@behavioral-agentic-design-system/core 0.45.0 → 0.47.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 (237) hide show
  1. package/package.json +17 -3
  2. package/scripts/a11y-lint.cjs +78 -15
  3. package/scripts/bads-sync.mjs +1 -1
  4. package/scripts/build-tokens.cjs +122 -7
  5. package/scripts/check-dark-contrast.mjs +204 -0
  6. package/scripts/check-flush-edges.mjs +245 -0
  7. package/scripts/design-system-advisory/README.md +239 -0
  8. package/scripts/design-system-advisory/check-copy-punctuation.mjs +44 -0
  9. package/scripts/design-system-advisory/check-even-padding.mjs +35 -0
  10. package/scripts/design-system-advisory/check-hand-built-button.mjs +46 -0
  11. package/scripts/design-system-advisory/check-html-nesting.mjs +51 -0
  12. package/scripts/design-system-advisory/check-icon-sizing.mjs +79 -0
  13. package/scripts/design-system-advisory/check-label-case.mjs +92 -0
  14. package/scripts/design-system-advisory/check-native-form-controls.mjs +53 -0
  15. package/scripts/design-system-advisory/check-radius.mjs +56 -0
  16. package/scripts/design-system-advisory/check-raw-values.mjs +61 -0
  17. package/scripts/design-system-advisory/check-small-text.mjs +72 -0
  18. package/scripts/design-system-advisory/check-tap-target.mjs +70 -0
  19. package/scripts/design-system-advisory/defaults.mjs +90 -0
  20. package/scripts/design-system-advisory/fixtures/clean.tsx.fixture +12 -0
  21. package/scripts/design-system-advisory/fixtures/violations.tsx.fixture +19 -0
  22. package/scripts/design-system-advisory/lib.mjs +255 -0
  23. package/scripts/design-system-advisory/run.mjs +189 -0
  24. package/scripts/design-system-advisory/workflow.yml +82 -0
  25. package/scripts/lib/copy-strings.mjs +146 -0
  26. package/scripts/lib/dark-contrast.mjs +120 -0
  27. package/scripts/lib/flush-edges.mjs +294 -0
  28. package/scripts/lib/lab-lint.mjs +62 -0
  29. package/scripts/lib/mount-page.mjs +25 -0
  30. package/scripts/lib/source-scan.mjs +173 -0
  31. package/scripts/lib/tells.mjs +240 -2
  32. package/scripts/lint-arbitrary-tokens.mjs +47 -0
  33. package/scripts/lint-component-token-refs.mjs +63 -0
  34. package/scripts/lint-content-hierarchy.mjs +114 -0
  35. package/scripts/lint-control-baseline.mjs +72 -0
  36. package/scripts/lint-copy-punctuation.mjs +60 -0
  37. package/scripts/lint-even-padding.mjs +58 -0
  38. package/scripts/lint-label-case.mjs +219 -0
  39. package/scripts/lint-microanimation.mjs +2 -2
  40. package/scripts/lint-proximity.mjs +181 -0
  41. package/scripts/lint-slop.mjs +1 -1
  42. package/scripts/lint-spacing-scale.mjs +78 -0
  43. package/scripts/lint-target-size.cjs +132 -0
  44. package/scripts/lint-token-primitives.mjs +307 -0
  45. package/scripts/size-audit.cjs +2 -2
  46. package/scripts/ux-tells.mjs +8 -6
  47. package/scripts/wcag-audit.cjs +25 -4
  48. package/src/api/layers/file.ts +2 -0
  49. package/src/api/site-auth.ts +14 -2
  50. package/src/app/preview/components/page.tsx +94 -14
  51. package/src/app/preview/sticker-sheet/page.tsx +329 -0
  52. package/src/app/preview/sticker-sheet/specimens.tsx +296 -0
  53. package/src/app/shell.tsx +4 -3
  54. package/src/components/Foundations/Colors.stories.tsx +119 -8
  55. package/src/components/home-tab.tsx +6 -1
  56. package/src/components/onboarding-wizard.tsx +1 -1
  57. package/src/components/ui/avatar.tsx +4 -0
  58. package/src/components/ui/chart.tsx +134 -42
  59. package/src/components/ui/checkbox-group.tsx +1 -1
  60. package/src/components/ui/checkbox.tsx +1 -1
  61. package/src/components/ui/combobox.tsx +1 -0
  62. package/src/components/ui/command.tsx +1 -1
  63. package/src/components/ui/date-picker.tsx +2 -0
  64. package/src/components/ui/date-range-picker.tsx +4 -0
  65. package/src/components/ui/file-upload.tsx +21 -2
  66. package/src/components/ui/heatmap.tsx +3 -1
  67. package/src/components/ui/input-group.tsx +5 -2
  68. package/src/components/ui/multi-select.tsx +1 -0
  69. package/src/components/ui/radio-group.tsx +2 -2
  70. package/src/components/ui/sparkline.tsx +33 -4
  71. package/src/components/ui/spinner.tsx +23 -4
  72. package/src/components/ui/table.tsx +9 -0
  73. package/src/components/ui/week-picker.tsx +0 -12
  74. package/src/data/component-added.json +8 -0
  75. package/src/data/docs-index.ts +22 -1
  76. package/src/data/history.json +161 -161
  77. package/src/data/sticker-sheet.json +9244 -0
  78. package/src/docs-trace-globs.json +1 -0
  79. package/src/lib/chart-motion.ts +41 -0
  80. package/src/lib/get-icon-color.ts +1 -1
  81. package/src/stories/Accordion.stories.tsx +7 -0
  82. package/src/stories/ActionBar.stories.tsx +5 -0
  83. package/src/stories/Affix.stories.tsx +4 -0
  84. package/src/stories/AiBadge.stories.tsx +9 -7
  85. package/src/stories/Alert.stories.tsx +13 -0
  86. package/src/stories/AlertDialog.stories.tsx +4 -0
  87. package/src/stories/Anchor.stories.tsx +5 -0
  88. package/src/stories/AngleSlider.stories.tsx +6 -3
  89. package/src/stories/AspectRatio.stories.tsx +4 -0
  90. package/src/stories/Autocomplete.stories.tsx +6 -0
  91. package/src/stories/Avatar.stories.tsx +10 -0
  92. package/src/stories/Badge.stories.tsx +14 -6
  93. package/src/stories/Blockquote.stories.tsx +6 -0
  94. package/src/stories/BottomNavigation.stories.tsx +4 -0
  95. package/src/stories/Breadcrumb.stories.tsx +3 -0
  96. package/src/stories/Burger.stories.tsx +1 -0
  97. package/src/stories/Button.stories.tsx +24 -0
  98. package/src/stories/ButtonGroup.stories.tsx +9 -0
  99. package/src/stories/Calendar.stories.tsx +3 -0
  100. package/src/stories/Card.stories.tsx +4 -0
  101. package/src/stories/Carousel.stories.tsx +6 -0
  102. package/src/stories/Cascader.stories.tsx +4 -0
  103. package/src/stories/Chart.stories.tsx +46 -1
  104. package/src/stories/ChatBubble.stories.tsx +8 -2
  105. package/src/stories/ChatMarker.stories.tsx +1 -0
  106. package/src/stories/Checkbox.stories.tsx +40 -0
  107. package/src/stories/CheckboxCard.stories.tsx +8 -0
  108. package/src/stories/CheckboxGroup.stories.tsx +19 -0
  109. package/src/stories/Chip.stories.tsx +10 -19
  110. package/src/stories/CircularProgress.stories.tsx +13 -27
  111. package/src/stories/Clipboard.stories.tsx +6 -0
  112. package/src/stories/CloseButton.stories.tsx +6 -4
  113. package/src/stories/Code.stories.tsx +8 -1
  114. package/src/stories/Collapsible.stories.tsx +2 -0
  115. package/src/stories/ColorPicker.stories.tsx +6 -0
  116. package/src/stories/ColorSwatch.stories.tsx +1 -0
  117. package/src/stories/Combobox.stories.tsx +9 -0
  118. package/src/stories/Command.stories.tsx +2 -0
  119. package/src/stories/Container.stories.tsx +8 -0
  120. package/src/stories/ContextMenu.stories.tsx +9 -0
  121. package/src/stories/CopyButton.stories.tsx +12 -36
  122. package/src/stories/DataList.stories.tsx +8 -0
  123. package/src/stories/DataTable.stories.tsx +9 -0
  124. package/src/stories/DateField.stories.tsx +7 -0
  125. package/src/stories/DatePicker.stories.tsx +34 -0
  126. package/src/stories/DateRangePicker.stories.tsx +32 -0
  127. package/src/stories/Dialog.stories.tsx +8 -0
  128. package/src/stories/Drawer.stories.tsx +6 -0
  129. package/src/stories/DropdownMenu.stories.tsx +2 -0
  130. package/src/stories/Editable.stories.tsx +10 -0
  131. package/src/stories/EmptyState.stories.tsx +9 -0
  132. package/src/stories/Field.stories.tsx +7 -0
  133. package/src/stories/Fieldset.stories.tsx +8 -0
  134. package/src/stories/FileButton.stories.tsx +4 -0
  135. package/src/stories/FileUpload.stories.tsx +16 -17
  136. package/src/stories/FloatLabel.stories.tsx +3 -8
  137. package/src/stories/FloatingActionButton.stories.tsx +10 -0
  138. package/src/stories/FloatingIndicator.stories.tsx +4 -0
  139. package/src/stories/FloatingPanel.stories.tsx +6 -0
  140. package/src/stories/FocusTrap.stories.tsx +5 -0
  141. package/src/stories/FormatByte.stories.tsx +6 -0
  142. package/src/stories/FormatDate.stories.tsx +8 -0
  143. package/src/stories/FormatNumber.stories.tsx +9 -0
  144. package/src/stories/Heatmap.stories.tsx +11 -0
  145. package/src/stories/Highlight.stories.tsx +6 -0
  146. package/src/stories/HoverCard.stories.tsx +4 -0
  147. package/src/stories/Image.stories.tsx +9 -0
  148. package/src/stories/Indicator.stories.tsx +19 -0
  149. package/src/stories/Input.stories.tsx +7 -0
  150. package/src/stories/InputClearButton.stories.tsx +3 -0
  151. package/src/stories/InputGroup.stories.tsx +40 -0
  152. package/src/stories/Kbd.stories.tsx +7 -1
  153. package/src/stories/KeyboardShortcut.stories.tsx +2 -0
  154. package/src/stories/Label.stories.tsx +2 -0
  155. package/src/stories/Link.stories.tsx +9 -0
  156. package/src/stories/List.stories.tsx +8 -0
  157. package/src/stories/Listbox.stories.tsx +1 -0
  158. package/src/stories/LoadingDots.stories.tsx +5 -3
  159. package/src/stories/LoadingOverlay.stories.tsx +5 -1
  160. package/src/stories/Mark.stories.tsx +5 -0
  161. package/src/stories/Marquee.stories.tsx +4 -0
  162. package/src/stories/Masonry.stories.tsx +5 -0
  163. package/src/stories/Menubar.stories.tsx +3 -0
  164. package/src/stories/Meter.stories.tsx +11 -17
  165. package/src/stories/MonthPicker.stories.tsx +5 -1
  166. package/src/stories/MotionToggle.stories.tsx +1 -0
  167. package/src/stories/MultiSelect.stories.tsx +9 -0
  168. package/src/stories/NativeSelect.stories.tsx +1 -0
  169. package/src/stories/NavLink.stories.tsx +7 -0
  170. package/src/stories/NavigationMenu.stories.tsx +5 -0
  171. package/src/stories/NavigationRail.stories.tsx +10 -0
  172. package/src/stories/Notification.stories.tsx +13 -34
  173. package/src/stories/NumberInput.stories.tsx +8 -1
  174. package/src/stories/Overlay.stories.tsx +5 -1
  175. package/src/stories/Pagination.stories.tsx +8 -0
  176. package/src/stories/PasswordInput.stories.tsx +2 -0
  177. package/src/stories/PinInput.stories.tsx +9 -2
  178. package/src/stories/Popover.stories.tsx +2 -0
  179. package/src/stories/Progress.stories.tsx +6 -1
  180. package/src/stories/Prose.stories.tsx +8 -0
  181. package/src/stories/QrCode.stories.tsx +2 -0
  182. package/src/stories/Questionnaire.stories.tsx +7 -0
  183. package/src/stories/RadioGroup.stories.tsx +40 -0
  184. package/src/stories/RatingGroup.stories.tsx +8 -4
  185. package/src/stories/Resizable.stories.tsx +4 -2
  186. package/src/stories/Result.stories.tsx +3 -0
  187. package/src/stories/Reveal.stories.tsx +2 -0
  188. package/src/stories/RollingNumber.stories.tsx +5 -0
  189. package/src/stories/ScrollArea.stories.tsx +3 -1
  190. package/src/stories/SearchInput.stories.tsx +8 -6
  191. package/src/stories/SegmentedControl.stories.tsx +11 -0
  192. package/src/stories/Select.stories.tsx +7 -0
  193. package/src/stories/Separator.stories.tsx +6 -0
  194. package/src/stories/Sheet.stories.tsx +5 -0
  195. package/src/stories/Sidebar.stories.tsx +40 -1
  196. package/src/stories/SimpleGrid.stories.tsx +5 -0
  197. package/src/stories/Skeleton.stories.tsx +8 -0
  198. package/src/stories/SkeletonTable.stories.tsx +6 -5
  199. package/src/stories/SkipLink.stories.tsx +3 -0
  200. package/src/stories/Slider.stories.tsx +2 -1
  201. package/src/stories/Sonner.stories.tsx +7 -0
  202. package/src/stories/Sparkline.stories.tsx +14 -1
  203. package/src/stories/Spinner.stories.tsx +20 -10
  204. package/src/stories/Spoiler.stories.tsx +5 -0
  205. package/src/stories/Squircle.stories.tsx +7 -0
  206. package/src/stories/Stack.stories.tsx +7 -0
  207. package/src/stories/StatusBadge.stories.tsx +12 -6
  208. package/src/stories/Stepper.stories.tsx +5 -0
  209. package/src/stories/Switch.stories.tsx +4 -0
  210. package/src/stories/Table.stories.tsx +10 -1
  211. package/src/stories/Tabs.stories.tsx +8 -0
  212. package/src/stories/Tag.stories.tsx +13 -5
  213. package/src/stories/TagsInput.stories.tsx +13 -0
  214. package/src/stories/Text.stories.tsx +12 -0
  215. package/src/stories/Textarea.stories.tsx +9 -0
  216. package/src/stories/ThemeIcon.stories.tsx +6 -3
  217. package/src/stories/TimePicker.stories.tsx +2 -0
  218. package/src/stories/Timeline.stories.tsx +12 -0
  219. package/src/stories/Timer.stories.tsx +4 -0
  220. package/src/stories/Toggle.stories.tsx +7 -5
  221. package/src/stories/ToggleGroup.stories.tsx +5 -0
  222. package/src/stories/ToggleTip.stories.tsx +4 -0
  223. package/src/stories/Toolbar.stories.tsx +6 -0
  224. package/src/stories/Tooltip.stories.tsx +3 -0
  225. package/src/stories/Tour.stories.tsx +3 -0
  226. package/src/stories/TransferList.stories.tsx +3 -0
  227. package/src/stories/TreeSelect.stories.tsx +4 -0
  228. package/src/stories/TreeView.stories.tsx +5 -0
  229. package/src/stories/TypingIndicator.stories.tsx +4 -0
  230. package/src/stories/VisuallyHidden.stories.tsx +3 -0
  231. package/src/stories/Watermark.stories.tsx +6 -0
  232. package/src/stories/WeekPicker.stories.tsx +4 -1
  233. package/src/stories/WordRotate.stories.tsx +5 -0
  234. package/src/stories/YearPicker.stories.tsx +5 -11
  235. package/src/styles.css +50 -2
  236. package/src/tokens.json +4 -4
  237. package/LICENSE +0 -21
@@ -0,0 +1,296 @@
1
+ "use client";
2
+
3
+ // Specimens for the sticker sheet: one entry per registry key that has a
4
+ // declared state matrix. This file is also the fork adapter. A fork that owns
5
+ // its components replaces it with its own `{ [registryKey]: Specimen }` map
6
+ // (see docs/sticker-sheet.md); the page only reads the shape below.
7
+ import * as React from "react";
8
+ import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "../../../components/ui/accordion";
9
+ import { Alert, AlertDescription, AlertTitle } from "../../../components/ui/alert";
10
+ import { Badge } from "../../../components/ui/badge";
11
+ import { Button } from "../../../components/ui/button";
12
+ import { Checkbox } from "../../../components/ui/checkbox";
13
+ import { Chip } from "../../../components/ui/chip";
14
+ import { Kbd } from "../../../components/ui/kbd";
15
+ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../../../components/ui/select";
16
+ import { Skeleton } from "../../../components/ui/skeleton";
17
+ import { Spinner } from "../../../components/ui/spinner";
18
+ import { StatusBadge } from "../../../components/ui/status-badge";
19
+ import { Tabs, TabsList, TabsTrigger } from "../../../components/ui/tabs";
20
+ import { ToggleGroup, ToggleGroupItem } from "../../../components/ui/toggle-group";
21
+ import { Input } from "../../../components/ui/input";
22
+ import { Progress } from "../../../components/ui/progress";
23
+ import { RadioGroup, RadioGroupItem } from "../../../components/ui/radio-group";
24
+ import { Slider } from "../../../components/ui/slider";
25
+ import { Switch } from "../../../components/ui/switch";
26
+ import { Textarea } from "../../../components/ui/textarea";
27
+ import { Toggle } from "../../../components/ui/toggle";
28
+
29
+ export type StateKey =
30
+ | "default"
31
+ | "hover"
32
+ | "focus"
33
+ | "pressed"
34
+ | "disabled"
35
+ | "invalid"
36
+ | "checked"
37
+ | "checkedHover"
38
+ | "indeterminate";
39
+
40
+ export const STATE_LABEL: Record<StateKey, string> = {
41
+ default: "Default",
42
+ hover: "Hover",
43
+ focus: "Focus",
44
+ pressed: "Pressed",
45
+ disabled: "Disabled",
46
+ invalid: "Invalid",
47
+ checked: "Checked",
48
+ checkedHover: "Checked + hover",
49
+ indeterminate: "Indeterminate",
50
+ };
51
+
52
+ /** Attributes that put a specimen in a state without touching the component. */
53
+ export function stateAttrs(state: StateKey): Record<string, unknown> {
54
+ switch (state) {
55
+ case "hover":
56
+ case "checkedHover":
57
+ return { "data-pin": "hover" };
58
+ case "focus":
59
+ return { "data-pin": "focus" };
60
+ case "pressed":
61
+ return { "data-pin": "pressed" };
62
+ case "disabled":
63
+ return { disabled: true };
64
+ case "invalid":
65
+ return { "aria-invalid": true };
66
+ default:
67
+ return {};
68
+ }
69
+ }
70
+
71
+ export interface Variant {
72
+ label: string;
73
+ props?: Record<string, unknown>;
74
+ }
75
+
76
+ export interface Specimen {
77
+ /** Rows: one per variant or size. Omit for a component with a single look. */
78
+ variants?: Variant[];
79
+ states: StateKey[];
80
+ render: (args: { variant: Record<string, unknown>; state: StateKey; attrs: Record<string, unknown> }) => React.ReactNode;
81
+ /** Contrast pairings this component depends on, as "fgToken|bgToken". Looked up in the wcag-audit output. */
82
+ pairs: string[];
83
+ /** Tokens the component paints with. Shown with their resolved value per theme. */
84
+ tokens: string[];
85
+ /** Where pinning can't reproduce the real state. Shown under the band so the tile isn't read as the truth. */
86
+ limits?: string[];
87
+ }
88
+
89
+ const FORM = ["default", "hover", "focus", "disabled", "invalid"] satisfies StateKey[];
90
+ const CHECKABLE = ["default", "hover", "focus", "checked", "checkedHover", "indeterminate", "disabled", "invalid"] satisfies StateKey[];
91
+ const checkedFor = (state: StateKey) =>
92
+ state === "checked" || state === "checkedHover" ? true : state === "indeterminate" ? "indeterminate" : false;
93
+
94
+ export const SPECIMENS: Record<string, Specimen> = {
95
+ Button: {
96
+ variants: ["default", "secondary", "outline", "ghost", "destructive", "accent", "link"].map((v) => ({ label: v, props: { variant: v } })),
97
+ states: ["default", "hover", "focus", "pressed", "disabled"],
98
+ render: ({ variant, attrs }) => (
99
+ <Button {...variant} {...attrs}>
100
+ Save changes
101
+ </Button>
102
+ ),
103
+ pairs: ["primary-foreground|primary", "secondary-foreground|secondary", "accent-foreground|accent", "destructive-foreground|destructive", "ring|background"],
104
+ tokens: ["primary", "primary-foreground", "secondary", "accent", "destructive", "ring"],
105
+ },
106
+ Input: {
107
+ variants: ["outline", "ghost", "filled"].map((v) => ({ label: v, props: { variant: v } })),
108
+ states: FORM,
109
+ render: ({ variant, attrs }) => <Input aria-label="Email address" placeholder="maya@example.org" {...variant} {...attrs} />,
110
+ pairs: ["foreground|background", "muted-foreground|background", "input|card", "ring|background", "destructive|background"],
111
+ tokens: ["input", "ring", "destructive", "muted-foreground"],
112
+ },
113
+ Textarea: {
114
+ variants: ["sm", "default", "lg"].map((v) => ({ label: `size ${v}`, props: { size: v } })),
115
+ states: FORM,
116
+ render: ({ variant, attrs }) => <Textarea aria-label="Notes" placeholder="Anything we should know?" {...variant} {...attrs} />,
117
+ pairs: ["foreground|background", "muted-foreground|background", "input|card", "ring|background", "destructive|background"],
118
+ tokens: ["input", "ring", "destructive", "muted-foreground"],
119
+ },
120
+ Checkbox: {
121
+ variants: ["sm", "default", "lg"].map((v) => ({ label: `size ${v}`, props: { size: v } })),
122
+ states: CHECKABLE,
123
+ render: ({ variant, state, attrs }) => <Checkbox aria-label="Agree to terms" checked={checkedFor(state)} {...variant} {...attrs} />,
124
+ pairs: ["primary-foreground|primary", "primary|background", "ring|background", "destructive|background"],
125
+ tokens: ["primary", "primary-foreground", "ring", "destructive"],
126
+ },
127
+ Switch: {
128
+ variants: ["sm", "default", "lg"].map((v) => ({ label: `size ${v}`, props: { size: v } })),
129
+ states: ["default", "hover", "focus", "checked", "checkedHover", "disabled"],
130
+ render: ({ variant, state, attrs }) => <Switch aria-label="Email notifications" checked={checkedFor(state) === true} {...variant} {...attrs} />,
131
+ pairs: ["primary|background", "input|card", "ring|background"],
132
+ tokens: ["primary", "input", "ring"],
133
+ },
134
+ Toggle: {
135
+ variants: ["default", "outline"].map((v) => ({ label: v, props: { variant: v } })),
136
+ states: ["default", "hover", "focus", "pressed", "checked", "disabled"],
137
+ render: ({ variant, state, attrs }) => (
138
+ <Toggle aria-label="Bold" pressed={state === "checked"} {...variant} {...attrs}>
139
+ B
140
+ </Toggle>
141
+ ),
142
+ pairs: ["accent-foreground|accent", "input|card", "ring|background"],
143
+ tokens: ["accent", "accent-foreground", "input", "ring"],
144
+ },
145
+ Badge: {
146
+ variants: ["default", "secondary", "destructive", "outline", "success", "warning", "info"].map((v) => ({ label: v, props: { variant: v } })),
147
+ states: ["default", "focus"],
148
+ render: ({ variant, attrs }) => (
149
+ <Badge {...variant} {...attrs}>
150
+ In review
151
+ </Badge>
152
+ ),
153
+ pairs: ["primary-foreground|primary", "secondary-foreground|secondary", "destructive-foreground|destructive", "success|background", "warning|background", "info|background"],
154
+ tokens: ["primary", "secondary", "destructive", "success", "warning", "info"],
155
+ },
156
+ RadioGroup: {
157
+ variants: ["sm", "default", "lg"].map((v) => ({ label: `size ${v}`, props: { size: v } })),
158
+ states: CHECKABLE.filter((s) => s !== "indeterminate"),
159
+ render: ({ variant, state, attrs }) => (
160
+ <RadioGroup value={state === "checked" || state === "checkedHover" ? "a" : ""} aria-label="Plan">
161
+ <RadioGroupItem value="a" aria-label="Monthly plan" {...variant} {...attrs} />
162
+ </RadioGroup>
163
+ ),
164
+ pairs: ["primary|background", "ring|background", "destructive|background"],
165
+ tokens: ["primary", "ring", "destructive"],
166
+ },
167
+ Slider: {
168
+ states: ["default", "hover", "focus", "disabled"],
169
+ render: ({ attrs }) => (
170
+ <div className="w-48">
171
+ <Slider aria-label="Volume" defaultValue={[40]} {...attrs} />
172
+ </div>
173
+ ),
174
+ pairs: ["primary|background", "ring|background"],
175
+ tokens: ["primary", "ring"],
176
+ },
177
+ Progress: {
178
+ variants: ["default", "success", "warning", "error", "info"].map((v) => ({ label: v, props: { intent: v } })),
179
+ states: ["default"],
180
+ render: ({ variant }) => (
181
+ <div className="w-48">
182
+ <Progress aria-label="Upload" value={60} {...variant} />
183
+ </div>
184
+ ),
185
+ pairs: ["primary|background", "success|background", "warning|background", "destructive|background", "info|background"],
186
+ tokens: ["primary", "success", "warning", "destructive", "info"],
187
+ },
188
+ Alert: {
189
+ variants: ["default", "destructive", "success", "warning", "info"].map((v) => ({ label: v, props: { variant: v } })),
190
+ states: ["default"],
191
+ render: ({ variant }) => (
192
+ <Alert className="w-72" {...variant}>
193
+ <AlertTitle>Heads up</AlertTitle>
194
+ <AlertDescription>Your plan renews on the first of the month.</AlertDescription>
195
+ </Alert>
196
+ ),
197
+ pairs: ["foreground|background", "destructive|background", "success|background", "warning|background", "info|background"],
198
+ tokens: ["destructive", "success", "warning", "info"],
199
+ },
200
+ Select: {
201
+ states: FORM,
202
+ render: ({ attrs }) => (
203
+ <Select>
204
+ <SelectTrigger className="w-56" aria-label="Pick a fruit" {...attrs}>
205
+ <SelectValue placeholder="Pick a fruit" />
206
+ </SelectTrigger>
207
+ <SelectContent>
208
+ <SelectItem value="apple">Apple</SelectItem>
209
+ </SelectContent>
210
+ </Select>
211
+ ),
212
+ pairs: ["foreground|background", "muted-foreground|background", "input|card", "ring|background", "destructive|background"],
213
+ tokens: ["input", "ring", "destructive", "muted-foreground"],
214
+ },
215
+ Tabs: {
216
+ // Overview is the selected tab; the states act on the unselected "Usage"
217
+ // trigger. "Checked" flips the selection to show the active look instead.
218
+ states: ["default", "hover", "focus", "pressed", "checked", "disabled"],
219
+ render: ({ state, attrs }) => (
220
+ <Tabs value={state === "checked" ? "b" : "a"}>
221
+ <TabsList>
222
+ <TabsTrigger value="a">Overview</TabsTrigger>
223
+ <TabsTrigger value="b" {...(state === "checked" ? {} : attrs)}>
224
+ Usage
225
+ </TabsTrigger>
226
+ </TabsList>
227
+ </Tabs>
228
+ ),
229
+ pairs: ["foreground|background", "muted-foreground|muted", "ring|background"],
230
+ tokens: ["muted", "muted-foreground", "ring"],
231
+ },
232
+ Accordion: {
233
+ variants: ["default", "contained", "separated"].map((v) => ({ label: v, props: { variant: v } })),
234
+ states: ["default", "hover", "focus", "checked", "disabled"],
235
+ render: ({ variant, state, attrs }) => (
236
+ <Accordion type="single" collapsible className="w-72" defaultValue={state === "checked" ? "a" : undefined} {...variant}>
237
+ <AccordionItem value="a" disabled={state === "disabled"}>
238
+ <AccordionTrigger {...(state === "disabled" ? {} : attrs)}>What is BADS?</AccordionTrigger>
239
+ <AccordionContent>A portable design system for client work.</AccordionContent>
240
+ </AccordionItem>
241
+ </Accordion>
242
+ ),
243
+ pairs: ["foreground|background", "border|background", "ring|background"],
244
+ tokens: ["border", "ring"],
245
+ limits: [
246
+ "Contained and separated draw the focus ring on the item through :has(:focus-visible), which data-pin can't reach. The Focus tile for those two variants shows no ring. Tab through the live stories to see it.",
247
+ ],
248
+ },
249
+ ToggleGroup: {
250
+ variants: ["default", "outline"].map((v) => ({ label: v, props: { variant: v } })),
251
+ states: ["default", "hover", "focus", "pressed", "checked", "disabled"],
252
+ render: ({ variant, state, attrs }) => (
253
+ <ToggleGroup type="multiple" value={state === "checked" ? ["bold"] : []} {...variant}>
254
+ <ToggleGroupItem value="bold" aria-label="Bold" {...attrs}>
255
+ B
256
+ </ToggleGroupItem>
257
+ <ToggleGroupItem value="italic" aria-label="Italic">
258
+ I
259
+ </ToggleGroupItem>
260
+ </ToggleGroup>
261
+ ),
262
+ pairs: ["accent-foreground|accent", "input|card", "ring|background"],
263
+ tokens: ["accent", "accent-foreground", "input", "ring"],
264
+ },
265
+ Chip: {
266
+ states: ["default", "hover", "focus", "disabled"],
267
+ render: ({ attrs }) => <Chip {...attrs}>design tokens</Chip>,
268
+ pairs: ["foreground|background", "border|background"],
269
+ tokens: ["border", "muted"],
270
+ },
271
+ StatusBadge: {
272
+ variants: ["active", "pending", "processing", "error", "offline", "warning"].map((v) => ({ label: v, props: { status: v } })),
273
+ states: ["default"],
274
+ render: ({ variant }) => <StatusBadge {...(variant as { status: "active" })} />,
275
+ pairs: ["foreground|background", "success|background", "warning|background", "destructive|background"],
276
+ tokens: ["success", "warning", "destructive"],
277
+ },
278
+ Skeleton: {
279
+ states: ["default"],
280
+ render: () => <Skeleton className="h-4 w-48" />,
281
+ pairs: ["muted|background"],
282
+ tokens: ["muted"],
283
+ },
284
+ Spinner: {
285
+ states: ["default"],
286
+ render: () => <Spinner />,
287
+ pairs: ["foreground|background"],
288
+ tokens: ["foreground"],
289
+ },
290
+ Kbd: {
291
+ states: ["default"],
292
+ render: () => <Kbd>⌘K</Kbd>,
293
+ pairs: ["muted-foreground|muted"],
294
+ tokens: ["muted", "muted-foreground"],
295
+ },
296
+ };
package/src/app/shell.tsx CHANGED
@@ -6,7 +6,7 @@ import { Sheet, SheetContent, SheetHeader, SheetTitle } from "@behavioral-agenti
6
6
  import { Button } from "@behavioral-agentic-design-system/core/components/ui/button";
7
7
  import {
8
8
  Sun, Moon, BookOpen, X, ExternalLink, Menu, FlaskConical,
9
- House, Blocks,
9
+ House, Blocks, SwatchBook,
10
10
  Type, Shapes, FileText, Layers as LayersIcon, Activity, GitCommitHorizontal, SlidersHorizontal as StudioIcon,
11
11
  } from "lucide-react";
12
12
  import registry from "@/layer-5-component-registry/component-registry.json";
@@ -248,6 +248,7 @@ export const DEFAULT_TABS: ShellTab[] = [
248
248
  // value and the specimens beside it repaint, instead of navigating to find out.
249
249
  { value: "studio", label: "Studio", group: "build", icon: StudioIcon, render: ({ dark }) => <Studio dark={dark} /> },
250
250
  { value: "components", label: "Components", group: "build", icon: Blocks, count: COMPONENT_COUNT, render: ({ dark }) => <IframePreview dark={dark} src="/preview/components" title="Components preview" /> },
251
+ { value: "sticker-sheet", label: "Sticker sheet", group: "build", icon: SwatchBook, noPreload: true, render: () => <IframePreview dark={false} src="/preview/sticker-sheet" title="Sticker sheet preview" /> },
251
252
 
252
253
  // Typography was a route with no way to reach it — /preview/typography has
253
254
  // rendered fine and been unlinked. The Foundations group is where it belongs.
@@ -276,7 +277,7 @@ export const DEFAULT_TABS: ShellTab[] = [
276
277
 
277
278
  /**
278
279
  * A rail destination: glyph, label, and (only when genuinely derived) a count.
279
- * Icons render at the system stroke width of 1.5 — see CLAUDE.md "Icons".
280
+ * Icons render at the system stroke width of 1.5 — see AGENTS.md "Icons".
280
281
  */
281
282
  const RAIL_ITEM =
282
283
  "relative flex w-full min-h-9 items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm font-medium transition-colors before:absolute before:inset-x-0 before:-inset-y-1 before:content-[''] data-[state=active]:bg-primary data-[state=active]:text-primary-foreground data-[state=inactive]:text-muted-foreground hover:data-[state=inactive]:bg-muted hover:data-[state=inactive]:text-foreground";
@@ -830,7 +831,7 @@ export function Shell({ tabs, defaultTab }: ShellProps) {
830
831
  {/* Desktop (md+): the rail. It is a flex SIBLING with shrink-0, not a
831
832
  sticky or fixed element, so it rides the root View Transition
832
833
  snapshot exactly as the old header did and needs no
833
- view-transition-name. Naming it would be the trap CLAUDE.md
834
+ view-transition-name. Naming it would be the trap docs/agent-rules/theme-transition-and-sticky-chrome.md
834
835
  documents under "Theme transition and sticky chrome", not the fix.
835
836
  The panel area scrolls inside itself, which is what keeps the rail
836
837
  out of sticky-chrome territory in the first place. */}
@@ -1,16 +1,16 @@
1
1
  import type { Meta, StoryObj } from "@storybook/react";
2
+ import { useLayoutEffect, useRef, useState } from "react";
3
+ import { expect, waitFor } from "storybook/test";
2
4
 
3
5
  const meta: Meta = {
4
6
  title: "Foundations/Colors",
5
7
  parameters: {
6
8
  layout: "fullscreen",
7
- // This is a palette reference: every swatch paints a raw token as a
8
- // *background* with its name laid over it. Some tokens (chart fills, the
9
- // focus ring) are never text-bearing surfaces in product, so the label-on-
10
- // swatch pair legitimately falls under AA here. Disable only color-contrast
11
- // for this doc story — every other axe rule still runs, and real text/bg
12
- // pairs stay enforced by `pnpm wcag:audit` (AAA) and the rest of CI.
13
- a11y: { config: { rules: [{ id: "color-contrast", enabled: false }] } },
9
+ // color-contrast is ON for this story. Each swatch label measures its own
10
+ // swatch and changes to black or white when the paired token does not
11
+ // reach 4.5:1 (see useReadableLabel). Before that, the chart and input
12
+ // labels failed in some forks, and the rule was turned off for the whole
13
+ // page that exists to show colour discipline.
14
14
  },
15
15
  };
16
16
  export default meta;
@@ -65,10 +65,104 @@ const GROUPS: Record<string, { name: string; var: string; bg: string; fg?: strin
65
65
  ],
66
66
  };
67
67
 
68
+ // ---- readable labels ------------------------------------------------------
69
+ //
70
+ // A swatch shows a token as a background with its name on top. The name uses
71
+ // the token's paired foreground where one exists. But the colours change per
72
+ // fork and per theme, so a pairing that reads well in BADS can fail in a fork:
73
+ // FF-BADS measured "Chart 1" white on #3e7bc8 at 4.31:1, and "Input" (no pair,
74
+ // so it inherits) at 2.07:1. So each label measures what is painted. If the
75
+ // pair is under 4.5:1, the label changes to black or white, whichever reads
76
+ // better. One of the two always clears 4.5:1 on an opaque colour.
77
+
78
+ const MIN_RATIO = 4.5;
79
+ type RGBA = [number, number, number, number];
80
+
81
+ let probe: CanvasRenderingContext2D | null = null;
82
+ // The canvas turns any CSS colour (oklch, lab, color-mix, named) into sRGB.
83
+ function toRGBA(css: string): RGBA | null {
84
+ if (typeof document === "undefined") return null;
85
+ probe ??= Object.assign(document.createElement("canvas"), { width: 1, height: 1 })
86
+ .getContext("2d", { willReadFrequently: true });
87
+ if (!probe) return null;
88
+ probe.clearRect(0, 0, 1, 1);
89
+ probe.fillStyle = "rgba(0, 0, 0, 0)";
90
+ probe.fillStyle = css;
91
+ probe.fillRect(0, 0, 1, 1);
92
+ const [r, g, b, a] = probe.getImageData(0, 0, 1, 1).data;
93
+ return [r, g, b, a / 255];
94
+ }
95
+
96
+ function over(top: RGBA, under: RGBA): RGBA {
97
+ const a = top[3];
98
+ return [0, 1, 2].map((i) => top[i] * a + under[i] * (1 - a)).concat(1) as RGBA;
99
+ }
100
+
101
+ function luminance([r, g, b]: RGBA): number {
102
+ const c = [r, g, b].map((v) => {
103
+ const s = v / 255;
104
+ return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
105
+ });
106
+ return 0.2126 * c[0] + 0.7152 * c[1] + 0.0722 * c[2];
107
+ }
108
+
109
+ function ratio(a: RGBA, b: RGBA): number {
110
+ const [hi, lo] = [luminance(a), luminance(b)].sort((x, y) => y - x);
111
+ return (hi + 0.05) / (lo + 0.05);
112
+ }
113
+
114
+ // The colour actually behind an element: its own background, laid over each
115
+ // ancestor's background until an opaque one is reached.
116
+ function paintedBackground(el: Element | null): RGBA {
117
+ const layers: RGBA[] = [];
118
+ for (let n = el; n; n = n.parentElement) {
119
+ const c = toRGBA(getComputedStyle(n).backgroundColor);
120
+ if (!c || c[3] === 0) continue;
121
+ layers.push(c);
122
+ if (c[3] >= 1) break;
123
+ }
124
+ return layers.reduceRight<RGBA>((acc, c) => over(c, acc), [255, 255, 255, 1]);
125
+ }
126
+
127
+ const BLACK: RGBA = [0, 0, 0, 1];
128
+ const WHITE: RGBA = [255, 255, 255, 1];
129
+
130
+ function useReadableLabel() {
131
+ const ref = useRef<HTMLDivElement>(null);
132
+ const [override, setOverride] = useState<string | undefined>(undefined);
133
+ useLayoutEffect(() => {
134
+ const el = ref.current;
135
+ if (!el) return;
136
+ const measure = () => {
137
+ // Read the paired token's colour with any earlier override taken off.
138
+ const previous = el.style.color;
139
+ el.style.color = "";
140
+ const fgRaw = toRGBA(getComputedStyle(el).color);
141
+ el.style.color = previous;
142
+ const bg = paintedBackground(el);
143
+ if (!fgRaw) return;
144
+ if (ratio(over(fgRaw, bg), bg) >= MIN_RATIO) return setOverride(undefined);
145
+ setOverride(ratio(BLACK, bg) >= ratio(WHITE, bg) ? "black" : "white");
146
+ };
147
+ measure();
148
+ // Re-measure when the theme class or the brand colour changes on <html>.
149
+ const mo = new MutationObserver(measure);
150
+ mo.observe(document.documentElement, { attributes: true, attributeFilter: ["class", "style", "data-theme"] });
151
+ return () => mo.disconnect();
152
+ }, []);
153
+ return { ref, override };
154
+ }
155
+
68
156
  function Swatch({ name, var: v, bg, fg }: { name: string; var: string; bg: string; fg?: string }) {
157
+ const { ref, override } = useReadableLabel();
69
158
  return (
70
159
  <div className="flex flex-col">
71
- <div className={`h-20 rounded-lg border border-border ${bg} ${fg ?? ""} flex items-end p-2.5`}>
160
+ <div
161
+ ref={ref}
162
+ data-swatch-label={name}
163
+ className={`h-20 rounded-lg border border-border ${bg} ${fg ?? ""} flex items-end p-2.5`}
164
+ style={override ? { color: override } : undefined}
165
+ >
72
166
  <span className="text-sm font-medium">{name}</span>
73
167
  </div>
74
168
  <p className="text-xs text-muted-foreground font-mono mt-1.5">{v}</p>
@@ -77,6 +171,23 @@ function Swatch({ name, var: v, bg, fg }: { name: string; var: string; bg: strin
77
171
  }
78
172
 
79
173
  export const All: Story = {
174
+ // Axe does not fail a story test in this repo, so the story checks its own
175
+ // promise: every label reads at 4.5:1 or better on the colour behind it.
176
+ play: async ({ canvasElement }) => {
177
+ const labels = [...canvasElement.querySelectorAll<HTMLElement>("[data-swatch-label]")];
178
+ await expect(labels.length).toBeGreaterThan(0);
179
+ await waitFor(() => {
180
+ const failing = labels
181
+ .map((el) => {
182
+ const bg = paintedBackground(el);
183
+ const fg = toRGBA(getComputedStyle(el).color);
184
+ return { name: el.dataset.swatchLabel, r: fg ? ratio(over(fg, bg), bg) : 0 };
185
+ })
186
+ .filter((x) => x.r < MIN_RATIO)
187
+ .map((x) => `${x.name} ${x.r.toFixed(2)}:1`);
188
+ expect(failing).toEqual([]);
189
+ });
190
+ },
80
191
  render: () => (
81
192
  <div className="p-8 space-y-8 bg-background">
82
193
  {Object.entries(GROUPS).map(([title, swatches]) => (
@@ -32,6 +32,11 @@ import { BadsUpdateBanner } from "@behavioral-agentic-design-system/core/compone
32
32
  import { RecentlyAdded, type RecentItem } from "./home-recent";
33
33
  import registry from "@/layer-5-component-registry/component-registry.json";
34
34
  import tokens from "@/packages/core/src/tokens.json";
35
+ // An import, not require(): require is CommonJS and does not exist in a browser, so the
36
+ // component threw "require is not defined" in every browser-based story test. A fork
37
+ // resolves this path to its own packages/core/package.json, whose version mirrors the
38
+ // @core version it consumes.
39
+ import corePackage from "@/packages/core/package.json";
35
40
  import {
36
41
  AUTOMATION_COUNT,
37
42
  visibleDocGroups,
@@ -311,7 +316,7 @@ export function HomeTab({ onBrowseDocs, onBrowseComponents, onOpenRecent }: Home
311
316
  <Sparkles className="size-4 text-primary" strokeWidth={1.5} />
312
317
  <span className="font-mono uppercase tracking-wide">{brand.name}</span>
313
318
  <Badge variant="secondary" className="ml-1">
314
- v{require("@/packages/core/package.json").version}
319
+ v{corePackage.version}
315
320
  </Badge>
316
321
  </div>
317
322
  <h1 className="text-4xl font-semibold tracking-tight sm:text-5xl">
@@ -1092,7 +1092,7 @@ export function OnboardingWizard({
1092
1092
  label="Industry or category"
1093
1093
  value={draft.industry}
1094
1094
  onChange={(industry) => updateDraft({ industry })}
1095
- placeholder="Healthcare, education, devtools, fintech..."
1095
+ placeholder="Healthcare, education, devtools, fintech…"
1096
1096
  />
1097
1097
  <TextField
1098
1098
  id="onboarding-audience"
@@ -89,6 +89,10 @@ function AvatarGroup({ className, ...props }: React.ComponentProps<"div">) {
89
89
  return (
90
90
  <div
91
91
  data-slot="avatar-group"
92
+ // A named group, so a screen reader announces "Project contributors, group"
93
+ // instead of a run of unrelated images. Pass aria-label (required) and
94
+ // override role if the group is a list in your layout.
95
+ role="group"
92
96
  className={cn(
93
97
  "group/avatar-group flex -space-x-2 *:data-[slot=avatar]:ring-2 *:data-[slot=avatar]:ring-background",
94
98
  className