1
1
<script lang="ts">
2
- import type { ListboxRootProps , ListboxRootEmits } from ' reka-ui'
2
+ import type { AcceptableValue , ListboxRootProps , ListboxRootEmits } from ' reka-ui'
3
3
import type { FuseResult } from ' fuse.js'
4
4
import type { AppConfig } from ' @nuxt/schema'
5
5
import type { UseFuseOptions } from ' @vueuse/integrations/useFuse'
@@ -30,7 +30,7 @@ export interface CommandPaletteItem extends Omit<LinkProps, 'type' | 'raw' | 'cu
30
30
onSelect? (e ? : Event ): void
31
31
}
32
32
33
- export interface CommandPaletteGroup <T > {
33
+ export interface CommandPaletteGroup <T extends CommandPaletteItem = CommandPaletteItem > {
34
34
id: string
35
35
label? : string
36
36
slot? : string
@@ -47,7 +47,7 @@ export interface CommandPaletteGroup<T> {
47
47
highlightedIcon? : string
48
48
}
49
49
50
- export interface CommandPaletteProps <G , T > extends Pick <ListboxRootProps , ' multiple' | ' disabled' | ' modelValue' | ' defaultValue' | ' highlightOnHover' >, Pick <UseComponentIconsProps , ' loading' | ' loadingIcon' > {
50
+ export interface CommandPaletteProps <T extends CommandPaletteItem = CommandPaletteItem , G extends CommandPaletteGroup < T > = CommandPaletteGroup < T > > extends Pick <ListboxRootProps , ' multiple' | ' disabled' | ' modelValue' | ' defaultValue' | ' highlightOnHover' >, Pick <UseComponentIconsProps , ' loading' | ' loadingIcon' > {
51
51
/**
52
52
* The element or component this component should render as.
53
53
* @defaultValue 'div'
@@ -108,13 +108,13 @@ export interface CommandPaletteProps<G, T> extends Pick<ListboxRootProps, 'multi
108
108
ui? : PartialString <typeof commandPalette .slots >
109
109
}
110
110
111
- export type CommandPaletteEmits <T > = ListboxRootEmits <T > & {
111
+ export type CommandPaletteEmits <T extends AcceptableValue = AcceptableValue > = ListboxRootEmits <T > & {
112
112
' update:open' : [value : boolean ]
113
113
}
114
114
115
- type SlotProps <T > = (props : { item: T , index: number }) => any
115
+ type SlotProps <T extends CommandPaletteItem = CommandPaletteItem > = (props : { item: T , index: number }) => any
116
116
117
- export type CommandPaletteSlots <G extends { slot ? : string }, T extends { slot ? : string } > = {
117
+ export type CommandPaletteSlots <T extends CommandPaletteItem = CommandPaletteItem , G extends CommandPaletteGroup < T > = CommandPaletteGroup < T > > = {
118
118
' empty' (props : { searchTerm? : string }): any
119
119
' close' (props : { ui: any }): any
120
120
' item' : SlotProps <T >
@@ -126,7 +126,7 @@ export type CommandPaletteSlots<G extends { slot?: string }, T extends { slot?:
126
126
extendDevtoolsMeta ({ example: ' CommandPaletteExample' , ignoreProps: [' groups' ] })
127
127
</script >
128
128
129
- <script setup lang="ts" generic =" G extends CommandPaletteGroup <T >, T extends CommandPaletteItem " >
129
+ <script setup lang="ts" generic =" T extends CommandPaletteItem = CommandPaletteItem , G extends CommandPaletteGroup <T > = CommandPaletteGroup < T > " >
130
130
import { computed } from ' vue'
131
131
import { ListboxRoot , ListboxFilter , ListboxContent , ListboxGroup , ListboxGroupLabel , ListboxItem , ListboxItemIndicator , useForwardProps , useForwardPropsEmits } from ' reka-ui'
132
132
import { defu } from ' defu'
@@ -146,13 +146,13 @@ import ULink from './Link.vue'
146
146
import UInput from ' ./Input.vue'
147
147
import UKbd from ' ./Kbd.vue'
148
148
149
- const props = withDefaults (defineProps <CommandPaletteProps <G , T >>(), {
149
+ const props = withDefaults (defineProps <CommandPaletteProps <T , G >>(), {
150
150
modelValue: ' ' ,
151
151
labelKey: ' label' ,
152
152
autofocus: true
153
153
})
154
154
const emits = defineEmits <CommandPaletteEmits <T >>()
155
- const slots = defineSlots <CommandPaletteSlots <G , T >>()
155
+ const slots = defineSlots <CommandPaletteSlots <T , G >>()
156
156
157
157
const searchTerm = defineModel <string >(' searchTerm' , { default: ' ' })
158
158
0 commit comments