import { useState } from 'react'; import { createSandboxStory, globalScope, } from '../../../.storybook/components/sandbox/SandboxEditor'; import InputWithDisplayFormat, { InputWithDisplayFormatProps } from '..'; import Field, { FieldProps } from '../../Field/Field'; import { Meta, type StoryObj } from '@storybook/react-webpack5'; import { fn } from 'storybook/test'; type Story = StoryObj; const meta: Meta = { title: 'Forms/InputWithDisplayFormat', component: InputWithDisplayFormat, render: function Render({ label, ...args }: InputWithDisplayFormatProps & FieldProps) { return ( ); }, args: { onFocus: fn(), onBlur: fn(), onChange: fn(), }, } satisfies Meta; export default meta; export const Sandbox = createSandboxStory({ code: `const App = () => { const [value, setValue] = React.useState(''); return ( setValue(event.target.value)} /> ); };`, scope: globalScope, }); export const Basic: Story = { args: { label: 'Sort Code', placeholder: '**-**-**', displayPattern: '**-**-**', }, }; export const CardNumber: Story = { args: { label: 'Card Number', placeholder: '**** **** **** **** ***', displayPattern: '**** **** **** **** ***', }, }; export const CVC: Story = { args: { label: 'CVC', placeholder: '***', displayPattern: '***', value: '', }, }; export const ExpiryDate: Story = { args: { label: 'Expiry Date', placeholder: '** / **', displayPattern: '** / **', }, }; export const SecurityPin: Story = { args: { label: 'Security Pin', placeholder: '*-*-*-*-*-*', displayPattern: '*-*-*-*-*-*', }, }; export const PropUpdates: Story = { render: () => { const [value, setValue] = useState('123456'); const [displayPattern, setDisplayPattern] = useState('**-**-**'); return ( <>
{' '} {' '}
); }, };