nish-ui 3.1.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 (107) hide show
  1. package/README.md +13 -6
  2. package/dist/base-tailwind.css +30 -15
  3. package/dist/base.css +30 -15
  4. package/dist/chart.js +2 -2
  5. package/dist/elements-all.js +78 -78
  6. package/dist/elements-charts.d.ts +1 -1
  7. package/dist/elements-charts.js +43 -42
  8. package/dist/elements-data.d.ts +10 -0
  9. package/dist/elements-data.js +4 -5
  10. package/dist/elements-forms.js +9 -9
  11. package/dist/elements.d.ts +1 -0
  12. package/dist/elements.js +4 -4
  13. package/dist/esm/chart-values.js +2 -1
  14. package/dist/esm/combobox-filter.js +6 -5
  15. package/dist/esm/command-filter.js +83 -0
  16. package/dist/esm/components/accordion.js +5 -3
  17. package/dist/esm/components/app-shell.js +9 -5
  18. package/dist/esm/components/breadcrumbs.js +8 -4
  19. package/dist/esm/components/calendar-base.js +33 -6
  20. package/dist/esm/components/calendar-classes.js +14 -2
  21. package/dist/esm/components/canvas/follow-caption.js +31 -21
  22. package/dist/esm/components/canvas/follow.js +5 -6
  23. package/dist/esm/components/canvas/minimap.js +3 -3
  24. package/dist/esm/components/canvas/system-canvas.js +3 -1
  25. package/dist/esm/components/canvas/view.js +0 -2
  26. package/dist/esm/components/carousel.js +2 -3
  27. package/dist/esm/components/charts.js +18 -7
  28. package/dist/esm/components/combobox.js +20 -9
  29. package/dist/esm/components/command.js +25 -63
  30. package/dist/esm/components/context-menu.js +2 -1
  31. package/dist/esm/components/data-classes.js +23 -8
  32. package/dist/esm/components/data.js +19 -10
  33. package/dist/esm/components/display.js +24 -15
  34. package/dist/esm/components/drawer.js +17 -4
  35. package/dist/esm/components/error-boundary.js +3 -3
  36. package/dist/esm/components/feedback.js +4 -4
  37. package/dist/esm/components/file-dropzone.js +39 -7
  38. package/dist/esm/components/filters.js +42 -1
  39. package/dist/esm/components/flow.js +12 -9
  40. package/dist/esm/components/forms-classes.js +3 -1
  41. package/dist/esm/components/forms.js +8 -6
  42. package/dist/esm/components/hooks.js +47 -13
  43. package/dist/esm/components/hover-card.js +2 -1
  44. package/dist/esm/components/inbox.js +9 -2
  45. package/dist/esm/components/latest.js +4 -2
  46. package/dist/esm/components/layout.js +7 -4
  47. package/dist/esm/components/menu.js +14 -1
  48. package/dist/esm/components/modal.js +17 -4
  49. package/dist/esm/components/multi-select.js +7 -7
  50. package/dist/esm/components/nav-classes.js +9 -0
  51. package/dist/esm/components/nav.js +32 -12
  52. package/dist/esm/components/navigate.js +1 -1
  53. package/dist/esm/components/overlay-dialog.js +35 -1
  54. package/dist/esm/components/pagination.js +1 -1
  55. package/dist/esm/components/primitives-classes.js +4 -4
  56. package/dist/esm/components/primitives.js +18 -5
  57. package/dist/esm/components/progress.js +2 -1
  58. package/dist/esm/components/radio-group.js +1 -1
  59. package/dist/esm/components/resource-classes.js +7 -3
  60. package/dist/esm/components/resource.js +17 -6
  61. package/dist/esm/components/segmented.js +2 -0
  62. package/dist/esm/components/separator.js +6 -1
  63. package/dist/esm/components/service-tokens.js +18 -7
  64. package/dist/esm/components/settings.js +21 -1
  65. package/dist/esm/components/slider.js +5 -1
  66. package/dist/esm/components/split.js +4 -2
  67. package/dist/esm/components/strings.js +17 -4
  68. package/dist/esm/components/table.js +15 -3
  69. package/dist/esm/components/tabs.js +3 -2
  70. package/dist/esm/components/tag-input.js +5 -1
  71. package/dist/esm/components/time-field.js +15 -7
  72. package/dist/esm/components/toast-card.js +5 -3
  73. package/dist/esm/components/toast-store.js +16 -4
  74. package/dist/esm/components/toast.js +4 -1
  75. package/dist/esm/components/tooltip.js +3 -2
  76. package/dist/esm/components/url-state.js +5 -2
  77. package/dist/esm/components/virtual-table.js +2 -2
  78. package/dist/esm/components/virtual.js +8 -4
  79. package/dist/esm/format.js +27 -4
  80. package/dist/esm/runtime.js +9 -2
  81. package/dist/esm/server/inbox/client.js +4 -0
  82. package/dist/esm/split-layout.js +2 -1
  83. package/dist/esm/theme.js +38 -15
  84. package/dist/esm/tokens.mjs +1 -1
  85. package/dist/format.d.ts +5 -3
  86. package/dist/format.js +36 -7
  87. package/dist/inbox-client.d.ts +6 -2
  88. package/dist/inbox-client.js +4 -1
  89. package/dist/index.d.ts +65 -30
  90. package/dist/nish-components.css +70 -23
  91. package/dist/nish-components.min.css +1 -1
  92. package/dist/nish.css +30 -15
  93. package/dist/nish.min.css +1 -1
  94. package/dist/node/vite.js +1 -1
  95. package/dist/server/hono.d.ts +10 -3
  96. package/dist/server/hono.js +108 -11
  97. package/dist/server/index.d.ts +21 -13
  98. package/dist/server/index.js +124 -29
  99. package/dist/service-tokens.d.ts +4 -4
  100. package/dist/{spa-7myD4xvA.d.ts → spa-FwS7yZ8p.d.ts} +36 -7
  101. package/dist/split-layout.js +2 -2
  102. package/dist/system-canvas.d.ts +11 -10
  103. package/dist/theme.d.ts +30 -2
  104. package/dist/theme.global.js +53 -21
  105. package/dist/theme.js +53 -20
  106. package/package.json +3 -2
  107. package/dist/tokens.js +0 -425
@@ -9,6 +9,7 @@ import {
9
9
  useState
10
10
  } from "react";
11
11
  import { cn } from "../cn.js";
12
+ import { COMMAND_MAX_RESULTS, matchText, rankCommandItems } from "../command-filter.js";
12
13
  import { safeUrl } from "../url.js";
13
14
  import { XIcon } from "./icons.js";
14
15
  import { Modal } from "./modal.js";
@@ -17,59 +18,8 @@ import { useLatest } from "./latest.js";
17
18
  import { useStrings } from "./provider.js";
18
19
  import { COMMAND_STRINGS, FIELD_STRINGS, OVERLAY_STRINGS } from "./strings.js";
19
20
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
20
- var MAX_RESULTS = 50;
21
- function indexItems(items) {
22
- return items.map((item) => ({ item, label: item.label.toLowerCase(), keywords: (item.keywords ?? []).map((k) => k.toLowerCase()) }));
23
- }
24
- function isWordStart(text, i) {
25
- return i === 0 || !/[a-z0-9]/i.test(text[i - 1]);
26
- }
27
- function matchText(text, q) {
28
- const at = text.indexOf(q);
29
- if (at >= 0) {
30
- let tier = at === 0 ? 0 : 2;
31
- let start = at;
32
- if (tier === 2) {
33
- for (let from2 = at; from2 >= 0; from2 = text.indexOf(q, from2 + 1)) {
34
- if (isWordStart(text, from2)) {
35
- tier = 1;
36
- start = from2;
37
- break;
38
- }
39
- if (from2 + 1 >= text.length) break;
40
- }
41
- }
42
- return { tier, idx: Array.from({ length: q.length }, (_, k) => start + k) };
43
- }
44
- const idx = [];
45
- let from = 0;
46
- for (const ch of q) {
47
- const found = text.indexOf(ch, from);
48
- if (found < 0) return null;
49
- idx.push(found);
50
- from = found + 1;
51
- }
52
- return { tier: 3, idx };
53
- }
54
21
  function rankItems(items, query) {
55
- const q = query.trim().toLowerCase();
56
- if (!q) return items.slice(0, MAX_RESULTS).map(({ item }) => ({ item, marks: [] }));
57
- const scored = [];
58
- items.forEach(({ item, label: lower, keywords }, order) => {
59
- const label = matchText(lower, q);
60
- if (label) {
61
- scored.push({ r: { item, marks: label.idx }, score: label.tier, order });
62
- return;
63
- }
64
- let best = null;
65
- for (const kw of keywords) {
66
- const m = matchText(kw, q);
67
- if (m && m.tier < 3 && (best === null || m.tier < best)) best = m.tier;
68
- }
69
- if (best !== null) scored.push({ r: { item, marks: [] }, score: 4 + best, order });
70
- });
71
- scored.sort((a, b) => a.score - b.score || a.order - b.order);
72
- return scored.slice(0, MAX_RESULTS).map((s) => s.r);
22
+ return rankCommandItems(items, query);
73
23
  }
74
24
  function groupRows(rows) {
75
25
  const order = [];
@@ -124,9 +74,6 @@ function SearchIcon({ size = 18 }) {
124
74
  }
125
75
  );
126
76
  }
127
- function defaultResultsLabel(count) {
128
- return `${count} result${count === 1 ? "" : "s"}`;
129
- }
130
77
  function isTypingTarget(t) {
131
78
  if (!(t instanceof HTMLElement)) return false;
132
79
  const tag = t.tagName;
@@ -138,7 +85,7 @@ function useCommandHotkey(open, enabled = true) {
138
85
  if (!enabled) return;
139
86
  const onKey = (e) => {
140
87
  if (e.defaultPrevented || e.isComposing) return;
141
- if ((e.ctrlKey || e.metaKey) && !e.altKey && !e.shiftKey && e.key.toLowerCase() === "k") {
88
+ if ((e.ctrlKey || e.metaKey) && !e.altKey && !e.shiftKey && (e.key.toLowerCase() === "k" || e.code === "KeyK" && !/^[a-z]$/i.test(e.key))) {
142
89
  e.preventDefault();
143
90
  ref.current();
144
91
  } else if (e.key === "/" && !e.ctrlKey && !e.metaKey && !e.altKey && !isTypingTarget(e.target)) {
@@ -176,7 +123,7 @@ function CommandPalette({
176
123
  placeholder: placeholder ?? s.searchPlaceholder,
177
124
  emptyText: emptyText ?? s.noResults,
178
125
  resultsLabel,
179
- externalLabel: externalLabel ?? "opens in a new tab",
126
+ externalLabel: externalLabel ?? s.opensInNewTab,
180
127
  onQuery,
181
128
  footer,
182
129
  onSubmitQuery
@@ -196,6 +143,7 @@ function PaletteDialog({ onClose, items, placeholder, emptyText, resultsLabel, e
196
143
  const itemsRef = useLatest(items);
197
144
  const [dynamic, setDynamic] = useState([]);
198
145
  const [pending, setPending] = useState(isFn);
146
+ const enterQueued = useRef(false);
199
147
  useEffect(() => {
200
148
  const fn = itemsRef.current;
201
149
  if (typeof fn !== "function") return;
@@ -207,7 +155,7 @@ function PaletteDialog({ onClose, items, placeholder, emptyText, resultsLabel, e
207
155
  res = [];
208
156
  }
209
157
  if (Array.isArray(res)) {
210
- setDynamic(res.slice(0, MAX_RESULTS));
158
+ setDynamic(res.slice(0, COMMAND_MAX_RESULTS));
211
159
  setPending(false);
212
160
  return;
213
161
  }
@@ -215,24 +163,24 @@ function PaletteDialog({ onClose, items, placeholder, emptyText, resultsLabel, e
215
163
  res.then(
216
164
  (r) => {
217
165
  if (stale) return;
218
- setDynamic(r.slice(0, MAX_RESULTS));
166
+ setDynamic(r.slice(0, COMMAND_MAX_RESULTS));
219
167
  setPending(false);
220
168
  },
221
169
  () => {
222
170
  if (stale) return;
223
171
  setDynamic([]);
224
172
  setPending(false);
173
+ enterQueued.current = false;
225
174
  }
226
175
  );
227
176
  return () => {
228
177
  stale = true;
229
178
  };
230
179
  }, [query, isFn, itemsRef]);
231
- const indexed = useMemo(() => isFn ? [] : indexItems(items), [isFn, items]);
232
180
  const rows = useMemo(() => {
233
181
  if (isFn) return dynamic.map((item) => ({ item, marks: matchText(item.label.toLowerCase(), query.trim().toLowerCase())?.idx ?? [] }));
234
- return rankItems(indexed, query);
235
- }, [isFn, dynamic, indexed, query]);
182
+ return rankItems(items, query);
183
+ }, [isFn, dynamic, items, query]);
236
184
  const groups = useMemo(() => groupRows(rows), [rows]);
237
185
  const flat = useMemo(() => groups.flatMap((g) => g.rows.map((x) => x.r.item)), [groups]);
238
186
  useEffect(() => {
@@ -255,6 +203,16 @@ function PaletteDialog({ onClose, items, placeholder, emptyText, resultsLabel, e
255
203
  item.onSelect?.();
256
204
  }
257
205
  };
206
+ useEffect(() => {
207
+ if (pending || !enterQueued.current) return;
208
+ enterQueued.current = false;
209
+ const item = flat[0];
210
+ if (item) select(item);
211
+ else if (query.trim() && onSubmitQuery) {
212
+ onClose();
213
+ onSubmitQuery(query.trim());
214
+ }
215
+ }, [pending, flat]);
258
216
  const onKeyDown = (e) => {
259
217
  if (e.nativeEvent.isComposing) return;
260
218
  if (e.key === "ArrowDown") {
@@ -268,6 +226,10 @@ function PaletteDialog({ onClose, items, placeholder, emptyText, resultsLabel, e
268
226
  setActive(0);
269
227
  } else if (e.key === "Enter") {
270
228
  e.preventDefault();
229
+ if (isFn && pending) {
230
+ enterQueued.current = true;
231
+ return;
232
+ }
271
233
  const item = flat[active];
272
234
  if (item) select(item);
273
235
  else if (!pending && query.trim() && onSubmitQuery) {
@@ -327,7 +289,7 @@ function PaletteDialog({ onClose, items, placeholder, emptyText, resultsLabel, e
327
289
  footer,
328
290
  className: "sm:max-w-[560px]",
329
291
  children: [
330
- /* @__PURE__ */ jsx("div", { "aria-live": "polite", className: "sr-only", children: showEmpty ? "" : (resultsLabel ?? defaultResultsLabel)(flat.length) }),
292
+ /* @__PURE__ */ jsx("div", { "aria-live": "polite", className: "sr-only", children: showEmpty ? "" : (resultsLabel ?? s.resultsCount)(flat.length) }),
331
293
  /* @__PURE__ */ jsx(
332
294
  "div",
333
295
  {
@@ -143,7 +143,8 @@ function ContextMenu({
143
143
  const active = document.activeElement;
144
144
  if (!active || active === document.body || active.hasAttribute("data-nish-context-anchor")) returnTo.current?.focus({ preventScroll: true });
145
145
  }, [open]);
146
- const content = typeof menu === "function" ? target ? menu(target) : null : menu;
146
+ const anchor = target ?? rootRef.current;
147
+ const content = typeof menu === "function" ? anchor ? menu(anchor) : null : menu;
147
148
  const shown = open && content != null && content !== false;
148
149
  return /* @__PURE__ */ jsxs(
149
150
  "div",
@@ -2,9 +2,9 @@
2
2
  import { shared } from "../runtime.js";
3
3
  var ALIGN = { left: "text-start", center: "text-center", right: "text-end" };
4
4
  var ROW_TONE = {
5
- ok: "[&>td:first-child]:shadow-[inset_3px_0_0_var(--nish-ok-fill)] [&>th:first-child]:shadow-[inset_3px_0_0_var(--nish-ok-fill)] rtl:[&>td:first-child]:shadow-[inset_-3px_0_0_var(--nish-ok-fill)] rtl:[&>th:first-child]:shadow-[inset_-3px_0_0_var(--nish-ok-fill)] forced-colors:[&>td:first-child]:border-s-[3px] forced-colors:[&>td:first-child]:border-s-[color:Highlight]",
6
- warn: "[&>td:first-child]:shadow-[inset_3px_0_0_var(--nish-warn-fill)] [&>th:first-child]:shadow-[inset_3px_0_0_var(--nish-warn-fill)] rtl:[&>td:first-child]:shadow-[inset_-3px_0_0_var(--nish-warn-fill)] rtl:[&>th:first-child]:shadow-[inset_-3px_0_0_var(--nish-warn-fill)] forced-colors:[&>td:first-child]:border-s-[3px] forced-colors:[&>td:first-child]:border-s-[color:Highlight]",
7
- loss: "[&>td:first-child]:shadow-[inset_3px_0_0_var(--nish-loss-fill)] [&>th:first-child]:shadow-[inset_3px_0_0_var(--nish-loss-fill)] rtl:[&>td:first-child]:shadow-[inset_-3px_0_0_var(--nish-loss-fill)] rtl:[&>th:first-child]:shadow-[inset_-3px_0_0_var(--nish-loss-fill)] forced-colors:[&>td:first-child]:border-s-[3px] forced-colors:[&>td:first-child]:border-s-[color:Highlight]"
5
+ ok: "[&>td:first-child]:shadow-[inset_3px_0_0_var(--nish-ok-fill)] [&>th:first-child]:shadow-[inset_3px_0_0_var(--nish-ok-fill)] rtl:[&>td:first-child]:shadow-[inset_-3px_0_0_var(--nish-ok-fill)] rtl:[&>th:first-child]:shadow-[inset_-3px_0_0_var(--nish-ok-fill)] forced-colors:[&>td:first-child]:border-s-[3px] forced-colors:[&>td:first-child]:border-s-[color:Highlight] forced-colors:[&>th:first-child]:border-s-[3px] forced-colors:[&>th:first-child]:border-s-[color:Highlight]",
6
+ warn: "[&>td:first-child]:shadow-[inset_3px_0_0_var(--nish-warn-fill)] [&>th:first-child]:shadow-[inset_3px_0_0_var(--nish-warn-fill)] rtl:[&>td:first-child]:shadow-[inset_-3px_0_0_var(--nish-warn-fill)] rtl:[&>th:first-child]:shadow-[inset_-3px_0_0_var(--nish-warn-fill)] forced-colors:[&>td:first-child]:border-s-[3px] forced-colors:[&>td:first-child]:border-s-[color:Highlight] forced-colors:[&>th:first-child]:border-s-[3px] forced-colors:[&>th:first-child]:border-s-[color:Highlight]",
7
+ loss: "[&>td:first-child]:shadow-[inset_3px_0_0_var(--nish-loss-fill)] [&>th:first-child]:shadow-[inset_3px_0_0_var(--nish-loss-fill)] rtl:[&>td:first-child]:shadow-[inset_-3px_0_0_var(--nish-loss-fill)] rtl:[&>th:first-child]:shadow-[inset_-3px_0_0_var(--nish-loss-fill)] forced-colors:[&>td:first-child]:border-s-[3px] forced-colors:[&>td:first-child]:border-s-[color:Highlight] forced-colors:[&>th:first-child]:border-s-[3px] forced-colors:[&>th:first-child]:border-s-[color:Highlight]"
8
8
  };
9
9
  var WRAP = "relative overflow-auto rounded-xl border border-th-line bg-th-surface focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-th-accent";
10
10
  var STICKY = "[&_thead_th]:sticky [&_thead_th]:top-0 [&_thead_th]:z-[var(--nish-z-sticky,1)] [&_thead_th]:bg-th-surface";
@@ -41,17 +41,31 @@ var tableClass = {
41
41
  /** Add to tr for a status edge. */
42
42
  tone: ROW_TONE
43
43
  };
44
- var tableInternals = { ALIGN, STICKY_COL, WRAP, STICKY, TABLE, ZEBRA, TH, TD, PAD, TR, TR_INTERACTIVE };
44
+ var HIDE_BELOW = { sm: "hidden sm:table-cell", md: "hidden md:table-cell", lg: "hidden lg:table-cell" };
45
+ var tableInternals = { HIDE_BELOW, ALIGN, STICKY_COL, WRAP, STICKY, TABLE, ZEBRA, TH, TD, PAD, TR, TR_INTERACTIVE };
45
46
  function mergeRefs(...refs) {
46
47
  return (node) => {
47
48
  const cleanups = [];
49
+ const withCleanup = /* @__PURE__ */ new Set();
48
50
  for (const ref of refs) {
49
51
  if (typeof ref === "function") {
50
52
  const out = ref(node);
51
- if (typeof out === "function") cleanups.push(out);
53
+ if (typeof out === "function") {
54
+ cleanups.push(out);
55
+ withCleanup.add(ref);
56
+ }
52
57
  } else if (ref) ref.current = node;
53
58
  }
54
- if (cleanups.length) return () => cleanups.forEach((fn) => fn());
59
+ if (cleanups.length) {
60
+ return () => {
61
+ for (const ref of refs) {
62
+ if (typeof ref === "function") {
63
+ if (!withCleanup.has(ref)) ref(null);
64
+ } else if (ref) ref.current = null;
65
+ }
66
+ cleanups.forEach((fn) => fn());
67
+ };
68
+ }
55
69
  };
56
70
  }
57
71
  var COLLATOR = /* @__PURE__ */ new Intl.Collator(void 0, { numeric: true, sensitivity: "base" });
@@ -132,8 +146,9 @@ function chartNumber(v, locale = "en-US") {
132
146
  };
133
147
  NUMBER_FORMATS.set(locale, f);
134
148
  }
135
- if (Math.abs(v) >= 1e3) return f.whole.format(v);
136
- return f.small.format(Math.round(v * 100) / 100 || 0);
149
+ const r = Math.round(v * 100) / 100 || 0;
150
+ if (Math.abs(r) >= 1e3) return f.whole.format(r);
151
+ return f.small.format(r);
137
152
  }
138
153
  var warned = /* @__PURE__ */ new Set();
139
154
  function warnOnce(key, message) {
@@ -7,7 +7,8 @@ import {
7
7
  useId,
8
8
  useMemo,
9
9
  useRef,
10
- useState
10
+ useState,
11
+ useSyncExternalStore
11
12
  } from "react";
12
13
  import { cn } from "../cn.js";
13
14
  import { safeUrl } from "../url.js";
@@ -19,6 +20,7 @@ import {
19
20
  hostnameOf,
20
21
  mergeRefs,
21
22
  sortRows,
23
+ tableInternals,
22
24
  warnOnce
23
25
  } from "./data-classes.js";
24
26
  import { useMediaQuery } from "./hooks.js";
@@ -58,14 +60,12 @@ function fromInteractive(e) {
58
60
  const el = e.target?.closest?.('a,button,input,select,textarea,label,summary,[role="button"],[role="link"]');
59
61
  return !!el && el !== e.currentTarget && e.currentTarget.contains(el);
60
62
  }
63
+ var subscribeNever = () => () => {
64
+ };
61
65
  var TABLE_SHOW = { sm: "hidden sm:block", md: "hidden md:block", lg: "hidden lg:block" };
62
66
  var BP_PX = { sm: 640, md: 768, lg: 1024 };
63
67
  var CARDS_SHOW = { sm: "sm:hidden", md: "md:hidden", lg: "lg:hidden" };
64
- var HIDE_BELOW = {
65
- sm: "hidden sm:table-cell",
66
- md: "hidden md:table-cell",
67
- lg: "hidden lg:table-cell"
68
- };
68
+ var { HIDE_BELOW } = tableInternals;
69
69
  var TONE_EDGE = {
70
70
  ok: "border-s-[3px] border-s-[var(--nish-ok-fill)]",
71
71
  warn: "border-s-[3px] border-s-[var(--nish-warn-fill)]",
@@ -81,6 +81,9 @@ var BodyRow = /* @__PURE__ */ memo(function BodyRow2({ row, columns, tone, inter
81
81
  onClick: interactive ? (e) => {
82
82
  if (!fromInteractive(e)) onGo(row, e);
83
83
  } : void 0,
84
+ onAuxClick: interactive ? (e) => {
85
+ if (e.button === 1 && !fromInteractive(e)) onGo(row, e);
86
+ } : void 0,
84
87
  onKeyDown: interactive ? (e) => {
85
88
  if (e.target !== e.currentTarget) return;
86
89
  if (e.key === "Enter" || e.key === " ") {
@@ -123,6 +126,9 @@ function ResponsiveTable({
123
126
  const [announcement, setAnnouncement] = useState("");
124
127
  const sortId = useId();
125
128
  const wide = useMediaQuery(`(min-width: ${BP_PX[cardsBelow]}px)`);
129
+ const hydrated = useSyncExternalStore(subscribeNever, () => true, () => false);
130
+ const showTable = wide || !hydrated;
131
+ const showCards = !wide || !hydrated;
126
132
  const external = sort !== void 0 || onSortChange !== void 0;
127
133
  const current = sort !== void 0 ? sort : innerSort;
128
134
  const sortKey = current?.key;
@@ -155,10 +161,12 @@ function ResponsiveTable({
155
161
  else if (navigate) navigate(href);
156
162
  else window.location.assign(href);
157
163
  }, [latest]);
158
- if (error) return /* @__PURE__ */ jsx(ErrorState, { message: error.message, onRetry: error.onRetry, className });
164
+ if (error) {
165
+ return /* @__PURE__ */ jsx("div", { ...rest, ref, className, children: /* @__PURE__ */ jsx(ErrorState, { message: error.message, onRetry: error.onRetry }) });
166
+ }
159
167
  const emptyNode = empty ?? /* @__PURE__ */ jsx(EmptyState, { title: t.nothingHere });
160
168
  const hasRows = sorted.length > 0;
161
- const table = !wide ? null : loading ? /* @__PURE__ */ jsx(SkeletonRows, { rows: 5, height: 44, label: t.loadingNamed(label) }) : !hasRows ? emptyNode : /* @__PURE__ */ jsx(TableWrap, { minWidth, stickyHeader, maxHeight, stickyFirstColumn, label, children: /* @__PURE__ */ jsxs(Table, { "aria-label": label, children: [
169
+ const table = !showTable ? null : loading ? /* @__PURE__ */ jsx(SkeletonRows, { rows: 5, height: 44, label: t.loadingNamed(label) }) : !hasRows ? emptyNode : /* @__PURE__ */ jsx(TableWrap, { minWidth, stickyHeader, maxHeight, stickyFirstColumn, label, children: /* @__PURE__ */ jsxs(Table, { "aria-label": label, children: [
162
170
  /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: columns.map((c) => /* @__PURE__ */ jsx(
163
171
  Th,
164
172
  {
@@ -203,7 +211,7 @@ function ResponsiveTable({
203
211
  }
204
212
  return /* @__PURE__ */ jsx("div", { className: cardClassFor(tone, false), children: cardBody(row) });
205
213
  };
206
- const cards = wide ? null : loading ? /* @__PURE__ */ jsx(CardListSkeleton, { count: 3, lines: 2 }) : !hasRows ? emptyNode : /* @__PURE__ */ jsxs(Fragment, { children: [
214
+ const cards = !showCards ? null : loading ? /* @__PURE__ */ jsx(CardListSkeleton, { count: 3, lines: 2 }) : !hasRows ? emptyNode : /* @__PURE__ */ jsxs(Fragment, { children: [
207
215
  sortable.length > 0 ? /* @__PURE__ */ jsxs("div", { className: "mb-2 flex items-center gap-2", children: [
208
216
  /* @__PURE__ */ jsx("label", { className: "shrink-0 text-xs text-th-hi3", htmlFor: sortId, children: t.sortBy }),
209
217
  /* @__PURE__ */ jsxs(
@@ -234,7 +242,8 @@ function ResponsiveTable({
234
242
  /* @__PURE__ */ jsx("ul", { "aria-label": label, className: "grid gap-2", children: sorted.map((row) => /* @__PURE__ */ jsx("li", { children: cardItem(row) }, rowKey(row))) })
235
243
  ] });
236
244
  return /* @__PURE__ */ jsxs("div", { ...rest, ref, className, children: [
237
- wide ? /* @__PURE__ */ jsx("div", { className: TABLE_SHOW[cardsBelow], children: table }) : /* @__PURE__ */ jsx("div", { className: CARDS_SHOW[cardsBelow], children: cards }),
245
+ showTable ? /* @__PURE__ */ jsx("div", { className: TABLE_SHOW[cardsBelow], children: table }) : null,
246
+ showCards ? /* @__PURE__ */ jsx("div", { className: CARDS_SHOW[cardsBelow], children: cards }) : null,
238
247
  /* @__PURE__ */ jsx("div", { role: "status", "aria-live": "polite", className: "sr-only", children: announcement })
239
248
  ] });
240
249
  }
@@ -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;
@@ -273,7 +273,7 @@ function Meter({
273
273
  track === "overlay" ? "bg-th-overlay" : "bg-th-elevated",
274
274
  "forced-colors:border forced-colors:border-[CanvasText] forced-colors:bg-[Canvas]",
275
275
  vertical ? cn("h-full", METER_THICK_V[size]) : cn("w-full", METER_THICK[size]),
276
- !showValue && className
276
+ (!showValue || vertical) && className
277
277
  ),
278
278
  children: /* @__PURE__ */ jsx(
279
279
  "div",
@@ -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) => {
@@ -601,7 +610,7 @@ function AppHeader({
601
610
  /* @__PURE__ */ jsx("span", { className: cn("truncate", hideName && "max-sm:sr-only"), children: name })
602
611
  ] });
603
612
  const markClass = "inline-flex min-w-0 items-center gap-2 text-xl font-bold tracking-tight text-th-hi";
604
- const pillArrow = /* @__PURE__ */ jsx("span", { className: "inline-block rtl:-scale-x-100", children: "\u2190" });
613
+ const pillArrow = /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "inline-block rtl:-scale-x-100", children: "\u2190" });
605
614
  return /* @__PURE__ */ jsxs(
606
615
  "header",
607
616
  {
@@ -720,7 +729,7 @@ function ChartLegend({ items, marker = "line", label, className, ref, ...rest })
720
729
  "aria-label": label ?? strings.legend,
721
730
  className: cn("flex flex-wrap gap-x-4 gap-y-1 text-xs text-th-hi2", className),
722
731
  ...rest,
723
- children: items.map((it) => /* @__PURE__ */ jsxs("li", { className: "inline-flex items-center gap-1.5", children: [
732
+ children: items.map((it, i) => /* @__PURE__ */ jsxs("li", { className: "inline-flex items-center gap-1.5", children: [
724
733
  /* @__PURE__ */ jsx(
725
734
  "i",
726
735
  {
@@ -734,7 +743,7 @@ function ChartLegend({ items, marker = "line", label, className, ref, ...rest })
734
743
  }
735
744
  ),
736
745
  it.label
737
- ] }, it.label))
746
+ ] }, `${it.label}-${i}`))
738
747
  }
739
748
  );
740
749
  }
@@ -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 });
@@ -14,7 +14,7 @@ function SkeletonRows({ rows = 5, height = 56, gap = "md", label, className, row
14
14
  const s = useStrings(STATUS_STRINGS);
15
15
  return /* @__PURE__ */ jsxs("div", { ...rest, ref, role: "status", className: cn("grid", gap === "sm" ? "gap-1.5" : "gap-2.5", className), children: [
16
16
  /* @__PURE__ */ jsx("span", { className: "sr-only", children: label ?? s.loading }),
17
- Array.from({ length: rows }, (_, i) => /* @__PURE__ */ jsx(Skeleton, { className: cn("w-full rounded-xl", rowClassName), style: rowClassName && /\bh-/.test(rowClassName) ? void 0 : { height } }, i))
17
+ Array.from({ length: rows }, (_, i) => /* @__PURE__ */ jsx(Skeleton, { className: cn("w-full rounded-xl", rowClassName), style: rowClassName && /(^|\s)([\w-]+:)*(h|size)-/.test(rowClassName) ? void 0 : { height } }, i))
18
18
  ] });
19
19
  }
20
20
  var SPINNER_SIZE = { xs: 12, sm: 14, md: 16, lg: 24 };
@@ -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
@@ -8,13 +8,35 @@ import { IconButton } from "./primitives.js";
8
8
  import { useStrings } from "./provider.js";
9
9
  import { FILE_STRINGS } from "./strings.js";
10
10
  import { jsx, jsxs } from "react/jsx-runtime";
11
+ var EXT_TYPES = {
12
+ jpg: "image/jpeg",
13
+ jpeg: "image/jpeg",
14
+ png: "image/png",
15
+ gif: "image/gif",
16
+ webp: "image/webp",
17
+ heic: "image/heic",
18
+ heif: "image/heif",
19
+ avif: "image/avif",
20
+ svg: "image/svg+xml",
21
+ pdf: "application/pdf",
22
+ mp4: "video/mp4",
23
+ mov: "video/quicktime",
24
+ webm: "video/webm",
25
+ mp3: "audio/mpeg",
26
+ wav: "audio/wav",
27
+ m4a: "audio/mp4",
28
+ txt: "text/plain",
29
+ csv: "text/csv",
30
+ json: "application/json"
31
+ };
11
32
  function matchesAccept(file, accept) {
12
33
  const tokens = (accept ?? "").split(",").map((t) => t.trim().toLowerCase()).filter(Boolean);
13
34
  if (tokens.length === 0) return true;
14
35
  const fileName = file.name.toLowerCase();
15
- const type = file.type.toLowerCase();
36
+ const type = file.type.toLowerCase() || EXT_TYPES[fileName.split(".").pop() ?? ""] || "";
16
37
  return tokens.some((t) => {
17
38
  if (t.startsWith(".")) return fileName.endsWith(t);
39
+ if (!type) return t.endsWith("/*");
18
40
  if (t.endsWith("/*")) return type.startsWith(t.slice(0, -1));
19
41
  return type === t;
20
42
  });
@@ -59,6 +81,8 @@ function FileDropzone({
59
81
  const depth = useRef(0);
60
82
  const [files, setFiles] = useState([]);
61
83
  const [dragging, setDragging] = useState(false);
84
+ const list = useRef(null);
85
+ const pendingFocus = useRef(null);
62
86
  const isInvalid = invalid || ariaInvalid === true || ariaInvalid === "true";
63
87
  const latestChange = useRef(onFilesChange);
64
88
  useEffect(() => {
@@ -80,22 +104,29 @@ function FileDropzone({
80
104
  form.addEventListener("reset", onReset);
81
105
  return () => form.removeEventListener("reset", onReset);
82
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]);
83
114
  const take = (incoming) => {
84
115
  const rejected = [];
85
- const list = multiple ? [...files] : [];
116
+ const list2 = multiple ? [...files] : [];
86
117
  const cap = multiple ? maxFiles ?? Infinity : 1;
87
118
  let changed = false;
88
119
  for (const file of incoming) {
89
120
  if (!matchesAccept(file, accept)) rejected.push({ file, reason: "type" });
90
121
  else if (maxSize !== void 0 && file.size > maxSize) rejected.push({ file, reason: "size" });
91
- else if (multiple && list.some((f) => sameFile(f, file))) continue;
92
- 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" });
93
124
  else {
94
- list.push(file);
125
+ list2.push(file);
95
126
  changed = true;
96
127
  }
97
128
  }
98
- const next = !multiple && list.length === 0 ? files : list;
129
+ const next = !multiple && list2.length === 0 ? files : list2;
99
130
  syncInput(input.current, next);
100
131
  if (!changed && rejected.length === 0) return;
101
132
  if (next !== files) setFiles(next);
@@ -103,6 +134,7 @@ function FileDropzone({
103
134
  };
104
135
  const removeAt = (index) => {
105
136
  const next = files.filter((_, i) => i !== index);
137
+ pendingFocus.current = index;
106
138
  setFiles(next);
107
139
  syncInput(input.current, next);
108
140
  onFilesChange?.(next, []);
@@ -184,7 +216,7 @@ function FileDropzone({
184
216
  ]
185
217
  }
186
218
  ),
187
- 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(
188
220
  "li",
189
221
  {
190
222
  className: "flex items-center gap-2 rounded-lg border border-th-line bg-th-surface py-1 pe-1 ps-3 text-sm",