1
0
Fork 1
mirror of https://github.com/hay-kot/homebox.git synced 2024-12-26 00:36:30 +00:00
homebox/frontend/components/Form/TextField.vue

57 lines
1.2 KiB
Vue
Raw Normal View History

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>
<input ref="input" v-model="value" :placeholder="placeholder" :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>
<input v-model="value" :placeholder="placeholder" 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,
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,
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,
},
placeholder: {
type: String,
default: "",
},
2022-09-01 22:32:03 +00:00
});
const input = ref<HTMLElement | null>(null);
whenever(
() => props.triggerFocus,
() => {
if (input.value) {
input.value.focus();
}
}
);
const value = useVModel(props, "modelValue");
2022-09-01 22:32:03 +00:00
</script>