@x-plat/design-system 0.5.33 → 0.5.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Chart/index.cjs +152 -192
- package/dist/components/Chart/index.css +4 -1
- package/dist/components/Chart/index.js +140 -180
- package/dist/components/index.cjs +183 -239
- package/dist/components/index.css +4 -1
- package/dist/components/index.js +165 -221
- package/dist/index.cjs +183 -239
- package/dist/index.css +4 -1
- package/dist/index.js +165 -221
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6628,8 +6628,25 @@ 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
|
|
6631
6634
|
var import_react6 = __toESM(require("react"), 1);
|
|
6635
|
+
var import_react_dom = __toESM(require("react-dom"), 1);
|
|
6632
6636
|
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");
|
|
6633
6650
|
var CATEGORICAL_COUNT2 = 8;
|
|
6634
6651
|
var LINE_BAR_PALETTES = Array.from({ length: CATEGORICAL_COUNT2 }, (_, i) => {
|
|
6635
6652
|
const n = i + 1;
|
|
@@ -6675,11 +6692,11 @@ var toSmoothPath = (points) => {
|
|
|
6675
6692
|
};
|
|
6676
6693
|
var RESIZE_SETTLE_MS = 150;
|
|
6677
6694
|
var useChartSize = (ref) => {
|
|
6678
|
-
const [size, setSize] =
|
|
6679
|
-
const settleTimer =
|
|
6680
|
-
const committedSize =
|
|
6681
|
-
const initialRef =
|
|
6682
|
-
|
|
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(() => {
|
|
6683
6700
|
const el = ref.current;
|
|
6684
6701
|
if (!el) return;
|
|
6685
6702
|
const observer = new ResizeObserver((entries) => {
|
|
@@ -6721,10 +6738,10 @@ var useChartSize = (ref) => {
|
|
|
6721
6738
|
};
|
|
6722
6739
|
var prefersReducedMotion = () => typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
6723
6740
|
var useChartAnimation = (containerRef, dataKey) => {
|
|
6724
|
-
const [animate, setAnimate] =
|
|
6725
|
-
const prevDataKey =
|
|
6726
|
-
const hasAnimated =
|
|
6727
|
-
|
|
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(() => {
|
|
6728
6745
|
if (prefersReducedMotion()) return;
|
|
6729
6746
|
const el = containerRef.current;
|
|
6730
6747
|
if (!el) return;
|
|
@@ -6740,27 +6757,29 @@ var useChartAnimation = (containerRef, dataKey) => {
|
|
|
6740
6757
|
observer.observe(el);
|
|
6741
6758
|
return () => observer.disconnect();
|
|
6742
6759
|
}, [containerRef]);
|
|
6743
|
-
|
|
6760
|
+
import_react7.default.useEffect(() => {
|
|
6744
6761
|
if (dataKey !== prevDataKey.current) {
|
|
6745
6762
|
prevDataKey.current = dataKey;
|
|
6746
6763
|
if (prefersReducedMotion()) return;
|
|
6747
6764
|
setAnimate(false);
|
|
6748
|
-
requestAnimationFrame(() =>
|
|
6765
|
+
requestAnimationFrame(() => {
|
|
6766
|
+
requestAnimationFrame(() => setAnimate(true));
|
|
6767
|
+
});
|
|
6749
6768
|
}
|
|
6750
6769
|
}, [dataKey]);
|
|
6751
6770
|
return animate || prefersReducedMotion();
|
|
6752
6771
|
};
|
|
6753
6772
|
var TOOLTIP_OFFSET = 12;
|
|
6754
6773
|
var useChartTooltip = (enabled) => {
|
|
6755
|
-
const [tooltip, setTooltip] =
|
|
6774
|
+
const [tooltip, setTooltip] = import_react7.default.useState({
|
|
6756
6775
|
visible: false,
|
|
6757
6776
|
clientX: 0,
|
|
6758
6777
|
clientY: 0,
|
|
6759
6778
|
content: ""
|
|
6760
6779
|
});
|
|
6761
|
-
const containerRef =
|
|
6762
|
-
const rafRef =
|
|
6763
|
-
const move =
|
|
6780
|
+
const containerRef = import_react7.default.useRef(null);
|
|
6781
|
+
const rafRef = import_react7.default.useRef(0);
|
|
6782
|
+
const move = import_react7.default.useCallback((e) => {
|
|
6764
6783
|
if (!enabled) return;
|
|
6765
6784
|
const cx = e.clientX;
|
|
6766
6785
|
const cy = e.clientY;
|
|
@@ -6769,22 +6788,22 @@ var useChartTooltip = (enabled) => {
|
|
|
6769
6788
|
setTooltip((prev) => ({ ...prev, clientX: cx, clientY: cy }));
|
|
6770
6789
|
});
|
|
6771
6790
|
}, [enabled]);
|
|
6772
|
-
const show =
|
|
6791
|
+
const show = import_react7.default.useCallback((e, content) => {
|
|
6773
6792
|
if (!enabled) return;
|
|
6774
6793
|
setTooltip({ visible: true, clientX: e.clientX, clientY: e.clientY, content });
|
|
6775
6794
|
}, [enabled]);
|
|
6776
|
-
const hide =
|
|
6795
|
+
const hide = import_react7.default.useCallback(() => {
|
|
6777
6796
|
cancelAnimationFrame(rafRef.current);
|
|
6778
6797
|
setTooltip((prev) => ({ ...prev, visible: false }));
|
|
6779
6798
|
}, []);
|
|
6780
6799
|
return { tooltip, show, hide, move, containerRef };
|
|
6781
6800
|
};
|
|
6782
|
-
var GridLines =
|
|
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) => {
|
|
6783
6802
|
const y = PADDING.top + (1 - ratio) * chartH;
|
|
6784
6803
|
const val = Math.round(maxVal * ratio);
|
|
6785
|
-
return /* @__PURE__ */ (0,
|
|
6786
|
-
/* @__PURE__ */ (0,
|
|
6787
|
-
/* @__PURE__ */ (0,
|
|
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 })
|
|
6788
6807
|
] }, ratio);
|
|
6789
6808
|
}) }));
|
|
6790
6809
|
GridLines.displayName = "GridLines";
|
|
@@ -6794,18 +6813,18 @@ var getLabelStep = (count, chartW) => {
|
|
|
6794
6813
|
if (count <= maxLabels) return 1;
|
|
6795
6814
|
return Math.ceil(count / maxLabels);
|
|
6796
6815
|
};
|
|
6797
|
-
var AxisLabels =
|
|
6816
|
+
var AxisLabels = import_react7.default.memo(({ labels, count, chartW, height }) => {
|
|
6798
6817
|
const step = getLabelStep(count, chartW);
|
|
6799
|
-
return /* @__PURE__ */ (0,
|
|
6818
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(import_jsx_runtime308.Fragment, { children: labels.map((label, i) => {
|
|
6800
6819
|
if (i % step !== 0) return null;
|
|
6801
6820
|
const x = PADDING.left + i / (count - 1 || 1) * chartW;
|
|
6802
|
-
return /* @__PURE__ */ (0,
|
|
6821
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("text", { x, y: height - 8, className: "chart-axis-label", textAnchor: "middle", children: label }, i);
|
|
6803
6822
|
}) });
|
|
6804
6823
|
});
|
|
6805
6824
|
AxisLabels.displayName = "AxisLabels";
|
|
6806
6825
|
var useCrosshair = (seriesPoints, entries, labels, chartH) => {
|
|
6807
|
-
const [activeIndex, setActiveIndex] =
|
|
6808
|
-
const handleMouseMove =
|
|
6826
|
+
const [activeIndex, setActiveIndex] = import_react7.default.useState(null);
|
|
6827
|
+
const handleMouseMove = import_react7.default.useCallback((e) => {
|
|
6809
6828
|
const svg = e.currentTarget;
|
|
6810
6829
|
const rect = svg.getBoundingClientRect();
|
|
6811
6830
|
const mx = (e.clientX - rect.left) / rect.width * svg.viewBox.baseVal.width;
|
|
@@ -6824,17 +6843,17 @@ var useCrosshair = (seriesPoints, entries, labels, chartH) => {
|
|
|
6824
6843
|
}
|
|
6825
6844
|
setActiveIndex(minDist <= threshold ? closest : null);
|
|
6826
6845
|
}, [seriesPoints]);
|
|
6827
|
-
const handleMouseLeave =
|
|
6846
|
+
const handleMouseLeave = import_react7.default.useCallback(() => {
|
|
6828
6847
|
setActiveIndex(null);
|
|
6829
6848
|
}, []);
|
|
6830
|
-
const tooltipContent =
|
|
6849
|
+
const tooltipContent = import_react7.default.useMemo(() => {
|
|
6831
6850
|
if (activeIndex === null) return "";
|
|
6832
6851
|
return entries.map(([key], di) => {
|
|
6833
6852
|
const p = seriesPoints[di]?.[activeIndex];
|
|
6834
6853
|
return p ? `${key}: ${p.v}` : "";
|
|
6835
6854
|
}).filter(Boolean).join(" / ");
|
|
6836
6855
|
}, [activeIndex, entries, seriesPoints]);
|
|
6837
|
-
const getTooltipAt =
|
|
6856
|
+
const getTooltipAt = import_react7.default.useCallback((idx) => {
|
|
6838
6857
|
return entries.map(([key], di) => {
|
|
6839
6858
|
const p = seriesPoints[di]?.[idx];
|
|
6840
6859
|
return p ? `${key}: ${p.v}` : "";
|
|
@@ -6842,16 +6861,16 @@ var useCrosshair = (seriesPoints, entries, labels, chartH) => {
|
|
|
6842
6861
|
}, [entries, seriesPoints]);
|
|
6843
6862
|
return { activeIndex, handleMouseMove, handleMouseLeave, tooltipContent, getTooltipAt };
|
|
6844
6863
|
};
|
|
6845
|
-
var LineChart =
|
|
6846
|
-
const entries =
|
|
6847
|
-
const maxVal =
|
|
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(() => {
|
|
6848
6867
|
const allValues = entries.flatMap(([, v]) => v);
|
|
6849
6868
|
return Math.max(...allValues) * 1.2 || 1;
|
|
6850
6869
|
}, [entries]);
|
|
6851
6870
|
const count = labels.length;
|
|
6852
6871
|
const chartW = width - PADDING.left - PADDING.right;
|
|
6853
6872
|
const chartH = height - PADDING.top - PADDING.bottom;
|
|
6854
|
-
const seriesPoints =
|
|
6873
|
+
const seriesPoints = import_react7.default.useMemo(
|
|
6855
6874
|
() => entries.map(
|
|
6856
6875
|
([, values]) => values.map((v, i) => ({
|
|
6857
6876
|
x: PADDING.left + i / (count - 1 || 1) * chartW,
|
|
@@ -6861,34 +6880,21 @@ var LineChart = import_react6.default.memo(({ data, labels, width, height, anima
|
|
|
6861
6880
|
),
|
|
6862
6881
|
[entries, count, chartW, chartH, maxVal]
|
|
6863
6882
|
);
|
|
6864
|
-
const
|
|
6865
|
-
const clipRef = import_react6.default.useRef(null);
|
|
6883
|
+
const clipRef = import_react7.default.useRef(null);
|
|
6866
6884
|
const { activeIndex, handleMouseMove, handleMouseLeave, getTooltipAt } = useCrosshair(seriesPoints, entries, labels, chartH);
|
|
6867
|
-
|
|
6868
|
-
if (!animate) return;
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
el.style.transition = "stroke-dashoffset 1200ms ease-out 200ms";
|
|
6876
|
-
el.style.strokeDashoffset = "0";
|
|
6877
|
-
});
|
|
6885
|
+
import_react7.default.useEffect(() => {
|
|
6886
|
+
if (!animate || !clipRef.current) return;
|
|
6887
|
+
clipRef.current.setAttribute("width", "0");
|
|
6888
|
+
requestAnimationFrame(() => {
|
|
6889
|
+
if (clipRef.current) {
|
|
6890
|
+
clipRef.current.style.transition = "width 1200ms ease-out 200ms";
|
|
6891
|
+
clipRef.current.setAttribute("width", `${width}`);
|
|
6892
|
+
}
|
|
6878
6893
|
});
|
|
6879
|
-
|
|
6880
|
-
clipRef.current.setAttribute("width", "0");
|
|
6881
|
-
requestAnimationFrame(() => {
|
|
6882
|
-
if (clipRef.current) {
|
|
6883
|
-
clipRef.current.style.transition = "width 1200ms ease-out 200ms";
|
|
6884
|
-
clipRef.current.setAttribute("width", `${width}`);
|
|
6885
|
-
}
|
|
6886
|
-
});
|
|
6887
|
-
}
|
|
6888
|
-
}, [animate, seriesPoints, width]);
|
|
6894
|
+
}, [animate, width]);
|
|
6889
6895
|
const activeX = activeIndex !== null ? seriesPoints[0]?.[activeIndex]?.x ?? null : null;
|
|
6890
6896
|
const lineClipId = "line-area-clip";
|
|
6891
|
-
return /* @__PURE__ */ (0,
|
|
6897
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)(
|
|
6892
6898
|
"svg",
|
|
6893
6899
|
{
|
|
6894
6900
|
viewBox: `0 0 ${width} ${height}`,
|
|
@@ -6921,9 +6927,9 @@ var LineChart = import_react6.default.memo(({ data, labels, width, height, anima
|
|
|
6921
6927
|
onLeave();
|
|
6922
6928
|
},
|
|
6923
6929
|
children: [
|
|
6924
|
-
animate && /* @__PURE__ */ (0,
|
|
6925
|
-
/* @__PURE__ */ (0,
|
|
6926
|
-
/* @__PURE__ */ (0,
|
|
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 }),
|
|
6927
6933
|
entries.map(([key], di) => {
|
|
6928
6934
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
6929
6935
|
const color = palette[2];
|
|
@@ -6932,32 +6938,16 @@ var LineChart = import_react6.default.memo(({ data, labels, width, height, anima
|
|
|
6932
6938
|
const gradientId = `line-gradient-${di}`;
|
|
6933
6939
|
const polyPoints = points.map((p) => `${p.x},${p.y}`).join(" ");
|
|
6934
6940
|
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`;
|
|
6935
|
-
return /* @__PURE__ */ (0,
|
|
6936
|
-
/* @__PURE__ */ (0,
|
|
6937
|
-
/* @__PURE__ */ (0,
|
|
6938
|
-
/* @__PURE__ */ (0,
|
|
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" })
|
|
6939
6945
|
] }) }),
|
|
6940
|
-
/* @__PURE__ */ (0,
|
|
6941
|
-
"path",
|
|
6942
|
-
{
|
|
6943
|
-
|
|
6944
|
-
|
|
6945
|
-
clipPath: animate ? `url(#${lineClipId})` : void 0
|
|
6946
|
-
}
|
|
6947
|
-
),
|
|
6948
|
-
/* @__PURE__ */ (0, import_jsx_runtime307.jsx)(
|
|
6949
|
-
"polyline",
|
|
6950
|
-
{
|
|
6951
|
-
ref: (el) => {
|
|
6952
|
-
lineRefs.current[di] = el;
|
|
6953
|
-
},
|
|
6954
|
-
points: polyPoints,
|
|
6955
|
-
fill: "none",
|
|
6956
|
-
stroke: color,
|
|
6957
|
-
strokeWidth: "2"
|
|
6958
|
-
}
|
|
6959
|
-
),
|
|
6960
|
-
activeIndex !== null && points[activeIndex] && /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(
|
|
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" })
|
|
6949
|
+
] }),
|
|
6950
|
+
activeIndex !== null && points[activeIndex] && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
6961
6951
|
"circle",
|
|
6962
6952
|
{
|
|
6963
6953
|
cx: points[activeIndex].x,
|
|
@@ -6969,7 +6959,7 @@ var LineChart = import_react6.default.memo(({ data, labels, width, height, anima
|
|
|
6969
6959
|
)
|
|
6970
6960
|
] }, di);
|
|
6971
6961
|
}),
|
|
6972
|
-
activeX !== null && /* @__PURE__ */ (0,
|
|
6962
|
+
activeX !== null && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
6973
6963
|
"line",
|
|
6974
6964
|
{
|
|
6975
6965
|
x1: activeX,
|
|
@@ -6979,7 +6969,7 @@ var LineChart = import_react6.default.memo(({ data, labels, width, height, anima
|
|
|
6979
6969
|
className: "chart-crosshair"
|
|
6980
6970
|
}
|
|
6981
6971
|
),
|
|
6982
|
-
/* @__PURE__ */ (0,
|
|
6972
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
6983
6973
|
"rect",
|
|
6984
6974
|
{
|
|
6985
6975
|
x: PADDING.left,
|
|
@@ -6995,16 +6985,16 @@ var LineChart = import_react6.default.memo(({ data, labels, width, height, anima
|
|
|
6995
6985
|
);
|
|
6996
6986
|
});
|
|
6997
6987
|
LineChart.displayName = "LineChart";
|
|
6998
|
-
var CurveChart =
|
|
6999
|
-
const entries =
|
|
7000
|
-
const maxVal =
|
|
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(() => {
|
|
7001
6991
|
const allValues = entries.flatMap(([, v]) => v);
|
|
7002
6992
|
return Math.max(...allValues) * 1.2 || 1;
|
|
7003
6993
|
}, [entries]);
|
|
7004
6994
|
const count = labels.length;
|
|
7005
6995
|
const chartW = width - PADDING.left - PADDING.right;
|
|
7006
6996
|
const chartH = height - PADDING.top - PADDING.bottom;
|
|
7007
|
-
const seriesPoints =
|
|
6997
|
+
const seriesPoints = import_react7.default.useMemo(
|
|
7008
6998
|
() => entries.map(
|
|
7009
6999
|
([, values]) => values.map((v, i) => ({
|
|
7010
7000
|
x: PADDING.left + i / (count - 1 || 1) * chartW,
|
|
@@ -7014,34 +7004,21 @@ var CurveChart = import_react6.default.memo(({ data, labels, width, height, anim
|
|
|
7014
7004
|
),
|
|
7015
7005
|
[entries, count, chartW, chartH, maxVal]
|
|
7016
7006
|
);
|
|
7017
|
-
const
|
|
7018
|
-
const curveClipRef = import_react6.default.useRef(null);
|
|
7007
|
+
const curveClipRef = import_react7.default.useRef(null);
|
|
7019
7008
|
const { activeIndex, handleMouseMove, handleMouseLeave, getTooltipAt } = useCrosshair(seriesPoints, entries, labels, chartH);
|
|
7020
|
-
|
|
7021
|
-
if (!animate) return;
|
|
7022
|
-
|
|
7023
|
-
|
|
7024
|
-
|
|
7025
|
-
|
|
7026
|
-
|
|
7027
|
-
|
|
7028
|
-
el.style.transition = "stroke-dashoffset 1200ms ease-out 200ms";
|
|
7029
|
-
el.style.strokeDashoffset = "0";
|
|
7030
|
-
});
|
|
7009
|
+
import_react7.default.useEffect(() => {
|
|
7010
|
+
if (!animate || !curveClipRef.current) return;
|
|
7011
|
+
curveClipRef.current.setAttribute("width", "0");
|
|
7012
|
+
requestAnimationFrame(() => {
|
|
7013
|
+
if (curveClipRef.current) {
|
|
7014
|
+
curveClipRef.current.style.transition = "width 1200ms ease-out 200ms";
|
|
7015
|
+
curveClipRef.current.setAttribute("width", `${width}`);
|
|
7016
|
+
}
|
|
7031
7017
|
});
|
|
7032
|
-
|
|
7033
|
-
curveClipRef.current.setAttribute("width", "0");
|
|
7034
|
-
requestAnimationFrame(() => {
|
|
7035
|
-
if (curveClipRef.current) {
|
|
7036
|
-
curveClipRef.current.style.transition = "width 1200ms ease-out 200ms";
|
|
7037
|
-
curveClipRef.current.setAttribute("width", `${width}`);
|
|
7038
|
-
}
|
|
7039
|
-
});
|
|
7040
|
-
}
|
|
7041
|
-
}, [animate, seriesPoints, width]);
|
|
7018
|
+
}, [animate, width]);
|
|
7042
7019
|
const activeX = activeIndex !== null ? seriesPoints[0]?.[activeIndex]?.x ?? null : null;
|
|
7043
7020
|
const curveClipId = "curve-area-clip";
|
|
7044
|
-
return /* @__PURE__ */ (0,
|
|
7021
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)(
|
|
7045
7022
|
"svg",
|
|
7046
7023
|
{
|
|
7047
7024
|
viewBox: `0 0 ${width} ${height}`,
|
|
@@ -7074,9 +7051,9 @@ var CurveChart = import_react6.default.memo(({ data, labels, width, height, anim
|
|
|
7074
7051
|
onLeave();
|
|
7075
7052
|
},
|
|
7076
7053
|
children: [
|
|
7077
|
-
animate && /* @__PURE__ */ (0,
|
|
7078
|
-
/* @__PURE__ */ (0,
|
|
7079
|
-
/* @__PURE__ */ (0,
|
|
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 }),
|
|
7080
7057
|
entries.map(([key], di) => {
|
|
7081
7058
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
7082
7059
|
const color = palette[2];
|
|
@@ -7085,32 +7062,16 @@ var CurveChart = import_react6.default.memo(({ data, labels, width, height, anim
|
|
|
7085
7062
|
const gradientId = `curve-gradient-${di}`;
|
|
7086
7063
|
const linePath = toSmoothPath(points);
|
|
7087
7064
|
const areaPath = linePath + ` L ${points[points.length - 1].x} ${PADDING.top + chartH} L ${points[0].x} ${PADDING.top + chartH} Z`;
|
|
7088
|
-
return /* @__PURE__ */ (0,
|
|
7089
|
-
/* @__PURE__ */ (0,
|
|
7090
|
-
/* @__PURE__ */ (0,
|
|
7091
|
-
/* @__PURE__ */ (0,
|
|
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" })
|
|
7092
7069
|
] }) }),
|
|
7093
|
-
/* @__PURE__ */ (0,
|
|
7094
|
-
"path",
|
|
7095
|
-
{
|
|
7096
|
-
|
|
7097
|
-
|
|
7098
|
-
clipPath: animate ? `url(#${curveClipId})` : void 0
|
|
7099
|
-
}
|
|
7100
|
-
),
|
|
7101
|
-
/* @__PURE__ */ (0, import_jsx_runtime307.jsx)(
|
|
7102
|
-
"path",
|
|
7103
|
-
{
|
|
7104
|
-
ref: (el) => {
|
|
7105
|
-
lineRefs.current[di] = el;
|
|
7106
|
-
},
|
|
7107
|
-
d: linePath,
|
|
7108
|
-
fill: "none",
|
|
7109
|
-
stroke: color,
|
|
7110
|
-
strokeWidth: "2"
|
|
7111
|
-
}
|
|
7112
|
-
),
|
|
7113
|
-
activeIndex !== null && points[activeIndex] && /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(
|
|
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" })
|
|
7073
|
+
] }),
|
|
7074
|
+
activeIndex !== null && points[activeIndex] && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
7114
7075
|
"circle",
|
|
7115
7076
|
{
|
|
7116
7077
|
cx: points[activeIndex].x,
|
|
@@ -7122,7 +7083,7 @@ var CurveChart = import_react6.default.memo(({ data, labels, width, height, anim
|
|
|
7122
7083
|
)
|
|
7123
7084
|
] }, di);
|
|
7124
7085
|
}),
|
|
7125
|
-
activeX !== null && /* @__PURE__ */ (0,
|
|
7086
|
+
activeX !== null && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
7126
7087
|
"line",
|
|
7127
7088
|
{
|
|
7128
7089
|
x1: activeX,
|
|
@@ -7132,7 +7093,7 @@ var CurveChart = import_react6.default.memo(({ data, labels, width, height, anim
|
|
|
7132
7093
|
className: "chart-crosshair"
|
|
7133
7094
|
}
|
|
7134
7095
|
),
|
|
7135
|
-
/* @__PURE__ */ (0,
|
|
7096
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
7136
7097
|
"rect",
|
|
7137
7098
|
{
|
|
7138
7099
|
x: PADDING.left,
|
|
@@ -7148,9 +7109,9 @@ var CurveChart = import_react6.default.memo(({ data, labels, width, height, anim
|
|
|
7148
7109
|
);
|
|
7149
7110
|
});
|
|
7150
7111
|
CurveChart.displayName = "CurveChart";
|
|
7151
|
-
var BarChart =
|
|
7152
|
-
const entries =
|
|
7153
|
-
const maxVal =
|
|
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(() => {
|
|
7154
7115
|
const allValues = entries.flatMap(([, v]) => v);
|
|
7155
7116
|
return Math.max(...allValues) * 1.2 || 1;
|
|
7156
7117
|
}, [entries]);
|
|
@@ -7162,7 +7123,7 @@ var BarChart = import_react6.default.memo(({ data, labels, width, height, animat
|
|
|
7162
7123
|
const barGap = groupCount > 1 ? 2 : 0;
|
|
7163
7124
|
const barW = Math.max(1, Math.min(32, (groupW * 0.7 - barGap * (groupCount - 1)) / groupCount));
|
|
7164
7125
|
const baseline = PADDING.top + chartH;
|
|
7165
|
-
const bars =
|
|
7126
|
+
const bars = import_react7.default.useMemo(
|
|
7166
7127
|
() => entries.map(
|
|
7167
7128
|
([, values], di) => values.map((v, i) => {
|
|
7168
7129
|
const totalBarsW = barW * groupCount + barGap * (groupCount - 1);
|
|
@@ -7175,11 +7136,11 @@ var BarChart = import_react6.default.memo(({ data, labels, width, height, animat
|
|
|
7175
7136
|
[entries, maxVal, chartH, groupW, barW, barGap, groupCount]
|
|
7176
7137
|
);
|
|
7177
7138
|
const barLabelStep = getLabelStep(count, chartW);
|
|
7178
|
-
return /* @__PURE__ */ (0,
|
|
7179
|
-
/* @__PURE__ */ (0,
|
|
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 }),
|
|
7180
7141
|
labels.map((label, i) => {
|
|
7181
7142
|
if (i % barLabelStep !== 0) return null;
|
|
7182
|
-
return /* @__PURE__ */ (0,
|
|
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);
|
|
7183
7144
|
}),
|
|
7184
7145
|
entries.map(([key], di) => {
|
|
7185
7146
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
@@ -7188,7 +7149,7 @@ var BarChart = import_react6.default.memo(({ data, labels, width, height, animat
|
|
|
7188
7149
|
const r2 = Math.min(4, b.w / 2);
|
|
7189
7150
|
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`;
|
|
7190
7151
|
const delay = 100 + i * 80;
|
|
7191
|
-
return /* @__PURE__ */ (0,
|
|
7152
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
7192
7153
|
"path",
|
|
7193
7154
|
{
|
|
7194
7155
|
d,
|
|
@@ -7209,11 +7170,11 @@ var BarChart = import_react6.default.memo(({ data, labels, width, height, animat
|
|
|
7209
7170
|
] });
|
|
7210
7171
|
});
|
|
7211
7172
|
BarChart.displayName = "BarChart";
|
|
7212
|
-
var PieDonutChart =
|
|
7173
|
+
var PieDonutChart = import_react7.default.memo(
|
|
7213
7174
|
({ data, labels, width, height, animate, isDoughnut, onHover, onMove, onLeave }) => {
|
|
7214
|
-
const entries =
|
|
7215
|
-
const values =
|
|
7216
|
-
const total =
|
|
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]);
|
|
7217
7178
|
const size = Math.min(width, height);
|
|
7218
7179
|
const cx = size / 2;
|
|
7219
7180
|
const cy = size / 2;
|
|
@@ -7221,10 +7182,10 @@ var PieDonutChart = import_react6.default.memo(
|
|
|
7221
7182
|
const innerR = isDoughnut ? r2 * 0.5 : 0;
|
|
7222
7183
|
const firstKey = entries[0]?.[0] ?? "";
|
|
7223
7184
|
const colorOffset = hashString(firstKey);
|
|
7224
|
-
const maskRef =
|
|
7185
|
+
const maskRef = import_react7.default.useRef(null);
|
|
7225
7186
|
const maskR = r2 + 10;
|
|
7226
7187
|
const maskCircumference = 2 * Math.PI * maskR;
|
|
7227
|
-
|
|
7188
|
+
import_react7.default.useEffect(() => {
|
|
7228
7189
|
if (!animate || !maskRef.current) return;
|
|
7229
7190
|
const el = maskRef.current;
|
|
7230
7191
|
el.style.strokeDasharray = `${maskCircumference}`;
|
|
@@ -7234,7 +7195,7 @@ var PieDonutChart = import_react6.default.memo(
|
|
|
7234
7195
|
el.style.strokeDashoffset = "0";
|
|
7235
7196
|
});
|
|
7236
7197
|
}, [animate, maskCircumference]);
|
|
7237
|
-
const sliceData =
|
|
7198
|
+
const sliceData = import_react7.default.useMemo(() => {
|
|
7238
7199
|
let angle0 = -Math.PI / 2;
|
|
7239
7200
|
let cumulativeAngle = 0;
|
|
7240
7201
|
return values.map((v, i) => {
|
|
@@ -7268,8 +7229,8 @@ var PieDonutChart = import_react6.default.memo(
|
|
|
7268
7229
|
});
|
|
7269
7230
|
}, [values, total, cx, cy, r2, innerR, labels]);
|
|
7270
7231
|
const maskId = `pie-mask-${isDoughnut ? "d" : "p"}`;
|
|
7271
|
-
return /* @__PURE__ */ (0,
|
|
7272
|
-
animate && /* @__PURE__ */ (0,
|
|
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)(
|
|
7273
7234
|
"circle",
|
|
7274
7235
|
{
|
|
7275
7236
|
ref: maskRef,
|
|
@@ -7282,7 +7243,7 @@ var PieDonutChart = import_react6.default.memo(
|
|
|
7282
7243
|
transform: `rotate(-90 ${cx} ${cy})`
|
|
7283
7244
|
}
|
|
7284
7245
|
) }) }),
|
|
7285
|
-
/* @__PURE__ */ (0,
|
|
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)(
|
|
7286
7247
|
"path",
|
|
7287
7248
|
{
|
|
7288
7249
|
d: s.d,
|
|
@@ -7293,7 +7254,7 @@ var PieDonutChart = import_react6.default.memo(
|
|
|
7293
7254
|
onMouseLeave: onLeave
|
|
7294
7255
|
}
|
|
7295
7256
|
) }, i)) }),
|
|
7296
|
-
sliceData.map((s, i) => s.angle > 0.2 && /* @__PURE__ */ (0,
|
|
7257
|
+
sliceData.map((s, i) => s.angle > 0.2 && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
7297
7258
|
"text",
|
|
7298
7259
|
{
|
|
7299
7260
|
x: s.lx,
|
|
@@ -7311,9 +7272,9 @@ var PieDonutChart = import_react6.default.memo(
|
|
|
7311
7272
|
);
|
|
7312
7273
|
PieDonutChart.displayName = "PieDonutChart";
|
|
7313
7274
|
var ChartTooltipPortal = ({ clientX, clientY, visible, children }) => {
|
|
7314
|
-
const ref =
|
|
7315
|
-
const [pos, setPos] =
|
|
7316
|
-
|
|
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(() => {
|
|
7317
7278
|
const el = ref.current;
|
|
7318
7279
|
if (!el) return;
|
|
7319
7280
|
const w = el.offsetWidth;
|
|
@@ -7326,7 +7287,7 @@ var ChartTooltipPortal = ({ clientX, clientY, visible, children }) => {
|
|
|
7326
7287
|
if (left < 8) left = 8;
|
|
7327
7288
|
setPos({ left, top });
|
|
7328
7289
|
}, [clientX, clientY]);
|
|
7329
|
-
return /* @__PURE__ */ (0,
|
|
7290
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
7330
7291
|
"div",
|
|
7331
7292
|
{
|
|
7332
7293
|
ref,
|
|
@@ -7343,14 +7304,14 @@ var ChartLegend = ({ data, labels, type }) => {
|
|
|
7343
7304
|
const total = values.reduce((a, b) => a + b, 0) || 1;
|
|
7344
7305
|
const firstKey = entries[0]?.[0] ?? "";
|
|
7345
7306
|
const colorOffset = hashString(firstKey);
|
|
7346
|
-
return /* @__PURE__ */ (0,
|
|
7307
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("div", { className: "chart-legend", children: values.map((v, i) => {
|
|
7347
7308
|
const pct = Math.round(v / total * 100);
|
|
7348
7309
|
const color = PIE_COLORS[(i + colorOffset) % PIE_COLORS.length];
|
|
7349
|
-
return /* @__PURE__ */ (0,
|
|
7350
|
-
/* @__PURE__ */ (0,
|
|
7351
|
-
/* @__PURE__ */ (0,
|
|
7352
|
-
/* @__PURE__ */ (0,
|
|
7353
|
-
/* @__PURE__ */ (0,
|
|
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: [
|
|
7354
7315
|
v.toLocaleString(),
|
|
7355
7316
|
"(",
|
|
7356
7317
|
pct,
|
|
@@ -7360,37 +7321,37 @@ var ChartLegend = ({ data, labels, type }) => {
|
|
|
7360
7321
|
] }, i);
|
|
7361
7322
|
}) });
|
|
7362
7323
|
}
|
|
7363
|
-
return /* @__PURE__ */ (0,
|
|
7324
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("div", { className: "chart-legend", children: entries.map(([key], di) => {
|
|
7364
7325
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
7365
7326
|
const color = palette[2];
|
|
7366
7327
|
const values = entries[di][1];
|
|
7367
7328
|
const sum = values.reduce((a, b) => a + b, 0);
|
|
7368
|
-
return /* @__PURE__ */ (0,
|
|
7369
|
-
/* @__PURE__ */ (0,
|
|
7370
|
-
/* @__PURE__ */ (0,
|
|
7371
|
-
/* @__PURE__ */ (0,
|
|
7372
|
-
/* @__PURE__ */ (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() })
|
|
7373
7334
|
] })
|
|
7374
7335
|
] }, di);
|
|
7375
7336
|
}) });
|
|
7376
7337
|
};
|
|
7377
|
-
var Chart =
|
|
7338
|
+
var Chart = import_react7.default.memo((props) => {
|
|
7378
7339
|
const { type, data, labels, tooltip: showTooltip = true } = props;
|
|
7379
7340
|
const { tooltip, show, hide, move, containerRef } = useChartTooltip(showTooltip);
|
|
7380
7341
|
const { width, height } = useChartSize(containerRef);
|
|
7381
|
-
const stableData =
|
|
7382
|
-
const stableLabels =
|
|
7383
|
-
const dataKey =
|
|
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]);
|
|
7384
7345
|
const animate = useChartAnimation(containerRef, dataKey);
|
|
7385
7346
|
const ready = width > 0 && height > 0;
|
|
7386
|
-
return /* @__PURE__ */ (0,
|
|
7387
|
-
ready && type === "line" && /* @__PURE__ */ (0,
|
|
7388
|
-
ready && type === "curve" && /* @__PURE__ */ (0,
|
|
7389
|
-
ready && type === "bar" && /* @__PURE__ */ (0,
|
|
7390
|
-
ready && type === "pie" && /* @__PURE__ */ (0,
|
|
7391
|
-
ready && type === "doughnut" && /* @__PURE__ */ (0,
|
|
7392
|
-
ready && (type === "bar" || type === "pie" || type === "doughnut") && /* @__PURE__ */ (0,
|
|
7393
|
-
tooltip.content && /* @__PURE__ */ (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 }) })
|
|
7394
7355
|
] });
|
|
7395
7356
|
});
|
|
7396
7357
|
Chart.displayName = "Chart";
|
|
@@ -7416,7 +7377,7 @@ var import_tokens_core = require("@x-plat/tokens-core");
|
|
|
7416
7377
|
var import_tokens_core2 = require("@x-plat/tokens-core");
|
|
7417
7378
|
|
|
7418
7379
|
// src/components/CheckBox/CheckBox.tsx
|
|
7419
|
-
var
|
|
7380
|
+
var import_jsx_runtime309 = require("react/jsx-runtime");
|
|
7420
7381
|
var CheckBox = (props) => {
|
|
7421
7382
|
const {
|
|
7422
7383
|
checked,
|
|
@@ -7434,8 +7395,8 @@ var CheckBox = (props) => {
|
|
|
7434
7395
|
const checkedClasses = `checked`;
|
|
7435
7396
|
const disabledClasses = "disabled";
|
|
7436
7397
|
const boxClasses = disabled ? disabledClasses : checked ? checkedClasses : uncheckedClasses;
|
|
7437
|
-
return /* @__PURE__ */ (0,
|
|
7438
|
-
/* @__PURE__ */ (0,
|
|
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)(
|
|
7439
7400
|
"input",
|
|
7440
7401
|
{
|
|
7441
7402
|
type: "checkbox",
|
|
@@ -7445,22 +7406,22 @@ var CheckBox = (props) => {
|
|
|
7445
7406
|
...rest
|
|
7446
7407
|
}
|
|
7447
7408
|
),
|
|
7448
|
-
/* @__PURE__ */ (0,
|
|
7449
|
-
label && /* @__PURE__ */ (0,
|
|
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 })
|
|
7450
7411
|
] });
|
|
7451
7412
|
};
|
|
7452
7413
|
CheckBox.displayName = "CheckBox";
|
|
7453
7414
|
var CheckBox_default = CheckBox;
|
|
7454
7415
|
|
|
7455
7416
|
// src/components/Chip/Chip.tsx
|
|
7456
|
-
var
|
|
7417
|
+
var import_jsx_runtime310 = require("react/jsx-runtime");
|
|
7457
7418
|
var Chip = (props) => {
|
|
7458
7419
|
const {
|
|
7459
7420
|
children,
|
|
7460
7421
|
type = "primary",
|
|
7461
7422
|
size = "md"
|
|
7462
7423
|
} = props;
|
|
7463
|
-
return /* @__PURE__ */ (0,
|
|
7424
|
+
return /* @__PURE__ */ (0, import_jsx_runtime310.jsx)("div", { className: clsx_default("lib-xplat-chip", type, size), children });
|
|
7464
7425
|
};
|
|
7465
7426
|
Chip.displayName = "Chip";
|
|
7466
7427
|
var Chip_default = Chip;
|
|
@@ -7469,20 +7430,20 @@ var Chip_default = Chip;
|
|
|
7469
7430
|
var import_react13 = __toESM(require("react"), 1);
|
|
7470
7431
|
|
|
7471
7432
|
// src/components/Input/Input.tsx
|
|
7472
|
-
var
|
|
7433
|
+
var import_react8 = __toESM(require("react"), 1);
|
|
7473
7434
|
|
|
7474
7435
|
// src/components/Input/InputValidations.tsx
|
|
7475
|
-
var
|
|
7436
|
+
var import_jsx_runtime311 = require("react/jsx-runtime");
|
|
7476
7437
|
var InputValidations = (props) => {
|
|
7477
7438
|
const { message, status = "default" } = props;
|
|
7478
|
-
return /* @__PURE__ */ (0,
|
|
7479
|
-
/* @__PURE__ */ (0,
|
|
7480
|
-
status === "default" && /* @__PURE__ */ (0,
|
|
7481
|
-
status === "success" && /* @__PURE__ */ (0,
|
|
7482
|
-
status === "warning" && /* @__PURE__ */ (0,
|
|
7483
|
-
status === "error" && /* @__PURE__ */ (0,
|
|
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, {})
|
|
7484
7445
|
] }),
|
|
7485
|
-
/* @__PURE__ */ (0,
|
|
7446
|
+
/* @__PURE__ */ (0, import_jsx_runtime311.jsx)("div", { className: "message", children: message })
|
|
7486
7447
|
] });
|
|
7487
7448
|
};
|
|
7488
7449
|
InputValidations.displayName = "InputValidations";
|
|
@@ -7523,8 +7484,8 @@ var handleTelBackspace = (prevValue, currValue) => {
|
|
|
7523
7484
|
};
|
|
7524
7485
|
|
|
7525
7486
|
// src/components/Input/Input.tsx
|
|
7526
|
-
var
|
|
7527
|
-
var
|
|
7487
|
+
var import_jsx_runtime312 = require("react/jsx-runtime");
|
|
7488
|
+
var import_react9 = require("react");
|
|
7528
7489
|
var formatValue = (type, value) => {
|
|
7529
7490
|
if (value === null || value === void 0) return "";
|
|
7530
7491
|
const strValue = Array.isArray(value) ? String(value[0] ?? "") : String(value);
|
|
@@ -7572,7 +7533,7 @@ var parseValue = (type, value) => {
|
|
|
7572
7533
|
return value;
|
|
7573
7534
|
}
|
|
7574
7535
|
};
|
|
7575
|
-
var Input =
|
|
7536
|
+
var Input = import_react8.default.forwardRef((props, ref) => {
|
|
7576
7537
|
const {
|
|
7577
7538
|
value,
|
|
7578
7539
|
onChange,
|
|
@@ -7598,13 +7559,13 @@ var Input = import_react7.default.forwardRef((props, ref) => {
|
|
|
7598
7559
|
onChange(event);
|
|
7599
7560
|
}
|
|
7600
7561
|
};
|
|
7601
|
-
return /* @__PURE__ */ (0,
|
|
7602
|
-
/* @__PURE__ */ (0,
|
|
7562
|
+
return /* @__PURE__ */ (0, import_jsx_runtime312.jsxs)("div", { className: "lib-xplat-input-wrap", children: [
|
|
7563
|
+
/* @__PURE__ */ (0, import_jsx_runtime312.jsxs)(
|
|
7603
7564
|
"div",
|
|
7604
7565
|
{
|
|
7605
7566
|
className: clsx_default("lib-xplat-input", size, disabled ? "disabled" : void 0),
|
|
7606
7567
|
children: [
|
|
7607
|
-
/* @__PURE__ */ (0,
|
|
7568
|
+
/* @__PURE__ */ (0, import_jsx_runtime312.jsx)(
|
|
7608
7569
|
"input",
|
|
7609
7570
|
{
|
|
7610
7571
|
...inputProps,
|
|
@@ -7615,11 +7576,11 @@ var Input = import_react7.default.forwardRef((props, ref) => {
|
|
|
7615
7576
|
onChange: handleChange
|
|
7616
7577
|
}
|
|
7617
7578
|
),
|
|
7618
|
-
suffix && /* @__PURE__ */ (0,
|
|
7579
|
+
suffix && /* @__PURE__ */ (0, import_jsx_runtime312.jsx)("div", { className: "suffix", children: suffix })
|
|
7619
7580
|
]
|
|
7620
7581
|
}
|
|
7621
7582
|
),
|
|
7622
|
-
validations && /* @__PURE__ */ (0,
|
|
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)(
|
|
7623
7584
|
InputValidations_default,
|
|
7624
7585
|
{
|
|
7625
7586
|
...validation,
|
|
@@ -7632,20 +7593,20 @@ Input.displayName = "Input";
|
|
|
7632
7593
|
var Input_default = Input;
|
|
7633
7594
|
|
|
7634
7595
|
// src/components/Input/PasswordInput/PasswordInput.tsx
|
|
7635
|
-
var
|
|
7636
|
-
var
|
|
7637
|
-
var PasswordInput =
|
|
7596
|
+
var import_react10 = __toESM(require("react"), 1);
|
|
7597
|
+
var import_jsx_runtime313 = require("react/jsx-runtime");
|
|
7598
|
+
var PasswordInput = import_react10.default.forwardRef(
|
|
7638
7599
|
(props, ref) => {
|
|
7639
7600
|
const { reg: _reg, ...inputProps } = props;
|
|
7640
|
-
const [isView, setIsView] =
|
|
7601
|
+
const [isView, setIsView] = import_react10.default.useState(false);
|
|
7641
7602
|
const handleChangeView = () => {
|
|
7642
7603
|
setIsView((prev) => !prev);
|
|
7643
7604
|
};
|
|
7644
|
-
return /* @__PURE__ */ (0,
|
|
7605
|
+
return /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(
|
|
7645
7606
|
Input_default,
|
|
7646
7607
|
{
|
|
7647
7608
|
...inputProps,
|
|
7648
|
-
suffix: /* @__PURE__ */ (0,
|
|
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, {}) }),
|
|
7649
7610
|
type: isView ? "text" : "password",
|
|
7650
7611
|
ref
|
|
7651
7612
|
}
|
|
@@ -7658,23 +7619,6 @@ var PasswordInput_default = PasswordInput;
|
|
|
7658
7619
|
// src/components/Modal/Modal.tsx
|
|
7659
7620
|
var import_react11 = __toESM(require("react"), 1);
|
|
7660
7621
|
var import_react_dom2 = require("react-dom");
|
|
7661
|
-
|
|
7662
|
-
// src/tokens/hooks/Portal.tsx
|
|
7663
|
-
var import_react10 = __toESM(require("react"), 1);
|
|
7664
|
-
var import_react_dom = __toESM(require("react-dom"), 1);
|
|
7665
|
-
var import_jsx_runtime313 = require("react/jsx-runtime");
|
|
7666
|
-
var PortalContainerContext = import_react10.default.createContext(null);
|
|
7667
|
-
var PortalProvider = ({ container, children }) => /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(PortalContainerContext.Provider, { value: container, children });
|
|
7668
|
-
var Portal = ({ children }) => {
|
|
7669
|
-
const contextContainer = import_react10.default.useContext(PortalContainerContext);
|
|
7670
|
-
if (typeof document === "undefined") return null;
|
|
7671
|
-
const container = contextContainer ?? document.body;
|
|
7672
|
-
return import_react_dom.default.createPortal(children, container);
|
|
7673
|
-
};
|
|
7674
|
-
Portal.displayName = "Portal";
|
|
7675
|
-
var Portal_default = Portal;
|
|
7676
|
-
|
|
7677
|
-
// src/components/Modal/Modal.tsx
|
|
7678
7622
|
var import_jsx_runtime314 = require("react/jsx-runtime");
|
|
7679
7623
|
var ANIMATION_DURATION_MS = 200;
|
|
7680
7624
|
var Modal = (props) => {
|