@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.
@@ -2229,25 +2229,8 @@ var CardTab = Object.assign(CardTabRoot, {
2229
2229
  var CardTab_default = CardTab;
2230
2230
 
2231
2231
  // src/components/Chart/Chart.tsx
2232
- var import_react7 = __toESM(require("react"), 1);
2233
-
2234
- // src/tokens/hooks/Portal.tsx
2235
2232
  var import_react6 = __toESM(require("react"), 1);
2236
- var import_react_dom = __toESM(require("react-dom"), 1);
2237
2233
  var import_jsx_runtime307 = require("react/jsx-runtime");
2238
- var PortalContainerContext = import_react6.default.createContext(null);
2239
- var PortalProvider = ({ container, children }) => /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(PortalContainerContext.Provider, { value: container, children });
2240
- var Portal = ({ children }) => {
2241
- const contextContainer = import_react6.default.useContext(PortalContainerContext);
2242
- if (typeof document === "undefined") return null;
2243
- const container = contextContainer ?? document.body;
2244
- return import_react_dom.default.createPortal(children, container);
2245
- };
2246
- Portal.displayName = "Portal";
2247
- var Portal_default = Portal;
2248
-
2249
- // src/components/Chart/Chart.tsx
2250
- var import_jsx_runtime308 = require("react/jsx-runtime");
2251
2234
  var CATEGORICAL_COUNT2 = 8;
2252
2235
  var LINE_BAR_PALETTES = Array.from({ length: CATEGORICAL_COUNT2 }, (_, i) => {
2253
2236
  const n = i + 1;
@@ -2293,11 +2276,11 @@ var toSmoothPath = (points) => {
2293
2276
  };
2294
2277
  var RESIZE_SETTLE_MS = 150;
2295
2278
  var useChartSize = (ref) => {
2296
- const [size, setSize] = import_react7.default.useState({ width: 0, height: 0 });
2297
- const settleTimer = import_react7.default.useRef(0);
2298
- const committedSize = import_react7.default.useRef({ width: 0, height: 0 });
2299
- const initialRef = import_react7.default.useRef(true);
2300
- import_react7.default.useEffect(() => {
2279
+ const [size, setSize] = import_react6.default.useState({ width: 0, height: 0 });
2280
+ const settleTimer = import_react6.default.useRef(0);
2281
+ const committedSize = import_react6.default.useRef({ width: 0, height: 0 });
2282
+ const initialRef = import_react6.default.useRef(true);
2283
+ import_react6.default.useEffect(() => {
2301
2284
  const el = ref.current;
2302
2285
  if (!el) return;
2303
2286
  const observer = new ResizeObserver((entries) => {
@@ -2339,10 +2322,10 @@ var useChartSize = (ref) => {
2339
2322
  };
2340
2323
  var prefersReducedMotion = () => typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
2341
2324
  var useChartAnimation = (containerRef, dataKey) => {
2342
- const [animate, setAnimate] = import_react7.default.useState(false);
2343
- const prevDataKey = import_react7.default.useRef(dataKey);
2344
- const hasAnimated = import_react7.default.useRef(false);
2345
- import_react7.default.useEffect(() => {
2325
+ const [animate, setAnimate] = import_react6.default.useState(false);
2326
+ const prevDataKey = import_react6.default.useRef(dataKey);
2327
+ const hasAnimated = import_react6.default.useRef(false);
2328
+ import_react6.default.useEffect(() => {
2346
2329
  if (prefersReducedMotion()) return;
2347
2330
  const el = containerRef.current;
2348
2331
  if (!el) return;
@@ -2358,7 +2341,7 @@ var useChartAnimation = (containerRef, dataKey) => {
2358
2341
  observer.observe(el);
2359
2342
  return () => observer.disconnect();
2360
2343
  }, [containerRef]);
2361
- import_react7.default.useEffect(() => {
2344
+ import_react6.default.useEffect(() => {
2362
2345
  if (dataKey !== prevDataKey.current) {
2363
2346
  prevDataKey.current = dataKey;
2364
2347
  if (prefersReducedMotion()) return;
@@ -2372,39 +2355,47 @@ var useChartAnimation = (containerRef, dataKey) => {
2372
2355
  };
2373
2356
  var TOOLTIP_OFFSET = 12;
2374
2357
  var useChartTooltip = (enabled) => {
2375
- const [tooltip, setTooltip] = import_react7.default.useState({
2358
+ const [tooltip, setTooltip] = import_react6.default.useState({
2376
2359
  visible: false,
2377
- clientX: 0,
2378
- clientY: 0,
2360
+ x: 0,
2361
+ y: 0,
2379
2362
  content: ""
2380
2363
  });
2381
- const containerRef = import_react7.default.useRef(null);
2382
- const rafRef = import_react7.default.useRef(0);
2383
- const move = import_react7.default.useCallback((e) => {
2364
+ const containerRef = import_react6.default.useRef(null);
2365
+ const rafRef = import_react6.default.useRef(0);
2366
+ const move = import_react6.default.useCallback((e) => {
2384
2367
  if (!enabled) return;
2385
2368
  const cx = e.clientX;
2386
2369
  const cy = e.clientY;
2387
2370
  cancelAnimationFrame(rafRef.current);
2388
2371
  rafRef.current = requestAnimationFrame(() => {
2389
- setTooltip((prev) => ({ ...prev, clientX: cx, clientY: cy }));
2372
+ const rect = containerRef.current?.getBoundingClientRect();
2373
+ if (!rect) return;
2374
+ setTooltip((prev) => ({ ...prev, x: cx - rect.left, y: cy - rect.top }));
2390
2375
  });
2391
2376
  }, [enabled]);
2392
- const show = import_react7.default.useCallback((e, content) => {
2377
+ const show = import_react6.default.useCallback((e, content) => {
2378
+ if (!enabled) return;
2379
+ const rect = containerRef.current?.getBoundingClientRect();
2380
+ if (!rect) return;
2381
+ setTooltip({ visible: true, x: e.clientX - rect.left, y: e.clientY - rect.top, content });
2382
+ }, [enabled]);
2383
+ const showAt = import_react6.default.useCallback((x, y, content) => {
2393
2384
  if (!enabled) return;
2394
- setTooltip({ visible: true, clientX: e.clientX, clientY: e.clientY, content });
2385
+ setTooltip({ visible: true, x, y, content });
2395
2386
  }, [enabled]);
2396
- const hide = import_react7.default.useCallback(() => {
2387
+ const hide = import_react6.default.useCallback(() => {
2397
2388
  cancelAnimationFrame(rafRef.current);
2398
2389
  setTooltip((prev) => ({ ...prev, visible: false }));
2399
2390
  }, []);
2400
- return { tooltip, show, hide, move, containerRef };
2391
+ return { tooltip, show, showAt, hide, move, containerRef };
2401
2392
  };
2402
- var GridLines = import_react7.default.memo(({ width, height, chartH, maxVal }) => /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(import_jsx_runtime308.Fragment, { children: [0, 0.25, 0.5, 0.75, 1].map((ratio) => {
2393
+ var GridLines = import_react6.default.memo(({ width, height, chartH, maxVal }) => /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(import_jsx_runtime307.Fragment, { children: [0, 0.25, 0.5, 0.75, 1].map((ratio) => {
2403
2394
  const y = PADDING.top + (1 - ratio) * chartH;
2404
2395
  const val = Math.round(maxVal * ratio);
2405
- return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("g", { children: [
2406
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("line", { x1: PADDING.left, y1: y, x2: width - PADDING.right, y2: y, className: "chart-grid" }),
2407
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("text", { x: PADDING.left - 8, y: y + 4, className: "chart-axis-label", textAnchor: "end", children: val })
2396
+ return /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)("g", { children: [
2397
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("line", { x1: PADDING.left, y1: y, x2: width - PADDING.right, y2: y, className: "chart-grid" }),
2398
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("text", { x: PADDING.left - 8, y: y + 4, className: "chart-axis-label", textAnchor: "end", children: val })
2408
2399
  ] }, ratio);
2409
2400
  }) }));
2410
2401
  GridLines.displayName = "GridLines";
@@ -2414,18 +2405,18 @@ var getLabelStep = (count, chartW) => {
2414
2405
  if (count <= maxLabels) return 1;
2415
2406
  return Math.ceil(count / maxLabels);
2416
2407
  };
2417
- var AxisLabels = import_react7.default.memo(({ labels, count, chartW, height }) => {
2408
+ var AxisLabels = import_react6.default.memo(({ labels, count, chartW, height }) => {
2418
2409
  const step = getLabelStep(count, chartW);
2419
- return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(import_jsx_runtime308.Fragment, { children: labels.map((label, i) => {
2410
+ return /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(import_jsx_runtime307.Fragment, { children: labels.map((label, i) => {
2420
2411
  if (i % step !== 0) return null;
2421
2412
  const x = PADDING.left + i / (count - 1 || 1) * chartW;
2422
- return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("text", { x, y: height - 8, className: "chart-axis-label", textAnchor: "middle", children: label }, i);
2413
+ return /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("text", { x, y: height - 8, className: "chart-axis-label", textAnchor: "middle", children: label }, i);
2423
2414
  }) });
2424
2415
  });
2425
2416
  AxisLabels.displayName = "AxisLabels";
2426
2417
  var useCrosshair = (seriesPoints, entries, labels, chartH) => {
2427
- const [activeIndex, setActiveIndex] = import_react7.default.useState(null);
2428
- const handleMouseMove = import_react7.default.useCallback((e) => {
2418
+ const [activeIndex, setActiveIndex] = import_react6.default.useState(null);
2419
+ const handleMouseMove = import_react6.default.useCallback((e) => {
2429
2420
  const svg = e.currentTarget;
2430
2421
  const rect = svg.getBoundingClientRect();
2431
2422
  const mx = (e.clientX - rect.left) / rect.width * svg.viewBox.baseVal.width;
@@ -2444,17 +2435,17 @@ var useCrosshair = (seriesPoints, entries, labels, chartH) => {
2444
2435
  }
2445
2436
  setActiveIndex(minDist <= threshold ? closest : null);
2446
2437
  }, [seriesPoints]);
2447
- const handleMouseLeave = import_react7.default.useCallback(() => {
2438
+ const handleMouseLeave = import_react6.default.useCallback(() => {
2448
2439
  setActiveIndex(null);
2449
2440
  }, []);
2450
- const tooltipContent = import_react7.default.useMemo(() => {
2441
+ const tooltipContent = import_react6.default.useMemo(() => {
2451
2442
  if (activeIndex === null) return "";
2452
2443
  return entries.map(([key], di) => {
2453
2444
  const p = seriesPoints[di]?.[activeIndex];
2454
2445
  return p ? `${key}: ${p.v}` : "";
2455
2446
  }).filter(Boolean).join(" / ");
2456
2447
  }, [activeIndex, entries, seriesPoints]);
2457
- const getTooltipAt = import_react7.default.useCallback((idx) => {
2448
+ const getTooltipAt = import_react6.default.useCallback((idx) => {
2458
2449
  return entries.map(([key], di) => {
2459
2450
  const p = seriesPoints[di]?.[idx];
2460
2451
  return p ? `${key}: ${p.v}` : "";
@@ -2462,16 +2453,16 @@ var useCrosshair = (seriesPoints, entries, labels, chartH) => {
2462
2453
  }, [entries, seriesPoints]);
2463
2454
  return { activeIndex, handleMouseMove, handleMouseLeave, tooltipContent, getTooltipAt };
2464
2455
  };
2465
- var LineChart = import_react7.default.memo(({ data, labels, width, height, animate, onHover, onMove, onLeave }) => {
2466
- const entries = import_react7.default.useMemo(() => Object.entries(data), [data]);
2467
- const maxVal = import_react7.default.useMemo(() => {
2456
+ var LineChart = import_react6.default.memo(({ data, labels, width, height, animate, onHover, onShowAt, onMove, onLeave }) => {
2457
+ const entries = import_react6.default.useMemo(() => Object.entries(data), [data]);
2458
+ const maxVal = import_react6.default.useMemo(() => {
2468
2459
  const allValues = entries.flatMap(([, v]) => v);
2469
2460
  return Math.max(...allValues) * 1.2 || 1;
2470
2461
  }, [entries]);
2471
2462
  const count = labels.length;
2472
2463
  const chartW = width - PADDING.left - PADDING.right;
2473
2464
  const chartH = height - PADDING.top - PADDING.bottom;
2474
- const seriesPoints = import_react7.default.useMemo(
2465
+ const seriesPoints = import_react6.default.useMemo(
2475
2466
  () => entries.map(
2476
2467
  ([, values]) => values.map((v, i) => ({
2477
2468
  x: PADDING.left + i / (count - 1 || 1) * chartW,
@@ -2481,9 +2472,9 @@ var LineChart = import_react7.default.memo(({ data, labels, width, height, anima
2481
2472
  ),
2482
2473
  [entries, count, chartW, chartH, maxVal]
2483
2474
  );
2484
- const clipRef = import_react7.default.useRef(null);
2475
+ const clipRef = import_react6.default.useRef(null);
2485
2476
  const { activeIndex, handleMouseMove, handleMouseLeave, getTooltipAt } = useCrosshair(seriesPoints, entries, labels, chartH);
2486
- import_react7.default.useEffect(() => {
2477
+ import_react6.default.useEffect(() => {
2487
2478
  if (!animate || !clipRef.current) return;
2488
2479
  clipRef.current.setAttribute("width", "0");
2489
2480
  requestAnimationFrame(() => {
@@ -2495,30 +2486,16 @@ var LineChart = import_react7.default.memo(({ data, labels, width, height, anima
2495
2486
  }, [animate, width]);
2496
2487
  const activeX = activeIndex !== null ? seriesPoints[0]?.[activeIndex]?.x ?? null : null;
2497
2488
  const lineClipId = "line-area-clip";
2498
- return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)(
2489
+ return /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)(
2499
2490
  "svg",
2500
2491
  {
2501
2492
  viewBox: `0 0 ${width} ${height}`,
2502
2493
  className: "chart-svg",
2503
2494
  onMouseMove: (e) => {
2504
2495
  handleMouseMove(e);
2505
- const svg = e.currentTarget;
2506
- const rect = svg.getBoundingClientRect();
2507
- const mx = (e.clientX - rect.left) / rect.width * svg.viewBox.baseVal.width;
2508
- const points = seriesPoints[0];
2509
- if (!points || points.length === 0) return;
2510
- const step = points.length > 1 ? Math.abs(points[1].x - points[0].x) : 20;
2511
- let closest = 0;
2512
- let minDist = Math.abs(points[0].x - mx);
2513
- for (let i = 1; i < points.length; i++) {
2514
- const dist = Math.abs(points[i].x - mx);
2515
- if (dist < minDist) {
2516
- minDist = dist;
2517
- closest = i;
2518
- }
2519
- }
2520
- if (minDist <= step / 2) {
2521
- onHover(e, `${labels[closest]} \u2014 ${getTooltipAt(closest)}`);
2496
+ if (activeIndex !== null && seriesPoints[0]?.[activeIndex]) {
2497
+ const p = seriesPoints[0][activeIndex];
2498
+ onShowAt(p.x, p.y, `${labels[activeIndex]} \u2014 ${getTooltipAt(activeIndex)}`);
2522
2499
  } else {
2523
2500
  onLeave();
2524
2501
  }
@@ -2528,9 +2505,9 @@ var LineChart = import_react7.default.memo(({ data, labels, width, height, anima
2528
2505
  onLeave();
2529
2506
  },
2530
2507
  children: [
2531
- animate && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("clipPath", { id: lineClipId, children: /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("rect", { ref: clipRef, x: "0", y: "0", width: animate ? 0 : width, height }) }) }),
2532
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(GridLines, { width, height, chartH, maxVal }),
2533
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(AxisLabels, { labels, count, chartW, height }),
2508
+ animate && /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("clipPath", { id: lineClipId, children: /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("rect", { ref: clipRef, x: "0", y: "0", width: animate ? 0 : width, height }) }) }),
2509
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(GridLines, { width, height, chartH, maxVal }),
2510
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(AxisLabels, { labels, count, chartW, height }),
2534
2511
  entries.map(([key], di) => {
2535
2512
  const palette = getPalette(LINE_BAR_PALETTES, di, key);
2536
2513
  const color = palette[2];
@@ -2539,16 +2516,16 @@ var LineChart = import_react7.default.memo(({ data, labels, width, height, anima
2539
2516
  const gradientId = `line-gradient-${di}`;
2540
2517
  const polyPoints = points.map((p) => `${p.x},${p.y}`).join(" ");
2541
2518
  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`;
2542
- return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("g", { children: [
2543
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("linearGradient", { id: gradientId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
2544
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("stop", { offset: "0%", stopColor: areaColor, stopOpacity: "0.2" }),
2545
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("stop", { offset: "100%", stopColor: areaColor, stopOpacity: "0" })
2519
+ return /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)("g", { children: [
2520
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)("linearGradient", { id: gradientId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
2521
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("stop", { offset: "0%", stopColor: areaColor, stopOpacity: "0.2" }),
2522
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("stop", { offset: "100%", stopColor: areaColor, stopOpacity: "0" })
2546
2523
  ] }) }),
2547
- /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("g", { clipPath: animate ? `url(#${lineClipId})` : void 0, children: [
2548
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("path", { d: areaD, fill: `url(#${gradientId})` }),
2549
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("polyline", { points: polyPoints, fill: "none", stroke: color, strokeWidth: "2" })
2524
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)("g", { clipPath: animate ? `url(#${lineClipId})` : void 0, children: [
2525
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("path", { d: areaD, fill: `url(#${gradientId})` }),
2526
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("polyline", { points: polyPoints, fill: "none", stroke: color, strokeWidth: "2" })
2550
2527
  ] }),
2551
- activeIndex !== null && points[activeIndex] && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
2528
+ activeIndex !== null && points[activeIndex] && /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(
2552
2529
  "circle",
2553
2530
  {
2554
2531
  cx: points[activeIndex].x,
@@ -2560,7 +2537,7 @@ var LineChart = import_react7.default.memo(({ data, labels, width, height, anima
2560
2537
  )
2561
2538
  ] }, di);
2562
2539
  }),
2563
- activeX !== null && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
2540
+ activeX !== null && /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(
2564
2541
  "line",
2565
2542
  {
2566
2543
  x1: activeX,
@@ -2570,7 +2547,7 @@ var LineChart = import_react7.default.memo(({ data, labels, width, height, anima
2570
2547
  className: "chart-crosshair"
2571
2548
  }
2572
2549
  ),
2573
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
2550
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(
2574
2551
  "rect",
2575
2552
  {
2576
2553
  x: PADDING.left,
@@ -2586,16 +2563,16 @@ var LineChart = import_react7.default.memo(({ data, labels, width, height, anima
2586
2563
  );
2587
2564
  });
2588
2565
  LineChart.displayName = "LineChart";
2589
- var CurveChart = import_react7.default.memo(({ data, labels, width, height, animate, onHover, onMove, onLeave }) => {
2590
- const entries = import_react7.default.useMemo(() => Object.entries(data), [data]);
2591
- const maxVal = import_react7.default.useMemo(() => {
2566
+ var CurveChart = import_react6.default.memo(({ data, labels, width, height, animate, onHover, onShowAt, onMove, onLeave }) => {
2567
+ const entries = import_react6.default.useMemo(() => Object.entries(data), [data]);
2568
+ const maxVal = import_react6.default.useMemo(() => {
2592
2569
  const allValues = entries.flatMap(([, v]) => v);
2593
2570
  return Math.max(...allValues) * 1.2 || 1;
2594
2571
  }, [entries]);
2595
2572
  const count = labels.length;
2596
2573
  const chartW = width - PADDING.left - PADDING.right;
2597
2574
  const chartH = height - PADDING.top - PADDING.bottom;
2598
- const seriesPoints = import_react7.default.useMemo(
2575
+ const seriesPoints = import_react6.default.useMemo(
2599
2576
  () => entries.map(
2600
2577
  ([, values]) => values.map((v, i) => ({
2601
2578
  x: PADDING.left + i / (count - 1 || 1) * chartW,
@@ -2605,9 +2582,9 @@ var CurveChart = import_react7.default.memo(({ data, labels, width, height, anim
2605
2582
  ),
2606
2583
  [entries, count, chartW, chartH, maxVal]
2607
2584
  );
2608
- const curveClipRef = import_react7.default.useRef(null);
2585
+ const curveClipRef = import_react6.default.useRef(null);
2609
2586
  const { activeIndex, handleMouseMove, handleMouseLeave, getTooltipAt } = useCrosshair(seriesPoints, entries, labels, chartH);
2610
- import_react7.default.useEffect(() => {
2587
+ import_react6.default.useEffect(() => {
2611
2588
  if (!animate || !curveClipRef.current) return;
2612
2589
  curveClipRef.current.setAttribute("width", "0");
2613
2590
  requestAnimationFrame(() => {
@@ -2619,30 +2596,16 @@ var CurveChart = import_react7.default.memo(({ data, labels, width, height, anim
2619
2596
  }, [animate, width]);
2620
2597
  const activeX = activeIndex !== null ? seriesPoints[0]?.[activeIndex]?.x ?? null : null;
2621
2598
  const curveClipId = "curve-area-clip";
2622
- return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)(
2599
+ return /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)(
2623
2600
  "svg",
2624
2601
  {
2625
2602
  viewBox: `0 0 ${width} ${height}`,
2626
2603
  className: "chart-svg",
2627
2604
  onMouseMove: (e) => {
2628
2605
  handleMouseMove(e);
2629
- const svg = e.currentTarget;
2630
- const rect = svg.getBoundingClientRect();
2631
- const mx = (e.clientX - rect.left) / rect.width * svg.viewBox.baseVal.width;
2632
- const points = seriesPoints[0];
2633
- if (!points || points.length === 0) return;
2634
- const step = points.length > 1 ? Math.abs(points[1].x - points[0].x) : 20;
2635
- let closest = 0;
2636
- let minDist = Math.abs(points[0].x - mx);
2637
- for (let i = 1; i < points.length; i++) {
2638
- const dist = Math.abs(points[i].x - mx);
2639
- if (dist < minDist) {
2640
- minDist = dist;
2641
- closest = i;
2642
- }
2643
- }
2644
- if (minDist <= step / 2) {
2645
- onHover(e, `${labels[closest]} \u2014 ${getTooltipAt(closest)}`);
2606
+ if (activeIndex !== null && seriesPoints[0]?.[activeIndex]) {
2607
+ const p = seriesPoints[0][activeIndex];
2608
+ onShowAt(p.x, p.y, `${labels[activeIndex]} \u2014 ${getTooltipAt(activeIndex)}`);
2646
2609
  } else {
2647
2610
  onLeave();
2648
2611
  }
@@ -2652,9 +2615,9 @@ var CurveChart = import_react7.default.memo(({ data, labels, width, height, anim
2652
2615
  onLeave();
2653
2616
  },
2654
2617
  children: [
2655
- animate && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("clipPath", { id: curveClipId, children: /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("rect", { ref: curveClipRef, x: "0", y: "0", width: animate ? 0 : width, height }) }) }),
2656
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(GridLines, { width, height, chartH, maxVal }),
2657
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(AxisLabels, { labels, count, chartW, height }),
2618
+ animate && /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("clipPath", { id: curveClipId, children: /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("rect", { ref: curveClipRef, x: "0", y: "0", width: animate ? 0 : width, height }) }) }),
2619
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(GridLines, { width, height, chartH, maxVal }),
2620
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(AxisLabels, { labels, count, chartW, height }),
2658
2621
  entries.map(([key], di) => {
2659
2622
  const palette = getPalette(LINE_BAR_PALETTES, di, key);
2660
2623
  const color = palette[2];
@@ -2663,16 +2626,16 @@ var CurveChart = import_react7.default.memo(({ data, labels, width, height, anim
2663
2626
  const gradientId = `curve-gradient-${di}`;
2664
2627
  const linePath = toSmoothPath(points);
2665
2628
  const areaPath = linePath + ` L ${points[points.length - 1].x} ${PADDING.top + chartH} L ${points[0].x} ${PADDING.top + chartH} Z`;
2666
- return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("g", { children: [
2667
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("linearGradient", { id: gradientId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
2668
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("stop", { offset: "0%", stopColor: areaColor, stopOpacity: "0.4" }),
2669
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("stop", { offset: "100%", stopColor: areaColor, stopOpacity: "0.02" })
2629
+ return /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)("g", { children: [
2630
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)("linearGradient", { id: gradientId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
2631
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("stop", { offset: "0%", stopColor: areaColor, stopOpacity: "0.4" }),
2632
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("stop", { offset: "100%", stopColor: areaColor, stopOpacity: "0.02" })
2670
2633
  ] }) }),
2671
- /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("g", { clipPath: animate ? `url(#${curveClipId})` : void 0, children: [
2672
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("path", { d: areaPath, fill: `url(#${gradientId})` }),
2673
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("path", { d: linePath, fill: "none", stroke: color, strokeWidth: "2" })
2634
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)("g", { clipPath: animate ? `url(#${curveClipId})` : void 0, children: [
2635
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("path", { d: areaPath, fill: `url(#${gradientId})` }),
2636
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("path", { d: linePath, fill: "none", stroke: color, strokeWidth: "2" })
2674
2637
  ] }),
2675
- activeIndex !== null && points[activeIndex] && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
2638
+ activeIndex !== null && points[activeIndex] && /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(
2676
2639
  "circle",
2677
2640
  {
2678
2641
  cx: points[activeIndex].x,
@@ -2684,7 +2647,7 @@ var CurveChart = import_react7.default.memo(({ data, labels, width, height, anim
2684
2647
  )
2685
2648
  ] }, di);
2686
2649
  }),
2687
- activeX !== null && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
2650
+ activeX !== null && /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(
2688
2651
  "line",
2689
2652
  {
2690
2653
  x1: activeX,
@@ -2694,7 +2657,7 @@ var CurveChart = import_react7.default.memo(({ data, labels, width, height, anim
2694
2657
  className: "chart-crosshair"
2695
2658
  }
2696
2659
  ),
2697
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
2660
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(
2698
2661
  "rect",
2699
2662
  {
2700
2663
  x: PADDING.left,
@@ -2710,9 +2673,9 @@ var CurveChart = import_react7.default.memo(({ data, labels, width, height, anim
2710
2673
  );
2711
2674
  });
2712
2675
  CurveChart.displayName = "CurveChart";
2713
- var BarChart = import_react7.default.memo(({ data, labels, width, height, animate, onHover, onMove, onLeave }) => {
2714
- const entries = import_react7.default.useMemo(() => Object.entries(data), [data]);
2715
- const maxVal = import_react7.default.useMemo(() => {
2676
+ var BarChart = import_react6.default.memo(({ data, labels, width, height, animate, onHover, onShowAt, onMove, onLeave }) => {
2677
+ const entries = import_react6.default.useMemo(() => Object.entries(data), [data]);
2678
+ const maxVal = import_react6.default.useMemo(() => {
2716
2679
  const allValues = entries.flatMap(([, v]) => v);
2717
2680
  return Math.max(...allValues) * 1.2 || 1;
2718
2681
  }, [entries]);
@@ -2724,7 +2687,7 @@ var BarChart = import_react7.default.memo(({ data, labels, width, height, animat
2724
2687
  const barGap = groupCount > 1 ? 2 : 0;
2725
2688
  const barW = Math.max(1, Math.min(32, (groupW * 0.7 - barGap * (groupCount - 1)) / groupCount));
2726
2689
  const baseline = PADDING.top + chartH;
2727
- const bars = import_react7.default.useMemo(
2690
+ const bars = import_react6.default.useMemo(
2728
2691
  () => entries.map(
2729
2692
  ([, values], di) => values.map((v, i) => {
2730
2693
  const totalBarsW = barW * groupCount + barGap * (groupCount - 1);
@@ -2737,11 +2700,11 @@ var BarChart = import_react7.default.memo(({ data, labels, width, height, animat
2737
2700
  [entries, maxVal, chartH, groupW, barW, barGap, groupCount]
2738
2701
  );
2739
2702
  const barLabelStep = getLabelStep(count, chartW);
2740
- return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("svg", { viewBox: `0 0 ${width} ${height}`, className: "chart-svg", children: [
2741
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(GridLines, { width, height, chartH, maxVal }),
2703
+ return /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)("svg", { viewBox: `0 0 ${width} ${height}`, className: "chart-svg", children: [
2704
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(GridLines, { width, height, chartH, maxVal }),
2742
2705
  labels.map((label, i) => {
2743
2706
  if (i % barLabelStep !== 0) return null;
2744
- return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("text", { x: PADDING.left + groupW * i + groupW / 2, y: height - 8, className: "chart-axis-label", textAnchor: "middle", children: label }, i);
2707
+ return /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("text", { x: PADDING.left + groupW * i + groupW / 2, y: height - 8, className: "chart-axis-label", textAnchor: "middle", children: label }, i);
2745
2708
  }),
2746
2709
  entries.map(([key], di) => {
2747
2710
  const palette = getPalette(LINE_BAR_PALETTES, di, key);
@@ -2750,7 +2713,7 @@ var BarChart = import_react7.default.memo(({ data, labels, width, height, animat
2750
2713
  const r2 = Math.min(4, b.w / 2);
2751
2714
  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`;
2752
2715
  const delay = 100 + i * 80;
2753
- return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
2716
+ return /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(
2754
2717
  "path",
2755
2718
  {
2756
2719
  d,
@@ -2760,8 +2723,7 @@ var BarChart = import_react7.default.memo(({ data, labels, width, height, animat
2760
2723
  transformOrigin: `${b.x + b.w / 2}px ${baseline}px`,
2761
2724
  animationDelay: `${delay}ms`
2762
2725
  } : void 0,
2763
- onMouseEnter: (e) => onHover(e, `${key}: ${labels[i]} \u2014 ${b.v}`),
2764
- onMouseMove: onMove,
2726
+ onMouseEnter: () => onShowAt(b.x + b.w / 2, b.y, `${key}: ${labels[i]} \u2014 ${b.v}`),
2765
2727
  onMouseLeave: onLeave
2766
2728
  },
2767
2729
  `${di}-${i}`
@@ -2771,11 +2733,11 @@ var BarChart = import_react7.default.memo(({ data, labels, width, height, animat
2771
2733
  ] });
2772
2734
  });
2773
2735
  BarChart.displayName = "BarChart";
2774
- var PieDonutChart = import_react7.default.memo(
2736
+ var PieDonutChart = import_react6.default.memo(
2775
2737
  ({ data, labels, width, height, animate, isDoughnut, onHover, onMove, onLeave }) => {
2776
- const entries = import_react7.default.useMemo(() => Object.entries(data), [data]);
2777
- const values = import_react7.default.useMemo(() => entries.flatMap(([, v]) => v), [entries]);
2778
- const total = import_react7.default.useMemo(() => values.reduce((a, b) => a + b, 0) || 1, [values]);
2738
+ const entries = import_react6.default.useMemo(() => Object.entries(data), [data]);
2739
+ const values = import_react6.default.useMemo(() => entries.flatMap(([, v]) => v), [entries]);
2740
+ const total = import_react6.default.useMemo(() => values.reduce((a, b) => a + b, 0) || 1, [values]);
2779
2741
  const size = Math.min(width, height);
2780
2742
  const cx = size / 2;
2781
2743
  const cy = size / 2;
@@ -2783,10 +2745,10 @@ var PieDonutChart = import_react7.default.memo(
2783
2745
  const innerR = isDoughnut ? r2 * 0.5 : 0;
2784
2746
  const firstKey = entries[0]?.[0] ?? "";
2785
2747
  const colorOffset = hashString(firstKey);
2786
- const maskRef = import_react7.default.useRef(null);
2748
+ const maskRef = import_react6.default.useRef(null);
2787
2749
  const maskR = r2 + 10;
2788
2750
  const maskCircumference = 2 * Math.PI * maskR;
2789
- import_react7.default.useEffect(() => {
2751
+ import_react6.default.useEffect(() => {
2790
2752
  if (!animate || !maskRef.current) return;
2791
2753
  const el = maskRef.current;
2792
2754
  el.style.strokeDasharray = `${maskCircumference}`;
@@ -2796,7 +2758,7 @@ var PieDonutChart = import_react7.default.memo(
2796
2758
  el.style.strokeDashoffset = "0";
2797
2759
  });
2798
2760
  }, [animate, maskCircumference]);
2799
- const sliceData = import_react7.default.useMemo(() => {
2761
+ const sliceData = import_react6.default.useMemo(() => {
2800
2762
  let angle0 = -Math.PI / 2;
2801
2763
  let cumulativeAngle = 0;
2802
2764
  return values.map((v, i) => {
@@ -2830,8 +2792,8 @@ var PieDonutChart = import_react7.default.memo(
2830
2792
  });
2831
2793
  }, [values, total, cx, cy, r2, innerR, labels]);
2832
2794
  const maskId = `pie-mask-${isDoughnut ? "d" : "p"}`;
2833
- return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("svg", { viewBox: `0 0 ${size} ${size}`, className: "chart-svg chart-pie", children: [
2834
- animate && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("mask", { id: maskId, children: /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
2795
+ return /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)("svg", { viewBox: `0 0 ${size} ${size}`, className: "chart-svg chart-pie", children: [
2796
+ animate && /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("mask", { id: maskId, children: /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(
2835
2797
  "circle",
2836
2798
  {
2837
2799
  ref: maskRef,
@@ -2844,56 +2806,39 @@ var PieDonutChart = import_react7.default.memo(
2844
2806
  transform: `rotate(-90 ${cx} ${cy})`
2845
2807
  }
2846
2808
  ) }) }),
2847
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("g", { mask: animate ? `url(#${maskId})` : void 0, children: sliceData.map((s, i) => /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("g", { children: /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
2809
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("g", { mask: animate ? `url(#${maskId})` : void 0, children: sliceData.map((s, i) => /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("g", { children: /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(
2848
2810
  "path",
2849
2811
  {
2850
2812
  d: s.d,
2851
2813
  fill: PIE_COLORS[(i + colorOffset) % PIE_COLORS.length],
2852
- className: "chart-slice",
2853
- onMouseEnter: (e) => onHover(e, `${s.label}: ${s.v} (${s.pct}%)`),
2854
- onMouseMove: onMove,
2855
- onMouseLeave: onLeave
2814
+ className: "chart-slice"
2856
2815
  }
2857
- ) }, i)) }),
2858
- sliceData.map((s, i) => s.angle > 0.2 && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
2859
- "text",
2860
- {
2861
- x: s.lx,
2862
- y: s.ly,
2863
- className: `chart-pie-label ${animate ? "chart-pie-label-animate" : ""}`,
2864
- style: animate ? { animationDelay: `${s.labelDelay}ms` } : void 0,
2865
- textAnchor: "middle",
2866
- dominantBaseline: "central",
2867
- children: s.v
2868
- },
2869
- `label-${i}`
2870
- ))
2816
+ ) }, i)) })
2871
2817
  ] });
2872
2818
  }
2873
2819
  );
2874
2820
  PieDonutChart.displayName = "PieDonutChart";
2875
- var ChartTooltipPortal = ({ clientX, clientY, visible, children }) => {
2876
- const ref = import_react7.default.useRef(null);
2877
- const [pos, setPos] = import_react7.default.useState({ left: 0, top: 0 });
2878
- import_react7.default.useLayoutEffect(() => {
2821
+ var ChartTooltip = ({ x, y, containerWidth, containerHeight, children }) => {
2822
+ const ref = import_react6.default.useRef(null);
2823
+ const [pos, setPos] = import_react6.default.useState({ left: 0, top: 0 });
2824
+ import_react6.default.useLayoutEffect(() => {
2879
2825
  const el = ref.current;
2880
2826
  if (!el) return;
2881
2827
  const w = el.offsetWidth;
2882
2828
  const h = el.offsetHeight;
2883
- const vw = window.innerWidth;
2884
- let left = clientX + TOOLTIP_OFFSET;
2885
- let top = clientY - h - TOOLTIP_OFFSET;
2886
- if (left + w > vw - 8) left = clientX - w - TOOLTIP_OFFSET;
2887
- if (top < 8) top = clientY + TOOLTIP_OFFSET;
2888
- if (left < 8) left = 8;
2829
+ let left = x + TOOLTIP_OFFSET;
2830
+ let top = y - h - TOOLTIP_OFFSET;
2831
+ if (left + w > containerWidth) left = x - w - TOOLTIP_OFFSET;
2832
+ if (top < 0) top = y + TOOLTIP_OFFSET;
2833
+ if (left < 0) left = 0;
2889
2834
  setPos({ left, top });
2890
- }, [clientX, clientY]);
2891
- return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
2835
+ }, [x, y, containerWidth, containerHeight]);
2836
+ return /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(
2892
2837
  "div",
2893
2838
  {
2894
2839
  ref,
2895
- className: `chart-tooltip ${visible ? "chart-tooltip-show" : "chart-tooltip-hide"}`,
2896
- style: { position: "fixed", left: pos.left, top: pos.top, zIndex: 1100 },
2840
+ className: "chart-tooltip chart-tooltip-show",
2841
+ style: { left: pos.left, top: pos.top },
2897
2842
  children
2898
2843
  }
2899
2844
  );
@@ -2905,14 +2850,14 @@ var ChartLegend = ({ data, labels, type }) => {
2905
2850
  const total = values.reduce((a, b) => a + b, 0) || 1;
2906
2851
  const firstKey = entries[0]?.[0] ?? "";
2907
2852
  const colorOffset = hashString(firstKey);
2908
- return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("div", { className: "chart-legend", children: values.map((v, i) => {
2853
+ return /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("div", { className: "chart-legend", children: values.map((v, i) => {
2909
2854
  const pct = Math.round(v / total * 100);
2910
2855
  const color = PIE_COLORS[(i + colorOffset) % PIE_COLORS.length];
2911
- return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("div", { className: "chart-legend-item", children: [
2912
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("span", { className: "chart-legend-dot", style: { backgroundColor: color } }),
2913
- /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("div", { className: "chart-legend-text", children: [
2914
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("span", { className: "chart-legend-label", children: labels[i] || `${i + 1}` }),
2915
- /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("span", { className: "chart-legend-value", children: [
2856
+ return /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)("div", { className: "chart-legend-item", children: [
2857
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("span", { className: "chart-legend-dot", style: { backgroundColor: color } }),
2858
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)("div", { className: "chart-legend-text", children: [
2859
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("span", { className: "chart-legend-label", children: labels[i] || `${i + 1}` }),
2860
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)("span", { className: "chart-legend-value", children: [
2916
2861
  v.toLocaleString(),
2917
2862
  "(",
2918
2863
  pct,
@@ -2922,37 +2867,37 @@ var ChartLegend = ({ data, labels, type }) => {
2922
2867
  ] }, i);
2923
2868
  }) });
2924
2869
  }
2925
- return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("div", { className: "chart-legend", children: entries.map(([key], di) => {
2870
+ return /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("div", { className: "chart-legend", children: entries.map(([key], di) => {
2926
2871
  const palette = getPalette(LINE_BAR_PALETTES, di, key);
2927
2872
  const color = palette[2];
2928
2873
  const values = entries[di][1];
2929
2874
  const sum = values.reduce((a, b) => a + b, 0);
2930
- return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("div", { className: "chart-legend-item", children: [
2931
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("span", { className: "chart-legend-dot", style: { backgroundColor: color } }),
2932
- /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("div", { className: "chart-legend-text", children: [
2933
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("span", { className: "chart-legend-label", children: key }),
2934
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("span", { className: "chart-legend-value", children: sum.toLocaleString() })
2875
+ return /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)("div", { className: "chart-legend-item", children: [
2876
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("span", { className: "chart-legend-dot", style: { backgroundColor: color } }),
2877
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)("div", { className: "chart-legend-text", children: [
2878
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("span", { className: "chart-legend-label", children: key }),
2879
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("span", { className: "chart-legend-value", children: sum.toLocaleString() })
2935
2880
  ] })
2936
2881
  ] }, di);
2937
2882
  }) });
2938
2883
  };
2939
- var Chart = import_react7.default.memo((props) => {
2884
+ var Chart = import_react6.default.memo((props) => {
2940
2885
  const { type, data, labels, tooltip: showTooltip = true } = props;
2941
- const { tooltip, show, hide, move, containerRef } = useChartTooltip(showTooltip);
2886
+ const { tooltip, show, showAt, hide, move, containerRef } = useChartTooltip(showTooltip);
2942
2887
  const { width, height } = useChartSize(containerRef);
2943
- const stableData = import_react7.default.useMemo(() => data, [JSON.stringify(data)]);
2944
- const stableLabels = import_react7.default.useMemo(() => labels, [JSON.stringify(labels)]);
2945
- const dataKey = import_react7.default.useMemo(() => JSON.stringify(labels), [labels]);
2888
+ const stableData = import_react6.default.useMemo(() => data, [JSON.stringify(data)]);
2889
+ const stableLabels = import_react6.default.useMemo(() => labels, [JSON.stringify(labels)]);
2890
+ const dataKey = import_react6.default.useMemo(() => JSON.stringify(labels), [labels]);
2946
2891
  const animate = useChartAnimation(containerRef, dataKey);
2947
2892
  const ready = width > 0 && height > 0;
2948
- return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("div", { className: "lib-xplat-chart", ref: containerRef, children: [
2949
- ready && type === "line" && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(LineChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
2950
- ready && type === "curve" && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(CurveChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
2951
- ready && type === "bar" && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(BarChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
2952
- ready && type === "pie" && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(PieDonutChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
2953
- ready && type === "doughnut" && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(PieDonutChart, { data: stableData, labels: stableLabels, width, height, animate, isDoughnut: true, onHover: show, onMove: move, onLeave: hide }),
2954
- ready && (type === "bar" || type === "pie" || type === "doughnut") && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(ChartLegend, { data: stableData, labels: stableLabels, type }),
2955
- tooltip.content && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(Portal_default, { children: /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(ChartTooltipPortal, { clientX: tooltip.clientX, clientY: tooltip.clientY, visible: tooltip.visible, children: tooltip.content }) })
2893
+ return /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)("div", { className: "lib-xplat-chart", ref: containerRef, children: [
2894
+ ready && type === "line" && /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(LineChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onShowAt: showAt, onMove: move, onLeave: hide }),
2895
+ ready && type === "curve" && /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(CurveChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onShowAt: showAt, onMove: move, onLeave: hide }),
2896
+ ready && type === "bar" && /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(BarChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onShowAt: showAt, onMove: move, onLeave: hide }),
2897
+ ready && type === "pie" && /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(PieDonutChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onShowAt: showAt, onMove: move, onLeave: hide }),
2898
+ ready && type === "doughnut" && /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(PieDonutChart, { data: stableData, labels: stableLabels, width, height, animate, isDoughnut: true, onHover: show, onShowAt: showAt, onMove: move, onLeave: hide }),
2899
+ ready && (type === "bar" || type === "pie" || type === "doughnut") && /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(ChartLegend, { data: stableData, labels: stableLabels, type }),
2900
+ tooltip.visible && tooltip.content && /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(ChartTooltip, { x: tooltip.x, y: tooltip.y, containerWidth: width, containerHeight: height, children: tooltip.content })
2956
2901
  ] });
2957
2902
  });
2958
2903
  Chart.displayName = "Chart";
@@ -2965,7 +2910,7 @@ var import_tokens_core = require("@x-plat/tokens-core");
2965
2910
  var import_tokens_core2 = require("@x-plat/tokens-core");
2966
2911
 
2967
2912
  // src/components/CheckBox/CheckBox.tsx
2968
- var import_jsx_runtime309 = require("react/jsx-runtime");
2913
+ var import_jsx_runtime308 = require("react/jsx-runtime");
2969
2914
  var CheckBox = (props) => {
2970
2915
  const {
2971
2916
  checked,
@@ -2983,8 +2928,8 @@ var CheckBox = (props) => {
2983
2928
  const checkedClasses = `checked`;
2984
2929
  const disabledClasses = "disabled";
2985
2930
  const boxClasses = disabled ? disabledClasses : checked ? checkedClasses : uncheckedClasses;
2986
- return /* @__PURE__ */ (0, import_jsx_runtime309.jsxs)("label", { className: clsx_default("lib-xplat-checkbox", size, type), children: [
2987
- /* @__PURE__ */ (0, import_jsx_runtime309.jsx)(
2931
+ return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("label", { className: clsx_default("lib-xplat-checkbox", size, type), children: [
2932
+ /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
2988
2933
  "input",
2989
2934
  {
2990
2935
  type: "checkbox",
@@ -2994,22 +2939,22 @@ var CheckBox = (props) => {
2994
2939
  ...rest
2995
2940
  }
2996
2941
  ),
2997
- /* @__PURE__ */ (0, import_jsx_runtime309.jsx)("span", { className: clsx_default("checkbox", boxClasses), children: /* @__PURE__ */ (0, import_jsx_runtime309.jsx)("span", { className: clsx_default("check-icon", { visible: checked }), children: /* @__PURE__ */ (0, import_jsx_runtime309.jsx)(CheckIcon_default, {}) }) }),
2998
- label && /* @__PURE__ */ (0, import_jsx_runtime309.jsx)("span", { className: "label", children: label })
2942
+ /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("span", { className: clsx_default("checkbox", boxClasses), children: /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("span", { className: clsx_default("check-icon", { visible: checked }), children: /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(CheckIcon_default, {}) }) }),
2943
+ label && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("span", { className: "label", children: label })
2999
2944
  ] });
3000
2945
  };
3001
2946
  CheckBox.displayName = "CheckBox";
3002
2947
  var CheckBox_default = CheckBox;
3003
2948
 
3004
2949
  // src/components/Chip/Chip.tsx
3005
- var import_jsx_runtime310 = require("react/jsx-runtime");
2950
+ var import_jsx_runtime309 = require("react/jsx-runtime");
3006
2951
  var Chip = (props) => {
3007
2952
  const {
3008
2953
  children,
3009
2954
  type = "primary",
3010
2955
  size = "md"
3011
2956
  } = props;
3012
- return /* @__PURE__ */ (0, import_jsx_runtime310.jsx)("div", { className: clsx_default("lib-xplat-chip", type, size), children });
2957
+ return /* @__PURE__ */ (0, import_jsx_runtime309.jsx)("div", { className: clsx_default("lib-xplat-chip", type, size), children });
3013
2958
  };
3014
2959
  Chip.displayName = "Chip";
3015
2960
  var Chip_default = Chip;
@@ -3018,20 +2963,20 @@ var Chip_default = Chip;
3018
2963
  var import_react13 = __toESM(require("react"), 1);
3019
2964
 
3020
2965
  // src/components/Input/Input.tsx
3021
- var import_react8 = __toESM(require("react"), 1);
2966
+ var import_react7 = __toESM(require("react"), 1);
3022
2967
 
3023
2968
  // src/components/Input/InputValidations.tsx
3024
- var import_jsx_runtime311 = require("react/jsx-runtime");
2969
+ var import_jsx_runtime310 = require("react/jsx-runtime");
3025
2970
  var InputValidations = (props) => {
3026
2971
  const { message, status = "default" } = props;
3027
- return /* @__PURE__ */ (0, import_jsx_runtime311.jsxs)("div", { className: clsx_default("lib-xplat-input-validation", status), children: [
3028
- /* @__PURE__ */ (0, import_jsx_runtime311.jsxs)("div", { className: "icon", children: [
3029
- status === "default" && /* @__PURE__ */ (0, import_jsx_runtime311.jsx)(InfoIcon_default, {}),
3030
- status === "success" && /* @__PURE__ */ (0, import_jsx_runtime311.jsx)(SuccessIcon_default, {}),
3031
- status === "warning" && /* @__PURE__ */ (0, import_jsx_runtime311.jsx)(InfoIcon_default, {}),
3032
- status === "error" && /* @__PURE__ */ (0, import_jsx_runtime311.jsx)(ErrorIcon_default, {})
2972
+ return /* @__PURE__ */ (0, import_jsx_runtime310.jsxs)("div", { className: clsx_default("lib-xplat-input-validation", status), children: [
2973
+ /* @__PURE__ */ (0, import_jsx_runtime310.jsxs)("div", { className: "icon", children: [
2974
+ status === "default" && /* @__PURE__ */ (0, import_jsx_runtime310.jsx)(InfoIcon_default, {}),
2975
+ status === "success" && /* @__PURE__ */ (0, import_jsx_runtime310.jsx)(SuccessIcon_default, {}),
2976
+ status === "warning" && /* @__PURE__ */ (0, import_jsx_runtime310.jsx)(InfoIcon_default, {}),
2977
+ status === "error" && /* @__PURE__ */ (0, import_jsx_runtime310.jsx)(ErrorIcon_default, {})
3033
2978
  ] }),
3034
- /* @__PURE__ */ (0, import_jsx_runtime311.jsx)("div", { className: "message", children: message })
2979
+ /* @__PURE__ */ (0, import_jsx_runtime310.jsx)("div", { className: "message", children: message })
3035
2980
  ] });
3036
2981
  };
3037
2982
  InputValidations.displayName = "InputValidations";
@@ -3072,8 +3017,8 @@ var handleTelBackspace = (prevValue, currValue) => {
3072
3017
  };
3073
3018
 
3074
3019
  // src/components/Input/Input.tsx
3075
- var import_jsx_runtime312 = require("react/jsx-runtime");
3076
- var import_react9 = require("react");
3020
+ var import_jsx_runtime311 = require("react/jsx-runtime");
3021
+ var import_react8 = require("react");
3077
3022
  var formatValue = (type, value) => {
3078
3023
  if (value === null || value === void 0) return "";
3079
3024
  const strValue = Array.isArray(value) ? String(value[0] ?? "") : String(value);
@@ -3121,7 +3066,7 @@ var parseValue = (type, value) => {
3121
3066
  return value;
3122
3067
  }
3123
3068
  };
3124
- var Input = import_react8.default.forwardRef((props, ref) => {
3069
+ var Input = import_react7.default.forwardRef((props, ref) => {
3125
3070
  const {
3126
3071
  value,
3127
3072
  onChange,
@@ -3147,13 +3092,13 @@ var Input = import_react8.default.forwardRef((props, ref) => {
3147
3092
  onChange(event);
3148
3093
  }
3149
3094
  };
3150
- return /* @__PURE__ */ (0, import_jsx_runtime312.jsxs)("div", { className: "lib-xplat-input-wrap", children: [
3151
- /* @__PURE__ */ (0, import_jsx_runtime312.jsxs)(
3095
+ return /* @__PURE__ */ (0, import_jsx_runtime311.jsxs)("div", { className: "lib-xplat-input-wrap", children: [
3096
+ /* @__PURE__ */ (0, import_jsx_runtime311.jsxs)(
3152
3097
  "div",
3153
3098
  {
3154
3099
  className: clsx_default("lib-xplat-input", size, disabled ? "disabled" : void 0),
3155
3100
  children: [
3156
- /* @__PURE__ */ (0, import_jsx_runtime312.jsx)(
3101
+ /* @__PURE__ */ (0, import_jsx_runtime311.jsx)(
3157
3102
  "input",
3158
3103
  {
3159
3104
  ...inputProps,
@@ -3164,11 +3109,11 @@ var Input = import_react8.default.forwardRef((props, ref) => {
3164
3109
  onChange: handleChange
3165
3110
  }
3166
3111
  ),
3167
- suffix && /* @__PURE__ */ (0, import_jsx_runtime312.jsx)("div", { className: "suffix", children: suffix })
3112
+ suffix && /* @__PURE__ */ (0, import_jsx_runtime311.jsx)("div", { className: "suffix", children: suffix })
3168
3113
  ]
3169
3114
  }
3170
3115
  ),
3171
- validations && /* @__PURE__ */ (0, import_jsx_runtime312.jsx)("div", { className: "lib-xplat-input-validation-wrap", children: validations?.map((validation, idx) => /* @__PURE__ */ (0, import_react9.createElement)(
3116
+ validations && /* @__PURE__ */ (0, import_jsx_runtime311.jsx)("div", { className: "lib-xplat-input-validation-wrap", children: validations?.map((validation, idx) => /* @__PURE__ */ (0, import_react8.createElement)(
3172
3117
  InputValidations_default,
3173
3118
  {
3174
3119
  ...validation,
@@ -3181,20 +3126,20 @@ Input.displayName = "Input";
3181
3126
  var Input_default = Input;
3182
3127
 
3183
3128
  // src/components/Input/PasswordInput/PasswordInput.tsx
3184
- var import_react10 = __toESM(require("react"), 1);
3185
- var import_jsx_runtime313 = require("react/jsx-runtime");
3186
- var PasswordInput = import_react10.default.forwardRef(
3129
+ var import_react9 = __toESM(require("react"), 1);
3130
+ var import_jsx_runtime312 = require("react/jsx-runtime");
3131
+ var PasswordInput = import_react9.default.forwardRef(
3187
3132
  (props, ref) => {
3188
3133
  const { reg: _reg, ...inputProps } = props;
3189
- const [isView, setIsView] = import_react10.default.useState(false);
3134
+ const [isView, setIsView] = import_react9.default.useState(false);
3190
3135
  const handleChangeView = () => {
3191
3136
  setIsView((prev) => !prev);
3192
3137
  };
3193
- return /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(
3138
+ return /* @__PURE__ */ (0, import_jsx_runtime312.jsx)(
3194
3139
  Input_default,
3195
3140
  {
3196
3141
  ...inputProps,
3197
- suffix: /* @__PURE__ */ (0, import_jsx_runtime313.jsx)("div", { className: "wrapper pointer", onClick: handleChangeView, children: isView ? /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(OpenEyeIcon_default, {}) : /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(CloseEyeIcon_default, {}) }),
3142
+ suffix: /* @__PURE__ */ (0, import_jsx_runtime312.jsx)("div", { className: "wrapper pointer", onClick: handleChangeView, children: isView ? /* @__PURE__ */ (0, import_jsx_runtime312.jsx)(OpenEyeIcon_default, {}) : /* @__PURE__ */ (0, import_jsx_runtime312.jsx)(CloseEyeIcon_default, {}) }),
3198
3143
  type: isView ? "text" : "password",
3199
3144
  ref
3200
3145
  }
@@ -3207,6 +3152,23 @@ var PasswordInput_default = PasswordInput;
3207
3152
  // src/components/Modal/Modal.tsx
3208
3153
  var import_react11 = __toESM(require("react"), 1);
3209
3154
  var import_react_dom2 = require("react-dom");
3155
+
3156
+ // src/tokens/hooks/Portal.tsx
3157
+ var import_react10 = __toESM(require("react"), 1);
3158
+ var import_react_dom = __toESM(require("react-dom"), 1);
3159
+ var import_jsx_runtime313 = require("react/jsx-runtime");
3160
+ var PortalContainerContext = import_react10.default.createContext(null);
3161
+ var PortalProvider = ({ container, children }) => /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(PortalContainerContext.Provider, { value: container, children });
3162
+ var Portal = ({ children }) => {
3163
+ const contextContainer = import_react10.default.useContext(PortalContainerContext);
3164
+ if (typeof document === "undefined") return null;
3165
+ const container = contextContainer ?? document.body;
3166
+ return import_react_dom.default.createPortal(children, container);
3167
+ };
3168
+ Portal.displayName = "Portal";
3169
+ var Portal_default = Portal;
3170
+
3171
+ // src/components/Modal/Modal.tsx
3210
3172
  var import_jsx_runtime314 = require("react/jsx-runtime");
3211
3173
  var ANIMATION_DURATION_MS = 200;
3212
3174
  var Modal = (props) => {