import { Select } from "./index"; import { DocsPage } from "@shared/stories/DocsTemplate"; import type { Meta, StoryObj } from "@storybook/react"; const meta: Meta = { title: "Components/Select", component: Select, tags: ["autodocs"], parameters: { layout: "centered", docs: { page: DocsPage, description: { component: "A powerful select component built with react-select, featuring search/filtering, custom styling, and enhanced UX that matches the consumer app pattern.", }, }, }, argTypes: { variant: { control: { type: "select" }, options: ["default", "unstyled"], description: "Select styling variant", }, size: { control: { type: "select" }, options: ["sm", "md"], description: "Select size", }, placeholder: { control: { type: "text" }, description: "Placeholder text", }, isDisabled: { control: { type: "boolean" }, description: "Disable the select", }, hasError: { control: { type: "boolean" }, description: "Show error state", }, error: { control: { type: "text" }, description: "Error message text", }, helperText: { control: { type: "text" }, description: "Helper text", }, label: { control: { type: "text" }, description: "Label text", }, isCustomStyle: { control: { type: "boolean" }, description: "Use custom styling for dropdown indicator and values", }, isSearchable: { control: { type: "boolean" }, description: "Enable search/filtering functionality", }, isClearable: { control: { type: "boolean" }, description: "Allow clearing the selected value", }, }, args: { placeholder: "Select an option...", variant: "default", size: "md", isDisabled: false, hasError: false, isCustomStyle: false, isSearchable: true, isClearable: false, options: [ { label: "Option 1", value: "option1" }, { label: "Option 2", value: "option2" }, { label: "Option 3", value: "option3" }, ], }, }; export default meta; type Story = StoryObj; // Default select export const Default: Story = { args: {}, }; // Select with label export const WithLabel: Story = { render: (args: any) => (
), }; // With helper text export const WithHelperText: Story = { args: { helperText: "Please select the most appropriate option", placeholder: "Select an option", }, }; // Small select export const Small: Story = { args: { size: "sm", placeholder: "Small select", }, }; // Medium select export const Medium: Story = { args: { size: "md", placeholder: "Medium select", }, }; // Disabled select export const Disabled: Story = { args: { isDisabled: true, placeholder: "Disabled select", }, }; // Unstyled variant export const Unstyled: Story = { args: { variant: "unstyled", placeholder: "Unstyled select", }, }; // Searchable select export const Searchable: Story = { args: { isSearchable: true, placeholder: "Type to search...", options: [ { label: "Apple", value: "apple" }, { label: "Banana", value: "banana" }, { label: "Cherry", value: "cherry" }, { label: "Date", value: "date" }, { label: "Elderberry", value: "elderberry" }, { label: "Fig", value: "fig" }, { label: "Grape", value: "grape" }, ], }, }; // Clearable select export const Clearable: Story = { args: { isClearable: true, placeholder: "Select and clear option", value: { label: "Option 2", value: "option2" }, }, }; // Custom style select export const CustomStyle: Story = { args: { isCustomStyle: true, placeholder: "Custom styled select", options: [ { label: "Custom Option 1", value: "custom1" }, { label: "Custom Option 2", value: "custom2" }, { label: "Custom Option 3", value: "custom3" }, ], }, }; // With filtering options export const WithFiltering: Story = { args: { isSearchable: true, placeholder: "Search with custom filter...", filterOptions: { ignoreCase: true, ignoreAccents: true, matchFrom: "any", }, options: [ { label: "São Paulo", value: "sao-paulo" }, { label: "Café", value: "cafe" }, { label: "Naïve", value: "naive" }, { label: "Café au lait", value: "cafe-au-lait" }, { label: "São José", value: "sao-jose" }, ], }, parameters: { docs: { description: { story: "Select with custom filtering options that ignore case and accents for better search experience.", }, }, }, }; // With many options export const ManyOptions: Story = { args: { placeholder: "Choose a country", options: [ { label: "United States", value: "us" }, { label: "Canada", value: "ca" }, { label: "United Kingdom", value: "uk" }, { label: "Germany", value: "de" }, { label: "France", value: "fr" }, { label: "Spain", value: "es" }, { label: "Italy", value: "it" }, { label: "Japan", value: "jp" }, { label: "China", value: "cn" }, { label: "Australia", value: "au" }, { label: "Brazil", value: "br" }, { label: "India", value: "in" }, ], }, }; // With selected value export const WithSelectedValue: Story = { args: { value: { label: "Option 2", value: "option2" }, placeholder: "Select an option", }, }; // All variants showcase export const AllVariants: Story = { render: () => (
), parameters: { docs: { description: { story: "Showcase of all select variants, sizes, and states.", }, }, }, }; // Form example export const FormExample: Story = { render: () => (
), parameters: { docs: { description: { story: "Example of select components used in a form context.", }, }, }, };