import { useState, type ReactNode } from "react" import type { Meta, StoryObj } from "@storybook/react-vite" import { DatePicker } from "@hm-design/ui" import { StateBoard } from "@/components/story-board" import { StoryPage, StoryPageHeader, StorySection } from "@/components/story-page" // DatePicker is a Popover + Calendar composition packaged as a component (value handling, trigger text, close on select). // The representative Story shows real pickers; the same specimens also exist as Stories tagged `verification` (hidden from the // sidebar). The Label is Story composition (the way a consumer would); `today` is pinned through Calendar's own prop so the // Story looks the same on any day. const today = new Date(2026, 9, 2) const calendarProps = { today, startMonth: new Date(2026, 0), endMonth: new Date(2027, 11) } function Field({ label, id, children }: { label: string; id: string; children: ReactNode }) { return (
{children}
) } function Empty() { return ( ) } function Selected() { return ( ) } function FormatExamples() { return (
date.toLocaleDateString("ko-KR")} calendarProps={calendarProps} />
) } function Controlled() { const [date, setDate] = useState() return (
{`value = ${date ? date.toLocaleDateString("ko-KR") : "undefined"}`}
) } function Medium() { return ( ) } function DisabledDates() { return ( ) } function Disabled() { return ( ) } const sections = [ { id: "empty", label: "Empty (placeholder)", node: }, { id: "selected", label: "Selected", node: }, { id: "format", label: "Default format / custom override", node: }, { id: "controlled", label: "Controlled", node: }, { id: "medium", label: "Medium size", node: }, { id: "disabled-dates", label: "Disabled dates", node: }, { id: "disabled", label: "Disabled", node: }, ] const meta = { title: "Components/Search & Date/Date Picker", component: DatePicker, 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: "Date Picker", parameters: { layout: "fullscreen", controls: { disable: true } }, render: () => ( {board("empty")} {board("medium")} {board("selected", "controlled", "disabled-dates", "disabled")} {board("format")} ), } export const EmptyPicker: Story = { tags: ["verification"], name: "Empty", render: () => } export const InvalidFocus: Story = { tags: ["verification"], render: () => (
), } export const SelectedPicker: Story = { tags: ["verification"], name: "Selected", render: () => } export const ControlledPicker: Story = { tags: ["verification"], name: "Controlled", render: () => }