@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,68 @@
1
+ import * as react from 'react';
2
+ import * as recharts_types_chart_generateCategoricalChart from 'recharts/types/chart/generateCategoricalChart';
3
+ import * as _yamada_ui_core from '@yamada-ui/core';
4
+ import { CSSUIObject } from '@yamada-ui/core';
5
+ import * as _yamada_ui_utils from '@yamada-ui/utils';
6
+ import { Dict } from '@yamada-ui/utils';
7
+ import * as Recharts from 'recharts';
8
+ import { BarProps, BarChartType, ChartLayoutType, BarChartProps, ReferenceLineProps, RequiredChartPropGetter, ChartPropGetter } from './chart.types.mjs';
9
+
10
+ type UseBarChartOptions = {
11
+ /**
12
+ * Chart data.
13
+ */
14
+ data: Dict[];
15
+ /**
16
+ * An array of objects with `name` and `color` keys. Determines which data should be consumed from the `data` array.
17
+ */
18
+ series: BarProps[];
19
+ /**
20
+ * Props for the bars.
21
+ */
22
+ barProps?: Partial<BarProps>;
23
+ /**
24
+ * Controls how chart bars are positioned relative to each other.
25
+ *
26
+ * @default `default`
27
+ */
28
+ type?: BarChartType;
29
+ /**
30
+ * Chart orientation.
31
+ *
32
+ * @default 'horizontal'
33
+ */
34
+ layoutType?: ChartLayoutType;
35
+ /**
36
+ * Props passed down to recharts `BarChart` component.
37
+ */
38
+ barChartProps?: BarChartProps;
39
+ /**
40
+ * Reference lines that should be displayed on the chart.
41
+ */
42
+ referenceLineProps?: ReferenceLineProps[];
43
+ /**
44
+ * Controls fill opacity of all bars.
45
+ *
46
+ * @default 1
47
+ */
48
+ fillOpacity?: number | [number, number];
49
+ };
50
+ type UseBarChartProps = UseBarChartOptions & {
51
+ styles: Dict<CSSUIObject>;
52
+ };
53
+ declare const useBarChart: ({ data, series, type, layoutType, referenceLineProps, fillOpacity, styles, ...rest }: UseBarChartProps) => {
54
+ barVars: {
55
+ __prefix?: string | undefined;
56
+ name: string;
57
+ token?: "colors" | "transitionDuration" | "transitionProperty" | "animations" | "blurs" | "borders" | "breakpoints" | "fonts" | "fontSizes" | "fontWeights" | "gradients" | "layerStyles" | "letterSpacings" | "lineHeights" | "radii" | "shadows" | "sizes" | "spaces" | "textStyles" | "transitionEasing" | "zIndices" | undefined;
58
+ value?: (number | _yamada_ui_utils.StringLiteral | _yamada_ui_core.ResponsiveObject<number | _yamada_ui_utils.StringLiteral> | _yamada_ui_core.ColorModeArray<number | _yamada_ui_utils.StringLiteral>) | undefined;
59
+ }[];
60
+ getBarProps: RequiredChartPropGetter<"div", {
61
+ index: number;
62
+ }, Omit<Recharts.BarProps, "ref">>;
63
+ getBarChartProps: ChartPropGetter<"div", recharts_types_chart_generateCategoricalChart.CategoricalChartProps, recharts_types_chart_generateCategoricalChart.CategoricalChartProps>;
64
+ setHighlightedArea: react.Dispatch<react.SetStateAction<string | null>>;
65
+ };
66
+ type UseBarChartReturn = ReturnType<typeof useBarChart>;
67
+
68
+ export { type UseBarChartOptions, type UseBarChartProps, type UseBarChartReturn, useBarChart };
@@ -0,0 +1,68 @@
1
+ import * as react from 'react';
2
+ import * as recharts_types_chart_generateCategoricalChart from 'recharts/types/chart/generateCategoricalChart';
3
+ import * as _yamada_ui_core from '@yamada-ui/core';
4
+ import { CSSUIObject } from '@yamada-ui/core';
5
+ import * as _yamada_ui_utils from '@yamada-ui/utils';
6
+ import { Dict } from '@yamada-ui/utils';
7
+ import * as Recharts from 'recharts';
8
+ import { BarProps, BarChartType, ChartLayoutType, BarChartProps, ReferenceLineProps, RequiredChartPropGetter, ChartPropGetter } from './chart.types.js';
9
+
10
+ type UseBarChartOptions = {
11
+ /**
12
+ * Chart data.
13
+ */
14
+ data: Dict[];
15
+ /**
16
+ * An array of objects with `name` and `color` keys. Determines which data should be consumed from the `data` array.
17
+ */
18
+ series: BarProps[];
19
+ /**
20
+ * Props for the bars.
21
+ */
22
+ barProps?: Partial<BarProps>;
23
+ /**
24
+ * Controls how chart bars are positioned relative to each other.
25
+ *
26
+ * @default `default`
27
+ */
28
+ type?: BarChartType;
29
+ /**
30
+ * Chart orientation.
31
+ *
32
+ * @default 'horizontal'
33
+ */
34
+ layoutType?: ChartLayoutType;
35
+ /**
36
+ * Props passed down to recharts `BarChart` component.
37
+ */
38
+ barChartProps?: BarChartProps;
39
+ /**
40
+ * Reference lines that should be displayed on the chart.
41
+ */
42
+ referenceLineProps?: ReferenceLineProps[];
43
+ /**
44
+ * Controls fill opacity of all bars.
45
+ *
46
+ * @default 1
47
+ */
48
+ fillOpacity?: number | [number, number];
49
+ };
50
+ type UseBarChartProps = UseBarChartOptions & {
51
+ styles: Dict<CSSUIObject>;
52
+ };
53
+ declare const useBarChart: ({ data, series, type, layoutType, referenceLineProps, fillOpacity, styles, ...rest }: UseBarChartProps) => {
54
+ barVars: {
55
+ __prefix?: string | undefined;
56
+ name: string;
57
+ token?: "colors" | "transitionDuration" | "transitionProperty" | "animations" | "blurs" | "borders" | "breakpoints" | "fonts" | "fontSizes" | "fontWeights" | "gradients" | "layerStyles" | "letterSpacings" | "lineHeights" | "radii" | "shadows" | "sizes" | "spaces" | "textStyles" | "transitionEasing" | "zIndices" | undefined;
58
+ value?: (number | _yamada_ui_utils.StringLiteral | _yamada_ui_core.ResponsiveObject<number | _yamada_ui_utils.StringLiteral> | _yamada_ui_core.ColorModeArray<number | _yamada_ui_utils.StringLiteral>) | undefined;
59
+ }[];
60
+ getBarProps: RequiredChartPropGetter<"div", {
61
+ index: number;
62
+ }, Omit<Recharts.BarProps, "ref">>;
63
+ getBarChartProps: ChartPropGetter<"div", recharts_types_chart_generateCategoricalChart.CategoricalChartProps, recharts_types_chart_generateCategoricalChart.CategoricalChartProps>;
64
+ setHighlightedArea: react.Dispatch<react.SetStateAction<string | null>>;
65
+ };
66
+ type UseBarChartReturn = ReturnType<typeof useBarChart>;
67
+
68
+ export { type UseBarChartOptions, type UseBarChartProps, type UseBarChartReturn, useBarChart };
@@ -0,0 +1,288 @@
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-bar-chart.ts
22
+ var use_bar_chart_exports = {};
23
+ __export(use_bar_chart_exports, {
24
+ useBarChart: () => useBarChart
25
+ });
26
+ module.exports = __toCommonJS(use_bar_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 barChartProperties = [
47
+ "layout",
48
+ "syncId",
49
+ "syncMethod",
50
+ "width",
51
+ "height",
52
+ "data",
53
+ "margin",
54
+ "barCategoryGap",
55
+ "barGap",
56
+ "barSize",
57
+ "maxBarSize",
58
+ "stackOffset",
59
+ "reverseStackOrder",
60
+ "onClick",
61
+ "onMouseEnter",
62
+ "onMouseMove",
63
+ "onMouseLeave"
64
+ ];
65
+ var barProperties = [
66
+ "layout",
67
+ "dataKey",
68
+ "xAxisId",
69
+ "yAxisId",
70
+ "legendType",
71
+ "label",
72
+ "data",
73
+ "barSize",
74
+ "maxBarSize",
75
+ "minPointSize",
76
+ "background",
77
+ "shape",
78
+ "activeBar",
79
+ "stackId",
80
+ "unit",
81
+ "name",
82
+ "isAnimationActive",
83
+ "animationBegin",
84
+ "animationDuration",
85
+ "animationEasing",
86
+ "id",
87
+ "onAnimationStart",
88
+ "onAnimationEnd",
89
+ "onClick",
90
+ "onMouseDown",
91
+ "onMouseUp",
92
+ "onMouseMove",
93
+ "onMouseOver",
94
+ "onMouseOut",
95
+ "onMouseEnter",
96
+ "onMouseLeave",
97
+ "radius"
98
+ ];
99
+
100
+ // src/use-bar-chart.ts
101
+ var useBarChart = ({
102
+ data,
103
+ series,
104
+ type = "default",
105
+ layoutType = "horizontal",
106
+ referenceLineProps = [],
107
+ fillOpacity = 1,
108
+ styles,
109
+ ...rest
110
+ }) => {
111
+ var _a;
112
+ const uuid = (0, import_react.useId)();
113
+ const { theme } = (0, import_core2.useTheme)();
114
+ const [highlightedArea, setHighlightedArea] = (0, import_react.useState)(null);
115
+ const stacked = type === "stacked" || type === "percent";
116
+ const shouldHighlight = highlightedArea !== null;
117
+ const {
118
+ activeBar = {},
119
+ background = {},
120
+ dimBar,
121
+ ...computedBarProps
122
+ } = (_a = rest.barProps) != null ? _a : {};
123
+ const barColors = (0, import_react.useMemo)(
124
+ () => series.map(({ color }, index) => ({
125
+ __prefix: "ui",
126
+ name: `bar-${index}`,
127
+ token: "colors",
128
+ value: color != null ? color : "transparent"
129
+ })),
130
+ [series]
131
+ );
132
+ const referenceLineColors = (0, import_react.useMemo)(
133
+ () => referenceLineProps.map(({ color }, index) => ({
134
+ __prefix: "ui",
135
+ name: `reference-line-${index}`,
136
+ token: "colors",
137
+ value: color != null ? color : "transparent"
138
+ })),
139
+ [referenceLineProps]
140
+ );
141
+ const barVars = (0, import_react.useMemo)(() => {
142
+ return [
143
+ ...barColors,
144
+ ...referenceLineColors,
145
+ { __prefix: "ui", name: "fill-opacity", value: fillOpacity }
146
+ ];
147
+ }, [barColors, fillOpacity, referenceLineColors]);
148
+ const [barChartProps, barChartClassName] = (0, import_react.useMemo)(() => {
149
+ const resolvedBarChartProps = { barGap: 8, ...rest.barChartProps };
150
+ return getComponentProps(
151
+ [resolvedBarChartProps, barChartProperties],
152
+ styles.chart
153
+ )(theme);
154
+ }, [rest.barChartProps, styles.chart, theme]);
155
+ const [barProps, barClassName] = (0, import_react.useMemo)(() => {
156
+ const resolvedBarProps = {
157
+ fillOpacity: "var(--ui-fill-opacity)",
158
+ strokeOpacity: 1,
159
+ ...computedBarProps
160
+ };
161
+ return getComponentProps(
162
+ [resolvedBarProps, barProperties],
163
+ styles.bar
164
+ )(theme);
165
+ }, [computedBarProps, styles.bar, theme]);
166
+ const [dimBarProps, dimBarClassName] = (0, import_react.useMemo)(() => {
167
+ const resolvedDimBar = { fillOpacity: 0.3, strokeOpacity: 0, ...dimBar };
168
+ return getComponentProps([resolvedDimBar, barProperties])(
169
+ theme
170
+ );
171
+ }, [dimBar, theme]);
172
+ const [activeBarProps, activeBarClassName] = (0, import_react.useMemo)(
173
+ () => getComponentProps(
174
+ [activeBar, barProperties],
175
+ styles.activeBar
176
+ )(theme),
177
+ [activeBar, styles.activeBar, theme]
178
+ );
179
+ const [backgroundProps, backgroundClassName] = (0, import_react.useMemo)(
180
+ () => getComponentProps(
181
+ [background, barProperties],
182
+ styles.background
183
+ )(theme),
184
+ [background, styles.background, theme]
185
+ );
186
+ const barPropsList = (0, import_react.useMemo)(
187
+ () => series.map((props, index) => {
188
+ const {
189
+ dataKey,
190
+ activeBar: activeBar2 = {},
191
+ background: background2 = {},
192
+ dimBar: dimBar2 = {},
193
+ ...computedProps
194
+ } = props;
195
+ const id = `${uuid}-${dataKey}`;
196
+ const color = `var(--ui-bar-${index})`;
197
+ const dimmed = shouldHighlight && highlightedArea !== dataKey;
198
+ const computedDimBar = { ...dimBarProps, ...dimBar2 };
199
+ const resolvedProps = {
200
+ ...barProps,
201
+ ...computedProps,
202
+ ...dimmed ? computedDimBar : {}
203
+ };
204
+ const rest2 = getComponentProps(
205
+ [resolvedProps, barProperties],
206
+ barClassName,
207
+ dimmed ? dimBarClassName : void 0
208
+ )(theme, true);
209
+ const computedActiveBar = { ...activeBarProps, ...activeBar2 };
210
+ const resolvedActiveBar = getComponentProps(
211
+ [computedActiveBar, barProperties],
212
+ activeBarClassName
213
+ )(theme, true);
214
+ const computedBackground = { ...backgroundProps, ...background2 };
215
+ const resolvedBackground = getComponentProps(
216
+ [computedBackground, barProperties],
217
+ backgroundClassName
218
+ )(theme, true);
219
+ return {
220
+ ...rest2,
221
+ id,
222
+ activeBar: resolvedActiveBar,
223
+ background: resolvedBackground,
224
+ color,
225
+ dataKey
226
+ };
227
+ }),
228
+ [
229
+ activeBarClassName,
230
+ activeBarProps,
231
+ backgroundClassName,
232
+ backgroundProps,
233
+ barClassName,
234
+ barProps,
235
+ dimBarClassName,
236
+ dimBarProps,
237
+ highlightedArea,
238
+ series,
239
+ shouldHighlight,
240
+ theme,
241
+ uuid
242
+ ]
243
+ );
244
+ const getBarProps = (0, import_react.useCallback)(
245
+ ({ index, className: classNameProp, ...props }, ref = null) => {
246
+ const { id, className, activeBar: activeBar2, background: background2, color, dataKey, ...rest2 } = barPropsList[index];
247
+ return {
248
+ ref,
249
+ className: (0, import_utils2.cx)(classNameProp, className),
250
+ activeBar: activeBar2,
251
+ background: background2,
252
+ id,
253
+ name: dataKey,
254
+ dataKey,
255
+ fill: color,
256
+ stroke: color,
257
+ isAnimationActive: false,
258
+ stackId: stacked ? "stack" : void 0,
259
+ ...props,
260
+ ...rest2
261
+ };
262
+ },
263
+ [barPropsList, stacked]
264
+ );
265
+ const getBarChartProps = (0, import_react.useCallback)(
266
+ ({ className, ...props } = {}, ref = null) => ({
267
+ ref,
268
+ className: (0, import_utils2.cx)(className, barChartClassName),
269
+ data,
270
+ stackOffset: type === "percent" ? "expand" : void 0,
271
+ layout: layoutType,
272
+ ...props,
273
+ ...barChartProps
274
+ }),
275
+ [barChartClassName, barChartProps, data, layoutType, type]
276
+ );
277
+ return {
278
+ barVars,
279
+ getBarProps,
280
+ getBarChartProps,
281
+ setHighlightedArea
282
+ };
283
+ };
284
+ // Annotate the CommonJS export names for ESM import in node:
285
+ 0 && (module.exports = {
286
+ useBarChart
287
+ });
288
+ //# sourceMappingURL=use-bar-chart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/use-bar-chart.ts","../src/chart-utils.ts","../src/rechart-properties.ts"],"sourcesContent":["import { type CSSUIObject, useTheme, type CSSUIProps } from \"@yamada-ui/core\"\nimport { type Dict, cx } from \"@yamada-ui/utils\"\nimport {\n type ComponentPropsWithoutRef,\n useCallback,\n useState,\n useId,\n useMemo,\n} from \"react\"\nimport type * as Recharts from \"recharts\"\nimport { getComponentProps } from \"./chart-utils\"\nimport type {\n BarProps,\n BarChartType,\n BarChartProps,\n ChartPropGetter,\n ChartLayoutType,\n ReferenceLineProps,\n RequiredChartPropGetter,\n} from \"./chart.types\"\nimport { barProperties, barChartProperties } from \"./rechart-properties\"\n\nexport type UseBarChartOptions = {\n /**\n * Chart data.\n */\n data: Dict[]\n /**\n * An array of objects with `name` and `color` keys. Determines which data should be consumed from the `data` array.\n */\n series: BarProps[]\n /**\n * Props for the bars.\n */\n barProps?: Partial<BarProps>\n /**\n * Controls how chart bars are positioned relative to each other.\n *\n * @default `default`\n */\n type?: BarChartType\n /**\n * Chart orientation.\n *\n * @default 'horizontal'\n */\n layoutType?: ChartLayoutType\n /**\n * Props passed down to recharts `BarChart` component.\n */\n barChartProps?: BarChartProps\n /**\n * Reference lines that should be displayed on the chart.\n */\n referenceLineProps?: ReferenceLineProps[]\n /**\n * Controls fill opacity of all bars.\n *\n * @default 1\n */\n fillOpacity?: number | [number, number]\n}\n\nexport type UseBarChartProps = UseBarChartOptions & {\n styles: Dict<CSSUIObject>\n}\n\nexport const useBarChart = ({\n data,\n series,\n type = \"default\",\n layoutType = \"horizontal\",\n referenceLineProps = [],\n fillOpacity = 1,\n styles,\n ...rest\n}: UseBarChartProps) => {\n const uuid = useId()\n const { theme } = useTheme()\n const [highlightedArea, setHighlightedArea] = useState<string | null>(null)\n const stacked = type === \"stacked\" || type === \"percent\"\n const shouldHighlight = highlightedArea !== null\n const {\n activeBar = {},\n background = {},\n dimBar,\n ...computedBarProps\n } = rest.barProps ?? {}\n\n const barColors: CSSUIProps[\"var\"] = useMemo(\n () =>\n series.map(({ color }, index) => ({\n __prefix: \"ui\",\n name: `bar-${index}`,\n token: \"colors\",\n value: color ?? \"transparent\",\n })),\n [series],\n )\n\n const referenceLineColors: CSSUIProps[\"var\"] = useMemo(\n () =>\n referenceLineProps.map(({ color }, index) => ({\n __prefix: \"ui\",\n name: `reference-line-${index}`,\n token: \"colors\",\n value: color ?? \"transparent\",\n })),\n [referenceLineProps],\n )\n\n const barVars: CSSUIProps[\"var\"] = useMemo(() => {\n return [\n ...barColors,\n ...referenceLineColors,\n { __prefix: \"ui\", name: \"fill-opacity\", value: fillOpacity },\n ]\n }, [barColors, fillOpacity, referenceLineColors])\n\n const [barChartProps, barChartClassName] = useMemo(() => {\n const resolvedBarChartProps = { barGap: 8, ...rest.barChartProps }\n\n return getComponentProps<Dict, string>(\n [resolvedBarChartProps, barChartProperties],\n styles.chart,\n )(theme)\n }, [rest.barChartProps, styles.chart, theme])\n\n const [barProps, barClassName] = useMemo(() => {\n const resolvedBarProps = {\n fillOpacity: \"var(--ui-fill-opacity)\",\n strokeOpacity: 1,\n ...computedBarProps,\n }\n\n return getComponentProps<Dict, string>(\n [resolvedBarProps, barProperties],\n styles.bar,\n )(theme)\n }, [computedBarProps, styles.bar, theme])\n\n const [dimBarProps, dimBarClassName] = useMemo(() => {\n const resolvedDimBar = { fillOpacity: 0.3, strokeOpacity: 0, ...dimBar }\n\n return getComponentProps<Dict, string>([resolvedDimBar, barProperties])(\n theme,\n )\n }, [dimBar, theme])\n\n const [activeBarProps, activeBarClassName] = useMemo(\n () =>\n getComponentProps<Dict, string>(\n [activeBar, barProperties],\n styles.activeBar,\n )(theme),\n [activeBar, styles.activeBar, theme],\n )\n\n const [backgroundProps, backgroundClassName] = useMemo(\n () =>\n getComponentProps<Dict, string>(\n [background, barProperties],\n styles.background,\n )(theme),\n [background, styles.background, theme],\n )\n\n const barPropsList = useMemo(\n () =>\n series.map((props, index) => {\n const {\n dataKey,\n activeBar = {},\n background = {},\n dimBar = {},\n ...computedProps\n } = props\n const id = `${uuid}-${dataKey}`\n const color = `var(--ui-bar-${index})`\n const dimmed = shouldHighlight && highlightedArea !== dataKey\n const computedDimBar = { ...dimBarProps, ...dimBar }\n const resolvedProps = {\n ...barProps,\n ...computedProps,\n ...(dimmed ? computedDimBar : {}),\n }\n\n const rest = getComponentProps<Dict, string>(\n [resolvedProps, barProperties],\n barClassName,\n dimmed ? dimBarClassName : undefined,\n )(theme, true)\n\n const computedActiveBar = { ...activeBarProps, ...activeBar }\n\n const resolvedActiveBar = getComponentProps<Dict, string>(\n [computedActiveBar, barProperties],\n activeBarClassName,\n )(theme, true)\n\n const computedBackground = { ...backgroundProps, ...background }\n\n const resolvedBackground = getComponentProps<Dict, string>(\n [computedBackground, barProperties],\n backgroundClassName,\n )(theme, true)\n\n return {\n ...rest,\n id,\n activeBar: resolvedActiveBar,\n background: resolvedBackground,\n color,\n dataKey,\n }\n }),\n [\n activeBarClassName,\n activeBarProps,\n backgroundClassName,\n backgroundProps,\n barClassName,\n barProps,\n dimBarClassName,\n dimBarProps,\n highlightedArea,\n series,\n shouldHighlight,\n theme,\n uuid,\n ],\n )\n\n const getBarProps: RequiredChartPropGetter<\n \"div\",\n {\n index: number\n },\n Omit<Recharts.BarProps, \"ref\">\n > = useCallback(\n ({ index, className: classNameProp, ...props }, ref = null) => {\n const { id, className, activeBar, background, color, dataKey, ...rest } =\n barPropsList[index]\n\n return {\n ref,\n className: cx(classNameProp, className),\n activeBar,\n background,\n id,\n name: dataKey as string,\n dataKey,\n fill: color,\n stroke: color,\n isAnimationActive: false,\n stackId: stacked ? \"stack\" : undefined,\n ...(props as Omit<Recharts.BarProps, \"dataKey\">),\n ...rest,\n } as Recharts.BarProps\n },\n [barPropsList, stacked],\n )\n\n const getBarChartProps: ChartPropGetter<\n \"div\",\n ComponentPropsWithoutRef<typeof Recharts.BarChart>,\n ComponentPropsWithoutRef<typeof Recharts.BarChart>\n > = useCallback(\n ({ className, ...props } = {}, ref = null) => ({\n ref,\n className: cx(className, barChartClassName),\n data,\n stackOffset: type === \"percent\" ? \"expand\" : undefined,\n layout: layoutType,\n ...props,\n ...barChartProps,\n }),\n [barChartClassName, barChartProps, data, layoutType, type],\n )\n\n return {\n barVars,\n getBarProps,\n getBarChartProps,\n setHighlightedArea,\n }\n}\n\nexport type UseBarChartReturn = ReturnType<typeof useBarChart>\n","import type { StyledTheme } from \"@yamada-ui/core\"\nimport { getCSS } from \"@yamada-ui/core\"\nimport type { Dict } from \"@yamada-ui/utils\"\nimport { cx, isString, splitObject } from \"@yamada-ui/utils\"\n\nexport const getClassName =\n (...styles: (Dict | string | undefined)[]) =>\n (theme: StyledTheme) =>\n cx(\n ...styles.map((style) =>\n isString(style) ? style : getCSS(style)(theme),\n ),\n )\n\nexport const getComponentProps =\n <T extends Dict, K extends keyof T>(\n [obj, keys]: [T, K[]],\n ...props: (Dict | string | undefined)[]\n ) =>\n <P extends boolean = false>(theme: StyledTheme, isContain?: P) => {\n const [pickedProps, omittedProps] = splitObject<T, K>(obj, keys)\n const className = getClassName(...props, omittedProps)(theme)\n\n return (\n !isContain ? [pickedProps, className] : { ...pickedProps, className }\n ) as P extends false\n ? [{ [P in K]: T[P] }, string]\n : { [P in K]: T[P] } & { className: string }\n }\n","import type { ComponentPropsWithoutRef } from \"react\"\nimport type * as Recharts from \"recharts\"\n\nexport const areaChartProperties: (keyof ComponentPropsWithoutRef<\n typeof Recharts.AreaChart\n>)[] = [\n \"layout\",\n \"syncId\",\n \"syncMethod\",\n \"width\",\n \"height\",\n \"data\",\n \"margin\",\n \"stackOffset\",\n \"onClick\",\n \"onMouseEnter\",\n \"onMouseMove\",\n \"onMouseLeave\",\n]\n\nexport const barChartProperties: (keyof ComponentPropsWithoutRef<\n typeof Recharts.BarChart\n>)[] = [\n \"layout\",\n \"syncId\",\n \"syncMethod\",\n \"width\",\n \"height\",\n \"data\",\n \"margin\",\n \"barCategoryGap\",\n \"barGap\",\n \"barSize\",\n \"maxBarSize\",\n \"stackOffset\",\n \"reverseStackOrder\",\n \"onClick\",\n \"onMouseEnter\",\n \"onMouseMove\",\n \"onMouseLeave\",\n]\n\nexport const lineChartProperties: (keyof ComponentPropsWithoutRef<\n typeof Recharts.LineChart\n>)[] = [\n \"layout\",\n \"syncId\",\n \"syncMethod\",\n \"width\",\n \"height\",\n \"data\",\n \"margin\",\n \"onClick\",\n \"onMouseEnter\",\n \"onMouseMove\",\n \"onMouseLeave\",\n]\n\nexport const radarChartProperties: (keyof ComponentPropsWithoutRef<\n typeof Recharts.RadarChart\n>)[] = [\n \"width\",\n \"height\",\n \"data\",\n \"cx\",\n \"cy\",\n \"startAngle\",\n \"endAngle\",\n \"innerRadius\",\n \"outerRadius\",\n \"margin\",\n \"onMouseEnter\",\n \"onClick\",\n]\n\nexport const referenceLineProperties: (keyof Recharts.ReferenceLineProps)[] = [\n \"xAxisId\",\n \"yAxisId\",\n \"x\",\n \"y\",\n \"ifOverflow\",\n \"viewBox\",\n \"xAxis\",\n \"yAxis\",\n \"label\",\n \"isFront\",\n \"strokeWidth\",\n \"segment\",\n]\n\nexport const containerProperties: (keyof Omit<\n Recharts.ResponsiveContainerProps,\n \"children\"\n>)[] = [\n \"aspect\",\n \"width\",\n \"height\",\n \"minWidth\",\n \"minHeight\",\n \"debounce\",\n \"onResize\",\n]\n\nexport const gridProperties: (keyof Recharts.CartesianGridProps)[] = [\n \"x\",\n \"y\",\n \"width\",\n \"height\",\n \"horizontal\",\n \"vertical\",\n \"horizontalPoints\",\n \"horizontalCoordinatesGenerator\",\n \"verticalPoints\",\n \"verticalCoordinatesGenerator\",\n \"fill\",\n \"fillOpacity\",\n \"strokeDasharray\",\n]\n\nexport const xAxisProperties: (keyof Recharts.XAxisProps)[] = [\n \"hide\",\n \"dataKey\",\n \"xAxisId\",\n \"width\",\n \"height\",\n \"orientation\",\n \"type\",\n \"allowDecimals\",\n \"allowDataOverflow\",\n \"allowDuplicatedCategory\",\n \"angle\",\n \"tickCount\",\n \"domain\",\n \"includeHidden\",\n \"interval\",\n \"padding\",\n \"minTickGap\",\n \"axisLine\",\n \"tickLine\",\n \"tickSize\",\n \"tickFormatter\",\n \"ticks\",\n \"tick\",\n \"mirror\",\n \"reversed\",\n \"label\",\n \"scale\",\n \"unit\",\n \"name\",\n \"onClick\",\n \"onMouseDown\",\n \"onMouseUp\",\n \"onMouseMove\",\n \"onMouseOver\",\n \"onMouseOut\",\n \"onMouseEnter\",\n \"onMouseLeave\",\n \"tickMargin\",\n]\n\nexport const yAxisProperties: (keyof Recharts.YAxisProps)[] = [\n \"hide\",\n \"dataKey\",\n \"yAxisId\",\n \"width\",\n \"height\",\n \"orientation\",\n \"type\",\n \"tickCount\",\n \"domain\",\n \"includeHidden\",\n \"interval\",\n \"padding\",\n \"minTickGap\",\n \"allowDecimals\",\n \"allowDataOverflow\",\n \"allowDuplicatedCategory\",\n \"axisLine\",\n \"tickLine\",\n \"tickSize\",\n \"tickFormatter\",\n \"ticks\",\n \"tick\",\n \"mirror\",\n \"reversed\",\n \"label\",\n \"scale\",\n \"unit\",\n \"name\",\n \"onClick\",\n \"onMouseDown\",\n \"onMouseUp\",\n \"onMouseMove\",\n \"onMouseOver\",\n \"onMouseOut\",\n \"onMouseEnter\",\n \"onMouseLeave\",\n \"tickMargin\",\n]\n\nexport const legendProperties: (keyof Omit<Recharts.LegendProps, \"ref\">)[] = [\n \"width\",\n \"height\",\n \"layout\",\n \"align\",\n \"verticalAlign\",\n \"iconSize\",\n \"iconType\",\n \"payload\",\n \"chartWidth\",\n \"chartHeight\",\n \"margin\",\n \"content\",\n \"formatter\",\n \"wrapperStyle\",\n \"onClick\",\n \"onMouseDown\",\n \"onMouseUp\",\n \"onMouseMove\",\n \"onMouseOver\",\n \"onMouseOut\",\n \"onMouseEnter\",\n \"onMouseLeave\",\n]\n\nexport const tooltipProperties: (keyof Recharts.TooltipProps<any, any>)[] = [\n \"offset\",\n \"filterNull\",\n \"itemStyle\",\n \"wrapperStyle\",\n \"contentStyle\",\n \"labelStyle\",\n \"cursor\",\n \"viewBox\",\n \"allowEscapeViewBox\",\n \"active\",\n \"position\",\n \"coordinate\",\n \"payload\",\n \"label\",\n \"content\",\n \"formatter\",\n \"labelFormatter\",\n \"itemSorter\",\n \"isAnimationActive\",\n \"animationDuration\",\n \"animationEasing\",\n]\n\nexport const areaProperties: (keyof Omit<Recharts.AreaProps, \"ref\">)[] = [\n \"type\",\n \"dataKey\",\n \"xAxisId\",\n \"yAxisId\",\n \"legendType\",\n \"dot\",\n \"activeDot\",\n \"label\",\n \"stroke\",\n \"strokeWidth\",\n \"layout\",\n \"baseLine\",\n \"points\",\n \"stackId\",\n \"connectNulls\",\n \"unit\",\n \"name\",\n \"isAnimationActive\",\n \"animationBegin\",\n \"animationDuration\",\n \"animationEasing\",\n \"id\",\n \"onAnimationStart\",\n \"onAnimationEnd\",\n \"onClick\",\n \"onMouseDown\",\n \"onMouseUp\",\n \"onMouseMove\",\n \"onMouseOver\",\n \"onMouseOut\",\n \"onMouseEnter\",\n \"onMouseLeave\",\n]\n\nexport const barProperties: (keyof Omit<Recharts.BarProps, \"ref\">)[] = [\n \"layout\",\n \"dataKey\",\n \"xAxisId\",\n \"yAxisId\",\n \"legendType\",\n \"label\",\n \"data\",\n \"barSize\",\n \"maxBarSize\",\n \"minPointSize\",\n \"background\",\n \"shape\",\n \"activeBar\",\n \"stackId\",\n \"unit\",\n \"name\",\n \"isAnimationActive\",\n \"animationBegin\",\n \"animationDuration\",\n \"animationEasing\",\n \"id\",\n \"onAnimationStart\",\n \"onAnimationEnd\",\n \"onClick\",\n \"onMouseDown\",\n \"onMouseUp\",\n \"onMouseMove\",\n \"onMouseOver\",\n \"onMouseOut\",\n \"onMouseEnter\",\n \"onMouseLeave\",\n \"radius\",\n]\n\nexport const radarProperties: (keyof Omit<Recharts.RadarProps, \"ref\">)[] = [\n \"dataKey\",\n \"points\",\n \"shape\",\n \"dot\",\n \"activeDot\",\n \"legendType\",\n \"label\",\n \"isAnimationActive\",\n \"animationBegin\",\n \"animationDuration\",\n \"animationEasing\",\n \"onAnimationStart\",\n \"onAnimationEnd\",\n]\n\nexport const lineProperties: (keyof Omit<Recharts.LineProps, \"ref\">)[] = [\n \"type\",\n \"dataKey\",\n \"xAxisId\",\n \"yAxisId\",\n \"legendType\",\n \"dot\",\n \"activeDot\",\n \"label\",\n \"hide\",\n \"points\",\n \"stroke\",\n \"strokeWidth\",\n \"layout\",\n \"connectNulls\",\n \"unit\",\n \"name\",\n \"isAnimationActive\",\n \"animationBegin\",\n \"animationDuration\",\n \"animationEasing\",\n \"id\",\n \"onAnimationStart\",\n \"onAnimationEnd\",\n \"onClick\",\n \"onMouseDown\",\n \"onMouseUp\",\n \"onMouseMove\",\n \"onMouseOver\",\n \"onMouseOut\",\n \"onMouseEnter\",\n \"onMouseLeave\",\n \"strokeDasharray\",\n]\n\nexport const dotProperties: (keyof Omit<Recharts.DotProps, \"ref\">)[] = [\n \"cx\",\n \"cy\",\n \"r\",\n \"onClick\",\n \"onMouseDown\",\n \"onMouseUp\",\n \"onMouseMove\",\n \"onMouseOver\",\n \"onMouseOut\",\n \"onMouseEnter\",\n \"onMouseLeave\",\n]\n\nexport const polarGridProperties: (keyof Recharts.PolarGridProps)[] = [\n \"cx\",\n \"cy\",\n \"innerRadius\",\n \"outerRadius\",\n \"polarAngles\",\n \"polarRadius\",\n \"gridType\",\n]\n\nexport const polarAngleAxisProperties: (keyof Recharts.PolarAngleAxisProps)[] =\n [\n \"dataKey\",\n \"cx\",\n \"cy\",\n \"radius\",\n \"axisLine\",\n \"axisLineType\",\n \"tickLine\",\n \"tickSize\",\n \"tick\",\n \"ticks\",\n \"orient\",\n \"tickFormatter\",\n \"type\",\n \"allowDuplicatedCategory\",\n \"onClick\",\n \"onMouseDown\",\n \"onMouseUp\",\n \"onMouseMove\",\n \"onMouseOver\",\n \"onMouseOut\",\n \"onMouseEnter\",\n \"onMouseLeave\",\n ]\nexport const polarRadiusAxisProperties: (keyof Recharts.PolarRadiusAxisProps)[] =\n [\n \"angle\",\n \"type\",\n \"allowDuplicatedCategory\",\n \"cx\",\n \"cy\",\n \"domain\",\n \"reversed\",\n \"label\",\n \"orientation\",\n \"axisLine\",\n \"tick\",\n \"tickSize\",\n \"tickFormatter\",\n \"tickCount\",\n \"scale\",\n \"onClick\",\n \"onMouseDown\",\n \"onMouseUp\",\n \"onMouseMove\",\n \"onMouseOver\",\n \"onMouseOut\",\n \"onMouseEnter\",\n \"onMouseLeave\",\n ]\n"],"mappings":";;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QACA,MAAM;AAAA,QACN;AAAA,QACA,MAAM;AAAA,QACN,QAAQ;AAAA,QACR,mBAAmB;AAAA,QACnB,SAAS,UAAU,UAAU;AAAA,QAC7B,GAAI;AAAA,QACJ,GAAGE;AAAA,MACL;AAAA,IACF;AAAA,IACA,CAAC,cAAc,OAAO;AAAA,EACxB;AAEA,QAAM,uBAIF;AAAA,IACF,CAAC,EAAE,WAAW,GAAG,MAAM,IAAI,CAAC,GAAG,MAAM,UAAU;AAAA,MAC7C;AAAA,MACA,eAAW,kBAAG,WAAW,iBAAiB;AAAA,MAC1C;AAAA,MACA,aAAa,SAAS,YAAY,WAAW;AAAA,MAC7C,QAAQ;AAAA,MACR,GAAG;AAAA,MACH,GAAG;AAAA,IACL;AAAA,IACA,CAAC,mBAAmB,eAAe,MAAM,YAAY,IAAI;AAAA,EAC3D;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["import_core","import_utils","activeBar","background","dimBar","rest"]}
@@ -0,0 +1,10 @@
1
+ "use client"
2
+ import {
3
+ useBarChart
4
+ } from "./chunk-TKLHZBVY.mjs";
5
+ import "./chunk-5QCKM3B3.mjs";
6
+ import "./chunk-QL3DB7OJ.mjs";
7
+ export {
8
+ useBarChart
9
+ };
10
+ //# sourceMappingURL=use-bar-chart.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,73 @@
1
+ import { CSSUIObject } from '@yamada-ui/core';
2
+ import { Dict } from '@yamada-ui/utils';
3
+ import * as Recharts from 'recharts';
4
+ import { AreaChartType, ChartLayoutType, ChartAxisType, XAxisProps, YAxisProps, ChartPropGetter } from './chart.types.mjs';
5
+ import 'react';
6
+
7
+ type UseChartAxisOptions = {
8
+ /**
9
+ * The key of a group of data which should be unique in an chart.
10
+ */
11
+ dataKey: string;
12
+ /**
13
+ * Controls how chart areas are positioned relative to each other
14
+ *
15
+ * @default `default`
16
+ */
17
+ type?: AreaChartType;
18
+ /**
19
+ * Chart orientation.
20
+ *
21
+ * @default 'horizontal'
22
+ */
23
+ layoutType?: ChartLayoutType;
24
+ /**
25
+ * The option is the configuration of tick lines.
26
+ *
27
+ * @default 'y'
28
+ */
29
+ tickLine?: ChartAxisType;
30
+ /**
31
+ * Specifies which lines should be displayed in the grid.
32
+ *
33
+ * @default 'x'
34
+ */
35
+ gridAxis?: ChartAxisType;
36
+ /**
37
+ * If `true`, X axis is visible.
38
+ *
39
+ * @default true
40
+ */
41
+ withXAxis?: boolean;
42
+ /**
43
+ * If `true`, Y axis is visible.
44
+ *
45
+ * @default true
46
+ */
47
+ withYAxis?: boolean;
48
+ /**
49
+ * Props passed down to recharts 'XAxis' component.
50
+ */
51
+ xAxisProps?: XAxisProps;
52
+ /**
53
+ * Props passed down to recharts 'YAxis' component.
54
+ */
55
+ yAxisProps?: YAxisProps;
56
+ /**
57
+ * Unit displayed next to each tick in y-axis.
58
+ */
59
+ unit?: string;
60
+ /**
61
+ * A function to format values on Y axis and inside the tooltip
62
+ */
63
+ valueFormatter?: (value: number) => string;
64
+ };
65
+ type UseChartAxisProps = UseChartAxisOptions & {
66
+ styles: Dict<CSSUIObject>;
67
+ };
68
+ declare const useChartAxis: ({ dataKey, type, layoutType, tickLine, gridAxis, withXAxis, withYAxis, xAxisProps: _xAxisProps, yAxisProps: _yAxisProps, unit, valueFormatter, styles, }: UseChartAxisProps) => {
69
+ getXAxisProps: ChartPropGetter<"div", Partial<Recharts.XAxisProps>, Recharts.XAxisProps>;
70
+ getYAxisProps: ChartPropGetter<"div", Partial<Recharts.YAxisProps>, Recharts.YAxisProps>;
71
+ };
72
+
73
+ export { type UseChartAxisOptions, type UseChartAxisProps, useChartAxis };
@@ -0,0 +1,73 @@
1
+ import { CSSUIObject } from '@yamada-ui/core';
2
+ import { Dict } from '@yamada-ui/utils';
3
+ import * as Recharts from 'recharts';
4
+ import { AreaChartType, ChartLayoutType, ChartAxisType, XAxisProps, YAxisProps, ChartPropGetter } from './chart.types.js';
5
+ import 'react';
6
+
7
+ type UseChartAxisOptions = {
8
+ /**
9
+ * The key of a group of data which should be unique in an chart.
10
+ */
11
+ dataKey: string;
12
+ /**
13
+ * Controls how chart areas are positioned relative to each other
14
+ *
15
+ * @default `default`
16
+ */
17
+ type?: AreaChartType;
18
+ /**
19
+ * Chart orientation.
20
+ *
21
+ * @default 'horizontal'
22
+ */
23
+ layoutType?: ChartLayoutType;
24
+ /**
25
+ * The option is the configuration of tick lines.
26
+ *
27
+ * @default 'y'
28
+ */
29
+ tickLine?: ChartAxisType;
30
+ /**
31
+ * Specifies which lines should be displayed in the grid.
32
+ *
33
+ * @default 'x'
34
+ */
35
+ gridAxis?: ChartAxisType;
36
+ /**
37
+ * If `true`, X axis is visible.
38
+ *
39
+ * @default true
40
+ */
41
+ withXAxis?: boolean;
42
+ /**
43
+ * If `true`, Y axis is visible.
44
+ *
45
+ * @default true
46
+ */
47
+ withYAxis?: boolean;
48
+ /**
49
+ * Props passed down to recharts 'XAxis' component.
50
+ */
51
+ xAxisProps?: XAxisProps;
52
+ /**
53
+ * Props passed down to recharts 'YAxis' component.
54
+ */
55
+ yAxisProps?: YAxisProps;
56
+ /**
57
+ * Unit displayed next to each tick in y-axis.
58
+ */
59
+ unit?: string;
60
+ /**
61
+ * A function to format values on Y axis and inside the tooltip
62
+ */
63
+ valueFormatter?: (value: number) => string;
64
+ };
65
+ type UseChartAxisProps = UseChartAxisOptions & {
66
+ styles: Dict<CSSUIObject>;
67
+ };
68
+ declare const useChartAxis: ({ dataKey, type, layoutType, tickLine, gridAxis, withXAxis, withYAxis, xAxisProps: _xAxisProps, yAxisProps: _yAxisProps, unit, valueFormatter, styles, }: UseChartAxisProps) => {
69
+ getXAxisProps: ChartPropGetter<"div", Partial<Recharts.XAxisProps>, Recharts.XAxisProps>;
70
+ getYAxisProps: ChartPropGetter<"div", Partial<Recharts.YAxisProps>, Recharts.YAxisProps>;
71
+ };
72
+
73
+ export { type UseChartAxisOptions, type UseChartAxisProps, useChartAxis };