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