import type { Meta, StoryObj } from '@storybook/web-components-vite'; import { html } from 'lit'; import './index.js'; import type { USAMemorableDate } from './usa-memorable-date.js'; const meta: Meta = { title: 'Forms/Memorable Date', component: 'usa-memorable-date', parameters: { layout: 'padded', docs: { description: { component: ` The USA Memorable Date component provides a three-field date input (month/day/year) that's more accessible and user-friendly than a single date field. This pattern helps users enter dates more accurately and reduces input errors. ## Features - Three separate fields for month, day, and year - Month dropdown with named months for clarity - Numeric validation for day and year fields - Automatic date validation - ISO date conversion for form submission - Accessible labels and hints - Support for required and disabled states `, }, }, }, argTypes: { month: { control: 'text', description: 'Selected month (01-12)', }, day: { control: 'text', description: 'Selected day (1-31)', }, year: { control: 'text', description: 'Selected year (4 digits)', }, name: { control: 'text', description: 'Base name for form fields', }, label: { control: 'text', description: 'Fieldset legend label', }, hint: { control: 'text', description: 'Helper text for the date fields', }, disabled: { control: 'boolean', description: 'Disable all date fields', }, required: { control: 'boolean', description: 'Mark fields as required', }, }, }; export default meta; type Story = StoryObj; export const Default: Story = { args: { label: 'Date of birth', name: 'birth-date', }, render: (args) => html` `, }; export const WithHint: Story = { args: { label: 'Date of birth', name: 'birth-date', hint: 'For example: 4 28 1986', }, render: (args) => html` `, }; export const Required: Story = { args: { label: 'Date of birth', name: 'birth-date', hint: 'For example: 4 28 1986', required: true, }, render: (args) => html` `, }; export const Prefilled: Story = { args: { label: 'Date of birth', name: 'birth-date', month: '07', day: '04', year: '1776', }, render: (args) => html` `, }; export const Disabled: Story = { args: { label: 'Date of birth', name: 'birth-date', month: '12', day: '25', year: '2000', disabled: true, }, render: (args) => html` `, }; export const InteractiveExample: Story = { parameters: { controls: { disable: true }, // Static demo - no interactive controls needed docs: { description: { story: 'Interactive demonstration showing real-time date validation and event handling.', }, }, }, render: () => html`

Date Information:

No date selected
`, }; export const FormIntegration: Story = { parameters: { controls: { disable: true }, // Static demo - no interactive controls needed docs: { description: { story: 'Example of memorable date component integrated with form controls and validation.', }, }, }, render: () => html`
`, }; export const AccessibilityDemo: Story = { parameters: { controls: { disable: true }, // Static demo - no interactive controls needed docs: { description: { story: 'Demonstrates the accessibility features built into the memorable date component.', }, }, }, render: () => html`

Accessibility Features Demo

This memorable date component includes:

  • Proper fieldset/legend structure for screen readers
  • Associated labels for each input field
  • aria-describedby linking hints to all fields
  • Numeric input mode for mobile keyboards
  • Clear visual indication of required fields
Try with a screen reader: The fieldset groups the three fields together, and each field announces its purpose (Month, Day, Year) along with the helper text.
`, };