@nivaro/react 0.3.137 → 0.3.139

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 +95 -4
  4. package/dist/index.js +748 -743
  5. package/dist/shared/components/CollectionBrowserView.js +392 -389
  6. package/dist/shared/components/DelegateCoverLine.js +80 -87
  7. package/dist/shared/components/ItemEditForm.js +589 -588
  8. package/dist/shared/components/MyWorkView.js +284 -286
  9. package/dist/shared/components/NotificationBell.js +251 -205
  10. package/dist/shared/components/ai/AiAnalyticsView.js +878 -417
  11. package/dist/shared/components/ai/AiPlanCard.js +164 -122
  12. package/dist/shared/components/ai/AiPlanUndo.js +291 -0
  13. package/dist/shared/components/ai/call-log/CallDrawer.js +357 -0
  14. package/dist/shared/components/ai/call-log/RawJson.js +126 -0
  15. package/dist/shared/components/ai/call-log/ThreadView.js +223 -0
  16. package/dist/shared/components/ai/call-log/TranscriptView.js +227 -0
  17. package/dist/shared/components/ai/call-log/controls.js +364 -0
  18. package/dist/shared/components/ai/call-log/format.js +46 -0
  19. package/dist/shared/components/ai/call-log/url.js +105 -0
  20. package/dist/shared/components/chat/chat-core.js +422 -346
  21. package/dist/shared/components/integrations/IntegrationObligationsView.js +98 -98
  22. package/dist/shared/components/integrations/RecordIntegrationPreview.js +102 -93
  23. package/dist/shared/components/integrations/console/api.js +11 -1
  24. package/dist/shared/components/item-edit/HeaderRollupExplainer.js +5 -1
  25. package/dist/shared/components/item-edit/RecordLiveSync.js +241 -229
  26. package/dist/shared/components/item-edit/RecordRecapChanges.js +166 -0
  27. package/dist/shared/components/item-edit/RecordRecapStrip.js +254 -84
  28. package/dist/shared/components/item-edit/live-related.js +34 -18
  29. package/dist/shared/components/panels/RevisionsPanel.js +735 -683
  30. package/dist/shared/components/queue/QueueWorklist.js +323 -316
  31. package/dist/shared/components/support/SupportRequestDialog.js +198 -181
  32. package/dist/shared/components/trackers/use-tracker-link.js +74 -65
  33. package/dist/shared/lib/activity-sentence.js +167 -151
  34. package/dist/shared/lib/config-update-refresh.js +34 -0
  35. package/dist/shared/lib/config-watch.js +17 -17
  36. package/dist/shared/lib/gap-refresh.js +49 -0
  37. package/dist/shared/lib/integration-dots.js +8 -8
  38. package/dist/shared/lib/live-ops.js +26 -23
  39. package/dist/shared/lib/live-pickers.js +1 -1
  40. package/dist/shared/lib/live-queries.js +223 -195
  41. package/dist/shared/lib/live.js +56 -51
  42. package/dist/shared/lib/obligation-banner.js +11 -10
  43. package/dist/shared/lib/obligation-filters.js +22 -18
  44. package/dist/shared/lib/obligation-reason-text.js +18 -8
  45. package/dist/shared/lib/presence-hooks.js +133 -132
  46. package/dist/shared/lib/reconnect-resync.js +90 -0
  47. package/dist/shared/lib/record-room-holds.js +43 -0
  48. package/dist/shared/lib/socket-realtime.js +116 -105
  49. package/dist/shared/lib/user-sync.js +1 -6
  50. package/package.json +1 -1
@@ -0,0 +1,34 @@
1
+ import { useQueryClient as v } from "@tanstack/react-query";
2
+ import { useEffect as w } from "react";
3
+ const l = "nvr:config-update";
4
+ function N(n, o) {
5
+ return n ? o.some((e) => !!e && e === n) : !0;
6
+ }
7
+ function J(n, o, e = {}) {
8
+ const r = v(), i = e.enabled !== !1, s = e.jitterMs ?? 1500, c = JSON.stringify(n), f = JSON.stringify(o);
9
+ w(() => {
10
+ if (!i || typeof window > "u") return;
11
+ const d = JSON.parse(c), m = JSON.parse(f);
12
+ let t = null;
13
+ const a = (y) => {
14
+ var u;
15
+ const p = (u = y.detail) == null ? void 0 : u.collection;
16
+ !N(p, d) || t || (t = setTimeout(
17
+ () => {
18
+ t = null;
19
+ for (const h of m)
20
+ r.invalidateQueries({ queryKey: h, refetchType: "active" }, { cancelRefetch: !1 });
21
+ },
22
+ Math.floor(Math.random() * Math.max(0, s))
23
+ ));
24
+ };
25
+ return window.addEventListener(l, a), () => {
26
+ window.removeEventListener(l, a), t && clearTimeout(t);
27
+ };
28
+ }, [r, i, s, c, f]);
29
+ }
30
+ export {
31
+ l as CONFIG_UPDATE_WINDOW_EVENT,
32
+ N as configUpdateTouches,
33
+ J as useConfigUpdateRefresh
34
+ };
@@ -3,32 +3,32 @@ import { useLiveOps as b } from "./live-ops.js";
3
3
  function y(n, t) {
4
4
  return `cfg-${n}:${t}`;
5
5
  }
6
- const l = (n, t) => n != null && t != null && String(n).toLowerCase() === String(t).toLowerCase();
6
+ const d = (n, t) => n != null && t != null && String(n).toLowerCase() === String(t).toLowerCase();
7
7
  function S(n, t, o) {
8
8
  var i;
9
- const r = typeof t.part == "string" && t.part ? t.part : "several", e = t.by, a = e && e.id != null ? { id: String(e.id), name: typeof e.name == "string" ? e.name : "Someone" } : null;
9
+ const r = typeof t.part == "string" && t.part ? t.part : "several", e = t.by, s = e && e.id != null ? { id: String(e.id), name: typeof e.name == "string" ? e.name : "Someone" } : null;
10
10
  return n ? {
11
- by: l((i = n.by) == null ? void 0 : i.id, a == null ? void 0 : a.id) || !n.by && !a ? a : null,
11
+ by: d((i = n.by) == null ? void 0 : i.id, s == null ? void 0 : s.id) || !n.by && !s ? s : null,
12
12
  part: n.part === r ? r : "several",
13
13
  at: o,
14
14
  count: n.count + 1
15
- } : { by: a, part: r, at: o, count: 1 };
15
+ } : { by: s, part: r, at: o, count: 1 };
16
16
  }
17
17
  function $(n, t, o = {}) {
18
- const [r, e] = p(null), a = m(null), s = t != null && t !== "" ? y(n, t) : null, { meId: i, onChange: u } = o;
18
+ const [r, e] = p(null), s = m(null), c = t != null && t !== "" ? y(n, t) : null, { meId: i, onChange: u } = o;
19
19
  b(
20
- s,
21
- (c) => {
22
- if (c != null && c.by && l(c.by.id, i)) return;
23
- const g = S(a.current, c ?? {}, Date.now());
24
- a.current = g, e(g), u == null || u(g);
20
+ c,
21
+ (a) => {
22
+ if (a != null && a.reconnect || a != null && a.by && d(a.by.id, i)) return;
23
+ const g = S(s.current, a ?? {}, Date.now());
24
+ s.current = g, e(g), u == null || u(g);
25
25
  },
26
26
  { enabled: o.enabled !== !1, debounceMs: 250 }
27
27
  );
28
- const f = w(() => {
29
- a.current = null, e(null);
28
+ const l = w(() => {
29
+ s.current = null, e(null);
30
30
  }, []);
31
- return { change: r, clear: f };
31
+ return { change: r, clear: l };
32
32
  }
33
33
  const h = {
34
34
  state: "changed a state",
@@ -67,7 +67,7 @@ const C = /* @__PURE__ */ new Set([
67
67
  "sort",
68
68
  "updated_at"
69
69
  ]);
70
- function d(n) {
70
+ function f(n) {
71
71
  const t = {};
72
72
  for (const o of Object.keys(n).sort()) C.has(o) || (t[o] = n[o]);
73
73
  try {
@@ -77,10 +77,10 @@ function d(n) {
77
77
  }
78
78
  }
79
79
  function W(n, t) {
80
- const o = new Map((n ?? []).map((e) => [String(e.id), d(e)])), r = [];
80
+ const o = new Map((n ?? []).map((e) => [String(e.id), f(e)])), r = [];
81
81
  for (const e of t ?? []) {
82
- const a = String(e.id), s = o.get(a);
83
- s != null && s !== d(e) && r.push(a);
82
+ const s = String(e.id), c = o.get(s);
83
+ c != null && c !== f(e) && r.push(s);
84
84
  }
85
85
  return r;
86
86
  }
@@ -0,0 +1,49 @@
1
+ import { useRef as s, useEffect as l } from "react";
2
+ function a() {
3
+ return typeof document > "u" || document.visibilityState !== "hidden";
4
+ }
5
+ function d(o, r) {
6
+ const u = r.now ?? (() => Date.now()), c = r.isVisible ?? a;
7
+ let t = Number.NEGATIVE_INFINITY, n = null, e = !1;
8
+ const i = () => {
9
+ if (n = null, !c()) {
10
+ e = !0;
11
+ return;
12
+ }
13
+ e = !1, t = u(), o();
14
+ };
15
+ return {
16
+ poke() {
17
+ if (n) return;
18
+ const f = t + r.gapMs - u();
19
+ f <= 0 ? i() : n = setTimeout(i, f);
20
+ },
21
+ resume() {
22
+ !n && e && c() && i();
23
+ },
24
+ cancel() {
25
+ n && clearTimeout(n), n = null, e = !1;
26
+ }
27
+ };
28
+ }
29
+ function p(o, r, u = !0) {
30
+ const c = s(o);
31
+ c.current = o;
32
+ const t = s(null);
33
+ return l(() => {
34
+ if (!u) return;
35
+ const e = d(() => c.current(), { gapMs: r });
36
+ t.current = e;
37
+ const i = () => e.resume();
38
+ return typeof document < "u" && document.addEventListener("visibilitychange", i), () => {
39
+ typeof document < "u" && document.removeEventListener("visibilitychange", i), e.cancel(), t.current === e && (t.current = null);
40
+ };
41
+ }, [r, u]), s(() => {
42
+ var e;
43
+ return (e = t.current) == null ? void 0 : e.poke();
44
+ }).current;
45
+ }
46
+ export {
47
+ d as createGapRefresher,
48
+ p as useGapRefresh
49
+ };
@@ -1,14 +1,14 @@
1
- import { toneForOutcome as s } from "./obligation-filters.js";
1
+ import { toneForObligation as s } from "./obligation-filters.js";
2
2
  const r = { danger: 3, warning: 2, positive: 1, neutral: 0 };
3
- function u(c) {
4
- const e = /* @__PURE__ */ new Map();
5
- for (const o of c) {
3
+ function a(i) {
4
+ const n = /* @__PURE__ */ new Map();
5
+ for (const o of i) {
6
6
  if (o.outcome === "superseded") continue;
7
- const t = s(o.outcome), n = e.get(o.api);
8
- (!n || r[t] > r[n]) && e.set(o.api, t);
7
+ const t = s(o), e = n.get(o.api);
8
+ (!e || r[t] > r[e]) && n.set(o.api, t);
9
9
  }
10
- return [...e.entries()].map(([o, t]) => ({ api: o, tone: t }));
10
+ return [...n.entries()].map(([o, t]) => ({ api: o, tone: t }));
11
11
  }
12
12
  export {
13
- u as dotsForRecord
13
+ a as dotsForRecord
14
14
  };
@@ -1,41 +1,44 @@
1
1
  import { useRef as m, useEffect as l, useState as h } from "react";
2
2
  import { useLiveEvent as S } from "./live.js";
3
3
  import { useOptionalRealtime as b } from "./realtime.js";
4
- function O(t, c, n = {}) {
5
- const s = b(), u = n.enabled !== !1 && !!t, r = m(n.match);
6
- r.current = n.match, l(() => {
7
- if (!(!s || !u || !t))
8
- return s.emit("ops:join", { topic: t }), () => s.emit("ops:leave", { topic: t });
9
- }, [s, u, t]), S(
4
+ import { useResync as w } from "./reconnect-resync.js";
5
+ function j(t, u, n = {}) {
6
+ const c = b(), r = n.enabled !== !1 && !!t, s = m(n.match);
7
+ s.current = n.match;
8
+ const o = m(u);
9
+ o.current = u, l(() => {
10
+ if (!(!c || !r || !t))
11
+ return c.emit("ops:join", { topic: t }), () => c.emit("ops:leave", { topic: t });
12
+ }, [c, r, t]), S(
10
13
  "ops:changed",
11
14
  (e) => {
12
- c(e ?? {});
15
+ u(e ?? {});
13
16
  },
14
17
  {
15
- enabled: u,
18
+ enabled: r,
16
19
  debounceMs: n.debounceMs ?? 300,
17
20
  includeOwn: !0,
18
- match: (e) => (e == null ? void 0 : e.topic) === t && (!r.current || r.current(e ?? {}))
21
+ match: (e) => (e == null ? void 0 : e.topic) === t && (!s.current || s.current(e ?? {}))
19
22
  }
20
- );
23
+ ), w(() => o.current({ topic: t, reconnect: !0 }), { enabled: r });
21
24
  }
22
- function R(t, c = 4e3) {
23
- const n = m(null), [s, u] = h(() => /* @__PURE__ */ new Set()), r = (t ?? []).map(String).join("\0");
25
+ function y(t, u = 4e3) {
26
+ const n = m(null), [c, r] = h(() => /* @__PURE__ */ new Set()), s = (t ?? []).map(String).join("\0");
24
27
  return l(() => {
25
- const e = new Set(r ? r.split("\0") : []), i = n.current;
26
- if (n.current = e, !i || i.size === 0) return;
27
- const f = [...e].filter((o) => !i.has(o));
28
- f.length !== 0 && (u((o) => /* @__PURE__ */ new Set([...o, ...f])), setTimeout(
29
- () => u((o) => {
30
- const a = new Set(o);
31
- for (const d of f) a.delete(d);
28
+ const o = new Set(s ? s.split("\0") : []), e = n.current;
29
+ if (n.current = o, !e || e.size === 0) return;
30
+ const i = [...o].filter((f) => !e.has(f));
31
+ i.length !== 0 && (r((f) => /* @__PURE__ */ new Set([...f, ...i])), setTimeout(
32
+ () => r((f) => {
33
+ const a = new Set(f);
34
+ for (const d of i) a.delete(d);
32
35
  return a;
33
36
  }),
34
- c
37
+ u
35
38
  ));
36
- }, [r, c]), s;
39
+ }, [s, u]), c;
37
40
  }
38
41
  export {
39
- R as useFreshIds,
40
- O as useLiveOps
42
+ y as useFreshIds,
43
+ j as useLiveOps
41
44
  };
@@ -1,6 +1,6 @@
1
1
  import { liveQueryMeta as r } from "./live-queries.js";
2
2
  function i(e) {
3
- return e ? r({ reads: [e], staleOnly: !0 }) : void 0;
3
+ return e ? r({ reads: [e], staleOnly: !0, aspects: ["$picker"] }) : void 0;
4
4
  }
5
5
  export {
6
6
  i as pickerOptionsMeta