2022-09-01 22:32:03 +00:00
|
|
|
<template>
|
2022-09-07 05:58:59 +00:00
|
|
|
<div v-if="!inline" class="form-control w-full">
|
2022-09-01 22:32:03 +00:00
|
|
|
<label class="label">
|
|
|
|
<span class="label-text">{{ label }}</span>
|
|
|
|
</label>
|
2022-09-09 22:46:53 +00:00
|
|
|
<input ref="input" v-model="value" :type="type" class="input input-bordered w-full" />
|
2022-09-01 22:32:03 +00:00
|
|
|
</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
|
|
|
<input v-model="value" class="input input-bordered col-span-3 w-full mt-2" />
|
2022-09-07 05:58:59 +00:00
|
|
|
</div>
|
2022-09-01 22:32:03 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
const props = defineProps({
|
2022-09-02 17:46:20 +00:00
|
|
|
label: {
|
2022-09-01 22:32:03 +00:00
|
|
|
type: String,
|
2022-09-09 22:46:53 +00:00
|
|
|
default: "",
|
2022-09-01 22:32:03 +00:00
|
|
|
},
|
2022-09-02 17:46:20 +00:00
|
|
|
modelValue: {
|
2022-09-07 05:58:59 +00:00
|
|
|
type: [String, Number],
|
2022-09-02 17:46:20 +00:00
|
|
|
default: null,
|
2022-09-01 22:32:03 +00:00
|
|
|
},
|
|
|
|
type: {
|
|
|
|
type: String,
|
2022-09-09 22:46:53 +00:00
|
|
|
default: "text",
|
2022-09-01 22:32:03 +00:00
|
|
|
},
|
|
|
|
triggerFocus: {
|
|
|
|
type: Boolean,
|
|
|
|
default: null,
|
|
|
|
},
|
2022-09-07 05:58:59 +00:00
|
|
|
inline: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2022-09-01 22:32:03 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
const input = ref<HTMLElement | null>(null);
|
|
|
|
|
|
|
|
whenever(
|
|
|
|
() => props.triggerFocus,
|
|
|
|
() => {
|
|
|
|
if (input.value) {
|
|
|
|
input.value.focus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2022-09-09 22:46:53 +00:00
|
|
|
const value = useVModel(props, "modelValue");
|
2022-09-01 22:32:03 +00:00
|
|
|
</script>
|