| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <script setup>
- import { computed } from 'vue'
-
- const props = defineProps({
- label: {
- type: String,
- required: true,
- },
- disabled: {
- type: Boolean,
- default: false,
- },
- placeholder: {
- type: String,
- required: true,
- },
- error: {
- type: String,
- default: null,
- },
- rows: {
- type: Number,
- default: 5,
- },
- cols: {
- type: Number,
- default: 30,
- },
- modelValue: null,
- })
-
- defineEmits(['update:modelValue'])
-
- const isError = computed(() => (props.error ? true : false))
-
- const forLabel = computed(() => props.label.toLowerCase().replace(/\s+/g, '-'))
-
- const ariaDescribedbyLabel = computed(
- () => props.label.toLowerCase().replace(/\s+/g, '-') + '-help'
- )
- </script>
-
- <template>
- <div class="field">
- <label :for="forLabel">{{ label }}</label>
-
- <Textarea
- class="w-full"
- :class="{ 'p-invalid': isError }"
- :id="forLabel"
- :aria-describedby="ariaDescribedbyLabel"
- :model-value="modelValue"
- :value="modelValue"
- :placeholder="placeholder"
- :disabled="disabled"
- :auto-resize="true"
- :rows="rows"
- :cols="cols"
- @input="$emit('update:modelValue', $event.target.value)"
- />
-
- <small
- v-if="error"
- :id="ariaDescribedbyLabel"
- :class="{ 'p-error': isError }"
- >
- {{ error }}
- </small>
- </div>
- </template>
|