opnform-host-nginx/resources/js/components/forms/TextAreaInput.vue

65 lines
1.5 KiB
Vue
Raw Normal View History

2022-09-20 21:59:52 +02:00
<template>
2023-11-28 08:47:40 +01:00
<input-wrapper
v-bind="$props"
>
<template #label>
<slot name="label" />
</template>
2022-09-20 21:59:52 +02: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 21:59:52 +02:00
class="resize-y"
:name="name" :style="inputStyle"
:placeholder="placeholder"
:maxlength="maxCharLimit"
2022-09-20 21:59:52 +02:00
/>
2023-11-28 08:47:40 +01:00
<template v-if="maxCharLimit && showCharLimit" #bottom_after_help>
<small :class="theme.default.help">
{{ charCount }}/{{ maxCharLimit }}
</small>
2023-11-28 08:47:40 +01:00
</template>
<template #error>
<slot name="error" />
</template>
</input-wrapper>
2022-09-20 21:59:52 +02:00
</template>
<script>
2023-11-28 08:47:40 +01:00
import { inputProps, useFormInput } from './useFormInput.js'
import InputWrapper from './components/InputWrapper.vue'
2022-09-20 21:59:52 +02:00
export default {
name: 'TextAreaInput',
2023-11-28 08:47:40 +01:00
components: { InputWrapper },
mixins: [],
props: {
2023-11-28 08:47:40 +01:00
...inputProps,
maxCharLimit: { type: Number, required: false, default: null },
showCharLimit: { type: Boolean, required: false, default: false },
},
2023-11-28 08:47:40 +01: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 21:59:52 +02:00
}
</script>