Files
supabase/packages/ui-patterns/CommandMenu/internal/CommandSection.tsx
Charis 4fbcd61e95 feat: new command menu pt 1 (#23699)
Introduces the first (very small) slice of the new command menu as a `ui-pattern`.

This slice just handles state for available commands. It isn't hooked up to anything yet.
2024-06-04 14:32:13 -04:00

24 lines
490 B
TypeScript

import { type ICommand } from './Command'
type ICommandSection = {
id: string
name: string
forceMount: boolean
commands: Array<ICommand>
}
const toSectionId = (str: string) => str.toLowerCase().replace(/\s+/g, '-')
const section$new = (
name: string,
{ forceMount = false, id }: { forceMount?: boolean; id?: string } = {}
): ICommandSection => ({
id: id ?? toSectionId(name),
name,
forceMount,
commands: [],
})
export { section$new }
export type { ICommandSection }