@yamada-ui/charts 1.0.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 (175) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +28 -0
  3. package/dist/area-chart-gradient.d.mts +11 -0
  4. package/dist/area-chart-gradient.d.ts +11 -0
  5. package/dist/area-chart-gradient.js +47 -0
  6. package/dist/area-chart-gradient.js.map +1 -0
  7. package/dist/area-chart-gradient.mjs +8 -0
  8. package/dist/area-chart-gradient.mjs.map +1 -0
  9. package/dist/area-chart-split.d.mts +10 -0
  10. package/dist/area-chart-split.d.ts +10 -0
  11. package/dist/area-chart-split.js +52 -0
  12. package/dist/area-chart-split.js.map +1 -0
  13. package/dist/area-chart-split.mjs +8 -0
  14. package/dist/area-chart-split.mjs.map +1 -0
  15. package/dist/area-chart.d.mts +36 -0
  16. package/dist/area-chart.d.ts +36 -0
  17. package/dist/area-chart.js +1249 -0
  18. package/dist/area-chart.js.map +1 -0
  19. package/dist/area-chart.mjs +21 -0
  20. package/dist/area-chart.mjs.map +1 -0
  21. package/dist/bar-chart.d.mts +33 -0
  22. package/dist/bar-chart.d.ts +33 -0
  23. package/dist/bar-chart.js +1053 -0
  24. package/dist/bar-chart.js.map +1 -0
  25. package/dist/bar-chart.mjs +19 -0
  26. package/dist/bar-chart.mjs.map +1 -0
  27. package/dist/chart-legend.d.mts +12 -0
  28. package/dist/chart-legend.d.ts +12 -0
  29. package/dist/chart-legend.js +87 -0
  30. package/dist/chart-legend.js.map +1 -0
  31. package/dist/chart-legend.mjs +11 -0
  32. package/dist/chart-legend.mjs.map +1 -0
  33. package/dist/chart-tooltip.d.mts +12 -0
  34. package/dist/chart-tooltip.d.ts +12 -0
  35. package/dist/chart-tooltip.js +120 -0
  36. package/dist/chart-tooltip.js.map +1 -0
  37. package/dist/chart-tooltip.mjs +11 -0
  38. package/dist/chart-tooltip.mjs.map +1 -0
  39. package/dist/chart-utils.d.mts +9 -0
  40. package/dist/chart-utils.d.ts +9 -0
  41. package/dist/chart-utils.js +45 -0
  42. package/dist/chart-utils.js.map +1 -0
  43. package/dist/chart-utils.mjs +10 -0
  44. package/dist/chart-utils.mjs.map +1 -0
  45. package/dist/chart.types.d.mts +65 -0
  46. package/dist/chart.types.d.ts +65 -0
  47. package/dist/chart.types.js +20 -0
  48. package/dist/chart.types.js.map +1 -0
  49. package/dist/chart.types.mjs +2 -0
  50. package/dist/chart.types.mjs.map +1 -0
  51. package/dist/chunk-32BO2QEP.mjs +83 -0
  52. package/dist/chunk-32BO2QEP.mjs.map +1 -0
  53. package/dist/chunk-3CY3IFRN.mjs +42 -0
  54. package/dist/chunk-3CY3IFRN.mjs.map +1 -0
  55. package/dist/chunk-3IBGJT6F.mjs +341 -0
  56. package/dist/chunk-3IBGJT6F.mjs.map +1 -0
  57. package/dist/chunk-5QCKM3B3.mjs +438 -0
  58. package/dist/chunk-5QCKM3B3.mjs.map +1 -0
  59. package/dist/chunk-AURFFNDQ.mjs +114 -0
  60. package/dist/chunk-AURFFNDQ.mjs.map +1 -0
  61. package/dist/chunk-FGDWJUA3.mjs +56 -0
  62. package/dist/chunk-FGDWJUA3.mjs.map +1 -0
  63. package/dist/chunk-GZLE5XDS.mjs +227 -0
  64. package/dist/chunk-GZLE5XDS.mjs.map +1 -0
  65. package/dist/chunk-HE6SM47L.mjs +234 -0
  66. package/dist/chunk-HE6SM47L.mjs.map +1 -0
  67. package/dist/chunk-LXZCGIND.mjs +33 -0
  68. package/dist/chunk-LXZCGIND.mjs.map +1 -0
  69. package/dist/chunk-MSIOYYWR.mjs +24 -0
  70. package/dist/chunk-MSIOYYWR.mjs.map +1 -0
  71. package/dist/chunk-PNE3JG54.mjs +29 -0
  72. package/dist/chunk-PNE3JG54.mjs.map +1 -0
  73. package/dist/chunk-QL3DB7OJ.mjs +21 -0
  74. package/dist/chunk-QL3DB7OJ.mjs.map +1 -0
  75. package/dist/chunk-RG5JQJXE.mjs +249 -0
  76. package/dist/chunk-RG5JQJXE.mjs.map +1 -0
  77. package/dist/chunk-RTTZPOUT.mjs +50 -0
  78. package/dist/chunk-RTTZPOUT.mjs.map +1 -0
  79. package/dist/chunk-RXWD2EJ2.mjs +56 -0
  80. package/dist/chunk-RXWD2EJ2.mjs.map +1 -0
  81. package/dist/chunk-TKLHZBVY.mjs +206 -0
  82. package/dist/chunk-TKLHZBVY.mjs.map +1 -0
  83. package/dist/chunk-WDSR6B47.mjs +324 -0
  84. package/dist/chunk-WDSR6B47.mjs.map +1 -0
  85. package/dist/chunk-WF3BD34Y.mjs +74 -0
  86. package/dist/chunk-WF3BD34Y.mjs.map +1 -0
  87. package/dist/chunk-YBAGOHS5.mjs +204 -0
  88. package/dist/chunk-YBAGOHS5.mjs.map +1 -0
  89. package/dist/chunk-YRY7MUCR.mjs +258 -0
  90. package/dist/chunk-YRY7MUCR.mjs.map +1 -0
  91. package/dist/index.d.mts +23 -0
  92. package/dist/index.d.ts +23 -0
  93. package/dist/index.js +2725 -0
  94. package/dist/index.js.map +1 -0
  95. package/dist/index.mjs +36 -0
  96. package/dist/index.mjs.map +1 -0
  97. package/dist/line-chart.d.mts +33 -0
  98. package/dist/line-chart.d.ts +33 -0
  99. package/dist/line-chart.js +1114 -0
  100. package/dist/line-chart.js.map +1 -0
  101. package/dist/line-chart.mjs +19 -0
  102. package/dist/line-chart.mjs.map +1 -0
  103. package/dist/radar-chart.d.mts +52 -0
  104. package/dist/radar-chart.d.ts +52 -0
  105. package/dist/radar-chart.js +940 -0
  106. package/dist/radar-chart.js.map +1 -0
  107. package/dist/radar-chart.mjs +16 -0
  108. package/dist/radar-chart.mjs.map +1 -0
  109. package/dist/rechart-properties.d.mts +24 -0
  110. package/dist/rechart-properties.d.ts +24 -0
  111. package/dist/rechart-properties.js +479 -0
  112. package/dist/rechart-properties.js.map +1 -0
  113. package/dist/rechart-properties.mjs +44 -0
  114. package/dist/rechart-properties.mjs.map +1 -0
  115. package/dist/use-area-chart.d.mts +118 -0
  116. package/dist/use-area-chart.d.ts +118 -0
  117. package/dist/use-area-chart.js +418 -0
  118. package/dist/use-area-chart.js.map +1 -0
  119. package/dist/use-area-chart.mjs +10 -0
  120. package/dist/use-area-chart.mjs.map +1 -0
  121. package/dist/use-bar-chart.d.mts +68 -0
  122. package/dist/use-bar-chart.d.ts +68 -0
  123. package/dist/use-bar-chart.js +288 -0
  124. package/dist/use-bar-chart.js.map +1 -0
  125. package/dist/use-bar-chart.mjs +10 -0
  126. package/dist/use-bar-chart.mjs.map +1 -0
  127. package/dist/use-chart-axis.d.mts +73 -0
  128. package/dist/use-chart-axis.d.ts +73 -0
  129. package/dist/use-chart-axis.js +227 -0
  130. package/dist/use-chart-axis.js.map +1 -0
  131. package/dist/use-chart-axis.mjs +10 -0
  132. package/dist/use-chart-axis.mjs.map +1 -0
  133. package/dist/use-chart-grid.d.mts +32 -0
  134. package/dist/use-chart-grid.d.ts +32 -0
  135. package/dist/use-chart-grid.js +92 -0
  136. package/dist/use-chart-grid.js.map +1 -0
  137. package/dist/use-chart-grid.mjs +10 -0
  138. package/dist/use-chart-grid.mjs.map +1 -0
  139. package/dist/use-chart-legend.d.mts +18 -0
  140. package/dist/use-chart-legend.d.ts +18 -0
  141. package/dist/use-chart-legend.js +81 -0
  142. package/dist/use-chart-legend.js.map +1 -0
  143. package/dist/use-chart-legend.mjs +9 -0
  144. package/dist/use-chart-legend.mjs.map +1 -0
  145. package/dist/use-chart-reference-line.d.mts +22 -0
  146. package/dist/use-chart-reference-line.d.ts +22 -0
  147. package/dist/use-chart-reference-line.js +105 -0
  148. package/dist/use-chart-reference-line.js.map +1 -0
  149. package/dist/use-chart-reference-line.mjs +10 -0
  150. package/dist/use-chart-reference-line.mjs.map +1 -0
  151. package/dist/use-chart-tooltip.d.mts +35 -0
  152. package/dist/use-chart-tooltip.d.ts +35 -0
  153. package/dist/use-chart-tooltip.js +121 -0
  154. package/dist/use-chart-tooltip.js.map +1 -0
  155. package/dist/use-chart-tooltip.mjs +9 -0
  156. package/dist/use-chart-tooltip.mjs.map +1 -0
  157. package/dist/use-chart.d.mts +33 -0
  158. package/dist/use-chart.d.ts +33 -0
  159. package/dist/use-chart.js +104 -0
  160. package/dist/use-chart.js.map +1 -0
  161. package/dist/use-chart.mjs +18 -0
  162. package/dist/use-chart.mjs.map +1 -0
  163. package/dist/use-line-chart.d.mts +92 -0
  164. package/dist/use-line-chart.d.ts +92 -0
  165. package/dist/use-line-chart.js +342 -0
  166. package/dist/use-line-chart.js.map +1 -0
  167. package/dist/use-line-chart.mjs +10 -0
  168. package/dist/use-line-chart.mjs.map +1 -0
  169. package/dist/use-radar-chart.d.mts +93 -0
  170. package/dist/use-radar-chart.d.ts +93 -0
  171. package/dist/use-radar-chart.js +471 -0
  172. package/dist/use-radar-chart.js.map +1 -0
  173. package/dist/use-radar-chart.mjs +10 -0
  174. package/dist/use-radar-chart.mjs.map +1 -0
  175. package/package.json +84 -0
@@ -0,0 +1,940 @@
1
+ "use client"
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/radar-chart.tsx
22
+ var radar_chart_exports = {};
23
+ __export(radar_chart_exports, {
24
+ RadarChart: () => RadarChart
25
+ });
26
+ module.exports = __toCommonJS(radar_chart_exports);
27
+ var import_core6 = require("@yamada-ui/core");
28
+ var import_utils8 = require("@yamada-ui/utils");
29
+ var import_react5 = require("react");
30
+ var import_recharts = require("recharts");
31
+
32
+ // src/chart-legend.tsx
33
+ var import_core3 = require("@yamada-ui/core");
34
+ var import_utils3 = require("@yamada-ui/utils");
35
+
36
+ // src/use-chart.ts
37
+ var import_core2 = require("@yamada-ui/core");
38
+ var import_utils2 = require("@yamada-ui/utils");
39
+ var import_react = require("react");
40
+
41
+ // src/chart-utils.ts
42
+ var import_core = require("@yamada-ui/core");
43
+ var import_utils = require("@yamada-ui/utils");
44
+ var getClassName = (...styles) => (theme) => (0, import_utils.cx)(
45
+ ...styles.map(
46
+ (style) => (0, import_utils.isString)(style) ? style : (0, import_core.getCSS)(style)(theme)
47
+ )
48
+ );
49
+ var getComponentProps = ([obj, keys], ...props) => (theme, isContain) => {
50
+ const [pickedProps, omittedProps] = (0, import_utils.splitObject)(obj, keys);
51
+ const className = getClassName(...props, omittedProps)(theme);
52
+ return !isContain ? [pickedProps, className] : { ...pickedProps, className };
53
+ };
54
+
55
+ // src/rechart-properties.ts
56
+ var radarChartProperties = [
57
+ "width",
58
+ "height",
59
+ "data",
60
+ "cx",
61
+ "cy",
62
+ "startAngle",
63
+ "endAngle",
64
+ "innerRadius",
65
+ "outerRadius",
66
+ "margin",
67
+ "onMouseEnter",
68
+ "onClick"
69
+ ];
70
+ var containerProperties = [
71
+ "aspect",
72
+ "width",
73
+ "height",
74
+ "minWidth",
75
+ "minHeight",
76
+ "debounce",
77
+ "onResize"
78
+ ];
79
+ var legendProperties = [
80
+ "width",
81
+ "height",
82
+ "layout",
83
+ "align",
84
+ "verticalAlign",
85
+ "iconSize",
86
+ "iconType",
87
+ "payload",
88
+ "chartWidth",
89
+ "chartHeight",
90
+ "margin",
91
+ "content",
92
+ "formatter",
93
+ "wrapperStyle",
94
+ "onClick",
95
+ "onMouseDown",
96
+ "onMouseUp",
97
+ "onMouseMove",
98
+ "onMouseOver",
99
+ "onMouseOut",
100
+ "onMouseEnter",
101
+ "onMouseLeave"
102
+ ];
103
+ var tooltipProperties = [
104
+ "offset",
105
+ "filterNull",
106
+ "itemStyle",
107
+ "wrapperStyle",
108
+ "contentStyle",
109
+ "labelStyle",
110
+ "cursor",
111
+ "viewBox",
112
+ "allowEscapeViewBox",
113
+ "active",
114
+ "position",
115
+ "coordinate",
116
+ "payload",
117
+ "label",
118
+ "content",
119
+ "formatter",
120
+ "labelFormatter",
121
+ "itemSorter",
122
+ "isAnimationActive",
123
+ "animationDuration",
124
+ "animationEasing"
125
+ ];
126
+ var radarProperties = [
127
+ "dataKey",
128
+ "points",
129
+ "shape",
130
+ "dot",
131
+ "activeDot",
132
+ "legendType",
133
+ "label",
134
+ "isAnimationActive",
135
+ "animationBegin",
136
+ "animationDuration",
137
+ "animationEasing",
138
+ "onAnimationStart",
139
+ "onAnimationEnd"
140
+ ];
141
+ var dotProperties = [
142
+ "cx",
143
+ "cy",
144
+ "r",
145
+ "onClick",
146
+ "onMouseDown",
147
+ "onMouseUp",
148
+ "onMouseMove",
149
+ "onMouseOver",
150
+ "onMouseOut",
151
+ "onMouseEnter",
152
+ "onMouseLeave"
153
+ ];
154
+ var polarGridProperties = [
155
+ "cx",
156
+ "cy",
157
+ "innerRadius",
158
+ "outerRadius",
159
+ "polarAngles",
160
+ "polarRadius",
161
+ "gridType"
162
+ ];
163
+ var polarAngleAxisProperties = [
164
+ "dataKey",
165
+ "cx",
166
+ "cy",
167
+ "radius",
168
+ "axisLine",
169
+ "axisLineType",
170
+ "tickLine",
171
+ "tickSize",
172
+ "tick",
173
+ "ticks",
174
+ "orient",
175
+ "tickFormatter",
176
+ "type",
177
+ "allowDuplicatedCategory",
178
+ "onClick",
179
+ "onMouseDown",
180
+ "onMouseUp",
181
+ "onMouseMove",
182
+ "onMouseOver",
183
+ "onMouseOut",
184
+ "onMouseEnter",
185
+ "onMouseLeave"
186
+ ];
187
+ var polarRadiusAxisProperties = [
188
+ "angle",
189
+ "type",
190
+ "allowDuplicatedCategory",
191
+ "cx",
192
+ "cy",
193
+ "domain",
194
+ "reversed",
195
+ "label",
196
+ "orientation",
197
+ "axisLine",
198
+ "tick",
199
+ "tickSize",
200
+ "tickFormatter",
201
+ "tickCount",
202
+ "scale",
203
+ "onClick",
204
+ "onMouseDown",
205
+ "onMouseUp",
206
+ "onMouseMove",
207
+ "onMouseOver",
208
+ "onMouseOut",
209
+ "onMouseEnter",
210
+ "onMouseLeave"
211
+ ];
212
+
213
+ // src/use-chart.ts
214
+ var [ChartProvider, useChartContext] = (0, import_utils2.createContext)({
215
+ name: "ChartContext",
216
+ errorMessage: `useChartContext returned is 'undefined'. Seems you forgot to wrap the components in "<LineChart />" or "<BarChart />" etc.`
217
+ });
218
+ var useChart = ({ containerProps = {} }) => {
219
+ const { theme } = (0, import_core2.useTheme)();
220
+ const [reChartsProps, propClassName] = getComponentProps([
221
+ containerProps,
222
+ containerProperties
223
+ ])(theme);
224
+ const getContainerProps = (0, import_react.useCallback)(
225
+ ({ className, ...props } = {}, ref = null) => ({
226
+ ref,
227
+ className: (0, import_utils2.cx)("ui-chart__container", className, propClassName),
228
+ ...props,
229
+ ...reChartsProps
230
+ }),
231
+ [propClassName, reChartsProps]
232
+ );
233
+ return {
234
+ getContainerProps
235
+ };
236
+ };
237
+ var useLegend = ({} = {}) => {
238
+ const { styles } = useChartContext();
239
+ return {
240
+ styles
241
+ };
242
+ };
243
+ var useTooltip = ({} = {}) => {
244
+ const { styles } = useChartContext();
245
+ return {
246
+ styles
247
+ };
248
+ };
249
+
250
+ // src/chart-legend.tsx
251
+ var import_jsx_runtime = require("react/jsx-runtime");
252
+ var ChartLegend = (0, import_core3.forwardRef)(
253
+ ({ className, payload = [], onHighlight, ...rest }, ref) => {
254
+ const { styles } = useLegend();
255
+ const items = payload.map(({ dataKey, color }, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
256
+ import_core3.ui.div,
257
+ {
258
+ className: "ui-chart__legend-item",
259
+ onMouseEnter: () => onHighlight(dataKey),
260
+ onMouseLeave: () => onHighlight(null),
261
+ __css: styles.legendItem,
262
+ children: [
263
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
264
+ import_core3.ui.div,
265
+ {
266
+ className: "ui-chart__legend-swatch",
267
+ background: color,
268
+ __css: styles.legendSwatch
269
+ }
270
+ ),
271
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core3.ui.span, { className: "ui-chart__legend-label", children: dataKey })
272
+ ]
273
+ },
274
+ `legend-${index}`
275
+ ));
276
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
277
+ import_core3.ui.div,
278
+ {
279
+ ref,
280
+ className: (0, import_utils3.cx)("ui-chart__legend", className),
281
+ __css: styles.legend,
282
+ ...rest,
283
+ children: items
284
+ }
285
+ );
286
+ }
287
+ );
288
+
289
+ // src/chart-tooltip.tsx
290
+ var import_core4 = require("@yamada-ui/core");
291
+ var import_utils4 = require("@yamada-ui/utils");
292
+ var import_jsx_runtime2 = require("react/jsx-runtime");
293
+ var ChartTooltip = (0, import_core4.forwardRef)(
294
+ ({ label, className, payload = [], valueFormatter, unit, ...rest }, ref) => {
295
+ const { styles } = useTooltip();
296
+ const items = payload.map(
297
+ ({ color, name, value: valueProp } = {}, index) => {
298
+ var _a;
299
+ let value;
300
+ if ((0, import_utils4.isArray)(valueProp)) {
301
+ value = valueProp.map((value2) => {
302
+ var _a2;
303
+ return `${(_a2 = valueFormatter == null ? void 0 : valueFormatter(value2)) != null ? _a2 : value2}`;
304
+ }).join(" - ");
305
+ } else {
306
+ value = (_a = valueFormatter == null ? void 0 : valueFormatter(valueProp)) != null ? _a : valueProp;
307
+ }
308
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
309
+ import_core4.ui.div,
310
+ {
311
+ className: "ui-chart__tooltip-item",
312
+ __css: styles.tooltipItem,
313
+ children: [
314
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
315
+ import_core4.ui.div,
316
+ {
317
+ className: "ui-chart__tooltip-swatch",
318
+ background: color,
319
+ __css: styles.tooltipSwatch
320
+ }
321
+ ),
322
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
323
+ import_core4.ui.span,
324
+ {
325
+ className: "ui-chart__tooltip-label",
326
+ __css: styles.tooltipLabel,
327
+ children: name
328
+ }
329
+ ),
330
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
331
+ import_core4.ui.span,
332
+ {
333
+ className: "ui-chart__tooltip-value",
334
+ __css: styles.tooltipValue,
335
+ children: [
336
+ value,
337
+ unit ? unit : ""
338
+ ]
339
+ }
340
+ )
341
+ ]
342
+ },
343
+ `tooltip-payload-${index}`
344
+ );
345
+ }
346
+ );
347
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
348
+ import_core4.ui.div,
349
+ {
350
+ ref,
351
+ className: (0, import_utils4.cx)("ui-chart__tooltip", className),
352
+ __css: styles.tooltip,
353
+ ...rest,
354
+ children: [
355
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core4.ui.p, { className: "ui-chart__tooltip-title", __css: styles.tooltipTitle, children: label }),
356
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core4.ui.div, { className: "ui-chart__tooltip-list", __css: styles.tooltipList, children: items })
357
+ ]
358
+ }
359
+ );
360
+ }
361
+ );
362
+
363
+ // src/use-chart-legend.ts
364
+ var import_utils5 = require("@yamada-ui/utils");
365
+ var import_react2 = require("react");
366
+ var useChartLegend = ({
367
+ legendProps: _legendProps = {}
368
+ }) => {
369
+ const [rest, legendProps] = (0, import_utils5.splitObject)(
370
+ _legendProps,
371
+ legendProperties
372
+ );
373
+ const getLegendProps = (0, import_react2.useCallback)(
374
+ (props, ref = null) => {
375
+ return {
376
+ ref,
377
+ verticalAlign: "top",
378
+ ...props,
379
+ ...rest
380
+ };
381
+ },
382
+ [rest]
383
+ );
384
+ return { legendProps, getLegendProps };
385
+ };
386
+
387
+ // src/use-chart-tooltip.ts
388
+ var import_utils6 = require("@yamada-ui/utils");
389
+ var import_react3 = require("react");
390
+ var useChartTooltip = ({
391
+ tooltipProps: _tooltipProps = {},
392
+ tooltipAnimationDuration = 0,
393
+ styles
394
+ }) => {
395
+ const { cursor, ...rest } = _tooltipProps;
396
+ const resolvedCursor = (0, import_react3.useMemo)(
397
+ () => ({ ...styles.cursor, ...cursor }),
398
+ [cursor, styles]
399
+ );
400
+ const tooltipVars = (0, import_react3.useMemo)(
401
+ () => [
402
+ {
403
+ __prefix: "ui",
404
+ name: "cursor-fill",
405
+ token: "colors",
406
+ value: resolvedCursor.fill
407
+ },
408
+ {
409
+ __prefix: "ui",
410
+ name: "cursor-stroke",
411
+ token: "colors",
412
+ value: resolvedCursor.stroke
413
+ },
414
+ {
415
+ __prefix: "ui",
416
+ name: "cursor-stroke-width",
417
+ token: "colors",
418
+ value: resolvedCursor.strokeWidth
419
+ },
420
+ {
421
+ __prefix: "ui",
422
+ name: "cursor-stroke-dasharray",
423
+ token: "colors",
424
+ value: resolvedCursor.strokeDasharray
425
+ }
426
+ ],
427
+ [resolvedCursor]
428
+ );
429
+ const [tooltipProps, tooltipUIProps] = (0, import_utils6.splitObject)(
430
+ rest,
431
+ tooltipProperties
432
+ );
433
+ const getTooltipProps = (0, import_react3.useCallback)(
434
+ (props, ref = null) => ({
435
+ ref,
436
+ animationDuration: tooltipAnimationDuration,
437
+ isAnimationActive: (tooltipAnimationDuration || 0) > 0,
438
+ cursor: {
439
+ fill: "var(--ui-cursor-fill)",
440
+ stroke: "var(--ui-cursor-stroke)",
441
+ strokeWidth: "var(--ui-cursor-stroke-width)",
442
+ strokeDasharray: "var(--ui-cursor-stroke-dasharray)"
443
+ },
444
+ ...props,
445
+ ...tooltipProps
446
+ }),
447
+ [tooltipAnimationDuration, tooltipProps]
448
+ );
449
+ return { tooltipProps: tooltipUIProps, getTooltipProps, tooltipVars };
450
+ };
451
+
452
+ // src/use-radar-chart.ts
453
+ var import_core5 = require("@yamada-ui/core");
454
+ var import_utils7 = require("@yamada-ui/utils");
455
+ var import_react4 = require("react");
456
+ var useRadarChart = ({
457
+ data,
458
+ series,
459
+ dataKey,
460
+ withDots = false,
461
+ withActiveDots = false,
462
+ strokeWidth = 2,
463
+ fillOpacity = 0.4,
464
+ valueFormatter,
465
+ styles,
466
+ ...rest
467
+ }) => {
468
+ var _a;
469
+ const { theme } = (0, import_core5.useTheme)();
470
+ const [highlightedArea, setHighlightedArea] = (0, import_react4.useState)(null);
471
+ const shouldHighlight = highlightedArea !== null;
472
+ const {
473
+ dot = {},
474
+ activeDot = {},
475
+ dimDot,
476
+ dimRadar,
477
+ ...computedRadarProps
478
+ } = (_a = rest.radarProps) != null ? _a : {};
479
+ const radarColors = (0, import_react4.useMemo)(
480
+ () => series.map(({ color }, index) => ({
481
+ __prefix: "ui",
482
+ name: `radar-${index}`,
483
+ token: "colors",
484
+ value: color != null ? color : "transparent"
485
+ })),
486
+ [series]
487
+ );
488
+ const radarVars = (0, import_react4.useMemo)(
489
+ () => [
490
+ ...radarColors,
491
+ { __prefix: "ui", name: "fill-opacity", value: fillOpacity }
492
+ ],
493
+ [fillOpacity, radarColors]
494
+ );
495
+ const [polarAngleAxisProps, polarAngleAxisStyles] = (0, import_react4.useMemo)(
496
+ () => {
497
+ var _a2;
498
+ return (0, import_utils7.splitObject)(
499
+ (_a2 = rest.polarAngleAxisProps) != null ? _a2 : {},
500
+ polarAngleAxisProperties
501
+ );
502
+ },
503
+ [rest.polarAngleAxisProps]
504
+ );
505
+ const [polarRadiusAxisProps, polarRadiusAxisStyles] = (0, import_react4.useMemo)(
506
+ () => {
507
+ var _a2;
508
+ return (0, import_utils7.splitObject)(
509
+ (_a2 = rest.polarRadiusAxisProps) != null ? _a2 : {},
510
+ polarRadiusAxisProperties
511
+ );
512
+ },
513
+ [rest.polarRadiusAxisProps]
514
+ );
515
+ const [radarChartProps, radarChartClassName] = (0, import_react4.useMemo)(() => {
516
+ const resolvedRadarChartProps = {
517
+ "& .recharts-polar-grid-concentric-polygon": { ...styles.polarGrid },
518
+ "& .recharts-polar-grid-concentric-circle": { ...styles.polarGrid },
519
+ "& .recharts-polar-angle-axis": {
520
+ ...styles.polarAngleAxis,
521
+ ...polarAngleAxisStyles
522
+ },
523
+ "& .recharts-polar-angle-axis-tick": { ...styles.polarAngleAxisTick },
524
+ "& .recharts-polar-radius-axis": {
525
+ ...styles.polarRadiusAxis,
526
+ ...polarRadiusAxisStyles
527
+ },
528
+ "& .recharts-polar-radius-axis-tick": { ...styles.polarRadiusAxisTick },
529
+ ...rest.radarChartProps
530
+ };
531
+ return getComponentProps(
532
+ [resolvedRadarChartProps, radarChartProperties],
533
+ styles.chart
534
+ )(theme);
535
+ }, [
536
+ polarAngleAxisStyles,
537
+ polarRadiusAxisStyles,
538
+ rest.radarChartProps,
539
+ styles.chart,
540
+ styles.polarAngleAxis,
541
+ styles.polarAngleAxisTick,
542
+ styles.polarGrid,
543
+ styles.polarRadiusAxis,
544
+ styles.polarRadiusAxisTick,
545
+ theme
546
+ ]);
547
+ const [polarGridProps, polarGridClassName] = (0, import_react4.useMemo)(
548
+ () => {
549
+ var _a2;
550
+ return getComponentProps(
551
+ [(_a2 = rest.polarGridProps) != null ? _a2 : {}, polarGridProperties],
552
+ styles.polarGrid
553
+ )(theme);
554
+ },
555
+ [rest.polarGridProps, styles.polarGrid, theme]
556
+ );
557
+ const [radarProps, radarClassName] = (0, import_react4.useMemo)(() => {
558
+ const resolvedRadarProps = {
559
+ fillOpacity: "var(--ui-fill-opacity)",
560
+ ...computedRadarProps
561
+ };
562
+ return getComponentProps(
563
+ [resolvedRadarProps, radarProperties],
564
+ styles.radar
565
+ )(theme);
566
+ }, [computedRadarProps, styles.radar, theme]);
567
+ const [dimRadarProps, dimRadarClassName] = (0, import_react4.useMemo)(() => {
568
+ const resolvedDimRadar = {
569
+ fillOpacity: 0.3,
570
+ strokeOpacity: 0.3,
571
+ ...dimRadar
572
+ };
573
+ return getComponentProps([resolvedDimRadar, radarProperties])(
574
+ theme
575
+ );
576
+ }, [dimRadar, theme]);
577
+ const [dotProps, dotClassName] = (0, import_react4.useMemo)(() => {
578
+ const resolvedDot = { fillOpacity: 1, strokeWidth: 2, ...dot };
579
+ return getComponentProps(
580
+ [resolvedDot, dotProperties],
581
+ styles.dot
582
+ )(theme);
583
+ }, [dot, styles.dot, theme]);
584
+ const [activeDotProps, activeDotClassName] = (0, import_react4.useMemo)(
585
+ () => getComponentProps(
586
+ [activeDot, dotProperties],
587
+ styles.activeDot
588
+ )(theme),
589
+ [activeDot, styles.activeDot, theme]
590
+ );
591
+ const [dimDotProps, dimDotClassName] = (0, import_react4.useMemo)(() => {
592
+ const resolvedDimDot = { fillOpacity: 0, strokeOpacity: 0, ...dimDot };
593
+ return getComponentProps([resolvedDimDot, dotProperties])(
594
+ theme
595
+ );
596
+ }, [dimDot, theme]);
597
+ const radarPropList = (0, import_react4.useMemo)(
598
+ () => series.map((props, index) => {
599
+ const {
600
+ dataKey: dataKey2,
601
+ dot: dot2 = {},
602
+ activeDot: activeDot2 = {},
603
+ dimDot: dimDot2 = {},
604
+ dimRadar: dimRadar2 = {},
605
+ ...computedProps
606
+ } = props;
607
+ const color = `var(--ui-radar-${index})`;
608
+ const dimmed = shouldHighlight && highlightedArea !== dataKey2;
609
+ const computedDimRadar = { ...dimRadarProps, ...dimRadar2 };
610
+ const resolvedProps = {
611
+ ...radarProps,
612
+ ...computedProps,
613
+ ...dimmed ? computedDimRadar : {}
614
+ };
615
+ const rest2 = getComponentProps(
616
+ [resolvedProps, radarProperties],
617
+ radarClassName,
618
+ dimmed ? dimRadarClassName : void 0
619
+ )(theme, true);
620
+ let resolvedActiveDot;
621
+ if (withActiveDots) {
622
+ const computedActiveDot = {
623
+ ...activeDotProps,
624
+ ...activeDot2
625
+ };
626
+ const [rest3, className] = getComponentProps(
627
+ [computedActiveDot, dotProperties],
628
+ activeDotClassName
629
+ )(theme);
630
+ resolvedActiveDot = {
631
+ className: (0, import_utils7.cx)("ui-radar-chart__active-dot", className),
632
+ fill: color,
633
+ stroke: color,
634
+ r: 4,
635
+ ...rest3
636
+ };
637
+ } else {
638
+ resolvedActiveDot = false;
639
+ }
640
+ let resolvedDot;
641
+ if (withDots) {
642
+ const computedDimDot = { ...dimDotProps, ...dimDot2 };
643
+ const computedDot = {
644
+ ...dotProps,
645
+ ...dot2,
646
+ ...dimmed ? computedDimDot : {}
647
+ };
648
+ const [rest3, className] = getComponentProps(
649
+ [computedDot, dotProperties],
650
+ dotClassName,
651
+ dimmed ? dimDotClassName : void 0
652
+ )(theme);
653
+ resolvedDot = {
654
+ // BUG: className is not applied.
655
+ className: (0, import_utils7.cx)("ui-radar-chart__dot", className),
656
+ fill: color,
657
+ r: 4,
658
+ ...rest3
659
+ };
660
+ } else {
661
+ resolvedDot = false;
662
+ }
663
+ return {
664
+ ...rest2,
665
+ color,
666
+ dataKey: dataKey2,
667
+ dot: resolvedDot,
668
+ activeDot: resolvedActiveDot
669
+ };
670
+ }),
671
+ [
672
+ activeDotClassName,
673
+ activeDotProps,
674
+ dimDotClassName,
675
+ dimDotProps,
676
+ dimRadarClassName,
677
+ dimRadarProps,
678
+ dotClassName,
679
+ dotProps,
680
+ highlightedArea,
681
+ radarClassName,
682
+ radarProps,
683
+ series,
684
+ shouldHighlight,
685
+ theme,
686
+ withActiveDots,
687
+ withDots
688
+ ]
689
+ );
690
+ const getRadarChartProps = (0, import_react4.useCallback)(
691
+ ({ className, ...props } = {}, ref = null) => ({
692
+ ref,
693
+ className: (0, import_utils7.cx)(className, radarChartClassName),
694
+ data,
695
+ ...props,
696
+ ...radarChartProps
697
+ }),
698
+ [data, radarChartClassName, radarChartProps]
699
+ );
700
+ const getRadarProps = (0, import_react4.useCallback)(
701
+ ({ index, className: classNameProp, ...props }, ref = null) => {
702
+ const { color, className, dataKey: dataKey2, activeDot: activeDot2, dot: dot2, ...rest2 } = radarPropList[index];
703
+ return {
704
+ ref,
705
+ className: (0, import_utils7.cx)(classNameProp, className),
706
+ activeDot: activeDot2,
707
+ dot: dot2,
708
+ name: dataKey2,
709
+ dataKey: dataKey2,
710
+ fill: color,
711
+ strokeWidth,
712
+ stroke: color,
713
+ isAnimationActive: false,
714
+ ...props,
715
+ ...rest2
716
+ };
717
+ },
718
+ [radarPropList, strokeWidth]
719
+ );
720
+ const getPolarGridProps = (0, import_react4.useCallback)(
721
+ ({ className, ...props } = {}, ref = null) => ({
722
+ ref,
723
+ // BUG: `.recharts-polar-grid-concentric-xxx` is not applied className.
724
+ className: (0, import_utils7.cx)(className, polarGridClassName),
725
+ ...props,
726
+ ...polarGridProps
727
+ }),
728
+ [polarGridClassName, polarGridProps]
729
+ );
730
+ const getPolarAngleAxisProps = (0, import_react4.useCallback)(
731
+ ({ className, ...props } = {}, ref = null) => ({
732
+ ref,
733
+ // BUG: className is not applied.
734
+ // className: cx(className, polarAngleAxisClassName),
735
+ className,
736
+ dataKey,
737
+ tickFormatter: valueFormatter,
738
+ tickSize: 16,
739
+ ...props,
740
+ ...polarAngleAxisProps
741
+ }),
742
+ [
743
+ dataKey,
744
+ // polarAngleAxisClassName,
745
+ polarAngleAxisProps,
746
+ valueFormatter
747
+ ]
748
+ );
749
+ const getPolarRadiusAxisProps = (0, import_react4.useCallback)(
750
+ ({ className, ...props } = {}, ref = null) => ({
751
+ ref,
752
+ // BUG: className is not applied.
753
+ // className: cx(className, polarRadiusAxisClassName),
754
+ className,
755
+ tickFormatter: valueFormatter,
756
+ ...props,
757
+ ...polarRadiusAxisProps
758
+ }),
759
+ [
760
+ // polarRadiusAxisClassName,
761
+ polarRadiusAxisProps,
762
+ valueFormatter
763
+ ]
764
+ );
765
+ return {
766
+ radarVars,
767
+ getRadarChartProps,
768
+ getRadarProps,
769
+ getPolarGridProps,
770
+ getPolarAngleAxisProps,
771
+ getPolarRadiusAxisProps,
772
+ setHighlightedArea
773
+ };
774
+ };
775
+
776
+ // src/radar-chart.tsx
777
+ var import_jsx_runtime3 = require("react/jsx-runtime");
778
+ var RadarChart = (0, import_core6.forwardRef)((props, ref) => {
779
+ const [styles, mergedProps] = (0, import_core6.useMultiComponentStyle)("RadarChart", props);
780
+ const {
781
+ className,
782
+ data,
783
+ series,
784
+ dataKey,
785
+ radarProps,
786
+ radarChartProps,
787
+ polarGridProps,
788
+ polarAngleAxisProps,
789
+ polarRadiusAxisProps,
790
+ containerProps,
791
+ tooltipProps,
792
+ legendProps,
793
+ tooltipAnimationDuration,
794
+ unit,
795
+ valueFormatter,
796
+ withDots,
797
+ withActiveDots,
798
+ strokeWidth,
799
+ fillOpacity,
800
+ withTooltip = true,
801
+ withLegend = false,
802
+ withPolarGrid = true,
803
+ withPolarAngleAxis = true,
804
+ withPolarRadiusAxis = false,
805
+ ...rest
806
+ } = (0, import_core6.omitThemeProps)(mergedProps);
807
+ const {
808
+ getRadarProps,
809
+ getRadarChartProps,
810
+ getPolarGridProps,
811
+ getPolarAngleAxisProps,
812
+ getPolarRadiusAxisProps,
813
+ radarVars,
814
+ setHighlightedArea
815
+ } = useRadarChart({
816
+ data,
817
+ series,
818
+ dataKey,
819
+ radarProps,
820
+ radarChartProps,
821
+ polarGridProps,
822
+ polarAngleAxisProps,
823
+ polarRadiusAxisProps,
824
+ withDots,
825
+ withActiveDots,
826
+ strokeWidth,
827
+ fillOpacity,
828
+ valueFormatter,
829
+ styles
830
+ });
831
+ const { getContainerProps } = useChart({ containerProps });
832
+ const {
833
+ tooltipProps: computedTooltipProps,
834
+ getTooltipProps,
835
+ tooltipVars
836
+ } = useChartTooltip({
837
+ tooltipProps,
838
+ tooltipAnimationDuration,
839
+ styles
840
+ });
841
+ const { legendProps: computedLegendProps, getLegendProps } = useChartLegend({
842
+ legendProps
843
+ });
844
+ const radars = (0, import_react5.useMemo)(
845
+ () => series.map(({ dataKey: dataKey2 }, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
846
+ import_recharts.Radar,
847
+ {
848
+ ...getRadarProps({ index, className: "ui-radar-chart__radar" })
849
+ },
850
+ `radar=${dataKey2}`
851
+ )),
852
+ [getRadarProps, series]
853
+ );
854
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChartProvider, { value: { styles }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
855
+ import_core6.ui.div,
856
+ {
857
+ ref,
858
+ className: (0, import_utils8.cx)("ui-radar-chart", className),
859
+ var: [...radarVars, ...tooltipVars],
860
+ __css: { maxW: "full", ...styles.container },
861
+ ...rest,
862
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
863
+ import_recharts.ResponsiveContainer,
864
+ {
865
+ ...getContainerProps({ className: "ui-radar-chart__container" }),
866
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
867
+ import_recharts.RadarChart,
868
+ {
869
+ ...getRadarChartProps({ className: "ui-radar-chart__chart" }),
870
+ children: [
871
+ withPolarGrid ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
872
+ import_recharts.PolarGrid,
873
+ {
874
+ ...getPolarGridProps({
875
+ className: "ui-radar-chart__polar-grid"
876
+ })
877
+ }
878
+ ) : null,
879
+ withPolarAngleAxis ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
880
+ import_recharts.PolarAngleAxis,
881
+ {
882
+ ...getPolarAngleAxisProps({
883
+ className: "ui-radar-chart__polar-angle-axis"
884
+ })
885
+ }
886
+ ) : null,
887
+ withPolarRadiusAxis ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
888
+ import_recharts.PolarRadiusAxis,
889
+ {
890
+ ...getPolarRadiusAxisProps({
891
+ className: "ui-radar-chart__polar-radius-axis"
892
+ })
893
+ }
894
+ ) : null,
895
+ withLegend ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
896
+ import_recharts.Legend,
897
+ {
898
+ content: ({ payload }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
899
+ ChartLegend,
900
+ {
901
+ className: "ui-area-chart__legend",
902
+ payload,
903
+ onHighlight: setHighlightedArea,
904
+ ...computedLegendProps
905
+ }
906
+ ),
907
+ ...getLegendProps()
908
+ }
909
+ ) : null,
910
+ withTooltip ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
911
+ import_recharts.Tooltip,
912
+ {
913
+ content: ({ label, payload }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
914
+ ChartTooltip,
915
+ {
916
+ className: "ui-line-chart__tooltip",
917
+ label,
918
+ payload,
919
+ valueFormatter,
920
+ unit,
921
+ ...computedTooltipProps
922
+ }
923
+ ),
924
+ ...getTooltipProps()
925
+ }
926
+ ) : null,
927
+ radars
928
+ ]
929
+ }
930
+ )
931
+ }
932
+ )
933
+ }
934
+ ) });
935
+ });
936
+ // Annotate the CommonJS export names for ESM import in node:
937
+ 0 && (module.exports = {
938
+ RadarChart
939
+ });
940
+ //# sourceMappingURL=radar-chart.js.map