@nivaro/react 0.3.82 → 0.3.84

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.
@@ -1,17 +1,18 @@
1
- import { jsxs as a, jsx as e, Fragment as I } from "react/jsx-runtime";
2
- import { useMutation as y, useQuery as T } from "@tanstack/react-query";
3
- import { RefreshCw as F, LogOut as R, GitMerge as U, UserMinus as H } from "lucide-react";
4
- import { useState as m, useEffect as K } from "react";
1
+ import { jsxs as n, jsx as e, Fragment as T } from "react/jsx-runtime";
2
+ import { useMutation as y, useQuery as q } from "@tanstack/react-query";
3
+ import { RefreshCw as F, LogOut as M, GitMerge as U, UserMinus as H } from "lucide-react";
4
+ import { useState as u, useEffect as K } from "react";
5
5
  import { toast as x } from "sonner";
6
6
  import { useNivaroClient as C } from "../../context.js";
7
7
  import { post as N, get as j } from "../../lib/commands.js";
8
8
  import { cn as O } from "../../lib/utils.js";
9
- import { SectionCard as f, EmptyLine as M } from "./primitives.js";
10
- import { useReloadTheirTabs as Q, useSignOutEverywhere as z } from "./session-actions.js";
9
+ import { SectionCard as f, EmptyLine as R } from "./primitives.js";
10
+ import { SignOutMessageInput as Q } from "./SignOutMessageInput.js";
11
+ import { useReloadTheirTabs as z, useSignOutEverywhere as J } from "./session-actions.js";
11
12
  import { useInvalidatePerson as $, errorText as _ } from "./types.js";
12
- function oe({ profile: s }) {
13
- const [d, l] = m("15"), [t, u] = m(""), o = Q(s.id);
14
- return /* @__PURE__ */ a(
13
+ function de({ profile: i }) {
14
+ const [c, l] = u("15"), [t, p] = u(""), s = z(i.id);
15
+ return /* @__PURE__ */ n(
15
16
  f,
16
17
  {
17
18
  icon: /* @__PURE__ */ e(F, { className: "h-4 w-4" }),
@@ -20,14 +21,14 @@ function oe({ profile: s }) {
20
21
  tone: "danger",
21
22
  testId: "force-reload",
22
23
  children: [
23
- /* @__PURE__ */ a("div", { className: "flex flex-wrap items-center gap-2", "data-user-force-reload": !0, children: [
24
- /* @__PURE__ */ a("label", { className: "flex items-center gap-1.5 text-[12px] text-slate-600 dark:text-slate-300", children: [
24
+ /* @__PURE__ */ n("div", { className: "flex flex-wrap items-center gap-2", "data-user-force-reload": !0, children: [
25
+ /* @__PURE__ */ n("label", { className: "flex items-center gap-1.5 text-[12px] text-slate-600 dark:text-slate-300", children: [
25
26
  "Countdown",
26
27
  /* @__PURE__ */ e(
27
28
  "input",
28
29
  {
29
- value: d,
30
- onChange: (c) => l(c.target.value),
30
+ value: c,
31
+ onChange: (d) => l(d.target.value),
31
32
  inputMode: "numeric",
32
33
  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"
33
34
  }
@@ -38,21 +39,21 @@ function oe({ profile: s }) {
38
39
  "input",
39
40
  {
40
41
  value: t,
41
- onChange: (c) => u(c.target.value),
42
+ onChange: (d) => p(d.target.value),
42
43
  placeholder: "Optional message in their banner",
43
44
  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"
44
45
  }
45
46
  ),
46
- /* @__PURE__ */ a(
47
+ /* @__PURE__ */ n(
47
48
  "button",
48
49
  {
49
50
  type: "button",
50
- disabled: o.isPending,
51
- onClick: () => o.mutate({ seconds: Number(d) || 15, message: t }),
51
+ disabled: s.isPending,
52
+ onClick: () => s.mutate({ seconds: Number(c) || 15, message: t }),
52
53
  className: "inline-flex h-7 items-center gap-1.5 rounded-md border border-amber-300 px-2.5 text-[11.5px] font-medium text-amber-800 transition-colors hover:bg-amber-50 disabled:opacity-50 dark:border-amber-500/40 dark:text-amber-300 dark:hover:bg-amber-500/10",
53
54
  children: [
54
- /* @__PURE__ */ e(F, { className: O("h-3 w-3", o.isPending && "animate-spin") }),
55
- o.isPending ? "Sending…" : "Reload their tabs"
55
+ /* @__PURE__ */ e(F, { className: O("h-3 w-3", s.isPending && "animate-spin") }),
56
+ s.isPending ? "Sending…" : "Reload their tabs"
56
57
  ]
57
58
  }
58
59
  )
@@ -62,58 +63,74 @@ function oe({ profile: s }) {
62
63
  }
63
64
  );
64
65
  }
65
- function ie({ profile: s }) {
66
- const d = [s.first_name, s.last_name].filter(Boolean).join(" ") || s.email || "They", [l, t] = m(!1);
66
+ function le({ profile: i }) {
67
+ const c = [i.first_name, i.last_name].filter(Boolean).join(" ") || i.email || "They", [l, t] = u(!1), [p, s] = u("");
67
68
  K(() => {
68
- if (!l) return;
69
- const o = setTimeout(() => t(!1), 4e3);
70
- return () => clearTimeout(o);
71
- }, [l]);
72
- const u = z(s.id, d, { onDone: () => t(!1) });
73
- return /* @__PURE__ */ a(
69
+ if (!l || p.trim()) return;
70
+ const a = setTimeout(() => t(!1), 1e4);
71
+ return () => clearTimeout(a);
72
+ }, [l, p]);
73
+ const d = J(i.id, c, {
74
+ onDone: () => {
75
+ t(!1), s("");
76
+ }
77
+ }), h = () => d.mutate({ message: p });
78
+ return /* @__PURE__ */ n(
74
79
  f,
75
80
  {
76
- icon: /* @__PURE__ */ e(R, { className: "h-4 w-4" }),
81
+ icon: /* @__PURE__ */ e(M, { className: "h-4 w-4" }),
77
82
  title: "Sign out everywhere",
78
83
  hint: "Ends every session they have, on every app — each open tab goes back to sign-in",
79
84
  tone: "danger",
80
85
  testId: "sign-out-everywhere",
81
86
  children: [
82
- /* @__PURE__ */ e("div", { className: "flex flex-wrap items-center gap-2", "data-user-sign-out": !0, children: /* @__PURE__ */ a(
87
+ /* @__PURE__ */ e("div", { className: "flex flex-wrap items-center gap-2", "data-user-sign-out": !0, children: /* @__PURE__ */ n(
83
88
  "button",
84
89
  {
85
90
  type: "button",
86
- disabled: u.isPending,
87
- onClick: () => l ? u.mutate() : t(!0),
88
- onBlur: () => t(!1),
91
+ disabled: d.isPending,
92
+ onClick: () => l ? h() : t(!0),
93
+ onBlur: (a) => {
94
+ const m = a.relatedTarget;
95
+ m != null && m.closest("[data-sign-out-message]") || t(!1);
96
+ },
89
97
  className: O(
90
98
  "inline-flex h-7 items-center gap-1.5 rounded-md border px-2.5 text-[11.5px] font-medium transition-colors disabled:opacity-50",
91
99
  l ? "border-red-600 bg-red-600 text-white hover:bg-red-700" : "border-amber-300 text-amber-800 hover:bg-amber-50 dark:border-amber-500/40 dark:text-amber-300 dark:hover:bg-amber-500/10"
92
100
  ),
93
101
  children: [
94
- /* @__PURE__ */ e(R, { className: "h-3 w-3" }),
95
- u.isPending ? "Signing out…" : l ? "Confirm sign out" : "Sign them out"
102
+ /* @__PURE__ */ e(M, { className: "h-3 w-3" }),
103
+ d.isPending ? "Signing out…" : l ? "Confirm sign out" : "Sign them out"
96
104
  ]
97
105
  }
98
106
  ) }),
107
+ l && /* @__PURE__ */ e(
108
+ Q,
109
+ {
110
+ value: p,
111
+ onChange: s,
112
+ onSubmit: h,
113
+ className: "mt-2 max-w-md"
114
+ }
115
+ ),
99
116
  /* @__PURE__ */ e("p", { className: "mt-2 text-[11.5px] text-slate-500 dark:text-slate-400", children: "They can sign in again straight away — suspend the account to keep them out. API keys and static tokens keep working." })
100
117
  ]
101
118
  }
102
119
  );
103
120
  }
104
121
  function A({
105
- excludeId: s,
106
- value: d,
122
+ excludeId: i,
123
+ value: c,
107
124
  label: l,
108
125
  onPick: t
109
126
  }) {
110
- const u = C(), [o, c] = m(""), { data: h = [] } = T({
111
- queryKey: ["nvr-offboard-user-search", o],
112
- queryFn: () => u.request(j("/users", { search: o, limit: 8 })).then((i) => i.data),
113
- enabled: o.length > 1
127
+ const p = C(), [s, d] = u(""), { data: h = [] } = q({
128
+ queryKey: ["nvr-offboard-user-search", s],
129
+ queryFn: () => p.request(j("/users", { search: s, limit: 8 })).then((a) => a.data),
130
+ enabled: s.length > 1
114
131
  });
115
- return d ? /* @__PURE__ */ a("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: [
116
- d.name,
132
+ return c ? /* @__PURE__ */ n("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: [
133
+ c.name,
117
134
  /* @__PURE__ */ e(
118
135
  "button",
119
136
  {
@@ -124,37 +141,37 @@ function A({
124
141
  children: "✕"
125
142
  }
126
143
  )
127
- ] }) : /* @__PURE__ */ a("div", { className: "relative", children: [
144
+ ] }) : /* @__PURE__ */ n("div", { className: "relative", children: [
128
145
  /* @__PURE__ */ e(
129
146
  "input",
130
147
  {
131
- value: o,
132
- onChange: (i) => c(i.target.value),
148
+ value: s,
149
+ onChange: (a) => d(a.target.value),
133
150
  placeholder: l,
134
151
  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"
135
152
  }
136
153
  ),
137
- o.length > 1 && h.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: h.filter((i) => i.id.toUpperCase() !== s.toUpperCase()).map((i) => {
138
- const p = `${i.first_name ?? ""} ${i.last_name ?? ""}`.trim() || i.email;
139
- return /* @__PURE__ */ a(
154
+ s.length > 1 && h.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: h.filter((a) => a.id.toUpperCase() !== i.toUpperCase()).map((a) => {
155
+ const m = `${a.first_name ?? ""} ${a.last_name ?? ""}`.trim() || a.email;
156
+ return /* @__PURE__ */ n(
140
157
  "button",
141
158
  {
142
159
  type: "button",
143
160
  onClick: () => {
144
- t({ id: i.id, name: p }), c("");
161
+ t({ id: a.id, name: m }), d("");
145
162
  },
146
163
  className: "block w-full px-2.5 py-1.5 text-left text-[12.5px] text-slate-700 hover:bg-muted dark:text-foreground",
147
164
  children: [
148
- p,
149
- /* @__PURE__ */ e("span", { className: "ml-1.5 text-[11px] text-slate-400", children: i.email })
165
+ m,
166
+ /* @__PURE__ */ e("span", { className: "ml-1.5 text-[11px] text-slate-400", children: a.email })
150
167
  ]
151
168
  },
152
- i.id
169
+ a.id
153
170
  );
154
171
  }) })
155
172
  ] });
156
173
  }
157
- const q = {
174
+ const I = {
158
175
  queue_claims: "Queue claims",
159
176
  instance_ownerships: "Record ownerships (open pipelines)",
160
177
  open_tasks: "Open tasks",
@@ -163,7 +180,7 @@ const q = {
163
180
  direct_reports: "Direct reports",
164
181
  notification_subscriptions: "Notification subscriptions",
165
182
  field_watches: "Field watches"
166
- }, J = {
183
+ }, V = {
167
184
  queue_claims: "queue_claims",
168
185
  instance_ownerships: "instance_ownerships",
169
186
  open_tasks: "open_tasks",
@@ -173,19 +190,19 @@ const q = {
173
190
  notification_subscriptions: "notification_subscriptions",
174
191
  field_watches: "notification_subscriptions"
175
192
  };
176
- function de({ profile: s }) {
177
- const d = C(), l = $(s.id), [t, u] = m(null), [o, c] = m({}), [h, i] = m(!0), [p, g] = m(null), { data: n, refetch: k } = T({
178
- queryKey: ["nvr-offboarding", s.id],
179
- queryFn: () => d.request(j(`/offboarding/${s.id}`)).then((r) => r.data)
180
- }), v = y({
181
- mutationFn: () => d.request(
182
- N(`/offboarding/${s.id}/run`, { successor: t == null ? void 0 : t.id, include: o, suspend: h })
193
+ function ce({ profile: i }) {
194
+ const c = C(), l = $(i.id), [t, p] = u(null), [s, d] = u({}), [h, a] = u(!0), [m, g] = u(null), { data: o, refetch: v } = q({
195
+ queryKey: ["nvr-offboarding", i.id],
196
+ queryFn: () => c.request(j(`/offboarding/${i.id}`)).then((r) => r.data)
197
+ }), w = y({
198
+ mutationFn: () => c.request(
199
+ N(`/offboarding/${i.id}/run`, { successor: t == null ? void 0 : t.id, include: s, suspend: h })
183
200
  ).then((r) => r.data),
184
201
  onSuccess: (r) => {
185
- g(r), x.success("Offboarding complete"), k(), l();
202
+ g(r), x.success("Offboarding complete"), v(), l();
186
203
  },
187
204
  onError: (r) => x.error(_(r, "Offboarding failed"))
188
- }), D = Object.values((n == null ? void 0 : n.holdings) ?? {}).reduce((r, b) => r + b, 0), [S, L] = m("");
205
+ }), D = Object.values((o == null ? void 0 : o.holdings) ?? {}).reduce((r, b) => r + b, 0), [S, L] = u("");
189
206
  return /* @__PURE__ */ e(
190
207
  f,
191
208
  {
@@ -194,49 +211,49 @@ function de({ profile: s }) {
194
211
  hint: "Hand everything they hold to a successor in one pass",
195
212
  tone: "danger",
196
213
  testId: "offboarding",
197
- children: n ? /* @__PURE__ */ a("div", { className: "space-y-3", children: [
198
- /* @__PURE__ */ e("div", { className: "grid gap-x-6 gap-y-1 sm:grid-cols-2", children: Object.entries(n.holdings).map(([r, b]) => {
199
- const w = J[r], P = O(
214
+ children: o ? /* @__PURE__ */ n("div", { className: "space-y-3", children: [
215
+ /* @__PURE__ */ e("div", { className: "grid gap-x-6 gap-y-1 sm:grid-cols-2", children: Object.entries(o.holdings).map(([r, b]) => {
216
+ const k = V[r], P = O(
200
217
  "flex items-center gap-2 text-[12.5px]",
201
218
  b === 0 ? "text-slate-300 dark:text-slate-600" : "text-slate-700 dark:text-slate-200"
202
- ), E = /* @__PURE__ */ a(I, { children: [
203
- /* @__PURE__ */ e("span", { className: "flex-1", children: q[r] ?? r }),
219
+ ), E = /* @__PURE__ */ n(T, { children: [
220
+ /* @__PURE__ */ e("span", { className: "flex-1", children: I[r] ?? r }),
204
221
  /* @__PURE__ */ e("span", { className: "font-semibold tabular-nums", children: b })
205
222
  ] });
206
- return w ? /* @__PURE__ */ a("label", { className: P, children: [
223
+ return k ? /* @__PURE__ */ n("label", { className: P, children: [
207
224
  /* @__PURE__ */ e(
208
225
  "input",
209
226
  {
210
227
  type: "checkbox",
211
- checked: o[w] !== !1,
228
+ checked: s[k] !== !1,
212
229
  disabled: b === 0,
213
- onChange: (B) => c((G) => ({ ...G, [w]: B.target.checked })),
230
+ onChange: (B) => d((G) => ({ ...G, [k]: B.target.checked })),
214
231
  className: "h-3.5 w-3.5"
215
232
  }
216
233
  ),
217
234
  E
218
- ] }, r) : /* @__PURE__ */ a("div", { className: P, children: [
235
+ ] }, r) : /* @__PURE__ */ n("div", { className: P, children: [
219
236
  /* @__PURE__ */ e("span", { className: "w-3.5" }),
220
237
  E
221
238
  ] }, r);
222
239
  }) }),
223
- D === 0 ? /* @__PURE__ */ e(M, { children: "Nothing to hand over — this account holds no work." }) : /* @__PURE__ */ a("div", { className: "flex flex-wrap items-center gap-2.5", children: [
240
+ D === 0 ? /* @__PURE__ */ e(R, { children: "Nothing to hand over — this account holds no work." }) : /* @__PURE__ */ n("div", { className: "flex flex-wrap items-center gap-2.5", children: [
224
241
  /* @__PURE__ */ e(
225
242
  A,
226
243
  {
227
- excludeId: s.id,
244
+ excludeId: i.id,
228
245
  value: t,
229
246
  label: "Successor (who takes it over)…",
230
- onPick: u
247
+ onPick: p
231
248
  }
232
249
  ),
233
- /* @__PURE__ */ a("label", { className: "flex items-center gap-1.5 text-[12px] text-slate-600 dark:text-slate-300", children: [
250
+ /* @__PURE__ */ n("label", { className: "flex items-center gap-1.5 text-[12px] text-slate-600 dark:text-slate-300", children: [
234
251
  /* @__PURE__ */ e(
235
252
  "input",
236
253
  {
237
254
  type: "checkbox",
238
255
  checked: h,
239
- onChange: (r) => i(r.target.checked),
256
+ onChange: (r) => a(r.target.checked),
240
257
  className: "h-3.5 w-3.5"
241
258
  }
242
259
  ),
@@ -257,35 +274,35 @@ function de({ profile: s }) {
257
274
  "button",
258
275
  {
259
276
  type: "button",
260
- disabled: !t || S !== "OFFBOARD" || v.isPending,
261
- onClick: () => v.mutate(),
277
+ disabled: !t || S !== "OFFBOARD" || w.isPending,
278
+ onClick: () => w.mutate(),
262
279
  className: "h-8 rounded-md bg-amber-500 px-4 text-[12.5px] font-semibold text-white hover:bg-amber-600 disabled:opacity-50",
263
- children: v.isPending ? "Reassigning…" : "Run offboarding"
280
+ children: w.isPending ? "Reassigning…" : "Run offboarding"
264
281
  }
265
282
  )
266
283
  ] }),
267
- p && /* @__PURE__ */ a("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: [
284
+ m && /* @__PURE__ */ n("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: [
268
285
  "Done:",
269
286
  " ",
270
- Object.entries(p).map(([r, b]) => `${(q[r] ?? r).toLowerCase()} ${b}`).join(" · ")
287
+ Object.entries(m).map(([r, b]) => `${(I[r] ?? r).toLowerCase()} ${b}`).join(" · ")
271
288
  ] })
272
- ] }) : /* @__PURE__ */ e(M, { children: "Loading what they hold…" })
289
+ ] }) : /* @__PURE__ */ e(R, { children: "Loading what they hold…" })
273
290
  }
274
291
  );
275
292
  }
276
- function le({ profile: s }) {
277
- const d = C(), l = $(s.id), [t, u] = m(null), [o, c] = m(null), [h, i] = m(""), p = y({
278
- mutationFn: () => d.request(
279
- N(`/offboarding/${s.id}/merge`, { into: t == null ? void 0 : t.id, dry_run: !0 })
280
- ).then((n) => n.data),
281
- onSuccess: (n) => c(n.references),
282
- onError: (n) => x.error(_(n, "Preview failed"))
293
+ function me({ profile: i }) {
294
+ const c = C(), l = $(i.id), [t, p] = u(null), [s, d] = u(null), [h, a] = u(""), m = y({
295
+ mutationFn: () => c.request(
296
+ N(`/offboarding/${i.id}/merge`, { into: t == null ? void 0 : t.id, dry_run: !0 })
297
+ ).then((o) => o.data),
298
+ onSuccess: (o) => d(o.references),
299
+ onError: (o) => x.error(_(o, "Preview failed"))
283
300
  }), g = y({
284
- mutationFn: () => d.request(N(`/offboarding/${s.id}/merge`, { into: t == null ? void 0 : t.id })),
301
+ mutationFn: () => c.request(N(`/offboarding/${i.id}/merge`, { into: t == null ? void 0 : t.id })),
285
302
  onSuccess: () => {
286
- x.success("Accounts merged — the duplicate is suspended"), c(null), i(""), l();
303
+ x.success("Accounts merged — the duplicate is suspended"), d(null), a(""), l();
287
304
  },
288
- onError: (n) => x.error(_(n, "Merge failed"))
305
+ onError: (o) => x.error(_(o, "Merge failed"))
289
306
  });
290
307
  return /* @__PURE__ */ e(
291
308
  f,
@@ -295,16 +312,16 @@ function le({ profile: s }) {
295
312
  hint: "For duplicate or legacy twins: every reference moves to the survivor, then this account is suspended",
296
313
  tone: "danger",
297
314
  testId: "merge",
298
- children: /* @__PURE__ */ a("div", { className: "space-y-3", children: [
299
- /* @__PURE__ */ a("div", { className: "flex flex-wrap items-center gap-2.5", children: [
315
+ children: /* @__PURE__ */ n("div", { className: "space-y-3", children: [
316
+ /* @__PURE__ */ n("div", { className: "flex flex-wrap items-center gap-2.5", children: [
300
317
  /* @__PURE__ */ e(
301
318
  A,
302
319
  {
303
- excludeId: s.id,
320
+ excludeId: i.id,
304
321
  value: t,
305
322
  label: "Survivor account (keeps everything)…",
306
- onPick: (n) => {
307
- u(n), c(null);
323
+ onPick: (o) => {
324
+ p(o), d(null);
308
325
  }
309
326
  }
310
327
  ),
@@ -312,31 +329,31 @@ function le({ profile: s }) {
312
329
  "button",
313
330
  {
314
331
  type: "button",
315
- disabled: !t || p.isPending,
316
- onClick: () => p.mutate(),
332
+ disabled: !t || m.isPending,
333
+ onClick: () => m.mutate(),
317
334
  className: "h-8 rounded-md border border-slate-200 px-3 text-[12.5px] font-medium text-slate-600 hover:bg-slate-50 disabled:opacity-50 dark:border-border dark:text-slate-300 dark:hover:bg-muted",
318
- children: p.isPending ? "Scanning…" : "Preview references"
335
+ children: m.isPending ? "Scanning…" : "Preview references"
319
336
  }
320
337
  )
321
338
  ] }),
322
- o && /* @__PURE__ */ a(I, { children: [
323
- /* @__PURE__ */ e("div", { className: "max-h-[220px] overflow-y-auto rounded-md border border-slate-100 dark:border-border/60", children: Object.keys(o).length === 0 ? /* @__PURE__ */ e("p", { className: "px-3 py-2 text-[12px] text-slate-400", children: "Nothing references this account." }) : Object.entries(o).map(([n, k]) => /* @__PURE__ */ a(
339
+ s && /* @__PURE__ */ n(T, { children: [
340
+ /* @__PURE__ */ e("div", { className: "max-h-[220px] overflow-y-auto rounded-md border border-slate-100 dark:border-border/60", children: Object.keys(s).length === 0 ? /* @__PURE__ */ e("p", { className: "px-3 py-2 text-[12px] text-slate-400", children: "Nothing references this account." }) : Object.entries(s).map(([o, v]) => /* @__PURE__ */ n(
324
341
  "div",
325
342
  {
326
343
  className: "flex items-center justify-between border-b border-slate-50 px-3 py-1 text-[12px] last:border-0 dark:border-border/40",
327
344
  children: [
328
- /* @__PURE__ */ e("span", { className: "font-mono text-slate-600 dark:text-slate-300", children: n }),
329
- /* @__PURE__ */ e("span", { className: "font-semibold tabular-nums text-slate-700 dark:text-slate-200", children: k })
345
+ /* @__PURE__ */ e("span", { className: "font-mono text-slate-600 dark:text-slate-300", children: o }),
346
+ /* @__PURE__ */ e("span", { className: "font-semibold tabular-nums text-slate-700 dark:text-slate-200", children: v })
330
347
  ]
331
348
  },
332
- n
349
+ o
333
350
  )) }),
334
- /* @__PURE__ */ a("div", { className: "flex flex-wrap items-center gap-2", children: [
351
+ /* @__PURE__ */ n("div", { className: "flex flex-wrap items-center gap-2", children: [
335
352
  /* @__PURE__ */ e(
336
353
  "input",
337
354
  {
338
355
  value: h,
339
- onChange: (n) => i(n.target.value),
356
+ onChange: (o) => a(o.target.value),
340
357
  placeholder: "Type MERGE to confirm",
341
358
  "aria-label": "Type MERGE to confirm",
342
359
  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"
@@ -359,9 +376,9 @@ function le({ profile: s }) {
359
376
  );
360
377
  }
361
378
  export {
362
- oe as ForceReloadCard,
363
- le as MergeCard,
364
- de as OffboardingCard,
365
- ie as SignOutEverywhereCard,
379
+ de as ForceReloadCard,
380
+ me as MergeCard,
381
+ ce as OffboardingCard,
382
+ le as SignOutEverywhereCard,
366
383
  A as UserPicker
367
384
  };
@@ -0,0 +1,37 @@
1
+ import { jsxs as a, jsx as d } from "react/jsx-runtime";
2
+ import { cn as i } from "../../lib/utils.js";
3
+ const o = 280;
4
+ function g({
5
+ value: t,
6
+ onChange: s,
7
+ onSubmit: n,
8
+ className: l
9
+ }) {
10
+ const r = o - t.length;
11
+ return /* @__PURE__ */ a("div", { className: i("space-y-1", l), "data-sign-out-message": !0, children: [
12
+ /* @__PURE__ */ d(
13
+ "input",
14
+ {
15
+ autoFocus: !0,
16
+ type: "text",
17
+ value: t,
18
+ maxLength: o,
19
+ onChange: (e) => s(e.target.value),
20
+ onKeyDown: (e) => {
21
+ e.key === "Enter" && (e.preventDefault(), n());
22
+ },
23
+ "aria-label": "Message for them (optional)",
24
+ placeholder: "Message for them (optional) — shown on their sign-in page",
25
+ className: "h-8 w-full rounded-md border border-slate-300 bg-white px-2.5 text-[12px] text-slate-900 placeholder:text-slate-400 focus:border-red-500 focus:outline-none focus:ring-2 focus:ring-red-500/20 dark:border-border dark:bg-background dark:text-slate-100 dark:placeholder:text-slate-500"
26
+ }
27
+ ),
28
+ r <= 40 && /* @__PURE__ */ a("p", { className: "text-right text-[10.5px] tabular-nums text-slate-500 dark:text-slate-400", children: [
29
+ r,
30
+ " left"
31
+ ] })
32
+ ] });
33
+ }
34
+ export {
35
+ o as SIGN_OUT_MESSAGE_MAX,
36
+ g as SignOutMessageInput
37
+ };
@@ -1,52 +1,58 @@
1
1
  import { useMutation as i } from "@tanstack/react-query";
2
- import { toast as s } from "sonner";
2
+ import { toast as a } from "sonner";
3
3
  import { useOptionalNivaroClient as u } from "../../context.js";
4
4
  import { post as c } from "../../lib/commands.js";
5
- import { errorText as d } from "./types.js";
5
+ import { errorText as m } from "./types.js";
6
6
  function h(e) {
7
- const t = e.remembered ? ` Tabs that connect in the next ${e.remember_hours ?? 24} h reload too.` : "", o = typeof e.tabs == "number" && e.sockets > 0 ? Math.max(1, e.tabs) : e.sockets;
8
- return (o > 0 ? `Reload pushed to ${o} open tab${o === 1 ? "" : "s"}${e.partial ? " (another server did not answer — there may be more)" : ""}.` : e.partial ? "Reload sent — another server did not answer, so their open tabs could not be counted." : e.nodes != 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).") + t;
7
+ const o = e.remembered ? ` Tabs that connect in the next ${e.remember_hours ?? 24} h reload too.` : "", n = typeof e.tabs == "number" && e.sockets > 0 ? Math.max(1, e.tabs) : e.sockets;
8
+ return (n > 0 ? `Reload pushed to ${n} open tab${n === 1 ? "" : "s"}${e.partial ? " (another server did not answer — there may be more)" : ""}.` : e.partial ? "Reload sent — another server did not answer, so their open tabs could not be counted." : e.nodes != 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).") + o;
9
9
  }
10
- function m(e, t) {
11
- return t > 0 ? `${e} is signed out of ${t} session${t === 1 ? "" : "s"} — every open tab goes back to sign-in.` : `${e} had no session open.`;
10
+ function l(e, o) {
11
+ return o > 0 ? `${e} is signed out of ${o} session${o === 1 ? "" : "s"} — every open tab goes back to sign-in.` : `${e} had no session open.`;
12
12
  }
13
- function $(e, t = {}) {
14
- const o = u();
13
+ function y(e, o = {}) {
14
+ const n = u();
15
15
  return i({
16
- mutationFn: (r = {}) => {
17
- if (!o) throw new Error("Not connected");
18
- return o.request(
16
+ mutationFn: (s = {}) => {
17
+ if (!n) throw new Error("Not connected");
18
+ return n.request(
19
19
  c("/realtime/force-refresh", {
20
20
  user_ids: [e],
21
- seconds: r.seconds ?? 15,
22
- message: r.message ?? ""
21
+ seconds: s.seconds ?? 15,
22
+ message: s.message ?? ""
23
23
  })
24
- ).then((n) => n.data);
24
+ ).then((t) => t.data);
25
25
  },
26
- onSuccess: (r) => {
27
- var n;
28
- s.success(h(r)), (n = t.onDone) == null || n.call(t);
26
+ onSuccess: (s) => {
27
+ var t;
28
+ a.success(h(s)), (t = o.onDone) == null || t.call(o);
29
29
  },
30
- onError: (r) => s.error(d(r, "Failed to push the reload"))
30
+ onError: (s) => a.error(m(s, "Failed to push the reload"))
31
31
  });
32
32
  }
33
- function w(e, t, o = {}) {
34
- const r = u();
33
+ function $(e, o, n = {}) {
34
+ const s = u();
35
35
  return i({
36
- mutationFn: () => {
37
- if (!r) throw new Error("Not connected");
38
- return r.request(c(`/security/users/${e}/sign-out`)).then((n) => n.data);
36
+ // `message` (optional): shown to them on their sign-in page (sign-out-note).
37
+ mutationFn: (t) => {
38
+ if (!s) throw new Error("Not connected");
39
+ const r = t && typeof t.message == "string" ? t.message.trim() : "";
40
+ return s.request(
41
+ c(`/security/users/${e}/sign-out`, r ? { message: r } : {})
42
+ ).then((d) => d.data);
39
43
  },
40
- onSuccess: (n) => {
41
- var a;
42
- s.success(m(t, n.revoked)), (a = o.onDone) == null || a.call(o);
44
+ onSuccess: (t) => {
45
+ var r;
46
+ a.success(
47
+ l(o, t.revoked) + (t.message_left === !0 ? " Your message waits on their sign-in page." : t.message_left === !1 ? " Your message could not be left — tell them another way." : "")
48
+ ), (r = n.onDone) == null || r.call(n);
43
49
  },
44
- onError: (n) => s.error(d(n, "Could not sign them out"))
50
+ onError: (t) => a.error(m(t, "Could not sign them out"))
45
51
  });
46
52
  }
47
53
  export {
48
54
  h as reloadPushedText,
49
- m as signedOutText,
50
- $ as useReloadTheirTabs,
51
- w as useSignOutEverywhere
55
+ l as signedOutText,
56
+ y as useReloadTheirTabs,
57
+ $ as useSignOutEverywhere
52
58
  };
@@ -0,0 +1,54 @@
1
+ const g = "session:signed-out-note", r = "nvr:signout-note", s = "nvr:signed-out-note", m = 12096e5;
2
+ function i(e) {
3
+ if (!e || typeof e != "object") return null;
4
+ const t = e;
5
+ return typeof t.message != "string" || !t.message.trim() || typeof t.at != "string" || Number.isNaN(Date.parse(t.at)) ? null : {
6
+ user_id: typeof t.user_id == "string" && t.user_id ? t.user_id.toUpperCase() : null,
7
+ message: t.message.trim().slice(0, 280),
8
+ by_name: typeof t.by_name == "string" && t.by_name.trim() ? t.by_name.trim() : null,
9
+ at: t.at
10
+ };
11
+ }
12
+ function _(e) {
13
+ try {
14
+ localStorage.setItem(r, JSON.stringify(e));
15
+ } catch {
16
+ }
17
+ try {
18
+ window.dispatchEvent(new CustomEvent(s, { detail: e }));
19
+ } catch {
20
+ }
21
+ }
22
+ function l() {
23
+ try {
24
+ const e = localStorage.getItem(r), t = e ? i(JSON.parse(e)) : null;
25
+ return t && Date.now() - Date.parse(t.at) > 12096e5 ? (u(), null) : t;
26
+ } catch {
27
+ return null;
28
+ }
29
+ }
30
+ function u() {
31
+ try {
32
+ localStorage.removeItem(r);
33
+ } catch {
34
+ }
35
+ }
36
+ function N(e, t) {
37
+ return !!e && !!t && e.at === t.at && e.message === t.message && (e.user_id ?? "") === (t.user_id ?? "");
38
+ }
39
+ function S(e, t = /* @__PURE__ */ new Date()) {
40
+ const n = new Date(e.at), a = n.toLocaleTimeString("en-US", { hour: "numeric", minute: "2-digit" }), o = n.toDateString() === t.toDateString() ? `at ${a}` : `on ${n.toLocaleDateString("en-US", { month: "short", day: "numeric" })} at ${a}`;
41
+ return `Signed out by ${e.by_name ?? "an administrator"} ${o}`;
42
+ }
43
+ export {
44
+ g as SIGN_OUT_NOTE_EVENT,
45
+ m as SIGN_OUT_NOTE_KEEP_MS,
46
+ r as SIGN_OUT_NOTE_KEY,
47
+ s as SIGN_OUT_NOTE_WINDOW_EVENT,
48
+ u as clearSignOutNote,
49
+ i as parseSignOutNote,
50
+ l as readSignOutNote,
51
+ N as sameSignOutNote,
52
+ _ as saveSignOutNote,
53
+ S as signOutNoteHeading
54
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nivaro/react",
3
- "version": "0.3.82",
3
+ "version": "0.3.84",
4
4
  "description": "React hooks and components for Nivaro CMS forms",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",