mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-30 11:47:55 +01:00
feat(CommandPalette): handle static groups (#1458)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
@@ -216,7 +216,7 @@ export default defineComponent({
|
|||||||
const commands = computed(() => {
|
const commands = computed(() => {
|
||||||
const commands: Command[] = []
|
const commands: Command[] = []
|
||||||
for (const group of props.groups) {
|
for (const group of props.groups) {
|
||||||
if (!group.search) {
|
if (!group.search && !group.static) {
|
||||||
commands.push(...(group.commands?.map(command => ({ ...command, group: group.key })) || []))
|
commands.push(...(group.commands?.map(command => ({ ...command, group: group.key })) || []))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -274,9 +274,14 @@ export default defineComponent({
|
|||||||
return getGroupWithCommands(group, [...commands])
|
return getGroupWithCommands(group, [...commands])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const staticGroups: Group[] = props.groups.filter((group) => group.static && group.commands?.length).map((group) => {
|
||||||
|
return getGroupWithCommands(group, group.commands)
|
||||||
|
})
|
||||||
|
|
||||||
return [
|
return [
|
||||||
...groups,
|
...groups,
|
||||||
...searchGroups
|
...searchGroups,
|
||||||
|
...staticGroups
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -24,5 +24,6 @@ export interface Group {
|
|||||||
commands?: Command[]
|
commands?: Command[]
|
||||||
search?: Function
|
search?: Function
|
||||||
filter?: Function
|
filter?: Function
|
||||||
|
static?: Boolean
|
||||||
[key: string]: any
|
[key: string]: any
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user