@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.
- package/dist/components/ScreenShareHost.js +24 -0
- package/dist/full.css +50 -2
- package/dist/hooks/useSessionRecorder.js +61 -60
- package/dist/index.d.ts +1727 -19
- package/dist/index.js +1091 -950
- package/dist/shared/components/ActivityEntry.js +209 -97
- package/dist/shared/components/AgentPresenceChip.js +51 -0
- package/dist/shared/components/AnnouncementBanner.js +56 -41
- package/dist/shared/components/AutolinkedText.js +98 -85
- package/dist/shared/components/BroadcastView.js +149 -141
- package/dist/shared/components/CacheStamp.js +78 -30
- package/dist/shared/components/CollectionBrowserView.js +4088 -3592
- package/dist/shared/components/ConfigChangeStrip.js +63 -0
- package/dist/shared/components/ConfigReachNote.js +107 -0
- package/dist/shared/components/ConformanceView.js +389 -319
- package/dist/shared/components/DataTable.js +544 -504
- package/dist/shared/components/DelegateCoverLine.js +164 -0
- package/dist/shared/components/EnvironmentNotice.js +56 -65
- package/dist/shared/components/FilePreviewLightbox.js +89 -43
- package/dist/shared/components/FindingFixedMark.js +23 -0
- package/dist/shared/components/GridPresenceLine.js +100 -0
- package/dist/shared/components/IdleReloadWatcher.js +82 -43
- package/dist/shared/components/InStep.js +46 -0
- package/dist/shared/components/ItemEditForm.js +5504 -4889
- package/dist/shared/components/LiveAnnouncer.js +62 -0
- package/dist/shared/components/LiveCount.js +54 -0
- package/dist/shared/components/LiveFigure.js +28 -0
- package/dist/shared/components/LiveListControls.js +114 -0
- package/dist/shared/components/LiveNewMatchesPill.js +25 -0
- package/dist/shared/components/LiveOffNote.js +44 -0
- package/dist/shared/components/LivePreferenceHost.js +42 -0
- package/dist/shared/components/LiveRowMark.js +25 -20
- package/dist/shared/components/LiveTraceView.js +257 -0
- package/dist/shared/components/MapView.js +30 -29
- package/dist/shared/components/MatrixEditor.js +497 -462
- package/dist/shared/components/MyWorkView.js +346 -272
- package/dist/shared/components/NotificationBell.js +215 -201
- package/dist/shared/components/PageRenderer.js +636 -599
- package/dist/shared/components/PresenceDot.js +21 -0
- package/dist/shared/components/ProfileView.js +656 -536
- package/dist/shared/components/RealtimeStatusBanner.js +25 -25
- package/dist/shared/components/RecentRecordsRail.js +51 -48
- package/dist/shared/components/RecordCompare.js +241 -150
- package/dist/shared/components/RecordDrilldownSheet.js +66 -64
- package/dist/shared/components/RecordGridEditor.js +350 -311
- package/dist/shared/components/RecordHoverCard.js +147 -0
- package/dist/shared/components/RecordPeekHost.js +111 -0
- package/dist/shared/components/RecordReadView.js +414 -412
- package/dist/shared/components/RelativeTime.js +16 -0
- package/dist/shared/components/ReportView.js +1396 -1304
- package/dist/shared/components/ScreenRefreshButton.js +77 -0
- package/dist/shared/components/TabCountHost.js +10 -0
- package/dist/shared/components/TickerNumber.js +19 -18
- package/dist/shared/components/TipLayer.js +70 -58
- package/dist/shared/components/WidgetImageMenu.js +59 -0
- package/dist/shared/components/WidgetSlot.js +571 -524
- package/dist/shared/components/activity/RecordActivityStream.js +317 -0
- package/dist/shared/components/bulk/BulkSelectionNotices.js +220 -0
- package/dist/shared/components/cbv/approval-changed.js +20 -0
- package/dist/shared/components/cbv/changed-by-others.js +251 -0
- package/dist/shared/components/cbv/column-totals.js +75 -67
- package/dist/shared/components/change-proposals/ChangeProposalsPanel.js +320 -0
- package/dist/shared/components/change-proposals/ProposalValue.js +28 -0
- package/dist/shared/components/change-proposals/ProposeChangeButton.js +44 -0
- package/dist/shared/components/change-proposals/ProposeChangeDialog.js +359 -0
- package/dist/shared/components/change-proposals/types.js +4 -0
- package/dist/shared/components/chat/ChatPanel.js +1571 -1528
- package/dist/shared/components/chat/Composer.js +276 -298
- package/dist/shared/components/chat/room-due.js +13 -0
- package/dist/shared/components/collections-directory/CollectionRow.js +76 -75
- package/dist/shared/components/collections-directory/CollectionsDirectory.js +415 -395
- package/dist/shared/components/collections-directory/directory-data.js +75 -63
- package/dist/shared/components/imports/ImportConsole.js +159 -155
- package/dist/shared/components/imports/ImportDuplicatesNotice.js +46 -31
- package/dist/shared/components/integrations/SendStatus.js +202 -0
- package/dist/shared/components/integrations/console/IntegrationsConsole.js +45 -36
- package/dist/shared/components/integrations/console/ReadyToSendView.js +453 -0
- package/dist/shared/components/integrations/console/api.js +161 -117
- package/dist/shared/components/integrations/console/tone.js +15 -12
- package/dist/shared/components/item-edit/CatalogPickerField.js +1353 -1245
- package/dist/shared/components/item-edit/ChangedAfterApprovalBadge.js +162 -0
- package/dist/shared/components/item-edit/CloneDialog.js +208 -206
- package/dist/shared/components/item-edit/DerivedCauseNote.js +57 -0
- package/dist/shared/components/item-edit/DraftRecoveryBanner.js +81 -70
- package/dist/shared/components/item-edit/DuplicateNotice.js +169 -101
- package/dist/shared/components/item-edit/FieldAffordances.js +294 -385
- package/dist/shared/components/item-edit/FieldComments.js +159 -116
- package/dist/shared/components/item-edit/FieldPointer.js +132 -0
- package/dist/shared/components/item-edit/FieldRenderer.js +277 -273
- package/dist/shared/components/item-edit/FieldRow.js +519 -439
- package/dist/shared/components/item-edit/FieldSourceBadge.js +88 -0
- package/dist/shared/components/item-edit/FilePickerField.js +454 -369
- package/dist/shared/components/item-edit/GroupSection.js +618 -567
- package/dist/shared/components/item-edit/HeldEditsChip.js +113 -0
- package/dist/shared/components/item-edit/InlineTableField.js +2891 -2723
- package/dist/shared/components/item-edit/ListNeighborNav.js +79 -0
- package/dist/shared/components/item-edit/LiveTraceSheet.js +26 -0
- package/dist/shared/components/item-edit/M2MCombobox.js +284 -273
- package/dist/shared/components/item-edit/OutboxReviewTray.js +313 -0
- package/dist/shared/components/item-edit/PickerBadges.js +52 -0
- package/dist/shared/components/item-edit/PlanGrid.js +434 -439
- package/dist/shared/components/item-edit/RecalcValue.js +55 -0
- package/dist/shared/components/item-edit/RecordChatActions.js +76 -64
- package/dist/shared/components/item-edit/RecordChatMentionsChip.js +103 -0
- package/dist/shared/components/item-edit/RecordGrantTools.js +87 -86
- package/dist/shared/components/item-edit/RecordHelpChip.js +70 -0
- package/dist/shared/components/item-edit/RecordLiveSync.js +230 -217
- package/dist/shared/components/item-edit/RecordOutbox.js +53 -52
- package/dist/shared/components/item-edit/RecordRecapStrip.js +109 -36
- package/dist/shared/components/item-edit/RelationCombobox.js +229 -217
- package/dist/shared/components/item-edit/RelationGroupedCombobox.js +105 -100
- package/dist/shared/components/item-edit/RemoteChangeUi.js +454 -0
- package/dist/shared/components/item-edit/RemoteUploads.js +55 -0
- package/dist/shared/components/item-edit/RemovedLineNote.js +92 -0
- package/dist/shared/components/item-edit/RichTextEditorImpl.js +298 -223
- package/dist/shared/components/item-edit/ScheduledChangeChip.js +244 -0
- package/dist/shared/components/item-edit/SectionPresence.js +78 -0
- package/dist/shared/components/item-edit/SplitLinesButton.js +166 -0
- package/dist/shared/components/item-edit/catalog-line-watch.js +94 -0
- package/dist/shared/components/item-edit/coedit/collab.js +84 -0
- package/dist/shared/components/item-edit/coedit/context.js +24 -0
- package/dist/shared/components/item-edit/coedit/cursors.js +103 -0
- package/dist/shared/components/item-edit/coedit/safe-link.js +15 -0
- package/dist/shared/components/item-edit/coedit/session.js +382 -0
- package/dist/shared/components/item-edit/coedit/useCoedit.js +49 -0
- package/dist/shared/components/item-edit/file-live.js +77 -0
- package/dist/shared/components/item-edit/file-processing.js +87 -0
- package/dist/shared/components/item-edit/layout-switch.js +148 -0
- package/dist/shared/components/item-edit/live-related.js +23 -0
- package/dist/shared/components/item-edit/live-title.js +66 -0
- package/dist/shared/components/item-edit/partner-needs.js +142 -0
- package/dist/shared/components/item-edit/removed-line.js +58 -0
- package/dist/shared/components/item-edit/render-stability.js +70 -59
- package/dist/shared/components/layout-editor/ChangeNote.js +36 -34
- package/dist/shared/components/layout-editor/CollabParts.js +72 -70
- package/dist/shared/components/layout-editor/LayoutEditor.js +306 -303
- package/dist/shared/components/list/InlineEdit.js +504 -208
- package/dist/shared/components/list/ListViewers.js +81 -0
- package/dist/shared/components/merge/MergeRecordsDialog.js +1227 -0
- package/dist/shared/components/merge/MergeWithFlow.js +290 -0
- package/dist/shared/components/merge/merge-values.js +110 -0
- package/dist/shared/components/monitoring/InactiveUserLinksView.js +285 -258
- package/dist/shared/components/notifications/NotificationCenterView.js +388 -321
- package/dist/shared/components/notifications/NotificationDetailBits.js +205 -130
- package/dist/shared/components/notifications/NotificationRulesEditor.js +72 -52
- package/dist/shared/components/notifications/bundles.js +21 -19
- package/dist/shared/components/notifications/resolved-line.js +25 -0
- package/dist/shared/components/ops/OpsTasksView.js +45 -44
- package/dist/shared/components/panels/AccessGrantedNote.js +85 -0
- package/dist/shared/components/panels/AlertBanners.js +132 -0
- package/dist/shared/components/panels/AsyncUserPicker.js +54 -45
- package/dist/shared/components/panels/BranchLanes.js +82 -54
- package/dist/shared/components/panels/CommentAwareness.js +332 -0
- package/dist/shared/components/panels/CommentImages.js +219 -0
- package/dist/shared/components/panels/CommentPanel.js +649 -530
- package/dist/shared/components/panels/ExternalRequestsChip.js +98 -80
- package/dist/shared/components/panels/NewSinceChip.js +16 -0
- package/dist/shared/components/panels/OwnerOpenedLine.js +85 -0
- package/dist/shared/components/panels/PipelinePanel.js +1644 -1494
- package/dist/shared/components/panels/ResubmissionDiff.js +293 -0
- package/dist/shared/components/panels/SlaBreachBanner.js +30 -29
- package/dist/shared/components/panels/SlaClock.js +130 -99
- package/dist/shared/components/panels/TaskPanel.js +308 -287
- package/dist/shared/components/panels/unseen-move-check.js +101 -0
- package/dist/shared/components/pipeline/OwnerMatrix.js +80 -71
- package/dist/shared/components/pipeline/OwnerMatrixSheet.js +495 -0
- package/dist/shared/components/pipeline/PipelineEditorView.js +1855 -1771
- package/dist/shared/components/profile/AgentNameField.js +141 -0
- package/dist/shared/components/profile/AgentsPanel.js +55 -46
- package/dist/shared/components/profile/PersonAccess.js +398 -330
- package/dist/shared/components/profile/PersonAdminTools.js +127 -113
- package/dist/shared/components/profile/PersonProfile.js +81 -73
- package/dist/shared/components/profile/SignInTroubleshooter.js +361 -0
- package/dist/shared/components/queue/QueueBulkBar.js +101 -84
- package/dist/shared/components/queue/QueueItemSheet.js +66 -66
- package/dist/shared/components/queue/QueueTeamStrip.js +279 -0
- package/dist/shared/components/queue/QueueWorklist.js +2076 -1686
- package/dist/shared/components/queue/queue-totals.js +92 -0
- package/dist/shared/components/queue/worklist-helpers.js +18 -14
- package/dist/shared/components/send-view/SendViewButton.js +136 -0
- package/dist/shared/components/send-view/SentViewCards.js +147 -0
- package/dist/shared/components/support/ReportProblem.js +1 -0
- package/dist/shared/components/support/ScreenShare.js +554 -0
- package/dist/shared/components/support/SupportView.js +160 -129
- package/dist/shared/components/support/TicketDetailSheet.js +101 -89
- package/dist/shared/components/watch-list/WatchDock.js +1044 -0
- package/dist/shared/components/watch-list/WatchExtras.js +723 -0
- package/dist/shared/components/watch-list/WatchListButton.js +46 -0
- package/dist/shared/components/watch-list/WatchPinButton.js +67 -0
- package/dist/shared/components/watch-list/WatchRows.js +348 -0
- package/dist/shared/lib/activity-sentence.js +87 -75
- package/dist/shared/lib/agent-presence.js +46 -0
- package/dist/shared/lib/approval-progress.js +49 -0
- package/dist/shared/lib/attention-prefs.js +27 -0
- package/dist/shared/lib/cell-locks.js +56 -0
- package/dist/shared/lib/co-edit.js +166 -0
- package/dist/shared/lib/coedit-registry.js +44 -0
- package/dist/shared/lib/comment-awareness.js +124 -0
- package/dist/shared/lib/comment-images.js +45 -0
- package/dist/shared/lib/config-watch.js +94 -0
- package/dist/shared/lib/copy-rules.js +65 -0
- package/dist/shared/lib/count-step.js +30 -0
- package/dist/shared/lib/deadline-ticker.js +68 -0
- package/dist/shared/lib/derived-causes.js +115 -0
- package/dist/shared/lib/draft-store.js +114 -85
- package/dist/shared/lib/error-hints.js +1 -0
- package/dist/shared/lib/field-merge.js +126 -0
- package/dist/shared/lib/filter-sentence.js +10 -10
- package/dist/shared/lib/focus-mode.js +16 -12
- package/dist/shared/lib/grid-cursors.js +77 -0
- package/dist/shared/lib/grid-presence.js +182 -0
- package/dist/shared/lib/idle-reload.js +100 -73
- package/dist/shared/lib/in-step.js +45 -0
- package/dist/shared/lib/integration-chip.js +19 -18
- package/dist/shared/lib/line-locks.js +141 -0
- package/dist/shared/lib/line-split.js +41 -0
- package/dist/shared/lib/linked-changes.js +150 -0
- package/dist/shared/lib/list-link.js +56 -50
- package/dist/shared/lib/list-return.js +231 -0
- package/dist/shared/lib/list-viewers.js +52 -0
- package/dist/shared/lib/live-announcer.js +86 -0
- package/dist/shared/lib/live-counts.js +85 -0
- package/dist/shared/lib/live-data-changed.js +108 -0
- package/dist/shared/lib/live-deltas.js +81 -0
- package/dist/shared/lib/live-findings.js +113 -0
- package/dist/shared/lib/live-groups.js +122 -0
- package/dist/shared/lib/live-link-labels.js +162 -0
- package/dist/shared/lib/live-list-flow.js +334 -0
- package/dist/shared/lib/live-list.js +143 -129
- package/dist/shared/lib/live-moves.js +51 -0
- package/dist/shared/lib/live-ops.js +26 -26
- package/dist/shared/lib/live-pickers.js +7 -0
- package/dist/shared/lib/live-preference.js +184 -0
- package/dist/shared/lib/live-queries.js +226 -181
- package/dist/shared/lib/live-screen.js +333 -0
- package/dist/shared/lib/live-search.js +108 -0
- package/dist/shared/lib/live-seen.js +35 -0
- package/dist/shared/lib/live-views.js +100 -0
- package/dist/shared/lib/live.js +159 -133
- package/dist/shared/lib/missed-updates.js +198 -0
- package/dist/shared/lib/newer-file.js +56 -0
- package/dist/shared/lib/notification-sound.js +42 -20
- package/dist/shared/lib/own-writes.js +59 -41
- package/dist/shared/lib/picker-badges.js +94 -0
- package/dist/shared/lib/presence-signals.js +131 -84
- package/dist/shared/lib/realtime.js +49 -24
- package/dist/shared/lib/record-gaps.js +85 -0
- package/dist/shared/lib/record-outbox.js +369 -222
- package/dist/shared/lib/record-peek.js +75 -0
- package/dist/shared/lib/record-tabs.js +92 -72
- package/dist/shared/lib/relative-ticker.js +42 -0
- package/dist/shared/lib/request-gate.js +119 -119
- package/dist/shared/lib/rollup-recalc.js +107 -0
- package/dist/shared/lib/room-gaps.js +40 -36
- package/dist/shared/lib/rum.js +137 -87
- package/dist/shared/lib/save-progress.js +20 -0
- package/dist/shared/lib/scheduled-countdown.js +67 -0
- package/dist/shared/lib/screen-refresh.js +160 -0
- package/dist/shared/lib/screen-share.js +234 -0
- package/dist/shared/lib/seen-since.js +74 -0
- package/dist/shared/lib/selection-watch.js +205 -0
- package/dist/shared/lib/send-status.js +132 -0
- package/dist/shared/lib/send-view.js +23 -0
- package/dist/shared/lib/socket-liveness.js +155 -0
- package/dist/shared/lib/socket-realtime.js +168 -140
- package/dist/shared/lib/state-census.js +53 -0
- package/dist/shared/lib/summary-mode.js +61 -39
- package/dist/shared/lib/tab-attention.js +143 -32
- package/dist/shared/lib/table-density.js +64 -0
- package/dist/shared/lib/track-travel.js +40 -0
- package/dist/shared/lib/unseen-changes.js +68 -0
- package/dist/shared/lib/upload-file.js +33 -0
- package/dist/shared/lib/upload-presence.js +127 -0
- package/dist/shared/lib/urgent-chime.js +65 -0
- package/dist/shared/lib/use-online-users.js +32 -11
- package/dist/shared/lib/user-sync.js +155 -39
- package/dist/shared/lib/waiting-count.js +44 -0
- package/dist/shared/lib/watch-desktop.js +83 -0
- package/dist/shared/lib/watch-list.js +447 -0
- package/dist/shared/lib/widget-image-render.js +64 -0
- package/dist/shared/lib/widget-image.js +111 -0
- package/dist/shared/lib/worker-socket.js +130 -104
- package/dist/shared/lib/write-to-screen.js +133 -0
- package/package.json +1 -1
- package/styles.css +49 -1
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { isOwnWrite as A } from "./own-writes.js";
|
|
2
|
+
const w = "nvr:list-return", x = 360 * 60 * 1e3, v = 500, S = (e, t) => !!e && !!t && e.collection === t.collection && String(e.id).toLowerCase() === String(t.id).toLowerCase();
|
|
3
|
+
function y() {
|
|
4
|
+
var t, n;
|
|
5
|
+
if (typeof window > "u") return null;
|
|
6
|
+
const e = (n = (t = window.history) == null ? void 0 : t.state) == null ? void 0 : n.idx;
|
|
7
|
+
return typeof e == "number" && Number.isFinite(e) ? e : null;
|
|
8
|
+
}
|
|
9
|
+
function m() {
|
|
10
|
+
try {
|
|
11
|
+
return typeof window < "u" ? window.sessionStorage : null;
|
|
12
|
+
} catch {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function T(e) {
|
|
17
|
+
const t = m();
|
|
18
|
+
if (!t) return;
|
|
19
|
+
const n = y(), r = [], o = /* @__PURE__ */ new Set();
|
|
20
|
+
for (const i of e.rows) {
|
|
21
|
+
if (!(i != null && i.collection) || i.id == null || i.id === "") continue;
|
|
22
|
+
const u = `${i.collection}${String(i.id).toLowerCase()}`;
|
|
23
|
+
if (!o.has(u) && (o.add(u), r.push({ collection: i.collection, id: String(i.id) }), r.length >= v))
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
const c = {
|
|
27
|
+
list: e.list,
|
|
28
|
+
label: e.label ?? null,
|
|
29
|
+
path: e.path ?? (typeof window < "u" ? `${window.location.pathname}${window.location.search}` : ""),
|
|
30
|
+
rows: r,
|
|
31
|
+
current: { collection: e.opened.collection, id: String(e.opened.id) },
|
|
32
|
+
opened: { collection: e.opened.collection, id: String(e.opened.id) },
|
|
33
|
+
idx: n == null ? null : n + 1,
|
|
34
|
+
entry: e.entry ?? null,
|
|
35
|
+
at: Date.now()
|
|
36
|
+
};
|
|
37
|
+
try {
|
|
38
|
+
t.setItem(w, JSON.stringify(c));
|
|
39
|
+
} catch {
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function g(e = Date.now()) {
|
|
43
|
+
const t = m();
|
|
44
|
+
if (!t) return null;
|
|
45
|
+
try {
|
|
46
|
+
const n = t.getItem(w);
|
|
47
|
+
if (!n) return null;
|
|
48
|
+
const r = JSON.parse(n);
|
|
49
|
+
return !r || typeof r.list != "string" || !Array.isArray(r.rows) || !r.current || !(e - Number(r.at ?? 0) <= x) ? null : r;
|
|
50
|
+
} catch {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function R(e) {
|
|
55
|
+
var t;
|
|
56
|
+
try {
|
|
57
|
+
(t = m()) == null || t.setItem(w, JSON.stringify(e));
|
|
58
|
+
} catch {
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function _(e, t) {
|
|
62
|
+
if (!e) return null;
|
|
63
|
+
const n = e.rows.findIndex((r) => S(r, t));
|
|
64
|
+
return n < 0 ? null : {
|
|
65
|
+
index: n + 1,
|
|
66
|
+
total: e.rows.length,
|
|
67
|
+
prev: n > 0 ? e.rows[n - 1] : null,
|
|
68
|
+
next: n < e.rows.length - 1 ? e.rows[n + 1] : null
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function I(e, t = g()) {
|
|
72
|
+
if (!t || !S(t.current, e)) return null;
|
|
73
|
+
const n = y();
|
|
74
|
+
return t.idx != null && n != null && t.idx !== n ? null : _(t, e) ? t : null;
|
|
75
|
+
}
|
|
76
|
+
function O(e) {
|
|
77
|
+
const t = g();
|
|
78
|
+
t && R({ ...t, current: { collection: e.collection, id: String(e.id) }, at: Date.now() });
|
|
79
|
+
}
|
|
80
|
+
function $(e, t = g()) {
|
|
81
|
+
return !t || t.list !== e ? null : t.current;
|
|
82
|
+
}
|
|
83
|
+
function k(e, t) {
|
|
84
|
+
var i;
|
|
85
|
+
if (!e || typeof window > "u" || !t) return !1;
|
|
86
|
+
const n = typeof CSS < "u" && CSS.escape ? CSS.escape(t) : t.replace(/"/g, '\\"'), r = e.querySelector(`[data-row-key="${n}"]`);
|
|
87
|
+
if (!r) return !1;
|
|
88
|
+
r.setAttribute("data-return-row", "");
|
|
89
|
+
let o = !1;
|
|
90
|
+
try {
|
|
91
|
+
o = !!((i = window.matchMedia) != null && i.call(window, "(prefers-reduced-motion: reduce)").matches);
|
|
92
|
+
} catch {
|
|
93
|
+
o = !1;
|
|
94
|
+
}
|
|
95
|
+
const c = Array.from(r.children);
|
|
96
|
+
return o || c.some((u) => typeof u.animate != "function") ? (setTimeout(() => r.removeAttribute("data-return-row"), 1800), !0) : (c.forEach((u, a) => {
|
|
97
|
+
const s = a === 0 ? "inset 3px 0 0 0 rgba(0, 206, 255, 0.85), " : "";
|
|
98
|
+
u.animate(
|
|
99
|
+
[
|
|
100
|
+
{ boxShadow: `${s}inset 0 0 0 9999px rgba(0, 206, 255, 0.10)` },
|
|
101
|
+
{ boxShadow: `${s}inset 0 0 0 9999px rgba(0, 206, 255, 0.10)`, offset: 0.55 },
|
|
102
|
+
{
|
|
103
|
+
boxShadow: `${a === 0 ? "inset 3px 0 0 0 rgba(0, 206, 255, 0), " : ""}inset 0 0 0 9999px rgba(0, 206, 255, 0)`
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
{ duration: 2400, easing: "ease-out" }
|
|
107
|
+
);
|
|
108
|
+
}), setTimeout(() => r.removeAttribute("data-return-row"), 2400), !0);
|
|
109
|
+
}
|
|
110
|
+
function C(e, t) {
|
|
111
|
+
const n = e.getBoundingClientRect(), r = { top: 0, bottom: typeof window < "u" ? window.innerHeight : 0 };
|
|
112
|
+
return n.bottom > r.top + 4 && n.top < r.bottom - 4;
|
|
113
|
+
}
|
|
114
|
+
const L = 300, h = 900 * 1e3, E = 40, p = /* @__PURE__ */ new Map();
|
|
115
|
+
function N(e) {
|
|
116
|
+
if (!e.coalesced) return [e];
|
|
117
|
+
const { coalesced: t, items: n, many: r, count: o, ...c } = e;
|
|
118
|
+
return r || !Array.isArray(n) ? [{ ...c, item: "*" }] : n.map((i) => ({ ...c, item: i }));
|
|
119
|
+
}
|
|
120
|
+
function d(e, t) {
|
|
121
|
+
e.complete && (e.complete = !1, e.reason = t, e.events = []);
|
|
122
|
+
}
|
|
123
|
+
function D(e, t, n) {
|
|
124
|
+
const r = [...new Set(n.filter(Boolean))];
|
|
125
|
+
if (!e || !t || r.length === 0) return () => {
|
|
126
|
+
};
|
|
127
|
+
const o = {
|
|
128
|
+
key: t,
|
|
129
|
+
events: [],
|
|
130
|
+
complete: !0,
|
|
131
|
+
away: !1,
|
|
132
|
+
leftAt: 0,
|
|
133
|
+
dropped: !1,
|
|
134
|
+
stop: () => {
|
|
135
|
+
},
|
|
136
|
+
timer: null
|
|
137
|
+
}, c = (s) => {
|
|
138
|
+
if (!(!o.away || !o.complete))
|
|
139
|
+
for (const l of N(s)) {
|
|
140
|
+
if (!l || !r.includes(String(l.collection))) continue;
|
|
141
|
+
if (String(l.item) === "*") {
|
|
142
|
+
d(o, "bulk");
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
if (o.events.length >= L) {
|
|
146
|
+
d(o, "overflow");
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const f = Array.isArray(l.changed_fields) ? l.changed_fields : null;
|
|
150
|
+
o.events.push({
|
|
151
|
+
collection: String(l.collection),
|
|
152
|
+
item: String(l.item),
|
|
153
|
+
...l.action ? { action: l.action } : {},
|
|
154
|
+
...f ? { changed_fields: [...f] } : {},
|
|
155
|
+
own: A(String(l.collection), String(l.item), f)
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}, i = e.subscribeCollections(r, c), u = e.onStatus ? e.onStatus((s) => {
|
|
159
|
+
o.away && (s.state === "reconnecting" ? o.dropped = !0 : o.dropped && (o.dropped = !1, s.resumed !== "replayed" && d(o, "reconnect")));
|
|
160
|
+
}) : () => {
|
|
161
|
+
}, a = () => {
|
|
162
|
+
o.away && d(o, "stale");
|
|
163
|
+
};
|
|
164
|
+
return typeof window < "u" && (window.addEventListener("nvr:catchup-full", a), window.addEventListener("nvr:realtime-stale", a)), o.stop = () => {
|
|
165
|
+
i(), u(), typeof window < "u" && (window.removeEventListener("nvr:catchup-full", a), window.removeEventListener("nvr:realtime-stale", a)), o.timer && clearTimeout(o.timer), o.timer = null;
|
|
166
|
+
}, () => {
|
|
167
|
+
const s = p.get(t);
|
|
168
|
+
s && s !== o && s.stop(), o.away = !0, o.leftAt = Date.now(), o.timer = setTimeout(() => {
|
|
169
|
+
o.stop(), d(o, "expired");
|
|
170
|
+
}, h), p.set(t, o);
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
function b(e, t) {
|
|
174
|
+
const n = t - e.leftAt > h;
|
|
175
|
+
return {
|
|
176
|
+
events: e.complete && !n ? [...e.events] : [],
|
|
177
|
+
complete: e.complete && !n,
|
|
178
|
+
...e.reason ? { reason: e.reason } : n ? { reason: "expired" } : {},
|
|
179
|
+
leftAt: e.leftAt,
|
|
180
|
+
awayMs: Math.max(0, t - e.leftAt)
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
function J(e, t = Date.now()) {
|
|
184
|
+
const n = p.get(e);
|
|
185
|
+
return n != null && n.away ? b(n, t) : null;
|
|
186
|
+
}
|
|
187
|
+
function W(e, t = Date.now()) {
|
|
188
|
+
const n = p.get(e);
|
|
189
|
+
return n != null && n.away ? (p.delete(e), n.stop(), b(n, t)) : null;
|
|
190
|
+
}
|
|
191
|
+
function X(e, t = {}) {
|
|
192
|
+
return e ? e.complete ? e.events.length === 0 ? "keep" : new Set(e.events.map((r) => `${r.collection}${String(r.item)}`)).size <= (t.maxRows ?? E) ? "replay" : "refetch" : "refetch" : "fresh";
|
|
193
|
+
}
|
|
194
|
+
function j(e, t, n = (r) => String(r.id)) {
|
|
195
|
+
if (!e || !t) return [];
|
|
196
|
+
const r = new Map(e.map((c) => [n(c), c])), o = [];
|
|
197
|
+
for (const c of t) {
|
|
198
|
+
const i = n(c), u = r.get(i);
|
|
199
|
+
if (!u) continue;
|
|
200
|
+
const a = /* @__PURE__ */ new Set([...Object.keys(u), ...Object.keys(c)]);
|
|
201
|
+
for (const s of a) {
|
|
202
|
+
const l = u[s], f = c[s];
|
|
203
|
+
if (l !== f && !(l && f && typeof l == "object" && typeof f == "object" && JSON.stringify(l) === JSON.stringify(f))) {
|
|
204
|
+
o.push(i);
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return o;
|
|
210
|
+
}
|
|
211
|
+
export {
|
|
212
|
+
L as AWAY_MAX_EVENTS,
|
|
213
|
+
h as AWAY_MAX_MS,
|
|
214
|
+
w as LIST_RETURN_KEY,
|
|
215
|
+
x as LIST_RETURN_MAX_AGE_MS,
|
|
216
|
+
v as LIST_RETURN_MAX_ROWS,
|
|
217
|
+
E as RETURN_MAX_ROWS,
|
|
218
|
+
j as changedRowIds,
|
|
219
|
+
_ as listNeighbors,
|
|
220
|
+
I as listReturnFor,
|
|
221
|
+
k as markReturnRow,
|
|
222
|
+
T as noteListOpen,
|
|
223
|
+
J as peekListAway,
|
|
224
|
+
X as planListReturn,
|
|
225
|
+
g as readListReturn,
|
|
226
|
+
$ as returnRowFor,
|
|
227
|
+
C as rowInView,
|
|
228
|
+
D as standbyListAway,
|
|
229
|
+
O as stepListReturn,
|
|
230
|
+
W as takeListAway
|
|
231
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { useContext as f, useState as l, useEffect as h } from "react";
|
|
2
|
+
import { ItemEditAuthContext as p } from "../context.js";
|
|
3
|
+
import { useLiveEvent as d } from "./live.js";
|
|
4
|
+
import { useOptionalRealtime as g } from "./realtime.js";
|
|
5
|
+
function y(t, e) {
|
|
6
|
+
return `${t === "list" ? "list-view" : "queue-view"}:${e}`;
|
|
7
|
+
}
|
|
8
|
+
function $(t, e) {
|
|
9
|
+
if (!Array.isArray(t)) return [];
|
|
10
|
+
const o = e.toUpperCase(), a = /* @__PURE__ */ new Set(), i = [];
|
|
11
|
+
for (const n of t) {
|
|
12
|
+
if (!n || typeof n.id != "string" || typeof n.name != "string") continue;
|
|
13
|
+
const r = n.id.toUpperCase();
|
|
14
|
+
r === o || a.has(r) || (a.add(r), i.push({ id: n.id, name: n.name }));
|
|
15
|
+
}
|
|
16
|
+
return i.sort((n, r) => n.name.localeCompare(r.name));
|
|
17
|
+
}
|
|
18
|
+
function A(t, e, o = !0, a) {
|
|
19
|
+
const i = g(), n = f(p), r = a ?? n.userId, [m, c] = l([]), u = e == null || e === "" ? null : y(t, e);
|
|
20
|
+
return d(
|
|
21
|
+
"ops:changed",
|
|
22
|
+
(s) => c($(s.viewers, r ?? "")),
|
|
23
|
+
{
|
|
24
|
+
enabled: !!u && o,
|
|
25
|
+
includeOwn: !0,
|
|
26
|
+
match: (s) => (s == null ? void 0 : s.topic) === u && s != null && "viewers" in s
|
|
27
|
+
}
|
|
28
|
+
), h(() => {
|
|
29
|
+
if (c([]), !(!i || !u || !o)) {
|
|
30
|
+
try {
|
|
31
|
+
i.emit("ops:join", { topic: u });
|
|
32
|
+
} catch {
|
|
33
|
+
}
|
|
34
|
+
return () => {
|
|
35
|
+
try {
|
|
36
|
+
i.emit("ops:leave", { topic: u });
|
|
37
|
+
} catch {
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}, [i, u, o]), m;
|
|
42
|
+
}
|
|
43
|
+
function E(t) {
|
|
44
|
+
const e = (o) => o.split(/\s+/)[0] || o;
|
|
45
|
+
return t.length === 0 ? "" : t.length === 1 ? `${e(t[0].name)} is viewing this too` : t.length === 2 ? `${e(t[0].name)} and ${e(t[1].name)} are viewing this too` : `${e(t[0].name)} and ${t.length - 1} others are viewing this too`;
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
y as listViewTopic,
|
|
49
|
+
$ as othersFrom,
|
|
50
|
+
A as useListViewers,
|
|
51
|
+
E as viewersSentence
|
|
52
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
const _ = 5e3, E = 800;
|
|
2
|
+
function T(e) {
|
|
3
|
+
const t = e.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_-]+/g, " ").trim();
|
|
4
|
+
return t ? t.charAt(0).toUpperCase() + t.slice(1).toLowerCase() : "";
|
|
5
|
+
}
|
|
6
|
+
const $ = {
|
|
7
|
+
$state: "Status",
|
|
8
|
+
$comments: "Comments",
|
|
9
|
+
$tasks: "Tasks",
|
|
10
|
+
$addendums: "Addendums",
|
|
11
|
+
$owners: "Owners"
|
|
12
|
+
};
|
|
13
|
+
function A(e) {
|
|
14
|
+
const t = [];
|
|
15
|
+
for (const o of e) {
|
|
16
|
+
const i = o.startsWith("$") ? $[o] : T(o);
|
|
17
|
+
i && !t.includes(i) && t.push(i);
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
}
|
|
21
|
+
function g(e) {
|
|
22
|
+
if (e.action === "create" || e.action === "delete") return !0;
|
|
23
|
+
const t = e.fields;
|
|
24
|
+
return !t || t.length === 0 ? !0 : A(t).length > 0;
|
|
25
|
+
}
|
|
26
|
+
function p(e, t, o) {
|
|
27
|
+
return `${e} ${e === 1 ? t : o}`;
|
|
28
|
+
}
|
|
29
|
+
function S(e, t = "full") {
|
|
30
|
+
if (t === "off") return "";
|
|
31
|
+
const o = e.filter(g);
|
|
32
|
+
if (o.length === 0) return "";
|
|
33
|
+
const i = /* @__PURE__ */ new Set();
|
|
34
|
+
let h = 0;
|
|
35
|
+
const u = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(), s = [];
|
|
36
|
+
let r = !1, f = 0;
|
|
37
|
+
for (const d of o) {
|
|
38
|
+
f++;
|
|
39
|
+
const m = d.item == null ? `#${f}` : String(d.item);
|
|
40
|
+
if (d.item === "*" ? h += Math.max(1, d.bulk ?? 1) : i.add(m), d.action === "create") u.add(m);
|
|
41
|
+
else if (d.action === "delete") c.add(m);
|
|
42
|
+
else {
|
|
43
|
+
r = !0;
|
|
44
|
+
for (const N of A(d.fields ?? [])) s.includes(N) || s.push(N);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const l = i.size + h;
|
|
48
|
+
if (t === "brief") return l <= 1 ? "Updated" : `${l} rows updated`;
|
|
49
|
+
const n = [];
|
|
50
|
+
if (l === 1 && u.size === 0 && c.size === 0)
|
|
51
|
+
return s.length > 0 && s.length <= 2 ? `${s.join(" and ")} changed` : s.length > 2 ? `${s.length} fields changed` : "Record updated";
|
|
52
|
+
const a = l - u.size - c.size;
|
|
53
|
+
u.size > 0 && n.push(p(u.size, "row added", "rows added")), c.size > 0 && n.push(p(c.size, "row removed", "rows removed")), r && a > 0 && n.push(p(a, "row updated", "rows updated")), n.length === 0 && n.push(p(l, "row updated", "rows updated"));
|
|
54
|
+
const w = n.join(", ");
|
|
55
|
+
return w.charAt(0).toUpperCase() + w.slice(1);
|
|
56
|
+
}
|
|
57
|
+
function z(e) {
|
|
58
|
+
const t = e.minGapMs ?? 5e3, o = e.settleMs ?? 800, i = e.now ?? (() => Date.now()), h = e.setTimer ?? ((n, a) => setTimeout(n, a)), u = e.clearTimer ?? ((n) => clearTimeout(n));
|
|
59
|
+
let c = e.verbosity ?? "full", s = [], r = null, f = Number.NEGATIVE_INFINITY;
|
|
60
|
+
const l = () => {
|
|
61
|
+
r = null;
|
|
62
|
+
const n = s;
|
|
63
|
+
s = [];
|
|
64
|
+
const a = S(n, c);
|
|
65
|
+
a && (f = i(), e.say(a));
|
|
66
|
+
};
|
|
67
|
+
return {
|
|
68
|
+
note(n) {
|
|
69
|
+
c === "off" || !g(n) || (s.push(n), !r && (r = h(l, Math.max(o, f + t - i()))));
|
|
70
|
+
},
|
|
71
|
+
setVerbosity(n) {
|
|
72
|
+
c = n, n === "off" && (s = [], r && (u(r), r = null));
|
|
73
|
+
},
|
|
74
|
+
dispose() {
|
|
75
|
+
s = [], r && u(r), r = null;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export {
|
|
80
|
+
_ as ANNOUNCE_MIN_GAP_MS,
|
|
81
|
+
E as ANNOUNCE_SETTLE_MS,
|
|
82
|
+
S as composeAnnouncement,
|
|
83
|
+
z as createAnnouncer,
|
|
84
|
+
T as humanField,
|
|
85
|
+
g as worthAnnouncing
|
|
86
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { useQueryClient as k } from "@tanstack/react-query";
|
|
2
|
+
import { useRef as p, useEffect as S } from "react";
|
|
3
|
+
import { useLiveOps as T } from "./live-ops.js";
|
|
4
|
+
function q() {
|
|
5
|
+
return typeof document > "u" || document.visibilityState !== "hidden";
|
|
6
|
+
}
|
|
7
|
+
const y = 2e3, w = 15e3;
|
|
8
|
+
function O(e, n = {}) {
|
|
9
|
+
const o = Math.max(0, n.quietMs ?? y), c = Math.max(o, n.maxWaitMs ?? w), l = n.isVisible ?? q, f = n.now ?? (() => Date.now());
|
|
10
|
+
let t = null, s = null, i = !1;
|
|
11
|
+
const d = () => {
|
|
12
|
+
if (t = null, s = null, !l()) {
|
|
13
|
+
i = !0;
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
i = !1, e();
|
|
17
|
+
};
|
|
18
|
+
return {
|
|
19
|
+
poke() {
|
|
20
|
+
const r = f();
|
|
21
|
+
s === null && (s = r);
|
|
22
|
+
const u = Math.min(r + o, s + c);
|
|
23
|
+
t && clearTimeout(t), t = setTimeout(d, Math.max(0, u - r));
|
|
24
|
+
},
|
|
25
|
+
resume() {
|
|
26
|
+
t || !i || !l() || (i = !1, e());
|
|
27
|
+
},
|
|
28
|
+
cancel() {
|
|
29
|
+
t && clearTimeout(t), t = null, s = null, i = !1;
|
|
30
|
+
},
|
|
31
|
+
pending: () => t != null || i
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const M = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new WeakMap();
|
|
35
|
+
let W = 1;
|
|
36
|
+
function C(e, n, o, c) {
|
|
37
|
+
return `${e}|${o}|${c ?? ""}|${JSON.stringify(n)}`;
|
|
38
|
+
}
|
|
39
|
+
function E(e) {
|
|
40
|
+
const n = k(), o = e.enabled !== !1, c = Math.max(y, e.quietMs ?? y), l = e.maxWaitMs, f = JSON.stringify(e.keys), t = p(() => {
|
|
41
|
+
}), s = p(e.onReady);
|
|
42
|
+
s.current = e.onReady, S(() => {
|
|
43
|
+
var h;
|
|
44
|
+
if (!o) return;
|
|
45
|
+
let i = x.get(n);
|
|
46
|
+
i == null && (i = W++, x.set(n, i));
|
|
47
|
+
const d = JSON.parse(f), r = C(i, d, c, l);
|
|
48
|
+
let u = M.get(r);
|
|
49
|
+
if (!u) {
|
|
50
|
+
const b = O(
|
|
51
|
+
() => {
|
|
52
|
+
for (const g of d)
|
|
53
|
+
n.invalidateQueries({ queryKey: g, refetchType: "active" });
|
|
54
|
+
},
|
|
55
|
+
{ quietMs: c, maxWaitMs: l }
|
|
56
|
+
), v = () => b.resume();
|
|
57
|
+
typeof document < "u" && document.addEventListener("visibilitychange", v), u = {
|
|
58
|
+
co: b,
|
|
59
|
+
users: 0,
|
|
60
|
+
stopVis: () => {
|
|
61
|
+
typeof document < "u" && document.removeEventListener("visibilitychange", v);
|
|
62
|
+
}
|
|
63
|
+
}, M.set(r, u);
|
|
64
|
+
}
|
|
65
|
+
u.users += 1;
|
|
66
|
+
const a = u;
|
|
67
|
+
t.current = () => a.co.poke();
|
|
68
|
+
const m = (h = s.current) == null ? void 0 : h.call(s, () => a.co.poke());
|
|
69
|
+
return () => {
|
|
70
|
+
m == null || m(), t.current = () => {
|
|
71
|
+
}, a.users -= 1, a.users <= 0 && (a.co.cancel(), a.stopVis(), M.delete(r));
|
|
72
|
+
};
|
|
73
|
+
}, [n, o, f, c, l]), T(e.topic ?? null, () => t.current(), {
|
|
74
|
+
enabled: o && !!e.topic,
|
|
75
|
+
// The coalescer is the real wait; the ops hook only forwards.
|
|
76
|
+
debounceMs: 0
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
export {
|
|
80
|
+
w as COUNT_MAX_WAIT_MS,
|
|
81
|
+
y as COUNT_QUIET_MS,
|
|
82
|
+
O as createCoalescer,
|
|
83
|
+
C as refreshSignature,
|
|
84
|
+
E as useLiveRefresh
|
|
85
|
+
};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { useState as m, useEffect as h, useCallback as g, useMemo as R, useRef as l } from "react";
|
|
2
|
+
import { useLiveCollection as A } from "./live.js";
|
|
3
|
+
function S(t) {
|
|
4
|
+
const e = [];
|
|
5
|
+
for (const n of (t == null ? void 0 : t.freshness_sources) ?? []) {
|
|
6
|
+
const r = typeof (n == null ? void 0 : n.table) == "string" ? n.table.trim() : "";
|
|
7
|
+
r && !e.includes(r) && e.push(r);
|
|
8
|
+
}
|
|
9
|
+
return e.slice(0, 12);
|
|
10
|
+
}
|
|
11
|
+
function _(t) {
|
|
12
|
+
return (t == null ? void 0 : t.cached_at) ?? (t == null ? void 0 : t.executed_at) ?? null;
|
|
13
|
+
}
|
|
14
|
+
function b(t) {
|
|
15
|
+
return !t.aspectsOnly && t.events.length > 0;
|
|
16
|
+
}
|
|
17
|
+
function E(t, e, n = !0) {
|
|
18
|
+
const [r, c] = m(null);
|
|
19
|
+
h(() => {
|
|
20
|
+
c(null);
|
|
21
|
+
}, [e]);
|
|
22
|
+
const s = t.join(",");
|
|
23
|
+
return A(
|
|
24
|
+
s ? t : null,
|
|
25
|
+
(o) => {
|
|
26
|
+
b(o) && c((u) => u ?? Date.now());
|
|
27
|
+
},
|
|
28
|
+
{ debounceMs: 1e3, includeOwn: !0, enabled: n && s !== "" }
|
|
29
|
+
), r;
|
|
30
|
+
}
|
|
31
|
+
const f = "nvr:auto-refresh:";
|
|
32
|
+
function d(t) {
|
|
33
|
+
try {
|
|
34
|
+
return localStorage.getItem(f + t) === "1";
|
|
35
|
+
} catch {
|
|
36
|
+
return !1;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function T(t, e) {
|
|
40
|
+
try {
|
|
41
|
+
e ? localStorage.setItem(f + t, "1") : localStorage.removeItem(f + t);
|
|
42
|
+
} catch {
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function w(t) {
|
|
46
|
+
const [e, n] = m(() => d(t));
|
|
47
|
+
h(() => {
|
|
48
|
+
n(d(t));
|
|
49
|
+
}, [t]);
|
|
50
|
+
const r = g(
|
|
51
|
+
(c) => {
|
|
52
|
+
T(t, c), n(c);
|
|
53
|
+
},
|
|
54
|
+
[t]
|
|
55
|
+
);
|
|
56
|
+
return [e, r];
|
|
57
|
+
}
|
|
58
|
+
const y = 15e3, C = 6, M = [];
|
|
59
|
+
function O(t = Date.now(), e = M, n = C) {
|
|
60
|
+
for (; e.length > 0 && t - e[0] >= 6e4; ) e.shift();
|
|
61
|
+
return e.length >= n ? !1 : (e.push(t), !0);
|
|
62
|
+
}
|
|
63
|
+
function D(t) {
|
|
64
|
+
const { changedAt: e, enabled: n } = t, r = l(t.refresh);
|
|
65
|
+
r.current = t.refresh;
|
|
66
|
+
const c = l(0), s = l(null), o = t.minGapMs ?? y;
|
|
67
|
+
h(() => {
|
|
68
|
+
if (!n || e == null || s.current === e) return;
|
|
69
|
+
let u = null;
|
|
70
|
+
const a = () => {
|
|
71
|
+
if (u = null, !document.hidden) {
|
|
72
|
+
if (!O()) {
|
|
73
|
+
u = setTimeout(a, 1e4);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
s.current = e, c.current = Date.now(), r.current();
|
|
77
|
+
}
|
|
78
|
+
}, i = () => {
|
|
79
|
+
!document.hidden && !u && s.current !== e && (u = setTimeout(a, 0));
|
|
80
|
+
};
|
|
81
|
+
return document.addEventListener("visibilitychange", i), u = setTimeout(a, Math.max(0, c.current + o - Date.now())), () => {
|
|
82
|
+
document.removeEventListener("visibilitychange", i), u && clearTimeout(u);
|
|
83
|
+
};
|
|
84
|
+
}, [n, e, o]);
|
|
85
|
+
}
|
|
86
|
+
function F(t) {
|
|
87
|
+
const { envelope: e, scope: n, refresh: r, autoOverride: c } = t, s = R(() => S(e), [e]), o = E(s, _(e), s.length > 0), [u, a] = w(n), i = c ?? u;
|
|
88
|
+
return D({ changedAt: o, enabled: i && s.length > 0, refresh: r }), {
|
|
89
|
+
/** Tables are known and one changed since the run (and auto-refresh is not already on it). */
|
|
90
|
+
changed: o != null && !i,
|
|
91
|
+
/** null when no table is known — nothing to offer. */
|
|
92
|
+
autoRefresh: s.length > 0 && c === void 0 ? { on: u, onChange: a } : null
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
export {
|
|
96
|
+
y as AUTO_REFRESH_MIN_GAP_MS,
|
|
97
|
+
C as AUTO_REFRESH_TAB_PER_MINUTE,
|
|
98
|
+
b as countsAsDataChange,
|
|
99
|
+
d as readAutoRefresh,
|
|
100
|
+
_ as runStamp,
|
|
101
|
+
O as takeAutoRefreshSlot,
|
|
102
|
+
D as useAutoRefreshOnChange,
|
|
103
|
+
w as useAutoRefreshPref,
|
|
104
|
+
E as useDataChanged,
|
|
105
|
+
F as useLiveStamp,
|
|
106
|
+
S as watchedTables,
|
|
107
|
+
T as writeAutoRefresh
|
|
108
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { useState as d, useEffect as f, useMemo as y } from "react";
|
|
2
|
+
function p(t) {
|
|
3
|
+
if (t == null) return null;
|
|
4
|
+
const n = String(t).trim().replace(/−/g, "-");
|
|
5
|
+
if (!/^-?\d{1,3}(,\d{3})*$|^-?\d+$/.test(n)) return null;
|
|
6
|
+
const r = Number(n.replace(/,/g, ""));
|
|
7
|
+
return Number.isSafeInteger(r) ? r : null;
|
|
8
|
+
}
|
|
9
|
+
const o = (t) => String(t).padStart(2, "0");
|
|
10
|
+
function g(t) {
|
|
11
|
+
return `${t.getFullYear()}-${o(t.getMonth() + 1)}-${o(t.getDate())}`;
|
|
12
|
+
}
|
|
13
|
+
function N(t) {
|
|
14
|
+
const n = new Date(t.getFullYear(), t.getMonth(), t.getDate() - 1);
|
|
15
|
+
return g(n);
|
|
16
|
+
}
|
|
17
|
+
function c(t, n, r = /* @__PURE__ */ new Date()) {
|
|
18
|
+
const e = g(r);
|
|
19
|
+
return t ? t.day === e ? t.last === n ? t : { ...t, last: n } : {
|
|
20
|
+
day: e,
|
|
21
|
+
first: n,
|
|
22
|
+
firstHour: r.getHours(),
|
|
23
|
+
last: n,
|
|
24
|
+
// Only the day right before counts as "yesterday"; an older visit is no baseline.
|
|
25
|
+
prevLast: t.day === N(r) ? t.last : null
|
|
26
|
+
} : { day: e, first: n, firstHour: r.getHours(), last: n, prevLast: null };
|
|
27
|
+
}
|
|
28
|
+
function S(t) {
|
|
29
|
+
if (!t) return null;
|
|
30
|
+
let n = t.last - t.first, r = t.firstHour < 12 ? "this morning" : "earlier today";
|
|
31
|
+
if (n === 0) {
|
|
32
|
+
if (t.prevLast == null || t.prevLast === t.last) return null;
|
|
33
|
+
n = t.last - t.prevLast, r = "yesterday";
|
|
34
|
+
}
|
|
35
|
+
const e = `${n > 0 ? "+" : "−"}${Math.abs(n).toLocaleString("en-US")}`;
|
|
36
|
+
return { delta: n, sign: e, since: r, text: `${e} since ${r}` };
|
|
37
|
+
}
|
|
38
|
+
const m = "nvr:chip:";
|
|
39
|
+
function i(t) {
|
|
40
|
+
try {
|
|
41
|
+
const n = localStorage.getItem(m + t);
|
|
42
|
+
if (!n) return null;
|
|
43
|
+
const r = JSON.parse(n);
|
|
44
|
+
return typeof r.day != "string" || !Number.isFinite(r.first) || !Number.isFinite(r.last) || !Number.isFinite(r.firstHour) ? null : {
|
|
45
|
+
day: r.day,
|
|
46
|
+
first: Number(r.first),
|
|
47
|
+
firstHour: Number(r.firstHour),
|
|
48
|
+
last: Number(r.last),
|
|
49
|
+
prevLast: r.prevLast == null || !Number.isFinite(r.prevLast) ? null : Number(r.prevLast)
|
|
50
|
+
};
|
|
51
|
+
} catch {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function h(t, n) {
|
|
56
|
+
try {
|
|
57
|
+
localStorage.setItem(m + t, JSON.stringify(n));
|
|
58
|
+
} catch {
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function $(t, n, r = !0) {
|
|
62
|
+
const e = r ? p(n) : null, [u, l] = d(
|
|
63
|
+
() => r ? i(t) : null
|
|
64
|
+
);
|
|
65
|
+
return f(() => {
|
|
66
|
+
l(r ? i(t) : null);
|
|
67
|
+
}, [t, r]), f(() => {
|
|
68
|
+
e != null && l((a) => {
|
|
69
|
+
const s = c(a ?? i(t), e);
|
|
70
|
+
return s !== a && h(t, s), s;
|
|
71
|
+
});
|
|
72
|
+
}, [e, t]), y(() => e == null ? null : S(c(u, e)), [e, u]);
|
|
73
|
+
}
|
|
74
|
+
export {
|
|
75
|
+
c as advanceBaseline,
|
|
76
|
+
g as dayKey,
|
|
77
|
+
S as deltaChip,
|
|
78
|
+
p as parseCount,
|
|
79
|
+
i as readBaseline,
|
|
80
|
+
$ as useChangeChip
|
|
81
|
+
};
|