@behavioral-agentic-design-system/core 0.45.0 → 0.48.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 (240) 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 +183 -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/number-field.tsx +390 -0
  70. package/src/components/ui/radio-group.tsx +2 -2
  71. package/src/components/ui/sparkline.tsx +33 -4
  72. package/src/components/ui/spinner.tsx +23 -4
  73. package/src/components/ui/table.tsx +9 -0
  74. package/src/components/ui/week-picker.tsx +0 -12
  75. package/src/data/component-added.json +12 -0
  76. package/src/data/docs-index.ts +22 -1
  77. package/src/data/history.json +162 -162
  78. package/src/data/sticker-sheet.json +9297 -0
  79. package/src/docs-trace-globs.json +1 -0
  80. package/src/lib/chart-motion.ts +41 -0
  81. package/src/lib/get-icon-color.ts +1 -1
  82. package/src/stories/Accordion.stories.tsx +7 -0
  83. package/src/stories/ActionBar.stories.tsx +5 -0
  84. package/src/stories/Affix.stories.tsx +4 -0
  85. package/src/stories/AiBadge.stories.tsx +9 -7
  86. package/src/stories/Alert.stories.tsx +13 -0
  87. package/src/stories/AlertDialog.stories.tsx +4 -0
  88. package/src/stories/Anchor.stories.tsx +5 -0
  89. package/src/stories/AngleSlider.stories.tsx +6 -3
  90. package/src/stories/AspectRatio.stories.tsx +4 -0
  91. package/src/stories/Autocomplete.stories.tsx +6 -0
  92. package/src/stories/Avatar.stories.tsx +10 -0
  93. package/src/stories/Badge.stories.tsx +14 -6
  94. package/src/stories/Blockquote.stories.tsx +6 -0
  95. package/src/stories/BottomNavigation.stories.tsx +4 -0
  96. package/src/stories/Breadcrumb.stories.tsx +3 -0
  97. package/src/stories/Burger.stories.tsx +1 -0
  98. package/src/stories/Button.stories.tsx +24 -0
  99. package/src/stories/ButtonGroup.stories.tsx +9 -0
  100. package/src/stories/Calendar.stories.tsx +3 -0
  101. package/src/stories/Card.stories.tsx +4 -0
  102. package/src/stories/Carousel.stories.tsx +6 -0
  103. package/src/stories/Cascader.stories.tsx +4 -0
  104. package/src/stories/Chart.stories.tsx +46 -1
  105. package/src/stories/ChatBubble.stories.tsx +8 -2
  106. package/src/stories/ChatMarker.stories.tsx +1 -0
  107. package/src/stories/Checkbox.stories.tsx +40 -0
  108. package/src/stories/CheckboxCard.stories.tsx +8 -0
  109. package/src/stories/CheckboxGroup.stories.tsx +20 -0
  110. package/src/stories/Chip.stories.tsx +10 -19
  111. package/src/stories/CircularProgress.stories.tsx +13 -27
  112. package/src/stories/Clipboard.stories.tsx +6 -0
  113. package/src/stories/CloseButton.stories.tsx +6 -4
  114. package/src/stories/Code.stories.tsx +8 -1
  115. package/src/stories/Collapsible.stories.tsx +2 -0
  116. package/src/stories/ColorPicker.stories.tsx +6 -0
  117. package/src/stories/ColorSwatch.stories.tsx +1 -0
  118. package/src/stories/Combobox.stories.tsx +9 -0
  119. package/src/stories/Command.stories.tsx +2 -0
  120. package/src/stories/Container.stories.tsx +8 -0
  121. package/src/stories/ContextMenu.stories.tsx +9 -0
  122. package/src/stories/CopyButton.stories.tsx +12 -36
  123. package/src/stories/DataList.stories.tsx +8 -0
  124. package/src/stories/DataTable.stories.tsx +9 -0
  125. package/src/stories/DateField.stories.tsx +7 -0
  126. package/src/stories/DatePicker.stories.tsx +34 -0
  127. package/src/stories/DateRangePicker.stories.tsx +32 -0
  128. package/src/stories/Dialog.stories.tsx +8 -0
  129. package/src/stories/Drawer.stories.tsx +6 -0
  130. package/src/stories/DropdownMenu.stories.tsx +2 -0
  131. package/src/stories/Editable.stories.tsx +10 -0
  132. package/src/stories/EmptyState.stories.tsx +9 -0
  133. package/src/stories/Field.stories.tsx +7 -0
  134. package/src/stories/Fieldset.stories.tsx +8 -0
  135. package/src/stories/FileButton.stories.tsx +4 -0
  136. package/src/stories/FileUpload.stories.tsx +16 -17
  137. package/src/stories/FloatLabel.stories.tsx +3 -8
  138. package/src/stories/FloatingActionButton.stories.tsx +10 -0
  139. package/src/stories/FloatingIndicator.stories.tsx +4 -0
  140. package/src/stories/FloatingPanel.stories.tsx +6 -0
  141. package/src/stories/FocusTrap.stories.tsx +5 -0
  142. package/src/stories/FormatByte.stories.tsx +6 -0
  143. package/src/stories/FormatDate.stories.tsx +8 -0
  144. package/src/stories/FormatNumber.stories.tsx +9 -0
  145. package/src/stories/Heatmap.stories.tsx +11 -0
  146. package/src/stories/Highlight.stories.tsx +6 -0
  147. package/src/stories/HoverCard.stories.tsx +4 -0
  148. package/src/stories/Image.stories.tsx +9 -0
  149. package/src/stories/Indicator.stories.tsx +19 -0
  150. package/src/stories/Input.stories.tsx +7 -0
  151. package/src/stories/InputClearButton.stories.tsx +3 -0
  152. package/src/stories/InputGroup.stories.tsx +40 -0
  153. package/src/stories/Kbd.stories.tsx +7 -1
  154. package/src/stories/KeyboardShortcut.stories.tsx +2 -0
  155. package/src/stories/Label.stories.tsx +2 -0
  156. package/src/stories/Link.stories.tsx +9 -0
  157. package/src/stories/List.stories.tsx +8 -0
  158. package/src/stories/Listbox.stories.tsx +1 -0
  159. package/src/stories/LoadingDots.stories.tsx +5 -3
  160. package/src/stories/LoadingOverlay.stories.tsx +5 -1
  161. package/src/stories/Mark.stories.tsx +5 -0
  162. package/src/stories/Marquee.stories.tsx +4 -0
  163. package/src/stories/Masonry.stories.tsx +5 -0
  164. package/src/stories/Menubar.stories.tsx +3 -0
  165. package/src/stories/Meter.stories.tsx +11 -17
  166. package/src/stories/MonthPicker.stories.tsx +5 -1
  167. package/src/stories/MotionToggle.stories.tsx +1 -0
  168. package/src/stories/MultiSelect.stories.tsx +9 -0
  169. package/src/stories/NativeSelect.stories.tsx +1 -0
  170. package/src/stories/NavLink.stories.tsx +7 -0
  171. package/src/stories/NavigationMenu.stories.tsx +5 -0
  172. package/src/stories/NavigationRail.stories.tsx +10 -0
  173. package/src/stories/Notification.stories.tsx +13 -34
  174. package/src/stories/NumberField.stories.tsx +214 -0
  175. package/src/stories/NumberInput.stories.tsx +8 -1
  176. package/src/stories/Overlay.stories.tsx +5 -1
  177. package/src/stories/Pagination.stories.tsx +8 -0
  178. package/src/stories/PasswordInput.stories.tsx +2 -0
  179. package/src/stories/PinInput.stories.tsx +9 -2
  180. package/src/stories/Popover.stories.tsx +2 -0
  181. package/src/stories/Progress.stories.tsx +6 -1
  182. package/src/stories/Prose.stories.tsx +8 -0
  183. package/src/stories/QrCode.stories.tsx +2 -0
  184. package/src/stories/Questionnaire.stories.tsx +7 -0
  185. package/src/stories/RadioGroup.stories.tsx +40 -0
  186. package/src/stories/RatingGroup.stories.tsx +8 -4
  187. package/src/stories/Resizable.stories.tsx +4 -2
  188. package/src/stories/Result.stories.tsx +3 -0
  189. package/src/stories/Reveal.stories.tsx +2 -0
  190. package/src/stories/RollingNumber.stories.tsx +5 -0
  191. package/src/stories/ScrollArea.stories.tsx +3 -1
  192. package/src/stories/SearchInput.stories.tsx +8 -6
  193. package/src/stories/SegmentedControl.stories.tsx +11 -0
  194. package/src/stories/Select.stories.tsx +7 -0
  195. package/src/stories/Separator.stories.tsx +6 -0
  196. package/src/stories/Sheet.stories.tsx +5 -0
  197. package/src/stories/Sidebar.stories.tsx +40 -1
  198. package/src/stories/SimpleGrid.stories.tsx +5 -0
  199. package/src/stories/Skeleton.stories.tsx +8 -0
  200. package/src/stories/SkeletonTable.stories.tsx +6 -5
  201. package/src/stories/SkipLink.stories.tsx +3 -0
  202. package/src/stories/Slider.stories.tsx +2 -1
  203. package/src/stories/Sonner.stories.tsx +7 -0
  204. package/src/stories/Sparkline.stories.tsx +14 -1
  205. package/src/stories/Spinner.stories.tsx +20 -10
  206. package/src/stories/Spoiler.stories.tsx +5 -0
  207. package/src/stories/Squircle.stories.tsx +7 -0
  208. package/src/stories/Stack.stories.tsx +7 -0
  209. package/src/stories/StatusBadge.stories.tsx +12 -6
  210. package/src/stories/Stepper.stories.tsx +5 -0
  211. package/src/stories/Switch.stories.tsx +4 -0
  212. package/src/stories/Table.stories.tsx +10 -1
  213. package/src/stories/Tabs.stories.tsx +8 -0
  214. package/src/stories/Tag.stories.tsx +13 -5
  215. package/src/stories/TagsInput.stories.tsx +13 -0
  216. package/src/stories/Text.stories.tsx +12 -0
  217. package/src/stories/Textarea.stories.tsx +9 -0
  218. package/src/stories/ThemeIcon.stories.tsx +6 -3
  219. package/src/stories/TimePicker.stories.tsx +2 -0
  220. package/src/stories/Timeline.stories.tsx +12 -0
  221. package/src/stories/Timer.stories.tsx +4 -0
  222. package/src/stories/Toggle.stories.tsx +7 -5
  223. package/src/stories/ToggleGroup.stories.tsx +5 -0
  224. package/src/stories/ToggleTip.stories.tsx +4 -0
  225. package/src/stories/Toolbar.stories.tsx +6 -0
  226. package/src/stories/Tooltip.stories.tsx +3 -0
  227. package/src/stories/Tour.stories.tsx +3 -0
  228. package/src/stories/TransferList.stories.tsx +3 -0
  229. package/src/stories/TreeSelect.stories.tsx +4 -0
  230. package/src/stories/TreeView.stories.tsx +5 -0
  231. package/src/stories/TypingIndicator.stories.tsx +4 -0
  232. package/src/stories/VisuallyHidden.stories.tsx +3 -0
  233. package/src/stories/Watermark.stories.tsx +6 -0
  234. package/src/stories/WeekPicker.stories.tsx +4 -1
  235. package/src/stories/WordRotate.stories.tsx +5 -0
  236. package/src/stories/YearPicker.stories.tsx +5 -11
  237. package/src/stories/story-groups.json +2 -1
  238. package/src/styles.css +50 -2
  239. package/src/tokens.json +4 -4
  240. package/LICENSE +0 -21
@@ -124,6 +124,9 @@ import { FloatingPanel } from "@behavioral-agentic-design-system/core/components
124
124
  import { NumberInput } from "@behavioral-agentic-design-system/core/components/ui/number-input";
125
125
  import { InlineEdit } from "@behavioral-agentic-design-system/core/components/ui/inline-edit";
126
126
  import { OTPInput } from "@behavioral-agentic-design-system/core/components/ui/otp-input";
127
+ import { NumberField } from "@behavioral-agentic-design-system/core/components/ui/number-field";
128
+ import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@behavioral-agentic-design-system/core/components/ui/collapsible";
129
+ import { ChevronDownIcon } from "lucide-react";
127
130
  import { FileUpload } from "@behavioral-agentic-design-system/core/components/ui/file-upload";
128
131
  import { Spinner } from "@behavioral-agentic-design-system/core/components/ui/spinner";
129
132
  import { CircularProgress } from "@behavioral-agentic-design-system/core/components/ui/circular-progress";
@@ -1634,7 +1637,7 @@ export default function ComponentsPreview() {
1634
1637
  <div className="space-y-4">
1635
1638
  {(["sm", "default", "lg"] as const).map((size) => (
1636
1639
  <div key={size} className="space-y-1">
1637
- <p className="text-xs text-muted-foreground/60">size=&quot;{size}&quot;</p>
1640
+ <p className="text-xs text-muted-foreground">size=&quot;{size}&quot;</p>
1638
1641
  <Pagination size={size}>
1639
1642
  <PaginationContent>
1640
1643
  <PaginationItem><PaginationPrevious href="#" /></PaginationItem>
@@ -2019,9 +2022,8 @@ export default function ComponentsPreview() {
2019
2022
  <span className="text-xs text-muted-foreground">muted</span>
2020
2023
  </div>
2021
2024
  <div className="flex flex-col items-center gap-2">
2022
- <div className="flex size-16 items-center justify-center rounded-md bg-primary">
2023
- {/* [&>svg] targets the SVG directly since className on Spinner goes to the wrapper span */}
2024
- <Spinner variant="primary" className="[&>svg]:text-primary-foreground" />
2025
+ <div className="flex size-16 items-center justify-center rounded-md border bg-card">
2026
+ <Spinner variant="primary" />
2025
2027
  </div>
2026
2028
  <span className="text-xs text-muted-foreground">primary</span>
2027
2029
  </div>
@@ -2032,7 +2034,7 @@ export default function ComponentsPreview() {
2032
2034
  <p className="text-sm font-medium text-muted-foreground">Button loading state</p>
2033
2035
  <div className="flex flex-wrap items-center gap-3">
2034
2036
  <Button disabled className="gap-2">
2035
- <Spinner size="xs" className="text-primary-foreground" label="Saving" />
2037
+ <Spinner size="xs" label="Saving" />
2036
2038
  Saving changes…
2037
2039
  </Button>
2038
2040
  <Button variant="outline" disabled className="gap-2">
@@ -3037,7 +3039,7 @@ export default function ComponentsPreview() {
3037
3039
  </Section>
3038
3040
 
3039
3041
  <Section title="Table">
3040
- <Table>
3042
+ <Table aria-label="Design System Team contributions, Q2">
3041
3043
  <TableCaption>Design System Team — Q2 contributions</TableCaption>
3042
3044
  <TableHeader>
3043
3045
  <TableRow>
@@ -4250,7 +4252,7 @@ export default function ComponentsPreview() {
4250
4252
  <ColorSwatch color="#171717" size="lg" aria-label="Selected: near-black">
4251
4253
  <CheckIcon strokeWidth={1.5} className="text-white" />
4252
4254
  </ColorSwatch>
4253
- {/* Picker's own label pattern (see CLAUDE.md -> Customize Tab):
4255
+ {/* Picker's own label pattern (see AGENTS.md -> Customize Tab):
4254
4256
  shows the user's raw hex pick back as text, not a style
4255
4257
  value — SC 1.4.6 doesn't apply to displayed data. */}
4256
4258
  <span className="tabular-nums text-muted-foreground">
@@ -6447,6 +6449,12 @@ export default function ComponentsPreview() {
6447
6449
  <Section title="OTPInput">
6448
6450
  <OTPInputShowcase />
6449
6451
  </Section>
6452
+ <Section title="Collapsible">
6453
+ <CollapsibleShowcase />
6454
+ </Section>
6455
+ <Section title="NumberField">
6456
+ <NumberFieldShowcase />
6457
+ </Section>
6450
6458
  </div>
6451
6459
  </div>
6452
6460
  );
@@ -11858,7 +11866,7 @@ function LoadingDotsShowcase() {
11858
11866
  <LoadingDots size="xs" aria-label="Saving" />
11859
11867
  </Button>
11860
11868
  <p className="flex items-center gap-2 text-sm text-muted-foreground">
11861
- Fetching results <LoadingDots size="sm" color="muted" />
11869
+ Fetching results <LoadingDots size="sm" tone="muted" />
11862
11870
  </p>
11863
11871
  <div className="flex h-12 w-full items-center justify-center rounded-md border border-dashed">
11864
11872
  <LoadingDots tone="muted" aria-label="Loading content" />
@@ -12472,12 +12480,21 @@ function SparklineShowcase() {
12472
12480
  <p className="mb-3 text-xs font-medium text-muted-foreground">
12473
12481
  withDot — marks last data point
12474
12482
  </p>
12475
- <Sparkline
12476
- data={revenueData}
12477
- withDot
12478
- className="w-40"
12479
- aria-label="Monthly revenue trend with current-value dot"
12480
- />
12483
+ <div className="flex gap-4">
12484
+ <Sparkline
12485
+ data={revenueData}
12486
+ withDot
12487
+ className="w-40"
12488
+ aria-label="Monthly revenue trend with current-value dot"
12489
+ />
12490
+ <Sparkline
12491
+ data={revenueData}
12492
+ type="line"
12493
+ withDot
12494
+ className="w-40"
12495
+ aria-label="Monthly revenue line with current-value dot"
12496
+ />
12497
+ </div>
12481
12498
  </div>
12482
12499
 
12483
12500
  <div>
@@ -15291,3 +15308,155 @@ function OTPInputShowcase() {
15291
15308
  </div>
15292
15309
  )
15293
15310
  }
15311
+
15312
+ function CollapsibleShowcase() {
15313
+ const [open, setOpen] = React.useState(false)
15314
+ return (
15315
+ <div className="flex flex-col gap-6">
15316
+ <div className="flex flex-col items-start gap-3">
15317
+ <p className="text-xs font-medium text-muted-foreground">Default — closed, one disclosure</p>
15318
+ <Collapsible className="w-full max-w-md rounded-lg border p-4">
15319
+ <CollapsibleTrigger asChild>
15320
+ <Button variant="ghost" size="xl" className="group w-full justify-between px-3">
15321
+ What changed in this release
15322
+ <ChevronDownIcon strokeWidth={1.5} className="size-5 transition-transform group-data-[state=open]:rotate-180" />
15323
+ </Button>
15324
+ </CollapsibleTrigger>
15325
+ <CollapsibleContent className="px-3 pt-2 text-sm text-muted-foreground">
15326
+ Variants and sizes now match the registry, upload rejections are announced to screen readers, and
15327
+ the date fields stay controlled when they start empty.
15328
+ </CollapsibleContent>
15329
+ </Collapsible>
15330
+ </div>
15331
+ <div className="flex flex-col items-start gap-3">
15332
+ <p className="text-xs font-medium text-muted-foreground">Open by default</p>
15333
+ <Collapsible defaultOpen className="w-full max-w-md rounded-lg border p-4">
15334
+ <CollapsibleTrigger asChild>
15335
+ <Button variant="ghost" size="xl" className="group w-full justify-between px-3">
15336
+ Accessibility floor
15337
+ <ChevronDownIcon strokeWidth={1.5} className="size-5 transition-transform group-data-[state=open]:rotate-180" />
15338
+ </Button>
15339
+ </CollapsibleTrigger>
15340
+ <CollapsibleContent className="px-3 pt-2 text-sm text-muted-foreground">
15341
+ 7:1 text contrast, 44px touch targets, and a visible focus ring on every control.
15342
+ </CollapsibleContent>
15343
+ </Collapsible>
15344
+ </div>
15345
+ <div className="flex flex-col items-start gap-3">
15346
+ <p className="text-xs font-medium text-muted-foreground">Disabled</p>
15347
+ <Collapsible disabled className="w-full max-w-md rounded-lg border p-4">
15348
+ <CollapsibleTrigger asChild>
15349
+ <Button variant="ghost" size="xl" className="group w-full justify-between px-3" disabled>
15350
+ Details unavailable
15351
+ <ChevronDownIcon strokeWidth={1.5} className="size-5" />
15352
+ </Button>
15353
+ </CollapsibleTrigger>
15354
+ <CollapsibleContent className="px-3 pt-2 text-sm text-muted-foreground">Hidden.</CollapsibleContent>
15355
+ </Collapsible>
15356
+ </div>
15357
+ <div className="flex flex-col items-start gap-3">
15358
+ <p className="text-xs font-medium text-muted-foreground">Realistic use — controlled, with a count</p>
15359
+ <Collapsible open={open} onOpenChange={setOpen} className="w-full max-w-md rounded-lg border p-4">
15360
+ <div className="flex items-center justify-between gap-3">
15361
+ <p className="text-sm font-medium">3 reviews waiting on you</p>
15362
+ <CollapsibleTrigger asChild>
15363
+ <Button variant="outline" size="xl">
15364
+ {open ? "Hide details" : "Show details"}
15365
+ </Button>
15366
+ </CollapsibleTrigger>
15367
+ </div>
15368
+ <CollapsibleContent className="mt-3 flex flex-col gap-2 text-sm text-muted-foreground">
15369
+ <p>Priya Nair: table row spacing at the dense size.</p>
15370
+ <p>Theo Okafor: focus ring on the date field.</p>
15371
+ <p>Seo-yun Park: new variant for the tag primitive.</p>
15372
+ </CollapsibleContent>
15373
+ </Collapsible>
15374
+ </div>
15375
+ </div>
15376
+ )
15377
+ }
15378
+
15379
+ function NumberFieldShowcase() {
15380
+ const [quantity, setQuantity] = React.useState(2);
15381
+ const [price, setPrice] = React.useState(49.0);
15382
+ const [discount, setDiscount] = React.useState(25);
15383
+ const total = quantity * price * (1 - discount / 100);
15384
+
15385
+ return (
15386
+ <div className="space-y-8">
15387
+ <div className="flex flex-wrap gap-6 items-start">
15388
+ <div className="w-56">
15389
+ <NumberField label="Quantity" defaultValue={1} min={1} max={99} size="sm" />
15390
+ </div>
15391
+ <div className="w-56">
15392
+ <NumberField label="Quantity" defaultValue={1} min={1} max={99} />
15393
+ </div>
15394
+ <div className="w-56">
15395
+ <NumberField label="Quantity" defaultValue={1} min={1} max={99} size="lg" />
15396
+ </div>
15397
+ </div>
15398
+ <div className="flex flex-wrap gap-6 items-start">
15399
+ <div className="w-64">
15400
+ <NumberField
15401
+ label="Price"
15402
+ defaultValue={29.99}
15403
+ step={0.01}
15404
+ min={0}
15405
+ formatOptions={{ style: "currency", currency: "USD" }}
15406
+ helperText="Enter price before tax"
15407
+ />
15408
+ </div>
15409
+ <div className="w-64">
15410
+ <NumberField
15411
+ label="Discount"
15412
+ defaultValue={0}
15413
+ min={0}
15414
+ max={100}
15415
+ step={5}
15416
+ formatOptions={{ style: "percent", maximumFractionDigits: 0 }}
15417
+ errorMessage="Value must be between 0 and 100"
15418
+ />
15419
+ </div>
15420
+ <div className="w-64">
15421
+ <NumberField label="Seat count" defaultValue={5} disabled helperText="Set during checkout" />
15422
+ </div>
15423
+ </div>
15424
+ <div className="w-80 flex flex-col gap-5 rounded-lg border p-5">
15425
+ <p className="text-sm font-medium text-foreground">Order summary</p>
15426
+ <NumberField
15427
+ label="Quantity"
15428
+ value={quantity}
15429
+ onChange={setQuantity}
15430
+ min={1}
15431
+ max={99}
15432
+ required
15433
+ helperText="Maximum 99 per order"
15434
+ />
15435
+ <NumberField
15436
+ label="Unit price"
15437
+ value={price}
15438
+ onChange={setPrice}
15439
+ step={0.01}
15440
+ min={0}
15441
+ formatOptions={{ style: "currency", currency: "USD" }}
15442
+ />
15443
+ <NumberField
15444
+ label="Discount"
15445
+ value={discount}
15446
+ onChange={setDiscount}
15447
+ min={0}
15448
+ max={100}
15449
+ step={5}
15450
+ formatOptions={{ style: "percent", maximumFractionDigits: 0 }}
15451
+ helperText="Applied at checkout"
15452
+ />
15453
+ <div className="flex justify-between text-sm pt-2 border-t border-border">
15454
+ <span className="text-muted-foreground">Total</span>
15455
+ <span className="font-medium tabular-nums">
15456
+ {new Intl.NumberFormat("en-US", { style: "currency", currency: "USD" }).format(total)}
15457
+ </span>
15458
+ </div>
15459
+ </div>
15460
+ </div>
15461
+ )
15462
+ }
@@ -0,0 +1,329 @@
1
+ "use client";
2
+
3
+ // Sticker sheet: every registered component, every declared state, light and
4
+ // dark, with the measured contrast beside it. The registry supplies the list,
5
+ // data/sticker-sheet.json (generated from wcag-audit --json) supplies every
6
+ // number, and specimens.tsx supplies the states. A registry key with no
7
+ // specimen renders as a dashed "not defined" box, never as a blank.
8
+ import * as React from "react";
9
+ import registry from "@/layer-5-component-registry/component-registry.json";
10
+ import data from "../../../data/sticker-sheet.json";
11
+ import { SPECIMENS, STATE_LABEL, stateAttrs, type Specimen } from "./specimens";
12
+
13
+ type Theme = "light" | "dark";
14
+ type Pair = (typeof data.contrast)[number];
15
+ type TokenMap = Record<string, { hex: string; alpha?: number }>;
16
+
17
+ const THEMES: Theme[] = ["light", "dark"];
18
+
19
+ interface StoryEntry {
20
+ id: string;
21
+ name: string;
22
+ }
23
+ interface StoryGroup {
24
+ title: string;
25
+ entries: StoryEntry[];
26
+ }
27
+ const STORIES = data.stories as Record<string, StoryGroup>;
28
+ const OTHER_STORIES = data.otherStories as StoryGroup[];
29
+
30
+ // Same resolution the shell uses for its Storybook link: a fork can point
31
+ // NEXT_PUBLIC_STORYBOOK_URL at its own deploy, dev uses the local server, and
32
+ // production uses the static build served same-origin.
33
+ const STORYBOOK_BASE = (
34
+ process.env.NEXT_PUBLIC_STORYBOOK_URL ??
35
+ (process.env.NODE_ENV === "development"
36
+ ? "http://localhost:6080"
37
+ : `/storybook/${process.env.NEXT_PUBLIC_STORYBOOK_VERSION || "dev"}`)
38
+ ).replace(/\/index\.html$/, "").replace(/\/$/, "");
39
+
40
+ const storyHref = (id: string) => `${STORYBOOK_BASE}/?path=/story/${id}`;
41
+ const storyFrame = (id: string, theme: Theme) => `${STORYBOOK_BASE}/iframe.html?id=${id}&viewMode=story&globals=theme:${theme}`;
42
+
43
+ // ~1,600 stories x 2 themes is far too many live iframes for one page (headless
44
+ // Chromium crashes). Mount a pair only while its cell is within ~1.5 screens of
45
+ // the viewport and drop it again after it leaves, so memory stays bounded and
46
+ // scrolling still lands on a loaded frame.
47
+ //
48
+ // `?all=1` mounts every frame up front with native loading="lazy"; the static
49
+ // export (scripts/export-sticker-sheet.mjs) uses it so the saved HTML carries
50
+ // every frame's src.
51
+ function useNearViewport<T extends Element>() {
52
+ const ref = React.useRef<T>(null);
53
+ const [near, setNear] = React.useState(false);
54
+ React.useEffect(() => {
55
+ const el = ref.current;
56
+ if (!el || typeof IntersectionObserver === "undefined" || new URLSearchParams(window.location.search).has("all")) {
57
+ setNear(true);
58
+ return;
59
+ }
60
+ const io = new IntersectionObserver(([entry]) => setNear(entry.isIntersecting), { rootMargin: "1400px 0px" });
61
+ io.observe(el);
62
+ return () => io.disconnect();
63
+ }, []);
64
+ return [ref, near] as const;
65
+ }
66
+
67
+ function StoryCell({ entry }: { entry: StoryEntry }) {
68
+ const [ref, near] = useNearViewport<HTMLDivElement>();
69
+ // Whole-screen stories need room; a single control does not. The frame is
70
+ // resizable either way, and Storybook is one click away for the rest.
71
+ const tall = /realistic|screen|page|layout|dashboard/i.test(entry.name);
72
+ const height = tall ? "h-96" : "h-44";
73
+ return (
74
+ <div className="flex min-w-0 flex-col gap-2" data-story={entry.id}>
75
+ <div className="flex flex-wrap items-baseline justify-between gap-x-3">
76
+ <h4 className="text-sm font-medium">{entry.name}</h4>
77
+ <a href={storyHref(entry.id)} target="_blank" rel="noreferrer" className="inline-flex min-h-11 items-center text-xs underline underline-offset-4">
78
+ Open in Storybook
79
+ </a>
80
+ </div>
81
+ <div ref={ref} className="grid gap-3 sm:grid-cols-2">
82
+ {THEMES.map((theme) =>
83
+ near ? (
84
+ <iframe
85
+ key={theme}
86
+ loading="lazy"
87
+ src={storyFrame(entry.id, theme)}
88
+ title={`${entry.name}, ${theme}`}
89
+ className={`${height} w-full resize-y rounded-md border border-border bg-background`}
90
+ />
91
+ ) : (
92
+ <div key={theme} aria-hidden className={`${height} w-full rounded-md border border-dashed border-border`} />
93
+ ),
94
+ )}
95
+ </div>
96
+ </div>
97
+ );
98
+ }
99
+
100
+ function StoryList({ group }: { group: StoryGroup }) {
101
+ return (
102
+ <div className="flex flex-col gap-6">
103
+ {group.entries.map((e) => (
104
+ <StoryCell key={e.id} entry={e} />
105
+ ))}
106
+ </div>
107
+ );
108
+ }
109
+ const TOKENS = data.tokens as Record<Theme, TokenMap>;
110
+
111
+ function pairFor(theme: Theme, key: string): Pair | undefined {
112
+ const [fg, bg] = key.split("|");
113
+ return data.contrast.find((p) => p.mode === theme && p.fgKey === fg && p.bgKey === bg);
114
+ }
115
+
116
+ function Verdict({ pair }: { pair: Pair | undefined }) {
117
+ if (!pair) return <span className="rounded border border-dashed border-border px-2 py-0.5 text-xs text-muted-foreground">not audited</span>;
118
+ const pass = pair.ratio >= pair.floor;
119
+ return (
120
+ <span className="tabular-nums">
121
+ {pair.ratio.toFixed(2)}:1 <span className="text-muted-foreground">/ {pair.floor}:1</span>{" "}
122
+ <span className="font-semibold">{pass ? "pass" : "FAIL"}</span>
123
+ </span>
124
+ );
125
+ }
126
+
127
+ function Swatch({ token, theme }: { token: string; theme: Theme }) {
128
+ const entry = TOKENS[theme][token];
129
+ return (
130
+ <li className="flex items-center gap-2">
131
+ {/* lint-disable: checkbox-bypass a square token color chip, not a control */}
132
+ <span aria-hidden className="size-4 shrink-0 rounded-sm border border-border" style={{ background: `var(--${token})` }} />
133
+ <code className="text-xs">{token}</code>
134
+ <span className="text-xs text-muted-foreground tabular-nums">{entry ? `${entry.hex}${entry.alpha ? ` @ ${entry.alpha}` : ""}` : "unresolved"}</span>
135
+ </li>
136
+ );
137
+ }
138
+
139
+ function Band({ name, specimen, theme }: { name: string; specimen: Specimen; theme: Theme }) {
140
+ const rows = specimen.variants ?? [{ label: "default", props: {} }];
141
+ return (
142
+ <div
143
+ data-theme-band={theme}
144
+ className={`${theme === "dark" ? "dark " : ""}rounded-lg border border-border bg-background p-6 text-foreground`}
145
+ >
146
+ <p className="mb-4 text-xs font-medium uppercase tracking-wide text-muted-foreground">{theme}</p>
147
+ <div className="flex flex-col gap-6">
148
+ {rows.map((row) => (
149
+ <div key={row.label}>
150
+ {specimen.variants && <p className="mb-2 text-sm font-medium">{row.label}</p>}
151
+ <div className="flex flex-wrap gap-x-8 gap-y-5">
152
+ {specimen.states.map((state) => (
153
+ <div key={state} className="flex min-w-0 flex-col gap-2" data-specimen={`${theme}:${name}:${row.label}:${state}`}>
154
+ <span className="text-xs text-muted-foreground">{STATE_LABEL[state]}</span>
155
+ <div className="min-h-11 overflow-hidden p-1">
156
+ {specimen.render({ variant: row.props ?? {}, state, attrs: stateAttrs(state) })}
157
+ </div>
158
+ </div>
159
+ ))}
160
+ </div>
161
+ </div>
162
+ ))}
163
+ </div>
164
+ {specimen.limits?.map((note) => (
165
+ <p key={note} className="mt-4 rounded-md border border-dashed border-border p-3 text-xs text-muted-foreground">
166
+ Pinning limit: {note}
167
+ </p>
168
+ ))}
169
+ <div className="mt-6 grid gap-6 border-t border-border pt-4 sm:grid-cols-2">
170
+ <div>
171
+ <p className="mb-2 text-xs font-medium uppercase tracking-wide text-muted-foreground">Contrast</p>
172
+ <ul className="flex flex-col gap-1 text-xs">
173
+ {specimen.pairs.map((key) => (
174
+ <li key={key} className="flex flex-wrap items-baseline justify-between gap-x-3">
175
+ <code>{key.replace("|", " on ")}</code>
176
+ <Verdict pair={pairFor(theme, key)} />
177
+ </li>
178
+ ))}
179
+ </ul>
180
+ </div>
181
+ <div>
182
+ <p className="mb-2 text-xs font-medium uppercase tracking-wide text-muted-foreground">Tokens</p>
183
+ <ul className="flex flex-col gap-1">
184
+ {specimen.tokens.map((t) => (
185
+ <Swatch key={t} token={t} theme={theme} />
186
+ ))}
187
+ </ul>
188
+ </div>
189
+ </div>
190
+ </div>
191
+ );
192
+ }
193
+
194
+ export default function StickerSheetPage() {
195
+ // The sheet shows both themes itself, so the document must be light: the
196
+ // light band reads :root, and a dark document would repaint it. Runs after
197
+ // DarkModeClient's effect, so it wins over ?dark=1.
198
+ React.useEffect(() => {
199
+ document.documentElement.classList.remove("dark");
200
+ }, []);
201
+
202
+ const [query, setQuery] = React.useState("");
203
+ const deferred = React.useDeferredValue(query.trim().toLowerCase());
204
+
205
+ const keys = Object.keys(registry as Record<string, unknown>);
206
+ const noStories = keys.filter((k) => !STORIES[k] && !SPECIMENS[k]);
207
+ const pinned = keys.filter((k) => SPECIMENS[k]);
208
+ const storyCount = Object.values(STORIES).reduce((n, g) => n + g.entries.length, 0);
209
+ const failing = data.contrast.filter((p) => p.ratio < p.floor);
210
+ const shown = keys.filter((k) => (STORIES[k] || SPECIMENS[k]) && k.toLowerCase().includes(deferred));
211
+
212
+ return (
213
+ <main className="mx-auto flex max-w-6xl flex-col gap-10 px-4 py-8 sm:px-6">
214
+ <header className="flex flex-col gap-4">
215
+ <h1 className="text-2xl font-semibold">Sticker sheet</h1>
216
+ <p className="max-w-prose text-sm text-muted-foreground">
217
+ {keys.length} registered components. {keys.length - noStories.length} have stories ({storyCount} in all, each shown in light and dark and linked to Storybook), {pinned.length} also have a pinned state matrix, and {noStories.length} have neither. Every contrast number comes from <code>wcag:audit</code>, which currently reports {failing.length} failing pairs across {data.contrast.length}.
218
+ </p>
219
+ <label className="flex max-w-sm flex-col gap-2 text-sm">
220
+ Filter components
221
+ <input
222
+ type="search"
223
+ value={query}
224
+ onChange={(e) => setQuery(e.target.value)}
225
+ placeholder="Button, Dialog, Tabs"
226
+ className="min-h-11 rounded-md border border-input bg-background px-3 text-sm"
227
+ />
228
+ </label>
229
+ </header>
230
+
231
+ {shown.map((name) => {
232
+ const group = STORIES[name];
233
+ return (
234
+ <section key={name} id={name} aria-labelledby={`${name}-h`} className="flex flex-col gap-4 border-t border-border pt-8">
235
+ <div className="flex flex-wrap items-baseline justify-between gap-x-4">
236
+ <h2 id={`${name}-h`} className="text-xl font-semibold">
237
+ {name}
238
+ </h2>
239
+ {group && (
240
+ <a href={`${STORYBOOK_BASE}/?path=/docs/${group.entries[0].id.split("--")[0]}--docs`} target="_blank" rel="noreferrer" className="inline-flex min-h-11 items-center text-sm underline underline-offset-4">
241
+ {group.title} in Storybook
242
+ </a>
243
+ )}
244
+ </div>
245
+ {SPECIMENS[name] ? (
246
+ <div className="flex flex-col gap-4">
247
+ {THEMES.map((theme) => (
248
+ <Band key={theme} name={name} specimen={SPECIMENS[name]} theme={theme} />
249
+ ))}
250
+ </div>
251
+ ) : (
252
+ <p className="rounded-md border border-dashed border-border p-3 text-sm text-muted-foreground">Pinned state matrix: not defined</p>
253
+ )}
254
+ {group ? <StoryList group={group} /> : <p className="rounded-md border border-dashed border-border p-3 text-sm text-muted-foreground">Stories: not defined</p>}
255
+ </section>
256
+ );
257
+ })}
258
+
259
+ {OTHER_STORIES.length > 0 && !deferred && (
260
+ <section aria-labelledby="other-h" className="flex flex-col gap-6 border-t border-border pt-8">
261
+ <h2 id="other-h" className="text-xl font-semibold">
262
+ Stories with no registry entry
263
+ </h2>
264
+ {OTHER_STORIES.map((g) => (
265
+ <div key={g.title} className="flex flex-col gap-4">
266
+ <h3 className="text-base font-semibold">{g.title}</h3>
267
+ <StoryList group={g} />
268
+ </div>
269
+ ))}
270
+ </section>
271
+ )}
272
+
273
+ {noStories.length > 0 && (
274
+ <section aria-labelledby="gaps-h" className="flex flex-col gap-4 border-t border-border pt-8">
275
+ <h2 id="gaps-h" className="text-xl font-semibold">
276
+ Not defined ({noStories.length})
277
+ </h2>
278
+ <ul className="grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4">
279
+ {noStories.map((k) => (
280
+ <li key={k} className="min-w-0 overflow-hidden rounded-md border border-dashed border-border p-3">
281
+ <p className="truncate text-sm font-medium" title={k}>
282
+ {k}
283
+ </p>
284
+ <p className="text-xs text-muted-foreground">registered, no story</p>
285
+ </li>
286
+ ))}
287
+ </ul>
288
+ </section>
289
+ )}
290
+
291
+ <section aria-labelledby="pairs-h" className="flex flex-col gap-4">
292
+ <h2 id="pairs-h" className="text-xl font-semibold">
293
+ Every audited pair
294
+ </h2>
295
+ {THEMES.map((theme) => (
296
+ <details key={theme} className="rounded-lg border border-border p-4">
297
+ <summary className="min-h-11 cursor-pointer text-sm font-medium">
298
+ {theme} ({data.contrast.filter((p) => p.mode === theme).length} pairs)
299
+ </summary>
300
+ <table className="mt-3 w-full text-xs">
301
+ <thead>
302
+ <tr className="text-left text-muted-foreground">
303
+ <th className="py-1 pr-3 font-medium">Pair</th>
304
+ <th className="py-1 pr-3 font-medium">Kind</th>
305
+ <th className="py-1 font-medium">Ratio</th>
306
+ </tr>
307
+ </thead>
308
+ <tbody>
309
+ {data.contrast
310
+ .filter((p) => p.mode === theme)
311
+ .map((p) => (
312
+ <tr key={`${p.fgKey}|${p.bgKey}`} className="border-t border-border">
313
+ <td className="py-1 pr-3">
314
+ <code>{p.fgKey}</code> on <code>{p.bgKey}</code>
315
+ </td>
316
+ <td className="py-1 pr-3">{p.kind}</td>
317
+ <td className="py-1">
318
+ <Verdict pair={p} />
319
+ </td>
320
+ </tr>
321
+ ))}
322
+ </tbody>
323
+ </table>
324
+ </details>
325
+ ))}
326
+ </section>
327
+ </main>
328
+ );
329
+ }