@automattic/charts 0.56.3 → 0.56.4

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 (184) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/charts/bar-chart/index.cjs +5 -5
  3. package/dist/charts/bar-chart/index.css +12 -0
  4. package/dist/charts/bar-chart/index.css.map +1 -1
  5. package/dist/charts/bar-chart/index.js +4 -4
  6. package/dist/charts/bar-list-chart/index.cjs +6 -6
  7. package/dist/charts/bar-list-chart/index.css +12 -0
  8. package/dist/charts/bar-list-chart/index.css.map +1 -1
  9. package/dist/charts/bar-list-chart/index.js +5 -5
  10. package/dist/charts/conversion-funnel-chart/index.cjs +5 -3
  11. package/dist/charts/conversion-funnel-chart/index.cjs.map +1 -1
  12. package/dist/charts/conversion-funnel-chart/index.css +14 -1
  13. package/dist/charts/conversion-funnel-chart/index.css.map +1 -1
  14. package/dist/charts/conversion-funnel-chart/index.d.cts +2 -0
  15. package/dist/charts/conversion-funnel-chart/index.d.ts +2 -0
  16. package/dist/charts/conversion-funnel-chart/index.js +4 -2
  17. package/dist/charts/geo-chart/index.cjs +4 -4
  18. package/dist/charts/geo-chart/index.css +12 -0
  19. package/dist/charts/geo-chart/index.css.map +1 -1
  20. package/dist/charts/geo-chart/index.js +3 -3
  21. package/dist/charts/leaderboard-chart/index.cjs +5 -5
  22. package/dist/charts/leaderboard-chart/index.css +12 -0
  23. package/dist/charts/leaderboard-chart/index.css.map +1 -1
  24. package/dist/charts/leaderboard-chart/index.js +4 -4
  25. package/dist/charts/line-chart/index.cjs +5 -5
  26. package/dist/charts/line-chart/index.css +12 -0
  27. package/dist/charts/line-chart/index.css.map +1 -1
  28. package/dist/charts/line-chart/index.js +4 -4
  29. package/dist/charts/pie-chart/index.cjs +7 -7
  30. package/dist/charts/pie-chart/index.css +12 -0
  31. package/dist/charts/pie-chart/index.css.map +1 -1
  32. package/dist/charts/pie-chart/index.js +6 -6
  33. package/dist/charts/pie-semi-circle-chart/index.cjs +7 -7
  34. package/dist/charts/pie-semi-circle-chart/index.css +12 -0
  35. package/dist/charts/pie-semi-circle-chart/index.css.map +1 -1
  36. package/dist/charts/pie-semi-circle-chart/index.js +6 -6
  37. package/dist/charts/sparkline/index.cjs +6 -6
  38. package/dist/charts/sparkline/index.css +12 -0
  39. package/dist/charts/sparkline/index.css.map +1 -1
  40. package/dist/charts/sparkline/index.js +5 -5
  41. package/dist/{chunk-OTZT3MC2.cjs → chunk-2A34OA5O.cjs} +19 -20
  42. package/dist/chunk-2A34OA5O.cjs.map +1 -0
  43. package/dist/chunk-4YYROZDJ.cjs +375 -0
  44. package/dist/chunk-4YYROZDJ.cjs.map +1 -0
  45. package/dist/{chunk-YYQ4IK5V.cjs → chunk-5N77S5N3.cjs} +103 -80
  46. package/dist/chunk-5N77S5N3.cjs.map +1 -0
  47. package/dist/chunk-66BXSWMW.cjs +1065 -0
  48. package/dist/chunk-66BXSWMW.cjs.map +1 -0
  49. package/dist/{chunk-CEZGL6YP.js → chunk-6CCZL2JJ.js} +15 -7
  50. package/dist/chunk-6CCZL2JJ.js.map +1 -0
  51. package/dist/{chunk-NW3RUYK2.cjs → chunk-7QDEU3KN.cjs} +15 -22
  52. package/dist/chunk-7QDEU3KN.cjs.map +1 -0
  53. package/dist/{chunk-H34CJSR6.js → chunk-AWNCAKZY.js} +367 -358
  54. package/dist/chunk-AWNCAKZY.js.map +1 -0
  55. package/dist/{chunk-5XI443YP.js → chunk-BPYKWMI7.js} +72 -64
  56. package/dist/chunk-BPYKWMI7.js.map +1 -0
  57. package/dist/{chunk-7UJPVCMB.cjs → chunk-CERFRCXD.cjs} +265 -262
  58. package/dist/chunk-CERFRCXD.cjs.map +1 -0
  59. package/dist/chunk-CMHPXSCI.js +351 -0
  60. package/dist/chunk-CMHPXSCI.js.map +1 -0
  61. package/dist/chunk-EBDUXL5K.js +421 -0
  62. package/dist/chunk-EBDUXL5K.js.map +1 -0
  63. package/dist/{chunk-2VPPTJS2.js → chunk-FZYJM5PN.js} +256 -253
  64. package/dist/chunk-FZYJM5PN.js.map +1 -0
  65. package/dist/chunk-GBDFC74U.cjs +165 -0
  66. package/dist/chunk-GBDFC74U.cjs.map +1 -0
  67. package/dist/{chunk-ODF5O5PV.cjs → chunk-HNEG3EFJ.cjs} +154 -170
  68. package/dist/chunk-HNEG3EFJ.cjs.map +1 -0
  69. package/dist/{chunk-SRXJLAKG.cjs → chunk-I2276W3I.cjs} +28 -37
  70. package/dist/chunk-I2276W3I.cjs.map +1 -0
  71. package/dist/chunk-KKPZ4MVF.js +375 -0
  72. package/dist/chunk-KKPZ4MVF.js.map +1 -0
  73. package/dist/chunk-KMYJJTSR.cjs +421 -0
  74. package/dist/chunk-KMYJJTSR.cjs.map +1 -0
  75. package/dist/{chunk-A3AEEGKR.js → chunk-KXRWNFQJ.js} +20 -21
  76. package/dist/chunk-KXRWNFQJ.js.map +1 -0
  77. package/dist/{chunk-TVV7ZI7C.cjs → chunk-LSV7F26B.cjs} +362 -353
  78. package/dist/chunk-LSV7F26B.cjs.map +1 -0
  79. package/dist/{chunk-T4J6TI55.js → chunk-M7PRGJFE.js} +102 -79
  80. package/dist/chunk-M7PRGJFE.js.map +1 -0
  81. package/dist/{chunk-TNRKEBTA.js → chunk-PGJAZN2H.js} +148 -164
  82. package/dist/{chunk-TNRKEBTA.js.map → chunk-PGJAZN2H.js.map} +1 -1
  83. package/dist/chunk-R23BFDIW.js +1065 -0
  84. package/dist/chunk-R23BFDIW.js.map +1 -0
  85. package/dist/{chunk-HIWNB5PK.cjs → chunk-RCY6XLGU.cjs} +13 -5
  86. package/dist/chunk-RCY6XLGU.cjs.map +1 -0
  87. package/dist/chunk-RSYD434G.cjs +351 -0
  88. package/dist/chunk-RSYD434G.cjs.map +1 -0
  89. package/dist/{chunk-C33AQZEC.js → chunk-TYIH5LMV.js} +16 -23
  90. package/dist/chunk-TYIH5LMV.js.map +1 -0
  91. package/dist/chunk-WMWAUOQ4.js +165 -0
  92. package/dist/chunk-WMWAUOQ4.js.map +1 -0
  93. package/dist/chunk-XWYZIFZW.js +66 -0
  94. package/dist/chunk-XWYZIFZW.js.map +1 -0
  95. package/dist/{chunk-7HROSZRS.cjs → chunk-Y3NNQMAX.cjs} +70 -62
  96. package/dist/chunk-Y3NNQMAX.cjs.map +1 -0
  97. package/dist/chunk-ZXEFMKVP.cjs +120 -0
  98. package/dist/chunk-ZXEFMKVP.cjs.map +1 -0
  99. package/dist/chunk-ZY4FXLMM.js +120 -0
  100. package/dist/chunk-ZY4FXLMM.js.map +1 -0
  101. package/dist/components/legend/index.cjs +2 -2
  102. package/dist/components/legend/index.css +12 -0
  103. package/dist/components/legend/index.css.map +1 -1
  104. package/dist/components/legend/index.js +1 -1
  105. package/dist/components/tooltip/index.cjs +2 -2
  106. package/dist/components/tooltip/index.js +1 -1
  107. package/dist/components/trend-indicator/index.cjs +2 -2
  108. package/dist/components/trend-indicator/index.js +1 -1
  109. package/dist/hooks/index.cjs +4 -2
  110. package/dist/hooks/index.cjs.map +1 -1
  111. package/dist/hooks/index.css +12 -0
  112. package/dist/hooks/index.css.map +1 -1
  113. package/dist/hooks/index.d.cts +28 -2
  114. package/dist/hooks/index.d.ts +28 -2
  115. package/dist/hooks/index.js +3 -1
  116. package/dist/index.cjs +18 -18
  117. package/dist/index.cjs.map +1 -1
  118. package/dist/index.css +14 -1
  119. package/dist/index.css.map +1 -1
  120. package/dist/index.d.cts +1 -1
  121. package/dist/index.d.ts +1 -1
  122. package/dist/index.js +17 -17
  123. package/dist/providers/index.cjs +2 -2
  124. package/dist/providers/index.css +12 -0
  125. package/dist/providers/index.css.map +1 -1
  126. package/dist/providers/index.d.cts +1 -1
  127. package/dist/providers/index.d.ts +1 -1
  128. package/dist/providers/index.js +1 -1
  129. package/dist/{themes-DQs9rbN5.d.cts → themes-BDVaIfBz.d.cts} +9 -0
  130. package/dist/{themes-CRV5fVzJ.d.ts → themes-mcS8QNkQ.d.ts} +9 -0
  131. package/package.json +5 -1
  132. package/src/charts/conversion-funnel-chart/conversion-funnel-chart.module.scss +2 -1
  133. package/src/charts/conversion-funnel-chart/conversion-funnel-chart.tsx +16 -6
  134. package/src/charts/conversion-funnel-chart/test/conversion-funnel-chart.test.tsx +34 -0
  135. package/src/charts/conversion-funnel-chart/types.ts +2 -0
  136. package/src/charts/pie-chart/pie-chart.tsx +2 -3
  137. package/src/hooks/index.ts +1 -0
  138. package/src/hooks/test/use-tooltip-portal-relocator.test.ts +216 -0
  139. package/src/hooks/use-tooltip-portal-relocator.module.scss +10 -0
  140. package/src/hooks/use-tooltip-portal-relocator.ts +177 -0
  141. package/src/providers/chart-context/global-charts-provider.tsx +18 -1
  142. package/tsup.config.ts +11 -0
  143. package/dist/chunk-2VPPTJS2.js.map +0 -1
  144. package/dist/chunk-5XI443YP.js.map +0 -1
  145. package/dist/chunk-7HROSZRS.cjs.map +0 -1
  146. package/dist/chunk-7UJPVCMB.cjs.map +0 -1
  147. package/dist/chunk-A3AEEGKR.js.map +0 -1
  148. package/dist/chunk-C33AQZEC.js.map +0 -1
  149. package/dist/chunk-CEZGL6YP.js.map +0 -1
  150. package/dist/chunk-COOC2TVQ.js +0 -167
  151. package/dist/chunk-COOC2TVQ.js.map +0 -1
  152. package/dist/chunk-EJHLLXBV.js +0 -362
  153. package/dist/chunk-EJHLLXBV.js.map +0 -1
  154. package/dist/chunk-FWMJ2FR2.js +0 -121
  155. package/dist/chunk-FWMJ2FR2.js.map +0 -1
  156. package/dist/chunk-GRYNIPWH.cjs +0 -385
  157. package/dist/chunk-GRYNIPWH.cjs.map +0 -1
  158. package/dist/chunk-H34CJSR6.js.map +0 -1
  159. package/dist/chunk-HIWNB5PK.cjs.map +0 -1
  160. package/dist/chunk-IZWC33YN.cjs +0 -357
  161. package/dist/chunk-IZWC33YN.cjs.map +0 -1
  162. package/dist/chunk-KOF32DBL.cjs +0 -1058
  163. package/dist/chunk-KOF32DBL.cjs.map +0 -1
  164. package/dist/chunk-LHWRZMF7.cjs +0 -362
  165. package/dist/chunk-LHWRZMF7.cjs.map +0 -1
  166. package/dist/chunk-MFRS2PEY.cjs +0 -121
  167. package/dist/chunk-MFRS2PEY.cjs.map +0 -1
  168. package/dist/chunk-MMDLXS6O.js +0 -75
  169. package/dist/chunk-MMDLXS6O.js.map +0 -1
  170. package/dist/chunk-NW3RUYK2.cjs.map +0 -1
  171. package/dist/chunk-ODF5O5PV.cjs.map +0 -1
  172. package/dist/chunk-OTZT3MC2.cjs.map +0 -1
  173. package/dist/chunk-SBRMWDWM.js +0 -357
  174. package/dist/chunk-SBRMWDWM.js.map +0 -1
  175. package/dist/chunk-SRXJLAKG.cjs.map +0 -1
  176. package/dist/chunk-T4J6TI55.js.map +0 -1
  177. package/dist/chunk-TVV7ZI7C.cjs.map +0 -1
  178. package/dist/chunk-XVMXWV3C.cjs +0 -167
  179. package/dist/chunk-XVMXWV3C.cjs.map +0 -1
  180. package/dist/chunk-YYQ4IK5V.cjs.map +0 -1
  181. package/dist/chunk-ZDNCF642.js +0 -1058
  182. package/dist/chunk-ZDNCF642.js.map +0 -1
  183. package/dist/chunk-ZWBUEHKF.js +0 -385
  184. package/dist/chunk-ZWBUEHKF.js.map +0 -1
@@ -1,362 +0,0 @@
1
- import {
2
- radial_wipe_animation_default
3
- } from "./chunk-A3AEEGKR.js";
4
- import {
5
- ChartHTML,
6
- ChartSVG,
7
- useChartChildren
8
- } from "./chunk-CEZGL6YP.js";
9
- import {
10
- BaseTooltip
11
- } from "./chunk-5XI443YP.js";
12
- import {
13
- withResponsive
14
- } from "./chunk-C33AQZEC.js";
15
- import {
16
- GlobalChartsContext,
17
- GlobalChartsProvider,
18
- Legend,
19
- SingleChartContext,
20
- useChartId,
21
- useChartLegendItems,
22
- useChartRegistration,
23
- useElementHeight,
24
- useGlobalChartsContext,
25
- useInteractiveLegendData,
26
- usePrefersReducedMotion
27
- } from "./chunk-H34CJSR6.js";
28
- import {
29
- attachSubComponents
30
- } from "./chunk-TE63Y5PX.js";
31
-
32
- // src/charts/pie-semi-circle-chart/pie-semi-circle-chart.tsx
33
- import { Group } from "@visx/group";
34
- import { Pie } from "@visx/shape";
35
- import { Text } from "@visx/text";
36
- import { useTooltip, useTooltipInPortal } from "@visx/tooltip";
37
- import { __ } from "@wordpress/i18n";
38
- import clsx from "clsx";
39
- import { useCallback, useContext, useMemo } from "react";
40
-
41
- // src/charts/pie-semi-circle-chart/pie-semi-circle-chart.module.scss
42
- var pie_semi_circle_chart_module_default = {
43
- "pie-semi-circle-chart": "a8ccharts-8tyaQj",
44
- "pie-semi-circle-chart--legend-top": "a8ccharts-M1lF7A",
45
- "label": "a8ccharts-EKZS3j",
46
- "note": "a8ccharts-v85A8-"
47
- };
48
-
49
- // src/charts/pie-semi-circle-chart/pie-semi-circle-chart.tsx
50
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
51
- var renderDefaultPieSemiCircleTooltip = ({
52
- tooltipData
53
- }) => {
54
- return /* @__PURE__ */ jsx(BaseTooltip, { data: tooltipData, top: 0, left: 0, renderContainer: false });
55
- };
56
- var PAD_ANGLE = 0.03;
57
- var validateData = (data) => {
58
- if (!data.length) {
59
- return { isValid: false, message: "No data available" };
60
- }
61
- const hasNegativeValues = data.some((item) => item.percentage < 0 || item.value < 0);
62
- if (hasNegativeValues) {
63
- return { isValid: false, message: "Invalid data: Negative values are not allowed" };
64
- }
65
- const totalPercentage = data.reduce((sum, item) => sum + item.percentage, 0);
66
- if (totalPercentage <= 0) {
67
- return { isValid: false, message: "Invalid percentage total: Must be greater than 0" };
68
- }
69
- return { isValid: true, message: "" };
70
- };
71
- var PieSemiCircleChartInternal = ({
72
- data,
73
- chartId: providedChartId,
74
- width = 400,
75
- thickness = 0.4,
76
- clockwise = true,
77
- withTooltips = false,
78
- showLegend = false,
79
- legendOrientation = "horizontal",
80
- legendPosition = "bottom",
81
- legendAlignment = "center",
82
- legendMaxWidth,
83
- legendTextOverflow = "wrap",
84
- legendItemClassName,
85
- legendShape = "circle",
86
- legendValueDisplay = "percentage",
87
- legendInteractive = false,
88
- label,
89
- animation,
90
- note,
91
- className,
92
- children,
93
- tooltipOffsetX = 0,
94
- tooltipOffsetY = -15,
95
- renderTooltip = renderDefaultPieSemiCircleTooltip
96
- }) => {
97
- const chartId = useChartId(providedChartId);
98
- const [legendRef, legendHeight] = useElementHeight();
99
- const { tooltipOpen, tooltipLeft, tooltipTop, tooltipData, hideTooltip, showTooltip } = useTooltip();
100
- const { containerRef, TooltipInPortal, containerBounds } = useTooltipInPortal({
101
- detectBounds: true,
102
- scroll: true,
103
- debounce: 0
104
- });
105
- const handleMouseMove = useCallback(
106
- (event, arc) => {
107
- if (containerBounds.width === 0 || containerBounds.height === 0) {
108
- return;
109
- }
110
- showTooltip({
111
- tooltipData: arc.data,
112
- tooltipLeft: event.clientX - containerBounds.left + tooltipOffsetX,
113
- tooltipTop: event.clientY - containerBounds.top + tooltipOffsetY
114
- });
115
- },
116
- [
117
- containerBounds.width,
118
- containerBounds.height,
119
- containerBounds.left,
120
- containerBounds.top,
121
- showTooltip,
122
- tooltipOffsetX,
123
- tooltipOffsetY
124
- ]
125
- );
126
- const handleMouseLeave = useCallback(() => {
127
- hideTooltip();
128
- }, [hideTooltip]);
129
- const handleArcMouseMove = useCallback(
130
- (arc) => (event) => {
131
- handleMouseMove(event, arc);
132
- },
133
- [handleMouseMove]
134
- );
135
- const { isValid, message } = validateData(data);
136
- const { getElementStyles, isSeriesVisible } = useGlobalChartsContext();
137
- const { visibleData, allSegmentsHidden, legendData } = useInteractiveLegendData({
138
- data,
139
- chartId,
140
- legendInteractive,
141
- isSeriesVisible
142
- });
143
- const accessors = useMemo(
144
- () => ({
145
- value: (d) => d.value,
146
- sort: (a, b) => b.value - a.value,
147
- fill: (d) => getElementStyles({ data: d, index: d.index }).color
148
- }),
149
- [getElementStyles]
150
- );
151
- const legendOptions = useMemo(
152
- () => ({ showValues: true, legendValueDisplay }),
153
- [legendValueDisplay]
154
- );
155
- const legendItems = useChartLegendItems(legendData, legendOptions);
156
- const { svgChildren, htmlChildren, otherChildren } = useChartChildren(
157
- children,
158
- "PieSemiCircleChart"
159
- );
160
- const chartMetadata = useMemo(
161
- () => ({
162
- thickness,
163
- clockwise
164
- }),
165
- [thickness, clockwise]
166
- );
167
- useChartRegistration({
168
- chartId,
169
- legendItems,
170
- chartType: "pie-semi-circle",
171
- isDataValid: isValid,
172
- metadata: chartMetadata
173
- });
174
- const prefersReducedMotion = usePrefersReducedMotion();
175
- if (!isValid) {
176
- return /* @__PURE__ */ jsx("div", { className: pie_semi_circle_chart_module_default["pie-semi-circle-chart"], children: /* @__PURE__ */ jsx("svg", { width, height: width / 2, "data-testid": "pie-chart-svg", children: /* @__PURE__ */ jsx("text", { x: "50%", y: "50%", textAnchor: "middle", className: pie_semi_circle_chart_module_default.error, children: message }) }) });
177
- }
178
- const height = width / 2;
179
- const chartHeight = height - (showLegend && legendPosition === "top" ? legendHeight : 0);
180
- const radius = Math.min(width / 2, chartHeight);
181
- const innerRadius = radius * (1 - thickness);
182
- const dataWithIndex = visibleData.map((d) => {
183
- const originalIndex = data.findIndex((item) => item.label === d.label);
184
- return {
185
- ...d,
186
- index: originalIndex >= 0 ? originalIndex : 0
187
- };
188
- });
189
- const startAngle = clockwise ? -Math.PI / 2 : Math.PI / 2;
190
- const endAngle = clockwise ? Math.PI / 2 : -Math.PI / 2;
191
- return /* @__PURE__ */ jsx(
192
- SingleChartContext.Provider,
193
- {
194
- value: {
195
- chartId,
196
- chartWidth: width,
197
- chartHeight: radius
198
- },
199
- children: /* @__PURE__ */ jsxs(
200
- "div",
201
- {
202
- ref: containerRef,
203
- className: clsx(
204
- "pie-semi-circle-chart",
205
- pie_semi_circle_chart_module_default["pie-semi-circle-chart"],
206
- {
207
- [pie_semi_circle_chart_module_default["pie-semi-circle-chart--legend-top"]]: showLegend && legendPosition === "top"
208
- },
209
- className
210
- ),
211
- "data-testid": "pie-chart-container",
212
- children: [
213
- /* @__PURE__ */ jsxs(
214
- "svg",
215
- {
216
- width,
217
- height: radius,
218
- viewBox: `0 0 ${width} ${chartHeight}`,
219
- "data-testid": "pie-chart-svg",
220
- children: [
221
- /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx(
222
- radial_wipe_animation_default,
223
- {
224
- id: `radial-wipe-${chartId}`,
225
- radius,
226
- innerRadius,
227
- startAngle: "-180deg",
228
- wipePercentage: 50
229
- }
230
- ) }),
231
- /* @__PURE__ */ jsx(
232
- Group,
233
- {
234
- top: chartHeight,
235
- left: width / 2,
236
- mask: animation && !prefersReducedMotion ? `url(#radial-wipe-${chartId})` : null,
237
- children: allSegmentsHidden ? /* @__PURE__ */ jsx(
238
- "text",
239
- {
240
- textAnchor: "middle",
241
- y: -radius / 2,
242
- fill: "#ccc",
243
- fontSize: "14",
244
- fontFamily: "-apple-system,BlinkMacSystemFont,Roboto,Helvetica Neue,sans-serif",
245
- children: __(
246
- "All segments are hidden. Click legend items to show data.",
247
- "jetpack-charts"
248
- )
249
- }
250
- ) : /* @__PURE__ */ jsxs(Fragment, { children: [
251
- /* @__PURE__ */ jsx(
252
- Pie,
253
- {
254
- data: dataWithIndex,
255
- pieValue: accessors.value,
256
- outerRadius: radius,
257
- innerRadius,
258
- cornerRadius: 3,
259
- padAngle: PAD_ANGLE,
260
- startAngle,
261
- endAngle,
262
- pieSort: accessors.sort,
263
- children: (pie) => {
264
- return pie.arcs.map((arc) => /* @__PURE__ */ jsx(
265
- "g",
266
- {
267
- onMouseMove: withTooltips ? handleArcMouseMove(arc) : void 0,
268
- onMouseLeave: withTooltips ? handleMouseLeave : void 0,
269
- children: /* @__PURE__ */ jsx(
270
- "path",
271
- {
272
- d: pie.path(arc) || "",
273
- fill: accessors.fill(arc.data),
274
- "data-testid": "pie-segment"
275
- }
276
- )
277
- },
278
- arc.data.label
279
- ));
280
- }
281
- }
282
- ),
283
- /* @__PURE__ */ jsxs(Group, { children: [
284
- /* @__PURE__ */ jsx(
285
- Text,
286
- {
287
- textAnchor: "middle",
288
- verticalAnchor: "start",
289
- y: -40,
290
- className: pie_semi_circle_chart_module_default.label,
291
- children: label
292
- }
293
- ),
294
- /* @__PURE__ */ jsx(
295
- Text,
296
- {
297
- textAnchor: "middle",
298
- verticalAnchor: "start",
299
- y: -20,
300
- className: pie_semi_circle_chart_module_default.note,
301
- children: note
302
- }
303
- )
304
- ] }),
305
- !allSegmentsHidden && svgChildren
306
- ] })
307
- }
308
- )
309
- ]
310
- }
311
- ),
312
- withTooltips && tooltipOpen && tooltipData && /* @__PURE__ */ jsx(TooltipInPortal, { top: tooltipTop || 0, left: tooltipLeft || 0, children: /* @__PURE__ */ jsx("div", { role: "tooltip", children: renderTooltip({ tooltipData }) }) }),
313
- showLegend && /* @__PURE__ */ jsx(
314
- Legend,
315
- {
316
- orientation: legendOrientation,
317
- position: legendPosition,
318
- alignment: legendAlignment,
319
- maxWidth: legendMaxWidth,
320
- textOverflow: legendTextOverflow,
321
- legendItemClassName,
322
- shape: legendShape,
323
- ref: legendRef,
324
- chartId,
325
- interactive: legendInteractive
326
- }
327
- ),
328
- htmlChildren,
329
- otherChildren
330
- ]
331
- }
332
- )
333
- }
334
- );
335
- };
336
- var PieSemiCircleChartWithProvider = (props) => {
337
- const existingContext = useContext(GlobalChartsContext);
338
- if (existingContext) {
339
- return /* @__PURE__ */ jsx(PieSemiCircleChartInternal, { ...props });
340
- }
341
- return /* @__PURE__ */ jsx(GlobalChartsProvider, { children: /* @__PURE__ */ jsx(PieSemiCircleChartInternal, { ...props }) });
342
- };
343
- PieSemiCircleChartWithProvider.displayName = "PieSemiCircleChart";
344
- var PieSemiCircleChart = attachSubComponents(PieSemiCircleChartWithProvider, {
345
- Legend,
346
- SVG: ChartSVG,
347
- HTML: ChartHTML
348
- });
349
- var PieSemiCircleChartResponsive = attachSubComponents(
350
- withResponsive(PieSemiCircleChartWithProvider),
351
- {
352
- Legend,
353
- SVG: ChartSVG,
354
- HTML: ChartHTML
355
- }
356
- );
357
-
358
- export {
359
- PieSemiCircleChart,
360
- PieSemiCircleChartResponsive
361
- };
362
- //# sourceMappingURL=chunk-EJHLLXBV.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/charts/pie-semi-circle-chart/pie-semi-circle-chart.tsx","../src/charts/pie-semi-circle-chart/pie-semi-circle-chart.module.scss"],"sourcesContent":["import { Group } from '@visx/group';\nimport { Pie } from '@visx/shape';\nimport { Text } from '@visx/text';\nimport { useTooltip, useTooltipInPortal } from '@visx/tooltip';\nimport { __ } from '@wordpress/i18n';\nimport clsx from 'clsx';\nimport { useCallback, useContext, useMemo } from 'react';\nimport { Legend, useChartLegendItems } from '../../components/legend';\nimport { BaseTooltip } from '../../components/tooltip';\nimport { useElementHeight, useInteractiveLegendData, usePrefersReducedMotion } from '../../hooks';\nimport {\n\tGlobalChartsProvider,\n\tuseChartId,\n\tuseChartRegistration,\n\tuseGlobalChartsContext,\n\tGlobalChartsContext,\n} from '../../providers';\nimport { attachSubComponents } from '../../utils';\nimport { ChartSVG, ChartHTML, useChartChildren } from '../private/chart-composition';\nimport { RadialWipeAnimation } from '../private/radial-wipe-animation';\nimport { SingleChartContext } from '../private/single-chart-context';\nimport { withResponsive } from '../private/with-responsive';\nimport styles from './pie-semi-circle-chart.module.scss';\nimport type { LegendValueDisplay } from '../../components/legend';\nimport type { BaseChartProps, DataPointPercentage, Optional } from '../../types';\nimport type { ChartComponentWithComposition } from '../private/chart-composition';\nimport type { ResponsiveConfig } from '../private/with-responsive';\nimport type { PieArcDatum } from '@visx/shape/lib/shapes/Pie';\nimport type { FC, MouseEvent, ReactNode } from 'react';\n\n/**\n * Parameters passed to the renderTooltip function for semi-circle charts.\n */\nexport type PieSemiCircleChartRenderTooltipParams = {\n\t/**\n\t * The data point being hovered, including label, value, and percentage.\n\t */\n\ttooltipData: DataPointPercentage;\n};\n\n/**\n * Default tooltip renderer for semi-circle pie charts.\n * Renders a BaseTooltip with the hovered segment's data.\n *\n * @param {PieSemiCircleChartRenderTooltipParams} params - The tooltip parameters containing the hovered data point\n * @return {ReactNode} The rendered tooltip content\n */\nconst renderDefaultPieSemiCircleTooltip = ( {\n\ttooltipData,\n}: PieSemiCircleChartRenderTooltipParams ): ReactNode => {\n\treturn <BaseTooltip data={ tooltipData } top={ 0 } left={ 0 } renderContainer={ false } />;\n};\n\nconst PAD_ANGLE = 0.03; // Padding between segments\n\nexport interface PieSemiCircleChartProps extends BaseChartProps< DataPointPercentage[] > {\n\t/**\n\t * Width of the chart in pixels; height would be half of this value calculated automatically.\n\t */\n\twidth?: number;\n\n\t/**\n\t * Thickness of the pie chart. A value between 0 and 1\n\t */\n\tthickness?: number;\n\n\t/**\n\t * Direction of chart rendering\n\t * true for clockwise, false for counter-clockwise\n\t */\n\tclockwise?: boolean;\n\n\t/**\n\t * Label text to display above the chart\n\t */\n\tlabel?: string;\n\n\t/**\n\t * Note text to display below the label\n\t */\n\tnote?: string;\n\n\t/**\n\t * Use the children prop to render additional elements on the chart.\n\t */\n\tchildren?: ReactNode;\n\n\t/**\n\t * What type of value to display in the legend when showValues is true.\n\t * - 'percentage': Shows percentage values (e.g., \"23%\") [default]\n\t * - 'value': Shows raw numeric values (e.g., \"30000\")\n\t * - 'valueDisplay': Shows formatted values (e.g., \"30K\")\n\t * - 'none': Shows no values, only labels\n\t */\n\tlegendValueDisplay?: LegendValueDisplay;\n\n\t/**\n\t * Enable interactive legend items that can toggle segment visibility.\n\t * Requires chartId and GlobalChartsProvider.\n\t * When segments are hidden, percentages are recalculated so visible segments total 100%.\n\t */\n\tlegendInteractive?: boolean;\n\n\t/**\n\t * Horizontal offset for tooltip positioning in pixels (default: 0)\n\t */\n\ttooltipOffsetX?: number;\n\n\t/**\n\t * Vertical offset for tooltip positioning in pixels (default: -15)\n\t */\n\ttooltipOffsetY?: number;\n\n\t/**\n\t * Custom render function for tooltip content.\n\t * When provided, replaces the default BaseTooltip with custom content.\n\t */\n\trenderTooltip?: ( params: PieSemiCircleChartRenderTooltipParams ) => ReactNode;\n}\n\n// Base props type with optional responsive properties\ntype PieSemiCircleChartBaseProps = Optional< PieSemiCircleChartProps, 'width' >;\n\n// Composition API types\ntype PieSemiCircleChartComponent = ChartComponentWithComposition< PieSemiCircleChartBaseProps >;\ntype PieSemiCircleChartResponsiveComponent = ChartComponentWithComposition<\n\tPieSemiCircleChartBaseProps & ResponsiveConfig\n>;\n\nexport type ArcData = PieArcDatum< DataPointPercentage >;\n\n/**\n * Validates the semi-circle pie chart data\n * @param data - The data to validate\n * @return Object containing validation result and error message\n */\nconst validateData = ( data: DataPointPercentage[] ) => {\n\tif ( ! data.length ) {\n\t\treturn { isValid: false, message: 'No data available' };\n\t}\n\n\t// Check for negative values\n\tconst hasNegativeValues = data.some( item => item.percentage < 0 || item.value < 0 );\n\tif ( hasNegativeValues ) {\n\t\treturn { isValid: false, message: 'Invalid data: Negative values are not allowed' };\n\t}\n\n\t// Validate total percentage is greater than 0\n\tconst totalPercentage = data.reduce( ( sum, item ) => sum + item.percentage, 0 );\n\tif ( totalPercentage <= 0 ) {\n\t\treturn { isValid: false, message: 'Invalid percentage total: Must be greater than 0' };\n\t}\n\n\treturn { isValid: true, message: '' };\n};\n\nconst PieSemiCircleChartInternal: FC< PieSemiCircleChartProps > = ( {\n\tdata,\n\tchartId: providedChartId,\n\twidth = 400,\n\tthickness = 0.4,\n\tclockwise = true,\n\twithTooltips = false,\n\tshowLegend = false,\n\tlegendOrientation = 'horizontal',\n\tlegendPosition = 'bottom',\n\tlegendAlignment = 'center',\n\tlegendMaxWidth,\n\tlegendTextOverflow = 'wrap',\n\tlegendItemClassName,\n\tlegendShape = 'circle',\n\tlegendValueDisplay = 'percentage',\n\tlegendInteractive = false,\n\tlabel,\n\tanimation,\n\tnote,\n\tclassName,\n\tchildren,\n\ttooltipOffsetX = 0,\n\ttooltipOffsetY = -15,\n\trenderTooltip = renderDefaultPieSemiCircleTooltip,\n} ) => {\n\tconst chartId = useChartId( providedChartId );\n\tconst [ legendRef, legendHeight ] = useElementHeight< HTMLDivElement >();\n\tconst { tooltipOpen, tooltipLeft, tooltipTop, tooltipData, hideTooltip, showTooltip } =\n\t\tuseTooltip< DataPointPercentage >();\n\n\t// Set up portal tooltip for better z-index handling\n\t// We get containerBounds to cancel out stale offsets in the position calculation\n\tconst { containerRef, TooltipInPortal, containerBounds } = useTooltipInPortal( {\n\t\tdetectBounds: true,\n\t\tscroll: true,\n\t\tdebounce: 0,\n\t} );\n\n\tconst handleMouseMove = useCallback(\n\t\t( event: MouseEvent< SVGElement >, arc: ArcData ) => {\n\t\t\t// Don't show tooltip until container bounds are measured\n\t\t\tif ( containerBounds.width === 0 || containerBounds.height === 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Use clientX/Y and subtract containerBounds to cancel out any stale offset.\n\t\t\t// TooltipInPortal calculates: tooltipLeft + containerBounds.left + scrollX\n\t\t\t// By passing (clientX - containerBounds.left), we get:\n\t\t\t// (clientX - containerBounds.left) + containerBounds.left + scrollX = clientX + scrollX\n\t\t\t// This gives correct page coordinates regardless of stale bounds.\n\t\t\tshowTooltip( {\n\t\t\t\ttooltipData: arc.data,\n\t\t\t\ttooltipLeft: event.clientX - containerBounds.left + tooltipOffsetX,\n\t\t\t\ttooltipTop: event.clientY - containerBounds.top + tooltipOffsetY,\n\t\t\t} );\n\t\t},\n\t\t[\n\t\t\tcontainerBounds.width,\n\t\t\tcontainerBounds.height,\n\t\t\tcontainerBounds.left,\n\t\t\tcontainerBounds.top,\n\t\t\tshowTooltip,\n\t\t\ttooltipOffsetX,\n\t\t\ttooltipOffsetY,\n\t\t]\n\t);\n\n\tconst handleMouseLeave = useCallback( () => {\n\t\thideTooltip();\n\t}, [ hideTooltip ] );\n\n\tconst handleArcMouseMove = useCallback(\n\t\t( arc: ArcData ) => ( event: MouseEvent< SVGElement > ) => {\n\t\t\thandleMouseMove( event, arc );\n\t\t},\n\t\t[ handleMouseMove ]\n\t);\n\n\t// Validate data first to get validation result\n\tconst { isValid, message } = validateData( data );\n\n\tconst { getElementStyles, isSeriesVisible } = useGlobalChartsContext();\n\n\t// Filter and recalculate data for interactive legends\n\tconst { visibleData, allSegmentsHidden, legendData } = useInteractiveLegendData( {\n\t\tdata,\n\t\tchartId,\n\t\tlegendInteractive,\n\t\tisSeriesVisible,\n\t} );\n\n\t// Define accessors with useMemo to avoid changing dependencies\n\tconst accessors = useMemo(\n\t\t() => ( {\n\t\t\tvalue: ( d: DataPointPercentage ) => d.value,\n\t\t\tsort: (\n\t\t\t\ta: DataPointPercentage & { index: number },\n\t\t\t\tb: DataPointPercentage & { index: number }\n\t\t\t) => b.value - a.value,\n\t\t\tfill: ( d: DataPointPercentage & { index: number } ) =>\n\t\t\t\tgetElementStyles( { data: d, index: d.index } ).color,\n\t\t} ),\n\t\t[ getElementStyles ]\n\t);\n\n\t// Memoize legend options to prevent unnecessary re-calculations\n\tconst legendOptions = useMemo(\n\t\t() => ( { showValues: true, legendValueDisplay } ),\n\t\t[ legendValueDisplay ]\n\t);\n\n\t// Create legend items using legendData (has recalculated percentages for visible items)\n\tconst legendItems = useChartLegendItems( legendData, legendOptions );\n\n\t// Process children to extract compound components\n\tconst { svgChildren, htmlChildren, otherChildren } = useChartChildren(\n\t\tchildren,\n\t\t'PieSemiCircleChart'\n\t);\n\n\t// Memoize metadata to prevent unnecessary re-registration\n\tconst chartMetadata = useMemo(\n\t\t() => ( {\n\t\t\tthickness,\n\t\t\tclockwise,\n\t\t} ),\n\t\t[ thickness, clockwise ]\n\t);\n\n\t// Register chart with context only if data is valid\n\tuseChartRegistration( {\n\t\tchartId,\n\t\tlegendItems,\n\t\tchartType: 'pie-semi-circle',\n\t\tisDataValid: isValid,\n\t\tmetadata: chartMetadata,\n\t} );\n\n\tconst prefersReducedMotion = usePrefersReducedMotion();\n\n\tif ( ! isValid ) {\n\t\treturn (\n\t\t\t<div className={ styles[ 'pie-semi-circle-chart' ] }>\n\t\t\t\t<svg width={ width } height={ width / 2 } data-testid=\"pie-chart-svg\">\n\t\t\t\t\t<text x=\"50%\" y=\"50%\" textAnchor=\"middle\" className={ styles.error }>\n\t\t\t\t\t\t{ message }\n\t\t\t\t\t</text>\n\t\t\t\t</svg>\n\t\t\t</div>\n\t\t);\n\t}\n\n\t// Calculate chart dimensions\n\t// TODO: we might want to accept height as a prop in the future, because the height of container might not always be enough.\n\tconst height = width / 2;\n\t// The chart only takes the height minus the legend height.\n\tconst chartHeight = height - ( showLegend && legendPosition === 'top' ? legendHeight : 0 );\n\tconst radius = Math.min( width / 2, chartHeight );\n\tconst innerRadius = radius * ( 1 - thickness );\n\n\t// Map data with index for color assignment\n\t// When interactive, we need to find the original index to maintain consistent colors\n\tconst dataWithIndex = visibleData.map( d => {\n\t\tconst originalIndex = data.findIndex( item => item.label === d.label );\n\t\treturn {\n\t\t\t...d,\n\t\t\tindex: originalIndex >= 0 ? originalIndex : 0,\n\t\t};\n\t} );\n\n\t// Configure pie angles based on clockwise direction\n\tconst startAngle = clockwise ? -Math.PI / 2 : Math.PI / 2;\n\tconst endAngle = clockwise ? Math.PI / 2 : -Math.PI / 2;\n\n\treturn (\n\t\t<SingleChartContext.Provider\n\t\t\tvalue={ {\n\t\t\t\tchartId,\n\t\t\t\tchartWidth: width,\n\t\t\t\tchartHeight: radius,\n\t\t\t} }\n\t\t>\n\t\t\t<div\n\t\t\t\tref={ containerRef }\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'pie-semi-circle-chart',\n\t\t\t\t\tstyles[ 'pie-semi-circle-chart' ],\n\t\t\t\t\t{\n\t\t\t\t\t\t[ styles[ 'pie-semi-circle-chart--legend-top' ] ]:\n\t\t\t\t\t\t\tshowLegend && legendPosition === 'top',\n\t\t\t\t\t},\n\t\t\t\t\tclassName\n\t\t\t\t) }\n\t\t\t\tdata-testid=\"pie-chart-container\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\twidth={ width }\n\t\t\t\t\theight={ radius }\n\t\t\t\t\tviewBox={ `0 0 ${ width } ${ chartHeight }` }\n\t\t\t\t\tdata-testid=\"pie-chart-svg\"\n\t\t\t\t>\n\t\t\t\t\t<defs>\n\t\t\t\t\t\t<RadialWipeAnimation\n\t\t\t\t\t\t\tid={ `radial-wipe-${ chartId }` }\n\t\t\t\t\t\t\tradius={ radius }\n\t\t\t\t\t\t\tinnerRadius={ innerRadius }\n\t\t\t\t\t\t\tstartAngle=\"-180deg\"\n\t\t\t\t\t\t\twipePercentage={ 50 }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</defs>\n\n\t\t\t\t\t{ /* Main chart group centered horizontally and positioned at bottom */ }\n\t\t\t\t\t<Group\n\t\t\t\t\t\ttop={ chartHeight }\n\t\t\t\t\t\tleft={ width / 2 }\n\t\t\t\t\t\tmask={ animation && ! prefersReducedMotion ? `url(#radial-wipe-${ chartId })` : null }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ allSegmentsHidden ? (\n\t\t\t\t\t\t\t<text\n\t\t\t\t\t\t\t\ttextAnchor=\"middle\"\n\t\t\t\t\t\t\t\ty={ -radius / 2 }\n\t\t\t\t\t\t\t\tfill=\"#ccc\"\n\t\t\t\t\t\t\t\tfontSize=\"14\"\n\t\t\t\t\t\t\t\tfontFamily=\"-apple-system,BlinkMacSystemFont,Roboto,Helvetica Neue,sans-serif\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'All segments are hidden. Click legend items to show data.',\n\t\t\t\t\t\t\t\t\t'jetpack-charts'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</text>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t{ /* Pie chart */ }\n\t\t\t\t\t\t\t\t<Pie< DataPointPercentage & { index: number } >\n\t\t\t\t\t\t\t\t\tdata={ dataWithIndex }\n\t\t\t\t\t\t\t\t\tpieValue={ accessors.value }\n\t\t\t\t\t\t\t\t\touterRadius={ radius }\n\t\t\t\t\t\t\t\t\tinnerRadius={ innerRadius }\n\t\t\t\t\t\t\t\t\tcornerRadius={ 3 }\n\t\t\t\t\t\t\t\t\tpadAngle={ PAD_ANGLE }\n\t\t\t\t\t\t\t\t\tstartAngle={ startAngle }\n\t\t\t\t\t\t\t\t\tendAngle={ endAngle }\n\t\t\t\t\t\t\t\t\tpieSort={ accessors.sort }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ pie => {\n\t\t\t\t\t\t\t\t\t\treturn pie.arcs.map( arc => (\n\t\t\t\t\t\t\t\t\t\t\t<g\n\t\t\t\t\t\t\t\t\t\t\t\tkey={ arc.data.label }\n\t\t\t\t\t\t\t\t\t\t\t\tonMouseMove={ withTooltips ? handleArcMouseMove( arc ) : undefined }\n\t\t\t\t\t\t\t\t\t\t\t\tonMouseLeave={ withTooltips ? handleMouseLeave : undefined }\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t<path\n\t\t\t\t\t\t\t\t\t\t\t\t\td={ pie.path( arc ) || '' }\n\t\t\t\t\t\t\t\t\t\t\t\t\tfill={ accessors.fill( arc.data ) }\n\t\t\t\t\t\t\t\t\t\t\t\t\tdata-testid=\"pie-segment\"\n\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t</g>\n\t\t\t\t\t\t\t\t\t\t) );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t</Pie>\n\n\t\t\t\t\t\t\t\t{ /* Label and note text */ }\n\t\t\t\t\t\t\t\t<Group>\n\t\t\t\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\t\t\t\ttextAnchor=\"middle\"\n\t\t\t\t\t\t\t\t\t\tverticalAnchor=\"start\"\n\t\t\t\t\t\t\t\t\t\ty={ -40 } // Position above the chart with space for note\n\t\t\t\t\t\t\t\t\t\tclassName={ styles.label }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\t\t\t\ttextAnchor=\"middle\"\n\t\t\t\t\t\t\t\t\t\tverticalAnchor=\"start\"\n\t\t\t\t\t\t\t\t\t\ty={ -20 } // Position between label and chart\n\t\t\t\t\t\t\t\t\t\tclassName={ styles.note }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ note }\n\t\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t\t</Group>\n\n\t\t\t\t\t\t\t\t{ /* Render SVG children from composition API */ }\n\t\t\t\t\t\t\t\t{ ! allSegmentsHidden && svgChildren }\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Group>\n\t\t\t\t</svg>\n\n\t\t\t\t{ withTooltips && tooltipOpen && tooltipData && (\n\t\t\t\t\t<TooltipInPortal top={ tooltipTop || 0 } left={ tooltipLeft || 0 }>\n\t\t\t\t\t\t<div role=\"tooltip\">{ renderTooltip( { tooltipData } ) }</div>\n\t\t\t\t\t</TooltipInPortal>\n\t\t\t\t) }\n\n\t\t\t\t{ showLegend && (\n\t\t\t\t\t<Legend\n\t\t\t\t\t\torientation={ legendOrientation }\n\t\t\t\t\t\tposition={ legendPosition }\n\t\t\t\t\t\talignment={ legendAlignment }\n\t\t\t\t\t\tmaxWidth={ legendMaxWidth }\n\t\t\t\t\t\ttextOverflow={ legendTextOverflow }\n\t\t\t\t\t\tlegendItemClassName={ legendItemClassName }\n\t\t\t\t\t\tshape={ legendShape }\n\t\t\t\t\t\tref={ legendRef }\n\t\t\t\t\t\tchartId={ chartId }\n\t\t\t\t\t\tinteractive={ legendInteractive }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ /* Render HTML children from composition API */ }\n\t\t\t\t{ htmlChildren }\n\n\t\t\t\t{ /* Render any other children that aren't compound components */ }\n\t\t\t\t{ otherChildren }\n\t\t\t</div>\n\t\t</SingleChartContext.Provider>\n\t);\n};\n\nconst PieSemiCircleChartWithProvider: FC< PieSemiCircleChartProps > = props => {\n\tconst existingContext = useContext( GlobalChartsContext );\n\n\t// If we're already in a GlobalChartsProvider context, don't create a new one\n\tif ( existingContext ) {\n\t\treturn <PieSemiCircleChartInternal { ...props } />;\n\t}\n\n\t// Otherwise, create our own GlobalChartsProvider\n\treturn (\n\t\t<GlobalChartsProvider>\n\t\t\t<PieSemiCircleChartInternal { ...props } />\n\t\t</GlobalChartsProvider>\n\t);\n};\n\nPieSemiCircleChartWithProvider.displayName = 'PieSemiCircleChart';\n\n// Create PieSemiCircleChart with composition API\nconst PieSemiCircleChart = attachSubComponents( PieSemiCircleChartWithProvider, {\n\tLegend: Legend,\n\tSVG: ChartSVG,\n\tHTML: ChartHTML,\n} ) as PieSemiCircleChartComponent;\n\n// Create responsive PieSemiCircleChart with composition API\nconst PieSemiCircleChartResponsive = attachSubComponents(\n\twithResponsive< PieSemiCircleChartProps >( PieSemiCircleChartWithProvider ),\n\t{\n\t\tLegend: Legend,\n\t\tSVG: ChartSVG,\n\t\tHTML: ChartHTML,\n\t}\n) as PieSemiCircleChartResponsiveComponent;\n\nexport {\n\tPieSemiCircleChartResponsive as default,\n\tPieSemiCircleChart as PieSemiCircleChartUnresponsive,\n};\n","import 'css-chunk:src/charts/pie-semi-circle-chart/pie-semi-circle-chart.module.scss';export default {\n \"pie-semi-circle-chart\": \"a8ccharts-8tyaQj\",\n \"pie-semi-circle-chart--legend-top\": \"a8ccharts-M1lF7A\",\n \"label\": \"a8ccharts-EKZS3j\",\n \"note\": \"a8ccharts-v85A8-\"\n};"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,aAAa;AACtB,SAAS,WAAW;AACpB,SAAS,YAAY;AACrB,SAAS,YAAY,0BAA0B;AAC/C,SAAS,UAAU;AACnB,OAAO,UAAU;AACjB,SAAS,aAAa,YAAY,eAAe;;;ACNqC,IAAO,uCAAQ;AAAA,EACnG,yBAAyB;AAAA,EACzB,qCAAqC;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,WAAS;AAC9E,QAAM,kBAAkB,WAAY,mBAAoB;AAGxD,MAAK,iBAAkB;AACtB,WAAO,oBAAC,8BAA6B,GAAG,OAAQ;AAAA,EACjD;AAGA,SACC,oBAAC,wBACA,8BAAC,8BAA6B,GAAG,OAAQ,GAC1C;AAEF;AAEA,+BAA+B,cAAc;AAG7C,IAAM,qBAAqB,oBAAqB,gCAAgC;AAAA,EAC/E;AAAA,EACA,KAAK;AAAA,EACL,MAAM;AACP,CAAE;AAGF,IAAM,+BAA+B;AAAA,EACpC,eAA2C,8BAA+B;AAAA,EAC1E;AAAA,IACC;AAAA,IACA,KAAK;AAAA,IACL,MAAM;AAAA,EACP;AACD;","names":[]}
@@ -1,121 +0,0 @@
1
- import {
2
- withResponsive
3
- } from "./chunk-C33AQZEC.js";
4
- import {
5
- GlobalChartsContext,
6
- GlobalChartsProvider,
7
- useGlobalChartsContext
8
- } from "./chunk-H34CJSR6.js";
9
- import {
10
- lightenHexColor,
11
- normalizeColorToHex,
12
- resolveCssVariable
13
- } from "./chunk-TE63Y5PX.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 } 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: { featureFillColor },
43
- backgroundColor
44
- }
45
- } = useGlobalChartsContext();
46
- const loadingPlaceholder = /* @__PURE__ */ jsx(
47
- "div",
48
- {
49
- className: clsx("geo-chart", geo_chart_module_default.container, className),
50
- "data-testid": "geo-chart-loading",
51
- style: { width, height },
52
- children: renderPlaceholder ? renderPlaceholder() : __("Loading map", "jetpack-charts")
53
- }
54
- );
55
- const fullColorHex = getElementStyles({ index: 0 }).color;
56
- const lightColorHex = lightenHexColor(fullColorHex, 0.8);
57
- const backgroundColorHex = normalizeColorToHex(backgroundColor, null, resolveCssVariable) || DEFAULT_BACKGROUND_COLOR;
58
- const defaultFillColorHex = normalizeColorToHex(featureFillColor, null, resolveCssVariable) || DEFAULT_FEATURE_FILL_COLOR;
59
- const hasHtmlTooltips = useMemo(
60
- () => data.length > 0 && data[0].some(
61
- (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
62
- ),
63
- [data]
64
- );
65
- const options = useMemo(
66
- () => ({
67
- ...region !== "world" && { region },
68
- ...resolution !== "countries" && { resolution },
69
- colorAxis: { colors: [lightColorHex, fullColorHex] },
70
- backgroundColor: backgroundColorHex,
71
- datalessRegionColor: defaultFillColorHex,
72
- defaultColor: defaultFillColorHex,
73
- tooltip: { trigger: "focus", isHtml: hasHtmlTooltips },
74
- legend: "none",
75
- keepAspectRatio: true
76
- }),
77
- [
78
- region,
79
- resolution,
80
- lightColorHex,
81
- fullColorHex,
82
- backgroundColorHex,
83
- defaultFillColorHex,
84
- hasHtmlTooltips
85
- ]
86
- );
87
- return /* @__PURE__ */ jsx(
88
- "div",
89
- {
90
- className: clsx("geo-chart", geo_chart_module_default.container, className),
91
- "data-testid": "geo-chart",
92
- style: { width, height, backgroundColor },
93
- children: /* @__PURE__ */ jsx(
94
- Chart,
95
- {
96
- chartType: "GeoChart",
97
- width,
98
- height,
99
- data,
100
- options,
101
- loader: loadingPlaceholder
102
- }
103
- )
104
- }
105
- );
106
- };
107
- var GeoChartWithProvider = (props) => {
108
- const existingContext = useContext(GlobalChartsContext);
109
- if (existingContext) {
110
- return /* @__PURE__ */ jsx(GeoChartInternal, { ...props });
111
- }
112
- return /* @__PURE__ */ jsx(GlobalChartsProvider, { children: /* @__PURE__ */ jsx(GeoChartInternal, { ...props }) });
113
- };
114
- GeoChartWithProvider.displayName = "GeoChart";
115
- var GeoChartResponsive = withResponsive(GeoChartWithProvider);
116
-
117
- export {
118
- GeoChartWithProvider,
119
- GeoChartResponsive
120
- };
121
- //# sourceMappingURL=chunk-FWMJ2FR2.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 { FC, useContext, useMemo } from 'react';\nimport { Chart, type GoogleChartOptions } 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 { GeoChartProps } from './types';\n\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: FC< GeoChartProps > = ( {\n\tclassName,\n\tdata,\n\twidth,\n\theight,\n\tregion = 'world',\n\tresolution = 'countries',\n\trenderPlaceholder,\n} ) => {\n\tconst {\n\t\tgetElementStyles,\n\t\ttheme: {\n\t\t\tgeoChart: { featureFillColor },\n\t\t\tbackgroundColor,\n\t\t},\n\t} = useGlobalChartsContext();\n\n\t// Render loading placeholder\n\tconst loadingPlaceholder = (\n\t\t<div\n\t\t\tclassName={ clsx( 'geo-chart', styles.container, className ) }\n\t\t\tdata-testid=\"geo-chart-loading\"\n\t\t\tstyle={ { width, height } }\n\t\t>\n\t\t\t{ renderPlaceholder ? renderPlaceholder() : __( 'Loading map', 'jetpack-charts' ) }\n\t\t</div>\n\t);\n\n\t// Google charts doesn't accept CSS variables, so we need to convert them to hex colors\n\tconst fullColorHex = getElementStyles( { index: 0 } ).color;\n\tconst lightColorHex = lightenHexColor( fullColorHex, 0.8 );\n\t// Use normalizeColorToHex to ensure HSL/RGB values from CSS variables are converted to hex\n\tconst backgroundColorHex =\n\t\tnormalizeColorToHex( backgroundColor, null, resolveCssVariable ) || DEFAULT_BACKGROUND_COLOR;\n\tconst defaultFillColorHex =\n\t\tnormalizeColorToHex( featureFillColor, null, resolveCssVariable ) || DEFAULT_FEATURE_FILL_COLOR;\n\n\t// Check if data has HTML tooltips (column with role: 'tooltip' and p.html: true)\n\tconst hasHtmlTooltips = useMemo(\n\t\t() =>\n\t\t\tdata.length > 0 &&\n\t\t\tdata[ 0 ].some(\n\t\t\t\tcol =>\n\t\t\t\t\ttypeof col === 'object' &&\n\t\t\t\t\tcol !== null &&\n\t\t\t\t\t'role' in col &&\n\t\t\t\t\tcol.role === 'tooltip' &&\n\t\t\t\t\t'p' in col &&\n\t\t\t\t\ttypeof col.p === 'object' &&\n\t\t\t\t\tcol.p !== null &&\n\t\t\t\t\t'html' in col.p &&\n\t\t\t\t\tcol.p.html === true\n\t\t\t),\n\t\t[ data ]\n\t);\n\n\tconst options: GoogleChartOptions = useMemo(\n\t\t() => ( {\n\t\t\t...( region !== 'world' && { region } ),\n\t\t\t...( resolution !== 'countries' && { resolution } ),\n\t\t\tcolorAxis: { colors: [ lightColorHex, fullColorHex ] },\n\t\t\tbackgroundColor: backgroundColorHex,\n\t\t\tdatalessRegionColor: defaultFillColorHex,\n\t\t\tdefaultColor: defaultFillColorHex,\n\t\t\ttooltip: { trigger: 'focus', isHtml: hasHtmlTooltips },\n\t\t\tlegend: 'none',\n\t\t\tkeepAspectRatio: true,\n\t\t} ),\n\t\t[\n\t\t\tregion,\n\t\t\tresolution,\n\t\t\tlightColorHex,\n\t\t\tfullColorHex,\n\t\t\tbackgroundColorHex,\n\t\t\tdefaultFillColorHex,\n\t\t\thasHtmlTooltips,\n\t\t]\n\t);\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ clsx( 'geo-chart', styles.container, className ) }\n\t\t\tdata-testid=\"geo-chart\"\n\t\t\tstyle={ { width, height, backgroundColor } }\n\t\t>\n\t\t\t<Chart\n\t\t\t\tchartType=\"GeoChart\"\n\t\t\t\twidth={ width }\n\t\t\t\theight={ height }\n\t\t\t\tdata={ data }\n\t\t\t\toptions={ options }\n\t\t\t\tloader={ loadingPlaceholder }\n\t\t\t/>\n\t\t</div>\n\t);\n};\n\nconst GeoChartWithProvider: FC< GeoChartProps > = props => {\n\tconst existingContext = useContext( GlobalChartsContext );\n\n\t// If we're already in a GlobalChartsProvider context, don't create a new one\n\tif ( existingContext ) {\n\t\treturn <GeoChartInternal { ...props } />;\n\t}\n\n\t// Otherwise, create our own GlobalChartsProvider\n\treturn (\n\t\t<GlobalChartsProvider>\n\t\t\t<GeoChartInternal { ...props } />\n\t\t</GlobalChartsProvider>\n\t);\n};\n\nGeoChartWithProvider.displayName = 'GeoChart';\n\nconst GeoChartResponsive = withResponsive< GeoChartProps >( GeoChartWithProvider );\n\nexport { GeoChartResponsive as default, GeoChartWithProvider as GeoChartUnresponsive };\n","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,SAAa,YAAY,eAAe;AACxC,SAAS,aAAsC;;;ACNe,IAAO,2BAAQ;AAAA,EAC3E,aAAa;AACf;;;ADwDE;AAzCF,IAAM,6BAA6B;AACnC,IAAM,2BAA2B;AAqBjC,IAAM,mBAAwC,CAAE;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,aAAa;AAAA,EACb;AACD,MAAO;AACN,QAAM;AAAA,IACL;AAAA,IACA,OAAO;AAAA,MACN,UAAU,EAAE,iBAAiB;AAAA,MAC7B;AAAA,IACD;AAAA,EACD,IAAI,uBAAuB;AAG3B,QAAM,qBACL;AAAA,IAAC;AAAA;AAAA,MACA,WAAY,KAAM,aAAa,yBAAO,WAAW,SAAU;AAAA,MAC3D,eAAY;AAAA,MACZ,OAAQ,EAAE,OAAO,OAAO;AAAA,MAEtB,8BAAoB,kBAAkB,IAAI,GAAI,eAAe,gBAAiB;AAAA;AAAA,EACjF;AAID,QAAM,eAAe,iBAAkB,EAAE,OAAO,EAAE,CAAE,EAAE;AACtD,QAAM,gBAAgB,gBAAiB,cAAc,GAAI;AAEzD,QAAM,qBACL,oBAAqB,iBAAiB,MAAM,kBAAmB,KAAK;AACrE,QAAM,sBACL,oBAAqB,kBAAkB,MAAM,kBAAmB,KAAK;AAGtE,QAAM,kBAAkB;AAAA,IACvB,MACC,KAAK,SAAS,KACd,KAAM,CAAE,EAAE;AAAA,MACT,SACC,OAAO,QAAQ,YACf,QAAQ,QACR,UAAU,OACV,IAAI,SAAS,aACb,OAAO,OACP,OAAO,IAAI,MAAM,YACjB,IAAI,MAAM,QACV,UAAU,IAAI,KACd,IAAI,EAAE,SAAS;AAAA,IACjB;AAAA,IACD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