@geomak/ui 6.3.0 → 6.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +245 -193
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +45 -1
- package/dist/index.d.ts +45 -1
- package/dist/index.js +61 -10
- package/dist/index.js.map +1 -1
- package/dist/styles.css +10 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var chunk255PCZIW_cjs = require('./chunk-255PCZIW.cjs');
|
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
-
var
|
|
5
|
+
var React14 = require('react');
|
|
6
6
|
var reactDom = require('react-dom');
|
|
7
7
|
var AvatarPrimitive = require('@radix-ui/react-avatar');
|
|
8
8
|
var Dialog = require('@radix-ui/react-dialog');
|
|
@@ -39,7 +39,7 @@ function _interopNamespace(e) {
|
|
|
39
39
|
return Object.freeze(n);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
var
|
|
42
|
+
var React14__default = /*#__PURE__*/_interopDefault(React14);
|
|
43
43
|
var AvatarPrimitive__namespace = /*#__PURE__*/_interopNamespace(AvatarPrimitive);
|
|
44
44
|
var Dialog__namespace = /*#__PURE__*/_interopNamespace(Dialog);
|
|
45
45
|
var TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespace(TooltipPrimitive);
|
|
@@ -214,8 +214,8 @@ Icon.Copy = Copy;
|
|
|
214
214
|
Icon.CircleStack = CircleStack;
|
|
215
215
|
var icons_default = Icon;
|
|
216
216
|
function Portal({ children, target }) {
|
|
217
|
-
const [resolved, setResolved] =
|
|
218
|
-
|
|
217
|
+
const [resolved, setResolved] = React14.useState(null);
|
|
218
|
+
React14.useEffect(() => {
|
|
219
219
|
if (target === null) {
|
|
220
220
|
setResolved(null);
|
|
221
221
|
return;
|
|
@@ -648,7 +648,7 @@ function IconButton({
|
|
|
648
648
|
className = "",
|
|
649
649
|
style
|
|
650
650
|
}) {
|
|
651
|
-
const colorScheme =
|
|
651
|
+
const colorScheme = React14.useMemo(() => {
|
|
652
652
|
if (type === "primary") {
|
|
653
653
|
return "bg-accent text-accent-fg hover:bg-accent-hover";
|
|
654
654
|
}
|
|
@@ -960,9 +960,9 @@ function Tooltip({
|
|
|
960
960
|
] }) });
|
|
961
961
|
}
|
|
962
962
|
var TooltipProvider = TooltipPrimitive__namespace.Provider;
|
|
963
|
-
var TabsContext =
|
|
963
|
+
var TabsContext = React14.createContext(null);
|
|
964
964
|
function useTabsContext() {
|
|
965
|
-
const ctx =
|
|
965
|
+
const ctx = React14.useContext(TabsContext);
|
|
966
966
|
if (!ctx) throw new Error("Tabs.List / Tabs.Trigger / Tabs.Panel must be rendered inside <Tabs>.");
|
|
967
967
|
return ctx;
|
|
968
968
|
}
|
|
@@ -984,26 +984,26 @@ function Tabs({
|
|
|
984
984
|
children
|
|
985
985
|
}) {
|
|
986
986
|
const isControlled = value !== void 0;
|
|
987
|
-
const [internal, setInternal] =
|
|
987
|
+
const [internal, setInternal] = React14.useState(defaultValue);
|
|
988
988
|
const current = isControlled ? value : internal;
|
|
989
989
|
const reduced = !!framerMotion.useReducedMotion();
|
|
990
|
-
const indicatorId =
|
|
991
|
-
const select =
|
|
990
|
+
const indicatorId = React14.useId();
|
|
991
|
+
const select = React14.useCallback((next) => {
|
|
992
992
|
if (!isControlled) setInternal(next);
|
|
993
993
|
onValueChange?.(next);
|
|
994
994
|
}, [isControlled, onValueChange]);
|
|
995
|
-
const registry =
|
|
996
|
-
const orderRef =
|
|
997
|
-
const [, bump] =
|
|
998
|
-
const registerTab =
|
|
995
|
+
const registry = React14.useRef(/* @__PURE__ */ new Map());
|
|
996
|
+
const orderRef = React14.useRef(0);
|
|
997
|
+
const [, bump] = React14.useState(0);
|
|
998
|
+
const registerTab = React14.useCallback((val, meta) => {
|
|
999
999
|
const existing = registry.current.get(val);
|
|
1000
1000
|
registry.current.set(val, { ...meta, order: existing?.order ?? orderRef.current++ });
|
|
1001
1001
|
if (!existing) bump((v) => v + 1);
|
|
1002
1002
|
}, []);
|
|
1003
|
-
const unregisterTab =
|
|
1003
|
+
const unregisterTab = React14.useCallback((val) => {
|
|
1004
1004
|
if (registry.current.delete(val)) bump((v) => v + 1);
|
|
1005
1005
|
}, []);
|
|
1006
|
-
const getTabs =
|
|
1006
|
+
const getTabs = React14.useCallback(() => [...registry.current.entries()].sort((a, b) => a[1].order - b[1].order).map(([val, m]) => ({ value: val, label: m.label, icon: m.icon, disabled: m.disabled })), []);
|
|
1007
1007
|
return /* @__PURE__ */ jsxRuntime.jsx(TabsContext.Provider, { value: { value: current, variant, size, orientation, indicatorId, reduced, select, registerTab, unregisterTab, getTabs }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1008
1008
|
TabsPrimitive__namespace.Root,
|
|
1009
1009
|
{
|
|
@@ -1023,10 +1023,10 @@ function Tabs({
|
|
|
1023
1023
|
function TabsList({ children, "aria-label": ariaLabel, className = "" }) {
|
|
1024
1024
|
const { variant, orientation, reduced, value } = useTabsContext();
|
|
1025
1025
|
const horizontal = orientation === "horizontal";
|
|
1026
|
-
const scrollRef =
|
|
1027
|
-
const [edges, setEdges] =
|
|
1026
|
+
const scrollRef = React14.useRef(null);
|
|
1027
|
+
const [edges, setEdges] = React14.useState({ start: false, end: false });
|
|
1028
1028
|
const scrollable = variant !== "segmented";
|
|
1029
|
-
|
|
1029
|
+
React14.useLayoutEffect(() => {
|
|
1030
1030
|
const el = scrollRef.current;
|
|
1031
1031
|
if (!el || !scrollable) return;
|
|
1032
1032
|
const update = () => {
|
|
@@ -1051,13 +1051,13 @@ function TabsList({ children, "aria-label": ariaLabel, className = "" }) {
|
|
|
1051
1051
|
ro.disconnect();
|
|
1052
1052
|
};
|
|
1053
1053
|
}, [horizontal, scrollable, children]);
|
|
1054
|
-
const nudge =
|
|
1054
|
+
const nudge = React14.useCallback((dir) => {
|
|
1055
1055
|
const el = scrollRef.current;
|
|
1056
1056
|
if (!el) return;
|
|
1057
1057
|
const amount = (horizontal ? el.clientWidth : el.clientHeight) * 0.7 * dir;
|
|
1058
1058
|
el.scrollBy({ [horizontal ? "left" : "top"]: amount, behavior: reduced ? "auto" : "smooth" });
|
|
1059
1059
|
}, [horizontal, reduced]);
|
|
1060
|
-
|
|
1060
|
+
React14.useLayoutEffect(() => {
|
|
1061
1061
|
const el = scrollRef.current;
|
|
1062
1062
|
if (!el || !scrollable) return;
|
|
1063
1063
|
const active = el.querySelector("[role=tab][data-state=active]");
|
|
@@ -1115,9 +1115,9 @@ function Chevron({ side, orientation, onClick }) {
|
|
|
1115
1115
|
function OverflowMenu() {
|
|
1116
1116
|
const { getTabs, value, select, orientation } = useTabsContext();
|
|
1117
1117
|
const horizontal = orientation === "horizontal";
|
|
1118
|
-
const [open, setOpen] =
|
|
1119
|
-
const wrapRef =
|
|
1120
|
-
const timer =
|
|
1118
|
+
const [open, setOpen] = React14.useState(false);
|
|
1119
|
+
const wrapRef = React14.useRef(null);
|
|
1120
|
+
const timer = React14.useRef(null);
|
|
1121
1121
|
const openNow = () => {
|
|
1122
1122
|
if (timer.current) clearTimeout(timer.current);
|
|
1123
1123
|
setOpen(true);
|
|
@@ -1125,7 +1125,7 @@ function OverflowMenu() {
|
|
|
1125
1125
|
const closeSoon = () => {
|
|
1126
1126
|
timer.current = setTimeout(() => setOpen(false), 160);
|
|
1127
1127
|
};
|
|
1128
|
-
|
|
1128
|
+
React14.useLayoutEffect(() => {
|
|
1129
1129
|
if (!open) return;
|
|
1130
1130
|
const onDoc = (e) => {
|
|
1131
1131
|
if (wrapRef.current && !wrapRef.current.contains(e.target)) setOpen(false);
|
|
@@ -1206,7 +1206,7 @@ function TabsTrigger({ value, icon, badge, closeable, onClose, disabled, classNa
|
|
|
1206
1206
|
const isActive = active === value;
|
|
1207
1207
|
const horizontal = orientation === "horizontal";
|
|
1208
1208
|
const sz = SIZE[size];
|
|
1209
|
-
|
|
1209
|
+
React14.useLayoutEffect(() => {
|
|
1210
1210
|
registerTab(value, { label: children, icon, disabled });
|
|
1211
1211
|
return () => unregisterTab(value);
|
|
1212
1212
|
}, [value, children, icon, disabled, registerTab, unregisterTab]);
|
|
@@ -1404,7 +1404,7 @@ function Tree({
|
|
|
1404
1404
|
item.key
|
|
1405
1405
|
)) });
|
|
1406
1406
|
}
|
|
1407
|
-
var AccordionCtx =
|
|
1407
|
+
var AccordionCtx = React14.createContext({ variant: "separated" });
|
|
1408
1408
|
function Accordion2({
|
|
1409
1409
|
children,
|
|
1410
1410
|
type = "single",
|
|
@@ -1463,7 +1463,7 @@ var Chevron2 = /* @__PURE__ */ jsxRuntime.jsx(
|
|
|
1463
1463
|
}
|
|
1464
1464
|
);
|
|
1465
1465
|
function AccordionItem({ value, title, icon, children, disabled, className = "" }) {
|
|
1466
|
-
const { variant } =
|
|
1466
|
+
const { variant } = React14.useContext(AccordionCtx);
|
|
1467
1467
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1468
1468
|
AccordionPrimitive__namespace.Item,
|
|
1469
1469
|
{
|
|
@@ -1499,7 +1499,58 @@ function AccordionItem({ value, title, icon, children, disabled, className = ""
|
|
|
1499
1499
|
}
|
|
1500
1500
|
Accordion2.Item = AccordionItem;
|
|
1501
1501
|
var Accordion_default = Accordion2;
|
|
1502
|
-
var
|
|
1502
|
+
var DefaultSeparator = /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, "aria-hidden": "true", className: "h-3.5 w-3.5 text-foreground-muted", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M9 5l7 7-7 7" }) });
|
|
1503
|
+
var crumbBase = "inline-flex items-center gap-1.5 rounded px-1 -mx-1 text-sm transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-accent";
|
|
1504
|
+
function Crumb({ item, current }) {
|
|
1505
|
+
const inner = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1506
|
+
item.icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex h-4 w-4 flex-shrink-0 items-center justify-center", children: item.icon }),
|
|
1507
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: item.label })
|
|
1508
|
+
] });
|
|
1509
|
+
if (current) {
|
|
1510
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-current": "page", className: `${crumbBase} font-medium text-foreground max-w-[16rem]`, children: inner });
|
|
1511
|
+
}
|
|
1512
|
+
if (item.href || item.onClick) {
|
|
1513
|
+
return /* @__PURE__ */ jsxRuntime.jsx("a", { href: item.href, onClick: item.onClick, className: `${crumbBase} text-foreground-secondary hover:text-foreground max-w-[12rem]`, children: inner });
|
|
1514
|
+
}
|
|
1515
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: `${crumbBase} text-foreground-secondary max-w-[12rem]`, children: inner });
|
|
1516
|
+
}
|
|
1517
|
+
function Breadcrumbs({
|
|
1518
|
+
items,
|
|
1519
|
+
separator = DefaultSeparator,
|
|
1520
|
+
maxItems = 0,
|
|
1521
|
+
"aria-label": ariaLabel = "Breadcrumb",
|
|
1522
|
+
className = "",
|
|
1523
|
+
style
|
|
1524
|
+
}) {
|
|
1525
|
+
const [expanded, setExpanded] = React14.useState(false);
|
|
1526
|
+
const shouldCollapse = maxItems > 0 && items.length > maxItems && !expanded;
|
|
1527
|
+
const visible = [];
|
|
1528
|
+
if (shouldCollapse) {
|
|
1529
|
+
const tailCount = Math.max(1, maxItems - 1);
|
|
1530
|
+
visible.push({ item: items[0], index: 0 });
|
|
1531
|
+
visible.push("ellipsis");
|
|
1532
|
+
for (let i = items.length - tailCount; i < items.length; i++) visible.push({ item: items[i], index: i });
|
|
1533
|
+
} else {
|
|
1534
|
+
items.forEach((item, index) => visible.push({ item, index }));
|
|
1535
|
+
}
|
|
1536
|
+
return /* @__PURE__ */ jsxRuntime.jsx("nav", { "aria-label": ariaLabel, className: ["min-w-0", className].filter(Boolean).join(" "), style, children: /* @__PURE__ */ jsxRuntime.jsx("ol", { className: "flex items-center gap-1.5 flex-nowrap min-w-0", children: visible.map((entry, i) => {
|
|
1537
|
+
const isLast = i === visible.length - 1;
|
|
1538
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "flex items-center gap-1.5 min-w-0", children: [
|
|
1539
|
+
entry === "ellipsis" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1540
|
+
"button",
|
|
1541
|
+
{
|
|
1542
|
+
type: "button",
|
|
1543
|
+
onClick: () => setExpanded(true),
|
|
1544
|
+
"aria-label": "Show hidden breadcrumbs",
|
|
1545
|
+
className: "inline-flex h-6 items-center rounded px-1.5 text-sm text-foreground-secondary hover:bg-surface-raised hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-accent",
|
|
1546
|
+
children: "\u2026"
|
|
1547
|
+
}
|
|
1548
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(Crumb, { item: entry.item, current: entry.index === items.length - 1 }),
|
|
1549
|
+
!isLast && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-shrink-0", children: separator })
|
|
1550
|
+
] }, entry === "ellipsis" ? "ellipsis" : entry.index);
|
|
1551
|
+
}) }) });
|
|
1552
|
+
}
|
|
1553
|
+
var NotificationContext = React14.createContext({
|
|
1503
1554
|
open: () => void 0,
|
|
1504
1555
|
close: () => void 0
|
|
1505
1556
|
});
|
|
@@ -1557,26 +1608,26 @@ function NotificationItem({
|
|
|
1557
1608
|
onClose,
|
|
1558
1609
|
reduced
|
|
1559
1610
|
}) {
|
|
1560
|
-
const [paused, setPaused] =
|
|
1611
|
+
const [paused, setPaused] = React14.useState(false);
|
|
1561
1612
|
const duration = n.duration ?? 4e3;
|
|
1562
1613
|
const isAutoDismissing = isFinite(duration) && duration > 0;
|
|
1563
1614
|
const showProgress = !reduced && isAutoDismissing;
|
|
1564
|
-
const timerRef =
|
|
1565
|
-
const startTimeRef =
|
|
1566
|
-
const remainingRef =
|
|
1567
|
-
const clearTimer =
|
|
1615
|
+
const timerRef = React14.useRef(null);
|
|
1616
|
+
const startTimeRef = React14.useRef(0);
|
|
1617
|
+
const remainingRef = React14.useRef(duration);
|
|
1618
|
+
const clearTimer = React14.useCallback(() => {
|
|
1568
1619
|
if (timerRef.current !== null) {
|
|
1569
1620
|
clearTimeout(timerRef.current);
|
|
1570
1621
|
timerRef.current = null;
|
|
1571
1622
|
}
|
|
1572
1623
|
}, []);
|
|
1573
|
-
const scheduleDismiss =
|
|
1624
|
+
const scheduleDismiss = React14.useCallback((ms) => {
|
|
1574
1625
|
clearTimer();
|
|
1575
1626
|
if (!isAutoDismissing) return;
|
|
1576
1627
|
startTimeRef.current = Date.now();
|
|
1577
1628
|
timerRef.current = setTimeout(() => onClose(n.id), ms);
|
|
1578
1629
|
}, [clearTimer, isAutoDismissing, n.id, onClose]);
|
|
1579
|
-
|
|
1630
|
+
React14.useEffect(() => {
|
|
1580
1631
|
if (paused || !isAutoDismissing) return;
|
|
1581
1632
|
scheduleDismiss(remainingRef.current);
|
|
1582
1633
|
return clearTimer;
|
|
@@ -1659,15 +1710,15 @@ function NotificationProvider({
|
|
|
1659
1710
|
children,
|
|
1660
1711
|
position = "top-right"
|
|
1661
1712
|
}) {
|
|
1662
|
-
const [notifications, setNotifications] =
|
|
1713
|
+
const [notifications, setNotifications] = React14.useState([]);
|
|
1663
1714
|
const reduced = framerMotion.useReducedMotion();
|
|
1664
|
-
const open =
|
|
1715
|
+
const open = React14.useCallback((payload) => {
|
|
1665
1716
|
setNotifications((prev) => [
|
|
1666
1717
|
...prev,
|
|
1667
1718
|
{ duration: 4e3, ...payload, id: Date.now() + Math.random() }
|
|
1668
1719
|
]);
|
|
1669
1720
|
}, []);
|
|
1670
|
-
const close =
|
|
1721
|
+
const close = React14.useCallback((id) => {
|
|
1671
1722
|
setNotifications((prev) => prev.filter((n) => n.id !== id));
|
|
1672
1723
|
}, []);
|
|
1673
1724
|
return /* @__PURE__ */ jsxRuntime.jsxs(NotificationContext.Provider, { value: { open, close }, children: [
|
|
@@ -1696,7 +1747,7 @@ function NotificationProvider({
|
|
|
1696
1747
|
] });
|
|
1697
1748
|
}
|
|
1698
1749
|
function useNotification() {
|
|
1699
|
-
const { open } =
|
|
1750
|
+
const { open } = React14.useContext(NotificationContext);
|
|
1700
1751
|
return {
|
|
1701
1752
|
info: (props) => open({ type: "info", ...props }),
|
|
1702
1753
|
success: (props) => open({ type: "success", ...props }),
|
|
@@ -1813,10 +1864,10 @@ function FadingBase({
|
|
|
1813
1864
|
isMounted = false,
|
|
1814
1865
|
children
|
|
1815
1866
|
}) {
|
|
1816
|
-
const [shouldRender, setShouldRender] =
|
|
1817
|
-
const [visible, setVisible] =
|
|
1818
|
-
const timerRef =
|
|
1819
|
-
|
|
1867
|
+
const [shouldRender, setShouldRender] = React14.useState(isMounted);
|
|
1868
|
+
const [visible, setVisible] = React14.useState(false);
|
|
1869
|
+
const timerRef = React14.useRef(null);
|
|
1870
|
+
React14.useEffect(() => {
|
|
1820
1871
|
if (isMounted) {
|
|
1821
1872
|
setShouldRender(true);
|
|
1822
1873
|
const rafId = requestAnimationFrame(() => setVisible(true));
|
|
@@ -1914,8 +1965,8 @@ function ScalableContainer({
|
|
|
1914
1965
|
togglePosition = "top-right",
|
|
1915
1966
|
className = ""
|
|
1916
1967
|
}) {
|
|
1917
|
-
const containerRef =
|
|
1918
|
-
const [internalScaled, setInternalScaled] =
|
|
1968
|
+
const containerRef = React14.useRef(null);
|
|
1969
|
+
const [internalScaled, setInternalScaled] = React14.useState(false);
|
|
1919
1970
|
const isScaled = expanded ?? internalScaled;
|
|
1920
1971
|
const reduced = framerMotion.useReducedMotion();
|
|
1921
1972
|
const onToggle = () => {
|
|
@@ -2053,17 +2104,17 @@ function CatalogGrid({ items, buttonText, onOpen, className = "" }) {
|
|
|
2053
2104
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `flex flex-wrap gap-2 ${className}`.trim(), children: items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(GridCard, { item, buttonText, onOpen }, item.key)) });
|
|
2054
2105
|
}
|
|
2055
2106
|
function CatalogCarousel({ items, buttonText, onOpen, className = "" }) {
|
|
2056
|
-
const [activeIndex, setActiveIndex] =
|
|
2057
|
-
const [indexPool, setIndexPool] =
|
|
2058
|
-
const cardRefs =
|
|
2059
|
-
const getIndexes =
|
|
2107
|
+
const [activeIndex, setActiveIndex] = React14.useState(0);
|
|
2108
|
+
const [indexPool, setIndexPool] = React14.useState([]);
|
|
2109
|
+
const cardRefs = React14.useRef([]);
|
|
2110
|
+
const getIndexes = React14.useMemo(() => {
|
|
2060
2111
|
let nextIndex = activeIndex + 1;
|
|
2061
2112
|
let previousIndex = activeIndex - 1;
|
|
2062
2113
|
if (activeIndex === 0) previousIndex = items.length - 1;
|
|
2063
2114
|
if (activeIndex === items.length - 1) nextIndex = 0;
|
|
2064
2115
|
return { previousIndex, nextIndex };
|
|
2065
2116
|
}, [activeIndex, items.length]);
|
|
2066
|
-
|
|
2117
|
+
React14.useEffect(() => {
|
|
2067
2118
|
const { nextIndex, previousIndex } = getIndexes;
|
|
2068
2119
|
let indexes = [previousIndex, activeIndex, nextIndex];
|
|
2069
2120
|
if (activeIndex !== 0 && activeIndex !== items.length - 1) {
|
|
@@ -2236,8 +2287,8 @@ function writeDismissed(key) {
|
|
|
2236
2287
|
}
|
|
2237
2288
|
}
|
|
2238
2289
|
function useTargetBbox(ref) {
|
|
2239
|
-
const [bbox, setBbox] =
|
|
2240
|
-
|
|
2290
|
+
const [bbox, setBbox] = React14.useState(null);
|
|
2291
|
+
React14.useLayoutEffect(() => {
|
|
2241
2292
|
const el = ref?.current;
|
|
2242
2293
|
if (!el) {
|
|
2243
2294
|
setBbox(null);
|
|
@@ -2267,7 +2318,7 @@ function tooltipStyleFor(bbox, placement) {
|
|
|
2267
2318
|
return { left: bbox.left + bbox.width / 2, top: bbox.top - TOOLTIP_GAP, transform: "translate(-50%, -100%)", width: TOOLTIP_WIDTH };
|
|
2268
2319
|
}
|
|
2269
2320
|
function useFocusTrap(containerRef, active) {
|
|
2270
|
-
|
|
2321
|
+
React14.useEffect(() => {
|
|
2271
2322
|
if (!active) return;
|
|
2272
2323
|
const el = containerRef.current;
|
|
2273
2324
|
if (!el) return;
|
|
@@ -2306,16 +2357,16 @@ function Wizard({
|
|
|
2306
2357
|
onComplete,
|
|
2307
2358
|
onSkip
|
|
2308
2359
|
}) {
|
|
2309
|
-
const tooltipRef =
|
|
2310
|
-
const tooltipTitleId =
|
|
2311
|
-
const tooltipBodyId =
|
|
2360
|
+
const tooltipRef = React14.useRef(null);
|
|
2361
|
+
const tooltipTitleId = React14.useId();
|
|
2362
|
+
const tooltipBodyId = React14.useId();
|
|
2312
2363
|
const reduced = framerMotion.useReducedMotion();
|
|
2313
|
-
const [open, setOpen] =
|
|
2314
|
-
const [activeIndex, setActiveIndex] =
|
|
2364
|
+
const [open, setOpen] = React14.useState(() => steps.length > 0 && !readDismissed(storageKey));
|
|
2365
|
+
const [activeIndex, setActiveIndex] = React14.useState(0);
|
|
2315
2366
|
const step = steps[activeIndex];
|
|
2316
2367
|
const bbox = useTargetBbox(step?.stepRef);
|
|
2317
2368
|
useFocusTrap(tooltipRef, open);
|
|
2318
|
-
|
|
2369
|
+
React14.useEffect(() => {
|
|
2319
2370
|
if (!open || !dismissible) return;
|
|
2320
2371
|
const onKey = (e) => {
|
|
2321
2372
|
if (e.key === "Escape") {
|
|
@@ -2326,12 +2377,12 @@ function Wizard({
|
|
|
2326
2377
|
document.addEventListener("keydown", onKey);
|
|
2327
2378
|
return () => document.removeEventListener("keydown", onKey);
|
|
2328
2379
|
}, [open, dismissible]);
|
|
2329
|
-
const handleSkip =
|
|
2380
|
+
const handleSkip = React14.useCallback(() => {
|
|
2330
2381
|
writeDismissed(storageKey);
|
|
2331
2382
|
setOpen(false);
|
|
2332
2383
|
onSkip?.();
|
|
2333
2384
|
}, [storageKey, onSkip]);
|
|
2334
|
-
const handleComplete =
|
|
2385
|
+
const handleComplete = React14.useCallback(() => {
|
|
2335
2386
|
writeDismissed(storageKey);
|
|
2336
2387
|
setOpen(false);
|
|
2337
2388
|
onComplete?.();
|
|
@@ -2602,7 +2653,7 @@ function Field({
|
|
|
2602
2653
|
);
|
|
2603
2654
|
}
|
|
2604
2655
|
var SearchIcon = /* @__PURE__ */ jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", className: "w-4 h-4", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx("path", { fillRule: "evenodd", d: "M10.5 3.75a6.75 6.75 0 100 13.5 6.75 6.75 0 000-13.5zM2.25 10.5a8.25 8.25 0 1114.59 5.28l4.69 4.69a.75.75 0 11-1.06 1.06l-4.69-4.69A8.25 8.25 0 012.25 10.5z", clipRule: "evenodd" }) });
|
|
2605
|
-
var SearchInput =
|
|
2656
|
+
var SearchInput = React14__default.default.forwardRef(function SearchInput2({ value, onChange, disabled, label, htmlFor, placeholder, name, inputStyle, style, layout = "vertical", size = "md", icon, helperText, className }, ref) {
|
|
2606
2657
|
return /* @__PURE__ */ jsxRuntime.jsx(Field, { className, label, htmlFor, layout, helperText, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2607
2658
|
"div",
|
|
2608
2659
|
{
|
|
@@ -2656,11 +2707,11 @@ function MultiTagRow({
|
|
|
2656
2707
|
labelFor,
|
|
2657
2708
|
onRemove
|
|
2658
2709
|
}) {
|
|
2659
|
-
const wrapRef =
|
|
2660
|
-
const measureRef =
|
|
2661
|
-
const [visibleCount, setVisibleCount] =
|
|
2710
|
+
const wrapRef = React14.useRef(null);
|
|
2711
|
+
const measureRef = React14.useRef(null);
|
|
2712
|
+
const [visibleCount, setVisibleCount] = React14.useState(values.length);
|
|
2662
2713
|
const key = values.map(String).join("|");
|
|
2663
|
-
|
|
2714
|
+
React14.useLayoutEffect(() => {
|
|
2664
2715
|
const wrap = wrapRef.current;
|
|
2665
2716
|
const measure = measureRef.current;
|
|
2666
2717
|
if (!wrap || !measure) return;
|
|
@@ -2754,16 +2805,16 @@ function Dropdown({
|
|
|
2754
2805
|
size = "md",
|
|
2755
2806
|
className = ""
|
|
2756
2807
|
}) {
|
|
2757
|
-
const [open, setOpen] =
|
|
2758
|
-
const [selectedItems, setSelectedItems] =
|
|
2759
|
-
const [searchTerm, setSearchTerm] =
|
|
2760
|
-
const [innerItems, setInnerItems] =
|
|
2761
|
-
const errorId =
|
|
2808
|
+
const [open, setOpen] = React14.useState(false);
|
|
2809
|
+
const [selectedItems, setSelectedItems] = React14.useState([]);
|
|
2810
|
+
const [searchTerm, setSearchTerm] = React14.useState("");
|
|
2811
|
+
const [innerItems, setInnerItems] = React14.useState([]);
|
|
2812
|
+
const errorId = React14.useId();
|
|
2762
2813
|
const hasError = errorMessage != null;
|
|
2763
|
-
|
|
2814
|
+
React14.useEffect(() => {
|
|
2764
2815
|
setInnerItems(items);
|
|
2765
2816
|
}, [items]);
|
|
2766
|
-
|
|
2817
|
+
React14.useEffect(() => {
|
|
2767
2818
|
if (isMultiselect && Array.isArray(value)) {
|
|
2768
2819
|
setSelectedItems(value);
|
|
2769
2820
|
}
|
|
@@ -3088,7 +3139,7 @@ function TableBody({
|
|
|
3088
3139
|
expandRow,
|
|
3089
3140
|
getRowKey
|
|
3090
3141
|
}) {
|
|
3091
|
-
const [expanded, setExpanded] =
|
|
3142
|
+
const [expanded, setExpanded] = React14.useState(() => /* @__PURE__ */ new Set());
|
|
3092
3143
|
const reduced = framerMotion.useReducedMotion();
|
|
3093
3144
|
const toggleRow = (rowKey) => {
|
|
3094
3145
|
setExpanded((prev) => {
|
|
@@ -3103,7 +3154,7 @@ function TableBody({
|
|
|
3103
3154
|
return /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: rows.map((row, i) => {
|
|
3104
3155
|
const rowKey = getRowKey(row, i);
|
|
3105
3156
|
const isExpanded = expanded.has(rowKey);
|
|
3106
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3157
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(React14__default.default.Fragment, { children: [
|
|
3107
3158
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3108
3159
|
"tr",
|
|
3109
3160
|
{
|
|
@@ -3159,9 +3210,9 @@ function Pagination({
|
|
|
3159
3210
|
const matchedOption = picker.find(
|
|
3160
3211
|
(o) => o.label === options.perPage || o.value === options.perPage
|
|
3161
3212
|
);
|
|
3162
|
-
const [perPageKey, setPerPageKey] =
|
|
3213
|
+
const [perPageKey, setPerPageKey] = React14.useState(() => matchedOption?.key ?? picker[0]?.key);
|
|
3163
3214
|
const displayPerPageKey = serverSide ? matchedOption?.key ?? perPageKey : perPageKey;
|
|
3164
|
-
|
|
3215
|
+
React14.useEffect(() => {
|
|
3165
3216
|
if (serverSide && options.perPage != null) {
|
|
3166
3217
|
const next = picker.find((o) => o.label === options.perPage || o.value === options.perPage);
|
|
3167
3218
|
if (next) setPerPageKey(next.key);
|
|
@@ -3225,14 +3276,14 @@ function Table({
|
|
|
3225
3276
|
className = "",
|
|
3226
3277
|
style
|
|
3227
3278
|
}) {
|
|
3228
|
-
const searchRef =
|
|
3229
|
-
const [searchTerm, setSearchTerm] =
|
|
3230
|
-
const [perPage, setPerPage] =
|
|
3279
|
+
const searchRef = React14.useRef(null);
|
|
3280
|
+
const [searchTerm, setSearchTerm] = React14.useState("");
|
|
3281
|
+
const [perPage, setPerPage] = React14.useState(
|
|
3231
3282
|
typeof pagination.perPage === "number" ? pagination.perPage : 15
|
|
3232
3283
|
);
|
|
3233
|
-
const [activePage, setActivePage] =
|
|
3284
|
+
const [activePage, setActivePage] = React14.useState(0);
|
|
3234
3285
|
const isServerSide = !!(pagination.enabled && pagination.serverSide);
|
|
3235
|
-
const filteredRows =
|
|
3286
|
+
const filteredRows = React14.useMemo(() => {
|
|
3236
3287
|
if (isServerSide || !searchTerm) return rows;
|
|
3237
3288
|
const term = searchTerm.toLowerCase();
|
|
3238
3289
|
return rows.filter(
|
|
@@ -3241,29 +3292,29 @@ function Table({
|
|
|
3241
3292
|
)
|
|
3242
3293
|
);
|
|
3243
3294
|
}, [rows, searchTerm, isServerSide]);
|
|
3244
|
-
const datasets =
|
|
3295
|
+
const datasets = React14.useMemo(() => {
|
|
3245
3296
|
if (isServerSide) return [rows];
|
|
3246
3297
|
return createDatasets(filteredRows, pagination.enabled ? perPage : null);
|
|
3247
3298
|
}, [filteredRows, perPage, pagination.enabled, isServerSide, rows]);
|
|
3248
|
-
const MAX_PAGE =
|
|
3299
|
+
const MAX_PAGE = React14.useMemo(() => {
|
|
3249
3300
|
if (isServerSide && typeof pagination.maxPage === "number") return Math.max(0, pagination.maxPage);
|
|
3250
3301
|
if (isServerSide && typeof pagination.totalCount === "number")
|
|
3251
3302
|
return Math.max(0, Math.ceil(pagination.totalCount / perPage) - 1);
|
|
3252
3303
|
return datasets.length ? datasets.length - 1 : 0;
|
|
3253
3304
|
}, [isServerSide, pagination.maxPage, pagination.totalCount, perPage, datasets.length]);
|
|
3254
|
-
const currentPageRows =
|
|
3305
|
+
const currentPageRows = React14.useMemo(() => {
|
|
3255
3306
|
if (isServerSide) return rows;
|
|
3256
3307
|
return datasets[activePage] ?? [];
|
|
3257
3308
|
}, [isServerSide, rows, datasets, activePage]);
|
|
3258
|
-
|
|
3309
|
+
React14.useEffect(() => {
|
|
3259
3310
|
if (pagination.enabled && !isServerSide && typeof pagination.perPage === "number") {
|
|
3260
3311
|
setPerPage(pagination.perPage);
|
|
3261
3312
|
}
|
|
3262
3313
|
}, [pagination.enabled, pagination.perPage, isServerSide]);
|
|
3263
|
-
|
|
3314
|
+
React14.useEffect(() => {
|
|
3264
3315
|
if (isServerSide && typeof pagination.perPage === "number") setPerPage(pagination.perPage);
|
|
3265
3316
|
}, [isServerSide, pagination.perPage]);
|
|
3266
|
-
|
|
3317
|
+
React14.useEffect(() => {
|
|
3267
3318
|
if (isServerSide && typeof pagination.page === "number" && pagination.page >= 1)
|
|
3268
3319
|
setActivePage(pagination.page - 1);
|
|
3269
3320
|
}, [isServerSide, pagination.page]);
|
|
@@ -3347,7 +3398,7 @@ function TableSkeletonBody({
|
|
|
3347
3398
|
)) });
|
|
3348
3399
|
}
|
|
3349
3400
|
function ThemeSwitch({ checked, onChange, label = "Toggle dark mode", className = "" }) {
|
|
3350
|
-
const id =
|
|
3401
|
+
const id = React14.useId();
|
|
3351
3402
|
return /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: id, className: `flex items-center gap-2 cursor-pointer select-none ${className}`.trim(), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3352
3403
|
SwitchPrimitive__namespace.Root,
|
|
3353
3404
|
{
|
|
@@ -3531,7 +3582,7 @@ function Sidebar({
|
|
|
3531
3582
|
}
|
|
3532
3583
|
) });
|
|
3533
3584
|
}
|
|
3534
|
-
var MegaMenuContext =
|
|
3585
|
+
var MegaMenuContext = React14.createContext({ align: "start" });
|
|
3535
3586
|
function MegaMenu({
|
|
3536
3587
|
children,
|
|
3537
3588
|
align = "start",
|
|
@@ -3562,7 +3613,7 @@ function MegaMenu({
|
|
|
3562
3613
|
}
|
|
3563
3614
|
var TOP_ITEM = "group/top inline-flex items-center gap-1.5 h-10 px-3 rounded-md text-sm font-medium select-none text-foreground-secondary hover:text-foreground hover:bg-surface-raised data-[state=open]:text-accent data-[active]:text-accent transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-accent";
|
|
3564
3615
|
function MegaMenuItem({ label, icon, href, children, className = "" }) {
|
|
3565
|
-
const { align } =
|
|
3616
|
+
const { align } = React14.useContext(MegaMenuContext);
|
|
3566
3617
|
const pos = align === "center" ? "left-1/2 -translate-x-1/2" : align === "end" ? "right-0" : "left-0";
|
|
3567
3618
|
if (!children) {
|
|
3568
3619
|
return /* @__PURE__ */ jsxRuntime.jsx(NavigationMenu__namespace.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs(NavigationMenu__namespace.Link, { href, className: [TOP_ITEM, className].filter(Boolean).join(" "), children: [
|
|
@@ -3647,8 +3698,8 @@ function MegaMenuLink({ href, icon, description, active, onClick, children, clas
|
|
|
3647
3698
|
function MegaMenuFeatured({ children, className = "" }) {
|
|
3648
3699
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: ["min-w-0 rounded-lg bg-surface-raised border border-border p-4 flex flex-col", className].filter(Boolean).join(" "), children });
|
|
3649
3700
|
}
|
|
3650
|
-
var elementsOfType = (children, type) =>
|
|
3651
|
-
(c) =>
|
|
3701
|
+
var elementsOfType = (children, type) => React14__default.default.Children.toArray(children).filter(
|
|
3702
|
+
(c) => React14__default.default.isValidElement(c) && c.type === type
|
|
3652
3703
|
);
|
|
3653
3704
|
var MOBILE_CHEVRON = /* @__PURE__ */ jsxRuntime.jsx(
|
|
3654
3705
|
"svg",
|
|
@@ -3685,9 +3736,9 @@ function MobileLinkRow({ link, onNavigate }) {
|
|
|
3685
3736
|
);
|
|
3686
3737
|
}
|
|
3687
3738
|
function MobilePanel({ panel, onNavigate }) {
|
|
3688
|
-
const nodes =
|
|
3739
|
+
const nodes = React14__default.default.Children.toArray(panel.props.children);
|
|
3689
3740
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-4 px-2 pb-3 pt-1", children: nodes.map((node, i) => {
|
|
3690
|
-
if (!
|
|
3741
|
+
if (!React14__default.default.isValidElement(node)) return null;
|
|
3691
3742
|
const el = node;
|
|
3692
3743
|
if (el.type === MegaMenuSection) {
|
|
3693
3744
|
const { title, children } = el.props;
|
|
@@ -3706,8 +3757,8 @@ function MegaMenuMobile({
|
|
|
3706
3757
|
children,
|
|
3707
3758
|
label
|
|
3708
3759
|
}) {
|
|
3709
|
-
const [open, setOpen] =
|
|
3710
|
-
const [expanded, setExpanded] =
|
|
3760
|
+
const [open, setOpen] = React14.useState(false);
|
|
3761
|
+
const [expanded, setExpanded] = React14.useState(null);
|
|
3711
3762
|
const items = elementsOfType(children, MegaMenuItem);
|
|
3712
3763
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "md:hidden w-full", children: [
|
|
3713
3764
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -3780,17 +3831,17 @@ function AppShell({
|
|
|
3780
3831
|
children,
|
|
3781
3832
|
className = ""
|
|
3782
3833
|
}) {
|
|
3783
|
-
const [expanded, setExpanded] =
|
|
3784
|
-
const [isMobile, setIsMobile] =
|
|
3785
|
-
const [mobileOpen, setMobileOpen] =
|
|
3786
|
-
|
|
3834
|
+
const [expanded, setExpanded] = React14.useState(sidebarDefaultExpanded);
|
|
3835
|
+
const [isMobile, setIsMobile] = React14.useState(false);
|
|
3836
|
+
const [mobileOpen, setMobileOpen] = React14.useState(false);
|
|
3837
|
+
React14.useEffect(() => {
|
|
3787
3838
|
const mq = window.matchMedia("(max-width: 767px)");
|
|
3788
3839
|
const update = (e) => setIsMobile(e.matches);
|
|
3789
3840
|
update(mq);
|
|
3790
3841
|
mq.addEventListener("change", update);
|
|
3791
3842
|
return () => mq.removeEventListener("change", update);
|
|
3792
3843
|
}, []);
|
|
3793
|
-
|
|
3844
|
+
React14.useEffect(() => {
|
|
3794
3845
|
if (!isMobile) setMobileOpen(false);
|
|
3795
3846
|
}, [isMobile]);
|
|
3796
3847
|
const hasSidebar = sidebarSections.length > 0;
|
|
@@ -3980,10 +4031,10 @@ function ThemeProvider({
|
|
|
3980
4031
|
className = "",
|
|
3981
4032
|
style
|
|
3982
4033
|
}) {
|
|
3983
|
-
const id =
|
|
4034
|
+
const id = React14__default.default.useId().replace(/:/g, "");
|
|
3984
4035
|
const scopeClass = `geo-th-${id}`;
|
|
3985
|
-
const divRef =
|
|
3986
|
-
|
|
4036
|
+
const divRef = React14.useRef(null);
|
|
4037
|
+
React14.useEffect(() => {
|
|
3987
4038
|
const el = divRef.current;
|
|
3988
4039
|
if (!el) return;
|
|
3989
4040
|
if (colorScheme === "auto") return;
|
|
@@ -3998,8 +4049,8 @@ function ThemeProvider({
|
|
|
3998
4049
|
}
|
|
3999
4050
|
el.classList.toggle("dark", colorScheme === "dark");
|
|
4000
4051
|
}, [colorScheme]);
|
|
4001
|
-
const lightVars =
|
|
4002
|
-
const darkVarStr =
|
|
4052
|
+
const lightVars = React14.useMemo(() => toCssVars(theme), [theme]);
|
|
4053
|
+
const darkVarStr = React14.useMemo(() => {
|
|
4003
4054
|
if (!darkTheme) return "";
|
|
4004
4055
|
const dvars = toCssVars(darkTheme);
|
|
4005
4056
|
if (!Object.keys(dvars).length) return "";
|
|
@@ -4039,7 +4090,7 @@ function TextInput({
|
|
|
4039
4090
|
prefix,
|
|
4040
4091
|
suffix
|
|
4041
4092
|
}) {
|
|
4042
|
-
const errorId =
|
|
4093
|
+
const errorId = React14.useId();
|
|
4043
4094
|
const hasError = errorMessage != null;
|
|
4044
4095
|
const hasAdornment = prefix != null || suffix != null;
|
|
4045
4096
|
const input = /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4109,7 +4160,7 @@ function NumberInput({
|
|
|
4109
4160
|
readOnly = false,
|
|
4110
4161
|
precision
|
|
4111
4162
|
}) {
|
|
4112
|
-
const errorId =
|
|
4163
|
+
const errorId = React14.useId();
|
|
4113
4164
|
const hasError = errorMessage != null;
|
|
4114
4165
|
const inferredPrecision = precision ?? (Number.isInteger(step) ? 0 : String(step).split(".")[1]?.length ?? 0);
|
|
4115
4166
|
const round = (n) => {
|
|
@@ -4240,8 +4291,8 @@ function Password({
|
|
|
4240
4291
|
showIcon,
|
|
4241
4292
|
hideIcon
|
|
4242
4293
|
}) {
|
|
4243
|
-
const [visible, setVisible] =
|
|
4244
|
-
const errorId =
|
|
4294
|
+
const [visible, setVisible] = React14.useState(false);
|
|
4295
|
+
const errorId = React14.useId();
|
|
4245
4296
|
const hasError = errorMessage != null;
|
|
4246
4297
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4247
4298
|
Field,
|
|
@@ -4314,7 +4365,7 @@ function Checkbox({
|
|
|
4314
4365
|
}) {
|
|
4315
4366
|
const isChecked = checked ?? value ?? false;
|
|
4316
4367
|
const labelFirst = labelPosition === "left";
|
|
4317
|
-
const errorId =
|
|
4368
|
+
const errorId = React14.useId();
|
|
4318
4369
|
const hasError = errorMessage != null;
|
|
4319
4370
|
const box = /* @__PURE__ */ jsxRuntime.jsx(
|
|
4320
4371
|
CheckboxPrimitive__namespace.Root,
|
|
@@ -4422,8 +4473,8 @@ function RadioGroup({
|
|
|
4422
4473
|
className,
|
|
4423
4474
|
errorMessage
|
|
4424
4475
|
}) {
|
|
4425
|
-
const errorId =
|
|
4426
|
-
const groupId =
|
|
4476
|
+
const errorId = React14.useId();
|
|
4477
|
+
const groupId = React14.useId();
|
|
4427
4478
|
const hasError = errorMessage != null;
|
|
4428
4479
|
const labelFirst = labelPosition === "left";
|
|
4429
4480
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4523,11 +4574,11 @@ function Switch({
|
|
|
4523
4574
|
disabled,
|
|
4524
4575
|
errorMessage
|
|
4525
4576
|
}) {
|
|
4526
|
-
const id =
|
|
4527
|
-
const errorId =
|
|
4577
|
+
const id = React14.useId();
|
|
4578
|
+
const errorId = React14.useId();
|
|
4528
4579
|
const hasError = errorMessage != null;
|
|
4529
4580
|
const isControlled = checked !== void 0;
|
|
4530
|
-
const [internal, setInternal] =
|
|
4581
|
+
const [internal, setInternal] = React14.useState(defaultChecked);
|
|
4531
4582
|
const isOn = isControlled ? checked : internal;
|
|
4532
4583
|
const handle = (c) => {
|
|
4533
4584
|
if (!isControlled) setInternal(c);
|
|
@@ -4600,19 +4651,19 @@ function AutoComplete({
|
|
|
4600
4651
|
required,
|
|
4601
4652
|
htmlFor
|
|
4602
4653
|
}) {
|
|
4603
|
-
const errorId =
|
|
4654
|
+
const errorId = React14.useId();
|
|
4604
4655
|
const hasError = errorMessage != null;
|
|
4605
|
-
const [term, setTerm] =
|
|
4606
|
-
const [open, setOpen] =
|
|
4607
|
-
const [asyncItems, setAsyncItems] =
|
|
4608
|
-
const [loading, setLoading] =
|
|
4656
|
+
const [term, setTerm] = React14.useState("");
|
|
4657
|
+
const [open, setOpen] = React14.useState(false);
|
|
4658
|
+
const [asyncItems, setAsyncItems] = React14.useState([]);
|
|
4659
|
+
const [loading, setLoading] = React14.useState(false);
|
|
4609
4660
|
const isAsync = typeof onSearch === "function";
|
|
4610
|
-
const debounceRef =
|
|
4611
|
-
const requestIdRef =
|
|
4661
|
+
const debounceRef = React14.useRef(null);
|
|
4662
|
+
const requestIdRef = React14.useRef(0);
|
|
4612
4663
|
const staticFiltered = isAsync || !items ? [] : term.trim() ? items.filter(
|
|
4613
4664
|
({ key, label: label2 }) => label2.toLowerCase().includes(term.toLowerCase()) || key.toLowerCase().includes(term.toLowerCase())
|
|
4614
4665
|
) : [];
|
|
4615
|
-
|
|
4666
|
+
React14.useEffect(() => {
|
|
4616
4667
|
if (!isAsync) return;
|
|
4617
4668
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
4618
4669
|
if (!term.trim()) {
|
|
@@ -4768,15 +4819,15 @@ function TreeSelect({
|
|
|
4768
4819
|
defaultExpandedKeys = [],
|
|
4769
4820
|
size = "md"
|
|
4770
4821
|
}) {
|
|
4771
|
-
const errorId =
|
|
4822
|
+
const errorId = React14.useId();
|
|
4772
4823
|
const hasError = errorMessage != null;
|
|
4773
|
-
const [open, setOpen] =
|
|
4774
|
-
const [expanded, setExpanded] =
|
|
4775
|
-
const [activeIndex, setActiveIndex] =
|
|
4776
|
-
const listRef =
|
|
4777
|
-
const visible =
|
|
4778
|
-
const didSyncOnOpenRef =
|
|
4779
|
-
|
|
4824
|
+
const [open, setOpen] = React14.useState(false);
|
|
4825
|
+
const [expanded, setExpanded] = React14.useState(() => new Set(defaultExpandedKeys));
|
|
4826
|
+
const [activeIndex, setActiveIndex] = React14.useState(0);
|
|
4827
|
+
const listRef = React14.useRef(null);
|
|
4828
|
+
const visible = React14.useMemo(() => flattenVisible(items, expanded), [items, expanded]);
|
|
4829
|
+
const didSyncOnOpenRef = React14.useRef(false);
|
|
4830
|
+
React14.useEffect(() => {
|
|
4780
4831
|
if (!open) {
|
|
4781
4832
|
didSyncOnOpenRef.current = false;
|
|
4782
4833
|
return;
|
|
@@ -4786,7 +4837,7 @@ function TreeSelect({
|
|
|
4786
4837
|
setActiveIndex(selectedIdx >= 0 ? selectedIdx : 0);
|
|
4787
4838
|
didSyncOnOpenRef.current = true;
|
|
4788
4839
|
}, [open, value]);
|
|
4789
|
-
const selectedNode =
|
|
4840
|
+
const selectedNode = React14.useMemo(
|
|
4790
4841
|
() => value != null ? findNodeByKey(items, value) : null,
|
|
4791
4842
|
[items, value]
|
|
4792
4843
|
);
|
|
@@ -5017,11 +5068,11 @@ function FileInput({
|
|
|
5017
5068
|
required,
|
|
5018
5069
|
icon
|
|
5019
5070
|
}) {
|
|
5020
|
-
const inputRef =
|
|
5021
|
-
const errorId =
|
|
5022
|
-
const [files, setFiles] =
|
|
5023
|
-
const [dragging, setDragging] =
|
|
5024
|
-
const [sizeError, setSizeError] =
|
|
5071
|
+
const inputRef = React14.useRef(null);
|
|
5072
|
+
const errorId = React14.useId();
|
|
5073
|
+
const [files, setFiles] = React14.useState([]);
|
|
5074
|
+
const [dragging, setDragging] = React14.useState(false);
|
|
5075
|
+
const [sizeError, setSizeError] = React14.useState(null);
|
|
5025
5076
|
const effectiveError = errorMessage ?? sizeError ?? void 0;
|
|
5026
5077
|
const openPicker = () => {
|
|
5027
5078
|
if (!disabled) inputRef.current?.click();
|
|
@@ -5212,30 +5263,30 @@ function DatePicker({
|
|
|
5212
5263
|
size = "md",
|
|
5213
5264
|
className = ""
|
|
5214
5265
|
}) {
|
|
5215
|
-
const errorId =
|
|
5266
|
+
const errorId = React14.useId();
|
|
5216
5267
|
const hasError = errorMessage != null;
|
|
5217
|
-
const [open, setOpen] =
|
|
5218
|
-
const [viewMonth, setViewMonth] =
|
|
5219
|
-
const [focusDate, setFocusDate] =
|
|
5220
|
-
const [view, setView] =
|
|
5221
|
-
const gridRef =
|
|
5222
|
-
|
|
5268
|
+
const [open, setOpen] = React14.useState(false);
|
|
5269
|
+
const [viewMonth, setViewMonth] = React14.useState(() => startOfMonth(value ?? /* @__PURE__ */ new Date()));
|
|
5270
|
+
const [focusDate, setFocusDate] = React14.useState(() => value ?? /* @__PURE__ */ new Date());
|
|
5271
|
+
const [view, setView] = React14.useState("days");
|
|
5272
|
+
const gridRef = React14.useRef(null);
|
|
5273
|
+
React14.useEffect(() => {
|
|
5223
5274
|
if (!open) return;
|
|
5224
5275
|
const target = value ?? /* @__PURE__ */ new Date();
|
|
5225
5276
|
setViewMonth(startOfMonth(target));
|
|
5226
5277
|
setFocusDate(target);
|
|
5227
5278
|
setView("days");
|
|
5228
5279
|
}, [open, value]);
|
|
5229
|
-
|
|
5280
|
+
React14.useEffect(() => {
|
|
5230
5281
|
if (!open) return;
|
|
5231
5282
|
const cell = gridRef.current?.querySelector(`[data-day="${defaultFormat(focusDate)}"]`);
|
|
5232
5283
|
cell?.focus();
|
|
5233
5284
|
}, [open, focusDate]);
|
|
5234
|
-
const weekdays =
|
|
5285
|
+
const weekdays = React14.useMemo(() => {
|
|
5235
5286
|
const ordered = WEEKDAY_SHORT.slice(weekStartsOn).concat(WEEKDAY_SHORT.slice(0, weekStartsOn));
|
|
5236
5287
|
return ordered;
|
|
5237
5288
|
}, [weekStartsOn]);
|
|
5238
|
-
const grid =
|
|
5289
|
+
const grid = React14.useMemo(() => buildGrid(viewMonth, weekStartsOn), [viewMonth, weekStartsOn]);
|
|
5239
5290
|
const isDisabled = (d) => {
|
|
5240
5291
|
if (min && d < min) return true;
|
|
5241
5292
|
if (max && d > max) return true;
|
|
@@ -5525,10 +5576,10 @@ function TextArea({
|
|
|
5525
5576
|
style,
|
|
5526
5577
|
inputStyle
|
|
5527
5578
|
}) {
|
|
5528
|
-
const errorId =
|
|
5579
|
+
const errorId = React14.useId();
|
|
5529
5580
|
const hasError = errorMessage != null;
|
|
5530
|
-
const ref =
|
|
5531
|
-
|
|
5581
|
+
const ref = React14.useRef(null);
|
|
5582
|
+
React14.useLayoutEffect(() => {
|
|
5532
5583
|
if (!autoGrow) return;
|
|
5533
5584
|
const el = ref.current;
|
|
5534
5585
|
if (!el) return;
|
|
@@ -5598,11 +5649,11 @@ function SegmentedControl({
|
|
|
5598
5649
|
"aria-label": ariaLabel
|
|
5599
5650
|
}) {
|
|
5600
5651
|
const sz = SIZE2[size];
|
|
5601
|
-
const groupId =
|
|
5602
|
-
const errorId =
|
|
5652
|
+
const groupId = React14.useId();
|
|
5653
|
+
const errorId = React14.useId();
|
|
5603
5654
|
const hasError = errorMessage != null;
|
|
5604
5655
|
const isControlled = value !== void 0;
|
|
5605
|
-
const [internal, setInternal] =
|
|
5656
|
+
const [internal, setInternal] = React14.useState(defaultValue);
|
|
5606
5657
|
const current = isControlled ? value : internal;
|
|
5607
5658
|
const handle = (v) => {
|
|
5608
5659
|
if (!v) return;
|
|
@@ -5696,14 +5747,14 @@ function Slider({
|
|
|
5696
5747
|
name,
|
|
5697
5748
|
htmlFor
|
|
5698
5749
|
}) {
|
|
5699
|
-
const errorId =
|
|
5750
|
+
const errorId = React14.useId();
|
|
5700
5751
|
const hasError = errorMessage != null;
|
|
5701
5752
|
const isRange = Array.isArray(value ?? defaultValue);
|
|
5702
|
-
const [internal, setInternal] =
|
|
5753
|
+
const [internal, setInternal] = React14.useState(
|
|
5703
5754
|
() => toArray(value) ?? toArray(defaultValue) ?? [min]
|
|
5704
5755
|
);
|
|
5705
5756
|
const current = toArray(value) ?? internal;
|
|
5706
|
-
const [dragging, setDragging] =
|
|
5757
|
+
const [dragging, setDragging] = React14.useState(false);
|
|
5707
5758
|
const emit = (arr) => {
|
|
5708
5759
|
setInternal(arr);
|
|
5709
5760
|
const next = isRange ? [arr[0], arr[1]] : arr[0];
|
|
@@ -5798,11 +5849,11 @@ function TagsInput({
|
|
|
5798
5849
|
validate,
|
|
5799
5850
|
separators = ["Enter", ","]
|
|
5800
5851
|
}) {
|
|
5801
|
-
const errorId =
|
|
5802
|
-
const inputRef =
|
|
5803
|
-
const [internal, setInternal] =
|
|
5804
|
-
const [draft, setDraft] =
|
|
5805
|
-
const [localError, setLocalError] =
|
|
5852
|
+
const errorId = React14.useId();
|
|
5853
|
+
const inputRef = React14.useRef(null);
|
|
5854
|
+
const [internal, setInternal] = React14.useState(defaultValue ?? []);
|
|
5855
|
+
const [draft, setDraft] = React14.useState("");
|
|
5856
|
+
const [localError, setLocalError] = React14.useState(null);
|
|
5806
5857
|
const tags = value ?? internal;
|
|
5807
5858
|
const hasError = errorMessage != null || localError != null;
|
|
5808
5859
|
const errorText = errorMessage ?? localError ?? void 0;
|
|
@@ -5933,9 +5984,9 @@ function OtpInput({
|
|
|
5933
5984
|
className,
|
|
5934
5985
|
groupAfter
|
|
5935
5986
|
}) {
|
|
5936
|
-
const errorId =
|
|
5987
|
+
const errorId = React14.useId();
|
|
5937
5988
|
const hasError = errorMessage != null;
|
|
5938
|
-
const refs =
|
|
5989
|
+
const refs = React14.useRef([]);
|
|
5939
5990
|
const chars = Array.from({ length }, (_, i) => value[i] ?? "");
|
|
5940
5991
|
const pattern = mode === "numeric" ? /[0-9]/ : /[a-zA-Z0-9]/;
|
|
5941
5992
|
const emit = (next) => {
|
|
@@ -5984,7 +6035,7 @@ function OtpInput({
|
|
|
5984
6035
|
emit(valid.join(""));
|
|
5985
6036
|
focusBox(valid.length);
|
|
5986
6037
|
};
|
|
5987
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Field, { className, label, htmlFor, errorId, errorMessage, required, layout, helperText, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2", role: "group", "aria-label": typeof label === "string" ? label : "One-time code", children: chars.map((char, idx) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6038
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Field, { className, label, htmlFor, errorId, errorMessage, required, layout, helperText, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2", role: "group", "aria-label": typeof label === "string" ? label : "One-time code", children: chars.map((char, idx) => /* @__PURE__ */ jsxRuntime.jsxs(React14__default.default.Fragment, { children: [
|
|
5988
6039
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5989
6040
|
"input",
|
|
5990
6041
|
{
|
|
@@ -6042,9 +6093,9 @@ function Rating({
|
|
|
6042
6093
|
className,
|
|
6043
6094
|
required
|
|
6044
6095
|
}) {
|
|
6045
|
-
const errorId =
|
|
6046
|
-
const [internal, setInternal] =
|
|
6047
|
-
const [hover, setHover] =
|
|
6096
|
+
const errorId = React14.useId();
|
|
6097
|
+
const [internal, setInternal] = React14.useState(defaultValue);
|
|
6098
|
+
const [hover, setHover] = React14.useState(null);
|
|
6048
6099
|
const current = value ?? internal;
|
|
6049
6100
|
const display2 = hover ?? current;
|
|
6050
6101
|
const interactive = !readOnly && !disabled;
|
|
@@ -6167,9 +6218,9 @@ function TimePicker({
|
|
|
6167
6218
|
required,
|
|
6168
6219
|
style
|
|
6169
6220
|
}) {
|
|
6170
|
-
const errorId =
|
|
6221
|
+
const errorId = React14.useId();
|
|
6171
6222
|
const hasError = errorMessage != null;
|
|
6172
|
-
const [open, setOpen] =
|
|
6223
|
+
const [open, setOpen] = React14.useState(false);
|
|
6173
6224
|
const parsed = parse(value) ?? { h: 0, m: 0, s: 0 };
|
|
6174
6225
|
const update = (next) => {
|
|
6175
6226
|
const merged = { ...parsed, ...next };
|
|
@@ -6293,13 +6344,13 @@ function DateRangePicker({
|
|
|
6293
6344
|
required,
|
|
6294
6345
|
style
|
|
6295
6346
|
}) {
|
|
6296
|
-
const errorId =
|
|
6347
|
+
const errorId = React14.useId();
|
|
6297
6348
|
const hasError = errorMessage != null;
|
|
6298
|
-
const [open, setOpen] =
|
|
6299
|
-
const [leftMonth, setLeftMonth] =
|
|
6300
|
-
const [pendingStart, setPendingStart] =
|
|
6301
|
-
const [hoverDate, setHoverDate] =
|
|
6302
|
-
const weekdays =
|
|
6349
|
+
const [open, setOpen] = React14.useState(false);
|
|
6350
|
+
const [leftMonth, setLeftMonth] = React14.useState(() => startOfMonth2(value.start ?? /* @__PURE__ */ new Date()));
|
|
6351
|
+
const [pendingStart, setPendingStart] = React14.useState(null);
|
|
6352
|
+
const [hoverDate, setHoverDate] = React14.useState(null);
|
|
6353
|
+
const weekdays = React14.useMemo(
|
|
6303
6354
|
() => WEEKDAY.slice(weekStartsOn).concat(WEEKDAY.slice(0, weekStartsOn)),
|
|
6304
6355
|
[weekStartsOn]
|
|
6305
6356
|
);
|
|
@@ -6475,10 +6526,10 @@ function ColorPicker({
|
|
|
6475
6526
|
required,
|
|
6476
6527
|
placeholder = "Pick a colour\u2026"
|
|
6477
6528
|
}) {
|
|
6478
|
-
const errorId =
|
|
6529
|
+
const errorId = React14.useId();
|
|
6479
6530
|
const hasError = errorMessage != null;
|
|
6480
|
-
const [open, setOpen] =
|
|
6481
|
-
const [draft, setDraft] =
|
|
6531
|
+
const [open, setOpen] = React14.useState(false);
|
|
6532
|
+
const [draft, setDraft] = React14.useState(value);
|
|
6482
6533
|
const valid = HEX_RE.test(value);
|
|
6483
6534
|
const pick = (hex) => {
|
|
6484
6535
|
onChange?.(hex);
|
|
@@ -6865,11 +6916,11 @@ function buildBindings(store, name, kind, snap) {
|
|
|
6865
6916
|
|
|
6866
6917
|
// src/form/useForm.ts
|
|
6867
6918
|
function useForm(options = {}) {
|
|
6868
|
-
const ref =
|
|
6919
|
+
const ref = React14.useRef(null);
|
|
6869
6920
|
if (ref.current === null) ref.current = new FormStore(options);
|
|
6870
6921
|
const store = ref.current;
|
|
6871
|
-
|
|
6872
|
-
const make =
|
|
6922
|
+
React14.useSyncExternalStore(store.subscribe, store.getRootSnapshot, store.getRootSnapshot);
|
|
6923
|
+
const make = React14.useCallback(
|
|
6873
6924
|
(kind) => (name, rules) => {
|
|
6874
6925
|
if (rules !== void 0) store.setRule(name, rules);
|
|
6875
6926
|
return buildBindings(store, name, kind, store.getFieldSnapshot(name));
|
|
@@ -6898,9 +6949,9 @@ function useForm(options = {}) {
|
|
|
6898
6949
|
fieldTarget: make("target")
|
|
6899
6950
|
};
|
|
6900
6951
|
}
|
|
6901
|
-
var FormContext =
|
|
6952
|
+
var FormContext = React14.createContext(null);
|
|
6902
6953
|
function useFormStore() {
|
|
6903
|
-
const store =
|
|
6954
|
+
const store = React14.useContext(FormContext);
|
|
6904
6955
|
if (!store) {
|
|
6905
6956
|
throw new Error("useFormStore must be used within a <Form>. Did you forget to wrap your fields?");
|
|
6906
6957
|
}
|
|
@@ -6914,8 +6965,8 @@ function Form({
|
|
|
6914
6965
|
children,
|
|
6915
6966
|
...rest
|
|
6916
6967
|
}) {
|
|
6917
|
-
const ref =
|
|
6918
|
-
const bypass =
|
|
6968
|
+
const ref = React14.useRef(null);
|
|
6969
|
+
const bypass = React14.useRef(false);
|
|
6919
6970
|
const handleSubmit = async (e) => {
|
|
6920
6971
|
if (bypass.current) {
|
|
6921
6972
|
bypass.current = false;
|
|
@@ -6967,12 +7018,12 @@ function useFormField(name, options = {}) {
|
|
|
6967
7018
|
const store = useFormStore();
|
|
6968
7019
|
const { kind = "value", rules } = options;
|
|
6969
7020
|
if (rules !== void 0 && store.getRule(name) !== rules) store.setRule(name, rules);
|
|
6970
|
-
|
|
7021
|
+
React14.useEffect(() => {
|
|
6971
7022
|
return () => {
|
|
6972
7023
|
if (rules !== void 0) store.removeRule(name);
|
|
6973
7024
|
};
|
|
6974
7025
|
}, [store, name]);
|
|
6975
|
-
const snap =
|
|
7026
|
+
const snap = React14.useSyncExternalStore(
|
|
6976
7027
|
store.subscribe,
|
|
6977
7028
|
() => store.getFieldSnapshot(name)
|
|
6978
7029
|
);
|
|
@@ -6984,7 +7035,7 @@ function FormField({ name, kind, rules, children }) {
|
|
|
6984
7035
|
}
|
|
6985
7036
|
function useFieldArray(name) {
|
|
6986
7037
|
const store = useFormStore();
|
|
6987
|
-
|
|
7038
|
+
React14.useSyncExternalStore(store.subscribe, store.getRootSnapshot, store.getRootSnapshot);
|
|
6988
7039
|
const arr = store.getValue(name) ?? [];
|
|
6989
7040
|
const keys = store.getKeys(name);
|
|
6990
7041
|
return {
|
|
@@ -7107,7 +7158,7 @@ function CreditCardForm({
|
|
|
7107
7158
|
className = "",
|
|
7108
7159
|
style
|
|
7109
7160
|
}) {
|
|
7110
|
-
const initial =
|
|
7161
|
+
const initial = React14.useRef({
|
|
7111
7162
|
number: formatCardNumber(defaultValue?.number ?? ""),
|
|
7112
7163
|
name: defaultValue?.name ?? "",
|
|
7113
7164
|
expiry: formatExpiry(defaultValue?.expiry ?? ""),
|
|
@@ -7116,7 +7167,7 @@ function CreditCardForm({
|
|
|
7116
7167
|
const form = useForm({ initialValues: initial });
|
|
7117
7168
|
const numberStr = String(form.values.number ?? "");
|
|
7118
7169
|
const brand = detectBrand(numberStr);
|
|
7119
|
-
|
|
7170
|
+
React14.useEffect(() => {
|
|
7120
7171
|
onChange?.(toCard(form.values));
|
|
7121
7172
|
}, [form.values.number, form.values.name, form.values.expiry, form.values.cvv]);
|
|
7122
7173
|
const numberBind = form.fieldNative("number", {
|
|
@@ -7219,6 +7270,7 @@ exports.AppShell = AppShell;
|
|
|
7219
7270
|
exports.AutoComplete = AutoComplete;
|
|
7220
7271
|
exports.Avatar = Avatar;
|
|
7221
7272
|
exports.Box = Box;
|
|
7273
|
+
exports.Breadcrumbs = Breadcrumbs;
|
|
7222
7274
|
exports.Button = Button;
|
|
7223
7275
|
exports.CARD_BRANDS = CARD_BRANDS;
|
|
7224
7276
|
exports.Catalog = Catalog;
|