mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-19 06:21:46 +01:00
chore(CommandPalette): improve component
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
<UButton v-if="closeIcon" :icon="closeIcon" variant="transparent" class="absolute right-3" @click="onClear" />
|
||||
</div>
|
||||
|
||||
<ComboboxOptions v-if="groups.length" static hold class="relative flex-1 overflow-y-auto divide-y u-divide-gray-100 scroll-py-2">
|
||||
<ComboboxOptions v-if="groups.length" static hold class="relative flex-1 overflow-y-auto divide-y divide-gray-100 dark:divide-gray-800 scroll-py-2">
|
||||
<CommandPaletteGroup v-for="group of groups" :key="group.key" :group="group" />
|
||||
</ComboboxOptions>
|
||||
|
||||
@@ -126,7 +126,7 @@ function activateFirstOption () {
|
||||
}, 0)
|
||||
}
|
||||
|
||||
function onSelect (option) {
|
||||
function onSelect (option: Command) {
|
||||
if (option.disabled) {
|
||||
return
|
||||
}
|
||||
@@ -140,9 +140,11 @@ function onSelect (option) {
|
||||
emit('update:modelValue', option)
|
||||
|
||||
// waiting for modal to be closed
|
||||
setTimeout(() => {
|
||||
query.value = ''
|
||||
}, 300)
|
||||
if (!option.prevent) {
|
||||
setTimeout(() => {
|
||||
query.value = ''
|
||||
}, 300)
|
||||
}
|
||||
}
|
||||
|
||||
function onClear () {
|
||||
|
||||
4
src/runtime/types/command-palette.d.ts
vendored
4
src/runtime/types/command-palette.d.ts
vendored
@@ -1,4 +1,5 @@
|
||||
import type { UseFuseOptions } from '@vueuse/integrations/useFuse'
|
||||
import type { RouteLocationRaw } from 'vue-router'
|
||||
|
||||
export interface Command {
|
||||
prefix?: string
|
||||
@@ -9,6 +10,9 @@ export interface Command {
|
||||
avatar?: string
|
||||
chip?: string
|
||||
disabled?: boolean
|
||||
prevent?: boolean
|
||||
click?: Function
|
||||
to?: RouteLocationRaw
|
||||
shortcuts?: string[]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user