@behavioral-agentic-design-system/core 0.26.0 → 0.28.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 +4 -4
- package/scripts/build-tokens.cjs +8 -0
- package/src/app/preview/components/page.tsx +1004 -22
- package/src/app/shell.tsx +17 -0
- package/src/components/ui/ai-badge.tsx +74 -0
- package/src/components/ui/chat-bubble.tsx +298 -0
- package/src/components/ui/clipboard.tsx +291 -0
- package/src/components/ui/copy-button.tsx +5 -1
- package/src/components/ui/data-table.tsx +388 -0
- package/src/components/ui/floating-action-button.tsx +179 -0
- package/src/components/ui/focus-trap.tsx +184 -0
- package/src/components/ui/index.ts +8 -0
- package/src/components/ui/mark.tsx +69 -0
- package/src/components/ui/meter.tsx +4 -4
- package/src/components/ui/rolling-number.tsx +200 -0
- package/src/components/ui/transfer-list.tsx +48 -13
- package/src/components/ui/typing-indicator.tsx +96 -0
- package/src/components/ui/word-rotate.tsx +87 -0
- package/src/data/docs-index.ts +1 -0
- package/src/stories/Affix.stories.tsx +1 -1
- package/src/stories/AiBadge.stories.tsx +67 -0
- package/src/stories/Anchor.stories.tsx +4 -4
- package/src/stories/ChatBubble.stories.tsx +222 -0
- package/src/stories/Clipboard.stories.tsx +136 -0
- package/src/stories/CopyButton.stories.tsx +2 -0
- package/src/stories/DataTable.stories.tsx +271 -0
- package/src/stories/FloatingActionButton.stories.tsx +215 -0
- package/src/stories/FocusTrap.stories.tsx +218 -0
- package/src/stories/Mark.stories.tsx +84 -0
- package/src/stories/Meter.stories.tsx +7 -0
- package/src/stories/RollingNumber.stories.tsx +226 -0
- package/src/stories/TransferList.stories.tsx +21 -0
- package/src/stories/TypingIndicator.stories.tsx +140 -0
- package/src/stories/WordRotate.stories.tsx +102 -0
- package/src/styles.css +8 -0
- package/src/tokens.json +1 -1
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
import {
|
|
4
|
+
DataTable,
|
|
5
|
+
type ColumnDef,
|
|
6
|
+
} from "@behavioral-agentic-design-system/core/components/ui/data-table";
|
|
7
|
+
import { Badge } from "@behavioral-agentic-design-system/core/components/ui/badge";
|
|
8
|
+
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
// Meta
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
|
|
13
|
+
const meta: Meta<typeof DataTable> = {
|
|
14
|
+
title: "Components/DataTable",
|
|
15
|
+
component: DataTable,
|
|
16
|
+
parameters: {
|
|
17
|
+
layout: "padded",
|
|
18
|
+
docs: {
|
|
19
|
+
description: {
|
|
20
|
+
component:
|
|
21
|
+
"Sortable, paginated, optionally selectable data grid. Wraps @tanstack/react-table for state management and exposes a declarative columns + data API. Use for admin tables, report outputs, and any structured dataset with >10 rows. Prefer the bare Table primitive for static reference data.",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
tags: ["autodocs"],
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default meta;
|
|
29
|
+
type Story = StoryObj<typeof meta>;
|
|
30
|
+
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
// Shared types & data
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
|
|
35
|
+
interface TeamMember {
|
|
36
|
+
name: string;
|
|
37
|
+
role: string;
|
|
38
|
+
email: string;
|
|
39
|
+
joined: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const TEAM_MEMBERS: TeamMember[] = [
|
|
43
|
+
{
|
|
44
|
+
name: "Jordan Reeves",
|
|
45
|
+
role: "Design Lead",
|
|
46
|
+
email: "jordan@reeves.design",
|
|
47
|
+
joined: "2024-03-12",
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: "Anika Patel",
|
|
51
|
+
role: "Frontend Engineer",
|
|
52
|
+
email: "anika.patel@bads.design",
|
|
53
|
+
joined: "2024-05-01",
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: "Marcus Lindqvist",
|
|
57
|
+
role: "Product Manager",
|
|
58
|
+
email: "m.lindqvist@bads.design",
|
|
59
|
+
joined: "2023-11-20",
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: "Priya Nair",
|
|
63
|
+
role: "Accessibility Specialist",
|
|
64
|
+
email: "priya.nair@bads.design",
|
|
65
|
+
joined: "2025-01-08",
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "Theo Okafor",
|
|
69
|
+
role: "Design Technologist",
|
|
70
|
+
email: "theo.okafor@bads.design",
|
|
71
|
+
joined: "2024-09-15",
|
|
72
|
+
},
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
const TEAM_COLUMNS: ColumnDef<TeamMember>[] = [
|
|
76
|
+
{ accessorKey: "name", header: "Name" },
|
|
77
|
+
{ accessorKey: "role", header: "Role" },
|
|
78
|
+
{ accessorKey: "email", header: "Email" },
|
|
79
|
+
{ accessorKey: "joined", header: "Joined" },
|
|
80
|
+
];
|
|
81
|
+
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
// Default
|
|
84
|
+
// ---------------------------------------------------------------------------
|
|
85
|
+
|
|
86
|
+
export const Default: Story = {
|
|
87
|
+
render: () => (
|
|
88
|
+
<DataTable columns={TEAM_COLUMNS} data={TEAM_MEMBERS} />
|
|
89
|
+
),
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// ---------------------------------------------------------------------------
|
|
93
|
+
// Sortable (explicit prop — same as default since sorting is on by default)
|
|
94
|
+
// ---------------------------------------------------------------------------
|
|
95
|
+
|
|
96
|
+
export const Sortable: Story = {
|
|
97
|
+
render: () => (
|
|
98
|
+
<DataTable columns={TEAM_COLUMNS} data={TEAM_MEMBERS} sorting={true} />
|
|
99
|
+
),
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// ---------------------------------------------------------------------------
|
|
103
|
+
// WithPagination (15+ rows)
|
|
104
|
+
// ---------------------------------------------------------------------------
|
|
105
|
+
|
|
106
|
+
interface ComponentAdoption {
|
|
107
|
+
component: string;
|
|
108
|
+
status: string;
|
|
109
|
+
adopters: number;
|
|
110
|
+
coverage: string;
|
|
111
|
+
lastUpdated: string;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const ADOPTION_DATA: ComponentAdoption[] = [
|
|
115
|
+
{ component: "Button", status: "Stable", adopters: 14, coverage: "100%", lastUpdated: "2026-07-28" },
|
|
116
|
+
{ component: "Input", status: "Stable", adopters: 13, coverage: "98%", lastUpdated: "2026-07-22" },
|
|
117
|
+
{ component: "Card", status: "Stable", adopters: 12, coverage: "95%", lastUpdated: "2026-07-15" },
|
|
118
|
+
{ component: "Dialog", status: "Stable", adopters: 11, coverage: "91%", lastUpdated: "2026-07-10" },
|
|
119
|
+
{ component: "Table", status: "Stable", adopters: 10, coverage: "88%", lastUpdated: "2026-07-08" },
|
|
120
|
+
{ component: "Badge", status: "Stable", adopters: 9, coverage: "84%", lastUpdated: "2026-07-05" },
|
|
121
|
+
{ component: "Select", status: "Stable", adopters: 9, coverage: "82%", lastUpdated: "2026-07-01" },
|
|
122
|
+
{ component: "Checkbox", status: "Stable", adopters: 8, coverage: "78%", lastUpdated: "2026-06-28" },
|
|
123
|
+
{ component: "Tooltip", status: "Stable", adopters: 8, coverage: "75%", lastUpdated: "2026-06-25" },
|
|
124
|
+
{ component: "Accordion", status: "Stable", adopters: 7, coverage: "70%", lastUpdated: "2026-06-20" },
|
|
125
|
+
{ component: "Sheet", status: "Stable", adopters: 7, coverage: "68%", lastUpdated: "2026-06-18" },
|
|
126
|
+
{ component: "Popover", status: "Stable", adopters: 6, coverage: "64%", lastUpdated: "2026-06-14" },
|
|
127
|
+
{ component: "Tabs", status: "Stable", adopters: 6, coverage: "61%", lastUpdated: "2026-06-10" },
|
|
128
|
+
{ component: "DataTable", status: "New", adopters: 1, coverage: "12%", lastUpdated: "2026-08-03" },
|
|
129
|
+
{ component: "Slider", status: "Beta", adopters: 4, coverage: "42%", lastUpdated: "2026-06-05" },
|
|
130
|
+
{ component: "Calendar", status: "Beta", adopters: 3, coverage: "38%", lastUpdated: "2026-06-02" },
|
|
131
|
+
{ component: "TreeView", status: "Beta", adopters: 2, coverage: "24%", lastUpdated: "2026-05-28" },
|
|
132
|
+
];
|
|
133
|
+
|
|
134
|
+
const ADOPTION_COLUMNS: ColumnDef<ComponentAdoption>[] = [
|
|
135
|
+
{ accessorKey: "component", header: "Component" },
|
|
136
|
+
{ accessorKey: "status", header: "Status" },
|
|
137
|
+
{ accessorKey: "adopters", header: "Adopters" },
|
|
138
|
+
{ accessorKey: "coverage", header: "Coverage" },
|
|
139
|
+
{ accessorKey: "lastUpdated", header: "Last Updated" },
|
|
140
|
+
];
|
|
141
|
+
|
|
142
|
+
export const WithPagination: Story = {
|
|
143
|
+
render: () => (
|
|
144
|
+
<DataTable
|
|
145
|
+
columns={ADOPTION_COLUMNS}
|
|
146
|
+
data={ADOPTION_DATA}
|
|
147
|
+
pagination={{ pageSize: 8 }}
|
|
148
|
+
/>
|
|
149
|
+
),
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
// ---------------------------------------------------------------------------
|
|
153
|
+
// WithRowSelection
|
|
154
|
+
// ---------------------------------------------------------------------------
|
|
155
|
+
|
|
156
|
+
export const WithRowSelection: Story = {
|
|
157
|
+
render: () => (
|
|
158
|
+
<DataTable
|
|
159
|
+
columns={TEAM_COLUMNS}
|
|
160
|
+
data={TEAM_MEMBERS}
|
|
161
|
+
rowSelection={true}
|
|
162
|
+
/>
|
|
163
|
+
),
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
// ---------------------------------------------------------------------------
|
|
167
|
+
// Dense
|
|
168
|
+
// ---------------------------------------------------------------------------
|
|
169
|
+
|
|
170
|
+
export const Dense: Story = {
|
|
171
|
+
render: () => (
|
|
172
|
+
<DataTable
|
|
173
|
+
columns={TEAM_COLUMNS}
|
|
174
|
+
data={TEAM_MEMBERS}
|
|
175
|
+
density="dense"
|
|
176
|
+
/>
|
|
177
|
+
),
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
// ---------------------------------------------------------------------------
|
|
181
|
+
// EmptyState
|
|
182
|
+
// ---------------------------------------------------------------------------
|
|
183
|
+
|
|
184
|
+
export const EmptyState: Story = {
|
|
185
|
+
render: () => (
|
|
186
|
+
<DataTable
|
|
187
|
+
columns={TEAM_COLUMNS}
|
|
188
|
+
data={[]}
|
|
189
|
+
emptyMessage="No team members matched your filters."
|
|
190
|
+
/>
|
|
191
|
+
),
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
// ---------------------------------------------------------------------------
|
|
195
|
+
// RealisticUse — design system component adoption table
|
|
196
|
+
// ---------------------------------------------------------------------------
|
|
197
|
+
|
|
198
|
+
type AdoptionStatus = "Stable" | "Beta" | "New" | "Deprecated";
|
|
199
|
+
|
|
200
|
+
interface ComponentRow {
|
|
201
|
+
component: string;
|
|
202
|
+
status: AdoptionStatus;
|
|
203
|
+
adopters: number;
|
|
204
|
+
coverage: string;
|
|
205
|
+
lastUpdated: string;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const REALISTIC_DATA: ComponentRow[] = [
|
|
209
|
+
{ component: "Button", status: "Stable", adopters: 14, coverage: "100%", lastUpdated: "2026-07-28" },
|
|
210
|
+
{ component: "Input", status: "Stable", adopters: 13, coverage: "98%", lastUpdated: "2026-07-22" },
|
|
211
|
+
{ component: "Card", status: "Stable", adopters: 12, coverage: "95%", lastUpdated: "2026-07-15" },
|
|
212
|
+
{ component: "Dialog", status: "Stable", adopters: 11, coverage: "91%", lastUpdated: "2026-07-10" },
|
|
213
|
+
{ component: "DataTable", status: "New", adopters: 1, coverage: "12%", lastUpdated: "2026-08-03" },
|
|
214
|
+
{ component: "Slider", status: "Beta", adopters: 4, coverage: "42%", lastUpdated: "2026-06-05" },
|
|
215
|
+
{ component: "Calendar", status: "Beta", adopters: 3, coverage: "38%", lastUpdated: "2026-06-02" },
|
|
216
|
+
];
|
|
217
|
+
|
|
218
|
+
const STATUS_VARIANT_MAP: Record<AdoptionStatus, "default" | "secondary" | "outline" | "destructive"> = {
|
|
219
|
+
Stable: "default",
|
|
220
|
+
Beta: "secondary",
|
|
221
|
+
New: "outline",
|
|
222
|
+
Deprecated: "destructive",
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
const REALISTIC_COLUMNS: ColumnDef<ComponentRow>[] = [
|
|
226
|
+
{ accessorKey: "component", header: "Component" },
|
|
227
|
+
{
|
|
228
|
+
accessorKey: "status",
|
|
229
|
+
header: "Status",
|
|
230
|
+
cell: ({ row }) => {
|
|
231
|
+
const status = row.getValue<AdoptionStatus>("status");
|
|
232
|
+
return (
|
|
233
|
+
<Badge variant={STATUS_VARIANT_MAP[status]} className="text-xs">
|
|
234
|
+
{status}
|
|
235
|
+
</Badge>
|
|
236
|
+
);
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
accessorKey: "adopters",
|
|
241
|
+
header: "Adopters",
|
|
242
|
+
cell: ({ row }) => (
|
|
243
|
+
<span className="tabular-nums">{row.getValue<number>("adopters")}</span>
|
|
244
|
+
),
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
accessorKey: "coverage",
|
|
248
|
+
header: "Coverage",
|
|
249
|
+
cell: ({ row }) => (
|
|
250
|
+
<span className="tabular-nums font-medium">{row.getValue<string>("coverage")}</span>
|
|
251
|
+
),
|
|
252
|
+
},
|
|
253
|
+
{ accessorKey: "lastUpdated", header: "Last Updated" },
|
|
254
|
+
];
|
|
255
|
+
|
|
256
|
+
export const RealisticUse: Story = {
|
|
257
|
+
render: () => (
|
|
258
|
+
<div className="space-y-2">
|
|
259
|
+
<p className="text-sm text-muted-foreground">
|
|
260
|
+
Component adoption tracker — Jordan Reeves' team across 14 product surfaces.
|
|
261
|
+
</p>
|
|
262
|
+
<DataTable
|
|
263
|
+
columns={REALISTIC_COLUMNS}
|
|
264
|
+
data={REALISTIC_DATA}
|
|
265
|
+
sorting={true}
|
|
266
|
+
pagination={{ pageSize: 5 }}
|
|
267
|
+
rowSelection={true}
|
|
268
|
+
/>
|
|
269
|
+
</div>
|
|
270
|
+
),
|
|
271
|
+
};
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
import { MessageCircle, Pencil, Plus } from "lucide-react";
|
|
4
|
+
import { FloatingActionButton } from "@behavioral-agentic-design-system/core/components/ui/floating-action-button";
|
|
5
|
+
import { Badge } from "@behavioral-agentic-design-system/core/components/ui/badge";
|
|
6
|
+
|
|
7
|
+
const meta: Meta<typeof FloatingActionButton> = {
|
|
8
|
+
title: "Components/FloatingActionButton",
|
|
9
|
+
component: FloatingActionButton,
|
|
10
|
+
parameters: {
|
|
11
|
+
layout: "centered",
|
|
12
|
+
docs: {
|
|
13
|
+
description: {
|
|
14
|
+
component:
|
|
15
|
+
"Fixed-position circular button that triggers a single primary action — the single-action counterpart to SpeedDial (which opens a 2–5 item submenu). Wraps Button, so focus ring, loading, and disabled ship from the primitive. md (56px) is the recommended thumb-target size; sm (40px) sits below the 44px floor and is for dense secondary chrome only. Icon-only FABs REQUIRE aria-label. Stories render inside a [transform:translateZ(0)] frame so position:fixed pins to the demo frame instead of the Storybook viewport.",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
tags: ["autodocs"],
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default meta;
|
|
23
|
+
type Story = StoryObj<typeof meta>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Demo frame: `transform: translateZ(0)` makes this box the containing block
|
|
27
|
+
* for `position: fixed` descendants, so the FAB pins to the frame instead of
|
|
28
|
+
* the Storybook viewport (same trick as the Affix stories). In a real app the
|
|
29
|
+
* FAB pins to the true viewport.
|
|
30
|
+
*/
|
|
31
|
+
function DemoFrame({ children }: { children: React.ReactNode }) {
|
|
32
|
+
return (
|
|
33
|
+
<div className="relative h-64 w-96 overflow-hidden rounded-lg border border-border bg-card [transform:translateZ(0)]">
|
|
34
|
+
<div className="p-4">
|
|
35
|
+
<p className="text-sm font-medium text-foreground">design.bads.com</p>
|
|
36
|
+
<p className="text-sm text-muted-foreground">
|
|
37
|
+
The frame stands in for the viewport — the FAB stays pinned to its
|
|
38
|
+
corner while everything else scrolls.
|
|
39
|
+
</p>
|
|
40
|
+
</div>
|
|
41
|
+
{children}
|
|
42
|
+
</div>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const Default: Story = {
|
|
47
|
+
render: () => (
|
|
48
|
+
<DemoFrame>
|
|
49
|
+
<FloatingActionButton
|
|
50
|
+
icon={<Plus strokeWidth={1.5} aria-hidden="true" />}
|
|
51
|
+
aria-label="Create new"
|
|
52
|
+
/>
|
|
53
|
+
</DemoFrame>
|
|
54
|
+
),
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const Variant_Secondary: Story = {
|
|
58
|
+
render: () => (
|
|
59
|
+
<DemoFrame>
|
|
60
|
+
<FloatingActionButton
|
|
61
|
+
variant="secondary"
|
|
62
|
+
icon={<MessageCircle strokeWidth={1.5} aria-hidden="true" />}
|
|
63
|
+
aria-label="Open chat with Jordan Reeves"
|
|
64
|
+
/>
|
|
65
|
+
</DemoFrame>
|
|
66
|
+
),
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const WithLabel: Story = {
|
|
70
|
+
render: () => (
|
|
71
|
+
<DemoFrame>
|
|
72
|
+
{/* Extended (pill) form — the visible label IS the accessible name. */}
|
|
73
|
+
<FloatingActionButton
|
|
74
|
+
icon={<Pencil strokeWidth={1.5} aria-hidden="true" />}
|
|
75
|
+
label="New proposal"
|
|
76
|
+
/>
|
|
77
|
+
</DemoFrame>
|
|
78
|
+
),
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const Size_Sm: Story = {
|
|
82
|
+
render: () => (
|
|
83
|
+
<DemoFrame>
|
|
84
|
+
{/* 40px — below the 44px SC 2.5.5 floor. Dense/desktop-secondary
|
|
85
|
+
chrome only; never the primary CTA (see registry antiPatterns). */}
|
|
86
|
+
<FloatingActionButton
|
|
87
|
+
size="sm"
|
|
88
|
+
variant="secondary"
|
|
89
|
+
icon={<Plus strokeWidth={1.5} aria-hidden="true" />}
|
|
90
|
+
aria-label="Add token"
|
|
91
|
+
/>
|
|
92
|
+
</DemoFrame>
|
|
93
|
+
),
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export const Size_Md: Story = {
|
|
97
|
+
render: () => (
|
|
98
|
+
<DemoFrame>
|
|
99
|
+
<FloatingActionButton
|
|
100
|
+
size="md"
|
|
101
|
+
icon={<Plus strokeWidth={1.5} aria-hidden="true" />}
|
|
102
|
+
aria-label="Create new"
|
|
103
|
+
/>
|
|
104
|
+
</DemoFrame>
|
|
105
|
+
),
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export const Size_Lg: Story = {
|
|
109
|
+
render: () => (
|
|
110
|
+
<DemoFrame>
|
|
111
|
+
<FloatingActionButton
|
|
112
|
+
size="lg"
|
|
113
|
+
icon={<Plus strokeWidth={1.5} aria-hidden="true" />}
|
|
114
|
+
aria-label="Create new"
|
|
115
|
+
/>
|
|
116
|
+
</DemoFrame>
|
|
117
|
+
),
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export const Corner_BottomLeft: Story = {
|
|
121
|
+
render: () => (
|
|
122
|
+
<DemoFrame>
|
|
123
|
+
<FloatingActionButton
|
|
124
|
+
corner="bottom-left"
|
|
125
|
+
icon={<MessageCircle strokeWidth={1.5} aria-hidden="true" />}
|
|
126
|
+
aria-label="Open support chat"
|
|
127
|
+
/>
|
|
128
|
+
</DemoFrame>
|
|
129
|
+
),
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export const Loading: Story = {
|
|
133
|
+
render: () => (
|
|
134
|
+
<DemoFrame>
|
|
135
|
+
{/* Spinner replaces the icon; aria-busy + disabled via Button. The
|
|
136
|
+
min-h/min-w frame keeps dimensions stable while loading. */}
|
|
137
|
+
<FloatingActionButton
|
|
138
|
+
loading
|
|
139
|
+
icon={<Plus strokeWidth={1.5} aria-hidden="true" />}
|
|
140
|
+
aria-label="Creating proposal"
|
|
141
|
+
/>
|
|
142
|
+
</DemoFrame>
|
|
143
|
+
),
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export const Disabled: Story = {
|
|
147
|
+
render: () => (
|
|
148
|
+
<DemoFrame>
|
|
149
|
+
<FloatingActionButton
|
|
150
|
+
disabled
|
|
151
|
+
icon={<Plus strokeWidth={1.5} aria-hidden="true" />}
|
|
152
|
+
aria-label="Create new (unavailable)"
|
|
153
|
+
/>
|
|
154
|
+
</DemoFrame>
|
|
155
|
+
),
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// Real content from content/personas/bads.json (primary persona pool).
|
|
159
|
+
const reviewQueue = [
|
|
160
|
+
{
|
|
161
|
+
author: "Jordan Reeves",
|
|
162
|
+
date: "2026-05-26",
|
|
163
|
+
entry:
|
|
164
|
+
"Shared 36 components for review at design.bads.com/share/tokens-v2-proposal.",
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
author: "Seo-yun Park",
|
|
168
|
+
date: "2026-01-15",
|
|
169
|
+
entry: "Raised the contrast floor to 7:1 across every shipped token pair.",
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
author: "Marcus Lindqvist",
|
|
173
|
+
date: "2025-11-20",
|
|
174
|
+
entry: "Moved the touch-target audit to the 44×44px target across all CTAs.",
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
author: "Anika Patel",
|
|
178
|
+
date: "2027-03-01",
|
|
179
|
+
entry:
|
|
180
|
+
"Scheduled the semantic-layer migration — token drift lint goes strict.",
|
|
181
|
+
},
|
|
182
|
+
];
|
|
183
|
+
|
|
184
|
+
export const RealisticUse: Story = {
|
|
185
|
+
render: () => (
|
|
186
|
+
<div className="relative h-80 w-[420px] overflow-hidden rounded-lg border border-border bg-card [transform:translateZ(0)]">
|
|
187
|
+
<div className="h-full overflow-y-auto p-4" tabIndex={0}>
|
|
188
|
+
<div className="flex items-center justify-between gap-3">
|
|
189
|
+
<h3 className="min-w-0 truncate text-base font-semibold text-foreground">
|
|
190
|
+
Tokens v2 proposal — review queue
|
|
191
|
+
</h3>
|
|
192
|
+
<Badge variant="secondary">4 open</Badge>
|
|
193
|
+
</div>
|
|
194
|
+
<ul className="mt-3 space-y-4">
|
|
195
|
+
{reviewQueue.map((item, i) => (
|
|
196
|
+
<li key={i} className="space-y-1">
|
|
197
|
+
<p className="text-sm font-medium text-foreground">
|
|
198
|
+
{item.author}{" "}
|
|
199
|
+
<span className="font-normal text-muted-foreground">
|
|
200
|
+
· {item.date}
|
|
201
|
+
</span>
|
|
202
|
+
</p>
|
|
203
|
+
<p className="text-sm text-muted-foreground">{item.entry}</p>
|
|
204
|
+
</li>
|
|
205
|
+
))}
|
|
206
|
+
</ul>
|
|
207
|
+
</div>
|
|
208
|
+
{/* The single primary action on this surface: start a new review. */}
|
|
209
|
+
<FloatingActionButton
|
|
210
|
+
icon={<Pencil strokeWidth={1.5} aria-hidden="true" />}
|
|
211
|
+
label="New review"
|
|
212
|
+
/>
|
|
213
|
+
</div>
|
|
214
|
+
),
|
|
215
|
+
};
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
import {
|
|
4
|
+
FocusTrap,
|
|
5
|
+
FocusTrapInitialFocus,
|
|
6
|
+
} from "@behavioral-agentic-design-system/core/components/ui/focus-trap";
|
|
7
|
+
import { Button } from "@behavioral-agentic-design-system/core/components/ui/button";
|
|
8
|
+
import { Input } from "@behavioral-agentic-design-system/core/components/ui/input";
|
|
9
|
+
import { Label } from "@behavioral-agentic-design-system/core/components/ui/label";
|
|
10
|
+
|
|
11
|
+
const meta: Meta<typeof FocusTrap> = {
|
|
12
|
+
title: "Components/FocusTrap",
|
|
13
|
+
component: FocusTrap,
|
|
14
|
+
parameters: { layout: "centered" },
|
|
15
|
+
tags: ["autodocs"],
|
|
16
|
+
argTypes: {
|
|
17
|
+
active: { control: "boolean" },
|
|
18
|
+
loop: { control: "boolean" },
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default meta;
|
|
23
|
+
type Story = StoryObj<typeof meta>;
|
|
24
|
+
|
|
25
|
+
export const Default: Story = {
|
|
26
|
+
render: () => {
|
|
27
|
+
const [open, setOpen] = React.useState(false);
|
|
28
|
+
return (
|
|
29
|
+
<div className="space-y-4">
|
|
30
|
+
<Button onClick={() => setOpen(true)}>Open trapped form</Button>
|
|
31
|
+
{open && (
|
|
32
|
+
<FocusTrap
|
|
33
|
+
active
|
|
34
|
+
onEscapeKeyDown={() => setOpen(false)}
|
|
35
|
+
className="rounded-lg border bg-card p-6 shadow-sm"
|
|
36
|
+
>
|
|
37
|
+
<div role="dialog" aria-modal="true" aria-labelledby="ft-title">
|
|
38
|
+
<h3 id="ft-title" className="mb-4 text-lg font-semibold">
|
|
39
|
+
Trapped focus area
|
|
40
|
+
</h3>
|
|
41
|
+
<div className="space-y-3">
|
|
42
|
+
<div className="space-y-1.5">
|
|
43
|
+
<Label htmlFor="ft-name">Name</Label>
|
|
44
|
+
<Input id="ft-name" placeholder="Seo-yun Park" />
|
|
45
|
+
</div>
|
|
46
|
+
<div className="space-y-1.5">
|
|
47
|
+
<Label htmlFor="ft-email">Email</Label>
|
|
48
|
+
<Input id="ft-email" type="email" placeholder="seo-yun@bads.com" />
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
<div className="mt-4 flex gap-3">
|
|
52
|
+
<Button size="sm" onClick={() => setOpen(false)}>
|
|
53
|
+
Save
|
|
54
|
+
</Button>
|
|
55
|
+
<Button size="sm" variant="outline" onClick={() => setOpen(false)}>
|
|
56
|
+
Cancel
|
|
57
|
+
</Button>
|
|
58
|
+
</div>
|
|
59
|
+
<p className="mt-3 text-xs text-muted-foreground">
|
|
60
|
+
Tab cycles within. Press Escape to close.
|
|
61
|
+
</p>
|
|
62
|
+
</div>
|
|
63
|
+
</FocusTrap>
|
|
64
|
+
)}
|
|
65
|
+
</div>
|
|
66
|
+
);
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const Deactivated: Story = {
|
|
71
|
+
render: () => (
|
|
72
|
+
<FocusTrap
|
|
73
|
+
active={false}
|
|
74
|
+
className="rounded-lg border bg-card p-6"
|
|
75
|
+
>
|
|
76
|
+
<p className="mb-3 text-sm text-muted-foreground">
|
|
77
|
+
active=false — Tab moves freely outside this container.
|
|
78
|
+
</p>
|
|
79
|
+
<div className="flex gap-3">
|
|
80
|
+
<Button size="sm">First</Button>
|
|
81
|
+
<Button size="sm" variant="outline">Second</Button>
|
|
82
|
+
<Button size="sm" variant="outline">Third</Button>
|
|
83
|
+
</div>
|
|
84
|
+
</FocusTrap>
|
|
85
|
+
),
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export const WithEscapeKey: Story = {
|
|
89
|
+
render: () => {
|
|
90
|
+
const [open, setOpen] = React.useState(false);
|
|
91
|
+
const [log, setLog] = React.useState<string[]>([]);
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<div className="space-y-4">
|
|
95
|
+
<Button
|
|
96
|
+
onClick={() => {
|
|
97
|
+
setOpen(true);
|
|
98
|
+
setLog((l) => [...l, "opened"]);
|
|
99
|
+
}}
|
|
100
|
+
>
|
|
101
|
+
Open (then press Escape)
|
|
102
|
+
</Button>
|
|
103
|
+
{open && (
|
|
104
|
+
<FocusTrap
|
|
105
|
+
active
|
|
106
|
+
onEscapeKeyDown={() => {
|
|
107
|
+
setOpen(false);
|
|
108
|
+
setLog((l) => [...l, "closed via Escape"]);
|
|
109
|
+
}}
|
|
110
|
+
className="rounded-lg border bg-card p-6 shadow-sm"
|
|
111
|
+
>
|
|
112
|
+
<p className="mb-3 text-sm">Press Escape to close and log it.</p>
|
|
113
|
+
<div className="flex gap-3">
|
|
114
|
+
<Button size="sm">Action A</Button>
|
|
115
|
+
<Button size="sm" variant="outline">Action B</Button>
|
|
116
|
+
</div>
|
|
117
|
+
</FocusTrap>
|
|
118
|
+
)}
|
|
119
|
+
{log.length > 0 && (
|
|
120
|
+
<ul className="space-y-1">
|
|
121
|
+
{log.map((entry, i) => (
|
|
122
|
+
<li key={i} className="text-xs text-muted-foreground">
|
|
123
|
+
{i + 1}. {entry}
|
|
124
|
+
</li>
|
|
125
|
+
))}
|
|
126
|
+
</ul>
|
|
127
|
+
)}
|
|
128
|
+
</div>
|
|
129
|
+
);
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export const WithInitialFocus: Story = {
|
|
134
|
+
render: () => {
|
|
135
|
+
const [open, setOpen] = React.useState(false);
|
|
136
|
+
return (
|
|
137
|
+
<div className="space-y-4">
|
|
138
|
+
<Button onClick={() => setOpen(true)}>Open (Cancel gets initial focus)</Button>
|
|
139
|
+
{open && (
|
|
140
|
+
<FocusTrap
|
|
141
|
+
active
|
|
142
|
+
onEscapeKeyDown={() => setOpen(false)}
|
|
143
|
+
className="rounded-lg border border-destructive/30 bg-card p-6 shadow-sm"
|
|
144
|
+
>
|
|
145
|
+
<p className="mb-4 text-sm text-muted-foreground">
|
|
146
|
+
FocusTrapInitialFocus sits before the destructive Confirm — the
|
|
147
|
+
safe Cancel button receives focus on open.
|
|
148
|
+
</p>
|
|
149
|
+
<Button variant="destructive" size="sm">
|
|
150
|
+
Confirm delete
|
|
151
|
+
</Button>{" "}
|
|
152
|
+
<FocusTrapInitialFocus />
|
|
153
|
+
<Button
|
|
154
|
+
size="sm"
|
|
155
|
+
variant="outline"
|
|
156
|
+
onClick={() => setOpen(false)}
|
|
157
|
+
>
|
|
158
|
+
Cancel (initial focus)
|
|
159
|
+
</Button>
|
|
160
|
+
</FocusTrap>
|
|
161
|
+
)}
|
|
162
|
+
</div>
|
|
163
|
+
);
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
export const RealisticUse: Story = {
|
|
168
|
+
render: () => {
|
|
169
|
+
const [open, setOpen] = React.useState(false);
|
|
170
|
+
return (
|
|
171
|
+
<div className="max-w-sm space-y-4">
|
|
172
|
+
<p className="text-sm text-muted-foreground">
|
|
173
|
+
A lightweight confirmation panel that uses FocusTrap instead of
|
|
174
|
+
Dialog — no overlay, no portal. Useful for inline destructive
|
|
175
|
+
actions in table rows or settings lists.
|
|
176
|
+
</p>
|
|
177
|
+
<Button variant="outline" size="sm" onClick={() => setOpen(true)}>
|
|
178
|
+
Remove team member
|
|
179
|
+
</Button>
|
|
180
|
+
{open && (
|
|
181
|
+
<FocusTrap
|
|
182
|
+
active
|
|
183
|
+
onEscapeKeyDown={() => setOpen(false)}
|
|
184
|
+
className="rounded-lg border border-destructive/40 bg-card px-5 py-4 shadow-md"
|
|
185
|
+
>
|
|
186
|
+
<div role="dialog" aria-modal="true" aria-labelledby="rm-title">
|
|
187
|
+
<p
|
|
188
|
+
id="rm-title"
|
|
189
|
+
className="mb-1 text-sm font-medium text-foreground"
|
|
190
|
+
>
|
|
191
|
+
Remove Arjun Mehta from the workspace?
|
|
192
|
+
</p>
|
|
193
|
+
<p className="mb-4 text-xs text-muted-foreground">
|
|
194
|
+
This revokes access immediately. The action cannot be undone.
|
|
195
|
+
</p>
|
|
196
|
+
<div className="flex gap-2">
|
|
197
|
+
<Button
|
|
198
|
+
variant="destructive"
|
|
199
|
+
size="sm"
|
|
200
|
+
onClick={() => setOpen(false)}
|
|
201
|
+
>
|
|
202
|
+
Remove
|
|
203
|
+
</Button>
|
|
204
|
+
<Button
|
|
205
|
+
variant="outline"
|
|
206
|
+
size="sm"
|
|
207
|
+
onClick={() => setOpen(false)}
|
|
208
|
+
>
|
|
209
|
+
Cancel
|
|
210
|
+
</Button>
|
|
211
|
+
</div>
|
|
212
|
+
</div>
|
|
213
|
+
</FocusTrap>
|
|
214
|
+
)}
|
|
215
|
+
</div>
|
|
216
|
+
);
|
|
217
|
+
},
|
|
218
|
+
};
|