import type { Meta, StoryObj } from '@storybook/react-vite';
import { Input } from './input';
import { Label } from '../label/label';
import { SearchIcon } from '@/icons';
const meta = {
title: 'Components/Input',
component: Input,
parameters: {
layout: 'centered',
docs: {
description: {
component:
'Single-line text field. The error treatment is driven by `aria-invalid`, so what is shown always matches what assistive technology reports.',
},
},
},
tags: ['autodocs'],
argTypes: {
size: { control: 'inline-radio', options: ['xs', 'sm', 'md', 'lg'] },
variant: { control: 'inline-radio', options: ['outline', 'flushed'] },
},
args: { placeholder: 'name@example.com' },
decorators: [(Story) =>
],
} satisfies Meta;
export default meta;
type Story = StoryObj;
export const Sizes: Story = {
render: (args) => (
{(['xs', 'sm', 'md', 'lg'] as const).map((size) => (
))}
),
};
/** CBAR's second treatment: underlined only, for dense forms and inline edits. */
export const Flushed: Story = {
args: { variant: 'flushed' },
};
export const Default: Story = {};
export const WithLabel: Story = {
render: (args) => (
Email
),
};
export const Types: Story = {
render: () => (
),
};
export const Invalid: Story = {
args: { 'aria-invalid': true, defaultValue: 'not-an-email' },
};
export const Disabled: Story = {
args: { disabled: true, defaultValue: 'Read only' },
};
/**
* CBAR's Input set draws `.leftElement?` and `.rightElement?`, both on by
* default. `startElement` is inert so a click reaches the field; `endElement`
* stays interactive, which is where a clear button or a unit toggle belongs.
*/
export const Adornments: Story = {
render: () => (
} placeholder="Search" />
₼} defaultValue="1200" />
}
endElement={⌘K }
placeholder="Both"
/>
} placeholder="Disabled" disabled />
} defaultValue="nope" aria-invalid />
),
};
/** The adornment box follows the same 32 / 36 / 44 / 56px ladder. */
export const AdornmentSizes: Story = {
render: () => (
{(['xs', 'sm', 'md', 'lg'] as const).map((size) => (
} placeholder={size} />
))}
),
};