@nivaro/react 0.3.114 → 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.
Files changed (293) hide show
  1. package/dist/components/ScreenShareHost.js +24 -0
  2. package/dist/full.css +50 -2
  3. package/dist/hooks/useSessionRecorder.js +61 -60
  4. package/dist/index.d.ts +1728 -22
  5. package/dist/index.js +1091 -950
  6. package/dist/shared/components/ActivityEntry.js +209 -97
  7. package/dist/shared/components/AgentPresenceChip.js +51 -0
  8. package/dist/shared/components/AnnouncementBanner.js +56 -41
  9. package/dist/shared/components/AutolinkedText.js +98 -85
  10. package/dist/shared/components/BroadcastView.js +149 -141
  11. package/dist/shared/components/CacheStamp.js +78 -30
  12. package/dist/shared/components/CollectionBrowserView.js +4909 -4182
  13. package/dist/shared/components/ConfigChangeStrip.js +63 -0
  14. package/dist/shared/components/ConfigReachNote.js +107 -0
  15. package/dist/shared/components/ConformanceView.js +389 -319
  16. package/dist/shared/components/DataTable.js +612 -551
  17. package/dist/shared/components/DelegateCoverLine.js +164 -0
  18. package/dist/shared/components/EnvironmentNotice.js +56 -65
  19. package/dist/shared/components/FilePreviewLightbox.js +89 -43
  20. package/dist/shared/components/FindingFixedMark.js +23 -0
  21. package/dist/shared/components/GridPresenceLine.js +100 -0
  22. package/dist/shared/components/IdleReloadWatcher.js +82 -43
  23. package/dist/shared/components/InStep.js +46 -0
  24. package/dist/shared/components/ItemEditForm.js +5504 -4889
  25. package/dist/shared/components/LiveAnnouncer.js +62 -0
  26. package/dist/shared/components/LiveCount.js +54 -0
  27. package/dist/shared/components/LiveFigure.js +28 -0
  28. package/dist/shared/components/LiveListControls.js +114 -0
  29. package/dist/shared/components/LiveNewMatchesPill.js +25 -0
  30. package/dist/shared/components/LiveOffNote.js +44 -0
  31. package/dist/shared/components/LivePreferenceHost.js +42 -0
  32. package/dist/shared/components/LiveRowMark.js +25 -20
  33. package/dist/shared/components/LiveTraceView.js +257 -0
  34. package/dist/shared/components/MapView.js +30 -29
  35. package/dist/shared/components/MatrixEditor.js +497 -462
  36. package/dist/shared/components/MyWorkView.js +346 -272
  37. package/dist/shared/components/NotificationBell.js +215 -201
  38. package/dist/shared/components/OverflowRail.js +326 -0
  39. package/dist/shared/components/PageRenderer.js +636 -599
  40. package/dist/shared/components/PresenceDot.js +21 -0
  41. package/dist/shared/components/ProfileView.js +656 -536
  42. package/dist/shared/components/RealtimeStatusBanner.js +25 -25
  43. package/dist/shared/components/RecentRecordsRail.js +51 -48
  44. package/dist/shared/components/RecordCompare.js +241 -150
  45. package/dist/shared/components/RecordDrilldownSheet.js +66 -64
  46. package/dist/shared/components/RecordGridEditor.js +350 -311
  47. package/dist/shared/components/RecordHoverCard.js +147 -0
  48. package/dist/shared/components/RecordPeekHost.js +111 -0
  49. package/dist/shared/components/RecordReadView.js +414 -412
  50. package/dist/shared/components/RelativeTime.js +16 -0
  51. package/dist/shared/components/ReportView.js +1396 -1304
  52. package/dist/shared/components/ScreenRefreshButton.js +77 -0
  53. package/dist/shared/components/TabCountHost.js +10 -0
  54. package/dist/shared/components/TickerNumber.js +19 -18
  55. package/dist/shared/components/TipLayer.js +70 -58
  56. package/dist/shared/components/WidgetImageMenu.js +59 -0
  57. package/dist/shared/components/WidgetSlot.js +571 -524
  58. package/dist/shared/components/activity/RecordActivityStream.js +317 -0
  59. package/dist/shared/components/bulk/BulkSelectionNotices.js +220 -0
  60. package/dist/shared/components/cbv/approval-changed.js +20 -0
  61. package/dist/shared/components/cbv/changed-by-others.js +251 -0
  62. package/dist/shared/components/change-proposals/ChangeProposalsPanel.js +320 -0
  63. package/dist/shared/components/change-proposals/ProposalValue.js +28 -0
  64. package/dist/shared/components/change-proposals/ProposeChangeButton.js +44 -0
  65. package/dist/shared/components/change-proposals/ProposeChangeDialog.js +359 -0
  66. package/dist/shared/components/change-proposals/types.js +4 -0
  67. package/dist/shared/components/chat/ChatPanel.js +1571 -1528
  68. package/dist/shared/components/chat/Composer.js +276 -298
  69. package/dist/shared/components/chat/room-due.js +13 -0
  70. package/dist/shared/components/collections-directory/CollectionRow.js +76 -75
  71. package/dist/shared/components/collections-directory/CollectionsDirectory.js +415 -395
  72. package/dist/shared/components/collections-directory/directory-data.js +75 -63
  73. package/dist/shared/components/imports/ImportConsole.js +159 -155
  74. package/dist/shared/components/imports/ImportDuplicatesNotice.js +46 -31
  75. package/dist/shared/components/integrations/SendStatus.js +202 -0
  76. package/dist/shared/components/integrations/console/IntegrationsConsole.js +45 -36
  77. package/dist/shared/components/integrations/console/ReadyToSendView.js +453 -0
  78. package/dist/shared/components/integrations/console/SignalCard.js +84 -77
  79. package/dist/shared/components/integrations/console/api.js +161 -117
  80. package/dist/shared/components/integrations/console/tone.js +15 -12
  81. package/dist/shared/components/item-edit/CatalogPickerField.js +1353 -1245
  82. package/dist/shared/components/item-edit/ChangedAfterApprovalBadge.js +162 -0
  83. package/dist/shared/components/item-edit/CloneDialog.js +208 -206
  84. package/dist/shared/components/item-edit/DerivedCauseNote.js +57 -0
  85. package/dist/shared/components/item-edit/DraftRecoveryBanner.js +81 -70
  86. package/dist/shared/components/item-edit/DuplicateNotice.js +169 -101
  87. package/dist/shared/components/item-edit/FieldAffordances.js +294 -385
  88. package/dist/shared/components/item-edit/FieldComments.js +159 -116
  89. package/dist/shared/components/item-edit/FieldPointer.js +132 -0
  90. package/dist/shared/components/item-edit/FieldRenderer.js +277 -273
  91. package/dist/shared/components/item-edit/FieldRow.js +519 -439
  92. package/dist/shared/components/item-edit/FieldSourceBadge.js +88 -0
  93. package/dist/shared/components/item-edit/FilePickerField.js +454 -369
  94. package/dist/shared/components/item-edit/GroupSection.js +618 -567
  95. package/dist/shared/components/item-edit/HeldEditsChip.js +113 -0
  96. package/dist/shared/components/item-edit/InlineTableField.js +2891 -2723
  97. package/dist/shared/components/item-edit/ListNeighborNav.js +79 -0
  98. package/dist/shared/components/item-edit/LiveTraceSheet.js +26 -0
  99. package/dist/shared/components/item-edit/M2MCombobox.js +284 -273
  100. package/dist/shared/components/item-edit/OutboxReviewTray.js +313 -0
  101. package/dist/shared/components/item-edit/PickerBadges.js +52 -0
  102. package/dist/shared/components/item-edit/PlanGrid.js +434 -439
  103. package/dist/shared/components/item-edit/RecalcValue.js +55 -0
  104. package/dist/shared/components/item-edit/RecordChatActions.js +76 -64
  105. package/dist/shared/components/item-edit/RecordChatMentionsChip.js +103 -0
  106. package/dist/shared/components/item-edit/RecordGrantTools.js +87 -86
  107. package/dist/shared/components/item-edit/RecordHelpChip.js +70 -0
  108. package/dist/shared/components/item-edit/RecordLiveSync.js +230 -217
  109. package/dist/shared/components/item-edit/RecordOutbox.js +53 -52
  110. package/dist/shared/components/item-edit/RecordRecapStrip.js +109 -36
  111. package/dist/shared/components/item-edit/RelationCombobox.js +229 -217
  112. package/dist/shared/components/item-edit/RelationGroupedCombobox.js +105 -100
  113. package/dist/shared/components/item-edit/RemoteChangeUi.js +454 -0
  114. package/dist/shared/components/item-edit/RemoteUploads.js +55 -0
  115. package/dist/shared/components/item-edit/RemovedLineNote.js +92 -0
  116. package/dist/shared/components/item-edit/RichTextEditorImpl.js +298 -223
  117. package/dist/shared/components/item-edit/ScheduledChangeChip.js +244 -0
  118. package/dist/shared/components/item-edit/SectionPresence.js +78 -0
  119. package/dist/shared/components/item-edit/SplitLinesButton.js +166 -0
  120. package/dist/shared/components/item-edit/catalog-line-watch.js +94 -0
  121. package/dist/shared/components/item-edit/coedit/collab.js +84 -0
  122. package/dist/shared/components/item-edit/coedit/context.js +24 -0
  123. package/dist/shared/components/item-edit/coedit/cursors.js +103 -0
  124. package/dist/shared/components/item-edit/coedit/safe-link.js +15 -0
  125. package/dist/shared/components/item-edit/coedit/session.js +382 -0
  126. package/dist/shared/components/item-edit/coedit/useCoedit.js +49 -0
  127. package/dist/shared/components/item-edit/file-live.js +77 -0
  128. package/dist/shared/components/item-edit/file-processing.js +87 -0
  129. package/dist/shared/components/item-edit/layout-switch.js +148 -0
  130. package/dist/shared/components/item-edit/live-related.js +23 -0
  131. package/dist/shared/components/item-edit/live-title.js +66 -0
  132. package/dist/shared/components/item-edit/partner-needs.js +142 -0
  133. package/dist/shared/components/item-edit/removed-line.js +58 -0
  134. package/dist/shared/components/item-edit/render-stability.js +70 -59
  135. package/dist/shared/components/layout-editor/ChangeNote.js +36 -34
  136. package/dist/shared/components/layout-editor/CollabParts.js +72 -70
  137. package/dist/shared/components/layout-editor/LayoutEditor.js +306 -303
  138. package/dist/shared/components/list/InlineEdit.js +504 -208
  139. package/dist/shared/components/list/ListViewers.js +81 -0
  140. package/dist/shared/components/list/PhonePager.js +50 -0
  141. package/dist/shared/components/merge/MergeRecordsDialog.js +1227 -0
  142. package/dist/shared/components/merge/MergeWithFlow.js +290 -0
  143. package/dist/shared/components/merge/merge-values.js +110 -0
  144. package/dist/shared/components/monitoring/InactiveUserLinksView.js +285 -258
  145. package/dist/shared/components/notifications/NotificationCenterView.js +389 -323
  146. package/dist/shared/components/notifications/NotificationDetailBits.js +205 -130
  147. package/dist/shared/components/notifications/NotificationRulesEditor.js +72 -52
  148. package/dist/shared/components/notifications/bundles.js +21 -19
  149. package/dist/shared/components/notifications/resolved-line.js +25 -0
  150. package/dist/shared/components/ops/OpsTasksView.js +45 -44
  151. package/dist/shared/components/panels/AccessGrantedNote.js +85 -0
  152. package/dist/shared/components/panels/AlertBanners.js +132 -0
  153. package/dist/shared/components/panels/AsyncUserPicker.js +54 -45
  154. package/dist/shared/components/panels/BranchLanes.js +82 -54
  155. package/dist/shared/components/panels/CommentAwareness.js +332 -0
  156. package/dist/shared/components/panels/CommentImages.js +219 -0
  157. package/dist/shared/components/panels/CommentPanel.js +649 -530
  158. package/dist/shared/components/panels/ExternalRequestsChip.js +98 -80
  159. package/dist/shared/components/panels/NewSinceChip.js +16 -0
  160. package/dist/shared/components/panels/OwnerOpenedLine.js +85 -0
  161. package/dist/shared/components/panels/PipelinePanel.js +1644 -1494
  162. package/dist/shared/components/panels/ResubmissionDiff.js +293 -0
  163. package/dist/shared/components/panels/SlaBreachBanner.js +30 -29
  164. package/dist/shared/components/panels/SlaClock.js +130 -99
  165. package/dist/shared/components/panels/TaskPanel.js +308 -287
  166. package/dist/shared/components/panels/unseen-move-check.js +101 -0
  167. package/dist/shared/components/pipeline/OwnerMatrix.js +80 -71
  168. package/dist/shared/components/pipeline/OwnerMatrixSheet.js +495 -0
  169. package/dist/shared/components/pipeline/PipelineEditorView.js +2050 -1942
  170. package/dist/shared/components/profile/AgentNameField.js +141 -0
  171. package/dist/shared/components/profile/AgentsPanel.js +55 -46
  172. package/dist/shared/components/profile/PersonAccess.js +398 -330
  173. package/dist/shared/components/profile/PersonAdminTools.js +127 -113
  174. package/dist/shared/components/profile/PersonProfile.js +81 -73
  175. package/dist/shared/components/profile/SignInTroubleshooter.js +361 -0
  176. package/dist/shared/components/queue/OwnerAvatars.js +9 -9
  177. package/dist/shared/components/queue/QueueBulkBar.js +101 -84
  178. package/dist/shared/components/queue/QueueItemSheet.js +66 -66
  179. package/dist/shared/components/queue/QueueTeamStrip.js +279 -0
  180. package/dist/shared/components/queue/QueueWorklist.js +2407 -1950
  181. package/dist/shared/components/queue/worklist-helpers.js +10 -6
  182. package/dist/shared/components/send-view/SendViewButton.js +136 -0
  183. package/dist/shared/components/send-view/SentViewCards.js +147 -0
  184. package/dist/shared/components/support/ReportProblem.js +1 -0
  185. package/dist/shared/components/support/ScreenShare.js +554 -0
  186. package/dist/shared/components/support/SupportView.js +160 -129
  187. package/dist/shared/components/support/TicketDetailSheet.js +101 -89
  188. package/dist/shared/components/ui/popover.js +53 -29
  189. package/dist/shared/components/watch-list/WatchDock.js +1044 -0
  190. package/dist/shared/components/watch-list/WatchExtras.js +723 -0
  191. package/dist/shared/components/watch-list/WatchListButton.js +46 -0
  192. package/dist/shared/components/watch-list/WatchPinButton.js +67 -0
  193. package/dist/shared/components/watch-list/WatchRows.js +348 -0
  194. package/dist/shared/lib/activity-sentence.js +87 -75
  195. package/dist/shared/lib/agent-presence.js +46 -0
  196. package/dist/shared/lib/approval-progress.js +49 -0
  197. package/dist/shared/lib/attention-prefs.js +27 -0
  198. package/dist/shared/lib/cell-locks.js +56 -0
  199. package/dist/shared/lib/co-edit.js +166 -0
  200. package/dist/shared/lib/coedit-registry.js +44 -0
  201. package/dist/shared/lib/comment-awareness.js +124 -0
  202. package/dist/shared/lib/comment-images.js +45 -0
  203. package/dist/shared/lib/config-watch.js +94 -0
  204. package/dist/shared/lib/copy-rules.js +65 -0
  205. package/dist/shared/lib/count-step.js +30 -0
  206. package/dist/shared/lib/deadline-ticker.js +68 -0
  207. package/dist/shared/lib/derived-causes.js +115 -0
  208. package/dist/shared/lib/draft-store.js +114 -85
  209. package/dist/shared/lib/error-hints.js +1 -0
  210. package/dist/shared/lib/field-merge.js +126 -0
  211. package/dist/shared/lib/filter-sentence.js +10 -10
  212. package/dist/shared/lib/focus-mode.js +16 -12
  213. package/dist/shared/lib/grid-cursors.js +77 -0
  214. package/dist/shared/lib/grid-presence.js +182 -0
  215. package/dist/shared/lib/idle-reload.js +100 -73
  216. package/dist/shared/lib/in-step.js +45 -0
  217. package/dist/shared/lib/integration-chip.js +19 -18
  218. package/dist/shared/lib/keep-row-focus.js +43 -0
  219. package/dist/shared/lib/line-locks.js +141 -0
  220. package/dist/shared/lib/line-split.js +41 -0
  221. package/dist/shared/lib/linked-changes.js +150 -0
  222. package/dist/shared/lib/list-return.js +231 -0
  223. package/dist/shared/lib/list-viewers.js +52 -0
  224. package/dist/shared/lib/live-announcer.js +86 -0
  225. package/dist/shared/lib/live-counts.js +85 -0
  226. package/dist/shared/lib/live-data-changed.js +108 -0
  227. package/dist/shared/lib/live-deltas.js +81 -0
  228. package/dist/shared/lib/live-findings.js +113 -0
  229. package/dist/shared/lib/live-groups.js +122 -0
  230. package/dist/shared/lib/live-link-labels.js +162 -0
  231. package/dist/shared/lib/live-list-flow.js +334 -0
  232. package/dist/shared/lib/live-list.js +143 -129
  233. package/dist/shared/lib/live-moves.js +51 -0
  234. package/dist/shared/lib/live-ops.js +26 -26
  235. package/dist/shared/lib/live-pickers.js +7 -0
  236. package/dist/shared/lib/live-preference.js +184 -0
  237. package/dist/shared/lib/live-queries.js +226 -181
  238. package/dist/shared/lib/live-screen.js +333 -0
  239. package/dist/shared/lib/live-search.js +108 -0
  240. package/dist/shared/lib/live-seen.js +35 -0
  241. package/dist/shared/lib/live-views.js +100 -0
  242. package/dist/shared/lib/live.js +159 -133
  243. package/dist/shared/lib/missed-updates.js +198 -0
  244. package/dist/shared/lib/newer-file.js +56 -0
  245. package/dist/shared/lib/notification-sound.js +42 -20
  246. package/dist/shared/lib/obligation-banner.js +17 -17
  247. package/dist/shared/lib/own-writes.js +59 -41
  248. package/dist/shared/lib/picker-badges.js +94 -0
  249. package/dist/shared/lib/presence-signals.js +131 -84
  250. package/dist/shared/lib/rail-menu-context.js +9 -0
  251. package/dist/shared/lib/realtime.js +49 -24
  252. package/dist/shared/lib/record-gaps.js +85 -0
  253. package/dist/shared/lib/record-outbox.js +369 -222
  254. package/dist/shared/lib/record-peek.js +75 -0
  255. package/dist/shared/lib/record-tabs.js +92 -72
  256. package/dist/shared/lib/relative-ticker.js +42 -0
  257. package/dist/shared/lib/request-gate.js +119 -119
  258. package/dist/shared/lib/rollup-recalc.js +107 -0
  259. package/dist/shared/lib/room-gaps.js +40 -36
  260. package/dist/shared/lib/row-surface.js +7 -0
  261. package/dist/shared/lib/rum.js +137 -87
  262. package/dist/shared/lib/save-progress.js +20 -0
  263. package/dist/shared/lib/scheduled-countdown.js +67 -0
  264. package/dist/shared/lib/screen-refresh.js +160 -0
  265. package/dist/shared/lib/screen-share.js +234 -0
  266. package/dist/shared/lib/seen-since.js +74 -0
  267. package/dist/shared/lib/selection-watch.js +205 -0
  268. package/dist/shared/lib/send-status.js +132 -0
  269. package/dist/shared/lib/send-view.js +23 -0
  270. package/dist/shared/lib/socket-liveness.js +155 -0
  271. package/dist/shared/lib/socket-realtime.js +168 -140
  272. package/dist/shared/lib/state-census.js +53 -0
  273. package/dist/shared/lib/summary-mode.js +61 -39
  274. package/dist/shared/lib/tab-attention.js +143 -32
  275. package/dist/shared/lib/table-density.js +64 -0
  276. package/dist/shared/lib/table-pins.js +20 -18
  277. package/dist/shared/lib/track-travel.js +40 -0
  278. package/dist/shared/lib/unseen-changes.js +68 -0
  279. package/dist/shared/lib/upload-file.js +62 -0
  280. package/dist/shared/lib/upload-presence.js +127 -0
  281. package/dist/shared/lib/urgent-chime.js +65 -0
  282. package/dist/shared/lib/use-below-md.js +29 -0
  283. package/dist/shared/lib/use-online-users.js +32 -11
  284. package/dist/shared/lib/user-sync.js +155 -39
  285. package/dist/shared/lib/waiting-count.js +44 -0
  286. package/dist/shared/lib/watch-desktop.js +83 -0
  287. package/dist/shared/lib/watch-list.js +447 -0
  288. package/dist/shared/lib/widget-image-render.js +64 -0
  289. package/dist/shared/lib/widget-image.js +111 -0
  290. package/dist/shared/lib/worker-socket.js +130 -104
  291. package/dist/shared/lib/write-to-screen.js +133 -0
  292. package/package.json +1 -1
  293. package/styles.css +49 -1
@@ -0,0 +1,29 @@
1
+ import { useSyncExternalStore as o } from "react";
2
+ const c = "(max-width: 767px)";
3
+ function i() {
4
+ try {
5
+ return typeof window > "u" || !window.matchMedia ? null : window.matchMedia(c);
6
+ } catch {
7
+ return null;
8
+ }
9
+ }
10
+ function s(n) {
11
+ var t;
12
+ const e = i();
13
+ return e ? ((t = e.addEventListener) == null || t.call(e, "change", n), () => {
14
+ var r;
15
+ return (r = e.removeEventListener) == null ? void 0 : r.call(e, "change", n);
16
+ }) : () => {
17
+ };
18
+ }
19
+ const u = () => {
20
+ var n;
21
+ return ((n = i()) == null ? void 0 : n.matches) ?? !1;
22
+ };
23
+ function d() {
24
+ return o(s, u, () => !1);
25
+ }
26
+ export {
27
+ c as BELOW_MD_QUERY,
28
+ d as useBelowMd
29
+ };
@@ -1,19 +1,40 @@
1
- import { readOnlinePresence as l } from "@nivaro/sdk";
2
- import { useQuery as s } from "@tanstack/react-query";
1
+ import { readOnlinePresence as a } from "@nivaro/sdk";
2
+ import { useQuery as c } from "@tanstack/react-query";
3
3
  import { useNivaroClient as u } from "../context.js";
4
- import { usePresenceOnlinePoll as a } from "./presence-live.js";
5
- function y(r = !0) {
6
- const t = u(), n = a(3e4, r), { data: o } = s({
4
+ import { usePresenceOnlinePoll as p } from "./presence-live.js";
5
+ function P(t = !0) {
6
+ const r = u(), o = p(3e4, t), { data: s } = c({
7
7
  queryKey: ["presence-online"],
8
- queryFn: () => t.request(l()),
9
- select: (e) => ((e == null ? void 0 : e.data) ?? []).map((i) => String(i.user_id ?? "").toUpperCase()).filter(Boolean),
10
- enabled: r,
11
- refetchInterval: n,
8
+ queryFn: () => r.request(a()),
9
+ select: (e) => ((e == null ? void 0 : e.data) ?? []).map((n) => String(n.user_id ?? "").toUpperCase()).filter(Boolean),
10
+ enabled: t,
11
+ refetchInterval: o,
12
12
  staleTime: 25e3,
13
13
  retry: !1
14
14
  });
15
- return new Set(o ?? []);
15
+ return new Set(s ?? []);
16
16
  }
17
+ function w(t = !0) {
18
+ const r = u(), o = p(3e4, t), { data: s } = c({
19
+ queryKey: ["presence-online"],
20
+ queryFn: () => r.request(a()),
21
+ select: (e) => {
22
+ const n = /* @__PURE__ */ new Map();
23
+ for (const i of (e == null ? void 0 : e.data) ?? []) {
24
+ const l = String(i.user_id ?? "").toUpperCase();
25
+ l && n.set(l, i.is_idle || i.away ? "idle" : "online");
26
+ }
27
+ return n;
28
+ },
29
+ enabled: t,
30
+ refetchInterval: o,
31
+ staleTime: 25e3,
32
+ retry: !1
33
+ });
34
+ return s ?? f;
35
+ }
36
+ const f = /* @__PURE__ */ new Map();
17
37
  export {
18
- y as useOnlineUsers
38
+ P as useOnlineUsers,
39
+ w as usePresenceStates
19
40
  };
@@ -1,66 +1,182 @@
1
- import { useQueryClient as d } from "@tanstack/react-query";
2
- import { useRef as a, useEffect as y } from "react";
3
- import { useLiveEvent as f } from "./live.js";
4
- const m = "nvr-prefs";
5
- let r = null;
6
- function l(n) {
1
+ import { useQueryClient as g } from "@tanstack/react-query";
2
+ import { useRef as f, useEffect as y } from "react";
3
+ import { useLiveEvent as u } from "./live.js";
4
+ import { forgetSettledReads as w } from "./request-gate.js";
5
+ const S = "nvr-prefs";
6
+ let c = null;
7
+ function p(n) {
7
8
  if (typeof BroadcastChannel > "u") return null;
8
- if (!r)
9
+ if (!c)
9
10
  try {
10
- r = new BroadcastChannel(`${m}:${n}`);
11
+ c = new BroadcastChannel(`${S}:${n}`);
11
12
  } catch {
12
- r = null;
13
+ c = null;
13
14
  }
14
- return r;
15
+ return c;
15
16
  }
16
- let s = "";
17
- function E(n) {
18
- if (n !== s) {
19
- s = n;
17
+ let d = "";
18
+ function k(n) {
19
+ if (n !== d) {
20
+ d = n;
20
21
  try {
21
- r == null || r.close();
22
+ c == null || c.close();
22
23
  } catch {
23
24
  }
24
- r = null;
25
+ c = null;
25
26
  }
26
27
  }
27
- function S(n = []) {
28
- var o;
28
+ function q() {
29
+ return d.endsWith(":as");
30
+ }
31
+ function L(n = []) {
32
+ var t;
29
33
  try {
30
- (o = l(s)) == null || o.postMessage({ keys: n });
34
+ (t = p(d)) == null || t.postMessage({ keys: n });
31
35
  } catch {
32
36
  }
33
37
  }
34
- const v = [["notification-count"], ["notifications"], ["my-work"]], h = [["nvr-chat-rooms"]];
35
- function T(n = {}) {
36
- const o = d(), c = a(n.onPrefsChanged);
37
- c.current = n.onPrefsChanged, f(
38
+ const E = /* @__PURE__ */ new Set([
39
+ "users",
40
+ "people-search",
41
+ "people-cards",
42
+ "task-people",
43
+ "task-people-search",
44
+ "sla-users",
45
+ "sla-user-search",
46
+ "role-users",
47
+ "record-chat-mentions",
48
+ "nvr-chat-directory",
49
+ "nvr-chat-members",
50
+ "nvr-chat-members-page",
51
+ "users-list-for-issues",
52
+ "users-list-for-approvals",
53
+ "presence-visible-people",
54
+ "team-members"
55
+ ]), b = /* @__PURE__ */ new Set([
56
+ "user-card",
57
+ "user-avatar",
58
+ "user-name",
59
+ "user-chip",
60
+ "user",
61
+ "activity-chip-user",
62
+ "nvr-directory-entry",
63
+ "nvr-profile-card"
64
+ ]);
65
+ function C(n, t) {
66
+ const i = n[0];
67
+ if (typeof i != "string") return !1;
68
+ if (E.has(i)) return !0;
69
+ if (!b.has(i)) return !1;
70
+ if (!t) return !0;
71
+ const o = n[1];
72
+ return (typeof o == "string" || typeof o == "number") && t.has(String(o).toUpperCase());
73
+ }
74
+ function m(n, t = 1200) {
75
+ setTimeout(n, Math.floor(Math.random() * t));
76
+ }
77
+ const M = [["notification-count"], ["notifications"], ["my-work"]], T = [["nvr-chat-rooms"], ["nvr-chat-record-room"]], K = {
78
+ "saved-views": [["cbv-views"], ["cbv-view-count"]],
79
+ "saved-searches": [["global-search-saved"]],
80
+ overview: [
81
+ ["overview", "prefs"],
82
+ ["overview", "pinned-widgets"]
83
+ ]
84
+ };
85
+ function P(n = {}) {
86
+ const t = g(), i = f(n.onPrefsChanged);
87
+ i.current = n.onPrefsChanged, u(
38
88
  "read:changed",
39
89
  (e) => {
40
- const t = (e == null ? void 0 : e.kind) === "chat" ? h : v;
41
- for (const i of t) o.invalidateQueries({ queryKey: i });
90
+ const r = (e == null ? void 0 : e.kind) === "chat" ? T : M;
91
+ for (const s of r) t.invalidateQueries({ queryKey: s });
42
92
  },
43
- { includeOwn: !0, debounceMs: 250 }
93
+ // Counts: a burst of reads (mark-all) is one re-read, not one per event.
94
+ { includeOwn: !0, debounceMs: 2e3 }
44
95
  );
45
- const u = a(() => {
96
+ const o = f(() => {
46
97
  });
47
- u.current = () => {
98
+ o.current = () => {
48
99
  var e;
49
- o.invalidateQueries({ queryKey: ["nvr-profile-prefs"] }), o.invalidateQueries({ queryKey: ["presence-online"] }), (e = c.current) == null || e.call(c);
50
- }, f("prefs:changed", () => u.current(), { includeOwn: !0, debounceMs: 250 }), y(() => {
51
- const e = l(s);
100
+ t.invalidateQueries({ queryKey: ["nvr-profile-prefs"] }), t.invalidateQueries({ queryKey: ["presence-online"] }), t.invalidateQueries({ queryKey: ["nvr-nav-favorites"] }), (e = i.current) == null || e.call(i);
101
+ }, u(
102
+ "prefs:changed",
103
+ (e) => {
104
+ const r = Array.isArray(e == null ? void 0 : e.keys) ? e.keys : null;
105
+ r && r.length > 0 && r.every((s) => s === "watch_list") || o.current();
106
+ },
107
+ { includeOwn: !0, debounceMs: 250 }
108
+ ), u(
109
+ "mine:changed",
110
+ (e) => {
111
+ for (const r of K[String(e == null ? void 0 : e.kind)] ?? [])
112
+ t.invalidateQueries({ queryKey: r, refetchType: "active" });
113
+ },
114
+ { includeOwn: !0, debounceMs: 300 }
115
+ ), u(
116
+ "pins:changed",
117
+ () => m(() => void t.invalidateQueries({ queryKey: ["collection-pins"] })),
118
+ { includeOwn: !0, debounceMs: 500 }
119
+ );
120
+ const v = f(n.onAccessChanged);
121
+ v.current = n.onAccessChanged, u(
122
+ "access:changed",
123
+ (e) => {
124
+ e != null && e.perms && m(() => {
125
+ var r;
126
+ w(), (r = v.current ?? i.current) == null || r(), t.invalidateQueries({ refetchType: "active" });
127
+ });
128
+ },
129
+ { includeOwn: !0, debounceMs: 400 }
130
+ );
131
+ const a = f(null);
132
+ u(
133
+ "people:changed",
134
+ (e) => {
135
+ const r = Array.isArray(e == null ? void 0 : e.user_ids) ? e.user_ids.map((l) => String(l).toUpperCase()) : null, s = a.current;
136
+ if (s) {
137
+ if (!r) s.ids = null;
138
+ else if (s.ids) for (const l of r) s.ids.add(l);
139
+ return;
140
+ }
141
+ const h = {
142
+ ids: r ? new Set(r) : null,
143
+ timer: setTimeout(
144
+ () => {
145
+ a.current = null, t.invalidateQueries({
146
+ refetchType: "active",
147
+ predicate: (l) => C(l.queryKey, h.ids)
148
+ });
149
+ },
150
+ 300 + Math.floor(Math.random() * 800)
151
+ )
152
+ };
153
+ a.current = h;
154
+ },
155
+ { includeOwn: !0 }
156
+ ), y(
157
+ () => () => {
158
+ a.current && clearTimeout(a.current.timer);
159
+ },
160
+ []
161
+ ), y(() => {
162
+ const e = p(d);
52
163
  if (!e) return;
53
- let t = null;
54
- const i = () => {
55
- t && clearTimeout(t), t = setTimeout(() => u.current(), 100);
164
+ let r = null;
165
+ const s = () => {
166
+ r && clearTimeout(r), r = setTimeout(() => o.current(), 100);
56
167
  };
57
- return e.addEventListener("message", i), () => {
58
- e.removeEventListener("message", i), t && clearTimeout(t);
168
+ return e.addEventListener("message", s), () => {
169
+ e.removeEventListener("message", s), r && clearTimeout(r);
59
170
  };
60
171
  }, []);
61
172
  }
62
173
  export {
63
- S as announceLocalPrefs,
64
- E as configureUserSync,
65
- T as useUserSync
174
+ K as MINE_KEYS,
175
+ E as PEOPLE_LIST_KEYS,
176
+ b as PERSON_KEYS,
177
+ L as announceLocalPrefs,
178
+ k as configureUserSync,
179
+ C as peopleQueryMatches,
180
+ P as useUserSync,
181
+ q as userSyncScoped
66
182
  };
@@ -0,0 +1,44 @@
1
+ import { useQueryClient as a, useQuery as l } from "@tanstack/react-query";
2
+ import { useRef as c, useEffect as p } from "react";
3
+ import { useOptionalNivaroClient as y } from "../context.js";
4
+ import { get as v } from "./commands.js";
5
+ import { useLiveEvent as w } from "./live.js";
6
+ import { useLiveOps as I } from "./live-ops.js";
7
+ import { useLiveRefetchInterval as k } from "./live-queries.js";
8
+ function q(e) {
9
+ if (!e) return 0;
10
+ let o = 0;
11
+ for (const r of [e.owned, e.approvals, e.questions])
12
+ typeof r == "number" && Number.isFinite(r) && r > 0 && (o += Math.floor(r));
13
+ return o;
14
+ }
15
+ const h = 3e4;
16
+ function Q(e = !0) {
17
+ const o = y(), r = a(), f = k(18e4, { safetyMs: 18e4, enabled: e }), { data: m } = l({
18
+ queryKey: ["my-work"],
19
+ queryFn: () => o.request(v("/my-work")).then((t) => t.data),
20
+ enabled: e && !!o,
21
+ staleTime: 6e4,
22
+ refetchInterval: f,
23
+ refetchIntervalInBackground: !0,
24
+ retry: !1,
25
+ select: (t) => q(t == null ? void 0 : t.counts)
26
+ }), i = c(0), n = c(null), u = () => {
27
+ if (n.current) return;
28
+ const t = () => {
29
+ n.current = null, i.current = Date.now(), r.invalidateQueries({ queryKey: ["my-work"] });
30
+ }, s = i.current + h - Date.now();
31
+ s <= 0 ? t() : n.current = setTimeout(t, s);
32
+ };
33
+ return I("my-work", u, { debounceMs: 1500, enabled: e }), w("notification:new", u, { debounceMs: 1500, enabled: e }), p(
34
+ () => () => {
35
+ n.current && clearTimeout(n.current);
36
+ },
37
+ []
38
+ ), e ? m ?? 0 : 0;
39
+ }
40
+ export {
41
+ h as WAITING_LIVE_GAP_MS,
42
+ Q as useWaitingCount,
43
+ q as waitingCount
44
+ };
@@ -0,0 +1,83 @@
1
+ const d = "nivaro-watch-list", w = 12e4, f = "nvr:watch-desktop:claim";
2
+ function s() {
3
+ return typeof window > "u" || typeof window.Notification > "u" ? "unsupported" : window.Notification.permission;
4
+ }
5
+ async function h() {
6
+ if (s() === "unsupported") return "unsupported";
7
+ try {
8
+ return await window.Notification.requestPermission();
9
+ } catch {
10
+ return s();
11
+ }
12
+ }
13
+ function l() {
14
+ return typeof document > "u" ? !1 : document.visibilityState === "hidden" || !document.hasFocus();
15
+ }
16
+ function p(t, n, e, o) {
17
+ const i = [];
18
+ for (const r of new Set(t)) {
19
+ const c = n[r];
20
+ if (!c) continue;
21
+ const a = new Date(c).getTime();
22
+ if (!Number.isFinite(a) || o - a > 12e4) continue;
23
+ const u = e.get(r);
24
+ u && u >= c || i.push(r);
25
+ }
26
+ return i;
27
+ }
28
+ function g(t, n) {
29
+ if (t.length === 1) {
30
+ const o = n[t[0]];
31
+ return {
32
+ title: "Watch list",
33
+ body: o ? `${o} changed` : "A record you watch changed"
34
+ };
35
+ }
36
+ const e = t.map((o) => n[o]).filter(Boolean);
37
+ return {
38
+ title: "Watch list",
39
+ body: e.length > 0 ? `${t.length} records you watch changed: ${e.slice(0, 2).join(", ")}${t.length > 2 ? "…" : ""}` : `${t.length} records you watch changed`
40
+ };
41
+ }
42
+ function m(t, n = Date.now()) {
43
+ const e = [...t].sort().join("|");
44
+ try {
45
+ const o = window.localStorage.getItem(f);
46
+ if (o) {
47
+ const i = JSON.parse(o);
48
+ if (i.sig === e && typeof i.at == "number" && n - i.at < 8e3) return !1;
49
+ }
50
+ window.localStorage.setItem(f, JSON.stringify({ sig: e, at: n }));
51
+ } catch {
52
+ }
53
+ return !0;
54
+ }
55
+ function S(t, n) {
56
+ if (s() === "granted")
57
+ try {
58
+ const e = new window.Notification(t.title, {
59
+ body: t.body,
60
+ tag: d,
61
+ silent: !1
62
+ });
63
+ e.onclick = () => {
64
+ try {
65
+ window.focus();
66
+ } catch {
67
+ }
68
+ n == null || n(), e.close();
69
+ };
70
+ } catch {
71
+ }
72
+ }
73
+ export {
74
+ w as DESKTOP_FRESH_MS,
75
+ d as DESKTOP_TAG,
76
+ m as claimBurst,
77
+ s as desktopPermission,
78
+ g as desktopText,
79
+ p as keysToNotify,
80
+ l as pageOutOfSight,
81
+ h as requestDesktopPermission,
82
+ S as showDesktop
83
+ };