@yamada-ui/charts 1.1.2 → 1.1.4-dev-20240508155232

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/dist/area-chart-gradient.d.mts +11 -0
  2. package/dist/area-chart-gradient.d.ts +11 -0
  3. package/dist/area-chart-gradient.js +47 -0
  4. package/dist/area-chart-gradient.js.map +1 -0
  5. package/dist/area-chart-gradient.mjs +8 -0
  6. package/dist/area-chart-gradient.mjs.map +1 -0
  7. package/dist/area-chart-split.d.mts +10 -0
  8. package/dist/area-chart-split.d.ts +10 -0
  9. package/dist/area-chart-split.js +52 -0
  10. package/dist/area-chart-split.js.map +1 -0
  11. package/dist/area-chart-split.mjs +8 -0
  12. package/dist/area-chart-split.mjs.map +1 -0
  13. package/dist/area-chart.d.mts +41 -0
  14. package/dist/area-chart.d.ts +41 -0
  15. package/dist/area-chart.js +1223 -0
  16. package/dist/area-chart.js.map +1 -0
  17. package/dist/area-chart.mjs +21 -0
  18. package/dist/area-chart.mjs.map +1 -0
  19. package/dist/bar-chart.d.mts +38 -0
  20. package/dist/bar-chart.d.ts +38 -0
  21. package/dist/bar-chart.js +1027 -0
  22. package/dist/bar-chart.js.map +1 -0
  23. package/dist/bar-chart.mjs +19 -0
  24. package/dist/bar-chart.mjs.map +1 -0
  25. package/dist/chart-legend.d.mts +12 -0
  26. package/dist/chart-legend.d.ts +12 -0
  27. package/dist/chart-legend.js +90 -0
  28. package/dist/chart-legend.js.map +1 -0
  29. package/dist/chart-legend.mjs +11 -0
  30. package/dist/chart-legend.mjs.map +1 -0
  31. package/dist/chart-tooltip.d.mts +12 -0
  32. package/dist/chart-tooltip.d.ts +12 -0
  33. package/dist/chart-tooltip.js +121 -0
  34. package/dist/chart-tooltip.js.map +1 -0
  35. package/dist/chart-tooltip.mjs +11 -0
  36. package/dist/chart-tooltip.mjs.map +1 -0
  37. package/dist/chart-utils.d.mts +9 -0
  38. package/dist/chart-utils.d.ts +9 -0
  39. package/dist/chart-utils.js +45 -0
  40. package/dist/chart-utils.js.map +1 -0
  41. package/dist/chart-utils.mjs +10 -0
  42. package/dist/chart-utils.mjs.map +1 -0
  43. package/dist/chart.types.d.mts +78 -0
  44. package/dist/chart.types.d.ts +78 -0
  45. package/dist/chart.types.js +20 -0
  46. package/dist/chart.types.js.map +1 -0
  47. package/dist/chart.types.mjs +2 -0
  48. package/dist/chart.types.mjs.map +1 -0
  49. package/dist/chunk-4WX5YS7M.mjs +179 -0
  50. package/dist/chunk-4WX5YS7M.mjs.map +1 -0
  51. package/dist/chunk-5TVYPA64.mjs +256 -0
  52. package/dist/chunk-5TVYPA64.mjs.map +1 -0
  53. package/dist/chunk-BPR7YL3O.mjs +179 -0
  54. package/dist/chunk-BPR7YL3O.mjs.map +1 -0
  55. package/dist/chunk-E2I2XAZ6.mjs +232 -0
  56. package/dist/chunk-E2I2XAZ6.mjs.map +1 -0
  57. package/dist/chunk-HDOYOHLA.mjs +326 -0
  58. package/dist/chunk-HDOYOHLA.mjs.map +1 -0
  59. package/dist/chunk-KNAADLWO.mjs +225 -0
  60. package/dist/chunk-KNAADLWO.mjs.map +1 -0
  61. package/dist/chunk-KT4YOMM4.mjs +344 -0
  62. package/dist/chunk-KT4YOMM4.mjs.map +1 -0
  63. package/dist/chunk-LBC2B6UX.mjs +84 -0
  64. package/dist/chunk-LBC2B6UX.mjs.map +1 -0
  65. package/dist/chunk-LGMALZCN.mjs +42 -0
  66. package/dist/chunk-LGMALZCN.mjs.map +1 -0
  67. package/dist/chunk-LHI57S6P.mjs +215 -0
  68. package/dist/chunk-LHI57S6P.mjs.map +1 -0
  69. package/dist/chunk-LM2DQK2P.mjs +33 -0
  70. package/dist/chunk-LM2DQK2P.mjs.map +1 -0
  71. package/dist/chunk-MSIOYYWR.mjs +24 -0
  72. package/dist/chunk-MSIOYYWR.mjs.map +1 -0
  73. package/dist/chunk-MWPICUEW.mjs +56 -0
  74. package/dist/chunk-MWPICUEW.mjs.map +1 -0
  75. package/dist/chunk-NEGDEVRX.mjs +53 -0
  76. package/dist/chunk-NEGDEVRX.mjs.map +1 -0
  77. package/dist/chunk-OSNFBRHL.mjs +474 -0
  78. package/dist/chunk-OSNFBRHL.mjs.map +1 -0
  79. package/dist/chunk-OW7SOTEF.mjs +206 -0
  80. package/dist/chunk-OW7SOTEF.mjs.map +1 -0
  81. package/dist/chunk-P7AFSM5W.mjs +114 -0
  82. package/dist/chunk-P7AFSM5W.mjs.map +1 -0
  83. package/dist/chunk-PNE3JG54.mjs +29 -0
  84. package/dist/chunk-PNE3JG54.mjs.map +1 -0
  85. package/dist/chunk-QL3DB7OJ.mjs +21 -0
  86. package/dist/chunk-QL3DB7OJ.mjs.map +1 -0
  87. package/dist/chunk-QZ5OXZ6Z.mjs +251 -0
  88. package/dist/chunk-QZ5OXZ6Z.mjs.map +1 -0
  89. package/dist/chunk-RN6PXJAD.mjs +47 -0
  90. package/dist/chunk-RN6PXJAD.mjs.map +1 -0
  91. package/dist/chunk-STBYRLC5.mjs +208 -0
  92. package/dist/chunk-STBYRLC5.mjs.map +1 -0
  93. package/dist/chunk-XIFDRM7J.mjs +56 -0
  94. package/dist/chunk-XIFDRM7J.mjs.map +1 -0
  95. package/dist/donut-chart.d.mts +31 -0
  96. package/dist/donut-chart.d.ts +31 -0
  97. package/dist/donut-chart.js +702 -0
  98. package/dist/donut-chart.js.map +1 -0
  99. package/dist/donut-chart.mjs +16 -0
  100. package/dist/donut-chart.mjs.map +1 -0
  101. package/dist/index.d.mts +26 -0
  102. package/dist/index.d.ts +26 -0
  103. package/dist/index.js +3228 -0
  104. package/dist/index.js.map +1 -0
  105. package/dist/index.mjs +45 -0
  106. package/dist/index.mjs.map +1 -0
  107. package/dist/line-chart.d.mts +38 -0
  108. package/dist/line-chart.d.ts +38 -0
  109. package/dist/line-chart.js +1088 -0
  110. package/dist/line-chart.js.map +1 -0
  111. package/dist/line-chart.mjs +19 -0
  112. package/dist/line-chart.mjs.map +1 -0
  113. package/dist/pie-chart.d.mts +49 -0
  114. package/dist/pie-chart.d.ts +49 -0
  115. package/dist/pie-chart.js +702 -0
  116. package/dist/pie-chart.js.map +1 -0
  117. package/dist/pie-chart.mjs +16 -0
  118. package/dist/pie-chart.mjs.map +1 -0
  119. package/dist/radar-chart.d.mts +57 -0
  120. package/dist/radar-chart.d.ts +57 -0
  121. package/dist/radar-chart.js +918 -0
  122. package/dist/radar-chart.js.map +1 -0
  123. package/dist/radar-chart.mjs +16 -0
  124. package/dist/radar-chart.mjs.map +1 -0
  125. package/dist/rechart-properties.d.mts +26 -0
  126. package/dist/rechart-properties.d.ts +26 -0
  127. package/dist/rechart-properties.js +517 -0
  128. package/dist/rechart-properties.js.map +1 -0
  129. package/dist/rechart-properties.mjs +48 -0
  130. package/dist/rechart-properties.mjs.map +1 -0
  131. package/dist/use-area-chart.d.mts +123 -0
  132. package/dist/use-area-chart.d.ts +123 -0
  133. package/dist/use-area-chart.js +420 -0
  134. package/dist/use-area-chart.js.map +1 -0
  135. package/dist/use-area-chart.mjs +10 -0
  136. package/dist/use-area-chart.mjs.map +1 -0
  137. package/dist/use-bar-chart.d.mts +73 -0
  138. package/dist/use-bar-chart.d.ts +73 -0
  139. package/dist/use-bar-chart.js +290 -0
  140. package/dist/use-bar-chart.js.map +1 -0
  141. package/dist/use-bar-chart.mjs +10 -0
  142. package/dist/use-bar-chart.mjs.map +1 -0
  143. package/dist/use-chart-axis.d.mts +73 -0
  144. package/dist/use-chart-axis.d.ts +73 -0
  145. package/dist/use-chart-axis.js +227 -0
  146. package/dist/use-chart-axis.js.map +1 -0
  147. package/dist/use-chart-axis.mjs +10 -0
  148. package/dist/use-chart-axis.mjs.map +1 -0
  149. package/dist/use-chart-grid.d.mts +32 -0
  150. package/dist/use-chart-grid.d.ts +32 -0
  151. package/dist/use-chart-grid.js +92 -0
  152. package/dist/use-chart-grid.js.map +1 -0
  153. package/dist/use-chart-grid.mjs +10 -0
  154. package/dist/use-chart-grid.mjs.map +1 -0
  155. package/dist/use-chart-legend.d.mts +18 -0
  156. package/dist/use-chart-legend.d.ts +18 -0
  157. package/dist/use-chart-legend.js +81 -0
  158. package/dist/use-chart-legend.js.map +1 -0
  159. package/dist/use-chart-legend.mjs +9 -0
  160. package/dist/use-chart-legend.mjs.map +1 -0
  161. package/dist/use-chart-reference-line.d.mts +22 -0
  162. package/dist/use-chart-reference-line.d.ts +22 -0
  163. package/dist/use-chart-reference-line.js +105 -0
  164. package/dist/use-chart-reference-line.js.map +1 -0
  165. package/dist/use-chart-reference-line.mjs +10 -0
  166. package/dist/use-chart-reference-line.mjs.map +1 -0
  167. package/dist/use-chart-tooltip.d.mts +27 -0
  168. package/dist/use-chart-tooltip.d.ts +27 -0
  169. package/dist/use-chart-tooltip.js +100 -0
  170. package/dist/use-chart-tooltip.js.map +1 -0
  171. package/dist/use-chart-tooltip.mjs +10 -0
  172. package/dist/use-chart-tooltip.mjs.map +1 -0
  173. package/dist/use-chart.d.mts +33 -0
  174. package/dist/use-chart.d.ts +33 -0
  175. package/dist/use-chart.js +104 -0
  176. package/dist/use-chart.js.map +1 -0
  177. package/dist/use-chart.mjs +18 -0
  178. package/dist/use-chart.mjs.map +1 -0
  179. package/dist/use-line-chart.d.mts +97 -0
  180. package/dist/use-line-chart.d.ts +97 -0
  181. package/dist/use-line-chart.js +344 -0
  182. package/dist/use-line-chart.js.map +1 -0
  183. package/dist/use-line-chart.mjs +10 -0
  184. package/dist/use-line-chart.mjs.map +1 -0
  185. package/dist/use-pie-chart.d.mts +112 -0
  186. package/dist/use-pie-chart.d.ts +112 -0
  187. package/dist/use-pie-chart.js +282 -0
  188. package/dist/use-pie-chart.js.map +1 -0
  189. package/dist/use-pie-chart.mjs +10 -0
  190. package/dist/use-pie-chart.mjs.map +1 -0
  191. package/dist/use-radar-chart.d.mts +105 -0
  192. package/dist/use-radar-chart.d.ts +105 -0
  193. package/dist/use-radar-chart.js +473 -0
  194. package/dist/use-radar-chart.js.map +1 -0
  195. package/dist/use-radar-chart.mjs +10 -0
  196. package/dist/use-radar-chart.mjs.map +1 -0
  197. package/package.json +2 -5
@@ -0,0 +1,123 @@
1
+ import * as react from 'react';
2
+ import * as _yamada_ui_core from '@yamada-ui/core';
3
+ import { CSSUIObject } from '@yamada-ui/core';
4
+ import * as _yamada_ui_utils from '@yamada-ui/utils';
5
+ import { Dict } from '@yamada-ui/utils';
6
+ import * as recharts_types_chart_generateCategoricalChart from 'recharts/types/chart/generateCategoricalChart';
7
+ import * as Recharts from 'recharts';
8
+ import { AreaGradientProps } from './area-chart-gradient.mjs';
9
+ import { AreaSplitProps } from './area-chart-split.mjs';
10
+ import { AreaProps, AreaChartType, AreaChartProps, ChartLayoutType, ChartCurveType, ReferenceLineProps, ChartPropGetter, RequiredChartPropGetter } from './chart.types.mjs';
11
+ import 'react/jsx-runtime';
12
+
13
+ type UseAreaChartOptions = {
14
+ /**
15
+ * Chart data.
16
+ */
17
+ data: Dict[];
18
+ /**
19
+ * An array of objects with `dataKey` and `color` keys. Determines which data should be consumed from the `data` array.
20
+ */
21
+ series: AreaProps[];
22
+ /**
23
+ * Props for the areas.
24
+ */
25
+ areaProps?: Partial<AreaProps>;
26
+ /**
27
+ * Controls how chart areas are positioned relative to each other.
28
+ *
29
+ * @default `default`
30
+ */
31
+ type?: AreaChartType;
32
+ /**
33
+ * Props passed down to recharts `AreaChart` component.
34
+ */
35
+ chartProps?: AreaChartProps;
36
+ /**
37
+ * If any two categorical charts have the same syncId,
38
+ * these two charts can sync the position tooltip, and the startIndex, endIndex of Brush.
39
+ */
40
+ syncId?: number | string;
41
+ /**
42
+ * Chart orientation.
43
+ *
44
+ * @default 'horizontal'
45
+ */
46
+ layoutType?: ChartLayoutType;
47
+ /**
48
+ * Determines whether the chart area should be represented with a gradient instead of the solid color.
49
+ */
50
+ withGradient?: boolean;
51
+ /**
52
+ * Determines whether dots should be displayed.
53
+ *
54
+ * @default true
55
+ */
56
+ withDots?: boolean;
57
+ /**
58
+ * Determines whether activeDots should be displayed.
59
+ *
60
+ * @default true
61
+ */
62
+ withActiveDots?: boolean;
63
+ /**
64
+ * Type of the curve.
65
+ *
66
+ * @default `monotone`
67
+ */
68
+ curveType?: ChartCurveType;
69
+ /**
70
+ * Stroke width for the chart areas.
71
+ *
72
+ * @default 2
73
+ */
74
+ strokeWidth?: number;
75
+ /**
76
+ * Determines whether points with `null` values should be connected.
77
+ *
78
+ * @default true
79
+ */
80
+ connectNulls?: boolean;
81
+ /**
82
+ * A tuple of colors used when `type="split"` is set, ignored in all other cases.
83
+ *
84
+ * @default '["red.400", "green.400"]'
85
+ */
86
+ splitColors?: [string, string];
87
+ /**
88
+ * Offset for the split gradient. By default, value is inferred from `data` and `series` if possible.
89
+ * Must be generated from the data array with `getSplitOffset` function.
90
+ */
91
+ splitOffset?: number;
92
+ /**
93
+ * Reference lines that should be displayed on the chart.
94
+ */
95
+ referenceLineProps?: ReferenceLineProps[];
96
+ /**
97
+ * Controls fill opacity of all areas.
98
+ *
99
+ * @default 0.4
100
+ */
101
+ fillOpacity?: number | [number, number];
102
+ };
103
+ type UseAreaChartProps = UseAreaChartOptions & {
104
+ styles: Dict<CSSUIObject>;
105
+ };
106
+ declare const useAreaChart: ({ data, series, type, layoutType, withGradient: withGradientProp, withDots, withActiveDots, curveType, strokeWidth, connectNulls, fillOpacity, splitColors, splitOffset, referenceLineProps, syncId, styles, ...rest }: UseAreaChartProps) => {
107
+ getAreaChartProps: ChartPropGetter<"div", recharts_types_chart_generateCategoricalChart.CategoricalChartProps, recharts_types_chart_generateCategoricalChart.CategoricalChartProps>;
108
+ getAreaSplitProps: ChartPropGetter<"div", Partial<AreaSplitProps>, AreaSplitProps>;
109
+ getAreaProps: RequiredChartPropGetter<"div", {
110
+ index: number;
111
+ }, Omit<Recharts.AreaProps, "ref">>;
112
+ getAreaGradientProps: ChartPropGetter<"div", Partial<AreaGradientProps>, AreaGradientProps>;
113
+ areaVars: {
114
+ __prefix?: string | undefined;
115
+ name: string;
116
+ token?: "colors" | "transitionDuration" | "transitionProperty" | "animations" | "blurs" | "borders" | "breakpoints" | "fonts" | "fontSizes" | "fontWeights" | "gradients" | "layerStyles" | "letterSpacings" | "lineHeights" | "radii" | "shadows" | "sizes" | "spaces" | "textStyles" | "transitionEasing" | "zIndices" | undefined;
117
+ value?: (number | _yamada_ui_utils.StringLiteral | Partial<Record<(string & {}) | "base" | "sm" | "md" | "lg" | "xl" | "2xl", number | _yamada_ui_utils.StringLiteral>> | _yamada_ui_core.ColorModeArray<number | _yamada_ui_utils.StringLiteral>) | undefined;
118
+ }[];
119
+ setHighlightedArea: react.Dispatch<react.SetStateAction<string | null>>;
120
+ };
121
+ type UseAreaChartReturn = ReturnType<typeof useAreaChart>;
122
+
123
+ export { type UseAreaChartOptions, type UseAreaChartProps, type UseAreaChartReturn, useAreaChart };
@@ -0,0 +1,123 @@
1
+ import * as react from 'react';
2
+ import * as _yamada_ui_core from '@yamada-ui/core';
3
+ import { CSSUIObject } from '@yamada-ui/core';
4
+ import * as _yamada_ui_utils from '@yamada-ui/utils';
5
+ import { Dict } from '@yamada-ui/utils';
6
+ import * as recharts_types_chart_generateCategoricalChart from 'recharts/types/chart/generateCategoricalChart';
7
+ import * as Recharts from 'recharts';
8
+ import { AreaGradientProps } from './area-chart-gradient.js';
9
+ import { AreaSplitProps } from './area-chart-split.js';
10
+ import { AreaProps, AreaChartType, AreaChartProps, ChartLayoutType, ChartCurveType, ReferenceLineProps, ChartPropGetter, RequiredChartPropGetter } from './chart.types.js';
11
+ import 'react/jsx-runtime';
12
+
13
+ type UseAreaChartOptions = {
14
+ /**
15
+ * Chart data.
16
+ */
17
+ data: Dict[];
18
+ /**
19
+ * An array of objects with `dataKey` and `color` keys. Determines which data should be consumed from the `data` array.
20
+ */
21
+ series: AreaProps[];
22
+ /**
23
+ * Props for the areas.
24
+ */
25
+ areaProps?: Partial<AreaProps>;
26
+ /**
27
+ * Controls how chart areas are positioned relative to each other.
28
+ *
29
+ * @default `default`
30
+ */
31
+ type?: AreaChartType;
32
+ /**
33
+ * Props passed down to recharts `AreaChart` component.
34
+ */
35
+ chartProps?: AreaChartProps;
36
+ /**
37
+ * If any two categorical charts have the same syncId,
38
+ * these two charts can sync the position tooltip, and the startIndex, endIndex of Brush.
39
+ */
40
+ syncId?: number | string;
41
+ /**
42
+ * Chart orientation.
43
+ *
44
+ * @default 'horizontal'
45
+ */
46
+ layoutType?: ChartLayoutType;
47
+ /**
48
+ * Determines whether the chart area should be represented with a gradient instead of the solid color.
49
+ */
50
+ withGradient?: boolean;
51
+ /**
52
+ * Determines whether dots should be displayed.
53
+ *
54
+ * @default true
55
+ */
56
+ withDots?: boolean;
57
+ /**
58
+ * Determines whether activeDots should be displayed.
59
+ *
60
+ * @default true
61
+ */
62
+ withActiveDots?: boolean;
63
+ /**
64
+ * Type of the curve.
65
+ *
66
+ * @default `monotone`
67
+ */
68
+ curveType?: ChartCurveType;
69
+ /**
70
+ * Stroke width for the chart areas.
71
+ *
72
+ * @default 2
73
+ */
74
+ strokeWidth?: number;
75
+ /**
76
+ * Determines whether points with `null` values should be connected.
77
+ *
78
+ * @default true
79
+ */
80
+ connectNulls?: boolean;
81
+ /**
82
+ * A tuple of colors used when `type="split"` is set, ignored in all other cases.
83
+ *
84
+ * @default '["red.400", "green.400"]'
85
+ */
86
+ splitColors?: [string, string];
87
+ /**
88
+ * Offset for the split gradient. By default, value is inferred from `data` and `series` if possible.
89
+ * Must be generated from the data array with `getSplitOffset` function.
90
+ */
91
+ splitOffset?: number;
92
+ /**
93
+ * Reference lines that should be displayed on the chart.
94
+ */
95
+ referenceLineProps?: ReferenceLineProps[];
96
+ /**
97
+ * Controls fill opacity of all areas.
98
+ *
99
+ * @default 0.4
100
+ */
101
+ fillOpacity?: number | [number, number];
102
+ };
103
+ type UseAreaChartProps = UseAreaChartOptions & {
104
+ styles: Dict<CSSUIObject>;
105
+ };
106
+ declare const useAreaChart: ({ data, series, type, layoutType, withGradient: withGradientProp, withDots, withActiveDots, curveType, strokeWidth, connectNulls, fillOpacity, splitColors, splitOffset, referenceLineProps, syncId, styles, ...rest }: UseAreaChartProps) => {
107
+ getAreaChartProps: ChartPropGetter<"div", recharts_types_chart_generateCategoricalChart.CategoricalChartProps, recharts_types_chart_generateCategoricalChart.CategoricalChartProps>;
108
+ getAreaSplitProps: ChartPropGetter<"div", Partial<AreaSplitProps>, AreaSplitProps>;
109
+ getAreaProps: RequiredChartPropGetter<"div", {
110
+ index: number;
111
+ }, Omit<Recharts.AreaProps, "ref">>;
112
+ getAreaGradientProps: ChartPropGetter<"div", Partial<AreaGradientProps>, AreaGradientProps>;
113
+ areaVars: {
114
+ __prefix?: string | undefined;
115
+ name: string;
116
+ token?: "colors" | "transitionDuration" | "transitionProperty" | "animations" | "blurs" | "borders" | "breakpoints" | "fonts" | "fontSizes" | "fontWeights" | "gradients" | "layerStyles" | "letterSpacings" | "lineHeights" | "radii" | "shadows" | "sizes" | "spaces" | "textStyles" | "transitionEasing" | "zIndices" | undefined;
117
+ value?: (number | _yamada_ui_utils.StringLiteral | Partial<Record<(string & {}) | "base" | "sm" | "md" | "lg" | "xl" | "2xl", number | _yamada_ui_utils.StringLiteral>> | _yamada_ui_core.ColorModeArray<number | _yamada_ui_utils.StringLiteral>) | undefined;
118
+ }[];
119
+ setHighlightedArea: react.Dispatch<react.SetStateAction<string | null>>;
120
+ };
121
+ type UseAreaChartReturn = ReturnType<typeof useAreaChart>;
122
+
123
+ export { type UseAreaChartOptions, type UseAreaChartProps, type UseAreaChartReturn, useAreaChart };
@@ -0,0 +1,420 @@
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/use-area-chart.ts
22
+ var use_area_chart_exports = {};
23
+ __export(use_area_chart_exports, {
24
+ useAreaChart: () => useAreaChart
25
+ });
26
+ module.exports = __toCommonJS(use_area_chart_exports);
27
+ var import_core2 = require("@yamada-ui/core");
28
+ var import_utils2 = require("@yamada-ui/utils");
29
+ var import_react = require("react");
30
+
31
+ // src/chart-utils.ts
32
+ var import_core = require("@yamada-ui/core");
33
+ var import_utils = require("@yamada-ui/utils");
34
+ var getClassName = (...styles) => (theme) => (0, import_utils.cx)(
35
+ ...styles.map(
36
+ (style) => (0, import_utils.isString)(style) ? style : (0, import_core.getCSS)(style)(theme)
37
+ )
38
+ );
39
+ var getComponentProps = ([obj, keys], ...props) => (theme, isContain) => {
40
+ const [pickedProps, omittedProps] = (0, import_utils.splitObject)(obj, keys);
41
+ const className = getClassName(...props, omittedProps)(theme);
42
+ return !isContain ? [pickedProps, className] : { ...pickedProps, className };
43
+ };
44
+
45
+ // src/rechart-properties.ts
46
+ var areaChartProperties = [
47
+ "layout",
48
+ "syncId",
49
+ "syncMethod",
50
+ "width",
51
+ "height",
52
+ "data",
53
+ "margin",
54
+ "stackOffset",
55
+ "onClick",
56
+ "onMouseEnter",
57
+ "onMouseMove",
58
+ "onMouseLeave"
59
+ ];
60
+ var areaProperties = [
61
+ "type",
62
+ "dataKey",
63
+ "xAxisId",
64
+ "yAxisId",
65
+ "legendType",
66
+ "dot",
67
+ "activeDot",
68
+ "label",
69
+ "stroke",
70
+ "strokeWidth",
71
+ "layout",
72
+ "baseLine",
73
+ "points",
74
+ "stackId",
75
+ "connectNulls",
76
+ "unit",
77
+ "name",
78
+ "isAnimationActive",
79
+ "animationBegin",
80
+ "animationDuration",
81
+ "animationEasing",
82
+ "id",
83
+ "onAnimationStart",
84
+ "onAnimationEnd",
85
+ "onClick",
86
+ "onMouseDown",
87
+ "onMouseUp",
88
+ "onMouseMove",
89
+ "onMouseOver",
90
+ "onMouseOut",
91
+ "onMouseEnter",
92
+ "onMouseLeave"
93
+ ];
94
+ var dotProperties = [
95
+ "cx",
96
+ "cy",
97
+ "r",
98
+ "onClick",
99
+ "onMouseDown",
100
+ "onMouseUp",
101
+ "onMouseMove",
102
+ "onMouseOver",
103
+ "onMouseOut",
104
+ "onMouseEnter",
105
+ "onMouseLeave"
106
+ ];
107
+
108
+ // src/use-area-chart.ts
109
+ var useAreaChart = ({
110
+ data,
111
+ series,
112
+ type,
113
+ layoutType = "horizontal",
114
+ withGradient: withGradientProp,
115
+ withDots = true,
116
+ withActiveDots = true,
117
+ curveType = "monotone",
118
+ strokeWidth = 2,
119
+ connectNulls = true,
120
+ fillOpacity = 0.4,
121
+ splitColors = ["#ee6a5d", "#5fce7d"],
122
+ splitOffset,
123
+ referenceLineProps,
124
+ syncId,
125
+ styles,
126
+ ...rest
127
+ }) => {
128
+ var _a;
129
+ const uuid = (0, import_react.useId)();
130
+ const { theme } = (0, import_core2.useTheme)();
131
+ const [highlightedArea, setHighlightedArea] = (0, import_react.useState)(null);
132
+ const splitId = `${uuid}-split`;
133
+ const stacked = type === "stacked" || type === "percent";
134
+ const withGradient = typeof withGradientProp === "boolean" ? withGradientProp : type === "default";
135
+ const shouldHighlight = highlightedArea !== null;
136
+ const {
137
+ dot = {},
138
+ activeDot = {},
139
+ dimDot,
140
+ dimArea,
141
+ ...computedAreaProps
142
+ } = (_a = rest.areaProps) != null ? _a : {};
143
+ const areaColors = (0, import_react.useMemo)(
144
+ () => series.map(({ color }, index) => ({
145
+ __prefix: "ui",
146
+ name: `area-${index}`,
147
+ token: "colors",
148
+ value: color != null ? color : "transparent"
149
+ })),
150
+ [series]
151
+ );
152
+ const areaSplitColors = (0, import_react.useMemo)(
153
+ () => splitColors.map((color, index) => ({
154
+ __prefix: "ui",
155
+ name: `area-split-${index}`,
156
+ token: "colors",
157
+ value: color != null ? color : "transparent"
158
+ })),
159
+ [splitColors]
160
+ );
161
+ const referenceLineColors = (0, import_react.useMemo)(
162
+ () => referenceLineProps ? referenceLineProps.map(({ color }, index) => ({
163
+ __prefix: "ui",
164
+ name: `reference-line-${index}`,
165
+ token: "colors",
166
+ value: color != null ? color : "transparent"
167
+ })) : [],
168
+ [referenceLineProps]
169
+ );
170
+ const areaVars = (0, import_react.useMemo)(() => {
171
+ return [
172
+ ...areaColors,
173
+ ...areaSplitColors,
174
+ ...referenceLineColors,
175
+ { __prefix: "ui", name: "fill-opacity", value: fillOpacity }
176
+ ];
177
+ }, [areaColors, areaSplitColors, referenceLineColors, fillOpacity]);
178
+ const [chartProps, areaChartClassName] = (0, import_react.useMemo)(
179
+ () => {
180
+ var _a2;
181
+ return getComponentProps(
182
+ [(_a2 = rest.chartProps) != null ? _a2 : {}, areaChartProperties],
183
+ styles.chart
184
+ )(theme);
185
+ },
186
+ [rest.chartProps, styles.chart, theme]
187
+ );
188
+ const [areaProps, areaClassName] = (0, import_react.useMemo)(() => {
189
+ const resolvedAreaProps = {
190
+ fillOpacity: 1,
191
+ strokeOpacity: 1,
192
+ ...computedAreaProps
193
+ };
194
+ return getComponentProps(
195
+ [resolvedAreaProps, areaProperties],
196
+ styles.area
197
+ )(theme);
198
+ }, [computedAreaProps, styles.area, theme]);
199
+ const [dimAreaProps, dimAreaClassName] = (0, import_react.useMemo)(() => {
200
+ const resolvedDimArea = {
201
+ fillOpacity: 0,
202
+ strokeOpacity: 0.3,
203
+ ...dimArea
204
+ };
205
+ return getComponentProps([resolvedDimArea, areaProperties])(
206
+ theme
207
+ );
208
+ }, [dimArea, theme]);
209
+ const [dotProps, dotClassName] = (0, import_react.useMemo)(() => {
210
+ const resolvedDot = { fillOpacity: 1, strokeWidth: 2, ...dot };
211
+ return getComponentProps(
212
+ [resolvedDot, dotProperties],
213
+ styles.dot
214
+ )(theme);
215
+ }, [dot, styles.dot, theme]);
216
+ const [activeDotProps, activeDotClassName] = (0, import_react.useMemo)(
217
+ () => getComponentProps(
218
+ [activeDot, dotProperties],
219
+ styles.activeDot
220
+ )(theme),
221
+ [activeDot, styles.activeDot, theme]
222
+ );
223
+ const [dimDotProps, dimDotClassName] = (0, import_react.useMemo)(() => {
224
+ const resolvedDimDot = { fillOpacity: 0, strokeOpacity: 0, ...dimDot };
225
+ return getComponentProps([resolvedDimDot, dotProperties])(
226
+ theme
227
+ );
228
+ }, [dimDot, theme]);
229
+ const defaultSplitOffset = (0, import_react.useMemo)(() => {
230
+ if (series.length === 1) {
231
+ const dataKey = series[0].dataKey;
232
+ const dataMax = Math.max(...data.map((item) => item[dataKey]));
233
+ const dataMin = Math.min(...data.map((item) => item[dataKey]));
234
+ if (dataMax <= 0)
235
+ return 0;
236
+ if (dataMin >= 0)
237
+ return 1;
238
+ return dataMax / (dataMax - dataMin);
239
+ }
240
+ return 0.5;
241
+ }, [data, series]);
242
+ const areaPropsList = (0, import_react.useMemo)(
243
+ () => series.map((props, index) => {
244
+ const {
245
+ dataKey,
246
+ dot: dot2 = {},
247
+ activeDot: activeDot2 = {},
248
+ dimDot: dimDot2 = {},
249
+ dimArea: dimArea2 = {},
250
+ strokeDasharray,
251
+ ...computedProps
252
+ } = props;
253
+ const id = `${uuid}-${dataKey}`;
254
+ const color = `var(--ui-area-${index})`;
255
+ const dimmed = shouldHighlight && highlightedArea !== dataKey;
256
+ const computedDimArea = { ...dimAreaProps, ...dimArea2 };
257
+ const resolvedProps = {
258
+ ...areaProps,
259
+ ...computedProps,
260
+ ...dimmed ? computedDimArea : {}
261
+ };
262
+ const rest2 = getComponentProps(
263
+ [resolvedProps, areaProperties],
264
+ areaClassName,
265
+ dimmed ? dimAreaClassName : void 0
266
+ )(theme, true);
267
+ let resolvedActiveDot;
268
+ if (withActiveDots) {
269
+ const computedActiveDot = { ...activeDotProps, ...activeDot2 };
270
+ const [rest3, className] = getComponentProps(
271
+ [computedActiveDot, dotProperties],
272
+ activeDotClassName
273
+ )(theme);
274
+ resolvedActiveDot = {
275
+ className: (0, import_utils2.cx)("ui-area-chart__active-dot", className),
276
+ stroke: color,
277
+ r: 4,
278
+ ...rest3
279
+ };
280
+ } else {
281
+ resolvedActiveDot = false;
282
+ }
283
+ let resolvedDot;
284
+ if (withDots) {
285
+ const computedDimDot = { ...dimDotProps, ...dimDot2 };
286
+ const computedDot = {
287
+ ...dotProps,
288
+ ...dot2,
289
+ ...dimmed ? computedDimDot : {}
290
+ };
291
+ const [rest3, className] = getComponentProps(
292
+ [computedDot, dotProperties],
293
+ dotClassName,
294
+ dimmed ? dimDotClassName : void 0
295
+ )(theme);
296
+ resolvedDot = {
297
+ className: (0, import_utils2.cx)("ui-area-chart__dot", className),
298
+ fill: color,
299
+ r: 4,
300
+ ...rest3
301
+ };
302
+ } else {
303
+ resolvedDot = false;
304
+ }
305
+ return {
306
+ ...rest2,
307
+ id,
308
+ color,
309
+ strokeDasharray,
310
+ dataKey,
311
+ activeDot: resolvedActiveDot,
312
+ dot: resolvedDot
313
+ };
314
+ }),
315
+ [
316
+ series,
317
+ uuid,
318
+ shouldHighlight,
319
+ highlightedArea,
320
+ dimAreaProps,
321
+ dimDotProps,
322
+ areaProps,
323
+ areaClassName,
324
+ dimAreaClassName,
325
+ theme,
326
+ withActiveDots,
327
+ withDots,
328
+ activeDotProps,
329
+ activeDotClassName,
330
+ dotProps,
331
+ dotClassName,
332
+ dimDotClassName
333
+ ]
334
+ );
335
+ const getAreaChartProps = (0, import_react.useCallback)(
336
+ ({ className, ...props } = {}, ref = null) => ({
337
+ ref,
338
+ className: (0, import_utils2.cx)(className, areaChartClassName),
339
+ data,
340
+ stackOffset: type === "percent" ? "expand" : void 0,
341
+ layout: layoutType,
342
+ syncId,
343
+ ...props,
344
+ ...chartProps
345
+ }),
346
+ [areaChartClassName, data, type, layoutType, syncId, chartProps]
347
+ );
348
+ const getAreaSplitProps = (0, import_react.useCallback)(
349
+ (props = {}) => ({
350
+ id: splitId,
351
+ offset: splitOffset != null ? splitOffset : defaultSplitOffset,
352
+ fillOpacity: "var(--ui-fill-opacity)",
353
+ ...props
354
+ }),
355
+ [defaultSplitOffset, splitId, splitOffset]
356
+ );
357
+ const getAreaProps = (0, import_react.useCallback)(
358
+ ({ index, className: classNameProp, ...props }, ref = null) => {
359
+ const {
360
+ id,
361
+ color,
362
+ className,
363
+ dataKey,
364
+ strokeDasharray,
365
+ activeDot: activeDot2,
366
+ dot: dot2,
367
+ ...rest2
368
+ } = areaPropsList[index];
369
+ return {
370
+ ref,
371
+ className: (0, import_utils2.cx)(classNameProp, className),
372
+ id,
373
+ activeDot: activeDot2,
374
+ dot: dot2,
375
+ name: dataKey,
376
+ type: curveType,
377
+ dataKey,
378
+ fill: type === "split" ? `url(#${splitId})` : `url(#${id})`,
379
+ strokeWidth,
380
+ stroke: color,
381
+ isAnimationActive: false,
382
+ connectNulls,
383
+ stackId: stacked ? "stack" : void 0,
384
+ strokeDasharray,
385
+ ...props,
386
+ ...rest2
387
+ };
388
+ },
389
+ [
390
+ areaPropsList,
391
+ connectNulls,
392
+ curveType,
393
+ splitId,
394
+ stacked,
395
+ strokeWidth,
396
+ type
397
+ ]
398
+ );
399
+ const getAreaGradientProps = (0, import_react.useCallback)(
400
+ (props = {}) => ({
401
+ withGradient,
402
+ fillOpacity: "var(--ui-fill-opacity)",
403
+ ...props
404
+ }),
405
+ [withGradient]
406
+ );
407
+ return {
408
+ getAreaChartProps,
409
+ getAreaSplitProps,
410
+ getAreaProps,
411
+ getAreaGradientProps,
412
+ areaVars,
413
+ setHighlightedArea
414
+ };
415
+ };
416
+ // Annotate the CommonJS export names for ESM import in node:
417
+ 0 && (module.exports = {
418
+ useAreaChart
419
+ });
420
+ //# sourceMappingURL=use-area-chart.js.map