import type { Meta, StoryObj } from '@storybook/nextjs-vite'; import { useState } from 'react'; import { Button } from '../components/ui/button'; import { Input } from '../components/ui/input'; import { SearchIcon } from '../components/icons-v2-generated/interface/search-icon'; const meta = { title: 'UI/Input', component: Input, } satisfies Meta; export default meta; type Story = StoryObj; /** * Default Input without adornments. */ export const Default: Story = { args: { placeholder: 'Enter text...', }, }; /** * Input with text endAdornment. */ export const WithEndAdornmentText: Story = { args: { placeholder: '90', endAdornment: 'Seconds', className: 'w-full', }, }; /** * Input with icon startAdornment. */ export const WithStartAdornmentIcon: Story = { args: { placeholder: 'Search...', startAdornment: '🔍', }, }; /** * Input with both startAdornment and endAdornment. */ export const WithBothAdornments: Story = { args: { placeholder: '0.00', startAdornment: '$', endAdornment: 'USD', }, }; /** * Input with icon endAdornment. */ export const WithEndAdornmentIcon: Story = { args: { placeholder: 'Enter timeout...', endAdornment: '⏱', }, }; /** * Disabled input with adornments. */ export const DisabledWithAdornments: Story = { args: { placeholder: '90', endAdornment: 'Seconds', disabled: true, }, }; /** * Invalid input with adornments (error state). */ export const InvalidWithAdornments: Story = { args: { placeholder: '0', startAdornment: '$', invalid: true, }, }; /** * Input with value and endAdornment. */ export const WithValueAndEndAdornment: Story = { args: { defaultValue: '90', endAdornment: 'Seconds', className: 'max-w-[320px]', }, }; /** * Number input with unit adornment. */ export const NumberWithUnit: Story = { args: { type: 'number', placeholder: '100', endAdornment: 'ms', }, }; /** * Input with label. */ export const WithLabel: Story = { args: { placeholder: 'Enter text...', label: 'Username', }, }; /** * Input with label and error message. */ export const WithLabelAndError: Story = { args: { placeholder: 'Enter text...', label: 'Username', error: 'This field is required', }, }; /** * Input with label, value and no error (valid state). */ export const WithLabelAndValue: Story = { args: { label: 'Timeout', defaultValue: '90', endAdornment: 'Seconds', }, }; /** * Input with error only (no label). */ export const WithErrorOnly: Story = { args: { placeholder: 'Enter value...', error: 'Invalid value', }, }; /** * Search input with SearchIcon startAdornment. */ export const SearchInput: Story = { render: function Render() { const [value, setValue] = useState(''); return ( setValue(e.target.value)} placeholder="Search..." startAdornment={} /> ); }, }; /** * Input with loading spinner. */ export const Loading: Story = { args: { placeholder: 'Searching...', loading: true, startAdornment: , }, }; /** * Input with a submit button. */ export const WithButton: Story = { render: function Render() { const [value, setValue] = useState(''); return (
setValue(e.target.value)} placeholder="Enter your email..." error='sdfsd' />
); }, }; /** * All input variants displayed together for comparison. */ export const AllVariants: Story = { args: { placeholder: 'Default', }, render: () => (
), }; /** * Error / status states. Long messages wrap up to two lines, then ellipsize. */ export const ErrorState: Story = { args: { placeholder: 'Enter text...', }, render: () => (
{/* Half-width pair, as on the Create Organization screen */}
), };