46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import type { Meta, StoryObj } from "@storybook/react";
|
|
import { DemoField, DemoSelect } from "./_demo-primitives.js";
|
|
|
|
const meta: Meta<typeof DemoSelect> = {
|
|
title: "UI / Inputs / Select",
|
|
component: DemoSelect,
|
|
tags: ["autodocs"],
|
|
};
|
|
|
|
export default meta;
|
|
|
|
type Story = StoryObj<typeof DemoSelect>;
|
|
|
|
const roleOptions = [
|
|
{ value: "viewer", label: "Viewer" },
|
|
{ value: "editor", label: "Editor" },
|
|
{ value: "admin", label: "Admin" },
|
|
];
|
|
|
|
export const Single: Story = {
|
|
args: { options: roleOptions, defaultValue: "viewer" },
|
|
render: (args) => (
|
|
<DemoField label="Role" htmlFor="role-single">
|
|
<DemoSelect id="role-single" {...args} />
|
|
</DemoField>
|
|
),
|
|
};
|
|
|
|
export const Multi: Story = {
|
|
args: { options: roleOptions, multiple: true, size: 3 },
|
|
render: (args) => (
|
|
<DemoField label="Roles" htmlFor="role-multi" hint="Hold ⌘/Ctrl to select multiple.">
|
|
<DemoSelect id="role-multi" {...args} />
|
|
</DemoField>
|
|
),
|
|
};
|
|
|
|
export const Disabled: Story = {
|
|
args: { options: roleOptions, disabled: true, defaultValue: "admin" },
|
|
render: (args) => (
|
|
<DemoField label="Role" htmlFor="role-disabled">
|
|
<DemoSelect id="role-disabled" {...args} />
|
|
</DemoField>
|
|
),
|
|
};
|