33 lang="ts"
44 generic ="
55 T extends BaseOption = ExtendedOption ,
6- Options extends T [] | OptionGroup <string , T >[] = T [] | OptionGroup <string , T >[]
6+ Options extends T [] | OptionGroup <string , T >[] = T [] | OptionGroup <string , T >[],
7+ ModelValue extends string = string
78 " >
89import { ref , computed , useAttrs } from ' vue'
910import { Listbox , ListboxButton } from ' @headlessui/vue'
@@ -43,7 +44,7 @@ const props = withDefaults(
4344 /**
4445 * the prop modelValue is required to use [v-model](https://vuejs.org/guide/components/events.html#usage-with-v-model) with a component.
4546 */
46- modelValue: string
47+ modelValue: ModelValue
4748 /**
4849 * direction in which the dropdown is opening.
4950 * possible values: `up`, `down`. Default is `down`
@@ -75,7 +76,7 @@ const props = withDefaults(
7576)
7677
7778const emit = defineEmits <{
78- ' update:modelValue' : [value : string ]
79+ ' update:modelValue' : [value : ModelValue ]
7980}>()
8081
8182const attrs = useAttrs ()
@@ -98,8 +99,8 @@ const flatOptions = computed((): T[] =>
9899)
99100
100101const model = computed ({
101- get : () => props .modelValue ,
102- set : (value : string ) => emit (' update:modelValue' , value )
102+ get : (): ModelValue => props .modelValue ,
103+ set : (value : ModelValue ) => emit (' update:modelValue' , value )
103104})
104105
105106const valueOption = computed (() => flatOptions .value .find (option => option .value === model .value ))
0 commit comments