@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
@@ -1,21 +1,22 @@
1
1
  import { jsxs as n, jsx as t, Fragment as v } from "react/jsx-runtime";
2
2
  import { useQueryClient as w, useQuery as C, useMutation as E } from "@tanstack/react-query";
3
- import { Check as q, X as S, Pencil as I, Trash2 as F, Plus as K, Brain as _, History as D } from "lucide-react";
4
- import { useEffect as H, useState as u } from "react";
5
- import { useNivaroClient as M } from "../../context.js";
3
+ import { Check as q, X as S, Pencil as I, Trash2 as F, Plus as K, Brain as M, History as _ } from "lucide-react";
4
+ import { useEffect as D, useState as u } from "react";
5
+ import { useNivaroClient as H } from "../../context.js";
6
6
  import { get as Q, patch as P } from "../../lib/commands.js";
7
- import { AiHistorySwitch as X } from "../ai/AiHistorySwitch.js";
7
+ import { userErrorMessage as X } from "../../lib/safe-error.js";
8
+ import { AiHistorySwitch as j } from "../ai/AiHistorySwitch.js";
8
9
  import { SectionCard as N } from "./primitives.js";
9
10
  const g = 20, k = 300;
10
- function Z() {
11
- const d = M(), A = w(), { data: i } = C({
11
+ function G() {
12
+ const d = H(), A = w(), { data: i } = C({
12
13
  queryKey: ["nvr-profile-prefs"],
13
14
  queryFn: () => d.request(Q("/users/me")).then((e) => {
14
15
  var r;
15
16
  return ((r = e.data) == null ? void 0 : r.preferences) ?? {};
16
17
  })
17
18
  }), h = i !== void 0;
18
- H(() => {
19
+ D(() => {
19
20
  var e;
20
21
  !h || typeof window > "u" || window.location.hash !== "#ai-memory" || (e = document.querySelector('[data-profile-card="ai-memory"]')) == null || e.scrollIntoView({ block: "start", behavior: "smooth" });
21
22
  }, [h]);
@@ -27,7 +28,7 @@ function Z() {
27
28
  onError: (e) => {
28
29
  var r, a;
29
30
  return y(
30
- ((a = (r = e == null ? void 0 : e.response) == null ? void 0 : r.data) == null ? void 0 : a.error) ?? (e instanceof Error ? e.message : "Could not save")
31
+ ((a = (r = e == null ? void 0 : e.response) == null ? void 0 : r.data) == null ? void 0 : a.error) ?? X(e, "Could not save")
31
32
  );
32
33
  }
33
34
  }), b = () => {
@@ -41,7 +42,7 @@ function Z() {
41
42
  return /* @__PURE__ */ n(
42
43
  N,
43
44
  {
44
- icon: /* @__PURE__ */ t(_, { className: "h-4 w-4" }),
45
+ icon: /* @__PURE__ */ t(M, { className: "h-4 w-4" }),
45
46
  title: "Ask AI memory",
46
47
  hint: "Notes every Ask AI answer takes into account. Only you see them.",
47
48
  testId: "ai-memory",
@@ -147,17 +148,17 @@ function Z() {
147
148
  }
148
149
  );
149
150
  }
150
- function z() {
151
+ function J() {
151
152
  const d = w();
152
153
  return /* @__PURE__ */ t(
153
154
  N,
154
155
  {
155
- icon: /* @__PURE__ */ t(D, { className: "h-4 w-4" }),
156
+ icon: /* @__PURE__ */ t(_, { className: "h-4 w-4" }),
156
157
  title: "Ask AI history",
157
158
  hint: "Whether Ask AI keeps your conversations.",
158
159
  testId: "ai-history",
159
160
  children: /* @__PURE__ */ t(
160
- X,
161
+ j,
161
162
  {
162
163
  onDeleted: () => void d.invalidateQueries({ queryKey: ["ask-conversations"] })
163
164
  }
@@ -166,6 +167,6 @@ function z() {
166
167
  );
167
168
  }
168
169
  export {
169
- z as AiHistoryCard,
170
- Z as AiMemoryCard
170
+ J as AiHistoryCard,
171
+ G as AiMemoryCard
171
172
  };
@@ -1,28 +1,31 @@
1
1
  import { jsxs as o, jsx as e, Fragment as E } from "react/jsx-runtime";
2
- import { useMutation as f, useQuery as M } from "@tanstack/react-query";
2
+ import { useMutation as v, useQuery as M } from "@tanstack/react-query";
3
3
  import { RefreshCw as P, GitMerge as U, UserMinus as B } from "lucide-react";
4
4
  import { useState as m } from "react";
5
- import { toast as g } from "sonner";
6
- import { useNivaroClient as y } from "../../context.js";
7
- import { post as v, get as $ } from "../../lib/commands.js";
5
+ import { toast as x } from "sonner";
6
+ import { useNivaroClient as k } from "../../context.js";
7
+ import { post as w, get as $ } from "../../lib/commands.js";
8
8
  import { cn as I } from "../../lib/utils.js";
9
9
  import { SectionCard as C, EmptyLine as S } from "./primitives.js";
10
- import { errorText as w, useInvalidatePerson as j } from "./types.js";
10
+ import { errorText as y, useInvalidatePerson as j } from "./types.js";
11
11
  function te({ profile: d }) {
12
- const u = y(), [p, t] = m("15"), [h, i] = m(""), l = f({
12
+ const u = k(), [h, t] = m("15"), [p, i] = m(""), l = v({
13
13
  mutationFn: () => u.request(
14
- v("/realtime/force-refresh", {
14
+ w("/realtime/force-refresh", {
15
15
  user_ids: [d.id],
16
- seconds: Number(p) || 15,
17
- message: h
16
+ seconds: Number(h) || 15,
17
+ message: p
18
18
  })
19
- ).then((n) => n.data),
19
+ ).then((a) => a.data),
20
20
  // The reload rides the person's room on every server; only the tab count can fall short.
21
21
  // A server without `nodes` counts only the tabs on the server that took this request.
22
- onSuccess: ({ sockets: n, nodes: s, partial: c }) => g.success(
23
- n > 0 ? `Reload pushed to ${n} open tab${n === 1 ? "" : "s"}${c ? " (another server did not answer — there may be more)" : ""}` : c ? "Reload sent — another server did not answer, so their open tabs could not be counted" : s != null ? "Reload sent — they have no tab open right now" : "Reload sent to every tab they have open (tabs on other servers are not counted)"
24
- ),
25
- onError: (n) => g.error(w(n, "Failed to push the reload"))
22
+ onSuccess: ({ sockets: a, nodes: s, partial: c, remembered: b, remember_hours: r }) => {
23
+ const f = b ? ` Tabs that connect in the next ${r ?? 24} h reload too.` : "";
24
+ x.success(
25
+ (a > 0 ? `Reload pushed to ${a} open tab${a === 1 ? "" : "s"}${c ? " (another server did not answer — there may be more)" : ""}.` : c ? "Reload sent — another server did not answer, so their open tabs could not be counted." : s != null ? "Reload sent — they have no tab open right now." : "Reload sent to every tab they have open (tabs on other servers are not counted).") + f
26
+ );
27
+ },
28
+ onError: (a) => x.error(y(a, "Failed to push the reload"))
26
29
  });
27
30
  return /* @__PURE__ */ o(
28
31
  C,
@@ -39,8 +42,8 @@ function te({ profile: d }) {
39
42
  /* @__PURE__ */ e(
40
43
  "input",
41
44
  {
42
- value: p,
43
- onChange: (n) => t(n.target.value),
45
+ value: h,
46
+ onChange: (a) => t(a.target.value),
44
47
  inputMode: "numeric",
45
48
  className: "h-7 w-14 rounded-md border border-slate-200 bg-white px-2 text-right text-[12px] dark:border-border dark:bg-background"
46
49
  }
@@ -50,8 +53,8 @@ function te({ profile: d }) {
50
53
  /* @__PURE__ */ e(
51
54
  "input",
52
55
  {
53
- value: h,
54
- onChange: (n) => i(n.target.value),
56
+ value: p,
57
+ onChange: (a) => i(a.target.value),
55
58
  placeholder: "Optional message in their banner",
56
59
  className: "h-7 min-w-[200px] flex-1 rounded-md border border-slate-200 bg-white px-2.5 text-[12px] dark:border-border dark:bg-background"
57
60
  }
@@ -78,12 +81,12 @@ function te({ profile: d }) {
78
81
  function D({
79
82
  excludeId: d,
80
83
  value: u,
81
- label: p,
84
+ label: h,
82
85
  onPick: t
83
86
  }) {
84
- const h = y(), [i, l] = m(""), { data: n = [] } = M({
87
+ const p = k(), [i, l] = m(""), { data: a = [] } = M({
85
88
  queryKey: ["nvr-offboard-user-search", i],
86
- queryFn: () => h.request($("/users", { search: i, limit: 8 })).then((s) => s.data),
89
+ queryFn: () => p.request($("/users", { search: i, limit: 8 })).then((s) => s.data),
87
90
  enabled: i.length > 1
88
91
  });
89
92
  return u ? /* @__PURE__ */ o("span", { className: "inline-flex items-center gap-1.5 rounded-full bg-nvr-cyan/10 px-2.5 py-1 text-[12px] font-medium text-nvr-navy dark:text-nvr-cyan", children: [
@@ -104,11 +107,11 @@ function D({
104
107
  {
105
108
  value: i,
106
109
  onChange: (s) => l(s.target.value),
107
- placeholder: p,
110
+ placeholder: h,
108
111
  className: "h-8 w-[260px] rounded-md border border-slate-200 bg-white px-2.5 text-[12.5px] dark:border-border dark:bg-background"
109
112
  }
110
113
  ),
111
- i.length > 1 && n.length > 0 && /* @__PURE__ */ e("div", { className: "absolute z-10 mt-1 w-[260px] rounded-md border border-slate-200 bg-white shadow-lg dark:border-border dark:bg-card", children: n.filter((s) => s.id.toUpperCase() !== d.toUpperCase()).map((s) => {
114
+ i.length > 1 && a.length > 0 && /* @__PURE__ */ e("div", { className: "absolute z-10 mt-1 w-[260px] rounded-md border border-slate-200 bg-white shadow-lg dark:border-border dark:bg-card", children: a.filter((s) => s.id.toUpperCase() !== d.toUpperCase()).map((s) => {
112
115
  const c = `${s.first_name ?? ""} ${s.last_name ?? ""}`.trim() || s.email;
113
116
  return /* @__PURE__ */ o(
114
117
  "button",
@@ -148,18 +151,18 @@ const q = {
148
151
  field_watches: "notification_subscriptions"
149
152
  };
150
153
  function re({ profile: d }) {
151
- const u = y(), p = j(d.id), [t, h] = m(null), [i, l] = m({}), [n, s] = m(!0), [c, x] = m(null), { data: a, refetch: k } = M({
154
+ const u = k(), h = j(d.id), [t, p] = m(null), [i, l] = m({}), [a, s] = m(!0), [c, b] = m(null), { data: r, refetch: f } = M({
152
155
  queryKey: ["nvr-offboarding", d.id],
153
- queryFn: () => u.request($(`/offboarding/${d.id}`)).then((r) => r.data)
154
- }), N = f({
156
+ queryFn: () => u.request($(`/offboarding/${d.id}`)).then((n) => n.data)
157
+ }), N = v({
155
158
  mutationFn: () => u.request(
156
- v(`/offboarding/${d.id}/run`, { successor: t == null ? void 0 : t.id, include: i, suspend: n })
157
- ).then((r) => r.data),
158
- onSuccess: (r) => {
159
- x(r), g.success("Offboarding complete"), k(), p();
159
+ w(`/offboarding/${d.id}/run`, { successor: t == null ? void 0 : t.id, include: i, suspend: a })
160
+ ).then((n) => n.data),
161
+ onSuccess: (n) => {
162
+ b(n), x.success("Offboarding complete"), f(), h();
160
163
  },
161
- onError: (r) => g.error(w(r, "Offboarding failed"))
162
- }), L = Object.values((a == null ? void 0 : a.holdings) ?? {}).reduce((r, b) => r + b, 0), [O, A] = m("");
164
+ onError: (n) => x.error(y(n, "Offboarding failed"))
165
+ }), L = Object.values((r == null ? void 0 : r.holdings) ?? {}).reduce((n, g) => n + g, 0), [O, T] = m("");
163
166
  return /* @__PURE__ */ e(
164
167
  C,
165
168
  {
@@ -168,14 +171,14 @@ function re({ profile: d }) {
168
171
  hint: "Hand everything they hold to a successor in one pass",
169
172
  tone: "danger",
170
173
  testId: "offboarding",
171
- children: a ? /* @__PURE__ */ o("div", { className: "space-y-3", children: [
172
- /* @__PURE__ */ e("div", { className: "grid gap-x-6 gap-y-1 sm:grid-cols-2", children: Object.entries(a.holdings).map(([r, b]) => {
173
- const _ = H[r], F = I(
174
+ children: r ? /* @__PURE__ */ o("div", { className: "space-y-3", children: [
175
+ /* @__PURE__ */ e("div", { className: "grid gap-x-6 gap-y-1 sm:grid-cols-2", children: Object.entries(r.holdings).map(([n, g]) => {
176
+ const _ = H[n], F = I(
174
177
  "flex items-center gap-2 text-[12.5px]",
175
- b === 0 ? "text-slate-300 dark:text-slate-600" : "text-slate-700 dark:text-slate-200"
178
+ g === 0 ? "text-slate-300 dark:text-slate-600" : "text-slate-700 dark:text-slate-200"
176
179
  ), R = /* @__PURE__ */ o(E, { children: [
177
- /* @__PURE__ */ e("span", { className: "flex-1", children: q[r] ?? r }),
178
- /* @__PURE__ */ e("span", { className: "font-semibold tabular-nums", children: b })
180
+ /* @__PURE__ */ e("span", { className: "flex-1", children: q[n] ?? n }),
181
+ /* @__PURE__ */ e("span", { className: "font-semibold tabular-nums", children: g })
179
182
  ] });
180
183
  return _ ? /* @__PURE__ */ o("label", { className: F, children: [
181
184
  /* @__PURE__ */ e(
@@ -183,16 +186,16 @@ function re({ profile: d }) {
183
186
  {
184
187
  type: "checkbox",
185
188
  checked: i[_] !== !1,
186
- disabled: b === 0,
187
- onChange: (G) => l((T) => ({ ...T, [_]: G.target.checked })),
189
+ disabled: g === 0,
190
+ onChange: (A) => l((G) => ({ ...G, [_]: A.target.checked })),
188
191
  className: "h-3.5 w-3.5"
189
192
  }
190
193
  ),
191
194
  R
192
- ] }, r) : /* @__PURE__ */ o("div", { className: F, children: [
195
+ ] }, n) : /* @__PURE__ */ o("div", { className: F, children: [
193
196
  /* @__PURE__ */ e("span", { className: "w-3.5" }),
194
197
  R
195
- ] }, r);
198
+ ] }, n);
196
199
  }) }),
197
200
  L === 0 ? /* @__PURE__ */ e(S, { children: "Nothing to hand over — this account holds no work." }) : /* @__PURE__ */ o("div", { className: "flex flex-wrap items-center gap-2.5", children: [
198
201
  /* @__PURE__ */ e(
@@ -201,7 +204,7 @@ function re({ profile: d }) {
201
204
  excludeId: d.id,
202
205
  value: t,
203
206
  label: "Successor (who takes it over)…",
204
- onPick: h
207
+ onPick: p
205
208
  }
206
209
  ),
207
210
  /* @__PURE__ */ o("label", { className: "flex items-center gap-1.5 text-[12px] text-slate-600 dark:text-slate-300", children: [
@@ -209,8 +212,8 @@ function re({ profile: d }) {
209
212
  "input",
210
213
  {
211
214
  type: "checkbox",
212
- checked: n,
213
- onChange: (r) => s(r.target.checked),
215
+ checked: a,
216
+ onChange: (n) => s(n.target.checked),
214
217
  className: "h-3.5 w-3.5"
215
218
  }
216
219
  ),
@@ -221,7 +224,7 @@ function re({ profile: d }) {
221
224
  "input",
222
225
  {
223
226
  value: O,
224
- onChange: (r) => A(r.target.value),
227
+ onChange: (n) => T(n.target.value),
225
228
  placeholder: "Type OFFBOARD",
226
229
  "aria-label": "Type OFFBOARD to confirm",
227
230
  className: "h-8 w-[150px] rounded-md border border-amber-300 bg-white px-2.5 text-[12.5px] dark:border-amber-500/40 dark:bg-background"
@@ -241,25 +244,25 @@ function re({ profile: d }) {
241
244
  c && /* @__PURE__ */ o("p", { className: "rounded-md bg-emerald-50 px-3 py-2 text-[12px] text-emerald-700 dark:bg-emerald-500/10 dark:text-emerald-400", children: [
242
245
  "Done:",
243
246
  " ",
244
- Object.entries(c).map(([r, b]) => `${(q[r] ?? r).toLowerCase()} ${b}`).join(" · ")
247
+ Object.entries(c).map(([n, g]) => `${(q[n] ?? n).toLowerCase()} ${g}`).join(" · ")
245
248
  ] })
246
249
  ] }) : /* @__PURE__ */ e(S, { children: "Loading what they hold…" })
247
250
  }
248
251
  );
249
252
  }
250
253
  function ne({ profile: d }) {
251
- const u = y(), p = j(d.id), [t, h] = m(null), [i, l] = m(null), [n, s] = m(""), c = f({
254
+ const u = k(), h = j(d.id), [t, p] = m(null), [i, l] = m(null), [a, s] = m(""), c = v({
252
255
  mutationFn: () => u.request(
253
- v(`/offboarding/${d.id}/merge`, { into: t == null ? void 0 : t.id, dry_run: !0 })
254
- ).then((a) => a.data),
255
- onSuccess: (a) => l(a.references),
256
- onError: (a) => g.error(w(a, "Preview failed"))
257
- }), x = f({
258
- mutationFn: () => u.request(v(`/offboarding/${d.id}/merge`, { into: t == null ? void 0 : t.id })),
256
+ w(`/offboarding/${d.id}/merge`, { into: t == null ? void 0 : t.id, dry_run: !0 })
257
+ ).then((r) => r.data),
258
+ onSuccess: (r) => l(r.references),
259
+ onError: (r) => x.error(y(r, "Preview failed"))
260
+ }), b = v({
261
+ mutationFn: () => u.request(w(`/offboarding/${d.id}/merge`, { into: t == null ? void 0 : t.id })),
259
262
  onSuccess: () => {
260
- g.success("Accounts merged — the duplicate is suspended"), l(null), s(""), p();
263
+ x.success("Accounts merged — the duplicate is suspended"), l(null), s(""), h();
261
264
  },
262
- onError: (a) => g.error(w(a, "Merge failed"))
265
+ onError: (r) => x.error(y(r, "Merge failed"))
263
266
  });
264
267
  return /* @__PURE__ */ e(
265
268
  C,
@@ -277,8 +280,8 @@ function ne({ profile: d }) {
277
280
  excludeId: d.id,
278
281
  value: t,
279
282
  label: "Survivor account (keeps everything)…",
280
- onPick: (a) => {
281
- h(a), l(null);
283
+ onPick: (r) => {
284
+ p(r), l(null);
282
285
  }
283
286
  }
284
287
  ),
@@ -294,23 +297,23 @@ function ne({ profile: d }) {
294
297
  )
295
298
  ] }),
296
299
  i && /* @__PURE__ */ o(E, { children: [
297
- /* @__PURE__ */ e("div", { className: "max-h-[220px] overflow-y-auto rounded-md border border-slate-100 dark:border-border/60", children: Object.keys(i).length === 0 ? /* @__PURE__ */ e("p", { className: "px-3 py-2 text-[12px] text-slate-400", children: "Nothing references this account." }) : Object.entries(i).map(([a, k]) => /* @__PURE__ */ o(
300
+ /* @__PURE__ */ e("div", { className: "max-h-[220px] overflow-y-auto rounded-md border border-slate-100 dark:border-border/60", children: Object.keys(i).length === 0 ? /* @__PURE__ */ e("p", { className: "px-3 py-2 text-[12px] text-slate-400", children: "Nothing references this account." }) : Object.entries(i).map(([r, f]) => /* @__PURE__ */ o(
298
301
  "div",
299
302
  {
300
303
  className: "flex items-center justify-between border-b border-slate-50 px-3 py-1 text-[12px] last:border-0 dark:border-border/40",
301
304
  children: [
302
- /* @__PURE__ */ e("span", { className: "font-mono text-slate-600 dark:text-slate-300", children: a }),
303
- /* @__PURE__ */ e("span", { className: "font-semibold tabular-nums text-slate-700 dark:text-slate-200", children: k })
305
+ /* @__PURE__ */ e("span", { className: "font-mono text-slate-600 dark:text-slate-300", children: r }),
306
+ /* @__PURE__ */ e("span", { className: "font-semibold tabular-nums text-slate-700 dark:text-slate-200", children: f })
304
307
  ]
305
308
  },
306
- a
309
+ r
307
310
  )) }),
308
311
  /* @__PURE__ */ o("div", { className: "flex flex-wrap items-center gap-2", children: [
309
312
  /* @__PURE__ */ e(
310
313
  "input",
311
314
  {
312
- value: n,
313
- onChange: (a) => s(a.target.value),
315
+ value: a,
316
+ onChange: (r) => s(r.target.value),
314
317
  placeholder: "Type MERGE to confirm",
315
318
  "aria-label": "Type MERGE to confirm",
316
319
  className: "h-8 w-[180px] rounded-md border border-amber-300 bg-white px-2.5 text-[12.5px] dark:border-amber-500/40 dark:bg-background"
@@ -320,10 +323,10 @@ function ne({ profile: d }) {
320
323
  "button",
321
324
  {
322
325
  type: "button",
323
- disabled: n !== "MERGE" || x.isPending,
324
- onClick: () => x.mutate(),
326
+ disabled: a !== "MERGE" || b.isPending,
327
+ onClick: () => b.mutate(),
325
328
  className: "h-8 rounded-md bg-amber-500 px-4 text-[12.5px] font-semibold text-white hover:bg-amber-600 disabled:opacity-50",
326
- children: x.isPending ? "Merging…" : `Merge into ${(t == null ? void 0 : t.name) ?? ""}`
329
+ children: b.isPending ? "Merging…" : `Merge into ${(t == null ? void 0 : t.name) ?? ""}`
327
330
  }
328
331
  )
329
332
  ] })
@@ -1,57 +1,62 @@
1
- import { useQueryClient as f, useQuery as c } from "@tanstack/react-query";
2
- import { useNivaroClient as p } from "../../context.js";
3
- import { get as a } from "../../lib/commands.js";
4
- import { useLiveEvent as m } from "../../lib/live.js";
5
- import { prettyPagePath as g } from "../../lib/presence-state.js";
1
+ import { useQueryClient as y, useQuery as u } from "@tanstack/react-query";
2
+ import { useNivaroClient as a } from "../../context.js";
3
+ import { get as g } from "../../lib/commands.js";
4
+ import { useLiveEvent as h } from "../../lib/live.js";
5
+ import { usePresenceOnlinePoll as f } from "../../lib/presence-live.js";
6
+ import { presenceChangeTouches as P, prettyPagePath as m } from "../../lib/presence-state.js";
6
7
  import { PERSON_PROFILE_KEY as d } from "./types.js";
7
- function P(r) {
8
- var i, o;
9
- const s = p(), l = f();
10
- m(
8
+ function K(n) {
9
+ var t, o;
10
+ const l = a(), s = y();
11
+ h(
11
12
  "presence:changed",
12
13
  () => {
13
- l.invalidateQueries({ queryKey: [d, r] }), l.invalidateQueries({ queryKey: ["presence-online"] });
14
+ s.invalidateQueries(
15
+ { queryKey: [d, n] },
16
+ { cancelRefetch: !1 }
17
+ );
14
18
  },
15
19
  {
16
- enabled: !!r,
17
- debounceMs: 500,
20
+ enabled: !!n,
21
+ debounceMs: 1e3,
18
22
  includeOwn: !0,
19
- match: (t) => String((t == null ? void 0 : t.user_id) ?? "").toUpperCase() === String(r ?? "").toUpperCase()
23
+ // Coalesced server events list every changed id (`user_ids`); older ones carry `user_id`.
24
+ match: (i) => P(i, n)
20
25
  }
21
26
  );
22
- const { data: e } = c({
27
+ const c = f(15e3, !!n), { data: e } = u({
23
28
  queryKey: ["presence-online"],
24
- queryFn: () => s.request(
25
- a("/presence/online")
29
+ queryFn: () => l.request(
30
+ g("/presence/online")
26
31
  ),
27
- enabled: !!r,
28
- refetchInterval: 15e3,
32
+ enabled: !!n,
33
+ refetchInterval: c,
29
34
  staleTime: 5e3
30
- }), n = (i = e == null ? void 0 : e.data) == null ? void 0 : i.find(
31
- (t) => String(t.user_id).toUpperCase() === String(r ?? "").toUpperCase()
32
- ), u = (((o = e == null ? void 0 : e.config) == null ? void 0 : o.fields) ?? ["role", "page"]).includes("page");
33
- return { page: n && u ? n.page ?? g(n.current_path) : null };
35
+ }), r = (t = e == null ? void 0 : e.data) == null ? void 0 : t.find(
36
+ (i) => String(i.user_id).toUpperCase() === String(n ?? "").toUpperCase()
37
+ ), p = (((o = e == null ? void 0 : e.config) == null ? void 0 : o.fields) ?? ["role", "page"]).includes("page");
38
+ return { page: r && p ? r.page ?? m(r.current_path) : null };
34
39
  }
35
- function _(r, s) {
36
- var i, o;
37
- const l = p(), { data: e } = c({
40
+ function O(n, l) {
41
+ var t, o;
42
+ const s = a(), c = f(15e3, l && !!n), { data: e } = u({
38
43
  queryKey: ["presence-online"],
39
- queryFn: () => l.request(a("/presence/online")),
40
- enabled: s && !!r,
41
- refetchInterval: s ? 15e3 : !1,
44
+ queryFn: () => s.request(g("/presence/online")),
45
+ enabled: l && !!n,
46
+ refetchInterval: c,
42
47
  staleTime: 5e3
43
- }), n = (i = e == null ? void 0 : e.data) == null ? void 0 : i.find(
44
- (t) => String(t.user_id).toUpperCase() === String(r ?? "").toUpperCase()
48
+ }), r = (t = e == null ? void 0 : e.data) == null ? void 0 : t.find(
49
+ (i) => String(i.user_id).toUpperCase() === String(n ?? "").toUpperCase()
45
50
  );
46
- if (!n) return { word: null, page: null, minutes: null };
47
- const u = (((o = e == null ? void 0 : e.config) == null ? void 0 : o.fields) ?? ["role", "page"]).includes("page");
51
+ if (!r) return { word: null, page: null, minutes: null };
52
+ const p = (((o = e == null ? void 0 : e.config) == null ? void 0 : o.fields) ?? ["role", "page"]).includes("page");
48
53
  return {
49
- word: n.away ? "away" : n.is_idle ? "idle" : "online",
50
- page: u ? n.page ?? g(n.current_path) : null,
51
- minutes: n.idle_minutes ?? null
54
+ word: r.away ? "away" : r.is_idle ? "idle" : "online",
55
+ page: p ? r.page ?? m(r.current_path) : null,
56
+ minutes: r.idle_minutes ?? null
52
57
  };
53
58
  }
54
59
  export {
55
- _ as useCardPresence,
56
- P as usePersonPresence
60
+ O as useCardPresence,
61
+ K as usePersonPresence
57
62
  };