@nivaro/react 0.3.113 → 0.3.115

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 (285) 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 +1727 -19
  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 +4088 -3592
  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 +544 -504
  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/PageRenderer.js +636 -599
  39. package/dist/shared/components/PresenceDot.js +21 -0
  40. package/dist/shared/components/ProfileView.js +656 -536
  41. package/dist/shared/components/RealtimeStatusBanner.js +25 -25
  42. package/dist/shared/components/RecentRecordsRail.js +51 -48
  43. package/dist/shared/components/RecordCompare.js +241 -150
  44. package/dist/shared/components/RecordDrilldownSheet.js +66 -64
  45. package/dist/shared/components/RecordGridEditor.js +350 -311
  46. package/dist/shared/components/RecordHoverCard.js +147 -0
  47. package/dist/shared/components/RecordPeekHost.js +111 -0
  48. package/dist/shared/components/RecordReadView.js +414 -412
  49. package/dist/shared/components/RelativeTime.js +16 -0
  50. package/dist/shared/components/ReportView.js +1396 -1304
  51. package/dist/shared/components/ScreenRefreshButton.js +77 -0
  52. package/dist/shared/components/TabCountHost.js +10 -0
  53. package/dist/shared/components/TickerNumber.js +19 -18
  54. package/dist/shared/components/TipLayer.js +70 -58
  55. package/dist/shared/components/WidgetImageMenu.js +59 -0
  56. package/dist/shared/components/WidgetSlot.js +571 -524
  57. package/dist/shared/components/activity/RecordActivityStream.js +317 -0
  58. package/dist/shared/components/bulk/BulkSelectionNotices.js +220 -0
  59. package/dist/shared/components/cbv/approval-changed.js +20 -0
  60. package/dist/shared/components/cbv/changed-by-others.js +251 -0
  61. package/dist/shared/components/cbv/column-totals.js +75 -67
  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/api.js +161 -117
  79. package/dist/shared/components/integrations/console/tone.js +15 -12
  80. package/dist/shared/components/item-edit/CatalogPickerField.js +1353 -1245
  81. package/dist/shared/components/item-edit/ChangedAfterApprovalBadge.js +162 -0
  82. package/dist/shared/components/item-edit/CloneDialog.js +208 -206
  83. package/dist/shared/components/item-edit/DerivedCauseNote.js +57 -0
  84. package/dist/shared/components/item-edit/DraftRecoveryBanner.js +81 -70
  85. package/dist/shared/components/item-edit/DuplicateNotice.js +169 -101
  86. package/dist/shared/components/item-edit/FieldAffordances.js +294 -385
  87. package/dist/shared/components/item-edit/FieldComments.js +159 -116
  88. package/dist/shared/components/item-edit/FieldPointer.js +132 -0
  89. package/dist/shared/components/item-edit/FieldRenderer.js +277 -273
  90. package/dist/shared/components/item-edit/FieldRow.js +519 -439
  91. package/dist/shared/components/item-edit/FieldSourceBadge.js +88 -0
  92. package/dist/shared/components/item-edit/FilePickerField.js +454 -369
  93. package/dist/shared/components/item-edit/GroupSection.js +618 -567
  94. package/dist/shared/components/item-edit/HeldEditsChip.js +113 -0
  95. package/dist/shared/components/item-edit/InlineTableField.js +2891 -2723
  96. package/dist/shared/components/item-edit/ListNeighborNav.js +79 -0
  97. package/dist/shared/components/item-edit/LiveTraceSheet.js +26 -0
  98. package/dist/shared/components/item-edit/M2MCombobox.js +284 -273
  99. package/dist/shared/components/item-edit/OutboxReviewTray.js +313 -0
  100. package/dist/shared/components/item-edit/PickerBadges.js +52 -0
  101. package/dist/shared/components/item-edit/PlanGrid.js +434 -439
  102. package/dist/shared/components/item-edit/RecalcValue.js +55 -0
  103. package/dist/shared/components/item-edit/RecordChatActions.js +76 -64
  104. package/dist/shared/components/item-edit/RecordChatMentionsChip.js +103 -0
  105. package/dist/shared/components/item-edit/RecordGrantTools.js +87 -86
  106. package/dist/shared/components/item-edit/RecordHelpChip.js +70 -0
  107. package/dist/shared/components/item-edit/RecordLiveSync.js +230 -217
  108. package/dist/shared/components/item-edit/RecordOutbox.js +53 -52
  109. package/dist/shared/components/item-edit/RecordRecapStrip.js +109 -36
  110. package/dist/shared/components/item-edit/RelationCombobox.js +229 -217
  111. package/dist/shared/components/item-edit/RelationGroupedCombobox.js +105 -100
  112. package/dist/shared/components/item-edit/RemoteChangeUi.js +454 -0
  113. package/dist/shared/components/item-edit/RemoteUploads.js +55 -0
  114. package/dist/shared/components/item-edit/RemovedLineNote.js +92 -0
  115. package/dist/shared/components/item-edit/RichTextEditorImpl.js +298 -223
  116. package/dist/shared/components/item-edit/ScheduledChangeChip.js +244 -0
  117. package/dist/shared/components/item-edit/SectionPresence.js +78 -0
  118. package/dist/shared/components/item-edit/SplitLinesButton.js +166 -0
  119. package/dist/shared/components/item-edit/catalog-line-watch.js +94 -0
  120. package/dist/shared/components/item-edit/coedit/collab.js +84 -0
  121. package/dist/shared/components/item-edit/coedit/context.js +24 -0
  122. package/dist/shared/components/item-edit/coedit/cursors.js +103 -0
  123. package/dist/shared/components/item-edit/coedit/safe-link.js +15 -0
  124. package/dist/shared/components/item-edit/coedit/session.js +382 -0
  125. package/dist/shared/components/item-edit/coedit/useCoedit.js +49 -0
  126. package/dist/shared/components/item-edit/file-live.js +77 -0
  127. package/dist/shared/components/item-edit/file-processing.js +87 -0
  128. package/dist/shared/components/item-edit/layout-switch.js +148 -0
  129. package/dist/shared/components/item-edit/live-related.js +23 -0
  130. package/dist/shared/components/item-edit/live-title.js +66 -0
  131. package/dist/shared/components/item-edit/partner-needs.js +142 -0
  132. package/dist/shared/components/item-edit/removed-line.js +58 -0
  133. package/dist/shared/components/item-edit/render-stability.js +70 -59
  134. package/dist/shared/components/layout-editor/ChangeNote.js +36 -34
  135. package/dist/shared/components/layout-editor/CollabParts.js +72 -70
  136. package/dist/shared/components/layout-editor/LayoutEditor.js +306 -303
  137. package/dist/shared/components/list/InlineEdit.js +504 -208
  138. package/dist/shared/components/list/ListViewers.js +81 -0
  139. package/dist/shared/components/merge/MergeRecordsDialog.js +1227 -0
  140. package/dist/shared/components/merge/MergeWithFlow.js +290 -0
  141. package/dist/shared/components/merge/merge-values.js +110 -0
  142. package/dist/shared/components/monitoring/InactiveUserLinksView.js +285 -258
  143. package/dist/shared/components/notifications/NotificationCenterView.js +388 -321
  144. package/dist/shared/components/notifications/NotificationDetailBits.js +205 -130
  145. package/dist/shared/components/notifications/NotificationRulesEditor.js +72 -52
  146. package/dist/shared/components/notifications/bundles.js +21 -19
  147. package/dist/shared/components/notifications/resolved-line.js +25 -0
  148. package/dist/shared/components/ops/OpsTasksView.js +45 -44
  149. package/dist/shared/components/panels/AccessGrantedNote.js +85 -0
  150. package/dist/shared/components/panels/AlertBanners.js +132 -0
  151. package/dist/shared/components/panels/AsyncUserPicker.js +54 -45
  152. package/dist/shared/components/panels/BranchLanes.js +82 -54
  153. package/dist/shared/components/panels/CommentAwareness.js +332 -0
  154. package/dist/shared/components/panels/CommentImages.js +219 -0
  155. package/dist/shared/components/panels/CommentPanel.js +649 -530
  156. package/dist/shared/components/panels/ExternalRequestsChip.js +98 -80
  157. package/dist/shared/components/panels/NewSinceChip.js +16 -0
  158. package/dist/shared/components/panels/OwnerOpenedLine.js +85 -0
  159. package/dist/shared/components/panels/PipelinePanel.js +1644 -1494
  160. package/dist/shared/components/panels/ResubmissionDiff.js +293 -0
  161. package/dist/shared/components/panels/SlaBreachBanner.js +30 -29
  162. package/dist/shared/components/panels/SlaClock.js +130 -99
  163. package/dist/shared/components/panels/TaskPanel.js +308 -287
  164. package/dist/shared/components/panels/unseen-move-check.js +101 -0
  165. package/dist/shared/components/pipeline/OwnerMatrix.js +80 -71
  166. package/dist/shared/components/pipeline/OwnerMatrixSheet.js +495 -0
  167. package/dist/shared/components/pipeline/PipelineEditorView.js +1855 -1771
  168. package/dist/shared/components/profile/AgentNameField.js +141 -0
  169. package/dist/shared/components/profile/AgentsPanel.js +55 -46
  170. package/dist/shared/components/profile/PersonAccess.js +398 -330
  171. package/dist/shared/components/profile/PersonAdminTools.js +127 -113
  172. package/dist/shared/components/profile/PersonProfile.js +81 -73
  173. package/dist/shared/components/profile/SignInTroubleshooter.js +361 -0
  174. package/dist/shared/components/queue/QueueBulkBar.js +101 -84
  175. package/dist/shared/components/queue/QueueItemSheet.js +66 -66
  176. package/dist/shared/components/queue/QueueTeamStrip.js +279 -0
  177. package/dist/shared/components/queue/QueueWorklist.js +2076 -1686
  178. package/dist/shared/components/queue/queue-totals.js +92 -0
  179. package/dist/shared/components/queue/worklist-helpers.js +18 -14
  180. package/dist/shared/components/send-view/SendViewButton.js +136 -0
  181. package/dist/shared/components/send-view/SentViewCards.js +147 -0
  182. package/dist/shared/components/support/ReportProblem.js +1 -0
  183. package/dist/shared/components/support/ScreenShare.js +554 -0
  184. package/dist/shared/components/support/SupportView.js +160 -129
  185. package/dist/shared/components/support/TicketDetailSheet.js +101 -89
  186. package/dist/shared/components/watch-list/WatchDock.js +1044 -0
  187. package/dist/shared/components/watch-list/WatchExtras.js +723 -0
  188. package/dist/shared/components/watch-list/WatchListButton.js +46 -0
  189. package/dist/shared/components/watch-list/WatchPinButton.js +67 -0
  190. package/dist/shared/components/watch-list/WatchRows.js +348 -0
  191. package/dist/shared/lib/activity-sentence.js +87 -75
  192. package/dist/shared/lib/agent-presence.js +46 -0
  193. package/dist/shared/lib/approval-progress.js +49 -0
  194. package/dist/shared/lib/attention-prefs.js +27 -0
  195. package/dist/shared/lib/cell-locks.js +56 -0
  196. package/dist/shared/lib/co-edit.js +166 -0
  197. package/dist/shared/lib/coedit-registry.js +44 -0
  198. package/dist/shared/lib/comment-awareness.js +124 -0
  199. package/dist/shared/lib/comment-images.js +45 -0
  200. package/dist/shared/lib/config-watch.js +94 -0
  201. package/dist/shared/lib/copy-rules.js +65 -0
  202. package/dist/shared/lib/count-step.js +30 -0
  203. package/dist/shared/lib/deadline-ticker.js +68 -0
  204. package/dist/shared/lib/derived-causes.js +115 -0
  205. package/dist/shared/lib/draft-store.js +114 -85
  206. package/dist/shared/lib/error-hints.js +1 -0
  207. package/dist/shared/lib/field-merge.js +126 -0
  208. package/dist/shared/lib/filter-sentence.js +10 -10
  209. package/dist/shared/lib/focus-mode.js +16 -12
  210. package/dist/shared/lib/grid-cursors.js +77 -0
  211. package/dist/shared/lib/grid-presence.js +182 -0
  212. package/dist/shared/lib/idle-reload.js +100 -73
  213. package/dist/shared/lib/in-step.js +45 -0
  214. package/dist/shared/lib/integration-chip.js +19 -18
  215. package/dist/shared/lib/line-locks.js +141 -0
  216. package/dist/shared/lib/line-split.js +41 -0
  217. package/dist/shared/lib/linked-changes.js +150 -0
  218. package/dist/shared/lib/list-link.js +56 -50
  219. package/dist/shared/lib/list-return.js +231 -0
  220. package/dist/shared/lib/list-viewers.js +52 -0
  221. package/dist/shared/lib/live-announcer.js +86 -0
  222. package/dist/shared/lib/live-counts.js +85 -0
  223. package/dist/shared/lib/live-data-changed.js +108 -0
  224. package/dist/shared/lib/live-deltas.js +81 -0
  225. package/dist/shared/lib/live-findings.js +113 -0
  226. package/dist/shared/lib/live-groups.js +122 -0
  227. package/dist/shared/lib/live-link-labels.js +162 -0
  228. package/dist/shared/lib/live-list-flow.js +334 -0
  229. package/dist/shared/lib/live-list.js +143 -129
  230. package/dist/shared/lib/live-moves.js +51 -0
  231. package/dist/shared/lib/live-ops.js +26 -26
  232. package/dist/shared/lib/live-pickers.js +7 -0
  233. package/dist/shared/lib/live-preference.js +184 -0
  234. package/dist/shared/lib/live-queries.js +226 -181
  235. package/dist/shared/lib/live-screen.js +333 -0
  236. package/dist/shared/lib/live-search.js +108 -0
  237. package/dist/shared/lib/live-seen.js +35 -0
  238. package/dist/shared/lib/live-views.js +100 -0
  239. package/dist/shared/lib/live.js +159 -133
  240. package/dist/shared/lib/missed-updates.js +198 -0
  241. package/dist/shared/lib/newer-file.js +56 -0
  242. package/dist/shared/lib/notification-sound.js +42 -20
  243. package/dist/shared/lib/own-writes.js +59 -41
  244. package/dist/shared/lib/picker-badges.js +94 -0
  245. package/dist/shared/lib/presence-signals.js +131 -84
  246. package/dist/shared/lib/realtime.js +49 -24
  247. package/dist/shared/lib/record-gaps.js +85 -0
  248. package/dist/shared/lib/record-outbox.js +369 -222
  249. package/dist/shared/lib/record-peek.js +75 -0
  250. package/dist/shared/lib/record-tabs.js +92 -72
  251. package/dist/shared/lib/relative-ticker.js +42 -0
  252. package/dist/shared/lib/request-gate.js +119 -119
  253. package/dist/shared/lib/rollup-recalc.js +107 -0
  254. package/dist/shared/lib/room-gaps.js +40 -36
  255. package/dist/shared/lib/rum.js +137 -87
  256. package/dist/shared/lib/save-progress.js +20 -0
  257. package/dist/shared/lib/scheduled-countdown.js +67 -0
  258. package/dist/shared/lib/screen-refresh.js +160 -0
  259. package/dist/shared/lib/screen-share.js +234 -0
  260. package/dist/shared/lib/seen-since.js +74 -0
  261. package/dist/shared/lib/selection-watch.js +205 -0
  262. package/dist/shared/lib/send-status.js +132 -0
  263. package/dist/shared/lib/send-view.js +23 -0
  264. package/dist/shared/lib/socket-liveness.js +155 -0
  265. package/dist/shared/lib/socket-realtime.js +168 -140
  266. package/dist/shared/lib/state-census.js +53 -0
  267. package/dist/shared/lib/summary-mode.js +61 -39
  268. package/dist/shared/lib/tab-attention.js +143 -32
  269. package/dist/shared/lib/table-density.js +64 -0
  270. package/dist/shared/lib/track-travel.js +40 -0
  271. package/dist/shared/lib/unseen-changes.js +68 -0
  272. package/dist/shared/lib/upload-file.js +33 -0
  273. package/dist/shared/lib/upload-presence.js +127 -0
  274. package/dist/shared/lib/urgent-chime.js +65 -0
  275. package/dist/shared/lib/use-online-users.js +32 -11
  276. package/dist/shared/lib/user-sync.js +155 -39
  277. package/dist/shared/lib/waiting-count.js +44 -0
  278. package/dist/shared/lib/watch-desktop.js +83 -0
  279. package/dist/shared/lib/watch-list.js +447 -0
  280. package/dist/shared/lib/widget-image-render.js +64 -0
  281. package/dist/shared/lib/widget-image.js +111 -0
  282. package/dist/shared/lib/worker-socket.js +130 -104
  283. package/dist/shared/lib/write-to-screen.js +133 -0
  284. package/package.json +1 -1
  285. package/styles.css +49 -1
@@ -1,253 +1,341 @@
1
- import { jsx as i, jsxs as c } from "react/jsx-runtime";
2
- import { useQueries as L, useQuery as M } from "@tanstack/react-query";
3
- import { X as A } from "lucide-react";
4
- import { useRef as D, useEffect as K, useState as O } from "react";
5
- import { createPortal as B } from "react-dom";
6
- import { useNivaroClient as I } from "../context.js";
7
- import { get as F, getActiveLayout as Q } from "../lib/commands.js";
8
- import { formSections as X } from "../lib/form-sections.js";
9
- import { friendlyIdOf as J, recordRefLabel as P } from "../lib/record-ref.js";
10
- import { cn as R, titleCase as G } from "../lib/utils.js";
11
- import { Skeleton as _ } from "./ui/skeleton.js";
12
- function H(r) {
13
- if (r == null || r === "") return "";
14
- if (typeof r == "boolean") return r ? "true" : "false";
15
- if (typeof r == "object")
1
+ import { jsx as c, jsxs as p } from "react/jsx-runtime";
2
+ import { useQueries as H, useQuery as I, useQueryClient as ne } from "@tanstack/react-query";
3
+ import { X as oe } from "lucide-react";
4
+ import { useRef as F, useEffect as j, useState as X } from "react";
5
+ import { createPortal as ae } from "react-dom";
6
+ import { useNivaroClient as se } from "../context.js";
7
+ import { get as K, getActiveLayout as le } from "../lib/commands.js";
8
+ import { formSections as ie } from "../lib/form-sections.js";
9
+ import { useLiveAvailable as ce, useLiveRecord as de } from "../lib/live.js";
10
+ import { useLivePreference as ue, liveMotionAllowed as fe } from "../lib/live-preference.js";
11
+ import { friendlyIdOf as me, recordRefLabel as pe } from "../lib/record-ref.js";
12
+ import { cn as J, titleCase as ge } from "../lib/utils.js";
13
+ import { Skeleton as U } from "./ui/skeleton.js";
14
+ function O(t) {
15
+ if (t == null || t === "") return "";
16
+ if (typeof t == "boolean") return t ? "true" : "false";
17
+ if (typeof t == "object")
16
18
  try {
17
- return JSON.stringify(r);
19
+ return JSON.stringify(t);
18
20
  } catch {
19
- return String(r);
21
+ return String(t);
20
22
  }
21
- const a = String(r).trim(), u = Number(a);
22
- return a !== "" && Number.isFinite(u) ? String(Math.round(u * 100) / 100) : a;
23
+ const n = String(t).trim(), o = Number(n);
24
+ return n !== "" && Number.isFinite(o) ? String(Math.round(o * 100) / 100) : n;
23
25
  }
24
- function U(r) {
25
- const { records: a, forms: u, labels: y } = r, g = {
26
+ function be(t) {
27
+ const { records: n, forms: o, labels: i } = t, m = {
26
28
  key: "__fields__",
27
29
  label: "Fields",
28
- fields: r.fallback.map((l) => ({ field: l, label: null }))
29
- }, m = u.map((l) => l ?? [g]), p = [], N = /* @__PURE__ */ new Map(), k = /* @__PURE__ */ new Set(), w = /* @__PURE__ */ new Map();
30
- for (const l of m)
31
- for (const n of l) {
32
- for (const o of n.fields)
33
- o.label && !w.has(o.field) && w.set(o.field, o.label);
34
- const d = n.fields.map((o) => o.field).filter((o) => !k.has(o));
35
- if (!d.length) continue;
36
- for (const o of d) k.add(o);
37
- const b = N.get(n.label);
38
- if (b) b.fields.push(...d);
30
+ fields: t.fallback.map((l) => ({ field: l, label: null }))
31
+ }, f = o.map((l) => l ?? [m]), u = [], w = /* @__PURE__ */ new Map(), S = /* @__PURE__ */ new Set(), N = /* @__PURE__ */ new Map();
32
+ for (const l of f)
33
+ for (const a of l) {
34
+ for (const d of a.fields)
35
+ d.label && !N.has(d.field) && N.set(d.field, d.label);
36
+ const g = a.fields.map((d) => d.field).filter((d) => !S.has(d));
37
+ if (!g.length) continue;
38
+ for (const d of g) S.add(d);
39
+ const h = w.get(a.label);
40
+ if (h) h.fields.push(...g);
39
41
  else {
40
- const o = { key: n.key, label: n.label, fields: d };
41
- N.set(n.label, o), p.push(o);
42
+ const d = { key: a.key, label: a.label, fields: g };
43
+ w.set(a.label, d), u.push(d);
42
44
  }
43
45
  }
44
- const S = m.map((l) => new Set(l.flatMap((n) => n.fields.map((d) => d.field))));
45
- return p.map((l) => ({
46
+ const q = f.map((l) => new Set(l.flatMap((a) => a.fields.map((g) => g.field))));
47
+ return u.map((l) => ({
46
48
  key: l.key,
47
49
  label: l.label,
48
- rows: l.fields.flatMap((n) => {
49
- const d = a.map((f, v) => {
50
- const h = f ? S[v].has(n) ? n in f ? null : "hidden" : "form" : "record";
51
- return { absent: h, value: h || !f ? null : f[n] };
52
- }), b = d.filter((f) => !f.absent);
53
- if (b.length === 0) return [];
54
- const o = b.length > 1 && new Set(b.map((f) => H(f.value))).size > 1;
50
+ rows: l.fields.flatMap((a) => {
51
+ const g = n.map((b, C) => {
52
+ const x = b ? q[C].has(a) ? a in b ? null : "hidden" : "form" : "record";
53
+ return { absent: x, value: x || !b ? null : b[a] };
54
+ }), h = g.filter((b) => !b.absent);
55
+ if (h.length === 0) return [];
56
+ const d = h.length > 1 && new Set(h.map((b) => O(b.value))).size > 1;
55
57
  return [
56
58
  {
57
- field: n,
58
- label: w.get(n) || y[n] || G(n),
59
- cells: d,
60
- differs: o
59
+ field: a,
60
+ label: N.get(a) || i[a] || ge(a),
61
+ cells: g,
62
+ differs: d
61
63
  }
62
64
  ];
63
65
  })
64
66
  })).filter((l) => l.rows.length > 0);
65
67
  }
66
- function V(r, a, u, y, g) {
67
- const m = J(r, a);
68
- if (m) return m;
69
- if (r && a) {
70
- const p = P(r, a, u, y);
71
- if (p && p !== String(u)) return p;
68
+ function he(t, n, o, i, m) {
69
+ const f = me(t, n);
70
+ if (f) return f;
71
+ if (t && n) {
72
+ const u = pe(t, n, o, i);
73
+ if (u && u !== String(o)) return u;
72
74
  }
73
- return `Record ${g + 1}`;
75
+ return `Record ${m + 1}`;
74
76
  }
75
- const W = {
77
+ function ye(t, n) {
78
+ return n.map((o, i) => {
79
+ const m = t[i];
80
+ if (!o || !m) return [];
81
+ const f = [];
82
+ for (const u of Object.keys(o))
83
+ u === "id" || !(u in m) || O(m[u]) !== O(o[u]) && f.push(u);
84
+ return f;
85
+ });
86
+ }
87
+ function xe(t, n) {
88
+ return t.map((o) => ({ ...o, rows: o.rows.filter((i) => i.differs || n.has(i.field)) })).filter((o) => o.rows.length > 0);
89
+ }
90
+ function ve({
91
+ collection: t,
92
+ id: n,
93
+ onChange: o
94
+ }) {
95
+ return de(t, n, (i) => o(String(n), i), {
96
+ debounceMs: 800,
97
+ includeOwn: !0
98
+ }), null;
99
+ }
100
+ function we(t) {
101
+ !t || !(t instanceof HTMLElement) || typeof t.animate != "function" || fe() && t.animate(
102
+ [{ backgroundColor: "rgba(0, 206, 255, 0.18)" }, { backgroundColor: "rgba(0, 206, 255, 0)" }],
103
+ { duration: 1600, easing: "ease-out" }
104
+ );
105
+ }
106
+ function Ne(t, n) {
107
+ const o = /* @__PURE__ */ new Map();
108
+ for (const i of t) o.set(i, (o.get(i) ?? 0) + 1);
109
+ return t.map((i, m) => {
110
+ if ((o.get(i) ?? 0) <= 1) return { primary: i, secondary: null };
111
+ const f = i.replace(/^No .+? number(?: · )?/, "").trim();
112
+ return { primary: `#${n[m]}`, secondary: f || null };
113
+ });
114
+ }
115
+ const ke = {
76
116
  record: "Not available",
77
117
  form: "Not on this form",
78
118
  hidden: "Not visible to you"
79
119
  };
80
- function de({
81
- collection: r,
82
- ids: a,
83
- fields: u,
84
- renderValue: y,
85
- onClose: g
120
+ function Oe({
121
+ collection: t,
122
+ ids: n,
123
+ fields: o,
124
+ renderValue: i,
125
+ onClose: m
86
126
  }) {
87
- const m = I(), p = L({
88
- queries: a.map((e) => ({
89
- queryKey: ["cbv-compare", r, String(e)],
90
- queryFn: () => m.request(F(`/items/${r}/${e}`)).then((t) => t.data ?? null).catch(() => null),
127
+ const f = se(), u = H({
128
+ queries: n.map((e) => ({
129
+ queryKey: ["cbv-compare", t, String(e)],
130
+ queryFn: () => f.request(K(`/items/${t}/${e}`)).then((r) => r.data ?? null).catch(() => null),
91
131
  staleTime: 3e4
92
132
  }))
93
- }), N = L({
94
- queries: a.map((e) => ({
95
- queryKey: ["compare-form", r, String(e)],
96
- queryFn: () => m.request(Q({ collection: r, item: String(e) })).then((t) => t.data ?? null).catch(() => null),
133
+ }), w = H({
134
+ queries: n.map((e) => ({
135
+ queryKey: ["compare-form", t, String(e)],
136
+ queryFn: () => f.request(le({ collection: t, item: String(e) })).then((r) => r.data ?? null).catch(() => null),
97
137
  staleTime: 3e4
98
138
  }))
99
- }), k = M({
100
- queryKey: ["bulk-fields-config", r],
101
- queryFn: () => m.request(
102
- F(`/field-config/${r}`)
139
+ }), S = I({
140
+ queryKey: ["bulk-fields-config", t],
141
+ queryFn: () => f.request(
142
+ K(`/field-config/${t}`)
103
143
  ).then((e) => Array.isArray(e.data) ? e.data : []),
104
144
  staleTime: 6e4
105
- }), w = M({
106
- queryKey: ["cbv-collection-meta", r],
107
- queryFn: () => m.request(F(`/collections/${r}`)).then((e) => e.data ?? null).catch(() => null),
145
+ }), N = I({
146
+ queryKey: ["cbv-collection-meta", t],
147
+ queryFn: () => f.request(K(`/collections/${t}`)).then((e) => e.data ?? null).catch(() => null),
108
148
  staleTime: 10 * 6e4
109
- }), S = D(null);
110
- K(() => {
111
- var t;
149
+ }), q = F(null);
150
+ j(() => {
151
+ var r;
112
152
  const e = document.activeElement;
113
- return (t = S.current) == null || t.focus(), () => {
153
+ return (r = q.current) == null || r.focus(), () => {
114
154
  var s;
115
155
  return (s = e == null ? void 0 : e.focus) == null ? void 0 : s.call(e);
116
156
  };
117
- }, []), K(() => {
118
- const e = (t) => {
119
- t.key === "Escape" && g();
157
+ }, []), j(() => {
158
+ const e = (r) => {
159
+ r.key === "Escape" && m();
120
160
  };
121
161
  return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
122
- }, [g]);
123
- const l = p.some((e) => e.isLoading) || N.some((e) => e.isLoading), n = p.map((e) => e.data ?? null), d = N.map((e) => e.data ?? null), b = {}, o = /* @__PURE__ */ new Map();
124
- for (const e of k.data ?? [])
125
- b[e.field] = e.label, o.set(e.field, e);
126
- const f = (e) => V(w.data ?? null, n[e], a[e], r, e), v = l ? [] : U({
127
- records: n,
128
- forms: d.map(
129
- (e) => e ? X(e.groups ?? [], e.assignments ?? [], {
162
+ }, [m]);
163
+ const l = u.some((e) => e.isLoading) || w.some((e) => e.isLoading), a = u.map((e) => e.data ?? null), g = w.map((e) => e.data ?? null), h = {}, d = /* @__PURE__ */ new Map();
164
+ for (const e of S.data ?? [])
165
+ h[e.field] = e.label, d.set(e.field, e);
166
+ const b = Ne(
167
+ n.map((e, r) => he(N.data ?? null, a[r], e, t, r)),
168
+ n
169
+ ), C = (e) => b[e].primary, x = l ? [] : be({
170
+ records: a,
171
+ forms: g.map(
172
+ (e) => e ? ie(e.groups ?? [], e.assignments ?? [], {
130
173
  ungroupedSort: e.ungrouped_sort
131
174
  }) : null
132
175
  ),
133
- labels: b,
134
- fallback: u.filter((e) => !e.hidden && e.field !== "id").map((e) => e.field)
135
- }), [h, j] = O(!1), q = v.reduce((e, t) => e + t.rows.filter((s) => s.differs).length, 0), C = h ? v.map((e) => ({ ...e, rows: e.rows.filter((t) => t.differs) })).filter((e) => e.rows.length > 0) : v, T = d.map((e) => {
136
- var t;
137
- return ((t = e == null ? void 0 : e.layout) == null ? void 0 : t.name) ?? null;
138
- }), E = new Set(d.map((e) => {
139
- var t;
140
- return ((t = e == null ? void 0 : e.layout) == null ? void 0 : t.id) ?? null;
141
- })).size === 1, $ = { gridTemplateColumns: `minmax(160px, 220px) repeat(${a.length}, minmax(0, 1fr))` };
142
- return B(
176
+ labels: h,
177
+ fallback: o.filter((e) => !e.hidden && e.field !== "id").map((e) => e.field)
178
+ }), [L, G] = X(!1), $ = x.reduce((e, r) => e + r.rows.filter((s) => s.differs).length, 0), T = F(/* @__PURE__ */ new Set()), R = L ? xe(x, T.current) : x;
179
+ if (L) for (const e of R) for (const r of e.rows) T.current.add(r.field);
180
+ else T.current = /* @__PURE__ */ new Set();
181
+ const _ = ne(), V = ce(), W = ue(), Y = V && !W.off, Z = (e, r) => {
182
+ var s;
183
+ r.aspectsOnly && !((s = r.changedFields) != null && s.includes("$state")) || (_.invalidateQueries({ queryKey: ["cbv-compare", t, e] }), (r.changedFields === null || r.changedFields.includes("$state")) && _.invalidateQueries({ queryKey: ["compare-form", t, e] }));
184
+ }, D = F(null), Q = F(null), [ee, te] = X(""), z = u.map((e) => e.dataUpdatedAt).join(",");
185
+ j(() => {
186
+ var k;
187
+ if (l || !z) return;
188
+ const e = Q.current;
189
+ if (Q.current = a, !e) return;
190
+ const r = ye(e, a), s = /* @__PURE__ */ new Map();
191
+ for (const v of ((k = D.current) == null ? void 0 : k.querySelectorAll("[data-compare-row]")) ?? [])
192
+ s.set(v.getAttribute("data-compare-row") ?? "", v);
193
+ r.forEach((v, E) => {
194
+ var P;
195
+ for (const re of v)
196
+ we(((P = s.get(re)) == null ? void 0 : P.querySelector(`[data-compare-cell="${E}"]`)) ?? null);
197
+ });
198
+ const y = r.map((v, E) => v.length ? C(E) : null).filter(Boolean);
199
+ y.length && te(`${y.join(" and ")} changed just now`);
200
+ }, [l, z]);
201
+ const M = g.map((e) => {
202
+ var r;
203
+ return ((r = e == null ? void 0 : e.layout) == null ? void 0 : r.name) ?? null;
204
+ }), B = new Set(g.map((e) => {
205
+ var r;
206
+ return ((r = e == null ? void 0 : e.layout) == null ? void 0 : r.id) ?? null;
207
+ })).size === 1, A = { gridTemplateColumns: `minmax(160px, 220px) repeat(${n.length}, minmax(0, 1fr))` };
208
+ return ae(
143
209
  // biome-ignore lint/a11y/noStaticElementInteractions: backdrop click closes; Escape is the keyboard path
144
- /* @__PURE__ */ i(
210
+ /* @__PURE__ */ c(
145
211
  "div",
146
212
  {
147
213
  className: "fixed inset-0 z-[130] flex items-center justify-center bg-black/40 p-4 sm:p-6",
148
- onMouseDown: (e) => e.target === e.currentTarget && g(),
214
+ onMouseDown: (e) => e.target === e.currentTarget && m(),
149
215
  "data-record-compare": !0,
150
- children: /* @__PURE__ */ c(
216
+ children: /* @__PURE__ */ p(
151
217
  "div",
152
218
  {
153
- ref: S,
219
+ ref: q,
154
220
  role: "dialog",
155
221
  "aria-modal": "true",
156
- "aria-label": `Compare ${a.length} records`,
222
+ "aria-label": `Compare ${n.length} records`,
157
223
  tabIndex: -1,
158
224
  className: "nvr-pop-in flex outline-none max-h-[88vh] w-full max-w-[1100px] flex-col overflow-hidden rounded-lg border border-border bg-card shadow-xl",
159
225
  children: [
160
- /* @__PURE__ */ c("div", { className: "flex shrink-0 flex-wrap items-center gap-x-3 gap-y-1 border-b border-border px-4 py-2.5", children: [
161
- /* @__PURE__ */ c("span", { className: "text-[14px] font-semibold text-foreground", children: [
226
+ /* @__PURE__ */ p("div", { className: "flex shrink-0 flex-wrap items-center gap-x-3 gap-y-1 border-b border-border px-4 py-2.5", children: [
227
+ /* @__PURE__ */ p("span", { className: "text-[14px] font-semibold text-foreground", children: [
162
228
  "Compare ",
163
- a.length,
229
+ n.length,
164
230
  " records"
165
231
  ] }),
166
- !l && /* @__PURE__ */ c("span", { className: "text-[12px] text-muted-foreground", "data-compare-diff-count": q, children: [
167
- q === 0 ? "No differences" : `${q} field${q === 1 ? "" : "s"} differ`,
168
- E && T[0] ? ` · ${T[0]} form` : ""
232
+ !l && /* @__PURE__ */ p("span", { className: "text-[12px] text-muted-foreground", "data-compare-diff-count": $, children: [
233
+ $ === 0 ? "No differences" : $ === 1 ? "1 field differs" : `${$} fields differ`,
234
+ B && M[0] ? ` · ${M[0]} form` : ""
169
235
  ] }),
170
- /* @__PURE__ */ c("label", { className: "ml-auto flex cursor-pointer items-center gap-1.5 text-[12px] text-muted-foreground", children: [
171
- /* @__PURE__ */ i(
236
+ Y && !l && /* @__PURE__ */ p(
237
+ "span",
238
+ {
239
+ className: "inline-flex items-center gap-1 text-[11.5px] text-muted-foreground",
240
+ "data-tip": "Changes to these records show here as they are saved",
241
+ "data-compare-live": !0,
242
+ children: [
243
+ /* @__PURE__ */ c(
244
+ "span",
245
+ {
246
+ className: "h-1.5 w-1.5 rounded-full bg-emerald-500 dark:bg-emerald-400",
247
+ "aria-hidden": !0
248
+ }
249
+ ),
250
+ "Live"
251
+ ]
252
+ }
253
+ ),
254
+ /* @__PURE__ */ c("span", { className: "sr-only", role: "status", "aria-live": "polite", children: ee }),
255
+ n.map((e) => /* @__PURE__ */ c(ve, { collection: t, id: e, onChange: Z }, String(e))),
256
+ /* @__PURE__ */ p("label", { className: "ml-auto flex cursor-pointer items-center gap-1.5 text-[12px] text-muted-foreground", children: [
257
+ /* @__PURE__ */ c(
172
258
  "input",
173
259
  {
174
260
  type: "checkbox",
175
- checked: h,
176
- onChange: (e) => j(e.target.checked),
261
+ checked: L,
262
+ onChange: (e) => G(e.target.checked),
177
263
  className: "h-3.5 w-3.5 accent-[hsl(var(--primary))]"
178
264
  }
179
265
  ),
180
266
  "Differences only"
181
267
  ] }),
182
- /* @__PURE__ */ i(
268
+ /* @__PURE__ */ c(
183
269
  "button",
184
270
  {
185
271
  type: "button",
186
- onClick: g,
272
+ onClick: m,
187
273
  "aria-label": "Close",
188
274
  className: "rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan",
189
- children: /* @__PURE__ */ i(A, { className: "h-4 w-4" })
275
+ children: /* @__PURE__ */ c(oe, { className: "h-4 w-4" })
190
276
  }
191
277
  )
192
278
  ] }),
193
- /* @__PURE__ */ c("div", { className: "min-h-0 flex-1 overflow-auto", children: [
194
- /* @__PURE__ */ c(
279
+ /* @__PURE__ */ p("div", { ref: D, className: "relative min-h-0 flex-1 overflow-auto", children: [
280
+ /* @__PURE__ */ p(
195
281
  "div",
196
282
  {
197
283
  className: "sticky top-0 z-[1] grid border-b border-border bg-slate-50 dark:bg-background",
198
- style: $,
284
+ style: A,
199
285
  children: [
200
- /* @__PURE__ */ i("span", { className: "px-3 py-2 text-[11.5px] font-medium text-muted-foreground", children: "Field" }),
201
- a.map((e, t) => /* @__PURE__ */ c("span", { className: "min-w-0 px-3 py-2", children: [
202
- /* @__PURE__ */ i(
286
+ /* @__PURE__ */ c("span", { className: "px-3 py-2 text-[11.5px] font-medium text-muted-foreground", children: "Field" }),
287
+ n.map((e, r) => /* @__PURE__ */ p("span", { className: "min-w-0 px-3 py-2", children: [
288
+ /* @__PURE__ */ c(
203
289
  "span",
204
290
  {
205
291
  className: "block truncate text-[12px] font-semibold text-foreground",
206
292
  "data-compare-side": !0,
207
- children: f(t)
293
+ children: C(r)
208
294
  }
209
295
  ),
210
- !E && /* @__PURE__ */ i("span", { className: "block truncate text-[11px] text-muted-foreground", children: T[t] ? `${T[t]} form` : "No form" })
296
+ b[r].secondary && /* @__PURE__ */ c("span", { className: "block truncate text-[11px] text-muted-foreground", children: b[r].secondary }),
297
+ !B && /* @__PURE__ */ c("span", { className: "block truncate text-[11px] text-muted-foreground", children: M[r] ? `${M[r]} form` : "No form" })
211
298
  ] }, String(e)))
212
299
  ]
213
300
  }
214
301
  ),
215
- l ? /* @__PURE__ */ i("div", { className: "space-y-2 p-4", "aria-busy": "true", children: [0, 1, 2, 3, 4].map((e) => /* @__PURE__ */ c("div", { className: "grid gap-3", style: $, children: [
216
- /* @__PURE__ */ i(_, { className: "h-4 w-28" }),
217
- a.map((t) => /* @__PURE__ */ i(_, { className: "h-4 w-full" }, String(t)))
218
- ] }, e)) }) : n.every((e) => e == null) ? /* @__PURE__ */ i("p", { className: "px-4 py-8 text-center text-[12.5px] text-muted-foreground", children: "These records could not be opened. They may have been deleted, or you may no longer have access." }) : C.length === 0 ? /* @__PURE__ */ i("p", { className: "px-4 py-8 text-center text-[12.5px] text-muted-foreground", children: h ? "Every field you can see holds the same value." : "Nothing to compare." }) : C.map((e) => {
219
- const t = e.rows.filter((s) => s.differs).length;
220
- return /* @__PURE__ */ c("section", { "data-compare-section": e.key, children: [
221
- /* @__PURE__ */ c("h3", { className: "flex items-baseline gap-2 border-b border-border bg-card px-3 pb-1.5 pt-4 text-[12.5px] font-semibold text-foreground", children: [
302
+ l ? /* @__PURE__ */ c("div", { className: "space-y-2 p-4", "aria-busy": "true", children: [0, 1, 2, 3, 4].map((e) => /* @__PURE__ */ p("div", { className: "grid gap-3", style: A, children: [
303
+ /* @__PURE__ */ c(U, { className: "h-4 w-28" }),
304
+ n.map((r) => /* @__PURE__ */ c(U, { className: "h-4 w-full" }, String(r)))
305
+ ] }, e)) }) : a.every((e) => e == null) ? /* @__PURE__ */ c("p", { className: "px-4 py-8 text-center text-[12.5px] text-muted-foreground", children: "These records could not be opened. They may have been deleted, or you may no longer have access." }) : R.length === 0 ? /* @__PURE__ */ c("p", { className: "px-4 py-8 text-center text-[12.5px] text-muted-foreground", children: L ? "Every field you can see holds the same value." : "Nothing to compare." }) : R.map((e) => {
306
+ const r = e.rows.filter((s) => s.differs).length;
307
+ return /* @__PURE__ */ p("section", { "data-compare-section": e.key, children: [
308
+ /* @__PURE__ */ p("h3", { className: "flex items-baseline gap-2 border-b border-border bg-card px-3 pb-1.5 pt-4 text-[12.5px] font-semibold text-foreground", children: [
222
309
  e.label,
223
- t > 0 && /* @__PURE__ */ c("span", { className: "text-[11.5px] font-normal text-muted-foreground", children: [
224
- t,
310
+ r > 0 && /* @__PURE__ */ p("span", { className: "text-[11.5px] font-normal text-muted-foreground", children: [
311
+ r,
225
312
  " differ",
226
- t === 1 ? "s" : ""
313
+ r === 1 ? "s" : ""
227
314
  ] })
228
315
  ] }),
229
- e.rows.map((s) => /* @__PURE__ */ c(
316
+ e.rows.map((s) => /* @__PURE__ */ p(
230
317
  "div",
231
318
  {
232
319
  "data-compare-row": s.field,
233
320
  "data-differs": s.differs ? "" : void 0,
234
- className: R(
321
+ className: J(
235
322
  "grid border-b border-slate-100 text-[12.5px] dark:border-border/60",
236
323
  s.differs && "bg-amber-50 dark:bg-amber-400/10"
237
324
  ),
238
- style: $,
325
+ style: A,
239
326
  children: [
240
- /* @__PURE__ */ i("span", { className: "min-w-0 px-3 py-1.5 text-muted-foreground", children: s.label }),
241
- s.cells.map((x, z) => /* @__PURE__ */ i(
327
+ /* @__PURE__ */ c("span", { className: "min-w-0 px-3 py-1.5 text-muted-foreground", children: s.label }),
328
+ s.cells.map((y, k) => /* @__PURE__ */ c(
242
329
  "span",
243
330
  {
244
- className: R(
331
+ "data-compare-cell": k,
332
+ className: J(
245
333
  "min-w-0 break-words px-3 py-1.5 tabular-nums",
246
- x.absent ? "text-[11.5px] italic text-muted-foreground" : s.differs ? "font-medium text-foreground" : "text-slate-600 dark:text-slate-300"
334
+ y.absent ? "text-[11.5px] italic text-muted-foreground" : s.differs ? "font-medium text-foreground" : "text-slate-600 dark:text-slate-300"
247
335
  ),
248
- children: x.absent ? W[x.absent] : x.value == null || x.value === "" ? /* @__PURE__ */ i("span", { className: "text-muted-foreground", children: "—" }) : y(s.field, x.value, o.get(s.field))
336
+ children: y.absent ? ke[y.absent] : y.value == null || y.value === "" ? /* @__PURE__ */ c("span", { className: "text-muted-foreground", children: "—" }) : i(s.field, y.value, d.get(s.field))
249
337
  },
250
- z
338
+ String(n[k])
251
339
  ))
252
340
  ]
253
341
  },
@@ -265,8 +353,11 @@ function de({
265
353
  );
266
354
  }
267
355
  export {
268
- de as RecordCompareDialog,
269
- U as buildCompare,
270
- H as compareKey,
271
- V as compareSideName
356
+ Oe as RecordCompareDialog,
357
+ be as buildCompare,
358
+ ye as changedCompareCells,
359
+ O as compareKey,
360
+ Ne as compareSideHeads,
361
+ he as compareSideName,
362
+ xe as stickyDiffRows
272
363
  };