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
@@ -22,6 +22,7 @@ import {
22
22
  monthGrid,
23
23
  monthNames,
24
24
  monthOf,
25
+ msUntilNextMidnight,
25
26
  monthTitle,
26
27
  parseIso,
27
28
  parseMonth,
@@ -37,7 +38,25 @@ import { useNishContext, useStrings } from "./provider.js";
37
38
  import { PICKER_STRINGS } from "./strings.js";
38
39
  import { jsx, jsxs } from "react/jsx-runtime";
39
40
  var warned = /* @__PURE__ */ new Set();
40
- var noopSubscribe = () => () => {
41
+ var subscribeToday = (onChange) => {
42
+ if (typeof window === "undefined") return () => {
43
+ };
44
+ let timer;
45
+ const schedule = () => {
46
+ timer = setTimeout(() => {
47
+ onChange();
48
+ schedule();
49
+ }, msUntilNextMidnight(/* @__PURE__ */ new Date()) + 1e3);
50
+ };
51
+ const onVisible = () => {
52
+ if (document.visibilityState === "visible") onChange();
53
+ };
54
+ schedule();
55
+ document.addEventListener("visibilitychange", onVisible);
56
+ return () => {
57
+ clearTimeout(timer);
58
+ document.removeEventListener("visibilitychange", onVisible);
59
+ };
41
60
  };
42
61
  var EMPTY_GRID = Array.from({ length: 6 }, () => Array.from({ length: 7 }, () => null));
43
62
  var pad2 = (n) => String(n).padStart(2, "0");
@@ -96,15 +115,15 @@ function CalendarBase({
96
115
  const [ownMonth, setOwnMonth] = useState(() => defaultMonthIso ?? initialMonth);
97
116
  const [focusedDate, setFocusedDate] = useState(null);
98
117
  const today = useSyncExternalStore(
99
- noopSubscribe,
118
+ subscribeToday,
100
119
  () => isoToday(),
101
120
  () => null
102
121
  );
103
122
  const shown = monthControlled ?? ownMonth ?? (today ? monthOf(today) : null);
104
123
  const setMonth = (raw) => {
105
- const next = clampIso(raw, "0001-01", "9999-12");
124
+ const next = clampIso(raw, min ? monthOf(min) : "0001-01", max ? monthOf(max) : "9999-12");
106
125
  if (next === shown) return;
107
- if (monthProp === void 0) setOwnMonth(next);
126
+ if (monthControlled === null) setOwnMonth(next);
108
127
  onMonthChange?.(next);
109
128
  };
110
129
  const disabled = (iso) => !inRange(iso, min, max) || isDateDisabled?.(iso) === true;
@@ -191,7 +210,15 @@ function CalendarBase({
191
210
  value: shownMonthNo ?? "",
192
211
  disabled: !shown,
193
212
  onChange: (e) => shownYear !== null && setMonth(`${pad4(shownYear)}-${pad2(Number(e.target.value))}`),
194
- children: monthNames(loc).map((name, i) => /* @__PURE__ */ jsx("option", { value: i + 1, children: name }, i))
213
+ children: monthNames(loc).map((name, i) => /* @__PURE__ */ jsx(
214
+ "option",
215
+ {
216
+ value: i + 1,
217
+ disabled: shownYear !== null && (min !== null && `${pad4(shownYear)}-${pad2(i + 1)}` < monthOf(min) || max !== null && `${pad4(shownYear)}-${pad2(i + 1)}` > monthOf(max)),
218
+ children: name
219
+ },
220
+ i
221
+ ))
195
222
  }
196
223
  ),
197
224
  /* @__PURE__ */ jsx(
@@ -202,7 +229,7 @@ function CalendarBase({
202
229
  value: shownYear ?? "",
203
230
  disabled: !shown,
204
231
  onChange: (e) => shownMonthNo !== null && setMonth(`${pad4(Number(e.target.value))}-${pad2(shownMonthNo)}`),
205
- children: years.map((y) => /* @__PURE__ */ jsx("option", { value: y, children: y }, y))
232
+ children: years.map((y) => /* @__PURE__ */ jsx("option", { value: y, disabled: min !== null && y < Number(min.slice(0, 4)) || max !== null && y > Number(max.slice(0, 4)), children: y }, y))
206
233
  }
207
234
  )
208
235
  ] }),
@@ -142,6 +142,10 @@ function isoToday(now = /* @__PURE__ */ new Date()) {
142
142
  return toIso({ y: now.getFullYear(), m: now.getMonth() + 1, d: now.getDate() });
143
143
  }
144
144
  var resolved = /* @__PURE__ */ new Map();
145
+ function msUntilNextMidnight(now) {
146
+ const next = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1, 0, 0, 0, 0);
147
+ return next.getTime() - now.getTime();
148
+ }
145
149
  function resolveLocale(locale) {
146
150
  if (!locale) return "en-US";
147
151
  const hit = resolved.get(locale);
@@ -216,6 +220,12 @@ function formatDateField(iso, locale) {
216
220
  var FIELD_JUNK_RE = /[^\d\s/.,-]/;
217
221
  var ISO_FIELD_RE = /^\d{4}-\d{2}-\d{2}$/;
218
222
  var DIGITS_RE = /\d+/g;
223
+ function expandTwoDigitYear(yy, thisYear = (/* @__PURE__ */ new Date()).getFullYear()) {
224
+ let y = Math.floor(thisYear / 100) * 100 + yy;
225
+ if (y > thisYear + 19) y -= 100;
226
+ else if (y < thisYear - 80) y += 100;
227
+ return y;
228
+ }
219
229
  function parseDateField(text, locale) {
220
230
  const t = text.replace(BIDI_MARKS_RE, "").trim();
221
231
  if (t === "") return null;
@@ -249,7 +259,7 @@ function parseDateField(text, locale) {
249
259
  });
250
260
  let y = Number(found.year);
251
261
  if (found.year.length === 3 || found.year.length > 4) return null;
252
- if (found.year.length <= 2) y = 2e3 + y;
262
+ if (found.year.length <= 2) y = expandTwoDigitYear(y);
253
263
  const m = Number(found.month);
254
264
  const d = Number(found.day);
255
265
  if (y < 1 || m < 1 || m > 12 || d < 1 || d > daysInMonth(y, m)) return null;
@@ -351,7 +361,7 @@ function calendarDayClass({ filled, today, disabled, band = null }) {
351
361
  return cn(
352
362
  DAY_BASE,
353
363
  !filled && !band && !disabled && "hover:bg-th-elevated hover:text-th-hi",
354
- today && !filled && "font-semibold text-th-accent ring-1 ring-inset ring-th-accent/50",
364
+ today && !filled && "font-semibold text-th-accent ring-1 ring-inset ring-th-accent/50 forced-colors:outline forced-colors:outline-1 forced-colors:-outline-offset-1 forced-colors:outline-[CanvasText]",
355
365
  band && today && !filled && "ring-th-accent",
356
366
  band === "start" && "rounded-e-none",
357
367
  band === "end" && "rounded-s-none",
@@ -374,6 +384,7 @@ export {
374
384
  dayNumber,
375
385
  daysInMonth,
376
386
  endOfWeek,
387
+ expandTwoDigitYear,
377
388
  firstDisabledIn,
378
389
  firstOfMonth,
379
390
  formatDateField,
@@ -385,6 +396,7 @@ export {
385
396
  monthNames,
386
397
  monthOf,
387
398
  monthTitle,
399
+ msUntilNextMidnight,
388
400
  orderRange,
389
401
  parseDateField,
390
402
  parseIso,
@@ -1,31 +1,41 @@
1
1
  "use client";
2
2
 
3
3
  // src/components/canvas/follow-caption.tsx
4
- import { memo } from "react";
4
+ import { memo, useEffect, useRef, useState } from "react";
5
5
  import { StatusDot } from "../display.js";
6
6
  import { TickerText } from "../flow.js";
7
7
  import { DEFAULT_CANVAS_LABELS } from "./types.js";
8
- import { jsx, jsxs } from "react/jsx-runtime";
8
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
9
  var FollowCaption = memo(function FollowCaption2({ step, labels = DEFAULT_CANVAS_LABELS }) {
10
- if (!step) return null;
11
- const only = step.targets.length === 1 ? step.targets[0] : null;
12
- const text = step.mode === "idle" ? labels.followIdle : only ? labels.followOne(only.group, only.label) : labels.followMany(step.targets.length);
13
- return /* @__PURE__ */ jsxs(
14
- "div",
15
- {
16
- "data-canvas-ui": true,
17
- role: "status",
18
- "aria-live": "polite",
19
- className: "absolute bottom-[68px] start-3 z-10 flex max-w-[min(420px,calc(100%-24px))] items-center gap-2 rounded-xl border border-th-line bg-th-surface px-3 py-2 text-xs text-th-hi shadow-card min-[600px]:bottom-3",
20
- children: [
21
- /* @__PURE__ */ jsx(StatusDot, { tone: "accent", pulse: step.mode !== "idle" }),
22
- /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
23
- /* @__PURE__ */ jsx("div", { className: "truncate", children: text }),
24
- only?.note ? /* @__PURE__ */ jsx(TickerText, { as: "div", text: only.note, className: "truncate text-th-hi3" }) : null
25
- ] })
26
- ]
27
- }
28
- );
10
+ const only = step && step.targets.length === 1 ? step.targets[0] : null;
11
+ const text = !step ? null : step.mode === "idle" ? labels.followIdle : only ? labels.followOne(only.group, only.label) : labels.followMany(step.targets.length);
12
+ const textRef = useRef(text);
13
+ const [spoken, setSpoken] = useState("");
14
+ const mode = step?.mode;
15
+ useEffect(() => {
16
+ textRef.current = text;
17
+ });
18
+ useEffect(() => {
19
+ setSpoken(mode ? textRef.current ?? "" : "");
20
+ }, [mode]);
21
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
22
+ /* @__PURE__ */ jsx("div", { role: "status", "aria-live": "polite", className: "sr-only", children: spoken }),
23
+ step ? /* @__PURE__ */ jsxs(
24
+ "div",
25
+ {
26
+ "data-canvas-ui": true,
27
+ "data-follow-caption": true,
28
+ className: "absolute bottom-[68px] start-3 z-10 flex max-w-[min(420px,calc(100%-24px))] items-center gap-2 rounded-xl border border-th-line bg-th-surface px-3 py-2 text-xs text-th-hi shadow-card min-[600px]:bottom-3",
29
+ children: [
30
+ /* @__PURE__ */ jsx(StatusDot, { tone: "accent", pulse: step.mode !== "idle" }),
31
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
32
+ /* @__PURE__ */ jsx("div", { className: "truncate", children: text }),
33
+ only?.note ? /* @__PURE__ */ jsx(TickerText, { as: "div", text: only.note, className: "truncate text-th-hi3" }) : null
34
+ ] })
35
+ ]
36
+ }
37
+ ) : null
38
+ ] });
29
39
  });
30
40
  export {
31
41
  FollowCaption
@@ -2,11 +2,10 @@
2
2
 
3
3
  // src/components/canvas/follow.ts
4
4
  import { useEffect, useRef, useState } from "react";
5
- import { centerOn, clampK } from "./view.js";
5
+ import { centerOn, clampK, FIT_PAD, PHONE_K, PHONE_MAX_W } from "./view.js";
6
6
  var CYCLE_MS = 6e3;
7
7
  var BBOX_PAD = 80;
8
- var VIEW_PAD = 96;
9
- var PHONE_W = 600;
8
+ var VIEW_PAD = 2 * FIT_PAD;
10
9
  var PHONE_TOP = 0.45;
11
10
  function followTargets(groups, layout) {
12
11
  const out = [];
@@ -21,14 +20,14 @@ function followTargets(groups, layout) {
21
20
  }
22
21
  function place(w, h, k, box, groupBox, top = 0) {
23
22
  const v = centerOn(w, h, k, box);
24
- if (w >= PHONE_W) return v;
23
+ if (w >= PHONE_MAX_W) return v;
25
24
  const y = Math.max(h * PHONE_TOP / 2, top + box.h * k / 2) - (box.y + box.h / 2) * k;
26
25
  if (groupBox && groupBox.w * k <= w - 24) return { ...v, x: w / 2 - (groupBox.x + groupBox.w / 2) * k, y };
27
26
  return { ...v, y };
28
27
  }
29
28
  function followStep(targets, i, w, h, fit, top = 0) {
30
29
  if (targets.length === 0) return { mode: "idle", view: fit, targets: [] };
31
- const phone = w < PHONE_W;
30
+ const phone = w < PHONE_MAX_W;
32
31
  const single = phone ? 0.8 : 1;
33
32
  if (targets.length === 1) {
34
33
  return { mode: "all", targets, view: place(w, h, single, targets[0].box, targets[0].groupBox, top) };
@@ -45,7 +44,7 @@ function followStep(targets, i, w, h, fit, top = 0) {
45
44
  }
46
45
  const bbox = { x: x0 - BBOX_PAD, y: y0 - BBOX_PAD, w: x1 - x0 + 2 * BBOX_PAD, h: y1 - y0 + 2 * BBOX_PAD };
47
46
  const kAll = Math.min((w - VIEW_PAD) / bbox.w, (h - VIEW_PAD) / bbox.h, 1.1);
48
- if (kAll >= (phone ? 0.55 : 0.75)) {
47
+ if (kAll >= (phone ? PHONE_K : 0.75)) {
49
48
  return { mode: "all", targets, view: place(w, h, clampK(kAll), bbox, void 0, top) };
50
49
  }
51
50
  const target = targets[(i % targets.length + targets.length) % targets.length];
@@ -2,11 +2,11 @@
2
2
 
3
3
  // src/components/canvas/minimap.tsx
4
4
  import { memo, useCallback, useEffect, useImperativeHandle, useRef } from "react";
5
+ import { PHONE_MAX_W } from "./view.js";
5
6
  import { jsx, jsxs } from "react/jsx-runtime";
6
7
  var MAP_W = 176;
7
8
  var MAP_MAX_H = 132;
8
9
  var MAP_MIN_H = 60;
9
- var MIN_CANVAS_W = 600;
10
10
  var hueVar = (hue, soft) => hue ? `var(--nish-${hue}${soft ? "-soft" : ""})` : soft ? "var(--nish-accent-soft)" : "var(--nish-accent)";
11
11
  var Minimap = memo(function Minimap2({
12
12
  layout,
@@ -30,7 +30,7 @@ var Minimap = memo(function Minimap2({
30
30
  const rect = rectRef.current;
31
31
  if (!cur || !wrap || !rect) return;
32
32
  const { v, size } = cur;
33
- wrap.style.display = size.w < MIN_CANVAS_W ? "none" : "";
33
+ wrap.style.display = size.w < PHONE_MAX_W ? "none" : "";
34
34
  const x0 = Math.max(0, ox + -v.x / v.k * s);
35
35
  const y0 = Math.max(0, oy + (-v.y / v.k + layout.titleRoom) * s);
36
36
  const x1 = Math.min(MAP_W, ox + (-v.x + size.w) / v.k * s);
@@ -68,7 +68,7 @@ var Minimap = memo(function Minimap2({
68
68
  ref: wrapRef,
69
69
  "data-canvas-ui": true,
70
70
  "aria-hidden": "true",
71
- className: "nish-canvas-minimap absolute right-3 top-3 z-[5] overflow-hidden rounded-xl border border-th-line bg-th-surface shadow-pop",
71
+ className: "nish-canvas-minimap absolute end-3 top-3 z-[5] overflow-hidden rounded-xl border border-th-line bg-th-surface shadow-pop",
72
72
  style: { display: "none" },
73
73
  children: /* @__PURE__ */ jsxs(
74
74
  "svg",
@@ -502,6 +502,8 @@ function SystemCanvas({
502
502
  g.mode = "pan";
503
503
  g.lastX = rest2.x;
504
504
  g.lastY = rest2.y;
505
+ } else if (pointers.current.size >= 2 && g.mode === "pinch") {
506
+ startPinch();
505
507
  } else if (pointers.current.size === 0) {
506
508
  if (g.mode === "pending" && e.pointerType === "touch" && e.type === "pointerup") {
507
509
  const p = local(e);
@@ -731,7 +733,7 @@ function SystemCanvas({
731
733
  ref: setViewportRef,
732
734
  role: "application",
733
735
  "aria-label": label,
734
- "aria-roledescription": "canvas",
736
+ "aria-roledescription": strings.canvasRole,
735
737
  tabIndex: 0,
736
738
  className: cn("nish-canvas", className),
737
739
  style: { height, ...style },
@@ -4,7 +4,6 @@ var MAX_K = 2;
4
4
  var PHONE_K = 0.55;
5
5
  var PHONE_MAX_W = 600;
6
6
  var FIT_PAD = 48;
7
- var TITLE_ROOM = 36;
8
7
  var LABEL_K = 0.8;
9
8
  var ANIM_MS = 300;
10
9
  var FOLLOW_MS = 700;
@@ -38,7 +37,6 @@ export {
38
37
  MIN_K,
39
38
  PHONE_K,
40
39
  PHONE_MAX_W,
41
- TITLE_ROOM,
42
40
  ZOOM_STEP,
43
41
  centerOn,
44
42
  clampK,
@@ -3,6 +3,7 @@
3
3
  // src/components/carousel.tsx
4
4
  import {
5
5
  Children,
6
+ isValidElement,
6
7
  useCallback,
7
8
  useEffect,
8
9
  useRef,
@@ -256,8 +257,6 @@ function Carousel({
256
257
  {
257
258
  ref: trackRef,
258
259
  tabIndex: 0,
259
- role: "group",
260
- "aria-label": ariaLabel,
261
260
  onKeyDown: onTrackKey,
262
261
  onScroll,
263
262
  className: "flex w-full min-w-0 snap-x snap-mandatory gap-3 overflow-x-auto overscroll-x-contain rounded-lg [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
@@ -274,7 +273,7 @@ function Carousel({
274
273
  style: { width: slideWidth },
275
274
  children: child
276
275
  },
277
- i
276
+ isValidElement(child) && child.key != null ? child.key : i
278
277
  ))
279
278
  }
280
279
  )
@@ -85,10 +85,12 @@ function LineChart({
85
85
  const yFmt = yFormat ?? ((v) => chartNumber(v, loc));
86
86
  const xFmt = xFormat ?? ((v) => chartNumber(v, loc));
87
87
  const [wrapRef, width, wrapEl] = useWidth();
88
+ const rootRef = useMemo(() => mergeRefs(wrapRef, ref), [wrapRef, ref]);
88
89
  const rtl = useChartRtl(wrapEl);
89
90
  const gradId = `nish-area-${useId().replace(/[^a-zA-Z0-9]/g, "")}`;
90
91
  const [active, setActive] = useState(null);
91
92
  const fromKey = useRef(false);
93
+ const [viaKey, setViaKey] = useState(false);
92
94
  const lines = useMemo(() => series ?? (data ? [{ label, tone, points: data }] : []), [series, data, label, tone]);
93
95
  const xs = useMemo(() => {
94
96
  const set = /* @__PURE__ */ new Set();
@@ -197,12 +199,14 @@ function LineChart({
197
199
  };
198
200
  const onPointer = (e) => {
199
201
  fromKey.current = false;
202
+ setViaKey(false);
200
203
  moveTo(e.clientX, e.currentTarget);
201
204
  };
202
205
  const onKey = (e) => {
203
206
  if (e.key === "ArrowLeft" || e.key === "ArrowRight") {
204
207
  e.preventDefault();
205
208
  fromKey.current = true;
209
+ setViaKey(true);
206
210
  const dir = (e.key === "ArrowRight" ? 1 : -1) * (rtl ? -1 : 1);
207
211
  setActive((a) => a == null ? dir > 0 ? 0 : xs.length - 1 : Math.min(xs.length - 1, Math.max(0, a + dir)));
208
212
  } else if (e.key === "Escape") setActive(null);
@@ -212,7 +216,8 @@ function LineChart({
212
216
  const tipRows = ax != null ? lines.map((s, i) => ({ s, i, y: lookup[i].get(ax) })).filter((r) => r.y != null) : [];
213
217
  const tipRight = cx < width / 2;
214
218
  const tableXs = xs.slice(0, 200);
215
- return /* @__PURE__ */ jsxs("div", { ...rest, ref: mergeRefs(wrapRef, ref), className: cn("relative w-full select-none", className), style: { height, ...rest.style }, children: [
219
+ const announce = ax != null && viaKey ? `${xFmt(ax)}: ${tipRows.map((r) => lines.length > 1 ? `${r.s.label} ${yFmt(r.y)}` : yFmt(r.y)).join(", ")}` : "";
220
+ return /* @__PURE__ */ jsxs("div", { ...rest, ref: rootRef, className: cn("relative w-full select-none", className), style: { height, ...rest.style }, children: [
216
221
  width > 0 && /* @__PURE__ */ jsxs(
217
222
  "svg",
218
223
  {
@@ -301,16 +306,20 @@ function LineChart({
301
306
  ]
302
307
  }
303
308
  ),
309
+ /* @__PURE__ */ jsx("div", { className: "sr-only", "aria-live": "polite", children: announce }),
304
310
  /* @__PURE__ */ jsxs("table", { className: "sr-only", children: [
305
311
  /* @__PURE__ */ jsx("caption", { children: label }),
306
312
  /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
307
313
  /* @__PURE__ */ jsx("th", { scope: "col", children: "x" }),
308
314
  lines.map((s, i) => /* @__PURE__ */ jsx("th", { scope: "col", children: s.label }, i))
309
315
  ] }) }),
310
- /* @__PURE__ */ jsx("tbody", { children: tableXs.map((x) => /* @__PURE__ */ jsxs("tr", { children: [
311
- /* @__PURE__ */ jsx("th", { scope: "row", children: xFmt(x) }),
312
- lines.map((_, i) => /* @__PURE__ */ jsx("td", { children: lookup[i].has(x) ? yFmt(lookup[i].get(x)) : "" }, i))
313
- ] }, x)) })
316
+ /* @__PURE__ */ jsxs("tbody", { children: [
317
+ tableXs.map((x) => /* @__PURE__ */ jsxs("tr", { children: [
318
+ /* @__PURE__ */ jsx("th", { scope: "row", children: xFmt(x) }),
319
+ lines.map((_, i) => /* @__PURE__ */ jsx("td", { children: lookup[i].has(x) ? yFmt(lookup[i].get(x)) : "" }, i))
320
+ ] }, x)),
321
+ xs.length > tableXs.length && /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("th", { scope: "row", colSpan: lines.length + 1, children: t.chartTruncated(tableXs.length, xs.length) }) })
322
+ ] })
314
323
  ] })
315
324
  ] });
316
325
  }
@@ -335,6 +344,7 @@ function BarChart({
335
344
  const loc = locale ?? config.locale ?? "en-US";
336
345
  const fmt = valueFormat ?? ((v) => chartNumber(v, loc));
337
346
  const [wrapRef, width, wrapEl] = useWidth();
347
+ const rootRef = useMemo(() => mergeRefs(wrapRef, ref), [wrapRef, ref]);
338
348
  const rtl = useChartRtl(wrapEl);
339
349
  const coarse = useMediaQuery("(pointer: coarse)");
340
350
  const [pickedBar, setSelected] = useState(null);
@@ -380,7 +390,7 @@ function BarChart({
380
390
  setSelected(() => selected == null ? dir > 0 ? 0 : data.length - 1 : Math.min(data.length - 1, Math.max(0, selected + dir)));
381
391
  } else if (e.key === "Escape") setSelected(null);
382
392
  };
383
- return /* @__PURE__ */ jsxs("div", { ...rest, ref: mergeRefs(wrapRef, ref), className: cn("w-full", className), children: [
393
+ return /* @__PURE__ */ jsxs("div", { ...rest, ref: rootRef, className: cn("w-full", className), children: [
384
394
  width > 0 && /* @__PURE__ */ jsxs(
385
395
  "svg",
386
396
  {
@@ -434,6 +444,7 @@ function BarChart({
434
444
  ] });
435
445
  }
436
446
  function RangeBar({ min, max, low, high, current, label, locale, className, ref, ...rest }) {
447
+ const t = useStrings(DISPLAY_STRINGS);
437
448
  const config = useNishContext();
438
449
  const loc = locale ?? config.locale ?? "en-US";
439
450
  const num = (v) => chartNumber(v, loc);
@@ -447,7 +458,7 @@ function RangeBar({ min, max, low, high, current, label, locale, className, ref,
447
458
  ...rest,
448
459
  ref,
449
460
  role: "img",
450
- "aria-label": label ?? `Range ${num(low)} to ${num(high)}${current != null ? `, current ${num(current)}` : ""}, within ${num(min)} to ${num(max)}`,
461
+ "aria-label": label ?? t.rangeLabel(num(low), num(high), current != null ? num(current) : null, num(min), num(max)),
451
462
  className: cn("relative h-1.5 w-full rounded-full bg-th-line forced-colors:bg-[color:GrayText]", className),
452
463
  children: [
453
464
  /* @__PURE__ */ jsx(
@@ -9,11 +9,10 @@ import { fieldClass } from "./primitives.js";
9
9
  import { useStrings } from "./provider.js";
10
10
  import { FIELD_STRINGS } from "./strings.js";
11
11
  import { indexComboboxOptions, setRef } from "./forms-classes.js";
12
- import { COMBOBOX_DEBOUNCE_MS, COMBOBOX_MAX_SHOWN } from "../combobox-filter.js";
12
+ import { COMBOBOX_DEBOUNCE_MS, COMBOBOX_MAX_SHOWN, matchesComboboxNeedle } from "../combobox-filter.js";
13
13
  import { jsx, jsxs } from "react/jsx-runtime";
14
14
  var MAX_SHOWN = COMBOBOX_MAX_SHOWN;
15
15
  var DEBOUNCE_MS = COMBOBOX_DEBOUNCE_MS;
16
- var defaultResultsText = (n) => `${n} ${n === 1 ? "result" : "results"}`;
17
16
  function Combobox({
18
17
  ref,
19
18
  options,
@@ -40,7 +39,7 @@ function Combobox({
40
39
  size = "md",
41
40
  clearLabel,
42
41
  loadingText,
43
- resultsText = defaultResultsText,
42
+ resultsText,
44
43
  className,
45
44
  ...rest
46
45
  }) {
@@ -76,7 +75,7 @@ function Combobox({
76
75
  if (dirty && !serverFiltered) {
77
76
  if (filter) {
78
77
  if (!filter(it.option, text)) continue;
79
- } else if (needle && !it.label.includes(needle) && !(it.hint?.includes(needle) ?? false)) continue;
78
+ } else if (!matchesComboboxNeedle(it.label, it.hint, needle)) continue;
80
79
  }
81
80
  out.push(it.option);
82
81
  }
@@ -99,10 +98,22 @@ function Combobox({
99
98
  useEffect(() => {
100
99
  if (open) listRef.current?.scrollIntoView?.({ block: "nearest" });
101
100
  }, [open]);
102
- const reset = useCallback(() => {
101
+ const reset = () => {
102
+ if (dirty && onQueryChange) {
103
+ window.clearTimeout(debounceRef.current);
104
+ onQueryChange("");
105
+ }
103
106
  setDirty(false);
104
107
  setText("");
105
- }, []);
108
+ };
109
+ const [fieldLabel, setFieldLabel] = useState({});
110
+ useEffect(() => {
111
+ if (!open || ariaLabel || ariaLabelledBy) return;
112
+ const doc = inputRef.current?.ownerDocument;
113
+ const el = doc ? Array.from(doc.getElementsByTagName("label")).find((l) => l.htmlFor === inputId) : void 0;
114
+ const next = el ? el.id ? { id: el.id } : { text: el.textContent?.trim() || void 0 } : {};
115
+ setFieldLabel((prev) => prev.id === next.id && prev.text === next.text ? prev : next);
116
+ }, [open, ariaLabel, ariaLabelledBy, inputId]);
106
117
  const close = useCallback(() => {
107
118
  setOpen(false);
108
119
  setActive(-1);
@@ -284,15 +295,15 @@ function Combobox({
284
295
  children: /* @__PURE__ */ jsx("span", { className: "flex size-8 items-center justify-center rounded-md hover:bg-th-elevated", children: /* @__PURE__ */ jsx(XIcon, { size: 16 }) })
285
296
  }
286
297
  ) : null,
287
- /* @__PURE__ */ jsx("div", { role: "status", "aria-live": "polite", className: "sr-only", children: open ? loading ? searching : visible.length === 0 ? empty : resultsText(visible.length) : "" }),
298
+ /* @__PURE__ */ jsx("div", { role: "status", "aria-live": "polite", className: "sr-only", children: open ? loading ? searching : visible.length === 0 ? empty : (resultsText ?? strings.resultsCount)(visible.length) : "" }),
288
299
  open ? /* @__PURE__ */ jsxs(
289
300
  "ul",
290
301
  {
291
302
  ref: listRef,
292
303
  id: listId,
293
304
  role: "listbox",
294
- "aria-label": ariaLabel,
295
- "aria-labelledby": ariaLabel ? void 0 : ariaLabelledBy ?? inputId,
305
+ "aria-label": ariaLabel ?? (ariaLabelledBy ? void 0 : fieldLabel.text),
306
+ "aria-labelledby": ariaLabel ? void 0 : ariaLabelledBy ?? fieldLabel.id,
296
307
  className: "absolute inset-x-0 top-full z-[var(--nish-z-dropdown,40)] mt-1 max-h-[min(16rem,40dvh)] overflow-auto rounded-xl border border-th-line bg-th-elevated shadow-pop",
297
308
  children: [
298
309
  visible.map((o, i) => {