diff --git a/src/runtime/components/CommandPalette.vue b/src/runtime/components/CommandPalette.vue index 50f7a9aa85..a6570037d8 100644 --- a/src/runtime/components/CommandPalette.vue +++ b/src/runtime/components/CommandPalette.vue @@ -7,7 +7,7 @@ import type { UseFuseOptions } from '@vueuse/integrations/useFuse' import theme from '#build/ui/command-palette' import type { UseComponentIconsProps } from '../composables/useComponentIcons' import type { AvatarProps, ButtonProps, ChipProps, KbdProps, InputProps, LinkProps, IconProps } from '../types' -import type { GetItemKeys } from '../types/utils' +import type { GetItemKeys, GetModelValue, GetModelValueEmits } from '../types/utils' import type { ComponentConfig } from '../types/tv' type CommandPalette = ComponentConfig @@ -58,7 +58,7 @@ export interface CommandPaletteGroup = CommandPaletteGroup, T extends CommandPaletteItem = CommandPaletteItem> extends Pick, Pick { +export interface CommandPaletteProps = CommandPaletteGroup, T extends CommandPaletteItem = CommandPaletteItem, VK extends GetItemKeys | undefined = undefined, M extends boolean = false> extends Pick, Pick { /** * The element or component this component should render as. * @defaultValue 'div' @@ -118,6 +118,10 @@ export interface CommandPaletteProps = CommandP */ backIcon?: IconProps['name'] groups?: G[] + /** The value of the InputMenu when initially rendered. Use when you do not need to control the state of the InputMenu. */ + defaultValue?: GetModelValue + /** The controlled value of the InputMenu. Can be binded-with with `v-model`. */ + modelValue?: GetModelValue /** * Options for [useFuse](https://vueuse.org/integrations/useFuse). * @defaultValue { @@ -136,13 +140,25 @@ export interface CommandPaletteProps = CommandP * @defaultValue 'label' */ labelKey?: GetItemKeys + /** + * When `items` is an array of objects, select the field to use as the value. + * @defaultValue 'undefined' + */ + valueKey?: VK + /** Whether multiple options can be selected or not. */ + multiple?: M & boolean + /** + * Use this to compare objects by a particular field, or pass your own + * comparison function for complete control over how objects are compared. + */ + by?: GetItemKeys | ((a: GetModelValue, b: GetModelValue) => boolean) class?: any ui?: CommandPalette['slots'] } -export type CommandPaletteEmits = ListboxRootEmits & { +export type CommandPaletteEmits | undefined = undefined, M extends boolean = false> = ListboxRootEmits & { 'update:open': [value: boolean] -} +} & GetModelValueEmits type SlotProps = (props: { item: T, index: number }) => any @@ -159,7 +175,9 @@ export type CommandPaletteSlots = CommandPalett -