import { StoryObj, Meta } from "@storybook/react-vite"; import { within, expect } from "storybook/test"; import Select from "./select"; import "./select.scss"; import React from "react"; const meta: Meta = { title: "FP.React Forms/Select", tags: ["stable"], component: Select, parameters: { docs: { description: { component: "Accessible select dropdown component with themeable arrow and validation support. Follows fpkit component conventions with ref forwarding and custom styling options.", }, }, }, args: { children: ( <> ), }, } as Story; export default meta; type Story = StoryObj; /** * Default select component with standard options using the new API */ export const SelectComponent: Story = { args: { id: "default-select", name: "defaultSelect", children: ( <> ), }, play: async ({ canvasElement }) => { const canvas = within(canvasElement); const select = canvas.getByRole("combobox"); expect(select).toBeInTheDocument(); expect(select).toHaveAttribute("id", "default-select"); }, } as Story; /** * Select with label prop for display text */ export const WithLabels: Story = { args: { children: ( <> ), }, } as Story; /** * Select with children instead of label prop */ export const WithChildren: Story = { args: { children: ( <> โš›๏ธ React ๐Ÿ’š Vue ๐Ÿ”บ Angular ๐Ÿงก Svelte ), }, } as Story; /** * Select with disabled options */ export const WithDisabledOptions: Story = { args: { children: ( <> ), }, } as Story; /** * Required select field */ export const Required: Story = { args: { id: "required-select", name: "requiredSelect", required: true, children: ( <> ), }, } as Story; /** * Disabled select component */ export const Disabled: Story = { args: { disabled: true, children: ( <> ), }, } as Story; /** * Select with custom styling */ export const CustomStyling: Story = { args: { styles: { "--select-arrow-color": "#0066cc", "--input-border-color": "#0066cc", "--input-radius": "1rem", } as React.CSSProperties, classes: "custom-select", children: ( <> ), }, } as Story; /** * Styled options with variant data attributes */ export const StyledWithVariants: Story = { args: { children: ( <> ), }, parameters: { docs: { description: { story: "Options with variant data attributes for CSS targeting: `option[data-option=\"primary\"]`", }, }, }, } as Story; /** * Options with size variants */ export const WithSizes: Story = { args: { children: ( <> ), }, parameters: { docs: { description: { story: "Options with size data attributes: `option[data-size=\"sm\"]`", }, }, }, } as Story; /** * Options with custom data attributes */ export const WithCustomDataAttributes: Story = { args: { children: ( <> ), }, parameters: { docs: { description: { story: "Options with custom data attributes for advanced styling: `option[data-category=\"premium\"]`", }, }, }, } as Story; /** * Legacy API - backwards compatibility with selectValue and selectLabel * @deprecated Use `value` and `label` props instead */ export const LegacyAPI: Story = { args: { children: ( <> ), }, parameters: { docs: { description: { story: "Example using deprecated `selectValue` and `selectLabel` props. Use `value` and `label` instead.", }, }, }, } as Story;