@geomak/ui 7.9.0 → 7.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +493 -428
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +37 -5
- package/dist/index.d.ts +37 -5
- package/dist/index.js +136 -71
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var chunk4V4U2W7K_cjs = require('./chunk-4V4U2W7K.cjs');
|
|
4
4
|
var chunkCNUDNGJM_cjs = require('./chunk-CNUDNGJM.cjs');
|
|
5
|
-
var
|
|
5
|
+
var React36 = require('react');
|
|
6
6
|
var reactDom = require('react-dom');
|
|
7
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
8
|
var AvatarPrimitive = require('@radix-ui/react-avatar');
|
|
@@ -41,7 +41,7 @@ function _interopNamespace(e) {
|
|
|
41
41
|
return Object.freeze(n);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
var
|
|
44
|
+
var React36__default = /*#__PURE__*/_interopDefault(React36);
|
|
45
45
|
var AvatarPrimitive__namespace = /*#__PURE__*/_interopNamespace(AvatarPrimitive);
|
|
46
46
|
var DropdownMenu2__namespace = /*#__PURE__*/_interopNamespace(DropdownMenu2);
|
|
47
47
|
var Dialog__namespace = /*#__PURE__*/_interopNamespace(Dialog);
|
|
@@ -67,8 +67,8 @@ function cx(...values) {
|
|
|
67
67
|
return out;
|
|
68
68
|
}
|
|
69
69
|
function Portal({ children, target }) {
|
|
70
|
-
const [resolved, setResolved] =
|
|
71
|
-
|
|
70
|
+
const [resolved, setResolved] = React36.useState(null);
|
|
71
|
+
React36.useEffect(() => {
|
|
72
72
|
if (target === null) {
|
|
73
73
|
setResolved(null);
|
|
74
74
|
return;
|
|
@@ -489,7 +489,7 @@ function Typography({
|
|
|
489
489
|
}
|
|
490
490
|
);
|
|
491
491
|
}
|
|
492
|
-
var IconButton =
|
|
492
|
+
var IconButton = React36__default.default.forwardRef(function IconButton2({
|
|
493
493
|
icon,
|
|
494
494
|
onClick,
|
|
495
495
|
type = "primary",
|
|
@@ -502,7 +502,7 @@ var IconButton = React34__default.default.forwardRef(function IconButton2({
|
|
|
502
502
|
className = "",
|
|
503
503
|
style
|
|
504
504
|
}, ref) {
|
|
505
|
-
const colorScheme =
|
|
505
|
+
const colorScheme = React36.useMemo(() => {
|
|
506
506
|
if (type === "primary") {
|
|
507
507
|
return "bg-accent text-accent-fg hover:bg-accent-hover";
|
|
508
508
|
}
|
|
@@ -598,7 +598,7 @@ var SIZE_CLASSES = {
|
|
|
598
598
|
md: "h-9 px-4 text-sm gap-1.5 rounded-lg",
|
|
599
599
|
lg: "h-11 px-5 text-sm gap-2 rounded-xl"
|
|
600
600
|
};
|
|
601
|
-
var Button =
|
|
601
|
+
var Button = React36__default.default.forwardRef(function Button2({
|
|
602
602
|
content,
|
|
603
603
|
variant = "primary",
|
|
604
604
|
size = "md",
|
|
@@ -706,7 +706,7 @@ function MenuButton({
|
|
|
706
706
|
"data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",
|
|
707
707
|
"data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95"
|
|
708
708
|
].join(" "),
|
|
709
|
-
children: items.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
709
|
+
children: items.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(React36__default.default.Fragment, { children: [
|
|
710
710
|
item.separatorBefore && /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu2__namespace.Separator, { className: "my-1 h-px bg-border" }),
|
|
711
711
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
712
712
|
DropdownMenu2__namespace.Item,
|
|
@@ -729,6 +729,10 @@ function MenuButton({
|
|
|
729
729
|
) })
|
|
730
730
|
] });
|
|
731
731
|
}
|
|
732
|
+
var DialogContainerContext = React36.createContext(null);
|
|
733
|
+
function useDialogContainer() {
|
|
734
|
+
return React36.useContext(DialogContainerContext);
|
|
735
|
+
}
|
|
732
736
|
var SIZE_MAP = {
|
|
733
737
|
sm: 400,
|
|
734
738
|
md: 600,
|
|
@@ -753,6 +757,7 @@ function Modal({
|
|
|
753
757
|
className = ""
|
|
754
758
|
}) {
|
|
755
759
|
const reduced = framerMotion.useReducedMotion();
|
|
760
|
+
const [panelEl, setPanelEl] = React36.useState(null);
|
|
756
761
|
const maxWidth = width ?? SIZE_MAP[size];
|
|
757
762
|
return /* @__PURE__ */ jsxRuntime.jsx(Dialog__namespace.Root, { open, onOpenChange: (next) => {
|
|
758
763
|
if (!next) onClose?.();
|
|
@@ -770,6 +775,7 @@ function Modal({
|
|
|
770
775
|
/* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children: open && /* @__PURE__ */ jsxRuntime.jsx(Dialog__namespace.Content, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
771
776
|
framerMotion.motion.div,
|
|
772
777
|
{
|
|
778
|
+
ref: setPanelEl,
|
|
773
779
|
className: `fixed left-1/2 top-1/2 z-modal flex flex-col w-[calc(100%-2rem)] max-h-[90dvh] bg-surface rounded-2xl shadow-xl overflow-hidden focus:outline-none ${className}`.trim(),
|
|
774
780
|
style: {
|
|
775
781
|
maxWidth,
|
|
@@ -797,7 +803,7 @@ function Modal({
|
|
|
797
803
|
}
|
|
798
804
|
) })
|
|
799
805
|
] }),
|
|
800
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: `flex-1 overflow-y-auto p-5 ${hasFooter ? "" : "pb-5"}`, children }),
|
|
806
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: `flex-1 overflow-y-auto p-5 ${hasFooter ? "" : "pb-5"}`, children: /* @__PURE__ */ jsxRuntime.jsx(DialogContainerContext.Provider, { value: panelEl, children }) }),
|
|
801
807
|
hasFooter && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-shrink-0 items-center justify-end gap-3 border-t border-border px-5 py-3", children: [
|
|
802
808
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
803
809
|
Button_default,
|
|
@@ -848,6 +854,7 @@ function Drawer({
|
|
|
848
854
|
className = ""
|
|
849
855
|
}) {
|
|
850
856
|
const reduced = framerMotion.useReducedMotion();
|
|
857
|
+
const [panelEl, setPanelEl] = React36.useState(null);
|
|
851
858
|
const isRight = placement === "right";
|
|
852
859
|
const hiddenX = isRight ? "100%" : "-100%";
|
|
853
860
|
const resolvedWidth = width ?? SIZE_MAP2[size];
|
|
@@ -868,6 +875,7 @@ function Drawer({
|
|
|
868
875
|
/* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children: open && /* @__PURE__ */ jsxRuntime.jsx(Dialog__namespace.Content, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
869
876
|
framerMotion.motion.div,
|
|
870
877
|
{
|
|
878
|
+
ref: setPanelEl,
|
|
871
879
|
className: `fixed top-0 bottom-0 ${isRight ? "right-0" : "left-0"} z-modal flex flex-col bg-surface shadow-xl focus:outline-none ${className}`.trim(),
|
|
872
880
|
style: { width: `min(calc(100vw - 1rem), ${widthCss})` },
|
|
873
881
|
initial: { x: reduced ? 0 : hiddenX, opacity: reduced ? 0 : 1 },
|
|
@@ -894,7 +902,7 @@ function Drawer({
|
|
|
894
902
|
}
|
|
895
903
|
) })
|
|
896
904
|
] }),
|
|
897
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 overflow-y-auto p-5", children }),
|
|
905
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 overflow-y-auto p-5", children: /* @__PURE__ */ jsxRuntime.jsx(DialogContainerContext.Provider, { value: panelEl, children }) }),
|
|
898
906
|
hasFooter && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `flex flex-shrink-0 items-center gap-3 border-t border-border px-5 py-3 ${isRight ? "justify-start" : "justify-end"}`, children: [
|
|
899
907
|
/* @__PURE__ */ jsxRuntime.jsx(Button_default, { style: { width: 90 }, variant: cancelVariant, content: cancelText, onClick: onCancel }),
|
|
900
908
|
/* @__PURE__ */ jsxRuntime.jsx(Button_default, { style: { width: 90 }, variant: okVariant, content: okText, onClick: onOk })
|
|
@@ -955,9 +963,9 @@ function Tooltip({
|
|
|
955
963
|
] }) });
|
|
956
964
|
}
|
|
957
965
|
var TooltipProvider = TooltipPrimitive__namespace.Provider;
|
|
958
|
-
var TabsContext =
|
|
966
|
+
var TabsContext = React36.createContext(null);
|
|
959
967
|
function useTabsContext() {
|
|
960
|
-
const ctx =
|
|
968
|
+
const ctx = React36.useContext(TabsContext);
|
|
961
969
|
if (!ctx) throw new Error("Tabs.List / Tabs.Trigger / Tabs.Panel must be rendered inside <Tabs>.");
|
|
962
970
|
return ctx;
|
|
963
971
|
}
|
|
@@ -979,26 +987,26 @@ function Tabs({
|
|
|
979
987
|
children
|
|
980
988
|
}) {
|
|
981
989
|
const isControlled = value !== void 0;
|
|
982
|
-
const [internal, setInternal] =
|
|
990
|
+
const [internal, setInternal] = React36.useState(defaultValue);
|
|
983
991
|
const current = isControlled ? value : internal;
|
|
984
992
|
const reduced = !!framerMotion.useReducedMotion();
|
|
985
|
-
const indicatorId =
|
|
986
|
-
const select =
|
|
993
|
+
const indicatorId = React36.useId();
|
|
994
|
+
const select = React36.useCallback((next) => {
|
|
987
995
|
if (!isControlled) setInternal(next);
|
|
988
996
|
onChange?.(next);
|
|
989
997
|
}, [isControlled, onChange]);
|
|
990
|
-
const registry =
|
|
991
|
-
const orderRef =
|
|
992
|
-
const [, bump] =
|
|
993
|
-
const registerTab =
|
|
998
|
+
const registry = React36.useRef(/* @__PURE__ */ new Map());
|
|
999
|
+
const orderRef = React36.useRef(0);
|
|
1000
|
+
const [, bump] = React36.useState(0);
|
|
1001
|
+
const registerTab = React36.useCallback((val, meta) => {
|
|
994
1002
|
const existing = registry.current.get(val);
|
|
995
1003
|
registry.current.set(val, { ...meta, order: existing?.order ?? orderRef.current++ });
|
|
996
1004
|
if (!existing) bump((v) => v + 1);
|
|
997
1005
|
}, []);
|
|
998
|
-
const unregisterTab =
|
|
1006
|
+
const unregisterTab = React36.useCallback((val) => {
|
|
999
1007
|
if (registry.current.delete(val)) bump((v) => v + 1);
|
|
1000
1008
|
}, []);
|
|
1001
|
-
const getTabs =
|
|
1009
|
+
const getTabs = React36.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 })), []);
|
|
1002
1010
|
return /* @__PURE__ */ jsxRuntime.jsx(TabsContext.Provider, { value: { value: current, variant, size, orientation, indicatorId, reduced, select, registerTab, unregisterTab, getTabs }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1003
1011
|
TabsPrimitive__namespace.Root,
|
|
1004
1012
|
{
|
|
@@ -1018,10 +1026,10 @@ function Tabs({
|
|
|
1018
1026
|
function TabsList({ children, "aria-label": ariaLabel, className = "" }) {
|
|
1019
1027
|
const { variant, orientation, reduced, value } = useTabsContext();
|
|
1020
1028
|
const horizontal = orientation === "horizontal";
|
|
1021
|
-
const scrollRef =
|
|
1022
|
-
const [edges, setEdges] =
|
|
1029
|
+
const scrollRef = React36.useRef(null);
|
|
1030
|
+
const [edges, setEdges] = React36.useState({ start: false, end: false });
|
|
1023
1031
|
const scrollable = variant !== "segmented";
|
|
1024
|
-
|
|
1032
|
+
React36.useLayoutEffect(() => {
|
|
1025
1033
|
const el = scrollRef.current;
|
|
1026
1034
|
if (!el || !scrollable) return;
|
|
1027
1035
|
const update = () => {
|
|
@@ -1046,13 +1054,13 @@ function TabsList({ children, "aria-label": ariaLabel, className = "" }) {
|
|
|
1046
1054
|
ro.disconnect();
|
|
1047
1055
|
};
|
|
1048
1056
|
}, [horizontal, scrollable, children]);
|
|
1049
|
-
const nudge =
|
|
1057
|
+
const nudge = React36.useCallback((dir) => {
|
|
1050
1058
|
const el = scrollRef.current;
|
|
1051
1059
|
if (!el) return;
|
|
1052
1060
|
const amount = (horizontal ? el.clientWidth : el.clientHeight) * 0.7 * dir;
|
|
1053
1061
|
el.scrollBy({ [horizontal ? "left" : "top"]: amount, behavior: reduced ? "auto" : "smooth" });
|
|
1054
1062
|
}, [horizontal, reduced]);
|
|
1055
|
-
|
|
1063
|
+
React36.useLayoutEffect(() => {
|
|
1056
1064
|
const el = scrollRef.current;
|
|
1057
1065
|
if (!el || !scrollable) return;
|
|
1058
1066
|
const active = el.querySelector("[role=tab][data-state=active]");
|
|
@@ -1110,9 +1118,9 @@ function Chevron2({ side, orientation, onClick }) {
|
|
|
1110
1118
|
function OverflowMenu() {
|
|
1111
1119
|
const { getTabs, value, select, orientation } = useTabsContext();
|
|
1112
1120
|
const horizontal = orientation === "horizontal";
|
|
1113
|
-
const [open, setOpen] =
|
|
1114
|
-
const wrapRef =
|
|
1115
|
-
const timer =
|
|
1121
|
+
const [open, setOpen] = React36.useState(false);
|
|
1122
|
+
const wrapRef = React36.useRef(null);
|
|
1123
|
+
const timer = React36.useRef(null);
|
|
1116
1124
|
const openNow = () => {
|
|
1117
1125
|
if (timer.current) clearTimeout(timer.current);
|
|
1118
1126
|
setOpen(true);
|
|
@@ -1120,7 +1128,7 @@ function OverflowMenu() {
|
|
|
1120
1128
|
const closeSoon = () => {
|
|
1121
1129
|
timer.current = setTimeout(() => setOpen(false), 160);
|
|
1122
1130
|
};
|
|
1123
|
-
|
|
1131
|
+
React36.useLayoutEffect(() => {
|
|
1124
1132
|
if (!open) return;
|
|
1125
1133
|
const onDoc = (e) => {
|
|
1126
1134
|
if (wrapRef.current && !wrapRef.current.contains(e.target)) setOpen(false);
|
|
@@ -1201,7 +1209,7 @@ function TabsTrigger({ value, icon, badge, closeable, onClose, disabled, classNa
|
|
|
1201
1209
|
const isActive = active === value;
|
|
1202
1210
|
const horizontal = orientation === "horizontal";
|
|
1203
1211
|
const sz = SIZE[size];
|
|
1204
|
-
|
|
1212
|
+
React36.useLayoutEffect(() => {
|
|
1205
1213
|
registerTab(value, { label: children, icon, disabled });
|
|
1206
1214
|
return () => unregisterTab(value);
|
|
1207
1215
|
}, [value, children, icon, disabled, registerTab, unregisterTab]);
|
|
@@ -1400,7 +1408,7 @@ function Tree({
|
|
|
1400
1408
|
item.key
|
|
1401
1409
|
)) });
|
|
1402
1410
|
}
|
|
1403
|
-
var AccordionCtx =
|
|
1411
|
+
var AccordionCtx = React36.createContext({ variant: "separated" });
|
|
1404
1412
|
function Accordion2({
|
|
1405
1413
|
children,
|
|
1406
1414
|
type = "single",
|
|
@@ -1459,7 +1467,7 @@ var Chevron3 = /* @__PURE__ */ jsxRuntime.jsx(
|
|
|
1459
1467
|
}
|
|
1460
1468
|
);
|
|
1461
1469
|
function AccordionItem({ value, title, icon, children, disabled, className = "" }) {
|
|
1462
|
-
const { variant } =
|
|
1470
|
+
const { variant } = React36.useContext(AccordionCtx);
|
|
1463
1471
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1464
1472
|
AccordionPrimitive__namespace.Item,
|
|
1465
1473
|
{
|
|
@@ -1518,7 +1526,7 @@ function Breadcrumbs({
|
|
|
1518
1526
|
className = "",
|
|
1519
1527
|
style
|
|
1520
1528
|
}) {
|
|
1521
|
-
const [expanded, setExpanded] =
|
|
1529
|
+
const [expanded, setExpanded] = React36.useState(false);
|
|
1522
1530
|
const shouldCollapse = maxItems > 0 && items.length > maxItems && !expanded;
|
|
1523
1531
|
const visible = [];
|
|
1524
1532
|
if (shouldCollapse) {
|
|
@@ -1743,8 +1751,8 @@ function Stepper({
|
|
|
1743
1751
|
className = ""
|
|
1744
1752
|
}) {
|
|
1745
1753
|
const reduced = framerMotion.useReducedMotion();
|
|
1746
|
-
const [forcedVertical, setForcedVertical] =
|
|
1747
|
-
|
|
1754
|
+
const [forcedVertical, setForcedVertical] = React36.useState(false);
|
|
1755
|
+
React36.useEffect(() => {
|
|
1748
1756
|
if (!responsive || orientation === "vertical") return;
|
|
1749
1757
|
if (typeof window === "undefined" || typeof window.matchMedia !== "function") return;
|
|
1750
1758
|
const mq = window.matchMedia("(max-width: 767px)");
|
|
@@ -1853,7 +1861,7 @@ function Kbd({
|
|
|
1853
1861
|
style
|
|
1854
1862
|
}) {
|
|
1855
1863
|
if (keys && keys.length > 0) {
|
|
1856
|
-
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: cx("inline-flex items-center gap-1", className), style, children: keys.map((k, i) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1864
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: cx("inline-flex items-center gap-1", className), style, children: keys.map((k, i) => /* @__PURE__ */ jsxRuntime.jsxs(React36__default.default.Fragment, { children: [
|
|
1857
1865
|
i > 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground-muted text-xs select-none", children: separator }),
|
|
1858
1866
|
/* @__PURE__ */ jsxRuntime.jsx("kbd", { className: [cap, SIZE3[size]].join(" "), children: k })
|
|
1859
1867
|
] }, `${k}-${i}`)) });
|
|
@@ -1944,13 +1952,13 @@ function FlatCarousel({
|
|
|
1944
1952
|
className = "",
|
|
1945
1953
|
style
|
|
1946
1954
|
}) {
|
|
1947
|
-
const scrollerRef =
|
|
1948
|
-
const slides =
|
|
1949
|
-
const [active, setActive] =
|
|
1950
|
-
const [atStart, setAtStart] =
|
|
1951
|
-
const [atEnd, setAtEnd] =
|
|
1955
|
+
const scrollerRef = React36.useRef(null);
|
|
1956
|
+
const slides = React36__default.default.Children.toArray(children);
|
|
1957
|
+
const [active, setActive] = React36.useState(0);
|
|
1958
|
+
const [atStart, setAtStart] = React36.useState(true);
|
|
1959
|
+
const [atEnd, setAtEnd] = React36.useState(false);
|
|
1952
1960
|
const width = typeof itemWidth === "number" ? `${itemWidth}px` : itemWidth;
|
|
1953
|
-
const update =
|
|
1961
|
+
const update = React36.useCallback(() => {
|
|
1954
1962
|
const el = scrollerRef.current;
|
|
1955
1963
|
if (!el) return;
|
|
1956
1964
|
setAtStart(el.scrollLeft <= 1);
|
|
@@ -1959,7 +1967,7 @@ function FlatCarousel({
|
|
|
1959
1967
|
const slideW = first ? first.getBoundingClientRect().width + gap : el.clientWidth;
|
|
1960
1968
|
setActive(Math.round(el.scrollLeft / slideW));
|
|
1961
1969
|
}, [gap]);
|
|
1962
|
-
|
|
1970
|
+
React36.useEffect(() => {
|
|
1963
1971
|
update();
|
|
1964
1972
|
const el = scrollerRef.current;
|
|
1965
1973
|
if (!el) return;
|
|
@@ -2000,9 +2008,9 @@ function RotatingCarousel({
|
|
|
2000
2008
|
className = "",
|
|
2001
2009
|
style
|
|
2002
2010
|
}) {
|
|
2003
|
-
const slides =
|
|
2011
|
+
const slides = React36__default.default.Children.toArray(children);
|
|
2004
2012
|
const count = slides.length;
|
|
2005
|
-
const [active, setActive] =
|
|
2013
|
+
const [active, setActive] = React36.useState(0);
|
|
2006
2014
|
const reduced = framerMotion.useReducedMotion();
|
|
2007
2015
|
const wrap = (n) => count > 0 ? (n % count + count) % count : 0;
|
|
2008
2016
|
const idx = wrap(active);
|
|
@@ -2240,13 +2248,13 @@ function Chat({
|
|
|
2240
2248
|
className = "",
|
|
2241
2249
|
style
|
|
2242
2250
|
}) {
|
|
2243
|
-
const listRef =
|
|
2244
|
-
const atBottomRef =
|
|
2245
|
-
const [showJump, setShowJump] =
|
|
2246
|
-
const [draft, setDraft] =
|
|
2251
|
+
const listRef = React36.useRef(null);
|
|
2252
|
+
const atBottomRef = React36.useRef(true);
|
|
2253
|
+
const [showJump, setShowJump] = React36.useState(false);
|
|
2254
|
+
const [draft, setDraft] = React36.useState("");
|
|
2247
2255
|
const hasHeader = title != null || subtitle != null || avatar != null || headerActions != null;
|
|
2248
2256
|
const isTyping = typingNames.length > 0;
|
|
2249
|
-
const scrollToBottom =
|
|
2257
|
+
const scrollToBottom = React36.useCallback((smooth = true) => {
|
|
2250
2258
|
const el = listRef.current;
|
|
2251
2259
|
if (!el) return;
|
|
2252
2260
|
if (typeof el.scrollTo === "function") el.scrollTo({ top: el.scrollHeight, behavior: smooth ? "smooth" : "auto" });
|
|
@@ -2259,10 +2267,10 @@ function Chat({
|
|
|
2259
2267
|
atBottomRef.current = near;
|
|
2260
2268
|
setShowJump(!near);
|
|
2261
2269
|
};
|
|
2262
|
-
|
|
2270
|
+
React36.useEffect(() => {
|
|
2263
2271
|
if (atBottomRef.current) scrollToBottom(messages.length > 0);
|
|
2264
2272
|
}, [messages.length, isTyping]);
|
|
2265
|
-
|
|
2273
|
+
React36.useEffect(() => {
|
|
2266
2274
|
scrollToBottom(false);
|
|
2267
2275
|
}, [scrollToBottom]);
|
|
2268
2276
|
const send = () => {
|
|
@@ -2452,7 +2460,7 @@ function FAB({
|
|
|
2452
2460
|
className = "",
|
|
2453
2461
|
style
|
|
2454
2462
|
}) {
|
|
2455
|
-
const [open, setOpen] =
|
|
2463
|
+
const [open, setOpen] = React36.useState(false);
|
|
2456
2464
|
const reduced = framerMotion.useReducedMotion();
|
|
2457
2465
|
const hasDial = !!actions && actions.length > 0;
|
|
2458
2466
|
const bottom = position.startsWith("bottom");
|
|
@@ -2554,8 +2562,8 @@ function PopConfirm({
|
|
|
2554
2562
|
onOpenChange,
|
|
2555
2563
|
className = ""
|
|
2556
2564
|
}) {
|
|
2557
|
-
const [uncontrolledOpen, setUncontrolledOpen] =
|
|
2558
|
-
const [loading, setLoading] =
|
|
2565
|
+
const [uncontrolledOpen, setUncontrolledOpen] = React36.useState(false);
|
|
2566
|
+
const [loading, setLoading] = React36.useState(false);
|
|
2559
2567
|
const isOpen = open ?? uncontrolledOpen;
|
|
2560
2568
|
const setOpen = (next) => {
|
|
2561
2569
|
onOpenChange?.(next);
|
|
@@ -2658,16 +2666,16 @@ function LogoutTimer({
|
|
|
2658
2666
|
logoutLabel = "Sign out now"
|
|
2659
2667
|
}) {
|
|
2660
2668
|
const reduced = framerMotion.useReducedMotion();
|
|
2661
|
-
const [warning, setWarning] =
|
|
2662
|
-
const [remaining, setRemaining] =
|
|
2663
|
-
const idleTimer =
|
|
2664
|
-
const tick =
|
|
2665
|
-
const deadline =
|
|
2666
|
-
const warningRef =
|
|
2667
|
-
const lastReset =
|
|
2668
|
-
const cbs =
|
|
2669
|
+
const [warning, setWarning] = React36.useState(false);
|
|
2670
|
+
const [remaining, setRemaining] = React36.useState(countdown);
|
|
2671
|
+
const idleTimer = React36.useRef(null);
|
|
2672
|
+
const tick = React36.useRef(null);
|
|
2673
|
+
const deadline = React36.useRef(0);
|
|
2674
|
+
const warningRef = React36.useRef(false);
|
|
2675
|
+
const lastReset = React36.useRef(0);
|
|
2676
|
+
const cbs = React36.useRef({ onLogout, onContinue, onWarning });
|
|
2669
2677
|
cbs.current = { onLogout, onContinue, onWarning };
|
|
2670
|
-
const clearTimers =
|
|
2678
|
+
const clearTimers = React36.useCallback(() => {
|
|
2671
2679
|
if (idleTimer.current) {
|
|
2672
2680
|
clearTimeout(idleTimer.current);
|
|
2673
2681
|
idleTimer.current = null;
|
|
@@ -2677,13 +2685,13 @@ function LogoutTimer({
|
|
|
2677
2685
|
tick.current = null;
|
|
2678
2686
|
}
|
|
2679
2687
|
}, []);
|
|
2680
|
-
const logout =
|
|
2688
|
+
const logout = React36.useCallback(() => {
|
|
2681
2689
|
clearTimers();
|
|
2682
2690
|
warningRef.current = false;
|
|
2683
2691
|
setWarning(false);
|
|
2684
2692
|
cbs.current.onLogout();
|
|
2685
2693
|
}, [clearTimers]);
|
|
2686
|
-
const startIdle =
|
|
2694
|
+
const startIdle = React36.useCallback(() => {
|
|
2687
2695
|
if (idleTimer.current) clearTimeout(idleTimer.current);
|
|
2688
2696
|
idleTimer.current = setTimeout(() => {
|
|
2689
2697
|
warningRef.current = true;
|
|
@@ -2698,7 +2706,7 @@ function LogoutTimer({
|
|
|
2698
2706
|
}, 250);
|
|
2699
2707
|
}, timeout);
|
|
2700
2708
|
}, [timeout, countdown, logout]);
|
|
2701
|
-
const stay =
|
|
2709
|
+
const stay = React36.useCallback(() => {
|
|
2702
2710
|
if (tick.current) {
|
|
2703
2711
|
clearInterval(tick.current);
|
|
2704
2712
|
tick.current = null;
|
|
@@ -2708,7 +2716,7 @@ function LogoutTimer({
|
|
|
2708
2716
|
cbs.current.onContinue?.();
|
|
2709
2717
|
startIdle();
|
|
2710
2718
|
}, [startIdle]);
|
|
2711
|
-
|
|
2719
|
+
React36.useEffect(() => {
|
|
2712
2720
|
if (!enabled) {
|
|
2713
2721
|
clearTimers();
|
|
2714
2722
|
warningRef.current = false;
|
|
@@ -2773,11 +2781,11 @@ function SegmentedControl({
|
|
|
2773
2781
|
"aria-label": ariaLabel
|
|
2774
2782
|
}) {
|
|
2775
2783
|
const sz = SIZE5[size];
|
|
2776
|
-
const groupId =
|
|
2777
|
-
const errorId =
|
|
2784
|
+
const groupId = React36.useId();
|
|
2785
|
+
const errorId = React36.useId();
|
|
2778
2786
|
const hasError = errorMessage != null;
|
|
2779
2787
|
const isControlled = value !== void 0;
|
|
2780
|
-
const [internal, setInternal] =
|
|
2788
|
+
const [internal, setInternal] = React36.useState(defaultValue);
|
|
2781
2789
|
const current = isControlled ? value : internal;
|
|
2782
2790
|
const handle = (v) => {
|
|
2783
2791
|
if (!v) return;
|
|
@@ -2938,22 +2946,22 @@ function Scheduler({
|
|
|
2938
2946
|
style
|
|
2939
2947
|
}) {
|
|
2940
2948
|
const reduced = framerMotion.useReducedMotion();
|
|
2941
|
-
const [view, setView] =
|
|
2942
|
-
const [cursor, setCursor] =
|
|
2943
|
-
const [loaded, setLoaded] =
|
|
2944
|
-
const [loading, setLoading] =
|
|
2945
|
-
const [error, setError] =
|
|
2946
|
-
const [reloadKey, setReloadKey] =
|
|
2947
|
-
const [dir, setDir] =
|
|
2948
|
-
const cbRef =
|
|
2949
|
+
const [view, setView] = React36.useState(defaultView);
|
|
2950
|
+
const [cursor, setCursor] = React36.useState(() => defaultDate ?? /* @__PURE__ */ new Date());
|
|
2951
|
+
const [loaded, setLoaded] = React36.useState([]);
|
|
2952
|
+
const [loading, setLoading] = React36.useState(false);
|
|
2953
|
+
const [error, setError] = React36.useState(null);
|
|
2954
|
+
const [reloadKey, setReloadKey] = React36.useState(0);
|
|
2955
|
+
const [dir, setDir] = React36.useState(0);
|
|
2956
|
+
const cbRef = React36.useRef({ loadEvents, onError });
|
|
2949
2957
|
cbRef.current = { loadEvents, onError };
|
|
2950
|
-
const range =
|
|
2958
|
+
const range = React36.useMemo(
|
|
2951
2959
|
() => view === "month" ? monthRange(cursor) : weekRange(cursor, weekStartsOn),
|
|
2952
2960
|
[view, cursor, weekStartsOn]
|
|
2953
2961
|
);
|
|
2954
2962
|
const fromKey = range.from.getTime();
|
|
2955
2963
|
const toKey = range.to.getTime();
|
|
2956
|
-
|
|
2964
|
+
React36.useEffect(() => {
|
|
2957
2965
|
const { loadEvents: loader, onError: onErr } = cbRef.current;
|
|
2958
2966
|
if (!loader) return;
|
|
2959
2967
|
let cancelled = false;
|
|
@@ -2973,16 +2981,16 @@ function Scheduler({
|
|
|
2973
2981
|
cancelled = true;
|
|
2974
2982
|
};
|
|
2975
2983
|
}, [fromKey, toKey, view, reloadKey]);
|
|
2976
|
-
const retry =
|
|
2977
|
-
const events =
|
|
2984
|
+
const retry = React36.useCallback(() => setReloadKey((k) => k + 1), []);
|
|
2985
|
+
const events = React36.useMemo(
|
|
2978
2986
|
() => (controlledEvents ?? loaded).map(normalize),
|
|
2979
2987
|
[controlledEvents, loaded]
|
|
2980
2988
|
);
|
|
2981
|
-
const go =
|
|
2989
|
+
const go = React36.useCallback((delta) => {
|
|
2982
2990
|
setDir(delta);
|
|
2983
2991
|
setCursor((c) => view === "month" ? addMonths(c, delta) : addDays(c, delta * 7));
|
|
2984
2992
|
}, [view]);
|
|
2985
|
-
const goToday =
|
|
2993
|
+
const goToday = React36.useCallback(() => {
|
|
2986
2994
|
setDir(0);
|
|
2987
2995
|
setCursor(/* @__PURE__ */ new Date());
|
|
2988
2996
|
}, []);
|
|
@@ -3092,9 +3100,9 @@ function SchedulerError({ onRetry }) {
|
|
|
3092
3100
|
] });
|
|
3093
3101
|
}
|
|
3094
3102
|
function MonthYearPicker({ label, cursor, onPick }) {
|
|
3095
|
-
const [open, setOpen] =
|
|
3096
|
-
const [viewYear, setViewYear] =
|
|
3097
|
-
|
|
3103
|
+
const [open, setOpen] = React36.useState(false);
|
|
3104
|
+
const [viewYear, setViewYear] = React36.useState(cursor.getFullYear());
|
|
3105
|
+
React36.useEffect(() => {
|
|
3098
3106
|
if (open) setViewYear(cursor.getFullYear());
|
|
3099
3107
|
}, [open, cursor]);
|
|
3100
3108
|
return /* @__PURE__ */ jsxRuntime.jsxs(Popover__namespace.Root, { open, onOpenChange: setOpen, children: [
|
|
@@ -3168,8 +3176,8 @@ function MonthView({
|
|
|
3168
3176
|
onSelectSlot,
|
|
3169
3177
|
onSelectEvent
|
|
3170
3178
|
}) {
|
|
3171
|
-
const grid =
|
|
3172
|
-
const eventsByDay =
|
|
3179
|
+
const grid = React36.useMemo(() => buildMonthGrid(cursor, weekStartsOn), [cursor, weekStartsOn]);
|
|
3180
|
+
const eventsByDay = React36.useMemo(() => bucketByDay(events), [events]);
|
|
3173
3181
|
const labels = weekdayLabels(weekStartsOn);
|
|
3174
3182
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col", children: [
|
|
3175
3183
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-7 border-b border-border", children: labels.map((l) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-2 py-1.5 text-center text-[11px] font-medium uppercase tracking-wide text-foreground-muted", children: l }, l)) }),
|
|
@@ -3243,12 +3251,12 @@ function WeekView({
|
|
|
3243
3251
|
onSelectSlot,
|
|
3244
3252
|
onSelectEvent
|
|
3245
3253
|
}) {
|
|
3246
|
-
const days =
|
|
3247
|
-
const eventsByDay =
|
|
3248
|
-
const labels =
|
|
3254
|
+
const days = React36.useMemo(() => getWeekDays(cursor, weekStartsOn), [cursor, weekStartsOn]);
|
|
3255
|
+
const eventsByDay = React36.useMemo(() => bucketByDay(events), [events]);
|
|
3256
|
+
const labels = React36.useMemo(() => weekdayLabels(weekStartsOn), [weekStartsOn]);
|
|
3249
3257
|
const dow = (d) => labels[(d.getDay() - weekStartsOn + 7) % 7];
|
|
3250
3258
|
const [startHour, endHour] = dayHours;
|
|
3251
|
-
const hours =
|
|
3259
|
+
const hours = React36.useMemo(
|
|
3252
3260
|
() => Array.from({ length: endHour - startHour }, (_, i) => startHour + i),
|
|
3253
3261
|
[startHour, endHour]
|
|
3254
3262
|
);
|
|
@@ -3439,17 +3447,17 @@ function Cart({
|
|
|
3439
3447
|
] })
|
|
3440
3448
|
] });
|
|
3441
3449
|
}
|
|
3442
|
-
var CartContext =
|
|
3450
|
+
var CartContext = React36.createContext(null);
|
|
3443
3451
|
var clampQty = (qty, max) => {
|
|
3444
3452
|
const lower = Math.max(1, Math.round(qty));
|
|
3445
3453
|
return max != null ? Math.min(lower, max) : lower;
|
|
3446
3454
|
};
|
|
3447
3455
|
function CartProvider({ children, initialItems = [], onChange }) {
|
|
3448
|
-
const [items, setItems] =
|
|
3449
|
-
|
|
3456
|
+
const [items, setItems] = React36.useState(initialItems);
|
|
3457
|
+
React36.useEffect(() => {
|
|
3450
3458
|
onChange?.(items);
|
|
3451
3459
|
}, [items]);
|
|
3452
|
-
const addToCart =
|
|
3460
|
+
const addToCart = React36.useCallback((item, quantity) => {
|
|
3453
3461
|
const addQty = quantity ?? item.quantity ?? 1;
|
|
3454
3462
|
setItems((prev) => {
|
|
3455
3463
|
const existing = prev.find((it) => it.id === item.id);
|
|
@@ -3462,29 +3470,29 @@ function CartProvider({ children, initialItems = [], onChange }) {
|
|
|
3462
3470
|
return [...prev, { ...rest, quantity: clampQty(addQty, item.max) }];
|
|
3463
3471
|
});
|
|
3464
3472
|
}, []);
|
|
3465
|
-
const removeFromCart =
|
|
3473
|
+
const removeFromCart = React36.useCallback((id) => {
|
|
3466
3474
|
setItems((prev) => prev.filter((it) => it.id !== id));
|
|
3467
3475
|
}, []);
|
|
3468
|
-
const updateQuantity =
|
|
3476
|
+
const updateQuantity = React36.useCallback((id, quantity) => {
|
|
3469
3477
|
setItems(
|
|
3470
3478
|
(prev) => prev.map((it) => it.id === id ? { ...it, quantity: clampQty(quantity, it.max) } : it)
|
|
3471
3479
|
);
|
|
3472
3480
|
}, []);
|
|
3473
|
-
const clearCart =
|
|
3474
|
-
const isInCart =
|
|
3475
|
-
const getItemCount =
|
|
3476
|
-
const getCartTotal =
|
|
3481
|
+
const clearCart = React36.useCallback(() => setItems([]), []);
|
|
3482
|
+
const isInCart = React36.useCallback((id) => items.some((it) => it.id === id), [items]);
|
|
3483
|
+
const getItemCount = React36.useCallback(() => items.reduce((sum, it) => sum + it.quantity, 0), [items]);
|
|
3484
|
+
const getCartTotal = React36.useCallback(
|
|
3477
3485
|
() => items.reduce((sum, it) => sum + it.price * it.quantity, 0),
|
|
3478
3486
|
[items]
|
|
3479
3487
|
);
|
|
3480
|
-
const value =
|
|
3488
|
+
const value = React36.useMemo(
|
|
3481
3489
|
() => ({ items, addToCart, removeFromCart, updateQuantity, clearCart, isInCart, getItemCount, getCartTotal }),
|
|
3482
3490
|
[items, addToCart, removeFromCart, updateQuantity, clearCart, isInCart, getItemCount, getCartTotal]
|
|
3483
3491
|
);
|
|
3484
3492
|
return /* @__PURE__ */ jsxRuntime.jsx(CartContext.Provider, { value, children });
|
|
3485
3493
|
}
|
|
3486
3494
|
function useCart() {
|
|
3487
|
-
const ctx =
|
|
3495
|
+
const ctx = React36.useContext(CartContext);
|
|
3488
3496
|
if (!ctx) {
|
|
3489
3497
|
throw new Error("useCart must be used within a <CartProvider>.");
|
|
3490
3498
|
}
|
|
@@ -3826,11 +3834,11 @@ function buildBindings(store, name, kind, snap) {
|
|
|
3826
3834
|
|
|
3827
3835
|
// src/form/useForm.ts
|
|
3828
3836
|
function useForm(options = {}) {
|
|
3829
|
-
const ref =
|
|
3837
|
+
const ref = React36.useRef(null);
|
|
3830
3838
|
if (ref.current === null) ref.current = new FormStore(options);
|
|
3831
3839
|
const store = ref.current;
|
|
3832
|
-
|
|
3833
|
-
const make =
|
|
3840
|
+
React36.useSyncExternalStore(store.subscribe, store.getRootSnapshot, store.getRootSnapshot);
|
|
3841
|
+
const make = React36.useCallback(
|
|
3834
3842
|
(kind) => (name, rules) => {
|
|
3835
3843
|
if (rules !== void 0) store.setRule(name, rules);
|
|
3836
3844
|
return buildBindings(store, name, kind, store.getFieldSnapshot(name));
|
|
@@ -3860,9 +3868,9 @@ function useForm(options = {}) {
|
|
|
3860
3868
|
fieldTarget: make("target")
|
|
3861
3869
|
};
|
|
3862
3870
|
}
|
|
3863
|
-
var FormContext =
|
|
3871
|
+
var FormContext = React36.createContext(null);
|
|
3864
3872
|
function useFormStore() {
|
|
3865
|
-
const store =
|
|
3873
|
+
const store = React36.useContext(FormContext);
|
|
3866
3874
|
if (!store) {
|
|
3867
3875
|
throw new Error("useFormStore must be used within a <Form>. Did you forget to wrap your fields?");
|
|
3868
3876
|
}
|
|
@@ -3876,8 +3884,8 @@ function Form({
|
|
|
3876
3884
|
children,
|
|
3877
3885
|
...rest
|
|
3878
3886
|
}) {
|
|
3879
|
-
const ref =
|
|
3880
|
-
const bypass =
|
|
3887
|
+
const ref = React36.useRef(null);
|
|
3888
|
+
const bypass = React36.useRef(false);
|
|
3881
3889
|
const handleSubmit = async (e) => {
|
|
3882
3890
|
if (bypass.current) {
|
|
3883
3891
|
bypass.current = false;
|
|
@@ -3934,12 +3942,12 @@ function useFormField(name, options = {}) {
|
|
|
3934
3942
|
const store = useFormStore();
|
|
3935
3943
|
const { kind = "value", rules } = options;
|
|
3936
3944
|
if (rules !== void 0 && store.getRule(name) !== rules) store.setRule(name, rules);
|
|
3937
|
-
|
|
3945
|
+
React36.useEffect(() => {
|
|
3938
3946
|
return () => {
|
|
3939
3947
|
if (rules !== void 0) store.removeRule(name);
|
|
3940
3948
|
};
|
|
3941
3949
|
}, [store, name]);
|
|
3942
|
-
const snap =
|
|
3950
|
+
const snap = React36.useSyncExternalStore(
|
|
3943
3951
|
store.subscribe,
|
|
3944
3952
|
() => store.getFieldSnapshot(name)
|
|
3945
3953
|
);
|
|
@@ -3951,7 +3959,7 @@ function FormField({ name, kind, rules, children }) {
|
|
|
3951
3959
|
}
|
|
3952
3960
|
function useFieldArray(name) {
|
|
3953
3961
|
const store = useFormStore();
|
|
3954
|
-
|
|
3962
|
+
React36.useSyncExternalStore(store.subscribe, store.getRootSnapshot, store.getRootSnapshot);
|
|
3955
3963
|
const arr = store.getValue(name) ?? [];
|
|
3956
3964
|
const keys = store.getKeys(name);
|
|
3957
3965
|
return {
|
|
@@ -3984,7 +3992,7 @@ function TextInput({
|
|
|
3984
3992
|
suffix,
|
|
3985
3993
|
id
|
|
3986
3994
|
}) {
|
|
3987
|
-
const errorId =
|
|
3995
|
+
const errorId = React36.useId();
|
|
3988
3996
|
const hasError = errorMessage != null;
|
|
3989
3997
|
const hasAdornment = prefix != null || suffix != null;
|
|
3990
3998
|
const inputId = htmlFor ?? id;
|
|
@@ -4145,7 +4153,7 @@ function CreditCardForm({
|
|
|
4145
4153
|
className = "",
|
|
4146
4154
|
style
|
|
4147
4155
|
}) {
|
|
4148
|
-
const initial =
|
|
4156
|
+
const initial = React36.useRef({
|
|
4149
4157
|
number: formatCardNumber(defaultValue?.number ?? ""),
|
|
4150
4158
|
name: defaultValue?.name ?? "",
|
|
4151
4159
|
expiry: formatExpiry(defaultValue?.expiry ?? ""),
|
|
@@ -4154,7 +4162,7 @@ function CreditCardForm({
|
|
|
4154
4162
|
const form = useForm({ initialValues: initial });
|
|
4155
4163
|
const numberStr = String(form.values.number ?? "");
|
|
4156
4164
|
const brand = detectBrand(numberStr);
|
|
4157
|
-
|
|
4165
|
+
React36.useEffect(() => {
|
|
4158
4166
|
onChange?.(toCard(form.values));
|
|
4159
4167
|
}, [form.values.number, form.values.name, form.values.expiry, form.values.cvv]);
|
|
4160
4168
|
const numberBind = form.fieldNative("number", {
|
|
@@ -4277,7 +4285,7 @@ function Checkout({
|
|
|
4277
4285
|
] })
|
|
4278
4286
|
] });
|
|
4279
4287
|
}
|
|
4280
|
-
var NotificationContext =
|
|
4288
|
+
var NotificationContext = React36.createContext({
|
|
4281
4289
|
open: () => void 0,
|
|
4282
4290
|
close: () => void 0
|
|
4283
4291
|
});
|
|
@@ -4335,26 +4343,26 @@ function NotificationItem({
|
|
|
4335
4343
|
onClose,
|
|
4336
4344
|
reduced
|
|
4337
4345
|
}) {
|
|
4338
|
-
const [paused, setPaused] =
|
|
4346
|
+
const [paused, setPaused] = React36.useState(false);
|
|
4339
4347
|
const duration = n.duration ?? 4e3;
|
|
4340
4348
|
const isAutoDismissing = isFinite(duration) && duration > 0;
|
|
4341
4349
|
const showProgress = !reduced && isAutoDismissing;
|
|
4342
|
-
const timerRef =
|
|
4343
|
-
const startTimeRef =
|
|
4344
|
-
const remainingRef =
|
|
4345
|
-
const clearTimer =
|
|
4350
|
+
const timerRef = React36.useRef(null);
|
|
4351
|
+
const startTimeRef = React36.useRef(0);
|
|
4352
|
+
const remainingRef = React36.useRef(duration);
|
|
4353
|
+
const clearTimer = React36.useCallback(() => {
|
|
4346
4354
|
if (timerRef.current !== null) {
|
|
4347
4355
|
clearTimeout(timerRef.current);
|
|
4348
4356
|
timerRef.current = null;
|
|
4349
4357
|
}
|
|
4350
4358
|
}, []);
|
|
4351
|
-
const scheduleDismiss =
|
|
4359
|
+
const scheduleDismiss = React36.useCallback((ms) => {
|
|
4352
4360
|
clearTimer();
|
|
4353
4361
|
if (!isAutoDismissing) return;
|
|
4354
4362
|
startTimeRef.current = Date.now();
|
|
4355
4363
|
timerRef.current = setTimeout(() => onClose(n.id), ms);
|
|
4356
4364
|
}, [clearTimer, isAutoDismissing, n.id, onClose]);
|
|
4357
|
-
|
|
4365
|
+
React36.useEffect(() => {
|
|
4358
4366
|
if (paused || !isAutoDismissing) return;
|
|
4359
4367
|
scheduleDismiss(remainingRef.current);
|
|
4360
4368
|
return clearTimer;
|
|
@@ -4437,15 +4445,15 @@ function NotificationProvider({
|
|
|
4437
4445
|
children,
|
|
4438
4446
|
position = "top-right"
|
|
4439
4447
|
}) {
|
|
4440
|
-
const [notifications, setNotifications] =
|
|
4448
|
+
const [notifications, setNotifications] = React36.useState([]);
|
|
4441
4449
|
const reduced = framerMotion.useReducedMotion();
|
|
4442
|
-
const open =
|
|
4450
|
+
const open = React36.useCallback((payload) => {
|
|
4443
4451
|
setNotifications((prev) => [
|
|
4444
4452
|
...prev,
|
|
4445
4453
|
{ duration: 4e3, ...payload, id: Date.now() + Math.random() }
|
|
4446
4454
|
]);
|
|
4447
4455
|
}, []);
|
|
4448
|
-
const close =
|
|
4456
|
+
const close = React36.useCallback((id) => {
|
|
4449
4457
|
setNotifications((prev) => prev.filter((n) => n.id !== id));
|
|
4450
4458
|
}, []);
|
|
4451
4459
|
return /* @__PURE__ */ jsxRuntime.jsxs(NotificationContext.Provider, { value: { open, close }, children: [
|
|
@@ -4474,7 +4482,7 @@ function NotificationProvider({
|
|
|
4474
4482
|
] });
|
|
4475
4483
|
}
|
|
4476
4484
|
function useNotification() {
|
|
4477
|
-
const { open } =
|
|
4485
|
+
const { open } = React36.useContext(NotificationContext);
|
|
4478
4486
|
return {
|
|
4479
4487
|
info: (props) => open({ type: "info", ...props }),
|
|
4480
4488
|
success: (props) => open({ type: "success", ...props }),
|
|
@@ -4591,10 +4599,10 @@ function FadingBase({
|
|
|
4591
4599
|
isMounted = false,
|
|
4592
4600
|
children
|
|
4593
4601
|
}) {
|
|
4594
|
-
const [shouldRender, setShouldRender] =
|
|
4595
|
-
const [visible, setVisible] =
|
|
4596
|
-
const timerRef =
|
|
4597
|
-
|
|
4602
|
+
const [shouldRender, setShouldRender] = React36.useState(isMounted);
|
|
4603
|
+
const [visible, setVisible] = React36.useState(false);
|
|
4604
|
+
const timerRef = React36.useRef(null);
|
|
4605
|
+
React36.useEffect(() => {
|
|
4598
4606
|
if (isMounted) {
|
|
4599
4607
|
setShouldRender(true);
|
|
4600
4608
|
const rafId = requestAnimationFrame(() => setVisible(true));
|
|
@@ -4706,14 +4714,14 @@ function ScalableContainer({
|
|
|
4706
4714
|
togglePosition = "top-right",
|
|
4707
4715
|
className = ""
|
|
4708
4716
|
}) {
|
|
4709
|
-
const containerRef =
|
|
4710
|
-
const [internalScaled, setInternalScaled] =
|
|
4717
|
+
const containerRef = React36.useRef(null);
|
|
4718
|
+
const [internalScaled, setInternalScaled] = React36.useState(false);
|
|
4711
4719
|
const isScaled = expanded ?? internalScaled;
|
|
4712
4720
|
const reduced = framerMotion.useReducedMotion();
|
|
4713
|
-
const prevScaled =
|
|
4721
|
+
const prevScaled = React36.useRef(isScaled);
|
|
4714
4722
|
const expandW = targetWidth ?? expandedWidth;
|
|
4715
4723
|
const expandH = targetHeight ?? expandedHeight;
|
|
4716
|
-
|
|
4724
|
+
React36.useEffect(() => {
|
|
4717
4725
|
if (isScaled === prevScaled.current) return;
|
|
4718
4726
|
prevScaled.current = isScaled;
|
|
4719
4727
|
if (typeof window === "undefined") return;
|
|
@@ -4860,17 +4868,17 @@ function CatalogGrid({ items, buttonText, onOpen, className = "" }) {
|
|
|
4860
4868
|
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)) });
|
|
4861
4869
|
}
|
|
4862
4870
|
function CatalogCarousel({ items, buttonText, onOpen, className = "" }) {
|
|
4863
|
-
const [activeIndex, setActiveIndex] =
|
|
4864
|
-
const [indexPool, setIndexPool] =
|
|
4865
|
-
const cardRefs =
|
|
4866
|
-
const getIndexes =
|
|
4871
|
+
const [activeIndex, setActiveIndex] = React36.useState(0);
|
|
4872
|
+
const [indexPool, setIndexPool] = React36.useState([]);
|
|
4873
|
+
const cardRefs = React36.useRef([]);
|
|
4874
|
+
const getIndexes = React36.useMemo(() => {
|
|
4867
4875
|
let nextIndex = activeIndex + 1;
|
|
4868
4876
|
let previousIndex = activeIndex - 1;
|
|
4869
4877
|
if (activeIndex === 0) previousIndex = items.length - 1;
|
|
4870
4878
|
if (activeIndex === items.length - 1) nextIndex = 0;
|
|
4871
4879
|
return { previousIndex, nextIndex };
|
|
4872
4880
|
}, [activeIndex, items.length]);
|
|
4873
|
-
|
|
4881
|
+
React36.useEffect(() => {
|
|
4874
4882
|
const { nextIndex, previousIndex } = getIndexes;
|
|
4875
4883
|
let indexes = [previousIndex, activeIndex, nextIndex];
|
|
4876
4884
|
if (activeIndex !== 0 && activeIndex !== items.length - 1) {
|
|
@@ -5043,8 +5051,8 @@ function writeDismissed(key) {
|
|
|
5043
5051
|
}
|
|
5044
5052
|
}
|
|
5045
5053
|
function useTargetBbox(ref) {
|
|
5046
|
-
const [bbox, setBbox] =
|
|
5047
|
-
|
|
5054
|
+
const [bbox, setBbox] = React36.useState(null);
|
|
5055
|
+
React36.useLayoutEffect(() => {
|
|
5048
5056
|
const el = ref?.current;
|
|
5049
5057
|
if (!el) {
|
|
5050
5058
|
setBbox(null);
|
|
@@ -5074,7 +5082,7 @@ function tooltipStyleFor(bbox, placement) {
|
|
|
5074
5082
|
return { left: bbox.left + bbox.width / 2, top: bbox.top - TOOLTIP_GAP, transform: "translate(-50%, -100%)", width: TOOLTIP_WIDTH };
|
|
5075
5083
|
}
|
|
5076
5084
|
function useFocusTrap(containerRef, active) {
|
|
5077
|
-
|
|
5085
|
+
React36.useEffect(() => {
|
|
5078
5086
|
if (!active) return;
|
|
5079
5087
|
const el = containerRef.current;
|
|
5080
5088
|
if (!el) return;
|
|
@@ -5113,16 +5121,16 @@ function Wizard({
|
|
|
5113
5121
|
onComplete,
|
|
5114
5122
|
onSkip
|
|
5115
5123
|
}) {
|
|
5116
|
-
const tooltipRef =
|
|
5117
|
-
const tooltipTitleId =
|
|
5118
|
-
const tooltipBodyId =
|
|
5124
|
+
const tooltipRef = React36.useRef(null);
|
|
5125
|
+
const tooltipTitleId = React36.useId();
|
|
5126
|
+
const tooltipBodyId = React36.useId();
|
|
5119
5127
|
const reduced = framerMotion.useReducedMotion();
|
|
5120
|
-
const [open, setOpen] =
|
|
5121
|
-
const [activeIndex, setActiveIndex] =
|
|
5128
|
+
const [open, setOpen] = React36.useState(() => steps.length > 0 && !readDismissed(storageKey));
|
|
5129
|
+
const [activeIndex, setActiveIndex] = React36.useState(0);
|
|
5122
5130
|
const step = steps[activeIndex];
|
|
5123
5131
|
const bbox = useTargetBbox(step?.stepRef);
|
|
5124
5132
|
useFocusTrap(tooltipRef, open);
|
|
5125
|
-
|
|
5133
|
+
React36.useEffect(() => {
|
|
5126
5134
|
if (!open || !dismissible) return;
|
|
5127
5135
|
const onKey = (e) => {
|
|
5128
5136
|
if (e.key === "Escape") {
|
|
@@ -5133,12 +5141,12 @@ function Wizard({
|
|
|
5133
5141
|
document.addEventListener("keydown", onKey);
|
|
5134
5142
|
return () => document.removeEventListener("keydown", onKey);
|
|
5135
5143
|
}, [open, dismissible]);
|
|
5136
|
-
const handleSkip =
|
|
5144
|
+
const handleSkip = React36.useCallback(() => {
|
|
5137
5145
|
writeDismissed(storageKey);
|
|
5138
5146
|
setOpen(false);
|
|
5139
5147
|
onSkip?.();
|
|
5140
5148
|
}, [storageKey, onSkip]);
|
|
5141
|
-
const handleComplete =
|
|
5149
|
+
const handleComplete = React36.useCallback(() => {
|
|
5142
5150
|
writeDismissed(storageKey);
|
|
5143
5151
|
setOpen(false);
|
|
5144
5152
|
onComplete?.();
|
|
@@ -5281,7 +5289,7 @@ function Wizard({
|
|
|
5281
5289
|
] });
|
|
5282
5290
|
}
|
|
5283
5291
|
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" }) });
|
|
5284
|
-
var SearchInput =
|
|
5292
|
+
var SearchInput = React36__default.default.forwardRef(function SearchInput2({ value, onChange, disabled, label, htmlFor, placeholder, name, inputStyle, style, layout = "vertical", size = "md", icon, helperText, className }, ref) {
|
|
5285
5293
|
return /* @__PURE__ */ jsxRuntime.jsx(Field, { className, label, htmlFor, layout, helperText, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5286
5294
|
"div",
|
|
5287
5295
|
{
|
|
@@ -5516,15 +5524,15 @@ function EditableCell({
|
|
|
5516
5524
|
rowIndex,
|
|
5517
5525
|
onCellEdit
|
|
5518
5526
|
}) {
|
|
5519
|
-
const [editing, setEditing] =
|
|
5520
|
-
const editRef =
|
|
5527
|
+
const [editing, setEditing] = React36.useState(false);
|
|
5528
|
+
const editRef = React36.useRef(null);
|
|
5521
5529
|
const value = row[col.keyBind];
|
|
5522
5530
|
const commit = (next) => {
|
|
5523
5531
|
setEditing(false);
|
|
5524
5532
|
onCellEdit?.({ row, key: col.keyBind, value: next, rowIndex });
|
|
5525
5533
|
};
|
|
5526
5534
|
const cancel = () => setEditing(false);
|
|
5527
|
-
|
|
5535
|
+
React36.useEffect(() => {
|
|
5528
5536
|
if (!editing || !col.editor) return;
|
|
5529
5537
|
const onMouseDown = (e) => {
|
|
5530
5538
|
const target = e.target;
|
|
@@ -5583,7 +5591,7 @@ function TableBody({
|
|
|
5583
5591
|
getRowKey,
|
|
5584
5592
|
onCellEdit
|
|
5585
5593
|
}) {
|
|
5586
|
-
const [expanded, setExpanded] =
|
|
5594
|
+
const [expanded, setExpanded] = React36.useState(() => /* @__PURE__ */ new Set());
|
|
5587
5595
|
const reduced = framerMotion.useReducedMotion();
|
|
5588
5596
|
const toggleRow = (rowKey) => {
|
|
5589
5597
|
setExpanded((prev) => {
|
|
@@ -5598,7 +5606,7 @@ function TableBody({
|
|
|
5598
5606
|
return /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: rows.map((row, i) => {
|
|
5599
5607
|
const rowKey = getRowKey(row, i);
|
|
5600
5608
|
const isExpanded = expanded.has(rowKey);
|
|
5601
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5609
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(React36__default.default.Fragment, { children: [
|
|
5602
5610
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
5603
5611
|
"tr",
|
|
5604
5612
|
{
|
|
@@ -5710,13 +5718,13 @@ function Table({
|
|
|
5710
5718
|
className = "",
|
|
5711
5719
|
style
|
|
5712
5720
|
}) {
|
|
5713
|
-
const searchRef =
|
|
5714
|
-
const [searchTerm, setSearchTerm] =
|
|
5715
|
-
const [perPage, setPerPage] =
|
|
5721
|
+
const searchRef = React36.useRef(null);
|
|
5722
|
+
const [searchTerm, setSearchTerm] = React36.useState("");
|
|
5723
|
+
const [perPage, setPerPage] = React36.useState(
|
|
5716
5724
|
typeof pagination.perPage === "number" ? pagination.perPage : 15
|
|
5717
5725
|
);
|
|
5718
|
-
const [activePage, setActivePage] =
|
|
5719
|
-
const [sortState, setSortState] =
|
|
5726
|
+
const [activePage, setActivePage] = React36.useState(0);
|
|
5727
|
+
const [sortState, setSortState] = React36.useState(defaultSort);
|
|
5720
5728
|
const isServerSide = !!(pagination.enabled && pagination.serverSide);
|
|
5721
5729
|
const handleSort = (col) => {
|
|
5722
5730
|
const key = col.keyBind;
|
|
@@ -5728,8 +5736,8 @@ function Table({
|
|
|
5728
5736
|
onSortChange?.(next);
|
|
5729
5737
|
};
|
|
5730
5738
|
const debounceMs = search?.debounceMs ?? 0;
|
|
5731
|
-
const [debouncedTerm, setDebouncedTerm] =
|
|
5732
|
-
|
|
5739
|
+
const [debouncedTerm, setDebouncedTerm] = React36.useState("");
|
|
5740
|
+
React36.useEffect(() => {
|
|
5733
5741
|
if (debounceMs <= 0) {
|
|
5734
5742
|
setDebouncedTerm(searchTerm);
|
|
5735
5743
|
return;
|
|
@@ -5738,7 +5746,7 @@ function Table({
|
|
|
5738
5746
|
return () => clearTimeout(t);
|
|
5739
5747
|
}, [searchTerm, debounceMs]);
|
|
5740
5748
|
const term = debounceMs > 0 ? debouncedTerm : searchTerm;
|
|
5741
|
-
const filteredRows =
|
|
5749
|
+
const filteredRows = React36.useMemo(() => {
|
|
5742
5750
|
if (isServerSide || !term) return rows;
|
|
5743
5751
|
if (search?.predicate) return rows.filter((row) => search.predicate(row, term));
|
|
5744
5752
|
const cs = !!search?.caseSensitive;
|
|
@@ -5752,7 +5760,7 @@ function Table({
|
|
|
5752
5760
|
};
|
|
5753
5761
|
return rows.filter((row) => keys ? keys.some((k) => test(row[k])) : Object.values(row).some(test));
|
|
5754
5762
|
}, [rows, term, isServerSide, search?.predicate, search?.caseSensitive, search?.matchMode, search?.keys]);
|
|
5755
|
-
const sortedRows =
|
|
5763
|
+
const sortedRows = React36.useMemo(() => {
|
|
5756
5764
|
if (isServerSide || !sortState) return filteredRows;
|
|
5757
5765
|
const col = columns.find((c) => c.keyBind === sortState.key);
|
|
5758
5766
|
const accessor = col?.sortAccessor ?? ((r) => r[sortState.key]);
|
|
@@ -5760,29 +5768,29 @@ function Table({
|
|
|
5760
5768
|
if (sortState.direction === "desc") out.reverse();
|
|
5761
5769
|
return out;
|
|
5762
5770
|
}, [filteredRows, sortState, isServerSide, columns]);
|
|
5763
|
-
const datasets =
|
|
5771
|
+
const datasets = React36.useMemo(() => {
|
|
5764
5772
|
if (isServerSide) return [rows];
|
|
5765
5773
|
return createDatasets(sortedRows, pagination.enabled ? perPage : null);
|
|
5766
5774
|
}, [sortedRows, perPage, pagination.enabled, isServerSide, rows]);
|
|
5767
|
-
const MAX_PAGE =
|
|
5775
|
+
const MAX_PAGE = React36.useMemo(() => {
|
|
5768
5776
|
if (isServerSide && typeof pagination.maxPage === "number") return Math.max(0, pagination.maxPage);
|
|
5769
5777
|
if (isServerSide && typeof pagination.totalCount === "number")
|
|
5770
5778
|
return Math.max(0, Math.ceil(pagination.totalCount / perPage) - 1);
|
|
5771
5779
|
return datasets.length ? datasets.length - 1 : 0;
|
|
5772
5780
|
}, [isServerSide, pagination.maxPage, pagination.totalCount, perPage, datasets.length]);
|
|
5773
|
-
const currentPageRows =
|
|
5781
|
+
const currentPageRows = React36.useMemo(() => {
|
|
5774
5782
|
if (isServerSide) return rows;
|
|
5775
5783
|
return datasets[activePage] ?? [];
|
|
5776
5784
|
}, [isServerSide, rows, datasets, activePage]);
|
|
5777
|
-
|
|
5785
|
+
React36.useEffect(() => {
|
|
5778
5786
|
if (pagination.enabled && !isServerSide && typeof pagination.perPage === "number") {
|
|
5779
5787
|
setPerPage(pagination.perPage);
|
|
5780
5788
|
}
|
|
5781
5789
|
}, [pagination.enabled, pagination.perPage, isServerSide]);
|
|
5782
|
-
|
|
5790
|
+
React36.useEffect(() => {
|
|
5783
5791
|
if (isServerSide && typeof pagination.perPage === "number") setPerPage(pagination.perPage);
|
|
5784
5792
|
}, [isServerSide, pagination.perPage]);
|
|
5785
|
-
|
|
5793
|
+
React36.useEffect(() => {
|
|
5786
5794
|
if (isServerSide && typeof pagination.page === "number" && pagination.page >= 1)
|
|
5787
5795
|
setActivePage(pagination.page - 1);
|
|
5788
5796
|
}, [isServerSide, pagination.page]);
|
|
@@ -5871,7 +5879,7 @@ function TableSkeletonBody({
|
|
|
5871
5879
|
i
|
|
5872
5880
|
)) });
|
|
5873
5881
|
}
|
|
5874
|
-
var useIsoLayoutEffect = typeof window !== "undefined" ?
|
|
5882
|
+
var useIsoLayoutEffect = typeof window !== "undefined" ? React36.useLayoutEffect : React36.useEffect;
|
|
5875
5883
|
function VirtualList({
|
|
5876
5884
|
items,
|
|
5877
5885
|
rowHeight,
|
|
@@ -5888,10 +5896,10 @@ function VirtualList({
|
|
|
5888
5896
|
className = "",
|
|
5889
5897
|
style
|
|
5890
5898
|
}) {
|
|
5891
|
-
const scrollRef =
|
|
5892
|
-
const [scrollTop, setScrollTop] =
|
|
5893
|
-
const [viewport, setViewport] =
|
|
5894
|
-
const [term, setTerm] =
|
|
5899
|
+
const scrollRef = React36.useRef(null);
|
|
5900
|
+
const [scrollTop, setScrollTop] = React36.useState(0);
|
|
5901
|
+
const [viewport, setViewport] = React36.useState(typeof height === "number" ? height : 400);
|
|
5902
|
+
const [term, setTerm] = React36.useState("");
|
|
5895
5903
|
useIsoLayoutEffect(() => {
|
|
5896
5904
|
const el = scrollRef.current;
|
|
5897
5905
|
if (!el) return;
|
|
@@ -5902,7 +5910,7 @@ function VirtualList({
|
|
|
5902
5910
|
ro.observe(el);
|
|
5903
5911
|
return () => ro.disconnect();
|
|
5904
5912
|
}, []);
|
|
5905
|
-
const filtered =
|
|
5913
|
+
const filtered = React36.useMemo(() => {
|
|
5906
5914
|
if (!searchable || !term) return items;
|
|
5907
5915
|
if (filter) return items.filter((it) => filter(it, term));
|
|
5908
5916
|
const needle = term.toLowerCase();
|
|
@@ -6043,35 +6051,37 @@ function PdfViewer({
|
|
|
6043
6051
|
onLoad,
|
|
6044
6052
|
onError,
|
|
6045
6053
|
onPageChange,
|
|
6054
|
+
height = 600,
|
|
6055
|
+
width,
|
|
6046
6056
|
className = "",
|
|
6047
6057
|
style
|
|
6048
6058
|
}) {
|
|
6049
|
-
const [pdfjs, setPdfjs] =
|
|
6050
|
-
const [doc, setDoc] =
|
|
6051
|
-
const [numPages, setNumPages] =
|
|
6052
|
-
const [baseSize, setBaseSize] =
|
|
6053
|
-
const [sizes, setSizes] =
|
|
6054
|
-
const [status, setStatus] =
|
|
6055
|
-
const [error, setError] =
|
|
6056
|
-
const [reloadKey, setReloadKey] =
|
|
6057
|
-
const scrollRef =
|
|
6058
|
-
const [scrollTop, setScrollTop] =
|
|
6059
|
-
const [viewport, setViewport] =
|
|
6060
|
-
const [zoomMode, setZoomMode] =
|
|
6061
|
-
const [page, setPage] =
|
|
6062
|
-
const [showSearch, setShowSearch] =
|
|
6063
|
-
const [query, setQuery] =
|
|
6064
|
-
const [matchPages, setMatchPages] =
|
|
6065
|
-
const [matchIdx, setMatchIdx] =
|
|
6066
|
-
const [searching, setSearching] =
|
|
6067
|
-
const [pageDraft, setPageDraft] =
|
|
6068
|
-
const pageEditing =
|
|
6069
|
-
const pageText =
|
|
6070
|
-
const searchSeq =
|
|
6071
|
-
const searchTimer =
|
|
6072
|
-
const measured =
|
|
6059
|
+
const [pdfjs, setPdfjs] = React36.useState(null);
|
|
6060
|
+
const [doc, setDoc] = React36.useState(null);
|
|
6061
|
+
const [numPages, setNumPages] = React36.useState(0);
|
|
6062
|
+
const [baseSize, setBaseSize] = React36.useState(null);
|
|
6063
|
+
const [sizes, setSizes] = React36.useState([]);
|
|
6064
|
+
const [status, setStatus] = React36.useState("loading");
|
|
6065
|
+
const [error, setError] = React36.useState(null);
|
|
6066
|
+
const [reloadKey, setReloadKey] = React36.useState(0);
|
|
6067
|
+
const scrollRef = React36.useRef(null);
|
|
6068
|
+
const [scrollTop, setScrollTop] = React36.useState(0);
|
|
6069
|
+
const [viewport, setViewport] = React36.useState({ w: 0, h: 0 });
|
|
6070
|
+
const [zoomMode, setZoomMode] = React36.useState(zoom);
|
|
6071
|
+
const [page, setPage] = React36.useState(initialPage);
|
|
6072
|
+
const [showSearch, setShowSearch] = React36.useState(false);
|
|
6073
|
+
const [query, setQuery] = React36.useState("");
|
|
6074
|
+
const [matchPages, setMatchPages] = React36.useState(null);
|
|
6075
|
+
const [matchIdx, setMatchIdx] = React36.useState(0);
|
|
6076
|
+
const [searching, setSearching] = React36.useState(false);
|
|
6077
|
+
const [pageDraft, setPageDraft] = React36.useState("");
|
|
6078
|
+
const pageEditing = React36.useRef(false);
|
|
6079
|
+
const pageText = React36.useRef(/* @__PURE__ */ new Map());
|
|
6080
|
+
const searchSeq = React36.useRef(0);
|
|
6081
|
+
const searchTimer = React36.useRef(null);
|
|
6082
|
+
const measured = React36.useRef(/* @__PURE__ */ new Set());
|
|
6073
6083
|
const tb = toolbar === true ? { zoom: true, pager: true, download: true, print: true, search: true } : toolbar || {};
|
|
6074
|
-
|
|
6084
|
+
React36.useEffect(() => {
|
|
6075
6085
|
let cancelled = false;
|
|
6076
6086
|
let task;
|
|
6077
6087
|
setStatus("loading");
|
|
@@ -6115,10 +6125,10 @@ function PdfViewer({
|
|
|
6115
6125
|
task?.destroy?.();
|
|
6116
6126
|
};
|
|
6117
6127
|
}, [source, remote, reloadKey, workerSrc]);
|
|
6118
|
-
|
|
6128
|
+
React36.useEffect(() => () => {
|
|
6119
6129
|
doc?.destroy?.();
|
|
6120
6130
|
}, [doc]);
|
|
6121
|
-
|
|
6131
|
+
React36.useEffect(() => {
|
|
6122
6132
|
const el = scrollRef.current;
|
|
6123
6133
|
if (!el || typeof ResizeObserver === "undefined") return;
|
|
6124
6134
|
const measure = () => setViewport({ w: el.clientWidth, h: el.clientHeight });
|
|
@@ -6127,7 +6137,7 @@ function PdfViewer({
|
|
|
6127
6137
|
ro.observe(el);
|
|
6128
6138
|
return () => ro.disconnect();
|
|
6129
6139
|
}, [status]);
|
|
6130
|
-
const handleMeasure =
|
|
6140
|
+
const handleMeasure = React36.useCallback((p, size) => {
|
|
6131
6141
|
setSizes((prev) => {
|
|
6132
6142
|
const cur = prev[p - 1];
|
|
6133
6143
|
if (cur && Math.abs(cur.width - size.width) < 0.5 && Math.abs(cur.height - size.height) < 0.5) return prev;
|
|
@@ -6136,7 +6146,7 @@ function PdfViewer({
|
|
|
6136
6146
|
return next;
|
|
6137
6147
|
});
|
|
6138
6148
|
}, []);
|
|
6139
|
-
const scale =
|
|
6149
|
+
const scale = React36.useMemo(() => {
|
|
6140
6150
|
if (!baseSize) return 1;
|
|
6141
6151
|
if (typeof zoomMode === "number") return zoomMode;
|
|
6142
6152
|
const avail = Math.max(1, (viewport.w || baseSize.width) - 32);
|
|
@@ -6147,7 +6157,7 @@ function PdfViewer({
|
|
|
6147
6157
|
}
|
|
6148
6158
|
return 1;
|
|
6149
6159
|
}, [zoomMode, baseSize, viewport]);
|
|
6150
|
-
const { offsets, total } =
|
|
6160
|
+
const { offsets, total } = React36.useMemo(() => {
|
|
6151
6161
|
const offs = new Array(sizes.length);
|
|
6152
6162
|
let acc = 0;
|
|
6153
6163
|
for (let i = 0; i < sizes.length; i++) {
|
|
@@ -6161,13 +6171,13 @@ function PdfViewer({
|
|
|
6161
6171
|
const startIdx = hasLayout ? Math.max(0, pageIndexAt(offsets, scrollTop) - overscan) : 0;
|
|
6162
6172
|
const endIdx = hasLayout ? Math.min(numPages, pageIndexAt(offsets, scrollTop + viewport.h) + 1 + overscan) : 0;
|
|
6163
6173
|
const visiblePages = Array.from({ length: Math.max(0, endIdx - startIdx) }, (_, i) => startIdx + i + 1);
|
|
6164
|
-
const scrollToPage =
|
|
6174
|
+
const scrollToPage = React36.useCallback((p) => {
|
|
6165
6175
|
const el = scrollRef.current;
|
|
6166
6176
|
if (!el || !offsets.length) return;
|
|
6167
6177
|
const clamped = Math.min(offsets.length, Math.max(1, p));
|
|
6168
6178
|
el.scrollTo({ top: offsets[clamped - 1] ?? 0, behavior: "smooth" });
|
|
6169
6179
|
}, [offsets]);
|
|
6170
|
-
|
|
6180
|
+
React36.useEffect(() => {
|
|
6171
6181
|
if (!hasLayout) return;
|
|
6172
6182
|
const cur = pageIndexAt(offsets, scrollTop + viewport.h / 2) + 1;
|
|
6173
6183
|
if (cur !== page) {
|
|
@@ -6175,10 +6185,10 @@ function PdfViewer({
|
|
|
6175
6185
|
onPageChange?.(cur);
|
|
6176
6186
|
}
|
|
6177
6187
|
}, [scrollTop, offsets, viewport.h, numPages]);
|
|
6178
|
-
|
|
6188
|
+
React36.useEffect(() => {
|
|
6179
6189
|
if (status === "ready" && initialPage > 1) scrollToPage(initialPage);
|
|
6180
6190
|
}, [status, initialPage]);
|
|
6181
|
-
const runSearch =
|
|
6191
|
+
const runSearch = React36.useCallback(async (q) => {
|
|
6182
6192
|
const needle = q.trim().toLowerCase();
|
|
6183
6193
|
if (!doc || !needle) {
|
|
6184
6194
|
setMatchPages(null);
|
|
@@ -6207,7 +6217,7 @@ function PdfViewer({
|
|
|
6207
6217
|
setSearching(false);
|
|
6208
6218
|
if (hits.length) scrollToPage(hits[0]);
|
|
6209
6219
|
}, [doc, numPages, scrollToPage]);
|
|
6210
|
-
const onQueryChange =
|
|
6220
|
+
const onQueryChange = React36.useCallback((v) => {
|
|
6211
6221
|
setQuery(v);
|
|
6212
6222
|
if (searchTimer.current) clearTimeout(searchTimer.current);
|
|
6213
6223
|
if (!v.trim()) {
|
|
@@ -6219,7 +6229,7 @@ function PdfViewer({
|
|
|
6219
6229
|
}
|
|
6220
6230
|
searchTimer.current = setTimeout(() => runSearch(v), SEARCH_DEBOUNCE);
|
|
6221
6231
|
}, [runSearch]);
|
|
6222
|
-
|
|
6232
|
+
React36.useEffect(() => () => {
|
|
6223
6233
|
if (searchTimer.current) clearTimeout(searchTimer.current);
|
|
6224
6234
|
}, []);
|
|
6225
6235
|
const gotoMatch = (dir) => {
|
|
@@ -6228,18 +6238,18 @@ function PdfViewer({
|
|
|
6228
6238
|
setMatchIdx(next);
|
|
6229
6239
|
scrollToPage(matchPages[next]);
|
|
6230
6240
|
};
|
|
6231
|
-
const getBytes =
|
|
6241
|
+
const getBytes = React36.useCallback(async () => {
|
|
6232
6242
|
if (doc?.getData) return doc.getData();
|
|
6233
6243
|
if (source instanceof Uint8Array) return source;
|
|
6234
6244
|
if (source instanceof ArrayBuffer) return new Uint8Array(source);
|
|
6235
6245
|
if (typeof Blob !== "undefined" && source instanceof Blob) return new Uint8Array(await source.arrayBuffer());
|
|
6236
6246
|
throw new Error("No bytes available");
|
|
6237
6247
|
}, [doc, source]);
|
|
6238
|
-
const download =
|
|
6248
|
+
const download = React36.useCallback(async () => {
|
|
6239
6249
|
const bytes = await getBytes();
|
|
6240
6250
|
downloadBlob(new Blob([bytes], { type: "application/pdf" }), sourceName(source) || "document.pdf");
|
|
6241
6251
|
}, [getBytes, source]);
|
|
6242
|
-
const print =
|
|
6252
|
+
const print = React36.useCallback(async () => {
|
|
6243
6253
|
const bytes = await getBytes();
|
|
6244
6254
|
const blob = new Blob([bytes], { type: "application/pdf" });
|
|
6245
6255
|
const url = URL.createObjectURL(blob);
|
|
@@ -6277,7 +6287,7 @@ function PdfViewer({
|
|
|
6277
6287
|
] });
|
|
6278
6288
|
}
|
|
6279
6289
|
const ready = status === "ready";
|
|
6280
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx("flex flex-col overflow-hidden rounded-lg border border-border bg-surface-raised", className), style: { height
|
|
6290
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx("flex flex-col overflow-hidden rounded-lg border border-border bg-surface-raised", className), style: { height, width, ...style }, children: [
|
|
6281
6291
|
toolbar !== false && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-shrink-0 flex-col border-b border-border bg-surface", children: [
|
|
6282
6292
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1 px-2 py-1.5", children: [
|
|
6283
6293
|
tb.pager && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
|
|
@@ -6397,9 +6407,9 @@ function PdfPage({
|
|
|
6397
6407
|
textLayer,
|
|
6398
6408
|
onMeasure
|
|
6399
6409
|
}) {
|
|
6400
|
-
const canvasRef =
|
|
6401
|
-
const textRef =
|
|
6402
|
-
|
|
6410
|
+
const canvasRef = React36.useRef(null);
|
|
6411
|
+
const textRef = React36.useRef(null);
|
|
6412
|
+
React36.useEffect(() => {
|
|
6403
6413
|
let cancelled = false;
|
|
6404
6414
|
let renderTask;
|
|
6405
6415
|
(async () => {
|
|
@@ -6458,6 +6468,15 @@ var FitPageIcon = () => /* @__PURE__ */ jsxRuntime.jsxs("svg", { viewBox: "0 0 2
|
|
|
6458
6468
|
] });
|
|
6459
6469
|
var DEFAULT_COL_WIDTH = 140;
|
|
6460
6470
|
var GUTTER = 52;
|
|
6471
|
+
var END_PAD = 12;
|
|
6472
|
+
function compareValues2(a, b) {
|
|
6473
|
+
if (a == null && b == null) return 0;
|
|
6474
|
+
if (a == null) return 1;
|
|
6475
|
+
if (b == null) return -1;
|
|
6476
|
+
if (typeof a === "number" && typeof b === "number") return a - b;
|
|
6477
|
+
if (typeof a === "boolean" && typeof b === "boolean") return a === b ? 0 : a ? 1 : -1;
|
|
6478
|
+
return String(a).localeCompare(String(b), void 0, { numeric: true, sensitivity: "base" });
|
|
6479
|
+
}
|
|
6461
6480
|
function resolveWidth(w) {
|
|
6462
6481
|
if (typeof w === "number" && Number.isFinite(w)) return w;
|
|
6463
6482
|
if (typeof w === "string") {
|
|
@@ -6476,7 +6495,11 @@ function DataGrid({
|
|
|
6476
6495
|
rowHeight = 34,
|
|
6477
6496
|
headerHeight = 38,
|
|
6478
6497
|
height = 480,
|
|
6498
|
+
width,
|
|
6479
6499
|
editable = false,
|
|
6500
|
+
sortable = false,
|
|
6501
|
+
sort: sortProp,
|
|
6502
|
+
onSortChange,
|
|
6480
6503
|
virtualize = true,
|
|
6481
6504
|
overscan = 4,
|
|
6482
6505
|
rowNumbers = true,
|
|
@@ -6485,13 +6508,16 @@ function DataGrid({
|
|
|
6485
6508
|
style,
|
|
6486
6509
|
emptyState = "No data"
|
|
6487
6510
|
}) {
|
|
6488
|
-
const scrollRef =
|
|
6489
|
-
const [scroll, setScroll] =
|
|
6490
|
-
const [viewport, setViewport] =
|
|
6491
|
-
const [editing, setEditing] =
|
|
6492
|
-
const [draft, setDraft] =
|
|
6511
|
+
const scrollRef = React36.useRef(null);
|
|
6512
|
+
const [scroll, setScroll] = React36.useState({ top: 0, left: 0 });
|
|
6513
|
+
const [viewport, setViewport] = React36.useState({ w: 0, h: 0 });
|
|
6514
|
+
const [editing, setEditing] = React36.useState(null);
|
|
6515
|
+
const [draft, setDraft] = React36.useState("");
|
|
6516
|
+
const [internalSort, setInternalSort] = React36.useState(null);
|
|
6517
|
+
const sort = sortProp !== void 0 ? sortProp : internalSort;
|
|
6493
6518
|
const gutter = rowNumbers ? GUTTER : 0;
|
|
6494
|
-
const
|
|
6519
|
+
const colSortable = (c) => c.sortable ?? sortable;
|
|
6520
|
+
const { widths, offsets, totalWidth } = React36.useMemo(() => {
|
|
6495
6521
|
const widths2 = columns.map((c) => resolveWidth(c.width));
|
|
6496
6522
|
const offsets2 = [];
|
|
6497
6523
|
let acc = 0;
|
|
@@ -6501,8 +6527,20 @@ function DataGrid({
|
|
|
6501
6527
|
}
|
|
6502
6528
|
return { widths: widths2, offsets: offsets2, totalWidth: acc };
|
|
6503
6529
|
}, [columns]);
|
|
6530
|
+
const order = React36.useMemo(() => {
|
|
6531
|
+
const idx = rows.map((_, i) => i);
|
|
6532
|
+
if (!sort) return idx;
|
|
6533
|
+
const dir = sort.dir === "asc" ? 1 : -1;
|
|
6534
|
+
return idx.sort((ia, ib) => dir * compareValues2(rows[ia]?.[sort.key] ?? null, rows[ib]?.[sort.key] ?? null));
|
|
6535
|
+
}, [rows, sort]);
|
|
6536
|
+
const toggleSort = (key) => {
|
|
6537
|
+
const nextDir = sort?.key !== key ? "asc" : sort.dir === "asc" ? "desc" : null;
|
|
6538
|
+
const next = nextDir ? { key, dir: nextDir } : null;
|
|
6539
|
+
if (sortProp === void 0) setInternalSort(next);
|
|
6540
|
+
onSortChange?.(next);
|
|
6541
|
+
};
|
|
6504
6542
|
const totalHeight = rows.length * rowHeight;
|
|
6505
|
-
|
|
6543
|
+
React36.useEffect(() => {
|
|
6506
6544
|
const el = scrollRef.current;
|
|
6507
6545
|
if (!el || typeof ResizeObserver === "undefined") return;
|
|
6508
6546
|
const measure = () => setViewport({ w: el.clientWidth, h: el.clientHeight });
|
|
@@ -6528,17 +6566,17 @@ function DataGrid({
|
|
|
6528
6566
|
}
|
|
6529
6567
|
const visibleRows = Array.from({ length: Math.max(0, rowEnd - rowStart) }, (_, i) => rowStart + i);
|
|
6530
6568
|
const visibleCols = Array.from({ length: Math.max(0, colEnd - colStart) }, (_, i) => colStart + i);
|
|
6531
|
-
const commit =
|
|
6569
|
+
const commit = React36.useCallback(() => {
|
|
6532
6570
|
if (!editing) return;
|
|
6533
6571
|
const col = columns[editing.col];
|
|
6534
|
-
onCellEdit?.({ row: editing.
|
|
6572
|
+
onCellEdit?.({ row: order[editing.disp], column: col.key, value: draft });
|
|
6535
6573
|
setEditing(null);
|
|
6536
|
-
}, [editing, columns, draft, onCellEdit]);
|
|
6537
|
-
const startEdit = (
|
|
6574
|
+
}, [editing, columns, draft, onCellEdit, order]);
|
|
6575
|
+
const startEdit = (disp, col) => {
|
|
6538
6576
|
const c = columns[col];
|
|
6539
6577
|
if (!(c.editable ?? editable)) return;
|
|
6540
|
-
setDraft(displayValue(rows[
|
|
6541
|
-
setEditing({
|
|
6578
|
+
setDraft(displayValue(rows[order[disp]]?.[c.key] ?? ""));
|
|
6579
|
+
setEditing({ disp, col });
|
|
6542
6580
|
};
|
|
6543
6581
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6544
6582
|
"div",
|
|
@@ -6546,12 +6584,12 @@ function DataGrid({
|
|
|
6546
6584
|
ref: scrollRef,
|
|
6547
6585
|
onScroll: (e) => setScroll({ top: e.currentTarget.scrollTop, left: e.currentTarget.scrollLeft }),
|
|
6548
6586
|
className: cx("relative overflow-auto rounded-lg border border-border bg-surface-raised text-sm", className),
|
|
6549
|
-
style: { height, ...style },
|
|
6587
|
+
style: { height, width, ...style },
|
|
6550
6588
|
role: "grid",
|
|
6551
6589
|
"aria-rowcount": rows.length,
|
|
6552
6590
|
"aria-colcount": columns.length,
|
|
6553
6591
|
children: [
|
|
6554
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { position: "relative", width: gutter + totalWidth, height: headerHeight + totalHeight }, children: [
|
|
6592
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { position: "relative", width: gutter + totalWidth + END_PAD, height: headerHeight + totalHeight + END_PAD }, children: [
|
|
6555
6593
|
rowNumbers && /* @__PURE__ */ jsxRuntime.jsx(
|
|
6556
6594
|
"div",
|
|
6557
6595
|
{
|
|
@@ -6561,11 +6599,18 @@ function DataGrid({
|
|
|
6561
6599
|
),
|
|
6562
6600
|
visibleCols.map((ci) => {
|
|
6563
6601
|
const c = columns[ci];
|
|
6564
|
-
|
|
6602
|
+
const sortDir = sort?.key === c.key ? sort.dir : null;
|
|
6603
|
+
const canSort = colSortable(c);
|
|
6604
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6565
6605
|
"div",
|
|
6566
6606
|
{
|
|
6567
6607
|
role: "columnheader",
|
|
6568
|
-
|
|
6608
|
+
"aria-sort": sortDir ? sortDir === "asc" ? "ascending" : "descending" : void 0,
|
|
6609
|
+
onClick: canSort ? () => toggleSort(c.key) : void 0,
|
|
6610
|
+
className: cx(
|
|
6611
|
+
"flex items-center gap-1 border-b border-r border-border bg-surface px-3 font-medium text-foreground-secondary",
|
|
6612
|
+
canSort && "cursor-pointer select-none hover:text-foreground"
|
|
6613
|
+
),
|
|
6569
6614
|
style: {
|
|
6570
6615
|
position: "absolute",
|
|
6571
6616
|
top: scroll.top,
|
|
@@ -6575,38 +6620,42 @@ function DataGrid({
|
|
|
6575
6620
|
zIndex: 2,
|
|
6576
6621
|
justifyContent: c.align === "right" ? "flex-end" : c.align === "center" ? "center" : "flex-start"
|
|
6577
6622
|
},
|
|
6578
|
-
children:
|
|
6623
|
+
children: [
|
|
6624
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: c.label ?? c.key }),
|
|
6625
|
+
canSort && /* @__PURE__ */ jsxRuntime.jsx(SortCaret, { dir: sortDir })
|
|
6626
|
+
]
|
|
6579
6627
|
},
|
|
6580
6628
|
`h-${c.key}`
|
|
6581
6629
|
);
|
|
6582
6630
|
}),
|
|
6583
|
-
rowNumbers && visibleRows.map((
|
|
6631
|
+
rowNumbers && visibleRows.map((disp) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
6584
6632
|
"div",
|
|
6585
6633
|
{
|
|
6586
6634
|
className: "flex items-center justify-center border-b border-r border-border bg-surface text-xs tabular-nums text-foreground-muted",
|
|
6587
|
-
style: { position: "absolute", left: scroll.left, top: headerHeight +
|
|
6588
|
-
children:
|
|
6635
|
+
style: { position: "absolute", left: scroll.left, top: headerHeight + disp * rowHeight, width: gutter, height: rowHeight, zIndex: 1 },
|
|
6636
|
+
children: disp + 1
|
|
6589
6637
|
},
|
|
6590
|
-
`g-${
|
|
6638
|
+
`g-${disp}`
|
|
6591
6639
|
)),
|
|
6592
|
-
visibleRows.map(
|
|
6593
|
-
|
|
6640
|
+
visibleRows.map((disp) => {
|
|
6641
|
+
const ri = order[disp];
|
|
6642
|
+
return visibleCols.map((ci) => {
|
|
6594
6643
|
const c = columns[ci];
|
|
6595
|
-
const isEditing = editing?.
|
|
6644
|
+
const isEditing = editing?.disp === disp && editing?.col === ci;
|
|
6596
6645
|
const canEdit = c.editable ?? editable;
|
|
6597
6646
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6598
6647
|
"div",
|
|
6599
6648
|
{
|
|
6600
6649
|
role: "gridcell",
|
|
6601
|
-
onDoubleClick: () => startEdit(
|
|
6650
|
+
onDoubleClick: () => startEdit(disp, ci),
|
|
6602
6651
|
className: cx(
|
|
6603
6652
|
"flex items-center border-b border-r border-border px-3",
|
|
6604
|
-
|
|
6653
|
+
disp % 2 ? "bg-surface-raised" : "bg-surface",
|
|
6605
6654
|
canEdit && "cursor-text"
|
|
6606
6655
|
),
|
|
6607
6656
|
style: {
|
|
6608
6657
|
position: "absolute",
|
|
6609
|
-
top: headerHeight +
|
|
6658
|
+
top: headerHeight + disp * rowHeight,
|
|
6610
6659
|
left: gutter + offsets[ci],
|
|
6611
6660
|
width: widths[ci],
|
|
6612
6661
|
height: rowHeight,
|
|
@@ -6627,16 +6676,22 @@ function DataGrid({
|
|
|
6627
6676
|
}
|
|
6628
6677
|
) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-foreground", children: displayValue(rows[ri]?.[c.key] ?? "") })
|
|
6629
6678
|
},
|
|
6630
|
-
`${
|
|
6679
|
+
`${disp}-${c.key}`
|
|
6631
6680
|
);
|
|
6632
|
-
})
|
|
6633
|
-
)
|
|
6681
|
+
});
|
|
6682
|
+
})
|
|
6634
6683
|
] }),
|
|
6635
6684
|
rows.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 flex items-center justify-center text-foreground-muted", style: { top: headerHeight }, children: emptyState })
|
|
6636
6685
|
]
|
|
6637
6686
|
}
|
|
6638
6687
|
);
|
|
6639
6688
|
}
|
|
6689
|
+
function SortCaret({ dir }) {
|
|
6690
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { viewBox: "0 0 16 16", className: "h-3 w-3 flex-shrink-0", fill: "none", stroke: "currentColor", strokeWidth: 1.75, "aria-hidden": "true", children: [
|
|
6691
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M5 6.5 8 3.5l3 3", className: dir === "asc" ? "text-accent" : "text-foreground-muted opacity-50" }),
|
|
6692
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M5 9.5 8 12.5l3-3", className: dir === "desc" ? "text-accent" : "text-foreground-muted opacity-50" })
|
|
6693
|
+
] });
|
|
6694
|
+
}
|
|
6640
6695
|
function toColumns(cols) {
|
|
6641
6696
|
return cols.map((c) => typeof c === "string" ? { key: c, label: c } : { ...c, label: c.label ?? c.key });
|
|
6642
6697
|
}
|
|
@@ -6675,15 +6730,18 @@ function Spreadsheet({
|
|
|
6675
6730
|
export: exportFormats = ["xlsx", "csv", "pdf"],
|
|
6676
6731
|
fileName,
|
|
6677
6732
|
virtualize = true,
|
|
6733
|
+
sortable = true,
|
|
6734
|
+
height = 480,
|
|
6735
|
+
width,
|
|
6678
6736
|
className = "",
|
|
6679
6737
|
style
|
|
6680
6738
|
}) {
|
|
6681
|
-
const [sheets, setSheets] =
|
|
6682
|
-
const [active, setActive] =
|
|
6683
|
-
const [status, setStatus] =
|
|
6684
|
-
const [error, setError] =
|
|
6685
|
-
const [reloadKey, setReloadKey] =
|
|
6686
|
-
|
|
6739
|
+
const [sheets, setSheets] = React36.useState(Array.isArray(source) ? source : null);
|
|
6740
|
+
const [active, setActive] = React36.useState(0);
|
|
6741
|
+
const [status, setStatus] = React36.useState(Array.isArray(source) ? "ready" : "loading");
|
|
6742
|
+
const [error, setError] = React36.useState(null);
|
|
6743
|
+
const [reloadKey, setReloadKey] = React36.useState(0);
|
|
6744
|
+
React36.useEffect(() => {
|
|
6687
6745
|
if (Array.isArray(source)) {
|
|
6688
6746
|
setSheets(source);
|
|
6689
6747
|
setStatus("ready");
|
|
@@ -6729,9 +6787,9 @@ function Spreadsheet({
|
|
|
6729
6787
|
};
|
|
6730
6788
|
}, [source, remote, reloadKey]);
|
|
6731
6789
|
const sheet = sheets?.[active];
|
|
6732
|
-
const columns =
|
|
6733
|
-
const plainRows =
|
|
6734
|
-
const handleCellEdit =
|
|
6790
|
+
const columns = React36.useMemo(() => sheet ? toColumns(sheet.columns) : [], [sheet]);
|
|
6791
|
+
const plainRows = React36.useMemo(() => sheet ? toPlainRows(sheet, columns) : [], [sheet, columns]);
|
|
6792
|
+
const handleCellEdit = React36.useCallback(({ row, column, value }) => {
|
|
6735
6793
|
let coerced = value;
|
|
6736
6794
|
setSheets((prev) => {
|
|
6737
6795
|
if (!prev) return prev;
|
|
@@ -6750,17 +6808,17 @@ function Spreadsheet({
|
|
|
6750
6808
|
});
|
|
6751
6809
|
onCellEdit?.({ sheet: sheets?.[active]?.name ?? "", row, column, value: coerced });
|
|
6752
6810
|
}, [active, onCellEdit, onChange, sheets]);
|
|
6753
|
-
const baseName =
|
|
6811
|
+
const baseName = React36.useMemo(
|
|
6754
6812
|
() => (fileName || (typeof source === "object" && "name" in source ? sourceName(source) : null) || "spreadsheet").replace(/\.[^.]+$/, ""),
|
|
6755
6813
|
[fileName, source]
|
|
6756
6814
|
);
|
|
6757
|
-
const sheetAoa =
|
|
6815
|
+
const sheetAoa = React36.useCallback((s) => {
|
|
6758
6816
|
const cols = toColumns(s.columns);
|
|
6759
6817
|
const header = cols.map((c) => typeof c.label === "string" ? c.label : c.key);
|
|
6760
6818
|
const body = s.rows.map((r) => cols.map((c) => cellValue(r[c.key])));
|
|
6761
6819
|
return [header, ...body];
|
|
6762
6820
|
}, []);
|
|
6763
|
-
const exportXlsx =
|
|
6821
|
+
const exportXlsx = React36.useCallback(async () => {
|
|
6764
6822
|
if (!sheets) return;
|
|
6765
6823
|
const XLSX = await loadXlsx();
|
|
6766
6824
|
const wb = XLSX.utils.book_new();
|
|
@@ -6771,7 +6829,7 @@ function Spreadsheet({
|
|
|
6771
6829
|
const out = XLSX.write(wb, { bookType: "xlsx", type: "array" });
|
|
6772
6830
|
downloadBlob(new Blob([out], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" }), `${baseName}.xlsx`);
|
|
6773
6831
|
}, [sheets, sheetAoa, baseName]);
|
|
6774
|
-
const exportCsv =
|
|
6832
|
+
const exportCsv = React36.useCallback(() => {
|
|
6775
6833
|
if (!sheet) return;
|
|
6776
6834
|
const aoa = sheetAoa(sheet);
|
|
6777
6835
|
const esc = (v) => {
|
|
@@ -6781,7 +6839,7 @@ function Spreadsheet({
|
|
|
6781
6839
|
const csv = aoa.map((row) => row.map(esc).join(",")).join("\r\n");
|
|
6782
6840
|
downloadBlob(new Blob([`\uFEFF${csv}`], { type: "text/csv;charset=utf-8" }), `${baseName}.csv`);
|
|
6783
6841
|
}, [sheet, sheetAoa, baseName]);
|
|
6784
|
-
const exportPdf =
|
|
6842
|
+
const exportPdf = React36.useCallback(async () => {
|
|
6785
6843
|
if (!sheet) return;
|
|
6786
6844
|
const { jsPDF } = await loadJspdf();
|
|
6787
6845
|
const doc = new jsPDF({ orientation: "landscape", unit: "pt", format: "a4" });
|
|
@@ -6822,16 +6880,16 @@ function Spreadsheet({
|
|
|
6822
6880
|
else void exportPdf();
|
|
6823
6881
|
};
|
|
6824
6882
|
if (status === "error") {
|
|
6825
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx("flex flex-col items-center justify-center gap-3 rounded-lg border border-border bg-surface p-8 text-center", className), style, children: [
|
|
6883
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx("flex flex-col items-center justify-center gap-3 rounded-lg border border-border bg-surface p-8 text-center", className), style: { height, width, ...style }, children: [
|
|
6826
6884
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-status-error", children: "Couldn\u2019t load the spreadsheet" }),
|
|
6827
6885
|
error?.message && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "max-w-md text-xs text-foreground-muted", children: error.message }),
|
|
6828
6886
|
/* @__PURE__ */ jsxRuntime.jsx(Button_default, { content: "Retry", size: "sm", variant: "outline", onClick: () => setReloadKey((k) => k + 1) })
|
|
6829
6887
|
] });
|
|
6830
6888
|
}
|
|
6831
6889
|
if (status === "loading" || !sheets) {
|
|
6832
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx("rounded-lg border border-border bg-surface-raised p-4", className), style, children: [
|
|
6890
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx("overflow-hidden rounded-lg border border-border bg-surface-raised p-4", className), style: { height, width, ...style }, children: [
|
|
6833
6891
|
/* @__PURE__ */ jsxRuntime.jsx(SkeletonBox, { height: 32, className: "mb-3 rounded" }),
|
|
6834
|
-
/* @__PURE__ */ jsxRuntime.jsx(SkeletonBox, { height:
|
|
6892
|
+
/* @__PURE__ */ jsxRuntime.jsx(SkeletonBox, { height: "calc(100% - 44px)", className: "rounded" })
|
|
6835
6893
|
] });
|
|
6836
6894
|
}
|
|
6837
6895
|
const formats = exportFormats || [];
|
|
@@ -6840,25 +6898,10 @@ function Spreadsheet({
|
|
|
6840
6898
|
csv: "CSV \u2014 this sheet (.csv)",
|
|
6841
6899
|
pdf: "PDF table (.pdf)"
|
|
6842
6900
|
};
|
|
6843
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx("flex flex-col overflow-hidden rounded-lg border border-border bg-surface-raised", className), style, children: [
|
|
6844
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-shrink-0 items-center gap-2 border-b border-border bg-surface px-
|
|
6845
|
-
|
|
6846
|
-
|
|
6847
|
-
{
|
|
6848
|
-
role: "tab",
|
|
6849
|
-
type: "button",
|
|
6850
|
-
"aria-selected": i === active,
|
|
6851
|
-
onClick: () => setActive(i),
|
|
6852
|
-
className: cx(
|
|
6853
|
-
"flex-shrink-0 rounded-md px-3 py-1 text-sm font-medium transition-colors",
|
|
6854
|
-
"focus:outline-none focus-visible:ring-2 focus-visible:ring-accent",
|
|
6855
|
-
i === active ? "bg-accent text-accent-fg shadow-sm" : "text-foreground-secondary hover:bg-surface-raised hover:text-foreground"
|
|
6856
|
-
),
|
|
6857
|
-
children: s.name || `Sheet ${i + 1}`
|
|
6858
|
-
},
|
|
6859
|
-
`${s.name}-${i}`
|
|
6860
|
-
)) }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-1 truncate px-1 text-sm font-medium text-foreground", children: sheet?.name || "Sheet 1" }),
|
|
6861
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "hidden flex-shrink-0 px-1 text-xs tabular-nums text-foreground-muted sm:inline", children: [
|
|
6901
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx("flex flex-col overflow-hidden rounded-lg border border-border bg-surface-raised", className), style: { height, width, ...style }, children: [
|
|
6902
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-shrink-0 items-center gap-2 border-b border-border bg-surface px-3 py-1.5", children: [
|
|
6903
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate text-sm font-semibold text-foreground", children: sheet?.name || "Sheet 1" }),
|
|
6904
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "hidden flex-shrink-0 text-xs tabular-nums text-foreground-muted sm:inline", children: [
|
|
6862
6905
|
plainRows.length.toLocaleString(),
|
|
6863
6906
|
" ",
|
|
6864
6907
|
plainRows.length === 1 ? "row" : "rows",
|
|
@@ -6885,22 +6928,41 @@ function Spreadsheet({
|
|
|
6885
6928
|
)
|
|
6886
6929
|
] })
|
|
6887
6930
|
] }),
|
|
6888
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6931
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6889
6932
|
DataGrid,
|
|
6890
6933
|
{
|
|
6891
6934
|
columns,
|
|
6892
6935
|
rows: plainRows,
|
|
6893
6936
|
editable,
|
|
6937
|
+
sortable,
|
|
6894
6938
|
virtualize,
|
|
6895
6939
|
onCellEdit: handleCellEdit,
|
|
6940
|
+
height: "100%",
|
|
6896
6941
|
className: "!rounded-none !border-0"
|
|
6897
|
-
}
|
|
6898
|
-
|
|
6942
|
+
},
|
|
6943
|
+
active
|
|
6944
|
+
) }),
|
|
6945
|
+
sheets.length > 1 && /* @__PURE__ */ jsxRuntime.jsx("div", { role: "tablist", "aria-label": "Sheets", className: "flex flex-shrink-0 items-center gap-1 overflow-x-auto border-t border-border bg-surface px-2 py-1", children: sheets.map((s, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
6946
|
+
"button",
|
|
6947
|
+
{
|
|
6948
|
+
role: "tab",
|
|
6949
|
+
type: "button",
|
|
6950
|
+
"aria-selected": i === active,
|
|
6951
|
+
onClick: () => setActive(i),
|
|
6952
|
+
className: cx(
|
|
6953
|
+
"flex-shrink-0 rounded-md px-3 py-1 text-xs font-medium transition-colors",
|
|
6954
|
+
"focus:outline-none focus-visible:ring-2 focus-visible:ring-accent",
|
|
6955
|
+
i === active ? "bg-surface-raised text-foreground shadow-sm" : "text-foreground-secondary hover:bg-surface-raised hover:text-foreground"
|
|
6956
|
+
),
|
|
6957
|
+
children: s.name || `Sheet ${i + 1}`
|
|
6958
|
+
},
|
|
6959
|
+
`${s.name}-${i}`
|
|
6960
|
+
)) })
|
|
6899
6961
|
] });
|
|
6900
6962
|
}
|
|
6901
6963
|
var DownloadIcon2 = () => /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, className: "h-4 w-4", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M12 3v12m0 0 4-4m-4 4-4-4M4 21h16" }) });
|
|
6902
6964
|
function ThemeSwitch({ checked, onChange, label = "Toggle dark mode", className = "" }) {
|
|
6903
|
-
const id =
|
|
6965
|
+
const id = React36.useId();
|
|
6904
6966
|
return /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: id, className: `flex items-center gap-2 cursor-pointer select-none ${className}`.trim(), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6905
6967
|
SwitchPrimitive__namespace.Root,
|
|
6906
6968
|
{
|
|
@@ -6998,8 +7060,8 @@ function FlyoutItems({ items }) {
|
|
|
6998
7060
|
}) });
|
|
6999
7061
|
}
|
|
7000
7062
|
function CollapsedFlyout({ item, trigger }) {
|
|
7001
|
-
const [open, setOpen] =
|
|
7002
|
-
const closeTimer =
|
|
7063
|
+
const [open, setOpen] = React36.useState(false);
|
|
7064
|
+
const closeTimer = React36__default.default.useRef(void 0);
|
|
7003
7065
|
const openNow = () => {
|
|
7004
7066
|
window.clearTimeout(closeTimer.current);
|
|
7005
7067
|
setOpen(true);
|
|
@@ -7008,7 +7070,7 @@ function CollapsedFlyout({ item, trigger }) {
|
|
|
7008
7070
|
window.clearTimeout(closeTimer.current);
|
|
7009
7071
|
closeTimer.current = window.setTimeout(() => setOpen(false), 150);
|
|
7010
7072
|
};
|
|
7011
|
-
|
|
7073
|
+
React36__default.default.useEffect(() => () => window.clearTimeout(closeTimer.current), []);
|
|
7012
7074
|
return /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu2__namespace.Root, { open, onOpenChange: setOpen, modal: false, children: [
|
|
7013
7075
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7014
7076
|
DropdownMenu2__namespace.Trigger,
|
|
@@ -7046,7 +7108,7 @@ function NavItem({
|
|
|
7046
7108
|
depth = 0
|
|
7047
7109
|
}) {
|
|
7048
7110
|
const hasChildren = !!(item.items && item.items.length);
|
|
7049
|
-
const [open, setOpen] =
|
|
7111
|
+
const [open, setOpen] = React36.useState(item.defaultOpen ?? (hasChildren && hasActiveDescendant(item)));
|
|
7050
7112
|
const handleClick = () => {
|
|
7051
7113
|
if (hasChildren && isExpanded) setOpen((o) => !o);
|
|
7052
7114
|
item.onClick?.();
|
|
@@ -7184,7 +7246,7 @@ function Sidebar({
|
|
|
7184
7246
|
}
|
|
7185
7247
|
) });
|
|
7186
7248
|
}
|
|
7187
|
-
var MegaMenuContext =
|
|
7249
|
+
var MegaMenuContext = React36.createContext({ align: "start" });
|
|
7188
7250
|
function MegaMenu({
|
|
7189
7251
|
children,
|
|
7190
7252
|
align = "start",
|
|
@@ -7215,7 +7277,7 @@ function MegaMenu({
|
|
|
7215
7277
|
}
|
|
7216
7278
|
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";
|
|
7217
7279
|
function MegaMenuItem({ label, icon, href, children, className = "" }) {
|
|
7218
|
-
const { align } =
|
|
7280
|
+
const { align } = React36.useContext(MegaMenuContext);
|
|
7219
7281
|
const pos = align === "center" ? "left-1/2 -translate-x-1/2" : align === "end" ? "right-0" : "left-0";
|
|
7220
7282
|
if (!children) {
|
|
7221
7283
|
return /* @__PURE__ */ jsxRuntime.jsx(NavigationMenu__namespace.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs(NavigationMenu__namespace.Link, { href, className: cx(TOP_ITEM, className), children: [
|
|
@@ -7300,8 +7362,8 @@ function MegaMenuLink({ href, icon, description, active, onClick, children, clas
|
|
|
7300
7362
|
function MegaMenuFeatured({ children, className = "" }) {
|
|
7301
7363
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cx("min-w-0 rounded-lg bg-surface-raised border border-border p-4 flex flex-col", className), children });
|
|
7302
7364
|
}
|
|
7303
|
-
var elementsOfType = (children, type) =>
|
|
7304
|
-
(c) =>
|
|
7365
|
+
var elementsOfType = (children, type) => React36__default.default.Children.toArray(children).filter(
|
|
7366
|
+
(c) => React36__default.default.isValidElement(c) && c.type === type
|
|
7305
7367
|
);
|
|
7306
7368
|
var MOBILE_CHEVRON = /* @__PURE__ */ jsxRuntime.jsx(
|
|
7307
7369
|
"svg",
|
|
@@ -7338,9 +7400,9 @@ function MobileLinkRow({ link, onNavigate }) {
|
|
|
7338
7400
|
);
|
|
7339
7401
|
}
|
|
7340
7402
|
function MobilePanel({ panel, onNavigate }) {
|
|
7341
|
-
const nodes =
|
|
7403
|
+
const nodes = React36__default.default.Children.toArray(panel.props.children);
|
|
7342
7404
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-4 px-2 pb-3 pt-1", children: nodes.map((node, i) => {
|
|
7343
|
-
if (!
|
|
7405
|
+
if (!React36__default.default.isValidElement(node)) return null;
|
|
7344
7406
|
const el = node;
|
|
7345
7407
|
if (el.type === MegaMenuSection) {
|
|
7346
7408
|
const { title, children } = el.props;
|
|
@@ -7359,8 +7421,8 @@ function MegaMenuMobile({
|
|
|
7359
7421
|
children,
|
|
7360
7422
|
label
|
|
7361
7423
|
}) {
|
|
7362
|
-
const [open, setOpen] =
|
|
7363
|
-
const [expanded, setExpanded] =
|
|
7424
|
+
const [open, setOpen] = React36.useState(false);
|
|
7425
|
+
const [expanded, setExpanded] = React36.useState(null);
|
|
7364
7426
|
const items = elementsOfType(children, MegaMenuItem);
|
|
7365
7427
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "md:hidden w-full", children: [
|
|
7366
7428
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -7433,17 +7495,17 @@ function AppShell({
|
|
|
7433
7495
|
children,
|
|
7434
7496
|
className = ""
|
|
7435
7497
|
}) {
|
|
7436
|
-
const [expanded, setExpanded] =
|
|
7437
|
-
const [isMobile, setIsMobile] =
|
|
7438
|
-
const [mobileOpen, setMobileOpen] =
|
|
7439
|
-
|
|
7498
|
+
const [expanded, setExpanded] = React36.useState(sidebarDefaultExpanded);
|
|
7499
|
+
const [isMobile, setIsMobile] = React36.useState(false);
|
|
7500
|
+
const [mobileOpen, setMobileOpen] = React36.useState(false);
|
|
7501
|
+
React36.useEffect(() => {
|
|
7440
7502
|
const mq = window.matchMedia("(max-width: 767px)");
|
|
7441
7503
|
const update = (e) => setIsMobile(e.matches);
|
|
7442
7504
|
update(mq);
|
|
7443
7505
|
mq.addEventListener("change", update);
|
|
7444
7506
|
return () => mq.removeEventListener("change", update);
|
|
7445
7507
|
}, []);
|
|
7446
|
-
|
|
7508
|
+
React36.useEffect(() => {
|
|
7447
7509
|
if (!isMobile) setMobileOpen(false);
|
|
7448
7510
|
}, [isMobile]);
|
|
7449
7511
|
const hasSidebar = sidebarSections.length > 0;
|
|
@@ -7570,7 +7632,7 @@ function SecureLayout({
|
|
|
7570
7632
|
className = ""
|
|
7571
7633
|
}) {
|
|
7572
7634
|
const reduced = framerMotion.useReducedMotion();
|
|
7573
|
-
const cbs =
|
|
7635
|
+
const cbs = React36.useRef({ canAccess, onGranted, onDeny });
|
|
7574
7636
|
cbs.current = { canAccess, onGranted, onDeny };
|
|
7575
7637
|
const rolesKey = JSON.stringify(roles);
|
|
7576
7638
|
const requiredRolesKey = JSON.stringify(requiredRoles);
|
|
@@ -7585,10 +7647,10 @@ function SecureLayout({
|
|
|
7585
7647
|
if (requiredPermissions?.length && !has(permissions, requiredPermissions, requireAllPermissions)) return false;
|
|
7586
7648
|
return true;
|
|
7587
7649
|
};
|
|
7588
|
-
const [state, setState] =
|
|
7650
|
+
const [state, setState] = React36.useState(
|
|
7589
7651
|
() => !passesSync() ? "denied" : canAccess ? "checking" : "granted"
|
|
7590
7652
|
);
|
|
7591
|
-
|
|
7653
|
+
React36.useEffect(() => {
|
|
7592
7654
|
let cancelled = false;
|
|
7593
7655
|
const { canAccess: check, onGranted: granted, onDeny: deny } = cbs.current;
|
|
7594
7656
|
const finish = (ok) => {
|
|
@@ -7749,10 +7811,10 @@ function ThemeProvider({
|
|
|
7749
7811
|
className = "",
|
|
7750
7812
|
style
|
|
7751
7813
|
}) {
|
|
7752
|
-
const id =
|
|
7814
|
+
const id = React36__default.default.useId().replace(/:/g, "");
|
|
7753
7815
|
const scopeClass = `geo-th-${id}`;
|
|
7754
|
-
const divRef =
|
|
7755
|
-
|
|
7816
|
+
const divRef = React36.useRef(null);
|
|
7817
|
+
React36.useEffect(() => {
|
|
7756
7818
|
const el = divRef.current;
|
|
7757
7819
|
if (!el) return;
|
|
7758
7820
|
if (colorScheme === "auto") return;
|
|
@@ -7767,8 +7829,8 @@ function ThemeProvider({
|
|
|
7767
7829
|
}
|
|
7768
7830
|
el.classList.toggle("dark", colorScheme === "dark");
|
|
7769
7831
|
}, [colorScheme]);
|
|
7770
|
-
const lightVars =
|
|
7771
|
-
const darkVarStr =
|
|
7832
|
+
const lightVars = React36.useMemo(() => toCssVars(theme), [theme]);
|
|
7833
|
+
const darkVarStr = React36.useMemo(() => {
|
|
7772
7834
|
if (!darkTheme) return "";
|
|
7773
7835
|
const dvars = toCssVars(darkTheme);
|
|
7774
7836
|
if (!Object.keys(dvars).length) return "";
|
|
@@ -7810,7 +7872,7 @@ function NumberInput({
|
|
|
7810
7872
|
readOnly = false,
|
|
7811
7873
|
precision
|
|
7812
7874
|
}) {
|
|
7813
|
-
const errorId =
|
|
7875
|
+
const errorId = React36.useId();
|
|
7814
7876
|
const hasError = errorMessage != null;
|
|
7815
7877
|
const inferredPrecision = precision ?? (Number.isInteger(step) ? 0 : String(step).split(".")[1]?.length ?? 0);
|
|
7816
7878
|
const round = (n) => {
|
|
@@ -7941,8 +8003,8 @@ function Password({
|
|
|
7941
8003
|
showIcon,
|
|
7942
8004
|
hideIcon
|
|
7943
8005
|
}) {
|
|
7944
|
-
const [visible, setVisible] =
|
|
7945
|
-
const errorId =
|
|
8006
|
+
const [visible, setVisible] = React36.useState(false);
|
|
8007
|
+
const errorId = React36.useId();
|
|
7946
8008
|
const hasError = errorMessage != null;
|
|
7947
8009
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7948
8010
|
Field,
|
|
@@ -8042,7 +8104,7 @@ function PasswordStrength({
|
|
|
8042
8104
|
className = "",
|
|
8043
8105
|
style
|
|
8044
8106
|
}) {
|
|
8045
|
-
const { score, label } =
|
|
8107
|
+
const { score, label } = React36.useMemo(() => scorer(value), [scorer, value]);
|
|
8046
8108
|
const showMatch = confirmValue != null && (value.length > 0 || confirmValue.length > 0);
|
|
8047
8109
|
const matches = value.length > 0 && value === confirmValue;
|
|
8048
8110
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx("flex flex-col gap-2", className), style, "aria-live": "polite", children: [
|
|
@@ -8101,8 +8163,8 @@ function RadioTile({
|
|
|
8101
8163
|
errorMessage,
|
|
8102
8164
|
className
|
|
8103
8165
|
}) {
|
|
8104
|
-
const groupId =
|
|
8105
|
-
const errorId =
|
|
8166
|
+
const groupId = React36.useId();
|
|
8167
|
+
const errorId = React36.useId();
|
|
8106
8168
|
const hasError = errorMessage != null;
|
|
8107
8169
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
8108
8170
|
Field,
|
|
@@ -8177,7 +8239,7 @@ function Checkbox({
|
|
|
8177
8239
|
}) {
|
|
8178
8240
|
const isChecked = checked ?? value ?? false;
|
|
8179
8241
|
const labelFirst = labelPosition === "left";
|
|
8180
|
-
const errorId =
|
|
8242
|
+
const errorId = React36.useId();
|
|
8181
8243
|
const hasError = errorMessage != null;
|
|
8182
8244
|
const box = /* @__PURE__ */ jsxRuntime.jsx(
|
|
8183
8245
|
CheckboxPrimitive__namespace.Root,
|
|
@@ -8285,8 +8347,8 @@ function RadioGroup({
|
|
|
8285
8347
|
className,
|
|
8286
8348
|
errorMessage
|
|
8287
8349
|
}) {
|
|
8288
|
-
const errorId =
|
|
8289
|
-
const groupId =
|
|
8350
|
+
const errorId = React36.useId();
|
|
8351
|
+
const groupId = React36.useId();
|
|
8290
8352
|
const hasError = errorMessage != null;
|
|
8291
8353
|
const labelFirst = labelPosition === "left";
|
|
8292
8354
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -8386,11 +8448,11 @@ function Switch({
|
|
|
8386
8448
|
disabled,
|
|
8387
8449
|
errorMessage
|
|
8388
8450
|
}) {
|
|
8389
|
-
const id =
|
|
8390
|
-
const errorId =
|
|
8451
|
+
const id = React36.useId();
|
|
8452
|
+
const errorId = React36.useId();
|
|
8391
8453
|
const hasError = errorMessage != null;
|
|
8392
8454
|
const isControlled = checked !== void 0;
|
|
8393
|
-
const [internal, setInternal] =
|
|
8455
|
+
const [internal, setInternal] = React36.useState(defaultChecked);
|
|
8394
8456
|
const isOn = isControlled ? checked : internal;
|
|
8395
8457
|
const handle = (c) => {
|
|
8396
8458
|
if (!isControlled) setInternal(c);
|
|
@@ -8466,11 +8528,11 @@ function MultiTagRow({
|
|
|
8466
8528
|
labelFor,
|
|
8467
8529
|
onRemove
|
|
8468
8530
|
}) {
|
|
8469
|
-
const wrapRef =
|
|
8470
|
-
const measureRef =
|
|
8471
|
-
const [visibleCount, setVisibleCount] =
|
|
8531
|
+
const wrapRef = React36.useRef(null);
|
|
8532
|
+
const measureRef = React36.useRef(null);
|
|
8533
|
+
const [visibleCount, setVisibleCount] = React36.useState(values.length);
|
|
8472
8534
|
const key = values.map(String).join("|");
|
|
8473
|
-
|
|
8535
|
+
React36.useLayoutEffect(() => {
|
|
8474
8536
|
const wrap = wrapRef.current;
|
|
8475
8537
|
const measure = measureRef.current;
|
|
8476
8538
|
if (!wrap || !measure) return;
|
|
@@ -8562,18 +8624,21 @@ function Dropdown({
|
|
|
8562
8624
|
labelStyle = {},
|
|
8563
8625
|
placeholder,
|
|
8564
8626
|
size = "md",
|
|
8565
|
-
className = ""
|
|
8627
|
+
className = "",
|
|
8628
|
+
container
|
|
8566
8629
|
}) {
|
|
8567
|
-
const
|
|
8568
|
-
const
|
|
8569
|
-
const [
|
|
8570
|
-
const [
|
|
8571
|
-
const
|
|
8630
|
+
const dialogContainer = useDialogContainer();
|
|
8631
|
+
const portalContainer = container ?? dialogContainer ?? void 0;
|
|
8632
|
+
const [open, setOpen] = React36.useState(false);
|
|
8633
|
+
const [selectedItems, setSelectedItems] = React36.useState([]);
|
|
8634
|
+
const [searchTerm, setSearchTerm] = React36.useState("");
|
|
8635
|
+
const [innerItems, setInnerItems] = React36.useState([]);
|
|
8636
|
+
const errorId = React36.useId();
|
|
8572
8637
|
const hasError = errorMessage != null;
|
|
8573
|
-
|
|
8638
|
+
React36.useEffect(() => {
|
|
8574
8639
|
setInnerItems(items);
|
|
8575
8640
|
}, [items]);
|
|
8576
|
-
|
|
8641
|
+
React36.useEffect(() => {
|
|
8577
8642
|
if (isMultiselect && Array.isArray(value)) {
|
|
8578
8643
|
setSelectedItems(value);
|
|
8579
8644
|
}
|
|
@@ -8669,7 +8734,7 @@ function Dropdown({
|
|
|
8669
8734
|
]
|
|
8670
8735
|
}
|
|
8671
8736
|
) }),
|
|
8672
|
-
/* @__PURE__ */ jsxRuntime.jsx(Popover__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8737
|
+
/* @__PURE__ */ jsxRuntime.jsx(Popover__namespace.Portal, { container: portalContainer, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8673
8738
|
Popover__namespace.Content,
|
|
8674
8739
|
{
|
|
8675
8740
|
align: "start",
|
|
@@ -8766,19 +8831,19 @@ function AutoComplete({
|
|
|
8766
8831
|
required,
|
|
8767
8832
|
htmlFor
|
|
8768
8833
|
}) {
|
|
8769
|
-
const errorId =
|
|
8834
|
+
const errorId = React36.useId();
|
|
8770
8835
|
const hasError = errorMessage != null;
|
|
8771
|
-
const [term, setTerm] =
|
|
8772
|
-
const [open, setOpen] =
|
|
8773
|
-
const [asyncItems, setAsyncItems] =
|
|
8774
|
-
const [loading, setLoading] =
|
|
8836
|
+
const [term, setTerm] = React36.useState("");
|
|
8837
|
+
const [open, setOpen] = React36.useState(false);
|
|
8838
|
+
const [asyncItems, setAsyncItems] = React36.useState([]);
|
|
8839
|
+
const [loading, setLoading] = React36.useState(false);
|
|
8775
8840
|
const isAsync = typeof onSearch === "function";
|
|
8776
|
-
const debounceRef =
|
|
8777
|
-
const requestIdRef =
|
|
8841
|
+
const debounceRef = React36.useRef(null);
|
|
8842
|
+
const requestIdRef = React36.useRef(0);
|
|
8778
8843
|
const staticFiltered = isAsync || !items ? [] : term.trim() ? items.filter(
|
|
8779
8844
|
({ key, label: label2 }) => label2.toLowerCase().includes(term.toLowerCase()) || key.toLowerCase().includes(term.toLowerCase())
|
|
8780
8845
|
) : [];
|
|
8781
|
-
|
|
8846
|
+
React36.useEffect(() => {
|
|
8782
8847
|
if (!isAsync) return;
|
|
8783
8848
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
8784
8849
|
if (!term.trim()) {
|
|
@@ -8935,15 +9000,15 @@ function TreeSelect({
|
|
|
8935
9000
|
defaultExpandedKeys = [],
|
|
8936
9001
|
size = "md"
|
|
8937
9002
|
}) {
|
|
8938
|
-
const errorId =
|
|
9003
|
+
const errorId = React36.useId();
|
|
8939
9004
|
const hasError = errorMessage != null;
|
|
8940
|
-
const [open, setOpen] =
|
|
8941
|
-
const [expanded, setExpanded] =
|
|
8942
|
-
const [activeIndex, setActiveIndex] =
|
|
8943
|
-
const listRef =
|
|
8944
|
-
const visible =
|
|
8945
|
-
const didSyncOnOpenRef =
|
|
8946
|
-
|
|
9005
|
+
const [open, setOpen] = React36.useState(false);
|
|
9006
|
+
const [expanded, setExpanded] = React36.useState(() => new Set(defaultExpandedKeys));
|
|
9007
|
+
const [activeIndex, setActiveIndex] = React36.useState(0);
|
|
9008
|
+
const listRef = React36.useRef(null);
|
|
9009
|
+
const visible = React36.useMemo(() => flattenVisible(items, expanded), [items, expanded]);
|
|
9010
|
+
const didSyncOnOpenRef = React36.useRef(false);
|
|
9011
|
+
React36.useEffect(() => {
|
|
8947
9012
|
if (!open) {
|
|
8948
9013
|
didSyncOnOpenRef.current = false;
|
|
8949
9014
|
return;
|
|
@@ -8953,7 +9018,7 @@ function TreeSelect({
|
|
|
8953
9018
|
setActiveIndex(selectedIdx >= 0 ? selectedIdx : 0);
|
|
8954
9019
|
didSyncOnOpenRef.current = true;
|
|
8955
9020
|
}, [open, value]);
|
|
8956
|
-
const selectedNode =
|
|
9021
|
+
const selectedNode = React36.useMemo(
|
|
8957
9022
|
() => value != null ? findNodeByKey(items, value) : null,
|
|
8958
9023
|
[items, value]
|
|
8959
9024
|
);
|
|
@@ -9185,11 +9250,11 @@ function FileInput({
|
|
|
9185
9250
|
required,
|
|
9186
9251
|
icon
|
|
9187
9252
|
}) {
|
|
9188
|
-
const inputRef =
|
|
9189
|
-
const errorId =
|
|
9190
|
-
const [files, setFiles] =
|
|
9191
|
-
const [dragging, setDragging] =
|
|
9192
|
-
const [sizeError, setSizeError] =
|
|
9253
|
+
const inputRef = React36.useRef(null);
|
|
9254
|
+
const errorId = React36.useId();
|
|
9255
|
+
const [files, setFiles] = React36.useState([]);
|
|
9256
|
+
const [dragging, setDragging] = React36.useState(false);
|
|
9257
|
+
const [sizeError, setSizeError] = React36.useState(null);
|
|
9193
9258
|
const effectiveError = errorMessage ?? sizeError ?? void 0;
|
|
9194
9259
|
const openPicker = () => {
|
|
9195
9260
|
if (!disabled) inputRef.current?.click();
|
|
@@ -9380,30 +9445,30 @@ function DatePicker({
|
|
|
9380
9445
|
size = "md",
|
|
9381
9446
|
className = ""
|
|
9382
9447
|
}) {
|
|
9383
|
-
const errorId =
|
|
9448
|
+
const errorId = React36.useId();
|
|
9384
9449
|
const hasError = errorMessage != null;
|
|
9385
|
-
const [open, setOpen] =
|
|
9386
|
-
const [viewMonth, setViewMonth] =
|
|
9387
|
-
const [focusDate, setFocusDate] =
|
|
9388
|
-
const [view, setView] =
|
|
9389
|
-
const gridRef =
|
|
9390
|
-
|
|
9450
|
+
const [open, setOpen] = React36.useState(false);
|
|
9451
|
+
const [viewMonth, setViewMonth] = React36.useState(() => startOfMonth2(value ?? /* @__PURE__ */ new Date()));
|
|
9452
|
+
const [focusDate, setFocusDate] = React36.useState(() => value ?? /* @__PURE__ */ new Date());
|
|
9453
|
+
const [view, setView] = React36.useState("days");
|
|
9454
|
+
const gridRef = React36.useRef(null);
|
|
9455
|
+
React36.useEffect(() => {
|
|
9391
9456
|
if (!open) return;
|
|
9392
9457
|
const target = value ?? /* @__PURE__ */ new Date();
|
|
9393
9458
|
setViewMonth(startOfMonth2(target));
|
|
9394
9459
|
setFocusDate(target);
|
|
9395
9460
|
setView("days");
|
|
9396
9461
|
}, [open, value]);
|
|
9397
|
-
|
|
9462
|
+
React36.useEffect(() => {
|
|
9398
9463
|
if (!open) return;
|
|
9399
9464
|
const cell = gridRef.current?.querySelector(`[data-day="${defaultFormat3(focusDate)}"]`);
|
|
9400
9465
|
cell?.focus();
|
|
9401
9466
|
}, [open, focusDate]);
|
|
9402
|
-
const weekdays =
|
|
9467
|
+
const weekdays = React36.useMemo(() => {
|
|
9403
9468
|
const ordered = WEEKDAY_SHORT.slice(weekStartsOn).concat(WEEKDAY_SHORT.slice(0, weekStartsOn));
|
|
9404
9469
|
return ordered;
|
|
9405
9470
|
}, [weekStartsOn]);
|
|
9406
|
-
const grid =
|
|
9471
|
+
const grid = React36.useMemo(() => buildGrid(viewMonth, weekStartsOn), [viewMonth, weekStartsOn]);
|
|
9407
9472
|
const isDisabled = (d) => {
|
|
9408
9473
|
if (min && d < min) return true;
|
|
9409
9474
|
if (max && d > max) return true;
|
|
@@ -9694,10 +9759,10 @@ function TextArea({
|
|
|
9694
9759
|
style,
|
|
9695
9760
|
inputStyle
|
|
9696
9761
|
}) {
|
|
9697
|
-
const errorId =
|
|
9762
|
+
const errorId = React36.useId();
|
|
9698
9763
|
const hasError = errorMessage != null;
|
|
9699
|
-
const ref =
|
|
9700
|
-
|
|
9764
|
+
const ref = React36.useRef(null);
|
|
9765
|
+
React36.useLayoutEffect(() => {
|
|
9701
9766
|
if (!autoGrow) return;
|
|
9702
9767
|
const el = ref.current;
|
|
9703
9768
|
if (!el) return;
|
|
@@ -9769,14 +9834,14 @@ function Slider({
|
|
|
9769
9834
|
name,
|
|
9770
9835
|
htmlFor
|
|
9771
9836
|
}) {
|
|
9772
|
-
const errorId =
|
|
9837
|
+
const errorId = React36.useId();
|
|
9773
9838
|
const hasError = errorMessage != null;
|
|
9774
9839
|
const isRange = Array.isArray(value ?? defaultValue);
|
|
9775
|
-
const [internal, setInternal] =
|
|
9840
|
+
const [internal, setInternal] = React36.useState(
|
|
9776
9841
|
() => toArray(value) ?? toArray(defaultValue) ?? [min]
|
|
9777
9842
|
);
|
|
9778
9843
|
const current = toArray(value) ?? internal;
|
|
9779
|
-
const [dragging, setDragging] =
|
|
9844
|
+
const [dragging, setDragging] = React36.useState(false);
|
|
9780
9845
|
const emit = (arr) => {
|
|
9781
9846
|
setInternal(arr);
|
|
9782
9847
|
const next = isRange ? [arr[0], arr[1]] : arr[0];
|
|
@@ -9871,11 +9936,11 @@ function TagsInput({
|
|
|
9871
9936
|
validate,
|
|
9872
9937
|
separators = ["Enter", ","]
|
|
9873
9938
|
}) {
|
|
9874
|
-
const errorId =
|
|
9875
|
-
const inputRef =
|
|
9876
|
-
const [internal, setInternal] =
|
|
9877
|
-
const [draft, setDraft] =
|
|
9878
|
-
const [localError, setLocalError] =
|
|
9939
|
+
const errorId = React36.useId();
|
|
9940
|
+
const inputRef = React36.useRef(null);
|
|
9941
|
+
const [internal, setInternal] = React36.useState(defaultValue ?? []);
|
|
9942
|
+
const [draft, setDraft] = React36.useState("");
|
|
9943
|
+
const [localError, setLocalError] = React36.useState(null);
|
|
9879
9944
|
const tags = value ?? internal;
|
|
9880
9945
|
const hasError = errorMessage != null || localError != null;
|
|
9881
9946
|
const errorText = errorMessage ?? localError ?? void 0;
|
|
@@ -10006,9 +10071,9 @@ function OtpInput({
|
|
|
10006
10071
|
className,
|
|
10007
10072
|
groupAfter
|
|
10008
10073
|
}) {
|
|
10009
|
-
const errorId =
|
|
10074
|
+
const errorId = React36.useId();
|
|
10010
10075
|
const hasError = errorMessage != null;
|
|
10011
|
-
const refs =
|
|
10076
|
+
const refs = React36.useRef([]);
|
|
10012
10077
|
const chars = Array.from({ length }, (_, i) => value[i] ?? "");
|
|
10013
10078
|
const pattern = mode === "numeric" ? /[0-9]/ : /[a-zA-Z0-9]/;
|
|
10014
10079
|
const emit = (next) => {
|
|
@@ -10057,7 +10122,7 @@ function OtpInput({
|
|
|
10057
10122
|
emit(valid.join(""));
|
|
10058
10123
|
focusBox(valid.length);
|
|
10059
10124
|
};
|
|
10060
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Field, { className, label, htmlFor, errorId, errorMessage, required, layout, helperText, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap items-center gap-2", role: "group", "aria-label": typeof label === "string" ? label : "One-time code", children: chars.map((char, idx) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10125
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Field, { className, label, htmlFor, errorId, errorMessage, required, layout, helperText, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap items-center gap-2", role: "group", "aria-label": typeof label === "string" ? label : "One-time code", children: chars.map((char, idx) => /* @__PURE__ */ jsxRuntime.jsxs(React36__default.default.Fragment, { children: [
|
|
10061
10126
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10062
10127
|
"input",
|
|
10063
10128
|
{
|
|
@@ -10115,9 +10180,9 @@ function Rating({
|
|
|
10115
10180
|
className,
|
|
10116
10181
|
required
|
|
10117
10182
|
}) {
|
|
10118
|
-
const errorId =
|
|
10119
|
-
const [internal, setInternal] =
|
|
10120
|
-
const [hover, setHover] =
|
|
10183
|
+
const errorId = React36.useId();
|
|
10184
|
+
const [internal, setInternal] = React36.useState(defaultValue);
|
|
10185
|
+
const [hover, setHover] = React36.useState(null);
|
|
10121
10186
|
const current = value ?? internal;
|
|
10122
10187
|
const display2 = hover ?? current;
|
|
10123
10188
|
const interactive = !readOnly && !disabled;
|
|
@@ -10240,9 +10305,9 @@ function TimePicker({
|
|
|
10240
10305
|
required,
|
|
10241
10306
|
style
|
|
10242
10307
|
}) {
|
|
10243
|
-
const errorId =
|
|
10308
|
+
const errorId = React36.useId();
|
|
10244
10309
|
const hasError = errorMessage != null;
|
|
10245
|
-
const [open, setOpen] =
|
|
10310
|
+
const [open, setOpen] = React36.useState(false);
|
|
10246
10311
|
const parsed = parse(value) ?? { h: 0, m: 0, s: 0 };
|
|
10247
10312
|
const update = (next) => {
|
|
10248
10313
|
const merged = { ...parsed, ...next };
|
|
@@ -10367,13 +10432,13 @@ function DateRangePicker({
|
|
|
10367
10432
|
required,
|
|
10368
10433
|
style
|
|
10369
10434
|
}) {
|
|
10370
|
-
const errorId =
|
|
10435
|
+
const errorId = React36.useId();
|
|
10371
10436
|
const hasError = errorMessage != null;
|
|
10372
|
-
const [open, setOpen] =
|
|
10373
|
-
const [leftMonth, setLeftMonth] =
|
|
10374
|
-
const [pendingStart, setPendingStart] =
|
|
10375
|
-
const [hoverDate, setHoverDate] =
|
|
10376
|
-
const weekdays =
|
|
10437
|
+
const [open, setOpen] = React36.useState(false);
|
|
10438
|
+
const [leftMonth, setLeftMonth] = React36.useState(() => startOfMonth3(value.start ?? /* @__PURE__ */ new Date()));
|
|
10439
|
+
const [pendingStart, setPendingStart] = React36.useState(null);
|
|
10440
|
+
const [hoverDate, setHoverDate] = React36.useState(null);
|
|
10441
|
+
const weekdays = React36.useMemo(
|
|
10377
10442
|
() => WEEKDAY.slice(weekStartsOn).concat(WEEKDAY.slice(0, weekStartsOn)),
|
|
10378
10443
|
[weekStartsOn]
|
|
10379
10444
|
);
|
|
@@ -10550,10 +10615,10 @@ function ColorPicker({
|
|
|
10550
10615
|
required,
|
|
10551
10616
|
placeholder = "Pick a colour\u2026"
|
|
10552
10617
|
}) {
|
|
10553
|
-
const errorId =
|
|
10618
|
+
const errorId = React36.useId();
|
|
10554
10619
|
const hasError = errorMessage != null;
|
|
10555
|
-
const [open, setOpen] =
|
|
10556
|
-
const [draft, setDraft] =
|
|
10620
|
+
const [open, setOpen] = React36.useState(false);
|
|
10621
|
+
const [draft, setDraft] = React36.useState(value);
|
|
10557
10622
|
const valid = HEX_RE.test(value);
|
|
10558
10623
|
const pick = (hex) => {
|
|
10559
10624
|
onChange?.(hex);
|
|
@@ -10641,7 +10706,7 @@ function ColorPicker({
|
|
|
10641
10706
|
}
|
|
10642
10707
|
var CUSTOM_EVENT = "oxy-local-storage";
|
|
10643
10708
|
function useLocalStorage(key, initialValue) {
|
|
10644
|
-
const read =
|
|
10709
|
+
const read = React36.useCallback(() => {
|
|
10645
10710
|
if (typeof window === "undefined") return initialValue;
|
|
10646
10711
|
try {
|
|
10647
10712
|
const item = window.localStorage.getItem(key);
|
|
@@ -10650,8 +10715,8 @@ function useLocalStorage(key, initialValue) {
|
|
|
10650
10715
|
return initialValue;
|
|
10651
10716
|
}
|
|
10652
10717
|
}, [key]);
|
|
10653
|
-
const [stored, setStored] =
|
|
10654
|
-
const setValue =
|
|
10718
|
+
const [stored, setStored] = React36.useState(read);
|
|
10719
|
+
const setValue = React36.useCallback((value) => {
|
|
10655
10720
|
setStored((prev) => {
|
|
10656
10721
|
const next = value instanceof Function ? value(prev) : value;
|
|
10657
10722
|
try {
|
|
@@ -10664,7 +10729,7 @@ function useLocalStorage(key, initialValue) {
|
|
|
10664
10729
|
return next;
|
|
10665
10730
|
});
|
|
10666
10731
|
}, [key]);
|
|
10667
|
-
const remove =
|
|
10732
|
+
const remove = React36.useCallback(() => {
|
|
10668
10733
|
try {
|
|
10669
10734
|
if (typeof window !== "undefined") {
|
|
10670
10735
|
window.localStorage.removeItem(key);
|
|
@@ -10674,10 +10739,10 @@ function useLocalStorage(key, initialValue) {
|
|
|
10674
10739
|
}
|
|
10675
10740
|
setStored(initialValue);
|
|
10676
10741
|
}, [key]);
|
|
10677
|
-
|
|
10742
|
+
React36.useEffect(() => {
|
|
10678
10743
|
setStored(read());
|
|
10679
10744
|
}, [key, read]);
|
|
10680
|
-
|
|
10745
|
+
React36.useEffect(() => {
|
|
10681
10746
|
if (typeof window === "undefined") return;
|
|
10682
10747
|
const onStorage = (e) => {
|
|
10683
10748
|
if (e.key === null || e.key === key) setStored(read());
|
|
@@ -10696,8 +10761,8 @@ function useLocalStorage(key, initialValue) {
|
|
|
10696
10761
|
}
|
|
10697
10762
|
function useMediaQuery(query) {
|
|
10698
10763
|
const get = () => typeof window !== "undefined" && typeof window.matchMedia === "function" ? window.matchMedia(query).matches : false;
|
|
10699
|
-
const [matches, setMatches] =
|
|
10700
|
-
|
|
10764
|
+
const [matches, setMatches] = React36.useState(get);
|
|
10765
|
+
React36.useEffect(() => {
|
|
10701
10766
|
if (typeof window === "undefined" || typeof window.matchMedia !== "function") return;
|
|
10702
10767
|
const mql = window.matchMedia(query);
|
|
10703
10768
|
const onChange = () => setMatches(mql.matches);
|
|
@@ -10728,8 +10793,8 @@ function decodeSegment(seg) {
|
|
|
10728
10793
|
}
|
|
10729
10794
|
}
|
|
10730
10795
|
function useJwt(token) {
|
|
10731
|
-
const [, tick] =
|
|
10732
|
-
const decoded =
|
|
10796
|
+
const [, tick] = React36.useState(0);
|
|
10797
|
+
const decoded = React36.useMemo(() => {
|
|
10733
10798
|
if (!token) return { payload: null, header: null, exp: null };
|
|
10734
10799
|
const [h, p] = token.split(".");
|
|
10735
10800
|
const header = decodeSegment(h);
|
|
@@ -10737,7 +10802,7 @@ function useJwt(token) {
|
|
|
10737
10802
|
const exp = payload && typeof payload.exp === "number" ? payload.exp : null;
|
|
10738
10803
|
return { payload, header, exp };
|
|
10739
10804
|
}, [token]);
|
|
10740
|
-
|
|
10805
|
+
React36.useEffect(() => {
|
|
10741
10806
|
if (decoded.exp == null) return;
|
|
10742
10807
|
const ms = decoded.exp * 1e3 - Date.now();
|
|
10743
10808
|
if (ms <= 0) return;
|
|
@@ -10911,13 +10976,13 @@ function SlideShow({
|
|
|
10911
10976
|
style
|
|
10912
10977
|
}) {
|
|
10913
10978
|
const reduced = framerMotion.useReducedMotion();
|
|
10914
|
-
const [index, setIndex] =
|
|
10915
|
-
const [paused, setPaused] =
|
|
10979
|
+
const [index, setIndex] = React36.useState(0);
|
|
10980
|
+
const [paused, setPaused] = React36.useState(false);
|
|
10916
10981
|
const count = slides.length;
|
|
10917
10982
|
const idx = count ? (index % count + count) % count : 0;
|
|
10918
|
-
const go =
|
|
10919
|
-
const timer =
|
|
10920
|
-
|
|
10983
|
+
const go = React36.useCallback((d) => setIndex((i) => i + d), []);
|
|
10984
|
+
const timer = React36.useRef(null);
|
|
10985
|
+
React36.useEffect(() => {
|
|
10921
10986
|
if (!autoPlay || paused || count <= 1) return;
|
|
10922
10987
|
timer.current = setInterval(() => setIndex((i) => i + 1), interval);
|
|
10923
10988
|
return () => {
|
|
@@ -10993,7 +11058,7 @@ function Video({
|
|
|
10993
11058
|
className = "",
|
|
10994
11059
|
style
|
|
10995
11060
|
}) {
|
|
10996
|
-
const [playing, setPlaying] =
|
|
11061
|
+
const [playing, setPlaying] = React36.useState(autoPlay);
|
|
10997
11062
|
const frame = cx("relative w-full overflow-hidden bg-backdrop", framed ? "rounded-2xl border border-border shadow-sm" : "", className);
|
|
10998
11063
|
const ratio = aspect.replace("/", " / ");
|
|
10999
11064
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: frame, style: { aspectRatio: ratio, ...style }, children: embedUrl ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -11048,7 +11113,7 @@ function Parallax({
|
|
|
11048
11113
|
style
|
|
11049
11114
|
}) {
|
|
11050
11115
|
const reduced = framerMotion.useReducedMotion();
|
|
11051
|
-
const ref =
|
|
11116
|
+
const ref = React36.useRef(null);
|
|
11052
11117
|
const { scrollYProgress } = framerMotion.useScroll({ target: ref, offset: ["start end", "end start"] });
|
|
11053
11118
|
const shift = Math.max(0, Math.min(1, speed)) * 100;
|
|
11054
11119
|
const y = framerMotion.useTransform(scrollYProgress, [0, 1], reduced ? ["0%", "0%"] : [`-${shift / 2}%`, `${shift / 2}%`]);
|
|
@@ -11116,7 +11181,7 @@ function Blog({
|
|
|
11116
11181
|
post.tag != null && !post.image && /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(Badge, { tone: "accent", variant: "soft", size: "sm", children: post.tag }) }),
|
|
11117
11182
|
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-base font-semibold leading-snug text-foreground transition-colors group-hover:text-accent", children: post.title }),
|
|
11118
11183
|
post.excerpt != null && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "line-clamp-3 text-sm leading-relaxed text-foreground-secondary", children: post.excerpt }),
|
|
11119
|
-
meta.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-auto flex flex-wrap items-center gap-x-2 gap-y-1 pt-3 text-xs text-foreground-muted", children: meta.map((m, j) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11184
|
+
meta.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-auto flex flex-wrap items-center gap-x-2 gap-y-1 pt-3 text-xs text-foreground-muted", children: meta.map((m, j) => /* @__PURE__ */ jsxRuntime.jsxs(React36__default.default.Fragment, { children: [
|
|
11120
11185
|
j > 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", children: "\xB7" }),
|
|
11121
11186
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: m })
|
|
11122
11187
|
] }, j)) })
|
|
@@ -11245,8 +11310,8 @@ function LeadCapture({
|
|
|
11245
11310
|
className = "",
|
|
11246
11311
|
style
|
|
11247
11312
|
}) {
|
|
11248
|
-
const [email, setEmail] =
|
|
11249
|
-
const [done, setDone] =
|
|
11313
|
+
const [email, setEmail] = React36.useState("");
|
|
11314
|
+
const [done, setDone] = React36.useState(false);
|
|
11250
11315
|
const submit = (e) => {
|
|
11251
11316
|
e.preventDefault();
|
|
11252
11317
|
const value = email.trim();
|