@x-plat/design-system 0.5.34 → 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 +131 -115
- package/dist/components/Chart/index.css +4 -1
- package/dist/components/Chart/index.js +117 -101
- package/dist/components/index.cjs +162 -162
- package/dist/components/index.css +4 -1
- package/dist/components/index.js +142 -142
- package/dist/index.cjs +162 -162
- package/dist/index.css +4 -1
- package/dist/index.js +142 -142
- 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,7 +6757,7 @@ 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;
|
|
@@ -6754,15 +6771,15 @@ var useChartAnimation = (containerRef, dataKey) => {
|
|
|
6754
6771
|
};
|
|
6755
6772
|
var TOOLTIP_OFFSET = 12;
|
|
6756
6773
|
var useChartTooltip = (enabled) => {
|
|
6757
|
-
const [tooltip, setTooltip] =
|
|
6774
|
+
const [tooltip, setTooltip] = import_react7.default.useState({
|
|
6758
6775
|
visible: false,
|
|
6759
6776
|
clientX: 0,
|
|
6760
6777
|
clientY: 0,
|
|
6761
6778
|
content: ""
|
|
6762
6779
|
});
|
|
6763
|
-
const containerRef =
|
|
6764
|
-
const rafRef =
|
|
6765
|
-
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) => {
|
|
6766
6783
|
if (!enabled) return;
|
|
6767
6784
|
const cx = e.clientX;
|
|
6768
6785
|
const cy = e.clientY;
|
|
@@ -6771,22 +6788,22 @@ var useChartTooltip = (enabled) => {
|
|
|
6771
6788
|
setTooltip((prev) => ({ ...prev, clientX: cx, clientY: cy }));
|
|
6772
6789
|
});
|
|
6773
6790
|
}, [enabled]);
|
|
6774
|
-
const show =
|
|
6791
|
+
const show = import_react7.default.useCallback((e, content) => {
|
|
6775
6792
|
if (!enabled) return;
|
|
6776
6793
|
setTooltip({ visible: true, clientX: e.clientX, clientY: e.clientY, content });
|
|
6777
6794
|
}, [enabled]);
|
|
6778
|
-
const hide =
|
|
6795
|
+
const hide = import_react7.default.useCallback(() => {
|
|
6779
6796
|
cancelAnimationFrame(rafRef.current);
|
|
6780
6797
|
setTooltip((prev) => ({ ...prev, visible: false }));
|
|
6781
6798
|
}, []);
|
|
6782
6799
|
return { tooltip, show, hide, move, containerRef };
|
|
6783
6800
|
};
|
|
6784
|
-
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) => {
|
|
6785
6802
|
const y = PADDING.top + (1 - ratio) * chartH;
|
|
6786
6803
|
const val = Math.round(maxVal * ratio);
|
|
6787
|
-
return /* @__PURE__ */ (0,
|
|
6788
|
-
/* @__PURE__ */ (0,
|
|
6789
|
-
/* @__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 })
|
|
6790
6807
|
] }, ratio);
|
|
6791
6808
|
}) }));
|
|
6792
6809
|
GridLines.displayName = "GridLines";
|
|
@@ -6796,18 +6813,18 @@ var getLabelStep = (count, chartW) => {
|
|
|
6796
6813
|
if (count <= maxLabels) return 1;
|
|
6797
6814
|
return Math.ceil(count / maxLabels);
|
|
6798
6815
|
};
|
|
6799
|
-
var AxisLabels =
|
|
6816
|
+
var AxisLabels = import_react7.default.memo(({ labels, count, chartW, height }) => {
|
|
6800
6817
|
const step = getLabelStep(count, chartW);
|
|
6801
|
-
return /* @__PURE__ */ (0,
|
|
6818
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(import_jsx_runtime308.Fragment, { children: labels.map((label, i) => {
|
|
6802
6819
|
if (i % step !== 0) return null;
|
|
6803
6820
|
const x = PADDING.left + i / (count - 1 || 1) * chartW;
|
|
6804
|
-
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);
|
|
6805
6822
|
}) });
|
|
6806
6823
|
});
|
|
6807
6824
|
AxisLabels.displayName = "AxisLabels";
|
|
6808
6825
|
var useCrosshair = (seriesPoints, entries, labels, chartH) => {
|
|
6809
|
-
const [activeIndex, setActiveIndex] =
|
|
6810
|
-
const handleMouseMove =
|
|
6826
|
+
const [activeIndex, setActiveIndex] = import_react7.default.useState(null);
|
|
6827
|
+
const handleMouseMove = import_react7.default.useCallback((e) => {
|
|
6811
6828
|
const svg = e.currentTarget;
|
|
6812
6829
|
const rect = svg.getBoundingClientRect();
|
|
6813
6830
|
const mx = (e.clientX - rect.left) / rect.width * svg.viewBox.baseVal.width;
|
|
@@ -6826,17 +6843,17 @@ var useCrosshair = (seriesPoints, entries, labels, chartH) => {
|
|
|
6826
6843
|
}
|
|
6827
6844
|
setActiveIndex(minDist <= threshold ? closest : null);
|
|
6828
6845
|
}, [seriesPoints]);
|
|
6829
|
-
const handleMouseLeave =
|
|
6846
|
+
const handleMouseLeave = import_react7.default.useCallback(() => {
|
|
6830
6847
|
setActiveIndex(null);
|
|
6831
6848
|
}, []);
|
|
6832
|
-
const tooltipContent =
|
|
6849
|
+
const tooltipContent = import_react7.default.useMemo(() => {
|
|
6833
6850
|
if (activeIndex === null) return "";
|
|
6834
6851
|
return entries.map(([key], di) => {
|
|
6835
6852
|
const p = seriesPoints[di]?.[activeIndex];
|
|
6836
6853
|
return p ? `${key}: ${p.v}` : "";
|
|
6837
6854
|
}).filter(Boolean).join(" / ");
|
|
6838
6855
|
}, [activeIndex, entries, seriesPoints]);
|
|
6839
|
-
const getTooltipAt =
|
|
6856
|
+
const getTooltipAt = import_react7.default.useCallback((idx) => {
|
|
6840
6857
|
return entries.map(([key], di) => {
|
|
6841
6858
|
const p = seriesPoints[di]?.[idx];
|
|
6842
6859
|
return p ? `${key}: ${p.v}` : "";
|
|
@@ -6844,16 +6861,16 @@ var useCrosshair = (seriesPoints, entries, labels, chartH) => {
|
|
|
6844
6861
|
}, [entries, seriesPoints]);
|
|
6845
6862
|
return { activeIndex, handleMouseMove, handleMouseLeave, tooltipContent, getTooltipAt };
|
|
6846
6863
|
};
|
|
6847
|
-
var LineChart =
|
|
6848
|
-
const entries =
|
|
6849
|
-
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(() => {
|
|
6850
6867
|
const allValues = entries.flatMap(([, v]) => v);
|
|
6851
6868
|
return Math.max(...allValues) * 1.2 || 1;
|
|
6852
6869
|
}, [entries]);
|
|
6853
6870
|
const count = labels.length;
|
|
6854
6871
|
const chartW = width - PADDING.left - PADDING.right;
|
|
6855
6872
|
const chartH = height - PADDING.top - PADDING.bottom;
|
|
6856
|
-
const seriesPoints =
|
|
6873
|
+
const seriesPoints = import_react7.default.useMemo(
|
|
6857
6874
|
() => entries.map(
|
|
6858
6875
|
([, values]) => values.map((v, i) => ({
|
|
6859
6876
|
x: PADDING.left + i / (count - 1 || 1) * chartW,
|
|
@@ -6863,9 +6880,9 @@ var LineChart = import_react6.default.memo(({ data, labels, width, height, anima
|
|
|
6863
6880
|
),
|
|
6864
6881
|
[entries, count, chartW, chartH, maxVal]
|
|
6865
6882
|
);
|
|
6866
|
-
const clipRef =
|
|
6883
|
+
const clipRef = import_react7.default.useRef(null);
|
|
6867
6884
|
const { activeIndex, handleMouseMove, handleMouseLeave, getTooltipAt } = useCrosshair(seriesPoints, entries, labels, chartH);
|
|
6868
|
-
|
|
6885
|
+
import_react7.default.useEffect(() => {
|
|
6869
6886
|
if (!animate || !clipRef.current) return;
|
|
6870
6887
|
clipRef.current.setAttribute("width", "0");
|
|
6871
6888
|
requestAnimationFrame(() => {
|
|
@@ -6877,7 +6894,7 @@ var LineChart = import_react6.default.memo(({ data, labels, width, height, anima
|
|
|
6877
6894
|
}, [animate, width]);
|
|
6878
6895
|
const activeX = activeIndex !== null ? seriesPoints[0]?.[activeIndex]?.x ?? null : null;
|
|
6879
6896
|
const lineClipId = "line-area-clip";
|
|
6880
|
-
return /* @__PURE__ */ (0,
|
|
6897
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)(
|
|
6881
6898
|
"svg",
|
|
6882
6899
|
{
|
|
6883
6900
|
viewBox: `0 0 ${width} ${height}`,
|
|
@@ -6910,9 +6927,9 @@ var LineChart = import_react6.default.memo(({ data, labels, width, height, anima
|
|
|
6910
6927
|
onLeave();
|
|
6911
6928
|
},
|
|
6912
6929
|
children: [
|
|
6913
|
-
animate && /* @__PURE__ */ (0,
|
|
6914
|
-
/* @__PURE__ */ (0,
|
|
6915
|
-
/* @__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 }),
|
|
6916
6933
|
entries.map(([key], di) => {
|
|
6917
6934
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
6918
6935
|
const color = palette[2];
|
|
@@ -6921,16 +6938,16 @@ var LineChart = import_react6.default.memo(({ data, labels, width, height, anima
|
|
|
6921
6938
|
const gradientId = `line-gradient-${di}`;
|
|
6922
6939
|
const polyPoints = points.map((p) => `${p.x},${p.y}`).join(" ");
|
|
6923
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`;
|
|
6924
|
-
return /* @__PURE__ */ (0,
|
|
6925
|
-
/* @__PURE__ */ (0,
|
|
6926
|
-
/* @__PURE__ */ (0,
|
|
6927
|
-
/* @__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" })
|
|
6928
6945
|
] }) }),
|
|
6929
|
-
/* @__PURE__ */ (0,
|
|
6930
|
-
/* @__PURE__ */ (0,
|
|
6931
|
-
/* @__PURE__ */ (0,
|
|
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" })
|
|
6932
6949
|
] }),
|
|
6933
|
-
activeIndex !== null && points[activeIndex] && /* @__PURE__ */ (0,
|
|
6950
|
+
activeIndex !== null && points[activeIndex] && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
6934
6951
|
"circle",
|
|
6935
6952
|
{
|
|
6936
6953
|
cx: points[activeIndex].x,
|
|
@@ -6942,7 +6959,7 @@ var LineChart = import_react6.default.memo(({ data, labels, width, height, anima
|
|
|
6942
6959
|
)
|
|
6943
6960
|
] }, di);
|
|
6944
6961
|
}),
|
|
6945
|
-
activeX !== null && /* @__PURE__ */ (0,
|
|
6962
|
+
activeX !== null && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
6946
6963
|
"line",
|
|
6947
6964
|
{
|
|
6948
6965
|
x1: activeX,
|
|
@@ -6952,7 +6969,7 @@ var LineChart = import_react6.default.memo(({ data, labels, width, height, anima
|
|
|
6952
6969
|
className: "chart-crosshair"
|
|
6953
6970
|
}
|
|
6954
6971
|
),
|
|
6955
|
-
/* @__PURE__ */ (0,
|
|
6972
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
6956
6973
|
"rect",
|
|
6957
6974
|
{
|
|
6958
6975
|
x: PADDING.left,
|
|
@@ -6968,16 +6985,16 @@ var LineChart = import_react6.default.memo(({ data, labels, width, height, anima
|
|
|
6968
6985
|
);
|
|
6969
6986
|
});
|
|
6970
6987
|
LineChart.displayName = "LineChart";
|
|
6971
|
-
var CurveChart =
|
|
6972
|
-
const entries =
|
|
6973
|
-
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(() => {
|
|
6974
6991
|
const allValues = entries.flatMap(([, v]) => v);
|
|
6975
6992
|
return Math.max(...allValues) * 1.2 || 1;
|
|
6976
6993
|
}, [entries]);
|
|
6977
6994
|
const count = labels.length;
|
|
6978
6995
|
const chartW = width - PADDING.left - PADDING.right;
|
|
6979
6996
|
const chartH = height - PADDING.top - PADDING.bottom;
|
|
6980
|
-
const seriesPoints =
|
|
6997
|
+
const seriesPoints = import_react7.default.useMemo(
|
|
6981
6998
|
() => entries.map(
|
|
6982
6999
|
([, values]) => values.map((v, i) => ({
|
|
6983
7000
|
x: PADDING.left + i / (count - 1 || 1) * chartW,
|
|
@@ -6987,9 +7004,9 @@ var CurveChart = import_react6.default.memo(({ data, labels, width, height, anim
|
|
|
6987
7004
|
),
|
|
6988
7005
|
[entries, count, chartW, chartH, maxVal]
|
|
6989
7006
|
);
|
|
6990
|
-
const curveClipRef =
|
|
7007
|
+
const curveClipRef = import_react7.default.useRef(null);
|
|
6991
7008
|
const { activeIndex, handleMouseMove, handleMouseLeave, getTooltipAt } = useCrosshair(seriesPoints, entries, labels, chartH);
|
|
6992
|
-
|
|
7009
|
+
import_react7.default.useEffect(() => {
|
|
6993
7010
|
if (!animate || !curveClipRef.current) return;
|
|
6994
7011
|
curveClipRef.current.setAttribute("width", "0");
|
|
6995
7012
|
requestAnimationFrame(() => {
|
|
@@ -7001,7 +7018,7 @@ var CurveChart = import_react6.default.memo(({ data, labels, width, height, anim
|
|
|
7001
7018
|
}, [animate, width]);
|
|
7002
7019
|
const activeX = activeIndex !== null ? seriesPoints[0]?.[activeIndex]?.x ?? null : null;
|
|
7003
7020
|
const curveClipId = "curve-area-clip";
|
|
7004
|
-
return /* @__PURE__ */ (0,
|
|
7021
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)(
|
|
7005
7022
|
"svg",
|
|
7006
7023
|
{
|
|
7007
7024
|
viewBox: `0 0 ${width} ${height}`,
|
|
@@ -7034,9 +7051,9 @@ var CurveChart = import_react6.default.memo(({ data, labels, width, height, anim
|
|
|
7034
7051
|
onLeave();
|
|
7035
7052
|
},
|
|
7036
7053
|
children: [
|
|
7037
|
-
animate && /* @__PURE__ */ (0,
|
|
7038
|
-
/* @__PURE__ */ (0,
|
|
7039
|
-
/* @__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 }),
|
|
7040
7057
|
entries.map(([key], di) => {
|
|
7041
7058
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
7042
7059
|
const color = palette[2];
|
|
@@ -7045,16 +7062,16 @@ var CurveChart = import_react6.default.memo(({ data, labels, width, height, anim
|
|
|
7045
7062
|
const gradientId = `curve-gradient-${di}`;
|
|
7046
7063
|
const linePath = toSmoothPath(points);
|
|
7047
7064
|
const areaPath = linePath + ` L ${points[points.length - 1].x} ${PADDING.top + chartH} L ${points[0].x} ${PADDING.top + chartH} Z`;
|
|
7048
|
-
return /* @__PURE__ */ (0,
|
|
7049
|
-
/* @__PURE__ */ (0,
|
|
7050
|
-
/* @__PURE__ */ (0,
|
|
7051
|
-
/* @__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" })
|
|
7052
7069
|
] }) }),
|
|
7053
|
-
/* @__PURE__ */ (0,
|
|
7054
|
-
/* @__PURE__ */ (0,
|
|
7055
|
-
/* @__PURE__ */ (0,
|
|
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" })
|
|
7056
7073
|
] }),
|
|
7057
|
-
activeIndex !== null && points[activeIndex] && /* @__PURE__ */ (0,
|
|
7074
|
+
activeIndex !== null && points[activeIndex] && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
7058
7075
|
"circle",
|
|
7059
7076
|
{
|
|
7060
7077
|
cx: points[activeIndex].x,
|
|
@@ -7066,7 +7083,7 @@ var CurveChart = import_react6.default.memo(({ data, labels, width, height, anim
|
|
|
7066
7083
|
)
|
|
7067
7084
|
] }, di);
|
|
7068
7085
|
}),
|
|
7069
|
-
activeX !== null && /* @__PURE__ */ (0,
|
|
7086
|
+
activeX !== null && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
7070
7087
|
"line",
|
|
7071
7088
|
{
|
|
7072
7089
|
x1: activeX,
|
|
@@ -7076,7 +7093,7 @@ var CurveChart = import_react6.default.memo(({ data, labels, width, height, anim
|
|
|
7076
7093
|
className: "chart-crosshair"
|
|
7077
7094
|
}
|
|
7078
7095
|
),
|
|
7079
|
-
/* @__PURE__ */ (0,
|
|
7096
|
+
/* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
7080
7097
|
"rect",
|
|
7081
7098
|
{
|
|
7082
7099
|
x: PADDING.left,
|
|
@@ -7092,9 +7109,9 @@ var CurveChart = import_react6.default.memo(({ data, labels, width, height, anim
|
|
|
7092
7109
|
);
|
|
7093
7110
|
});
|
|
7094
7111
|
CurveChart.displayName = "CurveChart";
|
|
7095
|
-
var BarChart =
|
|
7096
|
-
const entries =
|
|
7097
|
-
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(() => {
|
|
7098
7115
|
const allValues = entries.flatMap(([, v]) => v);
|
|
7099
7116
|
return Math.max(...allValues) * 1.2 || 1;
|
|
7100
7117
|
}, [entries]);
|
|
@@ -7106,7 +7123,7 @@ var BarChart = import_react6.default.memo(({ data, labels, width, height, animat
|
|
|
7106
7123
|
const barGap = groupCount > 1 ? 2 : 0;
|
|
7107
7124
|
const barW = Math.max(1, Math.min(32, (groupW * 0.7 - barGap * (groupCount - 1)) / groupCount));
|
|
7108
7125
|
const baseline = PADDING.top + chartH;
|
|
7109
|
-
const bars =
|
|
7126
|
+
const bars = import_react7.default.useMemo(
|
|
7110
7127
|
() => entries.map(
|
|
7111
7128
|
([, values], di) => values.map((v, i) => {
|
|
7112
7129
|
const totalBarsW = barW * groupCount + barGap * (groupCount - 1);
|
|
@@ -7119,11 +7136,11 @@ var BarChart = import_react6.default.memo(({ data, labels, width, height, animat
|
|
|
7119
7136
|
[entries, maxVal, chartH, groupW, barW, barGap, groupCount]
|
|
7120
7137
|
);
|
|
7121
7138
|
const barLabelStep = getLabelStep(count, chartW);
|
|
7122
|
-
return /* @__PURE__ */ (0,
|
|
7123
|
-
/* @__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 }),
|
|
7124
7141
|
labels.map((label, i) => {
|
|
7125
7142
|
if (i % barLabelStep !== 0) return null;
|
|
7126
|
-
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);
|
|
7127
7144
|
}),
|
|
7128
7145
|
entries.map(([key], di) => {
|
|
7129
7146
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
@@ -7132,7 +7149,7 @@ var BarChart = import_react6.default.memo(({ data, labels, width, height, animat
|
|
|
7132
7149
|
const r2 = Math.min(4, b.w / 2);
|
|
7133
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`;
|
|
7134
7151
|
const delay = 100 + i * 80;
|
|
7135
|
-
return /* @__PURE__ */ (0,
|
|
7152
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
7136
7153
|
"path",
|
|
7137
7154
|
{
|
|
7138
7155
|
d,
|
|
@@ -7153,11 +7170,11 @@ var BarChart = import_react6.default.memo(({ data, labels, width, height, animat
|
|
|
7153
7170
|
] });
|
|
7154
7171
|
});
|
|
7155
7172
|
BarChart.displayName = "BarChart";
|
|
7156
|
-
var PieDonutChart =
|
|
7173
|
+
var PieDonutChart = import_react7.default.memo(
|
|
7157
7174
|
({ data, labels, width, height, animate, isDoughnut, onHover, onMove, onLeave }) => {
|
|
7158
|
-
const entries =
|
|
7159
|
-
const values =
|
|
7160
|
-
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]);
|
|
7161
7178
|
const size = Math.min(width, height);
|
|
7162
7179
|
const cx = size / 2;
|
|
7163
7180
|
const cy = size / 2;
|
|
@@ -7165,10 +7182,10 @@ var PieDonutChart = import_react6.default.memo(
|
|
|
7165
7182
|
const innerR = isDoughnut ? r2 * 0.5 : 0;
|
|
7166
7183
|
const firstKey = entries[0]?.[0] ?? "";
|
|
7167
7184
|
const colorOffset = hashString(firstKey);
|
|
7168
|
-
const maskRef =
|
|
7185
|
+
const maskRef = import_react7.default.useRef(null);
|
|
7169
7186
|
const maskR = r2 + 10;
|
|
7170
7187
|
const maskCircumference = 2 * Math.PI * maskR;
|
|
7171
|
-
|
|
7188
|
+
import_react7.default.useEffect(() => {
|
|
7172
7189
|
if (!animate || !maskRef.current) return;
|
|
7173
7190
|
const el = maskRef.current;
|
|
7174
7191
|
el.style.strokeDasharray = `${maskCircumference}`;
|
|
@@ -7178,7 +7195,7 @@ var PieDonutChart = import_react6.default.memo(
|
|
|
7178
7195
|
el.style.strokeDashoffset = "0";
|
|
7179
7196
|
});
|
|
7180
7197
|
}, [animate, maskCircumference]);
|
|
7181
|
-
const sliceData =
|
|
7198
|
+
const sliceData = import_react7.default.useMemo(() => {
|
|
7182
7199
|
let angle0 = -Math.PI / 2;
|
|
7183
7200
|
let cumulativeAngle = 0;
|
|
7184
7201
|
return values.map((v, i) => {
|
|
@@ -7212,8 +7229,8 @@ var PieDonutChart = import_react6.default.memo(
|
|
|
7212
7229
|
});
|
|
7213
7230
|
}, [values, total, cx, cy, r2, innerR, labels]);
|
|
7214
7231
|
const maskId = `pie-mask-${isDoughnut ? "d" : "p"}`;
|
|
7215
|
-
return /* @__PURE__ */ (0,
|
|
7216
|
-
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)(
|
|
7217
7234
|
"circle",
|
|
7218
7235
|
{
|
|
7219
7236
|
ref: maskRef,
|
|
@@ -7226,7 +7243,7 @@ var PieDonutChart = import_react6.default.memo(
|
|
|
7226
7243
|
transform: `rotate(-90 ${cx} ${cy})`
|
|
7227
7244
|
}
|
|
7228
7245
|
) }) }),
|
|
7229
|
-
/* @__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)(
|
|
7230
7247
|
"path",
|
|
7231
7248
|
{
|
|
7232
7249
|
d: s.d,
|
|
@@ -7237,7 +7254,7 @@ var PieDonutChart = import_react6.default.memo(
|
|
|
7237
7254
|
onMouseLeave: onLeave
|
|
7238
7255
|
}
|
|
7239
7256
|
) }, i)) }),
|
|
7240
|
-
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)(
|
|
7241
7258
|
"text",
|
|
7242
7259
|
{
|
|
7243
7260
|
x: s.lx,
|
|
@@ -7255,9 +7272,9 @@ var PieDonutChart = import_react6.default.memo(
|
|
|
7255
7272
|
);
|
|
7256
7273
|
PieDonutChart.displayName = "PieDonutChart";
|
|
7257
7274
|
var ChartTooltipPortal = ({ clientX, clientY, visible, children }) => {
|
|
7258
|
-
const ref =
|
|
7259
|
-
const [pos, setPos] =
|
|
7260
|
-
|
|
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(() => {
|
|
7261
7278
|
const el = ref.current;
|
|
7262
7279
|
if (!el) return;
|
|
7263
7280
|
const w = el.offsetWidth;
|
|
@@ -7270,7 +7287,7 @@ var ChartTooltipPortal = ({ clientX, clientY, visible, children }) => {
|
|
|
7270
7287
|
if (left < 8) left = 8;
|
|
7271
7288
|
setPos({ left, top });
|
|
7272
7289
|
}, [clientX, clientY]);
|
|
7273
|
-
return /* @__PURE__ */ (0,
|
|
7290
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
|
|
7274
7291
|
"div",
|
|
7275
7292
|
{
|
|
7276
7293
|
ref,
|
|
@@ -7287,14 +7304,14 @@ var ChartLegend = ({ data, labels, type }) => {
|
|
|
7287
7304
|
const total = values.reduce((a, b) => a + b, 0) || 1;
|
|
7288
7305
|
const firstKey = entries[0]?.[0] ?? "";
|
|
7289
7306
|
const colorOffset = hashString(firstKey);
|
|
7290
|
-
return /* @__PURE__ */ (0,
|
|
7307
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("div", { className: "chart-legend", children: values.map((v, i) => {
|
|
7291
7308
|
const pct = Math.round(v / total * 100);
|
|
7292
7309
|
const color = PIE_COLORS[(i + colorOffset) % PIE_COLORS.length];
|
|
7293
|
-
return /* @__PURE__ */ (0,
|
|
7294
|
-
/* @__PURE__ */ (0,
|
|
7295
|
-
/* @__PURE__ */ (0,
|
|
7296
|
-
/* @__PURE__ */ (0,
|
|
7297
|
-
/* @__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: [
|
|
7298
7315
|
v.toLocaleString(),
|
|
7299
7316
|
"(",
|
|
7300
7317
|
pct,
|
|
@@ -7304,37 +7321,37 @@ var ChartLegend = ({ data, labels, type }) => {
|
|
|
7304
7321
|
] }, i);
|
|
7305
7322
|
}) });
|
|
7306
7323
|
}
|
|
7307
|
-
return /* @__PURE__ */ (0,
|
|
7324
|
+
return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("div", { className: "chart-legend", children: entries.map(([key], di) => {
|
|
7308
7325
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
7309
7326
|
const color = palette[2];
|
|
7310
7327
|
const values = entries[di][1];
|
|
7311
7328
|
const sum = values.reduce((a, b) => a + b, 0);
|
|
7312
|
-
return /* @__PURE__ */ (0,
|
|
7313
|
-
/* @__PURE__ */ (0,
|
|
7314
|
-
/* @__PURE__ */ (0,
|
|
7315
|
-
/* @__PURE__ */ (0,
|
|
7316
|
-
/* @__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() })
|
|
7317
7334
|
] })
|
|
7318
7335
|
] }, di);
|
|
7319
7336
|
}) });
|
|
7320
7337
|
};
|
|
7321
|
-
var Chart =
|
|
7338
|
+
var Chart = import_react7.default.memo((props) => {
|
|
7322
7339
|
const { type, data, labels, tooltip: showTooltip = true } = props;
|
|
7323
7340
|
const { tooltip, show, hide, move, containerRef } = useChartTooltip(showTooltip);
|
|
7324
7341
|
const { width, height } = useChartSize(containerRef);
|
|
7325
|
-
const stableData =
|
|
7326
|
-
const stableLabels =
|
|
7327
|
-
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]);
|
|
7328
7345
|
const animate = useChartAnimation(containerRef, dataKey);
|
|
7329
7346
|
const ready = width > 0 && height > 0;
|
|
7330
|
-
return /* @__PURE__ */ (0,
|
|
7331
|
-
ready && type === "line" && /* @__PURE__ */ (0,
|
|
7332
|
-
ready && type === "curve" && /* @__PURE__ */ (0,
|
|
7333
|
-
ready && type === "bar" && /* @__PURE__ */ (0,
|
|
7334
|
-
ready && type === "pie" && /* @__PURE__ */ (0,
|
|
7335
|
-
ready && type === "doughnut" && /* @__PURE__ */ (0,
|
|
7336
|
-
ready && (type === "bar" || type === "pie" || type === "doughnut") && /* @__PURE__ */ (0,
|
|
7337
|
-
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 }) })
|
|
7338
7355
|
] });
|
|
7339
7356
|
});
|
|
7340
7357
|
Chart.displayName = "Chart";
|
|
@@ -7360,7 +7377,7 @@ var import_tokens_core = require("@x-plat/tokens-core");
|
|
|
7360
7377
|
var import_tokens_core2 = require("@x-plat/tokens-core");
|
|
7361
7378
|
|
|
7362
7379
|
// src/components/CheckBox/CheckBox.tsx
|
|
7363
|
-
var
|
|
7380
|
+
var import_jsx_runtime309 = require("react/jsx-runtime");
|
|
7364
7381
|
var CheckBox = (props) => {
|
|
7365
7382
|
const {
|
|
7366
7383
|
checked,
|
|
@@ -7378,8 +7395,8 @@ var CheckBox = (props) => {
|
|
|
7378
7395
|
const checkedClasses = `checked`;
|
|
7379
7396
|
const disabledClasses = "disabled";
|
|
7380
7397
|
const boxClasses = disabled ? disabledClasses : checked ? checkedClasses : uncheckedClasses;
|
|
7381
|
-
return /* @__PURE__ */ (0,
|
|
7382
|
-
/* @__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)(
|
|
7383
7400
|
"input",
|
|
7384
7401
|
{
|
|
7385
7402
|
type: "checkbox",
|
|
@@ -7389,22 +7406,22 @@ var CheckBox = (props) => {
|
|
|
7389
7406
|
...rest
|
|
7390
7407
|
}
|
|
7391
7408
|
),
|
|
7392
|
-
/* @__PURE__ */ (0,
|
|
7393
|
-
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 })
|
|
7394
7411
|
] });
|
|
7395
7412
|
};
|
|
7396
7413
|
CheckBox.displayName = "CheckBox";
|
|
7397
7414
|
var CheckBox_default = CheckBox;
|
|
7398
7415
|
|
|
7399
7416
|
// src/components/Chip/Chip.tsx
|
|
7400
|
-
var
|
|
7417
|
+
var import_jsx_runtime310 = require("react/jsx-runtime");
|
|
7401
7418
|
var Chip = (props) => {
|
|
7402
7419
|
const {
|
|
7403
7420
|
children,
|
|
7404
7421
|
type = "primary",
|
|
7405
7422
|
size = "md"
|
|
7406
7423
|
} = props;
|
|
7407
|
-
return /* @__PURE__ */ (0,
|
|
7424
|
+
return /* @__PURE__ */ (0, import_jsx_runtime310.jsx)("div", { className: clsx_default("lib-xplat-chip", type, size), children });
|
|
7408
7425
|
};
|
|
7409
7426
|
Chip.displayName = "Chip";
|
|
7410
7427
|
var Chip_default = Chip;
|
|
@@ -7413,20 +7430,20 @@ var Chip_default = Chip;
|
|
|
7413
7430
|
var import_react13 = __toESM(require("react"), 1);
|
|
7414
7431
|
|
|
7415
7432
|
// src/components/Input/Input.tsx
|
|
7416
|
-
var
|
|
7433
|
+
var import_react8 = __toESM(require("react"), 1);
|
|
7417
7434
|
|
|
7418
7435
|
// src/components/Input/InputValidations.tsx
|
|
7419
|
-
var
|
|
7436
|
+
var import_jsx_runtime311 = require("react/jsx-runtime");
|
|
7420
7437
|
var InputValidations = (props) => {
|
|
7421
7438
|
const { message, status = "default" } = props;
|
|
7422
|
-
return /* @__PURE__ */ (0,
|
|
7423
|
-
/* @__PURE__ */ (0,
|
|
7424
|
-
status === "default" && /* @__PURE__ */ (0,
|
|
7425
|
-
status === "success" && /* @__PURE__ */ (0,
|
|
7426
|
-
status === "warning" && /* @__PURE__ */ (0,
|
|
7427
|
-
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, {})
|
|
7428
7445
|
] }),
|
|
7429
|
-
/* @__PURE__ */ (0,
|
|
7446
|
+
/* @__PURE__ */ (0, import_jsx_runtime311.jsx)("div", { className: "message", children: message })
|
|
7430
7447
|
] });
|
|
7431
7448
|
};
|
|
7432
7449
|
InputValidations.displayName = "InputValidations";
|
|
@@ -7467,8 +7484,8 @@ var handleTelBackspace = (prevValue, currValue) => {
|
|
|
7467
7484
|
};
|
|
7468
7485
|
|
|
7469
7486
|
// src/components/Input/Input.tsx
|
|
7470
|
-
var
|
|
7471
|
-
var
|
|
7487
|
+
var import_jsx_runtime312 = require("react/jsx-runtime");
|
|
7488
|
+
var import_react9 = require("react");
|
|
7472
7489
|
var formatValue = (type, value) => {
|
|
7473
7490
|
if (value === null || value === void 0) return "";
|
|
7474
7491
|
const strValue = Array.isArray(value) ? String(value[0] ?? "") : String(value);
|
|
@@ -7516,7 +7533,7 @@ var parseValue = (type, value) => {
|
|
|
7516
7533
|
return value;
|
|
7517
7534
|
}
|
|
7518
7535
|
};
|
|
7519
|
-
var Input =
|
|
7536
|
+
var Input = import_react8.default.forwardRef((props, ref) => {
|
|
7520
7537
|
const {
|
|
7521
7538
|
value,
|
|
7522
7539
|
onChange,
|
|
@@ -7542,13 +7559,13 @@ var Input = import_react7.default.forwardRef((props, ref) => {
|
|
|
7542
7559
|
onChange(event);
|
|
7543
7560
|
}
|
|
7544
7561
|
};
|
|
7545
|
-
return /* @__PURE__ */ (0,
|
|
7546
|
-
/* @__PURE__ */ (0,
|
|
7562
|
+
return /* @__PURE__ */ (0, import_jsx_runtime312.jsxs)("div", { className: "lib-xplat-input-wrap", children: [
|
|
7563
|
+
/* @__PURE__ */ (0, import_jsx_runtime312.jsxs)(
|
|
7547
7564
|
"div",
|
|
7548
7565
|
{
|
|
7549
7566
|
className: clsx_default("lib-xplat-input", size, disabled ? "disabled" : void 0),
|
|
7550
7567
|
children: [
|
|
7551
|
-
/* @__PURE__ */ (0,
|
|
7568
|
+
/* @__PURE__ */ (0, import_jsx_runtime312.jsx)(
|
|
7552
7569
|
"input",
|
|
7553
7570
|
{
|
|
7554
7571
|
...inputProps,
|
|
@@ -7559,11 +7576,11 @@ var Input = import_react7.default.forwardRef((props, ref) => {
|
|
|
7559
7576
|
onChange: handleChange
|
|
7560
7577
|
}
|
|
7561
7578
|
),
|
|
7562
|
-
suffix && /* @__PURE__ */ (0,
|
|
7579
|
+
suffix && /* @__PURE__ */ (0, import_jsx_runtime312.jsx)("div", { className: "suffix", children: suffix })
|
|
7563
7580
|
]
|
|
7564
7581
|
}
|
|
7565
7582
|
),
|
|
7566
|
-
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)(
|
|
7567
7584
|
InputValidations_default,
|
|
7568
7585
|
{
|
|
7569
7586
|
...validation,
|
|
@@ -7576,20 +7593,20 @@ Input.displayName = "Input";
|
|
|
7576
7593
|
var Input_default = Input;
|
|
7577
7594
|
|
|
7578
7595
|
// src/components/Input/PasswordInput/PasswordInput.tsx
|
|
7579
|
-
var
|
|
7580
|
-
var
|
|
7581
|
-
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(
|
|
7582
7599
|
(props, ref) => {
|
|
7583
7600
|
const { reg: _reg, ...inputProps } = props;
|
|
7584
|
-
const [isView, setIsView] =
|
|
7601
|
+
const [isView, setIsView] = import_react10.default.useState(false);
|
|
7585
7602
|
const handleChangeView = () => {
|
|
7586
7603
|
setIsView((prev) => !prev);
|
|
7587
7604
|
};
|
|
7588
|
-
return /* @__PURE__ */ (0,
|
|
7605
|
+
return /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(
|
|
7589
7606
|
Input_default,
|
|
7590
7607
|
{
|
|
7591
7608
|
...inputProps,
|
|
7592
|
-
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, {}) }),
|
|
7593
7610
|
type: isView ? "text" : "password",
|
|
7594
7611
|
ref
|
|
7595
7612
|
}
|
|
@@ -7602,23 +7619,6 @@ var PasswordInput_default = PasswordInput;
|
|
|
7602
7619
|
// src/components/Modal/Modal.tsx
|
|
7603
7620
|
var import_react11 = __toESM(require("react"), 1);
|
|
7604
7621
|
var import_react_dom2 = require("react-dom");
|
|
7605
|
-
|
|
7606
|
-
// src/tokens/hooks/Portal.tsx
|
|
7607
|
-
var import_react10 = __toESM(require("react"), 1);
|
|
7608
|
-
var import_react_dom = __toESM(require("react-dom"), 1);
|
|
7609
|
-
var import_jsx_runtime313 = require("react/jsx-runtime");
|
|
7610
|
-
var PortalContainerContext = import_react10.default.createContext(null);
|
|
7611
|
-
var PortalProvider = ({ container, children }) => /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(PortalContainerContext.Provider, { value: container, children });
|
|
7612
|
-
var Portal = ({ children }) => {
|
|
7613
|
-
const contextContainer = import_react10.default.useContext(PortalContainerContext);
|
|
7614
|
-
if (typeof document === "undefined") return null;
|
|
7615
|
-
const container = contextContainer ?? document.body;
|
|
7616
|
-
return import_react_dom.default.createPortal(children, container);
|
|
7617
|
-
};
|
|
7618
|
-
Portal.displayName = "Portal";
|
|
7619
|
-
var Portal_default = Portal;
|
|
7620
|
-
|
|
7621
|
-
// src/components/Modal/Modal.tsx
|
|
7622
7622
|
var import_jsx_runtime314 = require("react/jsx-runtime");
|
|
7623
7623
|
var ANIMATION_DURATION_MS = 200;
|
|
7624
7624
|
var Modal = (props) => {
|