@yamada-ui/charts 1.1.2-next-20240429233030 → 1.1.2

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 (197) hide show
  1. package/package.json +5 -5
  2. package/dist/area-chart-gradient.d.mts +0 -11
  3. package/dist/area-chart-gradient.d.ts +0 -11
  4. package/dist/area-chart-gradient.js +0 -47
  5. package/dist/area-chart-gradient.js.map +0 -1
  6. package/dist/area-chart-gradient.mjs +0 -8
  7. package/dist/area-chart-gradient.mjs.map +0 -1
  8. package/dist/area-chart-split.d.mts +0 -10
  9. package/dist/area-chart-split.d.ts +0 -10
  10. package/dist/area-chart-split.js +0 -52
  11. package/dist/area-chart-split.js.map +0 -1
  12. package/dist/area-chart-split.mjs +0 -8
  13. package/dist/area-chart-split.mjs.map +0 -1
  14. package/dist/area-chart.d.mts +0 -41
  15. package/dist/area-chart.d.ts +0 -41
  16. package/dist/area-chart.js +0 -1223
  17. package/dist/area-chart.js.map +0 -1
  18. package/dist/area-chart.mjs +0 -21
  19. package/dist/area-chart.mjs.map +0 -1
  20. package/dist/bar-chart.d.mts +0 -38
  21. package/dist/bar-chart.d.ts +0 -38
  22. package/dist/bar-chart.js +0 -1027
  23. package/dist/bar-chart.js.map +0 -1
  24. package/dist/bar-chart.mjs +0 -19
  25. package/dist/bar-chart.mjs.map +0 -1
  26. package/dist/chart-legend.d.mts +0 -12
  27. package/dist/chart-legend.d.ts +0 -12
  28. package/dist/chart-legend.js +0 -90
  29. package/dist/chart-legend.js.map +0 -1
  30. package/dist/chart-legend.mjs +0 -11
  31. package/dist/chart-legend.mjs.map +0 -1
  32. package/dist/chart-tooltip.d.mts +0 -12
  33. package/dist/chart-tooltip.d.ts +0 -12
  34. package/dist/chart-tooltip.js +0 -121
  35. package/dist/chart-tooltip.js.map +0 -1
  36. package/dist/chart-tooltip.mjs +0 -11
  37. package/dist/chart-tooltip.mjs.map +0 -1
  38. package/dist/chart-utils.d.mts +0 -9
  39. package/dist/chart-utils.d.ts +0 -9
  40. package/dist/chart-utils.js +0 -45
  41. package/dist/chart-utils.js.map +0 -1
  42. package/dist/chart-utils.mjs +0 -10
  43. package/dist/chart-utils.mjs.map +0 -1
  44. package/dist/chart.types.d.mts +0 -78
  45. package/dist/chart.types.d.ts +0 -78
  46. package/dist/chart.types.js +0 -20
  47. package/dist/chart.types.js.map +0 -1
  48. package/dist/chart.types.mjs +0 -2
  49. package/dist/chart.types.mjs.map +0 -1
  50. package/dist/chunk-4WX5YS7M.mjs +0 -179
  51. package/dist/chunk-4WX5YS7M.mjs.map +0 -1
  52. package/dist/chunk-5TVYPA64.mjs +0 -256
  53. package/dist/chunk-5TVYPA64.mjs.map +0 -1
  54. package/dist/chunk-BPR7YL3O.mjs +0 -179
  55. package/dist/chunk-BPR7YL3O.mjs.map +0 -1
  56. package/dist/chunk-E2I2XAZ6.mjs +0 -232
  57. package/dist/chunk-E2I2XAZ6.mjs.map +0 -1
  58. package/dist/chunk-HDOYOHLA.mjs +0 -326
  59. package/dist/chunk-HDOYOHLA.mjs.map +0 -1
  60. package/dist/chunk-KNAADLWO.mjs +0 -225
  61. package/dist/chunk-KNAADLWO.mjs.map +0 -1
  62. package/dist/chunk-KT4YOMM4.mjs +0 -344
  63. package/dist/chunk-KT4YOMM4.mjs.map +0 -1
  64. package/dist/chunk-LBC2B6UX.mjs +0 -84
  65. package/dist/chunk-LBC2B6UX.mjs.map +0 -1
  66. package/dist/chunk-LGMALZCN.mjs +0 -42
  67. package/dist/chunk-LGMALZCN.mjs.map +0 -1
  68. package/dist/chunk-LHI57S6P.mjs +0 -215
  69. package/dist/chunk-LHI57S6P.mjs.map +0 -1
  70. package/dist/chunk-LM2DQK2P.mjs +0 -33
  71. package/dist/chunk-LM2DQK2P.mjs.map +0 -1
  72. package/dist/chunk-MSIOYYWR.mjs +0 -24
  73. package/dist/chunk-MSIOYYWR.mjs.map +0 -1
  74. package/dist/chunk-MWPICUEW.mjs +0 -56
  75. package/dist/chunk-MWPICUEW.mjs.map +0 -1
  76. package/dist/chunk-NEGDEVRX.mjs +0 -53
  77. package/dist/chunk-NEGDEVRX.mjs.map +0 -1
  78. package/dist/chunk-OSNFBRHL.mjs +0 -474
  79. package/dist/chunk-OSNFBRHL.mjs.map +0 -1
  80. package/dist/chunk-OW7SOTEF.mjs +0 -206
  81. package/dist/chunk-OW7SOTEF.mjs.map +0 -1
  82. package/dist/chunk-P7AFSM5W.mjs +0 -114
  83. package/dist/chunk-P7AFSM5W.mjs.map +0 -1
  84. package/dist/chunk-PNE3JG54.mjs +0 -29
  85. package/dist/chunk-PNE3JG54.mjs.map +0 -1
  86. package/dist/chunk-QL3DB7OJ.mjs +0 -21
  87. package/dist/chunk-QL3DB7OJ.mjs.map +0 -1
  88. package/dist/chunk-QZ5OXZ6Z.mjs +0 -251
  89. package/dist/chunk-QZ5OXZ6Z.mjs.map +0 -1
  90. package/dist/chunk-RN6PXJAD.mjs +0 -47
  91. package/dist/chunk-RN6PXJAD.mjs.map +0 -1
  92. package/dist/chunk-STBYRLC5.mjs +0 -208
  93. package/dist/chunk-STBYRLC5.mjs.map +0 -1
  94. package/dist/chunk-XIFDRM7J.mjs +0 -56
  95. package/dist/chunk-XIFDRM7J.mjs.map +0 -1
  96. package/dist/donut-chart.d.mts +0 -31
  97. package/dist/donut-chart.d.ts +0 -31
  98. package/dist/donut-chart.js +0 -702
  99. package/dist/donut-chart.js.map +0 -1
  100. package/dist/donut-chart.mjs +0 -16
  101. package/dist/donut-chart.mjs.map +0 -1
  102. package/dist/index.d.mts +0 -26
  103. package/dist/index.d.ts +0 -26
  104. package/dist/index.js +0 -3228
  105. package/dist/index.js.map +0 -1
  106. package/dist/index.mjs +0 -45
  107. package/dist/index.mjs.map +0 -1
  108. package/dist/line-chart.d.mts +0 -38
  109. package/dist/line-chart.d.ts +0 -38
  110. package/dist/line-chart.js +0 -1088
  111. package/dist/line-chart.js.map +0 -1
  112. package/dist/line-chart.mjs +0 -19
  113. package/dist/line-chart.mjs.map +0 -1
  114. package/dist/pie-chart.d.mts +0 -49
  115. package/dist/pie-chart.d.ts +0 -49
  116. package/dist/pie-chart.js +0 -702
  117. package/dist/pie-chart.js.map +0 -1
  118. package/dist/pie-chart.mjs +0 -16
  119. package/dist/pie-chart.mjs.map +0 -1
  120. package/dist/radar-chart.d.mts +0 -57
  121. package/dist/radar-chart.d.ts +0 -57
  122. package/dist/radar-chart.js +0 -918
  123. package/dist/radar-chart.js.map +0 -1
  124. package/dist/radar-chart.mjs +0 -16
  125. package/dist/radar-chart.mjs.map +0 -1
  126. package/dist/rechart-properties.d.mts +0 -26
  127. package/dist/rechart-properties.d.ts +0 -26
  128. package/dist/rechart-properties.js +0 -517
  129. package/dist/rechart-properties.js.map +0 -1
  130. package/dist/rechart-properties.mjs +0 -48
  131. package/dist/rechart-properties.mjs.map +0 -1
  132. package/dist/use-area-chart.d.mts +0 -123
  133. package/dist/use-area-chart.d.ts +0 -123
  134. package/dist/use-area-chart.js +0 -420
  135. package/dist/use-area-chart.js.map +0 -1
  136. package/dist/use-area-chart.mjs +0 -10
  137. package/dist/use-area-chart.mjs.map +0 -1
  138. package/dist/use-bar-chart.d.mts +0 -73
  139. package/dist/use-bar-chart.d.ts +0 -73
  140. package/dist/use-bar-chart.js +0 -290
  141. package/dist/use-bar-chart.js.map +0 -1
  142. package/dist/use-bar-chart.mjs +0 -10
  143. package/dist/use-bar-chart.mjs.map +0 -1
  144. package/dist/use-chart-axis.d.mts +0 -73
  145. package/dist/use-chart-axis.d.ts +0 -73
  146. package/dist/use-chart-axis.js +0 -227
  147. package/dist/use-chart-axis.js.map +0 -1
  148. package/dist/use-chart-axis.mjs +0 -10
  149. package/dist/use-chart-axis.mjs.map +0 -1
  150. package/dist/use-chart-grid.d.mts +0 -32
  151. package/dist/use-chart-grid.d.ts +0 -32
  152. package/dist/use-chart-grid.js +0 -92
  153. package/dist/use-chart-grid.js.map +0 -1
  154. package/dist/use-chart-grid.mjs +0 -10
  155. package/dist/use-chart-grid.mjs.map +0 -1
  156. package/dist/use-chart-legend.d.mts +0 -18
  157. package/dist/use-chart-legend.d.ts +0 -18
  158. package/dist/use-chart-legend.js +0 -81
  159. package/dist/use-chart-legend.js.map +0 -1
  160. package/dist/use-chart-legend.mjs +0 -9
  161. package/dist/use-chart-legend.mjs.map +0 -1
  162. package/dist/use-chart-reference-line.d.mts +0 -22
  163. package/dist/use-chart-reference-line.d.ts +0 -22
  164. package/dist/use-chart-reference-line.js +0 -105
  165. package/dist/use-chart-reference-line.js.map +0 -1
  166. package/dist/use-chart-reference-line.mjs +0 -10
  167. package/dist/use-chart-reference-line.mjs.map +0 -1
  168. package/dist/use-chart-tooltip.d.mts +0 -27
  169. package/dist/use-chart-tooltip.d.ts +0 -27
  170. package/dist/use-chart-tooltip.js +0 -100
  171. package/dist/use-chart-tooltip.js.map +0 -1
  172. package/dist/use-chart-tooltip.mjs +0 -10
  173. package/dist/use-chart-tooltip.mjs.map +0 -1
  174. package/dist/use-chart.d.mts +0 -33
  175. package/dist/use-chart.d.ts +0 -33
  176. package/dist/use-chart.js +0 -104
  177. package/dist/use-chart.js.map +0 -1
  178. package/dist/use-chart.mjs +0 -18
  179. package/dist/use-chart.mjs.map +0 -1
  180. package/dist/use-line-chart.d.mts +0 -97
  181. package/dist/use-line-chart.d.ts +0 -97
  182. package/dist/use-line-chart.js +0 -344
  183. package/dist/use-line-chart.js.map +0 -1
  184. package/dist/use-line-chart.mjs +0 -10
  185. package/dist/use-line-chart.mjs.map +0 -1
  186. package/dist/use-pie-chart.d.mts +0 -112
  187. package/dist/use-pie-chart.d.ts +0 -112
  188. package/dist/use-pie-chart.js +0 -282
  189. package/dist/use-pie-chart.js.map +0 -1
  190. package/dist/use-pie-chart.mjs +0 -10
  191. package/dist/use-pie-chart.mjs.map +0 -1
  192. package/dist/use-radar-chart.d.mts +0 -105
  193. package/dist/use-radar-chart.d.ts +0 -105
  194. package/dist/use-radar-chart.js +0 -473
  195. package/dist/use-radar-chart.js.map +0 -1
  196. package/dist/use-radar-chart.mjs +0 -10
  197. package/dist/use-radar-chart.mjs.map +0 -1
@@ -1,702 +0,0 @@
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/donut-chart.tsx
22
- var donut_chart_exports = {};
23
- __export(donut_chart_exports, {
24
- DonutChart: () => DonutChart
25
- });
26
- module.exports = __toCommonJS(donut_chart_exports);
27
- var import_core7 = 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 pieChartProperties = ["width", "height", "margin", "onClick", "onMouseEnter", "onMouseLeave"];
57
- var containerProperties = [
58
- "aspect",
59
- "width",
60
- "height",
61
- "minWidth",
62
- "minHeight",
63
- "debounce",
64
- "onResize"
65
- ];
66
- var legendProperties = [
67
- "width",
68
- "height",
69
- "layout",
70
- "align",
71
- "verticalAlign",
72
- "iconSize",
73
- "iconType",
74
- "payload",
75
- "chartWidth",
76
- "chartHeight",
77
- "margin",
78
- "content",
79
- "formatter",
80
- "wrapperStyle",
81
- "onClick",
82
- "onMouseDown",
83
- "onMouseUp",
84
- "onMouseMove",
85
- "onMouseOver",
86
- "onMouseOut",
87
- "onMouseEnter",
88
- "onMouseLeave"
89
- ];
90
- var tooltipProperties = [
91
- "offset",
92
- "filterNull",
93
- "itemStyle",
94
- "wrapperStyle",
95
- "contentStyle",
96
- "labelStyle",
97
- "cursor",
98
- "viewBox",
99
- "allowEscapeViewBox",
100
- "active",
101
- "position",
102
- "coordinate",
103
- "payload",
104
- "label",
105
- "content",
106
- "formatter",
107
- "labelFormatter",
108
- "itemSorter",
109
- "isAnimationActive",
110
- "animationDuration",
111
- "animationEasing"
112
- ];
113
- var pieProperties = [
114
- "cx",
115
- "cy",
116
- "innerRadius",
117
- "outerRadius",
118
- "startAngle",
119
- "endAngle",
120
- "minAngle",
121
- "paddingAngle",
122
- "nameKey",
123
- "dataKey",
124
- "legendType",
125
- "label",
126
- "labelLine",
127
- "data",
128
- "activeIndex",
129
- "activeShape",
130
- "inactiveShape",
131
- "isAnimationActive",
132
- "animationBegin",
133
- "animationDuration",
134
- "animationEasing",
135
- "onAnimationStart",
136
- "onAnimationEnd",
137
- "onClick",
138
- "onMouseDown",
139
- "onMouseUp",
140
- "onMouseMove",
141
- "onMouseOver",
142
- "onMouseOut",
143
- "onMouseEnter",
144
- "onMouseLeave"
145
- ];
146
-
147
- // src/use-chart.ts
148
- var [ChartProvider, useChartContext] = (0, import_utils2.createContext)({
149
- name: "ChartContext",
150
- errorMessage: `useChartContext returned is 'undefined'. Seems you forgot to wrap the components in "<LineChart />" or "<BarChart />" etc.`
151
- });
152
- var useChart = ({ containerProps = {} }) => {
153
- const { theme } = (0, import_core2.useTheme)();
154
- const [reChartsProps, propClassName] = getComponentProps([
155
- containerProps,
156
- containerProperties
157
- ])(theme);
158
- const getContainerProps = (0, import_react.useCallback)(
159
- ({ className, ...props } = {}, ref = null) => ({
160
- ref,
161
- className: (0, import_utils2.cx)("ui-chart__container", className, propClassName),
162
- ...props,
163
- ...reChartsProps
164
- }),
165
- [propClassName, reChartsProps]
166
- );
167
- return {
168
- getContainerProps
169
- };
170
- };
171
- var useLegend = ({} = {}) => {
172
- const { styles } = useChartContext();
173
- return {
174
- styles
175
- };
176
- };
177
- var useTooltip = ({} = {}) => {
178
- const { styles } = useChartContext();
179
- return {
180
- styles
181
- };
182
- };
183
-
184
- // src/chart-legend.tsx
185
- var import_jsx_runtime = require("react/jsx-runtime");
186
- var ChartLegend = (0, import_core3.forwardRef)(
187
- ({ className, payload = [], onHighlight, ...rest }, ref) => {
188
- const { styles } = useLegend();
189
- const items = payload.map(({ dataKey, value: valueProp, color }, index) => {
190
- const value = dataKey != null ? dataKey : valueProp;
191
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
192
- import_core3.ui.div,
193
- {
194
- className: "ui-chart__legend-item",
195
- onMouseEnter: () => onHighlight(value),
196
- onMouseLeave: () => onHighlight(null),
197
- __css: styles.legendItem,
198
- children: [
199
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
200
- import_core3.ui.div,
201
- {
202
- className: "ui-chart__legend-swatch",
203
- background: color,
204
- __css: styles.legendSwatch
205
- }
206
- ),
207
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core3.ui.span, { className: "ui-chart__legend-label", children: value })
208
- ]
209
- },
210
- `legend-${index}`
211
- );
212
- });
213
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
214
- import_core3.ui.div,
215
- {
216
- ref,
217
- className: (0, import_utils3.cx)("ui-chart__legend", className),
218
- __css: styles.legend,
219
- ...rest,
220
- children: items
221
- }
222
- );
223
- }
224
- );
225
-
226
- // src/chart-tooltip.tsx
227
- var import_core4 = require("@yamada-ui/core");
228
- var import_utils4 = require("@yamada-ui/utils");
229
- var import_jsx_runtime2 = require("react/jsx-runtime");
230
- var ChartTooltip = (0, import_core4.forwardRef)(
231
- ({ label, className, payload = [], valueFormatter, unit, ...rest }, ref) => {
232
- const { styles } = useTooltip();
233
- const items = payload.map(
234
- ({ color: colorProp, name, value: valueProp, payload: payload2 } = {}, index) => {
235
- var _a;
236
- const color = colorProp != null ? colorProp : payload2 == null ? void 0 : payload2.color;
237
- let value;
238
- if ((0, import_utils4.isArray)(valueProp)) {
239
- value = valueProp.map((value2) => {
240
- var _a2;
241
- return `${(_a2 = valueFormatter == null ? void 0 : valueFormatter(value2)) != null ? _a2 : value2}`;
242
- }).join(" - ");
243
- } else {
244
- value = (_a = valueFormatter == null ? void 0 : valueFormatter(valueProp)) != null ? _a : valueProp;
245
- }
246
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
247
- import_core4.ui.div,
248
- {
249
- className: "ui-chart__tooltip-item",
250
- __css: styles.tooltipItem,
251
- children: [
252
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
253
- import_core4.ui.div,
254
- {
255
- className: "ui-chart__tooltip-swatch",
256
- background: color,
257
- __css: styles.tooltipSwatch
258
- }
259
- ),
260
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
261
- import_core4.ui.span,
262
- {
263
- className: "ui-chart__tooltip-label",
264
- __css: styles.tooltipLabel,
265
- children: name
266
- }
267
- ),
268
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
269
- import_core4.ui.span,
270
- {
271
- className: "ui-chart__tooltip-value",
272
- __css: styles.tooltipValue,
273
- children: [
274
- value,
275
- unit ? unit : ""
276
- ]
277
- }
278
- )
279
- ]
280
- },
281
- `tooltip-payload-${index}`
282
- );
283
- }
284
- );
285
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
286
- import_core4.ui.div,
287
- {
288
- ref,
289
- className: (0, import_utils4.cx)("ui-chart__tooltip", className),
290
- __css: styles.tooltip,
291
- ...rest,
292
- children: [
293
- label ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core4.ui.p, { className: "ui-chart__tooltip-title", __css: styles.tooltipTitle, children: label }) : null,
294
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core4.ui.div, { className: "ui-chart__tooltip-list", __css: styles.tooltipList, children: items })
295
- ]
296
- }
297
- );
298
- }
299
- );
300
-
301
- // src/use-chart-legend.ts
302
- var import_utils5 = require("@yamada-ui/utils");
303
- var import_react2 = require("react");
304
- var useChartLegend = ({
305
- legendProps: _legendProps = {}
306
- }) => {
307
- const [rest, legendProps] = (0, import_utils5.splitObject)(
308
- _legendProps,
309
- legendProperties
310
- );
311
- const getLegendProps = (0, import_react2.useCallback)(
312
- (props, ref = null) => {
313
- return {
314
- ref,
315
- verticalAlign: "top",
316
- ...props,
317
- ...rest
318
- };
319
- },
320
- [rest]
321
- );
322
- return { legendProps, getLegendProps };
323
- };
324
-
325
- // src/use-chart-tooltip.ts
326
- var import_core5 = require("@yamada-ui/core");
327
- var import_utils6 = require("@yamada-ui/utils");
328
- var import_react3 = require("react");
329
- var useChartTooltip = ({
330
- tooltipProps: _tooltipProps = {},
331
- tooltipAnimationDuration = 0,
332
- styles
333
- }) => {
334
- const { theme } = (0, import_core5.useTheme)();
335
- const { cursor, ...rest } = _tooltipProps;
336
- const cursorClassName = (0, import_react3.useMemo)(
337
- () => getClassName({ ...styles.cursor, ...cursor })(theme),
338
- [cursor, styles.cursor, theme]
339
- );
340
- const [tooltipProps, tooltipUIProps] = (0, import_utils6.splitObject)(
341
- rest,
342
- tooltipProperties
343
- );
344
- const getTooltipProps = (0, import_react3.useCallback)(
345
- (props, ref = null) => ({
346
- ref,
347
- animationDuration: tooltipAnimationDuration,
348
- isAnimationActive: (tooltipAnimationDuration || 0) > 0,
349
- cursor: {
350
- className: (0, import_utils6.cx)("ui-chart__cursor", cursorClassName)
351
- },
352
- ...props,
353
- ...tooltipProps
354
- }),
355
- [cursorClassName, tooltipAnimationDuration, tooltipProps]
356
- );
357
- return { tooltipProps: tooltipUIProps, getTooltipProps };
358
- };
359
-
360
- // src/use-pie-chart.ts
361
- var import_core6 = require("@yamada-ui/core");
362
- var import_utils7 = require("@yamada-ui/utils");
363
- var import_react4 = require("react");
364
- var usePieChart = ({
365
- data,
366
- withLabels = false,
367
- withLabelLines = false,
368
- strokeWidth = 1,
369
- fillOpacity = 1,
370
- innerRadius = "0%",
371
- outerRadius = withLabels ? "80%" : "100%",
372
- paddingAngle = 0,
373
- startAngle = 90,
374
- endAngle = -270,
375
- styles,
376
- ...rest
377
- }) => {
378
- var _a, _b;
379
- const { theme } = (0, import_core6.useTheme)();
380
- const [highlightedArea, setHighlightedArea] = (0, import_react4.useState)(null);
381
- const shouldHighlight = highlightedArea !== null;
382
- const { dimCell, ...computedCellProps } = (_a = rest.cellProps) != null ? _a : {};
383
- const {
384
- activeShape = {},
385
- inactiveShape = {},
386
- label,
387
- labelLine,
388
- ...computedPieProps
389
- } = (_b = rest.pieProps) != null ? _b : {};
390
- const cellColors = (0, import_react4.useMemo)(
391
- () => data.map(({ color }, index) => ({
392
- __prefix: "ui",
393
- name: `cell-${index}`,
394
- token: "colors",
395
- value: color != null ? color : "transparent"
396
- })),
397
- [data]
398
- );
399
- const pieVars = (0, import_react4.useMemo)(
400
- () => [
401
- ...cellColors,
402
- { __prefix: "ui", name: "fill-opacity", value: fillOpacity }
403
- ],
404
- [fillOpacity, cellColors]
405
- );
406
- const [chartProps, chartClassName] = (0, import_react4.useMemo)(
407
- () => {
408
- var _a2;
409
- return getComponentProps(
410
- [(_a2 = rest.chartProps) != null ? _a2 : {}, pieChartProperties],
411
- styles.chart
412
- )(theme);
413
- },
414
- [rest.chartProps, styles.chart, theme]
415
- );
416
- const [pieProps, pieClassName] = (0, import_react4.useMemo)(
417
- () => getComponentProps(
418
- [computedPieProps, pieProperties],
419
- styles.pie
420
- )(theme),
421
- [computedPieProps, styles.pie, theme]
422
- );
423
- const cellClassName = (0, import_react4.useMemo)(() => {
424
- const resolvedCellProps = {
425
- fillOpacity: "var(--ui-fill-opacity)",
426
- ...styles.cell,
427
- ...computedCellProps
428
- };
429
- return getClassName(resolvedCellProps)(theme);
430
- }, [computedCellProps, styles.cell, theme]);
431
- const dimCellClassName = (0, import_react4.useMemo)(() => {
432
- const resolvedDimCell = { fillOpacity: 0.3, strokeOpacity: 0, ...dimCell };
433
- return getClassName(resolvedDimCell)(theme);
434
- }, [dimCell, theme]);
435
- const activeShapeProps = (0, import_react4.useMemo)(
436
- () => getComponentProps(
437
- [{ _focus: { outline: "none" }, ...activeShape }, pieProperties],
438
- styles.activeShape
439
- )(theme, true),
440
- [activeShape, styles.activeShape, theme]
441
- );
442
- const inactiveShapeProps = (0, import_react4.useMemo)(
443
- () => getComponentProps(
444
- [inactiveShape, pieProperties],
445
- styles.inactiveShape
446
- )(theme, true),
447
- [inactiveShape, styles.inactiveShape, theme]
448
- );
449
- const labelClassName = (0, import_react4.useMemo)(
450
- () => getClassName({ fillOpacity: 1, ...styles.label, ...label })(theme),
451
- [label, styles.label, theme]
452
- );
453
- const labelLineClassName = (0, import_react4.useMemo)(
454
- () => getClassName({ ...styles.labelLine, ...labelLine })(theme),
455
- [labelLine, styles.labelLine, theme]
456
- );
457
- const cellPropList = (0, import_react4.useMemo)(
458
- () => data.map((props, index) => {
459
- const { name, dimCell: dimCell2 = {}, ...computedProps } = props;
460
- const color = `var(--ui-cell-${index})`;
461
- const dimmed = shouldHighlight && highlightedArea !== name;
462
- const resolvedProps = {
463
- ...computedProps,
464
- ...dimmed ? dimCell2 : {}
465
- };
466
- const className = getClassName(
467
- {
468
- cellClassName,
469
- ...resolvedProps
470
- },
471
- dimmed ? dimCellClassName : void 0
472
- )(theme);
473
- return {
474
- color,
475
- className
476
- };
477
- }),
478
- [
479
- cellClassName,
480
- data,
481
- dimCellClassName,
482
- highlightedArea,
483
- shouldHighlight,
484
- theme
485
- ]
486
- );
487
- const getPieChartProps = (0, import_react4.useCallback)(
488
- ({ className, ...props } = {}, ref = null) => ({
489
- ref,
490
- className: (0, import_utils7.cx)(className, chartClassName),
491
- ...props,
492
- ...chartProps
493
- }),
494
- [chartProps, chartClassName]
495
- );
496
- const getPieProps = (0, import_react4.useCallback)(
497
- ({
498
- className,
499
- labelClassName: labelClassNameProp,
500
- labelLineClassName: labelLineClassNameProp,
501
- ...props
502
- }, ref = null) => ({
503
- ref,
504
- className: (0, import_utils7.cx)(className, pieClassName),
505
- dataKey: "value",
506
- data,
507
- rootTabIndex: -1,
508
- outerRadius,
509
- innerRadius,
510
- paddingAngle,
511
- startAngle,
512
- endAngle,
513
- isAnimationActive: false,
514
- label: withLabels ? { className: (0, import_utils7.cx)(labelClassNameProp, labelClassName) } : false,
515
- labelLine: withLabelLines ? { className: (0, import_utils7.cx)(labelLineClassNameProp, labelLineClassName) } : false,
516
- activeShape: activeShapeProps,
517
- inactiveShape: inactiveShapeProps,
518
- ...props,
519
- ...pieProps
520
- }),
521
- [
522
- pieClassName,
523
- data,
524
- outerRadius,
525
- innerRadius,
526
- paddingAngle,
527
- startAngle,
528
- endAngle,
529
- withLabels,
530
- labelClassName,
531
- withLabelLines,
532
- labelLineClassName,
533
- activeShapeProps,
534
- inactiveShapeProps,
535
- pieProps
536
- ]
537
- );
538
- const getCellProps = (0, import_react4.useCallback)(
539
- ({ index, className: classNameProp, ...props }, ref = null) => {
540
- const { className, color } = cellPropList[index];
541
- return {
542
- ref,
543
- className: (0, import_utils7.cx)(classNameProp, className),
544
- fill: color,
545
- stroke: color,
546
- strokeWidth,
547
- ...props
548
- };
549
- },
550
- [cellPropList, strokeWidth]
551
- );
552
- return {
553
- pieVars,
554
- getPieProps,
555
- getPieChartProps,
556
- getCellProps,
557
- setHighlightedArea
558
- };
559
- };
560
-
561
- // src/donut-chart.tsx
562
- var import_jsx_runtime3 = require("react/jsx-runtime");
563
- var DonutChart = (0, import_core7.forwardRef)((props, ref) => {
564
- const [styles, mergedProps] = (0, import_core7.useMultiComponentStyle)("DonutChart", props);
565
- const {
566
- className,
567
- data,
568
- pieProps,
569
- chartProps,
570
- cellProps,
571
- containerProps,
572
- withTooltip = true,
573
- withLegend = false,
574
- tooltipProps,
575
- tooltipAnimationDuration,
576
- tooltipDataSource = "all",
577
- valueFormatter,
578
- unit,
579
- paddingAngle,
580
- startAngle,
581
- endAngle,
582
- withLabels,
583
- withLabelLines,
584
- innerRadius = withLabels ? "60%" : "80%",
585
- outerRadius,
586
- strokeWidth,
587
- legendProps,
588
- ...rest
589
- } = (0, import_core7.omitThemeProps)(mergedProps);
590
- const {
591
- pieVars,
592
- getPieProps,
593
- getPieChartProps,
594
- getCellProps,
595
- setHighlightedArea
596
- } = usePieChart({
597
- data,
598
- pieProps,
599
- chartProps,
600
- cellProps,
601
- innerRadius,
602
- outerRadius,
603
- paddingAngle,
604
- startAngle,
605
- endAngle,
606
- strokeWidth,
607
- withLabels,
608
- withLabelLines,
609
- styles
610
- });
611
- const { getContainerProps } = useChart({ containerProps });
612
- const { tooltipProps: computedTooltipProps, getTooltipProps } = useChartTooltip({
613
- tooltipProps,
614
- tooltipAnimationDuration,
615
- styles
616
- });
617
- const { legendProps: computedLegendProps, getLegendProps } = useChartLegend({
618
- legendProps
619
- });
620
- const cells = (0, import_react5.useMemo)(
621
- () => data.map(({ name }, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
622
- import_recharts.Cell,
623
- {
624
- ...getCellProps({ index, className: "ui-donut-chart__cell" })
625
- },
626
- `donut-cell-${name}`
627
- )),
628
- [data, getCellProps]
629
- );
630
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChartProvider, { value: { styles }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
631
- import_core7.ui.div,
632
- {
633
- ref,
634
- className: (0, import_utils8.cx)("ui-donut-chart", className),
635
- var: pieVars,
636
- __css: { maxW: "full", ...styles.container },
637
- ...rest,
638
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
639
- import_recharts.ResponsiveContainer,
640
- {
641
- ...getContainerProps({ className: "ui-donut-chart__container" }),
642
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
643
- import_recharts.PieChart,
644
- {
645
- ...getPieChartProps({ className: "ui-donut-chart__chart" }),
646
- children: [
647
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
648
- import_recharts.Pie,
649
- {
650
- ...getPieProps({
651
- className: "ui-donut-chart__donut",
652
- labelClassName: "ui-donut-chart__label",
653
- labelLineClassName: "ui-donut-chart__label-line"
654
- }),
655
- children: cells
656
- }
657
- ),
658
- withLegend ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
659
- import_recharts.Legend,
660
- {
661
- content: ({ payload }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
662
- ChartLegend,
663
- {
664
- className: "ui-donut-chart__legend",
665
- payload,
666
- onHighlight: setHighlightedArea,
667
- ...computedLegendProps
668
- }
669
- ),
670
- ...getLegendProps()
671
- }
672
- ) : null,
673
- withTooltip ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
674
- import_recharts.Tooltip,
675
- {
676
- content: ({ label, payload }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
677
- ChartTooltip,
678
- {
679
- className: "ui-donut-chart__tooltip",
680
- label,
681
- payload: tooltipDataSource === "segment" ? payload : data,
682
- valueFormatter,
683
- unit,
684
- ...computedTooltipProps
685
- }
686
- ),
687
- ...getTooltipProps()
688
- }
689
- ) : null
690
- ]
691
- }
692
- )
693
- }
694
- )
695
- }
696
- ) });
697
- });
698
- // Annotate the CommonJS export names for ESM import in node:
699
- 0 && (module.exports = {
700
- DonutChart
701
- });
702
- //# sourceMappingURL=donut-chart.js.map