import * as React from 'react'; import type { Meta, StoryObj } from '@storybook/react-vite'; import { DatePicker, DateRangePicker } from './date-picker'; import { Label } from '../label/label'; const meta = { title: 'Components/DatePicker', component: DatePicker, parameters: { layout: 'centered', docs: { description: { component: 'Date, month or year picker. A calendar is more than a grid: keyboard navigation across month boundaries, locale-aware week starts, disabled ranges, and text entry that has to parse as loosely as people type. All of it is local to the kit and built on `Date` + `Intl`, so values are plain `Date` objects in local time and no date library reaches the consumer.', }, }, }, tags: ['autodocs'], decorators: [(Story) =>
], } satisfies Meta; export default meta; type Story = StoryObj; export const Default: Story = { args: { placeholder: 'Select a date' }, }; export const Controlled: Story = { render: function ControlledStory() { const [value, setValue] = React.useState(new Date()); return (

{value ? value.toDateString() : 'Nothing selected'}

); }, }; /** `picker` switches the panel; give it a matching `format` for the input. */ export const Granularity: Story = { render: () => (
), }; /** `locale` drives month names, weekday names and where the week starts. */ export const Localised: Story = { render: () => (
), }; /** Past dates are rejected — useful for scheduling. */ export const DisabledPastDates: Story = { args: { placeholder: 'Pick a future date', disabledDate: (current: Date) => current < new Date(new Date().setHours(0, 0, 0, 0)), }, }; export const Disabled: Story = { args: { disabled: true, value: new Date() }, }; export const Range: Story = { render: function RangeStory() { const [range, setRange] = React.useState<[Date | null, Date | null] | null>(null); return (

{range?.[0] && range?.[1] ? `${range[0].toDateString()} → ${range[1].toDateString()}` : 'No range selected'}

); }, };