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

55 lines
1.5 KiB
Vue
Raw Normal View History

2021-04-10 19:45:11 +02:00
<template>
2024-01-01 17:55:13 +01:00
<label class="flex flex-col">
2024-02-02 01:05:45 +01:00
<span v-if="label" class="font-semibold text-gray-400" :class="labelClass(size)">{{ label }}<span v-show="required" class="text-red-800">&nbsp;*</span></span>
2024-01-01 17:55:13 +01:00
<div class="relative w-full h-full">
2024-02-02 01:05:45 +01:00
<textarea :placeholder="placeholder" class="h-full w-full outline-none" :class="[defaultFieldClass, fieldClass(size)]" :rows="rows" @input="trigger" v-text="modelValue"></textarea>
2024-01-01 17:55:13 +01:00
<div v-if="hint" v-tooltip="hint" class="absolute right-0 top-0 mr-2 mt-2">
<ui-sprite src="info-button" class="w-5 h-5 text-indigo-200"></ui-sprite>
</div>
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-02-02 01:05:45 +01:00
const {labelClass, fieldClass, defaultFieldClass} = useFieldSize();
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: {
default: null,
},
rows: {
default: function () {
return 4;
2023-03-06 23:00:46 +01:00
},
2021-04-10 19:45:11 +02:00
},
2023-12-26 00:44:49 +01:00
id: {
required: true,
},
hint: {
default: null,
},
modelValue: {
default: undefined,
},
label: {
default: false,
},
placeholder: {
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);
}
if (typeof props.modelValue === 'undefined') {
emit('update:modelValue', '');
}
2021-04-10 19:45:11 +02:00
</script>