@nivaro/react 0.3.127 → 0.3.129

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/components/slots/CommentsSlot.js +124 -95
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useSessionRecorder.js +1 -1
  4. package/dist/index.d.ts +29 -3
  5. package/dist/index.js +150 -147
  6. package/dist/shared/components/CollectionBrowserView.js +3259 -3211
  7. package/dist/shared/components/DataTable.js +406 -401
  8. package/dist/shared/components/ItemEditForm.js +4485 -4409
  9. package/dist/shared/components/MatrixEditor.js +548 -490
  10. package/dist/shared/components/MyWorkView.js +284 -274
  11. package/dist/shared/components/NotificationBell.js +264 -218
  12. package/dist/shared/components/RecordGridEditor.js +582 -472
  13. package/dist/shared/components/ai/AiMarkdown.js +215 -196
  14. package/dist/shared/components/chat/chat-core.js +331 -346
  15. package/dist/shared/components/chat/chat-typing.js +25 -0
  16. package/dist/shared/components/command-center/CommandCenterView.js +1 -1
  17. package/dist/shared/components/command-center/PeekPanel.js +8 -1
  18. package/dist/shared/components/command-center/api.js +17 -9
  19. package/dist/shared/components/command-center/panels/AttentionPanel.js +4 -1
  20. package/dist/shared/components/command-center/panels/PartnersPanel.js +2 -1
  21. package/dist/shared/components/item-edit/GroupSection.js +1 -1
  22. package/dist/shared/components/item-edit/HeaderTools.js +216 -210
  23. package/dist/shared/components/item-edit/InlineTableField.js +432 -429
  24. package/dist/shared/components/item-edit/RecordLiveSync.js +115 -108
  25. package/dist/shared/components/item-edit/RecordViewersChip.js +17 -16
  26. package/dist/shared/components/item-edit/RowComments.js +33 -30
  27. package/dist/shared/components/item-edit/cascade-clear-notice.js +30 -28
  28. package/dist/shared/components/item-edit/live-related.js +29 -16
  29. package/dist/shared/components/item-edit/record-opened-live.js +86 -0
  30. package/dist/shared/components/panels/CommentPanel.js +345 -327
  31. package/dist/shared/components/panels/OwnerOpenedLine.js +24 -23
  32. package/dist/shared/components/panels/RecordIntegrityBanner.js +1 -1
  33. package/dist/shared/components/pipeline/TeamSuggestions.js +1 -1
  34. package/dist/shared/components/queue/QueueItemSheet.js +171 -130
  35. package/dist/shared/components/record-grid-guard.js +85 -0
  36. package/dist/shared/components/support/TicketDetailSheet.js +213 -174
  37. package/dist/shared/components/trackers/MirroredText.js +40 -0
  38. package/dist/shared/components/trackers/SourceTracker.js +168 -0
  39. package/dist/shared/components/trackers/TrackerChip.js +71 -0
  40. package/dist/shared/components/trackers/TrackerLinkPanel.js +1039 -0
  41. package/dist/shared/components/trackers/TrackerPickers.js +245 -0
  42. package/dist/shared/components/trackers/tracker-model.js +126 -0
  43. package/dist/shared/components/trackers/use-tracker-link.js +159 -0
  44. package/dist/shared/lib/at-risk-fields.js +14 -0
  45. package/dist/shared/lib/live-queries.js +9 -8
  46. package/dist/shared/lib/live-screen.js +77 -76
  47. package/dist/shared/lib/presence-hooks.js +190 -127
  48. package/dist/shared/lib/user-sync.js +78 -65
  49. package/dist/shared/lib/waiting-count.js +40 -29
  50. package/package.json +1 -1
@@ -1,45 +1,48 @@
1
1
  import { jsxs as o, Fragment as C, jsx as t } from "react/jsx-runtime";
2
- import { useQuery as M, useQueryClient as Q, useMutation as q } from "@tanstack/react-query";
3
- import { MessageSquare as S, SmilePlus as _ } from "lucide-react";
4
- import { useRef as D, useState as h } from "react";
2
+ import { useQuery as M, useQueryClient as D, useMutation as q } from "@tanstack/react-query";
3
+ import { MessageSquare as Q, SmilePlus as S } from "lucide-react";
4
+ import { useRef as _, useState as h } from "react";
5
5
  import { createPortal as E } from "react-dom";
6
6
  import { toast as j } from "sonner";
7
7
  import { useNivaroClient as R } from "../../context.js";
8
8
  import { get as K, post as F } from "../../lib/commands.js";
9
9
  import { formatRelative as L } from "../../lib/utils.js";
10
10
  const T = ["👍", "✅", "👀", "🎉", "❤️", "😂"];
11
- function V(s, a, d) {
12
- const m = R(), { data: l } = M({
11
+ function V(s, a, m) {
12
+ const c = R(), { data: i } = M({
13
13
  queryKey: ["row-comment-counts", s, a.join(",")],
14
- queryFn: () => m.request(
14
+ queryFn: () => c.request(
15
15
  K("/comments/counts", { collection: s, ids: a.join(",") })
16
- ).then((u) => u.data ?? {}).catch(() => ({})),
17
- enabled: d && a.length > 0,
18
- staleTime: 3e4
16
+ ).then((d) => d.data ?? {}).catch(() => ({})),
17
+ enabled: m && a.length > 0,
18
+ staleTime: 3e4,
19
+ // Low (seamless) 3: the key is the joined row ids, so adding or removing a line re-keys it;
20
+ // the badges keep the last counts (a row's count is still its count) until the new answer.
21
+ placeholderData: (d) => d
19
22
  });
20
- return l ?? {};
23
+ return i ?? {};
21
24
  }
22
25
  function X({
23
26
  collection: s,
24
27
  rowId: a,
25
- count: d
28
+ count: m
26
29
  }) {
27
- const m = R(), l = Q(), u = D(null), [c, p] = h(null), [x, f] = h(""), [y, g] = h(null), v = !!c, { data: N = [], isLoading: P } = M({
30
+ const c = R(), i = D(), d = _(null), [u, p] = h(null), [x, f] = h(""), [y, g] = h(null), v = !!u, { data: N = [], isLoading: P } = M({
28
31
  queryKey: ["comments", s, a],
29
- queryFn: () => m.request(K("/comments", { collection: s, item: a })).then(
30
- (e) => (e.data ?? []).filter((n) => !n.deleted).sort((n, i) => new Date(i.created_at).getTime() - new Date(n.created_at).getTime())
32
+ queryFn: () => c.request(K("/comments", { collection: s, item: a })).then(
33
+ (e) => (e.data ?? []).filter((n) => !n.deleted).sort((n, l) => new Date(l.created_at).getTime() - new Date(n.created_at).getTime())
31
34
  ),
32
35
  enabled: v
33
36
  }), k = q({
34
- mutationFn: (e) => m.request(F("/comments", { collection: s, item: a, text: e })),
37
+ mutationFn: (e) => c.request(F("/comments", { collection: s, item: a, text: e })),
35
38
  onSuccess: () => {
36
- f(""), l.invalidateQueries({ queryKey: ["comments", s, a] }), l.invalidateQueries({ queryKey: ["row-comment-counts", s] }), l.invalidateQueries({ queryKey: ["comments-related"] });
39
+ f(""), i.invalidateQueries({ queryKey: ["comments", s, a] }), i.invalidateQueries({ queryKey: ["row-comment-counts", s] }), i.invalidateQueries({ queryKey: ["comments-related"] });
37
40
  },
38
41
  onError: () => j.error("Failed to post comment")
39
42
  }), w = q({
40
- mutationFn: ({ id: e, emoji: n }) => m.request(F(`/comments/${e}/reactions`, { emoji: n })),
43
+ mutationFn: ({ id: e, emoji: n }) => c.request(F(`/comments/${e}/reactions`, { emoji: n })),
41
44
  onSuccess: () => {
42
- g(null), l.invalidateQueries({ queryKey: ["comments", s, a] });
45
+ g(null), i.invalidateQueries({ queryKey: ["comments", s, a] });
43
46
  },
44
47
  onError: () => j.error("Failed to react")
45
48
  });
@@ -47,36 +50,36 @@ function X({
47
50
  /* @__PURE__ */ o(
48
51
  "button",
49
52
  {
50
- ref: u,
53
+ ref: d,
51
54
  type: "button",
52
55
  onClick: (e) => {
53
56
  var r;
54
- if (e.stopPropagation(), c) {
57
+ if (e.stopPropagation(), u) {
55
58
  p(null);
56
59
  return;
57
60
  }
58
- const n = (r = u.current) == null ? void 0 : r.getBoundingClientRect();
61
+ const n = (r = d.current) == null ? void 0 : r.getBoundingClientRect();
59
62
  if (!n) return;
60
- const i = 280, b = n.bottom + i > window.innerHeight ? Math.max(8, n.top - i - 4) : n.bottom + 4;
63
+ const l = 280, b = n.bottom + l > window.innerHeight ? Math.max(8, n.top - l - 4) : n.bottom + 4;
61
64
  p({ top: b, left: Math.max(8, Math.min(n.left - 240, window.innerWidth - 320)) });
62
65
  },
63
66
  title: "Line comments",
64
- className: `relative rounded p-0.5 ${d > 0 ? "text-nvr-navy dark:text-nvr-cyan" : "text-slate-300 hover:text-nvr-cyan"}`,
67
+ className: `relative rounded p-0.5 ${m > 0 ? "text-nvr-navy dark:text-nvr-cyan" : "text-slate-300 hover:text-nvr-cyan"}`,
65
68
  "data-row-comments": a,
66
69
  children: [
67
- /* @__PURE__ */ t(S, { className: "h-3 w-3" }),
68
- d > 0 && /* @__PURE__ */ t("span", { className: "absolute -right-1.5 -top-1.5 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-nvr-cyan px-0.5 text-[8.5px] font-bold text-white", children: d })
70
+ /* @__PURE__ */ t(Q, { className: "h-3 w-3" }),
71
+ m > 0 && /* @__PURE__ */ t("span", { className: "absolute -right-1.5 -top-1.5 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-nvr-cyan px-0.5 text-[8.5px] font-bold text-white", children: m })
69
72
  ]
70
73
  }
71
74
  ),
72
- v && c && E(
75
+ v && u && E(
73
76
  /* @__PURE__ */ o(C, { children: [
74
77
  /* @__PURE__ */ t("div", { className: "fixed inset-0 z-[100]", onClick: () => p(null) }),
75
78
  /* @__PURE__ */ o(
76
79
  "div",
77
80
  {
78
81
  className: "fixed z-[110] w-[300px] rounded-lg border border-slate-200 bg-white shadow-xl dark:border-border dark:bg-popover",
79
- style: { top: c.top, left: c.left },
82
+ style: { top: u.top, left: u.left },
80
83
  onClick: (e) => e.stopPropagation(),
81
84
  onKeyDown: (e) => {
82
85
  e.key === "Escape" && p(null);
@@ -85,10 +88,10 @@ function X({
85
88
  "aria-label": "Line comments",
86
89
  children: [
87
90
  /* @__PURE__ */ t("div", { className: "max-h-[190px] overflow-y-auto px-3 py-2", children: P ? /* @__PURE__ */ t("p", { className: "py-3 text-center text-[11px] text-slate-400", children: "Loading…" }) : N.length === 0 ? /* @__PURE__ */ t("p", { className: "py-3 text-center text-[11px] text-slate-400", children: "No comments on this line yet." }) : /* @__PURE__ */ t("div", { className: "space-y-2", children: N.map((e) => {
88
- var n, i, b;
91
+ var n, l, b;
89
92
  return /* @__PURE__ */ o("div", { children: [
90
93
  /* @__PURE__ */ o("p", { className: "text-[11px]", children: [
91
- /* @__PURE__ */ t("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: [(n = e.user) == null ? void 0 : n.first_name, (i = e.user) == null ? void 0 : i.last_name].filter(Boolean).join(" ") || ((b = e.user) == null ? void 0 : b.email) || "Unknown" }),
94
+ /* @__PURE__ */ t("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: [(n = e.user) == null ? void 0 : n.first_name, (l = e.user) == null ? void 0 : l.last_name].filter(Boolean).join(" ") || ((b = e.user) == null ? void 0 : b.email) || "Unknown" }),
92
95
  " ",
93
96
  /* @__PURE__ */ t("span", { className: "text-slate-400", children: L(e.created_at) })
94
97
  ] }),
@@ -115,7 +118,7 @@ function X({
115
118
  onClick: () => g(y === e.id ? null : e.id),
116
119
  className: "rounded p-0.5 text-slate-300 hover:bg-slate-100 hover:text-slate-500 dark:hover:bg-muted",
117
120
  "aria-label": "Add reaction",
118
- children: /* @__PURE__ */ t(_, { className: "h-3 w-3" })
121
+ children: /* @__PURE__ */ t(S, { className: "h-3 w-3" })
119
122
  }
120
123
  ),
121
124
  y === e.id && /* @__PURE__ */ t("span", { className: "absolute bottom-5 left-0 z-20 flex gap-0.5 rounded-full border border-slate-200 bg-white px-1 py-0.5 shadow-lg dark:border-border dark:bg-popover", children: T.map((r) => /* @__PURE__ */ t(
@@ -1,36 +1,36 @@
1
1
  import { useRef as s, useEffect as f, useCallback as d, createContext as h, useContext as C } from "react";
2
- import { toast as m } from "sonner";
3
- const p = h(null), $ = () => C(p);
4
- function k(e) {
2
+ import { toast as k } from "sonner";
3
+ const m = h(null), $ = () => C(m);
4
+ function p(e) {
5
5
  const t = [...new Set(e.filter(Boolean))];
6
6
  return t.length <= 1 ? t[0] ?? "" : `${t.slice(0, -1).join(", ")} and ${t[t.length - 1]}`;
7
7
  }
8
- function g(e, t) {
9
- const r = k(e);
10
- return t ? `${r} cleared — not available for the ${t} you picked` : `${r} cleared — no longer available for what you picked`;
11
- }
12
8
  function S(e, t) {
13
- const r = new Set(e.map((n) => n.field)), c = [...new Set(e.flatMap((n) => n.parents))].filter((n) => !r.has(n));
14
- return c.length === 0 ? null : c.reduce((n, o) => t(o) > t(n) ? o : n, c[0]);
9
+ const n = p(e);
10
+ return t ? `${n} cleared — not available for the ${t} you picked` : `${n} cleared — no longer available for what you picked`;
11
+ }
12
+ function g(e, t) {
13
+ const n = new Set(e.map((r) => r.field)), c = [...new Set(e.flatMap((r) => r.parents))].filter((r) => !n.has(r));
14
+ return c.length === 0 ? null : c.reduce((r, o) => t(o) > t(r) ? o : r, c[0]);
15
15
  }
16
- const T = 4e3, w = 500, P = "nvr-cascade-clear";
17
- function M(e) {
16
+ const w = 4e3, T = 500, P = "nvr-cascade-clear";
17
+ function v(e) {
18
18
  const t = s(e);
19
19
  t.current = e;
20
- const r = s([]), c = s(0), n = s(null);
20
+ const n = s([]), c = s(0), r = s(null);
21
21
  return f(
22
22
  () => () => {
23
- n.current && clearTimeout(n.current);
23
+ r.current && clearTimeout(r.current);
24
24
  },
25
25
  []
26
26
  ), d((o) => {
27
27
  const i = Date.now();
28
- i - c.current > T && (r.current = []), c.current = i, r.current.some((a) => a.field === o.field) || r.current.push(o), n.current && clearTimeout(n.current), n.current = setTimeout(() => {
29
- const a = r.current;
28
+ i - c.current > w && (n.current = []), c.current = i, n.current.some((a) => a.field === o.field) || n.current.push(o), r.current && clearTimeout(r.current), r.current = setTimeout(() => {
29
+ const a = n.current;
30
30
  if (a.length === 0) return;
31
- const u = S(a, t.current.editSeq);
32
- m.info(
33
- g(
31
+ const u = g(a, t.current.editSeq);
32
+ k.info(
33
+ S(
34
34
  a.map((l) => l.label),
35
35
  u ? t.current.labelOf(u) : null
36
36
  ),
@@ -39,14 +39,16 @@ function M(e) {
39
39
  description: "Pick them again from the narrowed lists."
40
40
  }
41
41
  );
42
- }, w);
42
+ }, T);
43
43
  }, []);
44
44
  }
45
- function v(e, t, r) {
46
- return r.crossFill > 0 || r.notPerson > 0 ? !1 : (e.touched.add(t), e.seq.set(t, e.next()), !0);
45
+ function M(e, t, n) {
46
+ return n.crossFill > 0 || n.notPerson > 0 ? !1 : (e.touched.add(t), e.seq.set(t, e.next()), !0);
47
47
  }
48
48
  function A(e, t) {
49
- t.leftWorkStaged || e.clear();
49
+ if (t.leftWorkStaged) return;
50
+ const n = new Set(t.typedDuringSave ?? []);
51
+ for (const c of [...e]) n.has(c) || e.delete(c);
50
52
  }
51
53
  function E(e) {
52
54
  return `Pick a ${e}`;
@@ -55,14 +57,14 @@ function N(e) {
55
57
  return typeof e == "string" && e.startsWith("Pick a ");
56
58
  }
57
59
  export {
58
- p as CascadeClearNoticeContext,
59
- g as cascadeClearText,
60
+ m as CascadeClearNoticeContext,
61
+ S as cascadeClearText,
60
62
  E as cascadePickMessage,
61
- S as cascadeRootParent,
63
+ g as cascadeRootParent,
62
64
  N as isCascadePickMessage,
63
- k as joinLabels,
64
- v as notePersonLinkEdit,
65
+ p as joinLabels,
66
+ M as notePersonLinkEdit,
65
67
  A as settleTouchedAfterSave,
66
- M as useCascadeClearNotices,
68
+ v as useCascadeClearNotices,
67
69
  $ as useCascadeClearNotifier
68
70
  };
@@ -1,23 +1,36 @@
1
- const o = (t, n) => t != null && String(t) === n;
2
- function f(t, n) {
3
- return (e) => {
4
- const r = e[0];
5
- return r === "o2m-rows" || r === "o2m-field-snapshots" || r === "m2m-items" ? o(e[3], n) : r === "rrv-related" || r === "record-links" || r === "record-graph" ? e[1] === t && o(e[2], n) : r === "o2m-compare";
1
+ const o = (n, t) => n != null && String(n) === t;
2
+ function a(n, t) {
3
+ return (r) => {
4
+ const e = r[0];
5
+ return e === "o2m-rows" || e === "o2m-field-snapshots" || e === "m2m-items" || e === "summary-m2a-items" ? o(r[3], t) : e === "rrv-related" || e === "record-links" || e === "record-graph" || e === "referenced-by" ? r[1] === n && o(r[2], t) : e === "o2m-compare";
6
6
  };
7
7
  }
8
- function i(t, n) {
9
- return (e) => {
10
- const r = e[0];
11
- return r === "m2m-items" ? o(e[3], n) : r === "file-usage" || r === "file-download-stats" ? e[1] === t && o(e[2], n) : r === "files-meta" || r === "file-meta" || r === "file-health";
8
+ function s(n, t) {
9
+ return (r) => (r[0] === "item-actions" || r[0] === "ext-item-actions") && r[1] === n && o(r[2], t);
10
+ }
11
+ function u(n, t) {
12
+ return (r) => r[0] === "resolve-paths" && r[1] === n && o(r[2], t);
13
+ }
14
+ const f = [
15
+ ["pipeline-instance", "nivaro_addendums"],
16
+ ["addendum-lines"]
17
+ ];
18
+ function c(n, t) {
19
+ return (r) => {
20
+ const e = r[0];
21
+ return e === "m2m-items" ? o(r[3], t) : e === "file-usage" || e === "file-download-stats" ? r[1] === n && o(r[2], t) : e === "files-meta" || e === "file-meta" || e === "file-health";
12
22
  };
13
23
  }
14
- const a = 3e3;
15
- function l(t = Math.random) {
16
- return Math.floor(t() * a);
24
+ const i = 3e3;
25
+ function d(n = Math.random) {
26
+ return Math.floor(n() * i);
17
27
  }
18
28
  export {
19
- a as WIDE_RELATED_SPREAD_MS,
20
- i as fileQueryOfRecord,
21
- f as relatedQueryOfRecord,
22
- l as wideSpreadDelay
29
+ f as ADDENDUM_DETAIL_KEYS,
30
+ i as WIDE_RELATED_SPREAD_MS,
31
+ s as actionQueryOfRecord,
32
+ c as fileQueryOfRecord,
33
+ a as relatedQueryOfRecord,
34
+ u as resolvedPathQueryOfRecord,
35
+ d as wideSpreadDelay
23
36
  };
@@ -0,0 +1,86 @@
1
+ import { useQueryClient as E } from "@tanstack/react-query";
2
+ import { useRef as d, useEffect as O } from "react";
3
+ import { useLiveEvent as a } from "../../lib/live.js";
4
+ import { useMyUserId as g } from "../../lib/presence-signals.js";
5
+ const h = 3e3;
6
+ function w(r, n) {
7
+ return (e) => (e == null ? void 0 : e.collection) == null || (e == null ? void 0 : e.item) == null ? !0 : e.collection === r && String(e.item) === n;
8
+ }
9
+ function y(r) {
10
+ const n = /* @__PURE__ */ new Set();
11
+ if (!Array.isArray(r == null ? void 0 : r.viewers)) return n;
12
+ for (const e of r.viewers) {
13
+ const t = (e == null ? void 0 : e.id) ?? (e == null ? void 0 : e.user_id);
14
+ t != null && n.add(String(t).toUpperCase());
15
+ }
16
+ return n;
17
+ }
18
+ function S(r, n, e) {
19
+ const t = y(n), o = e ? e.toUpperCase() : null;
20
+ let s = !1;
21
+ for (const u of t) !r.has(u) && u !== o && (s = !0);
22
+ r.clear();
23
+ for (const u of t) r.add(u);
24
+ return s;
25
+ }
26
+ function C(r) {
27
+ if (Array.isArray(r)) {
28
+ const n = /* @__PURE__ */ new Set();
29
+ for (const e of r) {
30
+ const t = (e == null ? void 0 : e.user_id) ?? (e == null ? void 0 : e.id);
31
+ t != null && n.add(String(t).toUpperCase());
32
+ }
33
+ return n;
34
+ }
35
+ return r && typeof r == "object" && r.status === "not_opened" ? /* @__PURE__ */ new Set() : null;
36
+ }
37
+ function _(r, n, e) {
38
+ if (!e) return !1;
39
+ const t = n ? n.toUpperCase() : null;
40
+ for (const o of y(r)) if (o !== t && !e.has(o)) return !0;
41
+ return !1;
42
+ }
43
+ function A(r, n, e, t = !0) {
44
+ const o = E(), s = g(), u = d(/* @__PURE__ */ new Set()), c = d(!1);
45
+ O(() => {
46
+ u.current = /* @__PURE__ */ new Set(), c.current = !1;
47
+ }, [r, n]);
48
+ const i = d(!1);
49
+ a(
50
+ "record:viewers",
51
+ (f) => {
52
+ var l;
53
+ if (!c.current) {
54
+ c.current = !0;
55
+ const m = (l = o.getQueriesData({ queryKey: [...e] })[0]) == null ? void 0 : l[1];
56
+ _(f, s, C(m)) && (i.current = !0), S(u.current, f, s);
57
+ return;
58
+ }
59
+ S(u.current, f, s) && (i.current = !0);
60
+ },
61
+ {
62
+ enabled: t && !!r && !!n,
63
+ includeOwn: !0,
64
+ match: w(r, n)
65
+ }
66
+ ), a(
67
+ "record:viewers",
68
+ () => {
69
+ i.current && (i.current = !1, o.invalidateQueries({ queryKey: [...e] }));
70
+ },
71
+ {
72
+ enabled: t && !!r && !!n,
73
+ includeOwn: !0,
74
+ debounceMs: h,
75
+ match: w(r, n)
76
+ }
77
+ );
78
+ }
79
+ export {
80
+ h as RECORD_OPENED_SETTLE_MS,
81
+ S as bringsNewViewer,
82
+ _ as firstNoticeJoins,
83
+ C as knownOpeners,
84
+ A as useRefreshOnRecordOpened,
85
+ w as viewersNoticeFor
86
+ };