@x-plat/design-system 0.5.33 → 0.5.35
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/components/Chart/index.cjs +152 -192
- package/dist/components/Chart/index.css +4 -1
- package/dist/components/Chart/index.js +140 -180
- package/dist/components/index.cjs +183 -239
- package/dist/components/index.css +4 -1
- package/dist/components/index.js +165 -221
- package/dist/index.cjs +183 -239
- package/dist/index.css +4 -1
- package/dist/index.js +165 -221
- package/package.json +1 -1
|
@@ -2229,8 +2229,25 @@ var CardTab = Object.assign(CardTabRoot, {
|
|
|
2229
2229
|
var CardTab_default = CardTab;
|
|
2230
2230
|
|
|
2231
2231
|
// src/components/Chart/Chart.tsx
|
|
2232
|
+
var import_react7 = __toESM(require("react"), 1);
|
|
2233
|
+
|
|
2234
|
+
// src/tokens/hooks/Portal.tsx
|
|
2232
2235
|
var import_react6 = __toESM(require("react"), 1);
|
|
2236
|
+
var import_react_dom = __toESM(require("react-dom"), 1);
|
|
2233
2237
|
var import_jsx_runtime307 = require("react/jsx-runtime");
|
|
2238
|
+
var PortalContainerContext = import_react6.default.createContext(null);
|
|
2239
|
+
var PortalProvider = ({ container, children }) => /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(PortalContainerContext.Provider, { value: container, children });
|
|
2240
|
+
var Portal = ({ children }) => {
|
|
2241
|
+
const contextContainer = import_react6.default.useContext(PortalContainerContext);
|
|
2242
|
+
if (typeof document === "undefined") return null;
|
|
2243
|
+
const container = contextContainer ?? document.body;
|
|
2244
|
+
return import_react_dom.default.createPortal(children, container);
|
|
2245
|
+
};
|
|
2246
|
+
Portal.displayName = "Portal";
|
|
2247
|
+
var Portal_default = Portal;
|
|
2248
|
+
|
|
2249
|
+
// src/components/Chart/Chart.tsx
|
|
2250
|
+
var import_jsx_runtime308 = require("react/jsx-runtime");
|
|
2234
2251
|
var CATEGORICAL_COUNT2 = 8;
|
|
2235
2252
|
var LINE_BAR_PALETTES = Array.from({ length: CATEGORICAL_COUNT2 }, (_, i) => {
|
|
2236
2253
|
const n = i + 1;
|
|
@@ -2276,11 +2293,11 @@ var toSmoothPath = (points) => {
|
|
|
2276
2293
|
};
|
|
2277
2294
|
var RESIZE_SETTLE_MS = 150;
|
|
2278
2295
|
var useChartSize = (ref) => {
|
|
2279
|
-
const [size, setSize] =
|
|
2280
|
-
const settleTimer =
|
|
2281
|
-
const committedSize =
|
|
2282
|
-
const initialRef =
|
|
2283
|
-
|
|
2296
|
+
const [size, setSize] = import_react7.default.useState({ width: 0, height: 0 });
|
|
2297
|
+
const settleTimer = import_react7.default.useRef(0);
|
|
2298
|
+
const committedSize = import_react7.default.useRef({ width: 0, height: 0 });
|
|
2299
|
+
const initialRef = import_react7.default.useRef(true);
|
|
2300
|
+
import_react7.default.useEffect(() => {
|
|
2284
2301
|
const el = ref.current;
|
|
2285
2302
|
if (!el) return;
|
|
2286
2303
|
const observer = new ResizeObserver((entries) => {
|
|
@@ -2322,10 +2339,10 @@ var useChartSize = (ref) => {
|
|
|
2322
2339
|
};
|
|
2323
2340
|
var prefersReducedMotion = () => typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
2324
2341
|
var useChartAnimation = (containerRef, dataKey) => {
|
|
2325
|
-
const [animate, setAnimate] =
|
|
2326
|
-
const prevDataKey =
|
|
2327
|
-
const hasAnimated =
|
|
2328
|
-
|
|
2342
|
+
const [animate, setAnimate] = import_react7.default.useState(false);
|
|
2343
|
+
const prevDataKey = import_react7.default.useRef(dataKey);
|
|
2344
|
+
const hasAnimated = import_react7.default.useRef(false);
|
|
2345
|
+
import_react7.default.useEffect(() => {
|
|
2329
2346
|
if (prefersReducedMotion()) return;
|
|
2330
2347
|
const el = containerRef.current;
|
|
2331
2348
|
if (!el) return;
|
|
@@ -2341,27 +2358,29 @@ var useChartAnimation = (containerRef, dataKey) => {
|
|
|
2341
2358
|
observer.observe(el);
|
|
2342
2359
|
return () => observer.disconnect();
|
|
2343
2360
|
}, [containerRef]);
|
|
2344
|
-
|
|
2361
|
+
import_react7.default.useEffect(() => {
|
|
2345
2362
|
if (dataKey !== prevDataKey.current) {
|
|
2346
2363
|
prevDataKey.current = dataKey;
|
|
2347
2364
|
if (prefersReducedMotion()) return;
|
|
2348
2365
|
setAnimate(false);
|
|
2349
|
-
requestAnimationFrame(() =>
|
|
2366
|
+
requestAnimationFrame(() => {
|
|
2367
|
+
requestAnimationFrame(() => setAnimate(true));
|
|
2368
|
+
});
|
|
2350
2369
|
}
|
|
2351
2370
|
}, [dataKey]);
|
|
2352
2371
|
return animate || prefersReducedMotion();
|
|
2353
2372
|
};
|
|
2354
2373
|
var TOOLTIP_OFFSET = 12;
|
|
2355
2374
|
var useChartTooltip = (enabled) => {
|
|
2356
|
-
const [tooltip, setTooltip] =
|
|
2375
|
+
const [tooltip, setTooltip] = import_react7.default.useState({
|
|
2357
2376
|
visible: false,
|
|
2358
2377
|
clientX: 0,
|
|
2359
2378
|
clientY: 0,
|
|
2360
2379
|
content: ""
|
|
2361
2380
|
});
|
|
2362
|
-
const containerRef =
|
|
2363
|
-
const rafRef =
|
|
2364
|
-
const move =
|
|
2381
|
+
const containerRef = import_react7.default.useRef(null);
|
|
2382
|
+
const rafRef = import_react7.default.useRef(0);
|
|
2383
|
+
const move = import_react7.default.useCallback((e) => {
|
|
2365
2384
|
if (!enabled) return;
|
|
2366
2385
|
const cx = e.clientX;
|
|
2367
2386
|
const cy = e.clientY;
|
|
@@ -2370,22 +2389,22 @@ var useChartTooltip = (enabled) => {
|
|
|
2370
2389
|
setTooltip((prev) => ({ ...prev, clientX: cx, clientY: cy }));
|
|
2371
2390
|
});
|
|
2372
2391
|
}, [enabled]);
|
|
2373
|
-
const show =
|
|
2392
|
+
const show = import_react7.default.useCallback((e, content) => {
|
|
2374
2393
|
if (!enabled) return;
|
|
2375
2394
|
setTooltip({ visible: true, clientX: e.clientX, clientY: e.clientY, content });
|
|
2376
2395
|
}, [enabled]);
|
|
2377
|
-
const hide =
|
|
2396
|
+
const hide = import_react7.default.useCallback(() => {
|
|
2378
2397
|
cancelAnimationFrame(rafRef.current);
|
|
2379
2398
|
setTooltip((prev) => ({ ...prev, visible: false }));
|
|
2380
2399
|
}, []);
|
|
2381
2400
|
return { tooltip, show, hide, move, containerRef };
|
|
2382
2401
|
};
|
|
2383
|
-
var GridLines =
|
|
2402
|
+
var GridLines = import_react7.default.memo(({ width, height, chartH, maxVal }) => /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(import_jsx_runtime308.Fragment, { children: [0, 0.25, 0.5, 0.75, 1].map((ratio) => {
|
|
2384
2403
|
const y = PADDING.top + (1 - ratio) * chartH;
|
|
2385
2404
|
const val = Math.round(maxVal * ratio);
|
|
2386
|
-
return /* @__PURE__ */ (0,
|
|
2387
|
-
/* @__PURE__ */ (0,
|
|
2388
|
-
/* @__PURE__ */ (0,
|
|
2405
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("g", { children: [
|
|
2406
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsx)("line", { x1: PADDING.left, y1: y, x2: width - PADDING.right, y2: y, className: "chart-grid" }),
|
|
2407
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsx)("text", { x: PADDING.left - 8, y: y + 4, className: "chart-axis-label", textAnchor: "end", children: val })
|
|
2389
2408
|
] }, ratio);
|
|
2390
2409
|
}) }));
|
|
2391
2410
|
GridLines.displayName = "GridLines";
|
|
@@ -2395,18 +2414,18 @@ var getLabelStep = (count, chartW) => {
|
|
|
2395
2414
|
if (count <= maxLabels) return 1;
|
|
2396
2415
|
return Math.ceil(count / maxLabels);
|
|
2397
2416
|
};
|
|
2398
|
-
var AxisLabels =
|
|
2417
|
+
var AxisLabels = import_react7.default.memo(({ labels, count, chartW, height }) => {
|
|
2399
2418
|
const step = getLabelStep(count, chartW);
|
|
2400
|
-
return /* @__PURE__ */ (0,
|
|
2419
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(import_jsx_runtime308.Fragment, { children: labels.map((label, i) => {
|
|
2401
2420
|
if (i % step !== 0) return null;
|
|
2402
2421
|
const x = PADDING.left + i / (count - 1 || 1) * chartW;
|
|
2403
|
-
return /* @__PURE__ */ (0,
|
|
2422
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("text", { x, y: height - 8, className: "chart-axis-label", textAnchor: "middle", children: label }, i);
|
|
2404
2423
|
}) });
|
|
2405
2424
|
});
|
|
2406
2425
|
AxisLabels.displayName = "AxisLabels";
|
|
2407
2426
|
var useCrosshair = (seriesPoints, entries, labels, chartH) => {
|
|
2408
|
-
const [activeIndex, setActiveIndex] =
|
|
2409
|
-
const handleMouseMove =
|
|
2427
|
+
const [activeIndex, setActiveIndex] = import_react7.default.useState(null);
|
|
2428
|
+
const handleMouseMove = import_react7.default.useCallback((e) => {
|
|
2410
2429
|
const svg = e.currentTarget;
|
|
2411
2430
|
const rect = svg.getBoundingClientRect();
|
|
2412
2431
|
const mx = (e.clientX - rect.left) / rect.width * svg.viewBox.baseVal.width;
|
|
@@ -2425,17 +2444,17 @@ var useCrosshair = (seriesPoints, entries, labels, chartH) => {
|
|
|
2425
2444
|
}
|
|
2426
2445
|
setActiveIndex(minDist <= threshold ? closest : null);
|
|
2427
2446
|
}, [seriesPoints]);
|
|
2428
|
-
const handleMouseLeave =
|
|
2447
|
+
const handleMouseLeave = import_react7.default.useCallback(() => {
|
|
2429
2448
|
setActiveIndex(null);
|
|
2430
2449
|
}, []);
|
|
2431
|
-
const tooltipContent =
|
|
2450
|
+
const tooltipContent = import_react7.default.useMemo(() => {
|
|
2432
2451
|
if (activeIndex === null) return "";
|
|
2433
2452
|
return entries.map(([key], di) => {
|
|
2434
2453
|
const p = seriesPoints[di]?.[activeIndex];
|
|
2435
2454
|
return p ? `${key}: ${p.v}` : "";
|
|
2436
2455
|
}).filter(Boolean).join(" / ");
|
|
2437
2456
|
}, [activeIndex, entries, seriesPoints]);
|
|
2438
|
-
const getTooltipAt =
|
|
2457
|
+
const getTooltipAt = import_react7.default.useCallback((idx) => {
|
|
2439
2458
|
return entries.map(([key], di) => {
|
|
2440
2459
|
const p = seriesPoints[di]?.[idx];
|
|
2441
2460
|
return p ? `${key}: ${p.v}` : "";
|
|
@@ -2443,16 +2462,16 @@ var useCrosshair = (seriesPoints, entries, labels, chartH) => {
|
|
|
2443
2462
|
}, [entries, seriesPoints]);
|
|
2444
2463
|
return { activeIndex, handleMouseMove, handleMouseLeave, tooltipContent, getTooltipAt };
|
|
2445
2464
|
};
|
|
2446
|
-
var LineChart =
|
|
2447
|
-
const entries =
|
|
2448
|
-
const maxVal =
|
|
2465
|
+
var LineChart = import_react7.default.memo(({ data, labels, width, height, animate, onHover, onMove, onLeave }) => {
|
|
2466
|
+
const entries = import_react7.default.useMemo(() => Object.entries(data), [data]);
|
|
2467
|
+
const maxVal = import_react7.default.useMemo(() => {
|
|
2449
2468
|
const allValues = entries.flatMap(([, v]) => v);
|
|
2450
2469
|
return Math.max(...allValues) * 1.2 || 1;
|
|
2451
2470
|
}, [entries]);
|
|
2452
2471
|
const count = labels.length;
|
|
2453
2472
|
const chartW = width - PADDING.left - PADDING.right;
|
|
2454
2473
|
const chartH = height - PADDING.top - PADDING.bottom;
|
|
2455
|
-
const seriesPoints =
|
|
2474
|
+
const seriesPoints = import_react7.default.useMemo(
|
|
2456
2475
|
() => entries.map(
|
|
2457
2476
|
([, values]) => values.map((v, i) => ({
|
|
2458
2477
|
x: PADDING.left + i / (count - 1 || 1) * chartW,
|
|
@@ -2462,34 +2481,21 @@ var LineChart = import_react6.default.memo(({ data, labels, width, height, anima
|
|
|
2462
2481
|
),
|
|
2463
2482
|
[entries, count, chartW, chartH, maxVal]
|
|
2464
2483
|
);
|
|
2465
|
-
const
|
|
2466
|
-
const clipRef = import_react6.default.useRef(null);
|
|
2484
|
+
const clipRef = import_react7.default.useRef(null);
|
|
2467
2485
|
const { activeIndex, handleMouseMove, handleMouseLeave, getTooltipAt } = useCrosshair(seriesPoints, entries, labels, chartH);
|
|
2468
|
-
|
|
2469
|
-
if (!animate) return;
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
el.style.transition = "stroke-dashoffset 1200ms ease-out 200ms";
|
|
2477
|
-
el.style.strokeDashoffset = "0";
|
|
2478
|
-
});
|
|
2486
|
+
import_react7.default.useEffect(() => {
|
|
2487
|
+
if (!animate || !clipRef.current) return;
|
|
2488
|
+
clipRef.current.setAttribute("width", "0");
|
|
2489
|
+
requestAnimationFrame(() => {
|
|
2490
|
+
if (clipRef.current) {
|
|
2491
|
+
clipRef.current.style.transition = "width 1200ms ease-out 200ms";
|
|
2492
|
+
clipRef.current.setAttribute("width", `${width}`);
|
|
2493
|
+
}
|
|
2479
2494
|
});
|
|
2480
|
-
|
|
2481
|
-
clipRef.current.setAttribute("width", "0");
|
|
2482
|
-
requestAnimationFrame(() => {
|
|
2483
|
-
if (clipRef.current) {
|
|
2484
|
-
clipRef.current.style.transition = "width 1200ms ease-out 200ms";
|
|
2485
|
-
clipRef.current.setAttribute("width", `${width}`);
|
|
2486
|
-
}
|
|
2487
|
-
});
|
|
2488
|
-
}
|
|
2489
|
-
}, [animate, seriesPoints, width]);
|
|
2495
|
+
}, [animate, width]);
|
|
2490
2496
|
const activeX = activeIndex !== null ? seriesPoints[0]?.[activeIndex]?.x ?? null : null;
|
|
2491
2497
|
const lineClipId = "line-area-clip";
|
|
2492
|
-
return /* @__PURE__ */ (0,
|
|
2498
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)(
|
|
2493
2499
|
"svg",
|
|
2494
2500
|
{
|
|
2495
2501
|
viewBox: `0 0 ${width} ${height}`,
|
|
@@ -2522,9 +2528,9 @@ var LineChart = import_react6.default.memo(({ data, labels, width, height, anima
|
|
|
2522
2528
|
onLeave();
|
|
2523
2529
|
},
|
|
2524
2530
|
children: [
|
|
2525
|
-
animate && /* @__PURE__ */ (0,
|
|
2526
|
-
/* @__PURE__ */ (0,
|
|
2527
|
-
/* @__PURE__ */ (0,
|
|
2531
|
+
animate && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("clipPath", { id: lineClipId, children: /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("rect", { ref: clipRef, x: "0", y: "0", width: animate ? 0 : width, height }) }) }),
|
|
2532
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsx)(GridLines, { width, height, chartH, maxVal }),
|
|
2533
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsx)(AxisLabels, { labels, count, chartW, height }),
|
|
2528
2534
|
entries.map(([key], di) => {
|
|
2529
2535
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
2530
2536
|
const color = palette[2];
|
|
@@ -2533,32 +2539,16 @@ var LineChart = import_react6.default.memo(({ data, labels, width, height, anima
|
|
|
2533
2539
|
const gradientId = `line-gradient-${di}`;
|
|
2534
2540
|
const polyPoints = points.map((p) => `${p.x},${p.y}`).join(" ");
|
|
2535
2541
|
const areaD = `M ${points[0].x},${points[0].y} ${points.map((p) => `L ${p.x},${p.y}`).join(" ")} L ${points[points.length - 1].x},${PADDING.top + chartH} L ${points[0].x},${PADDING.top + chartH} Z`;
|
|
2536
|
-
return /* @__PURE__ */ (0,
|
|
2537
|
-
/* @__PURE__ */ (0,
|
|
2538
|
-
/* @__PURE__ */ (0,
|
|
2539
|
-
/* @__PURE__ */ (0,
|
|
2542
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("g", { children: [
|
|
2543
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("linearGradient", { id: gradientId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
2544
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsx)("stop", { offset: "0%", stopColor: areaColor, stopOpacity: "0.2" }),
|
|
2545
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsx)("stop", { offset: "100%", stopColor: areaColor, stopOpacity: "0" })
|
|
2540
2546
|
] }) }),
|
|
2541
|
-
/* @__PURE__ */ (0,
|
|
2542
|
-
"path",
|
|
2543
|
-
{
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
clipPath: animate ? `url(#${lineClipId})` : void 0
|
|
2547
|
-
}
|
|
2548
|
-
),
|
|
2549
|
-
/* @__PURE__ */ (0, import_jsx_runtime307.jsx)(
|
|
2550
|
-
"polyline",
|
|
2551
|
-
{
|
|
2552
|
-
ref: (el) => {
|
|
2553
|
-
lineRefs.current[di] = el;
|
|
2554
|
-
},
|
|
2555
|
-
points: polyPoints,
|
|
2556
|
-
fill: "none",
|
|
2557
|
-
stroke: color,
|
|
2558
|
-
strokeWidth: "2"
|
|
2559
|
-
}
|
|
2560
|
-
),
|
|
2561
|
-
activeIndex !== null && points[activeIndex] && /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(
|
|
2547
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("g", { clipPath: animate ? `url(#${lineClipId})` : void 0, children: [
|
|
2548
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsx)("path", { d: areaD, fill: `url(#${gradientId})` }),
|
|
2549
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsx)("polyline", { points: polyPoints, fill: "none", stroke: color, strokeWidth: "2" })
|
|
2550
|
+
] }),
|
|
2551
|
+
activeIndex !== null && points[activeIndex] && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
2562
2552
|
"circle",
|
|
2563
2553
|
{
|
|
2564
2554
|
cx: points[activeIndex].x,
|
|
@@ -2570,7 +2560,7 @@ var LineChart = import_react6.default.memo(({ data, labels, width, height, anima
|
|
|
2570
2560
|
)
|
|
2571
2561
|
] }, di);
|
|
2572
2562
|
}),
|
|
2573
|
-
activeX !== null && /* @__PURE__ */ (0,
|
|
2563
|
+
activeX !== null && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
2574
2564
|
"line",
|
|
2575
2565
|
{
|
|
2576
2566
|
x1: activeX,
|
|
@@ -2580,7 +2570,7 @@ var LineChart = import_react6.default.memo(({ data, labels, width, height, anima
|
|
|
2580
2570
|
className: "chart-crosshair"
|
|
2581
2571
|
}
|
|
2582
2572
|
),
|
|
2583
|
-
/* @__PURE__ */ (0,
|
|
2573
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
2584
2574
|
"rect",
|
|
2585
2575
|
{
|
|
2586
2576
|
x: PADDING.left,
|
|
@@ -2596,16 +2586,16 @@ var LineChart = import_react6.default.memo(({ data, labels, width, height, anima
|
|
|
2596
2586
|
);
|
|
2597
2587
|
});
|
|
2598
2588
|
LineChart.displayName = "LineChart";
|
|
2599
|
-
var CurveChart =
|
|
2600
|
-
const entries =
|
|
2601
|
-
const maxVal =
|
|
2589
|
+
var CurveChart = import_react7.default.memo(({ data, labels, width, height, animate, onHover, onMove, onLeave }) => {
|
|
2590
|
+
const entries = import_react7.default.useMemo(() => Object.entries(data), [data]);
|
|
2591
|
+
const maxVal = import_react7.default.useMemo(() => {
|
|
2602
2592
|
const allValues = entries.flatMap(([, v]) => v);
|
|
2603
2593
|
return Math.max(...allValues) * 1.2 || 1;
|
|
2604
2594
|
}, [entries]);
|
|
2605
2595
|
const count = labels.length;
|
|
2606
2596
|
const chartW = width - PADDING.left - PADDING.right;
|
|
2607
2597
|
const chartH = height - PADDING.top - PADDING.bottom;
|
|
2608
|
-
const seriesPoints =
|
|
2598
|
+
const seriesPoints = import_react7.default.useMemo(
|
|
2609
2599
|
() => entries.map(
|
|
2610
2600
|
([, values]) => values.map((v, i) => ({
|
|
2611
2601
|
x: PADDING.left + i / (count - 1 || 1) * chartW,
|
|
@@ -2615,34 +2605,21 @@ var CurveChart = import_react6.default.memo(({ data, labels, width, height, anim
|
|
|
2615
2605
|
),
|
|
2616
2606
|
[entries, count, chartW, chartH, maxVal]
|
|
2617
2607
|
);
|
|
2618
|
-
const
|
|
2619
|
-
const curveClipRef = import_react6.default.useRef(null);
|
|
2608
|
+
const curveClipRef = import_react7.default.useRef(null);
|
|
2620
2609
|
const { activeIndex, handleMouseMove, handleMouseLeave, getTooltipAt } = useCrosshair(seriesPoints, entries, labels, chartH);
|
|
2621
|
-
|
|
2622
|
-
if (!animate) return;
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
el.style.transition = "stroke-dashoffset 1200ms ease-out 200ms";
|
|
2630
|
-
el.style.strokeDashoffset = "0";
|
|
2631
|
-
});
|
|
2610
|
+
import_react7.default.useEffect(() => {
|
|
2611
|
+
if (!animate || !curveClipRef.current) return;
|
|
2612
|
+
curveClipRef.current.setAttribute("width", "0");
|
|
2613
|
+
requestAnimationFrame(() => {
|
|
2614
|
+
if (curveClipRef.current) {
|
|
2615
|
+
curveClipRef.current.style.transition = "width 1200ms ease-out 200ms";
|
|
2616
|
+
curveClipRef.current.setAttribute("width", `${width}`);
|
|
2617
|
+
}
|
|
2632
2618
|
});
|
|
2633
|
-
|
|
2634
|
-
curveClipRef.current.setAttribute("width", "0");
|
|
2635
|
-
requestAnimationFrame(() => {
|
|
2636
|
-
if (curveClipRef.current) {
|
|
2637
|
-
curveClipRef.current.style.transition = "width 1200ms ease-out 200ms";
|
|
2638
|
-
curveClipRef.current.setAttribute("width", `${width}`);
|
|
2639
|
-
}
|
|
2640
|
-
});
|
|
2641
|
-
}
|
|
2642
|
-
}, [animate, seriesPoints, width]);
|
|
2619
|
+
}, [animate, width]);
|
|
2643
2620
|
const activeX = activeIndex !== null ? seriesPoints[0]?.[activeIndex]?.x ?? null : null;
|
|
2644
2621
|
const curveClipId = "curve-area-clip";
|
|
2645
|
-
return /* @__PURE__ */ (0,
|
|
2622
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)(
|
|
2646
2623
|
"svg",
|
|
2647
2624
|
{
|
|
2648
2625
|
viewBox: `0 0 ${width} ${height}`,
|
|
@@ -2675,9 +2652,9 @@ var CurveChart = import_react6.default.memo(({ data, labels, width, height, anim
|
|
|
2675
2652
|
onLeave();
|
|
2676
2653
|
},
|
|
2677
2654
|
children: [
|
|
2678
|
-
animate && /* @__PURE__ */ (0,
|
|
2679
|
-
/* @__PURE__ */ (0,
|
|
2680
|
-
/* @__PURE__ */ (0,
|
|
2655
|
+
animate && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("clipPath", { id: curveClipId, children: /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("rect", { ref: curveClipRef, x: "0", y: "0", width: animate ? 0 : width, height }) }) }),
|
|
2656
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsx)(GridLines, { width, height, chartH, maxVal }),
|
|
2657
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsx)(AxisLabels, { labels, count, chartW, height }),
|
|
2681
2658
|
entries.map(([key], di) => {
|
|
2682
2659
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
2683
2660
|
const color = palette[2];
|
|
@@ -2686,32 +2663,16 @@ var CurveChart = import_react6.default.memo(({ data, labels, width, height, anim
|
|
|
2686
2663
|
const gradientId = `curve-gradient-${di}`;
|
|
2687
2664
|
const linePath = toSmoothPath(points);
|
|
2688
2665
|
const areaPath = linePath + ` L ${points[points.length - 1].x} ${PADDING.top + chartH} L ${points[0].x} ${PADDING.top + chartH} Z`;
|
|
2689
|
-
return /* @__PURE__ */ (0,
|
|
2690
|
-
/* @__PURE__ */ (0,
|
|
2691
|
-
/* @__PURE__ */ (0,
|
|
2692
|
-
/* @__PURE__ */ (0,
|
|
2666
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("g", { children: [
|
|
2667
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("linearGradient", { id: gradientId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
2668
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsx)("stop", { offset: "0%", stopColor: areaColor, stopOpacity: "0.4" }),
|
|
2669
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsx)("stop", { offset: "100%", stopColor: areaColor, stopOpacity: "0.02" })
|
|
2693
2670
|
] }) }),
|
|
2694
|
-
/* @__PURE__ */ (0,
|
|
2695
|
-
"path",
|
|
2696
|
-
{
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
clipPath: animate ? `url(#${curveClipId})` : void 0
|
|
2700
|
-
}
|
|
2701
|
-
),
|
|
2702
|
-
/* @__PURE__ */ (0, import_jsx_runtime307.jsx)(
|
|
2703
|
-
"path",
|
|
2704
|
-
{
|
|
2705
|
-
ref: (el) => {
|
|
2706
|
-
lineRefs.current[di] = el;
|
|
2707
|
-
},
|
|
2708
|
-
d: linePath,
|
|
2709
|
-
fill: "none",
|
|
2710
|
-
stroke: color,
|
|
2711
|
-
strokeWidth: "2"
|
|
2712
|
-
}
|
|
2713
|
-
),
|
|
2714
|
-
activeIndex !== null && points[activeIndex] && /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(
|
|
2671
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("g", { clipPath: animate ? `url(#${curveClipId})` : void 0, children: [
|
|
2672
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsx)("path", { d: areaPath, fill: `url(#${gradientId})` }),
|
|
2673
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsx)("path", { d: linePath, fill: "none", stroke: color, strokeWidth: "2" })
|
|
2674
|
+
] }),
|
|
2675
|
+
activeIndex !== null && points[activeIndex] && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
2715
2676
|
"circle",
|
|
2716
2677
|
{
|
|
2717
2678
|
cx: points[activeIndex].x,
|
|
@@ -2723,7 +2684,7 @@ var CurveChart = import_react6.default.memo(({ data, labels, width, height, anim
|
|
|
2723
2684
|
)
|
|
2724
2685
|
] }, di);
|
|
2725
2686
|
}),
|
|
2726
|
-
activeX !== null && /* @__PURE__ */ (0,
|
|
2687
|
+
activeX !== null && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
2727
2688
|
"line",
|
|
2728
2689
|
{
|
|
2729
2690
|
x1: activeX,
|
|
@@ -2733,7 +2694,7 @@ var CurveChart = import_react6.default.memo(({ data, labels, width, height, anim
|
|
|
2733
2694
|
className: "chart-crosshair"
|
|
2734
2695
|
}
|
|
2735
2696
|
),
|
|
2736
|
-
/* @__PURE__ */ (0,
|
|
2697
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
2737
2698
|
"rect",
|
|
2738
2699
|
{
|
|
2739
2700
|
x: PADDING.left,
|
|
@@ -2749,9 +2710,9 @@ var CurveChart = import_react6.default.memo(({ data, labels, width, height, anim
|
|
|
2749
2710
|
);
|
|
2750
2711
|
});
|
|
2751
2712
|
CurveChart.displayName = "CurveChart";
|
|
2752
|
-
var BarChart =
|
|
2753
|
-
const entries =
|
|
2754
|
-
const maxVal =
|
|
2713
|
+
var BarChart = import_react7.default.memo(({ data, labels, width, height, animate, onHover, onMove, onLeave }) => {
|
|
2714
|
+
const entries = import_react7.default.useMemo(() => Object.entries(data), [data]);
|
|
2715
|
+
const maxVal = import_react7.default.useMemo(() => {
|
|
2755
2716
|
const allValues = entries.flatMap(([, v]) => v);
|
|
2756
2717
|
return Math.max(...allValues) * 1.2 || 1;
|
|
2757
2718
|
}, [entries]);
|
|
@@ -2763,7 +2724,7 @@ var BarChart = import_react6.default.memo(({ data, labels, width, height, animat
|
|
|
2763
2724
|
const barGap = groupCount > 1 ? 2 : 0;
|
|
2764
2725
|
const barW = Math.max(1, Math.min(32, (groupW * 0.7 - barGap * (groupCount - 1)) / groupCount));
|
|
2765
2726
|
const baseline = PADDING.top + chartH;
|
|
2766
|
-
const bars =
|
|
2727
|
+
const bars = import_react7.default.useMemo(
|
|
2767
2728
|
() => entries.map(
|
|
2768
2729
|
([, values], di) => values.map((v, i) => {
|
|
2769
2730
|
const totalBarsW = barW * groupCount + barGap * (groupCount - 1);
|
|
@@ -2776,11 +2737,11 @@ var BarChart = import_react6.default.memo(({ data, labels, width, height, animat
|
|
|
2776
2737
|
[entries, maxVal, chartH, groupW, barW, barGap, groupCount]
|
|
2777
2738
|
);
|
|
2778
2739
|
const barLabelStep = getLabelStep(count, chartW);
|
|
2779
|
-
return /* @__PURE__ */ (0,
|
|
2780
|
-
/* @__PURE__ */ (0,
|
|
2740
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("svg", { viewBox: `0 0 ${width} ${height}`, className: "chart-svg", children: [
|
|
2741
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsx)(GridLines, { width, height, chartH, maxVal }),
|
|
2781
2742
|
labels.map((label, i) => {
|
|
2782
2743
|
if (i % barLabelStep !== 0) return null;
|
|
2783
|
-
return /* @__PURE__ */ (0,
|
|
2744
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("text", { x: PADDING.left + groupW * i + groupW / 2, y: height - 8, className: "chart-axis-label", textAnchor: "middle", children: label }, i);
|
|
2784
2745
|
}),
|
|
2785
2746
|
entries.map(([key], di) => {
|
|
2786
2747
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
@@ -2789,7 +2750,7 @@ var BarChart = import_react6.default.memo(({ data, labels, width, height, animat
|
|
|
2789
2750
|
const r2 = Math.min(4, b.w / 2);
|
|
2790
2751
|
const d = b.h <= r2 ? `M ${b.x} ${b.y + b.h} V ${b.y} H ${b.x + b.w} V ${b.y + b.h} Z` : `M ${b.x} ${b.y + b.h} V ${b.y + r2} Q ${b.x} ${b.y} ${b.x + r2} ${b.y} H ${b.x + b.w - r2} Q ${b.x + b.w} ${b.y} ${b.x + b.w} ${b.y + r2} V ${b.y + b.h} Z`;
|
|
2791
2752
|
const delay = 100 + i * 80;
|
|
2792
|
-
return /* @__PURE__ */ (0,
|
|
2753
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
2793
2754
|
"path",
|
|
2794
2755
|
{
|
|
2795
2756
|
d,
|
|
@@ -2810,11 +2771,11 @@ var BarChart = import_react6.default.memo(({ data, labels, width, height, animat
|
|
|
2810
2771
|
] });
|
|
2811
2772
|
});
|
|
2812
2773
|
BarChart.displayName = "BarChart";
|
|
2813
|
-
var PieDonutChart =
|
|
2774
|
+
var PieDonutChart = import_react7.default.memo(
|
|
2814
2775
|
({ data, labels, width, height, animate, isDoughnut, onHover, onMove, onLeave }) => {
|
|
2815
|
-
const entries =
|
|
2816
|
-
const values =
|
|
2817
|
-
const total =
|
|
2776
|
+
const entries = import_react7.default.useMemo(() => Object.entries(data), [data]);
|
|
2777
|
+
const values = import_react7.default.useMemo(() => entries.flatMap(([, v]) => v), [entries]);
|
|
2778
|
+
const total = import_react7.default.useMemo(() => values.reduce((a, b) => a + b, 0) || 1, [values]);
|
|
2818
2779
|
const size = Math.min(width, height);
|
|
2819
2780
|
const cx = size / 2;
|
|
2820
2781
|
const cy = size / 2;
|
|
@@ -2822,10 +2783,10 @@ var PieDonutChart = import_react6.default.memo(
|
|
|
2822
2783
|
const innerR = isDoughnut ? r2 * 0.5 : 0;
|
|
2823
2784
|
const firstKey = entries[0]?.[0] ?? "";
|
|
2824
2785
|
const colorOffset = hashString(firstKey);
|
|
2825
|
-
const maskRef =
|
|
2786
|
+
const maskRef = import_react7.default.useRef(null);
|
|
2826
2787
|
const maskR = r2 + 10;
|
|
2827
2788
|
const maskCircumference = 2 * Math.PI * maskR;
|
|
2828
|
-
|
|
2789
|
+
import_react7.default.useEffect(() => {
|
|
2829
2790
|
if (!animate || !maskRef.current) return;
|
|
2830
2791
|
const el = maskRef.current;
|
|
2831
2792
|
el.style.strokeDasharray = `${maskCircumference}`;
|
|
@@ -2835,7 +2796,7 @@ var PieDonutChart = import_react6.default.memo(
|
|
|
2835
2796
|
el.style.strokeDashoffset = "0";
|
|
2836
2797
|
});
|
|
2837
2798
|
}, [animate, maskCircumference]);
|
|
2838
|
-
const sliceData =
|
|
2799
|
+
const sliceData = import_react7.default.useMemo(() => {
|
|
2839
2800
|
let angle0 = -Math.PI / 2;
|
|
2840
2801
|
let cumulativeAngle = 0;
|
|
2841
2802
|
return values.map((v, i) => {
|
|
@@ -2869,8 +2830,8 @@ var PieDonutChart = import_react6.default.memo(
|
|
|
2869
2830
|
});
|
|
2870
2831
|
}, [values, total, cx, cy, r2, innerR, labels]);
|
|
2871
2832
|
const maskId = `pie-mask-${isDoughnut ? "d" : "p"}`;
|
|
2872
|
-
return /* @__PURE__ */ (0,
|
|
2873
|
-
animate && /* @__PURE__ */ (0,
|
|
2833
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("svg", { viewBox: `0 0 ${size} ${size}`, className: "chart-svg chart-pie", children: [
|
|
2834
|
+
animate && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("mask", { id: maskId, children: /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
2874
2835
|
"circle",
|
|
2875
2836
|
{
|
|
2876
2837
|
ref: maskRef,
|
|
@@ -2883,7 +2844,7 @@ var PieDonutChart = import_react6.default.memo(
|
|
|
2883
2844
|
transform: `rotate(-90 ${cx} ${cy})`
|
|
2884
2845
|
}
|
|
2885
2846
|
) }) }),
|
|
2886
|
-
/* @__PURE__ */ (0,
|
|
2847
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsx)("g", { mask: animate ? `url(#${maskId})` : void 0, children: sliceData.map((s, i) => /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("g", { children: /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
2887
2848
|
"path",
|
|
2888
2849
|
{
|
|
2889
2850
|
d: s.d,
|
|
@@ -2894,7 +2855,7 @@ var PieDonutChart = import_react6.default.memo(
|
|
|
2894
2855
|
onMouseLeave: onLeave
|
|
2895
2856
|
}
|
|
2896
2857
|
) }, i)) }),
|
|
2897
|
-
sliceData.map((s, i) => s.angle > 0.2 && /* @__PURE__ */ (0,
|
|
2858
|
+
sliceData.map((s, i) => s.angle > 0.2 && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
2898
2859
|
"text",
|
|
2899
2860
|
{
|
|
2900
2861
|
x: s.lx,
|
|
@@ -2912,9 +2873,9 @@ var PieDonutChart = import_react6.default.memo(
|
|
|
2912
2873
|
);
|
|
2913
2874
|
PieDonutChart.displayName = "PieDonutChart";
|
|
2914
2875
|
var ChartTooltipPortal = ({ clientX, clientY, visible, children }) => {
|
|
2915
|
-
const ref =
|
|
2916
|
-
const [pos, setPos] =
|
|
2917
|
-
|
|
2876
|
+
const ref = import_react7.default.useRef(null);
|
|
2877
|
+
const [pos, setPos] = import_react7.default.useState({ left: 0, top: 0 });
|
|
2878
|
+
import_react7.default.useLayoutEffect(() => {
|
|
2918
2879
|
const el = ref.current;
|
|
2919
2880
|
if (!el) return;
|
|
2920
2881
|
const w = el.offsetWidth;
|
|
@@ -2927,7 +2888,7 @@ var ChartTooltipPortal = ({ clientX, clientY, visible, children }) => {
|
|
|
2927
2888
|
if (left < 8) left = 8;
|
|
2928
2889
|
setPos({ left, top });
|
|
2929
2890
|
}, [clientX, clientY]);
|
|
2930
|
-
return /* @__PURE__ */ (0,
|
|
2891
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
2931
2892
|
"div",
|
|
2932
2893
|
{
|
|
2933
2894
|
ref,
|
|
@@ -2944,14 +2905,14 @@ var ChartLegend = ({ data, labels, type }) => {
|
|
|
2944
2905
|
const total = values.reduce((a, b) => a + b, 0) || 1;
|
|
2945
2906
|
const firstKey = entries[0]?.[0] ?? "";
|
|
2946
2907
|
const colorOffset = hashString(firstKey);
|
|
2947
|
-
return /* @__PURE__ */ (0,
|
|
2908
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("div", { className: "chart-legend", children: values.map((v, i) => {
|
|
2948
2909
|
const pct = Math.round(v / total * 100);
|
|
2949
2910
|
const color = PIE_COLORS[(i + colorOffset) % PIE_COLORS.length];
|
|
2950
|
-
return /* @__PURE__ */ (0,
|
|
2951
|
-
/* @__PURE__ */ (0,
|
|
2952
|
-
/* @__PURE__ */ (0,
|
|
2953
|
-
/* @__PURE__ */ (0,
|
|
2954
|
-
/* @__PURE__ */ (0,
|
|
2911
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("div", { className: "chart-legend-item", children: [
|
|
2912
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsx)("span", { className: "chart-legend-dot", style: { backgroundColor: color } }),
|
|
2913
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("div", { className: "chart-legend-text", children: [
|
|
2914
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsx)("span", { className: "chart-legend-label", children: labels[i] || `${i + 1}` }),
|
|
2915
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("span", { className: "chart-legend-value", children: [
|
|
2955
2916
|
v.toLocaleString(),
|
|
2956
2917
|
"(",
|
|
2957
2918
|
pct,
|
|
@@ -2961,37 +2922,37 @@ var ChartLegend = ({ data, labels, type }) => {
|
|
|
2961
2922
|
] }, i);
|
|
2962
2923
|
}) });
|
|
2963
2924
|
}
|
|
2964
|
-
return /* @__PURE__ */ (0,
|
|
2925
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("div", { className: "chart-legend", children: entries.map(([key], di) => {
|
|
2965
2926
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
2966
2927
|
const color = palette[2];
|
|
2967
2928
|
const values = entries[di][1];
|
|
2968
2929
|
const sum = values.reduce((a, b) => a + b, 0);
|
|
2969
|
-
return /* @__PURE__ */ (0,
|
|
2970
|
-
/* @__PURE__ */ (0,
|
|
2971
|
-
/* @__PURE__ */ (0,
|
|
2972
|
-
/* @__PURE__ */ (0,
|
|
2973
|
-
/* @__PURE__ */ (0,
|
|
2930
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("div", { className: "chart-legend-item", children: [
|
|
2931
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsx)("span", { className: "chart-legend-dot", style: { backgroundColor: color } }),
|
|
2932
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("div", { className: "chart-legend-text", children: [
|
|
2933
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsx)("span", { className: "chart-legend-label", children: key }),
|
|
2934
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsx)("span", { className: "chart-legend-value", children: sum.toLocaleString() })
|
|
2974
2935
|
] })
|
|
2975
2936
|
] }, di);
|
|
2976
2937
|
}) });
|
|
2977
2938
|
};
|
|
2978
|
-
var Chart =
|
|
2939
|
+
var Chart = import_react7.default.memo((props) => {
|
|
2979
2940
|
const { type, data, labels, tooltip: showTooltip = true } = props;
|
|
2980
2941
|
const { tooltip, show, hide, move, containerRef } = useChartTooltip(showTooltip);
|
|
2981
2942
|
const { width, height } = useChartSize(containerRef);
|
|
2982
|
-
const stableData =
|
|
2983
|
-
const stableLabels =
|
|
2984
|
-
const dataKey =
|
|
2943
|
+
const stableData = import_react7.default.useMemo(() => data, [JSON.stringify(data)]);
|
|
2944
|
+
const stableLabels = import_react7.default.useMemo(() => labels, [JSON.stringify(labels)]);
|
|
2945
|
+
const dataKey = import_react7.default.useMemo(() => JSON.stringify(labels), [labels]);
|
|
2985
2946
|
const animate = useChartAnimation(containerRef, dataKey);
|
|
2986
2947
|
const ready = width > 0 && height > 0;
|
|
2987
|
-
return /* @__PURE__ */ (0,
|
|
2988
|
-
ready && type === "line" && /* @__PURE__ */ (0,
|
|
2989
|
-
ready && type === "curve" && /* @__PURE__ */ (0,
|
|
2990
|
-
ready && type === "bar" && /* @__PURE__ */ (0,
|
|
2991
|
-
ready && type === "pie" && /* @__PURE__ */ (0,
|
|
2992
|
-
ready && type === "doughnut" && /* @__PURE__ */ (0,
|
|
2993
|
-
ready && (type === "bar" || type === "pie" || type === "doughnut") && /* @__PURE__ */ (0,
|
|
2994
|
-
tooltip.content && /* @__PURE__ */ (0,
|
|
2948
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("div", { className: "lib-xplat-chart", ref: containerRef, children: [
|
|
2949
|
+
ready && type === "line" && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(LineChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
|
|
2950
|
+
ready && type === "curve" && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(CurveChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
|
|
2951
|
+
ready && type === "bar" && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(BarChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
|
|
2952
|
+
ready && type === "pie" && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(PieDonutChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
|
|
2953
|
+
ready && type === "doughnut" && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(PieDonutChart, { data: stableData, labels: stableLabels, width, height, animate, isDoughnut: true, onHover: show, onMove: move, onLeave: hide }),
|
|
2954
|
+
ready && (type === "bar" || type === "pie" || type === "doughnut") && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(ChartLegend, { data: stableData, labels: stableLabels, type }),
|
|
2955
|
+
tooltip.content && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(Portal_default, { children: /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(ChartTooltipPortal, { clientX: tooltip.clientX, clientY: tooltip.clientY, visible: tooltip.visible, children: tooltip.content }) })
|
|
2995
2956
|
] });
|
|
2996
2957
|
});
|
|
2997
2958
|
Chart.displayName = "Chart";
|
|
@@ -3004,7 +2965,7 @@ var import_tokens_core = require("@x-plat/tokens-core");
|
|
|
3004
2965
|
var import_tokens_core2 = require("@x-plat/tokens-core");
|
|
3005
2966
|
|
|
3006
2967
|
// src/components/CheckBox/CheckBox.tsx
|
|
3007
|
-
var
|
|
2968
|
+
var import_jsx_runtime309 = require("react/jsx-runtime");
|
|
3008
2969
|
var CheckBox = (props) => {
|
|
3009
2970
|
const {
|
|
3010
2971
|
checked,
|
|
@@ -3022,8 +2983,8 @@ var CheckBox = (props) => {
|
|
|
3022
2983
|
const checkedClasses = `checked`;
|
|
3023
2984
|
const disabledClasses = "disabled";
|
|
3024
2985
|
const boxClasses = disabled ? disabledClasses : checked ? checkedClasses : uncheckedClasses;
|
|
3025
|
-
return /* @__PURE__ */ (0,
|
|
3026
|
-
/* @__PURE__ */ (0,
|
|
2986
|
+
return /* @__PURE__ */ (0, import_jsx_runtime309.jsxs)("label", { className: clsx_default("lib-xplat-checkbox", size, type), children: [
|
|
2987
|
+
/* @__PURE__ */ (0, import_jsx_runtime309.jsx)(
|
|
3027
2988
|
"input",
|
|
3028
2989
|
{
|
|
3029
2990
|
type: "checkbox",
|
|
@@ -3033,22 +2994,22 @@ var CheckBox = (props) => {
|
|
|
3033
2994
|
...rest
|
|
3034
2995
|
}
|
|
3035
2996
|
),
|
|
3036
|
-
/* @__PURE__ */ (0,
|
|
3037
|
-
label && /* @__PURE__ */ (0,
|
|
2997
|
+
/* @__PURE__ */ (0, import_jsx_runtime309.jsx)("span", { className: clsx_default("checkbox", boxClasses), children: /* @__PURE__ */ (0, import_jsx_runtime309.jsx)("span", { className: clsx_default("check-icon", { visible: checked }), children: /* @__PURE__ */ (0, import_jsx_runtime309.jsx)(CheckIcon_default, {}) }) }),
|
|
2998
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime309.jsx)("span", { className: "label", children: label })
|
|
3038
2999
|
] });
|
|
3039
3000
|
};
|
|
3040
3001
|
CheckBox.displayName = "CheckBox";
|
|
3041
3002
|
var CheckBox_default = CheckBox;
|
|
3042
3003
|
|
|
3043
3004
|
// src/components/Chip/Chip.tsx
|
|
3044
|
-
var
|
|
3005
|
+
var import_jsx_runtime310 = require("react/jsx-runtime");
|
|
3045
3006
|
var Chip = (props) => {
|
|
3046
3007
|
const {
|
|
3047
3008
|
children,
|
|
3048
3009
|
type = "primary",
|
|
3049
3010
|
size = "md"
|
|
3050
3011
|
} = props;
|
|
3051
|
-
return /* @__PURE__ */ (0,
|
|
3012
|
+
return /* @__PURE__ */ (0, import_jsx_runtime310.jsx)("div", { className: clsx_default("lib-xplat-chip", type, size), children });
|
|
3052
3013
|
};
|
|
3053
3014
|
Chip.displayName = "Chip";
|
|
3054
3015
|
var Chip_default = Chip;
|
|
@@ -3057,20 +3018,20 @@ var Chip_default = Chip;
|
|
|
3057
3018
|
var import_react13 = __toESM(require("react"), 1);
|
|
3058
3019
|
|
|
3059
3020
|
// src/components/Input/Input.tsx
|
|
3060
|
-
var
|
|
3021
|
+
var import_react8 = __toESM(require("react"), 1);
|
|
3061
3022
|
|
|
3062
3023
|
// src/components/Input/InputValidations.tsx
|
|
3063
|
-
var
|
|
3024
|
+
var import_jsx_runtime311 = require("react/jsx-runtime");
|
|
3064
3025
|
var InputValidations = (props) => {
|
|
3065
3026
|
const { message, status = "default" } = props;
|
|
3066
|
-
return /* @__PURE__ */ (0,
|
|
3067
|
-
/* @__PURE__ */ (0,
|
|
3068
|
-
status === "default" && /* @__PURE__ */ (0,
|
|
3069
|
-
status === "success" && /* @__PURE__ */ (0,
|
|
3070
|
-
status === "warning" && /* @__PURE__ */ (0,
|
|
3071
|
-
status === "error" && /* @__PURE__ */ (0,
|
|
3027
|
+
return /* @__PURE__ */ (0, import_jsx_runtime311.jsxs)("div", { className: clsx_default("lib-xplat-input-validation", status), children: [
|
|
3028
|
+
/* @__PURE__ */ (0, import_jsx_runtime311.jsxs)("div", { className: "icon", children: [
|
|
3029
|
+
status === "default" && /* @__PURE__ */ (0, import_jsx_runtime311.jsx)(InfoIcon_default, {}),
|
|
3030
|
+
status === "success" && /* @__PURE__ */ (0, import_jsx_runtime311.jsx)(SuccessIcon_default, {}),
|
|
3031
|
+
status === "warning" && /* @__PURE__ */ (0, import_jsx_runtime311.jsx)(InfoIcon_default, {}),
|
|
3032
|
+
status === "error" && /* @__PURE__ */ (0, import_jsx_runtime311.jsx)(ErrorIcon_default, {})
|
|
3072
3033
|
] }),
|
|
3073
|
-
/* @__PURE__ */ (0,
|
|
3034
|
+
/* @__PURE__ */ (0, import_jsx_runtime311.jsx)("div", { className: "message", children: message })
|
|
3074
3035
|
] });
|
|
3075
3036
|
};
|
|
3076
3037
|
InputValidations.displayName = "InputValidations";
|
|
@@ -3111,8 +3072,8 @@ var handleTelBackspace = (prevValue, currValue) => {
|
|
|
3111
3072
|
};
|
|
3112
3073
|
|
|
3113
3074
|
// src/components/Input/Input.tsx
|
|
3114
|
-
var
|
|
3115
|
-
var
|
|
3075
|
+
var import_jsx_runtime312 = require("react/jsx-runtime");
|
|
3076
|
+
var import_react9 = require("react");
|
|
3116
3077
|
var formatValue = (type, value) => {
|
|
3117
3078
|
if (value === null || value === void 0) return "";
|
|
3118
3079
|
const strValue = Array.isArray(value) ? String(value[0] ?? "") : String(value);
|
|
@@ -3160,7 +3121,7 @@ var parseValue = (type, value) => {
|
|
|
3160
3121
|
return value;
|
|
3161
3122
|
}
|
|
3162
3123
|
};
|
|
3163
|
-
var Input =
|
|
3124
|
+
var Input = import_react8.default.forwardRef((props, ref) => {
|
|
3164
3125
|
const {
|
|
3165
3126
|
value,
|
|
3166
3127
|
onChange,
|
|
@@ -3186,13 +3147,13 @@ var Input = import_react7.default.forwardRef((props, ref) => {
|
|
|
3186
3147
|
onChange(event);
|
|
3187
3148
|
}
|
|
3188
3149
|
};
|
|
3189
|
-
return /* @__PURE__ */ (0,
|
|
3190
|
-
/* @__PURE__ */ (0,
|
|
3150
|
+
return /* @__PURE__ */ (0, import_jsx_runtime312.jsxs)("div", { className: "lib-xplat-input-wrap", children: [
|
|
3151
|
+
/* @__PURE__ */ (0, import_jsx_runtime312.jsxs)(
|
|
3191
3152
|
"div",
|
|
3192
3153
|
{
|
|
3193
3154
|
className: clsx_default("lib-xplat-input", size, disabled ? "disabled" : void 0),
|
|
3194
3155
|
children: [
|
|
3195
|
-
/* @__PURE__ */ (0,
|
|
3156
|
+
/* @__PURE__ */ (0, import_jsx_runtime312.jsx)(
|
|
3196
3157
|
"input",
|
|
3197
3158
|
{
|
|
3198
3159
|
...inputProps,
|
|
@@ -3203,11 +3164,11 @@ var Input = import_react7.default.forwardRef((props, ref) => {
|
|
|
3203
3164
|
onChange: handleChange
|
|
3204
3165
|
}
|
|
3205
3166
|
),
|
|
3206
|
-
suffix && /* @__PURE__ */ (0,
|
|
3167
|
+
suffix && /* @__PURE__ */ (0, import_jsx_runtime312.jsx)("div", { className: "suffix", children: suffix })
|
|
3207
3168
|
]
|
|
3208
3169
|
}
|
|
3209
3170
|
),
|
|
3210
|
-
validations && /* @__PURE__ */ (0,
|
|
3171
|
+
validations && /* @__PURE__ */ (0, import_jsx_runtime312.jsx)("div", { className: "lib-xplat-input-validation-wrap", children: validations?.map((validation, idx) => /* @__PURE__ */ (0, import_react9.createElement)(
|
|
3211
3172
|
InputValidations_default,
|
|
3212
3173
|
{
|
|
3213
3174
|
...validation,
|
|
@@ -3220,20 +3181,20 @@ Input.displayName = "Input";
|
|
|
3220
3181
|
var Input_default = Input;
|
|
3221
3182
|
|
|
3222
3183
|
// src/components/Input/PasswordInput/PasswordInput.tsx
|
|
3223
|
-
var
|
|
3224
|
-
var
|
|
3225
|
-
var PasswordInput =
|
|
3184
|
+
var import_react10 = __toESM(require("react"), 1);
|
|
3185
|
+
var import_jsx_runtime313 = require("react/jsx-runtime");
|
|
3186
|
+
var PasswordInput = import_react10.default.forwardRef(
|
|
3226
3187
|
(props, ref) => {
|
|
3227
3188
|
const { reg: _reg, ...inputProps } = props;
|
|
3228
|
-
const [isView, setIsView] =
|
|
3189
|
+
const [isView, setIsView] = import_react10.default.useState(false);
|
|
3229
3190
|
const handleChangeView = () => {
|
|
3230
3191
|
setIsView((prev) => !prev);
|
|
3231
3192
|
};
|
|
3232
|
-
return /* @__PURE__ */ (0,
|
|
3193
|
+
return /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(
|
|
3233
3194
|
Input_default,
|
|
3234
3195
|
{
|
|
3235
3196
|
...inputProps,
|
|
3236
|
-
suffix: /* @__PURE__ */ (0,
|
|
3197
|
+
suffix: /* @__PURE__ */ (0, import_jsx_runtime313.jsx)("div", { className: "wrapper pointer", onClick: handleChangeView, children: isView ? /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(OpenEyeIcon_default, {}) : /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(CloseEyeIcon_default, {}) }),
|
|
3237
3198
|
type: isView ? "text" : "password",
|
|
3238
3199
|
ref
|
|
3239
3200
|
}
|
|
@@ -3246,23 +3207,6 @@ var PasswordInput_default = PasswordInput;
|
|
|
3246
3207
|
// src/components/Modal/Modal.tsx
|
|
3247
3208
|
var import_react11 = __toESM(require("react"), 1);
|
|
3248
3209
|
var import_react_dom2 = require("react-dom");
|
|
3249
|
-
|
|
3250
|
-
// src/tokens/hooks/Portal.tsx
|
|
3251
|
-
var import_react10 = __toESM(require("react"), 1);
|
|
3252
|
-
var import_react_dom = __toESM(require("react-dom"), 1);
|
|
3253
|
-
var import_jsx_runtime313 = require("react/jsx-runtime");
|
|
3254
|
-
var PortalContainerContext = import_react10.default.createContext(null);
|
|
3255
|
-
var PortalProvider = ({ container, children }) => /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(PortalContainerContext.Provider, { value: container, children });
|
|
3256
|
-
var Portal = ({ children }) => {
|
|
3257
|
-
const contextContainer = import_react10.default.useContext(PortalContainerContext);
|
|
3258
|
-
if (typeof document === "undefined") return null;
|
|
3259
|
-
const container = contextContainer ?? document.body;
|
|
3260
|
-
return import_react_dom.default.createPortal(children, container);
|
|
3261
|
-
};
|
|
3262
|
-
Portal.displayName = "Portal";
|
|
3263
|
-
var Portal_default = Portal;
|
|
3264
|
-
|
|
3265
|
-
// src/components/Modal/Modal.tsx
|
|
3266
3210
|
var import_jsx_runtime314 = require("react/jsx-runtime");
|
|
3267
3211
|
var ANIMATION_DURATION_MS = 200;
|
|
3268
3212
|
var Modal = (props) => {
|