@nivaro/react 0.3.117 → 0.3.118

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 (137) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +136 -14
  4. package/dist/index.js +488 -485
  5. package/dist/shared/components/ActivityEntry.js +130 -125
  6. package/dist/shared/components/AgentPresenceChip.js +36 -26
  7. package/dist/shared/components/CellCopyLayer.js +50 -45
  8. package/dist/shared/components/CollectionBrowserView.js +3757 -3695
  9. package/dist/shared/components/FilePreviewLightbox.js +96 -58
  10. package/dist/shared/components/InStep.js +18 -17
  11. package/dist/shared/components/ItemEditForm.js +4220 -4175
  12. package/dist/shared/components/JobsTray.js +8 -8
  13. package/dist/shared/components/LiveNewMatchesPill.js +21 -14
  14. package/dist/shared/components/LiveOffNote.js +3 -2
  15. package/dist/shared/components/LiveRowMark.js +53 -23
  16. package/dist/shared/components/LiveTraceView.js +162 -123
  17. package/dist/shared/components/MyWorkView.js +320 -299
  18. package/dist/shared/components/NotificationBell.js +14 -14
  19. package/dist/shared/components/OverflowRail.js +1 -1
  20. package/dist/shared/components/PageRenderer.js +120 -116
  21. package/dist/shared/components/ProfileView.js +203 -202
  22. package/dist/shared/components/RealtimeStatusBanner.js +31 -29
  23. package/dist/shared/components/RecordDrilldownSheet.js +7 -7
  24. package/dist/shared/components/RecordHoverCard.js +102 -84
  25. package/dist/shared/components/RecordReadView.js +146 -146
  26. package/dist/shared/components/ScreenRefreshButton.js +34 -32
  27. package/dist/shared/components/TipLayer.js +65 -58
  28. package/dist/shared/components/WidgetImageMenu.js +83 -43
  29. package/dist/shared/components/activity/RecordActivityStream.js +175 -173
  30. package/dist/shared/components/bulk/BulkSelectionNotices.js +142 -119
  31. package/dist/shared/components/change-proposals/ChangeProposalsPanel.js +158 -143
  32. package/dist/shared/components/change-proposals/ProposeChangeButton.js +17 -11
  33. package/dist/shared/components/change-proposals/ProposeChangeDialog.js +201 -173
  34. package/dist/shared/components/chat/ChatAnalyticsView.js +27 -27
  35. package/dist/shared/components/chat/HuddleAnalyticsTab.js +17 -17
  36. package/dist/shared/components/collections-directory/CollectionsToolbar.js +39 -41
  37. package/dist/shared/components/collections-directory/page-model.js +72 -67
  38. package/dist/shared/components/integrations/RecordIntegrationPreview.js +48 -56
  39. package/dist/shared/components/integrations/SendStatus.js +65 -59
  40. package/dist/shared/components/integrations/console/ReadyToSendView.js +275 -209
  41. package/dist/shared/components/integrations/console/SignalCard.js +237 -230
  42. package/dist/shared/components/item-edit/CatalogPickerField.js +227 -205
  43. package/dist/shared/components/item-edit/ChangedAfterApprovalBadge.js +131 -92
  44. package/dist/shared/components/item-edit/CloneDialog.js +191 -161
  45. package/dist/shared/components/item-edit/DerivedCauseNote.js +44 -30
  46. package/dist/shared/components/item-edit/DraftRecoveryBanner.js +153 -134
  47. package/dist/shared/components/item-edit/FieldComments.js +54 -53
  48. package/dist/shared/components/item-edit/FieldPointer.js +82 -67
  49. package/dist/shared/components/item-edit/FieldRow.js +106 -100
  50. package/dist/shared/components/item-edit/FieldSourceBadge.js +58 -56
  51. package/dist/shared/components/item-edit/FilePickerField.js +452 -387
  52. package/dist/shared/components/item-edit/HeaderSummaryChip.js +78 -56
  53. package/dist/shared/components/item-edit/HeaderTools.js +94 -85
  54. package/dist/shared/components/item-edit/InlineTableField.js +1242 -1218
  55. package/dist/shared/components/item-edit/ListNeighborNav.js +47 -50
  56. package/dist/shared/components/item-edit/LiveTraceSheet.js +15 -10
  57. package/dist/shared/components/item-edit/MembershipSetField.js +285 -254
  58. package/dist/shared/components/item-edit/OutboxReviewTray.js +155 -144
  59. package/dist/shared/components/item-edit/QueueReturnChip.js +15 -36
  60. package/dist/shared/components/item-edit/RecalcValue.js +57 -32
  61. package/dist/shared/components/item-edit/RecordHelpChip.js +21 -22
  62. package/dist/shared/components/item-edit/RecordLiveSync.js +283 -231
  63. package/dist/shared/components/item-edit/RelationCombobox.js +439 -393
  64. package/dist/shared/components/item-edit/RemoteChangeUi.js +292 -224
  65. package/dist/shared/components/item-edit/RemoteUploads.js +26 -20
  66. package/dist/shared/components/item-edit/RemovedLineNote.js +77 -67
  67. package/dist/shared/components/item-edit/RichTextEditorImpl.js +184 -179
  68. package/dist/shared/components/item-edit/ScheduledChangeChip.js +168 -134
  69. package/dist/shared/components/item-edit/SectionPresence.js +18 -10
  70. package/dist/shared/components/item-edit/SplitLinesButton.js +163 -139
  71. package/dist/shared/components/item-edit/UserChip.js +1 -1
  72. package/dist/shared/components/item-edit/file-live.js +69 -54
  73. package/dist/shared/components/item-edit/layout-switch.js +98 -89
  74. package/dist/shared/components/item-edit/partner-needs.js +12 -12
  75. package/dist/shared/components/item-edit/removed-line.js +31 -25
  76. package/dist/shared/components/layout-editor/pickers/field-picker.js +112 -104
  77. package/dist/shared/components/list/ListViewers.js +46 -35
  78. package/dist/shared/components/notifications/NotificationCenterView.js +479 -437
  79. package/dist/shared/components/panels/AccessDeniedPanel.js +176 -101
  80. package/dist/shared/components/panels/AlertBanners.js +82 -72
  81. package/dist/shared/components/panels/BranchLanes.js +22 -22
  82. package/dist/shared/components/panels/CommentImages.js +123 -102
  83. package/dist/shared/components/panels/CommentPanel.js +186 -185
  84. package/dist/shared/components/panels/ExternalRequestsChip.js +111 -119
  85. package/dist/shared/components/panels/OwnerOpenedLine.js +31 -24
  86. package/dist/shared/components/panels/PipelinePanel.js +2037 -1885
  87. package/dist/shared/components/panels/ResubmissionDiff.js +163 -142
  88. package/dist/shared/components/pipeline/OwnerMatrixSheet.js +400 -288
  89. package/dist/shared/components/pipeline/PipelineEditorView.js +7 -2
  90. package/dist/shared/components/profile/AgentNameField.js +107 -81
  91. package/dist/shared/components/profile/AgentsPanel.js +184 -184
  92. package/dist/shared/components/profile/PersonAccess.js +599 -495
  93. package/dist/shared/components/profile/SignInTroubleshooter.js +160 -127
  94. package/dist/shared/components/profile/SignedInDevices.js +17 -17
  95. package/dist/shared/components/profile/primitives.js +1 -1
  96. package/dist/shared/components/queue/OwnerAvatars.js +91 -54
  97. package/dist/shared/components/queue/QueueTeamStrip.js +56 -46
  98. package/dist/shared/components/queue/QueueWorklist.js +1002 -983
  99. package/dist/shared/components/support/AssignRules.js +1733 -0
  100. package/dist/shared/components/support/PersonPick.js +88 -0
  101. package/dist/shared/components/support/RequestList.js +790 -0
  102. package/dist/shared/components/support/ScreenShare.js +158 -152
  103. package/dist/shared/components/support/SupportRequestDialog.js +50 -48
  104. package/dist/shared/components/support/SupportView.js +140 -246
  105. package/dist/shared/components/support/TicketDetailSheet.js +82 -75
  106. package/dist/shared/components/support/TicketSlowScreens.js +9 -9
  107. package/dist/shared/components/support/assign-rules-text.js +171 -0
  108. package/dist/shared/components/support/support-list.js +125 -0
  109. package/dist/shared/components/ui/SimpleSelect.js +28 -20
  110. package/dist/shared/components/ui/checkbox.js +6 -6
  111. package/dist/shared/components/ui/select.js +43 -39
  112. package/dist/shared/components/ui/sheet.js +9 -9
  113. package/dist/shared/components/ui/switch.js +12 -11
  114. package/dist/shared/components/watch-list/WatchDock.js +532 -459
  115. package/dist/shared/components/watch-list/WatchExtras.js +332 -286
  116. package/dist/shared/components/watch-list/WatchRows.js +164 -140
  117. package/dist/shared/lib/activity-sentence.js +103 -91
  118. package/dist/shared/lib/agent-presence.js +27 -21
  119. package/dist/shared/lib/approval-progress.js +2 -2
  120. package/dist/shared/lib/copy-rules.js +31 -24
  121. package/dist/shared/lib/derived-causes.js +113 -78
  122. package/dist/shared/lib/grid-cursors.js +26 -26
  123. package/dist/shared/lib/label-flash.js +27 -0
  124. package/dist/shared/lib/list-return.js +137 -125
  125. package/dist/shared/lib/live-deltas.js +40 -34
  126. package/dist/shared/lib/live-groups.js +56 -52
  127. package/dist/shared/lib/live-preference.js +64 -59
  128. package/dist/shared/lib/live-screen.js +223 -192
  129. package/dist/shared/lib/partner-failure.js +11 -11
  130. package/dist/shared/lib/rollup-recalc.js +68 -64
  131. package/dist/shared/lib/screen-refresh.js +74 -68
  132. package/dist/shared/lib/screen-share.js +108 -104
  133. package/dist/shared/lib/send-status.js +77 -61
  134. package/dist/shared/lib/text-diff-window.js +29 -0
  135. package/dist/shared/lib/watch-list.js +210 -209
  136. package/dist/shared/lib/widget-image-render.js +72 -49
  137. package/package.json +1 -1
@@ -1,75 +1,77 @@
1
- import { jsxs as l, jsx as r } from "react/jsx-runtime";
2
- import { QueryClientContext as p } from "@tanstack/react-query";
3
- import { Check as g, RotateCw as b } from "lucide-react";
4
- import { useContext as x, useEffect as h } from "react";
5
- import { useLivePreference as v } from "../lib/live-preference.js";
6
- import { registerPageRefreshButton as w, usePageRefreshButtonShown as R, useScreenRefreshState as k, refreshScreenData as y, screenRefreshClient as C, setScreenRefreshClient as S } from "../lib/screen-refresh.js";
7
- import { cn as o } from "../lib/utils.js";
1
+ import { jsxs as h, jsx as t } from "react/jsx-runtime";
2
+ import { QueryClientContext as b } from "@tanstack/react-query";
3
+ import { Check as g, RotateCw as x } from "lucide-react";
4
+ import { useContext as v, useEffect as c } from "react";
5
+ import { useLivePreference as w } from "../lib/live-preference.js";
6
+ import { registerPageRefreshButton as k, usePageRefreshButtonShown as R, useScreenRefreshState as y, refreshScreenData as C, screenRefreshClient as N, setScreenRefreshClient as S } from "../lib/screen-refresh.js";
7
+ import { cn as s } from "../lib/utils.js";
8
8
  import { LiveOffNote as u } from "./LiveOffNote.js";
9
9
  function E({
10
10
  variant: e = "header",
11
- className: c
11
+ className: m
12
12
  }) {
13
- const a = x(p);
14
- h(() => {
15
- a && !C() && S(a);
13
+ const a = v(b);
14
+ c(() => {
15
+ a && !N() && S(a);
16
16
  }, [a]);
17
17
  const n = e === "header";
18
- h(() => n ? w() : void 0, [n]);
19
- const m = R(), { phase: t } = k(), i = t === "running", { off: s } = v(), f = s && t !== "running" && t !== "partial" ? "Live updates are off. Refresh this page’s data (keeps your edits and place)" : t === "running" ? "Refreshing this page’s data…" : t === "partial" ? "Some parts of this page did not refresh. Refresh again" : "Refresh this page’s data (keeps your edits and place)";
20
- if (!n && m) return null;
21
- const d = /* @__PURE__ */ l(
18
+ c(() => n ? k() : void 0, [n]);
19
+ const p = R(), { phase: r, failed: i = 0 } = y(), o = r === "running", { off: d } = w(), f = d && r !== "running" && r !== "partial" ? "Live updates are off. Refresh this page’s data (keeps your edits and place)" : r === "running" ? "Refreshing this page’s data…" : r === "partial" ? `${i > 1 ? `${i} parts` : "One part"} of this page did not refresh — ${i > 1 ? "each shows" : "it shows"} its own error. Refresh again` : "Refresh this page’s data (keeps your edits and place)";
20
+ if (!n && p) return null;
21
+ const l = /* @__PURE__ */ h(
22
22
  "button",
23
23
  {
24
24
  type: "button",
25
25
  "aria-label": f,
26
26
  "data-tip": f,
27
- "data-screen-refresh": t,
28
- "aria-busy": i || void 0,
27
+ "data-screen-refresh": r,
28
+ "aria-busy": o || void 0,
29
29
  onClick: () => {
30
- i || y({ reason: "button", qc: a ?? void 0 });
30
+ o || C({ reason: "button", qc: a ?? void 0 });
31
31
  },
32
- className: o(
32
+ className: s(
33
33
  "relative inline-flex shrink-0 items-center justify-center rounded-md transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan",
34
34
  e === "rail" && "h-8 w-8 text-slate-400 hover:bg-white/[0.05] hover:text-white focus-visible:ring-offset-0",
35
- e === "header" && "h-8 w-8 text-slate-400 hover:bg-muted hover:text-slate-700 dark:text-muted-foreground dark:hover:text-foreground",
35
+ // A toolbar control like its bordered neighbours (a bare glyph read as stray), with an
36
+ // invisible 44 px hit area for touch.
37
+ e === "header" && "h-9 w-9 border border-slate-200 bg-white text-slate-500 shadow-sm hover:bg-slate-50 hover:text-slate-800 after:absolute after:-inset-1 after:content-[''] dark:border-border dark:bg-card dark:text-slate-300 dark:hover:bg-muted dark:hover:text-foreground",
36
38
  e === "bar" && "h-8 w-8 opacity-80 hover:opacity-100",
37
- c
39
+ m
38
40
  ),
39
41
  children: [
40
- t === "done" ? /* @__PURE__ */ r(
42
+ r === "done" ? /* @__PURE__ */ t(
41
43
  g,
42
44
  {
43
45
  "aria-hidden": !0,
44
- className: o(
46
+ className: s(
45
47
  "h-[15px] w-[15px] motion-safe:animate-in motion-safe:fade-in",
46
48
  e === "rail" ? "text-emerald-400" : "text-emerald-600 dark:text-emerald-400"
47
49
  )
48
50
  }
49
- ) : /* @__PURE__ */ r(
50
- b,
51
+ ) : /* @__PURE__ */ t(
52
+ x,
51
53
  {
52
54
  "aria-hidden": !0,
53
- className: o(
55
+ className: s(
54
56
  "h-[15px] w-[15px]",
55
- i && "animate-spin [animation-duration:900ms] motion-reduce:animate-none"
57
+ o && "animate-spin [animation-duration:900ms] motion-reduce:animate-none"
56
58
  )
57
59
  }
58
60
  ),
59
- t === "partial" && /* @__PURE__ */ r(
61
+ r === "partial" && /* @__PURE__ */ t(
60
62
  "span",
61
63
  {
62
64
  "aria-hidden": !0,
63
65
  className: "absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-amber-500 dark:bg-amber-400"
64
66
  }
65
67
  ),
66
- e === "rail" && /* @__PURE__ */ r(u, { variant: "dot" })
68
+ e === "rail" && /* @__PURE__ */ t(u, { variant: "dot" })
67
69
  ]
68
70
  }
69
71
  );
70
- return !s || e === "rail" ? d : /* @__PURE__ */ l("span", { className: "inline-flex items-center gap-1.5", children: [
71
- /* @__PURE__ */ r(u, { variant: e === "bar" ? "bar" : "header" }),
72
- d
72
+ return !d || e === "rail" ? l : /* @__PURE__ */ h("span", { className: "inline-flex items-center gap-1.5", children: [
73
+ /* @__PURE__ */ t(u, { variant: e === "bar" ? "bar" : "header" }),
74
+ l
73
75
  ] });
74
76
  }
75
77
  export {
@@ -1,74 +1,81 @@
1
- import { jsx as L } from "react/jsx-runtime";
2
- import { useState as x, useRef as y, useEffect as b, useLayoutEffect as E } from "react";
3
- import { createPortal as M } from "react-dom";
4
- const l = [], O = '[data-nvr-header-menu-panel], [role="menu"], [data-rail-menu]', g = 6;
5
- function W() {
6
- const [t, h] = x(null), [r, a] = x(!1), p = y(null);
7
- return b(() => (l.push(a), l[0] === a && a(!0), () => {
1
+ import { jsx as M } from "react/jsx-runtime";
2
+ import { useState as b, useRef as y, useEffect as x, useLayoutEffect as E } from "react";
3
+ import { createPortal as L } from "react-dom";
4
+ const w = [], O = '[data-nvr-header-menu-panel], [role="menu"], [data-rail-menu]', p = 6;
5
+ function R() {
6
+ const [t, a] = b(null), [u, f] = b(!1), g = y(null);
7
+ return x(() => (w.push(f), w[0] === f && f(!0), () => {
8
8
  var e;
9
- const c = l.indexOf(a);
10
- c < 0 || (l.splice(c, 1), c === 0 && ((e = l[0]) == null || e.call(l, !0)));
11
- }), []), b(() => {
12
- if (!r) return;
13
- const c = (n) => {
9
+ const c = w.indexOf(f);
10
+ c < 0 || (w.splice(c, 1), c === 0 && ((e = w[0]) == null || e.call(w, !0)));
11
+ }), []), x(() => {
12
+ if (!u) return;
13
+ const c = (o) => {
14
14
  var v;
15
- const i = (v = n == null ? void 0 : n.closest) == null ? void 0 : v.call(n, "[data-tip]"), u = i == null ? void 0 : i.getAttribute("data-tip");
16
- if (!i || !u || i.getAttribute("aria-expanded") === "true") {
17
- h((w) => w && null);
15
+ const i = (v = o == null ? void 0 : o.closest) == null ? void 0 : v.call(o, "[data-tip]"), d = i == null ? void 0 : i.getAttribute("data-tip");
16
+ if (!i || !d || i.getAttribute("aria-expanded") === "true") {
17
+ a((l) => l && null);
18
18
  return;
19
19
  }
20
- const o = i.getBoundingClientRect(), m = i.closest(O);
20
+ const n = i.getBoundingClientRect(), m = i.closest(O);
21
21
  if (m && m !== i) {
22
- const w = m.getBoundingClientRect();
23
- h({
24
- x: w.left,
25
- y: o.top,
26
- text: u,
27
- beside: { left: w.left, right: w.right, rowTop: o.top, rowHeight: o.height }
22
+ const l = m.getBoundingClientRect();
23
+ a({
24
+ x: l.left,
25
+ y: n.top,
26
+ text: d,
27
+ beside: { left: l.left, right: l.right, rowTop: n.top, rowHeight: n.height }
28
28
  });
29
29
  return;
30
30
  }
31
31
  if (i.getAttribute("data-tip-side") === "right") {
32
- h({
33
- x: o.right + g,
34
- y: o.top,
35
- text: u,
36
- rightOf: { left: o.left, right: o.right, top: o.top, height: o.height }
32
+ a({
33
+ x: n.right + p,
34
+ y: n.top,
35
+ text: d,
36
+ rightOf: { left: n.left, right: n.right, top: n.top, height: n.height }
37
37
  });
38
38
  return;
39
39
  }
40
- h({ x: o.left, y: o.bottom + 4, text: u });
41
- }, e = (n) => c(n.target), f = () => h(null), s = (n) => {
42
- var u, o;
43
- const i = (o = (u = n.target) == null ? void 0 : u.closest) == null ? void 0 : o.call(u, "[data-tip-focus]");
40
+ if (i.getAttribute("data-tip-side") === "top") {
41
+ a({ x: n.left, y: n.top, text: d, above: { top: n.top, bottom: n.bottom } });
42
+ return;
43
+ }
44
+ a({ x: n.left, y: n.bottom + 4, text: d });
45
+ }, e = (o) => c(o.target), h = () => a(null), s = (o) => {
46
+ var d, n;
47
+ const i = (n = (d = o.target) == null ? void 0 : d.closest) == null ? void 0 : n.call(d, "[data-tip-focus]");
44
48
  i && c(i);
45
- }, d = (n) => {
46
- var i, u;
47
- (u = (i = n.target) == null ? void 0 : i.closest) != null && u.call(i, "[data-tip-focus]") && h(null);
49
+ }, r = (o) => {
50
+ var i, d;
51
+ (d = (i = o.target) == null ? void 0 : i.closest) != null && d.call(i, "[data-tip-focus]") && a(null);
48
52
  };
49
- return window.addEventListener("mouseover", e), window.addEventListener("focusin", s), window.addEventListener("focusout", d), window.addEventListener("pointerdown", f, !0), window.addEventListener("scroll", f, !0), () => {
50
- window.removeEventListener("mouseover", e), window.removeEventListener("focusin", s), window.removeEventListener("focusout", d), window.removeEventListener("pointerdown", f, !0), window.removeEventListener("scroll", f, !0);
53
+ return window.addEventListener("mouseover", e), window.addEventListener("focusin", s), window.addEventListener("focusout", r), window.addEventListener("pointerdown", h, !0), window.addEventListener("scroll", h, !0), () => {
54
+ window.removeEventListener("mouseover", e), window.removeEventListener("focusin", s), window.removeEventListener("focusout", r), window.removeEventListener("pointerdown", h, !0), window.removeEventListener("scroll", h, !0);
51
55
  };
52
- }, [r]), E(() => {
56
+ }, [u]), E(() => {
53
57
  if (!t) return;
54
- const c = p.current;
58
+ const c = g.current;
55
59
  if (!c) return;
56
60
  const e = c.getBoundingClientRect();
57
- let { x: f, y: s } = t;
61
+ let { x: h, y: s } = t;
58
62
  if (t.rightOf) {
59
- const d = t.rightOf, n = d.right + g;
60
- f = n + e.width <= window.innerWidth - 8 ? n : Math.max(8, d.left - g - e.width), s = Math.round(d.top + (d.height - e.height) / 2), s = Math.max(8, Math.min(s, window.innerHeight - e.height - 8));
63
+ const r = t.rightOf, o = r.right + p;
64
+ h = o + e.width <= window.innerWidth - 8 ? o : Math.max(8, r.left - p - e.width), s = Math.round(r.top + (r.height - e.height) / 2), s = Math.max(8, Math.min(s, window.innerHeight - e.height - 8));
61
65
  } else if (t.beside) {
62
- const d = t.beside, n = d.left - g - e.width;
63
- f = n >= 8 ? n : Math.min(d.right + g, Math.max(8, window.innerWidth - e.width - 8)), s = Math.round(d.rowTop + (d.rowHeight - e.height) / 2), s = Math.max(8, Math.min(s, window.innerHeight - e.height - 8));
66
+ const r = t.beside, o = r.left - p - e.width;
67
+ h = o >= 8 ? o : Math.min(r.right + p, Math.max(8, window.innerWidth - e.width - 8)), s = Math.round(r.rowTop + (r.rowHeight - e.height) / 2), s = Math.max(8, Math.min(s, window.innerHeight - e.height - 8));
68
+ } else if (t.above) {
69
+ const r = t.above.top - p - e.height;
70
+ s = r >= 8 ? r : t.above.bottom + 4, h + e.width > window.innerWidth - 8 && (h = Math.max(8, window.innerWidth - e.width - 8));
64
71
  } else
65
- e.right > window.innerWidth - 8 && (f = Math.max(8, window.innerWidth - e.width - 8)), e.bottom > window.innerHeight - 8 && (s = Math.max(8, t.y - e.height - 30));
66
- (f !== t.x || s !== t.y) && h({ ...t, x: f, y: s });
67
- }, [t]), !r || !t ? null : M(
68
- /* @__PURE__ */ L(
72
+ e.right > window.innerWidth - 8 && (h = Math.max(8, window.innerWidth - e.width - 8)), e.bottom > window.innerHeight - 8 && (s = Math.max(8, t.y - e.height - 30));
73
+ (h !== t.x || s !== t.y) && a({ ...t, x: h, y: s });
74
+ }, [t]), !u || !t ? null : L(
75
+ /* @__PURE__ */ M(
69
76
  "div",
70
77
  {
71
- ref: p,
78
+ ref: g,
72
79
  style: { position: "fixed", left: t.x, top: t.y, zIndex: 120 },
73
80
  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",
74
81
  children: t.text
@@ -78,19 +85,19 @@ function W() {
78
85
  );
79
86
  }
80
87
  function T(t) {
81
- const h = y(null);
88
+ const a = y(null);
82
89
  return E(() => {
83
- const r = h.current;
84
- if (!r) return;
85
- const a = () => {
86
- (r.scrollWidth > r.clientWidth + 1 || r.scrollHeight > r.clientHeight + 1) && t ? r.setAttribute("data-tip", t) : r.removeAttribute("data-tip");
90
+ const u = a.current;
91
+ if (!u) return;
92
+ const f = () => {
93
+ (u.scrollWidth > u.clientWidth + 1 || u.scrollHeight > u.clientHeight + 1) && t ? u.setAttribute("data-tip", t) : u.removeAttribute("data-tip");
87
94
  };
88
- if (a(), typeof ResizeObserver > "u") return;
89
- const p = new ResizeObserver(a);
90
- return p.observe(r), () => p.disconnect();
91
- }, [t]), h;
95
+ if (f(), typeof ResizeObserver > "u") return;
96
+ const g = new ResizeObserver(f);
97
+ return g.observe(u), () => g.disconnect();
98
+ }, [t]), a;
92
99
  }
93
100
  export {
94
- W as TipLayer,
101
+ R as TipLayer,
95
102
  T as useOverflowTip
96
103
  };
@@ -1,59 +1,99 @@
1
- import { jsxs as o, jsx as t } from "react/jsx-runtime";
2
- import { Loader2 as x, MoreHorizontal as N, ImageIcon as I, Download as C } from "lucide-react";
3
- import { useState as D, useRef as M } from "react";
4
- import { toast as n } from "sonner";
5
- import { toastError as f } from "../lib/error-toast.js";
6
- import { cn as k } from "../lib/utils.js";
7
- import { widgetImageFileName as S, buildWidgetImageLabel as T } from "../lib/widget-image.js";
8
- import { WIDGET_IMAGE_IGNORE_ATTR as W, renderWidgetImage as E, copyPngOrSave as G, downloadBlob as j } from "../lib/widget-image-render.js";
9
- import { DropdownMenu as L, DropdownMenuTrigger as P, DropdownMenuContent as R, DropdownMenuItem as h } from "./ui/dropdown-menu.js";
10
- function J({
11
- getTarget: g,
12
- label: a,
13
- className: w,
14
- align: y = "end"
1
+ import { jsxs as r, jsx as t } from "react/jsx-runtime";
2
+ import { Loader2 as b, MoreHorizontal as S, ImageIcon as W, Download as R } from "lucide-react";
3
+ import { useState as x, useRef as A } from "react";
4
+ import { toast as c } from "sonner";
5
+ import { toastError as y } from "../lib/error-toast.js";
6
+ import { cn as E } from "../lib/utils.js";
7
+ import { widgetImageFileName as G, buildWidgetImageLabel as L } from "../lib/widget-image.js";
8
+ import { WIDGET_IMAGE_IGNORE_ATTR as v, renderWidgetImage as T, copyPngOrSave as j, downloadBlob as O } from "../lib/widget-image-render.js";
9
+ import { DropdownMenu as P, DropdownMenuTrigger as _, DropdownMenuContent as B, DropdownMenuItem as N } from "./ui/dropdown-menu.js";
10
+ function V({
11
+ getTarget: a,
12
+ label: o,
13
+ className: n,
14
+ align: I = "end",
15
+ loading: k
15
16
  }) {
16
- const [i, s] = D(!1), r = M(!1), b = () => T(typeof a == "function" ? a() : a), c = (v) => {
17
- const l = g();
18
- if (!l || r.current) return;
19
- r.current = !0, s(!0);
20
- const d = b(), u = S(d.title), m = E(l, d), p = () => {
21
- r.current = !1, s(!1);
17
+ const [u, p] = x(!1), [C, D] = x(!1), s = A(!1), i = k || C, M = () => L(typeof o == "function" ? o() : o), m = (d) => {
18
+ const f = a();
19
+ if (!f || s.current) return;
20
+ s.current = !0, p(!0);
21
+ const h = M(), l = G(h.title), g = T(f, h), w = () => {
22
+ s.current = !1, p(!1);
22
23
  };
23
- v === "copy" ? G(m, u).then((e) => {
24
- e === "copied" ? n.success("Copied the picture. Paste it into an email or Teams.") : n.info("Your browser would not copy a picture, so it was saved as a file.");
25
- }).catch((e) => f(e, "Could not make the picture.")).finally(p) : m.then((e) => {
26
- j(e, u), n.success("Saved the picture.");
27
- }).catch((e) => f(e, "Could not make the picture.")).finally(p);
24
+ d === "copy" ? j(g, l).then((e) => {
25
+ e === "copied" ? c.success("Copied the picture. Paste it into an email or Teams.") : c.info(`Your browser would not copy a picture, so it was saved as ${l}.`);
26
+ }).catch((e) => y(e, "Could not make the picture.")).finally(w) : g.then((e) => {
27
+ O(e, l), c.success("Saved the picture.");
28
+ }).catch((e) => y(e, "Could not make the picture.")).finally(w);
28
29
  };
29
- return /* @__PURE__ */ o(L, { children: [
30
- /* @__PURE__ */ t(P, { asChild: !0, children: /* @__PURE__ */ t(
30
+ return /* @__PURE__ */ r(P, { onOpenChange: (d) => d && D($(a())), children: [
31
+ /* @__PURE__ */ t(_, { asChild: !0, children: /* @__PURE__ */ t(
31
32
  "button",
32
33
  {
33
34
  type: "button",
34
- [W]: "",
35
+ [v]: "",
35
36
  "aria-label": "Widget options",
36
37
  "data-tip": "Copy or save as a picture",
37
- disabled: i,
38
- className: k(
39
- "inline-flex h-6 w-6 items-center justify-center rounded text-slate-400 transition-colors hover:bg-slate-100 hover:text-slate-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan disabled:opacity-60 dark:text-slate-500 dark:hover:bg-white/[0.06] dark:hover:text-slate-200",
40
- w
38
+ disabled: u,
39
+ className: E(
40
+ // The hit area reaches past the 24 px glyph box (finger-sized on a phone) without
41
+ // changing its look.
42
+ "relative inline-flex h-6 w-6 items-center before:absolute before:-inset-1 justify-center rounded text-slate-400 transition-colors hover:bg-slate-100 hover:text-slate-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan disabled:opacity-60 data-[state=open]:bg-slate-100 data-[state=open]:text-slate-700 dark:text-slate-500 dark:hover:bg-white/[0.06] dark:hover:text-slate-200 dark:data-[state=open]:bg-white/[0.08] dark:data-[state=open]:text-slate-200",
43
+ n
41
44
  ),
42
- children: i ? /* @__PURE__ */ t(x, { className: "h-3.5 w-3.5 animate-spin", "aria-hidden": !0 }) : /* @__PURE__ */ t(N, { className: "h-3.5 w-3.5", "aria-hidden": !0 })
45
+ children: u ? /* @__PURE__ */ t(b, { className: "h-3.5 w-3.5 animate-spin", "aria-hidden": !0 }) : /* @__PURE__ */ t(S, { className: "h-3.5 w-3.5", "aria-hidden": !0 })
43
46
  }
44
47
  ) }),
45
- /* @__PURE__ */ o(R, { align: y, className: "min-w-[170px]", children: [
46
- /* @__PURE__ */ o(h, { onSelect: () => c("copy"), className: "gap-2 text-[12.5px]", children: [
47
- /* @__PURE__ */ t(I, { className: "h-3.5 w-3.5", "aria-hidden": !0 }),
48
- "Copy as image"
49
- ] }),
50
- /* @__PURE__ */ o(h, { onSelect: () => c("download"), className: "gap-2 text-[12.5px]", children: [
51
- /* @__PURE__ */ t(C, { className: "h-3.5 w-3.5", "aria-hidden": !0 }),
52
- "Download PNG"
53
- ] })
48
+ /* @__PURE__ */ r(B, { align: I, className: "min-w-[170px]", children: [
49
+ /* @__PURE__ */ r(
50
+ N,
51
+ {
52
+ disabled: i,
53
+ onSelect: () => m("copy"),
54
+ className: "gap-2 text-[12.5px]",
55
+ children: [
56
+ /* @__PURE__ */ t(W, { className: "h-3.5 w-3.5", "aria-hidden": !0 }),
57
+ "Copy as image"
58
+ ]
59
+ }
60
+ ),
61
+ /* @__PURE__ */ r(
62
+ N,
63
+ {
64
+ disabled: i,
65
+ onSelect: () => m("download"),
66
+ className: "gap-2 text-[12.5px]",
67
+ children: [
68
+ /* @__PURE__ */ t(R, { className: "h-3.5 w-3.5", "aria-hidden": !0 }),
69
+ "Download PNG"
70
+ ]
71
+ }
72
+ ),
73
+ i && /* @__PURE__ */ r(
74
+ "p",
75
+ {
76
+ className: "flex items-center gap-1.5 px-2 pb-1 pt-1.5 text-[11.5px] text-muted-foreground",
77
+ "data-widget-image-wait": !0,
78
+ children: [
79
+ /* @__PURE__ */ t(b, { className: "h-3 w-3 animate-spin", "aria-hidden": !0 }),
80
+ "Wait for the widget to load"
81
+ ]
82
+ }
83
+ )
54
84
  ] })
55
85
  ] });
56
86
  }
87
+ function $(a) {
88
+ if (!a) return !1;
89
+ const o = a.querySelectorAll(
90
+ '[aria-busy="true"], .animate-spin, .animate-pulse'
91
+ );
92
+ for (const n of Array.from(o))
93
+ if (!n.closest(`[${v}]`)) return !0;
94
+ return !1;
95
+ }
57
96
  export {
58
- J as WidgetImageMenu
97
+ V as WidgetImageMenu,
98
+ $ as widgetIsLoading
59
99
  };