2022-09-01 22:32:03 +00:00
|
|
|
<template>
|
|
|
|
<div class="form-control w-full">
|
|
|
|
<label class="label">
|
|
|
|
<span class="label-text">{{ label }}</span>
|
|
|
|
</label>
|
|
|
|
<input ref="input" :type="type" v-model="value" class="input input-bordered w-full" />
|
|
|
|
</div>
|
|
|
|
</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-02 17:46:20 +00:00
|
|
|
default: '',
|
2022-09-01 22:32:03 +00:00
|
|
|
},
|
2022-09-02 17:46:20 +00:00
|
|
|
modelValue: {
|
2022-09-01 22:32:03 +00:00
|
|
|
type: String,
|
2022-09-02 17:46:20 +00:00
|
|
|
default: null,
|
2022-09-01 22:32:03 +00:00
|
|
|
},
|
|
|
|
type: {
|
|
|
|
type: String,
|
|
|
|
default: 'text',
|
|
|
|
},
|
|
|
|
triggerFocus: {
|
|
|
|
type: Boolean,
|
|
|
|
default: null,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
const input = ref<HTMLElement | null>(null);
|
|
|
|
|
|
|
|
whenever(
|
|
|
|
() => props.triggerFocus,
|
|
|
|
() => {
|
|
|
|
if (input.value) {
|
|
|
|
input.value.focus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
const value = useVModel(props, 'modelValue');
|
|
|
|
</script>
|