@behavioral-agentic-design-system/core 0.24.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -2
- package/scripts/build-tokens.cjs +79 -5
- package/src/app/preview/components/page.tsx +4474 -208
- package/src/app/shell.tsx +18 -6
- package/src/components/customize/brand-mark-section.tsx +1 -1
- package/src/components/customize-tab.tsx +2 -2
- package/src/components/home-tab.tsx +2 -2
- package/src/components/ui/action-bar.tsx +142 -0
- package/src/components/ui/affix.tsx +109 -0
- package/src/components/ui/alert.tsx +37 -3
- package/src/components/ui/anchor.tsx +136 -0
- package/src/components/ui/angle-slider.tsx +265 -0
- package/src/components/ui/autocomplete.tsx +223 -0
- package/src/components/ui/avatar.tsx +8 -2
- package/src/components/ui/blockquote.tsx +112 -0
- package/src/components/ui/bottom-navigation.tsx +144 -0
- package/src/components/ui/burger.tsx +117 -0
- package/src/components/ui/button.tsx +101 -3
- package/src/components/ui/calendar.tsx +1 -1
- package/src/components/ui/card.tsx +43 -5
- package/src/components/ui/carousel.tsx +10 -5
- package/src/components/ui/cascader.tsx +253 -0
- package/src/components/ui/checkbox-card.tsx +176 -0
- package/src/components/ui/checkbox-group.tsx +231 -0
- package/src/components/ui/checkbox.tsx +14 -3
- package/src/components/ui/chip.tsx +143 -0
- package/src/components/ui/circular-progress.tsx +2 -2
- package/src/components/ui/color-swatch.tsx +73 -0
- package/src/components/ui/copy-button.tsx +21 -4
- package/src/components/ui/date-picker.tsx +6 -3
- package/src/components/ui/date-range-picker.tsx +6 -3
- package/src/components/ui/float-label.tsx +114 -0
- package/src/components/ui/floating-panel.tsx +129 -0
- package/src/components/ui/format-number.tsx +122 -0
- package/src/components/ui/highlight.tsx +85 -0
- package/src/components/ui/image.tsx +195 -0
- package/src/components/ui/index.ts +50 -0
- package/src/components/ui/indicator.tsx +2 -2
- package/src/components/ui/input.tsx +48 -4
- package/src/components/ui/kbd.tsx +1 -1
- package/src/components/ui/link.tsx +158 -0
- package/src/components/ui/listbox.tsx +426 -0
- package/src/components/ui/loading-overlay.tsx +80 -0
- package/src/components/ui/marquee.tsx +193 -0
- package/src/components/ui/masonry.tsx +164 -0
- package/src/components/ui/meter.tsx +186 -0
- package/src/components/ui/motion-toggle.tsx +170 -0
- package/src/components/ui/notification.tsx +175 -0
- package/src/components/ui/overlay.tsx +63 -0
- package/src/components/ui/progress.tsx +95 -4
- package/src/components/ui/rating-group.tsx +1 -0
- package/src/components/ui/separator.tsx +57 -1
- package/src/components/ui/sidebar.tsx +1 -1
- package/src/components/ui/signature-pad.tsx +381 -0
- package/src/components/ui/skeleton.tsx +59 -2
- package/src/components/ui/skip-link.tsx +117 -0
- package/src/components/ui/slider.tsx +86 -1
- package/src/components/ui/spoiler.tsx +131 -0
- package/src/components/ui/tabs.tsx +1 -1
- package/src/components/ui/text.tsx +135 -0
- package/src/components/ui/textarea.tsx +66 -2
- package/src/components/ui/timeline.tsx +71 -14
- package/src/components/ui/timer.tsx +183 -0
- package/src/components/ui/tour.tsx +332 -0
- package/src/components/ui/transfer-list.tsx +308 -0
- package/src/components/ui/visually-hidden.tsx +42 -0
- package/src/components/ui/watermark.tsx +0 -0
- package/src/data/docs-index.ts +9 -2
- package/src/stories/ActionBar.stories.tsx +201 -0
- package/src/stories/Affix.stories.tsx +165 -0
- package/src/stories/Alert.stories.tsx +58 -0
- package/src/stories/Anchor.stories.tsx +236 -0
- package/src/stories/AngleSlider.stories.tsx +128 -0
- package/src/stories/Autocomplete.stories.tsx +216 -0
- package/src/stories/Avatar.stories.tsx +73 -1
- package/src/stories/Blockquote.stories.tsx +148 -0
- package/src/stories/BottomNavigation.stories.tsx +195 -0
- package/src/stories/Burger.stories.tsx +79 -0
- package/src/stories/Button.stories.tsx +103 -2
- package/src/stories/Calendar.stories.tsx +4 -0
- package/src/stories/Card.stories.tsx +30 -0
- package/src/stories/Carousel.stories.tsx +2 -1
- package/src/stories/Cascader.stories.tsx +285 -0
- package/src/stories/Checkbox.stories.tsx +13 -0
- package/src/stories/CheckboxCard.stories.tsx +210 -0
- package/src/stories/CheckboxGroup.stories.tsx +186 -0
- package/src/stories/Chip.stories.tsx +173 -0
- package/src/stories/CircularProgress.stories.tsx +3 -0
- package/src/stories/ColorSwatch.stories.tsx +81 -0
- package/src/stories/CopyButton.stories.tsx +3 -3
- package/src/stories/DatePicker.stories.tsx +3 -0
- package/src/stories/DateRangePicker.stories.tsx +3 -0
- package/src/stories/Editable.stories.tsx +14 -0
- package/src/stories/FloatLabel.stories.tsx +148 -0
- package/src/stories/FloatingPanel.stories.tsx +176 -0
- package/src/stories/FormatNumber.stories.tsx +308 -0
- package/src/stories/Highlight.stories.tsx +140 -0
- package/src/stories/Image.stories.tsx +141 -0
- package/src/stories/Indicator.stories.tsx +3 -0
- package/src/stories/Input.stories.tsx +33 -0
- package/src/stories/Kbd.stories.tsx +3 -0
- package/src/stories/Link.stories.tsx +198 -0
- package/src/stories/Listbox.stories.tsx +240 -0
- package/src/stories/LoadingOverlay.stories.tsx +148 -0
- package/src/stories/Marquee.stories.tsx +170 -0
- package/src/stories/Masonry.stories.tsx +227 -0
- package/src/stories/Meter.stories.tsx +143 -0
- package/src/stories/MotionToggle.stories.tsx +85 -0
- package/src/stories/Notification.stories.tsx +264 -0
- package/src/stories/Overlay.stories.tsx +169 -0
- package/src/stories/PasswordInput.stories.tsx +4 -0
- package/src/stories/Progress.stories.tsx +70 -27
- package/src/stories/RatingGroup.stories.tsx +5 -0
- package/src/stories/Separator.stories.tsx +41 -5
- package/src/stories/Sidebar.stories.tsx +2 -1
- package/src/stories/SignaturePad.stories.tsx +112 -0
- package/src/stories/Skeleton.stories.tsx +23 -4
- package/src/stories/SkipLink.stories.tsx +137 -0
- package/src/stories/Slider.stories.tsx +28 -0
- package/src/stories/Spoiler.stories.tsx +122 -0
- package/src/stories/Tabs.stories.tsx +2 -1
- package/src/stories/Text.stories.tsx +191 -0
- package/src/stories/Textarea.stories.tsx +58 -6
- package/src/stories/Timeline.stories.tsx +82 -0
- package/src/stories/Timer.stories.tsx +160 -0
- package/src/stories/Tour.stories.tsx +191 -0
- package/src/stories/TransferList.stories.tsx +169 -0
- package/src/stories/VisuallyHidden.stories.tsx +105 -0
- package/src/stories/Watermark.stories.tsx +212 -0
- package/src/styles.css +80 -6
- package/src/tokens.json +2 -2
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
import { Burger } from "@behavioral-agentic-design-system/core/components/ui/burger";
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof Burger> = {
|
|
6
|
+
title: "Components/Burger",
|
|
7
|
+
component: Burger,
|
|
8
|
+
parameters: { layout: "centered" },
|
|
9
|
+
tags: ["autodocs"],
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default meta;
|
|
13
|
+
type Story = StoryObj<typeof meta>;
|
|
14
|
+
|
|
15
|
+
export const Default: Story = {
|
|
16
|
+
args: { "aria-label": "Toggle navigation" },
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const Opened: Story = {
|
|
20
|
+
args: { "aria-label": "Toggle navigation", opened: true },
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const Size_SmClosed: Story = {
|
|
24
|
+
args: { "aria-label": "Toggle navigation", size: "sm" },
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const Size_SmOpened: Story = {
|
|
28
|
+
args: { "aria-label": "Toggle navigation", size: "sm", opened: true },
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const Size_MdClosed: Story = {
|
|
32
|
+
args: { "aria-label": "Toggle navigation", size: "md" },
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const Size_LgClosed: Story = {
|
|
36
|
+
args: { "aria-label": "Toggle navigation", size: "lg" },
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const Size_LgOpened: Story = {
|
|
40
|
+
args: { "aria-label": "Toggle navigation", size: "lg", opened: true },
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const Disabled: Story = {
|
|
44
|
+
args: { "aria-label": "Toggle navigation", disabled: true },
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
function RealisticUseDemo() {
|
|
48
|
+
const [opened, setOpened] = React.useState(false);
|
|
49
|
+
return (
|
|
50
|
+
<div className="w-72 rounded-lg border border-border bg-background">
|
|
51
|
+
<header className="flex items-center justify-between border-b border-border p-2 pl-4">
|
|
52
|
+
<span className="text-sm font-semibold">BADS Docs</span>
|
|
53
|
+
<Burger
|
|
54
|
+
opened={opened}
|
|
55
|
+
onClick={() => setOpened((v) => !v)}
|
|
56
|
+
aria-label="Toggle navigation"
|
|
57
|
+
aria-controls="storybook-burger-nav"
|
|
58
|
+
/>
|
|
59
|
+
</header>
|
|
60
|
+
<nav
|
|
61
|
+
id="storybook-burger-nav"
|
|
62
|
+
aria-label="Main"
|
|
63
|
+
hidden={!opened}
|
|
64
|
+
className="p-4"
|
|
65
|
+
>
|
|
66
|
+
<ul className="space-y-2 text-sm text-muted-foreground">
|
|
67
|
+
<li>Getting started</li>
|
|
68
|
+
<li>Tokens</li>
|
|
69
|
+
<li>Components</li>
|
|
70
|
+
<li>Accessibility</li>
|
|
71
|
+
</ul>
|
|
72
|
+
</nav>
|
|
73
|
+
</div>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export const RealisticUse: Story = {
|
|
78
|
+
render: () => <RealisticUseDemo />,
|
|
79
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// Motion: base transition narrowed transition-all → transition-colors (Vercel/Rauno "list only the properties you animate" + BADS microanimation rule). Focus ring now appears instantly rather than fading — strictly better for a11y.
|
|
1
2
|
import { Meta, StoryObj } from "@storybook/react"
|
|
2
3
|
import { userEvent, within, expect, fn } from "storybook/test"
|
|
3
4
|
import { Button } from "@behavioral-agentic-design-system/core/components/ui/button"
|
|
@@ -84,6 +85,69 @@ export const Disabled: Story = {
|
|
|
84
85
|
},
|
|
85
86
|
};
|
|
86
87
|
|
|
88
|
+
export const Loading: Story = {
|
|
89
|
+
args: {
|
|
90
|
+
loading: true,
|
|
91
|
+
children: "Saving",
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export const Loading_Variants: Story = {
|
|
96
|
+
render: () => (
|
|
97
|
+
<div className="flex flex-wrap items-center gap-3">
|
|
98
|
+
<Button loading>Saving</Button>
|
|
99
|
+
<Button loading variant="secondary">
|
|
100
|
+
Saving
|
|
101
|
+
</Button>
|
|
102
|
+
<Button loading variant="outline">
|
|
103
|
+
Saving
|
|
104
|
+
</Button>
|
|
105
|
+
<Button loading variant="destructive">
|
|
106
|
+
Deleting
|
|
107
|
+
</Button>
|
|
108
|
+
<Button loading size="xl">
|
|
109
|
+
Publishing
|
|
110
|
+
</Button>
|
|
111
|
+
</div>
|
|
112
|
+
),
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// asChild forwards Button's styling to a single slotted element (e.g. an <a>
|
|
116
|
+
// used as a link-button). Slot calls React.Children.only, so Button must pass
|
|
117
|
+
// exactly one child through — regression guard: the loading-prop refactor once
|
|
118
|
+
// emitted a `[null, children]` array here that threw at prerender and broke the
|
|
119
|
+
// production deploy. Rendered in every showcase shell header via asChild.
|
|
120
|
+
export const AsChild: Story = {
|
|
121
|
+
render: () => (
|
|
122
|
+
<Button asChild variant="outline">
|
|
123
|
+
<a href="#docs">Read the docs</a>
|
|
124
|
+
</Button>
|
|
125
|
+
),
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// A loading button must announce aria-busy and refuse re-fire (disabled), so a
|
|
129
|
+
// double-click can't submit twice while the request is in flight.
|
|
130
|
+
export const Interaction_LoadingBlocksClick: Story = {
|
|
131
|
+
tags: ["test"],
|
|
132
|
+
args: {
|
|
133
|
+
loading: true,
|
|
134
|
+
children: "Saving",
|
|
135
|
+
onClick: fn(),
|
|
136
|
+
},
|
|
137
|
+
play: async ({ canvasElement, args }) => {
|
|
138
|
+
const canvas = within(canvasElement);
|
|
139
|
+
const button = canvas.getByRole("button", { name: /saving/i });
|
|
140
|
+
// A loading button is disabled + aria-busy, and disabled:pointer-events-none
|
|
141
|
+
// means a real pointer can't even reach it — asserting those attributes is
|
|
142
|
+
// the complete guarantee that onClick can't fire (a native disabled button
|
|
143
|
+
// can't dispatch click). Attempting userEvent.click here would fail on the
|
|
144
|
+
// pointer-events:none element rather than exercise the guard.
|
|
145
|
+
expect(button).toHaveAttribute("aria-busy", "true");
|
|
146
|
+
expect(button).toBeDisabled();
|
|
147
|
+
expect(args.onClick).not.toHaveBeenCalled();
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
|
|
87
151
|
export const Icon_XS: Story = {
|
|
88
152
|
args: {
|
|
89
153
|
size: "icon-xs",
|
|
@@ -140,6 +204,44 @@ export const Interaction_Click: Story = {
|
|
|
140
204
|
},
|
|
141
205
|
};
|
|
142
206
|
|
|
207
|
+
// aria-disabled pattern: `disabledReason` keeps the button focusable so a
|
|
208
|
+
// keyboard / screen-reader user can reach it and hear WHY it's unavailable —
|
|
209
|
+
// a natively-disabled button drops out of the tab order and its reason is
|
|
210
|
+
// undiscoverable. Prefer this on form-gating buttons.
|
|
211
|
+
export const Disabled_WithReason: Story = {
|
|
212
|
+
args: {
|
|
213
|
+
disabledReason: "Enter your email before saving",
|
|
214
|
+
children: "Save",
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
// Verifies the aria-disabled contract: focusable (NOT native [disabled]),
|
|
219
|
+
// aria-disabled=true, activation blocked (onClick never fires), and the reason
|
|
220
|
+
// wired via aria-describedby to an sr-only sibling that is NOT part of the name.
|
|
221
|
+
export const Interaction_DisabledReason: Story = {
|
|
222
|
+
tags: ["test"],
|
|
223
|
+
args: {
|
|
224
|
+
disabledReason: "Enter your email before saving",
|
|
225
|
+
children: "Save",
|
|
226
|
+
onClick: fn(),
|
|
227
|
+
},
|
|
228
|
+
play: async ({ canvasElement, args }) => {
|
|
229
|
+
const canvas = within(canvasElement);
|
|
230
|
+
// Accessible name is just the label — the reason is description-only.
|
|
231
|
+
const button = canvas.getByRole("button", { name: "Save" });
|
|
232
|
+
expect(button).toHaveAttribute("aria-disabled", "true");
|
|
233
|
+
expect(button).not.toBeDisabled(); // stays focusable
|
|
234
|
+
button.focus();
|
|
235
|
+
expect(button).toHaveFocus();
|
|
236
|
+
await userEvent.click(button);
|
|
237
|
+
expect(args.onClick).not.toHaveBeenCalled(); // activation blocked
|
|
238
|
+
const describedby = button.getAttribute("aria-describedby");
|
|
239
|
+
expect(describedby).toBeTruthy();
|
|
240
|
+
const reason = document.getElementById(describedby!.split(" ").pop()!);
|
|
241
|
+
expect(reason).toHaveTextContent("Enter your email before saving");
|
|
242
|
+
},
|
|
243
|
+
};
|
|
244
|
+
|
|
143
245
|
export const AllSizes: Story = {
|
|
144
246
|
render: () => (
|
|
145
247
|
<div className="flex flex-wrap items-center gap-3">
|
|
@@ -155,5 +257,4 @@ export const AllSizes: Story = {
|
|
|
155
257
|
</Button>
|
|
156
258
|
</div>
|
|
157
259
|
),
|
|
158
|
-
};
|
|
159
|
-
|
|
260
|
+
};
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
// `allow-font-normal-small` escape hatch in calendar.tsx). A font-medium bump to
|
|
3
3
|
// satisfy the SADS-1 weight floor is a deferred design decision on this shared
|
|
4
4
|
// primitive, not a mechanical fix.
|
|
5
|
+
//
|
|
6
|
+
// react-day-picker v10: the grid element's classNames key is `month_grid`
|
|
7
|
+
// (v10 renamed the old `table` key). The migration left `table`, which type-
|
|
8
|
+
// checked under nothing and broke `next build`; fixed in calendar.tsx.
|
|
5
9
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
6
10
|
import { useState } from "react";
|
|
7
11
|
import { Calendar } from "@behavioral-agentic-design-system/core/components/ui/calendar";
|
|
@@ -27,6 +27,36 @@ export const Default: Story = {
|
|
|
27
27
|
</Card>),
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
+
export const Variant_Default: Story = {
|
|
31
|
+
render: () => (<Card variant="default" className="w-[360px]">
|
|
32
|
+
<CardHeader>
|
|
33
|
+
<CardTitle>Total Revenue</CardTitle>
|
|
34
|
+
<CardDescription>+20.1% from last month</CardDescription>
|
|
35
|
+
</CardHeader>
|
|
36
|
+
<CardContent>
|
|
37
|
+
<p className="text-3xl font-semibold tabular-nums">$15,231.89</p>
|
|
38
|
+
</CardContent>
|
|
39
|
+
<CardFooter>
|
|
40
|
+
<Button size="sm">View report</Button>
|
|
41
|
+
</CardFooter>
|
|
42
|
+
</Card>),
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const Variant_Elevated: Story = {
|
|
46
|
+
render: () => (<Card variant="elevated" className="w-[360px]">
|
|
47
|
+
<CardHeader>
|
|
48
|
+
<CardTitle>Total Revenue</CardTitle>
|
|
49
|
+
<CardDescription>+20.1% from last month</CardDescription>
|
|
50
|
+
</CardHeader>
|
|
51
|
+
<CardContent>
|
|
52
|
+
<p className="text-3xl font-semibold tabular-nums">$15,231.89</p>
|
|
53
|
+
</CardContent>
|
|
54
|
+
<CardFooter>
|
|
55
|
+
<Button size="sm">View report</Button>
|
|
56
|
+
</CardFooter>
|
|
57
|
+
</Card>),
|
|
58
|
+
};
|
|
59
|
+
|
|
30
60
|
export const RealisticUse: Story = {
|
|
31
61
|
render: () => (<Card className="w-[360px]">
|
|
32
62
|
<CardHeader>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// A11y: indicator dots changed from role=tab/tablist/aria-selected (a tab controlling no tabpanel — an ARIA anti-pattern) to plain buttons + aria-current on the active slide, per the APG carousel dot pattern.
|
|
1
2
|
// scrollbar-none (Tailwind v4.3 utility) replaces [scrollbar-width:none] [&::-webkit-scrollbar]:hidden
|
|
2
3
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
4
|
import {
|
|
@@ -230,4 +231,4 @@ export const RealisticUse: Story = {
|
|
|
230
231
|
</Carousel>
|
|
231
232
|
</div>
|
|
232
233
|
),
|
|
233
|
-
};
|
|
234
|
+
};
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Cascader, type CascaderOption } from "@behavioral-agentic-design-system/core/components/ui/cascader";
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof Cascader> = {
|
|
6
|
+
title: "Components/Cascader",
|
|
7
|
+
component: Cascader,
|
|
8
|
+
parameters: { layout: "centered" },
|
|
9
|
+
tags: ["autodocs"],
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default meta;
|
|
13
|
+
type Story = StoryObj<typeof Cascader>;
|
|
14
|
+
|
|
15
|
+
const geographyOptions: CascaderOption[] = [
|
|
16
|
+
{
|
|
17
|
+
value: "na",
|
|
18
|
+
label: "North America",
|
|
19
|
+
children: [
|
|
20
|
+
{
|
|
21
|
+
value: "us",
|
|
22
|
+
label: "United States",
|
|
23
|
+
children: [
|
|
24
|
+
{ value: "ca", label: "California" },
|
|
25
|
+
{ value: "ny", label: "New York" },
|
|
26
|
+
{ value: "tx", label: "Texas" },
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
value: "ca-country",
|
|
31
|
+
label: "Canada",
|
|
32
|
+
children: [
|
|
33
|
+
{ value: "on", label: "Ontario" },
|
|
34
|
+
{ value: "bc", label: "British Columbia" },
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
value: "eu",
|
|
41
|
+
label: "Europe",
|
|
42
|
+
children: [
|
|
43
|
+
{
|
|
44
|
+
value: "gb",
|
|
45
|
+
label: "United Kingdom",
|
|
46
|
+
children: [
|
|
47
|
+
{ value: "eng", label: "England" },
|
|
48
|
+
{ value: "sco", label: "Scotland" },
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
value: "de",
|
|
53
|
+
label: "Germany",
|
|
54
|
+
children: [
|
|
55
|
+
{ value: "by", label: "Bavaria" },
|
|
56
|
+
{ value: "be", label: "Berlin" },
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
value: "apac",
|
|
63
|
+
label: "Asia Pacific",
|
|
64
|
+
children: [
|
|
65
|
+
{
|
|
66
|
+
value: "jp",
|
|
67
|
+
label: "Japan",
|
|
68
|
+
children: [
|
|
69
|
+
{ value: "to", label: "Tokyo" },
|
|
70
|
+
{ value: "os", label: "Osaka" },
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
value: "au",
|
|
75
|
+
label: "Australia",
|
|
76
|
+
children: [
|
|
77
|
+
{ value: "nsw", label: "New South Wales" },
|
|
78
|
+
{ value: "vic", label: "Victoria" },
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
];
|
|
84
|
+
|
|
85
|
+
const categoryOptions: CascaderOption[] = [
|
|
86
|
+
{
|
|
87
|
+
value: "electronics",
|
|
88
|
+
label: "Electronics",
|
|
89
|
+
children: [
|
|
90
|
+
{
|
|
91
|
+
value: "phones",
|
|
92
|
+
label: "Phones",
|
|
93
|
+
children: [
|
|
94
|
+
{ value: "smartphones", label: "Smartphones" },
|
|
95
|
+
{ value: "feature-phones", label: "Feature Phones" },
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
value: "laptops",
|
|
100
|
+
label: "Laptops",
|
|
101
|
+
children: [
|
|
102
|
+
{ value: "gaming", label: "Gaming" },
|
|
103
|
+
{ value: "ultrabooks", label: "Ultrabooks" },
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
value: "clothing",
|
|
110
|
+
label: "Clothing",
|
|
111
|
+
children: [
|
|
112
|
+
{ value: "mens", label: "Men's", children: [
|
|
113
|
+
{ value: "mens-shirts", label: "Shirts" },
|
|
114
|
+
{ value: "mens-pants", label: "Pants" },
|
|
115
|
+
]},
|
|
116
|
+
{ value: "womens", label: "Women's", children: [
|
|
117
|
+
{ value: "womens-dresses", label: "Dresses" },
|
|
118
|
+
{ value: "womens-tops", label: "Tops" },
|
|
119
|
+
]},
|
|
120
|
+
],
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
value: "home",
|
|
124
|
+
label: "Home & Garden",
|
|
125
|
+
children: [
|
|
126
|
+
{ value: "furniture", label: "Furniture", children: [
|
|
127
|
+
{ value: "seating", label: "Seating" },
|
|
128
|
+
{ value: "storage", label: "Storage" },
|
|
129
|
+
]},
|
|
130
|
+
{ value: "garden", label: "Garden", children: [
|
|
131
|
+
{ value: "tools", label: "Tools" },
|
|
132
|
+
{ value: "plants", label: "Plants" },
|
|
133
|
+
]},
|
|
134
|
+
],
|
|
135
|
+
},
|
|
136
|
+
];
|
|
137
|
+
|
|
138
|
+
const twoLevelOptions: CascaderOption[] = [
|
|
139
|
+
{ value: "design", label: "Design", children: [
|
|
140
|
+
{ value: "ui", label: "UI Design" },
|
|
141
|
+
{ value: "ux", label: "UX Research" },
|
|
142
|
+
{ value: "brand", label: "Brand Identity" },
|
|
143
|
+
]},
|
|
144
|
+
{ value: "engineering", label: "Engineering", children: [
|
|
145
|
+
{ value: "frontend", label: "Frontend" },
|
|
146
|
+
{ value: "backend", label: "Backend" },
|
|
147
|
+
{ value: "devops", label: "DevOps" },
|
|
148
|
+
]},
|
|
149
|
+
{ value: "product", label: "Product", children: [
|
|
150
|
+
{ value: "pm", label: "Product Management" },
|
|
151
|
+
{ value: "analytics", label: "Analytics" },
|
|
152
|
+
]},
|
|
153
|
+
];
|
|
154
|
+
|
|
155
|
+
export const Default: Story = {
|
|
156
|
+
args: {
|
|
157
|
+
options: geographyOptions,
|
|
158
|
+
placeholder: "Select region…",
|
|
159
|
+
},
|
|
160
|
+
render: (args) => {
|
|
161
|
+
const [value, setValue] = React.useState<string[]>([]);
|
|
162
|
+
return (
|
|
163
|
+
<div className="w-72">
|
|
164
|
+
<Cascader
|
|
165
|
+
{...args}
|
|
166
|
+
value={value}
|
|
167
|
+
onValueChange={(v) => setValue(v)}
|
|
168
|
+
/>
|
|
169
|
+
{value.length > 0 && (
|
|
170
|
+
<p className="mt-2 text-sm text-muted-foreground">
|
|
171
|
+
Selected: {value.join(" → ")}
|
|
172
|
+
</p>
|
|
173
|
+
)}
|
|
174
|
+
</div>
|
|
175
|
+
);
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
export const TwoLevels: Story = {
|
|
180
|
+
render: () => {
|
|
181
|
+
const [value, setValue] = React.useState<string[]>([]);
|
|
182
|
+
return (
|
|
183
|
+
<div className="w-64">
|
|
184
|
+
<Cascader
|
|
185
|
+
options={twoLevelOptions}
|
|
186
|
+
placeholder="Select department…"
|
|
187
|
+
value={value}
|
|
188
|
+
onValueChange={(v) => setValue(v)}
|
|
189
|
+
/>
|
|
190
|
+
</div>
|
|
191
|
+
);
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
export const CategorySelection: Story = {
|
|
196
|
+
render: () => {
|
|
197
|
+
const [value, setValue] = React.useState<string[]>([]);
|
|
198
|
+
const [labels, setLabels] = React.useState<string[]>([]);
|
|
199
|
+
return (
|
|
200
|
+
<div className="w-80">
|
|
201
|
+
<Cascader
|
|
202
|
+
options={categoryOptions}
|
|
203
|
+
placeholder="Browse categories…"
|
|
204
|
+
value={value}
|
|
205
|
+
onValueChange={(v, l) => { setValue(v); setLabels(l); }}
|
|
206
|
+
/>
|
|
207
|
+
{labels.length > 0 && (
|
|
208
|
+
<p className="mt-2 text-sm text-muted-foreground">
|
|
209
|
+
{labels.join(" / ")}
|
|
210
|
+
</p>
|
|
211
|
+
)}
|
|
212
|
+
</div>
|
|
213
|
+
);
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
export const PreselectedValue: Story = {
|
|
218
|
+
render: () => (
|
|
219
|
+
<div className="w-72">
|
|
220
|
+
<Cascader
|
|
221
|
+
options={geographyOptions}
|
|
222
|
+
value={["na", "us", "ca"]}
|
|
223
|
+
onValueChange={() => {}}
|
|
224
|
+
/>
|
|
225
|
+
</div>
|
|
226
|
+
),
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
export const Disabled: Story = {
|
|
230
|
+
args: {
|
|
231
|
+
options: geographyOptions,
|
|
232
|
+
disabled: true,
|
|
233
|
+
value: ["na", "us", "ny"],
|
|
234
|
+
},
|
|
235
|
+
render: (args) => (
|
|
236
|
+
<div className="w-72">
|
|
237
|
+
<Cascader {...args} onValueChange={() => {}} />
|
|
238
|
+
</div>
|
|
239
|
+
),
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
export const RealisticUse: Story = {
|
|
243
|
+
render: () => {
|
|
244
|
+
const [region, setRegion] = React.useState<string[]>([]);
|
|
245
|
+
const [category, setCategory] = React.useState<string[]>([]);
|
|
246
|
+
|
|
247
|
+
return (
|
|
248
|
+
<div className="w-[480px] rounded-lg border bg-card p-6 shadow-sm">
|
|
249
|
+
<h3 className="mb-4 text-base font-semibold">New Listing</h3>
|
|
250
|
+
<div className="space-y-4">
|
|
251
|
+
<div className="space-y-1.5">
|
|
252
|
+
<label id="region-label" className="text-sm font-medium">
|
|
253
|
+
Target Region
|
|
254
|
+
</label>
|
|
255
|
+
<Cascader
|
|
256
|
+
options={geographyOptions}
|
|
257
|
+
value={region}
|
|
258
|
+
onValueChange={(v) => setRegion(v)}
|
|
259
|
+
placeholder="Select region…"
|
|
260
|
+
aria-labelledby="region-label"
|
|
261
|
+
/>
|
|
262
|
+
</div>
|
|
263
|
+
<div className="space-y-1.5">
|
|
264
|
+
<label id="category-label" className="text-sm font-medium">
|
|
265
|
+
Product Category
|
|
266
|
+
</label>
|
|
267
|
+
<Cascader
|
|
268
|
+
options={categoryOptions}
|
|
269
|
+
value={category}
|
|
270
|
+
onValueChange={(v) => setCategory(v)}
|
|
271
|
+
placeholder="Browse categories…"
|
|
272
|
+
aria-labelledby="category-label"
|
|
273
|
+
/>
|
|
274
|
+
</div>
|
|
275
|
+
{(region.length > 0 || category.length > 0) && (
|
|
276
|
+
<div className="rounded-md bg-muted px-3 py-2 text-sm">
|
|
277
|
+
{region.length > 0 && <p>Region: {region.join(" → ")}</p>}
|
|
278
|
+
{category.length > 0 && <p>Category: {category.join(" → ")}</p>}
|
|
279
|
+
</div>
|
|
280
|
+
)}
|
|
281
|
+
</div>
|
|
282
|
+
</div>
|
|
283
|
+
);
|
|
284
|
+
},
|
|
285
|
+
};
|
|
@@ -19,6 +19,19 @@ export const Default: Story = {
|
|
|
19
19
|
</div>),
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
+
// Indeterminate must render a MINUS, not a check — partial selection has to be
|
|
23
|
+
// visually distinct from full selection (the visual now matches the
|
|
24
|
+
// aria-checked="mixed" Radix announces). Regression guard for the 2026-07-11
|
|
25
|
+
// CheckboxGroup build's checkbox.tsx indicator fix.
|
|
26
|
+
export const Indeterminate: Story = {
|
|
27
|
+
render: () => (
|
|
28
|
+
<div className="flex items-center gap-2">
|
|
29
|
+
<Checkbox id="indeterminate" checked="indeterminate" />
|
|
30
|
+
<Label htmlFor="indeterminate">Select all components</Label>
|
|
31
|
+
</div>
|
|
32
|
+
),
|
|
33
|
+
};
|
|
34
|
+
|
|
22
35
|
export const Disabled: Story = {
|
|
23
36
|
args: { disabled: true, "aria-label": "I agree to the terms" } as any,
|
|
24
37
|
};
|