@geomak/ui 6.2.1 → 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 +340 -201
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +160 -21
- package/dist/index.js.map +1 -1
- package/dist/styles.css +18 -3
- 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,22 +3423,38 @@ function Sidebar({
|
|
|
3423
3423
|
}
|
|
3424
3424
|
) });
|
|
3425
3425
|
}
|
|
3426
|
-
var MegaMenuContext =
|
|
3427
|
-
function MegaMenu({
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
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
|
+
] });
|
|
3438
3454
|
}
|
|
3439
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";
|
|
3440
3456
|
function MegaMenuItem({ label, icon, href, children, className = "" }) {
|
|
3441
|
-
const { align } =
|
|
3457
|
+
const { align } = React12.useContext(MegaMenuContext);
|
|
3442
3458
|
const pos = align === "center" ? "left-1/2 -translate-x-1/2" : align === "end" ? "right-0" : "left-0";
|
|
3443
3459
|
if (!children) {
|
|
3444
3460
|
return /* @__PURE__ */ jsxRuntime.jsx(NavigationMenu__namespace.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs(NavigationMenu__namespace.Link, { href, className: [TOP_ITEM, className].filter(Boolean).join(" "), children: [
|
|
@@ -3475,18 +3491,24 @@ function MegaMenuItem({ label, icon, href, children, className = "" }) {
|
|
|
3475
3491
|
] });
|
|
3476
3492
|
}
|
|
3477
3493
|
function MegaMenuPanel({ children, columns, className = "", style }) {
|
|
3478
|
-
const
|
|
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
|
+
};
|
|
3479
3501
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3480
3502
|
"div",
|
|
3481
3503
|
{
|
|
3482
|
-
className: ["
|
|
3483
|
-
style: { maxWidth, ...style },
|
|
3504
|
+
className: ["grid gap-6 p-6", className].filter(Boolean).join(" "),
|
|
3505
|
+
style: { ...layout, maxWidth: "min(92vw, 960px)", ...style },
|
|
3484
3506
|
children
|
|
3485
3507
|
}
|
|
3486
3508
|
);
|
|
3487
3509
|
}
|
|
3488
3510
|
function MegaMenuSection({ title, children, className = "" }) {
|
|
3489
|
-
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: [
|
|
3490
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 }),
|
|
3491
3513
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-0.5", children })
|
|
3492
3514
|
] });
|
|
@@ -3515,7 +3537,124 @@ function MegaMenuLink({ href, icon, description, active, onClick, children, clas
|
|
|
3515
3537
|
);
|
|
3516
3538
|
}
|
|
3517
3539
|
function MegaMenuFeatured({ children, className = "" }) {
|
|
3518
|
-
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
|
+
] });
|
|
3519
3658
|
}
|
|
3520
3659
|
MegaMenu.Item = MegaMenuItem;
|
|
3521
3660
|
MegaMenu.Panel = MegaMenuPanel;
|
|
@@ -3533,17 +3672,17 @@ function AppShell({
|
|
|
3533
3672
|
children,
|
|
3534
3673
|
className = ""
|
|
3535
3674
|
}) {
|
|
3536
|
-
const [expanded, setExpanded] =
|
|
3537
|
-
const [isMobile, setIsMobile] =
|
|
3538
|
-
const [mobileOpen, setMobileOpen] =
|
|
3539
|
-
|
|
3675
|
+
const [expanded, setExpanded] = React12.useState(sidebarDefaultExpanded);
|
|
3676
|
+
const [isMobile, setIsMobile] = React12.useState(false);
|
|
3677
|
+
const [mobileOpen, setMobileOpen] = React12.useState(false);
|
|
3678
|
+
React12.useEffect(() => {
|
|
3540
3679
|
const mq = window.matchMedia("(max-width: 767px)");
|
|
3541
3680
|
const update = (e) => setIsMobile(e.matches);
|
|
3542
3681
|
update(mq);
|
|
3543
3682
|
mq.addEventListener("change", update);
|
|
3544
3683
|
return () => mq.removeEventListener("change", update);
|
|
3545
3684
|
}, []);
|
|
3546
|
-
|
|
3685
|
+
React12.useEffect(() => {
|
|
3547
3686
|
if (!isMobile) setMobileOpen(false);
|
|
3548
3687
|
}, [isMobile]);
|
|
3549
3688
|
const hasSidebar = sidebarSections.length > 0;
|
|
@@ -3733,10 +3872,10 @@ function ThemeProvider({
|
|
|
3733
3872
|
className = "",
|
|
3734
3873
|
style
|
|
3735
3874
|
}) {
|
|
3736
|
-
const id =
|
|
3875
|
+
const id = React12__default.default.useId().replace(/:/g, "");
|
|
3737
3876
|
const scopeClass = `geo-th-${id}`;
|
|
3738
|
-
const divRef =
|
|
3739
|
-
|
|
3877
|
+
const divRef = React12.useRef(null);
|
|
3878
|
+
React12.useEffect(() => {
|
|
3740
3879
|
const el = divRef.current;
|
|
3741
3880
|
if (!el) return;
|
|
3742
3881
|
if (colorScheme === "auto") return;
|
|
@@ -3751,8 +3890,8 @@ function ThemeProvider({
|
|
|
3751
3890
|
}
|
|
3752
3891
|
el.classList.toggle("dark", colorScheme === "dark");
|
|
3753
3892
|
}, [colorScheme]);
|
|
3754
|
-
const lightVars =
|
|
3755
|
-
const darkVarStr =
|
|
3893
|
+
const lightVars = React12.useMemo(() => toCssVars(theme), [theme]);
|
|
3894
|
+
const darkVarStr = React12.useMemo(() => {
|
|
3756
3895
|
if (!darkTheme) return "";
|
|
3757
3896
|
const dvars = toCssVars(darkTheme);
|
|
3758
3897
|
if (!Object.keys(dvars).length) return "";
|
|
@@ -3792,7 +3931,7 @@ function TextInput({
|
|
|
3792
3931
|
prefix,
|
|
3793
3932
|
suffix
|
|
3794
3933
|
}) {
|
|
3795
|
-
const errorId =
|
|
3934
|
+
const errorId = React12.useId();
|
|
3796
3935
|
const hasError = errorMessage != null;
|
|
3797
3936
|
const hasAdornment = prefix != null || suffix != null;
|
|
3798
3937
|
const input = /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3862,7 +4001,7 @@ function NumberInput({
|
|
|
3862
4001
|
readOnly = false,
|
|
3863
4002
|
precision
|
|
3864
4003
|
}) {
|
|
3865
|
-
const errorId =
|
|
4004
|
+
const errorId = React12.useId();
|
|
3866
4005
|
const hasError = errorMessage != null;
|
|
3867
4006
|
const inferredPrecision = precision ?? (Number.isInteger(step) ? 0 : String(step).split(".")[1]?.length ?? 0);
|
|
3868
4007
|
const round = (n) => {
|
|
@@ -3993,8 +4132,8 @@ function Password({
|
|
|
3993
4132
|
showIcon,
|
|
3994
4133
|
hideIcon
|
|
3995
4134
|
}) {
|
|
3996
|
-
const [visible, setVisible] =
|
|
3997
|
-
const errorId =
|
|
4135
|
+
const [visible, setVisible] = React12.useState(false);
|
|
4136
|
+
const errorId = React12.useId();
|
|
3998
4137
|
const hasError = errorMessage != null;
|
|
3999
4138
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4000
4139
|
Field,
|
|
@@ -4067,7 +4206,7 @@ function Checkbox({
|
|
|
4067
4206
|
}) {
|
|
4068
4207
|
const isChecked = checked ?? value ?? false;
|
|
4069
4208
|
const labelFirst = labelPosition === "left";
|
|
4070
|
-
const errorId =
|
|
4209
|
+
const errorId = React12.useId();
|
|
4071
4210
|
const hasError = errorMessage != null;
|
|
4072
4211
|
const box = /* @__PURE__ */ jsxRuntime.jsx(
|
|
4073
4212
|
CheckboxPrimitive__namespace.Root,
|
|
@@ -4175,8 +4314,8 @@ function RadioGroup({
|
|
|
4175
4314
|
className,
|
|
4176
4315
|
errorMessage
|
|
4177
4316
|
}) {
|
|
4178
|
-
const errorId =
|
|
4179
|
-
const groupId =
|
|
4317
|
+
const errorId = React12.useId();
|
|
4318
|
+
const groupId = React12.useId();
|
|
4180
4319
|
const hasError = errorMessage != null;
|
|
4181
4320
|
const labelFirst = labelPosition === "left";
|
|
4182
4321
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4276,11 +4415,11 @@ function Switch({
|
|
|
4276
4415
|
disabled,
|
|
4277
4416
|
errorMessage
|
|
4278
4417
|
}) {
|
|
4279
|
-
const id =
|
|
4280
|
-
const errorId =
|
|
4418
|
+
const id = React12.useId();
|
|
4419
|
+
const errorId = React12.useId();
|
|
4281
4420
|
const hasError = errorMessage != null;
|
|
4282
4421
|
const isControlled = checked !== void 0;
|
|
4283
|
-
const [internal, setInternal] =
|
|
4422
|
+
const [internal, setInternal] = React12.useState(defaultChecked);
|
|
4284
4423
|
const isOn = isControlled ? checked : internal;
|
|
4285
4424
|
const handle = (c) => {
|
|
4286
4425
|
if (!isControlled) setInternal(c);
|
|
@@ -4353,19 +4492,19 @@ function AutoComplete({
|
|
|
4353
4492
|
required,
|
|
4354
4493
|
htmlFor
|
|
4355
4494
|
}) {
|
|
4356
|
-
const errorId =
|
|
4495
|
+
const errorId = React12.useId();
|
|
4357
4496
|
const hasError = errorMessage != null;
|
|
4358
|
-
const [term, setTerm] =
|
|
4359
|
-
const [open, setOpen] =
|
|
4360
|
-
const [asyncItems, setAsyncItems] =
|
|
4361
|
-
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);
|
|
4362
4501
|
const isAsync = typeof onSearch === "function";
|
|
4363
|
-
const debounceRef =
|
|
4364
|
-
const requestIdRef =
|
|
4502
|
+
const debounceRef = React12.useRef(null);
|
|
4503
|
+
const requestIdRef = React12.useRef(0);
|
|
4365
4504
|
const staticFiltered = isAsync || !items ? [] : term.trim() ? items.filter(
|
|
4366
4505
|
({ key, label: label2 }) => label2.toLowerCase().includes(term.toLowerCase()) || key.toLowerCase().includes(term.toLowerCase())
|
|
4367
4506
|
) : [];
|
|
4368
|
-
|
|
4507
|
+
React12.useEffect(() => {
|
|
4369
4508
|
if (!isAsync) return;
|
|
4370
4509
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
4371
4510
|
if (!term.trim()) {
|
|
@@ -4521,15 +4660,15 @@ function TreeSelect({
|
|
|
4521
4660
|
defaultExpandedKeys = [],
|
|
4522
4661
|
size = "md"
|
|
4523
4662
|
}) {
|
|
4524
|
-
const errorId =
|
|
4663
|
+
const errorId = React12.useId();
|
|
4525
4664
|
const hasError = errorMessage != null;
|
|
4526
|
-
const [open, setOpen] =
|
|
4527
|
-
const [expanded, setExpanded] =
|
|
4528
|
-
const [activeIndex, setActiveIndex] =
|
|
4529
|
-
const listRef =
|
|
4530
|
-
const visible =
|
|
4531
|
-
const didSyncOnOpenRef =
|
|
4532
|
-
|
|
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(() => {
|
|
4533
4672
|
if (!open) {
|
|
4534
4673
|
didSyncOnOpenRef.current = false;
|
|
4535
4674
|
return;
|
|
@@ -4539,7 +4678,7 @@ function TreeSelect({
|
|
|
4539
4678
|
setActiveIndex(selectedIdx >= 0 ? selectedIdx : 0);
|
|
4540
4679
|
didSyncOnOpenRef.current = true;
|
|
4541
4680
|
}, [open, value]);
|
|
4542
|
-
const selectedNode =
|
|
4681
|
+
const selectedNode = React12.useMemo(
|
|
4543
4682
|
() => value != null ? findNodeByKey(items, value) : null,
|
|
4544
4683
|
[items, value]
|
|
4545
4684
|
);
|
|
@@ -4770,11 +4909,11 @@ function FileInput({
|
|
|
4770
4909
|
required,
|
|
4771
4910
|
icon
|
|
4772
4911
|
}) {
|
|
4773
|
-
const inputRef =
|
|
4774
|
-
const errorId =
|
|
4775
|
-
const [files, setFiles] =
|
|
4776
|
-
const [dragging, setDragging] =
|
|
4777
|
-
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);
|
|
4778
4917
|
const effectiveError = errorMessage ?? sizeError ?? void 0;
|
|
4779
4918
|
const openPicker = () => {
|
|
4780
4919
|
if (!disabled) inputRef.current?.click();
|
|
@@ -4965,30 +5104,30 @@ function DatePicker({
|
|
|
4965
5104
|
size = "md",
|
|
4966
5105
|
className = ""
|
|
4967
5106
|
}) {
|
|
4968
|
-
const errorId =
|
|
5107
|
+
const errorId = React12.useId();
|
|
4969
5108
|
const hasError = errorMessage != null;
|
|
4970
|
-
const [open, setOpen] =
|
|
4971
|
-
const [viewMonth, setViewMonth] =
|
|
4972
|
-
const [focusDate, setFocusDate] =
|
|
4973
|
-
const [view, setView] =
|
|
4974
|
-
const gridRef =
|
|
4975
|
-
|
|
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(() => {
|
|
4976
5115
|
if (!open) return;
|
|
4977
5116
|
const target = value ?? /* @__PURE__ */ new Date();
|
|
4978
5117
|
setViewMonth(startOfMonth(target));
|
|
4979
5118
|
setFocusDate(target);
|
|
4980
5119
|
setView("days");
|
|
4981
5120
|
}, [open, value]);
|
|
4982
|
-
|
|
5121
|
+
React12.useEffect(() => {
|
|
4983
5122
|
if (!open) return;
|
|
4984
5123
|
const cell = gridRef.current?.querySelector(`[data-day="${defaultFormat(focusDate)}"]`);
|
|
4985
5124
|
cell?.focus();
|
|
4986
5125
|
}, [open, focusDate]);
|
|
4987
|
-
const weekdays =
|
|
5126
|
+
const weekdays = React12.useMemo(() => {
|
|
4988
5127
|
const ordered = WEEKDAY_SHORT.slice(weekStartsOn).concat(WEEKDAY_SHORT.slice(0, weekStartsOn));
|
|
4989
5128
|
return ordered;
|
|
4990
5129
|
}, [weekStartsOn]);
|
|
4991
|
-
const grid =
|
|
5130
|
+
const grid = React12.useMemo(() => buildGrid(viewMonth, weekStartsOn), [viewMonth, weekStartsOn]);
|
|
4992
5131
|
const isDisabled = (d) => {
|
|
4993
5132
|
if (min && d < min) return true;
|
|
4994
5133
|
if (max && d > max) return true;
|
|
@@ -5278,10 +5417,10 @@ function TextArea({
|
|
|
5278
5417
|
style,
|
|
5279
5418
|
inputStyle
|
|
5280
5419
|
}) {
|
|
5281
|
-
const errorId =
|
|
5420
|
+
const errorId = React12.useId();
|
|
5282
5421
|
const hasError = errorMessage != null;
|
|
5283
|
-
const ref =
|
|
5284
|
-
|
|
5422
|
+
const ref = React12.useRef(null);
|
|
5423
|
+
React12.useLayoutEffect(() => {
|
|
5285
5424
|
if (!autoGrow) return;
|
|
5286
5425
|
const el = ref.current;
|
|
5287
5426
|
if (!el) return;
|
|
@@ -5351,11 +5490,11 @@ function SegmentedControl({
|
|
|
5351
5490
|
"aria-label": ariaLabel
|
|
5352
5491
|
}) {
|
|
5353
5492
|
const sz = SIZE2[size];
|
|
5354
|
-
const groupId =
|
|
5355
|
-
const errorId =
|
|
5493
|
+
const groupId = React12.useId();
|
|
5494
|
+
const errorId = React12.useId();
|
|
5356
5495
|
const hasError = errorMessage != null;
|
|
5357
5496
|
const isControlled = value !== void 0;
|
|
5358
|
-
const [internal, setInternal] =
|
|
5497
|
+
const [internal, setInternal] = React12.useState(defaultValue);
|
|
5359
5498
|
const current = isControlled ? value : internal;
|
|
5360
5499
|
const handle = (v) => {
|
|
5361
5500
|
if (!v) return;
|
|
@@ -5449,14 +5588,14 @@ function Slider({
|
|
|
5449
5588
|
name,
|
|
5450
5589
|
htmlFor
|
|
5451
5590
|
}) {
|
|
5452
|
-
const errorId =
|
|
5591
|
+
const errorId = React12.useId();
|
|
5453
5592
|
const hasError = errorMessage != null;
|
|
5454
5593
|
const isRange = Array.isArray(value ?? defaultValue);
|
|
5455
|
-
const [internal, setInternal] =
|
|
5594
|
+
const [internal, setInternal] = React12.useState(
|
|
5456
5595
|
() => toArray(value) ?? toArray(defaultValue) ?? [min]
|
|
5457
5596
|
);
|
|
5458
5597
|
const current = toArray(value) ?? internal;
|
|
5459
|
-
const [dragging, setDragging] =
|
|
5598
|
+
const [dragging, setDragging] = React12.useState(false);
|
|
5460
5599
|
const emit = (arr) => {
|
|
5461
5600
|
setInternal(arr);
|
|
5462
5601
|
const next = isRange ? [arr[0], arr[1]] : arr[0];
|
|
@@ -5551,11 +5690,11 @@ function TagsInput({
|
|
|
5551
5690
|
validate,
|
|
5552
5691
|
separators = ["Enter", ","]
|
|
5553
5692
|
}) {
|
|
5554
|
-
const errorId =
|
|
5555
|
-
const inputRef =
|
|
5556
|
-
const [internal, setInternal] =
|
|
5557
|
-
const [draft, setDraft] =
|
|
5558
|
-
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);
|
|
5559
5698
|
const tags = value ?? internal;
|
|
5560
5699
|
const hasError = errorMessage != null || localError != null;
|
|
5561
5700
|
const errorText = errorMessage ?? localError ?? void 0;
|
|
@@ -5686,9 +5825,9 @@ function OtpInput({
|
|
|
5686
5825
|
className,
|
|
5687
5826
|
groupAfter
|
|
5688
5827
|
}) {
|
|
5689
|
-
const errorId =
|
|
5828
|
+
const errorId = React12.useId();
|
|
5690
5829
|
const hasError = errorMessage != null;
|
|
5691
|
-
const refs =
|
|
5830
|
+
const refs = React12.useRef([]);
|
|
5692
5831
|
const chars = Array.from({ length }, (_, i) => value[i] ?? "");
|
|
5693
5832
|
const pattern = mode === "numeric" ? /[0-9]/ : /[a-zA-Z0-9]/;
|
|
5694
5833
|
const emit = (next) => {
|
|
@@ -5737,7 +5876,7 @@ function OtpInput({
|
|
|
5737
5876
|
emit(valid.join(""));
|
|
5738
5877
|
focusBox(valid.length);
|
|
5739
5878
|
};
|
|
5740
|
-
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: [
|
|
5741
5880
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5742
5881
|
"input",
|
|
5743
5882
|
{
|
|
@@ -5795,9 +5934,9 @@ function Rating({
|
|
|
5795
5934
|
className,
|
|
5796
5935
|
required
|
|
5797
5936
|
}) {
|
|
5798
|
-
const errorId =
|
|
5799
|
-
const [internal, setInternal] =
|
|
5800
|
-
const [hover, setHover] =
|
|
5937
|
+
const errorId = React12.useId();
|
|
5938
|
+
const [internal, setInternal] = React12.useState(defaultValue);
|
|
5939
|
+
const [hover, setHover] = React12.useState(null);
|
|
5801
5940
|
const current = value ?? internal;
|
|
5802
5941
|
const display2 = hover ?? current;
|
|
5803
5942
|
const interactive = !readOnly && !disabled;
|
|
@@ -5920,9 +6059,9 @@ function TimePicker({
|
|
|
5920
6059
|
required,
|
|
5921
6060
|
style
|
|
5922
6061
|
}) {
|
|
5923
|
-
const errorId =
|
|
6062
|
+
const errorId = React12.useId();
|
|
5924
6063
|
const hasError = errorMessage != null;
|
|
5925
|
-
const [open, setOpen] =
|
|
6064
|
+
const [open, setOpen] = React12.useState(false);
|
|
5926
6065
|
const parsed = parse(value) ?? { h: 0, m: 0, s: 0 };
|
|
5927
6066
|
const update = (next) => {
|
|
5928
6067
|
const merged = { ...parsed, ...next };
|
|
@@ -6046,13 +6185,13 @@ function DateRangePicker({
|
|
|
6046
6185
|
required,
|
|
6047
6186
|
style
|
|
6048
6187
|
}) {
|
|
6049
|
-
const errorId =
|
|
6188
|
+
const errorId = React12.useId();
|
|
6050
6189
|
const hasError = errorMessage != null;
|
|
6051
|
-
const [open, setOpen] =
|
|
6052
|
-
const [leftMonth, setLeftMonth] =
|
|
6053
|
-
const [pendingStart, setPendingStart] =
|
|
6054
|
-
const [hoverDate, setHoverDate] =
|
|
6055
|
-
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(
|
|
6056
6195
|
() => WEEKDAY.slice(weekStartsOn).concat(WEEKDAY.slice(0, weekStartsOn)),
|
|
6057
6196
|
[weekStartsOn]
|
|
6058
6197
|
);
|
|
@@ -6228,10 +6367,10 @@ function ColorPicker({
|
|
|
6228
6367
|
required,
|
|
6229
6368
|
placeholder = "Pick a colour\u2026"
|
|
6230
6369
|
}) {
|
|
6231
|
-
const errorId =
|
|
6370
|
+
const errorId = React12.useId();
|
|
6232
6371
|
const hasError = errorMessage != null;
|
|
6233
|
-
const [open, setOpen] =
|
|
6234
|
-
const [draft, setDraft] =
|
|
6372
|
+
const [open, setOpen] = React12.useState(false);
|
|
6373
|
+
const [draft, setDraft] = React12.useState(value);
|
|
6235
6374
|
const valid = HEX_RE.test(value);
|
|
6236
6375
|
const pick = (hex) => {
|
|
6237
6376
|
onChange?.(hex);
|
|
@@ -6618,11 +6757,11 @@ function buildBindings(store, name, kind, snap) {
|
|
|
6618
6757
|
|
|
6619
6758
|
// src/form/useForm.ts
|
|
6620
6759
|
function useForm(options = {}) {
|
|
6621
|
-
const ref =
|
|
6760
|
+
const ref = React12.useRef(null);
|
|
6622
6761
|
if (ref.current === null) ref.current = new FormStore(options);
|
|
6623
6762
|
const store = ref.current;
|
|
6624
|
-
|
|
6625
|
-
const make =
|
|
6763
|
+
React12.useSyncExternalStore(store.subscribe, store.getRootSnapshot, store.getRootSnapshot);
|
|
6764
|
+
const make = React12.useCallback(
|
|
6626
6765
|
(kind) => (name, rules) => {
|
|
6627
6766
|
if (rules !== void 0) store.setRule(name, rules);
|
|
6628
6767
|
return buildBindings(store, name, kind, store.getFieldSnapshot(name));
|
|
@@ -6651,9 +6790,9 @@ function useForm(options = {}) {
|
|
|
6651
6790
|
fieldTarget: make("target")
|
|
6652
6791
|
};
|
|
6653
6792
|
}
|
|
6654
|
-
var FormContext =
|
|
6793
|
+
var FormContext = React12.createContext(null);
|
|
6655
6794
|
function useFormStore() {
|
|
6656
|
-
const store =
|
|
6795
|
+
const store = React12.useContext(FormContext);
|
|
6657
6796
|
if (!store) {
|
|
6658
6797
|
throw new Error("useFormStore must be used within a <Form>. Did you forget to wrap your fields?");
|
|
6659
6798
|
}
|
|
@@ -6667,8 +6806,8 @@ function Form({
|
|
|
6667
6806
|
children,
|
|
6668
6807
|
...rest
|
|
6669
6808
|
}) {
|
|
6670
|
-
const ref =
|
|
6671
|
-
const bypass =
|
|
6809
|
+
const ref = React12.useRef(null);
|
|
6810
|
+
const bypass = React12.useRef(false);
|
|
6672
6811
|
const handleSubmit = async (e) => {
|
|
6673
6812
|
if (bypass.current) {
|
|
6674
6813
|
bypass.current = false;
|
|
@@ -6720,12 +6859,12 @@ function useFormField(name, options = {}) {
|
|
|
6720
6859
|
const store = useFormStore();
|
|
6721
6860
|
const { kind = "value", rules } = options;
|
|
6722
6861
|
if (rules !== void 0 && store.getRule(name) !== rules) store.setRule(name, rules);
|
|
6723
|
-
|
|
6862
|
+
React12.useEffect(() => {
|
|
6724
6863
|
return () => {
|
|
6725
6864
|
if (rules !== void 0) store.removeRule(name);
|
|
6726
6865
|
};
|
|
6727
6866
|
}, [store, name]);
|
|
6728
|
-
const snap =
|
|
6867
|
+
const snap = React12.useSyncExternalStore(
|
|
6729
6868
|
store.subscribe,
|
|
6730
6869
|
() => store.getFieldSnapshot(name)
|
|
6731
6870
|
);
|
|
@@ -6737,7 +6876,7 @@ function FormField({ name, kind, rules, children }) {
|
|
|
6737
6876
|
}
|
|
6738
6877
|
function useFieldArray(name) {
|
|
6739
6878
|
const store = useFormStore();
|
|
6740
|
-
|
|
6879
|
+
React12.useSyncExternalStore(store.subscribe, store.getRootSnapshot, store.getRootSnapshot);
|
|
6741
6880
|
const arr = store.getValue(name) ?? [];
|
|
6742
6881
|
const keys = store.getKeys(name);
|
|
6743
6882
|
return {
|
|
@@ -6860,7 +6999,7 @@ function CreditCardForm({
|
|
|
6860
6999
|
className = "",
|
|
6861
7000
|
style
|
|
6862
7001
|
}) {
|
|
6863
|
-
const initial =
|
|
7002
|
+
const initial = React12.useRef({
|
|
6864
7003
|
number: formatCardNumber(defaultValue?.number ?? ""),
|
|
6865
7004
|
name: defaultValue?.name ?? "",
|
|
6866
7005
|
expiry: formatExpiry(defaultValue?.expiry ?? ""),
|
|
@@ -6869,7 +7008,7 @@ function CreditCardForm({
|
|
|
6869
7008
|
const form = useForm({ initialValues: initial });
|
|
6870
7009
|
const numberStr = String(form.values.number ?? "");
|
|
6871
7010
|
const brand = detectBrand(numberStr);
|
|
6872
|
-
|
|
7011
|
+
React12.useEffect(() => {
|
|
6873
7012
|
onChange?.(toCard(form.values));
|
|
6874
7013
|
}, [form.values.number, form.values.name, form.values.expiry, form.values.cvv]);
|
|
6875
7014
|
const numberBind = form.fieldNative("number", {
|