2022-09-20 19:59:52 +00:00
|
|
|
<template>
|
|
|
|
<div :class="wrapperClass">
|
|
|
|
<label v-if="label" :for="id?id:name"
|
|
|
|
:class="[theme.default.label, {'uppercase text-xs':uppercaseLabels, 'text-sm':!uppercaseLabels}]"
|
|
|
|
>
|
|
|
|
{{ label }}
|
|
|
|
<span v-if="required" class="text-red-500 required-dot">*</span>
|
|
|
|
</label>
|
2023-04-19 08:13:50 +00:00
|
|
|
<div v-if="help && helpPosition=='above_input'" class="flex mb-1">
|
|
|
|
<small :class="theme.default.help" class="flex-grow">
|
|
|
|
<slot name="help"><span class="field-help" v-html="help" /></slot>
|
|
|
|
</small>
|
|
|
|
</div>
|
2022-09-20 19:59:52 +00:00
|
|
|
<textarea :id="id?id:name" v-model="compVal" :disabled="disabled"
|
2023-03-22 14:49:52 +00:00
|
|
|
: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"
|
2023-02-22 16:41:37 +00:00
|
|
|
:maxlength="maxCharLimit"
|
2022-09-20 19:59:52 +00:00
|
|
|
/>
|
2023-04-19 08:13:50 +00:00
|
|
|
<div v-if="(help && helpPosition=='below_input') || showCharLimit" class="flex">
|
|
|
|
<small v-if="help && helpPosition=='below_input'" :class="theme.default.help" class="flex-grow">
|
|
|
|
<slot name="help"><span class="field-help" v-html="help" /></slot>
|
2023-02-22 16:41:37 +00:00
|
|
|
</small>
|
|
|
|
<small v-else class="flex-grow"></small>
|
|
|
|
<small v-if="showCharLimit && maxCharLimit" :class="theme.default.help">
|
|
|
|
{{ charCount }}/{{ maxCharLimit }}
|
|
|
|
</small>
|
|
|
|
</div>
|
2022-09-20 19:59:52 +00:00
|
|
|
<has-error v-if="hasValidation" :form="form" :field="name" />
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-01-21 11:57:37 +00:00
|
|
|
import inputMixin from '~/mixins/forms/input.js'
|
2022-09-20 19:59:52 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'TextAreaInput',
|
2023-02-22 16:41:37 +00:00
|
|
|
mixins: [inputMixin],
|
|
|
|
|
|
|
|
props: {
|
|
|
|
maxCharLimit: { type: Number, required: false, default: null },
|
|
|
|
showCharLimit: { type: Boolean, required: false, default: false },
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
charCount() {
|
|
|
|
return (this.compVal) ? this.compVal.length : 0
|
|
|
|
}
|
|
|
|
}
|
2022-09-20 19:59:52 +00:00
|
|
|
}
|
|
|
|
</script>
|