@nivaro/react 0.3.57 → 0.3.59
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/fields/RelationField.js +110 -80
- package/dist/full.css +1 -1
- package/dist/hooks/useRelationOptions.js +1 -0
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +37 -2
- package/dist/index.js +523 -520
- package/dist/shared/components/CollectionBrowserView.js +2693 -2619
- package/dist/shared/components/DataTable.js +538 -495
- package/dist/shared/components/ItemEditForm.js +4559 -4386
- package/dist/shared/components/PageRenderer.js +537 -508
- package/dist/shared/components/ProfileView.js +716 -715
- package/dist/shared/components/QueryTable.js +74 -74
- package/dist/shared/components/RecordReadView.js +367 -364
- package/dist/shared/components/ReportView.js +64 -39
- package/dist/shared/components/WidgetSlot.js +543 -520
- package/dist/shared/components/alerts/AlertManagerView.js +324 -317
- package/dist/shared/components/alerts/types.js +37 -14
- package/dist/shared/components/cbv/row-focus.js +19 -0
- package/dist/shared/components/help-videos/HelpVideoPlayer.js +152 -147
- package/dist/shared/components/integrations/console/SignalCard.js +59 -59
- package/dist/shared/components/integrations/console/tone.js +52 -30
- package/dist/shared/components/item-edit/CatalogPickerField.js +525 -505
- package/dist/shared/components/item-edit/FieldRenderer.js +22 -20
- package/dist/shared/components/item-edit/FieldRow.js +175 -173
- package/dist/shared/components/item-edit/GridBulkEditDialog.js +55 -54
- package/dist/shared/components/item-edit/InlineTableField.js +2487 -2442
- package/dist/shared/components/item-edit/M2MCombobox.js +321 -295
- package/dist/shared/components/item-edit/MidairCollisionDialog.js +1 -1
- package/dist/shared/components/item-edit/PlanGrid.js +973 -894
- package/dist/shared/components/item-edit/QuickCreateButton.js +335 -106
- package/dist/shared/components/item-edit/RecordLiveSync.js +77 -75
- package/dist/shared/components/item-edit/RelationCombobox.js +452 -335
- package/dist/shared/components/item-edit/RelationGroupedCombobox.js +262 -141
- package/dist/shared/components/item-edit/SummaryPanel.js +385 -358
- package/dist/shared/components/item-edit/duplicate-rehearsal.js +47 -0
- package/dist/shared/components/item-edit/line-midair.js +82 -75
- package/dist/shared/components/item-edit/option-disambiguate.js +44 -32
- package/dist/shared/components/item-edit/related-missing.js +45 -0
- package/dist/shared/components/item-edit/save-outcome.js +9 -7
- package/dist/shared/components/notifications/NotificationRulesEditor.js +130 -123
- package/dist/shared/components/panels/AccessDeniedPanel.js +52 -48
- package/dist/shared/components/panels/ItemLockBanner.js +213 -211
- package/dist/shared/components/panels/PipelinePanel.js +1140 -1053
- package/dist/shared/components/panels/RecordIntegrityBanner.js +114 -86
- package/dist/shared/components/panels/RevisionsPanel.js +316 -299
- package/dist/shared/components/panels/TaskPanel.js +265 -249
- package/dist/shared/components/panels/landing-state.js +27 -0
- package/dist/shared/components/pipeline/PipelineEditorView.js +110 -92
- package/dist/shared/components/profile/AiMemoryCard.js +12 -10
- package/dist/shared/components/queue/OwnerAvatars.js +80 -41
- package/dist/shared/components/queue/QueueQuickFilters.js +52 -52
- package/dist/shared/components/queue/QueueWorklist.js +1050 -1026
- package/dist/shared/components/queue/group-sums.js +27 -0
- package/dist/shared/components/queue/live-state-aspect.js +9 -5
- package/dist/shared/components/widgets/ReviewListWidget.js +175 -154
- package/dist/shared/lib/back-closes.js +25 -0
- package/dist/shared/lib/display-prefs.js +60 -52
- package/dist/shared/lib/draft-store.js +71 -48
- package/dist/shared/lib/expression.js +53 -53
- package/dist/shared/lib/form-usage-beacon.js +7 -7
- package/dist/shared/lib/list-page-memory.js +63 -0
- package/dist/shared/lib/live.js +44 -44
- package/dist/shared/lib/money-input.js +45 -0
- package/dist/shared/lib/own-writes.js +76 -28
- package/dist/shared/lib/request-gate.js +110 -109
- package/dist/shared/lib/sanitize-html.js +10 -6
- package/dist/shared/lib/staged-row-labels.js +18 -0
- package/dist/shared/lib/validation-rules.js +34 -19
- package/package.json +1 -1
|
@@ -1,527 +1,590 @@
|
|
|
1
|
-
import { jsx as t, jsxs as
|
|
2
|
-
import { useQueryClient as
|
|
3
|
-
import { ChevronDown as
|
|
4
|
-
import { useRef as
|
|
5
|
-
import { toast as
|
|
6
|
-
import { useNivaroClient as
|
|
7
|
-
import { get as
|
|
8
|
-
import { useAfterIdle as
|
|
9
|
-
import { evaluateNumeric as
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
import { jsx as t, jsxs as c, Fragment as ra } from "react/jsx-runtime";
|
|
2
|
+
import { useQueryClient as sa, useQuery as he } from "@tanstack/react-query";
|
|
3
|
+
import { ChevronDown as Lt, ChevronRight as Mt, Lock as oa, MoreHorizontal as ia, Split as Et, Undo2 as da, History as ca, Trash2 as ua, Plus as pa } from "lucide-react";
|
|
4
|
+
import { useRef as me, useEffect as ue, useMemo as Z, useCallback as ee, useState as W } from "react";
|
|
5
|
+
import { toast as ie } from "sonner";
|
|
6
|
+
import { useNivaroClient as ma, useParentDraft as ha, useItemEditAuth as fa } from "../../context.js";
|
|
7
|
+
import { get as fe, post as ot } from "../../lib/commands.js";
|
|
8
|
+
import { useAfterIdle as xa } from "../../lib/defer.js";
|
|
9
|
+
import { evaluateNumeric as nt } from "../../lib/expression.js";
|
|
10
|
+
import { parseMoneyInput as ct } from "../../lib/money-input.js";
|
|
11
|
+
import { userErrorMessage as ga } from "../../lib/safe-error.js";
|
|
12
|
+
import { registerStagedRowLabel as ya } from "../../lib/staged-row-labels.js";
|
|
13
|
+
import { cn as D, formatRelative as ba } from "../../lib/utils.js";
|
|
14
|
+
import { NumberDraftInput as ka } from "../ui/number-draft-input.js";
|
|
15
|
+
import { Popover as ut, PopoverTrigger as pt, PopoverContent as mt } from "../ui/popover.js";
|
|
16
|
+
import { resolveCompareEndpoint as va, useCompareSeries as Na, compareColumnClosed as wa, planLabel as It, closedThroughLabel as $a, CompareProposalBanner as Ca, CompareStripChips as Sa, GridStatChip as Tt, monthLabel as it, extraSeriesValue as Ce, SeriesFigurePopover as Pt, monthLabelLong as je, unitWord as _a } from "./CompareSeries.js";
|
|
17
|
+
import { useO2MStaging as Oa, useLiveRows as Ra } from "./O2MStagingContext.js";
|
|
18
|
+
import { usePlanGridHost as La } from "./PlanGridHost.js";
|
|
19
|
+
import { RowHistorySheet as Ma } from "./RowHistorySheet.js";
|
|
20
|
+
import { RowWatchButton as Ea } from "./RowWatchButton.js";
|
|
21
|
+
const ze = "unclassified", B = (b) => Number(b) || 0, F = (b) => Math.round(b * 100) / 100;
|
|
22
|
+
function z(b) {
|
|
23
|
+
const n = Math.abs(b - Math.round(b)) < 5e-3;
|
|
24
|
+
return b.toLocaleString("en-US", {
|
|
23
25
|
style: "currency",
|
|
24
26
|
currency: "USD",
|
|
25
27
|
minimumFractionDigits: n ? 0 : 2,
|
|
26
28
|
maximumFractionDigits: n ? 0 : 2
|
|
27
29
|
});
|
|
28
30
|
}
|
|
29
|
-
function
|
|
30
|
-
const n =
|
|
31
|
-
|
|
32
|
-
const p = /^\(.*\)$/.test(n), g = Number(p ? n.slice(1, -1) : n);
|
|
33
|
-
return Number.isFinite(g) ? T(p ? -g : g) : null;
|
|
31
|
+
function Bt(b) {
|
|
32
|
+
const n = ct(b);
|
|
33
|
+
return n.ok ? n.value : null;
|
|
34
34
|
}
|
|
35
|
-
function
|
|
36
|
-
|
|
35
|
+
function Dt(b) {
|
|
36
|
+
const n = ct(b);
|
|
37
|
+
return n.ok ? "Enter an amount of zero or more" : n.error;
|
|
37
38
|
}
|
|
38
|
-
function
|
|
39
|
-
const
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
39
|
+
function Ta(b, n, x, f = {}) {
|
|
40
|
+
const i = b ? Object.keys(x).filter((M) => Math.abs(B(x[M]) - B(b[M])) < 5e-3) : [];
|
|
41
|
+
if (i.length === 0) return { merge: { ...x, ...f }, replace: null };
|
|
42
|
+
const k = Object.fromEntries(
|
|
43
|
+
Object.entries({ ...n ?? {}, ...x, ...f }).filter(([M]) => !i.includes(M))
|
|
44
|
+
);
|
|
45
|
+
return {
|
|
46
|
+
merge: null,
|
|
47
|
+
replace: Object.keys(k).some((M) => !M.startsWith("_")) ? k : null
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function Pa(b, n) {
|
|
51
|
+
return b[0] === "item" && b.length >= 3 && String(b[2]) === String(n);
|
|
52
|
+
}
|
|
53
|
+
function ja(b) {
|
|
54
|
+
const { column: n, actual: x, openColumns: f, mode: i } = b, k = b.targetRow != null, M = F(B(b.row[n]) - x), E = { [n]: F(x) }, K = b.targetRow ?? b.row, L = k ? {} : E;
|
|
55
|
+
if (i === "none" || Math.abs(M) < 5e-3 || f.length === 0)
|
|
56
|
+
return { patch: E, moved: 0, unabsorbed: i === "none" ? 0 : M, targets: [] };
|
|
57
|
+
let p, N;
|
|
58
|
+
if (i === "next" ? (p = [f[0]], N = [1]) : i === "weighted" ? (p = f.filter((g) => B(K[g]) > 5e-3), N = p.map((g) => B(K[g])), p.length === 0 && k && M > 0 && (p = f, N = p.map(() => 1))) : (p = f, N = p.map(() => 1)), p.length === 0) return { patch: E, moved: 0, unabsorbed: M, targets: [] };
|
|
59
|
+
const v = N.reduce((g, j) => g + j, 0) || 1;
|
|
60
|
+
let y = M;
|
|
61
|
+
if (p.forEach((g, j) => {
|
|
62
|
+
const C = j === p.length - 1 ? y : F(M * N[j] / v), q = Math.max(0, F(B(K[g]) + C)), s = F(q - B(K[g]));
|
|
63
|
+
L[g] = q, y = F(y - s);
|
|
64
|
+
}), Math.abs(y) >= 5e-3 && y < 0)
|
|
65
|
+
for (const g of p) {
|
|
66
|
+
if (Math.abs(y) < 5e-3) break;
|
|
67
|
+
const j = Math.min(L[g], -y);
|
|
68
|
+
L[g] = F(L[g] - j), y = F(y + j);
|
|
54
69
|
}
|
|
55
|
-
return
|
|
56
|
-
patch:
|
|
70
|
+
return k ? {
|
|
71
|
+
patch: E,
|
|
57
72
|
targetPatch: L,
|
|
58
|
-
moved:
|
|
59
|
-
unabsorbed:
|
|
60
|
-
targets:
|
|
61
|
-
} : { patch: L, moved:
|
|
73
|
+
moved: F(M - y),
|
|
74
|
+
unabsorbed: y,
|
|
75
|
+
targets: p
|
|
76
|
+
} : { patch: L, moved: F(M - y), unabsorbed: y, targets: p };
|
|
62
77
|
}
|
|
63
|
-
const
|
|
64
|
-
function
|
|
78
|
+
const jt = 176, qt = 112, At = 128, Ne = "sticky left-0 z-[2] bg-white dark:bg-[hsl(var(--card))] border-r border-slate-200 dark:border-border", we = "sticky right-0 z-[2] bg-white dark:bg-[hsl(var(--card))] border-l border-slate-200 dark:border-border", Se = "bg-slate-50 dark:bg-white/[0.035]";
|
|
79
|
+
function il(b) {
|
|
65
80
|
const {
|
|
66
81
|
relatedCollection: n,
|
|
67
|
-
manyField:
|
|
68
|
-
parentId:
|
|
69
|
-
config:
|
|
70
|
-
compareSeries:
|
|
71
|
-
stats:
|
|
72
|
-
sumCap:
|
|
73
|
-
remaining:
|
|
82
|
+
manyField: x,
|
|
83
|
+
parentId: f,
|
|
84
|
+
config: i,
|
|
85
|
+
compareSeries: k,
|
|
86
|
+
stats: M,
|
|
87
|
+
sumCap: E,
|
|
88
|
+
remaining: K,
|
|
74
89
|
readOnly: L = !1,
|
|
75
|
-
showHistory:
|
|
76
|
-
emptyLabel:
|
|
77
|
-
} =
|
|
78
|
-
data:
|
|
79
|
-
isLoading:
|
|
80
|
-
dataUpdatedAt:
|
|
81
|
-
} =
|
|
82
|
-
queryKey: ["o2m-rows", n,
|
|
83
|
-
queryFn: () =>
|
|
84
|
-
|
|
90
|
+
showHistory: p = !0,
|
|
91
|
+
emptyLabel: N
|
|
92
|
+
} = b, v = ma(), y = sa(), g = Oa(), j = Ra(), I = ha(), C = I == null ? void 0 : I.draft, { isAdmin: q } = fa(), s = !f || f === "new", O = !L && !!g, h = i.value_fields, R = i.total_field ?? null, {
|
|
93
|
+
data: T = [],
|
|
94
|
+
isLoading: de,
|
|
95
|
+
dataUpdatedAt: re
|
|
96
|
+
} = he({
|
|
97
|
+
queryKey: ["o2m-rows", n, x, f, ""],
|
|
98
|
+
queryFn: () => v.request(
|
|
99
|
+
fe(`/items/${n}`, { filter: JSON.stringify({ [x]: { _eq: f } }), limit: 200 })
|
|
85
100
|
).then((e) => e.data ?? []),
|
|
86
|
-
enabled: !
|
|
101
|
+
enabled: !s,
|
|
87
102
|
staleTime: 3e4
|
|
88
|
-
}),
|
|
89
|
-
queryKey: ["o2m-cell-provenance", n,
|
|
90
|
-
queryFn: () =>
|
|
91
|
-
|
|
103
|
+
}), A = xa(2e3), { data: le = {} } = he({
|
|
104
|
+
queryKey: ["o2m-cell-provenance", n, x, f, re],
|
|
105
|
+
queryFn: () => v.request(
|
|
106
|
+
fe("/revisions/o2m-cell-provenance", {
|
|
92
107
|
collection: n,
|
|
93
|
-
many_field:
|
|
94
|
-
parent_id:
|
|
108
|
+
many_field: x,
|
|
109
|
+
parent_id: f
|
|
95
110
|
})
|
|
96
111
|
).then((e) => e.data ?? {}),
|
|
97
|
-
enabled:
|
|
112
|
+
enabled: A && p && !s && T.length > 0,
|
|
98
113
|
staleTime: 6e4,
|
|
99
114
|
placeholderData: (e) => e
|
|
100
|
-
}), V = (e, a) => e.id ? `${n}:${e.id}:${a}` : void 0,
|
|
115
|
+
}), V = (e, a) => e.id ? `${n}:${e.id}:${a}` : void 0, ce = (e, a) => {
|
|
101
116
|
var l;
|
|
102
117
|
return e.id && !e.edited ? (l = le[e.id]) == null ? void 0 : l[a] : void 0;
|
|
103
|
-
}, w =
|
|
118
|
+
}, w = me(null), xe = (e, a) => {
|
|
104
119
|
!e || typeof window > "u" || window.dispatchEvent(new CustomEvent("nvr:cell-editing", { detail: { cell: e, state: a } }));
|
|
105
|
-
},
|
|
106
|
-
var l, r,
|
|
107
|
-
const a = ((
|
|
108
|
-
a !== w.current && (w.current &&
|
|
109
|
-
},
|
|
120
|
+
}, zt = (e) => {
|
|
121
|
+
var l, r, o;
|
|
122
|
+
const a = ((o = (r = (l = e.target) == null ? void 0 : l.closest) == null ? void 0 : r.call(l, "[data-grid-cell]")) == null ? void 0 : o.getAttribute("data-grid-cell")) ?? null;
|
|
123
|
+
a !== w.current && (w.current && xe(w.current, "end"), w.current = a, a && xe(a, "start"));
|
|
124
|
+
}, Ut = (e) => {
|
|
110
125
|
var a, l;
|
|
111
|
-
(l = (a = e.relatedTarget) == null ? void 0 : a.closest) != null && l.call(a, "[data-grid-cell]") || (w.current &&
|
|
126
|
+
(l = (a = e.relatedTarget) == null ? void 0 : a.closest) != null && l.call(a, "[data-grid-cell]") || (w.current && xe(w.current, "end"), w.current = null);
|
|
112
127
|
};
|
|
113
|
-
|
|
128
|
+
ue(
|
|
114
129
|
() => () => {
|
|
115
|
-
w.current &&
|
|
130
|
+
w.current && xe(w.current, "end");
|
|
116
131
|
},
|
|
117
132
|
[]
|
|
118
133
|
);
|
|
119
|
-
const
|
|
120
|
-
() =>
|
|
121
|
-
[
|
|
122
|
-
),
|
|
123
|
-
client:
|
|
124
|
-
endpoint:
|
|
125
|
-
enabled: !!
|
|
126
|
-
}),
|
|
134
|
+
const qe = Z(
|
|
135
|
+
() => k != null && k.endpoint ? va(k.endpoint, C) : null,
|
|
136
|
+
[k == null ? void 0 : k.endpoint, C]
|
|
137
|
+
), Ae = Na({
|
|
138
|
+
client: v,
|
|
139
|
+
endpoint: qe,
|
|
140
|
+
enabled: !!k && !s
|
|
141
|
+
}), u = k && !s ? Ae.data ?? null : null, ht = Ae.refetch, Fe = me(0);
|
|
142
|
+
ue(() => {
|
|
143
|
+
if (!(!re || !k || s)) {
|
|
144
|
+
if (Fe.current === 0) {
|
|
145
|
+
Fe.current = re;
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
re !== Fe.current && (Fe.current = re, ht());
|
|
149
|
+
}
|
|
150
|
+
}, [re, ht, k, s]);
|
|
151
|
+
const ge = Z(() => !i.split_endpoint || s ? null : i.split_endpoint.replace(
|
|
127
152
|
/\$parent\.([A-Za-z_][A-Za-z0-9_]*)/g,
|
|
128
|
-
(e, a) => String(a === "id" ?
|
|
129
|
-
), [
|
|
130
|
-
queryKey:
|
|
131
|
-
queryFn: () =>
|
|
132
|
-
enabled: !!
|
|
153
|
+
(e, a) => String(a === "id" ? f : (C == null ? void 0 : C[a]) ?? "")
|
|
154
|
+
), [i.split_endpoint, s, f, C]), Ue = Z(() => ["plan-grid-split-info", ge], [ge]), { data: pe = null } = he({
|
|
155
|
+
queryKey: Ue,
|
|
156
|
+
queryFn: () => v.request(fe(ge)).then((e) => e.data ?? null).catch(() => null),
|
|
157
|
+
enabled: !!ge,
|
|
133
158
|
staleTime: 3e4
|
|
134
|
-
}), { data:
|
|
135
|
-
queryKey: ["plan-grid-categories",
|
|
159
|
+
}), { data: ft = {} } = he({
|
|
160
|
+
queryKey: ["plan-grid-categories", i.category_collection, i.category_label_field],
|
|
136
161
|
queryFn: async () => {
|
|
137
|
-
const e =
|
|
138
|
-
|
|
162
|
+
const e = i.category_label_field ?? "name", a = await v.request(
|
|
163
|
+
fe(`/items/${i.category_collection}`, { fields: `id,${e}`, limit: 100 })
|
|
139
164
|
);
|
|
140
165
|
return Object.fromEntries((a.data ?? []).map((l) => [String(l.id), String(l[e] ?? l.id)]));
|
|
141
166
|
},
|
|
142
|
-
enabled: !!
|
|
167
|
+
enabled: !!i.category_collection,
|
|
143
168
|
staleTime: 10 * 6e4
|
|
144
|
-
}),
|
|
145
|
-
(e) => e ===
|
|
146
|
-
[
|
|
147
|
-
),
|
|
148
|
-
|
|
149
|
-
const e =
|
|
150
|
-
if (
|
|
151
|
-
const a = () => void
|
|
169
|
+
}), ye = ee(
|
|
170
|
+
(e) => e === ze ? i.unclassified_label ?? "Unclassified" : ft[e] ?? `#${e}`,
|
|
171
|
+
[ft, i.unclassified_label]
|
|
172
|
+
), We = Z(() => (i.categories ?? []).map(String), [i.categories]), He = (g == null ? void 0 : g.getPendingRows(n, x)) ?? [], se = g == null ? void 0 : g.getPendingEdits(n, x), be = g == null ? void 0 : g.getPendingDeletes(n, x), Ke = He.length + ((se == null ? void 0 : se.size) ?? 0) + ((be == null ? void 0 : be.size) ?? 0), xt = me(Ke);
|
|
173
|
+
ue(() => {
|
|
174
|
+
const e = xt.current;
|
|
175
|
+
if (xt.current = Ke, s || !(e > 0 && Ke === 0)) return;
|
|
176
|
+
const a = () => void y.invalidateQueries({ predicate: (r) => Pa(r.queryKey, f) });
|
|
152
177
|
a();
|
|
153
178
|
const l = setTimeout(a, 2e3);
|
|
154
179
|
return () => clearTimeout(l);
|
|
155
|
-
}, [
|
|
156
|
-
const
|
|
180
|
+
}, [Ke, s, f, y]);
|
|
181
|
+
const J = Z(() => {
|
|
157
182
|
const e = [], a = (l) => l && typeof l == "object" && "id" in l ? l.id : l;
|
|
158
|
-
for (const l of
|
|
183
|
+
for (const l of T) {
|
|
159
184
|
const r = String(l.id);
|
|
160
|
-
if (
|
|
161
|
-
const
|
|
185
|
+
if (be != null && be.has(r)) continue;
|
|
186
|
+
const o = se == null ? void 0 : se.get(r), m = o ? { ...l, ...o } : l, _ = a(m[i.category_field]);
|
|
162
187
|
e.push({
|
|
163
188
|
uid: `s:${r}`,
|
|
164
189
|
id: r,
|
|
165
190
|
pendingIndex: null,
|
|
166
|
-
key: String(a(
|
|
167
|
-
cat:
|
|
168
|
-
values:
|
|
169
|
-
edited: !!
|
|
191
|
+
key: String(a(m[i.key_field]) ?? ""),
|
|
192
|
+
cat: _ == null || _ === "" ? null : String(_),
|
|
193
|
+
values: m,
|
|
194
|
+
edited: !!o && Object.keys(o).some((U) => !U.startsWith("_")),
|
|
170
195
|
isNew: !1
|
|
171
196
|
});
|
|
172
197
|
}
|
|
173
|
-
return
|
|
174
|
-
const
|
|
198
|
+
return He.forEach((l, r) => {
|
|
199
|
+
const o = a(l[i.category_field]);
|
|
175
200
|
e.push({
|
|
176
201
|
uid: `p:${r}`,
|
|
177
202
|
id: null,
|
|
178
203
|
pendingIndex: r,
|
|
179
|
-
key: String(a(l[
|
|
180
|
-
cat:
|
|
204
|
+
key: String(a(l[i.key_field]) ?? ""),
|
|
205
|
+
cat: o == null || o === "" ? null : String(o),
|
|
181
206
|
values: l,
|
|
182
207
|
edited: !1,
|
|
183
208
|
isNew: !0
|
|
184
209
|
});
|
|
185
210
|
}), e;
|
|
186
|
-
}, [
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
211
|
+
}, [T, He, se, be, i.key_field, i.category_field]), gt = me(J);
|
|
212
|
+
gt.current = J;
|
|
213
|
+
const yt = me(() => "");
|
|
214
|
+
ue(
|
|
215
|
+
() => ya(n, (e) => {
|
|
216
|
+
const a = gt.current.find((l) => l.id === e);
|
|
217
|
+
return a ? yt.current(a) : null;
|
|
218
|
+
}),
|
|
219
|
+
[n]
|
|
220
|
+
);
|
|
221
|
+
const Y = ee(
|
|
222
|
+
(e) => F(h.reduce((a, l) => a + B(e[l]), 0)),
|
|
223
|
+
[h]
|
|
224
|
+
), oe = Z(() => {
|
|
190
225
|
const e = /* @__PURE__ */ new Map();
|
|
191
|
-
for (const a of
|
|
226
|
+
for (const a of J) {
|
|
192
227
|
if (!a.key) continue;
|
|
193
228
|
let l = e.get(a.key);
|
|
194
229
|
l || (l = { key: a.key, mode: "top", top: null, cats: [] }, e.set(a.key, l)), a.cat == null ? l.top = l.top ?? a : l.cats.push(a);
|
|
195
230
|
}
|
|
196
231
|
for (const a of e.values())
|
|
197
232
|
a.cats.length && (a.mode = "split", a.cats.sort((l, r) => {
|
|
198
|
-
const
|
|
199
|
-
return (
|
|
233
|
+
const o = We.indexOf(l.cat), m = We.indexOf(r.cat);
|
|
234
|
+
return (o < 0 ? 99 : o) - (m < 0 ? 99 : m);
|
|
200
235
|
}));
|
|
201
|
-
for (const a of (
|
|
236
|
+
for (const a of (u == null ? void 0 : u.rows) ?? []) {
|
|
202
237
|
const l = String(a.key);
|
|
203
|
-
e.has(l) ||
|
|
238
|
+
e.has(l) || h.some((r) => Math.abs(B(a.values[r])) >= 5e-3) && e.set(l, { key: l, mode: "ghost", top: null, cats: [] });
|
|
204
239
|
}
|
|
205
240
|
return [...e.values()].sort(
|
|
206
241
|
(a, l) => Number(a.key) - Number(l.key) || a.key.localeCompare(l.key)
|
|
207
242
|
);
|
|
208
|
-
}, [
|
|
209
|
-
() =>
|
|
210
|
-
[
|
|
211
|
-
),
|
|
212
|
-
|
|
213
|
-
if (
|
|
214
|
-
if (
|
|
215
|
-
|
|
243
|
+
}, [J, u, h, We]), _e = Z(
|
|
244
|
+
() => J.map((e) => R ? { ...e.values, [R]: Y(e.values) } : e.values),
|
|
245
|
+
[J, R, Y]
|
|
246
|
+
), ke = j == null ? void 0 : j.report;
|
|
247
|
+
ue(() => {
|
|
248
|
+
if (ke) {
|
|
249
|
+
if (de) {
|
|
250
|
+
ke(n, x, null);
|
|
216
251
|
return;
|
|
217
252
|
}
|
|
218
|
-
|
|
253
|
+
ke(n, x, _e);
|
|
219
254
|
}
|
|
220
|
-
}, [
|
|
221
|
-
const
|
|
255
|
+
}, [ke, n, x, _e, de]);
|
|
256
|
+
const bt = me(() => {
|
|
222
257
|
});
|
|
223
|
-
|
|
258
|
+
bt.current = () => ke == null ? void 0 : ke(n, x, null), ue(() => () => bt.current(), []);
|
|
224
259
|
const Oe = ee(
|
|
225
260
|
(e) => {
|
|
226
|
-
if (e.startsWith("$parent.")) return (
|
|
261
|
+
if (e.startsWith("$parent.")) return (C == null ? void 0 : C[e.slice(8)]) ?? 0;
|
|
227
262
|
if (e.startsWith("$sum.")) {
|
|
228
263
|
const a = e.slice(5);
|
|
229
|
-
return _e.reduce((l, r) => l +
|
|
264
|
+
return _e.reduce((l, r) => l + B(r[a]), 0);
|
|
230
265
|
}
|
|
231
|
-
return e === "$count" ? _e.length :
|
|
266
|
+
return e === "$count" ? _e.length : C == null ? void 0 : C[e];
|
|
232
267
|
},
|
|
233
|
-
[
|
|
234
|
-
),
|
|
235
|
-
() => (
|
|
236
|
-
[
|
|
237
|
-
),
|
|
238
|
-
() =>
|
|
239
|
-
[
|
|
240
|
-
),
|
|
241
|
-
const a =
|
|
242
|
-
|
|
268
|
+
[C, _e]
|
|
269
|
+
), kt = Z(
|
|
270
|
+
() => (M ?? []).map((e) => ({ ...e, result: nt(e.value, Oe) })),
|
|
271
|
+
[M, Oe]
|
|
272
|
+
), Qe = Z(
|
|
273
|
+
() => F(J.reduce((e, a) => e + Y(a.values), 0)),
|
|
274
|
+
[J, Y]
|
|
275
|
+
), Re = Z(() => pe ? pe.categories.filter((e) => e.cap > 5e-3 || J.some((a) => a.cat === String(e.id))).map((e) => {
|
|
276
|
+
const a = F(
|
|
277
|
+
J.filter((l) => l.cat === String(e.id)).reduce((l, r) => l + Y(r.values), 0)
|
|
243
278
|
);
|
|
244
279
|
return {
|
|
245
280
|
id: String(e.id),
|
|
246
281
|
label: e.label,
|
|
247
282
|
cap: e.cap,
|
|
248
283
|
planned: a,
|
|
249
|
-
left:
|
|
284
|
+
left: F(e.cap - a)
|
|
250
285
|
};
|
|
251
|
-
}) : [], [
|
|
252
|
-
(e, a) =>
|
|
253
|
-
[
|
|
254
|
-
),
|
|
255
|
-
(e, a) => !
|
|
256
|
-
[
|
|
257
|
-
),
|
|
286
|
+
}) : [], [pe, J, Y]), G = ee(
|
|
287
|
+
(e, a) => wa(u, e, a),
|
|
288
|
+
[u]
|
|
289
|
+
), Ie = ee(
|
|
290
|
+
(e, a) => !O || G(e, a) && !!(u != null && u.closed_locked) && !q,
|
|
291
|
+
[O, G, u == null ? void 0 : u.closed_locked, q]
|
|
292
|
+
), Le = ee(
|
|
258
293
|
(e, a, l) => {
|
|
259
|
-
var
|
|
260
|
-
const r =
|
|
294
|
+
var m, _, U;
|
|
295
|
+
const r = u == null ? void 0 : u.rows.find((P) => String(P.key) === e);
|
|
261
296
|
if (!r) return { value: 0, details: [] };
|
|
262
|
-
if (a == null) return { value:
|
|
263
|
-
const
|
|
264
|
-
return { value:
|
|
297
|
+
if (a == null) return { value: B(r.values[l]), details: ((m = r.details) == null ? void 0 : m[l]) ?? [] };
|
|
298
|
+
const o = (_ = r.by_category) == null ? void 0 : _[a];
|
|
299
|
+
return { value: B(o == null ? void 0 : o.values[l]), details: ((U = o == null ? void 0 : o.details) == null ? void 0 : U[l]) ?? [] };
|
|
265
300
|
},
|
|
266
|
-
[
|
|
267
|
-
), [
|
|
301
|
+
[u]
|
|
302
|
+
), [vt, Ve] = W(null), X = ee(
|
|
268
303
|
(e, a, l, r) => {
|
|
269
|
-
if (!
|
|
270
|
-
const
|
|
271
|
-
if (U -
|
|
272
|
-
if (
|
|
273
|
-
const
|
|
274
|
-
if (
|
|
275
|
-
return
|
|
276
|
-
`${
|
|
304
|
+
if (!g) return !1;
|
|
305
|
+
const o = (r == null ? void 0 : r.credit) ?? 0, m = { ...e.values, ...a }, _ = Y(e.values), U = Y(m);
|
|
306
|
+
if (U - o > _ + 5e-3) {
|
|
307
|
+
if (E) {
|
|
308
|
+
const P = nt(E.cap, Oe), $ = F(Qe - _ + U - o);
|
|
309
|
+
if (P != null && $ > P + 5e-3)
|
|
310
|
+
return Ve(
|
|
311
|
+
`${E.message ?? `${E.label ?? "The total"} cannot exceed ${z(P)}`} — this would reach ${z($)}, ${z(F($ - P))} over.`
|
|
277
312
|
), !1;
|
|
278
313
|
}
|
|
279
314
|
if (e.cat != null) {
|
|
280
|
-
const
|
|
281
|
-
if (
|
|
282
|
-
const
|
|
283
|
-
if (
|
|
284
|
-
return
|
|
285
|
-
`${
|
|
315
|
+
const P = Re.find(($) => $.id === e.cat);
|
|
316
|
+
if (P) {
|
|
317
|
+
const $ = F(P.planned - _ + U - o);
|
|
318
|
+
if ($ > P.cap + 5e-3)
|
|
319
|
+
return Ve(
|
|
320
|
+
`${P.label} would reach ${z($)} — ${z(F($ - P.cap))} over its ${z(P.cap)}.`
|
|
286
321
|
), !1;
|
|
287
322
|
}
|
|
288
323
|
}
|
|
289
324
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
325
|
+
if (Ve(null), e.id) {
|
|
326
|
+
const P = {
|
|
327
|
+
...l ? { _change_reason: l } : {},
|
|
328
|
+
...r != null && r.early ? { __flush_early: !0 } : {}
|
|
329
|
+
}, $ = Ta(
|
|
330
|
+
T.find((H) => String(H.id) === e.id),
|
|
331
|
+
se == null ? void 0 : se.get(e.id),
|
|
332
|
+
a,
|
|
333
|
+
P
|
|
334
|
+
);
|
|
335
|
+
$.merge ? g.queueEdit(n, x, e.id, $.merge) : (g.cancelPendingEdit(n, x, e.id), $.replace && g.queueEdit(n, x, e.id, $.replace));
|
|
336
|
+
} else e.pendingIndex != null && g.updateRow(n, x, e.pendingIndex, {
|
|
295
337
|
...e.values,
|
|
296
338
|
...a,
|
|
297
339
|
...l ? { _change_reason: l } : {}
|
|
298
|
-
})
|
|
340
|
+
});
|
|
341
|
+
return !0;
|
|
299
342
|
},
|
|
300
|
-
[
|
|
343
|
+
[
|
|
344
|
+
g,
|
|
345
|
+
Y,
|
|
346
|
+
E,
|
|
347
|
+
Oe,
|
|
348
|
+
Qe,
|
|
349
|
+
Re,
|
|
350
|
+
n,
|
|
351
|
+
x,
|
|
352
|
+
T,
|
|
353
|
+
se
|
|
354
|
+
]
|
|
301
355
|
), Me = ee(
|
|
302
356
|
(e, a, l, r) => {
|
|
303
|
-
|
|
304
|
-
[
|
|
305
|
-
...r != null ? { [
|
|
306
|
-
...Object.fromEntries(
|
|
357
|
+
g && g.queueRow(n, x, {
|
|
358
|
+
[i.key_field]: e,
|
|
359
|
+
...r != null ? { [i.category_field]: /^\d+$/.test(r) ? Number(r) : r } : {},
|
|
360
|
+
...Object.fromEntries(h.map((o) => [o, (a == null ? void 0 : a[o]) ?? 0])),
|
|
307
361
|
...l ? { _change_reason: l } : {}
|
|
308
362
|
});
|
|
309
363
|
},
|
|
310
|
-
[
|
|
311
|
-
), { data:
|
|
312
|
-
queryKey: ["plan-grid-keys",
|
|
313
|
-
queryFn: () =>
|
|
314
|
-
|
|
364
|
+
[g, n, x, i.key_field, i.category_field, h]
|
|
365
|
+
), { data: Je } = he({
|
|
366
|
+
queryKey: ["plan-grid-keys", i.key_collection],
|
|
367
|
+
queryFn: () => v.request(
|
|
368
|
+
fe(`/items/${i.key_collection}`, { fields: "id", sort: "-id", limit: 200 })
|
|
315
369
|
).then((e) => (e.data ?? []).map((a) => a.id)),
|
|
316
|
-
enabled: !!
|
|
370
|
+
enabled: !!i.key_collection && !!(u != null && u.closed_through),
|
|
317
371
|
staleTime: 10 * 6e4
|
|
318
|
-
}),
|
|
372
|
+
}), Ge = ee(
|
|
319
373
|
(e, a) => {
|
|
320
374
|
const l = Number(e);
|
|
321
375
|
if (!Number.isInteger(l)) return null;
|
|
322
|
-
const r = String(l + 1),
|
|
323
|
-
let
|
|
324
|
-
return
|
|
376
|
+
const r = String(l + 1), o = h.filter((P) => !G(r, P)), m = oe.find((P) => P.key === r);
|
|
377
|
+
let _ = null, U = null;
|
|
378
|
+
return i.key_collection && Je && !Je.some((P) => String(P) === r) ? U = `${r} is not set up yet` : o.length === 0 ? U = `${r} has no open period either` : (m == null ? void 0 : m.mode) === "split" ? a == null ? U = `${r} is planned by category and this line is not` : _ = m.cats.find((P) => P.cat === a) ?? null : (m == null ? void 0 : m.mode) === "top" && (a != null ? U = `${r} is planned as one line and this one is by category` : _ = m.top), { key: r, cat: a, openColumns: o, row: _, blocked: U };
|
|
325
379
|
},
|
|
326
|
-
[
|
|
327
|
-
),
|
|
380
|
+
[h, G, oe, i.key_collection, Je]
|
|
381
|
+
), Ze = ee(
|
|
328
382
|
(e, a, l, r) => {
|
|
329
383
|
if (!r || Object.keys(r.patch).length === 0) return X(e, a, l);
|
|
330
|
-
const
|
|
331
|
-
Y({ ...(
|
|
384
|
+
const o = F(Y({ ...e.values, ...a }) - Y(e.values)), m = r.target.row, _ = F(
|
|
385
|
+
Y({ ...(m == null ? void 0 : m.values) ?? {}, ...r.patch }) - Y((m == null ? void 0 : m.values) ?? {})
|
|
332
386
|
);
|
|
333
|
-
return
|
|
387
|
+
return o <= 0 ? m ? X(m, r.patch, l, { credit: -o }) ? X(e, a, l, { early: !0 }) : !1 : _ > -o + 5e-3 || !X(e, a, l, { early: !0 }) ? !1 : (Me(Number(r.target.key), r.patch, l, r.target.cat), !0) : m ? X(e, a, l, { credit: -_ }) ? X(m, r.patch, l, { early: !0 }) : !1 : X(e, a, l);
|
|
334
388
|
},
|
|
335
389
|
[X, Y, Me]
|
|
336
|
-
),
|
|
390
|
+
), Wt = ee(
|
|
337
391
|
(e) => {
|
|
338
|
-
if (!
|
|
392
|
+
if (!g) return;
|
|
339
393
|
const a = [...e.top ? [e.top] : [], ...e.cats];
|
|
340
|
-
for (const l of a.filter((r) => r.pendingIndex != null).sort((r,
|
|
341
|
-
|
|
342
|
-
for (const l of a) l.id &&
|
|
394
|
+
for (const l of a.filter((r) => r.pendingIndex != null).sort((r, o) => (o.pendingIndex ?? 0) - (r.pendingIndex ?? 0)))
|
|
395
|
+
g.removeRow(n, x, l.pendingIndex);
|
|
396
|
+
for (const l of a) l.id && g.queueDelete(n, x, l.id);
|
|
343
397
|
},
|
|
344
|
-
[
|
|
345
|
-
),
|
|
346
|
-
|
|
347
|
-
}, [
|
|
398
|
+
[g, n, x]
|
|
399
|
+
), Ht = ee(() => {
|
|
400
|
+
y.invalidateQueries({ queryKey: ["o2m-rows", n, x, f] }), y.invalidateQueries({ queryKey: Ue }), qe && y.invalidateQueries({ queryKey: ["o2m-compare", qe] });
|
|
401
|
+
}, [y, n, x, f, Ue, qe]), Ye = me(null), ve = Z(() => {
|
|
348
402
|
const e = [];
|
|
349
|
-
for (const a of
|
|
403
|
+
for (const a of oe)
|
|
350
404
|
if (a.mode === "top" && a.top && e.push(a.top.uid), a.mode === "split") for (const l of a.cats) e.push(l.uid);
|
|
351
405
|
return e;
|
|
352
|
-
}, [
|
|
406
|
+
}, [oe]), Nt = ee((e, a) => {
|
|
353
407
|
var r;
|
|
354
|
-
const l = (r =
|
|
408
|
+
const l = (r = Ye.current) == null ? void 0 : r.querySelector(`[data-pg-cell="${e}:${a}"]`);
|
|
355
409
|
return l ? (l.focus(), l.select(), !0) : !1;
|
|
356
|
-
}, []),
|
|
410
|
+
}, []), wt = ee(
|
|
357
411
|
(e, a, l, r) => {
|
|
358
|
-
let
|
|
359
|
-
for (let
|
|
360
|
-
if (
|
|
412
|
+
let o = ve.indexOf(e), m = h.indexOf(a);
|
|
413
|
+
for (let _ = 0; _ < 40; _++)
|
|
414
|
+
if (o += l, m += r, o < 0 || o >= ve.length || m < 0 || m >= h.length || Nt(ve[o], h[m])) return;
|
|
361
415
|
},
|
|
362
|
-
[
|
|
363
|
-
),
|
|
416
|
+
[ve, h, Nt]
|
|
417
|
+
), $t = ee(
|
|
364
418
|
(e, a, l) => {
|
|
365
419
|
const r = l.replace(/\r/g, "").split(`
|
|
366
|
-
`).filter((
|
|
367
|
-
let
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
420
|
+
`).filter((P) => P.trim() !== ""), o = ve.indexOf(e.uid), m = h.indexOf(a);
|
|
421
|
+
let _ = 0;
|
|
422
|
+
const U = [];
|
|
423
|
+
r.forEach((P, $) => {
|
|
424
|
+
const H = J.find((d) => d.uid === ve[o + $]);
|
|
425
|
+
if (!H) return;
|
|
426
|
+
const te = {};
|
|
427
|
+
P.split(" ").forEach((d, S) => {
|
|
428
|
+
const ae = h[m + S];
|
|
429
|
+
if (!ae || Ie(H.key, ae)) return;
|
|
430
|
+
const Pe = Bt(d);
|
|
431
|
+
if (Pe == null || Pe < 0) {
|
|
432
|
+
U.push(d.trim());
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
te[ae] = Pe;
|
|
436
|
+
}), Object.keys(te).length && X(H, te) && (_ += Object.keys(te).length);
|
|
437
|
+
}), U.length && ie.error(
|
|
438
|
+
`${U.length} pasted ${U.length === 1 ? "cell was" : "cells were"} left out — ${Dt(U[0])}`
|
|
439
|
+
), _ && ie.success(`Pasted ${_} ${_ === 1 ? "figure" : "figures"}`);
|
|
379
440
|
},
|
|
380
|
-
[
|
|
381
|
-
), [
|
|
382
|
-
|
|
441
|
+
[ve, h, J, Ie, X]
|
|
442
|
+
), [Qt, Ct] = W(/* @__PURE__ */ new Set()), Xe = me(null);
|
|
443
|
+
ue(() => {
|
|
383
444
|
const e = (a) => {
|
|
384
445
|
const l = a.detail;
|
|
385
446
|
if (!l || l.collection !== n || l.rowId == null) return;
|
|
386
|
-
const r =
|
|
387
|
-
r && (l.handled = !0,
|
|
388
|
-
|
|
389
|
-
}, 8e3),
|
|
390
|
-
if (!
|
|
391
|
-
const
|
|
392
|
-
return
|
|
447
|
+
const r = J.find((o) => o.id === String(l.rowId));
|
|
448
|
+
r && (l.handled = !0, Xe.current !== r.id && (Xe.current = r.id, window.setTimeout(() => {
|
|
449
|
+
Xe.current = null;
|
|
450
|
+
}, 8e3), Ct((o) => {
|
|
451
|
+
if (!o.has(r.key)) return o;
|
|
452
|
+
const m = new Set(o);
|
|
453
|
+
return m.delete(r.key), m;
|
|
393
454
|
}), window.setTimeout(() => {
|
|
394
|
-
var
|
|
395
|
-
const
|
|
396
|
-
|
|
455
|
+
var m;
|
|
456
|
+
const o = (m = Ye.current) == null ? void 0 : m.querySelector(`[data-o2m-row="${n}:${r.id}"]`);
|
|
457
|
+
o && (o.scrollIntoView({ block: "center", behavior: "smooth" }), o.classList.remove("nvr-row-flash"), o.offsetWidth, o.classList.add("nvr-row-flash"));
|
|
397
458
|
}, 60)));
|
|
398
459
|
};
|
|
399
460
|
return window.addEventListener("nvr:grid-open-row", e), () => window.removeEventListener("nvr:grid-open-row", e);
|
|
400
|
-
}, [n,
|
|
401
|
-
const [
|
|
461
|
+
}, [n, J]);
|
|
462
|
+
const [Vt, Jt] = W(() => {
|
|
402
463
|
try {
|
|
403
464
|
return new Set(
|
|
404
|
-
JSON.parse(localStorage.getItem(`nvr_pg_dismissed:${n}:${
|
|
465
|
+
JSON.parse(localStorage.getItem(`nvr_pg_dismissed:${n}:${f}`) ?? "[]")
|
|
405
466
|
);
|
|
406
467
|
} catch {
|
|
407
468
|
return /* @__PURE__ */ new Set();
|
|
408
469
|
}
|
|
409
|
-
}),
|
|
410
|
-
|
|
470
|
+
}), St = ((u == null ? void 0 : u.proposals) ?? []).filter((e) => !Vt.has(e.id)), _t = (e, a) => {
|
|
471
|
+
Jt((l) => {
|
|
411
472
|
const r = new Set(l).add(e.id);
|
|
412
473
|
if (a)
|
|
413
474
|
try {
|
|
414
|
-
localStorage.setItem(`nvr_pg_dismissed:${n}:${
|
|
475
|
+
localStorage.setItem(`nvr_pg_dismissed:${n}:${f}`, JSON.stringify([...r]));
|
|
415
476
|
} catch {
|
|
416
477
|
}
|
|
417
478
|
return r;
|
|
418
479
|
});
|
|
419
|
-
},
|
|
480
|
+
}, Gt = (e) => {
|
|
420
481
|
let a = 0;
|
|
421
482
|
for (const l of e.rows) {
|
|
422
|
-
const r = String(l.key),
|
|
423
|
-
if ((
|
|
424
|
-
const
|
|
483
|
+
const r = String(l.key), o = oe.find(($) => $.key === r);
|
|
484
|
+
if ((o == null ? void 0 : o.mode) === "split" != (l.category != null)) continue;
|
|
485
|
+
const m = e.mode === "add", _ = Object.fromEntries(
|
|
425
486
|
Object.entries(l.values).filter(
|
|
426
|
-
([
|
|
487
|
+
([$, H]) => h.includes($) && !G(r, $) && (m ? B(H) !== 0 : B(H) > 0)
|
|
427
488
|
)
|
|
428
|
-
), U = (
|
|
429
|
-
Object.entries(
|
|
430
|
-
),
|
|
489
|
+
), U = ($) => Object.fromEntries(
|
|
490
|
+
Object.entries(_).map(([H, te]) => [H, Math.max(0, F(B($ == null ? void 0 : $[H]) + B(te)))]).filter(([H, te]) => Math.abs(te - B($ == null ? void 0 : $[H])) >= 5e-3)
|
|
491
|
+
), P = l.category != null ? o == null ? void 0 : o.cats.find(($) => String($.cat) === String(l.category)) : null;
|
|
431
492
|
if (l.category != null) {
|
|
432
|
-
if (!
|
|
433
|
-
const
|
|
434
|
-
Object.keys(
|
|
435
|
-
} else if (
|
|
436
|
-
const
|
|
493
|
+
if (!P) continue;
|
|
494
|
+
const $ = m ? U(P.values) : Object.fromEntries(Object.entries(_).filter(([H]) => B(P.values[H]) === 0));
|
|
495
|
+
Object.keys($).length && X(P, $, e.change_reason) && (a += Object.keys($).length);
|
|
496
|
+
} else if (o != null && o.top) {
|
|
497
|
+
const $ = m ? U(o.top.values) : Object.fromEntries(Object.entries(_).filter(([H]) => {
|
|
437
498
|
var te;
|
|
438
|
-
return
|
|
499
|
+
return B((te = o.top) == null ? void 0 : te.values[H]) === 0;
|
|
439
500
|
}));
|
|
440
|
-
Object.keys(
|
|
441
|
-
} else Object.keys(
|
|
501
|
+
Object.keys($).length && X(o.top, $, e.change_reason) && (a += Object.keys($).length);
|
|
502
|
+
} else Object.keys(_).length && !(m && Object.values(_).every(($) => B($) < 0)) && (Me(l.key, m ? U(void 0) : _, e.change_reason), a += Object.keys(_).length);
|
|
442
503
|
}
|
|
443
|
-
a ?
|
|
504
|
+
a ? ie.success(
|
|
444
505
|
`${e.label}: ${a} ${a === 1 ? "figure" : "figures"} staged — Save to keep them`
|
|
445
|
-
) :
|
|
506
|
+
) : ie.message(
|
|
446
507
|
e.mode === "add" ? "Nothing to move — no open period could take it" : "Nothing to fill — those periods already hold a figure"
|
|
447
|
-
),
|
|
448
|
-
}, [Q,
|
|
508
|
+
), _t(e, !1);
|
|
509
|
+
}, [Q, et] = W(null), Be = La(), tt = Q && (Be != null && Be.renderRowHistory) ? Be.renderRowHistory({
|
|
449
510
|
collection: n,
|
|
450
|
-
parentId:
|
|
511
|
+
parentId: f,
|
|
451
512
|
rowId: Q.id,
|
|
452
513
|
key: Q.key,
|
|
453
514
|
category: Q.cat,
|
|
454
|
-
categoryLabel: (e) =>
|
|
455
|
-
onClose: () =>
|
|
456
|
-
}) : null, { data:
|
|
515
|
+
categoryLabel: (e) => ye(String(e)),
|
|
516
|
+
onClose: () => et(null)
|
|
517
|
+
}) : null, { data: Zt = [], isLoading: Yt } = he({
|
|
457
518
|
queryKey: ["o2m-row-revisions", n, Q == null ? void 0 : Q.id],
|
|
458
|
-
queryFn: () =>
|
|
459
|
-
|
|
519
|
+
queryFn: () => v.request(
|
|
520
|
+
fe("/revisions", { collection: n, item: String(Q == null ? void 0 : Q.id) })
|
|
460
521
|
).then((e) => e.data ?? []),
|
|
461
|
-
enabled: !!(Q != null && Q.id) &&
|
|
522
|
+
enabled: !!(Q != null && Q.id) && tt == null,
|
|
462
523
|
staleTime: 15e3
|
|
463
|
-
}), { data:
|
|
524
|
+
}), { data: Ot = [] } = he({
|
|
464
525
|
queryKey: ["plan-grid-fields", n],
|
|
465
|
-
queryFn: () =>
|
|
526
|
+
queryFn: () => v.request(fe(`/field-config/${n}`)).then((e) => e.data ?? []),
|
|
466
527
|
enabled: !!Q,
|
|
467
528
|
staleTime: 5 * 6e4
|
|
468
|
-
}), [
|
|
529
|
+
}), [at, Xt] = W(!1), Rt = oe.some((e) => e.mode === "split"), Ee = It(u);
|
|
530
|
+
yt.current = (e) => `${e.key} ${Ee.toLowerCase()}${e.cat != null ? ` · ${ye(e.cat)}` : ""}`;
|
|
531
|
+
const $e = (u == null ? void 0 : u.label) ?? (k == null ? void 0 : k.label) ?? "Actual", De = $a(u == null ? void 0 : u.closed_through), Te = u != null && u.closed_through ? Number(u.closed_through.split("-")[0]) : null, ea = Z(() => {
|
|
469
532
|
if (Te == null) return null;
|
|
470
|
-
const e =
|
|
533
|
+
const e = h.filter((a) => G(String(Te), a));
|
|
471
534
|
return e[e.length - 1] ?? null;
|
|
472
|
-
}, [Te,
|
|
473
|
-
() => new Set(
|
|
474
|
-
[
|
|
475
|
-
),
|
|
476
|
-
let a =
|
|
535
|
+
}, [Te, h, G]), ta = Z(
|
|
536
|
+
() => new Set(oe.filter((e) => e.mode !== "ghost").map((e) => e.key)),
|
|
537
|
+
[oe]
|
|
538
|
+
), aa = K ? nt(K, Oe) : null, la = (e) => {
|
|
539
|
+
let a = aa ?? 0;
|
|
477
540
|
if (e.cat != null) {
|
|
478
|
-
const
|
|
479
|
-
|
|
541
|
+
const m = Re.find((_) => _.id === e.cat);
|
|
542
|
+
m && (a = Math.min(a, m.left));
|
|
480
543
|
}
|
|
481
|
-
const l =
|
|
544
|
+
const l = h.filter((m) => !G(e.key, m) && B(e.values[m]) === 0);
|
|
482
545
|
if (a < 5e-3 || l.length === 0) {
|
|
483
|
-
|
|
546
|
+
ie.message(
|
|
484
547
|
a < 5e-3 ? "Nothing is left to spread" : "No empty open periods on this line"
|
|
485
548
|
);
|
|
486
549
|
return;
|
|
487
550
|
}
|
|
488
|
-
const r = Math.floor(a / l.length * 100) / 100,
|
|
489
|
-
l.forEach((
|
|
490
|
-
|
|
491
|
-
}), X(e,
|
|
492
|
-
},
|
|
551
|
+
const r = Math.floor(a / l.length * 100) / 100, o = {};
|
|
552
|
+
l.forEach((m, _) => {
|
|
553
|
+
o[m] = _ === l.length - 1 ? F(a - r * (l.length - 1)) : r;
|
|
554
|
+
}), X(e, o) && ie.success(`${z(a)} spread over ${l.length} open periods`);
|
|
555
|
+
}, lt = Z(() => {
|
|
493
556
|
const e = {}, a = {};
|
|
494
|
-
for (const l of
|
|
495
|
-
e[l] =
|
|
557
|
+
for (const l of h)
|
|
558
|
+
e[l] = F(J.reduce((r, o) => r + B(o.values[l]), 0)), a[l] = F(((u == null ? void 0 : u.rows) ?? []).reduce((r, o) => r + B(o.values[l]), 0));
|
|
496
559
|
return { planBy: e, actualBy: a };
|
|
497
|
-
}, [
|
|
498
|
-
return !
|
|
560
|
+
}, [h, J, u]), na = jt + h.length * qt + At;
|
|
561
|
+
return !s && de ? /* @__PURE__ */ t("div", { className: "space-y-1.5", "data-plan-grid-loading": !0, children: [0, 1, 2].map((e) => /* @__PURE__ */ t(
|
|
499
562
|
"div",
|
|
500
563
|
{
|
|
501
564
|
className: "h-8 animate-pulse rounded",
|
|
502
565
|
style: { background: "hsl(var(--nvr-skeleton))" }
|
|
503
566
|
},
|
|
504
567
|
e
|
|
505
|
-
)) }) : /* @__PURE__ */
|
|
506
|
-
|
|
507
|
-
|
|
568
|
+
)) }) : /* @__PURE__ */ c("div", { ref: Ye, "data-plan-grid": n, className: "min-w-0", children: [
|
|
569
|
+
u && St.length > 0 && O && /* @__PURE__ */ t(
|
|
570
|
+
Ca,
|
|
508
571
|
{
|
|
509
|
-
proposals:
|
|
510
|
-
onApply:
|
|
511
|
-
onDismiss: (e) =>
|
|
572
|
+
proposals: St,
|
|
573
|
+
onApply: Gt,
|
|
574
|
+
onDismiss: (e) => _t(e, !0)
|
|
512
575
|
}
|
|
513
576
|
),
|
|
514
|
-
(
|
|
577
|
+
(kt.length > 0 || k) && /* @__PURE__ */ c("div", { className: "mb-2 flex flex-wrap items-center gap-1.5", "data-o2m-stats": !0, children: [
|
|
515
578
|
/* @__PURE__ */ t(
|
|
516
|
-
|
|
579
|
+
Sa,
|
|
517
580
|
{
|
|
518
|
-
data:
|
|
519
|
-
loading: !!
|
|
520
|
-
error: !!
|
|
581
|
+
data: u,
|
|
582
|
+
loading: !!k && !s && Ae.isLoading,
|
|
583
|
+
error: !!k && !s && Ae.isError
|
|
521
584
|
}
|
|
522
585
|
),
|
|
523
|
-
|
|
524
|
-
|
|
586
|
+
kt.map((e) => /* @__PURE__ */ t(
|
|
587
|
+
Tt,
|
|
525
588
|
{
|
|
526
589
|
label: e.label,
|
|
527
590
|
value: e.result,
|
|
@@ -530,26 +593,26 @@ function Ya(v) {
|
|
|
530
593
|
},
|
|
531
594
|
e.label
|
|
532
595
|
)),
|
|
533
|
-
|
|
596
|
+
Re.length > 1 && Rt && /* @__PURE__ */ c(
|
|
534
597
|
"button",
|
|
535
598
|
{
|
|
536
599
|
type: "button",
|
|
537
600
|
"data-plan-grid-categories-toggle": !0,
|
|
538
|
-
"aria-expanded":
|
|
539
|
-
onClick: () =>
|
|
601
|
+
"aria-expanded": at,
|
|
602
|
+
onClick: () => Xt((e) => !e),
|
|
540
603
|
className: "inline-flex h-[28px] items-center gap-1 rounded-md px-2 text-[11.5px] font-medium text-slate-600 hover:bg-muted dark:text-slate-300",
|
|
541
604
|
children: [
|
|
542
|
-
|
|
605
|
+
at ? /* @__PURE__ */ t(Lt, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ t(Mt, { className: "h-3.5 w-3.5" }),
|
|
543
606
|
"By category"
|
|
544
607
|
]
|
|
545
608
|
}
|
|
546
609
|
)
|
|
547
610
|
] }),
|
|
548
|
-
|
|
549
|
-
|
|
611
|
+
at && Rt && /* @__PURE__ */ t("div", { className: "mb-2 flex flex-wrap gap-1.5", "data-plan-grid-categories": !0, children: Re.map((e) => /* @__PURE__ */ t(
|
|
612
|
+
Tt,
|
|
550
613
|
{
|
|
551
614
|
dataKey: `category:${e.id}`,
|
|
552
|
-
label: `${e.label} left of ${
|
|
615
|
+
label: `${e.label} left of ${z(e.cap)}`,
|
|
553
616
|
value: e.left,
|
|
554
617
|
format: "currency",
|
|
555
618
|
negative: e.left < -5e-3
|
|
@@ -561,56 +624,56 @@ function Ya(v) {
|
|
|
561
624
|
{
|
|
562
625
|
className: "overflow-x-auto rounded-lg border border-slate-200 dark:border-border",
|
|
563
626
|
"data-plan-grid-scroll": !0,
|
|
564
|
-
onFocusCapture:
|
|
565
|
-
onBlurCapture:
|
|
566
|
-
children: /* @__PURE__ */
|
|
627
|
+
onFocusCapture: zt,
|
|
628
|
+
onBlurCapture: Ut,
|
|
629
|
+
children: /* @__PURE__ */ c(
|
|
567
630
|
"table",
|
|
568
631
|
{
|
|
569
632
|
className: "border-separate border-spacing-0 text-[12px] tabular-nums",
|
|
570
|
-
style: { width: "100%", minWidth:
|
|
633
|
+
style: { width: "100%", minWidth: na, tableLayout: "fixed" },
|
|
571
634
|
children: [
|
|
572
|
-
/* @__PURE__ */
|
|
573
|
-
/* @__PURE__ */ t("col", { style: { width:
|
|
574
|
-
|
|
575
|
-
/* @__PURE__ */ t("col", { style: { width:
|
|
635
|
+
/* @__PURE__ */ c("colgroup", { children: [
|
|
636
|
+
/* @__PURE__ */ t("col", { style: { width: jt } }),
|
|
637
|
+
h.map((e) => /* @__PURE__ */ t("col", { style: { width: qt } }, e)),
|
|
638
|
+
/* @__PURE__ */ t("col", { style: { width: At } })
|
|
576
639
|
] }),
|
|
577
|
-
/* @__PURE__ */ t("thead", { children: /* @__PURE__ */
|
|
640
|
+
/* @__PURE__ */ t("thead", { children: /* @__PURE__ */ c("tr", { children: [
|
|
578
641
|
/* @__PURE__ */ t(
|
|
579
642
|
"th",
|
|
580
643
|
{
|
|
581
|
-
className:
|
|
582
|
-
|
|
644
|
+
className: D(
|
|
645
|
+
Ne,
|
|
583
646
|
"z-[3] border-b px-3 py-1.5 text-left text-[10.5px] font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400"
|
|
584
647
|
),
|
|
585
|
-
children:
|
|
648
|
+
children: rt(i.key_field)
|
|
586
649
|
}
|
|
587
650
|
),
|
|
588
|
-
|
|
589
|
-
const a = Te != null &&
|
|
651
|
+
h.map((e) => {
|
|
652
|
+
const a = Te != null && G(String(Te), e);
|
|
590
653
|
return /* @__PURE__ */ t(
|
|
591
654
|
"th",
|
|
592
655
|
{
|
|
593
|
-
className:
|
|
656
|
+
className: D(
|
|
594
657
|
"border-b border-slate-200 px-2.5 py-1.5 text-right text-[10.5px] font-semibold uppercase tracking-wide text-slate-500 dark:border-border dark:text-slate-400",
|
|
595
|
-
a &&
|
|
658
|
+
a && Se
|
|
596
659
|
),
|
|
597
|
-
children: /* @__PURE__ */
|
|
598
|
-
e ===
|
|
660
|
+
children: /* @__PURE__ */ c("span", { className: "inline-flex items-center justify-end gap-1", children: [
|
|
661
|
+
e === ea && /* @__PURE__ */ t(
|
|
599
662
|
"span",
|
|
600
663
|
{
|
|
601
664
|
"data-plan-grid-lock": !0,
|
|
602
|
-
"data-tip": `Closed through ${
|
|
665
|
+
"data-tip": `Closed through ${De ?? ""}${u != null && u.closed_rule ? ` — ${u.closed_rule}` : ""}`,
|
|
603
666
|
className: "inline-flex",
|
|
604
667
|
children: /* @__PURE__ */ t(
|
|
605
|
-
|
|
668
|
+
oa,
|
|
606
669
|
{
|
|
607
670
|
className: "h-3 w-3",
|
|
608
|
-
"aria-label": `Closed through ${
|
|
671
|
+
"aria-label": `Closed through ${De ?? ""}`
|
|
609
672
|
}
|
|
610
673
|
)
|
|
611
674
|
}
|
|
612
675
|
),
|
|
613
|
-
|
|
676
|
+
it(e)
|
|
614
677
|
] })
|
|
615
678
|
},
|
|
616
679
|
e
|
|
@@ -619,67 +682,67 @@ function Ya(v) {
|
|
|
619
682
|
/* @__PURE__ */ t(
|
|
620
683
|
"th",
|
|
621
684
|
{
|
|
622
|
-
className:
|
|
623
|
-
|
|
685
|
+
className: D(
|
|
686
|
+
we,
|
|
624
687
|
"z-[3] border-b px-3 py-1.5 text-right text-[10.5px] font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400"
|
|
625
688
|
),
|
|
626
|
-
children:
|
|
689
|
+
children: i.total_label ?? "Total"
|
|
627
690
|
}
|
|
628
691
|
)
|
|
629
692
|
] }) }),
|
|
630
|
-
|
|
693
|
+
oe.length === 0 && /* @__PURE__ */ t("tbody", { children: /* @__PURE__ */ t("tr", { children: /* @__PURE__ */ c(
|
|
631
694
|
"td",
|
|
632
695
|
{
|
|
633
|
-
colSpan:
|
|
696
|
+
colSpan: h.length + 2,
|
|
634
697
|
className: "px-3 py-6 text-[12.5px] text-slate-500 dark:text-slate-400",
|
|
635
698
|
children: [
|
|
636
|
-
`No ${(
|
|
637
|
-
|
|
699
|
+
`No ${(N ?? "rows").toLowerCase()} yet.`,
|
|
700
|
+
O ? ` Add a ${rt(i.key_field).toLowerCase()} to start planning.` : ""
|
|
638
701
|
]
|
|
639
702
|
}
|
|
640
703
|
) }) }),
|
|
641
|
-
|
|
642
|
-
var
|
|
643
|
-
const l = !
|
|
644
|
-
var
|
|
645
|
-
return e.mode === "split" ?
|
|
646
|
-
},
|
|
647
|
-
(
|
|
648
|
-
),
|
|
649
|
-
(
|
|
650
|
-
), U =
|
|
651
|
-
return /* @__PURE__ */
|
|
704
|
+
oe.map((e, a) => {
|
|
705
|
+
var $, H, te;
|
|
706
|
+
const l = !Qt.has(e.key), r = (d) => {
|
|
707
|
+
var S;
|
|
708
|
+
return e.mode === "split" ? F(e.cats.reduce((ae, Pe) => ae + B(Pe.values[d]), 0)) : B((S = e.top) == null ? void 0 : S.values[d]);
|
|
709
|
+
}, o = F(h.reduce((d, S) => d + r(S), 0)), m = h.some(
|
|
710
|
+
(d) => Math.abs(Le(e.key, ze, d).value) >= 5e-3
|
|
711
|
+
), _ = ((u == null ? void 0 : u.series) ?? []).filter(
|
|
712
|
+
(d) => h.some((S) => Math.abs(Ce(d, e.key, S) ?? 0) >= 5e-3)
|
|
713
|
+
), U = h.some((d) => Math.abs(Le(e.key, null, d).value) >= 5e-3), P = ((($ = e.top) == null ? void 0 : $.edited) || ((H = e.top) == null ? void 0 : H.isNew) || e.cats.some((d) => d.edited || d.isNew)) ?? !1;
|
|
714
|
+
return /* @__PURE__ */ c(
|
|
652
715
|
"tbody",
|
|
653
716
|
{
|
|
654
717
|
"data-plan-block": e.key,
|
|
655
718
|
"data-plan-mode": e.mode,
|
|
656
|
-
className:
|
|
719
|
+
className: D(a > 0 && "pg-block"),
|
|
657
720
|
children: [
|
|
658
|
-
/* @__PURE__ */
|
|
721
|
+
/* @__PURE__ */ c(
|
|
659
722
|
"tr",
|
|
660
723
|
{
|
|
661
724
|
"data-o2m-row": (te = e.top) != null && te.id ? `${n}:${e.top.id}` : void 0,
|
|
662
|
-
className:
|
|
725
|
+
className: D(
|
|
663
726
|
a > 0 && "[&>td]:border-t [&>td]:border-slate-200 dark:[&>td]:border-border"
|
|
664
727
|
),
|
|
665
728
|
children: [
|
|
666
|
-
/* @__PURE__ */ t("td", { className:
|
|
729
|
+
/* @__PURE__ */ t("td", { className: D(Ne, "px-2 py-1"), children: /* @__PURE__ */ c("div", { className: "flex items-center gap-1", children: [
|
|
667
730
|
e.mode === "split" ? /* @__PURE__ */ t(
|
|
668
731
|
"button",
|
|
669
732
|
{
|
|
670
733
|
type: "button",
|
|
671
734
|
"aria-expanded": l,
|
|
672
735
|
"aria-label": `${l ? "Collapse" : "Expand"} ${e.key}`,
|
|
673
|
-
onClick: () =>
|
|
674
|
-
const
|
|
675
|
-
return
|
|
736
|
+
onClick: () => Ct((d) => {
|
|
737
|
+
const S = new Set(d);
|
|
738
|
+
return S.has(e.key) ? S.delete(e.key) : S.add(e.key), S;
|
|
676
739
|
}),
|
|
677
740
|
className: "rounded p-0.5 text-slate-500 hover:bg-muted",
|
|
678
|
-
children: l ? /* @__PURE__ */ t(
|
|
741
|
+
children: l ? /* @__PURE__ */ t(Lt, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ t(Mt, { className: "h-3.5 w-3.5" })
|
|
679
742
|
}
|
|
680
743
|
) : /* @__PURE__ */ t("span", { className: "w-[18px]" }),
|
|
681
744
|
/* @__PURE__ */ t("span", { className: "text-[13px] font-semibold text-slate-900 dark:text-slate-100", children: e.key }),
|
|
682
|
-
|
|
745
|
+
P && /* @__PURE__ */ t(
|
|
683
746
|
"span",
|
|
684
747
|
{
|
|
685
748
|
"data-plan-edited": !0,
|
|
@@ -687,38 +750,38 @@ function Ya(v) {
|
|
|
687
750
|
className: "h-1.5 w-1.5 rounded-full bg-amber-500"
|
|
688
751
|
}
|
|
689
752
|
),
|
|
690
|
-
/* @__PURE__ */ t("span", { className: "ml-auto text-[10.5px] font-medium text-slate-500 dark:text-slate-400", children: e.mode === "ghost" ? "" :
|
|
691
|
-
|
|
692
|
-
|
|
753
|
+
/* @__PURE__ */ t("span", { className: "ml-auto text-[10.5px] font-medium text-slate-500 dark:text-slate-400", children: e.mode === "ghost" ? "" : Ee }),
|
|
754
|
+
O && e.mode !== "ghost" && /* @__PURE__ */ t(
|
|
755
|
+
Fa,
|
|
693
756
|
{
|
|
694
757
|
block: e,
|
|
695
|
-
config:
|
|
696
|
-
canSplit: !!
|
|
697
|
-
splitUnavailable:
|
|
698
|
-
const
|
|
699
|
-
return
|
|
758
|
+
config: i,
|
|
759
|
+
canSplit: !!ge && !!(pe != null && pe.can_split) && !s,
|
|
760
|
+
splitUnavailable: ge && pe && !pe.can_split && !s ? (() => {
|
|
761
|
+
const d = pe.categories.filter((S) => S.cap > 5e-3);
|
|
762
|
+
return d.length === 1 ? `Every line on this record is ${d[0].label} — there is nothing to split between.` : "This record has no categorised lines yet — add lines first.";
|
|
700
763
|
})() : null,
|
|
701
|
-
splitBase:
|
|
702
|
-
client:
|
|
703
|
-
cols:
|
|
704
|
-
catLabel:
|
|
705
|
-
showHistory:
|
|
706
|
-
onHistory:
|
|
707
|
-
onSpread:
|
|
708
|
-
onRemove: () =>
|
|
709
|
-
onDone:
|
|
764
|
+
splitBase: ge,
|
|
765
|
+
client: v,
|
|
766
|
+
cols: h,
|
|
767
|
+
catLabel: ye,
|
|
768
|
+
showHistory: p,
|
|
769
|
+
onHistory: et,
|
|
770
|
+
onSpread: K ? la : null,
|
|
771
|
+
onRemove: () => Wt(e),
|
|
772
|
+
onDone: Ht,
|
|
710
773
|
rc: n
|
|
711
774
|
}
|
|
712
775
|
)
|
|
713
776
|
] }) }),
|
|
714
|
-
e.mode === "ghost" ? /* @__PURE__ */
|
|
777
|
+
e.mode === "ghost" ? /* @__PURE__ */ c(
|
|
715
778
|
"td",
|
|
716
779
|
{
|
|
717
|
-
colSpan:
|
|
780
|
+
colSpan: h.length,
|
|
718
781
|
className: "px-3 py-1 text-[12px] text-slate-500 dark:text-slate-400",
|
|
719
782
|
children: [
|
|
720
|
-
`No ${
|
|
721
|
-
|
|
783
|
+
`No ${Ee.toLowerCase()} for ${e.key}`,
|
|
784
|
+
O && /* @__PURE__ */ t(
|
|
722
785
|
"button",
|
|
723
786
|
{
|
|
724
787
|
type: "button",
|
|
@@ -730,114 +793,114 @@ function Ya(v) {
|
|
|
730
793
|
)
|
|
731
794
|
]
|
|
732
795
|
}
|
|
733
|
-
) :
|
|
734
|
-
const
|
|
796
|
+
) : h.map((d) => {
|
|
797
|
+
const S = G(e.key, d);
|
|
735
798
|
return e.mode === "split" ? /* @__PURE__ */ t(
|
|
736
799
|
"td",
|
|
737
800
|
{
|
|
738
|
-
className:
|
|
801
|
+
className: D(
|
|
739
802
|
"px-2.5 py-1 text-right font-semibold text-slate-900 dark:text-slate-100",
|
|
740
|
-
|
|
803
|
+
S && Se
|
|
741
804
|
),
|
|
742
|
-
children: /* @__PURE__ */ t(ne, { n: r(
|
|
805
|
+
children: /* @__PURE__ */ t(ne, { n: r(d) })
|
|
743
806
|
},
|
|
744
|
-
|
|
807
|
+
d
|
|
745
808
|
) : /* @__PURE__ */ t(
|
|
746
|
-
|
|
809
|
+
Ft,
|
|
747
810
|
{
|
|
748
811
|
row: e.top,
|
|
749
|
-
col:
|
|
750
|
-
closed:
|
|
751
|
-
prov:
|
|
752
|
-
cellKey: V(e.top,
|
|
753
|
-
locked:
|
|
754
|
-
lockedTip:
|
|
755
|
-
onCommit: (ae) => X(e.top, { [
|
|
756
|
-
onMove:
|
|
757
|
-
onPaste:
|
|
812
|
+
col: d,
|
|
813
|
+
closed: S,
|
|
814
|
+
prov: ce(e.top, d),
|
|
815
|
+
cellKey: V(e.top, d),
|
|
816
|
+
locked: Ie(e.key, d),
|
|
817
|
+
lockedTip: S ? (u == null ? void 0 : u.closed_locked_message) ?? "This period is closed" : void 0,
|
|
818
|
+
onCommit: (ae) => X(e.top, { [d]: ae }),
|
|
819
|
+
onMove: wt,
|
|
820
|
+
onPaste: $t
|
|
758
821
|
},
|
|
759
|
-
|
|
822
|
+
d
|
|
760
823
|
);
|
|
761
824
|
}),
|
|
762
825
|
/* @__PURE__ */ t(
|
|
763
826
|
"td",
|
|
764
827
|
{
|
|
765
|
-
className:
|
|
766
|
-
|
|
828
|
+
className: D(
|
|
829
|
+
we,
|
|
767
830
|
"px-3 py-1 text-right font-semibold text-slate-900 dark:text-slate-100"
|
|
768
831
|
),
|
|
769
|
-
children: e.mode === "ghost" ? "" : /* @__PURE__ */ t(ne, { n:
|
|
832
|
+
children: e.mode === "ghost" ? "" : /* @__PURE__ */ t(ne, { n: o })
|
|
770
833
|
}
|
|
771
834
|
)
|
|
772
835
|
]
|
|
773
836
|
}
|
|
774
837
|
),
|
|
775
|
-
|
|
776
|
-
|
|
838
|
+
u && /* @__PURE__ */ t(
|
|
839
|
+
st,
|
|
777
840
|
{
|
|
778
|
-
label:
|
|
841
|
+
label: $e,
|
|
779
842
|
blockKey: e.key,
|
|
780
843
|
cat: null,
|
|
781
|
-
cols:
|
|
782
|
-
compare:
|
|
844
|
+
cols: h,
|
|
845
|
+
compare: u,
|
|
783
846
|
planOf: r,
|
|
784
|
-
actualFor:
|
|
785
|
-
isClosed:
|
|
847
|
+
actualFor: Le,
|
|
848
|
+
isClosed: G,
|
|
786
849
|
row: e.mode === "top" ? e.top : null,
|
|
787
|
-
canReconcile:
|
|
788
|
-
onReconcile:
|
|
789
|
-
carryFor:
|
|
850
|
+
canReconcile: O && e.mode === "top",
|
|
851
|
+
onReconcile: Ze,
|
|
852
|
+
carryFor: Ge
|
|
790
853
|
}
|
|
791
854
|
),
|
|
792
|
-
e.mode !== "split" &&
|
|
793
|
-
/* @__PURE__ */ t("td", { className:
|
|
855
|
+
e.mode !== "split" && _.map((d) => /* @__PURE__ */ c("tr", { "data-compare-series": d.key, children: [
|
|
856
|
+
/* @__PURE__ */ t("td", { className: D(Ne, "px-2 py-0.5"), children: /* @__PURE__ */ t(
|
|
794
857
|
"span",
|
|
795
858
|
{
|
|
796
|
-
"data-tip":
|
|
859
|
+
"data-tip": d.hint ?? "",
|
|
797
860
|
className: "block pl-[22px] text-right text-[10.5px] font-medium text-slate-500 dark:text-slate-400",
|
|
798
|
-
children:
|
|
861
|
+
children: d.label
|
|
799
862
|
}
|
|
800
863
|
) }),
|
|
801
|
-
|
|
864
|
+
h.map((S) => /* @__PURE__ */ t(
|
|
802
865
|
"td",
|
|
803
866
|
{
|
|
804
|
-
className:
|
|
867
|
+
className: D(
|
|
805
868
|
"px-2.5 py-0.5 text-right text-[11.5px] text-slate-500 dark:text-slate-400",
|
|
806
|
-
|
|
869
|
+
G(e.key, S) && Se
|
|
807
870
|
),
|
|
808
|
-
children: Math.abs(
|
|
809
|
-
|
|
871
|
+
children: Math.abs(Ce(d, e.key, S) ?? 0) >= 5e-3 ? /* @__PURE__ */ t(
|
|
872
|
+
Pt,
|
|
810
873
|
{
|
|
811
|
-
series:
|
|
812
|
-
value:
|
|
813
|
-
periodLabel: `${
|
|
814
|
-
children: /* @__PURE__ */ t(ne, { n:
|
|
874
|
+
series: d,
|
|
875
|
+
value: Ce(d, e.key, S) ?? 0,
|
|
876
|
+
periodLabel: `${je(S)} ${e.key}`,
|
|
877
|
+
children: /* @__PURE__ */ t(ne, { n: Ce(d, e.key, S) ?? 0, muted: !0 })
|
|
815
878
|
}
|
|
816
879
|
) : /* @__PURE__ */ t(ne, { n: 0, muted: !0 })
|
|
817
880
|
},
|
|
818
|
-
|
|
881
|
+
S
|
|
819
882
|
)),
|
|
820
883
|
/* @__PURE__ */ t(
|
|
821
884
|
"td",
|
|
822
885
|
{
|
|
823
|
-
className:
|
|
824
|
-
|
|
886
|
+
className: D(
|
|
887
|
+
we,
|
|
825
888
|
"px-3 py-0.5 text-right text-[11.5px] text-slate-500 dark:text-slate-400"
|
|
826
889
|
),
|
|
827
890
|
children: /* @__PURE__ */ t(
|
|
828
|
-
|
|
891
|
+
Pt,
|
|
829
892
|
{
|
|
830
|
-
series:
|
|
831
|
-
value:
|
|
832
|
-
|
|
893
|
+
series: d,
|
|
894
|
+
value: F(
|
|
895
|
+
h.reduce((S, ae) => S + (Ce(d, e.key, ae) ?? 0), 0)
|
|
833
896
|
),
|
|
834
897
|
periodLabel: String(e.key),
|
|
835
898
|
whole: !0,
|
|
836
899
|
children: /* @__PURE__ */ t(
|
|
837
900
|
ne,
|
|
838
901
|
{
|
|
839
|
-
n:
|
|
840
|
-
|
|
902
|
+
n: F(
|
|
903
|
+
h.reduce((S, ae) => S + (Ce(d, e.key, ae) ?? 0), 0)
|
|
841
904
|
),
|
|
842
905
|
muted: !0
|
|
843
906
|
}
|
|
@@ -846,83 +909,84 @@ function Ya(v) {
|
|
|
846
909
|
)
|
|
847
910
|
}
|
|
848
911
|
)
|
|
849
|
-
] },
|
|
850
|
-
e.mode === "split" && l && e.cats.map((
|
|
851
|
-
/* @__PURE__ */
|
|
912
|
+
] }, d.key)),
|
|
913
|
+
e.mode === "split" && l && e.cats.map((d) => /* @__PURE__ */ c(qa, { children: [
|
|
914
|
+
/* @__PURE__ */ c(
|
|
852
915
|
"tr",
|
|
853
916
|
{
|
|
854
|
-
"data-o2m-row":
|
|
855
|
-
"data-plan-category":
|
|
917
|
+
"data-o2m-row": d.id ? `${n}:${d.id}` : void 0,
|
|
918
|
+
"data-plan-category": d.cat ?? "",
|
|
856
919
|
children: [
|
|
857
|
-
/* @__PURE__ */ t("td", { className:
|
|
858
|
-
/* @__PURE__ */ t("span", { className: "truncate text-[12.5px] font-medium text-slate-800 dark:text-slate-100", children:
|
|
859
|
-
(
|
|
860
|
-
/* @__PURE__ */ t("span", { className: "ml-auto text-[10.5px] font-medium text-slate-500 dark:text-slate-400", children:
|
|
920
|
+
/* @__PURE__ */ t("td", { className: D(Ne, "px-2 py-1"), children: /* @__PURE__ */ c("div", { className: "flex items-center gap-1 pl-[22px]", children: [
|
|
921
|
+
/* @__PURE__ */ t("span", { className: "truncate text-[12.5px] font-medium text-slate-800 dark:text-slate-100", children: ye(d.cat) }),
|
|
922
|
+
(d.edited || d.isNew) && /* @__PURE__ */ t("span", { className: "h-1.5 w-1.5 rounded-full bg-amber-500" }),
|
|
923
|
+
/* @__PURE__ */ t("span", { className: "ml-auto text-[10.5px] font-medium text-slate-500 dark:text-slate-400", children: Ee })
|
|
861
924
|
] }) }),
|
|
862
|
-
|
|
863
|
-
|
|
925
|
+
h.map((S) => /* @__PURE__ */ t(
|
|
926
|
+
Ft,
|
|
864
927
|
{
|
|
865
|
-
row:
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
928
|
+
row: d,
|
|
929
|
+
rowLabel: d.cat != null ? ye(String(d.cat)) : void 0,
|
|
930
|
+
col: S,
|
|
931
|
+
closed: G(e.key, S),
|
|
932
|
+
prov: ce(d, S),
|
|
933
|
+
cellKey: V(d, S),
|
|
934
|
+
locked: Ie(e.key, S),
|
|
935
|
+
lockedTip: G(e.key, S) ? (u == null ? void 0 : u.closed_locked_message) ?? "This period is closed" : void 0,
|
|
936
|
+
onCommit: (ae) => X(d, { [S]: ae }),
|
|
937
|
+
onMove: wt,
|
|
938
|
+
onPaste: $t
|
|
875
939
|
},
|
|
876
|
-
|
|
940
|
+
S
|
|
877
941
|
)),
|
|
878
942
|
/* @__PURE__ */ t(
|
|
879
943
|
"td",
|
|
880
944
|
{
|
|
881
|
-
className:
|
|
882
|
-
|
|
945
|
+
className: D(
|
|
946
|
+
we,
|
|
883
947
|
"px-3 py-1 text-right font-medium text-slate-800 dark:text-slate-100"
|
|
884
948
|
),
|
|
885
|
-
children: /* @__PURE__ */ t(ne, { n: Y(
|
|
949
|
+
children: /* @__PURE__ */ t(ne, { n: Y(d.values) })
|
|
886
950
|
}
|
|
887
951
|
)
|
|
888
952
|
]
|
|
889
953
|
}
|
|
890
954
|
),
|
|
891
|
-
|
|
892
|
-
|
|
955
|
+
u && U && /* @__PURE__ */ t(
|
|
956
|
+
st,
|
|
893
957
|
{
|
|
894
|
-
label:
|
|
958
|
+
label: $e,
|
|
895
959
|
blockKey: e.key,
|
|
896
|
-
cat:
|
|
897
|
-
cols:
|
|
898
|
-
compare:
|
|
899
|
-
planOf: (
|
|
900
|
-
actualFor:
|
|
901
|
-
isClosed:
|
|
902
|
-
row:
|
|
903
|
-
canReconcile:
|
|
904
|
-
onReconcile:
|
|
905
|
-
carryFor:
|
|
960
|
+
cat: d.cat,
|
|
961
|
+
cols: h,
|
|
962
|
+
compare: u,
|
|
963
|
+
planOf: (S) => B(d.values[S]),
|
|
964
|
+
actualFor: Le,
|
|
965
|
+
isClosed: G,
|
|
966
|
+
row: d,
|
|
967
|
+
canReconcile: O,
|
|
968
|
+
onReconcile: Ze,
|
|
969
|
+
carryFor: Ge,
|
|
906
970
|
indent: !0
|
|
907
971
|
}
|
|
908
972
|
)
|
|
909
|
-
] },
|
|
910
|
-
e.mode === "split" && l &&
|
|
911
|
-
|
|
973
|
+
] }, d.uid)),
|
|
974
|
+
e.mode === "split" && l && u && m && /* @__PURE__ */ t(
|
|
975
|
+
st,
|
|
912
976
|
{
|
|
913
|
-
label: `${
|
|
914
|
-
tip: `${
|
|
977
|
+
label: `${ye(ze)} · ${$e.toLowerCase()}`,
|
|
978
|
+
tip: `${$e} the source could not place in a category — it counts in the ${e.key} total only.`,
|
|
915
979
|
blockKey: e.key,
|
|
916
|
-
cat:
|
|
917
|
-
cols:
|
|
918
|
-
compare:
|
|
980
|
+
cat: ze,
|
|
981
|
+
cols: h,
|
|
982
|
+
compare: u,
|
|
919
983
|
planOf: () => 0,
|
|
920
|
-
actualFor:
|
|
921
|
-
isClosed:
|
|
984
|
+
actualFor: Le,
|
|
985
|
+
isClosed: G,
|
|
922
986
|
row: null,
|
|
923
987
|
canReconcile: !1,
|
|
924
|
-
onReconcile:
|
|
925
|
-
carryFor:
|
|
988
|
+
onReconcile: Ze,
|
|
989
|
+
carryFor: Ge,
|
|
926
990
|
indent: !0,
|
|
927
991
|
plain: !0
|
|
928
992
|
}
|
|
@@ -932,49 +996,49 @@ function Ya(v) {
|
|
|
932
996
|
e.key
|
|
933
997
|
);
|
|
934
998
|
}),
|
|
935
|
-
|
|
936
|
-
/* @__PURE__ */
|
|
937
|
-
/* @__PURE__ */ t("td", { className:
|
|
999
|
+
oe.length > 1 && /* @__PURE__ */ c("tfoot", { children: [
|
|
1000
|
+
/* @__PURE__ */ c("tr", { className: "[&>td]:border-t [&>td]:border-slate-300 dark:[&>td]:border-border", children: [
|
|
1001
|
+
/* @__PURE__ */ t("td", { className: D(Ne, "px-2 py-1.5"), children: /* @__PURE__ */ c("div", { className: "flex items-center pl-[22px]", children: [
|
|
938
1002
|
/* @__PURE__ */ t("span", { className: "text-[12px] font-semibold text-slate-900 dark:text-slate-100", children: "All" }),
|
|
939
|
-
/* @__PURE__ */ t("span", { className: "ml-auto text-[10.5px] font-medium text-slate-500 dark:text-slate-400", children:
|
|
1003
|
+
/* @__PURE__ */ t("span", { className: "ml-auto text-[10.5px] font-medium text-slate-500 dark:text-slate-400", children: Ee })
|
|
940
1004
|
] }) }),
|
|
941
|
-
|
|
1005
|
+
h.map((e) => /* @__PURE__ */ t(
|
|
942
1006
|
"td",
|
|
943
1007
|
{
|
|
944
1008
|
className: "px-2.5 py-1.5 text-right font-semibold text-slate-900 dark:text-slate-100",
|
|
945
|
-
children: /* @__PURE__ */ t(ne, { n:
|
|
1009
|
+
children: /* @__PURE__ */ t(ne, { n: lt.planBy[e] })
|
|
946
1010
|
},
|
|
947
1011
|
e
|
|
948
1012
|
)),
|
|
949
1013
|
/* @__PURE__ */ t(
|
|
950
1014
|
"td",
|
|
951
1015
|
{
|
|
952
|
-
className:
|
|
953
|
-
|
|
1016
|
+
className: D(
|
|
1017
|
+
we,
|
|
954
1018
|
"px-3 py-1.5 text-right font-semibold text-slate-900 dark:text-slate-100"
|
|
955
1019
|
),
|
|
956
|
-
children: /* @__PURE__ */ t(ne, { n:
|
|
1020
|
+
children: /* @__PURE__ */ t(ne, { n: Qe })
|
|
957
1021
|
}
|
|
958
1022
|
)
|
|
959
1023
|
] }),
|
|
960
|
-
|
|
961
|
-
/* @__PURE__ */ t("td", { className:
|
|
962
|
-
|
|
1024
|
+
u && /* @__PURE__ */ c("tr", { children: [
|
|
1025
|
+
/* @__PURE__ */ t("td", { className: D(Ne, "px-2 pb-1.5 pt-0"), children: /* @__PURE__ */ t("span", { className: "block text-right text-[10.5px] font-medium text-slate-500 dark:text-slate-400", children: $e }) }),
|
|
1026
|
+
h.map((e) => /* @__PURE__ */ t(
|
|
963
1027
|
"td",
|
|
964
1028
|
{
|
|
965
1029
|
className: "px-2.5 pb-1.5 pt-0 text-right text-[11.5px] text-slate-600 dark:text-slate-300",
|
|
966
|
-
children: /* @__PURE__ */ t(ne, { n:
|
|
1030
|
+
children: /* @__PURE__ */ t(ne, { n: lt.actualBy[e], muted: !0 })
|
|
967
1031
|
},
|
|
968
1032
|
e
|
|
969
1033
|
)),
|
|
970
1034
|
/* @__PURE__ */ t(
|
|
971
1035
|
"td",
|
|
972
1036
|
{
|
|
973
|
-
className:
|
|
974
|
-
|
|
1037
|
+
className: D(
|
|
1038
|
+
we,
|
|
975
1039
|
"px-3 pb-1.5 pt-0 text-right text-[11.5px] text-slate-600 dark:text-slate-300"
|
|
976
1040
|
),
|
|
977
|
-
children: /* @__PURE__ */ t(ne, { n:
|
|
1041
|
+
children: /* @__PURE__ */ t(ne, { n: F(h.reduce((e, a) => e + lt.actualBy[a], 0)), muted: !0 })
|
|
978
1042
|
}
|
|
979
1043
|
)
|
|
980
1044
|
] })
|
|
@@ -984,49 +1048,49 @@ function Ya(v) {
|
|
|
984
1048
|
)
|
|
985
1049
|
}
|
|
986
1050
|
),
|
|
987
|
-
|
|
1051
|
+
vt && /* @__PURE__ */ t(
|
|
988
1052
|
"p",
|
|
989
1053
|
{
|
|
990
1054
|
role: "alert",
|
|
991
1055
|
"data-plan-grid-notice": !0,
|
|
992
1056
|
className: "mt-1.5 text-[12px] font-medium text-red-700 dark:text-red-300",
|
|
993
|
-
children:
|
|
1057
|
+
children: vt
|
|
994
1058
|
}
|
|
995
1059
|
),
|
|
996
|
-
|
|
1060
|
+
O && /* @__PURE__ */ c("div", { className: "mt-2 flex items-center gap-2", children: [
|
|
997
1061
|
/* @__PURE__ */ t(
|
|
998
|
-
|
|
1062
|
+
Ba,
|
|
999
1063
|
{
|
|
1000
|
-
config:
|
|
1001
|
-
client:
|
|
1002
|
-
used:
|
|
1064
|
+
config: i,
|
|
1065
|
+
client: v,
|
|
1066
|
+
used: ta,
|
|
1003
1067
|
onAdd: (e) => Me(e),
|
|
1004
|
-
label: `Add ${
|
|
1068
|
+
label: `Add ${rt(i.key_field).toLowerCase()}`
|
|
1005
1069
|
}
|
|
1006
1070
|
),
|
|
1007
|
-
(
|
|
1071
|
+
(u == null ? void 0 : u.closed_locked) && !q && De && /* @__PURE__ */ t("span", { className: "text-[11.5px] text-slate-500 dark:text-slate-400", children: `Periods through ${De} are closed — open a highlighted ${$e.toLowerCase()} figure to reconcile one.` })
|
|
1008
1072
|
] }),
|
|
1009
|
-
|
|
1010
|
-
Q &&
|
|
1011
|
-
|
|
1073
|
+
tt,
|
|
1074
|
+
Q && tt == null && /* @__PURE__ */ t(
|
|
1075
|
+
Ma,
|
|
1012
1076
|
{
|
|
1013
1077
|
open: !0,
|
|
1014
1078
|
onOpenChange: (e) => {
|
|
1015
|
-
e ||
|
|
1079
|
+
e || et(null);
|
|
1016
1080
|
},
|
|
1017
|
-
rowTitle: `${Q.key}${Q.cat ? ` · ${
|
|
1018
|
-
revisions:
|
|
1019
|
-
loading:
|
|
1020
|
-
fields:
|
|
1021
|
-
displayCols:
|
|
1022
|
-
(e) =>
|
|
1081
|
+
rowTitle: `${Q.key}${Q.cat ? ` · ${ye(Q.cat)}` : ""}`,
|
|
1082
|
+
revisions: Zt,
|
|
1083
|
+
loading: Yt,
|
|
1084
|
+
fields: Ot,
|
|
1085
|
+
displayCols: Ot.filter(
|
|
1086
|
+
(e) => h.includes(e.field) || e.field === i.category_field
|
|
1023
1087
|
),
|
|
1024
|
-
parentField:
|
|
1088
|
+
parentField: x,
|
|
1025
1089
|
m2oRelMap: /* @__PURE__ */ new Map(),
|
|
1026
1090
|
relations: [],
|
|
1027
1091
|
collection: n,
|
|
1028
1092
|
m2oDisplays: {},
|
|
1029
|
-
client:
|
|
1093
|
+
client: v,
|
|
1030
1094
|
allowRestore: !1,
|
|
1031
1095
|
onRestore: () => {
|
|
1032
1096
|
}
|
|
@@ -1034,84 +1098,97 @@ function Ya(v) {
|
|
|
1034
1098
|
)
|
|
1035
1099
|
] });
|
|
1036
1100
|
}
|
|
1037
|
-
function
|
|
1038
|
-
return
|
|
1101
|
+
function rt(b) {
|
|
1102
|
+
return b.replace(/_/g, " ").replace(/^\w/, (n) => n.toUpperCase());
|
|
1039
1103
|
}
|
|
1040
|
-
function
|
|
1041
|
-
return /* @__PURE__ */ t(
|
|
1104
|
+
function qa(b) {
|
|
1105
|
+
return /* @__PURE__ */ t(ra, { children: b.children });
|
|
1042
1106
|
}
|
|
1043
|
-
function ne(
|
|
1044
|
-
return Math.abs(
|
|
1107
|
+
function ne(b) {
|
|
1108
|
+
return Math.abs(b.n) < 5e-3 ? /* @__PURE__ */ t("span", { className: "text-slate-400 dark:text-slate-500", children: "—" }) : /* @__PURE__ */ t("span", { children: z(b.n) });
|
|
1045
1109
|
}
|
|
1046
|
-
function
|
|
1047
|
-
const {
|
|
1048
|
-
|
|
1110
|
+
function Ft(b) {
|
|
1111
|
+
const {
|
|
1112
|
+
row: n,
|
|
1113
|
+
rowLabel: x,
|
|
1114
|
+
col: f,
|
|
1115
|
+
closed: i,
|
|
1116
|
+
locked: k,
|
|
1117
|
+
lockedTip: M,
|
|
1118
|
+
prov: E,
|
|
1119
|
+
cellKey: K,
|
|
1120
|
+
onCommit: L,
|
|
1121
|
+
onMove: p,
|
|
1122
|
+
onPaste: N
|
|
1123
|
+
} = b, v = B(n.values[f]), y = E ? `${je(f)} · changed ${ba(E.at)} by ${E.who}${E.reason ? `
|
|
1124
|
+
Reason: “${E.reason}”` : ""}` : void 0, g = E != null && E.reason ? /* @__PURE__ */ t(
|
|
1049
1125
|
"span",
|
|
1050
1126
|
{
|
|
1051
1127
|
"aria-hidden": "true",
|
|
1052
1128
|
"data-cell-reason": !0,
|
|
1053
1129
|
className: "pointer-events-none absolute left-0 top-0 h-0 w-0 border-r-[6px] border-t-[6px] border-r-transparent border-t-nvr-cyan"
|
|
1054
1130
|
}
|
|
1055
|
-
) : null, [
|
|
1056
|
-
if (
|
|
1057
|
-
return /* @__PURE__ */
|
|
1131
|
+
) : null, [j, I] = W(null), C = me(!1);
|
|
1132
|
+
if (k)
|
|
1133
|
+
return /* @__PURE__ */ c(
|
|
1058
1134
|
"td",
|
|
1059
1135
|
{
|
|
1060
|
-
"data-plan-locked":
|
|
1061
|
-
"data-tip": [
|
|
1136
|
+
"data-plan-locked": i ? "closed" : "readonly",
|
|
1137
|
+
"data-tip": [M, y].filter(Boolean).join(`
|
|
1062
1138
|
`) || void 0,
|
|
1063
1139
|
"data-grid-cell": K,
|
|
1064
|
-
className:
|
|
1140
|
+
className: D(
|
|
1065
1141
|
"relative px-2.5 py-1 text-right text-slate-700 dark:text-slate-200",
|
|
1066
|
-
|
|
1142
|
+
i && Se
|
|
1067
1143
|
),
|
|
1068
1144
|
children: [
|
|
1069
|
-
|
|
1070
|
-
/* @__PURE__ */ t(ne, { n:
|
|
1145
|
+
g,
|
|
1146
|
+
/* @__PURE__ */ t(ne, { n: v })
|
|
1071
1147
|
]
|
|
1072
1148
|
}
|
|
1073
1149
|
);
|
|
1074
|
-
const
|
|
1075
|
-
if (
|
|
1076
|
-
const
|
|
1077
|
-
if (
|
|
1078
|
-
|
|
1150
|
+
const q = () => {
|
|
1151
|
+
if (j == null) return;
|
|
1152
|
+
const s = Bt(j);
|
|
1153
|
+
if (I(null), C.current) {
|
|
1154
|
+
C.current = !1;
|
|
1079
1155
|
return;
|
|
1080
1156
|
}
|
|
1081
|
-
if (
|
|
1082
|
-
|
|
1157
|
+
if (s == null || s < 0) {
|
|
1158
|
+
ie.error(Dt(j));
|
|
1083
1159
|
return;
|
|
1084
1160
|
}
|
|
1085
|
-
|
|
1161
|
+
const O = ct(j);
|
|
1162
|
+
O.ok && O.rounded && ie.message(`Rounded to ${z(s)} — amounts are kept to the cent`), !(Math.abs(s - v) < 5e-3) && L(s);
|
|
1086
1163
|
};
|
|
1087
|
-
return /* @__PURE__ */
|
|
1164
|
+
return /* @__PURE__ */ c(
|
|
1088
1165
|
"td",
|
|
1089
1166
|
{
|
|
1090
|
-
className:
|
|
1167
|
+
className: D("relative p-0", i && Se),
|
|
1091
1168
|
"data-grid-cell": K,
|
|
1092
|
-
"data-tip":
|
|
1169
|
+
"data-tip": y,
|
|
1093
1170
|
children: [
|
|
1094
|
-
|
|
1171
|
+
g,
|
|
1095
1172
|
/* @__PURE__ */ t(
|
|
1096
1173
|
"input",
|
|
1097
1174
|
{
|
|
1098
|
-
"data-pg-cell": `${n.uid}:${
|
|
1099
|
-
"aria-label": `${
|
|
1175
|
+
"data-pg-cell": `${n.uid}:${f}`,
|
|
1176
|
+
"aria-label": `${je(f)} ${n.key}${x ? ` · ${x}` : ""}`,
|
|
1100
1177
|
inputMode: "decimal",
|
|
1101
|
-
value:
|
|
1178
|
+
value: j ?? (v === 0 ? "" : z(v)),
|
|
1102
1179
|
placeholder: "—",
|
|
1103
|
-
onFocus: (
|
|
1104
|
-
|
|
1180
|
+
onFocus: (s) => {
|
|
1181
|
+
I(v === 0 ? "" : String(v)), requestAnimationFrame(() => s.target.select());
|
|
1105
1182
|
},
|
|
1106
|
-
onChange: (
|
|
1107
|
-
onBlur:
|
|
1108
|
-
onPaste: (
|
|
1109
|
-
const
|
|
1110
|
-
/[\t\n]/.test(
|
|
1183
|
+
onChange: (s) => I(s.target.value),
|
|
1184
|
+
onBlur: q,
|
|
1185
|
+
onPaste: (s) => {
|
|
1186
|
+
const O = s.clipboardData.getData("text");
|
|
1187
|
+
/[\t\n]/.test(O.trim()) && (s.preventDefault(), C.current = !0, s.target.blur(), N(n, f, O));
|
|
1111
1188
|
},
|
|
1112
|
-
onKeyDown: (
|
|
1113
|
-
const
|
|
1114
|
-
|
|
1189
|
+
onKeyDown: (s) => {
|
|
1190
|
+
const O = s.currentTarget, h = O.selectionStart === 0 && O.selectionEnd === 0, R = O.selectionStart === O.value.length && O.selectionEnd === O.value.length;
|
|
1191
|
+
s.key === "Enter" || s.key === "ArrowDown" ? (s.preventDefault(), q(), p(n.uid, f, 1, 0)) : s.key === "ArrowUp" ? (s.preventDefault(), q(), p(n.uid, f, -1, 0)) : s.key === "ArrowLeft" && h ? (s.preventDefault(), q(), p(n.uid, f, 0, -1)) : s.key === "ArrowRight" && R ? (s.preventDefault(), q(), p(n.uid, f, 0, 1)) : s.key === "Escape" && (C.current = !0, O.blur());
|
|
1115
1192
|
},
|
|
1116
1193
|
className: "h-[30px] w-full bg-transparent px-2.5 text-right text-[12px] tabular-nums text-slate-900 outline-none placeholder:text-slate-400 hover:bg-muted/60 focus:bg-white focus:shadow-[inset_0_0_0_2px_rgb(var(--nvr-cyan-rgb))] dark:text-slate-100 dark:placeholder:text-slate-500 dark:focus:bg-[hsl(var(--background))]"
|
|
1117
1194
|
}
|
|
@@ -1120,69 +1197,69 @@ Reason: “${R.reason}”` : ""}` : void 0, b = R != null && R.reason ? /* @__PU
|
|
|
1120
1197
|
}
|
|
1121
1198
|
);
|
|
1122
1199
|
}
|
|
1123
|
-
function
|
|
1200
|
+
function st(b) {
|
|
1124
1201
|
const {
|
|
1125
1202
|
label: n,
|
|
1126
|
-
tip:
|
|
1127
|
-
blockKey:
|
|
1128
|
-
cat:
|
|
1129
|
-
cols:
|
|
1130
|
-
compare:
|
|
1131
|
-
planOf:
|
|
1132
|
-
actualFor:
|
|
1203
|
+
tip: x,
|
|
1204
|
+
blockKey: f,
|
|
1205
|
+
cat: i,
|
|
1206
|
+
cols: k,
|
|
1207
|
+
compare: M,
|
|
1208
|
+
planOf: E,
|
|
1209
|
+
actualFor: K,
|
|
1133
1210
|
isClosed: L,
|
|
1134
|
-
row:
|
|
1135
|
-
canReconcile:
|
|
1136
|
-
onReconcile:
|
|
1137
|
-
carryFor:
|
|
1138
|
-
plain:
|
|
1139
|
-
} =
|
|
1140
|
-
return /* @__PURE__ */
|
|
1141
|
-
/* @__PURE__ */ t("td", { className:
|
|
1211
|
+
row: p,
|
|
1212
|
+
canReconcile: N,
|
|
1213
|
+
onReconcile: v,
|
|
1214
|
+
carryFor: y,
|
|
1215
|
+
plain: g
|
|
1216
|
+
} = b, j = F(k.reduce((I, C) => I + K(f, i, C).value, 0));
|
|
1217
|
+
return /* @__PURE__ */ c("tr", { "data-plan-actual": i ?? "all", children: [
|
|
1218
|
+
/* @__PURE__ */ t("td", { className: D(Ne, "px-2 pb-1 pt-0"), children: /* @__PURE__ */ t(
|
|
1142
1219
|
"span",
|
|
1143
1220
|
{
|
|
1144
|
-
"data-tip":
|
|
1221
|
+
"data-tip": x,
|
|
1145
1222
|
className: "block text-right text-[10.5px] font-medium text-slate-500 dark:text-slate-400",
|
|
1146
1223
|
children: n
|
|
1147
1224
|
}
|
|
1148
1225
|
) }),
|
|
1149
|
-
|
|
1150
|
-
const
|
|
1226
|
+
k.map((I) => {
|
|
1227
|
+
const C = L(f, I), q = K(f, i, I), s = E(I), O = !g && C && Math.abs(q.value - s) >= 5e-3, h = !g && !C && q.value > s + 5e-3;
|
|
1151
1228
|
return /* @__PURE__ */ t(
|
|
1152
1229
|
"td",
|
|
1153
1230
|
{
|
|
1154
|
-
"data-compare-cell":
|
|
1155
|
-
className:
|
|
1156
|
-
children: Math.abs(
|
|
1157
|
-
|
|
1231
|
+
"data-compare-cell": I,
|
|
1232
|
+
className: D("px-2.5 pb-1 pt-0 text-right text-[11.5px]", C && Se),
|
|
1233
|
+
children: Math.abs(q.value) < 5e-3 && !O ? /* @__PURE__ */ t("span", { className: "text-slate-400 dark:text-slate-500", children: "—" }) : /* @__PURE__ */ t(
|
|
1234
|
+
Aa,
|
|
1158
1235
|
{
|
|
1159
|
-
title: `${
|
|
1160
|
-
compare:
|
|
1236
|
+
title: `${je(I)} ${f}`,
|
|
1237
|
+
compare: M,
|
|
1161
1238
|
actualName: n,
|
|
1162
|
-
actual:
|
|
1163
|
-
planned:
|
|
1164
|
-
closed:
|
|
1165
|
-
plain: !!
|
|
1166
|
-
details:
|
|
1167
|
-
tone:
|
|
1168
|
-
reconcile:
|
|
1169
|
-
row:
|
|
1170
|
-
column:
|
|
1171
|
-
openColumns:
|
|
1172
|
-
carry: (
|
|
1173
|
-
onApply: (
|
|
1239
|
+
actual: q.value,
|
|
1240
|
+
planned: s,
|
|
1241
|
+
closed: C,
|
|
1242
|
+
plain: !!g,
|
|
1243
|
+
details: q.details,
|
|
1244
|
+
tone: O ? "warn" : h ? "danger" : "neutral",
|
|
1245
|
+
reconcile: O && N && p ? {
|
|
1246
|
+
row: p,
|
|
1247
|
+
column: I,
|
|
1248
|
+
openColumns: k.filter((R) => !L(f, R)),
|
|
1249
|
+
carry: (y == null ? void 0 : y(f, i)) ?? null,
|
|
1250
|
+
onApply: (R, T, de) => v(p, R, T, de)
|
|
1174
1251
|
} : null
|
|
1175
1252
|
}
|
|
1176
1253
|
)
|
|
1177
1254
|
},
|
|
1178
|
-
|
|
1255
|
+
I
|
|
1179
1256
|
);
|
|
1180
1257
|
}),
|
|
1181
1258
|
/* @__PURE__ */ t(
|
|
1182
1259
|
"td",
|
|
1183
1260
|
{
|
|
1184
|
-
className:
|
|
1185
|
-
|
|
1261
|
+
className: D(
|
|
1262
|
+
we,
|
|
1186
1263
|
"px-3 pb-1 pt-0 text-right text-[11.5px] text-slate-600 dark:text-slate-300"
|
|
1187
1264
|
),
|
|
1188
1265
|
children: /* @__PURE__ */ t(ne, { n: j, muted: !0 })
|
|
@@ -1190,120 +1267,120 @@ function nt(v) {
|
|
|
1190
1267
|
)
|
|
1191
1268
|
] });
|
|
1192
1269
|
}
|
|
1193
|
-
const
|
|
1270
|
+
const Kt = {
|
|
1194
1271
|
warn: "text-amber-700 dark:text-amber-300 font-medium",
|
|
1195
1272
|
danger: "text-red-700 dark:text-red-300 font-medium",
|
|
1196
1273
|
neutral: "text-slate-600 dark:text-slate-300"
|
|
1197
1274
|
};
|
|
1198
|
-
function
|
|
1199
|
-
var V,
|
|
1200
|
-
const { title: n, compare:
|
|
1275
|
+
function Aa(b) {
|
|
1276
|
+
var V, ce;
|
|
1277
|
+
const { title: n, compare: x, actualName: f, actual: i, planned: k, closed: M, plain: E, details: K, tone: L, reconcile: p } = b, [N, v] = W(!1), [y, g] = W("next"), [j, I] = W(""), C = It(x), q = F(k - i), s = p && p.openColumns.length === 0 && p.carry && !p.carry.blocked ? p.carry : null, O = p && p.openColumns.length === 0 ? ((V = p.carry) == null ? void 0 : V.blocked) ?? null : null, h = s ? ((ce = s.row) == null ? void 0 : ce.values) ?? {} : (p == null ? void 0 : p.row.values) ?? {}, R = s ? s.openColumns : (p == null ? void 0 : p.openColumns) ?? [], T = Z(
|
|
1201
1278
|
() => {
|
|
1202
1279
|
var w;
|
|
1203
|
-
return
|
|
1204
|
-
row:
|
|
1205
|
-
column:
|
|
1206
|
-
actual:
|
|
1207
|
-
openColumns:
|
|
1208
|
-
mode:
|
|
1209
|
-
...
|
|
1280
|
+
return p ? ja({
|
|
1281
|
+
row: p.row.values,
|
|
1282
|
+
column: p.column,
|
|
1283
|
+
actual: i,
|
|
1284
|
+
openColumns: s ? s.openColumns : p.openColumns,
|
|
1285
|
+
mode: y,
|
|
1286
|
+
...s ? { targetRow: ((w = s.row) == null ? void 0 : w.values) ?? {} } : {}
|
|
1210
1287
|
}) : null;
|
|
1211
1288
|
},
|
|
1212
|
-
[
|
|
1213
|
-
),
|
|
1214
|
-
const w = `Reconciled ${n} to ${
|
|
1215
|
-
if (!
|
|
1216
|
-
const
|
|
1217
|
-
return
|
|
1218
|
-
}, [n,
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
}, [
|
|
1222
|
-
const le =
|
|
1289
|
+
[p, s, i, y]
|
|
1290
|
+
), de = T ? T.targetPatch ?? T.patch : {}, re = R.some((w) => B(h[w]) > 5e-3), A = Z(() => {
|
|
1291
|
+
const w = `Reconciled ${n} to ${f.toLowerCase()} (${z(i)})`;
|
|
1292
|
+
if (!T || Math.abs(T.moved) < 5e-3) return w;
|
|
1293
|
+
const xe = `${T.targets.length === 1 ? je(T.targets[0]) : `${T.targets.length} open periods`}${s ? ` ${s.key}` : ""}`;
|
|
1294
|
+
return T.moved > 0 ? `${w} — moved ${z(T.moved)} to ${xe}` : `${w} — took ${z(-T.moved)} from ${xe}`;
|
|
1295
|
+
}, [n, f, i, T, s]);
|
|
1296
|
+
ue(() => {
|
|
1297
|
+
N && I(A);
|
|
1298
|
+
}, [N, A]);
|
|
1299
|
+
const le = p ? [
|
|
1223
1300
|
{
|
|
1224
1301
|
key: "next",
|
|
1225
|
-
label:
|
|
1226
|
-
disabled:
|
|
1302
|
+
label: R[0] ? `Next open period (${it(R[0])}${s ? ` ${s.key}` : ""})` : "Next open period",
|
|
1303
|
+
disabled: R.length === 0
|
|
1227
1304
|
},
|
|
1228
1305
|
{
|
|
1229
1306
|
key: "even",
|
|
1230
|
-
label:
|
|
1231
|
-
disabled:
|
|
1307
|
+
label: s ? `Evenly over ${s.key}'s open periods` : "Evenly over every open period",
|
|
1308
|
+
disabled: R.length === 0
|
|
1232
1309
|
},
|
|
1233
1310
|
{
|
|
1234
1311
|
key: "weighted",
|
|
1235
|
-
label:
|
|
1236
|
-
disabled: !
|
|
1312
|
+
label: s ? `In proportion to the ${C.toLowerCase()} already in ${s.key}` : `In proportion to the ${C.toLowerCase()} already there`,
|
|
1313
|
+
disabled: !re
|
|
1237
1314
|
},
|
|
1238
1315
|
{ key: "none", label: "Nowhere — drop it from the plan" }
|
|
1239
1316
|
] : [];
|
|
1240
|
-
return /* @__PURE__ */
|
|
1241
|
-
/* @__PURE__ */ t(
|
|
1317
|
+
return /* @__PURE__ */ c(ut, { open: N, onOpenChange: v, children: [
|
|
1318
|
+
/* @__PURE__ */ t(pt, { asChild: !0, children: /* @__PURE__ */ t(
|
|
1242
1319
|
"button",
|
|
1243
1320
|
{
|
|
1244
1321
|
type: "button",
|
|
1245
1322
|
"data-compare-details": !0,
|
|
1246
1323
|
"data-tip": "",
|
|
1247
1324
|
"data-plan-off": L === "warn" ? "true" : void 0,
|
|
1248
|
-
className:
|
|
1325
|
+
className: D(
|
|
1249
1326
|
"rounded px-0.5 underline-offset-2 hover:underline focus-visible:underline",
|
|
1250
|
-
|
|
1327
|
+
Kt[L]
|
|
1251
1328
|
),
|
|
1252
|
-
children:
|
|
1329
|
+
children: z(i)
|
|
1253
1330
|
}
|
|
1254
1331
|
) }),
|
|
1255
|
-
/* @__PURE__ */
|
|
1256
|
-
/* @__PURE__ */
|
|
1332
|
+
/* @__PURE__ */ c(mt, { align: "end", sideOffset: 6, className: "w-[360px] p-0 text-[12px]", children: [
|
|
1333
|
+
/* @__PURE__ */ c("div", { className: "border-b border-slate-200 px-3 py-2 dark:border-border", children: [
|
|
1257
1334
|
/* @__PURE__ */ t("p", { className: "text-[12.5px] font-semibold text-slate-900 dark:text-slate-100", children: n }),
|
|
1258
|
-
/* @__PURE__ */
|
|
1259
|
-
!
|
|
1260
|
-
/* @__PURE__ */ t("dt", { className: "text-[10.5px] text-slate-500 dark:text-slate-400", children:
|
|
1261
|
-
/* @__PURE__ */ t("dd", { className: "font-medium text-slate-800 dark:text-slate-100", children:
|
|
1335
|
+
/* @__PURE__ */ c("dl", { className: "mt-1 grid grid-cols-3 gap-2 tabular-nums", children: [
|
|
1336
|
+
!E && /* @__PURE__ */ c("div", { children: [
|
|
1337
|
+
/* @__PURE__ */ t("dt", { className: "text-[10.5px] text-slate-500 dark:text-slate-400", children: C }),
|
|
1338
|
+
/* @__PURE__ */ t("dd", { className: "font-medium text-slate-800 dark:text-slate-100", children: z(k) })
|
|
1262
1339
|
] }),
|
|
1263
|
-
/* @__PURE__ */
|
|
1264
|
-
/* @__PURE__ */ t("dt", { className: "text-[10.5px] text-slate-500 dark:text-slate-400", children:
|
|
1265
|
-
/* @__PURE__ */ t("dd", { className: "font-medium text-slate-800 dark:text-slate-100", children:
|
|
1340
|
+
/* @__PURE__ */ c("div", { children: [
|
|
1341
|
+
/* @__PURE__ */ t("dt", { className: "text-[10.5px] text-slate-500 dark:text-slate-400", children: f }),
|
|
1342
|
+
/* @__PURE__ */ t("dd", { className: "font-medium text-slate-800 dark:text-slate-100", children: z(i) })
|
|
1266
1343
|
] }),
|
|
1267
|
-
!
|
|
1268
|
-
/* @__PURE__ */ t("dt", { className: "text-[10.5px] text-slate-500 dark:text-slate-400", children:
|
|
1344
|
+
!E && /* @__PURE__ */ c("div", { children: [
|
|
1345
|
+
/* @__PURE__ */ t("dt", { className: "text-[10.5px] text-slate-500 dark:text-slate-400", children: M ? "Difference" : "Still to come" }),
|
|
1269
1346
|
/* @__PURE__ */ t(
|
|
1270
1347
|
"dd",
|
|
1271
1348
|
{
|
|
1272
|
-
className:
|
|
1349
|
+
className: D(
|
|
1273
1350
|
"font-medium",
|
|
1274
|
-
Math.abs(
|
|
1351
|
+
Math.abs(q) < 5e-3 ? "text-slate-800 dark:text-slate-100" : Kt[L === "neutral" ? "neutral" : L]
|
|
1275
1352
|
),
|
|
1276
|
-
children:
|
|
1353
|
+
children: z(q)
|
|
1277
1354
|
}
|
|
1278
1355
|
)
|
|
1279
1356
|
] })
|
|
1280
1357
|
] })
|
|
1281
1358
|
] }),
|
|
1282
|
-
|
|
1283
|
-
/* @__PURE__ */
|
|
1359
|
+
K.length > 0 && /* @__PURE__ */ t("ul", { className: "max-h-[168px] overflow-y-auto px-3 py-1.5", children: K.map((w) => /* @__PURE__ */ c("li", { className: "flex items-baseline gap-2 py-0.5", children: [
|
|
1360
|
+
/* @__PURE__ */ c("span", { className: "min-w-0 flex-1 truncate text-slate-700 dark:text-slate-200", children: [
|
|
1284
1361
|
w.label,
|
|
1285
1362
|
w.sub ? /* @__PURE__ */ t("span", { className: "text-slate-500 dark:text-slate-400", children: ` · ${w.sub}` }) : null
|
|
1286
1363
|
] }),
|
|
1287
|
-
/* @__PURE__ */ t("span", { className: "tabular-nums text-slate-800 dark:text-slate-100", children:
|
|
1364
|
+
/* @__PURE__ */ t("span", { className: "tabular-nums text-slate-800 dark:text-slate-100", children: z(w.amount) })
|
|
1288
1365
|
] }, String(w.id))) }),
|
|
1289
|
-
|
|
1290
|
-
|
|
1366
|
+
K.length === 0 && /* @__PURE__ */ t("p", { className: "px-3 py-2 text-slate-500 dark:text-slate-400", children: `No ${_a(x, 2)} behind this figure.` }),
|
|
1367
|
+
p && T && /* @__PURE__ */ c(
|
|
1291
1368
|
"div",
|
|
1292
1369
|
{
|
|
1293
1370
|
className: "border-t border-slate-200 px-3 py-2 dark:border-border",
|
|
1294
1371
|
"data-plan-reconcile": !0,
|
|
1295
1372
|
children: [
|
|
1296
|
-
/* @__PURE__ */ t("p", { className: "font-medium text-slate-900 dark:text-slate-100", children: `Set the ${
|
|
1373
|
+
/* @__PURE__ */ t("p", { className: "font-medium text-slate-900 dark:text-slate-100", children: `Set the ${C.toLowerCase()} to ${z(i)} and put the ${z(Math.abs(q))} ${q > 0 ? "left over" : "shortfall"}…` }),
|
|
1297
1374
|
/* @__PURE__ */ t(
|
|
1298
1375
|
"div",
|
|
1299
1376
|
{
|
|
1300
1377
|
className: "mt-1.5 space-y-1",
|
|
1301
1378
|
role: "radiogroup",
|
|
1302
1379
|
"aria-label": "Where the difference goes",
|
|
1303
|
-
children: le.map((w) => /* @__PURE__ */
|
|
1380
|
+
children: le.map((w) => /* @__PURE__ */ c(
|
|
1304
1381
|
"label",
|
|
1305
1382
|
{
|
|
1306
|
-
className:
|
|
1383
|
+
className: D(
|
|
1307
1384
|
"flex cursor-pointer items-center gap-2",
|
|
1308
1385
|
w.disabled && "cursor-not-allowed opacity-50"
|
|
1309
1386
|
),
|
|
@@ -1315,8 +1392,8 @@ function La(v) {
|
|
|
1315
1392
|
name: "pg-reconcile",
|
|
1316
1393
|
"data-plan-reconcile-mode": w.key,
|
|
1317
1394
|
disabled: w.disabled,
|
|
1318
|
-
checked:
|
|
1319
|
-
onChange: () =>
|
|
1395
|
+
checked: y === w.key,
|
|
1396
|
+
onChange: () => g(w.key),
|
|
1320
1397
|
className: "accent-[rgb(var(--nvr-cyan-rgb))]"
|
|
1321
1398
|
}
|
|
1322
1399
|
),
|
|
@@ -1327,41 +1404,41 @@ function La(v) {
|
|
|
1327
1404
|
))
|
|
1328
1405
|
}
|
|
1329
1406
|
),
|
|
1330
|
-
|
|
1407
|
+
s && y !== "none" && /* @__PURE__ */ t(
|
|
1331
1408
|
"p",
|
|
1332
1409
|
{
|
|
1333
1410
|
className: "mt-1.5 text-[11.5px] text-slate-600 dark:text-slate-300",
|
|
1334
|
-
"data-plan-reconcile-carry":
|
|
1335
|
-
children:
|
|
1411
|
+
"data-plan-reconcile-carry": s.key,
|
|
1412
|
+
children: s.row ? `Every period of this row is closed, so it goes to ${s.key}.` : `Every period of this row is closed and ${s.key} has no row for this line — one is added, and shows as pending until you save.`
|
|
1336
1413
|
}
|
|
1337
1414
|
),
|
|
1338
|
-
|
|
1415
|
+
O && /* @__PURE__ */ t(
|
|
1339
1416
|
"p",
|
|
1340
1417
|
{
|
|
1341
1418
|
className: "mt-1.5 text-[11.5px] text-amber-700 dark:text-amber-300",
|
|
1342
1419
|
"data-plan-reconcile-blocked": !0,
|
|
1343
|
-
children: `Every period of this row is closed, and ${
|
|
1420
|
+
children: `Every period of this row is closed, and ${O} — the difference can only be dropped from here.`
|
|
1344
1421
|
}
|
|
1345
1422
|
),
|
|
1346
|
-
|
|
1423
|
+
T.targets.length > 0 && /* @__PURE__ */ c(
|
|
1347
1424
|
"p",
|
|
1348
1425
|
{
|
|
1349
1426
|
className: "mt-1.5 text-[11.5px] tabular-nums text-slate-600 dark:text-slate-300",
|
|
1350
1427
|
"data-plan-reconcile-preview": !0,
|
|
1351
1428
|
children: [
|
|
1352
|
-
|
|
1353
|
-
(w) => `${
|
|
1429
|
+
T.targets.slice(0, 6).map(
|
|
1430
|
+
(w) => `${it(w)}${s ? ` ${s.key}` : ""} ${z(B(h[w]))} → ${z(de[w])}`
|
|
1354
1431
|
).join(" · "),
|
|
1355
|
-
|
|
1432
|
+
T.targets.length > 6 ? ` · +${T.targets.length - 6} more` : ""
|
|
1356
1433
|
]
|
|
1357
1434
|
}
|
|
1358
1435
|
),
|
|
1359
|
-
|
|
1436
|
+
y !== "none" && Math.abs(T.unabsorbed) >= 5e-3 && /* @__PURE__ */ t("p", { className: "mt-1 text-[11.5px] text-amber-700 dark:text-amber-300", children: `${z(Math.abs(T.unabsorbed))} has nowhere to go — it leaves the ${C.toLowerCase()}.` }),
|
|
1360
1437
|
/* @__PURE__ */ t(
|
|
1361
1438
|
"textarea",
|
|
1362
1439
|
{
|
|
1363
1440
|
value: j,
|
|
1364
|
-
onChange: (w) =>
|
|
1441
|
+
onChange: (w) => I(w.target.value),
|
|
1365
1442
|
rows: 2,
|
|
1366
1443
|
"aria-label": "Reason",
|
|
1367
1444
|
className: "mt-2 w-full resize-none rounded-md border border-slate-200 bg-background px-2 py-1 text-[12px] text-slate-800 outline-none focus:border-slate-400 dark:border-border dark:text-slate-100"
|
|
@@ -1373,10 +1450,10 @@ function La(v) {
|
|
|
1373
1450
|
type: "button",
|
|
1374
1451
|
"data-plan-reconcile-apply": !0,
|
|
1375
1452
|
onClick: () => {
|
|
1376
|
-
const w =
|
|
1377
|
-
|
|
1378
|
-
w ? `Reconcile staged across ${n.split(" ").pop()} and ${
|
|
1379
|
-
),
|
|
1453
|
+
const w = s && T.targetPatch && Object.keys(T.targetPatch).length > 0 ? { target: s, patch: T.targetPatch } : void 0;
|
|
1454
|
+
p.onApply(T.patch, j.trim() || A, w) && (ie.success(
|
|
1455
|
+
w ? `Reconcile staged across ${n.split(" ").pop()} and ${s == null ? void 0 : s.key} — Save to keep it` : "Reconcile staged — Save to keep it"
|
|
1456
|
+
), v(!1));
|
|
1380
1457
|
},
|
|
1381
1458
|
className: "rounded-md bg-nvr-cyan px-3 py-1 text-[12px] font-medium text-white",
|
|
1382
1459
|
children: "Stage it"
|
|
@@ -1388,144 +1465,144 @@ function La(v) {
|
|
|
1388
1465
|
] })
|
|
1389
1466
|
] });
|
|
1390
1467
|
}
|
|
1391
|
-
function
|
|
1468
|
+
function Fa(b) {
|
|
1392
1469
|
const {
|
|
1393
1470
|
block: n,
|
|
1394
|
-
config:
|
|
1395
|
-
canSplit:
|
|
1396
|
-
splitUnavailable:
|
|
1397
|
-
splitBase:
|
|
1398
|
-
client:
|
|
1399
|
-
cols:
|
|
1400
|
-
catLabel:
|
|
1471
|
+
config: x,
|
|
1472
|
+
canSplit: f,
|
|
1473
|
+
splitUnavailable: i,
|
|
1474
|
+
splitBase: k,
|
|
1475
|
+
client: M,
|
|
1476
|
+
cols: E,
|
|
1477
|
+
catLabel: K,
|
|
1401
1478
|
showHistory: L,
|
|
1402
|
-
onHistory:
|
|
1403
|
-
onSpread:
|
|
1404
|
-
onRemove:
|
|
1405
|
-
onDone:
|
|
1406
|
-
rc:
|
|
1407
|
-
} =
|
|
1408
|
-
|
|
1409
|
-
j &&
|
|
1479
|
+
onHistory: p,
|
|
1480
|
+
onSpread: N,
|
|
1481
|
+
onRemove: v,
|
|
1482
|
+
onDone: y,
|
|
1483
|
+
rc: g
|
|
1484
|
+
} = b, [j, I] = W(!1), [C, q] = W("menu");
|
|
1485
|
+
ue(() => {
|
|
1486
|
+
j && q("menu");
|
|
1410
1487
|
}, [j]);
|
|
1411
|
-
const
|
|
1412
|
-
return /* @__PURE__ */
|
|
1413
|
-
/* @__PURE__ */ t(
|
|
1488
|
+
const s = [...n.top ? [n.top] : [], ...n.cats], O = s.some((R) => R.edited || R.isNew), h = "flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-[12.5px] text-slate-700 hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50 dark:text-slate-200";
|
|
1489
|
+
return /* @__PURE__ */ c(ut, { open: j, onOpenChange: I, children: [
|
|
1490
|
+
/* @__PURE__ */ t(pt, { asChild: !0, children: /* @__PURE__ */ t(
|
|
1414
1491
|
"button",
|
|
1415
1492
|
{
|
|
1416
1493
|
type: "button",
|
|
1417
1494
|
"data-plan-menu": n.key,
|
|
1418
1495
|
"aria-label": `Actions for ${n.key}`,
|
|
1419
1496
|
className: "rounded p-0.5 text-slate-500 hover:bg-muted hover:text-slate-800 dark:hover:text-slate-100",
|
|
1420
|
-
children: /* @__PURE__ */ t(
|
|
1497
|
+
children: /* @__PURE__ */ t(ia, { className: "h-3.5 w-3.5" })
|
|
1421
1498
|
}
|
|
1422
1499
|
) }),
|
|
1423
|
-
/* @__PURE__ */
|
|
1424
|
-
|
|
1500
|
+
/* @__PURE__ */ c(
|
|
1501
|
+
mt,
|
|
1425
1502
|
{
|
|
1426
1503
|
align: "start",
|
|
1427
1504
|
sideOffset: 6,
|
|
1428
|
-
className:
|
|
1505
|
+
className: D("p-1.5", C === "split" ? "w-[440px]" : "w-[300px]"),
|
|
1429
1506
|
children: [
|
|
1430
|
-
|
|
1431
|
-
n.mode === "top" &&
|
|
1507
|
+
C === "menu" && /* @__PURE__ */ c("div", { children: [
|
|
1508
|
+
n.mode === "top" && f && /* @__PURE__ */ c(
|
|
1432
1509
|
"button",
|
|
1433
1510
|
{
|
|
1434
1511
|
type: "button",
|
|
1435
1512
|
"data-plan-split": n.key,
|
|
1436
|
-
disabled:
|
|
1437
|
-
onClick: () =>
|
|
1438
|
-
className:
|
|
1513
|
+
disabled: O,
|
|
1514
|
+
onClick: () => q("split"),
|
|
1515
|
+
className: h,
|
|
1439
1516
|
children: [
|
|
1440
|
-
/* @__PURE__ */ t(
|
|
1441
|
-
|
|
1517
|
+
/* @__PURE__ */ t(Et, { className: "h-3.5 w-3.5" }),
|
|
1518
|
+
x.split_label ?? "Plan by category"
|
|
1442
1519
|
]
|
|
1443
1520
|
}
|
|
1444
1521
|
),
|
|
1445
|
-
n.mode === "top" && !
|
|
1446
|
-
/* @__PURE__ */
|
|
1447
|
-
/* @__PURE__ */ t(
|
|
1448
|
-
|
|
1522
|
+
n.mode === "top" && !f && i && /* @__PURE__ */ c("div", { "data-plan-split-unavailable": !0, className: "px-2 py-1.5", children: [
|
|
1523
|
+
/* @__PURE__ */ c("p", { className: "flex items-center gap-2 text-[12.5px] text-slate-400 dark:text-slate-500", children: [
|
|
1524
|
+
/* @__PURE__ */ t(Et, { className: "h-3.5 w-3.5" }),
|
|
1525
|
+
x.split_label ?? "Plan by category"
|
|
1449
1526
|
] }),
|
|
1450
|
-
/* @__PURE__ */ t("p", { className: "mt-0.5 pl-[22px] text-[11px] text-slate-500 dark:text-slate-400", children:
|
|
1527
|
+
/* @__PURE__ */ t("p", { className: "mt-0.5 pl-[22px] text-[11px] text-slate-500 dark:text-slate-400", children: i })
|
|
1451
1528
|
] }),
|
|
1452
|
-
n.mode === "split" &&
|
|
1529
|
+
n.mode === "split" && k && /* @__PURE__ */ c(
|
|
1453
1530
|
"button",
|
|
1454
1531
|
{
|
|
1455
1532
|
type: "button",
|
|
1456
1533
|
"data-plan-merge": n.key,
|
|
1457
|
-
disabled:
|
|
1458
|
-
onClick: () =>
|
|
1459
|
-
className:
|
|
1534
|
+
disabled: O,
|
|
1535
|
+
onClick: () => q("merge"),
|
|
1536
|
+
className: h,
|
|
1460
1537
|
children: [
|
|
1461
|
-
/* @__PURE__ */ t(
|
|
1462
|
-
|
|
1538
|
+
/* @__PURE__ */ t(da, { className: "h-3.5 w-3.5" }),
|
|
1539
|
+
x.merge_label ?? "Merge back to one line"
|
|
1463
1540
|
]
|
|
1464
1541
|
}
|
|
1465
1542
|
),
|
|
1466
|
-
|
|
1467
|
-
|
|
1543
|
+
O && (n.mode === "split" || f) && /* @__PURE__ */ t("p", { className: "px-2 pb-1 text-[11px] text-slate-500 dark:text-slate-400", children: "Save your changes to this block first." }),
|
|
1544
|
+
N && s.map((R) => /* @__PURE__ */ c(
|
|
1468
1545
|
"button",
|
|
1469
1546
|
{
|
|
1470
1547
|
type: "button",
|
|
1471
|
-
"data-plan-spread":
|
|
1548
|
+
"data-plan-spread": R.uid,
|
|
1472
1549
|
onClick: () => {
|
|
1473
|
-
|
|
1550
|
+
N(R), I(!1);
|
|
1474
1551
|
},
|
|
1475
|
-
className:
|
|
1552
|
+
className: h,
|
|
1476
1553
|
children: [
|
|
1477
1554
|
/* @__PURE__ */ t("span", { className: "w-3.5" }),
|
|
1478
|
-
`Spread what is left${
|
|
1555
|
+
`Spread what is left${R.cat ? ` · ${K(R.cat)}` : ""}`
|
|
1479
1556
|
]
|
|
1480
1557
|
},
|
|
1481
|
-
|
|
1558
|
+
R.uid
|
|
1482
1559
|
)),
|
|
1483
|
-
L &&
|
|
1484
|
-
/* @__PURE__ */
|
|
1560
|
+
L && s.filter((R) => R.id).map((R) => /* @__PURE__ */ c("div", { className: "flex items-center", children: [
|
|
1561
|
+
/* @__PURE__ */ c(
|
|
1485
1562
|
"button",
|
|
1486
1563
|
{
|
|
1487
1564
|
type: "button",
|
|
1488
1565
|
onClick: () => {
|
|
1489
|
-
|
|
1566
|
+
p(R), I(!1);
|
|
1490
1567
|
},
|
|
1491
|
-
className:
|
|
1568
|
+
className: h,
|
|
1492
1569
|
children: [
|
|
1493
|
-
/* @__PURE__ */ t(
|
|
1494
|
-
`History${
|
|
1570
|
+
/* @__PURE__ */ t(ca, { className: "h-3.5 w-3.5" }),
|
|
1571
|
+
`History${R.cat ? ` · ${K(R.cat)}` : ""}`
|
|
1495
1572
|
]
|
|
1496
1573
|
}
|
|
1497
1574
|
),
|
|
1498
1575
|
/* @__PURE__ */ t(
|
|
1499
|
-
|
|
1576
|
+
Ea,
|
|
1500
1577
|
{
|
|
1501
|
-
collection:
|
|
1502
|
-
rowId:
|
|
1503
|
-
rowLabel: `${n.key}${
|
|
1578
|
+
collection: g,
|
|
1579
|
+
rowId: R.id,
|
|
1580
|
+
rowLabel: `${n.key}${R.cat ? ` ${K(R.cat)}` : ""}`
|
|
1504
1581
|
}
|
|
1505
1582
|
)
|
|
1506
|
-
] },
|
|
1507
|
-
/* @__PURE__ */
|
|
1583
|
+
] }, R.uid)),
|
|
1584
|
+
/* @__PURE__ */ c(
|
|
1508
1585
|
"button",
|
|
1509
1586
|
{
|
|
1510
1587
|
type: "button",
|
|
1511
1588
|
"data-plan-remove": n.key,
|
|
1512
|
-
onClick: () =>
|
|
1513
|
-
className:
|
|
1589
|
+
onClick: () => q("remove"),
|
|
1590
|
+
className: D(h, "text-red-700 dark:text-red-300"),
|
|
1514
1591
|
children: [
|
|
1515
|
-
/* @__PURE__ */ t(
|
|
1592
|
+
/* @__PURE__ */ t(ua, { className: "h-3.5 w-3.5" }),
|
|
1516
1593
|
`Remove ${n.key}`
|
|
1517
1594
|
]
|
|
1518
1595
|
}
|
|
1519
1596
|
)
|
|
1520
1597
|
] }),
|
|
1521
|
-
|
|
1598
|
+
C === "remove" && /* @__PURE__ */ c("div", { className: "p-1.5", children: [
|
|
1522
1599
|
/* @__PURE__ */ t("p", { className: "text-[12.5px] text-slate-700 dark:text-slate-200", children: `Remove the ${n.key} plan? It leaves with the next Save.` }),
|
|
1523
|
-
/* @__PURE__ */
|
|
1600
|
+
/* @__PURE__ */ c("div", { className: "mt-2 flex justify-end gap-2", children: [
|
|
1524
1601
|
/* @__PURE__ */ t(
|
|
1525
1602
|
"button",
|
|
1526
1603
|
{
|
|
1527
1604
|
type: "button",
|
|
1528
|
-
onClick: () =>
|
|
1605
|
+
onClick: () => q("menu"),
|
|
1529
1606
|
className: "rounded-md px-2.5 py-1 text-[12px] text-slate-600 hover:bg-muted dark:text-slate-300",
|
|
1530
1607
|
children: "Keep it"
|
|
1531
1608
|
}
|
|
@@ -1536,7 +1613,7 @@ function Ra(v) {
|
|
|
1536
1613
|
type: "button",
|
|
1537
1614
|
"data-plan-remove-confirm": !0,
|
|
1538
1615
|
onClick: () => {
|
|
1539
|
-
|
|
1616
|
+
v(), I(!1);
|
|
1540
1617
|
},
|
|
1541
1618
|
className: "rounded-md bg-red-600 px-2.5 py-1 text-[12px] font-medium text-white",
|
|
1542
1619
|
children: "Remove"
|
|
@@ -1544,30 +1621,30 @@ function Ra(v) {
|
|
|
1544
1621
|
)
|
|
1545
1622
|
] })
|
|
1546
1623
|
] }),
|
|
1547
|
-
|
|
1548
|
-
|
|
1624
|
+
C === "split" && k && n.top && /* @__PURE__ */ t(
|
|
1625
|
+
Ka,
|
|
1549
1626
|
{
|
|
1550
1627
|
block: n,
|
|
1551
|
-
config:
|
|
1552
|
-
splitBase:
|
|
1553
|
-
client:
|
|
1554
|
-
cols:
|
|
1555
|
-
onCancel: () =>
|
|
1628
|
+
config: x,
|
|
1629
|
+
splitBase: k,
|
|
1630
|
+
client: M,
|
|
1631
|
+
cols: E,
|
|
1632
|
+
onCancel: () => q("menu"),
|
|
1556
1633
|
onDone: () => {
|
|
1557
|
-
|
|
1634
|
+
I(!1), y();
|
|
1558
1635
|
}
|
|
1559
1636
|
}
|
|
1560
1637
|
),
|
|
1561
|
-
|
|
1562
|
-
|
|
1638
|
+
C === "merge" && k && /* @__PURE__ */ t(
|
|
1639
|
+
Ia,
|
|
1563
1640
|
{
|
|
1564
1641
|
block: n,
|
|
1565
|
-
config:
|
|
1566
|
-
splitBase:
|
|
1567
|
-
client:
|
|
1568
|
-
onCancel: () =>
|
|
1642
|
+
config: x,
|
|
1643
|
+
splitBase: k,
|
|
1644
|
+
client: M,
|
|
1645
|
+
onCancel: () => q("menu"),
|
|
1569
1646
|
onDone: () => {
|
|
1570
|
-
|
|
1647
|
+
I(!1), y();
|
|
1571
1648
|
}
|
|
1572
1649
|
}
|
|
1573
1650
|
)
|
|
@@ -1576,146 +1653,146 @@ function Ra(v) {
|
|
|
1576
1653
|
)
|
|
1577
1654
|
] });
|
|
1578
1655
|
}
|
|
1579
|
-
function
|
|
1580
|
-
return
|
|
1656
|
+
function dt(b) {
|
|
1657
|
+
return ga(b, "Something went wrong");
|
|
1581
1658
|
}
|
|
1582
|
-
function
|
|
1583
|
-
var
|
|
1584
|
-
const { block: n, config:
|
|
1585
|
-
|
|
1586
|
-
let
|
|
1659
|
+
function Ka(b) {
|
|
1660
|
+
var de, re;
|
|
1661
|
+
const { block: n, config: x, splitBase: f, client: i, cols: k, onCancel: M, onDone: E } = b, K = Number.isFinite(Number(n.key)) ? Number(n.key) : n.key, [L, p] = W(null), [N, v] = W(null), [y, g] = W(null), [j, I] = W(!1), [C, q] = W(""), s = JSON.stringify(L);
|
|
1662
|
+
ue(() => {
|
|
1663
|
+
let A = !0;
|
|
1587
1664
|
const le = window.setTimeout(
|
|
1588
1665
|
() => {
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
[
|
|
1666
|
+
i.request(
|
|
1667
|
+
ot(`${f}/split`, {
|
|
1668
|
+
[x.key_field]: K,
|
|
1592
1669
|
preview: !0,
|
|
1593
1670
|
...L ? { shares: L } : {}
|
|
1594
1671
|
})
|
|
1595
1672
|
).then((V) => {
|
|
1596
|
-
|
|
1673
|
+
A && (v(V.data), g(null), L || p(
|
|
1597
1674
|
Object.fromEntries(
|
|
1598
|
-
V.data.categories.map((
|
|
1675
|
+
V.data.categories.map((ce) => [String(ce.id), Math.round(ce.share * 1e3) / 10])
|
|
1599
1676
|
)
|
|
1600
1677
|
));
|
|
1601
|
-
}).catch((V) =>
|
|
1678
|
+
}).catch((V) => A && g(dt(V)));
|
|
1602
1679
|
},
|
|
1603
1680
|
L ? 250 : 0
|
|
1604
1681
|
);
|
|
1605
1682
|
return () => {
|
|
1606
|
-
|
|
1683
|
+
A = !1, window.clearTimeout(le);
|
|
1607
1684
|
};
|
|
1608
|
-
}, [
|
|
1609
|
-
const
|
|
1610
|
-
|
|
1685
|
+
}, [s, f]);
|
|
1686
|
+
const O = (N == null ? void 0 : N.categories.map((A) => A.label).join(" / ")) ?? "", h = `Split the ${n.key} plan into ${O}`, R = async () => {
|
|
1687
|
+
I(!0);
|
|
1611
1688
|
try {
|
|
1612
|
-
await
|
|
1613
|
-
|
|
1614
|
-
[
|
|
1689
|
+
await i.request(
|
|
1690
|
+
ot(`${f}/split`, {
|
|
1691
|
+
[x.key_field]: K,
|
|
1615
1692
|
shares: L ?? void 0,
|
|
1616
|
-
reason:
|
|
1693
|
+
reason: C.trim() || h
|
|
1617
1694
|
})
|
|
1618
|
-
),
|
|
1619
|
-
} catch (
|
|
1620
|
-
|
|
1695
|
+
), ie.success(`${n.key} is now planned by ${O}`), E();
|
|
1696
|
+
} catch (A) {
|
|
1697
|
+
g(dt(A));
|
|
1621
1698
|
} finally {
|
|
1622
|
-
|
|
1699
|
+
I(!1);
|
|
1623
1700
|
}
|
|
1624
|
-
},
|
|
1625
|
-
return /* @__PURE__ */
|
|
1626
|
-
/* @__PURE__ */ t("p", { className: "text-[12.5px] font-semibold text-slate-900 dark:text-slate-100", children: `${
|
|
1701
|
+
}, T = (A) => F(k.reduce((le, V) => le + B(A[V]), 0));
|
|
1702
|
+
return /* @__PURE__ */ c("div", { className: "p-1.5", "data-plan-split-pane": !0, children: [
|
|
1703
|
+
/* @__PURE__ */ t("p", { className: "text-[12.5px] font-semibold text-slate-900 dark:text-slate-100", children: `${x.split_label ?? "Plan by category"} · ${n.key}` }),
|
|
1627
1704
|
/* @__PURE__ */ t("p", { className: "mt-0.5 text-[11.5px] text-slate-600 dark:text-slate-300", children: "Every period is divided by these shares. Closed periods keep their totals; open ones can be changed in the grid afterwards." }),
|
|
1628
|
-
!
|
|
1705
|
+
!N && !y && /* @__PURE__ */ t(
|
|
1629
1706
|
"div",
|
|
1630
1707
|
{
|
|
1631
1708
|
className: "mt-2 h-16 animate-pulse rounded",
|
|
1632
1709
|
style: { background: "hsl(var(--nvr-skeleton))" }
|
|
1633
1710
|
}
|
|
1634
1711
|
),
|
|
1635
|
-
|
|
1712
|
+
N && (((de = N.share_sets) == null ? void 0 : de.length) ?? 0) > 1 && /* @__PURE__ */ c("div", { className: "mt-2 flex flex-wrap items-center gap-1", "data-plan-share-sets": !0, children: [
|
|
1636
1713
|
/* @__PURE__ */ t("span", { className: "text-[11px] text-slate-500 dark:text-slate-400", children: "Shares from" }),
|
|
1637
|
-
(
|
|
1714
|
+
(re = N.share_sets) == null ? void 0 : re.map((A) => {
|
|
1638
1715
|
const le = Object.fromEntries(
|
|
1639
|
-
Object.entries(
|
|
1640
|
-
), V = JSON.stringify(le) ===
|
|
1716
|
+
Object.entries(A.shares).map(([ce, w]) => [ce, Math.round(w * 1e3) / 10])
|
|
1717
|
+
), V = JSON.stringify(le) === s;
|
|
1641
1718
|
return /* @__PURE__ */ t(
|
|
1642
1719
|
"button",
|
|
1643
1720
|
{
|
|
1644
1721
|
type: "button",
|
|
1645
|
-
"data-plan-share-set":
|
|
1722
|
+
"data-plan-share-set": A.key,
|
|
1646
1723
|
"aria-pressed": V,
|
|
1647
|
-
"data-tip":
|
|
1648
|
-
onClick: () =>
|
|
1724
|
+
"data-tip": A.hint ?? "",
|
|
1725
|
+
onClick: () => p(le),
|
|
1649
1726
|
className: `h-6 rounded-md border px-1.5 text-[11px] font-medium ${V ? "border-transparent bg-nvr-cyan text-white" : "border-slate-200 text-slate-600 hover:bg-muted dark:border-border dark:text-slate-300"}`,
|
|
1650
|
-
children:
|
|
1727
|
+
children: A.label
|
|
1651
1728
|
},
|
|
1652
|
-
|
|
1729
|
+
A.key
|
|
1653
1730
|
);
|
|
1654
1731
|
})
|
|
1655
1732
|
] }),
|
|
1656
|
-
|
|
1657
|
-
/* @__PURE__ */ t("thead", { children: /* @__PURE__ */
|
|
1733
|
+
N && /* @__PURE__ */ c("table", { className: "mt-2 w-full text-[12px] tabular-nums", children: [
|
|
1734
|
+
/* @__PURE__ */ t("thead", { children: /* @__PURE__ */ c("tr", { className: "text-left text-[10.5px] text-slate-500 dark:text-slate-400", children: [
|
|
1658
1735
|
/* @__PURE__ */ t("th", { className: "py-1 font-medium", children: "Category" }),
|
|
1659
1736
|
/* @__PURE__ */ t("th", { className: "py-1 text-right font-medium", children: "Share" }),
|
|
1660
1737
|
/* @__PURE__ */ t("th", { className: "py-1 text-right font-medium", children: `${n.key} plan` }),
|
|
1661
1738
|
/* @__PURE__ */ t("th", { className: "py-1 text-right font-medium", children: "Ceiling" })
|
|
1662
1739
|
] }) }),
|
|
1663
|
-
/* @__PURE__ */
|
|
1664
|
-
|
|
1665
|
-
/* @__PURE__ */ t("td", { className: "py-1 text-slate-800 dark:text-slate-100", children:
|
|
1666
|
-
/* @__PURE__ */
|
|
1740
|
+
/* @__PURE__ */ c("tbody", { children: [
|
|
1741
|
+
N.categories.map((A) => /* @__PURE__ */ c("tr", { className: "border-t border-slate-100 dark:border-border", children: [
|
|
1742
|
+
/* @__PURE__ */ t("td", { className: "py-1 text-slate-800 dark:text-slate-100", children: A.label }),
|
|
1743
|
+
/* @__PURE__ */ c("td", { className: "py-1 text-right", children: [
|
|
1667
1744
|
/* @__PURE__ */ t(
|
|
1668
|
-
|
|
1745
|
+
ka,
|
|
1669
1746
|
{
|
|
1670
1747
|
bare: !0,
|
|
1671
1748
|
type: "text",
|
|
1672
1749
|
allowNegative: !1,
|
|
1673
|
-
"data-plan-share": String(
|
|
1674
|
-
"aria-label": `${
|
|
1675
|
-
value: (L == null ? void 0 : L[String(
|
|
1676
|
-
onValue: (le) =>
|
|
1750
|
+
"data-plan-share": String(A.id),
|
|
1751
|
+
"aria-label": `${A.label} share`,
|
|
1752
|
+
value: (L == null ? void 0 : L[String(A.id)]) ?? "",
|
|
1753
|
+
onValue: (le) => p((V) => ({ ...V ?? {}, [String(A.id)]: le ?? 0 })),
|
|
1677
1754
|
className: "h-6 w-16 rounded border border-slate-200 bg-background px-1.5 text-right text-[12px] outline-none focus:border-slate-400 dark:border-border"
|
|
1678
1755
|
}
|
|
1679
1756
|
),
|
|
1680
1757
|
/* @__PURE__ */ t("span", { className: "ml-0.5 text-slate-500", children: "%" })
|
|
1681
1758
|
] }),
|
|
1682
|
-
/* @__PURE__ */ t("td", { className: "py-1 text-right text-slate-800 dark:text-slate-100", children:
|
|
1683
|
-
/* @__PURE__ */ t("td", { className: "py-1 text-right text-slate-500 dark:text-slate-400", children:
|
|
1684
|
-
] }, String(
|
|
1685
|
-
/* @__PURE__ */
|
|
1686
|
-
/* @__PURE__ */ t("td", { className: "py-1 text-slate-800 dark:text-slate-100", children:
|
|
1759
|
+
/* @__PURE__ */ t("td", { className: "py-1 text-right text-slate-800 dark:text-slate-100", children: z(T(A.values)) }),
|
|
1760
|
+
/* @__PURE__ */ t("td", { className: "py-1 text-right text-slate-500 dark:text-slate-400", children: z(A.cap) })
|
|
1761
|
+
] }, String(A.id))),
|
|
1762
|
+
/* @__PURE__ */ c("tr", { className: "border-t border-slate-200 font-medium dark:border-border", children: [
|
|
1763
|
+
/* @__PURE__ */ t("td", { className: "py-1 text-slate-800 dark:text-slate-100", children: x.total_label ?? "Total" }),
|
|
1687
1764
|
/* @__PURE__ */ t("td", {}),
|
|
1688
|
-
/* @__PURE__ */ t("td", { className: "py-1 text-right text-slate-800 dark:text-slate-100", children:
|
|
1765
|
+
/* @__PURE__ */ t("td", { className: "py-1 text-right text-slate-800 dark:text-slate-100", children: z(T(N.original)) }),
|
|
1689
1766
|
/* @__PURE__ */ t("td", {})
|
|
1690
1767
|
] })
|
|
1691
1768
|
] })
|
|
1692
1769
|
] }),
|
|
1693
|
-
(
|
|
1770
|
+
(y || (N == null ? void 0 : N.blocked)) && /* @__PURE__ */ t(
|
|
1694
1771
|
"p",
|
|
1695
1772
|
{
|
|
1696
1773
|
role: "alert",
|
|
1697
1774
|
"data-plan-split-blocked": !0,
|
|
1698
1775
|
className: "mt-1.5 text-[11.5px] font-medium text-red-700 dark:text-red-300",
|
|
1699
|
-
children:
|
|
1776
|
+
children: y ?? (N == null ? void 0 : N.blocked)
|
|
1700
1777
|
}
|
|
1701
1778
|
),
|
|
1702
1779
|
/* @__PURE__ */ t(
|
|
1703
1780
|
"textarea",
|
|
1704
1781
|
{
|
|
1705
|
-
value:
|
|
1706
|
-
onChange: (
|
|
1707
|
-
placeholder:
|
|
1782
|
+
value: C,
|
|
1783
|
+
onChange: (A) => q(A.target.value),
|
|
1784
|
+
placeholder: h,
|
|
1708
1785
|
rows: 2,
|
|
1709
1786
|
"aria-label": "Reason",
|
|
1710
1787
|
className: "mt-2 w-full resize-none rounded-md border border-slate-200 bg-background px-2 py-1 text-[12px] text-slate-800 outline-none focus:border-slate-400 dark:border-border dark:text-slate-100"
|
|
1711
1788
|
}
|
|
1712
1789
|
),
|
|
1713
|
-
/* @__PURE__ */
|
|
1790
|
+
/* @__PURE__ */ c("div", { className: "mt-1.5 flex justify-end gap-2", children: [
|
|
1714
1791
|
/* @__PURE__ */ t(
|
|
1715
1792
|
"button",
|
|
1716
1793
|
{
|
|
1717
1794
|
type: "button",
|
|
1718
|
-
onClick:
|
|
1795
|
+
onClick: M,
|
|
1719
1796
|
className: "rounded-md px-2.5 py-1 text-[12px] text-slate-600 hover:bg-muted dark:text-slate-300",
|
|
1720
1797
|
children: "Back"
|
|
1721
1798
|
}
|
|
@@ -1725,8 +1802,8 @@ function Ma(v) {
|
|
|
1725
1802
|
{
|
|
1726
1803
|
type: "button",
|
|
1727
1804
|
"data-plan-split-apply": !0,
|
|
1728
|
-
disabled: j || !
|
|
1729
|
-
onClick:
|
|
1805
|
+
disabled: j || !N || !!N.blocked,
|
|
1806
|
+
onClick: R,
|
|
1730
1807
|
className: "rounded-md bg-nvr-cyan px-3 py-1 text-[12px] font-medium text-white disabled:opacity-50",
|
|
1731
1808
|
children: j ? "Splitting…" : "Split it"
|
|
1732
1809
|
}
|
|
@@ -1734,29 +1811,29 @@ function Ma(v) {
|
|
|
1734
1811
|
] })
|
|
1735
1812
|
] });
|
|
1736
1813
|
}
|
|
1737
|
-
function
|
|
1738
|
-
const { block: n, config:
|
|
1739
|
-
return /* @__PURE__ */
|
|
1740
|
-
/* @__PURE__ */ t("p", { className: "text-[12.5px] font-semibold text-slate-900 dark:text-slate-100", children: `${
|
|
1814
|
+
function Ia(b) {
|
|
1815
|
+
const { block: n, config: x, splitBase: f, client: i, onCancel: k, onDone: M } = b, E = Number.isFinite(Number(n.key)) ? Number(n.key) : n.key, [K, L] = W(""), [p, N] = W(!1), [v, y] = W(null), g = `Merged the ${n.key} plan back to one line`;
|
|
1816
|
+
return /* @__PURE__ */ c("div", { className: "p-1.5", "data-plan-merge-pane": !0, children: [
|
|
1817
|
+
/* @__PURE__ */ t("p", { className: "text-[12.5px] font-semibold text-slate-900 dark:text-slate-100", children: `${x.merge_label ?? "Merge back to one line"} · ${n.key}` }),
|
|
1741
1818
|
/* @__PURE__ */ t("p", { className: "mt-0.5 text-[11.5px] text-slate-600 dark:text-slate-300", children: "The category lines are added together, period by period. Their history stays on the record." }),
|
|
1742
|
-
|
|
1819
|
+
v && /* @__PURE__ */ t("p", { role: "alert", className: "mt-1.5 text-[11.5px] font-medium text-red-700 dark:text-red-300", children: v }),
|
|
1743
1820
|
/* @__PURE__ */ t(
|
|
1744
1821
|
"textarea",
|
|
1745
1822
|
{
|
|
1746
|
-
value:
|
|
1823
|
+
value: K,
|
|
1747
1824
|
onChange: (j) => L(j.target.value),
|
|
1748
|
-
placeholder:
|
|
1825
|
+
placeholder: g,
|
|
1749
1826
|
rows: 2,
|
|
1750
1827
|
"aria-label": "Reason",
|
|
1751
1828
|
className: "mt-2 w-full resize-none rounded-md border border-slate-200 bg-background px-2 py-1 text-[12px] text-slate-800 outline-none focus:border-slate-400 dark:border-border dark:text-slate-100"
|
|
1752
1829
|
}
|
|
1753
1830
|
),
|
|
1754
|
-
/* @__PURE__ */
|
|
1831
|
+
/* @__PURE__ */ c("div", { className: "mt-1.5 flex justify-end gap-2", children: [
|
|
1755
1832
|
/* @__PURE__ */ t(
|
|
1756
1833
|
"button",
|
|
1757
1834
|
{
|
|
1758
1835
|
type: "button",
|
|
1759
|
-
onClick:
|
|
1836
|
+
onClick: k,
|
|
1760
1837
|
className: "rounded-md px-2.5 py-1 text-[12px] text-slate-600 hover:bg-muted dark:text-slate-300",
|
|
1761
1838
|
children: "Back"
|
|
1762
1839
|
}
|
|
@@ -1766,79 +1843,79 @@ function Ta(v) {
|
|
|
1766
1843
|
{
|
|
1767
1844
|
type: "button",
|
|
1768
1845
|
"data-plan-merge-apply": !0,
|
|
1769
|
-
disabled:
|
|
1846
|
+
disabled: p,
|
|
1770
1847
|
onClick: async () => {
|
|
1771
|
-
|
|
1848
|
+
N(!0);
|
|
1772
1849
|
try {
|
|
1773
|
-
await
|
|
1774
|
-
|
|
1775
|
-
[
|
|
1776
|
-
reason:
|
|
1850
|
+
await i.request(
|
|
1851
|
+
ot(`${f}/merge`, {
|
|
1852
|
+
[x.key_field]: E,
|
|
1853
|
+
reason: K.trim() || g
|
|
1777
1854
|
})
|
|
1778
|
-
),
|
|
1855
|
+
), ie.success(`${n.key} is one line again`), M();
|
|
1779
1856
|
} catch (j) {
|
|
1780
|
-
|
|
1857
|
+
y(dt(j));
|
|
1781
1858
|
} finally {
|
|
1782
|
-
|
|
1859
|
+
N(!1);
|
|
1783
1860
|
}
|
|
1784
1861
|
},
|
|
1785
1862
|
className: "rounded-md bg-nvr-cyan px-3 py-1 text-[12px] font-medium text-white disabled:opacity-50",
|
|
1786
|
-
children:
|
|
1863
|
+
children: p ? "Merging…" : "Merge it"
|
|
1787
1864
|
}
|
|
1788
1865
|
)
|
|
1789
1866
|
] })
|
|
1790
1867
|
] });
|
|
1791
1868
|
}
|
|
1792
|
-
function
|
|
1793
|
-
const { config: n, client:
|
|
1869
|
+
function Ba(b) {
|
|
1870
|
+
const { config: n, client: x, used: f, onAdd: i, label: k } = b, [M, E] = W(!1), [K, L] = W(""), { data: p = [] } = he({
|
|
1794
1871
|
queryKey: ["plan-grid-keys", n.key_collection],
|
|
1795
|
-
queryFn: () =>
|
|
1796
|
-
|
|
1797
|
-
).then((
|
|
1798
|
-
enabled:
|
|
1872
|
+
queryFn: () => x.request(
|
|
1873
|
+
fe(`/items/${n.key_collection}`, { fields: "id", sort: "-id", limit: 200 })
|
|
1874
|
+
).then((v) => (v.data ?? []).map((y) => y.id)),
|
|
1875
|
+
enabled: M && !!n.key_collection,
|
|
1799
1876
|
staleTime: 10 * 6e4
|
|
1800
|
-
}),
|
|
1801
|
-
return /* @__PURE__ */
|
|
1802
|
-
/* @__PURE__ */ t(
|
|
1877
|
+
}), N = p.filter((v) => !f.has(String(v)));
|
|
1878
|
+
return /* @__PURE__ */ c(ut, { open: M, onOpenChange: E, children: [
|
|
1879
|
+
/* @__PURE__ */ t(pt, { asChild: !0, children: /* @__PURE__ */ c(
|
|
1803
1880
|
"button",
|
|
1804
1881
|
{
|
|
1805
1882
|
type: "button",
|
|
1806
1883
|
"data-plan-add": !0,
|
|
1807
1884
|
className: "inline-flex h-7 items-center gap-1 rounded-md border border-slate-200 px-2 text-[12px] font-medium text-slate-700 hover:bg-muted dark:border-border dark:text-slate-200",
|
|
1808
1885
|
children: [
|
|
1809
|
-
/* @__PURE__ */ t(
|
|
1810
|
-
|
|
1886
|
+
/* @__PURE__ */ t(pa, { className: "h-3.5 w-3.5" }),
|
|
1887
|
+
k
|
|
1811
1888
|
]
|
|
1812
1889
|
}
|
|
1813
1890
|
) }),
|
|
1814
|
-
/* @__PURE__ */ t(
|
|
1815
|
-
|
|
1816
|
-
|
|
1891
|
+
/* @__PURE__ */ t(mt, { align: "start", sideOffset: 6, className: "w-[200px] p-1.5", children: n.key_collection ? /* @__PURE__ */ c("ul", { className: "max-h-[220px] overflow-y-auto", children: [
|
|
1892
|
+
N.length === 0 && /* @__PURE__ */ t("li", { className: "px-2 py-1.5 text-[12px] text-slate-500", children: "Every one is already here." }),
|
|
1893
|
+
N.map((v) => /* @__PURE__ */ t("li", { children: /* @__PURE__ */ t(
|
|
1817
1894
|
"button",
|
|
1818
1895
|
{
|
|
1819
1896
|
type: "button",
|
|
1820
|
-
"data-plan-add-key": String(
|
|
1897
|
+
"data-plan-add-key": String(v),
|
|
1821
1898
|
onClick: () => {
|
|
1822
|
-
|
|
1899
|
+
i(v), E(!1);
|
|
1823
1900
|
},
|
|
1824
1901
|
className: "w-full rounded px-2 py-1.5 text-left text-[12.5px] text-slate-700 hover:bg-muted dark:text-slate-200",
|
|
1825
|
-
children: String(
|
|
1902
|
+
children: String(v)
|
|
1826
1903
|
}
|
|
1827
|
-
) }, String(
|
|
1904
|
+
) }, String(v)))
|
|
1828
1905
|
] }) : /* @__PURE__ */ t(
|
|
1829
1906
|
"form",
|
|
1830
1907
|
{
|
|
1831
|
-
onSubmit: (
|
|
1832
|
-
|
|
1833
|
-
const
|
|
1834
|
-
!
|
|
1908
|
+
onSubmit: (v) => {
|
|
1909
|
+
v.preventDefault();
|
|
1910
|
+
const y = K.trim();
|
|
1911
|
+
!y || f.has(y) || (i(Number.isFinite(Number(y)) ? Number(y) : y), L(""), E(!1));
|
|
1835
1912
|
},
|
|
1836
1913
|
children: /* @__PURE__ */ t(
|
|
1837
1914
|
"input",
|
|
1838
1915
|
{
|
|
1839
|
-
value:
|
|
1840
|
-
onChange: (
|
|
1841
|
-
"aria-label":
|
|
1916
|
+
value: K,
|
|
1917
|
+
onChange: (v) => L(v.target.value),
|
|
1918
|
+
"aria-label": k,
|
|
1842
1919
|
className: "h-7 w-full rounded border border-slate-200 bg-background px-2 text-[12.5px] outline-none focus:border-slate-400 dark:border-border"
|
|
1843
1920
|
}
|
|
1844
1921
|
)
|
|
@@ -1847,9 +1924,11 @@ function Ea(v) {
|
|
|
1847
1924
|
] });
|
|
1848
1925
|
}
|
|
1849
1926
|
export {
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1927
|
+
il as PlanGridField,
|
|
1928
|
+
Dt as figureError,
|
|
1929
|
+
z as fmtFigure,
|
|
1930
|
+
Pa as isParentItemKey,
|
|
1931
|
+
Ta as nextStagedEdit,
|
|
1932
|
+
Bt as parseFigure,
|
|
1933
|
+
ja as reconcilePatch
|
|
1855
1934
|
};
|