@automattic/charts 0.57.0 → 0.59.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 (267) hide show
  1. package/CHANGELOG.md +36 -2
  2. package/README.md +7 -54
  3. package/dist/index.cjs +9607 -21
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.css +32 -49
  6. package/dist/index.css.map +1 -1
  7. package/dist/index.d.cts +1612 -33
  8. package/dist/index.d.ts +1612 -33
  9. package/dist/index.js +9640 -54
  10. package/dist/index.js.map +1 -1
  11. package/package.json +9 -126
  12. package/src/charts/bar-chart/bar-chart.module.scss +0 -5
  13. package/src/charts/bar-chart/bar-chart.tsx +142 -149
  14. package/src/charts/bar-chart/test/bar-chart.test.tsx +48 -31
  15. package/src/charts/leaderboard-chart/leaderboard-chart.tsx +54 -74
  16. package/src/charts/leaderboard-chart/test/leaderboard-chart.test.tsx +4 -5
  17. package/src/charts/leaderboard-chart/types.ts +1 -11
  18. package/src/charts/line-chart/line-chart.module.scss +0 -5
  19. package/src/charts/line-chart/line-chart.tsx +202 -193
  20. package/src/charts/line-chart/private/line-chart-annotations-overlay.tsx +1 -2
  21. package/src/charts/line-chart/test/line-chart.test.tsx +49 -27
  22. package/src/charts/line-chart/types.ts +0 -1
  23. package/src/charts/pie-chart/pie-chart.module.scss +2 -10
  24. package/src/charts/pie-chart/pie-chart.tsx +212 -212
  25. package/src/charts/pie-chart/test/composition-api.test.tsx +44 -3
  26. package/src/charts/pie-chart/test/pie-chart.test.tsx +51 -44
  27. package/src/charts/pie-semi-circle-chart/pie-semi-circle-chart.module.scss +2 -8
  28. package/src/charts/pie-semi-circle-chart/pie-semi-circle-chart.tsx +166 -168
  29. package/src/charts/pie-semi-circle-chart/test/pie-semi-circle-chart.test.tsx +58 -30
  30. package/src/charts/private/chart-composition/index.ts +2 -0
  31. package/src/charts/private/chart-composition/render-legend-slot.ts +22 -0
  32. package/src/charts/private/chart-composition/test/render-legend-slot.test.tsx +60 -0
  33. package/src/charts/private/chart-composition/test/use-chart-children.test.tsx +91 -0
  34. package/src/charts/private/chart-composition/use-chart-children.ts +34 -2
  35. package/src/charts/private/chart-layout/chart-layout.module.scss +7 -0
  36. package/src/charts/private/chart-layout/chart-layout.tsx +106 -0
  37. package/src/charts/private/chart-layout/index.ts +2 -0
  38. package/src/charts/private/chart-layout/test/chart-layout.test.tsx +167 -0
  39. package/src/charts/private/single-chart-context/single-chart-context.tsx +2 -2
  40. package/src/charts/private/svg-empty-state/index.ts +1 -0
  41. package/src/charts/private/svg-empty-state/svg-empty-state.module.scss +7 -0
  42. package/src/charts/private/svg-empty-state/svg-empty-state.tsx +40 -0
  43. package/src/components/legend/hooks/test/use-chart-legend-items.test.tsx +12 -8
  44. package/src/components/legend/hooks/use-chart-legend-items.ts +12 -13
  45. package/src/components/legend/index.ts +1 -8
  46. package/src/components/legend/legend.tsx +33 -8
  47. package/src/components/legend/private/base-legend.module.scss +19 -37
  48. package/src/components/legend/private/base-legend.tsx +0 -2
  49. package/src/components/legend/test/legend.test.tsx +93 -1
  50. package/src/components/legend/types.ts +7 -34
  51. package/src/hooks/index.ts +1 -1
  52. package/src/hooks/use-data-with-percentages.ts +24 -0
  53. package/src/hooks/use-interactive-legend-data.ts +18 -15
  54. package/src/index.ts +66 -9
  55. package/src/providers/chart-context/global-charts-provider.tsx +7 -1
  56. package/src/providers/chart-context/hooks/use-chart-registration.ts +2 -1
  57. package/src/providers/chart-context/types.ts +2 -2
  58. package/src/types.ts +110 -45
  59. package/src/utils/date-parsing.ts +10 -1
  60. package/src/utils/test/date-parsing.test.ts +12 -0
  61. package/src/utils/test/resolve-css-var.test.ts +4 -2
  62. package/tsup.config.ts +1 -1
  63. package/dist/base-tooltip-DOq93wjU.d.cts +0 -38
  64. package/dist/base-tooltip-DOq93wjU.d.ts +0 -38
  65. package/dist/charts/bar-chart/index.cjs +0 -15
  66. package/dist/charts/bar-chart/index.cjs.map +0 -1
  67. package/dist/charts/bar-chart/index.css +0 -153
  68. package/dist/charts/bar-chart/index.css.map +0 -1
  69. package/dist/charts/bar-chart/index.d.cts +0 -37
  70. package/dist/charts/bar-chart/index.d.ts +0 -37
  71. package/dist/charts/bar-chart/index.js +0 -15
  72. package/dist/charts/bar-chart/index.js.map +0 -1
  73. package/dist/charts/bar-list-chart/index.cjs +0 -16
  74. package/dist/charts/bar-list-chart/index.cjs.map +0 -1
  75. package/dist/charts/bar-list-chart/index.css +0 -153
  76. package/dist/charts/bar-list-chart/index.css.map +0 -1
  77. package/dist/charts/bar-list-chart/index.d.cts +0 -92
  78. package/dist/charts/bar-list-chart/index.d.ts +0 -92
  79. package/dist/charts/bar-list-chart/index.js +0 -16
  80. package/dist/charts/bar-list-chart/index.js.map +0 -1
  81. package/dist/charts/conversion-funnel-chart/index.cjs +0 -11
  82. package/dist/charts/conversion-funnel-chart/index.cjs.map +0 -1
  83. package/dist/charts/conversion-funnel-chart/index.css +0 -251
  84. package/dist/charts/conversion-funnel-chart/index.css.map +0 -1
  85. package/dist/charts/conversion-funnel-chart/index.d.cts +0 -97
  86. package/dist/charts/conversion-funnel-chart/index.d.ts +0 -97
  87. package/dist/charts/conversion-funnel-chart/index.js +0 -11
  88. package/dist/charts/conversion-funnel-chart/index.js.map +0 -1
  89. package/dist/charts/geo-chart/index.cjs +0 -13
  90. package/dist/charts/geo-chart/index.cjs.map +0 -1
  91. package/dist/charts/geo-chart/index.css +0 -117
  92. package/dist/charts/geo-chart/index.css.map +0 -1
  93. package/dist/charts/geo-chart/index.d.cts +0 -67
  94. package/dist/charts/geo-chart/index.d.ts +0 -67
  95. package/dist/charts/geo-chart/index.js +0 -13
  96. package/dist/charts/geo-chart/index.js.map +0 -1
  97. package/dist/charts/leaderboard-chart/index.cjs +0 -20
  98. package/dist/charts/leaderboard-chart/index.cjs.map +0 -1
  99. package/dist/charts/leaderboard-chart/index.css +0 -172
  100. package/dist/charts/leaderboard-chart/index.css.map +0 -1
  101. package/dist/charts/leaderboard-chart/index.d.cts +0 -46
  102. package/dist/charts/leaderboard-chart/index.d.ts +0 -46
  103. package/dist/charts/leaderboard-chart/index.js +0 -20
  104. package/dist/charts/leaderboard-chart/index.js.map +0 -1
  105. package/dist/charts/line-chart/index.cjs +0 -15
  106. package/dist/charts/line-chart/index.cjs.map +0 -1
  107. package/dist/charts/line-chart/index.css +0 -225
  108. package/dist/charts/line-chart/index.css.map +0 -1
  109. package/dist/charts/line-chart/index.d.cts +0 -99
  110. package/dist/charts/line-chart/index.d.ts +0 -99
  111. package/dist/charts/line-chart/index.js +0 -15
  112. package/dist/charts/line-chart/index.js.map +0 -1
  113. package/dist/charts/pie-chart/index.cjs +0 -18
  114. package/dist/charts/pie-chart/index.cjs.map +0 -1
  115. package/dist/charts/pie-chart/index.css +0 -143
  116. package/dist/charts/pie-chart/index.css.map +0 -1
  117. package/dist/charts/pie-chart/index.d.cts +0 -97
  118. package/dist/charts/pie-chart/index.d.ts +0 -97
  119. package/dist/charts/pie-chart/index.js +0 -18
  120. package/dist/charts/pie-chart/index.js.map +0 -1
  121. package/dist/charts/pie-semi-circle-chart/index.cjs +0 -17
  122. package/dist/charts/pie-semi-circle-chart/index.cjs.map +0 -1
  123. package/dist/charts/pie-semi-circle-chart/index.css +0 -144
  124. package/dist/charts/pie-semi-circle-chart/index.css.map +0 -1
  125. package/dist/charts/pie-semi-circle-chart/index.d.cts +0 -94
  126. package/dist/charts/pie-semi-circle-chart/index.d.ts +0 -94
  127. package/dist/charts/pie-semi-circle-chart/index.js +0 -17
  128. package/dist/charts/pie-semi-circle-chart/index.js.map +0 -1
  129. package/dist/charts/sparkline/index.cjs +0 -16
  130. package/dist/charts/sparkline/index.cjs.map +0 -1
  131. package/dist/charts/sparkline/index.css +0 -242
  132. package/dist/charts/sparkline/index.css.map +0 -1
  133. package/dist/charts/sparkline/index.d.cts +0 -113
  134. package/dist/charts/sparkline/index.d.ts +0 -113
  135. package/dist/charts/sparkline/index.js +0 -16
  136. package/dist/charts/sparkline/index.js.map +0 -1
  137. package/dist/chunk-2A34OA5O.cjs +0 -51
  138. package/dist/chunk-2A34OA5O.cjs.map +0 -1
  139. package/dist/chunk-2NCY7R4G.js +0 -3897
  140. package/dist/chunk-2NCY7R4G.js.map +0 -1
  141. package/dist/chunk-32DH6JDF.js +0 -1263
  142. package/dist/chunk-32DH6JDF.js.map +0 -1
  143. package/dist/chunk-4OPFE4RM.js +0 -614
  144. package/dist/chunk-4OPFE4RM.js.map +0 -1
  145. package/dist/chunk-6CCZL2JJ.js +0 -63
  146. package/dist/chunk-6CCZL2JJ.js.map +0 -1
  147. package/dist/chunk-77OKCVQN.cjs +0 -421
  148. package/dist/chunk-77OKCVQN.cjs.map +0 -1
  149. package/dist/chunk-7FQX4ALL.cjs +0 -219
  150. package/dist/chunk-7FQX4ALL.cjs.map +0 -1
  151. package/dist/chunk-ASLARV7L.cjs +0 -81
  152. package/dist/chunk-ASLARV7L.cjs.map +0 -1
  153. package/dist/chunk-BCX5THDQ.js +0 -403
  154. package/dist/chunk-BCX5THDQ.js.map +0 -1
  155. package/dist/chunk-BPYKWMI7.js +0 -194
  156. package/dist/chunk-BPYKWMI7.js.map +0 -1
  157. package/dist/chunk-CZGYJKG6.js +0 -421
  158. package/dist/chunk-CZGYJKG6.js.map +0 -1
  159. package/dist/chunk-D2UH4CFE.cjs +0 -120
  160. package/dist/chunk-D2UH4CFE.cjs.map +0 -1
  161. package/dist/chunk-DAU3HNEG.js +0 -344
  162. package/dist/chunk-DAU3HNEG.js.map +0 -1
  163. package/dist/chunk-H2V4JMSA.js +0 -219
  164. package/dist/chunk-H2V4JMSA.js.map +0 -1
  165. package/dist/chunk-I2276W3I.cjs +0 -66
  166. package/dist/chunk-I2276W3I.cjs.map +0 -1
  167. package/dist/chunk-I35UYJJR.cjs +0 -468
  168. package/dist/chunk-I35UYJJR.cjs.map +0 -1
  169. package/dist/chunk-IU4DYUAV.js +0 -120
  170. package/dist/chunk-IU4DYUAV.js.map +0 -1
  171. package/dist/chunk-KXRWNFQJ.js +0 -51
  172. package/dist/chunk-KXRWNFQJ.js.map +0 -1
  173. package/dist/chunk-OP6PHB2U.js +0 -81
  174. package/dist/chunk-OP6PHB2U.js.map +0 -1
  175. package/dist/chunk-PXLEMUGJ.js +0 -165
  176. package/dist/chunk-PXLEMUGJ.js.map +0 -1
  177. package/dist/chunk-RCY6XLGU.cjs +0 -63
  178. package/dist/chunk-RCY6XLGU.cjs.map +0 -1
  179. package/dist/chunk-RHHVEJHJ.cjs +0 -1263
  180. package/dist/chunk-RHHVEJHJ.cjs.map +0 -1
  181. package/dist/chunk-TO3OQBXG.cjs +0 -165
  182. package/dist/chunk-TO3OQBXG.cjs.map +0 -1
  183. package/dist/chunk-V36ERY7Y.js +0 -375
  184. package/dist/chunk-V36ERY7Y.js.map +0 -1
  185. package/dist/chunk-VJM5XCB4.cjs +0 -614
  186. package/dist/chunk-VJM5XCB4.cjs.map +0 -1
  187. package/dist/chunk-VTS3PNMS.cjs +0 -344
  188. package/dist/chunk-VTS3PNMS.cjs.map +0 -1
  189. package/dist/chunk-WLODYNLB.js +0 -1067
  190. package/dist/chunk-WLODYNLB.js.map +0 -1
  191. package/dist/chunk-XKRJL2QT.cjs +0 -375
  192. package/dist/chunk-XKRJL2QT.cjs.map +0 -1
  193. package/dist/chunk-XWYZIFZW.js +0 -66
  194. package/dist/chunk-XWYZIFZW.js.map +0 -1
  195. package/dist/chunk-Y3NNQMAX.cjs +0 -194
  196. package/dist/chunk-Y3NNQMAX.cjs.map +0 -1
  197. package/dist/chunk-YE2T52VZ.cjs +0 -1067
  198. package/dist/chunk-YE2T52VZ.cjs.map +0 -1
  199. package/dist/chunk-Z26M4V2M.js +0 -468
  200. package/dist/chunk-Z26M4V2M.js.map +0 -1
  201. package/dist/chunk-Z45KX47P.cjs +0 -3897
  202. package/dist/chunk-Z45KX47P.cjs.map +0 -1
  203. package/dist/chunk-ZH4F5RMG.cjs +0 -403
  204. package/dist/chunk-ZH4F5RMG.cjs.map +0 -1
  205. package/dist/components/legend/index.cjs +0 -11
  206. package/dist/components/legend/index.cjs.map +0 -1
  207. package/dist/components/legend/index.css +0 -103
  208. package/dist/components/legend/index.css.map +0 -1
  209. package/dist/components/legend/index.d.cts +0 -37
  210. package/dist/components/legend/index.d.ts +0 -37
  211. package/dist/components/legend/index.js +0 -11
  212. package/dist/components/legend/index.js.map +0 -1
  213. package/dist/components/tooltip/index.cjs +0 -12
  214. package/dist/components/tooltip/index.cjs.map +0 -1
  215. package/dist/components/tooltip/index.css +0 -13
  216. package/dist/components/tooltip/index.css.map +0 -1
  217. package/dist/components/tooltip/index.d.cts +0 -71
  218. package/dist/components/tooltip/index.d.ts +0 -71
  219. package/dist/components/tooltip/index.js +0 -12
  220. package/dist/components/tooltip/index.js.map +0 -1
  221. package/dist/components/trend-indicator/index.cjs +0 -8
  222. package/dist/components/trend-indicator/index.cjs.map +0 -1
  223. package/dist/components/trend-indicator/index.css +0 -27
  224. package/dist/components/trend-indicator/index.css.map +0 -1
  225. package/dist/components/trend-indicator/index.d.cts +0 -44
  226. package/dist/components/trend-indicator/index.d.ts +0 -44
  227. package/dist/components/trend-indicator/index.js +0 -8
  228. package/dist/components/trend-indicator/index.js.map +0 -1
  229. package/dist/format-metric-value-MXm5DtQ_.d.cts +0 -24
  230. package/dist/format-metric-value-MXm5DtQ_.d.ts +0 -24
  231. package/dist/hooks/index.cjs +0 -31
  232. package/dist/hooks/index.cjs.map +0 -1
  233. package/dist/hooks/index.css +0 -103
  234. package/dist/hooks/index.css.map +0 -1
  235. package/dist/hooks/index.d.cts +0 -272
  236. package/dist/hooks/index.d.ts +0 -272
  237. package/dist/hooks/index.js +0 -31
  238. package/dist/hooks/index.js.map +0 -1
  239. package/dist/leaderboard-chart-BKYYXcg2.d.ts +0 -83
  240. package/dist/leaderboard-chart-DR7CGb0L.d.cts +0 -83
  241. package/dist/legend-C2grwnWk.d.cts +0 -9
  242. package/dist/legend-Cj0xM5dU.d.ts +0 -9
  243. package/dist/providers/index.cjs +0 -21
  244. package/dist/providers/index.cjs.map +0 -1
  245. package/dist/providers/index.css +0 -103
  246. package/dist/providers/index.css.map +0 -1
  247. package/dist/providers/index.d.cts +0 -28
  248. package/dist/providers/index.d.ts +0 -28
  249. package/dist/providers/index.js +0 -21
  250. package/dist/providers/index.js.map +0 -1
  251. package/dist/themes-BmVGrYnF.d.ts +0 -67
  252. package/dist/themes-CyjKm-P_.d.cts +0 -67
  253. package/dist/types-CuUEszrM.d.ts +0 -19
  254. package/dist/types-DZordNiO.d.cts +0 -505
  255. package/dist/types-DZordNiO.d.ts +0 -505
  256. package/dist/types-I67mddpr.d.cts +0 -78
  257. package/dist/types-I67mddpr.d.ts +0 -78
  258. package/dist/types-KtOPPzPX.d.cts +0 -19
  259. package/dist/utils/index.cjs +0 -44
  260. package/dist/utils/index.cjs.map +0 -1
  261. package/dist/utils/index.d.cts +0 -226
  262. package/dist/utils/index.d.ts +0 -226
  263. package/dist/utils/index.js +0 -44
  264. package/dist/utils/index.js.map +0 -1
  265. package/dist/with-responsive-CNfhzAUu.d.cts +0 -18
  266. package/dist/with-responsive-CNfhzAUu.d.ts +0 -18
  267. package/src/hooks/use-has-legend-child.ts +0 -22
@@ -1,120 +0,0 @@
1
- import {
2
- withResponsive
3
- } from "./chunk-OP6PHB2U.js";
4
- import {
5
- GlobalChartsContext,
6
- GlobalChartsProvider,
7
- useGlobalChartsContext
8
- } from "./chunk-32DH6JDF.js";
9
- import {
10
- lightenHexColor,
11
- normalizeColorToHex,
12
- resolveCssVariable
13
- } from "./chunk-DAU3HNEG.js";
14
-
15
- // src/charts/geo-chart/geo-chart.tsx
16
- import { __ } from "@wordpress/i18n";
17
- import clsx from "clsx";
18
- import { useContext, useMemo } from "react";
19
- import { Chart } from "react-google-charts";
20
-
21
- // src/charts/geo-chart/geo-chart.module.scss
22
- var geo_chart_module_default = {
23
- "container": "a8ccharts-JvcqOz"
24
- };
25
-
26
- // src/charts/geo-chart/geo-chart.tsx
27
- import { jsx as _jsx } from "react/jsx-runtime";
28
- var DEFAULT_FEATURE_FILL_COLOR = "#ffffff";
29
- var DEFAULT_BACKGROUND_COLOR = "#ffffff";
30
- var GeoChartInternal = ({
31
- className,
32
- data,
33
- width,
34
- height,
35
- region = "world",
36
- resolution = "countries",
37
- renderPlaceholder
38
- }) => {
39
- const {
40
- getElementStyles,
41
- theme: {
42
- geoChart: {
43
- featureFillColor
44
- },
45
- backgroundColor
46
- }
47
- } = useGlobalChartsContext();
48
- const loadingPlaceholder = /* @__PURE__ */ _jsx("div", {
49
- className: clsx("geo-chart", geo_chart_module_default.container, className),
50
- style: {
51
- width,
52
- height
53
- },
54
- children: renderPlaceholder ? renderPlaceholder() : __("Loading map", "jetpack-charts")
55
- });
56
- const fullColorHex = getElementStyles({
57
- index: 0
58
- }).color;
59
- const lightColorHex = lightenHexColor(fullColorHex, 0.8);
60
- const backgroundColorHex = normalizeColorToHex(backgroundColor, null, resolveCssVariable) || DEFAULT_BACKGROUND_COLOR;
61
- const defaultFillColorHex = normalizeColorToHex(featureFillColor, null, resolveCssVariable) || DEFAULT_FEATURE_FILL_COLOR;
62
- const hasHtmlTooltips = useMemo(() => data.length > 0 && data[0].some((col) => typeof col === "object" && col !== null && "role" in col && col.role === "tooltip" && "p" in col && typeof col.p === "object" && col.p !== null && "html" in col.p && col.p.html === true), [data]);
63
- const options = useMemo(() => ({
64
- ...region !== "world" && {
65
- region
66
- },
67
- ...resolution !== "countries" && {
68
- resolution
69
- },
70
- colorAxis: {
71
- colors: [lightColorHex, fullColorHex]
72
- },
73
- backgroundColor: backgroundColorHex,
74
- datalessRegionColor: defaultFillColorHex,
75
- defaultColor: defaultFillColorHex,
76
- tooltip: {
77
- trigger: "focus",
78
- isHtml: hasHtmlTooltips
79
- },
80
- legend: "none",
81
- keepAspectRatio: true
82
- }), [region, resolution, lightColorHex, fullColorHex, backgroundColorHex, defaultFillColorHex, hasHtmlTooltips]);
83
- return /* @__PURE__ */ _jsx("div", {
84
- className: clsx("geo-chart", geo_chart_module_default.container, className),
85
- style: {
86
- width,
87
- height,
88
- backgroundColor
89
- },
90
- children: /* @__PURE__ */ _jsx(Chart, {
91
- chartType: "GeoChart",
92
- width,
93
- height,
94
- data,
95
- options,
96
- loader: loadingPlaceholder
97
- })
98
- });
99
- };
100
- var GeoChartWithProvider = (props) => {
101
- const existingContext = useContext(GlobalChartsContext);
102
- if (existingContext) {
103
- return /* @__PURE__ */ _jsx(GeoChartInternal, {
104
- ...props
105
- });
106
- }
107
- return /* @__PURE__ */ _jsx(GlobalChartsProvider, {
108
- children: /* @__PURE__ */ _jsx(GeoChartInternal, {
109
- ...props
110
- })
111
- });
112
- };
113
- GeoChartWithProvider.displayName = "GeoChart";
114
- var GeoChartResponsive = withResponsive(GeoChartWithProvider);
115
-
116
- export {
117
- GeoChartWithProvider,
118
- GeoChartResponsive
119
- };
120
- //# sourceMappingURL=chunk-IU4DYUAV.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/charts/geo-chart/geo-chart.tsx","../src/charts/geo-chart/geo-chart.module.scss"],"sourcesContent":["/**\n * External dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport clsx from 'clsx';\nimport { useContext, useMemo } from 'react';\nimport { Chart } from 'react-google-charts';\n/**\n * Internal dependencies\n */\nimport { GlobalChartsContext, GlobalChartsProvider, useGlobalChartsContext } from '../../providers';\nimport { lightenHexColor, normalizeColorToHex } from '../../utils/color-utils';\nimport { resolveCssVariable } from '../../utils/resolve-css-var';\nimport { withResponsive } from '../private/with-responsive';\nimport styles from './geo-chart.module.scss';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst DEFAULT_FEATURE_FILL_COLOR = '#ffffff';\nconst DEFAULT_BACKGROUND_COLOR = '#ffffff';\n\n/**\n * Renders a geographical chart using Google Charts GeoChart to visualize data.\n *\n * Supports the full Google Charts data format including custom tooltips, formatted values,\n * and multiple data columns for maximum flexibility.\n *\n * Locations can be identified by full name (e.g., 'United States', 'California') or codes\n * (e.g., 'US', 'US-CA'). Full names are recommended for better readability in tooltips.\n *\n * @param props - The props for the GeoChart component\n * @param props.data - Data in Google Charts format (array of arrays with headers)\n * @param props.width - Width of the chart in pixels\n * @param props.height - Height of the chart in pixels\n * @param props.region - Region to display ('world', 'US', or ISO 3166-1 alpha-2 code)\n * @param props.resolution - Resolution level ('countries', 'provinces', or 'metros')\n * @param props.className - Additional CSS class name for the chart container\n * @param props.renderPlaceholder - Optional render function for the loading placeholder\n * @return A React component displaying an interactive map with data visualization\n */\nconst GeoChartInternal = ({\n className,\n data,\n width,\n height,\n region = 'world',\n resolution = 'countries',\n renderPlaceholder\n}) => {\n const {\n getElementStyles,\n theme: {\n geoChart: {\n featureFillColor\n },\n backgroundColor\n }\n } = useGlobalChartsContext();\n\n // Render loading placeholder\n const loadingPlaceholder = /*#__PURE__*/_jsx(\"div\", {\n className: clsx('geo-chart', styles.container, className),\n style: {\n width,\n height\n },\n children: renderPlaceholder ? renderPlaceholder() : __('Loading map', 'jetpack-charts')\n });\n\n // Google charts doesn't accept CSS variables, so we need to convert them to hex colors\n const fullColorHex = getElementStyles({\n index: 0\n }).color;\n const lightColorHex = lightenHexColor(fullColorHex, 0.8);\n // Use normalizeColorToHex to ensure HSL/RGB values from CSS variables are converted to hex\n const backgroundColorHex = normalizeColorToHex(backgroundColor, null, resolveCssVariable) || DEFAULT_BACKGROUND_COLOR;\n const defaultFillColorHex = normalizeColorToHex(featureFillColor, null, resolveCssVariable) || DEFAULT_FEATURE_FILL_COLOR;\n\n // Check if data has HTML tooltips (column with role: 'tooltip' and p.html: true)\n const hasHtmlTooltips = useMemo(() => data.length > 0 && data[0].some(col => typeof col === 'object' && col !== null && 'role' in col && col.role === 'tooltip' && 'p' in col && typeof col.p === 'object' && col.p !== null && 'html' in col.p && col.p.html === true), [data]);\n const options = useMemo(() => ({\n ...(region !== 'world' && {\n region\n }),\n ...(resolution !== 'countries' && {\n resolution\n }),\n colorAxis: {\n colors: [lightColorHex, fullColorHex]\n },\n backgroundColor: backgroundColorHex,\n datalessRegionColor: defaultFillColorHex,\n defaultColor: defaultFillColorHex,\n tooltip: {\n trigger: 'focus',\n isHtml: hasHtmlTooltips\n },\n legend: 'none',\n keepAspectRatio: true\n }), [region, resolution, lightColorHex, fullColorHex, backgroundColorHex, defaultFillColorHex, hasHtmlTooltips]);\n return /*#__PURE__*/_jsx(\"div\", {\n className: clsx('geo-chart', styles.container, className),\n style: {\n width,\n height,\n backgroundColor\n },\n children: /*#__PURE__*/_jsx(Chart, {\n chartType: \"GeoChart\",\n width: width,\n height: height,\n data: data,\n options: options,\n loader: loadingPlaceholder\n })\n });\n};\nconst GeoChartWithProvider = props => {\n const existingContext = useContext(GlobalChartsContext);\n\n // If we're already in a GlobalChartsProvider context, don't create a new one\n if (existingContext) {\n return /*#__PURE__*/_jsx(GeoChartInternal, {\n ...props\n });\n }\n\n // Otherwise, create our own GlobalChartsProvider\n return /*#__PURE__*/_jsx(GlobalChartsProvider, {\n children: /*#__PURE__*/_jsx(GeoChartInternal, {\n ...props\n })\n });\n};\nGeoChartWithProvider.displayName = 'GeoChart';\nconst GeoChartResponsive = withResponsive(GeoChartWithProvider);\nexport { GeoChartResponsive as default, GeoChartWithProvider as GeoChartUnresponsive };","import 'css-chunk:src/charts/geo-chart/geo-chart.module.scss';export default {\n \"container\": \"a8ccharts-JvcqOz\"\n};"],"mappings":";;;;;;;;;;;;;;;AAGA,SAAS,UAAU;AACnB,OAAO,UAAU;AACjB,SAAS,YAAY,eAAe;AACpC,SAAS,aAAa;;;ACNwC,IAAO,2BAAQ;AAAA,EAC3E,aAAa;AACf;;;ADaA,SAAS,OAAO,YAAY;AAC5B,IAAM,6BAA6B;AACnC,IAAM,2BAA2B;AAqBjC,IAAM,mBAAmB,CAAC;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,aAAa;AAAA,EACb;AACF,MAAM;AACJ,QAAM;AAAA,IACJ;AAAA,IACA,OAAO;AA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C/G,SAAoB,qBAAK,OAAO;AAAA,IAC9B,WAAW,KAAK,aAAa,yBAAO,WAAW,SAAS;AAAA,IACxD,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,UAAuB,qBAAK,OAAO;AAAA,MACjC,WAAW;AAAA,MACX;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,QAAQ;AAAA,IACV,CAAC;AAAA,EACH,CAAC;AACH;AACA,IAAM,uBAAuB,WAAS;AACpC,QAAM,kBAAkB,WAAW,mBAAmB;AAGtD,MAAI,iBAAiB;AACnB,WAAoB,qBAAK,kBAAkB;AAAA,MACzC,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAGA,SAAoB,qBAAK,sBAAsB;AAAA,IAC7C,UAAuB,qBAAK,kBAAkB;AAAA,MAC5C,GAAG;AAAA,IACL,CAAC;AAAA,EACH,CAAC;AACH;AACA,qBAAqB,cAAc;AACnC,IAAM,qBAAqB,eAAe,oBAAoB;","names":[]}
@@ -1,51 +0,0 @@
1
- // src/charts/private/radial-wipe-animation/radial-wipe-animation.tsx
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- function RadialWipeAnimation({
4
- id,
5
- radius,
6
- innerRadius = 0,
7
- durationMs = 1e3,
8
- wipePercentage = 100,
9
- direction = "clockwise",
10
- startAngle = "-90deg"
11
- }) {
12
- const strokeWidth = (radius - innerRadius) * 2 + // The stroke is centered on the circumference, so we need to double the width.
13
- 1;
14
- const scaleY = direction === "clockwise" ? -1 : 1;
15
- const isValidWipePercentage = 0 < wipePercentage && wipePercentage <= 100;
16
- const animationDuration = `${// If wipePercentage is invalid, set animation duration to 0 to disable animation.
17
- isValidWipePercentage ? durationMs * (100 / wipePercentage) : 0}ms`;
18
- return /* @__PURE__ */ _jsx("mask", {
19
- id,
20
- children: /* @__PURE__ */ _jsx("circle", {
21
- cx: 0,
22
- cy: 0,
23
- r: radius,
24
- pathLength: "100",
25
- fill: "white",
26
- stroke: "black",
27
- strokeWidth,
28
- strokeDasharray: "100, 1000",
29
- strokeDashoffset: "0",
30
- style: {
31
- transform: `rotate(${startAngle}) scaleY(${scaleY})`
32
- },
33
- children: /* @__PURE__ */ _jsx("animate", {
34
- attributeName: "stroke-dashoffset",
35
- from: "0",
36
- to: "100.1",
37
- dur: animationDuration,
38
- fill: "freeze",
39
- calcMode: "spline",
40
- keySplines: "0.42 0 0.58 1;0 0 1 1",
41
- keyTimes: `0;${wipePercentage / 100};1`
42
- })
43
- })
44
- });
45
- }
46
- var radial_wipe_animation_default = RadialWipeAnimation;
47
-
48
- export {
49
- radial_wipe_animation_default
50
- };
51
- //# sourceMappingURL=chunk-KXRWNFQJ.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/charts/private/radial-wipe-animation/radial-wipe-animation.tsx"],"sourcesContent":["import { jsx as _jsx } from \"react/jsx-runtime\";\n/**\n * This animation uses the SVG self-drawing technique (source: https://www.joshwcomeau.com/svg/friendly-introduction-to-svg/),\n * leveraging stroke-dasharray and stroke-dashoffset properties to create the effect.\n *\n * Here, we reverse the animation to \"un-draw\" the circle for the revealing / radial wipe effect:\n * - Initially, the entire circle is drawn with a white mask.\n * - The circle's border (stroke) is drawn with a black stroke, wide enough to cover the circle.\n * - The stroke is then \"un-drawn,\" creating the wipe animation.\n * - A white mask makes the area visible, while a black mask makes the area invisible.\n */\n\n/**\n * RadialWipeAnimationProps - SVG mask props that requires a radial wipe animation effect.\n *\n * @param {object} props - The properties object.\n * @param {string} props.id - The unique ID for the mask.\n * @param {number} props.radius - The outer radius of the radial wipe.\n * @param {number} [props.innerRadius=0] - The inner radius of the radial wipe.\n * @param {number} [props.durationMs=1000] - The duration of the animation in milliseconds.\n * @param {number} [props.wipePercentage=100] - The percentage of the wipe animation to complete.\n * @param {'clockwise' | 'counter-clockwise'} [props.direction='clockwise'] - The direction of the wipe animation.\n * @param {Angle} [props.startAngle='-90deg'] - The starting angle of the wipe animation.\n *\n * @return {JSX.Element} The radial wipe mask element.\n */\n\n/**\n * Renders a SVG mask that creates a radial wipe animation effect.\n *\n * @param {RadialWipeAnimationProps} props - Component props\n * @return {JSX.Element} The rendered mask component\n */\nfunction RadialWipeAnimation({\n id,\n radius,\n innerRadius = 0,\n durationMs = 1000,\n wipePercentage = 100,\n direction = 'clockwise',\n startAngle = '-90deg'\n}) {\n const strokeWidth = (radius - innerRadius) * 2 +\n // The stroke is centered on the circumference, so we need to double the width.\n 1; // Added 1 to prevent sub-pixel rendering issues.\n\n const scaleY = direction === 'clockwise' ? -1 : 1;\n const isValidWipePercentage = 0 < wipePercentage && wipePercentage <= 100;\n const animationDuration = `${\n // If wipePercentage is invalid, set animation duration to 0 to disable animation.\n isValidWipePercentage ? durationMs * (100 / wipePercentage) : 0}ms`;\n return /*#__PURE__*/_jsx(\"mask\", {\n id: id,\n children: /*#__PURE__*/_jsx(\"circle\", {\n cx: 0,\n cy: 0,\n r: radius,\n pathLength: \"100\",\n fill: \"white\",\n stroke: \"black\" // The stroke will be un-drawn, hence 'black' mask.\n ,\n strokeWidth: strokeWidth,\n strokeDasharray: \"100, 1000\",\n strokeDashoffset: \"0\",\n style: {\n transform: `rotate(${startAngle}) scaleY(${scaleY})`\n },\n children: /*#__PURE__*/_jsx(\"animate\", {\n attributeName: \"stroke-dashoffset\",\n from: \"0\",\n to: \"100.1\",\n dur: animationDuration,\n fill: \"freeze\" // Same as CSS 'forwards' to retain the final state after animation.\n ,\n calcMode: \"spline\" // custom easing\n ,\n keySplines: \"0.42 0 0.58 1;0 0 1 1\" // ease-in-out ; linear (unimportant)\n ,\n keyTimes: `0;${wipePercentage / 100};1`\n })\n })\n });\n}\nexport default RadialWipeAnimation;"],"mappings":";AAAA,SAAS,OAAO,YAAY;AAiC5B,SAAS,oBAAoB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,YAAY;AAAA,EACZ,aAAa;AACf,GAAG;AACD,QAAM,eAAe,SAAS,eAAe;AAAA,EAE7C;AAEA,QAAM,SAAS,cAAc,cAAc,KAAK;AAChD,QAAM,wBAAwB,IAAI,kBAAkB,kBAAkB;AACtE,QAAM,oBAAoB;AAAA,EAE1B,wBAAwB,cAAc,MAAM,kBAAkB,CAAC;AAC/D,SAAoB,qBAAK,QAAQ;AAAA,IAC/B;AAAA,IACA,UAAuB,qBAAK,UAAU;AAAA,MACpC,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,GAAG;AAAA,MACH,YAAY;AAAA,MACZ,MAAM;AAAA,MACN,QAAQ;AAAA,MAER;AAAA,MACA,iBAAiB;AAAA,MACjB,kBAAkB;AAAA,MAClB,OAAO;AAAA,QACL,WAAW,UAAU,UAAU,YAAY,MAAM;AAAA,MACnD;AAAA,MACA,UAAuB,qBAAK,WAAW;AAAA,QACrC,eAAe;AAAA,QACf,MAAM;AAAA,QACN,IAAI;AAAA,QACJ,KAAK;AAAA,QACL,MAAM;AAAA,QAEN,UAAU;AAAA,QAEV,YAAY;AAAA,QAEZ,UAAU,KAAK,iBAAiB,GAAG;AAAA,MACrC,CAAC;AAAA,IACH,CAAC;AAAA,EACH,CAAC;AACH;AACA,IAAO,gCAAQ;","names":[]}
@@ -1,81 +0,0 @@
1
- // src/charts/private/with-responsive/with-responsive.tsx
2
- import { useParentSize } from "@visx/responsive";
3
-
4
- // src/charts/private/with-responsive/with-responsive.module.scss
5
- var with_responsive_module_default = {
6
- "container": "a8ccharts-GSKfBD"
7
- };
8
-
9
- // src/charts/private/with-responsive/with-responsive.tsx
10
- import { jsx as _jsx } from "react/jsx-runtime";
11
- var useResponsiveDimensions = ({
12
- resizeDebounceTime = 300,
13
- maxWidth = 1200,
14
- aspectRatio
15
- }) => {
16
- const {
17
- parentRef,
18
- width: parentWidth,
19
- height: parentHeight
20
- } = useParentSize({
21
- debounceTime: resizeDebounceTime,
22
- enableDebounceLeadingCall: true
23
- });
24
- const containerWidth = parentWidth > 0 ? Math.min(parentWidth, maxWidth) : 0;
25
- const containerHeight = aspectRatio !== void 0 ? containerWidth * aspectRatio : parentHeight;
26
- return {
27
- parentRef,
28
- width: containerWidth,
29
- height: containerHeight,
30
- /**
31
- * Whether an aspectRatio was provided. Used to determine container
32
- * height styling: 'auto' when true (height derived from width),
33
- * '100%' when false (fill parent container).
34
- */
35
- hasAspectRatio: aspectRatio !== void 0
36
- };
37
- };
38
- function withResponsive(WrappedComponent) {
39
- return function ResponsiveChart({
40
- resizeDebounceTime = 300,
41
- maxWidth = 1200,
42
- aspectRatio,
43
- size,
44
- width,
45
- height,
46
- ...chartProps
47
- }) {
48
- const {
49
- parentRef,
50
- width: measuredWidth,
51
- height: measuredHeight,
52
- hasAspectRatio
53
- } = useResponsiveDimensions({
54
- resizeDebounceTime,
55
- maxWidth,
56
- aspectRatio
57
- });
58
- const effectiveWidth = measuredWidth || width || 0;
59
- const effectiveHeight = measuredHeight || height || 0;
60
- const defaultHeight = hasAspectRatio ? "auto" : "100%";
61
- return /* @__PURE__ */ _jsx("div", {
62
- ref: parentRef,
63
- className: with_responsive_module_default.container,
64
- style: {
65
- width: width ?? "100%",
66
- height: height ?? defaultHeight
67
- },
68
- children: /* @__PURE__ */ _jsx(WrappedComponent, {
69
- width: effectiveWidth,
70
- height: effectiveHeight,
71
- size,
72
- ...chartProps
73
- })
74
- });
75
- };
76
- }
77
-
78
- export {
79
- withResponsive
80
- };
81
- //# sourceMappingURL=chunk-OP6PHB2U.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/charts/private/with-responsive/with-responsive.tsx","../src/charts/private/with-responsive/with-responsive.module.scss"],"sourcesContent":["import { useParentSize } from '@visx/responsive';\nimport styles from './with-responsive.module.scss';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst useResponsiveDimensions = ({\n resizeDebounceTime = 300,\n maxWidth = 1200,\n aspectRatio\n}) => {\n const {\n parentRef,\n width: parentWidth,\n height: parentHeight\n } = useParentSize({\n debounceTime: resizeDebounceTime,\n enableDebounceLeadingCall: true\n });\n const containerWidth = parentWidth > 0 ? Math.min(parentWidth, maxWidth) : 0;\n const containerHeight = aspectRatio !== undefined ? containerWidth * aspectRatio : parentHeight;\n return {\n parentRef,\n width: containerWidth,\n height: containerHeight,\n /**\n * Whether an aspectRatio was provided. Used to determine container\n * height styling: 'auto' when true (height derived from width),\n * '100%' when false (fill parent container).\n */\n hasAspectRatio: aspectRatio !== undefined\n };\n};\n\n/**\n * A higher-order component that provides responsive dimensions\n * to the wrapped chart component using useParentSize from `@visx/responsive`.\n *\n * @param WrappedComponent - The chart component to be wrapped.\n * @return A functional component that renders the wrapped component with responsive dimensions.\n */\nexport function withResponsive(\n// 'options' is excluded so that each chart can define its own options type\nWrappedComponent) {\n return function ResponsiveChart({\n resizeDebounceTime = 300,\n maxWidth = 1200,\n aspectRatio,\n size,\n width,\n height,\n ...chartProps\n }) {\n const {\n parentRef,\n width: measuredWidth,\n height: measuredHeight,\n hasAspectRatio\n } = useResponsiveDimensions({\n resizeDebounceTime,\n maxWidth,\n aspectRatio\n });\n\n // Use measured dimensions, but fall back to explicit width/height props if measurement returns 0\n // (e.g., during initial render or in test environments without DOM measurement).\n // Do not use size here — size controls chart element dimensions (e.g. pie diameter), not container dimensions.\n const effectiveWidth = measuredWidth || width || 0;\n const effectiveHeight = measuredHeight || height || 0;\n const defaultHeight = hasAspectRatio ? 'auto' : '100%';\n return /*#__PURE__*/_jsx(\"div\", {\n ref: parentRef,\n className: styles.container,\n style: {\n width: width ?? '100%',\n height: height ?? defaultHeight\n },\n children: /*#__PURE__*/_jsx(WrappedComponent, {\n width: effectiveWidth,\n height: effectiveHeight,\n size: size,\n ...chartProps\n })\n });\n };\n}","import 'css-chunk:src/charts/private/with-responsive/with-responsive.module.scss';export default {\n \"container\": \"a8ccharts-GSKfBD\"\n};"],"mappings":";AAAA,SAAS,qBAAqB;;;ACAoD,IAAO,iCAAQ;AAAA,EAC/F,aAAa;AACf;;;ADAA,SAAS,OAAO,YAAY;AAC5B,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from "./chunk-WLODYNLB.js";
4
- import {
5
- withResponsive
6
- } from "./chunk-OP6PHB2U.js";
7
- import {
8
- useGlobalChartsTheme
9
- } from "./chunk-32DH6JDF.js";
10
-
11
- // src/charts/sparkline/sparkline.tsx
12
- import clsx from "clsx";
13
- import { useMemo, forwardRef } from "react";
14
-
15
- // src/charts/sparkline/sparkline.module.scss
16
- var sparkline_module_default = {
17
- "sparkline": "a8ccharts-o-3Z8B",
18
- "sparkline--empty": "a8ccharts-CbLbcd"
19
- };
20
-
21
- // src/charts/sparkline/sparkline.tsx
22
- import { jsx as _jsx } from "react/jsx-runtime";
23
- var DEFAULT_WIDTH = 100;
24
- var DEFAULT_HEIGHT = 40;
25
- var transformToSeriesData = (data, color, strokeWidth) => {
26
- const baseDate = new Date(2e3, 0, 1);
27
- return [{
28
- label: "sparkline",
29
- data: data.map((value, index) => ({
30
- date: new Date(baseDate.getTime() + index * 864e5),
31
- // Add days
32
- value
33
- })),
34
- options: {
35
- stroke: color,
36
- seriesLineStyle: strokeWidth ? {
37
- strokeWidth
38
- } : void 0
39
- }
40
- }];
41
- };
42
- var SparklineComponent = /* @__PURE__ */ forwardRef(({
43
- data,
44
- width = DEFAULT_WIDTH,
45
- height = DEFAULT_HEIGHT,
46
- color,
47
- strokeWidth: strokeWidthProp,
48
- withGradientFill = true,
49
- gradient,
50
- className,
51
- chartId,
52
- margin: marginProp,
53
- animation
54
- }, ref) => {
55
- const theme = useGlobalChartsTheme();
56
- const themeStrokeWidth = theme.sparkline?.strokeWidth ?? 1.5;
57
- const strokeWidth = strokeWidthProp ?? themeStrokeWidth;
58
- const seriesData = useMemo(() => {
59
- if (!data || data.length === 0) {
60
- return [];
61
- }
62
- return transformToSeriesData(data, color, strokeWidth);
63
- }, [data, color, strokeWidth]);
64
- const finalMargin = useMemo(() => {
65
- const themeMargin = theme.sparkline?.margin ?? {
66
- top: 2,
67
- right: 2,
68
- bottom: 2,
69
- left: 2
70
- };
71
- const margin = marginProp ?? themeMargin;
72
- return {
73
- ...themeMargin,
74
- ...margin
75
- };
76
- }, [marginProp, theme.sparkline?.margin]);
77
- const seriesWithGradient = useMemo(() => {
78
- if (!gradient || seriesData.length === 0) {
79
- return seriesData;
80
- }
81
- return seriesData.map((series) => ({
82
- ...series,
83
- options: {
84
- ...series.options,
85
- gradient: {
86
- from: gradient.from || color || "#000000",
87
- to: gradient.to || "#ffffff",
88
- fromOpacity: gradient.fromOpacity ?? 0.5,
89
- toOpacity: gradient.toOpacity ?? 0
90
- }
91
- }
92
- }));
93
- }, [seriesData, gradient, color]);
94
- if (!data || data.length === 0) {
95
- return /* @__PURE__ */ _jsx("div", {
96
- ref,
97
- className: clsx("sparkline", sparkline_module_default.sparkline, sparkline_module_default["sparkline--empty"], className),
98
- style: {
99
- width,
100
- height
101
- }
102
- });
103
- }
104
- if (data.length === 1) {
105
- const cx = width / 2;
106
- const cy = height / 2;
107
- const resolvedColor = color || "#000000";
108
- return /* @__PURE__ */ _jsx("div", {
109
- ref,
110
- className: clsx("sparkline", sparkline_module_default.sparkline, sparkline_module_default["sparkline--single-point"], className),
111
- style: {
112
- width,
113
- height
114
- },
115
- children: /* @__PURE__ */ _jsx("svg", {
116
- width,
117
- height,
118
- "aria-hidden": "true",
119
- children: /* @__PURE__ */ _jsx("circle", {
120
- cx,
121
- cy,
122
- r: strokeWidth * 1.5,
123
- fill: resolvedColor
124
- })
125
- })
126
- });
127
- }
128
- return /* @__PURE__ */ _jsx("div", {
129
- ref,
130
- className: clsx("sparkline", sparkline_module_default.sparkline, className),
131
- children: /* @__PURE__ */ _jsx(LineChart, {
132
- data: seriesWithGradient,
133
- width,
134
- height,
135
- margin: finalMargin,
136
- chartId,
137
- withGradientFill,
138
- withTooltips: false,
139
- showLegend: false,
140
- gridVisibility: "none",
141
- options: {
142
- axis: {
143
- x: {
144
- display: false
145
- },
146
- y: {
147
- display: false
148
- }
149
- }
150
- },
151
- curveType: "monotone",
152
- animation
153
- })
154
- });
155
- });
156
- SparklineComponent.displayName = "SparklineComponent";
157
- var SparklineUnresponsive = SparklineComponent;
158
- SparklineUnresponsive.displayName = "SparklineUnresponsive";
159
- var Sparkline = withResponsive(SparklineUnresponsive);
160
-
161
- export {
162
- SparklineUnresponsive,
163
- Sparkline
164
- };
165
- //# sourceMappingURL=chunk-PXLEMUGJ.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/charts/sparkline/sparkline.tsx","../src/charts/sparkline/sparkline.module.scss"],"sourcesContent":["import clsx from 'clsx';\nimport { useMemo, forwardRef } from 'react';\nimport { useGlobalChartsTheme } from '../../providers';\nimport { LineChartUnresponsive } from '../line-chart';\nimport { withResponsive } from '../private/with-responsive';\nimport styles from './sparkline.module.scss';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst DEFAULT_WIDTH = 100;\nconst DEFAULT_HEIGHT = 40;\n\n/**\n * Transforms a simple number array into SeriesData format for LineChart.\n * Uses index-based dates to create a linear x-axis.\n *\n * @param data - Array of numeric values to plot\n * @param color - Optional color for the line stroke\n * @param strokeWidth - Optional stroke width for the line\n * @return SeriesData array suitable for LineChart\n */\nconst transformToSeriesData = (data, color, strokeWidth) => {\n // Use a fixed base date and increment by index to create linear spacing\n const baseDate = new Date(2000, 0, 1);\n return [{\n label: 'sparkline',\n data: data.map((value, index) => ({\n date: new Date(baseDate.getTime() + index * 86400000),\n // Add days\n value\n })),\n options: {\n stroke: color,\n seriesLineStyle: strokeWidth ? {\n strokeWidth\n } : undefined\n }\n }];\n};\nconst SparklineComponent = /*#__PURE__*/forwardRef(({\n data,\n width = DEFAULT_WIDTH,\n height = DEFAULT_HEIGHT,\n color,\n strokeWidth: strokeWidthProp,\n withGradientFill = true,\n gradient,\n className,\n chartId,\n margin: marginProp,\n animation\n}, ref) => {\n const theme = useGlobalChartsTheme();\n\n // Get theme defaults for sparkline\n const themeStrokeWidth = theme.sparkline?.strokeWidth ?? 1.5;\n\n // Use prop values or fall back to theme defaults\n const strokeWidth = strokeWidthProp ?? themeStrokeWidth;\n\n // Transform number[] to SeriesData[] for LineChart\n const seriesData = useMemo(() => {\n if (!data || data.length === 0) {\n return [];\n }\n return transformToSeriesData(data, color, strokeWidth);\n }, [data, color, strokeWidth]);\n\n // Merge margins with theme defaults\n const finalMargin = useMemo(() => {\n const themeMargin = theme.sparkline?.margin ?? {\n top: 2,\n right: 2,\n bottom: 2,\n left: 2\n };\n const margin = marginProp ?? themeMargin;\n return {\n ...themeMargin,\n ...margin\n };\n }, [marginProp, theme.sparkline?.margin]);\n\n // Build gradient options for the series if custom gradient is provided\n // Note: This must be called before any early returns to follow React hooks rules\n const seriesWithGradient = useMemo(() => {\n if (!gradient || seriesData.length === 0) {\n return seriesData;\n }\n return seriesData.map(series => ({\n ...series,\n options: {\n ...series.options,\n gradient: {\n from: gradient.from || color || '#000000',\n to: gradient.to || '#ffffff',\n fromOpacity: gradient.fromOpacity ?? 0.5,\n toOpacity: gradient.toOpacity ?? 0.0\n }\n }\n }));\n }, [seriesData, gradient, color]);\n\n // Handle empty data\n if (!data || data.length === 0) {\n return /*#__PURE__*/_jsx(\"div\", {\n ref: ref,\n className: clsx('sparkline', styles.sparkline, styles['sparkline--empty'], className),\n style: {\n width,\n height\n }\n });\n }\n\n // Handle single data point - render a simple dot\n if (data.length === 1) {\n const cx = width / 2;\n const cy = height / 2;\n const resolvedColor = color || '#000000';\n return /*#__PURE__*/_jsx(\"div\", {\n ref: ref,\n className: clsx('sparkline', styles.sparkline, styles['sparkline--single-point'], className),\n style: {\n width,\n height\n },\n children: /*#__PURE__*/_jsx(\"svg\", {\n width: width,\n height: height,\n \"aria-hidden\": \"true\",\n children: /*#__PURE__*/_jsx(\"circle\", {\n cx: cx,\n cy: cy,\n r: strokeWidth * 1.5,\n fill: resolvedColor\n })\n })\n });\n }\n return /*#__PURE__*/_jsx(\"div\", {\n ref: ref,\n className: clsx('sparkline', styles.sparkline, className),\n children: /*#__PURE__*/_jsx(LineChartUnresponsive, {\n data: seriesWithGradient,\n width: width,\n height: height,\n margin: finalMargin,\n chartId: chartId,\n withGradientFill: withGradientFill,\n withTooltips: false,\n showLegend: false,\n gridVisibility: \"none\",\n options: {\n axis: {\n x: {\n display: false\n },\n y: {\n display: false\n }\n }\n },\n curveType: \"monotone\",\n animation: animation\n })\n });\n});\nSparklineComponent.displayName = 'SparklineComponent';\n\n/**\n * Sparkline - A minimal line chart for inline data visualization.\n *\n * Sparklines are compact charts designed to be embedded inline with text or\n * displayed in small spaces like table cells or dashboards. They show trends\n * without axes, labels, or other chart chrome.\n *\n * This component is built on top of LineChart with preconfigured settings\n * for minimal display (no axes, grid, tooltips, or legend).\n */\nconst SparklineUnresponsive = SparklineComponent;\nSparklineUnresponsive.displayName = 'SparklineUnresponsive';\n\n/**\n * Responsive Sparkline chart component\n */\nconst Sparkline = withResponsive(SparklineUnresponsive);\nexport { Sparkline as default, SparklineUnresponsive };","import 'css-chunk:src/charts/sparkline/sparkline.module.scss';export default {\n \"sparkline\": \"a8ccharts-o-3Z8B\",\n \"sparkline--empty\": \"a8ccharts-CbLbcd\"\n};"],"mappings":";;;;;;;;;;;AAAA,OAAO,UAAU;AACjB,SAAS,SAAS,kBAAkB;;;ACD0B,IAAO,2BAAQ;AAAA,EAC3E,aAAa;AAAA,EACb,oBAAoB;AACtB;;;ADGA,SAAS,OAAO,YAAY;AAC5B,IAAM,gBAAgB;AACtB,IAAM,iBAAiB;AAWvB,IAAM,wBAAwB,CAAC,MAAM,OAAO,gBAAgB;AAE1D,QAAM,WAAW,IAAI,KAAK,KAAM,GAAG,CAAC;AACpC,SAAO,CAAC;AAAA,IACN,OAAO;AAAA,IACP,MAAM,KAAK,IAAI,CAAC,OAAO,WAAW;AAAA,MAChC,MAAM,IAAI,KAAK,SAAS,QAAQ,IAAI,QAAQ,KAAQ;AAAA;AAAA,MAEpD;AAAA,IACF,EAAE;AAAA,IACF,SAAS;AAAA,MACP,QAAQ;AAAA,MACR,iBAAiB,cAAc;AAAA,QAC7B;AAAA,MACF,IAAI;AAAA,I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AAC9B,sBAAsB,cAAc;AAKpC,IAAM,YAAY,eAAe,qBAAqB;","names":[]}
@@ -1,63 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/charts/private/chart-composition/chart-svg.tsx
2
- var _jsxruntime = require('react/jsx-runtime');
3
- var ChartSVG = ({
4
- children
5
- }) => {
6
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, {
7
- children
8
- });
9
- };
10
- ChartSVG.displayName = "Chart.SVG";
11
-
12
- // src/charts/private/chart-composition/chart-html.tsx
13
-
14
- var ChartHTML = ({
15
- children
16
- }) => {
17
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, {
18
- children
19
- });
20
- };
21
- ChartHTML.displayName = "Chart.HTML";
22
-
23
- // src/charts/private/chart-composition/use-chart-children.ts
24
- var _group = require('@visx/group');
25
- var _react = require('react');
26
- function useChartChildren(children, chartType) {
27
- return _react.useMemo.call(void 0, () => {
28
- const svg = [];
29
- const html = [];
30
- const other = [];
31
- _react.Children.forEach(children, (child) => {
32
- if (_react.isValidElement.call(void 0, child)) {
33
- const childType = child.type;
34
- const displayName = _optionalChain([childType, 'optionalAccess', _ => _.displayName]);
35
- if (displayName === `${chartType}.SVG` || displayName === "Chart.SVG") {
36
- if (_optionalChain([child, 'access', _2 => _2.props, 'optionalAccess', _3 => _3.children])) {
37
- _react.Children.forEach(child.props.children, (svgChild) => {
38
- svg.push(svgChild);
39
- });
40
- }
41
- } else if (displayName === `${chartType}.HTML` || displayName === "Chart.HTML") {
42
- if (_optionalChain([child, 'access', _4 => _4.props, 'optionalAccess', _5 => _5.children])) {
43
- _react.Children.forEach(child.props.children, (htmlChild) => {
44
- html.push(htmlChild);
45
- });
46
- }
47
- } else if (child.type === _group.Group) {
48
- svg.push(child);
49
- } else {
50
- other.push(child);
51
- }
52
- }
53
- });
54
- return { svgChildren: svg, htmlChildren: html, otherChildren: other };
55
- }, [children, chartType]);
56
- }
57
-
58
-
59
-
60
-
61
-
62
- exports.ChartSVG = ChartSVG; exports.ChartHTML = ChartHTML; exports.useChartChildren = useChartChildren;
63
- //# sourceMappingURL=chunk-RCY6XLGU.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/jetpack/jetpack/projects/js-packages/charts/dist/chunk-RCY6XLGU.cjs","../src/charts/private/chart-composition/chart-svg.tsx","../src/charts/private/chart-composition/chart-html.tsx","../src/charts/private/chart-composition/use-chart-children.ts"],"names":["_jsx","_Fragment"],"mappings":"AAAA;ACAA,+CAAmD;AAU5C,IAAM,SAAA,EAAW,CAAC;AAAA,EACvB;AACF,CAAA,EAAA,GAAM;AAGJ,EAAA,uBAAoB,6BAAA,oBAAK,EAAW;AAAA,IAClC;AAAA,EACF,CAAC,CAAA;AACH,CAAA;AAGA,QAAA,CAAS,YAAA,EAAc,WAAA;ADXvB;AACA;AEXA;AAUO,IAAM,UAAA,EAAY,CAAC;AAAA,EACxB;AACF,CAAA,EAAA,GAAM;AAGJ,EAAA,uBAAoBA,6BAAAA,oBAAKC,EAAW;AAAA,IAClC;AAAA,EACF,CAAC,CAAA;AACH,CAAA;AAGA,SAAA,CAAU,YAAA,EAAc,YAAA;AFAxB;AACA;AGtBA,oCAAsB;AACtB,8BAAkD;AAkB3C,SAAS,gBAAA,CAAkB,QAAA,EAAqB,SAAA,EAAmC;AACzF,EAAA,OAAO,4BAAA,CAAS,EAAA,GAAM;AACrB,IAAA,MAAM,IAAA,EAAmB,CAAC,CAAA;AAC1B,IAAA,MAAM,KAAA,EAAoB,CAAC,CAAA;AAC3B,IAAA,MAAM,MAAA,EAAqB,CAAC,CAAA;AAE5B,IAAA,eAAA,CAAS,OAAA,CAAS,QAAA,EAAU,CAAA,KAAA,EAAA,GAAS;AACpC,MAAA,GAAA,CAAK,mCAAA,KAAsB,CAAA,EAAI;AAE9B,QAAA,MAAM,UAAA,EAAY,KAAA,CAAM,IAAA;AACxB,QAAA,MAAM,YAAA,kBAAc,SAAA,2BAAW,aAAA;AAG/B,QAAA,GAAA,CAAK,YAAA,IAAgB,CAAA,EAAA;AAEF,UAAA;AACC,YAAA;AACP,cAAA;AACT,YAAA;AACH,UAAA;AACW,QAAA;AAEO,UAAA;AACC,YAAA;AACN,cAAA;AACV,YAAA;AACH,UAAA;AACiB,QAAA;AAED,UAAA;AACV,QAAA;AACY,UAAA;AACnB,QAAA;AACD,MAAA;AACC,IAAA;AAEoB,IAAA;AACI,EAAA;AAC5B;AHD6B;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/jetpack/jetpack/projects/js-packages/charts/dist/chunk-RCY6XLGU.cjs","sourcesContent":[null,"import { Fragment as _Fragment, jsx as _jsx } from \"react/jsx-runtime\";\n/**\n * Compound component for SVG children in charts.\n * This component serves as a marker for SVG content that should be rendered\n * inside the chart's SVG element. The actual rendering is handled by the parent chart.\n *\n * @param {PropsWithChildren} props - Component props\n * @param {ReactNode} props.children - Child elements to render inside the SVG\n * @return {JSX.Element} The children wrapped in a fragment\n */\nexport const ChartSVG = ({\n children\n}) => {\n // This component doesn't render directly - its children are extracted by the parent chart\n // We just return the children as-is\n return /*#__PURE__*/_jsx(_Fragment, {\n children: children\n });\n};\n\n// Set displayName for better debugging and type checking\nChartSVG.displayName = 'Chart.SVG';","import { Fragment as _Fragment, jsx as _jsx } from \"react/jsx-runtime\";\n/**\n * Compound component for HTML children in charts.\n * This component serves as a marker for HTML content that should be rendered\n * outside the chart's SVG element. The actual rendering is handled by the parent chart.\n *\n * @param {PropsWithChildren} props - Component props\n * @param {ReactNode} props.children - Child elements to render outside the SVG\n * @return {JSX.Element} The children wrapped in a fragment\n */\nexport const ChartHTML = ({\n children\n}) => {\n // This component doesn't render directly - its children are extracted by the parent chart\n // We just return the children as-is\n return /*#__PURE__*/_jsx(_Fragment, {\n children: children\n });\n};\n\n// Set displayName for better debugging and type checking\nChartHTML.displayName = 'Chart.HTML';","import { Group } from '@visx/group';\nimport { useMemo, Children, isValidElement } from 'react';\nimport type { ReactNode } from 'react';\n\ninterface ChartChildren {\n\tsvgChildren: ReactNode[];\n\thtmlChildren: ReactNode[];\n\totherChildren: ReactNode[];\n}\n\n/**\n * Custom hook to process and categorize chart children for composition API.\n * Extracts children from compound components (Chart.SVG, Chart.HTML) and\n * maintains backward compatibility with legacy Group components.\n *\n * @param {ReactNode} children - The children prop from the chart component\n * @param {string} chartType - The type of chart (e.g., 'PieChart', 'BarChart')\n * @return {ChartChildren} Categorized children for rendering\n */\nexport function useChartChildren( children: ReactNode, chartType: string ): ChartChildren {\n\treturn useMemo( () => {\n\t\tconst svg: ReactNode[] = [];\n\t\tconst html: ReactNode[] = [];\n\t\tconst other: ReactNode[] = [];\n\n\t\tChildren.forEach( children, child => {\n\t\t\tif ( isValidElement( child ) ) {\n\t\t\t\t// Check displayName for compound components\n\t\t\t\tconst childType = child.type as { displayName?: string };\n\t\t\t\tconst displayName = childType?.displayName;\n\n\t\t\t\t// Handle chart-specific compound components (e.g., PieChart.SVG)\n\t\t\t\tif ( displayName === `${ chartType }.SVG` || displayName === 'Chart.SVG' ) {\n\t\t\t\t\t// Extract children from Chart.SVG with safety checks\n\t\t\t\t\tif ( child.props?.children ) {\n\t\t\t\t\t\tChildren.forEach( child.props.children, svgChild => {\n\t\t\t\t\t\t\tsvg.push( svgChild );\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t} else if ( displayName === `${ chartType }.HTML` || displayName === 'Chart.HTML' ) {\n\t\t\t\t\t// Extract children from Chart.HTML with safety checks\n\t\t\t\t\tif ( child.props?.children ) {\n\t\t\t\t\t\tChildren.forEach( child.props.children, htmlChild => {\n\t\t\t\t\t\t\thtml.push( htmlChild );\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t} else if ( child.type === Group ) {\n\t\t\t\t\t// Legacy support: still check for Group type for backward compatibility\n\t\t\t\t\tsvg.push( child );\n\t\t\t\t} else {\n\t\t\t\t\tother.push( child );\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\n\t\treturn { svgChildren: svg, htmlChildren: html, otherChildren: other };\n\t}, [ children, chartType ] );\n}\n"]}