@nivaro/react 0.3.8 → 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 (60) hide show
  1. package/dist/components/fields/FileField.js +20 -19
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/replayUploadQueue.js +107 -93
  4. package/dist/hooks/useNivaroForm.js +129 -126
  5. package/dist/hooks/useSessionRecorder.js +103 -101
  6. package/dist/index.d.ts +115 -2
  7. package/dist/index.js +466 -447
  8. package/dist/shared/components/CollectionBrowserView.js +1058 -1059
  9. package/dist/shared/components/ConformanceView.js +36 -35
  10. package/dist/shared/components/DataTable.js +230 -223
  11. package/dist/shared/components/ForceReloadBanner.js +58 -34
  12. package/dist/shared/components/ItemEditForm.js +3687 -3580
  13. package/dist/shared/components/JsonMapEditor.js +18 -17
  14. package/dist/shared/components/MatrixEditor.js +8 -7
  15. package/dist/shared/components/MyWorkView.js +32 -31
  16. package/dist/shared/components/PageRenderer.js +146 -145
  17. package/dist/shared/components/QueryTable.js +49 -49
  18. package/dist/shared/components/RecordGridEditor.js +76 -75
  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/ChatPanel.js +288 -287
  24. package/dist/shared/components/chat/SlashCommands.js +30 -29
  25. package/dist/shared/components/chat/chat-outbox.js +76 -75
  26. package/dist/shared/components/help-videos/recorder/useLeaveWarning.js +6 -5
  27. package/dist/shared/components/integrations/console/SignalCard.js +124 -123
  28. package/dist/shared/components/integrations/console/SnoozeMenu.js +24 -23
  29. package/dist/shared/components/item-edit/CloneDialog.js +85 -78
  30. package/dist/shared/components/item-edit/InlineTableField.js +301 -300
  31. package/dist/shared/components/item-edit/MembershipSetField.js +24 -23
  32. package/dist/shared/components/item-edit/QuickCreateButton.js +8 -7
  33. package/dist/shared/components/item-edit/RecordLiveSync.js +101 -100
  34. package/dist/shared/components/item-edit/staged-links.js +86 -0
  35. package/dist/shared/components/layout-editor/LayoutEditor.js +275 -274
  36. package/dist/shared/components/layout-editor/editors/cascade-rule-row.js +18 -17
  37. package/dist/shared/components/layout-editor/inspector/HelpTab.js +37 -36
  38. package/dist/shared/components/layout-editor/matrix/FieldStateMatrix.js +50 -49
  39. package/dist/shared/components/panels/CommentPanel.js +237 -236
  40. package/dist/shared/components/profile/AiMemoryCard.js +15 -14
  41. package/dist/shared/components/profile/PersonAdminTools.js +70 -67
  42. package/dist/shared/components/profile/usePersonPresence.js +42 -37
  43. package/dist/shared/components/queue/QueueItemSheet.js +36 -35
  44. package/dist/shared/components/queue/QueueWorklist.js +597 -598
  45. package/dist/shared/lib/client-version.js +63 -0
  46. package/dist/shared/lib/force-reload.js +36 -0
  47. package/dist/shared/lib/load-error.js +11 -10
  48. package/dist/shared/lib/presence-live.js +73 -0
  49. package/dist/shared/lib/presence-state.js +39 -31
  50. package/dist/shared/lib/record-outbox.js +76 -75
  51. package/dist/shared/lib/request-gate.js +120 -102
  52. package/dist/shared/lib/rum.js +45 -36
  53. package/dist/shared/lib/safe-error.js +39 -0
  54. package/dist/shared/lib/server-clock.js +11 -7
  55. package/dist/shared/lib/signed-out.js +114 -0
  56. package/dist/shared/lib/socket-realtime.js +19 -17
  57. package/dist/shared/lib/unsaved-work.js +62 -0
  58. package/dist/shared/lib/use-online-users.js +11 -10
  59. package/dist/shared/lib/worker-socket.js +89 -79
  60. package/package.json +1 -1
@@ -5,34 +5,35 @@ import { useMemo as K, useState as x } from "react";
5
5
  import { toast as q } from "sonner";
6
6
  import { useNivaroClient as pe } from "../../context.js";
7
7
  import { get as he, post as U } from "../../lib/commands.js";
8
+ import { userErrorMessage as fe } from "../../lib/safe-error.js";
8
9
  import { cn as G } from "../../lib/utils.js";
9
- import { Popover as fe, PopoverTrigger as be, PopoverContent as ke } from "../ui/popover.js";
10
- import { useAvailableBulkActions as xe, bulkActionEnabled as ge } from "./BulkActionButtons.js";
11
- function H(i, a, t, d) {
12
- return ((i == null ? void 0 : i[t]) ?? []).some((u) => u.source === "builtin" && u.key === d) && ge(a, t, d);
10
+ import { Popover as be, PopoverTrigger as ke, PopoverContent as xe } from "../ui/popover.js";
11
+ import { useAvailableBulkActions as ge, bulkActionEnabled as ye } from "./BulkActionButtons.js";
12
+ function H(i, r, t, d) {
13
+ return ((i == null ? void 0 : i[t]) ?? []).some((u) => u.source === "builtin" && u.key === d) && ye(r, t, d);
13
14
  }
14
- function ye(i) {
15
- const a = { succeeded: 0, failed: 0, skipped: 0, errors: [], outcomes: [] };
15
+ function ve(i) {
16
+ const r = { succeeded: 0, failed: 0, skipped: 0, errors: [], outcomes: [] };
16
17
  for (const { collection: t, data: d } of i) {
17
- a.succeeded += d.succeeded ?? 0, a.failed += d.failed ?? 0, a.skipped += d.skipped ?? 0, a.errors.push(...d.errors ?? []);
18
+ r.succeeded += d.succeeded ?? 0, r.failed += d.failed ?? 0, r.skipped += d.skipped ?? 0, r.errors.push(...d.errors ?? []);
18
19
  for (const u of d.outcomes ?? [])
19
- a.outcomes.push({ ...u, item: `${t}:${u.item}` });
20
+ r.outcomes.push({ ...u, item: `${t}:${u.item}` });
20
21
  }
21
- return a;
22
+ return r;
22
23
  }
23
- function ve(i, a) {
24
- const t = [`${a.succeeded} done`];
25
- return a.skipped && t.push(`${a.skipped} skipped`), a.failed && t.push(`${a.failed} failed`), `${i}: ${t.join(" · ")}`;
24
+ function we(i, r) {
25
+ const t = [`${r.succeeded} done`];
26
+ return r.skipped && t.push(`${r.skipped} skipped`), r.failed && t.push(`${r.failed} failed`), `${i}: ${t.join(" · ")}`;
26
27
  }
27
- function Ee({
28
+ function Qe({
28
29
  targets: i,
29
- enabledKeys: a,
30
+ enabledKeys: r,
30
31
  tone: t = "light",
31
32
  disabled: d,
32
33
  onDone: u
33
34
  }) {
34
- const v = pe(), J = oe(), w = K(() => [...new Set(i.map((e) => e.collection))], [i]), { data: j } = xe(w), N = w.filter((e) => H(j, a, e, "push")), O = w.filter(
35
- (e) => H(j, a, e, "retry-push")
35
+ const v = pe(), J = oe(), w = K(() => [...new Set(i.map((e) => e.collection))], [i]), { data: j } = ge(w), N = w.filter((e) => H(j, r, e, "push")), O = w.filter(
36
+ (e) => H(j, r, e, "retry-push")
36
37
  ), P = le({
37
38
  queries: N.map((e) => ({
38
39
  queryKey: ["bulk-push-actions", e],
@@ -41,19 +42,19 @@ function Ee({
41
42
  }))
42
43
  }), V = P.map((e) => e.dataUpdatedAt).join(","), W = K(() => {
43
44
  const e = /* @__PURE__ */ new Map();
44
- return N.forEach((s, r) => {
45
+ return N.forEach((s, a) => {
45
46
  var o;
46
- for (const n of ((o = P[r]) == null ? void 0 : o.data) ?? []) {
47
+ for (const n of ((o = P[a]) == null ? void 0 : o.data) ?? []) {
47
48
  const m = e.get(n.id);
48
49
  m ? m.collections.push(s) : e.set(n.id, { ...n, collections: [s] });
49
50
  }
50
51
  }), [...e.values()];
51
- }, [V, N.join(",")]), [X, S] = x(null), [g, A] = x(""), [_, E] = x(null), [Y, $] = x({}), [Z, M] = x({}), D = (e) => {
52
- const [s, ...r] = e.split(":"), o = r.join(":"), n = i.find((m) => m.collection === s && String(m.id) === o);
52
+ }, [V, N.join(",")]), [X, S] = x(null), [g, A] = x(""), [M, _] = x(null), [Y, $] = x({}), [Z, E] = x({}), D = (e) => {
53
+ const [s, ...a] = e.split(":"), o = a.join(":"), n = i.find((m) => m.collection === s && String(m.id) === o);
53
54
  return n != null && n.label ? String(n.label) : `#${o}`;
54
55
  }, Q = async (e, s) => {
55
- const r = e.kind === "push" ? e.action.collections : e.collections, o = [];
56
- for (const n of r) {
56
+ const a = e.kind === "push" ? e.action.collections : e.collections, o = [];
57
+ for (const n of a) {
57
58
  const m = i.filter((p) => p.collection === n).map((p) => p.id);
58
59
  if (m.length === 0) continue;
59
60
  const k = e.kind === "push" ? await v.request(
@@ -69,24 +70,24 @@ function Ee({
69
70
  );
70
71
  o.push({ collection: n, data: k.data });
71
72
  }
72
- return ye(o);
73
+ return ve(o);
73
74
  }, C = (e) => e.kind === "push" ? `push:${e.action.id}` : "retry-push", R = (e) => e.kind === "push" ? e.action.label : "Retry failed pushes", ee = async (e) => {
74
75
  const s = C(e);
75
- $((r) => ({ ...r, [s]: "loading" }));
76
+ $((a) => ({ ...a, [s]: "loading" }));
76
77
  try {
77
- const r = await Q(e, !0);
78
- $((o) => ({ ...o, [s]: r }));
78
+ const a = await Q(e, !0);
79
+ $((o) => ({ ...o, [s]: a }));
79
80
  } catch {
80
- $((r) => ({ ...r, [s]: null }));
81
+ $((a) => ({ ...a, [s]: null }));
81
82
  }
82
83
  }, te = async (e) => {
83
84
  const s = C(e);
84
- E(s);
85
+ _(s);
85
86
  try {
86
- const r = await Q(e, !1);
87
- M((n) => ({ ...n, [s]: r }));
88
- const o = ve(R(e), r);
89
- r.failed > 0 ? q.warning(o, { duration: 8e3 }) : q.success(o, { duration: 4e3 });
87
+ const a = await Q(e, !1);
88
+ E((n) => ({ ...n, [s]: a }));
89
+ const o = we(R(e), a);
90
+ a.failed > 0 ? q.warning(o, { duration: 8e3 }) : q.success(o, { duration: 4e3 });
90
91
  for (const n of [
91
92
  "erp-submissions",
92
93
  "row-push-state",
@@ -96,11 +97,11 @@ function Ee({
96
97
  "item-actions"
97
98
  ])
98
99
  J.invalidateQueries({ queryKey: [n] });
99
- } catch (r) {
100
- const o = r.response;
101
- q.error((o == null ? void 0 : o.error) ?? (r instanceof Error ? r.message : `${R(e)} failed`));
100
+ } catch (a) {
101
+ const o = a.response;
102
+ q.error((o == null ? void 0 : o.error) ?? fe(a, `${R(e)} failed`));
102
103
  } finally {
103
- E(null);
104
+ _(null);
104
105
  }
105
106
  }, B = [
106
107
  ...W.map((e) => ({ kind: "push", action: e })),
@@ -116,32 +117,32 @@ function Ee({
116
117
  );
117
118
  return /* @__PURE__ */ l(ie, { children: B.map((e) => {
118
119
  var F, L, z, T;
119
- const s = C(e), r = R(e), o = e.kind === "push" ? e.action.collections : e.collections, n = i.filter((b) => o.includes(b.collection)).length, m = X === s, k = _ === s, p = e.kind === "push" ? (F = e.action.confirm) == null ? void 0 : F.input : void 0, h = Y[s], f = Z[s] ?? null, y = h && h !== "loading" ? h.succeeded : null, ne = n > 0 && !k && y !== 0 && (!(p != null && p.required) || g.trim().length > 0), re = e.kind === "push" ? ((L = e.action.confirm) == null ? void 0 : L.body) ?? `Runs "${e.action.label}" on each selected record, one at a time. Every record is a real request to the partner.` : "Re-sends the latest failed push of each selected record, partner by partner — the same stored request the record’s own Retry button sends.";
120
+ const s = C(e), a = R(e), o = e.kind === "push" ? e.action.collections : e.collections, n = i.filter((b) => o.includes(b.collection)).length, m = X === s, k = M === s, p = e.kind === "push" ? (F = e.action.confirm) == null ? void 0 : F.input : void 0, h = Y[s], f = Z[s] ?? null, y = h && h !== "loading" ? h.succeeded : null, ne = n > 0 && !k && y !== 0 && (!(p != null && p.required) || g.trim().length > 0), re = e.kind === "push" ? ((L = e.action.confirm) == null ? void 0 : L.body) ?? `Runs "${e.action.label}" on each selected record, one at a time. Every record is a real request to the partner.` : "Re-sends the latest failed push of each selected record, partner by partner — the same stored request the record’s own Retry button sends.";
120
121
  return /* @__PURE__ */ c(
121
- fe,
122
+ be,
122
123
  {
123
124
  open: m,
124
125
  onOpenChange: (b) => {
125
- S(b ? s : null), b ? (A(""), M((ae) => ({ ...ae, [s]: null })), ee(e)) : f && (u == null || u(f));
126
+ S(b ? s : null), b ? (A(""), E((ae) => ({ ...ae, [s]: null })), ee(e)) : f && (u == null || u(f));
126
127
  },
127
128
  children: [
128
- /* @__PURE__ */ l(be, { asChild: !0, children: /* @__PURE__ */ c(
129
+ /* @__PURE__ */ l(ke, { asChild: !0, children: /* @__PURE__ */ c(
129
130
  "button",
130
131
  {
131
132
  type: "button",
132
- disabled: d || !!_,
133
+ disabled: d || !!M,
133
134
  "data-bulk-push-action": e.kind === "push" ? e.action.id : void 0,
134
135
  "data-bulk-retry-push": e.kind === "retry" ? "" : void 0,
135
136
  title: e.kind === "push" ? `Run ${e.action.label} on the selected records` : "Re-send each selected record’s latest failed push",
136
137
  className: se(m),
137
138
  children: [
138
139
  k ? /* @__PURE__ */ l(I, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ l(ce, { className: "h-3.5 w-3.5" }),
139
- r
140
+ a
140
141
  ]
141
142
  }
142
143
  ) }),
143
144
  /* @__PURE__ */ c(
144
- ke,
145
+ xe,
145
146
  {
146
147
  align: "center",
147
148
  side: "top",
@@ -150,7 +151,7 @@ function Ee({
150
151
  "data-bulk-push-popover": s,
151
152
  children: [
152
153
  /* @__PURE__ */ c("p", { className: "text-[13px] font-semibold text-slate-800 dark:text-slate-100", children: [
153
- r,
154
+ a,
154
155
  /* @__PURE__ */ c("span", { className: "ml-1.5 font-normal text-slate-500 dark:text-slate-400", children: [
155
156
  "· ",
156
157
  n,
@@ -172,7 +173,7 @@ function Ee({
172
173
  e.kind === "push" ? "run" : "be retried",
173
174
  h.skipped + h.failed > 0 && /* @__PURE__ */ c("span", { className: "font-normal text-slate-500 dark:text-slate-400", children: [
174
175
  " · ",
175
- we(h)
176
+ Ne(h)
176
177
  ] })
177
178
  ]
178
179
  }
@@ -193,7 +194,7 @@ function Ee({
193
194
  }
194
195
  )
195
196
  ] }),
196
- f && /* @__PURE__ */ l(Ne, { result: f, labelFor: D }),
197
+ f && /* @__PURE__ */ l($e, { result: f, labelFor: D }),
197
198
  /* @__PURE__ */ c("div", { className: "mt-3 flex items-center justify-end gap-2", children: [
198
199
  /* @__PURE__ */ l(
199
200
  "button",
@@ -214,7 +215,7 @@ function Ee({
214
215
  disabled: !ne,
215
216
  "data-bulk-push-run": !0,
216
217
  className: "h-8 rounded-md bg-nvr-cyan px-3 text-[12.5px] font-semibold text-[#172940] hover:bg-nvr-cyan-dark disabled:opacity-40",
217
- children: k ? /* @__PURE__ */ l(I, { className: "h-3.5 w-3.5 animate-spin" }) : y != null && y !== n ? `${e.kind === "push" ? ((z = e.action.confirm) == null ? void 0 : z.confirm_label) ?? r : "Retry"} · ${y} of ${n}` : `${e.kind === "push" ? ((T = e.action.confirm) == null ? void 0 : T.confirm_label) ?? r : "Retry"} ${n}`
218
+ children: k ? /* @__PURE__ */ l(I, { className: "h-3.5 w-3.5 animate-spin" }) : y != null && y !== n ? `${e.kind === "push" ? ((z = e.action.confirm) == null ? void 0 : z.confirm_label) ?? a : "Retry"} · ${y} of ${n}` : `${e.kind === "push" ? ((T = e.action.confirm) == null ? void 0 : T.confirm_label) ?? a : "Retry"} ${n}`
218
219
  }
219
220
  )
220
221
  ] })
@@ -227,18 +228,18 @@ function Ee({
227
228
  );
228
229
  }) });
229
230
  }
230
- function we(i) {
231
- const a = /* @__PURE__ */ new Map();
231
+ function Ne(i) {
232
+ const r = /* @__PURE__ */ new Map();
232
233
  for (const t of i.outcomes) {
233
234
  if (t.outcome === "change") continue;
234
235
  const d = t.reason ?? t.outcome;
235
- a.set(d, (a.get(d) ?? 0) + 1);
236
+ r.set(d, (r.get(d) ?? 0) + 1);
236
237
  }
237
- return [...a.entries()].map(([t, d]) => `${d} ${t}`).join(" · ");
238
+ return [...r.entries()].map(([t, d]) => `${d} ${t}`).join(" · ");
238
239
  }
239
- function Ne({
240
+ function $e({
240
241
  result: i,
241
- labelFor: a
242
+ labelFor: r
242
243
  }) {
243
244
  return /* @__PURE__ */ c("div", { className: "mt-2", "data-bulk-push-results": !0, children: [
244
245
  /* @__PURE__ */ c("p", { className: "text-[11.5px] font-medium text-slate-700 dark:text-slate-200", children: [
@@ -260,7 +261,7 @@ function Ne({
260
261
  children: [
261
262
  t.outcome === "change" ? /* @__PURE__ */ l(de, { className: "mt-px h-3.5 w-3.5 shrink-0 text-emerald-600 dark:text-emerald-400" }) : t.outcome === "fail" ? /* @__PURE__ */ l(ue, { className: "mt-px h-3.5 w-3.5 shrink-0 text-red-600 dark:text-red-400" }) : /* @__PURE__ */ l(me, { className: "mt-px h-3.5 w-3.5 shrink-0 text-slate-400" }),
262
263
  /* @__PURE__ */ c("span", { className: "min-w-0", children: [
263
- /* @__PURE__ */ l("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: a(t.item) }),
264
+ /* @__PURE__ */ l("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: r(t.item) }),
264
265
  t.reason && /* @__PURE__ */ c("span", { className: "break-words text-slate-500 dark:text-slate-400", children: [
265
266
  " ",
266
267
  "— ",
@@ -274,7 +275,7 @@ function Ne({
274
275
  ] });
275
276
  }
276
277
  export {
277
- Ee as PushBulkButtons,
278
- Ne as PushResultList,
278
+ Qe as PushBulkButtons,
279
+ $e as PushResultList,
279
280
  H as builtinListed
280
281
  };