From cdd8ae795e00a948ad252af1008ff3d8ac46f254 Mon Sep 17 00:00:00 2001 From: Rando Leppik Date: Mon, 28 Sep 2026 16:25:53 +0300 Subject: [PATCH] docs(form-field): add TEDI-Ready FormField stories #393 --- .../form/form-field/form-field.stories.ts | 137 ++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 src/tedi/components/form/form-field/form-field.stories.ts diff --git a/src/tedi/components/form/form-field/form-field.stories.ts b/src/tedi/components/form/form-field/form-field.stories.ts new file mode 100644 index 000000000..61c11f5c8 --- /dev/null +++ b/src/tedi/components/form/form-field/form-field.stories.ts @@ -0,0 +1,137 @@ +import { + argsToTemplate, + Meta, + moduleMetadata, + StoryObj, +} from "@storybook/angular"; +import { FormFieldComponent } from "./form-field.component"; +import { FeedbackTextComponent } from "../feedback-text/feedback-text.component"; +import { LabelComponent } from "../../content/label/label.component"; +import { TextFieldComponent } from "../text-field/text-field.component"; + +/** + * Groups a label and a form control, and provides shared field features such as + * sizing, an icon, a clear button, and a character counter. + */ +export default { + title: "TEDI-Ready/Components/Form/FormField", + component: FormFieldComponent, + decorators: [ + moduleMetadata({ + imports: [ + FormFieldComponent, + FeedbackTextComponent, + LabelComponent, + TextFieldComponent, + ], + }), + ], + parameters: { + status: { + type: ["devComponent"], + }, + }, + argTypes: { + size: { + control: "radio", + options: ["default", "small", "large"], + }, + icon: { + control: "text", + description: "Icon name or configuration shown at the end of the field.", + }, + clearable: { + control: "boolean", + description: "Shows a clear button when the field has a value.", + }, + showClearOnInteraction: { + control: "boolean", + description: + "Shows the clear button only while the filled field is hovered or focused. Requires clearable.", + }, + characterLimit: { + control: "number", + description: + "Shows a live character counter and marks excess text as invalid.", + }, + }, +} as Meta; + +type Story = StoryObj; + +export const WithTextField: Story = { + args: { + size: "default", + clearable: false, + showClearOnInteraction: false, + }, + render: (args) => ({ + props: args, + template: ` + + + + + `, + }), +}; + +/** The clear button appears when the filled field is hovered or focused. */ +export const ClearButtonOnInteraction: Story = { + args: { + clearable: true, + showClearOnInteraction: true, + }, + render: (args) => ({ + props: args, + template: ` + + + + + `, + }), +}; + +export const WithCharacterLimit: Story = { + args: { + characterLimit: 20, + }, + render: (args) => ({ + props: args, + template: ` + + + + + `, + }), +}; + +export const WithIcon: Story = { + args: { + icon: "search", + }, + render: (args) => ({ + props: args, + template: ` + + + + + `, + }), +}; + +export const WithFeedback: Story = { + render: (args) => ({ + props: args, + template: ` + + + + + + `, + }), +};