@nivaro/react 0.3.6 → 0.3.8

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.
@@ -8,7 +8,7 @@ import { normalizeReplaySampling as x, replaySampleDraw as Ae, currentReplayRout
8
8
  import { emitReplayTap as Ce, setReplayRecorderMode as N, registerReplayCapture as Ie, clipEndOffset as _e, withClipKind as De } from "../shared/lib/replay-capture.js";
9
9
  import { instrumentConsole as qe, instrumentRequests as Le, redactSecrets as Te } from "../shared/lib/replay-context.js";
10
10
  import { instrumentSocket as Pe } from "../shared/lib/replay-socket.js";
11
- const Ne = "nivaro-react@0.3.6", j = 1e4, Me = 150, Oe = 3e3, Ue = 600, We = (n) => `nvr_replay_resume${n ? `:${n}` : ""}`, G = () => typeof navigator > "u" || navigator.onLine !== !1;
11
+ const Ne = "nivaro-react@0.3.8", j = 1e4, Me = 150, Oe = 3e3, Ue = 600, We = (n) => `nvr_replay_resume${n ? `:${n}` : ""}`, G = () => typeof navigator > "u" || navigator.onLine !== !1;
12
12
  function Fe(n) {
13
13
  return typeof n.url != "string" || typeof fetch != "function" ? null : (f, a) => {
14
14
  const l = typeof n.getToken == "function" ? n.getToken() : void 0, d = { "Content-Type": "application/json" };
package/dist/index.d.ts CHANGED
@@ -2179,10 +2179,12 @@ export declare function DelegationCard({ user, onSaved, forUser, coversFor }: {
2179
2179
  }>;
2180
2180
  }): JSX.Element;
2181
2181
 
2182
- export declare function DelegationConsoleView({ className, onNotice }: DelegationConsoleViewProps): JSX.Element;
2182
+ export declare function DelegationConsoleView({ className, onNotice, compactHeader }: DelegationConsoleViewProps): JSX.Element;
2183
2183
 
2184
2184
  export declare interface DelegationConsoleViewProps {
2185
2185
  className?: string;
2186
+ /** Host already shows the title (a tab of a page): drop the icon and heading. */
2187
+ compactHeader?: boolean;
2186
2188
  /** Host toast hook. */
2187
2189
  onNotice?: (message: string) => void;
2188
2190
  }
@@ -3062,6 +3064,13 @@ export declare const FORCE_RELOAD_EVENT = "nvr:force-refresh";
3062
3064
  *
3063
3065
  * A second push while a countdown is running restarts the clock with the
3064
3066
  * newer duration — the later instruction wins.
3067
+ *
3068
+ * The countdown runs against a wall-clock deadline, not a count of timer
3069
+ * ticks: a background tab's timers wake about once a minute, so counting 15
3070
+ * ticks took 15 minutes there (staging, 2026-10-23 — idle tabs on an old
3071
+ * build never reloaded while the admin watched). A throttled tab reloads at
3072
+ * its first wake past the deadline, and a frozen one the moment it is shown
3073
+ * or focused again.
3065
3074
  */
3066
3075
  export declare function ForceReloadBanner(): JSX.Element | null;
3067
3076
 
@@ -5959,8 +5968,10 @@ declare interface NotificationActionsProps {
5959
5968
  className?: string;
5960
5969
  }
5961
5970
 
5962
- export declare function NotificationAnalyticsView({ className }: {
5971
+ export declare function NotificationAnalyticsView({ className, compactHeader }: {
5963
5972
  className?: string;
5973
+ /** Host already shows the title (a tab of a page): drop the icon and heading. */
5974
+ compactHeader?: boolean;
5964
5975
  }): JSX.Element;
5965
5976
 
5966
5977
  /**
@@ -6171,8 +6182,10 @@ declare interface NotificationSourcesCardProps {
6171
6182
  * admin console page and any headless host. Needs NivaroProvider (+ an
6172
6183
  * optional NavigationContext for the "Manage →" links).
6173
6184
  */
6174
- export declare function NotificationSubscriptionsView({ title }: {
6185
+ export declare function NotificationSubscriptionsView({ title, compactHeader }: {
6175
6186
  title?: string;
6187
+ /** Host already shows the title (a tab of a page): drop the icon and heading. */
6188
+ compactHeader?: boolean;
6176
6189
  }): JSX.Element;
6177
6190
 
6178
6191
  export declare type NotificationTarget = {
@@ -1,39 +1,44 @@
1
- import { jsxs as n, jsx as i } from "react/jsx-runtime";
2
- import { RotateCw as u } from "lucide-react";
3
- import { useState as m, useEffect as l } from "react";
4
- const c = "nvr:force-refresh";
5
- function g() {
6
- const [e, b] = m(null), [a, o] = m(0);
7
- return l(() => {
8
- const r = (t) => {
9
- const s = t.detail ?? {}, d = Math.max(5, Number(s.seconds) || 30);
10
- b({ seconds: d, message: String(s.message ?? "") }), o(d);
1
+ import { jsxs as a, jsx as c } from "react/jsx-runtime";
2
+ import { RotateCw as p } from "lucide-react";
3
+ import { useState as m, useRef as h, useEffect as l } from "react";
4
+ const w = "nvr:force-refresh";
5
+ function E() {
6
+ const [t, u] = m(null), [b, o] = m(() => Date.now()), s = h(!1);
7
+ l(() => {
8
+ const e = (n) => {
9
+ const r = n.detail ?? {}, f = Math.max(5, Number(r.seconds) || 30), d = Date.now();
10
+ u({ deadline: d + f * 1e3, message: String(r.message ?? "") }), o(d);
11
11
  };
12
- return window.addEventListener(c, r), () => window.removeEventListener(c, r);
12
+ return window.addEventListener(w, e), () => window.removeEventListener(w, e);
13
13
  }, []), l(() => {
14
- if (!e) return;
15
- const r = setInterval(() => {
16
- o((t) => t <= 1 ? (window.location.reload(), 0) : t - 1);
17
- }, 1e3);
18
- return () => clearInterval(r);
19
- }, [e]), e ? /* @__PURE__ */ n(
14
+ if (!t) return;
15
+ const e = () => {
16
+ const r = Date.now();
17
+ o(r), r >= t.deadline && !s.current && (s.current = !0, window.location.reload());
18
+ }, n = setInterval(e, 1e3);
19
+ return document.addEventListener("visibilitychange", e), window.addEventListener("focus", e), window.addEventListener("pageshow", e), () => {
20
+ clearInterval(n), document.removeEventListener("visibilitychange", e), window.removeEventListener("focus", e), window.removeEventListener("pageshow", e);
21
+ };
22
+ }, [t]);
23
+ const i = t ? Math.max(0, Math.ceil((t.deadline - b) / 1e3)) : 0;
24
+ return t ? /* @__PURE__ */ a(
20
25
  "div",
21
26
  {
22
27
  role: "alert",
23
- "data-nvr-force-reload": a,
28
+ "data-nvr-force-reload": i,
24
29
  "data-nvr-recording-hide": !0,
25
30
  className: "fixed inset-x-0 top-0 z-[150] flex items-center justify-center gap-3 border-b border-amber-300 bg-amber-50 px-4 py-2.5 text-[13px] text-amber-900 dark:border-amber-500/40 dark:bg-[#3a2e10] dark:text-amber-200",
26
31
  children: [
27
- /* @__PURE__ */ i(u, { className: "h-4 w-4 animate-spin" }),
28
- /* @__PURE__ */ n("span", { children: [
29
- /* @__PURE__ */ n("span", { className: "font-semibold", children: [
32
+ /* @__PURE__ */ c(p, { className: "h-4 w-4 animate-spin" }),
33
+ /* @__PURE__ */ a("span", { children: [
34
+ /* @__PURE__ */ a("span", { className: "font-semibold", children: [
30
35
  "This page will reload in ",
31
- a,
36
+ i,
32
37
  "s"
33
38
  ] }),
34
- e.message ? ` — ${e.message}` : " — an administrator pushed an update."
39
+ t.message ? ` — ${t.message}` : " — an administrator pushed an update."
35
40
  ] }),
36
- /* @__PURE__ */ i(
41
+ /* @__PURE__ */ c(
37
42
  "button",
38
43
  {
39
44
  type: "button",
@@ -47,6 +52,6 @@ function g() {
47
52
  ) : null;
48
53
  }
49
54
  export {
50
- c as FORCE_RELOAD_EVENT,
51
- g as ForceReloadBanner
55
+ w as FORCE_RELOAD_EVENT,
56
+ E as ForceReloadBanner
52
57
  };
@@ -1,13 +1,14 @@
1
- import { jsxs as i, Fragment as H, jsx as t } from "react/jsx-runtime";
2
- import { useQueryClient as M, useQuery as T } from "@tanstack/react-query";
3
- import { ArrowLeft as G, ExternalLink as J } from "lucide-react";
4
- import { useState as U, useCallback as D, useMemo as X, Suspense as R, lazy as q } from "react";
5
- import { useNivaroClient as Y, useItemNavigation as Z, useDrilldownViews as L, DrilldownContext as x } from "../context.js";
6
- import { get as P } from "../lib/commands.js";
7
- import { titleCase as ee } from "../lib/utils.js";
8
- import { DesignCanvas as te } from "./layout-editor/design-canvas.js";
9
- import { Sheet as le, SheetContent as re, SheetHeader as oe, SheetTitle as ne } from "./ui/sheet.js";
10
- const ae = q(() => import("./ItemEditForm.js").then((n) => ({ default: n.ItemEditForm }))), $ = q(
1
+ import { jsxs as a, Fragment as M, jsx as t } from "react/jsx-runtime";
2
+ import { useQueryClient as T, useQuery as G } from "@tanstack/react-query";
3
+ import { ArrowLeft as J, Eye as U, ExternalLink as X } from "lucide-react";
4
+ import { useState as Y, useCallback as R, useMemo as Z, Suspense as $, lazy as j } from "react";
5
+ import { useNivaroClient as L, useItemNavigation as P, useDrilldownViews as ee, DrilldownContext as v } from "../context.js";
6
+ import { get as te } from "../lib/commands.js";
7
+ import { usePresence as le } from "../lib/presence-hooks.js";
8
+ import { titleCase as re } from "../lib/utils.js";
9
+ import { DesignCanvas as oe } from "./layout-editor/design-canvas.js";
10
+ import { Sheet as ne, SheetContent as ae, SheetHeader as ie, SheetTitle as ce } from "./ui/sheet.js";
11
+ const se = j(() => import("./ItemEditForm.js").then((n) => ({ default: n.ItemEditForm }))), q = j(
11
12
  () => import("./RecordReadView.js").then((n) => ({ default: n.RecordReadView }))
12
13
  ), b = /* @__PURE__ */ t("div", { className: "space-y-2 px-4 py-3", children: [0, 1, 2, 3, 4, 5].map((n) => /* @__PURE__ */ t(
13
14
  "div",
@@ -16,34 +17,37 @@ const ae = q(() => import("./ItemEditForm.js").then((n) => ({ default: n.ItemEdi
16
17
  },
17
18
  n
18
19
  )) });
19
- function xe({
20
+ function we({
20
21
  collection: n,
21
- itemId: W,
22
- layoutId: j,
23
- rootLayoutSlug: v,
24
- width: h,
25
- title: E,
26
- stack: f,
27
- onPush: m,
28
- onPop: u,
29
- onClose: F,
22
+ itemId: E,
23
+ layoutId: W,
24
+ rootLayoutSlug: y,
25
+ width: f,
26
+ title: F,
27
+ stack: p,
28
+ onPush: u,
29
+ onPop: h,
30
+ onClose: K,
30
31
  design: l
31
32
  }) {
32
- var S;
33
- const K = M(), O = Y(), { open: Q } = Z(), [_, y] = U([
34
- { collection: n, itemId: W, layoutId: j, width: h, title: E }
35
- ]), c = f != null, a = c && f.length ? f : _, e = l ? a[0] : a[a.length - 1], k = D(
33
+ var D;
34
+ const O = T(), Q = L(), { open: _ } = P(), [A, w] = Y([
35
+ { collection: n, itemId: E, layoutId: W, width: f, title: F }
36
+ ]), s = p != null, i = s && p.length ? p : A, e = l ? i[0] : i[i.length - 1], k = R(
36
37
  (o) => {
37
- c ? m == null || m(o) : y((B) => [...B, o]);
38
+ s ? u == null || u(o) : w((H) => [...H, o]);
38
39
  },
39
- [c, m]
40
- ), w = D(() => {
41
- c ? u == null || u() : y((o) => o.slice(0, -1));
42
- }, [c, u]), p = X(() => l ? null : { open: k }, [l, k]), V = L(), d = l ? null : V[e.collection] ?? null, s = !l && a.length === 1 && !!v, { data: z, isLoading: A } = T({
40
+ [s, u]
41
+ ), g = R(() => {
42
+ s ? h == null || h() : w((o) => o.slice(0, -1));
43
+ }, [s, h]), { viewers: c } = le(
44
+ l ? null : e.collection,
45
+ l ? null : e.itemId
46
+ ), x = Z(() => l ? null : { open: k }, [l, k]), V = ee(), d = l ? null : V[e.collection] ?? null, m = !l && i.length === 1 && !!y, { data: z, isLoading: B } = G({
43
47
  queryKey: ["drilldown-layout", e.collection, e.layoutId ?? null],
44
- enabled: !s && !l,
45
- queryFn: () => O.request(
46
- P(
48
+ enabled: !m && !l,
49
+ queryFn: () => Q.request(
50
+ te(
47
51
  `/collection-layouts/detail/${e.collection}`,
48
52
  e.layoutId ? { layout_id: e.layoutId } : {}
49
53
  )
@@ -51,40 +55,52 @@ function xe({
51
55
  }), r = l ? {
52
56
  ...l.layout,
53
57
  layout: l.layout.layout ?? { id: 0, name: "", slug: null }
54
- } : z, g = s ? v ?? void 0 : (r == null ? void 0 : r.layout.slug) ?? void 0, I = (S = r == null ? void 0 : r.layout) == null ? void 0 : S.sheet_width, N = /* @__PURE__ */ i(H, { children: [
55
- /* @__PURE__ */ i("span", { className: "flex min-w-0 items-center gap-1.5", children: [
56
- a.length > 1 && /* @__PURE__ */ t(
58
+ } : z, N = m ? y ?? void 0 : (r == null ? void 0 : r.layout.slug) ?? void 0, I = (D = r == null ? void 0 : r.layout) == null ? void 0 : D.sheet_width, C = /* @__PURE__ */ a(M, { children: [
59
+ /* @__PURE__ */ a("span", { className: "flex min-w-0 items-center gap-1.5", children: [
60
+ i.length > 1 && /* @__PURE__ */ t(
57
61
  "button",
58
62
  {
59
63
  type: "button",
60
64
  "aria-label": "Back",
61
- onClick: w,
65
+ onClick: g,
62
66
  className: "shrink-0 rounded p-0.5 text-slate-400 hover:bg-slate-100 hover:text-slate-700 dark:hover:bg-slate-800 dark:hover:text-slate-200",
63
- children: /* @__PURE__ */ t(G, { className: "h-4 w-4" })
67
+ children: /* @__PURE__ */ t(J, { className: "h-4 w-4" })
64
68
  }
65
69
  ),
66
- /* @__PURE__ */ i("span", { className: "truncate", children: [
67
- ee(e.collection),
68
- !s && r ? ` · ${r.layout.name}` : ""
70
+ /* @__PURE__ */ a("span", { className: "truncate", children: [
71
+ re(e.collection),
72
+ !m && r ? ` · ${r.layout.name}` : ""
69
73
  ] })
70
74
  ] }),
71
- !l && /* @__PURE__ */ i(
75
+ !l && c.length > 0 && /* @__PURE__ */ a(
76
+ "span",
77
+ {
78
+ className: "ml-auto flex min-w-0 items-center gap-1 text-[11px] font-normal text-slate-500 dark:text-slate-400",
79
+ "data-drill-viewers": c.length,
80
+ "data-tip": `Also viewing: ${c.map((o) => o.name).join(", ")}`,
81
+ children: [
82
+ /* @__PURE__ */ t(U, { className: "h-3 w-3 shrink-0" }),
83
+ /* @__PURE__ */ t("span", { className: "truncate", children: c.length === 1 ? c[0].name : `${c.length} others` })
84
+ ]
85
+ }
86
+ ),
87
+ !l && /* @__PURE__ */ a(
72
88
  "button",
73
89
  {
74
90
  type: "button",
75
- onClick: () => Q({ collection: e.collection, itemId: e.itemId }),
91
+ onClick: () => _({ collection: e.collection, itemId: e.itemId }),
76
92
  className: "flex shrink-0 items-center gap-1 text-[11px] font-normal text-nvr-navy hover:underline dark:text-nvr-cyan",
77
93
  children: [
78
94
  "Open record ",
79
- /* @__PURE__ */ t(J, { className: "h-3 w-3" })
95
+ /* @__PURE__ */ t(X, { className: "h-3 w-3" })
80
96
  ]
81
97
  }
82
98
  )
83
- ] }), C = /* @__PURE__ */ t("div", { className: "nvr-tab-enter flex min-h-0 flex-1 flex-col overflow-hidden", children: d ? /* @__PURE__ */ t(x.Provider, { value: p, children: d.render({ itemId: String(e.itemId) }) }) : A && !s ? b : !s && (r == null ? void 0 : r.layout.display_mode) === "read" ? (
99
+ ] }), S = /* @__PURE__ */ t("div", { className: "nvr-tab-enter flex min-h-0 flex-1 flex-col overflow-hidden", children: d ? /* @__PURE__ */ t(v.Provider, { value: x, children: d.render({ itemId: String(e.itemId) }) }) : B && !m ? b : !m && (r == null ? void 0 : r.layout.display_mode) === "read" ? (
84
100
  // Read-only presentation — definition grids + tabbed child lists,
85
101
  // no form inputs. Editing lives on the full record page.
86
- /* @__PURE__ */ t(x.Provider, { value: p, children: /* @__PURE__ */ t(R, { fallback: b, children: l ? /* @__PURE__ */ t($, { collection: e.collection, design: l }) : /* @__PURE__ */ t(
87
- $,
102
+ /* @__PURE__ */ t(v.Provider, { value: x, children: /* @__PURE__ */ t($, { fallback: b, children: l ? /* @__PURE__ */ t(q, { collection: e.collection, design: l }) : /* @__PURE__ */ t(
103
+ q,
88
104
  {
89
105
  collection: e.collection,
90
106
  itemId: e.itemId,
@@ -92,48 +108,48 @@ function xe({
92
108
  },
93
109
  `${e.collection}:${e.itemId}:read`
94
110
  ) }) })
95
- ) : /* @__PURE__ */ t(x.Provider, { value: p, children: /* @__PURE__ */ t(R, { fallback: b, children: /* @__PURE__ */ t(
96
- ae,
111
+ ) : /* @__PURE__ */ t(v.Provider, { value: x, children: /* @__PURE__ */ t($, { fallback: b, children: /* @__PURE__ */ t(
112
+ se,
97
113
  {
98
114
  collection: e.collection,
99
115
  itemId: e.itemId,
100
- layoutSlug: g,
116
+ layoutSlug: N,
101
117
  onSaved: () => {
102
- K.invalidateQueries({ queryKey: ["queue-items"] });
118
+ O.invalidateQueries({ queryKey: ["queue-items"] });
103
119
  },
104
120
  design: l
105
121
  },
106
- `${e.collection}:${e.itemId}:${g ?? "default"}`
122
+ `${e.collection}:${e.itemId}:${N ?? "default"}`
107
123
  ) }) }) });
108
- return l ? /* @__PURE__ */ t(te, { design: l.context, onRefusedWrite: l.onRefusedWrite, children: /* @__PURE__ */ i(
124
+ return l ? /* @__PURE__ */ t(oe, { design: l.context, onRefusedWrite: l.onRefusedWrite, children: /* @__PURE__ */ a(
109
125
  "div",
110
126
  {
111
127
  "data-design-sheet": !0,
112
128
  className: "flex h-full min-h-0 flex-col gap-0 overflow-hidden rounded-lg border border-slate-200 bg-background shadow-sm dark:border-border",
113
- style: { width: I ?? h ?? 640, maxWidth: "100%" },
129
+ style: { width: I ?? f ?? 640, maxWidth: "100%" },
114
130
  children: [
115
- /* @__PURE__ */ t("div", { className: "flex shrink-0 flex-col border-b border-slate-200 bg-slate-50 px-4 py-2 dark:border-border dark:bg-muted/30", children: /* @__PURE__ */ t("div", { className: "flex items-center justify-between gap-2 text-[12px] font-medium text-slate-500 dark:text-muted-foreground", children: N }) }),
116
- C
131
+ /* @__PURE__ */ t("div", { className: "flex shrink-0 flex-col border-b border-slate-200 bg-slate-50 px-4 py-2 dark:border-border dark:bg-muted/30", children: /* @__PURE__ */ t("div", { className: "flex items-center justify-between gap-2 text-[12px] font-medium text-slate-500 dark:text-muted-foreground", children: C }) }),
132
+ S
117
133
  ]
118
134
  }
119
- ) }) : /* @__PURE__ */ t(le, { open: !0, onOpenChange: (o) => !o && F(), children: /* @__PURE__ */ i(
120
- re,
135
+ ) }) : /* @__PURE__ */ t(ne, { open: !0, onOpenChange: (o) => !o && K(), children: /* @__PURE__ */ a(
136
+ ae,
121
137
  {
122
138
  className: "flex flex-col gap-0 overflow-hidden p-0",
123
139
  style: {
124
- width: (d == null ? void 0 : d.width) ?? e.width ?? I ?? h ?? 640,
140
+ width: (d == null ? void 0 : d.width) ?? e.width ?? I ?? f ?? 640,
125
141
  maxWidth: "96vw"
126
142
  },
127
- onEscapeKeyDown: a.length > 1 ? (o) => {
128
- o.preventDefault(), w();
143
+ onEscapeKeyDown: i.length > 1 ? (o) => {
144
+ o.preventDefault(), g();
129
145
  } : void 0,
130
146
  children: [
131
- /* @__PURE__ */ t(oe, { className: "shrink-0 border-b border-slate-200 bg-slate-50 px-4 py-2 dark:border-border dark:bg-muted/30", children: /* @__PURE__ */ t(ne, { className: "flex items-center justify-between gap-2 pr-6 text-[12px] font-medium text-slate-500 dark:text-muted-foreground", children: N }) }),
132
- C
147
+ /* @__PURE__ */ t(ie, { className: "shrink-0 border-b border-slate-200 bg-slate-50 px-4 py-2 dark:border-border dark:bg-muted/30", children: /* @__PURE__ */ t(ce, { className: "flex items-center justify-between gap-2 pr-6 text-[12px] font-medium text-slate-500 dark:text-muted-foreground", children: C }) }),
148
+ S
133
149
  ]
134
150
  }
135
151
  ) });
136
152
  }
137
153
  export {
138
- xe as RecordDrilldownSheet
154
+ we as RecordDrilldownSheet
139
155
  };
@@ -0,0 +1,37 @@
1
+ import { jsxs as r } from "react/jsx-runtime";
2
+ import { cn as i } from "../lib/utils.js";
3
+ function t(e) {
4
+ const n = `${e.tabs} tab${e.tabs === 1 ? "" : "s"}`;
5
+ return e.reason === "api" ? `${e.app}: loaded before the API update (${n})` : `${e.app}: ${e.build ?? "unknown build"}${e.current_build ? ` — current is ${e.current_build}` : ""} (${n})`;
6
+ }
7
+ function s({
8
+ builds: e,
9
+ className: n
10
+ }) {
11
+ if (!(e != null && e.length)) return null;
12
+ const a = `Needs a reload — running an old version
13
+ ${e.map(t).join(`
14
+ `)}
15
+ Force client refresh → Old versions on /realtime reloads them.`;
16
+ return /* @__PURE__ */ r(
17
+ "span",
18
+ {
19
+ className: i(
20
+ "ml-1.5 rounded-full bg-rose-500/10 px-1.5 py-px text-[10px] font-medium text-rose-700 dark:text-rose-300",
21
+ n
22
+ ),
23
+ "data-stale-build": e.map((o) => o.app).join(","),
24
+ "data-tip": a,
25
+ children: [
26
+ "Old build",
27
+ /* @__PURE__ */ r("span", { className: "sr-only", children: [
28
+ ": needs a reload — ",
29
+ e.map(t).join("; ")
30
+ ] })
31
+ ]
32
+ }
33
+ );
34
+ }
35
+ export {
36
+ s as StaleBuildChip
37
+ };