import type { Meta, StoryObj } from '@storybook/react' import { Cat, Dog, Fish, Rabbit, Turtle } from 'lucide-react' import { Select, SelectTrigger, SelectContent, SelectItem, SelectValue, } from '../Select/Select' import { MultiSelect } from './MultiSelect' const options = [ { label: 'React', value: 'react' }, { label: 'Vue', value: 'vue' }, { label: 'Angular', value: 'angular' }, { label: 'Svelte', value: 'svelte' }, { label: 'Ember', value: 'ember' }, ] const optionsWithIcons = [ { label: 'Cat', value: 'cat', icon: Cat }, { label: 'Dog', value: 'dog', icon: Dog }, { label: 'Rabbit', value: 'rabbit', icon: Rabbit }, { label: 'Turtle', value: 'turtle', icon: Turtle }, { label: 'Fish', value: 'fish', icon: Fish }, ] const networkOptions = [ { value: 'arbitrum', label: 'Arbitrum', icon: ({ className }: { className?: string }) => ( Arbitrum ), }, { value: 'avalanche', label: 'Avalanche', icon: ({ className }: { className?: string }) => ( Avalanche ), }, { value: 'base', label: 'Base', icon: ({ className }: { className?: string }) => ( Base ), }, { value: 'ethereum', label: 'Ethereum', icon: ({ className }: { className?: string }) => ( Ethereum ), }, { value: 'solana', label: 'Solana', icon: ({ className }: { className?: string }) => ( Solana ), }, { value: 'polygon', label: 'Polygon', icon: ({ className }: { className?: string }) => ( Polygon ), }, ] const groupedOptions = [ { heading: 'Frontend', options: [ { label: 'React', value: 'react' }, { label: 'Vue', value: 'vue' }, { label: 'Angular', value: 'angular' }, ], }, { heading: 'Backend', options: [ { label: 'Node.js', value: 'node' }, { label: 'Python', value: 'python' }, { label: 'Go', value: 'go' }, ], }, { heading: 'Database', options: [ { label: 'PostgreSQL', value: 'postgresql' }, { label: 'MongoDB', value: 'mongodb' }, { label: 'Redis', value: 'redis' }, ], }, ] const meta = { title: 'Form/MultiSelect', component: MultiSelect, argTypes: { options: { control: 'object', description: 'Options to display', }, defaultValue: { control: 'object', description: 'Default selected values', }, placeholder: { control: 'text', description: 'Placeholder text', }, maxCount: { control: 'number', description: 'Maximum number of items to display', }, disabled: { control: 'boolean', description: 'Disable the component', }, searchable: { control: 'boolean', description: 'Enable search functionality', }, autoSize: { control: 'boolean', description: 'Auto size width', }, size: { control: 'select', options: ['default', 'sm', 'xs'], description: 'Size of the component', }, open: { control: 'boolean', description: 'Controlled open state', }, defaultOpen: { control: 'boolean', description: 'Default open state', }, onValueChange: { control: false }, }, args: { options, placeholder: 'Select frameworks', maxCount: 3, onValueChange: () => {}, }, decorators: [ (Story, context) => (
), ], } satisfies Meta export default meta type Story = StoryObj export const Default: Story = { args: { defaultValue: ['react'], }, } export const WithIcons: Story = { args: { options: optionsWithIcons, placeholder: 'Select pets', defaultValue: ['cat', 'dog'], }, } export const WithImages: Story = { args: { options: networkOptions, placeholder: 'Select networks', defaultValue: ['ethereum', 'arbitrum'], }, } export const Grouped: Story = { args: { options: groupedOptions, placeholder: 'Select technologies', defaultValue: ['react', 'node'], }, } export const Disabled: Story = { args: { options, defaultValue: ['react'], disabled: true, }, } export const EmptyIndicator: Story = { args: { options, placeholder: 'Search for "ruby"', }, } export const Responsive: Story = { parameters: { viewport: { defaultViewport: 'mobile1', }, }, args: { options, defaultValue: ['react', 'vue', 'angular', 'svelte'], responsive: true, }, } export const Sizes: Story = { render: () => (

Default

{}} />

Small

{}} />

Extra Small

{}} />
), decorators: [ (Story) => (
), ], } export const WidthConstraints: Story = { render: (_args, _context) => (
{}} />
), decorators: [ (Story, context) => (
), ], } export const SizeComparison: Story = { render: (_args, context) => { const openProp = context.viewMode === 'story' ? { defaultOpen: true } : {} const width = 'w-64 max-w-full' return (
{/* MultiSelect Variants */}

MultiSelect

Default

{}} {...openProp} />

Small (sm)

{}} {...openProp} />

Extra Small (xs)

{}} {...openProp} />
{/* Select Variants */}

Select

Default

Small (sm)

) }, decorators: [ (Story, context) => (
), ], }