@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,244 @@
|
|
|
1
|
+
import { jsxs as o, jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import { useQueryClient as E, useQuery as L, useMutation as $ } from "@tanstack/react-query";
|
|
3
|
+
import { CalendarCheck as K, CalendarX as Q, Loader2 as V, CalendarClock as j } from "lucide-react";
|
|
4
|
+
import { useMemo as R, useState as O, useId as B } from "react";
|
|
5
|
+
import { useNivaroClient as F } from "../../context.js";
|
|
6
|
+
import { get as H, del as W, patch as X, post as Y } from "../../lib/commands.js";
|
|
7
|
+
import { useDeadlineNow as z } from "../../lib/deadline-ticker.js";
|
|
8
|
+
import { toastError as S } from "../../lib/error-toast.js";
|
|
9
|
+
import { useLiveRecord as G, batchTouches as J, LIVE_ASPECTS as Z } from "../../lib/live.js";
|
|
10
|
+
import { readableRecent as w, chipOf as ee, whenText as g, countdownPart as N, fullSentence as te, changeSentence as ae, isDue as ne } from "../../lib/scheduled-countdown.js";
|
|
11
|
+
import { cn as P, titleCase as de } from "../../lib/utils.js";
|
|
12
|
+
import { ConfirmButton as D } from "../profile/primitives.js";
|
|
13
|
+
import { Input as re } from "../ui/input.js";
|
|
14
|
+
import { Popover as se, PopoverTrigger as le, PopoverContent as ie } from "../ui/popover.js";
|
|
15
|
+
import { formatDisplayValue as oe } from "./GroupSection.js";
|
|
16
|
+
function ce(e, t) {
|
|
17
|
+
return ["scheduled-changes", e, t, "recent"];
|
|
18
|
+
}
|
|
19
|
+
function ue(e) {
|
|
20
|
+
const t = new Date(e);
|
|
21
|
+
if (Number.isNaN(t.getTime())) return "";
|
|
22
|
+
const n = (l) => String(l).padStart(2, "0");
|
|
23
|
+
return `${t.getFullYear()}-${n(t.getMonth() + 1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`;
|
|
24
|
+
}
|
|
25
|
+
const me = {
|
|
26
|
+
pending: "border-slate-200 bg-slate-50 text-slate-600 hover:bg-slate-100 dark:border-border dark:bg-muted dark:text-slate-300 dark:hover:bg-muted/70",
|
|
27
|
+
applying: "border-sky-200 bg-sky-50 text-sky-800 hover:bg-sky-100 dark:border-sky-500/30 dark:bg-sky-500/10 dark:text-sky-300 dark:hover:bg-sky-500/15",
|
|
28
|
+
"waiting-admin": "border-amber-200 bg-amber-50 text-amber-800 hover:bg-amber-100 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-300 dark:hover:bg-amber-500/15",
|
|
29
|
+
applied: "border-emerald-200 bg-emerald-50 text-emerald-700 hover:bg-emerald-100 dark:border-emerald-500/30 dark:bg-emerald-500/10 dark:text-emerald-400 dark:hover:bg-emerald-500/15",
|
|
30
|
+
failed: "border-red-200 bg-red-50 text-red-700 hover:bg-red-100 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-400 dark:hover:bg-red-500/15"
|
|
31
|
+
};
|
|
32
|
+
function qe({
|
|
33
|
+
collection: e,
|
|
34
|
+
itemId: t,
|
|
35
|
+
fields: n,
|
|
36
|
+
relations: l
|
|
37
|
+
}) {
|
|
38
|
+
const u = F(), h = E(), b = ce(e, t), { data: x } = L({
|
|
39
|
+
queryKey: b,
|
|
40
|
+
queryFn: () => u.request(
|
|
41
|
+
H(`/scheduled-changes/${e}/${encodeURIComponent(t)}`, {
|
|
42
|
+
status: "recent"
|
|
43
|
+
})
|
|
44
|
+
).then((a) => a.data ?? []).catch(() => []),
|
|
45
|
+
staleTime: 6e4
|
|
46
|
+
});
|
|
47
|
+
G(
|
|
48
|
+
e,
|
|
49
|
+
t,
|
|
50
|
+
(a) => {
|
|
51
|
+
J(a, Z.scheduled) && h.invalidateQueries({ queryKey: b });
|
|
52
|
+
},
|
|
53
|
+
{ includeOwn: !0, debounceMs: 300 }
|
|
54
|
+
);
|
|
55
|
+
const c = R(() => w(x, n), [x, n]), m = z(c.length > 0), [f, k] = O(!1), y = R(() => new Map((n ?? []).map((a) => [a.field, a])), [n]), v = (a) => (l ?? []).some(
|
|
56
|
+
(p) => p.many_collection === e && p.many_field === a && !p.junction_field
|
|
57
|
+
), _ = (a) => {
|
|
58
|
+
var p;
|
|
59
|
+
return ((p = y.get(a)) == null ? void 0 : p.label) || de(a.replace(/_/g, " "));
|
|
60
|
+
}, C = (a, p) => v(a) ? "a new value" : oe(p, y.get(a)), r = (a) => ae(a.changes ?? {}, _, C), q = ee(c, m);
|
|
61
|
+
if (!q) return null;
|
|
62
|
+
const { kind: s, row: i } = q, M = c.filter((a) => a.status === "pending" || a.status === "applying").length, I = s === "pending" || s === "applying" ? M - 1 : 0, U = s === "applied" ? K : s === "failed" ? Q : s === "applying" ? V : j, A = s === "pending" ? `${r(i)} · Applies at ${g(i.scheduled_at, m)} (${N(i.scheduled_at, m)})` : s === "applying" ? `${r(i)} · Applying now…` : s === "waiting-admin" ? `${r(i)} · ${N(i.scheduled_at, m)}, waiting for an administrator` : s === "applied" ? `Applied: ${r(i)}` : `Failed — ${i.error_message || "not applied"}`;
|
|
63
|
+
return /* @__PURE__ */ o(se, { open: f, onOpenChange: k, children: [
|
|
64
|
+
/* @__PURE__ */ d(le, { asChild: !0, children: /* @__PURE__ */ o(
|
|
65
|
+
"button",
|
|
66
|
+
{
|
|
67
|
+
type: "button",
|
|
68
|
+
"data-scheduled-chip": !0,
|
|
69
|
+
"data-kind": s,
|
|
70
|
+
"aria-live": "polite",
|
|
71
|
+
"data-tip": s === "pending" ? te(r(i), g(i.scheduled_at, m), i.created_by_name) : s === "failed" ? `${r(i)} — not applied: ${i.error_message ?? ""}` : void 0,
|
|
72
|
+
className: P(
|
|
73
|
+
"inline-flex max-w-[360px] items-center gap-1 rounded-full border px-1.5 py-px text-[9.5px] font-medium transition-colors duration-300",
|
|
74
|
+
me[s]
|
|
75
|
+
),
|
|
76
|
+
children: [
|
|
77
|
+
/* @__PURE__ */ d(
|
|
78
|
+
U,
|
|
79
|
+
{
|
|
80
|
+
"aria-hidden": !0,
|
|
81
|
+
className: P(
|
|
82
|
+
"h-2.5 w-2.5 shrink-0",
|
|
83
|
+
s === "pending" && "text-nvr-cyan",
|
|
84
|
+
s === "applying" && "motion-safe:animate-spin"
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
),
|
|
88
|
+
/* @__PURE__ */ d("span", { className: "truncate tabular-nums", children: A }),
|
|
89
|
+
I > 0 && /* @__PURE__ */ o("span", { className: "shrink-0 opacity-70", children: [
|
|
90
|
+
"+",
|
|
91
|
+
I
|
|
92
|
+
] })
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
) }),
|
|
96
|
+
/* @__PURE__ */ o(ie, { align: "start", className: "w-[340px] p-0", "data-scheduled-panel": !0, children: [
|
|
97
|
+
/* @__PURE__ */ d("div", { className: "border-b border-slate-100 px-3 py-2 dark:border-border", children: /* @__PURE__ */ d("p", { className: "text-[12.5px] font-semibold text-slate-800 dark:text-slate-100", children: c.length === 1 ? "Scheduled change" : `${c.length} scheduled changes` }) }),
|
|
98
|
+
/* @__PURE__ */ d("ul", { className: "max-h-[320px] divide-y divide-slate-100 overflow-y-auto dark:divide-border", children: c.map((a) => /* @__PURE__ */ d(
|
|
99
|
+
he,
|
|
100
|
+
{
|
|
101
|
+
row: a,
|
|
102
|
+
now: m,
|
|
103
|
+
sentence: r(a),
|
|
104
|
+
onChanged: () => void h.invalidateQueries({ queryKey: b })
|
|
105
|
+
},
|
|
106
|
+
a.id
|
|
107
|
+
)) })
|
|
108
|
+
] })
|
|
109
|
+
] });
|
|
110
|
+
}
|
|
111
|
+
function pe({ row: e, now: t }) {
|
|
112
|
+
const n = e.status ?? "pending", l = e.executed_at ? g(e.executed_at, t) : null;
|
|
113
|
+
if (n === "pending" || n === "applying") {
|
|
114
|
+
const u = ne(e.scheduled_at, t), h = n === "applying" || u && e.auto_apply !== !1 ? `${g(e.scheduled_at, t)} · applying now…` : u ? `${g(e.scheduled_at, t)} · ${N(e.scheduled_at, t)} — waiting for an administrator` : `Applies at ${g(e.scheduled_at, t)} · ${N(e.scheduled_at, t)}`;
|
|
115
|
+
return /* @__PURE__ */ d(
|
|
116
|
+
"p",
|
|
117
|
+
{
|
|
118
|
+
className: P(
|
|
119
|
+
"mt-0.5 text-[11.5px] tabular-nums",
|
|
120
|
+
u && e.auto_apply === !1 ? "text-amber-700 dark:text-amber-300" : "text-slate-500 dark:text-slate-400"
|
|
121
|
+
),
|
|
122
|
+
children: h
|
|
123
|
+
}
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
return n === "executed" ? /* @__PURE__ */ o("p", { className: "mt-0.5 text-[11.5px] tabular-nums text-emerald-700 dark:text-emerald-400", children: [
|
|
127
|
+
"Applied",
|
|
128
|
+
l ? ` at ${l}` : "",
|
|
129
|
+
e.applied_on_time === !1 ? " by an administrator" : ""
|
|
130
|
+
] }) : n === "failed" ? /* @__PURE__ */ o("p", { className: "mt-0.5 text-[11.5px] text-red-700 dark:text-red-400", children: [
|
|
131
|
+
"Not applied",
|
|
132
|
+
l ? ` (${l})` : "",
|
|
133
|
+
": ",
|
|
134
|
+
e.error_message || "it was refused",
|
|
135
|
+
". Nothing on the record was changed."
|
|
136
|
+
] }) : /* @__PURE__ */ o("p", { className: "mt-0.5 text-[11.5px] tabular-nums text-slate-500 dark:text-slate-400", children: [
|
|
137
|
+
"Undone",
|
|
138
|
+
l ? ` at ${l}` : ""
|
|
139
|
+
] });
|
|
140
|
+
}
|
|
141
|
+
const T = "rounded px-1.5 py-0.5 text-[11.5px] font-medium text-slate-600 hover:bg-muted dark:text-slate-300";
|
|
142
|
+
function he({
|
|
143
|
+
row: e,
|
|
144
|
+
now: t,
|
|
145
|
+
sentence: n,
|
|
146
|
+
onChanged: l
|
|
147
|
+
}) {
|
|
148
|
+
const u = F(), h = B(), [b, x] = O(!1), [c, m] = O(() => ue(e.scheduled_at)), f = e.status ?? "pending", k = $({
|
|
149
|
+
mutationFn: () => u.request(W(`/scheduled-changes/${encodeURIComponent(e.id)}`)),
|
|
150
|
+
onSuccess: l,
|
|
151
|
+
onError: (r) => S(r, "Could not cancel the change")
|
|
152
|
+
}), y = $({
|
|
153
|
+
mutationFn: () => u.request(
|
|
154
|
+
X(`/scheduled-changes/${encodeURIComponent(e.id)}`, {
|
|
155
|
+
// datetime-local is the viewer's local time; the API stores UTC.
|
|
156
|
+
scheduled_at: new Date(c).toISOString()
|
|
157
|
+
})
|
|
158
|
+
),
|
|
159
|
+
onSuccess: () => {
|
|
160
|
+
x(!1), l();
|
|
161
|
+
},
|
|
162
|
+
onError: (r) => S(r, "Could not move the change")
|
|
163
|
+
}), v = $({
|
|
164
|
+
mutationFn: () => u.request(Y(`/scheduled-changes/${encodeURIComponent(e.id)}/undo`, {})),
|
|
165
|
+
onSuccess: l,
|
|
166
|
+
onError: (r) => S(r, "Could not undo the change")
|
|
167
|
+
}), _ = c !== "" && !Number.isNaN(new Date(c).getTime()), C = f === "executed" && e.can_undo === !0 && !!e.undo_until && new Date(e.undo_until).getTime() > t;
|
|
168
|
+
return /* @__PURE__ */ o("li", { className: "px-3 py-2.5", "data-scheduled-row": e.id, "data-status": f, children: [
|
|
169
|
+
/* @__PURE__ */ d("p", { className: "text-[12.5px] font-medium leading-snug text-slate-800 dark:text-slate-100", children: n }),
|
|
170
|
+
/* @__PURE__ */ d(pe, { row: e, now: t }),
|
|
171
|
+
e.created_by_name && /* @__PURE__ */ o("p", { className: "mt-0.5 text-[11px] text-slate-500 dark:text-slate-400", children: [
|
|
172
|
+
"Scheduled by ",
|
|
173
|
+
e.created_by_name
|
|
174
|
+
] }),
|
|
175
|
+
e.can_manage && f === "pending" && (b ? /* @__PURE__ */ o("div", { className: "mt-2 flex items-center gap-1.5", children: [
|
|
176
|
+
/* @__PURE__ */ d("label", { htmlFor: h, className: "sr-only", children: "New time" }),
|
|
177
|
+
/* @__PURE__ */ d(
|
|
178
|
+
re,
|
|
179
|
+
{
|
|
180
|
+
id: h,
|
|
181
|
+
type: "datetime-local",
|
|
182
|
+
value: c,
|
|
183
|
+
onChange: (r) => m(r.target.value),
|
|
184
|
+
className: "h-7 flex-1 text-[12px]"
|
|
185
|
+
}
|
|
186
|
+
),
|
|
187
|
+
/* @__PURE__ */ d(
|
|
188
|
+
"button",
|
|
189
|
+
{
|
|
190
|
+
type: "button",
|
|
191
|
+
disabled: !_ || y.isPending,
|
|
192
|
+
onClick: () => y.mutate(),
|
|
193
|
+
className: "h-7 rounded-md bg-nvr-cyan px-2.5 text-[11.5px] font-medium text-white disabled:opacity-50",
|
|
194
|
+
children: "Save"
|
|
195
|
+
}
|
|
196
|
+
),
|
|
197
|
+
/* @__PURE__ */ d(
|
|
198
|
+
"button",
|
|
199
|
+
{
|
|
200
|
+
type: "button",
|
|
201
|
+
onClick: () => x(!1),
|
|
202
|
+
className: "h-7 rounded-md px-2 text-[11.5px] text-slate-500 hover:bg-muted dark:text-slate-400",
|
|
203
|
+
children: "Back"
|
|
204
|
+
}
|
|
205
|
+
)
|
|
206
|
+
] }) : /* @__PURE__ */ o("div", { className: "mt-1.5 flex items-center gap-1", children: [
|
|
207
|
+
/* @__PURE__ */ d("button", { type: "button", onClick: () => x(!0), className: T, children: "Move…" }),
|
|
208
|
+
/* @__PURE__ */ d(
|
|
209
|
+
D,
|
|
210
|
+
{
|
|
211
|
+
onConfirm: () => k.mutate(),
|
|
212
|
+
disabled: k.isPending,
|
|
213
|
+
title: "Cancel this change",
|
|
214
|
+
confirmLabel: "Cancel it?",
|
|
215
|
+
className: T,
|
|
216
|
+
armedClassName: "rounded px-1.5 py-0.5 text-[11.5px] font-medium text-red-600 bg-red-50 dark:bg-red-500/10 dark:text-red-400",
|
|
217
|
+
children: "Cancel change"
|
|
218
|
+
}
|
|
219
|
+
)
|
|
220
|
+
] })),
|
|
221
|
+
C && /* @__PURE__ */ o("div", { className: "mt-1.5 flex items-center gap-2", children: [
|
|
222
|
+
/* @__PURE__ */ d(
|
|
223
|
+
D,
|
|
224
|
+
{
|
|
225
|
+
onConfirm: () => v.mutate(),
|
|
226
|
+
disabled: v.isPending,
|
|
227
|
+
title: "Put back the values this change replaced",
|
|
228
|
+
confirmLabel: "Undo it?",
|
|
229
|
+
className: T,
|
|
230
|
+
armedClassName: "rounded px-1.5 py-0.5 text-[11.5px] font-medium text-amber-800 bg-amber-50 dark:bg-amber-500/10 dark:text-amber-300",
|
|
231
|
+
children: "Undo"
|
|
232
|
+
}
|
|
233
|
+
),
|
|
234
|
+
/* @__PURE__ */ o("span", { className: "text-[11px] text-slate-500 dark:text-slate-400", children: [
|
|
235
|
+
"until ",
|
|
236
|
+
g(e.undo_until, t)
|
|
237
|
+
] })
|
|
238
|
+
] })
|
|
239
|
+
] });
|
|
240
|
+
}
|
|
241
|
+
export {
|
|
242
|
+
qe as ScheduledChangeChip,
|
|
243
|
+
ce as scheduledChangesKey
|
|
244
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { jsx as a, jsxs as c } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as g } from "react";
|
|
3
|
+
import { useFieldEditors as x, sectionPresence as u, sectionPresenceText as b } from "../../lib/co-edit.js";
|
|
4
|
+
import { cursorColor as k } from "../../lib/grid-cursors.js";
|
|
5
|
+
function w(t) {
|
|
6
|
+
return t.split(/\s+/).filter(Boolean).map((i) => i[0]).join("").slice(0, 2).toUpperCase() || "?";
|
|
7
|
+
}
|
|
8
|
+
function y({ person: t, size: i = 18 }) {
|
|
9
|
+
return /* @__PURE__ */ a(
|
|
10
|
+
"span",
|
|
11
|
+
{
|
|
12
|
+
className: "inline-flex shrink-0 items-center justify-center rounded-full border-[1.5px] bg-slate-100 font-semibold text-slate-700 ring-2 ring-white dark:bg-slate-700 dark:text-slate-100 dark:ring-card",
|
|
13
|
+
style: {
|
|
14
|
+
width: i,
|
|
15
|
+
height: i,
|
|
16
|
+
fontSize: Math.round(i * 0.45),
|
|
17
|
+
borderColor: k(t.id)
|
|
18
|
+
},
|
|
19
|
+
"aria-hidden": !0,
|
|
20
|
+
children: w(t.name)
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
function v({
|
|
25
|
+
collection: t,
|
|
26
|
+
itemId: i,
|
|
27
|
+
fields: m,
|
|
28
|
+
relations: h,
|
|
29
|
+
label: f
|
|
30
|
+
}) {
|
|
31
|
+
const o = x(t, i), p = Object.keys(o).length > 0, e = g(() => {
|
|
32
|
+
if (!p) return [];
|
|
33
|
+
const r = new Set(m.map((n) => n.field)), s = new Set(
|
|
34
|
+
h.filter(
|
|
35
|
+
(n) => n.one_collection === t && !!n.one_field && r.has(n.one_field) && !!n.many_collection
|
|
36
|
+
).map((n) => String(n.many_collection))
|
|
37
|
+
);
|
|
38
|
+
return u(o, r, s);
|
|
39
|
+
}, [p, o, m, h, t]), d = b(e, f);
|
|
40
|
+
if (!d) return null;
|
|
41
|
+
const l = e.slice(0, 3);
|
|
42
|
+
return /* @__PURE__ */ c(
|
|
43
|
+
"span",
|
|
44
|
+
{
|
|
45
|
+
"data-section-presence": "",
|
|
46
|
+
"data-tip": d,
|
|
47
|
+
role: "img",
|
|
48
|
+
"aria-label": d,
|
|
49
|
+
className: "nvr-fade-in inline-flex shrink-0 items-center gap-1.5",
|
|
50
|
+
children: [
|
|
51
|
+
/* @__PURE__ */ c("span", { className: "flex items-center pl-1", "aria-hidden": !0, children: [
|
|
52
|
+
l.map((r, s) => (
|
|
53
|
+
// The first face sits on top; the next tucks behind it, initials still readable.
|
|
54
|
+
/* @__PURE__ */ a(
|
|
55
|
+
"span",
|
|
56
|
+
{
|
|
57
|
+
className: s > 0 ? "-ml-1.5 flex" : "flex",
|
|
58
|
+
style: { zIndex: l.length - s, position: "relative" },
|
|
59
|
+
children: /* @__PURE__ */ a(y, { person: r, size: 20 })
|
|
60
|
+
},
|
|
61
|
+
r.id
|
|
62
|
+
)
|
|
63
|
+
)),
|
|
64
|
+
e.length > l.length && /* @__PURE__ */ c("span", { className: "relative -ml-1.5 inline-flex h-5 min-w-5 items-center justify-center rounded-full bg-slate-100 px-1 text-[9px] font-semibold text-slate-600 ring-2 ring-white dark:bg-slate-700 dark:text-slate-200 dark:ring-card", children: [
|
|
65
|
+
"+",
|
|
66
|
+
e.length - l.length
|
|
67
|
+
] })
|
|
68
|
+
] }),
|
|
69
|
+
/* @__PURE__ */ a("span", { "aria-hidden": !0, className: "hidden text-[11px] text-slate-500 sm:inline dark:text-slate-400", children: e.length === 1 ? `${e[0].name} is here` : e.length === 2 ? `${e[0].name.split(" ")[0]} and ${e[1].name.split(" ")[0]} are here` : `${e.length} people here` })
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
export {
|
|
75
|
+
y as CoViewerAvatar,
|
|
76
|
+
v as SectionPresence,
|
|
77
|
+
w as initialsOf
|
|
78
|
+
};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { jsxs as t, jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { useQueryClient as K, useQuery as O } from "@tanstack/react-query";
|
|
3
|
+
import { Split as L, Loader2 as P } from "lucide-react";
|
|
4
|
+
import { useState as $ } from "react";
|
|
5
|
+
import { toast as Q } from "sonner";
|
|
6
|
+
import { useNivaroClient as T, useItemNavigation as j } from "../../context.js";
|
|
7
|
+
import { post as _ } from "../../lib/commands.js";
|
|
8
|
+
import { toastError as A } from "../../lib/error-toast.js";
|
|
9
|
+
import { canOfferLineSplit as E, lineSplitBlocker as z, lineSplitPath as D, lineSplitKey as G } from "../../lib/line-split.js";
|
|
10
|
+
import { fetchCollectionMeta as H, queryKeys as J } from "../../lib/query-keys.js";
|
|
11
|
+
import { cn as R } from "../../lib/utils.js";
|
|
12
|
+
import { Popover as V, PopoverTrigger as W, PopoverContent as X } from "../ui/popover.js";
|
|
13
|
+
function Y(e) {
|
|
14
|
+
const r = typeof (e == null ? void 0 : e.singular) == "string" ? e.singular.trim() : "";
|
|
15
|
+
return r ? r.toLowerCase() : "record";
|
|
16
|
+
}
|
|
17
|
+
const c = (e, r) => `${e} ${r}${e === 1 ? "" : "s"}`;
|
|
18
|
+
function le({
|
|
19
|
+
parentCollection: e,
|
|
20
|
+
parentId: r,
|
|
21
|
+
lineCollection: m,
|
|
22
|
+
linkField: p,
|
|
23
|
+
selectedIds: o,
|
|
24
|
+
selectedUnsaved: f,
|
|
25
|
+
totalSaved: x,
|
|
26
|
+
unsavedEdits: M,
|
|
27
|
+
onMoved: S
|
|
28
|
+
}) {
|
|
29
|
+
const y = T(), g = K(), { open: q } = j(), [v, u] = $(!1), [a, w] = $(!1), { data: h } = O({
|
|
30
|
+
queryKey: J.collectionMeta(e),
|
|
31
|
+
queryFn: () => H(y, e),
|
|
32
|
+
staleTime: 10 * 6e4
|
|
33
|
+
});
|
|
34
|
+
if (!h || !E(h.browser_config, m, p)) return null;
|
|
35
|
+
const n = Y(h), i = o.length + f, b = z({
|
|
36
|
+
selectedSaved: o.length,
|
|
37
|
+
selectedUnsaved: f,
|
|
38
|
+
totalSaved: x,
|
|
39
|
+
unsavedEdits: M
|
|
40
|
+
}), k = Math.max(0, x - o.length), C = async () => {
|
|
41
|
+
var l;
|
|
42
|
+
w(!0);
|
|
43
|
+
try {
|
|
44
|
+
const d = (await y.request(
|
|
45
|
+
_(D(e, r), {
|
|
46
|
+
relation: G(m, p),
|
|
47
|
+
line_ids: o
|
|
48
|
+
})
|
|
49
|
+
)).data;
|
|
50
|
+
u(!1), S(o), g.invalidateQueries({ queryKey: ["o2m-rows", m, p, r] }), g.invalidateQueries({ queryKey: ["comments-related"] });
|
|
51
|
+
const B = `a new ${n}`;
|
|
52
|
+
Q.success(`Moved ${c(d.moved, "line")} to ${B}`, {
|
|
53
|
+
description: (((l = d.link_failures) == null ? void 0 : l.length) ?? 0) > 0 ? "Some linked values did not copy — check the new one." : "Both now say where the lines went.",
|
|
54
|
+
duration: 1e4,
|
|
55
|
+
...d.readable ? {
|
|
56
|
+
action: {
|
|
57
|
+
label: `Open the new ${n}`,
|
|
58
|
+
onClick: () => q({ collection: e, itemId: String(d.id) })
|
|
59
|
+
}
|
|
60
|
+
} : {}
|
|
61
|
+
});
|
|
62
|
+
} catch (N) {
|
|
63
|
+
A(N, "The lines could not be moved");
|
|
64
|
+
} finally {
|
|
65
|
+
w(!1);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
return /* @__PURE__ */ t(V, { open: v, onOpenChange: (l) => !a && u(l), children: [
|
|
69
|
+
/* @__PURE__ */ s(W, { asChild: !0, children: /* @__PURE__ */ t(
|
|
70
|
+
"button",
|
|
71
|
+
{
|
|
72
|
+
type: "button",
|
|
73
|
+
"data-split-lines": !0,
|
|
74
|
+
"data-tip": `Move the ticked lines to a new ${n} with the same details`,
|
|
75
|
+
className: R(
|
|
76
|
+
"inline-flex h-6 items-center gap-1 rounded border px-2 font-medium transition-colors",
|
|
77
|
+
v ? "border-nvr-cyan bg-nvr-cyan/10 text-nvr-cyan" : "border-slate-200 text-slate-700 hover:border-nvr-cyan hover:text-nvr-cyan dark:border-border dark:text-slate-200"
|
|
78
|
+
),
|
|
79
|
+
children: [
|
|
80
|
+
/* @__PURE__ */ s(L, { className: "h-3 w-3 rotate-90", "aria-hidden": "true" }),
|
|
81
|
+
"Move ",
|
|
82
|
+
i,
|
|
83
|
+
" to a new ",
|
|
84
|
+
n,
|
|
85
|
+
"…"
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
) }),
|
|
89
|
+
/* @__PURE__ */ t(
|
|
90
|
+
X,
|
|
91
|
+
{
|
|
92
|
+
align: "start",
|
|
93
|
+
className: "w-[320px] max-w-[calc(100vw-2rem)] p-0",
|
|
94
|
+
"data-split-lines-panel": !0,
|
|
95
|
+
children: [
|
|
96
|
+
/* @__PURE__ */ t("div", { className: "space-y-2 p-3", children: [
|
|
97
|
+
/* @__PURE__ */ t("p", { className: "text-[13px] font-semibold text-slate-800 dark:text-foreground", children: [
|
|
98
|
+
"Move ",
|
|
99
|
+
c(i, "line"),
|
|
100
|
+
" to a new ",
|
|
101
|
+
n
|
|
102
|
+
] }),
|
|
103
|
+
/* @__PURE__ */ t("ul", { className: "space-y-1 text-[12px] leading-snug text-slate-600 dark:text-muted-foreground", children: [
|
|
104
|
+
/* @__PURE__ */ t("li", { children: [
|
|
105
|
+
"A new ",
|
|
106
|
+
n,
|
|
107
|
+
" is made with this one’s details and starts at the first step."
|
|
108
|
+
] }),
|
|
109
|
+
/* @__PURE__ */ t("li", { children: [
|
|
110
|
+
"The ticked ",
|
|
111
|
+
i === 1 ? "line moves" : "lines move",
|
|
112
|
+
" with ",
|
|
113
|
+
i === 1 ? "its" : "their",
|
|
114
|
+
" ",
|
|
115
|
+
"history. ",
|
|
116
|
+
k > 0 ? `${c(k, "line")} stay here.` : ""
|
|
117
|
+
] }),
|
|
118
|
+
/* @__PURE__ */ t("li", { children: [
|
|
119
|
+
"Both ",
|
|
120
|
+
n,
|
|
121
|
+
"s get a note naming the other."
|
|
122
|
+
] })
|
|
123
|
+
] }),
|
|
124
|
+
b && /* @__PURE__ */ s(
|
|
125
|
+
"p",
|
|
126
|
+
{
|
|
127
|
+
className: "rounded border border-amber-200 bg-amber-50 px-2 py-1.5 text-[12px] text-amber-800 dark:border-amber-800/60 dark:bg-amber-950/30 dark:text-amber-200",
|
|
128
|
+
"data-split-lines-blocker": !0,
|
|
129
|
+
children: b
|
|
130
|
+
}
|
|
131
|
+
)
|
|
132
|
+
] }),
|
|
133
|
+
/* @__PURE__ */ t("div", { className: "flex justify-end gap-2 border-t border-slate-100 px-3 py-2 dark:border-border", children: [
|
|
134
|
+
/* @__PURE__ */ s(
|
|
135
|
+
"button",
|
|
136
|
+
{
|
|
137
|
+
type: "button",
|
|
138
|
+
onClick: () => u(!1),
|
|
139
|
+
disabled: a,
|
|
140
|
+
className: "h-7 px-2 text-[12px] text-slate-500 hover:text-slate-800 dark:text-muted-foreground dark:hover:text-foreground",
|
|
141
|
+
children: "Cancel"
|
|
142
|
+
}
|
|
143
|
+
),
|
|
144
|
+
/* @__PURE__ */ t(
|
|
145
|
+
"button",
|
|
146
|
+
{
|
|
147
|
+
type: "button",
|
|
148
|
+
onClick: () => void C(),
|
|
149
|
+
disabled: a || !!b,
|
|
150
|
+
"data-split-lines-confirm": !0,
|
|
151
|
+
className: "inline-flex h-7 items-center gap-1.5 rounded-md bg-nvr-cyan px-3 text-[12px] font-semibold text-white disabled:opacity-50",
|
|
152
|
+
children: [
|
|
153
|
+
a && /* @__PURE__ */ s(P, { className: "h-3 w-3 animate-spin", "aria-hidden": "true" }),
|
|
154
|
+
a ? "Moving…" : `Move ${c(i, "line")}`
|
|
155
|
+
]
|
|
156
|
+
}
|
|
157
|
+
)
|
|
158
|
+
] })
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
)
|
|
162
|
+
] });
|
|
163
|
+
}
|
|
164
|
+
export {
|
|
165
|
+
le as SplitLinesButton
|
|
166
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { useQuery as y, useQueryClient as w } from "@tanstack/react-query";
|
|
2
|
+
import { useRef as m, useEffect as b } from "react";
|
|
3
|
+
import { useNivaroClient as h } from "../../context.js";
|
|
4
|
+
import { get as g } from "../../lib/commands.js";
|
|
5
|
+
import { useLiveCollection as q } from "../../lib/live.js";
|
|
6
|
+
import { fetchCollectionRelations as S, queryKeys as $ } from "../../lib/query-keys.js";
|
|
7
|
+
import { applyDisplayTemplate as C } from "./helpers.js";
|
|
8
|
+
const p = (e) => {
|
|
9
|
+
if (e == null || e === "") return null;
|
|
10
|
+
const r = Number(e);
|
|
11
|
+
return Number.isFinite(r) ? r : null;
|
|
12
|
+
};
|
|
13
|
+
function L(e, r) {
|
|
14
|
+
const t = p(e), n = p(r);
|
|
15
|
+
return t === null || n === null || n <= 0 || t <= 0 ? null : Math.abs(n - t) >= 5e-3 ? { was: t, now: n } : null;
|
|
16
|
+
}
|
|
17
|
+
function P(e, r) {
|
|
18
|
+
return `Catalog price now ${r(e.now)} (was ${r(e.was)} when added)`;
|
|
19
|
+
}
|
|
20
|
+
function Q(e, r, t, n = (l) => l.toLocaleString()) {
|
|
21
|
+
const l = t != null && t.trim() ? ` at ${t.trim()}` : "";
|
|
22
|
+
return `${e <= 0 ? "None in stock" : `Only ${n(e)} in stock`}${l} (this line needs ${n(r)})`;
|
|
23
|
+
}
|
|
24
|
+
function x(e, r, t) {
|
|
25
|
+
var d;
|
|
26
|
+
const n = h(), l = t == null || t === "" ? null : String(t), { data: f = [] } = y({
|
|
27
|
+
queryKey: $.collectionRelations(e ?? ""),
|
|
28
|
+
queryFn: () => S(n, e),
|
|
29
|
+
enabled: !!e && !!r && !!l,
|
|
30
|
+
staleTime: 10 * 6e4
|
|
31
|
+
}), c = ((d = f.find(
|
|
32
|
+
(o) => o.many_collection === e && o.many_field === r && !o.junction_field
|
|
33
|
+
)) == null ? void 0 : d.one_collection) ?? null, { data: i } = y({
|
|
34
|
+
queryKey: ["col-meta", c],
|
|
35
|
+
queryFn: () => n.request(g(`/collections/${c}`)).then((o) => o.data),
|
|
36
|
+
enabled: !!c,
|
|
37
|
+
staleTime: 3e5,
|
|
38
|
+
retry: !1
|
|
39
|
+
}), { data: u } = y({
|
|
40
|
+
queryKey: ["catalog-place-row", c, l],
|
|
41
|
+
queryFn: () => n.request(g(`/items/${c}/${l}`)).then((o) => o.data ?? null).catch(() => null),
|
|
42
|
+
enabled: !!c && !!l,
|
|
43
|
+
staleTime: 3e5,
|
|
44
|
+
retry: !1
|
|
45
|
+
});
|
|
46
|
+
if (!u) return null;
|
|
47
|
+
const s = (i != null && i.display_template ? C(i.display_template, u) : "") || u.name || u.title || u.label || "";
|
|
48
|
+
return String(s).trim() || null;
|
|
49
|
+
}
|
|
50
|
+
const k = 1500;
|
|
51
|
+
function E(e) {
|
|
52
|
+
const r = w(), t = m(new Set(e.pickedIds.map((a) => a.toUpperCase())));
|
|
53
|
+
t.current = new Set(e.pickedIds.map((a) => a.toUpperCase()));
|
|
54
|
+
const n = m(/* @__PURE__ */ new Set()), l = m(null), f = m(e.related);
|
|
55
|
+
f.current = e.related;
|
|
56
|
+
const c = m(e.catalogCol);
|
|
57
|
+
c.current = e.catalogCol;
|
|
58
|
+
const i = [
|
|
59
|
+
...new Set([e.catalogCol, ...e.related.map((a) => a.collection)].filter(Boolean))
|
|
60
|
+
], u = () => {
|
|
61
|
+
l.current = null;
|
|
62
|
+
const a = [...n.current];
|
|
63
|
+
n.current.clear();
|
|
64
|
+
for (const s of a)
|
|
65
|
+
s === "$catalog" ? r.invalidateQueries({ queryKey: ["catalog-line-sources", c.current] }) : r.invalidateQueries({ queryKey: ["catalog-related", s] });
|
|
66
|
+
};
|
|
67
|
+
q(
|
|
68
|
+
e.enabled && i.length > 0 ? i : null,
|
|
69
|
+
(a) => {
|
|
70
|
+
for (const s of a.events) {
|
|
71
|
+
const d = String(s.collection);
|
|
72
|
+
if (d === c.current) {
|
|
73
|
+
const o = String(s.item).toUpperCase();
|
|
74
|
+
(o === "*" || t.current.has(o)) && n.current.add("$catalog");
|
|
75
|
+
}
|
|
76
|
+
for (const o of f.current) o.collection === d && n.current.add(o.key);
|
|
77
|
+
}
|
|
78
|
+
n.current.size > 0 && !l.current && (l.current = setTimeout(u, k));
|
|
79
|
+
},
|
|
80
|
+
{ enabled: e.enabled, debounceMs: 400 }
|
|
81
|
+
), b(
|
|
82
|
+
() => () => {
|
|
83
|
+
l.current && clearTimeout(l.current);
|
|
84
|
+
},
|
|
85
|
+
[]
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
export {
|
|
89
|
+
P as catalogPriceText,
|
|
90
|
+
L as linePriceChange,
|
|
91
|
+
Q as stockShortText,
|
|
92
|
+
E as useCatalogLineLive,
|
|
93
|
+
x as usePlaceName
|
|
94
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { getHTMLFromFragment as d } from "@tiptap/react";
|
|
2
|
+
const g = "nvrCoeditRemote";
|
|
3
|
+
function w(e, t) {
|
|
4
|
+
return { step: e, inverted: e.invert(t) };
|
|
5
|
+
}
|
|
6
|
+
function M(e, t, n) {
|
|
7
|
+
for (let s = e.length - 1; s >= 0; s--) n.step(e[s].inverted);
|
|
8
|
+
for (const s of t) n.step(s);
|
|
9
|
+
const r = [];
|
|
10
|
+
let c = e.length;
|
|
11
|
+
for (const s of e) {
|
|
12
|
+
const o = s.step.map(n.mapping.slice(c));
|
|
13
|
+
c--, o && !n.maybeStep(o).failed && (n.mapping.setMirror(
|
|
14
|
+
c,
|
|
15
|
+
n.steps.length - 1
|
|
16
|
+
), r.push({ step: o, inverted: o.invert(n.docs[n.docs.length - 1]) }));
|
|
17
|
+
}
|
|
18
|
+
return r;
|
|
19
|
+
}
|
|
20
|
+
const m = /* @__PURE__ */ new WeakMap();
|
|
21
|
+
function O(e) {
|
|
22
|
+
var o;
|
|
23
|
+
const t = m.get(e.schema);
|
|
24
|
+
if (t) return t;
|
|
25
|
+
const n = (o = e.schema.topNodeType.contentMatch.defaultType) == null ? void 0 : o.createAndFill();
|
|
26
|
+
if (!n) throw new Error("coedit: the schema has no default block");
|
|
27
|
+
const c = e.tr.insert(e.doc.content.size, n).steps[0], s = Object.getPrototypeOf(c.constructor);
|
|
28
|
+
if (typeof (s == null ? void 0 : s.fromJSON) != "function") throw new Error("coedit: no step class");
|
|
29
|
+
return m.set(e.schema, s), s;
|
|
30
|
+
}
|
|
31
|
+
function S(e, t) {
|
|
32
|
+
return O(e).fromJSON(e.schema, t);
|
|
33
|
+
}
|
|
34
|
+
function v(e, t) {
|
|
35
|
+
return e.constructor.create({ schema: e.schema, doc: t }).tr;
|
|
36
|
+
}
|
|
37
|
+
function y(e, t) {
|
|
38
|
+
const n = e.schema.nodeFromJSON(t.doc);
|
|
39
|
+
if (t.steps.length === 0) return n;
|
|
40
|
+
const r = v(e, n);
|
|
41
|
+
for (const c of t.steps) r.step(S(e, c.s));
|
|
42
|
+
return r.doc;
|
|
43
|
+
}
|
|
44
|
+
function F(e, t) {
|
|
45
|
+
return d(e.content, t);
|
|
46
|
+
}
|
|
47
|
+
function T(e, t, n, r, c, s) {
|
|
48
|
+
let o = 0;
|
|
49
|
+
for (; o < c.length && c[o] === s && o < t.length; ) o++;
|
|
50
|
+
const a = [];
|
|
51
|
+
for (let i = 0; i < r.length; i++)
|
|
52
|
+
a.push(i < o ? t[i].step.getMap() : r[i].getMap());
|
|
53
|
+
let l = t.slice(o);
|
|
54
|
+
const p = r.slice(o), h = n + r.length;
|
|
55
|
+
if (p.length === 0)
|
|
56
|
+
return { tr: null, unconfirmed: l, version: h, confirmed: o, maps: a };
|
|
57
|
+
const f = e.tr, u = l.length;
|
|
58
|
+
if (u) l = M(l, p, f);
|
|
59
|
+
else for (const i of p) f.step(i);
|
|
60
|
+
return f.setMeta(g, !0), f.setMeta("addToHistory", !1), u && f.setMeta("rebased", u), { tr: f, unconfirmed: l, version: h, confirmed: o, maps: a };
|
|
61
|
+
}
|
|
62
|
+
function C(e, t) {
|
|
63
|
+
if (t.length === 0) return e.doc;
|
|
64
|
+
const n = e.tr;
|
|
65
|
+
for (let r = t.length - 1; r >= 0; r--) n.step(t[r].inverted);
|
|
66
|
+
return n.doc;
|
|
67
|
+
}
|
|
68
|
+
function E() {
|
|
69
|
+
const e = Math.random().toString(36).slice(2, 10), t = Date.now().toString(36).slice(-6);
|
|
70
|
+
return `e${e}${t}`;
|
|
71
|
+
}
|
|
72
|
+
export {
|
|
73
|
+
g as COEDIT_REMOTE,
|
|
74
|
+
C as confirmedDoc,
|
|
75
|
+
F as htmlOf,
|
|
76
|
+
E as newClientId,
|
|
77
|
+
M as rebaseSteps,
|
|
78
|
+
w as rebaseable,
|
|
79
|
+
T as receiveSteps,
|
|
80
|
+
y as sessionDoc,
|
|
81
|
+
O as stepClassOf,
|
|
82
|
+
S as stepFromJSON,
|
|
83
|
+
v as transformOn
|
|
84
|
+
};
|