import { Meta, StoryObj } from '@storybook/react-webpack5';
import { fn } from 'storybook/test';

import { createSandboxStory, globalScope } from '../../.storybook/components/sandbox/SandboxEditor';
import { DateInput } from '..';

const meta: Meta<typeof DateInput> = {
  component: DateInput,
  title: 'Forms/DateInput',
} satisfies Meta<typeof DateInput>;

export default meta;

type Story = StoryObj<typeof meta>;

export const Sandbox = createSandboxStory({
  code: `const App = () => {
  const [value, setValue] = React.useState({ day: 15, month: 5, year: 1990 });

  return (
    <Field label="Date of birth">
      <DateInput
        value={value}
        onChange={(newValue) => setValue(newValue)}
      />
    </Field>
  );
};`,
  scope: globalScope,
});

export const Basic: Story = {
  args: {
    onChange: fn(),
    onBlur: fn(),
    onFocus: fn(),
  },
} satisfies Story;
