@nivaro/react 0.3.9 → 0.3.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/components/fields/FileField.js +20 -19
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useNivaroForm.js +129 -126
  4. package/dist/hooks/useSessionRecorder.js +1 -1
  5. package/dist/index.d.ts +103 -4
  6. package/dist/index.js +512 -501
  7. package/dist/shared/components/CollectionBrowserView.js +1632 -1564
  8. package/dist/shared/components/ConformanceView.js +36 -35
  9. package/dist/shared/components/ForceReloadBanner.js +58 -34
  10. package/dist/shared/components/ItemEditForm.js +4386 -4142
  11. package/dist/shared/components/JsonMapEditor.js +18 -17
  12. package/dist/shared/components/MatrixEditor.js +8 -7
  13. package/dist/shared/components/MyWorkView.js +32 -31
  14. package/dist/shared/components/PageRenderer.js +527 -479
  15. package/dist/shared/components/QueryStatStrip.js +74 -70
  16. package/dist/shared/components/RecordGridEditor.js +76 -75
  17. package/dist/shared/components/ReportView.js +818 -827
  18. package/dist/shared/components/SheetHeaderBody.js +16 -14
  19. package/dist/shared/components/ai/AiMemorySuggestions.js +15 -14
  20. package/dist/shared/components/ai/AskPanel.js +55 -54
  21. package/dist/shared/components/bulk/BulkActionButtons.js +30 -29
  22. package/dist/shared/components/bulk/PushBulkButtons.js +57 -56
  23. package/dist/shared/components/chat/SlashCommands.js +30 -29
  24. package/dist/shared/components/chat/chat-outbox.js +76 -75
  25. package/dist/shared/components/help-videos/recorder/useLeaveWarning.js +6 -5
  26. package/dist/shared/components/integrations/console/SignalCard.js +124 -123
  27. package/dist/shared/components/integrations/console/SnoozeMenu.js +24 -23
  28. package/dist/shared/components/item-edit/CatalogPickerField.js +1029 -933
  29. package/dist/shared/components/item-edit/CloneDialog.js +85 -78
  30. package/dist/shared/components/item-edit/FieldRenderer.js +161 -156
  31. package/dist/shared/components/item-edit/FieldRow.js +20 -19
  32. package/dist/shared/components/item-edit/FilePickerField.js +52 -40
  33. package/dist/shared/components/item-edit/GroupSection.js +221 -221
  34. package/dist/shared/components/item-edit/InlineGridField.js +41 -41
  35. package/dist/shared/components/item-edit/InlineTableField.js +2287 -2275
  36. package/dist/shared/components/item-edit/M2MCombobox.js +46 -44
  37. package/dist/shared/components/item-edit/MembershipSetField.js +24 -23
  38. package/dist/shared/components/item-edit/NestedRelationEditor.js +11 -11
  39. package/dist/shared/components/item-edit/QuickCreateButton.js +8 -7
  40. package/dist/shared/components/item-edit/QuickPicker.js +263 -216
  41. package/dist/shared/components/item-edit/RecordLiveSync.js +101 -100
  42. package/dist/shared/components/item-edit/RelationCombobox.js +285 -245
  43. package/dist/shared/components/item-edit/RichTextEditorImpl.js +42 -32
  44. package/dist/shared/components/item-edit/RowHistorySheet.js +130 -134
  45. package/dist/shared/components/item-edit/SummaryPanel.js +305 -279
  46. package/dist/shared/components/item-edit/helpers.js +133 -134
  47. package/dist/shared/components/item-edit/line-qty.js +57 -0
  48. package/dist/shared/components/item-edit/option-disambiguate.js +53 -0
  49. package/dist/shared/components/item-edit/staged-links.js +86 -0
  50. package/dist/shared/components/layout-editor/LayoutEditor.js +275 -274
  51. package/dist/shared/components/layout-editor/editors/cascade-rule-row.js +18 -17
  52. package/dist/shared/components/layout-editor/inspector/HelpTab.js +37 -36
  53. package/dist/shared/components/layout-editor/matrix/FieldStateMatrix.js +50 -49
  54. package/dist/shared/components/panels/AddendumLinesDiff.js +87 -90
  55. package/dist/shared/components/panels/CommentPanel.js +350 -315
  56. package/dist/shared/components/panels/ItemLockBanner.js +297 -230
  57. package/dist/shared/components/panels/PipelinePanel.js +719 -701
  58. package/dist/shared/components/profile/AiMemoryCard.js +15 -14
  59. package/dist/shared/components/profile/PersonAdminTools.js +70 -67
  60. package/dist/shared/components/queue/QueueItemSheet.js +36 -35
  61. package/dist/shared/components/queue/QueueQuickFilters.js +43 -41
  62. package/dist/shared/components/queue/QueueWorklist.js +1026 -957
  63. package/dist/shared/components/widgets/ReviewListWidget.js +99 -93
  64. package/dist/shared/lib/client-version.js +63 -0
  65. package/dist/shared/lib/force-reload.js +36 -0
  66. package/dist/shared/lib/load-error.js +11 -10
  67. package/dist/shared/lib/obligation-banner.js +14 -13
  68. package/dist/shared/lib/obligation-reason-text.js +13 -0
  69. package/dist/shared/lib/presence-live.js +54 -35
  70. package/dist/shared/lib/query-filter-seed.js +34 -11
  71. package/dist/shared/lib/record-outbox.js +76 -75
  72. package/dist/shared/lib/safe-error.js +39 -0
  73. package/dist/shared/lib/sanitize-html.js +24 -15
  74. package/dist/shared/lib/server-clock.js +11 -7
  75. package/dist/shared/lib/sheet-def.js +38 -22
  76. package/dist/shared/lib/unique-options.js +10 -0
  77. package/dist/shared/lib/unsaved-work.js +62 -0
  78. package/dist/shared/lib/utils.js +57 -43
  79. package/dist/shared/lib/validation-rules.js +58 -34
  80. package/package.json +1 -1
@@ -1,27 +1,28 @@
1
1
  import { useState as $, useEffect as T } from "react";
2
2
  import { post as F } from "../../lib/commands.js";
3
3
  import { useOptionalRealtime as Q } from "../../lib/realtime.js";
4
- const R = "nivaro-chat-outbox", v = "entries", j = "nvr-chat-outbox", J = 1440 * 60 * 1e3, P = 8e3, Y = "nvr-chat-outbox:flush";
5
- let G = !1;
4
+ import { userErrorMessage as R } from "../../lib/safe-error.js";
5
+ const j = "nivaro-chat-outbox", p = "entries", J = "nvr-chat-outbox", P = 1440 * 60 * 1e3, Y = 8e3, G = "nvr-chat-outbox:flush";
6
+ let I = !1;
6
7
  const h = /* @__PURE__ */ new Map();
7
- function I() {
8
+ function U() {
8
9
  return new Promise((e) => {
9
10
  try {
10
- if (G || typeof indexedDB > "u") return e(null);
11
- const t = indexedDB.open(R, 1);
11
+ if (I || typeof indexedDB > "u") return e(null);
12
+ const t = indexedDB.open(j, 1);
12
13
  t.onupgradeneeded = () => {
13
- t.result.objectStoreNames.contains(v) || t.result.createObjectStore(v, { keyPath: "client_id" });
14
+ t.result.objectStoreNames.contains(p) || t.result.createObjectStore(p, { keyPath: "client_id" });
14
15
  }, t.onsuccess = () => e(t.result), t.onerror = () => e(null), t.onblocked = () => e(null);
15
16
  } catch {
16
17
  e(null);
17
18
  }
18
19
  });
19
20
  }
20
- async function y(e, t) {
21
- const n = await I();
21
+ async function m(e, t) {
22
+ const n = await U();
22
23
  return n ? new Promise((i) => {
23
24
  try {
24
- const a = n.transaction(v, e), r = t(a.objectStore(v));
25
+ const a = n.transaction(p, e), r = t(a.objectStore(p));
25
26
  r.onsuccess = () => i({ ok: !0, value: r.result }), r.onerror = () => i({ ok: !1, value: null }), a.oncomplete = () => n.close(), a.onerror = () => {
26
27
  n.close(), i({ ok: !1, value: null });
27
28
  };
@@ -30,27 +31,27 @@ async function y(e, t) {
30
31
  }
31
32
  }) : { ok: !1, value: null };
32
33
  }
33
- const U = (e) => JSON.parse(JSON.stringify(e));
34
+ const X = (e) => JSON.parse(JSON.stringify(e));
34
35
  async function q(e) {
35
- h.set(e.client_id, e), await y("readwrite", (t) => t.put(U(e)));
36
+ h.set(e.client_id, e), await m("readwrite", (t) => t.put(X(e)));
36
37
  }
37
38
  async function L(e) {
38
- h.delete(e), await y("readwrite", (t) => t.delete(e));
39
+ h.delete(e), await m("readwrite", (t) => t.delete(e));
39
40
  }
40
41
  async function C(e) {
41
- const t = await y("readonly", (n) => n.get(e));
42
+ const t = await m("readonly", (n) => n.get(e));
42
43
  return t.ok ? t.value ?? null : h.get(e) ?? null;
43
44
  }
44
- async function B() {
45
- const e = await y("readonly", (t) => t.getAll());
45
+ async function M() {
46
+ const e = await m("readonly", (t) => t.getAll());
46
47
  return e.ok ? e.value ?? [] : [...h.values()];
47
48
  }
48
49
  let o = [];
49
50
  const D = /* @__PURE__ */ new Set();
50
- let p = null, s = null, l = null, M = !1, m = null, _ = !1, A = !1, f = null;
51
+ let v = null, s = null, c = null, B = !1, y = null, _ = !1, A = !1, f = null;
51
52
  const S = /* @__PURE__ */ new Set();
52
53
  let k = 0, g = !1;
53
- function X(e) {
54
+ function z(e) {
54
55
  return `${typeof location < "u" ? location.host : ""}|${e}`;
55
56
  }
56
57
  function w() {
@@ -64,9 +65,9 @@ function O() {
64
65
  }
65
66
  const E = (e, t) => e.created_at < t.created_at ? -1 : e.created_at > t.created_at ? 1 : 0;
66
67
  async function b() {
67
- if (!l || M) return;
68
- const e = l, t = await B();
69
- if (l !== e) return;
68
+ if (!c || B) return;
69
+ const e = c, t = await M();
70
+ if (c !== e) return;
70
71
  const n = t.filter((a) => (a == null ? void 0 : a.owner) === e).sort(E), i = new Set(n.map((a) => a.client_id));
71
72
  o = [
72
73
  ...n,
@@ -75,9 +76,9 @@ async function b() {
75
76
  }
76
77
  function x(e, t = Date.now()) {
77
78
  const n = new Date(e.created_at).getTime();
78
- return !Number.isFinite(n) || t - n > J;
79
+ return !Number.isFinite(n) || t - n > P;
79
80
  }
80
- function z(e, t = Date.now()) {
81
+ function H(e, t = Date.now()) {
81
82
  const n = /* @__PURE__ */ new Set();
82
83
  for (const i of [...e].sort(E))
83
84
  if (i.status !== "failed" && !n.has(i.room) && (n.add(i.room), !(i.held || x(i, t))))
@@ -93,29 +94,29 @@ async function d(e, t) {
93
94
  async function K(e) {
94
95
  o = o.filter((t) => t.client_id !== e), w(), await L(e), O();
95
96
  }
96
- function st(e, t, n) {
97
+ function lt(e, t, n) {
97
98
  var r;
98
- if (p = e, s = t, !n) return;
99
- const i = X(n);
100
- if (i === l) return;
101
- if (l = i, o = [], w(), !A && typeof window < "u" && (A = !0, window.addEventListener("online", () => u(0)), (r = document.addEventListener) == null || r.call(document, "visibilitychange", () => {
102
- document.visibilityState === "visible" && o.some((c) => c.status === "queued") && u(0);
99
+ if (v = e, s = t, !n) return;
100
+ const i = z(n);
101
+ if (i === c) return;
102
+ if (c = i, o = [], w(), !A && typeof window < "u" && (A = !0, window.addEventListener("online", () => u(0)), (r = document.addEventListener) == null || r.call(document, "visibilitychange", () => {
103
+ document.visibilityState === "visible" && o.some((l) => l.status === "queued") && u(0);
103
104
  })), typeof BroadcastChannel < "u" && !f)
104
105
  try {
105
106
  f = new BroadcastChannel("nvr-chat-outbox"), f.onmessage = () => void b();
106
107
  } catch {
107
108
  f = null;
108
109
  }
109
- const a = l;
110
+ const a = c;
110
111
  (async () => {
111
- for (const c of await B()) c && c.owner !== a && await L(c.client_id);
112
- await H(n, a), await b(), o.length && u(1e3);
112
+ for (const l of await M()) l && l.owner !== a && await L(l.client_id);
113
+ await V(n, a), await b(), o.length && u(1e3);
113
114
  })();
114
115
  }
115
- async function H(e, t) {
116
+ async function V(e, t) {
116
117
  try {
117
118
  if (typeof localStorage > "u") return;
118
- const n = `${j}:${e}`, i = localStorage.getItem(n);
119
+ const n = `${J}:${e}`, i = localStorage.getItem(n);
119
120
  if (!i) return;
120
121
  localStorage.removeItem(n);
121
122
  const a = JSON.parse(i);
@@ -124,17 +125,17 @@ async function H(e, t) {
124
125
  } catch {
125
126
  }
126
127
  }
127
- async function ut() {
128
- o = [], h.clear(), l = null, w(), await y("readwrite", (e) => e.clear()), O();
128
+ async function ct() {
129
+ o = [], h.clear(), c = null, w(), await m("readwrite", (e) => e.clear()), O();
129
130
  }
130
- function ct(e) {
131
+ function dt(e) {
131
132
  const t = typeof navigator < "u" && navigator.onLine === !1, n = g || t;
132
133
  let i = Date.parse(e.created_at) || Date.now();
133
134
  i <= k && (i = k + 1), k = i;
134
135
  const a = {
135
136
  ...e,
136
137
  created_at: new Date(i).toISOString(),
137
- owner: l ?? void 0,
138
+ owner: c ?? void 0,
138
139
  status: n ? "queued" : "sending",
139
140
  error: n ? "Waiting for a connection" : null,
140
141
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
@@ -144,50 +145,50 @@ function ct(e) {
144
145
  });
145
146
  }
146
147
  function u(e) {
147
- m && clearTimeout(m), m = setTimeout(() => {
148
- m = null, W();
148
+ y && clearTimeout(y), y = setTimeout(() => {
149
+ y = null, W();
149
150
  }, e);
150
151
  }
151
- function V() {
152
+ function Z() {
152
153
  o.some((e) => e.status === "queued" || e.status === "sending") && u(0);
153
154
  }
154
- function Z(e) {
155
+ function tt(e) {
155
156
  var i;
156
157
  const t = e, n = (t == null ? void 0 : t.status) ?? ((i = t == null ? void 0 : t.response) == null ? void 0 : i.status);
157
158
  return n == null ? !(t != null && t.response) : n === 0 || n === 502 || n === 503 || n === 504;
158
159
  }
159
- function tt() {
160
+ function et() {
160
161
  var e;
161
162
  return ((e = globalThis.navigator) == null ? void 0 : e.locks) ?? null;
162
163
  }
163
164
  async function W() {
164
- if (_ || !p) return;
165
- const e = tt();
165
+ if (_ || !v) return;
166
+ const e = et();
166
167
  if (!e) return N();
167
168
  let t = !1;
168
- await e.request(Y, { ifAvailable: !0 }, async (n) => {
169
+ await e.request(G, { ifAvailable: !0 }, async (n) => {
169
170
  n && (t = !0, await N());
170
171
  }).catch(() => {
171
172
  }), !t && o.some((n) => n.status !== "failed" && !n.held) && u(1500);
172
173
  }
173
174
  async function N() {
174
- if (_ || !p) return;
175
+ if (_ || !v) return;
175
176
  _ = !0;
176
- const e = p;
177
+ const e = v;
177
178
  try {
178
- await b(), et();
179
+ await b(), nt();
179
180
  for (let t = 0; t < 500; t++) {
180
- const n = z(o);
181
+ const n = H(o);
181
182
  if (!n) return;
182
- const i = M ? n : await C(n.client_id);
183
+ const i = B ? n : await C(n.client_id);
183
184
  if (!i || i.held || i.status === "failed") {
184
185
  i || S.delete(n.client_id), await b(), i || (o = o.filter((r) => r.client_id !== n.client_id));
185
186
  continue;
186
187
  }
187
- if (await d(i.client_id, { status: "sending", error: null }), await nt(e, i) === "offline") {
188
+ if (await d(i.client_id, { status: "sending", error: null }), await it(e, i) === "offline") {
188
189
  for (const r of o)
189
190
  r.status === "sending" && r.client_id !== i.client_id && await d(r.client_id, { status: "queued", error: "Waiting for a connection" });
190
- u(P);
191
+ u(Y);
191
192
  return;
192
193
  }
193
194
  }
@@ -195,7 +196,7 @@ async function N() {
195
196
  _ = !1;
196
197
  }
197
198
  }
198
- function et() {
199
+ function nt() {
199
200
  const e = Date.now();
200
201
  for (const t of o)
201
202
  t.status !== "failed" && !t.held && x(t, e) && d(t.client_id, {
@@ -203,7 +204,7 @@ function et() {
203
204
  error: "Not sent — it waited more than a day for a connection"
204
205
  });
205
206
  }
206
- async function nt(e, t) {
207
+ async function it(e, t) {
207
208
  try {
208
209
  const n = await e.request(
209
210
  F("/chat/messages", {
@@ -224,17 +225,17 @@ async function nt(e, t) {
224
225
  (a) => a && !a.data.some((r) => r.id === i.id) ? { ...a, data: [...a.data, i] } : a
225
226
  )), s == null || s.invalidateQueries({ queryKey: ["nvr-chat", t.room] }), s == null || s.invalidateQueries({ queryKey: ["nvr-chat-thread", t.room] }), s == null || s.invalidateQueries({ queryKey: ["nvr-chat-rooms"] }), "sent";
226
227
  } catch (n) {
227
- if (Z(n))
228
+ if (tt(n))
228
229
  return g = !0, await d(t.client_id, { status: "queued", error: "Waiting for a connection" }), "offline";
229
230
  g = !1;
230
231
  const i = n == null ? void 0 : n.response;
231
232
  return await d(t.client_id, {
232
233
  status: "failed",
233
- error: (i == null ? void 0 : i.error) ?? (n instanceof Error ? n.message : "Could not send")
234
+ error: (i == null ? void 0 : i.error) ?? R(n, "Could not send")
234
235
  }), "failed";
235
236
  }
236
237
  }
237
- function lt(e) {
238
+ function ft(e) {
238
239
  const t = o.find((n) => n.client_id === e);
239
240
  !t || t.status === "sending" || d(e, {
240
241
  status: "queued",
@@ -243,22 +244,22 @@ function lt(e) {
243
244
  created_at: x(t) ? (/* @__PURE__ */ new Date()).toISOString() : t.created_at
244
245
  }).then(() => u(0));
245
246
  }
246
- function it(e) {
247
+ function at(e) {
247
248
  const t = o.find((n) => n.client_id === e);
248
249
  !t || t.status === "sending" || K(e).then(() => u(0));
249
250
  }
250
- function dt(e, t) {
251
+ function wt(e, t) {
251
252
  const n = o.find((i) => i.client_id === e);
252
253
  return !n || n.status === "sending" ? !1 : (d(e, { held: t }).then(() => {
253
254
  t || u(0);
254
255
  }), !0);
255
256
  }
256
- function ft(e, t) {
257
+ function ht(e, t) {
257
258
  const n = o.find((a) => a.client_id === e);
258
259
  if (!n || n.status === "sending") return;
259
260
  const i = t.replace(/\s+$/, "");
260
261
  if (!i.trim() && n.attachments.length === 0) {
261
- it(e);
262
+ at(e);
262
263
  return;
263
264
  }
264
265
  d(e, {
@@ -269,7 +270,7 @@ function ft(e, t) {
269
270
  created_at: x(n) ? (/* @__PURE__ */ new Date()).toISOString() : n.created_at
270
271
  }).then(() => u(0));
271
272
  }
272
- function wt(e, t = null) {
273
+ function mt(e, t = null) {
273
274
  const [, n] = $(0), i = Q();
274
275
  return T(() => {
275
276
  const a = () => n((r) => r + 1);
@@ -280,24 +281,24 @@ function wt(e, t = null) {
280
281
  var r;
281
282
  if (!(i != null && i.onStatus)) return;
282
283
  let a = ((r = i.status) == null ? void 0 : r.call(i).state) ?? "live";
283
- return i.onStatus((c) => {
284
- c.state === "live" && a !== "live" && V(), a = c.state;
284
+ return i.onStatus((l) => {
285
+ l.state === "live" && a !== "live" && Z(), a = l.state;
285
286
  });
286
287
  }, [i]), o.filter((a) => a.room === e && (a.parent_id ?? null) === t);
287
288
  }
288
289
  export {
289
- J as OUTBOX_STALE_MS,
290
- st as bindChatOutbox,
291
- ut as clearChatOutbox,
292
- it as discardOutbox,
293
- ft as editOutbox,
294
- ct as enqueueChatOutbox,
290
+ P as OUTBOX_STALE_MS,
291
+ lt as bindChatOutbox,
292
+ ct as clearChatOutbox,
293
+ at as discardOutbox,
294
+ ht as editOutbox,
295
+ dt as enqueueChatOutbox,
295
296
  W as flushChatOutbox,
296
- dt as holdOutbox,
297
+ wt as holdOutbox,
297
298
  x as isStaleOutboxItem,
298
- z as nextToSend,
299
- V as nudgeChatOutbox,
300
- lt as retryOutbox,
299
+ H as nextToSend,
300
+ Z as nudgeChatOutbox,
301
+ ft as retryOutbox,
301
302
  u as scheduleFlush,
302
- wt as useOutbox
303
+ mt as useOutbox
303
304
  };
@@ -1,9 +1,10 @@
1
1
  import { useEffect as o } from "react";
2
- function u(n, e) {
2
+ import { useUnsavedWork as t } from "../../../lib/unsaved-work.js";
3
+ function d(n, e) {
3
4
  return n && (e === "countdown" || e === "recording" || e === "saving" || e === "remote");
4
5
  }
5
- function i(n) {
6
- o(() => {
6
+ function f(n) {
7
+ t(n, "Video recording"), o(() => {
7
8
  if (!n) return;
8
9
  const e = (r) => {
9
10
  r.preventDefault(), r.returnValue = "";
@@ -12,6 +13,6 @@ function i(n) {
12
13
  }, [n]);
13
14
  }
14
15
  export {
15
- u as leaveWarningActive,
16
- i as useLeaveWarning
16
+ d as leaveWarningActive,
17
+ f as useLeaveWarning
17
18
  };