2025-02-28 13:46:00 +00:00
|
|
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
|
|
|
import { action } from "@storybook/addon-actions";
|
2021-11-07 06:41:09 +00:00
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
import InputFieldWithIcon from ".";
|
|
|
|
|
|
2025-02-28 13:46:00 +00:00
|
|
|
// Define metadata for the story
|
2025-01-20 16:17:33 +00:00
|
|
|
const meta: Meta<typeof InputFieldWithIcon> = {
|
2025-02-28 13:46:00 +00:00
|
|
|
title: "Components/FormFields/InputFieldWithIcon",
|
2021-11-07 06:41:09 +00:00
|
|
|
component: InputFieldWithIcon,
|
|
|
|
|
argTypes: {
|
2025-02-28 13:46:00 +00:00
|
|
|
type: {
|
|
|
|
|
options: ["text", "password", "email", "number"],
|
|
|
|
|
control: "select",
|
|
|
|
|
},
|
|
|
|
|
value: {
|
|
|
|
|
control: "text",
|
|
|
|
|
},
|
|
|
|
|
disabled: {
|
|
|
|
|
control: "boolean",
|
|
|
|
|
},
|
|
|
|
|
error: {
|
|
|
|
|
control: "text",
|
2021-11-07 06:41:09 +00:00
|
|
|
},
|
2025-02-28 13:46:00 +00:00
|
|
|
helpText: {
|
|
|
|
|
control: "text",
|
|
|
|
|
},
|
|
|
|
|
tooltip: {
|
|
|
|
|
control: "text",
|
|
|
|
|
},
|
|
|
|
|
iconSvg: {
|
|
|
|
|
options: ["search", "filter"], // Add more icons as needed
|
2021-11-07 06:41:09 +00:00
|
|
|
control: "select",
|
|
|
|
|
},
|
|
|
|
|
},
|
2025-02-28 13:46:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default meta;
|
|
|
|
|
|
|
|
|
|
type Story = StoryObj<typeof InputFieldWithIcon>;
|
|
|
|
|
|
|
|
|
|
// Default story
|
|
|
|
|
export const Default: Story = {
|
2021-11-07 06:41:09 +00:00
|
|
|
args: {
|
|
|
|
|
label: "Email",
|
2025-02-28 13:46:00 +00:00
|
|
|
placeholder: "Enter your email",
|
|
|
|
|
type: "email",
|
|
|
|
|
onChange: action("onChange"),
|
2021-11-07 06:41:09 +00:00
|
|
|
},
|
2025-01-20 16:17:33 +00:00
|
|
|
};
|
|
|
|
|
|
2025-02-28 13:46:00 +00:00
|
|
|
// Password input story
|
|
|
|
|
export const PasswordInput: Story = {
|
|
|
|
|
args: {
|
|
|
|
|
...Default.args,
|
|
|
|
|
label: "Password",
|
|
|
|
|
placeholder: "Enter your password",
|
|
|
|
|
type: "password",
|
|
|
|
|
},
|
|
|
|
|
};
|
2021-11-07 06:41:09 +00:00
|
|
|
|
2025-02-28 13:46:00 +00:00
|
|
|
// With error story
|
|
|
|
|
export const WithError: Story = {
|
|
|
|
|
args: {
|
|
|
|
|
...Default.args,
|
|
|
|
|
error: "Invalid email address",
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// With help text story
|
|
|
|
|
export const WithHelpText: Story = {
|
|
|
|
|
args: {
|
|
|
|
|
...Default.args,
|
|
|
|
|
helpText: "We'll never share your email with anyone else.",
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Disabled story
|
|
|
|
|
export const Disabled: Story = {
|
|
|
|
|
args: {
|
|
|
|
|
...Default.args,
|
|
|
|
|
disabled: true,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// With tooltip story
|
|
|
|
|
export const WithTooltip: Story = {
|
|
|
|
|
args: {
|
|
|
|
|
...Default.args,
|
|
|
|
|
tooltip: "Enter the email address associated with your account",
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// With clear button story
|
|
|
|
|
export const WithClearButton: Story = {
|
|
|
|
|
args: {
|
|
|
|
|
...Default.args,
|
|
|
|
|
clearButton: action("clearButton"),
|
|
|
|
|
value: "example@email.com",
|
|
|
|
|
},
|
|
|
|
|
};
|
2021-11-07 06:41:09 +00:00
|
|
|
|
2025-02-28 13:46:00 +00:00
|
|
|
// Custom icon story
|
|
|
|
|
export const CustomIcon: Story = {
|
|
|
|
|
args: {
|
|
|
|
|
...Default.args,
|
|
|
|
|
iconSvg: "search", // Use an appropriate icon SVG name
|
|
|
|
|
label: "Search",
|
|
|
|
|
placeholder: "Search...",
|
|
|
|
|
},
|
|
|
|
|
};
|