|
18 | 18 | import InputComboboxOption from '@/components/form/InputComboboxOption.vue'; |
19 | 19 |
|
20 | 20 | const emit = defineEmits<{ |
21 | | - (e: 'update:modelValue', value: string): void; |
| 21 | + (e: 'update:modelValue', value: string | number): void; |
22 | 22 | }>(); |
23 | 23 | const props = withDefaults( |
24 | 24 | defineProps<{ |
25 | 25 | label?: string; |
26 | 26 | options?: Array<SelectItem>; |
27 | | - modelValue?: string; |
| 27 | + modelValue?: string | number | boolean; |
28 | 28 | requireOptionMatch?: boolean; |
29 | 29 | transformModelValue?: (newValue: SelectOption | null) => string; |
30 | 30 | class?: HTMLAttributes['class']; |
|
60 | 60 |
|
61 | 61 | if (!selectedItem && !props.requireOptionMatch) { |
62 | 62 | selectedItem = { |
63 | | - label: props.modelValue, |
| 63 | + label: String(props.modelValue), |
64 | 64 | value: props.modelValue, |
65 | 65 | }; |
66 | 66 | } |
|
76 | 76 | }); |
77 | 77 |
|
78 | 78 | const reference = useTemplateRef<HTMLElement | null>('reference'); |
79 | | - const query = ref(props.modelValue ?? ''); |
| 79 | + const query = ref(String(props.modelValue ?? '')); |
80 | 80 |
|
81 | 81 | const referenceCoordinates = computed(() => { |
82 | 82 | const coordinates = reference.value?.getBoundingClientRect(); |
|
88 | 88 | }); |
89 | 89 |
|
90 | 90 | function matchesQuery(query: MaybeRef<string>, item: MaybeRef<SelectOption>) { |
91 | | - const lowerQuery = unref(query).toLowerCase(); |
| 91 | + const lowerQuery = String(unref(query)).toLowerCase(); |
92 | 92 | const option = unref(item); |
93 | 93 |
|
94 | 94 | return ( |
95 | 95 | option.label.toLowerCase().includes(lowerQuery) || |
96 | | - option.value.toLowerCase().includes(lowerQuery) || |
| 96 | + option.value.toString().toLowerCase().includes(lowerQuery) || |
97 | 97 | (option.data?.keywords?.toLowerCase().includes(lowerQuery) ?? false) |
98 | 98 | ); |
99 | 99 | } |
|
0 commit comments