From c82828d889640eff752710f6348302eb758598c1 Mon Sep 17 00:00:00 2001 From: HugoRCD Date: Thu, 3 Jul 2025 17:07:16 +0200 Subject: [PATCH] up --- .../app/pages/components/command-palette.vue | 1 + src/runtime/components/CommandPalette.vue | 31 +++++++++---------- src/theme/command-palette.ts | 2 +- .../CommandPalette-vue.spec.ts.snap | 10 ++++-- .../__snapshots__/CommandPalette.spec.ts.snap | 10 +++--- 5 files changed, 30 insertions(+), 24 deletions(-) diff --git a/playground/app/pages/components/command-palette.vue b/playground/app/pages/components/command-palette.vue index 6b06a24e..1e359ec9 100644 --- a/playground/app/pages/components/command-palette.vue +++ b/playground/app/pages/components/command-palette.vue @@ -157,6 +157,7 @@ defineShortcuts({ v-model="selected" v-model:search-term="searchTerm" :loading="status === 'pending'" + trailing-icon="i-lucide-settings" :groups="groups" :fuse="{ fuseOptions: { diff --git a/src/runtime/components/CommandPalette.vue b/src/runtime/components/CommandPalette.vue index 1632dac7..b3be9730 100644 --- a/src/runtime/components/CommandPalette.vue +++ b/src/runtime/components/CommandPalette.vue @@ -80,7 +80,7 @@ export interface CommandPaletteProps = CommandP * @defaultValue appConfig.ui.icons.chevronRight * @IconifyIcon */ - trailingIcon?: string + itemTrailingIcon?: string /** * The placeholder text for the input. * @defaultValue t('commandPalette.placeholder') @@ -91,6 +91,12 @@ export interface CommandPaletteProps = CommandP * @defaultValue true */ autofocus?: boolean + /** + * The icon displayed in the input. + * @defaultValue appConfig.ui.icons.search + * @IconifyIcon + */ + trailingIcon?: string /** * Display a close button in the input (useful when inside a Modal for example). * `{ size: 'md', color: 'neutral', variant: 'ghost' }`{lang="ts-type"} @@ -116,11 +122,6 @@ export interface CommandPaletteProps = CommandP * @IconifyIcon */ backIcon?: string - /** - * Display a trailing icon in the input. - * @IconifyIcon - */ - inputTrailingIcon?: string groups?: G[] /** * Options for [useFuse](https://vueuse.org/integrations/useFuse). @@ -153,8 +154,9 @@ type SlotProps = (props: { item: T, index: number }) => any export type CommandPaletteSlots = CommandPaletteGroup, T extends CommandPaletteItem = CommandPaletteItem> = { 'empty'(props: { searchTerm?: string }): any 'back'(props: { ui: { [K in keyof Required]: (props?: Record) => string } }): any + 'trailing'(props: { ui: { [K in keyof Required]: (props?: Record) => string } }): any + 'actions'(props: { ui: { [K in keyof Required]: (props?: Record) => string } }): any 'close'(props: { ui: { [K in keyof Required]: (props?: Record) => string } }): any - 'input-trailing'(props: { ui: { [K in keyof Required]: (props?: Record) => string } }): any 'item': SlotProps 'item-leading': SlotProps 'item-label': SlotProps @@ -342,6 +344,7 @@ function onSelect(e: Event, item: T) { :autofocus="autofocus" v-bind="inputProps" :icon="icon || appConfig.ui.icons.search" + :trailing-icon="trailingIcon" :class="ui.input({ class: props.ui?.input })" @keydown.backspace="onBackspace" > @@ -359,15 +362,11 @@ function onSelect(e: Event, item: T) { -