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