31 lines
642 B
Vue
31 lines
642 B
Vue
<script setup>
|
|
import { onMounted, ref } from "vue";
|
|
|
|
defineProps({
|
|
modelValue: {
|
|
type: String,
|
|
required: true,
|
|
},
|
|
});
|
|
|
|
defineEmits(["update:modelValue"]);
|
|
|
|
const input = ref(null);
|
|
|
|
onMounted(() => {
|
|
if (input.value.hasAttribute("autofocus")) {
|
|
input.value.focus();
|
|
}
|
|
});
|
|
|
|
defineExpose({ focus: () => input.value.focus() });
|
|
</script>
|
|
|
|
<template>
|
|
<input
|
|
class="border-gray-700 bg-zinc-900 text-gray-300 focus:border-sky-600 hover:border-sky-600 rounded-md"
|
|
:value="modelValue"
|
|
@input="$emit('update:modelValue', $event.target.value)"
|
|
ref="input"
|
|
/>
|
|
</template>
|