@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/components/index.js
CHANGED
|
@@ -2139,25 +2139,8 @@ var CardTab = Object.assign(CardTabRoot, {
|
|
|
2139
2139
|
var CardTab_default = CardTab;
|
|
2140
2140
|
|
|
2141
2141
|
// src/components/Chart/Chart.tsx
|
|
2142
|
-
import React7 from "react";
|
|
2143
|
-
|
|
2144
|
-
// src/tokens/hooks/Portal.tsx
|
|
2145
2142
|
import React6 from "react";
|
|
2146
|
-
import
|
|
2147
|
-
import { jsx as jsx307 } from "react/jsx-runtime";
|
|
2148
|
-
var PortalContainerContext = React6.createContext(null);
|
|
2149
|
-
var PortalProvider = ({ container, children }) => /* @__PURE__ */ jsx307(PortalContainerContext.Provider, { value: container, children });
|
|
2150
|
-
var Portal = ({ children }) => {
|
|
2151
|
-
const contextContainer = React6.useContext(PortalContainerContext);
|
|
2152
|
-
if (typeof document === "undefined") return null;
|
|
2153
|
-
const container = contextContainer ?? document.body;
|
|
2154
|
-
return ReactDOM.createPortal(children, container);
|
|
2155
|
-
};
|
|
2156
|
-
Portal.displayName = "Portal";
|
|
2157
|
-
var Portal_default = Portal;
|
|
2158
|
-
|
|
2159
|
-
// src/components/Chart/Chart.tsx
|
|
2160
|
-
import { Fragment as Fragment2, jsx as jsx308, jsxs as jsxs197 } from "react/jsx-runtime";
|
|
2143
|
+
import { Fragment as Fragment2, jsx as jsx307, jsxs as jsxs197 } from "react/jsx-runtime";
|
|
2161
2144
|
var CATEGORICAL_COUNT2 = 8;
|
|
2162
2145
|
var LINE_BAR_PALETTES = Array.from({ length: CATEGORICAL_COUNT2 }, (_, i) => {
|
|
2163
2146
|
const n = i + 1;
|
|
@@ -2203,11 +2186,11 @@ var toSmoothPath = (points) => {
|
|
|
2203
2186
|
};
|
|
2204
2187
|
var RESIZE_SETTLE_MS = 150;
|
|
2205
2188
|
var useChartSize = (ref) => {
|
|
2206
|
-
const [size, setSize] =
|
|
2207
|
-
const settleTimer =
|
|
2208
|
-
const committedSize =
|
|
2209
|
-
const initialRef =
|
|
2210
|
-
|
|
2189
|
+
const [size, setSize] = React6.useState({ width: 0, height: 0 });
|
|
2190
|
+
const settleTimer = React6.useRef(0);
|
|
2191
|
+
const committedSize = React6.useRef({ width: 0, height: 0 });
|
|
2192
|
+
const initialRef = React6.useRef(true);
|
|
2193
|
+
React6.useEffect(() => {
|
|
2211
2194
|
const el = ref.current;
|
|
2212
2195
|
if (!el) return;
|
|
2213
2196
|
const observer = new ResizeObserver((entries) => {
|
|
@@ -2249,10 +2232,10 @@ var useChartSize = (ref) => {
|
|
|
2249
2232
|
};
|
|
2250
2233
|
var prefersReducedMotion = () => typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
2251
2234
|
var useChartAnimation = (containerRef, dataKey) => {
|
|
2252
|
-
const [animate, setAnimate] =
|
|
2253
|
-
const prevDataKey =
|
|
2254
|
-
const hasAnimated =
|
|
2255
|
-
|
|
2235
|
+
const [animate, setAnimate] = React6.useState(false);
|
|
2236
|
+
const prevDataKey = React6.useRef(dataKey);
|
|
2237
|
+
const hasAnimated = React6.useRef(false);
|
|
2238
|
+
React6.useEffect(() => {
|
|
2256
2239
|
if (prefersReducedMotion()) return;
|
|
2257
2240
|
const el = containerRef.current;
|
|
2258
2241
|
if (!el) return;
|
|
@@ -2268,7 +2251,7 @@ var useChartAnimation = (containerRef, dataKey) => {
|
|
|
2268
2251
|
observer.observe(el);
|
|
2269
2252
|
return () => observer.disconnect();
|
|
2270
2253
|
}, [containerRef]);
|
|
2271
|
-
|
|
2254
|
+
React6.useEffect(() => {
|
|
2272
2255
|
if (dataKey !== prevDataKey.current) {
|
|
2273
2256
|
prevDataKey.current = dataKey;
|
|
2274
2257
|
if (prefersReducedMotion()) return;
|
|
@@ -2282,39 +2265,47 @@ var useChartAnimation = (containerRef, dataKey) => {
|
|
|
2282
2265
|
};
|
|
2283
2266
|
var TOOLTIP_OFFSET = 12;
|
|
2284
2267
|
var useChartTooltip = (enabled) => {
|
|
2285
|
-
const [tooltip, setTooltip] =
|
|
2268
|
+
const [tooltip, setTooltip] = React6.useState({
|
|
2286
2269
|
visible: false,
|
|
2287
|
-
|
|
2288
|
-
|
|
2270
|
+
x: 0,
|
|
2271
|
+
y: 0,
|
|
2289
2272
|
content: ""
|
|
2290
2273
|
});
|
|
2291
|
-
const containerRef =
|
|
2292
|
-
const rafRef =
|
|
2293
|
-
const move =
|
|
2274
|
+
const containerRef = React6.useRef(null);
|
|
2275
|
+
const rafRef = React6.useRef(0);
|
|
2276
|
+
const move = React6.useCallback((e) => {
|
|
2294
2277
|
if (!enabled) return;
|
|
2295
2278
|
const cx = e.clientX;
|
|
2296
2279
|
const cy = e.clientY;
|
|
2297
2280
|
cancelAnimationFrame(rafRef.current);
|
|
2298
2281
|
rafRef.current = requestAnimationFrame(() => {
|
|
2299
|
-
|
|
2282
|
+
const rect = containerRef.current?.getBoundingClientRect();
|
|
2283
|
+
if (!rect) return;
|
|
2284
|
+
setTooltip((prev) => ({ ...prev, x: cx - rect.left, y: cy - rect.top }));
|
|
2300
2285
|
});
|
|
2301
2286
|
}, [enabled]);
|
|
2302
|
-
const show =
|
|
2287
|
+
const show = React6.useCallback((e, content) => {
|
|
2303
2288
|
if (!enabled) return;
|
|
2304
|
-
|
|
2289
|
+
const rect = containerRef.current?.getBoundingClientRect();
|
|
2290
|
+
if (!rect) return;
|
|
2291
|
+
setTooltip({ visible: true, x: e.clientX - rect.left, y: e.clientY - rect.top, content });
|
|
2305
2292
|
}, [enabled]);
|
|
2306
|
-
const
|
|
2293
|
+
const showAt = React6.useCallback((x, y, content) => {
|
|
2294
|
+
if (!enabled) return;
|
|
2295
|
+
setTooltip({ visible: true, x, y, content });
|
|
2296
|
+
}, [enabled]);
|
|
2297
|
+
const hide = React6.useCallback(() => {
|
|
2307
2298
|
cancelAnimationFrame(rafRef.current);
|
|
2308
2299
|
setTooltip((prev) => ({ ...prev, visible: false }));
|
|
2309
2300
|
}, []);
|
|
2310
|
-
return { tooltip, show, hide, move, containerRef };
|
|
2301
|
+
return { tooltip, show, showAt, hide, move, containerRef };
|
|
2311
2302
|
};
|
|
2312
|
-
var GridLines =
|
|
2303
|
+
var GridLines = React6.memo(({ width, height, chartH, maxVal }) => /* @__PURE__ */ jsx307(Fragment2, { children: [0, 0.25, 0.5, 0.75, 1].map((ratio) => {
|
|
2313
2304
|
const y = PADDING.top + (1 - ratio) * chartH;
|
|
2314
2305
|
const val = Math.round(maxVal * ratio);
|
|
2315
2306
|
return /* @__PURE__ */ jsxs197("g", { children: [
|
|
2316
|
-
/* @__PURE__ */
|
|
2317
|
-
/* @__PURE__ */
|
|
2307
|
+
/* @__PURE__ */ jsx307("line", { x1: PADDING.left, y1: y, x2: width - PADDING.right, y2: y, className: "chart-grid" }),
|
|
2308
|
+
/* @__PURE__ */ jsx307("text", { x: PADDING.left - 8, y: y + 4, className: "chart-axis-label", textAnchor: "end", children: val })
|
|
2318
2309
|
] }, ratio);
|
|
2319
2310
|
}) }));
|
|
2320
2311
|
GridLines.displayName = "GridLines";
|
|
@@ -2324,18 +2315,18 @@ var getLabelStep = (count, chartW) => {
|
|
|
2324
2315
|
if (count <= maxLabels) return 1;
|
|
2325
2316
|
return Math.ceil(count / maxLabels);
|
|
2326
2317
|
};
|
|
2327
|
-
var AxisLabels =
|
|
2318
|
+
var AxisLabels = React6.memo(({ labels, count, chartW, height }) => {
|
|
2328
2319
|
const step = getLabelStep(count, chartW);
|
|
2329
|
-
return /* @__PURE__ */
|
|
2320
|
+
return /* @__PURE__ */ jsx307(Fragment2, { children: labels.map((label, i) => {
|
|
2330
2321
|
if (i % step !== 0) return null;
|
|
2331
2322
|
const x = PADDING.left + i / (count - 1 || 1) * chartW;
|
|
2332
|
-
return /* @__PURE__ */
|
|
2323
|
+
return /* @__PURE__ */ jsx307("text", { x, y: height - 8, className: "chart-axis-label", textAnchor: "middle", children: label }, i);
|
|
2333
2324
|
}) });
|
|
2334
2325
|
});
|
|
2335
2326
|
AxisLabels.displayName = "AxisLabels";
|
|
2336
2327
|
var useCrosshair = (seriesPoints, entries, labels, chartH) => {
|
|
2337
|
-
const [activeIndex, setActiveIndex] =
|
|
2338
|
-
const handleMouseMove =
|
|
2328
|
+
const [activeIndex, setActiveIndex] = React6.useState(null);
|
|
2329
|
+
const handleMouseMove = React6.useCallback((e) => {
|
|
2339
2330
|
const svg = e.currentTarget;
|
|
2340
2331
|
const rect = svg.getBoundingClientRect();
|
|
2341
2332
|
const mx = (e.clientX - rect.left) / rect.width * svg.viewBox.baseVal.width;
|
|
@@ -2354,17 +2345,17 @@ var useCrosshair = (seriesPoints, entries, labels, chartH) => {
|
|
|
2354
2345
|
}
|
|
2355
2346
|
setActiveIndex(minDist <= threshold ? closest : null);
|
|
2356
2347
|
}, [seriesPoints]);
|
|
2357
|
-
const handleMouseLeave =
|
|
2348
|
+
const handleMouseLeave = React6.useCallback(() => {
|
|
2358
2349
|
setActiveIndex(null);
|
|
2359
2350
|
}, []);
|
|
2360
|
-
const tooltipContent =
|
|
2351
|
+
const tooltipContent = React6.useMemo(() => {
|
|
2361
2352
|
if (activeIndex === null) return "";
|
|
2362
2353
|
return entries.map(([key], di) => {
|
|
2363
2354
|
const p = seriesPoints[di]?.[activeIndex];
|
|
2364
2355
|
return p ? `${key}: ${p.v}` : "";
|
|
2365
2356
|
}).filter(Boolean).join(" / ");
|
|
2366
2357
|
}, [activeIndex, entries, seriesPoints]);
|
|
2367
|
-
const getTooltipAt =
|
|
2358
|
+
const getTooltipAt = React6.useCallback((idx) => {
|
|
2368
2359
|
return entries.map(([key], di) => {
|
|
2369
2360
|
const p = seriesPoints[di]?.[idx];
|
|
2370
2361
|
return p ? `${key}: ${p.v}` : "";
|
|
@@ -2372,16 +2363,16 @@ var useCrosshair = (seriesPoints, entries, labels, chartH) => {
|
|
|
2372
2363
|
}, [entries, seriesPoints]);
|
|
2373
2364
|
return { activeIndex, handleMouseMove, handleMouseLeave, tooltipContent, getTooltipAt };
|
|
2374
2365
|
};
|
|
2375
|
-
var LineChart =
|
|
2376
|
-
const entries =
|
|
2377
|
-
const maxVal =
|
|
2366
|
+
var LineChart = React6.memo(({ data, labels, width, height, animate, onHover, onShowAt, onMove, onLeave }) => {
|
|
2367
|
+
const entries = React6.useMemo(() => Object.entries(data), [data]);
|
|
2368
|
+
const maxVal = React6.useMemo(() => {
|
|
2378
2369
|
const allValues = entries.flatMap(([, v]) => v);
|
|
2379
2370
|
return Math.max(...allValues) * 1.2 || 1;
|
|
2380
2371
|
}, [entries]);
|
|
2381
2372
|
const count = labels.length;
|
|
2382
2373
|
const chartW = width - PADDING.left - PADDING.right;
|
|
2383
2374
|
const chartH = height - PADDING.top - PADDING.bottom;
|
|
2384
|
-
const seriesPoints =
|
|
2375
|
+
const seriesPoints = React6.useMemo(
|
|
2385
2376
|
() => entries.map(
|
|
2386
2377
|
([, values]) => values.map((v, i) => ({
|
|
2387
2378
|
x: PADDING.left + i / (count - 1 || 1) * chartW,
|
|
@@ -2391,9 +2382,9 @@ var LineChart = React7.memo(({ data, labels, width, height, animate, onHover, on
|
|
|
2391
2382
|
),
|
|
2392
2383
|
[entries, count, chartW, chartH, maxVal]
|
|
2393
2384
|
);
|
|
2394
|
-
const clipRef =
|
|
2385
|
+
const clipRef = React6.useRef(null);
|
|
2395
2386
|
const { activeIndex, handleMouseMove, handleMouseLeave, getTooltipAt } = useCrosshair(seriesPoints, entries, labels, chartH);
|
|
2396
|
-
|
|
2387
|
+
React6.useEffect(() => {
|
|
2397
2388
|
if (!animate || !clipRef.current) return;
|
|
2398
2389
|
clipRef.current.setAttribute("width", "0");
|
|
2399
2390
|
requestAnimationFrame(() => {
|
|
@@ -2412,23 +2403,9 @@ var LineChart = React7.memo(({ data, labels, width, height, animate, onHover, on
|
|
|
2412
2403
|
className: "chart-svg",
|
|
2413
2404
|
onMouseMove: (e) => {
|
|
2414
2405
|
handleMouseMove(e);
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
const points = seriesPoints[0];
|
|
2419
|
-
if (!points || points.length === 0) return;
|
|
2420
|
-
const step = points.length > 1 ? Math.abs(points[1].x - points[0].x) : 20;
|
|
2421
|
-
let closest = 0;
|
|
2422
|
-
let minDist = Math.abs(points[0].x - mx);
|
|
2423
|
-
for (let i = 1; i < points.length; i++) {
|
|
2424
|
-
const dist = Math.abs(points[i].x - mx);
|
|
2425
|
-
if (dist < minDist) {
|
|
2426
|
-
minDist = dist;
|
|
2427
|
-
closest = i;
|
|
2428
|
-
}
|
|
2429
|
-
}
|
|
2430
|
-
if (minDist <= step / 2) {
|
|
2431
|
-
onHover(e, `${labels[closest]} \u2014 ${getTooltipAt(closest)}`);
|
|
2406
|
+
if (activeIndex !== null && seriesPoints[0]?.[activeIndex]) {
|
|
2407
|
+
const p = seriesPoints[0][activeIndex];
|
|
2408
|
+
onShowAt(p.x, p.y, `${labels[activeIndex]} \u2014 ${getTooltipAt(activeIndex)}`);
|
|
2432
2409
|
} else {
|
|
2433
2410
|
onLeave();
|
|
2434
2411
|
}
|
|
@@ -2438,9 +2415,9 @@ var LineChart = React7.memo(({ data, labels, width, height, animate, onHover, on
|
|
|
2438
2415
|
onLeave();
|
|
2439
2416
|
},
|
|
2440
2417
|
children: [
|
|
2441
|
-
animate && /* @__PURE__ */
|
|
2442
|
-
/* @__PURE__ */
|
|
2443
|
-
/* @__PURE__ */
|
|
2418
|
+
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 }) }) }),
|
|
2419
|
+
/* @__PURE__ */ jsx307(GridLines, { width, height, chartH, maxVal }),
|
|
2420
|
+
/* @__PURE__ */ jsx307(AxisLabels, { labels, count, chartW, height }),
|
|
2444
2421
|
entries.map(([key], di) => {
|
|
2445
2422
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
2446
2423
|
const color = palette[2];
|
|
@@ -2450,15 +2427,15 @@ var LineChart = React7.memo(({ data, labels, width, height, animate, onHover, on
|
|
|
2450
2427
|
const polyPoints = points.map((p) => `${p.x},${p.y}`).join(" ");
|
|
2451
2428
|
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`;
|
|
2452
2429
|
return /* @__PURE__ */ jsxs197("g", { children: [
|
|
2453
|
-
/* @__PURE__ */
|
|
2454
|
-
/* @__PURE__ */
|
|
2455
|
-
/* @__PURE__ */
|
|
2430
|
+
/* @__PURE__ */ jsx307("defs", { children: /* @__PURE__ */ jsxs197("linearGradient", { id: gradientId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
2431
|
+
/* @__PURE__ */ jsx307("stop", { offset: "0%", stopColor: areaColor, stopOpacity: "0.2" }),
|
|
2432
|
+
/* @__PURE__ */ jsx307("stop", { offset: "100%", stopColor: areaColor, stopOpacity: "0" })
|
|
2456
2433
|
] }) }),
|
|
2457
2434
|
/* @__PURE__ */ jsxs197("g", { clipPath: animate ? `url(#${lineClipId})` : void 0, children: [
|
|
2458
|
-
/* @__PURE__ */
|
|
2459
|
-
/* @__PURE__ */
|
|
2435
|
+
/* @__PURE__ */ jsx307("path", { d: areaD, fill: `url(#${gradientId})` }),
|
|
2436
|
+
/* @__PURE__ */ jsx307("polyline", { points: polyPoints, fill: "none", stroke: color, strokeWidth: "2" })
|
|
2460
2437
|
] }),
|
|
2461
|
-
activeIndex !== null && points[activeIndex] && /* @__PURE__ */
|
|
2438
|
+
activeIndex !== null && points[activeIndex] && /* @__PURE__ */ jsx307(
|
|
2462
2439
|
"circle",
|
|
2463
2440
|
{
|
|
2464
2441
|
cx: points[activeIndex].x,
|
|
@@ -2470,7 +2447,7 @@ var LineChart = React7.memo(({ data, labels, width, height, animate, onHover, on
|
|
|
2470
2447
|
)
|
|
2471
2448
|
] }, di);
|
|
2472
2449
|
}),
|
|
2473
|
-
activeX !== null && /* @__PURE__ */
|
|
2450
|
+
activeX !== null && /* @__PURE__ */ jsx307(
|
|
2474
2451
|
"line",
|
|
2475
2452
|
{
|
|
2476
2453
|
x1: activeX,
|
|
@@ -2480,7 +2457,7 @@ var LineChart = React7.memo(({ data, labels, width, height, animate, onHover, on
|
|
|
2480
2457
|
className: "chart-crosshair"
|
|
2481
2458
|
}
|
|
2482
2459
|
),
|
|
2483
|
-
/* @__PURE__ */
|
|
2460
|
+
/* @__PURE__ */ jsx307(
|
|
2484
2461
|
"rect",
|
|
2485
2462
|
{
|
|
2486
2463
|
x: PADDING.left,
|
|
@@ -2496,16 +2473,16 @@ var LineChart = React7.memo(({ data, labels, width, height, animate, onHover, on
|
|
|
2496
2473
|
);
|
|
2497
2474
|
});
|
|
2498
2475
|
LineChart.displayName = "LineChart";
|
|
2499
|
-
var CurveChart =
|
|
2500
|
-
const entries =
|
|
2501
|
-
const maxVal =
|
|
2476
|
+
var CurveChart = React6.memo(({ data, labels, width, height, animate, onHover, onShowAt, onMove, onLeave }) => {
|
|
2477
|
+
const entries = React6.useMemo(() => Object.entries(data), [data]);
|
|
2478
|
+
const maxVal = React6.useMemo(() => {
|
|
2502
2479
|
const allValues = entries.flatMap(([, v]) => v);
|
|
2503
2480
|
return Math.max(...allValues) * 1.2 || 1;
|
|
2504
2481
|
}, [entries]);
|
|
2505
2482
|
const count = labels.length;
|
|
2506
2483
|
const chartW = width - PADDING.left - PADDING.right;
|
|
2507
2484
|
const chartH = height - PADDING.top - PADDING.bottom;
|
|
2508
|
-
const seriesPoints =
|
|
2485
|
+
const seriesPoints = React6.useMemo(
|
|
2509
2486
|
() => entries.map(
|
|
2510
2487
|
([, values]) => values.map((v, i) => ({
|
|
2511
2488
|
x: PADDING.left + i / (count - 1 || 1) * chartW,
|
|
@@ -2515,9 +2492,9 @@ var CurveChart = React7.memo(({ data, labels, width, height, animate, onHover, o
|
|
|
2515
2492
|
),
|
|
2516
2493
|
[entries, count, chartW, chartH, maxVal]
|
|
2517
2494
|
);
|
|
2518
|
-
const curveClipRef =
|
|
2495
|
+
const curveClipRef = React6.useRef(null);
|
|
2519
2496
|
const { activeIndex, handleMouseMove, handleMouseLeave, getTooltipAt } = useCrosshair(seriesPoints, entries, labels, chartH);
|
|
2520
|
-
|
|
2497
|
+
React6.useEffect(() => {
|
|
2521
2498
|
if (!animate || !curveClipRef.current) return;
|
|
2522
2499
|
curveClipRef.current.setAttribute("width", "0");
|
|
2523
2500
|
requestAnimationFrame(() => {
|
|
@@ -2536,23 +2513,9 @@ var CurveChart = React7.memo(({ data, labels, width, height, animate, onHover, o
|
|
|
2536
2513
|
className: "chart-svg",
|
|
2537
2514
|
onMouseMove: (e) => {
|
|
2538
2515
|
handleMouseMove(e);
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
const points = seriesPoints[0];
|
|
2543
|
-
if (!points || points.length === 0) return;
|
|
2544
|
-
const step = points.length > 1 ? Math.abs(points[1].x - points[0].x) : 20;
|
|
2545
|
-
let closest = 0;
|
|
2546
|
-
let minDist = Math.abs(points[0].x - mx);
|
|
2547
|
-
for (let i = 1; i < points.length; i++) {
|
|
2548
|
-
const dist = Math.abs(points[i].x - mx);
|
|
2549
|
-
if (dist < minDist) {
|
|
2550
|
-
minDist = dist;
|
|
2551
|
-
closest = i;
|
|
2552
|
-
}
|
|
2553
|
-
}
|
|
2554
|
-
if (minDist <= step / 2) {
|
|
2555
|
-
onHover(e, `${labels[closest]} \u2014 ${getTooltipAt(closest)}`);
|
|
2516
|
+
if (activeIndex !== null && seriesPoints[0]?.[activeIndex]) {
|
|
2517
|
+
const p = seriesPoints[0][activeIndex];
|
|
2518
|
+
onShowAt(p.x, p.y, `${labels[activeIndex]} \u2014 ${getTooltipAt(activeIndex)}`);
|
|
2556
2519
|
} else {
|
|
2557
2520
|
onLeave();
|
|
2558
2521
|
}
|
|
@@ -2562,9 +2525,9 @@ var CurveChart = React7.memo(({ data, labels, width, height, animate, onHover, o
|
|
|
2562
2525
|
onLeave();
|
|
2563
2526
|
},
|
|
2564
2527
|
children: [
|
|
2565
|
-
animate && /* @__PURE__ */
|
|
2566
|
-
/* @__PURE__ */
|
|
2567
|
-
/* @__PURE__ */
|
|
2528
|
+
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 }) }) }),
|
|
2529
|
+
/* @__PURE__ */ jsx307(GridLines, { width, height, chartH, maxVal }),
|
|
2530
|
+
/* @__PURE__ */ jsx307(AxisLabels, { labels, count, chartW, height }),
|
|
2568
2531
|
entries.map(([key], di) => {
|
|
2569
2532
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
2570
2533
|
const color = palette[2];
|
|
@@ -2574,15 +2537,15 @@ var CurveChart = React7.memo(({ data, labels, width, height, animate, onHover, o
|
|
|
2574
2537
|
const linePath = toSmoothPath(points);
|
|
2575
2538
|
const areaPath = linePath + ` L ${points[points.length - 1].x} ${PADDING.top + chartH} L ${points[0].x} ${PADDING.top + chartH} Z`;
|
|
2576
2539
|
return /* @__PURE__ */ jsxs197("g", { children: [
|
|
2577
|
-
/* @__PURE__ */
|
|
2578
|
-
/* @__PURE__ */
|
|
2579
|
-
/* @__PURE__ */
|
|
2540
|
+
/* @__PURE__ */ jsx307("defs", { children: /* @__PURE__ */ jsxs197("linearGradient", { id: gradientId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
2541
|
+
/* @__PURE__ */ jsx307("stop", { offset: "0%", stopColor: areaColor, stopOpacity: "0.4" }),
|
|
2542
|
+
/* @__PURE__ */ jsx307("stop", { offset: "100%", stopColor: areaColor, stopOpacity: "0.02" })
|
|
2580
2543
|
] }) }),
|
|
2581
2544
|
/* @__PURE__ */ jsxs197("g", { clipPath: animate ? `url(#${curveClipId})` : void 0, children: [
|
|
2582
|
-
/* @__PURE__ */
|
|
2583
|
-
/* @__PURE__ */
|
|
2545
|
+
/* @__PURE__ */ jsx307("path", { d: areaPath, fill: `url(#${gradientId})` }),
|
|
2546
|
+
/* @__PURE__ */ jsx307("path", { d: linePath, fill: "none", stroke: color, strokeWidth: "2" })
|
|
2584
2547
|
] }),
|
|
2585
|
-
activeIndex !== null && points[activeIndex] && /* @__PURE__ */
|
|
2548
|
+
activeIndex !== null && points[activeIndex] && /* @__PURE__ */ jsx307(
|
|
2586
2549
|
"circle",
|
|
2587
2550
|
{
|
|
2588
2551
|
cx: points[activeIndex].x,
|
|
@@ -2594,7 +2557,7 @@ var CurveChart = React7.memo(({ data, labels, width, height, animate, onHover, o
|
|
|
2594
2557
|
)
|
|
2595
2558
|
] }, di);
|
|
2596
2559
|
}),
|
|
2597
|
-
activeX !== null && /* @__PURE__ */
|
|
2560
|
+
activeX !== null && /* @__PURE__ */ jsx307(
|
|
2598
2561
|
"line",
|
|
2599
2562
|
{
|
|
2600
2563
|
x1: activeX,
|
|
@@ -2604,7 +2567,7 @@ var CurveChart = React7.memo(({ data, labels, width, height, animate, onHover, o
|
|
|
2604
2567
|
className: "chart-crosshair"
|
|
2605
2568
|
}
|
|
2606
2569
|
),
|
|
2607
|
-
/* @__PURE__ */
|
|
2570
|
+
/* @__PURE__ */ jsx307(
|
|
2608
2571
|
"rect",
|
|
2609
2572
|
{
|
|
2610
2573
|
x: PADDING.left,
|
|
@@ -2620,9 +2583,9 @@ var CurveChart = React7.memo(({ data, labels, width, height, animate, onHover, o
|
|
|
2620
2583
|
);
|
|
2621
2584
|
});
|
|
2622
2585
|
CurveChart.displayName = "CurveChart";
|
|
2623
|
-
var BarChart =
|
|
2624
|
-
const entries =
|
|
2625
|
-
const maxVal =
|
|
2586
|
+
var BarChart = React6.memo(({ data, labels, width, height, animate, onHover, onShowAt, onMove, onLeave }) => {
|
|
2587
|
+
const entries = React6.useMemo(() => Object.entries(data), [data]);
|
|
2588
|
+
const maxVal = React6.useMemo(() => {
|
|
2626
2589
|
const allValues = entries.flatMap(([, v]) => v);
|
|
2627
2590
|
return Math.max(...allValues) * 1.2 || 1;
|
|
2628
2591
|
}, [entries]);
|
|
@@ -2634,7 +2597,7 @@ var BarChart = React7.memo(({ data, labels, width, height, animate, onHover, onM
|
|
|
2634
2597
|
const barGap = groupCount > 1 ? 2 : 0;
|
|
2635
2598
|
const barW = Math.max(1, Math.min(32, (groupW * 0.7 - barGap * (groupCount - 1)) / groupCount));
|
|
2636
2599
|
const baseline = PADDING.top + chartH;
|
|
2637
|
-
const bars =
|
|
2600
|
+
const bars = React6.useMemo(
|
|
2638
2601
|
() => entries.map(
|
|
2639
2602
|
([, values], di) => values.map((v, i) => {
|
|
2640
2603
|
const totalBarsW = barW * groupCount + barGap * (groupCount - 1);
|
|
@@ -2648,10 +2611,10 @@ var BarChart = React7.memo(({ data, labels, width, height, animate, onHover, onM
|
|
|
2648
2611
|
);
|
|
2649
2612
|
const barLabelStep = getLabelStep(count, chartW);
|
|
2650
2613
|
return /* @__PURE__ */ jsxs197("svg", { viewBox: `0 0 ${width} ${height}`, className: "chart-svg", children: [
|
|
2651
|
-
/* @__PURE__ */
|
|
2614
|
+
/* @__PURE__ */ jsx307(GridLines, { width, height, chartH, maxVal }),
|
|
2652
2615
|
labels.map((label, i) => {
|
|
2653
2616
|
if (i % barLabelStep !== 0) return null;
|
|
2654
|
-
return /* @__PURE__ */
|
|
2617
|
+
return /* @__PURE__ */ jsx307("text", { x: PADDING.left + groupW * i + groupW / 2, y: height - 8, className: "chart-axis-label", textAnchor: "middle", children: label }, i);
|
|
2655
2618
|
}),
|
|
2656
2619
|
entries.map(([key], di) => {
|
|
2657
2620
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
@@ -2660,7 +2623,7 @@ var BarChart = React7.memo(({ data, labels, width, height, animate, onHover, onM
|
|
|
2660
2623
|
const r2 = Math.min(4, b.w / 2);
|
|
2661
2624
|
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`;
|
|
2662
2625
|
const delay = 100 + i * 80;
|
|
2663
|
-
return /* @__PURE__ */
|
|
2626
|
+
return /* @__PURE__ */ jsx307(
|
|
2664
2627
|
"path",
|
|
2665
2628
|
{
|
|
2666
2629
|
d,
|
|
@@ -2670,8 +2633,7 @@ var BarChart = React7.memo(({ data, labels, width, height, animate, onHover, onM
|
|
|
2670
2633
|
transformOrigin: `${b.x + b.w / 2}px ${baseline}px`,
|
|
2671
2634
|
animationDelay: `${delay}ms`
|
|
2672
2635
|
} : void 0,
|
|
2673
|
-
onMouseEnter: (
|
|
2674
|
-
onMouseMove: onMove,
|
|
2636
|
+
onMouseEnter: () => onShowAt(b.x + b.w / 2, b.y, `${key}: ${labels[i]} \u2014 ${b.v}`),
|
|
2675
2637
|
onMouseLeave: onLeave
|
|
2676
2638
|
},
|
|
2677
2639
|
`${di}-${i}`
|
|
@@ -2681,11 +2643,11 @@ var BarChart = React7.memo(({ data, labels, width, height, animate, onHover, onM
|
|
|
2681
2643
|
] });
|
|
2682
2644
|
});
|
|
2683
2645
|
BarChart.displayName = "BarChart";
|
|
2684
|
-
var PieDonutChart =
|
|
2646
|
+
var PieDonutChart = React6.memo(
|
|
2685
2647
|
({ data, labels, width, height, animate, isDoughnut, onHover, onMove, onLeave }) => {
|
|
2686
|
-
const entries =
|
|
2687
|
-
const values =
|
|
2688
|
-
const total =
|
|
2648
|
+
const entries = React6.useMemo(() => Object.entries(data), [data]);
|
|
2649
|
+
const values = React6.useMemo(() => entries.flatMap(([, v]) => v), [entries]);
|
|
2650
|
+
const total = React6.useMemo(() => values.reduce((a, b) => a + b, 0) || 1, [values]);
|
|
2689
2651
|
const size = Math.min(width, height);
|
|
2690
2652
|
const cx = size / 2;
|
|
2691
2653
|
const cy = size / 2;
|
|
@@ -2693,10 +2655,10 @@ var PieDonutChart = React7.memo(
|
|
|
2693
2655
|
const innerR = isDoughnut ? r2 * 0.5 : 0;
|
|
2694
2656
|
const firstKey = entries[0]?.[0] ?? "";
|
|
2695
2657
|
const colorOffset = hashString(firstKey);
|
|
2696
|
-
const maskRef =
|
|
2658
|
+
const maskRef = React6.useRef(null);
|
|
2697
2659
|
const maskR = r2 + 10;
|
|
2698
2660
|
const maskCircumference = 2 * Math.PI * maskR;
|
|
2699
|
-
|
|
2661
|
+
React6.useEffect(() => {
|
|
2700
2662
|
if (!animate || !maskRef.current) return;
|
|
2701
2663
|
const el = maskRef.current;
|
|
2702
2664
|
el.style.strokeDasharray = `${maskCircumference}`;
|
|
@@ -2706,7 +2668,7 @@ var PieDonutChart = React7.memo(
|
|
|
2706
2668
|
el.style.strokeDashoffset = "0";
|
|
2707
2669
|
});
|
|
2708
2670
|
}, [animate, maskCircumference]);
|
|
2709
|
-
const sliceData =
|
|
2671
|
+
const sliceData = React6.useMemo(() => {
|
|
2710
2672
|
let angle0 = -Math.PI / 2;
|
|
2711
2673
|
let cumulativeAngle = 0;
|
|
2712
2674
|
return values.map((v, i) => {
|
|
@@ -2741,7 +2703,7 @@ var PieDonutChart = React7.memo(
|
|
|
2741
2703
|
}, [values, total, cx, cy, r2, innerR, labels]);
|
|
2742
2704
|
const maskId = `pie-mask-${isDoughnut ? "d" : "p"}`;
|
|
2743
2705
|
return /* @__PURE__ */ jsxs197("svg", { viewBox: `0 0 ${size} ${size}`, className: "chart-svg chart-pie", children: [
|
|
2744
|
-
animate && /* @__PURE__ */
|
|
2706
|
+
animate && /* @__PURE__ */ jsx307("defs", { children: /* @__PURE__ */ jsx307("mask", { id: maskId, children: /* @__PURE__ */ jsx307(
|
|
2745
2707
|
"circle",
|
|
2746
2708
|
{
|
|
2747
2709
|
ref: maskRef,
|
|
@@ -2754,56 +2716,39 @@ var PieDonutChart = React7.memo(
|
|
|
2754
2716
|
transform: `rotate(-90 ${cx} ${cy})`
|
|
2755
2717
|
}
|
|
2756
2718
|
) }) }),
|
|
2757
|
-
/* @__PURE__ */
|
|
2719
|
+
/* @__PURE__ */ jsx307("g", { mask: animate ? `url(#${maskId})` : void 0, children: sliceData.map((s, i) => /* @__PURE__ */ jsx307("g", { children: /* @__PURE__ */ jsx307(
|
|
2758
2720
|
"path",
|
|
2759
2721
|
{
|
|
2760
2722
|
d: s.d,
|
|
2761
2723
|
fill: PIE_COLORS[(i + colorOffset) % PIE_COLORS.length],
|
|
2762
|
-
className: "chart-slice"
|
|
2763
|
-
onMouseEnter: (e) => onHover(e, `${s.label}: ${s.v} (${s.pct}%)`),
|
|
2764
|
-
onMouseMove: onMove,
|
|
2765
|
-
onMouseLeave: onLeave
|
|
2724
|
+
className: "chart-slice"
|
|
2766
2725
|
}
|
|
2767
|
-
) }, i)) })
|
|
2768
|
-
sliceData.map((s, i) => s.angle > 0.2 && /* @__PURE__ */ jsx308(
|
|
2769
|
-
"text",
|
|
2770
|
-
{
|
|
2771
|
-
x: s.lx,
|
|
2772
|
-
y: s.ly,
|
|
2773
|
-
className: `chart-pie-label ${animate ? "chart-pie-label-animate" : ""}`,
|
|
2774
|
-
style: animate ? { animationDelay: `${s.labelDelay}ms` } : void 0,
|
|
2775
|
-
textAnchor: "middle",
|
|
2776
|
-
dominantBaseline: "central",
|
|
2777
|
-
children: s.v
|
|
2778
|
-
},
|
|
2779
|
-
`label-${i}`
|
|
2780
|
-
))
|
|
2726
|
+
) }, i)) })
|
|
2781
2727
|
] });
|
|
2782
2728
|
}
|
|
2783
2729
|
);
|
|
2784
2730
|
PieDonutChart.displayName = "PieDonutChart";
|
|
2785
|
-
var
|
|
2786
|
-
const ref =
|
|
2787
|
-
const [pos, setPos] =
|
|
2788
|
-
|
|
2731
|
+
var ChartTooltip = ({ x, y, containerWidth, containerHeight, children }) => {
|
|
2732
|
+
const ref = React6.useRef(null);
|
|
2733
|
+
const [pos, setPos] = React6.useState({ left: 0, top: 0 });
|
|
2734
|
+
React6.useLayoutEffect(() => {
|
|
2789
2735
|
const el = ref.current;
|
|
2790
2736
|
if (!el) return;
|
|
2791
2737
|
const w = el.offsetWidth;
|
|
2792
2738
|
const h = el.offsetHeight;
|
|
2793
|
-
|
|
2794
|
-
let
|
|
2795
|
-
|
|
2796
|
-
if (
|
|
2797
|
-
if (
|
|
2798
|
-
if (left < 8) left = 8;
|
|
2739
|
+
let left = x + TOOLTIP_OFFSET;
|
|
2740
|
+
let top = y - h - TOOLTIP_OFFSET;
|
|
2741
|
+
if (left + w > containerWidth) left = x - w - TOOLTIP_OFFSET;
|
|
2742
|
+
if (top < 0) top = y + TOOLTIP_OFFSET;
|
|
2743
|
+
if (left < 0) left = 0;
|
|
2799
2744
|
setPos({ left, top });
|
|
2800
|
-
}, [
|
|
2801
|
-
return /* @__PURE__ */
|
|
2745
|
+
}, [x, y, containerWidth, containerHeight]);
|
|
2746
|
+
return /* @__PURE__ */ jsx307(
|
|
2802
2747
|
"div",
|
|
2803
2748
|
{
|
|
2804
2749
|
ref,
|
|
2805
|
-
className:
|
|
2806
|
-
style: {
|
|
2750
|
+
className: "chart-tooltip chart-tooltip-show",
|
|
2751
|
+
style: { left: pos.left, top: pos.top },
|
|
2807
2752
|
children
|
|
2808
2753
|
}
|
|
2809
2754
|
);
|
|
@@ -2815,13 +2760,13 @@ var ChartLegend = ({ data, labels, type }) => {
|
|
|
2815
2760
|
const total = values.reduce((a, b) => a + b, 0) || 1;
|
|
2816
2761
|
const firstKey = entries[0]?.[0] ?? "";
|
|
2817
2762
|
const colorOffset = hashString(firstKey);
|
|
2818
|
-
return /* @__PURE__ */
|
|
2763
|
+
return /* @__PURE__ */ jsx307("div", { className: "chart-legend", children: values.map((v, i) => {
|
|
2819
2764
|
const pct = Math.round(v / total * 100);
|
|
2820
2765
|
const color = PIE_COLORS[(i + colorOffset) % PIE_COLORS.length];
|
|
2821
2766
|
return /* @__PURE__ */ jsxs197("div", { className: "chart-legend-item", children: [
|
|
2822
|
-
/* @__PURE__ */
|
|
2767
|
+
/* @__PURE__ */ jsx307("span", { className: "chart-legend-dot", style: { backgroundColor: color } }),
|
|
2823
2768
|
/* @__PURE__ */ jsxs197("div", { className: "chart-legend-text", children: [
|
|
2824
|
-
/* @__PURE__ */
|
|
2769
|
+
/* @__PURE__ */ jsx307("span", { className: "chart-legend-label", children: labels[i] || `${i + 1}` }),
|
|
2825
2770
|
/* @__PURE__ */ jsxs197("span", { className: "chart-legend-value", children: [
|
|
2826
2771
|
v.toLocaleString(),
|
|
2827
2772
|
"(",
|
|
@@ -2832,37 +2777,37 @@ var ChartLegend = ({ data, labels, type }) => {
|
|
|
2832
2777
|
] }, i);
|
|
2833
2778
|
}) });
|
|
2834
2779
|
}
|
|
2835
|
-
return /* @__PURE__ */
|
|
2780
|
+
return /* @__PURE__ */ jsx307("div", { className: "chart-legend", children: entries.map(([key], di) => {
|
|
2836
2781
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
2837
2782
|
const color = palette[2];
|
|
2838
2783
|
const values = entries[di][1];
|
|
2839
2784
|
const sum = values.reduce((a, b) => a + b, 0);
|
|
2840
2785
|
return /* @__PURE__ */ jsxs197("div", { className: "chart-legend-item", children: [
|
|
2841
|
-
/* @__PURE__ */
|
|
2786
|
+
/* @__PURE__ */ jsx307("span", { className: "chart-legend-dot", style: { backgroundColor: color } }),
|
|
2842
2787
|
/* @__PURE__ */ jsxs197("div", { className: "chart-legend-text", children: [
|
|
2843
|
-
/* @__PURE__ */
|
|
2844
|
-
/* @__PURE__ */
|
|
2788
|
+
/* @__PURE__ */ jsx307("span", { className: "chart-legend-label", children: key }),
|
|
2789
|
+
/* @__PURE__ */ jsx307("span", { className: "chart-legend-value", children: sum.toLocaleString() })
|
|
2845
2790
|
] })
|
|
2846
2791
|
] }, di);
|
|
2847
2792
|
}) });
|
|
2848
2793
|
};
|
|
2849
|
-
var Chart =
|
|
2794
|
+
var Chart = React6.memo((props) => {
|
|
2850
2795
|
const { type, data, labels, tooltip: showTooltip = true } = props;
|
|
2851
|
-
const { tooltip, show, hide, move, containerRef } = useChartTooltip(showTooltip);
|
|
2796
|
+
const { tooltip, show, showAt, hide, move, containerRef } = useChartTooltip(showTooltip);
|
|
2852
2797
|
const { width, height } = useChartSize(containerRef);
|
|
2853
|
-
const stableData =
|
|
2854
|
-
const stableLabels =
|
|
2855
|
-
const dataKey =
|
|
2798
|
+
const stableData = React6.useMemo(() => data, [JSON.stringify(data)]);
|
|
2799
|
+
const stableLabels = React6.useMemo(() => labels, [JSON.stringify(labels)]);
|
|
2800
|
+
const dataKey = React6.useMemo(() => JSON.stringify(labels), [labels]);
|
|
2856
2801
|
const animate = useChartAnimation(containerRef, dataKey);
|
|
2857
2802
|
const ready = width > 0 && height > 0;
|
|
2858
2803
|
return /* @__PURE__ */ jsxs197("div", { className: "lib-xplat-chart", ref: containerRef, children: [
|
|
2859
|
-
ready && type === "line" && /* @__PURE__ */
|
|
2860
|
-
ready && type === "curve" && /* @__PURE__ */
|
|
2861
|
-
ready && type === "bar" && /* @__PURE__ */
|
|
2862
|
-
ready && type === "pie" && /* @__PURE__ */
|
|
2863
|
-
ready && type === "doughnut" && /* @__PURE__ */
|
|
2864
|
-
ready && (type === "bar" || type === "pie" || type === "doughnut") && /* @__PURE__ */
|
|
2865
|
-
tooltip.content && /* @__PURE__ */
|
|
2804
|
+
ready && type === "line" && /* @__PURE__ */ jsx307(LineChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onShowAt: showAt, onMove: move, onLeave: hide }),
|
|
2805
|
+
ready && type === "curve" && /* @__PURE__ */ jsx307(CurveChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onShowAt: showAt, onMove: move, onLeave: hide }),
|
|
2806
|
+
ready && type === "bar" && /* @__PURE__ */ jsx307(BarChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onShowAt: showAt, onMove: move, onLeave: hide }),
|
|
2807
|
+
ready && type === "pie" && /* @__PURE__ */ jsx307(PieDonutChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onShowAt: showAt, onMove: move, onLeave: hide }),
|
|
2808
|
+
ready && type === "doughnut" && /* @__PURE__ */ jsx307(PieDonutChart, { data: stableData, labels: stableLabels, width, height, animate, isDoughnut: true, onHover: show, onShowAt: showAt, onMove: move, onLeave: hide }),
|
|
2809
|
+
ready && (type === "bar" || type === "pie" || type === "doughnut") && /* @__PURE__ */ jsx307(ChartLegend, { data: stableData, labels: stableLabels, type }),
|
|
2810
|
+
tooltip.visible && tooltip.content && /* @__PURE__ */ jsx307(ChartTooltip, { x: tooltip.x, y: tooltip.y, containerWidth: width, containerHeight: height, children: tooltip.content })
|
|
2866
2811
|
] });
|
|
2867
2812
|
});
|
|
2868
2813
|
Chart.displayName = "Chart";
|
|
@@ -2875,7 +2820,7 @@ import { primitive, semantic } from "@x-plat/tokens-core";
|
|
|
2875
2820
|
import { cssVar } from "@x-plat/tokens-core";
|
|
2876
2821
|
|
|
2877
2822
|
// src/components/CheckBox/CheckBox.tsx
|
|
2878
|
-
import { jsx as
|
|
2823
|
+
import { jsx as jsx308, jsxs as jsxs198 } from "react/jsx-runtime";
|
|
2879
2824
|
var CheckBox = (props) => {
|
|
2880
2825
|
const {
|
|
2881
2826
|
checked,
|
|
@@ -2894,7 +2839,7 @@ var CheckBox = (props) => {
|
|
|
2894
2839
|
const disabledClasses = "disabled";
|
|
2895
2840
|
const boxClasses = disabled ? disabledClasses : checked ? checkedClasses : uncheckedClasses;
|
|
2896
2841
|
return /* @__PURE__ */ jsxs198("label", { className: clsx_default("lib-xplat-checkbox", size, type), children: [
|
|
2897
|
-
/* @__PURE__ */
|
|
2842
|
+
/* @__PURE__ */ jsx308(
|
|
2898
2843
|
"input",
|
|
2899
2844
|
{
|
|
2900
2845
|
type: "checkbox",
|
|
@@ -2904,22 +2849,22 @@ var CheckBox = (props) => {
|
|
|
2904
2849
|
...rest
|
|
2905
2850
|
}
|
|
2906
2851
|
),
|
|
2907
|
-
/* @__PURE__ */
|
|
2908
|
-
label && /* @__PURE__ */
|
|
2852
|
+
/* @__PURE__ */ jsx308("span", { className: clsx_default("checkbox", boxClasses), children: /* @__PURE__ */ jsx308("span", { className: clsx_default("check-icon", { visible: checked }), children: /* @__PURE__ */ jsx308(CheckIcon_default, {}) }) }),
|
|
2853
|
+
label && /* @__PURE__ */ jsx308("span", { className: "label", children: label })
|
|
2909
2854
|
] });
|
|
2910
2855
|
};
|
|
2911
2856
|
CheckBox.displayName = "CheckBox";
|
|
2912
2857
|
var CheckBox_default = CheckBox;
|
|
2913
2858
|
|
|
2914
2859
|
// src/components/Chip/Chip.tsx
|
|
2915
|
-
import { jsx as
|
|
2860
|
+
import { jsx as jsx309 } from "react/jsx-runtime";
|
|
2916
2861
|
var Chip = (props) => {
|
|
2917
2862
|
const {
|
|
2918
2863
|
children,
|
|
2919
2864
|
type = "primary",
|
|
2920
2865
|
size = "md"
|
|
2921
2866
|
} = props;
|
|
2922
|
-
return /* @__PURE__ */
|
|
2867
|
+
return /* @__PURE__ */ jsx309("div", { className: clsx_default("lib-xplat-chip", type, size), children });
|
|
2923
2868
|
};
|
|
2924
2869
|
Chip.displayName = "Chip";
|
|
2925
2870
|
var Chip_default = Chip;
|
|
@@ -2928,20 +2873,20 @@ var Chip_default = Chip;
|
|
|
2928
2873
|
import React12 from "react";
|
|
2929
2874
|
|
|
2930
2875
|
// src/components/Input/Input.tsx
|
|
2931
|
-
import
|
|
2876
|
+
import React7 from "react";
|
|
2932
2877
|
|
|
2933
2878
|
// src/components/Input/InputValidations.tsx
|
|
2934
|
-
import { jsx as
|
|
2879
|
+
import { jsx as jsx310, jsxs as jsxs199 } from "react/jsx-runtime";
|
|
2935
2880
|
var InputValidations = (props) => {
|
|
2936
2881
|
const { message, status = "default" } = props;
|
|
2937
2882
|
return /* @__PURE__ */ jsxs199("div", { className: clsx_default("lib-xplat-input-validation", status), children: [
|
|
2938
2883
|
/* @__PURE__ */ jsxs199("div", { className: "icon", children: [
|
|
2939
|
-
status === "default" && /* @__PURE__ */
|
|
2940
|
-
status === "success" && /* @__PURE__ */
|
|
2941
|
-
status === "warning" && /* @__PURE__ */
|
|
2942
|
-
status === "error" && /* @__PURE__ */
|
|
2884
|
+
status === "default" && /* @__PURE__ */ jsx310(InfoIcon_default, {}),
|
|
2885
|
+
status === "success" && /* @__PURE__ */ jsx310(SuccessIcon_default, {}),
|
|
2886
|
+
status === "warning" && /* @__PURE__ */ jsx310(InfoIcon_default, {}),
|
|
2887
|
+
status === "error" && /* @__PURE__ */ jsx310(ErrorIcon_default, {})
|
|
2943
2888
|
] }),
|
|
2944
|
-
/* @__PURE__ */
|
|
2889
|
+
/* @__PURE__ */ jsx310("div", { className: "message", children: message })
|
|
2945
2890
|
] });
|
|
2946
2891
|
};
|
|
2947
2892
|
InputValidations.displayName = "InputValidations";
|
|
@@ -2982,7 +2927,7 @@ var handleTelBackspace = (prevValue, currValue) => {
|
|
|
2982
2927
|
};
|
|
2983
2928
|
|
|
2984
2929
|
// src/components/Input/Input.tsx
|
|
2985
|
-
import { jsx as
|
|
2930
|
+
import { jsx as jsx311, jsxs as jsxs200 } from "react/jsx-runtime";
|
|
2986
2931
|
import { createElement } from "react";
|
|
2987
2932
|
var formatValue = (type, value) => {
|
|
2988
2933
|
if (value === null || value === void 0) return "";
|
|
@@ -3031,7 +2976,7 @@ var parseValue = (type, value) => {
|
|
|
3031
2976
|
return value;
|
|
3032
2977
|
}
|
|
3033
2978
|
};
|
|
3034
|
-
var Input =
|
|
2979
|
+
var Input = React7.forwardRef((props, ref) => {
|
|
3035
2980
|
const {
|
|
3036
2981
|
value,
|
|
3037
2982
|
onChange,
|
|
@@ -3063,7 +3008,7 @@ var Input = React8.forwardRef((props, ref) => {
|
|
|
3063
3008
|
{
|
|
3064
3009
|
className: clsx_default("lib-xplat-input", size, disabled ? "disabled" : void 0),
|
|
3065
3010
|
children: [
|
|
3066
|
-
/* @__PURE__ */
|
|
3011
|
+
/* @__PURE__ */ jsx311(
|
|
3067
3012
|
"input",
|
|
3068
3013
|
{
|
|
3069
3014
|
...inputProps,
|
|
@@ -3074,11 +3019,11 @@ var Input = React8.forwardRef((props, ref) => {
|
|
|
3074
3019
|
onChange: handleChange
|
|
3075
3020
|
}
|
|
3076
3021
|
),
|
|
3077
|
-
suffix && /* @__PURE__ */
|
|
3022
|
+
suffix && /* @__PURE__ */ jsx311("div", { className: "suffix", children: suffix })
|
|
3078
3023
|
]
|
|
3079
3024
|
}
|
|
3080
3025
|
),
|
|
3081
|
-
validations && /* @__PURE__ */
|
|
3026
|
+
validations && /* @__PURE__ */ jsx311("div", { className: "lib-xplat-input-validation-wrap", children: validations?.map((validation, idx) => /* @__PURE__ */ createElement(
|
|
3082
3027
|
InputValidations_default,
|
|
3083
3028
|
{
|
|
3084
3029
|
...validation,
|
|
@@ -3091,20 +3036,20 @@ Input.displayName = "Input";
|
|
|
3091
3036
|
var Input_default = Input;
|
|
3092
3037
|
|
|
3093
3038
|
// src/components/Input/PasswordInput/PasswordInput.tsx
|
|
3094
|
-
import
|
|
3095
|
-
import { jsx as
|
|
3096
|
-
var PasswordInput =
|
|
3039
|
+
import React8 from "react";
|
|
3040
|
+
import { jsx as jsx312 } from "react/jsx-runtime";
|
|
3041
|
+
var PasswordInput = React8.forwardRef(
|
|
3097
3042
|
(props, ref) => {
|
|
3098
3043
|
const { reg: _reg, ...inputProps } = props;
|
|
3099
|
-
const [isView, setIsView] =
|
|
3044
|
+
const [isView, setIsView] = React8.useState(false);
|
|
3100
3045
|
const handleChangeView = () => {
|
|
3101
3046
|
setIsView((prev) => !prev);
|
|
3102
3047
|
};
|
|
3103
|
-
return /* @__PURE__ */
|
|
3048
|
+
return /* @__PURE__ */ jsx312(
|
|
3104
3049
|
Input_default,
|
|
3105
3050
|
{
|
|
3106
3051
|
...inputProps,
|
|
3107
|
-
suffix: /* @__PURE__ */
|
|
3052
|
+
suffix: /* @__PURE__ */ jsx312("div", { className: "wrapper pointer", onClick: handleChangeView, children: isView ? /* @__PURE__ */ jsx312(OpenEyeIcon_default, {}) : /* @__PURE__ */ jsx312(CloseEyeIcon_default, {}) }),
|
|
3108
3053
|
type: isView ? "text" : "password",
|
|
3109
3054
|
ref
|
|
3110
3055
|
}
|
|
@@ -3117,6 +3062,23 @@ var PasswordInput_default = PasswordInput;
|
|
|
3117
3062
|
// src/components/Modal/Modal.tsx
|
|
3118
3063
|
import React10 from "react";
|
|
3119
3064
|
import { createPortal } from "react-dom";
|
|
3065
|
+
|
|
3066
|
+
// src/tokens/hooks/Portal.tsx
|
|
3067
|
+
import React9 from "react";
|
|
3068
|
+
import ReactDOM from "react-dom";
|
|
3069
|
+
import { jsx as jsx313 } from "react/jsx-runtime";
|
|
3070
|
+
var PortalContainerContext = React9.createContext(null);
|
|
3071
|
+
var PortalProvider = ({ container, children }) => /* @__PURE__ */ jsx313(PortalContainerContext.Provider, { value: container, children });
|
|
3072
|
+
var Portal = ({ children }) => {
|
|
3073
|
+
const contextContainer = React9.useContext(PortalContainerContext);
|
|
3074
|
+
if (typeof document === "undefined") return null;
|
|
3075
|
+
const container = contextContainer ?? document.body;
|
|
3076
|
+
return ReactDOM.createPortal(children, container);
|
|
3077
|
+
};
|
|
3078
|
+
Portal.displayName = "Portal";
|
|
3079
|
+
var Portal_default = Portal;
|
|
3080
|
+
|
|
3081
|
+
// src/components/Modal/Modal.tsx
|
|
3120
3082
|
import { jsx as jsx314 } from "react/jsx-runtime";
|
|
3121
3083
|
var ANIMATION_DURATION_MS = 200;
|
|
3122
3084
|
var Modal = (props) => {
|