@nivaro/react 0.3.115 → 0.3.116

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,13 +1,13 @@
1
1
  import { jsxs as n, jsx as t, Fragment as qe } from "react/jsx-runtime";
2
2
  import { useQueryClient as Nt, useQuery as H, keepPreviousData as Ct, useMutation as A } from "@tanstack/react-query";
3
- import { Archive as Me, CheckCheck as St, Search as _t, Check as oe, AlarmClock as ce, ExternalLink as Te, Bell as Le, ShieldCheck as ue, ChevronUp as At, ChevronLeft as Dt, ChevronRight as zt, History as $t, Trash2 as Ft, ChevronDown as qt } from "lucide-react";
3
+ import { ChevronUp as St, Archive as Me, CheckCheck as _t, Search as At, Check as oe, AlarmClock as ce, ExternalLink as Te, Bell as Le, ShieldCheck as ue, ChevronLeft as Dt, ChevronRight as zt, History as $t, Trash2 as Ft, ChevronDown as qt } from "lucide-react";
4
4
  import { useState as c, useEffect as me, useRef as Mt, useCallback as Tt, Fragment as pe } from "react";
5
5
  import { useNivaroClient as Lt } from "../../context.js";
6
6
  import { get as Q, post as w, patch as Pt, del as Rt } from "../../lib/commands.js";
7
7
  import { useTopInserts as Pe, slideIn as Ot } from "../../lib/live-screen.js";
8
8
  import { resolveNotificationTargetFor as V, runNotificationTarget as be } from "../../lib/notification-target.js";
9
- import { openInTabsMessage as It, openInTabs as jt } from "../../lib/open-in-tabs.js";
10
- import { useRecordPeek as Kt, isNewTabClick as Bt, notificationPeekTarget as Re } from "../../lib/record-peek.js";
9
+ import { openInTabsMessage as It, openInTabs as Kt } from "../../lib/open-in-tabs.js";
10
+ import { useRecordPeek as jt, isNewTabClick as Bt, notificationPeekTarget as Re } from "../../lib/record-peek.js";
11
11
  import { cn as b, formatRelative as Oe } from "../../lib/utils.js";
12
12
  import { AgentBadge as Ut } from "../AgentBadge.js";
13
13
  import { hasSnapshotView as Ht, offersChanges as Qt } from "../NotificationBell.js";
@@ -31,7 +31,7 @@ const xe = 25, na = [
31
31
  { key: "needs_you", label: "Needs you" },
32
32
  { key: "fyi", label: "FYI" }
33
33
  ];
34
- function je() {
34
+ function Ke() {
35
35
  const m = /* @__PURE__ */ new Date(), h = new Date(m.getTime() + 3600 * 1e3), N = new Date(m);
36
36
  N.setDate(N.getDate() + 1), N.setHours(8, 0, 0, 0);
37
37
  const D = new Date(m);
@@ -41,7 +41,7 @@ function je() {
41
41
  { label: "Until next week", until: D }
42
42
  ];
43
43
  }
44
- const Ke = (m) => `b:${m.collection}:${m.item}`, Be = (m) => `n:${m.id}`;
44
+ const je = (m) => `b:${m.collection}:${m.item}`, Be = (m) => `n:${m.id}`;
45
45
  function Sa({
46
46
  routes: m,
47
47
  onNavigate: h,
@@ -54,7 +54,7 @@ function Sa({
54
54
  onError: d,
55
55
  className: Ge
56
56
  }) {
57
- const p = Lt(), W = Kt(), Z = Nt(), [J, Ye] = c(() => {
57
+ const p = Lt(), W = jt(), Z = Nt(), [J, Ye] = c(() => {
58
58
  if (fe !== void 0) return fe;
59
59
  if (typeof window > "u") return null;
60
60
  const e = new URLSearchParams(window.location.search).get("changes"), a = Number(e);
@@ -66,9 +66,9 @@ function Sa({
66
66
  ).then((e) => e.data ?? []),
67
67
  enabled: i === "sent",
68
68
  refetchInterval: i === "sent" ? 3e4 : !1
69
- }), [S, F] = c(1), [Xe, X] = c(null), [ke, ve] = c(null), [E, Ee] = c(""), [I, et] = c(""), [q, tt] = c(""), [j, at] = c(!0), [nt, lt] = c(() => /* @__PURE__ */ new Set()), [v, ye] = c(null), [M, Y] = c(() => /* @__PURE__ */ new Set()), [ee, K] = c(!1), [rt, te] = c(!1), [we, dt] = c(!1), [Ne, it] = c("30");
69
+ }), [S, F] = c(1), [Xe, X] = c(null), [ke, ve] = c(null), [E, Ee] = c(""), [I, et] = c(""), [q, tt] = c(""), [K, at] = c(!0), [nt, lt] = c(() => /* @__PURE__ */ new Set()), [v, ye] = c(null), [M, Y] = c(() => /* @__PURE__ */ new Set()), [ee, j] = c(!1), [rt, te] = c(!1), [we, dt] = c(!1), [Ne, it] = c("30");
70
70
  me(() => {
71
- Y(/* @__PURE__ */ new Set()), K(!1), te(!1);
71
+ Y(/* @__PURE__ */ new Set()), j(!1), te(!1);
72
72
  }, [i, C, S, I, q]), me(() => {
73
73
  const e = setTimeout(() => {
74
74
  et(E.trim()), F(1);
@@ -88,7 +88,7 @@ function Sa({
88
88
  I,
89
89
  q,
90
90
  N ?? null,
91
- j
91
+ K
92
92
  ],
93
93
  queryFn: () => p.request(
94
94
  Q("/notifications", {
@@ -100,10 +100,10 @@ function Sa({
100
100
  search: I || void 0,
101
101
  collection: q || void 0,
102
102
  app: N,
103
- bundle: j ? "record" : void 0
103
+ bundle: K ? "record" : void 0
104
104
  })
105
105
  ).then((e) => {
106
- if (!j || e.bundles) return e;
106
+ if (!K || e.bundles) return e;
107
107
  const a = Yt(e.data ?? []);
108
108
  return { ...e, data: a.rows, bundles: a.bundles };
109
109
  }),
@@ -118,7 +118,7 @@ function Sa({
118
118
  return [...new Set(a.map((l) => l.collection))].sort();
119
119
  }),
120
120
  staleTime: 3e5
121
- }), z = i === "archived" || S > 1 ? [] : (u == null ? void 0 : u.pinned) ?? [], ut = new Set(z.map((e) => e.id)), T = ((u == null ? void 0 : u.data) ?? []).filter((e) => !ut.has(e.id)), B = (u == null ? void 0 : u.bundles) ?? [], $ = (u == null ? void 0 : u.total) ?? 0, ae = Math.max(1, Math.ceil($ / xe)), Ce = i !== "sent" && S === 1 && !!u && !ot, Se = [i, C, I, q, N ?? "", j].join("|"), L = Pe(u ? B : void 0, Ke, {
121
+ }), z = i === "archived" || S > 1 ? [] : (u == null ? void 0 : u.pinned) ?? [], ut = new Set(z.map((e) => e.id)), T = ((u == null ? void 0 : u.data) ?? []).filter((e) => !ut.has(e.id)), B = (u == null ? void 0 : u.bundles) ?? [], $ = (u == null ? void 0 : u.total) ?? 0, ae = Math.max(1, Math.ceil($ / xe)), Ce = i !== "sent" && S === 1 && !!u && !ot, Se = [i, C, I, q, N ?? "", K].join("|"), L = Pe(u ? B : void 0, je, {
122
122
  enabled: Ce,
123
123
  resetKey: Se
124
124
  }), P = Pe(u ? T : void 0, Be, {
@@ -186,7 +186,7 @@ function Sa({
186
186
  ),
187
187
  onSuccess: (e, a) => {
188
188
  var s;
189
- k(), Y(/* @__PURE__ */ new Set()), K(!1), te(!1);
189
+ k(), Y(/* @__PURE__ */ new Set()), j(!1), te(!1);
190
190
  const l = ((s = e.data) == null ? void 0 : s.updated) ?? 0;
191
191
  r == null || r(
192
192
  `${l} notification${l === 1 ? "" : "s"} ${a.action === "read" ? "marked read" : a.action === "archive" ? "archived" : "snoozed"}`
@@ -233,7 +233,7 @@ function Sa({
233
233
  e.read || (await p.request(w(`/notifications/${e.id}/read`)).catch(() => {
234
234
  }), k()), be(V(e, m), h);
235
235
  }, vt = (e) => {
236
- K(!1), Y((a) => {
236
+ j(!1), Y((a) => {
237
237
  const l = new Set(a);
238
238
  return l.has(e) ? l.delete(e) : l.add(e), l;
239
239
  });
@@ -429,7 +429,7 @@ function Sa({
429
429
  }
430
430
  ),
431
431
  ke === e.id && /* @__PURE__ */ n("div", { className: "absolute right-0 top-8 z-20 w-[180px] rounded-md border border-slate-200 bg-white py-1 shadow-lg dark:border-border dark:bg-card", children: [
432
- je().map((g) => /* @__PURE__ */ t(
432
+ Ke().map((g) => /* @__PURE__ */ t(
433
433
  "button",
434
434
  {
435
435
  type: "button",
@@ -494,7 +494,7 @@ function Sa({
494
494
  return /* @__PURE__ */ n(
495
495
  "div",
496
496
  {
497
- "data-live-key": Ke(e),
497
+ "data-live-key": je(e),
498
498
  "data-notification-bundle": a,
499
499
  "data-notification-bundle-count": e.count,
500
500
  "data-notification-bundle-lane": e.lane,
@@ -630,7 +630,23 @@ function Sa({
630
630
  /* @__PURE__ */ n("header", { className: "shrink-0 border-b border-slate-200 bg-white px-4 py-5 dark:border-border dark:bg-background sm:px-8", children: [
631
631
  /* @__PURE__ */ n("div", { className: "flex flex-wrap items-center justify-between gap-x-3 gap-y-2", children: [
632
632
  /* @__PURE__ */ n("div", { children: [
633
- /* @__PURE__ */ t("h1", { className: "text-xl font-bold text-slate-900 dark:text-slate-100", children: "Notifications" }),
633
+ /* @__PURE__ */ n("div", { className: "flex flex-wrap items-center gap-x-3 gap-y-1", children: [
634
+ /* @__PURE__ */ t("h1", { className: "text-xl font-bold text-slate-900 dark:text-slate-100", children: "Notifications" }),
635
+ ne > 0 && /* @__PURE__ */ n(
636
+ "button",
637
+ {
638
+ type: "button",
639
+ "data-notification-new-pill": ne,
640
+ onClick: bt,
641
+ className: "inline-flex h-7 items-center gap-1 rounded-full border border-nvr-cyan/40 bg-nvr-cyan/[0.08] px-3 text-[12px] font-medium text-nvr-navy transition-colors hover:bg-nvr-cyan/15 focus-visible:outline focus-visible:outline-2 focus-visible:outline-nvr-cyan dark:border-nvr-cyan/40 dark:bg-nvr-cyan/15 dark:text-nvr-cyan dark:hover:bg-nvr-cyan/25",
642
+ children: [
643
+ /* @__PURE__ */ t(St, { className: "h-3.5 w-3.5", "aria-hidden": !0 }),
644
+ ne,
645
+ " new"
646
+ ]
647
+ }
648
+ )
649
+ ] }),
634
650
  /* @__PURE__ */ n("p", { className: "mt-0.5 text-[13px] text-slate-400", children: [
635
651
  $,
636
652
  " notification",
@@ -660,7 +676,7 @@ function Sa({
660
676
  disabled: le.isPending,
661
677
  className: "inline-flex h-8 items-center gap-1.5 whitespace-nowrap rounded-md border border-slate-200 px-3 text-[12px] font-medium text-slate-700 hover:bg-slate-50 disabled:opacity-50 dark:border-border dark:text-foreground dark:hover:bg-muted",
662
678
  children: [
663
- /* @__PURE__ */ t(St, { className: "h-3.5 w-3.5" }),
679
+ /* @__PURE__ */ t(_t, { className: "h-3.5 w-3.5" }),
664
680
  le.isPending ? "Marking…" : "Mark all read"
665
681
  ]
666
682
  }
@@ -764,7 +780,7 @@ function Sa({
764
780
  e.key
765
781
  )) }),
766
782
  /* @__PURE__ */ n("div", { className: "relative w-full sm:ml-auto sm:w-auto", children: [
767
- /* @__PURE__ */ t(_t, { className: "pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400" }),
783
+ /* @__PURE__ */ t(At, { className: "pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400" }),
768
784
  /* @__PURE__ */ t(
769
785
  "input",
770
786
  {
@@ -800,7 +816,7 @@ function Sa({
800
816
  "input",
801
817
  {
802
818
  type: "checkbox",
803
- checked: j,
819
+ checked: K,
804
820
  onChange: (e) => at(e.target.checked),
805
821
  className: "h-3.5 w-3.5",
806
822
  "data-notification-group-by-record": !0
@@ -845,7 +861,7 @@ function Sa({
845
861
  "button",
846
862
  {
847
863
  type: "button",
848
- onClick: () => K(!0),
864
+ onClick: () => j(!0),
849
865
  "data-notification-select-matching": !0,
850
866
  className: "text-nvr-navy underline decoration-dotted underline-offset-2 dark:text-nvr-cyan",
851
867
  children: [
@@ -885,7 +901,7 @@ function Sa({
885
901
  ]
886
902
  }
887
903
  ),
888
- rt && /* @__PURE__ */ t("div", { className: "absolute left-0 top-8 z-20 w-[180px] rounded-md border border-slate-200 bg-white py-1 shadow-lg dark:border-border dark:bg-card", children: je().map((e) => /* @__PURE__ */ t(
904
+ rt && /* @__PURE__ */ t("div", { className: "absolute left-0 top-8 z-20 w-[180px] rounded-md border border-slate-200 bg-white py-1 shadow-lg dark:border-border dark:bg-card", children: Ke().map((e) => /* @__PURE__ */ t(
889
905
  "button",
890
906
  {
891
907
  type: "button",
@@ -921,7 +937,7 @@ function Sa({
921
937
  const l = V(a, m);
922
938
  l && (l.type === "external" ? e.push(l.url) : l.type === "path" && typeof window < "u" && e.push(`${window.location.origin}${l.path}`));
923
939
  }
924
- e.length === 0 ? r == null || r("None of the selected notifications opens a page") : r == null || r(It(jt(e)));
940
+ e.length === 0 ? r == null || r("None of the selected notifications opens a page") : r == null || r(It(Kt(e)));
925
941
  },
926
942
  "data-notification-bulk": "tabs",
927
943
  className: "inline-flex h-7 items-center gap-1 rounded-md border border-slate-200 bg-background px-2 text-[11.5px] font-medium hover:bg-slate-50 dark:border-border",
@@ -936,7 +952,7 @@ function Sa({
936
952
  {
937
953
  type: "button",
938
954
  onClick: () => {
939
- Y(/* @__PURE__ */ new Set()), K(!1);
955
+ Y(/* @__PURE__ */ new Set()), j(!1);
940
956
  },
941
957
  className: "ml-auto text-[11.5px] text-slate-500 underline decoration-dotted underline-offset-2",
942
958
  children: "Clear selection"
@@ -1034,51 +1050,34 @@ function Sa({
1034
1050
  /* @__PURE__ */ t(Le, { className: "h-10 w-10 text-slate-200 dark:text-slate-700" }),
1035
1051
  /* @__PURE__ */ t("p", { className: "mt-3 text-[14px] font-medium text-slate-500", children: "You're all caught up" }),
1036
1052
  /* @__PURE__ */ t("p", { className: "mt-1 text-[12px] text-slate-400", children: i === "inbox" ? "No unread notifications." : "No notifications here." })
1037
- ] }) : /* @__PURE__ */ n(qe, { children: [
1038
- ne > 0 && // Zero-height and sticky: floats over the list, never pushes it.
1039
- /* @__PURE__ */ t("div", { className: "sticky top-2 z-10 flex h-0 justify-center overflow-visible", children: /* @__PURE__ */ n(
1040
- "button",
1041
- {
1042
- type: "button",
1043
- "data-notification-new-pill": ne,
1044
- onClick: bt,
1045
- className: "mt-1 inline-flex h-7 items-center gap-1 rounded-full border border-nvr-cyan/40 bg-white px-3 text-[12px] font-medium text-nvr-navy shadow-sm transition-colors hover:bg-nvr-cyan/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-nvr-cyan dark:border-nvr-cyan/40 dark:bg-card dark:text-nvr-cyan dark:hover:bg-nvr-cyan/10",
1046
- children: [
1047
- /* @__PURE__ */ t(At, { className: "h-3.5 w-3.5", "aria-hidden": !0 }),
1048
- ne,
1049
- " new"
1050
- ]
1051
- }
1052
- ) }),
1053
- /* @__PURE__ */ n(
1054
- "div",
1055
- {
1056
- ref: pt,
1057
- className: "mx-8 my-6 divide-y divide-slate-100 overflow-hidden rounded-lg border border-slate-200 bg-white dark:divide-border dark:border-border dark:bg-card",
1058
- children: [
1059
- z.length > 0 && /* @__PURE__ */ n("div", { "data-notification-pinned": !0, children: [
1060
- /* @__PURE__ */ n("div", { className: "bg-amber-50 px-4 py-1 text-[10.5px] font-semibold uppercase tracking-wide text-amber-700 dark:bg-amber-400/10 dark:text-amber-300", children: [
1061
- "Needs your acknowledgement · ",
1062
- z.length
1063
- ] }),
1064
- z.map((e) => /* @__PURE__ */ t(pe, { children: se(e) }, `pin:${e.id}`))
1053
+ ] }) : /* @__PURE__ */ t(qe, { children: /* @__PURE__ */ n(
1054
+ "div",
1055
+ {
1056
+ ref: pt,
1057
+ className: "mx-8 my-6 divide-y divide-slate-100 overflow-hidden rounded-lg border border-slate-200 bg-white dark:divide-border dark:border-border dark:bg-card",
1058
+ children: [
1059
+ z.length > 0 && /* @__PURE__ */ n("div", { "data-notification-pinned": !0, children: [
1060
+ /* @__PURE__ */ n("div", { className: "bg-amber-50 px-4 py-1 text-[10.5px] font-semibold uppercase tracking-wide text-amber-700 dark:bg-amber-400/10 dark:text-amber-300", children: [
1061
+ "Needs your acknowledgement · ",
1062
+ z.length
1065
1063
  ] }),
1066
- mt.map(yt),
1067
- _e.map((e, a) => {
1068
- const l = (_) => {
1069
- if (!_) return "Older";
1070
- const o = new Date(_), f = /* @__PURE__ */ new Date(), g = new Date(f.getFullYear(), f.getMonth(), f.getDate());
1071
- return o >= g ? "Today" : o >= new Date(g.getTime() - 864e5) ? "Yesterday" : o >= new Date(g.getTime() - 5184e5) ? "This week" : "Older";
1072
- }, s = l(e.created_at), x = a > 0 ? l(_e[a - 1].created_at) : null;
1073
- return /* @__PURE__ */ n(pe, { children: [
1074
- s !== x ? /* @__PURE__ */ t("div", { className: "bg-slate-50/80 px-4 py-1 text-[10.5px] font-semibold uppercase tracking-wide text-slate-400 dark:bg-muted/40", children: s }) : null,
1075
- /* @__PURE__ */ t("div", { "data-live-key": Be(e), children: se(e) })
1076
- ] }, e.id);
1077
- })
1078
- ]
1079
- }
1080
- )
1081
- ] }),
1064
+ z.map((e) => /* @__PURE__ */ t(pe, { children: se(e) }, `pin:${e.id}`))
1065
+ ] }),
1066
+ mt.map(yt),
1067
+ _e.map((e, a) => {
1068
+ const l = (_) => {
1069
+ if (!_) return "Older";
1070
+ const o = new Date(_), f = /* @__PURE__ */ new Date(), g = new Date(f.getFullYear(), f.getMonth(), f.getDate());
1071
+ return o >= g ? "Today" : o >= new Date(g.getTime() - 864e5) ? "Yesterday" : o >= new Date(g.getTime() - 5184e5) ? "This week" : "Older";
1072
+ }, s = l(e.created_at), x = a > 0 ? l(_e[a - 1].created_at) : null;
1073
+ return /* @__PURE__ */ n(pe, { children: [
1074
+ s !== x ? /* @__PURE__ */ t("div", { className: "bg-slate-50/80 px-4 py-1 text-[10.5px] font-semibold uppercase tracking-wide text-slate-400 dark:bg-muted/40", children: s }) : null,
1075
+ /* @__PURE__ */ t("div", { "data-live-key": Be(e), children: se(e) })
1076
+ ] }, e.id);
1077
+ })
1078
+ ]
1079
+ }
1080
+ ) }),
1082
1081
  i !== "sent" && $ > xe && /* @__PURE__ */ n("div", { className: "mx-8 mb-6 flex items-center justify-between", children: [
1083
1082
  /* @__PURE__ */ n("p", { className: "text-[12px] text-slate-400", children: [
1084
1083
  "Page ",