@geomak/ui 6.6.0 → 6.7.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 +333 -195
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +107 -1
- package/dist/index.d.ts +107 -1
- package/dist/index.js +147 -11
- package/dist/index.js.map +1 -1
- package/dist/styles.css +72 -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 React16 = 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 React16__default = /*#__PURE__*/_interopDefault(React16);
|
|
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] = React16.useState(null);
|
|
218
|
+
React16.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 = React16.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 = React16.createContext(null);
|
|
964
964
|
function useTabsContext() {
|
|
965
|
-
const ctx =
|
|
965
|
+
const ctx = React16.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] = React16.useState(defaultValue);
|
|
988
988
|
const current = isControlled ? value : internal;
|
|
989
989
|
const reduced = !!framerMotion.useReducedMotion();
|
|
990
|
-
const indicatorId =
|
|
991
|
-
const select =
|
|
990
|
+
const indicatorId = React16.useId();
|
|
991
|
+
const select = React16.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 = React16.useRef(/* @__PURE__ */ new Map());
|
|
996
|
+
const orderRef = React16.useRef(0);
|
|
997
|
+
const [, bump] = React16.useState(0);
|
|
998
|
+
const registerTab = React16.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 = React16.useCallback((val) => {
|
|
1004
1004
|
if (registry.current.delete(val)) bump((v) => v + 1);
|
|
1005
1005
|
}, []);
|
|
1006
|
-
const getTabs =
|
|
1006
|
+
const getTabs = React16.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 = React16.useRef(null);
|
|
1027
|
+
const [edges, setEdges] = React16.useState({ start: false, end: false });
|
|
1028
1028
|
const scrollable = variant !== "segmented";
|
|
1029
|
-
|
|
1029
|
+
React16.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 = React16.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
|
+
React16.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] = React16.useState(false);
|
|
1119
|
+
const wrapRef = React16.useRef(null);
|
|
1120
|
+
const timer = React16.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
|
+
React16.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
|
+
React16.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 = React16.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 } = React16.useContext(AccordionCtx);
|
|
1467
1467
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1468
1468
|
AccordionPrimitive__namespace.Item,
|
|
1469
1469
|
{
|
|
@@ -1522,7 +1522,7 @@ function Breadcrumbs({
|
|
|
1522
1522
|
className = "",
|
|
1523
1523
|
style
|
|
1524
1524
|
}) {
|
|
1525
|
-
const [expanded, setExpanded] =
|
|
1525
|
+
const [expanded, setExpanded] = React16.useState(false);
|
|
1526
1526
|
const shouldCollapse = maxItems > 0 && items.length > maxItems && !expanded;
|
|
1527
1527
|
const visible = [];
|
|
1528
1528
|
if (shouldCollapse) {
|
|
@@ -1666,14 +1666,150 @@ function Kbd({
|
|
|
1666
1666
|
style
|
|
1667
1667
|
}) {
|
|
1668
1668
|
if (keys && keys.length > 0) {
|
|
1669
|
-
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: ["inline-flex items-center gap-1", className].filter(Boolean).join(" "), style, children: keys.map((k, i) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1669
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: ["inline-flex items-center gap-1", className].filter(Boolean).join(" "), style, children: keys.map((k, i) => /* @__PURE__ */ jsxRuntime.jsxs(React16__default.default.Fragment, { children: [
|
|
1670
1670
|
i > 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground-muted text-xs select-none", children: separator }),
|
|
1671
1671
|
/* @__PURE__ */ jsxRuntime.jsx("kbd", { className: [cap, SIZE3[size]].join(" "), children: k })
|
|
1672
1672
|
] }, `${k}-${i}`)) });
|
|
1673
1673
|
}
|
|
1674
1674
|
return /* @__PURE__ */ jsxRuntime.jsx("kbd", { className: [cap, SIZE3[size], className].filter(Boolean).join(" "), style, children });
|
|
1675
1675
|
}
|
|
1676
|
-
var
|
|
1676
|
+
var PAD = { none: "", sm: "p-3", md: "p-5", lg: "p-6" };
|
|
1677
|
+
function Card({ children, interactive, onClick, padding: padding2 = "none", flush, className = "", style }) {
|
|
1678
|
+
const base = [
|
|
1679
|
+
"rounded-xl overflow-hidden bg-surface",
|
|
1680
|
+
flush ? "" : "border border-border shadow-sm",
|
|
1681
|
+
PAD[padding2],
|
|
1682
|
+
interactive ? "transition-[transform,box-shadow] duration-200 ease-out hover:-translate-y-0.5 hover:shadow-md cursor-pointer focus:outline-none focus-visible:ring-2 focus-visible:ring-accent" : "",
|
|
1683
|
+
className
|
|
1684
|
+
].filter(Boolean).join(" ");
|
|
1685
|
+
if (interactive && onClick) {
|
|
1686
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1687
|
+
"div",
|
|
1688
|
+
{
|
|
1689
|
+
role: "button",
|
|
1690
|
+
tabIndex: 0,
|
|
1691
|
+
onClick,
|
|
1692
|
+
onKeyDown: (e) => {
|
|
1693
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
1694
|
+
e.preventDefault();
|
|
1695
|
+
onClick(e);
|
|
1696
|
+
}
|
|
1697
|
+
},
|
|
1698
|
+
className: base,
|
|
1699
|
+
style,
|
|
1700
|
+
children
|
|
1701
|
+
}
|
|
1702
|
+
);
|
|
1703
|
+
}
|
|
1704
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { onClick, className: base, style, children });
|
|
1705
|
+
}
|
|
1706
|
+
function CardMedia({ children, className = "" }) {
|
|
1707
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: ["[&>img]:block [&>img]:w-full [&>img]:object-cover", className].filter(Boolean).join(" "), children });
|
|
1708
|
+
}
|
|
1709
|
+
function CardHeader({ title, subtitle, action, avatar, children, className = "" }) {
|
|
1710
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ["flex items-start gap-3 px-5 pt-5", children ? "pb-0" : "pb-3", className].filter(Boolean).join(" "), children: [
|
|
1711
|
+
avatar && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-shrink-0", children: avatar }),
|
|
1712
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
1713
|
+
title && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm font-semibold text-foreground leading-snug", children: title }),
|
|
1714
|
+
subtitle && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-foreground-muted leading-snug mt-0.5", children: subtitle }),
|
|
1715
|
+
children
|
|
1716
|
+
] }),
|
|
1717
|
+
action && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-shrink-0 -mt-1 -mr-1", children: action })
|
|
1718
|
+
] });
|
|
1719
|
+
}
|
|
1720
|
+
function CardBody({ children, className = "" }) {
|
|
1721
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: ["px-5 py-4 text-sm text-foreground-secondary leading-relaxed", className].filter(Boolean).join(" "), children });
|
|
1722
|
+
}
|
|
1723
|
+
function CardFooter({ children, noDivider, className = "" }) {
|
|
1724
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: ["flex items-center gap-2 px-5 py-3", noDivider ? "" : "border-t border-border", className].filter(Boolean).join(" "), children });
|
|
1725
|
+
}
|
|
1726
|
+
Card.Media = CardMedia;
|
|
1727
|
+
Card.Header = CardHeader;
|
|
1728
|
+
Card.Body = CardBody;
|
|
1729
|
+
Card.Footer = CardFooter;
|
|
1730
|
+
var Card_default = Card;
|
|
1731
|
+
var Arrow2 = ({ dir }) => /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, "aria-hidden": "true", className: "h-5 w-5", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: dir === "left" ? "M15 19l-7-7 7-7" : "M9 5l7 7-7 7" }) });
|
|
1732
|
+
function CardCarousel({
|
|
1733
|
+
children,
|
|
1734
|
+
itemWidth = 280,
|
|
1735
|
+
gap = 16,
|
|
1736
|
+
showArrows = true,
|
|
1737
|
+
showDots = false,
|
|
1738
|
+
"aria-label": ariaLabel = "Carousel",
|
|
1739
|
+
className = "",
|
|
1740
|
+
style
|
|
1741
|
+
}) {
|
|
1742
|
+
const scrollerRef = React16.useRef(null);
|
|
1743
|
+
const slides = React16__default.default.Children.toArray(children);
|
|
1744
|
+
const [active, setActive] = React16.useState(0);
|
|
1745
|
+
const [atStart, setAtStart] = React16.useState(true);
|
|
1746
|
+
const [atEnd, setAtEnd] = React16.useState(false);
|
|
1747
|
+
const width = typeof itemWidth === "number" ? `${itemWidth}px` : itemWidth;
|
|
1748
|
+
const update = React16.useCallback(() => {
|
|
1749
|
+
const el = scrollerRef.current;
|
|
1750
|
+
if (!el) return;
|
|
1751
|
+
el.clientWidth;
|
|
1752
|
+
setAtStart(el.scrollLeft <= 1);
|
|
1753
|
+
setAtEnd(el.scrollLeft + el.clientWidth >= el.scrollWidth - 1);
|
|
1754
|
+
const first = el.firstElementChild;
|
|
1755
|
+
const slideW = first ? first.getBoundingClientRect().width + gap : el.clientWidth;
|
|
1756
|
+
setActive(Math.round(el.scrollLeft / slideW));
|
|
1757
|
+
}, [gap]);
|
|
1758
|
+
React16.useEffect(() => {
|
|
1759
|
+
update();
|
|
1760
|
+
const el = scrollerRef.current;
|
|
1761
|
+
if (!el) return;
|
|
1762
|
+
el.addEventListener("scroll", update, { passive: true });
|
|
1763
|
+
window.addEventListener("resize", update);
|
|
1764
|
+
return () => {
|
|
1765
|
+
el.removeEventListener("scroll", update);
|
|
1766
|
+
window.removeEventListener("resize", update);
|
|
1767
|
+
};
|
|
1768
|
+
}, [update]);
|
|
1769
|
+
const scrollByDir = (dir) => {
|
|
1770
|
+
const el = scrollerRef.current;
|
|
1771
|
+
if (!el) return;
|
|
1772
|
+
const first = el.firstElementChild;
|
|
1773
|
+
const slideW = first ? first.getBoundingClientRect().width + gap : el.clientWidth;
|
|
1774
|
+
el.scrollBy({ left: dir * slideW, behavior: "smooth" });
|
|
1775
|
+
};
|
|
1776
|
+
const scrollTo = (i) => {
|
|
1777
|
+
const el = scrollerRef.current;
|
|
1778
|
+
if (!el) return;
|
|
1779
|
+
const first = el.firstElementChild;
|
|
1780
|
+
const slideW = first ? first.getBoundingClientRect().width + gap : el.clientWidth;
|
|
1781
|
+
el.scrollTo({ left: i * slideW, behavior: "smooth" });
|
|
1782
|
+
};
|
|
1783
|
+
const arrowBtn = "absolute top-1/2 -translate-y-1/2 z-10 flex h-9 w-9 items-center justify-center rounded-full border border-border bg-surface text-foreground-secondary shadow-md transition hover:text-foreground hover:bg-surface-raised disabled:opacity-0 disabled:pointer-events-none focus:outline-none focus-visible:ring-2 focus-visible:ring-accent";
|
|
1784
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("section", { "aria-label": ariaLabel, className: ["relative", className].filter(Boolean).join(" "), style, children: [
|
|
1785
|
+
showArrows && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", "aria-label": "Previous", onClick: () => scrollByDir(-1), disabled: atStart, className: `${arrowBtn} left-1`, children: /* @__PURE__ */ jsxRuntime.jsx(Arrow2, { dir: "left" }) }),
|
|
1786
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1787
|
+
"div",
|
|
1788
|
+
{
|
|
1789
|
+
ref: scrollerRef,
|
|
1790
|
+
className: "flex overflow-x-auto snap-x snap-mandatory hidden-scrollbar scroll-smooth",
|
|
1791
|
+
style: { gap },
|
|
1792
|
+
children: slides.map((slide, i) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "snap-start flex-shrink-0", style: { width }, children: slide }, i))
|
|
1793
|
+
}
|
|
1794
|
+
),
|
|
1795
|
+
showArrows && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", "aria-label": "Next", onClick: () => scrollByDir(1), disabled: atEnd, className: `${arrowBtn} right-1`, children: /* @__PURE__ */ jsxRuntime.jsx(Arrow2, { dir: "right" }) }),
|
|
1796
|
+
showDots && slides.length > 1 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3 flex items-center justify-center gap-1.5", children: slides.map((_, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1797
|
+
"button",
|
|
1798
|
+
{
|
|
1799
|
+
type: "button",
|
|
1800
|
+
"aria-label": `Go to slide ${i + 1}`,
|
|
1801
|
+
"aria-current": i === active,
|
|
1802
|
+
onClick: () => scrollTo(i),
|
|
1803
|
+
className: [
|
|
1804
|
+
"h-1.5 rounded-full transition-all duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-accent",
|
|
1805
|
+
i === active ? "w-5 bg-accent" : "w-1.5 bg-border hover:bg-foreground-muted"
|
|
1806
|
+
].join(" ")
|
|
1807
|
+
},
|
|
1808
|
+
i
|
|
1809
|
+
)) })
|
|
1810
|
+
] });
|
|
1811
|
+
}
|
|
1812
|
+
var NotificationContext = React16.createContext({
|
|
1677
1813
|
open: () => void 0,
|
|
1678
1814
|
close: () => void 0
|
|
1679
1815
|
});
|
|
@@ -1731,26 +1867,26 @@ function NotificationItem({
|
|
|
1731
1867
|
onClose,
|
|
1732
1868
|
reduced
|
|
1733
1869
|
}) {
|
|
1734
|
-
const [paused, setPaused] =
|
|
1870
|
+
const [paused, setPaused] = React16.useState(false);
|
|
1735
1871
|
const duration = n.duration ?? 4e3;
|
|
1736
1872
|
const isAutoDismissing = isFinite(duration) && duration > 0;
|
|
1737
1873
|
const showProgress = !reduced && isAutoDismissing;
|
|
1738
|
-
const timerRef =
|
|
1739
|
-
const startTimeRef =
|
|
1740
|
-
const remainingRef =
|
|
1741
|
-
const clearTimer =
|
|
1874
|
+
const timerRef = React16.useRef(null);
|
|
1875
|
+
const startTimeRef = React16.useRef(0);
|
|
1876
|
+
const remainingRef = React16.useRef(duration);
|
|
1877
|
+
const clearTimer = React16.useCallback(() => {
|
|
1742
1878
|
if (timerRef.current !== null) {
|
|
1743
1879
|
clearTimeout(timerRef.current);
|
|
1744
1880
|
timerRef.current = null;
|
|
1745
1881
|
}
|
|
1746
1882
|
}, []);
|
|
1747
|
-
const scheduleDismiss =
|
|
1883
|
+
const scheduleDismiss = React16.useCallback((ms) => {
|
|
1748
1884
|
clearTimer();
|
|
1749
1885
|
if (!isAutoDismissing) return;
|
|
1750
1886
|
startTimeRef.current = Date.now();
|
|
1751
1887
|
timerRef.current = setTimeout(() => onClose(n.id), ms);
|
|
1752
1888
|
}, [clearTimer, isAutoDismissing, n.id, onClose]);
|
|
1753
|
-
|
|
1889
|
+
React16.useEffect(() => {
|
|
1754
1890
|
if (paused || !isAutoDismissing) return;
|
|
1755
1891
|
scheduleDismiss(remainingRef.current);
|
|
1756
1892
|
return clearTimer;
|
|
@@ -1833,15 +1969,15 @@ function NotificationProvider({
|
|
|
1833
1969
|
children,
|
|
1834
1970
|
position = "top-right"
|
|
1835
1971
|
}) {
|
|
1836
|
-
const [notifications, setNotifications] =
|
|
1972
|
+
const [notifications, setNotifications] = React16.useState([]);
|
|
1837
1973
|
const reduced = framerMotion.useReducedMotion();
|
|
1838
|
-
const open =
|
|
1974
|
+
const open = React16.useCallback((payload) => {
|
|
1839
1975
|
setNotifications((prev) => [
|
|
1840
1976
|
...prev,
|
|
1841
1977
|
{ duration: 4e3, ...payload, id: Date.now() + Math.random() }
|
|
1842
1978
|
]);
|
|
1843
1979
|
}, []);
|
|
1844
|
-
const close =
|
|
1980
|
+
const close = React16.useCallback((id) => {
|
|
1845
1981
|
setNotifications((prev) => prev.filter((n) => n.id !== id));
|
|
1846
1982
|
}, []);
|
|
1847
1983
|
return /* @__PURE__ */ jsxRuntime.jsxs(NotificationContext.Provider, { value: { open, close }, children: [
|
|
@@ -1870,7 +2006,7 @@ function NotificationProvider({
|
|
|
1870
2006
|
] });
|
|
1871
2007
|
}
|
|
1872
2008
|
function useNotification() {
|
|
1873
|
-
const { open } =
|
|
2009
|
+
const { open } = React16.useContext(NotificationContext);
|
|
1874
2010
|
return {
|
|
1875
2011
|
info: (props) => open({ type: "info", ...props }),
|
|
1876
2012
|
success: (props) => open({ type: "success", ...props }),
|
|
@@ -1987,10 +2123,10 @@ function FadingBase({
|
|
|
1987
2123
|
isMounted = false,
|
|
1988
2124
|
children
|
|
1989
2125
|
}) {
|
|
1990
|
-
const [shouldRender, setShouldRender] =
|
|
1991
|
-
const [visible, setVisible] =
|
|
1992
|
-
const timerRef =
|
|
1993
|
-
|
|
2126
|
+
const [shouldRender, setShouldRender] = React16.useState(isMounted);
|
|
2127
|
+
const [visible, setVisible] = React16.useState(false);
|
|
2128
|
+
const timerRef = React16.useRef(null);
|
|
2129
|
+
React16.useEffect(() => {
|
|
1994
2130
|
if (isMounted) {
|
|
1995
2131
|
setShouldRender(true);
|
|
1996
2132
|
const rafId = requestAnimationFrame(() => setVisible(true));
|
|
@@ -2088,8 +2224,8 @@ function ScalableContainer({
|
|
|
2088
2224
|
togglePosition = "top-right",
|
|
2089
2225
|
className = ""
|
|
2090
2226
|
}) {
|
|
2091
|
-
const containerRef =
|
|
2092
|
-
const [internalScaled, setInternalScaled] =
|
|
2227
|
+
const containerRef = React16.useRef(null);
|
|
2228
|
+
const [internalScaled, setInternalScaled] = React16.useState(false);
|
|
2093
2229
|
const isScaled = expanded ?? internalScaled;
|
|
2094
2230
|
const reduced = framerMotion.useReducedMotion();
|
|
2095
2231
|
const onToggle = () => {
|
|
@@ -2227,17 +2363,17 @@ function CatalogGrid({ items, buttonText, onOpen, className = "" }) {
|
|
|
2227
2363
|
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)) });
|
|
2228
2364
|
}
|
|
2229
2365
|
function CatalogCarousel({ items, buttonText, onOpen, className = "" }) {
|
|
2230
|
-
const [activeIndex, setActiveIndex] =
|
|
2231
|
-
const [indexPool, setIndexPool] =
|
|
2232
|
-
const cardRefs =
|
|
2233
|
-
const getIndexes =
|
|
2366
|
+
const [activeIndex, setActiveIndex] = React16.useState(0);
|
|
2367
|
+
const [indexPool, setIndexPool] = React16.useState([]);
|
|
2368
|
+
const cardRefs = React16.useRef([]);
|
|
2369
|
+
const getIndexes = React16.useMemo(() => {
|
|
2234
2370
|
let nextIndex = activeIndex + 1;
|
|
2235
2371
|
let previousIndex = activeIndex - 1;
|
|
2236
2372
|
if (activeIndex === 0) previousIndex = items.length - 1;
|
|
2237
2373
|
if (activeIndex === items.length - 1) nextIndex = 0;
|
|
2238
2374
|
return { previousIndex, nextIndex };
|
|
2239
2375
|
}, [activeIndex, items.length]);
|
|
2240
|
-
|
|
2376
|
+
React16.useEffect(() => {
|
|
2241
2377
|
const { nextIndex, previousIndex } = getIndexes;
|
|
2242
2378
|
let indexes = [previousIndex, activeIndex, nextIndex];
|
|
2243
2379
|
if (activeIndex !== 0 && activeIndex !== items.length - 1) {
|
|
@@ -2410,8 +2546,8 @@ function writeDismissed(key) {
|
|
|
2410
2546
|
}
|
|
2411
2547
|
}
|
|
2412
2548
|
function useTargetBbox(ref) {
|
|
2413
|
-
const [bbox, setBbox] =
|
|
2414
|
-
|
|
2549
|
+
const [bbox, setBbox] = React16.useState(null);
|
|
2550
|
+
React16.useLayoutEffect(() => {
|
|
2415
2551
|
const el = ref?.current;
|
|
2416
2552
|
if (!el) {
|
|
2417
2553
|
setBbox(null);
|
|
@@ -2441,7 +2577,7 @@ function tooltipStyleFor(bbox, placement) {
|
|
|
2441
2577
|
return { left: bbox.left + bbox.width / 2, top: bbox.top - TOOLTIP_GAP, transform: "translate(-50%, -100%)", width: TOOLTIP_WIDTH };
|
|
2442
2578
|
}
|
|
2443
2579
|
function useFocusTrap(containerRef, active) {
|
|
2444
|
-
|
|
2580
|
+
React16.useEffect(() => {
|
|
2445
2581
|
if (!active) return;
|
|
2446
2582
|
const el = containerRef.current;
|
|
2447
2583
|
if (!el) return;
|
|
@@ -2480,16 +2616,16 @@ function Wizard({
|
|
|
2480
2616
|
onComplete,
|
|
2481
2617
|
onSkip
|
|
2482
2618
|
}) {
|
|
2483
|
-
const tooltipRef =
|
|
2484
|
-
const tooltipTitleId =
|
|
2485
|
-
const tooltipBodyId =
|
|
2619
|
+
const tooltipRef = React16.useRef(null);
|
|
2620
|
+
const tooltipTitleId = React16.useId();
|
|
2621
|
+
const tooltipBodyId = React16.useId();
|
|
2486
2622
|
const reduced = framerMotion.useReducedMotion();
|
|
2487
|
-
const [open, setOpen] =
|
|
2488
|
-
const [activeIndex, setActiveIndex] =
|
|
2623
|
+
const [open, setOpen] = React16.useState(() => steps.length > 0 && !readDismissed(storageKey));
|
|
2624
|
+
const [activeIndex, setActiveIndex] = React16.useState(0);
|
|
2489
2625
|
const step = steps[activeIndex];
|
|
2490
2626
|
const bbox = useTargetBbox(step?.stepRef);
|
|
2491
2627
|
useFocusTrap(tooltipRef, open);
|
|
2492
|
-
|
|
2628
|
+
React16.useEffect(() => {
|
|
2493
2629
|
if (!open || !dismissible) return;
|
|
2494
2630
|
const onKey = (e) => {
|
|
2495
2631
|
if (e.key === "Escape") {
|
|
@@ -2500,12 +2636,12 @@ function Wizard({
|
|
|
2500
2636
|
document.addEventListener("keydown", onKey);
|
|
2501
2637
|
return () => document.removeEventListener("keydown", onKey);
|
|
2502
2638
|
}, [open, dismissible]);
|
|
2503
|
-
const handleSkip =
|
|
2639
|
+
const handleSkip = React16.useCallback(() => {
|
|
2504
2640
|
writeDismissed(storageKey);
|
|
2505
2641
|
setOpen(false);
|
|
2506
2642
|
onSkip?.();
|
|
2507
2643
|
}, [storageKey, onSkip]);
|
|
2508
|
-
const handleComplete =
|
|
2644
|
+
const handleComplete = React16.useCallback(() => {
|
|
2509
2645
|
writeDismissed(storageKey);
|
|
2510
2646
|
setOpen(false);
|
|
2511
2647
|
onComplete?.();
|
|
@@ -2776,7 +2912,7 @@ function Field({
|
|
|
2776
2912
|
);
|
|
2777
2913
|
}
|
|
2778
2914
|
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" }) });
|
|
2779
|
-
var SearchInput =
|
|
2915
|
+
var SearchInput = React16__default.default.forwardRef(function SearchInput2({ value, onChange, disabled, label, htmlFor, placeholder, name, inputStyle, style, layout = "vertical", size = "md", icon, helperText, className }, ref) {
|
|
2780
2916
|
return /* @__PURE__ */ jsxRuntime.jsx(Field, { className, label, htmlFor, layout, helperText, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2781
2917
|
"div",
|
|
2782
2918
|
{
|
|
@@ -2830,11 +2966,11 @@ function MultiTagRow({
|
|
|
2830
2966
|
labelFor,
|
|
2831
2967
|
onRemove
|
|
2832
2968
|
}) {
|
|
2833
|
-
const wrapRef =
|
|
2834
|
-
const measureRef =
|
|
2835
|
-
const [visibleCount, setVisibleCount] =
|
|
2969
|
+
const wrapRef = React16.useRef(null);
|
|
2970
|
+
const measureRef = React16.useRef(null);
|
|
2971
|
+
const [visibleCount, setVisibleCount] = React16.useState(values.length);
|
|
2836
2972
|
const key = values.map(String).join("|");
|
|
2837
|
-
|
|
2973
|
+
React16.useLayoutEffect(() => {
|
|
2838
2974
|
const wrap = wrapRef.current;
|
|
2839
2975
|
const measure = measureRef.current;
|
|
2840
2976
|
if (!wrap || !measure) return;
|
|
@@ -2928,16 +3064,16 @@ function Dropdown({
|
|
|
2928
3064
|
size = "md",
|
|
2929
3065
|
className = ""
|
|
2930
3066
|
}) {
|
|
2931
|
-
const [open, setOpen] =
|
|
2932
|
-
const [selectedItems, setSelectedItems] =
|
|
2933
|
-
const [searchTerm, setSearchTerm] =
|
|
2934
|
-
const [innerItems, setInnerItems] =
|
|
2935
|
-
const errorId =
|
|
3067
|
+
const [open, setOpen] = React16.useState(false);
|
|
3068
|
+
const [selectedItems, setSelectedItems] = React16.useState([]);
|
|
3069
|
+
const [searchTerm, setSearchTerm] = React16.useState("");
|
|
3070
|
+
const [innerItems, setInnerItems] = React16.useState([]);
|
|
3071
|
+
const errorId = React16.useId();
|
|
2936
3072
|
const hasError = errorMessage != null;
|
|
2937
|
-
|
|
3073
|
+
React16.useEffect(() => {
|
|
2938
3074
|
setInnerItems(items);
|
|
2939
3075
|
}, [items]);
|
|
2940
|
-
|
|
3076
|
+
React16.useEffect(() => {
|
|
2941
3077
|
if (isMultiselect && Array.isArray(value)) {
|
|
2942
3078
|
setSelectedItems(value);
|
|
2943
3079
|
}
|
|
@@ -3262,7 +3398,7 @@ function TableBody({
|
|
|
3262
3398
|
expandRow,
|
|
3263
3399
|
getRowKey
|
|
3264
3400
|
}) {
|
|
3265
|
-
const [expanded, setExpanded] =
|
|
3401
|
+
const [expanded, setExpanded] = React16.useState(() => /* @__PURE__ */ new Set());
|
|
3266
3402
|
const reduced = framerMotion.useReducedMotion();
|
|
3267
3403
|
const toggleRow = (rowKey) => {
|
|
3268
3404
|
setExpanded((prev) => {
|
|
@@ -3277,7 +3413,7 @@ function TableBody({
|
|
|
3277
3413
|
return /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: rows.map((row, i) => {
|
|
3278
3414
|
const rowKey = getRowKey(row, i);
|
|
3279
3415
|
const isExpanded = expanded.has(rowKey);
|
|
3280
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3416
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(React16__default.default.Fragment, { children: [
|
|
3281
3417
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3282
3418
|
"tr",
|
|
3283
3419
|
{
|
|
@@ -3333,9 +3469,9 @@ function Pagination({
|
|
|
3333
3469
|
const matchedOption = picker.find(
|
|
3334
3470
|
(o) => o.label === options.perPage || o.value === options.perPage
|
|
3335
3471
|
);
|
|
3336
|
-
const [perPageKey, setPerPageKey] =
|
|
3472
|
+
const [perPageKey, setPerPageKey] = React16.useState(() => matchedOption?.key ?? picker[0]?.key);
|
|
3337
3473
|
const displayPerPageKey = serverSide ? matchedOption?.key ?? perPageKey : perPageKey;
|
|
3338
|
-
|
|
3474
|
+
React16.useEffect(() => {
|
|
3339
3475
|
if (serverSide && options.perPage != null) {
|
|
3340
3476
|
const next = picker.find((o) => o.label === options.perPage || o.value === options.perPage);
|
|
3341
3477
|
if (next) setPerPageKey(next.key);
|
|
@@ -3399,14 +3535,14 @@ function Table({
|
|
|
3399
3535
|
className = "",
|
|
3400
3536
|
style
|
|
3401
3537
|
}) {
|
|
3402
|
-
const searchRef =
|
|
3403
|
-
const [searchTerm, setSearchTerm] =
|
|
3404
|
-
const [perPage, setPerPage] =
|
|
3538
|
+
const searchRef = React16.useRef(null);
|
|
3539
|
+
const [searchTerm, setSearchTerm] = React16.useState("");
|
|
3540
|
+
const [perPage, setPerPage] = React16.useState(
|
|
3405
3541
|
typeof pagination.perPage === "number" ? pagination.perPage : 15
|
|
3406
3542
|
);
|
|
3407
|
-
const [activePage, setActivePage] =
|
|
3543
|
+
const [activePage, setActivePage] = React16.useState(0);
|
|
3408
3544
|
const isServerSide = !!(pagination.enabled && pagination.serverSide);
|
|
3409
|
-
const filteredRows =
|
|
3545
|
+
const filteredRows = React16.useMemo(() => {
|
|
3410
3546
|
if (isServerSide || !searchTerm) return rows;
|
|
3411
3547
|
const term = searchTerm.toLowerCase();
|
|
3412
3548
|
return rows.filter(
|
|
@@ -3415,29 +3551,29 @@ function Table({
|
|
|
3415
3551
|
)
|
|
3416
3552
|
);
|
|
3417
3553
|
}, [rows, searchTerm, isServerSide]);
|
|
3418
|
-
const datasets =
|
|
3554
|
+
const datasets = React16.useMemo(() => {
|
|
3419
3555
|
if (isServerSide) return [rows];
|
|
3420
3556
|
return createDatasets(filteredRows, pagination.enabled ? perPage : null);
|
|
3421
3557
|
}, [filteredRows, perPage, pagination.enabled, isServerSide, rows]);
|
|
3422
|
-
const MAX_PAGE =
|
|
3558
|
+
const MAX_PAGE = React16.useMemo(() => {
|
|
3423
3559
|
if (isServerSide && typeof pagination.maxPage === "number") return Math.max(0, pagination.maxPage);
|
|
3424
3560
|
if (isServerSide && typeof pagination.totalCount === "number")
|
|
3425
3561
|
return Math.max(0, Math.ceil(pagination.totalCount / perPage) - 1);
|
|
3426
3562
|
return datasets.length ? datasets.length - 1 : 0;
|
|
3427
3563
|
}, [isServerSide, pagination.maxPage, pagination.totalCount, perPage, datasets.length]);
|
|
3428
|
-
const currentPageRows =
|
|
3564
|
+
const currentPageRows = React16.useMemo(() => {
|
|
3429
3565
|
if (isServerSide) return rows;
|
|
3430
3566
|
return datasets[activePage] ?? [];
|
|
3431
3567
|
}, [isServerSide, rows, datasets, activePage]);
|
|
3432
|
-
|
|
3568
|
+
React16.useEffect(() => {
|
|
3433
3569
|
if (pagination.enabled && !isServerSide && typeof pagination.perPage === "number") {
|
|
3434
3570
|
setPerPage(pagination.perPage);
|
|
3435
3571
|
}
|
|
3436
3572
|
}, [pagination.enabled, pagination.perPage, isServerSide]);
|
|
3437
|
-
|
|
3573
|
+
React16.useEffect(() => {
|
|
3438
3574
|
if (isServerSide && typeof pagination.perPage === "number") setPerPage(pagination.perPage);
|
|
3439
3575
|
}, [isServerSide, pagination.perPage]);
|
|
3440
|
-
|
|
3576
|
+
React16.useEffect(() => {
|
|
3441
3577
|
if (isServerSide && typeof pagination.page === "number" && pagination.page >= 1)
|
|
3442
3578
|
setActivePage(pagination.page - 1);
|
|
3443
3579
|
}, [isServerSide, pagination.page]);
|
|
@@ -3521,7 +3657,7 @@ function TableSkeletonBody({
|
|
|
3521
3657
|
)) });
|
|
3522
3658
|
}
|
|
3523
3659
|
function ThemeSwitch({ checked, onChange, label = "Toggle dark mode", className = "" }) {
|
|
3524
|
-
const id =
|
|
3660
|
+
const id = React16.useId();
|
|
3525
3661
|
return /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: id, className: `flex items-center gap-2 cursor-pointer select-none ${className}`.trim(), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3526
3662
|
SwitchPrimitive__namespace.Root,
|
|
3527
3663
|
{
|
|
@@ -3705,7 +3841,7 @@ function Sidebar({
|
|
|
3705
3841
|
}
|
|
3706
3842
|
) });
|
|
3707
3843
|
}
|
|
3708
|
-
var MegaMenuContext =
|
|
3844
|
+
var MegaMenuContext = React16.createContext({ align: "start" });
|
|
3709
3845
|
function MegaMenu({
|
|
3710
3846
|
children,
|
|
3711
3847
|
align = "start",
|
|
@@ -3736,7 +3872,7 @@ function MegaMenu({
|
|
|
3736
3872
|
}
|
|
3737
3873
|
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";
|
|
3738
3874
|
function MegaMenuItem({ label, icon, href, children, className = "" }) {
|
|
3739
|
-
const { align } =
|
|
3875
|
+
const { align } = React16.useContext(MegaMenuContext);
|
|
3740
3876
|
const pos = align === "center" ? "left-1/2 -translate-x-1/2" : align === "end" ? "right-0" : "left-0";
|
|
3741
3877
|
if (!children) {
|
|
3742
3878
|
return /* @__PURE__ */ jsxRuntime.jsx(NavigationMenu__namespace.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs(NavigationMenu__namespace.Link, { href, className: [TOP_ITEM, className].filter(Boolean).join(" "), children: [
|
|
@@ -3821,8 +3957,8 @@ function MegaMenuLink({ href, icon, description, active, onClick, children, clas
|
|
|
3821
3957
|
function MegaMenuFeatured({ children, className = "" }) {
|
|
3822
3958
|
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 });
|
|
3823
3959
|
}
|
|
3824
|
-
var elementsOfType = (children, type) =>
|
|
3825
|
-
(c) =>
|
|
3960
|
+
var elementsOfType = (children, type) => React16__default.default.Children.toArray(children).filter(
|
|
3961
|
+
(c) => React16__default.default.isValidElement(c) && c.type === type
|
|
3826
3962
|
);
|
|
3827
3963
|
var MOBILE_CHEVRON = /* @__PURE__ */ jsxRuntime.jsx(
|
|
3828
3964
|
"svg",
|
|
@@ -3859,9 +3995,9 @@ function MobileLinkRow({ link, onNavigate }) {
|
|
|
3859
3995
|
);
|
|
3860
3996
|
}
|
|
3861
3997
|
function MobilePanel({ panel, onNavigate }) {
|
|
3862
|
-
const nodes =
|
|
3998
|
+
const nodes = React16__default.default.Children.toArray(panel.props.children);
|
|
3863
3999
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-4 px-2 pb-3 pt-1", children: nodes.map((node, i) => {
|
|
3864
|
-
if (!
|
|
4000
|
+
if (!React16__default.default.isValidElement(node)) return null;
|
|
3865
4001
|
const el = node;
|
|
3866
4002
|
if (el.type === MegaMenuSection) {
|
|
3867
4003
|
const { title, children } = el.props;
|
|
@@ -3880,8 +4016,8 @@ function MegaMenuMobile({
|
|
|
3880
4016
|
children,
|
|
3881
4017
|
label
|
|
3882
4018
|
}) {
|
|
3883
|
-
const [open, setOpen] =
|
|
3884
|
-
const [expanded, setExpanded] =
|
|
4019
|
+
const [open, setOpen] = React16.useState(false);
|
|
4020
|
+
const [expanded, setExpanded] = React16.useState(null);
|
|
3885
4021
|
const items = elementsOfType(children, MegaMenuItem);
|
|
3886
4022
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "md:hidden w-full", children: [
|
|
3887
4023
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -3954,17 +4090,17 @@ function AppShell({
|
|
|
3954
4090
|
children,
|
|
3955
4091
|
className = ""
|
|
3956
4092
|
}) {
|
|
3957
|
-
const [expanded, setExpanded] =
|
|
3958
|
-
const [isMobile, setIsMobile] =
|
|
3959
|
-
const [mobileOpen, setMobileOpen] =
|
|
3960
|
-
|
|
4093
|
+
const [expanded, setExpanded] = React16.useState(sidebarDefaultExpanded);
|
|
4094
|
+
const [isMobile, setIsMobile] = React16.useState(false);
|
|
4095
|
+
const [mobileOpen, setMobileOpen] = React16.useState(false);
|
|
4096
|
+
React16.useEffect(() => {
|
|
3961
4097
|
const mq = window.matchMedia("(max-width: 767px)");
|
|
3962
4098
|
const update = (e) => setIsMobile(e.matches);
|
|
3963
4099
|
update(mq);
|
|
3964
4100
|
mq.addEventListener("change", update);
|
|
3965
4101
|
return () => mq.removeEventListener("change", update);
|
|
3966
4102
|
}, []);
|
|
3967
|
-
|
|
4103
|
+
React16.useEffect(() => {
|
|
3968
4104
|
if (!isMobile) setMobileOpen(false);
|
|
3969
4105
|
}, [isMobile]);
|
|
3970
4106
|
const hasSidebar = sidebarSections.length > 0;
|
|
@@ -4154,10 +4290,10 @@ function ThemeProvider({
|
|
|
4154
4290
|
className = "",
|
|
4155
4291
|
style
|
|
4156
4292
|
}) {
|
|
4157
|
-
const id =
|
|
4293
|
+
const id = React16__default.default.useId().replace(/:/g, "");
|
|
4158
4294
|
const scopeClass = `geo-th-${id}`;
|
|
4159
|
-
const divRef =
|
|
4160
|
-
|
|
4295
|
+
const divRef = React16.useRef(null);
|
|
4296
|
+
React16.useEffect(() => {
|
|
4161
4297
|
const el = divRef.current;
|
|
4162
4298
|
if (!el) return;
|
|
4163
4299
|
if (colorScheme === "auto") return;
|
|
@@ -4172,8 +4308,8 @@ function ThemeProvider({
|
|
|
4172
4308
|
}
|
|
4173
4309
|
el.classList.toggle("dark", colorScheme === "dark");
|
|
4174
4310
|
}, [colorScheme]);
|
|
4175
|
-
const lightVars =
|
|
4176
|
-
const darkVarStr =
|
|
4311
|
+
const lightVars = React16.useMemo(() => toCssVars(theme), [theme]);
|
|
4312
|
+
const darkVarStr = React16.useMemo(() => {
|
|
4177
4313
|
if (!darkTheme) return "";
|
|
4178
4314
|
const dvars = toCssVars(darkTheme);
|
|
4179
4315
|
if (!Object.keys(dvars).length) return "";
|
|
@@ -4213,7 +4349,7 @@ function TextInput({
|
|
|
4213
4349
|
prefix,
|
|
4214
4350
|
suffix
|
|
4215
4351
|
}) {
|
|
4216
|
-
const errorId =
|
|
4352
|
+
const errorId = React16.useId();
|
|
4217
4353
|
const hasError = errorMessage != null;
|
|
4218
4354
|
const hasAdornment = prefix != null || suffix != null;
|
|
4219
4355
|
const input = /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4283,7 +4419,7 @@ function NumberInput({
|
|
|
4283
4419
|
readOnly = false,
|
|
4284
4420
|
precision
|
|
4285
4421
|
}) {
|
|
4286
|
-
const errorId =
|
|
4422
|
+
const errorId = React16.useId();
|
|
4287
4423
|
const hasError = errorMessage != null;
|
|
4288
4424
|
const inferredPrecision = precision ?? (Number.isInteger(step) ? 0 : String(step).split(".")[1]?.length ?? 0);
|
|
4289
4425
|
const round = (n) => {
|
|
@@ -4414,8 +4550,8 @@ function Password({
|
|
|
4414
4550
|
showIcon,
|
|
4415
4551
|
hideIcon
|
|
4416
4552
|
}) {
|
|
4417
|
-
const [visible, setVisible] =
|
|
4418
|
-
const errorId =
|
|
4553
|
+
const [visible, setVisible] = React16.useState(false);
|
|
4554
|
+
const errorId = React16.useId();
|
|
4419
4555
|
const hasError = errorMessage != null;
|
|
4420
4556
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4421
4557
|
Field,
|
|
@@ -4488,7 +4624,7 @@ function Checkbox({
|
|
|
4488
4624
|
}) {
|
|
4489
4625
|
const isChecked = checked ?? value ?? false;
|
|
4490
4626
|
const labelFirst = labelPosition === "left";
|
|
4491
|
-
const errorId =
|
|
4627
|
+
const errorId = React16.useId();
|
|
4492
4628
|
const hasError = errorMessage != null;
|
|
4493
4629
|
const box = /* @__PURE__ */ jsxRuntime.jsx(
|
|
4494
4630
|
CheckboxPrimitive__namespace.Root,
|
|
@@ -4596,8 +4732,8 @@ function RadioGroup({
|
|
|
4596
4732
|
className,
|
|
4597
4733
|
errorMessage
|
|
4598
4734
|
}) {
|
|
4599
|
-
const errorId =
|
|
4600
|
-
const groupId =
|
|
4735
|
+
const errorId = React16.useId();
|
|
4736
|
+
const groupId = React16.useId();
|
|
4601
4737
|
const hasError = errorMessage != null;
|
|
4602
4738
|
const labelFirst = labelPosition === "left";
|
|
4603
4739
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4697,11 +4833,11 @@ function Switch({
|
|
|
4697
4833
|
disabled,
|
|
4698
4834
|
errorMessage
|
|
4699
4835
|
}) {
|
|
4700
|
-
const id =
|
|
4701
|
-
const errorId =
|
|
4836
|
+
const id = React16.useId();
|
|
4837
|
+
const errorId = React16.useId();
|
|
4702
4838
|
const hasError = errorMessage != null;
|
|
4703
4839
|
const isControlled = checked !== void 0;
|
|
4704
|
-
const [internal, setInternal] =
|
|
4840
|
+
const [internal, setInternal] = React16.useState(defaultChecked);
|
|
4705
4841
|
const isOn = isControlled ? checked : internal;
|
|
4706
4842
|
const handle = (c) => {
|
|
4707
4843
|
if (!isControlled) setInternal(c);
|
|
@@ -4774,19 +4910,19 @@ function AutoComplete({
|
|
|
4774
4910
|
required,
|
|
4775
4911
|
htmlFor
|
|
4776
4912
|
}) {
|
|
4777
|
-
const errorId =
|
|
4913
|
+
const errorId = React16.useId();
|
|
4778
4914
|
const hasError = errorMessage != null;
|
|
4779
|
-
const [term, setTerm] =
|
|
4780
|
-
const [open, setOpen] =
|
|
4781
|
-
const [asyncItems, setAsyncItems] =
|
|
4782
|
-
const [loading, setLoading] =
|
|
4915
|
+
const [term, setTerm] = React16.useState("");
|
|
4916
|
+
const [open, setOpen] = React16.useState(false);
|
|
4917
|
+
const [asyncItems, setAsyncItems] = React16.useState([]);
|
|
4918
|
+
const [loading, setLoading] = React16.useState(false);
|
|
4783
4919
|
const isAsync = typeof onSearch === "function";
|
|
4784
|
-
const debounceRef =
|
|
4785
|
-
const requestIdRef =
|
|
4920
|
+
const debounceRef = React16.useRef(null);
|
|
4921
|
+
const requestIdRef = React16.useRef(0);
|
|
4786
4922
|
const staticFiltered = isAsync || !items ? [] : term.trim() ? items.filter(
|
|
4787
4923
|
({ key, label: label2 }) => label2.toLowerCase().includes(term.toLowerCase()) || key.toLowerCase().includes(term.toLowerCase())
|
|
4788
4924
|
) : [];
|
|
4789
|
-
|
|
4925
|
+
React16.useEffect(() => {
|
|
4790
4926
|
if (!isAsync) return;
|
|
4791
4927
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
4792
4928
|
if (!term.trim()) {
|
|
@@ -4942,15 +5078,15 @@ function TreeSelect({
|
|
|
4942
5078
|
defaultExpandedKeys = [],
|
|
4943
5079
|
size = "md"
|
|
4944
5080
|
}) {
|
|
4945
|
-
const errorId =
|
|
5081
|
+
const errorId = React16.useId();
|
|
4946
5082
|
const hasError = errorMessage != null;
|
|
4947
|
-
const [open, setOpen] =
|
|
4948
|
-
const [expanded, setExpanded] =
|
|
4949
|
-
const [activeIndex, setActiveIndex] =
|
|
4950
|
-
const listRef =
|
|
4951
|
-
const visible =
|
|
4952
|
-
const didSyncOnOpenRef =
|
|
4953
|
-
|
|
5083
|
+
const [open, setOpen] = React16.useState(false);
|
|
5084
|
+
const [expanded, setExpanded] = React16.useState(() => new Set(defaultExpandedKeys));
|
|
5085
|
+
const [activeIndex, setActiveIndex] = React16.useState(0);
|
|
5086
|
+
const listRef = React16.useRef(null);
|
|
5087
|
+
const visible = React16.useMemo(() => flattenVisible(items, expanded), [items, expanded]);
|
|
5088
|
+
const didSyncOnOpenRef = React16.useRef(false);
|
|
5089
|
+
React16.useEffect(() => {
|
|
4954
5090
|
if (!open) {
|
|
4955
5091
|
didSyncOnOpenRef.current = false;
|
|
4956
5092
|
return;
|
|
@@ -4960,7 +5096,7 @@ function TreeSelect({
|
|
|
4960
5096
|
setActiveIndex(selectedIdx >= 0 ? selectedIdx : 0);
|
|
4961
5097
|
didSyncOnOpenRef.current = true;
|
|
4962
5098
|
}, [open, value]);
|
|
4963
|
-
const selectedNode =
|
|
5099
|
+
const selectedNode = React16.useMemo(
|
|
4964
5100
|
() => value != null ? findNodeByKey(items, value) : null,
|
|
4965
5101
|
[items, value]
|
|
4966
5102
|
);
|
|
@@ -5191,11 +5327,11 @@ function FileInput({
|
|
|
5191
5327
|
required,
|
|
5192
5328
|
icon
|
|
5193
5329
|
}) {
|
|
5194
|
-
const inputRef =
|
|
5195
|
-
const errorId =
|
|
5196
|
-
const [files, setFiles] =
|
|
5197
|
-
const [dragging, setDragging] =
|
|
5198
|
-
const [sizeError, setSizeError] =
|
|
5330
|
+
const inputRef = React16.useRef(null);
|
|
5331
|
+
const errorId = React16.useId();
|
|
5332
|
+
const [files, setFiles] = React16.useState([]);
|
|
5333
|
+
const [dragging, setDragging] = React16.useState(false);
|
|
5334
|
+
const [sizeError, setSizeError] = React16.useState(null);
|
|
5199
5335
|
const effectiveError = errorMessage ?? sizeError ?? void 0;
|
|
5200
5336
|
const openPicker = () => {
|
|
5201
5337
|
if (!disabled) inputRef.current?.click();
|
|
@@ -5386,30 +5522,30 @@ function DatePicker({
|
|
|
5386
5522
|
size = "md",
|
|
5387
5523
|
className = ""
|
|
5388
5524
|
}) {
|
|
5389
|
-
const errorId =
|
|
5525
|
+
const errorId = React16.useId();
|
|
5390
5526
|
const hasError = errorMessage != null;
|
|
5391
|
-
const [open, setOpen] =
|
|
5392
|
-
const [viewMonth, setViewMonth] =
|
|
5393
|
-
const [focusDate, setFocusDate] =
|
|
5394
|
-
const [view, setView] =
|
|
5395
|
-
const gridRef =
|
|
5396
|
-
|
|
5527
|
+
const [open, setOpen] = React16.useState(false);
|
|
5528
|
+
const [viewMonth, setViewMonth] = React16.useState(() => startOfMonth(value ?? /* @__PURE__ */ new Date()));
|
|
5529
|
+
const [focusDate, setFocusDate] = React16.useState(() => value ?? /* @__PURE__ */ new Date());
|
|
5530
|
+
const [view, setView] = React16.useState("days");
|
|
5531
|
+
const gridRef = React16.useRef(null);
|
|
5532
|
+
React16.useEffect(() => {
|
|
5397
5533
|
if (!open) return;
|
|
5398
5534
|
const target = value ?? /* @__PURE__ */ new Date();
|
|
5399
5535
|
setViewMonth(startOfMonth(target));
|
|
5400
5536
|
setFocusDate(target);
|
|
5401
5537
|
setView("days");
|
|
5402
5538
|
}, [open, value]);
|
|
5403
|
-
|
|
5539
|
+
React16.useEffect(() => {
|
|
5404
5540
|
if (!open) return;
|
|
5405
5541
|
const cell = gridRef.current?.querySelector(`[data-day="${defaultFormat(focusDate)}"]`);
|
|
5406
5542
|
cell?.focus();
|
|
5407
5543
|
}, [open, focusDate]);
|
|
5408
|
-
const weekdays =
|
|
5544
|
+
const weekdays = React16.useMemo(() => {
|
|
5409
5545
|
const ordered = WEEKDAY_SHORT.slice(weekStartsOn).concat(WEEKDAY_SHORT.slice(0, weekStartsOn));
|
|
5410
5546
|
return ordered;
|
|
5411
5547
|
}, [weekStartsOn]);
|
|
5412
|
-
const grid =
|
|
5548
|
+
const grid = React16.useMemo(() => buildGrid(viewMonth, weekStartsOn), [viewMonth, weekStartsOn]);
|
|
5413
5549
|
const isDisabled = (d) => {
|
|
5414
5550
|
if (min && d < min) return true;
|
|
5415
5551
|
if (max && d > max) return true;
|
|
@@ -5699,10 +5835,10 @@ function TextArea({
|
|
|
5699
5835
|
style,
|
|
5700
5836
|
inputStyle
|
|
5701
5837
|
}) {
|
|
5702
|
-
const errorId =
|
|
5838
|
+
const errorId = React16.useId();
|
|
5703
5839
|
const hasError = errorMessage != null;
|
|
5704
|
-
const ref =
|
|
5705
|
-
|
|
5840
|
+
const ref = React16.useRef(null);
|
|
5841
|
+
React16.useLayoutEffect(() => {
|
|
5706
5842
|
if (!autoGrow) return;
|
|
5707
5843
|
const el = ref.current;
|
|
5708
5844
|
if (!el) return;
|
|
@@ -5772,11 +5908,11 @@ function SegmentedControl({
|
|
|
5772
5908
|
"aria-label": ariaLabel
|
|
5773
5909
|
}) {
|
|
5774
5910
|
const sz = SIZE4[size];
|
|
5775
|
-
const groupId =
|
|
5776
|
-
const errorId =
|
|
5911
|
+
const groupId = React16.useId();
|
|
5912
|
+
const errorId = React16.useId();
|
|
5777
5913
|
const hasError = errorMessage != null;
|
|
5778
5914
|
const isControlled = value !== void 0;
|
|
5779
|
-
const [internal, setInternal] =
|
|
5915
|
+
const [internal, setInternal] = React16.useState(defaultValue);
|
|
5780
5916
|
const current = isControlled ? value : internal;
|
|
5781
5917
|
const handle = (v) => {
|
|
5782
5918
|
if (!v) return;
|
|
@@ -5870,14 +6006,14 @@ function Slider({
|
|
|
5870
6006
|
name,
|
|
5871
6007
|
htmlFor
|
|
5872
6008
|
}) {
|
|
5873
|
-
const errorId =
|
|
6009
|
+
const errorId = React16.useId();
|
|
5874
6010
|
const hasError = errorMessage != null;
|
|
5875
6011
|
const isRange = Array.isArray(value ?? defaultValue);
|
|
5876
|
-
const [internal, setInternal] =
|
|
6012
|
+
const [internal, setInternal] = React16.useState(
|
|
5877
6013
|
() => toArray(value) ?? toArray(defaultValue) ?? [min]
|
|
5878
6014
|
);
|
|
5879
6015
|
const current = toArray(value) ?? internal;
|
|
5880
|
-
const [dragging, setDragging] =
|
|
6016
|
+
const [dragging, setDragging] = React16.useState(false);
|
|
5881
6017
|
const emit = (arr) => {
|
|
5882
6018
|
setInternal(arr);
|
|
5883
6019
|
const next = isRange ? [arr[0], arr[1]] : arr[0];
|
|
@@ -5972,11 +6108,11 @@ function TagsInput({
|
|
|
5972
6108
|
validate,
|
|
5973
6109
|
separators = ["Enter", ","]
|
|
5974
6110
|
}) {
|
|
5975
|
-
const errorId =
|
|
5976
|
-
const inputRef =
|
|
5977
|
-
const [internal, setInternal] =
|
|
5978
|
-
const [draft, setDraft] =
|
|
5979
|
-
const [localError, setLocalError] =
|
|
6111
|
+
const errorId = React16.useId();
|
|
6112
|
+
const inputRef = React16.useRef(null);
|
|
6113
|
+
const [internal, setInternal] = React16.useState(defaultValue ?? []);
|
|
6114
|
+
const [draft, setDraft] = React16.useState("");
|
|
6115
|
+
const [localError, setLocalError] = React16.useState(null);
|
|
5980
6116
|
const tags = value ?? internal;
|
|
5981
6117
|
const hasError = errorMessage != null || localError != null;
|
|
5982
6118
|
const errorText = errorMessage ?? localError ?? void 0;
|
|
@@ -6107,9 +6243,9 @@ function OtpInput({
|
|
|
6107
6243
|
className,
|
|
6108
6244
|
groupAfter
|
|
6109
6245
|
}) {
|
|
6110
|
-
const errorId =
|
|
6246
|
+
const errorId = React16.useId();
|
|
6111
6247
|
const hasError = errorMessage != null;
|
|
6112
|
-
const refs =
|
|
6248
|
+
const refs = React16.useRef([]);
|
|
6113
6249
|
const chars = Array.from({ length }, (_, i) => value[i] ?? "");
|
|
6114
6250
|
const pattern = mode === "numeric" ? /[0-9]/ : /[a-zA-Z0-9]/;
|
|
6115
6251
|
const emit = (next) => {
|
|
@@ -6158,7 +6294,7 @@ function OtpInput({
|
|
|
6158
6294
|
emit(valid.join(""));
|
|
6159
6295
|
focusBox(valid.length);
|
|
6160
6296
|
};
|
|
6161
|
-
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(
|
|
6297
|
+
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(React16__default.default.Fragment, { children: [
|
|
6162
6298
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6163
6299
|
"input",
|
|
6164
6300
|
{
|
|
@@ -6216,9 +6352,9 @@ function Rating({
|
|
|
6216
6352
|
className,
|
|
6217
6353
|
required
|
|
6218
6354
|
}) {
|
|
6219
|
-
const errorId =
|
|
6220
|
-
const [internal, setInternal] =
|
|
6221
|
-
const [hover, setHover] =
|
|
6355
|
+
const errorId = React16.useId();
|
|
6356
|
+
const [internal, setInternal] = React16.useState(defaultValue);
|
|
6357
|
+
const [hover, setHover] = React16.useState(null);
|
|
6222
6358
|
const current = value ?? internal;
|
|
6223
6359
|
const display2 = hover ?? current;
|
|
6224
6360
|
const interactive = !readOnly && !disabled;
|
|
@@ -6341,9 +6477,9 @@ function TimePicker({
|
|
|
6341
6477
|
required,
|
|
6342
6478
|
style
|
|
6343
6479
|
}) {
|
|
6344
|
-
const errorId =
|
|
6480
|
+
const errorId = React16.useId();
|
|
6345
6481
|
const hasError = errorMessage != null;
|
|
6346
|
-
const [open, setOpen] =
|
|
6482
|
+
const [open, setOpen] = React16.useState(false);
|
|
6347
6483
|
const parsed = parse(value) ?? { h: 0, m: 0, s: 0 };
|
|
6348
6484
|
const update = (next) => {
|
|
6349
6485
|
const merged = { ...parsed, ...next };
|
|
@@ -6467,13 +6603,13 @@ function DateRangePicker({
|
|
|
6467
6603
|
required,
|
|
6468
6604
|
style
|
|
6469
6605
|
}) {
|
|
6470
|
-
const errorId =
|
|
6606
|
+
const errorId = React16.useId();
|
|
6471
6607
|
const hasError = errorMessage != null;
|
|
6472
|
-
const [open, setOpen] =
|
|
6473
|
-
const [leftMonth, setLeftMonth] =
|
|
6474
|
-
const [pendingStart, setPendingStart] =
|
|
6475
|
-
const [hoverDate, setHoverDate] =
|
|
6476
|
-
const weekdays =
|
|
6608
|
+
const [open, setOpen] = React16.useState(false);
|
|
6609
|
+
const [leftMonth, setLeftMonth] = React16.useState(() => startOfMonth2(value.start ?? /* @__PURE__ */ new Date()));
|
|
6610
|
+
const [pendingStart, setPendingStart] = React16.useState(null);
|
|
6611
|
+
const [hoverDate, setHoverDate] = React16.useState(null);
|
|
6612
|
+
const weekdays = React16.useMemo(
|
|
6477
6613
|
() => WEEKDAY.slice(weekStartsOn).concat(WEEKDAY.slice(0, weekStartsOn)),
|
|
6478
6614
|
[weekStartsOn]
|
|
6479
6615
|
);
|
|
@@ -6649,10 +6785,10 @@ function ColorPicker({
|
|
|
6649
6785
|
required,
|
|
6650
6786
|
placeholder = "Pick a colour\u2026"
|
|
6651
6787
|
}) {
|
|
6652
|
-
const errorId =
|
|
6788
|
+
const errorId = React16.useId();
|
|
6653
6789
|
const hasError = errorMessage != null;
|
|
6654
|
-
const [open, setOpen] =
|
|
6655
|
-
const [draft, setDraft] =
|
|
6790
|
+
const [open, setOpen] = React16.useState(false);
|
|
6791
|
+
const [draft, setDraft] = React16.useState(value);
|
|
6656
6792
|
const valid = HEX_RE.test(value);
|
|
6657
6793
|
const pick = (hex) => {
|
|
6658
6794
|
onChange?.(hex);
|
|
@@ -7039,11 +7175,11 @@ function buildBindings(store, name, kind, snap) {
|
|
|
7039
7175
|
|
|
7040
7176
|
// src/form/useForm.ts
|
|
7041
7177
|
function useForm(options = {}) {
|
|
7042
|
-
const ref =
|
|
7178
|
+
const ref = React16.useRef(null);
|
|
7043
7179
|
if (ref.current === null) ref.current = new FormStore(options);
|
|
7044
7180
|
const store = ref.current;
|
|
7045
|
-
|
|
7046
|
-
const make =
|
|
7181
|
+
React16.useSyncExternalStore(store.subscribe, store.getRootSnapshot, store.getRootSnapshot);
|
|
7182
|
+
const make = React16.useCallback(
|
|
7047
7183
|
(kind) => (name, rules) => {
|
|
7048
7184
|
if (rules !== void 0) store.setRule(name, rules);
|
|
7049
7185
|
return buildBindings(store, name, kind, store.getFieldSnapshot(name));
|
|
@@ -7072,9 +7208,9 @@ function useForm(options = {}) {
|
|
|
7072
7208
|
fieldTarget: make("target")
|
|
7073
7209
|
};
|
|
7074
7210
|
}
|
|
7075
|
-
var FormContext =
|
|
7211
|
+
var FormContext = React16.createContext(null);
|
|
7076
7212
|
function useFormStore() {
|
|
7077
|
-
const store =
|
|
7213
|
+
const store = React16.useContext(FormContext);
|
|
7078
7214
|
if (!store) {
|
|
7079
7215
|
throw new Error("useFormStore must be used within a <Form>. Did you forget to wrap your fields?");
|
|
7080
7216
|
}
|
|
@@ -7088,8 +7224,8 @@ function Form({
|
|
|
7088
7224
|
children,
|
|
7089
7225
|
...rest
|
|
7090
7226
|
}) {
|
|
7091
|
-
const ref =
|
|
7092
|
-
const bypass =
|
|
7227
|
+
const ref = React16.useRef(null);
|
|
7228
|
+
const bypass = React16.useRef(false);
|
|
7093
7229
|
const handleSubmit = async (e) => {
|
|
7094
7230
|
if (bypass.current) {
|
|
7095
7231
|
bypass.current = false;
|
|
@@ -7141,12 +7277,12 @@ function useFormField(name, options = {}) {
|
|
|
7141
7277
|
const store = useFormStore();
|
|
7142
7278
|
const { kind = "value", rules } = options;
|
|
7143
7279
|
if (rules !== void 0 && store.getRule(name) !== rules) store.setRule(name, rules);
|
|
7144
|
-
|
|
7280
|
+
React16.useEffect(() => {
|
|
7145
7281
|
return () => {
|
|
7146
7282
|
if (rules !== void 0) store.removeRule(name);
|
|
7147
7283
|
};
|
|
7148
7284
|
}, [store, name]);
|
|
7149
|
-
const snap =
|
|
7285
|
+
const snap = React16.useSyncExternalStore(
|
|
7150
7286
|
store.subscribe,
|
|
7151
7287
|
() => store.getFieldSnapshot(name)
|
|
7152
7288
|
);
|
|
@@ -7158,7 +7294,7 @@ function FormField({ name, kind, rules, children }) {
|
|
|
7158
7294
|
}
|
|
7159
7295
|
function useFieldArray(name) {
|
|
7160
7296
|
const store = useFormStore();
|
|
7161
|
-
|
|
7297
|
+
React16.useSyncExternalStore(store.subscribe, store.getRootSnapshot, store.getRootSnapshot);
|
|
7162
7298
|
const arr = store.getValue(name) ?? [];
|
|
7163
7299
|
const keys = store.getKeys(name);
|
|
7164
7300
|
return {
|
|
@@ -7281,7 +7417,7 @@ function CreditCardForm({
|
|
|
7281
7417
|
className = "",
|
|
7282
7418
|
style
|
|
7283
7419
|
}) {
|
|
7284
|
-
const initial =
|
|
7420
|
+
const initial = React16.useRef({
|
|
7285
7421
|
number: formatCardNumber(defaultValue?.number ?? ""),
|
|
7286
7422
|
name: defaultValue?.name ?? "",
|
|
7287
7423
|
expiry: formatExpiry(defaultValue?.expiry ?? ""),
|
|
@@ -7290,7 +7426,7 @@ function CreditCardForm({
|
|
|
7290
7426
|
const form = useForm({ initialValues: initial });
|
|
7291
7427
|
const numberStr = String(form.values.number ?? "");
|
|
7292
7428
|
const brand = detectBrand(numberStr);
|
|
7293
|
-
|
|
7429
|
+
React16.useEffect(() => {
|
|
7294
7430
|
onChange?.(toCard(form.values));
|
|
7295
7431
|
}, [form.values.number, form.values.name, form.values.expiry, form.values.cvv]);
|
|
7296
7432
|
const numberBind = form.fieldNative("number", {
|
|
@@ -7397,6 +7533,8 @@ exports.Box = Box;
|
|
|
7397
7533
|
exports.Breadcrumbs = Breadcrumbs;
|
|
7398
7534
|
exports.Button = Button;
|
|
7399
7535
|
exports.CARD_BRANDS = CARD_BRANDS;
|
|
7536
|
+
exports.Card = Card_default;
|
|
7537
|
+
exports.CardCarousel = CardCarousel;
|
|
7400
7538
|
exports.Catalog = Catalog;
|
|
7401
7539
|
exports.CatalogCarousel = CatalogCarousel;
|
|
7402
7540
|
exports.CatalogGrid = CatalogGrid;
|