import { Meta, StoryObj } from "@storybook/react"; import { fn } from "@storybook/test"; import { FieldStateControls, FocusEventsArgTypes, RenderPropsArgTypes, } from "@sb/helpers"; import { getCssProps } from "@sb/cssprops"; import { FieldLabel } from "../Field/FieldLabel"; import { Popover } from "@components/Overlays/Popover"; import { ListBox } from "@components/Dropdowns/ListBox"; import { FieldErrorMessage } from "../Field/FieldError"; import { FieldMessage } from "../Field/FieldMessage"; import { Button } from "@components/Buttons/Button"; import { Item, Section } from "@components/Collection"; import { MaterialIcon } from "@components/Icons/MaterialIcon"; import { SelectField as SelectField } from "."; export default { title: "Fields/SelectField", component: SelectField, parameters: { layout: "centered", cssprops: getCssProps("Dropdown", "Listbox", "Button"), }, argTypes: { ...FieldStateControls, ...RenderPropsArgTypes, ...FocusEventsArgTypes, selectedKey: { control: "select", description: "Control the value of the selected key in a controlled component", options: ["1", "2", "3", null], }, defaultSelectedKey: { control: false, description: "Control the value of the selected key in an uncontrolled component", }, children: { control: false, }, isOpen: { control: "boolean", description: "Control the open state of the menu", }, defaultOpen: { control: "boolean", description: "Control the inital state of the menu", }, onOpenChange: { control: false, action: "onOpenChange", description: "Callback for when the menu is opened or closed", table: { category: "Events", }, }, onSelectionChange: { action: "onSelectionChange", control: false, description: "Callback for when the selection changes", table: { category: "Events", }, }, }, } as Meta; type Story = StoryObj; export const Primary: Story = { args: { onSelectionChange: fn(), onOpenChange: fn(), children: [ Select an item, Choose an item from the list, , Item 1 Item 2 Item 3 , Something went wrong, ], }, }; export const WithSections: Story = { args: { ...Primary.args, children: [ Select an item, Choose an item from the list, ,
Item 1 Item 2
Item 3 Item 4
, ], }, };