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.
Files changed (95) hide show
  1. package/README.md +7 -3
  2. package/dist/base-tailwind.css +30 -15
  3. package/dist/base.css +30 -15
  4. package/dist/elements-all.js +78 -78
  5. package/dist/elements-charts.js +39 -38
  6. package/dist/elements-data.d.ts +10 -0
  7. package/dist/elements-data.js +4 -5
  8. package/dist/elements-forms.js +5 -5
  9. package/dist/elements.d.ts +1 -0
  10. package/dist/elements.js +4 -4
  11. package/dist/esm/command-filter.js +55 -4
  12. package/dist/esm/components/accordion.js +3 -2
  13. package/dist/esm/components/app-shell.js +8 -4
  14. package/dist/esm/components/breadcrumbs.js +7 -3
  15. package/dist/esm/components/calendar-base.js +32 -5
  16. package/dist/esm/components/calendar-classes.js +14 -2
  17. package/dist/esm/components/canvas/follow-caption.js +31 -21
  18. package/dist/esm/components/canvas/follow.js +5 -6
  19. package/dist/esm/components/canvas/minimap.js +3 -3
  20. package/dist/esm/components/canvas/system-canvas.js +3 -1
  21. package/dist/esm/components/canvas/view.js +0 -2
  22. package/dist/esm/components/carousel.js +2 -3
  23. package/dist/esm/components/charts.js +18 -7
  24. package/dist/esm/components/combobox.js +18 -7
  25. package/dist/esm/components/command.js +23 -61
  26. package/dist/esm/components/context-menu.js +2 -1
  27. package/dist/esm/components/data-classes.js +5 -4
  28. package/dist/esm/components/data.js +19 -10
  29. package/dist/esm/components/display.js +20 -11
  30. package/dist/esm/components/drawer.js +17 -4
  31. package/dist/esm/components/error-boundary.js +3 -3
  32. package/dist/esm/components/feedback.js +3 -3
  33. package/dist/esm/components/file-dropzone.js +16 -6
  34. package/dist/esm/components/filters.js +42 -1
  35. package/dist/esm/components/flow.js +8 -5
  36. package/dist/esm/components/forms-classes.js +2 -0
  37. package/dist/esm/components/forms.js +2 -2
  38. package/dist/esm/components/hooks.js +47 -13
  39. package/dist/esm/components/hover-card.js +2 -1
  40. package/dist/esm/components/inbox.js +5 -1
  41. package/dist/esm/components/latest.js +4 -2
  42. package/dist/esm/components/layout.js +7 -4
  43. package/dist/esm/components/menu.js +10 -1
  44. package/dist/esm/components/modal.js +17 -4
  45. package/dist/esm/components/multi-select.js +5 -5
  46. package/dist/esm/components/nav.js +30 -11
  47. package/dist/esm/components/navigate.js +1 -1
  48. package/dist/esm/components/overlay-dialog.js +35 -1
  49. package/dist/esm/components/pagination.js +1 -1
  50. package/dist/esm/components/primitives.js +17 -4
  51. package/dist/esm/components/progress.js +2 -1
  52. package/dist/esm/components/resource.js +14 -4
  53. package/dist/esm/components/segmented.js +2 -0
  54. package/dist/esm/components/separator.js +6 -1
  55. package/dist/esm/components/service-tokens.js +18 -7
  56. package/dist/esm/components/settings.js +16 -0
  57. package/dist/esm/components/slider.js +5 -1
  58. package/dist/esm/components/split.js +4 -2
  59. package/dist/esm/components/strings.js +17 -4
  60. package/dist/esm/components/table.js +15 -3
  61. package/dist/esm/components/tag-input.js +5 -1
  62. package/dist/esm/components/time-field.js +15 -7
  63. package/dist/esm/components/toast-card.js +5 -3
  64. package/dist/esm/components/toast.js +4 -1
  65. package/dist/esm/components/tooltip.js +3 -2
  66. package/dist/esm/components/url-state.js +3 -1
  67. package/dist/esm/components/virtual-table.js +2 -2
  68. package/dist/esm/components/virtual.js +8 -4
  69. package/dist/esm/format.js +3 -2
  70. package/dist/esm/runtime.js +1 -1
  71. package/dist/esm/server/inbox/client.js +4 -0
  72. package/dist/esm/theme.js +38 -15
  73. package/dist/esm/tokens.mjs +1 -1
  74. package/dist/format.d.ts +5 -3
  75. package/dist/format.js +4 -3
  76. package/dist/inbox-client.d.ts +1 -1
  77. package/dist/inbox-client.js +4 -0
  78. package/dist/index.d.ts +61 -29
  79. package/dist/nish-components.css +59 -21
  80. package/dist/nish-components.min.css +1 -1
  81. package/dist/nish.css +30 -15
  82. package/dist/nish.min.css +1 -1
  83. package/dist/node/vite.js +1 -1
  84. package/dist/server/hono.d.ts +9 -2
  85. package/dist/server/hono.js +17 -4
  86. package/dist/server/index.d.ts +3 -3
  87. package/dist/server/index.js +7 -2
  88. package/dist/service-tokens.d.ts +4 -4
  89. package/dist/{spa-BfRDo38r.d.ts → spa-FwS7yZ8p.d.ts} +4 -3
  90. package/dist/system-canvas.d.ts +11 -10
  91. package/dist/theme.d.ts +30 -2
  92. package/dist/theme.global.js +45 -18
  93. package/dist/theme.js +45 -18
  94. package/package.json +3 -2
  95. package/dist/tokens.js +0 -425
@@ -101,15 +101,15 @@ function Callout({
101
101
  if (hrefProp != null && href === void 0) warnDev(`nish-ui: Callout dropped an unsafe href (${hrefProp.slice(0, 40)}).`);
102
102
  const interactive = href != null || onClick != null;
103
103
  const iconEl = shown ? /* @__PURE__ */ jsx("span", { className: cn("shrink-0", compact ? "mt-px" : "mt-0.5", t.icon), children: shown }) : null;
104
- const text = /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1 basis-60", children: [
105
- title || count != null ? /* @__PURE__ */ jsxs("p", { className: "flex items-center gap-2 font-medium leading-snug text-th-hi", children: [
104
+ const text = /* @__PURE__ */ jsxs("span", { className: "block min-w-0 flex-1 basis-60", children: [
105
+ title || count != null ? /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2 font-medium leading-snug text-th-hi", children: [
106
106
  title ? /* @__PURE__ */ jsx("span", { className: "min-w-0", children: title }) : null,
107
107
  count != null ? /* @__PURE__ */ jsxs(Badge, { tone, "aria-label": strings.moreCount(count), className: "shrink-0", children: [
108
108
  "+",
109
109
  count
110
110
  ] }) : null
111
111
  ] }) : null,
112
- children ? /* @__PURE__ */ jsx("div", { className: cn("leading-snug text-th-hi2", title || count != null ? "mt-0.5" : null, clamp && CALLOUT_CLAMP[clamp]), children }) : null
112
+ children ? /* @__PURE__ */ jsx("span", { className: cn("block leading-snug text-th-hi2", title || count != null ? "mt-0.5" : null, clamp && CALLOUT_CLAMP[clamp]), children }) : null
113
113
  ] });
114
114
  const actionEl = action ? /* @__PURE__ */ jsx("div", { className: "flex shrink-0 items-center gap-2", children: action }) : null;
115
115
  const dismissEl = onDismiss ? /* @__PURE__ */ jsx(IconButton, { label: dismissLabel ?? strings.dismiss, size: "xs", onClick: onDismiss, className: "-my-0.5 -me-1", children: /* @__PURE__ */ jsx(XIcon, { size: 14 }) }) : null;
@@ -378,9 +378,17 @@ function Disclosure({
378
378
  open: isOpen,
379
379
  "data-state": isOpen ? "open" : "closed",
380
380
  onToggle: (e) => {
381
- const now = e.currentTarget.open;
382
- if (open === void 0) setInner(now);
383
- if (open === void 0 || now !== open) onOpenChange?.(now);
381
+ const el = e.currentTarget;
382
+ const now = el.open;
383
+ if (open === void 0) {
384
+ setInner(now);
385
+ onOpenChange?.(now);
386
+ return;
387
+ }
388
+ if (now !== open) {
389
+ onOpenChange?.(now);
390
+ el.open = open;
391
+ }
384
392
  },
385
393
  className: cn(
386
394
  "group",
@@ -464,7 +472,7 @@ function CopyButton({
464
472
  text,
465
473
  label,
466
474
  copiedLabel,
467
- failedLabel = "Copy failed",
475
+ failedLabel,
468
476
  iconOnly = false,
469
477
  size = "sm",
470
478
  variant = "secondary",
@@ -476,6 +484,7 @@ function CopyButton({
476
484
  const strings = useStrings(DISPLAY_STRINGS, SHELL_STRINGS);
477
485
  const idleText = label ?? strings.copy;
478
486
  const doneText = copiedLabel ?? strings.copied;
487
+ const failText = failedLabel ?? strings.copyFailed;
479
488
  const [state, setState] = useState("idle");
480
489
  const timer = useRef(null);
481
490
  useEffect(
@@ -491,12 +500,12 @@ function CopyButton({
491
500
  if (timer.current) clearTimeout(timer.current);
492
501
  timer.current = setTimeout(() => setState("idle"), COPIED_MS);
493
502
  };
494
- const shownText = state === "copied" ? doneText : state === "failed" ? failedLabel : idleText;
503
+ const shownText = state === "copied" ? doneText : state === "failed" ? failText : idleText;
495
504
  const iconSize = size === "sm" ? 14 : 16;
496
505
  const icon = state === "copied" ? /* @__PURE__ */ jsx(CheckIcon, { size: iconSize, className: "text-th-ok" }) : /* @__PURE__ */ jsx(CopyIcon, { size: iconSize });
497
506
  return /* @__PURE__ */ jsxs(Fragment, { children: [
498
507
  iconOnly ? /* @__PURE__ */ jsx(IconButton, { ref, label: shownText, size, onClick, className, "data-state": state, ...rest, children: icon }) : /* @__PURE__ */ jsx(Button, { ref, variant, size, icon, onClick, className, "data-state": state, ...rest, children: shownText }),
499
- /* @__PURE__ */ jsx("span", { role: "status", "aria-live": "polite", className: "sr-only", children: state === "copied" ? doneText : state === "failed" ? failedLabel : "" })
508
+ /* @__PURE__ */ jsx("span", { role: "status", "aria-live": "polite", className: "sr-only", children: state === "copied" ? doneText : state === "failed" ? failText : "" })
500
509
  ] });
501
510
  }
502
511
  function PageHeader({
@@ -513,7 +522,7 @@ function PageHeader({
513
522
  ...rest
514
523
  }) {
515
524
  const ref = useRef(null);
516
- const stuck = useStuck(ref) && sticky;
525
+ const stuck = useStuck(ref, sticky) && sticky;
517
526
  const collapsed = stuck && collapseWhenStuck;
518
527
  return /* @__PURE__ */ jsxs(
519
528
  "header",
@@ -582,7 +591,7 @@ function AppHeader({
582
591
  const strings = useStrings(DISPLAY_STRINGS, SHELL_STRINGS);
583
592
  const ref = useRef(null);
584
593
  useHeightVar(ref, "--nish-header-h", sticky);
585
- const stuck = useStuck(ref) && sticky;
594
+ const stuck = useStuck(ref, sticky) && sticky;
586
595
  const inlineActionsRef = useRef(null);
587
596
  useEffect(() => {
588
597
  inlineActionsRef.current?.querySelectorAll('[role="menuitem"]').forEach((el) => {
@@ -9,7 +9,7 @@ import { Portal } from "./portal.js";
9
9
  import { useStrings } from "./provider.js";
10
10
  import { OVERLAY_STRINGS } from "./strings.js";
11
11
  import { DRAWER_SHEET_HEIGHT, DRAWER_WIDTH } from "./overlay-classes.js";
12
- import { warnDev, useMergedRef, useScrollable } from "./overlay-core.js";
12
+ import { warnDev, useMergedRef, useScrollable, ov, isTop } from "./overlay-core.js";
13
13
  import { useDialog, useSheetExit, useSheetSwipe, SheetHandle } from "./overlay-dialog.js";
14
14
  import { jsx, jsxs } from "react/jsx-runtime";
15
15
  function Drawer({ open, ...props }) {
@@ -50,6 +50,18 @@ function DrawerPanel({
50
50
  const named = hasTitle || !!ariaLabel || !!ariaLabelledBy;
51
51
  const scrollable = useScrollable(bodyRef);
52
52
  const bodyLabel = typeof title === "string" ? title : ariaLabel;
53
+ const bodyLabelledBy = bodyLabel ? void 0 : hasTitle ? titleId : ariaLabelledBy;
54
+ const bodyNamed = !!bodyLabel || !!bodyLabelledBy;
55
+ const covered = useRef(false);
56
+ useEffect(() => {
57
+ const stack = ov().layerStack;
58
+ const self = stack[stack.length - 1];
59
+ const down = () => {
60
+ covered.current = !!self && !isTop(self);
61
+ };
62
+ document.addEventListener("pointerdown", down, true);
63
+ return () => document.removeEventListener("pointerdown", down, true);
64
+ }, []);
53
65
  useEffect(() => {
54
66
  if (!named) warnDev("nish-ui: <Drawer> has no accessible name. Pass `title`, `aria-label` or `aria-labelledby`.");
55
67
  }, [named]);
@@ -65,7 +77,7 @@ function DrawerPanel({
65
77
  ),
66
78
  style: bottom && bottomOffset ? { bottom: bottomOffset } : void 0,
67
79
  onMouseDown: (e) => {
68
- if (e.target === e.currentTarget) requestClose();
80
+ if (e.target === e.currentTarget && !covered.current) requestClose();
69
81
  },
70
82
  children: /* @__PURE__ */ jsxs(
71
83
  "div",
@@ -121,9 +133,10 @@ function DrawerPanel({
121
133
  "div",
122
134
  {
123
135
  ref: bodyRef,
124
- tabIndex: scrollable ? 0 : void 0,
125
- role: scrollable && bodyLabel ? "region" : void 0,
136
+ tabIndex: scrollable && bodyNamed ? 0 : void 0,
137
+ role: scrollable && bodyNamed ? "region" : void 0,
126
138
  "aria-label": scrollable ? bodyLabel : void 0,
139
+ "aria-labelledby": scrollable ? bodyLabelledBy : void 0,
127
140
  className: "min-h-0 flex-1 overflow-y-auto overscroll-contain px-5 py-4 text-sm text-th-hi2",
128
141
  children
129
142
  }
@@ -6,7 +6,7 @@ import { Button, Card } from "./primitives.js";
6
6
  import { useStrings } from "./provider.js";
7
7
  import { ERROR_STRINGS } from "./strings.js";
8
8
  import { jsx, jsxs } from "react/jsx-runtime";
9
- var CHUNK_MESSAGE = /Failed to fetch dynamically imported module|Importing a module script failed/;
9
+ var CHUNK_MESSAGE = /failed to fetch dynamically imported module|importing a module script failed|error loading dynamically imported module|unable to preload css/i;
10
10
  function isChunkError(e) {
11
11
  return e.name === "ChunkLoadError" || CHUNK_MESSAGE.test(e.message);
12
12
  }
@@ -29,8 +29,8 @@ var Boundary = class extends Component {
29
29
  componentDidCatch(error, info) {
30
30
  this.props.onError?.(error instanceof Error ? error : new Error(String(error)), { componentStack: info.componentStack });
31
31
  }
32
- componentDidUpdate(prev) {
33
- if (this.state.error && changed(prev.resetKeys, this.props.resetKeys)) this.reset();
32
+ componentDidUpdate(prev, prevState) {
33
+ if (this.state.error && prevState.error && changed(prev.resetKeys, this.props.resetKeys)) this.reset();
34
34
  }
35
35
  reset = () => {
36
36
  this.setState({ error: null });
@@ -111,9 +111,9 @@ function ErrorState({
111
111
  "button",
112
112
  {
113
113
  type: "button",
114
- onClick: onRetry,
115
- disabled: retrying,
116
- className: "mt-1 inline-flex items-center gap-1.5 rounded-full border border-th-line-strong px-3 py-1 text-xs text-th-hi2 transition-colors hover:bg-th-elevated hover:text-th-hi disabled:opacity-50 pointer-coarse:min-h-11",
114
+ onClick: retrying ? void 0 : onRetry,
115
+ "aria-disabled": retrying || void 0,
116
+ className: "mt-1 inline-flex items-center gap-1.5 rounded-full border border-th-line-strong px-3 py-1 text-xs text-th-hi2 transition-colors hover:bg-th-elevated hover:text-th-hi aria-disabled:opacity-50 pointer-coarse:min-h-11",
117
117
  children: [
118
118
  retrying ? /* @__PURE__ */ jsx(LoaderIcon, { size: 12, className: "animate-spin" }) : /* @__PURE__ */ jsx(RotateIcon, { size: 12 }),
119
119
  retryLabel ?? s.retry
@@ -81,6 +81,8 @@ function FileDropzone({
81
81
  const depth = useRef(0);
82
82
  const [files, setFiles] = useState([]);
83
83
  const [dragging, setDragging] = useState(false);
84
+ const list = useRef(null);
85
+ const pendingFocus = useRef(null);
84
86
  const isInvalid = invalid || ariaInvalid === true || ariaInvalid === "true";
85
87
  const latestChange = useRef(onFilesChange);
86
88
  useEffect(() => {
@@ -102,22 +104,29 @@ function FileDropzone({
102
104
  form.addEventListener("reset", onReset);
103
105
  return () => form.removeEventListener("reset", onReset);
104
106
  }, []);
107
+ useEffect(() => {
108
+ const index = pendingFocus.current;
109
+ if (index === null) return;
110
+ pendingFocus.current = null;
111
+ const buttons = list.current?.querySelectorAll("button") ?? [];
112
+ (buttons[index] ?? buttons[index - 1] ?? input.current)?.focus();
113
+ }, [files]);
105
114
  const take = (incoming) => {
106
115
  const rejected = [];
107
- const list = multiple ? [...files] : [];
116
+ const list2 = multiple ? [...files] : [];
108
117
  const cap = multiple ? maxFiles ?? Infinity : 1;
109
118
  let changed = false;
110
119
  for (const file of incoming) {
111
120
  if (!matchesAccept(file, accept)) rejected.push({ file, reason: "type" });
112
121
  else if (maxSize !== void 0 && file.size > maxSize) rejected.push({ file, reason: "size" });
113
- else if (multiple && list.some((f) => sameFile(f, file))) continue;
114
- else if (list.length >= cap) rejected.push({ file, reason: "count" });
122
+ else if (multiple && list2.some((f) => sameFile(f, file))) continue;
123
+ else if (list2.length >= cap) rejected.push({ file, reason: "count" });
115
124
  else {
116
- list.push(file);
125
+ list2.push(file);
117
126
  changed = true;
118
127
  }
119
128
  }
120
- const next = !multiple && list.length === 0 ? files : list;
129
+ const next = !multiple && list2.length === 0 ? files : list2;
121
130
  syncInput(input.current, next);
122
131
  if (!changed && rejected.length === 0) return;
123
132
  if (next !== files) setFiles(next);
@@ -125,6 +134,7 @@ function FileDropzone({
125
134
  };
126
135
  const removeAt = (index) => {
127
136
  const next = files.filter((_, i) => i !== index);
137
+ pendingFocus.current = index;
128
138
  setFiles(next);
129
139
  syncInput(input.current, next);
130
140
  onFilesChange?.(next, []);
@@ -206,7 +216,7 @@ function FileDropzone({
206
216
  ]
207
217
  }
208
218
  ),
209
- files.length > 0 ? /* @__PURE__ */ jsx("ul", { className: "grid gap-1.5", children: files.map((file, i) => /* @__PURE__ */ jsxs(
219
+ files.length > 0 ? /* @__PURE__ */ jsx("ul", { ref: list, className: "grid gap-1.5", children: files.map((file, i) => /* @__PURE__ */ jsxs(
210
220
  "li",
211
221
  {
212
222
  className: "flex items-center gap-2 rounded-lg border border-th-line bg-th-surface py-1 pe-1 ps-3 text-sm",
@@ -4,6 +4,7 @@
4
4
  import { useState } from "react";
5
5
  import { cn } from "../cn.js";
6
6
  import { SearchInput } from "./forms.js";
7
+ import { useIsClient } from "./client.js";
7
8
  import { NARROW_QUERY, useMediaQuery } from "./hooks.js";
8
9
  import { Drawer } from "./drawer.js";
9
10
  import { Badge, Button } from "./primitives.js";
@@ -63,6 +64,7 @@ function FilterBar({
63
64
  ...rest
64
65
  }) {
65
66
  const strings = useStrings(FILTER_STRINGS, FIELD_STRINGS);
67
+ const isClient = useIsClient();
66
68
  const compact = useMediaQuery(sheetBelow === "lg" ? LG_QUERY : NARROW_QUERY);
67
69
  const [openState, setOpen] = useState(false);
68
70
  const open = openState && compact;
@@ -78,6 +80,45 @@ function FilterBar({
78
80
  className: compact ? "min-w-[10rem] flex-1 basis-40" : "w-full max-w-xs"
79
81
  }
80
82
  ) : null;
83
+ const hasSummary = summary != null && summary !== false && summary !== "";
84
+ if (!isClient) {
85
+ const lg = sheetBelow === "lg";
86
+ const searchClass = lg ? "min-w-[10rem] flex-1 basis-40 lg:w-full lg:max-w-xs lg:flex-none lg:basis-auto" : "min-w-[10rem] flex-1 basis-40 md:w-full md:max-w-xs md:flex-none md:basis-auto";
87
+ const buttonClass = lg ? "min-h-11 shrink-0 lg:hidden" : "min-h-11 shrink-0 md:hidden";
88
+ const wrapClass = lg ? "contents max-lg:hidden" : "contents max-md:hidden";
89
+ return /* @__PURE__ */ jsxs(
90
+ "div",
91
+ {
92
+ ...rest,
93
+ ref,
94
+ className: cn(sticky && "sticky top-[var(--nish-header-h,0px)] z-[var(--nish-z-sticky,20)] border-b border-th-line bg-th-bg py-2", className),
95
+ children: [
96
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
97
+ search ? /* @__PURE__ */ jsx(
98
+ SearchInput,
99
+ {
100
+ value: search.value,
101
+ onChange: (v) => search.onChange(v),
102
+ placeholder: search.placeholder,
103
+ "aria-label": search.label ?? search.placeholder ?? strings.search,
104
+ className: searchClass
105
+ }
106
+ ) : null,
107
+ hasChildren ? /* @__PURE__ */ jsxs(Button, { variant: "secondary", size: "md", icon: /* @__PURE__ */ jsx(FunnelIcon, {}), "aria-haspopup": "dialog", "aria-expanded": false, className: buttonClass, children: [
108
+ strings.filters,
109
+ activeCount > 0 ? /* @__PURE__ */ jsx(Badge, { tone: "accent", "aria-label": strings.activeCount(activeCount), children: activeCount }) : null
110
+ ] }) : null,
111
+ /* @__PURE__ */ jsxs("div", { className: wrapClass, children: [
112
+ children,
113
+ activeCount > 0 && onClear ? /* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: onClear, children: strings.clearFilters }) : null
114
+ ] }),
115
+ trailing ? /* @__PURE__ */ jsx("div", { className: "ms-auto flex items-center gap-2", children: trailing }) : null
116
+ ] }),
117
+ /* @__PURE__ */ jsx("div", { "aria-live": "polite", className: cn("text-sm text-th-hi3", hasSummary ? "mt-2" : void 0), children: summary ?? null })
118
+ ]
119
+ }
120
+ );
121
+ }
81
122
  return /* @__PURE__ */ jsxs(
82
123
  "div",
83
124
  {
@@ -99,7 +140,7 @@ function FilterBar({
99
140
  trailing ? /* @__PURE__ */ jsx("div", { className: "ms-auto flex items-center gap-2", children: trailing }) : null
100
141
  ] })
101
142
  ] }),
102
- /* @__PURE__ */ jsx("div", { "aria-live": "polite", className: cn("text-sm text-th-hi3", summary ? "mt-2" : void 0), children: summary || null }),
143
+ /* @__PURE__ */ jsx("div", { "aria-live": "polite", className: cn("text-sm text-th-hi3", hasSummary ? "mt-2" : void 0), children: summary ?? null }),
103
144
  compact && hasChildren ? /* @__PURE__ */ jsx(FilterSheet, { open, onClose: () => setOpen(false), title: sheetTitle ?? strings.filters, onClear, activeCount, children }) : null
104
145
  ]
105
146
  }
@@ -120,14 +120,14 @@ var NODE_STATUS = {
120
120
  done: "bg-th-ok-fill text-th-on-ok forced-colors:border-2 forced-colors:border-[color:Highlight]",
121
121
  failed: "bg-th-loss-fill text-th-on-loss forced-colors:border-2 forced-colors:border-dashed forced-colors:border-[color:CanvasText]"
122
122
  };
123
- function pickStepFx(from, to) {
123
+ function pickStepFx(_from, to) {
124
124
  if (to === "done") return "done";
125
125
  if (to === "failed") return "failed";
126
- return from === to ? null : null;
126
+ return null;
127
127
  }
128
128
  function withFullText(text, label) {
129
129
  if (typeof text !== "string") return label;
130
- return /* @__PURE__ */ jsx(Tooltip, { tip: text, className: "nish-flow-label-tip max-w-full min-w-0", children: label });
130
+ return /* @__PURE__ */ jsx(Tooltip, { tip: text, focusable: false, className: "nish-flow-label-tip max-w-full min-w-0", children: label });
131
131
  }
132
132
  function StepRow({
133
133
  step,
@@ -349,7 +349,10 @@ function AgentNode({ label, state, model, activity, meta, onClick, stateLabels,
349
349
  done: s.agentDone,
350
350
  failed: s.agentFailed
351
351
  };
352
- const aria = `${label}: ${stateLabels?.[state] ?? stateWord[state]}`;
352
+ const extras = [model, typeof meta === "string" || typeof meta === "number" ? String(meta) : null, activity].filter(
353
+ (x) => typeof x === "string" && x !== ""
354
+ );
355
+ const aria = [`${label}: ${stateLabels?.[state] ?? stateWord[state]}`, ...extras].join(", ");
353
356
  const classes = cn(
354
357
  "nish-flow-agent block min-h-16 w-full min-w-0 rounded-xl border bg-th-surface p-3 text-start",
355
358
  AGENT_STATE[state],
@@ -510,7 +513,7 @@ var FEED_DOT_FORCED = "forced-colors:bg-[color:CanvasText]";
510
513
  function ActivityFeed({ items, max = 50, now, label, empty, className, ref, ...rest }) {
511
514
  const s = useStrings(PROGRESS_STRINGS, FLOW_STRINGS);
512
515
  const { locale } = useNishContext();
513
- const internalNow = useNow(15e3);
516
+ const internalNow = useNow(now != null ? 2147483647 : 15e3);
514
517
  const clock = now ?? internalNow;
515
518
  const shown = useMemo(() => [...items].sort((a, b) => b.at - a.at).slice(0, Math.max(0, max)), [items, max]);
516
519
  const fresh = useFreshIds(
@@ -34,9 +34,11 @@ var SEGMENTED_SIZE = {
34
34
  function indexComboboxOptions(options) {
35
35
  return options.map((option) => ({ option, label: option.label.toLowerCase(), hint: option.hint?.toLowerCase() }));
36
36
  }
37
+ var TAG_REMOVE_HIT = "pointer-coarse:min-h-0 pointer-coarse:min-w-0 pointer-coarse:relative pointer-coarse:after:absolute pointer-coarse:after:left-1/2 pointer-coarse:after:top-1/2 pointer-coarse:after:size-11 pointer-coarse:after:-translate-x-1/2 pointer-coarse:after:-translate-y-1/2 pointer-coarse:after:rounded-full pointer-coarse:after:content-['']";
37
38
  export {
38
39
  SEGMENTED_SELECTED,
39
40
  SEGMENTED_SIZE,
41
+ TAG_REMOVE_HIT,
40
42
  chipClass,
41
43
  indexComboboxOptions,
42
44
  setRef
@@ -18,7 +18,7 @@ import { isRtl, useIsoLayoutEffect } from "./client.js";
18
18
  import { useStrings } from "./provider.js";
19
19
  import { FIELD_STRINGS } from "./strings.js";
20
20
  import { warnDev } from "./display-classes.js";
21
- import { chipClass, setRef } from "./forms-classes.js";
21
+ import { chipClass, setRef, TAG_REMOVE_HIT } from "./forms-classes.js";
22
22
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
23
23
  function Svg({ size = 16, children, ...rest }) {
24
24
  return /* @__PURE__ */ jsx("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", focusable: "false", ...rest, children });
@@ -537,7 +537,7 @@ function Chip({ ref, variant = "toggle", pressed, onRemove, removeLabel, icon, t
537
537
  icon,
538
538
  children,
539
539
  trailing,
540
- onRemove ? /* @__PURE__ */ jsx(IconButton, { label: name, size: "xs", onClick: onRemove, className: "rounded-full", children: /* @__PURE__ */ jsx(XIcon, { size: 12 }) }) : null
540
+ onRemove ? /* @__PURE__ */ jsx(IconButton, { label: name, size: "xs", onClick: onRemove, className: cn("rounded-full", TAG_REMOVE_HIT), children: /* @__PURE__ */ jsx(XIcon, { size: 12 }) }) : null
541
541
  ]
542
542
  }
543
543
  );
@@ -87,18 +87,45 @@ function subscribeBreakpoint(onChange) {
87
87
  function useBreakpoint() {
88
88
  return useSyncExternalStore(subscribeBreakpoint, currentBreakpoint, () => "base");
89
89
  }
90
+ var titles = () => shared("documentTitle", () => ({
91
+ entries: [],
92
+ base: null,
93
+ seq: 0
94
+ }));
95
+ function applyTitle() {
96
+ const { entries } = titles();
97
+ let winner = entries[entries.length - 1];
98
+ for (let i = entries.length - 1; i >= 0; i--) {
99
+ if (entries[i].titled) {
100
+ winner = entries[i];
101
+ break;
102
+ }
103
+ }
104
+ if (winner) document.title = winner.next;
105
+ }
90
106
  function useDocumentTitle(title, o = {}) {
91
107
  const app = o.app;
108
+ const [id] = useState(() => ++titles().seq);
92
109
  useEffect(() => {
93
110
  if (typeof document === "undefined") return;
94
111
  const next = title && app ? `${title} \xB7 ${app}` : title || app;
95
112
  if (!next) return;
96
- const previous = document.title;
97
- document.title = next;
113
+ const t = titles();
114
+ if (t.entries.length === 0) t.base = document.title;
115
+ const entry = { id, next, titled: !!title };
116
+ const at = t.entries.findIndex((e) => e.id === id);
117
+ if (at >= 0) t.entries[at] = entry;
118
+ else t.entries.push(entry);
119
+ applyTitle();
98
120
  return () => {
99
- document.title = previous;
121
+ const cur = titles();
122
+ cur.entries = cur.entries.filter((e) => e.id !== id);
123
+ if (cur.entries.length === 0) {
124
+ if (cur.base !== null) document.title = cur.base;
125
+ cur.base = null;
126
+ } else applyTitle();
100
127
  };
101
- }, [title, app]);
128
+ }, [title, app, id]);
102
129
  }
103
130
  function useNow(intervalMs = 3e4) {
104
131
  const [now, setNow] = useState(() => Date.now());
@@ -130,7 +157,8 @@ function useNow(intervalMs = 3e4) {
130
157
  var local = () => shared("localStorage", () => ({
131
158
  subs: /* @__PURE__ */ new Map(),
132
159
  memory: /* @__PURE__ */ new Map(),
133
- listening: false
160
+ listening: false,
161
+ handler: void 0
134
162
  }));
135
163
  var warned = /* @__PURE__ */ new Set();
136
164
  function notify(key) {
@@ -149,16 +177,20 @@ function subscribeKey(key, cb) {
149
177
  if (!set) local().subs.set(key, set = /* @__PURE__ */ new Set());
150
178
  const subs = set;
151
179
  subs.add(cb);
152
- if (!local().listening) {
153
- local().listening = true;
154
- window.addEventListener("storage", onStorageEvent);
180
+ const rec = local();
181
+ if (!rec.handler) {
182
+ rec.handler = onStorageEvent;
183
+ rec.listening = true;
184
+ window.addEventListener("storage", rec.handler);
155
185
  }
156
186
  return () => {
157
187
  subs.delete(cb);
158
- if (subs.size === 0 && local().subs.get(key) === subs) local().subs.delete(key);
159
- if (local().subs.size === 0 && local().listening) {
160
- local().listening = false;
161
- window.removeEventListener("storage", onStorageEvent);
188
+ const r = local();
189
+ if (subs.size === 0 && r.subs.get(key) === subs) r.subs.delete(key);
190
+ if (r.subs.size === 0 && r.handler) {
191
+ window.removeEventListener("storage", r.handler);
192
+ r.handler = void 0;
193
+ r.listening = false;
162
194
  }
163
195
  };
164
196
  }
@@ -187,7 +219,9 @@ function parseStored(key, text, initial, raw) {
187
219
  }
188
220
  function useLocalStorage(key, initial, o = {}) {
189
221
  const raw = !!o.raw;
190
- const [first] = useState(() => initial);
222
+ const [held, setHeld] = useState(() => ({ key, initial }));
223
+ if (held.key !== key) setHeld({ key, initial });
224
+ const first = held.key === key ? held.initial : initial;
191
225
  const subscribe = useCallback((onChange) => subscribeKey(key, onChange), [key]);
192
226
  const get = useCallback(() => readText(key), [key]);
193
227
  const text = useSyncExternalStore(subscribe, get, () => null);
@@ -191,7 +191,8 @@ function HoverCard({
191
191
  onPointerEnter?.(e);
192
192
  },
193
193
  onPointerLeave: (e) => {
194
- hide();
194
+ const active = document.activeElement;
195
+ if (!(active && wrapperRef.current?.contains(active) && keyboardFocused(active))) hide();
195
196
  onPointerLeave?.(e);
196
197
  },
197
198
  style: {
@@ -160,7 +160,11 @@ function Inbox({
160
160
  const labelOf = (id) => sourceLabels[id] ?? id;
161
161
  const rowId = (id) => `${idBase}-item-${id}`;
162
162
  useEffect(() => {
163
- if (selectedId == null || scrolled.current === selectedId) return;
163
+ if (selectedId == null) {
164
+ scrolled.current = null;
165
+ return;
166
+ }
167
+ if (scrolled.current === selectedId) return;
164
168
  const el = document.getElementById(rowId(selectedId));
165
169
  if (!el) return;
166
170
  scrolled.current = selectedId;
@@ -1,6 +1,8 @@
1
+ "use client";
2
+
1
3
  // src/components/latest.ts
2
- import { useEffect, useLayoutEffect, useRef } from "react";
3
- var useIsoLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
4
+ import { useRef } from "react";
5
+ import { useIsoLayoutEffect } from "./client.js";
4
6
  function useLatest(value) {
5
7
  const ref = useRef(value);
6
8
  useIsoLayoutEffect(() => {
@@ -4,6 +4,7 @@
4
4
  import {
5
5
  useCallback,
6
6
  useEffect,
7
+ useMemo,
7
8
  useRef,
8
9
  useState,
9
10
  useSyncExternalStore
@@ -29,12 +30,13 @@ function StickyBar({
29
30
  const ref = useRef(null);
30
31
  const stuck = useStuck(ref);
31
32
  useHeightVar(ref, "--nish-sticky-extra");
33
+ const mergedRef = useMemo(() => mergeRefs(ref, refProp), [refProp]);
32
34
  const Tag = as;
33
35
  return /* @__PURE__ */ jsx(
34
36
  Tag,
35
37
  {
36
38
  ...rest,
37
- ref: mergeRefs(ref, refProp),
39
+ ref: mergedRef,
38
40
  "data-nish-bar": "",
39
41
  style: { top, ...style },
40
42
  className: cn(
@@ -58,13 +60,14 @@ function StickyActionBar({
58
60
  }) {
59
61
  const strings = useStrings(STATUS_STRINGS);
60
62
  const ref = useRef(null);
63
+ const mergedRef = useMemo(() => mergeRefs(ref, refProp), [refProp]);
61
64
  useHeightVar(ref, "--nish-bottom-bar-h", open);
62
65
  if (!open) return null;
63
66
  return /* @__PURE__ */ jsxs(
64
67
  "div",
65
68
  {
66
69
  ...rest,
67
- ref: mergeRefs(ref, refProp),
70
+ ref: mergedRef,
68
71
  role: "region",
69
72
  "aria-label": label ?? strings.actions,
70
73
  "data-state": "open",
@@ -180,7 +183,7 @@ function useOnline() {
180
183
  function ConnectionBanner({
181
184
  healthUrl,
182
185
  intervalMs = 3e4,
183
- message = "Can't reach the server",
186
+ message,
184
187
  offlineMessage,
185
188
  retryLabel,
186
189
  onRetry,
@@ -266,7 +269,7 @@ function ConnectionBanner({
266
269
  compact: true,
267
270
  ...rest,
268
271
  action: /* @__PURE__ */ jsx(Button, { size: "sm", variant: "secondary", loading: retrying, onClick: () => void retry(), children: retryLabel ?? strings.retry }),
269
- children: online ? message : offlineMessage ?? strings.offline
272
+ children: online ? message ?? strings.serverUnreachable : offlineMessage ?? strings.offline
270
273
  }
271
274
  );
272
275
  }
@@ -80,6 +80,15 @@ function DropdownMenu({
80
80
  const close = useCallback(() => setOpen(false), [setOpen]);
81
81
  const dismiss = useCallback((reason) => setOpen(false, reason), [setOpen]);
82
82
  useDismiss(shown && !asSheet, menuRef, triggerRef, dismiss);
83
+ const sheetEscape = useRef(false);
84
+ useEffect(() => {
85
+ if (!(shown && asSheet)) return;
86
+ const key = (e) => {
87
+ sheetEscape.current = e.key === "Escape";
88
+ };
89
+ document.addEventListener("keydown", key, true);
90
+ return () => document.removeEventListener("keydown", key, true);
91
+ }, [shown, asSheet]);
83
92
  useReturnFocus(shown, menuRef, triggerRef);
84
93
  useEffect(() => {
85
94
  if (!shown) return;
@@ -180,7 +189,7 @@ function DropdownMenu({
180
189
  };
181
190
  return /* @__PURE__ */ jsxs(Fragment, { children: [
182
191
  triggerEl,
183
- open && asSheet ? /* @__PURE__ */ jsx(MenuContext.Provider, { value: { close }, children: /* @__PURE__ */ jsx(drawer.Drawer, { side: "bottom", size: "md", title: sheetTitle ?? strings.menu, onClose: close, children: /* @__PURE__ */ jsx(
192
+ open && asSheet ? /* @__PURE__ */ jsx(MenuContext.Provider, { value: { close }, children: /* @__PURE__ */ jsx(drawer.Drawer, { side: "bottom", size: "md", title: sheetTitle ?? strings.menu, onClose: () => dismiss(sheetEscape.current ? "escape" : "outside"), children: /* @__PURE__ */ jsx(
184
193
  "div",
185
194
  {
186
195
  ...menuProps,
@@ -10,7 +10,7 @@ import { Portal } from "./portal.js";
10
10
  import { useStrings } from "./provider.js";
11
11
  import { OVERLAY_STRINGS } from "./strings.js";
12
12
  import { CLOSE_BUTTON, MODAL_SIZE, SHEET_HEIGHT_CLASS } from "./overlay-classes.js";
13
- import { isPhoneViewport, closeVetoes, warnDev, useMergedRef, useScrollable } from "./overlay-core.js";
13
+ import { isPhoneViewport, closeVetoes, warnDev, useMergedRef, useScrollable, ov, isTop } from "./overlay-core.js";
14
14
  import { useDialog, useSheetExit, useSheetSwipe, SheetHandle } from "./overlay-dialog.js";
15
15
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
16
16
  function Modal({ open, ...props }) {
@@ -51,6 +51,18 @@ function ModalPanel({
51
51
  const named = showTitle || !!ariaLabel || !!ariaLabelledBy;
52
52
  const scrollable = useScrollable(bodyRef);
53
53
  const bodyLabel = typeof title === "string" ? title : ariaLabel;
54
+ const bodyLabelledBy = bodyLabel ? void 0 : showTitle ? titleId : ariaLabelledBy;
55
+ const bodyNamed = !!bodyLabel || !!bodyLabelledBy;
56
+ const covered = useRef(false);
57
+ useEffect(() => {
58
+ const stack = ov().layerStack;
59
+ const self = stack[stack.length - 1];
60
+ const down = () => {
61
+ covered.current = !!self && !isTop(self);
62
+ };
63
+ document.addEventListener("pointerdown", down, true);
64
+ return () => document.removeEventListener("pointerdown", down, true);
65
+ }, []);
54
66
  useEffect(() => {
55
67
  if (!named) warnDev("nish-ui: <Modal> has no accessible name. Pass `title`, `aria-label` or `aria-labelledby`.");
56
68
  }, [named]);
@@ -66,7 +78,7 @@ function ModalPanel({
66
78
  placement === "top" ? "sm:items-start sm:pt-[12vh]" : "sm:items-center"
67
79
  ),
68
80
  onMouseDown: (e) => {
69
- if (e.target === e.currentTarget) requestClose();
81
+ if (e.target === e.currentTarget && !covered.current) requestClose();
70
82
  },
71
83
  children: /* @__PURE__ */ jsxs(
72
84
  "div",
@@ -107,9 +119,10 @@ function ModalPanel({
107
119
  "div",
108
120
  {
109
121
  ref: bodyRef,
110
- tabIndex: scrollable ? 0 : void 0,
111
- role: scrollable && bodyLabel ? "region" : void 0,
122
+ tabIndex: scrollable && bodyNamed ? 0 : void 0,
123
+ role: scrollable && bodyNamed ? "region" : void 0,
112
124
  "aria-label": scrollable ? bodyLabel : void 0,
125
+ "aria-labelledby": scrollable ? bodyLabelledBy : void 0,
113
126
  className: cn("min-h-0 flex-1 overflow-y-auto overscroll-contain px-5 pb-5 text-sm text-th-hi2", header !== void 0 && "pt-3"),
114
127
  children
115
128
  }