@behavioral-agentic-design-system/core 0.40.0 → 0.45.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.
Files changed (148) hide show
  1. package/README.md +2 -0
  2. package/package.json +41 -9
  3. package/scripts/a11y-lint.cjs +66 -3
  4. package/scripts/check-spec.mjs +73 -0
  5. package/scripts/deal-directions.mjs +186 -0
  6. package/scripts/health-report.mjs +23 -3
  7. package/scripts/lib/counted-lint.mjs +100 -0
  8. package/scripts/lib/marketing-library.mjs +129 -0
  9. package/scripts/lib/on-system.mjs +249 -0
  10. package/scripts/lib/random.mjs +22 -0
  11. package/scripts/lib/spec-parse.d.mts +25 -0
  12. package/scripts/lib/spec-parse.mjs +188 -0
  13. package/scripts/lib/tells.mjs +128 -0
  14. package/scripts/lint-css-vars.mjs +175 -0
  15. package/scripts/lint-html-nesting.mjs +116 -0
  16. package/scripts/lint-live-ctas.mjs +138 -0
  17. package/scripts/lint-slop.mjs +25 -1
  18. package/scripts/on-system-score.mjs +95 -0
  19. package/scripts/slop-rules.mjs +1 -1
  20. package/scripts/source-images.mjs +180 -0
  21. package/scripts/ux-tells.mjs +78 -0
  22. package/scripts/wcag-audit.cjs +72 -5
  23. package/src/api/brand-colors.ts +3 -0
  24. package/src/api/brand-fonts.ts +3 -0
  25. package/src/api/brand-mark.ts +6 -1
  26. package/src/api/dev-write-guard.ts +53 -0
  27. package/src/api/layers/file.ts +7 -4
  28. package/src/api/onboarding-extract.ts +85 -30
  29. package/src/api/onboarding.ts +3 -0
  30. package/src/api/save-tokens.ts +3 -0
  31. package/src/app/layout.tsx +6 -0
  32. package/src/app/opengraph-image.tsx +5 -0
  33. package/src/app/preview/canvas/page.tsx +12 -0
  34. package/src/app/preview/components/page.tsx +2003 -2
  35. package/src/app/preview/studio/blank-screen.tsx +143 -0
  36. package/src/app/preview/studio/page.tsx +7 -0
  37. package/src/app/shell.tsx +168 -49
  38. package/src/components/Foundations/Motion.stories.tsx +1 -0
  39. package/src/components/canvas/canvas.tsx +458 -0
  40. package/src/components/canvas/layout.ts +72 -0
  41. package/src/components/canvas/parse-canvas.ts +32 -0
  42. package/src/components/canvas/sample.ts +90 -0
  43. package/src/components/canvas/spec-frame.tsx +43 -0
  44. package/src/components/canvas/types.ts +33 -0
  45. package/src/components/customize/design-controls.tsx +16 -1
  46. package/src/components/docs-tab.tsx +7 -7
  47. package/src/components/home-recent.tsx +73 -0
  48. package/src/components/home-tab.tsx +13 -13
  49. package/src/components/layers-tab.tsx +2 -2
  50. package/src/components/markdown-preview.tsx +60 -12
  51. package/src/components/studio/control-panel.tsx +299 -0
  52. package/src/components/studio/control-row.tsx +77 -0
  53. package/src/components/studio/preview-frame.tsx +165 -0
  54. package/src/components/studio/preview-pane.tsx +247 -0
  55. package/src/components/studio/studio.tsx +158 -0
  56. package/src/components/studio/types.ts +218 -0
  57. package/src/components/studio/use-studio-tweaks.ts +128 -0
  58. package/src/components/studio/use-studio-view-state.ts +72 -0
  59. package/src/components/ui/anchor.tsx +37 -3
  60. package/src/components/ui/attachment.tsx +211 -0
  61. package/src/components/ui/autocomplete.tsx +1 -1
  62. package/src/components/ui/chart.tsx +3 -0
  63. package/src/components/ui/code.tsx +1 -1
  64. package/src/components/ui/color-picker.tsx +21 -5
  65. package/src/components/ui/data-table.tsx +64 -3
  66. package/src/components/ui/date-field.tsx +1 -1
  67. package/src/components/ui/editable.tsx +1 -0
  68. package/src/components/ui/faceted-filter.tsx +187 -0
  69. package/src/components/ui/gauge-chart.tsx +252 -0
  70. package/src/components/ui/heatmap.tsx +256 -0
  71. package/src/components/ui/index.ts +9 -0
  72. package/src/components/ui/infinite-scroll.tsx +103 -0
  73. package/src/components/ui/inline-edit.tsx +175 -0
  74. package/src/components/ui/json-input.tsx +351 -0
  75. package/src/components/ui/month-picker.tsx +1 -1
  76. package/src/components/ui/navigation-progress.tsx +281 -0
  77. package/src/components/ui/number-input.tsx +27 -7
  78. package/src/components/ui/otp-input.tsx +208 -0
  79. package/src/components/ui/password-input.tsx +2 -1
  80. package/src/components/ui/password-strength-input.tsx +288 -0
  81. package/src/components/ui/phone-input.tsx +274 -0
  82. package/src/components/ui/pill.tsx +140 -0
  83. package/src/components/ui/popover.tsx +27 -4
  84. package/src/components/ui/scroll-progress.tsx +100 -0
  85. package/src/components/ui/search-input.tsx +1 -1
  86. package/src/components/ui/snackbar.tsx +393 -0
  87. package/src/components/ui/sortable-list.tsx +342 -0
  88. package/src/components/ui/squircle.tsx +1 -1
  89. package/src/components/ui/table.tsx +1 -1
  90. package/src/components/ui/tags-input.tsx +1 -1
  91. package/src/components/ui/timer.tsx +1 -0
  92. package/src/components/ui/tour.tsx +1 -3
  93. package/src/components/ui/transfer-list.tsx +13 -26
  94. package/src/components/ui/week-picker.tsx +1 -1
  95. package/src/components/ui/year-picker.tsx +1 -1
  96. package/src/data/component-added.json +958 -0
  97. package/src/data/docs-index.ts +36 -0
  98. package/src/hooks/use-global-mono-font.ts +1 -0
  99. package/src/hooks/use-global-primary-color.ts +1 -0
  100. package/src/hooks/use-global-sans-font.ts +1 -0
  101. package/src/hooks/use-global-serif-font.ts +1 -0
  102. package/src/hooks/use-global-type-scale.ts +17 -2
  103. package/src/hooks/use-mobile.ts +2 -0
  104. package/src/hooks/use-sync-type-scale.ts +7 -11
  105. package/src/lib/clamp.ts +2 -0
  106. package/src/lib/spec-parse.ts +4 -0
  107. package/src/lib/svg-sanitize.ts +19 -9
  108. package/src/stories/Anchor.stories.tsx +54 -0
  109. package/src/stories/Attachment.stories.tsx +189 -0
  110. package/src/stories/Autocomplete.stories.tsx +2 -0
  111. package/src/stories/Canvas.stories.tsx +45 -0
  112. package/src/stories/Chart.stories.tsx +4 -0
  113. package/src/stories/Code.stories.tsx +1 -0
  114. package/src/stories/ColorPicker.stories.tsx +41 -0
  115. package/src/stories/DataTable.stories.tsx +30 -0
  116. package/src/stories/DateField.stories.tsx +21 -0
  117. package/src/stories/Editable.stories.tsx +2 -0
  118. package/src/stories/FacetedFilter.stories.tsx +197 -0
  119. package/src/stories/GaugeChart.stories.tsx +169 -0
  120. package/src/stories/Heatmap.stories.tsx +172 -0
  121. package/src/stories/InfiniteScroll.stories.tsx +225 -0
  122. package/src/stories/InlineEdit.stories.tsx +106 -0
  123. package/src/stories/JsonInput.stories.tsx +212 -0
  124. package/src/stories/MarkdownPreview.stories.tsx +53 -0
  125. package/src/stories/MonthPicker.stories.tsx +21 -0
  126. package/src/stories/NavigationProgress.stories.tsx +159 -0
  127. package/src/stories/NumberInput.stories.tsx +26 -0
  128. package/src/stories/OtpInput.stories.tsx +110 -0
  129. package/src/stories/PasswordInput.stories.tsx +4 -0
  130. package/src/stories/PasswordStrengthInput.stories.tsx +211 -0
  131. package/src/stories/PhoneInput.stories.tsx +127 -0
  132. package/src/stories/Pill.stories.tsx +201 -0
  133. package/src/stories/Popover.stories.tsx +29 -1
  134. package/src/stories/Portal.stories.tsx +3 -1
  135. package/src/stories/ScrollProgress.stories.tsx +117 -0
  136. package/src/stories/SearchInput.stories.tsx +2 -0
  137. package/src/stories/Snackbar.stories.tsx +315 -0
  138. package/src/stories/SortableList.stories.tsx +263 -0
  139. package/src/stories/Squircle.stories.tsx +1 -0
  140. package/src/stories/Table.stories.tsx +1 -0
  141. package/src/stories/TagsInput.stories.tsx +2 -0
  142. package/src/stories/Timer.stories.tsx +26 -0
  143. package/src/stories/Tour.stories.tsx +1 -0
  144. package/src/stories/TransferList.stories.tsx +4 -0
  145. package/src/stories/WeekPicker.stories.tsx +21 -0
  146. package/src/stories/YearPicker.stories.tsx +21 -0
  147. package/src/stories/story-groups.json +33 -16
  148. package/src/tokens.json +82 -54
@@ -0,0 +1,315 @@
1
+ import * as React from "react"
2
+ import type { Meta, StoryObj } from "@storybook/react"
3
+ import { userEvent, within, expect } from "storybook/test"
4
+ import { Archive, CircleCheck, Link2, Send } from "lucide-react"
5
+
6
+ import {
7
+ SnackbarProvider,
8
+ useSnackbar,
9
+ SNACKBAR_ANCHORS,
10
+ type SnackbarOptions,
11
+ } from "@behavioral-agentic-design-system/core/components/ui/snackbar"
12
+ import { Button } from "@behavioral-agentic-design-system/core/components/ui/button"
13
+
14
+ const meta: Meta<typeof SnackbarProvider> = {
15
+ title: "Components/Feedback/Snackbar",
16
+ component: SnackbarProvider,
17
+ // The outlet is position: fixed at the bottom of the viewport, so the
18
+ // story needs the whole canvas, not a centered box.
19
+ parameters: {
20
+ layout: "fullscreen",
21
+ docs: {
22
+ description: {
23
+ component:
24
+ "One transient feedback message at a time, anchored to the bottom of the screen, that auto-dismisses. Imperative API: `const { show, dismiss } = useSnackbar()` inside a `<SnackbarProvider>`. The next message queues behind the current one — nothing stacks. Use Sonner for a stacked queue of async events; use Snackbar for lightweight confirmations of something the user just did (copied, saved, moved · Undo). The timer pauses on hover and focus-within; a sticky message (`duration: Infinity`) is always dismissible; the live region is mounted before the first message so screen readers announce it.",
25
+ },
26
+ },
27
+ },
28
+ tags: ["autodocs"],
29
+ argTypes: {
30
+ anchor: { control: "select", options: [...SNACKBAR_ANCHORS] },
31
+ duration: { control: { type: "number", min: 500, step: 500 } },
32
+ container: { control: false },
33
+ children: { control: false },
34
+ className: { control: false },
35
+ },
36
+ }
37
+
38
+ export default meta
39
+ type Story = StoryObj<typeof meta>
40
+
41
+ // Content from content/personas/bads.json → primary.names / orgs.
42
+ const PERSON = "Seo-yun Park"
43
+ const ORG = "Harborline Logistics"
44
+
45
+ /**
46
+ * Shared harness: a Button inside the provider that calls `show()` with the
47
+ * story's options. `play` clicks it so the snackbar is on screen when the
48
+ * story (and Chromatic) first looks at it.
49
+ */
50
+ function Trigger({
51
+ label,
52
+ options,
53
+ }: {
54
+ label: string
55
+ options: SnackbarOptions | string
56
+ }) {
57
+ const { show } = useSnackbar()
58
+ return (
59
+ <Button variant="outline" size="xl" onClick={() => show(options)}>
60
+ {label}
61
+ </Button>
62
+ )
63
+ }
64
+
65
+ function Frame({ children }: { children: React.ReactNode }) {
66
+ return (
67
+ <div className="flex min-h-[360px] flex-wrap items-start gap-3 p-8">
68
+ {children}
69
+ </div>
70
+ )
71
+ }
72
+
73
+ const clickThenExpect =
74
+ (buttonName: RegExp, text: string | RegExp) =>
75
+ async ({ canvasElement }: { canvasElement: HTMLElement }) => {
76
+ const canvas = within(canvasElement)
77
+ await userEvent.click(canvas.getByRole("button", { name: buttonName }))
78
+ // The snackbar portals to the story iframe's <body>, outside canvasElement.
79
+ const body = within(canvasElement.ownerDocument.body)
80
+ const status = await body.findByRole("status")
81
+ await expect(within(status).getByText(text)).toBeInTheDocument()
82
+ }
83
+
84
+ export const Default: Story = {
85
+ args: { anchor: "bottom-center", duration: 4000 },
86
+ render: (args) => (
87
+ <SnackbarProvider {...args}>
88
+ <Frame>
89
+ <Trigger label="Save settings" options="Settings saved" />
90
+ </Frame>
91
+ </SnackbarProvider>
92
+ ),
93
+ play: clickThenExpect(/save settings/i, "Settings saved"),
94
+ }
95
+
96
+ export const WithAction: Story = {
97
+ parameters: { controls: { disable: true } },
98
+ render: () => (
99
+ <SnackbarProvider>
100
+ <Frame>
101
+ <Trigger
102
+ label="Archive component"
103
+ options={{
104
+ message: "Pill moved to Archive",
105
+ action: { label: "Undo", onClick: () => {} },
106
+ }}
107
+ />
108
+ </Frame>
109
+ </SnackbarProvider>
110
+ ),
111
+ play: clickThenExpect(/archive component/i, "Pill moved to Archive"),
112
+ }
113
+
114
+ export const WithIcon: Story = {
115
+ parameters: { controls: { disable: true } },
116
+ render: () => (
117
+ <SnackbarProvider>
118
+ <Frame>
119
+ <Trigger
120
+ label="Copy token name"
121
+ options={{
122
+ message: "Copied --primary to clipboard",
123
+ icon: <CircleCheck strokeWidth={1.5} className="text-icon-success" />,
124
+ }}
125
+ />
126
+ </Frame>
127
+ </SnackbarProvider>
128
+ ),
129
+ play: clickThenExpect(/copy token name/i, "Copied --primary to clipboard"),
130
+ }
131
+
132
+ /** A long single-word identifier wraps with overflow-wrap:anywhere instead of pushing the controls out. */
133
+ export const LongMessage: Story = {
134
+ parameters: { controls: { disable: true } },
135
+ render: () => (
136
+ <SnackbarProvider>
137
+ <Frame>
138
+ <Trigger
139
+ label="Share link"
140
+ options={{
141
+ message:
142
+ "Share link copied: https://design.harborline-logistics.example/preview/components#snackbar-queue-and-pause-on-hover-behaviour",
143
+ icon: <Link2 strokeWidth={1.5} />,
144
+ action: { label: "Open", onClick: () => {} },
145
+ }}
146
+ />
147
+ </Frame>
148
+ </SnackbarProvider>
149
+ ),
150
+ play: clickThenExpect(/share link/i, /Share link copied/),
151
+ }
152
+
153
+ /** 1.5 s — a quick confirmation that gets out of the way. */
154
+ export const CustomDuration: Story = {
155
+ parameters: { controls: { disable: true } },
156
+ render: () => (
157
+ <SnackbarProvider>
158
+ <Frame>
159
+ <Trigger
160
+ label="Save draft"
161
+ options={{ message: "Draft saved", duration: 1500 }}
162
+ />
163
+ </Frame>
164
+ </SnackbarProvider>
165
+ ),
166
+ play: clickThenExpect(/save draft/i, "Draft saved"),
167
+ }
168
+
169
+ export const Anchor_BottomLeft: Story = {
170
+ parameters: { controls: { disable: true } },
171
+ render: () => (
172
+ <SnackbarProvider anchor="bottom-left">
173
+ <Frame>
174
+ <Trigger label="Save settings" options="Settings saved" />
175
+ </Frame>
176
+ </SnackbarProvider>
177
+ ),
178
+ play: clickThenExpect(/save settings/i, "Settings saved"),
179
+ }
180
+
181
+ export const Anchor_BottomRight: Story = {
182
+ parameters: { controls: { disable: true } },
183
+ render: () => (
184
+ <SnackbarProvider anchor="bottom-right">
185
+ <Frame>
186
+ <Trigger label="Save settings" options="Settings saved" />
187
+ </Frame>
188
+ </SnackbarProvider>
189
+ ),
190
+ play: clickThenExpect(/save settings/i, "Settings saved"),
191
+ }
192
+
193
+ /** `duration: Infinity` — stays until dismissed. The × shows by default so the message can never trap itself. */
194
+ export const Sticky: Story = {
195
+ parameters: { controls: { disable: true } },
196
+ render: () => (
197
+ <SnackbarProvider>
198
+ <Frame>
199
+ <Trigger
200
+ label="Go offline"
201
+ options={{
202
+ message: `You're offline. Changes to ${ORG} sync when you reconnect.`,
203
+ duration: Infinity,
204
+ }}
205
+ />
206
+ </Frame>
207
+ </SnackbarProvider>
208
+ ),
209
+ play: clickThenExpect(/go offline/i, /You're offline/),
210
+ }
211
+
212
+ /** Three `show()` calls in a row — one visible, two waiting. The next mounts only after the current one has fully exited. */
213
+ export const Queue: Story = {
214
+ parameters: { controls: { disable: true } },
215
+ render: function QueueStory() {
216
+ function QueueTrigger() {
217
+ const { show, dismiss } = useSnackbar()
218
+ return (
219
+ <>
220
+ <Button
221
+ variant="outline"
222
+ size="xl"
223
+ onClick={() => {
224
+ show({ message: `Invitation sent to ${PERSON}`, duration: 2000 })
225
+ show({ message: "Role updated to Editor", duration: 2000 })
226
+ show({ message: "Workspace settings saved", duration: 2000 })
227
+ }}
228
+ >
229
+ Queue three messages
230
+ </Button>
231
+ <Button variant="ghost" size="xl" onClick={() => dismiss("all")}>
232
+ Clear queue
233
+ </Button>
234
+ </>
235
+ )
236
+ }
237
+ return (
238
+ <SnackbarProvider>
239
+ <Frame>
240
+ <QueueTrigger />
241
+ </Frame>
242
+ </SnackbarProvider>
243
+ )
244
+ },
245
+ play: clickThenExpect(/queue three messages/i, `Invitation sent to ${PERSON}`),
246
+ }
247
+
248
+ /** A team settings page: invite → confirmation with Undo, archive → confirmation with Undo. One snackbar, one message at a time. */
249
+ export const RealisticUse: Story = {
250
+ parameters: { controls: { disable: true } },
251
+ render: function RealisticUseStory() {
252
+ function TeamActions() {
253
+ const { show } = useSnackbar()
254
+ const [members, setMembers] = React.useState([PERSON, "Marcus Lindqvist", "Anika Patel"])
255
+ const [archived, setArchived] = React.useState<string[]>([])
256
+ return (
257
+ <div className="w-full max-w-md space-y-4">
258
+ <div>
259
+ <h3 className="text-lg font-semibold tracking-tight">{ORG} · Team</h3>
260
+ <p className="text-sm text-muted-foreground">
261
+ {members.length} members · {archived.length} archived
262
+ </p>
263
+ </div>
264
+ <ul className="divide-y rounded-lg border">
265
+ {members.map((name) => (
266
+ <li key={name} className="flex items-center justify-between gap-3 px-4 py-2">
267
+ <span className="min-w-0 truncate text-sm font-medium">{name}</span>
268
+ <Button
269
+ variant="ghost"
270
+ size="default"
271
+ className="min-h-11 shrink-0"
272
+ onClick={() => {
273
+ setMembers((m) => m.filter((n) => n !== name))
274
+ setArchived((a) => [...a, name])
275
+ show({
276
+ message: `${name} archived`,
277
+ icon: <Archive strokeWidth={1.5} />,
278
+ action: {
279
+ label: "Undo",
280
+ onClick: () => {
281
+ setArchived((a) => a.filter((n) => n !== name))
282
+ setMembers((m) => [...m, name])
283
+ },
284
+ },
285
+ })
286
+ }}
287
+ >
288
+ Archive
289
+ </Button>
290
+ </li>
291
+ ))}
292
+ </ul>
293
+ <Button
294
+ size="xl"
295
+ onClick={() =>
296
+ show({
297
+ message: "Invitation sent to Tomás Herrera",
298
+ icon: <Send strokeWidth={1.5} />,
299
+ })
300
+ }
301
+ >
302
+ Invite Tomás Herrera
303
+ </Button>
304
+ </div>
305
+ )
306
+ }
307
+ return (
308
+ <SnackbarProvider>
309
+ <Frame>
310
+ <TeamActions />
311
+ </Frame>
312
+ </SnackbarProvider>
313
+ )
314
+ },
315
+ }
@@ -0,0 +1,263 @@
1
+ import * as React from "react"
2
+ import type { Meta, StoryObj } from "@storybook/react"
3
+ import { SortableList } from "@behavioral-agentic-design-system/core/components/ui/sortable-list"
4
+ import {
5
+ Field,
6
+ FieldLabel,
7
+ FieldHelper,
8
+ } from "@behavioral-agentic-design-system/core/components/ui/field"
9
+ import { Badge } from "@behavioral-agentic-design-system/core/components/ui/badge"
10
+
11
+ // ─── Meta ─────────────────────────────────────────────────────────────────────
12
+
13
+ const meta = {
14
+ title: "Components/Layout/SortableList",
15
+ component: SortableList,
16
+ parameters: {
17
+ layout: "padded",
18
+ docs: {
19
+ description: {
20
+ component:
21
+ "Drag-and-drop reorderable list using @dnd-kit. Keyboard accessible — Space/Enter to lift, arrow keys to move, Space/Enter/Escape to drop/cancel. Items require a stable `id`.",
22
+ },
23
+ },
24
+ },
25
+ } satisfies Meta<typeof SortableList>
26
+
27
+ export default meta
28
+
29
+ // ─── Fixtures ─────────────────────────────────────────────────────────────────
30
+
31
+ const PRIORITIES = [
32
+ { id: "p1", label: "Northwind Health integration", priority: "high" },
33
+ { id: "p2", label: "Token refresh for Cedar & Pine Studio", priority: "medium" },
34
+ { id: "p3", label: "Harborline Logistics onboarding flow", priority: "medium" },
35
+ { id: "p4", label: "WCAG AAA audit — Meridian Payments", priority: "low" },
36
+ { id: "p5", label: "Lumen Analytics dashboard components", priority: "low" },
37
+ ]
38
+
39
+ const PIPELINE_STAGES = [
40
+ { id: "s1", label: "Qualification" },
41
+ { id: "s2", label: "Discovery" },
42
+ { id: "s3", label: "Proposal" },
43
+ { id: "s4", label: "Negotiation" },
44
+ { id: "s5", label: "Closed" },
45
+ ]
46
+
47
+ const TEAM_MEMBERS = [
48
+ { id: "u1", name: "Jordan Reeves", role: "Design Lead" },
49
+ { id: "u2", name: "Seo-yun Park", role: "Senior Engineer" },
50
+ { id: "u3", name: "Marcus Lindqvist", role: "Product Manager" },
51
+ { id: "u4", name: "Anika Patel", role: "QA Engineer" },
52
+ ]
53
+
54
+ // ─── Story helpers ────────────────────────────────────────────────────────────
55
+
56
+ function useItems<T>(initial: T[]) {
57
+ const [items, setItems] = React.useState(initial)
58
+ return { items, setItems }
59
+ }
60
+
61
+ // ─── Stories ──────────────────────────────────────────────────────────────────
62
+
63
+ type Story = StoryObj<typeof meta>
64
+
65
+ export const Default: Story = {
66
+ parameters: { controls: { disable: true } },
67
+ render: () => {
68
+ const { items, setItems } = useItems(PIPELINE_STAGES)
69
+ return (
70
+ <div className="w-80">
71
+ <SortableList
72
+ items={items}
73
+ onReorder={setItems}
74
+ aria-label="Pipeline stages"
75
+ renderItem={(item) => (
76
+ <span className="text-sm text-foreground">{item.label}</span>
77
+ )}
78
+ />
79
+ </div>
80
+ )
81
+ },
82
+ }
83
+
84
+ export const WithBadges: Story = {
85
+ parameters: { controls: { disable: true } },
86
+ render: () => {
87
+ const { items, setItems } = useItems(PRIORITIES)
88
+ return (
89
+ <div className="w-96">
90
+ <SortableList
91
+ items={items}
92
+ onReorder={setItems}
93
+ aria-label="Project priorities"
94
+ renderItem={(item) => (
95
+ <div className="flex min-w-0 items-center gap-2">
96
+ <span className="min-w-0 flex-1 truncate text-sm text-foreground">
97
+ {item.label}
98
+ </span>
99
+ <Badge
100
+ variant={
101
+ item.priority === "high"
102
+ ? "destructive"
103
+ : item.priority === "medium"
104
+ ? "secondary"
105
+ : "outline"
106
+ }
107
+ className="shrink-0 text-xs"
108
+ >
109
+ {item.priority}
110
+ </Badge>
111
+ </div>
112
+ )}
113
+ />
114
+ </div>
115
+ )
116
+ },
117
+ }
118
+
119
+ export const NoHandle: Story = {
120
+ parameters: { controls: { disable: true } },
121
+ render: () => {
122
+ const { items, setItems } = useItems(PIPELINE_STAGES)
123
+ return (
124
+ <div className="w-80">
125
+ <SortableList
126
+ items={items}
127
+ onReorder={setItems}
128
+ handle={false}
129
+ aria-label="Pipeline stages — full row draggable"
130
+ renderItem={(item) => (
131
+ <span className="cursor-grab text-sm text-foreground active:cursor-grabbing">
132
+ {item.label}
133
+ </span>
134
+ )}
135
+ />
136
+ </div>
137
+ )
138
+ },
139
+ }
140
+
141
+ export const Size_Sm: Story = {
142
+ parameters: { controls: { disable: true } },
143
+ render: () => {
144
+ const { items, setItems } = useItems(PIPELINE_STAGES)
145
+ return (
146
+ <div className="w-72">
147
+ <SortableList
148
+ items={items}
149
+ onReorder={setItems}
150
+ size="sm"
151
+ aria-label="Pipeline stages (small)"
152
+ renderItem={(item) => (
153
+ <span className="text-xs text-foreground">{item.label}</span>
154
+ )}
155
+ />
156
+ </div>
157
+ )
158
+ },
159
+ }
160
+
161
+ export const Size_Default: Story = {
162
+ parameters: { controls: { disable: true } },
163
+ render: () => {
164
+ const { items, setItems } = useItems(PIPELINE_STAGES)
165
+ return (
166
+ <div className="w-80">
167
+ <SortableList
168
+ items={items}
169
+ onReorder={setItems}
170
+ size="default"
171
+ aria-label="Pipeline stages (default)"
172
+ renderItem={(item) => (
173
+ <span className="text-sm text-foreground">{item.label}</span>
174
+ )}
175
+ />
176
+ </div>
177
+ )
178
+ },
179
+ }
180
+
181
+ export const Size_Lg: Story = {
182
+ parameters: { controls: { disable: true } },
183
+ render: () => {
184
+ const { items, setItems } = useItems(PIPELINE_STAGES)
185
+ return (
186
+ <div className="w-80">
187
+ <SortableList
188
+ items={items}
189
+ onReorder={setItems}
190
+ size="lg"
191
+ aria-label="Pipeline stages (large)"
192
+ renderItem={(item) => (
193
+ <span className="text-base text-foreground">{item.label}</span>
194
+ )}
195
+ />
196
+ </div>
197
+ )
198
+ },
199
+ }
200
+
201
+ export const Disabled: Story = {
202
+ parameters: { controls: { disable: true } },
203
+ render: () => {
204
+ const { items, setItems } = useItems(PIPELINE_STAGES)
205
+ return (
206
+ <div className="w-80">
207
+ <SortableList
208
+ items={items}
209
+ onReorder={setItems}
210
+ disabled
211
+ aria-label="Pipeline stages (read-only)"
212
+ renderItem={(item) => (
213
+ <span className="text-sm text-muted-foreground">{item.label}</span>
214
+ )}
215
+ />
216
+ </div>
217
+ )
218
+ },
219
+ }
220
+
221
+ // ─── Realistic use ────────────────────────────────────────────────────────────
222
+
223
+ function RealisticUseDemo() {
224
+ const [members, setMembers] = React.useState(TEAM_MEMBERS)
225
+
226
+ return (
227
+ <div className="w-80 space-y-3">
228
+ <Field name="team-order">
229
+ <FieldLabel>Review order</FieldLabel>
230
+ <FieldHelper>
231
+ Drag to set the order in which the team reviews Fieldnote Labs pull
232
+ requests.
233
+ </FieldHelper>
234
+ <SortableList
235
+ items={members}
236
+ onReorder={setMembers}
237
+ aria-label="Team review order"
238
+ renderItem={(member) => (
239
+ <div className="min-w-0">
240
+ <p className="truncate text-sm font-medium text-foreground">
241
+ {member.name}
242
+ </p>
243
+ <p className="truncate text-xs text-muted-foreground">
244
+ {member.role}
245
+ </p>
246
+ </div>
247
+ )}
248
+ />
249
+ </Field>
250
+ <p className="text-xs text-muted-foreground">
251
+ Current order:{" "}
252
+ {members.map((m) => m.name.split(" ")[0]).join(" → ")}
253
+ </p>
254
+ </div>
255
+ )
256
+ }
257
+
258
+ export const RealisticUse: Story = {
259
+ parameters: {
260
+ controls: { disable: true },
261
+ },
262
+ render: () => <RealisticUseDemo />,
263
+ }
@@ -125,3 +125,4 @@ export const RealisticUse: Story = {
125
125
  </div>
126
126
  ),
127
127
  };
128
+
@@ -134,6 +134,7 @@ export const WithWrapperProps: Story = {
134
134
  ),
135
135
  };
136
136
 
137
+ // Scrollbar styled via native CSS: [scrollbar-width:thin] [scrollbar-color:...]
137
138
  export const WideOverflowing: Story = {
138
139
  render: () => (
139
140
  <div className="w-[380px]">
@@ -166,6 +166,8 @@ export const Empty: Story = {
166
166
  };
167
167
 
168
168
  // Realistic use: design system docs, article tag filter
169
+ // Enter pressed to confirm an IME candidate (Japanese, Chinese, Korean) is ignored by this component.
170
+ // Not scriptable in a story; check by hand with an IME on.
169
171
  export const RealisticUse: Story = {
170
172
  render: () => {
171
173
  const [tags, setTags] = React.useState<string[]>(["Accessibility", "Tokens"]);
@@ -116,6 +116,32 @@ export const FormatMM_SS: Story = {
116
116
  ),
117
117
  };
118
118
 
119
+ export const Variant_Completed: Story = {
120
+ name: "Variant — Completed (zero)",
121
+ render: function CompletedStory() {
122
+ const [completed, setCompleted] = React.useState(false);
123
+ return (
124
+ <div className="flex flex-col items-center gap-3">
125
+ <Timer
126
+ mode="countdown"
127
+ startMs={0}
128
+ completeAnnouncement="Time is up"
129
+ onComplete={() => setCompleted(true)}
130
+ className="text-2xl"
131
+ />
132
+ {completed && (
133
+ <p className="text-sm text-muted-foreground">onComplete fired</p>
134
+ )}
135
+ <p className="text-sm text-muted-foreground max-w-xs text-center">
136
+ Timer at zero: the screen reader gets a single polite announcement via
137
+ a one-shot role=status element that mounts on completion and is
138
+ annotated with allow-conditional-aria-live.
139
+ </p>
140
+ </div>
141
+ );
142
+ },
143
+ };
144
+
119
145
  // Real content from content/personas/bads.json (primary persona pool).
120
146
  export const RealisticUse: Story = {
121
147
  render: function RealisticUseStory() {
@@ -189,3 +189,4 @@ export const RealisticUse: Story = {
189
189
  );
190
190
  },
191
191
  };
192
+
@@ -63,6 +63,10 @@ export const Default: Story = {
63
63
  ),
64
64
  }
65
65
 
66
+ // The checked-state visual (corrections.md #026 — was a hand-rolled div
67
+ // rendering as a circle, not a checkbox) doesn't need its own story: unlike
68
+ // FacetedFilter's popover, these rows render directly, so initialSelected
69
+ // below already puts real checked Checkbox primitives in front of Chromatic.
66
70
  export const WithSearch: Story = {
67
71
  render: () => (
68
72
  <ControlledTransferList
@@ -88,3 +88,24 @@ export const RealisticUse: Story = {
88
88
  )
89
89
  },
90
90
  }
91
+
92
+ // Controlled from an empty state: `useState<Date>()` starts as undefined, which used to read as
93
+ // "uncontrolled", so a later Clear showed the first pick again.
94
+ export const ControlledStartsEmpty: Story = {
95
+ parameters: { controls: { disable: true } },
96
+ render: () => {
97
+ const [value, setValue] = React.useState<Date>()
98
+ return (
99
+ <div className="flex flex-col items-start gap-3">
100
+ <WeekPicker value={value} onValueChange={(v) => setValue(v)} />
101
+ <button
102
+ type="button"
103
+ className="min-h-11 rounded-md border px-4 text-sm font-medium"
104
+ onClick={() => setValue(undefined)}
105
+ >
106
+ Clear
107
+ </button>
108
+ </div>
109
+ )
110
+ },
111
+ }