2022-09-02 17:46:20 +00:00
|
|
|
<template>
|
2022-09-09 22:46:53 +00:00
|
|
|
<div v-if="!inline" class="form-control">
|
2022-09-02 17:46:20 +00:00
|
|
|
<label class="label">
|
|
|
|
<span class="label-text">{{ label }}</span>
|
|
|
|
</label>
|
2022-09-09 22:46:53 +00:00
|
|
|
<textarea v-model="value" class="textarea textarea-bordered h-24" :placeholder="placeholder" />
|
2022-09-02 17:46:20 +00:00
|
|
|
<label v-if="limit" class="label">
|
|
|
|
<span class="label-text-alt"></span>
|
|
|
|
<span class="label-text-alt"> {{ valueLen }}/{{ limit }}</span>
|
|
|
|
</label>
|
|
|
|
</div>
|
2022-09-07 05:58:59 +00:00
|
|
|
<div v-else class="sm:grid sm:grid-cols-4 sm:items-start sm:gap-4">
|
|
|
|
<label class="label">
|
|
|
|
<span class="label-text">{{ label }}</span>
|
|
|
|
</label>
|
2022-09-09 22:46:53 +00:00
|
|
|
<textarea
|
|
|
|
v-model="value"
|
|
|
|
class="textarea textarea-bordered col-span-3 mt-3 h-24"
|
|
|
|
auto-grow
|
|
|
|
:placeholder="placeholder"
|
|
|
|
/>
|
2022-09-07 05:58:59 +00:00
|
|
|
</div>
|
2022-09-02 17:46:20 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2022-09-09 22:46:53 +00:00
|
|
|
const emit = defineEmits(["update:modelValue"]);
|
2022-09-02 17:46:20 +00:00
|
|
|
const props = defineProps({
|
|
|
|
modelValue: {
|
2022-09-07 05:58:59 +00:00
|
|
|
type: [String],
|
2022-09-02 17:46:20 +00:00
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
label: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
type: {
|
|
|
|
type: String,
|
2022-09-09 22:46:53 +00:00
|
|
|
default: "text",
|
2022-09-02 17:46:20 +00:00
|
|
|
},
|
|
|
|
limit: {
|
|
|
|
type: [Number, String],
|
|
|
|
default: null,
|
|
|
|
},
|
|
|
|
placeholder: {
|
|
|
|
type: String,
|
2022-09-09 22:46:53 +00:00
|
|
|
default: "",
|
2022-09-02 17:46:20 +00:00
|
|
|
},
|
2022-09-07 05:58:59 +00:00
|
|
|
inline: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2022-09-02 17:46:20 +00:00
|
|
|
});
|
|
|
|
|
2022-09-09 22:46:53 +00:00
|
|
|
const value = useVModel(props, "modelValue", emit);
|
2022-09-02 17:46:20 +00:00
|
|
|
const valueLen = computed(() => {
|
|
|
|
return value.value ? value.value.length : 0;
|
|
|
|
});
|
|
|
|
</script>
|