nish-ui 1.6.0 → 1.8.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/README.md +14 -2
- package/dist/chart.js.map +1 -1
- package/dist/elements-charts.d.ts +2 -0
- package/dist/elements-charts.js +1 -0
- package/dist/elements-charts.js.map +1 -0
- package/dist/elements-data.d.ts +2 -0
- package/dist/elements-data.js +1 -0
- package/dist/elements-data.js.map +1 -0
- package/dist/elements-forms.d.ts +147 -0
- package/dist/elements-forms.js +92 -0
- package/dist/elements-forms.js.map +1 -0
- package/dist/elements.js +3 -3
- package/dist/elements.js.map +1 -1
- package/dist/files.json +3 -0
- package/dist/index.d.ts +51 -16
- package/dist/index.js +508 -361
- package/dist/index.js.map +1 -1
- package/dist/nish-components.css +1189 -156
- package/dist/system-canvas.js.map +1 -1
- package/dist/theme.global.js +15 -3
- package/dist/theme.global.js.map +1 -1
- package/dist/theme.js +12 -0
- package/dist/theme.js.map +1 -1
- package/package.json +34 -2
package/dist/index.js
CHANGED
|
@@ -587,6 +587,13 @@ function mountThemeToggle(button, opts = {}) {
|
|
|
587
587
|
off();
|
|
588
588
|
};
|
|
589
589
|
}
|
|
590
|
+
var TOAST_ICON_PATHS = {
|
|
591
|
+
neutral: '<circle cx="12" cy="12" r="10"/><path d="M12 16v-4M12 8h.01"/>',
|
|
592
|
+
info: '<circle cx="12" cy="12" r="10"/><path d="M12 16v-4M12 8h.01"/>',
|
|
593
|
+
ok: '<circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/>',
|
|
594
|
+
warn: '<path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4M12 17h.01"/>',
|
|
595
|
+
loss: '<path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4M12 17h.01"/>'
|
|
596
|
+
};
|
|
590
597
|
var TOAST_MS = 6e3;
|
|
591
598
|
var toastRegion = null;
|
|
592
599
|
var hideCurrent = null;
|
|
@@ -602,6 +609,11 @@ function showToast(content, opts = {}) {
|
|
|
602
609
|
const region = toastRegion;
|
|
603
610
|
const box = document.createElement("div");
|
|
604
611
|
box.className = "nish-toast" + (opts.tone && opts.tone !== "neutral" ? ` nish-toast--${opts.tone}` : "");
|
|
612
|
+
const icon = document.createElement("span");
|
|
613
|
+
icon.className = "nish-toast-icon";
|
|
614
|
+
icon.setAttribute("aria-hidden", "true");
|
|
615
|
+
icon.innerHTML = `<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" focusable="false">${TOAST_ICON_PATHS[opts.tone ?? "neutral"]}</svg>`;
|
|
616
|
+
box.append(icon);
|
|
605
617
|
const body = document.createElement("p");
|
|
606
618
|
body.className = "nish-toast-body";
|
|
607
619
|
body.append(typeof content === "string" ? document.createTextNode(content) : content);
|
|
@@ -1160,6 +1172,16 @@ var SettingsIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
|
1160
1172
|
/* @__PURE__ */ jsx("path", { d: "M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z" }),
|
|
1161
1173
|
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "3" })
|
|
1162
1174
|
] });
|
|
1175
|
+
var PanelLeftCloseIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
1176
|
+
/* @__PURE__ */ jsx("rect", { width: "18", height: "18", x: "3", y: "3", rx: "2" }),
|
|
1177
|
+
/* @__PURE__ */ jsx("path", { d: "M9 3v18" }),
|
|
1178
|
+
/* @__PURE__ */ jsx("path", { d: "m16 15-3-3 3-3" })
|
|
1179
|
+
] });
|
|
1180
|
+
var PanelLeftOpenIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
1181
|
+
/* @__PURE__ */ jsx("rect", { width: "18", height: "18", x: "3", y: "3", rx: "2" }),
|
|
1182
|
+
/* @__PURE__ */ jsx("path", { d: "M9 3v18" }),
|
|
1183
|
+
/* @__PURE__ */ jsx("path", { d: "m14 9 3 3-3 3" })
|
|
1184
|
+
] });
|
|
1163
1185
|
|
|
1164
1186
|
// src/components/primitives.tsx
|
|
1165
1187
|
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
@@ -1870,7 +1892,7 @@ function ChipGroup({ label, scroll = false, className, children, ...rest }) {
|
|
|
1870
1892
|
}
|
|
1871
1893
|
|
|
1872
1894
|
// src/components/tabs.tsx
|
|
1873
|
-
import { createContext as createContext2, useContext as useContext2, useEffect as
|
|
1895
|
+
import { createContext as createContext2, useContext as useContext2, useEffect as useEffect9, useId as useId6, useRef as useRef7, useSyncExternalStore as useSyncExternalStore2 } from "react";
|
|
1874
1896
|
|
|
1875
1897
|
// src/components/layout-vars.ts
|
|
1876
1898
|
import { useEffect as useEffect2, useState } from "react";
|
|
@@ -1964,19 +1986,18 @@ function useScrollEdges(ref) {
|
|
|
1964
1986
|
// src/components/nav.tsx
|
|
1965
1987
|
import {
|
|
1966
1988
|
Fragment as Fragment4,
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
useRef as useRef5,
|
|
1989
|
+
useEffect as useEffect8,
|
|
1990
|
+
useRef as useRef6,
|
|
1970
1991
|
useState as useState6,
|
|
1971
1992
|
useSyncExternalStore
|
|
1972
1993
|
} from "react";
|
|
1973
1994
|
|
|
1974
1995
|
// src/components/command.tsx
|
|
1975
1996
|
import {
|
|
1976
|
-
useEffect as
|
|
1997
|
+
useEffect as useEffect5,
|
|
1977
1998
|
useId as useId4,
|
|
1978
1999
|
useMemo,
|
|
1979
|
-
useRef as
|
|
2000
|
+
useRef as useRef4,
|
|
1980
2001
|
useState as useState3
|
|
1981
2002
|
} from "react";
|
|
1982
2003
|
|
|
@@ -1986,13 +2007,26 @@ import {
|
|
|
1986
2007
|
createContext,
|
|
1987
2008
|
useCallback as useCallback2,
|
|
1988
2009
|
useContext,
|
|
1989
|
-
useEffect as
|
|
2010
|
+
useEffect as useEffect4,
|
|
1990
2011
|
useId as useId3,
|
|
1991
|
-
useLayoutEffect as
|
|
1992
|
-
useRef as
|
|
2012
|
+
useLayoutEffect as useLayoutEffect3,
|
|
2013
|
+
useRef as useRef3,
|
|
1993
2014
|
useState as useState2
|
|
1994
2015
|
} from "react";
|
|
1995
2016
|
import { createPortal } from "react-dom";
|
|
2017
|
+
|
|
2018
|
+
// src/components/latest.ts
|
|
2019
|
+
import { useEffect as useEffect3, useLayoutEffect as useLayoutEffect2, useRef as useRef2 } from "react";
|
|
2020
|
+
var useIsoLayoutEffect2 = typeof window === "undefined" ? useEffect3 : useLayoutEffect2;
|
|
2021
|
+
function useLatest(value) {
|
|
2022
|
+
const ref = useRef2(value);
|
|
2023
|
+
useIsoLayoutEffect2(() => {
|
|
2024
|
+
ref.current = value;
|
|
2025
|
+
});
|
|
2026
|
+
return ref;
|
|
2027
|
+
}
|
|
2028
|
+
|
|
2029
|
+
// src/components/overlay.tsx
|
|
1996
2030
|
import { Fragment, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1997
2031
|
var layerStack = [];
|
|
1998
2032
|
var isTop = (self) => layerStack[layerStack.length - 1] === self;
|
|
@@ -2103,9 +2137,8 @@ if (typeof window !== "undefined") {
|
|
|
2103
2137
|
}
|
|
2104
2138
|
function useDialog(panelRef, onClose, closeOnBackProp = false) {
|
|
2105
2139
|
const closeOnBack = closeOnBackProp && (typeof window === "undefined" || window.self === window.top);
|
|
2106
|
-
const onCloseRef =
|
|
2107
|
-
|
|
2108
|
-
useEffect3(() => {
|
|
2140
|
+
const onCloseRef = useLatest(onClose);
|
|
2141
|
+
useEffect4(() => {
|
|
2109
2142
|
const opener = document.activeElement;
|
|
2110
2143
|
const panel = panelRef.current;
|
|
2111
2144
|
const self = {};
|
|
@@ -2191,17 +2224,15 @@ function useDialog(panelRef, onClose, closeOnBackProp = false) {
|
|
|
2191
2224
|
history.back();
|
|
2192
2225
|
}
|
|
2193
2226
|
};
|
|
2194
|
-
}, [panelRef, closeOnBack]);
|
|
2227
|
+
}, [panelRef, closeOnBack, onCloseRef]);
|
|
2195
2228
|
}
|
|
2196
2229
|
function useSheetExit(onClose, canClose) {
|
|
2197
2230
|
const [closing, setClosing] = useState2(false);
|
|
2198
|
-
const closingRef =
|
|
2199
|
-
const timer =
|
|
2200
|
-
const onCloseRef =
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
canCloseRef.current = canClose;
|
|
2204
|
-
useEffect3(() => () => window.clearTimeout(timer.current), []);
|
|
2231
|
+
const closingRef = useRef3(false);
|
|
2232
|
+
const timer = useRef3(0);
|
|
2233
|
+
const onCloseRef = useLatest(onClose);
|
|
2234
|
+
const canCloseRef = useLatest(canClose);
|
|
2235
|
+
useEffect4(() => () => window.clearTimeout(timer.current), []);
|
|
2205
2236
|
const requestClose = useCallback2(() => {
|
|
2206
2237
|
if (closingRef.current) return;
|
|
2207
2238
|
if (closeVetoes.get(onCloseRef.current)?.()) return;
|
|
@@ -2217,24 +2248,21 @@ function useSheetExit(onClose, canClose) {
|
|
|
2217
2248
|
closingRef.current = false;
|
|
2218
2249
|
setClosing(false);
|
|
2219
2250
|
}, SHEET_EXIT_MS);
|
|
2220
|
-
}, []);
|
|
2251
|
+
}, [canCloseRef, onCloseRef]);
|
|
2221
2252
|
const closeNow = useCallback2(() => {
|
|
2222
2253
|
onCloseRef.current();
|
|
2223
|
-
}, []);
|
|
2254
|
+
}, [onCloseRef]);
|
|
2224
2255
|
const isClosing = useCallback2(() => closingRef.current, []);
|
|
2225
|
-
const allowClose = useCallback2(() => !canCloseRef.current || canCloseRef.current(), []);
|
|
2256
|
+
const allowClose = useCallback2(() => !canCloseRef.current || canCloseRef.current(), [canCloseRef]);
|
|
2226
2257
|
return { closing, requestClose, closeNow, isClosing, allowClose };
|
|
2227
2258
|
}
|
|
2228
2259
|
function useSheetSwipe(panelRef, scrimRef, enabled, onDismiss, allow = () => true) {
|
|
2229
|
-
const drag =
|
|
2230
|
-
const timer =
|
|
2231
|
-
const enabledRef =
|
|
2232
|
-
|
|
2233
|
-
const
|
|
2234
|
-
|
|
2235
|
-
const allowRef = useRef2(allow);
|
|
2236
|
-
allowRef.current = allow;
|
|
2237
|
-
useEffect3(() => () => window.clearTimeout(timer.current), []);
|
|
2260
|
+
const drag = useRef3(null);
|
|
2261
|
+
const timer = useRef3(0);
|
|
2262
|
+
const enabledRef = useLatest(enabled);
|
|
2263
|
+
const dismissRef = useLatest(onDismiss);
|
|
2264
|
+
const allowRef = useLatest(allow);
|
|
2265
|
+
useEffect4(() => () => window.clearTimeout(timer.current), []);
|
|
2238
2266
|
const onPointerDown = useCallback2(
|
|
2239
2267
|
(e) => {
|
|
2240
2268
|
if (drag.current || !enabledRef.current()) return;
|
|
@@ -2249,7 +2277,7 @@ function useSheetSwipe(panelRef, scrimRef, enabled, onDismiss, allow = () => tru
|
|
|
2249
2277
|
if (scrimRef.current) scrimRef.current.style.transition = "none";
|
|
2250
2278
|
drag.current = { startY: e.clientY, dy: 0, lastY: e.clientY, lastT: e.timeStamp, v: 0 };
|
|
2251
2279
|
},
|
|
2252
|
-
[panelRef, scrimRef]
|
|
2280
|
+
[enabledRef, panelRef, scrimRef]
|
|
2253
2281
|
);
|
|
2254
2282
|
const onPointerMove = useCallback2(
|
|
2255
2283
|
(e) => {
|
|
@@ -2298,7 +2326,7 @@ function useSheetSwipe(panelRef, scrimRef, enabled, onDismiss, allow = () => tru
|
|
|
2298
2326
|
}, ms);
|
|
2299
2327
|
}
|
|
2300
2328
|
},
|
|
2301
|
-
[panelRef, scrimRef]
|
|
2329
|
+
[allowRef, dismissRef, panelRef, scrimRef]
|
|
2302
2330
|
);
|
|
2303
2331
|
return {
|
|
2304
2332
|
onPointerDown,
|
|
@@ -2360,8 +2388,8 @@ function Modal({
|
|
|
2360
2388
|
className
|
|
2361
2389
|
}) {
|
|
2362
2390
|
const titleId = useId3();
|
|
2363
|
-
const panelRef =
|
|
2364
|
-
const scrimRef =
|
|
2391
|
+
const panelRef = useRef3(null);
|
|
2392
|
+
const scrimRef = useRef3(null);
|
|
2365
2393
|
const { closing, requestClose, closeNow, isClosing, allowClose } = useSheetExit(onClose, canClose);
|
|
2366
2394
|
useDialog(panelRef, requestClose, closeOnBack);
|
|
2367
2395
|
const swipe = useSheetSwipe(panelRef, scrimRef, () => dismissible && !isClosing() && isPhoneViewport(), closeNow, allowClose);
|
|
@@ -2451,8 +2479,8 @@ function Drawer({
|
|
|
2451
2479
|
className
|
|
2452
2480
|
}) {
|
|
2453
2481
|
const titleId = useId3();
|
|
2454
|
-
const panelRef =
|
|
2455
|
-
const scrimRef =
|
|
2482
|
+
const panelRef = useRef3(null);
|
|
2483
|
+
const scrimRef = useRef3(null);
|
|
2456
2484
|
const { closing, requestClose, closeNow, isClosing, allowClose } = useSheetExit(onClose, canClose);
|
|
2457
2485
|
useDialog(panelRef, requestClose, closeOnBack);
|
|
2458
2486
|
const bottom = side === "bottom";
|
|
@@ -2540,12 +2568,16 @@ function ConfirmDialog({
|
|
|
2540
2568
|
onConfirm,
|
|
2541
2569
|
onCancel
|
|
2542
2570
|
}) {
|
|
2543
|
-
const pendingRef =
|
|
2544
|
-
pendingRef.current = pending;
|
|
2571
|
+
const pendingRef = useLatest(pending);
|
|
2545
2572
|
const cancel = useCallback2(() => {
|
|
2546
2573
|
if (!pendingRef.current) onCancel();
|
|
2547
|
-
}, [onCancel]);
|
|
2548
|
-
|
|
2574
|
+
}, [onCancel, pendingRef]);
|
|
2575
|
+
useEffect4(() => {
|
|
2576
|
+
closeVetoes.set(cancel, () => pendingRef.current);
|
|
2577
|
+
return () => {
|
|
2578
|
+
closeVetoes.delete(cancel);
|
|
2579
|
+
};
|
|
2580
|
+
}, [cancel, pendingRef]);
|
|
2549
2581
|
const danger = tone === "danger";
|
|
2550
2582
|
return /* @__PURE__ */ jsx4(
|
|
2551
2583
|
Modal,
|
|
@@ -2603,7 +2635,7 @@ function place(r, w, h, side, align, gap) {
|
|
|
2603
2635
|
}
|
|
2604
2636
|
function useAnchoredPosition(anchor, floating, open, side, align, gap = GAP) {
|
|
2605
2637
|
const [pos, setPos] = useState2(null);
|
|
2606
|
-
|
|
2638
|
+
useLayoutEffect3(() => {
|
|
2607
2639
|
if (!open) {
|
|
2608
2640
|
setPos(null);
|
|
2609
2641
|
return;
|
|
@@ -2660,10 +2692,10 @@ function touchTracker() {
|
|
|
2660
2692
|
};
|
|
2661
2693
|
}
|
|
2662
2694
|
function Tooltip({ tip, children, className, side = "top", as = "span", focusable = true, variant = "default" }) {
|
|
2663
|
-
const triggerRef =
|
|
2695
|
+
const triggerRef = useRef3(null);
|
|
2664
2696
|
const [open, setOpen] = useState2(false);
|
|
2665
2697
|
const id = useId3();
|
|
2666
|
-
|
|
2698
|
+
useEffect4(() => {
|
|
2667
2699
|
const el = triggerRef.current;
|
|
2668
2700
|
if (!el) return;
|
|
2669
2701
|
const touch = touchTracker();
|
|
@@ -2721,7 +2753,7 @@ function FloatingTip({
|
|
|
2721
2753
|
tip,
|
|
2722
2754
|
side = "top"
|
|
2723
2755
|
}) {
|
|
2724
|
-
const tipRef =
|
|
2756
|
+
const tipRef = useRef3(null);
|
|
2725
2757
|
const pos = useAnchoredPosition(anchor, tipRef, true, side, "center");
|
|
2726
2758
|
return createPortal(
|
|
2727
2759
|
/* @__PURE__ */ jsx4(
|
|
@@ -2743,9 +2775,8 @@ function FloatingTip({
|
|
|
2743
2775
|
);
|
|
2744
2776
|
}
|
|
2745
2777
|
function useDismiss(open, panel, anchor, close) {
|
|
2746
|
-
const closeRef =
|
|
2747
|
-
|
|
2748
|
-
useEffect3(() => {
|
|
2778
|
+
const closeRef = useLatest(close);
|
|
2779
|
+
useEffect4(() => {
|
|
2749
2780
|
if (!open) return;
|
|
2750
2781
|
const self = {};
|
|
2751
2782
|
layerStack.push(self);
|
|
@@ -2768,12 +2799,12 @@ function useDismiss(open, panel, anchor, close) {
|
|
|
2768
2799
|
document.removeEventListener("keydown", onKey);
|
|
2769
2800
|
document.removeEventListener("pointerdown", onDown, true);
|
|
2770
2801
|
};
|
|
2771
|
-
}, [open, panel, anchor]);
|
|
2802
|
+
}, [open, panel, anchor, closeRef]);
|
|
2772
2803
|
}
|
|
2773
2804
|
function useReturnFocus(open, panel, anchor) {
|
|
2774
|
-
const wasOpen =
|
|
2775
|
-
const focusWasInside =
|
|
2776
|
-
|
|
2805
|
+
const wasOpen = useRef3(false);
|
|
2806
|
+
const focusWasInside = useRef3(false);
|
|
2807
|
+
useEffect4(() => {
|
|
2777
2808
|
if (!open) return;
|
|
2778
2809
|
const p = panel.current;
|
|
2779
2810
|
const track = () => {
|
|
@@ -2786,7 +2817,7 @@ function useReturnFocus(open, panel, anchor) {
|
|
|
2786
2817
|
p?.removeEventListener("focusout", track);
|
|
2787
2818
|
};
|
|
2788
2819
|
}, [open, panel]);
|
|
2789
|
-
|
|
2820
|
+
useLayoutEffect3(() => {
|
|
2790
2821
|
if (open) {
|
|
2791
2822
|
wasOpen.current = true;
|
|
2792
2823
|
return;
|
|
@@ -2810,18 +2841,16 @@ function Popover({
|
|
|
2810
2841
|
className,
|
|
2811
2842
|
children
|
|
2812
2843
|
}) {
|
|
2813
|
-
const panelRef =
|
|
2844
|
+
const panelRef = useRef3(null);
|
|
2814
2845
|
const pos = useAnchoredPosition(anchor, panelRef, open, side, align);
|
|
2815
|
-
const onOpenChangeRef =
|
|
2816
|
-
|
|
2817
|
-
const outsideRef = useRef2(dismissOnOutside);
|
|
2818
|
-
outsideRef.current = dismissOnOutside;
|
|
2846
|
+
const onOpenChangeRef = useLatest(onOpenChange);
|
|
2847
|
+
const outsideRef = useLatest(dismissOnOutside);
|
|
2819
2848
|
useDismiss(open, panelRef, anchor, (reason) => {
|
|
2820
2849
|
if (reason === "outside" && !outsideRef.current) return;
|
|
2821
2850
|
onOpenChangeRef.current(false, reason);
|
|
2822
2851
|
});
|
|
2823
2852
|
useReturnFocus(open, panelRef, anchor);
|
|
2824
|
-
|
|
2853
|
+
useEffect4(() => {
|
|
2825
2854
|
if (!open) return;
|
|
2826
2855
|
const t = window.setTimeout(() => {
|
|
2827
2856
|
const p = panelRef.current;
|
|
@@ -2874,7 +2903,7 @@ function setRef2(ref, value) {
|
|
|
2874
2903
|
}
|
|
2875
2904
|
function usePhoneViewport(enabled) {
|
|
2876
2905
|
const [phone, setPhone] = useState2(() => enabled && isPhoneViewport());
|
|
2877
|
-
|
|
2906
|
+
useEffect4(() => {
|
|
2878
2907
|
if (!enabled || typeof window.matchMedia !== "function") {
|
|
2879
2908
|
setPhone(false);
|
|
2880
2909
|
return;
|
|
@@ -2887,6 +2916,9 @@ function usePhoneViewport(enabled) {
|
|
|
2887
2916
|
}, [enabled]);
|
|
2888
2917
|
return phone;
|
|
2889
2918
|
}
|
|
2919
|
+
function Cloned({ element, ...props }) {
|
|
2920
|
+
return cloneElement2(element, props);
|
|
2921
|
+
}
|
|
2890
2922
|
function DropdownMenu({
|
|
2891
2923
|
trigger,
|
|
2892
2924
|
align = "start",
|
|
@@ -2902,28 +2934,38 @@ function DropdownMenu({
|
|
|
2902
2934
|
}) {
|
|
2903
2935
|
const [openState, setOpenState] = useState2(defaultOpen);
|
|
2904
2936
|
const open = openProp ?? openState;
|
|
2905
|
-
const triggerRef =
|
|
2906
|
-
const
|
|
2937
|
+
const triggerRef = useRef3(null);
|
|
2938
|
+
const [triggerNode, setTriggerNode] = useState2(null);
|
|
2939
|
+
const triggerPropRef = trigger.props.ref;
|
|
2940
|
+
const attachTrigger = useCallback2(
|
|
2941
|
+
(node) => {
|
|
2942
|
+
triggerRef.current = node;
|
|
2943
|
+
setTriggerNode(node);
|
|
2944
|
+
setRef2(triggerPropRef, node);
|
|
2945
|
+
},
|
|
2946
|
+
[triggerPropRef]
|
|
2947
|
+
);
|
|
2948
|
+
const shown = open && triggerNode != null;
|
|
2949
|
+
const menuRef = useRef3(null);
|
|
2907
2950
|
const menuId = useId3();
|
|
2908
2951
|
const triggerId = useId3();
|
|
2909
|
-
const initial =
|
|
2952
|
+
const initial = useRef3("first");
|
|
2910
2953
|
const asSheet = usePhoneViewport(sheetBelow === "sm");
|
|
2911
|
-
const pos = useAnchoredPosition(triggerRef, menuRef,
|
|
2912
|
-
const onOpenChangeRef =
|
|
2913
|
-
onOpenChangeRef.current = onOpenChange;
|
|
2954
|
+
const pos = useAnchoredPosition(triggerRef, menuRef, shown && !asSheet, side, align, 4);
|
|
2955
|
+
const onOpenChangeRef = useLatest(onOpenChange);
|
|
2914
2956
|
const setOpen = useCallback2(
|
|
2915
2957
|
(next, reason) => {
|
|
2916
2958
|
if (openProp === void 0) setOpenState(next);
|
|
2917
2959
|
onOpenChangeRef.current?.(next, reason);
|
|
2918
2960
|
},
|
|
2919
|
-
[openProp]
|
|
2961
|
+
[onOpenChangeRef, openProp]
|
|
2920
2962
|
);
|
|
2921
2963
|
const close = useCallback2(() => setOpen(false), [setOpen]);
|
|
2922
2964
|
const dismiss = useCallback2((reason) => setOpen(false, reason), [setOpen]);
|
|
2923
|
-
useDismiss(
|
|
2924
|
-
useReturnFocus(
|
|
2925
|
-
|
|
2926
|
-
if (!
|
|
2965
|
+
useDismiss(shown && !asSheet, menuRef, triggerRef, dismiss);
|
|
2966
|
+
useReturnFocus(shown, menuRef, triggerRef);
|
|
2967
|
+
useEffect4(() => {
|
|
2968
|
+
if (!shown) return;
|
|
2927
2969
|
const menu = menuRef.current;
|
|
2928
2970
|
if (!menu) return;
|
|
2929
2971
|
const focusInitial = () => {
|
|
@@ -2943,7 +2985,7 @@ function DropdownMenu({
|
|
|
2943
2985
|
window.clearTimeout(t);
|
|
2944
2986
|
mo.disconnect();
|
|
2945
2987
|
};
|
|
2946
|
-
}, [
|
|
2988
|
+
}, [shown, asSheet]);
|
|
2947
2989
|
function openWith(where) {
|
|
2948
2990
|
initial.current = where;
|
|
2949
2991
|
setOpen(true);
|
|
@@ -2981,30 +3023,31 @@ function DropdownMenu({
|
|
|
2981
3023
|
}
|
|
2982
3024
|
}
|
|
2983
3025
|
const tp = trigger.props;
|
|
2984
|
-
const triggerEl =
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3026
|
+
const triggerEl = /* @__PURE__ */ jsx4(
|
|
3027
|
+
Cloned,
|
|
3028
|
+
{
|
|
3029
|
+
element: trigger,
|
|
3030
|
+
ref: attachTrigger,
|
|
3031
|
+
id: tp.id ?? triggerId,
|
|
3032
|
+
"aria-haspopup": "menu",
|
|
3033
|
+
"aria-expanded": open,
|
|
3034
|
+
"aria-controls": open ? menuId : void 0,
|
|
3035
|
+
onClick: (e) => {
|
|
3036
|
+
tp.onClick?.(e);
|
|
3037
|
+
if (e.defaultPrevented) return;
|
|
3038
|
+
if (open) close();
|
|
3039
|
+
else openWith(e.detail === 0 ? "first" : "menu");
|
|
3040
|
+
},
|
|
3041
|
+
onKeyDown: (e) => {
|
|
3042
|
+
tp.onKeyDown?.(e);
|
|
3043
|
+
if (e.defaultPrevented) return;
|
|
3044
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
3045
|
+
e.preventDefault();
|
|
3046
|
+
openWith(e.key === "ArrowDown" ? "first" : "last");
|
|
3047
|
+
}
|
|
3005
3048
|
}
|
|
3006
3049
|
}
|
|
3007
|
-
|
|
3050
|
+
);
|
|
3008
3051
|
const menuProps = {
|
|
3009
3052
|
ref: menuRef,
|
|
3010
3053
|
id: menuId,
|
|
@@ -3027,7 +3070,7 @@ function DropdownMenu({
|
|
|
3027
3070
|
),
|
|
3028
3071
|
children
|
|
3029
3072
|
}
|
|
3030
|
-
) }) }) :
|
|
3073
|
+
) }) }) : shown ? createPortal(
|
|
3031
3074
|
/* @__PURE__ */ jsx4(MenuContext.Provider, { value: { close }, children: /* @__PURE__ */ jsx4(
|
|
3032
3075
|
"div",
|
|
3033
3076
|
{
|
|
@@ -3045,7 +3088,7 @@ function DropdownMenu({
|
|
|
3045
3088
|
children
|
|
3046
3089
|
}
|
|
3047
3090
|
) }),
|
|
3048
|
-
layerHost(
|
|
3091
|
+
layerHost(triggerNode)
|
|
3049
3092
|
) : null
|
|
3050
3093
|
] });
|
|
3051
3094
|
}
|
|
@@ -3253,9 +3296,8 @@ function isTypingTarget(t) {
|
|
|
3253
3296
|
return tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT" || t.isContentEditable;
|
|
3254
3297
|
}
|
|
3255
3298
|
function useCommandHotkey(open, enabled = true) {
|
|
3256
|
-
const ref =
|
|
3257
|
-
|
|
3258
|
-
useEffect4(() => {
|
|
3299
|
+
const ref = useLatest(open);
|
|
3300
|
+
useEffect5(() => {
|
|
3259
3301
|
if (!enabled) return;
|
|
3260
3302
|
const onKey = (e) => {
|
|
3261
3303
|
if (e.defaultPrevented || e.isComposing) return;
|
|
@@ -3269,7 +3311,7 @@ function useCommandHotkey(open, enabled = true) {
|
|
|
3269
3311
|
};
|
|
3270
3312
|
document.addEventListener("keydown", onKey);
|
|
3271
3313
|
return () => document.removeEventListener("keydown", onKey);
|
|
3272
|
-
}, [enabled]);
|
|
3314
|
+
}, [enabled, ref]);
|
|
3273
3315
|
}
|
|
3274
3316
|
function CommandPalette({
|
|
3275
3317
|
open,
|
|
@@ -3303,16 +3345,15 @@ function PaletteDialog({ onClose, items: items2, placeholder, emptyText, onQuery
|
|
|
3303
3345
|
const uid = useId4();
|
|
3304
3346
|
const listId = `${uid}-list`;
|
|
3305
3347
|
const optionId = (i) => `${uid}-opt-${i}`;
|
|
3306
|
-
const inputRef =
|
|
3307
|
-
const listRef =
|
|
3348
|
+
const inputRef = useRef4(null);
|
|
3349
|
+
const listRef = useRef4(null);
|
|
3308
3350
|
const [query, setQuery] = useState3("");
|
|
3309
3351
|
const [active, setActive] = useState3(0);
|
|
3310
3352
|
const isFn = typeof items2 === "function";
|
|
3311
|
-
const itemsRef =
|
|
3312
|
-
itemsRef.current = items2;
|
|
3353
|
+
const itemsRef = useLatest(items2);
|
|
3313
3354
|
const [dynamic, setDynamic] = useState3([]);
|
|
3314
3355
|
const [pending, setPending] = useState3(isFn);
|
|
3315
|
-
|
|
3356
|
+
useEffect5(() => {
|
|
3316
3357
|
const fn = itemsRef.current;
|
|
3317
3358
|
if (typeof fn !== "function") return;
|
|
3318
3359
|
let stale = false;
|
|
@@ -3343,20 +3384,20 @@ function PaletteDialog({ onClose, items: items2, placeholder, emptyText, onQuery
|
|
|
3343
3384
|
return () => {
|
|
3344
3385
|
stale = true;
|
|
3345
3386
|
};
|
|
3346
|
-
}, [query, isFn]);
|
|
3387
|
+
}, [query, isFn, itemsRef]);
|
|
3347
3388
|
const rows = useMemo(() => {
|
|
3348
3389
|
if (isFn) return dynamic.map((item) => ({ item, marks: matchText(item.label.toLowerCase(), query.trim().toLowerCase())?.idx ?? [] }));
|
|
3349
3390
|
return rankItems(items2, query);
|
|
3350
3391
|
}, [isFn, dynamic, items2, query]);
|
|
3351
3392
|
const groups = useMemo(() => groupRows(rows), [rows]);
|
|
3352
3393
|
const flat = useMemo(() => groups.flatMap((g) => g.rows.map((x) => x.r.item)), [groups]);
|
|
3353
|
-
|
|
3394
|
+
useEffect5(() => {
|
|
3354
3395
|
inputRef.current?.focus();
|
|
3355
3396
|
}, []);
|
|
3356
|
-
|
|
3397
|
+
useEffect5(() => {
|
|
3357
3398
|
setActive(0);
|
|
3358
3399
|
}, [query, flat.length]);
|
|
3359
|
-
|
|
3400
|
+
useEffect5(() => {
|
|
3360
3401
|
document.getElementById(optionId(active))?.scrollIntoView({ block: "nearest" });
|
|
3361
3402
|
}, [active]);
|
|
3362
3403
|
const select = (item) => {
|
|
@@ -3489,10 +3530,10 @@ function PaletteDialog({ onClose, items: items2, placeholder, emptyText, onQuery
|
|
|
3489
3530
|
}
|
|
3490
3531
|
|
|
3491
3532
|
// src/components/theme-toggle.tsx
|
|
3492
|
-
import { useEffect as
|
|
3533
|
+
import { useEffect as useEffect7, useState as useState5 } from "react";
|
|
3493
3534
|
|
|
3494
3535
|
// src/components/segmented.tsx
|
|
3495
|
-
import { useEffect as
|
|
3536
|
+
import { useEffect as useEffect6, useId as useId5, useRef as useRef5, useState as useState4 } from "react";
|
|
3496
3537
|
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
3497
3538
|
var SELECTED = {
|
|
3498
3539
|
accent: "bg-th-accent-soft text-th-accent ring-1 ring-th-accent/40",
|
|
@@ -3507,13 +3548,13 @@ var SIZE2 = {
|
|
|
3507
3548
|
function Segmented({ label, options, value, onChange, size = "sm", block = false, overflow = "scroll", fullWidth = false, className }) {
|
|
3508
3549
|
const fill = block || fullWidth;
|
|
3509
3550
|
const scroll = overflow === "scroll";
|
|
3510
|
-
const groupRef =
|
|
3551
|
+
const groupRef = useRef5(null);
|
|
3511
3552
|
useScrollEdges(groupRef);
|
|
3512
|
-
const refs =
|
|
3513
|
-
const tipAnchor =
|
|
3553
|
+
const refs = useRef5([]);
|
|
3554
|
+
const tipAnchor = useRef5(null);
|
|
3514
3555
|
const [tipAt, setTipAt] = useState4(null);
|
|
3515
3556
|
const tipId = useId5();
|
|
3516
|
-
const touch =
|
|
3557
|
+
const [touch] = useState4(touchTracker);
|
|
3517
3558
|
const showTip = (i) => {
|
|
3518
3559
|
if (options[i]?.tip == null) return;
|
|
3519
3560
|
tipAnchor.current = refs.current[i];
|
|
@@ -3522,7 +3563,7 @@ function Segmented({ label, options, value, onChange, size = "sm", block = false
|
|
|
3522
3563
|
const hideTip = (i) => setTipAt((cur) => cur === i ? null : cur);
|
|
3523
3564
|
const enabled = options.map((o, i) => o.disabled ? -1 : i).filter((i) => i >= 0);
|
|
3524
3565
|
const selected = options.findIndex((o) => o.value === value);
|
|
3525
|
-
|
|
3566
|
+
useEffect6(() => {
|
|
3526
3567
|
const el = selected >= 0 ? refs.current[selected] : null;
|
|
3527
3568
|
if (scroll && el && groupRef.current) revealInRow(groupRef.current, el);
|
|
3528
3569
|
}, [selected, scroll, options.length]);
|
|
@@ -3626,7 +3667,7 @@ function useTheme() {
|
|
|
3626
3667
|
const choice = typeof document === "undefined" ? "system" : getThemeChoice();
|
|
3627
3668
|
return { choice, theme: typeof document === "undefined" ? "dark" : resolveTheme(choice) };
|
|
3628
3669
|
});
|
|
3629
|
-
|
|
3670
|
+
useEffect7(() => onThemeChange((choice, theme) => setState({ choice, theme })), []);
|
|
3630
3671
|
return { ...state, scheme: schemeOf(state.theme), setChoice: setThemeChoice };
|
|
3631
3672
|
}
|
|
3632
3673
|
var MODES = [
|
|
@@ -3849,7 +3890,7 @@ function MoreDots() {
|
|
|
3849
3890
|
] });
|
|
3850
3891
|
}
|
|
3851
3892
|
function BottomNav({ items: items2, more, trailing, hideFrom = "md", label = "Sections", renderLink, className }) {
|
|
3852
|
-
const ref =
|
|
3893
|
+
const ref = useRef6(null);
|
|
3853
3894
|
const visible = useMatches(MAX_QUERY[hideFrom]);
|
|
3854
3895
|
useHeightVar(ref, "--nish-bottom-nav-h", visible);
|
|
3855
3896
|
const pill = (active) => cn(
|
|
@@ -3974,6 +4015,47 @@ function NavRail({ items: items2, tools, footer, showFrom = "md", hideFrom = "lg
|
|
|
3974
4015
|
}
|
|
3975
4016
|
);
|
|
3976
4017
|
}
|
|
4018
|
+
function NavSidebar({ items: items2, collapsed, onCollapsedChange, tools, footer, label = "Sections", renderLink, className }) {
|
|
4019
|
+
return /* @__PURE__ */ jsxs8(
|
|
4020
|
+
"aside",
|
|
4021
|
+
{
|
|
4022
|
+
"aria-label": "Sidebar",
|
|
4023
|
+
className: cn(
|
|
4024
|
+
"flex h-full shrink-0 flex-col border-r border-th-line bg-th-surface py-3 pl-[env(safe-area-inset-left)] transition-[width] duration-200 motion-reduce:transition-none",
|
|
4025
|
+
collapsed ? "w-16" : "w-56",
|
|
4026
|
+
className
|
|
4027
|
+
),
|
|
4028
|
+
children: [
|
|
4029
|
+
tools ? /* @__PURE__ */ jsx8("div", { className: cn("mb-2 flex gap-1 border-b border-th-line pb-2", collapsed ? "flex-col items-center" : "flex-wrap px-3"), children: tools }) : null,
|
|
4030
|
+
/* @__PURE__ */ jsx8("nav", { "aria-label": label, className: cn("flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto", collapsed ? "items-center px-2" : "px-3"), children: items2.map((item) => {
|
|
4031
|
+
const node = renderItem(
|
|
4032
|
+
item,
|
|
4033
|
+
cn(
|
|
4034
|
+
"flex min-h-11 items-center gap-3 rounded-lg border-l-2 text-sm transition-colors",
|
|
4035
|
+
FOCUS,
|
|
4036
|
+
collapsed ? "w-11 justify-center" : "w-full px-3",
|
|
4037
|
+
item.active ? "border-th-accent bg-th-accent-soft font-medium text-th-accent" : "border-transparent text-th-hi2 hover:bg-th-elevated hover:text-th-hi"
|
|
4038
|
+
),
|
|
4039
|
+
/* @__PURE__ */ jsxs8(Fragment5, { children: [
|
|
4040
|
+
/* @__PURE__ */ jsxs8("span", { className: "relative inline-flex size-5 shrink-0 items-center justify-center [&>svg]:size-5", children: [
|
|
4041
|
+
item.icon,
|
|
4042
|
+
/* @__PURE__ */ jsx8(CountBadge, { value: item.badge })
|
|
4043
|
+
] }),
|
|
4044
|
+
/* @__PURE__ */ jsx8("span", { className: collapsed ? "sr-only" : "min-w-0 truncate", children: item.label })
|
|
4045
|
+
] }),
|
|
4046
|
+
renderLink
|
|
4047
|
+
);
|
|
4048
|
+
const tip = collapsed ? item.label : item.hint;
|
|
4049
|
+
return tip ? /* @__PURE__ */ jsx8(Tooltip, { tip, side: "right", focusable: false, className: collapsed ? "block" : "block w-full", children: node }, item.key) : /* @__PURE__ */ jsx8("span", { className: "block w-full", children: node }, item.key);
|
|
4050
|
+
}) }),
|
|
4051
|
+
/* @__PURE__ */ jsxs8("div", { className: cn("mt-3 flex gap-2 border-t border-th-line pt-3", collapsed ? "flex-col items-center" : "items-center justify-between px-3"), children: [
|
|
4052
|
+
footer,
|
|
4053
|
+
/* @__PURE__ */ jsx8(IconButton, { label: collapsed ? "Expand sidebar" : "Collapse sidebar", onClick: () => onCollapsedChange(!collapsed), children: collapsed ? /* @__PURE__ */ jsx8(PanelLeftOpenIcon, { size: 18 }) : /* @__PURE__ */ jsx8(PanelLeftCloseIcon, { size: 18 }) })
|
|
4054
|
+
] })
|
|
4055
|
+
]
|
|
4056
|
+
}
|
|
4057
|
+
);
|
|
4058
|
+
}
|
|
3977
4059
|
function revealInRow(scroller, child) {
|
|
3978
4060
|
const s = scroller.getBoundingClientRect();
|
|
3979
4061
|
const c = child.getBoundingClientRect();
|
|
@@ -3983,18 +4065,19 @@ function revealInRow(scroller, child) {
|
|
|
3983
4065
|
}
|
|
3984
4066
|
var ACTIVE_SELECTOR = '[aria-pressed="true"],[aria-selected="true"],[aria-current]:not([aria-current="false"]),[aria-checked="true"]';
|
|
3985
4067
|
function ScrollRow({ children, bleed = false, fade = true, snap = false, as = "div", label, className }) {
|
|
3986
|
-
const ref =
|
|
4068
|
+
const ref = useRef6(null);
|
|
3987
4069
|
useScrollEdges(ref);
|
|
3988
|
-
const lastActive =
|
|
3989
|
-
|
|
4070
|
+
const lastActive = useRef6(null);
|
|
4071
|
+
useEffect8(() => {
|
|
3990
4072
|
const active = ref.current?.querySelector(ACTIVE_SELECTOR) ?? null;
|
|
3991
4073
|
if (active && active !== lastActive.current) {
|
|
3992
4074
|
revealInRow(ref.current, active);
|
|
3993
4075
|
}
|
|
3994
4076
|
lastActive.current = active;
|
|
3995
4077
|
});
|
|
3996
|
-
|
|
3997
|
-
|
|
4078
|
+
const Tag = as;
|
|
4079
|
+
return /* @__PURE__ */ jsx8(
|
|
4080
|
+
Tag,
|
|
3998
4081
|
{
|
|
3999
4082
|
ref,
|
|
4000
4083
|
"aria-label": label,
|
|
@@ -4004,15 +4087,15 @@ function ScrollRow({ children, bleed = false, fade = true, snap = false, as = "d
|
|
|
4004
4087
|
bleed && "-mx-[var(--nish-page-gutter)] px-[var(--nish-page-gutter)]",
|
|
4005
4088
|
snap && "snap-x snap-mandatory [&>*]:snap-start",
|
|
4006
4089
|
className
|
|
4007
|
-
)
|
|
4008
|
-
|
|
4009
|
-
|
|
4090
|
+
),
|
|
4091
|
+
children
|
|
4092
|
+
}
|
|
4010
4093
|
);
|
|
4011
4094
|
}
|
|
4012
4095
|
function useScrollSpy(ids, { rootMargin = "-45% 0px -50% 0px" } = {}) {
|
|
4013
4096
|
const [active, setActive] = useState6(ids[0] ?? null);
|
|
4014
4097
|
const key = ids.join("\0");
|
|
4015
|
-
|
|
4098
|
+
useEffect8(() => {
|
|
4016
4099
|
const list = key ? key.split("\0") : [];
|
|
4017
4100
|
setActive((cur) => cur != null && list.includes(cur) ? cur : list[0] ?? null);
|
|
4018
4101
|
if (!list.length || typeof IntersectionObserver === "undefined") return;
|
|
@@ -4075,11 +4158,11 @@ function useScrollSpy(ids, { rootMargin = "-45% 0px -50% 0px" } = {}) {
|
|
|
4075
4158
|
return active;
|
|
4076
4159
|
}
|
|
4077
4160
|
function SectionNav({ items: items2, sticky = true, onSelect, updateHash = true, label = "Sections", className }) {
|
|
4078
|
-
const ref =
|
|
4161
|
+
const ref = useRef6(null);
|
|
4079
4162
|
const spy = useScrollSpy(items2.map((i) => i.id));
|
|
4080
4163
|
const [locked, setLocked] = useState6(null);
|
|
4081
4164
|
const active = locked ?? spy;
|
|
4082
|
-
|
|
4165
|
+
useEffect8(() => {
|
|
4083
4166
|
if (locked == null) return;
|
|
4084
4167
|
const release = () => setLocked(null);
|
|
4085
4168
|
const onKey = (e) => {
|
|
@@ -4181,9 +4264,9 @@ function useBreakpoint(bp) {
|
|
|
4181
4264
|
);
|
|
4182
4265
|
}
|
|
4183
4266
|
function ScrollingList({ selected, children, ...rest }) {
|
|
4184
|
-
const ref =
|
|
4267
|
+
const ref = useRef7(null);
|
|
4185
4268
|
useScrollEdges(ref);
|
|
4186
|
-
|
|
4269
|
+
useEffect9(() => {
|
|
4187
4270
|
const el = selected >= 0 ? ref.current?.children[selected] : null;
|
|
4188
4271
|
if (el && ref.current) revealInRow(ref.current, el);
|
|
4189
4272
|
}, [selected]);
|
|
@@ -4223,7 +4306,7 @@ function Tabs({
|
|
|
4223
4306
|
const auto = useId6();
|
|
4224
4307
|
const wide = useBreakpoint(hideFrom);
|
|
4225
4308
|
const base = idBase ?? auto.replace(/:/g, "");
|
|
4226
|
-
const refs =
|
|
4309
|
+
const refs = useRef7([]);
|
|
4227
4310
|
const enabled = items2.map((t, i) => t.disabled ? -1 : i).filter((i) => i >= 0);
|
|
4228
4311
|
const selected = items2.findIndex((t) => t.value === value);
|
|
4229
4312
|
const tabStop = selected >= 0 && !items2[selected].disabled ? selected : enabled[0] ?? -1;
|
|
@@ -4425,7 +4508,7 @@ function ErrorState({
|
|
|
4425
4508
|
}
|
|
4426
4509
|
|
|
4427
4510
|
// src/components/toast.tsx
|
|
4428
|
-
import { useEffect as
|
|
4511
|
+
import { useEffect as useEffect10, useRef as useRef8, useState as useState7, useSyncExternalStore as useSyncExternalStore3 } from "react";
|
|
4429
4512
|
import { createPortal as createPortal2 } from "react-dom";
|
|
4430
4513
|
import { jsx as jsx11, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
4431
4514
|
var items = [];
|
|
@@ -4521,13 +4604,13 @@ function Toaster({ className, offset, offsetUntil = "md" }) {
|
|
|
4521
4604
|
const list = useToasts();
|
|
4522
4605
|
const [polite, setPolite] = useState7({ text: "", seq: 0 });
|
|
4523
4606
|
const [assertive, setAssertive] = useState7({ text: "", seq: 0 });
|
|
4524
|
-
const announced =
|
|
4525
|
-
const timers2 =
|
|
4607
|
+
const announced = useRef8(/* @__PURE__ */ new Set());
|
|
4608
|
+
const timers2 = useRef8({
|
|
4526
4609
|
queue: { polite: [], assertive: [] },
|
|
4527
4610
|
flush: {},
|
|
4528
4611
|
clear: {}
|
|
4529
4612
|
});
|
|
4530
|
-
|
|
4613
|
+
useEffect10(() => {
|
|
4531
4614
|
const t = timers2.current;
|
|
4532
4615
|
for (const item of list) {
|
|
4533
4616
|
if (announced.current.has(item.id)) continue;
|
|
@@ -4552,7 +4635,7 @@ function Toaster({ className, offset, offsetUntil = "md" }) {
|
|
|
4552
4635
|
if (!live.has(id)) announced.current.delete(id);
|
|
4553
4636
|
});
|
|
4554
4637
|
}, [list]);
|
|
4555
|
-
|
|
4638
|
+
useEffect10(() => {
|
|
4556
4639
|
const t = timers2.current;
|
|
4557
4640
|
return () => {
|
|
4558
4641
|
clearTimeout(t.flush.polite);
|
|
@@ -4593,8 +4676,8 @@ var SWIPE_DISMISS_FRACTION = 0.35;
|
|
|
4593
4676
|
var SWIPE_DISMISS_VELOCITY = 0.5;
|
|
4594
4677
|
var SWIPE_SLOP = 8;
|
|
4595
4678
|
function ToastCard({ t }) {
|
|
4596
|
-
const ref =
|
|
4597
|
-
const drag =
|
|
4679
|
+
const ref = useRef8(null);
|
|
4680
|
+
const drag = useRef8(null);
|
|
4598
4681
|
const setOffset = (dx, width) => {
|
|
4599
4682
|
const el = ref.current;
|
|
4600
4683
|
if (!el) return;
|
|
@@ -4709,10 +4792,35 @@ function ToastCard({ t }) {
|
|
|
4709
4792
|
import {
|
|
4710
4793
|
createContext as createContext3,
|
|
4711
4794
|
useContext as useContext3,
|
|
4712
|
-
useEffect as
|
|
4713
|
-
useRef as
|
|
4795
|
+
useEffect as useEffect11,
|
|
4796
|
+
useRef as useRef9,
|
|
4714
4797
|
useState as useState8
|
|
4715
4798
|
} from "react";
|
|
4799
|
+
|
|
4800
|
+
// src/sparkline-path.ts
|
|
4801
|
+
function sparklineGeometry(values, width, height, min, max) {
|
|
4802
|
+
const nums = values.filter((v) => v != null && Number.isFinite(v));
|
|
4803
|
+
const empty = nums.length === 0;
|
|
4804
|
+
const lo = min ?? (empty ? 0 : Math.min(...nums));
|
|
4805
|
+
const hi = max ?? (empty ? 1 : Math.max(...nums));
|
|
4806
|
+
const pad = 2;
|
|
4807
|
+
const x = (i) => values.length <= 1 ? width / 2 : i / (values.length - 1) * width;
|
|
4808
|
+
const y = (v) => hi === lo ? height / 2 : pad + (1 - (v - lo) / (hi - lo)) * (height - 2 * pad);
|
|
4809
|
+
const runs = [];
|
|
4810
|
+
let run = [];
|
|
4811
|
+
values.forEach((v, i) => {
|
|
4812
|
+
if (v == null || !Number.isFinite(v)) {
|
|
4813
|
+
if (run.length) runs.push(run);
|
|
4814
|
+
run = [];
|
|
4815
|
+
} else run.push({ x: x(i), y: y(v) });
|
|
4816
|
+
});
|
|
4817
|
+
if (run.length) runs.push(run);
|
|
4818
|
+
const line = (r) => r.length === 1 ? `M${r[0].x},${r[0].y}h0` : r.map((p, i) => `${i ? "L" : "M"}${p.x},${p.y}`).join("");
|
|
4819
|
+
const area = (r) => r.length < 2 ? "" : `${line(r)}L${r[r.length - 1].x},${height}L${r[0].x},${height}Z`;
|
|
4820
|
+
return { empty, lines: runs.map(line), areas: runs.map(area), baseline: `M0,${height / 2}H${width}` };
|
|
4821
|
+
}
|
|
4822
|
+
|
|
4823
|
+
// src/components/display.tsx
|
|
4716
4824
|
import { Fragment as Fragment6, jsx as jsx12, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
4717
4825
|
function Svg3({ size = 16, children, ...rest }) {
|
|
4718
4826
|
return /* @__PURE__ */ jsx12(
|
|
@@ -5028,24 +5136,7 @@ function Sparkline({
|
|
|
5028
5136
|
max,
|
|
5029
5137
|
className
|
|
5030
5138
|
}) {
|
|
5031
|
-
const
|
|
5032
|
-
const empty = nums.length === 0;
|
|
5033
|
-
const lo = min ?? (empty ? 0 : Math.min(...nums));
|
|
5034
|
-
const hi = max ?? (empty ? 1 : Math.max(...nums));
|
|
5035
|
-
const pad = 2;
|
|
5036
|
-
const x = (i) => values.length <= 1 ? width / 2 : i / (values.length - 1) * width;
|
|
5037
|
-
const y = (v) => hi === lo ? height / 2 : pad + (1 - (v - lo) / (hi - lo)) * (height - 2 * pad);
|
|
5038
|
-
const runs = [];
|
|
5039
|
-
let run = [];
|
|
5040
|
-
values.forEach((v, i) => {
|
|
5041
|
-
if (v == null || !Number.isFinite(v)) {
|
|
5042
|
-
if (run.length) runs.push(run);
|
|
5043
|
-
run = [];
|
|
5044
|
-
} else run.push({ x: x(i), y: y(v) });
|
|
5045
|
-
});
|
|
5046
|
-
if (run.length) runs.push(run);
|
|
5047
|
-
const line = (r) => r.length === 1 ? `M${r[0].x},${r[0].y}h0` : r.map((p, i) => `${i ? "L" : "M"}${p.x},${p.y}`).join("");
|
|
5048
|
-
const area = (r) => r.length < 2 ? "" : `${line(r)}L${r[r.length - 1].x},${height}L${r[0].x},${height}Z`;
|
|
5139
|
+
const { empty, lines, areas, baseline } = sparklineGeometry(values, width, height, min, max);
|
|
5049
5140
|
return /* @__PURE__ */ jsx12(
|
|
5050
5141
|
"svg",
|
|
5051
5142
|
{
|
|
@@ -5059,18 +5150,18 @@ function Sparkline({
|
|
|
5059
5150
|
children: empty ? /* @__PURE__ */ jsx12(
|
|
5060
5151
|
"path",
|
|
5061
5152
|
{
|
|
5062
|
-
d:
|
|
5153
|
+
d: baseline,
|
|
5063
5154
|
stroke: "currentColor",
|
|
5064
5155
|
strokeWidth: 1.5,
|
|
5065
5156
|
strokeDasharray: "3 3",
|
|
5066
5157
|
vectorEffect: "non-scaling-stroke"
|
|
5067
5158
|
}
|
|
5068
5159
|
) : /* @__PURE__ */ jsxs12(Fragment6, { children: [
|
|
5069
|
-
fill ?
|
|
5070
|
-
|
|
5160
|
+
fill ? areas.map((d, i) => /* @__PURE__ */ jsx12("path", { d, fill: "currentColor", fillOpacity: 0.15 }, `a${i}`)) : null,
|
|
5161
|
+
lines.map((d, i) => /* @__PURE__ */ jsx12(
|
|
5071
5162
|
"path",
|
|
5072
5163
|
{
|
|
5073
|
-
d
|
|
5164
|
+
d,
|
|
5074
5165
|
fill: "none",
|
|
5075
5166
|
stroke: "currentColor",
|
|
5076
5167
|
strokeWidth: 1.5,
|
|
@@ -5185,8 +5276,8 @@ function CopyButton({
|
|
|
5185
5276
|
className
|
|
5186
5277
|
}) {
|
|
5187
5278
|
const [copied, setCopied] = useState8(false);
|
|
5188
|
-
const timer =
|
|
5189
|
-
|
|
5279
|
+
const timer = useRef9(null);
|
|
5280
|
+
useEffect11(() => () => {
|
|
5190
5281
|
if (timer.current) clearTimeout(timer.current);
|
|
5191
5282
|
}, []);
|
|
5192
5283
|
const onClick = async () => {
|
|
@@ -5215,7 +5306,7 @@ function PageHeader({
|
|
|
5215
5306
|
collapseWhenStuck = true,
|
|
5216
5307
|
className
|
|
5217
5308
|
}) {
|
|
5218
|
-
const ref =
|
|
5309
|
+
const ref = useRef9(null);
|
|
5219
5310
|
const stuck = useStuck(ref) && sticky;
|
|
5220
5311
|
const collapsed = stuck && collapseWhenStuck;
|
|
5221
5312
|
return /* @__PURE__ */ jsxs12(
|
|
@@ -5263,6 +5354,7 @@ function MoreVerticalIcon({ size = 18 }) {
|
|
|
5263
5354
|
function AppHeader({
|
|
5264
5355
|
name,
|
|
5265
5356
|
icon,
|
|
5357
|
+
brand,
|
|
5266
5358
|
hubHref = "https://nish.software",
|
|
5267
5359
|
actions,
|
|
5268
5360
|
nav,
|
|
@@ -5277,11 +5369,11 @@ function AppHeader({
|
|
|
5277
5369
|
overflowActions,
|
|
5278
5370
|
className
|
|
5279
5371
|
}) {
|
|
5280
|
-
const ref =
|
|
5372
|
+
const ref = useRef9(null);
|
|
5281
5373
|
useHeightVar(ref, "--nish-header-h", sticky);
|
|
5282
5374
|
const stuck = useStuck(ref) && sticky;
|
|
5283
|
-
const inlineActionsRef =
|
|
5284
|
-
|
|
5375
|
+
const inlineActionsRef = useRef9(null);
|
|
5376
|
+
useEffect11(() => {
|
|
5285
5377
|
inlineActionsRef.current?.querySelectorAll('[role="menuitem"]').forEach((el) => {
|
|
5286
5378
|
el.removeAttribute("role");
|
|
5287
5379
|
el.tabIndex = el.getAttribute("aria-disabled") === "true" ? -1 : 0;
|
|
@@ -5329,7 +5421,10 @@ function AppHeader({
|
|
|
5329
5421
|
]
|
|
5330
5422
|
}
|
|
5331
5423
|
),
|
|
5332
|
-
|
|
5424
|
+
brand != null ? /* @__PURE__ */ jsxs12("div", { className: "flex min-w-0 items-center", children: [
|
|
5425
|
+
/* @__PURE__ */ jsx12("span", { className: "sr-only", children: name }),
|
|
5426
|
+
brand
|
|
5427
|
+
] }) : homeHref != null ? /* @__PURE__ */ jsx12("a", { href: homeHref, className: cn(markClass, "min-h-11 min-w-11 rounded-lg", hideName && "max-sm:justify-center"), children: mark }) : /* @__PURE__ */ jsx12("span", { className: markClass, children: mark }),
|
|
5333
5428
|
/* @__PURE__ */ jsxs12("div", { className: "ml-auto flex shrink-0 items-center gap-2", children: [
|
|
5334
5429
|
actions,
|
|
5335
5430
|
overflowActions ? /* @__PURE__ */ jsxs12(Fragment6, { children: [
|
|
@@ -5420,7 +5515,7 @@ function ChartLegend({ items: items2, marker = "line", label = "Legend", classNa
|
|
|
5420
5515
|
import {
|
|
5421
5516
|
createContext as createContext4,
|
|
5422
5517
|
useContext as useContext4,
|
|
5423
|
-
useRef as
|
|
5518
|
+
useRef as useRef10
|
|
5424
5519
|
} from "react";
|
|
5425
5520
|
import { jsx as jsx13, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
5426
5521
|
var ALIGN = { left: "text-left", center: "text-center", right: "text-right" };
|
|
@@ -5476,7 +5571,7 @@ function TableWrap({
|
|
|
5476
5571
|
children,
|
|
5477
5572
|
...rest
|
|
5478
5573
|
}) {
|
|
5479
|
-
const ref =
|
|
5574
|
+
const ref = useRef10(null);
|
|
5480
5575
|
useScrollEdges(ref);
|
|
5481
5576
|
const css = {
|
|
5482
5577
|
// With a pinned first column the left fade would wash it out, so only the right edge fades.
|
|
@@ -5567,14 +5662,14 @@ function Tr({ tone, interactive = false, muted = false, className, ...rest }) {
|
|
|
5567
5662
|
// src/components/layout.tsx
|
|
5568
5663
|
import {
|
|
5569
5664
|
useCallback as useCallback3,
|
|
5570
|
-
useEffect as
|
|
5571
|
-
useRef as
|
|
5665
|
+
useEffect as useEffect12,
|
|
5666
|
+
useRef as useRef11,
|
|
5572
5667
|
useState as useState9,
|
|
5573
5668
|
useSyncExternalStore as useSyncExternalStore4
|
|
5574
5669
|
} from "react";
|
|
5575
5670
|
import { jsx as jsx14, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
5576
5671
|
function StickyBar({ children, top = "var(--nish-header-h, 0px)", elevate = true, as = "div", className }) {
|
|
5577
|
-
const ref =
|
|
5672
|
+
const ref = useRef11(null);
|
|
5578
5673
|
const stuck = useStuck(ref);
|
|
5579
5674
|
useHeightVar(ref, "--nish-sticky-extra");
|
|
5580
5675
|
const Tag = as;
|
|
@@ -5593,7 +5688,7 @@ function StickyBar({ children, top = "var(--nish-header-h, 0px)", elevate = true
|
|
|
5593
5688
|
);
|
|
5594
5689
|
}
|
|
5595
5690
|
function StickyActionBar({ open, message, primary, secondary, label = "Actions", className }) {
|
|
5596
|
-
const ref =
|
|
5691
|
+
const ref = useRef11(null);
|
|
5597
5692
|
useHeightVar(ref, "--nish-bottom-bar-h", open);
|
|
5598
5693
|
if (!open) return null;
|
|
5599
5694
|
return /* @__PURE__ */ jsxs14(
|
|
@@ -5622,7 +5717,7 @@ function StickyActionBar({ open, message, primary, secondary, label = "Actions",
|
|
|
5622
5717
|
}
|
|
5623
5718
|
function LoadingBar({ active, delayMs = 200, top = "var(--nish-header-h, 0px)", className }) {
|
|
5624
5719
|
const [shown, setShown] = useState9(false);
|
|
5625
|
-
|
|
5720
|
+
useEffect12(() => {
|
|
5626
5721
|
if (!active) {
|
|
5627
5722
|
setShown(false);
|
|
5628
5723
|
return;
|
|
@@ -5678,8 +5773,8 @@ function ConnectionBanner({
|
|
|
5678
5773
|
const online = useOnline();
|
|
5679
5774
|
const [reachable, setReachable] = useState9(true);
|
|
5680
5775
|
const [retrying, setRetrying] = useState9(false);
|
|
5681
|
-
const probeRef =
|
|
5682
|
-
|
|
5776
|
+
const probeRef = useRef11(null);
|
|
5777
|
+
useEffect12(() => {
|
|
5683
5778
|
if (!healthUrl) {
|
|
5684
5779
|
probeRef.current = null;
|
|
5685
5780
|
setReachable(true);
|
|
@@ -5760,16 +5855,16 @@ function ConnectionBanner({
|
|
|
5760
5855
|
|
|
5761
5856
|
// src/components/data.tsx
|
|
5762
5857
|
import {
|
|
5763
|
-
useEffect as
|
|
5858
|
+
useEffect as useEffect14,
|
|
5764
5859
|
useId as useId7,
|
|
5765
|
-
useLayoutEffect as
|
|
5860
|
+
useLayoutEffect as useLayoutEffect4,
|
|
5766
5861
|
useMemo as useMemo2,
|
|
5767
|
-
useRef as
|
|
5862
|
+
useRef as useRef13,
|
|
5768
5863
|
useState as useState11
|
|
5769
5864
|
} from "react";
|
|
5770
5865
|
|
|
5771
5866
|
// src/components/hooks.tsx
|
|
5772
|
-
import { useCallback as useCallback4, useEffect as
|
|
5867
|
+
import { useCallback as useCallback4, useEffect as useEffect13, useRef as useRef12, useState as useState10, useSyncExternalStore as useSyncExternalStore5 } from "react";
|
|
5773
5868
|
|
|
5774
5869
|
// src/format.ts
|
|
5775
5870
|
var DASH = "\u2013";
|
|
@@ -5881,7 +5976,7 @@ function useBreakpoint2() {
|
|
|
5881
5976
|
}
|
|
5882
5977
|
function useDocumentTitle(title, o = {}) {
|
|
5883
5978
|
const app = o.app;
|
|
5884
|
-
|
|
5979
|
+
useEffect13(() => {
|
|
5885
5980
|
if (typeof document === "undefined") return;
|
|
5886
5981
|
const next = title && app ? `${title} \xB7 ${app}` : title || app;
|
|
5887
5982
|
if (!next) return;
|
|
@@ -5894,7 +5989,7 @@ function useDocumentTitle(title, o = {}) {
|
|
|
5894
5989
|
}
|
|
5895
5990
|
function useNow(intervalMs = 3e4) {
|
|
5896
5991
|
const [now, setNow] = useState10(() => Date.now());
|
|
5897
|
-
|
|
5992
|
+
useEffect13(() => {
|
|
5898
5993
|
if (typeof document === "undefined") return;
|
|
5899
5994
|
let id;
|
|
5900
5995
|
const start = () => {
|
|
@@ -5931,15 +6026,13 @@ function readStored(key, initial, raw) {
|
|
|
5931
6026
|
}
|
|
5932
6027
|
function useLocalStorage(key, initial, o = {}) {
|
|
5933
6028
|
const raw = !!o.raw;
|
|
5934
|
-
const initialRef =
|
|
5935
|
-
initialRef.current = initial;
|
|
6029
|
+
const initialRef = useLatest(initial);
|
|
5936
6030
|
const [value, setValueState] = useState10(
|
|
5937
6031
|
() => typeof window === "undefined" ? initial : readStored(key, initial, raw)
|
|
5938
6032
|
);
|
|
5939
|
-
const valueRef =
|
|
5940
|
-
|
|
5941
|
-
|
|
5942
|
-
useEffect12(() => {
|
|
6033
|
+
const valueRef = useLatest(value);
|
|
6034
|
+
const instanceRef = useRef12({});
|
|
6035
|
+
useEffect13(() => {
|
|
5943
6036
|
const sync = () => setValueState(readStored(key, initialRef.current, raw));
|
|
5944
6037
|
sync();
|
|
5945
6038
|
const onStorage = (e) => {
|
|
@@ -5955,7 +6048,7 @@ function useLocalStorage(key, initial, o = {}) {
|
|
|
5955
6048
|
window.removeEventListener("storage", onStorage);
|
|
5956
6049
|
window.removeEventListener(LOCAL_EVENT, onLocal);
|
|
5957
6050
|
};
|
|
5958
|
-
}, [key, raw]);
|
|
6051
|
+
}, [initialRef, key, raw]);
|
|
5959
6052
|
const setValue = useCallback4(
|
|
5960
6053
|
(next) => {
|
|
5961
6054
|
const resolved = typeof next === "function" ? next(valueRef.current) : next;
|
|
@@ -5970,7 +6063,7 @@ function useLocalStorage(key, initial, o = {}) {
|
|
|
5970
6063
|
} catch {
|
|
5971
6064
|
}
|
|
5972
6065
|
},
|
|
5973
|
-
[key, raw]
|
|
6066
|
+
[key, raw, valueRef]
|
|
5974
6067
|
);
|
|
5975
6068
|
return [value, setValue];
|
|
5976
6069
|
}
|
|
@@ -6263,7 +6356,7 @@ function Favicon({ url, size = 16, label, className }) {
|
|
|
6263
6356
|
const host = hostnameOf(url);
|
|
6264
6357
|
const [failed, setFailed] = useState11(false);
|
|
6265
6358
|
const [loaded, setLoaded] = useState11(false);
|
|
6266
|
-
|
|
6359
|
+
useEffect14(() => {
|
|
6267
6360
|
setFailed(false);
|
|
6268
6361
|
setLoaded(false);
|
|
6269
6362
|
}, [host]);
|
|
@@ -6345,9 +6438,9 @@ function LinkCard({
|
|
|
6345
6438
|
external = false,
|
|
6346
6439
|
className
|
|
6347
6440
|
}) {
|
|
6348
|
-
const ref =
|
|
6441
|
+
const ref = useRef13(null);
|
|
6349
6442
|
const [wide, setWide] = useState11(false);
|
|
6350
|
-
|
|
6443
|
+
useLayoutEffect4(() => {
|
|
6351
6444
|
if (layout !== "auto") return;
|
|
6352
6445
|
const parent = ref.current?.parentElement;
|
|
6353
6446
|
if (!parent) return;
|
|
@@ -6435,10 +6528,10 @@ function AsyncPanel({ status, skeleton, error, empty, children, className }) {
|
|
|
6435
6528
|
}
|
|
6436
6529
|
|
|
6437
6530
|
// src/components/charts.tsx
|
|
6438
|
-
import { useCallback as useCallback5, useEffect as
|
|
6531
|
+
import { useCallback as useCallback5, useEffect as useEffect16, useId as useId8, useMemo as useMemo3, useRef as useRef14, useState as useState13 } from "react";
|
|
6439
6532
|
|
|
6440
6533
|
// src/chart.ts
|
|
6441
|
-
import { useEffect as
|
|
6534
|
+
import { useEffect as useEffect15, useState as useState12 } from "react";
|
|
6442
6535
|
function seriesColor(i) {
|
|
6443
6536
|
const n = (Math.trunc(i) % 8 + 8) % 8;
|
|
6444
6537
|
return `var(--nish-chart-${n + 1})`;
|
|
@@ -6470,7 +6563,7 @@ function toneColor(tone, index) {
|
|
|
6470
6563
|
function useWidth() {
|
|
6471
6564
|
const [el, setEl] = useState13(null);
|
|
6472
6565
|
const [width, setWidth] = useState13(0);
|
|
6473
|
-
|
|
6566
|
+
useEffect16(() => {
|
|
6474
6567
|
if (!el) {
|
|
6475
6568
|
setWidth(0);
|
|
6476
6569
|
return;
|
|
@@ -6485,7 +6578,7 @@ function useWidth() {
|
|
|
6485
6578
|
}
|
|
6486
6579
|
function useCoarsePointer() {
|
|
6487
6580
|
const [coarse, setCoarse] = useState13(false);
|
|
6488
|
-
|
|
6581
|
+
useEffect16(() => {
|
|
6489
6582
|
if (typeof window === "undefined" || !window.matchMedia) return;
|
|
6490
6583
|
const mq = window.matchMedia("(pointer: coarse)");
|
|
6491
6584
|
const update = () => setCoarse(mq.matches);
|
|
@@ -6522,7 +6615,7 @@ function LineChart({
|
|
|
6522
6615
|
const [wrapRef, width, wrapEl] = useWidth();
|
|
6523
6616
|
const gradId = `nish-area-${useId8().replace(/[^a-zA-Z0-9]/g, "")}`;
|
|
6524
6617
|
const [active, setActive] = useState13(null);
|
|
6525
|
-
const fromKey =
|
|
6618
|
+
const fromKey = useRef14(false);
|
|
6526
6619
|
const lines = useMemo3(() => series ?? (data ? [{ label, tone, points: data }] : []), [series, data, label, tone]);
|
|
6527
6620
|
const xs = useMemo3(() => {
|
|
6528
6621
|
const set = /* @__PURE__ */ new Set();
|
|
@@ -6558,7 +6651,7 @@ function LineChart({
|
|
|
6558
6651
|
const xMax = xs[xs.length - 1];
|
|
6559
6652
|
return { xMin, xMax: xMax === xMin ? xMin + 1 : xMax, yMin, yMax };
|
|
6560
6653
|
}, [lines, xs, baseline]);
|
|
6561
|
-
|
|
6654
|
+
useEffect16(() => {
|
|
6562
6655
|
if (active == null) return;
|
|
6563
6656
|
const onDown = (e) => {
|
|
6564
6657
|
if (wrapEl && !wrapEl.contains(e.target)) setActive(null);
|
|
@@ -6823,10 +6916,10 @@ function RangeBar({ min, max, low, high, current, className }) {
|
|
|
6823
6916
|
|
|
6824
6917
|
// src/components/flow.tsx
|
|
6825
6918
|
import {
|
|
6826
|
-
useEffect as
|
|
6827
|
-
useLayoutEffect as
|
|
6919
|
+
useEffect as useEffect17,
|
|
6920
|
+
useLayoutEffect as useLayoutEffect5,
|
|
6828
6921
|
useMemo as useMemo4,
|
|
6829
|
-
useRef as
|
|
6922
|
+
useRef as useRef15,
|
|
6830
6923
|
useState as useState14
|
|
6831
6924
|
} from "react";
|
|
6832
6925
|
import { Fragment as Fragment8, jsx as jsx18, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
@@ -6846,8 +6939,8 @@ function warnDev(message) {
|
|
|
6846
6939
|
}
|
|
6847
6940
|
}
|
|
6848
6941
|
function useTransitionFx(value, ref, pick) {
|
|
6849
|
-
const prev =
|
|
6850
|
-
|
|
6942
|
+
const prev = useRef15(value);
|
|
6943
|
+
useLayoutEffect5(() => {
|
|
6851
6944
|
const from = prev.current;
|
|
6852
6945
|
prev.current = value;
|
|
6853
6946
|
if (from === value) return;
|
|
@@ -6866,17 +6959,17 @@ function useTransitionFx(value, ref, pick) {
|
|
|
6866
6959
|
}, [value, ref, pick]);
|
|
6867
6960
|
}
|
|
6868
6961
|
function useFreshIds(ids, skipFirst) {
|
|
6869
|
-
const
|
|
6870
|
-
const
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
});
|
|
6879
|
-
return fresh
|
|
6962
|
+
const key = ids.join("\n");
|
|
6963
|
+
const [seen, setSeen] = useState14(() => ({
|
|
6964
|
+
key,
|
|
6965
|
+
known: new Set(ids),
|
|
6966
|
+
fresh: new Set(skipFirst ? [] : ids)
|
|
6967
|
+
}));
|
|
6968
|
+
if (seen.key === key) return seen.fresh;
|
|
6969
|
+
const fresh = new Set([...seen.fresh].filter((id) => ids.includes(id)));
|
|
6970
|
+
for (const id of ids) if (!seen.known.has(id)) fresh.add(id);
|
|
6971
|
+
setSeen({ key, known: new Set(ids), fresh });
|
|
6972
|
+
return fresh;
|
|
6880
6973
|
}
|
|
6881
6974
|
function CheckSvg({ size, className }) {
|
|
6882
6975
|
return /* @__PURE__ */ jsx18(
|
|
@@ -6936,7 +7029,7 @@ function StepRow({
|
|
|
6936
7029
|
last,
|
|
6937
7030
|
sweeping
|
|
6938
7031
|
}) {
|
|
6939
|
-
const nodeRef =
|
|
7032
|
+
const nodeRef = useRef15(null);
|
|
6940
7033
|
useTransitionFx(step.status, nodeRef, pickStepFx);
|
|
6941
7034
|
const { status } = step;
|
|
6942
7035
|
return /* @__PURE__ */ jsxs17(
|
|
@@ -7004,9 +7097,9 @@ function StepRow({
|
|
|
7004
7097
|
}
|
|
7005
7098
|
function FlowSteps({ steps, orientation = "auto", label = "Progress", className }) {
|
|
7006
7099
|
const allDone = steps.length > 0 && steps.every((s) => s.status === "done");
|
|
7007
|
-
const prevAll =
|
|
7100
|
+
const prevAll = useRef15(null);
|
|
7008
7101
|
const [sweeping, setSweeping] = useState14(false);
|
|
7009
|
-
|
|
7102
|
+
useLayoutEffect5(() => {
|
|
7010
7103
|
const was = prevAll.current;
|
|
7011
7104
|
prevAll.current = allDone;
|
|
7012
7105
|
if (!allDone) {
|
|
@@ -7072,7 +7165,7 @@ function TickerText({ text, as = "span", className }) {
|
|
|
7072
7165
|
setState(cur);
|
|
7073
7166
|
}
|
|
7074
7167
|
const animating = cur.prev !== null;
|
|
7075
|
-
|
|
7168
|
+
useEffect17(() => {
|
|
7076
7169
|
if (!animating) return;
|
|
7077
7170
|
const timer = setTimeout(() => setState((s) => s.prev === null ? s : { ...s, prev: null }), 300);
|
|
7078
7171
|
return () => clearTimeout(timer);
|
|
@@ -7131,7 +7224,7 @@ function AgentIcon({ state }) {
|
|
|
7131
7224
|
return /* @__PURE__ */ jsx18("span", { className: "nish-flow-agent-icon grid size-5 shrink-0 place-items-center", children: /* @__PURE__ */ jsx18("span", { className: "size-4 rounded-full border-2 border-dashed border-th-ghost" }) });
|
|
7132
7225
|
}
|
|
7133
7226
|
function AgentNode({ label, state, model, activity, meta, onClick, className }) {
|
|
7134
|
-
const ref =
|
|
7227
|
+
const ref = useRef15(null);
|
|
7135
7228
|
useTransitionFx(state, ref, pickAgentFx);
|
|
7136
7229
|
const aria = `${label}: ${STATE_WORD[state]}`;
|
|
7137
7230
|
const classes = cn(
|
|
@@ -7348,13 +7441,12 @@ function AnimatedList({
|
|
|
7348
7441
|
setState(current);
|
|
7349
7442
|
}
|
|
7350
7443
|
const entries = current.entries;
|
|
7351
|
-
const els =
|
|
7352
|
-
const rects =
|
|
7353
|
-
const anims =
|
|
7354
|
-
const
|
|
7355
|
-
const
|
|
7356
|
-
|
|
7357
|
-
useEffect16(() => {
|
|
7444
|
+
const els = useRef15(/* @__PURE__ */ new Map());
|
|
7445
|
+
const rects = useRef15(/* @__PURE__ */ new Map());
|
|
7446
|
+
const anims = useRef15(/* @__PURE__ */ new Map());
|
|
7447
|
+
const lastKeys = useRef15(null);
|
|
7448
|
+
const timers2 = useRef15(/* @__PURE__ */ new Map());
|
|
7449
|
+
useEffect17(() => {
|
|
7358
7450
|
const wanted = /* @__PURE__ */ new Set();
|
|
7359
7451
|
for (const e of entries) {
|
|
7360
7452
|
if (e.phase === "idle") continue;
|
|
@@ -7387,14 +7479,14 @@ function AnimatedList({
|
|
|
7387
7479
|
}
|
|
7388
7480
|
});
|
|
7389
7481
|
}, [entries, exitMs]);
|
|
7390
|
-
|
|
7482
|
+
useEffect17(
|
|
7391
7483
|
() => () => {
|
|
7392
7484
|
timers2.current.forEach((timer) => clearTimeout(timer));
|
|
7393
7485
|
timers2.current.clear();
|
|
7394
7486
|
},
|
|
7395
7487
|
[]
|
|
7396
7488
|
);
|
|
7397
|
-
|
|
7489
|
+
useLayoutEffect5(() => {
|
|
7398
7490
|
const next = /* @__PURE__ */ new Map();
|
|
7399
7491
|
els.current.forEach((el, k) => next.set(k, { x: el.offsetLeft, y: el.offsetTop }));
|
|
7400
7492
|
const keyList = entries.map((e) => e.key).join("\n");
|
|
@@ -7407,9 +7499,6 @@ function AnimatedList({
|
|
|
7407
7499
|
anims.current.delete(k);
|
|
7408
7500
|
}
|
|
7409
7501
|
});
|
|
7410
|
-
refCbs.current.forEach((_, k) => {
|
|
7411
|
-
if (!live.has(k)) refCbs.current.delete(k);
|
|
7412
|
-
});
|
|
7413
7502
|
const active = typeof document !== "undefined" ? document.activeElement : null;
|
|
7414
7503
|
if (active) {
|
|
7415
7504
|
const ei = entries.findIndex((e) => e.phase === "exit" && els.current.get(e.key)?.contains(active));
|
|
@@ -7450,23 +7539,18 @@ function AnimatedList({
|
|
|
7450
7539
|
}
|
|
7451
7540
|
rects.current = next;
|
|
7452
7541
|
}, [entries, reduced]);
|
|
7453
|
-
const refFor = (key) => {
|
|
7454
|
-
let cb = refCbs.current.get(key);
|
|
7455
|
-
if (!cb) {
|
|
7456
|
-
cb = (el) => {
|
|
7457
|
-
if (el) els.current.set(key, el);
|
|
7458
|
-
else els.current.delete(key);
|
|
7459
|
-
};
|
|
7460
|
-
refCbs.current.set(key, cb);
|
|
7461
|
-
}
|
|
7462
|
-
return cb;
|
|
7463
|
-
};
|
|
7464
7542
|
const Root = as;
|
|
7465
7543
|
const Item = as === "div" ? "div" : "li";
|
|
7466
7544
|
return /* @__PURE__ */ jsx18(Root, { className, children: entries.map((e) => /* @__PURE__ */ jsx18(
|
|
7467
7545
|
Item,
|
|
7468
7546
|
{
|
|
7469
|
-
ref:
|
|
7547
|
+
ref: (el) => {
|
|
7548
|
+
if (!el) return;
|
|
7549
|
+
els.current.set(e.key, el);
|
|
7550
|
+
return () => {
|
|
7551
|
+
if (els.current.get(e.key) === el) els.current.delete(e.key);
|
|
7552
|
+
};
|
|
7553
|
+
},
|
|
7470
7554
|
className: cn("nish-flow-item", itemClassName),
|
|
7471
7555
|
"data-phase": e.phase,
|
|
7472
7556
|
"aria-hidden": e.phase === "exit" || void 0,
|
|
@@ -7482,7 +7566,7 @@ function AnimatedList({
|
|
|
7482
7566
|
import { SystemCanvas, layoutSystem, pickLayout, routeEdges } from "./system-canvas.js";
|
|
7483
7567
|
|
|
7484
7568
|
// src/components/inbox.tsx
|
|
7485
|
-
import { useEffect as
|
|
7569
|
+
import { useEffect as useEffect18, useId as useId9, useRef as useRef16, useState as useState15 } from "react";
|
|
7486
7570
|
|
|
7487
7571
|
// src/server/inbox/types.ts
|
|
7488
7572
|
var INBOX_ACTION_HEADER = "X-Inbox-Action";
|
|
@@ -7634,10 +7718,10 @@ function Inbox({
|
|
|
7634
7718
|
const [expanded, setExpanded] = useState15(() => /* @__PURE__ */ new Set());
|
|
7635
7719
|
const [confirmAll, setConfirmAll] = useState15(false);
|
|
7636
7720
|
const [running, setRunning] = useState15(() => /* @__PURE__ */ new Map());
|
|
7637
|
-
const scrolled =
|
|
7721
|
+
const scrolled = useRef16(null);
|
|
7638
7722
|
const labelOf = (id) => sourceLabels[id] ?? id;
|
|
7639
7723
|
const rowId = (id) => `${idBase}-item-${id}`;
|
|
7640
|
-
|
|
7724
|
+
useEffect18(() => {
|
|
7641
7725
|
if (selectedId == null || scrolled.current === selectedId) return;
|
|
7642
7726
|
const el = document.getElementById(rowId(selectedId));
|
|
7643
7727
|
if (!el) return;
|
|
@@ -7735,7 +7819,7 @@ function Inbox({
|
|
|
7735
7819
|
}
|
|
7736
7820
|
|
|
7737
7821
|
// src/components/app-shell.tsx
|
|
7738
|
-
import { Fragment as Fragment10, useEffect as
|
|
7822
|
+
import { Fragment as Fragment10, useEffect as useEffect19, useRef as useRef17, useState as useState16 } from "react";
|
|
7739
7823
|
|
|
7740
7824
|
// src/components/error-boundary.tsx
|
|
7741
7825
|
import { Component } from "react";
|
|
@@ -7788,9 +7872,10 @@ var MAIN_ID = "nish-main";
|
|
|
7788
7872
|
function AppShell({
|
|
7789
7873
|
name,
|
|
7790
7874
|
icon,
|
|
7875
|
+
brand,
|
|
7791
7876
|
homeHref = "/",
|
|
7792
7877
|
hubHref,
|
|
7793
|
-
nav,
|
|
7878
|
+
nav = [],
|
|
7794
7879
|
primary = 4,
|
|
7795
7880
|
moreItems = [],
|
|
7796
7881
|
renderLink,
|
|
@@ -7799,6 +7884,8 @@ function AppShell({
|
|
|
7799
7884
|
railFooter,
|
|
7800
7885
|
loading = false,
|
|
7801
7886
|
connection = {},
|
|
7887
|
+
banner,
|
|
7888
|
+
sidebar = false,
|
|
7802
7889
|
container = "default",
|
|
7803
7890
|
toaster = {},
|
|
7804
7891
|
errorBoundary = true,
|
|
@@ -7806,20 +7893,33 @@ function AppShell({
|
|
|
7806
7893
|
children
|
|
7807
7894
|
}) {
|
|
7808
7895
|
const [sheet, setSheet] = useState16(false);
|
|
7809
|
-
const firstKey =
|
|
7810
|
-
|
|
7896
|
+
const firstKey = useRef17(true);
|
|
7897
|
+
useEffect19(() => {
|
|
7811
7898
|
if (firstKey.current) {
|
|
7812
7899
|
firstKey.current = false;
|
|
7813
7900
|
return;
|
|
7814
7901
|
}
|
|
7815
7902
|
setSheet(false);
|
|
7816
7903
|
}, [resetKey]);
|
|
7904
|
+
const side = sidebar === false ? null : sidebar === true ? {} : sidebar;
|
|
7905
|
+
const storageKey = side?.storageKey === false ? null : side?.storageKey ?? "nish-sidebar-collapsed";
|
|
7906
|
+
const [storedCollapsed, setStoredCollapsed] = useLocalStorage(storageKey ?? "nish-sidebar-collapsed", side?.defaultCollapsed ?? false);
|
|
7907
|
+
const [memoryCollapsed, setMemoryCollapsed] = useState16(side?.defaultCollapsed ?? false);
|
|
7908
|
+
const collapsed = side?.collapsed ?? (storageKey ? storedCollapsed : memoryCollapsed);
|
|
7909
|
+
const setCollapsed = (next) => {
|
|
7910
|
+
if (side?.collapsed === void 0) (storageKey ? setStoredCollapsed : setMemoryCollapsed)(next);
|
|
7911
|
+
side?.onCollapsedChange?.(next);
|
|
7912
|
+
};
|
|
7913
|
+
const bannersRef = useRef17(null);
|
|
7914
|
+
useHeightVar(bannersRef, "--nish-banners-h");
|
|
7915
|
+
const hasNav = nav.length > 0;
|
|
7817
7916
|
const n = nav.length <= 5 ? nav.length : Math.max(0, primary);
|
|
7818
7917
|
const bottomItems = nav.slice(0, n);
|
|
7819
7918
|
const overflow = nav.slice(n);
|
|
7820
|
-
const sheetItems = [...overflow, ...moreItems];
|
|
7919
|
+
const sheetItems = hasNav ? [...overflow, ...moreItems] : [];
|
|
7821
7920
|
const hasSheet = sheetItems.length > 0;
|
|
7822
7921
|
const moreActive = sheetItems.some((i) => i.active);
|
|
7922
|
+
const stickTop = "sticky top-[calc(var(--nish-header-h,0px)+var(--nish-banners-h,0px))] h-[calc(100dvh-var(--nish-header-h,0px)-var(--nish-banners-h,0px))] self-start";
|
|
7823
7923
|
const toggle = themeToggle === false ? false : hasSheet ? /* @__PURE__ */ jsx21("span", { className: "max-md:hidden", children: themeToggle ?? /* @__PURE__ */ jsx21(ThemeToggle, {}) }) : themeToggle;
|
|
7824
7924
|
const desktopNav = /* @__PURE__ */ jsx21(Fragment11, { children: nav.map((item) => {
|
|
7825
7925
|
const className = cn(tabClass({ active: !!item.active }), "inline-flex");
|
|
@@ -7829,26 +7929,29 @@ function AppShell({
|
|
|
7829
7929
|
}
|
|
7830
7930
|
return item.href != null ? /* @__PURE__ */ jsx21("a", { href: item.href, className, "aria-current": current, onClick: item.onSelect, children: item.label }, item.key) : /* @__PURE__ */ jsx21("button", { type: "button", className, "aria-current": current, onClick: item.onSelect, children: item.label }, item.key);
|
|
7831
7931
|
}) });
|
|
7832
|
-
const moreMenu = moreItems.length > 0 ?
|
|
7833
|
-
|
|
7834
|
-
{
|
|
7835
|
-
|
|
7836
|
-
|
|
7837
|
-
|
|
7838
|
-
|
|
7839
|
-
|
|
7840
|
-
|
|
7841
|
-
|
|
7842
|
-
|
|
7843
|
-
|
|
7844
|
-
|
|
7932
|
+
const moreMenu = moreItems.length > 0 ? (
|
|
7933
|
+
// With nav, under 768px these items live in the MoreSheet; signed out there is no sheet.
|
|
7934
|
+
/* @__PURE__ */ jsx21("div", { className: hasNav ? "hidden md:inline-flex" : "inline-flex", children: /* @__PURE__ */ jsx21(
|
|
7935
|
+
DropdownMenu,
|
|
7936
|
+
{
|
|
7937
|
+
align: "end",
|
|
7938
|
+
trigger: /* @__PURE__ */ jsx21(IconButton, { label: "More", children: /* @__PURE__ */ jsx21(MoreIcon, { size: 20 }) }),
|
|
7939
|
+
children: moreItems.map((item) => /* @__PURE__ */ jsx21(
|
|
7940
|
+
MenuItem,
|
|
7941
|
+
{
|
|
7942
|
+
icon: item.icon,
|
|
7943
|
+
active: item.active,
|
|
7944
|
+
onSelect: () => {
|
|
7945
|
+
if (item.onSelect) item.onSelect();
|
|
7946
|
+
else if (item.href != null) window.location.assign(item.href);
|
|
7947
|
+
},
|
|
7948
|
+
children: item.label
|
|
7845
7949
|
},
|
|
7846
|
-
|
|
7847
|
-
|
|
7848
|
-
|
|
7849
|
-
|
|
7850
|
-
|
|
7851
|
-
) }) : null;
|
|
7950
|
+
item.key
|
|
7951
|
+
))
|
|
7952
|
+
}
|
|
7953
|
+
) })
|
|
7954
|
+
) : null;
|
|
7852
7955
|
const page = errorBoundary ? /* @__PURE__ */ jsx21(AppErrorBoundary, { resetKeys: [resetKey], children }) : children;
|
|
7853
7956
|
return /* @__PURE__ */ jsxs20(Fragment11, { children: [
|
|
7854
7957
|
/* @__PURE__ */ jsx21(
|
|
@@ -7871,41 +7974,59 @@ function AppShell({
|
|
|
7871
7974
|
{
|
|
7872
7975
|
name,
|
|
7873
7976
|
icon,
|
|
7977
|
+
brand,
|
|
7874
7978
|
homeHref,
|
|
7875
7979
|
hubHref,
|
|
7876
7980
|
hideNameBelow: icon != null ? "sm" : void 0,
|
|
7877
7981
|
compactPill: true,
|
|
7878
7982
|
actions: /* @__PURE__ */ jsxs20(Fragment11, { children: [
|
|
7983
|
+
hasNav && side?.tools != null ? /* @__PURE__ */ jsx21("span", { className: "flex items-center gap-2 lg:hidden", children: side.tools }) : null,
|
|
7879
7984
|
actions,
|
|
7880
7985
|
moreMenu
|
|
7881
7986
|
] }),
|
|
7882
7987
|
themeToggle: toggle,
|
|
7883
7988
|
className: "max-lg:[&>nav]:hidden",
|
|
7884
|
-
nav: desktopNav,
|
|
7989
|
+
nav: hasNav && !side ? desktopNav : void 0,
|
|
7885
7990
|
navLabel: "Sections"
|
|
7886
7991
|
}
|
|
7887
7992
|
),
|
|
7888
7993
|
/* @__PURE__ */ jsx21(LoadingBar, { active: loading }),
|
|
7889
|
-
|
|
7994
|
+
/* @__PURE__ */ jsxs20("div", { ref: bannersRef, className: "sticky top-[var(--nish-header-h,0px)] z-20 empty:hidden", children: [
|
|
7995
|
+
connection !== false ? /* @__PURE__ */ jsx21(ConnectionBanner, { ...connection }) : null,
|
|
7996
|
+
banner
|
|
7997
|
+
] }),
|
|
7890
7998
|
/* @__PURE__ */ jsxs20("div", { className: "md:flex", children: [
|
|
7891
|
-
/* @__PURE__ */ jsx21("div", { className:
|
|
7999
|
+
hasNav ? /* @__PURE__ */ jsx21("div", { className: cn(stickTop, "hidden md:block lg:hidden"), children: /* @__PURE__ */ jsx21(NavRail, { items: nav, showFrom: "md", hideFrom: "lg", footer: railFooter, renderLink, className: "h-full" }) }) : null,
|
|
8000
|
+
hasNav && side ? /* @__PURE__ */ jsx21("div", { className: cn(stickTop, "hidden lg:block"), children: /* @__PURE__ */ jsx21(
|
|
8001
|
+
NavSidebar,
|
|
8002
|
+
{
|
|
8003
|
+
items: nav,
|
|
8004
|
+
collapsed,
|
|
8005
|
+
onCollapsedChange: setCollapsed,
|
|
8006
|
+
tools: side.tools,
|
|
8007
|
+
footer: side.footer,
|
|
8008
|
+
renderLink
|
|
8009
|
+
}
|
|
8010
|
+
) }) : null,
|
|
7892
8011
|
/* @__PURE__ */ jsx21("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ jsx21("main", { id: MAIN_ID, tabIndex: -1, className: "focus:outline-none", children: container === false ? page : /* @__PURE__ */ jsx21(PageContainer, { as: "div", size: container, children: page }) }) })
|
|
7893
8012
|
] }),
|
|
7894
|
-
/* @__PURE__ */
|
|
7895
|
-
|
|
7896
|
-
|
|
7897
|
-
|
|
7898
|
-
|
|
7899
|
-
|
|
7900
|
-
|
|
7901
|
-
|
|
7902
|
-
|
|
8013
|
+
hasNav ? /* @__PURE__ */ jsxs20(Fragment11, { children: [
|
|
8014
|
+
/* @__PURE__ */ jsx21(
|
|
8015
|
+
BottomNav,
|
|
8016
|
+
{
|
|
8017
|
+
items: bottomItems,
|
|
8018
|
+
more: hasSheet ? { active: moreActive, expanded: sheet, onToggle: () => setSheet((s) => !s) } : void 0,
|
|
8019
|
+
renderLink
|
|
8020
|
+
}
|
|
8021
|
+
),
|
|
8022
|
+
/* @__PURE__ */ jsx21(MoreSheet, { open: sheet, onClose: () => setSheet(false), items: sheetItems, renderLink })
|
|
8023
|
+
] }) : null,
|
|
7903
8024
|
toaster !== false ? /* @__PURE__ */ jsx21(Toaster, { ...toaster }) : null
|
|
7904
8025
|
] });
|
|
7905
8026
|
}
|
|
7906
8027
|
|
|
7907
8028
|
// src/components/resource.ts
|
|
7908
|
-
import { useCallback as useCallback6, useEffect as
|
|
8029
|
+
import { useCallback as useCallback6, useEffect as useEffect20, useRef as useRef18, useState as useState17 } from "react";
|
|
7909
8030
|
var ApiError = class extends Error {
|
|
7910
8031
|
/** HTTP status; 0 = network failure or abort-by-timeout. */
|
|
7911
8032
|
status;
|
|
@@ -7931,14 +8052,19 @@ function configureApi(c) {
|
|
|
7931
8052
|
function isRawBody(b) {
|
|
7932
8053
|
return typeof b === "string" || typeof FormData !== "undefined" && b instanceof FormData || typeof Blob !== "undefined" && b instanceof Blob || typeof URLSearchParams !== "undefined" && b instanceof URLSearchParams || b instanceof ArrayBuffer || ArrayBuffer.isView(b);
|
|
7933
8054
|
}
|
|
7934
|
-
|
|
8055
|
+
var ERROR_CODE = /^[a-z0-9_]+$/;
|
|
8056
|
+
function errorMessage(body, status) {
|
|
8057
|
+
let raw = "";
|
|
7935
8058
|
if (body && typeof body === "object") {
|
|
7936
8059
|
const o = body;
|
|
7937
|
-
if (typeof o.error === "string" && o.error)
|
|
7938
|
-
if (typeof o.message === "string" && o.message)
|
|
8060
|
+
if (typeof o.error === "string" && o.error) raw = o.error;
|
|
8061
|
+
else if (typeof o.message === "string" && o.message) raw = o.message;
|
|
7939
8062
|
}
|
|
7940
|
-
|
|
7941
|
-
|
|
8063
|
+
if (raw && !ERROR_CODE.test(raw)) return raw;
|
|
8064
|
+
if (status === 401) return "Log in to continue.";
|
|
8065
|
+
if (raw && status === 404) return "That was not found.";
|
|
8066
|
+
if (raw) return "The server had a problem. Try again.";
|
|
8067
|
+
return `The server answered ${status}.`;
|
|
7942
8068
|
}
|
|
7943
8069
|
async function apiFetch(path, o = {}) {
|
|
7944
8070
|
const { body, timeoutMs = 15e3, nullOn404, signal: callerSignal, headers: extraHeaders, ...init } = o;
|
|
@@ -7972,9 +8098,9 @@ async function apiFetch(path, o = {}) {
|
|
|
7972
8098
|
res = await fetch(url, { credentials: "same-origin", ...init, headers, body: payload, signal: ctl.signal });
|
|
7973
8099
|
text = await res.text();
|
|
7974
8100
|
} catch (e) {
|
|
7975
|
-
if (timedOut) throw new ApiError("
|
|
8101
|
+
if (timedOut) throw new ApiError("The server took too long to answer.", { status: 0, url });
|
|
7976
8102
|
if (e instanceof Error && e.name === "AbortError") throw e;
|
|
7977
|
-
throw new ApiError("
|
|
8103
|
+
throw new ApiError("Could not reach the server.", { status: 0, url });
|
|
7978
8104
|
}
|
|
7979
8105
|
const type = res.headers.get("content-type") ?? "";
|
|
7980
8106
|
let parsed = text === "" ? null : text;
|
|
@@ -7987,7 +8113,7 @@ async function apiFetch(path, o = {}) {
|
|
|
7987
8113
|
}
|
|
7988
8114
|
if (!res.ok) {
|
|
7989
8115
|
if (res.status === 404 && nullOn404) return null;
|
|
7990
|
-
const err = new ApiError(errorMessage(parsed, res), { status: res.status, body: parsed, url });
|
|
8116
|
+
const err = new ApiError(errorMessage(parsed, res.status), { status: res.status, body: parsed, url });
|
|
7991
8117
|
if (res.status === 401) config.onUnauthorized?.(err);
|
|
7992
8118
|
throw err;
|
|
7993
8119
|
}
|
|
@@ -8008,17 +8134,13 @@ function useResource(key, fetcher, o = {}) {
|
|
|
8008
8134
|
updatedAt: void 0,
|
|
8009
8135
|
fetching: false
|
|
8010
8136
|
}));
|
|
8011
|
-
const fetcherRef =
|
|
8012
|
-
|
|
8013
|
-
const
|
|
8014
|
-
|
|
8015
|
-
const
|
|
8016
|
-
|
|
8017
|
-
const
|
|
8018
|
-
initialRef.current = o.initialData;
|
|
8019
|
-
const ctlRef = useRef17(null);
|
|
8020
|
-
const runRef = useRef17(0);
|
|
8021
|
-
const pollSkippedRef = useRef17(false);
|
|
8137
|
+
const fetcherRef = useLatest(fetcher);
|
|
8138
|
+
const keyRef = useLatest(key);
|
|
8139
|
+
const keepPrevRef = useLatest(keepPrevious);
|
|
8140
|
+
const initialRef = useLatest(o.initialData);
|
|
8141
|
+
const ctlRef = useRef18(null);
|
|
8142
|
+
const runRef = useRef18(0);
|
|
8143
|
+
const pollSkippedRef = useRef18(false);
|
|
8022
8144
|
const [now, setNow] = useState17(() => Date.now());
|
|
8023
8145
|
const load = useCallback6(async () => {
|
|
8024
8146
|
const k = keyRef.current;
|
|
@@ -8047,8 +8169,8 @@ function useResource(key, fetcher, o = {}) {
|
|
|
8047
8169
|
const error2 = e instanceof Error ? e : new Error(String(e));
|
|
8048
8170
|
setState((s) => ({ ...s, key: k, error: error2, fetching: false }));
|
|
8049
8171
|
}
|
|
8050
|
-
}, []);
|
|
8051
|
-
|
|
8172
|
+
}, [fetcherRef, initialRef, keepPrevRef, keyRef]);
|
|
8173
|
+
useEffect20(() => {
|
|
8052
8174
|
if (!active) return;
|
|
8053
8175
|
void load();
|
|
8054
8176
|
return () => {
|
|
@@ -8060,7 +8182,7 @@ function useResource(key, fetcher, o = {}) {
|
|
|
8060
8182
|
}, [active, key, load]);
|
|
8061
8183
|
const fetching = state.fetching;
|
|
8062
8184
|
const updatedAt = state.updatedAt;
|
|
8063
|
-
|
|
8185
|
+
useEffect20(() => {
|
|
8064
8186
|
if (!active || !intervalMs || fetching) return;
|
|
8065
8187
|
const id = setTimeout(() => {
|
|
8066
8188
|
if (typeof document !== "undefined" && document.hidden) {
|
|
@@ -8071,7 +8193,7 @@ function useResource(key, fetcher, o = {}) {
|
|
|
8071
8193
|
}, intervalMs);
|
|
8072
8194
|
return () => clearTimeout(id);
|
|
8073
8195
|
}, [active, intervalMs, fetching, load]);
|
|
8074
|
-
|
|
8196
|
+
useEffect20(() => {
|
|
8075
8197
|
if (!active || typeof document === "undefined") return;
|
|
8076
8198
|
let hiddenAt = document.hidden ? Date.now() : null;
|
|
8077
8199
|
const onVisibility = () => {
|
|
@@ -8095,7 +8217,7 @@ function useResource(key, fetcher, o = {}) {
|
|
|
8095
8217
|
window.removeEventListener("online", onOnline);
|
|
8096
8218
|
};
|
|
8097
8219
|
}, [active, refetchOnVisible, refetchOnReconnect, load]);
|
|
8098
|
-
|
|
8220
|
+
useEffect20(() => {
|
|
8099
8221
|
if (!intervalMs || updatedAt === void 0) return;
|
|
8100
8222
|
const id = setInterval(() => setNow(Date.now()), intervalMs);
|
|
8101
8223
|
return () => clearInterval(id);
|
|
@@ -8209,7 +8331,7 @@ function FilterBar({
|
|
|
8209
8331
|
}
|
|
8210
8332
|
|
|
8211
8333
|
// src/components/url-state.ts
|
|
8212
|
-
import { useCallback as useCallback7, useMemo as useMemo5,
|
|
8334
|
+
import { useCallback as useCallback7, useMemo as useMemo5, useSyncExternalStore as useSyncExternalStore6 } from "react";
|
|
8213
8335
|
var EVENT = "nish:urlstate";
|
|
8214
8336
|
var locationAdapter = {
|
|
8215
8337
|
get() {
|
|
@@ -8233,11 +8355,11 @@ var locationAdapter = {
|
|
|
8233
8355
|
};
|
|
8234
8356
|
}
|
|
8235
8357
|
};
|
|
8236
|
-
function parseValue(params, key, fallback) {
|
|
8358
|
+
function parseValue(params, key, fallback, comma) {
|
|
8237
8359
|
if (!params.has(key)) return fallback;
|
|
8238
8360
|
if (Array.isArray(fallback)) {
|
|
8239
8361
|
const all = params.getAll(key);
|
|
8240
|
-
return (all.length === 1 ? all[0].split(",") : all).filter(Boolean);
|
|
8362
|
+
return (comma && all.length === 1 ? all[0].split(",") : all).filter(Boolean);
|
|
8241
8363
|
}
|
|
8242
8364
|
const raw = params.get(key) ?? "";
|
|
8243
8365
|
if (typeof fallback === "number") {
|
|
@@ -8256,26 +8378,28 @@ function same(a, b) {
|
|
|
8256
8378
|
if (Array.isArray(a) && Array.isArray(b)) return a.length === b.length && a.every((v, i) => v === b[i]);
|
|
8257
8379
|
return a === b;
|
|
8258
8380
|
}
|
|
8259
|
-
function parse(params, defaults, prefix) {
|
|
8381
|
+
function parse(params, defaults, prefix, comma) {
|
|
8260
8382
|
const out = {};
|
|
8261
|
-
for (const key of Object.keys(defaults)) out[key] = parseValue(params, prefix + key, defaults[key]);
|
|
8383
|
+
for (const key of Object.keys(defaults)) out[key] = parseValue(params, prefix + key, defaults[key], isComma(comma, key));
|
|
8262
8384
|
return out;
|
|
8263
8385
|
}
|
|
8386
|
+
var isComma = (comma, key) => Array.isArray(comma) ? comma.includes(key) : comma === true;
|
|
8264
8387
|
function useUrlState(defaults, o = {}) {
|
|
8265
8388
|
const adapter = o.adapter ?? locationAdapter;
|
|
8266
8389
|
const prefix = o.prefix ? `${o.prefix}.` : "";
|
|
8267
|
-
const
|
|
8268
|
-
|
|
8390
|
+
const commaKey = JSON.stringify(o.comma ?? false);
|
|
8391
|
+
const comma = useMemo5(() => JSON.parse(commaKey), [commaKey]);
|
|
8269
8392
|
const defaultsKey = JSON.stringify(defaults);
|
|
8393
|
+
const stableDefaults = useMemo5(() => JSON.parse(defaultsKey), [defaultsKey]);
|
|
8270
8394
|
const search = useSyncExternalStore6(
|
|
8271
8395
|
adapter.subscribe,
|
|
8272
8396
|
() => adapter.get().toString(),
|
|
8273
8397
|
() => ""
|
|
8274
8398
|
);
|
|
8275
|
-
const state = useMemo5(() => parse(new URLSearchParams(search),
|
|
8399
|
+
const state = useMemo5(() => parse(new URLSearchParams(search), stableDefaults, prefix, comma), [search, prefix, stableDefaults, comma]);
|
|
8276
8400
|
const write = useCallback7(
|
|
8277
8401
|
(next) => {
|
|
8278
|
-
const d =
|
|
8402
|
+
const d = stableDefaults;
|
|
8279
8403
|
const params = adapter.get();
|
|
8280
8404
|
for (const key of Object.keys(next)) {
|
|
8281
8405
|
if (!(key in d)) continue;
|
|
@@ -8287,52 +8411,55 @@ function useUrlState(defaults, o = {}) {
|
|
|
8287
8411
|
if (value.length === 0) params.append(name, "");
|
|
8288
8412
|
else {
|
|
8289
8413
|
for (const v of value) params.append(name, v);
|
|
8290
|
-
if (value.length === 1 && value[0].includes(",")) params.append(name, "");
|
|
8414
|
+
if (isComma(comma, key) && value.length === 1 && value[0].includes(",")) params.append(name, "");
|
|
8291
8415
|
}
|
|
8292
8416
|
} else if (typeof value === "boolean") params.set(name, value ? "1" : "0");
|
|
8293
8417
|
else params.set(name, String(value));
|
|
8294
8418
|
}
|
|
8295
8419
|
adapter.set(params);
|
|
8296
8420
|
},
|
|
8297
|
-
[adapter, prefix]
|
|
8421
|
+
[adapter, stableDefaults, prefix, comma]
|
|
8298
8422
|
);
|
|
8299
8423
|
const patch = useCallback7(
|
|
8300
8424
|
(p) => {
|
|
8301
|
-
const prev = parse(adapter.get(),
|
|
8425
|
+
const prev = parse(adapter.get(), stableDefaults, prefix, comma);
|
|
8302
8426
|
write(typeof p === "function" ? p(prev) : p);
|
|
8303
8427
|
},
|
|
8304
|
-
[adapter, prefix, write]
|
|
8428
|
+
[adapter, stableDefaults, prefix, comma, write]
|
|
8305
8429
|
);
|
|
8306
8430
|
const reset = useCallback7(() => {
|
|
8307
8431
|
const params = adapter.get();
|
|
8308
|
-
for (const key of Object.keys(
|
|
8432
|
+
for (const key of Object.keys(stableDefaults)) params.delete(prefix + key);
|
|
8309
8433
|
adapter.set(params);
|
|
8310
|
-
}, [adapter, prefix]);
|
|
8434
|
+
}, [adapter, stableDefaults, prefix]);
|
|
8311
8435
|
return [state, patch, reset];
|
|
8312
8436
|
}
|
|
8313
8437
|
|
|
8314
8438
|
// src/components/settings.tsx
|
|
8315
8439
|
import {
|
|
8440
|
+
createContext as createContext5,
|
|
8316
8441
|
forwardRef as forwardRef3,
|
|
8317
8442
|
useCallback as useCallback8,
|
|
8318
|
-
|
|
8443
|
+
useContext as useContext5,
|
|
8444
|
+
useEffect as useEffect21,
|
|
8319
8445
|
useId as useId10,
|
|
8320
8446
|
useRef as useRef19,
|
|
8321
8447
|
useState as useState19
|
|
8322
8448
|
} from "react";
|
|
8323
8449
|
import { jsx as jsx23, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
8324
|
-
|
|
8450
|
+
var CompactSettings = createContext5(false);
|
|
8451
|
+
function SettingsSection({ title, description, id, actions, compact = false, children, className }) {
|
|
8325
8452
|
const auto = useId10();
|
|
8326
8453
|
const headingId = `${id ?? auto}-heading`;
|
|
8327
8454
|
return /* @__PURE__ */ jsxs22("section", { id, "aria-labelledby": headingId, className: cn("min-w-0", className), children: [
|
|
8328
|
-
/* @__PURE__ */ jsxs22("div", { className: "
|
|
8455
|
+
/* @__PURE__ */ jsxs22("div", { className: cn("flex flex-wrap items-end justify-between gap-x-4 gap-y-2", compact ? "mb-1" : "mb-3"), children: [
|
|
8329
8456
|
/* @__PURE__ */ jsxs22("div", { className: "min-w-0", children: [
|
|
8330
|
-
/* @__PURE__ */ jsx23("h2", { id: headingId, className: "text-base font-semibold text-th-hi", children: title }),
|
|
8331
|
-
description != null ? /* @__PURE__ */ jsx23("p", { className: "mt-0.5 text-
|
|
8457
|
+
/* @__PURE__ */ jsx23("h2", { id: headingId, className: compact ? "text-sm font-semibold text-th-hi2" : "text-base font-semibold text-th-hi", children: title }),
|
|
8458
|
+
description != null ? /* @__PURE__ */ jsx23("p", { className: cn("mt-0.5 text-th-hi3", compact ? "text-xs" : "text-sm"), children: description }) : null
|
|
8332
8459
|
] }),
|
|
8333
8460
|
actions != null ? /* @__PURE__ */ jsx23("div", { className: "flex shrink-0 items-center gap-2", children: actions }) : null
|
|
8334
8461
|
] }),
|
|
8335
|
-
/* @__PURE__ */ jsx23(Card, { padding: "none", className: "divide-y divide-th-line", children })
|
|
8462
|
+
/* @__PURE__ */ jsx23(CompactSettings.Provider, { value: compact, children: compact ? /* @__PURE__ */ jsx23("div", { className: "divide-y divide-th-line", children }) : /* @__PURE__ */ jsx23(Card, { padding: "none", className: "divide-y divide-th-line", children }) })
|
|
8336
8463
|
] });
|
|
8337
8464
|
}
|
|
8338
8465
|
var STATUS_TONE = { muted: "text-th-hi3", error: "text-th-loss", ok: "text-th-ok" };
|
|
@@ -8343,25 +8470,29 @@ function SettingRow({
|
|
|
8343
8470
|
htmlFor,
|
|
8344
8471
|
stacked = false,
|
|
8345
8472
|
inline = false,
|
|
8473
|
+
compact: compactProp,
|
|
8346
8474
|
status,
|
|
8347
8475
|
statusTone = "muted",
|
|
8348
8476
|
className
|
|
8349
8477
|
}) {
|
|
8478
|
+
const inCompactSection = useContext5(CompactSettings);
|
|
8479
|
+
const compact = compactProp ?? inCompactSection;
|
|
8350
8480
|
const labelClass = "block text-sm font-medium text-th-hi";
|
|
8351
8481
|
const auto = useId10();
|
|
8352
8482
|
const labelId = `${auto}-label`;
|
|
8353
8483
|
const descId = `${auto}-desc`;
|
|
8354
|
-
const
|
|
8355
|
-
|
|
8484
|
+
const side = inline || compact && !stacked;
|
|
8485
|
+
const layout = stacked ? "flex flex-col gap-2" : side ? "grid grid-cols-[1fr_auto] items-center gap-4" : "flex flex-col gap-2 sm:grid sm:grid-cols-[1fr_auto] sm:items-center sm:gap-4";
|
|
8486
|
+
return /* @__PURE__ */ jsxs22("div", { className: cn(compact ? cn("min-h-11 py-2", !inCompactSection && "px-4") : "min-h-[56px] px-4 py-3", layout, className), children: [
|
|
8356
8487
|
/* @__PURE__ */ jsxs22("div", { className: "min-w-0", children: [
|
|
8357
8488
|
htmlFor ? /* @__PURE__ */ jsx23("label", { htmlFor, className: labelClass, children: label }) : /* @__PURE__ */ jsx23("span", { id: labelId, className: labelClass, children: label }),
|
|
8358
|
-
description != null ? /* @__PURE__ */ jsx23("p", { id: descId, className: "mt-0.5 text-
|
|
8489
|
+
description != null ? /* @__PURE__ */ jsx23("p", { id: descId, className: cn("mt-0.5 text-th-hi3", compact ? "text-xs" : "text-sm"), children: description }) : null
|
|
8359
8490
|
] }),
|
|
8360
8491
|
/* @__PURE__ */ jsxs22(
|
|
8361
8492
|
"div",
|
|
8362
8493
|
{
|
|
8363
8494
|
...htmlFor ? {} : { role: "group", "aria-labelledby": labelId, "aria-describedby": description != null ? descId : void 0 },
|
|
8364
|
-
className: cn("flex min-w-0 items-center gap-2", stacked ? "w-full" :
|
|
8495
|
+
className: cn("flex min-w-0 items-center gap-2", stacked ? "w-full" : side ? "justify-end" : "w-full sm:w-auto sm:justify-end"),
|
|
8365
8496
|
children: [
|
|
8366
8497
|
children,
|
|
8367
8498
|
/* @__PURE__ */ jsx23("span", { role: "status", "aria-live": "polite", className: cn("shrink-0 text-sm empty:hidden", STATUS_TONE[statusTone]), children: status })
|
|
@@ -8378,7 +8509,7 @@ function useSaveStatus() {
|
|
|
8378
8509
|
const timer = useRef19(void 0);
|
|
8379
8510
|
const token = useRef19(0);
|
|
8380
8511
|
const mounted = useRef19(true);
|
|
8381
|
-
|
|
8512
|
+
useEffect21(() => {
|
|
8382
8513
|
mounted.current = true;
|
|
8383
8514
|
return () => {
|
|
8384
8515
|
mounted.current = false;
|
|
@@ -8413,6 +8544,7 @@ function useSaveStatus() {
|
|
|
8413
8544
|
const tone = status === "saved" ? "ok" : status === "error" ? "error" : "muted";
|
|
8414
8545
|
return { status, error, label, tone, run };
|
|
8415
8546
|
}
|
|
8547
|
+
var parseDraft = (text) => Number(text.trim().replace(/,/g, "").replace(/\u2212/g, "-"));
|
|
8416
8548
|
var fmt = (v) => v == null ? "" : String(v);
|
|
8417
8549
|
var decimals = (n) => String(n).split(".")[1]?.length ?? 0;
|
|
8418
8550
|
var NumberField = forwardRef3(function NumberField2({ value, onCommit, min, max, step = 1, nullable = false, suffix, precision, className, onBlur, onKeyDown, id, invalid, "aria-describedby": describedBy, ...rest }, ref) {
|
|
@@ -8429,13 +8561,13 @@ var NumberField = forwardRef3(function NumberField2({ value, onCommit, min, max,
|
|
|
8429
8561
|
draftRef.current = next;
|
|
8430
8562
|
setDraftState(next);
|
|
8431
8563
|
};
|
|
8432
|
-
|
|
8564
|
+
useEffect21(() => {
|
|
8433
8565
|
mounted.current = true;
|
|
8434
8566
|
return () => {
|
|
8435
8567
|
mounted.current = false;
|
|
8436
8568
|
};
|
|
8437
8569
|
}, []);
|
|
8438
|
-
|
|
8570
|
+
useEffect21(() => {
|
|
8439
8571
|
lastSent.current = null;
|
|
8440
8572
|
setDraft(fmt(value));
|
|
8441
8573
|
}, [value]);
|
|
@@ -8460,7 +8592,7 @@ var NumberField = forwardRef3(function NumberField2({ value, onCommit, min, max,
|
|
|
8460
8592
|
}
|
|
8461
8593
|
next = null;
|
|
8462
8594
|
} else {
|
|
8463
|
-
const n =
|
|
8595
|
+
const n = parseDraft(text);
|
|
8464
8596
|
if (Number.isNaN(n)) {
|
|
8465
8597
|
setDraft(fmt(value));
|
|
8466
8598
|
setError("Enter a number");
|
|
@@ -8497,7 +8629,7 @@ var NumberField = forwardRef3(function NumberField2({ value, onCommit, min, max,
|
|
|
8497
8629
|
}
|
|
8498
8630
|
};
|
|
8499
8631
|
const nudge = (dir) => {
|
|
8500
|
-
const base =
|
|
8632
|
+
const base = parseDraft(draftRef.current);
|
|
8501
8633
|
const from = Number.isNaN(base) || draftRef.current.trim() === "" ? value ?? min ?? 0 : base;
|
|
8502
8634
|
const n = Number(clamp2(from + dir * step).toFixed(Math.max(precision ?? 0, decimals(step), decimals(from))));
|
|
8503
8635
|
setDraft(String(n));
|
|
@@ -8521,16 +8653,24 @@ var NumberField = forwardRef3(function NumberField2({ value, onCommit, min, max,
|
|
|
8521
8653
|
nudge(e.key === "ArrowUp" ? 1 : -1);
|
|
8522
8654
|
}
|
|
8523
8655
|
};
|
|
8656
|
+
const shown = parseDraft(draft);
|
|
8657
|
+
const now = draft.trim() !== "" && !Number.isNaN(shown) ? shown : value ?? void 0;
|
|
8658
|
+
const negatives = min != null && min < 0;
|
|
8524
8659
|
return /* @__PURE__ */ jsxs22("div", { className: "flex min-w-0 flex-col gap-1", children: [
|
|
8525
8660
|
/* @__PURE__ */ jsxs22("div", { className: "flex items-center gap-2", children: [
|
|
8526
8661
|
/* @__PURE__ */ jsx23(
|
|
8527
8662
|
Input,
|
|
8528
8663
|
{
|
|
8664
|
+
inputMode: negatives ? "text" : "decimal",
|
|
8529
8665
|
...rest,
|
|
8530
8666
|
ref,
|
|
8531
8667
|
id,
|
|
8532
8668
|
type: "text",
|
|
8533
|
-
|
|
8669
|
+
role: "spinbutton",
|
|
8670
|
+
"aria-valuemin": min,
|
|
8671
|
+
"aria-valuemax": max,
|
|
8672
|
+
"aria-valuenow": now,
|
|
8673
|
+
"aria-valuetext": now != null && typeof suffix === "string" ? `${now} ${suffix}` : void 0,
|
|
8534
8674
|
autoComplete: "off",
|
|
8535
8675
|
value: draft,
|
|
8536
8676
|
invalid: invalid || error != null,
|
|
@@ -8560,7 +8700,7 @@ var NumberField = forwardRef3(function NumberField2({ value, onCommit, min, max,
|
|
|
8560
8700
|
// src/components/service-tokens.tsx
|
|
8561
8701
|
import {
|
|
8562
8702
|
useCallback as useCallback9,
|
|
8563
|
-
useEffect as
|
|
8703
|
+
useEffect as useEffect22,
|
|
8564
8704
|
useMemo as useMemo6,
|
|
8565
8705
|
useRef as useRef20,
|
|
8566
8706
|
useState as useState20
|
|
@@ -8574,7 +8714,7 @@ function useServiceTokens(url = "/api/service-tokens") {
|
|
|
8574
8714
|
const [error, setError] = useState20(null);
|
|
8575
8715
|
const [nonce, setNonce] = useState20(0);
|
|
8576
8716
|
const seq = useRef20(0);
|
|
8577
|
-
|
|
8717
|
+
useEffect22(() => {
|
|
8578
8718
|
const mine = ++seq.current;
|
|
8579
8719
|
const ctl = new AbortController();
|
|
8580
8720
|
apiFetch(url, { signal: ctl.signal }).then((r) => {
|
|
@@ -8636,7 +8776,7 @@ function ServiceTokensSection({
|
|
|
8636
8776
|
const [pending, setPending] = useState20(false);
|
|
8637
8777
|
const [failure, setFailure] = useState20(null);
|
|
8638
8778
|
const mounted = useRef20(true);
|
|
8639
|
-
|
|
8779
|
+
useEffect22(() => {
|
|
8640
8780
|
mounted.current = true;
|
|
8641
8781
|
return () => {
|
|
8642
8782
|
mounted.current = false;
|
|
@@ -8757,15 +8897,22 @@ function ServiceTokensSection({
|
|
|
8757
8897
|
}
|
|
8758
8898
|
|
|
8759
8899
|
// src/components/combobox.tsx
|
|
8760
|
-
import { useCallback as useCallback10, useEffect as
|
|
8761
|
-
|
|
8762
|
-
|
|
8763
|
-
var
|
|
8764
|
-
var
|
|
8900
|
+
import { useCallback as useCallback10, useEffect as useEffect23, useId as useId11, useMemo as useMemo7, useRef as useRef21, useState as useState21 } from "react";
|
|
8901
|
+
|
|
8902
|
+
// src/combobox-filter.ts
|
|
8903
|
+
var COMBOBOX_MAX_SHOWN = 50;
|
|
8904
|
+
var COMBOBOX_DEBOUNCE_MS = 200;
|
|
8905
|
+
var defaultComboboxFilter = (o, q) => {
|
|
8765
8906
|
const needle = q.trim().toLowerCase();
|
|
8766
8907
|
if (!needle) return true;
|
|
8767
8908
|
return o.label.toLowerCase().includes(needle) || (o.hint?.toLowerCase().includes(needle) ?? false);
|
|
8768
8909
|
};
|
|
8910
|
+
|
|
8911
|
+
// src/components/combobox.tsx
|
|
8912
|
+
import { jsx as jsx25, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
8913
|
+
var MAX_SHOWN = COMBOBOX_MAX_SHOWN;
|
|
8914
|
+
var DEBOUNCE_MS = COMBOBOX_DEBOUNCE_MS;
|
|
8915
|
+
var defaultFilter = defaultComboboxFilter;
|
|
8769
8916
|
function Combobox({
|
|
8770
8917
|
options,
|
|
8771
8918
|
value,
|
|
@@ -8802,13 +8949,13 @@ function Combobox({
|
|
|
8802
8949
|
const list = !dirty || serverFiltered ? options : options.filter((o) => test(o, text));
|
|
8803
8950
|
return list.slice(0, MAX_SHOWN);
|
|
8804
8951
|
}, [options, dirty, text, filter, onQueryChange]);
|
|
8805
|
-
|
|
8806
|
-
|
|
8952
|
+
useEffect23(() => () => window.clearTimeout(debounceRef.current), []);
|
|
8953
|
+
useEffect23(() => {
|
|
8807
8954
|
if (!open || active < 0) return;
|
|
8808
8955
|
const el = listRef.current?.querySelector(`[data-index="${active}"]`);
|
|
8809
8956
|
el?.scrollIntoView?.({ block: "nearest" });
|
|
8810
8957
|
}, [open, active]);
|
|
8811
|
-
|
|
8958
|
+
useEffect23(() => {
|
|
8812
8959
|
if (open) listRef.current?.scrollIntoView?.({ block: "nearest" });
|
|
8813
8960
|
}, [open]);
|
|
8814
8961
|
const reset = useCallback10(() => {
|
|
@@ -9027,8 +9174,8 @@ function Combobox({
|
|
|
9027
9174
|
|
|
9028
9175
|
// src/components/split.tsx
|
|
9029
9176
|
import {
|
|
9030
|
-
useEffect as
|
|
9031
|
-
useLayoutEffect as
|
|
9177
|
+
useEffect as useEffect24,
|
|
9178
|
+
useLayoutEffect as useLayoutEffect6,
|
|
9032
9179
|
useRef as useRef22,
|
|
9033
9180
|
useState as useState22
|
|
9034
9181
|
} from "react";
|
|
@@ -9467,10 +9614,10 @@ function SplitDividers({ layout, w, h, gap, onResize, onDragChange, minPane, bar
|
|
|
9467
9614
|
const hit = coarse ? 44 : 24;
|
|
9468
9615
|
const baseMin = minPane ?? { w: 160, h: 90 };
|
|
9469
9616
|
const onDragChangeRef = useRef22(onDragChange);
|
|
9470
|
-
|
|
9617
|
+
useEffect24(() => {
|
|
9471
9618
|
onDragChangeRef.current = onDragChange;
|
|
9472
9619
|
});
|
|
9473
|
-
|
|
9620
|
+
useEffect24(
|
|
9474
9621
|
() => () => {
|
|
9475
9622
|
if (drag.current) {
|
|
9476
9623
|
drag.current = null;
|
|
@@ -9598,10 +9745,10 @@ function SplitStage({
|
|
|
9598
9745
|
const showDividers = resizable && !!layout && slots.length > 1;
|
|
9599
9746
|
if (!showDividers && resizing) setResizing(false);
|
|
9600
9747
|
const onSizeRef = useRef22(onSize);
|
|
9601
|
-
|
|
9748
|
+
useEffect24(() => {
|
|
9602
9749
|
onSizeRef.current = onSize;
|
|
9603
9750
|
});
|
|
9604
|
-
|
|
9751
|
+
useLayoutEffect6(() => {
|
|
9605
9752
|
const el = ref.current;
|
|
9606
9753
|
if (!el) return;
|
|
9607
9754
|
const measure = () => {
|
|
@@ -9615,7 +9762,7 @@ function SplitStage({
|
|
|
9615
9762
|
ro.observe(el);
|
|
9616
9763
|
return () => ro.disconnect();
|
|
9617
9764
|
}, []);
|
|
9618
|
-
|
|
9765
|
+
useEffect24(() => {
|
|
9619
9766
|
onSizeRef.current?.(size);
|
|
9620
9767
|
}, [size]);
|
|
9621
9768
|
const measured = size.w > 0 && size.h > 0;
|