import { useState, type ReactNode } from "react" import type { Meta, StoryObj } from "@storybook/react-vite" import { CalendarIcon, SettingsIcon, UserIcon } from "lucide-react" import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut } from "@hm-design/ui" import { StateBoard } from "@/components/story-board" import { StoryPage, StoryPageHeader, StorySection } from "@/components/story-page" // The representative "Command" Story shows real, typeable lists; the same specimens also exist as Stories tagged `verification` // (hidden from the sidebar). Filtering is cmdk's. The bordered box is Story composition (Command draws no border of its own). // A selection log shows that Enter / click reach `onSelect`. const box = (node: ReactNode) =>
{node}
// `showValue={false}` hides the value readout on the representative page; the verification Stories keep it. function Basic({ showValue = true }: { showValue?: boolean }) { const [last, setLast] = useState("-") return (
{box( 결과가 없습니다. 사과 바나나 체리 (품절) 포도 )} {showValue ? {`선택: ${last}`} : null}
) } function Grouped() { return box( 결과가 없습니다. 일정 보기 프로필 ⌘P 환경설정 ⌘, 결제 (사용 불가) ) } function Long() { return box( 결과가 없습니다. {Array.from({ length: 30 }, (_, i) => ( {`항목 ${i + 1} — 긴 항목 이름도 줄바꿈 없이 한 줄로 이어질 수 있습니다`} ))} ) } const sections = [ { id: "basic", label: "Search", node: }, { id: "grouped", label: "Groups", node: }, { id: "long", label: "Long list", node: }, ] const meta = { title: "Components/Search & Date/Command", component: Command, parameters: { layout: "padded" } } satisfies Meta export default meta type Story = StoryObj const board = (...ids: string[]) => ( ids.includes(s.id)).map((s) => ({ id: s.id, label: s.label, children: s.node }))} /> ) // Representative Story: the common Story page; the sections group the same specimens. export const All: Story = { name: "Command", parameters: { layout: "fullscreen", controls: { disable: true } }, render: () => ( {board("basic")} {board("grouped")} {board("long")} ), } export const Search: Story = { tags: ["verification"], render: () => } export const GroupedList: Story = { tags: ["verification"], name: "Grouped", render: () => }