@nivaro/react 0.3.45 → 0.3.47
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 +290 -23
- package/dist/index.js +679 -659
- package/dist/shared/components/BaseMap.js +149 -103
- package/dist/shared/components/CollectionBrowserView.js +813 -826
- package/dist/shared/components/ErrorNotice.js +169 -0
- package/dist/shared/components/ErrorSurface.js +23 -17
- package/dist/shared/components/ListLoadError.js +8 -29
- package/dist/shared/components/LoadErrorNote.js +38 -21
- package/dist/shared/components/QueryErrorState.js +8 -11
- package/dist/shared/components/ReportView.js +1320 -1291
- package/dist/shared/components/chat/ChannelArchive.js +60 -60
- package/dist/shared/components/chat/ChannelExtras.js +74 -74
- package/dist/shared/components/chat/ChatPanel.js +368 -367
- package/dist/shared/components/command-center/CommandCenterView.js +313 -69
- package/dist/shared/components/command-center/Customize.js +353 -0
- package/dist/shared/components/command-center/Header.js +279 -53
- package/dist/shared/components/command-center/KioskLinks.js +198 -0
- package/dist/shared/components/command-center/PeekPanel.js +144 -3
- package/dist/shared/components/command-center/announce.js +13 -0
- package/dist/shared/components/command-center/board-prefs.js +99 -0
- package/dist/shared/components/command-center/freshness.js +29 -0
- package/dist/shared/components/command-center/layout.js +56 -0
- package/dist/shared/components/command-center/panels/AttentionPanel.js +132 -3
- package/dist/shared/components/command-center/panels/Banner.js +75 -0
- package/dist/shared/components/command-center/panels/BoardSettings.js +224 -0
- package/dist/shared/components/command-center/panels/FeedPanel.js +145 -29
- package/dist/shared/components/command-center/panels/FlowPanel.js +154 -56
- package/dist/shared/components/command-center/panels/ForecastPanel.js +244 -3
- package/dist/shared/components/command-center/panels/MapLegend.js +266 -0
- package/dist/shared/components/command-center/panels/MapPanel.js +216 -66
- package/dist/shared/components/command-center/panels/PartnersPanel.js +49 -3
- package/dist/shared/components/command-center/panels/PeoplePanel.js +258 -40
- package/dist/shared/components/command-center/panels/RegionPicker.js +88 -3
- package/dist/shared/components/command-center/panels/SystemPanel.js +158 -38
- package/dist/shared/components/command-center/panels/ThroughputPanel.js +307 -3
- package/dist/shared/components/command-center/panels/TimeBar.js +227 -6
- package/dist/shared/components/command-center/panels/TrafficPanel.js +12 -8
- package/dist/shared/components/command-center/panels/WorkloadPanel.js +82 -3
- package/dist/shared/components/command-center/panels/attention-actions.js +267 -0
- package/dist/shared/components/command-center/panels/map-shared.js +95 -0
- package/dist/shared/components/command-center/panels/registry.js +87 -19
- package/dist/shared/components/command-center/shell-hooks.js +118 -0
- package/dist/shared/components/command-center/shortcuts.js +37 -0
- package/dist/shared/components/command-center/theme.js +39 -21
- package/dist/shared/components/command-center/time.js +52 -0
- package/dist/shared/components/command-center/url-state.js +54 -0
- package/dist/shared/components/command-center/work-links.js +32 -0
- package/dist/shared/components/help-videos/editor/ClipsPanel.js +49 -48
- package/dist/shared/components/help-videos/editor/PublishButton.js +37 -36
- package/dist/shared/components/help-videos/editor/StatsTab.js +45 -44
- package/dist/shared/components/help-videos/editor/VersionsTab.js +29 -28
- package/dist/shared/components/help-videos/library/AuthorRolesButton.js +19 -18
- package/dist/shared/components/help-videos/library/HelpVideoLibrary.js +132 -129
- package/dist/shared/components/help-videos/library/LearningPathsPanel.js +42 -41
- package/dist/shared/components/help-videos/settings/HouseStyleButton.js +21 -20
- package/dist/shared/components/help-videos/settings/RenderSettingsButton.js +22 -21
- package/dist/shared/components/import/DocumentAutofillButton.js +24 -20
- package/dist/shared/components/import/ImportFromFileButton.js +61 -60
- package/dist/shared/components/imports/ImportStalenessControl.js +20 -21
- package/dist/shared/components/imports/NewImportDialog.js +29 -28
- package/dist/shared/components/imports/RunDetailSheet.js +63 -63
- package/dist/shared/components/item-edit/FieldRow.js +329 -329
- package/dist/shared/components/item-edit/InlineTableField.js +898 -898
- package/dist/shared/components/item-edit/PersonalDefaultControl.js +57 -56
- package/dist/shared/components/item-edit/PlanGrid.js +220 -221
- package/dist/shared/components/item-edit/RecordGrantTools.js +49 -48
- package/dist/shared/components/item-edit/placement-behaviour.js +68 -67
- package/dist/shared/components/layout-editor/inspector/ColumnFit.js +24 -23
- package/dist/shared/components/layout-editor/inspector/PickerPreview.js +17 -16
- package/dist/shared/components/layout-editor/matrix/FieldStateMatrix.js +41 -41
- package/dist/shared/components/layout-editor/outputs/output-api.js +33 -31
- package/dist/shared/components/layout-editor/overview/overview-api.js +84 -83
- package/dist/shared/components/layout-editor/useLayoutDraft.js +47 -42
- package/dist/shared/components/monitoring/InactiveUserLinksView.js +10 -9
- package/dist/shared/components/monitoring/TrafficMiniMap.js +111 -70
- package/dist/shared/components/panels/SlaClock.js +35 -36
- package/dist/shared/components/pipeline/PipelineEditorView.js +311 -312
- package/dist/shared/components/pipeline/TeamSuggestions.js +31 -30
- package/dist/shared/components/profile/AgentsPanel.js +73 -72
- package/dist/shared/components/profile/MailSuppressedPill.js +22 -21
- package/dist/shared/components/support/SupportRequestDialog.js +85 -81
- package/dist/shared/components/support/SupportView.js +94 -87
- package/dist/shared/lib/autofill-poll.js +21 -18
- package/dist/shared/lib/error-actions.js +85 -0
- package/dist/shared/lib/error-message.js +223 -82
- package/dist/shared/lib/error-toast.js +71 -13
- package/dist/shared/lib/safe-error.js +136 -38
- package/package.json +1 -1
|
@@ -7,13 +7,14 @@ import { useNivaroClient as sa, useParentDraft as ra, useItemEditAuth as oa } fr
|
|
|
7
7
|
import { get as ue, post as lt } from "../../lib/commands.js";
|
|
8
8
|
import { useAfterIdle as ia } from "../../lib/defer.js";
|
|
9
9
|
import { evaluateNumeric as et } from "../../lib/expression.js";
|
|
10
|
-
import {
|
|
10
|
+
import { userErrorMessage as da } from "../../lib/safe-error.js";
|
|
11
|
+
import { cn as I, formatRelative as ca } from "../../lib/utils.js";
|
|
11
12
|
import { Popover as rt, PopoverTrigger as ot, PopoverContent as it } from "../ui/popover.js";
|
|
12
|
-
import { resolveCompareEndpoint as
|
|
13
|
-
import { useO2MStaging as
|
|
14
|
-
import { usePlanGridHost as
|
|
15
|
-
import { RowHistorySheet as
|
|
16
|
-
import { RowWatchButton as
|
|
13
|
+
import { resolveCompareEndpoint as ua, useCompareSeries as pa, compareColumnClosed as ma, planLabel as Et, closedThroughLabel as ha, CompareProposalBanner as fa, CompareStripChips as xa, GridStatChip as Ct, monthLabel as nt, extraSeriesValue as ve, SeriesFigurePopover as _t, monthLabelLong as Re, unitWord as ga } from "./CompareSeries.js";
|
|
14
|
+
import { useO2MStaging as ya, useLiveRows as ba } from "./O2MStagingContext.js";
|
|
15
|
+
import { usePlanGridHost as ka } from "./PlanGridHost.js";
|
|
16
|
+
import { RowHistorySheet as va } from "./RowHistorySheet.js";
|
|
17
|
+
import { RowWatchButton as Na } from "./RowWatchButton.js";
|
|
17
18
|
const Ke = "unclassified", B = (_) => Number(_) || 0, E = (_) => Math.round(_ * 100) / 100;
|
|
18
19
|
function D(_) {
|
|
19
20
|
const n = Math.abs(_ - Math.round(_)) < 5e-3;
|
|
@@ -27,25 +28,25 @@ function D(_) {
|
|
|
27
28
|
function Tt(_) {
|
|
28
29
|
const n = _.replace(/[$,\s]/g, "");
|
|
29
30
|
if (n === "" || n === "-" || n === "—") return 0;
|
|
30
|
-
const
|
|
31
|
-
return Number.isFinite(
|
|
31
|
+
const p = /^\(.*\)$/.test(n), y = Number(p ? n.slice(1, -1) : n);
|
|
32
|
+
return Number.isFinite(y) ? E(p ? -y : y) : null;
|
|
32
33
|
}
|
|
33
|
-
function
|
|
34
|
-
const { column: n, actual:
|
|
35
|
-
if (o === "none" || Math.abs(M) < 5e-3 ||
|
|
34
|
+
function wa(_) {
|
|
35
|
+
const { column: n, actual: p, openColumns: y, mode: o } = _, $ = _.targetRow != null, M = E(B(_.row[n]) - p), K = { [n]: E(p) }, F = _.targetRow ?? _.row, L = $ ? {} : K;
|
|
36
|
+
if (o === "none" || Math.abs(M) < 5e-3 || y.length === 0)
|
|
36
37
|
return { patch: K, moved: 0, unabsorbed: o === "none" ? 0 : M, targets: [] };
|
|
37
38
|
let f, b;
|
|
38
|
-
if (o === "next" ? (f = [
|
|
39
|
-
const C = b.reduce((
|
|
39
|
+
if (o === "next" ? (f = [y[0]], b = [1]) : o === "weighted" ? (f = y.filter((x) => B(F[x]) > 5e-3), b = f.map((x) => B(F[x])), f.length === 0 && $ && M > 0 && (f = y, b = f.map(() => 1))) : (f = y, b = f.map(() => 1)), f.length === 0) return { patch: K, moved: 0, unabsorbed: M, targets: [] };
|
|
40
|
+
const C = b.reduce((x, j) => x + j, 0) || 1;
|
|
40
41
|
let k = M;
|
|
41
|
-
if (f.forEach((
|
|
42
|
-
const v = j === f.length - 1 ? k : E(M * b[j] / C),
|
|
43
|
-
L[
|
|
42
|
+
if (f.forEach((x, j) => {
|
|
43
|
+
const v = j === f.length - 1 ? k : E(M * b[j] / C), g = Math.max(0, E(B(F[x]) + v)), i = E(g - B(F[x]));
|
|
44
|
+
L[x] = g, k = E(k - i);
|
|
44
45
|
}), Math.abs(k) >= 5e-3 && k < 0)
|
|
45
|
-
for (const
|
|
46
|
+
for (const x of f) {
|
|
46
47
|
if (Math.abs(k) < 5e-3) break;
|
|
47
|
-
const j = Math.min(L[
|
|
48
|
-
L[
|
|
48
|
+
const j = Math.min(L[x], -k);
|
|
49
|
+
L[x] = E(L[x] - j), k = E(k + j);
|
|
49
50
|
}
|
|
50
51
|
return $ ? {
|
|
51
52
|
patch: K,
|
|
@@ -56,11 +57,11 @@ function Na(_) {
|
|
|
56
57
|
} : { patch: L, moved: E(M - k), unabsorbed: k, targets: f };
|
|
57
58
|
}
|
|
58
59
|
const St = 176, Ot = 112, Lt = 128, xe = "sticky left-0 z-[2] bg-white dark:bg-[hsl(var(--card))] border-r border-slate-200 dark:border-border", ge = "sticky right-0 z-[2] bg-white dark:bg-[hsl(var(--card))] border-l border-slate-200 dark:border-border", Ne = "bg-slate-50 dark:bg-white/[0.035]";
|
|
59
|
-
function
|
|
60
|
+
function Qa(_) {
|
|
60
61
|
const {
|
|
61
62
|
relatedCollection: n,
|
|
62
|
-
manyField:
|
|
63
|
-
parentId:
|
|
63
|
+
manyField: p,
|
|
64
|
+
parentId: y,
|
|
64
65
|
config: o,
|
|
65
66
|
compareSeries: $,
|
|
66
67
|
stats: M,
|
|
@@ -69,24 +70,24 @@ function Wa(_) {
|
|
|
69
70
|
readOnly: L = !1,
|
|
70
71
|
showHistory: f = !0,
|
|
71
72
|
emptyLabel: b
|
|
72
|
-
} = _, C = sa(), k = Yt(),
|
|
73
|
+
} = _, C = sa(), k = Yt(), x = ya(), j = ba(), T = ra(), v = T == null ? void 0 : T.draft, { isAdmin: g } = oa(), i = !y || y === "new", U = !L && !!x, m = o.value_fields, R = o.total_field ?? null, {
|
|
73
74
|
data: q = [],
|
|
74
75
|
isLoading: oe,
|
|
75
76
|
dataUpdatedAt: be
|
|
76
77
|
} = ce({
|
|
77
|
-
queryKey: ["o2m-rows", n,
|
|
78
|
+
queryKey: ["o2m-rows", n, p, y, ""],
|
|
78
79
|
queryFn: () => C.request(
|
|
79
|
-
ue(`/items/${n}`, { filter: JSON.stringify({ [
|
|
80
|
+
ue(`/items/${n}`, { filter: JSON.stringify({ [p]: { _eq: y } }), limit: 200 })
|
|
80
81
|
).then((e) => e.data ?? []),
|
|
81
82
|
enabled: !i,
|
|
82
83
|
staleTime: 3e4
|
|
83
84
|
}), P = ia(2e3), { data: le = {} } = ce({
|
|
84
|
-
queryKey: ["o2m-cell-provenance", n,
|
|
85
|
+
queryKey: ["o2m-cell-provenance", n, p, y, be],
|
|
85
86
|
queryFn: () => C.request(
|
|
86
87
|
ue("/revisions/o2m-cell-provenance", {
|
|
87
88
|
collection: n,
|
|
88
|
-
many_field:
|
|
89
|
-
parent_id:
|
|
89
|
+
many_field: p,
|
|
90
|
+
parent_id: y
|
|
90
91
|
})
|
|
91
92
|
).then((e) => e.data ?? {}),
|
|
92
93
|
enabled: P && f && !i && q.length > 0,
|
|
@@ -112,16 +113,16 @@ function Wa(_) {
|
|
|
112
113
|
[]
|
|
113
114
|
);
|
|
114
115
|
const Ee = G(
|
|
115
|
-
() => $ != null && $.endpoint ?
|
|
116
|
+
() => $ != null && $.endpoint ? ua($.endpoint, v) : null,
|
|
116
117
|
[$ == null ? void 0 : $.endpoint, v]
|
|
117
|
-
), Be =
|
|
118
|
+
), Be = pa({
|
|
118
119
|
client: C,
|
|
119
120
|
endpoint: Ee,
|
|
120
121
|
enabled: !!$ && !i
|
|
121
|
-
}),
|
|
122
|
+
}), c = $ && !i ? Be.data ?? null : null, me = G(() => !o.split_endpoint || i ? null : o.split_endpoint.replace(
|
|
122
123
|
/\$parent\.([A-Za-z_][A-Za-z0-9_]*)/g,
|
|
123
|
-
(e, a) => String(a === "id" ?
|
|
124
|
-
), [o.split_endpoint, i,
|
|
124
|
+
(e, a) => String(a === "id" ? y : (v == null ? void 0 : v[a]) ?? "")
|
|
125
|
+
), [o.split_endpoint, i, y, v]), Ie = G(() => ["plan-grid-split-info", me], [me]), { data: ie = null } = ce({
|
|
125
126
|
queryKey: Ie,
|
|
126
127
|
queryFn: () => C.request(ue(me)).then((e) => e.data ?? null).catch(() => null),
|
|
127
128
|
enabled: !!me,
|
|
@@ -139,19 +140,19 @@ function Wa(_) {
|
|
|
139
140
|
}), we = ee(
|
|
140
141
|
(e) => e === Ke ? o.unclassified_label ?? "Unclassified" : dt[e] ?? `#${e}`,
|
|
141
142
|
[dt, o.unclassified_label]
|
|
142
|
-
), De = G(() => (o.categories ?? []).map(String), [o.categories]), ct = (
|
|
143
|
+
), De = G(() => (o.categories ?? []).map(String), [o.categories]), ct = (x == null ? void 0 : x.getPendingRows(n, p)) ?? [], Te = x == null ? void 0 : x.getPendingEdits(n, p), qe = x == null ? void 0 : x.getPendingDeletes(n, p), Z = G(() => {
|
|
143
144
|
const e = [], a = (l) => l && typeof l == "object" && "id" in l ? l.id : l;
|
|
144
145
|
for (const l of q) {
|
|
145
146
|
const s = String(l.id);
|
|
146
147
|
if (qe != null && qe.has(s)) continue;
|
|
147
|
-
const r = Te == null ? void 0 : Te.get(s),
|
|
148
|
+
const r = Te == null ? void 0 : Te.get(s), u = r ? { ...l, ...r } : l, O = a(u[o.category_field]);
|
|
148
149
|
e.push({
|
|
149
150
|
uid: `s:${s}`,
|
|
150
151
|
id: s,
|
|
151
152
|
pendingIndex: null,
|
|
152
|
-
key: String(a(
|
|
153
|
+
key: String(a(u[o.key_field]) ?? ""),
|
|
153
154
|
cat: O == null || O === "" ? null : String(O),
|
|
154
|
-
values:
|
|
155
|
+
values: u,
|
|
155
156
|
edited: !!r && Object.keys(r).some((H) => !H.startsWith("_")),
|
|
156
157
|
isNew: !1
|
|
157
158
|
});
|
|
@@ -181,32 +182,32 @@ function Wa(_) {
|
|
|
181
182
|
}
|
|
182
183
|
for (const a of e.values())
|
|
183
184
|
a.cats.length && (a.mode = "split", a.cats.sort((l, s) => {
|
|
184
|
-
const r = De.indexOf(l.cat),
|
|
185
|
-
return (r < 0 ? 99 : r) - (
|
|
185
|
+
const r = De.indexOf(l.cat), u = De.indexOf(s.cat);
|
|
186
|
+
return (r < 0 ? 99 : r) - (u < 0 ? 99 : u);
|
|
186
187
|
}));
|
|
187
|
-
for (const a of (
|
|
188
|
+
for (const a of (c == null ? void 0 : c.rows) ?? []) {
|
|
188
189
|
const l = String(a.key);
|
|
189
190
|
e.has(l) || m.some((s) => Math.abs(B(a.values[s])) >= 5e-3) && e.set(l, { key: l, mode: "ghost", top: null, cats: [] });
|
|
190
191
|
}
|
|
191
192
|
return [...e.values()].sort(
|
|
192
193
|
(a, l) => Number(a.key) - Number(l.key) || a.key.localeCompare(l.key)
|
|
193
194
|
);
|
|
194
|
-
}, [Z,
|
|
195
|
+
}, [Z, c, m, De]), $e = G(
|
|
195
196
|
() => Z.map((e) => R ? { ...e.values, [R]: Y(e.values) } : e.values),
|
|
196
197
|
[Z, R, Y]
|
|
197
198
|
), he = j == null ? void 0 : j.report;
|
|
198
199
|
ye(() => {
|
|
199
200
|
if (he) {
|
|
200
201
|
if (oe) {
|
|
201
|
-
he(n,
|
|
202
|
+
he(n, p, null);
|
|
202
203
|
return;
|
|
203
204
|
}
|
|
204
|
-
he(n,
|
|
205
|
+
he(n, p, $e);
|
|
205
206
|
}
|
|
206
|
-
}, [he, n,
|
|
207
|
+
}, [he, n, p, $e, oe]);
|
|
207
208
|
const ut = Me(() => {
|
|
208
209
|
});
|
|
209
|
-
ut.current = () => he == null ? void 0 : he(n,
|
|
210
|
+
ut.current = () => he == null ? void 0 : he(n, p, null), ye(() => () => ut.current(), []);
|
|
210
211
|
const Ce = ee(
|
|
211
212
|
(e) => {
|
|
212
213
|
if (e.startsWith("$parent.")) return (v == null ? void 0 : v[e.slice(8)]) ?? 0;
|
|
@@ -235,25 +236,25 @@ function Wa(_) {
|
|
|
235
236
|
left: E(e.cap - a)
|
|
236
237
|
};
|
|
237
238
|
}) : [], [ie, Z, Y]), J = ee(
|
|
238
|
-
(e, a) =>
|
|
239
|
-
[
|
|
239
|
+
(e, a) => ma(c, e, a),
|
|
240
|
+
[c]
|
|
240
241
|
), Pe = ee(
|
|
241
|
-
(e, a) => !U || J(e, a) && !!(
|
|
242
|
-
[U, J,
|
|
242
|
+
(e, a) => !U || J(e, a) && !!(c != null && c.closed_locked) && !g,
|
|
243
|
+
[U, J, c == null ? void 0 : c.closed_locked, g]
|
|
243
244
|
), Se = ee(
|
|
244
245
|
(e, a, l) => {
|
|
245
|
-
var
|
|
246
|
-
const s =
|
|
246
|
+
var u, O, H;
|
|
247
|
+
const s = c == null ? void 0 : c.rows.find((A) => String(A.key) === e);
|
|
247
248
|
if (!s) return { value: 0, details: [] };
|
|
248
|
-
if (a == null) return { value: B(s.values[l]), details: ((
|
|
249
|
+
if (a == null) return { value: B(s.values[l]), details: ((u = s.details) == null ? void 0 : u[l]) ?? [] };
|
|
249
250
|
const r = (O = s.by_category) == null ? void 0 : O[a];
|
|
250
251
|
return { value: B(r == null ? void 0 : r.values[l]), details: ((H = r == null ? void 0 : r.details) == null ? void 0 : H[l]) ?? [] };
|
|
251
252
|
},
|
|
252
|
-
[
|
|
253
|
+
[c]
|
|
253
254
|
), [mt, He] = W(null), X = ee(
|
|
254
255
|
(e, a, l, s) => {
|
|
255
|
-
if (!
|
|
256
|
-
const r = (s == null ? void 0 : s.credit) ?? 0,
|
|
256
|
+
if (!x) return !1;
|
|
257
|
+
const r = (s == null ? void 0 : s.credit) ?? 0, u = { ...e.values, ...a }, O = Y(e.values), H = Y(u);
|
|
257
258
|
if (H - r > O + 5e-3) {
|
|
258
259
|
if (K) {
|
|
259
260
|
const A = et(K.cap, Ce), S = E(Ue - O + H - r);
|
|
@@ -273,64 +274,64 @@ function Wa(_) {
|
|
|
273
274
|
}
|
|
274
275
|
}
|
|
275
276
|
}
|
|
276
|
-
return He(null), e.id ?
|
|
277
|
+
return He(null), e.id ? x.queueEdit(n, p, e.id, {
|
|
277
278
|
...a,
|
|
278
279
|
...l ? { _change_reason: l } : {},
|
|
279
280
|
...s != null && s.early ? { __flush_early: !0 } : {}
|
|
280
|
-
}) : e.pendingIndex != null &&
|
|
281
|
+
}) : e.pendingIndex != null && x.updateRow(n, p, e.pendingIndex, {
|
|
281
282
|
...e.values,
|
|
282
283
|
...a,
|
|
283
284
|
...l ? { _change_reason: l } : {}
|
|
284
285
|
}), !0;
|
|
285
286
|
},
|
|
286
|
-
[
|
|
287
|
+
[x, Y, K, Ce, Ue, _e, n, p]
|
|
287
288
|
), Oe = ee(
|
|
288
289
|
(e, a, l, s) => {
|
|
289
|
-
|
|
290
|
+
x && x.queueRow(n, p, {
|
|
290
291
|
[o.key_field]: e,
|
|
291
292
|
...s != null ? { [o.category_field]: /^\d+$/.test(s) ? Number(s) : s } : {},
|
|
292
293
|
...Object.fromEntries(m.map((r) => [r, (a == null ? void 0 : a[r]) ?? 0])),
|
|
293
294
|
...l ? { _change_reason: l } : {}
|
|
294
295
|
});
|
|
295
296
|
},
|
|
296
|
-
[
|
|
297
|
+
[x, n, p, o.key_field, o.category_field, m]
|
|
297
298
|
), { data: We } = ce({
|
|
298
299
|
queryKey: ["plan-grid-keys", o.key_collection],
|
|
299
300
|
queryFn: () => C.request(
|
|
300
301
|
ue(`/items/${o.key_collection}`, { fields: "id", sort: "-id", limit: 200 })
|
|
301
302
|
).then((e) => (e.data ?? []).map((a) => a.id)),
|
|
302
|
-
enabled: !!o.key_collection && !!(
|
|
303
|
+
enabled: !!o.key_collection && !!(c != null && c.closed_through),
|
|
303
304
|
staleTime: 10 * 6e4
|
|
304
305
|
}), ze = ee(
|
|
305
306
|
(e, a) => {
|
|
306
307
|
const l = Number(e);
|
|
307
308
|
if (!Number.isInteger(l)) return null;
|
|
308
|
-
const s = String(l + 1), r = m.filter((A) => !J(s, A)),
|
|
309
|
+
const s = String(l + 1), r = m.filter((A) => !J(s, A)), u = re.find((A) => A.key === s);
|
|
309
310
|
let O = null, H = null;
|
|
310
|
-
return o.key_collection && We && !We.some((A) => String(A) === s) ? H = `${s} is not set up yet` : r.length === 0 ? H = `${s} has no open period either` : (
|
|
311
|
+
return o.key_collection && We && !We.some((A) => String(A) === s) ? H = `${s} is not set up yet` : r.length === 0 ? H = `${s} has no open period either` : (u == null ? void 0 : u.mode) === "split" ? a == null ? H = `${s} is planned by category and this line is not` : O = u.cats.find((A) => A.cat === a) ?? null : (u == null ? void 0 : u.mode) === "top" && (a != null ? H = `${s} is planned as one line and this one is by category` : O = u.top), { key: s, cat: a, openColumns: r, row: O, blocked: H };
|
|
311
312
|
},
|
|
312
313
|
[m, J, re, o.key_collection, We]
|
|
313
314
|
), Qe = ee(
|
|
314
315
|
(e, a, l, s) => {
|
|
315
316
|
if (!s || Object.keys(s.patch).length === 0) return X(e, a, l);
|
|
316
|
-
const r = E(Y({ ...e.values, ...a }) - Y(e.values)),
|
|
317
|
-
Y({ ...(
|
|
317
|
+
const r = E(Y({ ...e.values, ...a }) - Y(e.values)), u = s.target.row, O = E(
|
|
318
|
+
Y({ ...(u == null ? void 0 : u.values) ?? {}, ...s.patch }) - Y((u == null ? void 0 : u.values) ?? {})
|
|
318
319
|
);
|
|
319
|
-
return r <= 0 ?
|
|
320
|
+
return r <= 0 ? u ? X(u, s.patch, l, { credit: -r }) ? X(e, a, l, { early: !0 }) : !1 : O > -r + 5e-3 || !X(e, a, l, { early: !0 }) ? !1 : (Oe(Number(s.target.key), s.patch, l, s.target.cat), !0) : u ? X(e, a, l, { credit: -O }) ? X(u, s.patch, l, { early: !0 }) : !1 : X(e, a, l);
|
|
320
321
|
},
|
|
321
322
|
[X, Y, Oe]
|
|
322
323
|
), jt = ee(
|
|
323
324
|
(e) => {
|
|
324
|
-
if (!
|
|
325
|
+
if (!x) return;
|
|
325
326
|
const a = [...e.top ? [e.top] : [], ...e.cats];
|
|
326
327
|
for (const l of a.filter((s) => s.pendingIndex != null).sort((s, r) => (r.pendingIndex ?? 0) - (s.pendingIndex ?? 0)))
|
|
327
|
-
|
|
328
|
-
for (const l of a) l.id &&
|
|
328
|
+
x.removeRow(n, p, l.pendingIndex);
|
|
329
|
+
for (const l of a) l.id && x.queueDelete(n, p, l.id);
|
|
329
330
|
},
|
|
330
|
-
[
|
|
331
|
+
[x, n, p]
|
|
331
332
|
), Ft = ee(() => {
|
|
332
|
-
k.invalidateQueries({ queryKey: ["o2m-rows", n,
|
|
333
|
-
}, [k, n,
|
|
333
|
+
k.invalidateQueries({ queryKey: ["o2m-rows", n, p, y] }), k.invalidateQueries({ queryKey: Ie }), Ee && k.invalidateQueries({ queryKey: ["o2m-compare", Ee] });
|
|
334
|
+
}, [k, n, p, y, Ie, Ee]), Ve = Me(null), fe = G(() => {
|
|
334
335
|
const e = [];
|
|
335
336
|
for (const a of re)
|
|
336
337
|
if (a.mode === "top" && a.top && e.push(a.top.uid), a.mode === "split") for (const l of a.cats) e.push(l.uid);
|
|
@@ -341,22 +342,22 @@ function Wa(_) {
|
|
|
341
342
|
return l ? (l.focus(), l.select(), !0) : !1;
|
|
342
343
|
}, []), ft = ee(
|
|
343
344
|
(e, a, l, s) => {
|
|
344
|
-
let r = fe.indexOf(e),
|
|
345
|
+
let r = fe.indexOf(e), u = m.indexOf(a);
|
|
345
346
|
for (let O = 0; O < 40; O++)
|
|
346
|
-
if (r += l,
|
|
347
|
+
if (r += l, u += s, r < 0 || r >= fe.length || u < 0 || u >= m.length || ht(fe[r], m[u])) return;
|
|
347
348
|
},
|
|
348
349
|
[fe, m, ht]
|
|
349
350
|
), xt = ee(
|
|
350
351
|
(e, a, l) => {
|
|
351
352
|
const s = l.replace(/\r/g, "").split(`
|
|
352
|
-
`).filter((H) => H.trim() !== ""), r = fe.indexOf(e.uid),
|
|
353
|
+
`).filter((H) => H.trim() !== ""), r = fe.indexOf(e.uid), u = m.indexOf(a);
|
|
353
354
|
let O = 0;
|
|
354
355
|
s.forEach((H, A) => {
|
|
355
356
|
const S = Z.find((te) => te.uid === fe[r + A]);
|
|
356
357
|
if (!S) return;
|
|
357
358
|
const Q = {};
|
|
358
359
|
H.split(" ").forEach((te, h) => {
|
|
359
|
-
const w = m[
|
|
360
|
+
const w = m[u + h];
|
|
360
361
|
if (!w || Pe(S.key, w)) return;
|
|
361
362
|
const ae = Tt(te);
|
|
362
363
|
ae == null || ae < 0 || (Q[w] = ae);
|
|
@@ -374,11 +375,11 @@ function Wa(_) {
|
|
|
374
375
|
Je.current = null;
|
|
375
376
|
}, 8e3), gt((r) => {
|
|
376
377
|
if (!r.has(s.key)) return r;
|
|
377
|
-
const
|
|
378
|
-
return
|
|
378
|
+
const u = new Set(r);
|
|
379
|
+
return u.delete(s.key), u;
|
|
379
380
|
}), window.setTimeout(() => {
|
|
380
|
-
var
|
|
381
|
-
const r = (
|
|
381
|
+
var u;
|
|
382
|
+
const r = (u = Ve.current) == null ? void 0 : u.querySelector(`[data-o2m-row="${n}:${s.id}"]`);
|
|
382
383
|
r && (r.scrollIntoView({ block: "center", behavior: "smooth" }), r.classList.remove("nvr-row-flash"), r.offsetWidth, r.classList.add("nvr-row-flash"));
|
|
383
384
|
}, 60)));
|
|
384
385
|
};
|
|
@@ -387,17 +388,17 @@ function Wa(_) {
|
|
|
387
388
|
const [Kt, Bt] = W(() => {
|
|
388
389
|
try {
|
|
389
390
|
return new Set(
|
|
390
|
-
JSON.parse(localStorage.getItem(`nvr_pg_dismissed:${n}:${
|
|
391
|
+
JSON.parse(localStorage.getItem(`nvr_pg_dismissed:${n}:${y}`) ?? "[]")
|
|
391
392
|
);
|
|
392
393
|
} catch {
|
|
393
394
|
return /* @__PURE__ */ new Set();
|
|
394
395
|
}
|
|
395
|
-
}), yt = ((
|
|
396
|
+
}), yt = ((c == null ? void 0 : c.proposals) ?? []).filter((e) => !Kt.has(e.id)), bt = (e, a) => {
|
|
396
397
|
Bt((l) => {
|
|
397
398
|
const s = new Set(l).add(e.id);
|
|
398
399
|
if (a)
|
|
399
400
|
try {
|
|
400
|
-
localStorage.setItem(`nvr_pg_dismissed:${n}:${
|
|
401
|
+
localStorage.setItem(`nvr_pg_dismissed:${n}:${y}`, JSON.stringify([...s]));
|
|
401
402
|
} catch {
|
|
402
403
|
}
|
|
403
404
|
return s;
|
|
@@ -407,33 +408,33 @@ function Wa(_) {
|
|
|
407
408
|
for (const l of e.rows) {
|
|
408
409
|
const s = String(l.key), r = re.find((S) => S.key === s);
|
|
409
410
|
if ((r == null ? void 0 : r.mode) === "split" != (l.category != null)) continue;
|
|
410
|
-
const
|
|
411
|
+
const u = e.mode === "add", O = Object.fromEntries(
|
|
411
412
|
Object.entries(l.values).filter(
|
|
412
|
-
([S, Q]) => m.includes(S) && !J(s, S) && (
|
|
413
|
+
([S, Q]) => m.includes(S) && !J(s, S) && (u ? B(Q) !== 0 : B(Q) > 0)
|
|
413
414
|
)
|
|
414
415
|
), H = (S) => Object.fromEntries(
|
|
415
416
|
Object.entries(O).map(([Q, te]) => [Q, Math.max(0, E(B(S == null ? void 0 : S[Q]) + B(te)))]).filter(([Q, te]) => Math.abs(te - B(S == null ? void 0 : S[Q])) >= 5e-3)
|
|
416
417
|
), A = l.category != null ? r == null ? void 0 : r.cats.find((S) => String(S.cat) === String(l.category)) : null;
|
|
417
418
|
if (l.category != null) {
|
|
418
419
|
if (!A) continue;
|
|
419
|
-
const S =
|
|
420
|
+
const S = u ? H(A.values) : Object.fromEntries(Object.entries(O).filter(([Q]) => B(A.values[Q]) === 0));
|
|
420
421
|
Object.keys(S).length && X(A, S, e.change_reason) && (a += Object.keys(S).length);
|
|
421
422
|
} else if (r != null && r.top) {
|
|
422
|
-
const S =
|
|
423
|
+
const S = u ? H(r.top.values) : Object.fromEntries(Object.entries(O).filter(([Q]) => {
|
|
423
424
|
var te;
|
|
424
425
|
return B((te = r.top) == null ? void 0 : te.values[Q]) === 0;
|
|
425
426
|
}));
|
|
426
427
|
Object.keys(S).length && X(r.top, S, e.change_reason) && (a += Object.keys(S).length);
|
|
427
|
-
} else Object.keys(O).length && !(
|
|
428
|
+
} else Object.keys(O).length && !(u && Object.values(O).every((S) => B(S) < 0)) && (Oe(l.key, u ? H(void 0) : O, e.change_reason), a += Object.keys(O).length);
|
|
428
429
|
}
|
|
429
430
|
a ? de.success(
|
|
430
431
|
`${e.label}: ${a} ${a === 1 ? "figure" : "figures"} staged — Save to keep them`
|
|
431
432
|
) : de.message(
|
|
432
433
|
e.mode === "add" ? "Nothing to move — no open period could take it" : "Nothing to fill — those periods already hold a figure"
|
|
433
434
|
), bt(e, !1);
|
|
434
|
-
}, [V, Ge] = W(null), je =
|
|
435
|
+
}, [V, Ge] = W(null), je = ka(), Ze = V && (je != null && je.renderRowHistory) ? je.renderRowHistory({
|
|
435
436
|
collection: n,
|
|
436
|
-
parentId:
|
|
437
|
+
parentId: y,
|
|
437
438
|
rowId: V.id,
|
|
438
439
|
key: V.key,
|
|
439
440
|
category: V.cat,
|
|
@@ -451,7 +452,7 @@ function Wa(_) {
|
|
|
451
452
|
queryFn: () => C.request(ue(`/field-config/${n}`)).then((e) => e.data ?? []),
|
|
452
453
|
enabled: !!V,
|
|
453
454
|
staleTime: 5 * 6e4
|
|
454
|
-
}), [Ye, Ht] = W(!1), vt = re.some((e) => e.mode === "split"), Fe = Et(
|
|
455
|
+
}), [Ye, Ht] = W(!1), vt = re.some((e) => e.mode === "split"), Fe = Et(c), ke = (c == null ? void 0 : c.label) ?? ($ == null ? void 0 : $.label) ?? "Actual", Ae = ha(c == null ? void 0 : c.closed_through), Le = c != null && c.closed_through ? Number(c.closed_through.split("-")[0]) : null, Wt = G(() => {
|
|
455
456
|
if (Le == null) return null;
|
|
456
457
|
const e = m.filter((a) => J(String(Le), a));
|
|
457
458
|
return e[e.length - 1] ?? null;
|
|
@@ -461,10 +462,10 @@ function Wa(_) {
|
|
|
461
462
|
), Qt = F ? et(F, Ce) : null, Vt = (e) => {
|
|
462
463
|
let a = Qt ?? 0;
|
|
463
464
|
if (e.cat != null) {
|
|
464
|
-
const
|
|
465
|
-
|
|
465
|
+
const u = _e.find((O) => O.id === e.cat);
|
|
466
|
+
u && (a = Math.min(a, u.left));
|
|
466
467
|
}
|
|
467
|
-
const l = m.filter((
|
|
468
|
+
const l = m.filter((u) => !J(e.key, u) && B(e.values[u]) === 0);
|
|
468
469
|
if (a < 5e-3 || l.length === 0) {
|
|
469
470
|
de.message(
|
|
470
471
|
a < 5e-3 ? "Nothing is left to spread" : "No empty open periods on this line"
|
|
@@ -472,15 +473,15 @@ function Wa(_) {
|
|
|
472
473
|
return;
|
|
473
474
|
}
|
|
474
475
|
const s = Math.floor(a / l.length * 100) / 100, r = {};
|
|
475
|
-
l.forEach((
|
|
476
|
-
r[
|
|
476
|
+
l.forEach((u, O) => {
|
|
477
|
+
r[u] = O === l.length - 1 ? E(a - s * (l.length - 1)) : s;
|
|
477
478
|
}), X(e, r) && de.success(`${D(a)} spread over ${l.length} open periods`);
|
|
478
479
|
}, Xe = G(() => {
|
|
479
480
|
const e = {}, a = {};
|
|
480
481
|
for (const l of m)
|
|
481
|
-
e[l] = E(Z.reduce((s, r) => s + B(r.values[l]), 0)), a[l] = E(((
|
|
482
|
+
e[l] = E(Z.reduce((s, r) => s + B(r.values[l]), 0)), a[l] = E(((c == null ? void 0 : c.rows) ?? []).reduce((s, r) => s + B(r.values[l]), 0));
|
|
482
483
|
return { planBy: e, actualBy: a };
|
|
483
|
-
}, [m, Z,
|
|
484
|
+
}, [m, Z, c]), Jt = St + m.length * Ot + Lt;
|
|
484
485
|
return !i && oe ? /* @__PURE__ */ t("div", { className: "space-y-1.5", "data-plan-grid-loading": !0, children: [0, 1, 2].map((e) => /* @__PURE__ */ t(
|
|
485
486
|
"div",
|
|
486
487
|
{
|
|
@@ -489,8 +490,8 @@ function Wa(_) {
|
|
|
489
490
|
},
|
|
490
491
|
e
|
|
491
492
|
)) }) : /* @__PURE__ */ d("div", { ref: Ve, "data-plan-grid": n, className: "min-w-0", children: [
|
|
492
|
-
|
|
493
|
-
|
|
493
|
+
c && yt.length > 0 && U && /* @__PURE__ */ t(
|
|
494
|
+
fa,
|
|
494
495
|
{
|
|
495
496
|
proposals: yt,
|
|
496
497
|
onApply: It,
|
|
@@ -499,9 +500,9 @@ function Wa(_) {
|
|
|
499
500
|
),
|
|
500
501
|
(pt.length > 0 || $) && /* @__PURE__ */ d("div", { className: "mb-2 flex flex-wrap items-center gap-1.5", "data-o2m-stats": !0, children: [
|
|
501
502
|
/* @__PURE__ */ t(
|
|
502
|
-
|
|
503
|
+
xa,
|
|
503
504
|
{
|
|
504
|
-
data:
|
|
505
|
+
data: c,
|
|
505
506
|
loading: !!$ && !i && Be.isLoading,
|
|
506
507
|
error: !!$ && !i && Be.isError
|
|
507
508
|
}
|
|
@@ -585,7 +586,7 @@ function Wa(_) {
|
|
|
585
586
|
"span",
|
|
586
587
|
{
|
|
587
588
|
"data-plan-grid-lock": !0,
|
|
588
|
-
"data-tip": `Closed through ${Ae ?? ""}${
|
|
589
|
+
"data-tip": `Closed through ${Ae ?? ""}${c != null && c.closed_rule ? ` — ${c.closed_rule}` : ""}`,
|
|
589
590
|
className: "inline-flex",
|
|
590
591
|
children: /* @__PURE__ */ t(
|
|
591
592
|
Xt,
|
|
@@ -629,9 +630,9 @@ function Wa(_) {
|
|
|
629
630
|
const l = !At.has(e.key), s = (h) => {
|
|
630
631
|
var w;
|
|
631
632
|
return e.mode === "split" ? E(e.cats.reduce((ae, Gt) => ae + B(Gt.values[h]), 0)) : B((w = e.top) == null ? void 0 : w.values[h]);
|
|
632
|
-
}, r = E(m.reduce((h, w) => h + s(w), 0)),
|
|
633
|
+
}, r = E(m.reduce((h, w) => h + s(w), 0)), u = m.some(
|
|
633
634
|
(h) => Math.abs(Se(e.key, Ke, h).value) >= 5e-3
|
|
634
|
-
), O = ((
|
|
635
|
+
), O = ((c == null ? void 0 : c.series) ?? []).filter(
|
|
635
636
|
(h) => m.some((w) => Math.abs(ve(h, e.key, w) ?? 0) >= 5e-3)
|
|
636
637
|
), H = m.some((h) => Math.abs(Se(e.key, null, h).value) >= 5e-3), A = (((S = e.top) == null ? void 0 : S.edited) || ((Q = e.top) == null ? void 0 : Q.isNew) || e.cats.some((h) => h.edited || h.isNew)) ?? !1;
|
|
637
638
|
return /* @__PURE__ */ d(
|
|
@@ -675,7 +676,7 @@ function Wa(_) {
|
|
|
675
676
|
),
|
|
676
677
|
/* @__PURE__ */ t("span", { className: "ml-auto text-[10.5px] font-medium text-slate-500 dark:text-slate-400", children: e.mode === "ghost" ? "" : Fe }),
|
|
677
678
|
U && e.mode !== "ghost" && /* @__PURE__ */ t(
|
|
678
|
-
|
|
679
|
+
_a,
|
|
679
680
|
{
|
|
680
681
|
block: e,
|
|
681
682
|
config: o,
|
|
@@ -737,7 +738,7 @@ function Wa(_) {
|
|
|
737
738
|
prov: ne(e.top, h),
|
|
738
739
|
cellKey: z(e.top, h),
|
|
739
740
|
locked: Pe(e.key, h),
|
|
740
|
-
lockedTip: w ? (
|
|
741
|
+
lockedTip: w ? (c == null ? void 0 : c.closed_locked_message) ?? "This period is closed" : void 0,
|
|
741
742
|
onCommit: (ae) => X(e.top, { [h]: ae }),
|
|
742
743
|
onMove: ft,
|
|
743
744
|
onPaste: xt
|
|
@@ -758,14 +759,14 @@ function Wa(_) {
|
|
|
758
759
|
]
|
|
759
760
|
}
|
|
760
761
|
),
|
|
761
|
-
|
|
762
|
+
c && /* @__PURE__ */ t(
|
|
762
763
|
at,
|
|
763
764
|
{
|
|
764
765
|
label: ke,
|
|
765
766
|
blockKey: e.key,
|
|
766
767
|
cat: null,
|
|
767
768
|
cols: m,
|
|
768
|
-
compare:
|
|
769
|
+
compare: c,
|
|
769
770
|
planOf: s,
|
|
770
771
|
actualFor: Se,
|
|
771
772
|
isClosed: J,
|
|
@@ -833,7 +834,7 @@ function Wa(_) {
|
|
|
833
834
|
}
|
|
834
835
|
)
|
|
835
836
|
] }, h.key)),
|
|
836
|
-
e.mode === "split" && l && e.cats.map((h) => /* @__PURE__ */ d(
|
|
837
|
+
e.mode === "split" && l && e.cats.map((h) => /* @__PURE__ */ d($a, { children: [
|
|
837
838
|
/* @__PURE__ */ d(
|
|
838
839
|
"tr",
|
|
839
840
|
{
|
|
@@ -854,7 +855,7 @@ function Wa(_) {
|
|
|
854
855
|
prov: ne(h, w),
|
|
855
856
|
cellKey: z(h, w),
|
|
856
857
|
locked: Pe(e.key, w),
|
|
857
|
-
lockedTip: J(e.key, w) ? (
|
|
858
|
+
lockedTip: J(e.key, w) ? (c == null ? void 0 : c.closed_locked_message) ?? "This period is closed" : void 0,
|
|
858
859
|
onCommit: (ae) => X(h, { [w]: ae }),
|
|
859
860
|
onMove: ft,
|
|
860
861
|
onPaste: xt
|
|
@@ -874,14 +875,14 @@ function Wa(_) {
|
|
|
874
875
|
]
|
|
875
876
|
}
|
|
876
877
|
),
|
|
877
|
-
|
|
878
|
+
c && H && /* @__PURE__ */ t(
|
|
878
879
|
at,
|
|
879
880
|
{
|
|
880
881
|
label: ke,
|
|
881
882
|
blockKey: e.key,
|
|
882
883
|
cat: h.cat,
|
|
883
884
|
cols: m,
|
|
884
|
-
compare:
|
|
885
|
+
compare: c,
|
|
885
886
|
planOf: (w) => B(h.values[w]),
|
|
886
887
|
actualFor: Se,
|
|
887
888
|
isClosed: J,
|
|
@@ -893,7 +894,7 @@ function Wa(_) {
|
|
|
893
894
|
}
|
|
894
895
|
)
|
|
895
896
|
] }, h.uid)),
|
|
896
|
-
e.mode === "split" && l &&
|
|
897
|
+
e.mode === "split" && l && c && u && /* @__PURE__ */ t(
|
|
897
898
|
at,
|
|
898
899
|
{
|
|
899
900
|
label: `${we(Ke)} · ${ke.toLowerCase()}`,
|
|
@@ -901,7 +902,7 @@ function Wa(_) {
|
|
|
901
902
|
blockKey: e.key,
|
|
902
903
|
cat: Ke,
|
|
903
904
|
cols: m,
|
|
904
|
-
compare:
|
|
905
|
+
compare: c,
|
|
905
906
|
planOf: () => 0,
|
|
906
907
|
actualFor: Se,
|
|
907
908
|
isClosed: J,
|
|
@@ -943,7 +944,7 @@ function Wa(_) {
|
|
|
943
944
|
}
|
|
944
945
|
)
|
|
945
946
|
] }),
|
|
946
|
-
|
|
947
|
+
c && /* @__PURE__ */ d("tr", { children: [
|
|
947
948
|
/* @__PURE__ */ t("td", { className: I(xe, "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: ke }) }),
|
|
948
949
|
m.map((e) => /* @__PURE__ */ t(
|
|
949
950
|
"td",
|
|
@@ -981,7 +982,7 @@ function Wa(_) {
|
|
|
981
982
|
),
|
|
982
983
|
U && /* @__PURE__ */ d("div", { className: "mt-2 flex items-center gap-2", children: [
|
|
983
984
|
/* @__PURE__ */ t(
|
|
984
|
-
|
|
985
|
+
La,
|
|
985
986
|
{
|
|
986
987
|
config: o,
|
|
987
988
|
client: C,
|
|
@@ -990,11 +991,11 @@ function Wa(_) {
|
|
|
990
991
|
label: `Add ${tt(o.key_field).toLowerCase()}`
|
|
991
992
|
}
|
|
992
993
|
),
|
|
993
|
-
(
|
|
994
|
+
(c == null ? void 0 : c.closed_locked) && !g && Ae && /* @__PURE__ */ t("span", { className: "text-[11.5px] text-slate-500 dark:text-slate-400", children: `Periods through ${Ae} are closed — open a highlighted ${ke.toLowerCase()} figure to reconcile one.` })
|
|
994
995
|
] }),
|
|
995
996
|
Ze,
|
|
996
997
|
V && Ze == null && /* @__PURE__ */ t(
|
|
997
|
-
|
|
998
|
+
va,
|
|
998
999
|
{
|
|
999
1000
|
open: !0,
|
|
1000
1001
|
onOpenChange: (e) => {
|
|
@@ -1007,7 +1008,7 @@ function Wa(_) {
|
|
|
1007
1008
|
displayCols: kt.filter(
|
|
1008
1009
|
(e) => m.includes(e.field) || e.field === o.category_field
|
|
1009
1010
|
),
|
|
1010
|
-
parentField:
|
|
1011
|
+
parentField: p,
|
|
1011
1012
|
m2oRelMap: /* @__PURE__ */ new Map(),
|
|
1012
1013
|
relations: [],
|
|
1013
1014
|
collection: n,
|
|
@@ -1023,14 +1024,14 @@ function Wa(_) {
|
|
|
1023
1024
|
function tt(_) {
|
|
1024
1025
|
return _.replace(/_/g, " ").replace(/^\w/, (n) => n.toUpperCase());
|
|
1025
1026
|
}
|
|
1026
|
-
function
|
|
1027
|
+
function $a(_) {
|
|
1027
1028
|
return /* @__PURE__ */ t(Zt, { children: _.children });
|
|
1028
1029
|
}
|
|
1029
1030
|
function se(_) {
|
|
1030
1031
|
return Math.abs(_.n) < 5e-3 ? /* @__PURE__ */ t("span", { className: "text-slate-400 dark:text-slate-500", children: "—" }) : /* @__PURE__ */ t("span", { children: D(_.n) });
|
|
1031
1032
|
}
|
|
1032
1033
|
function Mt(_) {
|
|
1033
|
-
const { row: n, col:
|
|
1034
|
+
const { row: n, col: p, closed: y, locked: o, lockedTip: $, prov: M, cellKey: K, onCommit: F, onMove: L, onPaste: f } = _, b = B(n.values[p]), C = M ? `${Re(p)} · changed ${ca(M.at)} by ${M.who}${M.reason ? `
|
|
1034
1035
|
Reason: “${M.reason}”` : ""}` : void 0, k = M != null && M.reason ? /* @__PURE__ */ t(
|
|
1035
1036
|
"span",
|
|
1036
1037
|
{
|
|
@@ -1038,18 +1039,18 @@ Reason: “${M.reason}”` : ""}` : void 0, k = M != null && M.reason ? /* @__PU
|
|
|
1038
1039
|
"data-cell-reason": !0,
|
|
1039
1040
|
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"
|
|
1040
1041
|
}
|
|
1041
|
-
) : null, [
|
|
1042
|
+
) : null, [x, j] = W(null), T = Me(!1);
|
|
1042
1043
|
if (o)
|
|
1043
1044
|
return /* @__PURE__ */ d(
|
|
1044
1045
|
"td",
|
|
1045
1046
|
{
|
|
1046
|
-
"data-plan-locked":
|
|
1047
|
+
"data-plan-locked": y ? "closed" : "readonly",
|
|
1047
1048
|
"data-tip": [$, C].filter(Boolean).join(`
|
|
1048
1049
|
`) || void 0,
|
|
1049
1050
|
"data-grid-cell": K,
|
|
1050
1051
|
className: I(
|
|
1051
1052
|
"relative px-2.5 py-1 text-right text-slate-700 dark:text-slate-200",
|
|
1052
|
-
|
|
1053
|
+
y && Ne
|
|
1053
1054
|
),
|
|
1054
1055
|
children: [
|
|
1055
1056
|
k,
|
|
@@ -1058,22 +1059,22 @@ Reason: “${M.reason}”` : ""}` : void 0, k = M != null && M.reason ? /* @__PU
|
|
|
1058
1059
|
}
|
|
1059
1060
|
);
|
|
1060
1061
|
const v = () => {
|
|
1061
|
-
if (
|
|
1062
|
-
const
|
|
1062
|
+
if (x == null) return;
|
|
1063
|
+
const g = Tt(x);
|
|
1063
1064
|
if (j(null), T.current) {
|
|
1064
1065
|
T.current = !1;
|
|
1065
1066
|
return;
|
|
1066
1067
|
}
|
|
1067
|
-
if (
|
|
1068
|
+
if (g == null || g < 0) {
|
|
1068
1069
|
de.error("Enter an amount of zero or more");
|
|
1069
1070
|
return;
|
|
1070
1071
|
}
|
|
1071
|
-
Math.abs(
|
|
1072
|
+
Math.abs(g - b) < 5e-3 || F(g);
|
|
1072
1073
|
};
|
|
1073
1074
|
return /* @__PURE__ */ d(
|
|
1074
1075
|
"td",
|
|
1075
1076
|
{
|
|
1076
|
-
className: I("relative p-0",
|
|
1077
|
+
className: I("relative p-0", y && Ne),
|
|
1077
1078
|
"data-grid-cell": K,
|
|
1078
1079
|
"data-tip": C,
|
|
1079
1080
|
children: [
|
|
@@ -1081,23 +1082,23 @@ Reason: “${M.reason}”` : ""}` : void 0, k = M != null && M.reason ? /* @__PU
|
|
|
1081
1082
|
/* @__PURE__ */ t(
|
|
1082
1083
|
"input",
|
|
1083
1084
|
{
|
|
1084
|
-
"data-pg-cell": `${n.uid}:${
|
|
1085
|
-
"aria-label": `${Re(
|
|
1085
|
+
"data-pg-cell": `${n.uid}:${p}`,
|
|
1086
|
+
"aria-label": `${Re(p)} ${n.key}`,
|
|
1086
1087
|
inputMode: "decimal",
|
|
1087
|
-
value:
|
|
1088
|
+
value: x ?? (b === 0 ? "" : D(b)),
|
|
1088
1089
|
placeholder: "—",
|
|
1089
|
-
onFocus: (
|
|
1090
|
-
j(b === 0 ? "" : String(b)), requestAnimationFrame(() =>
|
|
1090
|
+
onFocus: (g) => {
|
|
1091
|
+
j(b === 0 ? "" : String(b)), requestAnimationFrame(() => g.target.select());
|
|
1091
1092
|
},
|
|
1092
|
-
onChange: (
|
|
1093
|
+
onChange: (g) => j(g.target.value),
|
|
1093
1094
|
onBlur: v,
|
|
1094
|
-
onPaste: (
|
|
1095
|
-
const i =
|
|
1096
|
-
/[\t\n]/.test(i.trim()) && (
|
|
1095
|
+
onPaste: (g) => {
|
|
1096
|
+
const i = g.clipboardData.getData("text");
|
|
1097
|
+
/[\t\n]/.test(i.trim()) && (g.preventDefault(), T.current = !0, g.target.blur(), f(n, p, i));
|
|
1097
1098
|
},
|
|
1098
|
-
onKeyDown: (
|
|
1099
|
-
const i =
|
|
1100
|
-
|
|
1099
|
+
onKeyDown: (g) => {
|
|
1100
|
+
const i = g.currentTarget, U = i.selectionStart === 0 && i.selectionEnd === 0, m = i.selectionStart === i.value.length && i.selectionEnd === i.value.length;
|
|
1101
|
+
g.key === "Enter" || g.key === "ArrowDown" ? (g.preventDefault(), v(), L(n.uid, p, 1, 0)) : g.key === "ArrowUp" ? (g.preventDefault(), v(), L(n.uid, p, -1, 0)) : g.key === "ArrowLeft" && U ? (g.preventDefault(), v(), L(n.uid, p, 0, -1)) : g.key === "ArrowRight" && m ? (g.preventDefault(), v(), L(n.uid, p, 0, 1)) : g.key === "Escape" && (T.current = !0, i.blur());
|
|
1101
1102
|
},
|
|
1102
1103
|
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))]"
|
|
1103
1104
|
}
|
|
@@ -1109,8 +1110,8 @@ Reason: “${M.reason}”` : ""}` : void 0, k = M != null && M.reason ? /* @__PU
|
|
|
1109
1110
|
function at(_) {
|
|
1110
1111
|
const {
|
|
1111
1112
|
label: n,
|
|
1112
|
-
tip:
|
|
1113
|
-
blockKey:
|
|
1113
|
+
tip: p,
|
|
1114
|
+
blockKey: y,
|
|
1114
1115
|
cat: o,
|
|
1115
1116
|
cols: $,
|
|
1116
1117
|
compare: M,
|
|
@@ -1121,41 +1122,41 @@ function at(_) {
|
|
|
1121
1122
|
canReconcile: b,
|
|
1122
1123
|
onReconcile: C,
|
|
1123
1124
|
carryFor: k,
|
|
1124
|
-
plain:
|
|
1125
|
-
} = _, j = E($.reduce((T, v) => T + F(
|
|
1125
|
+
plain: x
|
|
1126
|
+
} = _, j = E($.reduce((T, v) => T + F(y, o, v).value, 0));
|
|
1126
1127
|
return /* @__PURE__ */ d("tr", { "data-plan-actual": o ?? "all", children: [
|
|
1127
1128
|
/* @__PURE__ */ t("td", { className: I(xe, "px-2 pb-1 pt-0"), children: /* @__PURE__ */ t(
|
|
1128
1129
|
"span",
|
|
1129
1130
|
{
|
|
1130
|
-
"data-tip":
|
|
1131
|
+
"data-tip": p,
|
|
1131
1132
|
className: "block text-right text-[10.5px] font-medium text-slate-500 dark:text-slate-400",
|
|
1132
1133
|
children: n
|
|
1133
1134
|
}
|
|
1134
1135
|
) }),
|
|
1135
1136
|
$.map((T) => {
|
|
1136
|
-
const v = L(
|
|
1137
|
+
const v = L(y, T), g = F(y, o, T), i = K(T), U = !x && v && Math.abs(g.value - i) >= 5e-3, m = !x && !v && g.value > i + 5e-3;
|
|
1137
1138
|
return /* @__PURE__ */ t(
|
|
1138
1139
|
"td",
|
|
1139
1140
|
{
|
|
1140
1141
|
"data-compare-cell": T,
|
|
1141
1142
|
className: I("px-2.5 pb-1 pt-0 text-right text-[11.5px]", v && Ne),
|
|
1142
|
-
children: Math.abs(
|
|
1143
|
-
|
|
1143
|
+
children: Math.abs(g.value) < 5e-3 && !U ? /* @__PURE__ */ t("span", { className: "text-slate-400 dark:text-slate-500", children: "—" }) : /* @__PURE__ */ t(
|
|
1144
|
+
Ca,
|
|
1144
1145
|
{
|
|
1145
|
-
title: `${Re(T)} ${
|
|
1146
|
+
title: `${Re(T)} ${y}`,
|
|
1146
1147
|
compare: M,
|
|
1147
1148
|
actualName: n,
|
|
1148
|
-
actual:
|
|
1149
|
+
actual: g.value,
|
|
1149
1150
|
planned: i,
|
|
1150
1151
|
closed: v,
|
|
1151
|
-
plain: !!
|
|
1152
|
-
details:
|
|
1152
|
+
plain: !!x,
|
|
1153
|
+
details: g.details,
|
|
1153
1154
|
tone: U ? "warn" : m ? "danger" : "neutral",
|
|
1154
1155
|
reconcile: U && b && f ? {
|
|
1155
1156
|
row: f,
|
|
1156
1157
|
column: T,
|
|
1157
|
-
openColumns: $.filter((R) => !L(
|
|
1158
|
-
carry: (k == null ? void 0 : k(
|
|
1158
|
+
openColumns: $.filter((R) => !L(y, R)),
|
|
1159
|
+
carry: (k == null ? void 0 : k(y, o)) ?? null,
|
|
1159
1160
|
onApply: (R, q, oe) => C(f, R, q, oe)
|
|
1160
1161
|
} : null
|
|
1161
1162
|
}
|
|
@@ -1181,12 +1182,12 @@ const Rt = {
|
|
|
1181
1182
|
danger: "text-red-700 dark:text-red-300 font-medium",
|
|
1182
1183
|
neutral: "text-slate-600 dark:text-slate-300"
|
|
1183
1184
|
};
|
|
1184
|
-
function
|
|
1185
|
+
function Ca(_) {
|
|
1185
1186
|
var z, ne;
|
|
1186
|
-
const { title: n, compare:
|
|
1187
|
+
const { title: n, compare: p, actualName: y, actual: o, planned: $, closed: M, plain: K, details: F, tone: L, reconcile: f } = _, [b, C] = W(!1), [k, x] = W("next"), [j, T] = W(""), v = Et(p), g = E($ - o), i = f && f.openColumns.length === 0 && f.carry && !f.carry.blocked ? f.carry : null, U = f && f.openColumns.length === 0 ? ((z = f.carry) == null ? void 0 : z.blocked) ?? null : null, m = i ? ((ne = i.row) == null ? void 0 : ne.values) ?? {} : (f == null ? void 0 : f.row.values) ?? {}, R = i ? i.openColumns : (f == null ? void 0 : f.openColumns) ?? [], q = G(
|
|
1187
1188
|
() => {
|
|
1188
1189
|
var N;
|
|
1189
|
-
return f ?
|
|
1190
|
+
return f ? wa({
|
|
1190
1191
|
row: f.row.values,
|
|
1191
1192
|
column: f.column,
|
|
1192
1193
|
actual: o,
|
|
@@ -1197,11 +1198,11 @@ function $a(_) {
|
|
|
1197
1198
|
},
|
|
1198
1199
|
[f, i, o, k]
|
|
1199
1200
|
), oe = q ? q.targetPatch ?? q.patch : {}, be = R.some((N) => B(m[N]) > 5e-3), P = G(() => {
|
|
1200
|
-
const N = `Reconciled ${n} to ${
|
|
1201
|
+
const N = `Reconciled ${n} to ${y.toLowerCase()} (${D(o)})`;
|
|
1201
1202
|
if (!q || Math.abs(q.moved) < 5e-3) return N;
|
|
1202
1203
|
const pe = `${q.targets.length === 1 ? Re(q.targets[0]) : `${q.targets.length} open periods`}${i ? ` ${i.key}` : ""}`;
|
|
1203
1204
|
return q.moved > 0 ? `${N} — moved ${D(q.moved)} to ${pe}` : `${N} — took ${D(-q.moved)} from ${pe}`;
|
|
1204
|
-
}, [n,
|
|
1205
|
+
}, [n, y, o, q, i]);
|
|
1205
1206
|
ye(() => {
|
|
1206
1207
|
b && T(P);
|
|
1207
1208
|
}, [b, P]);
|
|
@@ -1247,7 +1248,7 @@ function $a(_) {
|
|
|
1247
1248
|
/* @__PURE__ */ t("dd", { className: "font-medium text-slate-800 dark:text-slate-100", children: D($) })
|
|
1248
1249
|
] }),
|
|
1249
1250
|
/* @__PURE__ */ d("div", { children: [
|
|
1250
|
-
/* @__PURE__ */ t("dt", { className: "text-[10.5px] text-slate-500 dark:text-slate-400", children:
|
|
1251
|
+
/* @__PURE__ */ t("dt", { className: "text-[10.5px] text-slate-500 dark:text-slate-400", children: y }),
|
|
1251
1252
|
/* @__PURE__ */ t("dd", { className: "font-medium text-slate-800 dark:text-slate-100", children: D(o) })
|
|
1252
1253
|
] }),
|
|
1253
1254
|
!K && /* @__PURE__ */ d("div", { children: [
|
|
@@ -1257,9 +1258,9 @@ function $a(_) {
|
|
|
1257
1258
|
{
|
|
1258
1259
|
className: I(
|
|
1259
1260
|
"font-medium",
|
|
1260
|
-
Math.abs(
|
|
1261
|
+
Math.abs(g) < 5e-3 ? "text-slate-800 dark:text-slate-100" : Rt[L === "neutral" ? "neutral" : L]
|
|
1261
1262
|
),
|
|
1262
|
-
children: D(
|
|
1263
|
+
children: D(g)
|
|
1263
1264
|
}
|
|
1264
1265
|
)
|
|
1265
1266
|
] })
|
|
@@ -1272,14 +1273,14 @@ function $a(_) {
|
|
|
1272
1273
|
] }),
|
|
1273
1274
|
/* @__PURE__ */ t("span", { className: "tabular-nums text-slate-800 dark:text-slate-100", children: D(N.amount) })
|
|
1274
1275
|
] }, String(N.id))) }),
|
|
1275
|
-
F.length === 0 && /* @__PURE__ */ t("p", { className: "px-3 py-2 text-slate-500 dark:text-slate-400", children: `No ${
|
|
1276
|
+
F.length === 0 && /* @__PURE__ */ t("p", { className: "px-3 py-2 text-slate-500 dark:text-slate-400", children: `No ${ga(p, 2)} behind this figure.` }),
|
|
1276
1277
|
f && q && /* @__PURE__ */ d(
|
|
1277
1278
|
"div",
|
|
1278
1279
|
{
|
|
1279
1280
|
className: "border-t border-slate-200 px-3 py-2 dark:border-border",
|
|
1280
1281
|
"data-plan-reconcile": !0,
|
|
1281
1282
|
children: [
|
|
1282
|
-
/* @__PURE__ */ t("p", { className: "font-medium text-slate-900 dark:text-slate-100", children: `Set the ${v.toLowerCase()} to ${D(o)} and put the ${D(Math.abs(
|
|
1283
|
+
/* @__PURE__ */ t("p", { className: "font-medium text-slate-900 dark:text-slate-100", children: `Set the ${v.toLowerCase()} to ${D(o)} and put the ${D(Math.abs(g))} ${g > 0 ? "left over" : "shortfall"}…` }),
|
|
1283
1284
|
/* @__PURE__ */ t(
|
|
1284
1285
|
"div",
|
|
1285
1286
|
{
|
|
@@ -1302,7 +1303,7 @@ function $a(_) {
|
|
|
1302
1303
|
"data-plan-reconcile-mode": N.key,
|
|
1303
1304
|
disabled: N.disabled,
|
|
1304
1305
|
checked: k === N.key,
|
|
1305
|
-
onChange: () =>
|
|
1306
|
+
onChange: () => x(N.key),
|
|
1306
1307
|
className: "accent-[rgb(var(--nvr-cyan-rgb))]"
|
|
1307
1308
|
}
|
|
1308
1309
|
),
|
|
@@ -1374,11 +1375,11 @@ function $a(_) {
|
|
|
1374
1375
|
] })
|
|
1375
1376
|
] });
|
|
1376
1377
|
}
|
|
1377
|
-
function
|
|
1378
|
+
function _a(_) {
|
|
1378
1379
|
const {
|
|
1379
1380
|
block: n,
|
|
1380
|
-
config:
|
|
1381
|
-
canSplit:
|
|
1381
|
+
config: p,
|
|
1382
|
+
canSplit: y,
|
|
1382
1383
|
splitUnavailable: o,
|
|
1383
1384
|
splitBase: $,
|
|
1384
1385
|
client: M,
|
|
@@ -1389,10 +1390,10 @@ function Ca(_) {
|
|
|
1389
1390
|
onSpread: b,
|
|
1390
1391
|
onRemove: C,
|
|
1391
1392
|
onDone: k,
|
|
1392
|
-
rc:
|
|
1393
|
-
} = _, [j, T] = W(!1), [v,
|
|
1393
|
+
rc: x
|
|
1394
|
+
} = _, [j, T] = W(!1), [v, g] = W("menu");
|
|
1394
1395
|
ye(() => {
|
|
1395
|
-
j &&
|
|
1396
|
+
j && g("menu");
|
|
1396
1397
|
}, [j]);
|
|
1397
1398
|
const i = [...n.top ? [n.top] : [], ...n.cats], U = i.some((R) => R.edited || R.isNew), m = "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";
|
|
1398
1399
|
return /* @__PURE__ */ d(rt, { open: j, onOpenChange: T, children: [
|
|
@@ -1414,24 +1415,24 @@ function Ca(_) {
|
|
|
1414
1415
|
className: I("p-1.5", v === "split" ? "w-[440px]" : "w-[300px]"),
|
|
1415
1416
|
children: [
|
|
1416
1417
|
v === "menu" && /* @__PURE__ */ d("div", { children: [
|
|
1417
|
-
n.mode === "top" &&
|
|
1418
|
+
n.mode === "top" && y && /* @__PURE__ */ d(
|
|
1418
1419
|
"button",
|
|
1419
1420
|
{
|
|
1420
1421
|
type: "button",
|
|
1421
1422
|
"data-plan-split": n.key,
|
|
1422
1423
|
disabled: U,
|
|
1423
|
-
onClick: () =>
|
|
1424
|
+
onClick: () => g("split"),
|
|
1424
1425
|
className: m,
|
|
1425
1426
|
children: [
|
|
1426
1427
|
/* @__PURE__ */ t($t, { className: "h-3.5 w-3.5" }),
|
|
1427
|
-
|
|
1428
|
+
p.split_label ?? "Plan by category"
|
|
1428
1429
|
]
|
|
1429
1430
|
}
|
|
1430
1431
|
),
|
|
1431
|
-
n.mode === "top" && !
|
|
1432
|
+
n.mode === "top" && !y && o && /* @__PURE__ */ d("div", { "data-plan-split-unavailable": !0, className: "px-2 py-1.5", children: [
|
|
1432
1433
|
/* @__PURE__ */ d("p", { className: "flex items-center gap-2 text-[12.5px] text-slate-400 dark:text-slate-500", children: [
|
|
1433
1434
|
/* @__PURE__ */ t($t, { className: "h-3.5 w-3.5" }),
|
|
1434
|
-
|
|
1435
|
+
p.split_label ?? "Plan by category"
|
|
1435
1436
|
] }),
|
|
1436
1437
|
/* @__PURE__ */ t("p", { className: "mt-0.5 pl-[22px] text-[11px] text-slate-500 dark:text-slate-400", children: o })
|
|
1437
1438
|
] }),
|
|
@@ -1441,15 +1442,15 @@ function Ca(_) {
|
|
|
1441
1442
|
type: "button",
|
|
1442
1443
|
"data-plan-merge": n.key,
|
|
1443
1444
|
disabled: U,
|
|
1444
|
-
onClick: () =>
|
|
1445
|
+
onClick: () => g("merge"),
|
|
1445
1446
|
className: m,
|
|
1446
1447
|
children: [
|
|
1447
1448
|
/* @__PURE__ */ t(ta, { className: "h-3.5 w-3.5" }),
|
|
1448
|
-
|
|
1449
|
+
p.merge_label ?? "Merge back to one line"
|
|
1449
1450
|
]
|
|
1450
1451
|
}
|
|
1451
1452
|
),
|
|
1452
|
-
U && (n.mode === "split" ||
|
|
1453
|
+
U && (n.mode === "split" || y) && /* @__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." }),
|
|
1453
1454
|
b && i.map((R) => /* @__PURE__ */ d(
|
|
1454
1455
|
"button",
|
|
1455
1456
|
{
|
|
@@ -1482,9 +1483,9 @@ function Ca(_) {
|
|
|
1482
1483
|
}
|
|
1483
1484
|
),
|
|
1484
1485
|
/* @__PURE__ */ t(
|
|
1485
|
-
|
|
1486
|
+
Na,
|
|
1486
1487
|
{
|
|
1487
|
-
collection:
|
|
1488
|
+
collection: x,
|
|
1488
1489
|
rowId: R.id,
|
|
1489
1490
|
rowLabel: `${n.key}${R.cat ? ` ${F(R.cat)}` : ""}`
|
|
1490
1491
|
}
|
|
@@ -1495,7 +1496,7 @@ function Ca(_) {
|
|
|
1495
1496
|
{
|
|
1496
1497
|
type: "button",
|
|
1497
1498
|
"data-plan-remove": n.key,
|
|
1498
|
-
onClick: () =>
|
|
1499
|
+
onClick: () => g("remove"),
|
|
1499
1500
|
className: I(m, "text-red-700 dark:text-red-300"),
|
|
1500
1501
|
children: [
|
|
1501
1502
|
/* @__PURE__ */ t(la, { className: "h-3.5 w-3.5" }),
|
|
@@ -1511,7 +1512,7 @@ function Ca(_) {
|
|
|
1511
1512
|
"button",
|
|
1512
1513
|
{
|
|
1513
1514
|
type: "button",
|
|
1514
|
-
onClick: () =>
|
|
1515
|
+
onClick: () => g("menu"),
|
|
1515
1516
|
className: "rounded-md px-2.5 py-1 text-[12px] text-slate-600 hover:bg-muted dark:text-slate-300",
|
|
1516
1517
|
children: "Keep it"
|
|
1517
1518
|
}
|
|
@@ -1531,27 +1532,27 @@ function Ca(_) {
|
|
|
1531
1532
|
] })
|
|
1532
1533
|
] }),
|
|
1533
1534
|
v === "split" && $ && n.top && /* @__PURE__ */ t(
|
|
1534
|
-
|
|
1535
|
+
Sa,
|
|
1535
1536
|
{
|
|
1536
1537
|
block: n,
|
|
1537
|
-
config:
|
|
1538
|
+
config: p,
|
|
1538
1539
|
splitBase: $,
|
|
1539
1540
|
client: M,
|
|
1540
1541
|
cols: K,
|
|
1541
|
-
onCancel: () =>
|
|
1542
|
+
onCancel: () => g("menu"),
|
|
1542
1543
|
onDone: () => {
|
|
1543
1544
|
T(!1), k();
|
|
1544
1545
|
}
|
|
1545
1546
|
}
|
|
1546
1547
|
),
|
|
1547
1548
|
v === "merge" && $ && /* @__PURE__ */ t(
|
|
1548
|
-
|
|
1549
|
+
Oa,
|
|
1549
1550
|
{
|
|
1550
1551
|
block: n,
|
|
1551
|
-
config:
|
|
1552
|
+
config: p,
|
|
1552
1553
|
splitBase: $,
|
|
1553
1554
|
client: M,
|
|
1554
|
-
onCancel: () =>
|
|
1555
|
+
onCancel: () => g("menu"),
|
|
1555
1556
|
onDone: () => {
|
|
1556
1557
|
T(!1), k();
|
|
1557
1558
|
}
|
|
@@ -1563,55 +1564,53 @@ function Ca(_) {
|
|
|
1563
1564
|
] });
|
|
1564
1565
|
}
|
|
1565
1566
|
function st(_) {
|
|
1566
|
-
|
|
1567
|
-
const n = _;
|
|
1568
|
-
return ((c = n == null ? void 0 : n.response) == null ? void 0 : c.error) ?? ((x = n == null ? void 0 : n.response) == null ? void 0 : x.message) ?? (n == null ? void 0 : n.message) ?? "Something went wrong";
|
|
1567
|
+
return da(_, "Something went wrong");
|
|
1569
1568
|
}
|
|
1570
|
-
function
|
|
1569
|
+
function Sa(_) {
|
|
1571
1570
|
var oe, be;
|
|
1572
|
-
const { block: n, config:
|
|
1571
|
+
const { block: n, config: p, splitBase: y, client: o, cols: $, onCancel: M, onDone: K } = _, F = Number.isFinite(Number(n.key)) ? Number(n.key) : n.key, [L, f] = W(null), [b, C] = W(null), [k, x] = W(null), [j, T] = W(!1), [v, g] = W(""), i = JSON.stringify(L);
|
|
1573
1572
|
ye(() => {
|
|
1574
1573
|
let P = !0;
|
|
1575
1574
|
const le = window.setTimeout(
|
|
1576
1575
|
() => {
|
|
1577
1576
|
o.request(
|
|
1578
|
-
lt(`${
|
|
1579
|
-
[
|
|
1577
|
+
lt(`${y}/split`, {
|
|
1578
|
+
[p.key_field]: F,
|
|
1580
1579
|
preview: !0,
|
|
1581
1580
|
...L ? { shares: L } : {}
|
|
1582
1581
|
})
|
|
1583
1582
|
).then((z) => {
|
|
1584
|
-
P && (C(z.data),
|
|
1583
|
+
P && (C(z.data), x(null), L || f(
|
|
1585
1584
|
Object.fromEntries(
|
|
1586
1585
|
z.data.categories.map((ne) => [String(ne.id), Math.round(ne.share * 1e3) / 10])
|
|
1587
1586
|
)
|
|
1588
1587
|
));
|
|
1589
|
-
}).catch((z) => P &&
|
|
1588
|
+
}).catch((z) => P && x(st(z)));
|
|
1590
1589
|
},
|
|
1591
1590
|
L ? 250 : 0
|
|
1592
1591
|
);
|
|
1593
1592
|
return () => {
|
|
1594
1593
|
P = !1, window.clearTimeout(le);
|
|
1595
1594
|
};
|
|
1596
|
-
}, [i,
|
|
1595
|
+
}, [i, y]);
|
|
1597
1596
|
const U = (b == null ? void 0 : b.categories.map((P) => P.label).join(" / ")) ?? "", m = `Split the ${n.key} plan into ${U}`, R = async () => {
|
|
1598
1597
|
T(!0);
|
|
1599
1598
|
try {
|
|
1600
1599
|
await o.request(
|
|
1601
|
-
lt(`${
|
|
1602
|
-
[
|
|
1600
|
+
lt(`${y}/split`, {
|
|
1601
|
+
[p.key_field]: F,
|
|
1603
1602
|
shares: L ?? void 0,
|
|
1604
1603
|
reason: v.trim() || m
|
|
1605
1604
|
})
|
|
1606
1605
|
), de.success(`${n.key} is now planned by ${U}`), K();
|
|
1607
1606
|
} catch (P) {
|
|
1608
|
-
|
|
1607
|
+
x(st(P));
|
|
1609
1608
|
} finally {
|
|
1610
1609
|
T(!1);
|
|
1611
1610
|
}
|
|
1612
1611
|
}, q = (P) => E($.reduce((le, z) => le + B(P[z]), 0));
|
|
1613
1612
|
return /* @__PURE__ */ d("div", { className: "p-1.5", "data-plan-split-pane": !0, children: [
|
|
1614
|
-
/* @__PURE__ */ t("p", { className: "text-[12.5px] font-semibold text-slate-900 dark:text-slate-100", children: `${
|
|
1613
|
+
/* @__PURE__ */ t("p", { className: "text-[12.5px] font-semibold text-slate-900 dark:text-slate-100", children: `${p.split_label ?? "Plan by category"} · ${n.key}` }),
|
|
1615
1614
|
/* @__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." }),
|
|
1616
1615
|
!b && !k && /* @__PURE__ */ t(
|
|
1617
1616
|
"div",
|
|
@@ -1672,7 +1671,7 @@ function _a(_) {
|
|
|
1672
1671
|
/* @__PURE__ */ t("td", { className: "py-1 text-right text-slate-500 dark:text-slate-400", children: D(P.cap) })
|
|
1673
1672
|
] }, String(P.id))),
|
|
1674
1673
|
/* @__PURE__ */ d("tr", { className: "border-t border-slate-200 font-medium dark:border-border", children: [
|
|
1675
|
-
/* @__PURE__ */ t("td", { className: "py-1 text-slate-800 dark:text-slate-100", children:
|
|
1674
|
+
/* @__PURE__ */ t("td", { className: "py-1 text-slate-800 dark:text-slate-100", children: p.total_label ?? "Total" }),
|
|
1676
1675
|
/* @__PURE__ */ t("td", {}),
|
|
1677
1676
|
/* @__PURE__ */ t("td", { className: "py-1 text-right text-slate-800 dark:text-slate-100", children: D(q(b.original)) }),
|
|
1678
1677
|
/* @__PURE__ */ t("td", {})
|
|
@@ -1692,7 +1691,7 @@ function _a(_) {
|
|
|
1692
1691
|
"textarea",
|
|
1693
1692
|
{
|
|
1694
1693
|
value: v,
|
|
1695
|
-
onChange: (P) =>
|
|
1694
|
+
onChange: (P) => g(P.target.value),
|
|
1696
1695
|
placeholder: m,
|
|
1697
1696
|
rows: 2,
|
|
1698
1697
|
"aria-label": "Reason",
|
|
@@ -1723,10 +1722,10 @@ function _a(_) {
|
|
|
1723
1722
|
] })
|
|
1724
1723
|
] });
|
|
1725
1724
|
}
|
|
1726
|
-
function
|
|
1727
|
-
const { block: n, config:
|
|
1725
|
+
function Oa(_) {
|
|
1726
|
+
const { block: n, config: p, splitBase: y, client: o, onCancel: $, onDone: M } = _, K = Number.isFinite(Number(n.key)) ? Number(n.key) : n.key, [F, L] = W(""), [f, b] = W(!1), [C, k] = W(null), x = `Merged the ${n.key} plan back to one line`;
|
|
1728
1727
|
return /* @__PURE__ */ d("div", { className: "p-1.5", "data-plan-merge-pane": !0, children: [
|
|
1729
|
-
/* @__PURE__ */ t("p", { className: "text-[12.5px] font-semibold text-slate-900 dark:text-slate-100", children: `${
|
|
1728
|
+
/* @__PURE__ */ t("p", { className: "text-[12.5px] font-semibold text-slate-900 dark:text-slate-100", children: `${p.merge_label ?? "Merge back to one line"} · ${n.key}` }),
|
|
1730
1729
|
/* @__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." }),
|
|
1731
1730
|
C && /* @__PURE__ */ t("p", { role: "alert", className: "mt-1.5 text-[11.5px] font-medium text-red-700 dark:text-red-300", children: C }),
|
|
1732
1731
|
/* @__PURE__ */ t(
|
|
@@ -1734,7 +1733,7 @@ function Sa(_) {
|
|
|
1734
1733
|
{
|
|
1735
1734
|
value: F,
|
|
1736
1735
|
onChange: (j) => L(j.target.value),
|
|
1737
|
-
placeholder:
|
|
1736
|
+
placeholder: x,
|
|
1738
1737
|
rows: 2,
|
|
1739
1738
|
"aria-label": "Reason",
|
|
1740
1739
|
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"
|
|
@@ -1760,9 +1759,9 @@ function Sa(_) {
|
|
|
1760
1759
|
b(!0);
|
|
1761
1760
|
try {
|
|
1762
1761
|
await o.request(
|
|
1763
|
-
lt(`${
|
|
1764
|
-
[
|
|
1765
|
-
reason: F.trim() ||
|
|
1762
|
+
lt(`${y}/merge`, {
|
|
1763
|
+
[p.key_field]: K,
|
|
1764
|
+
reason: F.trim() || x
|
|
1766
1765
|
})
|
|
1767
1766
|
), de.success(`${n.key} is one line again`), M();
|
|
1768
1767
|
} catch (j) {
|
|
@@ -1778,15 +1777,15 @@ function Sa(_) {
|
|
|
1778
1777
|
] })
|
|
1779
1778
|
] });
|
|
1780
1779
|
}
|
|
1781
|
-
function
|
|
1782
|
-
const { config: n, client:
|
|
1780
|
+
function La(_) {
|
|
1781
|
+
const { config: n, client: p, used: y, onAdd: o, label: $ } = _, [M, K] = W(!1), [F, L] = W(""), { data: f = [] } = ce({
|
|
1783
1782
|
queryKey: ["plan-grid-keys", n.key_collection],
|
|
1784
|
-
queryFn: () =>
|
|
1783
|
+
queryFn: () => p.request(
|
|
1785
1784
|
ue(`/items/${n.key_collection}`, { fields: "id", sort: "-id", limit: 200 })
|
|
1786
1785
|
).then((C) => (C.data ?? []).map((k) => k.id)),
|
|
1787
1786
|
enabled: M && !!n.key_collection,
|
|
1788
1787
|
staleTime: 10 * 6e4
|
|
1789
|
-
}), b = f.filter((C) => !
|
|
1788
|
+
}), b = f.filter((C) => !y.has(String(C)));
|
|
1790
1789
|
return /* @__PURE__ */ d(rt, { open: M, onOpenChange: K, children: [
|
|
1791
1790
|
/* @__PURE__ */ t(ot, { asChild: !0, children: /* @__PURE__ */ d(
|
|
1792
1791
|
"button",
|
|
@@ -1820,7 +1819,7 @@ function Oa(_) {
|
|
|
1820
1819
|
onSubmit: (C) => {
|
|
1821
1820
|
C.preventDefault();
|
|
1822
1821
|
const k = F.trim();
|
|
1823
|
-
!k ||
|
|
1822
|
+
!k || y.has(k) || (o(Number.isFinite(Number(k)) ? Number(k) : k), L(""), K(!1));
|
|
1824
1823
|
},
|
|
1825
1824
|
children: /* @__PURE__ */ t(
|
|
1826
1825
|
"input",
|
|
@@ -1836,8 +1835,8 @@ function Oa(_) {
|
|
|
1836
1835
|
] });
|
|
1837
1836
|
}
|
|
1838
1837
|
export {
|
|
1839
|
-
|
|
1838
|
+
Qa as PlanGridField,
|
|
1840
1839
|
D as fmtFigure,
|
|
1841
1840
|
Tt as parseFigure,
|
|
1842
|
-
|
|
1841
|
+
wa as reconcilePatch
|
|
1843
1842
|
};
|