@x-plat/design-system 0.5.33 → 0.5.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Chart/index.cjs +152 -192
- package/dist/components/Chart/index.css +4 -1
- package/dist/components/Chart/index.js +140 -180
- package/dist/components/index.cjs +183 -239
- package/dist/components/index.css +4 -1
- package/dist/components/index.js +165 -221
- package/dist/index.cjs +183 -239
- package/dist/index.css +4 -1
- package/dist/index.js +165 -221
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6229,8 +6229,25 @@ 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
|
|
6232
6235
|
import React6 from "react";
|
|
6233
|
-
import
|
|
6236
|
+
import ReactDOM from "react-dom";
|
|
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";
|
|
6234
6251
|
var CATEGORICAL_COUNT2 = 8;
|
|
6235
6252
|
var LINE_BAR_PALETTES = Array.from({ length: CATEGORICAL_COUNT2 }, (_, i) => {
|
|
6236
6253
|
const n = i + 1;
|
|
@@ -6276,11 +6293,11 @@ var toSmoothPath = (points) => {
|
|
|
6276
6293
|
};
|
|
6277
6294
|
var RESIZE_SETTLE_MS = 150;
|
|
6278
6295
|
var useChartSize = (ref) => {
|
|
6279
|
-
const [size, setSize] =
|
|
6280
|
-
const settleTimer =
|
|
6281
|
-
const committedSize =
|
|
6282
|
-
const initialRef =
|
|
6283
|
-
|
|
6296
|
+
const [size, setSize] = React7.useState({ width: 0, height: 0 });
|
|
6297
|
+
const settleTimer = React7.useRef(0);
|
|
6298
|
+
const committedSize = React7.useRef({ width: 0, height: 0 });
|
|
6299
|
+
const initialRef = React7.useRef(true);
|
|
6300
|
+
React7.useEffect(() => {
|
|
6284
6301
|
const el = ref.current;
|
|
6285
6302
|
if (!el) return;
|
|
6286
6303
|
const observer = new ResizeObserver((entries) => {
|
|
@@ -6322,10 +6339,10 @@ var useChartSize = (ref) => {
|
|
|
6322
6339
|
};
|
|
6323
6340
|
var prefersReducedMotion = () => typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
6324
6341
|
var useChartAnimation = (containerRef, dataKey) => {
|
|
6325
|
-
const [animate, setAnimate] =
|
|
6326
|
-
const prevDataKey =
|
|
6327
|
-
const hasAnimated =
|
|
6328
|
-
|
|
6342
|
+
const [animate, setAnimate] = React7.useState(false);
|
|
6343
|
+
const prevDataKey = React7.useRef(dataKey);
|
|
6344
|
+
const hasAnimated = React7.useRef(false);
|
|
6345
|
+
React7.useEffect(() => {
|
|
6329
6346
|
if (prefersReducedMotion()) return;
|
|
6330
6347
|
const el = containerRef.current;
|
|
6331
6348
|
if (!el) return;
|
|
@@ -6341,27 +6358,29 @@ var useChartAnimation = (containerRef, dataKey) => {
|
|
|
6341
6358
|
observer.observe(el);
|
|
6342
6359
|
return () => observer.disconnect();
|
|
6343
6360
|
}, [containerRef]);
|
|
6344
|
-
|
|
6361
|
+
React7.useEffect(() => {
|
|
6345
6362
|
if (dataKey !== prevDataKey.current) {
|
|
6346
6363
|
prevDataKey.current = dataKey;
|
|
6347
6364
|
if (prefersReducedMotion()) return;
|
|
6348
6365
|
setAnimate(false);
|
|
6349
|
-
requestAnimationFrame(() =>
|
|
6366
|
+
requestAnimationFrame(() => {
|
|
6367
|
+
requestAnimationFrame(() => setAnimate(true));
|
|
6368
|
+
});
|
|
6350
6369
|
}
|
|
6351
6370
|
}, [dataKey]);
|
|
6352
6371
|
return animate || prefersReducedMotion();
|
|
6353
6372
|
};
|
|
6354
6373
|
var TOOLTIP_OFFSET = 12;
|
|
6355
6374
|
var useChartTooltip = (enabled) => {
|
|
6356
|
-
const [tooltip, setTooltip] =
|
|
6375
|
+
const [tooltip, setTooltip] = React7.useState({
|
|
6357
6376
|
visible: false,
|
|
6358
6377
|
clientX: 0,
|
|
6359
6378
|
clientY: 0,
|
|
6360
6379
|
content: ""
|
|
6361
6380
|
});
|
|
6362
|
-
const containerRef =
|
|
6363
|
-
const rafRef =
|
|
6364
|
-
const move =
|
|
6381
|
+
const containerRef = React7.useRef(null);
|
|
6382
|
+
const rafRef = React7.useRef(0);
|
|
6383
|
+
const move = React7.useCallback((e) => {
|
|
6365
6384
|
if (!enabled) return;
|
|
6366
6385
|
const cx = e.clientX;
|
|
6367
6386
|
const cy = e.clientY;
|
|
@@ -6370,22 +6389,22 @@ var useChartTooltip = (enabled) => {
|
|
|
6370
6389
|
setTooltip((prev) => ({ ...prev, clientX: cx, clientY: cy }));
|
|
6371
6390
|
});
|
|
6372
6391
|
}, [enabled]);
|
|
6373
|
-
const show =
|
|
6392
|
+
const show = React7.useCallback((e, content) => {
|
|
6374
6393
|
if (!enabled) return;
|
|
6375
6394
|
setTooltip({ visible: true, clientX: e.clientX, clientY: e.clientY, content });
|
|
6376
6395
|
}, [enabled]);
|
|
6377
|
-
const hide =
|
|
6396
|
+
const hide = React7.useCallback(() => {
|
|
6378
6397
|
cancelAnimationFrame(rafRef.current);
|
|
6379
6398
|
setTooltip((prev) => ({ ...prev, visible: false }));
|
|
6380
6399
|
}, []);
|
|
6381
6400
|
return { tooltip, show, hide, move, containerRef };
|
|
6382
6401
|
};
|
|
6383
|
-
var GridLines =
|
|
6402
|
+
var GridLines = React7.memo(({ width, height, chartH, maxVal }) => /* @__PURE__ */ jsx308(Fragment2, { children: [0, 0.25, 0.5, 0.75, 1].map((ratio) => {
|
|
6384
6403
|
const y = PADDING.top + (1 - ratio) * chartH;
|
|
6385
6404
|
const val = Math.round(maxVal * ratio);
|
|
6386
6405
|
return /* @__PURE__ */ jsxs197("g", { children: [
|
|
6387
|
-
/* @__PURE__ */
|
|
6388
|
-
/* @__PURE__ */
|
|
6406
|
+
/* @__PURE__ */ jsx308("line", { x1: PADDING.left, y1: y, x2: width - PADDING.right, y2: y, className: "chart-grid" }),
|
|
6407
|
+
/* @__PURE__ */ jsx308("text", { x: PADDING.left - 8, y: y + 4, className: "chart-axis-label", textAnchor: "end", children: val })
|
|
6389
6408
|
] }, ratio);
|
|
6390
6409
|
}) }));
|
|
6391
6410
|
GridLines.displayName = "GridLines";
|
|
@@ -6395,18 +6414,18 @@ var getLabelStep = (count, chartW) => {
|
|
|
6395
6414
|
if (count <= maxLabels) return 1;
|
|
6396
6415
|
return Math.ceil(count / maxLabels);
|
|
6397
6416
|
};
|
|
6398
|
-
var AxisLabels =
|
|
6417
|
+
var AxisLabels = React7.memo(({ labels, count, chartW, height }) => {
|
|
6399
6418
|
const step = getLabelStep(count, chartW);
|
|
6400
|
-
return /* @__PURE__ */
|
|
6419
|
+
return /* @__PURE__ */ jsx308(Fragment2, { children: labels.map((label, i) => {
|
|
6401
6420
|
if (i % step !== 0) return null;
|
|
6402
6421
|
const x = PADDING.left + i / (count - 1 || 1) * chartW;
|
|
6403
|
-
return /* @__PURE__ */
|
|
6422
|
+
return /* @__PURE__ */ jsx308("text", { x, y: height - 8, className: "chart-axis-label", textAnchor: "middle", children: label }, i);
|
|
6404
6423
|
}) });
|
|
6405
6424
|
});
|
|
6406
6425
|
AxisLabels.displayName = "AxisLabels";
|
|
6407
6426
|
var useCrosshair = (seriesPoints, entries, labels, chartH) => {
|
|
6408
|
-
const [activeIndex, setActiveIndex] =
|
|
6409
|
-
const handleMouseMove =
|
|
6427
|
+
const [activeIndex, setActiveIndex] = React7.useState(null);
|
|
6428
|
+
const handleMouseMove = React7.useCallback((e) => {
|
|
6410
6429
|
const svg = e.currentTarget;
|
|
6411
6430
|
const rect = svg.getBoundingClientRect();
|
|
6412
6431
|
const mx = (e.clientX - rect.left) / rect.width * svg.viewBox.baseVal.width;
|
|
@@ -6425,17 +6444,17 @@ var useCrosshair = (seriesPoints, entries, labels, chartH) => {
|
|
|
6425
6444
|
}
|
|
6426
6445
|
setActiveIndex(minDist <= threshold ? closest : null);
|
|
6427
6446
|
}, [seriesPoints]);
|
|
6428
|
-
const handleMouseLeave =
|
|
6447
|
+
const handleMouseLeave = React7.useCallback(() => {
|
|
6429
6448
|
setActiveIndex(null);
|
|
6430
6449
|
}, []);
|
|
6431
|
-
const tooltipContent =
|
|
6450
|
+
const tooltipContent = React7.useMemo(() => {
|
|
6432
6451
|
if (activeIndex === null) return "";
|
|
6433
6452
|
return entries.map(([key], di) => {
|
|
6434
6453
|
const p = seriesPoints[di]?.[activeIndex];
|
|
6435
6454
|
return p ? `${key}: ${p.v}` : "";
|
|
6436
6455
|
}).filter(Boolean).join(" / ");
|
|
6437
6456
|
}, [activeIndex, entries, seriesPoints]);
|
|
6438
|
-
const getTooltipAt =
|
|
6457
|
+
const getTooltipAt = React7.useCallback((idx) => {
|
|
6439
6458
|
return entries.map(([key], di) => {
|
|
6440
6459
|
const p = seriesPoints[di]?.[idx];
|
|
6441
6460
|
return p ? `${key}: ${p.v}` : "";
|
|
@@ -6443,16 +6462,16 @@ var useCrosshair = (seriesPoints, entries, labels, chartH) => {
|
|
|
6443
6462
|
}, [entries, seriesPoints]);
|
|
6444
6463
|
return { activeIndex, handleMouseMove, handleMouseLeave, tooltipContent, getTooltipAt };
|
|
6445
6464
|
};
|
|
6446
|
-
var LineChart =
|
|
6447
|
-
const entries =
|
|
6448
|
-
const maxVal =
|
|
6465
|
+
var LineChart = React7.memo(({ data, labels, width, height, animate, onHover, onMove, onLeave }) => {
|
|
6466
|
+
const entries = React7.useMemo(() => Object.entries(data), [data]);
|
|
6467
|
+
const maxVal = React7.useMemo(() => {
|
|
6449
6468
|
const allValues = entries.flatMap(([, v]) => v);
|
|
6450
6469
|
return Math.max(...allValues) * 1.2 || 1;
|
|
6451
6470
|
}, [entries]);
|
|
6452
6471
|
const count = labels.length;
|
|
6453
6472
|
const chartW = width - PADDING.left - PADDING.right;
|
|
6454
6473
|
const chartH = height - PADDING.top - PADDING.bottom;
|
|
6455
|
-
const seriesPoints =
|
|
6474
|
+
const seriesPoints = React7.useMemo(
|
|
6456
6475
|
() => entries.map(
|
|
6457
6476
|
([, values]) => values.map((v, i) => ({
|
|
6458
6477
|
x: PADDING.left + i / (count - 1 || 1) * chartW,
|
|
@@ -6462,31 +6481,18 @@ var LineChart = React6.memo(({ data, labels, width, height, animate, onHover, on
|
|
|
6462
6481
|
),
|
|
6463
6482
|
[entries, count, chartW, chartH, maxVal]
|
|
6464
6483
|
);
|
|
6465
|
-
const
|
|
6466
|
-
const clipRef = React6.useRef(null);
|
|
6484
|
+
const clipRef = React7.useRef(null);
|
|
6467
6485
|
const { activeIndex, handleMouseMove, handleMouseLeave, getTooltipAt } = useCrosshair(seriesPoints, entries, labels, chartH);
|
|
6468
|
-
|
|
6469
|
-
if (!animate) return;
|
|
6470
|
-
|
|
6471
|
-
|
|
6472
|
-
|
|
6473
|
-
|
|
6474
|
-
|
|
6475
|
-
|
|
6476
|
-
el.style.transition = "stroke-dashoffset 1200ms ease-out 200ms";
|
|
6477
|
-
el.style.strokeDashoffset = "0";
|
|
6478
|
-
});
|
|
6486
|
+
React7.useEffect(() => {
|
|
6487
|
+
if (!animate || !clipRef.current) return;
|
|
6488
|
+
clipRef.current.setAttribute("width", "0");
|
|
6489
|
+
requestAnimationFrame(() => {
|
|
6490
|
+
if (clipRef.current) {
|
|
6491
|
+
clipRef.current.style.transition = "width 1200ms ease-out 200ms";
|
|
6492
|
+
clipRef.current.setAttribute("width", `${width}`);
|
|
6493
|
+
}
|
|
6479
6494
|
});
|
|
6480
|
-
|
|
6481
|
-
clipRef.current.setAttribute("width", "0");
|
|
6482
|
-
requestAnimationFrame(() => {
|
|
6483
|
-
if (clipRef.current) {
|
|
6484
|
-
clipRef.current.style.transition = "width 1200ms ease-out 200ms";
|
|
6485
|
-
clipRef.current.setAttribute("width", `${width}`);
|
|
6486
|
-
}
|
|
6487
|
-
});
|
|
6488
|
-
}
|
|
6489
|
-
}, [animate, seriesPoints, width]);
|
|
6495
|
+
}, [animate, width]);
|
|
6490
6496
|
const activeX = activeIndex !== null ? seriesPoints[0]?.[activeIndex]?.x ?? null : null;
|
|
6491
6497
|
const lineClipId = "line-area-clip";
|
|
6492
6498
|
return /* @__PURE__ */ jsxs197(
|
|
@@ -6522,9 +6528,9 @@ var LineChart = React6.memo(({ data, labels, width, height, animate, onHover, on
|
|
|
6522
6528
|
onLeave();
|
|
6523
6529
|
},
|
|
6524
6530
|
children: [
|
|
6525
|
-
animate && /* @__PURE__ */
|
|
6526
|
-
/* @__PURE__ */
|
|
6527
|
-
/* @__PURE__ */
|
|
6531
|
+
animate && /* @__PURE__ */ jsx308("defs", { children: /* @__PURE__ */ jsx308("clipPath", { id: lineClipId, children: /* @__PURE__ */ jsx308("rect", { ref: clipRef, x: "0", y: "0", width: animate ? 0 : width, height }) }) }),
|
|
6532
|
+
/* @__PURE__ */ jsx308(GridLines, { width, height, chartH, maxVal }),
|
|
6533
|
+
/* @__PURE__ */ jsx308(AxisLabels, { labels, count, chartW, height }),
|
|
6528
6534
|
entries.map(([key], di) => {
|
|
6529
6535
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
6530
6536
|
const color = palette[2];
|
|
@@ -6534,31 +6540,15 @@ var LineChart = React6.memo(({ data, labels, width, height, animate, onHover, on
|
|
|
6534
6540
|
const polyPoints = points.map((p) => `${p.x},${p.y}`).join(" ");
|
|
6535
6541
|
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`;
|
|
6536
6542
|
return /* @__PURE__ */ jsxs197("g", { children: [
|
|
6537
|
-
/* @__PURE__ */
|
|
6538
|
-
/* @__PURE__ */
|
|
6539
|
-
/* @__PURE__ */
|
|
6543
|
+
/* @__PURE__ */ jsx308("defs", { children: /* @__PURE__ */ jsxs197("linearGradient", { id: gradientId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
6544
|
+
/* @__PURE__ */ jsx308("stop", { offset: "0%", stopColor: areaColor, stopOpacity: "0.2" }),
|
|
6545
|
+
/* @__PURE__ */ jsx308("stop", { offset: "100%", stopColor: areaColor, stopOpacity: "0" })
|
|
6540
6546
|
] }) }),
|
|
6541
|
-
/* @__PURE__ */
|
|
6542
|
-
"path",
|
|
6543
|
-
{
|
|
6544
|
-
|
|
6545
|
-
|
|
6546
|
-
clipPath: animate ? `url(#${lineClipId})` : void 0
|
|
6547
|
-
}
|
|
6548
|
-
),
|
|
6549
|
-
/* @__PURE__ */ jsx307(
|
|
6550
|
-
"polyline",
|
|
6551
|
-
{
|
|
6552
|
-
ref: (el) => {
|
|
6553
|
-
lineRefs.current[di] = el;
|
|
6554
|
-
},
|
|
6555
|
-
points: polyPoints,
|
|
6556
|
-
fill: "none",
|
|
6557
|
-
stroke: color,
|
|
6558
|
-
strokeWidth: "2"
|
|
6559
|
-
}
|
|
6560
|
-
),
|
|
6561
|
-
activeIndex !== null && points[activeIndex] && /* @__PURE__ */ jsx307(
|
|
6547
|
+
/* @__PURE__ */ jsxs197("g", { clipPath: animate ? `url(#${lineClipId})` : void 0, children: [
|
|
6548
|
+
/* @__PURE__ */ jsx308("path", { d: areaD, fill: `url(#${gradientId})` }),
|
|
6549
|
+
/* @__PURE__ */ jsx308("polyline", { points: polyPoints, fill: "none", stroke: color, strokeWidth: "2" })
|
|
6550
|
+
] }),
|
|
6551
|
+
activeIndex !== null && points[activeIndex] && /* @__PURE__ */ jsx308(
|
|
6562
6552
|
"circle",
|
|
6563
6553
|
{
|
|
6564
6554
|
cx: points[activeIndex].x,
|
|
@@ -6570,7 +6560,7 @@ var LineChart = React6.memo(({ data, labels, width, height, animate, onHover, on
|
|
|
6570
6560
|
)
|
|
6571
6561
|
] }, di);
|
|
6572
6562
|
}),
|
|
6573
|
-
activeX !== null && /* @__PURE__ */
|
|
6563
|
+
activeX !== null && /* @__PURE__ */ jsx308(
|
|
6574
6564
|
"line",
|
|
6575
6565
|
{
|
|
6576
6566
|
x1: activeX,
|
|
@@ -6580,7 +6570,7 @@ var LineChart = React6.memo(({ data, labels, width, height, animate, onHover, on
|
|
|
6580
6570
|
className: "chart-crosshair"
|
|
6581
6571
|
}
|
|
6582
6572
|
),
|
|
6583
|
-
/* @__PURE__ */
|
|
6573
|
+
/* @__PURE__ */ jsx308(
|
|
6584
6574
|
"rect",
|
|
6585
6575
|
{
|
|
6586
6576
|
x: PADDING.left,
|
|
@@ -6596,16 +6586,16 @@ var LineChart = React6.memo(({ data, labels, width, height, animate, onHover, on
|
|
|
6596
6586
|
);
|
|
6597
6587
|
});
|
|
6598
6588
|
LineChart.displayName = "LineChart";
|
|
6599
|
-
var CurveChart =
|
|
6600
|
-
const entries =
|
|
6601
|
-
const maxVal =
|
|
6589
|
+
var CurveChart = React7.memo(({ data, labels, width, height, animate, onHover, onMove, onLeave }) => {
|
|
6590
|
+
const entries = React7.useMemo(() => Object.entries(data), [data]);
|
|
6591
|
+
const maxVal = React7.useMemo(() => {
|
|
6602
6592
|
const allValues = entries.flatMap(([, v]) => v);
|
|
6603
6593
|
return Math.max(...allValues) * 1.2 || 1;
|
|
6604
6594
|
}, [entries]);
|
|
6605
6595
|
const count = labels.length;
|
|
6606
6596
|
const chartW = width - PADDING.left - PADDING.right;
|
|
6607
6597
|
const chartH = height - PADDING.top - PADDING.bottom;
|
|
6608
|
-
const seriesPoints =
|
|
6598
|
+
const seriesPoints = React7.useMemo(
|
|
6609
6599
|
() => entries.map(
|
|
6610
6600
|
([, values]) => values.map((v, i) => ({
|
|
6611
6601
|
x: PADDING.left + i / (count - 1 || 1) * chartW,
|
|
@@ -6615,31 +6605,18 @@ var CurveChart = React6.memo(({ data, labels, width, height, animate, onHover, o
|
|
|
6615
6605
|
),
|
|
6616
6606
|
[entries, count, chartW, chartH, maxVal]
|
|
6617
6607
|
);
|
|
6618
|
-
const
|
|
6619
|
-
const curveClipRef = React6.useRef(null);
|
|
6608
|
+
const curveClipRef = React7.useRef(null);
|
|
6620
6609
|
const { activeIndex, handleMouseMove, handleMouseLeave, getTooltipAt } = useCrosshair(seriesPoints, entries, labels, chartH);
|
|
6621
|
-
|
|
6622
|
-
if (!animate) return;
|
|
6623
|
-
|
|
6624
|
-
|
|
6625
|
-
|
|
6626
|
-
|
|
6627
|
-
|
|
6628
|
-
|
|
6629
|
-
el.style.transition = "stroke-dashoffset 1200ms ease-out 200ms";
|
|
6630
|
-
el.style.strokeDashoffset = "0";
|
|
6631
|
-
});
|
|
6610
|
+
React7.useEffect(() => {
|
|
6611
|
+
if (!animate || !curveClipRef.current) return;
|
|
6612
|
+
curveClipRef.current.setAttribute("width", "0");
|
|
6613
|
+
requestAnimationFrame(() => {
|
|
6614
|
+
if (curveClipRef.current) {
|
|
6615
|
+
curveClipRef.current.style.transition = "width 1200ms ease-out 200ms";
|
|
6616
|
+
curveClipRef.current.setAttribute("width", `${width}`);
|
|
6617
|
+
}
|
|
6632
6618
|
});
|
|
6633
|
-
|
|
6634
|
-
curveClipRef.current.setAttribute("width", "0");
|
|
6635
|
-
requestAnimationFrame(() => {
|
|
6636
|
-
if (curveClipRef.current) {
|
|
6637
|
-
curveClipRef.current.style.transition = "width 1200ms ease-out 200ms";
|
|
6638
|
-
curveClipRef.current.setAttribute("width", `${width}`);
|
|
6639
|
-
}
|
|
6640
|
-
});
|
|
6641
|
-
}
|
|
6642
|
-
}, [animate, seriesPoints, width]);
|
|
6619
|
+
}, [animate, width]);
|
|
6643
6620
|
const activeX = activeIndex !== null ? seriesPoints[0]?.[activeIndex]?.x ?? null : null;
|
|
6644
6621
|
const curveClipId = "curve-area-clip";
|
|
6645
6622
|
return /* @__PURE__ */ jsxs197(
|
|
@@ -6675,9 +6652,9 @@ var CurveChart = React6.memo(({ data, labels, width, height, animate, onHover, o
|
|
|
6675
6652
|
onLeave();
|
|
6676
6653
|
},
|
|
6677
6654
|
children: [
|
|
6678
|
-
animate && /* @__PURE__ */
|
|
6679
|
-
/* @__PURE__ */
|
|
6680
|
-
/* @__PURE__ */
|
|
6655
|
+
animate && /* @__PURE__ */ jsx308("defs", { children: /* @__PURE__ */ jsx308("clipPath", { id: curveClipId, children: /* @__PURE__ */ jsx308("rect", { ref: curveClipRef, x: "0", y: "0", width: animate ? 0 : width, height }) }) }),
|
|
6656
|
+
/* @__PURE__ */ jsx308(GridLines, { width, height, chartH, maxVal }),
|
|
6657
|
+
/* @__PURE__ */ jsx308(AxisLabels, { labels, count, chartW, height }),
|
|
6681
6658
|
entries.map(([key], di) => {
|
|
6682
6659
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
6683
6660
|
const color = palette[2];
|
|
@@ -6687,31 +6664,15 @@ var CurveChart = React6.memo(({ data, labels, width, height, animate, onHover, o
|
|
|
6687
6664
|
const linePath = toSmoothPath(points);
|
|
6688
6665
|
const areaPath = linePath + ` L ${points[points.length - 1].x} ${PADDING.top + chartH} L ${points[0].x} ${PADDING.top + chartH} Z`;
|
|
6689
6666
|
return /* @__PURE__ */ jsxs197("g", { children: [
|
|
6690
|
-
/* @__PURE__ */
|
|
6691
|
-
/* @__PURE__ */
|
|
6692
|
-
/* @__PURE__ */
|
|
6667
|
+
/* @__PURE__ */ jsx308("defs", { children: /* @__PURE__ */ jsxs197("linearGradient", { id: gradientId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
6668
|
+
/* @__PURE__ */ jsx308("stop", { offset: "0%", stopColor: areaColor, stopOpacity: "0.4" }),
|
|
6669
|
+
/* @__PURE__ */ jsx308("stop", { offset: "100%", stopColor: areaColor, stopOpacity: "0.02" })
|
|
6693
6670
|
] }) }),
|
|
6694
|
-
/* @__PURE__ */
|
|
6695
|
-
"path",
|
|
6696
|
-
{
|
|
6697
|
-
|
|
6698
|
-
|
|
6699
|
-
clipPath: animate ? `url(#${curveClipId})` : void 0
|
|
6700
|
-
}
|
|
6701
|
-
),
|
|
6702
|
-
/* @__PURE__ */ jsx307(
|
|
6703
|
-
"path",
|
|
6704
|
-
{
|
|
6705
|
-
ref: (el) => {
|
|
6706
|
-
lineRefs.current[di] = el;
|
|
6707
|
-
},
|
|
6708
|
-
d: linePath,
|
|
6709
|
-
fill: "none",
|
|
6710
|
-
stroke: color,
|
|
6711
|
-
strokeWidth: "2"
|
|
6712
|
-
}
|
|
6713
|
-
),
|
|
6714
|
-
activeIndex !== null && points[activeIndex] && /* @__PURE__ */ jsx307(
|
|
6671
|
+
/* @__PURE__ */ jsxs197("g", { clipPath: animate ? `url(#${curveClipId})` : void 0, children: [
|
|
6672
|
+
/* @__PURE__ */ jsx308("path", { d: areaPath, fill: `url(#${gradientId})` }),
|
|
6673
|
+
/* @__PURE__ */ jsx308("path", { d: linePath, fill: "none", stroke: color, strokeWidth: "2" })
|
|
6674
|
+
] }),
|
|
6675
|
+
activeIndex !== null && points[activeIndex] && /* @__PURE__ */ jsx308(
|
|
6715
6676
|
"circle",
|
|
6716
6677
|
{
|
|
6717
6678
|
cx: points[activeIndex].x,
|
|
@@ -6723,7 +6684,7 @@ var CurveChart = React6.memo(({ data, labels, width, height, animate, onHover, o
|
|
|
6723
6684
|
)
|
|
6724
6685
|
] }, di);
|
|
6725
6686
|
}),
|
|
6726
|
-
activeX !== null && /* @__PURE__ */
|
|
6687
|
+
activeX !== null && /* @__PURE__ */ jsx308(
|
|
6727
6688
|
"line",
|
|
6728
6689
|
{
|
|
6729
6690
|
x1: activeX,
|
|
@@ -6733,7 +6694,7 @@ var CurveChart = React6.memo(({ data, labels, width, height, animate, onHover, o
|
|
|
6733
6694
|
className: "chart-crosshair"
|
|
6734
6695
|
}
|
|
6735
6696
|
),
|
|
6736
|
-
/* @__PURE__ */
|
|
6697
|
+
/* @__PURE__ */ jsx308(
|
|
6737
6698
|
"rect",
|
|
6738
6699
|
{
|
|
6739
6700
|
x: PADDING.left,
|
|
@@ -6749,9 +6710,9 @@ var CurveChart = React6.memo(({ data, labels, width, height, animate, onHover, o
|
|
|
6749
6710
|
);
|
|
6750
6711
|
});
|
|
6751
6712
|
CurveChart.displayName = "CurveChart";
|
|
6752
|
-
var BarChart =
|
|
6753
|
-
const entries =
|
|
6754
|
-
const maxVal =
|
|
6713
|
+
var BarChart = React7.memo(({ data, labels, width, height, animate, onHover, onMove, onLeave }) => {
|
|
6714
|
+
const entries = React7.useMemo(() => Object.entries(data), [data]);
|
|
6715
|
+
const maxVal = React7.useMemo(() => {
|
|
6755
6716
|
const allValues = entries.flatMap(([, v]) => v);
|
|
6756
6717
|
return Math.max(...allValues) * 1.2 || 1;
|
|
6757
6718
|
}, [entries]);
|
|
@@ -6763,7 +6724,7 @@ var BarChart = React6.memo(({ data, labels, width, height, animate, onHover, onM
|
|
|
6763
6724
|
const barGap = groupCount > 1 ? 2 : 0;
|
|
6764
6725
|
const barW = Math.max(1, Math.min(32, (groupW * 0.7 - barGap * (groupCount - 1)) / groupCount));
|
|
6765
6726
|
const baseline = PADDING.top + chartH;
|
|
6766
|
-
const bars =
|
|
6727
|
+
const bars = React7.useMemo(
|
|
6767
6728
|
() => entries.map(
|
|
6768
6729
|
([, values], di) => values.map((v, i) => {
|
|
6769
6730
|
const totalBarsW = barW * groupCount + barGap * (groupCount - 1);
|
|
@@ -6777,10 +6738,10 @@ var BarChart = React6.memo(({ data, labels, width, height, animate, onHover, onM
|
|
|
6777
6738
|
);
|
|
6778
6739
|
const barLabelStep = getLabelStep(count, chartW);
|
|
6779
6740
|
return /* @__PURE__ */ jsxs197("svg", { viewBox: `0 0 ${width} ${height}`, className: "chart-svg", children: [
|
|
6780
|
-
/* @__PURE__ */
|
|
6741
|
+
/* @__PURE__ */ jsx308(GridLines, { width, height, chartH, maxVal }),
|
|
6781
6742
|
labels.map((label, i) => {
|
|
6782
6743
|
if (i % barLabelStep !== 0) return null;
|
|
6783
|
-
return /* @__PURE__ */
|
|
6744
|
+
return /* @__PURE__ */ jsx308("text", { x: PADDING.left + groupW * i + groupW / 2, y: height - 8, className: "chart-axis-label", textAnchor: "middle", children: label }, i);
|
|
6784
6745
|
}),
|
|
6785
6746
|
entries.map(([key], di) => {
|
|
6786
6747
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
@@ -6789,7 +6750,7 @@ var BarChart = React6.memo(({ data, labels, width, height, animate, onHover, onM
|
|
|
6789
6750
|
const r2 = Math.min(4, b.w / 2);
|
|
6790
6751
|
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`;
|
|
6791
6752
|
const delay = 100 + i * 80;
|
|
6792
|
-
return /* @__PURE__ */
|
|
6753
|
+
return /* @__PURE__ */ jsx308(
|
|
6793
6754
|
"path",
|
|
6794
6755
|
{
|
|
6795
6756
|
d,
|
|
@@ -6810,11 +6771,11 @@ var BarChart = React6.memo(({ data, labels, width, height, animate, onHover, onM
|
|
|
6810
6771
|
] });
|
|
6811
6772
|
});
|
|
6812
6773
|
BarChart.displayName = "BarChart";
|
|
6813
|
-
var PieDonutChart =
|
|
6774
|
+
var PieDonutChart = React7.memo(
|
|
6814
6775
|
({ data, labels, width, height, animate, isDoughnut, onHover, onMove, onLeave }) => {
|
|
6815
|
-
const entries =
|
|
6816
|
-
const values =
|
|
6817
|
-
const total =
|
|
6776
|
+
const entries = React7.useMemo(() => Object.entries(data), [data]);
|
|
6777
|
+
const values = React7.useMemo(() => entries.flatMap(([, v]) => v), [entries]);
|
|
6778
|
+
const total = React7.useMemo(() => values.reduce((a, b) => a + b, 0) || 1, [values]);
|
|
6818
6779
|
const size = Math.min(width, height);
|
|
6819
6780
|
const cx = size / 2;
|
|
6820
6781
|
const cy = size / 2;
|
|
@@ -6822,10 +6783,10 @@ var PieDonutChart = React6.memo(
|
|
|
6822
6783
|
const innerR = isDoughnut ? r2 * 0.5 : 0;
|
|
6823
6784
|
const firstKey = entries[0]?.[0] ?? "";
|
|
6824
6785
|
const colorOffset = hashString(firstKey);
|
|
6825
|
-
const maskRef =
|
|
6786
|
+
const maskRef = React7.useRef(null);
|
|
6826
6787
|
const maskR = r2 + 10;
|
|
6827
6788
|
const maskCircumference = 2 * Math.PI * maskR;
|
|
6828
|
-
|
|
6789
|
+
React7.useEffect(() => {
|
|
6829
6790
|
if (!animate || !maskRef.current) return;
|
|
6830
6791
|
const el = maskRef.current;
|
|
6831
6792
|
el.style.strokeDasharray = `${maskCircumference}`;
|
|
@@ -6835,7 +6796,7 @@ var PieDonutChart = React6.memo(
|
|
|
6835
6796
|
el.style.strokeDashoffset = "0";
|
|
6836
6797
|
});
|
|
6837
6798
|
}, [animate, maskCircumference]);
|
|
6838
|
-
const sliceData =
|
|
6799
|
+
const sliceData = React7.useMemo(() => {
|
|
6839
6800
|
let angle0 = -Math.PI / 2;
|
|
6840
6801
|
let cumulativeAngle = 0;
|
|
6841
6802
|
return values.map((v, i) => {
|
|
@@ -6870,7 +6831,7 @@ var PieDonutChart = React6.memo(
|
|
|
6870
6831
|
}, [values, total, cx, cy, r2, innerR, labels]);
|
|
6871
6832
|
const maskId = `pie-mask-${isDoughnut ? "d" : "p"}`;
|
|
6872
6833
|
return /* @__PURE__ */ jsxs197("svg", { viewBox: `0 0 ${size} ${size}`, className: "chart-svg chart-pie", children: [
|
|
6873
|
-
animate && /* @__PURE__ */
|
|
6834
|
+
animate && /* @__PURE__ */ jsx308("defs", { children: /* @__PURE__ */ jsx308("mask", { id: maskId, children: /* @__PURE__ */ jsx308(
|
|
6874
6835
|
"circle",
|
|
6875
6836
|
{
|
|
6876
6837
|
ref: maskRef,
|
|
@@ -6883,7 +6844,7 @@ var PieDonutChart = React6.memo(
|
|
|
6883
6844
|
transform: `rotate(-90 ${cx} ${cy})`
|
|
6884
6845
|
}
|
|
6885
6846
|
) }) }),
|
|
6886
|
-
/* @__PURE__ */
|
|
6847
|
+
/* @__PURE__ */ jsx308("g", { mask: animate ? `url(#${maskId})` : void 0, children: sliceData.map((s, i) => /* @__PURE__ */ jsx308("g", { children: /* @__PURE__ */ jsx308(
|
|
6887
6848
|
"path",
|
|
6888
6849
|
{
|
|
6889
6850
|
d: s.d,
|
|
@@ -6894,7 +6855,7 @@ var PieDonutChart = React6.memo(
|
|
|
6894
6855
|
onMouseLeave: onLeave
|
|
6895
6856
|
}
|
|
6896
6857
|
) }, i)) }),
|
|
6897
|
-
sliceData.map((s, i) => s.angle > 0.2 && /* @__PURE__ */
|
|
6858
|
+
sliceData.map((s, i) => s.angle > 0.2 && /* @__PURE__ */ jsx308(
|
|
6898
6859
|
"text",
|
|
6899
6860
|
{
|
|
6900
6861
|
x: s.lx,
|
|
@@ -6912,9 +6873,9 @@ var PieDonutChart = React6.memo(
|
|
|
6912
6873
|
);
|
|
6913
6874
|
PieDonutChart.displayName = "PieDonutChart";
|
|
6914
6875
|
var ChartTooltipPortal = ({ clientX, clientY, visible, children }) => {
|
|
6915
|
-
const ref =
|
|
6916
|
-
const [pos, setPos] =
|
|
6917
|
-
|
|
6876
|
+
const ref = React7.useRef(null);
|
|
6877
|
+
const [pos, setPos] = React7.useState({ left: 0, top: 0 });
|
|
6878
|
+
React7.useLayoutEffect(() => {
|
|
6918
6879
|
const el = ref.current;
|
|
6919
6880
|
if (!el) return;
|
|
6920
6881
|
const w = el.offsetWidth;
|
|
@@ -6927,7 +6888,7 @@ var ChartTooltipPortal = ({ clientX, clientY, visible, children }) => {
|
|
|
6927
6888
|
if (left < 8) left = 8;
|
|
6928
6889
|
setPos({ left, top });
|
|
6929
6890
|
}, [clientX, clientY]);
|
|
6930
|
-
return /* @__PURE__ */
|
|
6891
|
+
return /* @__PURE__ */ jsx308(
|
|
6931
6892
|
"div",
|
|
6932
6893
|
{
|
|
6933
6894
|
ref,
|
|
@@ -6944,13 +6905,13 @@ var ChartLegend = ({ data, labels, type }) => {
|
|
|
6944
6905
|
const total = values.reduce((a, b) => a + b, 0) || 1;
|
|
6945
6906
|
const firstKey = entries[0]?.[0] ?? "";
|
|
6946
6907
|
const colorOffset = hashString(firstKey);
|
|
6947
|
-
return /* @__PURE__ */
|
|
6908
|
+
return /* @__PURE__ */ jsx308("div", { className: "chart-legend", children: values.map((v, i) => {
|
|
6948
6909
|
const pct = Math.round(v / total * 100);
|
|
6949
6910
|
const color = PIE_COLORS[(i + colorOffset) % PIE_COLORS.length];
|
|
6950
6911
|
return /* @__PURE__ */ jsxs197("div", { className: "chart-legend-item", children: [
|
|
6951
|
-
/* @__PURE__ */
|
|
6912
|
+
/* @__PURE__ */ jsx308("span", { className: "chart-legend-dot", style: { backgroundColor: color } }),
|
|
6952
6913
|
/* @__PURE__ */ jsxs197("div", { className: "chart-legend-text", children: [
|
|
6953
|
-
/* @__PURE__ */
|
|
6914
|
+
/* @__PURE__ */ jsx308("span", { className: "chart-legend-label", children: labels[i] || `${i + 1}` }),
|
|
6954
6915
|
/* @__PURE__ */ jsxs197("span", { className: "chart-legend-value", children: [
|
|
6955
6916
|
v.toLocaleString(),
|
|
6956
6917
|
"(",
|
|
@@ -6961,37 +6922,37 @@ var ChartLegend = ({ data, labels, type }) => {
|
|
|
6961
6922
|
] }, i);
|
|
6962
6923
|
}) });
|
|
6963
6924
|
}
|
|
6964
|
-
return /* @__PURE__ */
|
|
6925
|
+
return /* @__PURE__ */ jsx308("div", { className: "chart-legend", children: entries.map(([key], di) => {
|
|
6965
6926
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
6966
6927
|
const color = palette[2];
|
|
6967
6928
|
const values = entries[di][1];
|
|
6968
6929
|
const sum = values.reduce((a, b) => a + b, 0);
|
|
6969
6930
|
return /* @__PURE__ */ jsxs197("div", { className: "chart-legend-item", children: [
|
|
6970
|
-
/* @__PURE__ */
|
|
6931
|
+
/* @__PURE__ */ jsx308("span", { className: "chart-legend-dot", style: { backgroundColor: color } }),
|
|
6971
6932
|
/* @__PURE__ */ jsxs197("div", { className: "chart-legend-text", children: [
|
|
6972
|
-
/* @__PURE__ */
|
|
6973
|
-
/* @__PURE__ */
|
|
6933
|
+
/* @__PURE__ */ jsx308("span", { className: "chart-legend-label", children: key }),
|
|
6934
|
+
/* @__PURE__ */ jsx308("span", { className: "chart-legend-value", children: sum.toLocaleString() })
|
|
6974
6935
|
] })
|
|
6975
6936
|
] }, di);
|
|
6976
6937
|
}) });
|
|
6977
6938
|
};
|
|
6978
|
-
var Chart =
|
|
6939
|
+
var Chart = React7.memo((props) => {
|
|
6979
6940
|
const { type, data, labels, tooltip: showTooltip = true } = props;
|
|
6980
6941
|
const { tooltip, show, hide, move, containerRef } = useChartTooltip(showTooltip);
|
|
6981
6942
|
const { width, height } = useChartSize(containerRef);
|
|
6982
|
-
const stableData =
|
|
6983
|
-
const stableLabels =
|
|
6984
|
-
const dataKey =
|
|
6943
|
+
const stableData = React7.useMemo(() => data, [JSON.stringify(data)]);
|
|
6944
|
+
const stableLabels = React7.useMemo(() => labels, [JSON.stringify(labels)]);
|
|
6945
|
+
const dataKey = React7.useMemo(() => JSON.stringify(labels), [labels]);
|
|
6985
6946
|
const animate = useChartAnimation(containerRef, dataKey);
|
|
6986
6947
|
const ready = width > 0 && height > 0;
|
|
6987
6948
|
return /* @__PURE__ */ jsxs197("div", { className: "lib-xplat-chart", ref: containerRef, children: [
|
|
6988
|
-
ready && type === "line" && /* @__PURE__ */
|
|
6989
|
-
ready && type === "curve" && /* @__PURE__ */
|
|
6990
|
-
ready && type === "bar" && /* @__PURE__ */
|
|
6991
|
-
ready && type === "pie" && /* @__PURE__ */
|
|
6992
|
-
ready && type === "doughnut" && /* @__PURE__ */
|
|
6993
|
-
ready && (type === "bar" || type === "pie" || type === "doughnut") && /* @__PURE__ */
|
|
6994
|
-
tooltip.content && /* @__PURE__ */
|
|
6949
|
+
ready && type === "line" && /* @__PURE__ */ jsx308(LineChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
|
|
6950
|
+
ready && type === "curve" && /* @__PURE__ */ jsx308(CurveChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
|
|
6951
|
+
ready && type === "bar" && /* @__PURE__ */ jsx308(BarChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
|
|
6952
|
+
ready && type === "pie" && /* @__PURE__ */ jsx308(PieDonutChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
|
|
6953
|
+
ready && type === "doughnut" && /* @__PURE__ */ jsx308(PieDonutChart, { data: stableData, labels: stableLabels, width, height, animate, isDoughnut: true, onHover: show, onMove: move, onLeave: hide }),
|
|
6954
|
+
ready && (type === "bar" || type === "pie" || type === "doughnut") && /* @__PURE__ */ jsx308(ChartLegend, { data: stableData, labels: stableLabels, type }),
|
|
6955
|
+
tooltip.content && /* @__PURE__ */ jsx308(Portal_default, { children: /* @__PURE__ */ jsx308(ChartTooltipPortal, { clientX: tooltip.clientX, clientY: tooltip.clientY, visible: tooltip.visible, children: tooltip.content }) })
|
|
6995
6956
|
] });
|
|
6996
6957
|
});
|
|
6997
6958
|
Chart.displayName = "Chart";
|
|
@@ -7017,7 +6978,7 @@ import { primitive, semantic } from "@x-plat/tokens-core";
|
|
|
7017
6978
|
import { cssVar } from "@x-plat/tokens-core";
|
|
7018
6979
|
|
|
7019
6980
|
// src/components/CheckBox/CheckBox.tsx
|
|
7020
|
-
import { jsx as
|
|
6981
|
+
import { jsx as jsx309, jsxs as jsxs198 } from "react/jsx-runtime";
|
|
7021
6982
|
var CheckBox = (props) => {
|
|
7022
6983
|
const {
|
|
7023
6984
|
checked,
|
|
@@ -7036,7 +6997,7 @@ var CheckBox = (props) => {
|
|
|
7036
6997
|
const disabledClasses = "disabled";
|
|
7037
6998
|
const boxClasses = disabled ? disabledClasses : checked ? checkedClasses : uncheckedClasses;
|
|
7038
6999
|
return /* @__PURE__ */ jsxs198("label", { className: clsx_default("lib-xplat-checkbox", size, type), children: [
|
|
7039
|
-
/* @__PURE__ */
|
|
7000
|
+
/* @__PURE__ */ jsx309(
|
|
7040
7001
|
"input",
|
|
7041
7002
|
{
|
|
7042
7003
|
type: "checkbox",
|
|
@@ -7046,22 +7007,22 @@ var CheckBox = (props) => {
|
|
|
7046
7007
|
...rest
|
|
7047
7008
|
}
|
|
7048
7009
|
),
|
|
7049
|
-
/* @__PURE__ */
|
|
7050
|
-
label && /* @__PURE__ */
|
|
7010
|
+
/* @__PURE__ */ jsx309("span", { className: clsx_default("checkbox", boxClasses), children: /* @__PURE__ */ jsx309("span", { className: clsx_default("check-icon", { visible: checked }), children: /* @__PURE__ */ jsx309(CheckIcon_default, {}) }) }),
|
|
7011
|
+
label && /* @__PURE__ */ jsx309("span", { className: "label", children: label })
|
|
7051
7012
|
] });
|
|
7052
7013
|
};
|
|
7053
7014
|
CheckBox.displayName = "CheckBox";
|
|
7054
7015
|
var CheckBox_default = CheckBox;
|
|
7055
7016
|
|
|
7056
7017
|
// src/components/Chip/Chip.tsx
|
|
7057
|
-
import { jsx as
|
|
7018
|
+
import { jsx as jsx310 } from "react/jsx-runtime";
|
|
7058
7019
|
var Chip = (props) => {
|
|
7059
7020
|
const {
|
|
7060
7021
|
children,
|
|
7061
7022
|
type = "primary",
|
|
7062
7023
|
size = "md"
|
|
7063
7024
|
} = props;
|
|
7064
|
-
return /* @__PURE__ */
|
|
7025
|
+
return /* @__PURE__ */ jsx310("div", { className: clsx_default("lib-xplat-chip", type, size), children });
|
|
7065
7026
|
};
|
|
7066
7027
|
Chip.displayName = "Chip";
|
|
7067
7028
|
var Chip_default = Chip;
|
|
@@ -7070,20 +7031,20 @@ var Chip_default = Chip;
|
|
|
7070
7031
|
import React12 from "react";
|
|
7071
7032
|
|
|
7072
7033
|
// src/components/Input/Input.tsx
|
|
7073
|
-
import
|
|
7034
|
+
import React8 from "react";
|
|
7074
7035
|
|
|
7075
7036
|
// src/components/Input/InputValidations.tsx
|
|
7076
|
-
import { jsx as
|
|
7037
|
+
import { jsx as jsx311, jsxs as jsxs199 } from "react/jsx-runtime";
|
|
7077
7038
|
var InputValidations = (props) => {
|
|
7078
7039
|
const { message, status = "default" } = props;
|
|
7079
7040
|
return /* @__PURE__ */ jsxs199("div", { className: clsx_default("lib-xplat-input-validation", status), children: [
|
|
7080
7041
|
/* @__PURE__ */ jsxs199("div", { className: "icon", children: [
|
|
7081
|
-
status === "default" && /* @__PURE__ */
|
|
7082
|
-
status === "success" && /* @__PURE__ */
|
|
7083
|
-
status === "warning" && /* @__PURE__ */
|
|
7084
|
-
status === "error" && /* @__PURE__ */
|
|
7042
|
+
status === "default" && /* @__PURE__ */ jsx311(InfoIcon_default, {}),
|
|
7043
|
+
status === "success" && /* @__PURE__ */ jsx311(SuccessIcon_default, {}),
|
|
7044
|
+
status === "warning" && /* @__PURE__ */ jsx311(InfoIcon_default, {}),
|
|
7045
|
+
status === "error" && /* @__PURE__ */ jsx311(ErrorIcon_default, {})
|
|
7085
7046
|
] }),
|
|
7086
|
-
/* @__PURE__ */
|
|
7047
|
+
/* @__PURE__ */ jsx311("div", { className: "message", children: message })
|
|
7087
7048
|
] });
|
|
7088
7049
|
};
|
|
7089
7050
|
InputValidations.displayName = "InputValidations";
|
|
@@ -7124,7 +7085,7 @@ var handleTelBackspace = (prevValue, currValue) => {
|
|
|
7124
7085
|
};
|
|
7125
7086
|
|
|
7126
7087
|
// src/components/Input/Input.tsx
|
|
7127
|
-
import { jsx as
|
|
7088
|
+
import { jsx as jsx312, jsxs as jsxs200 } from "react/jsx-runtime";
|
|
7128
7089
|
import { createElement } from "react";
|
|
7129
7090
|
var formatValue = (type, value) => {
|
|
7130
7091
|
if (value === null || value === void 0) return "";
|
|
@@ -7173,7 +7134,7 @@ var parseValue = (type, value) => {
|
|
|
7173
7134
|
return value;
|
|
7174
7135
|
}
|
|
7175
7136
|
};
|
|
7176
|
-
var Input =
|
|
7137
|
+
var Input = React8.forwardRef((props, ref) => {
|
|
7177
7138
|
const {
|
|
7178
7139
|
value,
|
|
7179
7140
|
onChange,
|
|
@@ -7205,7 +7166,7 @@ var Input = React7.forwardRef((props, ref) => {
|
|
|
7205
7166
|
{
|
|
7206
7167
|
className: clsx_default("lib-xplat-input", size, disabled ? "disabled" : void 0),
|
|
7207
7168
|
children: [
|
|
7208
|
-
/* @__PURE__ */
|
|
7169
|
+
/* @__PURE__ */ jsx312(
|
|
7209
7170
|
"input",
|
|
7210
7171
|
{
|
|
7211
7172
|
...inputProps,
|
|
@@ -7216,11 +7177,11 @@ var Input = React7.forwardRef((props, ref) => {
|
|
|
7216
7177
|
onChange: handleChange
|
|
7217
7178
|
}
|
|
7218
7179
|
),
|
|
7219
|
-
suffix && /* @__PURE__ */
|
|
7180
|
+
suffix && /* @__PURE__ */ jsx312("div", { className: "suffix", children: suffix })
|
|
7220
7181
|
]
|
|
7221
7182
|
}
|
|
7222
7183
|
),
|
|
7223
|
-
validations && /* @__PURE__ */
|
|
7184
|
+
validations && /* @__PURE__ */ jsx312("div", { className: "lib-xplat-input-validation-wrap", children: validations?.map((validation, idx) => /* @__PURE__ */ createElement(
|
|
7224
7185
|
InputValidations_default,
|
|
7225
7186
|
{
|
|
7226
7187
|
...validation,
|
|
@@ -7233,20 +7194,20 @@ Input.displayName = "Input";
|
|
|
7233
7194
|
var Input_default = Input;
|
|
7234
7195
|
|
|
7235
7196
|
// src/components/Input/PasswordInput/PasswordInput.tsx
|
|
7236
|
-
import
|
|
7237
|
-
import { jsx as
|
|
7238
|
-
var PasswordInput =
|
|
7197
|
+
import React9 from "react";
|
|
7198
|
+
import { jsx as jsx313 } from "react/jsx-runtime";
|
|
7199
|
+
var PasswordInput = React9.forwardRef(
|
|
7239
7200
|
(props, ref) => {
|
|
7240
7201
|
const { reg: _reg, ...inputProps } = props;
|
|
7241
|
-
const [isView, setIsView] =
|
|
7202
|
+
const [isView, setIsView] = React9.useState(false);
|
|
7242
7203
|
const handleChangeView = () => {
|
|
7243
7204
|
setIsView((prev) => !prev);
|
|
7244
7205
|
};
|
|
7245
|
-
return /* @__PURE__ */
|
|
7206
|
+
return /* @__PURE__ */ jsx313(
|
|
7246
7207
|
Input_default,
|
|
7247
7208
|
{
|
|
7248
7209
|
...inputProps,
|
|
7249
|
-
suffix: /* @__PURE__ */
|
|
7210
|
+
suffix: /* @__PURE__ */ jsx313("div", { className: "wrapper pointer", onClick: handleChangeView, children: isView ? /* @__PURE__ */ jsx313(OpenEyeIcon_default, {}) : /* @__PURE__ */ jsx313(CloseEyeIcon_default, {}) }),
|
|
7250
7211
|
type: isView ? "text" : "password",
|
|
7251
7212
|
ref
|
|
7252
7213
|
}
|
|
@@ -7259,23 +7220,6 @@ var PasswordInput_default = PasswordInput;
|
|
|
7259
7220
|
// src/components/Modal/Modal.tsx
|
|
7260
7221
|
import React10 from "react";
|
|
7261
7222
|
import { createPortal } from "react-dom";
|
|
7262
|
-
|
|
7263
|
-
// src/tokens/hooks/Portal.tsx
|
|
7264
|
-
import React9 from "react";
|
|
7265
|
-
import ReactDOM from "react-dom";
|
|
7266
|
-
import { jsx as jsx313 } from "react/jsx-runtime";
|
|
7267
|
-
var PortalContainerContext = React9.createContext(null);
|
|
7268
|
-
var PortalProvider = ({ container, children }) => /* @__PURE__ */ jsx313(PortalContainerContext.Provider, { value: container, children });
|
|
7269
|
-
var Portal = ({ children }) => {
|
|
7270
|
-
const contextContainer = React9.useContext(PortalContainerContext);
|
|
7271
|
-
if (typeof document === "undefined") return null;
|
|
7272
|
-
const container = contextContainer ?? document.body;
|
|
7273
|
-
return ReactDOM.createPortal(children, container);
|
|
7274
|
-
};
|
|
7275
|
-
Portal.displayName = "Portal";
|
|
7276
|
-
var Portal_default = Portal;
|
|
7277
|
-
|
|
7278
|
-
// src/components/Modal/Modal.tsx
|
|
7279
7223
|
import { jsx as jsx314 } from "react/jsx-runtime";
|
|
7280
7224
|
var ANIMATION_DURATION_MS = 200;
|
|
7281
7225
|
var Modal = (props) => {
|