import type { Meta, StoryObj } from "@storybook/react"; import { useState } from "react"; import { SmartDateTimePicker } from "./smart-datetime-picker"; const meta: Meta = { title: "Widgets/SmartDateTimePicker", component: SmartDateTimePicker, parameters: { layout: "centered", }, tags: ["autodocs"], argTypes: { value: { control: false }, onChange: { action: "changed" }, includeTime: { control: "boolean" }, disabled: { control: "boolean" }, }, decorators: [ (Story) => (
), ], }; export default meta; type Story = StoryObj; // Wrapper to handle state function SmartDateTimePickerWithState( props: React.ComponentProps, ) { const [value, setValue] = useState(props.value); return ; } // ============================================================================= // DEFAULT // ============================================================================= export const Default: Story = { render: (args) => , args: { placeholder: "Enter a date or time...", }, }; // ============================================================================= // WITH TIME // ============================================================================= export const WithTime: Story = { name: "With Time", render: (args) => , args: { placeholder: "Enter a date and time...", includeTime: true, }, }; // ============================================================================= // WITH INITIAL VALUE // ============================================================================= export const WithInitialValue: Story = { name: "With Initial Value", render: (args) => , args: { value: new Date(), }, }; // ============================================================================= // WITH DATE CONSTRAINTS // ============================================================================= export const WithMinDate: Story = { name: "With Min Date (Today)", render: (args) => , args: { placeholder: "Select a future date...", minDate: new Date(), }, }; export const WithMaxDate: Story = { name: "With Max Date", render: (args) => , args: { placeholder: "Select a date before end of month...", maxDate: new Date(new Date().getFullYear(), new Date().getMonth() + 1, 0), }, }; export const WithDateRange: Story = { name: "With Date Range", render: (args) => , args: { placeholder: "Select a date this month...", minDate: new Date(new Date().getFullYear(), new Date().getMonth(), 1), maxDate: new Date(new Date().getFullYear(), new Date().getMonth() + 1, 0), }, }; // ============================================================================= // DISABLED // ============================================================================= export const Disabled: Story = { args: { placeholder: "Cannot select date...", disabled: true, }, }; // ============================================================================= // NATURAL LANGUAGE EXAMPLES // ============================================================================= export const NaturalLanguageHints: Story = { name: "Natural Language Examples", render: () => (

Try typing natural language dates like:

  • tomorrow
  • next friday
  • in 3 days
  • 2024-12-25
  • december 25
), };