nish-ui 2.2.0 → 3.0.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 (74) hide show
  1. package/README.md +5 -1
  2. package/dist/chart.js +1 -1
  3. package/dist/elements-all.js +58 -58
  4. package/dist/elements-charts.js +1 -1
  5. package/dist/elements-data.js +1 -1
  6. package/dist/elements-forms.js +1 -1
  7. package/dist/elements.js +4 -4
  8. package/dist/esm/components/accordion.js +3 -2
  9. package/dist/esm/components/app-shell.js +3 -2
  10. package/dist/esm/components/avatar.js +4 -3
  11. package/dist/esm/components/breadcrumbs.js +3 -2
  12. package/dist/esm/components/calendar-base.js +4 -3
  13. package/dist/esm/components/canvas/legend.js +3 -2
  14. package/dist/esm/components/canvas/node.js +3 -2
  15. package/dist/esm/components/canvas/system-canvas.js +3 -2
  16. package/dist/esm/components/carousel.js +3 -2
  17. package/dist/esm/components/charts.js +8 -7
  18. package/dist/esm/components/combobox.js +3 -2
  19. package/dist/esm/components/command.js +4 -3
  20. package/dist/esm/components/context-menu.js +3 -2
  21. package/dist/esm/components/data.js +4 -3
  22. package/dist/esm/components/date-picker.js +4 -3
  23. package/dist/esm/components/date-range-picker.js +4 -3
  24. package/dist/esm/components/display.js +7 -6
  25. package/dist/esm/components/drawer.js +3 -2
  26. package/dist/esm/components/error-boundary.js +4 -2
  27. package/dist/esm/components/feedback.js +7 -6
  28. package/dist/esm/components/file-dropzone.js +3 -2
  29. package/dist/esm/components/filters.js +4 -3
  30. package/dist/esm/components/flow.js +6 -5
  31. package/dist/esm/components/forms.js +13 -8
  32. package/dist/esm/components/hooks.js +2 -2
  33. package/dist/esm/components/hover-card.js +2 -2
  34. package/dist/esm/components/inbox.js +4 -2
  35. package/dist/esm/components/layout.js +5 -4
  36. package/dist/esm/components/media.js +3 -2
  37. package/dist/esm/components/menu.js +5 -4
  38. package/dist/esm/components/modal.js +4 -3
  39. package/dist/esm/components/more-sheet.js +3 -2
  40. package/dist/esm/components/multi-select.js +3 -2
  41. package/dist/esm/components/nav-items.js +4 -3
  42. package/dist/esm/components/nav.js +5 -4
  43. package/dist/esm/components/overlay-dialog.js +3 -2
  44. package/dist/esm/components/pagination.js +3 -2
  45. package/dist/esm/components/popover.js +2 -2
  46. package/dist/esm/components/portal.js +2 -2
  47. package/dist/esm/components/progress.js +3 -2
  48. package/dist/esm/components/provider.js +34 -5
  49. package/dist/esm/components/range-calendar.js +4 -3
  50. package/dist/esm/components/service-tokens.js +4 -3
  51. package/dist/esm/components/settings.js +4 -3
  52. package/dist/esm/components/slider.js +3 -2
  53. package/dist/esm/components/split.js +4 -3
  54. package/dist/esm/components/strings.js +174 -65
  55. package/dist/esm/components/tag-input.js +3 -2
  56. package/dist/esm/components/theme-toggle.js +3 -2
  57. package/dist/esm/components/time-field.js +4 -3
  58. package/dist/esm/components/toast-card.js +155 -0
  59. package/dist/esm/components/toast-store.js +136 -0
  60. package/dist/esm/components/toast.js +38 -241
  61. package/dist/esm/components/tooltip.js +2 -2
  62. package/dist/esm/components/virtual-table.js +3 -2
  63. package/dist/esm/index.js +0 -20
  64. package/dist/esm/runtime.js +1 -1
  65. package/dist/esm/system-canvas.js +4 -0
  66. package/dist/esm/theme.js +7 -7
  67. package/dist/format.js +1 -1
  68. package/dist/index.d.ts +11 -14
  69. package/dist/system-canvas.d.ts +183 -2
  70. package/dist/theme.d.ts +3 -3
  71. package/dist/theme.global.js +21 -145
  72. package/dist/theme.js +21 -145
  73. package/package.json +1 -1
  74. package/dist/system-canvas-BLuWd69H.d.ts +0 -183
@@ -1,159 +1,23 @@
1
1
  "use client";
2
2
 
3
3
  // src/components/toast.tsx
4
- import {
5
- useEffect,
6
- useRef,
7
- useState,
8
- useSyncExternalStore
9
- } from "react";
4
+ import { useEffect, useRef, useState } from "react";
10
5
  import { cn } from "../cn.js";
11
- import { shared } from "../runtime.js";
12
- import { AlertTriangleIcon, CheckCircleIcon, InfoIcon, XIcon } from "./icons.js";
6
+ import { XIcon } from "./icons.js";
7
+ import { lazyModule, preloadWhenIdle, useLazyModule } from "./lazy-module.js";
13
8
  import { Portal } from "./portal.js";
14
- import { useNishStrings } from "./provider.js";
9
+ import { useStrings } from "./provider.js";
10
+ import { DISPLAY_STRINGS } from "./strings.js";
11
+ import { dismissToast, useToasts } from "./toast-store.js";
12
+ import { toast, useToast, dismissToast as dismissToast2 } from "./toast-store.js";
15
13
  import { jsx, jsxs } from "react/jsx-runtime";
16
- var AUTO_DISMISS_MS = 4e3;
17
- var MAX_VISIBLE = 4;
18
- var cachedStore;
19
- function store() {
20
- return cachedStore ??= shared("toast", () => ({
21
- items: [],
22
- nextId: 1,
23
- subs: /* @__PURE__ */ new Set(),
24
- timers: /* @__PURE__ */ new Map()
25
- }));
26
- }
27
- var emit = () => store().subs.forEach((fn) => fn());
28
- function startTimer(id, ms) {
29
- const t = {
30
- handle: null,
31
- remaining: ms,
32
- started: Date.now(),
33
- paused: 0
34
- };
35
- t.handle = setTimeout(() => dismissToast(id), ms);
36
- store().timers.set(id, t);
37
- }
38
- function clearTimer(id) {
39
- const { timers } = store();
40
- const t = timers.get(id);
41
- if (t?.handle != null) clearTimeout(t.handle);
42
- timers.delete(id);
43
- }
44
- function pauseTimer(id) {
45
- const t = store().timers.get(id);
46
- if (!t) return;
47
- t.paused += 1;
48
- if (t.paused > 1 || t.handle == null) return;
49
- clearTimeout(t.handle);
50
- t.handle = null;
51
- t.remaining = Math.max(0, t.remaining - (Date.now() - t.started));
52
- }
53
- function resumeTimer(id) {
54
- const t = store().timers.get(id);
55
- if (!t || t.paused === 0) return;
56
- t.paused -= 1;
57
- if (t.paused > 0) return;
58
- t.started = Date.now();
59
- t.handle = setTimeout(() => dismissToast(id), Math.max(t.remaining, 1e3));
60
- }
61
- function dismissToast(id) {
62
- clearTimer(id);
63
- const s = store();
64
- const next = s.items.filter((t) => t.id !== id);
65
- if (next.length === s.items.length) return;
66
- s.items = next;
67
- emit();
68
- }
69
- var isKept = (t) => t.duration === "sticky" || t.tone === "error";
70
- function push(tone, title, bodyOrOptions) {
71
- const o = typeof bodyOrOptions === "string" ? { body: bodyOrOptions } : bodyOrOptions ?? {};
72
- const s = store();
73
- const id = s.nextId++;
74
- const asked = o.duration === Infinity ? "sticky" : o.duration;
75
- const duration = asked ?? (tone === "error" ? "sticky" : AUTO_DISMISS_MS);
76
- const item = {
77
- id,
78
- tone,
79
- title,
80
- body: o.body,
81
- action: o.action,
82
- slot: o.id,
83
- duration
84
- };
85
- const old = o.id ? s.items.find((t) => t.slot === o.id) : void 0;
86
- if (old) {
87
- clearTimer(old.id);
88
- s.items = s.items.map((t) => t === old ? item : t);
89
- } else {
90
- let excess = s.items.length + 1 - MAX_VISIBLE;
91
- const kept = [];
92
- for (const t of s.items) {
93
- if (excess > 0 && !isKept(t)) {
94
- excess--;
95
- clearTimer(t.id);
96
- } else {
97
- kept.push(t);
98
- }
99
- }
100
- s.items = [...kept, item];
101
- }
102
- emit();
103
- if (duration !== "sticky") startTimer(id, duration);
104
- return id;
105
- }
106
- var toast = /* @__PURE__ */ Object.assign((title, o) => push("info", title, o), {
107
- success: (title, o) => push("success", title, o),
108
- error: (title, o) => push("error", title, o),
109
- warn: (title, o) => push("warn", title, o),
110
- info: (title, o) => push("info", title, o),
111
- promise: (promise, messages) => {
112
- const slot = "nish-promise-" + store().nextId;
113
- push("info", messages.loading, { duration: "sticky", id: slot });
114
- promise.then(
115
- (value) => {
116
- push("success", typeof messages.success === "function" ? messages.success(value) : messages.success, { id: slot });
117
- },
118
- (error) => {
119
- push("error", typeof messages.error === "function" ? messages.error(error) : messages.error, { id: slot });
120
- }
121
- );
122
- return promise;
123
- }
124
- });
125
- function useToast() {
126
- return toast;
127
- }
128
- function useToasts() {
129
- return useSyncExternalStore(
130
- (fn) => {
131
- const { subs } = store();
132
- subs.add(fn);
133
- return () => subs.delete(fn);
134
- },
135
- () => store().items,
136
- () => store().items
137
- );
138
- }
139
- var TONE = {
140
- success: {
141
- icon: /* @__PURE__ */ jsx(CheckCircleIcon, { size: 15, className: "text-th-ok" }),
142
- className: "border-th-ok/35"
143
- },
144
- error: {
145
- icon: /* @__PURE__ */ jsx(AlertTriangleIcon, { size: 15, className: "text-th-loss" }),
146
- className: "border-th-loss/40"
147
- },
148
- warn: {
149
- icon: /* @__PURE__ */ jsx(AlertTriangleIcon, { size: 15, className: "text-th-warn" }),
150
- className: "border-th-warn/40"
151
- },
152
- info: {
153
- icon: /* @__PURE__ */ jsx(InfoIcon, { size: 15, className: "text-th-accent" }),
154
- className: "border-th-line-strong"
155
- }
156
- };
14
+ var cardFailed = false;
15
+ var cardModule = /* @__PURE__ */ lazyModule(
16
+ () => import("./toast-card.js").catch((e) => {
17
+ cardFailed = true;
18
+ throw e;
19
+ })
20
+ );
157
21
  var DESKTOP_BOTTOM = {
158
22
  sm: "sm:bottom-0 sm:pb-[calc(var(--nish-bottom-inset,0px)+1.25rem+min(var(--nish-bottom-bar-h,0px),1rem))]",
159
23
  md: "sm:bottom-0 sm:pb-[var(--nish-toast-offset,calc(var(--nish-bottom-inset,0px)+1.25rem+min(var(--nish-bottom-bar-h,0px),1rem)))] md:pb-[calc(var(--nish-bottom-inset,0px)+1.25rem+min(var(--nish-bottom-bar-h,0px),1rem))]",
@@ -161,6 +25,20 @@ var DESKTOP_BOTTOM = {
161
25
  };
162
26
  function Toaster({ className, offset, offsetUntil = "md", style: userStyle, ref, ...rest }) {
163
27
  const list = useToasts();
28
+ useEffect(() => cardFailed ? void 0 : preloadWhenIdle(cardModule), []);
29
+ const card = useLazyModule(cardModule, list.length > 0 && !cardFailed);
30
+ const Card = card?.ToastCard;
31
+ const stack = useRef(null);
32
+ const focused = useRef(null);
33
+ useEffect(() => {
34
+ const f = focused.current;
35
+ if (!Card || !f || document.activeElement !== document.body) return;
36
+ const at = list.findIndex((i) => i.id === f[0]);
37
+ const btn = [...stack.current?.children[at]?.querySelectorAll("button") ?? []].find(
38
+ (b) => (b.getAttribute("aria-label") ?? b.textContent) === f[1]
39
+ );
40
+ btn?.focus();
41
+ }, [Card]);
164
42
  const [polite, setPolite] = useState({ text: "", seq: 0 });
165
43
  const [assertive, setAssertive] = useState({ text: "", seq: 0 });
166
44
  const announced = useRef(/* @__PURE__ */ new Set());
@@ -224,105 +102,22 @@ function Toaster({ className, offset, offsetUntil = "md", style: userStyle, ref,
224
102
  children: [
225
103
  /* @__PURE__ */ jsx("div", { role: "status", "aria-live": "polite", "aria-atomic": "true", className: "sr-only", children: /* @__PURE__ */ jsx("span", { children: polite.text }, polite.seq) }),
226
104
  /* @__PURE__ */ jsx("div", { role: "alert", "aria-live": "assertive", "aria-atomic": "true", className: "sr-only", children: /* @__PURE__ */ jsx("span", { children: assertive.text }, assertive.seq) }),
227
- list.map((t) => /* @__PURE__ */ jsx(ToastCard, { t }, t.id))
105
+ /* @__PURE__ */ jsx("div", { ref: stack, className: "contents", children: list.map((t) => Card ? /* @__PURE__ */ jsx(Card, { t }, t.id) : /* @__PURE__ */ jsx(ToastFallback, { t, focusedRef: focused }, t.id)) })
228
106
  ]
229
107
  }
230
108
  ) });
231
109
  }
232
- var SWIPE_DISMISS_FRACTION = 0.35;
233
- var SWIPE_DISMISS_VELOCITY = 0.5;
234
- var SWIPE_SLOP = 8;
235
- function ToastCard({ t }) {
236
- const strings = useNishStrings();
237
- const ref = useRef(null);
238
- const drag = useRef(null);
239
- const setOffset = (dx, width) => {
240
- const el = ref.current;
241
- if (!el) return;
242
- el.style.transform = dx === 0 ? "" : `translateX(${dx}px)`;
243
- el.style.opacity = dx === 0 ? "" : String(Math.max(0, 1 - Math.abs(dx) / width));
244
- };
245
- const onDown = (e) => {
246
- if (e.pointerType === "mouse") return;
247
- drag.current = {
248
- pointerId: e.pointerId,
249
- startX: e.clientX,
250
- startY: e.clientY,
251
- lastX: e.clientX,
252
- lastT: e.timeStamp,
253
- velocity: 0,
254
- active: false
255
- };
256
- };
257
- const onMove = (e) => {
258
- const d = drag.current;
259
- const el = ref.current;
260
- if (!d || !el || d.pointerId !== e.pointerId) return;
261
- const dx = e.clientX - d.startX;
262
- if (!d.active) {
263
- if (Math.abs(dx) < SWIPE_SLOP || Math.abs(dx) < Math.abs(e.clientY - d.startY)) return;
264
- d.active = true;
265
- el.setPointerCapture(e.pointerId);
266
- pauseTimer(t.id);
267
- }
268
- const dt = e.timeStamp - d.lastT;
269
- if (dt > 0) d.velocity = (e.clientX - d.lastX) / dt;
270
- d.lastX = e.clientX;
271
- d.lastT = e.timeStamp;
272
- setOffset(dx, el.offsetWidth);
273
- };
274
- const onUp = (e) => {
275
- const d = drag.current;
276
- const el = ref.current;
277
- drag.current = null;
278
- if (!d || !el || d.pointerId !== e.pointerId || !d.active) return;
279
- const dx = e.clientX - d.startX;
280
- const width = el.offsetWidth;
281
- const flung = Math.abs(d.velocity) > SWIPE_DISMISS_VELOCITY && Math.sign(d.velocity) === Math.sign(dx);
282
- if (Math.abs(dx) > width * SWIPE_DISMISS_FRACTION || flung) {
283
- dismissToast(t.id);
284
- return;
285
- }
286
- el.style.transition = "transform 160ms var(--nish-ease-out), opacity 160ms var(--nish-ease-out)";
287
- setOffset(0, width);
288
- window.setTimeout(() => {
289
- if (ref.current) ref.current.style.transition = "";
290
- }, 180);
291
- resumeTimer(t.id);
292
- };
293
- const onCancel = (e) => {
294
- const d = drag.current;
295
- drag.current = null;
296
- if (!d?.active || d.pointerId !== e.pointerId) return;
297
- setOffset(0, ref.current?.offsetWidth || 1);
298
- resumeTimer(t.id);
299
- };
300
- const leave = (e) => {
301
- if (!e.currentTarget.contains(e.relatedTarget)) resumeTimer(t.id);
302
- };
303
- const enter = (e) => {
304
- if (!e.currentTarget.contains(e.relatedTarget)) pauseTimer(t.id);
110
+ function ToastFallback({ t, focusedRef }) {
111
+ const strings = useStrings(DISPLAY_STRINGS);
112
+ const track = (e) => {
113
+ focusedRef.current = [t.id, e.currentTarget.getAttribute("aria-label") ?? e.currentTarget.textContent];
305
114
  };
306
115
  return /* @__PURE__ */ jsxs(
307
116
  "div",
308
117
  {
309
- ref,
310
- onPointerDown: onDown,
311
- onPointerMove: onMove,
312
- onPointerUp: onUp,
313
- onPointerCancel: onCancel,
314
- onPointerEnter: (e) => e.pointerType === "mouse" && pauseTimer(t.id),
315
- onPointerLeave: (e) => e.pointerType === "mouse" && resumeTimer(t.id),
316
- onFocus: enter,
317
- onBlur: leave,
318
- className: cn(
319
- "pointer-events-auto flex w-full max-w-md items-start gap-2.5 rounded-xl border bg-th-elevated px-3.5 py-3 shadow-pop",
320
- "touch-pan-y animate-[nish-rise-in_160ms_var(--nish-ease-out)]",
321
- "max-sm:[html[data-nish-layer-open]_&]:animate-[nish-toast-in-top_200ms_var(--nish-ease-out)]",
322
- TONE[t.tone].className
323
- ),
118
+ "data-nish-toast-fallback": "",
119
+ className: "pointer-events-auto flex w-full max-w-md items-start gap-2.5 rounded-xl border border-th-line-strong bg-th-elevated px-3.5 py-3 shadow-pop animate-[nish-rise-in_160ms_var(--nish-ease-out)]",
324
120
  children: [
325
- /* @__PURE__ */ jsx("span", { className: "mt-0.5 shrink-0", children: TONE[t.tone].icon }),
326
121
  /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
327
122
  /* @__PURE__ */ jsx("p", { className: "text-sm font-medium leading-snug text-th-hi", children: t.title }),
328
123
  t.body ? /* @__PURE__ */ jsx("p", { className: "mt-0.5 break-words text-xs leading-snug text-th-hi2", children: t.body }) : null
@@ -331,6 +126,7 @@ function ToastCard({ t }) {
331
126
  "button",
332
127
  {
333
128
  type: "button",
129
+ onFocus: track,
334
130
  onClick: () => {
335
131
  t.action?.onClick();
336
132
  dismissToast(t.id);
@@ -343,6 +139,7 @@ function ToastCard({ t }) {
343
139
  "button",
344
140
  {
345
141
  type: "button",
142
+ onFocus: track,
346
143
  onClick: () => dismissToast(t.id),
347
144
  "aria-label": strings.dismiss,
348
145
  className: "-m-1 inline-flex shrink-0 items-center justify-center rounded-md p-1 text-th-hi3 transition-colors hover:bg-th-overlay hover:text-th-hi pointer-coarse:-my-2 pointer-coarse:min-h-11 pointer-coarse:min-w-11",
@@ -355,7 +152,7 @@ function ToastCard({ t }) {
355
152
  }
356
153
  export {
357
154
  Toaster,
358
- dismissToast,
155
+ dismissToast2 as dismissToast,
359
156
  toast,
360
157
  useToast
361
158
  };
@@ -6,7 +6,7 @@ import { createPortal } from "react-dom";
6
6
  import { cn } from "../cn.js";
7
7
  import { shared } from "../runtime.js";
8
8
  import { useIsoLayoutEffect } from "./client.js";
9
- import { useNishConfig } from "./provider.js";
9
+ import { useNishContext } from "./provider.js";
10
10
  import { keyboardFocused, touchTracker } from "./overlay-classes.js";
11
11
  import { FOCUSABLE, layerHost, useMergedRef } from "./overlay-core.js";
12
12
  import { EDGE, useAnchoredPosition, floatingStyle } from "./overlay-position.js";
@@ -146,7 +146,7 @@ function FloatingTip({
146
146
  onPointerEnter,
147
147
  onPointerLeave
148
148
  }) {
149
- const config = useNishConfig();
149
+ const config = useNishContext();
150
150
  const tipRef = useRef(null);
151
151
  const pos = useAnchoredPosition(anchor, tipRef, true, side, "center");
152
152
  return createPortal(
@@ -12,7 +12,8 @@ import {
12
12
  import { cn } from "../cn.js";
13
13
  import { useIsoLayoutEffect } from "./client.js";
14
14
  import { sortRows } from "./data-classes.js";
15
- import { useNishStrings } from "./provider.js";
15
+ import { useStrings } from "./provider.js";
16
+ import { TABLE_STRINGS, STATUS_STRINGS } from "./strings.js";
16
17
  import { useLatest } from "./latest.js";
17
18
  import { Table, TableWrap, Td, Th, Tr } from "./table.js";
18
19
  import { useVirtualRows } from "./virtual.js";
@@ -46,7 +47,7 @@ function VirtualTable({
46
47
  ref,
47
48
  ...rest
48
49
  }) {
49
- const t = useNishStrings();
50
+ const t = useStrings(TABLE_STRINGS, STATUS_STRINGS);
50
51
  const size = rowHeight ?? (onRowClick ? 44 : dense ? 33 : 41);
51
52
  const [innerSort, setInnerSort] = useState(null);
52
53
  const [announcement, setAnnouncement] = useState("");
package/dist/esm/index.js CHANGED
@@ -87,12 +87,6 @@ import {
87
87
  AnimatedList,
88
88
  usePrefersReducedMotion
89
89
  } from "./components/flow.js";
90
- import { SystemCanvas, layoutSystem, pickLayout, routeEdges } from "./system-canvas.js";
91
- import { DEFAULT_CANVAS_LABELS } from "./components/canvas/types.js";
92
- import { Inbox } from "./components/inbox.js";
93
- import { DEFAULT_INBOX_LABELS } from "./components/inbox-classes.js";
94
- import { INBOX_SOURCE_LABELS, INBOX_DEFAULT_SETTINGS } from "./inbox-types.js";
95
- import { INBOX_ACTION_HEADER, INBOX_ACTION_TIMEOUT_MS } from "./inbox-types.js";
96
90
  import { AppShell } from "./components/app-shell.js";
97
91
  import { useResource } from "./components/resource.js";
98
92
  import { apiFetch, ApiError, configureApi } from "./components/resource-classes.js";
@@ -100,7 +94,6 @@ import { AppErrorBoundary } from "./components/error-boundary.js";
100
94
  import { FilterBar, FilterSheet } from "./components/filters.js";
101
95
  import { useUrlState, locationAdapter } from "./components/url-state.js";
102
96
  import { SettingsSection, SettingRow, NumberField, useSaveStatus } from "./components/settings.js";
103
- import { ServiceTokensSection, useServiceTokens } from "./components/service-tokens.js";
104
97
  import { Combobox } from "./components/combobox.js";
105
98
  import { Calendar } from "./components/calendar.js";
106
99
  import { DatePicker } from "./components/date-picker.js";
@@ -195,8 +188,6 @@ export {
195
188
  ConnectionBanner,
196
189
  ContextMenu,
197
190
  CopyButton,
198
- DEFAULT_CANVAS_LABELS,
199
- DEFAULT_INBOX_LABELS,
200
191
  DEFAULT_STRINGS,
201
192
  DEFAULT_THEME,
202
193
  DatePicker,
@@ -215,12 +206,7 @@ export {
215
206
  FlowSteps,
216
207
  HUE_ROLES,
217
208
  HoverCard,
218
- INBOX_ACTION_HEADER,
219
- INBOX_ACTION_TIMEOUT_MS,
220
- INBOX_DEFAULT_SETTINGS,
221
- INBOX_SOURCE_LABELS,
222
209
  IconButton,
223
- Inbox,
224
210
  InfoIcon,
225
211
  Input,
226
212
  Kbd,
@@ -279,7 +265,6 @@ export {
279
265
  Segmented,
280
266
  Select,
281
267
  Separator,
282
- ServiceTokensSection,
283
268
  SettingRow,
284
269
  SettingsIcon,
285
270
  SettingsSection,
@@ -301,7 +286,6 @@ export {
301
286
  StickyBar,
302
287
  SunIcon,
303
288
  Switch,
304
- SystemCanvas,
305
289
  THEMES,
306
290
  TabPanel,
307
291
  Table,
@@ -341,16 +325,13 @@ export {
341
325
  googleFavicon,
342
326
  iconButtonClass,
343
327
  isRtl,
344
- layoutSystem,
345
328
  linkClass,
346
329
  locationAdapter,
347
330
  menuItemClass,
348
331
  navigateFromLayer,
349
332
  paginationRange,
350
- pickLayout,
351
333
  presetOptions,
352
334
  revealClass,
353
- routeEdges,
354
335
  safeUrl,
355
336
  setDefaultLocale,
356
337
  signTone,
@@ -377,7 +358,6 @@ export {
377
358
  useSaveStatus,
378
359
  useScrollEdges,
379
360
  useScrollSpy,
380
- useServiceTokens,
381
361
  useStuck,
382
362
  useTheme,
383
363
  useToast,
@@ -1,5 +1,5 @@
1
1
  // src/runtime.ts
2
- var version = true ? "2.2.0" : "dev";
2
+ var version = true ? "3.0.0" : "dev";
3
3
  var VERSION = version;
4
4
  var KEY = /* @__PURE__ */ Symbol.for("nish-ui.runtime.v1");
5
5
  function runtime() {
@@ -1,2 +1,6 @@
1
1
  // src/system-canvas.ts
2
2
  export * from "./components/canvas/index.js";
3
+ import { DEFAULT_CANVAS_LABELS } from "./components/canvas/types.js";
4
+ export {
5
+ DEFAULT_CANVAS_LABELS
6
+ };
package/dist/esm/theme.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { DEFAULT_THEME, THEMES } from "./tokens.mjs";
3
3
  import { shared } from "./runtime.js";
4
4
  import { safeUrl } from "./url.js";
5
- import { DEFAULT_STRINGS } from "./components/strings.js";
5
+ import { DISPLAY_STRINGS, OVERLAY_STRINGS, THEME_STRINGS } from "./components/strings.js";
6
6
  function buildPresets() {
7
7
  return Object.keys(THEMES).map((id) => ({
8
8
  id,
@@ -201,9 +201,9 @@ var TOGGLE_ICONS = {
201
201
  dark: [["path", { d: "M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9" }]]
202
202
  };
203
203
  var defaultToggleLabels = () => ({
204
- system: DEFAULT_STRINGS.themeSystem,
205
- light: DEFAULT_STRINGS.themeLight,
206
- dark: DEFAULT_STRINGS.themeDark
204
+ system: THEME_STRINGS.themeSystem,
205
+ light: THEME_STRINGS.themeLight,
206
+ dark: THEME_STRINGS.themeDark
207
207
  });
208
208
  var DEFAULT_ELSEWHERE = "set on another site";
209
209
  function nextChoice(choice) {
@@ -217,7 +217,7 @@ function themeLabel(choice, words) {
217
217
  }
218
218
  function mountThemeToggle(button, opts = {}) {
219
219
  const words = { ...defaultToggleLabels(), ...opts.labels };
220
- const sentence = opts.strings?.themeToggleLabel ?? DEFAULT_STRINGS.themeToggleLabel;
220
+ const sentence = opts.strings?.themeToggleLabel ?? THEME_STRINGS.themeToggleLabel;
221
221
  const elsewhereWords = opts.elsewhereLabel ?? DEFAULT_ELSEWHERE;
222
222
  if (button.tagName === "BUTTON" && !button.getAttribute("type")) button.setAttribute("type", "button");
223
223
  const children = Object.keys(TOGGLE_ICONS).map(
@@ -341,7 +341,7 @@ function showToast(content, opts = {}) {
341
341
  const close = document.createElement("button");
342
342
  close.type = "button";
343
343
  close.className = "nish-toast-close";
344
- close.setAttribute("aria-label", opts.dismissLabel ?? opts.strings?.dismiss ?? DEFAULT_STRINGS.dismiss);
344
+ close.setAttribute("aria-label", opts.dismissLabel ?? opts.strings?.dismiss ?? DISPLAY_STRINGS.dismiss);
345
345
  close.append(svgIcon(14, [["path", { d: "M18 6 6 18M6 6l12 12" }]]));
346
346
  close.addEventListener("click", hide);
347
347
  box.append(close);
@@ -391,7 +391,7 @@ function confirmDialog(opts) {
391
391
  b.textContent = label;
392
392
  return b;
393
393
  };
394
- const cancelBtn = button(opts.cancelLabel ?? opts.strings?.cancel ?? DEFAULT_STRINGS.cancel, "nish-btn");
394
+ const cancelBtn = button(opts.cancelLabel ?? opts.strings?.cancel ?? OVERLAY_STRINGS.cancel, "nish-btn");
395
395
  const confirmBtn = button(opts.confirmLabel ?? "Confirm", `nish-btn ${danger ? "nish-btn--danger" : "nish-btn--primary"}`);
396
396
  (danger ? cancelBtn : confirmBtn).autofocus = true;
397
397
  actions.append(cancelBtn, confirmBtn);
package/dist/format.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/runtime.ts
2
- var version = true ? "2.2.0" : "dev";
2
+ var version = true ? "3.0.0" : "dev";
3
3
  var KEY = /* @__PURE__ */ Symbol.for("nish-ui.runtime.v1");
4
4
  function runtime() {
5
5
  const g = globalThis;
package/dist/index.d.ts CHANGED
@@ -1,9 +1,6 @@
1
1
  import { ClassValue } from 'clsx';
2
2
  import * as react from 'react';
3
- import { ReactNode, useLayoutEffect, HTMLAttributes, Ref, ButtonHTMLAttributes, InputHTMLAttributes, SelectHTMLAttributes, FieldsetHTMLAttributes, ChangeEvent, MouseEvent, TextareaHTMLAttributes, ComponentPropsWithoutRef, RefObject, ReactElement, ComponentProps, ElementType, ComponentPropsWithRef, SVGProps } from 'react';
4
- export { C as CanvasEdge, a as CanvasEdgeKind, b as CanvasGroup, c as CanvasHue, d as CanvasLabels, e as CanvasLayout, f as CanvasLayoutMode, g as CanvasNode, h as CanvasNodeKind, D as DEFAULT_CANVAS_LABELS, L as LayoutOptions, R as RoutedEdge, S as SystemCanvas, i as SystemCanvasProps, l as layoutSystem, p as pickLayout, r as routeEdges } from './system-canvas-BLuWd69H.js';
5
- export { DEFAULT_INBOX_LABELS, INBOX_ACTION_HEADER, INBOX_ACTION_TIMEOUT_MS, INBOX_DEFAULT_SETTINGS, INBOX_SOURCE_LABELS, Inbox, InboxAction, InboxActionCall, InboxActionResult, InboxItem, InboxLabels, InboxListResponse, InboxProps, InboxSettings, InboxSeverity, InboxView } from './inbox.js';
6
- export { ServiceTokenListResponse, ServiceTokenView, ServiceTokensSection, ServiceTokensSectionProps, useServiceTokens } from './service-tokens.js';
3
+ import { ReactNode, useLayoutEffect, HTMLAttributes, Ref, ButtonHTMLAttributes, InputHTMLAttributes, SelectHTMLAttributes, FieldsetHTMLAttributes, ChangeEvent, TextareaHTMLAttributes, ComponentPropsWithoutRef, RefObject, ReactElement, ComponentProps, ElementType, ComponentPropsWithRef, SVGProps, MouseEvent } from 'react';
7
4
 
8
5
  /** Conditional Tailwind classes with conflict resolution. */
9
6
  declare function cn(...inputs: ClassValue[]): string;
@@ -333,6 +330,7 @@ interface NishStrings {
333
330
  /** Progress: label of an indeterminate bar. */
334
331
  progressIndeterminate: string;
335
332
  }
333
+ /** Every English default. Built from the groups; components read their own groups through `useStrings`. */
336
334
  declare const DEFAULT_STRINGS: NishStrings;
337
335
 
338
336
  /** Theme switching shared by every nish.software page.
@@ -385,7 +383,7 @@ interface MountThemeToggleOptions {
385
383
  /** Replace the words "System", "Light" and "Dark" in the button's label, e.g. for
386
384
  * another language. The label reads "Theme: Light. Switch to Dark". */
387
385
  labels?: ThemeToggleLabels;
388
- /** Replace the label sentence: `themeToggleLabel(current, next)`. Defaults to DEFAULT_STRINGS. */
386
+ /** Replace the label sentence: `themeToggleLabel(current, next)`. Defaults to THEME_STRINGS. */
389
387
  strings?: Partial<Pick<NishStrings, 'themeToggleLabel'>>;
390
388
  /** The words after a preset saved on another site: "Theme: Mocha (set on another site). …".
391
389
  * Default "set on another site". */
@@ -430,7 +428,7 @@ interface ShowToastOptions {
430
428
  href?: string;
431
429
  onClick?: () => void;
432
430
  };
433
- /** Accessible name of the dismiss button. Default DEFAULT_STRINGS.dismiss ("Dismiss"). */
431
+ /** Accessible name of the dismiss button. Default DISPLAY_STRINGS.dismiss ("Dismiss"). */
434
432
  dismissLabel?: string;
435
433
  /** Strings for this toast (another language): `dismiss`. `dismissLabel` wins when both are given. */
436
434
  strings?: Partial<Pick<NishStrings, 'dismiss'>>;
@@ -448,7 +446,7 @@ interface ConfirmDialogOptions {
448
446
  body?: string | Node;
449
447
  /** The confirm button's label: a verb that names the action. Default "Confirm". */
450
448
  confirmLabel?: string;
451
- /** The cancel button's label. Default DEFAULT_STRINGS.cancel ("Cancel"). */
449
+ /** The cancel button's label. Default OVERLAY_STRINGS.cancel ("Cancel"). */
452
450
  cancelLabel?: string;
453
451
  /** Strings for this dialog (another language): `cancel`. `cancelLabel` wins when both are given. */
454
452
  strings?: Partial<Pick<NishStrings, 'cancel'>>;
@@ -895,11 +893,9 @@ interface SwitchProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onC
895
893
  checked?: boolean;
896
894
  /** The starting state of an uncontrolled switch (no `checked`). */
897
895
  defaultChecked?: boolean;
898
- /** Called with the new value and the click event when the switch is clicked or toggled
899
- * with Space/Enter. Kept for 2.x; prefer onCheckedChange. */
900
- onChange?: (checked: boolean, event: MouseEvent<HTMLButtonElement>) => void;
901
- /** Called with the new value. The form-library friendly callback: use it with
902
- * react-hook-form's Controller (`onCheckedChange={field.onChange}`). */
896
+ /** Called with the new value when the switch is clicked or toggled with Space or Enter.
897
+ * Use it with react-hook-form's Controller (`onCheckedChange={field.onChange}`). Need the
898
+ * click event? Use `onClick`. */
903
899
  onCheckedChange?: (checked: boolean) => void;
904
900
  /** Field name for a native form. With it, a hidden checkbox mirrors the state, so
905
901
  * FormData and `<form action>` carry the value. */
@@ -926,7 +922,7 @@ interface SwitchProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onC
926
922
  * waits for Save; use Checkbox for that). A `<button role="switch" aria-checked>`; with a
927
923
  * `name` it also posts in native forms. `ref` and the remaining props go to the button;
928
924
  * `className` goes to the row (or to the button when there is no label). */
929
- declare function Switch({ ref, checked: checkedProp, defaultChecked, onChange, onCheckedChange, name, value, required, form, label, description, size, labelSide, disabled, className, id, onClick, ...rest }: SwitchProps): react.JSX.Element;
925
+ declare function Switch({ ref, checked: checkedProp, defaultChecked, onCheckedChange, name, value, required, form, label, description, size, labelSide, disabled, className, id, onClick, ...allRest }: SwitchProps): react.JSX.Element;
930
926
  interface FieldProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
931
927
  /** The wrapper element. */
932
928
  ref?: Ref<HTMLDivElement>;
@@ -1324,6 +1320,7 @@ type ToastFn = ToastCall & {
1324
1320
  declare const toast: ToastFn;
1325
1321
  /** Same API as a hook, for code that prefers one. */
1326
1322
  declare function useToast(): ToastFn;
1323
+
1327
1324
  interface ToasterProps extends Omit<ComponentPropsWithoutRef<'div'>, 'className' | 'children'> {
1328
1325
  /** Extra classes for the stack, e.g. to lift it above a bottom nav: sm:bottom-20. */
1329
1326
  className?: string;
@@ -2657,7 +2654,7 @@ interface ThemeToggleProps {
2657
2654
  ref?: Ref<HTMLElement>;
2658
2655
  }
2659
2656
  /** System / Light / Dark as a Segmented radio group, optionally with a preset picker,
2660
- * or one cycling icon button when compact. Words come from `useNishStrings()`. Other props
2657
+ * or one cycling icon button when compact. Words come from `useStrings(THEME_STRINGS)`. Other props
2661
2658
  * (id, data-*, aria-*, style) go on the root element. */
2662
2659
  declare function ThemeToggle({ ref, presets, labels, block, size, compact, variant, phone, collapse, className, elsewhereLabel, ...rest }: ThemeToggleProps & Omit<HTMLAttributes<HTMLElement>, 'children' | 'onChange'>): react.JSX.Element;
2663
2660