"use client" import type { Meta, StoryObj } from '@storybook/react'; import { Input } from './input'; import { Label } from './label'; import { Button } from './button'; import { Search, Mail, Lock, Eye, EyeOff } from 'lucide-react'; import { useState } from 'react'; const meta: Meta = { title: 'Components/Input', component: Input, parameters: { layout: 'centered', docs: { description: { component: 'Displays a form input field or a component that looks like an input field.', }, }, }, tags: ['autodocs'], argTypes: { type: { control: 'select', options: ['text', 'email', 'password', 'number', 'search', 'tel', 'url'], description: 'The type of input', }, placeholder: { control: 'text', description: 'Placeholder text', }, disabled: { control: 'boolean', description: 'Whether the input is disabled', }, className: { control: 'text', description: 'Additional CSS classes', }, }, }; export default meta; type Story = StoryObj; export const Default: Story = { args: { placeholder: 'Enter text...', }, }; export const WithLabel: Story = { render: () => (
), }; export const Email: Story = { args: { type: 'email', placeholder: 'Enter your email', }, }; export const Password: Story = { args: { type: 'password', placeholder: 'Enter your password', }, }; export const Search: Story = { args: { type: 'search', placeholder: 'Search...', }, }; export const Number: Story = { args: { type: 'number', placeholder: 'Enter a number', }, }; export const Disabled: Story = { args: { disabled: true, placeholder: 'Disabled input', }, }; export const WithIcon: Story = { render: () => (
), }; export const WithButton: Story = { render: () => (
), }; export const FormExample: Story = { render: () => (
), }; export const PasswordWithToggle: Story = { render: () => { const [showPassword, setShowPassword] = useState(false); return (
); }, }; export const Sizes: Story = { render: () => (
), }; export const States: Story = { render: () => (
), }; export const WithValidation: Story = { render: () => { const [email, setEmail] = useState(''); const [error, setError] = useState(''); const validateEmail = (value: string) => { if (!value) { setError('Email is required'); } else if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) { setError('Please enter a valid email address'); } else { setError(''); } }; return (
{ setEmail(e.target.value); validateEmail(e.target.value); }} className={error ? 'border-red-500' : ''} /> {error && (

{error}

)}
); }, };