import React, { useRef, useState } from 'react' import { type Meta, type StoryObj } from '@storybook/react' import { fn } from '@storybook/test' import isChromatic from 'chromatic' import { ModalAccessibleDescription } from '~components/Modal' import { Text } from '~components/Text' import { TextField } from '~components/TextField' import { chromaticModalSettings } from '../../_docs/controls' import { InputEditModal } from '../index' const IS_CHROMATIC = isChromatic() const ExampleForm = (): JSX.Element => ( <> Instructive text to drive user selection goes here.
) const meta = { title: 'Components/Modals/InputEditModal', component: InputEditModal, args: { isOpen: false, title: 'Your input is valuable', children: , submitLabel: 'Submit label', onSubmit: fn(), onDismiss: fn(), }, argTypes: { children: { control: { disable: true, }, }, }, } satisfies Meta export default meta type Story = StoryObj const InputModalTemplate: Story = { render: (args) => { const [isOpen, setIsOpen] = useState(IS_CHROMATIC) const handleOpen = (): void => setIsOpen(true) const handleClose = (): void => setIsOpen(false) return ( <> ) }, } export const Playground: Story = { ...InputModalTemplate, parameters: { docs: { canvas: { sourceState: 'shown', }, }, }, } export const Default: Story = { ...InputModalTemplate, ...chromaticModalSettings, } export const Unpadded: Story = { ...InputModalTemplate, args: { unpadded: true }, ...chromaticModalSettings, } export const OnAfterEnter: Story = { ...chromaticModalSettings, args: { title: 'Create new link', submitLabel: 'Add link', }, render: (args) => { const [isOpen, setIsOpen] = useState(IS_CHROMATIC) const inputRef = useRef(null) const handleOpen = (): void => setIsOpen(true) const handleClose = (): void => setIsOpen(false) return ( <> inputRef.current?.focus()} >
) }, parameters: { docs: { source: { code: ` // The label of the button and the input it is focused to may provide enough context. inputRef.current?.focus()} >
`, }, }, }, }