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

65 lines
1.5 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
v-bind="$props"
>
<template #label>
<slot name="label" />
</template>
2022-09-20 19:59:52 +00:00
<textarea :id="id?id:name" v-model="compVal" :disabled="disabled"
: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">
{{ 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 },
showCharLimit: { type: Boolean, required: false, default: false },
},
2023-11-28 07:47:40 +00:00
setup (props, context) {
const {
compVal,
inputStyle,
hasValidation,
hasError
} = useFormInput(props, context)
return {
compVal,
inputStyle,
hasValidation,
hasError
}
},
computed: {
charCount() {
return (this.compVal) ? this.compVal.length : 0
}
}
2022-09-20 19:59:52 +00:00
}
</script>