@nivaro/react 0.3.52 → 0.3.54
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 +47 -3
- package/dist/shared/components/ItemEditForm.js +4196 -4163
- package/dist/shared/components/NotificationBell.js +163 -150
- package/dist/shared/components/PageRenderer.js +645 -593
- package/dist/shared/components/ProfileView.js +36 -34
- package/dist/shared/components/QueryStatStrip.js +96 -89
- package/dist/shared/components/QueryTable.js +214 -215
- package/dist/shared/components/ReportView.js +548 -529
- package/dist/shared/components/alerts/AlertManagerView.js +346 -320
- package/dist/shared/components/item-edit/CatalogPickerField.js +1300 -1219
- package/dist/shared/components/item-edit/DraftRecoveryBanner.js +52 -54
- package/dist/shared/components/item-edit/FieldAffordances.js +145 -136
- package/dist/shared/components/item-edit/FieldRenderer.js +366 -326
- package/dist/shared/components/item-edit/InlineTableField.js +3047 -2932
- package/dist/shared/components/item-edit/NestedRelationEditor.js +149 -143
- package/dist/shared/components/item-edit/PersonalDefaultControl.js +12 -11
- package/dist/shared/components/item-edit/PlanGrid.js +718 -705
- package/dist/shared/components/item-edit/RelationCombobox.js +23 -20
- package/dist/shared/components/item-edit/SummaryPanel.js +415 -361
- package/dist/shared/components/item-edit/line-qty.js +115 -53
- package/dist/shared/components/item-edit/save-outcome.js +48 -0
- package/dist/shared/components/item-edit/save-refusal.js +18 -18
- package/dist/shared/components/item-edit/stale-banner.js +13 -0
- package/dist/shared/components/item-edit/usePersonalDefaults.js +225 -220
- package/dist/shared/components/panels/CommentPanel.js +204 -197
- package/dist/shared/components/panels/ItemLockBanner.js +318 -291
- package/dist/shared/components/panels/PipelinePanel.js +1388 -1218
- package/dist/shared/components/panels/RecordIntegrityBanner.js +201 -172
- package/dist/shared/components/panels/RevisionsPanel.js +101 -106
- package/dist/shared/components/panels/TransitionRequirementsDialog.js +564 -534
- package/dist/shared/components/panels/requirement-side-effects.js +46 -29
- package/dist/shared/components/queue/QueueItemSheet.js +219 -146
- package/dist/shared/components/queue/QueueWorklist.js +738 -730
- package/dist/shared/components/widgets/ReviewListWidget.js +236 -201
- package/dist/shared/lib/activity-sentence.js +236 -227
- package/dist/shared/lib/draft-store.js +35 -29
- package/dist/shared/lib/page-widget-access.js +11 -0
- package/dist/shared/lib/record-ref.js +43 -34
- 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 ge, useQuery as
|
|
2
|
+
import { useQueryClient as ge, useQuery as k } from "@tanstack/react-query";
|
|
3
3
|
import { Loader2 as Pe, Pencil as De, X as Ke } from "lucide-react";
|
|
4
|
-
import { useMemo as L, useRef as $e, useEffect as
|
|
4
|
+
import { useMemo as L, useRef as $e, useEffect as je, useState as T, Fragment as ke } from "react";
|
|
5
5
|
import { useNivaroClient as Le } from "../../context.js";
|
|
6
|
-
import { get as K, post as Te, patch as Fe, del as
|
|
7
|
-
import { titleCase as R, formatNumber as
|
|
6
|
+
import { get as K, post as Te, patch as Fe, del as Me } from "../../lib/commands.js";
|
|
7
|
+
import { titleCase as R, formatNumber as Ae, cn as ue, toLocalDateString as Je } from "../../lib/utils.js";
|
|
8
8
|
import { FieldRenderer as fe } from "./FieldRenderer.js";
|
|
9
|
-
import { SENTINEL_FIELDS as
|
|
10
|
-
const
|
|
9
|
+
import { SENTINEL_FIELDS as Ye, EMPTY_NESTED_OPS as O, applyDisplayTemplate as Se } from "./helpers.js";
|
|
10
|
+
const Ie = /* @__PURE__ */ new Set([
|
|
11
11
|
"alias",
|
|
12
12
|
"o2m",
|
|
13
13
|
"m2m",
|
|
@@ -15,22 +15,27 @@ const We = /* @__PURE__ */ new Set([
|
|
|
15
15
|
"presentation",
|
|
16
16
|
"group",
|
|
17
17
|
"divider"
|
|
18
|
-
]),
|
|
19
|
-
function
|
|
20
|
-
return
|
|
18
|
+
]), We = /* @__PURE__ */ new Set(["__apply_values__", "__create_with_defaults__"]);
|
|
19
|
+
function ze(o, l) {
|
|
20
|
+
return o === l || o == null && l == null ? !0 : o == null || l == null ? !1 : typeof o == "string" && typeof l == "number" || typeof o == "number" && typeof l == "string" ? String(o) === String(l) : JSON.stringify(o) === JSON.stringify(l);
|
|
21
21
|
}
|
|
22
|
-
function me(
|
|
22
|
+
function me(o) {
|
|
23
23
|
var x;
|
|
24
|
-
const
|
|
25
|
-
if ((x =
|
|
26
|
-
const q =
|
|
24
|
+
const l = o == null ? void 0 : o.response;
|
|
25
|
+
if ((x = l == null ? void 0 : l.violations) != null && x.length) {
|
|
26
|
+
const q = l.violations.map((b) => b.explanation).filter(Boolean).join("; ");
|
|
27
27
|
if (q) return q;
|
|
28
28
|
}
|
|
29
|
-
return
|
|
29
|
+
return l != null && l.message ? l.message : l != null && l.error ? l.error : o instanceof Error && o.message ? o.message : "Save failed";
|
|
30
30
|
}
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
function Ue(o) {
|
|
32
|
+
if (!Number.isFinite(o)) return o;
|
|
33
|
+
const l = Math.round((o + Math.sign(o) * Number.EPSILON) * 100) / 100;
|
|
34
|
+
return Object.is(l, -0) ? 0 : l;
|
|
35
|
+
}
|
|
36
|
+
function Ce({
|
|
37
|
+
parentCollection: o,
|
|
38
|
+
relationField: l,
|
|
34
39
|
parentRowId: x,
|
|
35
40
|
stagedMembers: q,
|
|
36
41
|
onStagedChange: b,
|
|
@@ -40,191 +45,191 @@ function Oe({
|
|
|
40
45
|
outerGridInvalidateKey: C,
|
|
41
46
|
deferred: F = !1,
|
|
42
47
|
onRowsChange: G,
|
|
43
|
-
stagedOps:
|
|
48
|
+
stagedOps: M,
|
|
44
49
|
onStagedOpsChange: f,
|
|
45
50
|
matchCollection: m,
|
|
46
|
-
matchQuery:
|
|
47
|
-
matchSeed:
|
|
51
|
+
matchQuery: A,
|
|
52
|
+
matchSeed: J
|
|
48
53
|
}) {
|
|
49
|
-
const y = Le(), ee = ge(), { data:
|
|
50
|
-
queryKey: ["collection-meta",
|
|
51
|
-
queryFn: () => y.request(K(`/collections/${
|
|
54
|
+
const y = Le(), ee = ge(), { data: Y, isLoading: xe } = k({
|
|
55
|
+
queryKey: ["collection-meta", o],
|
|
56
|
+
queryFn: () => y.request(K(`/collections/${o}`)).then((e) => {
|
|
52
57
|
const t = e.data;
|
|
53
58
|
return (t == null ? void 0 : t.relations) ?? [];
|
|
54
59
|
}),
|
|
55
60
|
staleTime: 10 * 6e4
|
|
56
61
|
}), P = L(
|
|
57
|
-
() =>
|
|
58
|
-
(e) => e.one_collection ===
|
|
62
|
+
() => Y == null ? void 0 : Y.find(
|
|
63
|
+
(e) => e.one_collection === o && e.one_field === l
|
|
59
64
|
),
|
|
60
|
-
[
|
|
61
|
-
),
|
|
62
|
-
queryKey: ["collection-meta",
|
|
63
|
-
queryFn: () => y.request(K(`/collections/${
|
|
65
|
+
[Y, o, l]
|
|
66
|
+
), d = m ?? (P == null ? void 0 : P.many_collection) ?? null, v = m ? null : (P == null ? void 0 : P.many_field) ?? null, { data: S = [] } = k({
|
|
67
|
+
queryKey: ["collection-meta", d],
|
|
68
|
+
queryFn: () => y.request(K(`/collections/${d}`)).then((e) => {
|
|
64
69
|
const t = e.data;
|
|
65
70
|
return (t == null ? void 0 : t.relations) ?? [];
|
|
66
71
|
}),
|
|
67
|
-
enabled: !!
|
|
72
|
+
enabled: !!d,
|
|
68
73
|
staleTime: 10 * 6e4
|
|
69
|
-
}), { data: te = [] } =
|
|
70
|
-
queryKey: ["field-config",
|
|
71
|
-
queryFn: () => y.request(K(`/field-config/${
|
|
72
|
-
enabled: !!
|
|
74
|
+
}), { data: te = [] } = k({
|
|
75
|
+
queryKey: ["field-config", d, null],
|
|
76
|
+
queryFn: () => y.request(K(`/field-config/${d}`)).then((e) => e.data ?? []),
|
|
77
|
+
enabled: !!d,
|
|
73
78
|
staleTime: 6e4
|
|
74
79
|
}), E = L(
|
|
75
80
|
() => te.filter(
|
|
76
|
-
(e) => !e.hidden && !
|
|
81
|
+
(e) => !e.hidden && !Ie.has(e.type) && e.field !== v && !(J && e.field in J) && e.field !== "id" && !Ye.has(e.field) && !We.has(e.group_key ?? "")
|
|
77
82
|
),
|
|
78
83
|
[te, v]
|
|
79
|
-
), re = m ? ["nested-rows",
|
|
84
|
+
), re = m ? ["nested-rows", d, JSON.stringify(A ?? null)] : ["nested-rows", d, v, x], { data: I = [], isLoading: Q } = k({
|
|
80
85
|
queryKey: re,
|
|
81
86
|
queryFn: () => y.request(
|
|
82
|
-
K(`/items/${
|
|
87
|
+
K(`/items/${d}`, {
|
|
83
88
|
filter: JSON.stringify(
|
|
84
|
-
m ?
|
|
89
|
+
m ? A : { [v]: { _eq: x } }
|
|
85
90
|
),
|
|
86
91
|
limit: 200
|
|
87
92
|
})
|
|
88
93
|
).then((e) => e.data ?? []),
|
|
89
|
-
enabled: m ? !!
|
|
94
|
+
enabled: m ? !!A : !!d && !!v && x != null,
|
|
90
95
|
staleTime: 3e4
|
|
91
96
|
}), N = L(() => {
|
|
92
97
|
if (x != null) {
|
|
93
98
|
if (F) {
|
|
94
|
-
const e =
|
|
95
|
-
const u = r.get(String(
|
|
96
|
-
return { key: String(
|
|
97
|
-
}),
|
|
98
|
-
return [...
|
|
99
|
+
const e = M ?? O, t = new Set(e.deleted), r = new Map(e.updated.map((a) => [a.id, a.changes])), s = I.filter((a) => !t.has(String(a.id))).map((a) => {
|
|
100
|
+
const u = r.get(String(a.id));
|
|
101
|
+
return { key: String(a.id), data: u ? { ...a, ...u } : a };
|
|
102
|
+
}), i = e.created.map((a, u) => ({ key: `created:${u}`, data: a }));
|
|
103
|
+
return [...s, ...i];
|
|
99
104
|
}
|
|
100
|
-
return
|
|
105
|
+
return I.map((e) => ({ key: String(e.id), data: e }));
|
|
101
106
|
}
|
|
102
107
|
return (q ?? []).map((e, t) => ({ key: `staged:${t}`, data: e }));
|
|
103
|
-
}, [x,
|
|
104
|
-
|
|
108
|
+
}, [x, I, q, F, M]), ne = $e("");
|
|
109
|
+
je(() => {
|
|
105
110
|
if (!G) return;
|
|
106
111
|
const e = JSON.stringify(N.map((t) => t.data));
|
|
107
112
|
e !== ne.current && (ne.current = e, G(N.map((t) => t.data)));
|
|
108
113
|
}, [N, G]);
|
|
109
|
-
const [
|
|
110
|
-
function
|
|
111
|
-
|
|
114
|
+
const [c, V] = T(null), [h, W] = T({}), [be, X] = T(null), [z, ie] = T(!1), [U, w] = T(null);
|
|
115
|
+
function se(e, t) {
|
|
116
|
+
W((r) => ({ ...r, [e]: t })), w(null);
|
|
112
117
|
}
|
|
113
118
|
function ye() {
|
|
114
|
-
_ || (V("new"),
|
|
119
|
+
_ || (V("new"), W({}), w(null));
|
|
115
120
|
}
|
|
116
121
|
function le(e, t) {
|
|
117
|
-
_ || (V(e),
|
|
122
|
+
_ || (V(e), W({ ...t }), w(null));
|
|
118
123
|
}
|
|
119
124
|
function D() {
|
|
120
|
-
V(null),
|
|
125
|
+
V(null), W({}), w(null);
|
|
121
126
|
}
|
|
122
127
|
function ae() {
|
|
123
128
|
ee.invalidateQueries({ queryKey: re }), C && ee.invalidateQueries({ queryKey: C });
|
|
124
129
|
}
|
|
125
130
|
async function oe() {
|
|
126
|
-
if (!
|
|
127
|
-
if (x != null &&
|
|
128
|
-
const t = new Set(E.map((
|
|
129
|
-
Object.entries(h).filter(([
|
|
131
|
+
if (!c) return;
|
|
132
|
+
if (x != null && d && (v || m)) {
|
|
133
|
+
const t = new Set(E.map((s) => s.field)), r = Object.fromEntries(
|
|
134
|
+
Object.entries(h).filter(([s]) => t.has(s))
|
|
130
135
|
);
|
|
131
136
|
if (F) {
|
|
132
|
-
const
|
|
133
|
-
if (
|
|
134
|
-
f == null || f({ ...
|
|
135
|
-
else if (
|
|
136
|
-
const u = parseInt(
|
|
137
|
-
$[u] =
|
|
137
|
+
const s = M ?? O, i = m ? { ...s, collection: m } : s, a = m ? { ...r, ...J ?? {} } : r;
|
|
138
|
+
if (c === "new")
|
|
139
|
+
f == null || f({ ...i, created: [...i.created, a] });
|
|
140
|
+
else if (c.startsWith("created:")) {
|
|
141
|
+
const u = parseInt(c.slice(8), 10), $ = [...i.created];
|
|
142
|
+
$[u] = a, f == null || f({ ...i, created: $ });
|
|
138
143
|
} else {
|
|
139
|
-
const u =
|
|
140
|
-
Object.entries(r).filter(([
|
|
141
|
-
), de =
|
|
142
|
-
Object.keys($).length > 0 && de.push({ id:
|
|
144
|
+
const u = I.find((j) => String(j.id) === c), $ = Object.fromEntries(
|
|
145
|
+
Object.entries(r).filter(([j, Ee]) => !ze(Ee, u == null ? void 0 : u[j]))
|
|
146
|
+
), de = i.updated.filter((j) => j.id !== c);
|
|
147
|
+
Object.keys($).length > 0 && de.push({ id: c, changes: $ }), f == null || f({ ...i, updated: de });
|
|
143
148
|
}
|
|
144
149
|
D();
|
|
145
150
|
return;
|
|
146
151
|
}
|
|
147
|
-
|
|
152
|
+
ie(!0);
|
|
148
153
|
try {
|
|
149
|
-
|
|
150
|
-
Te(`/items/${
|
|
154
|
+
c === "new" ? await y.request(
|
|
155
|
+
Te(`/items/${d}`, {
|
|
151
156
|
...r,
|
|
152
|
-
...m ?
|
|
157
|
+
...m ? J ?? {} : { [v]: x }
|
|
153
158
|
})
|
|
154
|
-
) : await y.request(Fe(`/items/${
|
|
155
|
-
} catch (
|
|
156
|
-
w(me(
|
|
159
|
+
) : await y.request(Fe(`/items/${d}/${c}`, r)), ae(), D();
|
|
160
|
+
} catch (s) {
|
|
161
|
+
w(me(s));
|
|
157
162
|
} finally {
|
|
158
|
-
|
|
163
|
+
ie(!1);
|
|
159
164
|
}
|
|
160
165
|
return;
|
|
161
166
|
}
|
|
162
167
|
const e = q ?? [];
|
|
163
|
-
if (
|
|
168
|
+
if (c === "new")
|
|
164
169
|
b == null || b([...e, h]);
|
|
165
|
-
else if (
|
|
166
|
-
const t = parseInt(
|
|
170
|
+
else if (c.startsWith("staged:")) {
|
|
171
|
+
const t = parseInt(c.slice(7), 10), r = [...e];
|
|
167
172
|
r[t] = h, b == null || b(r);
|
|
168
173
|
}
|
|
169
174
|
D();
|
|
170
175
|
}
|
|
171
176
|
async function Ne(e) {
|
|
172
|
-
if (x != null &&
|
|
177
|
+
if (x != null && d)
|
|
173
178
|
if (F) {
|
|
174
|
-
const t =
|
|
179
|
+
const t = M ?? O, r = m ? { ...t, collection: m } : t;
|
|
175
180
|
if (e.startsWith("created:")) {
|
|
176
|
-
const
|
|
177
|
-
f == null || f({ ...r, created: r.created.filter((
|
|
181
|
+
const s = parseInt(e.slice(8), 10);
|
|
182
|
+
f == null || f({ ...r, created: r.created.filter((i, a) => a !== s) });
|
|
178
183
|
} else
|
|
179
184
|
f == null || f({
|
|
180
185
|
...r,
|
|
181
|
-
updated: r.updated.filter((
|
|
186
|
+
updated: r.updated.filter((s) => s.id !== e),
|
|
182
187
|
deleted: r.deleted.includes(e) ? r.deleted : [...r.deleted, e]
|
|
183
188
|
});
|
|
184
189
|
} else
|
|
185
190
|
try {
|
|
186
|
-
await y.request(
|
|
191
|
+
await y.request(Me(`/items/${d}/${e}`)), ae();
|
|
187
192
|
} catch (t) {
|
|
188
193
|
w(me(t));
|
|
189
194
|
return;
|
|
190
195
|
}
|
|
191
196
|
else {
|
|
192
197
|
const t = parseInt(e.slice(7), 10);
|
|
193
|
-
b == null || b((q ?? []).filter((r,
|
|
198
|
+
b == null || b((q ?? []).filter((r, s) => s !== t));
|
|
194
199
|
}
|
|
195
|
-
X(null), w(null),
|
|
200
|
+
X(null), w(null), c === e && D();
|
|
196
201
|
}
|
|
197
202
|
const H = L(() => {
|
|
198
203
|
const e = /* @__PURE__ */ new Map();
|
|
199
204
|
for (const t of E) {
|
|
200
205
|
const r = S.find(
|
|
201
|
-
(
|
|
206
|
+
(s) => s.many_collection === d && s.many_field === t.field && !s.junction_field
|
|
202
207
|
);
|
|
203
208
|
r != null && r.one_collection && e.set(t.field, r);
|
|
204
209
|
}
|
|
205
210
|
return e;
|
|
206
|
-
}, [E, S,
|
|
211
|
+
}, [E, S, d]), Z = L(() => {
|
|
207
212
|
const e = /* @__PURE__ */ new Map();
|
|
208
213
|
for (const { key: t, data: r } of N) {
|
|
209
|
-
const
|
|
210
|
-
for (const [
|
|
211
|
-
const u = i
|
|
212
|
-
u == null || u === "" || !
|
|
214
|
+
const s = c === t ? h : r;
|
|
215
|
+
for (const [i, a] of H) {
|
|
216
|
+
const u = s[i];
|
|
217
|
+
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)));
|
|
213
218
|
}
|
|
214
219
|
}
|
|
215
220
|
return e;
|
|
216
|
-
}, [N,
|
|
221
|
+
}, [N, c, h, H]), { data: he = {} } = k({
|
|
217
222
|
queryKey: [
|
|
218
223
|
"nested-m2o-display",
|
|
219
|
-
|
|
224
|
+
d,
|
|
220
225
|
...Array.from(Z.entries()).flatMap(([e, t]) => [e, ...t])
|
|
221
226
|
],
|
|
222
227
|
queryFn: async () => {
|
|
223
228
|
const e = {};
|
|
224
229
|
return await Promise.all(
|
|
225
230
|
[...Z.entries()].map(async ([t, r]) => {
|
|
226
|
-
var
|
|
227
|
-
const [
|
|
231
|
+
var a;
|
|
232
|
+
const [s, i] = await Promise.all([
|
|
228
233
|
y.request(
|
|
229
234
|
K(`/collections/${t}`)
|
|
230
235
|
),
|
|
@@ -236,9 +241,9 @@ function Oe({
|
|
|
236
241
|
)
|
|
237
242
|
]);
|
|
238
243
|
e[t] = {};
|
|
239
|
-
for (const u of
|
|
244
|
+
for (const u of i.data ?? [])
|
|
240
245
|
e[t][String(u.id)] = Se(
|
|
241
|
-
(
|
|
246
|
+
(a = s.data) == null ? void 0 : a.display_template,
|
|
242
247
|
u
|
|
243
248
|
);
|
|
244
249
|
})
|
|
@@ -248,40 +253,40 @@ function Oe({
|
|
|
248
253
|
staleTime: 6e4
|
|
249
254
|
});
|
|
250
255
|
function we(e, t) {
|
|
251
|
-
var
|
|
256
|
+
var s;
|
|
252
257
|
if (t == null || t === "")
|
|
253
258
|
return /* @__PURE__ */ n("span", { className: "text-slate-300", children: "—" });
|
|
254
259
|
const r = H.get(e.field);
|
|
255
260
|
if (r != null && r.one_collection) {
|
|
256
|
-
const
|
|
257
|
-
return /* @__PURE__ */ n("span", { className: "block truncate", children:
|
|
261
|
+
const i = (s = he[r.one_collection]) == null ? void 0 : s[String(t)];
|
|
262
|
+
return /* @__PURE__ */ n("span", { className: "block truncate", children: i ?? String(t) });
|
|
258
263
|
}
|
|
259
264
|
if (e.type === "boolean")
|
|
260
265
|
return /* @__PURE__ */ n("span", { className: t ? "text-emerald-600" : "text-slate-400", children: t ? "Yes" : "No" });
|
|
261
266
|
if (e.type === "datetime" || e.type === "date")
|
|
262
267
|
try {
|
|
263
|
-
return /* @__PURE__ */ n("span", { className: "block truncate", children:
|
|
268
|
+
return /* @__PURE__ */ n("span", { className: "block truncate", children: Je(t) });
|
|
264
269
|
} catch {
|
|
265
270
|
}
|
|
266
271
|
return /* @__PURE__ */ n("span", { className: "block truncate", children: String(t) });
|
|
267
272
|
}
|
|
268
273
|
const _e = g && Number(pe[g.cap_field]) || 0, ve = g ? N.reduce(
|
|
269
274
|
(e, t) => {
|
|
270
|
-
const r =
|
|
275
|
+
const r = c === t.key ? h : t.data;
|
|
271
276
|
return e + (Number(r[g.sum_field]) || 0);
|
|
272
277
|
},
|
|
273
|
-
|
|
274
|
-
) : 0, ce = _e - ve;
|
|
275
|
-
if (xe && !m || !
|
|
276
|
-
if (m && !
|
|
278
|
+
c === "new" && Number(h[g.sum_field]) || 0
|
|
279
|
+
) : 0, ce = Ue(_e - ve);
|
|
280
|
+
if (xe && !m || !d || !v && !m) return null;
|
|
281
|
+
if (m && !A)
|
|
277
282
|
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: [
|
|
278
|
-
R(
|
|
283
|
+
R(l),
|
|
279
284
|
" — available after this row is saved."
|
|
280
285
|
] });
|
|
281
286
|
const qe = _ ? 0 : 1, B = E.length + qe;
|
|
282
287
|
return /* @__PURE__ */ p("div", { className: "overflow-hidden rounded-md border border-slate-200", children: [
|
|
283
288
|
/* @__PURE__ */ p("div", { className: "flex items-center gap-2 px-2 py-1 bg-slate-50 border-b border-slate-200", children: [
|
|
284
|
-
/* @__PURE__ */ n("span", { className: "text-[10px] font-medium text-slate-400 uppercase tracking-wide", children: R(
|
|
289
|
+
/* @__PURE__ */ n("span", { className: "text-[10px] font-medium text-slate-400 uppercase tracking-wide", children: R(l) }),
|
|
285
290
|
/* @__PURE__ */ n("span", { className: "rounded bg-slate-100 px-1.5 py-0.5 text-[10px] font-medium text-slate-500", children: N.length }),
|
|
286
291
|
g && /* @__PURE__ */ p(
|
|
287
292
|
"span",
|
|
@@ -292,7 +297,7 @@ function Oe({
|
|
|
292
297
|
),
|
|
293
298
|
children: [
|
|
294
299
|
"remaining: ",
|
|
295
|
-
|
|
300
|
+
Ae(ce)
|
|
296
301
|
]
|
|
297
302
|
}
|
|
298
303
|
)
|
|
@@ -312,8 +317,8 @@ function Oe({
|
|
|
312
317
|
/* @__PURE__ */ p("tbody", { children: [
|
|
313
318
|
Q && /* @__PURE__ */ n("tr", { children: /* @__PURE__ */ n("td", { colSpan: B, className: "px-2 py-3 text-center text-slate-400", children: /* @__PURE__ */ n(Pe, { className: "h-3.5 w-3.5 animate-spin inline" }) }) }),
|
|
314
319
|
!Q && N.map(({ key: e, data: t }) => {
|
|
315
|
-
const r =
|
|
316
|
-
return /* @__PURE__ */ p(
|
|
320
|
+
const r = c === e, s = be === e;
|
|
321
|
+
return /* @__PURE__ */ p(ke, { children: [
|
|
317
322
|
/* @__PURE__ */ p(
|
|
318
323
|
"tr",
|
|
319
324
|
{
|
|
@@ -324,49 +329,49 @@ function Oe({
|
|
|
324
329
|
!r && !_ ? "cursor-pointer" : ""
|
|
325
330
|
),
|
|
326
331
|
children: [
|
|
327
|
-
E.map((
|
|
332
|
+
E.map((i) => /* @__PURE__ */ n("td", { className: "px-2 py-1 align-top", children: r ? /* @__PURE__ */ n(
|
|
328
333
|
fe,
|
|
329
334
|
{
|
|
330
|
-
field:
|
|
331
|
-
value: h[
|
|
332
|
-
onChange: (
|
|
335
|
+
field: i,
|
|
336
|
+
value: h[i.field] ?? null,
|
|
337
|
+
onChange: (a) => se(i.field, a),
|
|
333
338
|
relations: S,
|
|
334
|
-
collection:
|
|
339
|
+
collection: d,
|
|
335
340
|
itemId: x != null ? e : "new"
|
|
336
341
|
}
|
|
337
|
-
) : /* @__PURE__ */ n("div", { className: "py-0.5 overflow-hidden", children: we(
|
|
342
|
+
) : /* @__PURE__ */ n("div", { className: "py-0.5 overflow-hidden", children: we(i, t[i.field]) }) }, i.field)),
|
|
338
343
|
!_ && /* @__PURE__ */ n("td", { className: "px-1 py-1 align-middle", children: r ? /* @__PURE__ */ p("div", { className: "flex items-stretch gap-1", children: [
|
|
339
344
|
/* @__PURE__ */ n(
|
|
340
345
|
"button",
|
|
341
346
|
{
|
|
342
347
|
type: "button",
|
|
343
|
-
disabled:
|
|
344
|
-
onClick: (
|
|
345
|
-
|
|
348
|
+
disabled: z,
|
|
349
|
+
onClick: (i) => {
|
|
350
|
+
i.stopPropagation(), oe();
|
|
346
351
|
},
|
|
347
352
|
className: "rounded px-2 h-7 bg-nvr-cyan text-white text-[10px] font-medium hover:brightness-110 disabled:opacity-50",
|
|
348
|
-
children:
|
|
353
|
+
children: z ? "…" : "Save"
|
|
349
354
|
}
|
|
350
355
|
),
|
|
351
356
|
/* @__PURE__ */ n(
|
|
352
357
|
"button",
|
|
353
358
|
{
|
|
354
359
|
type: "button",
|
|
355
|
-
onClick: (
|
|
356
|
-
|
|
360
|
+
onClick: (i) => {
|
|
361
|
+
i.stopPropagation(), D();
|
|
357
362
|
},
|
|
358
363
|
className: "rounded px-1.5 h-7 text-slate-400 hover:text-slate-700 text-[10px]",
|
|
359
364
|
children: "✕"
|
|
360
365
|
}
|
|
361
366
|
)
|
|
362
|
-
] }) :
|
|
367
|
+
] }) : s ? /* @__PURE__ */ p("div", { className: "flex items-center justify-end gap-1", children: [
|
|
363
368
|
/* @__PURE__ */ n("span", { className: "text-[10px] text-slate-400", children: "Delete?" }),
|
|
364
369
|
/* @__PURE__ */ n(
|
|
365
370
|
"button",
|
|
366
371
|
{
|
|
367
372
|
type: "button",
|
|
368
|
-
onClick: (
|
|
369
|
-
|
|
373
|
+
onClick: (i) => {
|
|
374
|
+
i.stopPropagation(), Ne(e);
|
|
370
375
|
},
|
|
371
376
|
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",
|
|
372
377
|
children: "Yes"
|
|
@@ -376,8 +381,8 @@ function Oe({
|
|
|
376
381
|
"button",
|
|
377
382
|
{
|
|
378
383
|
type: "button",
|
|
379
|
-
onClick: (
|
|
380
|
-
|
|
384
|
+
onClick: (i) => {
|
|
385
|
+
i.stopPropagation(), X(null), w(null);
|
|
381
386
|
},
|
|
382
387
|
className: "rounded px-1.5 py-0.5 text-[10px] text-slate-400 hover:text-slate-700 border border-slate-200",
|
|
383
388
|
children: "Cancel"
|
|
@@ -388,8 +393,8 @@ function Oe({
|
|
|
388
393
|
"button",
|
|
389
394
|
{
|
|
390
395
|
type: "button",
|
|
391
|
-
onClick: (
|
|
392
|
-
|
|
396
|
+
onClick: (i) => {
|
|
397
|
+
i.stopPropagation(), le(e, t);
|
|
393
398
|
},
|
|
394
399
|
className: "rounded p-0.5 text-slate-300 hover:text-nvr-cyan",
|
|
395
400
|
children: /* @__PURE__ */ n(De, { className: "h-3 w-3" })
|
|
@@ -399,8 +404,8 @@ function Oe({
|
|
|
399
404
|
"button",
|
|
400
405
|
{
|
|
401
406
|
type: "button",
|
|
402
|
-
onClick: (
|
|
403
|
-
|
|
407
|
+
onClick: (i) => {
|
|
408
|
+
i.stopPropagation(), X(e), w(null);
|
|
404
409
|
},
|
|
405
410
|
className: "rounded p-0.5 text-slate-300 hover:text-red-500",
|
|
406
411
|
children: /* @__PURE__ */ n(Ke, { className: "h-3 w-3" })
|
|
@@ -410,18 +415,18 @@ function Oe({
|
|
|
410
415
|
]
|
|
411
416
|
}
|
|
412
417
|
),
|
|
413
|
-
(r ||
|
|
418
|
+
(r || s) && U && /* @__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: U }) })
|
|
414
419
|
] }, e);
|
|
415
420
|
}),
|
|
416
|
-
|
|
421
|
+
c === "new" && /* @__PURE__ */ p("tr", { className: "border-b border-slate-100 bg-[#f0fbff] dark:bg-nvr-cyan/5", children: [
|
|
417
422
|
E.map((e) => /* @__PURE__ */ n("td", { className: "px-2 py-1 align-top", children: /* @__PURE__ */ n(
|
|
418
423
|
fe,
|
|
419
424
|
{
|
|
420
425
|
field: e,
|
|
421
426
|
value: h[e.field] ?? null,
|
|
422
|
-
onChange: (t) =>
|
|
427
|
+
onChange: (t) => se(e.field, t),
|
|
423
428
|
relations: S,
|
|
424
|
-
collection:
|
|
429
|
+
collection: d,
|
|
425
430
|
itemId: "new"
|
|
426
431
|
}
|
|
427
432
|
) }, e.field)),
|
|
@@ -430,10 +435,10 @@ function Oe({
|
|
|
430
435
|
"button",
|
|
431
436
|
{
|
|
432
437
|
type: "button",
|
|
433
|
-
disabled:
|
|
438
|
+
disabled: z,
|
|
434
439
|
onClick: oe,
|
|
435
440
|
className: "rounded px-2 h-7 bg-nvr-cyan text-white text-[10px] font-medium hover:brightness-110 disabled:opacity-50",
|
|
436
|
-
children:
|
|
441
|
+
children: z ? "…" : "Add"
|
|
437
442
|
}
|
|
438
443
|
),
|
|
439
444
|
/* @__PURE__ */ n(
|
|
@@ -447,8 +452,8 @@ function Oe({
|
|
|
447
452
|
)
|
|
448
453
|
] }) })
|
|
449
454
|
] }),
|
|
450
|
-
|
|
451
|
-
!Q && N.length === 0 &&
|
|
455
|
+
c === "new" && U && /* @__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: U }) }),
|
|
456
|
+
!Q && N.length === 0 && c !== "new" && /* @__PURE__ */ n("tr", { children: /* @__PURE__ */ n(
|
|
452
457
|
"td",
|
|
453
458
|
{
|
|
454
459
|
colSpan: B,
|
|
@@ -458,7 +463,7 @@ function Oe({
|
|
|
458
463
|
) })
|
|
459
464
|
] })
|
|
460
465
|
] }),
|
|
461
|
-
!_ &&
|
|
466
|
+
!_ && c !== "new" && /* @__PURE__ */ n("div", { className: "px-2 py-1 bg-slate-50/50 border-t border-slate-200", children: /* @__PURE__ */ n(
|
|
462
467
|
"button",
|
|
463
468
|
{
|
|
464
469
|
type: "button",
|
|
@@ -470,5 +475,6 @@ function Oe({
|
|
|
470
475
|
] });
|
|
471
476
|
}
|
|
472
477
|
export {
|
|
473
|
-
|
|
478
|
+
Ce as NestedRelationEditor,
|
|
479
|
+
Ue as roundCents
|
|
474
480
|
};
|
|
@@ -4,18 +4,19 @@ import { useState as F, Fragment as P, useInsertionEffect as T } from "react";
|
|
|
4
4
|
import { toast as h } from "sonner";
|
|
5
5
|
import { plainErrorText as I, userErrorMessage as R } from "../../lib/safe-error.js";
|
|
6
6
|
import { usePersonalDefaultsApi as D } from "./usePersonalDefaults.js";
|
|
7
|
-
function
|
|
8
|
-
return e.applied && e.hasDefault ? "applied" : e.editable ? e.loaded ? e.failed && !e.hasDefault ? e.hasValue ? "offer" : null : e.hasDefault ? e.hasValue ? e.isDefault ? "saved" : "update" : "saved-empty" : e.hasValue ? "offer" : "reserve" :
|
|
7
|
+
function V(e) {
|
|
8
|
+
return e.applied && e.hasDefault ? "applied" : e.editable ? !e.loaded || e.held && !e.hasValue ? "reserve" : e.failed && !e.hasDefault ? e.hasValue ? "offer" : null : e.hasDefault ? e.hasValue ? e.isDefault ? "saved" : "update" : "saved-empty" : e.hasValue ? "offer" : "reserve" : null;
|
|
9
9
|
}
|
|
10
10
|
function q(e, t, a) {
|
|
11
|
-
return e != null && e.allowed(t) ? e.manageable(t) ?
|
|
11
|
+
return e != null && e.allowed(t) ? e.manageable(t) ? V({
|
|
12
12
|
editable: a,
|
|
13
13
|
loaded: e.loaded,
|
|
14
14
|
hasValue: e.hasValue(t),
|
|
15
15
|
hasDefault: e.defaultFor(t) !== null,
|
|
16
16
|
isDefault: e.isDefault(t),
|
|
17
17
|
applied: e.applied(t),
|
|
18
|
-
failed: e.failed
|
|
18
|
+
failed: e.failed,
|
|
19
|
+
held: e.held === !0
|
|
19
20
|
}) : e.applied(t) && e.defaultFor(t) !== null ? "applied" : null : null;
|
|
20
21
|
}
|
|
21
22
|
function g(e, t) {
|
|
@@ -23,7 +24,7 @@ function g(e, t) {
|
|
|
23
24
|
const a = e, d = ((p = (s = a == null ? void 0 : a.response) == null ? void 0 : s.data) == null ? void 0 : p.error) ?? ((o = a == null ? void 0 : a.data) == null ? void 0 : o.error) ?? (a == null ? void 0 : a.error);
|
|
24
25
|
return typeof d == "string" ? I(d, t) : R(e, t);
|
|
25
26
|
}
|
|
26
|
-
function
|
|
27
|
+
function A(e, t) {
|
|
27
28
|
return e.clear(t).then(
|
|
28
29
|
(a) => (h.success(
|
|
29
30
|
"Your default was cleared",
|
|
@@ -42,7 +43,7 @@ function L(e, t) {
|
|
|
42
43
|
(a) => (h.error(g(a, "Could not clear your default")), !1)
|
|
43
44
|
);
|
|
44
45
|
}
|
|
45
|
-
const
|
|
46
|
+
const L = `
|
|
46
47
|
[data-pd-row]{container-type:inline-size;container-name:nvrpd}
|
|
47
48
|
[data-personal-default-slot]{min-width:13rem}
|
|
48
49
|
[data-personal-default-slot][data-pd-new]{min-width:16rem}
|
|
@@ -69,7 +70,7 @@ function $() {
|
|
|
69
70
|
T(() => {
|
|
70
71
|
if (typeof document > "u" || document.getElementById(N)) return;
|
|
71
72
|
const e = document.createElement("style");
|
|
72
|
-
e.id = N, e.textContent =
|
|
73
|
+
e.id = N, e.textContent = L, document.head.appendChild(e);
|
|
73
74
|
}, []);
|
|
74
75
|
}
|
|
75
76
|
const y = 'relative inline-flex h-5 shrink-0 items-center gap-1 whitespace-nowrap rounded px-1 text-[10.5px] font-medium text-slate-500 transition-colors duration-150 before:absolute before:inset-x-0 before:-inset-y-0.5 before:content-[""] hover:bg-muted hover:text-slate-800 active:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-600 disabled:cursor-not-allowed disabled:opacity-50 aria-expanded:bg-muted aria-expanded:text-slate-800 dark:text-muted-foreground dark:hover:text-foreground dark:focus-visible:ring-sky-300 dark:aria-expanded:text-foreground', M = "inline-flex h-5 shrink-0 items-center gap-1 whitespace-nowrap px-1 text-[10.5px] font-medium text-slate-500 dark:text-muted-foreground", j = "inline-flex h-5 shrink-0 items-center gap-1 whitespace-nowrap rounded bg-sky-50 px-1.5 text-[10.5px] font-medium text-sky-800 dark:bg-sky-900/30 dark:text-sky-200";
|
|
@@ -105,7 +106,7 @@ function G({
|
|
|
105
106
|
disabled: x || !l,
|
|
106
107
|
"aria-busy": x || void 0,
|
|
107
108
|
onClick: () => {
|
|
108
|
-
l && (b(!0),
|
|
109
|
+
l && (b(!0), A(l, e).then((n) => {
|
|
109
110
|
b(!1), n && (o == null || o());
|
|
110
111
|
}));
|
|
111
112
|
},
|
|
@@ -218,12 +219,12 @@ function H({ field: e }) {
|
|
|
218
219
|
);
|
|
219
220
|
}
|
|
220
221
|
export {
|
|
221
|
-
|
|
222
|
+
L as PERSONAL_DEFAULT_CSS,
|
|
222
223
|
H as PersonalDefaultMark,
|
|
223
224
|
G as PersonalDefaultSlot,
|
|
224
|
-
|
|
225
|
+
A as clearPersonalDefault,
|
|
225
226
|
q as personalDefaultSlotFor,
|
|
226
|
-
|
|
227
|
+
V as personalDefaultSlotState,
|
|
227
228
|
g as refusalText,
|
|
228
229
|
$ as usePersonalDefaultCss
|
|
229
230
|
};
|