import type { Meta, StoryObj } from "@storybook/react";
import { excludeControls } from "../../utils";
import { StoryContainer } from "../../utils/StoryContainer";
import type { TextAreaProps } from "./TextArea";
import { TextArea } from "./TextArea";

type StoryType = StoryObj<typeof TextArea>;

const meta: Meta<typeof TextArea> = {
  title: "Forms/TextArea",
  component: TextArea,
  argTypes: {
    ...excludeControls("description", "validationState"),
  },
  args: {
    isReadOnly: false,
    isDisabled: false,
    isRequired: false,
  },
  decorators: [
    Story => (
      <StoryContainer>
        <Story />
      </StoryContainer>
    ),
  ],
};

export const Default: StoryType = {
  render: (args: TextAreaProps) => <TextArea {...args} />,
  args: {
    label: "first name",
    placeholder: "Placeholder",
    defaultValue: "",
    isDisabled: false,
    errorMessage: "",
  },
};

export const ControlledValue: StoryType = {
  render: (args: TextAreaProps) => <TextArea {...args} />,
  args: {
    label: "first name",
    placeholder: "Placeholder",
    defaultValue: "John Doe",
    isDisabled: false,
    errorMessage: "",
  },
};

export const Disabled: StoryType = {
  render: (args: TextAreaProps) => <TextArea {...args} />,
  args: {
    label: "first name",
    placeholder: "Placeholder",
    defaultValue: "John Doe",
    isDisabled: true,
    errorMessage: "",
  },
};

export const WithError: StoryType = {
  render: (args: TextAreaProps) => <TextArea {...args} />,
  args: {
    label: "first name",
    placeholder: "Placeholder",
    defaultValue: "John Doe",
    isDisabled: false,
    errorMessage: "This is an error message",
    isInvalid: true,
  },
};

export const Valid: StoryType = {
  render: (args: TextAreaProps) => <TextArea {...args} />,
  args: {
    label: "first name",
    placeholder: "Placeholder",
    defaultValue: "John Doe",
    isDisabled: false,
    errorMessage: "",
    isInvalid: false,
  },
};

export const Invalid: StoryType = {
  render: (args: TextAreaProps) => <TextArea {...args} />,
  args: {
    label: "first name",
    placeholder: "Placeholder",
    defaultValue: "John Doe",
    isDisabled: false,
    errorMessage: "",
    isInvalid: true,
  },
};

export default meta;
