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