@geomak/ui 6.2.3 → 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 +345 -197
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +109 -1
- package/dist/index.d.ts +109 -1
- package/dist/index.js +161 -15
- package/dist/index.js.map +1 -1
- package/dist/styles.css +34 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
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');
|
|
9
9
|
var framerMotion = require('framer-motion');
|
|
10
10
|
var TooltipPrimitive = require('@radix-ui/react-tooltip');
|
|
11
11
|
var TabsPrimitive = require('@radix-ui/react-tabs');
|
|
12
|
-
var
|
|
12
|
+
var AccordionPrimitive = require('@radix-ui/react-accordion');
|
|
13
13
|
var ContextMenuPrimitive = require('@radix-ui/react-context-menu');
|
|
14
14
|
var Popover = require('@radix-ui/react-popover');
|
|
15
15
|
var SwitchPrimitive = require('@radix-ui/react-switch');
|
|
@@ -39,12 +39,12 @@ 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);
|
|
46
46
|
var TabsPrimitive__namespace = /*#__PURE__*/_interopNamespace(TabsPrimitive);
|
|
47
|
-
var
|
|
47
|
+
var AccordionPrimitive__namespace = /*#__PURE__*/_interopNamespace(AccordionPrimitive);
|
|
48
48
|
var ContextMenuPrimitive__namespace = /*#__PURE__*/_interopNamespace(ContextMenuPrimitive);
|
|
49
49
|
var Popover__namespace = /*#__PURE__*/_interopNamespace(Popover);
|
|
50
50
|
var SwitchPrimitive__namespace = /*#__PURE__*/_interopNamespace(SwitchPrimitive);
|
|
@@ -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]);
|
|
@@ -1329,14 +1329,14 @@ function TreeNodeItem({
|
|
|
1329
1329
|
}
|
|
1330
1330
|
const initialOpen = defaultExpandAll || defaultExpandedKeys.includes(item.key) ? [item.key] : [];
|
|
1331
1331
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1332
|
-
|
|
1332
|
+
AccordionPrimitive__namespace.Root,
|
|
1333
1333
|
{
|
|
1334
1334
|
type: "multiple",
|
|
1335
1335
|
defaultValue: initialOpen,
|
|
1336
1336
|
style: { paddingLeft: depth * 12 },
|
|
1337
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1337
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(AccordionPrimitive__namespace.Item, { value: item.key, className: "border-none", children: [
|
|
1338
1338
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1339
|
-
|
|
1339
|
+
AccordionPrimitive__namespace.Trigger,
|
|
1340
1340
|
{
|
|
1341
1341
|
onClick: () => onNodeClick({
|
|
1342
1342
|
isParent: true,
|
|
@@ -1370,7 +1370,7 @@ function TreeNodeItem({
|
|
|
1370
1370
|
]
|
|
1371
1371
|
}
|
|
1372
1372
|
),
|
|
1373
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1373
|
+
/* @__PURE__ */ jsxRuntime.jsx(AccordionPrimitive__namespace.Content, { className: "overflow-hidden data-[state=open]:animate-accordion-down data-[state=closed]:animate-accordion-up", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-3.5 border-l border-border py-0.5", children: item.children.map((child) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1374
1374
|
TreeNodeItem,
|
|
1375
1375
|
{
|
|
1376
1376
|
item: child,
|
|
@@ -1404,7 +1404,153 @@ function Tree({
|
|
|
1404
1404
|
item.key
|
|
1405
1405
|
)) });
|
|
1406
1406
|
}
|
|
1407
|
-
var
|
|
1407
|
+
var AccordionCtx = React14.createContext({ variant: "separated" });
|
|
1408
|
+
function Accordion2({
|
|
1409
|
+
children,
|
|
1410
|
+
type = "single",
|
|
1411
|
+
defaultValue,
|
|
1412
|
+
value,
|
|
1413
|
+
onValueChange,
|
|
1414
|
+
collapsible = true,
|
|
1415
|
+
variant = "separated",
|
|
1416
|
+
className = "",
|
|
1417
|
+
style
|
|
1418
|
+
}) {
|
|
1419
|
+
const common = {
|
|
1420
|
+
className: [
|
|
1421
|
+
variant === "contained" ? "rounded-lg border border-border bg-surface overflow-hidden divide-y divide-border" : "flex flex-col gap-2",
|
|
1422
|
+
className
|
|
1423
|
+
].filter(Boolean).join(" "),
|
|
1424
|
+
style
|
|
1425
|
+
};
|
|
1426
|
+
const inner = /* @__PURE__ */ jsxRuntime.jsx(AccordionCtx.Provider, { value: { variant }, children });
|
|
1427
|
+
if (type === "multiple") {
|
|
1428
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1429
|
+
AccordionPrimitive__namespace.Root,
|
|
1430
|
+
{
|
|
1431
|
+
type: "multiple",
|
|
1432
|
+
defaultValue,
|
|
1433
|
+
value,
|
|
1434
|
+
onValueChange,
|
|
1435
|
+
...common,
|
|
1436
|
+
children: inner
|
|
1437
|
+
}
|
|
1438
|
+
);
|
|
1439
|
+
}
|
|
1440
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1441
|
+
AccordionPrimitive__namespace.Root,
|
|
1442
|
+
{
|
|
1443
|
+
type: "single",
|
|
1444
|
+
collapsible,
|
|
1445
|
+
defaultValue,
|
|
1446
|
+
value,
|
|
1447
|
+
onValueChange,
|
|
1448
|
+
...common,
|
|
1449
|
+
children: inner
|
|
1450
|
+
}
|
|
1451
|
+
);
|
|
1452
|
+
}
|
|
1453
|
+
var Chevron2 = /* @__PURE__ */ jsxRuntime.jsx(
|
|
1454
|
+
"svg",
|
|
1455
|
+
{
|
|
1456
|
+
viewBox: "0 0 24 24",
|
|
1457
|
+
fill: "none",
|
|
1458
|
+
stroke: "currentColor",
|
|
1459
|
+
strokeWidth: 2,
|
|
1460
|
+
"aria-hidden": "true",
|
|
1461
|
+
className: "h-4 w-4 flex-shrink-0 text-foreground-muted transition-transform duration-200 group-data-[state=open]/acc:rotate-180 group-data-[state=open]/acc:text-accent",
|
|
1462
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19 9l-7 7-7-7" })
|
|
1463
|
+
}
|
|
1464
|
+
);
|
|
1465
|
+
function AccordionItem({ value, title, icon, children, disabled, className = "" }) {
|
|
1466
|
+
const { variant } = React14.useContext(AccordionCtx);
|
|
1467
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1468
|
+
AccordionPrimitive__namespace.Item,
|
|
1469
|
+
{
|
|
1470
|
+
value,
|
|
1471
|
+
disabled,
|
|
1472
|
+
className: [
|
|
1473
|
+
variant === "separated" ? "rounded-lg border border-border bg-surface overflow-hidden" : "",
|
|
1474
|
+
"data-[disabled]:opacity-60",
|
|
1475
|
+
className
|
|
1476
|
+
].filter(Boolean).join(" "),
|
|
1477
|
+
children: [
|
|
1478
|
+
/* @__PURE__ */ jsxRuntime.jsx(AccordionPrimitive__namespace.Header, { className: "m-0", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1479
|
+
AccordionPrimitive__namespace.Trigger,
|
|
1480
|
+
{
|
|
1481
|
+
className: "group/acc flex w-full items-center gap-3 px-4 py-3 text-left select-none\n text-sm font-medium text-foreground transition-colors\n hover:bg-surface-raised data-[state=open]:text-accent\n focus:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-inset\n disabled:cursor-not-allowed",
|
|
1482
|
+
children: [
|
|
1483
|
+
icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex h-5 w-5 flex-shrink-0 items-center justify-center text-foreground-muted group-data-[state=open]/acc:text-accent", children: icon }),
|
|
1484
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-1 min-w-0", children: title }),
|
|
1485
|
+
Chevron2
|
|
1486
|
+
]
|
|
1487
|
+
}
|
|
1488
|
+
) }),
|
|
1489
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1490
|
+
AccordionPrimitive__namespace.Content,
|
|
1491
|
+
{
|
|
1492
|
+
className: "overflow-hidden data-[state=open]:animate-accordion-down data-[state=closed]:animate-accordion-up",
|
|
1493
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 pb-4 pt-0 text-sm text-foreground-secondary leading-relaxed", children })
|
|
1494
|
+
}
|
|
1495
|
+
)
|
|
1496
|
+
]
|
|
1497
|
+
}
|
|
1498
|
+
);
|
|
1499
|
+
}
|
|
1500
|
+
Accordion2.Item = AccordionItem;
|
|
1501
|
+
var Accordion_default = Accordion2;
|
|
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({
|
|
1408
1554
|
open: () => void 0,
|
|
1409
1555
|
close: () => void 0
|
|
1410
1556
|
});
|
|
@@ -1462,26 +1608,26 @@ function NotificationItem({
|
|
|
1462
1608
|
onClose,
|
|
1463
1609
|
reduced
|
|
1464
1610
|
}) {
|
|
1465
|
-
const [paused, setPaused] =
|
|
1611
|
+
const [paused, setPaused] = React14.useState(false);
|
|
1466
1612
|
const duration = n.duration ?? 4e3;
|
|
1467
1613
|
const isAutoDismissing = isFinite(duration) && duration > 0;
|
|
1468
1614
|
const showProgress = !reduced && isAutoDismissing;
|
|
1469
|
-
const timerRef =
|
|
1470
|
-
const startTimeRef =
|
|
1471
|
-
const remainingRef =
|
|
1472
|
-
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(() => {
|
|
1473
1619
|
if (timerRef.current !== null) {
|
|
1474
1620
|
clearTimeout(timerRef.current);
|
|
1475
1621
|
timerRef.current = null;
|
|
1476
1622
|
}
|
|
1477
1623
|
}, []);
|
|
1478
|
-
const scheduleDismiss =
|
|
1624
|
+
const scheduleDismiss = React14.useCallback((ms) => {
|
|
1479
1625
|
clearTimer();
|
|
1480
1626
|
if (!isAutoDismissing) return;
|
|
1481
1627
|
startTimeRef.current = Date.now();
|
|
1482
1628
|
timerRef.current = setTimeout(() => onClose(n.id), ms);
|
|
1483
1629
|
}, [clearTimer, isAutoDismissing, n.id, onClose]);
|
|
1484
|
-
|
|
1630
|
+
React14.useEffect(() => {
|
|
1485
1631
|
if (paused || !isAutoDismissing) return;
|
|
1486
1632
|
scheduleDismiss(remainingRef.current);
|
|
1487
1633
|
return clearTimer;
|
|
@@ -1564,15 +1710,15 @@ function NotificationProvider({
|
|
|
1564
1710
|
children,
|
|
1565
1711
|
position = "top-right"
|
|
1566
1712
|
}) {
|
|
1567
|
-
const [notifications, setNotifications] =
|
|
1713
|
+
const [notifications, setNotifications] = React14.useState([]);
|
|
1568
1714
|
const reduced = framerMotion.useReducedMotion();
|
|
1569
|
-
const open =
|
|
1715
|
+
const open = React14.useCallback((payload) => {
|
|
1570
1716
|
setNotifications((prev) => [
|
|
1571
1717
|
...prev,
|
|
1572
1718
|
{ duration: 4e3, ...payload, id: Date.now() + Math.random() }
|
|
1573
1719
|
]);
|
|
1574
1720
|
}, []);
|
|
1575
|
-
const close =
|
|
1721
|
+
const close = React14.useCallback((id) => {
|
|
1576
1722
|
setNotifications((prev) => prev.filter((n) => n.id !== id));
|
|
1577
1723
|
}, []);
|
|
1578
1724
|
return /* @__PURE__ */ jsxRuntime.jsxs(NotificationContext.Provider, { value: { open, close }, children: [
|
|
@@ -1601,7 +1747,7 @@ function NotificationProvider({
|
|
|
1601
1747
|
] });
|
|
1602
1748
|
}
|
|
1603
1749
|
function useNotification() {
|
|
1604
|
-
const { open } =
|
|
1750
|
+
const { open } = React14.useContext(NotificationContext);
|
|
1605
1751
|
return {
|
|
1606
1752
|
info: (props) => open({ type: "info", ...props }),
|
|
1607
1753
|
success: (props) => open({ type: "success", ...props }),
|
|
@@ -1718,10 +1864,10 @@ function FadingBase({
|
|
|
1718
1864
|
isMounted = false,
|
|
1719
1865
|
children
|
|
1720
1866
|
}) {
|
|
1721
|
-
const [shouldRender, setShouldRender] =
|
|
1722
|
-
const [visible, setVisible] =
|
|
1723
|
-
const timerRef =
|
|
1724
|
-
|
|
1867
|
+
const [shouldRender, setShouldRender] = React14.useState(isMounted);
|
|
1868
|
+
const [visible, setVisible] = React14.useState(false);
|
|
1869
|
+
const timerRef = React14.useRef(null);
|
|
1870
|
+
React14.useEffect(() => {
|
|
1725
1871
|
if (isMounted) {
|
|
1726
1872
|
setShouldRender(true);
|
|
1727
1873
|
const rafId = requestAnimationFrame(() => setVisible(true));
|
|
@@ -1819,8 +1965,8 @@ function ScalableContainer({
|
|
|
1819
1965
|
togglePosition = "top-right",
|
|
1820
1966
|
className = ""
|
|
1821
1967
|
}) {
|
|
1822
|
-
const containerRef =
|
|
1823
|
-
const [internalScaled, setInternalScaled] =
|
|
1968
|
+
const containerRef = React14.useRef(null);
|
|
1969
|
+
const [internalScaled, setInternalScaled] = React14.useState(false);
|
|
1824
1970
|
const isScaled = expanded ?? internalScaled;
|
|
1825
1971
|
const reduced = framerMotion.useReducedMotion();
|
|
1826
1972
|
const onToggle = () => {
|
|
@@ -1958,17 +2104,17 @@ function CatalogGrid({ items, buttonText, onOpen, className = "" }) {
|
|
|
1958
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)) });
|
|
1959
2105
|
}
|
|
1960
2106
|
function CatalogCarousel({ items, buttonText, onOpen, className = "" }) {
|
|
1961
|
-
const [activeIndex, setActiveIndex] =
|
|
1962
|
-
const [indexPool, setIndexPool] =
|
|
1963
|
-
const cardRefs =
|
|
1964
|
-
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(() => {
|
|
1965
2111
|
let nextIndex = activeIndex + 1;
|
|
1966
2112
|
let previousIndex = activeIndex - 1;
|
|
1967
2113
|
if (activeIndex === 0) previousIndex = items.length - 1;
|
|
1968
2114
|
if (activeIndex === items.length - 1) nextIndex = 0;
|
|
1969
2115
|
return { previousIndex, nextIndex };
|
|
1970
2116
|
}, [activeIndex, items.length]);
|
|
1971
|
-
|
|
2117
|
+
React14.useEffect(() => {
|
|
1972
2118
|
const { nextIndex, previousIndex } = getIndexes;
|
|
1973
2119
|
let indexes = [previousIndex, activeIndex, nextIndex];
|
|
1974
2120
|
if (activeIndex !== 0 && activeIndex !== items.length - 1) {
|
|
@@ -2141,8 +2287,8 @@ function writeDismissed(key) {
|
|
|
2141
2287
|
}
|
|
2142
2288
|
}
|
|
2143
2289
|
function useTargetBbox(ref) {
|
|
2144
|
-
const [bbox, setBbox] =
|
|
2145
|
-
|
|
2290
|
+
const [bbox, setBbox] = React14.useState(null);
|
|
2291
|
+
React14.useLayoutEffect(() => {
|
|
2146
2292
|
const el = ref?.current;
|
|
2147
2293
|
if (!el) {
|
|
2148
2294
|
setBbox(null);
|
|
@@ -2172,7 +2318,7 @@ function tooltipStyleFor(bbox, placement) {
|
|
|
2172
2318
|
return { left: bbox.left + bbox.width / 2, top: bbox.top - TOOLTIP_GAP, transform: "translate(-50%, -100%)", width: TOOLTIP_WIDTH };
|
|
2173
2319
|
}
|
|
2174
2320
|
function useFocusTrap(containerRef, active) {
|
|
2175
|
-
|
|
2321
|
+
React14.useEffect(() => {
|
|
2176
2322
|
if (!active) return;
|
|
2177
2323
|
const el = containerRef.current;
|
|
2178
2324
|
if (!el) return;
|
|
@@ -2211,16 +2357,16 @@ function Wizard({
|
|
|
2211
2357
|
onComplete,
|
|
2212
2358
|
onSkip
|
|
2213
2359
|
}) {
|
|
2214
|
-
const tooltipRef =
|
|
2215
|
-
const tooltipTitleId =
|
|
2216
|
-
const tooltipBodyId =
|
|
2360
|
+
const tooltipRef = React14.useRef(null);
|
|
2361
|
+
const tooltipTitleId = React14.useId();
|
|
2362
|
+
const tooltipBodyId = React14.useId();
|
|
2217
2363
|
const reduced = framerMotion.useReducedMotion();
|
|
2218
|
-
const [open, setOpen] =
|
|
2219
|
-
const [activeIndex, setActiveIndex] =
|
|
2364
|
+
const [open, setOpen] = React14.useState(() => steps.length > 0 && !readDismissed(storageKey));
|
|
2365
|
+
const [activeIndex, setActiveIndex] = React14.useState(0);
|
|
2220
2366
|
const step = steps[activeIndex];
|
|
2221
2367
|
const bbox = useTargetBbox(step?.stepRef);
|
|
2222
2368
|
useFocusTrap(tooltipRef, open);
|
|
2223
|
-
|
|
2369
|
+
React14.useEffect(() => {
|
|
2224
2370
|
if (!open || !dismissible) return;
|
|
2225
2371
|
const onKey = (e) => {
|
|
2226
2372
|
if (e.key === "Escape") {
|
|
@@ -2231,12 +2377,12 @@ function Wizard({
|
|
|
2231
2377
|
document.addEventListener("keydown", onKey);
|
|
2232
2378
|
return () => document.removeEventListener("keydown", onKey);
|
|
2233
2379
|
}, [open, dismissible]);
|
|
2234
|
-
const handleSkip =
|
|
2380
|
+
const handleSkip = React14.useCallback(() => {
|
|
2235
2381
|
writeDismissed(storageKey);
|
|
2236
2382
|
setOpen(false);
|
|
2237
2383
|
onSkip?.();
|
|
2238
2384
|
}, [storageKey, onSkip]);
|
|
2239
|
-
const handleComplete =
|
|
2385
|
+
const handleComplete = React14.useCallback(() => {
|
|
2240
2386
|
writeDismissed(storageKey);
|
|
2241
2387
|
setOpen(false);
|
|
2242
2388
|
onComplete?.();
|
|
@@ -2507,7 +2653,7 @@ function Field({
|
|
|
2507
2653
|
);
|
|
2508
2654
|
}
|
|
2509
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" }) });
|
|
2510
|
-
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) {
|
|
2511
2657
|
return /* @__PURE__ */ jsxRuntime.jsx(Field, { className, label, htmlFor, layout, helperText, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2512
2658
|
"div",
|
|
2513
2659
|
{
|
|
@@ -2561,11 +2707,11 @@ function MultiTagRow({
|
|
|
2561
2707
|
labelFor,
|
|
2562
2708
|
onRemove
|
|
2563
2709
|
}) {
|
|
2564
|
-
const wrapRef =
|
|
2565
|
-
const measureRef =
|
|
2566
|
-
const [visibleCount, setVisibleCount] =
|
|
2710
|
+
const wrapRef = React14.useRef(null);
|
|
2711
|
+
const measureRef = React14.useRef(null);
|
|
2712
|
+
const [visibleCount, setVisibleCount] = React14.useState(values.length);
|
|
2567
2713
|
const key = values.map(String).join("|");
|
|
2568
|
-
|
|
2714
|
+
React14.useLayoutEffect(() => {
|
|
2569
2715
|
const wrap = wrapRef.current;
|
|
2570
2716
|
const measure = measureRef.current;
|
|
2571
2717
|
if (!wrap || !measure) return;
|
|
@@ -2659,16 +2805,16 @@ function Dropdown({
|
|
|
2659
2805
|
size = "md",
|
|
2660
2806
|
className = ""
|
|
2661
2807
|
}) {
|
|
2662
|
-
const [open, setOpen] =
|
|
2663
|
-
const [selectedItems, setSelectedItems] =
|
|
2664
|
-
const [searchTerm, setSearchTerm] =
|
|
2665
|
-
const [innerItems, setInnerItems] =
|
|
2666
|
-
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();
|
|
2667
2813
|
const hasError = errorMessage != null;
|
|
2668
|
-
|
|
2814
|
+
React14.useEffect(() => {
|
|
2669
2815
|
setInnerItems(items);
|
|
2670
2816
|
}, [items]);
|
|
2671
|
-
|
|
2817
|
+
React14.useEffect(() => {
|
|
2672
2818
|
if (isMultiselect && Array.isArray(value)) {
|
|
2673
2819
|
setSelectedItems(value);
|
|
2674
2820
|
}
|
|
@@ -2993,7 +3139,7 @@ function TableBody({
|
|
|
2993
3139
|
expandRow,
|
|
2994
3140
|
getRowKey
|
|
2995
3141
|
}) {
|
|
2996
|
-
const [expanded, setExpanded] =
|
|
3142
|
+
const [expanded, setExpanded] = React14.useState(() => /* @__PURE__ */ new Set());
|
|
2997
3143
|
const reduced = framerMotion.useReducedMotion();
|
|
2998
3144
|
const toggleRow = (rowKey) => {
|
|
2999
3145
|
setExpanded((prev) => {
|
|
@@ -3008,7 +3154,7 @@ function TableBody({
|
|
|
3008
3154
|
return /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: rows.map((row, i) => {
|
|
3009
3155
|
const rowKey = getRowKey(row, i);
|
|
3010
3156
|
const isExpanded = expanded.has(rowKey);
|
|
3011
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3157
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(React14__default.default.Fragment, { children: [
|
|
3012
3158
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3013
3159
|
"tr",
|
|
3014
3160
|
{
|
|
@@ -3064,9 +3210,9 @@ function Pagination({
|
|
|
3064
3210
|
const matchedOption = picker.find(
|
|
3065
3211
|
(o) => o.label === options.perPage || o.value === options.perPage
|
|
3066
3212
|
);
|
|
3067
|
-
const [perPageKey, setPerPageKey] =
|
|
3213
|
+
const [perPageKey, setPerPageKey] = React14.useState(() => matchedOption?.key ?? picker[0]?.key);
|
|
3068
3214
|
const displayPerPageKey = serverSide ? matchedOption?.key ?? perPageKey : perPageKey;
|
|
3069
|
-
|
|
3215
|
+
React14.useEffect(() => {
|
|
3070
3216
|
if (serverSide && options.perPage != null) {
|
|
3071
3217
|
const next = picker.find((o) => o.label === options.perPage || o.value === options.perPage);
|
|
3072
3218
|
if (next) setPerPageKey(next.key);
|
|
@@ -3130,14 +3276,14 @@ function Table({
|
|
|
3130
3276
|
className = "",
|
|
3131
3277
|
style
|
|
3132
3278
|
}) {
|
|
3133
|
-
const searchRef =
|
|
3134
|
-
const [searchTerm, setSearchTerm] =
|
|
3135
|
-
const [perPage, setPerPage] =
|
|
3279
|
+
const searchRef = React14.useRef(null);
|
|
3280
|
+
const [searchTerm, setSearchTerm] = React14.useState("");
|
|
3281
|
+
const [perPage, setPerPage] = React14.useState(
|
|
3136
3282
|
typeof pagination.perPage === "number" ? pagination.perPage : 15
|
|
3137
3283
|
);
|
|
3138
|
-
const [activePage, setActivePage] =
|
|
3284
|
+
const [activePage, setActivePage] = React14.useState(0);
|
|
3139
3285
|
const isServerSide = !!(pagination.enabled && pagination.serverSide);
|
|
3140
|
-
const filteredRows =
|
|
3286
|
+
const filteredRows = React14.useMemo(() => {
|
|
3141
3287
|
if (isServerSide || !searchTerm) return rows;
|
|
3142
3288
|
const term = searchTerm.toLowerCase();
|
|
3143
3289
|
return rows.filter(
|
|
@@ -3146,29 +3292,29 @@ function Table({
|
|
|
3146
3292
|
)
|
|
3147
3293
|
);
|
|
3148
3294
|
}, [rows, searchTerm, isServerSide]);
|
|
3149
|
-
const datasets =
|
|
3295
|
+
const datasets = React14.useMemo(() => {
|
|
3150
3296
|
if (isServerSide) return [rows];
|
|
3151
3297
|
return createDatasets(filteredRows, pagination.enabled ? perPage : null);
|
|
3152
3298
|
}, [filteredRows, perPage, pagination.enabled, isServerSide, rows]);
|
|
3153
|
-
const MAX_PAGE =
|
|
3299
|
+
const MAX_PAGE = React14.useMemo(() => {
|
|
3154
3300
|
if (isServerSide && typeof pagination.maxPage === "number") return Math.max(0, pagination.maxPage);
|
|
3155
3301
|
if (isServerSide && typeof pagination.totalCount === "number")
|
|
3156
3302
|
return Math.max(0, Math.ceil(pagination.totalCount / perPage) - 1);
|
|
3157
3303
|
return datasets.length ? datasets.length - 1 : 0;
|
|
3158
3304
|
}, [isServerSide, pagination.maxPage, pagination.totalCount, perPage, datasets.length]);
|
|
3159
|
-
const currentPageRows =
|
|
3305
|
+
const currentPageRows = React14.useMemo(() => {
|
|
3160
3306
|
if (isServerSide) return rows;
|
|
3161
3307
|
return datasets[activePage] ?? [];
|
|
3162
3308
|
}, [isServerSide, rows, datasets, activePage]);
|
|
3163
|
-
|
|
3309
|
+
React14.useEffect(() => {
|
|
3164
3310
|
if (pagination.enabled && !isServerSide && typeof pagination.perPage === "number") {
|
|
3165
3311
|
setPerPage(pagination.perPage);
|
|
3166
3312
|
}
|
|
3167
3313
|
}, [pagination.enabled, pagination.perPage, isServerSide]);
|
|
3168
|
-
|
|
3314
|
+
React14.useEffect(() => {
|
|
3169
3315
|
if (isServerSide && typeof pagination.perPage === "number") setPerPage(pagination.perPage);
|
|
3170
3316
|
}, [isServerSide, pagination.perPage]);
|
|
3171
|
-
|
|
3317
|
+
React14.useEffect(() => {
|
|
3172
3318
|
if (isServerSide && typeof pagination.page === "number" && pagination.page >= 1)
|
|
3173
3319
|
setActivePage(pagination.page - 1);
|
|
3174
3320
|
}, [isServerSide, pagination.page]);
|
|
@@ -3252,7 +3398,7 @@ function TableSkeletonBody({
|
|
|
3252
3398
|
)) });
|
|
3253
3399
|
}
|
|
3254
3400
|
function ThemeSwitch({ checked, onChange, label = "Toggle dark mode", className = "" }) {
|
|
3255
|
-
const id =
|
|
3401
|
+
const id = React14.useId();
|
|
3256
3402
|
return /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: id, className: `flex items-center gap-2 cursor-pointer select-none ${className}`.trim(), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3257
3403
|
SwitchPrimitive__namespace.Root,
|
|
3258
3404
|
{
|
|
@@ -3436,7 +3582,7 @@ function Sidebar({
|
|
|
3436
3582
|
}
|
|
3437
3583
|
) });
|
|
3438
3584
|
}
|
|
3439
|
-
var MegaMenuContext =
|
|
3585
|
+
var MegaMenuContext = React14.createContext({ align: "start" });
|
|
3440
3586
|
function MegaMenu({
|
|
3441
3587
|
children,
|
|
3442
3588
|
align = "start",
|
|
@@ -3467,7 +3613,7 @@ function MegaMenu({
|
|
|
3467
3613
|
}
|
|
3468
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";
|
|
3469
3615
|
function MegaMenuItem({ label, icon, href, children, className = "" }) {
|
|
3470
|
-
const { align } =
|
|
3616
|
+
const { align } = React14.useContext(MegaMenuContext);
|
|
3471
3617
|
const pos = align === "center" ? "left-1/2 -translate-x-1/2" : align === "end" ? "right-0" : "left-0";
|
|
3472
3618
|
if (!children) {
|
|
3473
3619
|
return /* @__PURE__ */ jsxRuntime.jsx(NavigationMenu__namespace.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs(NavigationMenu__namespace.Link, { href, className: [TOP_ITEM, className].filter(Boolean).join(" "), children: [
|
|
@@ -3552,8 +3698,8 @@ function MegaMenuLink({ href, icon, description, active, onClick, children, clas
|
|
|
3552
3698
|
function MegaMenuFeatured({ children, className = "" }) {
|
|
3553
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 });
|
|
3554
3700
|
}
|
|
3555
|
-
var elementsOfType = (children, type) =>
|
|
3556
|
-
(c) =>
|
|
3701
|
+
var elementsOfType = (children, type) => React14__default.default.Children.toArray(children).filter(
|
|
3702
|
+
(c) => React14__default.default.isValidElement(c) && c.type === type
|
|
3557
3703
|
);
|
|
3558
3704
|
var MOBILE_CHEVRON = /* @__PURE__ */ jsxRuntime.jsx(
|
|
3559
3705
|
"svg",
|
|
@@ -3590,9 +3736,9 @@ function MobileLinkRow({ link, onNavigate }) {
|
|
|
3590
3736
|
);
|
|
3591
3737
|
}
|
|
3592
3738
|
function MobilePanel({ panel, onNavigate }) {
|
|
3593
|
-
const nodes =
|
|
3739
|
+
const nodes = React14__default.default.Children.toArray(panel.props.children);
|
|
3594
3740
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-4 px-2 pb-3 pt-1", children: nodes.map((node, i) => {
|
|
3595
|
-
if (!
|
|
3741
|
+
if (!React14__default.default.isValidElement(node)) return null;
|
|
3596
3742
|
const el = node;
|
|
3597
3743
|
if (el.type === MegaMenuSection) {
|
|
3598
3744
|
const { title, children } = el.props;
|
|
@@ -3611,8 +3757,8 @@ function MegaMenuMobile({
|
|
|
3611
3757
|
children,
|
|
3612
3758
|
label
|
|
3613
3759
|
}) {
|
|
3614
|
-
const [open, setOpen] =
|
|
3615
|
-
const [expanded, setExpanded] =
|
|
3760
|
+
const [open, setOpen] = React14.useState(false);
|
|
3761
|
+
const [expanded, setExpanded] = React14.useState(null);
|
|
3616
3762
|
const items = elementsOfType(children, MegaMenuItem);
|
|
3617
3763
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "md:hidden w-full", children: [
|
|
3618
3764
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -3685,17 +3831,17 @@ function AppShell({
|
|
|
3685
3831
|
children,
|
|
3686
3832
|
className = ""
|
|
3687
3833
|
}) {
|
|
3688
|
-
const [expanded, setExpanded] =
|
|
3689
|
-
const [isMobile, setIsMobile] =
|
|
3690
|
-
const [mobileOpen, setMobileOpen] =
|
|
3691
|
-
|
|
3834
|
+
const [expanded, setExpanded] = React14.useState(sidebarDefaultExpanded);
|
|
3835
|
+
const [isMobile, setIsMobile] = React14.useState(false);
|
|
3836
|
+
const [mobileOpen, setMobileOpen] = React14.useState(false);
|
|
3837
|
+
React14.useEffect(() => {
|
|
3692
3838
|
const mq = window.matchMedia("(max-width: 767px)");
|
|
3693
3839
|
const update = (e) => setIsMobile(e.matches);
|
|
3694
3840
|
update(mq);
|
|
3695
3841
|
mq.addEventListener("change", update);
|
|
3696
3842
|
return () => mq.removeEventListener("change", update);
|
|
3697
3843
|
}, []);
|
|
3698
|
-
|
|
3844
|
+
React14.useEffect(() => {
|
|
3699
3845
|
if (!isMobile) setMobileOpen(false);
|
|
3700
3846
|
}, [isMobile]);
|
|
3701
3847
|
const hasSidebar = sidebarSections.length > 0;
|
|
@@ -3885,10 +4031,10 @@ function ThemeProvider({
|
|
|
3885
4031
|
className = "",
|
|
3886
4032
|
style
|
|
3887
4033
|
}) {
|
|
3888
|
-
const id =
|
|
4034
|
+
const id = React14__default.default.useId().replace(/:/g, "");
|
|
3889
4035
|
const scopeClass = `geo-th-${id}`;
|
|
3890
|
-
const divRef =
|
|
3891
|
-
|
|
4036
|
+
const divRef = React14.useRef(null);
|
|
4037
|
+
React14.useEffect(() => {
|
|
3892
4038
|
const el = divRef.current;
|
|
3893
4039
|
if (!el) return;
|
|
3894
4040
|
if (colorScheme === "auto") return;
|
|
@@ -3903,8 +4049,8 @@ function ThemeProvider({
|
|
|
3903
4049
|
}
|
|
3904
4050
|
el.classList.toggle("dark", colorScheme === "dark");
|
|
3905
4051
|
}, [colorScheme]);
|
|
3906
|
-
const lightVars =
|
|
3907
|
-
const darkVarStr =
|
|
4052
|
+
const lightVars = React14.useMemo(() => toCssVars(theme), [theme]);
|
|
4053
|
+
const darkVarStr = React14.useMemo(() => {
|
|
3908
4054
|
if (!darkTheme) return "";
|
|
3909
4055
|
const dvars = toCssVars(darkTheme);
|
|
3910
4056
|
if (!Object.keys(dvars).length) return "";
|
|
@@ -3944,7 +4090,7 @@ function TextInput({
|
|
|
3944
4090
|
prefix,
|
|
3945
4091
|
suffix
|
|
3946
4092
|
}) {
|
|
3947
|
-
const errorId =
|
|
4093
|
+
const errorId = React14.useId();
|
|
3948
4094
|
const hasError = errorMessage != null;
|
|
3949
4095
|
const hasAdornment = prefix != null || suffix != null;
|
|
3950
4096
|
const input = /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4014,7 +4160,7 @@ function NumberInput({
|
|
|
4014
4160
|
readOnly = false,
|
|
4015
4161
|
precision
|
|
4016
4162
|
}) {
|
|
4017
|
-
const errorId =
|
|
4163
|
+
const errorId = React14.useId();
|
|
4018
4164
|
const hasError = errorMessage != null;
|
|
4019
4165
|
const inferredPrecision = precision ?? (Number.isInteger(step) ? 0 : String(step).split(".")[1]?.length ?? 0);
|
|
4020
4166
|
const round = (n) => {
|
|
@@ -4145,8 +4291,8 @@ function Password({
|
|
|
4145
4291
|
showIcon,
|
|
4146
4292
|
hideIcon
|
|
4147
4293
|
}) {
|
|
4148
|
-
const [visible, setVisible] =
|
|
4149
|
-
const errorId =
|
|
4294
|
+
const [visible, setVisible] = React14.useState(false);
|
|
4295
|
+
const errorId = React14.useId();
|
|
4150
4296
|
const hasError = errorMessage != null;
|
|
4151
4297
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4152
4298
|
Field,
|
|
@@ -4219,7 +4365,7 @@ function Checkbox({
|
|
|
4219
4365
|
}) {
|
|
4220
4366
|
const isChecked = checked ?? value ?? false;
|
|
4221
4367
|
const labelFirst = labelPosition === "left";
|
|
4222
|
-
const errorId =
|
|
4368
|
+
const errorId = React14.useId();
|
|
4223
4369
|
const hasError = errorMessage != null;
|
|
4224
4370
|
const box = /* @__PURE__ */ jsxRuntime.jsx(
|
|
4225
4371
|
CheckboxPrimitive__namespace.Root,
|
|
@@ -4327,8 +4473,8 @@ function RadioGroup({
|
|
|
4327
4473
|
className,
|
|
4328
4474
|
errorMessage
|
|
4329
4475
|
}) {
|
|
4330
|
-
const errorId =
|
|
4331
|
-
const groupId =
|
|
4476
|
+
const errorId = React14.useId();
|
|
4477
|
+
const groupId = React14.useId();
|
|
4332
4478
|
const hasError = errorMessage != null;
|
|
4333
4479
|
const labelFirst = labelPosition === "left";
|
|
4334
4480
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4428,11 +4574,11 @@ function Switch({
|
|
|
4428
4574
|
disabled,
|
|
4429
4575
|
errorMessage
|
|
4430
4576
|
}) {
|
|
4431
|
-
const id =
|
|
4432
|
-
const errorId =
|
|
4577
|
+
const id = React14.useId();
|
|
4578
|
+
const errorId = React14.useId();
|
|
4433
4579
|
const hasError = errorMessage != null;
|
|
4434
4580
|
const isControlled = checked !== void 0;
|
|
4435
|
-
const [internal, setInternal] =
|
|
4581
|
+
const [internal, setInternal] = React14.useState(defaultChecked);
|
|
4436
4582
|
const isOn = isControlled ? checked : internal;
|
|
4437
4583
|
const handle = (c) => {
|
|
4438
4584
|
if (!isControlled) setInternal(c);
|
|
@@ -4505,19 +4651,19 @@ function AutoComplete({
|
|
|
4505
4651
|
required,
|
|
4506
4652
|
htmlFor
|
|
4507
4653
|
}) {
|
|
4508
|
-
const errorId =
|
|
4654
|
+
const errorId = React14.useId();
|
|
4509
4655
|
const hasError = errorMessage != null;
|
|
4510
|
-
const [term, setTerm] =
|
|
4511
|
-
const [open, setOpen] =
|
|
4512
|
-
const [asyncItems, setAsyncItems] =
|
|
4513
|
-
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);
|
|
4514
4660
|
const isAsync = typeof onSearch === "function";
|
|
4515
|
-
const debounceRef =
|
|
4516
|
-
const requestIdRef =
|
|
4661
|
+
const debounceRef = React14.useRef(null);
|
|
4662
|
+
const requestIdRef = React14.useRef(0);
|
|
4517
4663
|
const staticFiltered = isAsync || !items ? [] : term.trim() ? items.filter(
|
|
4518
4664
|
({ key, label: label2 }) => label2.toLowerCase().includes(term.toLowerCase()) || key.toLowerCase().includes(term.toLowerCase())
|
|
4519
4665
|
) : [];
|
|
4520
|
-
|
|
4666
|
+
React14.useEffect(() => {
|
|
4521
4667
|
if (!isAsync) return;
|
|
4522
4668
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
4523
4669
|
if (!term.trim()) {
|
|
@@ -4673,15 +4819,15 @@ function TreeSelect({
|
|
|
4673
4819
|
defaultExpandedKeys = [],
|
|
4674
4820
|
size = "md"
|
|
4675
4821
|
}) {
|
|
4676
|
-
const errorId =
|
|
4822
|
+
const errorId = React14.useId();
|
|
4677
4823
|
const hasError = errorMessage != null;
|
|
4678
|
-
const [open, setOpen] =
|
|
4679
|
-
const [expanded, setExpanded] =
|
|
4680
|
-
const [activeIndex, setActiveIndex] =
|
|
4681
|
-
const listRef =
|
|
4682
|
-
const visible =
|
|
4683
|
-
const didSyncOnOpenRef =
|
|
4684
|
-
|
|
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(() => {
|
|
4685
4831
|
if (!open) {
|
|
4686
4832
|
didSyncOnOpenRef.current = false;
|
|
4687
4833
|
return;
|
|
@@ -4691,7 +4837,7 @@ function TreeSelect({
|
|
|
4691
4837
|
setActiveIndex(selectedIdx >= 0 ? selectedIdx : 0);
|
|
4692
4838
|
didSyncOnOpenRef.current = true;
|
|
4693
4839
|
}, [open, value]);
|
|
4694
|
-
const selectedNode =
|
|
4840
|
+
const selectedNode = React14.useMemo(
|
|
4695
4841
|
() => value != null ? findNodeByKey(items, value) : null,
|
|
4696
4842
|
[items, value]
|
|
4697
4843
|
);
|
|
@@ -4922,11 +5068,11 @@ function FileInput({
|
|
|
4922
5068
|
required,
|
|
4923
5069
|
icon
|
|
4924
5070
|
}) {
|
|
4925
|
-
const inputRef =
|
|
4926
|
-
const errorId =
|
|
4927
|
-
const [files, setFiles] =
|
|
4928
|
-
const [dragging, setDragging] =
|
|
4929
|
-
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);
|
|
4930
5076
|
const effectiveError = errorMessage ?? sizeError ?? void 0;
|
|
4931
5077
|
const openPicker = () => {
|
|
4932
5078
|
if (!disabled) inputRef.current?.click();
|
|
@@ -5117,30 +5263,30 @@ function DatePicker({
|
|
|
5117
5263
|
size = "md",
|
|
5118
5264
|
className = ""
|
|
5119
5265
|
}) {
|
|
5120
|
-
const errorId =
|
|
5266
|
+
const errorId = React14.useId();
|
|
5121
5267
|
const hasError = errorMessage != null;
|
|
5122
|
-
const [open, setOpen] =
|
|
5123
|
-
const [viewMonth, setViewMonth] =
|
|
5124
|
-
const [focusDate, setFocusDate] =
|
|
5125
|
-
const [view, setView] =
|
|
5126
|
-
const gridRef =
|
|
5127
|
-
|
|
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(() => {
|
|
5128
5274
|
if (!open) return;
|
|
5129
5275
|
const target = value ?? /* @__PURE__ */ new Date();
|
|
5130
5276
|
setViewMonth(startOfMonth(target));
|
|
5131
5277
|
setFocusDate(target);
|
|
5132
5278
|
setView("days");
|
|
5133
5279
|
}, [open, value]);
|
|
5134
|
-
|
|
5280
|
+
React14.useEffect(() => {
|
|
5135
5281
|
if (!open) return;
|
|
5136
5282
|
const cell = gridRef.current?.querySelector(`[data-day="${defaultFormat(focusDate)}"]`);
|
|
5137
5283
|
cell?.focus();
|
|
5138
5284
|
}, [open, focusDate]);
|
|
5139
|
-
const weekdays =
|
|
5285
|
+
const weekdays = React14.useMemo(() => {
|
|
5140
5286
|
const ordered = WEEKDAY_SHORT.slice(weekStartsOn).concat(WEEKDAY_SHORT.slice(0, weekStartsOn));
|
|
5141
5287
|
return ordered;
|
|
5142
5288
|
}, [weekStartsOn]);
|
|
5143
|
-
const grid =
|
|
5289
|
+
const grid = React14.useMemo(() => buildGrid(viewMonth, weekStartsOn), [viewMonth, weekStartsOn]);
|
|
5144
5290
|
const isDisabled = (d) => {
|
|
5145
5291
|
if (min && d < min) return true;
|
|
5146
5292
|
if (max && d > max) return true;
|
|
@@ -5430,10 +5576,10 @@ function TextArea({
|
|
|
5430
5576
|
style,
|
|
5431
5577
|
inputStyle
|
|
5432
5578
|
}) {
|
|
5433
|
-
const errorId =
|
|
5579
|
+
const errorId = React14.useId();
|
|
5434
5580
|
const hasError = errorMessage != null;
|
|
5435
|
-
const ref =
|
|
5436
|
-
|
|
5581
|
+
const ref = React14.useRef(null);
|
|
5582
|
+
React14.useLayoutEffect(() => {
|
|
5437
5583
|
if (!autoGrow) return;
|
|
5438
5584
|
const el = ref.current;
|
|
5439
5585
|
if (!el) return;
|
|
@@ -5503,11 +5649,11 @@ function SegmentedControl({
|
|
|
5503
5649
|
"aria-label": ariaLabel
|
|
5504
5650
|
}) {
|
|
5505
5651
|
const sz = SIZE2[size];
|
|
5506
|
-
const groupId =
|
|
5507
|
-
const errorId =
|
|
5652
|
+
const groupId = React14.useId();
|
|
5653
|
+
const errorId = React14.useId();
|
|
5508
5654
|
const hasError = errorMessage != null;
|
|
5509
5655
|
const isControlled = value !== void 0;
|
|
5510
|
-
const [internal, setInternal] =
|
|
5656
|
+
const [internal, setInternal] = React14.useState(defaultValue);
|
|
5511
5657
|
const current = isControlled ? value : internal;
|
|
5512
5658
|
const handle = (v) => {
|
|
5513
5659
|
if (!v) return;
|
|
@@ -5601,14 +5747,14 @@ function Slider({
|
|
|
5601
5747
|
name,
|
|
5602
5748
|
htmlFor
|
|
5603
5749
|
}) {
|
|
5604
|
-
const errorId =
|
|
5750
|
+
const errorId = React14.useId();
|
|
5605
5751
|
const hasError = errorMessage != null;
|
|
5606
5752
|
const isRange = Array.isArray(value ?? defaultValue);
|
|
5607
|
-
const [internal, setInternal] =
|
|
5753
|
+
const [internal, setInternal] = React14.useState(
|
|
5608
5754
|
() => toArray(value) ?? toArray(defaultValue) ?? [min]
|
|
5609
5755
|
);
|
|
5610
5756
|
const current = toArray(value) ?? internal;
|
|
5611
|
-
const [dragging, setDragging] =
|
|
5757
|
+
const [dragging, setDragging] = React14.useState(false);
|
|
5612
5758
|
const emit = (arr) => {
|
|
5613
5759
|
setInternal(arr);
|
|
5614
5760
|
const next = isRange ? [arr[0], arr[1]] : arr[0];
|
|
@@ -5703,11 +5849,11 @@ function TagsInput({
|
|
|
5703
5849
|
validate,
|
|
5704
5850
|
separators = ["Enter", ","]
|
|
5705
5851
|
}) {
|
|
5706
|
-
const errorId =
|
|
5707
|
-
const inputRef =
|
|
5708
|
-
const [internal, setInternal] =
|
|
5709
|
-
const [draft, setDraft] =
|
|
5710
|
-
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);
|
|
5711
5857
|
const tags = value ?? internal;
|
|
5712
5858
|
const hasError = errorMessage != null || localError != null;
|
|
5713
5859
|
const errorText = errorMessage ?? localError ?? void 0;
|
|
@@ -5838,9 +5984,9 @@ function OtpInput({
|
|
|
5838
5984
|
className,
|
|
5839
5985
|
groupAfter
|
|
5840
5986
|
}) {
|
|
5841
|
-
const errorId =
|
|
5987
|
+
const errorId = React14.useId();
|
|
5842
5988
|
const hasError = errorMessage != null;
|
|
5843
|
-
const refs =
|
|
5989
|
+
const refs = React14.useRef([]);
|
|
5844
5990
|
const chars = Array.from({ length }, (_, i) => value[i] ?? "");
|
|
5845
5991
|
const pattern = mode === "numeric" ? /[0-9]/ : /[a-zA-Z0-9]/;
|
|
5846
5992
|
const emit = (next) => {
|
|
@@ -5889,7 +6035,7 @@ function OtpInput({
|
|
|
5889
6035
|
emit(valid.join(""));
|
|
5890
6036
|
focusBox(valid.length);
|
|
5891
6037
|
};
|
|
5892
|
-
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: [
|
|
5893
6039
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5894
6040
|
"input",
|
|
5895
6041
|
{
|
|
@@ -5947,9 +6093,9 @@ function Rating({
|
|
|
5947
6093
|
className,
|
|
5948
6094
|
required
|
|
5949
6095
|
}) {
|
|
5950
|
-
const errorId =
|
|
5951
|
-
const [internal, setInternal] =
|
|
5952
|
-
const [hover, setHover] =
|
|
6096
|
+
const errorId = React14.useId();
|
|
6097
|
+
const [internal, setInternal] = React14.useState(defaultValue);
|
|
6098
|
+
const [hover, setHover] = React14.useState(null);
|
|
5953
6099
|
const current = value ?? internal;
|
|
5954
6100
|
const display2 = hover ?? current;
|
|
5955
6101
|
const interactive = !readOnly && !disabled;
|
|
@@ -6072,9 +6218,9 @@ function TimePicker({
|
|
|
6072
6218
|
required,
|
|
6073
6219
|
style
|
|
6074
6220
|
}) {
|
|
6075
|
-
const errorId =
|
|
6221
|
+
const errorId = React14.useId();
|
|
6076
6222
|
const hasError = errorMessage != null;
|
|
6077
|
-
const [open, setOpen] =
|
|
6223
|
+
const [open, setOpen] = React14.useState(false);
|
|
6078
6224
|
const parsed = parse(value) ?? { h: 0, m: 0, s: 0 };
|
|
6079
6225
|
const update = (next) => {
|
|
6080
6226
|
const merged = { ...parsed, ...next };
|
|
@@ -6198,13 +6344,13 @@ function DateRangePicker({
|
|
|
6198
6344
|
required,
|
|
6199
6345
|
style
|
|
6200
6346
|
}) {
|
|
6201
|
-
const errorId =
|
|
6347
|
+
const errorId = React14.useId();
|
|
6202
6348
|
const hasError = errorMessage != null;
|
|
6203
|
-
const [open, setOpen] =
|
|
6204
|
-
const [leftMonth, setLeftMonth] =
|
|
6205
|
-
const [pendingStart, setPendingStart] =
|
|
6206
|
-
const [hoverDate, setHoverDate] =
|
|
6207
|
-
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(
|
|
6208
6354
|
() => WEEKDAY.slice(weekStartsOn).concat(WEEKDAY.slice(0, weekStartsOn)),
|
|
6209
6355
|
[weekStartsOn]
|
|
6210
6356
|
);
|
|
@@ -6380,10 +6526,10 @@ function ColorPicker({
|
|
|
6380
6526
|
required,
|
|
6381
6527
|
placeholder = "Pick a colour\u2026"
|
|
6382
6528
|
}) {
|
|
6383
|
-
const errorId =
|
|
6529
|
+
const errorId = React14.useId();
|
|
6384
6530
|
const hasError = errorMessage != null;
|
|
6385
|
-
const [open, setOpen] =
|
|
6386
|
-
const [draft, setDraft] =
|
|
6531
|
+
const [open, setOpen] = React14.useState(false);
|
|
6532
|
+
const [draft, setDraft] = React14.useState(value);
|
|
6387
6533
|
const valid = HEX_RE.test(value);
|
|
6388
6534
|
const pick = (hex) => {
|
|
6389
6535
|
onChange?.(hex);
|
|
@@ -6770,11 +6916,11 @@ function buildBindings(store, name, kind, snap) {
|
|
|
6770
6916
|
|
|
6771
6917
|
// src/form/useForm.ts
|
|
6772
6918
|
function useForm(options = {}) {
|
|
6773
|
-
const ref =
|
|
6919
|
+
const ref = React14.useRef(null);
|
|
6774
6920
|
if (ref.current === null) ref.current = new FormStore(options);
|
|
6775
6921
|
const store = ref.current;
|
|
6776
|
-
|
|
6777
|
-
const make =
|
|
6922
|
+
React14.useSyncExternalStore(store.subscribe, store.getRootSnapshot, store.getRootSnapshot);
|
|
6923
|
+
const make = React14.useCallback(
|
|
6778
6924
|
(kind) => (name, rules) => {
|
|
6779
6925
|
if (rules !== void 0) store.setRule(name, rules);
|
|
6780
6926
|
return buildBindings(store, name, kind, store.getFieldSnapshot(name));
|
|
@@ -6803,9 +6949,9 @@ function useForm(options = {}) {
|
|
|
6803
6949
|
fieldTarget: make("target")
|
|
6804
6950
|
};
|
|
6805
6951
|
}
|
|
6806
|
-
var FormContext =
|
|
6952
|
+
var FormContext = React14.createContext(null);
|
|
6807
6953
|
function useFormStore() {
|
|
6808
|
-
const store =
|
|
6954
|
+
const store = React14.useContext(FormContext);
|
|
6809
6955
|
if (!store) {
|
|
6810
6956
|
throw new Error("useFormStore must be used within a <Form>. Did you forget to wrap your fields?");
|
|
6811
6957
|
}
|
|
@@ -6819,8 +6965,8 @@ function Form({
|
|
|
6819
6965
|
children,
|
|
6820
6966
|
...rest
|
|
6821
6967
|
}) {
|
|
6822
|
-
const ref =
|
|
6823
|
-
const bypass =
|
|
6968
|
+
const ref = React14.useRef(null);
|
|
6969
|
+
const bypass = React14.useRef(false);
|
|
6824
6970
|
const handleSubmit = async (e) => {
|
|
6825
6971
|
if (bypass.current) {
|
|
6826
6972
|
bypass.current = false;
|
|
@@ -6872,12 +7018,12 @@ function useFormField(name, options = {}) {
|
|
|
6872
7018
|
const store = useFormStore();
|
|
6873
7019
|
const { kind = "value", rules } = options;
|
|
6874
7020
|
if (rules !== void 0 && store.getRule(name) !== rules) store.setRule(name, rules);
|
|
6875
|
-
|
|
7021
|
+
React14.useEffect(() => {
|
|
6876
7022
|
return () => {
|
|
6877
7023
|
if (rules !== void 0) store.removeRule(name);
|
|
6878
7024
|
};
|
|
6879
7025
|
}, [store, name]);
|
|
6880
|
-
const snap =
|
|
7026
|
+
const snap = React14.useSyncExternalStore(
|
|
6881
7027
|
store.subscribe,
|
|
6882
7028
|
() => store.getFieldSnapshot(name)
|
|
6883
7029
|
);
|
|
@@ -6889,7 +7035,7 @@ function FormField({ name, kind, rules, children }) {
|
|
|
6889
7035
|
}
|
|
6890
7036
|
function useFieldArray(name) {
|
|
6891
7037
|
const store = useFormStore();
|
|
6892
|
-
|
|
7038
|
+
React14.useSyncExternalStore(store.subscribe, store.getRootSnapshot, store.getRootSnapshot);
|
|
6893
7039
|
const arr = store.getValue(name) ?? [];
|
|
6894
7040
|
const keys = store.getKeys(name);
|
|
6895
7041
|
return {
|
|
@@ -7012,7 +7158,7 @@ function CreditCardForm({
|
|
|
7012
7158
|
className = "",
|
|
7013
7159
|
style
|
|
7014
7160
|
}) {
|
|
7015
|
-
const initial =
|
|
7161
|
+
const initial = React14.useRef({
|
|
7016
7162
|
number: formatCardNumber(defaultValue?.number ?? ""),
|
|
7017
7163
|
name: defaultValue?.name ?? "",
|
|
7018
7164
|
expiry: formatExpiry(defaultValue?.expiry ?? ""),
|
|
@@ -7021,7 +7167,7 @@ function CreditCardForm({
|
|
|
7021
7167
|
const form = useForm({ initialValues: initial });
|
|
7022
7168
|
const numberStr = String(form.values.number ?? "");
|
|
7023
7169
|
const brand = detectBrand(numberStr);
|
|
7024
|
-
|
|
7170
|
+
React14.useEffect(() => {
|
|
7025
7171
|
onChange?.(toCard(form.values));
|
|
7026
7172
|
}, [form.values.number, form.values.name, form.values.expiry, form.values.cvv]);
|
|
7027
7173
|
const numberBind = form.fieldNative("number", {
|
|
@@ -7119,10 +7265,12 @@ Object.defineProperty(exports, "vars", {
|
|
|
7119
7265
|
enumerable: true,
|
|
7120
7266
|
get: function () { return chunk255PCZIW_cjs.vars; }
|
|
7121
7267
|
});
|
|
7268
|
+
exports.Accordion = Accordion_default;
|
|
7122
7269
|
exports.AppShell = AppShell;
|
|
7123
7270
|
exports.AutoComplete = AutoComplete;
|
|
7124
7271
|
exports.Avatar = Avatar;
|
|
7125
7272
|
exports.Box = Box;
|
|
7273
|
+
exports.Breadcrumbs = Breadcrumbs;
|
|
7126
7274
|
exports.Button = Button;
|
|
7127
7275
|
exports.CARD_BRANDS = CARD_BRANDS;
|
|
7128
7276
|
exports.Catalog = Catalog;
|