@nivaro/react 0.3.110 → 0.3.111

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.
@@ -10,7 +10,7 @@ import { noteReplayEvent as Fe, createReplayCheckoutState as Me } from "../share
10
10
  import { emitReplayTap as Ne, setReplayRecorderMode as O, registerReplayCapture as Oe, clipEndOffset as Ue, withClipKind as We } from "../shared/lib/replay-capture.js";
11
11
  import { instrumentConsole as He, instrumentRequests as Ke, redactSecrets as $e } from "../shared/lib/replay-context.js";
12
12
  import { instrumentSocket as Be } from "../shared/lib/replay-socket.js";
13
- const ze = "nivaro-react@0.3.110", Q = 1e4, Ye = 150, xe = 3e3, je = 600, Ge = (o) => `nvr_replay_resume${o ? `:${o}` : ""}`, V = () => typeof navigator > "u" || navigator.onLine !== !1;
13
+ const ze = "nivaro-react@0.3.111", Q = 1e4, Ye = 150, xe = 3e3, je = 600, Ge = (o) => `nvr_replay_resume${o ? `:${o}` : ""}`, V = () => typeof navigator > "u" || navigator.onLine !== !1;
14
14
  function Je(o) {
15
15
  return typeof o.url != "string" || typeof fetch != "function" ? null : (f, u) => {
16
16
  const l = typeof o.getToken == "function" ? o.getToken() : void 0, d = { "Content-Type": "application/json" };
@@ -1,55 +1,62 @@
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);
1
+ import { jsx as L } from "react/jsx-runtime";
2
+ import { useState as g, useRef as y, useEffect as x, useLayoutEffect as E } from "react";
3
+ import { createPortal as M } from "react-dom";
4
+ const a = [], R = '[data-nvr-header-menu-panel], [role="menu"]', b = 6;
5
+ function T() {
6
+ const [e, d] = g(null), [o, f] = g(!1), p = y(null);
7
+ return x(() => (a.push(f), a[0] === f && f(!0), () => {
8
+ var n;
9
+ const s = a.indexOf(f);
10
+ s < 0 || (a.splice(s, 1), s === 0 && ((n = a[0]) == null || n.call(a, !0)));
11
+ }), []), x(() => {
12
+ if (!o) return;
13
+ const s = (i) => {
14
+ var v;
15
+ const t = (v = i == null ? void 0 : i.closest) == null ? void 0 : v.call(i, "[data-tip]"), r = t == null ? void 0 : t.getAttribute("data-tip");
16
+ if (!t || !r || t.getAttribute("aria-expanded") === "true") {
17
+ d((h) => h && null);
18
18
  return;
19
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 }
20
+ const l = t.getBoundingClientRect(), m = t.closest(R);
21
+ if (m && m !== t) {
22
+ const h = m.getBoundingClientRect();
23
+ d({
24
+ x: h.left,
25
+ y: l.top,
26
+ text: r,
27
+ beside: { left: h.left, right: h.right, rowTop: l.top, rowHeight: l.height }
28
28
  });
29
29
  return;
30
30
  }
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);
31
+ d({ x: l.left, y: l.bottom + 4, text: r });
32
+ }, n = (i) => s(i.target), u = () => d(null), c = (i) => {
33
+ var r, l;
34
+ const t = (l = (r = i.target) == null ? void 0 : r.closest) == null ? void 0 : l.call(r, "[data-tip-focus]");
35
+ t && s(t);
36
+ }, w = (i) => {
37
+ var t, r;
38
+ (r = (t = i.target) == null ? void 0 : t.closest) != null && r.call(t, "[data-tip-focus]") && d(null);
35
39
  };
36
- }, [r]), b(() => {
40
+ return window.addEventListener("mouseover", n), window.addEventListener("focusin", c), window.addEventListener("focusout", w), window.addEventListener("pointerdown", u, !0), window.addEventListener("scroll", u, !0), () => {
41
+ window.removeEventListener("mouseover", n), window.removeEventListener("focusin", c), window.removeEventListener("focusout", w), window.removeEventListener("pointerdown", u, !0), window.removeEventListener("scroll", u, !0);
42
+ };
43
+ }, [o]), E(() => {
37
44
  if (!e) return;
38
- const i = f.current;
39
- if (!i) return;
40
- const t = i.getBoundingClientRect();
41
- let { x: l, y: n } = e;
45
+ const s = p.current;
46
+ if (!s) return;
47
+ const n = s.getBoundingClientRect();
48
+ let { x: u, y: c } = e;
42
49
  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));
50
+ const w = e.beside, i = w.left - b - n.width;
51
+ u = i >= 8 ? i : Math.min(w.right + b, Math.max(8, window.innerWidth - n.width - 8)), c = Math.round(w.rowTop + (w.rowHeight - n.height) / 2), c = Math.max(8, Math.min(c, window.innerHeight - n.height - 8));
45
52
  } 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(
53
+ n.right > window.innerWidth - 8 && (u = Math.max(8, window.innerWidth - n.width - 8)), n.bottom > window.innerHeight - 8 && (c = Math.max(8, e.y - n.height - 30));
54
+ (u !== e.x || c !== e.y) && d({ ...e, x: u, y: c });
55
+ }, [e]), !o || !e ? null : M(
56
+ /* @__PURE__ */ L(
50
57
  "div",
51
58
  {
52
- ref: f,
59
+ ref: p,
53
60
  style: { position: "fixed", left: e.x, top: e.y, zIndex: 120 },
54
61
  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",
55
62
  children: e.text
@@ -58,20 +65,20 @@ function A() {
58
65
  document.body
59
66
  );
60
67
  }
61
- function O(e) {
62
- const o = v(null);
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");
68
+ function W(e) {
69
+ const d = y(null);
70
+ return E(() => {
71
+ const o = d.current;
72
+ if (!o) return;
73
+ const f = () => {
74
+ (o.scrollWidth > o.clientWidth + 1 || o.scrollHeight > o.clientHeight + 1) && e ? o.setAttribute("data-tip", e) : o.removeAttribute("data-tip");
68
75
  };
69
- if (u(), typeof ResizeObserver > "u") return;
70
- const f = new ResizeObserver(u);
71
- return f.observe(r), () => f.disconnect();
72
- }, [e]), o;
76
+ if (f(), typeof ResizeObserver > "u") return;
77
+ const p = new ResizeObserver(f);
78
+ return p.observe(o), () => p.disconnect();
79
+ }, [e]), d;
73
80
  }
74
81
  export {
75
- A as TipLayer,
76
- O as useOverflowTip
82
+ T as TipLayer,
83
+ W as useOverflowTip
77
84
  };
@@ -0,0 +1,73 @@
1
+ import { jsx as d, jsxs as c } from "react/jsx-runtime";
2
+ import { Lock as l } from "lucide-react";
3
+ import { forwardRef as u } from "react";
4
+ import { cn as p } from "../../lib/utils.js";
5
+ import { Button as f } from "../ui/button.js";
6
+ function v(t, r) {
7
+ if (!r || r.length === 0) return t;
8
+ const o = new Set(t.map((e) => String(e.id).toUpperCase())), a = r.filter((e) => e.blocked && !o.has(String(e.id).toUpperCase()));
9
+ if (a.length === 0) return t;
10
+ const n = [...t, ...a], s = (e) => typeof e.sort == "number" ? e.sort : Number.POSITIVE_INFINITY;
11
+ return n.map((e, i) => ({ t: e, i })).sort((e, i) => s(e.t) - s(i.t) || e.i - i.i).map(({ t: e }) => e);
12
+ }
13
+ function w(t) {
14
+ var r;
15
+ return !!((r = t.blocked) != null && r.reason);
16
+ }
17
+ function B(t, r) {
18
+ const o = [...new Set(t.map((a) => {
19
+ var n;
20
+ return ((n = a.blocked) == null ? void 0 : n.reason) ?? "";
21
+ }).filter(Boolean))];
22
+ return o.length <= 1 ? o[0] ?? "" : t.map((a, n) => {
23
+ var s;
24
+ return `${r(n)}: ${((s = a.blocked) == null ? void 0 : s.reason) ?? ""}`;
25
+ }).join(`
26
+ `);
27
+ }
28
+ const M = u(function({ label: r, reason: o, code: a, small: n = !1, className: s }, e) {
29
+ return /* @__PURE__ */ c(
30
+ f,
31
+ {
32
+ ref: e,
33
+ type: "button",
34
+ size: "sm",
35
+ variant: "outline",
36
+ "aria-disabled": !0,
37
+ "aria-description": o,
38
+ "data-tip": o,
39
+ "data-tip-focus": !0,
40
+ "data-move-unavailable": a ?? !0,
41
+ onClick: (i) => i.preventDefault(),
42
+ className: p(k, n ? "h-7 text-[11px]" : "text-[12px]", s),
43
+ children: [
44
+ /* @__PURE__ */ d(l, { className: "h-3 w-3", "aria-hidden": !0 }),
45
+ r
46
+ ]
47
+ }
48
+ );
49
+ }), k = "gap-1.5 cursor-not-allowed border-dashed border-slate-300 bg-transparent text-slate-500 shadow-none hover:bg-transparent hover:text-slate-500 active:scale-100 dark:border-slate-600 dark:bg-transparent dark:text-slate-400 dark:hover:bg-transparent dark:hover:text-slate-400 [&_svg]:size-3";
50
+ function S(t) {
51
+ var r;
52
+ return (r = t.blocked) != null && r.reason ? {
53
+ "aria-disabled": !0,
54
+ "aria-description": t.blocked.reason,
55
+ "data-tip": t.blocked.reason,
56
+ "data-tip-focus": !0,
57
+ "data-move-unavailable": t.blocked.code,
58
+ onSelect: (o) => o.preventDefault(),
59
+ className: "cursor-not-allowed text-slate-400 focus:bg-slate-50 focus:text-slate-500 dark:text-slate-500 dark:focus:bg-white/5 dark:focus:text-slate-400"
60
+ } : {};
61
+ }
62
+ function N() {
63
+ return /* @__PURE__ */ d(l, { "aria-hidden": !0, className: "ml-auto h-3 w-3 shrink-0 text-slate-400" });
64
+ }
65
+ export {
66
+ k as BLOCKED_MOVE_CLASS,
67
+ N as BlockedMenuMark,
68
+ M as BlockedMoveButton,
69
+ B as blockedGroupTip,
70
+ S as blockedMenuItemProps,
71
+ w as isBlockedMove,
72
+ v as withBlockedMoves
73
+ };