import type { Meta, StoryObj } from '@storybook/web-components-vite'; import { html } from 'lit'; import './usa-form-template.js'; const meta: Meta = { title: 'Templates/Form', component: 'usa-form-template', tags: ['autodocs'], parameters: { layout: 'fullscreen', docs: { description: { component: ` The form template provides a layout for single or multi-step forms. ## Features - Optional step indicator for multi-step forms - Form heading and subheading - Configurable action buttons (back, next, submit) - Optional sidebar - Government banner and identifier ## USWDS Reference https://designsystem.digital.gov/templates/form-templates/ `, }, }, }, argTypes: { heading: { control: 'text', description: 'Form heading', }, subheading: { control: 'text', description: 'Form subheading/description', }, showStepIndicator: { control: 'boolean', description: 'Show step indicator', }, currentStep: { control: 'number', description: 'Current step number (1-based)', }, totalSteps: { control: 'number', description: 'Total number of steps', }, showBackButton: { control: 'boolean', description: 'Show back button', }, submitText: { control: 'text', description: 'Submit button text', }, nextText: { control: 'text', description: 'Next button text', }, backText: { control: 'text', description: 'Back button text', }, showSidebar: { control: 'boolean', description: 'Show sidebar', }, sidebarPosition: { control: 'select', options: ['left', 'right'], description: 'Sidebar position', }, showBanner: { control: 'boolean', description: 'Show government banner', }, showIdentifier: { control: 'boolean', description: 'Show identifier', }, }, }; export default meta; type Story = StoryObj; export const SingleStepForm: Story = { args: { heading: 'Contact Information', subheading: 'Please provide your contact details.', submitText: 'Submit', showBanner: true, showIdentifier: true, }, render: (args) => html`
`, }; export const MultiStepForm: Story = { args: { heading: 'Application Form', showStepIndicator: true, currentStep: 2, totalSteps: 4, showBackButton: true, nextText: 'Continue', backText: 'Back', showBanner: true, showIdentifier: true, }, render: (args) => { const steps = [ { label: 'Personal Info', status: 'complete' as const }, { label: 'Contact Details', status: 'current' as const }, { label: 'Review', status: 'incomplete' as const }, { label: 'Submit', status: 'incomplete' as const }, ]; return html`

Contact Details

`; }, }; export const WithSidebar: Story = { args: { heading: 'Registration Form', subheading: 'Complete the form to register.', showSidebar: true, sidebarPosition: 'right', showBanner: true, showIdentifier: true, }, render: (args) => html`

Your information is secure and will not be shared with third parties.

Need Help?

Contact us at 1-800-555-1234

`, }; export const FirstStepOfMultiStep: Story = { args: { heading: 'New Application', showStepIndicator: true, currentStep: 1, totalSteps: 3, showBackButton: false, nextText: 'Continue', showBanner: true, showIdentifier: true, }, render: (args) => { const steps = [ { label: 'Personal Information', status: 'current' as const }, { label: 'Employment History', status: 'incomplete' as const }, { label: 'Review & Submit', status: 'incomplete' as const }, ]; return html`
`; }, }; export const FinalStepOfMultiStep: Story = { args: { heading: 'Review & Submit', showStepIndicator: true, currentStep: 3, totalSteps: 3, showBackButton: true, submitText: 'Submit Application', backText: 'Previous', showBanner: true, showIdentifier: true, }, render: (args) => { const steps = [ { label: 'Personal Information', status: 'complete' as const }, { label: 'Employment History', status: 'complete' as const }, { label: 'Review & Submit', status: 'current' as const }, ]; return html`

Review your information

Please review all the information below before submitting your application.

Personal Information

Name:
John Doe
Email:
john.doe@example.com

Employment History

Current Employer:
Acme Corporation
Position:
Software Developer
`; }, }; export const CustomActions: Story = { args: { heading: 'Custom Form Actions', showBanner: true, showIdentifier: true, }, render: (args) => html`
Save Draft Cancel Submit
`, }; export const WithPatterns: Story = { args: { heading: 'User Profile', subheading: 'Update your profile information', showBanner: true, showIdentifier: true, }, render: (args) => html`
`, }; export const MinimalForm: Story = { args: { heading: 'Quick Feedback', submitText: 'Send', showBanner: false, showIdentifier: false, }, render: (args) => html`
`, };