@automattic/charts 1.0.2 → 1.1.1

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 (44) hide show
  1. package/AGENTS.md +14 -1
  2. package/CHANGELOG.md +18 -0
  3. package/dist/{chunk-G3PMV62Z.js → chunk-5WRI5ZAA.js} +1 -6
  4. package/dist/{chunk-EMMSS5I5.cjs → chunk-DZUJEN5N.cjs} +2 -7
  5. package/dist/chunk-DZUJEN5N.cjs.map +1 -0
  6. package/dist/index.cjs +1571 -2377
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.css +31 -107
  9. package/dist/index.css.map +1 -1
  10. package/dist/index.d.cts +2 -0
  11. package/dist/index.d.ts +2 -0
  12. package/dist/index.js +1722 -2528
  13. package/dist/index.js.map +1 -1
  14. package/dist/visx/group/index.cjs +1 -1
  15. package/dist/visx/group/index.js +1 -1
  16. package/dist/visx/legend/index.cjs +1 -1
  17. package/dist/visx/legend/index.js +1 -1
  18. package/dist/visx/text/index.cjs +1 -1
  19. package/dist/visx/text/index.js +1 -1
  20. package/package.json +9 -8
  21. package/src/charts/conversion-funnel-chart/conversion-funnel-chart.module.scss +19 -47
  22. package/src/charts/conversion-funnel-chart/conversion-funnel-chart.tsx +17 -10
  23. package/src/charts/geo-chart/geo-chart.module.scss +0 -3
  24. package/src/charts/geo-chart/geo-chart.tsx +9 -4
  25. package/src/charts/leaderboard-chart/leaderboard-chart.module.scss +1 -1
  26. package/src/charts/leaderboard-chart/leaderboard-chart.tsx +2 -2
  27. package/src/charts/line-chart/line-chart.module.scss +3 -13
  28. package/src/charts/line-chart/line-chart.tsx +9 -2
  29. package/src/charts/line-chart/private/line-chart-annotation-label-popover.tsx +5 -4
  30. package/src/charts/pie-chart/pie-chart.tsx +5 -3
  31. package/src/charts/pie-semi-circle-chart/pie-semi-circle-chart.module.scss +3 -3
  32. package/src/components/legend/private/base-legend.module.scss +2 -51
  33. package/src/components/legend/private/base-legend.tsx +30 -28
  34. package/src/components/tooltip/base-tooltip.module.scss +1 -1
  35. package/src/components/trend-indicator/trend-indicator.module.scss +2 -2
  36. package/src/hooks/use-chart-margin.tsx +1 -14
  37. package/src/providers/chart-context/themes.ts +7 -1
  38. package/src/types.ts +2 -0
  39. package/src/utils/index.ts +3 -0
  40. package/src/utils/resolve-font-size.ts +37 -0
  41. package/src/utils/test/resolve-css-var.test.ts +3 -5
  42. package/src/utils/test/resolve-font-size.test.ts +66 -0
  43. package/dist/chunk-EMMSS5I5.cjs.map +0 -1
  44. /package/dist/{chunk-G3PMV62Z.js.map → chunk-5WRI5ZAA.js.map} +0 -0
package/AGENTS.md CHANGED
@@ -20,6 +20,15 @@ jp changelog add js-packages/charts -s patch -t changed -e "Charts: <user-facing
20
20
  - Accessibility behavior (keyboard navigation, accessible tooltips) is core chart behavior, not optional polish.
21
21
  - Charts are responsive by default — do not add external responsive wrappers that conflict with built-in sizing semantics.
22
22
 
23
+ ## WordPress UI + Theme Integration
24
+
25
+ The package is migrating to WordPress UI and Theme as its defaults. When adding or changing code, follow these defaults unless the task explicitly says otherwise:
26
+
27
+ - **Design tokens (WPDS).** In SCSS, use `var(--wpds-dimension-*, <fallback>)`, `var(--wpds-border-*, <fallback>)`, and `var(--wpds-font-*, <fallback>)` instead of hardcoded px values for spacing, padding, margins, border radius, border width, font size, and font weight. Fallbacks must match the WPDS spec value for that token — do not invent fallback values.
28
+ - **UI primitives.** Prefer `Stack` and the stable `Text` from `@wordpress/ui` over ad-hoc flexbox or raw `<span>`/`<div>` for layout and text. Do not use `__experimental*` exports from `@wordpress/components` (e.g. `__experimentalText`, `__experimentalHStack`) — use the stable `@wordpress/ui` equivalents. Exception: `__experimentalGrid` has no stable alternative yet and is acceptable to use for now.
29
+ - **Theming.** Theming flows through `@wordpress/theme`'s `ThemeProvider` (unlocked via private APIs in Storybook; see `src/stories/chart-decorator.tsx`). Do not manually override DS tokens in stories or components to achieve theming — pass a color through `ThemeProvider` instead.
30
+ - **Chart element styles.** Read chart element styles via `getElementStyles` from `GlobalChartsProvider`, not directly from `theme`. This is the supported path for color/style resolution across themes.
31
+
23
32
  ## Documentation Workflow
24
33
 
25
34
  - For docs tasks agents should use the skill at `.agents/skills/charts-docs.md`.
@@ -43,8 +52,12 @@ jp changelog add js-packages/charts -s patch -t changed -e "Charts: <user-facing
43
52
  - Documenting props or behavior not present in stories and implementation.
44
53
  - Refactoring core composition/provider patterns as if they are accidental complexity.
45
54
  - Defining new chart prop interfaces that diverge from established base chart contracts (for example, not aligning with `BaseChartProps` when appropriate).
46
- - Using ad-hoc flexbox layouts where established layout primitives (e.g. `Stack`) should be preferred.
55
+ - Using ad-hoc flexbox layouts where established layout primitives (e.g. `Stack` from `@wordpress/ui`) should be preferred.
47
56
  - Accessing colors/styles directly from `theme` rather than using `getElementStyles` from `GlobalChartsProvider`.
57
+ - Hardcoding px values in SCSS for spacing, borders, or typography where a WPDS token (`--wpds-dimension-*`, `--wpds-border-*`, `--wpds-font-*`) exists.
58
+ - CSS variable fallback values that diverge from the WPDS spec for that token.
59
+ - Using `__experimental*` exports from `@wordpress/components` (e.g. `__experimentalText`, `__experimentalHStack`) instead of the stable `@wordpress/ui` equivalents. (`__experimentalGrid` is excepted — no stable alternative exists yet.)
60
+ - Manually overriding DS tokens in stories or components to achieve theming instead of passing a color through `@wordpress/theme`'s `ThemeProvider`.
48
61
  - Responsive wrappers that conflict with component sizing semantics (fixed-height charts, resize behavior, aspect-ratio assumptions).
49
62
  - Updating `.docs.mdx` without the corresponding `.api.mdx` when API docs are affected.
50
63
  - Not checking CSF file references in `.docs.mdx` when changing or removing stories.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.1.1] - 2026-04-15
9
+ ### Changed
10
+ - Charts: Document WordPress UI + Theme integration defaults. [#48020]
11
+ - Charts: Replace ad-hoc flexbox layouts with @wordpress/ui Stack across legend, conversion funnel, line chart, geo chart, conversion funnel tooltip, and donut story. [#47981]
12
+ - Update package dependencies. [#47907]
13
+
14
+ ## [1.1.0] - 2026-04-10
15
+ ### Changed
16
+ - Replace hardcoded typography values with WPDS design tokens for font family, size, weight, and line height. [#47989]
17
+ - Replace __experimentalText from @wordpress/components with stable Text from @wordpress/ui. [#47894]
18
+ - Update package dependencies. [#47890] [#47998]
19
+
20
+ ### Fixed
21
+ - Fix Line Chart Annotations Custom and Alert story errors in Storybook by replacing the CJS-only gridicons dependency with @wordpress/icons. [#47990]
22
+ - Storybook: Replace manual design-system token override with real WPDS ThemeProvider. [#47983]
23
+
8
24
  ## [1.0.2] - 2026-04-06
9
25
  ### Changed
10
26
  - Conversion Funnel Chart: Rename non-BEM classnames to BEM modifiers. [#47854]
@@ -784,6 +800,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
784
800
  - Fixed lints following ESLint rule changes for TS [#40584]
785
801
  - Fixing a bug in Chart storybook data. [#40640]
786
802
 
803
+ [1.1.1]: https://github.com/Automattic/charts/compare/v1.1.0...v1.1.1
804
+ [1.1.0]: https://github.com/Automattic/charts/compare/v1.0.2...v1.1.0
787
805
  [1.0.2]: https://github.com/Automattic/charts/compare/v1.0.1...v1.0.2
788
806
  [1.0.1]: https://github.com/Automattic/charts/compare/v1.0.0...v1.0.1
789
807
  [1.0.0]: https://github.com/Automattic/charts/compare/v0.59.0...v1.0.0
@@ -7,10 +7,6 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __commonJS = (cb, mod) => function __require() {
8
8
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
9
  };
10
- var __export = (target, all) => {
11
- for (var name in all)
12
- __defProp(target, name, { get: all[name], enumerable: true });
13
- };
14
10
  var __copyProps = (to, from, except, desc) => {
15
11
  if (from && typeof from === "object" || typeof from === "function") {
16
12
  for (let key of __getOwnPropNames(from))
@@ -30,7 +26,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
26
 
31
27
  export {
32
28
  __commonJS,
33
- __export,
34
29
  __toESM
35
30
  };
36
- //# sourceMappingURL=chunk-G3PMV62Z.js.map
31
+ //# sourceMappingURL=chunk-5WRI5ZAA.js.map
@@ -7,10 +7,6 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __commonJS = (cb, mod) => function __require() {
8
8
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
9
  };
10
- var __export = (target, all) => {
11
- for (var name in all)
12
- __defProp(target, name, { get: all[name], enumerable: true });
13
- };
14
10
  var __copyProps = (to, from, except, desc) => {
15
11
  if (from && typeof from === "object" || typeof from === "function") {
16
12
  for (let key of __getOwnPropNames(from))
@@ -31,6 +27,5 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
31
27
 
32
28
 
33
29
 
34
-
35
- exports.__commonJS = __commonJS; exports.__export = __export; exports.__toESM = __toESM;
36
- //# sourceMappingURL=chunk-EMMSS5I5.cjs.map
30
+ exports.__commonJS = __commonJS; exports.__toESM = __toESM;
31
+ //# sourceMappingURL=chunk-DZUJEN5N.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/jetpack/jetpack/projects/js-packages/charts/dist/chunk-DZUJEN5N.cjs"],"names":[],"mappings":"AAAA,6EAAI,SAAS,EAAE,MAAM,CAAC,MAAM;AAC5B,IAAI,UAAU,EAAE,MAAM,CAAC,cAAc;AACrC,IAAI,iBAAiB,EAAE,MAAM,CAAC,wBAAwB;AACtD,IAAI,kBAAkB,EAAE,MAAM,CAAC,mBAAmB;AAClD,IAAI,aAAa,EAAE,MAAM,CAAC,cAAc;AACxC,IAAI,aAAa,EAAE,MAAM,CAAC,SAAS,CAAC,cAAc;AAClD,IAAI,WAAW,EAAE,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