Files
supabase/packages/ui-patterns/CommandMenu/internal/CommandSection.tsx
Charis 1b89fa0b5c feat: command menu v2 ui components (#27761)
Co-authored-by: Francesco Sansalvadore <f.sansalvadore@gmail.com>
2024-07-16 14:14:03 -04:00

24 lines
491 B
TypeScript

import { type ICommand } from './Command'
type ICommandSection = {
id: string
name: string
commands: Array<ICommand>
forceMount?: boolean
}
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 }