@nivaro/react 0.3.127 → 0.3.129
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/slots/CommentsSlot.js +124 -95
- package/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +29 -3
- package/dist/index.js +150 -147
- package/dist/shared/components/CollectionBrowserView.js +3259 -3211
- package/dist/shared/components/DataTable.js +406 -401
- package/dist/shared/components/ItemEditForm.js +4485 -4409
- package/dist/shared/components/MatrixEditor.js +548 -490
- package/dist/shared/components/MyWorkView.js +284 -274
- package/dist/shared/components/NotificationBell.js +264 -218
- package/dist/shared/components/RecordGridEditor.js +582 -472
- package/dist/shared/components/ai/AiMarkdown.js +215 -196
- package/dist/shared/components/chat/chat-core.js +331 -346
- package/dist/shared/components/chat/chat-typing.js +25 -0
- package/dist/shared/components/command-center/CommandCenterView.js +1 -1
- package/dist/shared/components/command-center/PeekPanel.js +8 -1
- package/dist/shared/components/command-center/api.js +17 -9
- package/dist/shared/components/command-center/panels/AttentionPanel.js +4 -1
- package/dist/shared/components/command-center/panels/PartnersPanel.js +2 -1
- package/dist/shared/components/item-edit/GroupSection.js +1 -1
- package/dist/shared/components/item-edit/HeaderTools.js +216 -210
- package/dist/shared/components/item-edit/InlineTableField.js +432 -429
- package/dist/shared/components/item-edit/RecordLiveSync.js +115 -108
- package/dist/shared/components/item-edit/RecordViewersChip.js +17 -16
- package/dist/shared/components/item-edit/RowComments.js +33 -30
- package/dist/shared/components/item-edit/cascade-clear-notice.js +30 -28
- package/dist/shared/components/item-edit/live-related.js +29 -16
- package/dist/shared/components/item-edit/record-opened-live.js +86 -0
- package/dist/shared/components/panels/CommentPanel.js +345 -327
- package/dist/shared/components/panels/OwnerOpenedLine.js +24 -23
- package/dist/shared/components/panels/RecordIntegrityBanner.js +1 -1
- package/dist/shared/components/pipeline/TeamSuggestions.js +1 -1
- package/dist/shared/components/queue/QueueItemSheet.js +171 -130
- package/dist/shared/components/record-grid-guard.js +85 -0
- package/dist/shared/components/support/TicketDetailSheet.js +213 -174
- package/dist/shared/components/trackers/MirroredText.js +40 -0
- package/dist/shared/components/trackers/SourceTracker.js +168 -0
- package/dist/shared/components/trackers/TrackerChip.js +71 -0
- package/dist/shared/components/trackers/TrackerLinkPanel.js +1039 -0
- package/dist/shared/components/trackers/TrackerPickers.js +245 -0
- package/dist/shared/components/trackers/tracker-model.js +126 -0
- package/dist/shared/components/trackers/use-tracker-link.js +159 -0
- package/dist/shared/lib/at-risk-fields.js +14 -0
- package/dist/shared/lib/live-queries.js +9 -8
- package/dist/shared/lib/live-screen.js +77 -76
- package/dist/shared/lib/presence-hooks.js +190 -127
- package/dist/shared/lib/user-sync.js +78 -65
- package/dist/shared/lib/waiting-count.js +40 -29
- package/package.json +1 -1
|
@@ -1,557 +1,593 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useQueryClient as
|
|
3
|
-
import { Loader2 as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { useNivaroClient as
|
|
6
|
-
import { get as
|
|
7
|
-
import { evaluateNumeric as
|
|
8
|
-
import { gridPageKey as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { jsxs as x, jsx as d, Fragment as Me } from "react/jsx-runtime";
|
|
2
|
+
import { useQueryClient as gt, useQuery as oe } from "@tanstack/react-query";
|
|
3
|
+
import { Loader2 as ut, ChevronRight as mt } from "lucide-react";
|
|
4
|
+
import { useState as Q, useRef as ie, useEffect as xe, useMemo as j } from "react";
|
|
5
|
+
import { useNivaroClient as wt } from "../context.js";
|
|
6
|
+
import { get as ce, post as pt } from "../lib/commands.js";
|
|
7
|
+
import { evaluateNumeric as $t } from "../lib/expression.js";
|
|
8
|
+
import { gridPageKey as St, useGridPresence as jt, gridPresenceCell as Ct } from "../lib/grid-presence.js";
|
|
9
|
+
import { liveQueryMeta as Ot } from "../lib/live-queries.js";
|
|
10
|
+
import { userErrorMessage as qt } from "../lib/safe-error.js";
|
|
11
|
+
import { cn as O } from "../lib/utils.js";
|
|
12
|
+
import { GridPresenceLine as Lt } from "./GridPresenceLine.js";
|
|
13
|
+
import { RelationCombobox as Mt } from "./item-edit/RelationCombobox.js";
|
|
14
|
+
import { useRecordLabels as Rt } from "./item-edit/useRecordLabels.js";
|
|
15
|
+
import { colorPair as Ft } from "./QueryTable.js";
|
|
16
|
+
import { GridRowGuard as Et, settleEditsAfterSave as Gt } from "./record-grid-guard.js";
|
|
17
|
+
const V = "__uncat__", B = "__bucket__";
|
|
18
|
+
function qe(t, _) {
|
|
17
19
|
if (!t) return;
|
|
18
|
-
const
|
|
19
|
-
Object.entries(
|
|
20
|
-
) :
|
|
21
|
-
return
|
|
20
|
+
const k = (p) => typeof p == "string" && p.startsWith("$scope.") ? _[p.slice(7)] : Array.isArray(p) ? p.map(k) : p && typeof p == "object" ? Object.fromEntries(
|
|
21
|
+
Object.entries(p).map(([w, b]) => [w, k(b)])
|
|
22
|
+
) : p;
|
|
23
|
+
return k(t);
|
|
22
24
|
}
|
|
23
|
-
function
|
|
24
|
-
return t === void 0 ? !0 : Array.isArray(t) ? t.some(
|
|
25
|
+
function Re(t) {
|
|
26
|
+
return t === void 0 ? !0 : Array.isArray(t) ? t.some(Re) : t && typeof t == "object" ? Object.values(t).some(Re) : !1;
|
|
25
27
|
}
|
|
26
|
-
function
|
|
28
|
+
function de(t, _) {
|
|
27
29
|
if (t && typeof t == "object") {
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
return t[
|
|
30
|
+
const w = _.replace(/\[\d+\]/g, "");
|
|
31
|
+
if (w in t)
|
|
32
|
+
return t[w] ?? null;
|
|
31
33
|
}
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
return
|
|
34
|
+
const k = _.split(".").flatMap((w) => {
|
|
35
|
+
const b = /^(\w+)\[(\d+)\]$/.exec(w);
|
|
36
|
+
return b ? [b[1], Number(b[2])] : [w];
|
|
35
37
|
});
|
|
36
|
-
let
|
|
37
|
-
for (const
|
|
38
|
-
if (
|
|
39
|
-
|
|
38
|
+
let p = t;
|
|
39
|
+
for (const w of k) {
|
|
40
|
+
if (p == null || typeof p != "object") return null;
|
|
41
|
+
p = p[w];
|
|
40
42
|
}
|
|
41
|
-
return
|
|
43
|
+
return p ?? null;
|
|
42
44
|
}
|
|
43
|
-
function
|
|
44
|
-
return t.replace(/\{\{\s*([\w.[\]]+)\s*\}\}/g, (
|
|
45
|
-
const
|
|
46
|
-
return
|
|
45
|
+
function Le(t, _) {
|
|
46
|
+
return t.replace(/\{\{\s*([\w.[\]]+)\s*\}\}/g, (k, p) => {
|
|
47
|
+
const w = de(_, p);
|
|
48
|
+
return w == null ? "" : String(w);
|
|
47
49
|
});
|
|
48
50
|
}
|
|
49
|
-
function
|
|
50
|
-
const
|
|
51
|
-
return t == null || t === "" || !Number.isFinite(
|
|
51
|
+
function R(t, _) {
|
|
52
|
+
const k = Number(t);
|
|
53
|
+
return t == null || t === "" || !Number.isFinite(k) ? "—" : _ === "currency" ? k.toLocaleString("en-US", { style: "currency", currency: "USD" }) : k.toLocaleString("en-US", { maximumFractionDigits: 2 });
|
|
52
54
|
}
|
|
53
|
-
function
|
|
55
|
+
function tr({
|
|
54
56
|
config: t,
|
|
55
57
|
initialScope: _,
|
|
56
|
-
lockScope:
|
|
58
|
+
lockScope: k = !1
|
|
57
59
|
}) {
|
|
58
|
-
var
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
var st, lt, at, nt, ot, it, ct;
|
|
61
|
+
const p = wt(), w = gt(), [b, D] = Q(_ ?? {}), _e = ie(_);
|
|
62
|
+
xe(() => {
|
|
63
|
+
_e.current !== _ && (_e.current = _, _ && D((e) => ({ ...e, ..._ })));
|
|
62
64
|
}, [_]);
|
|
63
|
-
const [
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
const [L, ee] = Q({}), Fe = ie(L);
|
|
66
|
+
Fe.current = L;
|
|
67
|
+
const [Ee, ue] = Q({}), [ye, ke] = Q({}), te = j(
|
|
68
|
+
() => new Et(p, t.target_collection),
|
|
69
|
+
[p, t.target_collection]
|
|
70
|
+
), Ge = () => {
|
|
71
|
+
ee({}), ue({}), ke({}), te.release();
|
|
72
|
+
}, [ze, Te] = Q(!1), [Ae, ve] = Q(null), [Ue, Pe] = Q(/* @__PURE__ */ new Set()), F = t.scope_fields.every(
|
|
73
|
+
(e) => b[e.field] !== null && b[e.field] !== void 0 && b[e.field] !== ""
|
|
74
|
+
), Ke = ie(null), E = t.scope_fields[0], I = E && F ? String(b[E.field]) : null, ft = St(
|
|
66
75
|
"matrix",
|
|
67
76
|
t.target_collection,
|
|
68
|
-
...t.scope_fields.slice(1).map((e) => String(
|
|
69
|
-
),
|
|
70
|
-
page:
|
|
71
|
-
collection:
|
|
72
|
-
items:
|
|
73
|
-
containerRef:
|
|
74
|
-
enabled: !!
|
|
75
|
-
}),
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
),
|
|
80
|
-
var r,
|
|
77
|
+
...t.scope_fields.slice(1).map((e) => String(b[e.field] ?? ""))
|
|
78
|
+
), We = j(() => I ? [I] : [], [I]), { editors: Ne } = jt({
|
|
79
|
+
page: ft,
|
|
80
|
+
collection: E == null ? void 0 : E.collection,
|
|
81
|
+
items: We,
|
|
82
|
+
containerRef: Ke,
|
|
83
|
+
enabled: !!I
|
|
84
|
+
}), ht = Rt(
|
|
85
|
+
E == null ? void 0 : E.collection,
|
|
86
|
+
We,
|
|
87
|
+
Ne.length > 0
|
|
88
|
+
), Je = ie(/* @__PURE__ */ new Map()), re = t.option_label ?? "name", T = JSON.stringify(b), f = t.group, Qe = j(() => {
|
|
89
|
+
var r, l;
|
|
81
90
|
const e = [
|
|
82
91
|
t.option_label_template,
|
|
83
92
|
(r = t.option_section) == null ? void 0 : r.label_template,
|
|
84
|
-
(
|
|
85
|
-
].filter((
|
|
86
|
-
if (e.length === 0) return `id,${
|
|
87
|
-
const
|
|
88
|
-
(
|
|
93
|
+
(l = t.option_section) == null ? void 0 : l.row_label_template
|
|
94
|
+
].filter((o) => !!o);
|
|
95
|
+
if (e.length === 0) return `id,${re}`;
|
|
96
|
+
const s = e.flatMap(
|
|
97
|
+
(o) => [...o.matchAll(/\{\{\s*([\w.[\]]+)\s*\}\}/g)].map((n) => n[1].replace(/\[\d+\]/g, ""))
|
|
89
98
|
);
|
|
90
|
-
return t.option_label_template ||
|
|
91
|
-
}, [t.option_label_template, t.option_section,
|
|
92
|
-
queryKey: ["matrix-options", t.option_collection,
|
|
99
|
+
return t.option_label_template || s.push(re), ["id", ...new Set(s)].join(",");
|
|
100
|
+
}, [t.option_label_template, t.option_section, re]), { data: Ve = [], isLoading: xt } = oe({
|
|
101
|
+
queryKey: ["matrix-options", t.option_collection, Qe, T],
|
|
93
102
|
queryFn: () => {
|
|
94
|
-
const e =
|
|
95
|
-
return
|
|
96
|
-
|
|
103
|
+
const e = qe(t.option_filter, b);
|
|
104
|
+
return p.request(
|
|
105
|
+
ce(`/items/${t.option_collection}`, {
|
|
97
106
|
limit: 500,
|
|
98
|
-
fields:
|
|
107
|
+
fields: Qe,
|
|
99
108
|
...e ? { filter: JSON.stringify(e) } : {}
|
|
100
109
|
})
|
|
101
|
-
).then((
|
|
110
|
+
).then((s) => s.data ?? []);
|
|
102
111
|
},
|
|
103
112
|
enabled: F,
|
|
104
113
|
staleTime: 3e4
|
|
105
|
-
}), { data:
|
|
106
|
-
queryKey: ["matrix-groups",
|
|
114
|
+
}), { data: A = [] } = oe({
|
|
115
|
+
queryKey: ["matrix-groups", f == null ? void 0 : f.collection, T],
|
|
107
116
|
queryFn: () => {
|
|
108
|
-
const e =
|
|
109
|
-
return
|
|
110
|
-
|
|
117
|
+
const e = qe(f == null ? void 0 : f.filter, b);
|
|
118
|
+
return p.request(
|
|
119
|
+
ce(`/items/${f.collection}`, {
|
|
111
120
|
limit: 200,
|
|
112
121
|
fields: [
|
|
113
122
|
"id",
|
|
114
|
-
|
|
123
|
+
f.label_field ?? "name",
|
|
115
124
|
...Object.values(t.group_seeds ?? {})
|
|
116
125
|
].join(","),
|
|
117
126
|
...e ? { filter: JSON.stringify(e) } : {}
|
|
118
127
|
})
|
|
119
|
-
).then((
|
|
128
|
+
).then((s) => s.data ?? []);
|
|
120
129
|
},
|
|
121
|
-
enabled: F && !!
|
|
130
|
+
enabled: F && !!f,
|
|
122
131
|
staleTime: 3e4
|
|
123
|
-
}),
|
|
124
|
-
var
|
|
132
|
+
}), _t = j(() => {
|
|
133
|
+
var s;
|
|
125
134
|
const e = ["id", t.key_field, t.value_field];
|
|
126
|
-
return
|
|
127
|
-
}, [t,
|
|
135
|
+
return f && e.push(f.field), (s = t.specials) != null && s.bucket && e.push(t.specials.bucket.flag_field), e.join(",");
|
|
136
|
+
}, [t, f]), { data: me = [], isLoading: ge } = oe({
|
|
128
137
|
queryKey: ["matrix-targets", t.target_collection, T],
|
|
129
138
|
queryFn: () => {
|
|
130
139
|
const e = {};
|
|
131
|
-
for (const
|
|
132
|
-
return
|
|
133
|
-
|
|
140
|
+
for (const s of t.scope_fields) e[s.field] = { _eq: b[s.field] };
|
|
141
|
+
return p.request(
|
|
142
|
+
ce(`/items/${t.target_collection}`, {
|
|
134
143
|
limit: 2e3,
|
|
135
|
-
fields:
|
|
144
|
+
fields: _t,
|
|
136
145
|
filter: JSON.stringify(e)
|
|
137
146
|
})
|
|
138
|
-
).then((
|
|
147
|
+
).then((s) => s.data ?? []);
|
|
139
148
|
},
|
|
140
149
|
enabled: F,
|
|
141
|
-
staleTime: 0
|
|
142
|
-
|
|
150
|
+
staleTime: 0,
|
|
151
|
+
// E11: another planner's save shows here; the person's typed cells stay on top of it.
|
|
152
|
+
meta: Ot({ reads: [t.target_collection], minGapMs: 2e3 })
|
|
153
|
+
});
|
|
154
|
+
xe(() => {
|
|
155
|
+
te.noteRows(me);
|
|
156
|
+
}, [te, me]);
|
|
157
|
+
const se = j(() => {
|
|
143
158
|
var r;
|
|
144
|
-
const e = /* @__PURE__ */ new Map(),
|
|
145
|
-
if (typeof
|
|
146
|
-
const
|
|
147
|
-
if (!
|
|
148
|
-
const
|
|
149
|
-
|
|
159
|
+
const e = /* @__PURE__ */ new Map(), s = (l) => {
|
|
160
|
+
if (typeof l != "string") return;
|
|
161
|
+
const o = /^\$(\w+)\.(.+)$/.exec(l);
|
|
162
|
+
if (!o || o[1] === "scope") return;
|
|
163
|
+
const n = e.get(o[1]) ?? /* @__PURE__ */ new Set();
|
|
164
|
+
n.add(o[2].replace(/\[\d+\]/g, "")), e.set(o[1], n);
|
|
150
165
|
};
|
|
151
|
-
for (const
|
|
152
|
-
for (const
|
|
153
|
-
for (const
|
|
166
|
+
for (const l of Object.values(t.scope_seeds ?? {})) s(l);
|
|
167
|
+
for (const l of Object.values(t.scope_defaults ?? {})) s(l);
|
|
168
|
+
for (const l of Object.values(((r = t.metrics) == null ? void 0 : r.params) ?? {})) s(l);
|
|
154
169
|
if (t.cap) {
|
|
155
|
-
const
|
|
156
|
-
|
|
170
|
+
const l = e.get(t.cap.scope_field) ?? /* @__PURE__ */ new Set();
|
|
171
|
+
l.add(t.cap.field), e.set(t.cap.scope_field, l);
|
|
157
172
|
}
|
|
158
173
|
return e;
|
|
159
|
-
}, [t.scope_seeds, t.scope_defaults, t.metrics, t.cap]), { data:
|
|
160
|
-
queryKey: ["matrix-scope-records", T, [...
|
|
174
|
+
}, [t.scope_seeds, t.scope_defaults, t.metrics, t.cap]), { data: U = {} } = oe({
|
|
175
|
+
queryKey: ["matrix-scope-records", T, [...se.keys()].join(",")],
|
|
161
176
|
queryFn: async () => {
|
|
162
177
|
const e = {};
|
|
163
|
-
for (const [
|
|
164
|
-
const
|
|
165
|
-
if (!
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
).then((
|
|
169
|
-
if (
|
|
170
|
-
if (
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
).then((
|
|
174
|
-
for (const [
|
|
175
|
-
|
|
178
|
+
for (const [s, r] of se) {
|
|
179
|
+
const l = t.scope_fields.find((a) => a.field === s), o = b[s];
|
|
180
|
+
if (!l || o == null) continue;
|
|
181
|
+
const n = [...r].filter((a) => !a.includes(".")), u = [...r].filter((a) => a.includes(".")), i = await p.request(
|
|
182
|
+
ce(`/items/${l.collection}/${o}`, { fields: ["id", ...n].join(",") })
|
|
183
|
+
).then((a) => a.data).catch(() => null);
|
|
184
|
+
if (i) {
|
|
185
|
+
if (u.length > 0) {
|
|
186
|
+
const a = await p.request(
|
|
187
|
+
ce(`/items/${l.collection}/${o}/resolve-paths`, { paths: u.join(",") })
|
|
188
|
+
).then((m) => m.data ?? {}).catch(() => ({}));
|
|
189
|
+
for (const [m, c] of Object.entries(a))
|
|
190
|
+
i[m] = c != null && c.ids && c.ids.length > 0 ? c.ids[0] : (c == null ? void 0 : c.value) ?? null;
|
|
176
191
|
}
|
|
177
|
-
e[
|
|
192
|
+
e[s] = i;
|
|
178
193
|
}
|
|
179
194
|
}
|
|
180
195
|
return e;
|
|
181
196
|
},
|
|
182
197
|
// Per-field, not scopeReady — scope_defaults must resolve while other
|
|
183
198
|
// pickers are still empty (project → default sub type).
|
|
184
|
-
enabled:
|
|
185
|
-
(e) =>
|
|
199
|
+
enabled: se.size > 0 && [...se.keys()].some(
|
|
200
|
+
(e) => b[e] !== null && b[e] !== void 0 && b[e] !== ""
|
|
186
201
|
),
|
|
187
202
|
staleTime: 3e4
|
|
188
203
|
});
|
|
189
|
-
|
|
204
|
+
xe(() => {
|
|
190
205
|
if (t.scope_defaults)
|
|
191
|
-
for (const [e,
|
|
192
|
-
if (
|
|
193
|
-
const r = /^\$(\w+)\.(.+)$/.exec(
|
|
206
|
+
for (const [e, s] of Object.entries(t.scope_defaults)) {
|
|
207
|
+
if (b[e] != null && b[e] !== "") continue;
|
|
208
|
+
const r = /^\$(\w+)\.(.+)$/.exec(s);
|
|
194
209
|
if (!r) continue;
|
|
195
|
-
const
|
|
196
|
-
|
|
210
|
+
const l = de(U[r[1]] ?? {}, r[2]);
|
|
211
|
+
l != null && l !== "" && D((o) => ({ ...o, [e]: l }));
|
|
197
212
|
}
|
|
198
|
-
}, [
|
|
199
|
-
const { data:
|
|
213
|
+
}, [U, t.scope_defaults, b]);
|
|
214
|
+
const { data: pe = [] } = oe({
|
|
200
215
|
queryKey: [
|
|
201
216
|
"matrix-metrics",
|
|
202
|
-
(
|
|
217
|
+
(st = t.metrics) == null ? void 0 : st.query_slug,
|
|
203
218
|
T,
|
|
204
|
-
Object.keys(
|
|
219
|
+
Object.keys(U).length
|
|
205
220
|
],
|
|
206
221
|
queryFn: () => {
|
|
207
222
|
var e;
|
|
208
|
-
return
|
|
209
|
-
|
|
223
|
+
return p.request(
|
|
224
|
+
pt(`/custom-queries/${t.metrics.query_slug}/execute`, {
|
|
210
225
|
params: Object.fromEntries(
|
|
211
|
-
Object.entries(((e = t.metrics) == null ? void 0 : e.params) ?? {}).map(([
|
|
226
|
+
Object.entries(((e = t.metrics) == null ? void 0 : e.params) ?? {}).map(([s, r]) => {
|
|
212
227
|
if (typeof r == "string" && r.startsWith("$scope."))
|
|
213
|
-
return [
|
|
228
|
+
return [s, b[r.slice(7)]];
|
|
214
229
|
if (typeof r == "string" && r.startsWith("$")) {
|
|
215
|
-
const
|
|
216
|
-
if (
|
|
230
|
+
const l = /^\$(\w+)\.(.+)$/.exec(r);
|
|
231
|
+
if (l) return [s, de(U[l[1]] ?? {}, l[2])];
|
|
217
232
|
}
|
|
218
|
-
return [
|
|
233
|
+
return [s, r];
|
|
219
234
|
})
|
|
220
235
|
)
|
|
221
236
|
})
|
|
222
|
-
).then((
|
|
237
|
+
).then((s) => s.data ?? []);
|
|
223
238
|
},
|
|
224
|
-
enabled: F && !!t.metrics && (
|
|
239
|
+
enabled: F && !!t.metrics && (se.size === 0 || Object.keys(U).length > 0),
|
|
225
240
|
staleTime: 3e4
|
|
226
|
-
}),
|
|
227
|
-
var
|
|
228
|
-
const
|
|
241
|
+
}), yt = (e) => {
|
|
242
|
+
var o;
|
|
243
|
+
const s = f ? String(e[f.field] ?? "") : "", r = (o = t.specials) == null ? void 0 : o.bucket;
|
|
229
244
|
if (r && (e[r.flag_field] === !0 || e[r.flag_field] === 1))
|
|
230
|
-
return `${
|
|
231
|
-
const
|
|
232
|
-
return `${
|
|
233
|
-
},
|
|
245
|
+
return `${s}|${B}`;
|
|
246
|
+
const l = e[t.key_field];
|
|
247
|
+
return `${s}|${l == null ? V : String(l)}`;
|
|
248
|
+
}, v = j(() => {
|
|
234
249
|
const e = /* @__PURE__ */ new Map();
|
|
235
|
-
for (const
|
|
236
|
-
const r =
|
|
237
|
-
|
|
250
|
+
for (const s of me) {
|
|
251
|
+
const r = yt(s), l = e.get(r) ?? { ids: [], total: 0 };
|
|
252
|
+
l.ids.push(s.id), l.total += Number(s[t.value_field]) || 0, e.set(r, l);
|
|
238
253
|
}
|
|
239
254
|
return e;
|
|
240
|
-
}, [
|
|
241
|
-
var
|
|
242
|
-
const r = t.metrics,
|
|
243
|
-
if (!r) return
|
|
244
|
-
const
|
|
245
|
-
for (const
|
|
246
|
-
if (r.match_group_field && String(
|
|
247
|
-
const c =
|
|
248
|
-
if (
|
|
249
|
-
for (const
|
|
250
|
-
|
|
255
|
+
}, [me, t.value_field]), be = (e, s) => {
|
|
256
|
+
var n, u, i, a;
|
|
257
|
+
const r = t.metrics, l = {};
|
|
258
|
+
if (!r) return l;
|
|
259
|
+
const o = s === V ? ((u = (n = t.specials) == null ? void 0 : n.uncategorized) == null ? void 0 : u.metric_value) ?? null : s === B ? ((a = (i = t.specials) == null ? void 0 : i.bucket) == null ? void 0 : a.metric_value) ?? null : s;
|
|
260
|
+
for (const m of pe) {
|
|
261
|
+
if (r.match_group_field && String(m[r.match_group_field] ?? "") !== e) continue;
|
|
262
|
+
const c = m[r.match_option_field], h = o === null || o === 0 || o === "0", $ = c == null || c === 0 || c === "0" || c === "";
|
|
263
|
+
if (h ? $ : String(c ?? "") === String(o))
|
|
264
|
+
for (const y of r.columns)
|
|
265
|
+
l[y.field] = (l[y.field] ?? 0) + (Number(m[y.field]) || 0);
|
|
251
266
|
}
|
|
252
|
-
return
|
|
253
|
-
},
|
|
254
|
-
const e = (r) => t.option_label_template ?
|
|
255
|
-
return [...
|
|
256
|
-
const
|
|
257
|
-
return { key: String(r.id), label:
|
|
258
|
-
}).sort((r,
|
|
259
|
-
}, [
|
|
267
|
+
return l;
|
|
268
|
+
}, q = j(() => {
|
|
269
|
+
const e = (r) => t.option_label_template ? Le(t.option_label_template, r) : String(r[re] ?? r.id), s = t.option_section;
|
|
270
|
+
return [...Ve].map((r) => {
|
|
271
|
+
const l = e(r), o = s ? Le(s.label_template, r) : "", n = s != null && s.row_label_template && Le(s.row_label_template, r) || l;
|
|
272
|
+
return { key: String(r.id), label: s ? n : l, section: o };
|
|
273
|
+
}).sort((r, l) => r.section.localeCompare(l.section) || r.label.localeCompare(l.label));
|
|
274
|
+
}, [Ve, t.option_label_template, t.option_section, re]), fe = j(() => {
|
|
260
275
|
if (!t.option_section) return [];
|
|
261
276
|
const e = /* @__PURE__ */ new Map();
|
|
262
|
-
for (const
|
|
263
|
-
const r = e.get(
|
|
264
|
-
r.push(
|
|
277
|
+
for (const s of q) {
|
|
278
|
+
const r = e.get(s.section) ?? [];
|
|
279
|
+
r.push(s), e.set(s.section, r);
|
|
265
280
|
}
|
|
266
|
-
return [...e.entries()].map(([
|
|
267
|
-
}, [
|
|
268
|
-
|
|
269
|
-
if (!
|
|
270
|
-
const e = `${T}#${t.option_section &&
|
|
271
|
-
if (
|
|
272
|
-
|
|
273
|
-
const
|
|
281
|
+
return [...e.entries()].map(([s, r]) => ({ name: s, rows: r }));
|
|
282
|
+
}, [q, t.option_section]), Be = ie(null);
|
|
283
|
+
xe(() => {
|
|
284
|
+
if (!f || A.length === 0 || ge) return;
|
|
285
|
+
const e = `${T}#${t.option_section && fe.length > 0 ? 1 : 0}`;
|
|
286
|
+
if (Be.current === e) return;
|
|
287
|
+
Be.current = e;
|
|
288
|
+
const s = new Set([...v.keys()].map((l) => l.split("|")[0])), r = new Set(A.map((l) => String(l.id)).filter((l) => !s.has(l)));
|
|
274
289
|
if (t.option_section) {
|
|
275
|
-
const
|
|
276
|
-
for (const
|
|
277
|
-
const
|
|
278
|
-
for (const
|
|
279
|
-
|
|
290
|
+
const l = new Set(v.keys());
|
|
291
|
+
for (const o of A) {
|
|
292
|
+
const n = String(o.id);
|
|
293
|
+
for (const u of fe)
|
|
294
|
+
u.rows.some((i) => l.has(`${n}|${i.key}`)) || r.add(`s:${n}|${u.name}`);
|
|
280
295
|
}
|
|
281
296
|
}
|
|
282
|
-
|
|
283
|
-
}, [
|
|
284
|
-
const
|
|
285
|
-
var
|
|
297
|
+
Pe(r);
|
|
298
|
+
}, [A, v, ge, T, f, fe, t.option_section]);
|
|
299
|
+
const M = j(() => f ? [...A].map((e) => ({ id: String(e.id), label: String(e[f.label_field ?? "name"] ?? e.id) })).sort((e, s) => e.label.localeCompare(s.label)) : [{ id: "", label: "" }], [A, f]), De = j(() => {
|
|
300
|
+
var s, r;
|
|
286
301
|
const e = /* @__PURE__ */ new Set();
|
|
287
|
-
for (const
|
|
288
|
-
for (const
|
|
289
|
-
(
|
|
302
|
+
for (const l of M) {
|
|
303
|
+
for (const o of q) e.add(`${l.id}|${o.key}`);
|
|
304
|
+
(s = t.specials) != null && s.uncategorized && e.add(`${l.id}|${V}`), (r = t.specials) != null && r.bucket && e.add(`${l.id}|${B}`);
|
|
290
305
|
}
|
|
291
306
|
return e;
|
|
292
|
-
}, [
|
|
307
|
+
}, [M, q, t.specials]), P = j(() => {
|
|
293
308
|
let e = 0;
|
|
294
|
-
for (const [
|
|
309
|
+
for (const [s, r] of v) De.has(s) || (e += r.total);
|
|
295
310
|
return e;
|
|
296
|
-
}, [
|
|
297
|
-
var
|
|
298
|
-
let e =
|
|
299
|
-
for (const
|
|
300
|
-
const
|
|
301
|
-
...
|
|
302
|
-
...(
|
|
303
|
-
...(r = t.specials) != null && r.bucket ? [
|
|
311
|
+
}, [v, De]), H = t.cap ? Number(de(U[t.cap.scope_field] ?? {}, t.cap.field)) || 0 : null, we = j(() => [...v.values()].reduce((e, s) => e + s.total, 0), [v]), Ie = j(() => {
|
|
312
|
+
var s, r, l;
|
|
313
|
+
let e = P;
|
|
314
|
+
for (const o of M) {
|
|
315
|
+
const n = [
|
|
316
|
+
...q.map((u) => u.key),
|
|
317
|
+
...(s = t.specials) != null && s.uncategorized ? [V] : [],
|
|
318
|
+
...(r = t.specials) != null && r.bucket ? [B] : []
|
|
304
319
|
];
|
|
305
|
-
for (const
|
|
306
|
-
const
|
|
307
|
-
|
|
320
|
+
for (const u of n) {
|
|
321
|
+
const i = `${o.id}|${u}`, a = L[i];
|
|
322
|
+
a !== void 0 && a.trim() !== "" && !Number.isNaN(Number(a)) ? e += Number(a) : e += ((l = v.get(i)) == null ? void 0 : l.total) ?? 0;
|
|
308
323
|
}
|
|
309
324
|
}
|
|
310
325
|
return e;
|
|
311
|
-
}, [
|
|
326
|
+
}, [L, v, M, q, P, t.specials]), $e = H !== null ? H - Ie : null, le = (e) => {
|
|
312
327
|
var r;
|
|
313
|
-
const
|
|
314
|
-
return
|
|
328
|
+
const s = L[e];
|
|
329
|
+
return s !== void 0 && s.trim() !== "" && !Number.isNaN(Number(s)) ? Number(s) : ((r = v.get(e)) == null ? void 0 : r.total) ?? 0;
|
|
315
330
|
};
|
|
316
|
-
function
|
|
317
|
-
var
|
|
318
|
-
const r =
|
|
319
|
-
|
|
320
|
-
|
|
331
|
+
function kt(e, s) {
|
|
332
|
+
var u;
|
|
333
|
+
const r = v.get(e);
|
|
334
|
+
e in Ee || ((r == null ? void 0 : r.ids[0]) != null && te.pin(String(r.ids[0])), ue((i) => ({ ...i, [e]: (r == null ? void 0 : r.total) ?? 0 })));
|
|
335
|
+
const l = s.trim();
|
|
336
|
+
if (l === "") {
|
|
337
|
+
ee((i) => ({ ...i, [e]: s })), ke((i) => {
|
|
338
|
+
if (!(e in i)) return i;
|
|
339
|
+
const a = { ...i };
|
|
340
|
+
return delete a[e], a;
|
|
341
|
+
}), ue((i) => {
|
|
342
|
+
if (!(e in i)) return i;
|
|
343
|
+
const a = { ...i };
|
|
344
|
+
return delete a[e], a;
|
|
345
|
+
});
|
|
321
346
|
return;
|
|
322
347
|
}
|
|
323
|
-
const
|
|
324
|
-
let
|
|
325
|
-
if (Number.isNaN(
|
|
326
|
-
|
|
348
|
+
const o = /^[+-]/.test(l) && l !== "-" && l !== "+";
|
|
349
|
+
let n = Number(l);
|
|
350
|
+
if (Number.isNaN(n)) {
|
|
351
|
+
ee((i) => ({ ...i, [e]: s }));
|
|
327
352
|
return;
|
|
328
353
|
}
|
|
329
|
-
if (
|
|
330
|
-
const i =
|
|
331
|
-
|
|
354
|
+
if (o && (n = (((u = v.get(e)) == null ? void 0 : u.total) ?? 0) + n), n < 0 && (n = 0), H !== null) {
|
|
355
|
+
const i = Ie - le(e), a = Math.max(0, H - i);
|
|
356
|
+
n = Math.min(n, a);
|
|
332
357
|
}
|
|
333
|
-
|
|
358
|
+
ee((i) => ({ ...i, [e]: o ? String(n) : s }));
|
|
334
359
|
}
|
|
335
|
-
async function
|
|
336
|
-
var
|
|
337
|
-
|
|
338
|
-
let e = 0,
|
|
360
|
+
async function vt() {
|
|
361
|
+
var n, u;
|
|
362
|
+
Te(!0), ve(null);
|
|
363
|
+
let e = 0, s = 0;
|
|
364
|
+
const r = {}, l = {}, o = L;
|
|
339
365
|
try {
|
|
340
|
-
const
|
|
341
|
-
for (const [
|
|
342
|
-
const
|
|
343
|
-
|
|
366
|
+
const i = {};
|
|
367
|
+
for (const [m, c] of Object.entries(t.scope_seeds ?? {})) {
|
|
368
|
+
const h = /^\$(\w+)\.(.+)$/.exec(c);
|
|
369
|
+
h && (i[m] = de(U[h[1]] ?? {}, h[2]));
|
|
344
370
|
}
|
|
345
|
-
for (const [
|
|
346
|
-
if (
|
|
347
|
-
const
|
|
348
|
-
if (Number.isNaN(
|
|
349
|
-
const
|
|
350
|
-
if (!(
|
|
351
|
-
if (
|
|
352
|
-
await
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
)
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
for (const [v, C] of Object.entries(t.group_seeds ?? {})) {
|
|
364
|
-
const x = k == null ? void 0 : k[C];
|
|
365
|
-
x != null && (c[v] = x);
|
|
371
|
+
for (const [m, c] of Object.entries(L)) {
|
|
372
|
+
if (c.trim() === "") continue;
|
|
373
|
+
const h = Number(c);
|
|
374
|
+
if (Number.isNaN(h) || h < 0) continue;
|
|
375
|
+
const $ = v.get(m);
|
|
376
|
+
if (!($ && $.total === h))
|
|
377
|
+
if ($) {
|
|
378
|
+
const S = await te.write(String($.ids[0]), { [t.value_field]: h });
|
|
379
|
+
S.ok ? (e++, l[m] = h) : r[m] = ((n = S.conflicts[0]) == null ? void 0 : n.current_value) ?? null;
|
|
380
|
+
} else {
|
|
381
|
+
const [S, y] = m.split("|"), N = { [t.value_field]: h, ...i };
|
|
382
|
+
for (const C of t.scope_fields) N[C.field] = b[C.field];
|
|
383
|
+
if (f && S) {
|
|
384
|
+
N[f.field] = S;
|
|
385
|
+
const C = A.find((Z) => String(Z.id) === S);
|
|
386
|
+
for (const [Z, g] of Object.entries(t.group_seeds ?? {})) {
|
|
387
|
+
const ne = C == null ? void 0 : C[g];
|
|
388
|
+
ne != null && (N[Z] = ne);
|
|
366
389
|
}
|
|
367
390
|
}
|
|
368
|
-
|
|
391
|
+
y === B && ((u = t.specials) != null && u.bucket) ? (N[t.key_field] = null, N[t.specials.bucket.flag_field] = !0) : y === V ? N[t.key_field] = null : N[t.key_field] = y, await p.request(pt(`/items/${t.target_collection}`, N)), s++, l[m] = h;
|
|
369
392
|
}
|
|
370
393
|
}
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
394
|
+
const a = Gt(Fe.current, o, new Set(Object.keys(r)));
|
|
395
|
+
ee(a), ue((m) => {
|
|
396
|
+
const c = {};
|
|
397
|
+
for (const h of Object.keys(a))
|
|
398
|
+
h in l ? c[h] = l[h] : m[h] !== void 0 && (c[h] = m[h]);
|
|
399
|
+
return c;
|
|
400
|
+
}), ke(r), await w.invalidateQueries({ queryKey: ["matrix-targets", t.target_collection] }), ve(Tt(e, s, Object.keys(r).length));
|
|
401
|
+
} catch (i) {
|
|
402
|
+
ve(`Save failed: ${qt(i, "unknown error")}`);
|
|
374
403
|
} finally {
|
|
375
|
-
|
|
404
|
+
Te(!1);
|
|
376
405
|
}
|
|
377
406
|
}
|
|
378
|
-
const
|
|
379
|
-
1 +
|
|
380
|
-
const
|
|
381
|
-
const
|
|
382
|
-
if (!
|
|
383
|
-
const [
|
|
384
|
-
return { "--qtc":
|
|
385
|
-
},
|
|
386
|
-
var
|
|
387
|
-
const e = /* @__PURE__ */ new Map(),
|
|
407
|
+
const He = Object.values(L).some((e) => e.trim() !== ""), G = ((lt = t.metrics) == null ? void 0 : lt.columns) ?? [], K = ((at = t.metrics) == null ? void 0 : at.derived) ?? [], Xe = t.value_label ?? t.value_field;
|
|
408
|
+
1 + G.length + K.length + 1;
|
|
409
|
+
const W = "text-[color:var(--qtc)] dark:text-[color:var(--qtcd)]", J = (e, s, r) => {
|
|
410
|
+
const o = r && typeof s == "number" && s < 0 ? r : e;
|
|
411
|
+
if (!o) return;
|
|
412
|
+
const [n, u] = Ft(o);
|
|
413
|
+
return { "--qtc": n, "--qtcd": u };
|
|
414
|
+
}, Se = t.value_color ?? "info", X = ((nt = t.metrics) == null ? void 0 : nt.unmatched) === !1 ? null : ((ot = t.metrics) == null ? void 0 : ot.unmatched) ?? {}, z = j(() => {
|
|
415
|
+
var a, m;
|
|
416
|
+
const e = /* @__PURE__ */ new Map(), s = {};
|
|
388
417
|
let r = 0;
|
|
389
|
-
const
|
|
390
|
-
if (!
|
|
391
|
-
const
|
|
392
|
-
(
|
|
393
|
-
for (const c of
|
|
394
|
-
const
|
|
395
|
-
if (
|
|
396
|
-
for (const
|
|
397
|
-
|
|
398
|
-
!
|
|
418
|
+
const l = t.metrics;
|
|
419
|
+
if (!l || !X) return { perGroup: e, otherGroup: s, otherGroupCount: r };
|
|
420
|
+
const o = new Set(M.map((c) => c.id)), n = new Set(q.map((c) => c.key)), u = /* @__PURE__ */ new Set(), i = (c) => c == null || c === 0 || c === "0" || c === "" ? "" : String(c);
|
|
421
|
+
(a = t.specials) != null && a.uncategorized && u.add(i(t.specials.uncategorized.metric_value)), (m = t.specials) != null && m.bucket && u.add(i(t.specials.bucket.metric_value));
|
|
422
|
+
for (const c of pe) {
|
|
423
|
+
const h = l.match_group_field ? String(c[l.match_group_field] ?? "") : "", $ = c[l.match_option_field], S = n.has(String($ ?? "")) || u.has(i($)), y = !f || o.has(h) ? S ? null : e.get(h) ?? {} : s;
|
|
424
|
+
if (y) {
|
|
425
|
+
for (const N of l.columns)
|
|
426
|
+
y[N.field] = (y[N.field] ?? 0) + (Number(c[N.field]) || 0);
|
|
427
|
+
!f || o.has(h) ? e.set(h, y) : r++;
|
|
399
428
|
}
|
|
400
429
|
}
|
|
401
|
-
return { perGroup: e, otherGroup:
|
|
402
|
-
}, [
|
|
403
|
-
(
|
|
404
|
-
|
|
405
|
-
{ ...r, __current__: e, __new__:
|
|
430
|
+
return { perGroup: e, otherGroup: s, otherGroupCount: r };
|
|
431
|
+
}, [pe, t.metrics, t.specials, M, q, f, X]), Ye = (e, s, r) => K.map(
|
|
432
|
+
(l) => $t(
|
|
433
|
+
l.formula,
|
|
434
|
+
{ ...r, __current__: e, __new__: s },
|
|
406
435
|
{ missing: "zero" }
|
|
407
436
|
)
|
|
408
|
-
),
|
|
409
|
-
const
|
|
437
|
+
), je = (e) => {
|
|
438
|
+
const s = {};
|
|
410
439
|
for (const r of e)
|
|
411
|
-
for (const
|
|
412
|
-
return
|
|
413
|
-
},
|
|
414
|
-
var e,
|
|
440
|
+
for (const l of G) s[l.field] = (s[l.field] ?? 0) + (r[l.field] ?? 0);
|
|
441
|
+
return s;
|
|
442
|
+
}, Ze = () => {
|
|
443
|
+
var e, s;
|
|
415
444
|
return [
|
|
416
|
-
...
|
|
417
|
-
...(e = t.specials) != null && e.uncategorized ? [
|
|
418
|
-
...(
|
|
445
|
+
...q.map((r) => r.key),
|
|
446
|
+
...(e = t.specials) != null && e.uncategorized ? [V] : [],
|
|
447
|
+
...(s = t.specials) != null && s.bucket ? [B] : []
|
|
419
448
|
];
|
|
420
|
-
},
|
|
421
|
-
var
|
|
422
|
-
let e = 0,
|
|
449
|
+
}, Y = j(() => {
|
|
450
|
+
var l;
|
|
451
|
+
let e = 0, s = 0;
|
|
423
452
|
const r = [];
|
|
424
|
-
for (const
|
|
425
|
-
for (const
|
|
426
|
-
const
|
|
427
|
-
e += ((
|
|
453
|
+
for (const o of M) {
|
|
454
|
+
for (const u of Ze()) {
|
|
455
|
+
const i = `${o.id}|${u}`;
|
|
456
|
+
e += ((l = v.get(i)) == null ? void 0 : l.total) ?? 0, s += le(i), r.push(be(o.id, u));
|
|
428
457
|
}
|
|
429
|
-
const
|
|
430
|
-
|
|
458
|
+
const n = z.perGroup.get(o.id);
|
|
459
|
+
n && r.push(n);
|
|
431
460
|
}
|
|
432
|
-
return r.push(z.otherGroup), e +=
|
|
461
|
+
return r.push(z.otherGroup), e += P, s += P, { current: e, next: s, metrics: je(r) };
|
|
433
462
|
}, [
|
|
463
|
+
M,
|
|
434
464
|
q,
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
A,
|
|
465
|
+
v,
|
|
466
|
+
L,
|
|
467
|
+
pe,
|
|
468
|
+
P,
|
|
440
469
|
z,
|
|
441
470
|
t.specials
|
|
442
|
-
]),
|
|
443
|
-
const
|
|
471
|
+
]), ae = (e, s, r) => {
|
|
472
|
+
const l = r != null && r.tone ? void 0 : J(r == null ? void 0 : r.role, e, r == null ? void 0 : r.negRole);
|
|
444
473
|
return /* @__PURE__ */ d(
|
|
445
474
|
"td",
|
|
446
475
|
{
|
|
447
|
-
className:
|
|
476
|
+
className: O(
|
|
448
477
|
"py-1.5 pr-3 text-right tabular-nums",
|
|
449
478
|
r != null && r.strong ? "font-semibold" : "",
|
|
450
|
-
|
|
479
|
+
l ? W : r != null && r.strong ? "text-slate-800 dark:text-slate-100" : "text-slate-600 dark:text-slate-300",
|
|
451
480
|
(r == null ? void 0 : r.tone) === "muted" && "text-slate-400 dark:text-slate-500",
|
|
452
481
|
(r == null ? void 0 : r.tone) === "neg" && "text-red-600 dark:text-red-400"
|
|
453
482
|
),
|
|
454
|
-
style:
|
|
455
|
-
children:
|
|
483
|
+
style: l,
|
|
484
|
+
children: R(e, s)
|
|
456
485
|
}
|
|
457
486
|
);
|
|
458
|
-
},
|
|
459
|
-
const
|
|
460
|
-
return /* @__PURE__ */
|
|
461
|
-
|
|
462
|
-
|
|
487
|
+
}, Ce = (e, s, r, l) => {
|
|
488
|
+
const o = Ye(e, s, r);
|
|
489
|
+
return /* @__PURE__ */ x(Me, { children: [
|
|
490
|
+
ae(e, t.value_format, { strong: l, role: Se }),
|
|
491
|
+
G.map((n) => /* @__PURE__ */ d(
|
|
463
492
|
"td",
|
|
464
493
|
{
|
|
465
|
-
className:
|
|
494
|
+
className: O(
|
|
466
495
|
"py-1.5 pr-3 text-right tabular-nums",
|
|
467
|
-
|
|
468
|
-
|
|
496
|
+
l && "font-semibold",
|
|
497
|
+
W
|
|
469
498
|
),
|
|
470
|
-
style:
|
|
471
|
-
children:
|
|
499
|
+
style: J(n.color ?? "ink"),
|
|
500
|
+
children: R(r[n.field], n.format)
|
|
472
501
|
},
|
|
473
|
-
|
|
502
|
+
n.field
|
|
474
503
|
)),
|
|
475
|
-
|
|
476
|
-
const
|
|
504
|
+
K.map((n, u) => {
|
|
505
|
+
const i = o[u];
|
|
477
506
|
return /* @__PURE__ */ d(
|
|
478
507
|
"td",
|
|
479
508
|
{
|
|
480
|
-
className:
|
|
509
|
+
className: O(
|
|
481
510
|
"py-1.5 pr-3 text-right tabular-nums",
|
|
482
|
-
|
|
483
|
-
|
|
511
|
+
l && "font-semibold",
|
|
512
|
+
W
|
|
484
513
|
),
|
|
485
|
-
style:
|
|
486
|
-
children:
|
|
514
|
+
style: J(n.color ?? "positive", i, n.color_negative ?? "negative"),
|
|
515
|
+
children: R(i, n.format ?? t.value_format)
|
|
487
516
|
},
|
|
488
|
-
|
|
517
|
+
n.label
|
|
489
518
|
);
|
|
490
519
|
}),
|
|
491
|
-
|
|
492
|
-
strong:
|
|
493
|
-
tone:
|
|
520
|
+
ae(s, t.value_format, {
|
|
521
|
+
strong: l,
|
|
522
|
+
tone: s !== e ? void 0 : "muted"
|
|
494
523
|
})
|
|
495
524
|
] });
|
|
496
|
-
},
|
|
497
|
-
var
|
|
498
|
-
const
|
|
499
|
-
|
|
500
|
-
const
|
|
501
|
-
|
|
525
|
+
}, he = (e, s, r, l = !1, o = 0) => {
|
|
526
|
+
var C, Z;
|
|
527
|
+
const n = `${e}|${s}`, u = `${e}:${s}`, i = e ? (C = M.find((g) => g.id === e)) == null ? void 0 : C.label : null;
|
|
528
|
+
Je.current.set(u, i ? `${i} · ${r}` : r);
|
|
529
|
+
const a = ((Z = v.get(n)) == null ? void 0 : Z.total) ?? 0, m = be(e, s), c = L[n] ?? "", h = le(n), $ = c.trim() !== "" && !Number.isNaN(Number(c)), S = $ ? h - a : 0, y = zt(
|
|
530
|
+
n in ye,
|
|
531
|
+
ye[n],
|
|
532
|
+
Ee[n],
|
|
533
|
+
a,
|
|
534
|
+
c.trim() !== "",
|
|
535
|
+
(g) => R(g, t.value_format)
|
|
536
|
+
), N = Ye(a, h, m);
|
|
537
|
+
return /* @__PURE__ */ x(
|
|
502
538
|
"tr",
|
|
503
539
|
{
|
|
504
|
-
className:
|
|
540
|
+
className: O(
|
|
505
541
|
"border-b border-slate-100 dark:border-border/50",
|
|
506
|
-
|
|
542
|
+
$ && "bg-nvr-cyan/[0.04]"
|
|
507
543
|
),
|
|
508
544
|
children: [
|
|
509
545
|
/* @__PURE__ */ d(
|
|
510
546
|
"td",
|
|
511
547
|
{
|
|
512
|
-
className:
|
|
548
|
+
className: O(
|
|
513
549
|
"py-1 pr-3 text-slate-700 dark:text-slate-200",
|
|
514
|
-
|
|
550
|
+
l && "italic text-slate-500"
|
|
515
551
|
),
|
|
516
|
-
style:
|
|
552
|
+
style: o ? { paddingLeft: o * 18 } : void 0,
|
|
517
553
|
children: r
|
|
518
554
|
}
|
|
519
555
|
),
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
const
|
|
556
|
+
ae(a, t.value_format, a === 0 ? { tone: "muted" } : { role: Se }),
|
|
557
|
+
G.map((g) => Oe(g.field, m[g.field], g.format, g.color ?? "ink")),
|
|
558
|
+
K.map((g, ne) => {
|
|
559
|
+
const dt = N[ne];
|
|
524
560
|
return /* @__PURE__ */ d(
|
|
525
561
|
"td",
|
|
526
562
|
{
|
|
527
|
-
className:
|
|
528
|
-
style:
|
|
529
|
-
children:
|
|
563
|
+
className: O("py-1.5 pr-3 text-right tabular-nums", W),
|
|
564
|
+
style: J(g.color ?? "positive", dt, g.color_negative ?? "negative"),
|
|
565
|
+
children: R(dt, g.format ?? t.value_format)
|
|
530
566
|
},
|
|
531
|
-
|
|
567
|
+
g.label
|
|
532
568
|
);
|
|
533
569
|
}),
|
|
534
|
-
/* @__PURE__ */ d("td", { className: "py-1 pr-3 text-right", children: /* @__PURE__ */
|
|
535
|
-
|
|
570
|
+
/* @__PURE__ */ d("td", { className: "py-1 pr-3 text-right", children: /* @__PURE__ */ x("span", { className: "inline-flex items-center justify-end gap-1.5", children: [
|
|
571
|
+
$ && S !== 0 && /* @__PURE__ */ x(
|
|
536
572
|
"span",
|
|
537
573
|
{
|
|
538
|
-
className:
|
|
574
|
+
className: O(
|
|
539
575
|
"rounded-full px-1.5 py-px text-[10.5px] font-medium tabular-nums",
|
|
540
|
-
|
|
576
|
+
W,
|
|
541
577
|
"bg-[color-mix(in_srgb,var(--qtc)_12%,transparent)] dark:bg-[color-mix(in_srgb,var(--qtcd)_14%,transparent)]"
|
|
542
578
|
),
|
|
543
|
-
style:
|
|
579
|
+
style: J(S > 0 ? "positive" : "negative"),
|
|
544
580
|
children: [
|
|
545
|
-
|
|
546
|
-
|
|
581
|
+
S > 0 ? "+" : "−",
|
|
582
|
+
R(Math.abs(S), t.value_format)
|
|
547
583
|
]
|
|
548
584
|
}
|
|
549
585
|
),
|
|
550
|
-
/* @__PURE__ */
|
|
586
|
+
/* @__PURE__ */ x(
|
|
551
587
|
"span",
|
|
552
588
|
{
|
|
553
589
|
className: "relative rounded-md",
|
|
554
|
-
"data-grid-cell":
|
|
590
|
+
"data-grid-cell": I ? Ct(I, u) : void 0,
|
|
555
591
|
children: [
|
|
556
592
|
t.value_format === "currency" && /* @__PURE__ */ d("span", { className: "pointer-events-none absolute left-2 top-1/2 -translate-y-1/2 text-[11px] text-slate-400", children: "$" }),
|
|
557
593
|
/* @__PURE__ */ d(
|
|
@@ -560,18 +596,27 @@ function Ut({
|
|
|
560
596
|
type: "text",
|
|
561
597
|
inputMode: "decimal",
|
|
562
598
|
value: c,
|
|
563
|
-
placeholder:
|
|
564
|
-
|
|
599
|
+
placeholder: R(
|
|
600
|
+
a,
|
|
565
601
|
t.value_format === "currency" ? "number" : t.value_format
|
|
566
602
|
),
|
|
567
|
-
onChange: (
|
|
568
|
-
title: "Type a new amount, or +500 / -250 to adjust the current one",
|
|
569
|
-
|
|
603
|
+
onChange: (g) => kt(n, g.target.value),
|
|
604
|
+
title: y ?? "Type a new amount, or +500 / -250 to adjust the current one",
|
|
605
|
+
"aria-invalid": n in ye || void 0,
|
|
606
|
+
className: O(
|
|
570
607
|
"h-7 w-32 rounded-md border bg-white text-right text-[12px] tabular-nums outline-none transition-colors placeholder:text-slate-300 focus:border-nvr-cyan dark:bg-background dark:placeholder:text-slate-600",
|
|
571
608
|
t.value_format === "currency" ? "pl-5 pr-2" : "px-2",
|
|
572
|
-
|
|
609
|
+
y ? "border-amber-500 ring-1 ring-amber-500/40" : $ ? "border-nvr-cyan bg-nvr-cyan/[0.06]" : "border-slate-200 dark:border-border"
|
|
573
610
|
)
|
|
574
611
|
}
|
|
612
|
+
),
|
|
613
|
+
y && /* @__PURE__ */ d(
|
|
614
|
+
"span",
|
|
615
|
+
{
|
|
616
|
+
"data-matrix-changed": !0,
|
|
617
|
+
className: "absolute right-0 top-full z-10 mt-0.5 whitespace-nowrap rounded bg-amber-100 px-1.5 py-0.5 text-[10.5px] font-medium text-amber-900 shadow-sm dark:bg-amber-500/20 dark:text-amber-200",
|
|
618
|
+
children: "Changed by someone else"
|
|
619
|
+
}
|
|
575
620
|
)
|
|
576
621
|
]
|
|
577
622
|
}
|
|
@@ -579,52 +624,52 @@ function Ut({
|
|
|
579
624
|
] }) })
|
|
580
625
|
]
|
|
581
626
|
},
|
|
582
|
-
|
|
627
|
+
n
|
|
583
628
|
);
|
|
584
|
-
},
|
|
629
|
+
}, Oe = (e, s, r, l) => /* @__PURE__ */ d(
|
|
585
630
|
"td",
|
|
586
631
|
{
|
|
587
|
-
className:
|
|
632
|
+
className: O(
|
|
588
633
|
"py-1.5 pr-3 text-right tabular-nums",
|
|
589
|
-
|
|
634
|
+
l ? W : "text-slate-600 dark:text-slate-300"
|
|
590
635
|
),
|
|
591
|
-
style:
|
|
592
|
-
children:
|
|
636
|
+
style: J(l),
|
|
637
|
+
children: R(s, r)
|
|
593
638
|
},
|
|
594
639
|
e
|
|
595
|
-
),
|
|
596
|
-
const
|
|
597
|
-
return !
|
|
640
|
+
), Nt = (e) => {
|
|
641
|
+
const s = z.perGroup.get(e);
|
|
642
|
+
return !s || !X || !G.some((r) => (s[r.field] ?? 0) !== 0) ? null : /* @__PURE__ */ x("tr", { className: "border-b border-slate-100 dark:border-border/50", children: [
|
|
598
643
|
/* @__PURE__ */ d(
|
|
599
644
|
"td",
|
|
600
645
|
{
|
|
601
646
|
className: "py-1 pr-3 pl-[18px] italic text-slate-400",
|
|
602
647
|
title: "Spend and commitments on categories outside this project’s list — nothing to allocate here, but they count toward the project total",
|
|
603
|
-
children:
|
|
648
|
+
children: X.option_label ?? "Other categories"
|
|
604
649
|
}
|
|
605
650
|
),
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
651
|
+
ae(null, t.value_format, { tone: "muted" }),
|
|
652
|
+
G.map((r) => Oe(r.field, s[r.field], r.format)),
|
|
653
|
+
K.map((r) => /* @__PURE__ */ d("td", { className: "py-1.5 pr-3 text-right tabular-nums text-slate-400", children: "—" }, r.label)),
|
|
609
654
|
/* @__PURE__ */ d("td", {})
|
|
610
655
|
] }, `${e}|__other__`);
|
|
611
|
-
},
|
|
612
|
-
const r = new Set(
|
|
656
|
+
}, et = (e) => e.label ?? e.field.replace(/_/g, " ").replace(/\b\w/g, (s) => s.toUpperCase()), tt = new Set(k ? Object.keys(_ ?? {}) : []), rt = (e) => Pe((s) => {
|
|
657
|
+
const r = new Set(s);
|
|
613
658
|
return r.has(e) ? r.delete(e) : r.add(e), r;
|
|
614
659
|
});
|
|
615
|
-
return /* @__PURE__ */
|
|
616
|
-
/* @__PURE__ */
|
|
617
|
-
t.scope_fields.filter((e) => !
|
|
618
|
-
const
|
|
619
|
-
return /* @__PURE__ */
|
|
620
|
-
/* @__PURE__ */ d("p", { className: "mb-1 text-[11px] font-medium text-slate-500 dark:text-slate-400", children:
|
|
660
|
+
return /* @__PURE__ */ x("div", { ref: Ke, className: "flex h-full min-h-0 flex-col", "data-matrix-editor": !0, children: [
|
|
661
|
+
/* @__PURE__ */ x("div", { className: "flex shrink-0 flex-wrap items-end gap-3 border-b border-slate-200 bg-white px-4 py-3 dark:border-border dark:bg-card", children: [
|
|
662
|
+
t.scope_fields.filter((e) => !tt.has(e.field)).map((e) => {
|
|
663
|
+
const s = qe(e.filter, b), r = s && !Re(s) ? s : void 0;
|
|
664
|
+
return /* @__PURE__ */ x("div", { className: "w-56", children: [
|
|
665
|
+
/* @__PURE__ */ d("p", { className: "mb-1 text-[11px] font-medium text-slate-500 dark:text-slate-400", children: et(e) }),
|
|
621
666
|
/* @__PURE__ */ d(
|
|
622
|
-
|
|
667
|
+
Mt,
|
|
623
668
|
{
|
|
624
669
|
collection: e.collection,
|
|
625
|
-
value:
|
|
626
|
-
onChange: (
|
|
627
|
-
|
|
670
|
+
value: b[e.field] ?? null,
|
|
671
|
+
onChange: (l) => {
|
|
672
|
+
D((o) => ({ ...o, [e.field]: l })), Ge();
|
|
628
673
|
},
|
|
629
674
|
extraFilter: r,
|
|
630
675
|
placeholder: "Select…"
|
|
@@ -632,91 +677,91 @@ function Ut({
|
|
|
632
677
|
)
|
|
633
678
|
] }, e.field);
|
|
634
679
|
}),
|
|
635
|
-
|
|
636
|
-
|
|
680
|
+
Ne.length > 0 ? /* @__PURE__ */ d(
|
|
681
|
+
Lt,
|
|
637
682
|
{
|
|
638
683
|
className: "min-w-[12rem] flex-1 pb-2",
|
|
639
|
-
editors:
|
|
640
|
-
noun: ((
|
|
641
|
-
rowLabel: (e) =>
|
|
642
|
-
cellLabel: (e) =>
|
|
684
|
+
editors: Ne,
|
|
685
|
+
noun: ((it = t.presence_noun) == null ? void 0 : it.trim()) || t.target_collection.replace(/_/g, " ").toLowerCase(),
|
|
686
|
+
rowLabel: (e) => ht.get(e),
|
|
687
|
+
cellLabel: (e) => Je.current.get(e)
|
|
643
688
|
}
|
|
644
689
|
) : /* @__PURE__ */ d("span", { className: "flex-1" }),
|
|
645
|
-
|
|
646
|
-
|
|
690
|
+
Ae && /* @__PURE__ */ d("span", { className: "pb-2 text-[12px] text-slate-500", children: Ae }),
|
|
691
|
+
He && /* @__PURE__ */ d(
|
|
647
692
|
"button",
|
|
648
693
|
{
|
|
649
694
|
type: "button",
|
|
650
|
-
onClick:
|
|
695
|
+
onClick: Ge,
|
|
651
696
|
className: "h-9 rounded-md px-3 text-[13px] font-medium text-slate-600 hover:bg-slate-100 dark:text-slate-300 dark:hover:bg-muted",
|
|
652
697
|
children: "Discard"
|
|
653
698
|
}
|
|
654
699
|
),
|
|
655
|
-
/* @__PURE__ */
|
|
700
|
+
/* @__PURE__ */ x(
|
|
656
701
|
"button",
|
|
657
702
|
{
|
|
658
703
|
type: "button",
|
|
659
|
-
disabled: !F || !
|
|
660
|
-
onClick: () => void
|
|
704
|
+
disabled: !F || !He || ze,
|
|
705
|
+
onClick: () => void vt(),
|
|
661
706
|
"data-matrix-save": !0,
|
|
662
707
|
className: "inline-flex h-9 items-center gap-1.5 rounded-md bg-nvr-cyan px-3.5 text-[13px] font-semibold text-[#172940] hover:bg-nvr-cyan-dark disabled:opacity-50",
|
|
663
708
|
children: [
|
|
664
|
-
|
|
709
|
+
ze && /* @__PURE__ */ d(ut, { className: "h-3.5 w-3.5 animate-spin" }),
|
|
665
710
|
"Save changes"
|
|
666
711
|
]
|
|
667
712
|
}
|
|
668
713
|
)
|
|
669
714
|
] }),
|
|
670
|
-
|
|
715
|
+
H !== null && F && /* @__PURE__ */ d("div", { className: "grid shrink-0 grid-cols-2 gap-px border-b border-slate-200 bg-slate-200 dark:border-border dark:bg-border sm:grid-cols-4", children: [
|
|
671
716
|
{
|
|
672
|
-
label: ((
|
|
673
|
-
value:
|
|
717
|
+
label: ((ct = t.cap) == null ? void 0 : ct.label) ?? "Cap",
|
|
718
|
+
value: H,
|
|
674
719
|
tone: "plain",
|
|
675
720
|
role: "accent"
|
|
676
721
|
},
|
|
677
722
|
{
|
|
678
723
|
label: "Allocated",
|
|
679
|
-
value:
|
|
680
|
-
tone:
|
|
681
|
-
role:
|
|
682
|
-
sub:
|
|
724
|
+
value: Y.next,
|
|
725
|
+
tone: Y.next !== we ? "edited" : "plain",
|
|
726
|
+
role: Se,
|
|
727
|
+
sub: Y.next !== we ? `was ${R(we, "currency")}` : void 0
|
|
683
728
|
},
|
|
684
729
|
{
|
|
685
730
|
label: "Available to allocate",
|
|
686
|
-
value:
|
|
687
|
-
tone:
|
|
731
|
+
value: $e,
|
|
732
|
+
tone: $e !== null && $e < 0 ? "neg" : "ok"
|
|
688
733
|
},
|
|
689
734
|
{
|
|
690
735
|
label: "Misallocated",
|
|
691
|
-
value:
|
|
692
|
-
tone:
|
|
736
|
+
value: P,
|
|
737
|
+
tone: P > 0 ? "neg" : "muted",
|
|
693
738
|
hint: "Allocations on categories or regions outside this project’s current lists"
|
|
694
739
|
}
|
|
695
|
-
].map((e) => /* @__PURE__ */
|
|
740
|
+
].map((e) => /* @__PURE__ */ x("div", { className: "bg-white px-4 py-2.5 dark:bg-card", title: e.hint, children: [
|
|
696
741
|
/* @__PURE__ */ d("p", { className: "text-[10px] font-semibold uppercase tracking-wide text-slate-400", children: e.label }),
|
|
697
742
|
/* @__PURE__ */ d(
|
|
698
743
|
"p",
|
|
699
744
|
{
|
|
700
|
-
className:
|
|
745
|
+
className: O(
|
|
701
746
|
"mt-0.5 text-[17px] font-semibold tabular-nums tracking-[-0.01em]",
|
|
702
|
-
e.tone === "muted" ? "text-slate-400" :
|
|
747
|
+
e.tone === "muted" ? "text-slate-400" : W
|
|
703
748
|
),
|
|
704
|
-
style:
|
|
749
|
+
style: J(
|
|
705
750
|
e.tone === "neg" ? "negative" : e.tone === "ok" ? "positive" : e.tone === "edited" ? "accent" : e.role ?? "ink"
|
|
706
751
|
),
|
|
707
|
-
children:
|
|
752
|
+
children: R(e.value, "currency")
|
|
708
753
|
}
|
|
709
754
|
),
|
|
710
755
|
e.sub && /* @__PURE__ */ d("p", { className: "text-[11px] text-slate-400", children: e.sub })
|
|
711
756
|
] }, e.label)) }),
|
|
712
|
-
/* @__PURE__ */ d("div", { className: "min-h-0 flex-1 overflow-auto bg-slate-50/60 dark:bg-transparent", children: F ?
|
|
713
|
-
/* @__PURE__ */ d(
|
|
757
|
+
/* @__PURE__ */ d("div", { className: "min-h-0 flex-1 overflow-auto bg-slate-50/60 dark:bg-transparent", children: F ? xt || ge ? /* @__PURE__ */ x("div", { className: "flex items-center gap-2 p-4 text-[12px] text-slate-400", children: [
|
|
758
|
+
/* @__PURE__ */ d(ut, { className: "h-4 w-4 animate-spin" }),
|
|
714
759
|
" Loading…"
|
|
715
|
-
] }) : /* @__PURE__ */
|
|
716
|
-
/* @__PURE__ */ d("thead", { className: "sticky top-0 z-[1] bg-slate-50 dark:bg-background", children: /* @__PURE__ */
|
|
760
|
+
] }) : /* @__PURE__ */ x("table", { className: "w-full text-[12px]", children: [
|
|
761
|
+
/* @__PURE__ */ d("thead", { className: "sticky top-0 z-[1] bg-slate-50 dark:bg-background", children: /* @__PURE__ */ x("tr", { className: "border-b border-slate-200 text-left dark:border-border", children: [
|
|
717
762
|
/* @__PURE__ */ d("th", { className: "px-3 py-2 text-[10.5px] font-semibold uppercase tracking-wide text-slate-400", children: t.option_collection.replace(/_/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()) }),
|
|
718
|
-
/* @__PURE__ */ d("th", { className: "w-32 py-2 pr-3 text-right text-[10.5px] font-semibold uppercase tracking-wide text-slate-400", children:
|
|
719
|
-
|
|
763
|
+
/* @__PURE__ */ d("th", { className: "w-32 py-2 pr-3 text-right text-[10.5px] font-semibold uppercase tracking-wide text-slate-400", children: Xe }),
|
|
764
|
+
G.map((e) => /* @__PURE__ */ d(
|
|
720
765
|
"th",
|
|
721
766
|
{
|
|
722
767
|
className: "w-32 py-2 pr-3 text-right text-[10.5px] font-semibold uppercase tracking-wide text-slate-400",
|
|
@@ -724,7 +769,7 @@ function Ut({
|
|
|
724
769
|
},
|
|
725
770
|
e.field
|
|
726
771
|
)),
|
|
727
|
-
|
|
772
|
+
K.map((e) => /* @__PURE__ */ d(
|
|
728
773
|
"th",
|
|
729
774
|
{
|
|
730
775
|
className: "w-32 py-2 pr-3 text-right text-[10.5px] font-semibold uppercase tracking-wide text-slate-400",
|
|
@@ -732,160 +777,173 @@ function Ut({
|
|
|
732
777
|
},
|
|
733
778
|
e.label
|
|
734
779
|
)),
|
|
735
|
-
/* @__PURE__ */
|
|
780
|
+
/* @__PURE__ */ x("th", { className: "w-44 py-2 pr-3 text-right text-[10.5px] font-semibold uppercase tracking-wide text-slate-400", children: [
|
|
736
781
|
"New ",
|
|
737
|
-
|
|
782
|
+
Xe
|
|
738
783
|
] })
|
|
739
784
|
] }) }),
|
|
740
|
-
/* @__PURE__ */
|
|
741
|
-
|
|
742
|
-
var
|
|
743
|
-
const
|
|
744
|
-
...
|
|
785
|
+
/* @__PURE__ */ x("tbody", { className: "bg-white dark:bg-transparent", children: [
|
|
786
|
+
M.map((e) => {
|
|
787
|
+
var u, i;
|
|
788
|
+
const s = Ue.has(e.id), r = [...v.entries()].filter(([a]) => a.startsWith(`${e.id}|`)).reduce((a, [, m]) => a + m.total, 0), l = Ze(), o = je([
|
|
789
|
+
...l.map((a) => be(e.id, a)),
|
|
745
790
|
...z.perGroup.get(e.id) ? [z.perGroup.get(e.id)] : []
|
|
746
|
-
]),
|
|
791
|
+
]), n = l.reduce((a, m) => a + le(`${e.id}|${m}`), 0) + (r - l.reduce((a, m) => {
|
|
747
792
|
var c;
|
|
748
|
-
return
|
|
793
|
+
return a + (((c = v.get(`${e.id}|${m}`)) == null ? void 0 : c.total) ?? 0);
|
|
749
794
|
}, 0));
|
|
750
795
|
return /* @__PURE__ */ d(
|
|
751
|
-
|
|
796
|
+
bt,
|
|
752
797
|
{
|
|
753
|
-
header:
|
|
798
|
+
header: f ? /* @__PURE__ */ x(
|
|
754
799
|
"tr",
|
|
755
800
|
{
|
|
756
801
|
className: "cursor-pointer border-y border-slate-200 bg-slate-100/70 hover:bg-slate-100 dark:border-border dark:bg-muted/60",
|
|
757
|
-
onClick: () =>
|
|
802
|
+
onClick: () => rt(e.id),
|
|
758
803
|
"data-matrix-group": e.id,
|
|
759
804
|
children: [
|
|
760
|
-
/* @__PURE__ */ d("td", { className: "px-3 py-1.5 text-[12px] font-semibold text-slate-700 dark:text-slate-200", children: /* @__PURE__ */
|
|
805
|
+
/* @__PURE__ */ d("td", { className: "px-3 py-1.5 text-[12px] font-semibold text-slate-700 dark:text-slate-200", children: /* @__PURE__ */ x("span", { className: "inline-flex items-center gap-1.5", children: [
|
|
761
806
|
/* @__PURE__ */ d(
|
|
762
|
-
|
|
807
|
+
mt,
|
|
763
808
|
{
|
|
764
|
-
className:
|
|
809
|
+
className: O(
|
|
765
810
|
"h-3.5 w-3.5 text-slate-400 transition-transform",
|
|
766
|
-
!
|
|
811
|
+
!s && "rotate-90"
|
|
767
812
|
)
|
|
768
813
|
}
|
|
769
814
|
),
|
|
770
815
|
e.label
|
|
771
816
|
] }) }),
|
|
772
|
-
|
|
817
|
+
Ce(r, n, o, !0)
|
|
773
818
|
]
|
|
774
819
|
}
|
|
775
820
|
) : null,
|
|
776
|
-
children: !
|
|
777
|
-
t.option_section ?
|
|
778
|
-
const
|
|
779
|
-
(
|
|
780
|
-
var
|
|
781
|
-
return
|
|
821
|
+
children: !s && /* @__PURE__ */ x(Me, { children: [
|
|
822
|
+
t.option_section ? fe.map((a) => {
|
|
823
|
+
const m = `s:${e.id}|${a.name}`, c = Ue.has(m), h = a.rows.reduce(
|
|
824
|
+
(y, N) => {
|
|
825
|
+
var C;
|
|
826
|
+
return y + (((C = v.get(`${e.id}|${N.key}`)) == null ? void 0 : C.total) ?? 0);
|
|
782
827
|
},
|
|
783
828
|
0
|
|
784
|
-
),
|
|
785
|
-
(
|
|
829
|
+
), $ = a.rows.reduce(
|
|
830
|
+
(y, N) => y + le(`${e.id}|${N.key}`),
|
|
786
831
|
0
|
|
787
|
-
),
|
|
788
|
-
|
|
832
|
+
), S = je(
|
|
833
|
+
a.rows.map((y) => be(e.id, y.key))
|
|
789
834
|
);
|
|
790
835
|
return /* @__PURE__ */ d(
|
|
791
|
-
|
|
836
|
+
bt,
|
|
792
837
|
{
|
|
793
|
-
header: /* @__PURE__ */
|
|
838
|
+
header: /* @__PURE__ */ x(
|
|
794
839
|
"tr",
|
|
795
840
|
{
|
|
796
841
|
className: "cursor-pointer border-b border-slate-100 bg-slate-50/80 hover:bg-slate-50 dark:border-border/50 dark:bg-muted/30",
|
|
797
|
-
onClick: () =>
|
|
842
|
+
onClick: () => rt(m),
|
|
798
843
|
children: [
|
|
799
|
-
/* @__PURE__ */ d("td", { className: "py-1 pr-3 pl-[22px] text-[11.5px] font-medium text-slate-600 dark:text-slate-300", children: /* @__PURE__ */
|
|
844
|
+
/* @__PURE__ */ d("td", { className: "py-1 pr-3 pl-[22px] text-[11.5px] font-medium text-slate-600 dark:text-slate-300", children: /* @__PURE__ */ x("span", { className: "inline-flex items-center gap-1.5", children: [
|
|
800
845
|
/* @__PURE__ */ d(
|
|
801
|
-
|
|
846
|
+
mt,
|
|
802
847
|
{
|
|
803
|
-
className:
|
|
848
|
+
className: O(
|
|
804
849
|
"h-3 w-3 text-slate-400 transition-transform",
|
|
805
850
|
!c && "rotate-90"
|
|
806
851
|
)
|
|
807
852
|
}
|
|
808
853
|
),
|
|
809
|
-
|
|
854
|
+
a.name || "—"
|
|
810
855
|
] }) }),
|
|
811
|
-
|
|
856
|
+
Ce(h, $, S, !1)
|
|
812
857
|
]
|
|
813
858
|
}
|
|
814
859
|
),
|
|
815
|
-
children: !c &&
|
|
816
|
-
(
|
|
860
|
+
children: !c && a.rows.map(
|
|
861
|
+
(y) => he(e.id, y.key, y.label, !1, 2.4)
|
|
817
862
|
)
|
|
818
863
|
},
|
|
819
|
-
|
|
864
|
+
m
|
|
820
865
|
);
|
|
821
|
-
}) :
|
|
822
|
-
((
|
|
866
|
+
}) : q.map((a) => he(e.id, a.key, a.label, !1, 1)),
|
|
867
|
+
((u = t.specials) == null ? void 0 : u.uncategorized) && he(
|
|
823
868
|
e.id,
|
|
824
|
-
|
|
869
|
+
V,
|
|
825
870
|
t.specials.uncategorized.label ?? "Uncategorized",
|
|
826
871
|
!0,
|
|
827
872
|
1
|
|
828
873
|
),
|
|
829
|
-
((
|
|
874
|
+
((i = t.specials) == null ? void 0 : i.bucket) && he(
|
|
830
875
|
e.id,
|
|
831
|
-
|
|
876
|
+
B,
|
|
832
877
|
t.specials.bucket.label ?? "Inventory",
|
|
833
878
|
!0,
|
|
834
879
|
1
|
|
835
880
|
),
|
|
836
|
-
|
|
881
|
+
Nt(e.id)
|
|
837
882
|
] })
|
|
838
883
|
},
|
|
839
884
|
e.id || "__all__"
|
|
840
885
|
);
|
|
841
886
|
}),
|
|
842
|
-
|
|
887
|
+
X && f && z.otherGroupCount > 0 && /* @__PURE__ */ x(
|
|
843
888
|
"tr",
|
|
844
889
|
{
|
|
845
890
|
className: "border-y border-slate-200 bg-slate-100/70 dark:border-border dark:bg-muted/60",
|
|
846
891
|
title: "Spend and commitments on regions outside this project’s list",
|
|
847
892
|
children: [
|
|
848
|
-
/* @__PURE__ */ d("td", { className: "px-3 py-1.5 text-[12px] font-semibold italic text-slate-500", children:
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
(e) =>
|
|
893
|
+
/* @__PURE__ */ d("td", { className: "px-3 py-1.5 text-[12px] font-semibold italic text-slate-500", children: X.group_label ?? "Other regions" }),
|
|
894
|
+
ae(null, t.value_format, { tone: "muted" }),
|
|
895
|
+
G.map(
|
|
896
|
+
(e) => Oe(e.field, z.otherGroup[e.field], e.format)
|
|
852
897
|
),
|
|
853
|
-
|
|
898
|
+
K.map((e) => /* @__PURE__ */ d("td", { className: "py-1.5 pr-3 text-right text-slate-400", children: "—" }, e.label)),
|
|
854
899
|
/* @__PURE__ */ d("td", {})
|
|
855
900
|
]
|
|
856
901
|
}
|
|
857
902
|
)
|
|
858
903
|
] }),
|
|
859
|
-
/* @__PURE__ */ d("tfoot", { className: "sticky bottom-0 bg-white dark:bg-card", children: /* @__PURE__ */
|
|
904
|
+
/* @__PURE__ */ d("tfoot", { className: "sticky bottom-0 bg-white dark:bg-card", children: /* @__PURE__ */ x("tr", { className: "border-t-2 border-slate-300 dark:border-border", children: [
|
|
860
905
|
/* @__PURE__ */ d("td", { className: "px-3 py-2 text-[12px] font-semibold text-slate-800 dark:text-slate-100", children: "Total" }),
|
|
861
|
-
|
|
906
|
+
Ce(Y.current, Y.next, Y.metrics, !0)
|
|
862
907
|
] }) })
|
|
863
|
-
] }) : /* @__PURE__ */
|
|
864
|
-
/* @__PURE__ */
|
|
908
|
+
] }) : /* @__PURE__ */ x("div", { className: "flex h-full flex-col items-center justify-center gap-1 p-8 text-center", children: [
|
|
909
|
+
/* @__PURE__ */ x("p", { className: "text-[13px] font-medium text-slate-600 dark:text-slate-300", children: [
|
|
865
910
|
"Choose",
|
|
866
911
|
" ",
|
|
867
|
-
t.scope_fields.filter((e) => !
|
|
912
|
+
t.scope_fields.filter((e) => !tt.has(e.field)).map(et).join(" and "),
|
|
868
913
|
" ",
|
|
869
914
|
"to load allocations"
|
|
870
915
|
] }),
|
|
871
|
-
/* @__PURE__ */
|
|
916
|
+
/* @__PURE__ */ x("p", { className: "text-[12px] text-slate-400", children: [
|
|
872
917
|
"Amounts are grouped by",
|
|
873
918
|
" ",
|
|
874
|
-
|
|
919
|
+
f != null && f.label_field ? f.collection.replace(/_/g, " ") : "section",
|
|
875
920
|
" and saved together."
|
|
876
921
|
] })
|
|
877
922
|
] }) })
|
|
878
923
|
] });
|
|
879
924
|
}
|
|
880
|
-
function
|
|
925
|
+
function bt({
|
|
881
926
|
header: t,
|
|
882
927
|
children: _
|
|
883
928
|
}) {
|
|
884
|
-
return /* @__PURE__ */
|
|
929
|
+
return /* @__PURE__ */ x(Me, { children: [
|
|
885
930
|
t,
|
|
886
931
|
_
|
|
887
932
|
] });
|
|
888
933
|
}
|
|
934
|
+
function zt(t, _, k, p, w, b) {
|
|
935
|
+
if (t) {
|
|
936
|
+
const D = Number(_);
|
|
937
|
+
return `Someone else saved ${_ == null ? "empty" : Number.isFinite(D) ? b(D) : String(_)} here since you started. Save again to keep yours, or clear the cell to take theirs.`;
|
|
938
|
+
}
|
|
939
|
+
return w && k !== void 0 && k !== p ? `Someone else changed this from ${b(k)} to ${b(p)} since you started.` : null;
|
|
940
|
+
}
|
|
941
|
+
function Tt(t, _, k) {
|
|
942
|
+
const p = `Saved — ${t} updated, ${_} created`;
|
|
943
|
+
return k === 0 ? p : `${p}. ${k} cell${k === 1 ? " was" : "s were"} changed by someone else — check the outlined cells.`;
|
|
944
|
+
}
|
|
889
945
|
export {
|
|
890
|
-
|
|
946
|
+
tr as MatrixEditor,
|
|
947
|
+
zt as matrixCellNote,
|
|
948
|
+
Tt as matrixSaveStatus
|
|
891
949
|
};
|