@nivaro/react 0.3.9 → 0.3.11

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 (80) hide show
  1. package/dist/components/fields/FileField.js +20 -19
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useNivaroForm.js +129 -126
  4. package/dist/hooks/useSessionRecorder.js +1 -1
  5. package/dist/index.d.ts +103 -4
  6. package/dist/index.js +512 -501
  7. package/dist/shared/components/CollectionBrowserView.js +1632 -1564
  8. package/dist/shared/components/ConformanceView.js +36 -35
  9. package/dist/shared/components/ForceReloadBanner.js +58 -34
  10. package/dist/shared/components/ItemEditForm.js +4386 -4142
  11. package/dist/shared/components/JsonMapEditor.js +18 -17
  12. package/dist/shared/components/MatrixEditor.js +8 -7
  13. package/dist/shared/components/MyWorkView.js +32 -31
  14. package/dist/shared/components/PageRenderer.js +527 -479
  15. package/dist/shared/components/QueryStatStrip.js +74 -70
  16. package/dist/shared/components/RecordGridEditor.js +76 -75
  17. package/dist/shared/components/ReportView.js +818 -827
  18. package/dist/shared/components/SheetHeaderBody.js +16 -14
  19. package/dist/shared/components/ai/AiMemorySuggestions.js +15 -14
  20. package/dist/shared/components/ai/AskPanel.js +55 -54
  21. package/dist/shared/components/bulk/BulkActionButtons.js +30 -29
  22. package/dist/shared/components/bulk/PushBulkButtons.js +57 -56
  23. package/dist/shared/components/chat/SlashCommands.js +30 -29
  24. package/dist/shared/components/chat/chat-outbox.js +76 -75
  25. package/dist/shared/components/help-videos/recorder/useLeaveWarning.js +6 -5
  26. package/dist/shared/components/integrations/console/SignalCard.js +124 -123
  27. package/dist/shared/components/integrations/console/SnoozeMenu.js +24 -23
  28. package/dist/shared/components/item-edit/CatalogPickerField.js +1029 -933
  29. package/dist/shared/components/item-edit/CloneDialog.js +85 -78
  30. package/dist/shared/components/item-edit/FieldRenderer.js +161 -156
  31. package/dist/shared/components/item-edit/FieldRow.js +20 -19
  32. package/dist/shared/components/item-edit/FilePickerField.js +52 -40
  33. package/dist/shared/components/item-edit/GroupSection.js +221 -221
  34. package/dist/shared/components/item-edit/InlineGridField.js +41 -41
  35. package/dist/shared/components/item-edit/InlineTableField.js +2287 -2275
  36. package/dist/shared/components/item-edit/M2MCombobox.js +46 -44
  37. package/dist/shared/components/item-edit/MembershipSetField.js +24 -23
  38. package/dist/shared/components/item-edit/NestedRelationEditor.js +11 -11
  39. package/dist/shared/components/item-edit/QuickCreateButton.js +8 -7
  40. package/dist/shared/components/item-edit/QuickPicker.js +263 -216
  41. package/dist/shared/components/item-edit/RecordLiveSync.js +101 -100
  42. package/dist/shared/components/item-edit/RelationCombobox.js +285 -245
  43. package/dist/shared/components/item-edit/RichTextEditorImpl.js +42 -32
  44. package/dist/shared/components/item-edit/RowHistorySheet.js +130 -134
  45. package/dist/shared/components/item-edit/SummaryPanel.js +305 -279
  46. package/dist/shared/components/item-edit/helpers.js +133 -134
  47. package/dist/shared/components/item-edit/line-qty.js +57 -0
  48. package/dist/shared/components/item-edit/option-disambiguate.js +53 -0
  49. package/dist/shared/components/item-edit/staged-links.js +86 -0
  50. package/dist/shared/components/layout-editor/LayoutEditor.js +275 -274
  51. package/dist/shared/components/layout-editor/editors/cascade-rule-row.js +18 -17
  52. package/dist/shared/components/layout-editor/inspector/HelpTab.js +37 -36
  53. package/dist/shared/components/layout-editor/matrix/FieldStateMatrix.js +50 -49
  54. package/dist/shared/components/panels/AddendumLinesDiff.js +87 -90
  55. package/dist/shared/components/panels/CommentPanel.js +350 -315
  56. package/dist/shared/components/panels/ItemLockBanner.js +297 -230
  57. package/dist/shared/components/panels/PipelinePanel.js +719 -701
  58. package/dist/shared/components/profile/AiMemoryCard.js +15 -14
  59. package/dist/shared/components/profile/PersonAdminTools.js +70 -67
  60. package/dist/shared/components/queue/QueueItemSheet.js +36 -35
  61. package/dist/shared/components/queue/QueueQuickFilters.js +43 -41
  62. package/dist/shared/components/queue/QueueWorklist.js +1026 -957
  63. package/dist/shared/components/widgets/ReviewListWidget.js +99 -93
  64. package/dist/shared/lib/client-version.js +63 -0
  65. package/dist/shared/lib/force-reload.js +36 -0
  66. package/dist/shared/lib/load-error.js +11 -10
  67. package/dist/shared/lib/obligation-banner.js +14 -13
  68. package/dist/shared/lib/obligation-reason-text.js +13 -0
  69. package/dist/shared/lib/presence-live.js +54 -35
  70. package/dist/shared/lib/query-filter-seed.js +34 -11
  71. package/dist/shared/lib/record-outbox.js +76 -75
  72. package/dist/shared/lib/safe-error.js +39 -0
  73. package/dist/shared/lib/sanitize-html.js +24 -15
  74. package/dist/shared/lib/server-clock.js +11 -7
  75. package/dist/shared/lib/sheet-def.js +38 -22
  76. package/dist/shared/lib/unique-options.js +10 -0
  77. package/dist/shared/lib/unsaved-work.js +62 -0
  78. package/dist/shared/lib/utils.js +57 -43
  79. package/dist/shared/lib/validation-rules.js +58 -34
  80. package/package.json +1 -1
@@ -1,49 +1,53 @@
1
1
  import { jsx as l, jsxs as y } from "react/jsx-runtime";
2
- import { useQuery as W } from "@tanstack/react-query";
3
- import { useRef as q, useState as R, useLayoutEffect as I, useId as K } from "react";
4
- import { useNivaroClient as Q } from "../context.js";
5
- import { post as G } from "../lib/commands.js";
6
- import { matchRows as J, statCoverage as V, statValue as H, sumField as X, fmtStat as T, compactStat as Y } from "../lib/query-stats.js";
7
- import { colorPair as z } from "./QueryTable.js";
8
- const Z = /* @__PURE__ */ new Set(["ink", "muted"]), ee = 150, F = 8;
9
- function te(e, d) {
10
- const f = q(null), b = q(null);
11
- return I(() => {
12
- const u = f.current, o = b.current;
13
- if (!u || !o) {
14
- d(!0);
2
+ import { useQuery as Q } from "@tanstack/react-query";
3
+ import { useRef as S, useState as C, useLayoutEffect as A, useId as G } from "react";
4
+ import { useNivaroClient as J } from "../context.js";
5
+ import { post as V } from "../lib/commands.js";
6
+ import { matchRows as H, statCoverage as X, statValue as Y, sumField as Z, fmtStat as z, compactStat as ee } from "../lib/query-stats.js";
7
+ import { colorPair as I } from "./QueryTable.js";
8
+ const te = /* @__PURE__ */ new Set(["ink", "muted"]), re = 150, P = 8;
9
+ function ne(e, c) {
10
+ const b = S(null), f = S(null);
11
+ return A(() => {
12
+ const d = b.current, o = f.current;
13
+ if (!d || !o) {
14
+ c(!0);
15
15
  return;
16
16
  }
17
- const x = () => d(o.offsetWidth <= u.clientWidth);
17
+ const x = () => c(o.offsetWidth <= d.clientWidth);
18
18
  if (x(), typeof ResizeObserver > "u") return;
19
19
  const m = new ResizeObserver(x);
20
- return m.observe(u), () => m.disconnect();
21
- }, [e]), { box: f, probe: b };
20
+ return m.observe(d), () => m.disconnect();
21
+ }, [e]), { box: b, probe: f };
22
22
  }
23
- function re({
23
+ function ae({
24
24
  stat: e,
25
- rows: d,
26
- effectiveParams: f,
27
- loading: b,
28
- compact: u,
25
+ rows: c,
26
+ effectiveParams: b,
27
+ loading: f,
28
+ compact: d,
29
29
  onFit: o
30
30
  }) {
31
- const x = Q(), [m, p] = R(!1), k = K(), t = e.query, g = t ? {
32
- ...t.params ?? {},
31
+ const x = J(), [m, p] = C(!1), k = G(), r = e.query, g = r ? {
32
+ ...r.params ?? {},
33
33
  ...Object.fromEntries(
34
- Object.entries(t.param_from ?? {}).map(([r, U]) => [r, f[U]])
34
+ Object.entries(r.param_from ?? {}).map(([t, K]) => [t, b[K]])
35
35
  )
36
- } : null, { data: N, isLoading: n } = W({
37
- queryKey: ["query-stat", t == null ? void 0 : t.slug, JSON.stringify(g)],
36
+ } : null, { data: N, isLoading: n } = Q({
37
+ queryKey: ["query-stat", r == null ? void 0 : r.slug, JSON.stringify(g)],
38
38
  queryFn: () => x.request(
39
- G(`/custom-queries/${t.slug}/execute`, { params: g })
40
- ).then((r) => r.data ?? []),
41
- enabled: !!t,
39
+ V(`/custom-queries/${r.slug}/execute`, { params: g })
40
+ ).then((t) => t.data ?? []),
41
+ enabled: !!r,
42
42
  staleTime: 6e4
43
- }), c = J(d, e.row_match), s = t ? n : b, a = e.coverage && !s ? V(e, d) : null, _ = !!a && a.reporting === 0, i = s || _ ? null : H(e, d, N ?? null), C = !s && (i == null || i === ""), L = e.format === "date" || e.format === "text", O = t ? t.label_field ? (N ?? []).map((r) => ({
44
- label: String(r[t.label_field] ?? "—"),
45
- value: Number(r[t.value_field]) || 0
46
- })) : [] : (e.details ?? []).map((r) => ({ label: r.label, value: X(c, r.field) })), M = typeof i == "number" && i < 0 && (e.field_subtract || e.accent_negative), w = M ? e.accent_negative ?? "negative" : e.accent, v = L || C || !w ? null : M ? z(w) : z(w, e.accent_dark), P = v && !Z.has(String(w).trim().toLowerCase()), E = typeof i == "number" && e.field_subtract && i > 0 ? "+" : "", h = `${E}${T(i, e.format, e.empty_label)}`, $ = typeof i == "number" && (e.format === void 0 || e.format === "currency" || e.format === "number"), { box: A, probe: B } = te($ ? h : "", o), j = u && $ ? `${E}${Y(i, e.format)}` : h, D = a && a.reporting > 0 && a.reporting < a.total, S = O.length > 0;
43
+ }), u = H(c, e.row_match), s = r ? n : f, a = e.coverage && !s ? X(e, c) : null, _ = !!a && a.reporting === 0, R = e.requires_field, L = !!R && !f && !c.some((t) => t[R] != null && t[R] !== ""), i = s || _ || L ? null : Y(e, c, N ?? null), O = !s && (i == null || i === ""), M = e.format === "date" || e.format === "text", E = r ? r.label_field ? (N ?? []).map((t) => ({
44
+ label: String(t[r.label_field] ?? "—"),
45
+ value: Number(t[r.value_field]) || 0
46
+ })) : [] : (e.details ?? []).map((t) => ({ label: t.label, value: Z(u, t.field) })), $ = typeof i == "number" && i < 0 && (e.field_subtract || e.accent_negative), w = $ ? e.accent_negative ?? "negative" : e.accent, v = M || O || !w ? null : $ ? I(w) : I(w, e.accent_dark), B = v && !te.has(String(w).trim().toLowerCase()), j = typeof i == "number" && e.field_subtract && i > 0 ? "+" : "", h = `${j}${z(
47
+ i,
48
+ e.format,
49
+ L ? e.requires_label ?? e.empty_label : e.empty_label
50
+ )}`, F = typeof i == "number" && (e.format === void 0 || e.format === "currency" || e.format === "number"), { box: D, probe: U } = ne(F ? h : "", o), T = d && F ? `${j}${ee(i, e.format)}` : h, W = a && a.reporting > 0 && a.reporting < a.total, q = E.length > 0;
47
51
  return (
48
52
  // Hover is a mouse convenience; the label button below is the keyboard path.
49
53
  // biome-ignore lint/a11y/noStaticElementInteractions: see above
@@ -52,11 +56,11 @@ function re({
52
56
  {
53
57
  className: "relative min-w-0 rounded-lg border border-slate-200 bg-white px-3 py-2 dark:border-border dark:bg-card",
54
58
  style: v ? { "--qsa": v[0], "--qsad": v[1] } : void 0,
55
- onMouseEnter: S ? () => p(!0) : void 0,
56
- onMouseLeave: S ? () => p(!1) : void 0,
59
+ onMouseEnter: q ? () => p(!0) : void 0,
60
+ onMouseLeave: q ? () => p(!1) : void 0,
57
61
  "data-stat-tile": e.label,
58
62
  children: [
59
- P && /* @__PURE__ */ l(
63
+ B && /* @__PURE__ */ l(
60
64
  "span",
61
65
  {
62
66
  "aria-hidden": "true",
@@ -72,7 +76,7 @@ function re({
72
76
  style: { backgroundColor: e.bg, filter: "saturate(2.2)" }
73
77
  }
74
78
  ),
75
- S ? (
79
+ q ? (
76
80
  // The breakdown is a disclosure: a real button so keyboard users reach it.
77
81
  /* @__PURE__ */ l(
78
82
  "button",
@@ -84,8 +88,8 @@ function re({
84
88
  onFocus: () => p(!0),
85
89
  onBlur: () => p(!1),
86
90
  onClick: () => p(!0),
87
- onKeyDown: (r) => {
88
- r.key === "Escape" && p(!1);
91
+ onKeyDown: (t) => {
92
+ t.key === "Escape" && p(!1);
89
93
  },
90
94
  title: e.label,
91
95
  children: e.label
@@ -96,16 +100,16 @@ function re({
96
100
  s ? /* @__PURE__ */ l("div", { className: "mt-1 h-5 w-24 animate-pulse rounded bg-slate-200/60 dark:bg-[hsl(var(--nvr-skeleton))]" }) : /* @__PURE__ */ y(
97
101
  "p",
98
102
  {
99
- ref: A,
100
- className: `relative mt-0.5 truncate leading-[22px] tabular-nums ${C ? "text-[13px] font-normal text-slate-500 dark:text-slate-400" : L ? "text-[13px] font-medium text-slate-600 dark:text-slate-300" : v ? "text-[15px] font-semibold text-[color:var(--qsa)] dark:text-[color:var(--qsad)]" : "text-[15px] font-semibold text-slate-800 dark:text-slate-100"}`,
101
- title: j !== h ? h : void 0,
103
+ ref: D,
104
+ className: `relative mt-0.5 truncate leading-[22px] tabular-nums ${O ? "text-[13px] font-normal text-slate-500 dark:text-slate-400" : M ? "text-[13px] font-medium text-slate-600 dark:text-slate-300" : v ? "text-[15px] font-semibold text-[color:var(--qsa)] dark:text-[color:var(--qsad)]" : "text-[15px] font-semibold text-slate-800 dark:text-slate-100"}`,
105
+ title: T !== h ? h : void 0,
102
106
  "data-stat-value": !0,
103
107
  children: [
104
- j,
108
+ T,
105
109
  /* @__PURE__ */ l(
106
110
  "span",
107
111
  {
108
- ref: B,
112
+ ref: U,
109
113
  "aria-hidden": "true",
110
114
  className: "pointer-events-none invisible absolute left-0 top-0 whitespace-nowrap",
111
115
  children: h
@@ -114,7 +118,7 @@ function re({
114
118
  ]
115
119
  }
116
120
  ),
117
- D && /* @__PURE__ */ y(
121
+ W && /* @__PURE__ */ y(
118
122
  "p",
119
123
  {
120
124
  className: "truncate text-[11px] tabular-nums text-slate-500 dark:text-slate-400",
@@ -128,15 +132,15 @@ function re({
128
132
  ]
129
133
  }
130
134
  ),
131
- m && S && /* @__PURE__ */ l(
135
+ m && q && /* @__PURE__ */ l(
132
136
  "div",
133
137
  {
134
138
  id: k,
135
139
  className: "absolute left-0 top-full z-40 mt-1 min-w-[220px] rounded-md border border-slate-200 bg-white p-2 shadow-lg dark:border-border dark:bg-popover",
136
- children: O.map((r) => /* @__PURE__ */ y("div", { className: "flex justify-between gap-4 py-0.5 text-[12px]", children: [
137
- /* @__PURE__ */ l("span", { className: "text-slate-500 dark:text-slate-400", children: r.label }),
138
- /* @__PURE__ */ l("span", { className: "tabular-nums text-slate-700 dark:text-slate-200", children: T(r.value, e.format) })
139
- ] }, r.label))
140
+ children: E.map((t) => /* @__PURE__ */ y("div", { className: "flex justify-between gap-4 py-0.5 text-[12px]", children: [
141
+ /* @__PURE__ */ l("span", { className: "text-slate-500 dark:text-slate-400", children: t.label }),
142
+ /* @__PURE__ */ l("span", { className: "tabular-nums text-slate-700 dark:text-slate-200", children: z(t.value, e.format) })
143
+ ] }, t.label))
140
144
  }
141
145
  )
142
146
  ]
@@ -144,40 +148,40 @@ function re({
144
148
  )
145
149
  );
146
150
  }
147
- function de({
151
+ function me({
148
152
  stats: e,
149
- rows: d,
150
- effectiveParams: f,
151
- loading: b
153
+ rows: c,
154
+ effectiveParams: b,
155
+ loading: f
152
156
  }) {
153
- const u = q(null), o = e.length, [x, m] = R(o), [p, k] = R({}), t = Object.values(p).some(Boolean), g = q(/* @__PURE__ */ new Map()), N = (n) => {
154
- let c = g.current.get(n);
155
- return c || (c = (s) => k((a) => a[n] === !s ? a : { ...a, [n]: !s }), g.current.set(n, c)), c;
157
+ const d = S(null), o = e.length, [x, m] = C(o), [p, k] = C({}), r = Object.values(p).some(Boolean), g = S(/* @__PURE__ */ new Map()), N = (n) => {
158
+ let u = g.current.get(n);
159
+ return u || (u = (s) => k((a) => a[n] === !s ? a : { ...a, [n]: !s }), g.current.set(n, u)), u;
156
160
  };
157
- return I(() => {
158
- const n = u.current;
161
+ return A(() => {
162
+ const n = d.current;
159
163
  if (!n || !o) return;
160
- const c = () => {
161
- const a = Math.max(1, Math.floor((n.clientWidth + F) / (ee + F))), _ = Math.ceil(o / a);
164
+ const u = () => {
165
+ const a = Math.max(1, Math.floor((n.clientWidth + P) / (re + P))), _ = Math.ceil(o / a);
162
166
  m(Math.ceil(o / _));
163
167
  };
164
- if (c(), typeof ResizeObserver > "u") return;
165
- const s = new ResizeObserver(c);
168
+ if (u(), typeof ResizeObserver > "u") return;
169
+ const s = new ResizeObserver(u);
166
170
  return s.observe(n), () => s.disconnect();
167
171
  }, [o]), o ? /* @__PURE__ */ l(
168
172
  "div",
169
173
  {
170
- ref: u,
174
+ ref: d,
171
175
  className: "grid gap-2 pb-3",
172
176
  style: { gridTemplateColumns: `repeat(${x}, minmax(0, 1fr))` },
173
177
  children: e.map((n) => /* @__PURE__ */ l(
174
- re,
178
+ ae,
175
179
  {
176
180
  stat: n,
177
- rows: d,
178
- effectiveParams: f,
179
- loading: b,
180
- compact: t,
181
+ rows: c,
182
+ effectiveParams: b,
183
+ loading: f,
184
+ compact: r,
181
185
  onFit: N(n.label)
182
186
  },
183
187
  n.label
@@ -186,5 +190,5 @@ function de({
186
190
  ) : null;
187
191
  }
188
192
  export {
189
- de as QueryStatStrip
193
+ me as QueryStatStrip
190
194
  };
@@ -1,15 +1,16 @@
1
- import { jsx as l, jsxs as i, Fragment as Ce } from "react/jsx-runtime";
1
+ import { jsx as l, jsxs as i, Fragment as qe } from "react/jsx-runtime";
2
2
  import { useQueryClient as Ne, useQuery as be } from "@tanstack/react-query";
3
- import { Loader2 as pe, X as ye, ChevronRight as qe } from "lucide-react";
4
- import { useState as N, useMemo as I, useCallback as je, useEffect as Oe } from "react";
3
+ import { Loader2 as pe, X as ye, ChevronRight as je } from "lucide-react";
4
+ import { useState as N, useMemo as I, useCallback as Oe, useEffect as Te } from "react";
5
5
  import { useNivaroClient as ke } from "../context.js";
6
6
  import { get as se, patch as we, post as he, del as ge } from "../lib/commands.js";
7
+ import { userErrorMessage as ve } from "../lib/safe-error.js";
7
8
  import { cn as G } from "../lib/utils.js";
8
- import { ChangeReasonDialog as ve, changeReasonChallenge as _e } from "./item-edit/ChangeReasonDialog.js";
9
- import { applyDisplayTemplate as Te } from "./item-edit/helpers.js";
9
+ import { ChangeReasonDialog as _e, changeReasonChallenge as $e } from "./item-edit/ChangeReasonDialog.js";
10
+ import { applyDisplayTemplate as Fe } from "./item-edit/helpers.js";
10
11
  import { RelationCombobox as xe } from "./item-edit/RelationCombobox.js";
11
- import { JsonMapEditor as Fe } from "./JsonMapEditor.js";
12
- import { colorPair as Ee } from "./QueryTable.js";
12
+ import { JsonMapEditor as Me } from "./JsonMapEditor.js";
13
+ import { colorPair as De } from "./QueryTable.js";
13
14
  const J = [
14
15
  "january",
15
16
  "february",
@@ -23,7 +24,7 @@ const J = [
23
24
  "october",
24
25
  "november",
25
26
  "december"
26
- ], $e = [
27
+ ], Se = [
27
28
  "Jan",
28
29
  "Feb",
29
30
  "Mar",
@@ -38,9 +39,9 @@ const J = [
38
39
  "Dec"
39
40
  ];
40
41
  function W(t, m) {
41
- return typeof t == "string" && t.startsWith("$scope.") ? m[t.slice(7)] : Array.isArray(t) ? t.map((D) => W(D, m)) : t && typeof t == "object" ? Object.fromEntries(
42
- Object.entries(t).map(([D, c]) => [
43
- D,
42
+ return typeof t == "string" && t.startsWith("$scope.") ? m[t.slice(7)] : Array.isArray(t) ? t.map((E) => W(E, m)) : t && typeof t == "object" ? Object.fromEntries(
43
+ Object.entries(t).map(([E, c]) => [
44
+ E,
44
45
  W(c, m)
45
46
  ])
46
47
  ) : t;
@@ -48,12 +49,12 @@ function W(t, m) {
48
49
  function fe(t) {
49
50
  return t === void 0 ? !0 : Array.isArray(t) ? t.some(fe) : t && typeof t == "object" ? Object.values(t).some(fe) : !1;
50
51
  }
51
- function We({ config: t }) {
52
- return t.browse ? /* @__PURE__ */ l(Le, { config: t }) : /* @__PURE__ */ l(Me, { config: t });
52
+ function Xe({ config: t }) {
53
+ return t.browse ? /* @__PURE__ */ l(Ae, { config: t }) : /* @__PURE__ */ l(Ee, { config: t });
53
54
  }
54
- function Me({ config: t }) {
55
+ function Ee({ config: t }) {
55
56
  var ce, re;
56
- const m = ke(), D = Ne(), [c, x] = N({}), [O, w] = N({}), [y, $] = N([]), [S, C] = N(/* @__PURE__ */ new Set()), [H, X] = N(!1), [oe, Z] = N(null), [P, z] = N(null), [j, h] = N(null), v = (t.scope ?? []).every(
57
+ const m = ke(), E = Ne(), [c, f] = N({}), [O, w] = N({}), [y, $] = N([]), [S, C] = N(/* @__PURE__ */ new Set()), [H, X] = N(!1), [oe, Z] = N(null), [P, z] = N(null), [j, h] = N(null), v = (t.scope ?? []).every(
57
58
  (r) => c[r.field] !== null && c[r.field] !== void 0 && c[r.field] !== ""
58
59
  ), g = JSON.stringify(c), de = I(() => {
59
60
  const r = [];
@@ -109,10 +110,10 @@ function Me({ config: t }) {
109
110
  ...y.map((r) => ({ key: r, record: null, isNew: !0 }))
110
111
  ];
111
112
  }, [t.row_source, L, Y, y, S]), B = (r, s) => {
112
- var T, f;
113
+ var T, x;
113
114
  const n = (T = O[r.key]) == null ? void 0 : T[s];
114
115
  if (n !== void 0) return n;
115
- const p = (f = r.record) == null ? void 0 : f[s];
116
+ const p = (x = r.record) == null ? void 0 : x[s];
116
117
  return p == null ? "" : String(p);
117
118
  }, k = (r, s, n) => w((p) => ({ ...p, [r]: { ...p[r] ?? {}, [s]: n } })), ee = Object.values(O).some((r) => Object.keys(r).length > 0) || y.length > 0 || S.size > 0;
118
119
  async function A(r) {
@@ -120,56 +121,56 @@ function Me({ config: t }) {
120
121
  X(!0), z(null);
121
122
  let s = 0, n = 0, p = 0;
122
123
  try {
123
- for (const f of _) {
124
- const q = O[f.key] ?? {}, V = Object.keys(q).length > 0;
125
- if (!f.record && !V) continue;
124
+ for (const x of _) {
125
+ const q = O[x.key] ?? {}, V = Object.keys(q).length > 0;
126
+ if (!x.record && !V) continue;
126
127
  const F = {};
127
- for (const [E, M] of Object.entries(q))
128
- !de.includes(E) && !(t.key_columns ?? []).some((K) => K.field === E) || (F[E] = M === "" ? null : Number.isNaN(Number(M)) ? M : Number(M));
128
+ for (const [M, D] of Object.entries(q))
129
+ !de.includes(M) && !(t.key_columns ?? []).some((K) => K.field === M) || (F[M] = D === "" ? null : Number.isNaN(Number(D)) ? D : Number(D));
129
130
  if (t.computed_total_field && ((T = t.month_sets) != null && T.length)) {
130
- const E = t.month_sets[0];
131
- F[t.computed_total_field] = J.reduce((M, K) => {
131
+ const M = t.month_sets[0];
132
+ F[t.computed_total_field] = J.reduce((D, K) => {
132
133
  var le;
133
- const Q = `${K}${E.suffix}`, ue = q[Q] !== void 0 ? Number(q[Q]) || 0 : Number((le = f.record) == null ? void 0 : le[Q]) || 0;
134
- return M + ue;
134
+ const Q = `${K}${M.suffix}`, ue = q[Q] !== void 0 ? Number(q[Q]) || 0 : Number((le = x.record) == null ? void 0 : le[Q]) || 0;
135
+ return D + ue;
135
136
  }, 0);
136
137
  }
137
- if (f.record) {
138
+ if (x.record) {
138
139
  if (Object.keys(F).length === 0) continue;
139
- r && (F._change_reason = r), await m.request(we(`/items/${t.collection}/${f.record.id}`, F)), n++;
140
+ r && (F._change_reason = r), await m.request(we(`/items/${t.collection}/${x.record.id}`, F)), n++;
140
141
  } else {
141
142
  if (!V) continue;
142
- for (const E of t.scope ?? []) F[E.field] = c[E.field];
143
- t.row_source && (F[t.row_source.fk_field] = f.sourceId), await m.request(he(`/items/${t.collection}`, F)), s++;
143
+ for (const M of t.scope ?? []) F[M.field] = c[M.field];
144
+ t.row_source && (F[t.row_source.fk_field] = x.sourceId), await m.request(he(`/items/${t.collection}`, F)), s++;
144
145
  }
145
146
  }
146
- for (const f of S)
147
- await m.request(ge(`/items/${t.collection}/${f}`)), p++;
147
+ for (const x of S)
148
+ await m.request(ge(`/items/${t.collection}/${x}`)), p++;
148
149
  if (t.after_save) {
149
- const f = W(t.after_save.params ?? {}, c);
150
+ const x = W(t.after_save.params ?? {}, c);
150
151
  await m.request(
151
- he(`/custom-queries/${t.after_save.query_slug}/execute`, { params: f })
152
+ he(`/custom-queries/${t.after_save.query_slug}/execute`, { params: x })
152
153
  );
153
154
  }
154
- w({}), $([]), C(/* @__PURE__ */ new Set()), await D.invalidateQueries({ queryKey: ["record-grid-rows", t.collection] }), z(
155
+ w({}), $([]), C(/* @__PURE__ */ new Set()), await E.invalidateQueries({ queryKey: ["record-grid-rows", t.collection] }), z(
155
156
  `Saved — ${n} updated, ${s} created${p ? `, ${p} deleted` : ""}`
156
157
  );
157
- } catch (f) {
158
- const q = _e(f);
159
- q ? (Z(q), z(null)) : z(`Save failed: ${f instanceof Error ? f.message : "unknown error"}`);
158
+ } catch (x) {
159
+ const q = $e(x);
160
+ q ? (Z(q), z(null)) : z(`Save failed: ${ve(x, "unknown error")}`);
160
161
  } finally {
161
162
  X(!1);
162
163
  }
163
164
  }
164
165
  const te = [
165
166
  ...(t.month_sets ?? []).flatMap(
166
- (r) => J.map((s, n) => ({ field: `${s}${r.suffix}`, label: `${$e[n]} ${r.label}` }))
167
+ (r) => J.map((s, n) => ({ field: `${s}${r.suffix}`, label: `${Se[n]} ${r.label}` }))
167
168
  ),
168
169
  ...(t.columns ?? []).map((r) => ({ field: r.field, label: r.label ?? r.field }))
169
170
  ];
170
171
  return /* @__PURE__ */ i("div", { className: "flex h-full flex-col gap-3 overflow-auto p-3", children: [
171
172
  /* @__PURE__ */ l(
172
- ve,
173
+ _e,
173
174
  {
174
175
  challenge: oe,
175
176
  onCancel: () => Z(null),
@@ -189,7 +190,7 @@ function Me({ config: t }) {
189
190
  collection: r.collection,
190
191
  value: c[r.field] ?? null,
191
192
  onChange: (p) => {
192
- x((T) => ({ ...T, [r.field]: p })), w({}), $([]), C(/* @__PURE__ */ new Set());
193
+ f((T) => ({ ...T, [r.field]: p })), w({}), $([]), C(/* @__PURE__ */ new Set());
193
194
  },
194
195
  extraFilter: n,
195
196
  placeholder: "Select…"
@@ -265,7 +266,7 @@ function Me({ config: t }) {
265
266
  }
266
267
  )
267
268
  ] }),
268
- /* @__PURE__ */ l("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ l(Fe, { config: t.toolbar_editors[j].json_map, scope: c }) })
269
+ /* @__PURE__ */ l("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ l(Me, { config: t.toolbar_editors[j].json_map, scope: c }) })
269
270
  ]
270
271
  }
271
272
  )
@@ -353,13 +354,13 @@ function Me({ config: t }) {
353
354
  ] });
354
355
  }
355
356
  const R = (t, m) => t == null || !Number.isFinite(t) || m != null && m.blankZero && t === 0 ? "—" : t.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 });
356
- function De({
357
+ function Le({
357
358
  value: t,
358
359
  original: m,
359
- onChange: D,
360
+ onChange: E,
360
361
  disabled: c
361
362
  }) {
362
- const [x, O] = N(!1), w = t !== m, y = t === "" ? null : Number(t), $ = x || y == null || Number.isNaN(y) ? t : R(y), S = w && y != null && !Number.isNaN(y) ? y - (Number(m) || 0) : 0;
363
+ const [f, O] = N(!1), w = t !== m, y = t === "" ? null : Number(t), $ = f || y == null || Number.isNaN(y) ? t : R(y), S = w && y != null && !Number.isNaN(y) ? y - (Number(m) || 0) : 0;
363
364
  return /* @__PURE__ */ l(
364
365
  "input",
365
366
  {
@@ -370,7 +371,7 @@ function De({
370
371
  title: w ? `Was ${R(Number(m) || 0)} (${S >= 0 ? "+" : "−"}${R(Math.abs(S))})` : void 0,
371
372
  onFocus: () => O(!0),
372
373
  onBlur: () => O(!1),
373
- onChange: (C) => D(C.target.value.replace(/[^\d.-]/g, "")),
374
+ onChange: (C) => E(C.target.value.replace(/[^\d.-]/g, "")),
374
375
  className: G(
375
376
  "h-7 w-[92px] rounded-md border bg-white px-1.5 text-right text-[12px] tabular-nums outline-none transition-colors focus:border-nvr-cyan disabled:bg-transparent dark:bg-background",
376
377
  w ? "border-nvr-cyan bg-nvr-cyan/[0.06] dark:bg-nvr-cyan/10" : "border-slate-200 dark:border-border",
@@ -379,13 +380,13 @@ function De({
379
380
  }
380
381
  );
381
382
  }
382
- function Le({ config: t }) {
383
+ function Ae({ config: t }) {
383
384
  var ue, le;
384
- const m = ke(), D = Ne(), c = t.key_columns ?? [], [x, O] = N({}), [w, y] = N({}), [$, S] = N([]), [C, H] = N(/* @__PURE__ */ new Set()), [X, oe] = N(!1), [Z, P] = N(null), [z, j] = N(null), h = c.length > 0 && c.every((e) => x[e.field] != null && x[e.field] !== ""), v = I(() => {
385
+ const m = ke(), E = Ne(), c = t.key_columns ?? [], [f, O] = N({}), [w, y] = N({}), [$, S] = N([]), [C, H] = N(/* @__PURE__ */ new Set()), [X, oe] = N(!1), [Z, P] = N(null), [z, j] = N(null), h = c.length > 0 && c.every((e) => f[e.field] != null && f[e.field] !== ""), v = I(() => {
385
386
  const e = (t.month_sets ?? []).flatMap(
386
387
  (a) => J.map((d, u) => ({
387
388
  field: `${d}${a.suffix}`,
388
- label: `${$e[u]}${a.label ? ` ${a.label}` : ""}`
389
+ label: `${Se[u]}${a.label ? ` ${a.label}` : ""}`
389
390
  }))
390
391
  ), o = (t.columns ?? []).map((a) => ({
391
392
  field: a.field,
@@ -410,14 +411,14 @@ function Le({ config: t }) {
410
411
  se(`/items/${o.collection}`, { limit: 1e3 })
411
412
  ).then((b) => b.data ?? []).catch(() => []), u = /* @__PURE__ */ new Map();
412
413
  for (const b of d)
413
- u.set(String(b.id), Te(a == null ? void 0 : a.display_template, b) || String(b.id));
414
+ u.set(String(b.id), Fe(a == null ? void 0 : a.display_template, b) || String(b.id));
414
415
  e[o.field] = u;
415
416
  })
416
417
  ), e;
417
418
  },
418
419
  enabled: c.length > 0,
419
420
  staleTime: 3e5
420
- }), L = je(
421
+ }), L = Oe(
421
422
  (e, o) => {
422
423
  var a;
423
424
  return o == null ? "—" : ((a = ne[e]) == null ? void 0 : a.get(String(o))) ?? String(o);
@@ -426,11 +427,11 @@ function Le({ config: t }) {
426
427
  ), _ = I(
427
428
  () => de.filter(
428
429
  (e) => c.every(
429
- (o) => x[o.field] == null || x[o.field] === "" || String(e[o.field]) === String(x[o.field])
430
+ (o) => f[o.field] == null || f[o.field] === "" || String(e[o.field]) === String(f[o.field])
430
431
  )
431
432
  ),
432
- [de, c, x]
433
- ), B = (le = c[0]) == null ? void 0 : le.field, k = c.filter((e) => x[e.field] == null || x[e.field] === ""), ee = I(() => {
433
+ [de, c, f]
434
+ ), B = (le = c[0]) == null ? void 0 : le.field, k = c.filter((e) => f[e.field] == null || f[e.field] === ""), ee = I(() => {
434
435
  if (h) return [];
435
436
  const e = /* @__PURE__ */ new Map();
436
437
  for (const o of _) {
@@ -456,7 +457,7 @@ function Le({ config: t }) {
456
457
  ..._.filter((e) => !C.has(String(e.id))).map((e) => ({ key: `rec-${e.id}`, record: e, isNew: !1 })),
457
458
  ...$.map((e) => ({ key: e, record: null, isNew: !0 }))
458
459
  ] : [], [_, h, $, C]);
459
- Oe(() => {
460
+ Te(() => {
460
461
  h && _.length === 0 && $.length === 0 && C.size === 0 && S([`new-${Date.now()}`]);
461
462
  }, [h, _.length, $.length, C.size]);
462
463
  const ie = (e, o) => {
@@ -485,33 +486,33 @@ function Le({ config: t }) {
485
486
  if (Object.keys(b).length === 0) continue;
486
487
  const U = {};
487
488
  for (const [ae, me] of Object.entries(b))
488
- v.some((Se) => Se.field === ae) && (U[ae] = me === "" ? null : Number.isNaN(Number(me)) ? me : Number(me));
489
+ v.some((Ce) => Ce.field === ae) && (U[ae] = me === "" ? null : Number.isNaN(Number(me)) ? me : Number(me));
489
490
  if (t.computed_total_field && g && (U[t.computed_total_field] = re(u)), u.record)
490
491
  e && (U._change_reason = e), await m.request(we(`/items/${t.collection}/${u.record.id}`, U)), a++;
491
492
  else {
492
- for (const ae of c) U[ae.field] = x[ae.field];
493
+ for (const ae of c) U[ae.field] = f[ae.field];
493
494
  await m.request(he(`/items/${t.collection}`, U)), o++;
494
495
  }
495
496
  }
496
497
  for (const u of C)
497
498
  await m.request(ge(`/items/${t.collection}/${u}`)), d++;
498
499
  if (t.after_save) {
499
- const u = W(t.after_save.params ?? {}, x);
500
+ const u = W(t.after_save.params ?? {}, f);
500
501
  await m.request(
501
502
  he(`/custom-queries/${t.after_save.query_slug}/execute`, { params: u })
502
503
  );
503
504
  }
504
- s(), await D.invalidateQueries({ queryKey: ["record-grid-browse-rows", t.collection] }), j(
505
+ s(), await E.invalidateQueries({ queryKey: ["record-grid-browse-rows", t.collection] }), j(
505
506
  `Saved — ${a} updated, ${o} created${d ? `, ${d} deleted` : ""}`
506
507
  );
507
508
  } catch (u) {
508
- const b = _e(u);
509
- b ? P(b) : j(`Save failed: ${u instanceof Error ? u.message : "unknown error"}`);
509
+ const b = $e(u);
510
+ b ? P(b) : j(`Save failed: ${ve(u, "unknown error")}`);
510
511
  } finally {
511
512
  oe(!1);
512
513
  }
513
514
  }
514
- const f = (e) => h ? A.reduce((o, a) => o + (Number(ie(a, e)) || 0), 0) : ee.reduce((o, a) => o + (a.sums[e] ?? 0), 0), q = (e) => g && e < 12 && e % 3 === 0 && e > 0, V = (e) => g && e < 12 && Math.floor(e / 3) % 2 === 1 ? "bg-slate-50/70 dark:bg-muted/30" : "", [F, E] = Ee("accent"), M = { "--qtc": F, "--qtcd": E }, K = "text-[color:var(--qtc)] dark:text-[color:var(--qtcd)]", Q = (e, o, a = "") => /* @__PURE__ */ l(
515
+ const x = (e) => h ? A.reduce((o, a) => o + (Number(ie(a, e)) || 0), 0) : ee.reduce((o, a) => o + (a.sums[e] ?? 0), 0), q = (e) => g && e < 12 && e % 3 === 0 && e > 0, V = (e) => g && e < 12 && Math.floor(e / 3) % 2 === 1 ? "bg-slate-50/70 dark:bg-muted/30" : "", [F, M] = De("accent"), D = { "--qtc": F, "--qtcd": M }, K = "text-[color:var(--qtc)] dark:text-[color:var(--qtcd)]", Q = (e, o, a = "") => /* @__PURE__ */ l(
515
516
  "th",
516
517
  {
517
518
  className: G(
@@ -526,7 +527,7 @@ function Le({ config: t }) {
526
527
  );
527
528
  return /* @__PURE__ */ i("div", { className: "flex h-full min-h-0 flex-col", "data-record-grid-browse": !0, children: [
528
529
  /* @__PURE__ */ l(
529
- ve,
530
+ _e,
530
531
  {
531
532
  challenge: Z,
532
533
  onCancel: () => P(null),
@@ -542,7 +543,7 @@ function Le({ config: t }) {
542
543
  xe,
543
544
  {
544
545
  collection: e.collection,
545
- value: x[e.field] ?? null,
546
+ value: f[e.field] ?? null,
546
547
  onChange: (o) => p(e.field, o),
547
548
  placeholder: "All",
548
549
  optionSort: e.collection === "funding_years" ? "-id" : void 0
@@ -588,7 +589,7 @@ function Le({ config: t }) {
588
589
  h ? /* @__PURE__ */ i("span", { children: [
589
590
  "Editing",
590
591
  " ",
591
- /* @__PURE__ */ l("strong", { className: "text-slate-700 dark:text-slate-200", children: c.map((e) => L(e.field, x[e.field])).join(" · ") }),
592
+ /* @__PURE__ */ l("strong", { className: "text-slate-700 dark:text-slate-200", children: c.map((e) => L(e.field, f[e.field])).join(" · ") }),
592
593
  A.length > 1 && ` — ${A.length} rows share this combination`
593
594
  ] }) : /* @__PURE__ */ i("span", { children: [
594
595
  "Totals across",
@@ -596,7 +597,7 @@ function Le({ config: t }) {
596
597
  /* @__PURE__ */ l("strong", { className: "text-slate-700 dark:text-slate-200", children: _.length }),
597
598
  " row",
598
599
  _.length === 1 ? "" : "s",
599
- k.length > 0 && /* @__PURE__ */ i(Ce, { children: [
600
+ k.length > 0 && /* @__PURE__ */ i(qe, { children: [
600
601
  ", by ",
601
602
  k.map((e) => e.label ?? e.field).join(" and "),
602
603
  " — pick",
@@ -605,7 +606,7 @@ function Le({ config: t }) {
605
606
  " to edit"
606
607
  ] })
607
608
  ] }),
608
- Object.keys(x).some((e) => x[e] != null && x[e] !== "") && /* @__PURE__ */ i(
609
+ Object.keys(f).some((e) => f[e] != null && f[e] !== "") && /* @__PURE__ */ i(
609
610
  "button",
610
611
  {
611
612
  type: "button",
@@ -651,7 +652,7 @@ function Le({ config: t }) {
651
652
  V(d)
652
653
  ),
653
654
  children: /* @__PURE__ */ l(
654
- De,
655
+ Le,
655
656
  {
656
657
  value: ie(e, a.field),
657
658
  original: te(e, a.field),
@@ -665,7 +666,7 @@ function Le({ config: t }) {
665
666
  "td",
666
667
  {
667
668
  className: `border-l border-slate-200 px-2 py-1 text-right font-semibold tabular-nums dark:border-border ${K}`,
668
- style: M,
669
+ style: D,
669
670
  children: R(re(e))
670
671
  }
671
672
  ),
@@ -709,7 +710,7 @@ function Le({ config: t }) {
709
710
  d === 0 && "sticky left-0 z-[1] bg-white font-medium dark:bg-card"
710
711
  ),
711
712
  children: [
712
- d === 0 && /* @__PURE__ */ l(qe, { className: "mr-1 inline h-3 w-3 text-slate-300" }),
713
+ d === 0 && /* @__PURE__ */ l(je, { className: "mr-1 inline h-3 w-3 text-slate-300" }),
713
714
  L(a.field, e.keyVals[a.field]),
714
715
  d === k.length - 1 && e.count > 1 && /* @__PURE__ */ i("span", { className: "ml-1.5 text-[10.5px] text-slate-400", children: [
715
716
  e.count,
@@ -736,7 +737,7 @@ function Le({ config: t }) {
736
737
  "td",
737
738
  {
738
739
  className: `border-l border-slate-200 px-2 py-1.5 text-right font-semibold tabular-nums dark:border-border ${K}`,
739
- style: M,
740
+ style: D,
740
741
  children: R(
741
742
  J.reduce(
742
743
  (a, d) => a + (e.sums[`${d}${g.suffix}`] ?? 0),
@@ -769,7 +770,7 @@ function Le({ config: t }) {
769
770
  q(o) && "border-l border-slate-200 dark:border-border",
770
771
  V(o)
771
772
  ),
772
- children: R(f(e.field))
773
+ children: R(x(e.field))
773
774
  },
774
775
  e.field
775
776
  )),
@@ -777,8 +778,8 @@ function Le({ config: t }) {
777
778
  "td",
778
779
  {
779
780
  className: `border-l border-slate-200 px-2 py-2 text-right font-semibold tabular-nums dark:border-border ${K}`,
780
- style: M,
781
- children: R(J.reduce((e, o) => e + f(`${o}${g.suffix}`), 0))
781
+ style: D,
782
+ children: R(J.reduce((e, o) => e + x(`${o}${g.suffix}`), 0))
782
783
  }
783
784
  ),
784
785
  h && t.allow_delete && /* @__PURE__ */ l("td", {})
@@ -787,5 +788,5 @@ function Le({ config: t }) {
787
788
  ] });
788
789
  }
789
790
  export {
790
- We as RecordGridEditor
791
+ Xe as RecordGridEditor
791
792
  };