@behavioral-agentic-design-system/core 0.28.0 → 0.30.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 +2 -2
- package/scripts/a11y-lint.cjs +78 -9
- package/scripts/build-tokens.cjs +273 -15
- package/scripts/wcag-audit.cjs +67 -11
- package/src/api/layers/file.ts +1 -0
- package/src/app/font-ready.tsx +6 -5
- package/src/app/layout.tsx +54 -3
- package/src/app/preview/components/page.tsx +5679 -3073
- package/src/app/preview/health/page.tsx +201 -0
- package/src/app/preview/layout.tsx +4 -1
- package/src/app/preview/showcase-filter.tsx +66 -0
- package/src/app/preview/tab-replay.tsx +63 -0
- package/src/app/shell.tsx +74 -18
- package/src/components/customize/save-bar.tsx +19 -6
- package/src/components/docs-tab.tsx +36 -24
- package/src/components/layers-tab.tsx +37 -5
- package/src/components/ui/alert.tsx +12 -0
- package/src/components/ui/badge.tsx +19 -0
- package/src/components/ui/button.tsx +10 -0
- package/src/components/ui/chat-marker.tsx +120 -0
- package/src/components/ui/checkbox.tsx +9 -1
- package/src/components/ui/close-button.tsx +71 -0
- package/src/components/ui/combobox.tsx +62 -3
- package/src/components/ui/container.tsx +65 -0
- package/src/components/ui/date-field.tsx +368 -0
- package/src/components/ui/drawer.tsx +334 -0
- package/src/components/ui/file-button.tsx +145 -0
- package/src/components/ui/floating-indicator.tsx +217 -0
- package/src/components/ui/format-byte.tsx +113 -0
- package/src/components/ui/index.ts +21 -0
- package/src/components/ui/input-clear-button.tsx +52 -0
- package/src/components/ui/input.tsx +39 -20
- package/src/components/ui/keyboard-shortcut.tsx +146 -0
- package/src/components/ui/loading-dots.tsx +99 -0
- package/src/components/ui/month-picker.tsx +296 -0
- package/src/components/ui/multi-select.tsx +35 -19
- package/src/components/ui/nav-link.tsx +200 -0
- package/src/components/ui/navigation-rail.tsx +256 -0
- package/src/components/ui/notification.tsx +20 -0
- package/src/components/ui/password-input.tsx +34 -1
- package/src/components/ui/progress.tsx +15 -1
- package/src/components/ui/prose.tsx +62 -0
- package/src/components/ui/questionnaire.tsx +334 -0
- package/src/components/ui/result.tsx +151 -0
- package/src/components/ui/rolling-number.tsx +1 -0
- package/src/components/ui/sidebar.tsx +5 -0
- package/src/components/ui/simple-grid.tsx +110 -0
- package/src/components/ui/skeleton.tsx +52 -3
- package/src/components/ui/squircle.tsx +274 -0
- package/src/components/ui/stack.tsx +105 -0
- package/src/components/ui/status-badge.tsx +93 -0
- package/src/components/ui/tabs.tsx +34 -7
- package/src/components/ui/tag.tsx +46 -5
- package/src/components/ui/textarea.tsx +5 -0
- package/src/components/ui/theme-icon.tsx +138 -0
- package/src/components/ui/timeline.tsx +27 -10
- package/src/components/ui/tooltip.tsx +12 -1
- package/src/components/ui/tree-select.tsx +386 -0
- package/src/components/ui/year-picker.tsx +307 -0
- package/src/data/docs-index.ts +12 -0
- package/src/hooks/use-global-primary-color.ts +57 -6
- package/src/lib/get-icon-color.ts +66 -0
- package/src/stories/Alert.stories.tsx +31 -1
- package/src/stories/Badge.stories.tsx +63 -6
- package/src/stories/Button.stories.tsx +3 -0
- package/src/stories/ChatMarker.stories.tsx +59 -0
- package/src/stories/Checkbox.stories.tsx +5 -0
- package/src/stories/CloseButton.stories.tsx +65 -0
- package/src/stories/Combobox.stories.tsx +74 -3
- package/src/stories/Container.stories.tsx +134 -0
- package/src/stories/DateField.stories.tsx +114 -0
- package/src/stories/Drawer.stories.tsx +211 -0
- package/src/stories/FileButton.stories.tsx +117 -0
- package/src/stories/FloatingIndicator.stories.tsx +343 -0
- package/src/stories/FormatByte.stories.tsx +142 -0
- package/src/stories/Input.stories.tsx +94 -0
- package/src/stories/InputClearButton.stories.tsx +53 -0
- package/src/stories/KeyboardShortcut.stories.tsx +87 -0
- package/src/stories/LoadingDots.stories.tsx +73 -0
- package/src/stories/MonthPicker.stories.tsx +99 -0
- package/src/stories/MultiSelect.stories.tsx +7 -1
- package/src/stories/NavLink.stories.tsx +213 -0
- package/src/stories/NavigationRail.stories.tsx +413 -0
- package/src/stories/Notification.stories.tsx +53 -0
- package/src/stories/PasswordInput.stories.tsx +21 -0
- package/src/stories/Progress.stories.tsx +38 -0
- package/src/stories/Prose.stories.tsx +232 -0
- package/src/stories/Questionnaire.stories.tsx +287 -0
- package/src/stories/Result.stories.tsx +145 -0
- package/src/stories/RollingNumber.stories.tsx +1 -1
- package/src/stories/Sidebar.stories.tsx +2 -0
- package/src/stories/SimpleGrid.stories.tsx +130 -0
- package/src/stories/Skeleton.stories.tsx +62 -1
- package/src/stories/Squircle.stories.tsx +127 -0
- package/src/stories/Stack.stories.tsx +140 -0
- package/src/stories/StatusBadge.stories.tsx +125 -0
- package/src/stories/Tabs.stories.tsx +56 -1
- package/src/stories/Tag.stories.tsx +31 -0
- package/src/stories/Textarea.stories.tsx +2 -0
- package/src/stories/ThemeIcon.stories.tsx +97 -0
- package/src/stories/Timeline.stories.tsx +69 -0
- package/src/stories/Tooltip.stories.tsx +18 -0
- package/src/stories/TreeSelect.stories.tsx +222 -0
- package/src/stories/YearPicker.stories.tsx +100 -0
- package/src/styles.css +289 -15
- package/src/tokens.json +96 -1
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FloatingIndicator — animated selection highlight that slides between nav/tab items.
|
|
3
|
+
*
|
|
4
|
+
* Implementation note: the indicator is a purely decorative, aria-hidden layer.
|
|
5
|
+
* All active-state ARIA (aria-selected, aria-current, data-state="active") belongs
|
|
6
|
+
* on the nav items themselves — FloatingIndicator provides only visual motion.
|
|
7
|
+
*
|
|
8
|
+
* Motion: token-driven var(--duration-base) + var(--ease-out) via inline style
|
|
9
|
+
* (explicit property list: left, top, width, height — never transition-all).
|
|
10
|
+
* Reduced-motion is handled automatically by the base-layer media query in styles.css.
|
|
11
|
+
*/
|
|
12
|
+
import * as React from "react";
|
|
13
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
14
|
+
import { cn } from "@behavioral-agentic-design-system/core/lib/utils";
|
|
15
|
+
import {
|
|
16
|
+
FloatingIndicator,
|
|
17
|
+
useFloatingIndicator,
|
|
18
|
+
} from "@behavioral-agentic-design-system/core/components/ui/floating-indicator";
|
|
19
|
+
|
|
20
|
+
// ─── Meta ─────────────────────────────────────────────────────────────────────
|
|
21
|
+
|
|
22
|
+
const meta: Meta<typeof FloatingIndicator> = {
|
|
23
|
+
title: "Components/FloatingIndicator",
|
|
24
|
+
component: FloatingIndicator,
|
|
25
|
+
parameters: {
|
|
26
|
+
layout: "centered",
|
|
27
|
+
docs: {
|
|
28
|
+
description: {
|
|
29
|
+
component:
|
|
30
|
+
"Animated selection highlight that slides between nav/tab items. Decorative aria-hidden layer — all active-state ARIA belongs on the nav items. Source: Mantine segmented-control pattern.",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
tags: ["autodocs"],
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default meta;
|
|
38
|
+
type Story = StoryObj<typeof meta>;
|
|
39
|
+
|
|
40
|
+
// ─── Default — three-tab bar (Jordan Reeves's workspace) ──────────────────────
|
|
41
|
+
|
|
42
|
+
const WORKSPACE_TABS = [
|
|
43
|
+
{ value: "dashboard", label: "Dashboard" },
|
|
44
|
+
{ value: "analytics", label: "Analytics" },
|
|
45
|
+
{ value: "settings", label: "Settings" },
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
function TabBarDemo() {
|
|
49
|
+
const [active, setActive] = React.useState(0);
|
|
50
|
+
const containerRef = React.useRef<HTMLDivElement>(null);
|
|
51
|
+
const itemRefs = React.useRef<(HTMLButtonElement | null)[]>([]);
|
|
52
|
+
const [target, setTarget] = React.useState<HTMLElement | null>(null);
|
|
53
|
+
|
|
54
|
+
// Sync target with active index on mount and when index changes
|
|
55
|
+
React.useEffect(() => {
|
|
56
|
+
setTarget(itemRefs.current[active] ?? null);
|
|
57
|
+
}, [active]);
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<div className="space-y-4 w-[380px]">
|
|
61
|
+
<p className="text-xs text-muted-foreground">
|
|
62
|
+
Jordan Reeves · Watershed Analytics workspace
|
|
63
|
+
</p>
|
|
64
|
+
<div
|
|
65
|
+
ref={containerRef}
|
|
66
|
+
role="tablist"
|
|
67
|
+
aria-label="Workspace sections"
|
|
68
|
+
className="relative inline-flex rounded-lg bg-muted p-1 gap-0.5"
|
|
69
|
+
>
|
|
70
|
+
<FloatingIndicator
|
|
71
|
+
target={target}
|
|
72
|
+
parent={containerRef.current}
|
|
73
|
+
className="bg-background shadow-sm rounded-md"
|
|
74
|
+
/>
|
|
75
|
+
{WORKSPACE_TABS.map((tab, i) => (
|
|
76
|
+
<button
|
|
77
|
+
key={tab.value}
|
|
78
|
+
ref={(el) => {
|
|
79
|
+
itemRefs.current[i] = el;
|
|
80
|
+
}}
|
|
81
|
+
role="tab"
|
|
82
|
+
aria-selected={active === i}
|
|
83
|
+
onClick={() => setActive(i)}
|
|
84
|
+
className={cn(
|
|
85
|
+
"relative z-10 px-3 py-1.5 text-sm font-medium rounded-md transition-colors",
|
|
86
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
87
|
+
active === i
|
|
88
|
+
? "text-foreground"
|
|
89
|
+
: "text-muted-foreground hover:text-foreground"
|
|
90
|
+
)}
|
|
91
|
+
>
|
|
92
|
+
{tab.label}
|
|
93
|
+
</button>
|
|
94
|
+
))}
|
|
95
|
+
</div>
|
|
96
|
+
<p className="text-xs text-muted-foreground">
|
|
97
|
+
Active: <span className="font-medium text-foreground">{WORKSPACE_TABS[active].label}</span>
|
|
98
|
+
</p>
|
|
99
|
+
</div>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export const Default: Story = {
|
|
104
|
+
render: () => <TabBarDemo />,
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
// ─── PillNav — horizontal pill navigation ─────────────────────────────────────
|
|
108
|
+
|
|
109
|
+
const PILL_NAV_ITEMS = [
|
|
110
|
+
{ value: "overview", label: "Overview" },
|
|
111
|
+
{ value: "components", label: "Components" },
|
|
112
|
+
{ value: "tokens", label: "Tokens" },
|
|
113
|
+
{ value: "docs", label: "Docs" },
|
|
114
|
+
];
|
|
115
|
+
|
|
116
|
+
function PillNavDemo() {
|
|
117
|
+
const [active, setActive] = React.useState(0);
|
|
118
|
+
const containerRef = React.useRef<HTMLDivElement>(null);
|
|
119
|
+
const itemRefs = React.useRef<(HTMLButtonElement | null)[]>([]);
|
|
120
|
+
const [target, setTarget] = React.useState<HTMLElement | null>(null);
|
|
121
|
+
|
|
122
|
+
React.useEffect(() => {
|
|
123
|
+
setTarget(itemRefs.current[active] ?? null);
|
|
124
|
+
}, [active]);
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<div className="space-y-4 w-[420px]">
|
|
128
|
+
<p className="text-xs text-muted-foreground">Pill-style navigation — rounded-full items</p>
|
|
129
|
+
<div
|
|
130
|
+
ref={containerRef}
|
|
131
|
+
role="navigation"
|
|
132
|
+
aria-label="Section navigation"
|
|
133
|
+
className="relative inline-flex gap-1 bg-transparent"
|
|
134
|
+
>
|
|
135
|
+
{/* Pill indicator: rounded-full matches the item shape */}
|
|
136
|
+
<FloatingIndicator
|
|
137
|
+
target={target}
|
|
138
|
+
parent={containerRef.current}
|
|
139
|
+
className="bg-primary/10 rounded-full shadow-none"
|
|
140
|
+
/>
|
|
141
|
+
{PILL_NAV_ITEMS.map((item, i) => (
|
|
142
|
+
<button
|
|
143
|
+
key={item.value}
|
|
144
|
+
ref={(el) => {
|
|
145
|
+
itemRefs.current[i] = el;
|
|
146
|
+
}}
|
|
147
|
+
onClick={() => setActive(i)}
|
|
148
|
+
aria-current={active === i ? "page" : undefined}
|
|
149
|
+
className={cn(
|
|
150
|
+
"relative z-10 px-4 py-2 text-sm font-medium rounded-full transition-colors",
|
|
151
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
152
|
+
active === i
|
|
153
|
+
? "text-primary"
|
|
154
|
+
: "text-muted-foreground hover:text-foreground"
|
|
155
|
+
)}
|
|
156
|
+
>
|
|
157
|
+
{item.label}
|
|
158
|
+
</button>
|
|
159
|
+
))}
|
|
160
|
+
</div>
|
|
161
|
+
</div>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export const PillNav: Story = {
|
|
166
|
+
render: () => <PillNavDemo />,
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
// ─── VerticalNav — sidebar navigation sliding indicator ───────────────────────
|
|
170
|
+
|
|
171
|
+
const SIDEBAR_NAV = [
|
|
172
|
+
{ value: "portfolio", label: "Portfolio" },
|
|
173
|
+
{ value: "clients", label: "Clients" },
|
|
174
|
+
{ value: "projects", label: "Projects" },
|
|
175
|
+
{ value: "reports", label: "Reports" },
|
|
176
|
+
{ value: "settings", label: "Settings" },
|
|
177
|
+
];
|
|
178
|
+
|
|
179
|
+
function VerticalNavDemo() {
|
|
180
|
+
const [active, setActive] = React.useState(0);
|
|
181
|
+
const containerRef = React.useRef<HTMLDivElement>(null);
|
|
182
|
+
const itemRefs = React.useRef<(HTMLButtonElement | null)[]>([]);
|
|
183
|
+
const [target, setTarget] = React.useState<HTMLElement | null>(null);
|
|
184
|
+
|
|
185
|
+
React.useEffect(() => {
|
|
186
|
+
setTarget(itemRefs.current[active] ?? null);
|
|
187
|
+
}, [active]);
|
|
188
|
+
|
|
189
|
+
return (
|
|
190
|
+
<div className="flex gap-6 w-[360px]">
|
|
191
|
+
<nav aria-label="Design system sections" className="w-40">
|
|
192
|
+
<div
|
|
193
|
+
ref={containerRef}
|
|
194
|
+
className="relative flex flex-col gap-0.5"
|
|
195
|
+
>
|
|
196
|
+
<FloatingIndicator
|
|
197
|
+
target={target}
|
|
198
|
+
parent={containerRef.current}
|
|
199
|
+
className="bg-muted rounded-md shadow-none"
|
|
200
|
+
/>
|
|
201
|
+
{SIDEBAR_NAV.map((item, i) => (
|
|
202
|
+
<button
|
|
203
|
+
key={item.value}
|
|
204
|
+
ref={(el) => {
|
|
205
|
+
itemRefs.current[i] = el;
|
|
206
|
+
}}
|
|
207
|
+
onClick={() => setActive(i)}
|
|
208
|
+
aria-current={active === i ? "page" : undefined}
|
|
209
|
+
className={cn(
|
|
210
|
+
"relative z-10 w-full text-left px-3 py-2 text-sm font-medium rounded-md transition-colors",
|
|
211
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
212
|
+
active === i
|
|
213
|
+
? "text-foreground"
|
|
214
|
+
: "text-muted-foreground hover:text-foreground"
|
|
215
|
+
)}
|
|
216
|
+
>
|
|
217
|
+
{item.label}
|
|
218
|
+
</button>
|
|
219
|
+
))}
|
|
220
|
+
</div>
|
|
221
|
+
</nav>
|
|
222
|
+
<div className="flex-1 pt-1">
|
|
223
|
+
<p className="text-xs text-muted-foreground mb-1">Active section</p>
|
|
224
|
+
<p className="text-sm font-medium">{SIDEBAR_NAV[active].label}</p>
|
|
225
|
+
</div>
|
|
226
|
+
</div>
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export const VerticalNav: Story = {
|
|
231
|
+
render: () => <VerticalNavDemo />,
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
// ─── RealisticUse — segmented control with content ────────────────────────────
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Complete segmented control pattern: FloatingIndicator powers the sliding
|
|
238
|
+
* highlight inside a custom nav bar, with real content below each tab.
|
|
239
|
+
* Demonstrates the useFloatingIndicator hook for integrated state management.
|
|
240
|
+
*/
|
|
241
|
+
|
|
242
|
+
const DASHBOARD_TABS = [
|
|
243
|
+
{ value: "dashboard", label: "Dashboard" },
|
|
244
|
+
{ value: "analytics", label: "Analytics" },
|
|
245
|
+
{ value: "settings", label: "Settings" },
|
|
246
|
+
];
|
|
247
|
+
|
|
248
|
+
const DASHBOARD_CONTENT: Record<string, React.ReactNode> = {
|
|
249
|
+
dashboard: (
|
|
250
|
+
<div className="space-y-2">
|
|
251
|
+
<p className="text-sm font-medium text-foreground">Active projects — Seo-yun Park</p>
|
|
252
|
+
<p className="text-sm text-muted-foreground">
|
|
253
|
+
Watershed Analytics Q3 · On track · 12 components shipped
|
|
254
|
+
</p>
|
|
255
|
+
<p className="text-sm text-muted-foreground">
|
|
256
|
+
Civic Design System · In review · 4 tokens pending approval
|
|
257
|
+
</p>
|
|
258
|
+
</div>
|
|
259
|
+
),
|
|
260
|
+
analytics: (
|
|
261
|
+
<div className="space-y-2">
|
|
262
|
+
<p className="text-sm font-medium text-foreground">Usage metrics · Last 30 days</p>
|
|
263
|
+
<p className="text-sm text-muted-foreground">
|
|
264
|
+
Component renders: <span className="font-medium text-foreground">142,800</span>
|
|
265
|
+
</p>
|
|
266
|
+
<p className="text-sm text-muted-foreground">
|
|
267
|
+
Token overrides applied: <span className="font-medium text-foreground">2,340</span>
|
|
268
|
+
</p>
|
|
269
|
+
</div>
|
|
270
|
+
),
|
|
271
|
+
settings: (
|
|
272
|
+
<div className="space-y-2">
|
|
273
|
+
<p className="text-sm font-medium text-foreground">Workspace settings — Jordan Reeves</p>
|
|
274
|
+
<p className="text-sm text-muted-foreground">
|
|
275
|
+
Brand: Watershed Analytics · Slug: watershed
|
|
276
|
+
</p>
|
|
277
|
+
<p className="text-sm text-muted-foreground">
|
|
278
|
+
Theme: System default · AAA audit: passing (78/78 pairs)
|
|
279
|
+
</p>
|
|
280
|
+
</div>
|
|
281
|
+
),
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
function RealisticUseDemo() {
|
|
285
|
+
const [active, setActive] = React.useState(0);
|
|
286
|
+
const containerRef = React.useRef<HTMLDivElement>(null);
|
|
287
|
+
const { target, setTarget } = useFloatingIndicator(containerRef);
|
|
288
|
+
const itemRefs = React.useRef<(HTMLButtonElement | null)[]>([]);
|
|
289
|
+
|
|
290
|
+
React.useEffect(() => {
|
|
291
|
+
setTarget(itemRefs.current[active] ?? null);
|
|
292
|
+
}, [active]);
|
|
293
|
+
|
|
294
|
+
return (
|
|
295
|
+
<div className="w-[440px] space-y-4">
|
|
296
|
+
<div className="rounded-xl border border-border bg-card shadow-sm">
|
|
297
|
+
{/* Custom segmented nav bar */}
|
|
298
|
+
<div className="border-b border-border px-4 pt-4 pb-0">
|
|
299
|
+
<div
|
|
300
|
+
ref={containerRef}
|
|
301
|
+
role="tablist"
|
|
302
|
+
aria-label="Dashboard sections"
|
|
303
|
+
className="relative inline-flex gap-0 border-b-0"
|
|
304
|
+
>
|
|
305
|
+
<FloatingIndicator
|
|
306
|
+
target={target}
|
|
307
|
+
parent={containerRef.current}
|
|
308
|
+
className="rounded-t-md rounded-b-none bg-background shadow-none border border-b-0 border-border"
|
|
309
|
+
/>
|
|
310
|
+
{DASHBOARD_TABS.map((tab, i) => (
|
|
311
|
+
<button
|
|
312
|
+
key={tab.value}
|
|
313
|
+
ref={(el) => {
|
|
314
|
+
itemRefs.current[i] = el;
|
|
315
|
+
}}
|
|
316
|
+
role="tab"
|
|
317
|
+
aria-selected={active === i}
|
|
318
|
+
onClick={() => setActive(i)}
|
|
319
|
+
className={cn(
|
|
320
|
+
"relative z-10 px-4 py-2.5 text-sm font-medium transition-colors",
|
|
321
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 rounded-sm",
|
|
322
|
+
active === i
|
|
323
|
+
? "text-foreground"
|
|
324
|
+
: "text-muted-foreground hover:text-foreground"
|
|
325
|
+
)}
|
|
326
|
+
>
|
|
327
|
+
{tab.label}
|
|
328
|
+
</button>
|
|
329
|
+
))}
|
|
330
|
+
</div>
|
|
331
|
+
</div>
|
|
332
|
+
{/* Tab content */}
|
|
333
|
+
<div className="p-4">
|
|
334
|
+
{DASHBOARD_CONTENT[DASHBOARD_TABS[active].value]}
|
|
335
|
+
</div>
|
|
336
|
+
</div>
|
|
337
|
+
</div>
|
|
338
|
+
);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export const RealisticUse: Story = {
|
|
342
|
+
render: () => <RealisticUseDemo />,
|
|
343
|
+
};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
3
|
+
import { FileArchiveIcon, FileCodeIcon, FileTextIcon } from "lucide-react"
|
|
4
|
+
import { FormatByte } from "@behavioral-agentic-design-system/core/components/ui/format-byte"
|
|
5
|
+
import {
|
|
6
|
+
Card,
|
|
7
|
+
CardContent,
|
|
8
|
+
CardDescription,
|
|
9
|
+
CardHeader,
|
|
10
|
+
CardTitle,
|
|
11
|
+
} from "@behavioral-agentic-design-system/core/components/ui/card"
|
|
12
|
+
|
|
13
|
+
const meta: Meta<typeof FormatByte> = {
|
|
14
|
+
title: "Components/FormatByte",
|
|
15
|
+
component: FormatByte,
|
|
16
|
+
parameters: { layout: "centered" },
|
|
17
|
+
tags: ["autodocs"],
|
|
18
|
+
argTypes: {
|
|
19
|
+
value: { control: "number" },
|
|
20
|
+
precision: { control: "number" },
|
|
21
|
+
locale: { control: "text" },
|
|
22
|
+
tabular: { control: "boolean" },
|
|
23
|
+
},
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default meta
|
|
27
|
+
type Story = StoryObj<typeof meta>
|
|
28
|
+
|
|
29
|
+
// All file names and byte counts come from content/personas/bads.json →
|
|
30
|
+
// primary.files (real-content rule — the pool grew these entries before this
|
|
31
|
+
// story used them). Scale is SI (base-1000, KB/MB/GB), matching Mantine and
|
|
32
|
+
// Chakra defaults and what OS file managers report — not IEC base-1024.
|
|
33
|
+
|
|
34
|
+
export const Default: Story = {
|
|
35
|
+
render: () => (
|
|
36
|
+
<p className="text-sm text-foreground">
|
|
37
|
+
roi-report-2026-06.pdf —{" "}
|
|
38
|
+
<FormatByte value={1536000} className="font-medium" />
|
|
39
|
+
</p>
|
|
40
|
+
),
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const Size_Bytes: Story = {
|
|
44
|
+
render: () => (
|
|
45
|
+
<p className="text-sm text-foreground">
|
|
46
|
+
favicon.svg — <FormatByte value={500} className="font-medium" />
|
|
47
|
+
</p>
|
|
48
|
+
),
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const Size_KB: Story = {
|
|
52
|
+
render: () => (
|
|
53
|
+
<p className="text-sm text-foreground">
|
|
54
|
+
Icon sprite chunk — <FormatByte value={2048} className="font-medium" />
|
|
55
|
+
</p>
|
|
56
|
+
),
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const Size_GB: Story = {
|
|
60
|
+
render: () => (
|
|
61
|
+
<p className="text-sm text-foreground">
|
|
62
|
+
chromatic-snapshots-2026-06.zip —{" "}
|
|
63
|
+
<FormatByte value={1_073_741_824} className="font-medium" />
|
|
64
|
+
</p>
|
|
65
|
+
),
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export const Precision_Zero: Story = {
|
|
69
|
+
render: () => (
|
|
70
|
+
<div className="space-y-2 text-sm text-foreground">
|
|
71
|
+
<p>
|
|
72
|
+
Default precision (1):{" "}
|
|
73
|
+
<FormatByte value={1536000} className="font-medium" />
|
|
74
|
+
</p>
|
|
75
|
+
<p>
|
|
76
|
+
precision={"{0}"}:{" "}
|
|
77
|
+
<FormatByte value={1536000} precision={0} className="font-medium" />
|
|
78
|
+
</p>
|
|
79
|
+
<p className="text-xs text-muted-foreground">
|
|
80
|
+
Scaled output rounds, so the exact byte count rides the native title
|
|
81
|
+
attribute — hover either size to recover “1,536,000 bytes”.
|
|
82
|
+
</p>
|
|
83
|
+
</div>
|
|
84
|
+
),
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export const RealisticUse: Story = {
|
|
88
|
+
render: () => (
|
|
89
|
+
<Card className="w-96">
|
|
90
|
+
<CardHeader>
|
|
91
|
+
<CardTitle>Engagement deliverables</CardTitle>
|
|
92
|
+
<CardDescription>
|
|
93
|
+
Files shared with the Austin design systems team this quarter.
|
|
94
|
+
</CardDescription>
|
|
95
|
+
</CardHeader>
|
|
96
|
+
<CardContent>
|
|
97
|
+
<ul className="divide-y divide-border">
|
|
98
|
+
{[
|
|
99
|
+
{
|
|
100
|
+
icon: FileTextIcon,
|
|
101
|
+
name: "roi-report-2026-06.pdf",
|
|
102
|
+
bytes: 1536000,
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
icon: FileCodeIcon,
|
|
106
|
+
name: "styles.css",
|
|
107
|
+
bytes: 42700,
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
icon: FileCodeIcon,
|
|
111
|
+
name: "brand-fonts.woff2",
|
|
112
|
+
bytes: 84512,
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
icon: FileArchiveIcon,
|
|
116
|
+
name: "chromatic-snapshots-2026-06.zip",
|
|
117
|
+
bytes: 1073741824,
|
|
118
|
+
},
|
|
119
|
+
].map((file) => (
|
|
120
|
+
<li key={file.name} className="flex items-center gap-3 py-2">
|
|
121
|
+
<file.icon
|
|
122
|
+
strokeWidth={1.5}
|
|
123
|
+
className="size-4 shrink-0 text-muted-foreground"
|
|
124
|
+
aria-hidden="true"
|
|
125
|
+
/>
|
|
126
|
+
<span
|
|
127
|
+
className="min-w-0 flex-1 truncate text-sm text-foreground"
|
|
128
|
+
title={file.name}
|
|
129
|
+
>
|
|
130
|
+
{file.name}
|
|
131
|
+
</span>
|
|
132
|
+
<FormatByte
|
|
133
|
+
value={file.bytes}
|
|
134
|
+
className="shrink-0 text-sm text-muted-foreground"
|
|
135
|
+
/>
|
|
136
|
+
</li>
|
|
137
|
+
))}
|
|
138
|
+
</ul>
|
|
139
|
+
</CardContent>
|
|
140
|
+
</Card>
|
|
141
|
+
),
|
|
142
|
+
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
// Input itself is server-renderable: it attaches no handler of its own and only
|
|
2
|
+
// forwards the caller's onChange. The clear affordance is the client half, split
|
|
3
|
+
// into components/ui/input-clear-button.tsx — see the Clearable stories below.
|
|
1
4
|
import * as React from "react";
|
|
2
5
|
import { Meta, StoryObj } from "@storybook/react";
|
|
6
|
+
import { CalendarIcon, MailIcon, SearchIcon } from "lucide-react";
|
|
3
7
|
import { Input } from "@behavioral-agentic-design-system/core/components/ui/input";
|
|
4
8
|
|
|
5
9
|
const meta: Meta<typeof Input> = {
|
|
@@ -62,7 +66,97 @@ export const WithError: Story = {
|
|
|
62
66
|
},
|
|
63
67
|
};
|
|
64
68
|
|
|
69
|
+
export const Variant_WithLeftIcon: Story = {
|
|
70
|
+
name: "Variant: With left icon",
|
|
71
|
+
args: {
|
|
72
|
+
type: "search",
|
|
73
|
+
placeholder: "Search users…",
|
|
74
|
+
"aria-label": "Search users",
|
|
75
|
+
leftSection: <SearchIcon size={16} strokeWidth={1.5} aria-hidden="true" />,
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const Variant_WithRightIcon: Story = {
|
|
80
|
+
name: "Variant: With right icon",
|
|
81
|
+
args: {
|
|
82
|
+
placeholder: "Due date",
|
|
83
|
+
"aria-label": "Due date",
|
|
84
|
+
rightSection: <CalendarIcon size={16} strokeWidth={1.5} aria-hidden="true" />,
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export const Variant_WithBothSections: Story = {
|
|
89
|
+
name: "Variant: With both sections",
|
|
90
|
+
args: {
|
|
91
|
+
type: "email",
|
|
92
|
+
placeholder: "amara.okafor@lumenworks.studio",
|
|
93
|
+
"aria-label": "Work email",
|
|
94
|
+
leftSection: <MailIcon size={16} strokeWidth={1.5} aria-hidden="true" />,
|
|
95
|
+
rightSection: (
|
|
96
|
+
<span className="text-sm" aria-hidden="true">
|
|
97
|
+
.com
|
|
98
|
+
</span>
|
|
99
|
+
),
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const Variant_WithRightText: Story = {
|
|
104
|
+
name: "Variant: With text sections (currency, percent)",
|
|
105
|
+
render: () => (
|
|
106
|
+
<div className="flex w-72 flex-col gap-4">
|
|
107
|
+
<Input
|
|
108
|
+
type="number"
|
|
109
|
+
inputMode="decimal"
|
|
110
|
+
placeholder="1,250.00"
|
|
111
|
+
aria-label="Amount"
|
|
112
|
+
leftSection={
|
|
113
|
+
<span className="text-sm" aria-hidden="true">
|
|
114
|
+
$
|
|
115
|
+
</span>
|
|
116
|
+
}
|
|
117
|
+
rightSection={
|
|
118
|
+
<span className="text-sm" aria-hidden="true">
|
|
119
|
+
USD
|
|
120
|
+
</span>
|
|
121
|
+
}
|
|
122
|
+
/>
|
|
123
|
+
<Input
|
|
124
|
+
type="number"
|
|
125
|
+
inputMode="decimal"
|
|
126
|
+
placeholder="7.5"
|
|
127
|
+
aria-label="Interest rate"
|
|
128
|
+
rightSection={
|
|
129
|
+
<span className="text-sm" aria-hidden="true">
|
|
130
|
+
%
|
|
131
|
+
</span>
|
|
132
|
+
}
|
|
133
|
+
/>
|
|
134
|
+
</div>
|
|
135
|
+
),
|
|
136
|
+
};
|
|
137
|
+
|
|
65
138
|
export const RealisticUse: Story = {
|
|
139
|
+
name: "Realistic use: search with clear",
|
|
140
|
+
render: () => {
|
|
141
|
+
const [value, setValue] = React.useState("design tokens");
|
|
142
|
+
return (
|
|
143
|
+
<div className="w-72">
|
|
144
|
+
<Input
|
|
145
|
+
type="search"
|
|
146
|
+
aria-label="Search users"
|
|
147
|
+
placeholder="Search users…"
|
|
148
|
+
value={value}
|
|
149
|
+
onChange={(e) => setValue(e.target.value)}
|
|
150
|
+
clearable
|
|
151
|
+
leftSection={<SearchIcon size={16} strokeWidth={1.5} aria-hidden="true" />}
|
|
152
|
+
/>
|
|
153
|
+
</div>
|
|
154
|
+
);
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export const RealisticUse_Email: Story = {
|
|
159
|
+
name: "Realistic use: email field",
|
|
66
160
|
args: {
|
|
67
161
|
type: "email",
|
|
68
162
|
placeholder: "your@email.com",
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// The client half of Input's clearable affordance. It lives in its own module so
|
|
2
|
+
// that a plain <Input /> stays renderable from a React Server Component and
|
|
3
|
+
// costs a consumer nothing on the client — only <Input clearable /> pulls this
|
|
4
|
+
// in. Storied separately so visual regression covers the button on its own,
|
|
5
|
+
// including the offset variant used when Input also has a rightSection.
|
|
6
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
7
|
+
import { InputClearButton } from "@behavioral-agentic-design-system/core/components/ui/input-clear-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 InputClearButton> = {
|
|
12
|
+
title: "Components/InputClearButton",
|
|
13
|
+
component: InputClearButton,
|
|
14
|
+
parameters: { layout: "centered" },
|
|
15
|
+
tags: ["autodocs"],
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default meta;
|
|
19
|
+
type Story = StoryObj<typeof meta>;
|
|
20
|
+
|
|
21
|
+
export const Default: Story = {
|
|
22
|
+
render: () => (
|
|
23
|
+
// Positioned absolutely against its input, so it needs a relative box to
|
|
24
|
+
// sit in even when shown in isolation.
|
|
25
|
+
<div className="relative h-9 w-[240px] rounded-md border border-input">
|
|
26
|
+
<InputClearButton className="right-1.5" />
|
|
27
|
+
</div>
|
|
28
|
+
),
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const OffsetForRightSection: Story = {
|
|
32
|
+
name: "Offset (input has a rightSection)",
|
|
33
|
+
render: () => (
|
|
34
|
+
<div className="relative h-9 w-[240px] rounded-md border border-input">
|
|
35
|
+
<InputClearButton className="right-8" />
|
|
36
|
+
<span className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3 text-sm text-muted-foreground">
|
|
37
|
+
USD
|
|
38
|
+
</span>
|
|
39
|
+
</div>
|
|
40
|
+
),
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const RealisticUse: Story = {
|
|
44
|
+
render: () => (
|
|
45
|
+
<div className="flex w-[320px] flex-col gap-3">
|
|
46
|
+
<Label htmlFor="search-city">Search by city</Label>
|
|
47
|
+
<Input id="search-city" clearable value="Nashville, TN" readOnly />
|
|
48
|
+
<p className="text-sm text-muted-foreground">
|
|
49
|
+
The clear button appears once the field has a value.
|
|
50
|
+
</p>
|
|
51
|
+
</div>
|
|
52
|
+
),
|
|
53
|
+
};
|