@x-plat/design-system 0.6.0 → 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/Calendar/index.cjs +1 -1
- package/dist/components/Calendar/index.js +1 -1
- package/dist/components/Skeleton/index.cjs +6 -6
- package/dist/components/Skeleton/index.js +6 -6
- package/dist/components/Video/index.css +1 -1
- package/dist/components/index.cjs +247 -247
- package/dist/components/index.css +48 -48
- package/dist/components/index.d.cts +2 -2
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.js +221 -221
- package/dist/index.cjs +247 -247
- package/dist/index.css +51 -51
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +221 -221
- package/dist/layout/Header/index.css +2 -2
- package/dist/layout/Layout/index.css +1 -1
- package/dist/layout/index.css +3 -3
- package/package.json +1 -1
package/dist/components/index.js
CHANGED
|
@@ -1503,8 +1503,69 @@ var Alert = (props) => {
|
|
|
1503
1503
|
Alert.displayName = "Alert";
|
|
1504
1504
|
var Alert_default = Alert;
|
|
1505
1505
|
|
|
1506
|
-
// src/components/
|
|
1506
|
+
// src/components/AutoResizeTextArea/AutoResizeTextArea.tsx
|
|
1507
|
+
import React2 from "react";
|
|
1507
1508
|
import { jsx as jsx297 } from "react/jsx-runtime";
|
|
1509
|
+
var MAX_HEIGHT = 400;
|
|
1510
|
+
var AutoResizeTextArea = React2.forwardRef(
|
|
1511
|
+
(props, ref) => {
|
|
1512
|
+
const { value, className, onChange, disabled, bare = false, ...textareaProps } = props;
|
|
1513
|
+
const localRef = React2.useRef(null);
|
|
1514
|
+
const setRefs = (el) => {
|
|
1515
|
+
localRef.current = el;
|
|
1516
|
+
if (!ref) return;
|
|
1517
|
+
if (typeof ref === "function") ref(el);
|
|
1518
|
+
else if (ref && "current" in ref)
|
|
1519
|
+
ref.current = el;
|
|
1520
|
+
};
|
|
1521
|
+
const updateHeight = () => {
|
|
1522
|
+
const el = localRef.current;
|
|
1523
|
+
if (!el) return;
|
|
1524
|
+
el.style.height = "0px";
|
|
1525
|
+
el.style.height = `${Math.min(el.scrollHeight, MAX_HEIGHT)}px`;
|
|
1526
|
+
};
|
|
1527
|
+
const handleChange = (e) => {
|
|
1528
|
+
if (onChange) {
|
|
1529
|
+
const event = {
|
|
1530
|
+
...e,
|
|
1531
|
+
target: { value: e.target.value }
|
|
1532
|
+
};
|
|
1533
|
+
onChange(event);
|
|
1534
|
+
}
|
|
1535
|
+
};
|
|
1536
|
+
React2.useEffect(() => {
|
|
1537
|
+
updateHeight();
|
|
1538
|
+
}, [value]);
|
|
1539
|
+
if (bare) {
|
|
1540
|
+
return /* @__PURE__ */ jsx297(
|
|
1541
|
+
"textarea",
|
|
1542
|
+
{
|
|
1543
|
+
...textareaProps,
|
|
1544
|
+
ref: setRefs,
|
|
1545
|
+
className,
|
|
1546
|
+
disabled,
|
|
1547
|
+
value,
|
|
1548
|
+
onChange: handleChange
|
|
1549
|
+
}
|
|
1550
|
+
);
|
|
1551
|
+
}
|
|
1552
|
+
return /* @__PURE__ */ jsx297("div", { className: clsx_default("lib-xplat-auto-resize-textarea-wrapper", className), children: /* @__PURE__ */ jsx297("div", { className: clsx_default("lib-xplat-auto-resize-textarea", disabled && "disabled"), children: /* @__PURE__ */ jsx297(
|
|
1553
|
+
"textarea",
|
|
1554
|
+
{
|
|
1555
|
+
...textareaProps,
|
|
1556
|
+
ref: setRefs,
|
|
1557
|
+
disabled,
|
|
1558
|
+
value,
|
|
1559
|
+
onChange: handleChange
|
|
1560
|
+
}
|
|
1561
|
+
) }) });
|
|
1562
|
+
}
|
|
1563
|
+
);
|
|
1564
|
+
AutoResizeTextArea.displayName = "AutoResizeTextArea";
|
|
1565
|
+
var AutoResizeTextArea_default = AutoResizeTextArea;
|
|
1566
|
+
|
|
1567
|
+
// src/components/Avatar/Avatar.tsx
|
|
1568
|
+
import { jsx as jsx298 } from "react/jsx-runtime";
|
|
1508
1569
|
var CATEGORICAL_COUNT = 8;
|
|
1509
1570
|
var getColorIndex = (name) => {
|
|
1510
1571
|
if (!name) return 1;
|
|
@@ -1521,13 +1582,13 @@ var Avatar = (props) => {
|
|
|
1521
1582
|
const fullInitials = name ? name.split(" ").map((s) => s[0]).join("").slice(0, 2).toUpperCase() : "";
|
|
1522
1583
|
const initials = size === "sm" ? fullInitials.slice(0, 1) : fullInitials;
|
|
1523
1584
|
const catIndex = getColorIndex(name || "");
|
|
1524
|
-
return /* @__PURE__ */
|
|
1585
|
+
return /* @__PURE__ */ jsx298("div", { className: clsx_default("lib-xplat-avatar", size), children: src ? /* @__PURE__ */ jsx298("img", { src, alt: alt || name || "avatar" }) : /* @__PURE__ */ jsx298("div", { className: clsx_default("fallback", `cat-${catIndex}`), children: initials || /* @__PURE__ */ jsx298("svg", { viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsx298("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" }) }) }) });
|
|
1525
1586
|
};
|
|
1526
1587
|
Avatar.displayName = "Avatar";
|
|
1527
1588
|
var Avatar_default = Avatar;
|
|
1528
1589
|
|
|
1529
1590
|
// src/components/Badge/Badge.tsx
|
|
1530
|
-
import { jsx as
|
|
1591
|
+
import { jsx as jsx299, jsxs as jsxs191 } from "react/jsx-runtime";
|
|
1531
1592
|
var Badge = (props) => {
|
|
1532
1593
|
const {
|
|
1533
1594
|
children,
|
|
@@ -1541,14 +1602,14 @@ var Badge = (props) => {
|
|
|
1541
1602
|
const displayCount = count !== void 0 && count > maxCount ? `${maxCount}+` : count;
|
|
1542
1603
|
return /* @__PURE__ */ jsxs191("div", { className: clsx_default("lib-xplat-badge", size), children: [
|
|
1543
1604
|
children,
|
|
1544
|
-
showBadge && /* @__PURE__ */
|
|
1605
|
+
showBadge && /* @__PURE__ */ jsx299("span", { className: clsx_default("badge-indicator", type, { dot }), children: !dot && displayCount })
|
|
1545
1606
|
] });
|
|
1546
1607
|
};
|
|
1547
1608
|
Badge.displayName = "Badge";
|
|
1548
1609
|
var Badge_default = Badge;
|
|
1549
1610
|
|
|
1550
1611
|
// src/components/Box/Box.tsx
|
|
1551
|
-
import { jsx as
|
|
1612
|
+
import { jsx as jsx300, jsxs as jsxs192 } from "react/jsx-runtime";
|
|
1552
1613
|
var Box = ({
|
|
1553
1614
|
children,
|
|
1554
1615
|
title,
|
|
@@ -1556,22 +1617,22 @@ var Box = ({
|
|
|
1556
1617
|
padding = "md"
|
|
1557
1618
|
}) => {
|
|
1558
1619
|
return /* @__PURE__ */ jsxs192("div", { className: clsx_default("lib-xplat-box", variant, `pad-${padding}`), children: [
|
|
1559
|
-
title && /* @__PURE__ */
|
|
1560
|
-
/* @__PURE__ */
|
|
1620
|
+
title && /* @__PURE__ */ jsx300("div", { className: "box-title", children: title }),
|
|
1621
|
+
/* @__PURE__ */ jsx300("div", { className: "box-content", children })
|
|
1561
1622
|
] });
|
|
1562
1623
|
};
|
|
1563
1624
|
Box.displayName = "Box";
|
|
1564
1625
|
var Box_default = Box;
|
|
1565
1626
|
|
|
1566
1627
|
// src/components/Breadcrumb/Breadcrumb.tsx
|
|
1567
|
-
import { jsx as
|
|
1628
|
+
import { jsx as jsx301, jsxs as jsxs193 } from "react/jsx-runtime";
|
|
1568
1629
|
var Breadcrumb = (props) => {
|
|
1569
1630
|
const { items, separator = "/" } = props;
|
|
1570
|
-
return /* @__PURE__ */
|
|
1631
|
+
return /* @__PURE__ */ jsx301("nav", { className: "lib-xplat-breadcrumb", "aria-label": "\uACBD\uB85C", children: /* @__PURE__ */ jsx301("ol", { children: items.map((item, index) => {
|
|
1571
1632
|
const isLast = index === items.length - 1;
|
|
1572
1633
|
return /* @__PURE__ */ jsxs193("li", { children: [
|
|
1573
|
-
isLast ? /* @__PURE__ */
|
|
1574
|
-
!isLast && /* @__PURE__ */
|
|
1634
|
+
isLast ? /* @__PURE__ */ jsx301("span", { className: "current", "aria-current": "page", children: item.label }) : item.href ? /* @__PURE__ */ jsx301("a", { href: item.href, className: "link", children: item.label }) : /* @__PURE__ */ jsx301("button", { className: "link", onClick: item.onClick, children: item.label }),
|
|
1635
|
+
!isLast && /* @__PURE__ */ jsx301("span", { className: "separator", children: separator })
|
|
1575
1636
|
] }, index);
|
|
1576
1637
|
}) }) });
|
|
1577
1638
|
};
|
|
@@ -1579,7 +1640,7 @@ Breadcrumb.displayName = "Breadcrumb";
|
|
|
1579
1640
|
var Breadcrumb_default = Breadcrumb;
|
|
1580
1641
|
|
|
1581
1642
|
// src/components/Button/Button.tsx
|
|
1582
|
-
import { jsx as
|
|
1643
|
+
import { jsx as jsx302 } from "react/jsx-runtime";
|
|
1583
1644
|
var Button = (props) => {
|
|
1584
1645
|
const {
|
|
1585
1646
|
children,
|
|
@@ -1588,7 +1649,7 @@ var Button = (props) => {
|
|
|
1588
1649
|
disabled,
|
|
1589
1650
|
...rest
|
|
1590
1651
|
} = props;
|
|
1591
|
-
return /* @__PURE__ */
|
|
1652
|
+
return /* @__PURE__ */ jsx302(
|
|
1592
1653
|
"button",
|
|
1593
1654
|
{
|
|
1594
1655
|
className: clsx_default("lib-xplat-button", type, size),
|
|
@@ -1602,15 +1663,15 @@ Button.displayName = "Button";
|
|
|
1602
1663
|
var Button_default = Button;
|
|
1603
1664
|
|
|
1604
1665
|
// src/components/Calendar/Calendar.tsx
|
|
1605
|
-
import
|
|
1666
|
+
import React4 from "react";
|
|
1606
1667
|
|
|
1607
1668
|
// src/components/Calendar/useCalendar.ts
|
|
1608
|
-
import
|
|
1669
|
+
import React3 from "react";
|
|
1609
1670
|
var useCalendar = (initialYear, initialMonth) => {
|
|
1610
1671
|
const today = /* @__PURE__ */ new Date();
|
|
1611
|
-
const [year, setYear] =
|
|
1612
|
-
const [month, setMonth] =
|
|
1613
|
-
const days =
|
|
1672
|
+
const [year, setYear] = React3.useState(initialYear ?? today.getFullYear());
|
|
1673
|
+
const [month, setMonth] = React3.useState(initialMonth ?? today.getMonth());
|
|
1674
|
+
const days = React3.useMemo(() => {
|
|
1614
1675
|
const firstDay = new Date(year, month, 1);
|
|
1615
1676
|
const lastDay = new Date(year, month + 1, 0);
|
|
1616
1677
|
const startDayOfWeek = firstDay.getDay();
|
|
@@ -1653,7 +1714,7 @@ var useCalendar = (initialYear, initialMonth) => {
|
|
|
1653
1714
|
}
|
|
1654
1715
|
return result;
|
|
1655
1716
|
}, [year, month]);
|
|
1656
|
-
const goToPrevMonth =
|
|
1717
|
+
const goToPrevMonth = React3.useCallback(() => {
|
|
1657
1718
|
setMonth((prev) => {
|
|
1658
1719
|
if (prev === 0) {
|
|
1659
1720
|
setYear((y) => y - 1);
|
|
@@ -1662,7 +1723,7 @@ var useCalendar = (initialYear, initialMonth) => {
|
|
|
1662
1723
|
return prev - 1;
|
|
1663
1724
|
});
|
|
1664
1725
|
}, []);
|
|
1665
|
-
const goToNextMonth =
|
|
1726
|
+
const goToNextMonth = React3.useCallback(() => {
|
|
1666
1727
|
setMonth((prev) => {
|
|
1667
1728
|
if (prev === 11) {
|
|
1668
1729
|
setYear((y) => y + 1);
|
|
@@ -1671,7 +1732,7 @@ var useCalendar = (initialYear, initialMonth) => {
|
|
|
1671
1732
|
return prev + 1;
|
|
1672
1733
|
});
|
|
1673
1734
|
}, []);
|
|
1674
|
-
const goToToday =
|
|
1735
|
+
const goToToday = React3.useCallback(() => {
|
|
1675
1736
|
setYear(today.getFullYear());
|
|
1676
1737
|
setMonth(today.getMonth());
|
|
1677
1738
|
}, []);
|
|
@@ -1705,8 +1766,8 @@ var MONTH_LABELS = {
|
|
|
1705
1766
|
};
|
|
1706
1767
|
|
|
1707
1768
|
// src/components/Calendar/Calendar.tsx
|
|
1708
|
-
import { Fragment, jsx as
|
|
1709
|
-
var DayCell =
|
|
1769
|
+
import { Fragment, jsx as jsx303, jsxs as jsxs194 } from "react/jsx-runtime";
|
|
1770
|
+
var DayCell = React4.memo(
|
|
1710
1771
|
({
|
|
1711
1772
|
day,
|
|
1712
1773
|
disabled,
|
|
@@ -1717,7 +1778,7 @@ var DayCell = React3.memo(
|
|
|
1717
1778
|
onEventClick
|
|
1718
1779
|
}) => {
|
|
1719
1780
|
if (renderDay) {
|
|
1720
|
-
return /* @__PURE__ */
|
|
1781
|
+
return /* @__PURE__ */ jsx303(
|
|
1721
1782
|
"div",
|
|
1722
1783
|
{
|
|
1723
1784
|
className: clsx_default(
|
|
@@ -1750,13 +1811,13 @@ var DayCell = React3.memo(
|
|
|
1750
1811
|
if (!disabled && day.isCurrentMonth) onSelect?.(day.date);
|
|
1751
1812
|
},
|
|
1752
1813
|
children: [
|
|
1753
|
-
/* @__PURE__ */
|
|
1814
|
+
/* @__PURE__ */ jsx303("span", { className: "calendar-day-number", children: day.day }),
|
|
1754
1815
|
dayEvents.length > 0 && /* @__PURE__ */ jsxs194("div", { className: "calendar-day-events", children: [
|
|
1755
|
-
dayEvents.slice(0, 3).map((event, ei) => /* @__PURE__ */
|
|
1816
|
+
dayEvents.slice(0, 3).map((event, ei) => /* @__PURE__ */ jsx303(
|
|
1756
1817
|
"span",
|
|
1757
1818
|
{
|
|
1758
1819
|
className: "calendar-event-dot",
|
|
1759
|
-
style: { backgroundColor: event.color ?? "var(--
|
|
1820
|
+
style: { backgroundColor: event.color ?? "var(--semantic-surface-brand-default)" },
|
|
1760
1821
|
title: event.label,
|
|
1761
1822
|
onClick: (e) => {
|
|
1762
1823
|
e.stopPropagation();
|
|
@@ -1802,14 +1863,14 @@ var Calendar = (props) => {
|
|
|
1802
1863
|
setYear,
|
|
1803
1864
|
setMonth
|
|
1804
1865
|
} = useCalendar(yearProp, monthProp);
|
|
1805
|
-
const [pickerMode, setPickerMode] =
|
|
1806
|
-
const [yearRangeStart, setYearRangeStart] =
|
|
1866
|
+
const [pickerMode, setPickerMode] = React4.useState("days");
|
|
1867
|
+
const [yearRangeStart, setYearRangeStart] = React4.useState(
|
|
1807
1868
|
Math.floor(year / 12) * 12
|
|
1808
1869
|
);
|
|
1809
|
-
|
|
1870
|
+
React4.useEffect(() => {
|
|
1810
1871
|
if (yearProp !== void 0) setYear(yearProp);
|
|
1811
1872
|
}, [yearProp, setYear]);
|
|
1812
|
-
|
|
1873
|
+
React4.useEffect(() => {
|
|
1813
1874
|
if (monthProp !== void 0) setMonth(monthProp);
|
|
1814
1875
|
}, [monthProp, setMonth]);
|
|
1815
1876
|
const handlePrev = () => {
|
|
@@ -1861,15 +1922,15 @@ var Calendar = (props) => {
|
|
|
1861
1922
|
setPickerMode("months");
|
|
1862
1923
|
onMonthChange?.(y, month);
|
|
1863
1924
|
};
|
|
1864
|
-
const minTime =
|
|
1925
|
+
const minTime = React4.useMemo(
|
|
1865
1926
|
() => minDate ? new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate()).getTime() : -Infinity,
|
|
1866
1927
|
[minDate]
|
|
1867
1928
|
);
|
|
1868
|
-
const maxTime =
|
|
1929
|
+
const maxTime = React4.useMemo(
|
|
1869
1930
|
() => maxDate ? new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate()).getTime() : Infinity,
|
|
1870
1931
|
[maxDate]
|
|
1871
1932
|
);
|
|
1872
|
-
const eventsMap =
|
|
1933
|
+
const eventsMap = React4.useMemo(() => {
|
|
1873
1934
|
const map = /* @__PURE__ */ new Map();
|
|
1874
1935
|
for (const e of events) {
|
|
1875
1936
|
const key = `${e.date.getFullYear()}-${e.date.getMonth()}-${e.date.getDate()}`;
|
|
@@ -1879,7 +1940,7 @@ var Calendar = (props) => {
|
|
|
1879
1940
|
}
|
|
1880
1941
|
return map;
|
|
1881
1942
|
}, [events]);
|
|
1882
|
-
const getEventsForDay =
|
|
1943
|
+
const getEventsForDay = React4.useCallback(
|
|
1883
1944
|
(date) => eventsMap.get(`${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`) ?? [],
|
|
1884
1945
|
[eventsMap]
|
|
1885
1946
|
);
|
|
@@ -1893,14 +1954,14 @@ var Calendar = (props) => {
|
|
|
1893
1954
|
style: selectedColor ? { "--calendar-selected-color": `var(--${selectedColor})` } : void 0,
|
|
1894
1955
|
children: [
|
|
1895
1956
|
/* @__PURE__ */ jsxs194("div", { className: "calendar-header", children: [
|
|
1896
|
-
/* @__PURE__ */
|
|
1897
|
-
/* @__PURE__ */
|
|
1898
|
-
/* @__PURE__ */
|
|
1899
|
-
showToday && /* @__PURE__ */
|
|
1957
|
+
/* @__PURE__ */ jsx303("button", { className: "calendar-nav", onClick: handlePrev, "aria-label": "\uC774\uC804", children: /* @__PURE__ */ jsx303(ChevronLeftIcon_default, {}) }),
|
|
1958
|
+
/* @__PURE__ */ jsx303("button", { className: "calendar-title", onClick: handleTitleClick, type: "button", children: titleText }),
|
|
1959
|
+
/* @__PURE__ */ jsx303("button", { className: "calendar-nav", onClick: handleNext, "aria-label": "\uB2E4\uC74C", children: /* @__PURE__ */ jsx303(ChevronRightIcon_default, {}) }),
|
|
1960
|
+
showToday && /* @__PURE__ */ jsx303("button", { className: "calendar-today-btn", onClick: handleToday, children: locale === "ko" ? "\uC624\uB298" : "Today" })
|
|
1900
1961
|
] }),
|
|
1901
|
-
pickerMode === "years" && /* @__PURE__ */
|
|
1962
|
+
pickerMode === "years" && /* @__PURE__ */ jsx303("div", { className: "calendar-picker-grid", children: Array.from({ length: 12 }, (_, i) => {
|
|
1902
1963
|
const y = yearRangeStart + i;
|
|
1903
|
-
return /* @__PURE__ */
|
|
1964
|
+
return /* @__PURE__ */ jsx303(
|
|
1904
1965
|
"button",
|
|
1905
1966
|
{
|
|
1906
1967
|
type: "button",
|
|
@@ -1911,7 +1972,7 @@ var Calendar = (props) => {
|
|
|
1911
1972
|
y
|
|
1912
1973
|
);
|
|
1913
1974
|
}) }),
|
|
1914
|
-
pickerMode === "months" && /* @__PURE__ */
|
|
1975
|
+
pickerMode === "months" && /* @__PURE__ */ jsx303("div", { className: "calendar-picker-grid", children: monthLabels.map((label, i) => /* @__PURE__ */ jsx303(
|
|
1915
1976
|
"button",
|
|
1916
1977
|
{
|
|
1917
1978
|
type: "button",
|
|
@@ -1922,7 +1983,7 @@ var Calendar = (props) => {
|
|
|
1922
1983
|
i
|
|
1923
1984
|
)) }),
|
|
1924
1985
|
pickerMode === "days" && /* @__PURE__ */ jsxs194(Fragment, { children: [
|
|
1925
|
-
/* @__PURE__ */
|
|
1986
|
+
/* @__PURE__ */ jsx303("div", { className: "calendar-weekdays", children: weekdays.map((label, i) => /* @__PURE__ */ jsx303(
|
|
1926
1987
|
"div",
|
|
1927
1988
|
{
|
|
1928
1989
|
className: clsx_default(
|
|
@@ -1934,12 +1995,12 @@ var Calendar = (props) => {
|
|
|
1934
1995
|
},
|
|
1935
1996
|
label
|
|
1936
1997
|
)) }),
|
|
1937
|
-
/* @__PURE__ */
|
|
1998
|
+
/* @__PURE__ */ jsx303("div", { className: "calendar-grid", children: days.map((day, idx) => {
|
|
1938
1999
|
const dayEvents = getEventsForDay(day.date);
|
|
1939
2000
|
const t = day.date.getTime();
|
|
1940
2001
|
const disabled = t < minTime || t > maxTime;
|
|
1941
2002
|
const isSelected = selectedDate ? isSameDay(day.date, selectedDate) : false;
|
|
1942
|
-
return /* @__PURE__ */
|
|
2003
|
+
return /* @__PURE__ */ jsx303(
|
|
1943
2004
|
DayCell,
|
|
1944
2005
|
{
|
|
1945
2006
|
day,
|
|
@@ -1962,13 +2023,13 @@ Calendar.displayName = "Calendar";
|
|
|
1962
2023
|
var Calendar_default = Calendar;
|
|
1963
2024
|
|
|
1964
2025
|
// src/components/CardTab/CardTab.tsx
|
|
1965
|
-
import
|
|
2026
|
+
import React5 from "react";
|
|
1966
2027
|
|
|
1967
2028
|
// src/components/CardTab/CardTabPanel.tsx
|
|
1968
|
-
import { jsx as
|
|
2029
|
+
import { jsx as jsx304 } from "react/jsx-runtime";
|
|
1969
2030
|
var CardTabPanel = (props) => {
|
|
1970
2031
|
const { children, columns = 3 } = props;
|
|
1971
|
-
return /* @__PURE__ */
|
|
2032
|
+
return /* @__PURE__ */ jsx304(
|
|
1972
2033
|
"div",
|
|
1973
2034
|
{
|
|
1974
2035
|
className: "card-tab-panel",
|
|
@@ -1981,7 +2042,7 @@ CardTabPanel.displayName = "CardTab.Panel";
|
|
|
1981
2042
|
var CardTabPanel_default = CardTabPanel;
|
|
1982
2043
|
|
|
1983
2044
|
// src/components/CardTab/CardTab.tsx
|
|
1984
|
-
import { jsx as
|
|
2045
|
+
import { jsx as jsx305, jsxs as jsxs195 } from "react/jsx-runtime";
|
|
1985
2046
|
var CardTabRoot = (props) => {
|
|
1986
2047
|
const {
|
|
1987
2048
|
tabs,
|
|
@@ -1991,7 +2052,7 @@ var CardTabRoot = (props) => {
|
|
|
1991
2052
|
children
|
|
1992
2053
|
} = props;
|
|
1993
2054
|
const isControlled = activeValueProp !== void 0;
|
|
1994
|
-
const [uncontrolledValue, setUncontrolledValue] =
|
|
2055
|
+
const [uncontrolledValue, setUncontrolledValue] = React5.useState(tabs[0]?.value ?? "");
|
|
1995
2056
|
const activeValue = isControlled ? activeValueProp : uncontrolledValue;
|
|
1996
2057
|
const handleTabClick = (tab) => {
|
|
1997
2058
|
if (!isControlled) {
|
|
@@ -1999,16 +2060,16 @@ var CardTabRoot = (props) => {
|
|
|
1999
2060
|
}
|
|
2000
2061
|
onChange?.(tab);
|
|
2001
2062
|
};
|
|
2002
|
-
const panels =
|
|
2003
|
-
(child) =>
|
|
2063
|
+
const panels = React5.Children.toArray(children).filter(
|
|
2064
|
+
(child) => React5.isValidElement(child) && child.type === CardTabPanel_default
|
|
2004
2065
|
);
|
|
2005
2066
|
const activePanel = panels.find(
|
|
2006
2067
|
(panel) => panel.props.value === activeValue
|
|
2007
2068
|
);
|
|
2008
2069
|
return /* @__PURE__ */ jsxs195("div", { className: clsx_default("lib-xplat-card-tab", size), children: [
|
|
2009
|
-
/* @__PURE__ */
|
|
2070
|
+
/* @__PURE__ */ jsx305("div", { className: "card-tab-bar", children: tabs.map((tab) => {
|
|
2010
2071
|
const isActive2 = tab.value === activeValue;
|
|
2011
|
-
return /* @__PURE__ */
|
|
2072
|
+
return /* @__PURE__ */ jsx305(
|
|
2012
2073
|
"button",
|
|
2013
2074
|
{
|
|
2014
2075
|
className: clsx_default("card-tab-trigger", isActive2 && "active"),
|
|
@@ -2020,7 +2081,7 @@ var CardTabRoot = (props) => {
|
|
|
2020
2081
|
tab.value
|
|
2021
2082
|
);
|
|
2022
2083
|
}) }),
|
|
2023
|
-
/* @__PURE__ */
|
|
2084
|
+
/* @__PURE__ */ jsx305("div", { className: "card-tab-body", children: activePanel })
|
|
2024
2085
|
] });
|
|
2025
2086
|
};
|
|
2026
2087
|
CardTabRoot.displayName = "CardTab";
|
|
@@ -2030,8 +2091,8 @@ var CardTab = Object.assign(CardTabRoot, {
|
|
|
2030
2091
|
var CardTab_default = CardTab;
|
|
2031
2092
|
|
|
2032
2093
|
// src/components/Chart/Chart.tsx
|
|
2033
|
-
import
|
|
2034
|
-
import { Fragment as Fragment2, jsx as
|
|
2094
|
+
import React6 from "react";
|
|
2095
|
+
import { Fragment as Fragment2, jsx as jsx306, jsxs as jsxs196 } from "react/jsx-runtime";
|
|
2035
2096
|
var CATEGORICAL_COUNT2 = 8;
|
|
2036
2097
|
var LINE_BAR_PALETTES = Array.from({ length: CATEGORICAL_COUNT2 }, (_, i) => {
|
|
2037
2098
|
const n = i + 1;
|
|
@@ -2076,8 +2137,8 @@ var toSmoothPath = (points) => {
|
|
|
2076
2137
|
return d;
|
|
2077
2138
|
};
|
|
2078
2139
|
var useChartSize = (ref) => {
|
|
2079
|
-
const [size, setSize] =
|
|
2080
|
-
|
|
2140
|
+
const [size, setSize] = React6.useState({ width: 0, height: 0 });
|
|
2141
|
+
React6.useEffect(() => {
|
|
2081
2142
|
const el = ref.current;
|
|
2082
2143
|
if (!el) return;
|
|
2083
2144
|
let rafId = 0;
|
|
@@ -2103,10 +2164,10 @@ var useChartSize = (ref) => {
|
|
|
2103
2164
|
};
|
|
2104
2165
|
var prefersReducedMotion = () => typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
2105
2166
|
var useChartAnimation = (containerRef, dataKey) => {
|
|
2106
|
-
const [animate, setAnimate] =
|
|
2107
|
-
const prevDataKey =
|
|
2108
|
-
const hasAnimated =
|
|
2109
|
-
|
|
2167
|
+
const [animate, setAnimate] = React6.useState(false);
|
|
2168
|
+
const prevDataKey = React6.useRef(dataKey);
|
|
2169
|
+
const hasAnimated = React6.useRef(false);
|
|
2170
|
+
React6.useEffect(() => {
|
|
2110
2171
|
if (prefersReducedMotion()) return;
|
|
2111
2172
|
const el = containerRef.current;
|
|
2112
2173
|
if (!el) return;
|
|
@@ -2122,7 +2183,7 @@ var useChartAnimation = (containerRef, dataKey) => {
|
|
|
2122
2183
|
observer.observe(el);
|
|
2123
2184
|
return () => observer.disconnect();
|
|
2124
2185
|
}, [containerRef]);
|
|
2125
|
-
|
|
2186
|
+
React6.useEffect(() => {
|
|
2126
2187
|
if (dataKey !== prevDataKey.current) {
|
|
2127
2188
|
prevDataKey.current = dataKey;
|
|
2128
2189
|
if (prefersReducedMotion()) return;
|
|
@@ -2136,15 +2197,15 @@ var useChartAnimation = (containerRef, dataKey) => {
|
|
|
2136
2197
|
};
|
|
2137
2198
|
var TOOLTIP_OFFSET = 12;
|
|
2138
2199
|
var useChartTooltip = (enabled) => {
|
|
2139
|
-
const [tooltip, setTooltip] =
|
|
2200
|
+
const [tooltip, setTooltip] = React6.useState({
|
|
2140
2201
|
visible: false,
|
|
2141
2202
|
x: 0,
|
|
2142
2203
|
y: 0,
|
|
2143
2204
|
content: ""
|
|
2144
2205
|
});
|
|
2145
|
-
const containerRef =
|
|
2146
|
-
const rafRef =
|
|
2147
|
-
const move =
|
|
2206
|
+
const containerRef = React6.useRef(null);
|
|
2207
|
+
const rafRef = React6.useRef(0);
|
|
2208
|
+
const move = React6.useCallback((e) => {
|
|
2148
2209
|
if (!enabled) return;
|
|
2149
2210
|
const cx = e.clientX;
|
|
2150
2211
|
const cy = e.clientY;
|
|
@@ -2155,24 +2216,24 @@ var useChartTooltip = (enabled) => {
|
|
|
2155
2216
|
setTooltip((prev) => ({ ...prev, x: cx - rect.left, y: cy - rect.top }));
|
|
2156
2217
|
});
|
|
2157
2218
|
}, [enabled]);
|
|
2158
|
-
const show =
|
|
2219
|
+
const show = React6.useCallback((e, content) => {
|
|
2159
2220
|
if (!enabled) return;
|
|
2160
2221
|
const rect = containerRef.current?.getBoundingClientRect();
|
|
2161
2222
|
if (!rect) return;
|
|
2162
2223
|
setTooltip({ visible: true, x: e.clientX - rect.left, y: e.clientY - rect.top, content });
|
|
2163
2224
|
}, [enabled]);
|
|
2164
|
-
const hide =
|
|
2225
|
+
const hide = React6.useCallback(() => {
|
|
2165
2226
|
cancelAnimationFrame(rafRef.current);
|
|
2166
2227
|
setTooltip((prev) => ({ ...prev, visible: false }));
|
|
2167
2228
|
}, []);
|
|
2168
2229
|
return { tooltip, show, hide, move, containerRef };
|
|
2169
2230
|
};
|
|
2170
|
-
var GridLines =
|
|
2231
|
+
var GridLines = React6.memo(({ width, height, chartH, maxVal }) => /* @__PURE__ */ jsx306(Fragment2, { children: [0, 0.25, 0.5, 0.75, 1].map((ratio) => {
|
|
2171
2232
|
const y = PADDING.top + (1 - ratio) * chartH;
|
|
2172
2233
|
const val = Math.round(maxVal * ratio);
|
|
2173
2234
|
return /* @__PURE__ */ jsxs196("g", { children: [
|
|
2174
|
-
/* @__PURE__ */
|
|
2175
|
-
/* @__PURE__ */
|
|
2235
|
+
/* @__PURE__ */ jsx306("line", { x1: PADDING.left, y1: y, x2: width - PADDING.right, y2: y, className: "chart-grid" }),
|
|
2236
|
+
/* @__PURE__ */ jsx306("text", { x: PADDING.left - 8, y: y + 4, className: "chart-axis-label", textAnchor: "end", children: val })
|
|
2176
2237
|
] }, ratio);
|
|
2177
2238
|
}) }));
|
|
2178
2239
|
GridLines.displayName = "GridLines";
|
|
@@ -2182,18 +2243,18 @@ var getLabelStep = (count, chartW) => {
|
|
|
2182
2243
|
if (count <= maxLabels) return 1;
|
|
2183
2244
|
return Math.ceil(count / maxLabels);
|
|
2184
2245
|
};
|
|
2185
|
-
var AxisLabels =
|
|
2246
|
+
var AxisLabels = React6.memo(({ labels, count, chartW, height }) => {
|
|
2186
2247
|
const step = getLabelStep(count, chartW);
|
|
2187
|
-
return /* @__PURE__ */
|
|
2248
|
+
return /* @__PURE__ */ jsx306(Fragment2, { children: labels.map((label, i) => {
|
|
2188
2249
|
if (i % step !== 0) return null;
|
|
2189
2250
|
const x = PADDING.left + i / (count - 1 || 1) * chartW;
|
|
2190
|
-
return /* @__PURE__ */
|
|
2251
|
+
return /* @__PURE__ */ jsx306("text", { x, y: height - 8, className: "chart-axis-label", textAnchor: "middle", children: label }, i);
|
|
2191
2252
|
}) });
|
|
2192
2253
|
});
|
|
2193
2254
|
AxisLabels.displayName = "AxisLabels";
|
|
2194
2255
|
var useCrosshair = (seriesPoints, entries, labels, chartH) => {
|
|
2195
|
-
const [activeIndex, setActiveIndex] =
|
|
2196
|
-
const handleMouseMove =
|
|
2256
|
+
const [activeIndex, setActiveIndex] = React6.useState(null);
|
|
2257
|
+
const handleMouseMove = React6.useCallback((e) => {
|
|
2197
2258
|
const svg = e.currentTarget;
|
|
2198
2259
|
const rect = svg.getBoundingClientRect();
|
|
2199
2260
|
const mx = (e.clientX - rect.left) / rect.width * svg.viewBox.baseVal.width;
|
|
@@ -2212,17 +2273,17 @@ var useCrosshair = (seriesPoints, entries, labels, chartH) => {
|
|
|
2212
2273
|
}
|
|
2213
2274
|
setActiveIndex(minDist <= threshold ? closest : null);
|
|
2214
2275
|
}, [seriesPoints]);
|
|
2215
|
-
const handleMouseLeave =
|
|
2276
|
+
const handleMouseLeave = React6.useCallback(() => {
|
|
2216
2277
|
setActiveIndex(null);
|
|
2217
2278
|
}, []);
|
|
2218
|
-
const tooltipContent =
|
|
2279
|
+
const tooltipContent = React6.useMemo(() => {
|
|
2219
2280
|
if (activeIndex === null) return "";
|
|
2220
2281
|
return entries.map(([key], di) => {
|
|
2221
2282
|
const p = seriesPoints[di]?.[activeIndex];
|
|
2222
2283
|
return p ? `${key}: ${p.v}` : "";
|
|
2223
2284
|
}).filter(Boolean).join(" / ");
|
|
2224
2285
|
}, [activeIndex, entries, seriesPoints]);
|
|
2225
|
-
const getTooltipAt =
|
|
2286
|
+
const getTooltipAt = React6.useCallback((idx) => {
|
|
2226
2287
|
return entries.map(([key], di) => {
|
|
2227
2288
|
const p = seriesPoints[di]?.[idx];
|
|
2228
2289
|
return p ? `${key}: ${p.v}` : "";
|
|
@@ -2230,16 +2291,16 @@ var useCrosshair = (seriesPoints, entries, labels, chartH) => {
|
|
|
2230
2291
|
}, [entries, seriesPoints]);
|
|
2231
2292
|
return { activeIndex, handleMouseMove, handleMouseLeave, tooltipContent, getTooltipAt };
|
|
2232
2293
|
};
|
|
2233
|
-
var LineChart =
|
|
2234
|
-
const entries =
|
|
2235
|
-
const maxVal =
|
|
2294
|
+
var LineChart = React6.memo(({ data, labels, width, height, animate, onHover, onMove, onLeave }) => {
|
|
2295
|
+
const entries = React6.useMemo(() => Object.entries(data), [data]);
|
|
2296
|
+
const maxVal = React6.useMemo(() => {
|
|
2236
2297
|
const allValues = entries.flatMap(([, v]) => v);
|
|
2237
2298
|
return Math.max(...allValues) * 1.2 || 1;
|
|
2238
2299
|
}, [entries]);
|
|
2239
2300
|
const count = labels.length;
|
|
2240
2301
|
const chartW = width - PADDING.left - PADDING.right;
|
|
2241
2302
|
const chartH = height - PADDING.top - PADDING.bottom;
|
|
2242
|
-
const seriesPoints =
|
|
2303
|
+
const seriesPoints = React6.useMemo(
|
|
2243
2304
|
() => entries.map(
|
|
2244
2305
|
([, values]) => values.map((v, i) => ({
|
|
2245
2306
|
x: PADDING.left + i / (count - 1 || 1) * chartW,
|
|
@@ -2249,9 +2310,9 @@ var LineChart = React5.memo(({ data, labels, width, height, animate, onHover, on
|
|
|
2249
2310
|
),
|
|
2250
2311
|
[entries, count, chartW, chartH, maxVal]
|
|
2251
2312
|
);
|
|
2252
|
-
const clipRef =
|
|
2313
|
+
const clipRef = React6.useRef(null);
|
|
2253
2314
|
const { activeIndex, handleMouseMove, handleMouseLeave, getTooltipAt } = useCrosshair(seriesPoints, entries, labels, chartH);
|
|
2254
|
-
|
|
2315
|
+
React6.useEffect(() => {
|
|
2255
2316
|
if (!animate || !clipRef.current) return;
|
|
2256
2317
|
clipRef.current.setAttribute("width", "0");
|
|
2257
2318
|
requestAnimationFrame(() => {
|
|
@@ -2281,9 +2342,9 @@ var LineChart = React5.memo(({ data, labels, width, height, animate, onHover, on
|
|
|
2281
2342
|
onLeave();
|
|
2282
2343
|
},
|
|
2283
2344
|
children: [
|
|
2284
|
-
animate && /* @__PURE__ */
|
|
2285
|
-
/* @__PURE__ */
|
|
2286
|
-
/* @__PURE__ */
|
|
2345
|
+
animate && /* @__PURE__ */ jsx306("defs", { children: /* @__PURE__ */ jsx306("clipPath", { id: lineClipId, children: /* @__PURE__ */ jsx306("rect", { ref: clipRef, x: "0", y: "0", width: animate ? 0 : width, height }) }) }),
|
|
2346
|
+
/* @__PURE__ */ jsx306(GridLines, { width, height, chartH, maxVal }),
|
|
2347
|
+
/* @__PURE__ */ jsx306(AxisLabels, { labels, count, chartW, height }),
|
|
2287
2348
|
entries.map(([key], di) => {
|
|
2288
2349
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
2289
2350
|
const color = palette[2];
|
|
@@ -2293,15 +2354,15 @@ var LineChart = React5.memo(({ data, labels, width, height, animate, onHover, on
|
|
|
2293
2354
|
const polyPoints = points.map((p) => `${p.x},${p.y}`).join(" ");
|
|
2294
2355
|
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`;
|
|
2295
2356
|
return /* @__PURE__ */ jsxs196("g", { children: [
|
|
2296
|
-
/* @__PURE__ */
|
|
2297
|
-
/* @__PURE__ */
|
|
2298
|
-
/* @__PURE__ */
|
|
2357
|
+
/* @__PURE__ */ jsx306("defs", { children: /* @__PURE__ */ jsxs196("linearGradient", { id: gradientId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
2358
|
+
/* @__PURE__ */ jsx306("stop", { offset: "0%", stopColor: areaColor, stopOpacity: "0.2" }),
|
|
2359
|
+
/* @__PURE__ */ jsx306("stop", { offset: "100%", stopColor: areaColor, stopOpacity: "0" })
|
|
2299
2360
|
] }) }),
|
|
2300
2361
|
/* @__PURE__ */ jsxs196("g", { clipPath: animate ? `url(#${lineClipId})` : void 0, children: [
|
|
2301
|
-
/* @__PURE__ */
|
|
2302
|
-
/* @__PURE__ */
|
|
2362
|
+
/* @__PURE__ */ jsx306("path", { d: areaD, fill: `url(#${gradientId})` }),
|
|
2363
|
+
/* @__PURE__ */ jsx306("polyline", { points: polyPoints, fill: "none", stroke: color, strokeWidth: "2" })
|
|
2303
2364
|
] }),
|
|
2304
|
-
activeIndex !== null && points[activeIndex] && /* @__PURE__ */
|
|
2365
|
+
activeIndex !== null && points[activeIndex] && /* @__PURE__ */ jsx306(
|
|
2305
2366
|
"circle",
|
|
2306
2367
|
{
|
|
2307
2368
|
cx: points[activeIndex].x,
|
|
@@ -2313,7 +2374,7 @@ var LineChart = React5.memo(({ data, labels, width, height, animate, onHover, on
|
|
|
2313
2374
|
)
|
|
2314
2375
|
] }, di);
|
|
2315
2376
|
}),
|
|
2316
|
-
activeX !== null && /* @__PURE__ */
|
|
2377
|
+
activeX !== null && /* @__PURE__ */ jsx306(
|
|
2317
2378
|
"line",
|
|
2318
2379
|
{
|
|
2319
2380
|
x1: activeX,
|
|
@@ -2323,7 +2384,7 @@ var LineChart = React5.memo(({ data, labels, width, height, animate, onHover, on
|
|
|
2323
2384
|
className: "chart-crosshair"
|
|
2324
2385
|
}
|
|
2325
2386
|
),
|
|
2326
|
-
/* @__PURE__ */
|
|
2387
|
+
/* @__PURE__ */ jsx306(
|
|
2327
2388
|
"rect",
|
|
2328
2389
|
{
|
|
2329
2390
|
x: PADDING.left,
|
|
@@ -2339,16 +2400,16 @@ var LineChart = React5.memo(({ data, labels, width, height, animate, onHover, on
|
|
|
2339
2400
|
);
|
|
2340
2401
|
});
|
|
2341
2402
|
LineChart.displayName = "LineChart";
|
|
2342
|
-
var CurveChart =
|
|
2343
|
-
const entries =
|
|
2344
|
-
const maxVal =
|
|
2403
|
+
var CurveChart = React6.memo(({ data, labels, width, height, animate, onHover, onMove, onLeave }) => {
|
|
2404
|
+
const entries = React6.useMemo(() => Object.entries(data), [data]);
|
|
2405
|
+
const maxVal = React6.useMemo(() => {
|
|
2345
2406
|
const allValues = entries.flatMap(([, v]) => v);
|
|
2346
2407
|
return Math.max(...allValues) * 1.2 || 1;
|
|
2347
2408
|
}, [entries]);
|
|
2348
2409
|
const count = labels.length;
|
|
2349
2410
|
const chartW = width - PADDING.left - PADDING.right;
|
|
2350
2411
|
const chartH = height - PADDING.top - PADDING.bottom;
|
|
2351
|
-
const seriesPoints =
|
|
2412
|
+
const seriesPoints = React6.useMemo(
|
|
2352
2413
|
() => entries.map(
|
|
2353
2414
|
([, values]) => values.map((v, i) => ({
|
|
2354
2415
|
x: PADDING.left + i / (count - 1 || 1) * chartW,
|
|
@@ -2358,9 +2419,9 @@ var CurveChart = React5.memo(({ data, labels, width, height, animate, onHover, o
|
|
|
2358
2419
|
),
|
|
2359
2420
|
[entries, count, chartW, chartH, maxVal]
|
|
2360
2421
|
);
|
|
2361
|
-
const curveClipRef =
|
|
2422
|
+
const curveClipRef = React6.useRef(null);
|
|
2362
2423
|
const { activeIndex, handleMouseMove, handleMouseLeave, getTooltipAt } = useCrosshair(seriesPoints, entries, labels, chartH);
|
|
2363
|
-
|
|
2424
|
+
React6.useEffect(() => {
|
|
2364
2425
|
if (!animate || !curveClipRef.current) return;
|
|
2365
2426
|
curveClipRef.current.setAttribute("width", "0");
|
|
2366
2427
|
requestAnimationFrame(() => {
|
|
@@ -2391,9 +2452,9 @@ var CurveChart = React5.memo(({ data, labels, width, height, animate, onHover, o
|
|
|
2391
2452
|
onLeave();
|
|
2392
2453
|
},
|
|
2393
2454
|
children: [
|
|
2394
|
-
animate && /* @__PURE__ */
|
|
2395
|
-
/* @__PURE__ */
|
|
2396
|
-
/* @__PURE__ */
|
|
2455
|
+
animate && /* @__PURE__ */ jsx306("defs", { children: /* @__PURE__ */ jsx306("clipPath", { id: curveClipId, children: /* @__PURE__ */ jsx306("rect", { ref: curveClipRef, x: "0", y: "0", width: animate ? 0 : width, height }) }) }),
|
|
2456
|
+
/* @__PURE__ */ jsx306(GridLines, { width, height, chartH, maxVal }),
|
|
2457
|
+
/* @__PURE__ */ jsx306(AxisLabels, { labels, count, chartW, height }),
|
|
2397
2458
|
entries.map(([key], di) => {
|
|
2398
2459
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
2399
2460
|
const color = palette[2];
|
|
@@ -2403,15 +2464,15 @@ var CurveChart = React5.memo(({ data, labels, width, height, animate, onHover, o
|
|
|
2403
2464
|
const linePath = toSmoothPath(points);
|
|
2404
2465
|
const areaPath = linePath + ` L ${points[points.length - 1].x} ${PADDING.top + chartH} L ${points[0].x} ${PADDING.top + chartH} Z`;
|
|
2405
2466
|
return /* @__PURE__ */ jsxs196("g", { children: [
|
|
2406
|
-
/* @__PURE__ */
|
|
2407
|
-
/* @__PURE__ */
|
|
2408
|
-
/* @__PURE__ */
|
|
2467
|
+
/* @__PURE__ */ jsx306("defs", { children: /* @__PURE__ */ jsxs196("linearGradient", { id: gradientId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
2468
|
+
/* @__PURE__ */ jsx306("stop", { offset: "0%", stopColor: areaColor, stopOpacity: "0.4" }),
|
|
2469
|
+
/* @__PURE__ */ jsx306("stop", { offset: "100%", stopColor: areaColor, stopOpacity: "0.02" })
|
|
2409
2470
|
] }) }),
|
|
2410
2471
|
/* @__PURE__ */ jsxs196("g", { clipPath: animate ? `url(#${curveClipId})` : void 0, children: [
|
|
2411
|
-
/* @__PURE__ */
|
|
2412
|
-
/* @__PURE__ */
|
|
2472
|
+
/* @__PURE__ */ jsx306("path", { d: areaPath, fill: `url(#${gradientId})` }),
|
|
2473
|
+
/* @__PURE__ */ jsx306("path", { d: linePath, fill: "none", stroke: color, strokeWidth: "2" })
|
|
2413
2474
|
] }),
|
|
2414
|
-
activeIndex !== null && points[activeIndex] && /* @__PURE__ */
|
|
2475
|
+
activeIndex !== null && points[activeIndex] && /* @__PURE__ */ jsx306(
|
|
2415
2476
|
"circle",
|
|
2416
2477
|
{
|
|
2417
2478
|
cx: points[activeIndex].x,
|
|
@@ -2423,7 +2484,7 @@ var CurveChart = React5.memo(({ data, labels, width, height, animate, onHover, o
|
|
|
2423
2484
|
)
|
|
2424
2485
|
] }, di);
|
|
2425
2486
|
}),
|
|
2426
|
-
activeX !== null && /* @__PURE__ */
|
|
2487
|
+
activeX !== null && /* @__PURE__ */ jsx306(
|
|
2427
2488
|
"line",
|
|
2428
2489
|
{
|
|
2429
2490
|
x1: activeX,
|
|
@@ -2433,7 +2494,7 @@ var CurveChart = React5.memo(({ data, labels, width, height, animate, onHover, o
|
|
|
2433
2494
|
className: "chart-crosshair"
|
|
2434
2495
|
}
|
|
2435
2496
|
),
|
|
2436
|
-
/* @__PURE__ */
|
|
2497
|
+
/* @__PURE__ */ jsx306(
|
|
2437
2498
|
"rect",
|
|
2438
2499
|
{
|
|
2439
2500
|
x: PADDING.left,
|
|
@@ -2449,9 +2510,9 @@ var CurveChart = React5.memo(({ data, labels, width, height, animate, onHover, o
|
|
|
2449
2510
|
);
|
|
2450
2511
|
});
|
|
2451
2512
|
CurveChart.displayName = "CurveChart";
|
|
2452
|
-
var BarChart =
|
|
2453
|
-
const entries =
|
|
2454
|
-
const maxVal =
|
|
2513
|
+
var BarChart = React6.memo(({ data, labels, width, height, animate, onHover, onMove, onLeave }) => {
|
|
2514
|
+
const entries = React6.useMemo(() => Object.entries(data), [data]);
|
|
2515
|
+
const maxVal = React6.useMemo(() => {
|
|
2455
2516
|
const allValues = entries.flatMap(([, v]) => v);
|
|
2456
2517
|
return Math.max(...allValues) * 1.2 || 1;
|
|
2457
2518
|
}, [entries]);
|
|
@@ -2463,7 +2524,7 @@ var BarChart = React5.memo(({ data, labels, width, height, animate, onHover, onM
|
|
|
2463
2524
|
const barGap = groupCount > 1 ? 2 : 0;
|
|
2464
2525
|
const barW = Math.max(1, Math.min(32, (groupW * 0.7 - barGap * (groupCount - 1)) / groupCount));
|
|
2465
2526
|
const baseline = PADDING.top + chartH;
|
|
2466
|
-
const bars =
|
|
2527
|
+
const bars = React6.useMemo(
|
|
2467
2528
|
() => entries.map(
|
|
2468
2529
|
([, values], di) => values.map((v, i) => {
|
|
2469
2530
|
const totalBarsW = barW * groupCount + barGap * (groupCount - 1);
|
|
@@ -2477,10 +2538,10 @@ var BarChart = React5.memo(({ data, labels, width, height, animate, onHover, onM
|
|
|
2477
2538
|
);
|
|
2478
2539
|
const barLabelStep = getLabelStep(count, chartW);
|
|
2479
2540
|
return /* @__PURE__ */ jsxs196("svg", { viewBox: `0 0 ${width} ${height}`, className: "chart-svg", children: [
|
|
2480
|
-
/* @__PURE__ */
|
|
2541
|
+
/* @__PURE__ */ jsx306(GridLines, { width, height, chartH, maxVal }),
|
|
2481
2542
|
labels.map((label, i) => {
|
|
2482
2543
|
if (i % barLabelStep !== 0) return null;
|
|
2483
|
-
return /* @__PURE__ */
|
|
2544
|
+
return /* @__PURE__ */ jsx306("text", { x: PADDING.left + groupW * i + groupW / 2, y: height - 8, className: "chart-axis-label", textAnchor: "middle", children: label }, i);
|
|
2484
2545
|
}),
|
|
2485
2546
|
entries.map(([key], di) => {
|
|
2486
2547
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
@@ -2489,7 +2550,7 @@ var BarChart = React5.memo(({ data, labels, width, height, animate, onHover, onM
|
|
|
2489
2550
|
const r2 = Math.min(4, b.w / 2);
|
|
2490
2551
|
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`;
|
|
2491
2552
|
const delay = 100 + i * 80;
|
|
2492
|
-
return /* @__PURE__ */
|
|
2553
|
+
return /* @__PURE__ */ jsx306(
|
|
2493
2554
|
"path",
|
|
2494
2555
|
{
|
|
2495
2556
|
d,
|
|
@@ -2510,11 +2571,11 @@ var BarChart = React5.memo(({ data, labels, width, height, animate, onHover, onM
|
|
|
2510
2571
|
] });
|
|
2511
2572
|
});
|
|
2512
2573
|
BarChart.displayName = "BarChart";
|
|
2513
|
-
var PieDonutChart =
|
|
2574
|
+
var PieDonutChart = React6.memo(
|
|
2514
2575
|
({ data, labels, width, height, animate, isDoughnut, onHover, onMove, onLeave }) => {
|
|
2515
|
-
const entries =
|
|
2516
|
-
const values =
|
|
2517
|
-
const total =
|
|
2576
|
+
const entries = React6.useMemo(() => Object.entries(data), [data]);
|
|
2577
|
+
const values = React6.useMemo(() => entries.flatMap(([, v]) => v), [entries]);
|
|
2578
|
+
const total = React6.useMemo(() => values.reduce((a, b) => a + b, 0) || 1, [values]);
|
|
2518
2579
|
const size = Math.min(width, height);
|
|
2519
2580
|
const cx = size / 2;
|
|
2520
2581
|
const cy = size / 2;
|
|
@@ -2522,10 +2583,10 @@ var PieDonutChart = React5.memo(
|
|
|
2522
2583
|
const innerR = isDoughnut ? r2 * 0.5 : 0;
|
|
2523
2584
|
const firstKey = entries[0]?.[0] ?? "";
|
|
2524
2585
|
const colorOffset = hashString(firstKey);
|
|
2525
|
-
const maskRef =
|
|
2586
|
+
const maskRef = React6.useRef(null);
|
|
2526
2587
|
const maskR = r2 + 10;
|
|
2527
2588
|
const maskCircumference = 2 * Math.PI * maskR;
|
|
2528
|
-
|
|
2589
|
+
React6.useEffect(() => {
|
|
2529
2590
|
if (!animate || !maskRef.current) return;
|
|
2530
2591
|
const el = maskRef.current;
|
|
2531
2592
|
el.style.strokeDasharray = `${maskCircumference}`;
|
|
@@ -2535,7 +2596,7 @@ var PieDonutChart = React5.memo(
|
|
|
2535
2596
|
el.style.strokeDashoffset = "0";
|
|
2536
2597
|
});
|
|
2537
2598
|
}, [animate, maskCircumference]);
|
|
2538
|
-
const sliceData =
|
|
2599
|
+
const sliceData = React6.useMemo(() => {
|
|
2539
2600
|
let angle0 = -Math.PI / 2;
|
|
2540
2601
|
let cumulativeAngle = 0;
|
|
2541
2602
|
return values.map((v, i) => {
|
|
@@ -2570,7 +2631,7 @@ var PieDonutChart = React5.memo(
|
|
|
2570
2631
|
}, [values, total, cx, cy, r2, innerR, labels]);
|
|
2571
2632
|
const maskId = `pie-mask-${isDoughnut ? "d" : "p"}`;
|
|
2572
2633
|
return /* @__PURE__ */ jsxs196("svg", { viewBox: `0 0 ${size} ${size}`, className: "chart-svg chart-pie", children: [
|
|
2573
|
-
animate && /* @__PURE__ */
|
|
2634
|
+
animate && /* @__PURE__ */ jsx306("defs", { children: /* @__PURE__ */ jsx306("mask", { id: maskId, children: /* @__PURE__ */ jsx306(
|
|
2574
2635
|
"circle",
|
|
2575
2636
|
{
|
|
2576
2637
|
ref: maskRef,
|
|
@@ -2583,7 +2644,7 @@ var PieDonutChart = React5.memo(
|
|
|
2583
2644
|
transform: `rotate(-90 ${cx} ${cy})`
|
|
2584
2645
|
}
|
|
2585
2646
|
) }) }),
|
|
2586
|
-
/* @__PURE__ */
|
|
2647
|
+
/* @__PURE__ */ jsx306("g", { mask: animate ? `url(#${maskId})` : void 0, children: sliceData.map((s, i) => /* @__PURE__ */ jsx306("g", { children: /* @__PURE__ */ jsx306(
|
|
2587
2648
|
"path",
|
|
2588
2649
|
{
|
|
2589
2650
|
d: s.d,
|
|
@@ -2599,9 +2660,9 @@ var PieDonutChart = React5.memo(
|
|
|
2599
2660
|
);
|
|
2600
2661
|
PieDonutChart.displayName = "PieDonutChart";
|
|
2601
2662
|
var ChartTooltip = ({ x, y, containerWidth, containerHeight, tooltipType, children }) => {
|
|
2602
|
-
const ref =
|
|
2603
|
-
const [pos, setPos] =
|
|
2604
|
-
|
|
2663
|
+
const ref = React6.useRef(null);
|
|
2664
|
+
const [pos, setPos] = React6.useState({ left: 0, top: 0 });
|
|
2665
|
+
React6.useLayoutEffect(() => {
|
|
2605
2666
|
const el = ref.current;
|
|
2606
2667
|
if (!el) return;
|
|
2607
2668
|
const w = el.offsetWidth;
|
|
@@ -2625,8 +2686,8 @@ var ChartTooltip = ({ x, y, containerWidth, containerHeight, tooltipType, childr
|
|
|
2625
2686
|
className: `lib-xplat-tooltip ${tooltipType} chart-tooltip-pos`,
|
|
2626
2687
|
style: { left: pos.left, top: pos.top },
|
|
2627
2688
|
children: [
|
|
2628
|
-
title && /* @__PURE__ */
|
|
2629
|
-
desc && /* @__PURE__ */
|
|
2689
|
+
title && /* @__PURE__ */ jsx306("div", { className: "tooltip-title", children: title }),
|
|
2690
|
+
desc && /* @__PURE__ */ jsx306("div", { className: "tooltip-desc", children: desc })
|
|
2630
2691
|
]
|
|
2631
2692
|
}
|
|
2632
2693
|
);
|
|
@@ -2638,13 +2699,13 @@ var ChartLegend = ({ data, labels, type }) => {
|
|
|
2638
2699
|
const total = values.reduce((a, b) => a + b, 0) || 1;
|
|
2639
2700
|
const firstKey = entries[0]?.[0] ?? "";
|
|
2640
2701
|
const colorOffset = hashString(firstKey);
|
|
2641
|
-
return /* @__PURE__ */
|
|
2702
|
+
return /* @__PURE__ */ jsx306("div", { className: "chart-legend", children: values.map((v, i) => {
|
|
2642
2703
|
const pct = Math.round(v / total * 100);
|
|
2643
2704
|
const color = PIE_COLORS[(i + colorOffset) % PIE_COLORS.length];
|
|
2644
2705
|
return /* @__PURE__ */ jsxs196("div", { className: "chart-legend-item", children: [
|
|
2645
|
-
/* @__PURE__ */
|
|
2706
|
+
/* @__PURE__ */ jsx306("span", { className: "chart-legend-dot", style: { backgroundColor: color } }),
|
|
2646
2707
|
/* @__PURE__ */ jsxs196("div", { className: "chart-legend-text", children: [
|
|
2647
|
-
/* @__PURE__ */
|
|
2708
|
+
/* @__PURE__ */ jsx306("span", { className: "chart-legend-label", children: labels[i] || `${i + 1}` }),
|
|
2648
2709
|
/* @__PURE__ */ jsxs196("span", { className: "chart-legend-value", children: [
|
|
2649
2710
|
v.toLocaleString(),
|
|
2650
2711
|
"(",
|
|
@@ -2655,103 +2716,42 @@ var ChartLegend = ({ data, labels, type }) => {
|
|
|
2655
2716
|
] }, i);
|
|
2656
2717
|
}) });
|
|
2657
2718
|
}
|
|
2658
|
-
return /* @__PURE__ */
|
|
2719
|
+
return /* @__PURE__ */ jsx306("div", { className: "chart-legend", children: entries.map(([key], di) => {
|
|
2659
2720
|
const palette = getPalette(LINE_BAR_PALETTES, di, key);
|
|
2660
2721
|
const color = palette[2];
|
|
2661
2722
|
const values = entries[di][1];
|
|
2662
2723
|
const sum = values.reduce((a, b) => a + b, 0);
|
|
2663
2724
|
return /* @__PURE__ */ jsxs196("div", { className: "chart-legend-item", children: [
|
|
2664
|
-
/* @__PURE__ */
|
|
2725
|
+
/* @__PURE__ */ jsx306("span", { className: "chart-legend-dot", style: { backgroundColor: color } }),
|
|
2665
2726
|
/* @__PURE__ */ jsxs196("div", { className: "chart-legend-text", children: [
|
|
2666
|
-
/* @__PURE__ */
|
|
2667
|
-
/* @__PURE__ */
|
|
2727
|
+
/* @__PURE__ */ jsx306("span", { className: "chart-legend-label", children: key }),
|
|
2728
|
+
/* @__PURE__ */ jsx306("span", { className: "chart-legend-value", children: sum.toLocaleString() })
|
|
2668
2729
|
] })
|
|
2669
2730
|
] }, di);
|
|
2670
2731
|
}) });
|
|
2671
2732
|
};
|
|
2672
|
-
var Chart =
|
|
2733
|
+
var Chart = React6.memo((props) => {
|
|
2673
2734
|
const { type, data, labels, tooltip: showTooltip = true, tooltipType = "light" } = props;
|
|
2674
2735
|
const { tooltip, show, hide, move, containerRef } = useChartTooltip(showTooltip);
|
|
2675
2736
|
const { width, height } = useChartSize(containerRef);
|
|
2676
|
-
const stableData =
|
|
2677
|
-
const stableLabels =
|
|
2678
|
-
const dataKey =
|
|
2737
|
+
const stableData = React6.useMemo(() => data, [JSON.stringify(data)]);
|
|
2738
|
+
const stableLabels = React6.useMemo(() => labels, [JSON.stringify(labels)]);
|
|
2739
|
+
const dataKey = React6.useMemo(() => JSON.stringify(labels), [labels]);
|
|
2679
2740
|
const animate = useChartAnimation(containerRef, dataKey);
|
|
2680
2741
|
const ready = width > 0 && height > 0;
|
|
2681
2742
|
return /* @__PURE__ */ jsxs196("div", { className: "lib-xplat-chart", ref: containerRef, children: [
|
|
2682
|
-
ready && type === "line" && /* @__PURE__ */
|
|
2683
|
-
ready && type === "curve" && /* @__PURE__ */
|
|
2684
|
-
ready && type === "bar" && /* @__PURE__ */
|
|
2685
|
-
ready && type === "pie" && /* @__PURE__ */
|
|
2686
|
-
ready && type === "doughnut" && /* @__PURE__ */
|
|
2687
|
-
ready && (type === "pie" || type === "doughnut") && /* @__PURE__ */
|
|
2688
|
-
tooltip.visible && tooltip.content && /* @__PURE__ */
|
|
2743
|
+
ready && type === "line" && /* @__PURE__ */ jsx306(LineChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
|
|
2744
|
+
ready && type === "curve" && /* @__PURE__ */ jsx306(CurveChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
|
|
2745
|
+
ready && type === "bar" && /* @__PURE__ */ jsx306(BarChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
|
|
2746
|
+
ready && type === "pie" && /* @__PURE__ */ jsx306(PieDonutChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
|
|
2747
|
+
ready && type === "doughnut" && /* @__PURE__ */ jsx306(PieDonutChart, { data: stableData, labels: stableLabels, width, height, animate, isDoughnut: true, onHover: show, onMove: move, onLeave: hide }),
|
|
2748
|
+
ready && (type === "pie" || type === "doughnut") && /* @__PURE__ */ jsx306(ChartLegend, { data: stableData, labels: stableLabels, type }),
|
|
2749
|
+
tooltip.visible && tooltip.content && /* @__PURE__ */ jsx306(ChartTooltip, { x: tooltip.x, y: tooltip.y, containerWidth: width, containerHeight: height, tooltipType, children: tooltip.content })
|
|
2689
2750
|
] });
|
|
2690
2751
|
});
|
|
2691
2752
|
Chart.displayName = "Chart";
|
|
2692
2753
|
var Chart_default = Chart;
|
|
2693
2754
|
|
|
2694
|
-
// src/components/AutoResizeTextArea/AutoResizeTextArea.tsx
|
|
2695
|
-
import React6 from "react";
|
|
2696
|
-
import { jsx as jsx306 } from "react/jsx-runtime";
|
|
2697
|
-
var MAX_HEIGHT = 400;
|
|
2698
|
-
var AutoResizeTextArea = React6.forwardRef(
|
|
2699
|
-
(props, ref) => {
|
|
2700
|
-
const { value, className, onChange, disabled, bare = false, ...textareaProps } = props;
|
|
2701
|
-
const localRef = React6.useRef(null);
|
|
2702
|
-
const setRefs = (el) => {
|
|
2703
|
-
localRef.current = el;
|
|
2704
|
-
if (!ref) return;
|
|
2705
|
-
if (typeof ref === "function") ref(el);
|
|
2706
|
-
else if (ref && "current" in ref)
|
|
2707
|
-
ref.current = el;
|
|
2708
|
-
};
|
|
2709
|
-
const updateHeight = () => {
|
|
2710
|
-
const el = localRef.current;
|
|
2711
|
-
if (!el) return;
|
|
2712
|
-
el.style.height = "0px";
|
|
2713
|
-
el.style.height = `${Math.min(el.scrollHeight, MAX_HEIGHT)}px`;
|
|
2714
|
-
};
|
|
2715
|
-
const handleChange = (e) => {
|
|
2716
|
-
if (onChange) {
|
|
2717
|
-
const event = {
|
|
2718
|
-
...e,
|
|
2719
|
-
target: { value: e.target.value }
|
|
2720
|
-
};
|
|
2721
|
-
onChange(event);
|
|
2722
|
-
}
|
|
2723
|
-
};
|
|
2724
|
-
React6.useEffect(() => {
|
|
2725
|
-
updateHeight();
|
|
2726
|
-
}, [value]);
|
|
2727
|
-
if (bare) {
|
|
2728
|
-
return /* @__PURE__ */ jsx306(
|
|
2729
|
-
"textarea",
|
|
2730
|
-
{
|
|
2731
|
-
...textareaProps,
|
|
2732
|
-
ref: setRefs,
|
|
2733
|
-
className,
|
|
2734
|
-
disabled,
|
|
2735
|
-
value,
|
|
2736
|
-
onChange: handleChange
|
|
2737
|
-
}
|
|
2738
|
-
);
|
|
2739
|
-
}
|
|
2740
|
-
return /* @__PURE__ */ jsx306("div", { className: clsx_default("lib-xplat-auto-resize-textarea-wrapper", className), children: /* @__PURE__ */ jsx306("div", { className: clsx_default("lib-xplat-auto-resize-textarea", disabled && "disabled"), children: /* @__PURE__ */ jsx306(
|
|
2741
|
-
"textarea",
|
|
2742
|
-
{
|
|
2743
|
-
...textareaProps,
|
|
2744
|
-
ref: setRefs,
|
|
2745
|
-
disabled,
|
|
2746
|
-
value,
|
|
2747
|
-
onChange: handleChange
|
|
2748
|
-
}
|
|
2749
|
-
) }) });
|
|
2750
|
-
}
|
|
2751
|
-
);
|
|
2752
|
-
AutoResizeTextArea.displayName = "AutoResizeTextArea";
|
|
2753
|
-
var AutoResizeTextArea_default = AutoResizeTextArea;
|
|
2754
|
-
|
|
2755
2755
|
// src/components/ChatInput/ChatInput.tsx
|
|
2756
2756
|
import React7 from "react";
|
|
2757
2757
|
|
|
@@ -5276,12 +5276,12 @@ var Select_default = Select;
|
|
|
5276
5276
|
// src/components/Skeleton/Skeleton.tsx
|
|
5277
5277
|
import { jsx as jsx337 } from "react/jsx-runtime";
|
|
5278
5278
|
var SIZE_MAP = {
|
|
5279
|
-
xs: "var(--spacing-
|
|
5280
|
-
sm: "var(--spacing-
|
|
5281
|
-
md: "var(--spacing-
|
|
5282
|
-
lg: "var(--spacing-
|
|
5283
|
-
xl: "var(--spacing-
|
|
5284
|
-
"2xl": "var(--spacing-
|
|
5279
|
+
xs: "var(--spacing-space-1)",
|
|
5280
|
+
sm: "var(--spacing-space-2)",
|
|
5281
|
+
md: "var(--spacing-space-4)",
|
|
5282
|
+
lg: "var(--spacing-space-8)",
|
|
5283
|
+
xl: "var(--spacing-space-12)",
|
|
5284
|
+
"2xl": "var(--spacing-space-16)",
|
|
5285
5285
|
full: "100%"
|
|
5286
5286
|
};
|
|
5287
5287
|
var Skeleton = (props) => {
|