@x-plat/design-system 0.5.35 → 0.5.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -6628,25 +6628,8 @@ var CardTab = Object.assign(CardTabRoot, {
6628
6628
  var CardTab_default = CardTab;
6629
6629
 
6630
6630
  // src/components/Chart/Chart.tsx
6631
- var import_react7 = __toESM(require("react"), 1);
6632
-
6633
- // src/tokens/hooks/Portal.tsx
6634
6631
  var import_react6 = __toESM(require("react"), 1);
6635
- var import_react_dom = __toESM(require("react-dom"), 1);
6636
6632
  var import_jsx_runtime307 = require("react/jsx-runtime");
6637
- var PortalContainerContext = import_react6.default.createContext(null);
6638
- var PortalProvider = ({ container, children }) => /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(PortalContainerContext.Provider, { value: container, children });
6639
- var Portal = ({ children }) => {
6640
- const contextContainer = import_react6.default.useContext(PortalContainerContext);
6641
- if (typeof document === "undefined") return null;
6642
- const container = contextContainer ?? document.body;
6643
- return import_react_dom.default.createPortal(children, container);
6644
- };
6645
- Portal.displayName = "Portal";
6646
- var Portal_default = Portal;
6647
-
6648
- // src/components/Chart/Chart.tsx
6649
- var import_jsx_runtime308 = require("react/jsx-runtime");
6650
6633
  var CATEGORICAL_COUNT2 = 8;
6651
6634
  var LINE_BAR_PALETTES = Array.from({ length: CATEGORICAL_COUNT2 }, (_, i) => {
6652
6635
  const n = i + 1;
@@ -6692,11 +6675,11 @@ var toSmoothPath = (points) => {
6692
6675
  };
6693
6676
  var RESIZE_SETTLE_MS = 150;
6694
6677
  var useChartSize = (ref) => {
6695
- const [size, setSize] = import_react7.default.useState({ width: 0, height: 0 });
6696
- const settleTimer = import_react7.default.useRef(0);
6697
- const committedSize = import_react7.default.useRef({ width: 0, height: 0 });
6698
- const initialRef = import_react7.default.useRef(true);
6699
- import_react7.default.useEffect(() => {
6678
+ const [size, setSize] = import_react6.default.useState({ width: 0, height: 0 });
6679
+ const settleTimer = import_react6.default.useRef(0);
6680
+ const committedSize = import_react6.default.useRef({ width: 0, height: 0 });
6681
+ const initialRef = import_react6.default.useRef(true);
6682
+ import_react6.default.useEffect(() => {
6700
6683
  const el = ref.current;
6701
6684
  if (!el) return;
6702
6685
  const observer = new ResizeObserver((entries) => {
@@ -6738,10 +6721,10 @@ var useChartSize = (ref) => {
6738
6721
  };
6739
6722
  var prefersReducedMotion = () => typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
6740
6723
  var useChartAnimation = (containerRef, dataKey) => {
6741
- const [animate, setAnimate] = import_react7.default.useState(false);
6742
- const prevDataKey = import_react7.default.useRef(dataKey);
6743
- const hasAnimated = import_react7.default.useRef(false);
6744
- import_react7.default.useEffect(() => {
6724
+ const [animate, setAnimate] = import_react6.default.useState(false);
6725
+ const prevDataKey = import_react6.default.useRef(dataKey);
6726
+ const hasAnimated = import_react6.default.useRef(false);
6727
+ import_react6.default.useEffect(() => {
6745
6728
  if (prefersReducedMotion()) return;
6746
6729
  const el = containerRef.current;
6747
6730
  if (!el) return;
@@ -6757,7 +6740,7 @@ var useChartAnimation = (containerRef, dataKey) => {
6757
6740
  observer.observe(el);
6758
6741
  return () => observer.disconnect();
6759
6742
  }, [containerRef]);
6760
- import_react7.default.useEffect(() => {
6743
+ import_react6.default.useEffect(() => {
6761
6744
  if (dataKey !== prevDataKey.current) {
6762
6745
  prevDataKey.current = dataKey;
6763
6746
  if (prefersReducedMotion()) return;
@@ -6771,39 +6754,47 @@ var useChartAnimation = (containerRef, dataKey) => {
6771
6754
  };
6772
6755
  var TOOLTIP_OFFSET = 12;
6773
6756
  var useChartTooltip = (enabled) => {
6774
- const [tooltip, setTooltip] = import_react7.default.useState({
6757
+ const [tooltip, setTooltip] = import_react6.default.useState({
6775
6758
  visible: false,
6776
- clientX: 0,
6777
- clientY: 0,
6759
+ x: 0,
6760
+ y: 0,
6778
6761
  content: ""
6779
6762
  });
6780
- const containerRef = import_react7.default.useRef(null);
6781
- const rafRef = import_react7.default.useRef(0);
6782
- const move = import_react7.default.useCallback((e) => {
6763
+ const containerRef = import_react6.default.useRef(null);
6764
+ const rafRef = import_react6.default.useRef(0);
6765
+ const move = import_react6.default.useCallback((e) => {
6783
6766
  if (!enabled) return;
6784
6767
  const cx = e.clientX;
6785
6768
  const cy = e.clientY;
6786
6769
  cancelAnimationFrame(rafRef.current);
6787
6770
  rafRef.current = requestAnimationFrame(() => {
6788
- setTooltip((prev) => ({ ...prev, clientX: cx, clientY: cy }));
6771
+ const rect = containerRef.current?.getBoundingClientRect();
6772
+ if (!rect) return;
6773
+ setTooltip((prev) => ({ ...prev, x: cx - rect.left, y: cy - rect.top }));
6789
6774
  });
6790
6775
  }, [enabled]);
6791
- const show = import_react7.default.useCallback((e, content) => {
6776
+ const show = import_react6.default.useCallback((e, content) => {
6777
+ if (!enabled) return;
6778
+ const rect = containerRef.current?.getBoundingClientRect();
6779
+ if (!rect) return;
6780
+ setTooltip({ visible: true, x: e.clientX - rect.left, y: e.clientY - rect.top, content });
6781
+ }, [enabled]);
6782
+ const showAt = import_react6.default.useCallback((x, y, content) => {
6792
6783
  if (!enabled) return;
6793
- setTooltip({ visible: true, clientX: e.clientX, clientY: e.clientY, content });
6784
+ setTooltip({ visible: true, x, y, content });
6794
6785
  }, [enabled]);
6795
- const hide = import_react7.default.useCallback(() => {
6786
+ const hide = import_react6.default.useCallback(() => {
6796
6787
  cancelAnimationFrame(rafRef.current);
6797
6788
  setTooltip((prev) => ({ ...prev, visible: false }));
6798
6789
  }, []);
6799
- return { tooltip, show, hide, move, containerRef };
6790
+ return { tooltip, show, showAt, hide, move, containerRef };
6800
6791
  };
6801
- 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) => {
6792
+ 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) => {
6802
6793
  const y = PADDING.top + (1 - ratio) * chartH;
6803
6794
  const val = Math.round(maxVal * ratio);
6804
- return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("g", { children: [
6805
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("line", { x1: PADDING.left, y1: y, x2: width - PADDING.right, y2: y, className: "chart-grid" }),
6806
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("text", { x: PADDING.left - 8, y: y + 4, className: "chart-axis-label", textAnchor: "end", children: val })
6795
+ return /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)("g", { children: [
6796
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("line", { x1: PADDING.left, y1: y, x2: width - PADDING.right, y2: y, className: "chart-grid" }),
6797
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("text", { x: PADDING.left - 8, y: y + 4, className: "chart-axis-label", textAnchor: "end", children: val })
6807
6798
  ] }, ratio);
6808
6799
  }) }));
6809
6800
  GridLines.displayName = "GridLines";
@@ -6813,18 +6804,18 @@ var getLabelStep = (count, chartW) => {
6813
6804
  if (count <= maxLabels) return 1;
6814
6805
  return Math.ceil(count / maxLabels);
6815
6806
  };
6816
- var AxisLabels = import_react7.default.memo(({ labels, count, chartW, height }) => {
6807
+ var AxisLabels = import_react6.default.memo(({ labels, count, chartW, height }) => {
6817
6808
  const step = getLabelStep(count, chartW);
6818
- return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(import_jsx_runtime308.Fragment, { children: labels.map((label, i) => {
6809
+ return /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(import_jsx_runtime307.Fragment, { children: labels.map((label, i) => {
6819
6810
  if (i % step !== 0) return null;
6820
6811
  const x = PADDING.left + i / (count - 1 || 1) * chartW;
6821
- return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("text", { x, y: height - 8, className: "chart-axis-label", textAnchor: "middle", children: label }, i);
6812
+ return /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("text", { x, y: height - 8, className: "chart-axis-label", textAnchor: "middle", children: label }, i);
6822
6813
  }) });
6823
6814
  });
6824
6815
  AxisLabels.displayName = "AxisLabels";
6825
6816
  var useCrosshair = (seriesPoints, entries, labels, chartH) => {
6826
- const [activeIndex, setActiveIndex] = import_react7.default.useState(null);
6827
- const handleMouseMove = import_react7.default.useCallback((e) => {
6817
+ const [activeIndex, setActiveIndex] = import_react6.default.useState(null);
6818
+ const handleMouseMove = import_react6.default.useCallback((e) => {
6828
6819
  const svg = e.currentTarget;
6829
6820
  const rect = svg.getBoundingClientRect();
6830
6821
  const mx = (e.clientX - rect.left) / rect.width * svg.viewBox.baseVal.width;
@@ -6843,17 +6834,17 @@ var useCrosshair = (seriesPoints, entries, labels, chartH) => {
6843
6834
  }
6844
6835
  setActiveIndex(minDist <= threshold ? closest : null);
6845
6836
  }, [seriesPoints]);
6846
- const handleMouseLeave = import_react7.default.useCallback(() => {
6837
+ const handleMouseLeave = import_react6.default.useCallback(() => {
6847
6838
  setActiveIndex(null);
6848
6839
  }, []);
6849
- const tooltipContent = import_react7.default.useMemo(() => {
6840
+ const tooltipContent = import_react6.default.useMemo(() => {
6850
6841
  if (activeIndex === null) return "";
6851
6842
  return entries.map(([key], di) => {
6852
6843
  const p = seriesPoints[di]?.[activeIndex];
6853
6844
  return p ? `${key}: ${p.v}` : "";
6854
6845
  }).filter(Boolean).join(" / ");
6855
6846
  }, [activeIndex, entries, seriesPoints]);
6856
- const getTooltipAt = import_react7.default.useCallback((idx) => {
6847
+ const getTooltipAt = import_react6.default.useCallback((idx) => {
6857
6848
  return entries.map(([key], di) => {
6858
6849
  const p = seriesPoints[di]?.[idx];
6859
6850
  return p ? `${key}: ${p.v}` : "";
@@ -6861,16 +6852,16 @@ var useCrosshair = (seriesPoints, entries, labels, chartH) => {
6861
6852
  }, [entries, seriesPoints]);
6862
6853
  return { activeIndex, handleMouseMove, handleMouseLeave, tooltipContent, getTooltipAt };
6863
6854
  };
6864
- var LineChart = import_react7.default.memo(({ data, labels, width, height, animate, onHover, onMove, onLeave }) => {
6865
- const entries = import_react7.default.useMemo(() => Object.entries(data), [data]);
6866
- const maxVal = import_react7.default.useMemo(() => {
6855
+ var LineChart = import_react6.default.memo(({ data, labels, width, height, animate, onHover, onShowAt, onMove, onLeave }) => {
6856
+ const entries = import_react6.default.useMemo(() => Object.entries(data), [data]);
6857
+ const maxVal = import_react6.default.useMemo(() => {
6867
6858
  const allValues = entries.flatMap(([, v]) => v);
6868
6859
  return Math.max(...allValues) * 1.2 || 1;
6869
6860
  }, [entries]);
6870
6861
  const count = labels.length;
6871
6862
  const chartW = width - PADDING.left - PADDING.right;
6872
6863
  const chartH = height - PADDING.top - PADDING.bottom;
6873
- const seriesPoints = import_react7.default.useMemo(
6864
+ const seriesPoints = import_react6.default.useMemo(
6874
6865
  () => entries.map(
6875
6866
  ([, values]) => values.map((v, i) => ({
6876
6867
  x: PADDING.left + i / (count - 1 || 1) * chartW,
@@ -6880,9 +6871,9 @@ var LineChart = import_react7.default.memo(({ data, labels, width, height, anima
6880
6871
  ),
6881
6872
  [entries, count, chartW, chartH, maxVal]
6882
6873
  );
6883
- const clipRef = import_react7.default.useRef(null);
6874
+ const clipRef = import_react6.default.useRef(null);
6884
6875
  const { activeIndex, handleMouseMove, handleMouseLeave, getTooltipAt } = useCrosshair(seriesPoints, entries, labels, chartH);
6885
- import_react7.default.useEffect(() => {
6876
+ import_react6.default.useEffect(() => {
6886
6877
  if (!animate || !clipRef.current) return;
6887
6878
  clipRef.current.setAttribute("width", "0");
6888
6879
  requestAnimationFrame(() => {
@@ -6894,30 +6885,16 @@ var LineChart = import_react7.default.memo(({ data, labels, width, height, anima
6894
6885
  }, [animate, width]);
6895
6886
  const activeX = activeIndex !== null ? seriesPoints[0]?.[activeIndex]?.x ?? null : null;
6896
6887
  const lineClipId = "line-area-clip";
6897
- return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)(
6888
+ return /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)(
6898
6889
  "svg",
6899
6890
  {
6900
6891
  viewBox: `0 0 ${width} ${height}`,
6901
6892
  className: "chart-svg",
6902
6893
  onMouseMove: (e) => {
6903
6894
  handleMouseMove(e);
6904
- const svg = e.currentTarget;
6905
- const rect = svg.getBoundingClientRect();
6906
- const mx = (e.clientX - rect.left) / rect.width * svg.viewBox.baseVal.width;
6907
- const points = seriesPoints[0];
6908
- if (!points || points.length === 0) return;
6909
- const step = points.length > 1 ? Math.abs(points[1].x - points[0].x) : 20;
6910
- let closest = 0;
6911
- let minDist = Math.abs(points[0].x - mx);
6912
- for (let i = 1; i < points.length; i++) {
6913
- const dist = Math.abs(points[i].x - mx);
6914
- if (dist < minDist) {
6915
- minDist = dist;
6916
- closest = i;
6917
- }
6918
- }
6919
- if (minDist <= step / 2) {
6920
- onHover(e, `${labels[closest]} \u2014 ${getTooltipAt(closest)}`);
6895
+ if (activeIndex !== null && seriesPoints[0]?.[activeIndex]) {
6896
+ const p = seriesPoints[0][activeIndex];
6897
+ onShowAt(p.x, p.y, `${labels[activeIndex]} \u2014 ${getTooltipAt(activeIndex)}`);
6921
6898
  } else {
6922
6899
  onLeave();
6923
6900
  }
@@ -6927,9 +6904,9 @@ var LineChart = import_react7.default.memo(({ data, labels, width, height, anima
6927
6904
  onLeave();
6928
6905
  },
6929
6906
  children: [
6930
- 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 }) }) }),
6931
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(GridLines, { width, height, chartH, maxVal }),
6932
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(AxisLabels, { labels, count, chartW, height }),
6907
+ 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 }) }) }),
6908
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(GridLines, { width, height, chartH, maxVal }),
6909
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(AxisLabels, { labels, count, chartW, height }),
6933
6910
  entries.map(([key], di) => {
6934
6911
  const palette = getPalette(LINE_BAR_PALETTES, di, key);
6935
6912
  const color = palette[2];
@@ -6938,16 +6915,16 @@ var LineChart = import_react7.default.memo(({ data, labels, width, height, anima
6938
6915
  const gradientId = `line-gradient-${di}`;
6939
6916
  const polyPoints = points.map((p) => `${p.x},${p.y}`).join(" ");
6940
6917
  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`;
6941
- return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("g", { children: [
6942
- /* @__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: [
6943
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("stop", { offset: "0%", stopColor: areaColor, stopOpacity: "0.2" }),
6944
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("stop", { offset: "100%", stopColor: areaColor, stopOpacity: "0" })
6918
+ return /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)("g", { children: [
6919
+ /* @__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: [
6920
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("stop", { offset: "0%", stopColor: areaColor, stopOpacity: "0.2" }),
6921
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("stop", { offset: "100%", stopColor: areaColor, stopOpacity: "0" })
6945
6922
  ] }) }),
6946
- /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("g", { clipPath: animate ? `url(#${lineClipId})` : void 0, children: [
6947
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("path", { d: areaD, fill: `url(#${gradientId})` }),
6948
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("polyline", { points: polyPoints, fill: "none", stroke: color, strokeWidth: "2" })
6923
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)("g", { clipPath: animate ? `url(#${lineClipId})` : void 0, children: [
6924
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("path", { d: areaD, fill: `url(#${gradientId})` }),
6925
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("polyline", { points: polyPoints, fill: "none", stroke: color, strokeWidth: "2" })
6949
6926
  ] }),
6950
- activeIndex !== null && points[activeIndex] && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
6927
+ activeIndex !== null && points[activeIndex] && /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(
6951
6928
  "circle",
6952
6929
  {
6953
6930
  cx: points[activeIndex].x,
@@ -6959,7 +6936,7 @@ var LineChart = import_react7.default.memo(({ data, labels, width, height, anima
6959
6936
  )
6960
6937
  ] }, di);
6961
6938
  }),
6962
- activeX !== null && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
6939
+ activeX !== null && /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(
6963
6940
  "line",
6964
6941
  {
6965
6942
  x1: activeX,
@@ -6969,7 +6946,7 @@ var LineChart = import_react7.default.memo(({ data, labels, width, height, anima
6969
6946
  className: "chart-crosshair"
6970
6947
  }
6971
6948
  ),
6972
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
6949
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(
6973
6950
  "rect",
6974
6951
  {
6975
6952
  x: PADDING.left,
@@ -6985,16 +6962,16 @@ var LineChart = import_react7.default.memo(({ data, labels, width, height, anima
6985
6962
  );
6986
6963
  });
6987
6964
  LineChart.displayName = "LineChart";
6988
- var CurveChart = import_react7.default.memo(({ data, labels, width, height, animate, onHover, onMove, onLeave }) => {
6989
- const entries = import_react7.default.useMemo(() => Object.entries(data), [data]);
6990
- const maxVal = import_react7.default.useMemo(() => {
6965
+ var CurveChart = import_react6.default.memo(({ data, labels, width, height, animate, onHover, onShowAt, onMove, onLeave }) => {
6966
+ const entries = import_react6.default.useMemo(() => Object.entries(data), [data]);
6967
+ const maxVal = import_react6.default.useMemo(() => {
6991
6968
  const allValues = entries.flatMap(([, v]) => v);
6992
6969
  return Math.max(...allValues) * 1.2 || 1;
6993
6970
  }, [entries]);
6994
6971
  const count = labels.length;
6995
6972
  const chartW = width - PADDING.left - PADDING.right;
6996
6973
  const chartH = height - PADDING.top - PADDING.bottom;
6997
- const seriesPoints = import_react7.default.useMemo(
6974
+ const seriesPoints = import_react6.default.useMemo(
6998
6975
  () => entries.map(
6999
6976
  ([, values]) => values.map((v, i) => ({
7000
6977
  x: PADDING.left + i / (count - 1 || 1) * chartW,
@@ -7004,9 +6981,9 @@ var CurveChart = import_react7.default.memo(({ data, labels, width, height, anim
7004
6981
  ),
7005
6982
  [entries, count, chartW, chartH, maxVal]
7006
6983
  );
7007
- const curveClipRef = import_react7.default.useRef(null);
6984
+ const curveClipRef = import_react6.default.useRef(null);
7008
6985
  const { activeIndex, handleMouseMove, handleMouseLeave, getTooltipAt } = useCrosshair(seriesPoints, entries, labels, chartH);
7009
- import_react7.default.useEffect(() => {
6986
+ import_react6.default.useEffect(() => {
7010
6987
  if (!animate || !curveClipRef.current) return;
7011
6988
  curveClipRef.current.setAttribute("width", "0");
7012
6989
  requestAnimationFrame(() => {
@@ -7018,30 +6995,16 @@ var CurveChart = import_react7.default.memo(({ data, labels, width, height, anim
7018
6995
  }, [animate, width]);
7019
6996
  const activeX = activeIndex !== null ? seriesPoints[0]?.[activeIndex]?.x ?? null : null;
7020
6997
  const curveClipId = "curve-area-clip";
7021
- return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)(
6998
+ return /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)(
7022
6999
  "svg",
7023
7000
  {
7024
7001
  viewBox: `0 0 ${width} ${height}`,
7025
7002
  className: "chart-svg",
7026
7003
  onMouseMove: (e) => {
7027
7004
  handleMouseMove(e);
7028
- const svg = e.currentTarget;
7029
- const rect = svg.getBoundingClientRect();
7030
- const mx = (e.clientX - rect.left) / rect.width * svg.viewBox.baseVal.width;
7031
- const points = seriesPoints[0];
7032
- if (!points || points.length === 0) return;
7033
- const step = points.length > 1 ? Math.abs(points[1].x - points[0].x) : 20;
7034
- let closest = 0;
7035
- let minDist = Math.abs(points[0].x - mx);
7036
- for (let i = 1; i < points.length; i++) {
7037
- const dist = Math.abs(points[i].x - mx);
7038
- if (dist < minDist) {
7039
- minDist = dist;
7040
- closest = i;
7041
- }
7042
- }
7043
- if (minDist <= step / 2) {
7044
- onHover(e, `${labels[closest]} \u2014 ${getTooltipAt(closest)}`);
7005
+ if (activeIndex !== null && seriesPoints[0]?.[activeIndex]) {
7006
+ const p = seriesPoints[0][activeIndex];
7007
+ onShowAt(p.x, p.y, `${labels[activeIndex]} \u2014 ${getTooltipAt(activeIndex)}`);
7045
7008
  } else {
7046
7009
  onLeave();
7047
7010
  }
@@ -7051,9 +7014,9 @@ var CurveChart = import_react7.default.memo(({ data, labels, width, height, anim
7051
7014
  onLeave();
7052
7015
  },
7053
7016
  children: [
7054
- 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 }) }) }),
7055
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(GridLines, { width, height, chartH, maxVal }),
7056
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(AxisLabels, { labels, count, chartW, height }),
7017
+ 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 }) }) }),
7018
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(GridLines, { width, height, chartH, maxVal }),
7019
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(AxisLabels, { labels, count, chartW, height }),
7057
7020
  entries.map(([key], di) => {
7058
7021
  const palette = getPalette(LINE_BAR_PALETTES, di, key);
7059
7022
  const color = palette[2];
@@ -7062,16 +7025,16 @@ var CurveChart = import_react7.default.memo(({ data, labels, width, height, anim
7062
7025
  const gradientId = `curve-gradient-${di}`;
7063
7026
  const linePath = toSmoothPath(points);
7064
7027
  const areaPath = linePath + ` L ${points[points.length - 1].x} ${PADDING.top + chartH} L ${points[0].x} ${PADDING.top + chartH} Z`;
7065
- return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("g", { children: [
7066
- /* @__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: [
7067
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("stop", { offset: "0%", stopColor: areaColor, stopOpacity: "0.4" }),
7068
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("stop", { offset: "100%", stopColor: areaColor, stopOpacity: "0.02" })
7028
+ return /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)("g", { children: [
7029
+ /* @__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: [
7030
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("stop", { offset: "0%", stopColor: areaColor, stopOpacity: "0.4" }),
7031
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("stop", { offset: "100%", stopColor: areaColor, stopOpacity: "0.02" })
7069
7032
  ] }) }),
7070
- /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("g", { clipPath: animate ? `url(#${curveClipId})` : void 0, children: [
7071
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("path", { d: areaPath, fill: `url(#${gradientId})` }),
7072
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("path", { d: linePath, fill: "none", stroke: color, strokeWidth: "2" })
7033
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)("g", { clipPath: animate ? `url(#${curveClipId})` : void 0, children: [
7034
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("path", { d: areaPath, fill: `url(#${gradientId})` }),
7035
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("path", { d: linePath, fill: "none", stroke: color, strokeWidth: "2" })
7073
7036
  ] }),
7074
- activeIndex !== null && points[activeIndex] && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
7037
+ activeIndex !== null && points[activeIndex] && /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(
7075
7038
  "circle",
7076
7039
  {
7077
7040
  cx: points[activeIndex].x,
@@ -7083,7 +7046,7 @@ var CurveChart = import_react7.default.memo(({ data, labels, width, height, anim
7083
7046
  )
7084
7047
  ] }, di);
7085
7048
  }),
7086
- activeX !== null && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
7049
+ activeX !== null && /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(
7087
7050
  "line",
7088
7051
  {
7089
7052
  x1: activeX,
@@ -7093,7 +7056,7 @@ var CurveChart = import_react7.default.memo(({ data, labels, width, height, anim
7093
7056
  className: "chart-crosshair"
7094
7057
  }
7095
7058
  ),
7096
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
7059
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(
7097
7060
  "rect",
7098
7061
  {
7099
7062
  x: PADDING.left,
@@ -7109,9 +7072,9 @@ var CurveChart = import_react7.default.memo(({ data, labels, width, height, anim
7109
7072
  );
7110
7073
  });
7111
7074
  CurveChart.displayName = "CurveChart";
7112
- var BarChart = import_react7.default.memo(({ data, labels, width, height, animate, onHover, onMove, onLeave }) => {
7113
- const entries = import_react7.default.useMemo(() => Object.entries(data), [data]);
7114
- const maxVal = import_react7.default.useMemo(() => {
7075
+ var BarChart = import_react6.default.memo(({ data, labels, width, height, animate, onHover, onShowAt, onMove, onLeave }) => {
7076
+ const entries = import_react6.default.useMemo(() => Object.entries(data), [data]);
7077
+ const maxVal = import_react6.default.useMemo(() => {
7115
7078
  const allValues = entries.flatMap(([, v]) => v);
7116
7079
  return Math.max(...allValues) * 1.2 || 1;
7117
7080
  }, [entries]);
@@ -7123,7 +7086,7 @@ var BarChart = import_react7.default.memo(({ data, labels, width, height, animat
7123
7086
  const barGap = groupCount > 1 ? 2 : 0;
7124
7087
  const barW = Math.max(1, Math.min(32, (groupW * 0.7 - barGap * (groupCount - 1)) / groupCount));
7125
7088
  const baseline = PADDING.top + chartH;
7126
- const bars = import_react7.default.useMemo(
7089
+ const bars = import_react6.default.useMemo(
7127
7090
  () => entries.map(
7128
7091
  ([, values], di) => values.map((v, i) => {
7129
7092
  const totalBarsW = barW * groupCount + barGap * (groupCount - 1);
@@ -7136,11 +7099,11 @@ var BarChart = import_react7.default.memo(({ data, labels, width, height, animat
7136
7099
  [entries, maxVal, chartH, groupW, barW, barGap, groupCount]
7137
7100
  );
7138
7101
  const barLabelStep = getLabelStep(count, chartW);
7139
- return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("svg", { viewBox: `0 0 ${width} ${height}`, className: "chart-svg", children: [
7140
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(GridLines, { width, height, chartH, maxVal }),
7102
+ return /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)("svg", { viewBox: `0 0 ${width} ${height}`, className: "chart-svg", children: [
7103
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(GridLines, { width, height, chartH, maxVal }),
7141
7104
  labels.map((label, i) => {
7142
7105
  if (i % barLabelStep !== 0) return null;
7143
- 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);
7106
+ 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);
7144
7107
  }),
7145
7108
  entries.map(([key], di) => {
7146
7109
  const palette = getPalette(LINE_BAR_PALETTES, di, key);
@@ -7149,7 +7112,7 @@ var BarChart = import_react7.default.memo(({ data, labels, width, height, animat
7149
7112
  const r2 = Math.min(4, b.w / 2);
7150
7113
  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`;
7151
7114
  const delay = 100 + i * 80;
7152
- return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
7115
+ return /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(
7153
7116
  "path",
7154
7117
  {
7155
7118
  d,
@@ -7159,8 +7122,7 @@ var BarChart = import_react7.default.memo(({ data, labels, width, height, animat
7159
7122
  transformOrigin: `${b.x + b.w / 2}px ${baseline}px`,
7160
7123
  animationDelay: `${delay}ms`
7161
7124
  } : void 0,
7162
- onMouseEnter: (e) => onHover(e, `${key}: ${labels[i]} \u2014 ${b.v}`),
7163
- onMouseMove: onMove,
7125
+ onMouseEnter: () => onShowAt(b.x + b.w / 2, b.y, `${key}: ${labels[i]} \u2014 ${b.v}`),
7164
7126
  onMouseLeave: onLeave
7165
7127
  },
7166
7128
  `${di}-${i}`
@@ -7170,11 +7132,11 @@ var BarChart = import_react7.default.memo(({ data, labels, width, height, animat
7170
7132
  ] });
7171
7133
  });
7172
7134
  BarChart.displayName = "BarChart";
7173
- var PieDonutChart = import_react7.default.memo(
7135
+ var PieDonutChart = import_react6.default.memo(
7174
7136
  ({ data, labels, width, height, animate, isDoughnut, onHover, onMove, onLeave }) => {
7175
- const entries = import_react7.default.useMemo(() => Object.entries(data), [data]);
7176
- const values = import_react7.default.useMemo(() => entries.flatMap(([, v]) => v), [entries]);
7177
- const total = import_react7.default.useMemo(() => values.reduce((a, b) => a + b, 0) || 1, [values]);
7137
+ const entries = import_react6.default.useMemo(() => Object.entries(data), [data]);
7138
+ const values = import_react6.default.useMemo(() => entries.flatMap(([, v]) => v), [entries]);
7139
+ const total = import_react6.default.useMemo(() => values.reduce((a, b) => a + b, 0) || 1, [values]);
7178
7140
  const size = Math.min(width, height);
7179
7141
  const cx = size / 2;
7180
7142
  const cy = size / 2;
@@ -7182,10 +7144,10 @@ var PieDonutChart = import_react7.default.memo(
7182
7144
  const innerR = isDoughnut ? r2 * 0.5 : 0;
7183
7145
  const firstKey = entries[0]?.[0] ?? "";
7184
7146
  const colorOffset = hashString(firstKey);
7185
- const maskRef = import_react7.default.useRef(null);
7147
+ const maskRef = import_react6.default.useRef(null);
7186
7148
  const maskR = r2 + 10;
7187
7149
  const maskCircumference = 2 * Math.PI * maskR;
7188
- import_react7.default.useEffect(() => {
7150
+ import_react6.default.useEffect(() => {
7189
7151
  if (!animate || !maskRef.current) return;
7190
7152
  const el = maskRef.current;
7191
7153
  el.style.strokeDasharray = `${maskCircumference}`;
@@ -7195,7 +7157,7 @@ var PieDonutChart = import_react7.default.memo(
7195
7157
  el.style.strokeDashoffset = "0";
7196
7158
  });
7197
7159
  }, [animate, maskCircumference]);
7198
- const sliceData = import_react7.default.useMemo(() => {
7160
+ const sliceData = import_react6.default.useMemo(() => {
7199
7161
  let angle0 = -Math.PI / 2;
7200
7162
  let cumulativeAngle = 0;
7201
7163
  return values.map((v, i) => {
@@ -7229,8 +7191,8 @@ var PieDonutChart = import_react7.default.memo(
7229
7191
  });
7230
7192
  }, [values, total, cx, cy, r2, innerR, labels]);
7231
7193
  const maskId = `pie-mask-${isDoughnut ? "d" : "p"}`;
7232
- return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("svg", { viewBox: `0 0 ${size} ${size}`, className: "chart-svg chart-pie", children: [
7233
- 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)(
7194
+ return /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)("svg", { viewBox: `0 0 ${size} ${size}`, className: "chart-svg chart-pie", children: [
7195
+ 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)(
7234
7196
  "circle",
7235
7197
  {
7236
7198
  ref: maskRef,
@@ -7243,56 +7205,39 @@ var PieDonutChart = import_react7.default.memo(
7243
7205
  transform: `rotate(-90 ${cx} ${cy})`
7244
7206
  }
7245
7207
  ) }) }),
7246
- /* @__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)(
7208
+ /* @__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)(
7247
7209
  "path",
7248
7210
  {
7249
7211
  d: s.d,
7250
7212
  fill: PIE_COLORS[(i + colorOffset) % PIE_COLORS.length],
7251
- className: "chart-slice",
7252
- onMouseEnter: (e) => onHover(e, `${s.label}: ${s.v} (${s.pct}%)`),
7253
- onMouseMove: onMove,
7254
- onMouseLeave: onLeave
7213
+ className: "chart-slice"
7255
7214
  }
7256
- ) }, i)) }),
7257
- sliceData.map((s, i) => s.angle > 0.2 && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
7258
- "text",
7259
- {
7260
- x: s.lx,
7261
- y: s.ly,
7262
- className: `chart-pie-label ${animate ? "chart-pie-label-animate" : ""}`,
7263
- style: animate ? { animationDelay: `${s.labelDelay}ms` } : void 0,
7264
- textAnchor: "middle",
7265
- dominantBaseline: "central",
7266
- children: s.v
7267
- },
7268
- `label-${i}`
7269
- ))
7215
+ ) }, i)) })
7270
7216
  ] });
7271
7217
  }
7272
7218
  );
7273
7219
  PieDonutChart.displayName = "PieDonutChart";
7274
- var ChartTooltipPortal = ({ clientX, clientY, visible, children }) => {
7275
- const ref = import_react7.default.useRef(null);
7276
- const [pos, setPos] = import_react7.default.useState({ left: 0, top: 0 });
7277
- import_react7.default.useLayoutEffect(() => {
7220
+ var ChartTooltip = ({ x, y, containerWidth, containerHeight, children }) => {
7221
+ const ref = import_react6.default.useRef(null);
7222
+ const [pos, setPos] = import_react6.default.useState({ left: 0, top: 0 });
7223
+ import_react6.default.useLayoutEffect(() => {
7278
7224
  const el = ref.current;
7279
7225
  if (!el) return;
7280
7226
  const w = el.offsetWidth;
7281
7227
  const h = el.offsetHeight;
7282
- const vw = window.innerWidth;
7283
- let left = clientX + TOOLTIP_OFFSET;
7284
- let top = clientY - h - TOOLTIP_OFFSET;
7285
- if (left + w > vw - 8) left = clientX - w - TOOLTIP_OFFSET;
7286
- if (top < 8) top = clientY + TOOLTIP_OFFSET;
7287
- if (left < 8) left = 8;
7228
+ let left = x + TOOLTIP_OFFSET;
7229
+ let top = y - h - TOOLTIP_OFFSET;
7230
+ if (left + w > containerWidth) left = x - w - TOOLTIP_OFFSET;
7231
+ if (top < 0) top = y + TOOLTIP_OFFSET;
7232
+ if (left < 0) left = 0;
7288
7233
  setPos({ left, top });
7289
- }, [clientX, clientY]);
7290
- return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
7234
+ }, [x, y, containerWidth, containerHeight]);
7235
+ return /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(
7291
7236
  "div",
7292
7237
  {
7293
7238
  ref,
7294
- className: `chart-tooltip ${visible ? "chart-tooltip-show" : "chart-tooltip-hide"}`,
7295
- style: { position: "fixed", left: pos.left, top: pos.top, zIndex: 1100 },
7239
+ className: "chart-tooltip chart-tooltip-show",
7240
+ style: { left: pos.left, top: pos.top },
7296
7241
  children
7297
7242
  }
7298
7243
  );
@@ -7304,14 +7249,14 @@ var ChartLegend = ({ data, labels, type }) => {
7304
7249
  const total = values.reduce((a, b) => a + b, 0) || 1;
7305
7250
  const firstKey = entries[0]?.[0] ?? "";
7306
7251
  const colorOffset = hashString(firstKey);
7307
- return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("div", { className: "chart-legend", children: values.map((v, i) => {
7252
+ return /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("div", { className: "chart-legend", children: values.map((v, i) => {
7308
7253
  const pct = Math.round(v / total * 100);
7309
7254
  const color = PIE_COLORS[(i + colorOffset) % PIE_COLORS.length];
7310
- return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("div", { className: "chart-legend-item", children: [
7311
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("span", { className: "chart-legend-dot", style: { backgroundColor: color } }),
7312
- /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("div", { className: "chart-legend-text", children: [
7313
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("span", { className: "chart-legend-label", children: labels[i] || `${i + 1}` }),
7314
- /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("span", { className: "chart-legend-value", children: [
7255
+ return /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)("div", { className: "chart-legend-item", children: [
7256
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("span", { className: "chart-legend-dot", style: { backgroundColor: color } }),
7257
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)("div", { className: "chart-legend-text", children: [
7258
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("span", { className: "chart-legend-label", children: labels[i] || `${i + 1}` }),
7259
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)("span", { className: "chart-legend-value", children: [
7315
7260
  v.toLocaleString(),
7316
7261
  "(",
7317
7262
  pct,
@@ -7321,37 +7266,37 @@ var ChartLegend = ({ data, labels, type }) => {
7321
7266
  ] }, i);
7322
7267
  }) });
7323
7268
  }
7324
- return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("div", { className: "chart-legend", children: entries.map(([key], di) => {
7269
+ return /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("div", { className: "chart-legend", children: entries.map(([key], di) => {
7325
7270
  const palette = getPalette(LINE_BAR_PALETTES, di, key);
7326
7271
  const color = palette[2];
7327
7272
  const values = entries[di][1];
7328
7273
  const sum = values.reduce((a, b) => a + b, 0);
7329
- return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("div", { className: "chart-legend-item", children: [
7330
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("span", { className: "chart-legend-dot", style: { backgroundColor: color } }),
7331
- /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("div", { className: "chart-legend-text", children: [
7332
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("span", { className: "chart-legend-label", children: key }),
7333
- /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("span", { className: "chart-legend-value", children: sum.toLocaleString() })
7274
+ return /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)("div", { className: "chart-legend-item", children: [
7275
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("span", { className: "chart-legend-dot", style: { backgroundColor: color } }),
7276
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)("div", { className: "chart-legend-text", children: [
7277
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("span", { className: "chart-legend-label", children: key }),
7278
+ /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("span", { className: "chart-legend-value", children: sum.toLocaleString() })
7334
7279
  ] })
7335
7280
  ] }, di);
7336
7281
  }) });
7337
7282
  };
7338
- var Chart = import_react7.default.memo((props) => {
7283
+ var Chart = import_react6.default.memo((props) => {
7339
7284
  const { type, data, labels, tooltip: showTooltip = true } = props;
7340
- const { tooltip, show, hide, move, containerRef } = useChartTooltip(showTooltip);
7285
+ const { tooltip, show, showAt, hide, move, containerRef } = useChartTooltip(showTooltip);
7341
7286
  const { width, height } = useChartSize(containerRef);
7342
- const stableData = import_react7.default.useMemo(() => data, [JSON.stringify(data)]);
7343
- const stableLabels = import_react7.default.useMemo(() => labels, [JSON.stringify(labels)]);
7344
- const dataKey = import_react7.default.useMemo(() => JSON.stringify(labels), [labels]);
7287
+ const stableData = import_react6.default.useMemo(() => data, [JSON.stringify(data)]);
7288
+ const stableLabels = import_react6.default.useMemo(() => labels, [JSON.stringify(labels)]);
7289
+ const dataKey = import_react6.default.useMemo(() => JSON.stringify(labels), [labels]);
7345
7290
  const animate = useChartAnimation(containerRef, dataKey);
7346
7291
  const ready = width > 0 && height > 0;
7347
- return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("div", { className: "lib-xplat-chart", ref: containerRef, children: [
7348
- ready && type === "line" && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(LineChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
7349
- ready && type === "curve" && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(CurveChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
7350
- ready && type === "bar" && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(BarChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
7351
- ready && type === "pie" && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(PieDonutChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
7352
- 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 }),
7353
- ready && (type === "bar" || type === "pie" || type === "doughnut") && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(ChartLegend, { data: stableData, labels: stableLabels, type }),
7354
- 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 }) })
7292
+ return /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)("div", { className: "lib-xplat-chart", ref: containerRef, children: [
7293
+ 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 }),
7294
+ 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 }),
7295
+ 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 }),
7296
+ 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 }),
7297
+ 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 }),
7298
+ ready && (type === "bar" || type === "pie" || type === "doughnut") && /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(ChartLegend, { data: stableData, labels: stableLabels, type }),
7299
+ tooltip.visible && tooltip.content && /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(ChartTooltip, { x: tooltip.x, y: tooltip.y, containerWidth: width, containerHeight: height, children: tooltip.content })
7355
7300
  ] });
7356
7301
  });
7357
7302
  Chart.displayName = "Chart";
@@ -7377,7 +7322,7 @@ var import_tokens_core = require("@x-plat/tokens-core");
7377
7322
  var import_tokens_core2 = require("@x-plat/tokens-core");
7378
7323
 
7379
7324
  // src/components/CheckBox/CheckBox.tsx
7380
- var import_jsx_runtime309 = require("react/jsx-runtime");
7325
+ var import_jsx_runtime308 = require("react/jsx-runtime");
7381
7326
  var CheckBox = (props) => {
7382
7327
  const {
7383
7328
  checked,
@@ -7395,8 +7340,8 @@ var CheckBox = (props) => {
7395
7340
  const checkedClasses = `checked`;
7396
7341
  const disabledClasses = "disabled";
7397
7342
  const boxClasses = disabled ? disabledClasses : checked ? checkedClasses : uncheckedClasses;
7398
- return /* @__PURE__ */ (0, import_jsx_runtime309.jsxs)("label", { className: clsx_default("lib-xplat-checkbox", size, type), children: [
7399
- /* @__PURE__ */ (0, import_jsx_runtime309.jsx)(
7343
+ return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)("label", { className: clsx_default("lib-xplat-checkbox", size, type), children: [
7344
+ /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
7400
7345
  "input",
7401
7346
  {
7402
7347
  type: "checkbox",
@@ -7406,22 +7351,22 @@ var CheckBox = (props) => {
7406
7351
  ...rest
7407
7352
  }
7408
7353
  ),
7409
- /* @__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, {}) }) }),
7410
- label && /* @__PURE__ */ (0, import_jsx_runtime309.jsx)("span", { className: "label", children: label })
7354
+ /* @__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, {}) }) }),
7355
+ label && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("span", { className: "label", children: label })
7411
7356
  ] });
7412
7357
  };
7413
7358
  CheckBox.displayName = "CheckBox";
7414
7359
  var CheckBox_default = CheckBox;
7415
7360
 
7416
7361
  // src/components/Chip/Chip.tsx
7417
- var import_jsx_runtime310 = require("react/jsx-runtime");
7362
+ var import_jsx_runtime309 = require("react/jsx-runtime");
7418
7363
  var Chip = (props) => {
7419
7364
  const {
7420
7365
  children,
7421
7366
  type = "primary",
7422
7367
  size = "md"
7423
7368
  } = props;
7424
- return /* @__PURE__ */ (0, import_jsx_runtime310.jsx)("div", { className: clsx_default("lib-xplat-chip", type, size), children });
7369
+ return /* @__PURE__ */ (0, import_jsx_runtime309.jsx)("div", { className: clsx_default("lib-xplat-chip", type, size), children });
7425
7370
  };
7426
7371
  Chip.displayName = "Chip";
7427
7372
  var Chip_default = Chip;
@@ -7430,20 +7375,20 @@ var Chip_default = Chip;
7430
7375
  var import_react13 = __toESM(require("react"), 1);
7431
7376
 
7432
7377
  // src/components/Input/Input.tsx
7433
- var import_react8 = __toESM(require("react"), 1);
7378
+ var import_react7 = __toESM(require("react"), 1);
7434
7379
 
7435
7380
  // src/components/Input/InputValidations.tsx
7436
- var import_jsx_runtime311 = require("react/jsx-runtime");
7381
+ var import_jsx_runtime310 = require("react/jsx-runtime");
7437
7382
  var InputValidations = (props) => {
7438
7383
  const { message, status = "default" } = props;
7439
- return /* @__PURE__ */ (0, import_jsx_runtime311.jsxs)("div", { className: clsx_default("lib-xplat-input-validation", status), children: [
7440
- /* @__PURE__ */ (0, import_jsx_runtime311.jsxs)("div", { className: "icon", children: [
7441
- status === "default" && /* @__PURE__ */ (0, import_jsx_runtime311.jsx)(InfoIcon_default, {}),
7442
- status === "success" && /* @__PURE__ */ (0, import_jsx_runtime311.jsx)(SuccessIcon_default, {}),
7443
- status === "warning" && /* @__PURE__ */ (0, import_jsx_runtime311.jsx)(InfoIcon_default, {}),
7444
- status === "error" && /* @__PURE__ */ (0, import_jsx_runtime311.jsx)(ErrorIcon_default, {})
7384
+ return /* @__PURE__ */ (0, import_jsx_runtime310.jsxs)("div", { className: clsx_default("lib-xplat-input-validation", status), children: [
7385
+ /* @__PURE__ */ (0, import_jsx_runtime310.jsxs)("div", { className: "icon", children: [
7386
+ status === "default" && /* @__PURE__ */ (0, import_jsx_runtime310.jsx)(InfoIcon_default, {}),
7387
+ status === "success" && /* @__PURE__ */ (0, import_jsx_runtime310.jsx)(SuccessIcon_default, {}),
7388
+ status === "warning" && /* @__PURE__ */ (0, import_jsx_runtime310.jsx)(InfoIcon_default, {}),
7389
+ status === "error" && /* @__PURE__ */ (0, import_jsx_runtime310.jsx)(ErrorIcon_default, {})
7445
7390
  ] }),
7446
- /* @__PURE__ */ (0, import_jsx_runtime311.jsx)("div", { className: "message", children: message })
7391
+ /* @__PURE__ */ (0, import_jsx_runtime310.jsx)("div", { className: "message", children: message })
7447
7392
  ] });
7448
7393
  };
7449
7394
  InputValidations.displayName = "InputValidations";
@@ -7484,8 +7429,8 @@ var handleTelBackspace = (prevValue, currValue) => {
7484
7429
  };
7485
7430
 
7486
7431
  // src/components/Input/Input.tsx
7487
- var import_jsx_runtime312 = require("react/jsx-runtime");
7488
- var import_react9 = require("react");
7432
+ var import_jsx_runtime311 = require("react/jsx-runtime");
7433
+ var import_react8 = require("react");
7489
7434
  var formatValue = (type, value) => {
7490
7435
  if (value === null || value === void 0) return "";
7491
7436
  const strValue = Array.isArray(value) ? String(value[0] ?? "") : String(value);
@@ -7533,7 +7478,7 @@ var parseValue = (type, value) => {
7533
7478
  return value;
7534
7479
  }
7535
7480
  };
7536
- var Input = import_react8.default.forwardRef((props, ref) => {
7481
+ var Input = import_react7.default.forwardRef((props, ref) => {
7537
7482
  const {
7538
7483
  value,
7539
7484
  onChange,
@@ -7559,13 +7504,13 @@ var Input = import_react8.default.forwardRef((props, ref) => {
7559
7504
  onChange(event);
7560
7505
  }
7561
7506
  };
7562
- return /* @__PURE__ */ (0, import_jsx_runtime312.jsxs)("div", { className: "lib-xplat-input-wrap", children: [
7563
- /* @__PURE__ */ (0, import_jsx_runtime312.jsxs)(
7507
+ return /* @__PURE__ */ (0, import_jsx_runtime311.jsxs)("div", { className: "lib-xplat-input-wrap", children: [
7508
+ /* @__PURE__ */ (0, import_jsx_runtime311.jsxs)(
7564
7509
  "div",
7565
7510
  {
7566
7511
  className: clsx_default("lib-xplat-input", size, disabled ? "disabled" : void 0),
7567
7512
  children: [
7568
- /* @__PURE__ */ (0, import_jsx_runtime312.jsx)(
7513
+ /* @__PURE__ */ (0, import_jsx_runtime311.jsx)(
7569
7514
  "input",
7570
7515
  {
7571
7516
  ...inputProps,
@@ -7576,11 +7521,11 @@ var Input = import_react8.default.forwardRef((props, ref) => {
7576
7521
  onChange: handleChange
7577
7522
  }
7578
7523
  ),
7579
- suffix && /* @__PURE__ */ (0, import_jsx_runtime312.jsx)("div", { className: "suffix", children: suffix })
7524
+ suffix && /* @__PURE__ */ (0, import_jsx_runtime311.jsx)("div", { className: "suffix", children: suffix })
7580
7525
  ]
7581
7526
  }
7582
7527
  ),
7583
- validations && /* @__PURE__ */ (0, import_jsx_runtime312.jsx)("div", { className: "lib-xplat-input-validation-wrap", children: validations?.map((validation, idx) => /* @__PURE__ */ (0, import_react9.createElement)(
7528
+ validations && /* @__PURE__ */ (0, import_jsx_runtime311.jsx)("div", { className: "lib-xplat-input-validation-wrap", children: validations?.map((validation, idx) => /* @__PURE__ */ (0, import_react8.createElement)(
7584
7529
  InputValidations_default,
7585
7530
  {
7586
7531
  ...validation,
@@ -7593,20 +7538,20 @@ Input.displayName = "Input";
7593
7538
  var Input_default = Input;
7594
7539
 
7595
7540
  // src/components/Input/PasswordInput/PasswordInput.tsx
7596
- var import_react10 = __toESM(require("react"), 1);
7597
- var import_jsx_runtime313 = require("react/jsx-runtime");
7598
- var PasswordInput = import_react10.default.forwardRef(
7541
+ var import_react9 = __toESM(require("react"), 1);
7542
+ var import_jsx_runtime312 = require("react/jsx-runtime");
7543
+ var PasswordInput = import_react9.default.forwardRef(
7599
7544
  (props, ref) => {
7600
7545
  const { reg: _reg, ...inputProps } = props;
7601
- const [isView, setIsView] = import_react10.default.useState(false);
7546
+ const [isView, setIsView] = import_react9.default.useState(false);
7602
7547
  const handleChangeView = () => {
7603
7548
  setIsView((prev) => !prev);
7604
7549
  };
7605
- return /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(
7550
+ return /* @__PURE__ */ (0, import_jsx_runtime312.jsx)(
7606
7551
  Input_default,
7607
7552
  {
7608
7553
  ...inputProps,
7609
- 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, {}) }),
7554
+ 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, {}) }),
7610
7555
  type: isView ? "text" : "password",
7611
7556
  ref
7612
7557
  }
@@ -7619,6 +7564,23 @@ var PasswordInput_default = PasswordInput;
7619
7564
  // src/components/Modal/Modal.tsx
7620
7565
  var import_react11 = __toESM(require("react"), 1);
7621
7566
  var import_react_dom2 = require("react-dom");
7567
+
7568
+ // src/tokens/hooks/Portal.tsx
7569
+ var import_react10 = __toESM(require("react"), 1);
7570
+ var import_react_dom = __toESM(require("react-dom"), 1);
7571
+ var import_jsx_runtime313 = require("react/jsx-runtime");
7572
+ var PortalContainerContext = import_react10.default.createContext(null);
7573
+ var PortalProvider = ({ container, children }) => /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(PortalContainerContext.Provider, { value: container, children });
7574
+ var Portal = ({ children }) => {
7575
+ const contextContainer = import_react10.default.useContext(PortalContainerContext);
7576
+ if (typeof document === "undefined") return null;
7577
+ const container = contextContainer ?? document.body;
7578
+ return import_react_dom.default.createPortal(children, container);
7579
+ };
7580
+ Portal.displayName = "Portal";
7581
+ var Portal_default = Portal;
7582
+
7583
+ // src/components/Modal/Modal.tsx
7622
7584
  var import_jsx_runtime314 = require("react/jsx-runtime");
7623
7585
  var ANIMATION_DURATION_MS = 200;
7624
7586
  var Modal = (props) => {