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
@@ -40,9 +40,21 @@ function TableWrap({
40
40
  update();
41
41
  if (typeof ResizeObserver === "undefined") return;
42
42
  const ro = new ResizeObserver(update);
43
- ro.observe(el);
44
- for (const c of Array.from(el.children)) ro.observe(c);
45
- return () => ro.disconnect();
43
+ const watch = () => {
44
+ ro.disconnect();
45
+ ro.observe(el);
46
+ for (const c of Array.from(el.children)) ro.observe(c);
47
+ };
48
+ watch();
49
+ const mo = typeof MutationObserver === "undefined" ? null : new MutationObserver(() => {
50
+ watch();
51
+ update();
52
+ });
53
+ mo?.observe(el, { childList: true });
54
+ return () => {
55
+ ro.disconnect();
56
+ mo?.disconnect();
57
+ };
46
58
  }, []);
47
59
  const name = label ?? rest["aria-label"];
48
60
  const css = {
@@ -143,7 +143,11 @@ function TagInput({
143
143
  if (!SPLIT.test(pasted)) return;
144
144
  e.preventDefault();
145
145
  const parts = pasted.split(SPLIT);
146
- parts[0] = text + parts[0];
146
+ const el = e.currentTarget;
147
+ const start = Math.min(el.selectionStart ?? text.length, text.length);
148
+ const end = Math.min(el.selectionEnd ?? start, text.length);
149
+ parts[0] = text.slice(0, start) + parts[0];
150
+ parts[parts.length - 1] += text.slice(end);
147
151
  const { error: err, refused } = add(parts);
148
152
  setText(err ? refused.join(", ") : "");
149
153
  };
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  // src/components/time-field.tsx
4
- import { useEffect, useId, useRef, useState } from "react";
4
+ import { useCallback, useEffect, useId, useRef, useState } from "react";
5
5
  import { cn } from "../cn.js";
6
6
  import { getDefaultLocale } from "../format.js";
7
7
  import { resolveLocale } from "./calendar-classes.js";
@@ -109,6 +109,13 @@ function TimeField({
109
109
  const [own, setOwn] = useState(() => okProp("defaultValue", defaultValue));
110
110
  const value = controlled ? okProp("value", valueProp) : own;
111
111
  const hourRef = useRef(null);
112
+ const setHourNode = useCallback(
113
+ (node) => {
114
+ hourRef.current = node;
115
+ setRef(ref, node);
116
+ },
117
+ [ref]
118
+ );
112
119
  const minuteRef = useRef(null);
113
120
  const [draftState, setDraft] = useState(null);
114
121
  const [bad, setBad] = useState(false);
@@ -188,10 +195,14 @@ function TimeField({
188
195
  }
189
196
  } else if (key === "Home") {
190
197
  e.preventDefault();
191
- update(which === "h" ? { ...shown, h: hourText(0, cycle), pm: false } : { ...shown, m: "00" });
198
+ update(
199
+ which === "h" ? cycle === 12 ? { ...shown, h: "1" } : { ...shown, h: hourText(0, cycle), pm: false } : { ...shown, m: "00" }
200
+ );
192
201
  } else if (key === "End") {
193
202
  e.preventDefault();
194
- update(which === "h" ? { ...shown, h: hourText(23, cycle), pm: true } : { ...shown, m: pad2(lastMinute(st)) });
203
+ update(
204
+ which === "h" ? cycle === 12 ? { ...shown, h: "12" } : { ...shown, h: hourText(23, cycle), pm: true } : { ...shown, m: pad2(lastMinute(st)) }
205
+ );
195
206
  } else if (cycle === 12 && (key === "a" || key === "A" || key === "p" || key === "P")) {
196
207
  e.preventDefault();
197
208
  update({ ...shown, pm: key === "p" || key === "P" });
@@ -258,10 +269,7 @@ function TimeField({
258
269
  "input",
259
270
  {
260
271
  ...common,
261
- ref: (node) => {
262
- hourRef.current = node;
263
- setRef(ref, node);
264
- },
272
+ ref: setHourNode,
265
273
  id: inputId,
266
274
  value: shown.h,
267
275
  "aria-labelledby": names(hId),
@@ -40,7 +40,7 @@ function ToastCard({ t }) {
40
40
  el.style.opacity = dx === 0 ? "" : String(Math.max(0, 1 - Math.abs(dx) / width));
41
41
  };
42
42
  const onDown = (e) => {
43
- if (e.pointerType === "mouse") return;
43
+ if (e.pointerType === "mouse" || drag.current) return;
44
44
  drag.current = {
45
45
  pointerId: e.pointerId,
46
46
  startX: e.clientX,
@@ -71,8 +71,9 @@ function ToastCard({ t }) {
71
71
  const onUp = (e) => {
72
72
  const d = drag.current;
73
73
  const el = ref.current;
74
+ if (d && d.pointerId !== e.pointerId) return;
74
75
  drag.current = null;
75
- if (!d || !el || d.pointerId !== e.pointerId || !d.active) return;
76
+ if (!d || !el || !d.active) return;
76
77
  const dx = e.clientX - d.startX;
77
78
  const width = el.offsetWidth;
78
79
  const flung = Math.abs(d.velocity) > SWIPE_DISMISS_VELOCITY && Math.sign(d.velocity) === Math.sign(dx);
@@ -89,8 +90,9 @@ function ToastCard({ t }) {
89
90
  };
90
91
  const onCancel = (e) => {
91
92
  const d = drag.current;
93
+ if (d && d.pointerId !== e.pointerId) return;
92
94
  drag.current = null;
93
- if (!d?.active || d.pointerId !== e.pointerId) return;
95
+ if (!d?.active) return;
94
96
  setOffset(0, ref.current?.offsetWidth || 1);
95
97
  resumeTimer(t.id);
96
98
  };
@@ -116,7 +116,10 @@ function ToastFallback({ t, focusedRef }) {
116
116
  "div",
117
117
  {
118
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)]",
119
+ onBlur: (e) => {
120
+ if (!e.currentTarget.contains(e.relatedTarget)) focusedRef.current = null;
121
+ },
122
+ className: `pointer-events-auto flex w-full max-w-md items-start gap-2.5 rounded-xl border ${{ success: "border-th-ok/35", error: "border-th-loss/40", warn: "border-th-warn/40", info: "border-th-line-strong" }[t.tone]} bg-th-elevated px-3.5 py-3 shadow-pop animate-[nish-rise-in_160ms_var(--nish-ease-out)]`,
120
123
  children: [
121
124
  /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
122
125
  /* @__PURE__ */ jsx("p", { className: "text-sm font-medium leading-snug text-th-hi", children: t.title }),
@@ -100,9 +100,10 @@ function Tooltip({ tip, children, className, side = "top", as = "span", focusabl
100
100
  if (!over) graceTimer.current = window.setTimeout(() => setOpen(false), TIP_GRACE_MS);
101
101
  }, []);
102
102
  const wrapperFocusable = focusable ?? !inner;
103
+ const own = rest ?? {};
103
104
  const a11y = {
104
- tabIndex: wrapperFocusable ? 0 : void 0,
105
- "aria-describedby": open && !inner ? id : void 0,
105
+ tabIndex: own.tabIndex ?? (wrapperFocusable ? 0 : void 0),
106
+ "aria-describedby": [own["aria-describedby"], open && !inner ? id : void 0].filter(Boolean).join(" ") || void 0,
106
107
  "data-state": open ? "open" : "closed"
107
108
  };
108
109
  const hint = variant === "hint" && "cursor-help underline decoration-th-hi3 decoration-dotted underline-offset-2";
@@ -2,7 +2,8 @@
2
2
 
3
3
  // src/components/url-state.ts
4
4
  import { useCallback, useMemo, useSyncExternalStore } from "react";
5
- var EVENT = "nish:urlstate";
5
+ var URL_STATE_EVENT = "nish:urlstate";
6
+ var EVENT = URL_STATE_EVENT;
6
7
  var locationAdapter = {
7
8
  get() {
8
9
  if (typeof location === "undefined") return new URLSearchParams();
@@ -115,6 +116,7 @@ function useUrlState(defaults, o = {}) {
115
116
  return [state, patch, reset];
116
117
  }
117
118
  export {
119
+ URL_STATE_EVENT,
118
120
  locationAdapter,
119
121
  useUrlState
120
122
  };
@@ -11,14 +11,14 @@ import {
11
11
  } from "react";
12
12
  import { cn } from "../cn.js";
13
13
  import { useIsoLayoutEffect } from "./client.js";
14
- import { sortRows } from "./data-classes.js";
14
+ import { sortRows, tableInternals } from "./data-classes.js";
15
15
  import { useStrings } from "./provider.js";
16
16
  import { TABLE_STRINGS, STATUS_STRINGS } from "./strings.js";
17
17
  import { useLatest } from "./latest.js";
18
18
  import { Table, TableWrap, Td, Th, Tr } from "./table.js";
19
19
  import { useVirtualRows } from "./virtual.js";
20
20
  import { jsx, jsxs } from "react/jsx-runtime";
21
- var HIDE_BELOW = { sm: "hidden sm:table-cell", md: "hidden md:table-cell", lg: "hidden lg:table-cell" };
21
+ var { HIDE_BELOW } = tableInternals;
22
22
  var ROW_FOCUS = "focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-th-accent";
23
23
  var INTERACTIVE_CHILD = 'a,button,input,select,textarea,label,summary,[role="button"],[role="link"]';
24
24
  function VirtualTable({
@@ -46,12 +46,12 @@ function useVirtualRows(options) {
46
46
  const offsets = useMemo(
47
47
  () => buildOffsets(
48
48
  count,
49
- (i) => (measured.size === 0 ? void 0 : measured.get(getKey(i))) ?? (typeof itemSize === "number" ? itemSize : itemSize(i)),
49
+ (i) => (!measure || measured.size === 0 ? void 0 : measured.get(getKey(i))) ?? (typeof itemSize === "number" ? itemSize : itemSize(i)),
50
50
  gap
51
51
  ),
52
52
  // getKey only matters once something is measured, so an unstable getKey must not rebuild fixed-size offsets
53
53
  // eslint-disable-next-line react-hooks/exhaustive-deps
54
- [count, itemSize, measure ? getKey : null, gap, measured]
54
+ [count, itemSize, measure, measure ? getKey : null, gap, measured]
55
55
  );
56
56
  const total = offsets[count];
57
57
  const offsetOf = useCallback((i) => offsets[i], [offsets]);
@@ -179,7 +179,8 @@ function useVirtualRows(options) {
179
179
  const pin = useCallback((index) => setPinned(index), []);
180
180
  const scrollToIndex = useCallback(
181
181
  // eslint-disable-next-line react-hooks/preserve-manual-memoization -- reads the latest-value ref on purpose; the callback must stay stable
182
- (index, { align = "auto", behavior = "auto" } = {}) => {
182
+ (index, { align = "auto", behavior: wanted = "auto" } = {}) => {
183
+ const behavior = wanted === "smooth" && typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches ? "auto" : wanted;
183
184
  const jump = (minMove) => {
184
185
  const { offsets: o, count: n, gap: g } = latest.current;
185
186
  if (n === 0) return;
@@ -261,7 +262,10 @@ function VirtualList({
261
262
  ...rest,
262
263
  ref: mergeRefs(ref, rootRef),
263
264
  style: rootStyle,
264
- tabIndex: self ? count > 0 ? 0 : void 0 : rest.tabIndex,
265
+ tabIndex: self ? rest.tabIndex ?? (count > 0 ? 0 : void 0) : rest.tabIndex,
266
+ role: self && labelled && count > 0 && rest.role === void 0 ? "region" : rest.role,
267
+ "aria-label": self && labelled && count > 0 && !ariaLabelledBy ? ariaLabel : void 0,
268
+ "aria-labelledby": self && labelled && count > 0 ? ariaLabelledBy : void 0,
265
269
  className: cn("relative", self && "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-th-accent", className),
266
270
  children: count === 0 && empty != null ? empty : /* @__PURE__ */ jsx(
267
271
  "div",
@@ -134,7 +134,7 @@ function money(v, o = {}) {
134
134
  }
135
135
  function signedMoney(v, o = {}) {
136
136
  if (!finite(v)) return DASH;
137
- if (Math.abs(v) < 5e-3) return "No change";
137
+ if (Math.abs(v) < 5e-3) return o.zero ?? "No change";
138
138
  return (v < 0 ? MINUS : "+") + moneyAbs(Math.abs(v), o, loc(o));
139
139
  }
140
140
  function pct(v, o = {}) {
@@ -172,7 +172,8 @@ function bytes(v, o = {}) {
172
172
  i++;
173
173
  }
174
174
  const text = i === 0 || abs >= 100 ? fixed(abs, 0, 0, locale) : fixed(abs, 0, 1, locale);
175
- return (v < 0 ? MINUS : "") + text + " " + BYTE_UNITS[i];
175
+ const zero = Number(text.replace(/[^0-9]/g, "")) === 0;
176
+ return (v < 0 && !zero ? MINUS : "") + text + " " + BYTE_UNITS[i];
176
177
  }
177
178
  var DURATION_PARTS = [
178
179
  [86400, "d", "day"],
@@ -1,5 +1,5 @@
1
1
  // src/runtime.ts
2
- var version = true ? "3.2.0" : "dev";
2
+ var version = true ? "3.3.0" : "dev";
3
3
  var VERSION = version;
4
4
  var KEY = /* @__PURE__ */ Symbol.for("nish-ui.runtime.v1");
5
5
  function runtime() {
@@ -236,6 +236,10 @@ function createInboxClient(options) {
236
236
  }
237
237
  if (queue[0] === head) queue.shift();
238
238
  if (result.kind === "ok") sentSinceDown++;
239
+ else if (!loggedInvalid.has(result.error)) {
240
+ loggedInvalid.add(result.error);
241
+ log(`queued event dropped: ${result.error}`);
242
+ }
239
243
  }
240
244
  retryStep = 0;
241
245
  if (down) {
package/dist/esm/theme.js CHANGED
@@ -25,7 +25,10 @@ function storageKey() {
25
25
  return k && /^[A-Za-z0-9_-]+$/.test(k) ? k : DEFAULT_KEY;
26
26
  }
27
27
  function registerThemes(themes) {
28
- Object.assign(state().extra, themes);
28
+ for (const [name, scheme] of Object.entries(themes)) {
29
+ if (/^[a-z0-9-]+$/.test(name)) state().extra[name] = scheme;
30
+ else console.warn(`[nish-ui] registerThemes: skipped "${name}" (use lowercase letters, digits and hyphens)`);
31
+ }
29
32
  }
30
33
  var has = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
31
34
  function isThemeName(v) {
@@ -34,7 +37,7 @@ function isThemeName(v) {
34
37
  function readCookie() {
35
38
  if (typeof document === "undefined") return null;
36
39
  try {
37
- const m = document.cookie.match(new RegExp(`(?:^|;\\s*)${storageKey()}=([a-z0-9-]+)`));
40
+ const m = document.cookie.match(new RegExp(`(?:^|;\\s*)${storageKey()}=([a-z0-9-]+)(?:;|$)`));
38
41
  return m ? m[1] : null;
39
42
  } catch {
40
43
  return null;
@@ -238,7 +241,7 @@ function mountThemeToggle(button, opts = {}) {
238
241
  if (svg.getAttribute("data-icon") === icon) svg.removeAttribute("display");
239
242
  else svg.setAttribute("display", "none");
240
243
  });
241
- const elsewhere = TOGGLE_ORDER.includes(choice) ? "" : ` (${elsewhereWords})`;
244
+ const elsewhere = TOGGLE_ORDER.includes(choice) || has(state().extra, choice) ? "" : ` (${elsewhereWords})`;
242
245
  const label = sentence(`${themeLabel(choice, words)}${elsewhere}`, themeLabel(nextChoice(choice), words));
243
246
  button.setAttribute("aria-label", label);
244
247
  button.setAttribute("title", label);
@@ -278,7 +281,8 @@ var toastRegion = null;
278
281
  var hideCurrent = null;
279
282
  function showToast(content, opts = {}) {
280
283
  hideCurrent?.();
281
- if (!toastRegion || !toastRegion.isConnected) {
284
+ if (!toastRegion || !toastRegion.isConnected) toastRegion = document.querySelector(".nish-toast-region");
285
+ if (!toastRegion) {
282
286
  toastRegion = document.createElement("div");
283
287
  toastRegion.setAttribute("role", "status");
284
288
  toastRegion.setAttribute("aria-live", "polite");
@@ -301,10 +305,13 @@ function showToast(content, opts = {}) {
301
305
  let remaining = opts.duration === "sticky" ? Infinity : opts.duration ?? TOAST_MS;
302
306
  let started = 0;
303
307
  let holds = 0;
308
+ let returnTo = null;
304
309
  const hide = () => {
305
310
  if (timer != null) clearTimeout(timer);
306
311
  timer = null;
312
+ const hadFocus = box.contains(document.activeElement);
307
313
  box.remove();
314
+ if (hadFocus && returnTo?.isConnected) returnTo.focus();
308
315
  if (hideCurrent === hide) hideCurrent = null;
309
316
  };
310
317
  const run = (ms) => {
@@ -347,7 +354,11 @@ function showToast(content, opts = {}) {
347
354
  box.append(close);
348
355
  box.addEventListener("pointerenter", (e) => e.pointerType === "mouse" && pause());
349
356
  box.addEventListener("pointerleave", (e) => e.pointerType === "mouse" && resume());
350
- box.addEventListener("focusin", (e) => !box.contains(e.relatedTarget) && pause());
357
+ box.addEventListener("focusin", (e) => {
358
+ if (box.contains(e.relatedTarget)) return;
359
+ if (e.relatedTarget instanceof HTMLElement) returnTo = e.relatedTarget;
360
+ pause();
361
+ });
351
362
  box.addEventListener("focusout", (e) => !box.contains(e.relatedTarget) && resume());
352
363
  box.addEventListener("keydown", (e) => {
353
364
  if (e.key === "Escape") hide();
@@ -361,6 +372,11 @@ function showToast(content, opts = {}) {
361
372
  return hide;
362
373
  }
363
374
  var dialogSeq = 0;
375
+ function onBackdrop(dialog, e) {
376
+ if (e.target !== dialog) return false;
377
+ const r = dialog.getBoundingClientRect();
378
+ return !(e.clientX >= r.left && e.clientX <= r.right && e.clientY >= r.top && e.clientY <= r.bottom);
379
+ }
364
380
  function confirmDialog(opts) {
365
381
  if (typeof document === "undefined") return Promise.resolve(false);
366
382
  const opener = document.activeElement instanceof HTMLElement ? document.activeElement : null;
@@ -416,11 +432,12 @@ function confirmDialog(opts) {
416
432
  finish(false);
417
433
  });
418
434
  dialog.addEventListener("close", () => finish(false));
435
+ let pressedOnBackdrop = null;
436
+ dialog.addEventListener("pointerdown", (e) => pressedOnBackdrop = onBackdrop(dialog, e));
419
437
  dialog.addEventListener("click", (e) => {
420
- if (e.target !== dialog) return;
421
- const r = dialog.getBoundingClientRect();
422
- const inside = e.clientX >= r.left && e.clientX <= r.right && e.clientY >= r.top && e.clientY <= r.bottom;
423
- if (!inside) finish(false);
438
+ const down = pressedOnBackdrop;
439
+ pressedOnBackdrop = null;
440
+ if (down !== false && onBackdrop(dialog, e)) finish(false);
424
441
  });
425
442
  document.body.append(dialog);
426
443
  dialog.showModal();
@@ -497,11 +514,15 @@ function openSheet(dialog) {
497
514
  const onKey = (e) => {
498
515
  if (e.key === "Escape") e.stopPropagation();
499
516
  };
517
+ let pressedOnBackdrop = null;
518
+ const onPress = (e) => {
519
+ pressedOnBackdrop = onBackdrop(dialog, e);
520
+ };
500
521
  const onClick = (e) => {
501
522
  if (e.target === dialog) {
502
- const r = dialog.getBoundingClientRect();
503
- const inside = e.clientX >= r.left && e.clientX <= r.right && e.clientY >= r.top && e.clientY <= r.bottom;
504
- if (!inside) closeNow();
523
+ const down = pressedOnBackdrop;
524
+ pressedOnBackdrop = null;
525
+ if (down !== false && onBackdrop(dialog, e)) closeNow();
505
526
  return;
506
527
  }
507
528
  if (e.target instanceof Element && e.target.closest("[data-sheet-close]")) closeNow();
@@ -516,7 +537,7 @@ function openSheet(dialog) {
516
537
  if (typeof matchMedia !== "undefined" && matchMedia("(min-width: 640px)").matches) return;
517
538
  const r = dialog.getBoundingClientRect();
518
539
  const onHeader = e.target instanceof Element && e.target.closest(".nish-sheet-header") != null;
519
- if (!onHeader && e.clientY - r.top > 28) return;
540
+ if (!onHeader && e.clientY - r.top > 44) return;
520
541
  dragging = true;
521
542
  startY = lastY = e.clientY;
522
543
  lastT = e.timeStamp;
@@ -553,6 +574,7 @@ function openSheet(dialog) {
553
574
  dialog.removeEventListener("cancel", onCancel);
554
575
  dialog.removeEventListener("keydown", onKey);
555
576
  dialog.removeEventListener("click", onClick);
577
+ dialog.removeEventListener("pointerdown", onPress);
556
578
  dialog.removeEventListener("pointerdown", onDown);
557
579
  dialog.removeEventListener("pointermove", onMove);
558
580
  dialog.removeEventListener("pointerup", onUp);
@@ -563,6 +585,7 @@ function openSheet(dialog) {
563
585
  dialog.addEventListener("cancel", onCancel);
564
586
  dialog.addEventListener("keydown", onKey);
565
587
  dialog.addEventListener("click", onClick);
588
+ dialog.addEventListener("pointerdown", onPress);
566
589
  dialog.addEventListener("pointerdown", onDown);
567
590
  dialog.addEventListener("pointermove", onMove);
568
591
  dialog.addEventListener("pointerup", onUp);
@@ -792,7 +815,7 @@ function mountScrollspy(nav, o = {}) {
792
815
  };
793
816
  return Object.assign(stop, { lock });
794
817
  }
795
- function mountChecklist(list) {
818
+ function mountChecklist(list, opts = {}) {
796
819
  if (typeof document === "undefined") return () => void 0;
797
820
  const key = list.dataset.store || null;
798
821
  const boxes = () => Array.from(list.querySelectorAll('li[data-id] input[type="checkbox"]'));
@@ -816,7 +839,7 @@ function mountChecklist(list) {
816
839
  const all = boxes();
817
840
  const done = all.filter((b) => b.checked).length;
818
841
  if (progress) {
819
- progress.textContent = `${done} of ${all.length}`;
842
+ progress.textContent = opts.format ? opts.format(done, all.length) : `${done} of ${all.length}`;
820
843
  progress.style.setProperty("--p", `${all.length ? done / all.length * 100 : 0}%`);
821
844
  }
822
845
  };
@@ -1,6 +1,6 @@
1
1
  // The one source of truth for every design token. scripts/build.mjs turns this into
2
2
  // dist/tokens.css (--nish-* custom properties), tools/contrast.mjs checks it, and
3
- // src/theme.ts reads PRESETS from it. Edit values here, never in generated CSS.
3
+ // src/theme.ts builds PRESETS from THEMES. Edit values here, never in generated CSS.
4
4
  //
5
5
  // Colors are plain hex so static pages can use them as-is; Tailwind opacity
6
6
  // modifiers (bg-th-surface/50) work through color-mix in Tailwind 4.
package/dist/format.d.ts CHANGED
@@ -22,8 +22,10 @@ interface MoneyOptions extends LocaleOptions {
22
22
  }
23
23
  /** Money: 1234.56 → "$1,234.56"; negatives use a true minus sign. The symbol always comes first. */
24
24
  declare function money(v: number | null | undefined, o?: MoneyOptions): string;
25
- /** Signed money: "+$12.30", "−$4.00", and "No change" when |v| < 0.005. */
26
- declare function signedMoney(v: number | null | undefined, o?: MoneyOptions): string;
25
+ /** Signed money: "+$12.30", "−$4.00", and "No change" when |v| < 0.005. Pass `zero` for another language. */
26
+ declare function signedMoney(v: number | null | undefined, o?: MoneyOptions & {
27
+ zero?: string;
28
+ }): string;
27
29
  interface PctOptions extends LocaleOptions {
28
30
  /** Fraction digits. Default 1. */
29
31
  digits?: number;
@@ -35,7 +37,7 @@ interface PctOptions extends LocaleOptions {
35
37
  /** Percent: 0.123 → "12.3%". */
36
38
  declare function pct(v: number | null | undefined, o?: PctOptions): string;
37
39
  interface NumOptions extends LocaleOptions {
38
- /** Fixed fraction digits. Default: up to 2, trailing zeros trimmed (1 when compact). */
40
+ /** Fixed fraction digits. Default: up to 2, trailing zeros trimmed (1 when compact). With `compact`, digits is a maximum: 12000 gives "12k", not "12.00k". */
39
41
  digits?: number;
40
42
  /** Short form: 12.3k, 4.5M. */
41
43
  compact?: boolean;
package/dist/format.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/runtime.ts
2
- var version = true ? "3.2.0" : "dev";
2
+ var version = true ? "3.3.0" : "dev";
3
3
  var KEY = /* @__PURE__ */ Symbol.for("nish-ui.runtime.v1");
4
4
  function runtime() {
5
5
  const g = globalThis;
@@ -167,7 +167,7 @@ function money(v, o = {}) {
167
167
  }
168
168
  function signedMoney(v, o = {}) {
169
169
  if (!finite(v)) return DASH;
170
- if (Math.abs(v) < 5e-3) return "No change";
170
+ if (Math.abs(v) < 5e-3) return o.zero ?? "No change";
171
171
  return (v < 0 ? MINUS : "+") + moneyAbs(Math.abs(v), o, loc(o));
172
172
  }
173
173
  function pct(v, o = {}) {
@@ -205,7 +205,8 @@ function bytes(v, o = {}) {
205
205
  i++;
206
206
  }
207
207
  const text = i === 0 || abs >= 100 ? fixed(abs, 0, 0, locale) : fixed(abs, 0, 1, locale);
208
- return (v < 0 ? MINUS : "") + text + " " + BYTE_UNITS[i];
208
+ const zero = Number(text.replace(/[^0-9]/g, "")) === 0;
209
+ return (v < 0 && !zero ? MINUS : "") + text + " " + BYTE_UNITS[i];
209
210
  }
210
211
  var DURATION_PARTS = [
211
212
  [86400, "d", "day"],
@@ -57,7 +57,7 @@ interface InboxEventInput {
57
57
  kind: string;
58
58
  /** Headline, trimmed, 1-140 characters. Longer text is cut to 139 plus an ellipsis. */
59
59
  title: string;
60
- /** Details, trimmed, up to 2000 characters. Longer text is cut to 1999 plus an ellipsis; an empty string becomes undefined. */
60
+ /** Details, trimmed, up to 2000 characters. Longer text is cut to 1999 plus an ellipsis; an empty string becomes null. */
61
61
  body?: string;
62
62
  /** Link opened when the notification or item is tapped. http: or https:, up to 2000 characters. */
63
63
  url?: string;
@@ -254,6 +254,10 @@ function createInboxClient(options) {
254
254
  }
255
255
  if (queue[0] === head) queue.shift();
256
256
  if (result.kind === "ok") sentSinceDown++;
257
+ else if (!loggedInvalid.has(result.error)) {
258
+ loggedInvalid.add(result.error);
259
+ log(`queued event dropped: ${result.error}`);
260
+ }
257
261
  }
258
262
  retryStep = 0;
259
263
  if (down) {