@@ -16,6 +16,7 @@ export interface CommandPaletteItem extends Omit<LinkProps, 'type' | 'raw' | 'cu
1616 prefix? : string
1717 label? : string
1818 suffix? : string
19+ description? : string
1920 /**
2021 * @IconifyIcon
2122 */
@@ -34,7 +35,7 @@ export interface CommandPaletteItem extends Omit<LinkProps, 'type' | 'raw' | 'cu
3435 children? : CommandPaletteItem []
3536 onSelect? : (e : Event ) => void
3637 class? : any
37- ui? : Pick <CommandPalette [' slots' ], ' item' | ' itemLeadingIcon' | ' itemLeadingAvatarSize' | ' itemLeadingAvatar' | ' itemLeadingChipSize' | ' itemLeadingChip' | ' itemLabel' | ' itemLabelPrefix' | ' itemLabelBase' | ' itemLabelSuffix' | ' itemTrailing' | ' itemTrailingKbds' | ' itemTrailingKbdsSize' | ' itemTrailingHighlightedIcon' | ' itemTrailingIcon' >
38+ ui? : Pick <CommandPalette [' slots' ], ' item' | ' itemLeadingIcon' | ' itemLeadingAvatarSize' | ' itemLeadingAvatar' | ' itemLeadingChipSize' | ' itemLeadingChip' | ' itemWrapper ' | ' itemLabel' | ' itemDescription ' | ' itemLabelPrefix' | ' itemLabelBase' | ' itemLabelSuffix' | ' itemTrailing' | ' itemTrailingKbds' | ' itemTrailingKbdsSize' | ' itemTrailingHighlightedIcon' | ' itemTrailingIcon' >
3839 [key : string ]: any
3940}
4041
@@ -153,6 +154,11 @@ export interface CommandPaletteProps<G extends CommandPaletteGroup<T> = CommandP
153154 * @defaultValue 'label'
154155 */
155156 labelKey? : GetItemKeys <T >
157+ /**
158+ * The key used to get the description from the item.
159+ * @defaultValue 'description'
160+ */
161+ descriptionKey? : GetItemKeys <T >
156162 class? : any
157163 ui? : CommandPalette [' slots' ]
158164}
@@ -171,6 +177,7 @@ export type CommandPaletteSlots<G extends CommandPaletteGroup<T> = CommandPalett
171177 ' item' : SlotProps <T >
172178 ' item-leading' : SlotProps <T >
173179 ' item-label' : SlotProps <T >
180+ ' item-description' : SlotProps <T >
174181 ' item-trailing' : SlotProps <T >
175182} & Record <string , SlotProps <G >> & Record <string , SlotProps <T >>
176183
@@ -200,6 +207,7 @@ import UKbd from './Kbd.vue'
200207const props = withDefaults (defineProps <CommandPaletteProps <G , T >>(), {
201208 modelValue: ' ' ,
202209 labelKey: ' label' ,
210+ descriptionKey: ' description' ,
203211 autofocus: true ,
204212 back: true ,
205213 virtualize: false
@@ -393,14 +401,22 @@ function onSelect(e: Event, item: T) {
393401 />
394402 </slot >
395403
396- <span v-if =" item.labelHtml || get(item, props.labelKey as string) || !!slots[(item.slot ? `${item.slot}-label` : group?.slot ? `${group.slot}-label` : `item-label`) as keyof CommandPaletteSlots<G, T>]" :class =" ui.itemLabel({ class: [props.ui?.itemLabel, item.ui?.itemLabel], active: active || item.active })" >
397- <slot :name =" ((item.slot ? `${item.slot}-label` : group?.slot ? `${group.slot}-label` : `item-label`) as keyof CommandPaletteSlots<G, T>)" :item =" (item as any)" :index =" index" :ui =" ui" >
398- <span v-if =" item.prefix" :class =" ui.itemLabelPrefix({ class: [props.ui?.itemLabelPrefix, item.ui?.itemLabelPrefix] })" >{{ item.prefix }}</span >
404+ <span v-if =" (item.prefix || (item.labelHtml || get(item, props.labelKey as string)) || (item.suffixHtml || item.suffix) || !!slots[(item.slot ? `${item.slot}-label` : group?.slot ? `${group.slot}-label` : `item-label`) as keyof CommandPaletteSlots<G, T>]) || (get(item, props.descriptionKey as string) || !!slots[(item.slot ? `${item.slot}-description` : group?.slot ? `${group.slot}-description` : `item-description`) as keyof CommandPaletteSlots<G, T>])" :class =" ui.itemWrapper({ class: [props.ui?.itemWrapper, item.ui?.itemWrapper] })" >
405+ <span :class =" ui.itemLabel({ class: [props.ui?.itemLabel, item.ui?.itemLabel], active: active || item.active })" >
406+ <slot :name =" ((item.slot ? `${item.slot}-label` : group?.slot ? `${group.slot}-label` : `item-label`) as keyof CommandPaletteSlots<G, T>)" :item =" (item as any)" :index =" index" :ui =" ui" >
407+ <span v-if =" item.prefix" :class =" ui.itemLabelPrefix({ class: [props.ui?.itemLabelPrefix, item.ui?.itemLabelPrefix] })" >{{ item.prefix }}</span >
399408
400- <span :class =" ui.itemLabelBase({ class: [props.ui?.itemLabelBase, item.ui?.itemLabelBase], active: active || item.active })" v-html =" item.labelHtml || get(item, props.labelKey as string)" />
409+ <span :class =" ui.itemLabelBase({ class: [props.ui?.itemLabelBase, item.ui?.itemLabelBase], active: active || item.active })" v-html =" item.labelHtml || get(item, props.labelKey as string)" />
401410
402- <span :class =" ui.itemLabelSuffix({ class: [props.ui?.itemLabelSuffix, item.ui?.itemLabelSuffix], active: active || item.active })" v-html =" item.suffixHtml || item.suffix" />
403- </slot >
411+ <span :class =" ui.itemLabelSuffix({ class: [props.ui?.itemLabelSuffix, item.ui?.itemLabelSuffix], active: active || item.active })" v-html =" item.suffixHtml || item.suffix" />
412+ </slot >
413+ </span >
414+
415+ <span v-if =" get(item, props.descriptionKey as string)" :class =" ui.itemDescription({ class: [props.ui?.itemDescription, item.ui?.itemDescription] })" >
416+ <slot :name =" ((item.slot ? `${item.slot}-description` : group?.slot ? `${group.slot}-description` : `item-description`) as keyof CommandPaletteSlots<G, T>)" :item =" (item as any)" :index =" index" :ui =" ui" >
417+ {{ get(item, props.descriptionKey as string) }}
418+ </slot >
419+ </span >
404420 </span >
405421
406422 <span :class =" ui.itemTrailing({ class: [props.ui?.itemTrailing, item.ui?.itemTrailing] })" >
0 commit comments