nish-ui 3.2.0 → 3.3.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 +7 -3
- package/dist/base-tailwind.css +30 -15
- package/dist/base.css +30 -15
- package/dist/elements-all.js +78 -78
- package/dist/elements-charts.js +39 -38
- package/dist/elements-data.d.ts +10 -0
- package/dist/elements-data.js +4 -5
- package/dist/elements-forms.js +5 -5
- package/dist/elements.d.ts +1 -0
- package/dist/elements.js +4 -4
- package/dist/esm/command-filter.js +55 -4
- package/dist/esm/components/accordion.js +3 -2
- package/dist/esm/components/app-shell.js +8 -4
- package/dist/esm/components/breadcrumbs.js +7 -3
- package/dist/esm/components/calendar-base.js +32 -5
- package/dist/esm/components/calendar-classes.js +14 -2
- package/dist/esm/components/canvas/follow-caption.js +31 -21
- package/dist/esm/components/canvas/follow.js +5 -6
- package/dist/esm/components/canvas/minimap.js +3 -3
- package/dist/esm/components/canvas/system-canvas.js +3 -1
- package/dist/esm/components/canvas/view.js +0 -2
- package/dist/esm/components/carousel.js +2 -3
- package/dist/esm/components/charts.js +18 -7
- package/dist/esm/components/combobox.js +18 -7
- package/dist/esm/components/command.js +23 -61
- package/dist/esm/components/context-menu.js +2 -1
- package/dist/esm/components/data-classes.js +5 -4
- package/dist/esm/components/data.js +19 -10
- package/dist/esm/components/display.js +20 -11
- package/dist/esm/components/drawer.js +17 -4
- package/dist/esm/components/error-boundary.js +3 -3
- package/dist/esm/components/feedback.js +3 -3
- package/dist/esm/components/file-dropzone.js +16 -6
- package/dist/esm/components/filters.js +42 -1
- package/dist/esm/components/flow.js +8 -5
- package/dist/esm/components/forms-classes.js +2 -0
- package/dist/esm/components/forms.js +2 -2
- package/dist/esm/components/hooks.js +47 -13
- package/dist/esm/components/hover-card.js +2 -1
- package/dist/esm/components/inbox.js +5 -1
- package/dist/esm/components/latest.js +4 -2
- package/dist/esm/components/layout.js +7 -4
- package/dist/esm/components/menu.js +10 -1
- package/dist/esm/components/modal.js +17 -4
- package/dist/esm/components/multi-select.js +5 -5
- package/dist/esm/components/nav.js +30 -11
- package/dist/esm/components/navigate.js +1 -1
- package/dist/esm/components/overlay-dialog.js +35 -1
- package/dist/esm/components/pagination.js +1 -1
- package/dist/esm/components/primitives.js +17 -4
- package/dist/esm/components/progress.js +2 -1
- package/dist/esm/components/resource.js +14 -4
- package/dist/esm/components/segmented.js +2 -0
- package/dist/esm/components/separator.js +6 -1
- package/dist/esm/components/service-tokens.js +18 -7
- package/dist/esm/components/settings.js +16 -0
- package/dist/esm/components/slider.js +5 -1
- package/dist/esm/components/split.js +4 -2
- package/dist/esm/components/strings.js +17 -4
- package/dist/esm/components/table.js +15 -3
- package/dist/esm/components/tag-input.js +5 -1
- package/dist/esm/components/time-field.js +15 -7
- package/dist/esm/components/toast-card.js +5 -3
- package/dist/esm/components/toast.js +4 -1
- package/dist/esm/components/tooltip.js +3 -2
- package/dist/esm/components/url-state.js +3 -1
- package/dist/esm/components/virtual-table.js +2 -2
- package/dist/esm/components/virtual.js +8 -4
- package/dist/esm/format.js +3 -2
- package/dist/esm/runtime.js +1 -1
- package/dist/esm/server/inbox/client.js +4 -0
- package/dist/esm/theme.js +38 -15
- package/dist/esm/tokens.mjs +1 -1
- package/dist/format.d.ts +5 -3
- package/dist/format.js +4 -3
- package/dist/inbox-client.d.ts +1 -1
- package/dist/inbox-client.js +4 -0
- package/dist/index.d.ts +61 -29
- package/dist/nish-components.css +59 -21
- package/dist/nish-components.min.css +1 -1
- package/dist/nish.css +30 -15
- package/dist/nish.min.css +1 -1
- package/dist/node/vite.js +1 -1
- package/dist/server/hono.d.ts +9 -2
- package/dist/server/hono.js +17 -4
- package/dist/server/index.d.ts +3 -3
- package/dist/server/index.js +7 -2
- package/dist/service-tokens.d.ts +4 -4
- package/dist/{spa-BfRDo38r.d.ts → spa-FwS7yZ8p.d.ts} +4 -3
- package/dist/system-canvas.d.ts +11 -10
- package/dist/theme.d.ts +30 -2
- package/dist/theme.global.js +45 -18
- package/dist/theme.js +45 -18
- package/package.json +3 -2
- package/dist/tokens.js +0 -425
|
@@ -6,13 +6,13 @@ import { cn } from "../cn.js";
|
|
|
6
6
|
import { CheckIcon, XIcon } from "./icons.js";
|
|
7
7
|
import { Spinner } from "./feedback.js";
|
|
8
8
|
import { Chip } from "./forms.js";
|
|
9
|
+
import { warnDev } from "./display-classes.js";
|
|
9
10
|
import { fieldClass } from "./primitives.js";
|
|
10
11
|
import { useStrings } from "./provider.js";
|
|
11
12
|
import { FIELD_STRINGS, MULTI_SELECT_STRINGS } from "./strings.js";
|
|
12
13
|
import { indexComboboxOptions, setRef } from "./forms-classes.js";
|
|
13
14
|
import { COMBOBOX_DEBOUNCE_MS, COMBOBOX_MAX_SHOWN, matchesComboboxNeedle } from "../combobox-filter.js";
|
|
14
15
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
-
var defaultResultsText = (n) => `${n} ${n === 1 ? "result" : "results"}`;
|
|
16
16
|
function MultiSelect({
|
|
17
17
|
ref,
|
|
18
18
|
options,
|
|
@@ -37,7 +37,7 @@ function MultiSelect({
|
|
|
37
37
|
onQueryChange,
|
|
38
38
|
loading = false,
|
|
39
39
|
loadingText,
|
|
40
|
-
resultsText
|
|
40
|
+
resultsText,
|
|
41
41
|
size = "md",
|
|
42
42
|
clearLabel,
|
|
43
43
|
className,
|
|
@@ -96,8 +96,8 @@ function MultiSelect({
|
|
|
96
96
|
const atLimit = maxSelected != null && values.length >= maxSelected;
|
|
97
97
|
useEffect(() => () => window.clearTimeout(debounceRef.current), []);
|
|
98
98
|
useEffect(() => {
|
|
99
|
-
if (
|
|
100
|
-
|
|
99
|
+
if (!ariaLabel && !ariaLabelledBy && id == null) {
|
|
100
|
+
warnDev("MultiSelect needs a name: pass aria-label, aria-labelledby, or an id with a <label htmlFor>.");
|
|
101
101
|
}
|
|
102
102
|
}, [ariaLabel, ariaLabelledBy, id]);
|
|
103
103
|
useEffect(() => {
|
|
@@ -256,7 +256,7 @@ function MultiSelect({
|
|
|
256
256
|
}
|
|
257
257
|
const activeId = open && current >= 0 && visible[current] ? `${listId}-opt-${current}` : void 0;
|
|
258
258
|
const isInvalid = invalid || ariaInvalid === true || ariaInvalid === "true";
|
|
259
|
-
const status = announcement || (open ? loading ? searching : visible.length === 0 ? empty : resultsText(visible.length) : "");
|
|
259
|
+
const status = announcement || (open ? loading ? searching : visible.length === 0 ? empty : (resultsText ?? strings.resultsCount)(visible.length) : "");
|
|
260
260
|
return /* @__PURE__ */ jsxs(
|
|
261
261
|
"div",
|
|
262
262
|
{
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from "react";
|
|
10
10
|
import { cn } from "../cn.js";
|
|
11
11
|
import { mergeRefs } from "./data-classes.js";
|
|
12
|
-
import { FORCED_MARK } from "./display-classes.js";
|
|
12
|
+
import { FORCED_MARK, warnDev } from "./display-classes.js";
|
|
13
13
|
import { chipClass } from "./forms.js";
|
|
14
14
|
import { useMediaQuery } from "./hooks.js";
|
|
15
15
|
import { PanelLeftCloseIcon, PanelLeftOpenIcon } from "./icons.js";
|
|
@@ -128,7 +128,7 @@ function NavRail({
|
|
|
128
128
|
ref: mergeRefs(ref, refProp),
|
|
129
129
|
"aria-label": label ?? strings.sections,
|
|
130
130
|
className: cn(
|
|
131
|
-
"hidden w-[72px] shrink-0 flex-col items-center gap-1 border-e border-th-line bg-th-surface py-3 pl-[env(safe-area-inset-left)]",
|
|
131
|
+
"hidden w-[72px] shrink-0 flex-col items-center gap-1 border-e border-th-line bg-th-surface py-3 ltr:pl-[env(safe-area-inset-left)] rtl:pr-[env(safe-area-inset-right)]",
|
|
132
132
|
RAIL_SHOW[showFrom],
|
|
133
133
|
hideFrom ? RAIL_HIDE[hideFrom] : null,
|
|
134
134
|
className
|
|
@@ -193,7 +193,7 @@ function NavSidebar({
|
|
|
193
193
|
ref: mergeRefs(ref, refProp),
|
|
194
194
|
"data-state": collapsed ? "closed" : "open",
|
|
195
195
|
className: cn(
|
|
196
|
-
"flex h-full shrink-0 flex-col border-e border-th-line bg-th-surface py-3 pl-[env(safe-area-inset-left)] transition-[width] duration-200 motion-reduce:transition-none",
|
|
196
|
+
"flex h-full shrink-0 flex-col border-e border-th-line bg-th-surface py-3 ltr:pl-[env(safe-area-inset-left)] rtl:pr-[env(safe-area-inset-right)] transition-[width] duration-200 motion-reduce:transition-none",
|
|
197
197
|
collapsed ? "w-16" : "w-56",
|
|
198
198
|
className
|
|
199
199
|
),
|
|
@@ -276,6 +276,7 @@ function ScrollRow({
|
|
|
276
276
|
}
|
|
277
277
|
);
|
|
278
278
|
}
|
|
279
|
+
var SCROLL_SPY_GIVE_UP_MS = 1e4;
|
|
279
280
|
function useScrollSpy(ids, { rootMargin = "-45% 0px -50% 0px" } = {}) {
|
|
280
281
|
const [active, setActive] = useState(ids[0] ?? null);
|
|
281
282
|
const key = ids.join("\0");
|
|
@@ -310,6 +311,15 @@ function useScrollSpy(ids, { rootMargin = "-45% 0px -50% 0px" } = {}) {
|
|
|
310
311
|
);
|
|
311
312
|
const seen = /* @__PURE__ */ new Set();
|
|
312
313
|
let mo = null;
|
|
314
|
+
let frame = 0;
|
|
315
|
+
let giveUp;
|
|
316
|
+
const stopLooking = () => {
|
|
317
|
+
mo?.disconnect();
|
|
318
|
+
mo = null;
|
|
319
|
+
clearTimeout(giveUp);
|
|
320
|
+
if (frame) cancelAnimationFrame(frame);
|
|
321
|
+
frame = 0;
|
|
322
|
+
};
|
|
313
323
|
const attach = () => {
|
|
314
324
|
for (const id of list) {
|
|
315
325
|
if (seen.has(id)) continue;
|
|
@@ -319,15 +329,23 @@ function useScrollSpy(ids, { rootMargin = "-45% 0px -50% 0px" } = {}) {
|
|
|
319
329
|
io.observe(el);
|
|
320
330
|
}
|
|
321
331
|
}
|
|
322
|
-
if (seen.size === list.length
|
|
323
|
-
mo.disconnect();
|
|
324
|
-
mo = null;
|
|
325
|
-
}
|
|
332
|
+
if (seen.size === list.length) stopLooking();
|
|
326
333
|
};
|
|
327
334
|
attach();
|
|
328
335
|
if (seen.size < list.length && typeof MutationObserver !== "undefined") {
|
|
329
|
-
mo = new MutationObserver(
|
|
336
|
+
mo = new MutationObserver(() => {
|
|
337
|
+
if (frame) return;
|
|
338
|
+
frame = requestAnimationFrame(() => {
|
|
339
|
+
frame = 0;
|
|
340
|
+
attach();
|
|
341
|
+
});
|
|
342
|
+
});
|
|
330
343
|
mo.observe(document.body, { childList: true, subtree: true });
|
|
344
|
+
giveUp = setTimeout(() => {
|
|
345
|
+
const missing = list.filter((id) => !seen.has(id));
|
|
346
|
+
stopLooking();
|
|
347
|
+
if (missing.length) warnDev(`useScrollSpy: no element with id ${missing.map((id) => `"${id}"`).join(", ")} appeared, so it is not tracked.`);
|
|
348
|
+
}, SCROLL_SPY_GIVE_UP_MS);
|
|
331
349
|
}
|
|
332
350
|
const onScroll = () => {
|
|
333
351
|
if (window.scrollY < 8) setActive(list[0]);
|
|
@@ -335,7 +353,7 @@ function useScrollSpy(ids, { rootMargin = "-45% 0px -50% 0px" } = {}) {
|
|
|
335
353
|
window.addEventListener("scroll", onScroll, { passive: true });
|
|
336
354
|
return () => {
|
|
337
355
|
io.disconnect();
|
|
338
|
-
|
|
356
|
+
stopLooking();
|
|
339
357
|
window.removeEventListener("scroll", onScroll);
|
|
340
358
|
};
|
|
341
359
|
}, [key, rootMargin]);
|
|
@@ -346,12 +364,13 @@ function SectionNav({
|
|
|
346
364
|
sticky = true,
|
|
347
365
|
onSelect,
|
|
348
366
|
updateHash = true,
|
|
349
|
-
label
|
|
367
|
+
label,
|
|
350
368
|
className,
|
|
351
369
|
style,
|
|
352
370
|
ref: refProp,
|
|
353
371
|
...rest
|
|
354
372
|
}) {
|
|
373
|
+
const strings = useStrings(SHELL_STRINGS);
|
|
355
374
|
const ref = useRef(null);
|
|
356
375
|
const spy = useScrollSpy(items.map((i) => i.id));
|
|
357
376
|
const [locked, setLocked] = useState(null);
|
|
@@ -413,7 +432,7 @@ function SectionNav({
|
|
|
413
432
|
{
|
|
414
433
|
...rest,
|
|
415
434
|
ref: mergeRefs(ref, refProp),
|
|
416
|
-
"aria-label": label,
|
|
435
|
+
"aria-label": label ?? strings.onThisPage,
|
|
417
436
|
"data-nish-bar": sticky ? "" : void 0,
|
|
418
437
|
style: sticky ? { top: "var(--nish-header-h, 0px)", ...style } : style,
|
|
419
438
|
className: cn("z-[var(--nish-z-sticky,20)] border-b border-th-line bg-th-bg py-2", sticky && "sticky", className),
|
|
@@ -3,7 +3,7 @@ import { safeUrl } from "../url.js";
|
|
|
3
3
|
import { whenHistorySettled } from "./overlay-core.js";
|
|
4
4
|
function warnUnsafe(href) {
|
|
5
5
|
try {
|
|
6
|
-
if (process.env.NODE_ENV !== "production") console.warn(`
|
|
6
|
+
if (process.env.NODE_ENV !== "production") console.warn(`nish-ui: ignored an unsafe href (${href.slice(0, 40)}).`);
|
|
7
7
|
} catch {
|
|
8
8
|
}
|
|
9
9
|
}
|
|
@@ -7,8 +7,27 @@ import { useLatest } from "./latest.js";
|
|
|
7
7
|
import { useStrings } from "./provider.js";
|
|
8
8
|
import { OVERLAY_STRINGS } from "./strings.js";
|
|
9
9
|
import { SHEET_EXIT_MS } from "./overlay-classes.js";
|
|
10
|
+
import { URL_STATE_EVENT } from "./url-state.js";
|
|
10
11
|
import { ov, isTop, syncLayerAttr, pushInert, popInert, acquireGuard, releaseGuard, prefersReducedMotion, closeVetoes, focusables, lockScroll, queueHistoryPush, cancelHistoryPush } from "./overlay-core.js";
|
|
11
12
|
import { jsx } from "react/jsx-runtime";
|
|
13
|
+
function carryUrl(from, to) {
|
|
14
|
+
if (!from || to === from) return;
|
|
15
|
+
let a;
|
|
16
|
+
let b;
|
|
17
|
+
try {
|
|
18
|
+
a = new URL(from);
|
|
19
|
+
b = new URL(to);
|
|
20
|
+
} catch {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (a.origin !== b.origin || a.pathname !== b.pathname || location.href !== from) return;
|
|
24
|
+
try {
|
|
25
|
+
history.replaceState(history.state, "", b.pathname + b.search + b.hash);
|
|
26
|
+
} catch {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
window.dispatchEvent(new Event(URL_STATE_EVENT));
|
|
30
|
+
}
|
|
12
31
|
function useDialog(panelRef, onClose, closeOnBackProp = false) {
|
|
13
32
|
const closeOnBack = closeOnBackProp && (typeof window === "undefined" || window.self === window.top);
|
|
14
33
|
const onCloseRef = useLatest(onClose);
|
|
@@ -25,11 +44,17 @@ function useDialog(panelRef, onClose, closeOnBackProp = false) {
|
|
|
25
44
|
const layerId = `nish-layer-${++s.layerSeq}`;
|
|
26
45
|
let pushed = false;
|
|
27
46
|
let rePushTimer = 0;
|
|
47
|
+
let pushedUrl = "";
|
|
48
|
+
let layerUrl = "";
|
|
28
49
|
const pushEntry = () => {
|
|
29
50
|
const prev = history.state && typeof history.state === "object" ? history.state : {};
|
|
30
51
|
history.pushState({ ...prev, nishLayer: layerId }, "");
|
|
31
52
|
pushed = true;
|
|
53
|
+
pushedUrl = layerUrl = location.href;
|
|
32
54
|
};
|
|
55
|
+
function onUrlState() {
|
|
56
|
+
if (pushed && history.state?.nishLayer === layerId) layerUrl = location.href;
|
|
57
|
+
}
|
|
33
58
|
const queuedPush = () => queueHistoryPush(pushEntry);
|
|
34
59
|
if (closeOnBack) acquireGuard();
|
|
35
60
|
const pushTimer = closeOnBack ? window.setTimeout(queuedPush, 0) : 0;
|
|
@@ -37,6 +62,7 @@ function useDialog(panelRef, onClose, closeOnBackProp = false) {
|
|
|
37
62
|
if (!pushed) return;
|
|
38
63
|
if (history.state?.nishLayer === layerId) return;
|
|
39
64
|
pushed = false;
|
|
65
|
+
carryUrl(pushedUrl, layerUrl);
|
|
40
66
|
if (!isTop(self)) {
|
|
41
67
|
pushEntry();
|
|
42
68
|
return;
|
|
@@ -47,7 +73,10 @@ function useDialog(panelRef, onClose, closeOnBackProp = false) {
|
|
|
47
73
|
if (!pushed) queuedPush();
|
|
48
74
|
}, SHEET_EXIT_MS + 60);
|
|
49
75
|
}
|
|
50
|
-
if (closeOnBack)
|
|
76
|
+
if (closeOnBack) {
|
|
77
|
+
window.addEventListener("popstate", onPop);
|
|
78
|
+
window.addEventListener(URL_STATE_EVENT, onUrlState);
|
|
79
|
+
}
|
|
51
80
|
const focusTimer = window.setTimeout(() => {
|
|
52
81
|
if (panel && !panel.contains(document.activeElement)) {
|
|
53
82
|
(panel.querySelector("[data-autofocus],[autofocus]") ?? panel).focus();
|
|
@@ -88,6 +117,7 @@ function useDialog(panelRef, onClose, closeOnBackProp = false) {
|
|
|
88
117
|
window.clearTimeout(rePushTimer);
|
|
89
118
|
cancelHistoryPush(pushEntry);
|
|
90
119
|
window.removeEventListener("popstate", onPop);
|
|
120
|
+
window.removeEventListener(URL_STATE_EVENT, onUrlState);
|
|
91
121
|
const at = s.layerStack.indexOf(self);
|
|
92
122
|
if (at >= 0) s.layerStack.splice(at, 1);
|
|
93
123
|
s.dialogCount--;
|
|
@@ -97,8 +127,11 @@ function useDialog(panelRef, onClose, closeOnBackProp = false) {
|
|
|
97
127
|
unlock();
|
|
98
128
|
opener?.focus?.();
|
|
99
129
|
if (pushed && history.state?.nishLayer === layerId) {
|
|
130
|
+
const from = pushedUrl;
|
|
131
|
+
const to = location.href;
|
|
100
132
|
s.pendingBacks++;
|
|
101
133
|
history.back();
|
|
134
|
+
if (to !== from) queueHistoryPush(() => carryUrl(from, to));
|
|
102
135
|
}
|
|
103
136
|
if (closeOnBack) releaseGuard();
|
|
104
137
|
};
|
|
@@ -265,6 +298,7 @@ function SheetHandle({ onClose, swipe, className }) {
|
|
|
265
298
|
}
|
|
266
299
|
export {
|
|
267
300
|
SheetHandle,
|
|
301
|
+
carryUrl,
|
|
268
302
|
useDialog,
|
|
269
303
|
useSheetExit,
|
|
270
304
|
useSheetSwipe
|
|
@@ -144,7 +144,7 @@ function Pagination({
|
|
|
144
144
|
className: cn("w-full min-w-0", className),
|
|
145
145
|
children: /* @__PURE__ */ jsxs("ul", { className: cn("flex flex-wrap items-center gap-1", compact && "justify-between"), children: [
|
|
146
146
|
prev,
|
|
147
|
-
compact ? /* @__PURE__ */ jsx("li", { className: "px-2 text-sm tabular-nums text-th-hi2", children: (compactLabel ??
|
|
147
|
+
compact ? /* @__PURE__ */ jsx("li", { className: "px-2 text-sm tabular-nums text-th-hi2", children: (compactLabel ?? strings.pageOfCount)(page, count) }) : paginationRange(page, count, siblings, boundaries).map(
|
|
148
148
|
(slot) => typeof slot === "number" ? control(slot, pageName(slot), slot === page, disabled, slot, `p${slot}`) : /* @__PURE__ */ jsx("li", { "aria-hidden": "true", className: cn("inline-flex items-center justify-center text-th-hi3", "min-w-6", SIZE[size].split(" ")[0]), children: "\u2026" }, slot)
|
|
149
149
|
),
|
|
150
150
|
next
|
|
@@ -50,21 +50,32 @@ function Button({
|
|
|
50
50
|
...rest
|
|
51
51
|
}) {
|
|
52
52
|
const off = !!disabled || loading;
|
|
53
|
+
const softOff = loading && !disabled;
|
|
54
|
+
const { onClick, ...restProps } = rest;
|
|
53
55
|
return /* @__PURE__ */ jsxs(
|
|
54
56
|
"button",
|
|
55
57
|
{
|
|
56
58
|
ref,
|
|
57
59
|
type,
|
|
58
|
-
disabled:
|
|
60
|
+
disabled: !!disabled,
|
|
61
|
+
"aria-disabled": softOff ? true : void 0,
|
|
59
62
|
"aria-busy": loading || void 0,
|
|
60
63
|
"data-disabled": off ? "" : void 0,
|
|
64
|
+
onClick: softOff ? (e) => {
|
|
65
|
+
e.preventDefault();
|
|
66
|
+
e.stopPropagation();
|
|
67
|
+
} : onClick,
|
|
61
68
|
className: buttonClass({
|
|
62
69
|
variant,
|
|
63
70
|
size,
|
|
64
71
|
inline,
|
|
65
|
-
className: cn(
|
|
72
|
+
className: cn(
|
|
73
|
+
variant === "link" ? LINK_DISABLED : BUTTON_DISABLED,
|
|
74
|
+
softOff && (variant === "link" ? "pointer-events-none text-th-ghost no-underline forced-colors:text-[GrayText]" : "pointer-events-none border border-th-line bg-th-elevated text-th-ghost shadow-none forced-colors:border-[GrayText] forced-colors:text-[GrayText]"),
|
|
75
|
+
className
|
|
76
|
+
)
|
|
66
77
|
}),
|
|
67
|
-
...
|
|
78
|
+
...restProps,
|
|
68
79
|
children: [
|
|
69
80
|
loading ? /* @__PURE__ */ jsx(
|
|
70
81
|
LoaderIcon,
|
|
@@ -143,7 +154,7 @@ function CardHeader({
|
|
|
143
154
|
description ? /* @__PURE__ */ jsx("p", { className: "mt-0.5 text-xs text-th-hi3", children: description }) : null
|
|
144
155
|
] })
|
|
145
156
|
] }),
|
|
146
|
-
action ? /* @__PURE__ */ jsx("div", { className: "flex
|
|
157
|
+
action ? /* @__PURE__ */ jsx("div", { className: "flex min-w-0 max-w-full flex-wrap items-center gap-2", children: action }) : null
|
|
147
158
|
]
|
|
148
159
|
}
|
|
149
160
|
);
|
|
@@ -155,6 +166,7 @@ function Card({
|
|
|
155
166
|
interactive = false,
|
|
156
167
|
variant = "surface",
|
|
157
168
|
title,
|
|
169
|
+
titleAs,
|
|
158
170
|
description,
|
|
159
171
|
action,
|
|
160
172
|
className,
|
|
@@ -178,6 +190,7 @@ function Card({
|
|
|
178
190
|
CardHeader,
|
|
179
191
|
{
|
|
180
192
|
title,
|
|
193
|
+
as: titleAs,
|
|
181
194
|
description,
|
|
182
195
|
action,
|
|
183
196
|
titleId: headingId,
|
|
@@ -66,7 +66,8 @@ function Progress({
|
|
|
66
66
|
"absolute inset-y-0 start-0 rounded-full transition-[width] duration-300 ease-out motion-reduce:transition-none",
|
|
67
67
|
FILL[tone],
|
|
68
68
|
"forced-color-adjust-none forced-colors:bg-[Highlight]",
|
|
69
|
-
|
|
69
|
+
// Pulses while motion is allowed; under reduced motion and forced colors it is a short bar, never a full one that reads as complete.
|
|
70
|
+
indeterminate && "motion-safe:animate-pulse motion-reduce:!w-2/5 forced-colors:!w-2/5"
|
|
70
71
|
),
|
|
71
72
|
style: { width: `${pct}%` }
|
|
72
73
|
}
|
|
@@ -7,6 +7,7 @@ import { apiFetch } from "./resource-classes.js";
|
|
|
7
7
|
import { ApiError, apiFetch as apiFetch2, configureApi } from "./resource-classes.js";
|
|
8
8
|
var MAX_BACKOFF_MS = 3e5;
|
|
9
9
|
var inflight = /* @__PURE__ */ new Map();
|
|
10
|
+
var clock = 0;
|
|
10
11
|
function sharedFetch(key, fetcher, signal) {
|
|
11
12
|
let entry = inflight.get(key);
|
|
12
13
|
if (!entry || entry.fetcher !== fetcher) {
|
|
@@ -15,6 +16,7 @@ function sharedFetch(key, fetcher, signal) {
|
|
|
15
16
|
fetcher,
|
|
16
17
|
ctl,
|
|
17
18
|
refs: 0,
|
|
19
|
+
seq: ++clock,
|
|
18
20
|
promise: fetcher ? fetcher(ctl.signal) : apiFetch(key, { signal: ctl.signal })
|
|
19
21
|
};
|
|
20
22
|
const forget = () => {
|
|
@@ -87,7 +89,7 @@ function useResource(key, fetcher, o = {}) {
|
|
|
87
89
|
const ctl = new AbortController();
|
|
88
90
|
ctlRef.current = ctl;
|
|
89
91
|
const run = ++runRef.current;
|
|
90
|
-
|
|
92
|
+
let startedAt = 0;
|
|
91
93
|
pollSkippedRef.current = false;
|
|
92
94
|
setState(
|
|
93
95
|
(s) => s.key === k ? { ...s, fetching: true } : {
|
|
@@ -102,10 +104,18 @@ function useResource(key, fetcher, o = {}) {
|
|
|
102
104
|
);
|
|
103
105
|
try {
|
|
104
106
|
const fn = fetcherRef.current;
|
|
105
|
-
|
|
107
|
+
let pending;
|
|
108
|
+
if (fresh) {
|
|
109
|
+
startedAt = ++clock;
|
|
110
|
+
pending = fn ? fn(ctl.signal) : apiFetch(k, { signal: ctl.signal });
|
|
111
|
+
} else {
|
|
112
|
+
pending = sharedFetch(k, fn, ctl.signal);
|
|
113
|
+
startedAt = inflight.get(k)?.seq ?? ++clock;
|
|
114
|
+
}
|
|
115
|
+
const data2 = await pending;
|
|
106
116
|
if (run !== runRef.current || ctl.signal.aborted) return;
|
|
107
117
|
failuresRef.current = 0;
|
|
108
|
-
if (mutatedRef.current
|
|
118
|
+
if (mutatedRef.current > startedAt) {
|
|
109
119
|
setState((s) => ({ ...s, key: k, error: void 0, fetching: false, settled: s.settled + 1, loaded: true }));
|
|
110
120
|
return;
|
|
111
121
|
}
|
|
@@ -181,7 +191,7 @@ function useResource(key, fetcher, o = {}) {
|
|
|
181
191
|
return () => clearInterval(id);
|
|
182
192
|
}, [intervalMs, updatedAt]);
|
|
183
193
|
const mutate = useCallback((next) => {
|
|
184
|
-
mutatedRef.current
|
|
194
|
+
mutatedRef.current = ++clock;
|
|
185
195
|
setState((s) => ({
|
|
186
196
|
...s,
|
|
187
197
|
data: typeof next === "function" ? next(s.data) : next
|
|
@@ -92,6 +92,8 @@ function Segmented({
|
|
|
92
92
|
const from = refs.current.findIndex((el) => el === document.activeElement);
|
|
93
93
|
const at = from >= 0 ? from : selected;
|
|
94
94
|
if (e.key === "Escape" && tipAt != null) {
|
|
95
|
+
e.preventDefault();
|
|
96
|
+
e.stopPropagation();
|
|
95
97
|
setTipAt(null);
|
|
96
98
|
return;
|
|
97
99
|
}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
1
3
|
// src/components/separator.tsx
|
|
4
|
+
import { useId } from "react";
|
|
2
5
|
import { cn } from "../cn.js";
|
|
3
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
7
|
var LINE = "bg-th-line forced-colors:bg-[CanvasText]";
|
|
5
8
|
function Separator({ orientation = "horizontal", decorative = true, label, className, ref, ...rest }) {
|
|
9
|
+
const labelId = useId();
|
|
6
10
|
const a11y = decorative ? { role: "none" } : { role: "separator", "aria-orientation": orientation };
|
|
7
11
|
const hasLabel = label != null && label !== false && label !== "" && orientation === "horizontal";
|
|
8
12
|
if (hasLabel) {
|
|
@@ -11,12 +15,13 @@ function Separator({ orientation = "horizontal", decorative = true, label, class
|
|
|
11
15
|
{
|
|
12
16
|
"data-orientation": orientation,
|
|
13
17
|
...a11y,
|
|
18
|
+
...!decorative && rest["aria-label"] === void 0 && rest["aria-labelledby"] === void 0 ? { "aria-labelledby": labelId } : {},
|
|
14
19
|
...rest,
|
|
15
20
|
ref,
|
|
16
21
|
className: cn("flex w-full items-center gap-3 text-xs text-th-hi3", className),
|
|
17
22
|
children: [
|
|
18
23
|
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: cn("h-px flex-1", LINE) }),
|
|
19
|
-
/* @__PURE__ */ jsx("span", { className: "shrink-0", children: label }),
|
|
24
|
+
/* @__PURE__ */ jsx("span", { id: labelId, className: "shrink-0", children: label }),
|
|
20
25
|
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: cn("h-px flex-1", LINE) })
|
|
21
26
|
]
|
|
22
27
|
}
|
|
@@ -25,18 +25,26 @@ function useServiceTokens(url = "/api/service-tokens") {
|
|
|
25
25
|
);
|
|
26
26
|
const [loading, setLoading] = useState(true);
|
|
27
27
|
const [error, setError] = useState(null);
|
|
28
|
+
const [ownerUrl, setOwnerUrl] = useState(url);
|
|
28
29
|
const [nonce, setNonce] = useState(0);
|
|
29
30
|
const seq = useRef(0);
|
|
31
|
+
const ownerRef = useRef(url);
|
|
30
32
|
useEffect(() => {
|
|
31
33
|
const mine = ++seq.current;
|
|
32
34
|
const ctl = new AbortController();
|
|
33
35
|
apiFetch(url, { signal: ctl.signal }).then((r) => {
|
|
34
36
|
if (seq.current !== mine) return;
|
|
37
|
+
ownerRef.current = url;
|
|
38
|
+
setOwnerUrl(url);
|
|
35
39
|
setTokens(r.tokens);
|
|
40
|
+
setError(null);
|
|
36
41
|
setLoading(false);
|
|
37
42
|
}).catch((e) => {
|
|
38
43
|
if (seq.current !== mine || e instanceof Error && e.name === "AbortError")
|
|
39
44
|
return;
|
|
45
|
+
if (ownerRef.current !== url) setTokens(void 0);
|
|
46
|
+
ownerRef.current = url;
|
|
47
|
+
setOwnerUrl(url);
|
|
40
48
|
setError(e instanceof Error ? e.message : strings.failedToLoad);
|
|
41
49
|
setLoading(false);
|
|
42
50
|
});
|
|
@@ -55,12 +63,15 @@ function useServiceTokens(url = "/api/service-tokens") {
|
|
|
55
63
|
{ method: "POST", body: {} }
|
|
56
64
|
);
|
|
57
65
|
seq.current++;
|
|
66
|
+
ownerRef.current = url;
|
|
67
|
+
setOwnerUrl(url);
|
|
58
68
|
setTokens(r.tokens);
|
|
59
69
|
setError(null);
|
|
60
70
|
setLoading(false);
|
|
61
71
|
},
|
|
62
72
|
[url]
|
|
63
73
|
);
|
|
74
|
+
if (ownerUrl !== url) return { tokens: void 0, loading: true, error: null, reload, revoke };
|
|
64
75
|
return { tokens, loading, error, reload, revoke };
|
|
65
76
|
}
|
|
66
77
|
function when(raw) {
|
|
@@ -83,10 +94,10 @@ function ServiceTokensSection({
|
|
|
83
94
|
description: descriptionProp,
|
|
84
95
|
id = "service-tokens",
|
|
85
96
|
className,
|
|
86
|
-
emptyMessage
|
|
97
|
+
emptyMessage,
|
|
87
98
|
revokeBody,
|
|
88
|
-
createdLabel
|
|
89
|
-
envSourceLabel
|
|
99
|
+
createdLabel,
|
|
100
|
+
envSourceLabel,
|
|
90
101
|
...rest
|
|
91
102
|
}) {
|
|
92
103
|
const strings = useStrings(TOKEN_STRINGS, STATUS_STRINGS, ERROR_STRINGS, OVERLAY_STRINGS);
|
|
@@ -148,12 +159,12 @@ function ServiceTokensSection({
|
|
|
148
159
|
} else if (sorted.length === 0) {
|
|
149
160
|
content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
150
161
|
errorRow,
|
|
151
|
-
/* @__PURE__ */ jsx("p", { className: "px-4 py-6 text-sm text-th-hi3", children: emptyMessage })
|
|
162
|
+
/* @__PURE__ */ jsx("p", { className: "px-4 py-6 text-sm text-th-hi3", children: emptyMessage ?? strings.tokenEmpty })
|
|
152
163
|
] });
|
|
153
164
|
} else {
|
|
154
165
|
const rows = sorted.map((t) => {
|
|
155
|
-
const parts = [t.id, t.scopes.join(", "), createdLabel(when(t.created))];
|
|
156
|
-
if (t.source === "env") parts.push(envSourceLabel);
|
|
166
|
+
const parts = [t.id, t.scopes.join(", "), (createdLabel ?? strings.tokenCreated)(when(t.created))];
|
|
167
|
+
if (t.source === "env") parts.push(envSourceLabel ?? strings.tokenFromEnv);
|
|
157
168
|
return /* @__PURE__ */ jsx(
|
|
158
169
|
SettingRow,
|
|
159
170
|
{
|
|
@@ -203,7 +214,7 @@ function ServiceTokensSection({
|
|
|
203
214
|
{
|
|
204
215
|
title: strings.tokenRevokeTitle(target.name),
|
|
205
216
|
body: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
206
|
-
revokeBody ?? /* @__PURE__ */ jsx("p", { children:
|
|
217
|
+
revokeBody ?? /* @__PURE__ */ jsx("p", { children: strings.tokenRevokeBody }),
|
|
207
218
|
failure ? /* @__PURE__ */ jsx("p", { role: "alert", className: "mt-3 text-th-loss", children: failure }) : null
|
|
208
219
|
] }),
|
|
209
220
|
confirmLabel: strings.tokenRevoke,
|
|
@@ -52,6 +52,21 @@ function SettingRow({
|
|
|
52
52
|
const auto = useId();
|
|
53
53
|
const labelId = `${auto}-label`;
|
|
54
54
|
const descId = `${auto}-desc`;
|
|
55
|
+
const controlRef = useRef(null);
|
|
56
|
+
const hasDescription = description != null;
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (!htmlFor || !hasDescription) return;
|
|
59
|
+
const el = controlRef.current?.ownerDocument.getElementById(htmlFor);
|
|
60
|
+
if (!el) return;
|
|
61
|
+
const had = (el.getAttribute("aria-describedby") ?? "").split(/\s+/).filter(Boolean);
|
|
62
|
+
if (had.includes(descId)) return;
|
|
63
|
+
el.setAttribute("aria-describedby", [...had, descId].join(" "));
|
|
64
|
+
return () => {
|
|
65
|
+
const now = (el.getAttribute("aria-describedby") ?? "").split(/\s+/).filter((t) => t && t !== descId);
|
|
66
|
+
if (now.length) el.setAttribute("aria-describedby", now.join(" "));
|
|
67
|
+
else el.removeAttribute("aria-describedby");
|
|
68
|
+
};
|
|
69
|
+
}, [htmlFor, hasDescription, descId]);
|
|
55
70
|
const side = inline || compact && !stacked;
|
|
56
71
|
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";
|
|
57
72
|
return /* @__PURE__ */ jsxs(
|
|
@@ -68,6 +83,7 @@ function SettingRow({
|
|
|
68
83
|
/* @__PURE__ */ jsxs(
|
|
69
84
|
"div",
|
|
70
85
|
{
|
|
86
|
+
ref: controlRef,
|
|
71
87
|
...htmlFor ? {} : { role: "group", "aria-labelledby": labelId, "aria-describedby": description != null ? descId : void 0 },
|
|
72
88
|
className: cn("flex min-w-0 items-center gap-2", stacked ? "w-full" : side ? "justify-end" : "w-full sm:w-auto sm:justify-end"),
|
|
73
89
|
children: [
|
|
@@ -119,7 +119,11 @@ function Slider({
|
|
|
119
119
|
const cur = live.current;
|
|
120
120
|
let i = 0;
|
|
121
121
|
if (cur.length === 2) {
|
|
122
|
-
if (
|
|
122
|
+
if (cur[0] === cur[1]) {
|
|
123
|
+
if (cur[0] === min) i = 1;
|
|
124
|
+
else if (cur[1] === max) i = 0;
|
|
125
|
+
else i = v >= cur[0] ? 1 : 0;
|
|
126
|
+
} else if (v <= cur[0]) i = 0;
|
|
123
127
|
else if (v >= cur[1]) i = 1;
|
|
124
128
|
else i = v - cur[0] <= cur[1] - v ? 0 : 1;
|
|
125
129
|
}
|
|
@@ -84,7 +84,8 @@ function SplitDividers({ layout, w, h, gap, onResize, onDragChange, minPane, bar
|
|
|
84
84
|
};
|
|
85
85
|
const fraction = (d) => {
|
|
86
86
|
const node = nodeAt(layout, d.path);
|
|
87
|
-
|
|
87
|
+
if (!node || node.type !== "split") return 0.5;
|
|
88
|
+
return Math.min(1, node.sizes.slice(0, d.index + 1).reduce((a, b) => a + b, 0));
|
|
88
89
|
};
|
|
89
90
|
const down = (e) => {
|
|
90
91
|
if (e.button !== 0) return;
|
|
@@ -236,6 +237,7 @@ function SplitStage({
|
|
|
236
237
|
return () => ro.disconnect();
|
|
237
238
|
}, []);
|
|
238
239
|
useEffect(() => {
|
|
240
|
+
if (size.w === 0 && size.h === 0) return;
|
|
239
241
|
onSizeRef.current?.(size);
|
|
240
242
|
}, [size]);
|
|
241
243
|
const measured = size.w > 0 && size.h > 0;
|
|
@@ -362,7 +364,7 @@ function LayoutPresetPicker({
|
|
|
362
364
|
className
|
|
363
365
|
),
|
|
364
366
|
children: [
|
|
365
|
-
/* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ jsx(ScrollRow, {
|
|
367
|
+
/* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ jsx(ScrollRow, { children: /* @__PURE__ */ jsx(
|
|
366
368
|
"div",
|
|
367
369
|
{
|
|
368
370
|
ref: group,
|
|
@@ -4,10 +4,12 @@ var OVERLAY_STRINGS = {
|
|
|
4
4
|
cancel: "Cancel",
|
|
5
5
|
menu: "Menu",
|
|
6
6
|
back: "Back: ",
|
|
7
|
-
contextMenu: "Actions"
|
|
7
|
+
contextMenu: "Actions",
|
|
8
|
+
opensInNewTab: "opens in a new tab"
|
|
8
9
|
};
|
|
9
10
|
var SHELL_STRINGS = {
|
|
10
11
|
sections: "Sections",
|
|
12
|
+
onThisPage: "On this page",
|
|
11
13
|
more: "More",
|
|
12
14
|
hubTitle: "Back to nish.software",
|
|
13
15
|
hubLabel: "\u2190 nish.software",
|
|
@@ -25,6 +27,7 @@ var STATUS_STRINGS = {
|
|
|
25
27
|
nothingHere: "Nothing here yet",
|
|
26
28
|
loadingNamed: (label) => `Loading ${label}`,
|
|
27
29
|
offline: "You're offline",
|
|
30
|
+
serverUnreachable: "Can't reach the server",
|
|
28
31
|
actions: "Actions"
|
|
29
32
|
};
|
|
30
33
|
var THEME_STRINGS = {
|
|
@@ -50,9 +53,12 @@ var DISPLAY_STRINGS = {
|
|
|
50
53
|
moreCount: (count) => `${count} more`,
|
|
51
54
|
copy: "Copy",
|
|
52
55
|
copied: "Copied",
|
|
56
|
+
copyFailed: "Copy failed",
|
|
53
57
|
legend: "Legend",
|
|
54
58
|
noData: "No data",
|
|
55
|
-
noDataNamed: (label) => `${label}: no data
|
|
59
|
+
noDataNamed: (label) => `${label}: no data`,
|
|
60
|
+
rangeLabel: (low, high, current, min, max) => `Range ${low} to ${high}${current != null ? `, current ${current}` : ""}, within ${min} to ${max}`,
|
|
61
|
+
chartTruncated: (shown, total) => `First ${shown} of ${total} points`
|
|
56
62
|
};
|
|
57
63
|
var FIELD_STRINGS = {
|
|
58
64
|
optional: "Optional",
|
|
@@ -62,6 +68,7 @@ var FIELD_STRINGS = {
|
|
|
62
68
|
removeNamed: (name) => `Remove ${name}`,
|
|
63
69
|
clear: "Clear",
|
|
64
70
|
noMatches: "No matches",
|
|
71
|
+
resultsCount: (n) => `${n} ${n === 1 ? "result" : "results"}`,
|
|
65
72
|
searching: "Searching\u2026",
|
|
66
73
|
removeTag: (tag) => `Remove ${tag}`,
|
|
67
74
|
maxTags: (max) => `You can add up to ${max}`
|
|
@@ -155,7 +162,8 @@ var CANVAS_STRINGS = {
|
|
|
155
162
|
zoomIn: "Zoom in",
|
|
156
163
|
fitToScreen: "Fit to screen",
|
|
157
164
|
followActivity: "Follow activity",
|
|
158
|
-
canvasLines: "Lines"
|
|
165
|
+
canvasLines: "Lines",
|
|
166
|
+
canvasRole: "canvas"
|
|
159
167
|
};
|
|
160
168
|
var TOKEN_STRINGS = {
|
|
161
169
|
serviceTokens: "Service tokens",
|
|
@@ -166,7 +174,11 @@ var TOKEN_STRINGS = {
|
|
|
166
174
|
tokenRevokedAt: (when) => `Revoked ${when}`,
|
|
167
175
|
tokenRevokeNamed: (name) => `Revoke ${name}`,
|
|
168
176
|
tokenRevokeTitle: (name) => `Revoke ${name}?`,
|
|
169
|
-
tokenRevokeFailed: "Could not revoke the token."
|
|
177
|
+
tokenRevokeFailed: "Could not revoke the token.",
|
|
178
|
+
tokenEmpty: "No service tokens. No machine client can read this app.",
|
|
179
|
+
tokenRevokeBody: 'Anything using this token gets "Unauthorized" from now on. This cannot be undone: to restore access, issue a new token with npm run tokens in nishant/mcp.',
|
|
180
|
+
tokenCreated: (when) => `created ${when}`,
|
|
181
|
+
tokenFromEnv: "from SERVICE_TOKENS"
|
|
170
182
|
};
|
|
171
183
|
var INBOX_STRINGS = {
|
|
172
184
|
inboxMarkHandled: "Mark handled",
|
|
@@ -183,6 +195,7 @@ var PAGING_STRINGS = {
|
|
|
183
195
|
previousPage: "Previous page",
|
|
184
196
|
nextPage: "Next page",
|
|
185
197
|
pageLabel: (n) => `Page ${n}`,
|
|
198
|
+
pageOfCount: (page, count) => `Page ${page} of ${count}`,
|
|
186
199
|
paginationLabel: "Pagination",
|
|
187
200
|
breadcrumbs: "Breadcrumbs"
|
|
188
201
|
};
|