{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "native-select-story",
  "title": "Native Select Story",
  "author": "Lloyd Richards <lloyd.d.richards@gmail.com>",
  "description": "Interactive Storybook stories demonstrating native select usage and variants",
  "dependencies": [
    "react-aria-components"
  ],
  "registryDependencies": [
    "label",
    "native-select"
  ],
  "files": [
    {
      "path": "registry/ui/native-select-story/native-select-aria.stories.tsx",
      "content": "import type { Meta, StoryObj } from \"@storybook/nextjs-vite\";\nimport { useState } from \"react\";\nimport { expect, userEvent } from \"storybook/test\";\n\nimport { Label } from \"@/components/ui/label\";\nimport {\n  NativeSelect,\n  NativeSelectOptGroup,\n  NativeSelectOption,\n} from \"@/components/ui/native-select\";\n\n/** A browser-native select for choosing one value from a list of options. */\nconst meta = {\n  id: \"ui-aria-nativeselect\",\n  title: \"ui/NativeSelect\",\n  component: NativeSelect,\n  tags: [\"autodocs\"],\n  parameters: { layout: \"centered\" },\n  args: {\n    \"aria-label\": \"Fruit\",\n    defaultValue: \"apple\",\n    disabled: false,\n    size: \"default\",\n  },\n  render: (args) => (\n    <NativeSelect {...args}>\n      <NativeSelectOption value=\"apple\">Apple</NativeSelectOption>\n      <NativeSelectOption value=\"banana\">Banana</NativeSelectOption>\n      <NativeSelectOption value=\"blueberry\">Blueberry</NativeSelectOption>\n    </NativeSelect>\n  ),\n} satisfies Meta<typeof NativeSelect>;\n\nexport default meta;\ntype Story = StoryObj<typeof meta>;\n\n/** Choose a fruit using the browser's native option menu. */\nexport const Default: Story = {};\n\n/** Use the small size in compact forms and toolbars. */\nexport const Small: Story = { args: { size: \"sm\" } };\n\n/** Disable the select when its value cannot be changed. */\nexport const Disabled: Story = { args: { disabled: true } };\n\n/** Group related options and disable choices that are unavailable. */\nexport const GroupedOptions: Story = {\n  render: (args) => (\n    <NativeSelect {...args}>\n      <NativeSelectOptGroup label=\"Fruit\">\n        <NativeSelectOption value=\"apple\">Apple</NativeSelectOption>\n        <NativeSelectOption value=\"banana\">Banana</NativeSelectOption>\n      </NativeSelectOptGroup>\n      <NativeSelectOptGroup label=\"Vegetables\">\n        <NativeSelectOption value=\"broccoli\">Broccoli</NativeSelectOption>\n        <NativeSelectOption value=\"carrot\" disabled>\n          Carrot (unavailable)\n        </NativeSelectOption>\n      </NativeSelectOptGroup>\n    </NativeSelect>\n  ),\n};\n\n/** Associate a visible label with the select. */\nexport const WithLabel: Story = {\n  render: (args) => (\n    <div className=\"grid gap-2\">\n      <Label htmlFor=\"native-select-fruit\">Fruit</Label>\n      <NativeSelect {...args} id=\"native-select-fruit\" aria-label={undefined}>\n        <NativeSelectOption value=\"apple\">Apple</NativeSelectOption>\n        <NativeSelectOption value=\"banana\">Banana</NativeSelectOption>\n        <NativeSelectOption value=\"blueberry\">Blueberry</NativeSelectOption>\n      </NativeSelect>\n    </div>\n  ),\n};\n\n/** Mark an invalid selection and explain how to correct it. */\nexport const Invalid: Story = {\n  args: { defaultValue: \"\", \"aria-invalid\": true },\n  render: (args) => (\n    <div className=\"grid gap-2\">\n      <Label htmlFor=\"native-select-required-fruit\">Fruit</Label>\n      <NativeSelect\n        {...args}\n        id=\"native-select-required-fruit\"\n        aria-label={undefined}\n        aria-describedby=\"native-select-fruit-error\"\n        required\n      >\n        <NativeSelectOption value=\"\" disabled>\n          Select a fruit\n        </NativeSelectOption>\n        <NativeSelectOption value=\"apple\">Apple</NativeSelectOption>\n        <NativeSelectOption value=\"banana\">Banana</NativeSelectOption>\n      </NativeSelect>\n      <p id=\"native-select-fruit-error\" className=\"text-destructive text-sm\">\n        Choose a fruit to continue.\n      </p>\n    </div>\n  ),\n};\n\n/** Keep the selected value in React state to update related content. */\nexport const Controlled: Story = {\n  render: function Render(args) {\n    const [fruit, setFruit] = useState(\"apple\");\n\n    return (\n      <div className=\"grid gap-2\">\n        <NativeSelect\n          {...args}\n          defaultValue={undefined}\n          value={fruit}\n          onChange={(event) => setFruit(event.target.value)}\n        >\n          <NativeSelectOption value=\"apple\">Apple</NativeSelectOption>\n          <NativeSelectOption value=\"banana\">Banana</NativeSelectOption>\n          <NativeSelectOption value=\"blueberry\">Blueberry</NativeSelectOption>\n        </NativeSelect>\n        <p role=\"status\" className=\"text-muted-foreground text-sm\">\n          Selected fruit: {fruit}\n        </p>\n      </div>\n    );\n  },\n};\n\n/** Changing an option updates both the select and the controlled state. */\nexport const ShouldChangeValue: Story = {\n  ...Controlled,\n  tags: [\"!dev\", \"!autodocs\"],\n  play: async ({ canvas }) => {\n    const select = canvas.getByRole(\"combobox\", { name: \"Fruit\" });\n    await expect(select).toHaveValue(\"apple\");\n    await userEvent.selectOptions(select, \"banana\");\n    await expect(select).toHaveValue(\"banana\");\n    await expect(canvas.getByRole(\"status\")).toHaveTextContent(\n      \"Selected fruit: banana\",\n    );\n    await userEvent.selectOptions(select, \"blueberry\");\n    await expect(select).toHaveValue(\"blueberry\");\n    await expect(canvas.getByRole(\"status\")).toHaveTextContent(\n      \"Selected fruit: blueberry\",\n    );\n  },\n};\n",
      "type": "registry:component",
      "target": "@ui/native-select.stories.tsx"
    }
  ],
  "categories": [
    "ui",
    "storybook",
    "native-select"
  ],
  "type": "registry:component"
}