mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 18:05:11 +03:00
## Problem The `ui-patterns/CommandMenu` exposes internal components that have the same names as the base shadcn components they wrap. This create confusion about which one to use and forces us to expose the base ones with the `_Shadcn_` suffix. ## Solution Rename those internal components to have `CommandMenu` in their names to make it clearer they are meant to be used with `CommandMenu`. We will then rename the shadcn base ones to remove the suffix. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Refactor * Standardized Command Menu component naming across the design system for improved consistency and clarity. Updated component names: `CommandInput` → `CommandMenuInput`, `CommandList` → `CommandMenuList`, `CommandItem` → `CommandMenuItem`, `CommandEmpty` → `CommandMenuEmpty`, and `CommandGroup` → `CommandMenuGroup`. Updated public API exports, internal subpath references, all examples within the registry, and implementations across documentation, studio, and application interfaces. <!-- review_stack_entry_start --> [](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/45996) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
71 lines
1.5 KiB
TypeScript
71 lines
1.5 KiB
TypeScript
import { Button } from '@ui/components/shadcn/ui/button'
|
|
import { useMemo, useState } from 'react'
|
|
import {
|
|
CommandMenu,
|
|
CommandMenuInput,
|
|
CommandMenuList,
|
|
CommandMenuTrigger as CommandMenuTriggerPrimitive,
|
|
CommandProvider,
|
|
useRegisterCommands,
|
|
} from 'ui-patterns/CommandMenu'
|
|
|
|
function Commands() {
|
|
const [activeCommand, setActiveCommand] = useState(1)
|
|
|
|
const toggleCommands = () => setActiveCommand((state) => (state === 1 ? 2 : 1))
|
|
|
|
const commandOne = useMemo(
|
|
() => [
|
|
{
|
|
id: 'one',
|
|
name: 'One',
|
|
action: () => alert('One'),
|
|
},
|
|
],
|
|
[]
|
|
)
|
|
|
|
const commandTwo = useMemo(
|
|
() => [
|
|
{
|
|
id: 'two',
|
|
name: 'Two',
|
|
action: () => alert('Two'),
|
|
},
|
|
],
|
|
[]
|
|
)
|
|
|
|
const command = activeCommand === 1 ? commandOne : commandTwo
|
|
|
|
useRegisterCommands('Commands', command, { deps: [command] })
|
|
|
|
return (
|
|
<Button onClick={toggleCommands}>
|
|
{activeCommand === 1 ? 'Change command to command two' : 'Change command to command one'}
|
|
</Button>
|
|
)
|
|
}
|
|
|
|
function CommandMenuTrigger() {
|
|
return (
|
|
<CommandMenuTriggerPrimitive>
|
|
<Button>Open command menu</Button>
|
|
</CommandMenuTriggerPrimitive>
|
|
)
|
|
}
|
|
|
|
export default function CommandMenuDemo() {
|
|
return (
|
|
<CommandProvider openKey="">
|
|
<div className="flex flex-col gap-2">
|
|
<CommandMenu trigger={<CommandMenuTrigger />}>
|
|
<CommandMenuInput />
|
|
<CommandMenuList />
|
|
</CommandMenu>
|
|
<Commands />
|
|
</div>
|
|
</CommandProvider>
|
|
)
|
|
}
|