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