mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-06-06 20:37:32 +00:00
36 lines
809 B
Vue
36 lines
809 B
Vue
<script setup lang="ts">
|
|
import { onMounted, ref } from 'vue';
|
|
|
|
defineProps({
|
|
modelValue: String,
|
|
name: String,
|
|
});
|
|
|
|
const input = ref<HTMLInputElement | null>(null);
|
|
|
|
onMounted(() => {
|
|
if (input.value?.hasAttribute('autofocus')) {
|
|
input.value?.focus();
|
|
}
|
|
});
|
|
|
|
defineExpose({ focus: () => input.value?.focus() });
|
|
|
|
const emit = defineEmits(['update:modelValue']);
|
|
|
|
function updateValue(event: Event) {
|
|
if (event.target && 'value' in event.target) {
|
|
emit('update:modelValue', event?.target?.value);
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<input
|
|
ref="input"
|
|
class="border-input-border bg-input-background text-white focus:border-input-border-active rounded-md shadow-sm"
|
|
:value="modelValue"
|
|
:name="name"
|
|
@input="updateValue" />
|
|
</template>
|