@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
|
@@ -13,19 +13,71 @@ export default meta;
|
|
|
13
13
|
type Story = StoryObj<typeof meta>;
|
|
14
14
|
|
|
15
15
|
export const Default: Story = {
|
|
16
|
-
render: () => (
|
|
16
|
+
render: () => (
|
|
17
|
+
<div className="flex flex-col gap-2 w-[320px]">
|
|
17
18
|
<Label htmlFor="msg">Message</Label>
|
|
18
19
|
<Textarea id="msg" placeholder="Tell us what's on your mind." rows={4} />
|
|
19
|
-
</div>
|
|
20
|
+
</div>
|
|
21
|
+
),
|
|
20
22
|
};
|
|
21
23
|
|
|
22
24
|
export const Disabled: Story = {
|
|
23
25
|
args: { disabled: true, "aria-label": "Message", placeholder: "Tell us what's on your mind." } as any,
|
|
24
26
|
};
|
|
25
27
|
|
|
28
|
+
export const ShowCount: Story = {
|
|
29
|
+
render: () => (
|
|
30
|
+
<div className="flex flex-col gap-2 w-[320px]">
|
|
31
|
+
<Label htmlFor="msg-count">Bio</Label>
|
|
32
|
+
<Textarea id="msg-count" placeholder="Tell us about yourself." rows={3} showCount />
|
|
33
|
+
</div>
|
|
34
|
+
),
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const ShowCountWithMax: Story = {
|
|
38
|
+
render: () => (
|
|
39
|
+
<div className="flex flex-col gap-2 w-[320px]">
|
|
40
|
+
<Label htmlFor="msg-max">Bio</Label>
|
|
41
|
+
<Textarea
|
|
42
|
+
id="msg-max"
|
|
43
|
+
placeholder="Tell us about yourself (max 160 chars)."
|
|
44
|
+
rows={3}
|
|
45
|
+
showCount
|
|
46
|
+
maxLength={160}
|
|
47
|
+
/>
|
|
48
|
+
</div>
|
|
49
|
+
),
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const ShowCountAtLimit: Story = {
|
|
53
|
+
render: () => (
|
|
54
|
+
<div className="flex flex-col gap-2 w-[320px]">
|
|
55
|
+
<Label htmlFor="msg-limit">Bio</Label>
|
|
56
|
+
<Textarea
|
|
57
|
+
id="msg-limit"
|
|
58
|
+
defaultValue={"A".repeat(160)}
|
|
59
|
+
rows={3}
|
|
60
|
+
showCount
|
|
61
|
+
maxLength={160}
|
|
62
|
+
/>
|
|
63
|
+
</div>
|
|
64
|
+
),
|
|
65
|
+
};
|
|
66
|
+
|
|
26
67
|
export const RealisticUse: Story = {
|
|
27
|
-
render: () => (
|
|
28
|
-
|
|
29
|
-
<
|
|
30
|
-
|
|
68
|
+
render: () => (
|
|
69
|
+
<div className="flex flex-col gap-2 w-[320px]">
|
|
70
|
+
<Label htmlFor="bio">Short bio</Label>
|
|
71
|
+
<Textarea
|
|
72
|
+
id="bio"
|
|
73
|
+
placeholder="Tell the team a little about yourself — what you work on, what you care about."
|
|
74
|
+
rows={4}
|
|
75
|
+
showCount
|
|
76
|
+
maxLength={200}
|
|
77
|
+
/>
|
|
78
|
+
<p className="text-xs text-muted-foreground">
|
|
79
|
+
Shown on your public profile.
|
|
80
|
+
</p>
|
|
81
|
+
</div>
|
|
82
|
+
),
|
|
31
83
|
};
|
|
@@ -214,6 +214,88 @@ export const ActivityFeed: Story = {
|
|
|
214
214
|
),
|
|
215
215
|
};
|
|
216
216
|
|
|
217
|
+
// Alternate orientation: centered spine, items alternate sides at md+.
|
|
218
|
+
// Below md this falls back to the standard left-aligned vertical layout.
|
|
219
|
+
export const Variant_Alternate: Story = {
|
|
220
|
+
render: () => (
|
|
221
|
+
<div className="w-[640px] max-w-full">
|
|
222
|
+
<Timeline orientation="alternate">
|
|
223
|
+
<TimelineItem
|
|
224
|
+
status="complete"
|
|
225
|
+
title="Token proposal shared"
|
|
226
|
+
description="tokens-v2 draft sent to Jordan Reeves for review."
|
|
227
|
+
time="May 26, 2026"
|
|
228
|
+
dateTime="2026-05-26"
|
|
229
|
+
/>
|
|
230
|
+
<TimelineItem
|
|
231
|
+
status="complete"
|
|
232
|
+
title="Semantic layer approved"
|
|
233
|
+
description="Seo-yun Park signed off on the 7:1 contrast pairs."
|
|
234
|
+
time="Jun 20, 2026"
|
|
235
|
+
dateTime="2026-06-20"
|
|
236
|
+
/>
|
|
237
|
+
<TimelineItem
|
|
238
|
+
status="active"
|
|
239
|
+
title="Component migration"
|
|
240
|
+
description="14 of 36 components on the new tokens."
|
|
241
|
+
time="Jul 9 (today)"
|
|
242
|
+
dateTime="2026-07-09"
|
|
243
|
+
/>
|
|
244
|
+
<TimelineItem
|
|
245
|
+
status="default"
|
|
246
|
+
title="Visual regression sweep"
|
|
247
|
+
description="Chromatic baseline refresh across every story."
|
|
248
|
+
time="Jul 14 (planned)"
|
|
249
|
+
/>
|
|
250
|
+
<TimelineItem
|
|
251
|
+
status="pending"
|
|
252
|
+
title="tokens-v2 released"
|
|
253
|
+
description="Published to npm with the migration guide."
|
|
254
|
+
time="Jul 21 (estimated)"
|
|
255
|
+
/>
|
|
256
|
+
</Timeline>
|
|
257
|
+
</div>
|
|
258
|
+
),
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
// Alternate orientation with custom icons — same icon slot, both sides.
|
|
262
|
+
export const Variant_AlternateWithIcons: Story = {
|
|
263
|
+
render: () => (
|
|
264
|
+
<div className="w-[640px] max-w-full">
|
|
265
|
+
<Timeline orientation="alternate">
|
|
266
|
+
<TimelineItem
|
|
267
|
+
status="complete"
|
|
268
|
+
icon={<UserCheckIcon className="size-3" strokeWidth={1.5} aria-hidden />}
|
|
269
|
+
title="Anika Patel joined as reviewer"
|
|
270
|
+
description="Second maintainer on the a11y contract lane."
|
|
271
|
+
time="Jun 24"
|
|
272
|
+
/>
|
|
273
|
+
<TimelineItem
|
|
274
|
+
status="complete"
|
|
275
|
+
icon={<ClipboardCheckIcon className="size-3" strokeWidth={1.5} aria-hidden />}
|
|
276
|
+
title="Accessibility audit passed"
|
|
277
|
+
description="36 components reviewed, all AAA."
|
|
278
|
+
time="Jul 1"
|
|
279
|
+
/>
|
|
280
|
+
<TimelineItem
|
|
281
|
+
status="active"
|
|
282
|
+
icon={<CalendarIcon className="size-3" strokeWidth={1.5} aria-hidden />}
|
|
283
|
+
title="Design review week"
|
|
284
|
+
description="Tue/Thu 10:00–11:00 AM with Tomás Herrera."
|
|
285
|
+
time="Jul 9 (today)"
|
|
286
|
+
/>
|
|
287
|
+
<TimelineItem
|
|
288
|
+
status="pending"
|
|
289
|
+
icon={<TrophyIcon className="size-3" strokeWidth={1.5} aria-hidden />}
|
|
290
|
+
title="v2.5.0 released"
|
|
291
|
+
description="Published to npm and Storybook."
|
|
292
|
+
time="Jul 21"
|
|
293
|
+
/>
|
|
294
|
+
</Timeline>
|
|
295
|
+
</div>
|
|
296
|
+
),
|
|
297
|
+
};
|
|
298
|
+
|
|
217
299
|
// Realistic use: BADS Design System, v2.4.0 release journey
|
|
218
300
|
export const RealisticUse: Story = {
|
|
219
301
|
render: () => (
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
import { Timer } from "@behavioral-agentic-design-system/core/components/ui/timer";
|
|
4
|
+
import { Button } from "@behavioral-agentic-design-system/core/components/ui/button";
|
|
5
|
+
import { Badge } from "@behavioral-agentic-design-system/core/components/ui/badge";
|
|
6
|
+
import {
|
|
7
|
+
Card,
|
|
8
|
+
CardContent,
|
|
9
|
+
CardHeader,
|
|
10
|
+
CardTitle,
|
|
11
|
+
} from "@behavioral-agentic-design-system/core/components/ui/card";
|
|
12
|
+
|
|
13
|
+
const meta: Meta<typeof Timer> = {
|
|
14
|
+
title: "Components/Timer",
|
|
15
|
+
component: Timer,
|
|
16
|
+
parameters: {
|
|
17
|
+
layout: "centered",
|
|
18
|
+
docs: {
|
|
19
|
+
description: {
|
|
20
|
+
component:
|
|
21
|
+
"Live countdown or count-up display ticking on a configurable interval. Drift-free (wall-clock anchored), tabular-nums digits, aria-live=off on the ticking value with a single polite role=status announcement at completion. data-state exposes running/paused/completed; paused dims via a token-driven color transition. Ethics contract: only bind to REAL deadlines — invented urgency is a dark pattern.",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
tags: ["autodocs"],
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default meta;
|
|
29
|
+
type Story = StoryObj<typeof meta>;
|
|
30
|
+
|
|
31
|
+
export const Default: Story = {
|
|
32
|
+
render: () => (
|
|
33
|
+
<div className="flex flex-col items-center gap-2">
|
|
34
|
+
<Timer mode="countdown" startMs={5 * 60 * 1000} className="text-2xl" />
|
|
35
|
+
<p className="text-sm text-muted-foreground">
|
|
36
|
+
Five-minute countdown, default MM:SS format.
|
|
37
|
+
</p>
|
|
38
|
+
</div>
|
|
39
|
+
),
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const CountUp: Story = {
|
|
43
|
+
render: () => (
|
|
44
|
+
<div className="flex flex-col items-center gap-2">
|
|
45
|
+
<Timer mode="countup" format="HH:MM:SS" className="text-2xl" />
|
|
46
|
+
<p className="text-sm text-muted-foreground">
|
|
47
|
+
Count-up from zero — elapsed-time displays (recording length, session
|
|
48
|
+
duration). Never completes.
|
|
49
|
+
</p>
|
|
50
|
+
</div>
|
|
51
|
+
),
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const PausedInitially: Story = {
|
|
55
|
+
render: function PausedInitiallyStory() {
|
|
56
|
+
const [paused, setPaused] = React.useState(true);
|
|
57
|
+
return (
|
|
58
|
+
<div className="flex flex-col items-center gap-3">
|
|
59
|
+
<Timer
|
|
60
|
+
mode="countdown"
|
|
61
|
+
startMs={90 * 1000}
|
|
62
|
+
paused={paused}
|
|
63
|
+
className="text-2xl"
|
|
64
|
+
/>
|
|
65
|
+
<Button
|
|
66
|
+
size="xl"
|
|
67
|
+
variant="outline"
|
|
68
|
+
aria-pressed={!paused}
|
|
69
|
+
onClick={() => setPaused((p) => !p)}
|
|
70
|
+
>
|
|
71
|
+
{paused ? "Start" : "Pause"}
|
|
72
|
+
</Button>
|
|
73
|
+
<p className="text-sm text-muted-foreground">
|
|
74
|
+
The paused prop wins over autoStart; paused dims the digits via a
|
|
75
|
+
token-driven color transition.
|
|
76
|
+
</p>
|
|
77
|
+
</div>
|
|
78
|
+
);
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const CustomFormat: Story = {
|
|
83
|
+
render: () => (
|
|
84
|
+
<div className="flex flex-col items-center gap-2">
|
|
85
|
+
<Timer
|
|
86
|
+
mode="countdown"
|
|
87
|
+
startMs={3 * 60 * 1000}
|
|
88
|
+
format={(ms) => {
|
|
89
|
+
const total = Math.max(0, Math.floor(ms / 1000));
|
|
90
|
+
return `${Math.floor(total / 60)} min ${String(total % 60).padStart(2, "0")} s`;
|
|
91
|
+
}}
|
|
92
|
+
className="text-2xl"
|
|
93
|
+
/>
|
|
94
|
+
<p className="text-sm text-muted-foreground">
|
|
95
|
+
format accepts a custom (ms) => string when the presets don't
|
|
96
|
+
fit.
|
|
97
|
+
</p>
|
|
98
|
+
</div>
|
|
99
|
+
),
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export const FormatMM_SS: Story = {
|
|
103
|
+
render: () => (
|
|
104
|
+
<div className="flex flex-col items-center gap-2">
|
|
105
|
+
<Timer
|
|
106
|
+
mode="countdown"
|
|
107
|
+
startMs={95 * 60 * 1000}
|
|
108
|
+
format="MM:SS"
|
|
109
|
+
className="text-2xl"
|
|
110
|
+
/>
|
|
111
|
+
<p className="text-sm text-muted-foreground">
|
|
112
|
+
MM:SS shows TOTAL minutes (95:00 for a 95-minute window) — switch to
|
|
113
|
+
HH:MM:SS when hours matter.
|
|
114
|
+
</p>
|
|
115
|
+
</div>
|
|
116
|
+
),
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
// Real content from content/personas/bads.json (primary persona pool).
|
|
120
|
+
export const RealisticUse: Story = {
|
|
121
|
+
render: function RealisticUseStory() {
|
|
122
|
+
const [done, setDone] = React.useState(false);
|
|
123
|
+
return (
|
|
124
|
+
<Card className="w-96">
|
|
125
|
+
<CardHeader>
|
|
126
|
+
<div className="flex items-center justify-between gap-3">
|
|
127
|
+
<CardTitle className="min-w-0 truncate">
|
|
128
|
+
Tokens v2 proposal — live review
|
|
129
|
+
</CardTitle>
|
|
130
|
+
<Badge variant={done ? "destructive" : "secondary"}>
|
|
131
|
+
{done ? "Session ended" : "In session"}
|
|
132
|
+
</Badge>
|
|
133
|
+
</div>
|
|
134
|
+
</CardHeader>
|
|
135
|
+
<CardContent className="space-y-3">
|
|
136
|
+
<p className="text-sm text-muted-foreground">
|
|
137
|
+
Jordan Reeves is walking 36 components through the 7:1 contrast
|
|
138
|
+
floor at design.bads.com/share/tokens-v2-proposal.
|
|
139
|
+
</p>
|
|
140
|
+
<div className="flex items-baseline gap-2">
|
|
141
|
+
<span className="text-sm font-medium text-foreground">
|
|
142
|
+
Time remaining
|
|
143
|
+
</span>
|
|
144
|
+
<Timer
|
|
145
|
+
mode="countdown"
|
|
146
|
+
startMs={25 * 60 * 1000}
|
|
147
|
+
format="MM:SS"
|
|
148
|
+
className="text-2xl"
|
|
149
|
+
completeAnnouncement="Review session ended"
|
|
150
|
+
onComplete={() => setDone(true)}
|
|
151
|
+
/>
|
|
152
|
+
</div>
|
|
153
|
+
<Button size="xl" className="w-full">
|
|
154
|
+
Join the review
|
|
155
|
+
</Button>
|
|
156
|
+
</CardContent>
|
|
157
|
+
</Card>
|
|
158
|
+
);
|
|
159
|
+
},
|
|
160
|
+
};
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
import { Search, Bell, Palette } from "lucide-react";
|
|
4
|
+
|
|
5
|
+
import { Tour, type TourStep } from "@behavioral-agentic-design-system/core/components/ui/tour";
|
|
6
|
+
import { Button } from "@behavioral-agentic-design-system/core/components/ui/button";
|
|
7
|
+
import {
|
|
8
|
+
Card,
|
|
9
|
+
CardContent,
|
|
10
|
+
CardHeader,
|
|
11
|
+
CardTitle,
|
|
12
|
+
} from "@behavioral-agentic-design-system/core/components/ui/card";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Tour is a guided product walkthrough built on Radix Dialog: focus trap,
|
|
16
|
+
* Escape-to-close, and focus-return come from the dialog base; the tour adds
|
|
17
|
+
* selector-anchored positioning, a primary-ring target highlight, text
|
|
18
|
+
* progress ("Step N of M"), and ArrowLeft/ArrowRight step navigation.
|
|
19
|
+
* Steps whose `target` is null (or matches nothing) render centered.
|
|
20
|
+
*/
|
|
21
|
+
const meta: Meta<typeof Tour> = {
|
|
22
|
+
title: "Components/Tour",
|
|
23
|
+
component: Tour,
|
|
24
|
+
parameters: { layout: "centered" },
|
|
25
|
+
tags: ["autodocs"],
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default meta;
|
|
29
|
+
type Story = StoryObj<typeof meta>;
|
|
30
|
+
|
|
31
|
+
function DemoChrome({ idPrefix }: { idPrefix: string }) {
|
|
32
|
+
return (
|
|
33
|
+
<Card className="w-96">
|
|
34
|
+
<CardHeader>
|
|
35
|
+
<CardTitle className="text-sm">Your design system at a glance</CardTitle>
|
|
36
|
+
</CardHeader>
|
|
37
|
+
<CardContent className="flex items-center gap-3">
|
|
38
|
+
<Button id={`${idPrefix}-search`} variant="outline" size="xl" className="px-4">
|
|
39
|
+
<Search strokeWidth={1.5} className="size-4" aria-hidden="true" />
|
|
40
|
+
Search
|
|
41
|
+
</Button>
|
|
42
|
+
<Button id={`${idPrefix}-alerts`} variant="outline" size="xl" className="px-4">
|
|
43
|
+
<Bell strokeWidth={1.5} className="size-4" aria-hidden="true" />
|
|
44
|
+
Alerts
|
|
45
|
+
</Button>
|
|
46
|
+
<Button id={`${idPrefix}-customize`} size="xl" className="px-4">
|
|
47
|
+
<Palette strokeWidth={1.5} className="size-4" aria-hidden="true" />
|
|
48
|
+
Customize
|
|
49
|
+
</Button>
|
|
50
|
+
</CardContent>
|
|
51
|
+
</Card>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function TourDemo({
|
|
56
|
+
steps,
|
|
57
|
+
idPrefix,
|
|
58
|
+
startLabel = "Start tour",
|
|
59
|
+
}: {
|
|
60
|
+
steps: TourStep[];
|
|
61
|
+
idPrefix: string;
|
|
62
|
+
startLabel?: string;
|
|
63
|
+
}) {
|
|
64
|
+
const [open, setOpen] = React.useState(false);
|
|
65
|
+
return (
|
|
66
|
+
<div className="flex flex-col items-start gap-4">
|
|
67
|
+
<Button size="xl" onClick={() => setOpen(true)}>
|
|
68
|
+
{startLabel}
|
|
69
|
+
</Button>
|
|
70
|
+
<DemoChrome idPrefix={idPrefix} />
|
|
71
|
+
<Tour steps={steps} open={open} onOpenChange={setOpen} />
|
|
72
|
+
</div>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export const Default: Story = {
|
|
77
|
+
render: () => (
|
|
78
|
+
<TourDemo
|
|
79
|
+
idPrefix="tour-default"
|
|
80
|
+
steps={[
|
|
81
|
+
{
|
|
82
|
+
title: "Search the registry",
|
|
83
|
+
description: "Find any primitive, token, or pattern by name.",
|
|
84
|
+
target: "#tour-default-search",
|
|
85
|
+
placement: "bottom",
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
title: "Watch for token changes",
|
|
89
|
+
description: "Alerts fire when a token change affects components you own.",
|
|
90
|
+
target: "#tour-default-alerts",
|
|
91
|
+
placement: "bottom",
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
title: "Customize your tokens",
|
|
95
|
+
description: "Brand color overrides live here, with AAA contrast warnings built in.",
|
|
96
|
+
target: "#tour-default-customize",
|
|
97
|
+
placement: "bottom",
|
|
98
|
+
},
|
|
99
|
+
]}
|
|
100
|
+
/>
|
|
101
|
+
),
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export const Placement_TopAndLeft: Story = {
|
|
105
|
+
render: () => (
|
|
106
|
+
<TourDemo
|
|
107
|
+
idPrefix="tour-placement"
|
|
108
|
+
startLabel="Start tour (top / left)"
|
|
109
|
+
steps={[
|
|
110
|
+
{
|
|
111
|
+
title: "Panel above the target",
|
|
112
|
+
description: "This step uses placement 'top'.",
|
|
113
|
+
target: "#tour-placement-search",
|
|
114
|
+
placement: "top",
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
title: "Panel beside the target",
|
|
118
|
+
description: "This step uses placement 'left'. Positions clamp to the viewport.",
|
|
119
|
+
target: "#tour-placement-customize",
|
|
120
|
+
placement: "left",
|
|
121
|
+
},
|
|
122
|
+
]}
|
|
123
|
+
/>
|
|
124
|
+
),
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export const Centered_WelcomeStep: Story = {
|
|
128
|
+
render: () => (
|
|
129
|
+
<TourDemo
|
|
130
|
+
idPrefix="tour-centered"
|
|
131
|
+
startLabel="Start tour (welcome step)"
|
|
132
|
+
steps={[
|
|
133
|
+
{
|
|
134
|
+
title: "Set up your design system in five minutes",
|
|
135
|
+
description:
|
|
136
|
+
"BADS ships with tokens, components, and accessibility baked in. This short tour shows the three surfaces you'll use most.",
|
|
137
|
+
target: null,
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
title: "Search the registry",
|
|
141
|
+
description: "Find any primitive, token, or pattern by name.",
|
|
142
|
+
target: "#tour-centered-search",
|
|
143
|
+
},
|
|
144
|
+
]}
|
|
145
|
+
/>
|
|
146
|
+
),
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export const RealisticUse: Story = {
|
|
150
|
+
render: function RealisticUseStory() {
|
|
151
|
+
const [open, setOpen] = React.useState(false);
|
|
152
|
+
const [completed, setCompleted] = React.useState(false);
|
|
153
|
+
return (
|
|
154
|
+
<div className="flex flex-col items-start gap-4">
|
|
155
|
+
<Button size="xl" onClick={() => setOpen(true)}>
|
|
156
|
+
Show me around
|
|
157
|
+
</Button>
|
|
158
|
+
{completed && (
|
|
159
|
+
<p className="text-sm text-muted-foreground">
|
|
160
|
+
Tour finished. Run it again any time from Settings.
|
|
161
|
+
</p>
|
|
162
|
+
)}
|
|
163
|
+
<DemoChrome idPrefix="tour-realistic" />
|
|
164
|
+
<Tour
|
|
165
|
+
open={open}
|
|
166
|
+
onOpenChange={setOpen}
|
|
167
|
+
onComplete={() => setCompleted(true)}
|
|
168
|
+
steps={[
|
|
169
|
+
{
|
|
170
|
+
title: "Welcome, Jordan",
|
|
171
|
+
description:
|
|
172
|
+
"36 components, all passing AAA contrast. Here's where everything lives.",
|
|
173
|
+
target: null,
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
title: "Search the registry",
|
|
177
|
+
description: "Find any primitive, token, or pattern by name.",
|
|
178
|
+
target: "#tour-realistic-search",
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
title: "Customize your tokens",
|
|
182
|
+
description:
|
|
183
|
+
"Brand color overrides live here. Changes stay in your browser until you commit them to tokens.json.",
|
|
184
|
+
target: "#tour-realistic-customize",
|
|
185
|
+
},
|
|
186
|
+
]}
|
|
187
|
+
/>
|
|
188
|
+
</div>
|
|
189
|
+
);
|
|
190
|
+
},
|
|
191
|
+
};
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
2
|
+
import * as React from "react"
|
|
3
|
+
import { TransferList } from "@behavioral-agentic-design-system/core/components/ui/transfer-list"
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof TransferList> = {
|
|
6
|
+
title: "Components/TransferList",
|
|
7
|
+
component: TransferList,
|
|
8
|
+
parameters: { layout: "centered" },
|
|
9
|
+
tags: ["autodocs"],
|
|
10
|
+
argTypes: {
|
|
11
|
+
searchable: { control: "boolean" },
|
|
12
|
+
availableLabel: { control: "text" },
|
|
13
|
+
selectedLabel: { control: "text" },
|
|
14
|
+
},
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default meta
|
|
18
|
+
type Story = StoryObj<typeof TransferList>
|
|
19
|
+
|
|
20
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
21
|
+
// Controlled wrapper
|
|
22
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
23
|
+
|
|
24
|
+
function ControlledTransferList(
|
|
25
|
+
props: Omit<
|
|
26
|
+
React.ComponentProps<typeof TransferList>,
|
|
27
|
+
"available" | "selected" | "onAvailableChange" | "onSelectedChange"
|
|
28
|
+
> & {
|
|
29
|
+
initialAvailable?: string[]
|
|
30
|
+
initialSelected?: string[]
|
|
31
|
+
}
|
|
32
|
+
) {
|
|
33
|
+
const {
|
|
34
|
+
initialAvailable = ["Alpha", "Bravo", "Charlie"],
|
|
35
|
+
initialSelected = [],
|
|
36
|
+
...rest
|
|
37
|
+
} = props
|
|
38
|
+
const [available, setAvailable] = React.useState<string[]>(initialAvailable)
|
|
39
|
+
const [selected, setSelected] = React.useState<string[]>(initialSelected)
|
|
40
|
+
return (
|
|
41
|
+
<TransferList
|
|
42
|
+
available={available}
|
|
43
|
+
selected={selected}
|
|
44
|
+
onAvailableChange={setAvailable}
|
|
45
|
+
onSelectedChange={setSelected}
|
|
46
|
+
{...rest}
|
|
47
|
+
/>
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
52
|
+
// Stories
|
|
53
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
54
|
+
|
|
55
|
+
export const Default: Story = {
|
|
56
|
+
render: () => (
|
|
57
|
+
<ControlledTransferList
|
|
58
|
+
searchable={false}
|
|
59
|
+
initialAvailable={["Alpha", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot"]}
|
|
60
|
+
/>
|
|
61
|
+
),
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export const WithSearch: Story = {
|
|
65
|
+
render: () => (
|
|
66
|
+
<ControlledTransferList
|
|
67
|
+
searchable
|
|
68
|
+
initialAvailable={[
|
|
69
|
+
"Accordion",
|
|
70
|
+
"Alert",
|
|
71
|
+
"Badge",
|
|
72
|
+
"Button",
|
|
73
|
+
"Calendar",
|
|
74
|
+
"Checkbox",
|
|
75
|
+
"Combobox",
|
|
76
|
+
"DataList",
|
|
77
|
+
"Dialog",
|
|
78
|
+
"Dropdown",
|
|
79
|
+
"Input",
|
|
80
|
+
"Label",
|
|
81
|
+
"Pagination",
|
|
82
|
+
"Progress",
|
|
83
|
+
"Select",
|
|
84
|
+
"Slider",
|
|
85
|
+
"Switch",
|
|
86
|
+
"Table",
|
|
87
|
+
"Tabs",
|
|
88
|
+
"Textarea",
|
|
89
|
+
"Toast",
|
|
90
|
+
"Tooltip",
|
|
91
|
+
]}
|
|
92
|
+
initialSelected={["Accordion", "Button", "Input"]}
|
|
93
|
+
/>
|
|
94
|
+
),
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Demonstrates wiring up to external controlled state (e.g., a form).
|
|
98
|
+
export const Controlled: Story = {
|
|
99
|
+
render: function ControlledStory() {
|
|
100
|
+
const [available, setAvailable] = React.useState([
|
|
101
|
+
"Read",
|
|
102
|
+
"Write",
|
|
103
|
+
"Delete",
|
|
104
|
+
"Admin",
|
|
105
|
+
])
|
|
106
|
+
const [selected, setSelected] = React.useState(["Read"])
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<div className="space-y-4">
|
|
110
|
+
<TransferList
|
|
111
|
+
available={available}
|
|
112
|
+
selected={selected}
|
|
113
|
+
onAvailableChange={setAvailable}
|
|
114
|
+
onSelectedChange={setSelected}
|
|
115
|
+
availableLabel="Permissions"
|
|
116
|
+
selectedLabel="Granted"
|
|
117
|
+
/>
|
|
118
|
+
<p className="text-sm text-muted-foreground">
|
|
119
|
+
Granted:{" "}
|
|
120
|
+
<span className="font-medium text-foreground">
|
|
121
|
+
{selected.length === 0 ? "none" : selected.join(", ")}
|
|
122
|
+
</span>
|
|
123
|
+
</p>
|
|
124
|
+
</div>
|
|
125
|
+
)
|
|
126
|
+
},
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Real-world usage: assigning team members to a project.
|
|
130
|
+
export const RealisticUse: Story = {
|
|
131
|
+
render: function RealisticUseStory() {
|
|
132
|
+
const allMembers = [
|
|
133
|
+
"Seo-yun Park",
|
|
134
|
+
"Jordan Reeves",
|
|
135
|
+
"Amara Osei",
|
|
136
|
+
"Takeshi Nakamura",
|
|
137
|
+
"Priya Mehta",
|
|
138
|
+
"Caleb Torres",
|
|
139
|
+
]
|
|
140
|
+
const [available, setAvailable] = React.useState(allMembers.slice(3))
|
|
141
|
+
const [selected, setSelected] = React.useState(allMembers.slice(0, 3))
|
|
142
|
+
|
|
143
|
+
return (
|
|
144
|
+
<div className="space-y-4 w-full">
|
|
145
|
+
<div>
|
|
146
|
+
<p className="text-sm font-medium text-foreground">
|
|
147
|
+
Assign team members to project
|
|
148
|
+
</p>
|
|
149
|
+
<p className="text-sm text-muted-foreground">
|
|
150
|
+
Select members from the available list, then move them to the
|
|
151
|
+
assigned column.
|
|
152
|
+
</p>
|
|
153
|
+
</div>
|
|
154
|
+
<TransferList
|
|
155
|
+
available={available}
|
|
156
|
+
selected={selected}
|
|
157
|
+
onAvailableChange={setAvailable}
|
|
158
|
+
onSelectedChange={setSelected}
|
|
159
|
+
availableLabel="Team members"
|
|
160
|
+
selectedLabel="Assigned"
|
|
161
|
+
searchable
|
|
162
|
+
/>
|
|
163
|
+
<p className="text-sm text-muted-foreground">
|
|
164
|
+
{selected.length} member{selected.length !== 1 ? "s" : ""} assigned
|
|
165
|
+
</p>
|
|
166
|
+
</div>
|
|
167
|
+
)
|
|
168
|
+
},
|
|
169
|
+
}
|