@nivaro/react 0.3.111 → 0.3.113
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 +207 -3
- package/dist/index.js +745 -728
- package/dist/shared/components/CollectionBrowserView.js +3133 -2954
- package/dist/shared/components/CollectionImportBanner.js +135 -0
- package/dist/shared/components/ItemEditForm.js +2235 -2218
- package/dist/shared/components/JobsTray.js +54 -47
- package/dist/shared/components/ViewAsPersonButton.js +109 -0
- package/dist/shared/components/bulk/BulkFieldUpdate.js +228 -150
- package/dist/shared/components/bulk/BulkFieldUpdateButton.js +35 -41
- package/dist/shared/components/bulk/BulkLinksValue.js +91 -0
- package/dist/shared/components/bulk/bulk-field-options.js +20 -19
- package/dist/shared/components/bulk/bulk-update-preview.js +39 -0
- package/dist/shared/components/cbv/ColumnHeaderMenu.js +130 -0
- package/dist/shared/components/cbv/column-totals.js +163 -0
- package/dist/shared/components/collections-directory/CollectionHoverCard.js +108 -81
- package/dist/shared/components/collections-directory/CollectionRow.js +164 -148
- package/dist/shared/components/collections-directory/CollectionsDirectory.js +167 -166
- package/dist/shared/components/collections-directory/directory-data.js +70 -58
- package/dist/shared/components/imports/CollectionImportPanel.js +120 -118
- package/dist/shared/components/imports/DefinitionsPanel.js +24 -24
- package/dist/shared/components/imports/ImportDuplicatesNotice.js +65 -0
- package/dist/shared/components/item-edit/CatalogPickerField.js +631 -639
- package/dist/shared/components/item-edit/DuplicateNotice.js +168 -0
- package/dist/shared/components/item-edit/FieldRow.js +248 -246
- package/dist/shared/components/item-edit/InlineGridField.js +34 -33
- package/dist/shared/components/item-edit/InlineTableField.js +3002 -2825
- package/dist/shared/components/item-edit/MembershipSetField.js +165 -169
- package/dist/shared/components/item-edit/NestedRelationEditor.js +184 -189
- package/dist/shared/components/item-edit/PlanGrid.js +2 -1
- package/dist/shared/components/item-edit/QuickPickerDialog.js +35 -34
- package/dist/shared/components/item-edit/RecordLiveSync.js +32 -30
- package/dist/shared/components/item-edit/RelationCombobox.js +101 -100
- package/dist/shared/components/item-edit/RowHistorySheet.js +28 -27
- package/dist/shared/components/item-edit/SummaryPanel.js +133 -135
- package/dist/shared/components/item-edit/UserChip.js +262 -239
- package/dist/shared/components/item-edit/ViewAsRole.js +129 -52
- package/dist/shared/components/item-edit/grid-search.js +375 -0
- package/dist/shared/components/item-edit/render-stability.js +61 -54
- package/dist/shared/components/notifications/NotificationRulesEditor.js +25 -20
- package/dist/shared/components/ops-report/DigestSections.js +163 -144
- package/dist/shared/components/ops-report/drill.js +97 -97
- package/dist/shared/components/panels/AddendumLinesDiff.js +52 -51
- package/dist/shared/components/panels/AddendumPanel.js +92 -91
- package/dist/shared/components/panels/AsyncUserPicker.js +108 -0
- package/dist/shared/components/panels/CommentPanel.js +265 -252
- package/dist/shared/components/panels/OwnersSlot.js +47 -35
- package/dist/shared/components/panels/PipelineInsight.js +186 -0
- package/dist/shared/components/panels/PipelinePanel.js +1440 -1397
- package/dist/shared/components/panels/RecordIntegrityBanner.js +39 -38
- package/dist/shared/components/panels/RevisionsPanel.js +261 -260
- package/dist/shared/components/panels/StandInReason.js +69 -0
- package/dist/shared/components/pipeline/FieldPicker.js +41 -40
- package/dist/shared/components/pipeline/OwnerMatrix.js +829 -700
- package/dist/shared/components/pipeline/OwnerRecordTrial.js +362 -0
- package/dist/shared/components/pipeline/PipelineEditorView.js +483 -467
- package/dist/shared/components/pipeline/PipelineStateOwners.js +65 -64
- package/dist/shared/components/pipeline/owner-matrix-draft.js +178 -0
- package/dist/shared/components/profile/MyDefaultsCard.js +36 -35
- package/dist/shared/components/profile/PersonHeader.js +29 -29
- package/dist/shared/components/profile/PersonProfile.js +30 -28
- package/dist/shared/components/profile/SlowScreensCard.js +286 -0
- package/dist/shared/components/queue/QueueWorklist.js +1090 -1071
- package/dist/shared/components/quick-filters/useQuickFilterEditing.js +45 -44
- package/dist/shared/components/support/TicketDetailSheet.js +25 -16
- package/dist/shared/components/support/TicketSlowScreens.js +32 -0
- package/dist/shared/lib/activity-sentence.js +224 -178
- package/dist/shared/lib/collection-import-banner.js +27 -0
- package/dist/shared/lib/crash-report.js +112 -0
- package/dist/shared/lib/export-runs.js +99 -0
- package/dist/shared/lib/jobs-tray.js +89 -67
- package/dist/shared/lib/list-link.js +76 -69
- package/dist/shared/lib/nav-trail.js +180 -76
- package/dist/shared/lib/query-keys.js +26 -0
- package/dist/shared/lib/view-as.js +16 -11
- package/package.json +1 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { jsxs as p, jsx as
|
|
2
|
-
import { useQueryClient as
|
|
3
|
-
import { Loader2 as
|
|
4
|
-
import { useMemo as k, useRef as
|
|
5
|
-
import { useNivaroClient as
|
|
6
|
-
import { get as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
1
|
+
import { jsxs as p, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { useQueryClient as je, useQuery as j } from "@tanstack/react-query";
|
|
3
|
+
import { Loader2 as ke, Pencil as Fe, X as $e } from "lucide-react";
|
|
4
|
+
import { useMemo as k, useRef as Te, useEffect as Se, useState as F, Fragment as Me } from "react";
|
|
5
|
+
import { useNivaroClient as Ae } from "../../context.js";
|
|
6
|
+
import { get as z, post as Je, patch as Ye, del as Ie } from "../../lib/commands.js";
|
|
7
|
+
import { fetchCollectionRelations as pe, queryKeys as O } from "../../lib/query-keys.js";
|
|
8
|
+
import { titleCase as C, cn as xe, toLocalDateString as Ue } from "../../lib/utils.js";
|
|
9
|
+
import { FieldRenderer as be } from "./FieldRenderer.js";
|
|
10
|
+
import { SENTINEL_FIELDS as Re, EMPTY_NESTED_OPS as ee, applyDisplayTemplate as We } from "./helpers.js";
|
|
11
|
+
const ze = /* @__PURE__ */ new Set([
|
|
11
12
|
"alias",
|
|
12
13
|
"o2m",
|
|
13
14
|
"m2m",
|
|
@@ -15,157 +16,151 @@ const We = /* @__PURE__ */ new Set([
|
|
|
15
16
|
"presentation",
|
|
16
17
|
"group",
|
|
17
18
|
"divider"
|
|
18
|
-
]),
|
|
19
|
-
function
|
|
19
|
+
]), Be = /* @__PURE__ */ new Set(["__apply_values__", "__create_with_defaults__"]);
|
|
20
|
+
function Ge(o, s) {
|
|
20
21
|
return o === s || o == null && s == null ? !0 : o == null || s == null ? !1 : typeof o == "string" && typeof s == "number" || typeof o == "number" && typeof s == "string" ? String(o) === String(s) : JSON.stringify(o) === JSON.stringify(s);
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
+
function ye(o) {
|
|
23
24
|
var x;
|
|
24
25
|
const s = o == null ? void 0 : o.response;
|
|
25
26
|
if ((x = s == null ? void 0 : s.violations) != null && x.length) {
|
|
26
|
-
const
|
|
27
|
-
if (
|
|
27
|
+
const q = s.violations.map((b) => b.explanation).filter(Boolean).join("; ");
|
|
28
|
+
if (q) return q;
|
|
28
29
|
}
|
|
29
30
|
return s != null && s.message ? s.message : s != null && s.error ? s.error : o instanceof Error && o.message ? o.message : "Save failed";
|
|
30
31
|
}
|
|
31
|
-
function
|
|
32
|
+
function Qe(o) {
|
|
32
33
|
if (!Number.isFinite(o)) return o;
|
|
33
34
|
const s = Math.round((o + Math.sign(o) * Number.EPSILON) * 100) / 100;
|
|
34
35
|
return Object.is(s, -0) ? 0 : s;
|
|
35
36
|
}
|
|
36
|
-
function
|
|
37
|
+
function st({
|
|
37
38
|
parentCollection: o,
|
|
38
39
|
relationField: s,
|
|
39
40
|
parentRowId: x,
|
|
40
|
-
stagedMembers:
|
|
41
|
+
stagedMembers: q,
|
|
41
42
|
onStagedChange: b,
|
|
42
|
-
parentDraft:
|
|
43
|
+
parentDraft: Ne,
|
|
43
44
|
hint: w,
|
|
44
45
|
readOnly: v = !1,
|
|
45
|
-
outerGridInvalidateKey:
|
|
46
|
-
deferred:
|
|
47
|
-
onRowsChange:
|
|
48
|
-
stagedOps:
|
|
46
|
+
outerGridInvalidateKey: te,
|
|
47
|
+
deferred: $ = !1,
|
|
48
|
+
onRowsChange: B,
|
|
49
|
+
stagedOps: T,
|
|
49
50
|
onStagedOpsChange: f,
|
|
50
51
|
matchCollection: m,
|
|
51
|
-
matchQuery:
|
|
52
|
-
matchSeed:
|
|
52
|
+
matchQuery: S,
|
|
53
|
+
matchSeed: M
|
|
53
54
|
}) {
|
|
54
|
-
var
|
|
55
|
-
const y =
|
|
56
|
-
queryKey:
|
|
57
|
-
queryFn: () => y
|
|
58
|
-
const t = e.data;
|
|
59
|
-
return (t == null ? void 0 : t.relations) ?? [];
|
|
60
|
-
}),
|
|
55
|
+
var ue, fe;
|
|
56
|
+
const y = Ae(), re = je(), { data: A, isLoading: he } = j({
|
|
57
|
+
queryKey: O.collectionRelations(o),
|
|
58
|
+
queryFn: () => pe(y, o),
|
|
61
59
|
staleTime: 10 * 6e4
|
|
62
60
|
}), P = k(
|
|
63
|
-
() =>
|
|
61
|
+
() => A == null ? void 0 : A.find(
|
|
64
62
|
(e) => e.one_collection === o && e.one_field === s
|
|
65
63
|
),
|
|
66
|
-
[
|
|
67
|
-
), d = m ?? (P == null ? void 0 : P.many_collection) ?? null,
|
|
68
|
-
queryKey:
|
|
69
|
-
queryFn: () => y
|
|
70
|
-
const t = e.data;
|
|
71
|
-
return (t == null ? void 0 : t.relations) ?? [];
|
|
72
|
-
}),
|
|
64
|
+
[A, o, s]
|
|
65
|
+
), d = m ?? (P == null ? void 0 : P.many_collection) ?? null, g = m ? null : (P == null ? void 0 : P.many_field) ?? null, { data: J = [] } = j({
|
|
66
|
+
queryKey: O.collectionRelations(d),
|
|
67
|
+
queryFn: () => pe(y, d),
|
|
73
68
|
enabled: !!d,
|
|
74
69
|
staleTime: 10 * 6e4
|
|
75
|
-
}), { data:
|
|
76
|
-
queryKey:
|
|
77
|
-
queryFn: () => y.request(
|
|
70
|
+
}), { data: G = [] } = j({
|
|
71
|
+
queryKey: O.fieldConfig(d, null),
|
|
72
|
+
queryFn: () => y.request(z(`/field-config/${d}`)).then((e) => e.data ?? []),
|
|
78
73
|
enabled: !!d,
|
|
79
74
|
staleTime: 6e4
|
|
80
75
|
}), E = k(
|
|
81
|
-
() =>
|
|
82
|
-
(e) => !e.hidden && !
|
|
76
|
+
() => G.filter(
|
|
77
|
+
(e) => !e.hidden && !ze.has(e.type) && e.field !== g && !(M && e.field in M) && e.field !== "id" && !Re.has(e.field) && !Be.has(e.group_key ?? "")
|
|
83
78
|
),
|
|
84
|
-
[
|
|
85
|
-
),
|
|
86
|
-
queryKey:
|
|
79
|
+
[G, g]
|
|
80
|
+
), ie = m ? ["nested-rows", d, JSON.stringify(S ?? null)] : ["nested-rows", d, g, x], { data: Y = [], isLoading: Q } = j({
|
|
81
|
+
queryKey: ie,
|
|
87
82
|
queryFn: () => y.request(
|
|
88
|
-
|
|
83
|
+
z(`/items/${d}`, {
|
|
89
84
|
filter: JSON.stringify(
|
|
90
|
-
m ?
|
|
85
|
+
m ? S : { [g]: { _eq: x } }
|
|
91
86
|
),
|
|
92
87
|
limit: 200
|
|
93
88
|
})
|
|
94
89
|
).then((e) => e.data ?? []),
|
|
95
|
-
enabled: m ? !!
|
|
90
|
+
enabled: m ? !!S : !!d && !!g && x != null,
|
|
96
91
|
staleTime: 3e4
|
|
97
92
|
}), N = k(() => {
|
|
98
93
|
if (x != null) {
|
|
99
|
-
if (
|
|
100
|
-
const e =
|
|
94
|
+
if ($) {
|
|
95
|
+
const e = T ?? ee, t = new Set(e.deleted), r = new Map(e.updated.map((a) => [a.id, a.changes])), l = Y.filter((a) => !t.has(String(a.id))).map((a) => {
|
|
101
96
|
const u = r.get(String(a.id));
|
|
102
97
|
return { key: String(a.id), data: u ? { ...a, ...u } : a };
|
|
103
|
-
}),
|
|
104
|
-
return [...l, ...
|
|
98
|
+
}), n = e.created.map((a, u) => ({ key: `created:${u}`, data: a }));
|
|
99
|
+
return [...l, ...n];
|
|
105
100
|
}
|
|
106
|
-
return
|
|
101
|
+
return Y.map((e) => ({ key: String(e.id), data: e }));
|
|
107
102
|
}
|
|
108
|
-
return (
|
|
109
|
-
}, [x,
|
|
110
|
-
|
|
111
|
-
if (!
|
|
103
|
+
return (q ?? []).map((e, t) => ({ key: `staged:${t}`, data: e }));
|
|
104
|
+
}, [x, Y, q, $, T]), ne = Te("");
|
|
105
|
+
Se(() => {
|
|
106
|
+
if (!B) return;
|
|
112
107
|
const e = JSON.stringify(N.map((t) => t.data));
|
|
113
|
-
e !== ne.current && (ne.current = e,
|
|
114
|
-
}, [N,
|
|
115
|
-
const [c,
|
|
116
|
-
function
|
|
117
|
-
|
|
108
|
+
e !== ne.current && (ne.current = e, B(N.map((t) => t.data)));
|
|
109
|
+
}, [N, B]);
|
|
110
|
+
const [c, V] = F(null), [h, I] = F({}), [_e, X] = F(null), [U, se] = F(!1), [R, _] = F(null);
|
|
111
|
+
function le(e, t) {
|
|
112
|
+
I((r) => ({ ...r, [e]: t })), _(null);
|
|
118
113
|
}
|
|
119
|
-
function
|
|
120
|
-
v || (
|
|
114
|
+
function we() {
|
|
115
|
+
v || (V("new"), I({}), _(null));
|
|
121
116
|
}
|
|
122
|
-
function
|
|
123
|
-
v || (
|
|
117
|
+
function oe(e, t) {
|
|
118
|
+
v || (V(e), I({ ...t }), _(null));
|
|
124
119
|
}
|
|
125
120
|
function D() {
|
|
126
|
-
|
|
121
|
+
V(null), I({}), _(null);
|
|
127
122
|
}
|
|
128
|
-
function
|
|
129
|
-
|
|
123
|
+
function ae() {
|
|
124
|
+
re.invalidateQueries({ queryKey: ie }), te && re.invalidateQueries({ queryKey: te });
|
|
130
125
|
}
|
|
131
|
-
async function
|
|
126
|
+
async function ce() {
|
|
132
127
|
if (!c) return;
|
|
133
|
-
if (x != null && d && (
|
|
128
|
+
if (x != null && d && (g || m)) {
|
|
134
129
|
const t = new Set(E.map((l) => l.field)), r = Object.fromEntries(
|
|
135
130
|
Object.entries(h).filter(([l]) => t.has(l))
|
|
136
131
|
);
|
|
137
|
-
if (
|
|
138
|
-
const l =
|
|
132
|
+
if ($) {
|
|
133
|
+
const l = T ?? ee, n = m ? { ...l, collection: m } : l, a = m ? { ...r, ...M ?? {} } : r;
|
|
139
134
|
if (c === "new")
|
|
140
|
-
f == null || f({ ...
|
|
135
|
+
f == null || f({ ...n, created: [...n.created, a] });
|
|
141
136
|
else if (c.startsWith("created:")) {
|
|
142
|
-
const u = parseInt(c.slice(8), 10), K = [...
|
|
143
|
-
K[u] = a, f == null || f({ ...
|
|
137
|
+
const u = parseInt(c.slice(8), 10), K = [...n.created];
|
|
138
|
+
K[u] = a, f == null || f({ ...n, created: K });
|
|
144
139
|
} else {
|
|
145
|
-
const u =
|
|
146
|
-
Object.entries(r).filter(([
|
|
147
|
-
),
|
|
148
|
-
Object.keys(K).length > 0 &&
|
|
140
|
+
const u = Y.find((L) => String(L.id) === c), K = Object.fromEntries(
|
|
141
|
+
Object.entries(r).filter(([L, Le]) => !Ge(Le, u == null ? void 0 : u[L]))
|
|
142
|
+
), me = n.updated.filter((L) => L.id !== c);
|
|
143
|
+
Object.keys(K).length > 0 && me.push({ id: c, changes: K }), f == null || f({ ...n, updated: me });
|
|
149
144
|
}
|
|
150
145
|
D();
|
|
151
146
|
return;
|
|
152
147
|
}
|
|
153
|
-
|
|
148
|
+
se(!0);
|
|
154
149
|
try {
|
|
155
150
|
c === "new" ? await y.request(
|
|
156
|
-
|
|
151
|
+
Je(`/items/${d}`, {
|
|
157
152
|
...r,
|
|
158
|
-
...m ?
|
|
153
|
+
...m ? M ?? {} : { [g]: x }
|
|
159
154
|
})
|
|
160
|
-
) : await y.request(
|
|
155
|
+
) : await y.request(Ye(`/items/${d}/${c}`, r)), ae(), D();
|
|
161
156
|
} catch (l) {
|
|
162
|
-
_(
|
|
157
|
+
_(ye(l));
|
|
163
158
|
} finally {
|
|
164
|
-
|
|
159
|
+
se(!1);
|
|
165
160
|
}
|
|
166
161
|
return;
|
|
167
162
|
}
|
|
168
|
-
const e =
|
|
163
|
+
const e = q ?? [];
|
|
169
164
|
if (c === "new")
|
|
170
165
|
b == null || b([...e, h]);
|
|
171
166
|
else if (c.startsWith("staged:")) {
|
|
@@ -174,13 +169,13 @@ function rt({
|
|
|
174
169
|
}
|
|
175
170
|
D();
|
|
176
171
|
}
|
|
177
|
-
async function
|
|
172
|
+
async function ve(e) {
|
|
178
173
|
if (x != null && d)
|
|
179
|
-
if (
|
|
180
|
-
const t =
|
|
174
|
+
if ($) {
|
|
175
|
+
const t = T ?? ee, r = m ? { ...t, collection: m } : t;
|
|
181
176
|
if (e.startsWith("created:")) {
|
|
182
177
|
const l = parseInt(e.slice(8), 10);
|
|
183
|
-
f == null || f({ ...r, created: r.created.filter((
|
|
178
|
+
f == null || f({ ...r, created: r.created.filter((n, a) => a !== l) });
|
|
184
179
|
} else
|
|
185
180
|
f == null || f({
|
|
186
181
|
...r,
|
|
@@ -189,37 +184,37 @@ function rt({
|
|
|
189
184
|
});
|
|
190
185
|
} else
|
|
191
186
|
try {
|
|
192
|
-
await y.request(
|
|
187
|
+
await y.request(Ie(`/items/${d}/${e}`)), ae();
|
|
193
188
|
} catch (t) {
|
|
194
|
-
_(
|
|
189
|
+
_(ye(t));
|
|
195
190
|
return;
|
|
196
191
|
}
|
|
197
192
|
else {
|
|
198
193
|
const t = parseInt(e.slice(7), 10);
|
|
199
|
-
b == null || b((
|
|
194
|
+
b == null || b((q ?? []).filter((r, l) => l !== t));
|
|
200
195
|
}
|
|
201
|
-
|
|
196
|
+
X(null), _(null), c === e && D();
|
|
202
197
|
}
|
|
203
|
-
const
|
|
198
|
+
const H = k(() => {
|
|
204
199
|
const e = /* @__PURE__ */ new Map();
|
|
205
200
|
for (const t of E) {
|
|
206
|
-
const r =
|
|
201
|
+
const r = J.find(
|
|
207
202
|
(l) => l.many_collection === d && l.many_field === t.field && !l.junction_field
|
|
208
203
|
);
|
|
209
204
|
r != null && r.one_collection && e.set(t.field, r);
|
|
210
205
|
}
|
|
211
206
|
return e;
|
|
212
|
-
}, [E,
|
|
207
|
+
}, [E, J, d]), Z = k(() => {
|
|
213
208
|
const e = /* @__PURE__ */ new Map();
|
|
214
209
|
for (const { key: t, data: r } of N) {
|
|
215
210
|
const l = c === t ? h : r;
|
|
216
|
-
for (const [
|
|
217
|
-
const u = l[
|
|
211
|
+
for (const [n, a] of H) {
|
|
212
|
+
const u = l[n];
|
|
218
213
|
u == null || u === "" || !a.one_collection || (e.has(a.one_collection) || e.set(a.one_collection, /* @__PURE__ */ new Set()), e.get(a.one_collection).add(String(u)));
|
|
219
214
|
}
|
|
220
215
|
}
|
|
221
216
|
return e;
|
|
222
|
-
}, [N, c, h,
|
|
217
|
+
}, [N, c, h, H]), { data: ge = {} } = j({
|
|
223
218
|
queryKey: [
|
|
224
219
|
"nested-m2o-display",
|
|
225
220
|
d,
|
|
@@ -230,20 +225,20 @@ function rt({
|
|
|
230
225
|
return await Promise.all(
|
|
231
226
|
[...Z.entries()].map(async ([t, r]) => {
|
|
232
227
|
var a;
|
|
233
|
-
const [l,
|
|
228
|
+
const [l, n] = await Promise.all([
|
|
234
229
|
y.request(
|
|
235
|
-
|
|
230
|
+
z(`/collections/${t}`)
|
|
236
231
|
),
|
|
237
232
|
y.request(
|
|
238
|
-
|
|
233
|
+
z(`/items/${t}`, {
|
|
239
234
|
filter: JSON.stringify({ id: { _in: [...r] } }),
|
|
240
235
|
limit: r.size
|
|
241
236
|
})
|
|
242
237
|
)
|
|
243
238
|
]);
|
|
244
239
|
e[t] = {};
|
|
245
|
-
for (const u of
|
|
246
|
-
e[t][String(u.id)] =
|
|
240
|
+
for (const u of n.data ?? [])
|
|
241
|
+
e[t][String(u.id)] = We(
|
|
247
242
|
(a = l.data) == null ? void 0 : a.display_template,
|
|
248
243
|
u
|
|
249
244
|
);
|
|
@@ -253,196 +248,196 @@ function rt({
|
|
|
253
248
|
enabled: Z.size > 0,
|
|
254
249
|
staleTime: 6e4
|
|
255
250
|
});
|
|
256
|
-
function
|
|
251
|
+
function qe(e, t) {
|
|
257
252
|
var l;
|
|
258
253
|
if (t == null || t === "")
|
|
259
|
-
return /* @__PURE__ */
|
|
260
|
-
const r =
|
|
254
|
+
return /* @__PURE__ */ i("span", { className: "text-slate-300", children: "—" });
|
|
255
|
+
const r = H.get(e.field);
|
|
261
256
|
if (r != null && r.one_collection) {
|
|
262
|
-
const
|
|
263
|
-
return /* @__PURE__ */
|
|
257
|
+
const n = (l = ge[r.one_collection]) == null ? void 0 : l[String(t)];
|
|
258
|
+
return /* @__PURE__ */ i("span", { className: "block truncate", children: n ?? String(t) });
|
|
264
259
|
}
|
|
265
260
|
if (e.type === "boolean")
|
|
266
|
-
return /* @__PURE__ */
|
|
261
|
+
return /* @__PURE__ */ i("span", { className: t ? "text-emerald-600" : "text-slate-400", children: t ? "Yes" : "No" });
|
|
267
262
|
if (e.type === "datetime" || e.type === "date")
|
|
268
263
|
try {
|
|
269
|
-
return /* @__PURE__ */
|
|
264
|
+
return /* @__PURE__ */ i("span", { className: "block truncate", children: Ue(t) });
|
|
270
265
|
} catch {
|
|
271
266
|
}
|
|
272
|
-
return /* @__PURE__ */
|
|
267
|
+
return /* @__PURE__ */ i("span", { className: "block truncate", children: String(t) });
|
|
273
268
|
}
|
|
274
|
-
const
|
|
269
|
+
const Ee = w && Number(Ne[w.cap_field]) || 0, Pe = w ? N.reduce(
|
|
275
270
|
(e, t) => {
|
|
276
271
|
const r = c === t.key ? h : t.data;
|
|
277
272
|
return e + (Number(r[w.sum_field]) || 0);
|
|
278
273
|
},
|
|
279
274
|
c === "new" && Number(h[w.sum_field]) || 0
|
|
280
|
-
) : 0,
|
|
281
|
-
if (
|
|
282
|
-
if (m && !
|
|
275
|
+
) : 0, de = Qe(Ee - Pe), De = w ? ((fe = (ue = G.find((e) => e.field === w.sum_field)) == null ? void 0 : ue.options) == null ? void 0 : fe.format) === "currency" : !1;
|
|
276
|
+
if (he && !m || !d || !g && !m) return null;
|
|
277
|
+
if (m && !S)
|
|
283
278
|
return /* @__PURE__ */ p("p", { className: "rounded-md border border-slate-200 bg-slate-50 px-2 py-1.5 text-[11px] text-slate-400", children: [
|
|
284
|
-
|
|
279
|
+
C(s),
|
|
285
280
|
" — available after this row is saved."
|
|
286
281
|
] });
|
|
287
|
-
const
|
|
282
|
+
const Ke = v ? 0 : 1, W = E.length + Ke;
|
|
288
283
|
return /* @__PURE__ */ p("div", { className: "overflow-hidden rounded-md border border-slate-200", children: [
|
|
289
284
|
/* @__PURE__ */ p("div", { className: "flex items-center gap-2 px-2 py-1 bg-slate-50 border-b border-slate-200", children: [
|
|
290
|
-
/* @__PURE__ */
|
|
291
|
-
/* @__PURE__ */
|
|
285
|
+
/* @__PURE__ */ i("span", { className: "text-[10px] font-medium text-slate-400 uppercase tracking-wide", children: C(s) }),
|
|
286
|
+
/* @__PURE__ */ i("span", { className: "rounded bg-slate-100 px-1.5 py-0.5 text-[10px] font-medium text-slate-500", children: N.length }),
|
|
292
287
|
w && /* @__PURE__ */ p(
|
|
293
288
|
"span",
|
|
294
289
|
{
|
|
295
|
-
className:
|
|
290
|
+
className: xe(
|
|
296
291
|
"ml-auto text-[11px] font-medium",
|
|
297
|
-
|
|
292
|
+
de < 0 ? "text-red-600" : "text-slate-500"
|
|
298
293
|
),
|
|
299
294
|
children: [
|
|
300
295
|
"remaining: ",
|
|
301
|
-
|
|
296
|
+
Ve(de, De)
|
|
302
297
|
]
|
|
303
298
|
}
|
|
304
299
|
)
|
|
305
300
|
] }),
|
|
306
301
|
/* @__PURE__ */ p("table", { className: "w-full table-fixed text-[12px]", children: [
|
|
307
|
-
/* @__PURE__ */
|
|
308
|
-
E.map((e) => /* @__PURE__ */
|
|
302
|
+
/* @__PURE__ */ i("thead", { className: "bg-slate-50 border-b border-slate-200", children: /* @__PURE__ */ p("tr", { children: [
|
|
303
|
+
E.map((e) => /* @__PURE__ */ i(
|
|
309
304
|
"th",
|
|
310
305
|
{
|
|
311
306
|
className: "px-2 py-1.5 text-left font-medium text-slate-500 text-[11px]",
|
|
312
|
-
children: e.label ??
|
|
307
|
+
children: e.label ?? C(e.field)
|
|
313
308
|
},
|
|
314
309
|
e.field
|
|
315
310
|
)),
|
|
316
|
-
!v && /* @__PURE__ */
|
|
311
|
+
!v && /* @__PURE__ */ i("th", { className: "w-16" })
|
|
317
312
|
] }) }),
|
|
318
313
|
/* @__PURE__ */ p("tbody", { children: [
|
|
319
|
-
|
|
320
|
-
!
|
|
321
|
-
const r = c === e, l =
|
|
322
|
-
return /* @__PURE__ */ p(
|
|
314
|
+
Q && /* @__PURE__ */ i("tr", { children: /* @__PURE__ */ i("td", { colSpan: W, className: "px-2 py-3 text-center text-slate-400", children: /* @__PURE__ */ i(ke, { className: "h-3.5 w-3.5 animate-spin inline" }) }) }),
|
|
315
|
+
!Q && N.map(({ key: e, data: t }) => {
|
|
316
|
+
const r = c === e, l = _e === e;
|
|
317
|
+
return /* @__PURE__ */ p(Me, { children: [
|
|
323
318
|
/* @__PURE__ */ p(
|
|
324
319
|
"tr",
|
|
325
320
|
{
|
|
326
|
-
onClick: () => !r && !v &&
|
|
327
|
-
className:
|
|
321
|
+
onClick: () => !r && !v && oe(e, t),
|
|
322
|
+
className: xe(
|
|
328
323
|
"border-b border-slate-100 transition-colors",
|
|
329
324
|
r ? "bg-[#f0fbff] dark:bg-nvr-cyan/5 cursor-default" : "bg-white hover:bg-slate-50/80",
|
|
330
325
|
!r && !v ? "cursor-pointer" : ""
|
|
331
326
|
),
|
|
332
327
|
children: [
|
|
333
|
-
E.map((
|
|
334
|
-
|
|
328
|
+
E.map((n) => /* @__PURE__ */ i("td", { className: "px-2 py-1 align-top", children: r ? /* @__PURE__ */ i(
|
|
329
|
+
be,
|
|
335
330
|
{
|
|
336
|
-
field:
|
|
337
|
-
value: h[
|
|
338
|
-
onChange: (a) =>
|
|
339
|
-
relations:
|
|
331
|
+
field: n,
|
|
332
|
+
value: h[n.field] ?? null,
|
|
333
|
+
onChange: (a) => le(n.field, a),
|
|
334
|
+
relations: J,
|
|
340
335
|
collection: d,
|
|
341
336
|
itemId: x != null ? e : "new"
|
|
342
337
|
}
|
|
343
|
-
) : /* @__PURE__ */
|
|
344
|
-
!v && /* @__PURE__ */
|
|
345
|
-
/* @__PURE__ */
|
|
338
|
+
) : /* @__PURE__ */ i("div", { className: "py-0.5 overflow-hidden", children: qe(n, t[n.field]) }) }, n.field)),
|
|
339
|
+
!v && /* @__PURE__ */ i("td", { className: "px-1 py-1 align-middle", children: r ? /* @__PURE__ */ p("div", { className: "flex items-stretch gap-1", children: [
|
|
340
|
+
/* @__PURE__ */ i(
|
|
346
341
|
"button",
|
|
347
342
|
{
|
|
348
343
|
type: "button",
|
|
349
|
-
disabled:
|
|
350
|
-
onClick: (
|
|
351
|
-
|
|
344
|
+
disabled: U,
|
|
345
|
+
onClick: (n) => {
|
|
346
|
+
n.stopPropagation(), ce();
|
|
352
347
|
},
|
|
353
348
|
className: "rounded px-2 h-7 bg-nvr-cyan text-white text-[10px] font-medium hover:brightness-110 disabled:opacity-50",
|
|
354
|
-
children:
|
|
349
|
+
children: U ? "…" : "Save"
|
|
355
350
|
}
|
|
356
351
|
),
|
|
357
|
-
/* @__PURE__ */
|
|
352
|
+
/* @__PURE__ */ i(
|
|
358
353
|
"button",
|
|
359
354
|
{
|
|
360
355
|
type: "button",
|
|
361
|
-
onClick: (
|
|
362
|
-
|
|
356
|
+
onClick: (n) => {
|
|
357
|
+
n.stopPropagation(), D();
|
|
363
358
|
},
|
|
364
359
|
className: "rounded px-1.5 h-7 text-slate-400 hover:text-slate-700 text-[10px]",
|
|
365
360
|
children: "✕"
|
|
366
361
|
}
|
|
367
362
|
)
|
|
368
363
|
] }) : l ? /* @__PURE__ */ p("div", { className: "flex items-center justify-end gap-1", children: [
|
|
369
|
-
/* @__PURE__ */
|
|
370
|
-
/* @__PURE__ */
|
|
364
|
+
/* @__PURE__ */ i("span", { className: "text-[10px] text-slate-400", children: "Delete?" }),
|
|
365
|
+
/* @__PURE__ */ i(
|
|
371
366
|
"button",
|
|
372
367
|
{
|
|
373
368
|
type: "button",
|
|
374
|
-
onClick: (
|
|
375
|
-
|
|
369
|
+
onClick: (n) => {
|
|
370
|
+
n.stopPropagation(), ve(e);
|
|
376
371
|
},
|
|
377
372
|
className: "rounded px-1.5 py-0.5 text-[10px] text-red-500 hover:text-red-700 border border-red-200 hover:border-red-400",
|
|
378
373
|
children: "Yes"
|
|
379
374
|
}
|
|
380
375
|
),
|
|
381
|
-
/* @__PURE__ */
|
|
376
|
+
/* @__PURE__ */ i(
|
|
382
377
|
"button",
|
|
383
378
|
{
|
|
384
379
|
type: "button",
|
|
385
|
-
onClick: (
|
|
386
|
-
|
|
380
|
+
onClick: (n) => {
|
|
381
|
+
n.stopPropagation(), X(null), _(null);
|
|
387
382
|
},
|
|
388
383
|
className: "rounded px-1.5 py-0.5 text-[10px] text-slate-400 hover:text-slate-700 border border-slate-200",
|
|
389
384
|
children: "Cancel"
|
|
390
385
|
}
|
|
391
386
|
)
|
|
392
387
|
] }) : /* @__PURE__ */ p("div", { className: "flex items-center justify-end gap-0.5", children: [
|
|
393
|
-
/* @__PURE__ */
|
|
388
|
+
/* @__PURE__ */ i(
|
|
394
389
|
"button",
|
|
395
390
|
{
|
|
396
391
|
type: "button",
|
|
397
|
-
onClick: (
|
|
398
|
-
|
|
392
|
+
onClick: (n) => {
|
|
393
|
+
n.stopPropagation(), oe(e, t);
|
|
399
394
|
},
|
|
400
395
|
className: "rounded p-0.5 text-slate-300 hover:text-nvr-cyan",
|
|
401
|
-
children: /* @__PURE__ */
|
|
396
|
+
children: /* @__PURE__ */ i(Fe, { className: "h-3 w-3" })
|
|
402
397
|
}
|
|
403
398
|
),
|
|
404
|
-
/* @__PURE__ */
|
|
399
|
+
/* @__PURE__ */ i(
|
|
405
400
|
"button",
|
|
406
401
|
{
|
|
407
402
|
type: "button",
|
|
408
|
-
onClick: (
|
|
409
|
-
|
|
403
|
+
onClick: (n) => {
|
|
404
|
+
n.stopPropagation(), X(e), _(null);
|
|
410
405
|
},
|
|
411
406
|
className: "rounded p-0.5 text-slate-300 hover:text-red-500",
|
|
412
|
-
children: /* @__PURE__ */
|
|
407
|
+
children: /* @__PURE__ */ i($e, { className: "h-3 w-3" })
|
|
413
408
|
}
|
|
414
409
|
)
|
|
415
410
|
] }) })
|
|
416
411
|
]
|
|
417
412
|
}
|
|
418
413
|
),
|
|
419
|
-
(r || l) &&
|
|
414
|
+
(r || l) && R && /* @__PURE__ */ i("tr", { className: "border-b border-slate-100 bg-red-50/50", children: /* @__PURE__ */ i("td", { colSpan: W, className: "px-2 py-1 text-[11px] text-red-600", children: R }) })
|
|
420
415
|
] }, e);
|
|
421
416
|
}),
|
|
422
417
|
c === "new" && /* @__PURE__ */ p("tr", { className: "border-b border-slate-100 bg-[#f0fbff] dark:bg-nvr-cyan/5", children: [
|
|
423
|
-
E.map((e) => /* @__PURE__ */
|
|
424
|
-
|
|
418
|
+
E.map((e) => /* @__PURE__ */ i("td", { className: "px-2 py-1 align-top", children: /* @__PURE__ */ i(
|
|
419
|
+
be,
|
|
425
420
|
{
|
|
426
421
|
field: e,
|
|
427
422
|
value: h[e.field] ?? null,
|
|
428
|
-
onChange: (t) =>
|
|
429
|
-
relations:
|
|
423
|
+
onChange: (t) => le(e.field, t),
|
|
424
|
+
relations: J,
|
|
430
425
|
collection: d,
|
|
431
426
|
itemId: "new"
|
|
432
427
|
}
|
|
433
428
|
) }, e.field)),
|
|
434
|
-
/* @__PURE__ */
|
|
435
|
-
/* @__PURE__ */
|
|
429
|
+
/* @__PURE__ */ i("td", { className: "px-1 py-1 align-middle", children: /* @__PURE__ */ p("div", { className: "flex items-stretch gap-1", children: [
|
|
430
|
+
/* @__PURE__ */ i(
|
|
436
431
|
"button",
|
|
437
432
|
{
|
|
438
433
|
type: "button",
|
|
439
|
-
disabled:
|
|
440
|
-
onClick:
|
|
434
|
+
disabled: U,
|
|
435
|
+
onClick: ce,
|
|
441
436
|
className: "rounded px-2 h-7 bg-nvr-cyan text-white text-[10px] font-medium hover:brightness-110 disabled:opacity-50",
|
|
442
|
-
children:
|
|
437
|
+
children: U ? "…" : "Add"
|
|
443
438
|
}
|
|
444
439
|
),
|
|
445
|
-
/* @__PURE__ */
|
|
440
|
+
/* @__PURE__ */ i(
|
|
446
441
|
"button",
|
|
447
442
|
{
|
|
448
443
|
type: "button",
|
|
@@ -453,36 +448,36 @@ function rt({
|
|
|
453
448
|
)
|
|
454
449
|
] }) })
|
|
455
450
|
] }),
|
|
456
|
-
c === "new" &&
|
|
457
|
-
!
|
|
451
|
+
c === "new" && R && /* @__PURE__ */ i("tr", { className: "border-b border-slate-100 bg-red-50/50", children: /* @__PURE__ */ i("td", { colSpan: W, className: "px-2 py-1 text-[11px] text-red-600", children: R }) }),
|
|
452
|
+
!Q && N.length === 0 && c !== "new" && /* @__PURE__ */ i("tr", { children: /* @__PURE__ */ i(
|
|
458
453
|
"td",
|
|
459
454
|
{
|
|
460
|
-
colSpan:
|
|
455
|
+
colSpan: W,
|
|
461
456
|
className: "px-2 py-3 text-center text-slate-400 text-[11px]",
|
|
462
457
|
children: "No rows"
|
|
463
458
|
}
|
|
464
459
|
) })
|
|
465
460
|
] })
|
|
466
461
|
] }),
|
|
467
|
-
!v && c !== "new" && /* @__PURE__ */
|
|
462
|
+
!v && c !== "new" && /* @__PURE__ */ i("div", { className: "px-2 py-1 bg-slate-50/50 border-t border-slate-200", children: /* @__PURE__ */ i(
|
|
468
463
|
"button",
|
|
469
464
|
{
|
|
470
465
|
type: "button",
|
|
471
|
-
onClick:
|
|
466
|
+
onClick: we,
|
|
472
467
|
className: "text-[11px] text-nvr-cyan font-medium hover:underline",
|
|
473
468
|
children: "+ Add row"
|
|
474
469
|
}
|
|
475
470
|
) })
|
|
476
471
|
] });
|
|
477
472
|
}
|
|
478
|
-
function
|
|
473
|
+
function Ve(o, s) {
|
|
479
474
|
return s ? o.toLocaleString("en-US", { style: "currency", currency: "USD" }) : o.toLocaleString("en-US", {
|
|
480
475
|
minimumFractionDigits: Number.isInteger(o) ? 0 : 2,
|
|
481
476
|
maximumFractionDigits: 2
|
|
482
477
|
});
|
|
483
478
|
}
|
|
484
479
|
export {
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
480
|
+
st as NestedRelationEditor,
|
|
481
|
+
Ve as formatRemaining,
|
|
482
|
+
Qe as roundCents
|
|
488
483
|
};
|