nish-ui 2.1.3 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/README.md +6 -2
  2. package/dist/chart.js +1 -1
  3. package/dist/elements-all.js +58 -58
  4. package/dist/elements-charts.js +1 -1
  5. package/dist/elements-data.js +1 -1
  6. package/dist/elements-forms.js +1 -1
  7. package/dist/elements.js +4 -4
  8. package/dist/esm/components/accordion.js +3 -2
  9. package/dist/esm/components/app-shell.js +3 -2
  10. package/dist/esm/components/avatar.js +4 -3
  11. package/dist/esm/components/breadcrumbs.js +3 -2
  12. package/dist/esm/components/calendar-base.js +292 -0
  13. package/dist/esm/components/calendar-classes.js +78 -0
  14. package/dist/esm/components/calendar.js +22 -254
  15. package/dist/esm/components/canvas/legend.js +3 -2
  16. package/dist/esm/components/canvas/node.js +3 -2
  17. package/dist/esm/components/canvas/system-canvas.js +3 -2
  18. package/dist/esm/components/carousel.js +3 -2
  19. package/dist/esm/components/charts.js +8 -7
  20. package/dist/esm/components/combobox.js +3 -2
  21. package/dist/esm/components/command.js +4 -3
  22. package/dist/esm/components/context-menu.js +3 -2
  23. package/dist/esm/components/data.js +4 -3
  24. package/dist/esm/components/date-picker.js +4 -3
  25. package/dist/esm/components/date-range-picker.js +214 -0
  26. package/dist/esm/components/display.js +7 -6
  27. package/dist/esm/components/drawer.js +3 -2
  28. package/dist/esm/components/error-boundary.js +4 -2
  29. package/dist/esm/components/feedback.js +7 -6
  30. package/dist/esm/components/file-dropzone.js +3 -2
  31. package/dist/esm/components/filters.js +4 -3
  32. package/dist/esm/components/flow.js +6 -5
  33. package/dist/esm/components/forms.js +14 -8
  34. package/dist/esm/components/hooks.js +2 -2
  35. package/dist/esm/components/hover-card.js +2 -2
  36. package/dist/esm/components/inbox.js +4 -2
  37. package/dist/esm/components/layout.js +5 -4
  38. package/dist/esm/components/media.js +3 -2
  39. package/dist/esm/components/menu.js +5 -4
  40. package/dist/esm/components/modal.js +4 -3
  41. package/dist/esm/components/more-sheet.js +3 -2
  42. package/dist/esm/components/multi-select.js +3 -2
  43. package/dist/esm/components/nav-items.js +4 -3
  44. package/dist/esm/components/nav.js +5 -4
  45. package/dist/esm/components/overlay-dialog.js +3 -2
  46. package/dist/esm/components/pagination.js +3 -2
  47. package/dist/esm/components/popover.js +2 -2
  48. package/dist/esm/components/portal.js +2 -2
  49. package/dist/esm/components/progress.js +3 -2
  50. package/dist/esm/components/provider.js +34 -5
  51. package/dist/esm/components/range-calendar.js +123 -0
  52. package/dist/esm/components/service-tokens.js +4 -3
  53. package/dist/esm/components/settings.js +4 -3
  54. package/dist/esm/components/slider.js +3 -2
  55. package/dist/esm/components/split.js +4 -3
  56. package/dist/esm/components/strings.js +178 -60
  57. package/dist/esm/components/tag-input.js +3 -2
  58. package/dist/esm/components/theme-toggle.js +3 -2
  59. package/dist/esm/components/time-field-classes.js +110 -0
  60. package/dist/esm/components/time-field.js +309 -0
  61. package/dist/esm/components/toast-card.js +155 -0
  62. package/dist/esm/components/toast-store.js +136 -0
  63. package/dist/esm/components/toast.js +38 -241
  64. package/dist/esm/components/tooltip.js +2 -2
  65. package/dist/esm/components/tree-view.js +40 -46
  66. package/dist/esm/components/virtual-table.js +3 -2
  67. package/dist/esm/index.js +6 -20
  68. package/dist/esm/runtime.js +1 -1
  69. package/dist/esm/system-canvas.js +4 -0
  70. package/dist/esm/theme.js +7 -7
  71. package/dist/format.js +1 -1
  72. package/dist/index.d.ts +172 -24
  73. package/dist/system-canvas.d.ts +183 -2
  74. package/dist/theme.d.ts +21 -3
  75. package/dist/theme.global.js +21 -136
  76. package/dist/theme.js +21 -136
  77. package/package.json +1 -1
  78. package/dist/system-canvas-BLuWd69H.d.ts +0 -183
@@ -3,7 +3,8 @@
3
3
  // src/components/canvas/legend.tsx
4
4
  import { memo, useEffect, useId, useRef, useState } from "react";
5
5
  import { cn } from "../../cn.js";
6
- import { useNishStrings } from "../provider.js";
6
+ import { useStrings } from "../provider.js";
7
+ import { CANVAS_STRINGS } from "../strings.js";
7
8
  import { Svg } from "./icons.js";
8
9
  import { DEFAULT_CANVAS_LABELS } from "./types.js";
9
10
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -22,7 +23,7 @@ var EdgeLegend = memo(function EdgeLegend2({
22
23
  onToggle,
23
24
  labels = DEFAULT_CANVAS_LABELS
24
25
  }) {
25
- const strings = useNishStrings();
26
+ const strings = useStrings(CANVAS_STRINGS);
26
27
  const [open, setOpen] = useState(false);
27
28
  const rootRef = useRef(null);
28
29
  const buttonRef = useRef(null);
@@ -4,7 +4,8 @@
4
4
  import { memo, useRef } from "react";
5
5
  import { useIsoLayoutEffect } from "../client.js";
6
6
  import { TickerText } from "../flow.js";
7
- import { useNishStrings } from "../provider.js";
7
+ import { useStrings } from "../provider.js";
8
+ import { MEDIA_STRINGS } from "../strings.js";
8
9
  import { KIND_ICON, Svg } from "./icons.js";
9
10
  import { jsx, jsxs } from "react/jsx-runtime";
10
11
  function hueStyle(hue) {
@@ -32,7 +33,7 @@ function usePing(active) {
32
33
  }
33
34
  var NodeView = memo(
34
35
  function NodeView2({ node, groupTitle, hue, box, selected, dim, delay, onSelect }) {
35
- const strings = useNishStrings();
36
+ const strings = useStrings(MEDIA_STRINGS);
36
37
  const active = !!node.active;
37
38
  const heat = clamp01(node.heat);
38
39
  const ref = usePing(active);
@@ -13,7 +13,8 @@ import { cn } from "../../cn.js";
13
13
  import { useIsoLayoutEffect } from "../client.js";
14
14
  import { usePrefersReducedMotion } from "../flow.js";
15
15
  import { IconButton } from "../primitives.js";
16
- import { useNishStrings } from "../provider.js";
16
+ import { useStrings } from "../provider.js";
17
+ import { CANVAS_STRINGS } from "../strings.js";
17
18
  import { FollowCaption } from "./follow-caption.js";
18
19
  import { useFollow } from "./follow.js";
19
20
  import { FitIcon, FollowIcon, MinusIcon, PlusIcon } from "./icons.js";
@@ -52,7 +53,7 @@ function SystemCanvas({
52
53
  ref: forwardedRef,
53
54
  ...rest
54
55
  }) {
55
- const strings = useNishStrings();
56
+ const strings = useStrings(CANVAS_STRINGS);
56
57
  const label = labelProp ?? strings.systemMap;
57
58
  const labels = useMemo(() => ({ ...DEFAULT_CANVAS_LABELS, ...labelOverrides }), [labelOverrides]);
58
59
  const reduced = usePrefersReducedMotion();
@@ -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;
@@ -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));
@@ -322,8 +323,8 @@ function BarChart({
322
323
  ref,
323
324
  ...rest
324
325
  }) {
325
- const t = useNishStrings();
326
- const config = useNishConfig();
326
+ const t = useStrings(DISPLAY_STRINGS);
327
+ const config = useNishContext();
327
328
  const loc = locale ?? config.locale ?? "en-US";
328
329
  const fmt = valueFormat ?? ((v) => chartNumber(v, loc));
329
330
  const [wrapRef, width, wrapEl] = useWidth();
@@ -425,7 +426,7 @@ function BarChart({
425
426
  ] });
426
427
  }
427
428
  function RangeBar({ min, max, low, high, current, label, locale, className, ref, ...rest }) {
428
- const config = useNishConfig();
429
+ const config = useNishContext();
429
430
  const loc = locale ?? config.locale ?? "en-US";
430
431
  const num = (v) => chartNumber(v, loc);
431
432
  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}`;
@@ -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);
@@ -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";
@@ -120,7 +121,7 @@ function ResponsiveTable({
120
121
  ref,
121
122
  ...rest
122
123
  }) {
123
- const t = useNishStrings();
124
+ const t = useStrings(STATUS_STRINGS, TABLE_STRINGS);
124
125
  const text = { ...DEFAULT_SORT_TEXT, ...sortText };
125
126
  const [innerSort, setInnerSort] = useState(null);
126
127
  const [announcement, setAnnouncement] = useState("");
@@ -490,7 +491,7 @@ function LinkCard({
490
491
  );
491
492
  }
492
493
  function AsyncPanel({ status, skeleton, error, empty, children, className, ref, ...rest }) {
493
- const t = useNishStrings();
494
+ const t = useStrings(STATUS_STRINGS, TABLE_STRINGS);
494
495
  let body;
495
496
  if (status === "loading") body = skeleton ?? /* @__PURE__ */ jsx(SkeletonRows, {});
496
497
  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}`;
@@ -0,0 +1,214 @@
1
+ "use client";
2
+
3
+ // src/components/date-range-picker.tsx
4
+ import { useEffect, useId, useRef, useState } from "react";
5
+ import { cn } from "../cn.js";
6
+ import { getDefaultLocale } from "../format.js";
7
+ import {
8
+ firstDisabledIn,
9
+ formatRangeField,
10
+ fullDate,
11
+ inRange,
12
+ parseIso,
13
+ parseRangeField,
14
+ rangePlaceholder,
15
+ resolveLocale,
16
+ sameRange,
17
+ toRange
18
+ } from "./calendar-classes.js";
19
+ import { setRef } from "./forms-classes.js";
20
+ import { Popover } from "./popover.js";
21
+ import { CalendarIcon } from "./icons.js";
22
+ import { RangeCalendar } from "./range-calendar.js";
23
+ import { fieldClass } from "./primitives-classes.js";
24
+ import { useNishContext, useStrings } from "./provider.js";
25
+ import { PICKER_STRINGS } from "./strings.js";
26
+ import { jsx, jsxs } from "react/jsx-runtime";
27
+ function DateRangePicker({
28
+ ref,
29
+ value: valueProp,
30
+ defaultValue = null,
31
+ onValueChange,
32
+ min: minProp,
33
+ max: maxProp,
34
+ isDateDisabled,
35
+ allowDisabledInRange = false,
36
+ locale,
37
+ weekStartsOn,
38
+ captionLayout,
39
+ placeholder,
40
+ "aria-label": ariaLabel,
41
+ "aria-labelledby": ariaLabelledBy,
42
+ "aria-describedby": ariaDescribedBy,
43
+ "aria-invalid": ariaInvalid,
44
+ invalid,
45
+ id,
46
+ name,
47
+ form,
48
+ required,
49
+ disabled = false,
50
+ size = "md",
51
+ calendarLabel,
52
+ className,
53
+ ...rest
54
+ }) {
55
+ const strings = useStrings(PICKER_STRINGS);
56
+ const config = useNishContext();
57
+ const loc = resolveLocale(locale ?? config.locale ?? getDefaultLocale());
58
+ const autoId = useId().replace(/[^a-zA-Z0-9_-]/g, "");
59
+ const inputId = id ?? `nish-drp-${autoId}`;
60
+ const min = parseIso(minProp) ? minProp : null;
61
+ const max = parseIso(maxProp) ? maxProp : null;
62
+ const controlled = valueProp !== void 0;
63
+ const [own, setOwn] = useState(() => toRange(defaultValue));
64
+ const value = controlled ? toRange(valueProp) : own;
65
+ const [open, setOpen] = useState(false);
66
+ const [text, setText] = useState("");
67
+ const [dirty, setDirty] = useState(false);
68
+ const [badText, setBadText] = useState(false);
69
+ const inputRef = useRef(null);
70
+ const buttonRef = useRef(null);
71
+ const shown = dirty ? text : value ? formatRangeField(value, loc) : "";
72
+ const isInvalid = invalid === true || ariaInvalid === true || ariaInvalid === "true" || badText;
73
+ useEffect(() => {
74
+ inputRef.current?.setCustomValidity(badText ? strings.invalidDateRange : "");
75
+ }, [badText, strings.invalidDateRange]);
76
+ useEffect(() => {
77
+ const f = inputRef.current?.form;
78
+ if (!f || controlled) return;
79
+ const onReset = () => {
80
+ setOwn(toRange(defaultValue));
81
+ setDirty(false);
82
+ setBadText(false);
83
+ };
84
+ f.addEventListener("reset", onReset);
85
+ return () => f.removeEventListener("reset", onReset);
86
+ }, [name, form, controlled, defaultValue]);
87
+ const commit = (v) => {
88
+ if (!controlled) setOwn(v);
89
+ onValueChange?.(v);
90
+ };
91
+ const commitText = () => {
92
+ if (!dirty) return;
93
+ if (text.trim() === "") {
94
+ if (value !== null) commit(null);
95
+ setDirty(false);
96
+ setBadText(false);
97
+ return;
98
+ }
99
+ const r = parseRangeField(text, loc);
100
+ if (r && inRange(r.from, min, max) && inRange(r.to, min, max) && isDateDisabled?.(r.from) !== true && isDateDisabled?.(r.to) !== true && (allowDisabledInRange || !isDateDisabled || firstDisabledIn(r.from, r.to, isDateDisabled) === null)) {
101
+ if (!sameRange(r, value)) commit(r);
102
+ setDirty(false);
103
+ setBadText(false);
104
+ return;
105
+ }
106
+ setBadText(true);
107
+ };
108
+ const pickFromCalendar = (r) => {
109
+ commit(r);
110
+ setDirty(false);
111
+ setBadText(false);
112
+ setOpen(false);
113
+ };
114
+ const onKeyDown = (e) => {
115
+ if (disabled) return;
116
+ if (e.key === "Enter") {
117
+ if (dirty) {
118
+ e.preventDefault();
119
+ commitText();
120
+ }
121
+ } else if (e.key === "ArrowDown" && e.altKey) {
122
+ e.preventDefault();
123
+ setOpen(true);
124
+ } else if (e.key === "Escape" && dirty) {
125
+ e.preventDefault();
126
+ e.stopPropagation();
127
+ setDirty(false);
128
+ setBadText(false);
129
+ }
130
+ };
131
+ const buttonLabel = calendarLabel ?? (value ? strings.changeDates(strings.dateRange(fullDate(value.from, loc), fullDate(value.to, loc))) : strings.chooseDates);
132
+ return /* @__PURE__ */ jsxs(
133
+ "div",
134
+ {
135
+ ...rest,
136
+ "data-state": open ? "open" : "closed",
137
+ "data-disabled": disabled ? "" : void 0,
138
+ className: cn("relative w-full min-w-0", className),
139
+ children: [
140
+ /* @__PURE__ */ jsx(
141
+ "input",
142
+ {
143
+ ref: (node) => {
144
+ inputRef.current = node;
145
+ setRef(ref, node);
146
+ },
147
+ id: inputId,
148
+ type: "text",
149
+ inputMode: "numeric",
150
+ autoComplete: "off",
151
+ spellCheck: false,
152
+ value: shown,
153
+ placeholder: placeholder ?? rangePlaceholder(loc, {
154
+ day: strings.dayToken,
155
+ month: strings.monthToken,
156
+ year: strings.yearToken
157
+ }),
158
+ disabled,
159
+ required,
160
+ "aria-label": ariaLabel,
161
+ "aria-labelledby": ariaLabelledBy,
162
+ "aria-describedby": ariaDescribedBy,
163
+ "aria-invalid": isInvalid || void 0,
164
+ "aria-required": required || void 0,
165
+ onChange: (e) => {
166
+ setText(e.target.value);
167
+ setDirty(true);
168
+ },
169
+ onBlur: commitText,
170
+ onKeyDown,
171
+ className: fieldClass({
172
+ size,
173
+ invalid: isInvalid,
174
+ className: "pe-11 tabular-nums"
175
+ })
176
+ }
177
+ ),
178
+ name != null ? /* @__PURE__ */ jsx("input", { type: "hidden", name, value: value ? `${value.from}/${value.to}` : "", form, disabled }) : null,
179
+ /* @__PURE__ */ jsx(
180
+ "button",
181
+ {
182
+ ref: buttonRef,
183
+ type: "button",
184
+ "aria-label": buttonLabel,
185
+ "aria-haspopup": "dialog",
186
+ "aria-expanded": open,
187
+ disabled,
188
+ onClick: () => setOpen((o) => !o),
189
+ className: "absolute inset-y-0 end-0 flex w-11 items-center justify-center text-th-hi3 hover:text-th-hi disabled:pointer-events-none disabled:opacity-50",
190
+ children: /* @__PURE__ */ jsx("span", { className: "flex size-8 items-center justify-center rounded-md hover:bg-th-elevated", children: /* @__PURE__ */ jsx(CalendarIcon, { size: 16 }) })
191
+ }
192
+ ),
193
+ /* @__PURE__ */ jsx(Popover, { open, onOpenChange: (o) => setOpen(o), anchor: buttonRef, align: "end", "aria-label": strings.chooseDates, className: "p-3", children: /* @__PURE__ */ jsx(
194
+ RangeCalendar,
195
+ {
196
+ value,
197
+ onValueChange: pickFromCalendar,
198
+ min: minProp,
199
+ max: maxProp,
200
+ isDateDisabled,
201
+ allowDisabledInRange,
202
+ locale: loc,
203
+ weekStartsOn,
204
+ captionLayout,
205
+ autoFocus: true
206
+ }
207
+ ) })
208
+ ]
209
+ }
210
+ );
211
+ }
212
+ export {
213
+ DateRangePicker
214
+ };
@@ -39,7 +39,8 @@ import { useHeightVar, useStuck } from "./layout-vars.js";
39
39
  import { DropdownMenu } 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;
@@ -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;
@@ -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
  {
@@ -5,7 +5,8 @@ import { useRef, useState } from "react";
5
5
  import { cn } from "../cn.js";
6
6
  import { XIcon } from "./icons.js";
7
7
  import { IconButton } from "./primitives.js";
8
- import { useNishStrings } from "./provider.js";
8
+ import { useStrings } from "./provider.js";
9
+ import { FILE_STRINGS } from "./strings.js";
9
10
  import { jsx, jsxs } from "react/jsx-runtime";
10
11
  function matchesAccept(file, accept) {
11
12
  const tokens = (accept ?? "").split(",").map((t) => t.trim().toLowerCase()).filter(Boolean);
@@ -53,7 +54,7 @@ function FileDropzone({
53
54
  "aria-invalid": ariaInvalid,
54
55
  ...rest
55
56
  }) {
56
- const strings = useNishStrings();
57
+ const strings = useStrings(FILE_STRINGS);
57
58
  const input = useRef(null);
58
59
  const depth = useRef(0);
59
60
  const [files, setFiles] = useState([]);
@@ -7,7 +7,8 @@ import { SearchInput } from "./forms.js";
7
7
  import { NARROW_QUERY, useMediaQuery } from "./hooks.js";
8
8
  import { Drawer } from "./drawer.js";
9
9
  import { Badge, Button } from "./primitives.js";
10
- import { useNishStrings } from "./provider.js";
10
+ import { useStrings } from "./provider.js";
11
+ import { FILTER_STRINGS, FIELD_STRINGS } from "./strings.js";
11
12
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
12
13
  var LG_QUERY = "(max-width: 1023.98px)";
13
14
  function FunnelIcon({ size = 16, ...rest }) {
@@ -30,7 +31,7 @@ function FunnelIcon({ size = 16, ...rest }) {
30
31
  );
31
32
  }
32
33
  function FilterSheet({ open, onClose, title, children, onClear, activeCount, resultLabel }) {
33
- const strings = useNishStrings();
34
+ const strings = useStrings(FILTER_STRINGS, FIELD_STRINGS);
34
35
  if (!open) return null;
35
36
  return /* @__PURE__ */ jsx(
36
37
  Drawer,
@@ -61,7 +62,7 @@ function FilterBar({
61
62
  ref,
62
63
  ...rest
63
64
  }) {
64
- const strings = useNishStrings();
65
+ const strings = useStrings(FILTER_STRINGS, FIELD_STRINGS);
65
66
  const compact = useMediaQuery(sheetBelow === "lg" ? LG_QUERY : NARROW_QUERY);
66
67
  const [open, setOpen] = useState(false);
67
68
  const hasChildren = children != null && children !== false;