@nivaro/react 0.3.126 → 0.3.128

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 (40) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +20 -2
  4. package/dist/index.js +150 -147
  5. package/dist/shared/components/CollectionBrowserView.js +3259 -3211
  6. package/dist/shared/components/DataTable.js +406 -401
  7. package/dist/shared/components/ItemEditForm.js +4359 -4299
  8. package/dist/shared/components/MatrixEditor.js +548 -490
  9. package/dist/shared/components/MyWorkView.js +284 -274
  10. package/dist/shared/components/NotificationBell.js +264 -218
  11. package/dist/shared/components/RecordGridEditor.js +582 -472
  12. package/dist/shared/components/chat/chat-core.js +331 -346
  13. package/dist/shared/components/chat/chat-typing.js +25 -0
  14. package/dist/shared/components/command-center/CommandCenterView.js +1 -1
  15. package/dist/shared/components/command-center/PeekPanel.js +8 -1
  16. package/dist/shared/components/command-center/api.js +17 -9
  17. package/dist/shared/components/command-center/panels/AttentionPanel.js +4 -1
  18. package/dist/shared/components/command-center/panels/PartnersPanel.js +2 -1
  19. package/dist/shared/components/item-edit/GroupSection.js +1 -1
  20. package/dist/shared/components/item-edit/InlineTableField.js +432 -429
  21. package/dist/shared/components/item-edit/RecordLiveSync.js +115 -108
  22. package/dist/shared/components/item-edit/RecordViewersChip.js +17 -16
  23. package/dist/shared/components/item-edit/RowComments.js +33 -30
  24. package/dist/shared/components/item-edit/cascade-clear-notice.js +30 -28
  25. package/dist/shared/components/item-edit/live-related.js +29 -16
  26. package/dist/shared/components/item-edit/record-opened-live.js +86 -0
  27. package/dist/shared/components/item-edit/reimport-m2m.js +17 -0
  28. package/dist/shared/components/panels/OwnerOpenedLine.js +24 -23
  29. package/dist/shared/components/panels/RecordIntegrityBanner.js +1 -1
  30. package/dist/shared/components/pipeline/TeamSuggestions.js +1 -1
  31. package/dist/shared/components/queue/QueueItemSheet.js +171 -130
  32. package/dist/shared/components/record-grid-guard.js +85 -0
  33. package/dist/shared/components/support/TicketDetailSheet.js +168 -151
  34. package/dist/shared/lib/at-risk-fields.js +14 -0
  35. package/dist/shared/lib/live-queries.js +9 -8
  36. package/dist/shared/lib/live-screen.js +77 -76
  37. package/dist/shared/lib/presence-hooks.js +190 -127
  38. package/dist/shared/lib/user-sync.js +78 -65
  39. package/dist/shared/lib/waiting-count.js +40 -29
  40. package/package.json +1 -1
@@ -1,34 +1,34 @@
1
1
  import { jsx as d, jsxs as u } from "react/jsx-runtime";
2
2
  import { useQueryClient as fe } from "@tanstack/react-query";
3
3
  import { EyeOff as he, ArrowLeft as ye, Trash2 as ge, Copy as be, FileUp as ve, Bot as xe, UploadCloud as I } from "lucide-react";
4
- import { useState as N, useRef as b, useEffect as E } from "react";
4
+ import { useState as N, useRef as b, useEffect as Q } from "react";
5
5
  import { toast as B } from "sonner";
6
6
  import { useNivaroClient as we, useRecordSurface as ke, useItemEditAuth as Se } from "../../context.js";
7
7
  import { get as j, post as Ne } from "../../lib/commands.js";
8
8
  import { useLiveRecord as Re, useLiveEvent as ee, useLiveRecordEvent as re, LIVE_ASPECTS as m, batchTouches as Te } from "../../lib/live.js";
9
9
  import { useOptionalRealtime as _e } from "../../lib/realtime.js";
10
- import { useRecordTabsSignal as Ke, useRecordTabs as Ee, otherTabNote as Qe } from "../../lib/record-tabs.js";
10
+ import { useRecordTabsSignal as Ke, useRecordTabs as Qe, otherTabNote as Ee } from "../../lib/record-tabs.js";
11
11
  import { userErrorMessage as qe } from "../../lib/safe-error.js";
12
- import { useRemoteUploads as Ae, UPLOAD_STATE_EVENT as te, uploadSentence as ne, applyRemoteUpload as $e } from "../../lib/upload-presence.js";
13
- import { formatRelative as Le, cn as se } from "../../lib/utils.js";
14
- import { CollectionImportBanner as Oe } from "../CollectionImportBanner.js";
12
+ import { useRemoteUploads as Ae, UPLOAD_STATE_EVENT as te, uploadSentence as ne, applyRemoteUpload as De } from "../../lib/upload-presence.js";
13
+ import { formatRelative as Oe, cn as se } from "../../lib/utils.js";
14
+ import { CollectionImportBanner as $e } from "../CollectionImportBanner.js";
15
15
  import { markLiveRecordWrite as ae } from "./live-record-marks.js";
16
- import { wideSpreadDelay as Ce, fileQueryOfRecord as De, relatedQueryOfRecord as Me } from "./live-related.js";
17
- function Ue(e, t, c) {
18
- var y;
16
+ import { ADDENDUM_DETAIL_KEYS as Le, wideSpreadDelay as Ce, actionQueryOfRecord as Me, fileQueryOfRecord as Ue, resolvedPathQueryOfRecord as Be, relatedQueryOfRecord as je } from "./live-related.js";
17
+ function Fe(e, t, c) {
18
+ var g;
19
19
  if (c.active)
20
20
  return { text: e ? `${e} moved this to ${t}` : `This record moved to ${t}` };
21
- const v = ((y = c.label) == null ? void 0 : y.trim()) || "A record in your tabs";
21
+ const v = ((g = c.label) == null ? void 0 : g.trim()) || "A record in your tabs";
22
22
  return {
23
23
  text: e ? `${e} moved ${v} to ${t}` : `${v} moved to ${t}`,
24
24
  open: c.open
25
25
  };
26
26
  }
27
- function Be(e, t) {
27
+ function Pe(e, t) {
28
28
  const c = e == null ? void 0 : e.user_id;
29
29
  return typeof c == "string" && !!t && c.toUpperCase() === String(t).toUpperCase();
30
30
  }
31
- const je = 8e3, ie = [
31
+ const Ye = 8e3, ie = [
32
32
  "item",
33
33
  "rrv-record",
34
34
  "revisions",
@@ -55,20 +55,20 @@ const je = 8e3, ie = [
55
55
  // The SLA clock (SlaClock.tsx slaStatusKey).
56
56
  "sla-breach"
57
57
  ];
58
- function Fe(e, t, c) {
59
- const v = new Set(ie), y = String(c);
58
+ function Ve(e, t, c) {
59
+ const v = new Set(ie), g = String(c);
60
60
  e.removeQueries({
61
- predicate: (l) => v.has(l.queryKey[0]) && l.queryKey[1] === t && String(l.queryKey[2]) === y
61
+ predicate: (l) => v.has(l.queryKey[0]) && l.queryKey[1] === t && String(l.queryKey[2]) === g
62
62
  });
63
63
  }
64
- function or(e, t, c) {
64
+ function cr(e, t, c) {
65
65
  if (!t || c.length === 0) return;
66
- const v = new Set(ie), y = new Set(c.map(String));
66
+ const v = new Set(ie), g = new Set(c.map(String));
67
67
  e.invalidateQueries({
68
- predicate: (l) => v.has(l.queryKey[0]) && l.queryKey[1] === t && y.has(String(l.queryKey[2]))
68
+ predicate: (l) => v.has(l.queryKey[0]) && l.queryKey[1] === t && g.has(String(l.queryKey[2]))
69
69
  });
70
70
  }
71
- function Pe({ onBack: e }) {
71
+ function We({ onBack: e }) {
72
72
  return /* @__PURE__ */ d("div", { className: "p-6", children: /* @__PURE__ */ u(
73
73
  "div",
74
74
  {
@@ -98,34 +98,34 @@ function Pe({ onBack: e }) {
98
98
  }
99
99
  ) });
100
100
  }
101
- const Ye = (e) => {
101
+ const He = (e) => {
102
102
  var t;
103
103
  return (e == null ? void 0 : e.status) ?? ((t = e == null ? void 0 : e.response) == null ? void 0 : t.status);
104
104
  };
105
- function dr({
105
+ function lr({
106
106
  collection: e,
107
107
  itemId: t,
108
108
  dirty: c = !1,
109
109
  loadDenied: v = !1,
110
- onGoneChange: y
110
+ onGoneChange: g
111
111
  }) {
112
- const l = _e(), Q = we(), h = fe(), [L, F] = N(!1), [oe, de] = N(null), x = Ae(e, String(t), "unclaimed"), [o, ue] = N(null), [ce, O] = N({}), [P, Y] = N(!1), [V, W] = N(!1), R = b(null), T = b(null), _ = b(null), q = b(Date.now()), C = b(null), A = b(y);
113
- A.current = y;
112
+ const l = _e(), E = we(), p = fe(), [O, F] = N(!1), [oe, de] = N(null), x = Ae(e, String(t), "unclaimed"), [o, ue] = N(null), [ce, $] = N({}), [P, Y] = N(!1), [V, W] = N(!1), R = b(null), T = b(null), _ = b(null), q = b(Date.now()), L = b(null), A = b(g);
113
+ A.current = g;
114
114
  const w = b(null), H = ke(), z = b(H);
115
115
  z.current = H;
116
116
  const K = (r) => {
117
117
  var n;
118
- w.current = r, ue(r), (n = A.current) == null || n.call(A, r), (r == null ? void 0 : r.kind) === "access" && setTimeout(() => Fe(h, e, t), 0);
118
+ w.current = r, ue(r), (n = A.current) == null || n.call(A, r), (r == null ? void 0 : r.kind) === "access" && setTimeout(() => Ve(p, e, t), 0);
119
119
  };
120
- E(() => {
121
- q.current = Date.now(), C.current = null, O({}), w.current && K(null);
120
+ Q(() => {
121
+ q.current = Date.now(), L.current = null, $({}), w.current && K(null);
122
122
  }, [e, t]);
123
- const p = (r) => {
124
- for (const n of r) h.invalidateQueries({ queryKey: n });
125
- }, D = async (r) => {
123
+ const f = (r) => {
124
+ for (const n of r) p.invalidateQueries({ queryKey: n });
125
+ }, C = async (r) => {
126
126
  let n = null;
127
127
  try {
128
- n = (await Q.request(
128
+ n = (await E.request(
129
129
  j("/trash/record", { collection: e, item: t })
130
130
  )).data;
131
131
  } catch {
@@ -142,11 +142,11 @@ function dr({
142
142
  }, le = async () => {
143
143
  var r;
144
144
  try {
145
- const n = (await Q.request(
145
+ const n = (await E.request(
146
146
  j(`/pipelines/instance/${e}/${t}`)
147
147
  )).data, i = (r = n == null ? void 0 : n.history) == null ? void 0 : r[0];
148
- if (!i || i.id === C.current || i.timestamp && new Date(i.timestamp).getTime() < q.current - 5e3 || (C.current = i.id, typeof document < "u" && document.visibilityState === "hidden")) return;
149
- const f = [i.first_name, i.last_name].filter(Boolean).join(" ") || i.user_email || null, g = i.to_state_label ?? "a new state", a = Ue(f, g, z.current);
148
+ if (!i || i.id === L.current || i.timestamp && new Date(i.timestamp).getTime() < q.current - 5e3 || (L.current = i.id, typeof document < "u" && document.visibilityState === "hidden")) return;
149
+ const h = [i.first_name, i.last_name].filter(Boolean).join(" ") || i.user_email || null, y = i.to_state_label ?? "a new state", a = Fe(h, y, z.current);
150
150
  B.info(
151
151
  a.text,
152
152
  a.open ? { action: { label: "Open", onClick: a.open } } : {}
@@ -154,53 +154,58 @@ function dr({
154
154
  } catch {
155
155
  }
156
156
  }, me = (r) => {
157
- var i, f, g, a;
157
+ var i, h, y, a;
158
158
  if (r.deleted) {
159
- D("deleted");
159
+ C("deleted");
160
160
  return;
161
161
  }
162
162
  if (w.current) return;
163
- r.events.some((s) => s.source === "import" && !s.own) && (W(!0), R.current && clearTimeout(R.current), R.current = setTimeout(() => W(!1), je));
163
+ r.events.some((s) => s.source === "import" && !s.own) && (W(!0), R.current && clearTimeout(R.current), R.current = setTimeout(() => W(!1), Ye));
164
164
  const n = (s) => Te(r, s);
165
- if (n(m.state) && (p([
166
- ["pipeline-instance", e, t],
167
- ["pipeline-all-owners", e, t],
168
- ["pipeline-instance-owners", e, t],
169
- ["pipeline-owners-resolved", e, t],
170
- ["approval-brief", e, t]
171
- ]), (i = r.changedFields) != null && i.includes(m.state) && le()), n(m.owners) && !n(m.state) && p([
165
+ if (n(m.state)) {
166
+ f([
167
+ ["pipeline-instance", e, t],
168
+ ["pipeline-all-owners", e, t],
169
+ ["pipeline-instance-owners", e, t],
170
+ ["pipeline-owners-resolved", e, t],
171
+ ["approval-brief", e, t]
172
+ ]);
173
+ const s = Me(e, String(t));
174
+ p.invalidateQueries({ predicate: (k) => s(k.queryKey) }), (i = r.changedFields) != null && i.includes(m.state) && le();
175
+ }
176
+ if (n(m.owners) && !n(m.state) && f([
172
177
  ["pipeline-all-owners", e, t],
173
178
  ["pipeline-instance-owners", e, t],
174
179
  ["pipeline-owners-resolved", e, t],
175
180
  ["approval-brief", e, t]
176
- ]), !(r.aspectsOnly && ((f = r.changedFields) != null && f.every((s) => s === m.owners)))) {
177
- if (n(m.addendums) && p([["addendums", e, t]]), n(m.comments) ? p([
181
+ ]), !(r.aspectsOnly && ((h = r.changedFields) != null && h.every((s) => s === m.owners)))) {
182
+ if (n(m.addendums) && f([["addendums", e, t], ...Le.map((s) => [...s])]), n(m.comments) ? f([
178
183
  ["comments", e, t],
179
184
  ["comments-related", e, t]
180
- ]) : (n(m.state) || n(m.integrations) || n(m.addendums) || !r.aspectsOnly) && p([["comments-related", e, t]]), n(m.tasks) && p([["tasks", e, t]]), n(m.integrations) && p([
185
+ ]) : (n(m.state) || n(m.integrations) || n(m.addendums) || !r.aspectsOnly) && f([["comments-related", e, t]]), n(m.tasks) && f([["tasks", e, t]]), n(m.integrations) && f([
181
186
  ["erp-submissions", e, t],
182
187
  ["record-integrations", e, t]
183
188
  ]), n(m.files)) {
184
- const s = De(e, String(t));
185
- h.invalidateQueries({ predicate: (S) => s(S.queryKey) });
189
+ const s = Ue(e, String(t));
190
+ p.invalidateQueries({ predicate: (k) => s(k.queryKey) });
186
191
  }
187
192
  if (n(m.related)) {
188
- const s = Me(e, String(t)), S = () => void h.invalidateQueries({ predicate: (U) => s(U.queryKey) });
189
- r.ids.length > 0 && r.ids.every((U) => U === "*") ? (_.current && clearTimeout(_.current), _.current = setTimeout(S, Ce())) : S();
193
+ const s = je(e, String(t)), k = () => void p.invalidateQueries({ predicate: (U) => s(U.queryKey) });
194
+ r.ids.length > 0 && r.ids.every((U) => U === "*") ? (_.current && clearTimeout(_.current), _.current = setTimeout(k, Ce())) : k();
190
195
  }
191
- if (h.invalidateQueries({
196
+ if (p.invalidateQueries({
192
197
  predicate: (s) => (s.queryKey[0] === "child-summary" || s.queryKey[0] === "field-lineage") && s.queryKey[1] === e && String(s.queryKey[2]) === String(t)
193
- }), (g = r.changedFields) != null && g.includes(m.related) && h.invalidateQueries({
198
+ }), (y = r.changedFields) != null && y.includes(m.related) && p.invalidateQueries({
194
199
  predicate: (s) => s.queryKey[0] === "o2m-rows" && String(s.queryKey[3]) === String(t)
195
200
  }), !r.aspectsOnly) {
196
201
  if (r.ids.length > 0 && r.ids.every((s) => s === "*")) {
197
- p([
202
+ f([
198
203
  ["item", e, t],
199
204
  ["pipeline-instance", e, t]
200
205
  ]);
201
206
  return;
202
207
  }
203
- h.invalidateQueries({
208
+ p.invalidateQueries({
204
209
  predicate: (s) => s.queryKey[0] === "o2m-rows" && String(s.queryKey[3]) === String(t) || s.queryKey[0] === "o2m-compare"
205
210
  }), ae(
206
211
  e,
@@ -210,25 +215,27 @@ function dr({
210
215
  }
211
216
  }
212
217
  }, G = async (r) => {
213
- p([
218
+ f([
214
219
  ["item", e, t],
215
220
  // Summary mode reads its own copy (#1869) — it diffs + highlights.
216
221
  ["rrv-record", e, t],
217
222
  ["field-touch", e, t],
218
223
  ["revisions", e, t]
219
224
  ]);
220
- const n = ["last-touch", e, String(t)];
221
- await h.invalidateQueries({ queryKey: n }).catch(() => {
225
+ const n = Be(e, String(t));
226
+ p.invalidateQueries({ predicate: (a) => n(a.queryKey) });
227
+ const i = ["last-touch", e, String(t)];
228
+ await p.invalidateQueries({ queryKey: i }).catch(() => {
222
229
  });
223
- const i = h.getQueryData(n);
224
- if (!r || Be(i, J.current)) return;
225
- const f = i == null ? void 0 : i.user_name;
226
- de(typeof f == "string" && f.trim() ? f.trim() : null), F(!0), T.current && clearTimeout(T.current), T.current = setTimeout(() => F(!1), 4e3);
230
+ const h = p.getQueryData(i);
231
+ if (!r || Pe(h, J.current)) return;
232
+ const y = h == null ? void 0 : h.user_name;
233
+ de(typeof y == "string" && y.trim() ? y.trim() : null), F(!0), T.current && clearTimeout(T.current), T.current = setTimeout(() => F(!1), 4e3);
227
234
  };
228
235
  Re(e, t, me);
229
- const { userId: $ } = Se(), J = b($);
230
- J.current = $, Ke($, "saved", e, t, ({ fields: r }) => {
231
- w.current || (r && ae(e, String(t), r), G(!1), p([
236
+ const { userId: D } = Se(), J = b(D);
237
+ J.current = D, Ke(D, "saved", e, t, ({ fields: r }) => {
238
+ w.current || (r && ae(e, String(t), r), G(!1), f([
232
239
  ["pipeline-instance", e, t],
233
240
  ["comments", e, t],
234
241
  ["tasks", e, t],
@@ -236,7 +243,7 @@ function dr({
236
243
  ["o2m-rows"],
237
244
  ["m2m-items"]
238
245
  ]));
239
- }), E(
246
+ }), Q(
240
247
  () => () => {
241
248
  T.current && clearTimeout(T.current), R.current && clearTimeout(R.current), _.current && clearTimeout(_.current);
242
249
  },
@@ -244,7 +251,7 @@ function dr({
244
251
  ), ee(
245
252
  "owners:changed",
246
253
  (r) => {
247
- w.current || r != null && r.checked || r != null && r.queues || Array.isArray(r == null ? void 0 : r.collections) && !r.collections.includes(e) || p([
254
+ w.current || r != null && r.checked || r != null && r.queues || Array.isArray(r == null ? void 0 : r.collections) && !r.collections.includes(e) || f([
248
255
  ["pipeline-instance-owners", e, t],
249
256
  ["pipeline-owners-resolved", e, t],
250
257
  ["pipeline-all-owners", e, t],
@@ -256,24 +263,24 @@ function dr({
256
263
  "record:integrity",
257
264
  e,
258
265
  t,
259
- () => p([["record-integrity", e, t]])
266
+ () => f([["record-integrity", e, t]])
260
267
  );
261
268
  const X = b(/* @__PURE__ */ new Map());
262
269
  re("record:automation", e, t, (r) => {
263
270
  const n = String((r == null ? void 0 : r.flow_id) ?? "");
264
271
  if (!n) return;
265
- const i = X.current, f = i.get(n);
266
- f && clearTimeout(f), i.delete(n);
267
- const g = () => O((a) => {
268
- const { [n]: s, ...S } = a;
269
- return S;
272
+ const i = X.current, h = i.get(n);
273
+ h && clearTimeout(h), i.delete(n);
274
+ const y = () => $((a) => {
275
+ const { [n]: s, ...k } = a;
276
+ return k;
270
277
  });
271
278
  if ((r == null ? void 0 : r.state) === "end") {
272
- g();
279
+ y();
273
280
  return;
274
281
  }
275
- O((a) => ({ ...a, [n]: String((r == null ? void 0 : r.flow_name) || "An automation") })), i.set(n, setTimeout(g, 5 * 6e4));
276
- }), E(() => {
282
+ $((a) => ({ ...a, [n]: String((r == null ? void 0 : r.flow_name) || "An automation") })), i.set(n, setTimeout(y, 5 * 6e4));
283
+ }), Q(() => {
277
284
  const r = X.current;
278
285
  return () => {
279
286
  for (const n of r.values()) clearTimeout(n);
@@ -285,23 +292,23 @@ function dr({
285
292
  setTimeout(
286
293
  () => {
287
294
  var r;
288
- ((r = w.current) == null ? void 0 : r.kind) !== "deleted" && Q.request(j(`/items/${e}/${t}`, { fields: "id" })).then(() => {
295
+ ((r = w.current) == null ? void 0 : r.kind) !== "deleted" && E.request(j(`/items/${e}/${t}`, { fields: "id" })).then(() => {
289
296
  var n;
290
- ((n = w.current) == null ? void 0 : n.kind) === "access" && (K(null), p([["item", e, t]]));
297
+ ((n = w.current) == null ? void 0 : n.kind) === "access" && (K(null), f([["item", e, t]]));
291
298
  }).catch((n) => {
292
- const i = Ye(n);
293
- (i === 403 || i === 404) && D("access");
299
+ const i = He(n);
300
+ (i === 403 || i === 404) && C("access");
294
301
  });
295
302
  },
296
303
  Math.floor(Math.random() * 1500)
297
304
  );
298
305
  },
299
306
  { debounceMs: 300 }
300
- ), E(() => {
301
- v && !w.current && D("access");
307
+ ), Q(() => {
308
+ v && !w.current && C("access");
302
309
  }, [v]);
303
- const Z = Ee(e, t, c, $), k = o ? null : Qe({ otherDirty: Z.otherDirty, dirty: c });
304
- E(() => {
310
+ const Z = Qe(e, t, c, D), S = o ? null : Ee({ otherDirty: Z.otherDirty, dirty: c });
311
+ Q(() => {
305
312
  if (!l) return;
306
313
  const r = (a) => {
307
314
  const s = a.detail;
@@ -309,19 +316,19 @@ function dr({
309
316
  };
310
317
  window.addEventListener(te, r);
311
318
  const n = (a) => {
312
- (a == null ? void 0 : a.collection) !== e || String(a == null ? void 0 : a.item) !== String(t) || $e(a);
313
- }, i = l.on("record:uploading", n), f = l.on("record:comment", (a) => {
314
- (a == null ? void 0 : a.collection) !== e || String(a == null ? void 0 : a.item) !== String(t) || (h.invalidateQueries({ queryKey: ["comments", e, t] }), h.invalidateQueries({ queryKey: ["comments-related", e, t] }));
315
- }), g = (a) => n(a.detail);
316
- return window.addEventListener("nvr:record-uploading", g), () => {
317
- window.removeEventListener(te, r), window.removeEventListener("nvr:record-uploading", g), i(), f();
319
+ (a == null ? void 0 : a.collection) !== e || String(a == null ? void 0 : a.item) !== String(t) || De(a);
320
+ }, i = l.on("record:uploading", n), h = l.on("record:comment", (a) => {
321
+ (a == null ? void 0 : a.collection) !== e || String(a == null ? void 0 : a.item) !== String(t) || (p.invalidateQueries({ queryKey: ["comments", e, t] }), p.invalidateQueries({ queryKey: ["comments-related", e, t] }));
322
+ }), y = (a) => n(a.detail);
323
+ return window.addEventListener("nvr:record-uploading", y), () => {
324
+ window.removeEventListener(te, r), window.removeEventListener("nvr:record-uploading", y), i(), h();
318
325
  };
319
- }, [l, e, t, h]);
326
+ }, [l, e, t, p]);
320
327
  const pe = async () => {
321
328
  if (o != null && o.trashId) {
322
329
  Y(!0);
323
330
  try {
324
- await Q.request(Ne(`/trash/${o.trashId}/restore`, {})), K(null), q.current = Date.now(), p([["item", e, t]]), B.success("Record restored");
331
+ await E.request(Ne(`/trash/${o.trashId}/restore`, {})), K(null), q.current = Date.now(), f([["item", e, t]]), B.success("Record restored");
325
332
  } catch (r) {
326
333
  B.error(qe(r, "Restore failed"));
327
334
  } finally {
@@ -329,7 +336,7 @@ function dr({
329
336
  }
330
337
  }
331
338
  }, M = Object.values(ce);
332
- return !o && M.length === 0 && !k && !V && (!l || !L && x.length === 0) ? null : /* @__PURE__ */ u("div", { className: "space-y-2", children: [
339
+ return !o && M.length === 0 && !S && !V && (!l || !O && x.length === 0) ? null : /* @__PURE__ */ u("div", { className: "space-y-2", children: [
333
340
  (o == null ? void 0 : o.kind) === "deleted" && /* @__PURE__ */ u(
334
341
  "div",
335
342
  {
@@ -341,7 +348,7 @@ function dr({
341
348
  /* @__PURE__ */ u("p", { className: "min-w-0 flex-1 text-[12px] text-rose-800 dark:text-rose-300", children: [
342
349
  /* @__PURE__ */ d("span", { className: "font-semibold", children: "This record was deleted" }),
343
350
  o.by ? ` by ${o.by}` : "",
344
- o.at ? ` ${Le(o.at)}` : "",
351
+ o.at ? ` ${Oe(o.at)}` : "",
345
352
  ". Saving is turned off",
346
353
  o.canRestore ? " — restore it to keep working." : "."
347
354
  ] }),
@@ -358,15 +365,15 @@ function dr({
358
365
  ]
359
366
  }
360
367
  ),
361
- (o == null ? void 0 : o.kind) === "access" && !y && /* @__PURE__ */ d(Pe, { onBack: () => window.history.back() }),
362
- k && /* @__PURE__ */ u(
368
+ (o == null ? void 0 : o.kind) === "access" && !g && /* @__PURE__ */ d(We, { onBack: () => window.history.back() }),
369
+ S && /* @__PURE__ */ u(
363
370
  "p",
364
371
  {
365
- "data-record-other-tab": k.tone,
372
+ "data-record-other-tab": S.tone,
366
373
  role: "status",
367
374
  className: se(
368
375
  "flex flex-wrap items-center gap-x-2 gap-y-0.5 px-0.5 text-[11.5px] leading-5",
369
- k.tone === "both" ? "text-amber-800 dark:text-amber-300" : "text-muted-foreground"
376
+ S.tone === "both" ? "text-amber-800 dark:text-amber-300" : "text-muted-foreground"
370
377
  ),
371
378
  children: [
372
379
  /* @__PURE__ */ d(
@@ -374,12 +381,12 @@ function dr({
374
381
  {
375
382
  className: se(
376
383
  "h-3.5 w-3.5 shrink-0",
377
- k.tone === "both" ? "text-amber-500" : "text-muted-foreground/70"
384
+ S.tone === "both" ? "text-amber-500" : "text-muted-foreground/70"
378
385
  ),
379
386
  "aria-hidden": !0
380
387
  }
381
388
  ),
382
- /* @__PURE__ */ d("span", { className: "min-w-0", children: k.text }),
389
+ /* @__PURE__ */ d("span", { className: "min-w-0", children: S.text }),
383
390
  /* @__PURE__ */ d(
384
391
  "button",
385
392
  {
@@ -408,7 +415,7 @@ function dr({
408
415
  ]
409
416
  }
410
417
  ),
411
- !o && /* @__PURE__ */ d(Oe, { collection: e, scope: "record" }),
418
+ !o && /* @__PURE__ */ d($e, { collection: e, scope: "record" }),
412
419
  M.length > 0 && !o && /* @__PURE__ */ u(
413
420
  "div",
414
421
  {
@@ -427,8 +434,8 @@ function dr({
427
434
  ]
428
435
  }
429
436
  ),
430
- l && (L || x.length > 0) && /* @__PURE__ */ u("div", { className: "flex flex-wrap items-center gap-2", children: [
431
- L && /* @__PURE__ */ u(
437
+ l && (O || x.length > 0) && /* @__PURE__ */ u("div", { className: "flex flex-wrap items-center gap-2", children: [
438
+ O && /* @__PURE__ */ u(
432
439
  "span",
433
440
  {
434
441
  "data-record-updated-by": !0,
@@ -497,10 +504,10 @@ function dr({
497
504
  }
498
505
  export {
499
506
  ie as RECORD_QUERY_HEADS,
500
- Pe as RecordAccessLostPanel,
501
- dr as RecordLiveSync,
502
- or as invalidateRecordQueries,
503
- Ue as moveNotice,
504
- Fe as purgeRecordQueries,
505
- Be as writtenBySelf
507
+ We as RecordAccessLostPanel,
508
+ lr as RecordLiveSync,
509
+ cr as invalidateRecordQueries,
510
+ Fe as moveNotice,
511
+ Ve as purgeRecordQueries,
512
+ Pe as writtenBySelf
506
513
  };
@@ -1,46 +1,47 @@
1
1
  import { jsxs as r, jsx as t, Fragment as d } from "react/jsx-runtime";
2
- import { useQuery as c } from "@tanstack/react-query";
3
- import { Eye as m } from "lucide-react";
4
- import { useState as p } from "react";
2
+ import { useQuery as p } from "@tanstack/react-query";
3
+ import { Eye as c } from "lucide-react";
4
+ import { useState as m } from "react";
5
5
  import { useNivaroClient as u } from "../../context.js";
6
6
  import { get as h } from "../../lib/commands.js";
7
7
  import { formatRelative as x } from "../../lib/utils.js";
8
- function N({ collection: s, itemId: l }) {
9
- const i = u(), [n, o] = p(!1), { data: a } = c({
10
- queryKey: ["record-viewers", s, l],
11
- queryFn: () => i.request(
12
- h(`/record-views/${s}/${encodeURIComponent(l)}/viewers`)
8
+ import { useRefreshOnRecordOpened as f } from "./record-opened-live.js";
9
+ function R({ collection: a, itemId: s }) {
10
+ const n = u(), [i, l] = m(!1), { data: o } = p({
11
+ queryKey: ["record-viewers", a, s],
12
+ queryFn: () => n.request(
13
+ h(`/record-views/${a}/${encodeURIComponent(s)}/viewers`)
13
14
  ).then((e) => e.data ?? []).catch(() => []),
14
15
  staleTime: 6e4
15
16
  });
16
- return !a || a.length === 0 ? null : /* @__PURE__ */ r("span", { className: "relative inline-flex", children: [
17
+ return f(a, s, ["record-viewers", a, s]), !o || o.length === 0 ? null : /* @__PURE__ */ r("span", { className: "relative inline-flex", children: [
17
18
  /* @__PURE__ */ r(
18
19
  "button",
19
20
  {
20
21
  type: "button",
21
- onClick: () => o((e) => !e),
22
+ onClick: () => l((e) => !e),
22
23
  "data-record-viewers": !0,
23
24
  className: "inline-flex items-center gap-1 rounded px-1 py-0.5 text-[10.5px] text-slate-400 hover:bg-slate-100 hover:text-slate-600 dark:text-slate-500 dark:hover:bg-muted dark:hover:text-slate-300",
24
25
  title: "Who has opened this record",
25
26
  children: [
26
- /* @__PURE__ */ t(m, { className: "h-3 w-3" }),
27
- a.length
27
+ /* @__PURE__ */ t(c, { className: "h-3 w-3" }),
28
+ o.length
28
29
  ]
29
30
  }
30
31
  ),
31
- n && /* @__PURE__ */ r(d, { children: [
32
+ i && /* @__PURE__ */ r(d, { children: [
32
33
  /* @__PURE__ */ t(
33
34
  "button",
34
35
  {
35
36
  type: "button",
36
37
  "aria-label": "Close",
37
38
  className: "fixed inset-0 z-[100] cursor-default",
38
- onClick: () => o(!1)
39
+ onClick: () => l(!1)
39
40
  }
40
41
  ),
41
42
  /* @__PURE__ */ r("div", { className: "absolute left-0 top-full z-[110] mt-1 w-60 rounded-lg border border-slate-200 bg-white p-2 shadow-lg dark:border-border dark:bg-card", children: [
42
43
  /* @__PURE__ */ t("p", { className: "mb-1 px-1 text-[10.5px] font-semibold uppercase tracking-wide text-slate-400", children: "Viewed by" }),
43
- /* @__PURE__ */ t("div", { className: "max-h-56 space-y-0.5 overflow-y-auto", children: a.map((e) => /* @__PURE__ */ r(
44
+ /* @__PURE__ */ t("div", { className: "max-h-56 space-y-0.5 overflow-y-auto", children: o.map((e) => /* @__PURE__ */ r(
44
45
  "div",
45
46
  {
46
47
  className: "flex items-baseline justify-between gap-2 rounded px-1 py-0.5 text-[11.5px] hover:bg-slate-50 dark:hover:bg-muted",
@@ -56,5 +57,5 @@ function N({ collection: s, itemId: l }) {
56
57
  ] });
57
58
  }
58
59
  export {
59
- N as RecordViewersChip
60
+ R as RecordViewersChip
60
61
  };