diff --git a/libs/ui/src/molecules/form-input.tsx b/libs/ui/src/molecules/form-input.tsx index 06117bf7d1..120a5e0db2 100644 --- a/libs/ui/src/molecules/form-input.tsx +++ b/libs/ui/src/molecules/form-input.tsx @@ -1,8 +1,7 @@ import type { ReactNode } from "react" -import { ErrorText } from "../atoms/error-text" -import { ExtraText } from "../atoms/extra-text" import { Input, type InputProps } from "../atoms/input" import { Label } from "../atoms/label" +import { StatusText } from "../atoms/status-text" type ValidateStatus = "default" | "error" | "success" | "warning" @@ -11,7 +10,6 @@ interface FormInputRawProps extends InputProps { label: ReactNode validateStatus?: ValidateStatus helpText?: ReactNode - extraText?: ReactNode } export function FormInputRaw({ @@ -19,14 +17,11 @@ export function FormInputRaw({ label, validateStatus = "default", helpText, - extraText, size = "md", required, disabled, ...props }: FormInputRawProps) { - const extraTextId = extraText ? `${id}-extra` : undefined - return (
) } +type FormInputProps = FormInputRawProps & { + showHelpTextIcon?: boolean +} + export function FormInput({ helpText, id, - validateStatus, - size, + validateStatus = "default", + showHelpTextIcon = validateStatus !== "default", + size = "md", ...props -}: FormInputRawProps) { - const helpTextId = helpText ? `${id}-helper` : undefined - +}: FormInputProps) { return ( - {helpText} - - ) : ( - + helpText && ( + {helpText} - + ) } id={id} diff --git a/libs/ui/stories/molecules/form-input.stories.tsx b/libs/ui/stories/molecules/form-input.stories.tsx index 9bfbdf5886..56a25daae7 100644 --- a/libs/ui/stories/molecules/form-input.stories.tsx +++ b/libs/ui/stories/molecules/form-input.stories.tsx @@ -33,6 +33,10 @@ const meta: Meta = { options: ['default', 'error', 'success', 'warning'], description: 'Validation state that affects input style and helper text', }, + showHelpTextIcon: { + control: 'boolean', + description: 'Whether to show an icon with the help text', + }, }, } @@ -70,6 +74,15 @@ export const AllVariants: Story = { +
+ +
@@ -183,6 +195,71 @@ export const AllVariants: Story = { ), } +// Validation States - Dedicated story showing all 4 validation states +export const ValidationStates: Story = { + render: () => ( +
+ + + + +
+ ), +} + +// Sizes - Dedicated story showing all size variants +export const Sizes: Story = { + render: () => ( +
+ + + +
+ ), +} + // Interactive validation example export const InteractiveValidation: Story = { render: () => { @@ -262,7 +339,7 @@ export const RegistrationForm: Story = { label="Username" placeholder="johndoe" required - extraText="Visible to other users" + helpText="Visible to other users" />