@nivaro/react 0.3.51 → 0.3.53
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 +3885 -3847
- package/dist/shared/components/NotificationBell.js +163 -150
- package/dist/shared/components/PageRenderer.js +600 -549
- 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/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/PlanGrid.js +718 -705
- package/dist/shared/components/item-edit/SummaryPanel.js +351 -337
- package/dist/shared/components/item-edit/line-qty.js +115 -53
- package/dist/shared/components/item-edit/save-refusal.js +18 -18
- package/dist/shared/components/item-edit/usePersonalDefaults.js +210 -207
- 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/record-ref.js +43 -34
- package/package.json +1 -1
|
@@ -1,84 +1,87 @@
|
|
|
1
|
-
import { useQueryClient as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { useNivaroClient as
|
|
4
|
-
import { get as
|
|
5
|
-
import { isEmptyValue as v, pickDefault as
|
|
6
|
-
import { titleCase as
|
|
7
|
-
const
|
|
8
|
-
function
|
|
9
|
-
return
|
|
1
|
+
import { useQueryClient as Be, useQuery as Ie } from "@tanstack/react-query";
|
|
2
|
+
import { useRef as F, useMemo as Oe, useState as ae, useEffect as I, useCallback as l, createContext as Ue, useContext as _e } from "react";
|
|
3
|
+
import { useNivaroClient as Je } from "../../context.js";
|
|
4
|
+
import { get as We, put as ie, del as Ge } from "../../lib/commands.js";
|
|
5
|
+
import { isEmptyValue as v, pickDefault as le, cascadeParents as K, orderTopDown as Xe, captureContext as Ze } from "../../lib/personal-defaults.js";
|
|
6
|
+
import { titleCase as Ce } from "../../lib/utils.js";
|
|
7
|
+
const et = Ue(null);
|
|
8
|
+
function dt() {
|
|
9
|
+
return _e(et);
|
|
10
10
|
}
|
|
11
11
|
function Q(i) {
|
|
12
12
|
return ["field-defaults", i];
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
return Array.isArray(i) ? i.map(
|
|
14
|
+
function L(i) {
|
|
15
|
+
return Array.isArray(i) ? i.map(L) : i && typeof i == "object" && "id" in i ? i.id : i;
|
|
16
16
|
}
|
|
17
|
-
const
|
|
18
|
-
function E(i, f,
|
|
17
|
+
const tt = /* @__PURE__ */ new Set(["integer", "bigInteger", "float", "decimal", "number", "double"]), rt = /* @__PURE__ */ new Set(["date"]), nt = /* @__PURE__ */ new Set(["dateTime", "datetime", "timestamp", "time"]);
|
|
18
|
+
function E(i, f, S) {
|
|
19
19
|
if (v(i) && v(f)) return !0;
|
|
20
|
-
if (
|
|
21
|
-
const M =
|
|
22
|
-
if (
|
|
20
|
+
if (S && !Array.isArray(i) && !Array.isArray(f) && !v(i) && !v(f)) {
|
|
21
|
+
const M = L(i), k = L(f);
|
|
22
|
+
if (tt.has(S)) {
|
|
23
23
|
const p = Number(M), m = Number(k);
|
|
24
24
|
if (Number.isFinite(p) && Number.isFinite(m)) return p === m;
|
|
25
|
-
} else if (
|
|
26
|
-
const p = (
|
|
27
|
-
var
|
|
28
|
-
return (
|
|
25
|
+
} else if (rt.has(S)) {
|
|
26
|
+
const p = (q) => {
|
|
27
|
+
var Y;
|
|
28
|
+
return (Y = /^(\d{4}-\d{2}-\d{2})/.exec(String(q))) == null ? void 0 : Y[1];
|
|
29
29
|
}, m = p(M), d = p(k);
|
|
30
30
|
if (m && d) return m === d;
|
|
31
|
-
} else if (
|
|
31
|
+
} else if (nt.has(S)) {
|
|
32
32
|
const p = Date.parse(String(M)), m = Date.parse(String(k));
|
|
33
33
|
if (Number.isFinite(p) && Number.isFinite(m)) return p === m;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
const N = (M) => {
|
|
37
|
-
const k =
|
|
37
|
+
const k = L(M);
|
|
38
38
|
return Array.isArray(k) ? k.map((p) => String(p)).sort() : String(k);
|
|
39
39
|
};
|
|
40
40
|
return JSON.stringify(N(i)) === JSON.stringify(N(f));
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
let
|
|
42
|
+
function yt(i, f) {
|
|
43
|
+
let S = 0;
|
|
44
44
|
for (const [N, M] of i) {
|
|
45
45
|
const k = f.get(N);
|
|
46
|
-
for (const p of M) k != null && k.has(String(p)) ||
|
|
46
|
+
for (const p of M) k != null && k.has(String(p)) || S++;
|
|
47
47
|
}
|
|
48
|
-
return
|
|
48
|
+
return S;
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function st(i) {
|
|
51
51
|
return Array.isArray(i) ? i : v(i) ? [] : [i];
|
|
52
52
|
}
|
|
53
|
-
function
|
|
54
|
-
const { collection: f, isNew:
|
|
53
|
+
function pt(i) {
|
|
54
|
+
const { collection: f, isNew: S, disabled: N, enabled: M = !0, ready: k = !0 } = i, p = Je(), m = Be(), d = F(i);
|
|
55
55
|
d.current = i;
|
|
56
|
-
const { data:
|
|
56
|
+
const { data: q, isError: Y } = Ie({
|
|
57
57
|
queryKey: Q(f),
|
|
58
|
-
queryFn: () => p.request(
|
|
58
|
+
queryFn: () => p.request(We("/field-defaults/mine", { collection: f })).then((e) => e.data ?? []),
|
|
59
59
|
staleTime: 5 * 6e4,
|
|
60
60
|
enabled: !!f && M
|
|
61
|
-
}), U =
|
|
61
|
+
}), U = Oe(() => {
|
|
62
62
|
const e = /* @__PURE__ */ new Map();
|
|
63
|
-
for (const t of
|
|
63
|
+
for (const t of q ?? []) {
|
|
64
64
|
const r = e.get(t.field) ?? [];
|
|
65
65
|
r.push(t), e.set(t.field, r);
|
|
66
66
|
}
|
|
67
67
|
return e;
|
|
68
|
-
}, [
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
I(() => (
|
|
72
|
-
|
|
68
|
+
}, [q]), ee = F(U);
|
|
69
|
+
ee.current = U;
|
|
70
|
+
const h = F(/* @__PURE__ */ new Map()), [_, Ve] = ae(() => /* @__PURE__ */ new Map()), A = F(/* @__PURE__ */ new Map()), [te, Ke] = ae(() => /* @__PURE__ */ new Map()), T = F(/* @__PURE__ */ new Set()), H = F(/* @__PURE__ */ new Map()), J = F(!0);
|
|
71
|
+
I(() => (J.current = !0, () => {
|
|
72
|
+
J.current = !1;
|
|
73
73
|
}), []);
|
|
74
|
-
const b = l(() => {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
74
|
+
const fe = F(_), de = F(te), b = l(() => {
|
|
75
|
+
if (!J.current) return;
|
|
76
|
+
const e = (t, r) => t.size === r.size && [...r].every(([n, s]) => t.get(n) === s);
|
|
77
|
+
if (!e(fe.current, h.current)) {
|
|
78
|
+
const t = new Map(h.current);
|
|
79
|
+
fe.current = t, Ve(t);
|
|
80
|
+
}
|
|
81
|
+
if (!e(de.current, A.current)) {
|
|
82
|
+
const t = new Map(A.current);
|
|
83
|
+
de.current = t, Ke(t);
|
|
84
|
+
}
|
|
82
85
|
}, []), o = l((e) => {
|
|
83
86
|
var n;
|
|
84
87
|
const t = d.current, r = (n = t.readValue) == null ? void 0 : n.call(t, e);
|
|
@@ -92,7 +95,7 @@ function dt(i) {
|
|
|
92
95
|
[o]
|
|
93
96
|
), D = l(async (e, t) => {
|
|
94
97
|
const r = d.current, s = (await Promise.all(
|
|
95
|
-
|
|
98
|
+
st(L(t)).map(async (u) => {
|
|
96
99
|
if (!r.valueLabel) return String(u);
|
|
97
100
|
try {
|
|
98
101
|
return await r.valueLabel(e, u) ?? null;
|
|
@@ -102,217 +105,217 @@ function dt(i) {
|
|
|
102
105
|
})
|
|
103
106
|
)).filter((u) => !!u);
|
|
104
107
|
return s.length > 0 ? s.join(", ") : null;
|
|
105
|
-
}, []),
|
|
108
|
+
}, []), $ = F(0), W = l(
|
|
106
109
|
async (e, t, r) => {
|
|
107
110
|
const n = await t;
|
|
108
|
-
|
|
111
|
+
$.current === r && (A.current.set(e, n), b());
|
|
109
112
|
},
|
|
110
113
|
[b]
|
|
111
|
-
),
|
|
114
|
+
), re = l(
|
|
112
115
|
async (e, t) => {
|
|
113
116
|
var s, u;
|
|
114
117
|
const r = ((u = (s = d.current).fieldLabel) == null ? void 0 : u.call(s, e)) ?? e, n = await D(e, t);
|
|
115
118
|
return n ? `Your default is for ${r} “${n}”` : `Your saved default is for a different ${r}`;
|
|
116
119
|
},
|
|
117
120
|
[D]
|
|
118
|
-
),
|
|
121
|
+
), G = l((e, t, r) => {
|
|
119
122
|
const n = d.current;
|
|
120
123
|
if (n.setFieldValue(e, t, r), v(t)) {
|
|
121
|
-
|
|
124
|
+
h.current.delete(e);
|
|
122
125
|
return;
|
|
123
126
|
}
|
|
124
|
-
|
|
125
|
-
}, []),
|
|
127
|
+
h.current.set(e, t), A.current.delete(e), n.markAutoFilled([e]);
|
|
128
|
+
}, []), ye = l(
|
|
126
129
|
async (e, t) => {
|
|
127
|
-
var
|
|
128
|
-
const r = d.current, n = () =>
|
|
130
|
+
var Re, Me, qe, De, Ee, Ne;
|
|
131
|
+
const r = d.current, n = () => $.current !== t, s = ee.current.get(e) ?? [];
|
|
129
132
|
if (s.length === 0 || !r.layoutAllows(e)) return [];
|
|
130
|
-
if (T.current.has(e) || !(((
|
|
133
|
+
if (T.current.has(e) || !(((Re = r.canFill) == null ? void 0 : Re.call(r, e)) ?? !0)) return [];
|
|
131
134
|
const u = o(e), y = !v(u);
|
|
132
|
-
if (y && !(((
|
|
133
|
-
const
|
|
135
|
+
if (y && !(((Me = r.replaceable) == null ? void 0 : Me.call(r, e, u)) ?? !1)) return [];
|
|
136
|
+
const R = new Set(s.flatMap((a) => Object.keys(a.context ?? {}))), w = O(R), { pick: c, fillParents: g, blockedBy: C } = le(s, w);
|
|
134
137
|
if (!c) {
|
|
135
138
|
if (C) {
|
|
136
|
-
const a = (
|
|
139
|
+
const a = (qe = s.find(
|
|
137
140
|
(x) => x.context && C in x.context && !E(x.context[C], w[C])
|
|
138
|
-
)) == null ? void 0 :
|
|
139
|
-
await
|
|
141
|
+
)) == null ? void 0 : qe.context[C];
|
|
142
|
+
await W(e, re(C, a), t);
|
|
140
143
|
}
|
|
141
144
|
return [];
|
|
142
145
|
}
|
|
143
|
-
const V = K(e, r.rulesFor).reverse(),
|
|
144
|
-
...V.filter((a) => a in
|
|
145
|
-
...Object.keys(
|
|
146
|
-
],
|
|
147
|
-
for (const [a, x] of
|
|
148
|
-
E(o(a), x) ?
|
|
146
|
+
const V = K(e, r.rulesFor).reverse(), ze = [
|
|
147
|
+
...V.filter((a) => a in g),
|
|
148
|
+
...Object.keys(g).filter((a) => !V.includes(a))
|
|
149
|
+
], Z = [], j = () => {
|
|
150
|
+
for (const [a, x] of Z.reverse())
|
|
151
|
+
E(o(a), x) ? G(a, null, x) : h.current.delete(a);
|
|
149
152
|
};
|
|
150
|
-
for (const a of
|
|
151
|
-
const x =
|
|
153
|
+
for (const a of ze) {
|
|
154
|
+
const x = g[a], Te = r.layoutAllows(a) && !T.current.has(a) && (((De = r.canFill) == null ? void 0 : De.call(r, a)) ?? !0) ? await r.revalidate(a, x) : !1;
|
|
152
155
|
if (n()) return [];
|
|
153
|
-
if (
|
|
154
|
-
return
|
|
155
|
-
if (!
|
|
156
|
-
return
|
|
157
|
-
|
|
156
|
+
if (Te === null)
|
|
157
|
+
return j(), [];
|
|
158
|
+
if (!Te || !v(o(a)))
|
|
159
|
+
return j(), await W(e, re(a, x), t), [];
|
|
160
|
+
G(a, x), Z.push([a, x]);
|
|
158
161
|
}
|
|
159
|
-
const
|
|
162
|
+
const Ae = await r.revalidate(e, c.value);
|
|
160
163
|
if (n()) return [];
|
|
161
|
-
if (
|
|
162
|
-
return
|
|
163
|
-
if (!
|
|
164
|
-
return
|
|
164
|
+
if (Ae === null)
|
|
165
|
+
return j(), [];
|
|
166
|
+
if (!Ae)
|
|
167
|
+
return j(), await W(
|
|
165
168
|
e,
|
|
166
169
|
D(e, c.value).then(
|
|
167
170
|
(a) => a ? `Your default "${a}" is no longer available` : "Your saved default is no longer available"
|
|
168
171
|
),
|
|
169
172
|
t
|
|
170
173
|
), [];
|
|
171
|
-
if (!E(o(e), u) || !(((
|
|
172
|
-
return
|
|
173
|
-
const
|
|
174
|
-
return ((
|
|
174
|
+
if (!E(o(e), u) || !(((Ee = r.canFill) == null ? void 0 : Ee.call(r, e)) ?? !0))
|
|
175
|
+
return j(), [];
|
|
176
|
+
const Pe = le(s, O(R));
|
|
177
|
+
return ((Ne = Pe.pick) == null ? void 0 : Ne.id) !== c.id || Object.keys(Pe.fillParents).length > 0 ? (j(), "stale") : (G(e, c.value, y ? u : void 0), H.current.set(
|
|
175
178
|
e,
|
|
176
|
-
|
|
177
|
-
), [...
|
|
179
|
+
Z.map(([a]) => a)
|
|
180
|
+
), [...Z.map(([a]) => a), e]);
|
|
178
181
|
},
|
|
179
|
-
[o, O,
|
|
180
|
-
),
|
|
182
|
+
[o, O, W, re, D, G]
|
|
183
|
+
), pe = l(
|
|
181
184
|
async (e, t) => {
|
|
182
185
|
for (let r = 0; r < 3; r++) {
|
|
183
|
-
const n = await
|
|
186
|
+
const n = await ye(e, t);
|
|
184
187
|
if (n !== "stale") return n;
|
|
185
188
|
}
|
|
186
189
|
return [];
|
|
187
190
|
},
|
|
188
|
-
[
|
|
189
|
-
),
|
|
191
|
+
[ye]
|
|
192
|
+
), ne = l(
|
|
190
193
|
async (e) => {
|
|
191
194
|
var n, s;
|
|
192
|
-
const t =
|
|
195
|
+
const t = $.current, r = /* @__PURE__ */ new Set();
|
|
193
196
|
for (const u of e) {
|
|
194
|
-
if (!
|
|
195
|
-
for (const y of await
|
|
197
|
+
if (!J.current || $.current !== t) return;
|
|
198
|
+
for (const y of await pe(u, t)) r.add(y);
|
|
196
199
|
b();
|
|
197
200
|
}
|
|
198
|
-
if (
|
|
201
|
+
if ($.current === t) {
|
|
199
202
|
for (const u of r)
|
|
200
|
-
|
|
203
|
+
h.current.has(u) && ((s = (n = d.current).afterApply) == null || s.call(n, u, h.current.get(u)));
|
|
201
204
|
b();
|
|
202
205
|
}
|
|
203
206
|
},
|
|
204
|
-
[
|
|
205
|
-
),
|
|
207
|
+
[pe, b]
|
|
208
|
+
), se = l(() => {
|
|
206
209
|
const e = d.current;
|
|
207
|
-
return
|
|
208
|
-
[...
|
|
210
|
+
return Xe(
|
|
211
|
+
[...ee.current.keys()].filter((t) => e.layoutAllows(t)),
|
|
209
212
|
e.rulesFor
|
|
210
213
|
);
|
|
211
|
-
}, []),
|
|
214
|
+
}, []), ce = F(!1);
|
|
212
215
|
I(() => {
|
|
213
|
-
!
|
|
214
|
-
}, [
|
|
216
|
+
!S || N || !k || ce.current || q === void 0 || (ce.current = !0, ne(se()));
|
|
217
|
+
}, [S, N, k, q, ne, se]), I(() => {
|
|
215
218
|
let e = !1;
|
|
216
|
-
for (const [t, r] of
|
|
217
|
-
E(o(t), r) || (
|
|
218
|
-
for (const t of
|
|
219
|
-
v(o(t)) || (
|
|
219
|
+
for (const [t, r] of h.current)
|
|
220
|
+
E(o(t), r) || (h.current.delete(t), e = !0);
|
|
221
|
+
for (const t of A.current.keys())
|
|
222
|
+
v(o(t)) || (A.current.delete(t), e = !0);
|
|
220
223
|
e && b();
|
|
221
224
|
});
|
|
222
|
-
const
|
|
225
|
+
const z = F(/* @__PURE__ */ new Set()), B = F(/* @__PURE__ */ new Map()), [Le, Ye] = ae(0), $e = l(
|
|
223
226
|
(e) => {
|
|
224
|
-
let t =
|
|
225
|
-
if (
|
|
227
|
+
let t = h.current.delete(e);
|
|
228
|
+
if (A.current.delete(e) && (t = !0), T.current.delete(e), B.current.delete(e), !d.current.isNew) {
|
|
226
229
|
t && b();
|
|
227
230
|
return;
|
|
228
231
|
}
|
|
229
232
|
const r = d.current.rulesFor;
|
|
230
|
-
for (const [n, s] of [...
|
|
231
|
-
K(n, r).includes(e) && (
|
|
232
|
-
t && b(),
|
|
233
|
+
for (const [n, s] of [...h.current])
|
|
234
|
+
K(n, r).includes(e) && (B.current.set(n, s), h.current.delete(n), t = !0);
|
|
235
|
+
t && b(), z.current.add(e), Ye((n) => n + 1);
|
|
233
236
|
},
|
|
234
237
|
[b]
|
|
235
238
|
);
|
|
236
239
|
I(() => {
|
|
237
|
-
if (
|
|
238
|
-
const e = [...
|
|
240
|
+
if (z.current.size === 0 || d.current.disabled) return;
|
|
241
|
+
const e = [...z.current];
|
|
242
|
+
z.current.clear();
|
|
243
|
+
const t = new Map(B.current);
|
|
239
244
|
B.current.clear();
|
|
240
|
-
const t = new Map(H.current);
|
|
241
|
-
H.current.clear();
|
|
242
245
|
const r = d.current, n = [];
|
|
243
|
-
for (const s of
|
|
246
|
+
for (const s of se()) {
|
|
244
247
|
if (t.has(s)) {
|
|
245
|
-
const y = t.get(s),
|
|
246
|
-
if (E(
|
|
247
|
-
else if (!v(
|
|
248
|
+
const y = t.get(s), R = o(s);
|
|
249
|
+
if (E(R, y)) r.setFieldValue(s, null, y);
|
|
250
|
+
else if (!v(R)) continue;
|
|
248
251
|
n.push(s);
|
|
249
252
|
continue;
|
|
250
253
|
}
|
|
251
254
|
const u = K(s, r.rulesFor);
|
|
252
|
-
e.some((y) => u.includes(y)) &&
|
|
255
|
+
e.some((y) => u.includes(y)) && A.current.has(s) && v(o(s)) && (A.current.delete(s), n.push(s));
|
|
253
256
|
}
|
|
254
|
-
b(), n.length > 0 &&
|
|
255
|
-
}, [
|
|
256
|
-
const
|
|
257
|
+
b(), n.length > 0 && ne(n);
|
|
258
|
+
}, [Le]);
|
|
259
|
+
const oe = l(
|
|
257
260
|
(e) => {
|
|
258
|
-
var
|
|
259
|
-
const t = d.current, r =
|
|
261
|
+
var R;
|
|
262
|
+
const t = d.current, r = h.current;
|
|
260
263
|
if (!r.has(e)) return;
|
|
261
264
|
const n = (w) => K(w, t.rulesFor), s = /* @__PURE__ */ new Set([e]);
|
|
262
265
|
for (let w = !0; w; ) {
|
|
263
266
|
w = !1;
|
|
264
267
|
for (const c of r.keys())
|
|
265
|
-
s.has(c) || n(c).some((
|
|
268
|
+
s.has(c) || n(c).some((g) => s.has(g)) && (s.add(c), w = !0);
|
|
266
269
|
for (const c of [...s])
|
|
267
|
-
for (const
|
|
268
|
-
if (s.has(
|
|
270
|
+
for (const g of H.current.get(c) ?? []) {
|
|
271
|
+
if (s.has(g) || !r.has(g)) continue;
|
|
269
272
|
[...r.keys()].some(
|
|
270
|
-
(V) => V !==
|
|
271
|
-
) || (s.add(
|
|
273
|
+
(V) => V !== g && !s.has(V) && ((H.current.get(V) ?? []).includes(g) || n(V).includes(g))
|
|
274
|
+
) || (s.add(g), w = !0);
|
|
272
275
|
}
|
|
273
276
|
}
|
|
274
277
|
const u = (w) => n(w).length, y = [];
|
|
275
|
-
for (const w of [...s].sort((c,
|
|
278
|
+
for (const w of [...s].sort((c, g) => u(g) - u(c))) {
|
|
276
279
|
const c = r.get(w);
|
|
277
|
-
E(o(w), c) && (t.setFieldValue(w, null, c), y.push(w)), r.delete(w),
|
|
280
|
+
E(o(w), c) && (t.setFieldValue(w, null, c), y.push(w)), r.delete(w), H.current.delete(w), T.current.add(w);
|
|
278
281
|
}
|
|
279
|
-
y.length && ((
|
|
282
|
+
y.length && ((R = t.onUndone) == null || R.call(t, y)), b();
|
|
280
283
|
},
|
|
281
284
|
[o, b]
|
|
282
|
-
),
|
|
285
|
+
), je = l(
|
|
283
286
|
(e) => {
|
|
284
|
-
if (!
|
|
285
|
-
const t =
|
|
286
|
-
E(o(e), t) && d.current.setFieldValue(e, null, t),
|
|
287
|
+
if (!h.current.has(e)) return;
|
|
288
|
+
const t = h.current.get(e);
|
|
289
|
+
E(o(e), t) && d.current.setFieldValue(e, null, t), h.current.delete(e), T.current.add(e), b();
|
|
287
290
|
},
|
|
288
291
|
[o, b]
|
|
289
|
-
),
|
|
292
|
+
), X = `${f}|${S ? "new" : "saved"}|${i.resetKey ?? ""}`, we = F(X);
|
|
290
293
|
I(() => {
|
|
291
|
-
|
|
292
|
-
}, [
|
|
293
|
-
const
|
|
294
|
+
we.current !== X && (we.current = X, h.current.clear(), A.current.clear(), T.current.clear(), H.current.clear(), B.current.clear(), z.current.clear(), ce.current = !1, $.current += 1, b());
|
|
295
|
+
}, [X, b]);
|
|
296
|
+
const ue = l((e) => te.get(e) ?? null, [te]), Qe = l(() => h.current, []), P = l(
|
|
294
297
|
(e) => {
|
|
295
298
|
const t = U.get(e) ?? [];
|
|
296
299
|
if (t.length === 0) return null;
|
|
297
300
|
const r = new Set(t.flatMap((n) => Object.keys(n.context ?? {})));
|
|
298
|
-
return
|
|
301
|
+
return le(t, O(r)).pick;
|
|
299
302
|
},
|
|
300
303
|
[U, O]
|
|
301
|
-
),
|
|
304
|
+
), me = l(() => {
|
|
302
305
|
m.invalidateQueries({ queryKey: Q(f) });
|
|
303
|
-
}, [m, f]),
|
|
306
|
+
}, [m, f]), he = l(
|
|
304
307
|
(e) => !v(o(e)),
|
|
305
308
|
[o]
|
|
306
|
-
),
|
|
309
|
+
), ge = l(
|
|
307
310
|
(e) => {
|
|
308
311
|
var n, s;
|
|
309
312
|
const t = o(e);
|
|
310
313
|
if (v(t)) return !1;
|
|
311
|
-
const r =
|
|
314
|
+
const r = P(e);
|
|
312
315
|
return !!r && E(r.value, t, (s = (n = d.current).fieldType) == null ? void 0 : s.call(n, e));
|
|
313
316
|
},
|
|
314
|
-
[o,
|
|
315
|
-
),
|
|
317
|
+
[o, P]
|
|
318
|
+
), be = l(
|
|
316
319
|
async (e) => {
|
|
317
320
|
const t = d.current, r = [
|
|
318
321
|
...[...K(e, t.rulesFor)].reverse().filter((n) => t.layoutAllows(n) && !v(o(n))),
|
|
@@ -323,22 +326,22 @@ function dt(i) {
|
|
|
323
326
|
r.map(
|
|
324
327
|
async (n) => {
|
|
325
328
|
var s;
|
|
326
|
-
return await D(n, o(n)) ?? ((s = t.fieldLabel) == null ? void 0 : s.call(t, n)) ??
|
|
329
|
+
return await D(n, o(n)) ?? ((s = t.fieldLabel) == null ? void 0 : s.call(t, n)) ?? Ce(n);
|
|
327
330
|
}
|
|
328
331
|
)
|
|
329
332
|
);
|
|
330
333
|
},
|
|
331
334
|
[o, D]
|
|
332
|
-
),
|
|
335
|
+
), ve = l(
|
|
333
336
|
async (e) => {
|
|
334
337
|
const t = d.current, r = o(e);
|
|
335
338
|
if (v(r)) throw new Error("Pick a value first");
|
|
336
339
|
const n = K(e, t.rulesFor), s = O([e, ...n]), u = (y) => p.request(
|
|
337
|
-
|
|
340
|
+
ie("/field-defaults/mine", {
|
|
338
341
|
collection: f,
|
|
339
342
|
field: y,
|
|
340
|
-
value:
|
|
341
|
-
context:
|
|
343
|
+
value: L(s[y]),
|
|
344
|
+
context: Ze(y, s, t.rulesFor)
|
|
342
345
|
})
|
|
343
346
|
);
|
|
344
347
|
try {
|
|
@@ -350,18 +353,18 @@ function dt(i) {
|
|
|
350
353
|
}
|
|
351
354
|
},
|
|
352
355
|
[p, m, f, o, O]
|
|
353
|
-
),
|
|
356
|
+
), ke = l(
|
|
354
357
|
async (e) => {
|
|
355
|
-
const t =
|
|
358
|
+
const t = P(e);
|
|
356
359
|
if (!t) throw new Error("You have no default here to update");
|
|
357
360
|
const r = o(e);
|
|
358
361
|
if (v(r)) throw new Error("Pick a value first");
|
|
359
362
|
try {
|
|
360
363
|
await p.request(
|
|
361
|
-
|
|
364
|
+
ie("/field-defaults/mine", {
|
|
362
365
|
collection: f,
|
|
363
366
|
field: e,
|
|
364
|
-
value:
|
|
367
|
+
value: L(r),
|
|
365
368
|
context: t.context ?? {}
|
|
366
369
|
})
|
|
367
370
|
);
|
|
@@ -369,32 +372,32 @@ function dt(i) {
|
|
|
369
372
|
await m.invalidateQueries({ queryKey: Q(f) });
|
|
370
373
|
}
|
|
371
374
|
},
|
|
372
|
-
[p, m, f, o,
|
|
373
|
-
),
|
|
375
|
+
[p, m, f, o, P]
|
|
376
|
+
), Fe = l(
|
|
374
377
|
async (e) => {
|
|
375
|
-
const t = d.current, r =
|
|
378
|
+
const t = d.current, r = P(e), n = (r == null ? void 0 : r.context) ?? {}, s = [...K(e, t.rulesFor)].reverse(), u = [
|
|
376
379
|
...s.filter((c) => c in n),
|
|
377
380
|
...Object.keys(n).filter((c) => !s.includes(c))
|
|
378
381
|
], y = (c) => {
|
|
379
|
-
var
|
|
380
|
-
return ((
|
|
381
|
-
}, [
|
|
382
|
+
var g;
|
|
383
|
+
return ((g = t.fieldLabel) == null ? void 0 : g.call(t, c)) ?? Ce(c);
|
|
384
|
+
}, [R, ...w] = await Promise.all([
|
|
382
385
|
D(e, o(e)).then((c) => c ?? y(e)),
|
|
383
|
-
...u.map((c) => D(c, n[c]).then((
|
|
386
|
+
...u.map((c) => D(c, n[c]).then((g) => g ?? y(c)))
|
|
384
387
|
]);
|
|
385
|
-
return { value:
|
|
388
|
+
return { value: R, context: w };
|
|
386
389
|
},
|
|
387
|
-
[o,
|
|
388
|
-
),
|
|
390
|
+
[o, P, D]
|
|
391
|
+
), Se = l(
|
|
389
392
|
async (e) => {
|
|
390
|
-
const t =
|
|
391
|
-
return t ? (await p.request(
|
|
393
|
+
const t = P(e);
|
|
394
|
+
return t ? (await p.request(Ge(`/field-defaults/mine/${t.id}`)), h.current.delete(e) && (T.current.add(e), b()), await m.invalidateQueries({ queryKey: Q(f) }), t) : null;
|
|
392
395
|
},
|
|
393
|
-
[p, m, f,
|
|
394
|
-
),
|
|
396
|
+
[p, m, f, P, b]
|
|
397
|
+
), xe = l(
|
|
395
398
|
async (e) => {
|
|
396
399
|
await p.request(
|
|
397
|
-
|
|
400
|
+
ie("/field-defaults/mine", {
|
|
398
401
|
collection: f,
|
|
399
402
|
field: e.field,
|
|
400
403
|
value: e.value,
|
|
@@ -403,56 +406,56 @@ function dt(i) {
|
|
|
403
406
|
), await m.invalidateQueries({ queryKey: Q(f) });
|
|
404
407
|
},
|
|
405
408
|
[p, m, f]
|
|
406
|
-
),
|
|
409
|
+
), He = Oe(
|
|
407
410
|
() => ({
|
|
408
411
|
allowed: (e) => (d.current.enabled ?? !0) && d.current.layoutAllows(e),
|
|
409
412
|
manageable: (e) => {
|
|
410
413
|
var t, r;
|
|
411
414
|
return ((r = (t = d.current).layoutManage) == null ? void 0 : r.call(t, e)) ?? !0;
|
|
412
415
|
},
|
|
413
|
-
loaded:
|
|
414
|
-
failed:
|
|
415
|
-
isNew:
|
|
416
|
-
defaultFor:
|
|
417
|
-
isDefault:
|
|
418
|
-
save:
|
|
419
|
-
update:
|
|
420
|
-
describeUpdate:
|
|
421
|
-
clear:
|
|
422
|
-
restore:
|
|
423
|
-
refresh:
|
|
424
|
-
hasValue:
|
|
425
|
-
describeSave:
|
|
426
|
-
applied: (e) =>
|
|
427
|
-
hintFor:
|
|
428
|
-
undo:
|
|
416
|
+
loaded: q !== void 0 || Y,
|
|
417
|
+
failed: q === void 0 && Y,
|
|
418
|
+
isNew: S,
|
|
419
|
+
defaultFor: P,
|
|
420
|
+
isDefault: ge,
|
|
421
|
+
save: ve,
|
|
422
|
+
update: ke,
|
|
423
|
+
describeUpdate: Fe,
|
|
424
|
+
clear: Se,
|
|
425
|
+
restore: xe,
|
|
426
|
+
refresh: me,
|
|
427
|
+
hasValue: he,
|
|
428
|
+
describeSave: be,
|
|
429
|
+
applied: (e) => _.has(e),
|
|
430
|
+
hintFor: ue,
|
|
431
|
+
undo: oe
|
|
429
432
|
}),
|
|
430
433
|
[
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
me,
|
|
434
|
+
q,
|
|
435
|
+
Y,
|
|
436
|
+
S,
|
|
437
|
+
P,
|
|
436
438
|
ge,
|
|
437
|
-
be,
|
|
438
439
|
ve,
|
|
439
440
|
ke,
|
|
440
441
|
Fe,
|
|
441
|
-
|
|
442
|
-
|
|
442
|
+
Se,
|
|
443
|
+
xe,
|
|
444
|
+
me,
|
|
443
445
|
he,
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
446
|
+
be,
|
|
447
|
+
_,
|
|
448
|
+
ue,
|
|
449
|
+
oe
|
|
447
450
|
]
|
|
448
451
|
);
|
|
449
|
-
return { ledger:
|
|
452
|
+
return { ledger: _, hintFor: ue, undo: oe, onPersonChange: $e, release: je, appliedNow: Qe, context: He };
|
|
450
453
|
}
|
|
451
454
|
export {
|
|
452
|
-
|
|
453
|
-
|
|
455
|
+
et as PersonalDefaultsContext,
|
|
456
|
+
yt as linksBeyond,
|
|
454
457
|
Q as personalDefaultsKey,
|
|
455
458
|
E as sameDefaultValue,
|
|
456
|
-
|
|
457
|
-
|
|
459
|
+
pt as usePersonalDefaults,
|
|
460
|
+
dt as usePersonalDefaultsApi
|
|
458
461
|
};
|