@nivaro/react 0.3.114 → 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 +1717 -21
- 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 +1 -0
- 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/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 +1927 -1635
- 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-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,141 @@
|
|
|
1
|
+
import { createContext as K, useState as E, useMemo as x, useEffect as S, useRef as g, useCallback as v } from "react";
|
|
2
|
+
import { useNivaroClient as A } from "../context.js";
|
|
3
|
+
import { post as w } from "./commands.js";
|
|
4
|
+
import { useLiveCollection as q, LIVE_ASPECTS as z } from "./live.js";
|
|
5
|
+
import { useRowLocks as B } from "./live-list.js";
|
|
6
|
+
const C = 1e4, H = 1500, P = 2e4;
|
|
7
|
+
function V(o, t, l) {
|
|
8
|
+
if (!t) return { readOnly: !1, by: null };
|
|
9
|
+
const r = o.get(String(t));
|
|
10
|
+
return r && !r.is_mine ? { readOnly: !0, by: r.locked_by_name ?? "Someone" } : l != null && l.has(String(t)) ? { readOnly: !0, by: l.get(String(t)) ?? "Someone" } : { readOnly: !1, by: null };
|
|
11
|
+
}
|
|
12
|
+
function Q(o, t) {
|
|
13
|
+
const r = ((c) => !!c && c !== "new" && !c.startsWith("pending:"))(t) ? t : null;
|
|
14
|
+
return o === r ? { release: null, claim: null } : { release: o, claim: r };
|
|
15
|
+
}
|
|
16
|
+
const p = (o, t) => `/item-locks/${encodeURIComponent(String(o))}/${encodeURIComponent(t)}`, D = {
|
|
17
|
+
enabled: !1,
|
|
18
|
+
view: () => ({ readOnly: !1, by: null }),
|
|
19
|
+
claim: async () => !0,
|
|
20
|
+
release: () => {
|
|
21
|
+
},
|
|
22
|
+
held: null
|
|
23
|
+
};
|
|
24
|
+
function U(o) {
|
|
25
|
+
const t = o == null ? void 0 : o.response, l = (t == null ? void 0 : t.data) ?? t;
|
|
26
|
+
if ((l == null ? void 0 : l.code) === "RECORD_LOCKED")
|
|
27
|
+
return typeof l.locked_by_name == "string" ? l.locked_by_name : null;
|
|
28
|
+
}
|
|
29
|
+
function X(o) {
|
|
30
|
+
const { collection: t, enabled: l } = o, r = A(), c = l && !!t && !String(t).startsWith("nivaro_"), [M, b] = E(0);
|
|
31
|
+
q(
|
|
32
|
+
c ? t : null,
|
|
33
|
+
(e) => {
|
|
34
|
+
e.events.some((n) => (n.changed_fields ?? []).includes(z.lock)) && b((n) => n + 1);
|
|
35
|
+
},
|
|
36
|
+
{ enabled: c, includeOwn: !0, debounceMs: 150 }
|
|
37
|
+
);
|
|
38
|
+
const m = B(c ? t : null, c ? o.rowIds : [], M), [h, k] = E(() => /* @__PURE__ */ new Map()), O = x(() => [...m.values()].some((e) => !e.is_mine), [m]);
|
|
39
|
+
S(() => {
|
|
40
|
+
if (!c || !O && h.size === 0) return;
|
|
41
|
+
const e = setInterval(() => {
|
|
42
|
+
k(/* @__PURE__ */ new Map()), b((n) => n + 1);
|
|
43
|
+
}, P);
|
|
44
|
+
return () => clearInterval(e);
|
|
45
|
+
}, [c, O, h.size]);
|
|
46
|
+
const [T, R] = E(null), u = g(null), y = g(null), s = g(null), _ = v(() => {
|
|
47
|
+
y.current && clearInterval(y.current), y.current = null;
|
|
48
|
+
}, []), i = v(
|
|
49
|
+
(e, n = !1) => {
|
|
50
|
+
var d;
|
|
51
|
+
if (_(), u.current === e && (u.current = null, R(null)), n && typeof fetch == "function") {
|
|
52
|
+
try {
|
|
53
|
+
const a = (d = r.getToken) == null ? void 0 : d.call(r), f = r.url ?? "";
|
|
54
|
+
fetch(`${f}/api${p(t, e)}/lock/release`, {
|
|
55
|
+
method: "POST",
|
|
56
|
+
keepalive: !0,
|
|
57
|
+
credentials: a ? "omit" : "include",
|
|
58
|
+
headers: a ? { Authorization: `Bearer ${a}` } : {}
|
|
59
|
+
}).catch(() => {
|
|
60
|
+
});
|
|
61
|
+
} catch {
|
|
62
|
+
}
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
r.request(w(`${p(t, e)}/lock/release`, {})).catch(() => {
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
[r, t, _]
|
|
69
|
+
), I = v(
|
|
70
|
+
async (e) => {
|
|
71
|
+
if (!c || (s.current && (clearTimeout(s.current), s.current = null), u.current === e)) return !0;
|
|
72
|
+
const n = u.current;
|
|
73
|
+
n && i(n);
|
|
74
|
+
const d = m.get(e);
|
|
75
|
+
if (d && !d.is_mine) return !1;
|
|
76
|
+
try {
|
|
77
|
+
await r.request(
|
|
78
|
+
w(`${p(t, e)}/lock`, { beat_ms: C })
|
|
79
|
+
);
|
|
80
|
+
} catch (a) {
|
|
81
|
+
const f = U(a);
|
|
82
|
+
return f !== void 0 ? (k((L) => new Map(L).set(e, f)), b((L) => L + 1), !1) : !0;
|
|
83
|
+
}
|
|
84
|
+
return u.current = e, R(e), k((a) => {
|
|
85
|
+
if (!a.has(e)) return a;
|
|
86
|
+
const f = new Map(a);
|
|
87
|
+
return f.delete(e), f;
|
|
88
|
+
}), _(), y.current = setInterval(() => {
|
|
89
|
+
r.request(w(`${p(t, e)}/heartbeat`, { beat_ms: C })).catch(() => {
|
|
90
|
+
});
|
|
91
|
+
}, C), !0;
|
|
92
|
+
},
|
|
93
|
+
[c, r, t, m, i, _]
|
|
94
|
+
), $ = v(
|
|
95
|
+
(e = {}) => {
|
|
96
|
+
const n = u.current;
|
|
97
|
+
if (n) {
|
|
98
|
+
if (s.current && clearTimeout(s.current), e.now) {
|
|
99
|
+
s.current = null, i(n);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
s.current = setTimeout(() => {
|
|
103
|
+
s.current = null, u.current === n && i(n);
|
|
104
|
+
}, H);
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
[i]
|
|
108
|
+
);
|
|
109
|
+
S(() => {
|
|
110
|
+
if (!c || typeof document > "u") return;
|
|
111
|
+
const e = () => {
|
|
112
|
+
document.visibilityState === "hidden" && u.current && i(u.current, !0);
|
|
113
|
+
}, n = () => {
|
|
114
|
+
u.current && i(u.current, !0);
|
|
115
|
+
};
|
|
116
|
+
return document.addEventListener("visibilitychange", e), window.addEventListener("pagehide", n), () => {
|
|
117
|
+
document.removeEventListener("visibilitychange", e), window.removeEventListener("pagehide", n);
|
|
118
|
+
};
|
|
119
|
+
}, [c, i]), S(
|
|
120
|
+
() => () => {
|
|
121
|
+
s.current && clearTimeout(s.current), u.current && i(u.current);
|
|
122
|
+
},
|
|
123
|
+
[i]
|
|
124
|
+
);
|
|
125
|
+
const N = v(
|
|
126
|
+
(e) => V(m, e, h),
|
|
127
|
+
[m, h]
|
|
128
|
+
);
|
|
129
|
+
return c ? { enabled: !0, view: N, claim: I, release: $, held: T } : D;
|
|
130
|
+
}
|
|
131
|
+
const Y = K(!1);
|
|
132
|
+
export {
|
|
133
|
+
C as LINE_LOCK_BEAT_MS,
|
|
134
|
+
H as LINE_LOCK_LEAVE_MS,
|
|
135
|
+
P as LINE_LOCK_RECHECK_MS,
|
|
136
|
+
Y as LineLockContext,
|
|
137
|
+
Q as lineLockMoves,
|
|
138
|
+
V as lineLockView,
|
|
139
|
+
U as lockRefusalHolder,
|
|
140
|
+
X as useLineLocks
|
|
141
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const s = /^[A-Za-z_][A-Za-z0-9_]*\.[A-Za-z_][A-Za-z0-9_]*$/;
|
|
2
|
+
function l(e) {
|
|
3
|
+
if (e && typeof e == "object" && !Array.isArray(e)) return e;
|
|
4
|
+
if (typeof e != "string" || e.trim() === "") return null;
|
|
5
|
+
try {
|
|
6
|
+
const t = JSON.parse(e);
|
|
7
|
+
return t && typeof t == "object" && !Array.isArray(t) ? t : null;
|
|
8
|
+
} catch {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function c(e, t) {
|
|
13
|
+
return `${e}.${t}`;
|
|
14
|
+
}
|
|
15
|
+
function u(e) {
|
|
16
|
+
var i;
|
|
17
|
+
const t = l((i = l(e)) == null ? void 0 : i.line_split);
|
|
18
|
+
if ((t == null ? void 0 : t.enabled) !== !0 || !Array.isArray(t.relations)) return [];
|
|
19
|
+
const n = [];
|
|
20
|
+
for (const o of t.relations) {
|
|
21
|
+
const r = typeof o == "string" ? o.trim() : "";
|
|
22
|
+
s.test(r) && !n.includes(r) && n.push(r);
|
|
23
|
+
}
|
|
24
|
+
return n.slice(0, 10);
|
|
25
|
+
}
|
|
26
|
+
function a(e, t, n) {
|
|
27
|
+
return u(e).includes(c(t, n));
|
|
28
|
+
}
|
|
29
|
+
function f(e) {
|
|
30
|
+
return e.selectedUnsaved > 0 ? "Save the new lines first — only saved lines can move." : e.unsavedEdits ? "Save your line changes first." : e.selectedSaved === 0 ? "Tick the lines to move." : e.selectedSaved >= e.totalSaved ? "Leave at least one line here. To move every line, duplicate the record instead." : null;
|
|
31
|
+
}
|
|
32
|
+
function d(e, t) {
|
|
33
|
+
return `/record-split/${encodeURIComponent(e)}/${encodeURIComponent(String(t))}`;
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
a as canOfferLineSplit,
|
|
37
|
+
f as lineSplitBlocker,
|
|
38
|
+
c as lineSplitKey,
|
|
39
|
+
d as lineSplitPath,
|
|
40
|
+
u as lineSplitRelations
|
|
41
|
+
};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { useQueryClient as k } from "@tanstack/react-query";
|
|
2
|
+
import { useRef as g, useState as w, useMemo as C, useCallback as E, useEffect as _ } from "react";
|
|
3
|
+
import { useNivaroClient as R } from "../context.js";
|
|
4
|
+
import { get as M } from "./commands.js";
|
|
5
|
+
import { useLiveCollection as T } from "./live.js";
|
|
6
|
+
function j(e, t = Date.now()) {
|
|
7
|
+
const l = t - new Date(e).getTime();
|
|
8
|
+
if (!Number.isFinite(l) || l < 6e4) return "just now";
|
|
9
|
+
const i = Math.floor(l / 6e4);
|
|
10
|
+
if (i < 60) return `${i} min ago`;
|
|
11
|
+
const r = Math.floor(i / 60);
|
|
12
|
+
return r < 48 ? `${r} hour${r === 1 ? "" : "s"} ago` : `${Math.floor(r / 24)} days ago`;
|
|
13
|
+
}
|
|
14
|
+
const D = /^(is_)?(active|enabled|available|open)$/i, W = [
|
|
15
|
+
[/^(is_)?(inactive|disabled|deactivated)$/i, "deactivated"],
|
|
16
|
+
[/^(is_)?archived$/i, "archived"],
|
|
17
|
+
[/^(is_)?retired$/i, "retired"],
|
|
18
|
+
[/^(is_)?closed$/i, "closed"],
|
|
19
|
+
[/^(is_)?(hidden|hide_from_pickers|picker_hidden)$/i, "hidden from pickers"]
|
|
20
|
+
];
|
|
21
|
+
function P(e, t, l = Date.now(), i) {
|
|
22
|
+
var $;
|
|
23
|
+
const r = (($ = t == null ? void 0 : t.label) == null ? void 0 : $.trim()) || "", o = (r && !/^#\S+$/.test(r) ? r : "") || (i == null ? void 0 : i.trim()) || r || e.trim() || "The linked record";
|
|
24
|
+
if (!t) return `${o} is no longer offered here`;
|
|
25
|
+
const m = `${j(t.at, l)}${t.by ? ` by ${t.by}` : ""}`;
|
|
26
|
+
if (t.kind === "hidden") return `${o} was hidden from pickers ${m}`;
|
|
27
|
+
for (const s of t.fields) {
|
|
28
|
+
if (s.value === !1 && D.test(s.field)) return `${o} was deactivated ${m}`;
|
|
29
|
+
if (s.value === !0) {
|
|
30
|
+
for (const [h, v] of W)
|
|
31
|
+
if (h.test(s.field)) return `${o} was ${v} ${m}`;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const p = t.fields.find(
|
|
35
|
+
(s) => typeof s.value == "string" && s.value.trim() && /(^|_)(status|state)$/i.test(s.field)
|
|
36
|
+
);
|
|
37
|
+
if (p) return `${o} was set to ${String(p.value).trim()} ${m}`;
|
|
38
|
+
const b = t.fields.map((s) => s.label).filter(Boolean);
|
|
39
|
+
return `${o} was changed ${m}${b.length ? ` (${b.slice(0, 3).join(", ")})` : ""}`;
|
|
40
|
+
}
|
|
41
|
+
function H(e) {
|
|
42
|
+
return [
|
|
43
|
+
["relation-single", e.collection, e.id],
|
|
44
|
+
["relation-avail", e.collection, e.id]
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
function K(e, t, l, i) {
|
|
48
|
+
const r = new Set([...l].map((o) => o.toUpperCase()));
|
|
49
|
+
return e.filter(
|
|
50
|
+
(o) => o.collection === t && (i || r.has(o.id.toUpperCase()))
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
const O = /* @__PURE__ */ new Set(["$picker", "$state"]);
|
|
54
|
+
function q(e) {
|
|
55
|
+
return !e || e.length === 0 ? !0 : e.some((t) => !t.startsWith("$") || O.has(t));
|
|
56
|
+
}
|
|
57
|
+
const A = 1e3;
|
|
58
|
+
function L(e) {
|
|
59
|
+
for (const [, t] of e) {
|
|
60
|
+
if (!t || typeof t != "object") continue;
|
|
61
|
+
const l = Object.entries(t).filter(([i, r]) => i !== "id" && (typeof r == "string" || typeof r == "number")).map(([, i]) => String(i).trim()).filter((i) => i && !/^\d{4}-\d{2}-\d{2}T/.test(i) && !/^-?\d+(\.\d+)?$/.test(i));
|
|
62
|
+
if (l.length > 0) return l[0];
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
function z(e) {
|
|
67
|
+
const t = R(), l = k(), i = g((/* @__PURE__ */ new Date()).toISOString()), r = g(e.targets);
|
|
68
|
+
r.current = e.targets;
|
|
69
|
+
const o = g(e.onRecheck);
|
|
70
|
+
o.current = e.onRecheck;
|
|
71
|
+
const m = g(e.labels);
|
|
72
|
+
m.current = e.labels;
|
|
73
|
+
const [p, b] = w({}), $ = g(/* @__PURE__ */ new Map()), s = g(null), h = C(
|
|
74
|
+
() => [...new Set(e.targets.map((c) => c.collection))].sort(),
|
|
75
|
+
[e.targets]
|
|
76
|
+
), v = E(() => {
|
|
77
|
+
var f;
|
|
78
|
+
s.current = null;
|
|
79
|
+
const c = [...$.current.values()];
|
|
80
|
+
if ($.current.clear(), c.length !== 0) {
|
|
81
|
+
for (const n of c)
|
|
82
|
+
for (const a of H(n)) l.invalidateQueries({ queryKey: a });
|
|
83
|
+
(f = o.current) == null || f.call(o, c.map((n) => n.field));
|
|
84
|
+
for (const n of c)
|
|
85
|
+
t.request(
|
|
86
|
+
M("/picker-exclusions/linked-change", {
|
|
87
|
+
collection: n.collection,
|
|
88
|
+
item_id: n.id,
|
|
89
|
+
since: i.current
|
|
90
|
+
})
|
|
91
|
+
).then((a) => a.data ?? null).catch(() => null).then((a) => {
|
|
92
|
+
const d = r.current.find((u) => u.field === n.field);
|
|
93
|
+
!d || d.id !== n.id || d.collection !== n.collection || b((u) => ({
|
|
94
|
+
...u,
|
|
95
|
+
[n.field]: {
|
|
96
|
+
change: a,
|
|
97
|
+
label: m.current(n.field),
|
|
98
|
+
shown: L(
|
|
99
|
+
l.getQueriesData({ queryKey: ["relation-single", n.collection, n.id] })
|
|
100
|
+
),
|
|
101
|
+
target: n.id
|
|
102
|
+
}
|
|
103
|
+
}));
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}, [t, l]);
|
|
107
|
+
T(
|
|
108
|
+
e.enabled ? h : null,
|
|
109
|
+
(c) => {
|
|
110
|
+
const f = /* @__PURE__ */ new Map();
|
|
111
|
+
for (const n of c.events) {
|
|
112
|
+
if (!q(n.changed_fields)) continue;
|
|
113
|
+
const a = String(n.collection), d = f.get(a) ?? /* @__PURE__ */ new Set();
|
|
114
|
+
d.add(String(n.item)), f.set(a, d);
|
|
115
|
+
}
|
|
116
|
+
for (const [n, a] of f) {
|
|
117
|
+
const d = K(r.current, n, a, a.has("*"));
|
|
118
|
+
for (const u of d) $.current.set(u.field, u);
|
|
119
|
+
}
|
|
120
|
+
$.current.size > 0 && !s.current && (s.current = setTimeout(v, A));
|
|
121
|
+
},
|
|
122
|
+
{ enabled: e.enabled, debounceMs: 400 }
|
|
123
|
+
), _(
|
|
124
|
+
() => () => {
|
|
125
|
+
s.current && clearTimeout(s.current);
|
|
126
|
+
},
|
|
127
|
+
[]
|
|
128
|
+
);
|
|
129
|
+
const y = e.targets.map((c) => `${c.field}=${c.collection}:${c.id}`).join("|");
|
|
130
|
+
return _(() => {
|
|
131
|
+
b((c) => {
|
|
132
|
+
let f = !1;
|
|
133
|
+
const n = { ...c };
|
|
134
|
+
for (const [a, d] of Object.entries(c)) {
|
|
135
|
+
const u = r.current.find((S) => S.field === a);
|
|
136
|
+
(!u || u.id !== d.target) && (delete n[a], f = !0);
|
|
137
|
+
}
|
|
138
|
+
return f ? n : c;
|
|
139
|
+
});
|
|
140
|
+
}, [y]), p;
|
|
141
|
+
}
|
|
142
|
+
export {
|
|
143
|
+
j as agoWords,
|
|
144
|
+
q as eventMatters,
|
|
145
|
+
P as linkedChangeSentence,
|
|
146
|
+
H as linkedReadKeys,
|
|
147
|
+
L as shownLabel,
|
|
148
|
+
K as targetsHit,
|
|
149
|
+
z as useLinkedRecordWatch
|
|
150
|
+
};
|
|
@@ -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
|
+
};
|