@nivaro/react 0.3.9 → 0.3.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/components/fields/FileField.js +20 -19
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useNivaroForm.js +129 -126
  4. package/dist/hooks/useSessionRecorder.js +1 -1
  5. package/dist/index.d.ts +69 -1
  6. package/dist/index.js +512 -501
  7. package/dist/shared/components/CollectionBrowserView.js +1000 -1001
  8. package/dist/shared/components/ConformanceView.js +36 -35
  9. package/dist/shared/components/ForceReloadBanner.js +58 -34
  10. package/dist/shared/components/ItemEditForm.js +3687 -3580
  11. package/dist/shared/components/JsonMapEditor.js +18 -17
  12. package/dist/shared/components/MatrixEditor.js +8 -7
  13. package/dist/shared/components/MyWorkView.js +32 -31
  14. package/dist/shared/components/PageRenderer.js +146 -145
  15. package/dist/shared/components/RecordGridEditor.js +76 -75
  16. package/dist/shared/components/ai/AiMemorySuggestions.js +15 -14
  17. package/dist/shared/components/ai/AskPanel.js +55 -54
  18. package/dist/shared/components/bulk/BulkActionButtons.js +30 -29
  19. package/dist/shared/components/bulk/PushBulkButtons.js +57 -56
  20. package/dist/shared/components/chat/SlashCommands.js +30 -29
  21. package/dist/shared/components/chat/chat-outbox.js +76 -75
  22. package/dist/shared/components/help-videos/recorder/useLeaveWarning.js +6 -5
  23. package/dist/shared/components/integrations/console/SignalCard.js +124 -123
  24. package/dist/shared/components/integrations/console/SnoozeMenu.js +24 -23
  25. package/dist/shared/components/item-edit/CloneDialog.js +85 -78
  26. package/dist/shared/components/item-edit/InlineTableField.js +301 -300
  27. package/dist/shared/components/item-edit/MembershipSetField.js +24 -23
  28. package/dist/shared/components/item-edit/QuickCreateButton.js +8 -7
  29. package/dist/shared/components/item-edit/RecordLiveSync.js +101 -100
  30. package/dist/shared/components/item-edit/staged-links.js +86 -0
  31. package/dist/shared/components/layout-editor/LayoutEditor.js +275 -274
  32. package/dist/shared/components/layout-editor/editors/cascade-rule-row.js +18 -17
  33. package/dist/shared/components/layout-editor/inspector/HelpTab.js +37 -36
  34. package/dist/shared/components/layout-editor/matrix/FieldStateMatrix.js +50 -49
  35. package/dist/shared/components/profile/AiMemoryCard.js +15 -14
  36. package/dist/shared/components/profile/PersonAdminTools.js +70 -67
  37. package/dist/shared/components/queue/QueueItemSheet.js +36 -35
  38. package/dist/shared/components/queue/QueueWorklist.js +597 -598
  39. package/dist/shared/lib/client-version.js +63 -0
  40. package/dist/shared/lib/force-reload.js +36 -0
  41. package/dist/shared/lib/load-error.js +11 -10
  42. package/dist/shared/lib/presence-live.js +54 -35
  43. package/dist/shared/lib/record-outbox.js +76 -75
  44. package/dist/shared/lib/safe-error.js +39 -0
  45. package/dist/shared/lib/server-clock.js +11 -7
  46. package/dist/shared/lib/unsaved-work.js +62 -0
  47. package/package.json +1 -1
@@ -1,13 +1,14 @@
1
1
  import { jsxs as n, jsx as e } from "react/jsx-runtime";
2
2
  import { useQueryClient as E, useQuery as F } from "@tanstack/react-query";
3
3
  import { useState as f, useRef as W, useEffect as O, useMemo as Y } from "react";
4
- import { useNivaroClient as M, useItemNavigation as V, useNavigation as j } from "../context.js";
5
- import { get as B, post as A, put as G } from "../lib/commands.js";
4
+ import { useNivaroClient as B, useItemNavigation as V, useNavigation as j } from "../context.js";
5
+ import { get as M, post as A, put as G } from "../lib/commands.js";
6
6
  import { useLiveWatchRoom as H, useLiveEvent as J } from "../lib/live.js";
7
+ import { userErrorMessage as X } from "../lib/safe-error.js";
7
8
  import { cn as N } from "../lib/utils.js";
8
9
  import { PickList as Q } from "./imports/ServiceConfigBuilder.js";
9
- import { TipLayer as X } from "./TipLayer.js";
10
- function Z({ p: t }) {
10
+ import { TipLayer as Z } from "./TipLayer.js";
11
+ function P({ p: t }) {
11
12
  const a = t.total ? Math.min(100, Math.round(t.checked / t.total * 100)) : null;
12
13
  return /* @__PURE__ */ n("div", { className: "flex items-center gap-3 text-[11.5px]", "data-conformance-sweep": t.run, children: [
13
14
  /* @__PURE__ */ e("span", { className: "w-[180px] shrink-0 truncate font-medium text-slate-700 dark:text-foreground", children: t.collection }),
@@ -44,7 +45,7 @@ function Z({ p: t }) {
44
45
  ] })
45
46
  ] });
46
47
  }
47
- function P(t) {
48
+ function ee(t) {
48
49
  if (!t) return "";
49
50
  const a = Date.now() - new Date(t).getTime(), s = Math.round(a / 6e4);
50
51
  if (s < 1) return "just now";
@@ -52,7 +53,7 @@ function P(t) {
52
53
  const p = Math.round(s / 60);
53
54
  return p < 24 ? `${p}h ago` : new Date(t).toLocaleDateString();
54
55
  }
55
- function ee(t) {
56
+ function te(t) {
56
57
  if (!t.started_at || !t.finished_at) return "";
57
58
  const a = Math.round(
58
59
  (new Date(t.finished_at).getTime() - new Date(t.started_at).getTime()) / 1e3
@@ -97,10 +98,10 @@ const T = {
97
98
  cls: "bg-purple-500/10 text-purple-700 dark:text-purple-400"
98
99
  }
99
100
  }, K = (t) => t.replace(/[-_]+/g, " ").replace(/^\w/, (a) => a.toUpperCase());
100
- function te({ findingId: t }) {
101
- const a = M(), [s, p] = f(!1), [x, i] = f(""), [o, c] = f(!1), [b, g] = f(null), w = F({
101
+ function re({ findingId: t }) {
102
+ const a = B(), [s, p] = f(!1), [x, i] = f(""), [o, c] = f(!1), [b, g] = f(null), w = F({
102
103
  queryKey: ["conformance-assign-users", x],
103
- queryFn: () => a.request(B(`/users?search=${encodeURIComponent(x)}&limit=8`)).then((u) => u.data),
104
+ queryFn: () => a.request(M(`/users?search=${encodeURIComponent(x)}&limit=8`)).then((u) => u.data),
104
105
  enabled: s && x.trim().length >= 2,
105
106
  staleTime: 3e4
106
107
  }), v = async (u) => {
@@ -165,8 +166,8 @@ function te({ findingId: t }) {
165
166
  )
166
167
  ] });
167
168
  }
168
- function fe({ className: t }) {
169
- const a = M(), s = E(), p = V(), x = j(), [i, o] = f(""), [c, b] = f(null), [g, w] = f(!1), [v, u] = f(null), [d, q] = f("5000"), L = H("conformance"), [r, h] = f({}), m = W(null);
169
+ function ge({ className: t }) {
170
+ const a = B(), s = E(), p = V(), x = j(), [i, o] = f(""), [c, b] = f(null), [g, w] = f(!1), [v, u] = f(null), [d, q] = f("5000"), L = H("conformance"), [r, h] = f({}), m = W(null);
170
171
  O(
171
172
  () => () => {
172
173
  m.current && clearTimeout(m.current);
@@ -191,13 +192,13 @@ function fe({ className: t }) {
191
192
  const { data: $ = [], isLoading: C } = F(
192
193
  {
193
194
  queryKey: ["conformance-collections"],
194
- queryFn: () => a.request(B("/config-conformance/collections")).then((l) => l.data ?? []),
195
+ queryFn: () => a.request(M("/config-conformance/collections")).then((l) => l.data ?? []),
195
196
  staleTime: 5 * 6e4
196
197
  }
197
198
  ), { data: k = [], isFetched: U } = F({
198
199
  queryKey: ["conformance-runs", i],
199
200
  queryFn: () => a.request(
200
- B(`/config-conformance/runs${i ? `?collection=${i}` : ""}`)
201
+ M(`/config-conformance/runs${i ? `?collection=${i}` : ""}`)
201
202
  ).then((l) => l.data ?? []),
202
203
  refetchInterval: (l) => {
203
204
  var _;
@@ -217,14 +218,14 @@ function fe({ className: t }) {
217
218
  );
218
219
  b(l.data.id), s.invalidateQueries({ queryKey: ["conformance-runs"] });
219
220
  } catch (l) {
220
- u(l instanceof Error ? l.message : "Could not start the run");
221
+ u(X(l, "Could not start the run"));
221
222
  } finally {
222
223
  w(!1);
223
224
  }
224
225
  }
225
226
  };
226
227
  return /* @__PURE__ */ n("div", { className: N("flex min-h-0 flex-1 flex-col gap-4 p-6", t), "data-conformance": !0, children: [
227
- /* @__PURE__ */ e(X, {}),
228
+ /* @__PURE__ */ e(Z, {}),
228
229
  /* @__PURE__ */ n("div", { className: "flex flex-wrap items-end gap-3", children: [
229
230
  /* @__PURE__ */ n("div", { className: "w-[300px]", children: [
230
231
  /* @__PURE__ */ e("p", { className: "mb-1 text-[11.5px] font-medium text-slate-700 dark:text-foreground", children: "Collection" }),
@@ -287,8 +288,8 @@ function fe({ className: t }) {
287
288
  children: g ? "Starting…" : "Run checks"
288
289
  }
289
290
  ),
290
- i && /* @__PURE__ */ e(re, { collection: i }),
291
- k.filter((l) => l.status === "completed").length >= 2 && /* @__PURE__ */ e(ae, { runs: k }),
291
+ i && /* @__PURE__ */ e(ae, { collection: i }),
292
+ k.filter((l) => l.status === "completed").length >= 2 && /* @__PURE__ */ e(ne, { runs: k }),
292
293
  v && /* @__PURE__ */ e("p", { className: "pb-1.5 text-[12px] text-red-600 dark:text-red-400", children: v })
293
294
  ] }),
294
295
  I.length > 0 && /* @__PURE__ */ n(
@@ -298,13 +299,13 @@ function fe({ className: t }) {
298
299
  "data-conformance-sweeps": !0,
299
300
  children: [
300
301
  /* @__PURE__ */ e("p", { className: "text-[10.5px] font-semibold uppercase tracking-wide text-slate-400", children: "Sweeps in progress" }),
301
- I.map((l) => /* @__PURE__ */ e(Z, { p: l }, l.run))
302
+ I.map((l) => /* @__PURE__ */ e(P, { p: l }, l.run))
302
303
  ]
303
304
  }
304
305
  ),
305
- k.length > 0 && /* @__PURE__ */ e(ne, { runs: k, activeId: (S == null ? void 0 : S.id) ?? null, onSelect: b }),
306
+ k.length > 0 && /* @__PURE__ */ e(le, { runs: k, activeId: (S == null ? void 0 : S.id) ?? null, onSelect: b }),
306
307
  S && /* @__PURE__ */ e(
307
- le,
308
+ oe,
308
309
  {
309
310
  run: S,
310
311
  liveProgress: r[S.id] ?? null,
@@ -326,11 +327,11 @@ function fe({ className: t }) {
326
327
  ] })
327
328
  ] });
328
329
  }
329
- function re({ collection: t }) {
330
- const a = M(), s = E(), { data: p, isError: x } = F({
330
+ function ae({ collection: t }) {
331
+ const a = B(), s = E(), { data: p, isError: x } = F({
331
332
  queryKey: ["conformance-schedules"],
332
333
  queryFn: () => a.request(
333
- B("/config-conformance/schedules")
334
+ M("/config-conformance/schedules")
334
335
  ).then((o) => o.data ?? []),
335
336
  retry: !1,
336
337
  staleTime: 6e4
@@ -363,7 +364,7 @@ function re({ collection: t }) {
363
364
  "Nightly sweep"
364
365
  ] });
365
366
  }
366
- function ae({ runs: t }) {
367
+ function ne({ runs: t }) {
367
368
  const a = t.filter((c) => c.status === "completed").slice(0, 12).reverse();
368
369
  if (a.length < 2) return null;
369
370
  const s = Math.max(...a.map((c) => c.violation_count), 1), p = 90, x = 22, i = a.map(
@@ -386,7 +387,7 @@ function ae({ runs: t }) {
386
387
  }
387
388
  );
388
389
  }
389
- function ne({
390
+ function le({
390
391
  runs: t,
391
392
  activeId: a,
392
393
  onSelect: s
@@ -426,13 +427,13 @@ function ne({
426
427
  o.violation_count === 1 ? "" : "s"
427
428
  ] }) }),
428
429
  /* @__PURE__ */ e("td", { className: "px-2 py-1.5 text-right text-slate-500 dark:text-muted-foreground", children: o.checked_records.toLocaleString() }),
429
- /* @__PURE__ */ e("td", { className: "px-2 py-1.5 text-right text-slate-500 dark:text-muted-foreground", children: ee(o) }),
430
+ /* @__PURE__ */ e("td", { className: "px-2 py-1.5 text-right text-slate-500 dark:text-muted-foreground", children: te(o) }),
430
431
  /* @__PURE__ */ e(
431
432
  "td",
432
433
  {
433
434
  className: "px-2 py-1.5 text-slate-500 dark:text-muted-foreground",
434
435
  "data-tip": o.started_at ? new Date(o.started_at).toLocaleString() : void 0,
435
- children: P(o.started_at)
436
+ children: ee(o.started_at)
436
437
  }
437
438
  ),
438
439
  /* @__PURE__ */ e("td", { className: "px-3 py-1.5 text-slate-500 dark:text-muted-foreground", children: o.triggered_by_name ?? "—" })
@@ -452,16 +453,16 @@ function ne({
452
453
  )
453
454
  ] });
454
455
  }
455
- function le({
456
+ function oe({
456
457
  run: t,
457
458
  onOpenItem: a,
458
459
  liveProgress: s,
459
460
  live: p
460
461
  }) {
461
- const x = M(), [i, o] = f(1), [c, b] = f(""), [g, w] = f(""), [v, u] = f(!1), { data: d } = F({
462
+ const x = B(), [i, o] = f(1), [c, b] = f(""), [g, w] = f(""), [v, u] = f(!1), { data: d } = F({
462
463
  queryKey: ["conformance-run", t.id, i, c, g, v],
463
464
  queryFn: () => x.request(
464
- B(
465
+ M(
465
466
  `/config-conformance/runs/${t.id}?page=${i}&limit=50${c ? `&rule=${c}` : ""}${g ? `&field=${g}` : ""}${v ? "&group=record" : ""}`
466
467
  )
467
468
  ).then((r) => r.data),
@@ -568,7 +569,7 @@ function le({
568
569
  "row-rule",
569
570
  "required",
570
571
  "row-input"
571
- ].includes(c) && /* @__PURE__ */ e(oe, { run: t, rule: c, field: g, total: (d == null ? void 0 : d.total) ?? 0 }),
572
+ ].includes(c) && /* @__PURE__ */ e(se, { run: t, rule: c, field: g, total: (d == null ? void 0 : d.total) ?? 0 }),
572
573
  /* @__PURE__ */ n("div", { className: "min-h-0 flex-1 overflow-y-auto", children: [
573
574
  d !== void 0 && ((d == null ? void 0 : d.findings) ?? []).length === 0 && t.status === "completed" && /* @__PURE__ */ e("p", { className: "px-4 py-6 text-[12.5px] text-emerald-600 dark:text-emerald-400", children: c || g ? "No findings match the filters." : "Every checked record satisfies its field configuration." }),
574
575
  v ? /* @__PURE__ */ e("div", { children: ((d == null ? void 0 : d.findings) ?? []).map((r) => /* @__PURE__ */ n(
@@ -658,7 +659,7 @@ function le({
658
659
  }
659
660
  ) }),
660
661
  /* @__PURE__ */ e("td", { className: "px-2 py-1.5 text-slate-600 dark:text-muted-foreground", children: r.message }),
661
- /* @__PURE__ */ e("td", { className: "w-[120px] px-2 py-1.5 text-right", children: /* @__PURE__ */ e(te, { findingId: r.id }) })
662
+ /* @__PURE__ */ e("td", { className: "w-[120px] px-2 py-1.5 text-right", children: /* @__PURE__ */ e(re, { findingId: r.id }) })
662
663
  ]
663
664
  },
664
665
  r.id
@@ -695,13 +696,13 @@ function le({
695
696
  ] })
696
697
  ] });
697
698
  }
698
- function oe({
699
+ function se({
699
700
  run: t,
700
701
  rule: a,
701
702
  field: s,
702
703
  total: p
703
704
  }) {
704
- const x = M(), i = E(), o = j(), [c, b] = f(null), [g, w] = f(!1), [v, u] = f(null), [d, q] = f(!1);
705
+ const x = B(), i = E(), o = j(), [c, b] = f(null), [g, w] = f(!1), [v, u] = f(null), [d, q] = f(!1);
705
706
  if (p === 0 && !v) return null;
706
707
  const L = () => {
707
708
  q(!0), x.request(
@@ -784,5 +785,5 @@ function oe({
784
785
  ] });
785
786
  }
786
787
  export {
787
- fe as ConformanceView
788
+ ge as ConformanceView
788
789
  };
@@ -1,49 +1,73 @@
1
- import { jsxs as a, jsx as c } from "react/jsx-runtime";
2
- import { RotateCw as p } from "lucide-react";
3
- import { useState as m, useRef as h, useEffect as l } from "react";
4
- const w = "nvr:force-refresh";
5
- function E() {
6
- const [t, u] = m(null), [b, o] = m(() => Date.now()), s = h(!1);
7
- l(() => {
8
- const e = (n) => {
9
- const r = n.detail ?? {}, f = Math.max(5, Number(r.seconds) || 30), d = Date.now();
10
- u({ deadline: d + f * 1e3, message: String(r.message ?? "") }), o(d);
1
+ import { jsxs as c, jsx as s, Fragment as x } from "react/jsx-runtime";
2
+ import { PauseCircle as N, RotateCw as F } from "lucide-react";
3
+ import { useState as h, useRef as w, useEffect as k } from "react";
4
+ import { markReloadFor as E } from "../lib/client-version.js";
5
+ import { shouldObeyForceReload as j, thisTabForReload as T } from "../lib/force-reload.js";
6
+ import { subscribeUnsavedWork as C, unsavedWorkLabels as D } from "../lib/unsaved-work.js";
7
+ const L = "nvr:force-refresh";
8
+ function W() {
9
+ const [e, R] = h(null), [y, b] = h(() => Date.now()), [g, l] = h([]), o = w(!1), m = w(!1), p = w(/* @__PURE__ */ new Set());
10
+ k(() => {
11
+ const i = (r) => {
12
+ const t = r.detail ?? {}, n = typeof t.id == "string" && t.id ? t.id : null;
13
+ if (n && p.current.has(n) || !j(t, T())) return;
14
+ n && p.current.add(n), m.current = !1, l([]);
15
+ const d = Math.max(5, Number(t.seconds) || 30), a = Date.now();
16
+ R({ deadline: a + d * 1e3, message: String(t.message ?? ""), id: n }), b(a);
11
17
  };
12
- return window.addEventListener(w, e), () => window.removeEventListener(w, e);
13
- }, []), l(() => {
14
- if (!t) return;
15
- const e = () => {
16
- const r = Date.now();
17
- o(r), r >= t.deadline && !s.current && (s.current = !0, window.location.reload());
18
- }, n = setInterval(e, 1e3);
19
- return document.addEventListener("visibilitychange", e), window.addEventListener("focus", e), window.addEventListener("pageshow", e), () => {
20
- clearInterval(n), document.removeEventListener("visibilitychange", e), window.removeEventListener("focus", e), window.removeEventListener("pageshow", e);
18
+ return window.addEventListener(L, i), () => window.removeEventListener(L, i);
19
+ }, []), k(() => {
20
+ if (!e) return;
21
+ const i = () => {
22
+ o.current || (o.current = !0, e.id && E(e.id), window.location.reload(), setTimeout(() => {
23
+ o.current = !1, m.current = !0, l(["unsaved changes on this page"]);
24
+ }, 1500));
25
+ }, r = () => {
26
+ const d = Date.now();
27
+ if (b(d), d < e.deadline || o.current || m.current) return;
28
+ const a = D();
29
+ l((v) => v.join("|") === a.join("|") ? v : a), a.length === 0 && i();
30
+ }, t = setInterval(r, 1e3);
31
+ document.addEventListener("visibilitychange", r), window.addEventListener("focus", r), window.addEventListener("pageshow", r);
32
+ const n = C(() => setTimeout(r, 0));
33
+ return () => {
34
+ clearInterval(t), document.removeEventListener("visibilitychange", r), window.removeEventListener("focus", r), window.removeEventListener("pageshow", r), n();
21
35
  };
22
- }, [t]);
23
- const i = t ? Math.max(0, Math.ceil((t.deadline - b) / 1e3)) : 0;
24
- return t ? /* @__PURE__ */ a(
36
+ }, [e]);
37
+ const u = e ? Math.max(0, Math.ceil((e.deadline - y) / 1e3)) : 0, f = u === 0 && g.length > 0;
38
+ return e ? /* @__PURE__ */ c(
25
39
  "div",
26
40
  {
27
41
  role: "alert",
28
- "data-nvr-force-reload": i,
42
+ "data-nvr-force-reload": u,
43
+ "data-nvr-force-reload-held": f ? "true" : void 0,
29
44
  "data-nvr-recording-hide": !0,
30
45
  className: "fixed inset-x-0 top-0 z-[150] flex items-center justify-center gap-3 border-b border-amber-300 bg-amber-50 px-4 py-2.5 text-[13px] text-amber-900 dark:border-amber-500/40 dark:bg-[#3a2e10] dark:text-amber-200",
31
46
  children: [
32
- /* @__PURE__ */ c(p, { className: "h-4 w-4 animate-spin" }),
33
- /* @__PURE__ */ a("span", { children: [
34
- /* @__PURE__ */ a("span", { className: "font-semibold", children: [
47
+ f ? /* @__PURE__ */ s(N, { className: "h-4 w-4 shrink-0" }) : /* @__PURE__ */ s(F, { className: "h-4 w-4 shrink-0 animate-spin" }),
48
+ /* @__PURE__ */ s("span", { children: f ? /* @__PURE__ */ c(x, { children: [
49
+ /* @__PURE__ */ s("span", { className: "font-semibold", children: "A reload is waiting" }),
50
+ " — save or discard your changes (",
51
+ g.join(", ").toLowerCase(),
52
+ ") and the page reloads."
53
+ ] }) : /* @__PURE__ */ c(x, { children: [
54
+ /* @__PURE__ */ c("span", { className: "font-semibold", children: [
35
55
  "This page will reload in ",
36
- i,
56
+ u,
37
57
  "s"
38
58
  ] }),
39
- t.message ? ` — ${t.message}` : " — an administrator pushed an update."
40
- ] }),
41
- /* @__PURE__ */ c(
59
+ e.message ? ` — ${e.message}` : " — an administrator pushed an update."
60
+ ] }) }),
61
+ /* @__PURE__ */ s(
42
62
  "button",
43
63
  {
44
64
  type: "button",
45
- onClick: () => window.location.reload(),
46
- className: "rounded-md border border-amber-400 bg-white px-2.5 py-1 text-[12px] font-medium text-amber-800 hover:bg-amber-100 dark:bg-transparent dark:text-amber-200",
65
+ onClick: () => {
66
+ o.current = !0, e.id && E(e.id), window.location.reload(), setTimeout(() => {
67
+ o.current = !1;
68
+ }, 1500);
69
+ },
70
+ className: "shrink-0 rounded-md border border-amber-400 bg-white px-2.5 py-1 text-[12px] font-medium text-amber-800 hover:bg-amber-100 dark:bg-transparent dark:text-amber-200",
47
71
  children: "Reload now"
48
72
  }
49
73
  )
@@ -52,6 +76,6 @@ function E() {
52
76
  ) : null;
53
77
  }
54
78
  export {
55
- w as FORCE_RELOAD_EVENT,
56
- E as ForceReloadBanner
79
+ L as FORCE_RELOAD_EVENT,
80
+ W as ForceReloadBanner
57
81
  };