@behavioral-agentic-design-system/core 0.42.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 (314) hide show
  1. package/package.json +38 -8
  2. package/scripts/a11y-lint.cjs +101 -14
  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/check-spec.mjs +73 -0
  8. package/scripts/deal-directions.mjs +186 -0
  9. package/scripts/design-system-advisory/README.md +239 -0
  10. package/scripts/design-system-advisory/check-copy-punctuation.mjs +44 -0
  11. package/scripts/design-system-advisory/check-even-padding.mjs +35 -0
  12. package/scripts/design-system-advisory/check-hand-built-button.mjs +46 -0
  13. package/scripts/design-system-advisory/check-html-nesting.mjs +51 -0
  14. package/scripts/design-system-advisory/check-icon-sizing.mjs +79 -0
  15. package/scripts/design-system-advisory/check-label-case.mjs +92 -0
  16. package/scripts/design-system-advisory/check-native-form-controls.mjs +53 -0
  17. package/scripts/design-system-advisory/check-radius.mjs +56 -0
  18. package/scripts/design-system-advisory/check-raw-values.mjs +61 -0
  19. package/scripts/design-system-advisory/check-small-text.mjs +72 -0
  20. package/scripts/design-system-advisory/check-tap-target.mjs +70 -0
  21. package/scripts/design-system-advisory/defaults.mjs +90 -0
  22. package/scripts/design-system-advisory/fixtures/clean.tsx.fixture +12 -0
  23. package/scripts/design-system-advisory/fixtures/violations.tsx.fixture +19 -0
  24. package/scripts/design-system-advisory/lib.mjs +255 -0
  25. package/scripts/design-system-advisory/run.mjs +189 -0
  26. package/scripts/design-system-advisory/workflow.yml +82 -0
  27. package/scripts/health-report.mjs +20 -14
  28. package/scripts/lib/copy-strings.mjs +146 -0
  29. package/scripts/lib/counted-lint.mjs +100 -0
  30. package/scripts/lib/dark-contrast.mjs +120 -0
  31. package/scripts/lib/flush-edges.mjs +294 -0
  32. package/scripts/lib/lab-lint.mjs +62 -0
  33. package/scripts/lib/marketing-library.mjs +129 -0
  34. package/scripts/lib/mount-page.mjs +25 -0
  35. package/scripts/lib/on-system.mjs +249 -0
  36. package/scripts/lib/random.mjs +22 -0
  37. package/scripts/lib/source-scan.mjs +173 -0
  38. package/scripts/lib/spec-parse.d.mts +25 -0
  39. package/scripts/lib/spec-parse.mjs +188 -0
  40. package/scripts/lib/tells.mjs +366 -0
  41. package/scripts/lint-arbitrary-tokens.mjs +47 -0
  42. package/scripts/lint-component-token-refs.mjs +63 -0
  43. package/scripts/lint-content-hierarchy.mjs +114 -0
  44. package/scripts/lint-control-baseline.mjs +72 -0
  45. package/scripts/lint-copy-punctuation.mjs +60 -0
  46. package/scripts/lint-css-vars.mjs +175 -0
  47. package/scripts/lint-even-padding.mjs +58 -0
  48. package/scripts/lint-html-nesting.mjs +116 -0
  49. package/scripts/lint-label-case.mjs +219 -0
  50. package/scripts/lint-live-ctas.mjs +138 -0
  51. package/scripts/lint-microanimation.mjs +2 -2
  52. package/scripts/lint-proximity.mjs +181 -0
  53. package/scripts/lint-slop.mjs +1 -1
  54. package/scripts/lint-spacing-scale.mjs +78 -0
  55. package/scripts/lint-target-size.cjs +132 -0
  56. package/scripts/lint-token-primitives.mjs +307 -0
  57. package/scripts/on-system-score.mjs +95 -0
  58. package/scripts/size-audit.cjs +2 -2
  59. package/scripts/slop-rules.mjs +1 -1
  60. package/scripts/source-images.mjs +180 -0
  61. package/scripts/ux-tells.mjs +80 -0
  62. package/scripts/wcag-audit.cjs +25 -4
  63. package/src/api/brand-colors.ts +3 -0
  64. package/src/api/brand-fonts.ts +3 -0
  65. package/src/api/brand-mark.ts +6 -1
  66. package/src/api/dev-write-guard.ts +53 -0
  67. package/src/api/layers/file.ts +9 -4
  68. package/src/api/onboarding-extract.ts +85 -30
  69. package/src/api/onboarding.ts +3 -0
  70. package/src/api/save-tokens.ts +3 -0
  71. package/src/api/site-auth.ts +14 -2
  72. package/src/app/layout.tsx +6 -0
  73. package/src/app/preview/canvas/page.tsx +12 -0
  74. package/src/app/preview/components/page.tsx +828 -14
  75. package/src/app/preview/sticker-sheet/page.tsx +329 -0
  76. package/src/app/preview/sticker-sheet/specimens.tsx +296 -0
  77. package/src/app/preview/studio/blank-screen.tsx +143 -0
  78. package/src/app/preview/studio/page.tsx +7 -0
  79. package/src/app/shell.tsx +164 -47
  80. package/src/components/Foundations/Colors.stories.tsx +119 -8
  81. package/src/components/canvas/canvas.tsx +458 -0
  82. package/src/components/canvas/layout.ts +72 -0
  83. package/src/components/canvas/parse-canvas.ts +32 -0
  84. package/src/components/canvas/sample.ts +90 -0
  85. package/src/components/canvas/spec-frame.tsx +43 -0
  86. package/src/components/canvas/types.ts +33 -0
  87. package/src/components/docs-tab.tsx +7 -7
  88. package/src/components/home-recent.tsx +73 -0
  89. package/src/components/home-tab.tsx +19 -14
  90. package/src/components/layers-tab.tsx +2 -2
  91. package/src/components/markdown-preview.tsx +60 -12
  92. package/src/components/onboarding-wizard.tsx +1 -1
  93. package/src/components/studio/control-panel.tsx +299 -0
  94. package/src/components/studio/control-row.tsx +77 -0
  95. package/src/components/studio/preview-frame.tsx +165 -0
  96. package/src/components/studio/preview-pane.tsx +247 -0
  97. package/src/components/studio/studio.tsx +133 -128
  98. package/src/components/studio/types.ts +218 -0
  99. package/src/components/studio/use-studio-tweaks.ts +128 -0
  100. package/src/components/studio/use-studio-view-state.ts +72 -0
  101. package/src/components/ui/autocomplete.tsx +1 -1
  102. package/src/components/ui/avatar.tsx +4 -0
  103. package/src/components/ui/chart.tsx +134 -42
  104. package/src/components/ui/checkbox-group.tsx +1 -1
  105. package/src/components/ui/checkbox.tsx +1 -1
  106. package/src/components/ui/color-picker.tsx +20 -4
  107. package/src/components/ui/combobox.tsx +1 -0
  108. package/src/components/ui/command.tsx +1 -1
  109. package/src/components/ui/data-table.tsx +64 -3
  110. package/src/components/ui/date-field.tsx +1 -1
  111. package/src/components/ui/date-picker.tsx +2 -0
  112. package/src/components/ui/date-range-picker.tsx +4 -0
  113. package/src/components/ui/editable.tsx +1 -0
  114. package/src/components/ui/faceted-filter.tsx +187 -0
  115. package/src/components/ui/file-upload.tsx +21 -2
  116. package/src/components/ui/gauge-chart.tsx +18 -4
  117. package/src/components/ui/heatmap.tsx +3 -1
  118. package/src/components/ui/inline-edit.tsx +175 -0
  119. package/src/components/ui/input-group.tsx +5 -2
  120. package/src/components/ui/month-picker.tsx +1 -1
  121. package/src/components/ui/multi-select.tsx +1 -0
  122. package/src/components/ui/number-input.tsx +28 -5
  123. package/src/components/ui/otp-input.tsx +208 -0
  124. package/src/components/ui/phone-input.tsx +274 -0
  125. package/src/components/ui/radio-group.tsx +2 -2
  126. package/src/components/ui/search-input.tsx +1 -1
  127. package/src/components/ui/sparkline.tsx +33 -4
  128. package/src/components/ui/spinner.tsx +23 -4
  129. package/src/components/ui/table.tsx +9 -0
  130. package/src/components/ui/tags-input.tsx +1 -1
  131. package/src/components/ui/timer.tsx +1 -0
  132. package/src/components/ui/transfer-list.tsx +13 -26
  133. package/src/components/ui/week-picker.tsx +1 -13
  134. package/src/components/ui/year-picker.tsx +1 -1
  135. package/src/data/component-added.json +966 -0
  136. package/src/data/docs-index.ts +35 -2
  137. package/src/data/history.json +161 -161
  138. package/src/data/sticker-sheet.json +9244 -0
  139. package/src/docs-trace-globs.json +1 -0
  140. package/src/hooks/use-global-mono-font.ts +1 -0
  141. package/src/hooks/use-global-primary-color.ts +1 -0
  142. package/src/hooks/use-global-sans-font.ts +1 -0
  143. package/src/hooks/use-global-serif-font.ts +1 -0
  144. package/src/hooks/use-global-type-scale.ts +17 -2
  145. package/src/hooks/use-mobile.ts +2 -0
  146. package/src/hooks/use-sync-type-scale.ts +7 -11
  147. package/src/lib/chart-motion.ts +41 -0
  148. package/src/lib/get-icon-color.ts +1 -1
  149. package/src/lib/spec-parse.ts +4 -0
  150. package/src/lib/svg-sanitize.ts +19 -9
  151. package/src/stories/Accordion.stories.tsx +7 -0
  152. package/src/stories/ActionBar.stories.tsx +5 -0
  153. package/src/stories/Affix.stories.tsx +4 -0
  154. package/src/stories/AiBadge.stories.tsx +9 -7
  155. package/src/stories/Alert.stories.tsx +13 -0
  156. package/src/stories/AlertDialog.stories.tsx +4 -0
  157. package/src/stories/Anchor.stories.tsx +5 -0
  158. package/src/stories/AngleSlider.stories.tsx +6 -3
  159. package/src/stories/AspectRatio.stories.tsx +4 -0
  160. package/src/stories/Autocomplete.stories.tsx +8 -0
  161. package/src/stories/Avatar.stories.tsx +10 -0
  162. package/src/stories/Badge.stories.tsx +14 -6
  163. package/src/stories/Blockquote.stories.tsx +6 -0
  164. package/src/stories/BottomNavigation.stories.tsx +4 -0
  165. package/src/stories/Breadcrumb.stories.tsx +3 -0
  166. package/src/stories/Burger.stories.tsx +1 -0
  167. package/src/stories/Button.stories.tsx +24 -0
  168. package/src/stories/ButtonGroup.stories.tsx +9 -0
  169. package/src/stories/Calendar.stories.tsx +3 -0
  170. package/src/stories/Canvas.stories.tsx +45 -0
  171. package/src/stories/Card.stories.tsx +4 -0
  172. package/src/stories/Carousel.stories.tsx +6 -0
  173. package/src/stories/Cascader.stories.tsx +4 -0
  174. package/src/stories/Chart.stories.tsx +46 -1
  175. package/src/stories/ChatBubble.stories.tsx +8 -2
  176. package/src/stories/ChatMarker.stories.tsx +1 -0
  177. package/src/stories/Checkbox.stories.tsx +40 -0
  178. package/src/stories/CheckboxCard.stories.tsx +8 -0
  179. package/src/stories/CheckboxGroup.stories.tsx +19 -0
  180. package/src/stories/Chip.stories.tsx +10 -19
  181. package/src/stories/CircularProgress.stories.tsx +13 -27
  182. package/src/stories/Clipboard.stories.tsx +6 -0
  183. package/src/stories/CloseButton.stories.tsx +6 -4
  184. package/src/stories/Code.stories.tsx +8 -1
  185. package/src/stories/Collapsible.stories.tsx +2 -0
  186. package/src/stories/ColorPicker.stories.tsx +46 -0
  187. package/src/stories/ColorSwatch.stories.tsx +1 -0
  188. package/src/stories/Combobox.stories.tsx +9 -0
  189. package/src/stories/Command.stories.tsx +2 -0
  190. package/src/stories/Container.stories.tsx +8 -0
  191. package/src/stories/ContextMenu.stories.tsx +9 -0
  192. package/src/stories/CopyButton.stories.tsx +12 -36
  193. package/src/stories/DataList.stories.tsx +8 -0
  194. package/src/stories/DataTable.stories.tsx +39 -0
  195. package/src/stories/DateField.stories.tsx +28 -0
  196. package/src/stories/DatePicker.stories.tsx +34 -0
  197. package/src/stories/DateRangePicker.stories.tsx +32 -0
  198. package/src/stories/Dialog.stories.tsx +8 -0
  199. package/src/stories/Drawer.stories.tsx +6 -0
  200. package/src/stories/DropdownMenu.stories.tsx +2 -0
  201. package/src/stories/Editable.stories.tsx +12 -0
  202. package/src/stories/EmptyState.stories.tsx +9 -0
  203. package/src/stories/FacetedFilter.stories.tsx +197 -0
  204. package/src/stories/Field.stories.tsx +7 -0
  205. package/src/stories/Fieldset.stories.tsx +8 -0
  206. package/src/stories/FileButton.stories.tsx +4 -0
  207. package/src/stories/FileUpload.stories.tsx +16 -17
  208. package/src/stories/FloatLabel.stories.tsx +3 -8
  209. package/src/stories/FloatingActionButton.stories.tsx +10 -0
  210. package/src/stories/FloatingIndicator.stories.tsx +4 -0
  211. package/src/stories/FloatingPanel.stories.tsx +6 -0
  212. package/src/stories/FocusTrap.stories.tsx +5 -0
  213. package/src/stories/FormatByte.stories.tsx +6 -0
  214. package/src/stories/FormatDate.stories.tsx +8 -0
  215. package/src/stories/FormatNumber.stories.tsx +9 -0
  216. package/src/stories/GaugeChart.stories.tsx +9 -3
  217. package/src/stories/Heatmap.stories.tsx +11 -0
  218. package/src/stories/Highlight.stories.tsx +6 -0
  219. package/src/stories/HoverCard.stories.tsx +4 -0
  220. package/src/stories/Image.stories.tsx +9 -0
  221. package/src/stories/Indicator.stories.tsx +19 -0
  222. package/src/stories/InlineEdit.stories.tsx +106 -0
  223. package/src/stories/Input.stories.tsx +7 -0
  224. package/src/stories/InputClearButton.stories.tsx +3 -0
  225. package/src/stories/InputGroup.stories.tsx +40 -0
  226. package/src/stories/Kbd.stories.tsx +7 -1
  227. package/src/stories/KeyboardShortcut.stories.tsx +2 -0
  228. package/src/stories/Label.stories.tsx +2 -0
  229. package/src/stories/Link.stories.tsx +9 -0
  230. package/src/stories/List.stories.tsx +8 -0
  231. package/src/stories/Listbox.stories.tsx +1 -0
  232. package/src/stories/LoadingDots.stories.tsx +5 -3
  233. package/src/stories/LoadingOverlay.stories.tsx +5 -1
  234. package/src/stories/Mark.stories.tsx +5 -0
  235. package/src/stories/MarkdownPreview.stories.tsx +53 -0
  236. package/src/stories/Marquee.stories.tsx +4 -0
  237. package/src/stories/Masonry.stories.tsx +5 -0
  238. package/src/stories/Menubar.stories.tsx +3 -0
  239. package/src/stories/Meter.stories.tsx +11 -17
  240. package/src/stories/MonthPicker.stories.tsx +26 -1
  241. package/src/stories/MotionToggle.stories.tsx +1 -0
  242. package/src/stories/MultiSelect.stories.tsx +9 -0
  243. package/src/stories/NativeSelect.stories.tsx +1 -0
  244. package/src/stories/NavLink.stories.tsx +7 -0
  245. package/src/stories/NavigationMenu.stories.tsx +5 -0
  246. package/src/stories/NavigationRail.stories.tsx +10 -0
  247. package/src/stories/Notification.stories.tsx +13 -34
  248. package/src/stories/NumberInput.stories.tsx +33 -1
  249. package/src/stories/OtpInput.stories.tsx +110 -0
  250. package/src/stories/Overlay.stories.tsx +5 -1
  251. package/src/stories/Pagination.stories.tsx +8 -0
  252. package/src/stories/PasswordInput.stories.tsx +2 -0
  253. package/src/stories/PhoneInput.stories.tsx +127 -0
  254. package/src/stories/PinInput.stories.tsx +9 -2
  255. package/src/stories/Popover.stories.tsx +2 -0
  256. package/src/stories/Progress.stories.tsx +6 -1
  257. package/src/stories/Prose.stories.tsx +8 -0
  258. package/src/stories/QrCode.stories.tsx +2 -0
  259. package/src/stories/Questionnaire.stories.tsx +7 -0
  260. package/src/stories/RadioGroup.stories.tsx +40 -0
  261. package/src/stories/RatingGroup.stories.tsx +8 -4
  262. package/src/stories/Resizable.stories.tsx +4 -2
  263. package/src/stories/Result.stories.tsx +3 -0
  264. package/src/stories/Reveal.stories.tsx +2 -0
  265. package/src/stories/RollingNumber.stories.tsx +5 -0
  266. package/src/stories/ScrollArea.stories.tsx +3 -1
  267. package/src/stories/SearchInput.stories.tsx +10 -6
  268. package/src/stories/SegmentedControl.stories.tsx +11 -0
  269. package/src/stories/Select.stories.tsx +7 -0
  270. package/src/stories/Separator.stories.tsx +6 -0
  271. package/src/stories/Sheet.stories.tsx +5 -0
  272. package/src/stories/Sidebar.stories.tsx +40 -1
  273. package/src/stories/SimpleGrid.stories.tsx +5 -0
  274. package/src/stories/Skeleton.stories.tsx +8 -0
  275. package/src/stories/SkeletonTable.stories.tsx +6 -5
  276. package/src/stories/SkipLink.stories.tsx +3 -0
  277. package/src/stories/Slider.stories.tsx +2 -1
  278. package/src/stories/Sonner.stories.tsx +7 -0
  279. package/src/stories/Sparkline.stories.tsx +14 -1
  280. package/src/stories/Spinner.stories.tsx +20 -10
  281. package/src/stories/Spoiler.stories.tsx +5 -0
  282. package/src/stories/Squircle.stories.tsx +7 -0
  283. package/src/stories/Stack.stories.tsx +7 -0
  284. package/src/stories/StatusBadge.stories.tsx +12 -6
  285. package/src/stories/Stepper.stories.tsx +5 -0
  286. package/src/stories/Switch.stories.tsx +4 -0
  287. package/src/stories/Table.stories.tsx +10 -1
  288. package/src/stories/Tabs.stories.tsx +8 -0
  289. package/src/stories/Tag.stories.tsx +13 -5
  290. package/src/stories/TagsInput.stories.tsx +15 -0
  291. package/src/stories/Text.stories.tsx +12 -0
  292. package/src/stories/Textarea.stories.tsx +9 -0
  293. package/src/stories/ThemeIcon.stories.tsx +6 -3
  294. package/src/stories/TimePicker.stories.tsx +2 -0
  295. package/src/stories/Timeline.stories.tsx +12 -0
  296. package/src/stories/Timer.stories.tsx +30 -0
  297. package/src/stories/Toggle.stories.tsx +7 -5
  298. package/src/stories/ToggleGroup.stories.tsx +5 -0
  299. package/src/stories/ToggleTip.stories.tsx +4 -0
  300. package/src/stories/Toolbar.stories.tsx +6 -0
  301. package/src/stories/Tooltip.stories.tsx +3 -0
  302. package/src/stories/Tour.stories.tsx +3 -0
  303. package/src/stories/TransferList.stories.tsx +7 -0
  304. package/src/stories/TreeSelect.stories.tsx +4 -0
  305. package/src/stories/TreeView.stories.tsx +5 -0
  306. package/src/stories/TypingIndicator.stories.tsx +4 -0
  307. package/src/stories/VisuallyHidden.stories.tsx +3 -0
  308. package/src/stories/Watermark.stories.tsx +6 -0
  309. package/src/stories/WeekPicker.stories.tsx +25 -1
  310. package/src/stories/WordRotate.stories.tsx +5 -0
  311. package/src/stories/YearPicker.stories.tsx +26 -11
  312. package/src/stories/story-groups.json +22 -16
  313. package/src/styles.css +50 -2
  314. package/src/tokens.json +86 -58
@@ -139,7 +139,7 @@ function CheckboxGroup({
139
139
  role="group"
140
140
  data-slot="checkbox-group"
141
141
  data-disabled={disabled || undefined}
142
- className={cn("grid gap-3", className)}
142
+ className={cn("grid grid-cols-1 gap-3", className)}
143
143
  {...props}
144
144
  >
145
145
  {children}
@@ -45,7 +45,7 @@ function Checkbox({
45
45
  // the checkbox. It's absolutely positioned, so it adds zero layout
46
46
  // (respects the no-jump / layout-stability principle) and never touches
47
47
  // a neighbor's flow. Focus ring stays on the visible box.
48
- "peer relative inline-flex shrink-0 items-center justify-center border-2 border-muted-foreground/60 bg-white leading-none shadow-xs transition-[background-color,border-color,color] duration-[210ms] ease-in-out outline-none before:absolute before:left-1/2 before:top-1/2 before:size-11 before:-translate-x-1/2 before:-translate-y-1/2 before:content-[''] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground data-[state=indeterminate]:border-primary data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground dark:aria-invalid:ring-destructive/40",
48
+ "peer relative inline-flex shrink-0 items-center justify-center border-2 border-muted-foreground/60 bg-background dark:data-[state=unchecked]:bg-input/30 leading-none shadow-xs transition-[background-color,border-color,color] duration-[210ms] ease-in-out outline-none before:absolute before:left-1/2 before:top-1/2 before:size-11 before:-translate-x-1/2 before:-translate-y-1/2 before:content-[''] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground data-[state=indeterminate]:border-primary data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground dark:aria-invalid:ring-destructive/40",
49
49
  SIZE_CLASSES[size].box,
50
50
  className
51
51
  )}
@@ -350,7 +350,20 @@ export function ColorPicker({
350
350
  // Colors the user has added through the wheel, appended after the presets.
351
351
  const [addedSwatches, setAddedSwatches] = React.useState<string[]>([]);
352
352
  const allSwatches = React.useMemo(
353
- () => [...swatches, ...addedSwatches.filter((c) => !swatches.includes(c))],
353
+ () => {
354
+ // Case-insensitive: a controlled parent may hand the same color back
355
+ // as "#3B82F6" while the wheel drafted "#3b82f6", which listed it twice.
356
+ const seen = new Set(swatches.map((c) => c.toLowerCase()));
357
+ return [
358
+ ...swatches,
359
+ ...addedSwatches.filter((c) => {
360
+ const key = c.toLowerCase();
361
+ if (seen.has(key)) return false;
362
+ seen.add(key);
363
+ return true;
364
+ }),
365
+ ];
366
+ },
354
367
  [swatches, addedSwatches]
355
368
  );
356
369
 
@@ -429,14 +442,17 @@ export function ColorPicker({
429
442
 
430
443
  const addColor = () => {
431
444
  if (disabled || !isValidHex(draft)) return;
432
- if (!allSwatches.includes(draft)) setAddedSwatches((prev) => [...prev, draft]);
445
+ if (!allSwatches.some((c) => c.toLowerCase() === draft.toLowerCase()))
446
+ setAddedSwatches((prev) => [...prev, draft]);
433
447
  commit(draft);
434
448
  if (!swatches.includes(draft)) setCustomInput("");
435
449
  onAddSwatch?.(draft);
436
450
  setWheelOpen(false);
437
451
  };
438
452
 
439
- const selectedSwatchIdx = allSwatches.indexOf(value);
453
+ const selectedSwatchIdx = allSwatches.findIndex(
454
+ (c) => c.toLowerCase() === (value ?? "").toLowerCase()
455
+ );
440
456
 
441
457
  return (
442
458
  <div className={cn("space-y-3", className)}>
@@ -450,7 +466,7 @@ export function ColorPicker({
450
466
  className="flex flex-wrap gap-1.5"
451
467
  >
452
468
  {allSwatches.map((swatch, i) => {
453
- const isSelected = value === swatch;
469
+ const isSelected = (value ?? "").toLowerCase() === swatch.toLowerCase();
454
470
  const isRovingFocus = selectedSwatchIdx >= 0 ? isSelected : i === 0;
455
471
  return (
456
472
  <button
@@ -54,6 +54,7 @@ function Combobox({
54
54
  options,
55
55
  value,
56
56
  onValueChange,
57
+ // copy-ok: this default is quoted in the component registry and generated docs; change them together.
57
58
  placeholder = "Select option...",
58
59
  searchPlaceholder = "Search...",
59
60
  emptyText = "No results found.",
@@ -31,7 +31,7 @@ function Command({
31
31
 
32
32
  function CommandDialog({
33
33
  title = "Command Palette",
34
- description = "Search for a command to run...",
34
+ description = "Search for a command to run…",
35
35
  children,
36
36
  className,
37
37
  showCloseButton = true,
@@ -19,6 +19,7 @@ import { Button } from "./button"
19
19
  import { Checkbox } from "./checkbox"
20
20
  import {
21
21
  Table,
22
+ TableCaption,
22
23
  TableHeader,
23
24
  TableBody,
24
25
  TableRow,
@@ -72,6 +73,17 @@ export interface DataTableProps<TData> extends VariantProps<typeof cellVariants>
72
73
  * definition if needed.
73
74
  */
74
75
  rowSelection?: boolean
76
+ /**
77
+ * Fires with the selected rows' data whenever the selection changes (not on
78
+ * mount), so a "Delete selected" bar can act on them. Needs `rowSelection`.
79
+ */
80
+ onRowSelectionChange?: (rows: TData[]) => void
81
+ /**
82
+ * Stable id for a row. Without it, rows are identified by array index, so
83
+ * after a refetch or re-sort of `data` the selection can land on different
84
+ * records. Pass a primary key when rows have one.
85
+ */
86
+ getRowId?: (row: TData, index: number) => string
75
87
  /**
76
88
  * Callback fired when a data row is clicked. Does NOT constitute a
77
89
  * selection — pair with rowSelection for accessible multi-select. When
@@ -95,6 +107,13 @@ export interface DataTableProps<TData> extends VariantProps<typeof cellVariants>
95
107
  * height when `stickyHeader` is true. Defaults to `"400px"`.
96
108
  */
97
109
  scrollHeight?: string
110
+ /**
111
+ * Accessible label announced by screen readers as the table's region name.
112
+ * Also rendered as a visually hidden `<caption>` so assistive tech can
113
+ * identify the table's purpose (WCAG 1.3.1). Required when more than one
114
+ * table appears on a page; strongly recommended otherwise.
115
+ */
116
+ caption?: string
98
117
  className?: string
99
118
  }
100
119
 
@@ -201,11 +220,14 @@ function DataTable<TData>({
201
220
  sorting: sortingEnabled = true,
202
221
  pagination: paginationOptions,
203
222
  rowSelection: rowSelectionEnabled = false,
223
+ onRowSelectionChange,
224
+ getRowId,
204
225
  onRowClick,
205
226
  emptyMessage = "No results.",
206
227
  stickyHeader = false,
207
228
  scrollHeight = "400px",
208
229
  density = "comfortable",
230
+ caption,
209
231
  className,
210
232
  }: DataTableProps<TData>) {
211
233
  const [sortingState, setSortingState] = React.useState<SortingState>([])
@@ -231,6 +253,7 @@ function DataTable<TData>({
231
253
  },
232
254
  enableSorting: sortingEnabled,
233
255
  enableRowSelection: rowSelectionEnabled,
256
+ getRowId,
234
257
  onSortingChange: setSortingState,
235
258
  onRowSelectionChange: setRowSelectionState,
236
259
  getCoreRowModel: getCoreRowModel(),
@@ -245,6 +268,22 @@ function DataTable<TData>({
245
268
  },
246
269
  })
247
270
 
271
+ // Report the selected rows' data. A ref keeps an inline callback from re-running the effect, and the
272
+ // first run is skipped so mounting does not announce an empty selection.
273
+ const onRowSelectionChangeRef = React.useRef(onRowSelectionChange)
274
+ onRowSelectionChangeRef.current = onRowSelectionChange
275
+ const selectionMounted = React.useRef(false)
276
+ React.useEffect(() => {
277
+ if (!selectionMounted.current) {
278
+ selectionMounted.current = true
279
+ return
280
+ }
281
+ onRowSelectionChangeRef.current?.(
282
+ table.getSelectedRowModel().rows.map((r) => r.original)
283
+ )
284
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- table is stable; the selection state is the trigger
285
+ }, [rowSelectionState])
286
+
248
287
  const cellClass = cellVariants({ density })
249
288
 
250
289
  return (
@@ -252,13 +291,23 @@ function DataTable<TData>({
252
291
  data-slot="data-table"
253
292
  className={cn("rounded-md border bg-card overflow-hidden", className)}
254
293
  >
255
- {/* Scrollable table wrapper */}
256
- <div className="overflow-x-auto">
294
+ {/* Scrollable table wrapper — tabIndex makes the region keyboard-reachable
295
+ (WCAG 2.1.1 + axe scrollable-region-focusable). aria-label surfaces the
296
+ caption text as the region name for screen readers. */}
297
+ <div
298
+ className="overflow-x-auto"
299
+ tabIndex={0}
300
+ role="region"
301
+ aria-label={caption ?? "Data table"}
302
+ >
257
303
  <Table
258
304
  role="grid"
259
305
  wrapperClassName={stickyHeader ? "overflow-y-auto" : undefined}
260
306
  wrapperStyle={stickyHeader ? { maxHeight: scrollHeight } : undefined}
261
307
  >
308
+ {caption ? (
309
+ <TableCaption className="sr-only">{caption}</TableCaption>
310
+ ) : null}
262
311
  <TableHeader className={stickyHeader ? "sticky top-0 z-10 bg-card" : undefined}>
263
312
  {table.getHeaderGroups().map((headerGroup) => (
264
313
  <TableRow key={headerGroup.id}>
@@ -336,7 +385,19 @@ function DataTable<TData>({
336
385
  onRowClick && "cursor-pointer",
337
386
  row.getIsSelected() && "bg-muted"
338
387
  )}
339
- onClick={onRowClick ? () => onRowClick(row.original) : undefined}
388
+ onClick={
389
+ onRowClick
390
+ ? (event) => {
391
+ // A click on a control inside the row (the select checkbox, a link, an action
392
+ // button) belongs to that control, not to the row.
393
+ const hit = (event.target as HTMLElement).closest(
394
+ "a, button, input, label, select, textarea, [role='checkbox'], [role='button']"
395
+ )
396
+ if (hit && event.currentTarget.contains(hit)) return
397
+ onRowClick(row.original)
398
+ }
399
+ : undefined
400
+ }
340
401
  >
341
402
  {row.getVisibleCells().map((cell) => (
342
403
  <TableCell
@@ -65,7 +65,7 @@ function DateField({
65
65
  className,
66
66
  id,
67
67
  }: DateFieldProps) {
68
- const isControlled = value !== undefined
68
+ const isControlled = value !== undefined || onValueChange !== undefined
69
69
  const [internalValue, setInternalValue] = React.useState<Date | undefined>(
70
70
  isValidDate(defaultValue) ? atMidnight(defaultValue) : undefined
71
71
  )
@@ -146,6 +146,8 @@ function DatePicker({
146
146
  mode="single"
147
147
  selected={selectedDate}
148
148
  onSelect={handleSelect}
149
+ // Open on the selected date's month, not today's.
150
+ defaultMonth={selectedDate}
149
151
  startMonth={fromDate}
150
152
  endMonth={toDate}
151
153
  disabled={[
@@ -161,6 +161,10 @@ function DateRangePicker({
161
161
  mode="range"
162
162
  selected={selectedRange as DateRange | undefined}
163
163
  onSelect={handleSelect}
164
+ // Open on the selected range, not today's month. Without this a
165
+ // picker holding Jun 1 to Jun 15 opened on the current month with
166
+ // neither end of the range in view.
167
+ defaultMonth={selectedRange?.from}
164
168
  startMonth={fromDate}
165
169
  endMonth={toDate}
166
170
  disabled={[
@@ -151,6 +151,7 @@ function Editable({
151
151
  }
152
152
  if (
153
153
  e.key === "Enter" &&
154
+ !e.nativeEvent.isComposing &&
154
155
  (submitMode === "enter" || submitMode === "both")
155
156
  ) {
156
157
  e.preventDefault()
@@ -0,0 +1,187 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { PlusCircleIcon, XCircleIcon } from "lucide-react"
5
+
6
+ import { cn } from "../../lib/utils"
7
+ import { Badge } from "./badge"
8
+ import { Button } from "./button"
9
+ import { Checkbox } from "./checkbox"
10
+ import { Popover, PopoverContent, PopoverTrigger } from "./popover"
11
+ import { Separator } from "./separator"
12
+ import {
13
+ Command,
14
+ CommandEmpty,
15
+ CommandGroup,
16
+ CommandInput,
17
+ CommandItem,
18
+ CommandList,
19
+ CommandSeparator,
20
+ } from "./command"
21
+
22
+ export interface FacetedFilterOption {
23
+ label: string
24
+ value: string
25
+ icon?: React.ComponentType<{ className?: string }>
26
+ count?: number
27
+ }
28
+
29
+ export interface FacetedFilterProps {
30
+ title: string
31
+ options: FacetedFilterOption[]
32
+ selectedValues?: Set<string>
33
+ onSelectionChange?: (values: Set<string>) => void
34
+ className?: string
35
+ }
36
+
37
+ export function FacetedFilter({
38
+ title,
39
+ options,
40
+ selectedValues = new Set(),
41
+ onSelectionChange,
42
+ className,
43
+ }: FacetedFilterProps) {
44
+ const selectedCount = selectedValues.size
45
+
46
+ function toggleValue(value: string) {
47
+ const next = new Set(selectedValues)
48
+ if (next.has(value)) {
49
+ next.delete(value)
50
+ } else {
51
+ next.add(value)
52
+ }
53
+ onSelectionChange?.(next)
54
+ }
55
+
56
+ function clearSelection() {
57
+ onSelectionChange?.(new Set())
58
+ }
59
+
60
+ return (
61
+ <Popover>
62
+ <PopoverTrigger asChild>
63
+ <Button
64
+ variant="outline"
65
+ size="sm"
66
+ aria-label={
67
+ selectedCount > 0
68
+ ? `${title}: ${selectedCount} selected`
69
+ : `Filter by ${title}`
70
+ }
71
+ className={cn("h-8 gap-1.5 border-dashed", className)}
72
+ >
73
+ <PlusCircleIcon strokeWidth={1.5} className="size-4 shrink-0" />
74
+ <span>{title}</span>
75
+ {selectedCount > 0 && (
76
+ <>
77
+ <Separator orientation="vertical" className="h-4" />
78
+ {selectedCount > 2 ? (
79
+ <Badge
80
+ variant="secondary"
81
+ size="sm"
82
+ className="rounded-sm px-1 font-normal"
83
+ >
84
+ {selectedCount} selected
85
+ </Badge>
86
+ ) : (
87
+ <div className="flex gap-1">
88
+ {Array.from(selectedValues).map((val) => (
89
+ <Badge
90
+ key={val}
91
+ variant="secondary"
92
+ size="sm"
93
+ className="rounded-sm px-1 font-normal"
94
+ >
95
+ {options.find((o) => o.value === val)?.label ?? val}
96
+ </Badge>
97
+ ))}
98
+ </div>
99
+ )}
100
+ </>
101
+ )}
102
+ </Button>
103
+ </PopoverTrigger>
104
+ <PopoverContent
105
+ className="w-[220px] p-0"
106
+ align="start"
107
+ sideOffset={6}
108
+ >
109
+ <Command aria-label={`${title} filter options`}>
110
+ <CommandInput placeholder={`Search ${title.toLowerCase()}…`} />
111
+ <CommandList>
112
+ <CommandEmpty>No results.</CommandEmpty>
113
+ <CommandGroup>
114
+ {options.map((option) => {
115
+ const isSelected = selectedValues.has(option.value)
116
+ const Icon = option.icon
117
+ return (
118
+ <CommandItem
119
+ key={option.value}
120
+ value={option.value}
121
+ onSelect={() => toggleValue(option.value)}
122
+ className="gap-2"
123
+ style={{
124
+ transitionProperty: "color, background-color",
125
+ transitionDuration: "var(--duration-fast)",
126
+ transitionTimingFunction: "var(--ease-out)",
127
+ }}
128
+ >
129
+ {/* Decorative, not the real control: CommandItem's onSelect above is
130
+ what toggles selection and is what gets the roving cmdk focus. A
131
+ second focusable/interactive checkbox nested in the same row would
132
+ double the controls a screen reader announces for one choice. This
133
+ still has to be the real Checkbox primitive, not a hand-rolled
134
+ lookalike (see CLAUDE.md -> "Primitive visual parity") — tabIndex,
135
+ pointer-events, and aria-hidden are what make an otherwise-real,
136
+ otherwise-interactive component safe to use purely as a visual. */}
137
+ <Checkbox
138
+ size="sm"
139
+ checked={isSelected}
140
+ tabIndex={-1}
141
+ aria-hidden
142
+ className={cn(
143
+ "pointer-events-none",
144
+ !isSelected && "opacity-50 [.group_&]:opacity-100"
145
+ )}
146
+ />
147
+ {Icon && (
148
+ <Icon className="size-4 shrink-0 text-muted-foreground" />
149
+ )}
150
+ <span className="flex-1 truncate">{option.label}</span>
151
+ {option.count !== undefined && (
152
+ <span
153
+ className="ml-auto font-mono text-xs tabular-nums text-muted-foreground"
154
+ aria-label={`${option.count} items`}
155
+ >
156
+ {option.count}
157
+ </span>
158
+ )}
159
+ </CommandItem>
160
+ )
161
+ })}
162
+ </CommandGroup>
163
+ {selectedCount > 0 && (
164
+ <>
165
+ <CommandSeparator />
166
+ <CommandGroup>
167
+ <CommandItem
168
+ onSelect={clearSelection}
169
+ className="justify-center gap-1.5 text-muted-foreground"
170
+ style={{
171
+ transitionProperty: "color, background-color",
172
+ transitionDuration: "var(--duration-fast)",
173
+ transitionTimingFunction: "var(--ease-out)",
174
+ }}
175
+ >
176
+ <XCircleIcon strokeWidth={1.5} className="size-4" />
177
+ Clear filters
178
+ </CommandItem>
179
+ </CommandGroup>
180
+ </>
181
+ )}
182
+ </CommandList>
183
+ </Command>
184
+ </PopoverContent>
185
+ </Popover>
186
+ )
187
+ }
@@ -42,7 +42,7 @@ export interface FileUploadProps extends VariantProps<typeof fileUploadZoneVaria
42
42
  accept?: string;
43
43
  /** Allow selecting more than one file */
44
44
  multiple?: boolean;
45
- /** Maximum file size in bytes. Files larger than this are silently rejected. */
45
+ /** Maximum file size in bytes. Larger files are rejected, and the rejection is announced to screen readers. */
46
46
  maxSize?: number;
47
47
  disabled?: boolean;
48
48
  className?: string;
@@ -87,6 +87,8 @@ function FileUpload({
87
87
  const files = isControlled ? value : localFiles;
88
88
 
89
89
  const [dragState, setDragState] = React.useState<"idle" | "dragging" | "rejected">("idle");
90
+ // Spoken by the live region below. The red drop zone is visual only, and it clears after two seconds.
91
+ const [announcement, setAnnouncement] = React.useState("");
90
92
  const dragCounterRef = React.useRef(0);
91
93
  const rejectTimerRef = React.useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
92
94
 
@@ -104,11 +106,22 @@ function FileUpload({
104
106
  if (maxSize !== undefined && f.size > maxSize) return false;
105
107
  return true;
106
108
  });
107
- if (valid.length < arr.length) {
109
+ const rejected = arr.length - valid.length;
110
+ if (rejected > 0) {
108
111
  clearTimeout(rejectTimerRef.current);
109
112
  setDragState("rejected");
110
113
  rejectTimerRef.current = setTimeout(() => setDragState("idle"), 2000);
111
114
  }
115
+ const added = multiple ? valid.length : Math.min(valid.length, 1);
116
+ const plural = (n: number) => `${n} file${n === 1 ? "" : "s"}`;
117
+ setAnnouncement(
118
+ [
119
+ added > 0 ? `${plural(added)} added.` : "",
120
+ rejected > 0 ? `${plural(rejected)} not added: wrong type or too large.` : "",
121
+ ]
122
+ .filter(Boolean)
123
+ .join(" ")
124
+ );
112
125
  if (valid.length === 0) return;
113
126
  const next = multiple ? [...files, ...valid] : valid.slice(0, 1);
114
127
  if (!isControlled) setLocalFiles(next);
@@ -153,6 +166,7 @@ function FileUpload({
153
166
 
154
167
  const removeFile = (index: number) => {
155
168
  const next = files.filter((_, i) => i !== index);
169
+ setAnnouncement(`${files[index]?.name ?? "File"} removed.`);
156
170
  if (!isControlled) setLocalFiles(next);
157
171
  onChange?.(next);
158
172
  };
@@ -230,6 +244,11 @@ function FileUpload({
230
244
  </div>
231
245
  </label>
232
246
 
247
+ {/* Announces additions, rejections and removals; the visual states alone reach no one using a screen reader. */}
248
+ <div role="status" aria-live="polite" className="sr-only">
249
+ {announcement}
250
+ </div>
251
+
233
252
  {/* ── file list ── */}
234
253
  {files.length > 0 && (
235
254
  <ul data-slot="file-upload-list" className="space-y-2">
@@ -4,7 +4,7 @@ import * as React from "react"
4
4
  import { ResponsiveContainer, PieChart, Pie } from "recharts"
5
5
 
6
6
  import { cn } from "../../lib/utils"
7
- import { useReducedMotion } from "../../hooks/use-reduced-motion"
7
+ import { prefersReducedMotion } from "../../hooks/use-reduced-motion"
8
8
 
9
9
  // Arc geometry. Recharts measures angles counter-clockwise from 3 o'clock, so
10
10
  // starting at 225° (lower-left) and sweeping down to -45° (lower-right) draws
@@ -115,13 +115,27 @@ function GaugeChart({
115
115
  "aria-label": ariaLabel,
116
116
  ...props
117
117
  }: GaugeChartProps) {
118
- const prefersReducedMotion = useReducedMotion()
119
- const animate = !prefersReducedMotion
120
-
121
118
  // ResizeObserver gate — same pattern as ChartContainer and Sparkline.
122
119
  const containerRef = React.useRef<HTMLDivElement | null>(null)
123
120
  const [hasSize, setHasSize] = React.useState(false)
124
121
 
122
+ // Read reduced-motion synchronously at mount rather than via the reactive
123
+ // `useReducedMotion()` hook. That hook intentionally starts `false` on
124
+ // every render (SSR-safe) and corrects itself a tick later via its own
125
+ // effect — fine for components whose SSR output doesn't depend on it, but
126
+ // this chart's entire Pie subtree is already gated behind `hasSize` (which
127
+ // is `false` during SSR and the first client paint), so there is no
128
+ // server/client mismatch risk in reading the real preference immediately.
129
+ // Without this, `isAnimationActive` starts `true`, react-smooth begins
130
+ // tweening the value arc from a zero-width sector, and when the hook's
131
+ // effect flips it to `false` a tick later — mid-tween — Recharts freezes
132
+ // on whatever near-zero angle it had already interpolated to instead of
133
+ // jumping to the final one, so the arc never recovers to its correct
134
+ // angle. Reading the preference up front means `isAnimationActive` is
135
+ // right from the component's very first animation frame, so this race
136
+ // never opens. (Confirmed via repeated headless capture — see PR.)
137
+ const [animate] = React.useState(() => !prefersReducedMotion())
138
+
125
139
  React.useEffect(() => {
126
140
  const el = containerRef.current
127
141
  if (!el) return
@@ -147,7 +147,9 @@ function Heatmap({
147
147
  aria-label={label}
148
148
  tabIndex={0}
149
149
  className={cn(
150
- "inline-flex max-w-full flex-col gap-3 overflow-x-auto rounded-md outline-none",
150
+ // `relative` matters: each cell holds a screen-reader-only span (position: absolute). Without a positioned
151
+ // scroll container those spans escape its clipping and stretch the whole page sideways.
152
+ "relative inline-flex max-w-full flex-col gap-3 overflow-x-auto rounded-md outline-none",
151
153
  "focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
152
154
  className
153
155
  )}