@x-plat/design-system 0.5.66 → 0.6.1
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/Accordion/index.css +6 -6
- package/dist/components/AutoResizeTextArea/index.css +5 -5
- package/dist/components/Avatar/index.css +2 -2
- package/dist/components/Badge/index.css +1 -1
- package/dist/components/Box/index.css +5 -5
- package/dist/components/Breadcrumb/index.css +4 -4
- package/dist/components/Button/index.cjs +1 -2
- package/dist/components/Button/index.css +6 -6
- package/dist/components/Button/index.d.cts +1 -1
- package/dist/components/Button/index.d.ts +1 -1
- package/dist/components/Button/index.js +1 -2
- package/dist/components/Calendar/index.cjs +1 -1
- package/dist/components/Calendar/index.css +18 -18
- package/dist/components/Calendar/index.js +1 -1
- package/dist/components/CardTab/index.css +8 -8
- package/dist/components/Chart/index.css +11 -11
- package/dist/components/ChatInput/index.cjs +1 -2
- package/dist/components/ChatInput/index.css +16 -16
- package/dist/components/ChatInput/index.js +1 -2
- package/dist/components/CheckBox/index.css +2 -2
- package/dist/components/CheckBox/index.js +1 -1
- package/dist/components/Chip/index.css +5 -5
- package/dist/components/DatePicker/index.cjs +1 -2
- package/dist/components/DatePicker/index.css +36 -36
- package/dist/components/DatePicker/index.js +1 -2
- package/dist/components/Divider/index.css +2 -2
- package/dist/components/Drawer/index.css +5 -5
- package/dist/components/Dropdown/index.css +4 -4
- package/dist/components/Editor/index.css +36 -36
- package/dist/components/EmptyState/index.css +2 -2
- package/dist/components/FileUpload/index.css +4 -4
- package/dist/components/HtmlTypeWriter/index.css +1 -1
- package/dist/components/IconButton/index.cjs +1 -2
- package/dist/components/IconButton/index.css +5 -5
- package/dist/components/IconButton/index.d.cts +1 -1
- package/dist/components/IconButton/index.d.ts +1 -1
- package/dist/components/IconButton/index.js +1 -2
- package/dist/components/ImageSelector/index.css +7 -7
- package/dist/components/Input/index.css +7 -7
- package/dist/components/Modal/index.css +1 -1
- package/dist/components/Pagination/index.css +3 -3
- package/dist/components/PopOver/index.css +1 -1
- package/dist/components/Progress/index.css +1 -1
- package/dist/components/Radio/index.css +5 -5
- package/dist/components/Select/index.css +9 -9
- package/dist/components/Skeleton/index.cjs +6 -6
- package/dist/components/Skeleton/index.js +6 -6
- package/dist/components/Spinner/index.css +1 -1
- package/dist/components/Steps/index.css +3 -3
- package/dist/components/Swiper/index.css +3 -3
- package/dist/components/Switch/index.css +3 -3
- package/dist/components/Tab/index.css +4 -4
- package/dist/components/Table/index.css +10 -10
- package/dist/components/Tag/index.css +3 -3
- package/dist/components/TextArea/index.css +5 -5
- package/dist/components/Tooltip/index.css +4 -4
- package/dist/components/Video/index.css +2 -2
- package/dist/components/index.cjs +249 -251
- package/dist/components/index.css +667 -1059
- package/dist/components/index.d.cts +2 -2
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.js +224 -226
- package/dist/index.cjs +249 -253
- package/dist/index.css +670 -1062
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +224 -227
- package/dist/layout/Header/index.css +2 -2
- package/dist/layout/Layout/index.css +1 -1
- package/dist/layout/index.css +404 -796
- package/dist/tokens/index.cjs +0 -2
- package/dist/tokens/index.d.cts +9 -10
- package/dist/tokens/index.d.ts +9 -10
- package/dist/tokens/index.js +1 -2
- package/guidelines/AGENT_PROMPT.md +8 -9
- package/guidelines/Guidelines.md +1 -1
- package/guidelines/components/chart.md +1 -1
- package/guidelines/foundations/color.md +22 -23
- package/guidelines/foundations/typography.md +86 -36
- package/package.json +1 -1
|
@@ -1595,8 +1595,69 @@ var Alert = (props) => {
|
|
|
1595
1595
|
Alert.displayName = "Alert";
|
|
1596
1596
|
var Alert_default = Alert;
|
|
1597
1597
|
|
|
1598
|
-
// src/components/
|
|
1598
|
+
// src/components/AutoResizeTextArea/AutoResizeTextArea.tsx
|
|
1599
|
+
var import_react2 = __toESM(require("react"), 1);
|
|
1599
1600
|
var import_jsx_runtime297 = require("react/jsx-runtime");
|
|
1601
|
+
var MAX_HEIGHT = 400;
|
|
1602
|
+
var AutoResizeTextArea = import_react2.default.forwardRef(
|
|
1603
|
+
(props, ref) => {
|
|
1604
|
+
const { value, className, onChange, disabled, bare = false, ...textareaProps } = props;
|
|
1605
|
+
const localRef = import_react2.default.useRef(null);
|
|
1606
|
+
const setRefs = (el) => {
|
|
1607
|
+
localRef.current = el;
|
|
1608
|
+
if (!ref) return;
|
|
1609
|
+
if (typeof ref === "function") ref(el);
|
|
1610
|
+
else if (ref && "current" in ref)
|
|
1611
|
+
ref.current = el;
|
|
1612
|
+
};
|
|
1613
|
+
const updateHeight = () => {
|
|
1614
|
+
const el = localRef.current;
|
|
1615
|
+
if (!el) return;
|
|
1616
|
+
el.style.height = "0px";
|
|
1617
|
+
el.style.height = `${Math.min(el.scrollHeight, MAX_HEIGHT)}px`;
|
|
1618
|
+
};
|
|
1619
|
+
const handleChange = (e) => {
|
|
1620
|
+
if (onChange) {
|
|
1621
|
+
const event = {
|
|
1622
|
+
...e,
|
|
1623
|
+
target: { value: e.target.value }
|
|
1624
|
+
};
|
|
1625
|
+
onChange(event);
|
|
1626
|
+
}
|
|
1627
|
+
};
|
|
1628
|
+
import_react2.default.useEffect(() => {
|
|
1629
|
+
updateHeight();
|
|
1630
|
+
}, [value]);
|
|
1631
|
+
if (bare) {
|
|
1632
|
+
return /* @__PURE__ */ (0, import_jsx_runtime297.jsx)(
|
|
1633
|
+
"textarea",
|
|
1634
|
+
{
|
|
1635
|
+
...textareaProps,
|
|
1636
|
+
ref: setRefs,
|
|
1637
|
+
className,
|
|
1638
|
+
disabled,
|
|
1639
|
+
value,
|
|
1640
|
+
onChange: handleChange
|
|
1641
|
+
}
|
|
1642
|
+
);
|
|
1643
|
+
}
|
|
1644
|
+
return /* @__PURE__ */ (0, import_jsx_runtime297.jsx)("div", { className: clsx_default("lib-xplat-auto-resize-textarea-wrapper", className), children: /* @__PURE__ */ (0, import_jsx_runtime297.jsx)("div", { className: clsx_default("lib-xplat-auto-resize-textarea", disabled && "disabled"), children: /* @__PURE__ */ (0, import_jsx_runtime297.jsx)(
|
|
1645
|
+
"textarea",
|
|
1646
|
+
{
|
|
1647
|
+
...textareaProps,
|
|
1648
|
+
ref: setRefs,
|
|
1649
|
+
disabled,
|
|
1650
|
+
value,
|
|
1651
|
+
onChange: handleChange
|
|
1652
|
+
}
|
|
1653
|
+
) }) });
|
|
1654
|
+
}
|
|
1655
|
+
);
|
|
1656
|
+
AutoResizeTextArea.displayName = "AutoResizeTextArea";
|
|
1657
|
+
var AutoResizeTextArea_default = AutoResizeTextArea;
|
|
1658
|
+
|
|
1659
|
+
// src/components/Avatar/Avatar.tsx
|
|
1660
|
+
var import_jsx_runtime298 = require("react/jsx-runtime");
|
|
1600
1661
|
var CATEGORICAL_COUNT = 8;
|
|
1601
1662
|
var getColorIndex = (name) => {
|
|
1602
1663
|
if (!name) return 1;
|
|
@@ -1613,13 +1674,13 @@ var Avatar = (props) => {
|
|
|
1613
1674
|
const fullInitials = name ? name.split(" ").map((s) => s[0]).join("").slice(0, 2).toUpperCase() : "";
|
|
1614
1675
|
const initials = size === "sm" ? fullInitials.slice(0, 1) : fullInitials;
|
|
1615
1676
|
const catIndex = getColorIndex(name || "");
|
|
1616
|
-
return /* @__PURE__ */ (0,
|
|
1677
|
+
return /* @__PURE__ */ (0, import_jsx_runtime298.jsx)("div", { className: clsx_default("lib-xplat-avatar", size), children: src ? /* @__PURE__ */ (0, import_jsx_runtime298.jsx)("img", { src, alt: alt || name || "avatar" }) : /* @__PURE__ */ (0, import_jsx_runtime298.jsx)("div", { className: clsx_default("fallback", `cat-${catIndex}`), children: initials || /* @__PURE__ */ (0, import_jsx_runtime298.jsx)("svg", { viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime298.jsx)("path", { d: "M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z" }) }) }) });
|
|
1617
1678
|
};
|
|
1618
1679
|
Avatar.displayName = "Avatar";
|
|
1619
1680
|
var Avatar_default = Avatar;
|
|
1620
1681
|
|
|
1621
1682
|
// src/components/Badge/Badge.tsx
|
|
1622
|
-
var
|
|
1683
|
+
var import_jsx_runtime299 = require("react/jsx-runtime");
|
|
1623
1684
|
var Badge = (props) => {
|
|
1624
1685
|
const {
|
|
1625
1686
|
children,
|
|
@@ -1631,39 +1692,39 @@ var Badge = (props) => {
|
|
|
1631
1692
|
} = props;
|
|
1632
1693
|
const showBadge = dot || count !== void 0 && count > 0;
|
|
1633
1694
|
const displayCount = count !== void 0 && count > maxCount ? `${maxCount}+` : count;
|
|
1634
|
-
return /* @__PURE__ */ (0,
|
|
1695
|
+
return /* @__PURE__ */ (0, import_jsx_runtime299.jsxs)("div", { className: clsx_default("lib-xplat-badge", size), children: [
|
|
1635
1696
|
children,
|
|
1636
|
-
showBadge && /* @__PURE__ */ (0,
|
|
1697
|
+
showBadge && /* @__PURE__ */ (0, import_jsx_runtime299.jsx)("span", { className: clsx_default("badge-indicator", type, { dot }), children: !dot && displayCount })
|
|
1637
1698
|
] });
|
|
1638
1699
|
};
|
|
1639
1700
|
Badge.displayName = "Badge";
|
|
1640
1701
|
var Badge_default = Badge;
|
|
1641
1702
|
|
|
1642
1703
|
// src/components/Box/Box.tsx
|
|
1643
|
-
var
|
|
1704
|
+
var import_jsx_runtime300 = require("react/jsx-runtime");
|
|
1644
1705
|
var Box = ({
|
|
1645
1706
|
children,
|
|
1646
1707
|
title,
|
|
1647
1708
|
variant = "outlined",
|
|
1648
1709
|
padding = "md"
|
|
1649
1710
|
}) => {
|
|
1650
|
-
return /* @__PURE__ */ (0,
|
|
1651
|
-
title && /* @__PURE__ */ (0,
|
|
1652
|
-
/* @__PURE__ */ (0,
|
|
1711
|
+
return /* @__PURE__ */ (0, import_jsx_runtime300.jsxs)("div", { className: clsx_default("lib-xplat-box", variant, `pad-${padding}`), children: [
|
|
1712
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime300.jsx)("div", { className: "box-title", children: title }),
|
|
1713
|
+
/* @__PURE__ */ (0, import_jsx_runtime300.jsx)("div", { className: "box-content", children })
|
|
1653
1714
|
] });
|
|
1654
1715
|
};
|
|
1655
1716
|
Box.displayName = "Box";
|
|
1656
1717
|
var Box_default = Box;
|
|
1657
1718
|
|
|
1658
1719
|
// src/components/Breadcrumb/Breadcrumb.tsx
|
|
1659
|
-
var
|
|
1720
|
+
var import_jsx_runtime301 = require("react/jsx-runtime");
|
|
1660
1721
|
var Breadcrumb = (props) => {
|
|
1661
1722
|
const { items, separator = "/" } = props;
|
|
1662
|
-
return /* @__PURE__ */ (0,
|
|
1723
|
+
return /* @__PURE__ */ (0, import_jsx_runtime301.jsx)("nav", { className: "lib-xplat-breadcrumb", "aria-label": "\uACBD\uB85C", children: /* @__PURE__ */ (0, import_jsx_runtime301.jsx)("ol", { children: items.map((item, index) => {
|
|
1663
1724
|
const isLast = index === items.length - 1;
|
|
1664
|
-
return /* @__PURE__ */ (0,
|
|
1665
|
-
isLast ? /* @__PURE__ */ (0,
|
|
1666
|
-
!isLast && /* @__PURE__ */ (0,
|
|
1725
|
+
return /* @__PURE__ */ (0, import_jsx_runtime301.jsxs)("li", { children: [
|
|
1726
|
+
isLast ? /* @__PURE__ */ (0, import_jsx_runtime301.jsx)("span", { className: "current", "aria-current": "page", children: item.label }) : item.href ? /* @__PURE__ */ (0, import_jsx_runtime301.jsx)("a", { href: item.href, className: "link", children: item.label }) : /* @__PURE__ */ (0, import_jsx_runtime301.jsx)("button", { className: "link", onClick: item.onClick, children: item.label }),
|
|
1727
|
+
!isLast && /* @__PURE__ */ (0, import_jsx_runtime301.jsx)("span", { className: "separator", children: separator })
|
|
1667
1728
|
] }, index);
|
|
1668
1729
|
}) }) });
|
|
1669
1730
|
};
|
|
@@ -1671,20 +1732,19 @@ Breadcrumb.displayName = "Breadcrumb";
|
|
|
1671
1732
|
var Breadcrumb_default = Breadcrumb;
|
|
1672
1733
|
|
|
1673
1734
|
// src/components/Button/Button.tsx
|
|
1674
|
-
var
|
|
1735
|
+
var import_jsx_runtime302 = require("react/jsx-runtime");
|
|
1675
1736
|
var Button = (props) => {
|
|
1676
1737
|
const {
|
|
1677
1738
|
children,
|
|
1678
|
-
className,
|
|
1679
1739
|
type = "primary",
|
|
1680
1740
|
size = "md",
|
|
1681
1741
|
disabled,
|
|
1682
1742
|
...rest
|
|
1683
1743
|
} = props;
|
|
1684
|
-
return /* @__PURE__ */ (0,
|
|
1744
|
+
return /* @__PURE__ */ (0, import_jsx_runtime302.jsx)(
|
|
1685
1745
|
"button",
|
|
1686
1746
|
{
|
|
1687
|
-
className: clsx_default("lib-xplat-button", type, size
|
|
1747
|
+
className: clsx_default("lib-xplat-button", type, size),
|
|
1688
1748
|
disabled,
|
|
1689
1749
|
...rest,
|
|
1690
1750
|
children
|
|
@@ -1695,15 +1755,15 @@ Button.displayName = "Button";
|
|
|
1695
1755
|
var Button_default = Button;
|
|
1696
1756
|
|
|
1697
1757
|
// src/components/Calendar/Calendar.tsx
|
|
1698
|
-
var
|
|
1758
|
+
var import_react4 = __toESM(require("react"), 1);
|
|
1699
1759
|
|
|
1700
1760
|
// src/components/Calendar/useCalendar.ts
|
|
1701
|
-
var
|
|
1761
|
+
var import_react3 = __toESM(require("react"), 1);
|
|
1702
1762
|
var useCalendar = (initialYear, initialMonth) => {
|
|
1703
1763
|
const today = /* @__PURE__ */ new Date();
|
|
1704
|
-
const [year, setYear] =
|
|
1705
|
-
const [month, setMonth] =
|
|
1706
|
-
const days =
|
|
1764
|
+
const [year, setYear] = import_react3.default.useState(initialYear ?? today.getFullYear());
|
|
1765
|
+
const [month, setMonth] = import_react3.default.useState(initialMonth ?? today.getMonth());
|
|
1766
|
+
const days = import_react3.default.useMemo(() => {
|
|
1707
1767
|
const firstDay = new Date(year, month, 1);
|
|
1708
1768
|
const lastDay = new Date(year, month + 1, 0);
|
|
1709
1769
|
const startDayOfWeek = firstDay.getDay();
|
|
@@ -1746,7 +1806,7 @@ var useCalendar = (initialYear, initialMonth) => {
|
|
|
1746
1806
|
}
|
|
1747
1807
|
return result;
|
|
1748
1808
|
}, [year, month]);
|
|
1749
|
-
const goToPrevMonth =
|
|
1809
|
+
const goToPrevMonth = import_react3.default.useCallback(() => {
|
|
1750
1810
|
setMonth((prev) => {
|
|
1751
1811
|
if (prev === 0) {
|
|
1752
1812
|
setYear((y) => y - 1);
|
|
@@ -1755,7 +1815,7 @@ var useCalendar = (initialYear, initialMonth) => {
|
|
|
1755
1815
|
return prev - 1;
|
|
1756
1816
|
});
|
|
1757
1817
|
}, []);
|
|
1758
|
-
const goToNextMonth =
|
|
1818
|
+
const goToNextMonth = import_react3.default.useCallback(() => {
|
|
1759
1819
|
setMonth((prev) => {
|
|
1760
1820
|
if (prev === 11) {
|
|
1761
1821
|
setYear((y) => y + 1);
|
|
@@ -1764,7 +1824,7 @@ var useCalendar = (initialYear, initialMonth) => {
|
|
|
1764
1824
|
return prev + 1;
|
|
1765
1825
|
});
|
|
1766
1826
|
}, []);
|
|
1767
|
-
const goToToday =
|
|
1827
|
+
const goToToday = import_react3.default.useCallback(() => {
|
|
1768
1828
|
setYear(today.getFullYear());
|
|
1769
1829
|
setMonth(today.getMonth());
|
|
1770
1830
|
}, []);
|
|
@@ -1798,8 +1858,8 @@ var MONTH_LABELS = {
|
|
|
1798
1858
|
};
|
|
1799
1859
|
|
|
1800
1860
|
// src/components/Calendar/Calendar.tsx
|
|
1801
|
-
var
|
|
1802
|
-
var DayCell =
|
|
1861
|
+
var import_jsx_runtime303 = require("react/jsx-runtime");
|
|
1862
|
+
var DayCell = import_react4.default.memo(
|
|
1803
1863
|
({
|
|
1804
1864
|
day,
|
|
1805
1865
|
disabled,
|
|
@@ -1810,7 +1870,7 @@ var DayCell = import_react3.default.memo(
|
|
|
1810
1870
|
onEventClick
|
|
1811
1871
|
}) => {
|
|
1812
1872
|
if (renderDay) {
|
|
1813
|
-
return /* @__PURE__ */ (0,
|
|
1873
|
+
return /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(
|
|
1814
1874
|
"div",
|
|
1815
1875
|
{
|
|
1816
1876
|
className: clsx_default(
|
|
@@ -1827,7 +1887,7 @@ var DayCell = import_react3.default.memo(
|
|
|
1827
1887
|
}
|
|
1828
1888
|
);
|
|
1829
1889
|
}
|
|
1830
|
-
return /* @__PURE__ */ (0,
|
|
1890
|
+
return /* @__PURE__ */ (0, import_jsx_runtime303.jsxs)(
|
|
1831
1891
|
"div",
|
|
1832
1892
|
{
|
|
1833
1893
|
className: clsx_default(
|
|
@@ -1843,13 +1903,13 @@ var DayCell = import_react3.default.memo(
|
|
|
1843
1903
|
if (!disabled && day.isCurrentMonth) onSelect?.(day.date);
|
|
1844
1904
|
},
|
|
1845
1905
|
children: [
|
|
1846
|
-
/* @__PURE__ */ (0,
|
|
1847
|
-
dayEvents.length > 0 && /* @__PURE__ */ (0,
|
|
1848
|
-
dayEvents.slice(0, 3).map((event, ei) => /* @__PURE__ */ (0,
|
|
1906
|
+
/* @__PURE__ */ (0, import_jsx_runtime303.jsx)("span", { className: "calendar-day-number", children: day.day }),
|
|
1907
|
+
dayEvents.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime303.jsxs)("div", { className: "calendar-day-events", children: [
|
|
1908
|
+
dayEvents.slice(0, 3).map((event, ei) => /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(
|
|
1849
1909
|
"span",
|
|
1850
1910
|
{
|
|
1851
1911
|
className: "calendar-event-dot",
|
|
1852
|
-
style: { backgroundColor: event.color ?? "var(--
|
|
1912
|
+
style: { backgroundColor: event.color ?? "var(--semantic-surface-brand-default)" },
|
|
1853
1913
|
title: event.label,
|
|
1854
1914
|
onClick: (e) => {
|
|
1855
1915
|
e.stopPropagation();
|
|
@@ -1858,7 +1918,7 @@ var DayCell = import_react3.default.memo(
|
|
|
1858
1918
|
},
|
|
1859
1919
|
ei
|
|
1860
1920
|
)),
|
|
1861
|
-
dayEvents.length > 3 && /* @__PURE__ */ (0,
|
|
1921
|
+
dayEvents.length > 3 && /* @__PURE__ */ (0, import_jsx_runtime303.jsxs)("span", { className: "calendar-event-more", children: [
|
|
1862
1922
|
"+",
|
|
1863
1923
|
dayEvents.length - 3
|
|
1864
1924
|
] })
|
|
@@ -1895,14 +1955,14 @@ var Calendar = (props) => {
|
|
|
1895
1955
|
setYear,
|
|
1896
1956
|
setMonth
|
|
1897
1957
|
} = useCalendar(yearProp, monthProp);
|
|
1898
|
-
const [pickerMode, setPickerMode] =
|
|
1899
|
-
const [yearRangeStart, setYearRangeStart] =
|
|
1958
|
+
const [pickerMode, setPickerMode] = import_react4.default.useState("days");
|
|
1959
|
+
const [yearRangeStart, setYearRangeStart] = import_react4.default.useState(
|
|
1900
1960
|
Math.floor(year / 12) * 12
|
|
1901
1961
|
);
|
|
1902
|
-
|
|
1962
|
+
import_react4.default.useEffect(() => {
|
|
1903
1963
|
if (yearProp !== void 0) setYear(yearProp);
|
|
1904
1964
|
}, [yearProp, setYear]);
|
|
1905
|
-
|
|
1965
|
+
import_react4.default.useEffect(() => {
|
|
1906
1966
|
if (monthProp !== void 0) setMonth(monthProp);
|
|
1907
1967
|
}, [monthProp, setMonth]);
|
|
1908
1968
|
const handlePrev = () => {
|
|
@@ -1954,15 +2014,15 @@ var Calendar = (props) => {
|
|
|
1954
2014
|
setPickerMode("months");
|
|
1955
2015
|
onMonthChange?.(y, month);
|
|
1956
2016
|
};
|
|
1957
|
-
const minTime =
|
|
2017
|
+
const minTime = import_react4.default.useMemo(
|
|
1958
2018
|
() => minDate ? new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate()).getTime() : -Infinity,
|
|
1959
2019
|
[minDate]
|
|
1960
2020
|
);
|
|
1961
|
-
const maxTime =
|
|
2021
|
+
const maxTime = import_react4.default.useMemo(
|
|
1962
2022
|
() => maxDate ? new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate()).getTime() : Infinity,
|
|
1963
2023
|
[maxDate]
|
|
1964
2024
|
);
|
|
1965
|
-
const eventsMap =
|
|
2025
|
+
const eventsMap = import_react4.default.useMemo(() => {
|
|
1966
2026
|
const map = /* @__PURE__ */ new Map();
|
|
1967
2027
|
for (const e of events) {
|
|
1968
2028
|
const key = `${e.date.getFullYear()}-${e.date.getMonth()}-${e.date.getDate()}`;
|
|
@@ -1972,28 +2032,28 @@ var Calendar = (props) => {
|
|
|
1972
2032
|
}
|
|
1973
2033
|
return map;
|
|
1974
2034
|
}, [events]);
|
|
1975
|
-
const getEventsForDay =
|
|
2035
|
+
const getEventsForDay = import_react4.default.useCallback(
|
|
1976
2036
|
(date) => eventsMap.get(`${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`) ?? [],
|
|
1977
2037
|
[eventsMap]
|
|
1978
2038
|
);
|
|
1979
2039
|
const weekdays = WEEKDAY_LABELS[locale];
|
|
1980
2040
|
const monthLabels = MONTH_LABELS[locale];
|
|
1981
2041
|
const titleText = pickerMode === "days" ? locale === "ko" ? `${year}\uB144 ${monthLabels[month]}` : `${monthLabels[month]} ${year}` : pickerMode === "months" ? `${year}` : `${yearRangeStart} - ${yearRangeStart + 11}`;
|
|
1982
|
-
return /* @__PURE__ */ (0,
|
|
2042
|
+
return /* @__PURE__ */ (0, import_jsx_runtime303.jsxs)(
|
|
1983
2043
|
"div",
|
|
1984
2044
|
{
|
|
1985
2045
|
className: "lib-xplat-calendar",
|
|
1986
2046
|
style: selectedColor ? { "--calendar-selected-color": `var(--${selectedColor})` } : void 0,
|
|
1987
2047
|
children: [
|
|
1988
|
-
/* @__PURE__ */ (0,
|
|
1989
|
-
/* @__PURE__ */ (0,
|
|
1990
|
-
/* @__PURE__ */ (0,
|
|
1991
|
-
/* @__PURE__ */ (0,
|
|
1992
|
-
showToday && /* @__PURE__ */ (0,
|
|
2048
|
+
/* @__PURE__ */ (0, import_jsx_runtime303.jsxs)("div", { className: "calendar-header", children: [
|
|
2049
|
+
/* @__PURE__ */ (0, import_jsx_runtime303.jsx)("button", { className: "calendar-nav", onClick: handlePrev, "aria-label": "\uC774\uC804", children: /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(ChevronLeftIcon_default, {}) }),
|
|
2050
|
+
/* @__PURE__ */ (0, import_jsx_runtime303.jsx)("button", { className: "calendar-title", onClick: handleTitleClick, type: "button", children: titleText }),
|
|
2051
|
+
/* @__PURE__ */ (0, import_jsx_runtime303.jsx)("button", { className: "calendar-nav", onClick: handleNext, "aria-label": "\uB2E4\uC74C", children: /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(ChevronRightIcon_default, {}) }),
|
|
2052
|
+
showToday && /* @__PURE__ */ (0, import_jsx_runtime303.jsx)("button", { className: "calendar-today-btn", onClick: handleToday, children: locale === "ko" ? "\uC624\uB298" : "Today" })
|
|
1993
2053
|
] }),
|
|
1994
|
-
pickerMode === "years" && /* @__PURE__ */ (0,
|
|
2054
|
+
pickerMode === "years" && /* @__PURE__ */ (0, import_jsx_runtime303.jsx)("div", { className: "calendar-picker-grid", children: Array.from({ length: 12 }, (_, i) => {
|
|
1995
2055
|
const y = yearRangeStart + i;
|
|
1996
|
-
return /* @__PURE__ */ (0,
|
|
2056
|
+
return /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(
|
|
1997
2057
|
"button",
|
|
1998
2058
|
{
|
|
1999
2059
|
type: "button",
|
|
@@ -2004,7 +2064,7 @@ var Calendar = (props) => {
|
|
|
2004
2064
|
y
|
|
2005
2065
|
);
|
|
2006
2066
|
}) }),
|
|
2007
|
-
pickerMode === "months" && /* @__PURE__ */ (0,
|
|
2067
|
+
pickerMode === "months" && /* @__PURE__ */ (0, import_jsx_runtime303.jsx)("div", { className: "calendar-picker-grid", children: monthLabels.map((label, i) => /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(
|
|
2008
2068
|
"button",
|
|
2009
2069
|
{
|
|
2010
2070
|
type: "button",
|
|
@@ -2014,8 +2074,8 @@ var Calendar = (props) => {
|
|
|
2014
2074
|
},
|
|
2015
2075
|
i
|
|
2016
2076
|
)) }),
|
|
2017
|
-
pickerMode === "days" && /* @__PURE__ */ (0,
|
|
2018
|
-
/* @__PURE__ */ (0,
|
|
2077
|
+
pickerMode === "days" && /* @__PURE__ */ (0, import_jsx_runtime303.jsxs)(import_jsx_runtime303.Fragment, { children: [
|
|
2078
|
+
/* @__PURE__ */ (0, import_jsx_runtime303.jsx)("div", { className: "calendar-weekdays", children: weekdays.map((label, i) => /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(
|
|
2019
2079
|
"div",
|
|
2020
2080
|
{
|
|
2021
2081
|
className: clsx_default(
|
|
@@ -2027,12 +2087,12 @@ var Calendar = (props) => {
|
|
|
2027
2087
|
},
|
|
2028
2088
|
label
|
|
2029
2089
|
)) }),
|
|
2030
|
-
/* @__PURE__ */ (0,
|
|
2090
|
+
/* @__PURE__ */ (0, import_jsx_runtime303.jsx)("div", { className: "calendar-grid", children: days.map((day, idx) => {
|
|
2031
2091
|
const dayEvents = getEventsForDay(day.date);
|
|
2032
2092
|
const t = day.date.getTime();
|
|
2033
2093
|
const disabled = t < minTime || t > maxTime;
|
|
2034
2094
|
const isSelected = selectedDate ? isSameDay(day.date, selectedDate) : false;
|
|
2035
|
-
return /* @__PURE__ */ (0,
|
|
2095
|
+
return /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(
|
|
2036
2096
|
DayCell,
|
|
2037
2097
|
{
|
|
2038
2098
|
day,
|
|
@@ -2055,13 +2115,13 @@ Calendar.displayName = "Calendar";
|
|
|
2055
2115
|
var Calendar_default = Calendar;
|
|
2056
2116
|
|
|
2057
2117
|
// src/components/CardTab/CardTab.tsx
|
|
2058
|
-
var
|
|
2118
|
+
var import_react5 = __toESM(require("react"), 1);
|
|
2059
2119
|
|
|
2060
2120
|
// src/components/CardTab/CardTabPanel.tsx
|
|
2061
|
-
var
|
|
2121
|
+
var import_jsx_runtime304 = require("react/jsx-runtime");
|
|
2062
2122
|
var CardTabPanel = (props) => {
|
|
2063
2123
|
const { children, columns = 3 } = props;
|
|
2064
|
-
return /* @__PURE__ */ (0,
|
|
2124
|
+
return /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(
|
|
2065
2125
|
"div",
|
|
2066
2126
|
{
|
|
2067
2127
|
className: "card-tab-panel",
|
|
@@ -2074,7 +2134,7 @@ CardTabPanel.displayName = "CardTab.Panel";
|
|
|
2074
2134
|
var CardTabPanel_default = CardTabPanel;
|
|
2075
2135
|
|
|
2076
2136
|
// src/components/CardTab/CardTab.tsx
|
|
2077
|
-
var
|
|
2137
|
+
var import_jsx_runtime305 = require("react/jsx-runtime");
|
|
2078
2138
|
var CardTabRoot = (props) => {
|
|
2079
2139
|
const {
|
|
2080
2140
|
tabs,
|
|
@@ -2084,7 +2144,7 @@ var CardTabRoot = (props) => {
|
|
|
2084
2144
|
children
|
|
2085
2145
|
} = props;
|
|
2086
2146
|
const isControlled = activeValueProp !== void 0;
|
|
2087
|
-
const [uncontrolledValue, setUncontrolledValue] =
|
|
2147
|
+
const [uncontrolledValue, setUncontrolledValue] = import_react5.default.useState(tabs[0]?.value ?? "");
|
|
2088
2148
|
const activeValue = isControlled ? activeValueProp : uncontrolledValue;
|
|
2089
2149
|
const handleTabClick = (tab) => {
|
|
2090
2150
|
if (!isControlled) {
|
|
@@ -2092,16 +2152,16 @@ var CardTabRoot = (props) => {
|
|
|
2092
2152
|
}
|
|
2093
2153
|
onChange?.(tab);
|
|
2094
2154
|
};
|
|
2095
|
-
const panels =
|
|
2096
|
-
(child) =>
|
|
2155
|
+
const panels = import_react5.default.Children.toArray(children).filter(
|
|
2156
|
+
(child) => import_react5.default.isValidElement(child) && child.type === CardTabPanel_default
|
|
2097
2157
|
);
|
|
2098
2158
|
const activePanel = panels.find(
|
|
2099
2159
|
(panel) => panel.props.value === activeValue
|
|
2100
2160
|
);
|
|
2101
|
-
return /* @__PURE__ */ (0,
|
|
2102
|
-
/* @__PURE__ */ (0,
|
|
2161
|
+
return /* @__PURE__ */ (0, import_jsx_runtime305.jsxs)("div", { className: clsx_default("lib-xplat-card-tab", size), children: [
|
|
2162
|
+
/* @__PURE__ */ (0, import_jsx_runtime305.jsx)("div", { className: "card-tab-bar", children: tabs.map((tab) => {
|
|
2103
2163
|
const isActive2 = tab.value === activeValue;
|
|
2104
|
-
return /* @__PURE__ */ (0,
|
|
2164
|
+
return /* @__PURE__ */ (0, import_jsx_runtime305.jsx)(
|
|
2105
2165
|
"button",
|
|
2106
2166
|
{
|
|
2107
2167
|
className: clsx_default("card-tab-trigger", isActive2 && "active"),
|
|
@@ -2113,7 +2173,7 @@ var CardTabRoot = (props) => {
|
|
|
2113
2173
|
tab.value
|
|
2114
2174
|
);
|
|
2115
2175
|
}) }),
|
|
2116
|
-
/* @__PURE__ */ (0,
|
|
2176
|
+
/* @__PURE__ */ (0, import_jsx_runtime305.jsx)("div", { className: "card-tab-body", children: activePanel })
|
|
2117
2177
|
] });
|
|
2118
2178
|
};
|
|
2119
2179
|
CardTabRoot.displayName = "CardTab";
|
|
@@ -2123,8 +2183,8 @@ var CardTab = Object.assign(CardTabRoot, {
|
|
|
2123
2183
|
var CardTab_default = CardTab;
|
|
2124
2184
|
|
|
2125
2185
|
// src/components/Chart/Chart.tsx
|
|
2126
|
-
var
|
|
2127
|
-
var
|
|
2186
|
+
var import_react6 = __toESM(require("react"), 1);
|
|
2187
|
+
var import_jsx_runtime306 = require("react/jsx-runtime");
|
|
2128
2188
|
var CATEGORICAL_COUNT2 = 8;
|
|
2129
2189
|
var LINE_BAR_PALETTES = Array.from({ length: CATEGORICAL_COUNT2 }, (_, i) => {
|
|
2130
2190
|
const n = i + 1;
|
|
@@ -2169,8 +2229,8 @@ var toSmoothPath = (points) => {
|
|
|
2169
2229
|
return d;
|
|
2170
2230
|
};
|
|
2171
2231
|
var useChartSize = (ref) => {
|
|
2172
|
-
const [size, setSize] =
|
|
2173
|
-
|
|
2232
|
+
const [size, setSize] = import_react6.default.useState({ width: 0, height: 0 });
|
|
2233
|
+
import_react6.default.useEffect(() => {
|
|
2174
2234
|
const el = ref.current;
|
|
2175
2235
|
if (!el) return;
|
|
2176
2236
|
let rafId = 0;
|
|
@@ -2196,10 +2256,10 @@ var useChartSize = (ref) => {
|
|
|
2196
2256
|
};
|
|
2197
2257
|
var prefersReducedMotion = () => typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
2198
2258
|
var useChartAnimation = (containerRef, dataKey) => {
|
|
2199
|
-
const [animate, setAnimate] =
|
|
2200
|
-
const prevDataKey =
|
|
2201
|
-
const hasAnimated =
|
|
2202
|
-
|
|
2259
|
+
const [animate, setAnimate] = import_react6.default.useState(false);
|
|
2260
|
+
const prevDataKey = import_react6.default.useRef(dataKey);
|
|
2261
|
+
const hasAnimated = import_react6.default.useRef(false);
|
|
2262
|
+
import_react6.default.useEffect(() => {
|
|
2203
2263
|
if (prefersReducedMotion()) return;
|
|
2204
2264
|
const el = containerRef.current;
|
|
2205
2265
|
if (!el) return;
|
|
@@ -2215,7 +2275,7 @@ var useChartAnimation = (containerRef, dataKey) => {
|
|
|
2215
2275
|
observer.observe(el);
|
|
2216
2276
|
return () => observer.disconnect();
|
|
2217
2277
|
}, [containerRef]);
|
|
2218
|
-
|
|
2278
|
+
import_react6.default.useEffect(() => {
|
|
2219
2279
|
if (dataKey !== prevDataKey.current) {
|
|
2220
2280
|
prevDataKey.current = dataKey;
|
|
2221
2281
|
if (prefersReducedMotion()) return;
|
|
@@ -2229,15 +2289,15 @@ var useChartAnimation = (containerRef, dataKey) => {
|
|
|
2229
2289
|
};
|
|
2230
2290
|
var TOOLTIP_OFFSET = 12;
|
|
2231
2291
|
var useChartTooltip = (enabled) => {
|
|
2232
|
-
const [tooltip, setTooltip] =
|
|
2292
|
+
const [tooltip, setTooltip] = import_react6.default.useState({
|
|
2233
2293
|
visible: false,
|
|
2234
2294
|
x: 0,
|
|
2235
2295
|
y: 0,
|
|
2236
2296
|
content: ""
|
|
2237
2297
|
});
|
|
2238
|
-
const containerRef =
|
|
2239
|
-
const rafRef =
|
|
2240
|
-
const move =
|
|
2298
|
+
const containerRef = import_react6.default.useRef(null);
|
|
2299
|
+
const rafRef = import_react6.default.useRef(0);
|
|
2300
|
+
const move = import_react6.default.useCallback((e) => {
|
|
2241
2301
|
if (!enabled) return;
|
|
2242
2302
|
const cx = e.clientX;
|
|
2243
2303
|
const cy = e.clientY;
|
|
@@ -2248,24 +2308,24 @@ var useChartTooltip = (enabled) => {
|
|
|
2248
2308
|
setTooltip((prev) => ({ ...prev, x: cx - rect.left, y: cy - rect.top }));
|
|
2249
2309
|
});
|
|
2250
2310
|
}, [enabled]);
|
|
2251
|
-
const show =
|
|
2311
|
+
const show = import_react6.default.useCallback((e, content) => {
|
|
2252
2312
|
if (!enabled) return;
|
|
2253
2313
|
const rect = containerRef.current?.getBoundingClientRect();
|
|
2254
2314
|
if (!rect) return;
|
|
2255
2315
|
setTooltip({ visible: true, x: e.clientX - rect.left, y: e.clientY - rect.top, content });
|
|
2256
2316
|
}, [enabled]);
|
|
2257
|
-
const hide =
|
|
2317
|
+
const hide = import_react6.default.useCallback(() => {
|
|
2258
2318
|
cancelAnimationFrame(rafRef.current);
|
|
2259
2319
|
setTooltip((prev) => ({ ...prev, visible: false }));
|
|
2260
2320
|
}, []);
|
|
2261
2321
|
return { tooltip, show, hide, move, containerRef };
|
|
2262
2322
|
};
|
|
2263
|
-
var GridLines =
|
|
2323
|
+
var GridLines = import_react6.default.memo(({ width, height, chartH, maxVal }) => /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(import_jsx_runtime306.Fragment, { children: [0, 0.25, 0.5, 0.75, 1].map((ratio) => {
|
|
2264
2324
|
const y = PADDING.top + (1 - ratio) * chartH;
|
|
2265
2325
|
const val = Math.round(maxVal * ratio);
|
|
2266
|
-
return /* @__PURE__ */ (0,
|
|
2267
|
-
/* @__PURE__ */ (0,
|
|
2268
|
-
/* @__PURE__ */ (0,
|
|
2326
|
+
return /* @__PURE__ */ (0, import_jsx_runtime306.jsxs)("g", { children: [
|
|
2327
|
+
/* @__PURE__ */ (0, import_jsx_runtime306.jsx)("line", { x1: PADDING.left, y1: y, x2: width - PADDING.right, y2: y, className: "chart-grid" }),
|
|
2328
|
+
/* @__PURE__ */ (0, import_jsx_runtime306.jsx)("text", { x: PADDING.left - 8, y: y + 4, className: "chart-axis-label", textAnchor: "end", children: val })
|
|
2269
2329
|
] }, ratio);
|
|
2270
2330
|
}) }));
|
|
2271
2331
|
GridLines.displayName = "GridLines";
|
|
@@ -2275,18 +2335,18 @@ var getLabelStep = (count, chartW) => {
|
|
|
2275
2335
|
if (count <= maxLabels) return 1;
|
|
2276
2336
|
return Math.ceil(count / maxLabels);
|
|
2277
2337
|
};
|
|
2278
|
-
var AxisLabels =
|
|
2338
|
+
var AxisLabels = import_react6.default.memo(({ labels, count, chartW, height }) => {
|
|
2279
2339
|
const step = getLabelStep(count, chartW);
|
|
2280
|
-
return /* @__PURE__ */ (0,
|
|
2340
|
+
return /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(import_jsx_runtime306.Fragment, { children: labels.map((label, i) => {
|
|
2281
2341
|
if (i % step !== 0) return null;
|
|
2282
2342
|
const x = PADDING.left + i / (count - 1 || 1) * chartW;
|
|
2283
|
-
return /* @__PURE__ */ (0,
|
|
2343
|
+
return /* @__PURE__ */ (0, import_jsx_runtime306.jsx)("text", { x, y: height - 8, className: "chart-axis-label", textAnchor: "middle", children: label }, i);
|
|
2284
2344
|
}) });
|
|
2285
2345
|
});
|
|
2286
2346
|
AxisLabels.displayName = "AxisLabels";
|
|
2287
2347
|
var useCrosshair = (seriesPoints, entries, labels, chartH) => {
|
|
2288
|
-
const [activeIndex, setActiveIndex] =
|
|
2289
|
-
const handleMouseMove =
|
|
2348
|
+
const [activeIndex, setActiveIndex] = import_react6.default.useState(null);
|
|
2349
|
+
const handleMouseMove = import_react6.default.useCallback((e) => {
|
|
2290
2350
|
const svg = e.currentTarget;
|
|
2291
2351
|
const rect = svg.getBoundingClientRect();
|
|
2292
2352
|
const mx = (e.clientX - rect.left) / rect.width * svg.viewBox.baseVal.width;
|
|
@@ -2305,17 +2365,17 @@ var useCrosshair = (seriesPoints, entries, labels, chartH) => {
|
|
|
2305
2365
|
}
|
|
2306
2366
|
setActiveIndex(minDist <= threshold ? closest : null);
|
|
2307
2367
|
}, [seriesPoints]);
|
|
2308
|
-
const handleMouseLeave =
|
|
2368
|
+
const handleMouseLeave = import_react6.default.useCallback(() => {
|
|
2309
2369
|
setActiveIndex(null);
|
|
2310
2370
|
}, []);
|
|
2311
|
-
const tooltipContent =
|
|
2371
|
+
const tooltipContent = import_react6.default.useMemo(() => {
|
|
2312
2372
|
if (activeIndex === null) return "";
|
|
2313
2373
|
return entries.map(([key], di) => {
|
|
2314
2374
|
const p = seriesPoints[di]?.[activeIndex];
|
|
2315
2375
|
return p ? `${key}: ${p.v}` : "";
|
|
2316
2376
|
}).filter(Boolean).join(" / ");
|
|
2317
2377
|
}, [activeIndex, entries, seriesPoints]);
|
|
2318
|
-
const getTooltipAt =
|
|
2378
|
+
const getTooltipAt = import_react6.default.useCallback((idx) => {
|
|
2319
2379
|
return entries.map(([key], di) => {
|
|
2320
2380
|
const p = seriesPoints[di]?.[idx];
|
|
2321
2381
|
return p ? `${key}: ${p.v}` : "";
|
|
@@ -2323,16 +2383,16 @@ var useCrosshair = (seriesPoints, entries, labels, chartH) => {
|
|
|
2323
2383
|
}, [entries, seriesPoints]);
|
|
2324
2384
|
return { activeIndex, handleMouseMove, handleMouseLeave, tooltipContent, getTooltipAt };
|
|
2325
2385
|
};
|
|
2326
|
-
var LineChart =
|
|
2327
|
-
const entries =
|
|
2328
|
-
const maxVal =
|
|
2386
|
+
var LineChart = import_react6.default.memo(({ data, labels, width, height, animate, onHover, onMove, onLeave }) => {
|
|
2387
|
+
const entries = import_react6.default.useMemo(() => Object.entries(data), [data]);
|
|
2388
|
+
const maxVal = import_react6.default.useMemo(() => {
|
|
2329
2389
|
const allValues = entries.flatMap(([, v]) => v);
|
|
2330
2390
|
return Math.max(...allValues) * 1.2 || 1;
|
|
2331
2391
|
}, [entries]);
|
|
2332
2392
|
const count = labels.length;
|
|
2333
2393
|
const chartW = width - PADDING.left - PADDING.right;
|
|
2334
2394
|
const chartH = height - PADDING.top - PADDING.bottom;
|
|
2335
|
-
const seriesPoints =
|
|
2395
|
+
const seriesPoints = import_react6.default.useMemo(
|
|
2336
2396
|
() => entries.map(
|
|
2337
2397
|
([, values]) => values.map((v, i) => ({
|
|
2338
2398
|
x: PADDING.left + i / (count - 1 || 1) * chartW,
|
|
@@ -2342,9 +2402,9 @@ var LineChart = import_react5.default.memo(({ data, labels, width, height, anima
|
|
|
2342
2402
|
),
|
|
2343
2403
|
[entries, count, chartW, chartH, maxVal]
|
|
2344
2404
|
);
|
|
2345
|
-
const clipRef =
|
|
2405
|
+
const clipRef = import_react6.default.useRef(null);
|
|
2346
2406
|
const { activeIndex, handleMouseMove, handleMouseLeave, getTooltipAt } = useCrosshair(seriesPoints, entries, labels, chartH);
|
|
2347
|
-
|
|
2407
|
+
import_react6.default.useEffect(() => {
|
|
2348
2408
|
if (!animate || !clipRef.current) return;
|
|
2349
2409
|
clipRef.current.setAttribute("width", "0");
|
|
2350
2410
|
requestAnimationFrame(() => {
|
|
@@ -2356,7 +2416,7 @@ var LineChart = import_react5.default.memo(({ data, labels, width, height, anima
|
|
|
2356
2416
|
}, [animate, width]);
|
|
2357
2417
|
const activeX = activeIndex !== null ? seriesPoints[0]?.[activeIndex]?.x ?? null : null;
|
|
2358
2418
|
const lineClipId = "line-area-clip";
|
|
2359
|
-
return /* @__PURE__ */ (0,
|
|
2419
|
+
return /* @__PURE__ */ (0, import_jsx_runtime306.jsxs)(
|
|
2360
2420
|
"svg",
|
|
2361
2421
|
{
|
|
2362
2422
|
viewBox: `0 0 ${width} ${height}`,
|
|
@@ -2374,9 +2434,9 @@ var LineChart = import_react5.default.memo(({ data, labels, width, height, anima
|
|
|
2374
2434
|
onLeave();
|
|
2375
2435
|
},
|
|
2376
2436
|
children: [
|
|
2377
|
-
animate && /* @__PURE__ */ (0,
|
|
2378
|
-
/* @__PURE__ */ (0,
|
|
2379
|
-
/* @__PURE__ */ (0,
|
|
2437
|
+
animate && /* @__PURE__ */ (0, import_jsx_runtime306.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime306.jsx)("clipPath", { id: lineClipId, children: /* @__PURE__ */ (0, import_jsx_runtime306.jsx)("rect", { ref: clipRef, x: "0", y: "0", width: animate ? 0 : width, height }) }) }),
|
|
2438
|
+
/* @__PURE__ */ (0, import_jsx_runtime306.jsx)(GridLines, { width, height, chartH, maxVal }),
|
|
2439
|
+
/* @__PURE__ */ (0, import_jsx_runtime306.jsx)(AxisLabels, { labels, count, chartW, height }),
|
|
2380
2440
|
entries.map(([key], di) => {
|
|
2381
2441
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
2382
2442
|
const color = palette[2];
|
|
@@ -2385,16 +2445,16 @@ var LineChart = import_react5.default.memo(({ data, labels, width, height, anima
|
|
|
2385
2445
|
const gradientId = `line-gradient-${di}`;
|
|
2386
2446
|
const polyPoints = points.map((p) => `${p.x},${p.y}`).join(" ");
|
|
2387
2447
|
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`;
|
|
2388
|
-
return /* @__PURE__ */ (0,
|
|
2389
|
-
/* @__PURE__ */ (0,
|
|
2390
|
-
/* @__PURE__ */ (0,
|
|
2391
|
-
/* @__PURE__ */ (0,
|
|
2448
|
+
return /* @__PURE__ */ (0, import_jsx_runtime306.jsxs)("g", { children: [
|
|
2449
|
+
/* @__PURE__ */ (0, import_jsx_runtime306.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime306.jsxs)("linearGradient", { id: gradientId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
2450
|
+
/* @__PURE__ */ (0, import_jsx_runtime306.jsx)("stop", { offset: "0%", stopColor: areaColor, stopOpacity: "0.2" }),
|
|
2451
|
+
/* @__PURE__ */ (0, import_jsx_runtime306.jsx)("stop", { offset: "100%", stopColor: areaColor, stopOpacity: "0" })
|
|
2392
2452
|
] }) }),
|
|
2393
|
-
/* @__PURE__ */ (0,
|
|
2394
|
-
/* @__PURE__ */ (0,
|
|
2395
|
-
/* @__PURE__ */ (0,
|
|
2453
|
+
/* @__PURE__ */ (0, import_jsx_runtime306.jsxs)("g", { clipPath: animate ? `url(#${lineClipId})` : void 0, children: [
|
|
2454
|
+
/* @__PURE__ */ (0, import_jsx_runtime306.jsx)("path", { d: areaD, fill: `url(#${gradientId})` }),
|
|
2455
|
+
/* @__PURE__ */ (0, import_jsx_runtime306.jsx)("polyline", { points: polyPoints, fill: "none", stroke: color, strokeWidth: "2" })
|
|
2396
2456
|
] }),
|
|
2397
|
-
activeIndex !== null && points[activeIndex] && /* @__PURE__ */ (0,
|
|
2457
|
+
activeIndex !== null && points[activeIndex] && /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(
|
|
2398
2458
|
"circle",
|
|
2399
2459
|
{
|
|
2400
2460
|
cx: points[activeIndex].x,
|
|
@@ -2406,7 +2466,7 @@ var LineChart = import_react5.default.memo(({ data, labels, width, height, anima
|
|
|
2406
2466
|
)
|
|
2407
2467
|
] }, di);
|
|
2408
2468
|
}),
|
|
2409
|
-
activeX !== null && /* @__PURE__ */ (0,
|
|
2469
|
+
activeX !== null && /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(
|
|
2410
2470
|
"line",
|
|
2411
2471
|
{
|
|
2412
2472
|
x1: activeX,
|
|
@@ -2416,7 +2476,7 @@ var LineChart = import_react5.default.memo(({ data, labels, width, height, anima
|
|
|
2416
2476
|
className: "chart-crosshair"
|
|
2417
2477
|
}
|
|
2418
2478
|
),
|
|
2419
|
-
/* @__PURE__ */ (0,
|
|
2479
|
+
/* @__PURE__ */ (0, import_jsx_runtime306.jsx)(
|
|
2420
2480
|
"rect",
|
|
2421
2481
|
{
|
|
2422
2482
|
x: PADDING.left,
|
|
@@ -2432,16 +2492,16 @@ var LineChart = import_react5.default.memo(({ data, labels, width, height, anima
|
|
|
2432
2492
|
);
|
|
2433
2493
|
});
|
|
2434
2494
|
LineChart.displayName = "LineChart";
|
|
2435
|
-
var CurveChart =
|
|
2436
|
-
const entries =
|
|
2437
|
-
const maxVal =
|
|
2495
|
+
var CurveChart = import_react6.default.memo(({ data, labels, width, height, animate, onHover, onMove, onLeave }) => {
|
|
2496
|
+
const entries = import_react6.default.useMemo(() => Object.entries(data), [data]);
|
|
2497
|
+
const maxVal = import_react6.default.useMemo(() => {
|
|
2438
2498
|
const allValues = entries.flatMap(([, v]) => v);
|
|
2439
2499
|
return Math.max(...allValues) * 1.2 || 1;
|
|
2440
2500
|
}, [entries]);
|
|
2441
2501
|
const count = labels.length;
|
|
2442
2502
|
const chartW = width - PADDING.left - PADDING.right;
|
|
2443
2503
|
const chartH = height - PADDING.top - PADDING.bottom;
|
|
2444
|
-
const seriesPoints =
|
|
2504
|
+
const seriesPoints = import_react6.default.useMemo(
|
|
2445
2505
|
() => entries.map(
|
|
2446
2506
|
([, values]) => values.map((v, i) => ({
|
|
2447
2507
|
x: PADDING.left + i / (count - 1 || 1) * chartW,
|
|
@@ -2451,9 +2511,9 @@ var CurveChart = import_react5.default.memo(({ data, labels, width, height, anim
|
|
|
2451
2511
|
),
|
|
2452
2512
|
[entries, count, chartW, chartH, maxVal]
|
|
2453
2513
|
);
|
|
2454
|
-
const curveClipRef =
|
|
2514
|
+
const curveClipRef = import_react6.default.useRef(null);
|
|
2455
2515
|
const { activeIndex, handleMouseMove, handleMouseLeave, getTooltipAt } = useCrosshair(seriesPoints, entries, labels, chartH);
|
|
2456
|
-
|
|
2516
|
+
import_react6.default.useEffect(() => {
|
|
2457
2517
|
if (!animate || !curveClipRef.current) return;
|
|
2458
2518
|
curveClipRef.current.setAttribute("width", "0");
|
|
2459
2519
|
requestAnimationFrame(() => {
|
|
@@ -2465,7 +2525,7 @@ var CurveChart = import_react5.default.memo(({ data, labels, width, height, anim
|
|
|
2465
2525
|
}, [animate, width]);
|
|
2466
2526
|
const activeX = activeIndex !== null ? seriesPoints[0]?.[activeIndex]?.x ?? null : null;
|
|
2467
2527
|
const curveClipId = "curve-area-clip";
|
|
2468
|
-
return /* @__PURE__ */ (0,
|
|
2528
|
+
return /* @__PURE__ */ (0, import_jsx_runtime306.jsxs)(
|
|
2469
2529
|
"svg",
|
|
2470
2530
|
{
|
|
2471
2531
|
viewBox: `0 0 ${width} ${height}`,
|
|
@@ -2484,9 +2544,9 @@ var CurveChart = import_react5.default.memo(({ data, labels, width, height, anim
|
|
|
2484
2544
|
onLeave();
|
|
2485
2545
|
},
|
|
2486
2546
|
children: [
|
|
2487
|
-
animate && /* @__PURE__ */ (0,
|
|
2488
|
-
/* @__PURE__ */ (0,
|
|
2489
|
-
/* @__PURE__ */ (0,
|
|
2547
|
+
animate && /* @__PURE__ */ (0, import_jsx_runtime306.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime306.jsx)("clipPath", { id: curveClipId, children: /* @__PURE__ */ (0, import_jsx_runtime306.jsx)("rect", { ref: curveClipRef, x: "0", y: "0", width: animate ? 0 : width, height }) }) }),
|
|
2548
|
+
/* @__PURE__ */ (0, import_jsx_runtime306.jsx)(GridLines, { width, height, chartH, maxVal }),
|
|
2549
|
+
/* @__PURE__ */ (0, import_jsx_runtime306.jsx)(AxisLabels, { labels, count, chartW, height }),
|
|
2490
2550
|
entries.map(([key], di) => {
|
|
2491
2551
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
2492
2552
|
const color = palette[2];
|
|
@@ -2495,16 +2555,16 @@ var CurveChart = import_react5.default.memo(({ data, labels, width, height, anim
|
|
|
2495
2555
|
const gradientId = `curve-gradient-${di}`;
|
|
2496
2556
|
const linePath = toSmoothPath(points);
|
|
2497
2557
|
const areaPath = linePath + ` L ${points[points.length - 1].x} ${PADDING.top + chartH} L ${points[0].x} ${PADDING.top + chartH} Z`;
|
|
2498
|
-
return /* @__PURE__ */ (0,
|
|
2499
|
-
/* @__PURE__ */ (0,
|
|
2500
|
-
/* @__PURE__ */ (0,
|
|
2501
|
-
/* @__PURE__ */ (0,
|
|
2558
|
+
return /* @__PURE__ */ (0, import_jsx_runtime306.jsxs)("g", { children: [
|
|
2559
|
+
/* @__PURE__ */ (0, import_jsx_runtime306.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime306.jsxs)("linearGradient", { id: gradientId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
2560
|
+
/* @__PURE__ */ (0, import_jsx_runtime306.jsx)("stop", { offset: "0%", stopColor: areaColor, stopOpacity: "0.4" }),
|
|
2561
|
+
/* @__PURE__ */ (0, import_jsx_runtime306.jsx)("stop", { offset: "100%", stopColor: areaColor, stopOpacity: "0.02" })
|
|
2502
2562
|
] }) }),
|
|
2503
|
-
/* @__PURE__ */ (0,
|
|
2504
|
-
/* @__PURE__ */ (0,
|
|
2505
|
-
/* @__PURE__ */ (0,
|
|
2563
|
+
/* @__PURE__ */ (0, import_jsx_runtime306.jsxs)("g", { clipPath: animate ? `url(#${curveClipId})` : void 0, children: [
|
|
2564
|
+
/* @__PURE__ */ (0, import_jsx_runtime306.jsx)("path", { d: areaPath, fill: `url(#${gradientId})` }),
|
|
2565
|
+
/* @__PURE__ */ (0, import_jsx_runtime306.jsx)("path", { d: linePath, fill: "none", stroke: color, strokeWidth: "2" })
|
|
2506
2566
|
] }),
|
|
2507
|
-
activeIndex !== null && points[activeIndex] && /* @__PURE__ */ (0,
|
|
2567
|
+
activeIndex !== null && points[activeIndex] && /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(
|
|
2508
2568
|
"circle",
|
|
2509
2569
|
{
|
|
2510
2570
|
cx: points[activeIndex].x,
|
|
@@ -2516,7 +2576,7 @@ var CurveChart = import_react5.default.memo(({ data, labels, width, height, anim
|
|
|
2516
2576
|
)
|
|
2517
2577
|
] }, di);
|
|
2518
2578
|
}),
|
|
2519
|
-
activeX !== null && /* @__PURE__ */ (0,
|
|
2579
|
+
activeX !== null && /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(
|
|
2520
2580
|
"line",
|
|
2521
2581
|
{
|
|
2522
2582
|
x1: activeX,
|
|
@@ -2526,7 +2586,7 @@ var CurveChart = import_react5.default.memo(({ data, labels, width, height, anim
|
|
|
2526
2586
|
className: "chart-crosshair"
|
|
2527
2587
|
}
|
|
2528
2588
|
),
|
|
2529
|
-
/* @__PURE__ */ (0,
|
|
2589
|
+
/* @__PURE__ */ (0, import_jsx_runtime306.jsx)(
|
|
2530
2590
|
"rect",
|
|
2531
2591
|
{
|
|
2532
2592
|
x: PADDING.left,
|
|
@@ -2542,9 +2602,9 @@ var CurveChart = import_react5.default.memo(({ data, labels, width, height, anim
|
|
|
2542
2602
|
);
|
|
2543
2603
|
});
|
|
2544
2604
|
CurveChart.displayName = "CurveChart";
|
|
2545
|
-
var BarChart =
|
|
2546
|
-
const entries =
|
|
2547
|
-
const maxVal =
|
|
2605
|
+
var BarChart = import_react6.default.memo(({ data, labels, width, height, animate, onHover, onMove, onLeave }) => {
|
|
2606
|
+
const entries = import_react6.default.useMemo(() => Object.entries(data), [data]);
|
|
2607
|
+
const maxVal = import_react6.default.useMemo(() => {
|
|
2548
2608
|
const allValues = entries.flatMap(([, v]) => v);
|
|
2549
2609
|
return Math.max(...allValues) * 1.2 || 1;
|
|
2550
2610
|
}, [entries]);
|
|
@@ -2556,7 +2616,7 @@ var BarChart = import_react5.default.memo(({ data, labels, width, height, animat
|
|
|
2556
2616
|
const barGap = groupCount > 1 ? 2 : 0;
|
|
2557
2617
|
const barW = Math.max(1, Math.min(32, (groupW * 0.7 - barGap * (groupCount - 1)) / groupCount));
|
|
2558
2618
|
const baseline = PADDING.top + chartH;
|
|
2559
|
-
const bars =
|
|
2619
|
+
const bars = import_react6.default.useMemo(
|
|
2560
2620
|
() => entries.map(
|
|
2561
2621
|
([, values], di) => values.map((v, i) => {
|
|
2562
2622
|
const totalBarsW = barW * groupCount + barGap * (groupCount - 1);
|
|
@@ -2569,11 +2629,11 @@ var BarChart = import_react5.default.memo(({ data, labels, width, height, animat
|
|
|
2569
2629
|
[entries, maxVal, chartH, groupW, barW, barGap, groupCount]
|
|
2570
2630
|
);
|
|
2571
2631
|
const barLabelStep = getLabelStep(count, chartW);
|
|
2572
|
-
return /* @__PURE__ */ (0,
|
|
2573
|
-
/* @__PURE__ */ (0,
|
|
2632
|
+
return /* @__PURE__ */ (0, import_jsx_runtime306.jsxs)("svg", { viewBox: `0 0 ${width} ${height}`, className: "chart-svg", children: [
|
|
2633
|
+
/* @__PURE__ */ (0, import_jsx_runtime306.jsx)(GridLines, { width, height, chartH, maxVal }),
|
|
2574
2634
|
labels.map((label, i) => {
|
|
2575
2635
|
if (i % barLabelStep !== 0) return null;
|
|
2576
|
-
return /* @__PURE__ */ (0,
|
|
2636
|
+
return /* @__PURE__ */ (0, import_jsx_runtime306.jsx)("text", { x: PADDING.left + groupW * i + groupW / 2, y: height - 8, className: "chart-axis-label", textAnchor: "middle", children: label }, i);
|
|
2577
2637
|
}),
|
|
2578
2638
|
entries.map(([key], di) => {
|
|
2579
2639
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
@@ -2582,7 +2642,7 @@ var BarChart = import_react5.default.memo(({ data, labels, width, height, animat
|
|
|
2582
2642
|
const r2 = Math.min(4, b.w / 2);
|
|
2583
2643
|
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`;
|
|
2584
2644
|
const delay = 100 + i * 80;
|
|
2585
|
-
return /* @__PURE__ */ (0,
|
|
2645
|
+
return /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(
|
|
2586
2646
|
"path",
|
|
2587
2647
|
{
|
|
2588
2648
|
d,
|
|
@@ -2603,11 +2663,11 @@ var BarChart = import_react5.default.memo(({ data, labels, width, height, animat
|
|
|
2603
2663
|
] });
|
|
2604
2664
|
});
|
|
2605
2665
|
BarChart.displayName = "BarChart";
|
|
2606
|
-
var PieDonutChart =
|
|
2666
|
+
var PieDonutChart = import_react6.default.memo(
|
|
2607
2667
|
({ data, labels, width, height, animate, isDoughnut, onHover, onMove, onLeave }) => {
|
|
2608
|
-
const entries =
|
|
2609
|
-
const values =
|
|
2610
|
-
const total =
|
|
2668
|
+
const entries = import_react6.default.useMemo(() => Object.entries(data), [data]);
|
|
2669
|
+
const values = import_react6.default.useMemo(() => entries.flatMap(([, v]) => v), [entries]);
|
|
2670
|
+
const total = import_react6.default.useMemo(() => values.reduce((a, b) => a + b, 0) || 1, [values]);
|
|
2611
2671
|
const size = Math.min(width, height);
|
|
2612
2672
|
const cx = size / 2;
|
|
2613
2673
|
const cy = size / 2;
|
|
@@ -2615,10 +2675,10 @@ var PieDonutChart = import_react5.default.memo(
|
|
|
2615
2675
|
const innerR = isDoughnut ? r2 * 0.5 : 0;
|
|
2616
2676
|
const firstKey = entries[0]?.[0] ?? "";
|
|
2617
2677
|
const colorOffset = hashString(firstKey);
|
|
2618
|
-
const maskRef =
|
|
2678
|
+
const maskRef = import_react6.default.useRef(null);
|
|
2619
2679
|
const maskR = r2 + 10;
|
|
2620
2680
|
const maskCircumference = 2 * Math.PI * maskR;
|
|
2621
|
-
|
|
2681
|
+
import_react6.default.useEffect(() => {
|
|
2622
2682
|
if (!animate || !maskRef.current) return;
|
|
2623
2683
|
const el = maskRef.current;
|
|
2624
2684
|
el.style.strokeDasharray = `${maskCircumference}`;
|
|
@@ -2628,7 +2688,7 @@ var PieDonutChart = import_react5.default.memo(
|
|
|
2628
2688
|
el.style.strokeDashoffset = "0";
|
|
2629
2689
|
});
|
|
2630
2690
|
}, [animate, maskCircumference]);
|
|
2631
|
-
const sliceData =
|
|
2691
|
+
const sliceData = import_react6.default.useMemo(() => {
|
|
2632
2692
|
let angle0 = -Math.PI / 2;
|
|
2633
2693
|
let cumulativeAngle = 0;
|
|
2634
2694
|
return values.map((v, i) => {
|
|
@@ -2662,8 +2722,8 @@ var PieDonutChart = import_react5.default.memo(
|
|
|
2662
2722
|
});
|
|
2663
2723
|
}, [values, total, cx, cy, r2, innerR, labels]);
|
|
2664
2724
|
const maskId = `pie-mask-${isDoughnut ? "d" : "p"}`;
|
|
2665
|
-
return /* @__PURE__ */ (0,
|
|
2666
|
-
animate && /* @__PURE__ */ (0,
|
|
2725
|
+
return /* @__PURE__ */ (0, import_jsx_runtime306.jsxs)("svg", { viewBox: `0 0 ${size} ${size}`, className: "chart-svg chart-pie", children: [
|
|
2726
|
+
animate && /* @__PURE__ */ (0, import_jsx_runtime306.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime306.jsx)("mask", { id: maskId, children: /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(
|
|
2667
2727
|
"circle",
|
|
2668
2728
|
{
|
|
2669
2729
|
ref: maskRef,
|
|
@@ -2676,7 +2736,7 @@ var PieDonutChart = import_react5.default.memo(
|
|
|
2676
2736
|
transform: `rotate(-90 ${cx} ${cy})`
|
|
2677
2737
|
}
|
|
2678
2738
|
) }) }),
|
|
2679
|
-
/* @__PURE__ */ (0,
|
|
2739
|
+
/* @__PURE__ */ (0, import_jsx_runtime306.jsx)("g", { mask: animate ? `url(#${maskId})` : void 0, children: sliceData.map((s, i) => /* @__PURE__ */ (0, import_jsx_runtime306.jsx)("g", { children: /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(
|
|
2680
2740
|
"path",
|
|
2681
2741
|
{
|
|
2682
2742
|
d: s.d,
|
|
@@ -2692,9 +2752,9 @@ var PieDonutChart = import_react5.default.memo(
|
|
|
2692
2752
|
);
|
|
2693
2753
|
PieDonutChart.displayName = "PieDonutChart";
|
|
2694
2754
|
var ChartTooltip = ({ x, y, containerWidth, containerHeight, tooltipType, children }) => {
|
|
2695
|
-
const ref =
|
|
2696
|
-
const [pos, setPos] =
|
|
2697
|
-
|
|
2755
|
+
const ref = import_react6.default.useRef(null);
|
|
2756
|
+
const [pos, setPos] = import_react6.default.useState({ left: 0, top: 0 });
|
|
2757
|
+
import_react6.default.useLayoutEffect(() => {
|
|
2698
2758
|
const el = ref.current;
|
|
2699
2759
|
if (!el) return;
|
|
2700
2760
|
const w = el.offsetWidth;
|
|
@@ -2711,15 +2771,15 @@ var ChartTooltip = ({ x, y, containerWidth, containerHeight, tooltipType, childr
|
|
|
2711
2771
|
const sepIdx = content.indexOf(" \u2014 ");
|
|
2712
2772
|
const title = sepIdx >= 0 ? content.slice(0, sepIdx) : content;
|
|
2713
2773
|
const desc = sepIdx >= 0 ? content.slice(sepIdx + 3) : "";
|
|
2714
|
-
return /* @__PURE__ */ (0,
|
|
2774
|
+
return /* @__PURE__ */ (0, import_jsx_runtime306.jsxs)(
|
|
2715
2775
|
"div",
|
|
2716
2776
|
{
|
|
2717
2777
|
ref,
|
|
2718
2778
|
className: `lib-xplat-tooltip ${tooltipType} chart-tooltip-pos`,
|
|
2719
2779
|
style: { left: pos.left, top: pos.top },
|
|
2720
2780
|
children: [
|
|
2721
|
-
title && /* @__PURE__ */ (0,
|
|
2722
|
-
desc && /* @__PURE__ */ (0,
|
|
2781
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime306.jsx)("div", { className: "tooltip-title", children: title }),
|
|
2782
|
+
desc && /* @__PURE__ */ (0, import_jsx_runtime306.jsx)("div", { className: "tooltip-desc", children: desc })
|
|
2723
2783
|
]
|
|
2724
2784
|
}
|
|
2725
2785
|
);
|
|
@@ -2731,14 +2791,14 @@ var ChartLegend = ({ data, labels, type }) => {
|
|
|
2731
2791
|
const total = values.reduce((a, b) => a + b, 0) || 1;
|
|
2732
2792
|
const firstKey = entries[0]?.[0] ?? "";
|
|
2733
2793
|
const colorOffset = hashString(firstKey);
|
|
2734
|
-
return /* @__PURE__ */ (0,
|
|
2794
|
+
return /* @__PURE__ */ (0, import_jsx_runtime306.jsx)("div", { className: "chart-legend", children: values.map((v, i) => {
|
|
2735
2795
|
const pct = Math.round(v / total * 100);
|
|
2736
2796
|
const color = PIE_COLORS[(i + colorOffset) % PIE_COLORS.length];
|
|
2737
|
-
return /* @__PURE__ */ (0,
|
|
2738
|
-
/* @__PURE__ */ (0,
|
|
2739
|
-
/* @__PURE__ */ (0,
|
|
2740
|
-
/* @__PURE__ */ (0,
|
|
2741
|
-
/* @__PURE__ */ (0,
|
|
2797
|
+
return /* @__PURE__ */ (0, import_jsx_runtime306.jsxs)("div", { className: "chart-legend-item", children: [
|
|
2798
|
+
/* @__PURE__ */ (0, import_jsx_runtime306.jsx)("span", { className: "chart-legend-dot", style: { backgroundColor: color } }),
|
|
2799
|
+
/* @__PURE__ */ (0, import_jsx_runtime306.jsxs)("div", { className: "chart-legend-text", children: [
|
|
2800
|
+
/* @__PURE__ */ (0, import_jsx_runtime306.jsx)("span", { className: "chart-legend-label", children: labels[i] || `${i + 1}` }),
|
|
2801
|
+
/* @__PURE__ */ (0, import_jsx_runtime306.jsxs)("span", { className: "chart-legend-value", children: [
|
|
2742
2802
|
v.toLocaleString(),
|
|
2743
2803
|
"(",
|
|
2744
2804
|
pct,
|
|
@@ -2748,103 +2808,42 @@ var ChartLegend = ({ data, labels, type }) => {
|
|
|
2748
2808
|
] }, i);
|
|
2749
2809
|
}) });
|
|
2750
2810
|
}
|
|
2751
|
-
return /* @__PURE__ */ (0,
|
|
2811
|
+
return /* @__PURE__ */ (0, import_jsx_runtime306.jsx)("div", { className: "chart-legend", children: entries.map(([key], di) => {
|
|
2752
2812
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
2753
2813
|
const color = palette[2];
|
|
2754
2814
|
const values = entries[di][1];
|
|
2755
2815
|
const sum = values.reduce((a, b) => a + b, 0);
|
|
2756
|
-
return /* @__PURE__ */ (0,
|
|
2757
|
-
/* @__PURE__ */ (0,
|
|
2758
|
-
/* @__PURE__ */ (0,
|
|
2759
|
-
/* @__PURE__ */ (0,
|
|
2760
|
-
/* @__PURE__ */ (0,
|
|
2816
|
+
return /* @__PURE__ */ (0, import_jsx_runtime306.jsxs)("div", { className: "chart-legend-item", children: [
|
|
2817
|
+
/* @__PURE__ */ (0, import_jsx_runtime306.jsx)("span", { className: "chart-legend-dot", style: { backgroundColor: color } }),
|
|
2818
|
+
/* @__PURE__ */ (0, import_jsx_runtime306.jsxs)("div", { className: "chart-legend-text", children: [
|
|
2819
|
+
/* @__PURE__ */ (0, import_jsx_runtime306.jsx)("span", { className: "chart-legend-label", children: key }),
|
|
2820
|
+
/* @__PURE__ */ (0, import_jsx_runtime306.jsx)("span", { className: "chart-legend-value", children: sum.toLocaleString() })
|
|
2761
2821
|
] })
|
|
2762
2822
|
] }, di);
|
|
2763
2823
|
}) });
|
|
2764
2824
|
};
|
|
2765
|
-
var Chart =
|
|
2825
|
+
var Chart = import_react6.default.memo((props) => {
|
|
2766
2826
|
const { type, data, labels, tooltip: showTooltip = true, tooltipType = "light" } = props;
|
|
2767
2827
|
const { tooltip, show, hide, move, containerRef } = useChartTooltip(showTooltip);
|
|
2768
2828
|
const { width, height } = useChartSize(containerRef);
|
|
2769
|
-
const stableData =
|
|
2770
|
-
const stableLabels =
|
|
2771
|
-
const dataKey =
|
|
2829
|
+
const stableData = import_react6.default.useMemo(() => data, [JSON.stringify(data)]);
|
|
2830
|
+
const stableLabels = import_react6.default.useMemo(() => labels, [JSON.stringify(labels)]);
|
|
2831
|
+
const dataKey = import_react6.default.useMemo(() => JSON.stringify(labels), [labels]);
|
|
2772
2832
|
const animate = useChartAnimation(containerRef, dataKey);
|
|
2773
2833
|
const ready = width > 0 && height > 0;
|
|
2774
|
-
return /* @__PURE__ */ (0,
|
|
2775
|
-
ready && type === "line" && /* @__PURE__ */ (0,
|
|
2776
|
-
ready && type === "curve" && /* @__PURE__ */ (0,
|
|
2777
|
-
ready && type === "bar" && /* @__PURE__ */ (0,
|
|
2778
|
-
ready && type === "pie" && /* @__PURE__ */ (0,
|
|
2779
|
-
ready && type === "doughnut" && /* @__PURE__ */ (0,
|
|
2780
|
-
ready && (type === "pie" || type === "doughnut") && /* @__PURE__ */ (0,
|
|
2781
|
-
tooltip.visible && tooltip.content && /* @__PURE__ */ (0,
|
|
2834
|
+
return /* @__PURE__ */ (0, import_jsx_runtime306.jsxs)("div", { className: "lib-xplat-chart", ref: containerRef, children: [
|
|
2835
|
+
ready && type === "line" && /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(LineChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
|
|
2836
|
+
ready && type === "curve" && /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(CurveChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
|
|
2837
|
+
ready && type === "bar" && /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(BarChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
|
|
2838
|
+
ready && type === "pie" && /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(PieDonutChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
|
|
2839
|
+
ready && type === "doughnut" && /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(PieDonutChart, { data: stableData, labels: stableLabels, width, height, animate, isDoughnut: true, onHover: show, onMove: move, onLeave: hide }),
|
|
2840
|
+
ready && (type === "pie" || type === "doughnut") && /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(ChartLegend, { data: stableData, labels: stableLabels, type }),
|
|
2841
|
+
tooltip.visible && tooltip.content && /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(ChartTooltip, { x: tooltip.x, y: tooltip.y, containerWidth: width, containerHeight: height, tooltipType, children: tooltip.content })
|
|
2782
2842
|
] });
|
|
2783
2843
|
});
|
|
2784
2844
|
Chart.displayName = "Chart";
|
|
2785
2845
|
var Chart_default = Chart;
|
|
2786
2846
|
|
|
2787
|
-
// src/components/AutoResizeTextArea/AutoResizeTextArea.tsx
|
|
2788
|
-
var import_react6 = __toESM(require("react"), 1);
|
|
2789
|
-
var import_jsx_runtime306 = require("react/jsx-runtime");
|
|
2790
|
-
var MAX_HEIGHT = 400;
|
|
2791
|
-
var AutoResizeTextArea = import_react6.default.forwardRef(
|
|
2792
|
-
(props, ref) => {
|
|
2793
|
-
const { value, className, onChange, disabled, bare = false, ...textareaProps } = props;
|
|
2794
|
-
const localRef = import_react6.default.useRef(null);
|
|
2795
|
-
const setRefs = (el) => {
|
|
2796
|
-
localRef.current = el;
|
|
2797
|
-
if (!ref) return;
|
|
2798
|
-
if (typeof ref === "function") ref(el);
|
|
2799
|
-
else if (ref && "current" in ref)
|
|
2800
|
-
ref.current = el;
|
|
2801
|
-
};
|
|
2802
|
-
const updateHeight = () => {
|
|
2803
|
-
const el = localRef.current;
|
|
2804
|
-
if (!el) return;
|
|
2805
|
-
el.style.height = "0px";
|
|
2806
|
-
el.style.height = `${Math.min(el.scrollHeight, MAX_HEIGHT)}px`;
|
|
2807
|
-
};
|
|
2808
|
-
const handleChange = (e) => {
|
|
2809
|
-
if (onChange) {
|
|
2810
|
-
const event = {
|
|
2811
|
-
...e,
|
|
2812
|
-
target: { value: e.target.value }
|
|
2813
|
-
};
|
|
2814
|
-
onChange(event);
|
|
2815
|
-
}
|
|
2816
|
-
};
|
|
2817
|
-
import_react6.default.useEffect(() => {
|
|
2818
|
-
updateHeight();
|
|
2819
|
-
}, [value]);
|
|
2820
|
-
if (bare) {
|
|
2821
|
-
return /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(
|
|
2822
|
-
"textarea",
|
|
2823
|
-
{
|
|
2824
|
-
...textareaProps,
|
|
2825
|
-
ref: setRefs,
|
|
2826
|
-
className,
|
|
2827
|
-
disabled,
|
|
2828
|
-
value,
|
|
2829
|
-
onChange: handleChange
|
|
2830
|
-
}
|
|
2831
|
-
);
|
|
2832
|
-
}
|
|
2833
|
-
return /* @__PURE__ */ (0, import_jsx_runtime306.jsx)("div", { className: clsx_default("lib-xplat-auto-resize-textarea-wrapper", className), children: /* @__PURE__ */ (0, import_jsx_runtime306.jsx)("div", { className: clsx_default("lib-xplat-auto-resize-textarea", disabled && "disabled"), children: /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(
|
|
2834
|
-
"textarea",
|
|
2835
|
-
{
|
|
2836
|
-
...textareaProps,
|
|
2837
|
-
ref: setRefs,
|
|
2838
|
-
disabled,
|
|
2839
|
-
value,
|
|
2840
|
-
onChange: handleChange
|
|
2841
|
-
}
|
|
2842
|
-
) }) });
|
|
2843
|
-
}
|
|
2844
|
-
);
|
|
2845
|
-
AutoResizeTextArea.displayName = "AutoResizeTextArea";
|
|
2846
|
-
var AutoResizeTextArea_default = AutoResizeTextArea;
|
|
2847
|
-
|
|
2848
2847
|
// src/components/ChatInput/ChatInput.tsx
|
|
2849
2848
|
var import_react7 = __toESM(require("react"), 1);
|
|
2850
2849
|
|
|
@@ -2853,7 +2852,6 @@ var import_jsx_runtime307 = require("react/jsx-runtime");
|
|
|
2853
2852
|
var IconButton = (props) => {
|
|
2854
2853
|
const {
|
|
2855
2854
|
icon,
|
|
2856
|
-
className,
|
|
2857
2855
|
type = "primary",
|
|
2858
2856
|
size = "md",
|
|
2859
2857
|
disabled,
|
|
@@ -2862,7 +2860,7 @@ var IconButton = (props) => {
|
|
|
2862
2860
|
return /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(
|
|
2863
2861
|
"button",
|
|
2864
2862
|
{
|
|
2865
|
-
className: clsx_default("lib-xplat-icon-button", type, size
|
|
2863
|
+
className: clsx_default("lib-xplat-icon-button", type, size),
|
|
2866
2864
|
disabled,
|
|
2867
2865
|
...rest,
|
|
2868
2866
|
children: icon
|
|
@@ -5370,12 +5368,12 @@ var Select_default = Select;
|
|
|
5370
5368
|
// src/components/Skeleton/Skeleton.tsx
|
|
5371
5369
|
var import_jsx_runtime337 = require("react/jsx-runtime");
|
|
5372
5370
|
var SIZE_MAP = {
|
|
5373
|
-
xs: "var(--spacing-
|
|
5374
|
-
sm: "var(--spacing-
|
|
5375
|
-
md: "var(--spacing-
|
|
5376
|
-
lg: "var(--spacing-
|
|
5377
|
-
xl: "var(--spacing-
|
|
5378
|
-
"2xl": "var(--spacing-
|
|
5371
|
+
xs: "var(--spacing-space-1)",
|
|
5372
|
+
sm: "var(--spacing-space-2)",
|
|
5373
|
+
md: "var(--spacing-space-4)",
|
|
5374
|
+
lg: "var(--spacing-space-8)",
|
|
5375
|
+
xl: "var(--spacing-space-12)",
|
|
5376
|
+
"2xl": "var(--spacing-space-16)",
|
|
5379
5377
|
full: "100%"
|
|
5380
5378
|
};
|
|
5381
5379
|
var Skeleton = (props) => {
|