@nivaro/react 0.3.100 → 0.3.102

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 (32) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +46 -3
  4. package/dist/index.js +623 -620
  5. package/dist/shared/components/ActivityEntry.js +5 -5
  6. package/dist/shared/components/CollectionBrowserView.js +183 -175
  7. package/dist/shared/components/ItemEditForm.js +2708 -2704
  8. package/dist/shared/components/JobsTray.js +74 -63
  9. package/dist/shared/components/NotificationBell.js +80 -73
  10. package/dist/shared/components/TipLayer.js +56 -41
  11. package/dist/shared/components/cbv-file-label.js +46 -0
  12. package/dist/shared/components/integrations/console/SignalCard.js +40 -40
  13. package/dist/shared/components/integrations/console/drill/SubmissionDrill.js +95 -73
  14. package/dist/shared/components/integrations/console/drill/status.js +23 -18
  15. package/dist/shared/components/item-edit/RecordInsights.js +86 -86
  16. package/dist/shared/components/item-edit/header-path-preview.js +46 -34
  17. package/dist/shared/components/notifications/DeliveryChips.js +1 -2
  18. package/dist/shared/components/panels/BackgroundMove.js +152 -85
  19. package/dist/shared/components/panels/PipelinePanel.js +602 -594
  20. package/dist/shared/components/profile/ActivityFeedCard.js +322 -0
  21. package/dist/shared/components/profile/DayTimeline.js +145 -140
  22. package/dist/shared/components/profile/PersonAccess.js +679 -383
  23. package/dist/shared/components/profile/PersonActivity.js +404 -427
  24. package/dist/shared/components/profile/PersonDidPanel.js +248 -134
  25. package/dist/shared/components/profile/PersonProfile.js +33 -32
  26. package/dist/shared/components/profile/journey-view.js +166 -0
  27. package/dist/shared/lib/activity-sentence.js +319 -236
  28. package/dist/shared/lib/jobs-tray.js +60 -41
  29. package/dist/shared/lib/move-failure.js +16 -6
  30. package/dist/shared/lib/obligation-banner.js +16 -16
  31. package/dist/shared/lib/partner-failure.js +44 -32
  32. package/package.json +1 -1
@@ -1,30 +1,30 @@
1
1
  import { jsxs as r, jsx as t, Fragment as Ne } from "react/jsx-runtime";
2
- import { readUnreadNotificationCount as Ce, markNotificationRead as $e, markNotificationsRead as _e, markAllNotificationsRead as Se } from "@nivaro/sdk";
3
- import { useQueryClient as qe, useQuery as re, useMutation as F } from "@tanstack/react-query";
4
- import { Bell as Me, CheckCheck as Re, ExternalLink as oe, Check as A, History as Ee, ShieldCheck as Fe, ChevronDown as Ae } from "lucide-react";
5
- import { useState as S, useRef as le, useEffect as P, useMemo as ie, Fragment as se } from "react";
2
+ import { readUnreadNotificationCount as Ce, markNotificationRead as $e, markNotificationsRead as _e, markAllNotificationsRead as Me } from "@nivaro/sdk";
3
+ import { useQueryClient as Se, useQuery as re, useMutation as F } from "@tanstack/react-query";
4
+ import { Bell as qe, CheckCheck as Re, ExternalLink as oe, Check as A, History as Ee, ShieldCheck as Fe, ChevronDown as Ae } from "lucide-react";
5
+ import { useState as M, useRef as le, useEffect as P, useMemo as ie, Fragment as se } from "react";
6
6
  import { createPortal as Le } from "react-dom";
7
7
  import { useNivaroClient as Ie } from "../context.js";
8
8
  import { get as De, post as Te } from "../lib/commands.js";
9
9
  import { useLiveRefetchInterval as Ke } from "../lib/live-queries.js";
10
- import { resolveNotificationTargetFor as q, runNotificationTarget as L } from "../lib/notification-target.js";
11
- import { useTabAttention as Be } from "../lib/tab-attention.js";
12
- import { formatRelative as de, cn as je } from "../lib/utils.js";
13
- import { AsItWasSheet as ze } from "./notifications/AsItWasSheet.js";
14
- import { bundleLocally as Oe, laneTone as Pe, bundleAsNotification as Qe, bundleHeadline as He, categoryChipLabel as Ge } from "./notifications/bundles.js";
10
+ import { resolveNotificationTargetFor as S, runNotificationTarget as L } from "../lib/notification-target.js";
11
+ import { useTabAttention as Oe } from "../lib/tab-attention.js";
12
+ import { formatRelative as de, cn as Be } from "../lib/utils.js";
13
+ import { AsItWasSheet as je } from "./notifications/AsItWasSheet.js";
14
+ import { bundleLocally as ze, laneTone as Pe, bundleAsNotification as Qe, bundleHeadline as He, categoryChipLabel as Ge } from "./notifications/bundles.js";
15
15
  import { DeliveryChips as Ue } from "./notifications/DeliveryChips.js";
16
16
  import { NotificationActions as Ye } from "./notifications/NotificationActions.js";
17
17
  import { NotificationDetailBits as Ve } from "./notifications/NotificationDetailBits.js";
18
18
  function We(n) {
19
- var m, g;
19
+ var p, k;
20
20
  if (!n) return null;
21
21
  if (n.target_label && n.kind !== "record") return n.target_label;
22
22
  if (String(n.collection ?? "") === "__chat__") return "Chat";
23
23
  if (!n.collection) return null;
24
- const d = ((m = n.record_collection_label) == null ? void 0 : m.trim()) || (() => {
24
+ const d = ((p = n.record_collection_label) == null ? void 0 : p.trim()) || (() => {
25
25
  const h = String(n.collection).replace(/_/g, " ").trim();
26
26
  return h ? h.charAt(0).toUpperCase() + h.slice(1) : null;
27
- })(), u = (g = n.record_label) == null ? void 0 : g.trim();
27
+ })(), u = (k = n.record_label) == null ? void 0 : k.trim();
28
28
  return d && u ? `${d} ${u}` : u || d || null;
29
29
  }
30
30
  function Je(n) {
@@ -32,37 +32,37 @@ function Je(n) {
32
32
  return ce(n) ? n.revision_id != null || (((u = (d = n.detail) == null ? void 0 : d.changes) == null ? void 0 : u.length) ?? 0) > 0 || n.category === "watch" || n.category === "workflow" : !1;
33
33
  }
34
34
  function ce(n) {
35
- var g, h, M;
36
- if ((((g = n.target) == null ? void 0 : g.kind) ?? n.kind ?? (n.collection && n.item ? "record" : null)) !== "record") return !1;
37
- const u = ((h = n.target) == null ? void 0 : h.collection) ?? n.collection, m = ((M = n.target) == null ? void 0 : M.id) ?? n.item;
38
- return !!u && m != null && m !== "" && !/^(nivaro|directus)_|^__/i.test(u);
35
+ var k, h, q;
36
+ if ((((k = n.target) == null ? void 0 : k.kind) ?? n.kind ?? (n.collection && n.item ? "record" : null)) !== "record") return !1;
37
+ const u = ((h = n.target) == null ? void 0 : h.collection) ?? n.collection, p = ((q = n.target) == null ? void 0 : q.id) ?? n.item;
38
+ return !!u && p != null && p !== "" && !/^(nivaro|directus)_|^__/i.test(u);
39
39
  }
40
40
  function xt({
41
41
  routes: n,
42
42
  onNavigate: d,
43
43
  app: u,
44
- subscribe: m,
45
- buttonClassName: g,
44
+ subscribe: p,
45
+ buttonClassName: k,
46
46
  panelClassName: h,
47
- beforeList: M,
47
+ beforeList: q,
48
48
  extraBadge: Q = 0,
49
49
  mailLogUrl: ue,
50
50
  renderTrigger: H,
51
51
  allPath: G,
52
- subscriptionsPath: me,
53
- rulesPath: pe,
52
+ subscriptionsPath: pe,
53
+ rulesPath: me,
54
54
  onActionError: fe,
55
55
  panelPlacement: $ = "below",
56
56
  tabBadge: xe = !0
57
57
  }) {
58
- const y = Ie(), [k, p] = S(!1), [w, U] = S("attention"), I = le(null), Y = le(null), [D, he] = S(null), V = qe(), _ = () => {
58
+ const y = Ie(), [g, m] = M(!1), [w, U] = M("attention"), I = le(null), Y = le(null), [D, he] = M(null), V = Se(), _ = () => {
59
59
  V.invalidateQueries({ queryKey: ["notification-count"] }), V.invalidateQueries({ queryKey: ["notifications"] });
60
- }, be = Ke(6e4, { enabled: !!m, safetyMs: 12e4 }), { data: f } = re({
60
+ }, be = Ke(6e4, { enabled: !!p, safetyMs: 12e4 }), { data: f } = re({
61
61
  queryKey: ["notification-count"],
62
62
  queryFn: () => y.request(Ce()),
63
63
  refetchInterval: be
64
64
  }), T = (f == null ? void 0 : f.unread) ?? 0, K = (f == null ? void 0 : f.attention) ?? T, R = (f == null ? void 0 : f.lanes) ?? { critical: 0, fyi: 0 }, N = T + Q;
65
- Be(K + Q, { enabled: xe });
65
+ Oe(K + Q, { enabled: xe });
66
66
  const { data: x } = re({
67
67
  queryKey: ["notifications", "bell", u ?? null, w],
68
68
  queryFn: () => y.request(
@@ -75,20 +75,20 @@ function xt({
75
75
  })
76
76
  ).then((e) => {
77
77
  const a = e.pinned ?? [], o = new Set(a.map((s) => s.id)), i = (e.data ?? []).filter((s) => !o.has(s.id));
78
- return e.bundles ? { rows: i, bundles: e.bundles, pinned: a } : { ...Oe(i), pinned: a };
78
+ return e.bundles ? { rows: i, bundles: e.bundles, pinned: a } : { ...ze(i), pinned: a };
79
79
  }),
80
- enabled: k
81
- }), W = (x == null ? void 0 : x.rows) ?? [], B = (x == null ? void 0 : x.pinned) ?? [], J = (x == null ? void 0 : x.bundles) ?? [], [ge, X] = S(() => /* @__PURE__ */ new Set()), [C, j] = S(null);
82
- P(() => m == null ? void 0 : m(_), [m]), P(() => {
83
- if (!k) return;
80
+ enabled: g
81
+ }), W = (x == null ? void 0 : x.rows) ?? [], O = (x == null ? void 0 : x.pinned) ?? [], J = (x == null ? void 0 : x.bundles) ?? [], [ke, X] = M(() => /* @__PURE__ */ new Set()), [C, B] = M(null);
82
+ P(() => p == null ? void 0 : p(_), [p]), P(() => {
83
+ if (!g) return;
84
84
  const e = (a) => {
85
85
  var i, s;
86
86
  const o = a.target;
87
- (i = I.current) != null && i.contains(o) || (s = Y.current) != null && s.contains(o) || p(!1);
87
+ (i = I.current) != null && i.contains(o) || (s = Y.current) != null && s.contains(o) || m(!1);
88
88
  };
89
89
  return window.addEventListener("mousedown", e), () => window.removeEventListener("mousedown", e);
90
- }, [k]), P(() => {
91
- if (!k || $ !== "right") return;
90
+ }, [g]), P(() => {
91
+ if (!g || $ !== "right") return;
92
92
  const e = () => {
93
93
  var o;
94
94
  const a = (o = I.current) == null ? void 0 : o.getBoundingClientRect();
@@ -100,18 +100,18 @@ function xt({
100
100
  return e(), window.addEventListener("resize", e), window.addEventListener("scroll", e, !0), () => {
101
101
  window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
102
102
  };
103
- }, [k, $]);
103
+ }, [g, $]);
104
104
  const Z = F({
105
105
  mutationFn: (e) => y.request(Te(`/notifications/${e}/acknowledge`)),
106
106
  onSuccess: _
107
107
  }), E = F({
108
108
  mutationFn: (e) => y.request($e(e)),
109
109
  onSuccess: _
110
- }), z = F({
110
+ }), j = F({
111
111
  mutationFn: (e) => y.request(_e(e)),
112
112
  onSuccess: _
113
- }), ke = F({
114
- mutationFn: () => y.request(Se()),
113
+ }), ge = F({
114
+ mutationFn: () => y.request(Me()),
115
115
  onSuccess: _
116
116
  }), ee = ie(() => W.slice(0, 40), [W]), te = ie(() => {
117
117
  const e = /* @__PURE__ */ new Map();
@@ -126,13 +126,13 @@ function xt({
126
126
  }
127
127
  return [...e.values()];
128
128
  }, [ee]), we = (e) => {
129
- const a = q(e, n);
130
- a && (p(!1), L(a, d));
129
+ const a = S(e, n);
130
+ a && (m(!1), L(a, d));
131
131
  }, ae = (e) => {
132
- p(!1), d(e);
133
- }, O = (e, a, o = !1) => {
132
+ m(!1), d(e);
133
+ }, z = (e, a, o = !1) => {
134
134
  var v;
135
- const i = q(e, n) != null, s = `py-2 pr-3 ${o ? "pl-7" : "pl-3"}`, b = /* @__PURE__ */ r(Ne, { children: [
135
+ const i = S(e, n) != null, s = `py-2 pr-3 ${o ? "pl-7" : "pl-3"}`, b = /* @__PURE__ */ r(Ne, { children: [
136
136
  /* @__PURE__ */ t(
137
137
  "span",
138
138
  {
@@ -170,10 +170,10 @@ function xt({
170
170
  "data-notification-as-it-was": e.id,
171
171
  "data-tip": "The record as it was when you were told",
172
172
  onClick: (c) => {
173
- c.stopPropagation(), p(!1), j(e);
173
+ c.stopPropagation(), m(!1), B(e);
174
174
  },
175
175
  onKeyDown: (c) => {
176
- (c.key === "Enter" || c.key === " ") && (c.preventDefault(), c.stopPropagation(), p(!1), j(e));
176
+ (c.key === "Enter" || c.key === " ") && (c.preventDefault(), c.stopPropagation(), m(!1), B(e));
177
177
  },
178
178
  className: "inline-flex items-center gap-0.5 rounded px-1 text-[10.5px] text-slate-400 transition-colors hover:bg-slate-100 hover:text-slate-700 dark:hover:bg-muted dark:hover:text-slate-200",
179
179
  children: [
@@ -233,7 +233,7 @@ function xt({
233
233
  "data-tip": "Mark read",
234
234
  tabIndex: e.read ? -1 : void 0,
235
235
  onClick: () => E.mutate(e.id),
236
- className: je(l, "shrink-0", e.read && "invisible"),
236
+ className: Be(l, "shrink-0", e.read && "invisible"),
237
237
  children: /* @__PURE__ */ t(A, { className: "h-3 w-3" })
238
238
  }
239
239
  )
@@ -271,15 +271,15 @@ function xt({
271
271
  delivery: e.delivery,
272
272
  notificationId: e.id,
273
273
  recordChanges: Je(e),
274
- subscriptionsPath: me,
275
- rulesPath: pe,
274
+ subscriptionsPath: pe,
275
+ rulesPath: me,
276
276
  onNavigate: ae,
277
277
  className: `pb-3 pr-3 ${o ? "pl-[46px]" : "pl-[30px]"}`
278
278
  }
279
279
  )
280
280
  ] }, e.id);
281
281
  }, ve = (e) => {
282
- const a = `${e.collection}:${e.item}`, o = ge.has(a), i = Pe(e.lane), s = e.deleted ? null : q(Qe(e), n), b = e.rows.filter((l) => !l.read).map((l) => l.id);
282
+ const a = `${e.collection}:${e.item}`, o = ke.has(a), i = Pe(e.lane), s = e.deleted ? null : S(Qe(e), n), b = e.rows.filter((l) => !l.read).map((l) => l.id);
283
283
  return /* @__PURE__ */ r(
284
284
  "div",
285
285
  {
@@ -315,7 +315,7 @@ function xt({
315
315
  {
316
316
  type: "button",
317
317
  onClick: () => {
318
- s ? (p(!1), L(s, d)) : X((l) => new Set(l).add(a));
318
+ s ? (m(!1), L(s, d)) : X((l) => new Set(l).add(a));
319
319
  },
320
320
  className: "min-w-0 flex-1 text-left",
321
321
  children: [
@@ -354,7 +354,8 @@ function xt({
354
354
  "span",
355
355
  {
356
356
  className: "rounded bg-rose-50 px-1 py-px text-[9.5px] font-semibold text-rose-700 dark:bg-rose-900/30 dark:text-rose-300",
357
- title: "This record has since been deleted",
357
+ "data-notification-bundle-gone": !0,
358
+ "data-tip": "This record has since been deleted",
358
359
  children: "deleted"
359
360
  }
360
361
  ),
@@ -382,9 +383,11 @@ function xt({
382
383
  "button",
383
384
  {
384
385
  type: "button",
385
- title: "Open record",
386
+ "aria-label": "Open record",
387
+ "data-tip": "Open record",
388
+ "data-notification-open-record": !0,
386
389
  onClick: () => {
387
- p(!1), L(s, d);
390
+ m(!1), L(s, d);
388
391
  },
389
392
  className: "rounded p-1 text-slate-400 hover:bg-slate-100 hover:text-slate-700 dark:hover:bg-muted dark:hover:text-slate-200",
390
393
  children: /* @__PURE__ */ t(oe, { className: "h-3 w-3" })
@@ -394,9 +397,10 @@ function xt({
394
397
  "button",
395
398
  {
396
399
  type: "button",
397
- title: "Mark all read",
400
+ "aria-label": "Mark read",
401
+ "data-tip": "Mark read",
398
402
  "data-notification-bundle-read": a,
399
- onClick: () => z.mutate(b),
403
+ onClick: () => j.mutate(b),
400
404
  className: "rounded p-1 text-slate-400 hover:bg-slate-100 hover:text-slate-700 dark:hover:bg-muted dark:hover:text-slate-200",
401
405
  children: /* @__PURE__ */ t(A, { className: "h-3 w-3" })
402
406
  }
@@ -408,7 +412,7 @@ function xt({
408
412
  {
409
413
  className: "border-t border-slate-50 bg-slate-50/50 dark:border-border/50 dark:bg-muted/30",
410
414
  "data-notification-bundle-rows": a,
411
- children: e.rows.map((l) => O(l, !0, !0))
415
+ children: e.rows.map((l) => z(l, !0, !0))
412
416
  }
413
417
  )
414
418
  ]
@@ -419,17 +423,17 @@ function xt({
419
423
  { key: "attention", label: "Needs you", count: K },
420
424
  { key: "fyi", label: "FYI", count: R.fyi },
421
425
  { key: "all", label: "All", count: null }
422
- ], ne = () => p((e) => (!e && w === "attention" && K === 0 && R.fyi > 0 && U("fyi"), !e));
426
+ ], ne = () => m((e) => (!e && w === "attention" && K === 0 && R.fyi > 0 && U("fyi"), !e));
423
427
  return /* @__PURE__ */ r("div", { ref: I, className: "relative", "data-nvr-notification-bell": !0, children: [
424
- H ? H({ open: k, badge: N, toggle: ne }) : /* @__PURE__ */ r(
428
+ H ? H({ open: g, badge: N, toggle: ne }) : /* @__PURE__ */ r(
425
429
  "button",
426
430
  {
427
431
  type: "button",
428
432
  onClick: ne,
429
- className: g ?? "relative rounded-md p-1.5 text-slate-500 transition-colors hover:bg-slate-100 dark:text-slate-400 dark:hover:bg-muted",
433
+ className: k ?? "relative rounded-md p-1.5 text-slate-500 transition-colors hover:bg-slate-100 dark:text-slate-400 dark:hover:bg-muted",
430
434
  "aria-label": N ? `Notifications (${N} unread)` : "Notifications",
431
435
  children: [
432
- /* @__PURE__ */ t(Me, { className: "h-4 w-4", strokeWidth: 1.8 }),
436
+ /* @__PURE__ */ t(qe, { className: "h-4 w-4", strokeWidth: 1.8 }),
433
437
  N > 0 && /* @__PURE__ */ t(
434
438
  "span",
435
439
  {
@@ -441,7 +445,7 @@ function xt({
441
445
  ]
442
446
  }
443
447
  ),
444
- k && ($ === "right" ? Le : (e) => e)(
448
+ g && ($ === "right" ? Le : (e) => e)(
445
449
  /* @__PURE__ */ r(
446
450
  "div",
447
451
  {
@@ -450,7 +454,7 @@ function xt({
450
454
  style: $ === "right" && D ? { left: D.left, bottom: D.bottom } : void 0,
451
455
  "data-nvr-notification-panel": !0,
452
456
  children: [
453
- M,
457
+ q,
454
458
  /* @__PURE__ */ r("div", { className: "flex items-center justify-between border-b border-slate-100 px-3 py-2 dark:border-border/60", children: [
455
459
  /* @__PURE__ */ t("div", { className: "flex items-center gap-1 rounded-md bg-slate-100 p-0.5 dark:bg-muted", children: ye.map((e) => /* @__PURE__ */ r(
456
460
  "button",
@@ -476,7 +480,7 @@ function xt({
476
480
  "button",
477
481
  {
478
482
  type: "button",
479
- onClick: () => ke.mutate(),
483
+ onClick: () => ge.mutate(),
480
484
  className: "inline-flex items-center gap-1 text-[11px] font-medium text-slate-400 transition-colors hover:text-nvr-cyan",
481
485
  children: [
482
486
  /* @__PURE__ */ t(Re, { className: "h-3.5 w-3.5", strokeWidth: 2 }),
@@ -486,14 +490,14 @@ function xt({
486
490
  )
487
491
  ] }),
488
492
  /* @__PURE__ */ r("div", { className: "max-h-96 overflow-y-auto", children: [
489
- B.length > 0 && /* @__PURE__ */ r("div", { "data-notification-pinned": !0, children: [
493
+ O.length > 0 && /* @__PURE__ */ r("div", { "data-notification-pinned": !0, children: [
490
494
  /* @__PURE__ */ t("div", { className: "bg-amber-50 px-3 py-1 text-[10px] font-semibold uppercase tracking-wide text-amber-700 dark:bg-amber-400/10 dark:text-amber-300", children: "Needs your acknowledgement" }),
491
- B.map((e) => /* @__PURE__ */ t(se, { children: O(e, !!q(e, n)) }, e.id))
495
+ O.map((e) => /* @__PURE__ */ t(se, { children: z(e, !!S(e, n)) }, e.id))
492
496
  ] }),
493
- te.length === 0 && J.length === 0 && B.length === 0 ? /* @__PURE__ */ t("p", { className: "px-3 py-6 text-center text-[12px] text-slate-400", children: w === "attention" ? "Nothing needs you right now." : w === "fyi" ? "No FYI notifications." : "No notifications" }) : [
497
+ te.length === 0 && J.length === 0 && O.length === 0 ? /* @__PURE__ */ t("p", { className: "px-3 py-6 text-center text-[12px] text-slate-400", children: w === "attention" ? "Nothing needs you right now." : w === "fyi" ? "No FYI notifications." : "No notifications" }) : [
494
498
  ...J.map(ve),
495
499
  ...te.map((e) => {
496
- const a = e.rows.filter((l) => !l.read).map((l) => l.id), o = q(e.rows[0], n), i = !!o, s = e.rows.find((l) => l.record_label) ?? e.rows[0], b = We(s);
500
+ const a = e.rows.filter((l) => !l.read).map((l) => l.id), o = S(e.rows[0], n), i = !!o, s = e.rows.find((l) => l.record_label) ?? e.rows[0], b = We(s);
497
501
  return /* @__PURE__ */ r(
498
502
  "div",
499
503
  {
@@ -509,9 +513,11 @@ function xt({
509
513
  "button",
510
514
  {
511
515
  type: "button",
512
- title: "Open record",
516
+ "aria-label": "Open record",
517
+ "data-tip": "Open record",
518
+ "data-notification-open-record": !0,
513
519
  onClick: () => {
514
- a.length && z.mutate(a), p(!1), L(o, d);
520
+ a.length && j.mutate(a), m(!1), L(o, d);
515
521
  },
516
522
  className: "rounded p-1 text-slate-400 hover:bg-slate-100 hover:text-slate-700 dark:hover:bg-muted dark:hover:text-slate-200",
517
523
  children: /* @__PURE__ */ t(oe, { className: "h-3 w-3" })
@@ -521,15 +527,16 @@ function xt({
521
527
  "button",
522
528
  {
523
529
  type: "button",
524
- title: "Mark read",
525
- onClick: () => z.mutate(a),
530
+ "aria-label": "Mark read",
531
+ "data-tip": "Mark read",
532
+ onClick: () => j.mutate(a),
526
533
  className: "rounded p-1 text-slate-400 hover:bg-slate-100 hover:text-slate-700 dark:hover:bg-muted dark:hover:text-slate-200",
527
534
  children: /* @__PURE__ */ t(A, { className: "h-3 w-3" })
528
535
  }
529
536
  )
530
537
  ] })
531
538
  ] }),
532
- e.rows.map((l) => O(l, i))
539
+ e.rows.map((l) => z(l, i))
533
540
  ]
534
541
  },
535
542
  e.key
@@ -542,7 +549,7 @@ function xt({
542
549
  {
543
550
  type: "button",
544
551
  onClick: () => {
545
- p(!1), d(G);
552
+ m(!1), d(G);
546
553
  },
547
554
  className: "block w-full border-t border-slate-100 px-3 py-1.5 text-center text-[11px] font-medium text-slate-500 hover:text-nvr-cyan dark:border-border/60",
548
555
  children: "See all notifications"
@@ -554,11 +561,11 @@ function xt({
554
561
  document.body
555
562
  ),
556
563
  /* @__PURE__ */ t(
557
- ze,
564
+ je,
558
565
  {
559
566
  notificationId: (C == null ? void 0 : C.id) ?? null,
560
567
  title: (C == null ? void 0 : C.title) ?? null,
561
- onClose: () => j(null)
568
+ onClose: () => B(null)
562
569
  }
563
570
  )
564
571
  ] });
@@ -1,42 +1,57 @@
1
- import { jsx as g } from "react/jsx-runtime";
2
- import { useState as m, useRef as v, useEffect as h, useLayoutEffect as x } from "react";
3
- import { createPortal as b } from "react-dom";
4
- const u = [];
5
- function R() {
6
- const [e, o] = m(null), [t, s] = m(!1), d = v(null);
7
- return h(() => (u.push(s), u[0] === s && s(!0), () => {
8
- var n;
9
- const r = u.indexOf(s);
10
- r < 0 || (u.splice(r, 1), r === 0 && ((n = u[0]) == null || n.call(u, !0)));
11
- }), []), h(() => {
12
- if (!t) return;
13
- const r = (c) => {
14
- var l, p;
15
- const i = (p = (l = c.target) == null ? void 0 : l.closest) == null ? void 0 : p.call(l, "[data-tip]"), f = i == null ? void 0 : i.getAttribute("data-tip");
16
- if (!i || !f || i.getAttribute("aria-expanded") === "true") {
17
- o((w) => w && null);
1
+ import { jsx as y } from "react/jsx-runtime";
2
+ import { useState as g, useRef as v, useEffect as m, useLayoutEffect as b } from "react";
3
+ import { createPortal as E } from "react-dom";
4
+ const c = [], L = '[data-nvr-header-menu-panel], [role="menu"]', x = 6;
5
+ function A() {
6
+ const [e, o] = g(null), [r, u] = g(!1), f = v(null);
7
+ return m(() => (c.push(u), c[0] === u && u(!0), () => {
8
+ var t;
9
+ const i = c.indexOf(u);
10
+ i < 0 || (c.splice(i, 1), i === 0 && ((t = c[0]) == null || t.call(c, !0)));
11
+ }), []), m(() => {
12
+ if (!r) return;
13
+ const i = (l) => {
14
+ var w, p;
15
+ const n = (p = (w = l.target) == null ? void 0 : w.closest) == null ? void 0 : p.call(w, "[data-tip]"), s = n == null ? void 0 : n.getAttribute("data-tip");
16
+ if (!n || !s || n.getAttribute("aria-expanded") === "true") {
17
+ o((a) => a && null);
18
+ return;
19
+ }
20
+ const d = n.getBoundingClientRect(), h = n.closest(L);
21
+ if (h && h !== n) {
22
+ const a = h.getBoundingClientRect();
23
+ o({
24
+ x: a.left,
25
+ y: d.top,
26
+ text: s,
27
+ beside: { left: a.left, right: a.right, rowTop: d.top, rowHeight: d.height }
28
+ });
18
29
  return;
19
30
  }
20
- const a = i.getBoundingClientRect();
21
- o({ x: a.left, y: a.bottom + 4, text: f });
22
- }, n = () => o(null);
23
- return window.addEventListener("mouseover", r), window.addEventListener("pointerdown", n, !0), window.addEventListener("scroll", n, !0), () => {
24
- window.removeEventListener("mouseover", r), window.removeEventListener("pointerdown", n, !0), window.removeEventListener("scroll", n, !0);
31
+ o({ x: d.left, y: d.bottom + 4, text: s });
32
+ }, t = () => o(null);
33
+ return window.addEventListener("mouseover", i), window.addEventListener("pointerdown", t, !0), window.addEventListener("scroll", t, !0), () => {
34
+ window.removeEventListener("mouseover", i), window.removeEventListener("pointerdown", t, !0), window.removeEventListener("scroll", t, !0);
25
35
  };
26
- }, [t]), x(() => {
36
+ }, [r]), b(() => {
27
37
  if (!e) return;
28
- const r = d.current;
29
- if (!r) return;
30
- const n = r.getBoundingClientRect();
31
- let { x: c, y: i } = e;
32
- n.right > window.innerWidth - 8 && (c = Math.max(8, window.innerWidth - n.width - 8)), n.bottom > window.innerHeight - 8 && (i = Math.max(8, e.y - n.height - 30)), (c !== e.x || i !== e.y) && o({ ...e, x: c, y: i });
33
- }, [e]), !t || !e ? null : b(
34
- /* @__PURE__ */ g(
38
+ const i = f.current;
39
+ if (!i) return;
40
+ const t = i.getBoundingClientRect();
41
+ let { x: l, y: n } = e;
42
+ if (e.beside) {
43
+ const s = e.beside, d = s.left - x - t.width;
44
+ l = d >= 8 ? d : Math.min(s.right + x, Math.max(8, window.innerWidth - t.width - 8)), n = Math.round(s.rowTop + (s.rowHeight - t.height) / 2), n = Math.max(8, Math.min(n, window.innerHeight - t.height - 8));
45
+ } else
46
+ t.right > window.innerWidth - 8 && (l = Math.max(8, window.innerWidth - t.width - 8)), t.bottom > window.innerHeight - 8 && (n = Math.max(8, e.y - t.height - 30));
47
+ (l !== e.x || n !== e.y) && o({ ...e, x: l, y: n });
48
+ }, [e]), !r || !e ? null : E(
49
+ /* @__PURE__ */ y(
35
50
  "div",
36
51
  {
37
- ref: d,
52
+ ref: f,
38
53
  style: { position: "fixed", left: e.x, top: e.y, zIndex: 120 },
39
- className: "pointer-events-none max-w-[340px] whitespace-pre-wrap break-words rounded-md bg-[#0f172a] px-2 py-1 text-[11px] font-medium leading-snug text-white shadow-lg dark:bg-[#334155]",
54
+ className: "pointer-events-none max-w-[340px] whitespace-pre-wrap break-words rounded-md bg-[#0f172a] px-2 py-1 text-[11px] font-medium leading-snug text-white shadow-lg dark:bg-[#334155] dark:ring-1 dark:ring-white/10",
40
55
  children: e.text
41
56
  }
42
57
  ),
@@ -45,18 +60,18 @@ function R() {
45
60
  }
46
61
  function O(e) {
47
62
  const o = v(null);
48
- return x(() => {
49
- const t = o.current;
50
- if (!t) return;
51
- const s = () => {
52
- (t.scrollWidth > t.clientWidth + 1 || t.scrollHeight > t.clientHeight + 1) && e ? t.setAttribute("data-tip", e) : t.removeAttribute("data-tip");
63
+ return b(() => {
64
+ const r = o.current;
65
+ if (!r) return;
66
+ const u = () => {
67
+ (r.scrollWidth > r.clientWidth + 1 || r.scrollHeight > r.clientHeight + 1) && e ? r.setAttribute("data-tip", e) : r.removeAttribute("data-tip");
53
68
  };
54
- if (s(), typeof ResizeObserver > "u") return;
55
- const d = new ResizeObserver(s);
56
- return d.observe(t), () => d.disconnect();
69
+ if (u(), typeof ResizeObserver > "u") return;
70
+ const f = new ResizeObserver(u);
71
+ return f.observe(r), () => f.disconnect();
57
72
  }, [e]), o;
58
73
  }
59
74
  export {
60
- R as TipLayer,
75
+ A as TipLayer,
61
76
  O as useOverflowTip
62
77
  };
@@ -0,0 +1,46 @@
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import { useQuery as c } from "@tanstack/react-query";
3
+ import { useNivaroClient as d, useApiFetchConfig as p } from "../context.js";
4
+ import { get as u } from "../lib/commands.js";
5
+ import { relatedMissing as m } from "./item-edit/related-missing.js";
6
+ function k({ id: n }) {
7
+ const l = d(), { apiBase: i } = p(), a = n != null && n !== "", { data: e, isPending: s } = c({
8
+ queryKey: ["cbv-file-meta", String(n)],
9
+ queryFn: () => l.request(
10
+ u(`/files/${encodeURIComponent(String(n))}/meta`)
11
+ ).then((t) => t.data ?? null).catch(() => null),
12
+ enabled: a,
13
+ staleTime: 5 * 6e4,
14
+ retry: !1
15
+ });
16
+ if (!a) return /* @__PURE__ */ r("span", { className: "text-[12px] text-slate-300", children: "—" });
17
+ if (s)
18
+ return /* @__PURE__ */ r("span", { className: "inline-block h-3.5 w-24 animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" });
19
+ const o = (e == null ? void 0 : e.title) || (e == null ? void 0 : e.filename_download);
20
+ if (!o) {
21
+ const t = m(null);
22
+ return /* @__PURE__ */ r(
23
+ "span",
24
+ {
25
+ "data-relation-missing": !0,
26
+ "data-tip": t.tip,
27
+ className: "text-[12px] italic text-slate-500 dark:text-slate-400",
28
+ children: t.text
29
+ }
30
+ );
31
+ }
32
+ return /* @__PURE__ */ r(
33
+ "a",
34
+ {
35
+ href: `${i}/files/${encodeURIComponent(String(n))}`,
36
+ target: "_blank",
37
+ rel: "noreferrer",
38
+ onClick: (t) => t.stopPropagation(),
39
+ className: "text-[12px] text-slate-700 underline decoration-slate-300 underline-offset-2 transition-colors hover:text-[#007a99] hover:decoration-[#007a99] dark:text-slate-200 dark:decoration-slate-600 dark:hover:text-nvr-cyan dark:hover:decoration-nvr-cyan",
40
+ children: o
41
+ }
42
+ );
43
+ }
44
+ export {
45
+ k as CbvFileLabel
46
+ };