@nivaro/react 0.3.64 → 0.3.66

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 (74) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +62 -8
  4. package/dist/shared/components/CollectionBrowserView.js +3127 -3204
  5. package/dist/shared/components/ConformanceView.js +235 -221
  6. package/dist/shared/components/DataTable.js +478 -459
  7. package/dist/shared/components/ItemEditForm.js +4842 -4500
  8. package/dist/shared/components/MyWorkView.js +124 -113
  9. package/dist/shared/components/PageRenderer.js +146 -138
  10. package/dist/shared/components/ProfileView.js +483 -472
  11. package/dist/shared/components/RecordDrilldownSheet.js +73 -65
  12. package/dist/shared/components/ReportView.js +1100 -1094
  13. package/dist/shared/components/bulk/BulkActionButtons.js +72 -72
  14. package/dist/shared/components/bulk/BulkCompareButton.js +62 -0
  15. package/dist/shared/components/bulk/BulkFieldUpdate.js +114 -103
  16. package/dist/shared/components/bulk/BulkFieldUpdateButton.js +73 -0
  17. package/dist/shared/components/bulk/MessageStakeholders.js +235 -0
  18. package/dist/shared/components/bulk/bulk-field-options.js +29 -23
  19. package/dist/shared/components/integrations/IntegrationObligationsView.js +191 -173
  20. package/dist/shared/components/integrations/IntegrationStatusLines.js +101 -85
  21. package/dist/shared/components/integrations/RecordIntegrationPreview.js +11 -9
  22. package/dist/shared/components/integrations/SendCurrentData.js +126 -0
  23. package/dist/shared/components/item-edit/CatalogPickerField.js +1535 -1440
  24. package/dist/shared/components/item-edit/FieldRenderer.js +49 -45
  25. package/dist/shared/components/item-edit/FieldRow.js +413 -403
  26. package/dist/shared/components/item-edit/GroupSection.js +555 -538
  27. package/dist/shared/components/item-edit/InlineTableField.js +2903 -2816
  28. package/dist/shared/components/item-edit/M2MCombobox.js +407 -338
  29. package/dist/shared/components/item-edit/MidairCollisionDialog.js +367 -116
  30. package/dist/shared/components/item-edit/NestedRelationEditor.js +171 -163
  31. package/dist/shared/components/item-edit/PlanGrid.js +783 -724
  32. package/dist/shared/components/item-edit/QuickCreateButton.js +291 -224
  33. package/dist/shared/components/item-edit/RecordInsights.js +113 -111
  34. package/dist/shared/components/item-edit/RecordLiveSync.js +4 -1
  35. package/dist/shared/components/item-edit/RelationCombobox.js +398 -364
  36. package/dist/shared/components/item-edit/SummaryPanel.js +146 -144
  37. package/dist/shared/components/item-edit/UserChip.js +264 -229
  38. package/dist/shared/components/item-edit/cascade-clear-notice.js +56 -0
  39. package/dist/shared/components/item-edit/collision-format.js +37 -0
  40. package/dist/shared/components/item-edit/field-a11y.js +25 -0
  41. package/dist/shared/components/item-edit/header-path-preview.js +52 -0
  42. package/dist/shared/components/item-edit/line-merge.js +84 -0
  43. package/dist/shared/components/item-edit/line-midair.js +94 -87
  44. package/dist/shared/components/item-edit/move-guard.js +17 -0
  45. package/dist/shared/components/item-edit/picker-search.js +27 -16
  46. package/dist/shared/components/item-edit/rail-width.js +8 -0
  47. package/dist/shared/components/monitoring/InactiveUserLinksView.js +126 -124
  48. package/dist/shared/components/panels/AccessDeniedPanel.js +96 -55
  49. package/dist/shared/components/panels/CommentPanel.js +142 -136
  50. package/dist/shared/components/panels/ItemLockBanner.js +246 -240
  51. package/dist/shared/components/panels/PipelinePanel.js +1366 -1194
  52. package/dist/shared/components/panels/RevisionsPanel.js +106 -102
  53. package/dist/shared/components/panels/SlaBreachBanner.js +16 -20
  54. package/dist/shared/components/panels/SlaClock.js +90 -68
  55. package/dist/shared/components/queue/QueueItemSheet.js +94 -87
  56. package/dist/shared/components/queue/QueueWorklist.js +1522 -1347
  57. package/dist/shared/components/queue/worklist-csv.js +75 -0
  58. package/dist/shared/components/queue/worklist-helpers.js +20 -0
  59. package/dist/shared/components/widgets/ReviewListWidget.js +226 -207
  60. package/dist/shared/lib/bulk-copy.js +17 -0
  61. package/dist/shared/lib/cbv-export.js +122 -0
  62. package/dist/shared/lib/delete-offer.js +13 -0
  63. package/dist/shared/lib/error-hints.js +1 -0
  64. package/dist/shared/lib/leave-guard.js +41 -26
  65. package/dist/shared/lib/list-link.js +72 -56
  66. package/dist/shared/lib/live-queries.js +32 -30
  67. package/dist/shared/lib/moved-notice.js +25 -0
  68. package/dist/shared/lib/notification-target.js +56 -54
  69. package/dist/shared/lib/obligation-banner.js +11 -8
  70. package/dist/shared/lib/obligation-reason-text.js +6 -6
  71. package/dist/shared/lib/quick-filter-cascade.js +29 -19
  72. package/dist/shared/lib/sort-cycle.js +6 -0
  73. package/dist/shared/lib/summary-mode.js +59 -41
  74. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import { jsxs as l, jsx as t, Fragment as L } from "react/jsx-runtime";
2
2
  import { useQuery as P, useQueryClient as ee, useMutation as Q } from "@tanstack/react-query";
3
- import { Clock as Y, Search as Ce, X as _e, CalendarClock as Te, GitCompareArrows as Re, ChevronDown as je, ChevronRight as Ae, MessageSquare as Le, RotateCcw as ie, ArrowRight as $e } from "lucide-react";
3
+ import { Clock as Y, Search as Ce, X as _e, CalendarClock as Te, GitCompareArrows as Re, ChevronDown as je, ChevronRight as Ae, MessageSquare as Le, RotateCcw as oe, ArrowRight as $e } from "lucide-react";
4
4
  import { useState as w, useRef as Oe, useMemo as R, createContext as De, useEffect as qe, useContext as ce } from "react";
5
5
  import { toast as A } from "sonner";
6
6
  import { useNivaroClient as F } from "../../context.js";
@@ -38,7 +38,7 @@ function ue(e, s) {
38
38
  enabled: s,
39
39
  staleTime: 3e5,
40
40
  queryFn: async () => {
41
- const [o, i] = await Promise.all([
41
+ const [i, o] = await Promise.all([
42
42
  d.request(q(`/field-config/${e}`)).then((n) => n.data ?? []).catch(() => []),
43
43
  d.request(
44
44
  q(`/collections/${e}`)
@@ -47,18 +47,18 @@ function ue(e, s) {
47
47
  return ((r = n.data) == null ? void 0 : r.relations) ?? [];
48
48
  }).catch(() => [])
49
49
  ]);
50
- return { fields: o, relations: i };
50
+ return { fields: i, relations: o };
51
51
  }
52
52
  });
53
53
  return R(() => {
54
- const o = /* @__PURE__ */ new Map(), i = (n) => {
54
+ const i = /* @__PURE__ */ new Map(), o = (n) => {
55
55
  const r = ((a == null ? void 0 : a.relations) ?? []).find(
56
56
  (m) => m.many_collection === e && m.many_field === n && m.junction_field == null
57
57
  );
58
58
  return r != null && r.one_collection ? r.one_collection === "directus_users" ? "nivaro_users" : r.one_collection : null;
59
59
  };
60
60
  for (const n of (a == null ? void 0 : a.fields) ?? [])
61
- n.field.startsWith("__") || o.set(n.field, {
61
+ n.field.startsWith("__") || i.set(n.field, {
62
62
  label: n.label || me(n.field.replace(/_/g, " ")),
63
63
  // Hidden fields are machine columns (e.g. the retired "workflow_state
64
64
  // (legacy)" a save still writes) — folded with the system fields, not
@@ -67,10 +67,10 @@ function ue(e, s) {
67
67
  // layout_assigned is only stamped when the collection HAS an active
68
68
  // layout — absent means there's no layout to be off of.
69
69
  onLayout: n.layout_assigned !== !1,
70
- relatedCollection: i(n.field),
70
+ relatedCollection: o(n.field),
71
71
  dateOnly: String(n.type ?? "").toLowerCase() === "date"
72
72
  });
73
- return o;
73
+ return i;
74
74
  }, [a, e]);
75
75
  }
76
76
  function k(e, s) {
@@ -111,7 +111,7 @@ function U(e) {
111
111
  function rt({ collection: e, id: s }) {
112
112
  const d = F(), { data: a } = P({
113
113
  queryKey: ["col-meta", e],
114
- queryFn: () => d.request(q(`/collections/${e}`)).then((o) => o.data),
114
+ queryFn: () => d.request(q(`/collections/${e}`)).then((i) => i.data),
115
115
  staleTime: 3e5,
116
116
  retry: !1
117
117
  });
@@ -133,17 +133,17 @@ function de({
133
133
  tone: s,
134
134
  dateOnly: d
135
135
  }) {
136
- const [a, o] = w(!1), i = at(e, d);
137
- if (i === "")
136
+ const [a, i] = w(!1), o = at(e, d);
137
+ if (o === "")
138
138
  return /* @__PURE__ */ t("span", { className: "text-[11.5px] italic text-slate-300 dark:text-slate-600", children: "empty" });
139
- const n = i.length > le, r = a || !n ? i : `${i.slice(0, le)}…`;
139
+ const n = o.length > le, r = a || !n ? o : `${o.slice(0, le)}…`;
140
140
  return /* @__PURE__ */ l("span", { className: "break-words text-[12px] leading-relaxed text-slate-700 dark:text-slate-300", children: [
141
141
  typeof e == "object" ? /* @__PURE__ */ t("span", { className: "font-mono text-[11px]", children: r }) : r,
142
142
  n && /* @__PURE__ */ t(
143
143
  "button",
144
144
  {
145
145
  type: "button",
146
- onClick: () => o((m) => !m),
146
+ onClick: () => i((m) => !m),
147
147
  className: T(
148
148
  "ml-1 text-[10.5px] font-medium hover:underline",
149
149
  s === "before" ? "text-rose-500" : "text-emerald-600"
@@ -168,21 +168,21 @@ function nt({
168
168
  before: e,
169
169
  after: s
170
170
  }) {
171
- const a = Array.from(/* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(s)])).sort().map((i) => {
172
- const n = i in e ? JSON.stringify(e[i]) : void 0, r = i in s ? JSON.stringify(s[i]) : void 0;
173
- return n === r ? null : { k: i, b: n, a: r };
171
+ const a = Array.from(/* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(s)])).sort().map((o) => {
172
+ const n = o in e ? JSON.stringify(e[o]) : void 0, r = o in s ? JSON.stringify(s[o]) : void 0;
173
+ return n === r ? null : { k: o, b: n, a: r };
174
174
  }).filter(Boolean);
175
175
  if (a.length === 0)
176
176
  return /* @__PURE__ */ t("span", { className: "text-[11px] italic text-slate-400", children: "keys reordered only" });
177
- const o = (i) => i == null ? void 0 : i.length > 80 ? `${i.slice(0, 80)}…` : i;
178
- return /* @__PURE__ */ t("div", { className: "space-y-0.5", "data-json-diff": !0, children: a.map(({ k: i, b: n, a: r }) => /* @__PURE__ */ l("p", { className: "text-[11.5px]", children: [
179
- /* @__PURE__ */ t("span", { className: "font-mono text-[10.5px] text-slate-500", children: i }),
177
+ const i = (o) => o == null ? void 0 : o.length > 80 ? `${o.slice(0, 80)}…` : o;
178
+ return /* @__PURE__ */ t("div", { className: "space-y-0.5", "data-json-diff": !0, children: a.map(({ k: o, b: n, a: r }) => /* @__PURE__ */ l("p", { className: "text-[11.5px]", children: [
179
+ /* @__PURE__ */ t("span", { className: "font-mono text-[10.5px] text-slate-500", children: o }),
180
180
  ":",
181
181
  " ",
182
- n !== void 0 && /* @__PURE__ */ t("span", { className: "text-rose-600 line-through dark:text-rose-400", children: o(n) }),
182
+ n !== void 0 && /* @__PURE__ */ t("span", { className: "text-rose-600 line-through dark:text-rose-400", children: i(n) }),
183
183
  n !== void 0 && r !== void 0 && " → ",
184
- r !== void 0 ? /* @__PURE__ */ t("span", { className: "text-emerald-700 dark:text-emerald-400", children: o(r) }) : /* @__PURE__ */ t("span", { className: "italic text-slate-400", children: " (removed)" })
185
- ] }, i)) });
184
+ r !== void 0 ? /* @__PURE__ */ t("span", { className: "text-emerald-700 dark:text-emerald-400", children: i(r) }) : /* @__PURE__ */ t("span", { className: "italic text-slate-400", children: " (removed)" })
185
+ ] }, o)) });
186
186
  }
187
187
  function lt({ field: e, ctl: s }) {
188
188
  return s.confirmField === e ? /* @__PURE__ */ l("span", { className: "inline-flex items-center gap-1", "data-revert-field-confirm": e, children: [
@@ -215,7 +215,7 @@ function lt({ field: e, ctl: s }) {
215
215
  title: "Set the field back to this revision’s value",
216
216
  "data-revert-field": e,
217
217
  children: [
218
- /* @__PURE__ */ t(ie, { className: "h-3 w-3" }),
218
+ /* @__PURE__ */ t(oe, { className: "h-3 w-3" }),
219
219
  "Revert"
220
220
  ]
221
221
  }
@@ -228,30 +228,30 @@ function Z(e) {
228
228
  return String(e ?? "").replace(/<[^>]*>/g, " ").replace(/&nbsp;/g, " ").replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").split(/\s+/).filter(Boolean);
229
229
  }
230
230
  function dt(e, s) {
231
- const a = Z(e).slice(0, 600), o = Z(s).slice(0, 600), i = a.length, n = o.length, r = Array.from({ length: i + 1 }, () => new Array(n + 1).fill(0));
232
- for (let g = i - 1; g >= 0; g--)
231
+ const a = Z(e).slice(0, 600), i = Z(s).slice(0, 600), o = a.length, n = i.length, r = Array.from({ length: o + 1 }, () => new Array(n + 1).fill(0));
232
+ for (let g = o - 1; g >= 0; g--)
233
233
  for (let c = n - 1; c >= 0; c--)
234
- r[g][c] = a[g] === o[c] ? r[g + 1][c + 1] + 1 : Math.max(r[g + 1][c], r[g][c + 1]);
234
+ r[g][c] = a[g] === i[c] ? r[g + 1][c + 1] + 1 : Math.max(r[g + 1][c], r[g][c + 1]);
235
235
  const m = [], x = (g, c) => {
236
236
  const y = m[m.length - 1];
237
237
  y && y.type === g ? y.text += ` ${c}` : m.push({ text: c, type: g });
238
238
  };
239
239
  let p = 0, u = 0;
240
- for (; p < i && u < n; )
241
- a[p] === o[u] ? (x("same", a[p]), p++, u++) : r[p + 1][u] >= r[p][u + 1] ? (x("del", a[p]), p++) : (x("ins", o[u]), u++);
242
- for (; p < i; ) x("del", a[p++]);
243
- for (; u < n; ) x("ins", o[u++]);
240
+ for (; p < o && u < n; )
241
+ a[p] === i[u] ? (x("same", a[p]), p++, u++) : r[p + 1][u] >= r[p][u + 1] ? (x("del", a[p]), p++) : (x("ins", i[u]), u++);
242
+ for (; p < o; ) x("del", a[p++]);
243
+ for (; u < n; ) x("ins", i[u++]);
244
244
  return m;
245
245
  }
246
- function ot({ before: e, after: s }) {
246
+ function it({ before: e, after: s }) {
247
247
  const d = dt(e, s);
248
248
  return /* @__PURE__ */ t("p", { className: "whitespace-pre-wrap break-words text-[12px] leading-relaxed text-slate-700 dark:text-slate-300", children: d.map(
249
- (a, o) => a.type === "same" ? (
249
+ (a, i) => a.type === "same" ? (
250
250
  // biome-ignore lint/suspicious/noArrayIndexKey: static segment list
251
251
  /* @__PURE__ */ l("span", { children: [
252
252
  a.text,
253
253
  " "
254
- ] }, o)
254
+ ] }, i)
255
255
  ) : a.type === "del" ? (
256
256
  // biome-ignore lint/suspicious/noArrayIndexKey: static segment list
257
257
  /* @__PURE__ */ l(
@@ -263,7 +263,7 @@ function ot({ before: e, after: s }) {
263
263
  " "
264
264
  ]
265
265
  },
266
- o
266
+ i
267
267
  )
268
268
  ) : (
269
269
  // biome-ignore lint/suspicious/noArrayIndexKey: static segment list
@@ -276,19 +276,19 @@ function ot({ before: e, after: s }) {
276
276
  " "
277
277
  ]
278
278
  },
279
- o
279
+ i
280
280
  )
281
281
  )
282
282
  ) });
283
283
  }
284
- const it = {
284
+ const ot = {
285
285
  added: "bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-400",
286
286
  removed: "bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-400",
287
287
  changed: "bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-400"
288
288
  };
289
289
  function ct(e, s, d) {
290
- const a = Array.from(/* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(s)])), o = (r) => r == null || r === "", i = a.map((r) => {
291
- const m = !(r in e) || o(e[r]), x = !(r in s) || o(s[r]);
290
+ const a = Array.from(/* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(s)])), i = (r) => r == null || r === "", o = a.map((r) => {
291
+ const m = !(r in e) || i(e[r]), x = !(r in s) || i(s[r]);
292
292
  if (m && x) return null;
293
293
  const p = m ? "added" : x ? "removed" : U(e[r]) !== U(s[r]) ? "changed" : "unchanged";
294
294
  return {
@@ -302,7 +302,7 @@ function ct(e, s, d) {
302
302
  const m = k(d, r.field);
303
303
  return (m.system ? 8 : m.onLayout ? 0 : 4) + (r.status === "unchanged" ? 2 : 0);
304
304
  };
305
- return i.sort(
305
+ return o.sort(
306
306
  (r, m) => n(r) - n(m) || k(d, r.field).label.localeCompare(k(d, m.field).label)
307
307
  );
308
308
  }
@@ -318,9 +318,10 @@ function mt({
318
318
  meta: s,
319
319
  fieldRevert: d,
320
320
  mode: a,
321
- hideStatusChips: o
321
+ hideStatusChips: i,
322
+ between: o
322
323
  }) {
323
- const i = e.status === "changed" && (X(e.before) || X(e.after)), n = e.status === "changed" && I(e.before) && I(e.after);
324
+ const n = e.status === "changed" && (X(e.before) || X(e.after)), r = e.status === "changed" && I(e.before) && I(e.after);
324
325
  return /* @__PURE__ */ l(
325
326
  "div",
326
327
  {
@@ -332,19 +333,21 @@ function mt({
332
333
  children: [
333
334
  /* @__PURE__ */ l("div", { className: "flex items-center gap-2", children: [
334
335
  /* @__PURE__ */ t(et, { map: s, field: e.field }),
335
- e.status !== "unchanged" && !o && /* @__PURE__ */ t(
336
+ e.status !== "unchanged" && !i && /* @__PURE__ */ t(
336
337
  "span",
337
338
  {
338
339
  className: T(
339
340
  "rounded px-1 py-px text-[9px] font-semibold uppercase tracking-wide",
340
- it[e.status]
341
+ ot[e.status]
341
342
  ),
342
343
  children: e.status === "added" ? "set" : e.status
343
344
  }
344
345
  ),
345
- (e.status === "changed" || a === "changes" && e.status === "added") && d && e.field !== "id" && /* @__PURE__ */ t("span", { className: "ml-auto shrink-0", children: /* @__PURE__ */ t(lt, { field: e.field, ctl: d }) })
346
+ (e.status === "changed" || a === "changes" && e.status === "added") && d && e.field !== "id" && // A value worked out between saves (a rollup, a forecast status) is
347
+ // not something to put back by hand (army11 f1 design review).
348
+ !o && /* @__PURE__ */ t("span", { className: "ml-auto shrink-0", children: /* @__PURE__ */ t(lt, { field: e.field, ctl: d }) })
346
349
  ] }),
347
- /* @__PURE__ */ t("div", { className: "mt-1", children: i ? /* @__PURE__ */ t("div", { "data-richtext-diff": !0, children: /* @__PURE__ */ t(ot, { before: e.before, after: e.after }) }) : n ? /* @__PURE__ */ t(
350
+ /* @__PURE__ */ t("div", { className: "mt-1", children: n ? /* @__PURE__ */ t("div", { "data-richtext-diff": !0, children: /* @__PURE__ */ t(it, { before: e.before, after: e.after }) }) : r ? /* @__PURE__ */ t(
348
351
  nt,
349
352
  {
350
353
  before: I(e.before),
@@ -364,13 +367,13 @@ function pt({
364
367
  after: s,
365
368
  meta: d,
366
369
  fieldRevert: a,
367
- mode: o,
368
- hideStatusChips: i,
370
+ mode: i,
371
+ hideStatusChips: o,
369
372
  ownFields: n
370
373
  }) {
371
- const [r, m] = w(!1), x = R(() => ct(e, s, d), [e, s, d]), p = o === "changes" ? x.filter((h) => h.status !== "unchanged") : x, u = r ? p : p.filter((h) => !h.system), g = (h) => !!n && o === "changes" && !h.system && !n.has(h.field), c = u.filter(g), y = [...u.filter((h) => !g(h)), ...c], j = c.length ? y.length - c.length : -1, f = p.length - y.length;
374
+ const [r, m] = w(!1), x = R(() => ct(e, s, d), [e, s, d]), p = i === "changes" ? x.filter((h) => h.status !== "unchanged") : x, u = r ? p : p.filter((h) => !h.system), g = (h) => !!n && i === "changes" && !h.system && !n.has(h.field), c = u.filter(g), y = [...u.filter((h) => !g(h)), ...c], j = c.length ? y.length - c.length : -1, f = p.length - y.length;
372
375
  if (p.length === 0)
373
- return /* @__PURE__ */ t("p", { className: "px-3 py-3 text-[12px] text-slate-400", children: o === "changes" ? "No field changes recorded." : "No snapshot data available." });
376
+ return /* @__PURE__ */ t("p", { className: "px-3 py-3 text-[12px] text-slate-400", children: i === "changes" ? "No field changes recorded." : "No snapshot data available." });
374
377
  const N = y.findIndex(
375
378
  (h) => !g(h) && !k(d, h.field).onLayout && !k(d, h.field).system
376
379
  ), S = y.some(
@@ -399,8 +402,9 @@ function pt({
399
402
  row: h,
400
403
  meta: d,
401
404
  fieldRevert: a,
402
- mode: o,
403
- hideStatusChips: i
405
+ mode: i,
406
+ hideStatusChips: o,
407
+ between: g(h)
404
408
  }
405
409
  )
406
410
  ] }, h.field)),
@@ -446,7 +450,7 @@ function ht(e, s, d) {
446
450
  }
447
451
  function xt({ revision: e, isLast: s }) {
448
452
  var x, p, u;
449
- const d = ce(te), a = e.event, o = (a == null ? void 0 : a.source) === "auto" || !e.user_id && (a == null ? void 0 : a.kind) === "transition", i = !o && ((x = a == null ? void 0 : a.on_behalf_of) != null && x.name) ? a.on_behalf_of.name : null, n = o ? "Automatic rule" : i ? `${B(e, d)}, for ${i}` : B(e, d);
453
+ const d = ce(te), a = e.event, i = (a == null ? void 0 : a.source) === "auto" || !e.user_id && (a == null ? void 0 : a.kind) === "transition", o = !i && ((x = a == null ? void 0 : a.on_behalf_of) != null && x.name) ? a.on_behalf_of.name : null, n = i ? "Automatic rule" : o ? `${B(e, d)}, for ${o}` : B(e, d);
450
454
  let r;
451
455
  (a == null ? void 0 : a.kind) === "transition" && a.addendum ? r = /* @__PURE__ */ l(L, { children: [
452
456
  "moved",
@@ -502,7 +506,7 @@ function xt({ revision: e, isLast: s }) {
502
506
  {
503
507
  className: "relative pl-9",
504
508
  "data-revision-event": (a == null ? void 0 : a.kind) ?? e.action ?? "",
505
- "data-revision-on-behalf": i ? (u = a == null ? void 0 : a.on_behalf_of) == null ? void 0 : u.id : void 0,
509
+ "data-revision-on-behalf": o ? (u = a == null ? void 0 : a.on_behalf_of) == null ? void 0 : u.id : void 0,
506
510
  children: [
507
511
  /* @__PURE__ */ t(
508
512
  "span",
@@ -522,7 +526,7 @@ function xt({ revision: e, isLast: s }) {
522
526
  }
523
527
  ),
524
528
  /* @__PURE__ */ l("div", { className: "flex w-full items-start gap-2.5 rounded-md px-2 py-2.5 text-left", children: [
525
- o ? /* @__PURE__ */ t("span", { className: "flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-violet-500/10 text-[10px] font-semibold text-violet-700 dark:text-violet-300", children: "⚡" }) : /* @__PURE__ */ t(
529
+ i ? /* @__PURE__ */ t("span", { className: "flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-violet-500/10 text-[10px] font-semibold text-violet-700 dark:text-violet-300", children: "⚡" }) : /* @__PURE__ */ t(
526
530
  pe,
527
531
  {
528
532
  userId: e.user_id,
@@ -565,8 +569,8 @@ function ft({
565
569
  previousData: s,
566
570
  meta: d,
567
571
  onRollback: a,
568
- inlineTableFields: o,
569
- isLast: i
572
+ inlineTableFields: i,
573
+ isLast: o
570
574
  }) {
571
575
  const n = F(), r = ce(te), m = Be(e).reason, [x, p] = w(!1), [u, g] = w(!1), [c, y] = w("changes"), [j, f] = w(!1), [N, S] = w(null), h = e.action === "update", C = e.action === "create" || e.action === "restore", W = e.action === "delete", v = W ? e.data ?? {} : C ? {} : s ?? {}, $ = W ? {} : e.data ?? {}, { humanDelta: V, systemDelta: he } = R(() => {
572
576
  const b = e.delta ?? {};
@@ -592,7 +596,7 @@ function ft({
592
596
  onSuccess: (b) => {
593
597
  g(!1), A.success("Rolled back to this revision");
594
598
  const _ = se(b);
595
- _ && A.warning(_, { duration: 1e4 }), o != null && o.length && e.timestamp && be(e.timestamp), a == null || a();
599
+ _ && A.warning(_, { duration: 1e4 }), i != null && i.length && e.timestamp && be(e.timestamp), a == null || a();
596
600
  },
597
601
  onError: () => A.error("Failed to rollback")
598
602
  });
@@ -630,7 +634,7 @@ function ft({
630
634
  "aria-hidden": !0
631
635
  }
632
636
  ),
633
- !i && /* @__PURE__ */ t(
637
+ !o && /* @__PURE__ */ t(
634
638
  "span",
635
639
  {
636
640
  className: "absolute bottom-0 left-[15.5px] top-[30px] w-px bg-slate-200 dark:bg-border",
@@ -749,7 +753,7 @@ function ft({
749
753
  onClick: () => g(!0),
750
754
  title: "Set the whole record back to how it looked after this save",
751
755
  children: [
752
- /* @__PURE__ */ t(ie, { className: "h-3 w-3" }),
756
+ /* @__PURE__ */ t(oe, { className: "h-3 w-3" }),
753
757
  "Restore this version"
754
758
  ]
755
759
  }
@@ -769,9 +773,9 @@ function ft({
769
773
  ownFields: h && e.delta ? xe : null
770
774
  }
771
775
  ),
772
- z && o && o.length > 0 && /* @__PURE__ */ l("div", { className: "space-y-1.5 rounded-md border border-slate-100 bg-slate-50 p-2 dark:border-border dark:bg-muted/30", children: [
776
+ z && i && i.length > 0 && /* @__PURE__ */ l("div", { className: "space-y-1.5 rounded-md border border-slate-100 bg-slate-50 p-2 dark:border-border dark:bg-muted/30", children: [
773
777
  /* @__PURE__ */ t("p", { className: "text-[10.5px] font-medium text-slate-500", children: "Also restore related rows?" }),
774
- o.map((b) => /* @__PURE__ */ l("div", { className: "flex items-center justify-between gap-2", children: [
778
+ i.map((b) => /* @__PURE__ */ l("div", { className: "flex items-center justify-between gap-2", children: [
775
779
  /* @__PURE__ */ t("span", { className: "text-[11.5px] text-slate-600 dark:text-slate-300", children: b.label }),
776
780
  /* @__PURE__ */ t(
777
781
  "button",
@@ -789,11 +793,11 @@ function ft({
789
793
  ] });
790
794
  }
791
795
  function bt({ data: e, meta: s }) {
792
- const [d, a] = w(null), [o, i] = w(""), [n, r] = w(""), [m, x] = w(""), p = R(() => {
793
- if (!o || !e) return null;
794
- const c = (/* @__PURE__ */ new Date(`${o}T23:59:59`)).getTime();
796
+ const [d, a] = w(null), [i, o] = w(""), [n, r] = w(""), [m, x] = w(""), p = R(() => {
797
+ if (!i || !e) return null;
798
+ const c = (/* @__PURE__ */ new Date(`${i}T23:59:59`)).getTime();
795
799
  return e.find((y) => y.timestamp && new Date(y.timestamp).getTime() <= c) ?? null;
796
- }, [o, e]), u = R(() => {
800
+ }, [i, e]), u = R(() => {
797
801
  if (!n || !m || !e) return null;
798
802
  const c = (/* @__PURE__ */ new Date(`${n}T23:59:59`)).getTime(), y = (/* @__PURE__ */ new Date(`${m}T23:59:59`)).getTime();
799
803
  if (y <= c) return { error: "The second date must be after the first" };
@@ -817,7 +821,7 @@ function bt({ data: e, meta: s }) {
817
821
  onClick: () => a(d === "asof" ? null : "asof"),
818
822
  className: T(
819
823
  "inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-[11.5px] transition-colors",
820
- d === "asof" || o ? "border-nvr-cyan/40 bg-nvr-cyan/5 font-medium text-nvr-navy dark:text-nvr-cyan" : "border-slate-200 text-slate-500 hover:text-slate-700 dark:border-border dark:text-slate-400 dark:hover:text-slate-200"
824
+ d === "asof" || i ? "border-nvr-cyan/40 bg-nvr-cyan/5 font-medium text-nvr-navy dark:text-nvr-cyan" : "border-slate-200 text-slate-500 hover:text-slate-700 dark:border-border dark:text-slate-400 dark:hover:text-slate-200"
821
825
  ),
822
826
  children: [
823
827
  /* @__PURE__ */ t(Te, { className: "h-3.5 w-3.5" }),
@@ -848,29 +852,29 @@ function bt({ data: e, meta: s }) {
848
852
  "input",
849
853
  {
850
854
  type: "date",
851
- value: o,
852
- onChange: (c) => i(c.target.value),
855
+ value: i,
856
+ onChange: (c) => o(c.target.value),
853
857
  className: g,
854
858
  "aria-label": "View record as of date",
855
859
  "data-as-of": !0
856
860
  }
857
861
  ),
858
- o && /* @__PURE__ */ t(
862
+ i && /* @__PURE__ */ t(
859
863
  "button",
860
864
  {
861
865
  type: "button",
862
- onClick: () => i(""),
866
+ onClick: () => o(""),
863
867
  className: "text-[11px] text-slate-400 hover:text-slate-600 dark:hover:text-slate-300",
864
868
  children: "Clear"
865
869
  }
866
870
  )
867
871
  ] }),
868
- o && !p && /* @__PURE__ */ t("p", { className: "mt-2 text-[12px] text-slate-400", children: "No snapshot exists at or before that date — the record is newer." }),
872
+ i && !p && /* @__PURE__ */ t("p", { className: "mt-2 text-[12px] text-slate-400", children: "No snapshot exists at or before that date — the record is newer." }),
869
873
  p && /* @__PURE__ */ l("div", { className: "mt-2 overflow-hidden rounded-lg border border-nvr-cyan/40 bg-white dark:bg-card", children: [
870
874
  /* @__PURE__ */ t("div", { className: "border-b border-slate-200 bg-[#f0fbff] px-2.5 py-1.5 dark:border-border dark:bg-nvr-cyan/10", children: /* @__PURE__ */ l("span", { className: "text-[11.5px] font-semibold text-slate-700 dark:text-slate-200", children: [
871
875
  "Record as of",
872
876
  " ",
873
- p.timestamp ? new Date(p.timestamp).toLocaleString() : o
877
+ p.timestamp ? new Date(p.timestamp).toLocaleString() : i
874
878
  ] }) }),
875
879
  /* @__PURE__ */ t("div", { className: "max-h-80 overflow-y-auto", children: Object.entries(p.data ?? {}).filter(([, c]) => c != null && c !== "").sort(([c], [y]) => k(s, c).label.localeCompare(k(s, y).label)).map(([c, y]) => /* @__PURE__ */ l(
876
880
  "div",
@@ -994,9 +998,9 @@ function yt({
994
998
  onRollback: d,
995
999
  inlineTableFields: a
996
1000
  }) {
997
- const o = F(), i = ue(e, !0), { data: n, isLoading: r } = P({
1001
+ const i = F(), o = ue(e, !0), { data: n, isLoading: r } = P({
998
1002
  queryKey: ["revisions", e, s],
999
- queryFn: () => o.request(q("/revisions", { collection: e, item: s })).then((f) => f.data ?? []),
1003
+ queryFn: () => i.request(q("/revisions", { collection: e, item: s })).then((f) => f.data ?? []),
1000
1004
  staleTime: 3e4
1001
1005
  }), m = ee();
1002
1006
  Ie(e, s, [["revisions", e, s]], { client: m });
@@ -1023,8 +1027,8 @@ function yt({
1023
1027
  /* @__PURE__ */ t("p", { className: "text-[13px] font-medium text-slate-600 dark:text-slate-300", children: "No history yet" }),
1024
1028
  /* @__PURE__ */ t("p", { className: "mt-1 max-w-[38ch] text-[12px] text-slate-400", children: "Every save records who changed what — the trail will appear here." })
1025
1029
  ] }) : /* @__PURE__ */ t(te.Provider, { value: y, children: /* @__PURE__ */ l("div", { className: "space-y-3 pt-3", children: [
1026
- /* @__PURE__ */ t(bt, { data: g, meta: i }),
1027
- g.length >= 3 && /* @__PURE__ */ t(vt, { revisions: g, meta: i }),
1030
+ /* @__PURE__ */ t(bt, { data: g, meta: o }),
1031
+ g.length >= 3 && /* @__PURE__ */ t(vt, { revisions: g, meta: o }),
1028
1032
  /* @__PURE__ */ t("div", { children: j.map((f) => /* @__PURE__ */ l("div", { children: [
1029
1033
  /* @__PURE__ */ t("div", { className: "sticky top-0 z-10 -mx-6 border-b border-slate-100 bg-white px-6 py-1.5 dark:border-border/60 dark:bg-card", children: /* @__PURE__ */ t("span", { className: "text-[10.5px] font-semibold uppercase tracking-wide text-slate-400", children: f.day }) }),
1030
1034
  f.revisions.map((N) => {
@@ -1038,7 +1042,7 @@ function yt({
1038
1042
  p.has(O(N)) && "rounded-md bg-nvr-cyan/[0.06]"
1039
1043
  ),
1040
1044
  children: [
1041
- p.has(O(N)) && /* @__PURE__ */ t(oe, {}),
1045
+ p.has(O(N)) && /* @__PURE__ */ t(ie, {}),
1042
1046
  /* @__PURE__ */ t(xt, { revision: N, isLast: h })
1043
1047
  ]
1044
1048
  },
@@ -1053,13 +1057,13 @@ function yt({
1053
1057
  p.has(O(N)) && "rounded-md bg-nvr-cyan/[0.06]"
1054
1058
  ),
1055
1059
  children: [
1056
- p.has(O(N)) && /* @__PURE__ */ t(oe, {}),
1060
+ p.has(O(N)) && /* @__PURE__ */ t(ie, {}),
1057
1061
  /* @__PURE__ */ t(
1058
1062
  ft,
1059
1063
  {
1060
1064
  revision: N,
1061
1065
  previousData: (C == null ? void 0 : C.data) ?? null,
1062
- meta: i,
1066
+ meta: o,
1063
1067
  onRollback: d,
1064
1068
  inlineTableFields: a,
1065
1069
  isLast: h
@@ -1073,7 +1077,7 @@ function yt({
1073
1077
  ] }, f.day)) })
1074
1078
  ] }) });
1075
1079
  }
1076
- function oe() {
1080
+ function ie() {
1077
1081
  return (
1078
1082
  // Under the timeline dot, inside the row's 36px gutter.
1079
1083
  /* @__PURE__ */ t(
@@ -1091,13 +1095,13 @@ function Mt({
1091
1095
  item: s,
1092
1096
  onRollback: d,
1093
1097
  triggerClassName: a,
1094
- inlineTableFields: o,
1095
- open: i,
1098
+ inlineTableFields: i,
1099
+ open: o,
1096
1100
  onOpenChange: n,
1097
1101
  compact: r
1098
1102
  }) {
1099
- return /* @__PURE__ */ l(Ve, { open: i, onOpenChange: n, children: [
1100
- !(i !== void 0) && /* @__PURE__ */ t(ze, { asChild: !0, children: /* @__PURE__ */ l(
1103
+ return /* @__PURE__ */ l(Ve, { open: o, onOpenChange: n, children: [
1104
+ !(o !== void 0) && /* @__PURE__ */ t(ze, { asChild: !0, children: /* @__PURE__ */ l(
1101
1105
  M,
1102
1106
  {
1103
1107
  variant: r ? "ghost" : "outline",
@@ -1127,14 +1131,14 @@ function Mt({
1127
1131
  collection: e,
1128
1132
  item: s,
1129
1133
  onRollback: d,
1130
- inlineTableFields: o
1134
+ inlineTableFields: i
1131
1135
  }
1132
1136
  )
1133
1137
  ] }) })
1134
1138
  ] });
1135
1139
  }
1136
1140
  function Nt({ collection: e, item: s }) {
1137
- const d = F(), a = ue(e, !0), [o, i] = w(""), [n, r] = w(""), { data: m, isFetching: x } = P({
1141
+ const d = F(), a = ue(e, !0), [i, o] = w(""), [n, r] = w(""), { data: m, isFetching: x } = P({
1138
1142
  queryKey: ["rev-value-search", e, s, n],
1139
1143
  queryFn: () => d.request(q("/revisions/value-search", { collection: e, item: s, q: n })).then((p) => p.data),
1140
1144
  enabled: n.length >= 2
@@ -1145,10 +1149,10 @@ function Nt({ collection: e, item: s }) {
1145
1149
  /* @__PURE__ */ t(
1146
1150
  "input",
1147
1151
  {
1148
- value: o,
1149
- onChange: (p) => i(p.target.value),
1152
+ value: i,
1153
+ onChange: (p) => o(p.target.value),
1150
1154
  onKeyDown: (p) => {
1151
- p.key === "Enter" && r(o.trim());
1155
+ p.key === "Enter" && r(i.trim());
1152
1156
  },
1153
1157
  placeholder: "Search this record’s history for a value — who wrote it, and when",
1154
1158
  className: "h-8 w-full rounded-md border border-slate-200 bg-background pl-8 pr-8 text-[12.5px] outline-none focus:border-nvr-cyan dark:border-border"
@@ -1159,7 +1163,7 @@ function Nt({ collection: e, item: s }) {
1159
1163
  {
1160
1164
  type: "button",
1161
1165
  onClick: () => {
1162
- i(""), r("");
1166
+ o(""), r("");
1163
1167
  },
1164
1168
  className: "absolute right-2 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600",
1165
1169
  "aria-label": "Clear search",
@@ -1195,7 +1199,7 @@ function Nt({ collection: e, item: s }) {
1195
1199
  ] });
1196
1200
  }
1197
1201
  function kt({ revisionId: e }) {
1198
- const s = F(), d = ee(), [a, o] = w(""), { data: i = [] } = P({
1202
+ const s = F(), d = ee(), [a, i] = w(""), { data: o = [] } = P({
1199
1203
  queryKey: ["revision-notes", String(e)],
1200
1204
  queryFn: () => s.request(q("/comments", { collection: "nivaro_revisions", item: String(e) })).then((r) => r.data ?? []).catch(() => []),
1201
1205
  staleTime: 3e4
@@ -1204,12 +1208,12 @@ function kt({ revisionId: e }) {
1204
1208
  K("/comments", { collection: "nivaro_revisions", item: String(e), text: a })
1205
1209
  ),
1206
1210
  onSuccess: () => {
1207
- o(""), d.invalidateQueries({ queryKey: ["revision-notes", String(e)] });
1211
+ i(""), d.invalidateQueries({ queryKey: ["revision-notes", String(e)] });
1208
1212
  },
1209
1213
  onError: () => A.error("Note failed")
1210
1214
  });
1211
1215
  return /* @__PURE__ */ l("div", { className: "rounded-md border border-slate-100 bg-slate-50/60 p-2 dark:border-border/60 dark:bg-muted/30", children: [
1212
- i.map((r) => /* @__PURE__ */ l("p", { className: "text-[11.5px] text-slate-600 dark:text-slate-300", children: [
1216
+ o.map((r) => /* @__PURE__ */ l("p", { className: "text-[11.5px] text-slate-600 dark:text-slate-300", children: [
1213
1217
  r.text,
1214
1218
  " ",
1215
1219
  /* @__PURE__ */ l("span", { className: "text-[10px] text-slate-400", children: [
@@ -1231,7 +1235,7 @@ function kt({ revisionId: e }) {
1231
1235
  "input",
1232
1236
  {
1233
1237
  value: a,
1234
- onChange: (r) => o(r.target.value),
1238
+ onChange: (r) => i(r.target.value),
1235
1239
  placeholder: "Annotate this revision…",
1236
1240
  className: "h-6 flex-1 rounded border border-slate-200 bg-transparent px-1.5 text-[11.5px] outline-none dark:border-border"
1237
1241
  }
@@ -1254,17 +1258,17 @@ function vt({
1254
1258
  revisions: e,
1255
1259
  meta: s
1256
1260
  }) {
1257
- const d = [...e].reverse(), [a, o] = w(!1), [i, n] = w(0);
1261
+ const d = [...e].reverse(), [a, i] = w(!1), [o, n] = w(0);
1258
1262
  qe(() => {
1259
1263
  if (!a) return;
1260
- if (i >= d.length - 1) {
1261
- o(!1);
1264
+ if (o >= d.length - 1) {
1265
+ i(!1);
1262
1266
  return;
1263
1267
  }
1264
1268
  const x = setTimeout(() => n((p) => p + 1), 1600);
1265
1269
  return () => clearTimeout(x);
1266
- }, [a, i, d.length]);
1267
- const r = d[i], m = r != null && r.delta ? Object.keys(r.delta).slice(0, 5).map((x) => k(s, x).label) : [];
1270
+ }, [a, o, d.length]);
1271
+ const r = d[o], m = r != null && r.delta ? Object.keys(r.delta).slice(0, 5).map((x) => k(s, x).label) : [];
1268
1272
  return /* @__PURE__ */ l("div", { className: "rounded-md border border-slate-200 bg-slate-50/70 p-2 dark:border-border dark:bg-muted/30", children: [
1269
1273
  /* @__PURE__ */ l("div", { className: "flex items-center gap-2", children: [
1270
1274
  /* @__PURE__ */ t(
@@ -1272,7 +1276,7 @@ function vt({
1272
1276
  {
1273
1277
  type: "button",
1274
1278
  onClick: () => {
1275
- !a && i >= d.length - 1 && n(0), o((x) => !x);
1279
+ !a && o >= d.length - 1 && n(0), i((x) => !x);
1276
1280
  },
1277
1281
  className: "rounded-md bg-nvr-cyan px-2.5 py-1 text-[11.5px] font-semibold text-white",
1278
1282
  children: a ? "Pause" : "▶ Time-lapse"
@@ -1284,16 +1288,16 @@ function vt({
1284
1288
  type: "range",
1285
1289
  min: 0,
1286
1290
  max: Math.max(0, d.length - 1),
1287
- value: i,
1291
+ value: o,
1288
1292
  onChange: (x) => {
1289
- o(!1), n(Number(x.target.value));
1293
+ i(!1), n(Number(x.target.value));
1290
1294
  },
1291
1295
  className: "flex-1 accent-nvr-cyan",
1292
1296
  "aria-label": "History position"
1293
1297
  }
1294
1298
  ),
1295
1299
  /* @__PURE__ */ l("span", { className: "shrink-0 tabular-nums text-[11px] text-slate-400", children: [
1296
- i + 1,
1300
+ o + 1,
1297
1301
  "/",
1298
1302
  d.length
1299
1303
  ] })