@nivaro/react 0.3.9 → 0.3.10

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 (47) 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 +69 -1
  6. package/dist/index.js +512 -501
  7. package/dist/shared/components/CollectionBrowserView.js +1000 -1001
  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 +3687 -3580
  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 +146 -145
  15. package/dist/shared/components/RecordGridEditor.js +76 -75
  16. package/dist/shared/components/ai/AiMemorySuggestions.js +15 -14
  17. package/dist/shared/components/ai/AskPanel.js +55 -54
  18. package/dist/shared/components/bulk/BulkActionButtons.js +30 -29
  19. package/dist/shared/components/bulk/PushBulkButtons.js +57 -56
  20. package/dist/shared/components/chat/SlashCommands.js +30 -29
  21. package/dist/shared/components/chat/chat-outbox.js +76 -75
  22. package/dist/shared/components/help-videos/recorder/useLeaveWarning.js +6 -5
  23. package/dist/shared/components/integrations/console/SignalCard.js +124 -123
  24. package/dist/shared/components/integrations/console/SnoozeMenu.js +24 -23
  25. package/dist/shared/components/item-edit/CloneDialog.js +85 -78
  26. package/dist/shared/components/item-edit/InlineTableField.js +301 -300
  27. package/dist/shared/components/item-edit/MembershipSetField.js +24 -23
  28. package/dist/shared/components/item-edit/QuickCreateButton.js +8 -7
  29. package/dist/shared/components/item-edit/RecordLiveSync.js +101 -100
  30. package/dist/shared/components/item-edit/staged-links.js +86 -0
  31. package/dist/shared/components/layout-editor/LayoutEditor.js +275 -274
  32. package/dist/shared/components/layout-editor/editors/cascade-rule-row.js +18 -17
  33. package/dist/shared/components/layout-editor/inspector/HelpTab.js +37 -36
  34. package/dist/shared/components/layout-editor/matrix/FieldStateMatrix.js +50 -49
  35. package/dist/shared/components/profile/AiMemoryCard.js +15 -14
  36. package/dist/shared/components/profile/PersonAdminTools.js +70 -67
  37. package/dist/shared/components/queue/QueueItemSheet.js +36 -35
  38. package/dist/shared/components/queue/QueueWorklist.js +597 -598
  39. package/dist/shared/lib/client-version.js +63 -0
  40. package/dist/shared/lib/force-reload.js +36 -0
  41. package/dist/shared/lib/load-error.js +11 -10
  42. package/dist/shared/lib/presence-live.js +54 -35
  43. package/dist/shared/lib/record-outbox.js +76 -75
  44. package/dist/shared/lib/safe-error.js +39 -0
  45. package/dist/shared/lib/server-clock.js +11 -7
  46. package/dist/shared/lib/unsaved-work.js +62 -0
  47. package/package.json +1 -1
@@ -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
  };
@@ -1,17 +1,18 @@
1
- import { jsxs as a, jsx as n, Fragment as p } from "react/jsx-runtime";
1
+ import { jsxs as a, jsx as n, Fragment as x } from "react/jsx-runtime";
2
2
  import { useQueryClient as w, useQuery as C } from "@tanstack/react-query";
3
3
  import { Brain as A, Check as q, X as S } from "lucide-react";
4
4
  import { useState as f } from "react";
5
- import { useOptionalNivaroClient as L, useNavigation as R } from "../../context.js";
6
- import { get as _, post as j } from "../../lib/commands.js";
5
+ import { useOptionalNivaroClient as L, useNavigation as M } from "../../context.js";
6
+ import { get as R, post as _ } from "../../lib/commands.js";
7
+ import { userErrorMessage as j } from "../../lib/safe-error.js";
7
8
  import { cn as E } from "../../lib/utils.js";
8
- function P({
9
+ function U({
9
10
  suggestions: y,
10
11
  className: h
11
12
  }) {
12
- const i = L(), g = w(), [c, o] = f({}), [m, u] = f(null), v = R(), d = (y ?? []).filter((e) => e && typeof e.text == "string" && e.text), { data: l } = C({
13
+ const i = L(), g = w(), [c, o] = f({}), [m, u] = f(null), v = M(), d = (y ?? []).filter((e) => e && typeof e.text == "string" && e.text), { data: l } = C({
13
14
  queryKey: ["nvr-profile-prefs"],
14
- queryFn: () => i.request(_("/users/me")).then((e) => {
15
+ queryFn: () => i.request(R("/users/me")).then((e) => {
15
16
  var r;
16
17
  return ((r = e.data) == null ? void 0 : r.preferences) ?? {};
17
18
  }),
@@ -24,19 +25,19 @@ function P({
24
25
  var r;
25
26
  u(null), o((t) => ({ ...t, [e]: "saving" }));
26
27
  try {
27
- await i.request(j("/ai/memory", { text: e })), o((t) => ({ ...t, [e]: "saved" })), g.invalidateQueries({ queryKey: ["nvr-profile-prefs"] });
28
+ await i.request(_("/ai/memory", { text: e })), o((t) => ({ ...t, [e]: "saved" })), g.invalidateQueries({ queryKey: ["nvr-profile-prefs"] });
28
29
  } catch (t) {
29
30
  o((N) => ({ ...N, [e]: "idle" }));
30
31
  const s = (r = t == null ? void 0 : t.response) == null ? void 0 : r.data;
31
32
  u({
32
- text: (s == null ? void 0 : s.error) ?? (t instanceof Error ? t.message : "Could not remember that"),
33
+ text: (s == null ? void 0 : s.error) ?? j(t, "Could not remember that"),
33
34
  // A full memory refuses — nothing is dropped; the person picks on Profile.
34
35
  full: (s == null ? void 0 : s.code) === "AI_MEMORY_FULL"
35
36
  });
36
37
  }
37
- }, x = d.filter((e) => c[e.text] !== "dismissed");
38
- return x.length === 0 ? null : /* @__PURE__ */ a("div", { className: E("mt-2 space-y-1", h), "data-ai-memory-suggestions": !0, children: [
39
- x.map((e) => {
38
+ }, p = d.filter((e) => c[e.text] !== "dismissed");
39
+ return p.length === 0 ? null : /* @__PURE__ */ a("div", { className: E("mt-2 space-y-1", h), "data-ai-memory-suggestions": !0, children: [
40
+ p.map((e) => {
40
41
  const r = c[e.text] ?? "idle", t = r === "saved" || b.has(e.text.toLowerCase());
41
42
  return /* @__PURE__ */ a(
42
43
  "div",
@@ -50,7 +51,7 @@ function P({
50
51
  "Remembered: “",
51
52
  e.text,
52
53
  "” — see Profile → Ask AI memory."
53
- ] }) : /* @__PURE__ */ a(p, { children: [
54
+ ] }) : /* @__PURE__ */ a(x, { children: [
54
55
  /* @__PURE__ */ a("span", { className: "min-w-0 flex-1 text-slate-700 dark:text-slate-200", children: [
55
56
  /* @__PURE__ */ n("span", { className: "font-medium", children: "Remember this?" }),
56
57
  " ",
@@ -93,7 +94,7 @@ function P({
93
94
  }),
94
95
  m && /* @__PURE__ */ a("p", { className: "text-[11.5px] text-red-600", "data-ai-memory-error": !0, children: [
95
96
  m.text,
96
- m.full && /* @__PURE__ */ a(p, { children: [
97
+ m.full && /* @__PURE__ */ a(x, { children: [
97
98
  " ",
98
99
  /* @__PURE__ */ n(
99
100
  "button",
@@ -110,5 +111,5 @@ function P({
110
111
  ] });
111
112
  }
112
113
  export {
113
- P as AiMemorySuggestions
114
+ U as AiMemorySuggestions
114
115
  };