@yamada-ui/charts 1.1.2-dev-20240430063353 → 1.1.2-dev-20240501174240
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.
- package/package.json +5 -5
- package/dist/area-chart-gradient.d.mts +0 -11
- package/dist/area-chart-gradient.d.ts +0 -11
- package/dist/area-chart-gradient.js +0 -47
- package/dist/area-chart-gradient.js.map +0 -1
- package/dist/area-chart-gradient.mjs +0 -8
- package/dist/area-chart-gradient.mjs.map +0 -1
- package/dist/area-chart-split.d.mts +0 -10
- package/dist/area-chart-split.d.ts +0 -10
- package/dist/area-chart-split.js +0 -52
- package/dist/area-chart-split.js.map +0 -1
- package/dist/area-chart-split.mjs +0 -8
- package/dist/area-chart-split.mjs.map +0 -1
- package/dist/area-chart.d.mts +0 -41
- package/dist/area-chart.d.ts +0 -41
- package/dist/area-chart.js +0 -1223
- package/dist/area-chart.js.map +0 -1
- package/dist/area-chart.mjs +0 -21
- package/dist/area-chart.mjs.map +0 -1
- package/dist/bar-chart.d.mts +0 -38
- package/dist/bar-chart.d.ts +0 -38
- package/dist/bar-chart.js +0 -1027
- package/dist/bar-chart.js.map +0 -1
- package/dist/bar-chart.mjs +0 -19
- package/dist/bar-chart.mjs.map +0 -1
- package/dist/chart-legend.d.mts +0 -12
- package/dist/chart-legend.d.ts +0 -12
- package/dist/chart-legend.js +0 -90
- package/dist/chart-legend.js.map +0 -1
- package/dist/chart-legend.mjs +0 -11
- package/dist/chart-legend.mjs.map +0 -1
- package/dist/chart-tooltip.d.mts +0 -12
- package/dist/chart-tooltip.d.ts +0 -12
- package/dist/chart-tooltip.js +0 -121
- package/dist/chart-tooltip.js.map +0 -1
- package/dist/chart-tooltip.mjs +0 -11
- package/dist/chart-tooltip.mjs.map +0 -1
- package/dist/chart-utils.d.mts +0 -9
- package/dist/chart-utils.d.ts +0 -9
- package/dist/chart-utils.js +0 -45
- package/dist/chart-utils.js.map +0 -1
- package/dist/chart-utils.mjs +0 -10
- package/dist/chart-utils.mjs.map +0 -1
- package/dist/chart.types.d.mts +0 -78
- package/dist/chart.types.d.ts +0 -78
- package/dist/chart.types.js +0 -20
- package/dist/chart.types.js.map +0 -1
- package/dist/chart.types.mjs +0 -2
- package/dist/chart.types.mjs.map +0 -1
- package/dist/chunk-4WX5YS7M.mjs +0 -179
- package/dist/chunk-4WX5YS7M.mjs.map +0 -1
- package/dist/chunk-5TVYPA64.mjs +0 -256
- package/dist/chunk-5TVYPA64.mjs.map +0 -1
- package/dist/chunk-BPR7YL3O.mjs +0 -179
- package/dist/chunk-BPR7YL3O.mjs.map +0 -1
- package/dist/chunk-E2I2XAZ6.mjs +0 -232
- package/dist/chunk-E2I2XAZ6.mjs.map +0 -1
- package/dist/chunk-HDOYOHLA.mjs +0 -326
- package/dist/chunk-HDOYOHLA.mjs.map +0 -1
- package/dist/chunk-KNAADLWO.mjs +0 -225
- package/dist/chunk-KNAADLWO.mjs.map +0 -1
- package/dist/chunk-KT4YOMM4.mjs +0 -344
- package/dist/chunk-KT4YOMM4.mjs.map +0 -1
- package/dist/chunk-LBC2B6UX.mjs +0 -84
- package/dist/chunk-LBC2B6UX.mjs.map +0 -1
- package/dist/chunk-LGMALZCN.mjs +0 -42
- package/dist/chunk-LGMALZCN.mjs.map +0 -1
- package/dist/chunk-LHI57S6P.mjs +0 -215
- package/dist/chunk-LHI57S6P.mjs.map +0 -1
- package/dist/chunk-LM2DQK2P.mjs +0 -33
- package/dist/chunk-LM2DQK2P.mjs.map +0 -1
- package/dist/chunk-MSIOYYWR.mjs +0 -24
- package/dist/chunk-MSIOYYWR.mjs.map +0 -1
- package/dist/chunk-MWPICUEW.mjs +0 -56
- package/dist/chunk-MWPICUEW.mjs.map +0 -1
- package/dist/chunk-NEGDEVRX.mjs +0 -53
- package/dist/chunk-NEGDEVRX.mjs.map +0 -1
- package/dist/chunk-OSNFBRHL.mjs +0 -474
- package/dist/chunk-OSNFBRHL.mjs.map +0 -1
- package/dist/chunk-OW7SOTEF.mjs +0 -206
- package/dist/chunk-OW7SOTEF.mjs.map +0 -1
- package/dist/chunk-P7AFSM5W.mjs +0 -114
- package/dist/chunk-P7AFSM5W.mjs.map +0 -1
- package/dist/chunk-PNE3JG54.mjs +0 -29
- package/dist/chunk-PNE3JG54.mjs.map +0 -1
- package/dist/chunk-QL3DB7OJ.mjs +0 -21
- package/dist/chunk-QL3DB7OJ.mjs.map +0 -1
- package/dist/chunk-QZ5OXZ6Z.mjs +0 -251
- package/dist/chunk-QZ5OXZ6Z.mjs.map +0 -1
- package/dist/chunk-RN6PXJAD.mjs +0 -47
- package/dist/chunk-RN6PXJAD.mjs.map +0 -1
- package/dist/chunk-STBYRLC5.mjs +0 -208
- package/dist/chunk-STBYRLC5.mjs.map +0 -1
- package/dist/chunk-XIFDRM7J.mjs +0 -56
- package/dist/chunk-XIFDRM7J.mjs.map +0 -1
- package/dist/donut-chart.d.mts +0 -31
- package/dist/donut-chart.d.ts +0 -31
- package/dist/donut-chart.js +0 -702
- package/dist/donut-chart.js.map +0 -1
- package/dist/donut-chart.mjs +0 -16
- package/dist/donut-chart.mjs.map +0 -1
- package/dist/index.d.mts +0 -26
- package/dist/index.d.ts +0 -26
- package/dist/index.js +0 -3228
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -45
- package/dist/index.mjs.map +0 -1
- package/dist/line-chart.d.mts +0 -38
- package/dist/line-chart.d.ts +0 -38
- package/dist/line-chart.js +0 -1088
- package/dist/line-chart.js.map +0 -1
- package/dist/line-chart.mjs +0 -19
- package/dist/line-chart.mjs.map +0 -1
- package/dist/pie-chart.d.mts +0 -49
- package/dist/pie-chart.d.ts +0 -49
- package/dist/pie-chart.js +0 -702
- package/dist/pie-chart.js.map +0 -1
- package/dist/pie-chart.mjs +0 -16
- package/dist/pie-chart.mjs.map +0 -1
- package/dist/radar-chart.d.mts +0 -57
- package/dist/radar-chart.d.ts +0 -57
- package/dist/radar-chart.js +0 -918
- package/dist/radar-chart.js.map +0 -1
- package/dist/radar-chart.mjs +0 -16
- package/dist/radar-chart.mjs.map +0 -1
- package/dist/rechart-properties.d.mts +0 -26
- package/dist/rechart-properties.d.ts +0 -26
- package/dist/rechart-properties.js +0 -517
- package/dist/rechart-properties.js.map +0 -1
- package/dist/rechart-properties.mjs +0 -48
- package/dist/rechart-properties.mjs.map +0 -1
- package/dist/use-area-chart.d.mts +0 -123
- package/dist/use-area-chart.d.ts +0 -123
- package/dist/use-area-chart.js +0 -420
- package/dist/use-area-chart.js.map +0 -1
- package/dist/use-area-chart.mjs +0 -10
- package/dist/use-area-chart.mjs.map +0 -1
- package/dist/use-bar-chart.d.mts +0 -73
- package/dist/use-bar-chart.d.ts +0 -73
- package/dist/use-bar-chart.js +0 -290
- package/dist/use-bar-chart.js.map +0 -1
- package/dist/use-bar-chart.mjs +0 -10
- package/dist/use-bar-chart.mjs.map +0 -1
- package/dist/use-chart-axis.d.mts +0 -73
- package/dist/use-chart-axis.d.ts +0 -73
- package/dist/use-chart-axis.js +0 -227
- package/dist/use-chart-axis.js.map +0 -1
- package/dist/use-chart-axis.mjs +0 -10
- package/dist/use-chart-axis.mjs.map +0 -1
- package/dist/use-chart-grid.d.mts +0 -32
- package/dist/use-chart-grid.d.ts +0 -32
- package/dist/use-chart-grid.js +0 -92
- package/dist/use-chart-grid.js.map +0 -1
- package/dist/use-chart-grid.mjs +0 -10
- package/dist/use-chart-grid.mjs.map +0 -1
- package/dist/use-chart-legend.d.mts +0 -18
- package/dist/use-chart-legend.d.ts +0 -18
- package/dist/use-chart-legend.js +0 -81
- package/dist/use-chart-legend.js.map +0 -1
- package/dist/use-chart-legend.mjs +0 -9
- package/dist/use-chart-legend.mjs.map +0 -1
- package/dist/use-chart-reference-line.d.mts +0 -22
- package/dist/use-chart-reference-line.d.ts +0 -22
- package/dist/use-chart-reference-line.js +0 -105
- package/dist/use-chart-reference-line.js.map +0 -1
- package/dist/use-chart-reference-line.mjs +0 -10
- package/dist/use-chart-reference-line.mjs.map +0 -1
- package/dist/use-chart-tooltip.d.mts +0 -27
- package/dist/use-chart-tooltip.d.ts +0 -27
- package/dist/use-chart-tooltip.js +0 -100
- package/dist/use-chart-tooltip.js.map +0 -1
- package/dist/use-chart-tooltip.mjs +0 -10
- package/dist/use-chart-tooltip.mjs.map +0 -1
- package/dist/use-chart.d.mts +0 -33
- package/dist/use-chart.d.ts +0 -33
- package/dist/use-chart.js +0 -104
- package/dist/use-chart.js.map +0 -1
- package/dist/use-chart.mjs +0 -18
- package/dist/use-chart.mjs.map +0 -1
- package/dist/use-line-chart.d.mts +0 -97
- package/dist/use-line-chart.d.ts +0 -97
- package/dist/use-line-chart.js +0 -344
- package/dist/use-line-chart.js.map +0 -1
- package/dist/use-line-chart.mjs +0 -10
- package/dist/use-line-chart.mjs.map +0 -1
- package/dist/use-pie-chart.d.mts +0 -112
- package/dist/use-pie-chart.d.ts +0 -112
- package/dist/use-pie-chart.js +0 -282
- package/dist/use-pie-chart.js.map +0 -1
- package/dist/use-pie-chart.mjs +0 -10
- package/dist/use-pie-chart.mjs.map +0 -1
- package/dist/use-radar-chart.d.mts +0 -105
- package/dist/use-radar-chart.d.ts +0 -105
- package/dist/use-radar-chart.js +0 -473
- package/dist/use-radar-chart.js.map +0 -1
- package/dist/use-radar-chart.mjs +0 -10
- package/dist/use-radar-chart.mjs.map +0 -1
package/dist/chunk-STBYRLC5.mjs
DELETED
@@ -1,208 +0,0 @@
|
|
1
|
-
"use client"
|
2
|
-
import {
|
3
|
-
barChartProperties,
|
4
|
-
barProperties
|
5
|
-
} from "./chunk-OSNFBRHL.mjs";
|
6
|
-
import {
|
7
|
-
getComponentProps
|
8
|
-
} from "./chunk-QL3DB7OJ.mjs";
|
9
|
-
|
10
|
-
// src/use-bar-chart.ts
|
11
|
-
import { useTheme } from "@yamada-ui/core";
|
12
|
-
import { cx } from "@yamada-ui/utils";
|
13
|
-
import {
|
14
|
-
useCallback,
|
15
|
-
useState,
|
16
|
-
useId,
|
17
|
-
useMemo
|
18
|
-
} from "react";
|
19
|
-
var useBarChart = ({
|
20
|
-
data,
|
21
|
-
series,
|
22
|
-
type = "default",
|
23
|
-
layoutType = "horizontal",
|
24
|
-
referenceLineProps = [],
|
25
|
-
fillOpacity = 1,
|
26
|
-
syncId,
|
27
|
-
styles,
|
28
|
-
...rest
|
29
|
-
}) => {
|
30
|
-
var _a;
|
31
|
-
const uuid = useId();
|
32
|
-
const { theme } = useTheme();
|
33
|
-
const [highlightedArea, setHighlightedArea] = useState(null);
|
34
|
-
const stacked = type === "stacked" || type === "percent";
|
35
|
-
const shouldHighlight = highlightedArea !== null;
|
36
|
-
const {
|
37
|
-
activeBar = {},
|
38
|
-
background = {},
|
39
|
-
dimBar,
|
40
|
-
...computedBarProps
|
41
|
-
} = (_a = rest.barProps) != null ? _a : {};
|
42
|
-
const barColors = useMemo(
|
43
|
-
() => series.map(({ color }, index) => ({
|
44
|
-
__prefix: "ui",
|
45
|
-
name: `bar-${index}`,
|
46
|
-
token: "colors",
|
47
|
-
value: color != null ? color : "transparent"
|
48
|
-
})),
|
49
|
-
[series]
|
50
|
-
);
|
51
|
-
const referenceLineColors = useMemo(
|
52
|
-
() => referenceLineProps.map(({ color }, index) => ({
|
53
|
-
__prefix: "ui",
|
54
|
-
name: `reference-line-${index}`,
|
55
|
-
token: "colors",
|
56
|
-
value: color != null ? color : "transparent"
|
57
|
-
})),
|
58
|
-
[referenceLineProps]
|
59
|
-
);
|
60
|
-
const barVars = useMemo(() => {
|
61
|
-
return [
|
62
|
-
...barColors,
|
63
|
-
...referenceLineColors,
|
64
|
-
{ __prefix: "ui", name: "fill-opacity", value: fillOpacity }
|
65
|
-
];
|
66
|
-
}, [barColors, fillOpacity, referenceLineColors]);
|
67
|
-
const [chartProps, barChartClassName] = useMemo(() => {
|
68
|
-
const resolvedBarChartProps = { barGap: 8, ...rest.chartProps };
|
69
|
-
return getComponentProps(
|
70
|
-
[resolvedBarChartProps, barChartProperties],
|
71
|
-
styles.chart
|
72
|
-
)(theme);
|
73
|
-
}, [rest.chartProps, styles.chart, theme]);
|
74
|
-
const [barProps, barClassName] = useMemo(() => {
|
75
|
-
const resolvedBarProps = {
|
76
|
-
fillOpacity: "var(--ui-fill-opacity)",
|
77
|
-
strokeOpacity: 1,
|
78
|
-
...computedBarProps
|
79
|
-
};
|
80
|
-
return getComponentProps(
|
81
|
-
[resolvedBarProps, barProperties],
|
82
|
-
styles.bar
|
83
|
-
)(theme);
|
84
|
-
}, [computedBarProps, styles.bar, theme]);
|
85
|
-
const [dimBarProps, dimBarClassName] = useMemo(() => {
|
86
|
-
const resolvedDimBar = { fillOpacity: 0.3, strokeOpacity: 0, ...dimBar };
|
87
|
-
return getComponentProps([resolvedDimBar, barProperties])(
|
88
|
-
theme
|
89
|
-
);
|
90
|
-
}, [dimBar, theme]);
|
91
|
-
const [activeBarProps, activeBarClassName] = useMemo(
|
92
|
-
() => getComponentProps(
|
93
|
-
[activeBar, barProperties],
|
94
|
-
styles.activeBar
|
95
|
-
)(theme),
|
96
|
-
[activeBar, styles.activeBar, theme]
|
97
|
-
);
|
98
|
-
const [backgroundProps, backgroundClassName] = useMemo(
|
99
|
-
() => getComponentProps(
|
100
|
-
[background, barProperties],
|
101
|
-
styles.background
|
102
|
-
)(theme),
|
103
|
-
[background, styles.background, theme]
|
104
|
-
);
|
105
|
-
const barPropsList = useMemo(
|
106
|
-
() => series.map((props, index) => {
|
107
|
-
const {
|
108
|
-
dataKey,
|
109
|
-
activeBar: activeBar2 = {},
|
110
|
-
background: background2 = {},
|
111
|
-
dimBar: dimBar2 = {},
|
112
|
-
...computedProps
|
113
|
-
} = props;
|
114
|
-
const id = `${uuid}-${dataKey}`;
|
115
|
-
const color = `var(--ui-bar-${index})`;
|
116
|
-
const dimmed = shouldHighlight && highlightedArea !== dataKey;
|
117
|
-
const computedDimBar = { ...dimBarProps, ...dimBar2 };
|
118
|
-
const resolvedProps = {
|
119
|
-
...barProps,
|
120
|
-
...computedProps,
|
121
|
-
...dimmed ? computedDimBar : {}
|
122
|
-
};
|
123
|
-
const rest2 = getComponentProps(
|
124
|
-
[resolvedProps, barProperties],
|
125
|
-
barClassName,
|
126
|
-
dimmed ? dimBarClassName : void 0
|
127
|
-
)(theme, true);
|
128
|
-
const computedActiveBar = { ...activeBarProps, ...activeBar2 };
|
129
|
-
const resolvedActiveBar = getComponentProps(
|
130
|
-
[computedActiveBar, barProperties],
|
131
|
-
activeBarClassName
|
132
|
-
)(theme, true);
|
133
|
-
const computedBackground = { ...backgroundProps, ...background2 };
|
134
|
-
const resolvedBackground = getComponentProps(
|
135
|
-
[computedBackground, barProperties],
|
136
|
-
backgroundClassName
|
137
|
-
)(theme, true);
|
138
|
-
return {
|
139
|
-
...rest2,
|
140
|
-
id,
|
141
|
-
activeBar: resolvedActiveBar,
|
142
|
-
background: resolvedBackground,
|
143
|
-
color,
|
144
|
-
dataKey
|
145
|
-
};
|
146
|
-
}),
|
147
|
-
[
|
148
|
-
activeBarClassName,
|
149
|
-
activeBarProps,
|
150
|
-
backgroundClassName,
|
151
|
-
backgroundProps,
|
152
|
-
barClassName,
|
153
|
-
barProps,
|
154
|
-
dimBarClassName,
|
155
|
-
dimBarProps,
|
156
|
-
highlightedArea,
|
157
|
-
series,
|
158
|
-
shouldHighlight,
|
159
|
-
theme,
|
160
|
-
uuid
|
161
|
-
]
|
162
|
-
);
|
163
|
-
const getBarProps = useCallback(
|
164
|
-
({ index, className: classNameProp, ...props }, ref = null) => {
|
165
|
-
const { id, className, activeBar: activeBar2, background: background2, color, dataKey, ...rest2 } = barPropsList[index];
|
166
|
-
return {
|
167
|
-
ref,
|
168
|
-
className: cx(classNameProp, className),
|
169
|
-
activeBar: activeBar2,
|
170
|
-
background: background2,
|
171
|
-
id,
|
172
|
-
name: dataKey,
|
173
|
-
dataKey,
|
174
|
-
fill: color,
|
175
|
-
stroke: color,
|
176
|
-
isAnimationActive: false,
|
177
|
-
stackId: stacked ? "stack" : void 0,
|
178
|
-
...props,
|
179
|
-
...rest2
|
180
|
-
};
|
181
|
-
},
|
182
|
-
[barPropsList, stacked]
|
183
|
-
);
|
184
|
-
const getBarChartProps = useCallback(
|
185
|
-
({ className, ...props } = {}, ref = null) => ({
|
186
|
-
ref,
|
187
|
-
className: cx(className, barChartClassName),
|
188
|
-
data,
|
189
|
-
stackOffset: type === "percent" ? "expand" : void 0,
|
190
|
-
layout: layoutType,
|
191
|
-
syncId,
|
192
|
-
...props,
|
193
|
-
...chartProps
|
194
|
-
}),
|
195
|
-
[barChartClassName, chartProps, data, syncId, layoutType, type]
|
196
|
-
);
|
197
|
-
return {
|
198
|
-
barVars,
|
199
|
-
getBarProps,
|
200
|
-
getBarChartProps,
|
201
|
-
setHighlightedArea
|
202
|
-
};
|
203
|
-
};
|
204
|
-
|
205
|
-
export {
|
206
|
-
useBarChart
|
207
|
-
};
|
208
|
-
//# sourceMappingURL=chunk-STBYRLC5.mjs.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/use-bar-chart.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 * If any two categorical charts have the same syncId,\n * these two charts can sync the position tooltip, and the startIndex, endIndex of Brush.\n */\n syncId?: number | string\n /**\n * Props passed down to recharts `BarChart` component.\n */\n chartProps?: 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 syncId,\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 [chartProps, barChartClassName] = useMemo(() => {\n const resolvedBarChartProps = { barGap: 8, ...rest.chartProps }\n\n return getComponentProps<Dict, string>(\n [resolvedBarChartProps, barChartProperties],\n styles.chart,\n )(theme)\n }, [rest.chartProps, 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 syncId,\n ...props,\n ...chartProps,\n }),\n [barChartClassName, chartProps, data, syncId, layoutType, type],\n )\n\n return {\n barVars,\n getBarProps,\n getBarChartProps,\n setHighlightedArea,\n }\n}\n\nexport type UseBarChartReturn = ReturnType<typeof useBarChart>\n"],"mappings":";;;;;;;;;;AAAA,SAA2B,gBAAiC;AAC5D,SAAoB,UAAU;AAC9B;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAgEA,IAAM,cAAc,CAAC;AAAA,EAC1B;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP,aAAa;AAAA,EACb,qBAAqB,CAAC;AAAA,EACtB,cAAc;AAAA,EACd;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAwB;AAlFxB;AAmFE,QAAM,OAAO,MAAM;AACnB,QAA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E;AAAA,MACL;AAAA,IACF;AAAA,IACA,CAAC,cAAc,OAAO;AAAA,EACxB;AAEA,QAAM,mBAIF;AAAA,IACF,CAAC,EAAE,WAAW,GAAG,MAAM,IAAI,CAAC,GAAG,MAAM,UAAU;AAAA,MAC7C;AAAA,MACA,WAAW,GAAG,WAAW,iBAAiB;AAAA,MAC1C;AAAA,MACA,aAAa,SAAS,YAAY,WAAW;AAAA,MAC7C,QAAQ;AAAA,MACR;AAAA,MACA,GAAG;AAAA,MACH,GAAG;AAAA,IACL;AAAA,IACA,CAAC,mBAAmB,YAAY,MAAM,QAAQ,YAAY,IAAI;AAAA,EAChE;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["activeBar","background","dimBar","rest"]}
|
package/dist/chunk-XIFDRM7J.mjs
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
"use client"
|
2
|
-
import {
|
3
|
-
containerProperties
|
4
|
-
} from "./chunk-OSNFBRHL.mjs";
|
5
|
-
import {
|
6
|
-
getComponentProps
|
7
|
-
} from "./chunk-QL3DB7OJ.mjs";
|
8
|
-
|
9
|
-
// src/use-chart.ts
|
10
|
-
import { useTheme } from "@yamada-ui/core";
|
11
|
-
import { createContext, cx } from "@yamada-ui/utils";
|
12
|
-
import { useCallback } from "react";
|
13
|
-
var [ChartProvider, useChartContext] = createContext({
|
14
|
-
name: "ChartContext",
|
15
|
-
errorMessage: `useChartContext returned is 'undefined'. Seems you forgot to wrap the components in "<LineChart />" or "<BarChart />" etc.`
|
16
|
-
});
|
17
|
-
var useChart = ({ containerProps = {} }) => {
|
18
|
-
const { theme } = useTheme();
|
19
|
-
const [reChartsProps, propClassName] = getComponentProps([
|
20
|
-
containerProps,
|
21
|
-
containerProperties
|
22
|
-
])(theme);
|
23
|
-
const getContainerProps = useCallback(
|
24
|
-
({ className, ...props } = {}, ref = null) => ({
|
25
|
-
ref,
|
26
|
-
className: cx("ui-chart__container", className, propClassName),
|
27
|
-
...props,
|
28
|
-
...reChartsProps
|
29
|
-
}),
|
30
|
-
[propClassName, reChartsProps]
|
31
|
-
);
|
32
|
-
return {
|
33
|
-
getContainerProps
|
34
|
-
};
|
35
|
-
};
|
36
|
-
var useLegend = ({} = {}) => {
|
37
|
-
const { styles } = useChartContext();
|
38
|
-
return {
|
39
|
-
styles
|
40
|
-
};
|
41
|
-
};
|
42
|
-
var useTooltip = ({} = {}) => {
|
43
|
-
const { styles } = useChartContext();
|
44
|
-
return {
|
45
|
-
styles
|
46
|
-
};
|
47
|
-
};
|
48
|
-
|
49
|
-
export {
|
50
|
-
ChartProvider,
|
51
|
-
useChartContext,
|
52
|
-
useChart,
|
53
|
-
useLegend,
|
54
|
-
useTooltip
|
55
|
-
};
|
56
|
-
//# sourceMappingURL=chunk-XIFDRM7J.mjs.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/use-chart.ts"],"sourcesContent":["import { useTheme, type CSSUIObject } from \"@yamada-ui/core\"\nimport type { Dict } from \"@yamada-ui/utils\"\nimport { createContext, cx } from \"@yamada-ui/utils\"\nimport { useCallback } from \"react\"\nimport type * as Recharts from \"recharts\"\nimport { getComponentProps } from \"./chart-utils\"\nimport type { ChartPropGetter, ResponsiveContainerProps } from \"./chart.types\"\nimport { containerProperties } from \"./rechart-properties\"\n\ntype ChartContext = { styles: Record<string, CSSUIObject> }\n\nexport const [ChartProvider, useChartContext] = createContext<ChartContext>({\n name: \"ChartContext\",\n errorMessage: `useChartContext returned is 'undefined'. Seems you forgot to wrap the components in \"<LineChart />\" or \"<BarChart />\" etc.`,\n})\n\nexport type UseChartProps = {\n /**\n * Props passed down to recharts `ResponsiveContainer` component.\n */\n containerProps?: ResponsiveContainerProps\n}\n\nexport const useChart = ({ containerProps = {} }: UseChartProps) => {\n const { theme } = useTheme()\n const [reChartsProps, propClassName] = getComponentProps<Dict, string>([\n containerProps,\n containerProperties,\n ])(theme)\n\n const getContainerProps: ChartPropGetter<\n \"div\",\n Partial<Omit<Recharts.ResponsiveContainerProps, \"children\">>,\n Omit<Recharts.ResponsiveContainerProps, \"children\">\n > = useCallback(\n ({ className, ...props } = {}, ref = null) => ({\n ref,\n className: cx(\"ui-chart__container\", className as string, propClassName),\n ...props,\n ...reChartsProps,\n }),\n [propClassName, reChartsProps],\n )\n\n return {\n getContainerProps,\n }\n}\n\nexport type UseChartReturn = ReturnType<typeof useChart>\n\nexport type UseLegendProps = {}\n\nexport const useLegend = ({}: UseLegendProps = {}) => {\n const { styles } = useChartContext()\n return {\n styles,\n }\n}\nexport type UseLegendReturn = ReturnType<typeof useLegend>\n\nexport type UseTooltipProps = {}\n\nexport const useTooltip = ({}: UseTooltipProps = {}) => {\n const { styles } = useChartContext()\n return {\n styles,\n }\n}\nexport type UseTooltipReturn = ReturnType<typeof useTooltip>\n"],"mappings":";;;;;;;;;AAAA,SAAS,gBAAkC;AAE3C,SAAS,eAAe,UAAU;AAClC,SAAS,mBAAmB;AAQrB,IAAM,CAAC,eAAe,eAAe,IAAI,cAA4B;AAAA,EAC1E,MAAM;AAAA,EACN,cAAc;AAChB,CAAC;AASM,IAAM,WAAW,CAAC,EAAE,iBAAiB,CAAC,EAAE,MAAqB;AAClE,QAAM,EAAE,MAAM,IAAI,SAAS;AAC3B,QAAM,CAAC,eAAe,aAAa,IAAI,kBAAgC;AAAA,IACrE;AAAA,IACA;AAAA,EACF,CAAC,EAAE,KAAK;AAER,QAAM,oBAIF;AAAA,IACF,CAAC,EAAE,WAAW,GAAG,MAAM,IAAI,CAAC,GAAG,MAAM,UAAU;AAAA,MAC7C;AAAA,MACA,WAAW,GAAG,uBAAuB,WAAqB,aAAa;AAAA,MACvE,GAAG;AAAA,MACH,GAAG;AAAA,IACL;AAAA,IACA,CAAC,eAAe,aAAa;AAAA,EAC/B;AAEA,SAAO;AAAA,IACL;AAAA,EACF;AACF;AAMO,IAAM,YAAY,CAAC,CAAC,IAAoB,CAAC,MAAM;AACpD,QAAM,EAAE,OAAO,IAAI,gBAAgB;AACnC,SAAO;AAAA,IACL;AAAA,EACF;AACF;AAKO,IAAM,aAAa,CAAC,CAAC,IAAqB,CAAC,MAAM;AACtD,QAAM,EAAE,OAAO,IAAI,gBAAgB;AACnC,SAAO;AAAA,IACL;AAAA,EACF;AACF;","names":[]}
|
package/dist/donut-chart.d.mts
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
import * as _yamada_ui_core from '@yamada-ui/core';
|
2
|
-
import { PieChartProps } from './pie-chart.mjs';
|
3
|
-
import './chart.types.mjs';
|
4
|
-
import '@yamada-ui/utils';
|
5
|
-
import 'react';
|
6
|
-
import 'recharts';
|
7
|
-
import './use-chart.mjs';
|
8
|
-
import './use-chart-legend.mjs';
|
9
|
-
import './use-chart-tooltip.mjs';
|
10
|
-
import './use-pie-chart.mjs';
|
11
|
-
import 'recharts/types/chart/generateCategoricalChart';
|
12
|
-
|
13
|
-
type DonutChartOptions = {
|
14
|
-
/**
|
15
|
-
* Controls innerRadius of the chart segments.
|
16
|
-
* If it is a number, it is the width of the radius.
|
17
|
-
* For example, `60` means the radius is `60px` and the diameter is `120px`.
|
18
|
-
*
|
19
|
-
* @default '60%'
|
20
|
-
*/
|
21
|
-
innerRadius?: number | string;
|
22
|
-
};
|
23
|
-
type DonutChartProps = PieChartProps & DonutChartOptions;
|
24
|
-
/**
|
25
|
-
* `DonutChart` is a component for drawing donut charts to compare multiple sets of data.
|
26
|
-
*
|
27
|
-
* @see Docs https://yamada-ui.com/components/feedback/donut-chart
|
28
|
-
*/
|
29
|
-
declare const DonutChart: _yamada_ui_core.Component<"div", DonutChartProps>;
|
30
|
-
|
31
|
-
export { DonutChart, type DonutChartProps };
|
package/dist/donut-chart.d.ts
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
import * as _yamada_ui_core from '@yamada-ui/core';
|
2
|
-
import { PieChartProps } from './pie-chart.js';
|
3
|
-
import './chart.types.js';
|
4
|
-
import '@yamada-ui/utils';
|
5
|
-
import 'react';
|
6
|
-
import 'recharts';
|
7
|
-
import './use-chart.js';
|
8
|
-
import './use-chart-legend.js';
|
9
|
-
import './use-chart-tooltip.js';
|
10
|
-
import './use-pie-chart.js';
|
11
|
-
import 'recharts/types/chart/generateCategoricalChart';
|
12
|
-
|
13
|
-
type DonutChartOptions = {
|
14
|
-
/**
|
15
|
-
* Controls innerRadius of the chart segments.
|
16
|
-
* If it is a number, it is the width of the radius.
|
17
|
-
* For example, `60` means the radius is `60px` and the diameter is `120px`.
|
18
|
-
*
|
19
|
-
* @default '60%'
|
20
|
-
*/
|
21
|
-
innerRadius?: number | string;
|
22
|
-
};
|
23
|
-
type DonutChartProps = PieChartProps & DonutChartOptions;
|
24
|
-
/**
|
25
|
-
* `DonutChart` is a component for drawing donut charts to compare multiple sets of data.
|
26
|
-
*
|
27
|
-
* @see Docs https://yamada-ui.com/components/feedback/donut-chart
|
28
|
-
*/
|
29
|
-
declare const DonutChart: _yamada_ui_core.Component<"div", DonutChartProps>;
|
30
|
-
|
31
|
-
export { DonutChart, type DonutChartProps };
|