@automattic/charts 0.56.3 → 0.56.5

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 (186) hide show
  1. package/CHANGELOG.md +14 -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-H34CJSR6.js → chunk-32ESS4MV.js} +406 -363
  44. package/dist/chunk-32ESS4MV.js.map +1 -0
  45. package/dist/{chunk-CEZGL6YP.js → chunk-6CCZL2JJ.js} +15 -7
  46. package/dist/chunk-6CCZL2JJ.js.map +1 -0
  47. package/dist/{chunk-NW3RUYK2.cjs → chunk-7QDEU3KN.cjs} +15 -22
  48. package/dist/chunk-7QDEU3KN.cjs.map +1 -0
  49. package/dist/chunk-7TQSPLIN.js +351 -0
  50. package/dist/chunk-7TQSPLIN.js.map +1 -0
  51. package/dist/{chunk-T4J6TI55.js → chunk-AFWQR3SM.js} +102 -79
  52. package/dist/chunk-AFWQR3SM.js.map +1 -0
  53. package/dist/{chunk-5XI443YP.js → chunk-BPYKWMI7.js} +72 -64
  54. package/dist/chunk-BPYKWMI7.js.map +1 -0
  55. package/dist/{chunk-TNRKEBTA.js → chunk-DBY6C4O2.js} +148 -164
  56. package/dist/{chunk-TNRKEBTA.js.map → chunk-DBY6C4O2.js.map} +1 -1
  57. package/dist/chunk-DLSUC7RN.js +1065 -0
  58. package/dist/chunk-DLSUC7RN.js.map +1 -0
  59. package/dist/{chunk-TVV7ZI7C.cjs → chunk-EJJO2QNB.cjs} +399 -356
  60. package/dist/chunk-EJJO2QNB.cjs.map +1 -0
  61. package/dist/{chunk-ODF5O5PV.cjs → chunk-FIFSYVN6.cjs} +154 -170
  62. package/dist/chunk-FIFSYVN6.cjs.map +1 -0
  63. package/dist/chunk-FY325WQ4.cjs +1065 -0
  64. package/dist/chunk-FY325WQ4.cjs.map +1 -0
  65. package/dist/{chunk-SRXJLAKG.cjs → chunk-I2276W3I.cjs} +28 -37
  66. package/dist/chunk-I2276W3I.cjs.map +1 -0
  67. package/dist/{chunk-7UJPVCMB.cjs → chunk-IHESL7H5.cjs} +265 -262
  68. package/dist/chunk-IHESL7H5.cjs.map +1 -0
  69. package/dist/chunk-JL4ZKKZU.cjs +375 -0
  70. package/dist/chunk-JL4ZKKZU.cjs.map +1 -0
  71. package/dist/chunk-KHRPRH4V.js +165 -0
  72. package/dist/chunk-KHRPRH4V.js.map +1 -0
  73. package/dist/{chunk-A3AEEGKR.js → chunk-KXRWNFQJ.js} +20 -21
  74. package/dist/chunk-KXRWNFQJ.js.map +1 -0
  75. package/dist/{chunk-2VPPTJS2.js → chunk-KXSLMOW5.js} +256 -253
  76. package/dist/chunk-KXSLMOW5.js.map +1 -0
  77. package/dist/chunk-LT4YOIMM.js +375 -0
  78. package/dist/chunk-LT4YOIMM.js.map +1 -0
  79. package/dist/chunk-LTPJPIDP.cjs +165 -0
  80. package/dist/chunk-LTPJPIDP.cjs.map +1 -0
  81. package/dist/chunk-NGHXTIUE.cjs +120 -0
  82. package/dist/chunk-NGHXTIUE.cjs.map +1 -0
  83. package/dist/chunk-PCOI2GT5.js +120 -0
  84. package/dist/chunk-PCOI2GT5.js.map +1 -0
  85. package/dist/{chunk-YYQ4IK5V.cjs → chunk-Q6G3BGCL.cjs} +103 -80
  86. package/dist/chunk-Q6G3BGCL.cjs.map +1 -0
  87. package/dist/{chunk-HIWNB5PK.cjs → chunk-RCY6XLGU.cjs} +13 -5
  88. package/dist/chunk-RCY6XLGU.cjs.map +1 -0
  89. package/dist/chunk-TKPK4RFS.cjs +351 -0
  90. package/dist/chunk-TKPK4RFS.cjs.map +1 -0
  91. package/dist/{chunk-C33AQZEC.js → chunk-TYIH5LMV.js} +16 -23
  92. package/dist/chunk-TYIH5LMV.js.map +1 -0
  93. package/dist/chunk-X6GX4QUJ.js +421 -0
  94. package/dist/chunk-X6GX4QUJ.js.map +1 -0
  95. package/dist/chunk-XCXAWMJQ.cjs +421 -0
  96. package/dist/chunk-XCXAWMJQ.cjs.map +1 -0
  97. package/dist/chunk-XWYZIFZW.js +66 -0
  98. package/dist/chunk-XWYZIFZW.js.map +1 -0
  99. package/dist/{chunk-7HROSZRS.cjs → chunk-Y3NNQMAX.cjs} +70 -62
  100. package/dist/chunk-Y3NNQMAX.cjs.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 +6 -2
  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-chart-margin.test.tsx +44 -0
  139. package/src/hooks/test/use-tooltip-portal-relocator.test.ts +216 -0
  140. package/src/hooks/use-chart-margin.tsx +92 -6
  141. package/src/hooks/use-tooltip-portal-relocator.module.scss +10 -0
  142. package/src/hooks/use-tooltip-portal-relocator.ts +177 -0
  143. package/src/providers/chart-context/global-charts-provider.tsx +18 -1
  144. package/tsup.config.ts +11 -0
  145. package/dist/chunk-2VPPTJS2.js.map +0 -1
  146. package/dist/chunk-5XI443YP.js.map +0 -1
  147. package/dist/chunk-7HROSZRS.cjs.map +0 -1
  148. package/dist/chunk-7UJPVCMB.cjs.map +0 -1
  149. package/dist/chunk-A3AEEGKR.js.map +0 -1
  150. package/dist/chunk-C33AQZEC.js.map +0 -1
  151. package/dist/chunk-CEZGL6YP.js.map +0 -1
  152. package/dist/chunk-COOC2TVQ.js +0 -167
  153. package/dist/chunk-COOC2TVQ.js.map +0 -1
  154. package/dist/chunk-EJHLLXBV.js +0 -362
  155. package/dist/chunk-EJHLLXBV.js.map +0 -1
  156. package/dist/chunk-FWMJ2FR2.js +0 -121
  157. package/dist/chunk-FWMJ2FR2.js.map +0 -1
  158. package/dist/chunk-GRYNIPWH.cjs +0 -385
  159. package/dist/chunk-GRYNIPWH.cjs.map +0 -1
  160. package/dist/chunk-H34CJSR6.js.map +0 -1
  161. package/dist/chunk-HIWNB5PK.cjs.map +0 -1
  162. package/dist/chunk-IZWC33YN.cjs +0 -357
  163. package/dist/chunk-IZWC33YN.cjs.map +0 -1
  164. package/dist/chunk-KOF32DBL.cjs +0 -1058
  165. package/dist/chunk-KOF32DBL.cjs.map +0 -1
  166. package/dist/chunk-LHWRZMF7.cjs +0 -362
  167. package/dist/chunk-LHWRZMF7.cjs.map +0 -1
  168. package/dist/chunk-MFRS2PEY.cjs +0 -121
  169. package/dist/chunk-MFRS2PEY.cjs.map +0 -1
  170. package/dist/chunk-MMDLXS6O.js +0 -75
  171. package/dist/chunk-MMDLXS6O.js.map +0 -1
  172. package/dist/chunk-NW3RUYK2.cjs.map +0 -1
  173. package/dist/chunk-ODF5O5PV.cjs.map +0 -1
  174. package/dist/chunk-OTZT3MC2.cjs.map +0 -1
  175. package/dist/chunk-SBRMWDWM.js +0 -357
  176. package/dist/chunk-SBRMWDWM.js.map +0 -1
  177. package/dist/chunk-SRXJLAKG.cjs.map +0 -1
  178. package/dist/chunk-T4J6TI55.js.map +0 -1
  179. package/dist/chunk-TVV7ZI7C.cjs.map +0 -1
  180. package/dist/chunk-XVMXWV3C.cjs +0 -167
  181. package/dist/chunk-XVMXWV3C.cjs.map +0 -1
  182. package/dist/chunk-YYQ4IK5V.cjs.map +0 -1
  183. package/dist/chunk-ZDNCF642.js +0 -1058
  184. package/dist/chunk-ZDNCF642.js.map +0 -1
  185. package/dist/chunk-ZWBUEHKF.js +0 -385
  186. package/dist/chunk-ZWBUEHKF.js.map +0 -1
@@ -0,0 +1,165 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }
2
+
3
+ var _chunkFY325WQ4cjs = require('./chunk-FY325WQ4.cjs');
4
+
5
+
6
+ var _chunk7QDEU3KNcjs = require('./chunk-7QDEU3KN.cjs');
7
+
8
+
9
+ var _chunkEJJO2QNBcjs = require('./chunk-EJJO2QNB.cjs');
10
+
11
+ // src/charts/sparkline/sparkline.tsx
12
+ var _clsx = require('clsx'); var _clsx2 = _interopRequireDefault(_clsx);
13
+ var _react = require('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
+ var _jsxruntime = require('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__ */ _react.forwardRef.call(void 0, ({
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 = _chunkEJJO2QNBcjs.useGlobalChartsTheme.call(void 0, );
56
+ const themeStrokeWidth = _nullishCoalesce(_optionalChain([theme, 'access', _ => _.sparkline, 'optionalAccess', _2 => _2.strokeWidth]), () => ( 1.5));
57
+ const strokeWidth = _nullishCoalesce(strokeWidthProp, () => ( themeStrokeWidth));
58
+ const seriesData = _react.useMemo.call(void 0, () => {
59
+ if (!data || data.length === 0) {
60
+ return [];
61
+ }
62
+ return transformToSeriesData(data, color, strokeWidth);
63
+ }, [data, color, strokeWidth]);
64
+ const finalMargin = _react.useMemo.call(void 0, () => {
65
+ const themeMargin = _nullishCoalesce(_optionalChain([theme, 'access', _3 => _3.sparkline, 'optionalAccess', _4 => _4.margin]), () => ( {
66
+ top: 2,
67
+ right: 2,
68
+ bottom: 2,
69
+ left: 2
70
+ }));
71
+ const margin = _nullishCoalesce(marginProp, () => ( themeMargin));
72
+ return {
73
+ ...themeMargin,
74
+ ...margin
75
+ };
76
+ }, [marginProp, _optionalChain([theme, 'access', _5 => _5.sparkline, 'optionalAccess', _6 => _6.margin])]);
77
+ const seriesWithGradient = _react.useMemo.call(void 0, () => {
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: _nullishCoalesce(gradient.fromOpacity, () => ( 0.5)),
89
+ toOpacity: _nullishCoalesce(gradient.toOpacity, () => ( 0))
90
+ }
91
+ }
92
+ }));
93
+ }, [seriesData, gradient, color]);
94
+ if (!data || data.length === 0) {
95
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {
96
+ ref,
97
+ className: _clsx2.default.call(void 0, "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__ */ _jsxruntime.jsx.call(void 0, "div", {
109
+ ref,
110
+ className: _clsx2.default.call(void 0, "sparkline", sparkline_module_default.sparkline, sparkline_module_default["sparkline--single-point"], className),
111
+ style: {
112
+ width,
113
+ height
114
+ },
115
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", {
116
+ width,
117
+ height,
118
+ "aria-hidden": "true",
119
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "circle", {
120
+ cx,
121
+ cy,
122
+ r: strokeWidth * 1.5,
123
+ fill: resolvedColor
124
+ })
125
+ })
126
+ });
127
+ }
128
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {
129
+ ref,
130
+ className: _clsx2.default.call(void 0, "sparkline", sparkline_module_default.sparkline, className),
131
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkFY325WQ4cjs.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 = _chunk7QDEU3KNcjs.withResponsive.call(void 0, SparklineUnresponsive);
160
+
161
+
162
+
163
+
164
+ exports.SparklineUnresponsive = SparklineUnresponsive; exports.Sparkline = Sparkline;
165
+ //# sourceMappingURL=chunk-LTPJPIDP.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/jetpack/jetpack/projects/js-packages/charts/dist/chunk-LTPJPIDP.cjs","../src/charts/sparkline/sparkline.tsx","../src/charts/sparkline/sparkline.module.scss"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACVA,wE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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};"]}
@@ -0,0 +1,120 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
+
3
+ var _chunk7QDEU3KNcjs = require('./chunk-7QDEU3KN.cjs');
4
+
5
+
6
+
7
+
8
+ var _chunkEJJO2QNBcjs = require('./chunk-EJJO2QNB.cjs');
9
+
10
+
11
+
12
+
13
+ var _chunkZVGEDXDPcjs = require('./chunk-ZVGEDXDP.cjs');
14
+
15
+ // src/charts/geo-chart/geo-chart.tsx
16
+ var _i18n = require('@wordpress/i18n');
17
+ var _clsx = require('clsx'); var _clsx2 = _interopRequireDefault(_clsx);
18
+ var _react = require('react');
19
+ var _reactgooglecharts = require('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
+ var _jsxruntime = require('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
+ } = _chunkEJJO2QNBcjs.useGlobalChartsContext.call(void 0, );
48
+ const loadingPlaceholder = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {
49
+ className: _clsx2.default.call(void 0, "geo-chart", geo_chart_module_default.container, className),
50
+ style: {
51
+ width,
52
+ height
53
+ },
54
+ children: renderPlaceholder ? renderPlaceholder() : _i18n.__.call(void 0, "Loading map", "jetpack-charts")
55
+ });
56
+ const fullColorHex = getElementStyles({
57
+ index: 0
58
+ }).color;
59
+ const lightColorHex = _chunkZVGEDXDPcjs.lightenHexColor.call(void 0, fullColorHex, 0.8);
60
+ const backgroundColorHex = _chunkZVGEDXDPcjs.normalizeColorToHex.call(void 0, backgroundColor, null, _chunkZVGEDXDPcjs.resolveCssVariable) || DEFAULT_BACKGROUND_COLOR;
61
+ const defaultFillColorHex = _chunkZVGEDXDPcjs.normalizeColorToHex.call(void 0, featureFillColor, null, _chunkZVGEDXDPcjs.resolveCssVariable) || DEFAULT_FEATURE_FILL_COLOR;
62
+ const hasHtmlTooltips = _react.useMemo.call(void 0, () => 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 = _react.useMemo.call(void 0, () => ({
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__ */ _jsxruntime.jsx.call(void 0, "div", {
84
+ className: _clsx2.default.call(void 0, "geo-chart", geo_chart_module_default.container, className),
85
+ style: {
86
+ width,
87
+ height,
88
+ backgroundColor
89
+ },
90
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactgooglecharts.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 = _react.useContext.call(void 0, _chunkEJJO2QNBcjs.GlobalChartsContext);
102
+ if (existingContext) {
103
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, GeoChartInternal, {
104
+ ...props
105
+ });
106
+ }
107
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkEJJO2QNBcjs.GlobalChartsProvider, {
108
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, GeoChartInternal, {
109
+ ...props
110
+ })
111
+ });
112
+ };
113
+ GeoChartWithProvider.displayName = "GeoChart";
114
+ var GeoChartResponsive = _chunk7QDEU3KNcjs.withResponsive.call(void 0, GeoChartWithProvider);
115
+
116
+
117
+
118
+
119
+ exports.GeoChartWithProvider = GeoChartWithProvider; exports.GeoChartResponsive = GeoChartResponsive;
120
+ //# sourceMappingURL=chunk-NGHXTIUE.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/jetpack/jetpack/projects/js-packages/charts/dist/chunk-NGHXTIUE.cjs","../src/charts/geo-chart/geo-chart.tsx","../src/charts/geo-chart/geo-chart.module.scss"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACXA,uCAAmB;AACnB,wEAAiB;AACjB,8BAAoC;AACpC,wDAAsB;ADatB;AACA;AEpB8D,IAAO,yBAAA,EAAQ;AAAA,EAC3E,WAAA,EAAa;AACf,CAA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AAA;AAAA,MACA,MAAA;AAAA,MACA;AAAA,IACF,CAAA;AAAA,IACA,QAAA,kBAAuB,6BAAA,wBAAK,EAAO;AAAA,MACjC,SAAA,EAAW,UAAA;AAAA,MACX,KAAA;AAAA,MACA,MAAA;AAAA,MACA,IAAA;AAAA,MACA,OAAA;AAAA,MACA,MAAA,EAAQ;AAAA,IACV,CAAC;AAAA,EACH,CAAC,CAAA;AACH,CAAA;AACA,IAAM,qBAAA,EAAuB,CAAA,KAAA,EAAA,GAAS;AACpC,EAAA,MAAM,gBAAA,EAAkB,+BAAA,qCAA8B,CAAA;AAGtD,EAAA,GAAA,CAAI,eAAA,EAAiB;AACnB,IAAA,uBAAoB,6BAAA,gBAAK,EAAkB;AAAA,MACzC,GAAG;AAAA,IACL,CAAC,CAAA;AAAA,EACH;AAGA,EAAA,uBAAoB,6BAAA,sCAAK,EAAsB;AAAA,IAC7C,QAAA,kBAAuB,6BAAA,gBAAK,EAAkB;AAAA,MAC5C,GAAG;AAAA,IACL,CAAC;AAAA,EACH,CAAC,CAAA;AACH,CAAA;AACA,oBAAA,CAAqB,YAAA,EAAc,UAAA;AACnC,IAAM,mBAAA,EAAqB,8CAAA,oBAAmC,CAAA;ADnB9D;AACA;AACE;AACA;AACF,qGAAC","file":"/home/runner/work/jetpack/jetpack/projects/js-packages/charts/dist/chunk-NGHXTIUE.cjs","sourcesContent":[null,"/**\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};"]}
@@ -0,0 +1,120 @@
1
+ import {
2
+ withResponsive
3
+ } from "./chunk-TYIH5LMV.js";
4
+ import {
5
+ GlobalChartsContext,
6
+ GlobalChartsProvider,
7
+ useGlobalChartsContext
8
+ } from "./chunk-32ESS4MV.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 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-PCOI2GT5.js.map
@@ -0,0 +1 @@
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-ch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