@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-LHI57S6P.mjs
DELETED
@@ -1,215 +0,0 @@
|
|
1
|
-
"use client"
|
2
|
-
import {
|
3
|
-
pieChartProperties,
|
4
|
-
pieProperties
|
5
|
-
} from "./chunk-OSNFBRHL.mjs";
|
6
|
-
import {
|
7
|
-
getClassName,
|
8
|
-
getComponentProps
|
9
|
-
} from "./chunk-QL3DB7OJ.mjs";
|
10
|
-
|
11
|
-
// src/use-pie-chart.ts
|
12
|
-
import { useTheme } from "@yamada-ui/core";
|
13
|
-
import { cx } from "@yamada-ui/utils";
|
14
|
-
import { useCallback, useMemo, useState } from "react";
|
15
|
-
var usePieChart = ({
|
16
|
-
data,
|
17
|
-
withLabels = false,
|
18
|
-
withLabelLines = false,
|
19
|
-
strokeWidth = 1,
|
20
|
-
fillOpacity = 1,
|
21
|
-
innerRadius = "0%",
|
22
|
-
outerRadius = withLabels ? "80%" : "100%",
|
23
|
-
paddingAngle = 0,
|
24
|
-
startAngle = 90,
|
25
|
-
endAngle = -270,
|
26
|
-
styles,
|
27
|
-
...rest
|
28
|
-
}) => {
|
29
|
-
var _a, _b;
|
30
|
-
const { theme } = useTheme();
|
31
|
-
const [highlightedArea, setHighlightedArea] = useState(null);
|
32
|
-
const shouldHighlight = highlightedArea !== null;
|
33
|
-
const { dimCell, ...computedCellProps } = (_a = rest.cellProps) != null ? _a : {};
|
34
|
-
const {
|
35
|
-
activeShape = {},
|
36
|
-
inactiveShape = {},
|
37
|
-
label,
|
38
|
-
labelLine,
|
39
|
-
...computedPieProps
|
40
|
-
} = (_b = rest.pieProps) != null ? _b : {};
|
41
|
-
const cellColors = useMemo(
|
42
|
-
() => data.map(({ color }, index) => ({
|
43
|
-
__prefix: "ui",
|
44
|
-
name: `cell-${index}`,
|
45
|
-
token: "colors",
|
46
|
-
value: color != null ? color : "transparent"
|
47
|
-
})),
|
48
|
-
[data]
|
49
|
-
);
|
50
|
-
const pieVars = useMemo(
|
51
|
-
() => [
|
52
|
-
...cellColors,
|
53
|
-
{ __prefix: "ui", name: "fill-opacity", value: fillOpacity }
|
54
|
-
],
|
55
|
-
[fillOpacity, cellColors]
|
56
|
-
);
|
57
|
-
const [chartProps, chartClassName] = useMemo(
|
58
|
-
() => {
|
59
|
-
var _a2;
|
60
|
-
return getComponentProps(
|
61
|
-
[(_a2 = rest.chartProps) != null ? _a2 : {}, pieChartProperties],
|
62
|
-
styles.chart
|
63
|
-
)(theme);
|
64
|
-
},
|
65
|
-
[rest.chartProps, styles.chart, theme]
|
66
|
-
);
|
67
|
-
const [pieProps, pieClassName] = useMemo(
|
68
|
-
() => getComponentProps(
|
69
|
-
[computedPieProps, pieProperties],
|
70
|
-
styles.pie
|
71
|
-
)(theme),
|
72
|
-
[computedPieProps, styles.pie, theme]
|
73
|
-
);
|
74
|
-
const cellClassName = useMemo(() => {
|
75
|
-
const resolvedCellProps = {
|
76
|
-
fillOpacity: "var(--ui-fill-opacity)",
|
77
|
-
...styles.cell,
|
78
|
-
...computedCellProps
|
79
|
-
};
|
80
|
-
return getClassName(resolvedCellProps)(theme);
|
81
|
-
}, [computedCellProps, styles.cell, theme]);
|
82
|
-
const dimCellClassName = useMemo(() => {
|
83
|
-
const resolvedDimCell = { fillOpacity: 0.3, strokeOpacity: 0, ...dimCell };
|
84
|
-
return getClassName(resolvedDimCell)(theme);
|
85
|
-
}, [dimCell, theme]);
|
86
|
-
const activeShapeProps = useMemo(
|
87
|
-
() => getComponentProps(
|
88
|
-
[{ _focus: { outline: "none" }, ...activeShape }, pieProperties],
|
89
|
-
styles.activeShape
|
90
|
-
)(theme, true),
|
91
|
-
[activeShape, styles.activeShape, theme]
|
92
|
-
);
|
93
|
-
const inactiveShapeProps = useMemo(
|
94
|
-
() => getComponentProps(
|
95
|
-
[inactiveShape, pieProperties],
|
96
|
-
styles.inactiveShape
|
97
|
-
)(theme, true),
|
98
|
-
[inactiveShape, styles.inactiveShape, theme]
|
99
|
-
);
|
100
|
-
const labelClassName = useMemo(
|
101
|
-
() => getClassName({ fillOpacity: 1, ...styles.label, ...label })(theme),
|
102
|
-
[label, styles.label, theme]
|
103
|
-
);
|
104
|
-
const labelLineClassName = useMemo(
|
105
|
-
() => getClassName({ ...styles.labelLine, ...labelLine })(theme),
|
106
|
-
[labelLine, styles.labelLine, theme]
|
107
|
-
);
|
108
|
-
const cellPropList = useMemo(
|
109
|
-
() => data.map((props, index) => {
|
110
|
-
const { name, dimCell: dimCell2 = {}, ...computedProps } = props;
|
111
|
-
const color = `var(--ui-cell-${index})`;
|
112
|
-
const dimmed = shouldHighlight && highlightedArea !== name;
|
113
|
-
const resolvedProps = {
|
114
|
-
...computedProps,
|
115
|
-
...dimmed ? dimCell2 : {}
|
116
|
-
};
|
117
|
-
const className = getClassName(
|
118
|
-
{
|
119
|
-
cellClassName,
|
120
|
-
...resolvedProps
|
121
|
-
},
|
122
|
-
dimmed ? dimCellClassName : void 0
|
123
|
-
)(theme);
|
124
|
-
return {
|
125
|
-
color,
|
126
|
-
className
|
127
|
-
};
|
128
|
-
}),
|
129
|
-
[
|
130
|
-
cellClassName,
|
131
|
-
data,
|
132
|
-
dimCellClassName,
|
133
|
-
highlightedArea,
|
134
|
-
shouldHighlight,
|
135
|
-
theme
|
136
|
-
]
|
137
|
-
);
|
138
|
-
const getPieChartProps = useCallback(
|
139
|
-
({ className, ...props } = {}, ref = null) => ({
|
140
|
-
ref,
|
141
|
-
className: cx(className, chartClassName),
|
142
|
-
...props,
|
143
|
-
...chartProps
|
144
|
-
}),
|
145
|
-
[chartProps, chartClassName]
|
146
|
-
);
|
147
|
-
const getPieProps = useCallback(
|
148
|
-
({
|
149
|
-
className,
|
150
|
-
labelClassName: labelClassNameProp,
|
151
|
-
labelLineClassName: labelLineClassNameProp,
|
152
|
-
...props
|
153
|
-
}, ref = null) => ({
|
154
|
-
ref,
|
155
|
-
className: cx(className, pieClassName),
|
156
|
-
dataKey: "value",
|
157
|
-
data,
|
158
|
-
rootTabIndex: -1,
|
159
|
-
outerRadius,
|
160
|
-
innerRadius,
|
161
|
-
paddingAngle,
|
162
|
-
startAngle,
|
163
|
-
endAngle,
|
164
|
-
isAnimationActive: false,
|
165
|
-
label: withLabels ? { className: cx(labelClassNameProp, labelClassName) } : false,
|
166
|
-
labelLine: withLabelLines ? { className: cx(labelLineClassNameProp, labelLineClassName) } : false,
|
167
|
-
activeShape: activeShapeProps,
|
168
|
-
inactiveShape: inactiveShapeProps,
|
169
|
-
...props,
|
170
|
-
...pieProps
|
171
|
-
}),
|
172
|
-
[
|
173
|
-
pieClassName,
|
174
|
-
data,
|
175
|
-
outerRadius,
|
176
|
-
innerRadius,
|
177
|
-
paddingAngle,
|
178
|
-
startAngle,
|
179
|
-
endAngle,
|
180
|
-
withLabels,
|
181
|
-
labelClassName,
|
182
|
-
withLabelLines,
|
183
|
-
labelLineClassName,
|
184
|
-
activeShapeProps,
|
185
|
-
inactiveShapeProps,
|
186
|
-
pieProps
|
187
|
-
]
|
188
|
-
);
|
189
|
-
const getCellProps = useCallback(
|
190
|
-
({ index, className: classNameProp, ...props }, ref = null) => {
|
191
|
-
const { className, color } = cellPropList[index];
|
192
|
-
return {
|
193
|
-
ref,
|
194
|
-
className: cx(classNameProp, className),
|
195
|
-
fill: color,
|
196
|
-
stroke: color,
|
197
|
-
strokeWidth,
|
198
|
-
...props
|
199
|
-
};
|
200
|
-
},
|
201
|
-
[cellPropList, strokeWidth]
|
202
|
-
);
|
203
|
-
return {
|
204
|
-
pieVars,
|
205
|
-
getPieProps,
|
206
|
-
getPieChartProps,
|
207
|
-
getCellProps,
|
208
|
-
setHighlightedArea
|
209
|
-
};
|
210
|
-
};
|
211
|
-
|
212
|
-
export {
|
213
|
-
usePieChart
|
214
|
-
};
|
215
|
-
//# sourceMappingURL=chunk-LHI57S6P.mjs.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/use-pie-chart.ts"],"sourcesContent":["import { useTheme, type CSSUIObject, type CSSUIProps } from \"@yamada-ui/core\"\nimport { cx, type Dict } from \"@yamada-ui/utils\"\nimport type { ComponentPropsWithoutRef } from \"react\"\nimport { useCallback, useMemo, useState } from \"react\"\nimport type * as Recharts from \"recharts\"\nimport { getClassName, getComponentProps } from \"./chart-utils\"\nimport type {\n CellProps,\n ChartPropGetter,\n PieChartProps,\n PieProps,\n RequiredChartPropGetter,\n} from \"./chart.types\"\nimport { pieChartProperties, pieProperties } from \"./rechart-properties\"\n\nexport type UsePieChartOptions = {\n /**\n * Chart data.\n */\n data: CellProps[]\n /**\n * Props passed down to recharts `PieChart` component.\n */\n chartProps?: PieChartProps\n /**\n * Props for the pie.\n */\n pieProps?: Partial<PieProps>\n /**\n * Props for the cell.\n */\n cellProps?: Partial<CellProps>\n /**\n * Determines whether each segment should have associated label.\n *\n * @default false\n */\n withLabels?: boolean\n /**\n * Determines whether segments labels should have lines that connect the segment with the label.\n *\n * @default false\n */\n withLabelLines?: boolean\n /**\n * Controls innerRadius of the chart segments.\n * If it is a number, it is the width of the radius.\n * For example, `60` means the radius is `60px` and the diameter is `120px`.\n *\n * @default '0%'\n */\n innerRadius?: number | string\n /**\n * Controls thickness of the chart segments. If it is a number, it is calculated as px.\n * If it is a number, it is the width of the radius.\n * For example, `60` means the radius is `60px` and the diameter is `120px`.\n *\n * @default '80%'\n */\n outerRadius?: number | string\n /**\n * Controls padding between segments.\n *\n * @default 0\n */\n paddingAngle?: number\n /**\n * Stroke width for the chart pies.\n *\n * @default 1\n */\n strokeWidth?: number\n /**\n * Controls angle at which chart starts.\n *\n * @default 90\n */\n startAngle?: number\n /**\n * Controls angle at which chart ends.\n *\n * @default -270\n */\n endAngle?: number\n /**\n * Controls fill opacity of all pies.\n *\n * @default 1\n */\n fillOpacity?: number | [number, number]\n /**\n * A function to format values inside the tooltip.\n */\n valueFormatter?: (value: number) => string\n}\n\ntype UsePieChartProps = UsePieChartOptions & {\n styles: Dict<CSSUIObject>\n}\n\nexport const usePieChart = ({\n data,\n withLabels = false,\n withLabelLines = false,\n strokeWidth = 1,\n fillOpacity = 1,\n innerRadius = \"0%\",\n outerRadius = withLabels ? \"80%\" : \"100%\",\n paddingAngle = 0,\n startAngle = 90,\n endAngle = -270,\n styles,\n ...rest\n}: UsePieChartProps) => {\n const { theme } = useTheme()\n const [highlightedArea, setHighlightedArea] = useState<string | null>(null)\n const shouldHighlight = highlightedArea !== null\n const { dimCell, ...computedCellProps } = rest.cellProps ?? {}\n const {\n activeShape = {},\n inactiveShape = {},\n label,\n labelLine,\n ...computedPieProps\n } = rest.pieProps ?? {}\n\n const cellColors: CSSUIProps[\"var\"] = useMemo(\n () =>\n data.map(({ color }, index) => ({\n __prefix: \"ui\",\n name: `cell-${index}`,\n token: \"colors\",\n value: color ?? \"transparent\",\n })),\n [data],\n )\n\n const pieVars: CSSUIProps[\"var\"] = useMemo(\n () =>\n [\n ...cellColors,\n { __prefix: \"ui\", name: \"fill-opacity\", value: fillOpacity },\n ] as Required<CSSUIProps>[\"var\"],\n [fillOpacity, cellColors],\n )\n\n const [chartProps, chartClassName] = useMemo(\n () =>\n getComponentProps<Dict, string>(\n [rest.chartProps ?? {}, pieChartProperties],\n styles.chart,\n )(theme),\n [rest.chartProps, styles.chart, theme],\n )\n\n const [pieProps, pieClassName] = useMemo(\n () =>\n getComponentProps<Dict, string>(\n [computedPieProps, pieProperties],\n styles.pie,\n )(theme),\n [computedPieProps, styles.pie, theme],\n )\n\n const cellClassName = useMemo(() => {\n const resolvedCellProps = {\n fillOpacity: \"var(--ui-fill-opacity)\",\n ...styles.cell,\n ...computedCellProps,\n }\n\n return getClassName(resolvedCellProps)(theme)\n }, [computedCellProps, styles.cell, theme])\n\n const dimCellClassName = useMemo(() => {\n const resolvedDimCell = { fillOpacity: 0.3, strokeOpacity: 0, ...dimCell }\n\n return getClassName(resolvedDimCell)(theme)\n }, [dimCell, theme])\n\n const activeShapeProps = useMemo(\n () =>\n getComponentProps<Dict, string>(\n [{ _focus: { outline: \"none\" }, ...activeShape }, pieProperties],\n styles.activeShape,\n )(theme, true),\n [activeShape, styles.activeShape, theme],\n )\n\n const inactiveShapeProps = useMemo(\n () =>\n getComponentProps<Dict, string>(\n [inactiveShape, pieProperties],\n styles.inactiveShape,\n )(theme, true),\n [inactiveShape, styles.inactiveShape, theme],\n )\n\n const labelClassName = useMemo(\n () => getClassName({ fillOpacity: 1, ...styles.label, ...label })(theme),\n [label, styles.label, theme],\n )\n\n const labelLineClassName = useMemo(\n () => getClassName({ ...styles.labelLine, ...labelLine })(theme),\n [labelLine, styles.labelLine, theme],\n )\n\n const cellPropList = useMemo(\n () =>\n data.map((props, index) => {\n const { name, dimCell = {}, ...computedProps } = props\n const color = `var(--ui-cell-${index})`\n const dimmed = shouldHighlight && highlightedArea !== name\n const resolvedProps = {\n ...computedProps,\n ...(dimmed ? dimCell : {}),\n }\n\n const className = getClassName(\n {\n cellClassName,\n ...resolvedProps,\n },\n dimmed ? dimCellClassName : undefined,\n )(theme)\n\n return {\n color,\n className,\n }\n }),\n [\n cellClassName,\n data,\n dimCellClassName,\n highlightedArea,\n shouldHighlight,\n theme,\n ],\n )\n\n const getPieChartProps: ChartPropGetter<\n \"div\",\n ComponentPropsWithoutRef<typeof Recharts.PieChart>,\n ComponentPropsWithoutRef<typeof Recharts.PieChart>\n > = useCallback(\n ({ className, ...props } = {}, ref = null) => ({\n ref,\n className: cx(className, chartClassName),\n ...props,\n ...chartProps,\n }),\n [chartProps, chartClassName],\n )\n\n const getPieProps: RequiredChartPropGetter<\n \"div\",\n Partial<Recharts.PieProps> & {\n labelClassName: string\n labelLineClassName: string\n },\n Omit<Recharts.PieProps, \"ref\">\n > = useCallback(\n (\n {\n className,\n labelClassName: labelClassNameProp,\n labelLineClassName: labelLineClassNameProp,\n ...props\n },\n ref = null,\n ) => ({\n ref,\n className: cx(className, pieClassName),\n dataKey: \"value\",\n data,\n rootTabIndex: -1,\n outerRadius,\n innerRadius,\n paddingAngle,\n startAngle,\n endAngle,\n isAnimationActive: false,\n label: withLabels\n ? { className: cx(labelClassNameProp, labelClassName) }\n : false,\n labelLine: withLabelLines\n ? { className: cx(labelLineClassNameProp, labelLineClassName) }\n : false,\n activeShape: activeShapeProps,\n inactiveShape: inactiveShapeProps,\n ...(props as Omit<Recharts.PieProps, \"dataKey\">),\n ...pieProps,\n }),\n [\n pieClassName,\n data,\n outerRadius,\n innerRadius,\n paddingAngle,\n startAngle,\n endAngle,\n withLabels,\n labelClassName,\n withLabelLines,\n labelLineClassName,\n activeShapeProps,\n inactiveShapeProps,\n pieProps,\n ],\n )\n\n const getCellProps: RequiredChartPropGetter<\n \"div\",\n Omit<Recharts.CellProps, \"ref\"> & { index: number },\n Omit<Recharts.CellProps, \"ref\">\n > = useCallback(\n ({ index, className: classNameProp, ...props }, ref = null) => {\n const { className, color } = cellPropList[index]\n\n return {\n ref,\n className: cx(classNameProp, className),\n fill: color,\n stroke: color,\n strokeWidth,\n ...(props as Recharts.CellProps),\n }\n },\n [cellPropList, strokeWidth],\n )\n\n return {\n pieVars,\n getPieProps,\n getPieChartProps,\n getCellProps,\n setHighlightedArea,\n }\n}\n\nexport type UsePieChartReturn = ReturnType<typeof usePieChart>\n"],"mappings":"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","names":["_a","dimCell"]}
|
package/dist/chunk-LM2DQK2P.mjs
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
"use client"
|
2
|
-
import {
|
3
|
-
legendProperties
|
4
|
-
} from "./chunk-OSNFBRHL.mjs";
|
5
|
-
|
6
|
-
// src/use-chart-legend.ts
|
7
|
-
import { splitObject } from "@yamada-ui/utils";
|
8
|
-
import { useCallback } from "react";
|
9
|
-
var useChartLegend = ({
|
10
|
-
legendProps: _legendProps = {}
|
11
|
-
}) => {
|
12
|
-
const [rest, legendProps] = splitObject(
|
13
|
-
_legendProps,
|
14
|
-
legendProperties
|
15
|
-
);
|
16
|
-
const getLegendProps = useCallback(
|
17
|
-
(props, ref = null) => {
|
18
|
-
return {
|
19
|
-
ref,
|
20
|
-
verticalAlign: "top",
|
21
|
-
...props,
|
22
|
-
...rest
|
23
|
-
};
|
24
|
-
},
|
25
|
-
[rest]
|
26
|
-
);
|
27
|
-
return { legendProps, getLegendProps };
|
28
|
-
};
|
29
|
-
|
30
|
-
export {
|
31
|
-
useChartLegend
|
32
|
-
};
|
33
|
-
//# sourceMappingURL=chunk-LM2DQK2P.mjs.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/use-chart-legend.ts"],"sourcesContent":["import type { Dict } from \"@yamada-ui/utils\"\nimport { splitObject } from \"@yamada-ui/utils\"\nimport { useCallback } from \"react\"\nimport type * as Recharts from \"recharts\"\nimport type { ChartPropGetter, LegendProps } from \"./chart.types\"\nimport { legendProperties } from \"./rechart-properties\"\n\nexport type UseChartLegendProps = {\n /**\n * Props passed down to recharts 'Legend' component.\n */\n legendProps?: LegendProps\n}\n\nexport const useChartLegend = ({\n legendProps: _legendProps = {},\n}: UseChartLegendProps) => {\n const [rest, legendProps] = splitObject<Dict, string>(\n _legendProps,\n legendProperties,\n )\n\n const getLegendProps: ChartPropGetter<\n \"div\",\n Partial<Recharts.LegendProps>,\n Omit<Recharts.LegendProps, \"ref\">\n > = useCallback(\n (props, ref = null) => {\n return {\n ref,\n verticalAlign: \"top\",\n ...props,\n ...rest,\n }\n },\n [rest],\n )\n\n return { legendProps, getLegendProps }\n}\n"],"mappings":";;;;;;AACA,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB;AAYrB,IAAM,iBAAiB,CAAC;AAAA,EAC7B,aAAa,eAAe,CAAC;AAC/B,MAA2B;AACzB,QAAM,CAAC,MAAM,WAAW,IAAI;AAAA,IAC1B;AAAA,IACA;AAAA,EACF;AAEA,QAAM,iBAIF;AAAA,IACF,CAAC,OAAO,MAAM,SAAS;AACrB,aAAO;AAAA,QACL;AAAA,QACA,eAAe;AAAA,QACf,GAAG;AAAA,QACH,GAAG;AAAA,MACL;AAAA,IACF;AAAA,IACA,CAAC,IAAI;AAAA,EACP;AAEA,SAAO,EAAE,aAAa,eAAe;AACvC;","names":[]}
|
package/dist/chunk-MSIOYYWR.mjs
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
"use client"
|
2
|
-
|
3
|
-
// src/area-chart-gradient.tsx
|
4
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
5
|
-
var AreaGradient = ({
|
6
|
-
color,
|
7
|
-
id,
|
8
|
-
withGradient,
|
9
|
-
fillOpacity
|
10
|
-
}) => {
|
11
|
-
if (withGradient) {
|
12
|
-
return /* @__PURE__ */ jsxs("linearGradient", { id, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
13
|
-
/* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: color, stopOpacity: fillOpacity }),
|
14
|
-
/* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: color, stopOpacity: 0.01 })
|
15
|
-
] });
|
16
|
-
} else {
|
17
|
-
return /* @__PURE__ */ jsx("linearGradient", { id, x1: "0", y1: "0", x2: "0", y2: "1", children: /* @__PURE__ */ jsx("stop", { stopColor: color, stopOpacity: fillOpacity }) });
|
18
|
-
}
|
19
|
-
};
|
20
|
-
|
21
|
-
export {
|
22
|
-
AreaGradient
|
23
|
-
};
|
24
|
-
//# sourceMappingURL=chunk-MSIOYYWR.mjs.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/area-chart-gradient.tsx"],"sourcesContent":["export type AreaGradientProps = {\n id?: string\n color?: string\n withGradient?: boolean\n fillOpacity: number | string\n}\n\nexport const AreaGradient = ({\n color,\n id,\n withGradient,\n fillOpacity,\n}: AreaGradientProps) => {\n if (withGradient) {\n return (\n <linearGradient id={id} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n <stop offset=\"0%\" stopColor={color} stopOpacity={fillOpacity} />\n <stop offset=\"100%\" stopColor={color} stopOpacity={0.01} />\n </linearGradient>\n )\n } else {\n return (\n <linearGradient id={id} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n <stop stopColor={color} stopOpacity={fillOpacity} />\n </linearGradient>\n )\n }\n}\n"],"mappings":";;;AAeM,SACE,KADF;AARC,IAAM,eAAe,CAAC;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAyB;AACvB,MAAI,cAAc;AAChB,WACE,qBAAC,oBAAe,IAAQ,IAAG,KAAI,IAAG,KAAI,IAAG,KAAI,IAAG,KAC9C;AAAA,0BAAC,UAAK,QAAO,MAAK,WAAW,OAAO,aAAa,aAAa;AAAA,MAC9D,oBAAC,UAAK,QAAO,QAAO,WAAW,OAAO,aAAa,MAAM;AAAA,OAC3D;AAAA,EAEJ,OAAO;AACL,WACE,oBAAC,oBAAe,IAAQ,IAAG,KAAI,IAAG,KAAI,IAAG,KAAI,IAAG,KAC9C,8BAAC,UAAK,WAAW,OAAO,aAAa,aAAa,GACpD;AAAA,EAEJ;AACF;","names":[]}
|
package/dist/chunk-MWPICUEW.mjs
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
"use client"
|
2
|
-
import {
|
3
|
-
referenceLineProperties
|
4
|
-
} from "./chunk-OSNFBRHL.mjs";
|
5
|
-
import {
|
6
|
-
getComponentProps
|
7
|
-
} from "./chunk-QL3DB7OJ.mjs";
|
8
|
-
|
9
|
-
// src/use-chart-reference-line.ts
|
10
|
-
import { getCSS, useTheme } from "@yamada-ui/core";
|
11
|
-
import { isObject, cx } from "@yamada-ui/utils";
|
12
|
-
import { useCallback, useMemo } from "react";
|
13
|
-
var useChartReferenceLine = ({
|
14
|
-
referenceLineProps = [],
|
15
|
-
styles
|
16
|
-
}) => {
|
17
|
-
const { theme } = useTheme();
|
18
|
-
const styleClassName = getCSS(styles.referenceLine)(theme);
|
19
|
-
const propList = useMemo(
|
20
|
-
() => referenceLineProps.map((props, index) => {
|
21
|
-
const [{ label: labelProp, ...rest }, propClassName] = getComponentProps(
|
22
|
-
[props, referenceLineProperties],
|
23
|
-
styleClassName
|
24
|
-
)(theme);
|
25
|
-
const color = `var(--ui-reference-line-${index})`;
|
26
|
-
const label = {
|
27
|
-
value: labelProp,
|
28
|
-
fill: color,
|
29
|
-
position: "insideBottomLeft",
|
30
|
-
...isObject(labelProp) ? labelProp : {}
|
31
|
-
};
|
32
|
-
return { propClassName, color, label, ...rest };
|
33
|
-
}),
|
34
|
-
[referenceLineProps, styleClassName, theme]
|
35
|
-
);
|
36
|
-
const getReferenceLineProps = useCallback(
|
37
|
-
({ index, className, ...props }, ref = null) => {
|
38
|
-
const { propClassName, color, label, ...rest } = propList[index];
|
39
|
-
return {
|
40
|
-
ref,
|
41
|
-
className: cx(className, propClassName),
|
42
|
-
stroke: color,
|
43
|
-
label,
|
44
|
-
...props,
|
45
|
-
...rest
|
46
|
-
};
|
47
|
-
},
|
48
|
-
[propList]
|
49
|
-
);
|
50
|
-
return { getReferenceLineProps };
|
51
|
-
};
|
52
|
-
|
53
|
-
export {
|
54
|
-
useChartReferenceLine
|
55
|
-
};
|
56
|
-
//# sourceMappingURL=chunk-MWPICUEW.mjs.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/use-chart-reference-line.ts"],"sourcesContent":["import { getCSS, useTheme } from \"@yamada-ui/core\"\nimport type { CSSUIObject } from \"@yamada-ui/core\"\nimport type { Dict } from \"@yamada-ui/utils\"\nimport { isObject, cx } from \"@yamada-ui/utils\"\nimport { useCallback, useMemo } from \"react\"\nimport type * as Recharts from \"recharts\"\nimport { getComponentProps } from \"./chart-utils\"\nimport type { ReferenceLineProps, RequiredChartPropGetter } from \"./chart.types\"\nimport { referenceLineProperties } from \"./rechart-properties\"\n\nexport type UseChartReferenceLineOptions = {\n /**\n * Reference lines that should be displayed on the chart.\n */\n referenceLineProps?: ReferenceLineProps[]\n}\n\ntype UseChartReferenceLineProps = UseChartReferenceLineOptions & {\n styles: Dict<CSSUIObject>\n}\n\nexport const useChartReferenceLine = ({\n referenceLineProps = [],\n styles,\n}: UseChartReferenceLineProps) => {\n const { theme } = useTheme()\n const styleClassName = getCSS(styles.referenceLine)(theme)\n const propList = useMemo(\n () =>\n referenceLineProps.map((props, index) => {\n const [{ label: labelProp, ...rest }, propClassName] =\n getComponentProps(\n [props, referenceLineProperties],\n styleClassName,\n )(theme)\n\n const color = `var(--ui-reference-line-${index})`\n const label: Recharts.ReferenceLineProps[\"label\"] = {\n value: labelProp as string,\n fill: color,\n position: \"insideBottomLeft\",\n ...(isObject(labelProp) ? labelProp : {}),\n }\n\n return { propClassName, color, label, ...rest }\n }),\n [referenceLineProps, styleClassName, theme],\n )\n\n const getReferenceLineProps: RequiredChartPropGetter<\n \"div\",\n {\n index: number\n },\n Omit<Recharts.ReferenceLineProps, \"ref\">\n > = useCallback(\n ({ index, className, ...props }, ref = null) => {\n const { propClassName, color, label, ...rest } = propList[index]\n\n return {\n ref,\n className: cx(className, propClassName),\n stroke: color,\n label,\n ...(props as Recharts.ReferenceLineProps),\n ...rest,\n }\n },\n [propList],\n )\n\n return { getReferenceLineProps }\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,QAAQ,gBAAgB;AAGjC,SAAS,UAAU,UAAU;AAC7B,SAAS,aAAa,eAAe;AAiB9B,IAAM,wBAAwB,CAAC;AAAA,EACpC,qBAAqB,CAAC;AAAA,EACtB;AACF,MAAkC;AAChC,QAAM,EAAE,MAAM,IAAI,SAAS;AAC3B,QAAM,iBAAiB,OAAO,OAAO,aAAa,EAAE,KAAK;AACzD,QAAM,WAAW;AAAA,IACf,MACE,mBAAmB,IAAI,CAAC,OAAO,UAAU;AACvC,YAAM,CAAC,EAAE,OAAO,WAAW,GAAG,KAAK,GAAG,aAAa,IACjD;AAAA,QACE,CAAC,OAAO,uBAAuB;AAAA,QAC/B;AAAA,MACF,EAAE,KAAK;AAET,YAAM,QAAQ,2BAA2B,KAAK;AAC9C,YAAM,QAA8C;AAAA,QAClD,OAAO;AAAA,QACP,MAAM;AAAA,QACN,UAAU;AAAA,QACV,GAAI,SAAS,SAAS,IAAI,YAAY,CAAC;AAAA,MACzC;AAEA,aAAO,EAAE,eAAe,OAAO,OAAO,GAAG,KAAK;AAAA,IAChD,CAAC;AAAA,IACH,CAAC,oBAAoB,gBAAgB,KAAK;AAAA,EAC5C;AAEA,QAAM,wBAMF;AAAA,IACF,CAAC,EAAE,OAAO,WAAW,GAAG,MAAM,GAAG,MAAM,SAAS;AAC9C,YAAM,EAAE,eAAe,OAAO,OAAO,GAAG,KAAK,IAAI,SAAS,KAAK;AAE/D,aAAO;AAAA,QACL;AAAA,QACA,WAAW,GAAG,WAAW,aAAa;AAAA,QACtC,QAAQ;AAAA,QACR;AAAA,QACA,GAAI;AAAA,QACJ,GAAG;AAAA,MACL;AAAA,IACF;AAAA,IACA,CAAC,QAAQ;AAAA,EACX;AAEA,SAAO,EAAE,sBAAsB;AACjC;","names":[]}
|
package/dist/chunk-NEGDEVRX.mjs
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
"use client"
|
2
|
-
import {
|
3
|
-
useLegend
|
4
|
-
} from "./chunk-XIFDRM7J.mjs";
|
5
|
-
|
6
|
-
// src/chart-legend.tsx
|
7
|
-
import { forwardRef, ui } from "@yamada-ui/core";
|
8
|
-
import { cx } from "@yamada-ui/utils";
|
9
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
10
|
-
var ChartLegend = forwardRef(
|
11
|
-
({ className, payload = [], onHighlight, ...rest }, ref) => {
|
12
|
-
const { styles } = useLegend();
|
13
|
-
const items = payload.map(({ dataKey, value: valueProp, color }, index) => {
|
14
|
-
const value = dataKey != null ? dataKey : valueProp;
|
15
|
-
return /* @__PURE__ */ jsxs(
|
16
|
-
ui.div,
|
17
|
-
{
|
18
|
-
className: "ui-chart__legend-item",
|
19
|
-
onMouseEnter: () => onHighlight(value),
|
20
|
-
onMouseLeave: () => onHighlight(null),
|
21
|
-
__css: styles.legendItem,
|
22
|
-
children: [
|
23
|
-
/* @__PURE__ */ jsx(
|
24
|
-
ui.div,
|
25
|
-
{
|
26
|
-
className: "ui-chart__legend-swatch",
|
27
|
-
background: color,
|
28
|
-
__css: styles.legendSwatch
|
29
|
-
}
|
30
|
-
),
|
31
|
-
/* @__PURE__ */ jsx(ui.span, { className: "ui-chart__legend-label", children: value })
|
32
|
-
]
|
33
|
-
},
|
34
|
-
`legend-${index}`
|
35
|
-
);
|
36
|
-
});
|
37
|
-
return /* @__PURE__ */ jsx(
|
38
|
-
ui.div,
|
39
|
-
{
|
40
|
-
ref,
|
41
|
-
className: cx("ui-chart__legend", className),
|
42
|
-
__css: styles.legend,
|
43
|
-
...rest,
|
44
|
-
children: items
|
45
|
-
}
|
46
|
-
);
|
47
|
-
}
|
48
|
-
);
|
49
|
-
|
50
|
-
export {
|
51
|
-
ChartLegend
|
52
|
-
};
|
53
|
-
//# sourceMappingURL=chunk-NEGDEVRX.mjs.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/chart-legend.tsx"],"sourcesContent":["import type { HTMLUIProps } from \"@yamada-ui/core\"\nimport { forwardRef, ui } from \"@yamada-ui/core\"\nimport { cx, type Dict } from \"@yamada-ui/utils\"\nimport { useLegend } from \"./use-chart\"\n\ntype ChartLegendOptions = {\n payload?: Dict[]\n onHighlight: (area: string | null) => void\n}\n\nexport type ChartLegendProps = HTMLUIProps<\"div\"> & ChartLegendOptions\n\nexport const ChartLegend = forwardRef<ChartLegendProps, \"div\">(\n ({ className, payload = [], onHighlight, ...rest }, ref) => {\n const { styles } = useLegend()\n\n const items = payload.map(({ dataKey, value: valueProp, color }, index) => {\n const value = dataKey ?? valueProp\n\n return (\n <ui.div\n className=\"ui-chart__legend-item\"\n key={`legend-${index}`}\n onMouseEnter={() => onHighlight(value)}\n onMouseLeave={() => onHighlight(null)}\n __css={styles.legendItem}\n >\n <ui.div\n className=\"ui-chart__legend-swatch\"\n background={color}\n __css={styles.legendSwatch}\n />\n\n <ui.span className=\"ui-chart__legend-label\">{value}</ui.span>\n </ui.div>\n )\n })\n\n return (\n <ui.div\n ref={ref}\n className={cx(\"ui-chart__legend\", className)}\n __css={styles.legend}\n {...rest}\n >\n {items}\n </ui.div>\n )\n },\n)\n"],"mappings":";;;;;;AACA,SAAS,YAAY,UAAU;AAC/B,SAAS,UAAqB;AAkBtB,SAOE,KAPF;AARD,IAAM,cAAc;AAAA,EACzB,CAAC,EAAE,WAAW,UAAU,CAAC,GAAG,aAAa,GAAG,KAAK,GAAG,QAAQ;AAC1D,UAAM,EAAE,OAAO,IAAI,UAAU;AAE7B,UAAM,QAAQ,QAAQ,IAAI,CAAC,EAAE,SAAS,OAAO,WAAW,MAAM,GAAG,UAAU;AACzE,YAAM,QAAQ,4BAAW;AAEzB,aACE;AAAA,QAAC,GAAG;AAAA,QAAH;AAAA,UACC,WAAU;AAAA,UAEV,cAAc,MAAM,YAAY,KAAK;AAAA,UACrC,cAAc,MAAM,YAAY,IAAI;AAAA,UACpC,OAAO,OAAO;AAAA,UAEd;AAAA;AAAA,cAAC,GAAG;AAAA,cAAH;AAAA,gBACC,WAAU;AAAA,gBACV,YAAY;AAAA,gBACZ,OAAO,OAAO;AAAA;AAAA,YAChB;AAAA,YAEA,oBAAC,GAAG,MAAH,EAAQ,WAAU,0BAA0B,iBAAM;AAAA;AAAA;AAAA,QAX9C,UAAU,KAAK;AAAA,MAYtB;AAAA,IAEJ,CAAC;AAED,WACE;AAAA,MAAC,GAAG;AAAA,MAAH;AAAA,QACC;AAAA,QACA,WAAW,GAAG,oBAAoB,SAAS;AAAA,QAC3C,OAAO,OAAO;AAAA,QACb,GAAG;AAAA,QAEH;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;","names":[]}
|