@behavioral-agentic-design-system/core 0.23.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 +8 -4
- package/scripts/build-tokens.cjs +79 -5
- package/src/app/preview/components/page.tsx +4760 -213
- 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/data-list.tsx +169 -0
- package/src/components/ui/date-picker.tsx +6 -3
- package/src/components/ui/date-range-picker.tsx +6 -3
- package/src/components/ui/fieldset.tsx +8 -2
- 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 +52 -0
- package/src/components/ui/indicator.tsx +2 -2
- package/src/components/ui/input-group.tsx +11 -1
- 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/qr-code.tsx +107 -0
- 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 +10 -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/DataList.stories.tsx +160 -0
- 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/Fieldset.stories.tsx +4 -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/InputGroup.stories.tsx +39 -41
- 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/QrCode.stories.tsx +146 -0
- 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
|
@@ -7,7 +7,8 @@ import {
|
|
|
7
7
|
InputGroupText,
|
|
8
8
|
InputGroupButton,
|
|
9
9
|
} from "@behavioral-agentic-design-system/core/components/ui/input-group";
|
|
10
|
-
import {
|
|
10
|
+
import { CopyButton } from "@behavioral-agentic-design-system/core/components/ui/copy-button";
|
|
11
|
+
import { Search, Link2 } from "lucide-react";
|
|
11
12
|
|
|
12
13
|
const meta: Meta<typeof InputGroup> = {
|
|
13
14
|
title: "Components/InputGroup",
|
|
@@ -119,37 +120,29 @@ export const TextPrefix: Story = {
|
|
|
119
120
|
),
|
|
120
121
|
};
|
|
121
122
|
|
|
123
|
+
// Inline copy actions compose the CopyButton primitive — it owns the real
|
|
124
|
+
// clipboard write, the token-driven icon-swap "Copied!" animation, and the
|
|
125
|
+
// aria-live announcement. Never hand-roll a copied state (the first version
|
|
126
|
+
// of this story did, and the showcase demo then shipped a dead Copy button —
|
|
127
|
+
// Sir caught it on prod, 2026-07-06).
|
|
122
128
|
export const WithButton: Story = {
|
|
123
|
-
render: () =>
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
{copied ? (
|
|
141
|
-
<>
|
|
142
|
-
<Check aria-hidden /> Copied
|
|
143
|
-
</>
|
|
144
|
-
) : (
|
|
145
|
-
<>
|
|
146
|
-
<Copy aria-hidden /> Copy
|
|
147
|
-
</>
|
|
148
|
-
)}
|
|
149
|
-
</InputGroupButton>
|
|
150
|
-
</InputGroup>
|
|
151
|
-
);
|
|
152
|
-
},
|
|
129
|
+
render: () => (
|
|
130
|
+
<InputGroup className="w-96">
|
|
131
|
+
<InputGroupInput
|
|
132
|
+
readOnly
|
|
133
|
+
value="avery.castillo@protonmail.com"
|
|
134
|
+
aria-label="Invite link email"
|
|
135
|
+
/>
|
|
136
|
+
<CopyButton
|
|
137
|
+
value="avery.castillo@protonmail.com"
|
|
138
|
+
variant="ghost"
|
|
139
|
+
size="sm"
|
|
140
|
+
className="h-full shrink-0 rounded-none"
|
|
141
|
+
>
|
|
142
|
+
Copy
|
|
143
|
+
</CopyButton>
|
|
144
|
+
</InputGroup>
|
|
145
|
+
),
|
|
153
146
|
};
|
|
154
147
|
|
|
155
148
|
export const Disabled: Story = {
|
|
@@ -186,16 +179,21 @@ export const RealisticUse: Story = {
|
|
|
186
179
|
<label htmlFor="ig-search" className="text-sm font-medium">
|
|
187
180
|
Find a member
|
|
188
181
|
</label>
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
182
|
+
{/* InputGroupButton is for non-copy inline actions (submit, clear).
|
|
183
|
+
Copy actions use CopyButton — see WithButton above. */}
|
|
184
|
+
<form action="#" onSubmit={(e) => e.preventDefault()}>
|
|
185
|
+
<InputGroup>
|
|
186
|
+
<InputGroupAddon align="inline-start">
|
|
187
|
+
<Search aria-hidden />
|
|
188
|
+
</InputGroupAddon>
|
|
189
|
+
<InputGroupInput
|
|
190
|
+
id="ig-search"
|
|
191
|
+
placeholder="Priya Ramanathan"
|
|
192
|
+
defaultValue="Mei-Lin Chen"
|
|
193
|
+
/>
|
|
194
|
+
<InputGroupButton type="submit">Search</InputGroupButton>
|
|
195
|
+
</InputGroup>
|
|
196
|
+
</form>
|
|
199
197
|
</div>
|
|
200
198
|
|
|
201
199
|
<div className="flex flex-col gap-1.5">
|
|
@@ -20,6 +20,9 @@ export const Default: Story = {
|
|
|
20
20
|
render: () => <Kbd>⌘K</Kbd>,
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
+
// The default variant's bottom shadow now uses the real oklch --border token:
|
|
24
|
+
// it was shadow-[…hsl(var(--border))] — hsl() wrapping an oklch value is invalid
|
|
25
|
+
// CSS and silently dropped the shadow — fixed to …var(--border) (2026-07-24).
|
|
23
26
|
export const Variant_Default: Story = {
|
|
24
27
|
render: () => (
|
|
25
28
|
<div className="flex items-center gap-2">
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
3
|
+
import { Link } from "@behavioral-agentic-design-system/core/components/ui/link"
|
|
4
|
+
import { Text } from "@behavioral-agentic-design-system/core/components/ui/text"
|
|
5
|
+
import {
|
|
6
|
+
Card,
|
|
7
|
+
CardContent,
|
|
8
|
+
CardHeader,
|
|
9
|
+
CardTitle,
|
|
10
|
+
} from "@behavioral-agentic-design-system/core/components/ui/card"
|
|
11
|
+
import { Separator } from "@behavioral-agentic-design-system/core/components/ui/separator"
|
|
12
|
+
|
|
13
|
+
const meta: Meta<typeof Link> = {
|
|
14
|
+
title: "Components/Link",
|
|
15
|
+
component: Link,
|
|
16
|
+
parameters: { layout: "centered" },
|
|
17
|
+
tags: ["autodocs"],
|
|
18
|
+
argTypes: {
|
|
19
|
+
underline: { control: "select", options: ["always", "hover", "none"] },
|
|
20
|
+
tone: { control: "select", options: ["default", "foreground", "muted"] },
|
|
21
|
+
external: { control: "boolean" },
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default meta
|
|
26
|
+
type Story = StoryObj<typeof meta>
|
|
27
|
+
|
|
28
|
+
// Content pulled from content/personas/bads.json (real-content rule) —
|
|
29
|
+
// URLs, names, and copy are entries from the persona pool.
|
|
30
|
+
|
|
31
|
+
export const Default: Story = {
|
|
32
|
+
render: () => (
|
|
33
|
+
<div className="max-w-md">
|
|
34
|
+
<Text>
|
|
35
|
+
Read the{" "}
|
|
36
|
+
<Link href="https://design.bads.com/docs/getting-started">
|
|
37
|
+
getting started guide
|
|
38
|
+
</Link>{" "}
|
|
39
|
+
before customizing tokens — the underline (not color alone) marks the
|
|
40
|
+
link inside prose.
|
|
41
|
+
</Text>
|
|
42
|
+
</div>
|
|
43
|
+
),
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Standalone/nav context — position identifies the link, so the underline
|
|
47
|
+
// can wait for hover.
|
|
48
|
+
export const Variant_Underline_Hover: Story = {
|
|
49
|
+
render: () => (
|
|
50
|
+
<nav aria-label="Documentation" className="flex flex-col gap-2 text-sm">
|
|
51
|
+
<Link href="https://design.bads.com/docs/getting-started" underline="hover">
|
|
52
|
+
Getting started
|
|
53
|
+
</Link>
|
|
54
|
+
<Link href="https://design.bads.com/share/tokens-v2-proposal" underline="hover">
|
|
55
|
+
Tokens v2 proposal
|
|
56
|
+
</Link>
|
|
57
|
+
<Link href="https://design.bads.com" underline="hover">
|
|
58
|
+
Component registry
|
|
59
|
+
</Link>
|
|
60
|
+
</nav>
|
|
61
|
+
),
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export const Variant_Underline_None: Story = {
|
|
65
|
+
render: () => (
|
|
66
|
+
<div className="flex items-center gap-4 text-sm">
|
|
67
|
+
<Link href="https://design.bads.com" underline="none">
|
|
68
|
+
Docs
|
|
69
|
+
</Link>
|
|
70
|
+
<Link href="https://design.bads.com/share/tokens-v2-proposal" underline="none">
|
|
71
|
+
Changelog
|
|
72
|
+
</Link>
|
|
73
|
+
<Link href="https://design.bads.com/docs/getting-started" underline="none">
|
|
74
|
+
Support
|
|
75
|
+
</Link>
|
|
76
|
+
</div>
|
|
77
|
+
),
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export const Variant_Tone_Foreground: Story = {
|
|
81
|
+
render: () => (
|
|
82
|
+
<div className="max-w-md">
|
|
83
|
+
<Text>
|
|
84
|
+
Reviewed by{" "}
|
|
85
|
+
<Link href="https://design.bads.com" tone="foreground">
|
|
86
|
+
Seo-yun Park
|
|
87
|
+
</Link>{" "}
|
|
88
|
+
on 2026-05-26 — 36 components, all passing AAA contrast.
|
|
89
|
+
</Text>
|
|
90
|
+
</div>
|
|
91
|
+
),
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export const Variant_Tone_Muted: Story = {
|
|
95
|
+
render: () => (
|
|
96
|
+
<div className="flex items-center gap-3 text-sm">
|
|
97
|
+
<Link href="https://design.bads.com" tone="muted" underline="hover">
|
|
98
|
+
Privacy
|
|
99
|
+
</Link>
|
|
100
|
+
<Link href="https://design.bads.com" tone="muted" underline="hover">
|
|
101
|
+
Terms
|
|
102
|
+
</Link>
|
|
103
|
+
<Link href="https://design.bads.com" tone="muted" underline="hover">
|
|
104
|
+
Accessibility statement
|
|
105
|
+
</Link>
|
|
106
|
+
</div>
|
|
107
|
+
),
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// external sets target="_blank" rel="noopener noreferrer", appends the
|
|
111
|
+
// aria-hidden icon, and announces "(opens in new tab)" to screen readers.
|
|
112
|
+
export const External: Story = {
|
|
113
|
+
render: () => (
|
|
114
|
+
<div className="max-w-md">
|
|
115
|
+
<Text>
|
|
116
|
+
The token pipeline write-up lives at{" "}
|
|
117
|
+
<Link href="https://design.bads.com/share/tokens-v2-proposal" external>
|
|
118
|
+
design.bads.com/share/tokens-v2-proposal
|
|
119
|
+
</Link>{" "}
|
|
120
|
+
if your team wants the full methodology.
|
|
121
|
+
</Text>
|
|
122
|
+
</div>
|
|
123
|
+
),
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Radix Slot idiom — a framework anchor (Next.js <Link>, TanStack <Link>)
|
|
127
|
+
// slots in and receives the styles + data attributes. Demoed with a plain
|
|
128
|
+
// <a> since Storybook has no router; the contract is identical.
|
|
129
|
+
export const AsChild: Story = {
|
|
130
|
+
render: () => (
|
|
131
|
+
<div className="max-w-md">
|
|
132
|
+
<Text>
|
|
133
|
+
Jump to{" "}
|
|
134
|
+
<Link asChild>
|
|
135
|
+
<a href="https://design.bads.com/docs/getting-started">
|
|
136
|
+
the customize tab
|
|
137
|
+
</a>
|
|
138
|
+
</Link>{" "}
|
|
139
|
+
to override brand colors per-user.
|
|
140
|
+
</Text>
|
|
141
|
+
</div>
|
|
142
|
+
),
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// A raw URL as link text in a narrow container — exercises the overflow
|
|
146
|
+
// contract ([overflow-wrap:anywhere]): the unbroken string wraps instead
|
|
147
|
+
// of bleeding out of the 320px box.
|
|
148
|
+
export const LongContent: Story = {
|
|
149
|
+
render: () => (
|
|
150
|
+
<div className="w-[320px]">
|
|
151
|
+
<Text variant="body-sm">
|
|
152
|
+
Full proposal:{" "}
|
|
153
|
+
<Link href="https://design.bads.com/share/tokens-v2-proposal" external>
|
|
154
|
+
https://design.bads.com/share/tokens-v2-proposal
|
|
155
|
+
</Link>
|
|
156
|
+
</Text>
|
|
157
|
+
</div>
|
|
158
|
+
),
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export const RealisticUse: Story = {
|
|
162
|
+
render: () => (
|
|
163
|
+
<Card className="w-96">
|
|
164
|
+
<CardHeader>
|
|
165
|
+
<CardTitle className="text-lg">Set up your design system in five minutes</CardTitle>
|
|
166
|
+
</CardHeader>
|
|
167
|
+
<CardContent className="space-y-4">
|
|
168
|
+
<Text variant="body-sm">
|
|
169
|
+
Start with the{" "}
|
|
170
|
+
<Link href="https://design.bads.com/docs/getting-started">
|
|
171
|
+
getting started guide
|
|
172
|
+
</Link>
|
|
173
|
+
, then review{" "}
|
|
174
|
+
<Link href="https://design.bads.com/share/tokens-v2-proposal">
|
|
175
|
+
Seo-yun Park’s tokens v2 proposal
|
|
176
|
+
</Link>{" "}
|
|
177
|
+
before your first token change. Escalations go to{" "}
|
|
178
|
+
<Link href="mailto:jordan@reeves.design">jordan@reeves.design</Link>.
|
|
179
|
+
</Text>
|
|
180
|
+
<Text variant="body-sm" tone="muted">
|
|
181
|
+
Last token change was 3 days ago. Story coverage is at 98.4%.
|
|
182
|
+
</Text>
|
|
183
|
+
<Separator />
|
|
184
|
+
<div className="flex items-center gap-3 text-sm">
|
|
185
|
+
<Link href="https://design.bads.com" tone="muted" underline="hover">
|
|
186
|
+
Docs
|
|
187
|
+
</Link>
|
|
188
|
+
<Link href="https://design.bads.com" tone="muted" underline="hover">
|
|
189
|
+
Registry
|
|
190
|
+
</Link>
|
|
191
|
+
<Link href="https://design.bads.com" tone="muted" underline="hover" external>
|
|
192
|
+
Storybook
|
|
193
|
+
</Link>
|
|
194
|
+
</div>
|
|
195
|
+
</CardContent>
|
|
196
|
+
</Card>
|
|
197
|
+
),
|
|
198
|
+
}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
import {
|
|
4
|
+
Listbox,
|
|
5
|
+
ListboxRoot,
|
|
6
|
+
ListboxOption,
|
|
7
|
+
} from "@behavioral-agentic-design-system/core/components/ui/listbox";
|
|
8
|
+
import { Label } from "@behavioral-agentic-design-system/core/components/ui/label";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Listbox is a controlled, always-visible listbox widget for single or
|
|
12
|
+
* multi-select. It renders with `role="listbox"` and `role="option"` children,
|
|
13
|
+
* following the ARIA Listbox pattern with `aria-activedescendant` keyboard
|
|
14
|
+
* navigation (focus stays on the container).
|
|
15
|
+
*
|
|
16
|
+
* Keyboard: ArrowDown/Up navigate, Home/End jump, Space/Enter select,
|
|
17
|
+
* Shift+ArrowDown/Up extends selection in multi mode.
|
|
18
|
+
*
|
|
19
|
+
* Use for: filter sidebars, settings panels, locale/language pickers — any
|
|
20
|
+
* surface where the list stays open and selection is immediately visible.
|
|
21
|
+
*
|
|
22
|
+
* **Not** for navigation (use NavigationMenu) or popup selection
|
|
23
|
+
* (use Select, Combobox, DropdownMenu).
|
|
24
|
+
*/
|
|
25
|
+
const meta: Meta<typeof ListboxRoot> = {
|
|
26
|
+
title: "Components/Listbox",
|
|
27
|
+
component: ListboxRoot,
|
|
28
|
+
parameters: {
|
|
29
|
+
layout: "centered",
|
|
30
|
+
docs: {
|
|
31
|
+
description: {
|
|
32
|
+
component:
|
|
33
|
+
"Controlled always-visible listbox (role=listbox + role=option). Follows the ARIA Listbox authoring-practices pattern: aria-activedescendant cursor, keyboard nav (Up/Down/Home/End/Space/Enter/Shift+Arrow in multi), single or multi-select. Distinct from Select/Combobox/DropdownMenu, which are popup-based.",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
tags: ["autodocs"],
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default meta;
|
|
41
|
+
type Story = StoryObj<typeof meta>;
|
|
42
|
+
|
|
43
|
+
// ---------------------------------------------------------------------------
|
|
44
|
+
// Default — single-select, 5 options, one pre-selected
|
|
45
|
+
// ---------------------------------------------------------------------------
|
|
46
|
+
|
|
47
|
+
export const Default: Story = {
|
|
48
|
+
render: function DefaultStory() {
|
|
49
|
+
const [value, setValue] = React.useState("active");
|
|
50
|
+
return (
|
|
51
|
+
<div className="w-64">
|
|
52
|
+
<Listbox
|
|
53
|
+
value={value}
|
|
54
|
+
onValueChange={(v) => setValue(v as string)}
|
|
55
|
+
aria-label="Filter by project status"
|
|
56
|
+
>
|
|
57
|
+
<ListboxOption value="active">Active</ListboxOption>
|
|
58
|
+
<ListboxOption value="in-review">In Review</ListboxOption>
|
|
59
|
+
<ListboxOption value="on-hold">On Hold</ListboxOption>
|
|
60
|
+
<ListboxOption value="draft">Draft</ListboxOption>
|
|
61
|
+
<ListboxOption value="archived">Archived</ListboxOption>
|
|
62
|
+
</Listbox>
|
|
63
|
+
<p className="mt-2 text-sm text-muted-foreground">
|
|
64
|
+
Selected:{" "}
|
|
65
|
+
<span className="font-medium text-foreground">{value}</span>
|
|
66
|
+
</p>
|
|
67
|
+
</div>
|
|
68
|
+
);
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// ---------------------------------------------------------------------------
|
|
73
|
+
// MultiSelect — multiple=true, multiple pre-selected
|
|
74
|
+
// ---------------------------------------------------------------------------
|
|
75
|
+
|
|
76
|
+
export const MultiSelect: Story = {
|
|
77
|
+
render: function MultiSelectStory() {
|
|
78
|
+
const [value, setValue] = React.useState<string[]>(["design", "tokens"]);
|
|
79
|
+
return (
|
|
80
|
+
<div className="w-64">
|
|
81
|
+
<ListboxRoot
|
|
82
|
+
multiple
|
|
83
|
+
value={value}
|
|
84
|
+
onValueChange={(v) => setValue(v as string[])}
|
|
85
|
+
aria-label="Filter by discipline"
|
|
86
|
+
>
|
|
87
|
+
<ListboxOption value="design">Design</ListboxOption>
|
|
88
|
+
<ListboxOption value="tokens">Tokens</ListboxOption>
|
|
89
|
+
<ListboxOption value="accessibility">Accessibility</ListboxOption>
|
|
90
|
+
<ListboxOption value="motion">Motion</ListboxOption>
|
|
91
|
+
<ListboxOption value="engineering">Engineering</ListboxOption>
|
|
92
|
+
</ListboxRoot>
|
|
93
|
+
<p className="mt-2 text-sm text-muted-foreground">
|
|
94
|
+
{value.length > 0
|
|
95
|
+
? `${value.length} selected: ${value.join(", ")}`
|
|
96
|
+
: "None selected"}
|
|
97
|
+
</p>
|
|
98
|
+
</div>
|
|
99
|
+
);
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
// ---------------------------------------------------------------------------
|
|
104
|
+
// Disabled — whole listbox disabled
|
|
105
|
+
// ---------------------------------------------------------------------------
|
|
106
|
+
|
|
107
|
+
export const Disabled: Story = {
|
|
108
|
+
render: () => (
|
|
109
|
+
<div className="w-64">
|
|
110
|
+
<Listbox
|
|
111
|
+
value="active"
|
|
112
|
+
disabled
|
|
113
|
+
aria-label="Project status (read-only)"
|
|
114
|
+
>
|
|
115
|
+
<ListboxOption value="active">Active</ListboxOption>
|
|
116
|
+
<ListboxOption value="in-review">In Review</ListboxOption>
|
|
117
|
+
<ListboxOption value="on-hold">On Hold</ListboxOption>
|
|
118
|
+
<ListboxOption value="archived">Archived</ListboxOption>
|
|
119
|
+
</Listbox>
|
|
120
|
+
</div>
|
|
121
|
+
),
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// ---------------------------------------------------------------------------
|
|
125
|
+
// DisabledOption — one option disabled within a live listbox
|
|
126
|
+
// ---------------------------------------------------------------------------
|
|
127
|
+
|
|
128
|
+
export const DisabledOption: Story = {
|
|
129
|
+
render: function DisabledOptionStory() {
|
|
130
|
+
const [value, setValue] = React.useState("active");
|
|
131
|
+
return (
|
|
132
|
+
<div className="w-64">
|
|
133
|
+
<Listbox
|
|
134
|
+
value={value}
|
|
135
|
+
onValueChange={(v) => setValue(v as string)}
|
|
136
|
+
aria-label="Filter by project status"
|
|
137
|
+
>
|
|
138
|
+
<ListboxOption value="active">Active</ListboxOption>
|
|
139
|
+
<ListboxOption value="in-review">In Review</ListboxOption>
|
|
140
|
+
{/* On Hold is locked — pending policy review */}
|
|
141
|
+
<ListboxOption value="on-hold" disabled>
|
|
142
|
+
On Hold
|
|
143
|
+
</ListboxOption>
|
|
144
|
+
<ListboxOption value="draft">Draft</ListboxOption>
|
|
145
|
+
<ListboxOption value="archived">Archived</ListboxOption>
|
|
146
|
+
</Listbox>
|
|
147
|
+
<p className="mt-2 text-sm text-muted-foreground">
|
|
148
|
+
Selected:{" "}
|
|
149
|
+
<span className="font-medium text-foreground">{value}</span>
|
|
150
|
+
</p>
|
|
151
|
+
</div>
|
|
152
|
+
);
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
// ---------------------------------------------------------------------------
|
|
157
|
+
// LongList — 10+ options with max-h + overflow-y to show scroll
|
|
158
|
+
// ---------------------------------------------------------------------------
|
|
159
|
+
|
|
160
|
+
export const LongList: Story = {
|
|
161
|
+
render: function LongListStory() {
|
|
162
|
+
const [value, setValue] = React.useState("jordan-reeves");
|
|
163
|
+
const reviewers = [
|
|
164
|
+
{ value: "jordan-reeves", label: "Jordan Reeves" },
|
|
165
|
+
{ value: "seoyun-park", label: "Seo-yun Park" },
|
|
166
|
+
{ value: "marcus-lindqvist", label: "Marcus Lindqvist" },
|
|
167
|
+
{ value: "anika-patel", label: "Anika Patel" },
|
|
168
|
+
{ value: "yemi-adeyemi", label: "Yemi Adeyemi" },
|
|
169
|
+
{ value: "priya-menon", label: "Priya Menon" },
|
|
170
|
+
{ value: "dario-esposito", label: "Dario Esposito" },
|
|
171
|
+
{ value: "fatima-al-rashid", label: "Fatima Al-Rashid" },
|
|
172
|
+
{ value: "noah-bergstrom", label: "Noah Bergström" },
|
|
173
|
+
{ value: "lena-fischer", label: "Lena Fischer" },
|
|
174
|
+
{ value: "kwame-asante", label: "Kwame Asante" },
|
|
175
|
+
{ value: "celia-andrade", label: "Celia Andrade" },
|
|
176
|
+
];
|
|
177
|
+
return (
|
|
178
|
+
<div className="w-64">
|
|
179
|
+
<Listbox
|
|
180
|
+
value={value}
|
|
181
|
+
onValueChange={(v) => setValue(v as string)}
|
|
182
|
+
aria-label="Assign reviewer"
|
|
183
|
+
className="max-h-48 overflow-y-auto"
|
|
184
|
+
>
|
|
185
|
+
{reviewers.map((r) => (
|
|
186
|
+
<ListboxOption key={r.value} value={r.value}>
|
|
187
|
+
{r.label}
|
|
188
|
+
</ListboxOption>
|
|
189
|
+
))}
|
|
190
|
+
</Listbox>
|
|
191
|
+
<p className="mt-2 text-sm text-muted-foreground">
|
|
192
|
+
Reviewer:{" "}
|
|
193
|
+
<span className="font-medium text-foreground">
|
|
194
|
+
{reviewers.find((r) => r.value === value)?.label ?? "—"}
|
|
195
|
+
</span>
|
|
196
|
+
</p>
|
|
197
|
+
</div>
|
|
198
|
+
);
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
// ---------------------------------------------------------------------------
|
|
203
|
+
// RealisticUse — filter sidebar panel with label and 4 status options
|
|
204
|
+
// ---------------------------------------------------------------------------
|
|
205
|
+
|
|
206
|
+
export const RealisticUse: Story = {
|
|
207
|
+
render: function RealisticUseStory() {
|
|
208
|
+
const [value, setValue] = React.useState<string[]>(["active", "in-review"]);
|
|
209
|
+
|
|
210
|
+
const statuses = [
|
|
211
|
+
{ value: "active", label: "Active" },
|
|
212
|
+
{ value: "in-review", label: "In Review" },
|
|
213
|
+
{ value: "on-hold", label: "On Hold" },
|
|
214
|
+
{ value: "archived", label: "Archived" },
|
|
215
|
+
];
|
|
216
|
+
|
|
217
|
+
return (
|
|
218
|
+
<div className="w-64 space-y-1.5">
|
|
219
|
+
<Label className="text-sm font-medium">Filter by status</Label>
|
|
220
|
+
<ListboxRoot
|
|
221
|
+
multiple
|
|
222
|
+
value={value}
|
|
223
|
+
onValueChange={(v) => setValue(v as string[])}
|
|
224
|
+
aria-label="Filter by status"
|
|
225
|
+
>
|
|
226
|
+
{statuses.map((s) => (
|
|
227
|
+
<ListboxOption key={s.value} value={s.value}>
|
|
228
|
+
{s.label}
|
|
229
|
+
</ListboxOption>
|
|
230
|
+
))}
|
|
231
|
+
</ListboxRoot>
|
|
232
|
+
<p className="text-xs text-muted-foreground">
|
|
233
|
+
{value.length > 0
|
|
234
|
+
? `Showing: ${value.map((v) => statuses.find((s) => s.value === v)?.label).join(", ")}`
|
|
235
|
+
: "All statuses shown"}
|
|
236
|
+
</p>
|
|
237
|
+
</div>
|
|
238
|
+
);
|
|
239
|
+
},
|
|
240
|
+
};
|