@nivaro/react 0.3.127 → 0.3.128
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 +20 -2
- 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 +4203 -4156
- 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/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/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/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 +168 -151
- 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,19 +1,21 @@
|
|
|
1
|
-
import { jsx as l, jsxs as
|
|
2
|
-
import { useQueryClient as
|
|
3
|
-
import { Loader2 as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { useNivaroClient as
|
|
6
|
-
import { get as
|
|
7
|
-
import { useGridPresence as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
1
|
+
import { jsx as l, jsxs as u, Fragment as He } from "react/jsx-runtime";
|
|
2
|
+
import { useQueryClient as Re, useQuery as ve, keepPreviousData as Xe } from "@tanstack/react-query";
|
|
3
|
+
import { Loader2 as _e, X as Me, ChevronRight as Ze } from "lucide-react";
|
|
4
|
+
import { useState as k, useMemo as Q, useCallback as Ye, useRef as et, useEffect as je } from "react";
|
|
5
|
+
import { useNivaroClient as Ae } from "../context.js";
|
|
6
|
+
import { get as xe, post as Se, del as Ee } from "../lib/commands.js";
|
|
7
|
+
import { useGridPresence as tt, gridPageKey as rt, gridPresenceCell as lt } from "../lib/grid-presence.js";
|
|
8
|
+
import { liveQueryMeta as Fe } from "../lib/live-queries.js";
|
|
9
|
+
import { userErrorMessage as Le } from "../lib/safe-error.js";
|
|
10
|
+
import { cn as Y } from "../lib/utils.js";
|
|
11
|
+
import { GridPresenceLine as at } from "./GridPresenceLine.js";
|
|
12
|
+
import { ChangeReasonDialog as De, changeReasonChallenge as ze } from "./item-edit/ChangeReasonDialog.js";
|
|
13
|
+
import { applyDisplayTemplate as st } from "./item-edit/helpers.js";
|
|
14
|
+
import { RelationCombobox as qe } from "./item-edit/RelationCombobox.js";
|
|
15
|
+
import { JsonMapEditor as ot } from "./JsonMapEditor.js";
|
|
16
|
+
import { colorPair as nt } from "./QueryTable.js";
|
|
17
|
+
import { GridRowGuard as Pe, takeTheirs as Ge, gridRowPatch as Ke, conflictsOf as Ve, settleDraftAfterSave as Je } from "./record-grid-guard.js";
|
|
18
|
+
const ee = [
|
|
17
19
|
"january",
|
|
18
20
|
"february",
|
|
19
21
|
"march",
|
|
@@ -26,7 +28,7 @@ const U = [
|
|
|
26
28
|
"october",
|
|
27
29
|
"november",
|
|
28
30
|
"december"
|
|
29
|
-
],
|
|
31
|
+
], Ue = [
|
|
30
32
|
"Jan",
|
|
31
33
|
"Feb",
|
|
32
34
|
"Mar",
|
|
@@ -40,661 +42,766 @@ const U = [
|
|
|
40
42
|
"Nov",
|
|
41
43
|
"Dec"
|
|
42
44
|
];
|
|
43
|
-
function
|
|
44
|
-
return typeof t == "string" && t.startsWith("$scope.") ?
|
|
45
|
-
Object.entries(t).map(([
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
function pe(t, i) {
|
|
46
|
+
return typeof t == "string" && t.startsWith("$scope.") ? i[t.slice(7)] : Array.isArray(t) ? t.map((g) => pe(g, i)) : t && typeof t == "object" ? Object.fromEntries(
|
|
47
|
+
Object.entries(t).map(([g, c]) => [
|
|
48
|
+
g,
|
|
49
|
+
pe(c, i)
|
|
48
50
|
])
|
|
49
51
|
) : t;
|
|
50
52
|
}
|
|
51
|
-
function
|
|
52
|
-
return t === void 0 ? !0 : Array.isArray(t) ? t.some(
|
|
53
|
+
function $e(t) {
|
|
54
|
+
return t === void 0 ? !0 : Array.isArray(t) ? t.some($e) : t && typeof t == "object" ? Object.values(t).some($e) : !1;
|
|
53
55
|
}
|
|
54
|
-
function
|
|
55
|
-
|
|
56
|
+
function Be(t) {
|
|
57
|
+
const i = Number(t);
|
|
58
|
+
return `Someone else saved ${t == null || t === "" ? "empty" : Number.isFinite(i) ? i.toLocaleString("en-US", { maximumFractionDigits: 2 }) : String(t)} here since you started. Save again to keep yours, or take theirs.`;
|
|
59
|
+
}
|
|
60
|
+
function Ie(t, i, g, c) {
|
|
61
|
+
const m = `Saved — ${t} updated, ${i} created${g ? `, ${g} deleted` : ""}`, x = Object.keys(c).length;
|
|
62
|
+
return x === 0 ? m : `${m}. ${x} row${x === 1 ? " was" : "s were"} changed by someone else — check the outlined cells.`;
|
|
63
|
+
}
|
|
64
|
+
function Qe({ count: t, onClick: i }) {
|
|
65
|
+
return /* @__PURE__ */ u(
|
|
66
|
+
"button",
|
|
67
|
+
{
|
|
68
|
+
type: "button",
|
|
69
|
+
onClick: i,
|
|
70
|
+
"data-record-grid-take-theirs": !0,
|
|
71
|
+
className: "h-9 rounded-md border border-amber-400 bg-amber-50 px-3 text-[13px] font-medium text-amber-800 hover:bg-amber-100 dark:border-amber-500/60 dark:bg-amber-500/10 dark:text-amber-200 dark:hover:bg-amber-500/20",
|
|
72
|
+
children: [
|
|
73
|
+
"Take theirs (",
|
|
74
|
+
t,
|
|
75
|
+
")"
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
);
|
|
56
79
|
}
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
80
|
+
function qt({ config: t }) {
|
|
81
|
+
return t.browse ? /* @__PURE__ */ l(ut, { config: t }) : /* @__PURE__ */ l(dt, { config: t });
|
|
82
|
+
}
|
|
83
|
+
function dt({ config: t }) {
|
|
84
|
+
var ue, we;
|
|
85
|
+
const i = Ae(), g = Re(), [c, m] = k({}), [x, C] = k({}), [M, w] = k([]), [O, v] = k(/* @__PURE__ */ new Set()), [j, re] = k(!1), [le, U] = k(null), [R, ae] = k(null), [z, W] = k(null), [K, B] = k({}), p = Q(
|
|
86
|
+
() => new Pe(i, t.collection),
|
|
87
|
+
[i, t.collection]
|
|
88
|
+
), T = (t.scope ?? []).every(
|
|
89
|
+
(r) => c[r.field] !== null && c[r.field] !== void 0 && c[r.field] !== ""
|
|
90
|
+
), _ = JSON.stringify(c), ye = Q(() => {
|
|
62
91
|
const r = [];
|
|
63
|
-
for (const o of t.month_sets ?? []) for (const
|
|
92
|
+
for (const o of t.month_sets ?? []) for (const d of ee) r.push(`${d}${o.suffix}`);
|
|
64
93
|
for (const o of t.columns ?? []) r.push(o.field);
|
|
65
94
|
return r;
|
|
66
|
-
}, [t]), {
|
|
95
|
+
}, [t]), {
|
|
96
|
+
data: se = [],
|
|
97
|
+
isLoading: ke,
|
|
98
|
+
isPlaceholderData: L
|
|
99
|
+
} = ve({
|
|
67
100
|
queryKey: ["record-grid-rows", t.collection, _],
|
|
68
101
|
queryFn: () => {
|
|
69
102
|
const r = {};
|
|
70
|
-
for (const o of t.scope ?? []) r[o.field] = { _eq:
|
|
71
|
-
return
|
|
72
|
-
|
|
103
|
+
for (const o of t.scope ?? []) r[o.field] = { _eq: c[o.field] };
|
|
104
|
+
return i.request(
|
|
105
|
+
xe(`/items/${t.collection}`, {
|
|
73
106
|
limit: 2e3,
|
|
74
107
|
...Object.keys(r).length ? { filter: JSON.stringify(r) } : {}
|
|
75
108
|
})
|
|
76
109
|
).then((o) => o.data ?? []);
|
|
77
110
|
},
|
|
78
|
-
enabled:
|
|
79
|
-
staleTime: 1e4
|
|
80
|
-
|
|
81
|
-
|
|
111
|
+
enabled: T,
|
|
112
|
+
staleTime: 1e4,
|
|
113
|
+
// R1: someone else's save shows up here (the draft stays on top of it).
|
|
114
|
+
meta: Fe({ reads: [t.collection], minGapMs: 2e3 }),
|
|
115
|
+
// A new scope keeps the old rows (dimmed, not editable) until its own arrive — no blank grid.
|
|
116
|
+
placeholderData: Xe
|
|
117
|
+
});
|
|
118
|
+
je(() => {
|
|
119
|
+
L || p.noteRows(se);
|
|
120
|
+
}, [p, se, L]);
|
|
121
|
+
const { data: P = [] } = ve({
|
|
122
|
+
queryKey: ["record-grid-source", (ue = t.row_source) == null ? void 0 : ue.collection, _],
|
|
82
123
|
queryFn: () => {
|
|
83
124
|
const r = t.row_source;
|
|
84
125
|
if (!r) return Promise.resolve([]);
|
|
85
|
-
const o =
|
|
86
|
-
return
|
|
87
|
-
|
|
126
|
+
const o = pe(r.filter, c), d = o && !$e(o) ? o : void 0;
|
|
127
|
+
return i.request(
|
|
128
|
+
xe(`/items/${r.collection}`, {
|
|
88
129
|
limit: 1e3,
|
|
89
130
|
...r.sort ? { sort: r.sort } : {},
|
|
90
|
-
...
|
|
131
|
+
...d ? { filter: JSON.stringify(d) } : {}
|
|
91
132
|
})
|
|
92
133
|
).then((f) => f.data ?? []);
|
|
93
134
|
},
|
|
94
|
-
enabled:
|
|
135
|
+
enabled: T && !!t.row_source,
|
|
95
136
|
staleTime: 3e4
|
|
96
|
-
}),
|
|
137
|
+
}), oe = Q(() => {
|
|
97
138
|
if (t.row_source) {
|
|
98
139
|
const r = t.row_source;
|
|
99
|
-
return
|
|
100
|
-
const
|
|
140
|
+
return P.map((o) => {
|
|
141
|
+
const d = se.find((f) => String(f[r.fk_field]) === String(o.id)) ?? null;
|
|
101
142
|
return {
|
|
102
143
|
key: `src-${o.id}`,
|
|
103
|
-
record:
|
|
144
|
+
record: d,
|
|
104
145
|
sourceId: o.id,
|
|
105
146
|
sourceLabel: String(o[r.label_field] ?? o.id),
|
|
106
|
-
isNew: !
|
|
147
|
+
isNew: !d
|
|
107
148
|
};
|
|
108
149
|
});
|
|
109
150
|
}
|
|
110
151
|
return [
|
|
111
|
-
...
|
|
112
|
-
...
|
|
152
|
+
...se.filter((r) => !O.has(String(r.id))).map((r) => ({ key: `rec-${r.id}`, record: r, isNew: !1 })),
|
|
153
|
+
...M.map((r) => ({ key: r, record: null, isNew: !0 }))
|
|
113
154
|
];
|
|
114
|
-
}, [t.row_source,
|
|
115
|
-
var
|
|
116
|
-
const
|
|
117
|
-
if (
|
|
118
|
-
const f = (
|
|
155
|
+
}, [t.row_source, P, se, M, O]), S = (r, o) => {
|
|
156
|
+
var N, H;
|
|
157
|
+
const d = (N = x[r.key]) == null ? void 0 : N[o];
|
|
158
|
+
if (d !== void 0) return d;
|
|
159
|
+
const f = (H = r.record) == null ? void 0 : H[o];
|
|
119
160
|
return f == null ? "" : String(f);
|
|
120
|
-
},
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
161
|
+
}, ie = (r, o, d) => {
|
|
162
|
+
var f;
|
|
163
|
+
((f = r.record) == null ? void 0 : f.id) != null && p.pin(String(r.record.id)), C((N) => ({ ...N, [r.key]: { ...N[r.key] ?? {}, [o]: d } }));
|
|
164
|
+
}, D = Object.values(x).some((r) => Object.keys(r).length > 0) || M.length > 0 || O.size > 0, fe = Object.values(K).reduce((r, o) => r + Object.keys(o).length, 0);
|
|
165
|
+
async function ge(r) {
|
|
166
|
+
var he;
|
|
167
|
+
re(!0), ae(null);
|
|
168
|
+
let o = 0, d = 0, f = 0;
|
|
169
|
+
const N = {}, H = (q) => ye.includes(q) || (t.key_columns ?? []).some((G) => G.field === q), Ne = (he = t.month_sets) == null ? void 0 : he[0], ne = t.computed_total_field && Ne ? {
|
|
170
|
+
field: t.computed_total_field,
|
|
171
|
+
of: ee.map((q) => `${q}${Ne.suffix}`)
|
|
172
|
+
} : null;
|
|
125
173
|
try {
|
|
126
|
-
for (const
|
|
127
|
-
const
|
|
128
|
-
if (!
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
} else {
|
|
144
|
-
if (!ie) continue;
|
|
145
|
-
for (const A of t.scope ?? []) L[A.field] = i[A.field];
|
|
146
|
-
t.row_source && (L[t.row_source.fk_field] = x.sourceId), await m.request(be(`/items/${t.collection}`, L)), o++;
|
|
147
|
-
}
|
|
174
|
+
for (const y of oe) {
|
|
175
|
+
const A = x[y.key] ?? {}, X = Object.keys(A).length > 0;
|
|
176
|
+
if (!(!y.record && !X))
|
|
177
|
+
if (y.record) {
|
|
178
|
+
const E = Ke(A, y.record, H, ne);
|
|
179
|
+
if (!E) continue;
|
|
180
|
+
r && (E._change_reason = r);
|
|
181
|
+
const F = await p.write(String(y.record.id), E);
|
|
182
|
+
F.ok ? d++ : Object.assign(N, Ve(y.key, F.conflicts));
|
|
183
|
+
} else {
|
|
184
|
+
const E = {};
|
|
185
|
+
for (const [F, I] of Object.entries(A))
|
|
186
|
+
H(F) && (E[F] = I === "" ? null : Number.isNaN(Number(I)) ? I : Number(I));
|
|
187
|
+
if (ne && (E[ne.field] = ne.of.reduce((F, I) => F + (Number(A[I]) || 0), 0)), !X) continue;
|
|
188
|
+
for (const F of t.scope ?? []) E[F.field] = c[F.field];
|
|
189
|
+
t.row_source && (E[t.row_source.fk_field] = y.sourceId), await i.request(Se(`/items/${t.collection}`, E)), o++;
|
|
190
|
+
}
|
|
148
191
|
}
|
|
149
|
-
for (const
|
|
150
|
-
await
|
|
151
|
-
if (t.after_save) {
|
|
152
|
-
const
|
|
153
|
-
await
|
|
154
|
-
|
|
192
|
+
for (const y of O)
|
|
193
|
+
await i.request(Ee(`/items/${t.collection}/${y}`)), f++;
|
|
194
|
+
if (t.after_save && d + o + f > 0) {
|
|
195
|
+
const y = pe(t.after_save.params ?? {}, c);
|
|
196
|
+
await i.request(
|
|
197
|
+
Se(`/custom-queries/${t.after_save.query_slug}/execute`, { params: y })
|
|
155
198
|
);
|
|
156
199
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
200
|
+
const q = new Set(M), G = new Set(O);
|
|
201
|
+
C((y) => {
|
|
202
|
+
const A = Je(y, x, new Set(Object.keys(N)));
|
|
203
|
+
for (const X of q) delete A[X];
|
|
204
|
+
return A;
|
|
205
|
+
}), B(N), w((y) => y.filter((A) => !q.has(A))), v((y) => new Set([...y].filter((A) => !G.has(A)))), await g.invalidateQueries({ queryKey: ["record-grid-rows", t.collection] }), ae(Ie(d, o, f, N));
|
|
206
|
+
} catch (q) {
|
|
207
|
+
const G = ze(q);
|
|
208
|
+
G ? (U(G), ae(null)) : ae(`Save failed: ${Le(q, "unknown error")}`);
|
|
163
209
|
} finally {
|
|
164
|
-
|
|
210
|
+
re(!1);
|
|
165
211
|
}
|
|
166
212
|
}
|
|
167
|
-
const
|
|
213
|
+
const ce = [
|
|
168
214
|
...(t.month_sets ?? []).flatMap(
|
|
169
|
-
(r) =>
|
|
215
|
+
(r) => ee.map((o, d) => ({ field: `${o}${r.suffix}`, label: `${Ue[d]} ${r.label}` }))
|
|
170
216
|
),
|
|
171
217
|
...(t.columns ?? []).map((r) => ({ field: r.field, label: r.label ?? r.field }))
|
|
172
218
|
];
|
|
173
|
-
return /* @__PURE__ */
|
|
219
|
+
return /* @__PURE__ */ u("div", { className: "flex h-full flex-col gap-3 overflow-auto p-3", children: [
|
|
174
220
|
/* @__PURE__ */ l(
|
|
175
|
-
|
|
221
|
+
De,
|
|
176
222
|
{
|
|
177
|
-
challenge:
|
|
178
|
-
onCancel: () =>
|
|
223
|
+
challenge: le,
|
|
224
|
+
onCancel: () => U(null),
|
|
179
225
|
onSubmit: (r) => {
|
|
180
|
-
|
|
226
|
+
U(null), ge(r);
|
|
181
227
|
}
|
|
182
228
|
}
|
|
183
229
|
),
|
|
184
|
-
/* @__PURE__ */
|
|
230
|
+
/* @__PURE__ */ u("div", { className: "flex flex-wrap items-end gap-3", children: [
|
|
185
231
|
(t.scope ?? []).map((r) => {
|
|
186
|
-
const o =
|
|
187
|
-
return /* @__PURE__ */
|
|
232
|
+
const o = pe(r.filter, c), d = o && !$e(o) ? o : void 0;
|
|
233
|
+
return /* @__PURE__ */ u("div", { className: "w-52", children: [
|
|
188
234
|
/* @__PURE__ */ l("p", { className: "mb-1 text-[11px] font-medium text-slate-500", children: r.label ?? r.field.replace(/_/g, " ").replace(/\b\w/g, (f) => f.toUpperCase()) }),
|
|
189
235
|
/* @__PURE__ */ l(
|
|
190
|
-
|
|
236
|
+
qe,
|
|
191
237
|
{
|
|
192
238
|
collection: r.collection,
|
|
193
|
-
value:
|
|
239
|
+
value: c[r.field] ?? null,
|
|
194
240
|
onChange: (f) => {
|
|
195
|
-
|
|
241
|
+
m((N) => ({ ...N, [r.field]: f })), C({}), w([]), v(/* @__PURE__ */ new Set()), B({}), p.release();
|
|
196
242
|
},
|
|
197
|
-
extraFilter:
|
|
243
|
+
extraFilter: d,
|
|
198
244
|
placeholder: "Select…"
|
|
199
245
|
}
|
|
200
246
|
)
|
|
201
247
|
] }, r.field);
|
|
202
248
|
}),
|
|
203
|
-
/* @__PURE__ */
|
|
249
|
+
/* @__PURE__ */ u(
|
|
204
250
|
"button",
|
|
205
251
|
{
|
|
206
252
|
type: "button",
|
|
207
|
-
disabled: !
|
|
208
|
-
onClick: () => void
|
|
253
|
+
disabled: !T || !D || j,
|
|
254
|
+
onClick: () => void ge(),
|
|
209
255
|
className: "inline-flex h-9 items-center gap-1.5 rounded-md bg-nvr-cyan px-3 text-[13px] font-medium text-white hover:brightness-110 disabled:opacity-50",
|
|
210
256
|
children: [
|
|
211
|
-
|
|
257
|
+
j && /* @__PURE__ */ l(_e, { className: "h-3.5 w-3.5 animate-spin" }),
|
|
212
258
|
"Save changes"
|
|
213
259
|
]
|
|
214
260
|
}
|
|
215
261
|
),
|
|
216
|
-
t.allow_add &&
|
|
262
|
+
t.allow_add && T && /* @__PURE__ */ l(
|
|
217
263
|
"button",
|
|
218
264
|
{
|
|
219
265
|
type: "button",
|
|
220
|
-
onClick: () =>
|
|
266
|
+
onClick: () => w((r) => [...r, `new-${r.length}-${Math.random().toString(36).slice(2, 8)}`]),
|
|
221
267
|
className: "inline-flex h-9 items-center rounded-md border border-slate-200 bg-white px-3 text-[13px] text-slate-700 hover:border-slate-400 dark:border-border dark:bg-card dark:text-slate-200",
|
|
222
268
|
children: "+ Add row"
|
|
223
269
|
}
|
|
224
270
|
),
|
|
225
271
|
(t.toolbar_editors ?? []).map((r, o) => {
|
|
226
|
-
const
|
|
227
|
-
(f) =>
|
|
272
|
+
const d = (r.require_scope ?? []).every(
|
|
273
|
+
(f) => c[f] !== null && c[f] !== void 0 && c[f] !== ""
|
|
228
274
|
);
|
|
229
275
|
return /* @__PURE__ */ l(
|
|
230
276
|
"button",
|
|
231
277
|
{
|
|
232
278
|
type: "button",
|
|
233
|
-
disabled: !
|
|
234
|
-
title:
|
|
235
|
-
onClick: () =>
|
|
279
|
+
disabled: !d,
|
|
280
|
+
title: d ? void 0 : `Choose ${(r.require_scope ?? []).join(", ")} first`,
|
|
281
|
+
onClick: () => W(o),
|
|
236
282
|
className: "inline-flex h-9 items-center rounded-md border border-slate-200 bg-white px-3 text-[13px] text-slate-700 hover:border-slate-400 disabled:opacity-50 dark:border-border dark:bg-card dark:text-slate-200",
|
|
237
283
|
children: r.button_label
|
|
238
284
|
},
|
|
239
285
|
r.button_label
|
|
240
286
|
);
|
|
241
287
|
}),
|
|
242
|
-
|
|
288
|
+
R && /* @__PURE__ */ l("span", { className: "pb-2 text-[12px] text-slate-500", children: R }),
|
|
289
|
+
fe > 0 && /* @__PURE__ */ l(
|
|
290
|
+
Qe,
|
|
291
|
+
{
|
|
292
|
+
count: fe,
|
|
293
|
+
onClick: () => {
|
|
294
|
+
C((r) => Ge(r, K)), B({});
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
)
|
|
243
298
|
] }),
|
|
244
|
-
|
|
299
|
+
z !== null && ((we = t.toolbar_editors) == null ? void 0 : we[z]) && /* @__PURE__ */ l(
|
|
245
300
|
"div",
|
|
246
301
|
{
|
|
247
302
|
className: "fixed inset-0 z-[60] flex justify-end bg-black/30",
|
|
248
|
-
onClick: () =>
|
|
249
|
-
children: /* @__PURE__ */
|
|
303
|
+
onClick: () => W(null),
|
|
304
|
+
children: /* @__PURE__ */ u(
|
|
250
305
|
"div",
|
|
251
306
|
{
|
|
252
307
|
className: "flex h-full flex-col border-l border-slate-200 bg-white shadow-2xl dark:border-border dark:bg-background",
|
|
253
308
|
style: {
|
|
254
|
-
width: typeof t.toolbar_editors[
|
|
309
|
+
width: typeof t.toolbar_editors[z].sheet_width == "number" ? `${t.toolbar_editors[z].sheet_width}px` : t.toolbar_editors[z].sheet_width ?? "70%",
|
|
255
310
|
maxWidth: "96%"
|
|
256
311
|
},
|
|
257
312
|
onClick: (r) => r.stopPropagation(),
|
|
258
313
|
children: [
|
|
259
|
-
/* @__PURE__ */
|
|
260
|
-
/* @__PURE__ */ l("p", { className: "text-[13px] font-semibold text-slate-700 dark:text-slate-200", children: t.toolbar_editors[
|
|
314
|
+
/* @__PURE__ */ u("div", { className: "flex shrink-0 items-center justify-between border-b border-slate-200 px-4 py-2.5 dark:border-border", children: [
|
|
315
|
+
/* @__PURE__ */ l("p", { className: "text-[13px] font-semibold text-slate-700 dark:text-slate-200", children: t.toolbar_editors[z].button_label }),
|
|
261
316
|
/* @__PURE__ */ l(
|
|
262
317
|
"button",
|
|
263
318
|
{
|
|
264
319
|
type: "button",
|
|
265
|
-
onClick: () =>
|
|
320
|
+
onClick: () => W(null),
|
|
266
321
|
className: "rounded px-2 py-1 text-[12px] text-slate-500 hover:bg-slate-100 hover:text-slate-700 dark:hover:bg-muted",
|
|
267
322
|
children: "Close"
|
|
268
323
|
}
|
|
269
324
|
)
|
|
270
325
|
] }),
|
|
271
|
-
/* @__PURE__ */ l("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ l(
|
|
326
|
+
/* @__PURE__ */ l("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ l(ot, { config: t.toolbar_editors[z].json_map, scope: c }) })
|
|
272
327
|
]
|
|
273
328
|
}
|
|
274
329
|
)
|
|
275
330
|
}
|
|
276
331
|
),
|
|
277
|
-
|
|
278
|
-
/* @__PURE__ */ l(
|
|
332
|
+
T ? ke ? /* @__PURE__ */ u("div", { className: "flex items-center gap-2 text-[12px] text-slate-400", children: [
|
|
333
|
+
/* @__PURE__ */ l(_e, { className: "h-4 w-4 animate-spin" }),
|
|
279
334
|
" Loading…"
|
|
280
|
-
] }) : /* @__PURE__ */ l(
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
children:
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
{
|
|
294
|
-
className: "min-w-[86px] py-1.5 pr-2 text-right font-medium text-slate-500",
|
|
295
|
-
children: r.label
|
|
296
|
-
},
|
|
297
|
-
r.field
|
|
298
|
-
)),
|
|
299
|
-
t.allow_delete && /* @__PURE__ */ l("th", { "aria-label": "Remove" })
|
|
300
|
-
] }) }),
|
|
301
|
-
/* @__PURE__ */ c("tbody", { children: [
|
|
302
|
-
j.map((r) => /* @__PURE__ */ c("tr", { className: "border-b border-slate-100 dark:border-border/50", children: [
|
|
303
|
-
t.row_source && /* @__PURE__ */ c("td", { className: "whitespace-nowrap py-1 pr-3 font-medium text-slate-700 dark:text-slate-200", children: [
|
|
304
|
-
r.sourceLabel,
|
|
305
|
-
r.isNew && /* @__PURE__ */ l("span", { className: "ml-1.5 text-[10px] text-slate-400", children: "(new)" })
|
|
306
|
-
] }),
|
|
307
|
-
(t.key_columns ?? []).map((o) => /* @__PURE__ */ l("td", { className: "py-1 pr-3", children: /* @__PURE__ */ l(
|
|
308
|
-
ye,
|
|
309
|
-
{
|
|
310
|
-
collection: o.collection,
|
|
311
|
-
value: B(r, o.field) || null,
|
|
312
|
-
onChange: (n) => w(r.key, o.field, n == null ? "" : String(n)),
|
|
313
|
-
placeholder: "Select…"
|
|
314
|
-
}
|
|
315
|
-
) }, o.field)),
|
|
316
|
-
te.map((o) => /* @__PURE__ */ l("td", { className: "py-0.5 pr-2 text-right", children: /* @__PURE__ */ l(
|
|
317
|
-
"input",
|
|
318
|
-
{
|
|
319
|
-
type: "number",
|
|
320
|
-
min: t.allow_negative ? void 0 : 0,
|
|
321
|
-
value: B(r, o.field),
|
|
322
|
-
title: t.allow_negative ? void 0 : Ee,
|
|
323
|
-
onChange: (n) => {
|
|
324
|
-
!t.allow_negative && n.target.value.trim().startsWith("-") || w(r.key, o.field, n.target.value);
|
|
335
|
+
] }) : /* @__PURE__ */ l(
|
|
336
|
+
"div",
|
|
337
|
+
{
|
|
338
|
+
className: Y("overflow-x-auto transition-opacity", L && "opacity-60"),
|
|
339
|
+
"aria-busy": L || void 0,
|
|
340
|
+
children: /* @__PURE__ */ u("table", { className: "w-full text-[12px]", children: [
|
|
341
|
+
/* @__PURE__ */ l("thead", { children: /* @__PURE__ */ u("tr", { className: "border-b border-slate-200 text-left dark:border-border", children: [
|
|
342
|
+
t.row_source && /* @__PURE__ */ l("th", { className: "py-1.5 pr-3 font-medium text-slate-500", children: t.row_source.label_field.replace(/_/g, " ") }),
|
|
343
|
+
(t.key_columns ?? []).map((r) => /* @__PURE__ */ l(
|
|
344
|
+
"th",
|
|
345
|
+
{
|
|
346
|
+
className: "min-w-[140px] py-1.5 pr-3 font-medium text-slate-500",
|
|
347
|
+
children: r.label ?? r.field
|
|
325
348
|
},
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
onClick: () => {
|
|
334
|
-
r.record ? y((o) => {
|
|
335
|
-
var n;
|
|
336
|
-
return new Set(o).add(String((n = r.record) == null ? void 0 : n.id));
|
|
337
|
-
}) : q((o) => o.filter((n) => n !== r.key)), g((o) => {
|
|
338
|
-
const n = { ...o };
|
|
339
|
-
return delete n[r.key], n;
|
|
340
|
-
});
|
|
349
|
+
r.field
|
|
350
|
+
)),
|
|
351
|
+
ce.map((r) => /* @__PURE__ */ l(
|
|
352
|
+
"th",
|
|
353
|
+
{
|
|
354
|
+
className: "min-w-[86px] py-1.5 pr-2 text-right font-medium text-slate-500",
|
|
355
|
+
children: r.label
|
|
341
356
|
},
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
}
|
|
345
|
-
) })
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
357
|
+
r.field
|
|
358
|
+
)),
|
|
359
|
+
t.allow_delete && /* @__PURE__ */ l("th", { "aria-label": "Remove" })
|
|
360
|
+
] }) }),
|
|
361
|
+
/* @__PURE__ */ u("tbody", { children: [
|
|
362
|
+
oe.map((r) => /* @__PURE__ */ u("tr", { className: "border-b border-slate-100 dark:border-border/50", children: [
|
|
363
|
+
t.row_source && /* @__PURE__ */ u("td", { className: "whitespace-nowrap py-1 pr-3 font-medium text-slate-700 dark:text-slate-200", children: [
|
|
364
|
+
r.sourceLabel,
|
|
365
|
+
r.isNew && /* @__PURE__ */ l("span", { className: "ml-1.5 text-[10px] text-slate-400", children: "(new)" })
|
|
366
|
+
] }),
|
|
367
|
+
(t.key_columns ?? []).map((o) => /* @__PURE__ */ l("td", { className: "py-1 pr-3", children: /* @__PURE__ */ l(
|
|
368
|
+
qe,
|
|
369
|
+
{
|
|
370
|
+
collection: o.collection,
|
|
371
|
+
value: S(r, o.field) || null,
|
|
372
|
+
onChange: (d) => ie(r, o.field, d == null ? "" : String(d)),
|
|
373
|
+
placeholder: "Select…"
|
|
374
|
+
}
|
|
375
|
+
) }, o.field)),
|
|
376
|
+
ce.map((o) => /* @__PURE__ */ l("td", { className: "py-0.5 pr-2 text-right", children: /* @__PURE__ */ l(
|
|
377
|
+
"input",
|
|
378
|
+
{
|
|
379
|
+
type: "number",
|
|
380
|
+
min: t.allow_negative ? void 0 : 0,
|
|
381
|
+
value: S(r, o.field),
|
|
382
|
+
disabled: L,
|
|
383
|
+
"aria-invalid": o.field in (K[r.key] ?? {}) || void 0,
|
|
384
|
+
title: o.field in (K[r.key] ?? {}) ? Be(K[r.key][o.field]) : t.allow_negative ? void 0 : We,
|
|
385
|
+
onChange: (d) => {
|
|
386
|
+
!t.allow_negative && d.target.value.trim().startsWith("-") || ie(r, o.field, d.target.value);
|
|
387
|
+
},
|
|
388
|
+
className: Y(
|
|
389
|
+
"h-7 w-[84px] rounded border bg-white px-1.5 text-right text-[12px] tabular-nums outline-none focus:border-nvr-cyan dark:bg-background",
|
|
390
|
+
o.field in (K[r.key] ?? {}) ? "border-amber-500 ring-1 ring-amber-500/40" : "border-slate-200 dark:border-border"
|
|
391
|
+
)
|
|
392
|
+
}
|
|
393
|
+
) }, o.field)),
|
|
394
|
+
t.allow_delete && /* @__PURE__ */ l("td", { className: "py-1 pl-2", children: /* @__PURE__ */ l(
|
|
395
|
+
"button",
|
|
396
|
+
{
|
|
397
|
+
type: "button",
|
|
398
|
+
onClick: () => {
|
|
399
|
+
r.record ? v((o) => {
|
|
400
|
+
var d;
|
|
401
|
+
return new Set(o).add(String((d = r.record) == null ? void 0 : d.id));
|
|
402
|
+
}) : w((o) => o.filter((d) => d !== r.key)), C((o) => {
|
|
403
|
+
const d = { ...o };
|
|
404
|
+
return delete d[r.key], d;
|
|
405
|
+
});
|
|
406
|
+
},
|
|
407
|
+
className: "rounded px-1.5 text-[12px] text-slate-400 hover:text-red-600",
|
|
408
|
+
children: "✕"
|
|
409
|
+
}
|
|
410
|
+
) })
|
|
411
|
+
] }, r.key)),
|
|
412
|
+
oe.length === 0 && /* @__PURE__ */ l("tr", { children: /* @__PURE__ */ l("td", { colSpan: 99, className: "py-3 text-center text-[12px] text-slate-400", children: "No rows" }) })
|
|
413
|
+
] }),
|
|
414
|
+
/* @__PURE__ */ l("tfoot", { children: /* @__PURE__ */ u("tr", { className: "border-t border-slate-300 font-semibold dark:border-border", children: [
|
|
415
|
+
t.row_source && /* @__PURE__ */ l("td", { className: "py-1.5 pr-3", children: "Total" }),
|
|
416
|
+
(t.key_columns ?? []).map((r, o) => /* @__PURE__ */ l("td", { className: "py-1.5 pr-3", children: !t.row_source && o === 0 ? "Total" : "" }, r.field)),
|
|
417
|
+
ce.map((r) => /* @__PURE__ */ l("td", { className: "py-1.5 pr-2 text-right tabular-nums", children: oe.reduce((o, d) => o + (Number(S(d, r.field)) || 0), 0).toLocaleString("en-US", { maximumFractionDigits: 2 }) }, r.field)),
|
|
418
|
+
t.allow_delete && /* @__PURE__ */ l("td", {})
|
|
419
|
+
] }) })
|
|
420
|
+
] })
|
|
421
|
+
}
|
|
422
|
+
) : /* @__PURE__ */ u("p", { className: "text-[12px] text-slate-400", children: [
|
|
356
423
|
"Choose ",
|
|
357
424
|
(t.scope ?? []).map((r) => r.label ?? r.field).join(", "),
|
|
358
425
|
" to load rows."
|
|
359
426
|
] })
|
|
360
427
|
] });
|
|
361
428
|
}
|
|
362
|
-
const
|
|
363
|
-
function
|
|
364
|
-
const
|
|
365
|
-
if (
|
|
366
|
-
const
|
|
367
|
-
return { value: `${
|
|
429
|
+
const te = (t, i) => t == null || !Number.isFinite(t) || i != null && i.blankZero && t === 0 ? "—" : t.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 }), We = "Enter an amount of zero or more";
|
|
430
|
+
function it(t, i) {
|
|
431
|
+
const g = t.replace(/[^\d.-]/g, "");
|
|
432
|
+
if (g.includes("-") && !i) return { value: null, refused: We };
|
|
433
|
+
const c = g.startsWith("-") ? "-" : "", m = g.replace(/-/g, ""), x = m.indexOf("."), C = x < 0 ? m : `${m.slice(0, x + 1)}${m.slice(x + 1).replace(/\./g, "")}`;
|
|
434
|
+
return { value: `${c}${C}`, refused: null };
|
|
368
435
|
}
|
|
369
|
-
function
|
|
436
|
+
function ct({
|
|
370
437
|
value: t,
|
|
371
|
-
original:
|
|
372
|
-
onChange:
|
|
373
|
-
disabled:
|
|
374
|
-
allowNegative:
|
|
438
|
+
original: i,
|
|
439
|
+
onChange: g,
|
|
440
|
+
disabled: c,
|
|
441
|
+
allowNegative: m = !1,
|
|
442
|
+
conflict: x
|
|
375
443
|
}) {
|
|
376
|
-
const [
|
|
377
|
-
return /* @__PURE__ */
|
|
444
|
+
const [C, M] = k(!1), [w, O] = k(null), v = t !== i, j = t === "" ? null : Number(t), re = C || j == null || Number.isNaN(j) ? t : te(j), le = v && j != null && !Number.isNaN(j) ? j - (Number(i) || 0) : 0;
|
|
445
|
+
return /* @__PURE__ */ u("span", { className: "relative inline-block", children: [
|
|
378
446
|
/* @__PURE__ */ l(
|
|
379
447
|
"input",
|
|
380
448
|
{
|
|
381
449
|
type: "text",
|
|
382
450
|
inputMode: "decimal",
|
|
383
|
-
value:
|
|
384
|
-
disabled:
|
|
385
|
-
"aria-invalid":
|
|
386
|
-
title:
|
|
387
|
-
onFocus: (
|
|
388
|
-
|
|
389
|
-
const
|
|
451
|
+
value: re,
|
|
452
|
+
disabled: c,
|
|
453
|
+
"aria-invalid": w || x ? !0 : void 0,
|
|
454
|
+
title: w ?? x ?? (v ? `Was ${te(Number(i) || 0)} (${le >= 0 ? "+" : "−"}${te(Math.abs(le))})` : void 0),
|
|
455
|
+
onFocus: (U) => {
|
|
456
|
+
M(!0);
|
|
457
|
+
const R = U.currentTarget;
|
|
390
458
|
requestAnimationFrame(() => {
|
|
391
|
-
document.activeElement ===
|
|
459
|
+
document.activeElement === R && R.select();
|
|
392
460
|
});
|
|
393
461
|
},
|
|
394
462
|
onBlur: () => {
|
|
395
|
-
|
|
463
|
+
M(!1), O(null);
|
|
396
464
|
},
|
|
397
|
-
onChange: (
|
|
398
|
-
const
|
|
399
|
-
|
|
465
|
+
onChange: (U) => {
|
|
466
|
+
const R = it(U.target.value, m);
|
|
467
|
+
O(R.refused), R.value != null && g(R.value);
|
|
400
468
|
},
|
|
401
|
-
className:
|
|
469
|
+
className: Y(
|
|
402
470
|
"h-7 w-[92px] rounded-md border bg-white px-1.5 text-right text-[12px] tabular-nums outline-none transition-colors focus:border-nvr-cyan disabled:bg-transparent dark:bg-background",
|
|
403
|
-
|
|
404
|
-
!
|
|
471
|
+
w ? "border-red-400 focus:border-red-400" : x ? "border-amber-500 ring-1 ring-amber-500/40" : v ? "border-nvr-cyan bg-nvr-cyan/[0.06] dark:bg-nvr-cyan/10" : "border-slate-200 dark:border-border",
|
|
472
|
+
!v && (j === 0 || j == null) && "text-slate-400"
|
|
405
473
|
)
|
|
406
474
|
}
|
|
407
475
|
),
|
|
408
|
-
|
|
476
|
+
w && /* @__PURE__ */ l(
|
|
409
477
|
"span",
|
|
410
478
|
{
|
|
411
479
|
role: "alert",
|
|
412
480
|
className: "absolute right-0 top-full z-10 mt-0.5 whitespace-nowrap rounded bg-red-600 px-1.5 py-0.5 text-[10.5px] font-medium text-white shadow",
|
|
413
|
-
children:
|
|
481
|
+
children: w
|
|
414
482
|
}
|
|
415
483
|
)
|
|
416
484
|
] });
|
|
417
485
|
}
|
|
418
|
-
function
|
|
419
|
-
var
|
|
420
|
-
const
|
|
486
|
+
function ut({ config: t }) {
|
|
487
|
+
var I, Oe, Te;
|
|
488
|
+
const i = Ae(), g = Re(), c = t.key_columns ?? [], [m, x] = k({}), [C, M] = k({}), [w, O] = k([]), [v, j] = k(/* @__PURE__ */ new Set()), [re, le] = k(!1), [U, R] = k(null), [ae, z] = k(null), [W, K] = k({}), B = Q(
|
|
489
|
+
() => new Pe(i, t.collection),
|
|
490
|
+
[i, t.collection]
|
|
491
|
+
), p = c.length > 0 && c.every((e) => m[e.field] != null && m[e.field] !== ""), T = Q(() => {
|
|
421
492
|
const e = (t.month_sets ?? []).flatMap(
|
|
422
|
-
(
|
|
423
|
-
field: `${
|
|
424
|
-
label: `${
|
|
493
|
+
(s) => ee.map((n, b) => ({
|
|
494
|
+
field: `${n}${s.suffix}`,
|
|
495
|
+
label: `${Ue[b]}${s.label ? ` ${s.label}` : ""}`
|
|
425
496
|
}))
|
|
426
|
-
),
|
|
427
|
-
field:
|
|
428
|
-
label:
|
|
497
|
+
), a = (t.columns ?? []).map((s) => ({
|
|
498
|
+
field: s.field,
|
|
499
|
+
label: s.label ?? s.field
|
|
429
500
|
}));
|
|
430
|
-
return [...e, ...
|
|
431
|
-
}, [t.month_sets, t.columns]), _ = (
|
|
501
|
+
return [...e, ...a];
|
|
502
|
+
}, [t.month_sets, t.columns]), _ = (I = t.month_sets) == null ? void 0 : I[0], { data: ye = [], isLoading: se } = ve({
|
|
432
503
|
queryKey: ["record-grid-browse-rows", t.collection],
|
|
433
|
-
queryFn: () =>
|
|
434
|
-
|
|
504
|
+
queryFn: () => i.request(
|
|
505
|
+
xe(`/items/${t.collection}`, { limit: 5e3 })
|
|
435
506
|
).then((e) => e.data ?? []),
|
|
436
|
-
staleTime: 1e4
|
|
437
|
-
|
|
438
|
-
|
|
507
|
+
staleTime: 1e4,
|
|
508
|
+
// R1: another planner's saved values appear here; the person's own draft stays on top.
|
|
509
|
+
meta: Fe({ reads: [t.collection], minGapMs: 2e3 })
|
|
510
|
+
}), { data: ke = {} } = ve({
|
|
511
|
+
queryKey: ["record-grid-browse-labels", c.map((e) => e.collection).join(",")],
|
|
439
512
|
queryFn: async () => {
|
|
440
513
|
const e = {};
|
|
441
514
|
return await Promise.all(
|
|
442
|
-
|
|
443
|
-
const
|
|
444
|
-
|
|
445
|
-
).then((
|
|
446
|
-
|
|
447
|
-
).then((
|
|
448
|
-
for (const
|
|
449
|
-
|
|
450
|
-
e[
|
|
515
|
+
c.map(async (a) => {
|
|
516
|
+
const s = await i.request(
|
|
517
|
+
xe(`/collections/${a.collection}`)
|
|
518
|
+
).then((h) => h.data).catch(() => null), n = await i.request(
|
|
519
|
+
xe(`/items/${a.collection}`, { limit: 1e3 })
|
|
520
|
+
).then((h) => h.data ?? []).catch(() => []), b = /* @__PURE__ */ new Map();
|
|
521
|
+
for (const h of n)
|
|
522
|
+
b.set(String(h.id), st(s == null ? void 0 : s.display_template, h) || String(h.id));
|
|
523
|
+
e[a.field] = b;
|
|
451
524
|
})
|
|
452
525
|
), e;
|
|
453
526
|
},
|
|
454
|
-
enabled:
|
|
527
|
+
enabled: c.length > 0,
|
|
455
528
|
staleTime: 3e5
|
|
456
|
-
}),
|
|
457
|
-
(e,
|
|
458
|
-
var
|
|
459
|
-
return
|
|
529
|
+
}), L = Ye(
|
|
530
|
+
(e, a) => {
|
|
531
|
+
var s;
|
|
532
|
+
return a == null ? "—" : ((s = ke[e]) == null ? void 0 : s.get(String(a))) ?? String(a);
|
|
460
533
|
},
|
|
461
|
-
[
|
|
462
|
-
),
|
|
463
|
-
() =>
|
|
464
|
-
(e) =>
|
|
465
|
-
(
|
|
534
|
+
[ke]
|
|
535
|
+
), P = Q(
|
|
536
|
+
() => ye.filter(
|
|
537
|
+
(e) => c.every(
|
|
538
|
+
(a) => m[a.field] == null || m[a.field] === "" || String(e[a.field]) === String(m[a.field])
|
|
466
539
|
)
|
|
467
540
|
),
|
|
468
|
-
[
|
|
469
|
-
),
|
|
470
|
-
if (
|
|
541
|
+
[ye, c, m]
|
|
542
|
+
), oe = (Oe = c[0]) == null ? void 0 : Oe.field, S = c.filter((e) => m[e.field] == null || m[e.field] === ""), ie = Q(() => {
|
|
543
|
+
if (p) return [];
|
|
471
544
|
const e = /* @__PURE__ */ new Map();
|
|
472
|
-
for (const
|
|
473
|
-
const
|
|
474
|
-
for (const
|
|
475
|
-
const
|
|
476
|
-
for (const
|
|
477
|
-
|
|
478
|
-
|
|
545
|
+
for (const a of P) {
|
|
546
|
+
const s = {};
|
|
547
|
+
for (const h of S) s[h.field] = a[h.field];
|
|
548
|
+
const n = S.map((h) => String(a[h.field] ?? "")).join("|"), b = e.get(n) ?? { keyVals: s, sums: {}, count: 0 };
|
|
549
|
+
for (const h of T)
|
|
550
|
+
b.sums[h.field] = (b.sums[h.field] ?? 0) + (Number(a[h.field]) || 0);
|
|
551
|
+
b.count++, e.set(n, b);
|
|
479
552
|
}
|
|
480
|
-
return [...e.values()].sort((
|
|
481
|
-
for (const
|
|
482
|
-
const
|
|
483
|
-
|
|
553
|
+
return [...e.values()].sort((a, s) => {
|
|
554
|
+
for (const n of S) {
|
|
555
|
+
const b = L(n.field, a.keyVals[n.field]).localeCompare(
|
|
556
|
+
L(n.field, s.keyVals[n.field]),
|
|
484
557
|
void 0,
|
|
485
558
|
{ numeric: !0 }
|
|
486
559
|
);
|
|
487
|
-
if (
|
|
560
|
+
if (b) return n.field === oe ? -b : b;
|
|
488
561
|
}
|
|
489
562
|
return 0;
|
|
490
563
|
});
|
|
491
|
-
}, [
|
|
492
|
-
...
|
|
493
|
-
...
|
|
494
|
-
] : [], [
|
|
495
|
-
() =>
|
|
496
|
-
var
|
|
497
|
-
return ((
|
|
564
|
+
}, [P, S, p, T, L, oe]), D = Q(() => p ? [
|
|
565
|
+
...P.filter((e) => !v.has(String(e.id))).map((e) => ({ key: `rec-${e.id}`, record: e, isNew: !1 })),
|
|
566
|
+
...w.map((e) => ({ key: e, record: null, isNew: !0 }))
|
|
567
|
+
] : [], [P, p, w, v]), fe = et(null), ge = Q(
|
|
568
|
+
() => D.filter((e) => {
|
|
569
|
+
var a;
|
|
570
|
+
return ((a = e.record) == null ? void 0 : a.id) != null;
|
|
498
571
|
}).map((e) => {
|
|
499
|
-
var
|
|
500
|
-
return String((
|
|
572
|
+
var a;
|
|
573
|
+
return String((a = e.record) == null ? void 0 : a.id);
|
|
501
574
|
}),
|
|
502
|
-
[
|
|
503
|
-
), { editors:
|
|
504
|
-
page:
|
|
575
|
+
[D]
|
|
576
|
+
), { editors: Ce } = tt({
|
|
577
|
+
page: rt(
|
|
505
578
|
"rgrid",
|
|
506
579
|
t.collection,
|
|
507
|
-
...
|
|
580
|
+
...c.map((e) => String(m[e.field] ?? ""))
|
|
508
581
|
),
|
|
509
582
|
collection: t.collection,
|
|
510
|
-
items:
|
|
583
|
+
items: ge,
|
|
511
584
|
containerRef: fe,
|
|
512
|
-
enabled:
|
|
513
|
-
})
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
585
|
+
enabled: p
|
|
586
|
+
});
|
|
587
|
+
je(() => {
|
|
588
|
+
const e = D.flatMap((a) => a.record ? [a.record] : []);
|
|
589
|
+
e.length > 0 && B.noteRows(e);
|
|
590
|
+
}, [B, D]);
|
|
591
|
+
const ce = c.map((e) => L(e.field, m[e.field])).join(" · ");
|
|
592
|
+
je(() => {
|
|
593
|
+
p && P.length === 0 && w.length === 0 && v.size === 0 && O([`new-${Date.now()}`]);
|
|
594
|
+
}, [p, P.length, w.length, v.size]);
|
|
595
|
+
const ue = (e, a) => {
|
|
596
|
+
var b, h;
|
|
597
|
+
const s = (b = C[e.key]) == null ? void 0 : b[a];
|
|
598
|
+
if (s !== void 0) return s;
|
|
599
|
+
const n = (h = e.record) == null ? void 0 : h[a];
|
|
600
|
+
return n == null ? "" : String(n);
|
|
601
|
+
}, we = (e, a) => {
|
|
602
|
+
var n;
|
|
603
|
+
const s = (n = e.record) == null ? void 0 : n[a];
|
|
604
|
+
return s == null ? "" : String(s);
|
|
605
|
+
}, r = (e, a, s) => {
|
|
606
|
+
var n;
|
|
607
|
+
((n = e.record) == null ? void 0 : n.id) != null && B.pin(String(e.record.id)), M((b) => ({ ...b, [e.key]: { ...b[e.key] ?? {}, [a]: s } }));
|
|
608
|
+
}, o = Object.values(W).reduce((e, a) => e + Object.keys(a).length, 0), d = (e) => _ ? ee.reduce((a, s) => a + (Number(ue(e, `${s}${_.suffix}`)) || 0), 0) : null, f = Object.values(C).some((e) => Object.keys(e).length > 0) || v.size > 0 || w.some((e) => Object.keys(C[e] ?? {}).length > 0), N = () => {
|
|
609
|
+
M({}), O([]), j(/* @__PURE__ */ new Set()), K({}), B.release();
|
|
610
|
+
}, H = (e) => {
|
|
611
|
+
x((a) => ({ ...a, ...e })), N();
|
|
612
|
+
}, Ne = (e, a) => {
|
|
613
|
+
x((s) => ({ ...s, [e]: a })), N();
|
|
533
614
|
};
|
|
534
|
-
async function
|
|
535
|
-
|
|
536
|
-
let
|
|
615
|
+
async function ne(e) {
|
|
616
|
+
le(!0), z(null);
|
|
617
|
+
let a = 0, s = 0, n = 0;
|
|
618
|
+
const b = {}, h = (de) => T.some((me) => me.field === de);
|
|
537
619
|
try {
|
|
538
|
-
for (const
|
|
539
|
-
const
|
|
540
|
-
if (Object.keys(
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
620
|
+
for (const $ of D) {
|
|
621
|
+
const V = C[$.key] ?? {};
|
|
622
|
+
if (Object.keys(V).length !== 0)
|
|
623
|
+
if ($.record) {
|
|
624
|
+
const J = Ke(
|
|
625
|
+
V,
|
|
626
|
+
$.record,
|
|
627
|
+
h,
|
|
628
|
+
t.computed_total_field && _ ? {
|
|
629
|
+
field: t.computed_total_field,
|
|
630
|
+
of: ee.map((be) => `${be}${_.suffix}`)
|
|
631
|
+
} : null
|
|
632
|
+
);
|
|
633
|
+
if (!J) continue;
|
|
634
|
+
e && (J._change_reason = e);
|
|
635
|
+
const Z = await B.write(String($.record.id), J);
|
|
636
|
+
Z.ok ? s++ : Object.assign(b, Ve($.key, Z.conflicts));
|
|
637
|
+
} else {
|
|
638
|
+
const J = {};
|
|
639
|
+
for (const [Z, be] of Object.entries(V))
|
|
640
|
+
h(Z) && (J[Z] = be === "" ? null : Number.isNaN(Number(be)) ? be : Number(be));
|
|
641
|
+
t.computed_total_field && _ && (J[t.computed_total_field] = d($));
|
|
642
|
+
for (const Z of c) J[Z.field] = m[Z.field];
|
|
643
|
+
await i.request(Se(`/items/${t.collection}`, J)), a++;
|
|
644
|
+
}
|
|
550
645
|
}
|
|
551
|
-
for (const
|
|
552
|
-
await
|
|
553
|
-
if (t.after_save) {
|
|
554
|
-
const
|
|
555
|
-
await
|
|
556
|
-
|
|
646
|
+
for (const $ of v)
|
|
647
|
+
await i.request(Ee(`/items/${t.collection}/${$}`)), n++;
|
|
648
|
+
if (t.after_save && s + a + n > 0) {
|
|
649
|
+
const $ = pe(t.after_save.params ?? {}, m);
|
|
650
|
+
await i.request(
|
|
651
|
+
Se(`/custom-queries/${t.after_save.query_slug}/execute`, { params: $ })
|
|
557
652
|
);
|
|
558
653
|
}
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
654
|
+
const de = new Set(w), me = new Set(v);
|
|
655
|
+
M(($) => {
|
|
656
|
+
const V = Je($, C, new Set(Object.keys(b)));
|
|
657
|
+
for (const J of de) delete V[J];
|
|
658
|
+
return V;
|
|
659
|
+
}), O(($) => $.filter((V) => !de.has(V))), j(($) => new Set([...$].filter((V) => !me.has(V)))), K(b), await g.invalidateQueries({ queryKey: ["record-grid-browse-rows", t.collection] }), z(Ie(s, a, n, b));
|
|
660
|
+
} catch (de) {
|
|
661
|
+
const me = ze(de);
|
|
662
|
+
me ? R(me) : z(`Save failed: ${Le(de, "unknown error")}`);
|
|
565
663
|
} finally {
|
|
566
|
-
|
|
664
|
+
le(!1);
|
|
567
665
|
}
|
|
568
666
|
}
|
|
569
|
-
const
|
|
667
|
+
const he = (e) => p ? D.reduce((a, s) => a + (Number(ue(s, e)) || 0), 0) : ie.reduce((a, s) => a + (s.sums[e] ?? 0), 0), q = (e) => _ && e < 12 && e % 3 === 0 && e > 0, G = (e) => _ && e < 12 && Math.floor(e / 3) % 2 === 1 ? "bg-slate-50/70 dark:bg-muted/30" : "", [y, A] = nt("accent"), X = { "--qtc": y, "--qtcd": A }, E = "text-[color:var(--qtc)] dark:text-[color:var(--qtcd)]", F = (e, a, s = "") => /* @__PURE__ */ l(
|
|
570
668
|
"th",
|
|
571
669
|
{
|
|
572
|
-
className:
|
|
670
|
+
className: Y(
|
|
573
671
|
"whitespace-nowrap px-2 py-2 text-right text-[10.5px] font-semibold uppercase tracking-wide text-slate-400",
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
672
|
+
q(a) && "border-l border-slate-200 dark:border-border",
|
|
673
|
+
G(a),
|
|
674
|
+
s
|
|
577
675
|
),
|
|
578
676
|
children: e
|
|
579
677
|
},
|
|
580
|
-
e +
|
|
678
|
+
e + a
|
|
581
679
|
);
|
|
582
|
-
return /* @__PURE__ */
|
|
680
|
+
return /* @__PURE__ */ u("div", { ref: fe, className: "flex h-full min-h-0 flex-col", "data-record-grid-browse": !0, children: [
|
|
583
681
|
/* @__PURE__ */ l(
|
|
584
|
-
|
|
682
|
+
De,
|
|
585
683
|
{
|
|
586
|
-
challenge:
|
|
587
|
-
onCancel: () =>
|
|
684
|
+
challenge: U,
|
|
685
|
+
onCancel: () => R(null),
|
|
588
686
|
onSubmit: (e) => {
|
|
589
|
-
|
|
687
|
+
R(null), ne(e);
|
|
590
688
|
}
|
|
591
689
|
}
|
|
592
690
|
),
|
|
593
|
-
/* @__PURE__ */
|
|
594
|
-
|
|
691
|
+
/* @__PURE__ */ u("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: [
|
|
692
|
+
c.map((e) => /* @__PURE__ */ u("div", { className: "w-52", children: [
|
|
595
693
|
/* @__PURE__ */ l("p", { className: "mb-1 text-[11px] font-medium text-slate-500 dark:text-slate-400", children: e.label ?? e.field }),
|
|
596
694
|
/* @__PURE__ */ l(
|
|
597
|
-
|
|
695
|
+
qe,
|
|
598
696
|
{
|
|
599
697
|
collection: e.collection,
|
|
600
|
-
value:
|
|
601
|
-
onChange: (
|
|
698
|
+
value: m[e.field] ?? null,
|
|
699
|
+
onChange: (a) => Ne(e.field, a),
|
|
602
700
|
placeholder: "All",
|
|
603
701
|
optionSort: e.collection === "funding_years" ? "-id" : void 0
|
|
604
702
|
}
|
|
605
703
|
)
|
|
606
704
|
] }, e.field)),
|
|
607
705
|
/* @__PURE__ */ l("span", { className: "flex-1" }),
|
|
608
|
-
|
|
609
|
-
|
|
706
|
+
ae && /* @__PURE__ */ l("span", { className: "pb-2 text-[12px] text-slate-500", children: ae }),
|
|
707
|
+
o > 0 && /* @__PURE__ */ l(
|
|
708
|
+
Qe,
|
|
709
|
+
{
|
|
710
|
+
count: o,
|
|
711
|
+
onClick: () => {
|
|
712
|
+
M((e) => Ge(e, W)), K({});
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
),
|
|
716
|
+
p && t.allow_add && /* @__PURE__ */ l(
|
|
610
717
|
"button",
|
|
611
718
|
{
|
|
612
719
|
type: "button",
|
|
613
|
-
onClick: () =>
|
|
720
|
+
onClick: () => O((e) => [...e, `new-${Date.now()}`]),
|
|
614
721
|
className: "h-9 rounded-md border border-slate-200 bg-white px-3 text-[13px] text-slate-700 hover:border-slate-400 dark:border-border dark:bg-card dark:text-slate-200",
|
|
615
722
|
children: "+ Add row"
|
|
616
723
|
}
|
|
617
724
|
),
|
|
618
|
-
|
|
725
|
+
f && /* @__PURE__ */ l(
|
|
619
726
|
"button",
|
|
620
727
|
{
|
|
621
728
|
type: "button",
|
|
622
|
-
onClick:
|
|
729
|
+
onClick: N,
|
|
623
730
|
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",
|
|
624
731
|
children: "Discard"
|
|
625
732
|
}
|
|
626
733
|
),
|
|
627
|
-
/* @__PURE__ */
|
|
734
|
+
/* @__PURE__ */ u(
|
|
628
735
|
"button",
|
|
629
736
|
{
|
|
630
737
|
type: "button",
|
|
631
|
-
disabled: !
|
|
632
|
-
onClick: () => void
|
|
738
|
+
disabled: !p || !f || re,
|
|
739
|
+
onClick: () => void ne(),
|
|
633
740
|
"data-record-grid-save": !0,
|
|
634
741
|
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",
|
|
635
742
|
children: [
|
|
636
|
-
|
|
743
|
+
re && /* @__PURE__ */ l(_e, { className: "h-3.5 w-3.5 animate-spin" }),
|
|
637
744
|
"Save changes"
|
|
638
745
|
]
|
|
639
746
|
}
|
|
640
747
|
)
|
|
641
748
|
] }),
|
|
642
|
-
/* @__PURE__ */
|
|
643
|
-
|
|
749
|
+
/* @__PURE__ */ u("div", { className: "flex shrink-0 items-center gap-2 border-b border-slate-200 bg-slate-50 px-4 py-1.5 text-[12px] text-slate-500 dark:border-border dark:bg-muted/40 dark:text-slate-400", children: [
|
|
750
|
+
p ? /* @__PURE__ */ u("span", { children: [
|
|
644
751
|
"Editing",
|
|
645
752
|
" ",
|
|
646
|
-
/* @__PURE__ */ l("strong", { className: "text-slate-700 dark:text-slate-200", children:
|
|
647
|
-
|
|
753
|
+
/* @__PURE__ */ l("strong", { className: "text-slate-700 dark:text-slate-200", children: c.map((e) => L(e.field, m[e.field])).join(" · ") }),
|
|
754
|
+
D.length > 1 && ` — ${D.length} rows share this combination`
|
|
648
755
|
] }) : null,
|
|
649
|
-
|
|
650
|
-
|
|
756
|
+
p && Ce.length > 0 ? /* @__PURE__ */ l(
|
|
757
|
+
at,
|
|
651
758
|
{
|
|
652
759
|
className: "ml-3 border-l border-slate-200 pl-3 dark:border-border",
|
|
653
|
-
editors:
|
|
654
|
-
noun: ((
|
|
655
|
-
rowLabel: (e) =>
|
|
760
|
+
editors: Ce,
|
|
761
|
+
noun: ((Te = t.presence_noun) == null ? void 0 : Te.trim()) || t.collection.replace(/_/g, " ").toLowerCase(),
|
|
762
|
+
rowLabel: (e) => D.length > 1 ? `${ce} (#${e})` : ce || `#${e}`,
|
|
656
763
|
cellLabel: (e) => {
|
|
657
|
-
var
|
|
658
|
-
return (
|
|
764
|
+
var a;
|
|
765
|
+
return (a = T.find((s) => s.field === e)) == null ? void 0 : a.label;
|
|
659
766
|
}
|
|
660
767
|
}
|
|
661
768
|
) : null,
|
|
662
|
-
|
|
769
|
+
p ? null : /* @__PURE__ */ u("span", { children: [
|
|
663
770
|
"Totals across",
|
|
664
771
|
" ",
|
|
665
|
-
/* @__PURE__ */ l("strong", { className: "text-slate-700 dark:text-slate-200", children:
|
|
772
|
+
/* @__PURE__ */ l("strong", { className: "text-slate-700 dark:text-slate-200", children: P.length }),
|
|
666
773
|
" row",
|
|
667
|
-
|
|
668
|
-
|
|
774
|
+
P.length === 1 ? "" : "s",
|
|
775
|
+
S.length > 0 && /* @__PURE__ */ u(He, { children: [
|
|
669
776
|
", by ",
|
|
670
|
-
|
|
777
|
+
S.map((e) => e.label ?? e.field).join(" and "),
|
|
671
778
|
" — pick",
|
|
672
779
|
" ",
|
|
673
|
-
|
|
780
|
+
S.map((e) => e.label ?? e.field).join(", "),
|
|
674
781
|
" to edit"
|
|
675
782
|
] })
|
|
676
783
|
] }),
|
|
677
|
-
Object.keys(
|
|
784
|
+
Object.keys(m).some((e) => m[e] != null && m[e] !== "") && /* @__PURE__ */ u(
|
|
678
785
|
"button",
|
|
679
786
|
{
|
|
680
787
|
type: "button",
|
|
681
788
|
onClick: () => {
|
|
682
|
-
|
|
789
|
+
x({}), N();
|
|
683
790
|
},
|
|
684
791
|
className: "ml-auto inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[11.5px] text-slate-500 hover:bg-slate-200/60 hover:text-slate-700 dark:hover:bg-muted",
|
|
685
792
|
children: [
|
|
686
|
-
/* @__PURE__ */ l(
|
|
793
|
+
/* @__PURE__ */ l(Me, { className: "h-3 w-3" }),
|
|
687
794
|
" Clear"
|
|
688
795
|
]
|
|
689
796
|
}
|
|
690
797
|
)
|
|
691
798
|
] }),
|
|
692
|
-
/* @__PURE__ */ l("div", { className: "min-h-0 flex-1 overflow-auto", children:
|
|
693
|
-
/* @__PURE__ */ l(
|
|
799
|
+
/* @__PURE__ */ l("div", { className: "min-h-0 flex-1 overflow-auto", children: se ? /* @__PURE__ */ u("div", { className: "flex items-center gap-2 p-4 text-[12px] text-slate-400", children: [
|
|
800
|
+
/* @__PURE__ */ l(_e, { className: "h-4 w-4 animate-spin" }),
|
|
694
801
|
" Loading…"
|
|
695
|
-
] }) : /* @__PURE__ */
|
|
696
|
-
/* @__PURE__ */ l("thead", { className: "sticky top-0 z-[1] bg-white dark:bg-card", children: /* @__PURE__ */
|
|
697
|
-
(
|
|
802
|
+
] }) : /* @__PURE__ */ u("table", { className: "w-full text-[12px]", children: [
|
|
803
|
+
/* @__PURE__ */ l("thead", { className: "sticky top-0 z-[1] bg-white dark:bg-card", children: /* @__PURE__ */ u("tr", { className: "border-b border-slate-200 dark:border-border", children: [
|
|
804
|
+
(p ? [{ field: "__row", label: "" }] : S.map((e) => ({ field: e.field, label: e.label ?? e.field }))).map((e) => /* @__PURE__ */ l(
|
|
698
805
|
"th",
|
|
699
806
|
{
|
|
700
807
|
className: "sticky left-0 z-[2] bg-white px-2 py-2 text-left text-[10.5px] font-semibold uppercase tracking-wide text-slate-400 dark:bg-card",
|
|
@@ -702,45 +809,46 @@ function Qe({ config: t }) {
|
|
|
702
809
|
},
|
|
703
810
|
e.field
|
|
704
811
|
)),
|
|
705
|
-
|
|
706
|
-
_ &&
|
|
707
|
-
|
|
812
|
+
T.map((e, a) => F(e.label, a)),
|
|
813
|
+
_ && F("Total", 99, "border-l border-slate-200 dark:border-border"),
|
|
814
|
+
p && t.allow_delete && /* @__PURE__ */ l("th", { "aria-label": "Remove", className: "w-8" })
|
|
708
815
|
] }) }),
|
|
709
|
-
/* @__PURE__ */
|
|
710
|
-
|
|
711
|
-
var
|
|
712
|
-
return /* @__PURE__ */
|
|
713
|
-
/* @__PURE__ */ l("td", { className: "sticky left-0 z-[1] bg-white px-3 py-1 text-slate-600 dark:bg-card dark:text-slate-300", children: e.isNew ? /* @__PURE__ */ l("span", { className: "rounded bg-nvr-cyan/10 px-1.5 py-0.5 text-[10.5px] font-medium text-nvr-navy dark:text-nvr-cyan", children: "New row" }) : `#${(
|
|
714
|
-
|
|
715
|
-
var
|
|
816
|
+
/* @__PURE__ */ u("tbody", { children: [
|
|
817
|
+
p ? D.map((e) => {
|
|
818
|
+
var a;
|
|
819
|
+
return /* @__PURE__ */ u("tr", { className: "border-b border-slate-100 dark:border-border/50", children: [
|
|
820
|
+
/* @__PURE__ */ l("td", { className: "sticky left-0 z-[1] bg-white px-3 py-1 text-slate-600 dark:bg-card dark:text-slate-300", children: e.isNew ? /* @__PURE__ */ l("span", { className: "rounded bg-nvr-cyan/10 px-1.5 py-0.5 text-[10.5px] font-medium text-nvr-navy dark:text-nvr-cyan", children: "New row" }) : `#${(a = e.record) == null ? void 0 : a.id}` }),
|
|
821
|
+
T.map((s, n) => {
|
|
822
|
+
var b;
|
|
716
823
|
return /* @__PURE__ */ l(
|
|
717
824
|
"td",
|
|
718
825
|
{
|
|
719
|
-
"data-grid-cell": ((
|
|
720
|
-
className:
|
|
826
|
+
"data-grid-cell": ((b = e.record) == null ? void 0 : b.id) != null ? lt(String(e.record.id), s.field) : void 0,
|
|
827
|
+
className: Y(
|
|
721
828
|
"px-1 py-0.5 text-right",
|
|
722
|
-
|
|
723
|
-
|
|
829
|
+
q(n) && "border-l border-slate-100 dark:border-border/50",
|
|
830
|
+
G(n)
|
|
724
831
|
),
|
|
725
832
|
children: /* @__PURE__ */ l(
|
|
726
|
-
|
|
833
|
+
ct,
|
|
727
834
|
{
|
|
728
|
-
value:
|
|
729
|
-
original:
|
|
730
|
-
onChange: (
|
|
731
|
-
allowNegative: !!t.allow_negative
|
|
835
|
+
value: ue(e, s.field),
|
|
836
|
+
original: we(e, s.field),
|
|
837
|
+
onChange: (h) => r(e, s.field, h),
|
|
838
|
+
allowNegative: !!t.allow_negative,
|
|
839
|
+
conflict: s.field in (W[e.key] ?? {}) ? Be(W[e.key][s.field]) : void 0
|
|
732
840
|
}
|
|
733
841
|
)
|
|
734
842
|
},
|
|
735
|
-
|
|
843
|
+
s.field
|
|
736
844
|
);
|
|
737
845
|
}),
|
|
738
846
|
_ && /* @__PURE__ */ l(
|
|
739
847
|
"td",
|
|
740
848
|
{
|
|
741
|
-
className: `border-l border-slate-200 px-2 py-1 text-right font-semibold tabular-nums dark:border-border ${
|
|
742
|
-
style:
|
|
743
|
-
children:
|
|
849
|
+
className: `border-l border-slate-200 px-2 py-1 text-right font-semibold tabular-nums dark:border-border ${E}`,
|
|
850
|
+
style: X,
|
|
851
|
+
children: te(d(e))
|
|
744
852
|
}
|
|
745
853
|
),
|
|
746
854
|
t.allow_delete && /* @__PURE__ */ l("td", { className: "py-1 pl-1", children: /* @__PURE__ */ l(
|
|
@@ -749,71 +857,71 @@ function Qe({ config: t }) {
|
|
|
749
857
|
type: "button",
|
|
750
858
|
"aria-label": "Remove row",
|
|
751
859
|
onClick: () => {
|
|
752
|
-
e.record ?
|
|
753
|
-
var
|
|
754
|
-
return new Set(
|
|
755
|
-
}) :
|
|
756
|
-
const
|
|
757
|
-
return delete
|
|
860
|
+
e.record ? j((s) => {
|
|
861
|
+
var n;
|
|
862
|
+
return new Set(s).add(String((n = e.record) == null ? void 0 : n.id));
|
|
863
|
+
}) : O((s) => s.filter((n) => n !== e.key)), M((s) => {
|
|
864
|
+
const n = { ...s };
|
|
865
|
+
return delete n[e.key], n;
|
|
758
866
|
});
|
|
759
867
|
},
|
|
760
868
|
className: "rounded p-1 text-slate-400 hover:text-red-600",
|
|
761
|
-
children: /* @__PURE__ */ l(
|
|
869
|
+
children: /* @__PURE__ */ l(Me, { className: "h-3.5 w-3.5" })
|
|
762
870
|
}
|
|
763
871
|
) })
|
|
764
872
|
] }, e.key);
|
|
765
|
-
}) :
|
|
766
|
-
const
|
|
767
|
-
return /* @__PURE__ */
|
|
873
|
+
}) : ie.map((e) => {
|
|
874
|
+
const a = S.map((s) => String(e.keyVals[s.field] ?? "")).join("|");
|
|
875
|
+
return /* @__PURE__ */ u(
|
|
768
876
|
"tr",
|
|
769
877
|
{
|
|
770
878
|
className: "cursor-pointer border-b border-slate-100 hover:bg-slate-50 focus:outline-none focus-visible:bg-slate-50 dark:border-border/50 dark:hover:bg-muted/40",
|
|
771
|
-
onClick: () =>
|
|
772
|
-
onKeyDown: (
|
|
773
|
-
(
|
|
879
|
+
onClick: () => H(e.keyVals),
|
|
880
|
+
onKeyDown: (s) => {
|
|
881
|
+
(s.key === "Enter" || s.key === " ") && (s.preventDefault(), H(e.keyVals));
|
|
774
882
|
},
|
|
775
883
|
tabIndex: 0,
|
|
776
884
|
title: "Open this combination",
|
|
777
885
|
children: [
|
|
778
|
-
|
|
886
|
+
S.map((s, n) => /* @__PURE__ */ u(
|
|
779
887
|
"td",
|
|
780
888
|
{
|
|
781
|
-
className:
|
|
889
|
+
className: Y(
|
|
782
890
|
"whitespace-nowrap px-2 py-1.5 text-slate-700 dark:text-slate-200",
|
|
783
|
-
|
|
891
|
+
n === 0 && "sticky left-0 z-[1] bg-white font-medium dark:bg-card"
|
|
784
892
|
),
|
|
785
893
|
children: [
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
894
|
+
n === 0 && /* @__PURE__ */ l(Ze, { className: "mr-1 inline h-3 w-3 text-slate-300" }),
|
|
895
|
+
L(s.field, e.keyVals[s.field]),
|
|
896
|
+
n === S.length - 1 && e.count > 1 && /* @__PURE__ */ u("span", { className: "ml-1.5 text-[10.5px] text-slate-400", children: [
|
|
789
897
|
e.count,
|
|
790
898
|
" rows"
|
|
791
899
|
] })
|
|
792
900
|
]
|
|
793
901
|
},
|
|
794
|
-
|
|
902
|
+
s.field
|
|
795
903
|
)),
|
|
796
|
-
|
|
904
|
+
T.map((s, n) => /* @__PURE__ */ l(
|
|
797
905
|
"td",
|
|
798
906
|
{
|
|
799
|
-
className:
|
|
907
|
+
className: Y(
|
|
800
908
|
"whitespace-nowrap px-1.5 py-1.5 text-right tabular-nums",
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
(e.sums[
|
|
909
|
+
q(n) && "border-l border-slate-100 dark:border-border/50",
|
|
910
|
+
G(n),
|
|
911
|
+
(e.sums[s.field] ?? 0) === 0 ? "text-slate-300 dark:text-slate-600" : "text-slate-700 dark:text-slate-200"
|
|
804
912
|
),
|
|
805
|
-
children:
|
|
913
|
+
children: te(e.sums[s.field], { blankZero: !0 })
|
|
806
914
|
},
|
|
807
|
-
|
|
915
|
+
s.field
|
|
808
916
|
)),
|
|
809
917
|
_ && /* @__PURE__ */ l(
|
|
810
918
|
"td",
|
|
811
919
|
{
|
|
812
|
-
className: `border-l border-slate-200 px-2 py-1.5 text-right font-semibold tabular-nums dark:border-border ${
|
|
813
|
-
style:
|
|
814
|
-
children:
|
|
815
|
-
|
|
816
|
-
(
|
|
920
|
+
className: `border-l border-slate-200 px-2 py-1.5 text-right font-semibold tabular-nums dark:border-border ${E}`,
|
|
921
|
+
style: X,
|
|
922
|
+
children: te(
|
|
923
|
+
ee.reduce(
|
|
924
|
+
(s, n) => s + (e.sums[`${n}${_.suffix}`] ?? 0),
|
|
817
925
|
0
|
|
818
926
|
)
|
|
819
927
|
)
|
|
@@ -821,48 +929,50 @@ function Qe({ config: t }) {
|
|
|
821
929
|
)
|
|
822
930
|
]
|
|
823
931
|
},
|
|
824
|
-
|
|
932
|
+
a
|
|
825
933
|
);
|
|
826
934
|
}),
|
|
827
|
-
!
|
|
935
|
+
!p && ie.length === 0 && /* @__PURE__ */ l("tr", { children: /* @__PURE__ */ l("td", { colSpan: 99, className: "py-6 text-center text-[12px] text-slate-400", children: "No rows match" }) })
|
|
828
936
|
] }),
|
|
829
|
-
/* @__PURE__ */ l("tfoot", { className: "sticky bottom-0 bg-white dark:bg-card", children: /* @__PURE__ */
|
|
937
|
+
/* @__PURE__ */ l("tfoot", { className: "sticky bottom-0 bg-white dark:bg-card", children: /* @__PURE__ */ u("tr", { className: "border-t-2 border-slate-300 dark:border-border", children: [
|
|
830
938
|
/* @__PURE__ */ l(
|
|
831
939
|
"td",
|
|
832
940
|
{
|
|
833
|
-
colSpan:
|
|
941
|
+
colSpan: p ? 1 : Math.max(1, S.length),
|
|
834
942
|
className: "sticky left-0 z-[1] bg-white px-3 py-2 text-[12px] font-semibold text-slate-800 dark:bg-card dark:text-slate-100",
|
|
835
943
|
children: "Total"
|
|
836
944
|
}
|
|
837
945
|
),
|
|
838
|
-
|
|
946
|
+
T.map((e, a) => /* @__PURE__ */ l(
|
|
839
947
|
"td",
|
|
840
948
|
{
|
|
841
|
-
className:
|
|
949
|
+
className: Y(
|
|
842
950
|
"px-2 py-2 text-right font-semibold tabular-nums text-slate-800 dark:text-slate-100",
|
|
843
|
-
|
|
844
|
-
|
|
951
|
+
q(a) && "border-l border-slate-200 dark:border-border",
|
|
952
|
+
G(a)
|
|
845
953
|
),
|
|
846
|
-
children:
|
|
954
|
+
children: te(he(e.field))
|
|
847
955
|
},
|
|
848
956
|
e.field
|
|
849
957
|
)),
|
|
850
958
|
_ && /* @__PURE__ */ l(
|
|
851
959
|
"td",
|
|
852
960
|
{
|
|
853
|
-
className: `border-l border-slate-200 px-2 py-2 text-right font-semibold tabular-nums dark:border-border ${
|
|
854
|
-
style:
|
|
855
|
-
children:
|
|
961
|
+
className: `border-l border-slate-200 px-2 py-2 text-right font-semibold tabular-nums dark:border-border ${E}`,
|
|
962
|
+
style: X,
|
|
963
|
+
children: te(ee.reduce((e, a) => e + he(`${a}${_.suffix}`), 0))
|
|
856
964
|
}
|
|
857
965
|
),
|
|
858
|
-
|
|
966
|
+
p && t.allow_delete && /* @__PURE__ */ l("td", {})
|
|
859
967
|
] }) })
|
|
860
968
|
] }) })
|
|
861
969
|
] });
|
|
862
970
|
}
|
|
863
971
|
export {
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
972
|
+
We as NEGATIVE_AMOUNT_MESSAGE,
|
|
973
|
+
ct as NumberCell,
|
|
974
|
+
qt as RecordGridEditor,
|
|
975
|
+
Be as conflictTip,
|
|
976
|
+
it as sanitizeAmount,
|
|
977
|
+
Ie as saveStatus
|
|
868
978
|
};
|