opnform/resources/js/components/forms/TextAreaInput.vue

57 lines
1.4 KiB
Vue
Raw Normal View History

2022-09-20 19:59:52 +00:00
<template>
2023-11-28 07:47:40 +00:00
<input-wrapper
2023-12-01 20:24:38 +00:00
v-bind="inputWrapperProps"
2023-11-28 07:47:40 +00:00
>
<template #label>
<slot name="label" />
</template>
2023-12-01 20:24:38 +00:00
<textarea :id="id?id:name" v-model="compVal" :disabled="disabled?true:null"
:class="[theme.default.input,{ '!ring-red-500 !ring-2': hasValidation && form.errors.has(name), '!cursor-not-allowed !bg-gray-200':disabled }]"
2022-09-20 19:59:52 +00:00
class="resize-y"
:name="name" :style="inputStyle"
:placeholder="placeholder"
:maxlength="maxCharLimit"
2022-09-20 19:59:52 +00:00
/>
2023-11-28 07:47:40 +00:00
<template v-if="maxCharLimit && showCharLimit" #bottom_after_help>
<small :class="theme.default.help">
2023-12-01 20:24:38 +00:00
{{ charCount }}/{{ maxCharLimit }}
</small>
2023-11-28 07:47:40 +00:00
</template>
<template #error>
<slot name="error" />
</template>
</input-wrapper>
2022-09-20 19:59:52 +00:00
</template>
<script>
2023-11-28 07:47:40 +00:00
import { inputProps, useFormInput } from './useFormInput.js'
import InputWrapper from './components/InputWrapper.vue'
2022-09-20 19:59:52 +00:00
export default {
name: 'TextAreaInput',
2023-11-28 07:47:40 +00:00
components: { InputWrapper },
mixins: [],
props: {
2023-11-28 07:47:40 +00:00
...inputProps,
maxCharLimit: { type: Number, required: false, default: null },
2023-12-01 20:24:38 +00:00
showCharLimit: { type: Boolean, required: false, default: false }
},
2023-11-28 07:47:40 +00:00
2023-12-01 20:24:38 +00:00
setup (props, context) {
2023-11-28 07:47:40 +00:00
return {
2023-12-01 20:24:38 +00:00
...useFormInput(props, context)
2023-11-28 07:47:40 +00:00
}
},
2023-12-01 20:24:38 +00:00
computed: {
2023-12-01 20:24:38 +00:00
charCount () {
return (this.compVal) ? this.compVal.length : 0
}
}
2022-09-20 19:59:52 +00:00
}
</script>