Line data Source code
1 16 : <script setup lang="ts">
2 : import type { HTMLAttributes } from 'vue'
3 : import { useTemplateRef } from 'vue'
4 :
5 : import { cn } from '@comfyorg/tailwind-utils'
6 :
7 : const { class: className } = defineProps<{
8 : class?: HTMLAttributes['class']
9 : }>()
10 :
11 1473 : const modelValue = defineModel<string | number>()
12 :
13 1473 : const inputRef = useTemplateRef<HTMLInputElement>('inputEl')
14 :
15 1473 : defineExpose({
16 : focus: () => inputRef.value?.focus(),
17 : select: () => inputRef.value?.select(),
18 : blur: () => inputRef.value?.blur(),
19 : setSelectionRange: (start: number, end: number) =>
20 : inputRef.value?.setSelectionRange(start, end),
21 : selectAll: () =>
22 : inputRef.value?.setSelectionRange(0, inputRef.value.value.length)
23 : })
24 : </script>
25 :
26 : <template>
27 : <input
28 : ref="inputEl"
29 : v-model="modelValue"
30 : :class="
31 : cn(
32 : 'flex h-10 w-full min-w-0 appearance-none rounded-lg border-none bg-secondary px-4 py-2 text-sm text-foreground placeholder:text-muted-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50 aria-invalid:ring-1 aria-invalid:ring-destructive',
33 : className
34 : )
35 : "
36 : />
37 : </template>
|