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

type StoryType = StoryObj<typeof PasswordField>;

const meta: Meta<typeof PasswordField> = {
  title: "Forms/PasswordField",
  component: PasswordField,
  argTypes: {
    type: {
      control: { type: "radio" },
      options: ["text", "password"],
    },
    ...excludeControls("description", "validationState"),
  },
  args: {
    isReadOnly: false,
  },
  decorators: [
    Story => (
      <StoryContainer>
        <Story />
      </StoryContainer>
    ),
  ],
};

export const Default: StoryType = {
  render: (args: PasswordFieldProps) => <PasswordField {...args} />,
  args: {
    label: "Password",
    placeholder: "",
    isDisabled: false,
    errorMessage: "",
    type: "password",
    isRequired: false,
  },
};

export default meta;
