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) } // Label 14/20/500 in the default text color; a Disabled field keeps the secondary color at 0.6 (same as the Form pages). function Field({ label, id, disabled, children }: { label: string; id: string; disabled?: boolean; children: ReactNode }) { return (
{children}
) } function Empty() { return ( ) } function Selected() { return ( ) } function DefaultFormat() { return ( ) } function CustomFormat() { return ( date.toLocaleDateString("ko-KR")} calendarProps={calendarProps} /> ) } // `showValue={false}` hides the value readout on the representative page; the verification Stories keep it. function Controlled({ showValue = true }: { showValue?: boolean }) { const [date, setDate] = useState() return (
{showValue ? {`value = ${date ? date.toLocaleDateString("ko-KR") : "undefined"}`} : null}
) } function Medium() { return ( ) } function DisabledDates() { return ( ) } function Disabled() { return ( ) } // Same 3-column track as the Form pages (1 column on narrow screens). Each cell is a one-specimen StateBoard so subtitles, dividers and // fields line up; sections with fewer specimens leave the remaining tracks empty. const Grid = ({ children }: { children: ReactNode }) => (
{children}
) const Cell = ({ id, label, children }: { id: string; label: string; children: ReactNode }) => (
) const meta = { title: "Components/Search & Date/Date Picker", component: DatePicker, parameters: { layout: "padded" } } satisfies Meta export default meta type Story = StoryObj // 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: () => ( ), } 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: () => }