@behavioral-agentic-design-system/core 0.24.0 → 0.27.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 +87 -5
- package/src/app/preview/components/page.tsx +4745 -244
- 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-action-button.tsx +179 -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 +51 -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 +343 -0
- package/src/components/ui/typing-indicator.tsx +96 -0
- package/src/components/ui/visually-hidden.tsx +42 -0
- package/src/components/ui/watermark.tsx +0 -0
- package/src/components/ui/word-rotate.tsx +82 -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/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/FloatingActionButton.stories.tsx +215 -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 +150 -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 +190 -0
- package/src/stories/TypingIndicator.stories.tsx +139 -0
- package/src/stories/VisuallyHidden.stories.tsx +105 -0
- package/src/stories/Watermark.stories.tsx +212 -0
- package/src/stories/WordRotate.stories.tsx +101 -0
- package/src/styles.css +88 -6
- package/src/tokens.json +3 -3
|
@@ -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
|
};
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import {
|
|
4
|
+
CheckboxCard,
|
|
5
|
+
RadioCard,
|
|
6
|
+
} from "@behavioral-agentic-design-system/core/components/ui/checkbox-card";
|
|
7
|
+
|
|
8
|
+
const meta: Meta<typeof CheckboxCard> = {
|
|
9
|
+
title: "Components/CheckboxCard",
|
|
10
|
+
component: CheckboxCard,
|
|
11
|
+
parameters: {
|
|
12
|
+
layout: "centered",
|
|
13
|
+
docs: {
|
|
14
|
+
description: {
|
|
15
|
+
component:
|
|
16
|
+
"Card-shaped selection controls where the entire card surface is the hit area. A visually-hidden native input inside the label carries all keyboard and screen-reader behavior — Space toggles a CheckboxCard (multi-select, each card its own tab stop); RadioCards sharing a name form a native radio group (one tab stop, arrow keys move selection). Checked state paints border-primary + bg-primary/10 keyed off CSS :checked, so uncontrolled native radio groups always render correctly; the focus ring travels to the card surface via a peer overlay and appears instantly (excluded from the color transition). Motion: transition-colors on var(--duration-fast) + var(--ease-out).",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default meta;
|
|
23
|
+
type Story = StoryObj<typeof CheckboxCard>;
|
|
24
|
+
|
|
25
|
+
export const Default: Story = {
|
|
26
|
+
render: () => (
|
|
27
|
+
<CheckboxCard className="w-72">
|
|
28
|
+
<span className="text-sm font-medium text-foreground">
|
|
29
|
+
Chromatic visual regression
|
|
30
|
+
</span>
|
|
31
|
+
<span className="text-sm text-muted-foreground">
|
|
32
|
+
Baseline every story; diff every PR.
|
|
33
|
+
</span>
|
|
34
|
+
</CheckboxCard>
|
|
35
|
+
),
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const Checked: Story = {
|
|
39
|
+
render: () => (
|
|
40
|
+
<CheckboxCard checked className="w-72">
|
|
41
|
+
<span className="text-sm font-medium text-foreground">
|
|
42
|
+
Chromatic visual regression
|
|
43
|
+
</span>
|
|
44
|
+
<span className="text-sm text-muted-foreground">
|
|
45
|
+
Baseline every story; diff every PR.
|
|
46
|
+
</span>
|
|
47
|
+
</CheckboxCard>
|
|
48
|
+
),
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const Disabled: Story = {
|
|
52
|
+
render: () => (
|
|
53
|
+
<CheckboxCard disabled className="w-72">
|
|
54
|
+
<span className="text-sm font-medium text-foreground">
|
|
55
|
+
Figma token sync
|
|
56
|
+
</span>
|
|
57
|
+
<span className="text-sm text-muted-foreground">
|
|
58
|
+
Deferred — activation signal not fired (docs/roadmap.md).
|
|
59
|
+
</span>
|
|
60
|
+
</CheckboxCard>
|
|
61
|
+
),
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const RadioCard_Default: Story = {
|
|
65
|
+
render: () => (
|
|
66
|
+
<RadioCard name="plan-single" value="pro" className="w-72">
|
|
67
|
+
<span className="text-sm font-medium text-foreground">Pro</span>
|
|
68
|
+
<span className="text-sm text-muted-foreground">
|
|
69
|
+
$249.00/mo — every primitive, Chromatic, priority support.
|
|
70
|
+
</span>
|
|
71
|
+
</RadioCard>
|
|
72
|
+
),
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export const RadioCard_Checked: Story = {
|
|
76
|
+
render: () => (
|
|
77
|
+
<RadioCard checked name="plan-single-checked" value="pro" className="w-72">
|
|
78
|
+
<span className="text-sm font-medium text-foreground">Pro</span>
|
|
79
|
+
<span className="text-sm text-muted-foreground">
|
|
80
|
+
$249.00/mo — every primitive, Chromatic, priority support.
|
|
81
|
+
</span>
|
|
82
|
+
</RadioCard>
|
|
83
|
+
),
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export const RealisticUse_CheckboxCards: Story = {
|
|
87
|
+
render: function RealisticUseCheckboxCardsStory() {
|
|
88
|
+
// Real content: fork-onboarding service picker from the BADS pool
|
|
89
|
+
// (content/personas/bads.json → jargon, metrics) — Anika Patel scoping
|
|
90
|
+
// which enforcement passes her client fork turns on.
|
|
91
|
+
const services = [
|
|
92
|
+
{
|
|
93
|
+
value: "wcag-audit",
|
|
94
|
+
title: "WCAG AAA token audit",
|
|
95
|
+
description: "7:1 text pairs, 3:1 non-text — fails CI below the floor.",
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
value: "visual-regression",
|
|
99
|
+
title: "Chromatic visual regression",
|
|
100
|
+
description: "Baseline every story; diff every PR.",
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
value: "orphan-lint",
|
|
104
|
+
title: "Orphan-token sweep",
|
|
105
|
+
description: "12,417 token references scanned; zeros flagged quarterly.",
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
value: "ethics-contract",
|
|
109
|
+
title: "Ethics contract gate",
|
|
110
|
+
description: "Data-entry primitives blocked without an ethicsContract.",
|
|
111
|
+
},
|
|
112
|
+
];
|
|
113
|
+
const [selected, setSelected] = React.useState<string[]>([
|
|
114
|
+
"wcag-audit",
|
|
115
|
+
"visual-regression",
|
|
116
|
+
]);
|
|
117
|
+
const toggle = (value: string, next: boolean) =>
|
|
118
|
+
setSelected((prev) =>
|
|
119
|
+
next ? [...prev, value] : prev.filter((v) => v !== value)
|
|
120
|
+
);
|
|
121
|
+
return (
|
|
122
|
+
<div className="w-96">
|
|
123
|
+
<div className="mb-3 flex items-baseline justify-between gap-3">
|
|
124
|
+
<p className="text-sm font-medium text-foreground">
|
|
125
|
+
Enforcement passes
|
|
126
|
+
</p>
|
|
127
|
+
<p className="text-sm text-muted-foreground" aria-live="polite">
|
|
128
|
+
{selected.length} of {services.length} enabled
|
|
129
|
+
</p>
|
|
130
|
+
</div>
|
|
131
|
+
<div
|
|
132
|
+
role="group"
|
|
133
|
+
aria-label="Enforcement passes for this fork"
|
|
134
|
+
className="grid gap-3"
|
|
135
|
+
>
|
|
136
|
+
{services.map((service) => (
|
|
137
|
+
<CheckboxCard
|
|
138
|
+
key={service.value}
|
|
139
|
+
value={service.value}
|
|
140
|
+
checked={selected.includes(service.value)}
|
|
141
|
+
onCheckedChange={(next) => toggle(service.value, next)}
|
|
142
|
+
>
|
|
143
|
+
<span className="text-sm font-medium text-foreground">
|
|
144
|
+
{service.title}
|
|
145
|
+
</span>
|
|
146
|
+
<span className="text-sm text-muted-foreground">
|
|
147
|
+
{service.description}
|
|
148
|
+
</span>
|
|
149
|
+
</CheckboxCard>
|
|
150
|
+
))}
|
|
151
|
+
</div>
|
|
152
|
+
</div>
|
|
153
|
+
);
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
export const RealisticUse_RadioCards: Story = {
|
|
158
|
+
render: function RealisticUseRadioCardsStory() {
|
|
159
|
+
// Real content: engagement-tier picker — Jordan Reeves choosing a BADS
|
|
160
|
+
// engagement level; amounts from content/personas/bads.json →
|
|
161
|
+
// currency_amounts.
|
|
162
|
+
const plans = [
|
|
163
|
+
{
|
|
164
|
+
value: "starter",
|
|
165
|
+
title: "Starter",
|
|
166
|
+
description: "$0.00 — fork the system, community support, self-serve.",
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
value: "pro",
|
|
170
|
+
title: "Pro",
|
|
171
|
+
description: "$249.00/mo — every primitive, Chromatic, priority support.",
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
value: "enterprise",
|
|
175
|
+
title: "Enterprise",
|
|
176
|
+
description:
|
|
177
|
+
"$12,500.00/engagement — full brand calibration and onboarding.",
|
|
178
|
+
},
|
|
179
|
+
];
|
|
180
|
+
const [plan, setPlan] = React.useState("pro");
|
|
181
|
+
return (
|
|
182
|
+
<fieldset className="w-96 border-0 p-0">
|
|
183
|
+
<legend className="mb-3 text-sm font-medium text-foreground">
|
|
184
|
+
Engagement tier
|
|
185
|
+
</legend>
|
|
186
|
+
<div className="grid gap-3">
|
|
187
|
+
{plans.map((option) => (
|
|
188
|
+
<RadioCard
|
|
189
|
+
key={option.value}
|
|
190
|
+
name="engagement-tier"
|
|
191
|
+
value={option.value}
|
|
192
|
+
checked={plan === option.value}
|
|
193
|
+
onChange={() => setPlan(option.value)}
|
|
194
|
+
>
|
|
195
|
+
<span className="text-sm font-medium text-foreground">
|
|
196
|
+
{option.title}
|
|
197
|
+
</span>
|
|
198
|
+
<span className="text-sm text-muted-foreground">
|
|
199
|
+
{option.description}
|
|
200
|
+
</span>
|
|
201
|
+
</RadioCard>
|
|
202
|
+
))}
|
|
203
|
+
</div>
|
|
204
|
+
<p className="mt-3 text-sm text-muted-foreground" aria-live="polite">
|
|
205
|
+
Selected: {plans.find((p) => p.value === plan)?.title}
|
|
206
|
+
</p>
|
|
207
|
+
</fieldset>
|
|
208
|
+
);
|
|
209
|
+
},
|
|
210
|
+
};
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import {
|
|
4
|
+
CheckboxGroup,
|
|
5
|
+
CheckboxGroupItem,
|
|
6
|
+
CheckboxGroupSelectAll,
|
|
7
|
+
} from "@behavioral-agentic-design-system/core/components/ui/checkbox-group";
|
|
8
|
+
import {
|
|
9
|
+
Fieldset,
|
|
10
|
+
FieldsetLegend,
|
|
11
|
+
FieldsetHelper,
|
|
12
|
+
} from "@behavioral-agentic-design-system/core/components/ui/fieldset";
|
|
13
|
+
import { Label } from "@behavioral-agentic-design-system/core/components/ui/label";
|
|
14
|
+
import { Separator } from "@behavioral-agentic-design-system/core/components/ui/separator";
|
|
15
|
+
|
|
16
|
+
const meta: Meta<typeof CheckboxGroup> = {
|
|
17
|
+
title: "Components/CheckboxGroup",
|
|
18
|
+
component: CheckboxGroup,
|
|
19
|
+
parameters: {
|
|
20
|
+
layout: "centered",
|
|
21
|
+
docs: {
|
|
22
|
+
description: {
|
|
23
|
+
component:
|
|
24
|
+
"Group orchestration for Checkbox — the multi-select sibling of RadioGroup. Owns the shared string[] value (controlled or uncontrolled via value/defaultValue + onValueChange), propagates disabled and form name to every item, and derives a select-all parent's tri-state (checked / indeterminate / unchecked) from the items actually rendered. Items register on mount, so select-all never needs an allValues prop. Select-all operates on enabled items only: toggling off preserves disabled-but-checked values. The group needs an accessible name — aria-label / aria-labelledby, or wrap in Fieldset + FieldsetLegend. Rendering delegates to the existing BADS Checkbox.",
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
export default meta;
|
|
30
|
+
type Story = StoryObj<typeof CheckboxGroup>;
|
|
31
|
+
|
|
32
|
+
const itemRow = (
|
|
33
|
+
value: string,
|
|
34
|
+
id: string,
|
|
35
|
+
label: string,
|
|
36
|
+
disabled = false,
|
|
37
|
+
) => (
|
|
38
|
+
<div className="flex items-center gap-2.5">
|
|
39
|
+
<CheckboxGroupItem value={value} id={id} disabled={disabled} />
|
|
40
|
+
<Label htmlFor={id} className="font-normal">
|
|
41
|
+
{label}
|
|
42
|
+
</Label>
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
export const Default: Story = {
|
|
47
|
+
render: () => (
|
|
48
|
+
<CheckboxGroup
|
|
49
|
+
aria-label="Notification preferences"
|
|
50
|
+
defaultValue={["email", "push"]}
|
|
51
|
+
className="w-72"
|
|
52
|
+
>
|
|
53
|
+
{itemRow("email", "cg-email", "Email digest")}
|
|
54
|
+
{itemRow("push", "cg-push", "Push notifications")}
|
|
55
|
+
{itemRow("sms", "cg-sms", "SMS alerts")}
|
|
56
|
+
</CheckboxGroup>
|
|
57
|
+
),
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const Disabled: Story = {
|
|
61
|
+
render: () => (
|
|
62
|
+
<div className="flex w-72 flex-col gap-6">
|
|
63
|
+
<div className="flex flex-col gap-2">
|
|
64
|
+
<p className="text-xs font-medium text-muted-foreground">
|
|
65
|
+
Whole group disabled
|
|
66
|
+
</p>
|
|
67
|
+
<CheckboxGroup
|
|
68
|
+
aria-label="Notification preferences (read-only plan)"
|
|
69
|
+
defaultValue={["email"]}
|
|
70
|
+
disabled
|
|
71
|
+
>
|
|
72
|
+
{itemRow("email", "cgd-email", "Email digest")}
|
|
73
|
+
{itemRow("push", "cgd-push", "Push notifications")}
|
|
74
|
+
</CheckboxGroup>
|
|
75
|
+
</div>
|
|
76
|
+
<div className="flex flex-col gap-2">
|
|
77
|
+
<p className="text-xs font-medium text-muted-foreground">
|
|
78
|
+
Single item disabled
|
|
79
|
+
</p>
|
|
80
|
+
<CheckboxGroup
|
|
81
|
+
aria-label="Sync targets"
|
|
82
|
+
defaultValue={["tokens", "stories"]}
|
|
83
|
+
>
|
|
84
|
+
{itemRow("tokens", "cgd-tokens", "Design tokens")}
|
|
85
|
+
{itemRow("stories", "cgd-stories", "Storybook stories", true)}
|
|
86
|
+
{itemRow("registry", "cgd-registry", "Component registry")}
|
|
87
|
+
</CheckboxGroup>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
),
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export const SelectAll: Story = {
|
|
94
|
+
render: function SelectAllStory() {
|
|
95
|
+
const [value, setValue] = React.useState<string[]>(["button", "card"]);
|
|
96
|
+
return (
|
|
97
|
+
<CheckboxGroup
|
|
98
|
+
aria-label="Components to publish"
|
|
99
|
+
allValues={["button", "card", "input", "dialog"]}
|
|
100
|
+
value={value}
|
|
101
|
+
onValueChange={setValue}
|
|
102
|
+
className="w-72"
|
|
103
|
+
>
|
|
104
|
+
<div className="flex items-center gap-2.5">
|
|
105
|
+
<CheckboxGroupSelectAll id="cgsa-all" />
|
|
106
|
+
<Label htmlFor="cgsa-all">Select all</Label>
|
|
107
|
+
</div>
|
|
108
|
+
<Separator />
|
|
109
|
+
{itemRow("button", "cgsa-button", "Button")}
|
|
110
|
+
{itemRow("card", "cgsa-card", "Card")}
|
|
111
|
+
{itemRow("input", "cgsa-input", "Input")}
|
|
112
|
+
{itemRow("dialog", "cgsa-dialog", "Dialog")}
|
|
113
|
+
</CheckboxGroup>
|
|
114
|
+
);
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export const Controlled: Story = {
|
|
119
|
+
render: function ControlledStory() {
|
|
120
|
+
const [value, setValue] = React.useState<string[]>(["a11y contract"]);
|
|
121
|
+
return (
|
|
122
|
+
<div className="flex w-80 flex-col gap-4">
|
|
123
|
+
<CheckboxGroup
|
|
124
|
+
aria-label="Review checklist for the Tag primitive"
|
|
125
|
+
value={value}
|
|
126
|
+
onValueChange={setValue}
|
|
127
|
+
>
|
|
128
|
+
{itemRow("design tokens", "cgc-tokens", "Design tokens only")}
|
|
129
|
+
{itemRow("a11y contract", "cgc-a11y", "a11y contract complete")}
|
|
130
|
+
{itemRow("visual regression", "cgc-vr", "Visual regression passed")}
|
|
131
|
+
</CheckboxGroup>
|
|
132
|
+
<p className="text-sm text-muted-foreground">
|
|
133
|
+
Checked:{" "}
|
|
134
|
+
<span className="font-medium text-foreground">
|
|
135
|
+
{value.length > 0 ? value.join(", ") : "none"}
|
|
136
|
+
</span>
|
|
137
|
+
</p>
|
|
138
|
+
</div>
|
|
139
|
+
);
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export const RealisticUse: Story = {
|
|
144
|
+
render: function RealisticUseStory() {
|
|
145
|
+
const [value, setValue] = React.useState<string[]>([
|
|
146
|
+
"jordan.reeves",
|
|
147
|
+
"seoyun_park",
|
|
148
|
+
]);
|
|
149
|
+
return (
|
|
150
|
+
<form
|
|
151
|
+
className="w-[26rem]"
|
|
152
|
+
onSubmit={(e) => e.preventDefault()}
|
|
153
|
+
>
|
|
154
|
+
<Fieldset>
|
|
155
|
+
<FieldsetLegend>Review reminders</FieldsetLegend>
|
|
156
|
+
<FieldsetHelper>
|
|
157
|
+
Who gets pinged when a token change lands.
|
|
158
|
+
</FieldsetHelper>
|
|
159
|
+
{/* allValues lists only toggleable reviewers — anika.p is disabled
|
|
160
|
+
(on leave), so select-all never touches her entry. */}
|
|
161
|
+
<CheckboxGroup
|
|
162
|
+
aria-label="Reviewers to remind"
|
|
163
|
+
name="reviewers"
|
|
164
|
+
allValues={["jordan.reeves", "seoyun_park", "mlindqvist"]}
|
|
165
|
+
value={value}
|
|
166
|
+
onValueChange={setValue}
|
|
167
|
+
>
|
|
168
|
+
<div className="flex items-center gap-2.5">
|
|
169
|
+
<CheckboxGroupSelectAll id="ru-all" />
|
|
170
|
+
<Label htmlFor="ru-all">All reviewers</Label>
|
|
171
|
+
</div>
|
|
172
|
+
<Separator />
|
|
173
|
+
{itemRow("jordan.reeves", "ru-jordan", "Jordan Reeves")}
|
|
174
|
+
{itemRow("seoyun_park", "ru-seoyun", "Seo-yun Park")}
|
|
175
|
+
{itemRow("mlindqvist", "ru-marcus", "Marcus Lindqvist")}
|
|
176
|
+
{itemRow("anika.p", "ru-anika", "Anika Patel (on leave)", true)}
|
|
177
|
+
</CheckboxGroup>
|
|
178
|
+
<p className="text-sm text-muted-foreground">
|
|
179
|
+
{value.length} of 4 reviewers will be reminded before the
|
|
180
|
+
2026-05-26 release.
|
|
181
|
+
</p>
|
|
182
|
+
</Fieldset>
|
|
183
|
+
</form>
|
|
184
|
+
);
|
|
185
|
+
},
|
|
186
|
+
};
|