@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
@@ -0,0 +1,218 @@
1
+ /**
2
+ * Shared contract for the Studio screen. Pure TypeScript: no React, no DOM.
3
+ * The view-state, hook, control-panel and preview packages all import from here
4
+ * so they agree on names, URL keys, ranges, and the 14px type floor.
5
+ */
6
+ import {
7
+ DESIGN_CONTROL_DEFAULTS,
8
+ DESIGN_CONTROL_RANGES,
9
+ } from "@behavioral-agentic-design-system/core/hooks/use-global-design-controls";
10
+ import {
11
+ TYPE_SCALE_DEFAULTS,
12
+ TYPE_SCALE_RANGES,
13
+ type TypeScale,
14
+ } from "@behavioral-agentic-design-system/core/hooks/use-global-type-scale";
15
+
16
+ /* ── View state: lives in the URL ─────────────────────────────── */
17
+
18
+ export type StudioSubject = "blank" | "cards" | "dashboard";
19
+ export type StudioViewport = "fill" | "390" | "768" | "1280";
20
+ export type StudioPreviewTheme = "match" | "light" | "dark" | "both";
21
+ export type StudioPanelMode = "tweak" | "tokens";
22
+
23
+ /** The single source of truth for everything Studio shows that is NOT a token. */
24
+ export interface StudioViewState {
25
+ subject: StudioSubject;
26
+ viewport: StudioViewport;
27
+ theme: StudioPreviewTheme;
28
+ panel: StudioPanelMode;
29
+ controlsCollapsed: boolean;
30
+ }
31
+
32
+ export const STUDIO_VIEW_DEFAULTS: StudioViewState = {
33
+ subject: "blank",
34
+ viewport: "fill",
35
+ theme: "match",
36
+ panel: "tweak",
37
+ controlsCollapsed: false,
38
+ };
39
+
40
+ /** URL param name for each field. */
41
+ export const STUDIO_URL_KEYS = {
42
+ subject: "subject",
43
+ viewport: "vp",
44
+ theme: "theme",
45
+ panel: "panel",
46
+ controlsCollapsed: "controls",
47
+ } as const satisfies Record<keyof StudioViewState, string>;
48
+
49
+ export const STUDIO_SUBJECTS: readonly { value: StudioSubject; label: string; src: string }[] = [
50
+ { value: "blank", label: "Blank screen", src: "/preview/studio" },
51
+ { value: "cards", label: "Cards", src: "/preview/cards" },
52
+ { value: "dashboard", label: "Dashboard", src: "/preview/dashboard" },
53
+ ];
54
+
55
+ export const STUDIO_VIEWPORTS: readonly { value: StudioViewport; label: string; width: number | null }[] = [
56
+ { value: "fill", label: "Fill", width: null },
57
+ { value: "390", label: "390", width: 390 },
58
+ { value: "768", label: "768", width: 768 },
59
+ { value: "1280", label: "1280", width: 1280 },
60
+ ];
61
+
62
+ export const STUDIO_THEMES: readonly { value: StudioPreviewTheme; label: string }[] = [
63
+ { value: "match", label: "Match app" },
64
+ { value: "light", label: "Light" },
65
+ { value: "dark", label: "Dark" },
66
+ { value: "both", label: "Both" },
67
+ ];
68
+
69
+ function pick<T extends string>(
70
+ raw: string | null,
71
+ options: readonly { value: T }[],
72
+ fallback: T,
73
+ ): T {
74
+ const hit = options.find((o) => o.value === raw);
75
+ return hit ? hit.value : fallback;
76
+ }
77
+
78
+ const PANEL_MODES: readonly { value: StudioPanelMode }[] = [
79
+ { value: "tweak" },
80
+ { value: "tokens" },
81
+ ];
82
+
83
+ /** Parse URLSearchParams into a complete state. Unknown or missing values fall back to defaults. */
84
+ export function parseStudioViewState(params: URLSearchParams): StudioViewState {
85
+ const d = STUDIO_VIEW_DEFAULTS;
86
+ const collapsed = params.get(STUDIO_URL_KEYS.controlsCollapsed);
87
+ return {
88
+ subject: pick(params.get(STUDIO_URL_KEYS.subject), STUDIO_SUBJECTS, d.subject),
89
+ viewport: pick(params.get(STUDIO_URL_KEYS.viewport), STUDIO_VIEWPORTS, d.viewport),
90
+ theme: pick(params.get(STUDIO_URL_KEYS.theme), STUDIO_THEMES, d.theme),
91
+ panel: pick(params.get(STUDIO_URL_KEYS.panel), PANEL_MODES, d.panel),
92
+ controlsCollapsed: collapsed === "collapsed" ? true : d.controlsCollapsed,
93
+ };
94
+ }
95
+
96
+ /** Write only non-default fields into `params` (mutates and returns it). Removes keys that are back at default. */
97
+ export function writeStudioViewState(
98
+ params: URLSearchParams,
99
+ state: StudioViewState,
100
+ ): URLSearchParams {
101
+ const d = STUDIO_VIEW_DEFAULTS;
102
+ const set = (key: string, value: string, isDefault: boolean) => {
103
+ if (isDefault) params.delete(key);
104
+ else params.set(key, value);
105
+ };
106
+ set(STUDIO_URL_KEYS.subject, state.subject, state.subject === d.subject);
107
+ set(STUDIO_URL_KEYS.viewport, state.viewport, state.viewport === d.viewport);
108
+ set(STUDIO_URL_KEYS.theme, state.theme, state.theme === d.theme);
109
+ set(STUDIO_URL_KEYS.panel, state.panel, state.panel === d.panel);
110
+ set(
111
+ STUDIO_URL_KEYS.controlsCollapsed,
112
+ "collapsed",
113
+ state.controlsCollapsed === d.controlsCollapsed,
114
+ );
115
+ return params;
116
+ }
117
+
118
+ /* ── Tweaks: live in the existing global hooks ────────────────── */
119
+
120
+ export const TEXT_FLOOR_PX = 14;
121
+
122
+ /** text-xs is two steps below base. */
123
+ export function smallestTextPx(base: number, ratio: number): number {
124
+ return base / ratio ** 2;
125
+ }
126
+
127
+ /** Largest ratio that keeps text-xs at or above 14px for this base, capped at TYPE_SCALE_RANGES.ratio.max. */
128
+ export function maxRatioForBase(base: number): number {
129
+ return Math.min(TYPE_SCALE_RANGES.ratio.max, Math.sqrt(base / TEXT_FLOOR_PX));
130
+ }
131
+
132
+ /** Smallest base that keeps text-xs at or above 14px for this ratio, floored at TYPE_SCALE_RANGES.base.min. */
133
+ export function minBaseForRatio(ratio: number): number {
134
+ return Math.max(TYPE_SCALE_RANGES.base.min, TEXT_FLOOR_PX * ratio ** 2);
135
+ }
136
+
137
+ /** Clamp a scale so it satisfies the floor. Adjusts ratio first, then base. */
138
+ export function clampTypeScale(scale: TypeScale): TypeScale {
139
+ const ratio = Math.max(
140
+ TYPE_SCALE_RANGES.ratio.min,
141
+ Math.min(scale.ratio, maxRatioForBase(scale.base)),
142
+ );
143
+ // If the range minimum ratio still breaches the floor at this base, raise base.
144
+ const base = Math.min(
145
+ TYPE_SCALE_RANGES.base.max,
146
+ Math.max(scale.base, minBaseForRatio(ratio)),
147
+ );
148
+ return { base, ratio };
149
+ }
150
+
151
+ /** Every tweakable value Studio exposes, flattened into one typed object. */
152
+ export interface StudioTweaks {
153
+ primaryColor: string; // option key from useGlobalPrimaryColor
154
+ sansFont: string; // key of SANS_FONT_OPTIONS
155
+ typeBase: number; // px
156
+ typeRatio: number;
157
+ letterSpacing: number; // em
158
+ radius: number; // rem
159
+ shadowOpacity: number; // 0..1
160
+ spacing: number; // rem
161
+ }
162
+
163
+ export type StudioTweakKey = keyof StudioTweaks;
164
+
165
+ /** Numeric tweak metadata. Ranges and defaults are imported, never retyped. */
166
+ export const NUMERIC_TWEAKS: Record<
167
+ Exclude<StudioTweakKey, "primaryColor" | "sansFont">,
168
+ {
169
+ label: string;
170
+ group: "type" | "shape" | "space";
171
+ min: number;
172
+ max: number;
173
+ step: number;
174
+ unit: string;
175
+ default: number;
176
+ }
177
+ > = {
178
+ typeBase: {
179
+ label: "Base size",
180
+ group: "type",
181
+ ...TYPE_SCALE_RANGES.base,
182
+ default: TYPE_SCALE_DEFAULTS.base,
183
+ },
184
+ typeRatio: {
185
+ label: "Scale ratio",
186
+ group: "type",
187
+ ...TYPE_SCALE_RANGES.ratio,
188
+ default: TYPE_SCALE_DEFAULTS.ratio,
189
+ },
190
+ letterSpacing: {
191
+ label: "Letter spacing",
192
+ group: "type",
193
+ ...DESIGN_CONTROL_RANGES.letterSpacing,
194
+ default: DESIGN_CONTROL_DEFAULTS.letterSpacing,
195
+ },
196
+ radius: {
197
+ label: "Radius",
198
+ group: "shape",
199
+ ...DESIGN_CONTROL_RANGES.radius,
200
+ default: DESIGN_CONTROL_DEFAULTS.radius,
201
+ },
202
+ shadowOpacity: {
203
+ label: "Shadow",
204
+ group: "shape",
205
+ ...DESIGN_CONTROL_RANGES.shadowOpacity,
206
+ default: DESIGN_CONTROL_DEFAULTS.shadowOpacity,
207
+ },
208
+ spacing: {
209
+ label: "Spacing unit",
210
+ group: "space",
211
+ ...DESIGN_CONTROL_RANGES.spacing,
212
+ default: DESIGN_CONTROL_DEFAULTS.spacing,
213
+ },
214
+ };
215
+
216
+ /** postMessage-free contract: the preview needs no messages. Documented here so nobody adds one. */
217
+ export const STUDIO_SYNC_NOTE =
218
+ "Preview iframes sync through the storage event via GlobalFontClient. Do not add a postMessage channel.";
@@ -0,0 +1,128 @@
1
+ "use client";
2
+
3
+ import { useCallback, useMemo } from "react";
4
+ import { useTokenOverrides } from "@behavioral-agentic-design-system/core/hooks/use-token-overrides";
5
+ import {
6
+ DEFAULT_PRIMARY_COLOR,
7
+ useGlobalPrimaryColor,
8
+ } from "@behavioral-agentic-design-system/core/hooks/use-global-primary-color";
9
+ import {
10
+ DEFAULT_SANS_FONT,
11
+ SANS_FONT_OPTIONS,
12
+ useGlobalSansFont,
13
+ } from "@behavioral-agentic-design-system/core/hooks/use-global-sans-font";
14
+ import { useGlobalTypeScale } from "@behavioral-agentic-design-system/core/hooks/use-global-type-scale";
15
+ import { useGlobalDesignControls } from "@behavioral-agentic-design-system/core/hooks/use-global-design-controls";
16
+ import {
17
+ NUMERIC_TWEAKS,
18
+ clampTypeScale,
19
+ type StudioTweakKey,
20
+ type StudioTweaks,
21
+ } from "./types";
22
+
23
+ const PRIMARY_DEFAULT = DEFAULT_PRIMARY_COLOR;
24
+ const SANS_DEFAULT = DEFAULT_SANS_FONT;
25
+
26
+ const DEFAULTS: StudioTweaks = {
27
+ primaryColor: PRIMARY_DEFAULT,
28
+ sansFont: SANS_DEFAULT,
29
+ typeBase: NUMERIC_TWEAKS.typeBase.default,
30
+ typeRatio: NUMERIC_TWEAKS.typeRatio.default,
31
+ letterSpacing: NUMERIC_TWEAKS.letterSpacing.default,
32
+ radius: NUMERIC_TWEAKS.radius.default,
33
+ shadowOpacity: NUMERIC_TWEAKS.shadowOpacity.default,
34
+ spacing: NUMERIC_TWEAKS.spacing.default,
35
+ };
36
+
37
+ /**
38
+ * Studio tweaks: a typed facade over the four existing global hooks. Adds no
39
+ * state of its own, so values stay in the shipped localStorage + storage-event
40
+ * contract that every preview iframe already listens to.
41
+ */
42
+ export function useStudioTweaks() {
43
+ // Order matters: useTokenOverrides' mount effect runs applyThemeEditorState,
44
+ // which clears inline radius/spacing/fonts/colors. It must mount first so
45
+ // the other hooks' mount effects re-apply their values afterwards.
46
+ useTokenOverrides();
47
+ const { color, setColor, options, addCustomSilent } = useGlobalPrimaryColor();
48
+ const { font, setFont } = useGlobalSansFont();
49
+ const { scale, setScale, reset: resetScale } = useGlobalTypeScale();
50
+ const { controls, setControl, reset: resetControls } = useGlobalDesignControls();
51
+
52
+ const tweaks: StudioTweaks = useMemo(
53
+ () => ({
54
+ primaryColor: color,
55
+ sansFont: font,
56
+ typeBase: scale.base,
57
+ typeRatio: scale.ratio,
58
+ letterSpacing: controls.letterSpacing,
59
+ radius: controls.radius,
60
+ shadowOpacity: controls.shadowOpacity,
61
+ spacing: controls.spacing,
62
+ }),
63
+ [color, font, scale.base, scale.ratio, controls],
64
+ );
65
+
66
+ const set = useCallback(
67
+ <K extends StudioTweakKey>(key: K, value: StudioTweaks[K]) => {
68
+ switch (key) {
69
+ case "primaryColor":
70
+ setColor(value as string);
71
+ break;
72
+ case "sansFont":
73
+ if ((value as string) in SANS_FONT_OPTIONS) setFont(value as string);
74
+ break;
75
+ case "typeBase":
76
+ case "typeRatio": {
77
+ const next = clampTypeScale({
78
+ base: key === "typeBase" ? (value as number) : scale.base,
79
+ ratio: key === "typeRatio" ? (value as number) : scale.ratio,
80
+ });
81
+ if (next.base !== scale.base) setScale("base", next.base);
82
+ if (next.ratio !== scale.ratio) setScale("ratio", next.ratio);
83
+ break;
84
+ }
85
+ default:
86
+ setControl(key, value as number);
87
+ }
88
+ },
89
+ [setColor, setFont, setScale, setControl, scale.base, scale.ratio],
90
+ );
91
+
92
+ const reset = useCallback(
93
+ (key: StudioTweakKey) => set(key, DEFAULTS[key]),
94
+ [set],
95
+ );
96
+
97
+ const resetAll = useCallback(() => {
98
+ resetControls();
99
+ resetScale();
100
+ setFont(SANS_DEFAULT);
101
+ setColor(PRIMARY_DEFAULT);
102
+ }, [resetControls, resetScale, setFont, setColor]);
103
+
104
+ const isDefault = useCallback(
105
+ (key: StudioTweakKey) => tweaks[key] === DEFAULTS[key],
106
+ [tweaks],
107
+ );
108
+
109
+ const addCustomColor = useCallback(
110
+ (hex: string): string | null => {
111
+ const id = addCustomSilent(hex);
112
+ if (id) setColor(id);
113
+ return id;
114
+ },
115
+ [addCustomSilent, setColor],
116
+ );
117
+
118
+ return {
119
+ tweaks,
120
+ defaults: DEFAULTS,
121
+ set,
122
+ reset,
123
+ resetAll,
124
+ isDefault,
125
+ primaryOptions: options,
126
+ addCustomColor,
127
+ };
128
+ }
@@ -0,0 +1,72 @@
1
+ "use client";
2
+
3
+ import { useCallback, useEffect, useRef, useState } from "react";
4
+ import {
5
+ STUDIO_SUBJECTS,
6
+ STUDIO_VIEW_DEFAULTS,
7
+ parseStudioViewState,
8
+ writeStudioViewState,
9
+ type StudioViewState,
10
+ } from "./types";
11
+
12
+ const URL_DEBOUNCE_MS = 150;
13
+
14
+ /**
15
+ * Studio view state (subject, viewport, theme, panel mode, collapsed) mirrored
16
+ * into the URL. Initial render returns the defaults so server and client agree;
17
+ * a mount effect reads window.location.search once. Writes use replaceState,
18
+ * never pushState, and spread the existing history.state so the shell's
19
+ * `shellTab` entry survives.
20
+ */
21
+ export function useStudioViewState() {
22
+ const [state, setState] = useState<StudioViewState>(STUDIO_VIEW_DEFAULTS);
23
+ const latest = useRef<StudioViewState>(STUDIO_VIEW_DEFAULTS);
24
+ const timer = useRef<ReturnType<typeof setTimeout> | null>(null);
25
+ const dirty = useRef(false);
26
+
27
+ useEffect(() => {
28
+ const parsed = parseStudioViewState(new URLSearchParams(window.location.search));
29
+ latest.current = parsed;
30
+ setState(parsed);
31
+ }, []);
32
+
33
+ useEffect(
34
+ () => () => {
35
+ if (timer.current) clearTimeout(timer.current);
36
+ },
37
+ [],
38
+ );
39
+
40
+ const set = useCallback(
41
+ <K extends keyof StudioViewState>(key: K, value: StudioViewState[K]) => {
42
+ const next = { ...latest.current, [key]: value };
43
+ latest.current = next;
44
+ dirty.current = true;
45
+ setState(next);
46
+ if (timer.current) clearTimeout(timer.current);
47
+ timer.current = setTimeout(() => {
48
+ timer.current = null;
49
+ if (typeof window === "undefined") return;
50
+ const url = new URL(window.location.href);
51
+ writeStudioViewState(url.searchParams, latest.current);
52
+ window.history.replaceState({ ...window.history.state }, "", url);
53
+ }, URL_DEBOUNCE_MS);
54
+ },
55
+ [],
56
+ );
57
+
58
+ // The mount effect above reads the URL once, so a Studio that is already mounted (the shell keeps visited tabs
59
+ // alive) never sees a link that points it at another subject. Home's "Recently added" sends this event, the
60
+ // same pairing the Docs tab uses with "bads:docs:navigate".
61
+ useEffect(() => {
62
+ const onSubject = (event: Event) => {
63
+ const subject = (event as CustomEvent<unknown>).detail;
64
+ const match = STUDIO_SUBJECTS.find((s) => s.value === subject);
65
+ if (match) set("subject", match.value);
66
+ };
67
+ window.addEventListener("bads:studio:subject", onSubject);
68
+ return () => window.removeEventListener("bads:studio:subject", onSubject);
69
+ }, [set]);
70
+
71
+ return { state, set };
72
+ }
@@ -108,7 +108,7 @@ export function Autocomplete({
108
108
  }
109
109
  return;
110
110
  }
111
- if (e.key === "Enter") {
111
+ if (e.key === "Enter" && !e.nativeEvent.isComposing) {
112
112
  // Free-text contract: only intercept Enter when an option is
113
113
  // highlighted. Otherwise the typed text stands and the event falls
114
114
  // through (form submit keeps working).
@@ -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
@@ -5,6 +5,7 @@ import * as RechartsPrimitive from "recharts"
5
5
 
6
6
  import { cn } from "../../lib/utils"
7
7
  import { useReducedMotion } from "../../hooks/use-reduced-motion"
8
+ import { readChartMotion, type ChartMotion } from "../../lib/chart-motion"
8
9
 
9
10
  // Format: { THEME_NAME: CSS_SELECTOR }
10
11
  const THEMES = { light: "", dark: ".dark" } as const
@@ -51,34 +52,74 @@ const ANIMATED_RECHARTS_COMPONENTS = new Set<React.ElementType>([
51
52
  RechartsPrimitive.Scatter,
52
53
  ])
53
54
 
55
+ // Series that draw in along their path. ChartContainer gives them the
56
+ // token-derived draw timing (lib/chart-motion.ts) unless the consumer set
57
+ // their own.
58
+ const DRAWN_RECHARTS_COMPONENTS = new Set<React.ElementType>([
59
+ RechartsPrimitive.Line,
60
+ RechartsPrimitive.Area,
61
+ RechartsPrimitive.Radar,
62
+ ])
63
+
54
64
  function injectAnimationDefault(
55
65
  node: React.ReactNode,
56
- animate: boolean
66
+ animate: boolean,
67
+ motion: ChartMotion | null,
68
+ drawEnds: number[]
57
69
  ): React.ReactNode {
58
- // When animate is true we leave Recharts' defaults alone (entrance
59
- // animation on). When animate is false we walk the tree and force
60
- // isAnimationActive={false} on every animated primitive.
61
- if (animate) return node
70
+ // animate=false: force isAnimationActive={false} on every animated
71
+ // primitive. animate=true: give drawn series the token-derived duration and
72
+ // easing (unless the consumer set their own) and record when each one
73
+ // finishes drawing, so the point dots can wait for it.
62
74
  if (Array.isArray(node)) {
63
75
  return node.map((child, i) => (
64
- <React.Fragment key={i}>{injectAnimationDefault(child, animate)}</React.Fragment>
76
+ <React.Fragment key={i}>
77
+ {injectAnimationDefault(child, animate, motion, drawEnds)}
78
+ </React.Fragment>
65
79
  ))
66
80
  }
67
81
  if (!React.isValidElement(node)) return node
68
82
  const element = node as React.ReactElement<any>
69
83
  const props = element.props || {}
70
- const isAnimated = ANIMATED_RECHARTS_COMPONENTS.has(
71
- element.type as React.ElementType
72
- )
73
- const needsDefault =
74
- isAnimated && props.isAnimationActive === undefined
75
- const hasChildren = props.children !== undefined
76
- if (!needsDefault && !hasChildren) return element
84
+ const type = element.type as React.ElementType
77
85
  const nextProps: Record<string, unknown> = {}
78
- if (needsDefault) nextProps.isAnimationActive = false
79
- if (hasChildren) {
80
- nextProps.children = injectAnimationDefault(props.children, animate)
86
+ if (!animate) {
87
+ if (
88
+ ANIMATED_RECHARTS_COMPONENTS.has(type) &&
89
+ props.isAnimationActive === undefined
90
+ ) {
91
+ nextProps.isAnimationActive = false
92
+ }
93
+ } else if (DRAWN_RECHARTS_COMPONENTS.has(type) && props.isAnimationActive !== false) {
94
+ const duration =
95
+ typeof props.animationDuration === "number"
96
+ ? props.animationDuration
97
+ : motion?.drawMs
98
+ if (props.animationDuration === undefined && motion) {
99
+ nextProps.animationDuration = motion.drawMs
100
+ }
101
+ if (props.animationEasing === undefined && motion) {
102
+ nextProps.animationEasing = motion.drawEasing
103
+ }
104
+ // Only Line dots need holding back: Recharts mounts them at their final
105
+ // positions while the stroke is still drawing. Area dots sit inside the
106
+ // area's reveal clip and Radar dots ride the growing polygon, so both
107
+ // already arrive with their series.
108
+ if (type === RechartsPrimitive.Line && typeof duration === "number") {
109
+ const begin =
110
+ typeof props.animationBegin === "number" ? props.animationBegin : 0
111
+ drawEnds.push(begin + duration)
112
+ }
113
+ }
114
+ if (props.children !== undefined) {
115
+ nextProps.children = injectAnimationDefault(
116
+ props.children,
117
+ animate,
118
+ motion,
119
+ drawEnds
120
+ )
81
121
  }
122
+ if (Object.keys(nextProps).length === 0) return element
82
123
  return React.cloneElement(element, nextProps)
83
124
  }
84
125
 
@@ -118,10 +159,12 @@ function ChartContainer({
118
159
  // width AND height. The wrapping div still SSRs so layout is reserved.
119
160
  const containerRef = React.useRef<HTMLDivElement | null>(null)
120
161
  const [hasSize, setHasSize] = React.useState(false)
162
+ const [motion, setMotion] = React.useState<ChartMotion | null>(null)
121
163
 
122
164
  React.useEffect(() => {
123
165
  const el = containerRef.current
124
166
  if (!el) return
167
+ setMotion(readChartMotion(el))
125
168
  const observer = new ResizeObserver((entries) => {
126
169
  for (const entry of entries) {
127
170
  const { width, height } = entry.contentRect
@@ -139,10 +182,23 @@ function ChartContainer({
139
182
  // Recursively default isAnimationActive={false} on every animated Recharts
140
183
  // child. Consumers can override per-element by passing the prop explicitly,
141
184
  // or opt the whole tree back in via the `animate` prop on the container.
142
- const safeChildren = React.useMemo(
143
- () => injectAnimationDefault(children, effectiveAnimate) as typeof children,
144
- [children, effectiveAnimate]
145
- )
185
+ // The same walk hands drawn series their token-derived timing and reports
186
+ // when the last one finishes drawing; the dots fade in after that, never
187
+ // ahead of the stroke.
188
+ const { safeChildren, dotDelayMs } = React.useMemo(() => {
189
+ const drawEnds: number[] = []
190
+ const next = injectAnimationDefault(
191
+ children,
192
+ effectiveAnimate,
193
+ motion,
194
+ drawEnds
195
+ ) as typeof children
196
+ return {
197
+ safeChildren: next,
198
+ dotDelayMs:
199
+ effectiveAnimate && drawEnds.length ? Math.max(...drawEnds) : null,
200
+ }
201
+ }, [children, effectiveAnimate, motion])
146
202
 
147
203
  return (
148
204
  <ChartContext.Provider value={{ config }}>
@@ -162,8 +218,8 @@ function ChartContainer({
162
218
  style={style}
163
219
  {...props}
164
220
  >
165
- <ChartStyle id={chartId} config={config} />
166
- {hasSize ? (
221
+ <ChartStyle id={chartId} config={config} dotDelayMs={dotDelayMs} />
222
+ {hasSize && motion ? (
167
223
  <RechartsPrimitive.ResponsiveContainer width="100%" height="100%">
168
224
  {safeChildren}
169
225
  </RechartsPrimitive.ResponsiveContainer>
@@ -173,12 +229,56 @@ function ChartContainer({
173
229
  )
174
230
  }
175
231
 
176
- const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
232
+ // Line point dots (`<Line dot>`) render at their final positions the moment a
233
+ // series mounts, while the stroke takes the whole draw to reach them. Left
234
+ // alone they pop in all at once, ahead of the line. Hold them at
235
+ // opacity 0 until the last series has finished drawing (dotDelayMs, from
236
+ // ChartContainer), then fade them in over --duration-slow / --ease-out.
237
+ // Scoped to the line dot group so the hover activeDot (rendered in
238
+ // .recharts-active-dot) is never delayed, and Area / Radar dots (which
239
+ // already arrive with their series) are left alone. No rule at all when the chart is not
240
+ // animating, and none under prefers-reduced-motion: the global reduced-motion
241
+ // rule shortens animation-duration but not animation-delay.
242
+ const CHART_DOT_SELECTOR = [".recharts-line-dots .recharts-dot"]
243
+
244
+ function chartDotEntranceCss(id: string, dotDelayMs: number | null) {
245
+ if (dotDelayMs === null) return ""
246
+ const selector = CHART_DOT_SELECTOR.map(
247
+ (dots) => `[data-chart=${id}] ${dots}`
248
+ ).join(",\n")
249
+ return `
250
+ @keyframes chart-dot-fade-in {
251
+ 0% {
252
+ opacity: 0;
253
+ }
254
+ 100% {
255
+ opacity: 1;
256
+ }
257
+ }
258
+
259
+ @media (prefers-reduced-motion: no-preference) {
260
+ ${selector} {
261
+ animation: chart-dot-fade-in var(--duration-slow) var(--ease-out) ${Math.round(dotDelayMs)}ms both;
262
+ }
263
+ }
264
+ `
265
+ }
266
+
267
+ const ChartStyle = ({
268
+ id,
269
+ config,
270
+ dotDelayMs = null,
271
+ }: {
272
+ id: string
273
+ config: ChartConfig
274
+ dotDelayMs?: number | null
275
+ }) => {
177
276
  const colorConfig = Object.entries(config).filter(
178
277
  ([, config]) => config.theme || config.color
179
278
  )
279
+ const dotCss = chartDotEntranceCss(id, dotDelayMs)
180
280
 
181
- if (!colorConfig.length) {
281
+ if (!colorConfig.length && !dotCss) {
182
282
  return null
183
283
  }
184
284
 
@@ -188,19 +288,12 @@ const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
188
288
  // per-instance generated CSS, and the values written ARE tokens.
189
289
  <style
190
290
  dangerouslySetInnerHTML={{
191
- __html: `
192
- @keyframes chart-dot-fade-in {
193
- 0% {
194
- opacity: 0;
195
- }
196
- 100% {
197
- opacity: 1;
198
- }
199
- }
200
-
201
- ${Object.entries(THEMES)
202
- .map(
203
- ([theme, prefix]) => `
291
+ __html: `${dotCss}
292
+ ${
293
+ colorConfig.length
294
+ ? Object.entries(THEMES)
295
+ .map(
296
+ ([theme, prefix]) => `
204
297
  ${prefix} [data-chart=${id}] {
205
298
  ${colorConfig
206
299
  .map(([key, itemConfig]) => {
@@ -211,12 +304,11 @@ ${colorConfig
211
304
  })
212
305
  .join("\n")}
213
306
  }
214
- ${prefix} [data-chart=${id}] .recharts-dot {
215
- animation: chart-dot-fade-in 400ms ease-out 800ms both;
216
- }
217
307
  `
218
- )
219
- .join("\n")}
308
+ )
309
+ .join("\n")
310
+ : ""
311
+ }
220
312
  `,
221
313
  }}
222
314
  />