@nivaro/react 0.3.57 → 0.3.58

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 (50) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +5 -1
  4. package/dist/shared/components/CollectionBrowserView.js +2633 -2590
  5. package/dist/shared/components/DataTable.js +247 -236
  6. package/dist/shared/components/ItemEditForm.js +1693 -1668
  7. package/dist/shared/components/ProfileView.js +716 -715
  8. package/dist/shared/components/RecordReadView.js +367 -364
  9. package/dist/shared/components/ReportView.js +64 -39
  10. package/dist/shared/components/alerts/AlertManagerView.js +284 -271
  11. package/dist/shared/components/cbv/row-focus.js +19 -0
  12. package/dist/shared/components/help-videos/HelpVideoPlayer.js +152 -147
  13. package/dist/shared/components/integrations/console/SignalCard.js +59 -59
  14. package/dist/shared/components/integrations/console/tone.js +52 -30
  15. package/dist/shared/components/item-edit/CatalogPickerField.js +525 -505
  16. package/dist/shared/components/item-edit/FieldRow.js +175 -173
  17. package/dist/shared/components/item-edit/InlineTableField.js +407 -402
  18. package/dist/shared/components/item-edit/M2MCombobox.js +313 -291
  19. package/dist/shared/components/item-edit/MidairCollisionDialog.js +1 -1
  20. package/dist/shared/components/item-edit/PlanGrid.js +826 -803
  21. package/dist/shared/components/item-edit/QuickCreateButton.js +115 -79
  22. package/dist/shared/components/item-edit/RecordLiveSync.js +77 -75
  23. package/dist/shared/components/item-edit/RelationCombobox.js +412 -328
  24. package/dist/shared/components/item-edit/RelationGroupedCombobox.js +147 -125
  25. package/dist/shared/components/item-edit/SummaryPanel.js +406 -392
  26. package/dist/shared/components/item-edit/option-disambiguate.js +44 -32
  27. package/dist/shared/components/item-edit/related-missing.js +45 -0
  28. package/dist/shared/components/item-edit/save-outcome.js +5 -5
  29. package/dist/shared/components/notifications/NotificationRulesEditor.js +130 -123
  30. package/dist/shared/components/panels/AccessDeniedPanel.js +52 -48
  31. package/dist/shared/components/panels/ItemLockBanner.js +2 -3
  32. package/dist/shared/components/panels/PipelinePanel.js +1027 -978
  33. package/dist/shared/components/panels/RevisionsPanel.js +4 -1
  34. package/dist/shared/components/panels/TaskPanel.js +265 -249
  35. package/dist/shared/components/panels/landing-state.js +27 -0
  36. package/dist/shared/components/pipeline/PipelineEditorView.js +86 -78
  37. package/dist/shared/components/profile/AiMemoryCard.js +12 -10
  38. package/dist/shared/components/queue/OwnerAvatars.js +80 -41
  39. package/dist/shared/components/queue/QueueQuickFilters.js +48 -48
  40. package/dist/shared/components/queue/QueueWorklist.js +357 -358
  41. package/dist/shared/components/queue/group-sums.js +27 -0
  42. package/dist/shared/components/widgets/ReviewListWidget.js +186 -168
  43. package/dist/shared/lib/back-closes.js +25 -0
  44. package/dist/shared/lib/form-usage-beacon.js +7 -7
  45. package/dist/shared/lib/list-page-memory.js +41 -0
  46. package/dist/shared/lib/live.js +44 -44
  47. package/dist/shared/lib/own-writes.js +76 -28
  48. package/dist/shared/lib/request-gate.js +110 -109
  49. package/dist/shared/lib/validation-rules.js +34 -19
  50. package/package.json +1 -1
@@ -1,123 +1,149 @@
1
- import { jsxs as o, jsx as l } from "react/jsx-runtime";
2
- import { useQueryClient as S, useQuery as Q } from "@tanstack/react-query";
3
- import { Plus as _, Loader2 as E } from "lucide-react";
4
- import { useState as m } from "react";
5
- import { useNivaroClient as F, useParentDraft as K } from "../../context.js";
6
- import { get as P, post as z } from "../../lib/commands.js";
7
- import { userErrorMessage as A } from "../../lib/safe-error.js";
8
- import { cn as B, titleCase as p } from "../../lib/utils.js";
9
- function H({
10
- targetCollection: r,
11
- config: i,
12
- onCreated: c
1
+ import { jsxs as d, jsx as c } from "react/jsx-runtime";
2
+ import { useQueryClient as A, useQuery as P } from "@tanstack/react-query";
3
+ import { Plus as Q, Loader2 as _ } from "lucide-react";
4
+ import { useState as x } from "react";
5
+ import { useNivaroClient as D, useParentDraft as F } from "../../context.js";
6
+ import { get as K, post as W } from "../../lib/commands.js";
7
+ import { userErrorMessage as L } from "../../lib/safe-error.js";
8
+ import { cn as z, titleCase as m } from "../../lib/utils.js";
9
+ function X({
10
+ targetCollection: t,
11
+ config: l,
12
+ onCreated: s
13
13
  }) {
14
- const a = F(), d = S(), x = K(), [h, b] = m(!1), [y, N] = m({}), [g, k] = m(!1), [w, u] = m(null), { data: f } = Q({
15
- queryKey: ["quick-create-m2m", r],
16
- queryFn: () => a.request(P(`/collections/${r}`)).then(
14
+ const i = D(), u = A(), y = F(), [g, h] = x(!1), [v, k] = x({}), [w, $] = x(!1), [S, f] = x(null), { data: b } = P({
15
+ queryKey: ["quick-create-m2m", t],
16
+ queryFn: () => i.request(K(`/collections/${t}`)).then(
17
17
  (e) => {
18
- var s;
18
+ var n;
19
19
  return new Set(
20
- (((s = e.data) == null ? void 0 : s.relations) ?? []).filter(
21
- (t) => t.one_collection === r && !!t.one_field && !!t.junction_field
22
- ).map((t) => String(t.one_field))
20
+ (((n = e.data) == null ? void 0 : n.relations) ?? []).filter(
21
+ (o) => o.one_collection === t && !!o.one_field && !!o.junction_field
22
+ ).map((o) => String(o.one_field))
23
23
  );
24
24
  }
25
25
  ),
26
- enabled: h,
26
+ enabled: g,
27
27
  staleTime: 5 * 6e4
28
- }), v = (i.fields ?? []).filter((e) => e.from === void 0), q = (i.fields ?? []).filter((e) => e.from !== void 0), C = (e) => {
29
- var s;
30
- return typeof e == "string" && e.startsWith("$parent.") ? ((s = x == null ? void 0 : x.draft) == null ? void 0 : s[e.slice(8)]) ?? null : e;
31
- };
32
- async function j() {
33
- var s;
34
- for (const t of v)
35
- if (t.required && !(y[t.field] ?? "").trim()) {
36
- u(`${t.label ?? p(t.field)} is required`);
28
+ }), N = (l.fields ?? []).filter((e) => e.from === void 0), q = (l.fields ?? []).filter((e) => e.from !== void 0), j = (e) => {
29
+ var n;
30
+ return typeof e == "string" && e.startsWith("$parent.") ? ((n = y == null ? void 0 : y.draft) == null ? void 0 : n[e.slice(8)]) ?? null : e;
31
+ }, p = B(q, j);
32
+ async function C() {
33
+ var n, o;
34
+ if (p.length > 0) return;
35
+ for (const r of N)
36
+ if (r.required && !(v[r.field] ?? "").trim()) {
37
+ f(`${r.label ?? m(r.field)} is required`);
37
38
  return;
38
39
  }
39
- k(!0), u(null);
40
+ $(!0), f(null);
40
41
  const e = {};
41
- for (const t of q) {
42
- const n = C(t.from);
43
- if (f != null && f.has(t.field)) {
44
- const $ = I(n);
45
- $.length > 0 && (e[t.field] = $);
42
+ for (const r of q) {
43
+ const a = j(r.from);
44
+ if (b != null && b.has(r.field)) {
45
+ const E = M(a);
46
+ E.length > 0 && (e[r.field] = E);
46
47
  continue;
47
48
  }
48
- n != null && n !== "" && (e[t.field] = n);
49
+ a != null && a !== "" && (e[r.field] = a);
49
50
  }
50
- for (const t of v) {
51
- const n = (y[t.field] ?? "").trim();
52
- n !== "" && (e[t.field] = n);
51
+ for (const r of N) {
52
+ const a = (v[r.field] ?? "").trim();
53
+ a !== "" && (e[r.field] = a);
53
54
  }
54
55
  try {
55
- const n = (s = (await a.request(
56
- z(`/items/${r}`, e)
57
- )).data) == null ? void 0 : s.id;
58
- if (n == null) throw new Error("Created record returned no id");
59
- d.invalidateQueries({ queryKey: ["relation-opts", r] }), c(n), b(!1), N({});
60
- } catch (t) {
61
- u(A(t, "Create failed"));
56
+ const r = await i.request(W(`/items/${t}`, e)), a = (n = r.data) == null ? void 0 : n.id;
57
+ if (a == null) throw new Error("Created record returned no id");
58
+ if (u.invalidateQueries({ queryKey: ["relation-opts", t] }), ((o = r.meta) == null ? void 0 : o.readable) === !1) {
59
+ f(
60
+ "Created, but it is outside what you can see, so it can't be selected here. Ask an administrator to check your access."
61
+ ), k({});
62
+ return;
63
+ }
64
+ s(a), h(!1), k({});
65
+ } catch (r) {
66
+ f(L(r, "Create failed"));
62
67
  } finally {
63
- k(!1);
68
+ $(!1);
64
69
  }
65
70
  }
66
- return /* @__PURE__ */ o("div", { className: "relative shrink-0", children: [
67
- /* @__PURE__ */ o(
71
+ return /* @__PURE__ */ d("div", { className: "relative shrink-0", children: [
72
+ /* @__PURE__ */ d(
68
73
  "button",
69
74
  {
70
75
  type: "button",
71
- title: i.title ?? `New ${p(r)}`,
72
- onClick: () => b((e) => !e),
73
- className: B(
76
+ title: l.title ?? `New ${m(t)}`,
77
+ onClick: () => h((e) => !e),
78
+ className: z(
74
79
  "inline-flex h-9 items-center gap-1 rounded-md border px-2.5 text-[12px] transition-colors",
75
- h ? "border-nvr-cyan bg-nvr-cyan/10 text-nvr-cyan" : "border-input text-slate-600 hover:border-slate-400 hover:text-slate-800 dark:text-slate-300"
80
+ g ? "border-nvr-cyan bg-nvr-cyan/10 text-nvr-cyan" : "border-input text-slate-600 hover:border-slate-400 hover:text-slate-800 dark:text-slate-300"
76
81
  ),
77
82
  children: [
78
- /* @__PURE__ */ l(_, { className: "h-3.5 w-3.5" }),
79
- i.label ?? "New"
83
+ /* @__PURE__ */ c(Q, { className: "h-3.5 w-3.5" }),
84
+ l.label ?? "New"
80
85
  ]
81
86
  }
82
87
  ),
83
- h && /* @__PURE__ */ o("div", { className: "absolute right-0 z-50 mt-1 w-72 rounded-md border border-border bg-background p-3 shadow-md", children: [
84
- /* @__PURE__ */ l("p", { className: "mb-2 text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: i.title ?? `New ${p(r)}` }),
85
- /* @__PURE__ */ l("div", { className: "flex flex-col gap-2", children: v.map((e) => /* @__PURE__ */ o("label", { className: "flex flex-col gap-1", children: [
86
- /* @__PURE__ */ o("span", { className: "text-[11px] text-slate-500", children: [
87
- e.label ?? p(e.field),
88
- e.required && /* @__PURE__ */ l("span", { className: "ml-0.5 text-red-500", children: "*" })
88
+ g && /* @__PURE__ */ d("div", { className: "absolute right-0 z-50 mt-1 w-72 rounded-md border border-border bg-background p-3 shadow-md", children: [
89
+ /* @__PURE__ */ c("p", { className: "mb-2 text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: l.title ?? `New ${m(t)}` }),
90
+ p.length > 0 && /* @__PURE__ */ d(
91
+ "p",
92
+ {
93
+ "data-quick-create-missing": !0,
94
+ className: "mb-2 rounded border border-amber-200 bg-amber-50 px-2 py-1.5 text-[11.5px] leading-snug text-amber-800 dark:border-amber-500/40 dark:bg-[#2a2113] dark:text-amber-300",
95
+ children: [
96
+ "Pick ",
97
+ I(p),
98
+ " on the form first — the new",
99
+ " ",
100
+ (l.label ?? m(t)).replace(/^New\s+/i, "").toLowerCase(),
101
+ " ",
102
+ "takes ",
103
+ p.length === 1 ? "it" : "them",
104
+ " from there."
105
+ ]
106
+ }
107
+ ),
108
+ /* @__PURE__ */ c("div", { className: "flex flex-col gap-2", children: N.map((e) => /* @__PURE__ */ d("label", { className: "flex flex-col gap-1", children: [
109
+ /* @__PURE__ */ d("span", { className: "text-[11px] text-slate-500", children: [
110
+ e.label ?? m(e.field),
111
+ e.required && /* @__PURE__ */ c("span", { className: "ml-0.5 text-red-500", children: "*" })
89
112
  ] }),
90
- /* @__PURE__ */ l(
113
+ /* @__PURE__ */ c(
91
114
  "input",
92
115
  {
93
- value: y[e.field] ?? "",
94
- onChange: (s) => N((t) => ({ ...t, [e.field]: s.target.value })),
116
+ value: v[e.field] ?? "",
117
+ onChange: (n) => k((o) => ({ ...o, [e.field]: n.target.value })),
118
+ onKeyDown: (n) => {
119
+ n.key === "Enter" ? (n.preventDefault(), C()) : n.key === "Escape" && (n.preventDefault(), n.stopPropagation(), h(!1), f(null));
120
+ },
95
121
  className: "h-8 rounded border border-input bg-background px-2 text-[13px] outline-none focus:border-nvr-cyan"
96
122
  }
97
123
  )
98
124
  ] }, e.field)) }),
99
- w && /* @__PURE__ */ l("p", { className: "mt-2 text-[11px] text-red-600 dark:text-red-400", children: w }),
100
- /* @__PURE__ */ o("div", { className: "mt-3 flex justify-end gap-2", children: [
101
- /* @__PURE__ */ l(
125
+ S && /* @__PURE__ */ c("p", { className: "mt-2 text-[11px] text-red-600 dark:text-red-400", children: S }),
126
+ /* @__PURE__ */ d("div", { className: "mt-3 flex justify-end gap-2", children: [
127
+ /* @__PURE__ */ c(
102
128
  "button",
103
129
  {
104
130
  type: "button",
105
131
  onClick: () => {
106
- b(!1), u(null);
132
+ h(!1), f(null);
107
133
  },
108
134
  className: "h-7 rounded px-2 text-[12px] text-slate-500 hover:text-slate-700",
109
135
  children: "Cancel"
110
136
  }
111
137
  ),
112
- /* @__PURE__ */ o(
138
+ /* @__PURE__ */ d(
113
139
  "button",
114
140
  {
115
141
  type: "button",
116
- disabled: g || q.length > 0 && !f,
117
- onClick: () => void j(),
142
+ disabled: w || p.length > 0 || q.length > 0 && !b,
143
+ onClick: () => void C(),
118
144
  className: "inline-flex h-7 items-center gap-1 rounded bg-nvr-cyan px-2.5 text-[12px] font-medium text-white hover:brightness-110 disabled:opacity-50",
119
145
  children: [
120
- g && /* @__PURE__ */ l(E, { className: "h-3 w-3 animate-spin" }),
146
+ w && /* @__PURE__ */ c(_, { className: "h-3 w-3 animate-spin" }),
121
147
  "Create & select"
122
148
  ]
123
149
  }
@@ -126,14 +152,24 @@ function H({
126
152
  ] })
127
153
  ] });
128
154
  }
129
- function I(r) {
130
- const i = Array.isArray(r) ? r : [r], c = [];
131
- for (const a of i) {
132
- const d = a != null && typeof a == "object" ? a.id : a;
133
- (typeof d == "string" && d !== "" || typeof d == "number") && c.push(d);
155
+ function B(t, l) {
156
+ return t.filter((s) => s.required && typeof s.from == "string" && s.from.startsWith("$parent.")).filter((s) => {
157
+ const i = l(s.from);
158
+ return i == null || i === "" || Array.isArray(i) && i.length === 0;
159
+ }).map((s) => s.label ?? m(String(s.from).slice(8)));
160
+ }
161
+ function I(t) {
162
+ return t.length <= 1 ? t[0] ?? "" : `${t.slice(0, -1).join(", ")} and ${t[t.length - 1]}`;
163
+ }
164
+ function M(t) {
165
+ const l = Array.isArray(t) ? t : [t], s = [];
166
+ for (const i of l) {
167
+ const u = i != null && typeof i == "object" ? i.id : i;
168
+ (typeof u == "string" && u !== "" || typeof u == "number") && s.push(u);
134
169
  }
135
- return c;
170
+ return s;
136
171
  }
137
172
  export {
138
- H as QuickCreateButton
173
+ X as QuickCreateButton,
174
+ B as missingRequiredSeeds
139
175
  };
@@ -1,17 +1,17 @@
1
1
  import { jsx as d, jsxs as m } from "react/jsx-runtime";
2
2
  import { useQueryClient as ce } from "@tanstack/react-query";
3
3
  import { EyeOff as me, ArrowLeft as le, Trash2 as fe, Copy as pe, FileUp as be, Bot as he, UploadCloud as ge } from "lucide-react";
4
- import { useState as w, useRef as g, useEffect as k } from "react";
4
+ import { useState as w, useRef as v, useEffect as k } from "react";
5
5
  import { toast as O } from "sonner";
6
6
  import { useNivaroClient as ve, useRecordSurface as ye, useItemEditAuth as xe } from "../../context.js";
7
7
  import { get as U, post as we } from "../../lib/commands.js";
8
- import { useLiveRecord as ke, useLiveEvent as ee, useLiveRecordEvent as re, LIVE_ASPECTS as v, batchTouches as Se } from "../../lib/live.js";
8
+ import { useLiveRecord as ke, useLiveEvent as ee, useLiveRecordEvent as re, LIVE_ASPECTS as y, batchTouches as Se } from "../../lib/live.js";
9
9
  import { useOptionalRealtime as Ne } from "../../lib/realtime.js";
10
10
  import { useRecordTabsSignal as Re, useRecordTabs as Te } from "../../lib/record-tabs.js";
11
11
  import { userErrorMessage as _e } from "../../lib/safe-error.js";
12
12
  import { formatRelative as $e } from "../../lib/utils.js";
13
- import { markLiveRecordWrite as Ee } from "./live-record-marks.js";
14
- function Ke(e, r, u) {
13
+ import { markLiveRecordWrite as Ke } from "./live-record-marks.js";
14
+ function Ee(e, r, u) {
15
15
  var f;
16
16
  if (u.active)
17
17
  return { text: e ? `${e} moved this to ${r}` : `This record moved to ${r}` };
@@ -25,7 +25,7 @@ function De(e, r) {
25
25
  const u = e == null ? void 0 : e.user_id;
26
26
  return typeof u == "string" && !!r && u.toUpperCase() === String(r).toUpperCase();
27
27
  }
28
- const Le = 8e3, te = [
28
+ const Qe = 8e3, te = [
29
29
  "item",
30
30
  "rrv-record",
31
31
  "revisions",
@@ -45,7 +45,7 @@ const Le = 8e3, te = [
45
45
  "record-integrations",
46
46
  "record-integrity"
47
47
  ];
48
- function Qe(e, r, u) {
48
+ function qe(e, r, u) {
49
49
  const p = new Set(te), f = String(u);
50
50
  e.removeQueries({
51
51
  predicate: (c) => p.has(c.queryKey[0]) && c.queryKey[1] === r && String(c.queryKey[2]) === f
@@ -58,7 +58,7 @@ function Ge(e, r, u) {
58
58
  predicate: (c) => p.has(c.queryKey[0]) && c.queryKey[1] === r && f.has(String(c.queryKey[2]))
59
59
  });
60
60
  }
61
- function qe({ onBack: e }) {
61
+ function Le({ onBack: e }) {
62
62
  return /* @__PURE__ */ d("div", { className: "p-6", children: /* @__PURE__ */ m(
63
63
  "div",
64
64
  {
@@ -99,19 +99,19 @@ function Je({
99
99
  loadDenied: p = !1,
100
100
  onGoneChange: f
101
101
  }) {
102
- const c = Ne(), T = ve(), y = ce(), [D, j] = w(!1), [L, se] = w([]), [o, ne] = w(null), [ae, Q] = w({}), [B, F] = w(!1), [P, Y] = w(!1), S = g(null), N = g(null), _ = g(Date.now()), q = g(null), $ = g(f);
102
+ const c = Ne(), T = ve(), b = ce(), [D, j] = w(!1), [Q, se] = w([]), [i, ne] = w(null), [ae, q] = w({}), [B, F] = w(!1), [P, Y] = w(!1), S = v(null), N = v(null), _ = v(Date.now()), L = v(null), $ = v(f);
103
103
  $.current = f;
104
- const x = g(null), W = ye(), H = g(W);
104
+ const x = v(null), W = ye(), H = v(W);
105
105
  H.current = W;
106
106
  const R = (s) => {
107
107
  var t;
108
- x.current = s, ne(s), (t = $.current) == null || t.call($, s), (s == null ? void 0 : s.kind) === "access" && setTimeout(() => Qe(y, e, r), 0);
108
+ x.current = s, ne(s), (t = $.current) == null || t.call($, s), (s == null ? void 0 : s.kind) === "access" && setTimeout(() => qe(b, e, r), 0);
109
109
  };
110
110
  k(() => {
111
- _.current = Date.now(), q.current = null, Q({}), x.current && R(null);
111
+ _.current = Date.now(), L.current = null, q({}), x.current && R(null);
112
112
  }, [e, r]);
113
113
  const l = (s) => {
114
- for (const t of s) y.invalidateQueries({ queryKey: t });
114
+ for (const t of s) b.invalidateQueries({ queryKey: t });
115
115
  }, A = async (s) => {
116
116
  let t = null;
117
117
  try {
@@ -121,8 +121,8 @@ function Je({
121
121
  } catch {
122
122
  t = null;
123
123
  }
124
- const a = !!(t != null && t.deleted_at) && new Date(t.deleted_at).getTime() >= _.current - 6e4;
125
- R(a || s === "deleted" && !t ? {
124
+ const o = !!(t != null && t.deleted_at) && new Date(t.deleted_at).getTime() >= _.current - 6e4;
125
+ R(o || s === "deleted" && !t ? {
126
126
  kind: "deleted",
127
127
  by: (t == null ? void 0 : t.deleted_by_name) ?? null,
128
128
  at: (t == null ? void 0 : t.deleted_at) ?? (/* @__PURE__ */ new Date()).toISOString(),
@@ -134,9 +134,9 @@ function Je({
134
134
  try {
135
135
  const t = (await T.request(
136
136
  U(`/pipelines/instance/${e}/${r}`)
137
- )).data, a = (s = t == null ? void 0 : t.history) == null ? void 0 : s[0];
138
- if (!a || a.id === q.current || a.timestamp && new Date(a.timestamp).getTime() < _.current - 5e3 || (q.current = a.id, typeof document < "u" && document.visibilityState === "hidden")) return;
139
- const b = [a.first_name, a.last_name].filter(Boolean).join(" ") || a.user_email || null, i = a.to_state_label ?? "a new state", n = Ke(b, i, H.current);
137
+ )).data, o = (s = t == null ? void 0 : t.history) == null ? void 0 : s[0];
138
+ if (!o || o.id === L.current || o.timestamp && new Date(o.timestamp).getTime() < _.current - 5e3 || (L.current = o.id, typeof document < "u" && document.visibilityState === "hidden")) return;
139
+ const h = [o.first_name, o.last_name].filter(Boolean).join(" ") || o.user_email || null, a = o.to_state_label ?? "a new state", n = Ee(h, a, H.current);
140
140
  O.info(
141
141
  n.text,
142
142
  n.open ? { action: { label: "Open", onClick: n.open } } : {}
@@ -144,40 +144,42 @@ function Je({
144
144
  } catch {
145
145
  }
146
146
  }, ie = (s) => {
147
- var a, b;
147
+ var o, h;
148
148
  if (s.deleted) {
149
149
  A("deleted");
150
150
  return;
151
151
  }
152
152
  if (x.current) return;
153
- s.events.some((i) => i.source === "import" && !i.own) && (Y(!0), S.current && clearTimeout(S.current), S.current = setTimeout(() => Y(!1), Le));
154
- const t = (i) => Se(s, i);
155
- if (t(v.state) && (l([
153
+ s.events.some((a) => a.source === "import" && !a.own) && (Y(!0), S.current && clearTimeout(S.current), S.current = setTimeout(() => Y(!1), Qe));
154
+ const t = (a) => Se(s, a);
155
+ if (t(y.state) && (l([
156
156
  ["pipeline-instance", e, r],
157
157
  ["pipeline-all-owners", e, r],
158
158
  ["pipeline-instance-owners", e, r],
159
159
  ["pipeline-owners-resolved", e, r],
160
160
  ["approval-brief", e, r]
161
- ]), (a = s.changedFields) != null && a.includes(v.state) && oe()), t(v.addendums) && l([["addendums", e, r]]), t(v.comments) ? l([
161
+ ]), (o = s.changedFields) != null && o.includes(y.state) && oe()), t(y.addendums) && l([["addendums", e, r]]), t(y.comments) ? l([
162
162
  ["comments", e, r],
163
163
  ["comments-related", e, r]
164
- ]) : (t(v.state) || t(v.integrations) || t(v.addendums) || !s.aspectsOnly) && l([["comments-related", e, r]]), t(v.tasks) && l([["tasks", e, r]]), t(v.integrations) && l([
164
+ ]) : (t(y.state) || t(y.integrations) || t(y.addendums) || !s.aspectsOnly) && l([["comments-related", e, r]]), t(y.tasks) && l([["tasks", e, r]]), t(y.integrations) && l([
165
165
  ["erp-submissions", e, r],
166
166
  ["record-integrations", e, r]
167
- ]), y.invalidateQueries({
168
- predicate: (i) => (i.queryKey[0] === "child-summary" || i.queryKey[0] === "field-lineage") && i.queryKey[1] === e && String(i.queryKey[2]) === String(r)
167
+ ]), b.invalidateQueries({
168
+ predicate: (a) => (a.queryKey[0] === "child-summary" || a.queryKey[0] === "field-lineage") && a.queryKey[1] === e && String(a.queryKey[2]) === String(r)
169
169
  }), !s.aspectsOnly) {
170
- if (s.ids.length > 0 && s.ids.every((i) => i === "*")) {
170
+ if (s.ids.length > 0 && s.ids.every((a) => a === "*")) {
171
171
  l([
172
172
  ["item", e, r],
173
173
  ["pipeline-instance", e, r]
174
174
  ]);
175
175
  return;
176
176
  }
177
- Ee(
177
+ b.invalidateQueries({
178
+ predicate: (a) => a.queryKey[0] === "o2m-rows" && String(a.queryKey[3]) === String(r) || a.queryKey[0] === "o2m-compare"
179
+ }), Ke(
178
180
  e,
179
181
  r,
180
- ((b = s.changedFields) == null ? void 0 : b.filter((i) => !i.startsWith("$"))) ?? null
182
+ ((h = s.changedFields) == null ? void 0 : h.filter((a) => !a.startsWith("$"))) ?? null
181
183
  ), V(!0);
182
184
  }
183
185
  }, V = async (s) => {
@@ -189,12 +191,12 @@ function Je({
189
191
  ["revisions", e, r]
190
192
  ]);
191
193
  const t = ["last-touch", e, String(r)];
192
- await y.invalidateQueries({ queryKey: t }).catch(() => {
193
- }), !(!s || De(y.getQueryData(t), z.current)) && (j(!0), N.current && clearTimeout(N.current), N.current = setTimeout(() => j(!1), 4e3));
194
+ await b.invalidateQueries({ queryKey: t }).catch(() => {
195
+ }), !(!s || De(b.getQueryData(t), z.current)) && (j(!0), N.current && clearTimeout(N.current), N.current = setTimeout(() => j(!1), 4e3));
194
196
  };
195
197
  ke(e, r, ie);
196
- const { userId: E } = xe(), z = g(E);
197
- z.current = E, Re(E, "saved", e, r, () => {
198
+ const { userId: K } = xe(), z = v(K);
199
+ z.current = K, Re(K, "saved", e, r, () => {
198
200
  x.current || (V(!1), l([
199
201
  ["pipeline-instance", e, r],
200
202
  ["comments", e, r],
@@ -225,21 +227,21 @@ function Je({
225
227
  r,
226
228
  () => l([["record-integrity", e, r]])
227
229
  );
228
- const G = g(/* @__PURE__ */ new Map());
230
+ const G = v(/* @__PURE__ */ new Map());
229
231
  re("record:automation", e, r, (s) => {
230
232
  const t = String((s == null ? void 0 : s.flow_id) ?? "");
231
233
  if (!t) return;
232
- const a = G.current, b = a.get(t);
233
- b && clearTimeout(b), a.delete(t);
234
- const i = () => Q((n) => {
235
- const { [t]: h, ...M } = n;
234
+ const o = G.current, h = o.get(t);
235
+ h && clearTimeout(h), o.delete(t);
236
+ const a = () => q((n) => {
237
+ const { [t]: g, ...M } = n;
236
238
  return M;
237
239
  });
238
240
  if ((s == null ? void 0 : s.state) === "end") {
239
- i();
241
+ a();
240
242
  return;
241
243
  }
242
- Q((n) => ({ ...n, [t]: String((s == null ? void 0 : s.flow_name) || "An automation") })), a.set(t, setTimeout(i, 5 * 6e4));
244
+ q((n) => ({ ...n, [t]: String((s == null ? void 0 : s.flow_name) || "An automation") })), o.set(t, setTimeout(a, 5 * 6e4));
243
245
  }), k(() => {
244
246
  const s = G.current;
245
247
  return () => {
@@ -256,8 +258,8 @@ function Je({
256
258
  var t;
257
259
  ((t = x.current) == null ? void 0 : t.kind) === "access" && (R(null), l([["item", e, r]]));
258
260
  }).catch((t) => {
259
- const a = Ae(t);
260
- (a === 403 || a === 404) && A("access");
261
+ const o = Ae(t);
262
+ (o === 403 || o === 404) && A("access");
261
263
  });
262
264
  },
263
265
  Math.floor(Math.random() * 1500)
@@ -267,49 +269,49 @@ function Je({
267
269
  ), k(() => {
268
270
  p && !x.current && A("access");
269
271
  }, [p]);
270
- const K = Te(e, r, u, E), [de, J] = w(!1);
272
+ const E = Te(e, r, u, K), [de, J] = w(!1);
271
273
  k(() => {
272
- K.otherDirty || J(!1);
273
- }, [K.otherDirty]), k(() => {
274
+ E.otherDirty || J(!1);
275
+ }, [E.otherDirty]), k(() => {
274
276
  if (!c) return;
275
277
  const s = (n) => {
276
- const h = n.detail;
277
- h != null && h.name && c.emit("record:uploading", {
278
+ const g = n.detail;
279
+ g != null && g.name && c.emit("record:uploading", {
278
280
  collection: e,
279
281
  item: String(r),
280
- name: h.name,
281
- state: h.state
282
+ name: g.name,
283
+ state: g.state
282
284
  });
283
285
  };
284
286
  window.addEventListener("nvr:upload-state", s);
285
287
  const t = (n) => {
286
288
  if ((n == null ? void 0 : n.collection) !== e || String(n == null ? void 0 : n.item) !== String(r)) return;
287
- const h = String(n.user_name ?? n.user ?? "Someone");
289
+ const g = String(n.user_name ?? n.user ?? "Someone");
288
290
  se((M) => {
289
- const Z = M.filter((I) => !(I.user === h && I.name === n.name));
290
- return n.state === "start" ? [...Z, { user: h, name: String(n.name) }] : Z;
291
+ const Z = M.filter((I) => !(I.user === g && I.name === n.name));
292
+ return n.state === "start" ? [...Z, { user: g, name: String(n.name) }] : Z;
291
293
  });
292
- }, a = c.on("record:uploading", t), b = c.on("record:comment", (n) => {
293
- (n == null ? void 0 : n.collection) !== e || String(n == null ? void 0 : n.item) !== String(r) || (y.invalidateQueries({ queryKey: ["comments", e, r] }), y.invalidateQueries({ queryKey: ["comments-related", e, r] }));
294
- }), i = (n) => t(n.detail);
295
- return window.addEventListener("nvr:record-uploading", i), () => {
296
- window.removeEventListener("nvr:upload-state", s), window.removeEventListener("nvr:record-uploading", i), a(), b();
294
+ }, o = c.on("record:uploading", t), h = c.on("record:comment", (n) => {
295
+ (n == null ? void 0 : n.collection) !== e || String(n == null ? void 0 : n.item) !== String(r) || (b.invalidateQueries({ queryKey: ["comments", e, r] }), b.invalidateQueries({ queryKey: ["comments-related", e, r] }));
296
+ }), a = (n) => t(n.detail);
297
+ return window.addEventListener("nvr:record-uploading", a), () => {
298
+ window.removeEventListener("nvr:upload-state", s), window.removeEventListener("nvr:record-uploading", a), o(), h();
297
299
  };
298
- }, [c, e, r, y]);
300
+ }, [c, e, r, b]);
299
301
  const ue = async () => {
300
- if (o != null && o.trashId) {
302
+ if (i != null && i.trashId) {
301
303
  F(!0);
302
304
  try {
303
- await T.request(we(`/trash/${o.trashId}/restore`, {})), R(null), _.current = Date.now(), l([["item", e, r]]), O.success("Record restored");
305
+ await T.request(we(`/trash/${i.trashId}/restore`, {})), R(null), _.current = Date.now(), l([["item", e, r]]), O.success("Record restored");
304
306
  } catch (s) {
305
307
  O.error(_e(s, "Restore failed"));
306
308
  } finally {
307
309
  F(!1);
308
310
  }
309
311
  }
310
- }, C = Object.values(ae), X = K.otherDirty && !de && !u && !o;
311
- return !o && C.length === 0 && !X && !P && (!c || !D && L.length === 0) ? null : /* @__PURE__ */ m("div", { className: "space-y-2", children: [
312
- (o == null ? void 0 : o.kind) === "deleted" && /* @__PURE__ */ m(
312
+ }, C = Object.values(ae), X = E.otherDirty && !de && !u && !i;
313
+ return !i && C.length === 0 && !X && !P && (!c || !D && Q.length === 0) ? null : /* @__PURE__ */ m("div", { className: "space-y-2", children: [
314
+ (i == null ? void 0 : i.kind) === "deleted" && /* @__PURE__ */ m(
313
315
  "div",
314
316
  {
315
317
  "data-record-gone": "deleted",
@@ -319,12 +321,12 @@ function Je({
319
321
  /* @__PURE__ */ d(fe, { className: "h-4 w-4 shrink-0 text-rose-500" }),
320
322
  /* @__PURE__ */ m("p", { className: "min-w-0 flex-1 text-[12px] text-rose-800 dark:text-rose-300", children: [
321
323
  /* @__PURE__ */ d("span", { className: "font-semibold", children: "This record was deleted" }),
322
- o.by ? ` by ${o.by}` : "",
323
- o.at ? ` ${$e(o.at)}` : "",
324
+ i.by ? ` by ${i.by}` : "",
325
+ i.at ? ` ${$e(i.at)}` : "",
324
326
  ". Saving is turned off",
325
- o.canRestore ? " — restore it to keep working." : "."
327
+ i.canRestore ? " — restore it to keep working." : "."
326
328
  ] }),
327
- o.canRestore && o.trashId != null && /* @__PURE__ */ d(
329
+ i.canRestore && i.trashId != null && /* @__PURE__ */ d(
328
330
  "button",
329
331
  {
330
332
  type: "button",
@@ -337,7 +339,7 @@ function Je({
337
339
  ]
338
340
  }
339
341
  ),
340
- (o == null ? void 0 : o.kind) === "access" && !f && /* @__PURE__ */ d(qe, { onBack: () => window.history.back() }),
342
+ (i == null ? void 0 : i.kind) === "access" && !f && /* @__PURE__ */ d(Le, { onBack: () => window.history.back() }),
341
343
  X && /* @__PURE__ */ m(
342
344
  "div",
343
345
  {
@@ -350,7 +352,7 @@ function Je({
350
352
  "button",
351
353
  {
352
354
  type: "button",
353
- onClick: K.focusOther,
355
+ onClick: E.focusOther,
354
356
  className: "h-7 shrink-0 rounded-md border border-amber-300 bg-white px-2.5 text-[11.5px] font-medium text-amber-800 hover:bg-amber-100 dark:border-amber-500/40 dark:bg-transparent dark:text-amber-300 dark:hover:bg-amber-500/10",
355
357
  children: "Switch to that tab"
356
358
  }
@@ -367,7 +369,7 @@ function Je({
367
369
  ]
368
370
  }
369
371
  ),
370
- P && !o && /* @__PURE__ */ m(
372
+ P && !i && /* @__PURE__ */ m(
371
373
  "div",
372
374
  {
373
375
  "data-record-importing": !0,
@@ -383,7 +385,7 @@ function Je({
383
385
  ]
384
386
  }
385
387
  ),
386
- C.length > 0 && !o && /* @__PURE__ */ m(
388
+ C.length > 0 && !i && /* @__PURE__ */ m(
387
389
  "div",
388
390
  {
389
391
  "data-record-automation": !0,
@@ -401,12 +403,12 @@ function Je({
401
403
  ]
402
404
  }
403
405
  ),
404
- c && (D || L.length > 0) && /* @__PURE__ */ m("div", { className: "flex flex-wrap items-center gap-2", children: [
406
+ c && (D || Q.length > 0) && /* @__PURE__ */ m("div", { className: "flex flex-wrap items-center gap-2", children: [
405
407
  D && /* @__PURE__ */ m("span", { className: "inline-flex items-center gap-1.5 rounded-full border border-nvr-cyan/40 bg-nvr-cyan/10 px-2.5 py-0.5 text-[11px] font-medium text-[#0e7490] dark:text-[#67e8f9]", children: [
406
408
  /* @__PURE__ */ d("span", { className: "h-1.5 w-1.5 animate-pulse rounded-full bg-nvr-cyan" }),
407
409
  "Updated just now by someone else"
408
410
  ] }),
409
- L.map((s) => /* @__PURE__ */ m(
411
+ Q.map((s) => /* @__PURE__ */ m(
410
412
  "span",
411
413
  {
412
414
  className: "inline-flex items-center gap-1.5 rounded-full border border-slate-200 bg-white px-2.5 py-0.5 text-[11px] text-slate-600 dark:border-border dark:bg-card dark:text-slate-300",
@@ -425,10 +427,10 @@ function Je({
425
427
  }
426
428
  export {
427
429
  te as RECORD_QUERY_HEADS,
428
- qe as RecordAccessLostPanel,
430
+ Le as RecordAccessLostPanel,
429
431
  Je as RecordLiveSync,
430
432
  Ge as invalidateRecordQueries,
431
- Ke as moveNotice,
432
- Qe as purgeRecordQueries,
433
+ Ee as moveNotice,
434
+ qe as purgeRecordQueries,
433
435
  De as writtenBySelf
434
436
  };