opnform-host-nginx/client/components/forms/TextAreaInput.vue

68 lines
1.4 KiB
Vue
Raw Normal View History

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