nish-ui 2.2.0 → 3.1.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 (99) hide show
  1. package/README.md +10 -6
  2. package/dist/chart.d.ts +8 -3
  3. package/dist/chart.js +2 -417
  4. package/dist/elements-all.js +81 -80
  5. package/dist/elements-charts.d.ts +7 -1
  6. package/dist/elements-charts.js +16 -16
  7. package/dist/elements-data.d.ts +7 -1
  8. package/dist/elements-data.js +5 -5
  9. package/dist/elements-forms.d.ts +7 -1
  10. package/dist/elements-forms.js +18 -17
  11. package/dist/elements.d.ts +7 -1
  12. package/dist/elements.js +4 -4
  13. package/dist/esm/components/accordion.js +3 -2
  14. package/dist/esm/components/app-shell.js +3 -2
  15. package/dist/esm/components/avatar.js +6 -5
  16. package/dist/esm/components/breadcrumbs.js +3 -2
  17. package/dist/esm/components/calendar-base.js +4 -3
  18. package/dist/esm/components/canvas/legend.js +7 -6
  19. package/dist/esm/components/canvas/node.js +3 -2
  20. package/dist/esm/components/canvas/system-canvas.js +27 -3
  21. package/dist/esm/components/carousel.js +24 -5
  22. package/dist/esm/components/charts.js +29 -20
  23. package/dist/esm/components/combobox.js +4 -3
  24. package/dist/esm/components/command.js +4 -3
  25. package/dist/esm/components/context-menu.js +3 -2
  26. package/dist/esm/components/data-classes.js +5 -4
  27. package/dist/esm/components/data.js +5 -8
  28. package/dist/esm/components/date-picker.js +5 -3
  29. package/dist/esm/components/date-range-picker.js +5 -3
  30. package/dist/esm/components/display.js +10 -9
  31. package/dist/esm/components/drawer.js +3 -2
  32. package/dist/esm/components/error-boundary.js +4 -2
  33. package/dist/esm/components/feedback.js +7 -6
  34. package/dist/esm/components/file-dropzone.js +24 -3
  35. package/dist/esm/components/filters.js +7 -4
  36. package/dist/esm/components/flow.js +17 -15
  37. package/dist/esm/components/forms.js +37 -10
  38. package/dist/esm/components/hooks.js +22 -19
  39. package/dist/esm/components/hover-card.js +2 -2
  40. package/dist/esm/components/inbox.js +12 -8
  41. package/dist/esm/components/layout-vars.js +10 -7
  42. package/dist/esm/components/layout.js +5 -4
  43. package/dist/esm/components/media.js +3 -2
  44. package/dist/esm/components/menu.js +12 -8
  45. package/dist/esm/components/modal.js +4 -3
  46. package/dist/esm/components/more-sheet.js +3 -2
  47. package/dist/esm/components/multi-select.js +10 -6
  48. package/dist/esm/components/nav-items.js +4 -3
  49. package/dist/esm/components/nav.js +5 -4
  50. package/dist/esm/components/overlay-core.js +31 -10
  51. package/dist/esm/components/overlay-dialog.js +20 -4
  52. package/dist/esm/components/pagination.js +7 -3
  53. package/dist/esm/components/popover.js +17 -11
  54. package/dist/esm/components/portal.js +2 -2
  55. package/dist/esm/components/primitives.js +1 -1
  56. package/dist/esm/components/progress.js +5 -2
  57. package/dist/esm/components/provider.js +34 -5
  58. package/dist/esm/components/range-calendar.js +4 -3
  59. package/dist/esm/components/resource-classes.js +34 -16
  60. package/dist/esm/components/resource.js +5 -4
  61. package/dist/esm/components/service-tokens.js +4 -3
  62. package/dist/esm/components/settings.js +8 -5
  63. package/dist/esm/components/slider.js +4 -2
  64. package/dist/esm/components/split.js +4 -3
  65. package/dist/esm/components/strings.js +182 -65
  66. package/dist/esm/components/tag-input.js +18 -9
  67. package/dist/esm/components/theme-toggle.js +3 -2
  68. package/dist/esm/components/time-field-classes.js +5 -2
  69. package/dist/esm/components/time-field.js +19 -10
  70. package/dist/esm/components/toast-card.js +155 -0
  71. package/dist/esm/components/toast-store.js +136 -0
  72. package/dist/esm/components/toast.js +38 -241
  73. package/dist/esm/components/tooltip.js +3 -3
  74. package/dist/esm/components/url-state.js +1 -0
  75. package/dist/esm/components/virtual-table.js +11 -4
  76. package/dist/esm/components/virtual.js +16 -2
  77. package/dist/esm/format.js +17 -14
  78. package/dist/esm/index.js +0 -20
  79. package/dist/esm/runtime.js +1 -1
  80. package/dist/esm/server/inbox/client.js +1 -1
  81. package/dist/esm/system-canvas.js +4 -0
  82. package/dist/esm/theme.js +73 -13
  83. package/dist/format.js +18 -15
  84. package/dist/inbox-client.js +1 -1
  85. package/dist/index.d.ts +43 -21
  86. package/dist/nish-components.css +41 -1
  87. package/dist/nish-components.min.css +1 -1
  88. package/dist/node/th-check.js +12 -3
  89. package/dist/server/hono.d.ts +1 -1
  90. package/dist/server/hono.js +20 -1
  91. package/dist/server/index.d.ts +2 -2
  92. package/dist/server/index.js +19 -5
  93. package/dist/{spa-BLlMc0eI.d.ts → spa-7myD4xvA.d.ts} +3 -2
  94. package/dist/system-canvas.d.ts +179 -2
  95. package/dist/theme.d.ts +23 -5
  96. package/dist/theme.global.js +87 -151
  97. package/dist/theme.js +87 -151
  98. package/package.json +1 -1
  99. package/dist/system-canvas-BLuWd69H.d.ts +0 -183
@@ -14,7 +14,8 @@ import { CAROUSEL_MAX_DOTS, CAROUSEL_MIN_INTERVAL, nearestSlide, stepIndex } fro
14
14
  import { useMediaQuery } from "./hooks.js";
15
15
  import { ChevronLeftIcon, ChevronRightIcon, PauseIcon, PlayIcon } from "./icons.js";
16
16
  import { IconButton } from "./primitives.js";
17
- import { useNishStrings } from "./provider.js";
17
+ import { useStrings } from "./provider.js";
18
+ import { CAROUSEL_STRINGS } from "./strings.js";
18
19
  import { jsx, jsxs } from "react/jsx-runtime";
19
20
  var SETTLE_MS = 700;
20
21
  function Carousel({
@@ -38,7 +39,7 @@ function Carousel({
38
39
  onBlur,
39
40
  ...rest
40
41
  }) {
41
- const strings = useNishStrings();
42
+ const strings = useStrings(CAROUSEL_STRINGS);
42
43
  const reduced = useMediaQuery("(prefers-reduced-motion: reduce)");
43
44
  const slides = Children.toArray(children);
44
45
  const count = slides.length;
@@ -68,9 +69,10 @@ function Carousel({
68
69
  const [hovered, setHovered] = useState(false);
69
70
  const [focusedIn, setFocusedIn] = useState(false);
70
71
  const [hidden, setHidden] = useState(false);
72
+ const [offscreen, setOffscreen] = useState(false);
71
73
  const [playState, setPlayState] = useState("auto");
72
74
  const playing = playState === "on" || playState === "auto" && !reduced;
73
- const paused = hovered || focusedIn || hidden;
75
+ const paused = hovered || focusedIn || hidden || offscreen;
74
76
  const interval = Math.max(autoPlay ?? 0, CAROUSEL_MIN_INTERVAL);
75
77
  const rotating = !!autoPlay && count > 1 && playing && !paused;
76
78
  const setCurrent = useCallback((i) => {
@@ -82,8 +84,15 @@ function Carousel({
82
84
  const scrollToSlide = useCallback((i, behavior) => {
83
85
  viewRef.current = i;
84
86
  targetRef.current = { index: i, at: Date.now() };
85
- const el = trackRef.current?.children[i];
86
- el?.scrollIntoView({ behavior, block: "nearest", inline: "start" });
87
+ const track = trackRef.current;
88
+ const el = track?.children[i];
89
+ if (!track || !el) return;
90
+ const rtl = isRtl(track);
91
+ const a = el.getBoundingClientRect();
92
+ const b = track.getBoundingClientRect();
93
+ const left = rtl ? a.right - b.right : a.left - b.left;
94
+ if (typeof track.scrollBy === "function") track.scrollBy({ left, behavior });
95
+ else track.scrollLeft += left;
87
96
  }, []);
88
97
  const goTo = useCallback(
89
98
  (i) => {
@@ -163,6 +172,16 @@ function Carousel({
163
172
  document.addEventListener("visibilitychange", sync);
164
173
  return () => document.removeEventListener("visibilitychange", sync);
165
174
  }, []);
175
+ useEffect(() => {
176
+ const track = trackRef.current;
177
+ if (!track || typeof IntersectionObserver === "undefined") return;
178
+ const io = new IntersectionObserver((entries) => {
179
+ const last = entries[entries.length - 1];
180
+ if (last) setOffscreen(!last.isIntersecting);
181
+ });
182
+ io.observe(track);
183
+ return () => io.disconnect();
184
+ }, []);
166
185
  useEffect(() => {
167
186
  if (!rotating) return;
168
187
  const id = setTimeout(() => goToRef.current(index === count - 1 ? 0 : index + 1), interval);
@@ -15,7 +15,8 @@ import { isRtl } from "./client.js";
15
15
  import { chartNumber, decimateMinMax, mergeRefs } from "./data-classes.js";
16
16
  import { Skeleton } from "./feedback.js";
17
17
  import { useMediaQuery } from "./hooks.js";
18
- import { useNishConfig, useNishStrings } from "./provider.js";
18
+ import { useNishContext, useStrings } from "./provider.js";
19
+ import { DISPLAY_STRINGS } from "./strings.js";
19
20
  import { jsx, jsxs } from "react/jsx-runtime";
20
21
  function toneColor(tone, index) {
21
22
  if (!tone) return seriesColor(index);
@@ -41,7 +42,7 @@ function useWidth() {
41
42
  return [setEl, width, el];
42
43
  }
43
44
  function useChartRtl(el) {
44
- const { dir } = useNishConfig();
45
+ const { dir } = useNishContext();
45
46
  const [measured, setMeasured] = useState(false);
46
47
  useEffect(() => {
47
48
  setMeasured(isRtl(el));
@@ -78,8 +79,8 @@ function LineChart({
78
79
  ref,
79
80
  ...rest
80
81
  }) {
81
- const t = useNishStrings();
82
- const config = useNishConfig();
82
+ const t = useStrings(DISPLAY_STRINGS);
83
+ const config = useNishContext();
83
84
  const loc = locale ?? config.locale ?? "en-US";
84
85
  const yFmt = yFormat ?? ((v) => chartNumber(v, loc));
85
86
  const xFmt = xFormat ?? ((v) => chartNumber(v, loc));
@@ -149,6 +150,7 @@ function LineChart({
149
150
  const yLabels = scale ? ticksBetween(scale.yMin, scale.yMax, yTicks).map((v) => ({ v, text: yFmt(v) })) : [];
150
151
  const padLeft = Math.ceil(Math.max(0, ...yLabels.map((l) => l.text.length)) * 6.6) + 10;
151
152
  const plotW = Math.max(0, width - padLeft - PAD_RIGHT);
153
+ const plotX = rtl ? PAD_RIGHT : padLeft;
152
154
  const plotH = Math.max(0, height - PAD_TOP - PAD_BOTTOM);
153
155
  const paths = useMemo(() => {
154
156
  if (!scale) return [];
@@ -156,11 +158,11 @@ function LineChart({
156
158
  return runs.map(
157
159
  (segs) => segs.map(
158
160
  (seg) => decimateMinMax(seg, scale.xMin, scale.xMax, plotW).map(
159
- (p) => `${xPos(p.x, scale.xMin, scale.xMax, padLeft, plotW, rtl).toFixed(1)},${sy2(p.y).toFixed(1)}`
161
+ (p) => `${xPos(p.x, scale.xMin, scale.xMax, plotX, plotW, rtl).toFixed(1)},${sy2(p.y).toFixed(1)}`
160
162
  )
161
163
  )
162
164
  );
163
- }, [runs, scale, plotW, plotH, padLeft, rtl]);
165
+ }, [runs, scale, plotW, plotH, plotX, rtl]);
164
166
  if (loading) return /* @__PURE__ */ jsx(Skeleton, { className: cn("w-full rounded-xl", className), style: { height } });
165
167
  if (!scale) {
166
168
  return /* @__PURE__ */ jsx(
@@ -176,13 +178,13 @@ function LineChart({
176
178
  }
177
179
  );
178
180
  }
179
- const sx = (x) => xPos(x, scale.xMin, scale.xMax, padLeft, plotW, rtl);
181
+ const sx = (x) => xPos(x, scale.xMin, scale.xMax, plotX, plotW, rtl);
180
182
  const sy = (y) => PAD_TOP + (1 - (y - scale.yMin) / (scale.yMax - scale.yMin)) * plotH;
181
183
  const bottom = PAD_TOP + plotH;
182
184
  const xLabels = ticksBetween(scale.xMin, scale.xMax, Math.min(xTicks, Math.max(2, Math.floor(plotW / 72))));
183
185
  const moveTo = (clientX, el) => {
184
186
  const rect = el.getBoundingClientRect();
185
- const f = (clientX - rect.left - padLeft) / (plotW || 1);
187
+ const f = (clientX - rect.left - plotX) / (plotW || 1);
186
188
  const x = scale.xMin + (rtl ? 1 - f : f) * (scale.xMax - scale.xMin);
187
189
  let lo = 0;
188
190
  let hi = xs.length - 1;
@@ -219,7 +221,7 @@ function LineChart({
219
221
  role: "img",
220
222
  tabIndex: 0,
221
223
  "aria-label": label,
222
- className: "block rounded-md outline-none focus-visible:ring-2 focus-visible:ring-th-accent",
224
+ className: "block rounded-md outline-none forced-colors:focus-visible:outline-2 forced-colors:focus-visible:outline-solid forced-colors:focus-visible:outline-[Highlight] focus-visible:ring-2 focus-visible:ring-th-accent",
223
225
  style: { touchAction: "pan-y" },
224
226
  onPointerDown: onPointer,
225
227
  onPointerMove: onPointer,
@@ -236,11 +238,11 @@ function LineChart({
236
238
  /* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: toneColor(lines[0].tone, 0), stopOpacity: 0 })
237
239
  ] }) }),
238
240
  yLabels.map((l, i) => /* @__PURE__ */ jsxs("g", { children: [
239
- /* @__PURE__ */ jsx("line", { x1: padLeft, x2: padLeft + plotW, y1: sy(l.v), y2: sy(l.v), stroke: CHART.grid, strokeWidth: 1 }),
241
+ /* @__PURE__ */ jsx("line", { x1: plotX, x2: plotX + plotW, y1: sy(l.v), y2: sy(l.v), stroke: CHART.grid, strokeWidth: 1 }),
240
242
  /* @__PURE__ */ jsx(
241
243
  "text",
242
244
  {
243
- x: rtl ? padLeft + plotW + 6 : padLeft - 6,
245
+ x: rtl ? plotX + plotW + 6 : plotX - 6,
244
246
  y: sy(l.v),
245
247
  textAnchor: rtl ? "start" : "end",
246
248
  dominantBaseline: "middle",
@@ -264,7 +266,7 @@ function LineChart({
264
266
  },
265
267
  i
266
268
  )),
267
- baseline != null && Number.isFinite(baseline) && /* @__PURE__ */ jsx("line", { x1: padLeft, x2: padLeft + plotW, y1: sy(baseline), y2: sy(baseline), stroke: CHART.zero, strokeWidth: 1, strokeDasharray: "4 4" }),
269
+ baseline != null && Number.isFinite(baseline) && /* @__PURE__ */ jsx("line", { x1: plotX, x2: plotX + plotW, y1: sy(baseline), y2: sy(baseline), stroke: CHART.zero, strokeWidth: 1, strokeDasharray: "4 4" }),
268
270
  area && paths[0]?.map((seg, i) => /* @__PURE__ */ jsx("polygon", { points: `${seg[0].split(",")[0]},${bottom} ${seg.join(" ")} ${seg[seg.length - 1].split(",")[0]},${bottom}`, fill: `url(#${gradId})` }, i)),
269
271
  paths.map(
270
272
  (segs, si) => segs.map(
@@ -281,8 +283,14 @@ function LineChart({
281
283
  ax != null && width > 0 && /* @__PURE__ */ jsxs(
282
284
  "div",
283
285
  {
284
- className: "pointer-events-none absolute top-1 z-[var(--nish-z-tooltip,10)] whitespace-nowrap px-2 py-1 tabular-nums",
285
- style: { ...tooltipStyle, ...tipRight ? { left: cx + 10 } : { right: width - cx + 10 } },
286
+ ref: (el) => {
287
+ if (!el) return;
288
+ const w = el.offsetWidth;
289
+ if (tipRight) el.style.left = `${Math.max(0, Math.min(cx + 10, width - w))}px`;
290
+ else el.style.right = `${Math.max(0, Math.min(width - cx + 10, width - w))}px`;
291
+ },
292
+ className: "pointer-events-none absolute top-1 z-[var(--nish-z-tooltip,10)] overflow-hidden whitespace-nowrap px-2 py-1 tabular-nums",
293
+ style: { ...tooltipStyle, maxWidth: "calc(100% - 8px)", ...tipRight ? { left: cx + 10 } : { right: width - cx + 10 } },
286
294
  children: [
287
295
  /* @__PURE__ */ jsx("div", { className: "text-th-hi3", children: xFmt(ax) }),
288
296
  tipRows.map((r) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
@@ -322,14 +330,15 @@ function BarChart({
322
330
  ref,
323
331
  ...rest
324
332
  }) {
325
- const t = useNishStrings();
326
- const config = useNishConfig();
333
+ const t = useStrings(DISPLAY_STRINGS);
334
+ const config = useNishContext();
327
335
  const loc = locale ?? config.locale ?? "en-US";
328
336
  const fmt = valueFormat ?? ((v) => chartNumber(v, loc));
329
337
  const [wrapRef, width, wrapEl] = useWidth();
330
338
  const rtl = useChartRtl(wrapEl);
331
339
  const coarse = useMediaQuery("(pointer: coarse)");
332
- const [selected, setSelected] = useState(null);
340
+ const [pickedBar, setSelected] = useState(null);
341
+ const selected = pickedBar != null && pickedBar < data.length ? pickedBar : null;
333
342
  const color = toneColor(tone, 0);
334
343
  const pick = useCallback(
335
344
  (clientX, el) => {
@@ -368,7 +377,7 @@ function BarChart({
368
377
  if (e.key === "ArrowLeft" || e.key === "ArrowRight") {
369
378
  e.preventDefault();
370
379
  const dir = (e.key === "ArrowRight" ? 1 : -1) * (rtl ? -1 : 1);
371
- setSelected((s) => s == null ? dir > 0 ? 0 : data.length - 1 : Math.min(data.length - 1, Math.max(0, s + dir)));
380
+ setSelected(() => selected == null ? dir > 0 ? 0 : data.length - 1 : Math.min(data.length - 1, Math.max(0, selected + dir)));
372
381
  } else if (e.key === "Escape") setSelected(null);
373
382
  };
374
383
  return /* @__PURE__ */ jsxs("div", { ...rest, ref: mergeRefs(wrapRef, ref), className: cn("w-full", className), children: [
@@ -380,7 +389,7 @@ function BarChart({
380
389
  role: "img",
381
390
  tabIndex: 0,
382
391
  "aria-label": label,
383
- className: "block rounded-md outline-none focus-visible:ring-2 focus-visible:ring-th-accent",
392
+ className: "block rounded-md outline-none forced-colors:focus-visible:outline-2 forced-colors:focus-visible:outline-solid forced-colors:focus-visible:outline-[Highlight] focus-visible:ring-2 focus-visible:ring-th-accent",
384
393
  style: { touchAction: "pan-y" },
385
394
  onPointerDown: (e) => pick(e.clientX, e.currentTarget),
386
395
  onPointerMove: (e) => {
@@ -425,7 +434,7 @@ function BarChart({
425
434
  ] });
426
435
  }
427
436
  function RangeBar({ min, max, low, high, current, label, locale, className, ref, ...rest }) {
428
- const config = useNishConfig();
437
+ const config = useNishContext();
429
438
  const loc = locale ?? config.locale ?? "en-US";
430
439
  const num = (v) => chartNumber(v, loc);
431
440
  const span = max - min;
@@ -6,7 +6,8 @@ import { cn } from "../cn.js";
6
6
  import { CheckIcon, XIcon } from "./icons.js";
7
7
  import { Spinner } from "./feedback.js";
8
8
  import { fieldClass } from "./primitives.js";
9
- import { useNishStrings } from "./provider.js";
9
+ import { useStrings } from "./provider.js";
10
+ import { FIELD_STRINGS } from "./strings.js";
10
11
  import { indexComboboxOptions, setRef } from "./forms-classes.js";
11
12
  import { COMBOBOX_DEBOUNCE_MS, COMBOBOX_MAX_SHOWN } from "../combobox-filter.js";
12
13
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -43,7 +44,7 @@ function Combobox({
43
44
  className,
44
45
  ...rest
45
46
  }) {
46
- const strings = useNishStrings();
47
+ const strings = useStrings(FIELD_STRINGS);
47
48
  const autoId = useId().replace(/[^a-zA-Z0-9_-]/g, "");
48
49
  const inputId = id ?? `nish-cb-${autoId}`;
49
50
  const listId = `nish-cb-list-${autoId}`;
@@ -166,7 +167,7 @@ function Combobox({
166
167
  return true;
167
168
  }
168
169
  function onKeyDown(e) {
169
- if (disabled) return;
170
+ if (disabled || e.nativeEvent.isComposing || e.keyCode === 229) return;
170
171
  switch (e.key) {
171
172
  case "ArrowDown":
172
173
  case "ArrowUp": {
@@ -14,7 +14,8 @@ import { XIcon } from "./icons.js";
14
14
  import { Modal } from "./modal.js";
15
15
  import { navigateFromLayer, warnUnsafe } from "./navigate.js";
16
16
  import { useLatest } from "./latest.js";
17
- import { useNishStrings } from "./provider.js";
17
+ import { useStrings } from "./provider.js";
18
+ import { COMMAND_STRINGS, FIELD_STRINGS, OVERLAY_STRINGS } from "./strings.js";
18
19
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
19
20
  var MAX_RESULTS = 50;
20
21
  function indexItems(items) {
@@ -162,7 +163,7 @@ function CommandPalette({
162
163
  footer,
163
164
  onSubmitQuery
164
165
  }) {
165
- const s = useNishStrings();
166
+ const s = useStrings(COMMAND_STRINGS, FIELD_STRINGS, OVERLAY_STRINGS);
166
167
  useCommandHotkey(() => {
167
168
  if (!open) onOpenChange(true);
168
169
  }, hotkey);
@@ -183,7 +184,7 @@ function CommandPalette({
183
184
  );
184
185
  }
185
186
  function PaletteDialog({ onClose, items, placeholder, emptyText, resultsLabel, externalLabel, onQuery, footer, onSubmitQuery }) {
186
- const s = useNishStrings();
187
+ const s = useStrings(COMMAND_STRINGS, FIELD_STRINGS, OVERLAY_STRINGS);
187
188
  const uid = useId();
188
189
  const listId = `${uid}-list`;
189
190
  const optionId = (i) => `${uid}-opt-${i}`;
@@ -6,7 +6,8 @@ import { cn } from "../cn.js";
6
6
  import { isRtl, useIsoLayoutEffect } from "./client.js";
7
7
  import { mergeRefs } from "./data-classes.js";
8
8
  import { DropdownMenu } from "./menu.js";
9
- import { useNishStrings } from "./provider.js";
9
+ import { useStrings } from "./provider.js";
10
+ import { OVERLAY_STRINGS } from "./strings.js";
10
11
  import { jsx, jsxs } from "react/jsx-runtime";
11
12
  var FOCUSABLE = 'a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])';
12
13
  var NATIVE_MENU_TARGETS = 'input, textarea, select, [contenteditable]:not([contenteditable="false"])';
@@ -35,7 +36,7 @@ function ContextMenu({
35
36
  onClickCapture,
36
37
  ...rest
37
38
  }) {
38
- const t = useNishStrings();
39
+ const t = useStrings(OVERLAY_STRINGS);
39
40
  const [openState, setOpenState] = useState(false);
40
41
  const [point, setPoint] = useState(null);
41
42
  const [target, setTarget] = useState(null);
@@ -1,4 +1,5 @@
1
1
  // src/components/data-classes.ts
2
+ import { shared } from "../runtime.js";
2
3
  var ALIGN = { left: "text-start", center: "text-center", right: "text-end" };
3
4
  var ROW_TONE = {
4
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]",
@@ -15,7 +16,7 @@ var PAD = { normal: "py-2.5", dense: "py-1.5" };
15
16
  var TR = "border-b border-th-line last:border-b-0";
16
17
  var TR_INTERACTIVE = "cursor-pointer transition-colors hover:bg-th-elevated focus-within:bg-th-elevated";
17
18
  var NUMERIC = "whitespace-nowrap text-end tabular-nums";
18
- var STICKY_COL = "[&_thead_tr]:bg-th-surface [&_tbody_tr]:bg-th-surface [&_tr>:first-child]:sticky [&_tr>:first-child]:start-0 [&_tr>:first-child]:z-[calc(var(--nish-z-sticky,1)+9)] [&_tr>:first-child]:bg-inherit [&_tr>:first-child]:after:pointer-events-none [&_tr>:first-child]:after:absolute [&_tr>:first-child]:after:inset-y-0 [&_tr>:first-child]:after:start-full [&_tr>:first-child]:after:w-2.5 [&_tr>:first-child]:after:bg-gradient-to-r rtl:[&_tr>:first-child]:after:bg-gradient-to-l [&_tr>:first-child]:after:from-[color-mix(in_srgb,var(--nish-hi)_14%,transparent)] [&_tr>:first-child]:after:to-transparent [&_tr>:first-child]:after:opacity-0 [&_tr>:first-child]:after:transition-opacity [&[data-at-start=false]_tr>:first-child]:after:opacity-100";
19
+ var STICKY_COL = "[&_thead_tr]:bg-th-surface [&_tbody_tr]:bg-th-surface [&_thead_tr>:first-child]:z-[calc(var(--nish-z-sticky,1)+10)] [&_tr>:first-child]:sticky [&_tr>:first-child]:start-0 [&_tr>:first-child]:z-[calc(var(--nish-z-sticky,1)+9)] [&_tr>:first-child]:bg-inherit [&_tr>:first-child]:after:pointer-events-none [&_tr>:first-child]:after:absolute [&_tr>:first-child]:after:inset-y-0 [&_tr>:first-child]:after:start-full [&_tr>:first-child]:after:w-2.5 [&_tr>:first-child]:after:bg-gradient-to-r rtl:[&_tr>:first-child]:after:bg-gradient-to-l [&_tr>:first-child]:after:from-[color-mix(in_srgb,var(--nish-hi)_14%,transparent)] [&_tr>:first-child]:after:to-transparent [&_tr>:first-child]:after:opacity-0 [&_tr>:first-child]:after:transition-opacity ltr:[&[data-at-start=false]_tr>:first-child]:after:opacity-100 rtl:[&[data-at-end=false]_tr>:first-child]:after:opacity-100";
19
20
  var tableClass = {
20
21
  /** The scroll box around the table. */
21
22
  wrap: WRAP,
@@ -71,12 +72,12 @@ function sortRows(rows, get, dir) {
71
72
  return keyed.map((k) => k.row);
72
73
  }
73
74
  var googleFavicon = (host, size) => `https://www.google.com/s2/favicons?sz=${size * 2 > 32 ? 64 : 32}&domain=${encodeURIComponent(host)}`;
74
- var faviconResolver = () => null;
75
+ var favicons = () => shared("favicons", () => ({ resolve: (() => null) }));
75
76
  function configureFavicons(options) {
76
- faviconResolver = options.resolve ?? (() => null);
77
+ favicons().resolve = options.resolve ?? (() => null);
77
78
  }
78
79
  function getFaviconResolver() {
79
- return faviconResolver;
80
+ return favicons().resolve;
80
81
  }
81
82
  var FAVICON_HUES = 8;
82
83
  function hashString(s) {
@@ -25,7 +25,8 @@ import { useMediaQuery } from "./hooks.js";
25
25
  import { StatusDot } from "./display.js";
26
26
  import { CardListSkeleton, EmptyState, ErrorState, SkeletonRows } from "./feedback.js";
27
27
  import { useLatest } from "./latest.js";
28
- import { useNishStrings } from "./provider.js";
28
+ import { useStrings } from "./provider.js";
29
+ import { STATUS_STRINGS, TABLE_STRINGS } from "./strings.js";
29
30
  import { Table, TableWrap, Td, Th, Tr } from "./table.js";
30
31
  import { cardClass, IconButton, Select } from "./primitives.js";
31
32
  import { configureFavicons, googleFavicon } from "./data-classes.js";
@@ -70,10 +71,6 @@ var TONE_EDGE = {
70
71
  warn: "border-s-[3px] border-s-[var(--nish-warn-fill)]",
71
72
  loss: "border-s-[3px] border-s-[var(--nish-loss-fill)]"
72
73
  };
73
- var DEFAULT_SORT_TEXT = {
74
- announce: (header, dir) => dir ? `Sorted by ${header}, ${dir === "asc" ? "ascending" : "descending"}` : "Sorting cleared",
75
- toggle: (dir) => dir === "desc" ? "Sorted descending, switch to ascending" : "Sorted ascending, switch to descending"
76
- };
77
74
  var BodyRow = /* @__PURE__ */ memo(function BodyRow2({ row, columns, tone, interactive, onGo }) {
78
75
  return /* @__PURE__ */ jsx(
79
76
  Tr,
@@ -120,8 +117,8 @@ function ResponsiveTable({
120
117
  ref,
121
118
  ...rest
122
119
  }) {
123
- const t = useNishStrings();
124
- const text = { ...DEFAULT_SORT_TEXT, ...sortText };
120
+ const t = useStrings(STATUS_STRINGS, TABLE_STRINGS);
121
+ const text = { announce: sortText?.announce ?? t.sortAnnounce, toggle: sortText?.toggle ?? t.sortToggle };
125
122
  const [innerSort, setInnerSort] = useState(null);
126
123
  const [announcement, setAnnouncement] = useState("");
127
124
  const sortId = useId();
@@ -490,7 +487,7 @@ function LinkCard({
490
487
  );
491
488
  }
492
489
  function AsyncPanel({ status, skeleton, error, empty, children, className, ref, ...rest }) {
493
- const t = useNishStrings();
490
+ const t = useStrings(STATUS_STRINGS, TABLE_STRINGS);
494
491
  let body;
495
492
  if (status === "loading") body = skeleton ?? /* @__PURE__ */ jsx(SkeletonRows, {});
496
493
  else if (status === "error")
@@ -18,7 +18,8 @@ import { setRef } from "./forms-classes.js";
18
18
  import { Popover } from "./popover.js";
19
19
  import { CalendarIcon } from "./icons.js";
20
20
  import { fieldClass } from "./primitives-classes.js";
21
- import { useNishConfig, useNishStrings } from "./provider.js";
21
+ import { useNishContext, useStrings } from "./provider.js";
22
+ import { PICKER_STRINGS } from "./strings.js";
22
23
  import { jsx, jsxs } from "react/jsx-runtime";
23
24
  function DatePicker({
24
25
  ref,
@@ -47,8 +48,8 @@ function DatePicker({
47
48
  className,
48
49
  ...rest
49
50
  }) {
50
- const strings = useNishStrings();
51
- const config = useNishConfig();
51
+ const strings = useStrings(PICKER_STRINGS);
52
+ const config = useNishContext();
52
53
  const loc = resolveLocale(locale ?? config.locale ?? getDefaultLocale());
53
54
  const autoId = useId().replace(/[^a-zA-Z0-9_-]/g, "");
54
55
  const inputId = id ?? `nish-dp-${autoId}`;
@@ -152,6 +153,7 @@ function DatePicker({
152
153
  }),
153
154
  disabled,
154
155
  required,
156
+ form,
155
157
  "aria-label": ariaLabel,
156
158
  "aria-labelledby": ariaLabelledBy,
157
159
  "aria-describedby": ariaDescribedBy,
@@ -21,7 +21,8 @@ import { Popover } from "./popover.js";
21
21
  import { CalendarIcon } from "./icons.js";
22
22
  import { RangeCalendar } from "./range-calendar.js";
23
23
  import { fieldClass } from "./primitives-classes.js";
24
- import { useNishConfig, useNishStrings } from "./provider.js";
24
+ import { useNishContext, useStrings } from "./provider.js";
25
+ import { PICKER_STRINGS } from "./strings.js";
25
26
  import { jsx, jsxs } from "react/jsx-runtime";
26
27
  function DateRangePicker({
27
28
  ref,
@@ -51,8 +52,8 @@ function DateRangePicker({
51
52
  className,
52
53
  ...rest
53
54
  }) {
54
- const strings = useNishStrings();
55
- const config = useNishConfig();
55
+ const strings = useStrings(PICKER_STRINGS);
56
+ const config = useNishContext();
56
57
  const loc = resolveLocale(locale ?? config.locale ?? getDefaultLocale());
57
58
  const autoId = useId().replace(/[^a-zA-Z0-9_-]/g, "");
58
59
  const inputId = id ?? `nish-drp-${autoId}`;
@@ -156,6 +157,7 @@ function DateRangePicker({
156
157
  }),
157
158
  disabled,
158
159
  required,
160
+ form,
159
161
  "aria-label": ariaLabel,
160
162
  "aria-labelledby": ariaLabelledBy,
161
163
  "aria-describedby": ariaDescribedBy,
@@ -36,10 +36,11 @@ import {
36
36
  import { Skeleton } from "./feedback.js";
37
37
  import { AlertTriangleIcon, CheckCircleIcon, ChevronDownIcon, InfoIcon, XIcon } from "./icons.js";
38
38
  import { useHeightVar, useStuck } from "./layout-vars.js";
39
- import { DropdownMenu } from "./menu.js";
39
+ import { DropdownMenu, InlineMenuItemContext } from "./menu.js";
40
40
  import { Tooltip } from "./tooltip.js";
41
41
  import { Badge, Button, Card, IconButton } from "./primitives.js";
42
- import { useNishStrings } from "./provider.js";
42
+ import { useStrings } from "./provider.js";
43
+ import { DISPLAY_STRINGS, SHELL_STRINGS } from "./strings.js";
43
44
  import { ThemeToggle } from "./theme-toggle.js";
44
45
  import { signTone, toneFor as toneFor2 } from "./display-classes.js";
45
46
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -93,7 +94,7 @@ function Callout({
93
94
  ref,
94
95
  ...rest
95
96
  }) {
96
- const strings = useNishStrings();
97
+ const strings = useStrings(DISPLAY_STRINGS, SHELL_STRINGS);
97
98
  const t = CALLOUT_TONE[tone];
98
99
  const shown = icon === false ? null : icon ?? defaultCalloutIcon(tone, compact ? 14 : 16);
99
100
  const href = hrefProp == null ? void 0 : safeUrl(hrefProp) ?? void 0;
@@ -114,7 +115,7 @@ function Callout({
114
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;
115
116
  const chevron = /* @__PURE__ */ jsx(ChevronDownIcon, { size: 16, className: "-rotate-90 shrink-0 self-center text-th-hi3 rtl:rotate-90" });
116
117
  const hit = cn(
117
- "flex min-h-11 min-w-0 flex-1 items-start text-start outline-none focus-visible:ring-2 focus-visible:ring-th-accent/40",
118
+ "flex min-h-11 min-w-0 flex-1 items-start text-start outline-none focus-visible:ring-2 focus-visible:ring-th-accent/40 forced-colors:focus-visible:outline-2 forced-colors:focus-visible:outline-solid forced-colors:focus-visible:outline-[Highlight]",
118
119
  compact ? "gap-2" : "gap-3",
119
120
  // Pull the padding of the row into the link so the whole row is the target.
120
121
  compact ? "-my-2 py-2" : "-my-3 py-3"
@@ -310,7 +311,7 @@ function Sparkline({
310
311
  ref,
311
312
  ...rest
312
313
  }) {
313
- const strings = useNishStrings();
314
+ const strings = useStrings(DISPLAY_STRINGS, SHELL_STRINGS);
314
315
  const { empty, lines, areas, baseline } = useMemo(
315
316
  () => sparklineGeometry(values, width, height, min, max),
316
317
  [values, width, height, min, max]
@@ -472,7 +473,7 @@ function CopyButton({
472
473
  ref,
473
474
  ...rest
474
475
  }) {
475
- const strings = useNishStrings();
476
+ const strings = useStrings(DISPLAY_STRINGS, SHELL_STRINGS);
476
477
  const idleText = label ?? strings.copy;
477
478
  const doneText = copiedLabel ?? strings.copied;
478
479
  const [state, setState] = useState("idle");
@@ -578,7 +579,7 @@ function AppHeader({
578
579
  ref: refProp,
579
580
  ...rest
580
581
  }) {
581
- const strings = useNishStrings();
582
+ const strings = useStrings(DISPLAY_STRINGS, SHELL_STRINGS);
582
583
  const ref = useRef(null);
583
584
  useHeightVar(ref, "--nish-header-h", sticky);
584
585
  const stuck = useStuck(ref) && sticky;
@@ -647,7 +648,7 @@ function AppHeader({
647
648
  /* @__PURE__ */ jsxs("div", { className: "ms-auto flex shrink-0 items-center gap-2", children: [
648
649
  actions,
649
650
  overflowActions ? /* @__PURE__ */ jsxs(Fragment, { children: [
650
- /* @__PURE__ */ jsx("div", { ref: inlineActionsRef, className: "hidden items-center gap-2 sm:flex [&>button]:w-auto", children: overflowActions }),
651
+ /* @__PURE__ */ jsx("div", { ref: inlineActionsRef, className: "hidden items-center gap-2 sm:flex [&>button]:w-auto", children: /* @__PURE__ */ jsx(InlineMenuItemContext.Provider, { value: true, children: overflowActions }) }),
651
652
  /* @__PURE__ */ jsx("div", { className: "sm:hidden", children: /* @__PURE__ */ jsx(
652
653
  DropdownMenu,
653
654
  {
@@ -711,7 +712,7 @@ function KeyValueList({ items, dense = false, as = "ul", className, ref, ...rest
711
712
  ] }, it.key)) });
712
713
  }
713
714
  function ChartLegend({ items, marker = "line", label, className, ref, ...rest }) {
714
- const strings = useNishStrings();
715
+ const strings = useStrings(DISPLAY_STRINGS, SHELL_STRINGS);
715
716
  return /* @__PURE__ */ jsx(
716
717
  "ul",
717
718
  {
@@ -6,7 +6,8 @@ import { cn } from "../cn.js";
6
6
  import { XIcon } from "./icons.js";
7
7
  import { IconButton } from "./primitives.js";
8
8
  import { Portal } from "./portal.js";
9
- import { useNishStrings } from "./provider.js";
9
+ import { useStrings } from "./provider.js";
10
+ import { OVERLAY_STRINGS } from "./strings.js";
10
11
  import { DRAWER_SHEET_HEIGHT, DRAWER_WIDTH } from "./overlay-classes.js";
11
12
  import { warnDev, useMergedRef, useScrollable } from "./overlay-core.js";
12
13
  import { useDialog, useSheetExit, useSheetSwipe, SheetHandle } from "./overlay-dialog.js";
@@ -35,7 +36,7 @@ function DrawerPanel({
35
36
  ref,
36
37
  ...rest
37
38
  }) {
38
- const strings = useNishStrings();
39
+ const strings = useStrings(OVERLAY_STRINGS);
39
40
  const titleId = useId();
40
41
  const [panelRef, setPanelRef] = useMergedRef(ref);
41
42
  const scrimRef = useRef(null);
@@ -3,7 +3,8 @@
3
3
  // src/components/error-boundary.tsx
4
4
  import { Component } from "react";
5
5
  import { Button, Card } from "./primitives.js";
6
- import { useNishStrings } from "./provider.js";
6
+ import { useStrings } from "./provider.js";
7
+ import { ERROR_STRINGS } from "./strings.js";
7
8
  import { jsx, jsxs } from "react/jsx-runtime";
8
9
  var CHUNK_MESSAGE = /Failed to fetch dynamically imported module|Importing a module script failed/;
9
10
  function isChunkError(e) {
@@ -19,6 +20,7 @@ function isDevelopment() {
19
20
  return false;
20
21
  }
21
22
  }
23
+ var useErrorStrings = () => useStrings(ERROR_STRINGS);
22
24
  var Boundary = class extends Component {
23
25
  state = { error: null };
24
26
  static getDerivedStateFromError(error) {
@@ -56,7 +58,7 @@ var Boundary = class extends Component {
56
58
  }
57
59
  };
58
60
  function AppErrorBoundary(props) {
59
- const strings = useNishStrings();
61
+ const strings = useErrorStrings();
60
62
  return /* @__PURE__ */ jsx(Boundary, { ...props, strings });
61
63
  }
62
64
  export {
@@ -4,13 +4,14 @@
4
4
  import { cn } from "../cn.js";
5
5
  import { AlertTriangleIcon, LoaderIcon, RotateIcon } from "./icons.js";
6
6
  import { cardClass } from "./primitives.js";
7
- import { useNishStrings } from "./provider.js";
7
+ import { useStrings } from "./provider.js";
8
+ import { STATUS_STRINGS } from "./strings.js";
8
9
  import { jsx, jsxs } from "react/jsx-runtime";
9
10
  function Skeleton({ className, style, ref, ...rest }) {
10
11
  return /* @__PURE__ */ jsx("div", { ...rest, ref, "aria-hidden": "true", className: cn("nish-skeleton rounded-md", className), style });
11
12
  }
12
13
  function SkeletonRows({ rows = 5, height = 56, gap = "md", label, className, rowClassName, ref, ...rest }) {
13
- const s = useNishStrings();
14
+ const s = useStrings(STATUS_STRINGS);
14
15
  return /* @__PURE__ */ jsxs("div", { ...rest, ref, role: "status", className: cn("grid", gap === "sm" ? "gap-1.5" : "gap-2.5", className), children: [
15
16
  /* @__PURE__ */ jsx("span", { className: "sr-only", children: label ?? s.loading }),
16
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))
@@ -28,7 +29,7 @@ function Spinner({ size = "md", label, className, ref, ...rest }) {
28
29
  ] });
29
30
  }
30
31
  function SkeletonLines({ lines = 3, className, label, ref, ...rest }) {
31
- const s = useNishStrings();
32
+ const s = useStrings(STATUS_STRINGS);
32
33
  return /* @__PURE__ */ jsxs("div", { ...rest, ref, role: "status", className: cn("flex flex-col gap-2.5 p-3", className), children: [
33
34
  /* @__PURE__ */ jsx("span", { className: "sr-only", children: label ?? s.loading }),
34
35
  /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-2/5" }),
@@ -44,7 +45,7 @@ function SkeletonCard({ lines = 3, media = "none", className, ref, ...rest }) {
44
45
  ] });
45
46
  }
46
47
  function StatGridSkeleton({ count = 4, className, label, ref, ...rest }) {
47
- const s = useNishStrings();
48
+ const s = useStrings(STATUS_STRINGS);
48
49
  return /* @__PURE__ */ jsxs("div", { ...rest, ref, role: "status", className: cn("grid grid-cols-2 gap-3 md:grid-cols-4", className), children: [
49
50
  /* @__PURE__ */ jsx("span", { className: "sr-only", children: label ?? s.loading }),
50
51
  Array.from({ length: count }, (_, i) => /* @__PURE__ */ jsxs("div", { className: cn(cardClass({ padding: "sm" }), "min-w-0"), children: [
@@ -55,7 +56,7 @@ function StatGridSkeleton({ count = 4, className, label, ref, ...rest }) {
55
56
  ] });
56
57
  }
57
58
  function CardListSkeleton({ count = 3, lines = 2, className, label, ref, ...rest }) {
58
- const s = useNishStrings();
59
+ const s = useStrings(STATUS_STRINGS);
59
60
  return /* @__PURE__ */ jsxs("div", { ...rest, ref, role: "status", className: cn("grid gap-2.5", className), children: [
60
61
  /* @__PURE__ */ jsx("span", { className: "sr-only", children: label ?? s.loading }),
61
62
  Array.from({ length: count }, (_, i) => /* @__PURE__ */ jsx(SkeletonCard, { lines }, i))
@@ -91,7 +92,7 @@ function ErrorState({
91
92
  ref,
92
93
  ...rest
93
94
  }) {
94
- const s = useNishStrings();
95
+ const s = useStrings(STATUS_STRINGS);
95
96
  return /* @__PURE__ */ jsxs(
96
97
  "div",
97
98
  {