@geomak/ui 6.2.0 → 6.2.2
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 +350 -209
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -3
- package/dist/index.d.ts +14 -3
- package/dist/index.js +172 -31
- package/dist/index.js.map +1 -1
- package/dist/styles.css +21 -26
- 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 React12 = 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 React12__default = /*#__PURE__*/_interopDefault(React12);
|
|
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] = React12.useState(null);
|
|
218
|
+
React12.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 = React12.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 = React12.createContext(null);
|
|
964
964
|
function useTabsContext() {
|
|
965
|
-
const ctx =
|
|
965
|
+
const ctx = React12.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] = React12.useState(defaultValue);
|
|
988
988
|
const current = isControlled ? value : internal;
|
|
989
989
|
const reduced = !!framerMotion.useReducedMotion();
|
|
990
|
-
const indicatorId =
|
|
991
|
-
const select =
|
|
990
|
+
const indicatorId = React12.useId();
|
|
991
|
+
const select = React12.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 = React12.useRef(/* @__PURE__ */ new Map());
|
|
996
|
+
const orderRef = React12.useRef(0);
|
|
997
|
+
const [, bump] = React12.useState(0);
|
|
998
|
+
const registerTab = React12.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 = React12.useCallback((val) => {
|
|
1004
1004
|
if (registry.current.delete(val)) bump((v) => v + 1);
|
|
1005
1005
|
}, []);
|
|
1006
|
-
const getTabs =
|
|
1006
|
+
const getTabs = React12.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 = React12.useRef(null);
|
|
1027
|
+
const [edges, setEdges] = React12.useState({ start: false, end: false });
|
|
1028
1028
|
const scrollable = variant !== "segmented";
|
|
1029
|
-
|
|
1029
|
+
React12.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 = React12.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
|
+
React12.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] = React12.useState(false);
|
|
1119
|
+
const wrapRef = React12.useRef(null);
|
|
1120
|
+
const timer = React12.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
|
+
React12.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
|
+
React12.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 NotificationContext =
|
|
1407
|
+
var NotificationContext = React12.createContext({
|
|
1408
1408
|
open: () => void 0,
|
|
1409
1409
|
close: () => void 0
|
|
1410
1410
|
});
|
|
@@ -1462,26 +1462,26 @@ function NotificationItem({
|
|
|
1462
1462
|
onClose,
|
|
1463
1463
|
reduced
|
|
1464
1464
|
}) {
|
|
1465
|
-
const [paused, setPaused] =
|
|
1465
|
+
const [paused, setPaused] = React12.useState(false);
|
|
1466
1466
|
const duration = n.duration ?? 4e3;
|
|
1467
1467
|
const isAutoDismissing = isFinite(duration) && duration > 0;
|
|
1468
1468
|
const showProgress = !reduced && isAutoDismissing;
|
|
1469
|
-
const timerRef =
|
|
1470
|
-
const startTimeRef =
|
|
1471
|
-
const remainingRef =
|
|
1472
|
-
const clearTimer =
|
|
1469
|
+
const timerRef = React12.useRef(null);
|
|
1470
|
+
const startTimeRef = React12.useRef(0);
|
|
1471
|
+
const remainingRef = React12.useRef(duration);
|
|
1472
|
+
const clearTimer = React12.useCallback(() => {
|
|
1473
1473
|
if (timerRef.current !== null) {
|
|
1474
1474
|
clearTimeout(timerRef.current);
|
|
1475
1475
|
timerRef.current = null;
|
|
1476
1476
|
}
|
|
1477
1477
|
}, []);
|
|
1478
|
-
const scheduleDismiss =
|
|
1478
|
+
const scheduleDismiss = React12.useCallback((ms) => {
|
|
1479
1479
|
clearTimer();
|
|
1480
1480
|
if (!isAutoDismissing) return;
|
|
1481
1481
|
startTimeRef.current = Date.now();
|
|
1482
1482
|
timerRef.current = setTimeout(() => onClose(n.id), ms);
|
|
1483
1483
|
}, [clearTimer, isAutoDismissing, n.id, onClose]);
|
|
1484
|
-
|
|
1484
|
+
React12.useEffect(() => {
|
|
1485
1485
|
if (paused || !isAutoDismissing) return;
|
|
1486
1486
|
scheduleDismiss(remainingRef.current);
|
|
1487
1487
|
return clearTimer;
|
|
@@ -1564,15 +1564,15 @@ function NotificationProvider({
|
|
|
1564
1564
|
children,
|
|
1565
1565
|
position = "top-right"
|
|
1566
1566
|
}) {
|
|
1567
|
-
const [notifications, setNotifications] =
|
|
1567
|
+
const [notifications, setNotifications] = React12.useState([]);
|
|
1568
1568
|
const reduced = framerMotion.useReducedMotion();
|
|
1569
|
-
const open =
|
|
1569
|
+
const open = React12.useCallback((payload) => {
|
|
1570
1570
|
setNotifications((prev) => [
|
|
1571
1571
|
...prev,
|
|
1572
1572
|
{ duration: 4e3, ...payload, id: Date.now() + Math.random() }
|
|
1573
1573
|
]);
|
|
1574
1574
|
}, []);
|
|
1575
|
-
const close =
|
|
1575
|
+
const close = React12.useCallback((id) => {
|
|
1576
1576
|
setNotifications((prev) => prev.filter((n) => n.id !== id));
|
|
1577
1577
|
}, []);
|
|
1578
1578
|
return /* @__PURE__ */ jsxRuntime.jsxs(NotificationContext.Provider, { value: { open, close }, children: [
|
|
@@ -1601,7 +1601,7 @@ function NotificationProvider({
|
|
|
1601
1601
|
] });
|
|
1602
1602
|
}
|
|
1603
1603
|
function useNotification() {
|
|
1604
|
-
const { open } =
|
|
1604
|
+
const { open } = React12.useContext(NotificationContext);
|
|
1605
1605
|
return {
|
|
1606
1606
|
info: (props) => open({ type: "info", ...props }),
|
|
1607
1607
|
success: (props) => open({ type: "success", ...props }),
|
|
@@ -1718,10 +1718,10 @@ function FadingBase({
|
|
|
1718
1718
|
isMounted = false,
|
|
1719
1719
|
children
|
|
1720
1720
|
}) {
|
|
1721
|
-
const [shouldRender, setShouldRender] =
|
|
1722
|
-
const [visible, setVisible] =
|
|
1723
|
-
const timerRef =
|
|
1724
|
-
|
|
1721
|
+
const [shouldRender, setShouldRender] = React12.useState(isMounted);
|
|
1722
|
+
const [visible, setVisible] = React12.useState(false);
|
|
1723
|
+
const timerRef = React12.useRef(null);
|
|
1724
|
+
React12.useEffect(() => {
|
|
1725
1725
|
if (isMounted) {
|
|
1726
1726
|
setShouldRender(true);
|
|
1727
1727
|
const rafId = requestAnimationFrame(() => setVisible(true));
|
|
@@ -1819,8 +1819,8 @@ function ScalableContainer({
|
|
|
1819
1819
|
togglePosition = "top-right",
|
|
1820
1820
|
className = ""
|
|
1821
1821
|
}) {
|
|
1822
|
-
const containerRef =
|
|
1823
|
-
const [internalScaled, setInternalScaled] =
|
|
1822
|
+
const containerRef = React12.useRef(null);
|
|
1823
|
+
const [internalScaled, setInternalScaled] = React12.useState(false);
|
|
1824
1824
|
const isScaled = expanded ?? internalScaled;
|
|
1825
1825
|
const reduced = framerMotion.useReducedMotion();
|
|
1826
1826
|
const onToggle = () => {
|
|
@@ -1958,17 +1958,17 @@ function CatalogGrid({ items, buttonText, onOpen, className = "" }) {
|
|
|
1958
1958
|
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
1959
|
}
|
|
1960
1960
|
function CatalogCarousel({ items, buttonText, onOpen, className = "" }) {
|
|
1961
|
-
const [activeIndex, setActiveIndex] =
|
|
1962
|
-
const [indexPool, setIndexPool] =
|
|
1963
|
-
const cardRefs =
|
|
1964
|
-
const getIndexes =
|
|
1961
|
+
const [activeIndex, setActiveIndex] = React12.useState(0);
|
|
1962
|
+
const [indexPool, setIndexPool] = React12.useState([]);
|
|
1963
|
+
const cardRefs = React12.useRef([]);
|
|
1964
|
+
const getIndexes = React12.useMemo(() => {
|
|
1965
1965
|
let nextIndex = activeIndex + 1;
|
|
1966
1966
|
let previousIndex = activeIndex - 1;
|
|
1967
1967
|
if (activeIndex === 0) previousIndex = items.length - 1;
|
|
1968
1968
|
if (activeIndex === items.length - 1) nextIndex = 0;
|
|
1969
1969
|
return { previousIndex, nextIndex };
|
|
1970
1970
|
}, [activeIndex, items.length]);
|
|
1971
|
-
|
|
1971
|
+
React12.useEffect(() => {
|
|
1972
1972
|
const { nextIndex, previousIndex } = getIndexes;
|
|
1973
1973
|
let indexes = [previousIndex, activeIndex, nextIndex];
|
|
1974
1974
|
if (activeIndex !== 0 && activeIndex !== items.length - 1) {
|
|
@@ -2141,8 +2141,8 @@ function writeDismissed(key) {
|
|
|
2141
2141
|
}
|
|
2142
2142
|
}
|
|
2143
2143
|
function useTargetBbox(ref) {
|
|
2144
|
-
const [bbox, setBbox] =
|
|
2145
|
-
|
|
2144
|
+
const [bbox, setBbox] = React12.useState(null);
|
|
2145
|
+
React12.useLayoutEffect(() => {
|
|
2146
2146
|
const el = ref?.current;
|
|
2147
2147
|
if (!el) {
|
|
2148
2148
|
setBbox(null);
|
|
@@ -2172,7 +2172,7 @@ function tooltipStyleFor(bbox, placement) {
|
|
|
2172
2172
|
return { left: bbox.left + bbox.width / 2, top: bbox.top - TOOLTIP_GAP, transform: "translate(-50%, -100%)", width: TOOLTIP_WIDTH };
|
|
2173
2173
|
}
|
|
2174
2174
|
function useFocusTrap(containerRef, active) {
|
|
2175
|
-
|
|
2175
|
+
React12.useEffect(() => {
|
|
2176
2176
|
if (!active) return;
|
|
2177
2177
|
const el = containerRef.current;
|
|
2178
2178
|
if (!el) return;
|
|
@@ -2211,16 +2211,16 @@ function Wizard({
|
|
|
2211
2211
|
onComplete,
|
|
2212
2212
|
onSkip
|
|
2213
2213
|
}) {
|
|
2214
|
-
const tooltipRef =
|
|
2215
|
-
const tooltipTitleId =
|
|
2216
|
-
const tooltipBodyId =
|
|
2214
|
+
const tooltipRef = React12.useRef(null);
|
|
2215
|
+
const tooltipTitleId = React12.useId();
|
|
2216
|
+
const tooltipBodyId = React12.useId();
|
|
2217
2217
|
const reduced = framerMotion.useReducedMotion();
|
|
2218
|
-
const [open, setOpen] =
|
|
2219
|
-
const [activeIndex, setActiveIndex] =
|
|
2218
|
+
const [open, setOpen] = React12.useState(() => steps.length > 0 && !readDismissed(storageKey));
|
|
2219
|
+
const [activeIndex, setActiveIndex] = React12.useState(0);
|
|
2220
2220
|
const step = steps[activeIndex];
|
|
2221
2221
|
const bbox = useTargetBbox(step?.stepRef);
|
|
2222
2222
|
useFocusTrap(tooltipRef, open);
|
|
2223
|
-
|
|
2223
|
+
React12.useEffect(() => {
|
|
2224
2224
|
if (!open || !dismissible) return;
|
|
2225
2225
|
const onKey = (e) => {
|
|
2226
2226
|
if (e.key === "Escape") {
|
|
@@ -2231,12 +2231,12 @@ function Wizard({
|
|
|
2231
2231
|
document.addEventListener("keydown", onKey);
|
|
2232
2232
|
return () => document.removeEventListener("keydown", onKey);
|
|
2233
2233
|
}, [open, dismissible]);
|
|
2234
|
-
const handleSkip =
|
|
2234
|
+
const handleSkip = React12.useCallback(() => {
|
|
2235
2235
|
writeDismissed(storageKey);
|
|
2236
2236
|
setOpen(false);
|
|
2237
2237
|
onSkip?.();
|
|
2238
2238
|
}, [storageKey, onSkip]);
|
|
2239
|
-
const handleComplete =
|
|
2239
|
+
const handleComplete = React12.useCallback(() => {
|
|
2240
2240
|
writeDismissed(storageKey);
|
|
2241
2241
|
setOpen(false);
|
|
2242
2242
|
onComplete?.();
|
|
@@ -2507,7 +2507,7 @@ function Field({
|
|
|
2507
2507
|
);
|
|
2508
2508
|
}
|
|
2509
2509
|
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 =
|
|
2510
|
+
var SearchInput = React12__default.default.forwardRef(function SearchInput2({ value, onChange, disabled, label, htmlFor, placeholder, name, inputStyle, style, layout = "vertical", size = "md", icon, helperText, className }, ref) {
|
|
2511
2511
|
return /* @__PURE__ */ jsxRuntime.jsx(Field, { className, label, htmlFor, layout, helperText, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2512
2512
|
"div",
|
|
2513
2513
|
{
|
|
@@ -2561,11 +2561,11 @@ function MultiTagRow({
|
|
|
2561
2561
|
labelFor,
|
|
2562
2562
|
onRemove
|
|
2563
2563
|
}) {
|
|
2564
|
-
const wrapRef =
|
|
2565
|
-
const measureRef =
|
|
2566
|
-
const [visibleCount, setVisibleCount] =
|
|
2564
|
+
const wrapRef = React12.useRef(null);
|
|
2565
|
+
const measureRef = React12.useRef(null);
|
|
2566
|
+
const [visibleCount, setVisibleCount] = React12.useState(values.length);
|
|
2567
2567
|
const key = values.map(String).join("|");
|
|
2568
|
-
|
|
2568
|
+
React12.useLayoutEffect(() => {
|
|
2569
2569
|
const wrap = wrapRef.current;
|
|
2570
2570
|
const measure = measureRef.current;
|
|
2571
2571
|
if (!wrap || !measure) return;
|
|
@@ -2659,16 +2659,16 @@ function Dropdown({
|
|
|
2659
2659
|
size = "md",
|
|
2660
2660
|
className = ""
|
|
2661
2661
|
}) {
|
|
2662
|
-
const [open, setOpen] =
|
|
2663
|
-
const [selectedItems, setSelectedItems] =
|
|
2664
|
-
const [searchTerm, setSearchTerm] =
|
|
2665
|
-
const [innerItems, setInnerItems] =
|
|
2666
|
-
const errorId =
|
|
2662
|
+
const [open, setOpen] = React12.useState(false);
|
|
2663
|
+
const [selectedItems, setSelectedItems] = React12.useState([]);
|
|
2664
|
+
const [searchTerm, setSearchTerm] = React12.useState("");
|
|
2665
|
+
const [innerItems, setInnerItems] = React12.useState([]);
|
|
2666
|
+
const errorId = React12.useId();
|
|
2667
2667
|
const hasError = errorMessage != null;
|
|
2668
|
-
|
|
2668
|
+
React12.useEffect(() => {
|
|
2669
2669
|
setInnerItems(items);
|
|
2670
2670
|
}, [items]);
|
|
2671
|
-
|
|
2671
|
+
React12.useEffect(() => {
|
|
2672
2672
|
if (isMultiselect && Array.isArray(value)) {
|
|
2673
2673
|
setSelectedItems(value);
|
|
2674
2674
|
}
|
|
@@ -2993,7 +2993,7 @@ function TableBody({
|
|
|
2993
2993
|
expandRow,
|
|
2994
2994
|
getRowKey
|
|
2995
2995
|
}) {
|
|
2996
|
-
const [expanded, setExpanded] =
|
|
2996
|
+
const [expanded, setExpanded] = React12.useState(() => /* @__PURE__ */ new Set());
|
|
2997
2997
|
const toggleRow = (rowKey) => {
|
|
2998
2998
|
setExpanded((prev) => {
|
|
2999
2999
|
const next = new Set(prev);
|
|
@@ -3007,7 +3007,7 @@ function TableBody({
|
|
|
3007
3007
|
return /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: rows.map((row, i) => {
|
|
3008
3008
|
const rowKey = getRowKey(row, i);
|
|
3009
3009
|
const isExpanded = expanded.has(rowKey);
|
|
3010
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3010
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(React12__default.default.Fragment, { children: [
|
|
3011
3011
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3012
3012
|
"tr",
|
|
3013
3013
|
{
|
|
@@ -3051,9 +3051,9 @@ function Pagination({
|
|
|
3051
3051
|
const matchedOption = picker.find(
|
|
3052
3052
|
(o) => o.label === options.perPage || o.value === options.perPage
|
|
3053
3053
|
);
|
|
3054
|
-
const [perPageKey, setPerPageKey] =
|
|
3054
|
+
const [perPageKey, setPerPageKey] = React12.useState(() => matchedOption?.key ?? picker[0]?.key);
|
|
3055
3055
|
const displayPerPageKey = serverSide ? matchedOption?.key ?? perPageKey : perPageKey;
|
|
3056
|
-
|
|
3056
|
+
React12.useEffect(() => {
|
|
3057
3057
|
if (serverSide && options.perPage != null) {
|
|
3058
3058
|
const next = picker.find((o) => o.label === options.perPage || o.value === options.perPage);
|
|
3059
3059
|
if (next) setPerPageKey(next.key);
|
|
@@ -3117,14 +3117,14 @@ function Table({
|
|
|
3117
3117
|
className = "",
|
|
3118
3118
|
style
|
|
3119
3119
|
}) {
|
|
3120
|
-
const searchRef =
|
|
3121
|
-
const [searchTerm, setSearchTerm] =
|
|
3122
|
-
const [perPage, setPerPage] =
|
|
3120
|
+
const searchRef = React12.useRef(null);
|
|
3121
|
+
const [searchTerm, setSearchTerm] = React12.useState("");
|
|
3122
|
+
const [perPage, setPerPage] = React12.useState(
|
|
3123
3123
|
typeof pagination.perPage === "number" ? pagination.perPage : 15
|
|
3124
3124
|
);
|
|
3125
|
-
const [activePage, setActivePage] =
|
|
3125
|
+
const [activePage, setActivePage] = React12.useState(0);
|
|
3126
3126
|
const isServerSide = !!(pagination.enabled && pagination.serverSide);
|
|
3127
|
-
const filteredRows =
|
|
3127
|
+
const filteredRows = React12.useMemo(() => {
|
|
3128
3128
|
if (isServerSide || !searchTerm) return rows;
|
|
3129
3129
|
const term = searchTerm.toLowerCase();
|
|
3130
3130
|
return rows.filter(
|
|
@@ -3133,29 +3133,29 @@ function Table({
|
|
|
3133
3133
|
)
|
|
3134
3134
|
);
|
|
3135
3135
|
}, [rows, searchTerm, isServerSide]);
|
|
3136
|
-
const datasets =
|
|
3136
|
+
const datasets = React12.useMemo(() => {
|
|
3137
3137
|
if (isServerSide) return [rows];
|
|
3138
3138
|
return createDatasets(filteredRows, pagination.enabled ? perPage : null);
|
|
3139
3139
|
}, [filteredRows, perPage, pagination.enabled, isServerSide, rows]);
|
|
3140
|
-
const MAX_PAGE =
|
|
3140
|
+
const MAX_PAGE = React12.useMemo(() => {
|
|
3141
3141
|
if (isServerSide && typeof pagination.maxPage === "number") return Math.max(0, pagination.maxPage);
|
|
3142
3142
|
if (isServerSide && typeof pagination.totalCount === "number")
|
|
3143
3143
|
return Math.max(0, Math.ceil(pagination.totalCount / perPage) - 1);
|
|
3144
3144
|
return datasets.length ? datasets.length - 1 : 0;
|
|
3145
3145
|
}, [isServerSide, pagination.maxPage, pagination.totalCount, perPage, datasets.length]);
|
|
3146
|
-
const currentPageRows =
|
|
3146
|
+
const currentPageRows = React12.useMemo(() => {
|
|
3147
3147
|
if (isServerSide) return rows;
|
|
3148
3148
|
return datasets[activePage] ?? [];
|
|
3149
3149
|
}, [isServerSide, rows, datasets, activePage]);
|
|
3150
|
-
|
|
3150
|
+
React12.useEffect(() => {
|
|
3151
3151
|
if (pagination.enabled && !isServerSide && typeof pagination.perPage === "number") {
|
|
3152
3152
|
setPerPage(pagination.perPage);
|
|
3153
3153
|
}
|
|
3154
3154
|
}, [pagination.enabled, pagination.perPage, isServerSide]);
|
|
3155
|
-
|
|
3155
|
+
React12.useEffect(() => {
|
|
3156
3156
|
if (isServerSide && typeof pagination.perPage === "number") setPerPage(pagination.perPage);
|
|
3157
3157
|
}, [isServerSide, pagination.perPage]);
|
|
3158
|
-
|
|
3158
|
+
React12.useEffect(() => {
|
|
3159
3159
|
if (isServerSide && typeof pagination.page === "number" && pagination.page >= 1)
|
|
3160
3160
|
setActivePage(pagination.page - 1);
|
|
3161
3161
|
}, [isServerSide, pagination.page]);
|
|
@@ -3239,7 +3239,7 @@ function TableSkeletonBody({
|
|
|
3239
3239
|
)) });
|
|
3240
3240
|
}
|
|
3241
3241
|
function ThemeSwitch({ checked, onChange, label = "Toggle dark mode", className = "" }) {
|
|
3242
|
-
const id =
|
|
3242
|
+
const id = React12.useId();
|
|
3243
3243
|
return /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: id, className: `flex items-center gap-2 cursor-pointer select-none ${className}`.trim(), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3244
3244
|
SwitchPrimitive__namespace.Root,
|
|
3245
3245
|
{
|
|
@@ -3423,29 +3423,39 @@ function Sidebar({
|
|
|
3423
3423
|
}
|
|
3424
3424
|
) });
|
|
3425
3425
|
}
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3426
|
+
var MegaMenuContext = React12.createContext({ align: "start" });
|
|
3427
|
+
function MegaMenu({
|
|
3428
|
+
children,
|
|
3429
|
+
align = "start",
|
|
3430
|
+
delayDuration = 200,
|
|
3431
|
+
responsive = true,
|
|
3432
|
+
mobileLabel = "Menu",
|
|
3433
|
+
className = "",
|
|
3434
|
+
style,
|
|
3435
|
+
"aria-label": ariaLabel
|
|
3436
|
+
}) {
|
|
3437
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(MegaMenuContext.Provider, { value: { align }, children: [
|
|
3438
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3439
|
+
NavigationMenu__namespace.Root,
|
|
3440
|
+
{
|
|
3441
|
+
delayDuration,
|
|
3442
|
+
"aria-label": ariaLabel,
|
|
3443
|
+
className: [
|
|
3444
|
+
"relative z-10 w-full",
|
|
3445
|
+
responsive ? "hidden md:flex" : "flex",
|
|
3446
|
+
className
|
|
3447
|
+
].filter(Boolean).join(" "),
|
|
3448
|
+
style,
|
|
3449
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(NavigationMenu__namespace.List, { className: "flex items-center gap-1", children })
|
|
3450
|
+
}
|
|
3451
|
+
),
|
|
3452
|
+
responsive && /* @__PURE__ */ jsxRuntime.jsx(MegaMenuMobile, { label: mobileLabel, children })
|
|
3453
|
+
] });
|
|
3446
3454
|
}
|
|
3447
3455
|
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";
|
|
3448
3456
|
function MegaMenuItem({ label, icon, href, children, className = "" }) {
|
|
3457
|
+
const { align } = React12.useContext(MegaMenuContext);
|
|
3458
|
+
const pos = align === "center" ? "left-1/2 -translate-x-1/2" : align === "end" ? "right-0" : "left-0";
|
|
3449
3459
|
if (!children) {
|
|
3450
3460
|
return /* @__PURE__ */ jsxRuntime.jsx(NavigationMenu__namespace.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs(NavigationMenu__namespace.Link, { href, className: [TOP_ITEM, className].filter(Boolean).join(" "), children: [
|
|
3451
3461
|
icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex h-4 w-4 flex-shrink-0 items-center justify-center", children: icon }),
|
|
@@ -3469,22 +3479,36 @@ function MegaMenuItem({ label, icon, href, children, className = "" }) {
|
|
|
3469
3479
|
}
|
|
3470
3480
|
)
|
|
3471
3481
|
] }),
|
|
3472
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3482
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3483
|
+
NavigationMenu__namespace.Content,
|
|
3484
|
+
{
|
|
3485
|
+
className: `absolute top-full mt-2 ${pos} z-20 overflow-hidden rounded-lg border border-border bg-surface shadow-lg
|
|
3486
|
+
data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95
|
|
3487
|
+
data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95`,
|
|
3488
|
+
children
|
|
3489
|
+
}
|
|
3490
|
+
)
|
|
3473
3491
|
] });
|
|
3474
3492
|
}
|
|
3475
|
-
var COLS = { 1: "grid-cols-1", 2: "grid-cols-2", 3: "grid-cols-3", 4: "grid-cols-4" };
|
|
3476
3493
|
function MegaMenuPanel({ children, columns, className = "", style }) {
|
|
3494
|
+
const layout = columns ? {
|
|
3495
|
+
gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))`,
|
|
3496
|
+
width: `min(92vw, ${columns * 272}px)`
|
|
3497
|
+
} : {
|
|
3498
|
+
gridTemplateColumns: "repeat(auto-fit, minmax(220px, 1fr))",
|
|
3499
|
+
width: "min(92vw, 760px)"
|
|
3500
|
+
};
|
|
3477
3501
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3478
3502
|
"div",
|
|
3479
3503
|
{
|
|
3480
|
-
className: ["grid gap-6 p-6",
|
|
3481
|
-
style,
|
|
3504
|
+
className: ["grid gap-6 p-6", className].filter(Boolean).join(" "),
|
|
3505
|
+
style: { ...layout, maxWidth: "min(92vw, 960px)", ...style },
|
|
3482
3506
|
children
|
|
3483
3507
|
}
|
|
3484
3508
|
);
|
|
3485
3509
|
}
|
|
3486
3510
|
function MegaMenuSection({ title, children, className = "" }) {
|
|
3487
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ["min-w-
|
|
3511
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ["min-w-0 flex flex-col", className].filter(Boolean).join(" "), children: [
|
|
3488
3512
|
title && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "px-3 pb-1.5 text-[11px] font-semibold uppercase tracking-widest text-foreground-muted select-none", children: title }),
|
|
3489
3513
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-0.5", children })
|
|
3490
3514
|
] });
|
|
@@ -3513,7 +3537,124 @@ function MegaMenuLink({ href, icon, description, active, onClick, children, clas
|
|
|
3513
3537
|
);
|
|
3514
3538
|
}
|
|
3515
3539
|
function MegaMenuFeatured({ children, className = "" }) {
|
|
3516
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: ["min-w-
|
|
3540
|
+
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 });
|
|
3541
|
+
}
|
|
3542
|
+
var elementsOfType = (children, type) => React12__default.default.Children.toArray(children).filter(
|
|
3543
|
+
(c) => React12__default.default.isValidElement(c) && c.type === type
|
|
3544
|
+
);
|
|
3545
|
+
var MOBILE_CHEVRON = /* @__PURE__ */ jsxRuntime.jsx(
|
|
3546
|
+
"svg",
|
|
3547
|
+
{
|
|
3548
|
+
viewBox: "0 0 24 24",
|
|
3549
|
+
fill: "none",
|
|
3550
|
+
stroke: "currentColor",
|
|
3551
|
+
strokeWidth: 2,
|
|
3552
|
+
"aria-hidden": "true",
|
|
3553
|
+
className: "h-4 w-4 flex-shrink-0 text-foreground-muted transition-transform duration-200",
|
|
3554
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19 9l-7 7-7-7" })
|
|
3555
|
+
}
|
|
3556
|
+
);
|
|
3557
|
+
function MobileLinkRow({ link, onNavigate }) {
|
|
3558
|
+
const { href, icon, description, active, onClick, children } = link.props;
|
|
3559
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3560
|
+
"a",
|
|
3561
|
+
{
|
|
3562
|
+
href,
|
|
3563
|
+
onClick: (e) => {
|
|
3564
|
+
onClick?.(e);
|
|
3565
|
+
onNavigate();
|
|
3566
|
+
},
|
|
3567
|
+
"data-active": active ? "" : void 0,
|
|
3568
|
+
className: "flex items-start gap-3 rounded-md p-2.5 transition-colors select-none\n hover:bg-surface-raised focus:outline-none focus-visible:ring-2 focus-visible:ring-accent\n data-[active]:bg-surface-raised",
|
|
3569
|
+
children: [
|
|
3570
|
+
icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md bg-surface-raised text-accent", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "h-[17px] w-[17px] inline-flex items-center justify-center", children: icon }) }),
|
|
3571
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex flex-col min-w-0", children: [
|
|
3572
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium text-foreground data-[active]:text-accent", children }),
|
|
3573
|
+
description && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-foreground-muted leading-snug mt-0.5", children: description })
|
|
3574
|
+
] })
|
|
3575
|
+
]
|
|
3576
|
+
}
|
|
3577
|
+
);
|
|
3578
|
+
}
|
|
3579
|
+
function MobilePanel({ panel, onNavigate }) {
|
|
3580
|
+
const nodes = React12__default.default.Children.toArray(panel.props.children);
|
|
3581
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-4 px-2 pb-3 pt-1", children: nodes.map((node, i) => {
|
|
3582
|
+
if (!React12__default.default.isValidElement(node)) return null;
|
|
3583
|
+
const el = node;
|
|
3584
|
+
if (el.type === MegaMenuSection) {
|
|
3585
|
+
const { title, children } = el.props;
|
|
3586
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
3587
|
+
title && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "px-2.5 pb-1 text-[11px] font-semibold uppercase tracking-widest text-foreground-muted select-none", children: title }),
|
|
3588
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-0.5", children: elementsOfType(children, MegaMenuLink).map((lnk, j) => /* @__PURE__ */ jsxRuntime.jsx(MobileLinkRow, { link: lnk, onNavigate }, j)) })
|
|
3589
|
+
] }, i);
|
|
3590
|
+
}
|
|
3591
|
+
if (el.type === MegaMenuFeatured) {
|
|
3592
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg bg-surface-raised border border-border p-3 flex flex-col", children: el.props.children }, i);
|
|
3593
|
+
}
|
|
3594
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { children: node }, i);
|
|
3595
|
+
}) });
|
|
3596
|
+
}
|
|
3597
|
+
function MegaMenuMobile({
|
|
3598
|
+
children,
|
|
3599
|
+
label
|
|
3600
|
+
}) {
|
|
3601
|
+
const [open, setOpen] = React12.useState(false);
|
|
3602
|
+
const [expanded, setExpanded] = React12.useState(null);
|
|
3603
|
+
const items = elementsOfType(children, MegaMenuItem);
|
|
3604
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "md:hidden w-full", children: [
|
|
3605
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3606
|
+
"button",
|
|
3607
|
+
{
|
|
3608
|
+
type: "button",
|
|
3609
|
+
onClick: () => setOpen((o) => !o),
|
|
3610
|
+
"aria-expanded": open,
|
|
3611
|
+
className: "inline-flex items-center gap-2 h-10 px-3 rounded-md text-sm font-medium\n text-foreground-secondary hover:text-foreground hover:bg-surface-raised\n focus:outline-none focus-visible:ring-2 focus-visible:ring-accent transition-colors",
|
|
3612
|
+
children: [
|
|
3613
|
+
/* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, "aria-hidden": "true", className: "h-5 w-5", children: open ? /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 6l12 12M18 6L6 18" }) : /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M4 7h16M4 12h16M4 17h16" }) }),
|
|
3614
|
+
label
|
|
3615
|
+
]
|
|
3616
|
+
}
|
|
3617
|
+
),
|
|
3618
|
+
open && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-2 overflow-hidden rounded-lg border border-border bg-surface shadow-lg", children: items.map((item, i) => {
|
|
3619
|
+
const { label: itemLabel, icon, href, children: panel } = item.props;
|
|
3620
|
+
const hasPanel = panel != null;
|
|
3621
|
+
const isOpen = expanded === i;
|
|
3622
|
+
const rowBase = "flex w-full items-center gap-2 px-3 h-11 text-sm font-medium text-foreground-secondary hover:bg-surface-raised hover:text-foreground transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-accent";
|
|
3623
|
+
const divider = i > 0 ? "border-t border-border" : "";
|
|
3624
|
+
if (!hasPanel) {
|
|
3625
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3626
|
+
"a",
|
|
3627
|
+
{
|
|
3628
|
+
href,
|
|
3629
|
+
onClick: () => setOpen(false),
|
|
3630
|
+
className: [rowBase, divider].filter(Boolean).join(" "),
|
|
3631
|
+
children: [
|
|
3632
|
+
icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex h-4 w-4 flex-shrink-0 items-center justify-center", children: icon }),
|
|
3633
|
+
itemLabel
|
|
3634
|
+
]
|
|
3635
|
+
},
|
|
3636
|
+
i
|
|
3637
|
+
);
|
|
3638
|
+
}
|
|
3639
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: divider || void 0, children: [
|
|
3640
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3641
|
+
"button",
|
|
3642
|
+
{
|
|
3643
|
+
type: "button",
|
|
3644
|
+
onClick: () => setExpanded(isOpen ? null : i),
|
|
3645
|
+
"aria-expanded": isOpen,
|
|
3646
|
+
className: [rowBase, isOpen ? "text-accent" : ""].filter(Boolean).join(" "),
|
|
3647
|
+
children: [
|
|
3648
|
+
icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex h-4 w-4 flex-shrink-0 items-center justify-center", children: icon }),
|
|
3649
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-1 text-left", children: itemLabel }),
|
|
3650
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: isOpen ? "rotate-180" : "", children: MOBILE_CHEVRON })
|
|
3651
|
+
]
|
|
3652
|
+
}
|
|
3653
|
+
),
|
|
3654
|
+
isOpen && /* @__PURE__ */ jsxRuntime.jsx(MobilePanel, { panel, onNavigate: () => setOpen(false) })
|
|
3655
|
+
] }, i);
|
|
3656
|
+
}) })
|
|
3657
|
+
] });
|
|
3517
3658
|
}
|
|
3518
3659
|
MegaMenu.Item = MegaMenuItem;
|
|
3519
3660
|
MegaMenu.Panel = MegaMenuPanel;
|
|
@@ -3531,17 +3672,17 @@ function AppShell({
|
|
|
3531
3672
|
children,
|
|
3532
3673
|
className = ""
|
|
3533
3674
|
}) {
|
|
3534
|
-
const [expanded, setExpanded] =
|
|
3535
|
-
const [isMobile, setIsMobile] =
|
|
3536
|
-
const [mobileOpen, setMobileOpen] =
|
|
3537
|
-
|
|
3675
|
+
const [expanded, setExpanded] = React12.useState(sidebarDefaultExpanded);
|
|
3676
|
+
const [isMobile, setIsMobile] = React12.useState(false);
|
|
3677
|
+
const [mobileOpen, setMobileOpen] = React12.useState(false);
|
|
3678
|
+
React12.useEffect(() => {
|
|
3538
3679
|
const mq = window.matchMedia("(max-width: 767px)");
|
|
3539
3680
|
const update = (e) => setIsMobile(e.matches);
|
|
3540
3681
|
update(mq);
|
|
3541
3682
|
mq.addEventListener("change", update);
|
|
3542
3683
|
return () => mq.removeEventListener("change", update);
|
|
3543
3684
|
}, []);
|
|
3544
|
-
|
|
3685
|
+
React12.useEffect(() => {
|
|
3545
3686
|
if (!isMobile) setMobileOpen(false);
|
|
3546
3687
|
}, [isMobile]);
|
|
3547
3688
|
const hasSidebar = sidebarSections.length > 0;
|
|
@@ -3731,10 +3872,10 @@ function ThemeProvider({
|
|
|
3731
3872
|
className = "",
|
|
3732
3873
|
style
|
|
3733
3874
|
}) {
|
|
3734
|
-
const id =
|
|
3875
|
+
const id = React12__default.default.useId().replace(/:/g, "");
|
|
3735
3876
|
const scopeClass = `geo-th-${id}`;
|
|
3736
|
-
const divRef =
|
|
3737
|
-
|
|
3877
|
+
const divRef = React12.useRef(null);
|
|
3878
|
+
React12.useEffect(() => {
|
|
3738
3879
|
const el = divRef.current;
|
|
3739
3880
|
if (!el) return;
|
|
3740
3881
|
if (colorScheme === "auto") return;
|
|
@@ -3749,8 +3890,8 @@ function ThemeProvider({
|
|
|
3749
3890
|
}
|
|
3750
3891
|
el.classList.toggle("dark", colorScheme === "dark");
|
|
3751
3892
|
}, [colorScheme]);
|
|
3752
|
-
const lightVars =
|
|
3753
|
-
const darkVarStr =
|
|
3893
|
+
const lightVars = React12.useMemo(() => toCssVars(theme), [theme]);
|
|
3894
|
+
const darkVarStr = React12.useMemo(() => {
|
|
3754
3895
|
if (!darkTheme) return "";
|
|
3755
3896
|
const dvars = toCssVars(darkTheme);
|
|
3756
3897
|
if (!Object.keys(dvars).length) return "";
|
|
@@ -3790,7 +3931,7 @@ function TextInput({
|
|
|
3790
3931
|
prefix,
|
|
3791
3932
|
suffix
|
|
3792
3933
|
}) {
|
|
3793
|
-
const errorId =
|
|
3934
|
+
const errorId = React12.useId();
|
|
3794
3935
|
const hasError = errorMessage != null;
|
|
3795
3936
|
const hasAdornment = prefix != null || suffix != null;
|
|
3796
3937
|
const input = /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3860,7 +4001,7 @@ function NumberInput({
|
|
|
3860
4001
|
readOnly = false,
|
|
3861
4002
|
precision
|
|
3862
4003
|
}) {
|
|
3863
|
-
const errorId =
|
|
4004
|
+
const errorId = React12.useId();
|
|
3864
4005
|
const hasError = errorMessage != null;
|
|
3865
4006
|
const inferredPrecision = precision ?? (Number.isInteger(step) ? 0 : String(step).split(".")[1]?.length ?? 0);
|
|
3866
4007
|
const round = (n) => {
|
|
@@ -3991,8 +4132,8 @@ function Password({
|
|
|
3991
4132
|
showIcon,
|
|
3992
4133
|
hideIcon
|
|
3993
4134
|
}) {
|
|
3994
|
-
const [visible, setVisible] =
|
|
3995
|
-
const errorId =
|
|
4135
|
+
const [visible, setVisible] = React12.useState(false);
|
|
4136
|
+
const errorId = React12.useId();
|
|
3996
4137
|
const hasError = errorMessage != null;
|
|
3997
4138
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3998
4139
|
Field,
|
|
@@ -4065,7 +4206,7 @@ function Checkbox({
|
|
|
4065
4206
|
}) {
|
|
4066
4207
|
const isChecked = checked ?? value ?? false;
|
|
4067
4208
|
const labelFirst = labelPosition === "left";
|
|
4068
|
-
const errorId =
|
|
4209
|
+
const errorId = React12.useId();
|
|
4069
4210
|
const hasError = errorMessage != null;
|
|
4070
4211
|
const box = /* @__PURE__ */ jsxRuntime.jsx(
|
|
4071
4212
|
CheckboxPrimitive__namespace.Root,
|
|
@@ -4173,8 +4314,8 @@ function RadioGroup({
|
|
|
4173
4314
|
className,
|
|
4174
4315
|
errorMessage
|
|
4175
4316
|
}) {
|
|
4176
|
-
const errorId =
|
|
4177
|
-
const groupId =
|
|
4317
|
+
const errorId = React12.useId();
|
|
4318
|
+
const groupId = React12.useId();
|
|
4178
4319
|
const hasError = errorMessage != null;
|
|
4179
4320
|
const labelFirst = labelPosition === "left";
|
|
4180
4321
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4274,11 +4415,11 @@ function Switch({
|
|
|
4274
4415
|
disabled,
|
|
4275
4416
|
errorMessage
|
|
4276
4417
|
}) {
|
|
4277
|
-
const id =
|
|
4278
|
-
const errorId =
|
|
4418
|
+
const id = React12.useId();
|
|
4419
|
+
const errorId = React12.useId();
|
|
4279
4420
|
const hasError = errorMessage != null;
|
|
4280
4421
|
const isControlled = checked !== void 0;
|
|
4281
|
-
const [internal, setInternal] =
|
|
4422
|
+
const [internal, setInternal] = React12.useState(defaultChecked);
|
|
4282
4423
|
const isOn = isControlled ? checked : internal;
|
|
4283
4424
|
const handle = (c) => {
|
|
4284
4425
|
if (!isControlled) setInternal(c);
|
|
@@ -4351,19 +4492,19 @@ function AutoComplete({
|
|
|
4351
4492
|
required,
|
|
4352
4493
|
htmlFor
|
|
4353
4494
|
}) {
|
|
4354
|
-
const errorId =
|
|
4495
|
+
const errorId = React12.useId();
|
|
4355
4496
|
const hasError = errorMessage != null;
|
|
4356
|
-
const [term, setTerm] =
|
|
4357
|
-
const [open, setOpen] =
|
|
4358
|
-
const [asyncItems, setAsyncItems] =
|
|
4359
|
-
const [loading, setLoading] =
|
|
4497
|
+
const [term, setTerm] = React12.useState("");
|
|
4498
|
+
const [open, setOpen] = React12.useState(false);
|
|
4499
|
+
const [asyncItems, setAsyncItems] = React12.useState([]);
|
|
4500
|
+
const [loading, setLoading] = React12.useState(false);
|
|
4360
4501
|
const isAsync = typeof onSearch === "function";
|
|
4361
|
-
const debounceRef =
|
|
4362
|
-
const requestIdRef =
|
|
4502
|
+
const debounceRef = React12.useRef(null);
|
|
4503
|
+
const requestIdRef = React12.useRef(0);
|
|
4363
4504
|
const staticFiltered = isAsync || !items ? [] : term.trim() ? items.filter(
|
|
4364
4505
|
({ key, label: label2 }) => label2.toLowerCase().includes(term.toLowerCase()) || key.toLowerCase().includes(term.toLowerCase())
|
|
4365
4506
|
) : [];
|
|
4366
|
-
|
|
4507
|
+
React12.useEffect(() => {
|
|
4367
4508
|
if (!isAsync) return;
|
|
4368
4509
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
4369
4510
|
if (!term.trim()) {
|
|
@@ -4519,15 +4660,15 @@ function TreeSelect({
|
|
|
4519
4660
|
defaultExpandedKeys = [],
|
|
4520
4661
|
size = "md"
|
|
4521
4662
|
}) {
|
|
4522
|
-
const errorId =
|
|
4663
|
+
const errorId = React12.useId();
|
|
4523
4664
|
const hasError = errorMessage != null;
|
|
4524
|
-
const [open, setOpen] =
|
|
4525
|
-
const [expanded, setExpanded] =
|
|
4526
|
-
const [activeIndex, setActiveIndex] =
|
|
4527
|
-
const listRef =
|
|
4528
|
-
const visible =
|
|
4529
|
-
const didSyncOnOpenRef =
|
|
4530
|
-
|
|
4665
|
+
const [open, setOpen] = React12.useState(false);
|
|
4666
|
+
const [expanded, setExpanded] = React12.useState(() => new Set(defaultExpandedKeys));
|
|
4667
|
+
const [activeIndex, setActiveIndex] = React12.useState(0);
|
|
4668
|
+
const listRef = React12.useRef(null);
|
|
4669
|
+
const visible = React12.useMemo(() => flattenVisible(items, expanded), [items, expanded]);
|
|
4670
|
+
const didSyncOnOpenRef = React12.useRef(false);
|
|
4671
|
+
React12.useEffect(() => {
|
|
4531
4672
|
if (!open) {
|
|
4532
4673
|
didSyncOnOpenRef.current = false;
|
|
4533
4674
|
return;
|
|
@@ -4537,7 +4678,7 @@ function TreeSelect({
|
|
|
4537
4678
|
setActiveIndex(selectedIdx >= 0 ? selectedIdx : 0);
|
|
4538
4679
|
didSyncOnOpenRef.current = true;
|
|
4539
4680
|
}, [open, value]);
|
|
4540
|
-
const selectedNode =
|
|
4681
|
+
const selectedNode = React12.useMemo(
|
|
4541
4682
|
() => value != null ? findNodeByKey(items, value) : null,
|
|
4542
4683
|
[items, value]
|
|
4543
4684
|
);
|
|
@@ -4768,11 +4909,11 @@ function FileInput({
|
|
|
4768
4909
|
required,
|
|
4769
4910
|
icon
|
|
4770
4911
|
}) {
|
|
4771
|
-
const inputRef =
|
|
4772
|
-
const errorId =
|
|
4773
|
-
const [files, setFiles] =
|
|
4774
|
-
const [dragging, setDragging] =
|
|
4775
|
-
const [sizeError, setSizeError] =
|
|
4912
|
+
const inputRef = React12.useRef(null);
|
|
4913
|
+
const errorId = React12.useId();
|
|
4914
|
+
const [files, setFiles] = React12.useState([]);
|
|
4915
|
+
const [dragging, setDragging] = React12.useState(false);
|
|
4916
|
+
const [sizeError, setSizeError] = React12.useState(null);
|
|
4776
4917
|
const effectiveError = errorMessage ?? sizeError ?? void 0;
|
|
4777
4918
|
const openPicker = () => {
|
|
4778
4919
|
if (!disabled) inputRef.current?.click();
|
|
@@ -4963,30 +5104,30 @@ function DatePicker({
|
|
|
4963
5104
|
size = "md",
|
|
4964
5105
|
className = ""
|
|
4965
5106
|
}) {
|
|
4966
|
-
const errorId =
|
|
5107
|
+
const errorId = React12.useId();
|
|
4967
5108
|
const hasError = errorMessage != null;
|
|
4968
|
-
const [open, setOpen] =
|
|
4969
|
-
const [viewMonth, setViewMonth] =
|
|
4970
|
-
const [focusDate, setFocusDate] =
|
|
4971
|
-
const [view, setView] =
|
|
4972
|
-
const gridRef =
|
|
4973
|
-
|
|
5109
|
+
const [open, setOpen] = React12.useState(false);
|
|
5110
|
+
const [viewMonth, setViewMonth] = React12.useState(() => startOfMonth(value ?? /* @__PURE__ */ new Date()));
|
|
5111
|
+
const [focusDate, setFocusDate] = React12.useState(() => value ?? /* @__PURE__ */ new Date());
|
|
5112
|
+
const [view, setView] = React12.useState("days");
|
|
5113
|
+
const gridRef = React12.useRef(null);
|
|
5114
|
+
React12.useEffect(() => {
|
|
4974
5115
|
if (!open) return;
|
|
4975
5116
|
const target = value ?? /* @__PURE__ */ new Date();
|
|
4976
5117
|
setViewMonth(startOfMonth(target));
|
|
4977
5118
|
setFocusDate(target);
|
|
4978
5119
|
setView("days");
|
|
4979
5120
|
}, [open, value]);
|
|
4980
|
-
|
|
5121
|
+
React12.useEffect(() => {
|
|
4981
5122
|
if (!open) return;
|
|
4982
5123
|
const cell = gridRef.current?.querySelector(`[data-day="${defaultFormat(focusDate)}"]`);
|
|
4983
5124
|
cell?.focus();
|
|
4984
5125
|
}, [open, focusDate]);
|
|
4985
|
-
const weekdays =
|
|
5126
|
+
const weekdays = React12.useMemo(() => {
|
|
4986
5127
|
const ordered = WEEKDAY_SHORT.slice(weekStartsOn).concat(WEEKDAY_SHORT.slice(0, weekStartsOn));
|
|
4987
5128
|
return ordered;
|
|
4988
5129
|
}, [weekStartsOn]);
|
|
4989
|
-
const grid =
|
|
5130
|
+
const grid = React12.useMemo(() => buildGrid(viewMonth, weekStartsOn), [viewMonth, weekStartsOn]);
|
|
4990
5131
|
const isDisabled = (d) => {
|
|
4991
5132
|
if (min && d < min) return true;
|
|
4992
5133
|
if (max && d > max) return true;
|
|
@@ -5276,10 +5417,10 @@ function TextArea({
|
|
|
5276
5417
|
style,
|
|
5277
5418
|
inputStyle
|
|
5278
5419
|
}) {
|
|
5279
|
-
const errorId =
|
|
5420
|
+
const errorId = React12.useId();
|
|
5280
5421
|
const hasError = errorMessage != null;
|
|
5281
|
-
const ref =
|
|
5282
|
-
|
|
5422
|
+
const ref = React12.useRef(null);
|
|
5423
|
+
React12.useLayoutEffect(() => {
|
|
5283
5424
|
if (!autoGrow) return;
|
|
5284
5425
|
const el = ref.current;
|
|
5285
5426
|
if (!el) return;
|
|
@@ -5349,11 +5490,11 @@ function SegmentedControl({
|
|
|
5349
5490
|
"aria-label": ariaLabel
|
|
5350
5491
|
}) {
|
|
5351
5492
|
const sz = SIZE2[size];
|
|
5352
|
-
const groupId =
|
|
5353
|
-
const errorId =
|
|
5493
|
+
const groupId = React12.useId();
|
|
5494
|
+
const errorId = React12.useId();
|
|
5354
5495
|
const hasError = errorMessage != null;
|
|
5355
5496
|
const isControlled = value !== void 0;
|
|
5356
|
-
const [internal, setInternal] =
|
|
5497
|
+
const [internal, setInternal] = React12.useState(defaultValue);
|
|
5357
5498
|
const current = isControlled ? value : internal;
|
|
5358
5499
|
const handle = (v) => {
|
|
5359
5500
|
if (!v) return;
|
|
@@ -5447,14 +5588,14 @@ function Slider({
|
|
|
5447
5588
|
name,
|
|
5448
5589
|
htmlFor
|
|
5449
5590
|
}) {
|
|
5450
|
-
const errorId =
|
|
5591
|
+
const errorId = React12.useId();
|
|
5451
5592
|
const hasError = errorMessage != null;
|
|
5452
5593
|
const isRange = Array.isArray(value ?? defaultValue);
|
|
5453
|
-
const [internal, setInternal] =
|
|
5594
|
+
const [internal, setInternal] = React12.useState(
|
|
5454
5595
|
() => toArray(value) ?? toArray(defaultValue) ?? [min]
|
|
5455
5596
|
);
|
|
5456
5597
|
const current = toArray(value) ?? internal;
|
|
5457
|
-
const [dragging, setDragging] =
|
|
5598
|
+
const [dragging, setDragging] = React12.useState(false);
|
|
5458
5599
|
const emit = (arr) => {
|
|
5459
5600
|
setInternal(arr);
|
|
5460
5601
|
const next = isRange ? [arr[0], arr[1]] : arr[0];
|
|
@@ -5549,11 +5690,11 @@ function TagsInput({
|
|
|
5549
5690
|
validate,
|
|
5550
5691
|
separators = ["Enter", ","]
|
|
5551
5692
|
}) {
|
|
5552
|
-
const errorId =
|
|
5553
|
-
const inputRef =
|
|
5554
|
-
const [internal, setInternal] =
|
|
5555
|
-
const [draft, setDraft] =
|
|
5556
|
-
const [localError, setLocalError] =
|
|
5693
|
+
const errorId = React12.useId();
|
|
5694
|
+
const inputRef = React12.useRef(null);
|
|
5695
|
+
const [internal, setInternal] = React12.useState(defaultValue ?? []);
|
|
5696
|
+
const [draft, setDraft] = React12.useState("");
|
|
5697
|
+
const [localError, setLocalError] = React12.useState(null);
|
|
5557
5698
|
const tags = value ?? internal;
|
|
5558
5699
|
const hasError = errorMessage != null || localError != null;
|
|
5559
5700
|
const errorText = errorMessage ?? localError ?? void 0;
|
|
@@ -5684,9 +5825,9 @@ function OtpInput({
|
|
|
5684
5825
|
className,
|
|
5685
5826
|
groupAfter
|
|
5686
5827
|
}) {
|
|
5687
|
-
const errorId =
|
|
5828
|
+
const errorId = React12.useId();
|
|
5688
5829
|
const hasError = errorMessage != null;
|
|
5689
|
-
const refs =
|
|
5830
|
+
const refs = React12.useRef([]);
|
|
5690
5831
|
const chars = Array.from({ length }, (_, i) => value[i] ?? "");
|
|
5691
5832
|
const pattern = mode === "numeric" ? /[0-9]/ : /[a-zA-Z0-9]/;
|
|
5692
5833
|
const emit = (next) => {
|
|
@@ -5735,7 +5876,7 @@ function OtpInput({
|
|
|
5735
5876
|
emit(valid.join(""));
|
|
5736
5877
|
focusBox(valid.length);
|
|
5737
5878
|
};
|
|
5738
|
-
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(
|
|
5879
|
+
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(React12__default.default.Fragment, { children: [
|
|
5739
5880
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5740
5881
|
"input",
|
|
5741
5882
|
{
|
|
@@ -5793,9 +5934,9 @@ function Rating({
|
|
|
5793
5934
|
className,
|
|
5794
5935
|
required
|
|
5795
5936
|
}) {
|
|
5796
|
-
const errorId =
|
|
5797
|
-
const [internal, setInternal] =
|
|
5798
|
-
const [hover, setHover] =
|
|
5937
|
+
const errorId = React12.useId();
|
|
5938
|
+
const [internal, setInternal] = React12.useState(defaultValue);
|
|
5939
|
+
const [hover, setHover] = React12.useState(null);
|
|
5799
5940
|
const current = value ?? internal;
|
|
5800
5941
|
const display2 = hover ?? current;
|
|
5801
5942
|
const interactive = !readOnly && !disabled;
|
|
@@ -5918,9 +6059,9 @@ function TimePicker({
|
|
|
5918
6059
|
required,
|
|
5919
6060
|
style
|
|
5920
6061
|
}) {
|
|
5921
|
-
const errorId =
|
|
6062
|
+
const errorId = React12.useId();
|
|
5922
6063
|
const hasError = errorMessage != null;
|
|
5923
|
-
const [open, setOpen] =
|
|
6064
|
+
const [open, setOpen] = React12.useState(false);
|
|
5924
6065
|
const parsed = parse(value) ?? { h: 0, m: 0, s: 0 };
|
|
5925
6066
|
const update = (next) => {
|
|
5926
6067
|
const merged = { ...parsed, ...next };
|
|
@@ -6044,13 +6185,13 @@ function DateRangePicker({
|
|
|
6044
6185
|
required,
|
|
6045
6186
|
style
|
|
6046
6187
|
}) {
|
|
6047
|
-
const errorId =
|
|
6188
|
+
const errorId = React12.useId();
|
|
6048
6189
|
const hasError = errorMessage != null;
|
|
6049
|
-
const [open, setOpen] =
|
|
6050
|
-
const [leftMonth, setLeftMonth] =
|
|
6051
|
-
const [pendingStart, setPendingStart] =
|
|
6052
|
-
const [hoverDate, setHoverDate] =
|
|
6053
|
-
const weekdays =
|
|
6190
|
+
const [open, setOpen] = React12.useState(false);
|
|
6191
|
+
const [leftMonth, setLeftMonth] = React12.useState(() => startOfMonth2(value.start ?? /* @__PURE__ */ new Date()));
|
|
6192
|
+
const [pendingStart, setPendingStart] = React12.useState(null);
|
|
6193
|
+
const [hoverDate, setHoverDate] = React12.useState(null);
|
|
6194
|
+
const weekdays = React12.useMemo(
|
|
6054
6195
|
() => WEEKDAY.slice(weekStartsOn).concat(WEEKDAY.slice(0, weekStartsOn)),
|
|
6055
6196
|
[weekStartsOn]
|
|
6056
6197
|
);
|
|
@@ -6226,10 +6367,10 @@ function ColorPicker({
|
|
|
6226
6367
|
required,
|
|
6227
6368
|
placeholder = "Pick a colour\u2026"
|
|
6228
6369
|
}) {
|
|
6229
|
-
const errorId =
|
|
6370
|
+
const errorId = React12.useId();
|
|
6230
6371
|
const hasError = errorMessage != null;
|
|
6231
|
-
const [open, setOpen] =
|
|
6232
|
-
const [draft, setDraft] =
|
|
6372
|
+
const [open, setOpen] = React12.useState(false);
|
|
6373
|
+
const [draft, setDraft] = React12.useState(value);
|
|
6233
6374
|
const valid = HEX_RE.test(value);
|
|
6234
6375
|
const pick = (hex) => {
|
|
6235
6376
|
onChange?.(hex);
|
|
@@ -6616,11 +6757,11 @@ function buildBindings(store, name, kind, snap) {
|
|
|
6616
6757
|
|
|
6617
6758
|
// src/form/useForm.ts
|
|
6618
6759
|
function useForm(options = {}) {
|
|
6619
|
-
const ref =
|
|
6760
|
+
const ref = React12.useRef(null);
|
|
6620
6761
|
if (ref.current === null) ref.current = new FormStore(options);
|
|
6621
6762
|
const store = ref.current;
|
|
6622
|
-
|
|
6623
|
-
const make =
|
|
6763
|
+
React12.useSyncExternalStore(store.subscribe, store.getRootSnapshot, store.getRootSnapshot);
|
|
6764
|
+
const make = React12.useCallback(
|
|
6624
6765
|
(kind) => (name, rules) => {
|
|
6625
6766
|
if (rules !== void 0) store.setRule(name, rules);
|
|
6626
6767
|
return buildBindings(store, name, kind, store.getFieldSnapshot(name));
|
|
@@ -6649,9 +6790,9 @@ function useForm(options = {}) {
|
|
|
6649
6790
|
fieldTarget: make("target")
|
|
6650
6791
|
};
|
|
6651
6792
|
}
|
|
6652
|
-
var FormContext =
|
|
6793
|
+
var FormContext = React12.createContext(null);
|
|
6653
6794
|
function useFormStore() {
|
|
6654
|
-
const store =
|
|
6795
|
+
const store = React12.useContext(FormContext);
|
|
6655
6796
|
if (!store) {
|
|
6656
6797
|
throw new Error("useFormStore must be used within a <Form>. Did you forget to wrap your fields?");
|
|
6657
6798
|
}
|
|
@@ -6665,8 +6806,8 @@ function Form({
|
|
|
6665
6806
|
children,
|
|
6666
6807
|
...rest
|
|
6667
6808
|
}) {
|
|
6668
|
-
const ref =
|
|
6669
|
-
const bypass =
|
|
6809
|
+
const ref = React12.useRef(null);
|
|
6810
|
+
const bypass = React12.useRef(false);
|
|
6670
6811
|
const handleSubmit = async (e) => {
|
|
6671
6812
|
if (bypass.current) {
|
|
6672
6813
|
bypass.current = false;
|
|
@@ -6718,12 +6859,12 @@ function useFormField(name, options = {}) {
|
|
|
6718
6859
|
const store = useFormStore();
|
|
6719
6860
|
const { kind = "value", rules } = options;
|
|
6720
6861
|
if (rules !== void 0 && store.getRule(name) !== rules) store.setRule(name, rules);
|
|
6721
|
-
|
|
6862
|
+
React12.useEffect(() => {
|
|
6722
6863
|
return () => {
|
|
6723
6864
|
if (rules !== void 0) store.removeRule(name);
|
|
6724
6865
|
};
|
|
6725
6866
|
}, [store, name]);
|
|
6726
|
-
const snap =
|
|
6867
|
+
const snap = React12.useSyncExternalStore(
|
|
6727
6868
|
store.subscribe,
|
|
6728
6869
|
() => store.getFieldSnapshot(name)
|
|
6729
6870
|
);
|
|
@@ -6735,7 +6876,7 @@ function FormField({ name, kind, rules, children }) {
|
|
|
6735
6876
|
}
|
|
6736
6877
|
function useFieldArray(name) {
|
|
6737
6878
|
const store = useFormStore();
|
|
6738
|
-
|
|
6879
|
+
React12.useSyncExternalStore(store.subscribe, store.getRootSnapshot, store.getRootSnapshot);
|
|
6739
6880
|
const arr = store.getValue(name) ?? [];
|
|
6740
6881
|
const keys = store.getKeys(name);
|
|
6741
6882
|
return {
|
|
@@ -6858,7 +6999,7 @@ function CreditCardForm({
|
|
|
6858
6999
|
className = "",
|
|
6859
7000
|
style
|
|
6860
7001
|
}) {
|
|
6861
|
-
const initial =
|
|
7002
|
+
const initial = React12.useRef({
|
|
6862
7003
|
number: formatCardNumber(defaultValue?.number ?? ""),
|
|
6863
7004
|
name: defaultValue?.name ?? "",
|
|
6864
7005
|
expiry: formatExpiry(defaultValue?.expiry ?? ""),
|
|
@@ -6867,7 +7008,7 @@ function CreditCardForm({
|
|
|
6867
7008
|
const form = useForm({ initialValues: initial });
|
|
6868
7009
|
const numberStr = String(form.values.number ?? "");
|
|
6869
7010
|
const brand = detectBrand(numberStr);
|
|
6870
|
-
|
|
7011
|
+
React12.useEffect(() => {
|
|
6871
7012
|
onChange?.(toCard(form.values));
|
|
6872
7013
|
}, [form.values.number, form.values.name, form.values.expiry, form.values.cvv]);
|
|
6873
7014
|
const numberBind = form.fieldNative("number", {
|