import { action } from '@storybook/addon-actions';
import type { Meta, Story } from '@storybook/react';
import MuiGrid from '@mui/material/Grid';
import { Textarea } from './textarea';
import type { TextareaProps } from './textarea';

export default {
  component: Textarea,
  title: 'Forms/Text Area',
  argTypes: {
    color: {
      options: ['primary', 'secondary'],
      control: { type: 'select' }
    }
  }
} as Meta;

const loremText =
  'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';

const Template: Story<TextareaProps> = args => {
  if (args.error) args = { ...args, helperText: 'Error' };

  return (
    <MuiGrid container justifyContent="space-around">
      <Textarea {...args} style={{ width: '25%' }} />
    </MuiGrid>
  );
};

export const Primary = Template.bind({});
Primary.args = {
  autoFocus: true,
  disabled: false,
  error: false,
  placeholder: 'Text Area'
};

export const AutoHeight = Template.bind({});
AutoHeight.args = {
  autoFocus: false,
  autoHeight: true,
  defaultValue: loremText,
  disabled: false,
  error: false,
  placeholder: 'Text Area'
};

export const MinAndMaxRows = Template.bind({});
MinAndMaxRows.args = {
  autoFocus: false,
  autoHeight: true,
  defaultValue: loremText,
  disabled: false,
  error: false,
  minRows: 5,
  maxRows: 10,
  placeholder: 'Text Area'
};
