mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 13:37:30 +00:00
Zed + Opus 4.6; prompt: Convert the InputField JSX component to TypeScript and remove the ts-ignore directives that we no longer need after doing so. - [x] Changes file added - [x] Automated tests updated
140 lines
2.9 KiB
TypeScript
140 lines
2.9 KiB
TypeScript
import { Meta, StoryObj } from "@storybook/react";
|
|
import { action } from "@storybook/addon-actions";
|
|
|
|
import InputField from ".";
|
|
|
|
import "../../../../index.scss";
|
|
|
|
const meta: Meta<typeof InputField> = {
|
|
component: InputField,
|
|
title: "Components/FormFields/Input",
|
|
argTypes: {
|
|
type: {
|
|
control: "select",
|
|
options: ["text", "password", "email", "number", "textarea"],
|
|
},
|
|
autofocus: { control: "boolean" },
|
|
readOnly: { control: "boolean" },
|
|
disabled: { control: "boolean" },
|
|
blockAutoComplete: { control: "boolean" },
|
|
enableCopy: { control: "boolean" },
|
|
enableShowSecret: { control: "boolean" },
|
|
labelTooltipPosition: {
|
|
control: "select",
|
|
options: ["top", "right", "bottom", "left"],
|
|
},
|
|
},
|
|
};
|
|
|
|
export default meta;
|
|
|
|
type Story = StoryObj<typeof InputField>;
|
|
|
|
export const Default: Story = {
|
|
args: {
|
|
name: "default-input",
|
|
label: "Default Input",
|
|
placeholder: "Type here...",
|
|
value: "",
|
|
onChange: action("onChange"),
|
|
onFocus: action("onFocus"),
|
|
onBlur: action("onBlur"),
|
|
},
|
|
};
|
|
|
|
export const WithValue: Story = {
|
|
args: {
|
|
...Default.args,
|
|
name: "with-value-input",
|
|
label: "Input with Value",
|
|
value: "Sample text",
|
|
},
|
|
};
|
|
|
|
export const WithError: Story = {
|
|
args: {
|
|
...Default.args,
|
|
name: "error-input",
|
|
label: "Input with Error",
|
|
error: "This field is required",
|
|
value: "",
|
|
},
|
|
};
|
|
|
|
export const WithHelpText: Story = {
|
|
args: {
|
|
...Default.args,
|
|
name: "help-text-input",
|
|
label: "Input with Help Text",
|
|
helpText: "This is some helpful information about the input field.",
|
|
},
|
|
};
|
|
|
|
export const WithTooltip: Story = {
|
|
args: {
|
|
...Default.args,
|
|
name: "tooltip-input",
|
|
label: "Input with Tooltip",
|
|
tooltip: "This is additional information in a tooltip.",
|
|
labelTooltipPosition: "right",
|
|
},
|
|
};
|
|
|
|
export const Password: Story = {
|
|
args: {
|
|
...Default.args,
|
|
name: "password-input",
|
|
label: "Password Input",
|
|
type: "password",
|
|
placeholder: "Enter password",
|
|
},
|
|
};
|
|
|
|
export const ReadOnly: Story = {
|
|
args: {
|
|
...Default.args,
|
|
name: "readonly-input",
|
|
label: "Read-only Input",
|
|
readOnly: true,
|
|
value: "This is read-only content",
|
|
},
|
|
};
|
|
|
|
export const Disabled: Story = {
|
|
args: {
|
|
...Default.args,
|
|
name: "disabled-input",
|
|
label: "Disabled Input",
|
|
disabled: true,
|
|
value: "This input is disabled",
|
|
},
|
|
};
|
|
|
|
export const WithCopyButton: Story = {
|
|
args: {
|
|
...Default.args,
|
|
name: "copy-input",
|
|
label: "Input with Copy Button",
|
|
value: "Click to copy this text",
|
|
enableCopy: true,
|
|
},
|
|
};
|
|
|
|
export const AutoFocus: Story = {
|
|
args: {
|
|
...Default.args,
|
|
name: "autofocus-input",
|
|
label: "Autofocus Input",
|
|
autofocus: true,
|
|
},
|
|
};
|
|
|
|
export const Textarea: Story = {
|
|
args: {
|
|
...Default.args,
|
|
name: "textarea-input",
|
|
label: "Textarea Input",
|
|
type: "textarea",
|
|
placeholder: "Enter multiple lines of text...",
|
|
},
|
|
};
|