@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
|
@@ -1,604 +1,630 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useQueryClient as
|
|
3
|
-
import { Loader2 as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { useNivaroClient as
|
|
6
|
-
import { get as
|
|
7
|
-
import { evaluateNumeric as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { jsxs as b, jsx as d, Fragment as we } from "react/jsx-runtime";
|
|
2
|
+
import { useQueryClient as ft, useQuery as re } from "@tanstack/react-query";
|
|
3
|
+
import { Loader2 as rt, ChevronRight as lt } from "lucide-react";
|
|
4
|
+
import { useState as le, useRef as de, useEffect as ve, useMemo as g } from "react";
|
|
5
|
+
import { useNivaroClient as ht } from "../context.js";
|
|
6
|
+
import { get as se, post as st, patch as xt } from "../lib/commands.js";
|
|
7
|
+
import { evaluateNumeric as _t } from "../lib/expression.js";
|
|
8
|
+
import { gridPageKey as yt, useGridPresence as kt, gridPresenceCell as vt } from "../lib/grid-presence.js";
|
|
9
|
+
import { userErrorMessage as Nt } from "../lib/safe-error.js";
|
|
10
|
+
import { cn as S } from "../lib/utils.js";
|
|
11
|
+
import { GridPresenceLine as gt } from "./GridPresenceLine.js";
|
|
12
|
+
import { RelationCombobox as wt } from "./item-edit/RelationCombobox.js";
|
|
13
|
+
import { useRecordLabels as $t } from "./item-edit/useRecordLabels.js";
|
|
14
|
+
import { colorPair as St } from "./QueryTable.js";
|
|
15
|
+
const J = "__uncat__", V = "__bucket__";
|
|
16
|
+
function Ne(t, _) {
|
|
14
17
|
if (!t) return;
|
|
15
|
-
const
|
|
16
|
-
Object.entries(
|
|
17
|
-
) :
|
|
18
|
-
return
|
|
18
|
+
const $ = (f) => typeof f == "string" && f.startsWith("$scope.") ? _[f.slice(7)] : Array.isArray(f) ? f.map($) : f && typeof f == "object" ? Object.fromEntries(
|
|
19
|
+
Object.entries(f).map(([N, h]) => [N, $(h)])
|
|
20
|
+
) : f;
|
|
21
|
+
return $(t);
|
|
19
22
|
}
|
|
20
|
-
function
|
|
21
|
-
return t === void 0 ? !0 : Array.isArray(t) ? t.some(
|
|
23
|
+
function $e(t) {
|
|
24
|
+
return t === void 0 ? !0 : Array.isArray(t) ? t.some($e) : t && typeof t == "object" ? Object.values(t).some($e) : !1;
|
|
22
25
|
}
|
|
23
|
-
function
|
|
26
|
+
function ae(t, _) {
|
|
24
27
|
if (t && typeof t == "object") {
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
27
|
-
return t[
|
|
28
|
+
const N = _.replace(/\[\d+\]/g, "");
|
|
29
|
+
if (N in t)
|
|
30
|
+
return t[N] ?? null;
|
|
28
31
|
}
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
return
|
|
32
|
+
const $ = _.split(".").flatMap((N) => {
|
|
33
|
+
const h = /^(\w+)\[(\d+)\]$/.exec(N);
|
|
34
|
+
return h ? [h[1], Number(h[2])] : [N];
|
|
32
35
|
});
|
|
33
|
-
let
|
|
34
|
-
for (const
|
|
35
|
-
if (
|
|
36
|
-
|
|
36
|
+
let f = t;
|
|
37
|
+
for (const N of $) {
|
|
38
|
+
if (f == null || typeof f != "object") return null;
|
|
39
|
+
f = f[N];
|
|
37
40
|
}
|
|
38
|
-
return
|
|
41
|
+
return f ?? null;
|
|
39
42
|
}
|
|
40
|
-
function
|
|
41
|
-
return t.replace(/\{\{\s*([\w.[\]]+)\s*\}\}/g, (
|
|
42
|
-
const
|
|
43
|
-
return
|
|
43
|
+
function ge(t, _) {
|
|
44
|
+
return t.replace(/\{\{\s*([\w.[\]]+)\s*\}\}/g, ($, f) => {
|
|
45
|
+
const N = ae(_, f);
|
|
46
|
+
return N == null ? "" : String(N);
|
|
44
47
|
});
|
|
45
48
|
}
|
|
46
|
-
function
|
|
47
|
-
const
|
|
48
|
-
return t == null || t === "" || !Number.isFinite(
|
|
49
|
+
function L(t, _) {
|
|
50
|
+
const $ = Number(t);
|
|
51
|
+
return t == null || t === "" || !Number.isFinite($) ? "—" : _ === "currency" ? $.toLocaleString("en-US", { style: "currency", currency: "USD" }) : $.toLocaleString("en-US", { maximumFractionDigits: 2 });
|
|
49
52
|
}
|
|
50
|
-
function
|
|
53
|
+
function Ut({
|
|
51
54
|
config: t,
|
|
52
|
-
initialScope:
|
|
53
|
-
lockScope:
|
|
55
|
+
initialScope: _,
|
|
56
|
+
lockScope: $ = !1
|
|
54
57
|
}) {
|
|
55
|
-
var
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}, [
|
|
60
|
-
const [
|
|
61
|
-
(e) =>
|
|
62
|
-
),
|
|
63
|
-
|
|
58
|
+
var Be, Ie, He, Xe, Ye, Ze, et;
|
|
59
|
+
const f = ht(), N = ft(), [h, ue] = le(_ ?? {}), Se = de(_);
|
|
60
|
+
ve(() => {
|
|
61
|
+
Se.current !== _ && (Se.current = _, _ && ue((e) => ({ ...e, ..._ })));
|
|
62
|
+
}, [_]);
|
|
63
|
+
const [K, D] = le({}), [je, Ce] = le(!1), [qe, me] = le(null), [Oe, Le] = le(/* @__PURE__ */ new Set()), F = t.scope_fields.every(
|
|
64
|
+
(e) => h[e.field] !== null && h[e.field] !== void 0 && h[e.field] !== ""
|
|
65
|
+
), Fe = de(null), M = t.scope_fields[0], Q = M && F ? String(h[M.field]) : null, nt = yt(
|
|
66
|
+
"matrix",
|
|
67
|
+
t.target_collection,
|
|
68
|
+
...t.scope_fields.slice(1).map((e) => String(h[e.field] ?? ""))
|
|
69
|
+
), Me = g(() => Q ? [Q] : [], [Q]), { editors: pe } = kt({
|
|
70
|
+
page: nt,
|
|
71
|
+
collection: M == null ? void 0 : M.collection,
|
|
72
|
+
items: Me,
|
|
73
|
+
containerRef: Fe,
|
|
74
|
+
enabled: !!Q
|
|
75
|
+
}), ot = $t(
|
|
76
|
+
M == null ? void 0 : M.collection,
|
|
77
|
+
Me,
|
|
78
|
+
pe.length > 0
|
|
79
|
+
), Re = de(/* @__PURE__ */ new Map()), X = t.option_label ?? "name", T = JSON.stringify(h), m = t.group, ze = g(() => {
|
|
80
|
+
var r, s;
|
|
64
81
|
const e = [
|
|
65
82
|
t.option_label_template,
|
|
66
83
|
(r = t.option_section) == null ? void 0 : r.label_template,
|
|
67
|
-
(
|
|
84
|
+
(s = t.option_section) == null ? void 0 : s.row_label_template
|
|
68
85
|
].filter((a) => !!a);
|
|
69
|
-
if (e.length === 0) return `id,${
|
|
70
|
-
const
|
|
86
|
+
if (e.length === 0) return `id,${X}`;
|
|
87
|
+
const l = e.flatMap(
|
|
71
88
|
(a) => [...a.matchAll(/\{\{\s*([\w.[\]]+)\s*\}\}/g)].map((o) => o[1].replace(/\[\d+\]/g, ""))
|
|
72
89
|
);
|
|
73
|
-
return t.option_label_template ||
|
|
74
|
-
}, [t.option_label_template, t.option_section,
|
|
75
|
-
queryKey: ["matrix-options", t.option_collection,
|
|
90
|
+
return t.option_label_template || l.push(X), ["id", ...new Set(l)].join(",");
|
|
91
|
+
}, [t.option_label_template, t.option_section, X]), { data: Ke = [], isLoading: it } = re({
|
|
92
|
+
queryKey: ["matrix-options", t.option_collection, ze, T],
|
|
76
93
|
queryFn: () => {
|
|
77
|
-
const e =
|
|
78
|
-
return
|
|
79
|
-
|
|
94
|
+
const e = Ne(t.option_filter, h);
|
|
95
|
+
return f.request(
|
|
96
|
+
se(`/items/${t.option_collection}`, {
|
|
80
97
|
limit: 500,
|
|
81
|
-
fields:
|
|
98
|
+
fields: ze,
|
|
82
99
|
...e ? { filter: JSON.stringify(e) } : {}
|
|
83
100
|
})
|
|
84
|
-
).then((
|
|
101
|
+
).then((l) => l.data ?? []);
|
|
85
102
|
},
|
|
86
|
-
enabled:
|
|
103
|
+
enabled: F,
|
|
87
104
|
staleTime: 3e4
|
|
88
|
-
}), { data:
|
|
89
|
-
queryKey: ["matrix-groups",
|
|
105
|
+
}), { data: E = [] } = re({
|
|
106
|
+
queryKey: ["matrix-groups", m == null ? void 0 : m.collection, T],
|
|
90
107
|
queryFn: () => {
|
|
91
|
-
const e =
|
|
92
|
-
return
|
|
93
|
-
|
|
108
|
+
const e = Ne(m == null ? void 0 : m.filter, h);
|
|
109
|
+
return f.request(
|
|
110
|
+
se(`/items/${m.collection}`, {
|
|
94
111
|
limit: 200,
|
|
95
112
|
fields: [
|
|
96
113
|
"id",
|
|
97
|
-
|
|
114
|
+
m.label_field ?? "name",
|
|
98
115
|
...Object.values(t.group_seeds ?? {})
|
|
99
116
|
].join(","),
|
|
100
117
|
...e ? { filter: JSON.stringify(e) } : {}
|
|
101
118
|
})
|
|
102
|
-
).then((
|
|
119
|
+
).then((l) => l.data ?? []);
|
|
103
120
|
},
|
|
104
|
-
enabled:
|
|
121
|
+
enabled: F && !!m,
|
|
105
122
|
staleTime: 3e4
|
|
106
|
-
}),
|
|
107
|
-
var
|
|
123
|
+
}), ct = g(() => {
|
|
124
|
+
var l;
|
|
108
125
|
const e = ["id", t.key_field, t.value_field];
|
|
109
|
-
return
|
|
110
|
-
}, [t,
|
|
111
|
-
queryKey: ["matrix-targets", t.target_collection,
|
|
126
|
+
return m && e.push(m.field), (l = t.specials) != null && l.bucket && e.push(t.specials.bucket.flag_field), e.join(",");
|
|
127
|
+
}, [t, m]), { data: Te = [], isLoading: be } = re({
|
|
128
|
+
queryKey: ["matrix-targets", t.target_collection, T],
|
|
112
129
|
queryFn: () => {
|
|
113
130
|
const e = {};
|
|
114
|
-
for (const
|
|
115
|
-
return
|
|
116
|
-
|
|
131
|
+
for (const l of t.scope_fields) e[l.field] = { _eq: h[l.field] };
|
|
132
|
+
return f.request(
|
|
133
|
+
se(`/items/${t.target_collection}`, {
|
|
117
134
|
limit: 2e3,
|
|
118
|
-
fields:
|
|
135
|
+
fields: ct,
|
|
119
136
|
filter: JSON.stringify(e)
|
|
120
137
|
})
|
|
121
|
-
).then((
|
|
138
|
+
).then((l) => l.data ?? []);
|
|
122
139
|
},
|
|
123
|
-
enabled:
|
|
140
|
+
enabled: F,
|
|
124
141
|
staleTime: 0
|
|
125
|
-
}),
|
|
142
|
+
}), Y = g(() => {
|
|
126
143
|
var r;
|
|
127
|
-
const e = /* @__PURE__ */ new Map(),
|
|
128
|
-
if (typeof
|
|
129
|
-
const a = /^\$(\w+)\.(.+)$/.exec(
|
|
144
|
+
const e = /* @__PURE__ */ new Map(), l = (s) => {
|
|
145
|
+
if (typeof s != "string") return;
|
|
146
|
+
const a = /^\$(\w+)\.(.+)$/.exec(s);
|
|
130
147
|
if (!a || a[1] === "scope") return;
|
|
131
148
|
const o = e.get(a[1]) ?? /* @__PURE__ */ new Set();
|
|
132
149
|
o.add(a[2].replace(/\[\d+\]/g, "")), e.set(a[1], o);
|
|
133
150
|
};
|
|
134
|
-
for (const
|
|
135
|
-
for (const
|
|
136
|
-
for (const
|
|
151
|
+
for (const s of Object.values(t.scope_seeds ?? {})) l(s);
|
|
152
|
+
for (const s of Object.values(t.scope_defaults ?? {})) l(s);
|
|
153
|
+
for (const s of Object.values(((r = t.metrics) == null ? void 0 : r.params) ?? {})) l(s);
|
|
137
154
|
if (t.cap) {
|
|
138
|
-
const
|
|
139
|
-
|
|
155
|
+
const s = e.get(t.cap.scope_field) ?? /* @__PURE__ */ new Set();
|
|
156
|
+
s.add(t.cap.field), e.set(t.cap.scope_field, s);
|
|
140
157
|
}
|
|
141
158
|
return e;
|
|
142
|
-
}, [t.scope_seeds, t.scope_defaults, t.metrics, t.cap]), { data:
|
|
143
|
-
queryKey: ["matrix-scope-records",
|
|
159
|
+
}, [t.scope_seeds, t.scope_defaults, t.metrics, t.cap]), { data: G = {} } = re({
|
|
160
|
+
queryKey: ["matrix-scope-records", T, [...Y.keys()].join(",")],
|
|
144
161
|
queryFn: async () => {
|
|
145
162
|
const e = {};
|
|
146
|
-
for (const [
|
|
147
|
-
const
|
|
148
|
-
if (!
|
|
149
|
-
const o = [...r].filter((
|
|
150
|
-
|
|
151
|
-
).then((
|
|
163
|
+
for (const [l, r] of Y) {
|
|
164
|
+
const s = t.scope_fields.find((n) => n.field === l), a = h[l];
|
|
165
|
+
if (!s || a == null) continue;
|
|
166
|
+
const o = [...r].filter((n) => !n.includes(".")), i = [...r].filter((n) => n.includes(".")), u = await f.request(
|
|
167
|
+
se(`/items/${s.collection}/${a}`, { fields: ["id", ...o].join(",") })
|
|
168
|
+
).then((n) => n.data).catch(() => null);
|
|
152
169
|
if (u) {
|
|
153
|
-
if (
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
).then((
|
|
157
|
-
for (const [
|
|
158
|
-
u[
|
|
170
|
+
if (i.length > 0) {
|
|
171
|
+
const n = await f.request(
|
|
172
|
+
se(`/items/${s.collection}/${a}/resolve-paths`, { paths: i.join(",") })
|
|
173
|
+
).then((p) => p.data ?? {}).catch(() => ({}));
|
|
174
|
+
for (const [p, c] of Object.entries(n))
|
|
175
|
+
u[p] = c != null && c.ids && c.ids.length > 0 ? c.ids[0] : (c == null ? void 0 : c.value) ?? null;
|
|
159
176
|
}
|
|
160
|
-
e[
|
|
177
|
+
e[l] = u;
|
|
161
178
|
}
|
|
162
179
|
}
|
|
163
180
|
return e;
|
|
164
181
|
},
|
|
165
182
|
// Per-field, not scopeReady — scope_defaults must resolve while other
|
|
166
183
|
// pickers are still empty (project → default sub type).
|
|
167
|
-
enabled:
|
|
168
|
-
(e) =>
|
|
184
|
+
enabled: Y.size > 0 && [...Y.keys()].some(
|
|
185
|
+
(e) => h[e] !== null && h[e] !== void 0 && h[e] !== ""
|
|
169
186
|
),
|
|
170
187
|
staleTime: 3e4
|
|
171
188
|
});
|
|
172
|
-
|
|
189
|
+
ve(() => {
|
|
173
190
|
if (t.scope_defaults)
|
|
174
|
-
for (const [e,
|
|
175
|
-
if (
|
|
176
|
-
const r = /^\$(\w+)\.(.+)$/.exec(
|
|
191
|
+
for (const [e, l] of Object.entries(t.scope_defaults)) {
|
|
192
|
+
if (h[e] != null && h[e] !== "") continue;
|
|
193
|
+
const r = /^\$(\w+)\.(.+)$/.exec(l);
|
|
177
194
|
if (!r) continue;
|
|
178
|
-
const
|
|
179
|
-
|
|
195
|
+
const s = ae(G[r[1]] ?? {}, r[2]);
|
|
196
|
+
s != null && s !== "" && ue((a) => ({ ...a, [e]: s }));
|
|
180
197
|
}
|
|
181
|
-
}, [
|
|
182
|
-
const { data:
|
|
198
|
+
}, [G, t.scope_defaults, h]);
|
|
199
|
+
const { data: ne = [] } = re({
|
|
183
200
|
queryKey: [
|
|
184
201
|
"matrix-metrics",
|
|
185
|
-
(
|
|
186
|
-
|
|
187
|
-
Object.keys(
|
|
202
|
+
(Be = t.metrics) == null ? void 0 : Be.query_slug,
|
|
203
|
+
T,
|
|
204
|
+
Object.keys(G).length
|
|
188
205
|
],
|
|
189
206
|
queryFn: () => {
|
|
190
207
|
var e;
|
|
191
|
-
return
|
|
192
|
-
|
|
208
|
+
return f.request(
|
|
209
|
+
st(`/custom-queries/${t.metrics.query_slug}/execute`, {
|
|
193
210
|
params: Object.fromEntries(
|
|
194
|
-
Object.entries(((e = t.metrics) == null ? void 0 : e.params) ?? {}).map(([
|
|
211
|
+
Object.entries(((e = t.metrics) == null ? void 0 : e.params) ?? {}).map(([l, r]) => {
|
|
195
212
|
if (typeof r == "string" && r.startsWith("$scope."))
|
|
196
|
-
return [
|
|
213
|
+
return [l, h[r.slice(7)]];
|
|
197
214
|
if (typeof r == "string" && r.startsWith("$")) {
|
|
198
|
-
const
|
|
199
|
-
if (
|
|
215
|
+
const s = /^\$(\w+)\.(.+)$/.exec(r);
|
|
216
|
+
if (s) return [l, ae(G[s[1]] ?? {}, s[2])];
|
|
200
217
|
}
|
|
201
|
-
return [
|
|
218
|
+
return [l, r];
|
|
202
219
|
})
|
|
203
220
|
)
|
|
204
221
|
})
|
|
205
|
-
).then((
|
|
222
|
+
).then((l) => l.data ?? []);
|
|
206
223
|
},
|
|
207
|
-
enabled:
|
|
224
|
+
enabled: F && !!t.metrics && (Y.size === 0 || Object.keys(G).length > 0),
|
|
208
225
|
staleTime: 3e4
|
|
209
|
-
}),
|
|
226
|
+
}), dt = (e) => {
|
|
210
227
|
var a;
|
|
211
|
-
const
|
|
228
|
+
const l = m ? String(e[m.field] ?? "") : "", r = (a = t.specials) == null ? void 0 : a.bucket;
|
|
212
229
|
if (r && (e[r.flag_field] === !0 || e[r.flag_field] === 1))
|
|
213
|
-
return `${
|
|
214
|
-
const
|
|
215
|
-
return `${
|
|
216
|
-
},
|
|
230
|
+
return `${l}|${V}`;
|
|
231
|
+
const s = e[t.key_field];
|
|
232
|
+
return `${l}|${s == null ? J : String(s)}`;
|
|
233
|
+
}, y = g(() => {
|
|
217
234
|
const e = /* @__PURE__ */ new Map();
|
|
218
|
-
for (const
|
|
219
|
-
const r =
|
|
220
|
-
|
|
235
|
+
for (const l of Te) {
|
|
236
|
+
const r = dt(l), s = e.get(r) ?? { ids: [], total: 0 };
|
|
237
|
+
s.ids.push(l.id), s.total += Number(l[t.value_field]) || 0, e.set(r, s);
|
|
221
238
|
}
|
|
222
239
|
return e;
|
|
223
|
-
}, [
|
|
224
|
-
var o,
|
|
225
|
-
const r = t.metrics,
|
|
226
|
-
if (!r) return
|
|
227
|
-
const a =
|
|
228
|
-
for (const
|
|
229
|
-
if (r.match_group_field && String(
|
|
230
|
-
const c =
|
|
231
|
-
if (
|
|
232
|
-
for (const
|
|
233
|
-
|
|
240
|
+
}, [Te, t.value_field]), oe = (e, l) => {
|
|
241
|
+
var o, i, u, n;
|
|
242
|
+
const r = t.metrics, s = {};
|
|
243
|
+
if (!r) return s;
|
|
244
|
+
const a = l === J ? ((i = (o = t.specials) == null ? void 0 : o.uncategorized) == null ? void 0 : i.metric_value) ?? null : l === V ? ((n = (u = t.specials) == null ? void 0 : u.bucket) == null ? void 0 : n.metric_value) ?? null : l;
|
|
245
|
+
for (const p of ne) {
|
|
246
|
+
if (r.match_group_field && String(p[r.match_group_field] ?? "") !== e) continue;
|
|
247
|
+
const c = p[r.match_option_field], k = a === null || a === 0 || a === "0", v = c == null || c === 0 || c === "0" || c === "";
|
|
248
|
+
if (k ? v : String(c ?? "") === String(a))
|
|
249
|
+
for (const x of r.columns)
|
|
250
|
+
s[x.field] = (s[x.field] ?? 0) + (Number(p[x.field]) || 0);
|
|
234
251
|
}
|
|
235
|
-
return
|
|
236
|
-
},
|
|
237
|
-
const e = (r) => t.option_label_template ?
|
|
238
|
-
return [...
|
|
239
|
-
const
|
|
240
|
-
return { key: String(r.id), label:
|
|
241
|
-
}).sort((r,
|
|
242
|
-
}, [
|
|
252
|
+
return s;
|
|
253
|
+
}, j = g(() => {
|
|
254
|
+
const e = (r) => t.option_label_template ? ge(t.option_label_template, r) : String(r[X] ?? r.id), l = t.option_section;
|
|
255
|
+
return [...Ke].map((r) => {
|
|
256
|
+
const s = e(r), a = l ? ge(l.label_template, r) : "", o = l != null && l.row_label_template && ge(l.row_label_template, r) || s;
|
|
257
|
+
return { key: String(r.id), label: l ? o : s, section: a };
|
|
258
|
+
}).sort((r, s) => r.section.localeCompare(s.section) || r.label.localeCompare(s.label));
|
|
259
|
+
}, [Ke, t.option_label_template, t.option_section, X]), ie = g(() => {
|
|
243
260
|
if (!t.option_section) return [];
|
|
244
261
|
const e = /* @__PURE__ */ new Map();
|
|
245
|
-
for (const
|
|
246
|
-
const r = e.get(
|
|
247
|
-
r.push(
|
|
262
|
+
for (const l of j) {
|
|
263
|
+
const r = e.get(l.section) ?? [];
|
|
264
|
+
r.push(l), e.set(l.section, r);
|
|
248
265
|
}
|
|
249
|
-
return [...e.entries()].map(([
|
|
250
|
-
}, [
|
|
251
|
-
|
|
252
|
-
if (!
|
|
253
|
-
const e = `${
|
|
254
|
-
if (
|
|
255
|
-
|
|
256
|
-
const
|
|
266
|
+
return [...e.entries()].map(([l, r]) => ({ name: l, rows: r }));
|
|
267
|
+
}, [j, t.option_section]), Ee = de(null);
|
|
268
|
+
ve(() => {
|
|
269
|
+
if (!m || E.length === 0 || be) return;
|
|
270
|
+
const e = `${T}#${t.option_section && ie.length > 0 ? 1 : 0}`;
|
|
271
|
+
if (Ee.current === e) return;
|
|
272
|
+
Ee.current = e;
|
|
273
|
+
const l = new Set([...y.keys()].map((s) => s.split("|")[0])), r = new Set(E.map((s) => String(s.id)).filter((s) => !l.has(s)));
|
|
257
274
|
if (t.option_section) {
|
|
258
|
-
const
|
|
259
|
-
for (const a of
|
|
275
|
+
const s = new Set(y.keys());
|
|
276
|
+
for (const a of E) {
|
|
260
277
|
const o = String(a.id);
|
|
261
|
-
for (const
|
|
262
|
-
|
|
278
|
+
for (const i of ie)
|
|
279
|
+
i.rows.some((u) => s.has(`${o}|${u.key}`)) || r.add(`s:${o}|${i.name}`);
|
|
263
280
|
}
|
|
264
281
|
}
|
|
265
|
-
|
|
266
|
-
}, [
|
|
267
|
-
const
|
|
268
|
-
var
|
|
282
|
+
Le(r);
|
|
283
|
+
}, [E, y, be, T, m, ie, t.option_section]);
|
|
284
|
+
const q = g(() => m ? [...E].map((e) => ({ id: String(e.id), label: String(e[m.label_field ?? "name"] ?? e.id) })).sort((e, l) => e.label.localeCompare(l.label)) : [{ id: "", label: "" }], [E, m]), Ge = g(() => {
|
|
285
|
+
var l, r;
|
|
269
286
|
const e = /* @__PURE__ */ new Set();
|
|
270
|
-
for (const
|
|
271
|
-
for (const a of
|
|
272
|
-
(
|
|
287
|
+
for (const s of q) {
|
|
288
|
+
for (const a of j) e.add(`${s.id}|${a.key}`);
|
|
289
|
+
(l = t.specials) != null && l.uncategorized && e.add(`${s.id}|${J}`), (r = t.specials) != null && r.bucket && e.add(`${s.id}|${V}`);
|
|
273
290
|
}
|
|
274
291
|
return e;
|
|
275
|
-
}, [
|
|
292
|
+
}, [q, j, t.specials]), A = g(() => {
|
|
276
293
|
let e = 0;
|
|
277
|
-
for (const [
|
|
294
|
+
for (const [l, r] of y) Ge.has(l) || (e += r.total);
|
|
278
295
|
return e;
|
|
279
|
-
}, [
|
|
280
|
-
var
|
|
281
|
-
let e =
|
|
282
|
-
for (const a of
|
|
296
|
+
}, [y, Ge]), B = t.cap ? Number(ae(G[t.cap.scope_field] ?? {}, t.cap.field)) || 0 : null, fe = g(() => [...y.values()].reduce((e, l) => e + l.total, 0), [y]), Ae = g(() => {
|
|
297
|
+
var l, r, s;
|
|
298
|
+
let e = A;
|
|
299
|
+
for (const a of q) {
|
|
283
300
|
const o = [
|
|
284
|
-
...
|
|
285
|
-
...(
|
|
286
|
-
...(r = t.specials) != null && r.bucket ? [
|
|
301
|
+
...j.map((i) => i.key),
|
|
302
|
+
...(l = t.specials) != null && l.uncategorized ? [J] : [],
|
|
303
|
+
...(r = t.specials) != null && r.bucket ? [V] : []
|
|
287
304
|
];
|
|
288
|
-
for (const
|
|
289
|
-
const u = `${a.id}|${
|
|
290
|
-
|
|
305
|
+
for (const i of o) {
|
|
306
|
+
const u = `${a.id}|${i}`, n = K[u];
|
|
307
|
+
n !== void 0 && n.trim() !== "" && !Number.isNaN(Number(n)) ? e += Number(n) : e += ((s = y.get(u)) == null ? void 0 : s.total) ?? 0;
|
|
291
308
|
}
|
|
292
309
|
}
|
|
293
310
|
return e;
|
|
294
|
-
}, [
|
|
311
|
+
}, [K, y, q, j, A, t.specials]), he = B !== null ? B - Ae : null, Z = (e) => {
|
|
295
312
|
var r;
|
|
296
|
-
const
|
|
297
|
-
return
|
|
313
|
+
const l = K[e];
|
|
314
|
+
return l !== void 0 && l.trim() !== "" && !Number.isNaN(Number(l)) ? Number(l) : ((r = y.get(e)) == null ? void 0 : r.total) ?? 0;
|
|
298
315
|
};
|
|
299
|
-
function
|
|
316
|
+
function ut(e, l) {
|
|
300
317
|
var o;
|
|
301
|
-
const r =
|
|
318
|
+
const r = l.trim();
|
|
302
319
|
if (r === "") {
|
|
303
|
-
|
|
320
|
+
D((i) => ({ ...i, [e]: l }));
|
|
304
321
|
return;
|
|
305
322
|
}
|
|
306
|
-
const
|
|
323
|
+
const s = /^[+-]/.test(r) && r !== "-" && r !== "+";
|
|
307
324
|
let a = Number(r);
|
|
308
325
|
if (Number.isNaN(a)) {
|
|
309
|
-
|
|
326
|
+
D((i) => ({ ...i, [e]: l }));
|
|
310
327
|
return;
|
|
311
328
|
}
|
|
312
|
-
if (
|
|
313
|
-
const
|
|
329
|
+
if (s && (a = (((o = y.get(e)) == null ? void 0 : o.total) ?? 0) + a), a < 0 && (a = 0), B !== null) {
|
|
330
|
+
const i = Ae - Z(e), u = Math.max(0, B - i);
|
|
314
331
|
a = Math.min(a, u);
|
|
315
332
|
}
|
|
316
|
-
|
|
333
|
+
D((i) => ({ ...i, [e]: s ? String(a) : l }));
|
|
317
334
|
}
|
|
318
|
-
async function
|
|
335
|
+
async function mt() {
|
|
319
336
|
var r;
|
|
320
|
-
|
|
321
|
-
let e = 0,
|
|
337
|
+
Ce(!0), me(null);
|
|
338
|
+
let e = 0, l = 0;
|
|
322
339
|
try {
|
|
323
|
-
const
|
|
340
|
+
const s = {};
|
|
324
341
|
for (const [a, o] of Object.entries(t.scope_seeds ?? {})) {
|
|
325
|
-
const
|
|
326
|
-
|
|
342
|
+
const i = /^\$(\w+)\.(.+)$/.exec(o);
|
|
343
|
+
i && (s[a] = ae(G[i[1]] ?? {}, i[2]));
|
|
327
344
|
}
|
|
328
|
-
for (const [a, o] of Object.entries(
|
|
345
|
+
for (const [a, o] of Object.entries(K)) {
|
|
329
346
|
if (o.trim() === "") continue;
|
|
330
|
-
const
|
|
331
|
-
if (Number.isNaN(
|
|
332
|
-
const u =
|
|
333
|
-
if (!(u && u.total ===
|
|
347
|
+
const i = Number(o);
|
|
348
|
+
if (Number.isNaN(i) || i < 0) continue;
|
|
349
|
+
const u = y.get(a);
|
|
350
|
+
if (!(u && u.total === i))
|
|
334
351
|
if (u)
|
|
335
|
-
await
|
|
336
|
-
|
|
337
|
-
[t.value_field]:
|
|
352
|
+
await f.request(
|
|
353
|
+
xt(`/items/${t.target_collection}/${u.ids[0]}`, {
|
|
354
|
+
[t.value_field]: i
|
|
338
355
|
})
|
|
339
356
|
), e++;
|
|
340
357
|
else {
|
|
341
|
-
const [
|
|
342
|
-
for (const
|
|
343
|
-
if (
|
|
344
|
-
c[
|
|
345
|
-
const
|
|
346
|
-
for (const [
|
|
347
|
-
const
|
|
348
|
-
|
|
358
|
+
const [n, p] = a.split("|"), c = { [t.value_field]: i, ...s };
|
|
359
|
+
for (const k of t.scope_fields) c[k.field] = h[k.field];
|
|
360
|
+
if (m && n) {
|
|
361
|
+
c[m.field] = n;
|
|
362
|
+
const k = E.find((v) => String(v.id) === n);
|
|
363
|
+
for (const [v, C] of Object.entries(t.group_seeds ?? {})) {
|
|
364
|
+
const x = k == null ? void 0 : k[C];
|
|
365
|
+
x != null && (c[v] = x);
|
|
349
366
|
}
|
|
350
367
|
}
|
|
351
|
-
|
|
368
|
+
p === V && ((r = t.specials) != null && r.bucket) ? (c[t.key_field] = null, c[t.specials.bucket.flag_field] = !0) : p === J ? c[t.key_field] = null : c[t.key_field] = p, await f.request(st(`/items/${t.target_collection}`, c)), l++;
|
|
352
369
|
}
|
|
353
370
|
}
|
|
354
|
-
|
|
355
|
-
} catch (
|
|
356
|
-
|
|
371
|
+
D({}), await N.invalidateQueries({ queryKey: ["matrix-targets", t.target_collection] }), me(`Saved — ${e} updated, ${l} created`);
|
|
372
|
+
} catch (s) {
|
|
373
|
+
me(`Save failed: ${Nt(s, "unknown error")}`);
|
|
357
374
|
} finally {
|
|
358
|
-
|
|
375
|
+
Ce(!1);
|
|
359
376
|
}
|
|
360
377
|
}
|
|
361
|
-
const
|
|
362
|
-
1 +
|
|
363
|
-
const
|
|
364
|
-
const a = r && typeof
|
|
378
|
+
const Ue = Object.values(K).some((e) => e.trim() !== ""), R = ((Ie = t.metrics) == null ? void 0 : Ie.columns) ?? [], U = ((He = t.metrics) == null ? void 0 : He.derived) ?? [], Pe = t.value_label ?? t.value_field;
|
|
379
|
+
1 + R.length + U.length + 1;
|
|
380
|
+
const P = "text-[color:var(--qtc)] dark:text-[color:var(--qtcd)]", W = (e, l, r) => {
|
|
381
|
+
const a = r && typeof l == "number" && l < 0 ? r : e;
|
|
365
382
|
if (!a) return;
|
|
366
|
-
const [o,
|
|
367
|
-
return { "--qtc": o, "--qtcd":
|
|
368
|
-
},
|
|
369
|
-
var
|
|
370
|
-
const e = /* @__PURE__ */ new Map(),
|
|
383
|
+
const [o, i] = St(a);
|
|
384
|
+
return { "--qtc": o, "--qtcd": i };
|
|
385
|
+
}, xe = t.value_color ?? "info", I = ((Xe = t.metrics) == null ? void 0 : Xe.unmatched) === !1 ? null : ((Ye = t.metrics) == null ? void 0 : Ye.unmatched) ?? {}, z = g(() => {
|
|
386
|
+
var n, p;
|
|
387
|
+
const e = /* @__PURE__ */ new Map(), l = {};
|
|
371
388
|
let r = 0;
|
|
372
|
-
const
|
|
373
|
-
if (!
|
|
374
|
-
const a = new Set(
|
|
375
|
-
(
|
|
376
|
-
for (const c of
|
|
377
|
-
const
|
|
378
|
-
if (
|
|
379
|
-
for (const
|
|
380
|
-
|
|
381
|
-
!
|
|
389
|
+
const s = t.metrics;
|
|
390
|
+
if (!s || !I) return { perGroup: e, otherGroup: l, otherGroupCount: r };
|
|
391
|
+
const a = new Set(q.map((c) => c.id)), o = new Set(j.map((c) => c.key)), i = /* @__PURE__ */ new Set(), u = (c) => c == null || c === 0 || c === "0" || c === "" ? "" : String(c);
|
|
392
|
+
(n = t.specials) != null && n.uncategorized && i.add(u(t.specials.uncategorized.metric_value)), (p = t.specials) != null && p.bucket && i.add(u(t.specials.bucket.metric_value));
|
|
393
|
+
for (const c of ne) {
|
|
394
|
+
const k = s.match_group_field ? String(c[s.match_group_field] ?? "") : "", v = c[s.match_option_field], C = o.has(String(v ?? "")) || i.has(u(v)), x = !m || a.has(k) ? C ? null : e.get(k) ?? {} : l;
|
|
395
|
+
if (x) {
|
|
396
|
+
for (const O of s.columns)
|
|
397
|
+
x[O.field] = (x[O.field] ?? 0) + (Number(c[O.field]) || 0);
|
|
398
|
+
!m || a.has(k) ? e.set(k, x) : r++;
|
|
382
399
|
}
|
|
383
400
|
}
|
|
384
|
-
return { perGroup: e, otherGroup:
|
|
385
|
-
}, [
|
|
386
|
-
(
|
|
387
|
-
|
|
388
|
-
{ ...r, __current__: e, __new__:
|
|
401
|
+
return { perGroup: e, otherGroup: l, otherGroupCount: r };
|
|
402
|
+
}, [ne, t.metrics, t.specials, q, j, m, I]), We = (e, l, r) => U.map(
|
|
403
|
+
(s) => _t(
|
|
404
|
+
s.formula,
|
|
405
|
+
{ ...r, __current__: e, __new__: l },
|
|
389
406
|
{ missing: "zero" }
|
|
390
407
|
)
|
|
391
|
-
),
|
|
392
|
-
const
|
|
408
|
+
), _e = (e) => {
|
|
409
|
+
const l = {};
|
|
393
410
|
for (const r of e)
|
|
394
|
-
for (const
|
|
395
|
-
return
|
|
396
|
-
},
|
|
397
|
-
var e,
|
|
411
|
+
for (const s of R) l[s.field] = (l[s.field] ?? 0) + (r[s.field] ?? 0);
|
|
412
|
+
return l;
|
|
413
|
+
}, Je = () => {
|
|
414
|
+
var e, l;
|
|
398
415
|
return [
|
|
399
|
-
...
|
|
400
|
-
...(e = t.specials) != null && e.uncategorized ? [
|
|
401
|
-
...(
|
|
416
|
+
...j.map((r) => r.key),
|
|
417
|
+
...(e = t.specials) != null && e.uncategorized ? [J] : [],
|
|
418
|
+
...(l = t.specials) != null && l.bucket ? [V] : []
|
|
402
419
|
];
|
|
403
|
-
},
|
|
404
|
-
var
|
|
405
|
-
let e = 0,
|
|
420
|
+
}, H = g(() => {
|
|
421
|
+
var s;
|
|
422
|
+
let e = 0, l = 0;
|
|
406
423
|
const r = [];
|
|
407
|
-
for (const a of
|
|
408
|
-
for (const
|
|
409
|
-
const u = `${a.id}|${
|
|
410
|
-
e += ((
|
|
424
|
+
for (const a of q) {
|
|
425
|
+
for (const i of Je()) {
|
|
426
|
+
const u = `${a.id}|${i}`;
|
|
427
|
+
e += ((s = y.get(u)) == null ? void 0 : s.total) ?? 0, l += Z(u), r.push(oe(a.id, i));
|
|
411
428
|
}
|
|
412
|
-
const o =
|
|
429
|
+
const o = z.perGroup.get(a.id);
|
|
413
430
|
o && r.push(o);
|
|
414
431
|
}
|
|
415
|
-
return r.push(
|
|
432
|
+
return r.push(z.otherGroup), e += A, l += A, { current: e, next: l, metrics: _e(r) };
|
|
416
433
|
}, [
|
|
434
|
+
q,
|
|
417
435
|
j,
|
|
418
|
-
|
|
419
|
-
k,
|
|
420
|
-
L,
|
|
421
|
-
se,
|
|
436
|
+
y,
|
|
422
437
|
K,
|
|
423
|
-
|
|
438
|
+
ne,
|
|
439
|
+
A,
|
|
440
|
+
z,
|
|
424
441
|
t.specials
|
|
425
|
-
]),
|
|
426
|
-
const
|
|
442
|
+
]), ee = (e, l, r) => {
|
|
443
|
+
const s = r != null && r.tone ? void 0 : W(r == null ? void 0 : r.role, e, r == null ? void 0 : r.negRole);
|
|
427
444
|
return /* @__PURE__ */ d(
|
|
428
445
|
"td",
|
|
429
446
|
{
|
|
430
|
-
className:
|
|
447
|
+
className: S(
|
|
431
448
|
"py-1.5 pr-3 text-right tabular-nums",
|
|
432
449
|
r != null && r.strong ? "font-semibold" : "",
|
|
433
|
-
|
|
450
|
+
s ? P : r != null && r.strong ? "text-slate-800 dark:text-slate-100" : "text-slate-600 dark:text-slate-300",
|
|
434
451
|
(r == null ? void 0 : r.tone) === "muted" && "text-slate-400 dark:text-slate-500",
|
|
435
452
|
(r == null ? void 0 : r.tone) === "neg" && "text-red-600 dark:text-red-400"
|
|
436
453
|
),
|
|
437
|
-
style:
|
|
438
|
-
children:
|
|
454
|
+
style: s,
|
|
455
|
+
children: L(e, l)
|
|
439
456
|
}
|
|
440
457
|
);
|
|
441
|
-
},
|
|
442
|
-
const a =
|
|
443
|
-
return /* @__PURE__ */
|
|
444
|
-
|
|
445
|
-
|
|
458
|
+
}, ye = (e, l, r, s) => {
|
|
459
|
+
const a = We(e, l, r);
|
|
460
|
+
return /* @__PURE__ */ b(we, { children: [
|
|
461
|
+
ee(e, t.value_format, { strong: s, role: xe }),
|
|
462
|
+
R.map((o) => /* @__PURE__ */ d(
|
|
446
463
|
"td",
|
|
447
464
|
{
|
|
448
|
-
className:
|
|
465
|
+
className: S(
|
|
449
466
|
"py-1.5 pr-3 text-right tabular-nums",
|
|
450
|
-
|
|
451
|
-
|
|
467
|
+
s && "font-semibold",
|
|
468
|
+
P
|
|
452
469
|
),
|
|
453
|
-
style:
|
|
454
|
-
children:
|
|
470
|
+
style: W(o.color ?? "ink"),
|
|
471
|
+
children: L(r[o.field], o.format)
|
|
455
472
|
},
|
|
456
473
|
o.field
|
|
457
474
|
)),
|
|
458
|
-
|
|
459
|
-
const u = a[
|
|
475
|
+
U.map((o, i) => {
|
|
476
|
+
const u = a[i];
|
|
460
477
|
return /* @__PURE__ */ d(
|
|
461
478
|
"td",
|
|
462
479
|
{
|
|
463
|
-
className:
|
|
480
|
+
className: S(
|
|
464
481
|
"py-1.5 pr-3 text-right tabular-nums",
|
|
465
|
-
|
|
466
|
-
|
|
482
|
+
s && "font-semibold",
|
|
483
|
+
P
|
|
467
484
|
),
|
|
468
|
-
style:
|
|
469
|
-
children:
|
|
485
|
+
style: W(o.color ?? "positive", u, o.color_negative ?? "negative"),
|
|
486
|
+
children: L(u, o.format ?? t.value_format)
|
|
470
487
|
},
|
|
471
488
|
o.label
|
|
472
489
|
);
|
|
473
490
|
}),
|
|
474
|
-
|
|
475
|
-
strong:
|
|
476
|
-
tone:
|
|
491
|
+
ee(l, t.value_format, {
|
|
492
|
+
strong: s,
|
|
493
|
+
tone: l !== e ? void 0 : "muted"
|
|
477
494
|
})
|
|
478
495
|
] });
|
|
479
|
-
},
|
|
480
|
-
var
|
|
481
|
-
const o = `${e}|${
|
|
482
|
-
|
|
496
|
+
}, ce = (e, l, r, s = !1, a = 0) => {
|
|
497
|
+
var O, te;
|
|
498
|
+
const o = `${e}|${l}`, i = `${e}:${l}`, u = e ? (O = q.find((w) => w.id === e)) == null ? void 0 : O.label : null;
|
|
499
|
+
Re.current.set(i, u ? `${u} · ${r}` : r);
|
|
500
|
+
const n = ((te = y.get(o)) == null ? void 0 : te.total) ?? 0, p = oe(e, l), c = K[o] ?? "", k = Z(o), v = c.trim() !== "" && !Number.isNaN(Number(c)), C = v ? k - n : 0, x = We(n, k, p);
|
|
501
|
+
return /* @__PURE__ */ b(
|
|
483
502
|
"tr",
|
|
484
503
|
{
|
|
485
|
-
className:
|
|
504
|
+
className: S(
|
|
486
505
|
"border-b border-slate-100 dark:border-border/50",
|
|
487
|
-
|
|
506
|
+
v && "bg-nvr-cyan/[0.04]"
|
|
488
507
|
),
|
|
489
508
|
children: [
|
|
490
509
|
/* @__PURE__ */ d(
|
|
491
510
|
"td",
|
|
492
511
|
{
|
|
493
|
-
className:
|
|
512
|
+
className: S(
|
|
494
513
|
"py-1 pr-3 text-slate-700 dark:text-slate-200",
|
|
495
|
-
|
|
514
|
+
s && "italic text-slate-500"
|
|
496
515
|
),
|
|
497
516
|
style: a ? { paddingLeft: a * 18 } : void 0,
|
|
498
517
|
children: r
|
|
499
518
|
}
|
|
500
519
|
),
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
const
|
|
520
|
+
ee(n, t.value_format, n === 0 ? { tone: "muted" } : { role: xe }),
|
|
521
|
+
R.map((w) => ke(w.field, p[w.field], w.format, w.color ?? "ink")),
|
|
522
|
+
U.map((w, bt) => {
|
|
523
|
+
const tt = x[bt];
|
|
505
524
|
return /* @__PURE__ */ d(
|
|
506
525
|
"td",
|
|
507
526
|
{
|
|
508
|
-
className:
|
|
509
|
-
style:
|
|
510
|
-
children:
|
|
527
|
+
className: S("py-1.5 pr-3 text-right tabular-nums", P),
|
|
528
|
+
style: W(w.color ?? "positive", tt, w.color_negative ?? "negative"),
|
|
529
|
+
children: L(tt, w.format ?? t.value_format)
|
|
511
530
|
},
|
|
512
|
-
|
|
531
|
+
w.label
|
|
513
532
|
);
|
|
514
533
|
}),
|
|
515
|
-
/* @__PURE__ */ d("td", { className: "py-1 pr-3 text-right", children: /* @__PURE__ */
|
|
516
|
-
|
|
534
|
+
/* @__PURE__ */ d("td", { className: "py-1 pr-3 text-right", children: /* @__PURE__ */ b("span", { className: "inline-flex items-center justify-end gap-1.5", children: [
|
|
535
|
+
v && C !== 0 && /* @__PURE__ */ b(
|
|
517
536
|
"span",
|
|
518
537
|
{
|
|
519
|
-
className:
|
|
538
|
+
className: S(
|
|
520
539
|
"rounded-full px-1.5 py-px text-[10.5px] font-medium tabular-nums",
|
|
521
|
-
|
|
540
|
+
P,
|
|
522
541
|
"bg-[color-mix(in_srgb,var(--qtc)_12%,transparent)] dark:bg-[color-mix(in_srgb,var(--qtcd)_14%,transparent)]"
|
|
523
542
|
),
|
|
524
|
-
style:
|
|
543
|
+
style: W(C > 0 ? "positive" : "negative"),
|
|
525
544
|
children: [
|
|
526
|
-
|
|
527
|
-
|
|
545
|
+
C > 0 ? "+" : "−",
|
|
546
|
+
L(Math.abs(C), t.value_format)
|
|
528
547
|
]
|
|
529
548
|
}
|
|
530
549
|
),
|
|
531
|
-
/* @__PURE__ */
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
"
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
550
|
+
/* @__PURE__ */ b(
|
|
551
|
+
"span",
|
|
552
|
+
{
|
|
553
|
+
className: "relative rounded-md",
|
|
554
|
+
"data-grid-cell": Q ? vt(Q, i) : void 0,
|
|
555
|
+
children: [
|
|
556
|
+
t.value_format === "currency" && /* @__PURE__ */ d("span", { className: "pointer-events-none absolute left-2 top-1/2 -translate-y-1/2 text-[11px] text-slate-400", children: "$" }),
|
|
557
|
+
/* @__PURE__ */ d(
|
|
558
|
+
"input",
|
|
559
|
+
{
|
|
560
|
+
type: "text",
|
|
561
|
+
inputMode: "decimal",
|
|
562
|
+
value: c,
|
|
563
|
+
placeholder: L(
|
|
564
|
+
n,
|
|
565
|
+
t.value_format === "currency" ? "number" : t.value_format
|
|
566
|
+
),
|
|
567
|
+
onChange: (w) => ut(o, w.target.value),
|
|
568
|
+
title: "Type a new amount, or +500 / -250 to adjust the current one",
|
|
569
|
+
className: S(
|
|
570
|
+
"h-7 w-32 rounded-md border bg-white text-right text-[12px] tabular-nums outline-none transition-colors placeholder:text-slate-300 focus:border-nvr-cyan dark:bg-background dark:placeholder:text-slate-600",
|
|
571
|
+
t.value_format === "currency" ? "pl-5 pr-2" : "px-2",
|
|
572
|
+
v ? "border-nvr-cyan bg-nvr-cyan/[0.06]" : "border-slate-200 dark:border-border"
|
|
573
|
+
)
|
|
574
|
+
}
|
|
549
575
|
)
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
576
|
+
]
|
|
577
|
+
}
|
|
578
|
+
)
|
|
553
579
|
] }) })
|
|
554
580
|
]
|
|
555
581
|
},
|
|
556
582
|
o
|
|
557
583
|
);
|
|
558
|
-
},
|
|
584
|
+
}, ke = (e, l, r, s) => /* @__PURE__ */ d(
|
|
559
585
|
"td",
|
|
560
586
|
{
|
|
561
|
-
className:
|
|
587
|
+
className: S(
|
|
562
588
|
"py-1.5 pr-3 text-right tabular-nums",
|
|
563
|
-
|
|
589
|
+
s ? P : "text-slate-600 dark:text-slate-300"
|
|
564
590
|
),
|
|
565
|
-
style:
|
|
566
|
-
children:
|
|
591
|
+
style: W(s),
|
|
592
|
+
children: L(l, r)
|
|
567
593
|
},
|
|
568
594
|
e
|
|
569
|
-
),
|
|
570
|
-
const
|
|
571
|
-
return !
|
|
595
|
+
), pt = (e) => {
|
|
596
|
+
const l = z.perGroup.get(e);
|
|
597
|
+
return !l || !I || !R.some((r) => (l[r.field] ?? 0) !== 0) ? null : /* @__PURE__ */ b("tr", { className: "border-b border-slate-100 dark:border-border/50", children: [
|
|
572
598
|
/* @__PURE__ */ d(
|
|
573
599
|
"td",
|
|
574
600
|
{
|
|
575
601
|
className: "py-1 pr-3 pl-[18px] italic text-slate-400",
|
|
576
602
|
title: "Spend and commitments on categories outside this project’s list — nothing to allocate here, but they count toward the project total",
|
|
577
|
-
children:
|
|
603
|
+
children: I.option_label ?? "Other categories"
|
|
578
604
|
}
|
|
579
605
|
),
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
606
|
+
ee(null, t.value_format, { tone: "muted" }),
|
|
607
|
+
R.map((r) => ke(r.field, l[r.field], r.format)),
|
|
608
|
+
U.map((r) => /* @__PURE__ */ d("td", { className: "py-1.5 pr-3 text-right tabular-nums text-slate-400", children: "—" }, r.label)),
|
|
583
609
|
/* @__PURE__ */ d("td", {})
|
|
584
610
|
] }, `${e}|__other__`);
|
|
585
|
-
},
|
|
586
|
-
const r = new Set(
|
|
611
|
+
}, Ve = (e) => e.label ?? e.field.replace(/_/g, " ").replace(/\b\w/g, (l) => l.toUpperCase()), De = new Set($ ? Object.keys(_ ?? {}) : []), Qe = (e) => Le((l) => {
|
|
612
|
+
const r = new Set(l);
|
|
587
613
|
return r.has(e) ? r.delete(e) : r.add(e), r;
|
|
588
614
|
});
|
|
589
|
-
return /* @__PURE__ */
|
|
590
|
-
/* @__PURE__ */
|
|
591
|
-
t.scope_fields.filter((e) => !
|
|
592
|
-
const
|
|
593
|
-
return /* @__PURE__ */
|
|
594
|
-
/* @__PURE__ */ d("p", { className: "mb-1 text-[11px] font-medium text-slate-500 dark:text-slate-400", children:
|
|
615
|
+
return /* @__PURE__ */ b("div", { ref: Fe, className: "flex h-full min-h-0 flex-col", "data-matrix-editor": !0, children: [
|
|
616
|
+
/* @__PURE__ */ b("div", { className: "flex shrink-0 flex-wrap items-end gap-3 border-b border-slate-200 bg-white px-4 py-3 dark:border-border dark:bg-card", children: [
|
|
617
|
+
t.scope_fields.filter((e) => !De.has(e.field)).map((e) => {
|
|
618
|
+
const l = Ne(e.filter, h), r = l && !$e(l) ? l : void 0;
|
|
619
|
+
return /* @__PURE__ */ b("div", { className: "w-56", children: [
|
|
620
|
+
/* @__PURE__ */ d("p", { className: "mb-1 text-[11px] font-medium text-slate-500 dark:text-slate-400", children: Ve(e) }),
|
|
595
621
|
/* @__PURE__ */ d(
|
|
596
|
-
|
|
622
|
+
wt,
|
|
597
623
|
{
|
|
598
624
|
collection: e.collection,
|
|
599
|
-
value:
|
|
600
|
-
onChange: (
|
|
601
|
-
|
|
625
|
+
value: h[e.field] ?? null,
|
|
626
|
+
onChange: (s) => {
|
|
627
|
+
ue((a) => ({ ...a, [e.field]: s })), D({});
|
|
602
628
|
},
|
|
603
629
|
extraFilter: r,
|
|
604
630
|
placeholder: "Select…"
|
|
@@ -606,82 +632,91 @@ function vt({
|
|
|
606
632
|
)
|
|
607
633
|
] }, e.field);
|
|
608
634
|
}),
|
|
609
|
-
/* @__PURE__ */ d(
|
|
610
|
-
|
|
611
|
-
|
|
635
|
+
pe.length > 0 ? /* @__PURE__ */ d(
|
|
636
|
+
gt,
|
|
637
|
+
{
|
|
638
|
+
className: "min-w-[12rem] flex-1 pb-2",
|
|
639
|
+
editors: pe,
|
|
640
|
+
noun: ((Ze = t.presence_noun) == null ? void 0 : Ze.trim()) || t.target_collection.replace(/_/g, " ").toLowerCase(),
|
|
641
|
+
rowLabel: (e) => ot.get(e),
|
|
642
|
+
cellLabel: (e) => Re.current.get(e)
|
|
643
|
+
}
|
|
644
|
+
) : /* @__PURE__ */ d("span", { className: "flex-1" }),
|
|
645
|
+
qe && /* @__PURE__ */ d("span", { className: "pb-2 text-[12px] text-slate-500", children: qe }),
|
|
646
|
+
Ue && /* @__PURE__ */ d(
|
|
612
647
|
"button",
|
|
613
648
|
{
|
|
614
649
|
type: "button",
|
|
615
|
-
onClick: () =>
|
|
650
|
+
onClick: () => D({}),
|
|
616
651
|
className: "h-9 rounded-md px-3 text-[13px] font-medium text-slate-600 hover:bg-slate-100 dark:text-slate-300 dark:hover:bg-muted",
|
|
617
652
|
children: "Discard"
|
|
618
653
|
}
|
|
619
654
|
),
|
|
620
|
-
/* @__PURE__ */
|
|
655
|
+
/* @__PURE__ */ b(
|
|
621
656
|
"button",
|
|
622
657
|
{
|
|
623
658
|
type: "button",
|
|
624
|
-
disabled: !
|
|
625
|
-
onClick: () => void
|
|
659
|
+
disabled: !F || !Ue || je,
|
|
660
|
+
onClick: () => void mt(),
|
|
626
661
|
"data-matrix-save": !0,
|
|
627
662
|
className: "inline-flex h-9 items-center gap-1.5 rounded-md bg-nvr-cyan px-3.5 text-[13px] font-semibold text-[#172940] hover:bg-nvr-cyan-dark disabled:opacity-50",
|
|
628
663
|
children: [
|
|
629
|
-
|
|
664
|
+
je && /* @__PURE__ */ d(rt, { className: "h-3.5 w-3.5 animate-spin" }),
|
|
630
665
|
"Save changes"
|
|
631
666
|
]
|
|
632
667
|
}
|
|
633
668
|
)
|
|
634
669
|
] }),
|
|
635
|
-
|
|
670
|
+
B !== null && F && /* @__PURE__ */ d("div", { className: "grid shrink-0 grid-cols-2 gap-px border-b border-slate-200 bg-slate-200 dark:border-border dark:bg-border sm:grid-cols-4", children: [
|
|
636
671
|
{
|
|
637
|
-
label: ((
|
|
638
|
-
value:
|
|
672
|
+
label: ((et = t.cap) == null ? void 0 : et.label) ?? "Cap",
|
|
673
|
+
value: B,
|
|
639
674
|
tone: "plain",
|
|
640
675
|
role: "accent"
|
|
641
676
|
},
|
|
642
677
|
{
|
|
643
678
|
label: "Allocated",
|
|
644
|
-
value:
|
|
645
|
-
tone:
|
|
646
|
-
role:
|
|
647
|
-
sub:
|
|
679
|
+
value: H.next,
|
|
680
|
+
tone: H.next !== fe ? "edited" : "plain",
|
|
681
|
+
role: xe,
|
|
682
|
+
sub: H.next !== fe ? `was ${L(fe, "currency")}` : void 0
|
|
648
683
|
},
|
|
649
684
|
{
|
|
650
685
|
label: "Available to allocate",
|
|
651
|
-
value:
|
|
652
|
-
tone:
|
|
686
|
+
value: he,
|
|
687
|
+
tone: he !== null && he < 0 ? "neg" : "ok"
|
|
653
688
|
},
|
|
654
689
|
{
|
|
655
690
|
label: "Misallocated",
|
|
656
|
-
value:
|
|
657
|
-
tone:
|
|
691
|
+
value: A,
|
|
692
|
+
tone: A > 0 ? "neg" : "muted",
|
|
658
693
|
hint: "Allocations on categories or regions outside this project’s current lists"
|
|
659
694
|
}
|
|
660
|
-
].map((e) => /* @__PURE__ */
|
|
695
|
+
].map((e) => /* @__PURE__ */ b("div", { className: "bg-white px-4 py-2.5 dark:bg-card", title: e.hint, children: [
|
|
661
696
|
/* @__PURE__ */ d("p", { className: "text-[10px] font-semibold uppercase tracking-wide text-slate-400", children: e.label }),
|
|
662
697
|
/* @__PURE__ */ d(
|
|
663
698
|
"p",
|
|
664
699
|
{
|
|
665
|
-
className:
|
|
700
|
+
className: S(
|
|
666
701
|
"mt-0.5 text-[17px] font-semibold tabular-nums tracking-[-0.01em]",
|
|
667
|
-
e.tone === "muted" ? "text-slate-400" :
|
|
702
|
+
e.tone === "muted" ? "text-slate-400" : P
|
|
668
703
|
),
|
|
669
|
-
style:
|
|
704
|
+
style: W(
|
|
670
705
|
e.tone === "neg" ? "negative" : e.tone === "ok" ? "positive" : e.tone === "edited" ? "accent" : e.role ?? "ink"
|
|
671
706
|
),
|
|
672
|
-
children:
|
|
707
|
+
children: L(e.value, "currency")
|
|
673
708
|
}
|
|
674
709
|
),
|
|
675
710
|
e.sub && /* @__PURE__ */ d("p", { className: "text-[11px] text-slate-400", children: e.sub })
|
|
676
711
|
] }, e.label)) }),
|
|
677
|
-
/* @__PURE__ */ d("div", { className: "min-h-0 flex-1 overflow-auto bg-slate-50/60 dark:bg-transparent", children:
|
|
678
|
-
/* @__PURE__ */ d(
|
|
712
|
+
/* @__PURE__ */ d("div", { className: "min-h-0 flex-1 overflow-auto bg-slate-50/60 dark:bg-transparent", children: F ? it || be ? /* @__PURE__ */ b("div", { className: "flex items-center gap-2 p-4 text-[12px] text-slate-400", children: [
|
|
713
|
+
/* @__PURE__ */ d(rt, { className: "h-4 w-4 animate-spin" }),
|
|
679
714
|
" Loading…"
|
|
680
|
-
] }) : /* @__PURE__ */
|
|
681
|
-
/* @__PURE__ */ d("thead", { className: "sticky top-0 z-[1] bg-slate-50 dark:bg-background", children: /* @__PURE__ */
|
|
715
|
+
] }) : /* @__PURE__ */ b("table", { className: "w-full text-[12px]", children: [
|
|
716
|
+
/* @__PURE__ */ d("thead", { className: "sticky top-0 z-[1] bg-slate-50 dark:bg-background", children: /* @__PURE__ */ b("tr", { className: "border-b border-slate-200 text-left dark:border-border", children: [
|
|
682
717
|
/* @__PURE__ */ d("th", { className: "px-3 py-2 text-[10.5px] font-semibold uppercase tracking-wide text-slate-400", children: t.option_collection.replace(/_/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()) }),
|
|
683
|
-
/* @__PURE__ */ d("th", { className: "w-32 py-2 pr-3 text-right text-[10.5px] font-semibold uppercase tracking-wide text-slate-400", children:
|
|
684
|
-
|
|
718
|
+
/* @__PURE__ */ d("th", { className: "w-32 py-2 pr-3 text-right text-[10.5px] font-semibold uppercase tracking-wide text-slate-400", children: Pe }),
|
|
719
|
+
R.map((e) => /* @__PURE__ */ d(
|
|
685
720
|
"th",
|
|
686
721
|
{
|
|
687
722
|
className: "w-32 py-2 pr-3 text-right text-[10.5px] font-semibold uppercase tracking-wide text-slate-400",
|
|
@@ -689,7 +724,7 @@ function vt({
|
|
|
689
724
|
},
|
|
690
725
|
e.field
|
|
691
726
|
)),
|
|
692
|
-
|
|
727
|
+
U.map((e) => /* @__PURE__ */ d(
|
|
693
728
|
"th",
|
|
694
729
|
{
|
|
695
730
|
className: "w-32 py-2 pr-3 text-right text-[10.5px] font-semibold uppercase tracking-wide text-slate-400",
|
|
@@ -697,160 +732,160 @@ function vt({
|
|
|
697
732
|
},
|
|
698
733
|
e.label
|
|
699
734
|
)),
|
|
700
|
-
/* @__PURE__ */
|
|
735
|
+
/* @__PURE__ */ b("th", { className: "w-44 py-2 pr-3 text-right text-[10.5px] font-semibold uppercase tracking-wide text-slate-400", children: [
|
|
701
736
|
"New ",
|
|
702
|
-
|
|
737
|
+
Pe
|
|
703
738
|
] })
|
|
704
739
|
] }) }),
|
|
705
|
-
/* @__PURE__ */
|
|
706
|
-
|
|
707
|
-
var
|
|
708
|
-
const
|
|
709
|
-
...
|
|
710
|
-
...
|
|
711
|
-
]), o =
|
|
740
|
+
/* @__PURE__ */ b("tbody", { className: "bg-white dark:bg-transparent", children: [
|
|
741
|
+
q.map((e) => {
|
|
742
|
+
var i, u;
|
|
743
|
+
const l = Oe.has(e.id), r = [...y.entries()].filter(([n]) => n.startsWith(`${e.id}|`)).reduce((n, [, p]) => n + p.total, 0), s = Je(), a = _e([
|
|
744
|
+
...s.map((n) => oe(e.id, n)),
|
|
745
|
+
...z.perGroup.get(e.id) ? [z.perGroup.get(e.id)] : []
|
|
746
|
+
]), o = s.reduce((n, p) => n + Z(`${e.id}|${p}`), 0) + (r - s.reduce((n, p) => {
|
|
712
747
|
var c;
|
|
713
|
-
return
|
|
748
|
+
return n + (((c = y.get(`${e.id}|${p}`)) == null ? void 0 : c.total) ?? 0);
|
|
714
749
|
}, 0));
|
|
715
750
|
return /* @__PURE__ */ d(
|
|
716
|
-
|
|
751
|
+
at,
|
|
717
752
|
{
|
|
718
|
-
header:
|
|
753
|
+
header: m ? /* @__PURE__ */ b(
|
|
719
754
|
"tr",
|
|
720
755
|
{
|
|
721
756
|
className: "cursor-pointer border-y border-slate-200 bg-slate-100/70 hover:bg-slate-100 dark:border-border dark:bg-muted/60",
|
|
722
|
-
onClick: () =>
|
|
757
|
+
onClick: () => Qe(e.id),
|
|
723
758
|
"data-matrix-group": e.id,
|
|
724
759
|
children: [
|
|
725
|
-
/* @__PURE__ */ d("td", { className: "px-3 py-1.5 text-[12px] font-semibold text-slate-700 dark:text-slate-200", children: /* @__PURE__ */
|
|
760
|
+
/* @__PURE__ */ d("td", { className: "px-3 py-1.5 text-[12px] font-semibold text-slate-700 dark:text-slate-200", children: /* @__PURE__ */ b("span", { className: "inline-flex items-center gap-1.5", children: [
|
|
726
761
|
/* @__PURE__ */ d(
|
|
727
|
-
|
|
762
|
+
lt,
|
|
728
763
|
{
|
|
729
|
-
className:
|
|
764
|
+
className: S(
|
|
730
765
|
"h-3.5 w-3.5 text-slate-400 transition-transform",
|
|
731
|
-
!
|
|
766
|
+
!l && "rotate-90"
|
|
732
767
|
)
|
|
733
768
|
}
|
|
734
769
|
),
|
|
735
770
|
e.label
|
|
736
771
|
] }) }),
|
|
737
|
-
|
|
772
|
+
ye(r, o, a, !0)
|
|
738
773
|
]
|
|
739
774
|
}
|
|
740
775
|
) : null,
|
|
741
|
-
children: !
|
|
742
|
-
t.option_section ?
|
|
743
|
-
const
|
|
744
|
-
(
|
|
745
|
-
var
|
|
746
|
-
return
|
|
776
|
+
children: !l && /* @__PURE__ */ b(we, { children: [
|
|
777
|
+
t.option_section ? ie.map((n) => {
|
|
778
|
+
const p = `s:${e.id}|${n.name}`, c = Oe.has(p), k = n.rows.reduce(
|
|
779
|
+
(x, O) => {
|
|
780
|
+
var te;
|
|
781
|
+
return x + (((te = y.get(`${e.id}|${O.key}`)) == null ? void 0 : te.total) ?? 0);
|
|
747
782
|
},
|
|
748
783
|
0
|
|
749
|
-
),
|
|
750
|
-
(
|
|
784
|
+
), v = n.rows.reduce(
|
|
785
|
+
(x, O) => x + Z(`${e.id}|${O.key}`),
|
|
751
786
|
0
|
|
752
|
-
),
|
|
753
|
-
|
|
787
|
+
), C = _e(
|
|
788
|
+
n.rows.map((x) => oe(e.id, x.key))
|
|
754
789
|
);
|
|
755
790
|
return /* @__PURE__ */ d(
|
|
756
|
-
|
|
791
|
+
at,
|
|
757
792
|
{
|
|
758
|
-
header: /* @__PURE__ */
|
|
793
|
+
header: /* @__PURE__ */ b(
|
|
759
794
|
"tr",
|
|
760
795
|
{
|
|
761
796
|
className: "cursor-pointer border-b border-slate-100 bg-slate-50/80 hover:bg-slate-50 dark:border-border/50 dark:bg-muted/30",
|
|
762
|
-
onClick: () =>
|
|
797
|
+
onClick: () => Qe(p),
|
|
763
798
|
children: [
|
|
764
|
-
/* @__PURE__ */ d("td", { className: "py-1 pr-3 pl-[22px] text-[11.5px] font-medium text-slate-600 dark:text-slate-300", children: /* @__PURE__ */
|
|
799
|
+
/* @__PURE__ */ d("td", { className: "py-1 pr-3 pl-[22px] text-[11.5px] font-medium text-slate-600 dark:text-slate-300", children: /* @__PURE__ */ b("span", { className: "inline-flex items-center gap-1.5", children: [
|
|
765
800
|
/* @__PURE__ */ d(
|
|
766
|
-
|
|
801
|
+
lt,
|
|
767
802
|
{
|
|
768
|
-
className:
|
|
803
|
+
className: S(
|
|
769
804
|
"h-3 w-3 text-slate-400 transition-transform",
|
|
770
805
|
!c && "rotate-90"
|
|
771
806
|
)
|
|
772
807
|
}
|
|
773
808
|
),
|
|
774
|
-
|
|
809
|
+
n.name || "—"
|
|
775
810
|
] }) }),
|
|
776
|
-
|
|
811
|
+
ye(k, v, C, !1)
|
|
777
812
|
]
|
|
778
813
|
}
|
|
779
814
|
),
|
|
780
|
-
children: !c &&
|
|
781
|
-
(
|
|
815
|
+
children: !c && n.rows.map(
|
|
816
|
+
(x) => ce(e.id, x.key, x.label, !1, 2.4)
|
|
782
817
|
)
|
|
783
818
|
},
|
|
784
|
-
|
|
819
|
+
p
|
|
785
820
|
);
|
|
786
|
-
}) :
|
|
787
|
-
((
|
|
821
|
+
}) : j.map((n) => ce(e.id, n.key, n.label, !1, 1)),
|
|
822
|
+
((i = t.specials) == null ? void 0 : i.uncategorized) && ce(
|
|
788
823
|
e.id,
|
|
789
|
-
|
|
824
|
+
J,
|
|
790
825
|
t.specials.uncategorized.label ?? "Uncategorized",
|
|
791
826
|
!0,
|
|
792
827
|
1
|
|
793
828
|
),
|
|
794
|
-
((u = t.specials) == null ? void 0 : u.bucket) &&
|
|
829
|
+
((u = t.specials) == null ? void 0 : u.bucket) && ce(
|
|
795
830
|
e.id,
|
|
796
|
-
|
|
831
|
+
V,
|
|
797
832
|
t.specials.bucket.label ?? "Inventory",
|
|
798
833
|
!0,
|
|
799
834
|
1
|
|
800
835
|
),
|
|
801
|
-
|
|
836
|
+
pt(e.id)
|
|
802
837
|
] })
|
|
803
838
|
},
|
|
804
839
|
e.id || "__all__"
|
|
805
840
|
);
|
|
806
841
|
}),
|
|
807
|
-
|
|
842
|
+
I && m && z.otherGroupCount > 0 && /* @__PURE__ */ b(
|
|
808
843
|
"tr",
|
|
809
844
|
{
|
|
810
845
|
className: "border-y border-slate-200 bg-slate-100/70 dark:border-border dark:bg-muted/60",
|
|
811
846
|
title: "Spend and commitments on regions outside this project’s list",
|
|
812
847
|
children: [
|
|
813
|
-
/* @__PURE__ */ d("td", { className: "px-3 py-1.5 text-[12px] font-semibold italic text-slate-500", children:
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
(e) =>
|
|
848
|
+
/* @__PURE__ */ d("td", { className: "px-3 py-1.5 text-[12px] font-semibold italic text-slate-500", children: I.group_label ?? "Other regions" }),
|
|
849
|
+
ee(null, t.value_format, { tone: "muted" }),
|
|
850
|
+
R.map(
|
|
851
|
+
(e) => ke(e.field, z.otherGroup[e.field], e.format)
|
|
817
852
|
),
|
|
818
|
-
|
|
853
|
+
U.map((e) => /* @__PURE__ */ d("td", { className: "py-1.5 pr-3 text-right text-slate-400", children: "—" }, e.label)),
|
|
819
854
|
/* @__PURE__ */ d("td", {})
|
|
820
855
|
]
|
|
821
856
|
}
|
|
822
857
|
)
|
|
823
858
|
] }),
|
|
824
|
-
/* @__PURE__ */ d("tfoot", { className: "sticky bottom-0 bg-white dark:bg-card", children: /* @__PURE__ */
|
|
859
|
+
/* @__PURE__ */ d("tfoot", { className: "sticky bottom-0 bg-white dark:bg-card", children: /* @__PURE__ */ b("tr", { className: "border-t-2 border-slate-300 dark:border-border", children: [
|
|
825
860
|
/* @__PURE__ */ d("td", { className: "px-3 py-2 text-[12px] font-semibold text-slate-800 dark:text-slate-100", children: "Total" }),
|
|
826
|
-
|
|
861
|
+
ye(H.current, H.next, H.metrics, !0)
|
|
827
862
|
] }) })
|
|
828
|
-
] }) : /* @__PURE__ */
|
|
829
|
-
/* @__PURE__ */
|
|
863
|
+
] }) : /* @__PURE__ */ b("div", { className: "flex h-full flex-col items-center justify-center gap-1 p-8 text-center", children: [
|
|
864
|
+
/* @__PURE__ */ b("p", { className: "text-[13px] font-medium text-slate-600 dark:text-slate-300", children: [
|
|
830
865
|
"Choose",
|
|
831
866
|
" ",
|
|
832
|
-
t.scope_fields.filter((e) => !
|
|
867
|
+
t.scope_fields.filter((e) => !De.has(e.field)).map(Ve).join(" and "),
|
|
833
868
|
" ",
|
|
834
869
|
"to load allocations"
|
|
835
870
|
] }),
|
|
836
|
-
/* @__PURE__ */
|
|
871
|
+
/* @__PURE__ */ b("p", { className: "text-[12px] text-slate-400", children: [
|
|
837
872
|
"Amounts are grouped by",
|
|
838
873
|
" ",
|
|
839
|
-
|
|
874
|
+
m != null && m.label_field ? m.collection.replace(/_/g, " ") : "section",
|
|
840
875
|
" and saved together."
|
|
841
876
|
] })
|
|
842
877
|
] }) })
|
|
843
878
|
] });
|
|
844
879
|
}
|
|
845
|
-
function
|
|
880
|
+
function at({
|
|
846
881
|
header: t,
|
|
847
|
-
children:
|
|
882
|
+
children: _
|
|
848
883
|
}) {
|
|
849
|
-
return /* @__PURE__ */
|
|
884
|
+
return /* @__PURE__ */ b(we, { children: [
|
|
850
885
|
t,
|
|
851
|
-
|
|
886
|
+
_
|
|
852
887
|
] });
|
|
853
888
|
}
|
|
854
889
|
export {
|
|
855
|
-
|
|
890
|
+
Ut as MatrixEditor
|
|
856
891
|
};
|