bruv-ui 0.2.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.
- package/dist/area-chart.d.ts +84 -0
- package/dist/area-chart.js +2002 -0
- package/dist/area-chart.js.map +1 -0
- package/dist/bar-chart.d.ts +80 -0
- package/dist/bar-chart.js +2251 -0
- package/dist/bar-chart.js.map +1 -0
- package/dist/chart-background-BK77UXhl.d.ts +9 -0
- package/dist/chart-brush-BoxY9aDm.d.ts +72 -0
- package/dist/chart-dot-8H287EDv.d.ts +17 -0
- package/dist/chart-legend-Dv9pqes-.d.ts +16 -0
- package/dist/chart-tooltip-DajpzJRy.d.ts +68 -0
- package/dist/charts.d.ts +17 -0
- package/dist/charts.js +5097 -0
- package/dist/charts.js.map +1 -0
- package/dist/composed-chart.d.ts +93 -0
- package/dist/composed-chart.js +2338 -0
- package/dist/composed-chart.js.map +1 -0
- package/dist/form-dK_DJRTw.d.ts +43 -0
- package/dist/form-rhf.d.ts +26 -0
- package/dist/form-rhf.js +268 -0
- package/dist/form-rhf.js.map +1 -0
- package/dist/index.d.ts +2881 -0
- package/dist/index.js +9368 -0
- package/dist/index.js.map +1 -0
- package/dist/line-chart.d.ts +81 -0
- package/dist/line-chart.js +1879 -0
- package/dist/line-chart.js.map +1 -0
- package/dist/pie-chart.d.ts +64 -0
- package/dist/pie-chart.js +1094 -0
- package/dist/pie-chart.js.map +1 -0
- package/dist/radar-chart.d.ts +67 -0
- package/dist/radar-chart.js +1318 -0
- package/dist/radar-chart.js.map +1 -0
- package/dist/radial-chart.d.ts +56 -0
- package/dist/radial-chart.js +1051 -0
- package/dist/radial-chart.js.map +1 -0
- package/dist/sankey-chart.d.ts +58 -0
- package/dist/sankey-chart.js +1179 -0
- package/dist/sankey-chart.js.map +1 -0
- package/package.json +135 -0
- package/src/scales.css +288 -0
- package/src/shiki.css +37 -0
- package/src/styles.css +23 -0
- package/src/theme.css +659 -0
|
@@ -0,0 +1,1318 @@
|
|
|
1
|
+
// src/components/charts/chart.tsx
|
|
2
|
+
import * as RechartsPrimitive from "recharts";
|
|
3
|
+
|
|
4
|
+
// src/lib/cn.ts
|
|
5
|
+
import { clsx } from "clsx";
|
|
6
|
+
import { extendTailwindMerge } from "tailwind-merge";
|
|
7
|
+
var twMerge = extendTailwindMerge({
|
|
8
|
+
extend: {
|
|
9
|
+
classGroups: {
|
|
10
|
+
"font-size": [{ "text-cui": ["sm", "base", "lg", "xl"] }],
|
|
11
|
+
"text-color": [
|
|
12
|
+
{
|
|
13
|
+
"text-cui": [
|
|
14
|
+
"primary",
|
|
15
|
+
"secondary",
|
|
16
|
+
"tertiary",
|
|
17
|
+
"inverse",
|
|
18
|
+
"accent",
|
|
19
|
+
"accent-on",
|
|
20
|
+
"danger",
|
|
21
|
+
"danger-on",
|
|
22
|
+
"warn",
|
|
23
|
+
"warn-on",
|
|
24
|
+
"success",
|
|
25
|
+
"success-on"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
function cn(...inputs) {
|
|
33
|
+
return twMerge(clsx(inputs));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// src/components/charts/chart.tsx
|
|
37
|
+
import {
|
|
38
|
+
forwardRef,
|
|
39
|
+
useId,
|
|
40
|
+
createContext,
|
|
41
|
+
useContext
|
|
42
|
+
} from "react";
|
|
43
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
44
|
+
var THEMES = { light: "", dark: '[data-theme="dark"]' };
|
|
45
|
+
var VALID_THEME_KEYS = Object.keys(THEMES);
|
|
46
|
+
var DEFAULT_PALETTE = [
|
|
47
|
+
"var(--color-bruv-chart-1)",
|
|
48
|
+
"var(--color-bruv-chart-2)",
|
|
49
|
+
"var(--color-bruv-chart-3)",
|
|
50
|
+
"var(--color-bruv-chart-4)",
|
|
51
|
+
"var(--color-bruv-chart-5)",
|
|
52
|
+
"var(--color-bruv-chart-6)"
|
|
53
|
+
];
|
|
54
|
+
var ChartContext = createContext(null);
|
|
55
|
+
function useChart() {
|
|
56
|
+
const context = useContext(ChartContext);
|
|
57
|
+
if (!context) {
|
|
58
|
+
throw new Error("useChart must be used within a <Chart />");
|
|
59
|
+
}
|
|
60
|
+
return context;
|
|
61
|
+
}
|
|
62
|
+
function validateChartConfigColors(config) {
|
|
63
|
+
for (const [key, value] of Object.entries(config)) {
|
|
64
|
+
if (value.colors) {
|
|
65
|
+
const hasValidThemeKey = VALID_THEME_KEYS.some(
|
|
66
|
+
(themeKey) => value.colors?.[themeKey] !== void 0
|
|
67
|
+
);
|
|
68
|
+
if (!hasValidThemeKey) {
|
|
69
|
+
throw new Error(
|
|
70
|
+
`[BruvCharts] Invalid chart config for "${key}": colors object must have at least one theme key (${VALID_THEME_KEYS.join(", ")}).`
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function applyDefaultChartColors(config) {
|
|
77
|
+
const entries = Object.entries(config);
|
|
78
|
+
return Object.fromEntries(
|
|
79
|
+
entries.map(([key, item], index) => {
|
|
80
|
+
if (item.colors || item.color) {
|
|
81
|
+
if (item.color && !item.colors) {
|
|
82
|
+
return [
|
|
83
|
+
key,
|
|
84
|
+
{
|
|
85
|
+
...item,
|
|
86
|
+
colors: {
|
|
87
|
+
light: [item.color],
|
|
88
|
+
dark: [item.color]
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
];
|
|
92
|
+
}
|
|
93
|
+
return [key, item];
|
|
94
|
+
}
|
|
95
|
+
const paletteColor = DEFAULT_PALETTE[index % DEFAULT_PALETTE.length] ?? DEFAULT_PALETTE[0];
|
|
96
|
+
return [
|
|
97
|
+
key,
|
|
98
|
+
{
|
|
99
|
+
...item,
|
|
100
|
+
colors: {
|
|
101
|
+
light: [paletteColor],
|
|
102
|
+
dark: [paletteColor]
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
];
|
|
106
|
+
})
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
var Chart = forwardRef(function Chart2({
|
|
110
|
+
id,
|
|
111
|
+
config,
|
|
112
|
+
initialDimension = { width: 320, height: 200 },
|
|
113
|
+
className,
|
|
114
|
+
children,
|
|
115
|
+
footer,
|
|
116
|
+
...props
|
|
117
|
+
}, ref) {
|
|
118
|
+
const uniqueId = useId();
|
|
119
|
+
const chartId = `chart-${id ?? uniqueId.replace(/:/g, "")}`;
|
|
120
|
+
const resolvedConfig = applyDefaultChartColors(config);
|
|
121
|
+
validateChartConfigColors(resolvedConfig);
|
|
122
|
+
return /* @__PURE__ */ jsx(ChartContext.Provider, { value: { config: resolvedConfig }, children: /* @__PURE__ */ jsxs(
|
|
123
|
+
"div",
|
|
124
|
+
{
|
|
125
|
+
ref,
|
|
126
|
+
"data-slot": "chart",
|
|
127
|
+
"data-chart": chartId,
|
|
128
|
+
className: cn(
|
|
129
|
+
"bruv-chart relative flex min-h-0 w-full flex-1 flex-col justify-center text-bruv-sm text-bruv-secondary",
|
|
130
|
+
"[&_.recharts-cartesian-axis-tick_text]:fill-bruv-chart-axis [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-bruv-chart-grid/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-bruv-chart-cursor [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-bruv-chart-grid [&_.recharts-radial-bar-background-sector]:fill-bruv-subtle [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-bruv-subtle [&_.recharts-reference-line_[stroke='#ccc']]:stroke-bruv-chart-grid [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
|
|
131
|
+
!footer && "aspect-video",
|
|
132
|
+
className
|
|
133
|
+
),
|
|
134
|
+
...props,
|
|
135
|
+
children: [
|
|
136
|
+
/* @__PURE__ */ jsx(ChartStyle, { id: chartId, config: resolvedConfig }),
|
|
137
|
+
/* @__PURE__ */ jsx(
|
|
138
|
+
RechartsPrimitive.ResponsiveContainer,
|
|
139
|
+
{
|
|
140
|
+
className: "min-h-0 w-full flex-1",
|
|
141
|
+
initialDimension,
|
|
142
|
+
children
|
|
143
|
+
}
|
|
144
|
+
),
|
|
145
|
+
footer
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
) });
|
|
149
|
+
});
|
|
150
|
+
function LoadingIndicator({ isLoading }) {
|
|
151
|
+
if (!isLoading) return null;
|
|
152
|
+
return /* @__PURE__ */ jsx("div", { className: "pointer-events-none absolute inset-0 z-20 flex items-center justify-center", children: /* @__PURE__ */ jsxs("div", { className: "border-bruv-neutral bg-bruv-base-2 text-bruv-sm text-bruv-primary rounded-bruv-md flex items-center justify-center gap-2 border px-2 py-0.5", children: [
|
|
153
|
+
/* @__PURE__ */ jsx("div", { className: "border-bruv-neutral border-t-bruv-accent size-3 animate-spin rounded-full border" }),
|
|
154
|
+
/* @__PURE__ */ jsx("span", { children: "Loading" })
|
|
155
|
+
] }) });
|
|
156
|
+
}
|
|
157
|
+
function distributeColors(colorsArray, maxCount) {
|
|
158
|
+
const availableCount = colorsArray.length;
|
|
159
|
+
if (availableCount >= maxCount) {
|
|
160
|
+
return colorsArray.slice(0, maxCount);
|
|
161
|
+
}
|
|
162
|
+
const result = [];
|
|
163
|
+
const baseSlots = Math.floor(maxCount / availableCount);
|
|
164
|
+
const extraSlots = maxCount % availableCount;
|
|
165
|
+
for (let colorIdx = 0; colorIdx < availableCount; colorIdx++) {
|
|
166
|
+
const isExtraColor = colorIdx >= availableCount - extraSlots;
|
|
167
|
+
const slotsForThisColor = baseSlots + (isExtraColor ? 1 : 0);
|
|
168
|
+
for (let j = 0; j < slotsForThisColor; j++) {
|
|
169
|
+
const color = colorsArray[colorIdx];
|
|
170
|
+
if (color) result.push(color);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return result;
|
|
174
|
+
}
|
|
175
|
+
function ChartStyle({
|
|
176
|
+
id,
|
|
177
|
+
config
|
|
178
|
+
}) {
|
|
179
|
+
const colorConfig = Object.entries(config).filter(([, item]) => item.colors);
|
|
180
|
+
if (!colorConfig.length) return null;
|
|
181
|
+
const generateCssVars = (theme) => colorConfig.flatMap(([key, itemConfig]) => {
|
|
182
|
+
const colorsArray = itemConfig.colors?.[theme];
|
|
183
|
+
if (!colorsArray?.length) return [];
|
|
184
|
+
const maxCount = getColorsCount(itemConfig);
|
|
185
|
+
const distributedColors = distributeColors(colorsArray, maxCount);
|
|
186
|
+
return distributedColors.map(
|
|
187
|
+
(color, index) => ` --color-${key}-${index}: ${color};`
|
|
188
|
+
);
|
|
189
|
+
}).filter(Boolean).join("\n");
|
|
190
|
+
const css = Object.entries(THEMES).map(
|
|
191
|
+
([theme, prefix]) => `${prefix} [data-chart=${id}] {
|
|
192
|
+
${generateCssVars(theme)}
|
|
193
|
+
}`
|
|
194
|
+
).join("\n");
|
|
195
|
+
return /* @__PURE__ */ jsx("style", { dangerouslySetInnerHTML: { __html: css } });
|
|
196
|
+
}
|
|
197
|
+
function getPayloadConfigFromPayload(config, payload, key) {
|
|
198
|
+
if (typeof payload !== "object" || payload === null) return void 0;
|
|
199
|
+
const payloadPayload = "payload" in payload && typeof payload.payload === "object" && payload.payload !== null ? payload.payload : void 0;
|
|
200
|
+
let configLabelKey = key;
|
|
201
|
+
if (key in payload && typeof payload[key] === "string") {
|
|
202
|
+
configLabelKey = payload[key];
|
|
203
|
+
} else if (payloadPayload && key in payloadPayload && typeof payloadPayload[key] === "string") {
|
|
204
|
+
configLabelKey = payloadPayload[key];
|
|
205
|
+
}
|
|
206
|
+
return configLabelKey in config ? config[configLabelKey] : config[key];
|
|
207
|
+
}
|
|
208
|
+
function getColorsCount(config) {
|
|
209
|
+
if (!config.colors) return 1;
|
|
210
|
+
const counts = VALID_THEME_KEYS.map(
|
|
211
|
+
(theme) => config.colors?.[theme]?.length ?? 0
|
|
212
|
+
);
|
|
213
|
+
return Math.max(...counts, 1);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// src/components/charts/chart-tooltip.tsx
|
|
217
|
+
import * as RechartsPrimitive2 from "recharts";
|
|
218
|
+
import * as React from "react";
|
|
219
|
+
import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
220
|
+
var roundnessMap = {
|
|
221
|
+
sm: "rounded-bruv-sm",
|
|
222
|
+
md: "rounded-bruv-md",
|
|
223
|
+
lg: "rounded-bruv-lg",
|
|
224
|
+
xl: "rounded-bruv-xl"
|
|
225
|
+
};
|
|
226
|
+
var variantMap = {
|
|
227
|
+
default: "bg-bruv-base-2",
|
|
228
|
+
"frosted-glass": "bg-bruv-base-2/70 backdrop-blur-sm"
|
|
229
|
+
};
|
|
230
|
+
function ChartTooltipContent({
|
|
231
|
+
active,
|
|
232
|
+
payload,
|
|
233
|
+
className,
|
|
234
|
+
indicator = "dot",
|
|
235
|
+
hideLabel = false,
|
|
236
|
+
hideIndicator = false,
|
|
237
|
+
label,
|
|
238
|
+
labelFormatter,
|
|
239
|
+
labelClassName,
|
|
240
|
+
formatter,
|
|
241
|
+
nameKey,
|
|
242
|
+
labelKey,
|
|
243
|
+
selected,
|
|
244
|
+
roundness = "lg",
|
|
245
|
+
variant = "default"
|
|
246
|
+
}) {
|
|
247
|
+
const { config } = useChart();
|
|
248
|
+
const tooltipLabel = React.useMemo(() => {
|
|
249
|
+
if (hideLabel || !payload?.length) {
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
const [item] = payload;
|
|
253
|
+
const key = `${labelKey ?? item?.dataKey ?? item?.name ?? "value"}`;
|
|
254
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
255
|
+
const value = !labelKey && typeof label === "string" ? config[label]?.label ?? label : itemConfig?.label;
|
|
256
|
+
if (labelFormatter) {
|
|
257
|
+
return /* @__PURE__ */ jsx2("div", { className: cn("font-medium", labelClassName), children: labelFormatter(value, payload) });
|
|
258
|
+
}
|
|
259
|
+
if (!value) {
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
return /* @__PURE__ */ jsx2("div", { className: cn("font-medium", labelClassName), children: value });
|
|
263
|
+
}, [
|
|
264
|
+
label,
|
|
265
|
+
labelFormatter,
|
|
266
|
+
payload,
|
|
267
|
+
hideLabel,
|
|
268
|
+
labelClassName,
|
|
269
|
+
config,
|
|
270
|
+
labelKey
|
|
271
|
+
]);
|
|
272
|
+
if (!active || !payload?.length) {
|
|
273
|
+
return /* @__PURE__ */ jsx2("span", { className: "p-4" });
|
|
274
|
+
}
|
|
275
|
+
const nestLabel = payload.length === 1 && indicator !== "dot";
|
|
276
|
+
return /* @__PURE__ */ jsxs2(
|
|
277
|
+
"div",
|
|
278
|
+
{
|
|
279
|
+
className: cn(
|
|
280
|
+
"border-bruv-neutral/50 grid min-w-32 items-start gap-1.5 border px-2.5 py-1.5 text-xs shadow-xl",
|
|
281
|
+
roundnessMap[roundness],
|
|
282
|
+
variantMap[variant],
|
|
283
|
+
className
|
|
284
|
+
),
|
|
285
|
+
children: [
|
|
286
|
+
!nestLabel ? tooltipLabel : null,
|
|
287
|
+
/* @__PURE__ */ jsx2("div", { className: "grid gap-1.5", children: payload.filter((item) => item.type !== "none").map((item, index) => {
|
|
288
|
+
const payloadName = nameKey && item.payload ? item.payload[nameKey] : void 0;
|
|
289
|
+
const key = `${payloadName ?? item.name ?? item.dataKey ?? "value"}`;
|
|
290
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
291
|
+
const colorsCount = itemConfig ? getColorsCount(itemConfig) : 1;
|
|
292
|
+
return /* @__PURE__ */ jsx2(
|
|
293
|
+
"div",
|
|
294
|
+
{
|
|
295
|
+
className: cn(
|
|
296
|
+
"[&>svg]:text-bruv-secondary flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5",
|
|
297
|
+
indicator === "dot" && "items-center",
|
|
298
|
+
selected != null && selected !== item.dataKey && "opacity-30"
|
|
299
|
+
),
|
|
300
|
+
children: formatter && item?.value !== void 0 && item.name ? formatter(item.value, item.name, item, index, item.payload) : /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
301
|
+
itemConfig?.icon ? /* @__PURE__ */ jsx2(itemConfig.icon, {}) : !hideIndicator && /* @__PURE__ */ jsx2(
|
|
302
|
+
"div",
|
|
303
|
+
{
|
|
304
|
+
className: cn("shrink-0 rounded-[2px]", {
|
|
305
|
+
"h-2.5 w-2.5": indicator === "dot",
|
|
306
|
+
"w-1": indicator === "line",
|
|
307
|
+
"w-0 border-[1.5px] border-dashed bg-transparent!": indicator === "dashed",
|
|
308
|
+
"my-0.5": nestLabel && indicator === "dashed"
|
|
309
|
+
}),
|
|
310
|
+
style: getIndicatorColorStyle(key, colorsCount)
|
|
311
|
+
}
|
|
312
|
+
),
|
|
313
|
+
/* @__PURE__ */ jsxs2(
|
|
314
|
+
"div",
|
|
315
|
+
{
|
|
316
|
+
className: cn(
|
|
317
|
+
"flex flex-1 justify-between gap-4 leading-none",
|
|
318
|
+
nestLabel ? "items-end" : "items-center"
|
|
319
|
+
),
|
|
320
|
+
children: [
|
|
321
|
+
/* @__PURE__ */ jsxs2("div", { className: "grid gap-1.5", children: [
|
|
322
|
+
nestLabel ? tooltipLabel : null,
|
|
323
|
+
/* @__PURE__ */ jsx2("span", { className: "text-bruv-secondary", children: itemConfig?.label ?? item.name })
|
|
324
|
+
] }),
|
|
325
|
+
item.value != null && /* @__PURE__ */ jsx2("span", { className: "text-bruv-primary font-mono font-medium tabular-nums", children: typeof item.value === "number" ? item.value.toLocaleString() : String(item.value) })
|
|
326
|
+
]
|
|
327
|
+
}
|
|
328
|
+
)
|
|
329
|
+
] })
|
|
330
|
+
},
|
|
331
|
+
index
|
|
332
|
+
);
|
|
333
|
+
}) })
|
|
334
|
+
]
|
|
335
|
+
}
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
function getIndicatorColorStyle(dataKey, colorsCount) {
|
|
339
|
+
if (colorsCount <= 1) {
|
|
340
|
+
return { background: `var(--color-${dataKey}-0)` };
|
|
341
|
+
}
|
|
342
|
+
const stops = Array.from({ length: colorsCount }, (_, index) => {
|
|
343
|
+
const offset = index / (colorsCount - 1) * 100;
|
|
344
|
+
return `var(--color-${dataKey}-${index}) ${offset}%`;
|
|
345
|
+
}).join(", ");
|
|
346
|
+
return { background: `linear-gradient(to right, ${stops})` };
|
|
347
|
+
}
|
|
348
|
+
var ChartTooltip = ({
|
|
349
|
+
animationDuration = 200,
|
|
350
|
+
...props
|
|
351
|
+
}) => /* @__PURE__ */ jsx2(RechartsPrimitive2.Tooltip, { animationDuration, ...props });
|
|
352
|
+
|
|
353
|
+
// src/components/charts/chart-legend.tsx
|
|
354
|
+
import * as RechartsPrimitive3 from "recharts";
|
|
355
|
+
import "react";
|
|
356
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
357
|
+
function ChartLegendContent({
|
|
358
|
+
className,
|
|
359
|
+
hideIcon = false,
|
|
360
|
+
nameKey,
|
|
361
|
+
payload,
|
|
362
|
+
verticalAlign,
|
|
363
|
+
align = "right",
|
|
364
|
+
selected,
|
|
365
|
+
onSelectChange,
|
|
366
|
+
isClickable,
|
|
367
|
+
variant = "rounded-square"
|
|
368
|
+
}) {
|
|
369
|
+
const { config } = useChart();
|
|
370
|
+
if (!payload?.length) {
|
|
371
|
+
return null;
|
|
372
|
+
}
|
|
373
|
+
return /* @__PURE__ */ jsx3(
|
|
374
|
+
"div",
|
|
375
|
+
{
|
|
376
|
+
className: cn(
|
|
377
|
+
"flex items-center gap-4 select-none",
|
|
378
|
+
align === "left" && "justify-start",
|
|
379
|
+
align === "center" && "justify-center",
|
|
380
|
+
align === "right" && "justify-end",
|
|
381
|
+
verticalAlign === "top" ? "pb-4" : "pt-4",
|
|
382
|
+
className
|
|
383
|
+
),
|
|
384
|
+
children: payload.filter((item) => item.type !== "none").map((item) => {
|
|
385
|
+
const payloadName = nameKey && item.payload ? item.payload[nameKey] : void 0;
|
|
386
|
+
const key = `${payloadName ?? item.value ?? item.dataKey ?? "value"}`;
|
|
387
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
388
|
+
const isSelected = selected === null || selected === key;
|
|
389
|
+
const colorsCount = itemConfig ? getColorsCount(itemConfig) : 1;
|
|
390
|
+
return /* @__PURE__ */ jsxs3(
|
|
391
|
+
"div",
|
|
392
|
+
{
|
|
393
|
+
className: cn(
|
|
394
|
+
"[&>svg]:text-bruv-secondary flex items-center gap-1.5 transition-opacity [&>svg]:h-3 [&>svg]:w-3",
|
|
395
|
+
!isSelected && "opacity-30",
|
|
396
|
+
isClickable && "cursor-pointer"
|
|
397
|
+
),
|
|
398
|
+
onClick: () => {
|
|
399
|
+
if (!isClickable) return;
|
|
400
|
+
onSelectChange?.(selected === key ? null : key);
|
|
401
|
+
},
|
|
402
|
+
children: [
|
|
403
|
+
itemConfig?.icon && !hideIcon ? /* @__PURE__ */ jsx3(itemConfig.icon, {}) : /* @__PURE__ */ jsx3(
|
|
404
|
+
LegendIndicator,
|
|
405
|
+
{
|
|
406
|
+
variant,
|
|
407
|
+
dataKey: key,
|
|
408
|
+
colorsCount
|
|
409
|
+
}
|
|
410
|
+
),
|
|
411
|
+
itemConfig?.label
|
|
412
|
+
]
|
|
413
|
+
},
|
|
414
|
+
key
|
|
415
|
+
);
|
|
416
|
+
})
|
|
417
|
+
}
|
|
418
|
+
);
|
|
419
|
+
}
|
|
420
|
+
function LegendIndicator({
|
|
421
|
+
variant,
|
|
422
|
+
dataKey,
|
|
423
|
+
colorsCount
|
|
424
|
+
}) {
|
|
425
|
+
const fillStyle = getLegendFillStyle(dataKey, colorsCount);
|
|
426
|
+
const outlineStyle = getLegendOutlineStyle(dataKey, colorsCount);
|
|
427
|
+
switch (variant) {
|
|
428
|
+
case "square":
|
|
429
|
+
return /* @__PURE__ */ jsx3("div", { className: "h-2 w-2 shrink-0", style: fillStyle });
|
|
430
|
+
case "circle":
|
|
431
|
+
return /* @__PURE__ */ jsx3("div", { className: "h-2 w-2 shrink-0 rounded-full", style: fillStyle });
|
|
432
|
+
case "circle-outline":
|
|
433
|
+
return /* @__PURE__ */ jsx3(
|
|
434
|
+
"div",
|
|
435
|
+
{
|
|
436
|
+
className: "h-2.5 w-2.5 shrink-0 rounded-full p-[1.5px]",
|
|
437
|
+
style: outlineStyle
|
|
438
|
+
}
|
|
439
|
+
);
|
|
440
|
+
case "vertical-bar":
|
|
441
|
+
return /* @__PURE__ */ jsx3("div", { className: "h-3 w-1 shrink-0 rounded-[2px]", style: fillStyle });
|
|
442
|
+
case "horizontal-bar":
|
|
443
|
+
return /* @__PURE__ */ jsx3("div", { className: "h-1 w-3 shrink-0 rounded-[2px]", style: fillStyle });
|
|
444
|
+
case "rounded-square-outline":
|
|
445
|
+
return /* @__PURE__ */ jsx3(
|
|
446
|
+
"div",
|
|
447
|
+
{
|
|
448
|
+
className: "h-2.5 w-2.5 shrink-0 rounded-[3px] p-[1.5px]",
|
|
449
|
+
style: outlineStyle
|
|
450
|
+
}
|
|
451
|
+
);
|
|
452
|
+
case "rounded-square":
|
|
453
|
+
default:
|
|
454
|
+
return /* @__PURE__ */ jsx3("div", { className: "h-2 w-2 shrink-0 rounded-[2px]", style: fillStyle });
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
function getLegendFillStyle(dataKey, colorsCount) {
|
|
458
|
+
if (colorsCount <= 1) {
|
|
459
|
+
return { backgroundColor: `var(--color-${dataKey}-0)` };
|
|
460
|
+
}
|
|
461
|
+
const stops = Array.from({ length: colorsCount }, (_, i) => {
|
|
462
|
+
const offset = i / (colorsCount - 1) * 100;
|
|
463
|
+
return `var(--color-${dataKey}-${i}) ${offset}%`;
|
|
464
|
+
}).join(", ");
|
|
465
|
+
return { background: `linear-gradient(to right, ${stops})` };
|
|
466
|
+
}
|
|
467
|
+
function getLegendOutlineStyle(dataKey, colorsCount) {
|
|
468
|
+
const maskStyle = {
|
|
469
|
+
WebkitMask: "linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)",
|
|
470
|
+
WebkitMaskComposite: "xor",
|
|
471
|
+
mask: "linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)",
|
|
472
|
+
maskComposite: "exclude"
|
|
473
|
+
};
|
|
474
|
+
if (colorsCount <= 1) {
|
|
475
|
+
return {
|
|
476
|
+
backgroundColor: `var(--color-${dataKey}-0)`,
|
|
477
|
+
...maskStyle
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
const stops = Array.from({ length: colorsCount }, (_, i) => {
|
|
481
|
+
const offset = i / (colorsCount - 1) * 100;
|
|
482
|
+
return `var(--color-${dataKey}-${i}) ${offset}%`;
|
|
483
|
+
}).join(", ");
|
|
484
|
+
return {
|
|
485
|
+
background: `linear-gradient(to right, ${stops})`,
|
|
486
|
+
...maskStyle
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
var ChartLegend = RechartsPrimitive3.Legend;
|
|
490
|
+
|
|
491
|
+
// src/components/charts/chart-background.tsx
|
|
492
|
+
import { ZIndexLayer } from "recharts";
|
|
493
|
+
import { useId as useId2 } from "react";
|
|
494
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
495
|
+
var DotsPattern = ({ id }) => /* @__PURE__ */ jsx4(
|
|
496
|
+
"pattern",
|
|
497
|
+
{
|
|
498
|
+
id,
|
|
499
|
+
x: "0",
|
|
500
|
+
y: "0",
|
|
501
|
+
width: "20",
|
|
502
|
+
height: "20",
|
|
503
|
+
patternUnits: "userSpaceOnUse",
|
|
504
|
+
children: /* @__PURE__ */ jsx4(
|
|
505
|
+
"circle",
|
|
506
|
+
{
|
|
507
|
+
className: "text-bruv-chart-grid text-bruv-chart-grid",
|
|
508
|
+
cx: "2",
|
|
509
|
+
cy: "2",
|
|
510
|
+
r: "1",
|
|
511
|
+
fill: "currentColor"
|
|
512
|
+
}
|
|
513
|
+
)
|
|
514
|
+
}
|
|
515
|
+
);
|
|
516
|
+
var GridPattern = ({ id }) => /* @__PURE__ */ jsx4(
|
|
517
|
+
"pattern",
|
|
518
|
+
{
|
|
519
|
+
id,
|
|
520
|
+
x: "0",
|
|
521
|
+
y: "0",
|
|
522
|
+
width: "20",
|
|
523
|
+
height: "20",
|
|
524
|
+
patternUnits: "userSpaceOnUse",
|
|
525
|
+
children: /* @__PURE__ */ jsx4(
|
|
526
|
+
"path",
|
|
527
|
+
{
|
|
528
|
+
className: "text-bruv-chart-grid text-bruv-chart-grid",
|
|
529
|
+
d: "M 20 0 L 0 0 0 20",
|
|
530
|
+
fill: "none",
|
|
531
|
+
stroke: "currentColor",
|
|
532
|
+
strokeWidth: "0.5"
|
|
533
|
+
}
|
|
534
|
+
)
|
|
535
|
+
}
|
|
536
|
+
);
|
|
537
|
+
var CrossHatchPattern = ({ id }) => /* @__PURE__ */ jsx4(
|
|
538
|
+
"pattern",
|
|
539
|
+
{
|
|
540
|
+
id,
|
|
541
|
+
x: "0",
|
|
542
|
+
y: "0",
|
|
543
|
+
width: "20",
|
|
544
|
+
height: "20",
|
|
545
|
+
patternUnits: "userSpaceOnUse",
|
|
546
|
+
children: /* @__PURE__ */ jsx4(
|
|
547
|
+
"path",
|
|
548
|
+
{
|
|
549
|
+
className: "text-bruv-chart-grid/60 text-bruv-chart-grid/50",
|
|
550
|
+
d: "M 0 0 L 20 20 M 20 0 L 0 20",
|
|
551
|
+
fill: "none",
|
|
552
|
+
stroke: "currentColor",
|
|
553
|
+
strokeWidth: "0.5"
|
|
554
|
+
}
|
|
555
|
+
)
|
|
556
|
+
}
|
|
557
|
+
);
|
|
558
|
+
var DiagonalLinesPattern = ({ id }) => /* @__PURE__ */ jsx4(
|
|
559
|
+
"pattern",
|
|
560
|
+
{
|
|
561
|
+
id,
|
|
562
|
+
x: "0",
|
|
563
|
+
y: "0",
|
|
564
|
+
width: "6",
|
|
565
|
+
height: "6",
|
|
566
|
+
patternUnits: "userSpaceOnUse",
|
|
567
|
+
patternTransform: "rotate(45)",
|
|
568
|
+
children: /* @__PURE__ */ jsx4(
|
|
569
|
+
"line",
|
|
570
|
+
{
|
|
571
|
+
className: "text-bruv-chart-grid text-bruv-chart-grid",
|
|
572
|
+
x1: "0",
|
|
573
|
+
y1: "0",
|
|
574
|
+
x2: "0",
|
|
575
|
+
y2: "6",
|
|
576
|
+
stroke: "currentColor",
|
|
577
|
+
strokeWidth: "0.5"
|
|
578
|
+
}
|
|
579
|
+
)
|
|
580
|
+
}
|
|
581
|
+
);
|
|
582
|
+
var PlusPattern = ({ id }) => /* @__PURE__ */ jsx4(
|
|
583
|
+
"pattern",
|
|
584
|
+
{
|
|
585
|
+
id,
|
|
586
|
+
x: "0",
|
|
587
|
+
y: "0",
|
|
588
|
+
width: "16",
|
|
589
|
+
height: "16",
|
|
590
|
+
patternUnits: "userSpaceOnUse",
|
|
591
|
+
children: /* @__PURE__ */ jsx4(
|
|
592
|
+
"path",
|
|
593
|
+
{
|
|
594
|
+
className: "text-bruv-chart-grid text-bruv-chart-grid",
|
|
595
|
+
d: "M 8 4 L 8 12 M 4 8 L 12 8",
|
|
596
|
+
fill: "none",
|
|
597
|
+
stroke: "currentColor",
|
|
598
|
+
strokeWidth: "0.5",
|
|
599
|
+
strokeLinecap: "round"
|
|
600
|
+
}
|
|
601
|
+
)
|
|
602
|
+
}
|
|
603
|
+
);
|
|
604
|
+
var FallingTrianglesPattern = ({ id }) => /* @__PURE__ */ jsx4(
|
|
605
|
+
"pattern",
|
|
606
|
+
{
|
|
607
|
+
id,
|
|
608
|
+
x: "0",
|
|
609
|
+
y: "0",
|
|
610
|
+
width: "18",
|
|
611
|
+
height: "36",
|
|
612
|
+
patternUnits: "userSpaceOnUse",
|
|
613
|
+
children: /* @__PURE__ */ jsx4(
|
|
614
|
+
"path",
|
|
615
|
+
{
|
|
616
|
+
className: "text-bruv-chart-grid text-bruv-chart-grid",
|
|
617
|
+
d: "M2 6h12L8 18 2 6zm18 36h12l-6 12-6-12z",
|
|
618
|
+
transform: "scale(0.5)",
|
|
619
|
+
fill: "currentColor",
|
|
620
|
+
fillOpacity: "0.4"
|
|
621
|
+
}
|
|
622
|
+
)
|
|
623
|
+
}
|
|
624
|
+
);
|
|
625
|
+
var FourPointedStarPattern = ({ id }) => /* @__PURE__ */ jsx4(
|
|
626
|
+
"pattern",
|
|
627
|
+
{
|
|
628
|
+
id,
|
|
629
|
+
x: "0",
|
|
630
|
+
y: "0",
|
|
631
|
+
width: "16",
|
|
632
|
+
height: "16",
|
|
633
|
+
patternUnits: "userSpaceOnUse",
|
|
634
|
+
children: /* @__PURE__ */ jsx4(
|
|
635
|
+
"polygon",
|
|
636
|
+
{
|
|
637
|
+
className: "text-bruv-chart-grid text-bruv-chart-grid",
|
|
638
|
+
fillRule: "evenodd",
|
|
639
|
+
points: "5 3 8 4 5 5 4 8 3 5 0 4 3 3 4 0 5 3",
|
|
640
|
+
fill: "currentColor",
|
|
641
|
+
fillOpacity: "0.4"
|
|
642
|
+
}
|
|
643
|
+
)
|
|
644
|
+
}
|
|
645
|
+
);
|
|
646
|
+
var TinyCheckersPattern = ({ id }) => /* @__PURE__ */ jsx4(
|
|
647
|
+
"pattern",
|
|
648
|
+
{
|
|
649
|
+
id,
|
|
650
|
+
x: "0",
|
|
651
|
+
y: "0",
|
|
652
|
+
width: "8",
|
|
653
|
+
height: "8",
|
|
654
|
+
patternUnits: "userSpaceOnUse",
|
|
655
|
+
children: /* @__PURE__ */ jsx4(
|
|
656
|
+
"path",
|
|
657
|
+
{
|
|
658
|
+
className: "text-bruv-chart-grid text-bruv-chart-grid",
|
|
659
|
+
fillRule: "evenodd",
|
|
660
|
+
d: "M0 0h4v4H0V0zm4 4h4v4H4V4z",
|
|
661
|
+
fill: "currentColor",
|
|
662
|
+
fillOpacity: "0.2"
|
|
663
|
+
}
|
|
664
|
+
)
|
|
665
|
+
}
|
|
666
|
+
);
|
|
667
|
+
var OverlappingCirclesPattern = ({ id }) => /* @__PURE__ */ jsx4(
|
|
668
|
+
"pattern",
|
|
669
|
+
{
|
|
670
|
+
id,
|
|
671
|
+
x: "0",
|
|
672
|
+
y: "0",
|
|
673
|
+
width: "40",
|
|
674
|
+
height: "40",
|
|
675
|
+
patternUnits: "userSpaceOnUse",
|
|
676
|
+
children: /* @__PURE__ */ jsx4(
|
|
677
|
+
"path",
|
|
678
|
+
{
|
|
679
|
+
className: "text-bruv-chart-grid text-bruv-chart-grid",
|
|
680
|
+
fillRule: "evenodd",
|
|
681
|
+
d: "M25 25c0-2.762 2.238-5 5-5s5 2.238 5 5-2.238 5-5 5c0 2.762-2.238 5-5 5s-5-2.238-5-5 2.238-5 5-5zM5 5c0-2.762 2.238-5 5-5s5 2.238 5 5-2.238 5-5 5c0 2.762-2.238 5-5 5S0 12.762 0 10s2.238-5 5-5zm5 4c2.209 0 4-1.791 4-4s-1.791-4-4-4-4 1.791-4 4 1.791 4 4 4zm20 20c2.209 0 4-1.791 4-4s-1.791-4-4-4-4 1.791-4 4 1.791 4 4 4z",
|
|
682
|
+
fill: "currentColor",
|
|
683
|
+
fillOpacity: "0.4"
|
|
684
|
+
}
|
|
685
|
+
)
|
|
686
|
+
}
|
|
687
|
+
);
|
|
688
|
+
var WiggleLinesPattern = ({ id }) => /* @__PURE__ */ jsx4(
|
|
689
|
+
"pattern",
|
|
690
|
+
{
|
|
691
|
+
id,
|
|
692
|
+
x: "0",
|
|
693
|
+
y: "0",
|
|
694
|
+
width: "52",
|
|
695
|
+
height: "26",
|
|
696
|
+
patternUnits: "userSpaceOnUse",
|
|
697
|
+
patternTransform: "scale(0.6)",
|
|
698
|
+
children: /* @__PURE__ */ jsx4(
|
|
699
|
+
"path",
|
|
700
|
+
{
|
|
701
|
+
className: "text-bruv-chart-grid text-bruv-chart-grid",
|
|
702
|
+
d: "M10 10c0-2.21-1.79-4-4-4-3.314 0-6-2.686-6-6h2c0 2.21 1.79 4 4 4 3.314 0 6 2.686 6 6 0 2.21 1.79 4 4 4 3.314 0 6 2.686 6 6 0 2.21 1.79 4 4 4v2c-3.314 0-6-2.686-6-6 0-2.21-1.79-4-4-4-3.314 0-6-2.686-6-6zm25.464-1.95l8.486 8.486-1.414 1.414-8.486-8.486 1.414-1.414z",
|
|
703
|
+
fill: "currentColor",
|
|
704
|
+
fillOpacity: "0.4"
|
|
705
|
+
}
|
|
706
|
+
)
|
|
707
|
+
}
|
|
708
|
+
);
|
|
709
|
+
var BubblesPattern = ({ id }) => /* @__PURE__ */ jsx4(
|
|
710
|
+
"pattern",
|
|
711
|
+
{
|
|
712
|
+
id,
|
|
713
|
+
x: "0",
|
|
714
|
+
y: "0",
|
|
715
|
+
width: "100",
|
|
716
|
+
height: "100",
|
|
717
|
+
patternUnits: "userSpaceOnUse",
|
|
718
|
+
patternTransform: "scale(0.6667)",
|
|
719
|
+
children: /* @__PURE__ */ jsx4(
|
|
720
|
+
"path",
|
|
721
|
+
{
|
|
722
|
+
className: "text-bruv-chart-grid text-bruv-chart-grid",
|
|
723
|
+
d: "M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z",
|
|
724
|
+
fill: "currentColor",
|
|
725
|
+
fillOpacity: "0.4",
|
|
726
|
+
fillRule: "evenodd"
|
|
727
|
+
}
|
|
728
|
+
)
|
|
729
|
+
}
|
|
730
|
+
);
|
|
731
|
+
var PATTERN_MAP = {
|
|
732
|
+
dots: DotsPattern,
|
|
733
|
+
grid: GridPattern,
|
|
734
|
+
plus: PlusPattern,
|
|
735
|
+
bubbles: BubblesPattern,
|
|
736
|
+
"cross-hatch": CrossHatchPattern,
|
|
737
|
+
"diagonal-lines": DiagonalLinesPattern,
|
|
738
|
+
"falling-triangles": FallingTrianglesPattern,
|
|
739
|
+
"4-pointed-star": FourPointedStarPattern,
|
|
740
|
+
"tiny-checkers": TinyCheckersPattern,
|
|
741
|
+
"overlapping-circles": OverlappingCirclesPattern,
|
|
742
|
+
"wiggle-lines": WiggleLinesPattern
|
|
743
|
+
};
|
|
744
|
+
function ChartBackground({ variant }) {
|
|
745
|
+
const baseId = useId2().replace(/:/g, "");
|
|
746
|
+
const patternId = `${baseId}-bg-${variant}`;
|
|
747
|
+
const maskId = `${baseId}-bg-edge-fade`;
|
|
748
|
+
const filterId = `${baseId}-bg-blur`;
|
|
749
|
+
const PatternComponent = PATTERN_MAP[variant];
|
|
750
|
+
return /* @__PURE__ */ jsxs4(ZIndexLayer, { zIndex: -1, children: [
|
|
751
|
+
/* @__PURE__ */ jsxs4("defs", { children: [
|
|
752
|
+
/* @__PURE__ */ jsx4(PatternComponent, { id: patternId }),
|
|
753
|
+
/* @__PURE__ */ jsx4("filter", { id: filterId, children: /* @__PURE__ */ jsx4("feGaussianBlur", { stdDeviation: "25" }) }),
|
|
754
|
+
/* @__PURE__ */ jsx4("mask", { id: maskId, maskUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsx4(
|
|
755
|
+
"rect",
|
|
756
|
+
{
|
|
757
|
+
x: "8%",
|
|
758
|
+
y: "20%",
|
|
759
|
+
width: "85%",
|
|
760
|
+
height: "60%",
|
|
761
|
+
fill: "white",
|
|
762
|
+
filter: `url(#${filterId})`
|
|
763
|
+
}
|
|
764
|
+
) })
|
|
765
|
+
] }),
|
|
766
|
+
/* @__PURE__ */ jsx4(
|
|
767
|
+
"rect",
|
|
768
|
+
{
|
|
769
|
+
width: "100%",
|
|
770
|
+
height: "100%",
|
|
771
|
+
fill: `url(#${patternId})`,
|
|
772
|
+
mask: `url(#${maskId})`
|
|
773
|
+
}
|
|
774
|
+
)
|
|
775
|
+
] });
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
// src/components/charts/chart-dot.tsx
|
|
779
|
+
import * as React3 from "react";
|
|
780
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
781
|
+
var ChartDot = React3.memo(function ChartDot2({
|
|
782
|
+
cx,
|
|
783
|
+
cy,
|
|
784
|
+
dataKey,
|
|
785
|
+
chartId,
|
|
786
|
+
className,
|
|
787
|
+
fillOpacity = 1,
|
|
788
|
+
type = "default",
|
|
789
|
+
maskId
|
|
790
|
+
}) {
|
|
791
|
+
const dotId = React3.useId().replace(/:/g, "");
|
|
792
|
+
const gradientUrl = `url(#${chartId}-colors-${String(dataKey)})`;
|
|
793
|
+
if (cx === void 0 || cy === void 0) return null;
|
|
794
|
+
switch (type) {
|
|
795
|
+
case "border":
|
|
796
|
+
return /* @__PURE__ */ jsx5(
|
|
797
|
+
PrimaryBorderDot,
|
|
798
|
+
{
|
|
799
|
+
cx,
|
|
800
|
+
cy,
|
|
801
|
+
dotId,
|
|
802
|
+
fillOpacity,
|
|
803
|
+
gradientUrl,
|
|
804
|
+
className,
|
|
805
|
+
maskId
|
|
806
|
+
}
|
|
807
|
+
);
|
|
808
|
+
case "colored-border":
|
|
809
|
+
return /* @__PURE__ */ jsx5(
|
|
810
|
+
ColoredBorderDot,
|
|
811
|
+
{
|
|
812
|
+
cx,
|
|
813
|
+
cy,
|
|
814
|
+
dotId,
|
|
815
|
+
fillOpacity,
|
|
816
|
+
gradientUrl,
|
|
817
|
+
className,
|
|
818
|
+
maskId
|
|
819
|
+
}
|
|
820
|
+
);
|
|
821
|
+
default:
|
|
822
|
+
return /* @__PURE__ */ jsx5(
|
|
823
|
+
DefaultDot,
|
|
824
|
+
{
|
|
825
|
+
cx,
|
|
826
|
+
cy,
|
|
827
|
+
dotId,
|
|
828
|
+
fillOpacity,
|
|
829
|
+
gradientUrl,
|
|
830
|
+
className,
|
|
831
|
+
maskId
|
|
832
|
+
}
|
|
833
|
+
);
|
|
834
|
+
}
|
|
835
|
+
});
|
|
836
|
+
var DefaultDot = React3.memo(
|
|
837
|
+
({
|
|
838
|
+
cx,
|
|
839
|
+
cy,
|
|
840
|
+
dotId,
|
|
841
|
+
fillOpacity,
|
|
842
|
+
gradientUrl,
|
|
843
|
+
className,
|
|
844
|
+
maskId
|
|
845
|
+
}) => {
|
|
846
|
+
const r = 3;
|
|
847
|
+
return /* @__PURE__ */ jsxs5("g", { className, mask: maskId ? `url(#${maskId})` : void 0, children: [
|
|
848
|
+
/* @__PURE__ */ jsx5("defs", { children: /* @__PURE__ */ jsx5("clipPath", { id: `dot-clip-${dotId}`, children: /* @__PURE__ */ jsx5("circle", { cx, cy, r }) }) }),
|
|
849
|
+
/* @__PURE__ */ jsx5(
|
|
850
|
+
"rect",
|
|
851
|
+
{
|
|
852
|
+
x: "0",
|
|
853
|
+
y: cy - r,
|
|
854
|
+
width: "100%",
|
|
855
|
+
height: r * 2,
|
|
856
|
+
fill: gradientUrl,
|
|
857
|
+
fillOpacity,
|
|
858
|
+
clipPath: `url(#dot-clip-${dotId})`
|
|
859
|
+
}
|
|
860
|
+
)
|
|
861
|
+
] });
|
|
862
|
+
}
|
|
863
|
+
);
|
|
864
|
+
DefaultDot.displayName = "DefaultDot";
|
|
865
|
+
var PrimaryBorderDot = React3.memo(
|
|
866
|
+
({
|
|
867
|
+
cx,
|
|
868
|
+
cy,
|
|
869
|
+
dotId,
|
|
870
|
+
fillOpacity,
|
|
871
|
+
gradientUrl,
|
|
872
|
+
className,
|
|
873
|
+
maskId
|
|
874
|
+
}) => {
|
|
875
|
+
const r = 6;
|
|
876
|
+
const strokeWidth = 5;
|
|
877
|
+
return /* @__PURE__ */ jsxs5(
|
|
878
|
+
"g",
|
|
879
|
+
{
|
|
880
|
+
className: cn(className, "text-bruv-base-1"),
|
|
881
|
+
mask: maskId ? `url(#${maskId})` : void 0,
|
|
882
|
+
children: [
|
|
883
|
+
/* @__PURE__ */ jsx5("defs", { children: /* @__PURE__ */ jsx5("clipPath", { id: `dot-clip-${dotId}`, children: /* @__PURE__ */ jsx5("circle", { cx, cy, r }) }) }),
|
|
884
|
+
/* @__PURE__ */ jsx5("circle", { cx, cy, r, fill: "currentColor" }),
|
|
885
|
+
/* @__PURE__ */ jsx5(
|
|
886
|
+
"rect",
|
|
887
|
+
{
|
|
888
|
+
x: "0",
|
|
889
|
+
y: cy - (r - strokeWidth / 2),
|
|
890
|
+
width: "100%",
|
|
891
|
+
height: (r - strokeWidth / 2) * 2,
|
|
892
|
+
fill: gradientUrl,
|
|
893
|
+
fillOpacity,
|
|
894
|
+
clipPath: `url(#dot-clip-inner-${dotId})`
|
|
895
|
+
}
|
|
896
|
+
),
|
|
897
|
+
/* @__PURE__ */ jsx5("defs", { children: /* @__PURE__ */ jsx5("clipPath", { id: `dot-clip-inner-${dotId}`, children: /* @__PURE__ */ jsx5("circle", { cx, cy, r: r - strokeWidth / 2 }) }) })
|
|
898
|
+
]
|
|
899
|
+
}
|
|
900
|
+
);
|
|
901
|
+
}
|
|
902
|
+
);
|
|
903
|
+
PrimaryBorderDot.displayName = "PrimaryBorderDot";
|
|
904
|
+
var ColoredBorderDot = React3.memo(
|
|
905
|
+
({
|
|
906
|
+
cx,
|
|
907
|
+
cy,
|
|
908
|
+
dotId,
|
|
909
|
+
fillOpacity,
|
|
910
|
+
gradientUrl,
|
|
911
|
+
className,
|
|
912
|
+
maskId
|
|
913
|
+
}) => {
|
|
914
|
+
const r = 3;
|
|
915
|
+
const strokeWidth = 1;
|
|
916
|
+
return /* @__PURE__ */ jsxs5(
|
|
917
|
+
"g",
|
|
918
|
+
{
|
|
919
|
+
className: cn(className, "text-bruv-base-1"),
|
|
920
|
+
mask: maskId ? `url(#${maskId})` : void 0,
|
|
921
|
+
children: [
|
|
922
|
+
/* @__PURE__ */ jsx5("defs", { children: /* @__PURE__ */ jsx5("clipPath", { id: `dot-clip-${dotId}`, children: /* @__PURE__ */ jsx5("circle", { cx, cy, r: r + strokeWidth / 2 }) }) }),
|
|
923
|
+
/* @__PURE__ */ jsx5(
|
|
924
|
+
"rect",
|
|
925
|
+
{
|
|
926
|
+
x: "0",
|
|
927
|
+
y: cy - r - strokeWidth / 2,
|
|
928
|
+
width: "100%",
|
|
929
|
+
height: (r + strokeWidth / 2) * 2,
|
|
930
|
+
fill: gradientUrl,
|
|
931
|
+
fillOpacity,
|
|
932
|
+
clipPath: `url(#dot-clip-${dotId})`
|
|
933
|
+
}
|
|
934
|
+
),
|
|
935
|
+
/* @__PURE__ */ jsx5("circle", { cx, cy, r: r - strokeWidth / 2, fill: "currentColor" })
|
|
936
|
+
]
|
|
937
|
+
}
|
|
938
|
+
);
|
|
939
|
+
}
|
|
940
|
+
);
|
|
941
|
+
ColoredBorderDot.displayName = "ColoredBorderDot";
|
|
942
|
+
|
|
943
|
+
// src/components/charts/radar-chart.tsx
|
|
944
|
+
import {
|
|
945
|
+
Children,
|
|
946
|
+
createContext as createContext2,
|
|
947
|
+
isValidElement,
|
|
948
|
+
use,
|
|
949
|
+
useCallback,
|
|
950
|
+
useEffect,
|
|
951
|
+
useId as useId4,
|
|
952
|
+
useMemo as useMemo2,
|
|
953
|
+
useState
|
|
954
|
+
} from "react";
|
|
955
|
+
import {
|
|
956
|
+
PolarAngleAxis as RechartsPolarAngleAxis,
|
|
957
|
+
PolarGrid as RechartsPolarGrid,
|
|
958
|
+
PolarRadiusAxis as RechartsPolarRadiusAxis,
|
|
959
|
+
Radar as RechartsRadar,
|
|
960
|
+
RadarChart as RechartsRadarChart
|
|
961
|
+
} from "recharts";
|
|
962
|
+
import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
963
|
+
var STROKE_WIDTH = 1;
|
|
964
|
+
var DEFAULT_FILL_OPACITY = 0.3;
|
|
965
|
+
var LOADING_POINTS = 6;
|
|
966
|
+
var LOADING_ANIMATION_DURATION = 1500;
|
|
967
|
+
var LOADING_RADAR_DATA_KEY = "value";
|
|
968
|
+
var RadarChartContext = createContext2(null);
|
|
969
|
+
function useRadarChart() {
|
|
970
|
+
const context = use(RadarChartContext);
|
|
971
|
+
if (!context) {
|
|
972
|
+
throw new Error(
|
|
973
|
+
"Radar chart parts (<Radar />, <PolarAngleAxis />, \u2026) must be used within <RadarChart />"
|
|
974
|
+
);
|
|
975
|
+
}
|
|
976
|
+
return context;
|
|
977
|
+
}
|
|
978
|
+
function RadarChart({
|
|
979
|
+
config,
|
|
980
|
+
data,
|
|
981
|
+
children,
|
|
982
|
+
className,
|
|
983
|
+
chartProps,
|
|
984
|
+
backgroundVariant,
|
|
985
|
+
defaultSelectedDataKey = null,
|
|
986
|
+
onSelectionChange,
|
|
987
|
+
isLoading = false,
|
|
988
|
+
loadingPoints
|
|
989
|
+
}) {
|
|
990
|
+
const chartId = useId4().replace(/:/g, "");
|
|
991
|
+
const [selectedDataKey, setSelectedDataKey] = useState(
|
|
992
|
+
defaultSelectedDataKey
|
|
993
|
+
);
|
|
994
|
+
const loadingData = useLoadingData(isLoading, loadingPoints);
|
|
995
|
+
const selectDataKey = useCallback(
|
|
996
|
+
(newSelectedDataKey) => {
|
|
997
|
+
setSelectedDataKey(newSelectedDataKey);
|
|
998
|
+
onSelectionChange?.(newSelectedDataKey);
|
|
999
|
+
},
|
|
1000
|
+
[onSelectionChange]
|
|
1001
|
+
);
|
|
1002
|
+
const contextValue = useMemo2(
|
|
1003
|
+
() => ({
|
|
1004
|
+
config,
|
|
1005
|
+
isLoading,
|
|
1006
|
+
selectedDataKey,
|
|
1007
|
+
selectDataKey
|
|
1008
|
+
}),
|
|
1009
|
+
[config, isLoading, selectedDataKey, selectDataKey]
|
|
1010
|
+
);
|
|
1011
|
+
return /* @__PURE__ */ jsx6(RadarChartContext, { value: contextValue, children: /* @__PURE__ */ jsxs6(Chart, { className, config, children: [
|
|
1012
|
+
/* @__PURE__ */ jsx6(LoadingIndicator, { isLoading }),
|
|
1013
|
+
/* @__PURE__ */ jsxs6(
|
|
1014
|
+
RechartsRadarChart,
|
|
1015
|
+
{
|
|
1016
|
+
id: chartId,
|
|
1017
|
+
data: isLoading ? loadingData : data,
|
|
1018
|
+
...chartProps,
|
|
1019
|
+
children: [
|
|
1020
|
+
backgroundVariant && /* @__PURE__ */ jsx6(ChartBackground, { variant: backgroundVariant }),
|
|
1021
|
+
children,
|
|
1022
|
+
isLoading && /* @__PURE__ */ jsx6(LoadingRadar, {})
|
|
1023
|
+
]
|
|
1024
|
+
}
|
|
1025
|
+
)
|
|
1026
|
+
] }) });
|
|
1027
|
+
}
|
|
1028
|
+
function Radar({
|
|
1029
|
+
dataKey,
|
|
1030
|
+
variant = "filled",
|
|
1031
|
+
fillOpacity = DEFAULT_FILL_OPACITY,
|
|
1032
|
+
isClickable = false,
|
|
1033
|
+
children,
|
|
1034
|
+
radarProps
|
|
1035
|
+
}) {
|
|
1036
|
+
const { config, isLoading, selectedDataKey, selectDataKey } = useRadarChart();
|
|
1037
|
+
const id = useId4().replace(/:/g, "");
|
|
1038
|
+
if (isLoading) return null;
|
|
1039
|
+
const isSelected = selectedDataKey === null || selectedDataKey === dataKey;
|
|
1040
|
+
const opacity = isClickable && !isSelected ? 0.2 : 1;
|
|
1041
|
+
const isFilled = variant === "filled";
|
|
1042
|
+
const { dot, activeDot } = resolveDots(children, id, dataKey, opacity);
|
|
1043
|
+
return /* @__PURE__ */ jsxs6(Fragment2, { children: [
|
|
1044
|
+
/* @__PURE__ */ jsx6(
|
|
1045
|
+
RechartsRadar,
|
|
1046
|
+
{
|
|
1047
|
+
dataKey,
|
|
1048
|
+
stroke: `url(#${id}-radar-stroke-${dataKey})`,
|
|
1049
|
+
strokeOpacity: opacity,
|
|
1050
|
+
strokeWidth: STROKE_WIDTH,
|
|
1051
|
+
fill: isFilled ? `url(#${id}-radar-fill-${dataKey})` : "none",
|
|
1052
|
+
fillOpacity: isFilled ? fillOpacity * opacity : 0,
|
|
1053
|
+
dot,
|
|
1054
|
+
activeDot,
|
|
1055
|
+
className: "transition-opacity duration-200",
|
|
1056
|
+
style: isClickable ? { cursor: "pointer" } : void 0,
|
|
1057
|
+
onClick: () => {
|
|
1058
|
+
if (!isClickable) return;
|
|
1059
|
+
selectDataKey(selectedDataKey === dataKey ? null : dataKey);
|
|
1060
|
+
},
|
|
1061
|
+
...radarProps
|
|
1062
|
+
}
|
|
1063
|
+
),
|
|
1064
|
+
/* @__PURE__ */ jsxs6("defs", { children: [
|
|
1065
|
+
/* @__PURE__ */ jsx6(ColorGradient, { id, dataKey, config }),
|
|
1066
|
+
/* @__PURE__ */ jsx6(StrokeGradient, { id, dataKey, config }),
|
|
1067
|
+
isFilled && /* @__PURE__ */ jsx6(FillGradient, { id, dataKey, config })
|
|
1068
|
+
] })
|
|
1069
|
+
] });
|
|
1070
|
+
}
|
|
1071
|
+
var Dot = () => null;
|
|
1072
|
+
var ActiveDot = () => null;
|
|
1073
|
+
function PolarGrid({
|
|
1074
|
+
gridType = "polygon",
|
|
1075
|
+
stroke = "currentColor",
|
|
1076
|
+
strokeOpacity = 0.2,
|
|
1077
|
+
strokeDasharray = "3 4",
|
|
1078
|
+
...props
|
|
1079
|
+
}) {
|
|
1080
|
+
return /* @__PURE__ */ jsx6(
|
|
1081
|
+
RechartsPolarGrid,
|
|
1082
|
+
{
|
|
1083
|
+
gridType,
|
|
1084
|
+
stroke,
|
|
1085
|
+
strokeOpacity,
|
|
1086
|
+
strokeDasharray,
|
|
1087
|
+
...props
|
|
1088
|
+
}
|
|
1089
|
+
);
|
|
1090
|
+
}
|
|
1091
|
+
function PolarAngleAxis({
|
|
1092
|
+
tick = { fill: "currentColor", fontSize: 12 },
|
|
1093
|
+
tickLine = false,
|
|
1094
|
+
...props
|
|
1095
|
+
}) {
|
|
1096
|
+
const { isLoading } = useRadarChart();
|
|
1097
|
+
if (isLoading) return null;
|
|
1098
|
+
return /* @__PURE__ */ jsx6(RechartsPolarAngleAxis, { tick, tickLine, ...props });
|
|
1099
|
+
}
|
|
1100
|
+
function PolarRadiusAxis({
|
|
1101
|
+
tick = { fill: "currentColor", fontSize: 10 },
|
|
1102
|
+
tickLine = false,
|
|
1103
|
+
axisLine = false,
|
|
1104
|
+
...props
|
|
1105
|
+
}) {
|
|
1106
|
+
const { isLoading } = useRadarChart();
|
|
1107
|
+
if (isLoading) return null;
|
|
1108
|
+
return /* @__PURE__ */ jsx6(
|
|
1109
|
+
RechartsPolarRadiusAxis,
|
|
1110
|
+
{
|
|
1111
|
+
tick,
|
|
1112
|
+
tickLine,
|
|
1113
|
+
axisLine,
|
|
1114
|
+
...props
|
|
1115
|
+
}
|
|
1116
|
+
);
|
|
1117
|
+
}
|
|
1118
|
+
function Tooltip2({ variant, roundness, defaultIndex }) {
|
|
1119
|
+
const { isLoading, selectedDataKey } = useRadarChart();
|
|
1120
|
+
if (isLoading) return null;
|
|
1121
|
+
return /* @__PURE__ */ jsx6(
|
|
1122
|
+
ChartTooltip,
|
|
1123
|
+
{
|
|
1124
|
+
defaultIndex,
|
|
1125
|
+
cursor: false,
|
|
1126
|
+
content: /* @__PURE__ */ jsx6(
|
|
1127
|
+
ChartTooltipContent,
|
|
1128
|
+
{
|
|
1129
|
+
selected: selectedDataKey,
|
|
1130
|
+
roundness,
|
|
1131
|
+
variant
|
|
1132
|
+
}
|
|
1133
|
+
)
|
|
1134
|
+
}
|
|
1135
|
+
);
|
|
1136
|
+
}
|
|
1137
|
+
function Legend2({
|
|
1138
|
+
variant,
|
|
1139
|
+
align = "center",
|
|
1140
|
+
verticalAlign = "bottom",
|
|
1141
|
+
isClickable = false
|
|
1142
|
+
}) {
|
|
1143
|
+
const { isLoading, selectedDataKey, selectDataKey } = useRadarChart();
|
|
1144
|
+
if (isLoading) return null;
|
|
1145
|
+
return /* @__PURE__ */ jsx6(
|
|
1146
|
+
ChartLegend,
|
|
1147
|
+
{
|
|
1148
|
+
verticalAlign,
|
|
1149
|
+
align,
|
|
1150
|
+
content: /* @__PURE__ */ jsx6(
|
|
1151
|
+
ChartLegendContent,
|
|
1152
|
+
{
|
|
1153
|
+
selected: selectedDataKey,
|
|
1154
|
+
onSelectChange: selectDataKey,
|
|
1155
|
+
isClickable,
|
|
1156
|
+
variant
|
|
1157
|
+
}
|
|
1158
|
+
)
|
|
1159
|
+
}
|
|
1160
|
+
);
|
|
1161
|
+
}
|
|
1162
|
+
var resolveDots = (children, id, dataKey, dotOpacity) => {
|
|
1163
|
+
let dot = false;
|
|
1164
|
+
let activeDot = false;
|
|
1165
|
+
Children.forEach(children, (child) => {
|
|
1166
|
+
if (!isValidElement(child)) return;
|
|
1167
|
+
if (child.type === Dot) {
|
|
1168
|
+
const { variant } = child.props;
|
|
1169
|
+
dot = /* @__PURE__ */ jsx6(
|
|
1170
|
+
ChartDot,
|
|
1171
|
+
{
|
|
1172
|
+
type: variant,
|
|
1173
|
+
dataKey,
|
|
1174
|
+
chartId: id,
|
|
1175
|
+
fillOpacity: dotOpacity
|
|
1176
|
+
}
|
|
1177
|
+
);
|
|
1178
|
+
}
|
|
1179
|
+
if (child.type === ActiveDot) {
|
|
1180
|
+
const { variant } = child.props;
|
|
1181
|
+
activeDot = /* @__PURE__ */ jsx6(
|
|
1182
|
+
ChartDot,
|
|
1183
|
+
{
|
|
1184
|
+
type: variant,
|
|
1185
|
+
dataKey,
|
|
1186
|
+
chartId: id,
|
|
1187
|
+
fillOpacity: dotOpacity
|
|
1188
|
+
}
|
|
1189
|
+
);
|
|
1190
|
+
}
|
|
1191
|
+
});
|
|
1192
|
+
return { dot, activeDot };
|
|
1193
|
+
};
|
|
1194
|
+
var ColorStops = ({ dataKey, colorsCount, opacities }) => {
|
|
1195
|
+
if (colorsCount === 1) {
|
|
1196
|
+
return /* @__PURE__ */ jsxs6(Fragment2, { children: [
|
|
1197
|
+
/* @__PURE__ */ jsx6(
|
|
1198
|
+
"stop",
|
|
1199
|
+
{
|
|
1200
|
+
offset: "0%",
|
|
1201
|
+
stopColor: `var(--color-${dataKey}-0)`,
|
|
1202
|
+
stopOpacity: opacities?.[0]
|
|
1203
|
+
}
|
|
1204
|
+
),
|
|
1205
|
+
/* @__PURE__ */ jsx6(
|
|
1206
|
+
"stop",
|
|
1207
|
+
{
|
|
1208
|
+
offset: "100%",
|
|
1209
|
+
stopColor: `var(--color-${dataKey}-0)`,
|
|
1210
|
+
stopOpacity: opacities?.[opacities.length - 1]
|
|
1211
|
+
}
|
|
1212
|
+
)
|
|
1213
|
+
] });
|
|
1214
|
+
}
|
|
1215
|
+
return /* @__PURE__ */ jsx6(Fragment2, { children: Array.from({ length: colorsCount }, (_, index) => {
|
|
1216
|
+
const offset = `${index / (colorsCount - 1) * 100}%`;
|
|
1217
|
+
return /* @__PURE__ */ jsx6(
|
|
1218
|
+
"stop",
|
|
1219
|
+
{
|
|
1220
|
+
offset,
|
|
1221
|
+
stopColor: `var(--color-${dataKey}-${index}, var(--color-${dataKey}-0))`,
|
|
1222
|
+
stopOpacity: opacities?.[index]
|
|
1223
|
+
},
|
|
1224
|
+
offset
|
|
1225
|
+
);
|
|
1226
|
+
}) });
|
|
1227
|
+
};
|
|
1228
|
+
var ColorGradient = ({ id, dataKey, config }) => {
|
|
1229
|
+
const colorsCount = getColorsCount(config[dataKey] ?? {});
|
|
1230
|
+
return /* @__PURE__ */ jsx6("linearGradient", { id: `${id}-colors-${dataKey}`, x1: "0", y1: "0", x2: "1", y2: "0", children: /* @__PURE__ */ jsx6(ColorStops, { dataKey, colorsCount }) });
|
|
1231
|
+
};
|
|
1232
|
+
var StrokeGradient = ({ id, dataKey, config }) => {
|
|
1233
|
+
const colorsCount = getColorsCount(config[dataKey] ?? {});
|
|
1234
|
+
return /* @__PURE__ */ jsx6(
|
|
1235
|
+
"linearGradient",
|
|
1236
|
+
{
|
|
1237
|
+
id: `${id}-radar-stroke-${dataKey}`,
|
|
1238
|
+
x1: "0",
|
|
1239
|
+
y1: "0",
|
|
1240
|
+
x2: "1",
|
|
1241
|
+
y2: "1",
|
|
1242
|
+
children: /* @__PURE__ */ jsx6(ColorStops, { dataKey, colorsCount })
|
|
1243
|
+
}
|
|
1244
|
+
);
|
|
1245
|
+
};
|
|
1246
|
+
var FillGradient = ({ id, dataKey, config }) => {
|
|
1247
|
+
const colorsCount = getColorsCount(config[dataKey] ?? {});
|
|
1248
|
+
const opacities = colorsCount === 1 ? [0.8, 0.3] : Array.from({ length: colorsCount }, (_, i) => i === 0 ? 0.8 : 0.3);
|
|
1249
|
+
return /* @__PURE__ */ jsx6(
|
|
1250
|
+
"radialGradient",
|
|
1251
|
+
{
|
|
1252
|
+
id: `${id}-radar-fill-${dataKey}`,
|
|
1253
|
+
cx: "50%",
|
|
1254
|
+
cy: "50%",
|
|
1255
|
+
r: "50%",
|
|
1256
|
+
children: /* @__PURE__ */ jsx6(
|
|
1257
|
+
ColorStops,
|
|
1258
|
+
{
|
|
1259
|
+
dataKey,
|
|
1260
|
+
colorsCount,
|
|
1261
|
+
opacities
|
|
1262
|
+
}
|
|
1263
|
+
)
|
|
1264
|
+
}
|
|
1265
|
+
);
|
|
1266
|
+
};
|
|
1267
|
+
var generateLoadingData = (points) => {
|
|
1268
|
+
const categories = ["A", "B", "C", "D", "E", "F"];
|
|
1269
|
+
return categories.slice(0, points).map((category) => ({
|
|
1270
|
+
skill: category,
|
|
1271
|
+
[LOADING_RADAR_DATA_KEY]: 30 + Math.random() * 70
|
|
1272
|
+
}));
|
|
1273
|
+
};
|
|
1274
|
+
function useLoadingData(isLoading, loadingPoints = LOADING_POINTS) {
|
|
1275
|
+
const [refreshKey, setRefreshKey] = useState(0);
|
|
1276
|
+
useEffect(() => {
|
|
1277
|
+
if (!isLoading) return;
|
|
1278
|
+
const interval = setInterval(() => {
|
|
1279
|
+
setRefreshKey((prev) => prev + 1);
|
|
1280
|
+
}, LOADING_ANIMATION_DURATION);
|
|
1281
|
+
return () => clearInterval(interval);
|
|
1282
|
+
}, [isLoading]);
|
|
1283
|
+
const loadingData = useMemo2(
|
|
1284
|
+
() => generateLoadingData(loadingPoints),
|
|
1285
|
+
[loadingPoints, refreshKey]
|
|
1286
|
+
);
|
|
1287
|
+
return loadingData;
|
|
1288
|
+
}
|
|
1289
|
+
var LoadingRadar = () => {
|
|
1290
|
+
return /* @__PURE__ */ jsx6(
|
|
1291
|
+
RechartsRadar,
|
|
1292
|
+
{
|
|
1293
|
+
dataKey: LOADING_RADAR_DATA_KEY,
|
|
1294
|
+
stroke: "currentColor",
|
|
1295
|
+
strokeOpacity: 0.3,
|
|
1296
|
+
strokeWidth: 2,
|
|
1297
|
+
fill: "currentColor",
|
|
1298
|
+
fillOpacity: 0.1,
|
|
1299
|
+
dot: false,
|
|
1300
|
+
isAnimationActive: true,
|
|
1301
|
+
animationDuration: LOADING_ANIMATION_DURATION,
|
|
1302
|
+
animationEasing: "ease-in-out"
|
|
1303
|
+
}
|
|
1304
|
+
);
|
|
1305
|
+
};
|
|
1306
|
+
export {
|
|
1307
|
+
ActiveDot,
|
|
1308
|
+
Dot,
|
|
1309
|
+
Legend2 as Legend,
|
|
1310
|
+
PolarAngleAxis,
|
|
1311
|
+
PolarGrid,
|
|
1312
|
+
PolarRadiusAxis,
|
|
1313
|
+
Radar,
|
|
1314
|
+
RadarChart,
|
|
1315
|
+
Tooltip2 as Tooltip,
|
|
1316
|
+
useLoadingData
|
|
1317
|
+
};
|
|
1318
|
+
//# sourceMappingURL=radar-chart.js.map
|