mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-15 04:29:37 +01:00
chore(CommandPalette): improve component
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
<Combobox
|
||||
:model-value="modelValue"
|
||||
:multiple="multiple"
|
||||
:nullable="nullable"
|
||||
@update:model-value="onSelect"
|
||||
>
|
||||
<div class="flex flex-col flex-1 min-h-0 divide-y divide-gray-100 dark:divide-gray-800">
|
||||
@@ -43,7 +42,6 @@ import { defu } from 'defu'
|
||||
import type { UseFuseOptions } from '@vueuse/integrations/useFuse'
|
||||
import type { Group, Command } from '../../types/command-palette'
|
||||
import CommandPaletteGroup from './CommandPaletteGroup.vue'
|
||||
import { useRouter } from '#imports'
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
@@ -54,10 +52,6 @@ const props = defineProps({
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
nullable: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
groups: {
|
||||
type: Array as PropType<Group[]>,
|
||||
default: () => []
|
||||
@@ -124,16 +118,14 @@ function activateFirstOption () {
|
||||
}, 0)
|
||||
}
|
||||
|
||||
function onSelect (option: Command) {
|
||||
if (option.disabled) {
|
||||
return
|
||||
}
|
||||
|
||||
function onSelect (option: Command | Command[]) {
|
||||
emit('update:modelValue', option)
|
||||
|
||||
// waiting for modal to be closed
|
||||
if (!option.prevent) {
|
||||
query.value = ''
|
||||
// Clear input after selection
|
||||
if (!props.multiple) {
|
||||
setTimeout(() => {
|
||||
query.value = ''
|
||||
}, 0)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1
src/runtime/types/command-palette.d.ts
vendored
1
src/runtime/types/command-palette.d.ts
vendored
@@ -9,7 +9,6 @@ export interface Command {
|
||||
avatar?: string
|
||||
chip?: string
|
||||
disabled?: boolean
|
||||
prevent?: boolean
|
||||
shortcuts?: string[]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user