import { useMemo, useState } from 'react'
import { Button } from 'ui'
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 (
)
}
function CommandMenuTrigger() {
return (
)
}
export default function CommandMenuDemo() {
return (
}>
)
}