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E,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;IAC1C,YAAY,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;IAC7C,gBAAgB,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE;IAChD,gBAAgB,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE;IAChD,OAAO,EAAE,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IACrC,WAAW,EAAE,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;CAC1C,CAAC","sourcesContent":["import type { Meta, StoryFn } from '@storybook/react';\nimport { useState } from 'react';\nimport type { ChangeEvent, FormEvent } from 'react';\n\nimport {\n  Banner,\n  Button,\n  ThemeOverride,\n  Flex,\n  Form,\n  FormField,\n  Input\n} from '@pega/cosmos-react-core';\n\nimport { FormContent, ReadOnlyFormContent } from './Form.mocks';\n\nexport default {\n  title: 'Core/Form',\n  component: Form,\n  subcomponents: {\n    FormField\n  },\n  excludeStories: ['ConfigurableForm'],\n  args: {\n    heading: 'Form demo',\n    description: ''\n  },\n  argTypes: {\n    heading: { control: { type: 'text' } },\n    description: { control: { type: 'text' } }\n  }\n} as Meta;\ninterface FormStoryProps {\n  heading?: string;\n  description?: string;\n}\n\nexport const ReadOnlyOneColumnForm: StoryFn<FormStoryProps> = (args: FormStoryProps) => {\n  return (\n    <ReadOnlyFormContent\n      cols={1}\n      heading={args.heading}\n      description={args.description}\n      showActions\n    />\n  );\n};\n\nexport const OneColumnForm: StoryFn<FormStoryProps> = (args: FormStoryProps) => {\n  return <FormContent cols={1} heading={args.heading} description={args.description} showActions />;\n};\n\nexport const TwoColumnForm: StoryFn<FormStoryProps> = (args: FormStoryProps) => {\n  return <FormContent cols={2} heading={args.heading} description={args.description} showActions />;\n};\n\nexport const ThreeColumnForm: StoryFn<FormStoryProps> = (args: FormStoryProps) => {\n  return <FormContent cols={3} heading={args.heading} description={args.description} showActions />;\n};\n\nexport const SimpleFormDemo: StoryFn<FormStoryProps & { withBanners?: boolean }> = (\n  args: FormStoryProps & { withBanners?: boolean }\n) => {\n  const [inputValue, setInputValue] = useState('');\n  const [success, setSuccess] = useState('');\n\n  const actions = (\n    <>\n      <Button name='Cancel' variant='secondary' onClick={() => setInputValue('')}>\n        Cancel\n      </Button>\n      <Button name='Submit' type='submit' variant='primary'>\n        Submit\n      </Button>\n    </>\n  );\n\n  const successBanner = (\n    <Banner variant='success' messages={['Form submitted', `Input value: ${success}`]} />\n  );\n\n  const errorBanner = (\n    <Banner variant='urgent' messages={['All required fields in the form must be completed.']} />\n  );\n\n  const banner = success ? successBanner : errorBanner;\n\n  return (\n    <Form\n      banners={args.withBanners ? banner : undefined}\n      actions={actions}\n      heading={args.heading}\n      description={args.description}\n      onSubmit={(e: FormEvent) => {\n        e.preventDefault();\n        setSuccess(inputValue);\n        setInputValue('');\n      }}\n    >\n      <Flex container={{ direction: 'column', itemGap: 2 }}>\n        <Input\n          label='Name'\n          info='Enter your first name'\n          required\n          value={inputValue}\n          onChange={(e: ChangeEvent<HTMLInputElement>) => {\n            setSuccess('');\n            setInputValue(e.target.value);\n          }}\n        />\n      </Flex>\n    </Form>\n  );\n};\n\nSimpleFormDemo.args = {\n  withBanners: false\n};\n\nSimpleFormDemo.argTypes = {\n  withBanners: { control: { type: 'boolean' } }\n};\n\ninterface ConfigurableFormProps extends FormStoryProps {\n  foregroundColor?: string;\n  backgroundColor?: string;\n  borderColor?: string;\n  borderWidth?: string;\n  borderRadius?: number;\n  hoverBorderColor?: string;\n  focusBorderColor?: string;\n}\n\nexport const ConfigurableForm: StoryFn<ConfigurableFormProps> = (args: ConfigurableFormProps) => {\n  return (\n    <ThemeOverride\n      theme={{\n        components: {\n          'form-control': {\n            'foreground-color': args.foregroundColor,\n            'background-color': args.backgroundColor,\n            'border-color': args.borderColor,\n            'border-width': args.borderWidth,\n            'border-radius': args.borderRadius,\n            ':hover': {\n              'border-color': args.hoverBorderColor\n            },\n            ':focus': {\n              'border-color': args.focusBorderColor\n            }\n          }\n        }\n      }}\n    >\n      <FormContent cols={2} showActions />\n    </ThemeOverride>\n  );\n};\n\nConfigurableForm.args = {\n  foregroundColor: '#054a8a',\n  backgroundColor: '#e2f1ff',\n  borderColor: '#939393',\n  borderWidth: '0.0625rem',\n  borderRadius: 0.5,\n  hoverBorderColor: '#3f3f3f',\n  focusBorderColor: 'transparent'\n};\n\nConfigurableForm.argTypes = {\n  foregroundColor: { control: { type: 'color' } },\n  backgroundColor: { control: { type: 'color' } },\n  borderColor: { control: { type: 'color' } },\n  borderWidth: { control: { type: 'text' } },\n  borderRadius: { control: { type: 'number' } },\n  hoverBorderColor: { control: { type: 'color' } },\n  focusBorderColor: { control: { type: 'color' } },\n  heading: { table: { disable: true } },\n  description: { table: { disable: true } }\n};\n"]}