@x-plat/design-system 0.5.35 → 0.5.37
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 +164 -200
- package/dist/components/Chart/index.css +12 -25
- package/dist/components/Chart/index.js +151 -187
- package/dist/components/index.cjs +211 -231
- package/dist/components/index.css +12 -25
- package/dist/components/index.js +192 -212
- package/dist/index.cjs +211 -231
- package/dist/index.css +12 -25
- package/dist/index.js +192 -212
- 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,60 @@ 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 });
|
|
6382
|
+
}, [enabled]);
|
|
6383
|
+
const showAt = React6.useCallback((svgX, svgY, content, svgEl) => {
|
|
6384
|
+
if (!enabled) return;
|
|
6385
|
+
const container = containerRef.current;
|
|
6386
|
+
if (!container) return;
|
|
6387
|
+
let x = svgX;
|
|
6388
|
+
let y = svgY;
|
|
6389
|
+
if (svgEl) {
|
|
6390
|
+
const svgRect = svgEl.getBoundingClientRect();
|
|
6391
|
+
const containerRect = container.getBoundingClientRect();
|
|
6392
|
+
const vb = svgEl.viewBox.baseVal;
|
|
6393
|
+
const scaleX = svgRect.width / (vb.width || 1);
|
|
6394
|
+
const scaleY = svgRect.height / (vb.height || 1);
|
|
6395
|
+
x = svgX * scaleX + (svgRect.left - containerRect.left);
|
|
6396
|
+
y = svgY * scaleY + (svgRect.top - containerRect.top);
|
|
6397
|
+
}
|
|
6398
|
+
setTooltip({ visible: true, x, y, content });
|
|
6395
6399
|
}, [enabled]);
|
|
6396
|
-
const hide =
|
|
6400
|
+
const hide = React6.useCallback(() => {
|
|
6397
6401
|
cancelAnimationFrame(rafRef.current);
|
|
6398
6402
|
setTooltip((prev) => ({ ...prev, visible: false }));
|
|
6399
6403
|
}, []);
|
|
6400
|
-
return { tooltip, show, hide, move, containerRef };
|
|
6404
|
+
return { tooltip, show, showAt, hide, move, containerRef };
|
|
6401
6405
|
};
|
|
6402
|
-
var GridLines =
|
|
6406
|
+
var GridLines = React6.memo(({ width, height, chartH, maxVal }) => /* @__PURE__ */ jsx307(Fragment2, { children: [0, 0.25, 0.5, 0.75, 1].map((ratio) => {
|
|
6403
6407
|
const y = PADDING.top + (1 - ratio) * chartH;
|
|
6404
6408
|
const val = Math.round(maxVal * ratio);
|
|
6405
6409
|
return /* @__PURE__ */ jsxs197("g", { children: [
|
|
6406
|
-
/* @__PURE__ */
|
|
6407
|
-
/* @__PURE__ */
|
|
6410
|
+
/* @__PURE__ */ jsx307("line", { x1: PADDING.left, y1: y, x2: width - PADDING.right, y2: y, className: "chart-grid" }),
|
|
6411
|
+
/* @__PURE__ */ jsx307("text", { x: PADDING.left - 8, y: y + 4, className: "chart-axis-label", textAnchor: "end", children: val })
|
|
6408
6412
|
] }, ratio);
|
|
6409
6413
|
}) }));
|
|
6410
6414
|
GridLines.displayName = "GridLines";
|
|
@@ -6414,18 +6418,18 @@ var getLabelStep = (count, chartW) => {
|
|
|
6414
6418
|
if (count <= maxLabels) return 1;
|
|
6415
6419
|
return Math.ceil(count / maxLabels);
|
|
6416
6420
|
};
|
|
6417
|
-
var AxisLabels =
|
|
6421
|
+
var AxisLabels = React6.memo(({ labels, count, chartW, height }) => {
|
|
6418
6422
|
const step = getLabelStep(count, chartW);
|
|
6419
|
-
return /* @__PURE__ */
|
|
6423
|
+
return /* @__PURE__ */ jsx307(Fragment2, { children: labels.map((label, i) => {
|
|
6420
6424
|
if (i % step !== 0) return null;
|
|
6421
6425
|
const x = PADDING.left + i / (count - 1 || 1) * chartW;
|
|
6422
|
-
return /* @__PURE__ */
|
|
6426
|
+
return /* @__PURE__ */ jsx307("text", { x, y: height - 8, className: "chart-axis-label", textAnchor: "middle", children: label }, i);
|
|
6423
6427
|
}) });
|
|
6424
6428
|
});
|
|
6425
6429
|
AxisLabels.displayName = "AxisLabels";
|
|
6426
6430
|
var useCrosshair = (seriesPoints, entries, labels, chartH) => {
|
|
6427
|
-
const [activeIndex, setActiveIndex] =
|
|
6428
|
-
const handleMouseMove =
|
|
6431
|
+
const [activeIndex, setActiveIndex] = React6.useState(null);
|
|
6432
|
+
const handleMouseMove = React6.useCallback((e) => {
|
|
6429
6433
|
const svg = e.currentTarget;
|
|
6430
6434
|
const rect = svg.getBoundingClientRect();
|
|
6431
6435
|
const mx = (e.clientX - rect.left) / rect.width * svg.viewBox.baseVal.width;
|
|
@@ -6444,17 +6448,17 @@ var useCrosshair = (seriesPoints, entries, labels, chartH) => {
|
|
|
6444
6448
|
}
|
|
6445
6449
|
setActiveIndex(minDist <= threshold ? closest : null);
|
|
6446
6450
|
}, [seriesPoints]);
|
|
6447
|
-
const handleMouseLeave =
|
|
6451
|
+
const handleMouseLeave = React6.useCallback(() => {
|
|
6448
6452
|
setActiveIndex(null);
|
|
6449
6453
|
}, []);
|
|
6450
|
-
const tooltipContent =
|
|
6454
|
+
const tooltipContent = React6.useMemo(() => {
|
|
6451
6455
|
if (activeIndex === null) return "";
|
|
6452
6456
|
return entries.map(([key], di) => {
|
|
6453
6457
|
const p = seriesPoints[di]?.[activeIndex];
|
|
6454
6458
|
return p ? `${key}: ${p.v}` : "";
|
|
6455
6459
|
}).filter(Boolean).join(" / ");
|
|
6456
6460
|
}, [activeIndex, entries, seriesPoints]);
|
|
6457
|
-
const getTooltipAt =
|
|
6461
|
+
const getTooltipAt = React6.useCallback((idx) => {
|
|
6458
6462
|
return entries.map(([key], di) => {
|
|
6459
6463
|
const p = seriesPoints[di]?.[idx];
|
|
6460
6464
|
return p ? `${key}: ${p.v}` : "";
|
|
@@ -6462,16 +6466,16 @@ var useCrosshair = (seriesPoints, entries, labels, chartH) => {
|
|
|
6462
6466
|
}, [entries, seriesPoints]);
|
|
6463
6467
|
return { activeIndex, handleMouseMove, handleMouseLeave, tooltipContent, getTooltipAt };
|
|
6464
6468
|
};
|
|
6465
|
-
var LineChart =
|
|
6466
|
-
const entries =
|
|
6467
|
-
const maxVal =
|
|
6469
|
+
var LineChart = React6.memo(({ data, labels, width, height, animate, onHover, onShowAt, onMove, onLeave }) => {
|
|
6470
|
+
const entries = React6.useMemo(() => Object.entries(data), [data]);
|
|
6471
|
+
const maxVal = React6.useMemo(() => {
|
|
6468
6472
|
const allValues = entries.flatMap(([, v]) => v);
|
|
6469
6473
|
return Math.max(...allValues) * 1.2 || 1;
|
|
6470
6474
|
}, [entries]);
|
|
6471
6475
|
const count = labels.length;
|
|
6472
6476
|
const chartW = width - PADDING.left - PADDING.right;
|
|
6473
6477
|
const chartH = height - PADDING.top - PADDING.bottom;
|
|
6474
|
-
const seriesPoints =
|
|
6478
|
+
const seriesPoints = React6.useMemo(
|
|
6475
6479
|
() => entries.map(
|
|
6476
6480
|
([, values]) => values.map((v, i) => ({
|
|
6477
6481
|
x: PADDING.left + i / (count - 1 || 1) * chartW,
|
|
@@ -6481,9 +6485,10 @@ var LineChart = React7.memo(({ data, labels, width, height, animate, onHover, on
|
|
|
6481
6485
|
),
|
|
6482
6486
|
[entries, count, chartW, chartH, maxVal]
|
|
6483
6487
|
);
|
|
6484
|
-
const clipRef =
|
|
6488
|
+
const clipRef = React6.useRef(null);
|
|
6489
|
+
const svgRef = React6.useRef(null);
|
|
6485
6490
|
const { activeIndex, handleMouseMove, handleMouseLeave, getTooltipAt } = useCrosshair(seriesPoints, entries, labels, chartH);
|
|
6486
|
-
|
|
6491
|
+
React6.useEffect(() => {
|
|
6487
6492
|
if (!animate || !clipRef.current) return;
|
|
6488
6493
|
clipRef.current.setAttribute("width", "0");
|
|
6489
6494
|
requestAnimationFrame(() => {
|
|
@@ -6498,27 +6503,14 @@ var LineChart = React7.memo(({ data, labels, width, height, animate, onHover, on
|
|
|
6498
6503
|
return /* @__PURE__ */ jsxs197(
|
|
6499
6504
|
"svg",
|
|
6500
6505
|
{
|
|
6506
|
+
ref: svgRef,
|
|
6501
6507
|
viewBox: `0 0 ${width} ${height}`,
|
|
6502
6508
|
className: "chart-svg",
|
|
6503
6509
|
onMouseMove: (e) => {
|
|
6504
6510
|
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)}`);
|
|
6511
|
+
if (activeIndex !== null && seriesPoints[0]?.[activeIndex]) {
|
|
6512
|
+
const p = seriesPoints[0][activeIndex];
|
|
6513
|
+
onShowAt(p.x, p.y, `${labels[activeIndex]} \u2014 ${getTooltipAt(activeIndex)}`, svgRef.current);
|
|
6522
6514
|
} else {
|
|
6523
6515
|
onLeave();
|
|
6524
6516
|
}
|
|
@@ -6528,9 +6520,9 @@ var LineChart = React7.memo(({ data, labels, width, height, animate, onHover, on
|
|
|
6528
6520
|
onLeave();
|
|
6529
6521
|
},
|
|
6530
6522
|
children: [
|
|
6531
|
-
animate && /* @__PURE__ */
|
|
6532
|
-
/* @__PURE__ */
|
|
6533
|
-
/* @__PURE__ */
|
|
6523
|
+
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 }) }) }),
|
|
6524
|
+
/* @__PURE__ */ jsx307(GridLines, { width, height, chartH, maxVal }),
|
|
6525
|
+
/* @__PURE__ */ jsx307(AxisLabels, { labels, count, chartW, height }),
|
|
6534
6526
|
entries.map(([key], di) => {
|
|
6535
6527
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
6536
6528
|
const color = palette[2];
|
|
@@ -6540,15 +6532,15 @@ var LineChart = React7.memo(({ data, labels, width, height, animate, onHover, on
|
|
|
6540
6532
|
const polyPoints = points.map((p) => `${p.x},${p.y}`).join(" ");
|
|
6541
6533
|
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
6534
|
return /* @__PURE__ */ jsxs197("g", { children: [
|
|
6543
|
-
/* @__PURE__ */
|
|
6544
|
-
/* @__PURE__ */
|
|
6545
|
-
/* @__PURE__ */
|
|
6535
|
+
/* @__PURE__ */ jsx307("defs", { children: /* @__PURE__ */ jsxs197("linearGradient", { id: gradientId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
6536
|
+
/* @__PURE__ */ jsx307("stop", { offset: "0%", stopColor: areaColor, stopOpacity: "0.2" }),
|
|
6537
|
+
/* @__PURE__ */ jsx307("stop", { offset: "100%", stopColor: areaColor, stopOpacity: "0" })
|
|
6546
6538
|
] }) }),
|
|
6547
6539
|
/* @__PURE__ */ jsxs197("g", { clipPath: animate ? `url(#${lineClipId})` : void 0, children: [
|
|
6548
|
-
/* @__PURE__ */
|
|
6549
|
-
/* @__PURE__ */
|
|
6540
|
+
/* @__PURE__ */ jsx307("path", { d: areaD, fill: `url(#${gradientId})` }),
|
|
6541
|
+
/* @__PURE__ */ jsx307("polyline", { points: polyPoints, fill: "none", stroke: color, strokeWidth: "2" })
|
|
6550
6542
|
] }),
|
|
6551
|
-
activeIndex !== null && points[activeIndex] && /* @__PURE__ */
|
|
6543
|
+
activeIndex !== null && points[activeIndex] && /* @__PURE__ */ jsx307(
|
|
6552
6544
|
"circle",
|
|
6553
6545
|
{
|
|
6554
6546
|
cx: points[activeIndex].x,
|
|
@@ -6560,7 +6552,7 @@ var LineChart = React7.memo(({ data, labels, width, height, animate, onHover, on
|
|
|
6560
6552
|
)
|
|
6561
6553
|
] }, di);
|
|
6562
6554
|
}),
|
|
6563
|
-
activeX !== null && /* @__PURE__ */
|
|
6555
|
+
activeX !== null && /* @__PURE__ */ jsx307(
|
|
6564
6556
|
"line",
|
|
6565
6557
|
{
|
|
6566
6558
|
x1: activeX,
|
|
@@ -6570,7 +6562,7 @@ var LineChart = React7.memo(({ data, labels, width, height, animate, onHover, on
|
|
|
6570
6562
|
className: "chart-crosshair"
|
|
6571
6563
|
}
|
|
6572
6564
|
),
|
|
6573
|
-
/* @__PURE__ */
|
|
6565
|
+
/* @__PURE__ */ jsx307(
|
|
6574
6566
|
"rect",
|
|
6575
6567
|
{
|
|
6576
6568
|
x: PADDING.left,
|
|
@@ -6586,16 +6578,16 @@ var LineChart = React7.memo(({ data, labels, width, height, animate, onHover, on
|
|
|
6586
6578
|
);
|
|
6587
6579
|
});
|
|
6588
6580
|
LineChart.displayName = "LineChart";
|
|
6589
|
-
var CurveChart =
|
|
6590
|
-
const entries =
|
|
6591
|
-
const maxVal =
|
|
6581
|
+
var CurveChart = React6.memo(({ data, labels, width, height, animate, onHover, onShowAt, onMove, onLeave }) => {
|
|
6582
|
+
const entries = React6.useMemo(() => Object.entries(data), [data]);
|
|
6583
|
+
const maxVal = React6.useMemo(() => {
|
|
6592
6584
|
const allValues = entries.flatMap(([, v]) => v);
|
|
6593
6585
|
return Math.max(...allValues) * 1.2 || 1;
|
|
6594
6586
|
}, [entries]);
|
|
6595
6587
|
const count = labels.length;
|
|
6596
6588
|
const chartW = width - PADDING.left - PADDING.right;
|
|
6597
6589
|
const chartH = height - PADDING.top - PADDING.bottom;
|
|
6598
|
-
const seriesPoints =
|
|
6590
|
+
const seriesPoints = React6.useMemo(
|
|
6599
6591
|
() => entries.map(
|
|
6600
6592
|
([, values]) => values.map((v, i) => ({
|
|
6601
6593
|
x: PADDING.left + i / (count - 1 || 1) * chartW,
|
|
@@ -6605,9 +6597,10 @@ var CurveChart = React7.memo(({ data, labels, width, height, animate, onHover, o
|
|
|
6605
6597
|
),
|
|
6606
6598
|
[entries, count, chartW, chartH, maxVal]
|
|
6607
6599
|
);
|
|
6608
|
-
const curveClipRef =
|
|
6600
|
+
const curveClipRef = React6.useRef(null);
|
|
6601
|
+
const curveSvgRef = React6.useRef(null);
|
|
6609
6602
|
const { activeIndex, handleMouseMove, handleMouseLeave, getTooltipAt } = useCrosshair(seriesPoints, entries, labels, chartH);
|
|
6610
|
-
|
|
6603
|
+
React6.useEffect(() => {
|
|
6611
6604
|
if (!animate || !curveClipRef.current) return;
|
|
6612
6605
|
curveClipRef.current.setAttribute("width", "0");
|
|
6613
6606
|
requestAnimationFrame(() => {
|
|
@@ -6622,27 +6615,14 @@ var CurveChart = React7.memo(({ data, labels, width, height, animate, onHover, o
|
|
|
6622
6615
|
return /* @__PURE__ */ jsxs197(
|
|
6623
6616
|
"svg",
|
|
6624
6617
|
{
|
|
6618
|
+
ref: curveSvgRef,
|
|
6625
6619
|
viewBox: `0 0 ${width} ${height}`,
|
|
6626
6620
|
className: "chart-svg",
|
|
6627
6621
|
onMouseMove: (e) => {
|
|
6628
6622
|
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)}`);
|
|
6623
|
+
if (activeIndex !== null && seriesPoints[0]?.[activeIndex]) {
|
|
6624
|
+
const p = seriesPoints[0][activeIndex];
|
|
6625
|
+
onShowAt(p.x, p.y, `${labels[activeIndex]} \u2014 ${getTooltipAt(activeIndex)}`, curveSvgRef.current);
|
|
6646
6626
|
} else {
|
|
6647
6627
|
onLeave();
|
|
6648
6628
|
}
|
|
@@ -6652,9 +6632,9 @@ var CurveChart = React7.memo(({ data, labels, width, height, animate, onHover, o
|
|
|
6652
6632
|
onLeave();
|
|
6653
6633
|
},
|
|
6654
6634
|
children: [
|
|
6655
|
-
animate && /* @__PURE__ */
|
|
6656
|
-
/* @__PURE__ */
|
|
6657
|
-
/* @__PURE__ */
|
|
6635
|
+
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 }) }) }),
|
|
6636
|
+
/* @__PURE__ */ jsx307(GridLines, { width, height, chartH, maxVal }),
|
|
6637
|
+
/* @__PURE__ */ jsx307(AxisLabels, { labels, count, chartW, height }),
|
|
6658
6638
|
entries.map(([key], di) => {
|
|
6659
6639
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
6660
6640
|
const color = palette[2];
|
|
@@ -6664,15 +6644,15 @@ var CurveChart = React7.memo(({ data, labels, width, height, animate, onHover, o
|
|
|
6664
6644
|
const linePath = toSmoothPath(points);
|
|
6665
6645
|
const areaPath = linePath + ` L ${points[points.length - 1].x} ${PADDING.top + chartH} L ${points[0].x} ${PADDING.top + chartH} Z`;
|
|
6666
6646
|
return /* @__PURE__ */ jsxs197("g", { children: [
|
|
6667
|
-
/* @__PURE__ */
|
|
6668
|
-
/* @__PURE__ */
|
|
6669
|
-
/* @__PURE__ */
|
|
6647
|
+
/* @__PURE__ */ jsx307("defs", { children: /* @__PURE__ */ jsxs197("linearGradient", { id: gradientId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
6648
|
+
/* @__PURE__ */ jsx307("stop", { offset: "0%", stopColor: areaColor, stopOpacity: "0.4" }),
|
|
6649
|
+
/* @__PURE__ */ jsx307("stop", { offset: "100%", stopColor: areaColor, stopOpacity: "0.02" })
|
|
6670
6650
|
] }) }),
|
|
6671
6651
|
/* @__PURE__ */ jsxs197("g", { clipPath: animate ? `url(#${curveClipId})` : void 0, children: [
|
|
6672
|
-
/* @__PURE__ */
|
|
6673
|
-
/* @__PURE__ */
|
|
6652
|
+
/* @__PURE__ */ jsx307("path", { d: areaPath, fill: `url(#${gradientId})` }),
|
|
6653
|
+
/* @__PURE__ */ jsx307("path", { d: linePath, fill: "none", stroke: color, strokeWidth: "2" })
|
|
6674
6654
|
] }),
|
|
6675
|
-
activeIndex !== null && points[activeIndex] && /* @__PURE__ */
|
|
6655
|
+
activeIndex !== null && points[activeIndex] && /* @__PURE__ */ jsx307(
|
|
6676
6656
|
"circle",
|
|
6677
6657
|
{
|
|
6678
6658
|
cx: points[activeIndex].x,
|
|
@@ -6684,7 +6664,7 @@ var CurveChart = React7.memo(({ data, labels, width, height, animate, onHover, o
|
|
|
6684
6664
|
)
|
|
6685
6665
|
] }, di);
|
|
6686
6666
|
}),
|
|
6687
|
-
activeX !== null && /* @__PURE__ */
|
|
6667
|
+
activeX !== null && /* @__PURE__ */ jsx307(
|
|
6688
6668
|
"line",
|
|
6689
6669
|
{
|
|
6690
6670
|
x1: activeX,
|
|
@@ -6694,7 +6674,7 @@ var CurveChart = React7.memo(({ data, labels, width, height, animate, onHover, o
|
|
|
6694
6674
|
className: "chart-crosshair"
|
|
6695
6675
|
}
|
|
6696
6676
|
),
|
|
6697
|
-
/* @__PURE__ */
|
|
6677
|
+
/* @__PURE__ */ jsx307(
|
|
6698
6678
|
"rect",
|
|
6699
6679
|
{
|
|
6700
6680
|
x: PADDING.left,
|
|
@@ -6710,9 +6690,10 @@ var CurveChart = React7.memo(({ data, labels, width, height, animate, onHover, o
|
|
|
6710
6690
|
);
|
|
6711
6691
|
});
|
|
6712
6692
|
CurveChart.displayName = "CurveChart";
|
|
6713
|
-
var BarChart =
|
|
6714
|
-
const
|
|
6715
|
-
const
|
|
6693
|
+
var BarChart = React6.memo(({ data, labels, width, height, animate, onHover, onShowAt, onMove, onLeave }) => {
|
|
6694
|
+
const barSvgRef = React6.useRef(null);
|
|
6695
|
+
const entries = React6.useMemo(() => Object.entries(data), [data]);
|
|
6696
|
+
const maxVal = React6.useMemo(() => {
|
|
6716
6697
|
const allValues = entries.flatMap(([, v]) => v);
|
|
6717
6698
|
return Math.max(...allValues) * 1.2 || 1;
|
|
6718
6699
|
}, [entries]);
|
|
@@ -6724,7 +6705,7 @@ var BarChart = React7.memo(({ data, labels, width, height, animate, onHover, onM
|
|
|
6724
6705
|
const barGap = groupCount > 1 ? 2 : 0;
|
|
6725
6706
|
const barW = Math.max(1, Math.min(32, (groupW * 0.7 - barGap * (groupCount - 1)) / groupCount));
|
|
6726
6707
|
const baseline = PADDING.top + chartH;
|
|
6727
|
-
const bars =
|
|
6708
|
+
const bars = React6.useMemo(
|
|
6728
6709
|
() => entries.map(
|
|
6729
6710
|
([, values], di) => values.map((v, i) => {
|
|
6730
6711
|
const totalBarsW = barW * groupCount + barGap * (groupCount - 1);
|
|
@@ -6737,11 +6718,11 @@ var BarChart = React7.memo(({ data, labels, width, height, animate, onHover, onM
|
|
|
6737
6718
|
[entries, maxVal, chartH, groupW, barW, barGap, groupCount]
|
|
6738
6719
|
);
|
|
6739
6720
|
const barLabelStep = getLabelStep(count, chartW);
|
|
6740
|
-
return /* @__PURE__ */ jsxs197("svg", { viewBox: `0 0 ${width} ${height}`, className: "chart-svg", children: [
|
|
6741
|
-
/* @__PURE__ */
|
|
6721
|
+
return /* @__PURE__ */ jsxs197("svg", { ref: barSvgRef, viewBox: `0 0 ${width} ${height}`, className: "chart-svg", children: [
|
|
6722
|
+
/* @__PURE__ */ jsx307(GridLines, { width, height, chartH, maxVal }),
|
|
6742
6723
|
labels.map((label, i) => {
|
|
6743
6724
|
if (i % barLabelStep !== 0) return null;
|
|
6744
|
-
return /* @__PURE__ */
|
|
6725
|
+
return /* @__PURE__ */ jsx307("text", { x: PADDING.left + groupW * i + groupW / 2, y: height - 8, className: "chart-axis-label", textAnchor: "middle", children: label }, i);
|
|
6745
6726
|
}),
|
|
6746
6727
|
entries.map(([key], di) => {
|
|
6747
6728
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
@@ -6750,7 +6731,7 @@ var BarChart = React7.memo(({ data, labels, width, height, animate, onHover, onM
|
|
|
6750
6731
|
const r2 = Math.min(4, b.w / 2);
|
|
6751
6732
|
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
6733
|
const delay = 100 + i * 80;
|
|
6753
|
-
return /* @__PURE__ */
|
|
6734
|
+
return /* @__PURE__ */ jsx307(
|
|
6754
6735
|
"path",
|
|
6755
6736
|
{
|
|
6756
6737
|
d,
|
|
@@ -6760,8 +6741,7 @@ var BarChart = React7.memo(({ data, labels, width, height, animate, onHover, onM
|
|
|
6760
6741
|
transformOrigin: `${b.x + b.w / 2}px ${baseline}px`,
|
|
6761
6742
|
animationDelay: `${delay}ms`
|
|
6762
6743
|
} : void 0,
|
|
6763
|
-
onMouseEnter: (
|
|
6764
|
-
onMouseMove: onMove,
|
|
6744
|
+
onMouseEnter: () => onShowAt(b.x + b.w / 2, b.y, `${key}: ${labels[i]} \u2014 ${b.v}`, barSvgRef.current),
|
|
6765
6745
|
onMouseLeave: onLeave
|
|
6766
6746
|
},
|
|
6767
6747
|
`${di}-${i}`
|
|
@@ -6771,11 +6751,11 @@ var BarChart = React7.memo(({ data, labels, width, height, animate, onHover, onM
|
|
|
6771
6751
|
] });
|
|
6772
6752
|
});
|
|
6773
6753
|
BarChart.displayName = "BarChart";
|
|
6774
|
-
var PieDonutChart =
|
|
6754
|
+
var PieDonutChart = React6.memo(
|
|
6775
6755
|
({ data, labels, width, height, animate, isDoughnut, onHover, onMove, onLeave }) => {
|
|
6776
|
-
const entries =
|
|
6777
|
-
const values =
|
|
6778
|
-
const total =
|
|
6756
|
+
const entries = React6.useMemo(() => Object.entries(data), [data]);
|
|
6757
|
+
const values = React6.useMemo(() => entries.flatMap(([, v]) => v), [entries]);
|
|
6758
|
+
const total = React6.useMemo(() => values.reduce((a, b) => a + b, 0) || 1, [values]);
|
|
6779
6759
|
const size = Math.min(width, height);
|
|
6780
6760
|
const cx = size / 2;
|
|
6781
6761
|
const cy = size / 2;
|
|
@@ -6783,10 +6763,10 @@ var PieDonutChart = React7.memo(
|
|
|
6783
6763
|
const innerR = isDoughnut ? r2 * 0.5 : 0;
|
|
6784
6764
|
const firstKey = entries[0]?.[0] ?? "";
|
|
6785
6765
|
const colorOffset = hashString(firstKey);
|
|
6786
|
-
const maskRef =
|
|
6766
|
+
const maskRef = React6.useRef(null);
|
|
6787
6767
|
const maskR = r2 + 10;
|
|
6788
6768
|
const maskCircumference = 2 * Math.PI * maskR;
|
|
6789
|
-
|
|
6769
|
+
React6.useEffect(() => {
|
|
6790
6770
|
if (!animate || !maskRef.current) return;
|
|
6791
6771
|
const el = maskRef.current;
|
|
6792
6772
|
el.style.strokeDasharray = `${maskCircumference}`;
|
|
@@ -6796,7 +6776,7 @@ var PieDonutChart = React7.memo(
|
|
|
6796
6776
|
el.style.strokeDashoffset = "0";
|
|
6797
6777
|
});
|
|
6798
6778
|
}, [animate, maskCircumference]);
|
|
6799
|
-
const sliceData =
|
|
6779
|
+
const sliceData = React6.useMemo(() => {
|
|
6800
6780
|
let angle0 = -Math.PI / 2;
|
|
6801
6781
|
let cumulativeAngle = 0;
|
|
6802
6782
|
return values.map((v, i) => {
|
|
@@ -6831,7 +6811,7 @@ var PieDonutChart = React7.memo(
|
|
|
6831
6811
|
}, [values, total, cx, cy, r2, innerR, labels]);
|
|
6832
6812
|
const maskId = `pie-mask-${isDoughnut ? "d" : "p"}`;
|
|
6833
6813
|
return /* @__PURE__ */ jsxs197("svg", { viewBox: `0 0 ${size} ${size}`, className: "chart-svg chart-pie", children: [
|
|
6834
|
-
animate && /* @__PURE__ */
|
|
6814
|
+
animate && /* @__PURE__ */ jsx307("defs", { children: /* @__PURE__ */ jsx307("mask", { id: maskId, children: /* @__PURE__ */ jsx307(
|
|
6835
6815
|
"circle",
|
|
6836
6816
|
{
|
|
6837
6817
|
ref: maskRef,
|
|
@@ -6844,56 +6824,39 @@ var PieDonutChart = React7.memo(
|
|
|
6844
6824
|
transform: `rotate(-90 ${cx} ${cy})`
|
|
6845
6825
|
}
|
|
6846
6826
|
) }) }),
|
|
6847
|
-
/* @__PURE__ */
|
|
6827
|
+
/* @__PURE__ */ jsx307("g", { mask: animate ? `url(#${maskId})` : void 0, children: sliceData.map((s, i) => /* @__PURE__ */ jsx307("g", { children: /* @__PURE__ */ jsx307(
|
|
6848
6828
|
"path",
|
|
6849
6829
|
{
|
|
6850
6830
|
d: s.d,
|
|
6851
6831
|
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
|
|
6832
|
+
className: "chart-slice"
|
|
6856
6833
|
}
|
|
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
|
-
))
|
|
6834
|
+
) }, i)) })
|
|
6871
6835
|
] });
|
|
6872
6836
|
}
|
|
6873
6837
|
);
|
|
6874
6838
|
PieDonutChart.displayName = "PieDonutChart";
|
|
6875
|
-
var
|
|
6876
|
-
const ref =
|
|
6877
|
-
const [pos, setPos] =
|
|
6878
|
-
|
|
6839
|
+
var ChartTooltip = ({ x, y, containerWidth, containerHeight, children }) => {
|
|
6840
|
+
const ref = React6.useRef(null);
|
|
6841
|
+
const [pos, setPos] = React6.useState({ left: 0, top: 0 });
|
|
6842
|
+
React6.useLayoutEffect(() => {
|
|
6879
6843
|
const el = ref.current;
|
|
6880
6844
|
if (!el) return;
|
|
6881
6845
|
const w = el.offsetWidth;
|
|
6882
6846
|
const h = el.offsetHeight;
|
|
6883
|
-
|
|
6884
|
-
let
|
|
6885
|
-
|
|
6886
|
-
if (
|
|
6887
|
-
if (
|
|
6888
|
-
if (left < 8) left = 8;
|
|
6847
|
+
let left = x + TOOLTIP_OFFSET;
|
|
6848
|
+
let top = y - h - TOOLTIP_OFFSET;
|
|
6849
|
+
if (left + w > containerWidth) left = x - w - TOOLTIP_OFFSET;
|
|
6850
|
+
if (top < 0) top = y + TOOLTIP_OFFSET;
|
|
6851
|
+
if (left < 0) left = 0;
|
|
6889
6852
|
setPos({ left, top });
|
|
6890
|
-
}, [
|
|
6891
|
-
return /* @__PURE__ */
|
|
6853
|
+
}, [x, y, containerWidth, containerHeight]);
|
|
6854
|
+
return /* @__PURE__ */ jsx307(
|
|
6892
6855
|
"div",
|
|
6893
6856
|
{
|
|
6894
6857
|
ref,
|
|
6895
|
-
className:
|
|
6896
|
-
style: {
|
|
6858
|
+
className: "chart-tooltip chart-tooltip-show",
|
|
6859
|
+
style: { left: pos.left, top: pos.top },
|
|
6897
6860
|
children
|
|
6898
6861
|
}
|
|
6899
6862
|
);
|
|
@@ -6905,13 +6868,13 @@ var ChartLegend = ({ data, labels, type }) => {
|
|
|
6905
6868
|
const total = values.reduce((a, b) => a + b, 0) || 1;
|
|
6906
6869
|
const firstKey = entries[0]?.[0] ?? "";
|
|
6907
6870
|
const colorOffset = hashString(firstKey);
|
|
6908
|
-
return /* @__PURE__ */
|
|
6871
|
+
return /* @__PURE__ */ jsx307("div", { className: "chart-legend", children: values.map((v, i) => {
|
|
6909
6872
|
const pct = Math.round(v / total * 100);
|
|
6910
6873
|
const color = PIE_COLORS[(i + colorOffset) % PIE_COLORS.length];
|
|
6911
6874
|
return /* @__PURE__ */ jsxs197("div", { className: "chart-legend-item", children: [
|
|
6912
|
-
/* @__PURE__ */
|
|
6875
|
+
/* @__PURE__ */ jsx307("span", { className: "chart-legend-dot", style: { backgroundColor: color } }),
|
|
6913
6876
|
/* @__PURE__ */ jsxs197("div", { className: "chart-legend-text", children: [
|
|
6914
|
-
/* @__PURE__ */
|
|
6877
|
+
/* @__PURE__ */ jsx307("span", { className: "chart-legend-label", children: labels[i] || `${i + 1}` }),
|
|
6915
6878
|
/* @__PURE__ */ jsxs197("span", { className: "chart-legend-value", children: [
|
|
6916
6879
|
v.toLocaleString(),
|
|
6917
6880
|
"(",
|
|
@@ -6922,37 +6885,37 @@ var ChartLegend = ({ data, labels, type }) => {
|
|
|
6922
6885
|
] }, i);
|
|
6923
6886
|
}) });
|
|
6924
6887
|
}
|
|
6925
|
-
return /* @__PURE__ */
|
|
6888
|
+
return /* @__PURE__ */ jsx307("div", { className: "chart-legend", children: entries.map(([key], di) => {
|
|
6926
6889
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
6927
6890
|
const color = palette[2];
|
|
6928
6891
|
const values = entries[di][1];
|
|
6929
6892
|
const sum = values.reduce((a, b) => a + b, 0);
|
|
6930
6893
|
return /* @__PURE__ */ jsxs197("div", { className: "chart-legend-item", children: [
|
|
6931
|
-
/* @__PURE__ */
|
|
6894
|
+
/* @__PURE__ */ jsx307("span", { className: "chart-legend-dot", style: { backgroundColor: color } }),
|
|
6932
6895
|
/* @__PURE__ */ jsxs197("div", { className: "chart-legend-text", children: [
|
|
6933
|
-
/* @__PURE__ */
|
|
6934
|
-
/* @__PURE__ */
|
|
6896
|
+
/* @__PURE__ */ jsx307("span", { className: "chart-legend-label", children: key }),
|
|
6897
|
+
/* @__PURE__ */ jsx307("span", { className: "chart-legend-value", children: sum.toLocaleString() })
|
|
6935
6898
|
] })
|
|
6936
6899
|
] }, di);
|
|
6937
6900
|
}) });
|
|
6938
6901
|
};
|
|
6939
|
-
var Chart =
|
|
6902
|
+
var Chart = React6.memo((props) => {
|
|
6940
6903
|
const { type, data, labels, tooltip: showTooltip = true } = props;
|
|
6941
|
-
const { tooltip, show, hide, move, containerRef } = useChartTooltip(showTooltip);
|
|
6904
|
+
const { tooltip, show, showAt, hide, move, containerRef } = useChartTooltip(showTooltip);
|
|
6942
6905
|
const { width, height } = useChartSize(containerRef);
|
|
6943
|
-
const stableData =
|
|
6944
|
-
const stableLabels =
|
|
6945
|
-
const dataKey =
|
|
6906
|
+
const stableData = React6.useMemo(() => data, [JSON.stringify(data)]);
|
|
6907
|
+
const stableLabels = React6.useMemo(() => labels, [JSON.stringify(labels)]);
|
|
6908
|
+
const dataKey = React6.useMemo(() => JSON.stringify(labels), [labels]);
|
|
6946
6909
|
const animate = useChartAnimation(containerRef, dataKey);
|
|
6947
6910
|
const ready = width > 0 && height > 0;
|
|
6948
6911
|
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 === "
|
|
6955
|
-
tooltip.content && /* @__PURE__ */
|
|
6912
|
+
ready && type === "line" && /* @__PURE__ */ jsx307(LineChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onShowAt: showAt, onMove: move, onLeave: hide }),
|
|
6913
|
+
ready && type === "curve" && /* @__PURE__ */ jsx307(CurveChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onShowAt: showAt, onMove: move, onLeave: hide }),
|
|
6914
|
+
ready && type === "bar" && /* @__PURE__ */ jsx307(BarChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onShowAt: showAt, onMove: move, onLeave: hide }),
|
|
6915
|
+
ready && type === "pie" && /* @__PURE__ */ jsx307(PieDonutChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onShowAt: showAt, onMove: move, onLeave: hide }),
|
|
6916
|
+
ready && type === "doughnut" && /* @__PURE__ */ jsx307(PieDonutChart, { data: stableData, labels: stableLabels, width, height, animate, isDoughnut: true, onHover: show, onShowAt: showAt, onMove: move, onLeave: hide }),
|
|
6917
|
+
ready && (type === "pie" || type === "doughnut") && /* @__PURE__ */ jsx307(ChartLegend, { data: stableData, labels: stableLabels, type }),
|
|
6918
|
+
tooltip.visible && tooltip.content && /* @__PURE__ */ jsx307(ChartTooltip, { x: tooltip.x, y: tooltip.y, containerWidth: width, containerHeight: height, children: tooltip.content })
|
|
6956
6919
|
] });
|
|
6957
6920
|
});
|
|
6958
6921
|
Chart.displayName = "Chart";
|
|
@@ -6978,7 +6941,7 @@ import { primitive, semantic } from "@x-plat/tokens-core";
|
|
|
6978
6941
|
import { cssVar } from "@x-plat/tokens-core";
|
|
6979
6942
|
|
|
6980
6943
|
// src/components/CheckBox/CheckBox.tsx
|
|
6981
|
-
import { jsx as
|
|
6944
|
+
import { jsx as jsx308, jsxs as jsxs198 } from "react/jsx-runtime";
|
|
6982
6945
|
var CheckBox = (props) => {
|
|
6983
6946
|
const {
|
|
6984
6947
|
checked,
|
|
@@ -6997,7 +6960,7 @@ var CheckBox = (props) => {
|
|
|
6997
6960
|
const disabledClasses = "disabled";
|
|
6998
6961
|
const boxClasses = disabled ? disabledClasses : checked ? checkedClasses : uncheckedClasses;
|
|
6999
6962
|
return /* @__PURE__ */ jsxs198("label", { className: clsx_default("lib-xplat-checkbox", size, type), children: [
|
|
7000
|
-
/* @__PURE__ */
|
|
6963
|
+
/* @__PURE__ */ jsx308(
|
|
7001
6964
|
"input",
|
|
7002
6965
|
{
|
|
7003
6966
|
type: "checkbox",
|
|
@@ -7007,22 +6970,22 @@ var CheckBox = (props) => {
|
|
|
7007
6970
|
...rest
|
|
7008
6971
|
}
|
|
7009
6972
|
),
|
|
7010
|
-
/* @__PURE__ */
|
|
7011
|
-
label && /* @__PURE__ */
|
|
6973
|
+
/* @__PURE__ */ jsx308("span", { className: clsx_default("checkbox", boxClasses), children: /* @__PURE__ */ jsx308("span", { className: clsx_default("check-icon", { visible: checked }), children: /* @__PURE__ */ jsx308(CheckIcon_default, {}) }) }),
|
|
6974
|
+
label && /* @__PURE__ */ jsx308("span", { className: "label", children: label })
|
|
7012
6975
|
] });
|
|
7013
6976
|
};
|
|
7014
6977
|
CheckBox.displayName = "CheckBox";
|
|
7015
6978
|
var CheckBox_default = CheckBox;
|
|
7016
6979
|
|
|
7017
6980
|
// src/components/Chip/Chip.tsx
|
|
7018
|
-
import { jsx as
|
|
6981
|
+
import { jsx as jsx309 } from "react/jsx-runtime";
|
|
7019
6982
|
var Chip = (props) => {
|
|
7020
6983
|
const {
|
|
7021
6984
|
children,
|
|
7022
6985
|
type = "primary",
|
|
7023
6986
|
size = "md"
|
|
7024
6987
|
} = props;
|
|
7025
|
-
return /* @__PURE__ */
|
|
6988
|
+
return /* @__PURE__ */ jsx309("div", { className: clsx_default("lib-xplat-chip", type, size), children });
|
|
7026
6989
|
};
|
|
7027
6990
|
Chip.displayName = "Chip";
|
|
7028
6991
|
var Chip_default = Chip;
|
|
@@ -7031,20 +6994,20 @@ var Chip_default = Chip;
|
|
|
7031
6994
|
import React12 from "react";
|
|
7032
6995
|
|
|
7033
6996
|
// src/components/Input/Input.tsx
|
|
7034
|
-
import
|
|
6997
|
+
import React7 from "react";
|
|
7035
6998
|
|
|
7036
6999
|
// src/components/Input/InputValidations.tsx
|
|
7037
|
-
import { jsx as
|
|
7000
|
+
import { jsx as jsx310, jsxs as jsxs199 } from "react/jsx-runtime";
|
|
7038
7001
|
var InputValidations = (props) => {
|
|
7039
7002
|
const { message, status = "default" } = props;
|
|
7040
7003
|
return /* @__PURE__ */ jsxs199("div", { className: clsx_default("lib-xplat-input-validation", status), children: [
|
|
7041
7004
|
/* @__PURE__ */ jsxs199("div", { className: "icon", children: [
|
|
7042
|
-
status === "default" && /* @__PURE__ */
|
|
7043
|
-
status === "success" && /* @__PURE__ */
|
|
7044
|
-
status === "warning" && /* @__PURE__ */
|
|
7045
|
-
status === "error" && /* @__PURE__ */
|
|
7005
|
+
status === "default" && /* @__PURE__ */ jsx310(InfoIcon_default, {}),
|
|
7006
|
+
status === "success" && /* @__PURE__ */ jsx310(SuccessIcon_default, {}),
|
|
7007
|
+
status === "warning" && /* @__PURE__ */ jsx310(InfoIcon_default, {}),
|
|
7008
|
+
status === "error" && /* @__PURE__ */ jsx310(ErrorIcon_default, {})
|
|
7046
7009
|
] }),
|
|
7047
|
-
/* @__PURE__ */
|
|
7010
|
+
/* @__PURE__ */ jsx310("div", { className: "message", children: message })
|
|
7048
7011
|
] });
|
|
7049
7012
|
};
|
|
7050
7013
|
InputValidations.displayName = "InputValidations";
|
|
@@ -7085,7 +7048,7 @@ var handleTelBackspace = (prevValue, currValue) => {
|
|
|
7085
7048
|
};
|
|
7086
7049
|
|
|
7087
7050
|
// src/components/Input/Input.tsx
|
|
7088
|
-
import { jsx as
|
|
7051
|
+
import { jsx as jsx311, jsxs as jsxs200 } from "react/jsx-runtime";
|
|
7089
7052
|
import { createElement } from "react";
|
|
7090
7053
|
var formatValue = (type, value) => {
|
|
7091
7054
|
if (value === null || value === void 0) return "";
|
|
@@ -7134,7 +7097,7 @@ var parseValue = (type, value) => {
|
|
|
7134
7097
|
return value;
|
|
7135
7098
|
}
|
|
7136
7099
|
};
|
|
7137
|
-
var Input =
|
|
7100
|
+
var Input = React7.forwardRef((props, ref) => {
|
|
7138
7101
|
const {
|
|
7139
7102
|
value,
|
|
7140
7103
|
onChange,
|
|
@@ -7166,7 +7129,7 @@ var Input = React8.forwardRef((props, ref) => {
|
|
|
7166
7129
|
{
|
|
7167
7130
|
className: clsx_default("lib-xplat-input", size, disabled ? "disabled" : void 0),
|
|
7168
7131
|
children: [
|
|
7169
|
-
/* @__PURE__ */
|
|
7132
|
+
/* @__PURE__ */ jsx311(
|
|
7170
7133
|
"input",
|
|
7171
7134
|
{
|
|
7172
7135
|
...inputProps,
|
|
@@ -7177,11 +7140,11 @@ var Input = React8.forwardRef((props, ref) => {
|
|
|
7177
7140
|
onChange: handleChange
|
|
7178
7141
|
}
|
|
7179
7142
|
),
|
|
7180
|
-
suffix && /* @__PURE__ */
|
|
7143
|
+
suffix && /* @__PURE__ */ jsx311("div", { className: "suffix", children: suffix })
|
|
7181
7144
|
]
|
|
7182
7145
|
}
|
|
7183
7146
|
),
|
|
7184
|
-
validations && /* @__PURE__ */
|
|
7147
|
+
validations && /* @__PURE__ */ jsx311("div", { className: "lib-xplat-input-validation-wrap", children: validations?.map((validation, idx) => /* @__PURE__ */ createElement(
|
|
7185
7148
|
InputValidations_default,
|
|
7186
7149
|
{
|
|
7187
7150
|
...validation,
|
|
@@ -7194,20 +7157,20 @@ Input.displayName = "Input";
|
|
|
7194
7157
|
var Input_default = Input;
|
|
7195
7158
|
|
|
7196
7159
|
// src/components/Input/PasswordInput/PasswordInput.tsx
|
|
7197
|
-
import
|
|
7198
|
-
import { jsx as
|
|
7199
|
-
var PasswordInput =
|
|
7160
|
+
import React8 from "react";
|
|
7161
|
+
import { jsx as jsx312 } from "react/jsx-runtime";
|
|
7162
|
+
var PasswordInput = React8.forwardRef(
|
|
7200
7163
|
(props, ref) => {
|
|
7201
7164
|
const { reg: _reg, ...inputProps } = props;
|
|
7202
|
-
const [isView, setIsView] =
|
|
7165
|
+
const [isView, setIsView] = React8.useState(false);
|
|
7203
7166
|
const handleChangeView = () => {
|
|
7204
7167
|
setIsView((prev) => !prev);
|
|
7205
7168
|
};
|
|
7206
|
-
return /* @__PURE__ */
|
|
7169
|
+
return /* @__PURE__ */ jsx312(
|
|
7207
7170
|
Input_default,
|
|
7208
7171
|
{
|
|
7209
7172
|
...inputProps,
|
|
7210
|
-
suffix: /* @__PURE__ */
|
|
7173
|
+
suffix: /* @__PURE__ */ jsx312("div", { className: "wrapper pointer", onClick: handleChangeView, children: isView ? /* @__PURE__ */ jsx312(OpenEyeIcon_default, {}) : /* @__PURE__ */ jsx312(CloseEyeIcon_default, {}) }),
|
|
7211
7174
|
type: isView ? "text" : "password",
|
|
7212
7175
|
ref
|
|
7213
7176
|
}
|
|
@@ -7220,6 +7183,23 @@ var PasswordInput_default = PasswordInput;
|
|
|
7220
7183
|
// src/components/Modal/Modal.tsx
|
|
7221
7184
|
import React10 from "react";
|
|
7222
7185
|
import { createPortal } from "react-dom";
|
|
7186
|
+
|
|
7187
|
+
// src/tokens/hooks/Portal.tsx
|
|
7188
|
+
import React9 from "react";
|
|
7189
|
+
import ReactDOM from "react-dom";
|
|
7190
|
+
import { jsx as jsx313 } from "react/jsx-runtime";
|
|
7191
|
+
var PortalContainerContext = React9.createContext(null);
|
|
7192
|
+
var PortalProvider = ({ container, children }) => /* @__PURE__ */ jsx313(PortalContainerContext.Provider, { value: container, children });
|
|
7193
|
+
var Portal = ({ children }) => {
|
|
7194
|
+
const contextContainer = React9.useContext(PortalContainerContext);
|
|
7195
|
+
if (typeof document === "undefined") return null;
|
|
7196
|
+
const container = contextContainer ?? document.body;
|
|
7197
|
+
return ReactDOM.createPortal(children, container);
|
|
7198
|
+
};
|
|
7199
|
+
Portal.displayName = "Portal";
|
|
7200
|
+
var Portal_default = Portal;
|
|
7201
|
+
|
|
7202
|
+
// src/components/Modal/Modal.tsx
|
|
7223
7203
|
import { jsx as jsx314 } from "react/jsx-runtime";
|
|
7224
7204
|
var ANIMATION_DURATION_MS = 200;
|
|
7225
7205
|
var Modal = (props) => {
|