@x-plat/design-system 0.5.35 → 0.5.36
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 +146 -200
- package/dist/components/Chart/index.css +12 -25
- package/dist/components/Chart/index.js +132 -186
- package/dist/components/index.cjs +193 -231
- package/dist/components/index.css +12 -25
- package/dist/components/index.js +173 -211
- package/dist/index.cjs +193 -231
- package/dist/index.css +12 -25
- package/dist/index.js +173 -211
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6229,25 +6229,8 @@ var CardTab = Object.assign(CardTabRoot, {
|
|
|
6229
6229
|
var CardTab_default = CardTab;
|
|
6230
6230
|
|
|
6231
6231
|
// src/components/Chart/Chart.tsx
|
|
6232
|
-
import React7 from "react";
|
|
6233
|
-
|
|
6234
|
-
// src/tokens/hooks/Portal.tsx
|
|
6235
6232
|
import React6 from "react";
|
|
6236
|
-
import
|
|
6237
|
-
import { jsx as jsx307 } from "react/jsx-runtime";
|
|
6238
|
-
var PortalContainerContext = React6.createContext(null);
|
|
6239
|
-
var PortalProvider = ({ container, children }) => /* @__PURE__ */ jsx307(PortalContainerContext.Provider, { value: container, children });
|
|
6240
|
-
var Portal = ({ children }) => {
|
|
6241
|
-
const contextContainer = React6.useContext(PortalContainerContext);
|
|
6242
|
-
if (typeof document === "undefined") return null;
|
|
6243
|
-
const container = contextContainer ?? document.body;
|
|
6244
|
-
return ReactDOM.createPortal(children, container);
|
|
6245
|
-
};
|
|
6246
|
-
Portal.displayName = "Portal";
|
|
6247
|
-
var Portal_default = Portal;
|
|
6248
|
-
|
|
6249
|
-
// src/components/Chart/Chart.tsx
|
|
6250
|
-
import { Fragment as Fragment2, jsx as jsx308, jsxs as jsxs197 } from "react/jsx-runtime";
|
|
6233
|
+
import { Fragment as Fragment2, jsx as jsx307, jsxs as jsxs197 } from "react/jsx-runtime";
|
|
6251
6234
|
var CATEGORICAL_COUNT2 = 8;
|
|
6252
6235
|
var LINE_BAR_PALETTES = Array.from({ length: CATEGORICAL_COUNT2 }, (_, i) => {
|
|
6253
6236
|
const n = i + 1;
|
|
@@ -6293,11 +6276,11 @@ var toSmoothPath = (points) => {
|
|
|
6293
6276
|
};
|
|
6294
6277
|
var RESIZE_SETTLE_MS = 150;
|
|
6295
6278
|
var useChartSize = (ref) => {
|
|
6296
|
-
const [size, setSize] =
|
|
6297
|
-
const settleTimer =
|
|
6298
|
-
const committedSize =
|
|
6299
|
-
const initialRef =
|
|
6300
|
-
|
|
6279
|
+
const [size, setSize] = React6.useState({ width: 0, height: 0 });
|
|
6280
|
+
const settleTimer = React6.useRef(0);
|
|
6281
|
+
const committedSize = React6.useRef({ width: 0, height: 0 });
|
|
6282
|
+
const initialRef = React6.useRef(true);
|
|
6283
|
+
React6.useEffect(() => {
|
|
6301
6284
|
const el = ref.current;
|
|
6302
6285
|
if (!el) return;
|
|
6303
6286
|
const observer = new ResizeObserver((entries) => {
|
|
@@ -6339,10 +6322,10 @@ var useChartSize = (ref) => {
|
|
|
6339
6322
|
};
|
|
6340
6323
|
var prefersReducedMotion = () => typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
6341
6324
|
var useChartAnimation = (containerRef, dataKey) => {
|
|
6342
|
-
const [animate, setAnimate] =
|
|
6343
|
-
const prevDataKey =
|
|
6344
|
-
const hasAnimated =
|
|
6345
|
-
|
|
6325
|
+
const [animate, setAnimate] = React6.useState(false);
|
|
6326
|
+
const prevDataKey = React6.useRef(dataKey);
|
|
6327
|
+
const hasAnimated = React6.useRef(false);
|
|
6328
|
+
React6.useEffect(() => {
|
|
6346
6329
|
if (prefersReducedMotion()) return;
|
|
6347
6330
|
const el = containerRef.current;
|
|
6348
6331
|
if (!el) return;
|
|
@@ -6358,7 +6341,7 @@ var useChartAnimation = (containerRef, dataKey) => {
|
|
|
6358
6341
|
observer.observe(el);
|
|
6359
6342
|
return () => observer.disconnect();
|
|
6360
6343
|
}, [containerRef]);
|
|
6361
|
-
|
|
6344
|
+
React6.useEffect(() => {
|
|
6362
6345
|
if (dataKey !== prevDataKey.current) {
|
|
6363
6346
|
prevDataKey.current = dataKey;
|
|
6364
6347
|
if (prefersReducedMotion()) return;
|
|
@@ -6372,39 +6355,47 @@ var useChartAnimation = (containerRef, dataKey) => {
|
|
|
6372
6355
|
};
|
|
6373
6356
|
var TOOLTIP_OFFSET = 12;
|
|
6374
6357
|
var useChartTooltip = (enabled) => {
|
|
6375
|
-
const [tooltip, setTooltip] =
|
|
6358
|
+
const [tooltip, setTooltip] = React6.useState({
|
|
6376
6359
|
visible: false,
|
|
6377
|
-
|
|
6378
|
-
|
|
6360
|
+
x: 0,
|
|
6361
|
+
y: 0,
|
|
6379
6362
|
content: ""
|
|
6380
6363
|
});
|
|
6381
|
-
const containerRef =
|
|
6382
|
-
const rafRef =
|
|
6383
|
-
const move =
|
|
6364
|
+
const containerRef = React6.useRef(null);
|
|
6365
|
+
const rafRef = React6.useRef(0);
|
|
6366
|
+
const move = React6.useCallback((e) => {
|
|
6384
6367
|
if (!enabled) return;
|
|
6385
6368
|
const cx = e.clientX;
|
|
6386
6369
|
const cy = e.clientY;
|
|
6387
6370
|
cancelAnimationFrame(rafRef.current);
|
|
6388
6371
|
rafRef.current = requestAnimationFrame(() => {
|
|
6389
|
-
|
|
6372
|
+
const rect = containerRef.current?.getBoundingClientRect();
|
|
6373
|
+
if (!rect) return;
|
|
6374
|
+
setTooltip((prev) => ({ ...prev, x: cx - rect.left, y: cy - rect.top }));
|
|
6390
6375
|
});
|
|
6391
6376
|
}, [enabled]);
|
|
6392
|
-
const show =
|
|
6377
|
+
const show = React6.useCallback((e, content) => {
|
|
6393
6378
|
if (!enabled) return;
|
|
6394
|
-
|
|
6379
|
+
const rect = containerRef.current?.getBoundingClientRect();
|
|
6380
|
+
if (!rect) return;
|
|
6381
|
+
setTooltip({ visible: true, x: e.clientX - rect.left, y: e.clientY - rect.top, content });
|
|
6395
6382
|
}, [enabled]);
|
|
6396
|
-
const
|
|
6383
|
+
const showAt = React6.useCallback((x, y, content) => {
|
|
6384
|
+
if (!enabled) return;
|
|
6385
|
+
setTooltip({ visible: true, x, y, content });
|
|
6386
|
+
}, [enabled]);
|
|
6387
|
+
const hide = React6.useCallback(() => {
|
|
6397
6388
|
cancelAnimationFrame(rafRef.current);
|
|
6398
6389
|
setTooltip((prev) => ({ ...prev, visible: false }));
|
|
6399
6390
|
}, []);
|
|
6400
|
-
return { tooltip, show, hide, move, containerRef };
|
|
6391
|
+
return { tooltip, show, showAt, hide, move, containerRef };
|
|
6401
6392
|
};
|
|
6402
|
-
var GridLines =
|
|
6393
|
+
var GridLines = React6.memo(({ width, height, chartH, maxVal }) => /* @__PURE__ */ jsx307(Fragment2, { children: [0, 0.25, 0.5, 0.75, 1].map((ratio) => {
|
|
6403
6394
|
const y = PADDING.top + (1 - ratio) * chartH;
|
|
6404
6395
|
const val = Math.round(maxVal * ratio);
|
|
6405
6396
|
return /* @__PURE__ */ jsxs197("g", { children: [
|
|
6406
|
-
/* @__PURE__ */
|
|
6407
|
-
/* @__PURE__ */
|
|
6397
|
+
/* @__PURE__ */ jsx307("line", { x1: PADDING.left, y1: y, x2: width - PADDING.right, y2: y, className: "chart-grid" }),
|
|
6398
|
+
/* @__PURE__ */ jsx307("text", { x: PADDING.left - 8, y: y + 4, className: "chart-axis-label", textAnchor: "end", children: val })
|
|
6408
6399
|
] }, ratio);
|
|
6409
6400
|
}) }));
|
|
6410
6401
|
GridLines.displayName = "GridLines";
|
|
@@ -6414,18 +6405,18 @@ var getLabelStep = (count, chartW) => {
|
|
|
6414
6405
|
if (count <= maxLabels) return 1;
|
|
6415
6406
|
return Math.ceil(count / maxLabels);
|
|
6416
6407
|
};
|
|
6417
|
-
var AxisLabels =
|
|
6408
|
+
var AxisLabels = React6.memo(({ labels, count, chartW, height }) => {
|
|
6418
6409
|
const step = getLabelStep(count, chartW);
|
|
6419
|
-
return /* @__PURE__ */
|
|
6410
|
+
return /* @__PURE__ */ jsx307(Fragment2, { children: labels.map((label, i) => {
|
|
6420
6411
|
if (i % step !== 0) return null;
|
|
6421
6412
|
const x = PADDING.left + i / (count - 1 || 1) * chartW;
|
|
6422
|
-
return /* @__PURE__ */
|
|
6413
|
+
return /* @__PURE__ */ jsx307("text", { x, y: height - 8, className: "chart-axis-label", textAnchor: "middle", children: label }, i);
|
|
6423
6414
|
}) });
|
|
6424
6415
|
});
|
|
6425
6416
|
AxisLabels.displayName = "AxisLabels";
|
|
6426
6417
|
var useCrosshair = (seriesPoints, entries, labels, chartH) => {
|
|
6427
|
-
const [activeIndex, setActiveIndex] =
|
|
6428
|
-
const handleMouseMove =
|
|
6418
|
+
const [activeIndex, setActiveIndex] = React6.useState(null);
|
|
6419
|
+
const handleMouseMove = React6.useCallback((e) => {
|
|
6429
6420
|
const svg = e.currentTarget;
|
|
6430
6421
|
const rect = svg.getBoundingClientRect();
|
|
6431
6422
|
const mx = (e.clientX - rect.left) / rect.width * svg.viewBox.baseVal.width;
|
|
@@ -6444,17 +6435,17 @@ var useCrosshair = (seriesPoints, entries, labels, chartH) => {
|
|
|
6444
6435
|
}
|
|
6445
6436
|
setActiveIndex(minDist <= threshold ? closest : null);
|
|
6446
6437
|
}, [seriesPoints]);
|
|
6447
|
-
const handleMouseLeave =
|
|
6438
|
+
const handleMouseLeave = React6.useCallback(() => {
|
|
6448
6439
|
setActiveIndex(null);
|
|
6449
6440
|
}, []);
|
|
6450
|
-
const tooltipContent =
|
|
6441
|
+
const tooltipContent = React6.useMemo(() => {
|
|
6451
6442
|
if (activeIndex === null) return "";
|
|
6452
6443
|
return entries.map(([key], di) => {
|
|
6453
6444
|
const p = seriesPoints[di]?.[activeIndex];
|
|
6454
6445
|
return p ? `${key}: ${p.v}` : "";
|
|
6455
6446
|
}).filter(Boolean).join(" / ");
|
|
6456
6447
|
}, [activeIndex, entries, seriesPoints]);
|
|
6457
|
-
const getTooltipAt =
|
|
6448
|
+
const getTooltipAt = React6.useCallback((idx) => {
|
|
6458
6449
|
return entries.map(([key], di) => {
|
|
6459
6450
|
const p = seriesPoints[di]?.[idx];
|
|
6460
6451
|
return p ? `${key}: ${p.v}` : "";
|
|
@@ -6462,16 +6453,16 @@ var useCrosshair = (seriesPoints, entries, labels, chartH) => {
|
|
|
6462
6453
|
}, [entries, seriesPoints]);
|
|
6463
6454
|
return { activeIndex, handleMouseMove, handleMouseLeave, tooltipContent, getTooltipAt };
|
|
6464
6455
|
};
|
|
6465
|
-
var LineChart =
|
|
6466
|
-
const entries =
|
|
6467
|
-
const maxVal =
|
|
6456
|
+
var LineChart = React6.memo(({ data, labels, width, height, animate, onHover, onShowAt, onMove, onLeave }) => {
|
|
6457
|
+
const entries = React6.useMemo(() => Object.entries(data), [data]);
|
|
6458
|
+
const maxVal = React6.useMemo(() => {
|
|
6468
6459
|
const allValues = entries.flatMap(([, v]) => v);
|
|
6469
6460
|
return Math.max(...allValues) * 1.2 || 1;
|
|
6470
6461
|
}, [entries]);
|
|
6471
6462
|
const count = labels.length;
|
|
6472
6463
|
const chartW = width - PADDING.left - PADDING.right;
|
|
6473
6464
|
const chartH = height - PADDING.top - PADDING.bottom;
|
|
6474
|
-
const seriesPoints =
|
|
6465
|
+
const seriesPoints = React6.useMemo(
|
|
6475
6466
|
() => entries.map(
|
|
6476
6467
|
([, values]) => values.map((v, i) => ({
|
|
6477
6468
|
x: PADDING.left + i / (count - 1 || 1) * chartW,
|
|
@@ -6481,9 +6472,9 @@ var LineChart = React7.memo(({ data, labels, width, height, animate, onHover, on
|
|
|
6481
6472
|
),
|
|
6482
6473
|
[entries, count, chartW, chartH, maxVal]
|
|
6483
6474
|
);
|
|
6484
|
-
const clipRef =
|
|
6475
|
+
const clipRef = React6.useRef(null);
|
|
6485
6476
|
const { activeIndex, handleMouseMove, handleMouseLeave, getTooltipAt } = useCrosshair(seriesPoints, entries, labels, chartH);
|
|
6486
|
-
|
|
6477
|
+
React6.useEffect(() => {
|
|
6487
6478
|
if (!animate || !clipRef.current) return;
|
|
6488
6479
|
clipRef.current.setAttribute("width", "0");
|
|
6489
6480
|
requestAnimationFrame(() => {
|
|
@@ -6502,23 +6493,9 @@ var LineChart = React7.memo(({ data, labels, width, height, animate, onHover, on
|
|
|
6502
6493
|
className: "chart-svg",
|
|
6503
6494
|
onMouseMove: (e) => {
|
|
6504
6495
|
handleMouseMove(e);
|
|
6505
|
-
|
|
6506
|
-
|
|
6507
|
-
|
|
6508
|
-
const points = seriesPoints[0];
|
|
6509
|
-
if (!points || points.length === 0) return;
|
|
6510
|
-
const step = points.length > 1 ? Math.abs(points[1].x - points[0].x) : 20;
|
|
6511
|
-
let closest = 0;
|
|
6512
|
-
let minDist = Math.abs(points[0].x - mx);
|
|
6513
|
-
for (let i = 1; i < points.length; i++) {
|
|
6514
|
-
const dist = Math.abs(points[i].x - mx);
|
|
6515
|
-
if (dist < minDist) {
|
|
6516
|
-
minDist = dist;
|
|
6517
|
-
closest = i;
|
|
6518
|
-
}
|
|
6519
|
-
}
|
|
6520
|
-
if (minDist <= step / 2) {
|
|
6521
|
-
onHover(e, `${labels[closest]} \u2014 ${getTooltipAt(closest)}`);
|
|
6496
|
+
if (activeIndex !== null && seriesPoints[0]?.[activeIndex]) {
|
|
6497
|
+
const p = seriesPoints[0][activeIndex];
|
|
6498
|
+
onShowAt(p.x, p.y, `${labels[activeIndex]} \u2014 ${getTooltipAt(activeIndex)}`);
|
|
6522
6499
|
} else {
|
|
6523
6500
|
onLeave();
|
|
6524
6501
|
}
|
|
@@ -6528,9 +6505,9 @@ var LineChart = React7.memo(({ data, labels, width, height, animate, onHover, on
|
|
|
6528
6505
|
onLeave();
|
|
6529
6506
|
},
|
|
6530
6507
|
children: [
|
|
6531
|
-
animate && /* @__PURE__ */
|
|
6532
|
-
/* @__PURE__ */
|
|
6533
|
-
/* @__PURE__ */
|
|
6508
|
+
animate && /* @__PURE__ */ jsx307("defs", { children: /* @__PURE__ */ jsx307("clipPath", { id: lineClipId, children: /* @__PURE__ */ jsx307("rect", { ref: clipRef, x: "0", y: "0", width: animate ? 0 : width, height }) }) }),
|
|
6509
|
+
/* @__PURE__ */ jsx307(GridLines, { width, height, chartH, maxVal }),
|
|
6510
|
+
/* @__PURE__ */ jsx307(AxisLabels, { labels, count, chartW, height }),
|
|
6534
6511
|
entries.map(([key], di) => {
|
|
6535
6512
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
6536
6513
|
const color = palette[2];
|
|
@@ -6540,15 +6517,15 @@ var LineChart = React7.memo(({ data, labels, width, height, animate, onHover, on
|
|
|
6540
6517
|
const polyPoints = points.map((p) => `${p.x},${p.y}`).join(" ");
|
|
6541
6518
|
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`;
|
|
6542
6519
|
return /* @__PURE__ */ jsxs197("g", { children: [
|
|
6543
|
-
/* @__PURE__ */
|
|
6544
|
-
/* @__PURE__ */
|
|
6545
|
-
/* @__PURE__ */
|
|
6520
|
+
/* @__PURE__ */ jsx307("defs", { children: /* @__PURE__ */ jsxs197("linearGradient", { id: gradientId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
6521
|
+
/* @__PURE__ */ jsx307("stop", { offset: "0%", stopColor: areaColor, stopOpacity: "0.2" }),
|
|
6522
|
+
/* @__PURE__ */ jsx307("stop", { offset: "100%", stopColor: areaColor, stopOpacity: "0" })
|
|
6546
6523
|
] }) }),
|
|
6547
6524
|
/* @__PURE__ */ jsxs197("g", { clipPath: animate ? `url(#${lineClipId})` : void 0, children: [
|
|
6548
|
-
/* @__PURE__ */
|
|
6549
|
-
/* @__PURE__ */
|
|
6525
|
+
/* @__PURE__ */ jsx307("path", { d: areaD, fill: `url(#${gradientId})` }),
|
|
6526
|
+
/* @__PURE__ */ jsx307("polyline", { points: polyPoints, fill: "none", stroke: color, strokeWidth: "2" })
|
|
6550
6527
|
] }),
|
|
6551
|
-
activeIndex !== null && points[activeIndex] && /* @__PURE__ */
|
|
6528
|
+
activeIndex !== null && points[activeIndex] && /* @__PURE__ */ jsx307(
|
|
6552
6529
|
"circle",
|
|
6553
6530
|
{
|
|
6554
6531
|
cx: points[activeIndex].x,
|
|
@@ -6560,7 +6537,7 @@ var LineChart = React7.memo(({ data, labels, width, height, animate, onHover, on
|
|
|
6560
6537
|
)
|
|
6561
6538
|
] }, di);
|
|
6562
6539
|
}),
|
|
6563
|
-
activeX !== null && /* @__PURE__ */
|
|
6540
|
+
activeX !== null && /* @__PURE__ */ jsx307(
|
|
6564
6541
|
"line",
|
|
6565
6542
|
{
|
|
6566
6543
|
x1: activeX,
|
|
@@ -6570,7 +6547,7 @@ var LineChart = React7.memo(({ data, labels, width, height, animate, onHover, on
|
|
|
6570
6547
|
className: "chart-crosshair"
|
|
6571
6548
|
}
|
|
6572
6549
|
),
|
|
6573
|
-
/* @__PURE__ */
|
|
6550
|
+
/* @__PURE__ */ jsx307(
|
|
6574
6551
|
"rect",
|
|
6575
6552
|
{
|
|
6576
6553
|
x: PADDING.left,
|
|
@@ -6586,16 +6563,16 @@ var LineChart = React7.memo(({ data, labels, width, height, animate, onHover, on
|
|
|
6586
6563
|
);
|
|
6587
6564
|
});
|
|
6588
6565
|
LineChart.displayName = "LineChart";
|
|
6589
|
-
var CurveChart =
|
|
6590
|
-
const entries =
|
|
6591
|
-
const maxVal =
|
|
6566
|
+
var CurveChart = React6.memo(({ data, labels, width, height, animate, onHover, onShowAt, onMove, onLeave }) => {
|
|
6567
|
+
const entries = React6.useMemo(() => Object.entries(data), [data]);
|
|
6568
|
+
const maxVal = React6.useMemo(() => {
|
|
6592
6569
|
const allValues = entries.flatMap(([, v]) => v);
|
|
6593
6570
|
return Math.max(...allValues) * 1.2 || 1;
|
|
6594
6571
|
}, [entries]);
|
|
6595
6572
|
const count = labels.length;
|
|
6596
6573
|
const chartW = width - PADDING.left - PADDING.right;
|
|
6597
6574
|
const chartH = height - PADDING.top - PADDING.bottom;
|
|
6598
|
-
const seriesPoints =
|
|
6575
|
+
const seriesPoints = React6.useMemo(
|
|
6599
6576
|
() => entries.map(
|
|
6600
6577
|
([, values]) => values.map((v, i) => ({
|
|
6601
6578
|
x: PADDING.left + i / (count - 1 || 1) * chartW,
|
|
@@ -6605,9 +6582,9 @@ var CurveChart = React7.memo(({ data, labels, width, height, animate, onHover, o
|
|
|
6605
6582
|
),
|
|
6606
6583
|
[entries, count, chartW, chartH, maxVal]
|
|
6607
6584
|
);
|
|
6608
|
-
const curveClipRef =
|
|
6585
|
+
const curveClipRef = React6.useRef(null);
|
|
6609
6586
|
const { activeIndex, handleMouseMove, handleMouseLeave, getTooltipAt } = useCrosshair(seriesPoints, entries, labels, chartH);
|
|
6610
|
-
|
|
6587
|
+
React6.useEffect(() => {
|
|
6611
6588
|
if (!animate || !curveClipRef.current) return;
|
|
6612
6589
|
curveClipRef.current.setAttribute("width", "0");
|
|
6613
6590
|
requestAnimationFrame(() => {
|
|
@@ -6626,23 +6603,9 @@ var CurveChart = React7.memo(({ data, labels, width, height, animate, onHover, o
|
|
|
6626
6603
|
className: "chart-svg",
|
|
6627
6604
|
onMouseMove: (e) => {
|
|
6628
6605
|
handleMouseMove(e);
|
|
6629
|
-
|
|
6630
|
-
|
|
6631
|
-
|
|
6632
|
-
const points = seriesPoints[0];
|
|
6633
|
-
if (!points || points.length === 0) return;
|
|
6634
|
-
const step = points.length > 1 ? Math.abs(points[1].x - points[0].x) : 20;
|
|
6635
|
-
let closest = 0;
|
|
6636
|
-
let minDist = Math.abs(points[0].x - mx);
|
|
6637
|
-
for (let i = 1; i < points.length; i++) {
|
|
6638
|
-
const dist = Math.abs(points[i].x - mx);
|
|
6639
|
-
if (dist < minDist) {
|
|
6640
|
-
minDist = dist;
|
|
6641
|
-
closest = i;
|
|
6642
|
-
}
|
|
6643
|
-
}
|
|
6644
|
-
if (minDist <= step / 2) {
|
|
6645
|
-
onHover(e, `${labels[closest]} \u2014 ${getTooltipAt(closest)}`);
|
|
6606
|
+
if (activeIndex !== null && seriesPoints[0]?.[activeIndex]) {
|
|
6607
|
+
const p = seriesPoints[0][activeIndex];
|
|
6608
|
+
onShowAt(p.x, p.y, `${labels[activeIndex]} \u2014 ${getTooltipAt(activeIndex)}`);
|
|
6646
6609
|
} else {
|
|
6647
6610
|
onLeave();
|
|
6648
6611
|
}
|
|
@@ -6652,9 +6615,9 @@ var CurveChart = React7.memo(({ data, labels, width, height, animate, onHover, o
|
|
|
6652
6615
|
onLeave();
|
|
6653
6616
|
},
|
|
6654
6617
|
children: [
|
|
6655
|
-
animate && /* @__PURE__ */
|
|
6656
|
-
/* @__PURE__ */
|
|
6657
|
-
/* @__PURE__ */
|
|
6618
|
+
animate && /* @__PURE__ */ jsx307("defs", { children: /* @__PURE__ */ jsx307("clipPath", { id: curveClipId, children: /* @__PURE__ */ jsx307("rect", { ref: curveClipRef, x: "0", y: "0", width: animate ? 0 : width, height }) }) }),
|
|
6619
|
+
/* @__PURE__ */ jsx307(GridLines, { width, height, chartH, maxVal }),
|
|
6620
|
+
/* @__PURE__ */ jsx307(AxisLabels, { labels, count, chartW, height }),
|
|
6658
6621
|
entries.map(([key], di) => {
|
|
6659
6622
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
6660
6623
|
const color = palette[2];
|
|
@@ -6664,15 +6627,15 @@ var CurveChart = React7.memo(({ data, labels, width, height, animate, onHover, o
|
|
|
6664
6627
|
const linePath = toSmoothPath(points);
|
|
6665
6628
|
const areaPath = linePath + ` L ${points[points.length - 1].x} ${PADDING.top + chartH} L ${points[0].x} ${PADDING.top + chartH} Z`;
|
|
6666
6629
|
return /* @__PURE__ */ jsxs197("g", { children: [
|
|
6667
|
-
/* @__PURE__ */
|
|
6668
|
-
/* @__PURE__ */
|
|
6669
|
-
/* @__PURE__ */
|
|
6630
|
+
/* @__PURE__ */ jsx307("defs", { children: /* @__PURE__ */ jsxs197("linearGradient", { id: gradientId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
6631
|
+
/* @__PURE__ */ jsx307("stop", { offset: "0%", stopColor: areaColor, stopOpacity: "0.4" }),
|
|
6632
|
+
/* @__PURE__ */ jsx307("stop", { offset: "100%", stopColor: areaColor, stopOpacity: "0.02" })
|
|
6670
6633
|
] }) }),
|
|
6671
6634
|
/* @__PURE__ */ jsxs197("g", { clipPath: animate ? `url(#${curveClipId})` : void 0, children: [
|
|
6672
|
-
/* @__PURE__ */
|
|
6673
|
-
/* @__PURE__ */
|
|
6635
|
+
/* @__PURE__ */ jsx307("path", { d: areaPath, fill: `url(#${gradientId})` }),
|
|
6636
|
+
/* @__PURE__ */ jsx307("path", { d: linePath, fill: "none", stroke: color, strokeWidth: "2" })
|
|
6674
6637
|
] }),
|
|
6675
|
-
activeIndex !== null && points[activeIndex] && /* @__PURE__ */
|
|
6638
|
+
activeIndex !== null && points[activeIndex] && /* @__PURE__ */ jsx307(
|
|
6676
6639
|
"circle",
|
|
6677
6640
|
{
|
|
6678
6641
|
cx: points[activeIndex].x,
|
|
@@ -6684,7 +6647,7 @@ var CurveChart = React7.memo(({ data, labels, width, height, animate, onHover, o
|
|
|
6684
6647
|
)
|
|
6685
6648
|
] }, di);
|
|
6686
6649
|
}),
|
|
6687
|
-
activeX !== null && /* @__PURE__ */
|
|
6650
|
+
activeX !== null && /* @__PURE__ */ jsx307(
|
|
6688
6651
|
"line",
|
|
6689
6652
|
{
|
|
6690
6653
|
x1: activeX,
|
|
@@ -6694,7 +6657,7 @@ var CurveChart = React7.memo(({ data, labels, width, height, animate, onHover, o
|
|
|
6694
6657
|
className: "chart-crosshair"
|
|
6695
6658
|
}
|
|
6696
6659
|
),
|
|
6697
|
-
/* @__PURE__ */
|
|
6660
|
+
/* @__PURE__ */ jsx307(
|
|
6698
6661
|
"rect",
|
|
6699
6662
|
{
|
|
6700
6663
|
x: PADDING.left,
|
|
@@ -6710,9 +6673,9 @@ var CurveChart = React7.memo(({ data, labels, width, height, animate, onHover, o
|
|
|
6710
6673
|
);
|
|
6711
6674
|
});
|
|
6712
6675
|
CurveChart.displayName = "CurveChart";
|
|
6713
|
-
var BarChart =
|
|
6714
|
-
const entries =
|
|
6715
|
-
const maxVal =
|
|
6676
|
+
var BarChart = React6.memo(({ data, labels, width, height, animate, onHover, onShowAt, onMove, onLeave }) => {
|
|
6677
|
+
const entries = React6.useMemo(() => Object.entries(data), [data]);
|
|
6678
|
+
const maxVal = React6.useMemo(() => {
|
|
6716
6679
|
const allValues = entries.flatMap(([, v]) => v);
|
|
6717
6680
|
return Math.max(...allValues) * 1.2 || 1;
|
|
6718
6681
|
}, [entries]);
|
|
@@ -6724,7 +6687,7 @@ var BarChart = React7.memo(({ data, labels, width, height, animate, onHover, onM
|
|
|
6724
6687
|
const barGap = groupCount > 1 ? 2 : 0;
|
|
6725
6688
|
const barW = Math.max(1, Math.min(32, (groupW * 0.7 - barGap * (groupCount - 1)) / groupCount));
|
|
6726
6689
|
const baseline = PADDING.top + chartH;
|
|
6727
|
-
const bars =
|
|
6690
|
+
const bars = React6.useMemo(
|
|
6728
6691
|
() => entries.map(
|
|
6729
6692
|
([, values], di) => values.map((v, i) => {
|
|
6730
6693
|
const totalBarsW = barW * groupCount + barGap * (groupCount - 1);
|
|
@@ -6738,10 +6701,10 @@ var BarChart = React7.memo(({ data, labels, width, height, animate, onHover, onM
|
|
|
6738
6701
|
);
|
|
6739
6702
|
const barLabelStep = getLabelStep(count, chartW);
|
|
6740
6703
|
return /* @__PURE__ */ jsxs197("svg", { viewBox: `0 0 ${width} ${height}`, className: "chart-svg", children: [
|
|
6741
|
-
/* @__PURE__ */
|
|
6704
|
+
/* @__PURE__ */ jsx307(GridLines, { width, height, chartH, maxVal }),
|
|
6742
6705
|
labels.map((label, i) => {
|
|
6743
6706
|
if (i % barLabelStep !== 0) return null;
|
|
6744
|
-
return /* @__PURE__ */
|
|
6707
|
+
return /* @__PURE__ */ jsx307("text", { x: PADDING.left + groupW * i + groupW / 2, y: height - 8, className: "chart-axis-label", textAnchor: "middle", children: label }, i);
|
|
6745
6708
|
}),
|
|
6746
6709
|
entries.map(([key], di) => {
|
|
6747
6710
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
@@ -6750,7 +6713,7 @@ var BarChart = React7.memo(({ data, labels, width, height, animate, onHover, onM
|
|
|
6750
6713
|
const r2 = Math.min(4, b.w / 2);
|
|
6751
6714
|
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`;
|
|
6752
6715
|
const delay = 100 + i * 80;
|
|
6753
|
-
return /* @__PURE__ */
|
|
6716
|
+
return /* @__PURE__ */ jsx307(
|
|
6754
6717
|
"path",
|
|
6755
6718
|
{
|
|
6756
6719
|
d,
|
|
@@ -6760,8 +6723,7 @@ var BarChart = React7.memo(({ data, labels, width, height, animate, onHover, onM
|
|
|
6760
6723
|
transformOrigin: `${b.x + b.w / 2}px ${baseline}px`,
|
|
6761
6724
|
animationDelay: `${delay}ms`
|
|
6762
6725
|
} : void 0,
|
|
6763
|
-
onMouseEnter: (
|
|
6764
|
-
onMouseMove: onMove,
|
|
6726
|
+
onMouseEnter: () => onShowAt(b.x + b.w / 2, b.y, `${key}: ${labels[i]} \u2014 ${b.v}`),
|
|
6765
6727
|
onMouseLeave: onLeave
|
|
6766
6728
|
},
|
|
6767
6729
|
`${di}-${i}`
|
|
@@ -6771,11 +6733,11 @@ var BarChart = React7.memo(({ data, labels, width, height, animate, onHover, onM
|
|
|
6771
6733
|
] });
|
|
6772
6734
|
});
|
|
6773
6735
|
BarChart.displayName = "BarChart";
|
|
6774
|
-
var PieDonutChart =
|
|
6736
|
+
var PieDonutChart = React6.memo(
|
|
6775
6737
|
({ data, labels, width, height, animate, isDoughnut, onHover, onMove, onLeave }) => {
|
|
6776
|
-
const entries =
|
|
6777
|
-
const values =
|
|
6778
|
-
const total =
|
|
6738
|
+
const entries = React6.useMemo(() => Object.entries(data), [data]);
|
|
6739
|
+
const values = React6.useMemo(() => entries.flatMap(([, v]) => v), [entries]);
|
|
6740
|
+
const total = React6.useMemo(() => values.reduce((a, b) => a + b, 0) || 1, [values]);
|
|
6779
6741
|
const size = Math.min(width, height);
|
|
6780
6742
|
const cx = size / 2;
|
|
6781
6743
|
const cy = size / 2;
|
|
@@ -6783,10 +6745,10 @@ var PieDonutChart = React7.memo(
|
|
|
6783
6745
|
const innerR = isDoughnut ? r2 * 0.5 : 0;
|
|
6784
6746
|
const firstKey = entries[0]?.[0] ?? "";
|
|
6785
6747
|
const colorOffset = hashString(firstKey);
|
|
6786
|
-
const maskRef =
|
|
6748
|
+
const maskRef = React6.useRef(null);
|
|
6787
6749
|
const maskR = r2 + 10;
|
|
6788
6750
|
const maskCircumference = 2 * Math.PI * maskR;
|
|
6789
|
-
|
|
6751
|
+
React6.useEffect(() => {
|
|
6790
6752
|
if (!animate || !maskRef.current) return;
|
|
6791
6753
|
const el = maskRef.current;
|
|
6792
6754
|
el.style.strokeDasharray = `${maskCircumference}`;
|
|
@@ -6796,7 +6758,7 @@ var PieDonutChart = React7.memo(
|
|
|
6796
6758
|
el.style.strokeDashoffset = "0";
|
|
6797
6759
|
});
|
|
6798
6760
|
}, [animate, maskCircumference]);
|
|
6799
|
-
const sliceData =
|
|
6761
|
+
const sliceData = React6.useMemo(() => {
|
|
6800
6762
|
let angle0 = -Math.PI / 2;
|
|
6801
6763
|
let cumulativeAngle = 0;
|
|
6802
6764
|
return values.map((v, i) => {
|
|
@@ -6831,7 +6793,7 @@ var PieDonutChart = React7.memo(
|
|
|
6831
6793
|
}, [values, total, cx, cy, r2, innerR, labels]);
|
|
6832
6794
|
const maskId = `pie-mask-${isDoughnut ? "d" : "p"}`;
|
|
6833
6795
|
return /* @__PURE__ */ jsxs197("svg", { viewBox: `0 0 ${size} ${size}`, className: "chart-svg chart-pie", children: [
|
|
6834
|
-
animate && /* @__PURE__ */
|
|
6796
|
+
animate && /* @__PURE__ */ jsx307("defs", { children: /* @__PURE__ */ jsx307("mask", { id: maskId, children: /* @__PURE__ */ jsx307(
|
|
6835
6797
|
"circle",
|
|
6836
6798
|
{
|
|
6837
6799
|
ref: maskRef,
|
|
@@ -6844,56 +6806,39 @@ var PieDonutChart = React7.memo(
|
|
|
6844
6806
|
transform: `rotate(-90 ${cx} ${cy})`
|
|
6845
6807
|
}
|
|
6846
6808
|
) }) }),
|
|
6847
|
-
/* @__PURE__ */
|
|
6809
|
+
/* @__PURE__ */ jsx307("g", { mask: animate ? `url(#${maskId})` : void 0, children: sliceData.map((s, i) => /* @__PURE__ */ jsx307("g", { children: /* @__PURE__ */ jsx307(
|
|
6848
6810
|
"path",
|
|
6849
6811
|
{
|
|
6850
6812
|
d: s.d,
|
|
6851
6813
|
fill: PIE_COLORS[(i + colorOffset) % PIE_COLORS.length],
|
|
6852
|
-
className: "chart-slice"
|
|
6853
|
-
onMouseEnter: (e) => onHover(e, `${s.label}: ${s.v} (${s.pct}%)`),
|
|
6854
|
-
onMouseMove: onMove,
|
|
6855
|
-
onMouseLeave: onLeave
|
|
6814
|
+
className: "chart-slice"
|
|
6856
6815
|
}
|
|
6857
|
-
) }, i)) })
|
|
6858
|
-
sliceData.map((s, i) => s.angle > 0.2 && /* @__PURE__ */ jsx308(
|
|
6859
|
-
"text",
|
|
6860
|
-
{
|
|
6861
|
-
x: s.lx,
|
|
6862
|
-
y: s.ly,
|
|
6863
|
-
className: `chart-pie-label ${animate ? "chart-pie-label-animate" : ""}`,
|
|
6864
|
-
style: animate ? { animationDelay: `${s.labelDelay}ms` } : void 0,
|
|
6865
|
-
textAnchor: "middle",
|
|
6866
|
-
dominantBaseline: "central",
|
|
6867
|
-
children: s.v
|
|
6868
|
-
},
|
|
6869
|
-
`label-${i}`
|
|
6870
|
-
))
|
|
6816
|
+
) }, i)) })
|
|
6871
6817
|
] });
|
|
6872
6818
|
}
|
|
6873
6819
|
);
|
|
6874
6820
|
PieDonutChart.displayName = "PieDonutChart";
|
|
6875
|
-
var
|
|
6876
|
-
const ref =
|
|
6877
|
-
const [pos, setPos] =
|
|
6878
|
-
|
|
6821
|
+
var ChartTooltip = ({ x, y, containerWidth, containerHeight, children }) => {
|
|
6822
|
+
const ref = React6.useRef(null);
|
|
6823
|
+
const [pos, setPos] = React6.useState({ left: 0, top: 0 });
|
|
6824
|
+
React6.useLayoutEffect(() => {
|
|
6879
6825
|
const el = ref.current;
|
|
6880
6826
|
if (!el) return;
|
|
6881
6827
|
const w = el.offsetWidth;
|
|
6882
6828
|
const h = el.offsetHeight;
|
|
6883
|
-
|
|
6884
|
-
let
|
|
6885
|
-
|
|
6886
|
-
if (
|
|
6887
|
-
if (
|
|
6888
|
-
if (left < 8) left = 8;
|
|
6829
|
+
let left = x + TOOLTIP_OFFSET;
|
|
6830
|
+
let top = y - h - TOOLTIP_OFFSET;
|
|
6831
|
+
if (left + w > containerWidth) left = x - w - TOOLTIP_OFFSET;
|
|
6832
|
+
if (top < 0) top = y + TOOLTIP_OFFSET;
|
|
6833
|
+
if (left < 0) left = 0;
|
|
6889
6834
|
setPos({ left, top });
|
|
6890
|
-
}, [
|
|
6891
|
-
return /* @__PURE__ */
|
|
6835
|
+
}, [x, y, containerWidth, containerHeight]);
|
|
6836
|
+
return /* @__PURE__ */ jsx307(
|
|
6892
6837
|
"div",
|
|
6893
6838
|
{
|
|
6894
6839
|
ref,
|
|
6895
|
-
className:
|
|
6896
|
-
style: {
|
|
6840
|
+
className: "chart-tooltip chart-tooltip-show",
|
|
6841
|
+
style: { left: pos.left, top: pos.top },
|
|
6897
6842
|
children
|
|
6898
6843
|
}
|
|
6899
6844
|
);
|
|
@@ -6905,13 +6850,13 @@ var ChartLegend = ({ data, labels, type }) => {
|
|
|
6905
6850
|
const total = values.reduce((a, b) => a + b, 0) || 1;
|
|
6906
6851
|
const firstKey = entries[0]?.[0] ?? "";
|
|
6907
6852
|
const colorOffset = hashString(firstKey);
|
|
6908
|
-
return /* @__PURE__ */
|
|
6853
|
+
return /* @__PURE__ */ jsx307("div", { className: "chart-legend", children: values.map((v, i) => {
|
|
6909
6854
|
const pct = Math.round(v / total * 100);
|
|
6910
6855
|
const color = PIE_COLORS[(i + colorOffset) % PIE_COLORS.length];
|
|
6911
6856
|
return /* @__PURE__ */ jsxs197("div", { className: "chart-legend-item", children: [
|
|
6912
|
-
/* @__PURE__ */
|
|
6857
|
+
/* @__PURE__ */ jsx307("span", { className: "chart-legend-dot", style: { backgroundColor: color } }),
|
|
6913
6858
|
/* @__PURE__ */ jsxs197("div", { className: "chart-legend-text", children: [
|
|
6914
|
-
/* @__PURE__ */
|
|
6859
|
+
/* @__PURE__ */ jsx307("span", { className: "chart-legend-label", children: labels[i] || `${i + 1}` }),
|
|
6915
6860
|
/* @__PURE__ */ jsxs197("span", { className: "chart-legend-value", children: [
|
|
6916
6861
|
v.toLocaleString(),
|
|
6917
6862
|
"(",
|
|
@@ -6922,37 +6867,37 @@ var ChartLegend = ({ data, labels, type }) => {
|
|
|
6922
6867
|
] }, i);
|
|
6923
6868
|
}) });
|
|
6924
6869
|
}
|
|
6925
|
-
return /* @__PURE__ */
|
|
6870
|
+
return /* @__PURE__ */ jsx307("div", { className: "chart-legend", children: entries.map(([key], di) => {
|
|
6926
6871
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
6927
6872
|
const color = palette[2];
|
|
6928
6873
|
const values = entries[di][1];
|
|
6929
6874
|
const sum = values.reduce((a, b) => a + b, 0);
|
|
6930
6875
|
return /* @__PURE__ */ jsxs197("div", { className: "chart-legend-item", children: [
|
|
6931
|
-
/* @__PURE__ */
|
|
6876
|
+
/* @__PURE__ */ jsx307("span", { className: "chart-legend-dot", style: { backgroundColor: color } }),
|
|
6932
6877
|
/* @__PURE__ */ jsxs197("div", { className: "chart-legend-text", children: [
|
|
6933
|
-
/* @__PURE__ */
|
|
6934
|
-
/* @__PURE__ */
|
|
6878
|
+
/* @__PURE__ */ jsx307("span", { className: "chart-legend-label", children: key }),
|
|
6879
|
+
/* @__PURE__ */ jsx307("span", { className: "chart-legend-value", children: sum.toLocaleString() })
|
|
6935
6880
|
] })
|
|
6936
6881
|
] }, di);
|
|
6937
6882
|
}) });
|
|
6938
6883
|
};
|
|
6939
|
-
var Chart =
|
|
6884
|
+
var Chart = React6.memo((props) => {
|
|
6940
6885
|
const { type, data, labels, tooltip: showTooltip = true } = props;
|
|
6941
|
-
const { tooltip, show, hide, move, containerRef } = useChartTooltip(showTooltip);
|
|
6886
|
+
const { tooltip, show, showAt, hide, move, containerRef } = useChartTooltip(showTooltip);
|
|
6942
6887
|
const { width, height } = useChartSize(containerRef);
|
|
6943
|
-
const stableData =
|
|
6944
|
-
const stableLabels =
|
|
6945
|
-
const dataKey =
|
|
6888
|
+
const stableData = React6.useMemo(() => data, [JSON.stringify(data)]);
|
|
6889
|
+
const stableLabels = React6.useMemo(() => labels, [JSON.stringify(labels)]);
|
|
6890
|
+
const dataKey = React6.useMemo(() => JSON.stringify(labels), [labels]);
|
|
6946
6891
|
const animate = useChartAnimation(containerRef, dataKey);
|
|
6947
6892
|
const ready = width > 0 && height > 0;
|
|
6948
6893
|
return /* @__PURE__ */ jsxs197("div", { className: "lib-xplat-chart", ref: containerRef, children: [
|
|
6949
|
-
ready && type === "line" && /* @__PURE__ */
|
|
6950
|
-
ready && type === "curve" && /* @__PURE__ */
|
|
6951
|
-
ready && type === "bar" && /* @__PURE__ */
|
|
6952
|
-
ready && type === "pie" && /* @__PURE__ */
|
|
6953
|
-
ready && type === "doughnut" && /* @__PURE__ */
|
|
6954
|
-
ready && (type === "bar" || type === "pie" || type === "doughnut") && /* @__PURE__ */
|
|
6955
|
-
tooltip.content && /* @__PURE__ */
|
|
6894
|
+
ready && type === "line" && /* @__PURE__ */ jsx307(LineChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onShowAt: showAt, onMove: move, onLeave: hide }),
|
|
6895
|
+
ready && type === "curve" && /* @__PURE__ */ jsx307(CurveChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onShowAt: showAt, onMove: move, onLeave: hide }),
|
|
6896
|
+
ready && type === "bar" && /* @__PURE__ */ jsx307(BarChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onShowAt: showAt, onMove: move, onLeave: hide }),
|
|
6897
|
+
ready && type === "pie" && /* @__PURE__ */ jsx307(PieDonutChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onShowAt: showAt, onMove: move, onLeave: hide }),
|
|
6898
|
+
ready && type === "doughnut" && /* @__PURE__ */ jsx307(PieDonutChart, { data: stableData, labels: stableLabels, width, height, animate, isDoughnut: true, onHover: show, onShowAt: showAt, onMove: move, onLeave: hide }),
|
|
6899
|
+
ready && (type === "bar" || type === "pie" || type === "doughnut") && /* @__PURE__ */ jsx307(ChartLegend, { data: stableData, labels: stableLabels, type }),
|
|
6900
|
+
tooltip.visible && tooltip.content && /* @__PURE__ */ jsx307(ChartTooltip, { x: tooltip.x, y: tooltip.y, containerWidth: width, containerHeight: height, children: tooltip.content })
|
|
6956
6901
|
] });
|
|
6957
6902
|
});
|
|
6958
6903
|
Chart.displayName = "Chart";
|
|
@@ -6978,7 +6923,7 @@ import { primitive, semantic } from "@x-plat/tokens-core";
|
|
|
6978
6923
|
import { cssVar } from "@x-plat/tokens-core";
|
|
6979
6924
|
|
|
6980
6925
|
// src/components/CheckBox/CheckBox.tsx
|
|
6981
|
-
import { jsx as
|
|
6926
|
+
import { jsx as jsx308, jsxs as jsxs198 } from "react/jsx-runtime";
|
|
6982
6927
|
var CheckBox = (props) => {
|
|
6983
6928
|
const {
|
|
6984
6929
|
checked,
|
|
@@ -6997,7 +6942,7 @@ var CheckBox = (props) => {
|
|
|
6997
6942
|
const disabledClasses = "disabled";
|
|
6998
6943
|
const boxClasses = disabled ? disabledClasses : checked ? checkedClasses : uncheckedClasses;
|
|
6999
6944
|
return /* @__PURE__ */ jsxs198("label", { className: clsx_default("lib-xplat-checkbox", size, type), children: [
|
|
7000
|
-
/* @__PURE__ */
|
|
6945
|
+
/* @__PURE__ */ jsx308(
|
|
7001
6946
|
"input",
|
|
7002
6947
|
{
|
|
7003
6948
|
type: "checkbox",
|
|
@@ -7007,22 +6952,22 @@ var CheckBox = (props) => {
|
|
|
7007
6952
|
...rest
|
|
7008
6953
|
}
|
|
7009
6954
|
),
|
|
7010
|
-
/* @__PURE__ */
|
|
7011
|
-
label && /* @__PURE__ */
|
|
6955
|
+
/* @__PURE__ */ jsx308("span", { className: clsx_default("checkbox", boxClasses), children: /* @__PURE__ */ jsx308("span", { className: clsx_default("check-icon", { visible: checked }), children: /* @__PURE__ */ jsx308(CheckIcon_default, {}) }) }),
|
|
6956
|
+
label && /* @__PURE__ */ jsx308("span", { className: "label", children: label })
|
|
7012
6957
|
] });
|
|
7013
6958
|
};
|
|
7014
6959
|
CheckBox.displayName = "CheckBox";
|
|
7015
6960
|
var CheckBox_default = CheckBox;
|
|
7016
6961
|
|
|
7017
6962
|
// src/components/Chip/Chip.tsx
|
|
7018
|
-
import { jsx as
|
|
6963
|
+
import { jsx as jsx309 } from "react/jsx-runtime";
|
|
7019
6964
|
var Chip = (props) => {
|
|
7020
6965
|
const {
|
|
7021
6966
|
children,
|
|
7022
6967
|
type = "primary",
|
|
7023
6968
|
size = "md"
|
|
7024
6969
|
} = props;
|
|
7025
|
-
return /* @__PURE__ */
|
|
6970
|
+
return /* @__PURE__ */ jsx309("div", { className: clsx_default("lib-xplat-chip", type, size), children });
|
|
7026
6971
|
};
|
|
7027
6972
|
Chip.displayName = "Chip";
|
|
7028
6973
|
var Chip_default = Chip;
|
|
@@ -7031,20 +6976,20 @@ var Chip_default = Chip;
|
|
|
7031
6976
|
import React12 from "react";
|
|
7032
6977
|
|
|
7033
6978
|
// src/components/Input/Input.tsx
|
|
7034
|
-
import
|
|
6979
|
+
import React7 from "react";
|
|
7035
6980
|
|
|
7036
6981
|
// src/components/Input/InputValidations.tsx
|
|
7037
|
-
import { jsx as
|
|
6982
|
+
import { jsx as jsx310, jsxs as jsxs199 } from "react/jsx-runtime";
|
|
7038
6983
|
var InputValidations = (props) => {
|
|
7039
6984
|
const { message, status = "default" } = props;
|
|
7040
6985
|
return /* @__PURE__ */ jsxs199("div", { className: clsx_default("lib-xplat-input-validation", status), children: [
|
|
7041
6986
|
/* @__PURE__ */ jsxs199("div", { className: "icon", children: [
|
|
7042
|
-
status === "default" && /* @__PURE__ */
|
|
7043
|
-
status === "success" && /* @__PURE__ */
|
|
7044
|
-
status === "warning" && /* @__PURE__ */
|
|
7045
|
-
status === "error" && /* @__PURE__ */
|
|
6987
|
+
status === "default" && /* @__PURE__ */ jsx310(InfoIcon_default, {}),
|
|
6988
|
+
status === "success" && /* @__PURE__ */ jsx310(SuccessIcon_default, {}),
|
|
6989
|
+
status === "warning" && /* @__PURE__ */ jsx310(InfoIcon_default, {}),
|
|
6990
|
+
status === "error" && /* @__PURE__ */ jsx310(ErrorIcon_default, {})
|
|
7046
6991
|
] }),
|
|
7047
|
-
/* @__PURE__ */
|
|
6992
|
+
/* @__PURE__ */ jsx310("div", { className: "message", children: message })
|
|
7048
6993
|
] });
|
|
7049
6994
|
};
|
|
7050
6995
|
InputValidations.displayName = "InputValidations";
|
|
@@ -7085,7 +7030,7 @@ var handleTelBackspace = (prevValue, currValue) => {
|
|
|
7085
7030
|
};
|
|
7086
7031
|
|
|
7087
7032
|
// src/components/Input/Input.tsx
|
|
7088
|
-
import { jsx as
|
|
7033
|
+
import { jsx as jsx311, jsxs as jsxs200 } from "react/jsx-runtime";
|
|
7089
7034
|
import { createElement } from "react";
|
|
7090
7035
|
var formatValue = (type, value) => {
|
|
7091
7036
|
if (value === null || value === void 0) return "";
|
|
@@ -7134,7 +7079,7 @@ var parseValue = (type, value) => {
|
|
|
7134
7079
|
return value;
|
|
7135
7080
|
}
|
|
7136
7081
|
};
|
|
7137
|
-
var Input =
|
|
7082
|
+
var Input = React7.forwardRef((props, ref) => {
|
|
7138
7083
|
const {
|
|
7139
7084
|
value,
|
|
7140
7085
|
onChange,
|
|
@@ -7166,7 +7111,7 @@ var Input = React8.forwardRef((props, ref) => {
|
|
|
7166
7111
|
{
|
|
7167
7112
|
className: clsx_default("lib-xplat-input", size, disabled ? "disabled" : void 0),
|
|
7168
7113
|
children: [
|
|
7169
|
-
/* @__PURE__ */
|
|
7114
|
+
/* @__PURE__ */ jsx311(
|
|
7170
7115
|
"input",
|
|
7171
7116
|
{
|
|
7172
7117
|
...inputProps,
|
|
@@ -7177,11 +7122,11 @@ var Input = React8.forwardRef((props, ref) => {
|
|
|
7177
7122
|
onChange: handleChange
|
|
7178
7123
|
}
|
|
7179
7124
|
),
|
|
7180
|
-
suffix && /* @__PURE__ */
|
|
7125
|
+
suffix && /* @__PURE__ */ jsx311("div", { className: "suffix", children: suffix })
|
|
7181
7126
|
]
|
|
7182
7127
|
}
|
|
7183
7128
|
),
|
|
7184
|
-
validations && /* @__PURE__ */
|
|
7129
|
+
validations && /* @__PURE__ */ jsx311("div", { className: "lib-xplat-input-validation-wrap", children: validations?.map((validation, idx) => /* @__PURE__ */ createElement(
|
|
7185
7130
|
InputValidations_default,
|
|
7186
7131
|
{
|
|
7187
7132
|
...validation,
|
|
@@ -7194,20 +7139,20 @@ Input.displayName = "Input";
|
|
|
7194
7139
|
var Input_default = Input;
|
|
7195
7140
|
|
|
7196
7141
|
// src/components/Input/PasswordInput/PasswordInput.tsx
|
|
7197
|
-
import
|
|
7198
|
-
import { jsx as
|
|
7199
|
-
var PasswordInput =
|
|
7142
|
+
import React8 from "react";
|
|
7143
|
+
import { jsx as jsx312 } from "react/jsx-runtime";
|
|
7144
|
+
var PasswordInput = React8.forwardRef(
|
|
7200
7145
|
(props, ref) => {
|
|
7201
7146
|
const { reg: _reg, ...inputProps } = props;
|
|
7202
|
-
const [isView, setIsView] =
|
|
7147
|
+
const [isView, setIsView] = React8.useState(false);
|
|
7203
7148
|
const handleChangeView = () => {
|
|
7204
7149
|
setIsView((prev) => !prev);
|
|
7205
7150
|
};
|
|
7206
|
-
return /* @__PURE__ */
|
|
7151
|
+
return /* @__PURE__ */ jsx312(
|
|
7207
7152
|
Input_default,
|
|
7208
7153
|
{
|
|
7209
7154
|
...inputProps,
|
|
7210
|
-
suffix: /* @__PURE__ */
|
|
7155
|
+
suffix: /* @__PURE__ */ jsx312("div", { className: "wrapper pointer", onClick: handleChangeView, children: isView ? /* @__PURE__ */ jsx312(OpenEyeIcon_default, {}) : /* @__PURE__ */ jsx312(CloseEyeIcon_default, {}) }),
|
|
7211
7156
|
type: isView ? "text" : "password",
|
|
7212
7157
|
ref
|
|
7213
7158
|
}
|
|
@@ -7220,6 +7165,23 @@ var PasswordInput_default = PasswordInput;
|
|
|
7220
7165
|
// src/components/Modal/Modal.tsx
|
|
7221
7166
|
import React10 from "react";
|
|
7222
7167
|
import { createPortal } from "react-dom";
|
|
7168
|
+
|
|
7169
|
+
// src/tokens/hooks/Portal.tsx
|
|
7170
|
+
import React9 from "react";
|
|
7171
|
+
import ReactDOM from "react-dom";
|
|
7172
|
+
import { jsx as jsx313 } from "react/jsx-runtime";
|
|
7173
|
+
var PortalContainerContext = React9.createContext(null);
|
|
7174
|
+
var PortalProvider = ({ container, children }) => /* @__PURE__ */ jsx313(PortalContainerContext.Provider, { value: container, children });
|
|
7175
|
+
var Portal = ({ children }) => {
|
|
7176
|
+
const contextContainer = React9.useContext(PortalContainerContext);
|
|
7177
|
+
if (typeof document === "undefined") return null;
|
|
7178
|
+
const container = contextContainer ?? document.body;
|
|
7179
|
+
return ReactDOM.createPortal(children, container);
|
|
7180
|
+
};
|
|
7181
|
+
Portal.displayName = "Portal";
|
|
7182
|
+
var Portal_default = Portal;
|
|
7183
|
+
|
|
7184
|
+
// src/components/Modal/Modal.tsx
|
|
7223
7185
|
import { jsx as jsx314 } from "react/jsx-runtime";
|
|
7224
7186
|
var ANIMATION_DURATION_MS = 200;
|
|
7225
7187
|
var Modal = (props) => {
|