import * as React from 'react'; import type { Meta, StoryObj } from '@storybook/react-vite'; import { CalendarIcon, SettingsIcon, SmileIcon, UserIcon } from 'lucide-react'; import { Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, } from './command'; import { Button } from '../button/button'; const meta = { title: 'Components/Command', component: Command, parameters: { layout: 'centered', docs: { description: { component: 'Filterable command list. Use it inline for a searchable list, or wrap it in `CommandDialog` for a ⌘K palette. Each item declares the text it is matched on through `value`, plus optional `keywords` for synonyms the label does not contain.', }, }, }, tags: ['autodocs'], } satisfies Meta; export default meta; type Story = StoryObj; export const Inline: Story = { render: () => ( No results found. Calendar Search emoji Profile ⌘P Preferences ⌘, ), }; /** `keywords` match terms the visible label does not contain. */ export const WithKeywords: Story = { render: () => ( No results found. Toggle theme Sign out Billing (unavailable) ), }; /** The palette pattern: bind ⌘K yourself and let the dialog handle the rest. */ export const Palette: Story = { render: function PaletteStory() { const [open, setOpen] = React.useState(false); React.useEffect(() => { const onKeyDown = (event: KeyboardEvent) => { if (event.key === 'k' && (event.metaKey || event.ctrlKey)) { event.preventDefault(); setOpen((value) => !value); } }; document.addEventListener('keydown', onKeyDown); return () => document.removeEventListener('keydown', onKeyDown); }, []); return ( <> No results found. setOpen(false)}> Go to dashboard setOpen(false)}> Go to settings ); }, };