@geomak/ui 6.20.0 → 6.21.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 +557 -232
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +225 -34
- package/dist/index.d.ts +225 -34
- package/dist/index.js +341 -21
- package/dist/index.js.map +1 -1
- package/dist/styles.css +44 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
var chunkOAV4TA4B_cjs = require('./chunk-OAV4TA4B.cjs');
|
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
-
var
|
|
5
|
+
var React26 = require('react');
|
|
6
6
|
var reactDom = require('react-dom');
|
|
7
7
|
var AvatarPrimitive = require('@radix-ui/react-avatar');
|
|
8
|
+
var DropdownMenu = require('@radix-ui/react-dropdown-menu');
|
|
8
9
|
var Dialog = require('@radix-ui/react-dialog');
|
|
9
10
|
var framerMotion = require('framer-motion');
|
|
10
11
|
var TooltipPrimitive = require('@radix-ui/react-tooltip');
|
|
@@ -39,8 +40,9 @@ function _interopNamespace(e) {
|
|
|
39
40
|
return Object.freeze(n);
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
var
|
|
43
|
+
var React26__default = /*#__PURE__*/_interopDefault(React26);
|
|
43
44
|
var AvatarPrimitive__namespace = /*#__PURE__*/_interopNamespace(AvatarPrimitive);
|
|
45
|
+
var DropdownMenu__namespace = /*#__PURE__*/_interopNamespace(DropdownMenu);
|
|
44
46
|
var Dialog__namespace = /*#__PURE__*/_interopNamespace(Dialog);
|
|
45
47
|
var TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespace(TooltipPrimitive);
|
|
46
48
|
var TabsPrimitive__namespace = /*#__PURE__*/_interopNamespace(TabsPrimitive);
|
|
@@ -214,8 +216,8 @@ Icon.Copy = Copy;
|
|
|
214
216
|
Icon.CircleStack = CircleStack;
|
|
215
217
|
var icons_default = Icon;
|
|
216
218
|
function Portal({ children, target }) {
|
|
217
|
-
const [resolved, setResolved] =
|
|
218
|
-
|
|
219
|
+
const [resolved, setResolved] = React26.useState(null);
|
|
220
|
+
React26.useEffect(() => {
|
|
219
221
|
if (target === null) {
|
|
220
222
|
setResolved(null);
|
|
221
223
|
return;
|
|
@@ -649,7 +651,7 @@ function IconButton({
|
|
|
649
651
|
className = "",
|
|
650
652
|
style
|
|
651
653
|
}) {
|
|
652
|
-
const colorScheme =
|
|
654
|
+
const colorScheme = React26.useMemo(() => {
|
|
653
655
|
if (type === "primary") {
|
|
654
656
|
return "bg-accent text-accent-fg hover:bg-accent-hover";
|
|
655
657
|
}
|
|
@@ -728,7 +730,7 @@ var SIZE_CLASSES = {
|
|
|
728
730
|
md: "h-9 px-4 text-sm gap-1.5 rounded-lg",
|
|
729
731
|
lg: "h-11 px-5 text-sm gap-2 rounded-xl"
|
|
730
732
|
};
|
|
731
|
-
var Button =
|
|
733
|
+
var Button = React26__default.default.forwardRef(function Button2({
|
|
732
734
|
content,
|
|
733
735
|
variant = "primary",
|
|
734
736
|
size = "md",
|
|
@@ -785,6 +787,80 @@ var Button = React24__default.default.forwardRef(function Button2({
|
|
|
785
787
|
});
|
|
786
788
|
Button.displayName = "Button";
|
|
787
789
|
var Button_default = Button;
|
|
790
|
+
var Chevron = () => /* @__PURE__ */ jsxRuntime.jsx(
|
|
791
|
+
"svg",
|
|
792
|
+
{
|
|
793
|
+
viewBox: "0 0 24 24",
|
|
794
|
+
fill: "none",
|
|
795
|
+
stroke: "currentColor",
|
|
796
|
+
strokeWidth: 2,
|
|
797
|
+
"aria-hidden": "true",
|
|
798
|
+
className: "h-4 w-4 transition-transform duration-150 group-data-[state=open]:rotate-180",
|
|
799
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 9l6 6 6-6" })
|
|
800
|
+
}
|
|
801
|
+
);
|
|
802
|
+
function MenuButton({
|
|
803
|
+
label,
|
|
804
|
+
items,
|
|
805
|
+
variant = "secondary",
|
|
806
|
+
size = "md",
|
|
807
|
+
icon,
|
|
808
|
+
hideChevron = false,
|
|
809
|
+
disabled,
|
|
810
|
+
align = "start",
|
|
811
|
+
side = "bottom",
|
|
812
|
+
className = ""
|
|
813
|
+
}) {
|
|
814
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu__namespace.Root, { children: [
|
|
815
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenu__namespace.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
816
|
+
Button_default,
|
|
817
|
+
{
|
|
818
|
+
variant,
|
|
819
|
+
size,
|
|
820
|
+
icon,
|
|
821
|
+
disabled,
|
|
822
|
+
className: `group ${className}`.trim(),
|
|
823
|
+
content: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "inline-flex items-center gap-1.5", children: [
|
|
824
|
+
label,
|
|
825
|
+
!hideChevron && /* @__PURE__ */ jsxRuntime.jsx(Chevron, {})
|
|
826
|
+
] })
|
|
827
|
+
}
|
|
828
|
+
) }),
|
|
829
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenu__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
830
|
+
DropdownMenu__namespace.Content,
|
|
831
|
+
{
|
|
832
|
+
align,
|
|
833
|
+
side,
|
|
834
|
+
sideOffset: 6,
|
|
835
|
+
collisionPadding: 8,
|
|
836
|
+
className: [
|
|
837
|
+
"z-[400] min-w-[10rem] rounded-lg border border-border bg-surface p-1 shadow-lg",
|
|
838
|
+
"data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",
|
|
839
|
+
"data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95"
|
|
840
|
+
].join(" "),
|
|
841
|
+
children: items.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(React26__default.default.Fragment, { children: [
|
|
842
|
+
item.separatorBefore && /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu__namespace.Separator, { className: "my-1 h-px bg-border" }),
|
|
843
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
844
|
+
DropdownMenu__namespace.Item,
|
|
845
|
+
{
|
|
846
|
+
disabled: item.disabled,
|
|
847
|
+
onSelect: () => item.onSelect?.(),
|
|
848
|
+
className: [
|
|
849
|
+
"flex items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm outline-none cursor-pointer select-none transition-colors",
|
|
850
|
+
"data-[disabled]:opacity-50 data-[disabled]:pointer-events-none",
|
|
851
|
+
item.danger ? "text-status-error data-[highlighted]:bg-status-error/10" : "text-foreground data-[highlighted]:bg-surface-raised"
|
|
852
|
+
].join(" "),
|
|
853
|
+
children: [
|
|
854
|
+
item.icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex h-4 w-4 flex-shrink-0 items-center justify-center", children: item.icon }),
|
|
855
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-1 truncate", children: item.label })
|
|
856
|
+
]
|
|
857
|
+
}
|
|
858
|
+
)
|
|
859
|
+
] }, item.key))
|
|
860
|
+
}
|
|
861
|
+
) })
|
|
862
|
+
] });
|
|
863
|
+
}
|
|
788
864
|
var SIZE_MAP = {
|
|
789
865
|
sm: 400,
|
|
790
866
|
md: 600,
|
|
@@ -1005,9 +1081,9 @@ function Tooltip({
|
|
|
1005
1081
|
] }) });
|
|
1006
1082
|
}
|
|
1007
1083
|
var TooltipProvider = TooltipPrimitive__namespace.Provider;
|
|
1008
|
-
var TabsContext =
|
|
1084
|
+
var TabsContext = React26.createContext(null);
|
|
1009
1085
|
function useTabsContext() {
|
|
1010
|
-
const ctx =
|
|
1086
|
+
const ctx = React26.useContext(TabsContext);
|
|
1011
1087
|
if (!ctx) throw new Error("Tabs.List / Tabs.Trigger / Tabs.Panel must be rendered inside <Tabs>.");
|
|
1012
1088
|
return ctx;
|
|
1013
1089
|
}
|
|
@@ -1029,26 +1105,26 @@ function Tabs({
|
|
|
1029
1105
|
children
|
|
1030
1106
|
}) {
|
|
1031
1107
|
const isControlled = value !== void 0;
|
|
1032
|
-
const [internal, setInternal] =
|
|
1108
|
+
const [internal, setInternal] = React26.useState(defaultValue);
|
|
1033
1109
|
const current = isControlled ? value : internal;
|
|
1034
1110
|
const reduced = !!framerMotion.useReducedMotion();
|
|
1035
|
-
const indicatorId =
|
|
1036
|
-
const select =
|
|
1111
|
+
const indicatorId = React26.useId();
|
|
1112
|
+
const select = React26.useCallback((next) => {
|
|
1037
1113
|
if (!isControlled) setInternal(next);
|
|
1038
1114
|
onValueChange?.(next);
|
|
1039
1115
|
}, [isControlled, onValueChange]);
|
|
1040
|
-
const registry =
|
|
1041
|
-
const orderRef =
|
|
1042
|
-
const [, bump] =
|
|
1043
|
-
const registerTab =
|
|
1116
|
+
const registry = React26.useRef(/* @__PURE__ */ new Map());
|
|
1117
|
+
const orderRef = React26.useRef(0);
|
|
1118
|
+
const [, bump] = React26.useState(0);
|
|
1119
|
+
const registerTab = React26.useCallback((val, meta) => {
|
|
1044
1120
|
const existing = registry.current.get(val);
|
|
1045
1121
|
registry.current.set(val, { ...meta, order: existing?.order ?? orderRef.current++ });
|
|
1046
1122
|
if (!existing) bump((v) => v + 1);
|
|
1047
1123
|
}, []);
|
|
1048
|
-
const unregisterTab =
|
|
1124
|
+
const unregisterTab = React26.useCallback((val) => {
|
|
1049
1125
|
if (registry.current.delete(val)) bump((v) => v + 1);
|
|
1050
1126
|
}, []);
|
|
1051
|
-
const getTabs =
|
|
1127
|
+
const getTabs = React26.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 })), []);
|
|
1052
1128
|
return /* @__PURE__ */ jsxRuntime.jsx(TabsContext.Provider, { value: { value: current, variant, size, orientation, indicatorId, reduced, select, registerTab, unregisterTab, getTabs }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1053
1129
|
TabsPrimitive__namespace.Root,
|
|
1054
1130
|
{
|
|
@@ -1068,10 +1144,10 @@ function Tabs({
|
|
|
1068
1144
|
function TabsList({ children, "aria-label": ariaLabel, className = "" }) {
|
|
1069
1145
|
const { variant, orientation, reduced, value } = useTabsContext();
|
|
1070
1146
|
const horizontal = orientation === "horizontal";
|
|
1071
|
-
const scrollRef =
|
|
1072
|
-
const [edges, setEdges] =
|
|
1147
|
+
const scrollRef = React26.useRef(null);
|
|
1148
|
+
const [edges, setEdges] = React26.useState({ start: false, end: false });
|
|
1073
1149
|
const scrollable = variant !== "segmented";
|
|
1074
|
-
|
|
1150
|
+
React26.useLayoutEffect(() => {
|
|
1075
1151
|
const el = scrollRef.current;
|
|
1076
1152
|
if (!el || !scrollable) return;
|
|
1077
1153
|
const update = () => {
|
|
@@ -1096,13 +1172,13 @@ function TabsList({ children, "aria-label": ariaLabel, className = "" }) {
|
|
|
1096
1172
|
ro.disconnect();
|
|
1097
1173
|
};
|
|
1098
1174
|
}, [horizontal, scrollable, children]);
|
|
1099
|
-
const nudge =
|
|
1175
|
+
const nudge = React26.useCallback((dir) => {
|
|
1100
1176
|
const el = scrollRef.current;
|
|
1101
1177
|
if (!el) return;
|
|
1102
1178
|
const amount = (horizontal ? el.clientWidth : el.clientHeight) * 0.7 * dir;
|
|
1103
1179
|
el.scrollBy({ [horizontal ? "left" : "top"]: amount, behavior: reduced ? "auto" : "smooth" });
|
|
1104
1180
|
}, [horizontal, reduced]);
|
|
1105
|
-
|
|
1181
|
+
React26.useLayoutEffect(() => {
|
|
1106
1182
|
const el = scrollRef.current;
|
|
1107
1183
|
if (!el || !scrollable) return;
|
|
1108
1184
|
const active = el.querySelector("[role=tab][data-state=active]");
|
|
@@ -1128,7 +1204,7 @@ function TabsList({ children, "aria-label": ariaLabel, className = "" }) {
|
|
|
1128
1204
|
const scrollClass = scrollable ? horizontal ? "overflow-x-auto overflow-y-hidden hidden-scrollbar" : "overflow-y-auto overflow-x-hidden hidden-scrollbar" : "";
|
|
1129
1205
|
const overflowing = scrollable && (edges.start || edges.end);
|
|
1130
1206
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ["relative flex min-w-0 gap-1", horizontal ? "flex-row items-stretch" : "flex-col items-stretch", className].filter(Boolean).join(" "), children: [
|
|
1131
|
-
scrollable && edges.start && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1207
|
+
scrollable && edges.start && /* @__PURE__ */ jsxRuntime.jsx(Chevron2, { side: "start", orientation, onClick: () => nudge(-1) }),
|
|
1132
1208
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1133
1209
|
TabsPrimitive__namespace.List,
|
|
1134
1210
|
{
|
|
@@ -1139,11 +1215,11 @@ function TabsList({ children, "aria-label": ariaLabel, className = "" }) {
|
|
|
1139
1215
|
children
|
|
1140
1216
|
}
|
|
1141
1217
|
),
|
|
1142
|
-
scrollable && edges.end && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1218
|
+
scrollable && edges.end && /* @__PURE__ */ jsxRuntime.jsx(Chevron2, { side: "end", orientation, onClick: () => nudge(1) }),
|
|
1143
1219
|
overflowing && /* @__PURE__ */ jsxRuntime.jsx(OverflowMenu, {})
|
|
1144
1220
|
] });
|
|
1145
1221
|
}
|
|
1146
|
-
function
|
|
1222
|
+
function Chevron2({ side, orientation, onClick }) {
|
|
1147
1223
|
const horizontal = orientation === "horizontal";
|
|
1148
1224
|
const rotate = horizontal ? side === "start" ? "rotate-180" : "" : side === "start" ? "-rotate-90" : "rotate-90";
|
|
1149
1225
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1160,9 +1236,9 @@ function Chevron({ side, orientation, onClick }) {
|
|
|
1160
1236
|
function OverflowMenu() {
|
|
1161
1237
|
const { getTabs, value, select, orientation } = useTabsContext();
|
|
1162
1238
|
const horizontal = orientation === "horizontal";
|
|
1163
|
-
const [open, setOpen] =
|
|
1164
|
-
const wrapRef =
|
|
1165
|
-
const timer =
|
|
1239
|
+
const [open, setOpen] = React26.useState(false);
|
|
1240
|
+
const wrapRef = React26.useRef(null);
|
|
1241
|
+
const timer = React26.useRef(null);
|
|
1166
1242
|
const openNow = () => {
|
|
1167
1243
|
if (timer.current) clearTimeout(timer.current);
|
|
1168
1244
|
setOpen(true);
|
|
@@ -1170,7 +1246,7 @@ function OverflowMenu() {
|
|
|
1170
1246
|
const closeSoon = () => {
|
|
1171
1247
|
timer.current = setTimeout(() => setOpen(false), 160);
|
|
1172
1248
|
};
|
|
1173
|
-
|
|
1249
|
+
React26.useLayoutEffect(() => {
|
|
1174
1250
|
if (!open) return;
|
|
1175
1251
|
const onDoc = (e) => {
|
|
1176
1252
|
if (wrapRef.current && !wrapRef.current.contains(e.target)) setOpen(false);
|
|
@@ -1251,7 +1327,7 @@ function TabsTrigger({ value, icon, badge, closeable, onClose, disabled, classNa
|
|
|
1251
1327
|
const isActive = active === value;
|
|
1252
1328
|
const horizontal = orientation === "horizontal";
|
|
1253
1329
|
const sz = SIZE[size];
|
|
1254
|
-
|
|
1330
|
+
React26.useLayoutEffect(() => {
|
|
1255
1331
|
registerTab(value, { label: children, icon, disabled });
|
|
1256
1332
|
return () => unregisterTab(value);
|
|
1257
1333
|
}, [value, children, icon, disabled, registerTab, unregisterTab]);
|
|
@@ -1449,7 +1525,7 @@ function Tree({
|
|
|
1449
1525
|
item.key
|
|
1450
1526
|
)) });
|
|
1451
1527
|
}
|
|
1452
|
-
var AccordionCtx =
|
|
1528
|
+
var AccordionCtx = React26.createContext({ variant: "separated" });
|
|
1453
1529
|
function Accordion2({
|
|
1454
1530
|
children,
|
|
1455
1531
|
type = "single",
|
|
@@ -1495,7 +1571,7 @@ function Accordion2({
|
|
|
1495
1571
|
}
|
|
1496
1572
|
);
|
|
1497
1573
|
}
|
|
1498
|
-
var
|
|
1574
|
+
var Chevron3 = /* @__PURE__ */ jsxRuntime.jsx(
|
|
1499
1575
|
"svg",
|
|
1500
1576
|
{
|
|
1501
1577
|
viewBox: "0 0 24 24",
|
|
@@ -1508,7 +1584,7 @@ var Chevron2 = /* @__PURE__ */ jsxRuntime.jsx(
|
|
|
1508
1584
|
}
|
|
1509
1585
|
);
|
|
1510
1586
|
function AccordionItem({ value, title, icon, children, disabled, className = "" }) {
|
|
1511
|
-
const { variant } =
|
|
1587
|
+
const { variant } = React26.useContext(AccordionCtx);
|
|
1512
1588
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1513
1589
|
AccordionPrimitive__namespace.Item,
|
|
1514
1590
|
{
|
|
@@ -1527,7 +1603,7 @@ function AccordionItem({ value, title, icon, children, disabled, className = ""
|
|
|
1527
1603
|
children: [
|
|
1528
1604
|
icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex h-5 w-5 flex-shrink-0 items-center justify-center text-foreground-muted group-data-[state=open]/acc:text-accent", children: icon }),
|
|
1529
1605
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-1 min-w-0", children: title }),
|
|
1530
|
-
|
|
1606
|
+
Chevron3
|
|
1531
1607
|
]
|
|
1532
1608
|
}
|
|
1533
1609
|
) }),
|
|
@@ -1567,7 +1643,7 @@ function Breadcrumbs({
|
|
|
1567
1643
|
className = "",
|
|
1568
1644
|
style
|
|
1569
1645
|
}) {
|
|
1570
|
-
const [expanded, setExpanded] =
|
|
1646
|
+
const [expanded, setExpanded] = React26.useState(false);
|
|
1571
1647
|
const shouldCollapse = maxItems > 0 && items.length > maxItems && !expanded;
|
|
1572
1648
|
const visible = [];
|
|
1573
1649
|
if (shouldCollapse) {
|
|
@@ -1697,6 +1773,156 @@ function Badge({
|
|
|
1697
1773
|
!hidden && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute -top-1 -right-1 flex", children: indicator })
|
|
1698
1774
|
] });
|
|
1699
1775
|
}
|
|
1776
|
+
var SIZES = {
|
|
1777
|
+
sm: { box: "h-7 w-7 text-xs", center: 14, title: "text-xs", desc: "text-[11px]" },
|
|
1778
|
+
md: { box: "h-9 w-9 text-sm", center: 18, title: "text-sm", desc: "text-xs" }
|
|
1779
|
+
};
|
|
1780
|
+
var Check = () => /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 3, "aria-hidden": "true", className: "h-1/2 w-1/2 animate-check-pop", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M20 6L9 17l-5-5" }) });
|
|
1781
|
+
var Cross = () => /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 3, "aria-hidden": "true", className: "h-1/2 w-1/2", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M18 6 6 18M6 6l12 12" }) });
|
|
1782
|
+
var Spinner = () => /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": "true", className: "h-1/2 w-1/2 animate-spin", children: /* @__PURE__ */ jsxRuntime.jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M4.755 10.059a7.5 7.5 0 0112.548-3.364l1.903 1.903h-3.183a.75.75 0 100 1.5h4.992a.75.75 0 00.75-.75V4.356a.75.75 0 00-1.5 0v3.18l-1.9-1.9A9 9 0 003.306 9.67a.75.75 0 101.45.388zm15.408 3.352a.75.75 0 00-.919.53 7.5 7.5 0 01-12.548 3.364l-1.902-1.903h3.183a.75.75 0 000-1.5H2.984a.75.75 0 00-.75.75v4.992a.75.75 0 001.5 0v-3.18l1.9 1.9a9 9 0 0015.059-4.035.75.75 0 00-.53-.918z" }) });
|
|
1783
|
+
function Indicator({ state, index, step, sizeKey }) {
|
|
1784
|
+
const reduced = framerMotion.useReducedMotion();
|
|
1785
|
+
const s = SIZES[sizeKey];
|
|
1786
|
+
const base = `relative z-10 flex flex-shrink-0 items-center justify-center rounded-full font-semibold transition-colors ${s.box}`;
|
|
1787
|
+
const tone = {
|
|
1788
|
+
completed: "bg-accent text-accent-fg",
|
|
1789
|
+
active: "border-2 border-accent bg-surface text-accent",
|
|
1790
|
+
loading: "border-2 border-accent bg-surface text-accent",
|
|
1791
|
+
error: "bg-status-error text-white",
|
|
1792
|
+
pending: "border border-border bg-surface text-foreground-muted"
|
|
1793
|
+
};
|
|
1794
|
+
const content = step.icon ?? (state === "completed" ? /* @__PURE__ */ jsxRuntime.jsx(Check, {}) : state === "error" ? /* @__PURE__ */ jsxRuntime.jsx(Cross, {}) : state === "loading" ? /* @__PURE__ */ jsxRuntime.jsx(Spinner, {}) : index + 1);
|
|
1795
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1796
|
+
framerMotion.motion.span,
|
|
1797
|
+
{
|
|
1798
|
+
className: `${base} ${tone[state]}`,
|
|
1799
|
+
initial: false,
|
|
1800
|
+
animate: reduced ? void 0 : { scale: state === "active" || state === "loading" ? 1.06 : 1 },
|
|
1801
|
+
transition: { type: "spring", stiffness: 320, damping: 24 },
|
|
1802
|
+
"aria-current": state === "active" || state === "loading" ? "step" : void 0,
|
|
1803
|
+
children: content
|
|
1804
|
+
}
|
|
1805
|
+
);
|
|
1806
|
+
}
|
|
1807
|
+
function VConnector({ filled, reduced }) {
|
|
1808
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "relative my-1 w-0.5 flex-1 bg-border", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1809
|
+
framerMotion.motion.span,
|
|
1810
|
+
{
|
|
1811
|
+
className: "absolute inset-0 bg-accent",
|
|
1812
|
+
style: { originY: 0 },
|
|
1813
|
+
initial: false,
|
|
1814
|
+
animate: { scaleY: filled ? 1 : 0 },
|
|
1815
|
+
transition: reduced ? { duration: 0 } : { duration: 0.35, ease: [0.16, 1, 0.3, 1] }
|
|
1816
|
+
}
|
|
1817
|
+
) });
|
|
1818
|
+
}
|
|
1819
|
+
function Stepper({
|
|
1820
|
+
steps,
|
|
1821
|
+
current,
|
|
1822
|
+
status = "active",
|
|
1823
|
+
orientation = "horizontal",
|
|
1824
|
+
responsive = true,
|
|
1825
|
+
onStepClick,
|
|
1826
|
+
size = "md",
|
|
1827
|
+
className = ""
|
|
1828
|
+
}) {
|
|
1829
|
+
const reduced = framerMotion.useReducedMotion();
|
|
1830
|
+
const [forcedVertical, setForcedVertical] = React26.useState(false);
|
|
1831
|
+
React26.useEffect(() => {
|
|
1832
|
+
if (!responsive || orientation === "vertical") return;
|
|
1833
|
+
if (typeof window === "undefined" || typeof window.matchMedia !== "function") return;
|
|
1834
|
+
const mq = window.matchMedia("(max-width: 767px)");
|
|
1835
|
+
const apply = (e) => setForcedVertical(e.matches);
|
|
1836
|
+
apply(mq);
|
|
1837
|
+
const handler = (e) => apply(e);
|
|
1838
|
+
mq.addEventListener("change", handler);
|
|
1839
|
+
return () => mq.removeEventListener("change", handler);
|
|
1840
|
+
}, [responsive, orientation]);
|
|
1841
|
+
const vertical = orientation === "vertical" || forcedVertical;
|
|
1842
|
+
const s = SIZES[size];
|
|
1843
|
+
const stateOf = (i) => i < current ? "completed" : i === current ? status : "pending";
|
|
1844
|
+
const Label = ({ step, state, align }) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: align === "center" ? "mt-2 text-center" : "pt-0.5", children: [
|
|
1845
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: `font-medium leading-tight ${s.title} ${state === "pending" ? "text-foreground-muted" : "text-foreground"}`, children: step.title }),
|
|
1846
|
+
step.description && /* @__PURE__ */ jsxRuntime.jsx("div", { className: `mt-0.5 leading-snug text-foreground-muted ${s.desc}`, children: step.description })
|
|
1847
|
+
] });
|
|
1848
|
+
const clickable = (i) => Boolean(onStepClick) && i <= current;
|
|
1849
|
+
const stepButton = (i, node) => clickable(i) ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: () => onStepClick?.(i), className: "rounded-md text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-accent", children: node }) : node;
|
|
1850
|
+
if (vertical) {
|
|
1851
|
+
return /* @__PURE__ */ jsxRuntime.jsx("ol", { className: ["flex flex-col", className].filter(Boolean).join(" "), children: steps.map((step, i) => {
|
|
1852
|
+
const state = stateOf(i);
|
|
1853
|
+
const last = i === steps.length - 1;
|
|
1854
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "flex gap-3", children: [
|
|
1855
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center self-stretch", children: [
|
|
1856
|
+
stepButton(i, /* @__PURE__ */ jsxRuntime.jsx(Indicator, { state, index: i, step, sizeKey: size })),
|
|
1857
|
+
!last && /* @__PURE__ */ jsxRuntime.jsx(VConnector, { filled: i < current, reduced })
|
|
1858
|
+
] }),
|
|
1859
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: last ? "" : "pb-6", children: stepButton(i, /* @__PURE__ */ jsxRuntime.jsx(Label, { step, state, align: "left" })) })
|
|
1860
|
+
] }, step.key);
|
|
1861
|
+
}) });
|
|
1862
|
+
}
|
|
1863
|
+
return /* @__PURE__ */ jsxRuntime.jsx("ol", { className: ["flex items-start", className].filter(Boolean).join(" "), children: steps.map((step, i) => {
|
|
1864
|
+
const state = stateOf(i);
|
|
1865
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "relative flex flex-1 flex-col items-center last:flex-none", children: [
|
|
1866
|
+
i > 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute right-1/2 h-0.5 w-full bg-border", style: { top: s.center - 1 }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1867
|
+
framerMotion.motion.span,
|
|
1868
|
+
{
|
|
1869
|
+
className: "absolute inset-0 bg-accent",
|
|
1870
|
+
style: { originX: 0 },
|
|
1871
|
+
initial: false,
|
|
1872
|
+
animate: { scaleX: i <= current ? 1 : 0 },
|
|
1873
|
+
transition: reduced ? { duration: 0 } : { duration: 0.35, ease: [0.16, 1, 0.3, 1] }
|
|
1874
|
+
}
|
|
1875
|
+
) }),
|
|
1876
|
+
stepButton(i, /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center", children: [
|
|
1877
|
+
/* @__PURE__ */ jsxRuntime.jsx(Indicator, { state, index: i, step, sizeKey: size }),
|
|
1878
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label, { step, state, align: "center" })
|
|
1879
|
+
] }))
|
|
1880
|
+
] }, step.key);
|
|
1881
|
+
}) });
|
|
1882
|
+
}
|
|
1883
|
+
var Check2 = () => /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 3, "aria-hidden": "true", className: "h-3 w-3", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M20 6L9 17l-5-5" }) });
|
|
1884
|
+
var Cross2 = () => /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 3, "aria-hidden": "true", className: "h-3 w-3", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M18 6 6 18M6 6l12 12" }) });
|
|
1885
|
+
var NODE = {
|
|
1886
|
+
complete: "bg-accent text-accent-fg border-accent",
|
|
1887
|
+
current: "bg-surface text-accent border-accent",
|
|
1888
|
+
upcoming: "bg-surface text-transparent border-border",
|
|
1889
|
+
error: "bg-status-error text-white border-status-error"
|
|
1890
|
+
};
|
|
1891
|
+
function Timeline({ events, current, className = "" }) {
|
|
1892
|
+
const statusOf = (e, i) => {
|
|
1893
|
+
if (e.status) return e.status;
|
|
1894
|
+
if (current == null) return "upcoming";
|
|
1895
|
+
return i < current ? "complete" : i === current ? "current" : "upcoming";
|
|
1896
|
+
};
|
|
1897
|
+
return /* @__PURE__ */ jsxRuntime.jsx("ol", { className: ["flex flex-col", className].filter(Boolean).join(" "), children: events.map((event, i) => {
|
|
1898
|
+
const status = statusOf(event, i);
|
|
1899
|
+
const last = i === events.length - 1;
|
|
1900
|
+
const railFilled = status === "complete";
|
|
1901
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "flex gap-3", children: [
|
|
1902
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center self-stretch", children: [
|
|
1903
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1904
|
+
"span",
|
|
1905
|
+
{
|
|
1906
|
+
className: [
|
|
1907
|
+
"relative z-10 flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-full border-2 transition-colors",
|
|
1908
|
+
NODE[status]
|
|
1909
|
+
].join(" "),
|
|
1910
|
+
children: [
|
|
1911
|
+
status === "current" && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute inset-0 animate-breathe rounded-full ring-2 ring-accent/40", "aria-hidden": "true" }),
|
|
1912
|
+
event.icon ?? (status === "complete" ? /* @__PURE__ */ jsxRuntime.jsx(Check2, {}) : status === "error" ? /* @__PURE__ */ jsxRuntime.jsx(Cross2, {}) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: `h-2 w-2 rounded-full ${status === "current" ? "bg-accent" : "bg-border"}` }))
|
|
1913
|
+
]
|
|
1914
|
+
}
|
|
1915
|
+
),
|
|
1916
|
+
!last && /* @__PURE__ */ jsxRuntime.jsx("span", { className: `my-1 w-0.5 flex-1 ${railFilled ? "bg-accent" : "bg-border"}` })
|
|
1917
|
+
] }),
|
|
1918
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: last ? "pb-0" : "pb-6", children: [
|
|
1919
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: `text-sm font-medium leading-tight ${status === "upcoming" ? "text-foreground-muted" : "text-foreground"}`, children: event.title }),
|
|
1920
|
+
event.description && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-0.5 text-xs leading-snug text-foreground-secondary", children: event.description }),
|
|
1921
|
+
event.timestamp && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 text-[11px] uppercase tracking-wide text-foreground-muted", children: event.timestamp })
|
|
1922
|
+
] })
|
|
1923
|
+
] }, event.key);
|
|
1924
|
+
}) });
|
|
1925
|
+
}
|
|
1700
1926
|
var SIZE3 = {
|
|
1701
1927
|
sm: "h-5 min-w-[20px] px-1.5 text-[11px]",
|
|
1702
1928
|
md: "h-6 min-w-[24px] px-2 text-xs"
|
|
@@ -1711,7 +1937,7 @@ function Kbd({
|
|
|
1711
1937
|
style
|
|
1712
1938
|
}) {
|
|
1713
1939
|
if (keys && keys.length > 0) {
|
|
1714
|
-
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: ["inline-flex items-center gap-1", className].filter(Boolean).join(" "), style, children: keys.map((k, i) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1940
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: ["inline-flex items-center gap-1", className].filter(Boolean).join(" "), style, children: keys.map((k, i) => /* @__PURE__ */ jsxRuntime.jsxs(React26__default.default.Fragment, { children: [
|
|
1715
1941
|
i > 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground-muted text-xs select-none", children: separator }),
|
|
1716
1942
|
/* @__PURE__ */ jsxRuntime.jsx("kbd", { className: [cap, SIZE3[size]].join(" "), children: k })
|
|
1717
1943
|
] }, `${k}-${i}`)) });
|
|
@@ -1802,13 +2028,13 @@ function FlatCarousel({
|
|
|
1802
2028
|
className = "",
|
|
1803
2029
|
style
|
|
1804
2030
|
}) {
|
|
1805
|
-
const scrollerRef =
|
|
1806
|
-
const slides =
|
|
1807
|
-
const [active, setActive] =
|
|
1808
|
-
const [atStart, setAtStart] =
|
|
1809
|
-
const [atEnd, setAtEnd] =
|
|
2031
|
+
const scrollerRef = React26.useRef(null);
|
|
2032
|
+
const slides = React26__default.default.Children.toArray(children);
|
|
2033
|
+
const [active, setActive] = React26.useState(0);
|
|
2034
|
+
const [atStart, setAtStart] = React26.useState(true);
|
|
2035
|
+
const [atEnd, setAtEnd] = React26.useState(false);
|
|
1810
2036
|
const width = typeof itemWidth === "number" ? `${itemWidth}px` : itemWidth;
|
|
1811
|
-
const update =
|
|
2037
|
+
const update = React26.useCallback(() => {
|
|
1812
2038
|
const el = scrollerRef.current;
|
|
1813
2039
|
if (!el) return;
|
|
1814
2040
|
setAtStart(el.scrollLeft <= 1);
|
|
@@ -1817,7 +2043,7 @@ function FlatCarousel({
|
|
|
1817
2043
|
const slideW = first ? first.getBoundingClientRect().width + gap : el.clientWidth;
|
|
1818
2044
|
setActive(Math.round(el.scrollLeft / slideW));
|
|
1819
2045
|
}, [gap]);
|
|
1820
|
-
|
|
2046
|
+
React26.useEffect(() => {
|
|
1821
2047
|
update();
|
|
1822
2048
|
const el = scrollerRef.current;
|
|
1823
2049
|
if (!el) return;
|
|
@@ -1858,9 +2084,9 @@ function RotatingCarousel({
|
|
|
1858
2084
|
className = "",
|
|
1859
2085
|
style
|
|
1860
2086
|
}) {
|
|
1861
|
-
const slides =
|
|
2087
|
+
const slides = React26__default.default.Children.toArray(children);
|
|
1862
2088
|
const count = slides.length;
|
|
1863
|
-
const [active, setActive] =
|
|
2089
|
+
const [active, setActive] = React26.useState(0);
|
|
1864
2090
|
const reduced = framerMotion.useReducedMotion();
|
|
1865
2091
|
const wrap = (n) => count > 0 ? (n % count + count) % count : 0;
|
|
1866
2092
|
const idx = wrap(active);
|
|
@@ -2010,7 +2236,7 @@ function FAB({
|
|
|
2010
2236
|
className = "",
|
|
2011
2237
|
style
|
|
2012
2238
|
}) {
|
|
2013
|
-
const [open, setOpen] =
|
|
2239
|
+
const [open, setOpen] = React26.useState(false);
|
|
2014
2240
|
const reduced = framerMotion.useReducedMotion();
|
|
2015
2241
|
const hasDial = !!actions && actions.length > 0;
|
|
2016
2242
|
const bottom = position.startsWith("bottom");
|
|
@@ -2112,8 +2338,8 @@ function PopConfirm({
|
|
|
2112
2338
|
onOpenChange,
|
|
2113
2339
|
className = ""
|
|
2114
2340
|
}) {
|
|
2115
|
-
const [uncontrolledOpen, setUncontrolledOpen] =
|
|
2116
|
-
const [loading, setLoading] =
|
|
2341
|
+
const [uncontrolledOpen, setUncontrolledOpen] = React26.useState(false);
|
|
2342
|
+
const [loading, setLoading] = React26.useState(false);
|
|
2117
2343
|
const isOpen = open ?? uncontrolledOpen;
|
|
2118
2344
|
const setOpen = (next) => {
|
|
2119
2345
|
onOpenChange?.(next);
|
|
@@ -2209,16 +2435,16 @@ function Calendar2({
|
|
|
2209
2435
|
className = "",
|
|
2210
2436
|
style
|
|
2211
2437
|
}) {
|
|
2212
|
-
const today =
|
|
2213
|
-
const [internalMonth, setInternalMonth] =
|
|
2438
|
+
const today = React26.useMemo(() => startOfDay(/* @__PURE__ */ new Date()), []);
|
|
2439
|
+
const [internalMonth, setInternalMonth] = React26.useState(() => month ?? defaultMonth ?? value ?? today);
|
|
2214
2440
|
const visible = month ?? internalMonth;
|
|
2215
2441
|
const setMonth = (next) => {
|
|
2216
2442
|
onMonthChange?.(next);
|
|
2217
2443
|
if (month === void 0) setInternalMonth(next);
|
|
2218
2444
|
};
|
|
2219
|
-
const grid =
|
|
2220
|
-
const weekdays =
|
|
2221
|
-
const eventsByDay =
|
|
2445
|
+
const grid = React26.useMemo(() => buildGrid(visible, weekStartsOn), [visible, weekStartsOn]);
|
|
2446
|
+
const weekdays = React26.useMemo(() => Array.from({ length: 7 }, (_, i) => WEEKDAYS[(i + weekStartsOn) % 7]), [weekStartsOn]);
|
|
2447
|
+
const eventsByDay = React26.useMemo(() => {
|
|
2222
2448
|
const map = /* @__PURE__ */ new Map();
|
|
2223
2449
|
for (const ev of events ?? []) {
|
|
2224
2450
|
const key = startOfDay(ev.date).toDateString();
|
|
@@ -2351,7 +2577,7 @@ function EmptyCart({
|
|
|
2351
2577
|
);
|
|
2352
2578
|
}
|
|
2353
2579
|
var defaultFormat = (v) => `${v < 0 ? "-" : ""}$${Math.abs(v).toFixed(2)}`;
|
|
2354
|
-
var
|
|
2580
|
+
var Stepper2 = ({
|
|
2355
2581
|
quantity,
|
|
2356
2582
|
max,
|
|
2357
2583
|
onChange
|
|
@@ -2384,7 +2610,7 @@ function Cart({
|
|
|
2384
2610
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "truncate text-sm font-medium text-foreground", children: it.name }),
|
|
2385
2611
|
it.meta && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "truncate text-xs text-foreground-muted mt-0.5", children: it.meta }),
|
|
2386
2612
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-1.5 flex items-center gap-3", children: [
|
|
2387
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2613
|
+
/* @__PURE__ */ jsxRuntime.jsx(Stepper2, { quantity: it.quantity, max: it.max, onChange: (q) => onQuantityChange?.(it.id, Math.max(1, q)) }),
|
|
2388
2614
|
onRemove && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2389
2615
|
"button",
|
|
2390
2616
|
{
|
|
@@ -2425,17 +2651,17 @@ function Cart({
|
|
|
2425
2651
|
] })
|
|
2426
2652
|
] });
|
|
2427
2653
|
}
|
|
2428
|
-
var CartContext =
|
|
2654
|
+
var CartContext = React26.createContext(null);
|
|
2429
2655
|
var clampQty = (qty, max) => {
|
|
2430
2656
|
const lower = Math.max(1, Math.round(qty));
|
|
2431
2657
|
return max != null ? Math.min(lower, max) : lower;
|
|
2432
2658
|
};
|
|
2433
2659
|
function CartProvider({ children, initialItems = [], onChange }) {
|
|
2434
|
-
const [items, setItems] =
|
|
2435
|
-
|
|
2660
|
+
const [items, setItems] = React26.useState(initialItems);
|
|
2661
|
+
React26.useEffect(() => {
|
|
2436
2662
|
onChange?.(items);
|
|
2437
2663
|
}, [items]);
|
|
2438
|
-
const addToCart =
|
|
2664
|
+
const addToCart = React26.useCallback((item, quantity) => {
|
|
2439
2665
|
const addQty = quantity ?? item.quantity ?? 1;
|
|
2440
2666
|
setItems((prev) => {
|
|
2441
2667
|
const existing = prev.find((it) => it.id === item.id);
|
|
@@ -2448,29 +2674,29 @@ function CartProvider({ children, initialItems = [], onChange }) {
|
|
|
2448
2674
|
return [...prev, { ...rest, quantity: clampQty(addQty, item.max) }];
|
|
2449
2675
|
});
|
|
2450
2676
|
}, []);
|
|
2451
|
-
const removeFromCart =
|
|
2677
|
+
const removeFromCart = React26.useCallback((id) => {
|
|
2452
2678
|
setItems((prev) => prev.filter((it) => it.id !== id));
|
|
2453
2679
|
}, []);
|
|
2454
|
-
const updateQuantity =
|
|
2680
|
+
const updateQuantity = React26.useCallback((id, quantity) => {
|
|
2455
2681
|
setItems(
|
|
2456
2682
|
(prev) => prev.map((it) => it.id === id ? { ...it, quantity: clampQty(quantity, it.max) } : it)
|
|
2457
2683
|
);
|
|
2458
2684
|
}, []);
|
|
2459
|
-
const clearCart =
|
|
2460
|
-
const isInCart =
|
|
2461
|
-
const getItemCount =
|
|
2462
|
-
const getCartTotal =
|
|
2685
|
+
const clearCart = React26.useCallback(() => setItems([]), []);
|
|
2686
|
+
const isInCart = React26.useCallback((id) => items.some((it) => it.id === id), [items]);
|
|
2687
|
+
const getItemCount = React26.useCallback(() => items.reduce((sum, it) => sum + it.quantity, 0), [items]);
|
|
2688
|
+
const getCartTotal = React26.useCallback(
|
|
2463
2689
|
() => items.reduce((sum, it) => sum + it.price * it.quantity, 0),
|
|
2464
2690
|
[items]
|
|
2465
2691
|
);
|
|
2466
|
-
const value =
|
|
2692
|
+
const value = React26.useMemo(
|
|
2467
2693
|
() => ({ items, addToCart, removeFromCart, updateQuantity, clearCart, isInCart, getItemCount, getCartTotal }),
|
|
2468
2694
|
[items, addToCart, removeFromCart, updateQuantity, clearCart, isInCart, getItemCount, getCartTotal]
|
|
2469
2695
|
);
|
|
2470
2696
|
return /* @__PURE__ */ jsxRuntime.jsx(CartContext.Provider, { value, children });
|
|
2471
2697
|
}
|
|
2472
2698
|
function useCart() {
|
|
2473
|
-
const ctx =
|
|
2699
|
+
const ctx = React26.useContext(CartContext);
|
|
2474
2700
|
if (!ctx) {
|
|
2475
2701
|
throw new Error("useCart must be used within a <CartProvider>.");
|
|
2476
2702
|
}
|
|
@@ -2804,11 +3030,11 @@ function buildBindings(store, name, kind, snap) {
|
|
|
2804
3030
|
|
|
2805
3031
|
// src/form/useForm.ts
|
|
2806
3032
|
function useForm(options = {}) {
|
|
2807
|
-
const ref =
|
|
3033
|
+
const ref = React26.useRef(null);
|
|
2808
3034
|
if (ref.current === null) ref.current = new FormStore(options);
|
|
2809
3035
|
const store = ref.current;
|
|
2810
|
-
|
|
2811
|
-
const make =
|
|
3036
|
+
React26.useSyncExternalStore(store.subscribe, store.getRootSnapshot, store.getRootSnapshot);
|
|
3037
|
+
const make = React26.useCallback(
|
|
2812
3038
|
(kind) => (name, rules) => {
|
|
2813
3039
|
if (rules !== void 0) store.setRule(name, rules);
|
|
2814
3040
|
return buildBindings(store, name, kind, store.getFieldSnapshot(name));
|
|
@@ -2837,9 +3063,9 @@ function useForm(options = {}) {
|
|
|
2837
3063
|
fieldTarget: make("target")
|
|
2838
3064
|
};
|
|
2839
3065
|
}
|
|
2840
|
-
var FormContext =
|
|
3066
|
+
var FormContext = React26.createContext(null);
|
|
2841
3067
|
function useFormStore() {
|
|
2842
|
-
const store =
|
|
3068
|
+
const store = React26.useContext(FormContext);
|
|
2843
3069
|
if (!store) {
|
|
2844
3070
|
throw new Error("useFormStore must be used within a <Form>. Did you forget to wrap your fields?");
|
|
2845
3071
|
}
|
|
@@ -2853,8 +3079,8 @@ function Form({
|
|
|
2853
3079
|
children,
|
|
2854
3080
|
...rest
|
|
2855
3081
|
}) {
|
|
2856
|
-
const ref =
|
|
2857
|
-
const bypass =
|
|
3082
|
+
const ref = React26.useRef(null);
|
|
3083
|
+
const bypass = React26.useRef(false);
|
|
2858
3084
|
const handleSubmit = async (e) => {
|
|
2859
3085
|
if (bypass.current) {
|
|
2860
3086
|
bypass.current = false;
|
|
@@ -2906,12 +3132,12 @@ function useFormField(name, options = {}) {
|
|
|
2906
3132
|
const store = useFormStore();
|
|
2907
3133
|
const { kind = "value", rules } = options;
|
|
2908
3134
|
if (rules !== void 0 && store.getRule(name) !== rules) store.setRule(name, rules);
|
|
2909
|
-
|
|
3135
|
+
React26.useEffect(() => {
|
|
2910
3136
|
return () => {
|
|
2911
3137
|
if (rules !== void 0) store.removeRule(name);
|
|
2912
3138
|
};
|
|
2913
3139
|
}, [store, name]);
|
|
2914
|
-
const snap =
|
|
3140
|
+
const snap = React26.useSyncExternalStore(
|
|
2915
3141
|
store.subscribe,
|
|
2916
3142
|
() => store.getFieldSnapshot(name)
|
|
2917
3143
|
);
|
|
@@ -2923,7 +3149,7 @@ function FormField({ name, kind, rules, children }) {
|
|
|
2923
3149
|
}
|
|
2924
3150
|
function useFieldArray(name) {
|
|
2925
3151
|
const store = useFormStore();
|
|
2926
|
-
|
|
3152
|
+
React26.useSyncExternalStore(store.subscribe, store.getRootSnapshot, store.getRootSnapshot);
|
|
2927
3153
|
const arr = store.getValue(name) ?? [];
|
|
2928
3154
|
const keys = store.getKeys(name);
|
|
2929
3155
|
return {
|
|
@@ -3084,7 +3310,7 @@ function TextInput({
|
|
|
3084
3310
|
suffix,
|
|
3085
3311
|
id
|
|
3086
3312
|
}) {
|
|
3087
|
-
const errorId =
|
|
3313
|
+
const errorId = React26.useId();
|
|
3088
3314
|
const hasError = errorMessage != null;
|
|
3089
3315
|
const hasAdornment = prefix != null || suffix != null;
|
|
3090
3316
|
const inputId = htmlFor ?? id;
|
|
@@ -3245,7 +3471,7 @@ function CreditCardForm({
|
|
|
3245
3471
|
className = "",
|
|
3246
3472
|
style
|
|
3247
3473
|
}) {
|
|
3248
|
-
const initial =
|
|
3474
|
+
const initial = React26.useRef({
|
|
3249
3475
|
number: formatCardNumber(defaultValue?.number ?? ""),
|
|
3250
3476
|
name: defaultValue?.name ?? "",
|
|
3251
3477
|
expiry: formatExpiry(defaultValue?.expiry ?? ""),
|
|
@@ -3254,7 +3480,7 @@ function CreditCardForm({
|
|
|
3254
3480
|
const form = useForm({ initialValues: initial });
|
|
3255
3481
|
const numberStr = String(form.values.number ?? "");
|
|
3256
3482
|
const brand = detectBrand(numberStr);
|
|
3257
|
-
|
|
3483
|
+
React26.useEffect(() => {
|
|
3258
3484
|
onChange?.(toCard(form.values));
|
|
3259
3485
|
}, [form.values.number, form.values.name, form.values.expiry, form.values.cvv]);
|
|
3260
3486
|
const numberBind = form.fieldNative("number", {
|
|
@@ -3377,7 +3603,7 @@ function Checkout({
|
|
|
3377
3603
|
] })
|
|
3378
3604
|
] });
|
|
3379
3605
|
}
|
|
3380
|
-
var NotificationContext =
|
|
3606
|
+
var NotificationContext = React26.createContext({
|
|
3381
3607
|
open: () => void 0,
|
|
3382
3608
|
close: () => void 0
|
|
3383
3609
|
});
|
|
@@ -3435,26 +3661,26 @@ function NotificationItem({
|
|
|
3435
3661
|
onClose,
|
|
3436
3662
|
reduced
|
|
3437
3663
|
}) {
|
|
3438
|
-
const [paused, setPaused] =
|
|
3664
|
+
const [paused, setPaused] = React26.useState(false);
|
|
3439
3665
|
const duration = n.duration ?? 4e3;
|
|
3440
3666
|
const isAutoDismissing = isFinite(duration) && duration > 0;
|
|
3441
3667
|
const showProgress = !reduced && isAutoDismissing;
|
|
3442
|
-
const timerRef =
|
|
3443
|
-
const startTimeRef =
|
|
3444
|
-
const remainingRef =
|
|
3445
|
-
const clearTimer =
|
|
3668
|
+
const timerRef = React26.useRef(null);
|
|
3669
|
+
const startTimeRef = React26.useRef(0);
|
|
3670
|
+
const remainingRef = React26.useRef(duration);
|
|
3671
|
+
const clearTimer = React26.useCallback(() => {
|
|
3446
3672
|
if (timerRef.current !== null) {
|
|
3447
3673
|
clearTimeout(timerRef.current);
|
|
3448
3674
|
timerRef.current = null;
|
|
3449
3675
|
}
|
|
3450
3676
|
}, []);
|
|
3451
|
-
const scheduleDismiss =
|
|
3677
|
+
const scheduleDismiss = React26.useCallback((ms) => {
|
|
3452
3678
|
clearTimer();
|
|
3453
3679
|
if (!isAutoDismissing) return;
|
|
3454
3680
|
startTimeRef.current = Date.now();
|
|
3455
3681
|
timerRef.current = setTimeout(() => onClose(n.id), ms);
|
|
3456
3682
|
}, [clearTimer, isAutoDismissing, n.id, onClose]);
|
|
3457
|
-
|
|
3683
|
+
React26.useEffect(() => {
|
|
3458
3684
|
if (paused || !isAutoDismissing) return;
|
|
3459
3685
|
scheduleDismiss(remainingRef.current);
|
|
3460
3686
|
return clearTimer;
|
|
@@ -3537,15 +3763,15 @@ function NotificationProvider({
|
|
|
3537
3763
|
children,
|
|
3538
3764
|
position = "top-right"
|
|
3539
3765
|
}) {
|
|
3540
|
-
const [notifications, setNotifications] =
|
|
3766
|
+
const [notifications, setNotifications] = React26.useState([]);
|
|
3541
3767
|
const reduced = framerMotion.useReducedMotion();
|
|
3542
|
-
const open =
|
|
3768
|
+
const open = React26.useCallback((payload) => {
|
|
3543
3769
|
setNotifications((prev) => [
|
|
3544
3770
|
...prev,
|
|
3545
3771
|
{ duration: 4e3, ...payload, id: Date.now() + Math.random() }
|
|
3546
3772
|
]);
|
|
3547
3773
|
}, []);
|
|
3548
|
-
const close =
|
|
3774
|
+
const close = React26.useCallback((id) => {
|
|
3549
3775
|
setNotifications((prev) => prev.filter((n) => n.id !== id));
|
|
3550
3776
|
}, []);
|
|
3551
3777
|
return /* @__PURE__ */ jsxRuntime.jsxs(NotificationContext.Provider, { value: { open, close }, children: [
|
|
@@ -3574,7 +3800,7 @@ function NotificationProvider({
|
|
|
3574
3800
|
] });
|
|
3575
3801
|
}
|
|
3576
3802
|
function useNotification() {
|
|
3577
|
-
const { open } =
|
|
3803
|
+
const { open } = React26.useContext(NotificationContext);
|
|
3578
3804
|
return {
|
|
3579
3805
|
info: (props) => open({ type: "info", ...props }),
|
|
3580
3806
|
success: (props) => open({ type: "success", ...props }),
|
|
@@ -3691,10 +3917,10 @@ function FadingBase({
|
|
|
3691
3917
|
isMounted = false,
|
|
3692
3918
|
children
|
|
3693
3919
|
}) {
|
|
3694
|
-
const [shouldRender, setShouldRender] =
|
|
3695
|
-
const [visible, setVisible] =
|
|
3696
|
-
const timerRef =
|
|
3697
|
-
|
|
3920
|
+
const [shouldRender, setShouldRender] = React26.useState(isMounted);
|
|
3921
|
+
const [visible, setVisible] = React26.useState(false);
|
|
3922
|
+
const timerRef = React26.useRef(null);
|
|
3923
|
+
React26.useEffect(() => {
|
|
3698
3924
|
if (isMounted) {
|
|
3699
3925
|
setShouldRender(true);
|
|
3700
3926
|
const rafId = requestAnimationFrame(() => setVisible(true));
|
|
@@ -3792,8 +4018,8 @@ function ScalableContainer({
|
|
|
3792
4018
|
togglePosition = "top-right",
|
|
3793
4019
|
className = ""
|
|
3794
4020
|
}) {
|
|
3795
|
-
const containerRef =
|
|
3796
|
-
const [internalScaled, setInternalScaled] =
|
|
4021
|
+
const containerRef = React26.useRef(null);
|
|
4022
|
+
const [internalScaled, setInternalScaled] = React26.useState(false);
|
|
3797
4023
|
const isScaled = expanded ?? internalScaled;
|
|
3798
4024
|
const reduced = framerMotion.useReducedMotion();
|
|
3799
4025
|
const onToggle = () => {
|
|
@@ -3931,17 +4157,17 @@ function CatalogGrid({ items, buttonText, onOpen, className = "" }) {
|
|
|
3931
4157
|
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)) });
|
|
3932
4158
|
}
|
|
3933
4159
|
function CatalogCarousel({ items, buttonText, onOpen, className = "" }) {
|
|
3934
|
-
const [activeIndex, setActiveIndex] =
|
|
3935
|
-
const [indexPool, setIndexPool] =
|
|
3936
|
-
const cardRefs =
|
|
3937
|
-
const getIndexes =
|
|
4160
|
+
const [activeIndex, setActiveIndex] = React26.useState(0);
|
|
4161
|
+
const [indexPool, setIndexPool] = React26.useState([]);
|
|
4162
|
+
const cardRefs = React26.useRef([]);
|
|
4163
|
+
const getIndexes = React26.useMemo(() => {
|
|
3938
4164
|
let nextIndex = activeIndex + 1;
|
|
3939
4165
|
let previousIndex = activeIndex - 1;
|
|
3940
4166
|
if (activeIndex === 0) previousIndex = items.length - 1;
|
|
3941
4167
|
if (activeIndex === items.length - 1) nextIndex = 0;
|
|
3942
4168
|
return { previousIndex, nextIndex };
|
|
3943
4169
|
}, [activeIndex, items.length]);
|
|
3944
|
-
|
|
4170
|
+
React26.useEffect(() => {
|
|
3945
4171
|
const { nextIndex, previousIndex } = getIndexes;
|
|
3946
4172
|
let indexes = [previousIndex, activeIndex, nextIndex];
|
|
3947
4173
|
if (activeIndex !== 0 && activeIndex !== items.length - 1) {
|
|
@@ -4114,8 +4340,8 @@ function writeDismissed(key) {
|
|
|
4114
4340
|
}
|
|
4115
4341
|
}
|
|
4116
4342
|
function useTargetBbox(ref) {
|
|
4117
|
-
const [bbox, setBbox] =
|
|
4118
|
-
|
|
4343
|
+
const [bbox, setBbox] = React26.useState(null);
|
|
4344
|
+
React26.useLayoutEffect(() => {
|
|
4119
4345
|
const el = ref?.current;
|
|
4120
4346
|
if (!el) {
|
|
4121
4347
|
setBbox(null);
|
|
@@ -4145,7 +4371,7 @@ function tooltipStyleFor(bbox, placement) {
|
|
|
4145
4371
|
return { left: bbox.left + bbox.width / 2, top: bbox.top - TOOLTIP_GAP, transform: "translate(-50%, -100%)", width: TOOLTIP_WIDTH };
|
|
4146
4372
|
}
|
|
4147
4373
|
function useFocusTrap(containerRef, active) {
|
|
4148
|
-
|
|
4374
|
+
React26.useEffect(() => {
|
|
4149
4375
|
if (!active) return;
|
|
4150
4376
|
const el = containerRef.current;
|
|
4151
4377
|
if (!el) return;
|
|
@@ -4184,16 +4410,16 @@ function Wizard({
|
|
|
4184
4410
|
onComplete,
|
|
4185
4411
|
onSkip
|
|
4186
4412
|
}) {
|
|
4187
|
-
const tooltipRef =
|
|
4188
|
-
const tooltipTitleId =
|
|
4189
|
-
const tooltipBodyId =
|
|
4413
|
+
const tooltipRef = React26.useRef(null);
|
|
4414
|
+
const tooltipTitleId = React26.useId();
|
|
4415
|
+
const tooltipBodyId = React26.useId();
|
|
4190
4416
|
const reduced = framerMotion.useReducedMotion();
|
|
4191
|
-
const [open, setOpen] =
|
|
4192
|
-
const [activeIndex, setActiveIndex] =
|
|
4417
|
+
const [open, setOpen] = React26.useState(() => steps.length > 0 && !readDismissed(storageKey));
|
|
4418
|
+
const [activeIndex, setActiveIndex] = React26.useState(0);
|
|
4193
4419
|
const step = steps[activeIndex];
|
|
4194
4420
|
const bbox = useTargetBbox(step?.stepRef);
|
|
4195
4421
|
useFocusTrap(tooltipRef, open);
|
|
4196
|
-
|
|
4422
|
+
React26.useEffect(() => {
|
|
4197
4423
|
if (!open || !dismissible) return;
|
|
4198
4424
|
const onKey = (e) => {
|
|
4199
4425
|
if (e.key === "Escape") {
|
|
@@ -4204,12 +4430,12 @@ function Wizard({
|
|
|
4204
4430
|
document.addEventListener("keydown", onKey);
|
|
4205
4431
|
return () => document.removeEventListener("keydown", onKey);
|
|
4206
4432
|
}, [open, dismissible]);
|
|
4207
|
-
const handleSkip =
|
|
4433
|
+
const handleSkip = React26.useCallback(() => {
|
|
4208
4434
|
writeDismissed(storageKey);
|
|
4209
4435
|
setOpen(false);
|
|
4210
4436
|
onSkip?.();
|
|
4211
4437
|
}, [storageKey, onSkip]);
|
|
4212
|
-
const handleComplete =
|
|
4438
|
+
const handleComplete = React26.useCallback(() => {
|
|
4213
4439
|
writeDismissed(storageKey);
|
|
4214
4440
|
setOpen(false);
|
|
4215
4441
|
onComplete?.();
|
|
@@ -4352,7 +4578,7 @@ function Wizard({
|
|
|
4352
4578
|
] });
|
|
4353
4579
|
}
|
|
4354
4580
|
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" }) });
|
|
4355
|
-
var SearchInput =
|
|
4581
|
+
var SearchInput = React26__default.default.forwardRef(function SearchInput2({ value, onChange, disabled, label, htmlFor, placeholder, name, inputStyle, style, layout = "vertical", size = "md", icon, helperText, className }, ref) {
|
|
4356
4582
|
return /* @__PURE__ */ jsxRuntime.jsx(Field, { className, label, htmlFor, layout, helperText, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4357
4583
|
"div",
|
|
4358
4584
|
{
|
|
@@ -4406,11 +4632,11 @@ function MultiTagRow({
|
|
|
4406
4632
|
labelFor,
|
|
4407
4633
|
onRemove
|
|
4408
4634
|
}) {
|
|
4409
|
-
const wrapRef =
|
|
4410
|
-
const measureRef =
|
|
4411
|
-
const [visibleCount, setVisibleCount] =
|
|
4635
|
+
const wrapRef = React26.useRef(null);
|
|
4636
|
+
const measureRef = React26.useRef(null);
|
|
4637
|
+
const [visibleCount, setVisibleCount] = React26.useState(values.length);
|
|
4412
4638
|
const key = values.map(String).join("|");
|
|
4413
|
-
|
|
4639
|
+
React26.useLayoutEffect(() => {
|
|
4414
4640
|
const wrap = wrapRef.current;
|
|
4415
4641
|
const measure = measureRef.current;
|
|
4416
4642
|
if (!wrap || !measure) return;
|
|
@@ -4504,16 +4730,16 @@ function Dropdown({
|
|
|
4504
4730
|
size = "md",
|
|
4505
4731
|
className = ""
|
|
4506
4732
|
}) {
|
|
4507
|
-
const [open, setOpen] =
|
|
4508
|
-
const [selectedItems, setSelectedItems] =
|
|
4509
|
-
const [searchTerm, setSearchTerm] =
|
|
4510
|
-
const [innerItems, setInnerItems] =
|
|
4511
|
-
const errorId =
|
|
4733
|
+
const [open, setOpen] = React26.useState(false);
|
|
4734
|
+
const [selectedItems, setSelectedItems] = React26.useState([]);
|
|
4735
|
+
const [searchTerm, setSearchTerm] = React26.useState("");
|
|
4736
|
+
const [innerItems, setInnerItems] = React26.useState([]);
|
|
4737
|
+
const errorId = React26.useId();
|
|
4512
4738
|
const hasError = errorMessage != null;
|
|
4513
|
-
|
|
4739
|
+
React26.useEffect(() => {
|
|
4514
4740
|
setInnerItems(items);
|
|
4515
4741
|
}, [items]);
|
|
4516
|
-
|
|
4742
|
+
React26.useEffect(() => {
|
|
4517
4743
|
if (isMultiselect && Array.isArray(value)) {
|
|
4518
4744
|
setSelectedItems(value);
|
|
4519
4745
|
}
|
|
@@ -4838,7 +5064,7 @@ function TableBody({
|
|
|
4838
5064
|
expandRow,
|
|
4839
5065
|
getRowKey
|
|
4840
5066
|
}) {
|
|
4841
|
-
const [expanded, setExpanded] =
|
|
5067
|
+
const [expanded, setExpanded] = React26.useState(() => /* @__PURE__ */ new Set());
|
|
4842
5068
|
const reduced = framerMotion.useReducedMotion();
|
|
4843
5069
|
const toggleRow = (rowKey) => {
|
|
4844
5070
|
setExpanded((prev) => {
|
|
@@ -4853,7 +5079,7 @@ function TableBody({
|
|
|
4853
5079
|
return /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: rows.map((row, i) => {
|
|
4854
5080
|
const rowKey = getRowKey(row, i);
|
|
4855
5081
|
const isExpanded = expanded.has(rowKey);
|
|
4856
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5082
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(React26__default.default.Fragment, { children: [
|
|
4857
5083
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4858
5084
|
"tr",
|
|
4859
5085
|
{
|
|
@@ -4909,9 +5135,9 @@ function Pagination({
|
|
|
4909
5135
|
const matchedOption = picker.find(
|
|
4910
5136
|
(o) => o.label === options.perPage || o.value === options.perPage
|
|
4911
5137
|
);
|
|
4912
|
-
const [perPageKey, setPerPageKey] =
|
|
5138
|
+
const [perPageKey, setPerPageKey] = React26.useState(() => matchedOption?.key ?? picker[0]?.key);
|
|
4913
5139
|
const displayPerPageKey = serverSide ? matchedOption?.key ?? perPageKey : perPageKey;
|
|
4914
|
-
|
|
5140
|
+
React26.useEffect(() => {
|
|
4915
5141
|
if (serverSide && options.perPage != null) {
|
|
4916
5142
|
const next = picker.find((o) => o.label === options.perPage || o.value === options.perPage);
|
|
4917
5143
|
if (next) setPerPageKey(next.key);
|
|
@@ -4975,14 +5201,14 @@ function Table({
|
|
|
4975
5201
|
className = "",
|
|
4976
5202
|
style
|
|
4977
5203
|
}) {
|
|
4978
|
-
const searchRef =
|
|
4979
|
-
const [searchTerm, setSearchTerm] =
|
|
4980
|
-
const [perPage, setPerPage] =
|
|
5204
|
+
const searchRef = React26.useRef(null);
|
|
5205
|
+
const [searchTerm, setSearchTerm] = React26.useState("");
|
|
5206
|
+
const [perPage, setPerPage] = React26.useState(
|
|
4981
5207
|
typeof pagination.perPage === "number" ? pagination.perPage : 15
|
|
4982
5208
|
);
|
|
4983
|
-
const [activePage, setActivePage] =
|
|
5209
|
+
const [activePage, setActivePage] = React26.useState(0);
|
|
4984
5210
|
const isServerSide = !!(pagination.enabled && pagination.serverSide);
|
|
4985
|
-
const filteredRows =
|
|
5211
|
+
const filteredRows = React26.useMemo(() => {
|
|
4986
5212
|
if (isServerSide || !searchTerm) return rows;
|
|
4987
5213
|
const term = searchTerm.toLowerCase();
|
|
4988
5214
|
return rows.filter(
|
|
@@ -4991,29 +5217,29 @@ function Table({
|
|
|
4991
5217
|
)
|
|
4992
5218
|
);
|
|
4993
5219
|
}, [rows, searchTerm, isServerSide]);
|
|
4994
|
-
const datasets =
|
|
5220
|
+
const datasets = React26.useMemo(() => {
|
|
4995
5221
|
if (isServerSide) return [rows];
|
|
4996
5222
|
return createDatasets(filteredRows, pagination.enabled ? perPage : null);
|
|
4997
5223
|
}, [filteredRows, perPage, pagination.enabled, isServerSide, rows]);
|
|
4998
|
-
const MAX_PAGE =
|
|
5224
|
+
const MAX_PAGE = React26.useMemo(() => {
|
|
4999
5225
|
if (isServerSide && typeof pagination.maxPage === "number") return Math.max(0, pagination.maxPage);
|
|
5000
5226
|
if (isServerSide && typeof pagination.totalCount === "number")
|
|
5001
5227
|
return Math.max(0, Math.ceil(pagination.totalCount / perPage) - 1);
|
|
5002
5228
|
return datasets.length ? datasets.length - 1 : 0;
|
|
5003
5229
|
}, [isServerSide, pagination.maxPage, pagination.totalCount, perPage, datasets.length]);
|
|
5004
|
-
const currentPageRows =
|
|
5230
|
+
const currentPageRows = React26.useMemo(() => {
|
|
5005
5231
|
if (isServerSide) return rows;
|
|
5006
5232
|
return datasets[activePage] ?? [];
|
|
5007
5233
|
}, [isServerSide, rows, datasets, activePage]);
|
|
5008
|
-
|
|
5234
|
+
React26.useEffect(() => {
|
|
5009
5235
|
if (pagination.enabled && !isServerSide && typeof pagination.perPage === "number") {
|
|
5010
5236
|
setPerPage(pagination.perPage);
|
|
5011
5237
|
}
|
|
5012
5238
|
}, [pagination.enabled, pagination.perPage, isServerSide]);
|
|
5013
|
-
|
|
5239
|
+
React26.useEffect(() => {
|
|
5014
5240
|
if (isServerSide && typeof pagination.perPage === "number") setPerPage(pagination.perPage);
|
|
5015
5241
|
}, [isServerSide, pagination.perPage]);
|
|
5016
|
-
|
|
5242
|
+
React26.useEffect(() => {
|
|
5017
5243
|
if (isServerSide && typeof pagination.page === "number" && pagination.page >= 1)
|
|
5018
5244
|
setActivePage(pagination.page - 1);
|
|
5019
5245
|
}, [isServerSide, pagination.page]);
|
|
@@ -5097,7 +5323,7 @@ function TableSkeletonBody({
|
|
|
5097
5323
|
)) });
|
|
5098
5324
|
}
|
|
5099
5325
|
function ThemeSwitch({ checked, onChange, label = "Toggle dark mode", className = "" }) {
|
|
5100
|
-
const id =
|
|
5326
|
+
const id = React26.useId();
|
|
5101
5327
|
return /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: id, className: `flex items-center gap-2 cursor-pointer select-none ${className}`.trim(), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5102
5328
|
SwitchPrimitive__namespace.Root,
|
|
5103
5329
|
{
|
|
@@ -5281,7 +5507,7 @@ function Sidebar({
|
|
|
5281
5507
|
}
|
|
5282
5508
|
) });
|
|
5283
5509
|
}
|
|
5284
|
-
var MegaMenuContext =
|
|
5510
|
+
var MegaMenuContext = React26.createContext({ align: "start" });
|
|
5285
5511
|
function MegaMenu({
|
|
5286
5512
|
children,
|
|
5287
5513
|
align = "start",
|
|
@@ -5312,7 +5538,7 @@ function MegaMenu({
|
|
|
5312
5538
|
}
|
|
5313
5539
|
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";
|
|
5314
5540
|
function MegaMenuItem({ label, icon, href, children, className = "" }) {
|
|
5315
|
-
const { align } =
|
|
5541
|
+
const { align } = React26.useContext(MegaMenuContext);
|
|
5316
5542
|
const pos = align === "center" ? "left-1/2 -translate-x-1/2" : align === "end" ? "right-0" : "left-0";
|
|
5317
5543
|
if (!children) {
|
|
5318
5544
|
return /* @__PURE__ */ jsxRuntime.jsx(NavigationMenu__namespace.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs(NavigationMenu__namespace.Link, { href, className: [TOP_ITEM, className].filter(Boolean).join(" "), children: [
|
|
@@ -5397,8 +5623,8 @@ function MegaMenuLink({ href, icon, description, active, onClick, children, clas
|
|
|
5397
5623
|
function MegaMenuFeatured({ children, className = "" }) {
|
|
5398
5624
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: ["min-w-0 rounded-lg bg-surface-raised border border-border p-4 flex flex-col", className].filter(Boolean).join(" "), children });
|
|
5399
5625
|
}
|
|
5400
|
-
var elementsOfType = (children, type) =>
|
|
5401
|
-
(c) =>
|
|
5626
|
+
var elementsOfType = (children, type) => React26__default.default.Children.toArray(children).filter(
|
|
5627
|
+
(c) => React26__default.default.isValidElement(c) && c.type === type
|
|
5402
5628
|
);
|
|
5403
5629
|
var MOBILE_CHEVRON = /* @__PURE__ */ jsxRuntime.jsx(
|
|
5404
5630
|
"svg",
|
|
@@ -5435,9 +5661,9 @@ function MobileLinkRow({ link, onNavigate }) {
|
|
|
5435
5661
|
);
|
|
5436
5662
|
}
|
|
5437
5663
|
function MobilePanel({ panel, onNavigate }) {
|
|
5438
|
-
const nodes =
|
|
5664
|
+
const nodes = React26__default.default.Children.toArray(panel.props.children);
|
|
5439
5665
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-4 px-2 pb-3 pt-1", children: nodes.map((node, i) => {
|
|
5440
|
-
if (!
|
|
5666
|
+
if (!React26__default.default.isValidElement(node)) return null;
|
|
5441
5667
|
const el = node;
|
|
5442
5668
|
if (el.type === MegaMenuSection) {
|
|
5443
5669
|
const { title, children } = el.props;
|
|
@@ -5456,8 +5682,8 @@ function MegaMenuMobile({
|
|
|
5456
5682
|
children,
|
|
5457
5683
|
label
|
|
5458
5684
|
}) {
|
|
5459
|
-
const [open, setOpen] =
|
|
5460
|
-
const [expanded, setExpanded] =
|
|
5685
|
+
const [open, setOpen] = React26.useState(false);
|
|
5686
|
+
const [expanded, setExpanded] = React26.useState(null);
|
|
5461
5687
|
const items = elementsOfType(children, MegaMenuItem);
|
|
5462
5688
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "md:hidden w-full", children: [
|
|
5463
5689
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -5530,17 +5756,17 @@ function AppShell({
|
|
|
5530
5756
|
children,
|
|
5531
5757
|
className = ""
|
|
5532
5758
|
}) {
|
|
5533
|
-
const [expanded, setExpanded] =
|
|
5534
|
-
const [isMobile, setIsMobile] =
|
|
5535
|
-
const [mobileOpen, setMobileOpen] =
|
|
5536
|
-
|
|
5759
|
+
const [expanded, setExpanded] = React26.useState(sidebarDefaultExpanded);
|
|
5760
|
+
const [isMobile, setIsMobile] = React26.useState(false);
|
|
5761
|
+
const [mobileOpen, setMobileOpen] = React26.useState(false);
|
|
5762
|
+
React26.useEffect(() => {
|
|
5537
5763
|
const mq = window.matchMedia("(max-width: 767px)");
|
|
5538
5764
|
const update = (e) => setIsMobile(e.matches);
|
|
5539
5765
|
update(mq);
|
|
5540
5766
|
mq.addEventListener("change", update);
|
|
5541
5767
|
return () => mq.removeEventListener("change", update);
|
|
5542
5768
|
}, []);
|
|
5543
|
-
|
|
5769
|
+
React26.useEffect(() => {
|
|
5544
5770
|
if (!isMobile) setMobileOpen(false);
|
|
5545
5771
|
}, [isMobile]);
|
|
5546
5772
|
const hasSidebar = sidebarSections.length > 0;
|
|
@@ -5627,6 +5853,101 @@ function AppShell({
|
|
|
5627
5853
|
] })
|
|
5628
5854
|
] });
|
|
5629
5855
|
}
|
|
5856
|
+
function parseJwt(token) {
|
|
5857
|
+
try {
|
|
5858
|
+
const part = token.split(".")[1];
|
|
5859
|
+
if (!part || typeof atob === "undefined") return null;
|
|
5860
|
+
const json = decodeURIComponent(
|
|
5861
|
+
atob(part.replace(/-/g, "+").replace(/_/g, "/")).split("").map((c) => "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2)).join("")
|
|
5862
|
+
);
|
|
5863
|
+
return JSON.parse(json);
|
|
5864
|
+
} catch {
|
|
5865
|
+
return null;
|
|
5866
|
+
}
|
|
5867
|
+
}
|
|
5868
|
+
function tokenValid(token) {
|
|
5869
|
+
const payload = parseJwt(token);
|
|
5870
|
+
if (!payload) return false;
|
|
5871
|
+
const exp = typeof payload.exp === "number" ? payload.exp : null;
|
|
5872
|
+
if (exp == null) return true;
|
|
5873
|
+
return exp * 1e3 > Date.now();
|
|
5874
|
+
}
|
|
5875
|
+
var has = (have, need, all) => all ? need.every((n) => have?.includes(n)) : need.some((n) => have?.includes(n));
|
|
5876
|
+
var Spinner2 = () => /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": "true", className: "h-6 w-6 animate-spin text-accent", children: /* @__PURE__ */ jsxRuntime.jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M4.755 10.059a7.5 7.5 0 0112.548-3.364l1.903 1.903h-3.183a.75.75 0 100 1.5h4.992a.75.75 0 00.75-.75V4.356a.75.75 0 00-1.5 0v3.18l-1.9-1.9A9 9 0 003.306 9.67a.75.75 0 101.45.388zm15.408 3.352a.75.75 0 00-.919.53 7.5 7.5 0 01-12.548 3.364l-1.902-1.903h3.183a.75.75 0 000-1.5H2.984a.75.75 0 00-.75.75v4.992a.75.75 0 001.5 0v-3.18l1.9 1.9a9 9 0 0015.059-4.035.75.75 0 00-.53-.918z" }) });
|
|
5877
|
+
function SecureLayout({
|
|
5878
|
+
children,
|
|
5879
|
+
isAuthenticated,
|
|
5880
|
+
token,
|
|
5881
|
+
roles,
|
|
5882
|
+
requiredRoles,
|
|
5883
|
+
requireAllRoles,
|
|
5884
|
+
permissions,
|
|
5885
|
+
requiredPermissions,
|
|
5886
|
+
requireAllPermissions,
|
|
5887
|
+
canAccess,
|
|
5888
|
+
loadingFallback,
|
|
5889
|
+
fallback,
|
|
5890
|
+
onDeny,
|
|
5891
|
+
className = ""
|
|
5892
|
+
}) {
|
|
5893
|
+
const reduced = framerMotion.useReducedMotion();
|
|
5894
|
+
const [state, setState] = React26.useState("checking");
|
|
5895
|
+
const rolesKey = JSON.stringify(roles);
|
|
5896
|
+
const requiredRolesKey = JSON.stringify(requiredRoles);
|
|
5897
|
+
const permissionsKey = JSON.stringify(permissions);
|
|
5898
|
+
const requiredPermissionsKey = JSON.stringify(requiredPermissions);
|
|
5899
|
+
React26.useEffect(() => {
|
|
5900
|
+
let cancelled = false;
|
|
5901
|
+
setState("checking");
|
|
5902
|
+
const evaluate = async () => {
|
|
5903
|
+
let authed = isAuthenticated;
|
|
5904
|
+
if (authed === void 0 && token !== void 0) authed = tokenValid(token);
|
|
5905
|
+
if (authed === void 0) authed = true;
|
|
5906
|
+
if (!authed) return false;
|
|
5907
|
+
if (requiredRoles?.length && !has(roles, requiredRoles, requireAllRoles)) return false;
|
|
5908
|
+
if (requiredPermissions?.length && !has(permissions, requiredPermissions, requireAllPermissions)) return false;
|
|
5909
|
+
if (canAccess && !await canAccess()) return false;
|
|
5910
|
+
return true;
|
|
5911
|
+
};
|
|
5912
|
+
evaluate().then((ok) => {
|
|
5913
|
+
if (cancelled) return;
|
|
5914
|
+
setState(ok ? "granted" : "denied");
|
|
5915
|
+
if (!ok) onDeny?.();
|
|
5916
|
+
});
|
|
5917
|
+
return () => {
|
|
5918
|
+
cancelled = true;
|
|
5919
|
+
};
|
|
5920
|
+
}, [
|
|
5921
|
+
isAuthenticated,
|
|
5922
|
+
token,
|
|
5923
|
+
requireAllRoles,
|
|
5924
|
+
requireAllPermissions,
|
|
5925
|
+
canAccess,
|
|
5926
|
+
rolesKey,
|
|
5927
|
+
requiredRolesKey,
|
|
5928
|
+
permissionsKey,
|
|
5929
|
+
requiredPermissionsKey
|
|
5930
|
+
]);
|
|
5931
|
+
if (state === "checking") {
|
|
5932
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: ["flex min-h-[8rem] items-center justify-center", className].filter(Boolean).join(" "), children: loadingFallback ?? /* @__PURE__ */ jsxRuntime.jsx(Spinner2, {}) });
|
|
5933
|
+
}
|
|
5934
|
+
if (state === "denied") {
|
|
5935
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: className || void 0, children: fallback ?? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-h-[8rem] flex-col items-center justify-center gap-1 rounded-xl border border-border bg-surface p-8 text-center", children: [
|
|
5936
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm font-semibold text-foreground", children: "Access denied" }),
|
|
5937
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-foreground-muted", children: "You don\u2019t have permission to view this content." })
|
|
5938
|
+
] }) });
|
|
5939
|
+
}
|
|
5940
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5941
|
+
framerMotion.motion.div,
|
|
5942
|
+
{
|
|
5943
|
+
className: className || void 0,
|
|
5944
|
+
initial: reduced ? false : { opacity: 0 },
|
|
5945
|
+
animate: { opacity: 1 },
|
|
5946
|
+
transition: { duration: reduced ? 0 : 0.2, ease: "easeOut" },
|
|
5947
|
+
children
|
|
5948
|
+
}
|
|
5949
|
+
);
|
|
5950
|
+
}
|
|
5630
5951
|
function px(v) {
|
|
5631
5952
|
return typeof v === "number" ? `${v}px` : v;
|
|
5632
5953
|
}
|
|
@@ -5730,10 +6051,10 @@ function ThemeProvider({
|
|
|
5730
6051
|
className = "",
|
|
5731
6052
|
style
|
|
5732
6053
|
}) {
|
|
5733
|
-
const id =
|
|
6054
|
+
const id = React26__default.default.useId().replace(/:/g, "");
|
|
5734
6055
|
const scopeClass = `geo-th-${id}`;
|
|
5735
|
-
const divRef =
|
|
5736
|
-
|
|
6056
|
+
const divRef = React26.useRef(null);
|
|
6057
|
+
React26.useEffect(() => {
|
|
5737
6058
|
const el = divRef.current;
|
|
5738
6059
|
if (!el) return;
|
|
5739
6060
|
if (colorScheme === "auto") return;
|
|
@@ -5748,8 +6069,8 @@ function ThemeProvider({
|
|
|
5748
6069
|
}
|
|
5749
6070
|
el.classList.toggle("dark", colorScheme === "dark");
|
|
5750
6071
|
}, [colorScheme]);
|
|
5751
|
-
const lightVars =
|
|
5752
|
-
const darkVarStr =
|
|
6072
|
+
const lightVars = React26.useMemo(() => toCssVars(theme), [theme]);
|
|
6073
|
+
const darkVarStr = React26.useMemo(() => {
|
|
5753
6074
|
if (!darkTheme) return "";
|
|
5754
6075
|
const dvars = toCssVars(darkTheme);
|
|
5755
6076
|
if (!Object.keys(dvars).length) return "";
|
|
@@ -5791,7 +6112,7 @@ function NumberInput({
|
|
|
5791
6112
|
readOnly = false,
|
|
5792
6113
|
precision
|
|
5793
6114
|
}) {
|
|
5794
|
-
const errorId =
|
|
6115
|
+
const errorId = React26.useId();
|
|
5795
6116
|
const hasError = errorMessage != null;
|
|
5796
6117
|
const inferredPrecision = precision ?? (Number.isInteger(step) ? 0 : String(step).split(".")[1]?.length ?? 0);
|
|
5797
6118
|
const round = (n) => {
|
|
@@ -5922,8 +6243,8 @@ function Password({
|
|
|
5922
6243
|
showIcon,
|
|
5923
6244
|
hideIcon
|
|
5924
6245
|
}) {
|
|
5925
|
-
const [visible, setVisible] =
|
|
5926
|
-
const errorId =
|
|
6246
|
+
const [visible, setVisible] = React26.useState(false);
|
|
6247
|
+
const errorId = React26.useId();
|
|
5927
6248
|
const hasError = errorMessage != null;
|
|
5928
6249
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5929
6250
|
Field,
|
|
@@ -5996,7 +6317,7 @@ function Checkbox({
|
|
|
5996
6317
|
}) {
|
|
5997
6318
|
const isChecked = checked ?? value ?? false;
|
|
5998
6319
|
const labelFirst = labelPosition === "left";
|
|
5999
|
-
const errorId =
|
|
6320
|
+
const errorId = React26.useId();
|
|
6000
6321
|
const hasError = errorMessage != null;
|
|
6001
6322
|
const box = /* @__PURE__ */ jsxRuntime.jsx(
|
|
6002
6323
|
CheckboxPrimitive__namespace.Root,
|
|
@@ -6104,8 +6425,8 @@ function RadioGroup({
|
|
|
6104
6425
|
className,
|
|
6105
6426
|
errorMessage
|
|
6106
6427
|
}) {
|
|
6107
|
-
const errorId =
|
|
6108
|
-
const groupId =
|
|
6428
|
+
const errorId = React26.useId();
|
|
6429
|
+
const groupId = React26.useId();
|
|
6109
6430
|
const hasError = errorMessage != null;
|
|
6110
6431
|
const labelFirst = labelPosition === "left";
|
|
6111
6432
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -6205,11 +6526,11 @@ function Switch({
|
|
|
6205
6526
|
disabled,
|
|
6206
6527
|
errorMessage
|
|
6207
6528
|
}) {
|
|
6208
|
-
const id =
|
|
6209
|
-
const errorId =
|
|
6529
|
+
const id = React26.useId();
|
|
6530
|
+
const errorId = React26.useId();
|
|
6210
6531
|
const hasError = errorMessage != null;
|
|
6211
6532
|
const isControlled = checked !== void 0;
|
|
6212
|
-
const [internal, setInternal] =
|
|
6533
|
+
const [internal, setInternal] = React26.useState(defaultChecked);
|
|
6213
6534
|
const isOn = isControlled ? checked : internal;
|
|
6214
6535
|
const handle = (c) => {
|
|
6215
6536
|
if (!isControlled) setInternal(c);
|
|
@@ -6282,19 +6603,19 @@ function AutoComplete({
|
|
|
6282
6603
|
required,
|
|
6283
6604
|
htmlFor
|
|
6284
6605
|
}) {
|
|
6285
|
-
const errorId =
|
|
6606
|
+
const errorId = React26.useId();
|
|
6286
6607
|
const hasError = errorMessage != null;
|
|
6287
|
-
const [term, setTerm] =
|
|
6288
|
-
const [open, setOpen] =
|
|
6289
|
-
const [asyncItems, setAsyncItems] =
|
|
6290
|
-
const [loading, setLoading] =
|
|
6608
|
+
const [term, setTerm] = React26.useState("");
|
|
6609
|
+
const [open, setOpen] = React26.useState(false);
|
|
6610
|
+
const [asyncItems, setAsyncItems] = React26.useState([]);
|
|
6611
|
+
const [loading, setLoading] = React26.useState(false);
|
|
6291
6612
|
const isAsync = typeof onSearch === "function";
|
|
6292
|
-
const debounceRef =
|
|
6293
|
-
const requestIdRef =
|
|
6613
|
+
const debounceRef = React26.useRef(null);
|
|
6614
|
+
const requestIdRef = React26.useRef(0);
|
|
6294
6615
|
const staticFiltered = isAsync || !items ? [] : term.trim() ? items.filter(
|
|
6295
6616
|
({ key, label: label2 }) => label2.toLowerCase().includes(term.toLowerCase()) || key.toLowerCase().includes(term.toLowerCase())
|
|
6296
6617
|
) : [];
|
|
6297
|
-
|
|
6618
|
+
React26.useEffect(() => {
|
|
6298
6619
|
if (!isAsync) return;
|
|
6299
6620
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
6300
6621
|
if (!term.trim()) {
|
|
@@ -6450,15 +6771,15 @@ function TreeSelect({
|
|
|
6450
6771
|
defaultExpandedKeys = [],
|
|
6451
6772
|
size = "md"
|
|
6452
6773
|
}) {
|
|
6453
|
-
const errorId =
|
|
6774
|
+
const errorId = React26.useId();
|
|
6454
6775
|
const hasError = errorMessage != null;
|
|
6455
|
-
const [open, setOpen] =
|
|
6456
|
-
const [expanded, setExpanded] =
|
|
6457
|
-
const [activeIndex, setActiveIndex] =
|
|
6458
|
-
const listRef =
|
|
6459
|
-
const visible =
|
|
6460
|
-
const didSyncOnOpenRef =
|
|
6461
|
-
|
|
6776
|
+
const [open, setOpen] = React26.useState(false);
|
|
6777
|
+
const [expanded, setExpanded] = React26.useState(() => new Set(defaultExpandedKeys));
|
|
6778
|
+
const [activeIndex, setActiveIndex] = React26.useState(0);
|
|
6779
|
+
const listRef = React26.useRef(null);
|
|
6780
|
+
const visible = React26.useMemo(() => flattenVisible(items, expanded), [items, expanded]);
|
|
6781
|
+
const didSyncOnOpenRef = React26.useRef(false);
|
|
6782
|
+
React26.useEffect(() => {
|
|
6462
6783
|
if (!open) {
|
|
6463
6784
|
didSyncOnOpenRef.current = false;
|
|
6464
6785
|
return;
|
|
@@ -6468,7 +6789,7 @@ function TreeSelect({
|
|
|
6468
6789
|
setActiveIndex(selectedIdx >= 0 ? selectedIdx : 0);
|
|
6469
6790
|
didSyncOnOpenRef.current = true;
|
|
6470
6791
|
}, [open, value]);
|
|
6471
|
-
const selectedNode =
|
|
6792
|
+
const selectedNode = React26.useMemo(
|
|
6472
6793
|
() => value != null ? findNodeByKey(items, value) : null,
|
|
6473
6794
|
[items, value]
|
|
6474
6795
|
);
|
|
@@ -6699,11 +7020,11 @@ function FileInput({
|
|
|
6699
7020
|
required,
|
|
6700
7021
|
icon
|
|
6701
7022
|
}) {
|
|
6702
|
-
const inputRef =
|
|
6703
|
-
const errorId =
|
|
6704
|
-
const [files, setFiles] =
|
|
6705
|
-
const [dragging, setDragging] =
|
|
6706
|
-
const [sizeError, setSizeError] =
|
|
7023
|
+
const inputRef = React26.useRef(null);
|
|
7024
|
+
const errorId = React26.useId();
|
|
7025
|
+
const [files, setFiles] = React26.useState([]);
|
|
7026
|
+
const [dragging, setDragging] = React26.useState(false);
|
|
7027
|
+
const [sizeError, setSizeError] = React26.useState(null);
|
|
6707
7028
|
const effectiveError = errorMessage ?? sizeError ?? void 0;
|
|
6708
7029
|
const openPicker = () => {
|
|
6709
7030
|
if (!disabled) inputRef.current?.click();
|
|
@@ -6894,30 +7215,30 @@ function DatePicker({
|
|
|
6894
7215
|
size = "md",
|
|
6895
7216
|
className = ""
|
|
6896
7217
|
}) {
|
|
6897
|
-
const errorId =
|
|
7218
|
+
const errorId = React26.useId();
|
|
6898
7219
|
const hasError = errorMessage != null;
|
|
6899
|
-
const [open, setOpen] =
|
|
6900
|
-
const [viewMonth, setViewMonth] =
|
|
6901
|
-
const [focusDate, setFocusDate] =
|
|
6902
|
-
const [view, setView] =
|
|
6903
|
-
const gridRef =
|
|
6904
|
-
|
|
7220
|
+
const [open, setOpen] = React26.useState(false);
|
|
7221
|
+
const [viewMonth, setViewMonth] = React26.useState(() => startOfMonth(value ?? /* @__PURE__ */ new Date()));
|
|
7222
|
+
const [focusDate, setFocusDate] = React26.useState(() => value ?? /* @__PURE__ */ new Date());
|
|
7223
|
+
const [view, setView] = React26.useState("days");
|
|
7224
|
+
const gridRef = React26.useRef(null);
|
|
7225
|
+
React26.useEffect(() => {
|
|
6905
7226
|
if (!open) return;
|
|
6906
7227
|
const target = value ?? /* @__PURE__ */ new Date();
|
|
6907
7228
|
setViewMonth(startOfMonth(target));
|
|
6908
7229
|
setFocusDate(target);
|
|
6909
7230
|
setView("days");
|
|
6910
7231
|
}, [open, value]);
|
|
6911
|
-
|
|
7232
|
+
React26.useEffect(() => {
|
|
6912
7233
|
if (!open) return;
|
|
6913
7234
|
const cell = gridRef.current?.querySelector(`[data-day="${defaultFormat3(focusDate)}"]`);
|
|
6914
7235
|
cell?.focus();
|
|
6915
7236
|
}, [open, focusDate]);
|
|
6916
|
-
const weekdays =
|
|
7237
|
+
const weekdays = React26.useMemo(() => {
|
|
6917
7238
|
const ordered = WEEKDAY_SHORT.slice(weekStartsOn).concat(WEEKDAY_SHORT.slice(0, weekStartsOn));
|
|
6918
7239
|
return ordered;
|
|
6919
7240
|
}, [weekStartsOn]);
|
|
6920
|
-
const grid =
|
|
7241
|
+
const grid = React26.useMemo(() => buildGrid2(viewMonth, weekStartsOn), [viewMonth, weekStartsOn]);
|
|
6921
7242
|
const isDisabled = (d) => {
|
|
6922
7243
|
if (min && d < min) return true;
|
|
6923
7244
|
if (max && d > max) return true;
|
|
@@ -7207,10 +7528,10 @@ function TextArea({
|
|
|
7207
7528
|
style,
|
|
7208
7529
|
inputStyle
|
|
7209
7530
|
}) {
|
|
7210
|
-
const errorId =
|
|
7531
|
+
const errorId = React26.useId();
|
|
7211
7532
|
const hasError = errorMessage != null;
|
|
7212
|
-
const ref =
|
|
7213
|
-
|
|
7533
|
+
const ref = React26.useRef(null);
|
|
7534
|
+
React26.useLayoutEffect(() => {
|
|
7214
7535
|
if (!autoGrow) return;
|
|
7215
7536
|
const el = ref.current;
|
|
7216
7537
|
if (!el) return;
|
|
@@ -7280,11 +7601,11 @@ function SegmentedControl({
|
|
|
7280
7601
|
"aria-label": ariaLabel
|
|
7281
7602
|
}) {
|
|
7282
7603
|
const sz = SIZE5[size];
|
|
7283
|
-
const groupId =
|
|
7284
|
-
const errorId =
|
|
7604
|
+
const groupId = React26.useId();
|
|
7605
|
+
const errorId = React26.useId();
|
|
7285
7606
|
const hasError = errorMessage != null;
|
|
7286
7607
|
const isControlled = value !== void 0;
|
|
7287
|
-
const [internal, setInternal] =
|
|
7608
|
+
const [internal, setInternal] = React26.useState(defaultValue);
|
|
7288
7609
|
const current = isControlled ? value : internal;
|
|
7289
7610
|
const handle = (v) => {
|
|
7290
7611
|
if (!v) return;
|
|
@@ -7378,14 +7699,14 @@ function Slider({
|
|
|
7378
7699
|
name,
|
|
7379
7700
|
htmlFor
|
|
7380
7701
|
}) {
|
|
7381
|
-
const errorId =
|
|
7702
|
+
const errorId = React26.useId();
|
|
7382
7703
|
const hasError = errorMessage != null;
|
|
7383
7704
|
const isRange = Array.isArray(value ?? defaultValue);
|
|
7384
|
-
const [internal, setInternal] =
|
|
7705
|
+
const [internal, setInternal] = React26.useState(
|
|
7385
7706
|
() => toArray(value) ?? toArray(defaultValue) ?? [min]
|
|
7386
7707
|
);
|
|
7387
7708
|
const current = toArray(value) ?? internal;
|
|
7388
|
-
const [dragging, setDragging] =
|
|
7709
|
+
const [dragging, setDragging] = React26.useState(false);
|
|
7389
7710
|
const emit = (arr) => {
|
|
7390
7711
|
setInternal(arr);
|
|
7391
7712
|
const next = isRange ? [arr[0], arr[1]] : arr[0];
|
|
@@ -7480,11 +7801,11 @@ function TagsInput({
|
|
|
7480
7801
|
validate,
|
|
7481
7802
|
separators = ["Enter", ","]
|
|
7482
7803
|
}) {
|
|
7483
|
-
const errorId =
|
|
7484
|
-
const inputRef =
|
|
7485
|
-
const [internal, setInternal] =
|
|
7486
|
-
const [draft, setDraft] =
|
|
7487
|
-
const [localError, setLocalError] =
|
|
7804
|
+
const errorId = React26.useId();
|
|
7805
|
+
const inputRef = React26.useRef(null);
|
|
7806
|
+
const [internal, setInternal] = React26.useState(defaultValue ?? []);
|
|
7807
|
+
const [draft, setDraft] = React26.useState("");
|
|
7808
|
+
const [localError, setLocalError] = React26.useState(null);
|
|
7488
7809
|
const tags = value ?? internal;
|
|
7489
7810
|
const hasError = errorMessage != null || localError != null;
|
|
7490
7811
|
const errorText = errorMessage ?? localError ?? void 0;
|
|
@@ -7615,9 +7936,9 @@ function OtpInput({
|
|
|
7615
7936
|
className,
|
|
7616
7937
|
groupAfter
|
|
7617
7938
|
}) {
|
|
7618
|
-
const errorId =
|
|
7939
|
+
const errorId = React26.useId();
|
|
7619
7940
|
const hasError = errorMessage != null;
|
|
7620
|
-
const refs =
|
|
7941
|
+
const refs = React26.useRef([]);
|
|
7621
7942
|
const chars = Array.from({ length }, (_, i) => value[i] ?? "");
|
|
7622
7943
|
const pattern = mode === "numeric" ? /[0-9]/ : /[a-zA-Z0-9]/;
|
|
7623
7944
|
const emit = (next) => {
|
|
@@ -7666,7 +7987,7 @@ function OtpInput({
|
|
|
7666
7987
|
emit(valid.join(""));
|
|
7667
7988
|
focusBox(valid.length);
|
|
7668
7989
|
};
|
|
7669
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Field, { className, label, htmlFor, errorId, errorMessage, required, layout, helperText, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2", role: "group", "aria-label": typeof label === "string" ? label : "One-time code", children: chars.map((char, idx) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7990
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Field, { className, label, htmlFor, errorId, errorMessage, required, layout, helperText, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2", role: "group", "aria-label": typeof label === "string" ? label : "One-time code", children: chars.map((char, idx) => /* @__PURE__ */ jsxRuntime.jsxs(React26__default.default.Fragment, { children: [
|
|
7670
7991
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7671
7992
|
"input",
|
|
7672
7993
|
{
|
|
@@ -7724,9 +8045,9 @@ function Rating({
|
|
|
7724
8045
|
className,
|
|
7725
8046
|
required
|
|
7726
8047
|
}) {
|
|
7727
|
-
const errorId =
|
|
7728
|
-
const [internal, setInternal] =
|
|
7729
|
-
const [hover, setHover] =
|
|
8048
|
+
const errorId = React26.useId();
|
|
8049
|
+
const [internal, setInternal] = React26.useState(defaultValue);
|
|
8050
|
+
const [hover, setHover] = React26.useState(null);
|
|
7730
8051
|
const current = value ?? internal;
|
|
7731
8052
|
const display2 = hover ?? current;
|
|
7732
8053
|
const interactive = !readOnly && !disabled;
|
|
@@ -7849,9 +8170,9 @@ function TimePicker({
|
|
|
7849
8170
|
required,
|
|
7850
8171
|
style
|
|
7851
8172
|
}) {
|
|
7852
|
-
const errorId =
|
|
8173
|
+
const errorId = React26.useId();
|
|
7853
8174
|
const hasError = errorMessage != null;
|
|
7854
|
-
const [open, setOpen] =
|
|
8175
|
+
const [open, setOpen] = React26.useState(false);
|
|
7855
8176
|
const parsed = parse(value) ?? { h: 0, m: 0, s: 0 };
|
|
7856
8177
|
const update = (next) => {
|
|
7857
8178
|
const merged = { ...parsed, ...next };
|
|
@@ -7975,13 +8296,13 @@ function DateRangePicker({
|
|
|
7975
8296
|
required,
|
|
7976
8297
|
style
|
|
7977
8298
|
}) {
|
|
7978
|
-
const errorId =
|
|
8299
|
+
const errorId = React26.useId();
|
|
7979
8300
|
const hasError = errorMessage != null;
|
|
7980
|
-
const [open, setOpen] =
|
|
7981
|
-
const [leftMonth, setLeftMonth] =
|
|
7982
|
-
const [pendingStart, setPendingStart] =
|
|
7983
|
-
const [hoverDate, setHoverDate] =
|
|
7984
|
-
const weekdays =
|
|
8301
|
+
const [open, setOpen] = React26.useState(false);
|
|
8302
|
+
const [leftMonth, setLeftMonth] = React26.useState(() => startOfMonth2(value.start ?? /* @__PURE__ */ new Date()));
|
|
8303
|
+
const [pendingStart, setPendingStart] = React26.useState(null);
|
|
8304
|
+
const [hoverDate, setHoverDate] = React26.useState(null);
|
|
8305
|
+
const weekdays = React26.useMemo(
|
|
7985
8306
|
() => WEEKDAY.slice(weekStartsOn).concat(WEEKDAY.slice(0, weekStartsOn)),
|
|
7986
8307
|
[weekStartsOn]
|
|
7987
8308
|
);
|
|
@@ -8157,10 +8478,10 @@ function ColorPicker({
|
|
|
8157
8478
|
required,
|
|
8158
8479
|
placeholder = "Pick a colour\u2026"
|
|
8159
8480
|
}) {
|
|
8160
|
-
const errorId =
|
|
8481
|
+
const errorId = React26.useId();
|
|
8161
8482
|
const hasError = errorMessage != null;
|
|
8162
|
-
const [open, setOpen] =
|
|
8163
|
-
const [draft, setDraft] =
|
|
8483
|
+
const [open, setOpen] = React26.useState(false);
|
|
8484
|
+
const [draft, setDraft] = React26.useState(value);
|
|
8164
8485
|
const valid = HEX_RE.test(value);
|
|
8165
8486
|
const pick = (hex) => {
|
|
8166
8487
|
onChange?.(hex);
|
|
@@ -8308,6 +8629,7 @@ exports.Kbd = Kbd;
|
|
|
8308
8629
|
exports.List = List2;
|
|
8309
8630
|
exports.LoadingSpinner = LoadingSpinner;
|
|
8310
8631
|
exports.MegaMenu = MegaMenu_default;
|
|
8632
|
+
exports.MenuButton = MenuButton;
|
|
8311
8633
|
exports.Modal = Modal;
|
|
8312
8634
|
exports.NotificationProvider = NotificationProvider;
|
|
8313
8635
|
exports.NumberInput = NumberInput;
|
|
@@ -8320,6 +8642,7 @@ exports.RadioGroup = RadioGroup;
|
|
|
8320
8642
|
exports.Rating = Rating;
|
|
8321
8643
|
exports.ScalableContainer = ScalableContainer;
|
|
8322
8644
|
exports.SearchInput = SearchInput_default;
|
|
8645
|
+
exports.SecureLayout = SecureLayout;
|
|
8323
8646
|
exports.SegmentedControl = SegmentedControl;
|
|
8324
8647
|
exports.Sidebar = Sidebar;
|
|
8325
8648
|
exports.SkeletonBox = SkeletonBox;
|
|
@@ -8328,6 +8651,7 @@ exports.SkeletonCircle = SkeletonCircle;
|
|
|
8328
8651
|
exports.SkeletonText = SkeletonText;
|
|
8329
8652
|
exports.Slider = Slider;
|
|
8330
8653
|
exports.Statistic = Statistic;
|
|
8654
|
+
exports.Stepper = Stepper;
|
|
8331
8655
|
exports.Switch = Switch;
|
|
8332
8656
|
exports.Table = Table;
|
|
8333
8657
|
exports.Tabs = Tabs_default;
|
|
@@ -8338,6 +8662,7 @@ exports.TextInput = TextInput;
|
|
|
8338
8662
|
exports.ThemeProvider = ThemeProvider;
|
|
8339
8663
|
exports.ThemeSwitch = ThemeSwitch;
|
|
8340
8664
|
exports.TimePicker = TimePicker;
|
|
8665
|
+
exports.Timeline = Timeline;
|
|
8341
8666
|
exports.Tooltip = Tooltip;
|
|
8342
8667
|
exports.TooltipProvider = TooltipProvider;
|
|
8343
8668
|
exports.TopBar = TopBar;
|