@nivaro/react 0.3.15 → 0.3.17
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 +127 -6
- package/dist/index.js +736 -734
- package/dist/shared/components/CollectionBrowserView.js +2344 -2309
- package/dist/shared/components/ItemEditForm.js +3773 -3604
- package/dist/shared/components/RecordGridEditor.js +319 -282
- package/dist/shared/components/RecordReadView.js +202 -200
- package/dist/shared/components/cbv/unknown-fields.js +18 -8
- package/dist/shared/components/chat/ChatAnalyticsView.js +2 -2
- package/dist/shared/components/import/DocumentAutofillButton.js +148 -142
- package/dist/shared/components/item-edit/CatalogPickerField.js +264 -276
- package/dist/shared/components/item-edit/FieldRenderer.js +136 -133
- package/dist/shared/components/item-edit/FieldRow.js +198 -184
- package/dist/shared/components/item-edit/HeaderTools.js +107 -99
- package/dist/shared/components/item-edit/InlineTableField.js +138 -136
- package/dist/shared/components/item-edit/RecordLiveSync.js +1 -0
- package/dist/shared/components/item-edit/RelationCombobox.js +30 -23
- package/dist/shared/components/item-edit/SummaryPanel.js +334 -294
- package/dist/shared/components/item-edit/column-length.js +12 -0
- package/dist/shared/components/panels/AccessDeniedPanel.js +47 -37
- package/dist/shared/components/panels/ItemLockBanner.js +307 -285
- package/dist/shared/components/panels/PipelinePanel.js +486 -465
- package/dist/shared/components/panels/RevisionsPanel.js +210 -204
- package/dist/shared/components/pipeline/PipelineEditorView.js +1672 -1568
- package/dist/shared/components/profile/DelegationCard.js +178 -121
- package/dist/shared/components/profile/PersonActivity.js +152 -139
- package/dist/shared/components/queue/QueueWorklist.js +668 -659
- package/dist/shared/components/queue/transition-note.js +90 -0
- package/dist/shared/components/support/SupportRequestDialog.js +100 -89
- package/dist/shared/components/support/TicketDetailSheet.js +104 -91
- package/dist/shared/lib/autofill-runs.js +33 -26
- package/dist/shared/lib/draft-store.js +40 -24
- package/dist/shared/lib/live-queries.js +10 -9
- package/dist/shared/lib/request-gate.js +140 -127
- package/dist/shared/lib/restore-skipped.js +10 -0
- package/package.json +1 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { jsx as l, jsxs as
|
|
1
|
+
import { jsx as l, jsxs as c, Fragment as je } from "react/jsx-runtime";
|
|
2
2
|
import { useQueryClient as Ne, useQuery as be } from "@tanstack/react-query";
|
|
3
|
-
import { Loader2 as pe, X as ye, ChevronRight as
|
|
4
|
-
import { useState as N, useMemo as
|
|
5
|
-
import { useNivaroClient as
|
|
6
|
-
import { get as
|
|
7
|
-
import { userErrorMessage as
|
|
8
|
-
import { cn as
|
|
3
|
+
import { Loader2 as pe, X as ye, ChevronRight as Oe } from "lucide-react";
|
|
4
|
+
import { useState as N, useMemo as Z, useCallback as Te, useEffect as Ee } from "react";
|
|
5
|
+
import { useNivaroClient as we } from "../context.js";
|
|
6
|
+
import { get as oe, patch as ke, post as he, del as ve } from "../lib/commands.js";
|
|
7
|
+
import { userErrorMessage as ge } from "../lib/safe-error.js";
|
|
8
|
+
import { cn as X } from "../lib/utils.js";
|
|
9
9
|
import { ChangeReasonDialog as _e, changeReasonChallenge as $e } from "./item-edit/ChangeReasonDialog.js";
|
|
10
|
-
import { applyDisplayTemplate as
|
|
10
|
+
import { applyDisplayTemplate as Ae } from "./item-edit/helpers.js";
|
|
11
11
|
import { RelationCombobox as xe } from "./item-edit/RelationCombobox.js";
|
|
12
12
|
import { JsonMapEditor as Me } from "./JsonMapEditor.js";
|
|
13
|
-
import { colorPair as
|
|
14
|
-
const
|
|
13
|
+
import { colorPair as Fe } from "./QueryTable.js";
|
|
14
|
+
const W = [
|
|
15
15
|
"january",
|
|
16
16
|
"february",
|
|
17
17
|
"march",
|
|
@@ -38,64 +38,64 @@ const J = [
|
|
|
38
38
|
"Nov",
|
|
39
39
|
"Dec"
|
|
40
40
|
];
|
|
41
|
-
function
|
|
42
|
-
return typeof t == "string" && t.startsWith("$scope.") ? m[t.slice(7)] : Array.isArray(t) ? t.map((
|
|
43
|
-
Object.entries(t).map(([
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
function Y(t, m) {
|
|
42
|
+
return typeof t == "string" && t.startsWith("$scope.") ? m[t.slice(7)] : Array.isArray(t) ? t.map((_) => Y(_, m)) : t && typeof t == "object" ? Object.fromEntries(
|
|
43
|
+
Object.entries(t).map(([_, i]) => [
|
|
44
|
+
_,
|
|
45
|
+
Y(i, m)
|
|
46
46
|
])
|
|
47
47
|
) : t;
|
|
48
48
|
}
|
|
49
49
|
function fe(t) {
|
|
50
50
|
return t === void 0 ? !0 : Array.isArray(t) ? t.some(fe) : t && typeof t == "object" ? Object.values(t).some(fe) : !1;
|
|
51
51
|
}
|
|
52
|
-
function
|
|
53
|
-
return t.browse ? /* @__PURE__ */ l(
|
|
52
|
+
function Ye({ config: t }) {
|
|
53
|
+
return t.browse ? /* @__PURE__ */ l(Re, { config: t }) : /* @__PURE__ */ l(De, { config: t });
|
|
54
54
|
}
|
|
55
|
-
function
|
|
56
|
-
var ce,
|
|
57
|
-
const m =
|
|
58
|
-
(r) =>
|
|
59
|
-
), g = JSON.stringify(
|
|
55
|
+
function De({ config: t }) {
|
|
56
|
+
var ce, le;
|
|
57
|
+
const m = we(), _ = Ne(), [i, p] = N({}), [$, k] = N({}), [S, C] = N([]), [v, x] = N(/* @__PURE__ */ new Set()), [J, L] = N(!1), [z, O] = N(null), [B, P] = N(null), [E, f] = N(null), q = (t.scope ?? []).every(
|
|
58
|
+
(r) => i[r.field] !== null && i[r.field] !== void 0 && i[r.field] !== ""
|
|
59
|
+
), g = JSON.stringify(i), de = Z(() => {
|
|
60
60
|
const r = [];
|
|
61
|
-
for (const s of t.month_sets ?? []) for (const n of
|
|
61
|
+
for (const s of t.month_sets ?? []) for (const n of W) r.push(`${n}${s.suffix}`);
|
|
62
62
|
for (const s of t.columns ?? []) r.push(s.field);
|
|
63
63
|
return r;
|
|
64
|
-
}, [t]), { data:
|
|
64
|
+
}, [t]), { data: ee = [], isLoading: ne } = be({
|
|
65
65
|
queryKey: ["record-grid-rows", t.collection, g],
|
|
66
66
|
queryFn: () => {
|
|
67
67
|
const r = {};
|
|
68
|
-
for (const s of t.scope ?? []) r[s.field] = { _eq:
|
|
68
|
+
for (const s of t.scope ?? []) r[s.field] = { _eq: i[s.field] };
|
|
69
69
|
return m.request(
|
|
70
|
-
|
|
70
|
+
oe(`/items/${t.collection}`, {
|
|
71
71
|
limit: 2e3,
|
|
72
72
|
...Object.keys(r).length ? { filter: JSON.stringify(r) } : {}
|
|
73
73
|
})
|
|
74
74
|
).then((s) => s.data ?? []);
|
|
75
75
|
},
|
|
76
|
-
enabled:
|
|
76
|
+
enabled: q,
|
|
77
77
|
staleTime: 1e4
|
|
78
|
-
}), { data:
|
|
78
|
+
}), { data: R = [] } = be({
|
|
79
79
|
queryKey: ["record-grid-source", (ce = t.row_source) == null ? void 0 : ce.collection, g],
|
|
80
80
|
queryFn: () => {
|
|
81
81
|
const r = t.row_source;
|
|
82
82
|
if (!r) return Promise.resolve([]);
|
|
83
|
-
const s =
|
|
83
|
+
const s = Y(r.filter, i), n = s && !fe(s) ? s : void 0;
|
|
84
84
|
return m.request(
|
|
85
|
-
|
|
85
|
+
oe(`/items/${r.collection}`, {
|
|
86
86
|
limit: 1e3,
|
|
87
87
|
...r.sort ? { sort: r.sort } : {},
|
|
88
88
|
...n ? { filter: JSON.stringify(n) } : {}
|
|
89
89
|
})
|
|
90
|
-
).then((
|
|
90
|
+
).then((h) => h.data ?? []);
|
|
91
91
|
},
|
|
92
|
-
enabled:
|
|
92
|
+
enabled: q && !!t.row_source,
|
|
93
93
|
staleTime: 3e4
|
|
94
|
-
}),
|
|
94
|
+
}), j = Z(() => {
|
|
95
95
|
if (t.row_source) {
|
|
96
96
|
const r = t.row_source;
|
|
97
|
-
return
|
|
98
|
-
const n =
|
|
97
|
+
return R.map((s) => {
|
|
98
|
+
const n = ee.find((h) => String(h[r.fk_field]) === String(s.id)) ?? null;
|
|
99
99
|
return {
|
|
100
100
|
key: `src-${s.id}`,
|
|
101
101
|
record: n,
|
|
@@ -106,91 +106,91 @@ function Ee({ config: t }) {
|
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
108
|
return [
|
|
109
|
-
...
|
|
110
|
-
...
|
|
109
|
+
...ee.filter((r) => !v.has(String(r.id))).map((r) => ({ key: `rec-${r.id}`, record: r, isNew: !1 })),
|
|
110
|
+
...S.map((r) => ({ key: r, record: null, isNew: !0 }))
|
|
111
111
|
];
|
|
112
|
-
}, [t.row_source,
|
|
113
|
-
var
|
|
114
|
-
const n = (
|
|
112
|
+
}, [t.row_source, R, ee, S, v]), I = (r, s) => {
|
|
113
|
+
var A, y;
|
|
114
|
+
const n = (A = $[r.key]) == null ? void 0 : A[s];
|
|
115
115
|
if (n !== void 0) return n;
|
|
116
|
-
const
|
|
117
|
-
return
|
|
118
|
-
},
|
|
119
|
-
async function
|
|
120
|
-
var
|
|
121
|
-
|
|
122
|
-
let s = 0, n = 0,
|
|
116
|
+
const h = (y = r.record) == null ? void 0 : y[s];
|
|
117
|
+
return h == null ? "" : String(h);
|
|
118
|
+
}, w = (r, s, n) => k((h) => ({ ...h, [r]: { ...h[r] ?? {}, [s]: n } })), te = Object.values($).some((r) => Object.keys(r).length > 0) || S.length > 0 || v.size > 0;
|
|
119
|
+
async function V(r) {
|
|
120
|
+
var A;
|
|
121
|
+
L(!0), P(null);
|
|
122
|
+
let s = 0, n = 0, h = 0;
|
|
123
123
|
try {
|
|
124
|
-
for (const
|
|
125
|
-
const
|
|
126
|
-
if (!
|
|
127
|
-
const
|
|
128
|
-
for (const [
|
|
129
|
-
!de.includes(
|
|
130
|
-
if (t.computed_total_field && ((
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
var
|
|
134
|
-
const Q = `${
|
|
124
|
+
for (const y of j) {
|
|
125
|
+
const T = $[y.key] ?? {}, G = Object.keys(T).length > 0;
|
|
126
|
+
if (!y.record && !G) continue;
|
|
127
|
+
const M = {};
|
|
128
|
+
for (const [F, D] of Object.entries(T))
|
|
129
|
+
!de.includes(F) && !(t.key_columns ?? []).some((U) => U.field === F) || (M[F] = D === "" ? null : Number.isNaN(Number(D)) ? D : Number(D));
|
|
130
|
+
if (t.computed_total_field && ((A = t.month_sets) != null && A.length)) {
|
|
131
|
+
const F = t.month_sets[0];
|
|
132
|
+
M[t.computed_total_field] = W.reduce((D, U) => {
|
|
133
|
+
var ae;
|
|
134
|
+
const Q = `${U}${F.suffix}`, ue = T[Q] !== void 0 ? Number(T[Q]) || 0 : Number((ae = y.record) == null ? void 0 : ae[Q]) || 0;
|
|
135
135
|
return D + ue;
|
|
136
136
|
}, 0);
|
|
137
137
|
}
|
|
138
|
-
if (
|
|
139
|
-
if (Object.keys(
|
|
140
|
-
r && (
|
|
138
|
+
if (y.record) {
|
|
139
|
+
if (Object.keys(M).length === 0) continue;
|
|
140
|
+
r && (M._change_reason = r), await m.request(ke(`/items/${t.collection}/${y.record.id}`, M)), n++;
|
|
141
141
|
} else {
|
|
142
|
-
if (!
|
|
143
|
-
for (const
|
|
144
|
-
t.row_source && (
|
|
142
|
+
if (!G) continue;
|
|
143
|
+
for (const F of t.scope ?? []) M[F.field] = i[F.field];
|
|
144
|
+
t.row_source && (M[t.row_source.fk_field] = y.sourceId), await m.request(he(`/items/${t.collection}`, M)), s++;
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
|
-
for (const
|
|
148
|
-
await m.request(
|
|
147
|
+
for (const y of v)
|
|
148
|
+
await m.request(ve(`/items/${t.collection}/${y}`)), h++;
|
|
149
149
|
if (t.after_save) {
|
|
150
|
-
const
|
|
150
|
+
const y = Y(t.after_save.params ?? {}, i);
|
|
151
151
|
await m.request(
|
|
152
|
-
he(`/custom-queries/${t.after_save.query_slug}/execute`, { params:
|
|
152
|
+
he(`/custom-queries/${t.after_save.query_slug}/execute`, { params: y })
|
|
153
153
|
);
|
|
154
154
|
}
|
|
155
|
-
|
|
156
|
-
`Saved — ${n} updated, ${s} created${
|
|
155
|
+
k({}), C([]), x(/* @__PURE__ */ new Set()), await _.invalidateQueries({ queryKey: ["record-grid-rows", t.collection] }), P(
|
|
156
|
+
`Saved — ${n} updated, ${s} created${h ? `, ${h} deleted` : ""}`
|
|
157
157
|
);
|
|
158
|
-
} catch (
|
|
159
|
-
const
|
|
160
|
-
|
|
158
|
+
} catch (y) {
|
|
159
|
+
const T = $e(y);
|
|
160
|
+
T ? (O(T), P(null)) : P(`Save failed: ${ge(y, "unknown error")}`);
|
|
161
161
|
} finally {
|
|
162
|
-
|
|
162
|
+
L(!1);
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
|
-
const
|
|
165
|
+
const re = [
|
|
166
166
|
...(t.month_sets ?? []).flatMap(
|
|
167
|
-
(r) =>
|
|
167
|
+
(r) => W.map((s, n) => ({ field: `${s}${r.suffix}`, label: `${Se[n]} ${r.label}` }))
|
|
168
168
|
),
|
|
169
169
|
...(t.columns ?? []).map((r) => ({ field: r.field, label: r.label ?? r.field }))
|
|
170
170
|
];
|
|
171
|
-
return /* @__PURE__ */
|
|
171
|
+
return /* @__PURE__ */ c("div", { className: "flex h-full flex-col gap-3 overflow-auto p-3", children: [
|
|
172
172
|
/* @__PURE__ */ l(
|
|
173
173
|
_e,
|
|
174
174
|
{
|
|
175
|
-
challenge:
|
|
176
|
-
onCancel: () =>
|
|
175
|
+
challenge: z,
|
|
176
|
+
onCancel: () => O(null),
|
|
177
177
|
onSubmit: (r) => {
|
|
178
|
-
|
|
178
|
+
O(null), V(r);
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
),
|
|
182
|
-
/* @__PURE__ */
|
|
182
|
+
/* @__PURE__ */ c("div", { className: "flex flex-wrap items-end gap-3", children: [
|
|
183
183
|
(t.scope ?? []).map((r) => {
|
|
184
|
-
const s =
|
|
185
|
-
return /* @__PURE__ */
|
|
186
|
-
/* @__PURE__ */ l("p", { className: "mb-1 text-[11px] font-medium text-slate-500", children: r.label ?? r.field.replace(/_/g, " ").replace(/\b\w/g, (
|
|
184
|
+
const s = Y(r.filter, i), n = s && !fe(s) ? s : void 0;
|
|
185
|
+
return /* @__PURE__ */ c("div", { className: "w-52", children: [
|
|
186
|
+
/* @__PURE__ */ l("p", { className: "mb-1 text-[11px] font-medium text-slate-500", children: r.label ?? r.field.replace(/_/g, " ").replace(/\b\w/g, (h) => h.toUpperCase()) }),
|
|
187
187
|
/* @__PURE__ */ l(
|
|
188
188
|
xe,
|
|
189
189
|
{
|
|
190
190
|
collection: r.collection,
|
|
191
|
-
value:
|
|
192
|
-
onChange: (
|
|
193
|
-
|
|
191
|
+
value: i[r.field] ?? null,
|
|
192
|
+
onChange: (h) => {
|
|
193
|
+
p((A) => ({ ...A, [r.field]: h })), k({}), C([]), x(/* @__PURE__ */ new Set());
|
|
194
194
|
},
|
|
195
195
|
extraFilter: n,
|
|
196
196
|
placeholder: "Select…"
|
|
@@ -198,31 +198,31 @@ function Ee({ config: t }) {
|
|
|
198
198
|
)
|
|
199
199
|
] }, r.field);
|
|
200
200
|
}),
|
|
201
|
-
/* @__PURE__ */
|
|
201
|
+
/* @__PURE__ */ c(
|
|
202
202
|
"button",
|
|
203
203
|
{
|
|
204
204
|
type: "button",
|
|
205
|
-
disabled: !
|
|
206
|
-
onClick: () => void
|
|
205
|
+
disabled: !q || !te || J,
|
|
206
|
+
onClick: () => void V(),
|
|
207
207
|
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",
|
|
208
208
|
children: [
|
|
209
|
-
|
|
209
|
+
J && /* @__PURE__ */ l(pe, { className: "h-3.5 w-3.5 animate-spin" }),
|
|
210
210
|
"Save changes"
|
|
211
211
|
]
|
|
212
212
|
}
|
|
213
213
|
),
|
|
214
|
-
t.allow_add &&
|
|
214
|
+
t.allow_add && q && /* @__PURE__ */ l(
|
|
215
215
|
"button",
|
|
216
216
|
{
|
|
217
217
|
type: "button",
|
|
218
|
-
onClick: () =>
|
|
218
|
+
onClick: () => C((r) => [...r, `new-${r.length}-${Math.random().toString(36).slice(2, 8)}`]),
|
|
219
219
|
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",
|
|
220
220
|
children: "+ Add row"
|
|
221
221
|
}
|
|
222
222
|
),
|
|
223
223
|
(t.toolbar_editors ?? []).map((r, s) => {
|
|
224
224
|
const n = (r.require_scope ?? []).every(
|
|
225
|
-
(
|
|
225
|
+
(h) => i[h] !== null && i[h] !== void 0 && i[h] !== ""
|
|
226
226
|
);
|
|
227
227
|
return /* @__PURE__ */ l(
|
|
228
228
|
"button",
|
|
@@ -230,53 +230,53 @@ function Ee({ config: t }) {
|
|
|
230
230
|
type: "button",
|
|
231
231
|
disabled: !n,
|
|
232
232
|
title: n ? void 0 : `Choose ${(r.require_scope ?? []).join(", ")} first`,
|
|
233
|
-
onClick: () =>
|
|
233
|
+
onClick: () => f(s),
|
|
234
234
|
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",
|
|
235
235
|
children: r.button_label
|
|
236
236
|
},
|
|
237
237
|
r.button_label
|
|
238
238
|
);
|
|
239
239
|
}),
|
|
240
|
-
|
|
240
|
+
B && /* @__PURE__ */ l("span", { className: "pb-2 text-[12px] text-slate-500", children: B })
|
|
241
241
|
] }),
|
|
242
|
-
|
|
242
|
+
E !== null && ((le = t.toolbar_editors) == null ? void 0 : le[E]) && /* @__PURE__ */ l(
|
|
243
243
|
"div",
|
|
244
244
|
{
|
|
245
245
|
className: "fixed inset-0 z-[60] flex justify-end bg-black/30",
|
|
246
|
-
onClick: () =>
|
|
247
|
-
children: /* @__PURE__ */
|
|
246
|
+
onClick: () => f(null),
|
|
247
|
+
children: /* @__PURE__ */ c(
|
|
248
248
|
"div",
|
|
249
249
|
{
|
|
250
250
|
className: "flex h-full flex-col border-l border-slate-200 bg-white shadow-2xl dark:border-border dark:bg-background",
|
|
251
251
|
style: {
|
|
252
|
-
width: typeof t.toolbar_editors[
|
|
252
|
+
width: typeof t.toolbar_editors[E].sheet_width == "number" ? `${t.toolbar_editors[E].sheet_width}px` : t.toolbar_editors[E].sheet_width ?? "70%",
|
|
253
253
|
maxWidth: "96%"
|
|
254
254
|
},
|
|
255
255
|
onClick: (r) => r.stopPropagation(),
|
|
256
256
|
children: [
|
|
257
|
-
/* @__PURE__ */
|
|
258
|
-
/* @__PURE__ */ l("p", { className: "text-[13px] font-semibold text-slate-700 dark:text-slate-200", children: t.toolbar_editors[
|
|
257
|
+
/* @__PURE__ */ c("div", { className: "flex shrink-0 items-center justify-between border-b border-slate-200 px-4 py-2.5 dark:border-border", children: [
|
|
258
|
+
/* @__PURE__ */ l("p", { className: "text-[13px] font-semibold text-slate-700 dark:text-slate-200", children: t.toolbar_editors[E].button_label }),
|
|
259
259
|
/* @__PURE__ */ l(
|
|
260
260
|
"button",
|
|
261
261
|
{
|
|
262
262
|
type: "button",
|
|
263
|
-
onClick: () =>
|
|
263
|
+
onClick: () => f(null),
|
|
264
264
|
className: "rounded px-2 py-1 text-[12px] text-slate-500 hover:bg-slate-100 hover:text-slate-700 dark:hover:bg-muted",
|
|
265
265
|
children: "Close"
|
|
266
266
|
}
|
|
267
267
|
)
|
|
268
268
|
] }),
|
|
269
|
-
/* @__PURE__ */ l("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ l(Me, { config: t.toolbar_editors[
|
|
269
|
+
/* @__PURE__ */ l("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ l(Me, { config: t.toolbar_editors[E].json_map, scope: i }) })
|
|
270
270
|
]
|
|
271
271
|
}
|
|
272
272
|
)
|
|
273
273
|
}
|
|
274
274
|
),
|
|
275
|
-
|
|
275
|
+
q ? ne ? /* @__PURE__ */ c("div", { className: "flex items-center gap-2 text-[12px] text-slate-400", children: [
|
|
276
276
|
/* @__PURE__ */ l(pe, { className: "h-4 w-4 animate-spin" }),
|
|
277
277
|
" Loading…"
|
|
278
|
-
] }) : /* @__PURE__ */ l("div", { className: "overflow-x-auto", children: /* @__PURE__ */
|
|
279
|
-
/* @__PURE__ */ l("thead", { children: /* @__PURE__ */
|
|
278
|
+
] }) : /* @__PURE__ */ l("div", { className: "overflow-x-auto", children: /* @__PURE__ */ c("table", { className: "w-full text-[12px]", children: [
|
|
279
|
+
/* @__PURE__ */ l("thead", { children: /* @__PURE__ */ c("tr", { className: "border-b border-slate-200 text-left dark:border-border", children: [
|
|
280
280
|
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, " ") }),
|
|
281
281
|
(t.key_columns ?? []).map((r) => /* @__PURE__ */ l(
|
|
282
282
|
"th",
|
|
@@ -286,7 +286,7 @@ function Ee({ config: t }) {
|
|
|
286
286
|
},
|
|
287
287
|
r.field
|
|
288
288
|
)),
|
|
289
|
-
|
|
289
|
+
re.map((r) => /* @__PURE__ */ l(
|
|
290
290
|
"th",
|
|
291
291
|
{
|
|
292
292
|
className: "min-w-[86px] py-1.5 pr-2 text-right font-medium text-slate-500",
|
|
@@ -296,9 +296,9 @@ function Ee({ config: t }) {
|
|
|
296
296
|
)),
|
|
297
297
|
t.allow_delete && /* @__PURE__ */ l("th", { "aria-label": "Remove" })
|
|
298
298
|
] }) }),
|
|
299
|
-
/* @__PURE__ */
|
|
300
|
-
|
|
301
|
-
t.row_source && /* @__PURE__ */
|
|
299
|
+
/* @__PURE__ */ c("tbody", { children: [
|
|
300
|
+
j.map((r) => /* @__PURE__ */ c("tr", { className: "border-b border-slate-100 dark:border-border/50", children: [
|
|
301
|
+
t.row_source && /* @__PURE__ */ c("td", { className: "whitespace-nowrap py-1 pr-3 font-medium text-slate-700 dark:text-slate-200", children: [
|
|
302
302
|
r.sourceLabel,
|
|
303
303
|
r.isNew && /* @__PURE__ */ l("span", { className: "ml-1.5 text-[10px] text-slate-400", children: "(new)" })
|
|
304
304
|
] }),
|
|
@@ -306,17 +306,21 @@ function Ee({ config: t }) {
|
|
|
306
306
|
xe,
|
|
307
307
|
{
|
|
308
308
|
collection: s.collection,
|
|
309
|
-
value:
|
|
310
|
-
onChange: (n) =>
|
|
309
|
+
value: I(r, s.field) || null,
|
|
310
|
+
onChange: (n) => w(r.key, s.field, n == null ? "" : String(n)),
|
|
311
311
|
placeholder: "Select…"
|
|
312
312
|
}
|
|
313
313
|
) }, s.field)),
|
|
314
|
-
|
|
314
|
+
re.map((s) => /* @__PURE__ */ l("td", { className: "py-0.5 pr-2 text-right", children: /* @__PURE__ */ l(
|
|
315
315
|
"input",
|
|
316
316
|
{
|
|
317
317
|
type: "number",
|
|
318
|
-
|
|
319
|
-
|
|
318
|
+
min: t.allow_negative ? void 0 : 0,
|
|
319
|
+
value: I(r, s.field),
|
|
320
|
+
title: t.allow_negative ? void 0 : Ce,
|
|
321
|
+
onChange: (n) => {
|
|
322
|
+
!t.allow_negative && n.target.value.trim().startsWith("-") || w(r.key, s.field, n.target.value);
|
|
323
|
+
},
|
|
320
324
|
className: "h-7 w-[84px] rounded border border-slate-200 bg-white px-1.5 text-right text-[12px] tabular-nums outline-none focus:border-nvr-cyan dark:border-border dark:bg-background"
|
|
321
325
|
}
|
|
322
326
|
) }, s.field)),
|
|
@@ -325,10 +329,10 @@ function Ee({ config: t }) {
|
|
|
325
329
|
{
|
|
326
330
|
type: "button",
|
|
327
331
|
onClick: () => {
|
|
328
|
-
r.record ?
|
|
332
|
+
r.record ? x((s) => {
|
|
329
333
|
var n;
|
|
330
334
|
return new Set(s).add(String((n = r.record) == null ? void 0 : n.id));
|
|
331
|
-
}) :
|
|
335
|
+
}) : C((s) => s.filter((n) => n !== r.key)), k((s) => {
|
|
332
336
|
const n = { ...s };
|
|
333
337
|
return delete n[r.key], n;
|
|
334
338
|
});
|
|
@@ -338,53 +342,82 @@ function Ee({ config: t }) {
|
|
|
338
342
|
}
|
|
339
343
|
) })
|
|
340
344
|
] }, r.key)),
|
|
341
|
-
|
|
345
|
+
j.length === 0 && /* @__PURE__ */ l("tr", { children: /* @__PURE__ */ l("td", { colSpan: 99, className: "py-3 text-center text-[12px] text-slate-400", children: "No rows" }) })
|
|
342
346
|
] }),
|
|
343
|
-
/* @__PURE__ */ l("tfoot", { children: /* @__PURE__ */
|
|
347
|
+
/* @__PURE__ */ l("tfoot", { children: /* @__PURE__ */ c("tr", { className: "border-t border-slate-300 font-semibold dark:border-border", children: [
|
|
344
348
|
t.row_source && /* @__PURE__ */ l("td", { className: "py-1.5 pr-3", children: "Total" }),
|
|
345
349
|
(t.key_columns ?? []).map((r, s) => /* @__PURE__ */ l("td", { className: "py-1.5 pr-3", children: !t.row_source && s === 0 ? "Total" : "" }, r.field)),
|
|
346
|
-
|
|
350
|
+
re.map((r) => /* @__PURE__ */ l("td", { className: "py-1.5 pr-2 text-right tabular-nums", children: j.reduce((s, n) => s + (Number(I(n, r.field)) || 0), 0).toLocaleString("en-US", { maximumFractionDigits: 2 }) }, r.field)),
|
|
347
351
|
t.allow_delete && /* @__PURE__ */ l("td", {})
|
|
348
352
|
] }) })
|
|
349
|
-
] }) }) : /* @__PURE__ */
|
|
353
|
+
] }) }) : /* @__PURE__ */ c("p", { className: "text-[12px] text-slate-400", children: [
|
|
350
354
|
"Choose ",
|
|
351
355
|
(t.scope ?? []).map((r) => r.label ?? r.field).join(", "),
|
|
352
356
|
" to load rows."
|
|
353
357
|
] })
|
|
354
358
|
] });
|
|
355
359
|
}
|
|
356
|
-
const
|
|
357
|
-
function Le({
|
|
360
|
+
const K = (t, m) => t == null || !Number.isFinite(t) || m != null && m.blankZero && t === 0 ? "—" : t.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 }), Ce = "Enter an amount of zero or more";
|
|
361
|
+
function Le(t, m) {
|
|
362
|
+
const _ = t.replace(/[^\d.-]/g, "");
|
|
363
|
+
if (_.includes("-") && !m) return { value: null, refused: Ce };
|
|
364
|
+
const i = _.startsWith("-") ? "-" : "", p = _.replace(/-/g, ""), $ = p.indexOf("."), k = $ < 0 ? p : `${p.slice(0, $ + 1)}${p.slice($ + 1).replace(/\./g, "")}`;
|
|
365
|
+
return { value: `${i}${k}`, refused: null };
|
|
366
|
+
}
|
|
367
|
+
function ze({
|
|
358
368
|
value: t,
|
|
359
369
|
original: m,
|
|
360
|
-
onChange:
|
|
361
|
-
disabled:
|
|
370
|
+
onChange: _,
|
|
371
|
+
disabled: i,
|
|
372
|
+
allowNegative: p = !1
|
|
362
373
|
}) {
|
|
363
|
-
const [
|
|
364
|
-
return /* @__PURE__ */
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
374
|
+
const [$, k] = N(!1), [S, C] = N(null), v = t !== m, x = t === "" ? null : Number(t), J = $ || x == null || Number.isNaN(x) ? t : K(x), L = v && x != null && !Number.isNaN(x) ? x - (Number(m) || 0) : 0;
|
|
375
|
+
return /* @__PURE__ */ c("span", { className: "relative inline-block", children: [
|
|
376
|
+
/* @__PURE__ */ l(
|
|
377
|
+
"input",
|
|
378
|
+
{
|
|
379
|
+
type: "text",
|
|
380
|
+
inputMode: "decimal",
|
|
381
|
+
value: J,
|
|
382
|
+
disabled: i,
|
|
383
|
+
"aria-invalid": S ? !0 : void 0,
|
|
384
|
+
title: S ?? (v ? `Was ${K(Number(m) || 0)} (${L >= 0 ? "+" : "−"}${K(Math.abs(L))})` : void 0),
|
|
385
|
+
onFocus: (z) => {
|
|
386
|
+
k(!0);
|
|
387
|
+
const O = z.currentTarget;
|
|
388
|
+
requestAnimationFrame(() => {
|
|
389
|
+
document.activeElement === O && O.select();
|
|
390
|
+
});
|
|
391
|
+
},
|
|
392
|
+
onBlur: () => {
|
|
393
|
+
k(!1), C(null);
|
|
394
|
+
},
|
|
395
|
+
onChange: (z) => {
|
|
396
|
+
const O = Le(z.target.value, p);
|
|
397
|
+
C(O.refused), O.value != null && _(O.value);
|
|
398
|
+
},
|
|
399
|
+
className: X(
|
|
400
|
+
"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",
|
|
401
|
+
S ? "border-red-400 focus:border-red-400" : v ? "border-nvr-cyan bg-nvr-cyan/[0.06] dark:bg-nvr-cyan/10" : "border-slate-200 dark:border-border",
|
|
402
|
+
!v && (x === 0 || x == null) && "text-slate-400"
|
|
403
|
+
)
|
|
404
|
+
}
|
|
405
|
+
),
|
|
406
|
+
S && /* @__PURE__ */ l(
|
|
407
|
+
"span",
|
|
408
|
+
{
|
|
409
|
+
role: "alert",
|
|
410
|
+
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",
|
|
411
|
+
children: S
|
|
412
|
+
}
|
|
413
|
+
)
|
|
414
|
+
] });
|
|
382
415
|
}
|
|
383
|
-
function
|
|
384
|
-
var ue,
|
|
385
|
-
const m =
|
|
416
|
+
function Re({ config: t }) {
|
|
417
|
+
var ue, ae;
|
|
418
|
+
const m = we(), _ = Ne(), i = t.key_columns ?? [], [p, $] = N({}), [k, S] = N({}), [C, v] = N([]), [x, J] = N(/* @__PURE__ */ new Set()), [L, z] = N(!1), [O, B] = N(null), [P, E] = N(null), f = i.length > 0 && i.every((e) => p[e.field] != null && p[e.field] !== ""), q = Z(() => {
|
|
386
419
|
const e = (t.month_sets ?? []).flatMap(
|
|
387
|
-
(a) =>
|
|
420
|
+
(a) => W.map((d, u) => ({
|
|
388
421
|
field: `${d}${a.suffix}`,
|
|
389
422
|
label: `${Se[u]}${a.label ? ` ${a.label}` : ""}`
|
|
390
423
|
}))
|
|
@@ -393,170 +426,170 @@ function Ae({ config: t }) {
|
|
|
393
426
|
label: a.label ?? a.field
|
|
394
427
|
}));
|
|
395
428
|
return [...e, ...o];
|
|
396
|
-
}, [t.month_sets, t.columns]), g = (ue = t.month_sets) == null ? void 0 : ue[0], { data: de = [], isLoading:
|
|
429
|
+
}, [t.month_sets, t.columns]), g = (ue = t.month_sets) == null ? void 0 : ue[0], { data: de = [], isLoading: ee } = be({
|
|
397
430
|
queryKey: ["record-grid-browse-rows", t.collection],
|
|
398
431
|
queryFn: () => m.request(
|
|
399
|
-
|
|
432
|
+
oe(`/items/${t.collection}`, { limit: 5e3 })
|
|
400
433
|
).then((e) => e.data ?? []),
|
|
401
434
|
staleTime: 1e4
|
|
402
435
|
}), { data: ne = {} } = be({
|
|
403
|
-
queryKey: ["record-grid-browse-labels",
|
|
436
|
+
queryKey: ["record-grid-browse-labels", i.map((e) => e.collection).join(",")],
|
|
404
437
|
queryFn: async () => {
|
|
405
438
|
const e = {};
|
|
406
439
|
return await Promise.all(
|
|
407
|
-
|
|
440
|
+
i.map(async (o) => {
|
|
408
441
|
const a = await m.request(
|
|
409
|
-
|
|
442
|
+
oe(`/collections/${o.collection}`)
|
|
410
443
|
).then((b) => b.data).catch(() => null), d = await m.request(
|
|
411
|
-
|
|
444
|
+
oe(`/items/${o.collection}`, { limit: 1e3 })
|
|
412
445
|
).then((b) => b.data ?? []).catch(() => []), u = /* @__PURE__ */ new Map();
|
|
413
446
|
for (const b of d)
|
|
414
|
-
u.set(String(b.id),
|
|
447
|
+
u.set(String(b.id), Ae(a == null ? void 0 : a.display_template, b) || String(b.id));
|
|
415
448
|
e[o.field] = u;
|
|
416
449
|
})
|
|
417
450
|
), e;
|
|
418
451
|
},
|
|
419
|
-
enabled:
|
|
452
|
+
enabled: i.length > 0,
|
|
420
453
|
staleTime: 3e5
|
|
421
|
-
}),
|
|
454
|
+
}), R = Te(
|
|
422
455
|
(e, o) => {
|
|
423
456
|
var a;
|
|
424
457
|
return o == null ? "—" : ((a = ne[e]) == null ? void 0 : a.get(String(o))) ?? String(o);
|
|
425
458
|
},
|
|
426
459
|
[ne]
|
|
427
|
-
),
|
|
460
|
+
), j = Z(
|
|
428
461
|
() => de.filter(
|
|
429
|
-
(e) =>
|
|
430
|
-
(o) =>
|
|
462
|
+
(e) => i.every(
|
|
463
|
+
(o) => p[o.field] == null || p[o.field] === "" || String(e[o.field]) === String(p[o.field])
|
|
431
464
|
)
|
|
432
465
|
),
|
|
433
|
-
[de,
|
|
434
|
-
),
|
|
435
|
-
if (
|
|
466
|
+
[de, i, p]
|
|
467
|
+
), I = (ae = i[0]) == null ? void 0 : ae.field, w = i.filter((e) => p[e.field] == null || p[e.field] === ""), te = Z(() => {
|
|
468
|
+
if (f) return [];
|
|
436
469
|
const e = /* @__PURE__ */ new Map();
|
|
437
|
-
for (const o of
|
|
470
|
+
for (const o of j) {
|
|
438
471
|
const a = {};
|
|
439
|
-
for (const b of
|
|
440
|
-
const d =
|
|
441
|
-
for (const b of
|
|
472
|
+
for (const b of w) a[b.field] = o[b.field];
|
|
473
|
+
const d = w.map((b) => String(o[b.field] ?? "")).join("|"), u = e.get(d) ?? { keyVals: a, sums: {}, count: 0 };
|
|
474
|
+
for (const b of q)
|
|
442
475
|
u.sums[b.field] = (u.sums[b.field] ?? 0) + (Number(o[b.field]) || 0);
|
|
443
476
|
u.count++, e.set(d, u);
|
|
444
477
|
}
|
|
445
478
|
return [...e.values()].sort((o, a) => {
|
|
446
|
-
for (const d of
|
|
447
|
-
const u =
|
|
448
|
-
|
|
479
|
+
for (const d of w) {
|
|
480
|
+
const u = R(d.field, o.keyVals[d.field]).localeCompare(
|
|
481
|
+
R(d.field, a.keyVals[d.field]),
|
|
449
482
|
void 0,
|
|
450
483
|
{ numeric: !0 }
|
|
451
484
|
);
|
|
452
|
-
if (u) return d.field ===
|
|
485
|
+
if (u) return d.field === I ? -u : u;
|
|
453
486
|
}
|
|
454
487
|
return 0;
|
|
455
488
|
});
|
|
456
|
-
}, [
|
|
457
|
-
...
|
|
458
|
-
|
|
459
|
-
] : [], [
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
}, [
|
|
489
|
+
}, [j, w, f, q, R, I]), V = Z(() => f ? [
|
|
490
|
+
...j.filter((e) => !x.has(String(e.id))).map((e) => ({ key: `rec-${e.id}`, record: e, isNew: !1 })),
|
|
491
|
+
...C.map((e) => ({ key: e, record: null, isNew: !0 }))
|
|
492
|
+
] : [], [j, f, C, x]);
|
|
493
|
+
Ee(() => {
|
|
494
|
+
f && j.length === 0 && C.length === 0 && x.size === 0 && v([`new-${Date.now()}`]);
|
|
495
|
+
}, [f, j.length, C.length, x.size]);
|
|
463
496
|
const ie = (e, o) => {
|
|
464
497
|
var u, b;
|
|
465
|
-
const a = (u =
|
|
498
|
+
const a = (u = k[e.key]) == null ? void 0 : u[o];
|
|
466
499
|
if (a !== void 0) return a;
|
|
467
500
|
const d = (b = e.record) == null ? void 0 : b[o];
|
|
468
501
|
return d == null ? "" : String(d);
|
|
469
|
-
},
|
|
502
|
+
}, re = (e, o) => {
|
|
470
503
|
var d;
|
|
471
504
|
const a = (d = e.record) == null ? void 0 : d[o];
|
|
472
505
|
return a == null ? "" : String(a);
|
|
473
|
-
}, ce = (e, o, a) =>
|
|
474
|
-
|
|
506
|
+
}, ce = (e, o, a) => S((d) => ({ ...d, [e]: { ...d[e] ?? {}, [o]: a } })), le = (e) => g ? W.reduce((o, a) => o + (Number(ie(e, `${a}${g.suffix}`)) || 0), 0) : null, r = Object.values(k).some((e) => Object.keys(e).length > 0) || x.size > 0 || C.some((e) => Object.keys(k[e] ?? {}).length > 0), s = () => {
|
|
507
|
+
S({}), v([]), J(/* @__PURE__ */ new Set());
|
|
475
508
|
}, n = (e) => {
|
|
476
|
-
|
|
477
|
-
},
|
|
478
|
-
|
|
509
|
+
$((o) => ({ ...o, ...e })), s();
|
|
510
|
+
}, h = (e, o) => {
|
|
511
|
+
$((a) => ({ ...a, [e]: o })), s();
|
|
479
512
|
};
|
|
480
|
-
async function
|
|
481
|
-
|
|
513
|
+
async function A(e) {
|
|
514
|
+
z(!0), E(null);
|
|
482
515
|
let o = 0, a = 0, d = 0;
|
|
483
516
|
try {
|
|
484
|
-
for (const u of
|
|
485
|
-
const b =
|
|
517
|
+
for (const u of V) {
|
|
518
|
+
const b = k[u.key] ?? {};
|
|
486
519
|
if (Object.keys(b).length === 0) continue;
|
|
487
|
-
const
|
|
488
|
-
for (const [
|
|
489
|
-
|
|
490
|
-
if (t.computed_total_field && g && (
|
|
491
|
-
e && (
|
|
520
|
+
const H = {};
|
|
521
|
+
for (const [se, me] of Object.entries(b))
|
|
522
|
+
q.some((qe) => qe.field === se) && (H[se] = me === "" ? null : Number.isNaN(Number(me)) ? me : Number(me));
|
|
523
|
+
if (t.computed_total_field && g && (H[t.computed_total_field] = le(u)), u.record)
|
|
524
|
+
e && (H._change_reason = e), await m.request(ke(`/items/${t.collection}/${u.record.id}`, H)), a++;
|
|
492
525
|
else {
|
|
493
|
-
for (const
|
|
494
|
-
await m.request(he(`/items/${t.collection}`,
|
|
526
|
+
for (const se of i) H[se.field] = p[se.field];
|
|
527
|
+
await m.request(he(`/items/${t.collection}`, H)), o++;
|
|
495
528
|
}
|
|
496
529
|
}
|
|
497
|
-
for (const u of
|
|
498
|
-
await m.request(
|
|
530
|
+
for (const u of x)
|
|
531
|
+
await m.request(ve(`/items/${t.collection}/${u}`)), d++;
|
|
499
532
|
if (t.after_save) {
|
|
500
|
-
const u =
|
|
533
|
+
const u = Y(t.after_save.params ?? {}, p);
|
|
501
534
|
await m.request(
|
|
502
535
|
he(`/custom-queries/${t.after_save.query_slug}/execute`, { params: u })
|
|
503
536
|
);
|
|
504
537
|
}
|
|
505
|
-
s(), await
|
|
538
|
+
s(), await _.invalidateQueries({ queryKey: ["record-grid-browse-rows", t.collection] }), E(
|
|
506
539
|
`Saved — ${a} updated, ${o} created${d ? `, ${d} deleted` : ""}`
|
|
507
540
|
);
|
|
508
541
|
} catch (u) {
|
|
509
542
|
const b = $e(u);
|
|
510
|
-
b ?
|
|
543
|
+
b ? B(b) : E(`Save failed: ${ge(u, "unknown error")}`);
|
|
511
544
|
} finally {
|
|
512
|
-
|
|
545
|
+
z(!1);
|
|
513
546
|
}
|
|
514
547
|
}
|
|
515
|
-
const
|
|
548
|
+
const y = (e) => f ? V.reduce((o, a) => o + (Number(ie(a, e)) || 0), 0) : te.reduce((o, a) => o + (a.sums[e] ?? 0), 0), T = (e) => g && e < 12 && e % 3 === 0 && e > 0, G = (e) => g && e < 12 && Math.floor(e / 3) % 2 === 1 ? "bg-slate-50/70 dark:bg-muted/30" : "", [M, F] = Fe("accent"), D = { "--qtc": M, "--qtcd": F }, U = "text-[color:var(--qtc)] dark:text-[color:var(--qtcd)]", Q = (e, o, a = "") => /* @__PURE__ */ l(
|
|
516
549
|
"th",
|
|
517
550
|
{
|
|
518
|
-
className:
|
|
551
|
+
className: X(
|
|
519
552
|
"whitespace-nowrap px-2 py-2 text-right text-[10.5px] font-semibold uppercase tracking-wide text-slate-400",
|
|
520
|
-
|
|
521
|
-
|
|
553
|
+
T(o) && "border-l border-slate-200 dark:border-border",
|
|
554
|
+
G(o),
|
|
522
555
|
a
|
|
523
556
|
),
|
|
524
557
|
children: e
|
|
525
558
|
},
|
|
526
559
|
e + o
|
|
527
560
|
);
|
|
528
|
-
return /* @__PURE__ */
|
|
561
|
+
return /* @__PURE__ */ c("div", { className: "flex h-full min-h-0 flex-col", "data-record-grid-browse": !0, children: [
|
|
529
562
|
/* @__PURE__ */ l(
|
|
530
563
|
_e,
|
|
531
564
|
{
|
|
532
|
-
challenge:
|
|
533
|
-
onCancel: () =>
|
|
565
|
+
challenge: O,
|
|
566
|
+
onCancel: () => B(null),
|
|
534
567
|
onSubmit: (e) => {
|
|
535
|
-
|
|
568
|
+
B(null), A(e);
|
|
536
569
|
}
|
|
537
570
|
}
|
|
538
571
|
),
|
|
539
|
-
/* @__PURE__ */
|
|
540
|
-
|
|
572
|
+
/* @__PURE__ */ c("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: [
|
|
573
|
+
i.map((e) => /* @__PURE__ */ c("div", { className: "w-52", children: [
|
|
541
574
|
/* @__PURE__ */ l("p", { className: "mb-1 text-[11px] font-medium text-slate-500 dark:text-slate-400", children: e.label ?? e.field }),
|
|
542
575
|
/* @__PURE__ */ l(
|
|
543
576
|
xe,
|
|
544
577
|
{
|
|
545
578
|
collection: e.collection,
|
|
546
|
-
value:
|
|
547
|
-
onChange: (o) =>
|
|
579
|
+
value: p[e.field] ?? null,
|
|
580
|
+
onChange: (o) => h(e.field, o),
|
|
548
581
|
placeholder: "All",
|
|
549
582
|
optionSort: e.collection === "funding_years" ? "-id" : void 0
|
|
550
583
|
}
|
|
551
584
|
)
|
|
552
585
|
] }, e.field)),
|
|
553
586
|
/* @__PURE__ */ l("span", { className: "flex-1" }),
|
|
554
|
-
|
|
555
|
-
|
|
587
|
+
P && /* @__PURE__ */ l("span", { className: "pb-2 text-[12px] text-slate-500", children: P }),
|
|
588
|
+
f && t.allow_add && /* @__PURE__ */ l(
|
|
556
589
|
"button",
|
|
557
590
|
{
|
|
558
591
|
type: "button",
|
|
559
|
-
onClick: () =>
|
|
592
|
+
onClick: () => v((e) => [...e, `new-${Date.now()}`]),
|
|
560
593
|
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",
|
|
561
594
|
children: "+ Add row"
|
|
562
595
|
}
|
|
@@ -570,48 +603,48 @@ function Ae({ config: t }) {
|
|
|
570
603
|
children: "Discard"
|
|
571
604
|
}
|
|
572
605
|
),
|
|
573
|
-
/* @__PURE__ */
|
|
606
|
+
/* @__PURE__ */ c(
|
|
574
607
|
"button",
|
|
575
608
|
{
|
|
576
609
|
type: "button",
|
|
577
|
-
disabled: !
|
|
578
|
-
onClick: () => void
|
|
610
|
+
disabled: !f || !r || L,
|
|
611
|
+
onClick: () => void A(),
|
|
579
612
|
"data-record-grid-save": !0,
|
|
580
613
|
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",
|
|
581
614
|
children: [
|
|
582
|
-
|
|
615
|
+
L && /* @__PURE__ */ l(pe, { className: "h-3.5 w-3.5 animate-spin" }),
|
|
583
616
|
"Save changes"
|
|
584
617
|
]
|
|
585
618
|
}
|
|
586
619
|
)
|
|
587
620
|
] }),
|
|
588
|
-
/* @__PURE__ */
|
|
589
|
-
|
|
621
|
+
/* @__PURE__ */ c("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: [
|
|
622
|
+
f ? /* @__PURE__ */ c("span", { children: [
|
|
590
623
|
"Editing",
|
|
591
624
|
" ",
|
|
592
|
-
/* @__PURE__ */ l("strong", { className: "text-slate-700 dark:text-slate-200", children:
|
|
593
|
-
|
|
594
|
-
] }) : /* @__PURE__ */
|
|
625
|
+
/* @__PURE__ */ l("strong", { className: "text-slate-700 dark:text-slate-200", children: i.map((e) => R(e.field, p[e.field])).join(" · ") }),
|
|
626
|
+
V.length > 1 && ` — ${V.length} rows share this combination`
|
|
627
|
+
] }) : /* @__PURE__ */ c("span", { children: [
|
|
595
628
|
"Totals across",
|
|
596
629
|
" ",
|
|
597
|
-
/* @__PURE__ */ l("strong", { className: "text-slate-700 dark:text-slate-200", children:
|
|
630
|
+
/* @__PURE__ */ l("strong", { className: "text-slate-700 dark:text-slate-200", children: j.length }),
|
|
598
631
|
" row",
|
|
599
|
-
|
|
600
|
-
|
|
632
|
+
j.length === 1 ? "" : "s",
|
|
633
|
+
w.length > 0 && /* @__PURE__ */ c(je, { children: [
|
|
601
634
|
", by ",
|
|
602
|
-
|
|
635
|
+
w.map((e) => e.label ?? e.field).join(" and "),
|
|
603
636
|
" — pick",
|
|
604
637
|
" ",
|
|
605
|
-
|
|
638
|
+
w.map((e) => e.label ?? e.field).join(", "),
|
|
606
639
|
" to edit"
|
|
607
640
|
] })
|
|
608
641
|
] }),
|
|
609
|
-
Object.keys(
|
|
642
|
+
Object.keys(p).some((e) => p[e] != null && p[e] !== "") && /* @__PURE__ */ c(
|
|
610
643
|
"button",
|
|
611
644
|
{
|
|
612
645
|
type: "button",
|
|
613
646
|
onClick: () => {
|
|
614
|
-
|
|
647
|
+
$({}), s();
|
|
615
648
|
},
|
|
616
649
|
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",
|
|
617
650
|
children: [
|
|
@@ -621,12 +654,12 @@ function Ae({ config: t }) {
|
|
|
621
654
|
}
|
|
622
655
|
)
|
|
623
656
|
] }),
|
|
624
|
-
/* @__PURE__ */ l("div", { className: "min-h-0 flex-1 overflow-auto", children:
|
|
657
|
+
/* @__PURE__ */ l("div", { className: "min-h-0 flex-1 overflow-auto", children: ee ? /* @__PURE__ */ c("div", { className: "flex items-center gap-2 p-4 text-[12px] text-slate-400", children: [
|
|
625
658
|
/* @__PURE__ */ l(pe, { className: "h-4 w-4 animate-spin" }),
|
|
626
659
|
" Loading…"
|
|
627
|
-
] }) : /* @__PURE__ */
|
|
628
|
-
/* @__PURE__ */ l("thead", { className: "sticky top-0 z-[1] bg-white dark:bg-card", children: /* @__PURE__ */
|
|
629
|
-
(
|
|
660
|
+
] }) : /* @__PURE__ */ c("table", { className: "w-full text-[12px]", children: [
|
|
661
|
+
/* @__PURE__ */ l("thead", { className: "sticky top-0 z-[1] bg-white dark:bg-card", children: /* @__PURE__ */ c("tr", { className: "border-b border-slate-200 dark:border-border", children: [
|
|
662
|
+
(f ? [{ field: "__row", label: "" }] : w.map((e) => ({ field: e.field, label: e.label ?? e.field }))).map((e) => /* @__PURE__ */ l(
|
|
630
663
|
"th",
|
|
631
664
|
{
|
|
632
665
|
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",
|
|
@@ -634,29 +667,30 @@ function Ae({ config: t }) {
|
|
|
634
667
|
},
|
|
635
668
|
e.field
|
|
636
669
|
)),
|
|
637
|
-
|
|
670
|
+
q.map((e, o) => Q(e.label, o)),
|
|
638
671
|
g && Q("Total", 99, "border-l border-slate-200 dark:border-border"),
|
|
639
|
-
|
|
672
|
+
f && t.allow_delete && /* @__PURE__ */ l("th", { "aria-label": "Remove", className: "w-8" })
|
|
640
673
|
] }) }),
|
|
641
|
-
/* @__PURE__ */
|
|
642
|
-
|
|
674
|
+
/* @__PURE__ */ c("tbody", { children: [
|
|
675
|
+
f ? V.map((e) => {
|
|
643
676
|
var o;
|
|
644
|
-
return /* @__PURE__ */
|
|
677
|
+
return /* @__PURE__ */ c("tr", { className: "border-b border-slate-100 dark:border-border/50", children: [
|
|
645
678
|
/* @__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" }) : `#${(o = e.record) == null ? void 0 : o.id}` }),
|
|
646
|
-
|
|
679
|
+
q.map((a, d) => /* @__PURE__ */ l(
|
|
647
680
|
"td",
|
|
648
681
|
{
|
|
649
|
-
className:
|
|
682
|
+
className: X(
|
|
650
683
|
"px-1 py-0.5 text-right",
|
|
651
|
-
|
|
652
|
-
|
|
684
|
+
T(d) && "border-l border-slate-100 dark:border-border/50",
|
|
685
|
+
G(d)
|
|
653
686
|
),
|
|
654
687
|
children: /* @__PURE__ */ l(
|
|
655
|
-
|
|
688
|
+
ze,
|
|
656
689
|
{
|
|
657
690
|
value: ie(e, a.field),
|
|
658
|
-
original:
|
|
659
|
-
onChange: (u) => ce(e.key, a.field, u)
|
|
691
|
+
original: re(e, a.field),
|
|
692
|
+
onChange: (u) => ce(e.key, a.field, u),
|
|
693
|
+
allowNegative: !!t.allow_negative
|
|
660
694
|
}
|
|
661
695
|
)
|
|
662
696
|
},
|
|
@@ -665,9 +699,9 @@ function Ae({ config: t }) {
|
|
|
665
699
|
g && /* @__PURE__ */ l(
|
|
666
700
|
"td",
|
|
667
701
|
{
|
|
668
|
-
className: `border-l border-slate-200 px-2 py-1 text-right font-semibold tabular-nums dark:border-border ${
|
|
702
|
+
className: `border-l border-slate-200 px-2 py-1 text-right font-semibold tabular-nums dark:border-border ${U}`,
|
|
669
703
|
style: D,
|
|
670
|
-
children:
|
|
704
|
+
children: K(le(e))
|
|
671
705
|
}
|
|
672
706
|
),
|
|
673
707
|
t.allow_delete && /* @__PURE__ */ l("td", { className: "py-1 pl-1", children: /* @__PURE__ */ l(
|
|
@@ -676,10 +710,10 @@ function Ae({ config: t }) {
|
|
|
676
710
|
type: "button",
|
|
677
711
|
"aria-label": "Remove row",
|
|
678
712
|
onClick: () => {
|
|
679
|
-
e.record ?
|
|
713
|
+
e.record ? J((a) => {
|
|
680
714
|
var d;
|
|
681
715
|
return new Set(a).add(String((d = e.record) == null ? void 0 : d.id));
|
|
682
|
-
}) :
|
|
716
|
+
}) : v((a) => a.filter((d) => d !== e.key)), S((a) => {
|
|
683
717
|
const d = { ...a };
|
|
684
718
|
return delete d[e.key], d;
|
|
685
719
|
});
|
|
@@ -689,9 +723,9 @@ function Ae({ config: t }) {
|
|
|
689
723
|
}
|
|
690
724
|
) })
|
|
691
725
|
] }, e.key);
|
|
692
|
-
}) :
|
|
693
|
-
const o =
|
|
694
|
-
return /* @__PURE__ */
|
|
726
|
+
}) : te.map((e) => {
|
|
727
|
+
const o = w.map((a) => String(e.keyVals[a.field] ?? "")).join("|");
|
|
728
|
+
return /* @__PURE__ */ c(
|
|
695
729
|
"tr",
|
|
696
730
|
{
|
|
697
731
|
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",
|
|
@@ -702,17 +736,17 @@ function Ae({ config: t }) {
|
|
|
702
736
|
tabIndex: 0,
|
|
703
737
|
title: "Open this combination",
|
|
704
738
|
children: [
|
|
705
|
-
|
|
739
|
+
w.map((a, d) => /* @__PURE__ */ c(
|
|
706
740
|
"td",
|
|
707
741
|
{
|
|
708
|
-
className:
|
|
742
|
+
className: X(
|
|
709
743
|
"whitespace-nowrap px-2 py-1.5 text-slate-700 dark:text-slate-200",
|
|
710
744
|
d === 0 && "sticky left-0 z-[1] bg-white font-medium dark:bg-card"
|
|
711
745
|
),
|
|
712
746
|
children: [
|
|
713
|
-
d === 0 && /* @__PURE__ */ l(
|
|
714
|
-
|
|
715
|
-
d ===
|
|
747
|
+
d === 0 && /* @__PURE__ */ l(Oe, { className: "mr-1 inline h-3 w-3 text-slate-300" }),
|
|
748
|
+
R(a.field, e.keyVals[a.field]),
|
|
749
|
+
d === w.length - 1 && e.count > 1 && /* @__PURE__ */ c("span", { className: "ml-1.5 text-[10.5px] text-slate-400", children: [
|
|
716
750
|
e.count,
|
|
717
751
|
" rows"
|
|
718
752
|
] })
|
|
@@ -720,26 +754,26 @@ function Ae({ config: t }) {
|
|
|
720
754
|
},
|
|
721
755
|
a.field
|
|
722
756
|
)),
|
|
723
|
-
|
|
757
|
+
q.map((a, d) => /* @__PURE__ */ l(
|
|
724
758
|
"td",
|
|
725
759
|
{
|
|
726
|
-
className:
|
|
760
|
+
className: X(
|
|
727
761
|
"whitespace-nowrap px-1.5 py-1.5 text-right tabular-nums",
|
|
728
|
-
|
|
729
|
-
|
|
762
|
+
T(d) && "border-l border-slate-100 dark:border-border/50",
|
|
763
|
+
G(d),
|
|
730
764
|
(e.sums[a.field] ?? 0) === 0 ? "text-slate-300 dark:text-slate-600" : "text-slate-700 dark:text-slate-200"
|
|
731
765
|
),
|
|
732
|
-
children:
|
|
766
|
+
children: K(e.sums[a.field], { blankZero: !0 })
|
|
733
767
|
},
|
|
734
768
|
a.field
|
|
735
769
|
)),
|
|
736
770
|
g && /* @__PURE__ */ l(
|
|
737
771
|
"td",
|
|
738
772
|
{
|
|
739
|
-
className: `border-l border-slate-200 px-2 py-1.5 text-right font-semibold tabular-nums dark:border-border ${
|
|
773
|
+
className: `border-l border-slate-200 px-2 py-1.5 text-right font-semibold tabular-nums dark:border-border ${U}`,
|
|
740
774
|
style: D,
|
|
741
|
-
children:
|
|
742
|
-
|
|
775
|
+
children: K(
|
|
776
|
+
W.reduce(
|
|
743
777
|
(a, d) => a + (e.sums[`${d}${g.suffix}`] ?? 0),
|
|
744
778
|
0
|
|
745
779
|
)
|
|
@@ -751,42 +785,45 @@ function Ae({ config: t }) {
|
|
|
751
785
|
o
|
|
752
786
|
);
|
|
753
787
|
}),
|
|
754
|
-
!
|
|
788
|
+
!f && te.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" }) })
|
|
755
789
|
] }),
|
|
756
|
-
/* @__PURE__ */ l("tfoot", { className: "sticky bottom-0 bg-white dark:bg-card", children: /* @__PURE__ */
|
|
790
|
+
/* @__PURE__ */ l("tfoot", { className: "sticky bottom-0 bg-white dark:bg-card", children: /* @__PURE__ */ c("tr", { className: "border-t-2 border-slate-300 dark:border-border", children: [
|
|
757
791
|
/* @__PURE__ */ l(
|
|
758
792
|
"td",
|
|
759
793
|
{
|
|
760
|
-
colSpan:
|
|
794
|
+
colSpan: f ? 1 : Math.max(1, w.length),
|
|
761
795
|
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",
|
|
762
796
|
children: "Total"
|
|
763
797
|
}
|
|
764
798
|
),
|
|
765
|
-
|
|
799
|
+
q.map((e, o) => /* @__PURE__ */ l(
|
|
766
800
|
"td",
|
|
767
801
|
{
|
|
768
|
-
className:
|
|
802
|
+
className: X(
|
|
769
803
|
"px-2 py-2 text-right font-semibold tabular-nums text-slate-800 dark:text-slate-100",
|
|
770
|
-
|
|
771
|
-
|
|
804
|
+
T(o) && "border-l border-slate-200 dark:border-border",
|
|
805
|
+
G(o)
|
|
772
806
|
),
|
|
773
|
-
children:
|
|
807
|
+
children: K(y(e.field))
|
|
774
808
|
},
|
|
775
809
|
e.field
|
|
776
810
|
)),
|
|
777
811
|
g && /* @__PURE__ */ l(
|
|
778
812
|
"td",
|
|
779
813
|
{
|
|
780
|
-
className: `border-l border-slate-200 px-2 py-2 text-right font-semibold tabular-nums dark:border-border ${
|
|
814
|
+
className: `border-l border-slate-200 px-2 py-2 text-right font-semibold tabular-nums dark:border-border ${U}`,
|
|
781
815
|
style: D,
|
|
782
|
-
children:
|
|
816
|
+
children: K(W.reduce((e, o) => e + y(`${o}${g.suffix}`), 0))
|
|
783
817
|
}
|
|
784
818
|
),
|
|
785
|
-
|
|
819
|
+
f && t.allow_delete && /* @__PURE__ */ l("td", {})
|
|
786
820
|
] }) })
|
|
787
821
|
] }) })
|
|
788
822
|
] });
|
|
789
823
|
}
|
|
790
824
|
export {
|
|
791
|
-
|
|
825
|
+
Ce as NEGATIVE_AMOUNT_MESSAGE,
|
|
826
|
+
ze as NumberCell,
|
|
827
|
+
Ye as RecordGridEditor,
|
|
828
|
+
Le as sanitizeAmount
|
|
792
829
|
};
|