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