@automattic/charts 1.6.0 → 1.7.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 (33) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +2 -2
  3. package/dist/index.cjs +22 -9
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.css +6 -3
  6. package/dist/index.d.cts +103 -30
  7. package/dist/index.d.ts +106 -33
  8. package/dist/index.js +22 -9
  9. package/dist/index.js.map +1 -1
  10. package/package.json +22 -21
  11. package/src/charts/area-chart/types.ts +1 -1
  12. package/src/charts/bar-chart/bar-chart.tsx +1 -1
  13. package/src/charts/geo-chart/geo-chart.tsx +3 -1
  14. package/src/charts/leaderboard-chart/leaderboard-chart.module.scss +27 -14
  15. package/src/charts/leaderboard-chart/leaderboard-chart.tsx +7 -4
  16. package/src/charts/leaderboard-chart/test/leaderboard-chart.test.tsx +51 -4
  17. package/src/charts/line-chart/line-chart.tsx +1 -1
  18. package/src/charts/line-chart/private/line-chart-annotation-label-popover.tsx +18 -2
  19. package/src/charts/line-chart/private/line-chart-annotation.tsx +1 -1
  20. package/src/charts/line-chart/types.ts +1 -1
  21. package/src/charts/pie-semi-circle-chart/pie-semi-circle-chart.tsx +2 -2
  22. package/src/charts/private/chart-layout/chart-layout.tsx +1 -2
  23. package/src/charts/private/x-zoom.tsx +2 -2
  24. package/src/components/legend/hooks/use-chart-legend-items.ts +6 -2
  25. package/src/components/legend/legend.tsx +1 -2
  26. package/src/components/legend/utils/label-transform-factory.ts +1 -1
  27. package/src/components/tooltip/accessible-tooltip.tsx +2 -6
  28. package/src/index.ts +6 -5
  29. package/src/providers/chart-context/themes.ts +1 -1
  30. package/src/providers/chart-context/types.ts +7 -2
  31. package/src/types.ts +104 -11
  32. package/src/utils/get-styles.ts +1 -2
  33. package/src/visx/types.ts +30 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,14 @@ 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.7.0] - 2026-06-23
9
+ ### Added
10
+ - Leaderboard interactive rows gain an opt-in `ariaLabel` for image-only labels, and the hover affordance now shrinks each bar in proportion to its length so small-share rows stay consistent. [#49812]
11
+
12
+ ### Changed
13
+ - Add React 19 compatibility for consumers. [#49661]
14
+ - Type `leaderboardChart.labelSpacing` as a WPDS `GapSize` token instead of `number` (the numeric value was silently ignored by `@wordpress/ui`'s Stack) to fix `@wordpress/ui` 0.15 type errors. [#49797]
15
+
8
16
  ## [1.6.0] - 2026-06-22
9
17
  ### Added
10
18
  - Allow Leaderboard items to be made interactive via a per-entry onClick, rendering the row as a keyboard-accessible button with a hover chevron. [#49733]
@@ -870,6 +878,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
870
878
  - Fixed lints following ESLint rule changes for TS [#40584]
871
879
  - Fixing a bug in Chart storybook data. [#40640]
872
880
 
881
+ [1.7.0]: https://github.com/Automattic/charts/compare/v1.6.0...v1.7.0
873
882
  [1.6.0]: https://github.com/Automattic/charts/compare/v1.5.3...v1.6.0
874
883
  [1.5.3]: https://github.com/Automattic/charts/compare/v1.5.2...v1.5.3
875
884
  [1.5.2]: https://github.com/Automattic/charts/compare/v1.5.1...v1.5.2
package/README.md CHANGED
@@ -6,8 +6,8 @@ Explore the available charts and their documentation in [Storybook](https://auto
6
6
 
7
7
  ## Requirements
8
8
 
9
- - **Node.js**: >= 20.10.0 (required by `@wordpress/ui` dependency)
10
- - **React**: 17.x or 18.x
9
+ - **Node.js**: >= 20.11.0
10
+ - **React**: 18.x or 19.x
11
11
 
12
12
  ## Quick Start
13
13
 
package/dist/index.cjs CHANGED
@@ -43,7 +43,6 @@ let _visx_gradient = require("@visx/gradient");
43
43
  let _visx_curve = require("@visx/curve");
44
44
  let _visx_responsive = require("@visx/responsive");
45
45
  let _visx_annotation = require("@visx/annotation");
46
- let _wordpress_icons = require("@wordpress/icons");
47
46
  let _visx_pattern = require("@visx/pattern");
48
47
  let _visx_tooltip = require("@visx/tooltip");
49
48
  let react_google_charts = require("react-google-charts");
@@ -52,6 +51,7 @@ dompurify = __toESM(dompurify, 1);
52
51
  let _babel_runtime_helpers_esm_extends = require("@babel/runtime/helpers/esm/extends");
53
52
  _babel_runtime_helpers_esm_extends = __toESM(_babel_runtime_helpers_esm_extends);
54
53
  require("@babel/runtime/helpers/extends");
54
+ let _wordpress_icons = require("@wordpress/icons");
55
55
  let _visx_shape = require("@visx/shape");
56
56
  //#region src/charts/private/single-chart-context/single-chart-context.tsx
57
57
  const ChartInstanceContext = (0, react$1.createContext)(null);
@@ -713,7 +713,7 @@ const defaultTheme = {
713
713
  leaderboardChart: {
714
714
  rowGap: 12,
715
715
  columnGap: 4,
716
- labelSpacing: 1.5,
716
+ labelSpacing: "xs",
717
717
  deltaColors: [
718
718
  "#FF8C8F",
719
719
  "#757575",
@@ -3063,6 +3063,19 @@ const LineChartAnnotationsOverlay = ({ children }) => {
3063
3063
  })
3064
3064
  });
3065
3065
  };
3066
+ const CloseIcon = () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
3067
+ width: "16",
3068
+ height: "16",
3069
+ viewBox: "0 0 24 24",
3070
+ fill: "none",
3071
+ stroke: "currentColor",
3072
+ strokeWidth: "2",
3073
+ strokeLinecap: "round",
3074
+ strokeLinejoin: "round",
3075
+ "aria-hidden": "true",
3076
+ focusable: "false",
3077
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M6 6l12 12M18 6L6 18" })
3078
+ });
3066
3079
  const LineChartAnnotationLabelWithPopover = ({ title, subtitle, renderLabel, renderLabelPopover }) => {
3067
3080
  const popoverId = (0, react$1.useId)();
3068
3081
  const buttonRef = (0, react$1.useRef)(null);
@@ -3124,10 +3137,7 @@ const LineChartAnnotationLabelWithPopover = ({ title, subtitle, renderLabel, ren
3124
3137
  popovertargetaction: "hide",
3125
3138
  className: line_chart_module_default["line-chart__annotation-label-popover-close-button"],
3126
3139
  "aria-label": (0, _wordpress_i18n.__)("Close", "jetpack-charts"),
3127
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_icons.Icon, {
3128
- icon: _wordpress_icons.close,
3129
- size: 16
3130
- })
3140
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CloseIcon, {})
3131
3141
  })]
3132
3142
  })
3133
3143
  })]
@@ -8142,13 +8152,15 @@ const defaultDeltaFormatter = (value) => {
8142
8152
  };
8143
8153
  /**
8144
8154
  * Build a bar's width. A hover-inset CSS variable (0 by default) is subtracted
8145
- * so interactive rows can pull the bar's right edge back by a fixed pixel amount
8146
- * on hover instead of a percentage scale keeping the bar↔value gap constant.
8155
+ * on hover, scaled by the bar's share so the pull-back is proportional to its
8156
+ * length: the full-length (100%) bar the one that reaches the value pulls
8157
+ * back the whole inset to keep its gap with the value, while shorter bars pull
8158
+ * back proportionally less, down to ~0 for a very short bar.
8147
8159
  *
8148
8160
  * @param share - The bar's share of the row width, as a percentage.
8149
8161
  * @return A CSS width value.
8150
8162
  */
8151
- const getBarWidth = (share) => `calc(${share}% - var(--a8c--charts--leaderboard--bar--hover-inset, 0px))`;
8163
+ const getBarWidth = (share) => `calc(${share}% - var(--a8c--charts--leaderboard--bar--hover-inset, 0px) * ${share} / 100)`;
8152
8164
  const BarLabel = ({ label }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: typeof label === "string" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Text$2, {
8153
8165
  className: leaderboard_chart_module_default.label,
8154
8166
  children: label
@@ -8357,6 +8369,7 @@ const LeaderboardChartInternal = ({ data, chartId: providedChartId, width: propW
8357
8369
  type: "button",
8358
8370
  className: leaderboard_chart_module_default.interactiveRow,
8359
8371
  onClick: entry.onClick,
8372
+ "aria-label": entry.ariaLabel,
8360
8373
  children: [rowCells, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_icons.Icon, {
8361
8374
  className: leaderboard_chart_module_default.chevron,
8362
8375
  icon: _wordpress_icons.chevronRight,