adrema/resources/js/components/form/Textarea.vue

51 lines
1.3 KiB
Vue
Raw Permalink Normal View History

2021-04-10 19:45:11 +02:00
<template>
2024-06-28 14:04:20 +02:00
<label class="flex flex-col group" :for="id" :class="sizeClass(size)">
<f-label v-if="label" :required="required" :value="label"></f-label>
<div class="relative flex-none flex">
<textarea class="w-full h-full" :class="[fieldAppearance, paddingX, paddingY]" :rows="rows" @input="trigger" v-text="modelValue"></textarea>
<f-hint v-if="hint" :value="hint"></f-hint>
2021-04-10 19:45:11 +02:00
</div>
</label>
</template>
2023-12-26 00:44:49 +01:00
<script setup>
2024-02-02 01:05:45 +01:00
import useFieldSize from '../../composables/useFieldSize.js';
2023-12-26 00:44:49 +01:00
const emit = defineEmits(['update:modelValue']);
2024-06-28 14:04:20 +02:00
const {fieldAppearance, paddingX, paddingY, sizeClass} = useFieldSize();
2024-02-02 01:05:45 +01:00
2023-12-26 00:44:49 +01:00
const props = defineProps({
required: {
type: Boolean,
default: false,
2021-04-10 19:45:11 +02:00
},
2023-12-26 00:44:49 +01:00
size: {
2024-06-28 13:43:38 +02:00
type: String,
default: () => 'base',
2023-12-26 00:44:49 +01:00
},
rows: {
2024-06-28 13:43:38 +02:00
type: Number,
default: () => 4,
2021-04-10 19:45:11 +02:00
},
2023-12-26 00:44:49 +01:00
id: {
2024-06-28 13:43:38 +02:00
type: String,
2023-12-26 00:44:49 +01:00
required: true,
},
hint: {
2024-06-28 13:43:38 +02:00
type: String,
default: () => '',
2023-12-26 00:44:49 +01:00
},
modelValue: {
2024-06-28 13:43:38 +02:00
validator: (v) => typeof v === 'string' || v === null,
required: true,
2023-12-26 00:44:49 +01:00
},
label: {
2024-06-28 13:43:38 +02:00
type: String,
default: () => '',
2023-03-06 23:00:46 +01:00
},
2023-12-26 00:44:49 +01:00
});
function trigger(v) {
emit('update:modelValue', v.target.value);
}
2021-04-10 19:45:11 +02:00
</script>