@x-plat/design-system 0.5.34 → 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 +131 -115
- package/dist/components/Chart/index.css +4 -1
- package/dist/components/Chart/index.js +117 -101
- package/dist/components/index.cjs +162 -162
- package/dist/components/index.css +4 -1
- package/dist/components/index.js +142 -142
- package/dist/index.cjs +162 -162
- package/dist/index.css +4 -1
- package/dist/index.js +142 -142
- 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,7 +2358,7 @@ 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;
|
|
@@ -2355,15 +2372,15 @@ var useChartAnimation = (containerRef, dataKey) => {
|
|
|
2355
2372
|
};
|
|
2356
2373
|
var TOOLTIP_OFFSET = 12;
|
|
2357
2374
|
var useChartTooltip = (enabled) => {
|
|
2358
|
-
const [tooltip, setTooltip] =
|
|
2375
|
+
const [tooltip, setTooltip] = import_react7.default.useState({
|
|
2359
2376
|
visible: false,
|
|
2360
2377
|
clientX: 0,
|
|
2361
2378
|
clientY: 0,
|
|
2362
2379
|
content: ""
|
|
2363
2380
|
});
|
|
2364
|
-
const containerRef =
|
|
2365
|
-
const rafRef =
|
|
2366
|
-
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) => {
|
|
2367
2384
|
if (!enabled) return;
|
|
2368
2385
|
const cx = e.clientX;
|
|
2369
2386
|
const cy = e.clientY;
|
|
@@ -2372,22 +2389,22 @@ var useChartTooltip = (enabled) => {
|
|
|
2372
2389
|
setTooltip((prev) => ({ ...prev, clientX: cx, clientY: cy }));
|
|
2373
2390
|
});
|
|
2374
2391
|
}, [enabled]);
|
|
2375
|
-
const show =
|
|
2392
|
+
const show = import_react7.default.useCallback((e, content) => {
|
|
2376
2393
|
if (!enabled) return;
|
|
2377
2394
|
setTooltip({ visible: true, clientX: e.clientX, clientY: e.clientY, content });
|
|
2378
2395
|
}, [enabled]);
|
|
2379
|
-
const hide =
|
|
2396
|
+
const hide = import_react7.default.useCallback(() => {
|
|
2380
2397
|
cancelAnimationFrame(rafRef.current);
|
|
2381
2398
|
setTooltip((prev) => ({ ...prev, visible: false }));
|
|
2382
2399
|
}, []);
|
|
2383
2400
|
return { tooltip, show, hide, move, containerRef };
|
|
2384
2401
|
};
|
|
2385
|
-
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) => {
|
|
2386
2403
|
const y = PADDING.top + (1 - ratio) * chartH;
|
|
2387
2404
|
const val = Math.round(maxVal * ratio);
|
|
2388
|
-
return /* @__PURE__ */ (0,
|
|
2389
|
-
/* @__PURE__ */ (0,
|
|
2390
|
-
/* @__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 })
|
|
2391
2408
|
] }, ratio);
|
|
2392
2409
|
}) }));
|
|
2393
2410
|
GridLines.displayName = "GridLines";
|
|
@@ -2397,18 +2414,18 @@ var getLabelStep = (count, chartW) => {
|
|
|
2397
2414
|
if (count <= maxLabels) return 1;
|
|
2398
2415
|
return Math.ceil(count / maxLabels);
|
|
2399
2416
|
};
|
|
2400
|
-
var AxisLabels =
|
|
2417
|
+
var AxisLabels = import_react7.default.memo(({ labels, count, chartW, height }) => {
|
|
2401
2418
|
const step = getLabelStep(count, chartW);
|
|
2402
|
-
return /* @__PURE__ */ (0,
|
|
2419
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(import_jsx_runtime308.Fragment, { children: labels.map((label, i) => {
|
|
2403
2420
|
if (i % step !== 0) return null;
|
|
2404
2421
|
const x = PADDING.left + i / (count - 1 || 1) * chartW;
|
|
2405
|
-
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);
|
|
2406
2423
|
}) });
|
|
2407
2424
|
});
|
|
2408
2425
|
AxisLabels.displayName = "AxisLabels";
|
|
2409
2426
|
var useCrosshair = (seriesPoints, entries, labels, chartH) => {
|
|
2410
|
-
const [activeIndex, setActiveIndex] =
|
|
2411
|
-
const handleMouseMove =
|
|
2427
|
+
const [activeIndex, setActiveIndex] = import_react7.default.useState(null);
|
|
2428
|
+
const handleMouseMove = import_react7.default.useCallback((e) => {
|
|
2412
2429
|
const svg = e.currentTarget;
|
|
2413
2430
|
const rect = svg.getBoundingClientRect();
|
|
2414
2431
|
const mx = (e.clientX - rect.left) / rect.width * svg.viewBox.baseVal.width;
|
|
@@ -2427,17 +2444,17 @@ var useCrosshair = (seriesPoints, entries, labels, chartH) => {
|
|
|
2427
2444
|
}
|
|
2428
2445
|
setActiveIndex(minDist <= threshold ? closest : null);
|
|
2429
2446
|
}, [seriesPoints]);
|
|
2430
|
-
const handleMouseLeave =
|
|
2447
|
+
const handleMouseLeave = import_react7.default.useCallback(() => {
|
|
2431
2448
|
setActiveIndex(null);
|
|
2432
2449
|
}, []);
|
|
2433
|
-
const tooltipContent =
|
|
2450
|
+
const tooltipContent = import_react7.default.useMemo(() => {
|
|
2434
2451
|
if (activeIndex === null) return "";
|
|
2435
2452
|
return entries.map(([key], di) => {
|
|
2436
2453
|
const p = seriesPoints[di]?.[activeIndex];
|
|
2437
2454
|
return p ? `${key}: ${p.v}` : "";
|
|
2438
2455
|
}).filter(Boolean).join(" / ");
|
|
2439
2456
|
}, [activeIndex, entries, seriesPoints]);
|
|
2440
|
-
const getTooltipAt =
|
|
2457
|
+
const getTooltipAt = import_react7.default.useCallback((idx) => {
|
|
2441
2458
|
return entries.map(([key], di) => {
|
|
2442
2459
|
const p = seriesPoints[di]?.[idx];
|
|
2443
2460
|
return p ? `${key}: ${p.v}` : "";
|
|
@@ -2445,16 +2462,16 @@ var useCrosshair = (seriesPoints, entries, labels, chartH) => {
|
|
|
2445
2462
|
}, [entries, seriesPoints]);
|
|
2446
2463
|
return { activeIndex, handleMouseMove, handleMouseLeave, tooltipContent, getTooltipAt };
|
|
2447
2464
|
};
|
|
2448
|
-
var LineChart =
|
|
2449
|
-
const entries =
|
|
2450
|
-
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(() => {
|
|
2451
2468
|
const allValues = entries.flatMap(([, v]) => v);
|
|
2452
2469
|
return Math.max(...allValues) * 1.2 || 1;
|
|
2453
2470
|
}, [entries]);
|
|
2454
2471
|
const count = labels.length;
|
|
2455
2472
|
const chartW = width - PADDING.left - PADDING.right;
|
|
2456
2473
|
const chartH = height - PADDING.top - PADDING.bottom;
|
|
2457
|
-
const seriesPoints =
|
|
2474
|
+
const seriesPoints = import_react7.default.useMemo(
|
|
2458
2475
|
() => entries.map(
|
|
2459
2476
|
([, values]) => values.map((v, i) => ({
|
|
2460
2477
|
x: PADDING.left + i / (count - 1 || 1) * chartW,
|
|
@@ -2464,9 +2481,9 @@ var LineChart = import_react6.default.memo(({ data, labels, width, height, anima
|
|
|
2464
2481
|
),
|
|
2465
2482
|
[entries, count, chartW, chartH, maxVal]
|
|
2466
2483
|
);
|
|
2467
|
-
const clipRef =
|
|
2484
|
+
const clipRef = import_react7.default.useRef(null);
|
|
2468
2485
|
const { activeIndex, handleMouseMove, handleMouseLeave, getTooltipAt } = useCrosshair(seriesPoints, entries, labels, chartH);
|
|
2469
|
-
|
|
2486
|
+
import_react7.default.useEffect(() => {
|
|
2470
2487
|
if (!animate || !clipRef.current) return;
|
|
2471
2488
|
clipRef.current.setAttribute("width", "0");
|
|
2472
2489
|
requestAnimationFrame(() => {
|
|
@@ -2478,7 +2495,7 @@ var LineChart = import_react6.default.memo(({ data, labels, width, height, anima
|
|
|
2478
2495
|
}, [animate, width]);
|
|
2479
2496
|
const activeX = activeIndex !== null ? seriesPoints[0]?.[activeIndex]?.x ?? null : null;
|
|
2480
2497
|
const lineClipId = "line-area-clip";
|
|
2481
|
-
return /* @__PURE__ */ (0,
|
|
2498
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)(
|
|
2482
2499
|
"svg",
|
|
2483
2500
|
{
|
|
2484
2501
|
viewBox: `0 0 ${width} ${height}`,
|
|
@@ -2511,9 +2528,9 @@ var LineChart = import_react6.default.memo(({ data, labels, width, height, anima
|
|
|
2511
2528
|
onLeave();
|
|
2512
2529
|
},
|
|
2513
2530
|
children: [
|
|
2514
|
-
animate && /* @__PURE__ */ (0,
|
|
2515
|
-
/* @__PURE__ */ (0,
|
|
2516
|
-
/* @__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 }),
|
|
2517
2534
|
entries.map(([key], di) => {
|
|
2518
2535
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
2519
2536
|
const color = palette[2];
|
|
@@ -2522,16 +2539,16 @@ var LineChart = import_react6.default.memo(({ data, labels, width, height, anima
|
|
|
2522
2539
|
const gradientId = `line-gradient-${di}`;
|
|
2523
2540
|
const polyPoints = points.map((p) => `${p.x},${p.y}`).join(" ");
|
|
2524
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`;
|
|
2525
|
-
return /* @__PURE__ */ (0,
|
|
2526
|
-
/* @__PURE__ */ (0,
|
|
2527
|
-
/* @__PURE__ */ (0,
|
|
2528
|
-
/* @__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" })
|
|
2529
2546
|
] }) }),
|
|
2530
|
-
/* @__PURE__ */ (0,
|
|
2531
|
-
/* @__PURE__ */ (0,
|
|
2532
|
-
/* @__PURE__ */ (0,
|
|
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" })
|
|
2533
2550
|
] }),
|
|
2534
|
-
activeIndex !== null && points[activeIndex] && /* @__PURE__ */ (0,
|
|
2551
|
+
activeIndex !== null && points[activeIndex] && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
2535
2552
|
"circle",
|
|
2536
2553
|
{
|
|
2537
2554
|
cx: points[activeIndex].x,
|
|
@@ -2543,7 +2560,7 @@ var LineChart = import_react6.default.memo(({ data, labels, width, height, anima
|
|
|
2543
2560
|
)
|
|
2544
2561
|
] }, di);
|
|
2545
2562
|
}),
|
|
2546
|
-
activeX !== null && /* @__PURE__ */ (0,
|
|
2563
|
+
activeX !== null && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
2547
2564
|
"line",
|
|
2548
2565
|
{
|
|
2549
2566
|
x1: activeX,
|
|
@@ -2553,7 +2570,7 @@ var LineChart = import_react6.default.memo(({ data, labels, width, height, anima
|
|
|
2553
2570
|
className: "chart-crosshair"
|
|
2554
2571
|
}
|
|
2555
2572
|
),
|
|
2556
|
-
/* @__PURE__ */ (0,
|
|
2573
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
2557
2574
|
"rect",
|
|
2558
2575
|
{
|
|
2559
2576
|
x: PADDING.left,
|
|
@@ -2569,16 +2586,16 @@ var LineChart = import_react6.default.memo(({ data, labels, width, height, anima
|
|
|
2569
2586
|
);
|
|
2570
2587
|
});
|
|
2571
2588
|
LineChart.displayName = "LineChart";
|
|
2572
|
-
var CurveChart =
|
|
2573
|
-
const entries =
|
|
2574
|
-
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(() => {
|
|
2575
2592
|
const allValues = entries.flatMap(([, v]) => v);
|
|
2576
2593
|
return Math.max(...allValues) * 1.2 || 1;
|
|
2577
2594
|
}, [entries]);
|
|
2578
2595
|
const count = labels.length;
|
|
2579
2596
|
const chartW = width - PADDING.left - PADDING.right;
|
|
2580
2597
|
const chartH = height - PADDING.top - PADDING.bottom;
|
|
2581
|
-
const seriesPoints =
|
|
2598
|
+
const seriesPoints = import_react7.default.useMemo(
|
|
2582
2599
|
() => entries.map(
|
|
2583
2600
|
([, values]) => values.map((v, i) => ({
|
|
2584
2601
|
x: PADDING.left + i / (count - 1 || 1) * chartW,
|
|
@@ -2588,9 +2605,9 @@ var CurveChart = import_react6.default.memo(({ data, labels, width, height, anim
|
|
|
2588
2605
|
),
|
|
2589
2606
|
[entries, count, chartW, chartH, maxVal]
|
|
2590
2607
|
);
|
|
2591
|
-
const curveClipRef =
|
|
2608
|
+
const curveClipRef = import_react7.default.useRef(null);
|
|
2592
2609
|
const { activeIndex, handleMouseMove, handleMouseLeave, getTooltipAt } = useCrosshair(seriesPoints, entries, labels, chartH);
|
|
2593
|
-
|
|
2610
|
+
import_react7.default.useEffect(() => {
|
|
2594
2611
|
if (!animate || !curveClipRef.current) return;
|
|
2595
2612
|
curveClipRef.current.setAttribute("width", "0");
|
|
2596
2613
|
requestAnimationFrame(() => {
|
|
@@ -2602,7 +2619,7 @@ var CurveChart = import_react6.default.memo(({ data, labels, width, height, anim
|
|
|
2602
2619
|
}, [animate, width]);
|
|
2603
2620
|
const activeX = activeIndex !== null ? seriesPoints[0]?.[activeIndex]?.x ?? null : null;
|
|
2604
2621
|
const curveClipId = "curve-area-clip";
|
|
2605
|
-
return /* @__PURE__ */ (0,
|
|
2622
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)(
|
|
2606
2623
|
"svg",
|
|
2607
2624
|
{
|
|
2608
2625
|
viewBox: `0 0 ${width} ${height}`,
|
|
@@ -2635,9 +2652,9 @@ var CurveChart = import_react6.default.memo(({ data, labels, width, height, anim
|
|
|
2635
2652
|
onLeave();
|
|
2636
2653
|
},
|
|
2637
2654
|
children: [
|
|
2638
|
-
animate && /* @__PURE__ */ (0,
|
|
2639
|
-
/* @__PURE__ */ (0,
|
|
2640
|
-
/* @__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 }),
|
|
2641
2658
|
entries.map(([key], di) => {
|
|
2642
2659
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
2643
2660
|
const color = palette[2];
|
|
@@ -2646,16 +2663,16 @@ var CurveChart = import_react6.default.memo(({ data, labels, width, height, anim
|
|
|
2646
2663
|
const gradientId = `curve-gradient-${di}`;
|
|
2647
2664
|
const linePath = toSmoothPath(points);
|
|
2648
2665
|
const areaPath = linePath + ` L ${points[points.length - 1].x} ${PADDING.top + chartH} L ${points[0].x} ${PADDING.top + chartH} Z`;
|
|
2649
|
-
return /* @__PURE__ */ (0,
|
|
2650
|
-
/* @__PURE__ */ (0,
|
|
2651
|
-
/* @__PURE__ */ (0,
|
|
2652
|
-
/* @__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" })
|
|
2653
2670
|
] }) }),
|
|
2654
|
-
/* @__PURE__ */ (0,
|
|
2655
|
-
/* @__PURE__ */ (0,
|
|
2656
|
-
/* @__PURE__ */ (0,
|
|
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" })
|
|
2657
2674
|
] }),
|
|
2658
|
-
activeIndex !== null && points[activeIndex] && /* @__PURE__ */ (0,
|
|
2675
|
+
activeIndex !== null && points[activeIndex] && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
2659
2676
|
"circle",
|
|
2660
2677
|
{
|
|
2661
2678
|
cx: points[activeIndex].x,
|
|
@@ -2667,7 +2684,7 @@ var CurveChart = import_react6.default.memo(({ data, labels, width, height, anim
|
|
|
2667
2684
|
)
|
|
2668
2685
|
] }, di);
|
|
2669
2686
|
}),
|
|
2670
|
-
activeX !== null && /* @__PURE__ */ (0,
|
|
2687
|
+
activeX !== null && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
2671
2688
|
"line",
|
|
2672
2689
|
{
|
|
2673
2690
|
x1: activeX,
|
|
@@ -2677,7 +2694,7 @@ var CurveChart = import_react6.default.memo(({ data, labels, width, height, anim
|
|
|
2677
2694
|
className: "chart-crosshair"
|
|
2678
2695
|
}
|
|
2679
2696
|
),
|
|
2680
|
-
/* @__PURE__ */ (0,
|
|
2697
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
2681
2698
|
"rect",
|
|
2682
2699
|
{
|
|
2683
2700
|
x: PADDING.left,
|
|
@@ -2693,9 +2710,9 @@ var CurveChart = import_react6.default.memo(({ data, labels, width, height, anim
|
|
|
2693
2710
|
);
|
|
2694
2711
|
});
|
|
2695
2712
|
CurveChart.displayName = "CurveChart";
|
|
2696
|
-
var BarChart =
|
|
2697
|
-
const entries =
|
|
2698
|
-
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(() => {
|
|
2699
2716
|
const allValues = entries.flatMap(([, v]) => v);
|
|
2700
2717
|
return Math.max(...allValues) * 1.2 || 1;
|
|
2701
2718
|
}, [entries]);
|
|
@@ -2707,7 +2724,7 @@ var BarChart = import_react6.default.memo(({ data, labels, width, height, animat
|
|
|
2707
2724
|
const barGap = groupCount > 1 ? 2 : 0;
|
|
2708
2725
|
const barW = Math.max(1, Math.min(32, (groupW * 0.7 - barGap * (groupCount - 1)) / groupCount));
|
|
2709
2726
|
const baseline = PADDING.top + chartH;
|
|
2710
|
-
const bars =
|
|
2727
|
+
const bars = import_react7.default.useMemo(
|
|
2711
2728
|
() => entries.map(
|
|
2712
2729
|
([, values], di) => values.map((v, i) => {
|
|
2713
2730
|
const totalBarsW = barW * groupCount + barGap * (groupCount - 1);
|
|
@@ -2720,11 +2737,11 @@ var BarChart = import_react6.default.memo(({ data, labels, width, height, animat
|
|
|
2720
2737
|
[entries, maxVal, chartH, groupW, barW, barGap, groupCount]
|
|
2721
2738
|
);
|
|
2722
2739
|
const barLabelStep = getLabelStep(count, chartW);
|
|
2723
|
-
return /* @__PURE__ */ (0,
|
|
2724
|
-
/* @__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 }),
|
|
2725
2742
|
labels.map((label, i) => {
|
|
2726
2743
|
if (i % barLabelStep !== 0) return null;
|
|
2727
|
-
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);
|
|
2728
2745
|
}),
|
|
2729
2746
|
entries.map(([key], di) => {
|
|
2730
2747
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
@@ -2733,7 +2750,7 @@ var BarChart = import_react6.default.memo(({ data, labels, width, height, animat
|
|
|
2733
2750
|
const r2 = Math.min(4, b.w / 2);
|
|
2734
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`;
|
|
2735
2752
|
const delay = 100 + i * 80;
|
|
2736
|
-
return /* @__PURE__ */ (0,
|
|
2753
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
2737
2754
|
"path",
|
|
2738
2755
|
{
|
|
2739
2756
|
d,
|
|
@@ -2754,11 +2771,11 @@ var BarChart = import_react6.default.memo(({ data, labels, width, height, animat
|
|
|
2754
2771
|
] });
|
|
2755
2772
|
});
|
|
2756
2773
|
BarChart.displayName = "BarChart";
|
|
2757
|
-
var PieDonutChart =
|
|
2774
|
+
var PieDonutChart = import_react7.default.memo(
|
|
2758
2775
|
({ data, labels, width, height, animate, isDoughnut, onHover, onMove, onLeave }) => {
|
|
2759
|
-
const entries =
|
|
2760
|
-
const values =
|
|
2761
|
-
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]);
|
|
2762
2779
|
const size = Math.min(width, height);
|
|
2763
2780
|
const cx = size / 2;
|
|
2764
2781
|
const cy = size / 2;
|
|
@@ -2766,10 +2783,10 @@ var PieDonutChart = import_react6.default.memo(
|
|
|
2766
2783
|
const innerR = isDoughnut ? r2 * 0.5 : 0;
|
|
2767
2784
|
const firstKey = entries[0]?.[0] ?? "";
|
|
2768
2785
|
const colorOffset = hashString(firstKey);
|
|
2769
|
-
const maskRef =
|
|
2786
|
+
const maskRef = import_react7.default.useRef(null);
|
|
2770
2787
|
const maskR = r2 + 10;
|
|
2771
2788
|
const maskCircumference = 2 * Math.PI * maskR;
|
|
2772
|
-
|
|
2789
|
+
import_react7.default.useEffect(() => {
|
|
2773
2790
|
if (!animate || !maskRef.current) return;
|
|
2774
2791
|
const el = maskRef.current;
|
|
2775
2792
|
el.style.strokeDasharray = `${maskCircumference}`;
|
|
@@ -2779,7 +2796,7 @@ var PieDonutChart = import_react6.default.memo(
|
|
|
2779
2796
|
el.style.strokeDashoffset = "0";
|
|
2780
2797
|
});
|
|
2781
2798
|
}, [animate, maskCircumference]);
|
|
2782
|
-
const sliceData =
|
|
2799
|
+
const sliceData = import_react7.default.useMemo(() => {
|
|
2783
2800
|
let angle0 = -Math.PI / 2;
|
|
2784
2801
|
let cumulativeAngle = 0;
|
|
2785
2802
|
return values.map((v, i) => {
|
|
@@ -2813,8 +2830,8 @@ var PieDonutChart = import_react6.default.memo(
|
|
|
2813
2830
|
});
|
|
2814
2831
|
}, [values, total, cx, cy, r2, innerR, labels]);
|
|
2815
2832
|
const maskId = `pie-mask-${isDoughnut ? "d" : "p"}`;
|
|
2816
|
-
return /* @__PURE__ */ (0,
|
|
2817
|
-
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)(
|
|
2818
2835
|
"circle",
|
|
2819
2836
|
{
|
|
2820
2837
|
ref: maskRef,
|
|
@@ -2827,7 +2844,7 @@ var PieDonutChart = import_react6.default.memo(
|
|
|
2827
2844
|
transform: `rotate(-90 ${cx} ${cy})`
|
|
2828
2845
|
}
|
|
2829
2846
|
) }) }),
|
|
2830
|
-
/* @__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)(
|
|
2831
2848
|
"path",
|
|
2832
2849
|
{
|
|
2833
2850
|
d: s.d,
|
|
@@ -2838,7 +2855,7 @@ var PieDonutChart = import_react6.default.memo(
|
|
|
2838
2855
|
onMouseLeave: onLeave
|
|
2839
2856
|
}
|
|
2840
2857
|
) }, i)) }),
|
|
2841
|
-
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)(
|
|
2842
2859
|
"text",
|
|
2843
2860
|
{
|
|
2844
2861
|
x: s.lx,
|
|
@@ -2856,9 +2873,9 @@ var PieDonutChart = import_react6.default.memo(
|
|
|
2856
2873
|
);
|
|
2857
2874
|
PieDonutChart.displayName = "PieDonutChart";
|
|
2858
2875
|
var ChartTooltipPortal = ({ clientX, clientY, visible, children }) => {
|
|
2859
|
-
const ref =
|
|
2860
|
-
const [pos, setPos] =
|
|
2861
|
-
|
|
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(() => {
|
|
2862
2879
|
const el = ref.current;
|
|
2863
2880
|
if (!el) return;
|
|
2864
2881
|
const w = el.offsetWidth;
|
|
@@ -2871,7 +2888,7 @@ var ChartTooltipPortal = ({ clientX, clientY, visible, children }) => {
|
|
|
2871
2888
|
if (left < 8) left = 8;
|
|
2872
2889
|
setPos({ left, top });
|
|
2873
2890
|
}, [clientX, clientY]);
|
|
2874
|
-
return /* @__PURE__ */ (0,
|
|
2891
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
2875
2892
|
"div",
|
|
2876
2893
|
{
|
|
2877
2894
|
ref,
|
|
@@ -2888,14 +2905,14 @@ var ChartLegend = ({ data, labels, type }) => {
|
|
|
2888
2905
|
const total = values.reduce((a, b) => a + b, 0) || 1;
|
|
2889
2906
|
const firstKey = entries[0]?.[0] ?? "";
|
|
2890
2907
|
const colorOffset = hashString(firstKey);
|
|
2891
|
-
return /* @__PURE__ */ (0,
|
|
2908
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("div", { className: "chart-legend", children: values.map((v, i) => {
|
|
2892
2909
|
const pct = Math.round(v / total * 100);
|
|
2893
2910
|
const color = PIE_COLORS[(i + colorOffset) % PIE_COLORS.length];
|
|
2894
|
-
return /* @__PURE__ */ (0,
|
|
2895
|
-
/* @__PURE__ */ (0,
|
|
2896
|
-
/* @__PURE__ */ (0,
|
|
2897
|
-
/* @__PURE__ */ (0,
|
|
2898
|
-
/* @__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: [
|
|
2899
2916
|
v.toLocaleString(),
|
|
2900
2917
|
"(",
|
|
2901
2918
|
pct,
|
|
@@ -2905,37 +2922,37 @@ var ChartLegend = ({ data, labels, type }) => {
|
|
|
2905
2922
|
] }, i);
|
|
2906
2923
|
}) });
|
|
2907
2924
|
}
|
|
2908
|
-
return /* @__PURE__ */ (0,
|
|
2925
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("div", { className: "chart-legend", children: entries.map(([key], di) => {
|
|
2909
2926
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
2910
2927
|
const color = palette[2];
|
|
2911
2928
|
const values = entries[di][1];
|
|
2912
2929
|
const sum = values.reduce((a, b) => a + b, 0);
|
|
2913
|
-
return /* @__PURE__ */ (0,
|
|
2914
|
-
/* @__PURE__ */ (0,
|
|
2915
|
-
/* @__PURE__ */ (0,
|
|
2916
|
-
/* @__PURE__ */ (0,
|
|
2917
|
-
/* @__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() })
|
|
2918
2935
|
] })
|
|
2919
2936
|
] }, di);
|
|
2920
2937
|
}) });
|
|
2921
2938
|
};
|
|
2922
|
-
var Chart =
|
|
2939
|
+
var Chart = import_react7.default.memo((props) => {
|
|
2923
2940
|
const { type, data, labels, tooltip: showTooltip = true } = props;
|
|
2924
2941
|
const { tooltip, show, hide, move, containerRef } = useChartTooltip(showTooltip);
|
|
2925
2942
|
const { width, height } = useChartSize(containerRef);
|
|
2926
|
-
const stableData =
|
|
2927
|
-
const stableLabels =
|
|
2928
|
-
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]);
|
|
2929
2946
|
const animate = useChartAnimation(containerRef, dataKey);
|
|
2930
2947
|
const ready = width > 0 && height > 0;
|
|
2931
|
-
return /* @__PURE__ */ (0,
|
|
2932
|
-
ready && type === "line" && /* @__PURE__ */ (0,
|
|
2933
|
-
ready && type === "curve" && /* @__PURE__ */ (0,
|
|
2934
|
-
ready && type === "bar" && /* @__PURE__ */ (0,
|
|
2935
|
-
ready && type === "pie" && /* @__PURE__ */ (0,
|
|
2936
|
-
ready && type === "doughnut" && /* @__PURE__ */ (0,
|
|
2937
|
-
ready && (type === "bar" || type === "pie" || type === "doughnut") && /* @__PURE__ */ (0,
|
|
2938
|
-
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 }) })
|
|
2939
2956
|
] });
|
|
2940
2957
|
});
|
|
2941
2958
|
Chart.displayName = "Chart";
|
|
@@ -2948,7 +2965,7 @@ var import_tokens_core = require("@x-plat/tokens-core");
|
|
|
2948
2965
|
var import_tokens_core2 = require("@x-plat/tokens-core");
|
|
2949
2966
|
|
|
2950
2967
|
// src/components/CheckBox/CheckBox.tsx
|
|
2951
|
-
var
|
|
2968
|
+
var import_jsx_runtime309 = require("react/jsx-runtime");
|
|
2952
2969
|
var CheckBox = (props) => {
|
|
2953
2970
|
const {
|
|
2954
2971
|
checked,
|
|
@@ -2966,8 +2983,8 @@ var CheckBox = (props) => {
|
|
|
2966
2983
|
const checkedClasses = `checked`;
|
|
2967
2984
|
const disabledClasses = "disabled";
|
|
2968
2985
|
const boxClasses = disabled ? disabledClasses : checked ? checkedClasses : uncheckedClasses;
|
|
2969
|
-
return /* @__PURE__ */ (0,
|
|
2970
|
-
/* @__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)(
|
|
2971
2988
|
"input",
|
|
2972
2989
|
{
|
|
2973
2990
|
type: "checkbox",
|
|
@@ -2977,22 +2994,22 @@ var CheckBox = (props) => {
|
|
|
2977
2994
|
...rest
|
|
2978
2995
|
}
|
|
2979
2996
|
),
|
|
2980
|
-
/* @__PURE__ */ (0,
|
|
2981
|
-
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 })
|
|
2982
2999
|
] });
|
|
2983
3000
|
};
|
|
2984
3001
|
CheckBox.displayName = "CheckBox";
|
|
2985
3002
|
var CheckBox_default = CheckBox;
|
|
2986
3003
|
|
|
2987
3004
|
// src/components/Chip/Chip.tsx
|
|
2988
|
-
var
|
|
3005
|
+
var import_jsx_runtime310 = require("react/jsx-runtime");
|
|
2989
3006
|
var Chip = (props) => {
|
|
2990
3007
|
const {
|
|
2991
3008
|
children,
|
|
2992
3009
|
type = "primary",
|
|
2993
3010
|
size = "md"
|
|
2994
3011
|
} = props;
|
|
2995
|
-
return /* @__PURE__ */ (0,
|
|
3012
|
+
return /* @__PURE__ */ (0, import_jsx_runtime310.jsx)("div", { className: clsx_default("lib-xplat-chip", type, size), children });
|
|
2996
3013
|
};
|
|
2997
3014
|
Chip.displayName = "Chip";
|
|
2998
3015
|
var Chip_default = Chip;
|
|
@@ -3001,20 +3018,20 @@ var Chip_default = Chip;
|
|
|
3001
3018
|
var import_react13 = __toESM(require("react"), 1);
|
|
3002
3019
|
|
|
3003
3020
|
// src/components/Input/Input.tsx
|
|
3004
|
-
var
|
|
3021
|
+
var import_react8 = __toESM(require("react"), 1);
|
|
3005
3022
|
|
|
3006
3023
|
// src/components/Input/InputValidations.tsx
|
|
3007
|
-
var
|
|
3024
|
+
var import_jsx_runtime311 = require("react/jsx-runtime");
|
|
3008
3025
|
var InputValidations = (props) => {
|
|
3009
3026
|
const { message, status = "default" } = props;
|
|
3010
|
-
return /* @__PURE__ */ (0,
|
|
3011
|
-
/* @__PURE__ */ (0,
|
|
3012
|
-
status === "default" && /* @__PURE__ */ (0,
|
|
3013
|
-
status === "success" && /* @__PURE__ */ (0,
|
|
3014
|
-
status === "warning" && /* @__PURE__ */ (0,
|
|
3015
|
-
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, {})
|
|
3016
3033
|
] }),
|
|
3017
|
-
/* @__PURE__ */ (0,
|
|
3034
|
+
/* @__PURE__ */ (0, import_jsx_runtime311.jsx)("div", { className: "message", children: message })
|
|
3018
3035
|
] });
|
|
3019
3036
|
};
|
|
3020
3037
|
InputValidations.displayName = "InputValidations";
|
|
@@ -3055,8 +3072,8 @@ var handleTelBackspace = (prevValue, currValue) => {
|
|
|
3055
3072
|
};
|
|
3056
3073
|
|
|
3057
3074
|
// src/components/Input/Input.tsx
|
|
3058
|
-
var
|
|
3059
|
-
var
|
|
3075
|
+
var import_jsx_runtime312 = require("react/jsx-runtime");
|
|
3076
|
+
var import_react9 = require("react");
|
|
3060
3077
|
var formatValue = (type, value) => {
|
|
3061
3078
|
if (value === null || value === void 0) return "";
|
|
3062
3079
|
const strValue = Array.isArray(value) ? String(value[0] ?? "") : String(value);
|
|
@@ -3104,7 +3121,7 @@ var parseValue = (type, value) => {
|
|
|
3104
3121
|
return value;
|
|
3105
3122
|
}
|
|
3106
3123
|
};
|
|
3107
|
-
var Input =
|
|
3124
|
+
var Input = import_react8.default.forwardRef((props, ref) => {
|
|
3108
3125
|
const {
|
|
3109
3126
|
value,
|
|
3110
3127
|
onChange,
|
|
@@ -3130,13 +3147,13 @@ var Input = import_react7.default.forwardRef((props, ref) => {
|
|
|
3130
3147
|
onChange(event);
|
|
3131
3148
|
}
|
|
3132
3149
|
};
|
|
3133
|
-
return /* @__PURE__ */ (0,
|
|
3134
|
-
/* @__PURE__ */ (0,
|
|
3150
|
+
return /* @__PURE__ */ (0, import_jsx_runtime312.jsxs)("div", { className: "lib-xplat-input-wrap", children: [
|
|
3151
|
+
/* @__PURE__ */ (0, import_jsx_runtime312.jsxs)(
|
|
3135
3152
|
"div",
|
|
3136
3153
|
{
|
|
3137
3154
|
className: clsx_default("lib-xplat-input", size, disabled ? "disabled" : void 0),
|
|
3138
3155
|
children: [
|
|
3139
|
-
/* @__PURE__ */ (0,
|
|
3156
|
+
/* @__PURE__ */ (0, import_jsx_runtime312.jsx)(
|
|
3140
3157
|
"input",
|
|
3141
3158
|
{
|
|
3142
3159
|
...inputProps,
|
|
@@ -3147,11 +3164,11 @@ var Input = import_react7.default.forwardRef((props, ref) => {
|
|
|
3147
3164
|
onChange: handleChange
|
|
3148
3165
|
}
|
|
3149
3166
|
),
|
|
3150
|
-
suffix && /* @__PURE__ */ (0,
|
|
3167
|
+
suffix && /* @__PURE__ */ (0, import_jsx_runtime312.jsx)("div", { className: "suffix", children: suffix })
|
|
3151
3168
|
]
|
|
3152
3169
|
}
|
|
3153
3170
|
),
|
|
3154
|
-
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)(
|
|
3155
3172
|
InputValidations_default,
|
|
3156
3173
|
{
|
|
3157
3174
|
...validation,
|
|
@@ -3164,20 +3181,20 @@ Input.displayName = "Input";
|
|
|
3164
3181
|
var Input_default = Input;
|
|
3165
3182
|
|
|
3166
3183
|
// src/components/Input/PasswordInput/PasswordInput.tsx
|
|
3167
|
-
var
|
|
3168
|
-
var
|
|
3169
|
-
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(
|
|
3170
3187
|
(props, ref) => {
|
|
3171
3188
|
const { reg: _reg, ...inputProps } = props;
|
|
3172
|
-
const [isView, setIsView] =
|
|
3189
|
+
const [isView, setIsView] = import_react10.default.useState(false);
|
|
3173
3190
|
const handleChangeView = () => {
|
|
3174
3191
|
setIsView((prev) => !prev);
|
|
3175
3192
|
};
|
|
3176
|
-
return /* @__PURE__ */ (0,
|
|
3193
|
+
return /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(
|
|
3177
3194
|
Input_default,
|
|
3178
3195
|
{
|
|
3179
3196
|
...inputProps,
|
|
3180
|
-
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, {}) }),
|
|
3181
3198
|
type: isView ? "text" : "password",
|
|
3182
3199
|
ref
|
|
3183
3200
|
}
|
|
@@ -3190,23 +3207,6 @@ var PasswordInput_default = PasswordInput;
|
|
|
3190
3207
|
// src/components/Modal/Modal.tsx
|
|
3191
3208
|
var import_react11 = __toESM(require("react"), 1);
|
|
3192
3209
|
var import_react_dom2 = require("react-dom");
|
|
3193
|
-
|
|
3194
|
-
// src/tokens/hooks/Portal.tsx
|
|
3195
|
-
var import_react10 = __toESM(require("react"), 1);
|
|
3196
|
-
var import_react_dom = __toESM(require("react-dom"), 1);
|
|
3197
|
-
var import_jsx_runtime313 = require("react/jsx-runtime");
|
|
3198
|
-
var PortalContainerContext = import_react10.default.createContext(null);
|
|
3199
|
-
var PortalProvider = ({ container, children }) => /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(PortalContainerContext.Provider, { value: container, children });
|
|
3200
|
-
var Portal = ({ children }) => {
|
|
3201
|
-
const contextContainer = import_react10.default.useContext(PortalContainerContext);
|
|
3202
|
-
if (typeof document === "undefined") return null;
|
|
3203
|
-
const container = contextContainer ?? document.body;
|
|
3204
|
-
return import_react_dom.default.createPortal(children, container);
|
|
3205
|
-
};
|
|
3206
|
-
Portal.displayName = "Portal";
|
|
3207
|
-
var Portal_default = Portal;
|
|
3208
|
-
|
|
3209
|
-
// src/components/Modal/Modal.tsx
|
|
3210
3210
|
var import_jsx_runtime314 = require("react/jsx-runtime");
|
|
3211
3211
|
var ANIMATION_DURATION_MS = 200;
|
|
3212
3212
|
var Modal = (props) => {
|