import { useState, type ReactNode } from "react" import type { Meta, StoryObj } from "@storybook/react-vite" import type { DateRange } from "react-day-picker" import { Calendar } from "@hm-design/ui" import { StateBoard } from "@/components/story-board" import { StoryPage, StoryPageHeader, StorySection } from "@/components/story-page" // The representative "Calendar" Story shows each mode with real, clickable calendars; the same specimens also exist as Stories // tagged `verification` (hidden from the sidebar). `today` is pinned to 2026-10-02 so the Story looks the same on any day; this // uses react-day-picker's own `today` prop, not an HM state. Korean is the Calendar default locale. const today = new Date(2026, 9, 2) const month = new Date(2026, 9, 1) const box = (node: ReactNode) =>
{node}
// `showValue={false}` hides the value readout on the representative page; the verification Stories keep it. function Single({ showValue = true }: { showValue?: boolean }) { const [date, setDate] = useState(new Date(2026, 9, 15)) return (
{box()} {showValue ? {`선택: ${date ? date.toLocaleDateString("ko-KR") : "없음"}`} : null}
) } function DisabledDates() { const [date, setDate] = useState() return box( ) } function Range() { const [range, setRange] = useState({ from: new Date(2026, 9, 8), to: new Date(2026, 9, 14) }) return box() } function TwoMonths() { return box() } // Same 3-column track as the Form pages (1 column on narrow screens). Each cell is a one-specimen StateBoard so subtitles, dividers and // specimen tops line up; the wide Two months specimen takes two tracks (the full row on narrow screens). const Grid = ({ children }: { children: ReactNode }) => (
{children}
) const Cell = ({ id, label, wide, children }: { id: string; label: string; wide?: boolean; children: ReactNode }) => (
) // No `component`: Calendar props are a union of selection modes, so Stories without args would not type-check. const meta = { title: "Components/Search & Date/Calendar", 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: "Calendar", parameters: { layout: "fullscreen", controls: { disable: true } }, render: () => ( ), } export const SingleSelection: Story = { tags: ["verification"], name: "Single", render: () => } export const DisabledSelection: Story = { tags: ["verification"], name: "Disabled Dates", render: () => } export const RangeSelection: Story = { tags: ["verification"], name: "Range", render: () => }