@nivaro/react 0.3.52 → 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.
Files changed (34) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +47 -3
  4. package/dist/shared/components/ItemEditForm.js +3851 -3821
  5. package/dist/shared/components/NotificationBell.js +163 -150
  6. package/dist/shared/components/PageRenderer.js +600 -549
  7. package/dist/shared/components/ProfileView.js +36 -34
  8. package/dist/shared/components/QueryStatStrip.js +96 -89
  9. package/dist/shared/components/QueryTable.js +214 -215
  10. package/dist/shared/components/ReportView.js +548 -529
  11. package/dist/shared/components/alerts/AlertManagerView.js +346 -320
  12. package/dist/shared/components/item-edit/CatalogPickerField.js +1300 -1219
  13. package/dist/shared/components/item-edit/FieldAffordances.js +145 -136
  14. package/dist/shared/components/item-edit/FieldRenderer.js +366 -326
  15. package/dist/shared/components/item-edit/InlineTableField.js +3047 -2932
  16. package/dist/shared/components/item-edit/NestedRelationEditor.js +149 -143
  17. package/dist/shared/components/item-edit/PlanGrid.js +718 -705
  18. package/dist/shared/components/item-edit/SummaryPanel.js +351 -337
  19. package/dist/shared/components/item-edit/line-qty.js +115 -53
  20. package/dist/shared/components/item-edit/save-refusal.js +18 -18
  21. package/dist/shared/components/item-edit/usePersonalDefaults.js +210 -207
  22. package/dist/shared/components/panels/CommentPanel.js +204 -197
  23. package/dist/shared/components/panels/ItemLockBanner.js +318 -291
  24. package/dist/shared/components/panels/PipelinePanel.js +1388 -1218
  25. package/dist/shared/components/panels/RecordIntegrityBanner.js +201 -172
  26. package/dist/shared/components/panels/RevisionsPanel.js +101 -106
  27. package/dist/shared/components/panels/TransitionRequirementsDialog.js +564 -534
  28. package/dist/shared/components/panels/requirement-side-effects.js +46 -29
  29. package/dist/shared/components/queue/QueueItemSheet.js +219 -146
  30. package/dist/shared/components/queue/QueueWorklist.js +738 -730
  31. package/dist/shared/components/widgets/ReviewListWidget.js +236 -201
  32. package/dist/shared/lib/activity-sentence.js +236 -227
  33. package/dist/shared/lib/record-ref.js +43 -34
  34. package/package.json +1 -1
@@ -1,84 +1,87 @@
1
- import { useQueryClient as ze, useQuery as Be } from "@tanstack/react-query";
2
- import { useRef as S, useMemo as Ne, useState as ue, useEffect as I, useCallback as l, createContext as He, useContext as Ie } from "react";
3
- import { useNivaroClient as Ue } from "../../context.js";
4
- import { get as _e, put as ae, del as Je } from "../../lib/commands.js";
5
- import { isEmptyValue as v, pickDefault as ie, cascadeParents as K, orderTopDown as We, captureContext as Ge } from "../../lib/personal-defaults.js";
6
- import { titleCase as Te } from "../../lib/utils.js";
7
- const Xe = He(null);
8
- function lt() {
9
- return Ie(Xe);
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 Y(i) {
15
- return Array.isArray(i) ? i.map(Y) : i && typeof i == "object" && "id" in i ? i.id : i;
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 Ze = /* @__PURE__ */ new Set(["integer", "bigInteger", "float", "decimal", "number", "double"]), et = /* @__PURE__ */ new Set(["date"]), tt = /* @__PURE__ */ new Set(["dateTime", "datetime", "timestamp", "time"]);
18
- function E(i, f, 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 (F && !Array.isArray(i) && !Array.isArray(f) && !v(i) && !v(f)) {
21
- const M = Y(i), k = Y(f);
22
- if (Ze.has(F)) {
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 (et.has(F)) {
26
- const p = (R) => {
27
- var $;
28
- return ($ = /^(\d{4}-\d{2}-\d{2})/.exec(String(R))) == null ? void 0 : $[1];
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 (tt.has(F)) {
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 = Y(M);
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 ft(i, f) {
43
- let F = 0;
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)) || F++;
46
+ for (const p of M) k != null && k.has(String(p)) || S++;
47
47
  }
48
- return F;
48
+ return S;
49
49
  }
50
- function rt(i) {
50
+ function st(i) {
51
51
  return Array.isArray(i) ? i : v(i) ? [] : [i];
52
52
  }
53
- function dt(i) {
54
- const { collection: f, isNew: F, disabled: N, enabled: M = !0, ready: k = !0 } = i, p = Ue(), m = ze(), d = S(i);
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: R, isError: $ } = Be({
56
+ const { data: q, isError: Y } = Ie({
57
57
  queryKey: Q(f),
58
- queryFn: () => p.request(_e("/field-defaults/mine", { collection: f })).then((e) => e.data ?? []),
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 = Ne(() => {
61
+ }), U = Oe(() => {
62
62
  const e = /* @__PURE__ */ new Map();
63
- for (const t of R ?? []) {
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
- }, [R]), Z = S(U);
69
- Z.current = U;
70
- const g = S(/* @__PURE__ */ new Map()), [ee, Oe] = ue(() => /* @__PURE__ */ new Map()), q = S(/* @__PURE__ */ new Map()), [le, Ce] = ue(() => /* @__PURE__ */ new Map()), T = S(/* @__PURE__ */ new Set()), z = S(/* @__PURE__ */ new Map()), _ = S(!0);
71
- I(() => (_.current = !0, () => {
72
- _.current = !1;
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
- _.current && (Oe((e) => {
76
- const t = g.current;
77
- return e.size === t.size && [...t].every(([r, n]) => e.get(r) === n) ? e : new Map(t);
78
- }), Ce((e) => {
79
- const t = q.current;
80
- return e.size === t.size && [...t].every(([r, n]) => e.get(r) === n) ? e : new Map(t);
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
- rt(Y(t)).map(async (u) => {
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
- }, []), j = S(0), J = l(
108
+ }, []), $ = F(0), W = l(
106
109
  async (e, t, r) => {
107
110
  const n = await t;
108
- j.current === r && (q.current.set(e, n), b());
111
+ $.current === r && (A.current.set(e, n), b());
109
112
  },
110
113
  [b]
111
- ), te = l(
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
- ), W = l((e, t, r) => {
121
+ ), G = l((e, t, r) => {
119
122
  const n = d.current;
120
123
  if (n.setFieldValue(e, t, r), v(t)) {
121
- g.current.delete(e);
124
+ h.current.delete(e);
122
125
  return;
123
126
  }
124
- g.current.set(e, t), q.current.delete(e), n.markAutoFilled([e]);
125
- }, []), fe = l(
127
+ h.current.set(e, t), A.current.delete(e), n.markAutoFilled([e]);
128
+ }, []), ye = l(
126
129
  async (e, t) => {
127
- var Ae, Pe, Me, Re, qe, De;
128
- const r = d.current, n = () => j.current !== t, s = Z.current.get(e) ?? [];
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) || !(((Ae = r.canFill) == null ? void 0 : Ae.call(r, e)) ?? !0)) return [];
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 && !(((Pe = r.replaceable) == null ? void 0 : Pe.call(r, e, u)) ?? !1)) return [];
133
- const P = new Set(s.flatMap((a) => Object.keys(a.context ?? {}))), w = O(P), { pick: c, fillParents: h, blockedBy: C } = ie(s, w);
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 = (Me = s.find(
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 : Me.context[C];
139
- await J(e, te(C, a), t);
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(), Qe = [
144
- ...V.filter((a) => a in h),
145
- ...Object.keys(h).filter((a) => !V.includes(a))
146
- ], X = [], L = () => {
147
- for (const [a, x] of X.reverse())
148
- E(o(a), x) ? W(a, null, x) : g.current.delete(a);
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 Qe) {
151
- const x = h[a], Ee = r.layoutAllows(a) && !T.current.has(a) && (((Re = r.canFill) == null ? void 0 : Re.call(r, a)) ?? !0) ? await r.revalidate(a, x) : !1;
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 (Ee === null)
154
- return L(), [];
155
- if (!Ee || !v(o(a)))
156
- return L(), await J(e, te(a, x), t), [];
157
- W(a, x), X.push([a, x]);
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 Se = await r.revalidate(e, c.value);
162
+ const Ae = await r.revalidate(e, c.value);
160
163
  if (n()) return [];
161
- if (Se === null)
162
- return L(), [];
163
- if (!Se)
164
- return L(), await J(
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) || !(((qe = r.canFill) == null ? void 0 : qe.call(r, e)) ?? !0))
172
- return L(), [];
173
- const xe = ie(s, O(P));
174
- return ((De = xe.pick) == null ? void 0 : De.id) !== c.id || Object.keys(xe.fillParents).length > 0 ? (L(), "stale") : (W(e, c.value, y ? u : void 0), z.current.set(
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
- X.map(([a]) => a)
177
- ), [...X.map(([a]) => a), e]);
179
+ Z.map(([a]) => a)
180
+ ), [...Z.map(([a]) => a), e]);
178
181
  },
179
- [o, O, J, te, D, W]
180
- ), de = l(
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 fe(e, t);
186
+ const n = await ye(e, t);
184
187
  if (n !== "stale") return n;
185
188
  }
186
189
  return [];
187
190
  },
188
- [fe]
189
- ), re = l(
191
+ [ye]
192
+ ), ne = l(
190
193
  async (e) => {
191
194
  var n, s;
192
- const t = j.current, r = /* @__PURE__ */ new Set();
195
+ const t = $.current, r = /* @__PURE__ */ new Set();
193
196
  for (const u of e) {
194
- if (!_.current || j.current !== t) return;
195
- for (const y of await de(u, t)) r.add(y);
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 (j.current === t) {
201
+ if ($.current === t) {
199
202
  for (const u of r)
200
- g.current.has(u) && ((s = (n = d.current).afterApply) == null || s.call(n, u, g.current.get(u)));
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
- [de, b]
205
- ), ne = l(() => {
207
+ [pe, b]
208
+ ), se = l(() => {
206
209
  const e = d.current;
207
- return We(
208
- [...Z.current.keys()].filter((t) => e.layoutAllows(t)),
210
+ return Xe(
211
+ [...ee.current.keys()].filter((t) => e.layoutAllows(t)),
209
212
  e.rulesFor
210
213
  );
211
- }, []), se = S(!1);
214
+ }, []), ce = F(!1);
212
215
  I(() => {
213
- !F || N || !k || se.current || R === void 0 || (se.current = !0, re(ne()));
214
- }, [F, N, k, R, re, ne]), I(() => {
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 g.current)
217
- E(o(t), r) || (g.current.delete(t), e = !0);
218
- for (const t of q.current.keys())
219
- v(o(t)) || (q.current.delete(t), e = !0);
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 B = S(/* @__PURE__ */ new Set()), H = S(/* @__PURE__ */ new Map()), [Ve, Ke] = ue(0), Ye = l(
225
+ const z = F(/* @__PURE__ */ new Set()), B = F(/* @__PURE__ */ new Map()), [Le, Ye] = ae(0), $e = l(
223
226
  (e) => {
224
- let t = g.current.delete(e);
225
- if (q.current.delete(e) && (t = !0), T.current.delete(e), H.current.delete(e), !d.current.isNew) {
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 [...g.current])
231
- K(n, r).includes(e) && (H.current.set(n, s), g.current.delete(n), t = !0);
232
- t && b(), B.current.add(e), Ke((n) => n + 1);
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 (B.current.size === 0 || d.current.disabled) return;
238
- const e = [...B.current];
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 ne()) {
246
+ for (const s of se()) {
244
247
  if (t.has(s)) {
245
- const y = t.get(s), P = o(s);
246
- if (E(P, y)) r.setFieldValue(s, null, y);
247
- else if (!v(P)) continue;
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)) && q.current.has(s) && v(o(s)) && (q.current.delete(s), n.push(s));
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 && re(n);
255
- }, [Ve]);
256
- const ce = l(
257
+ b(), n.length > 0 && ne(n);
258
+ }, [Le]);
259
+ const oe = l(
257
260
  (e) => {
258
- var P;
259
- const t = d.current, r = g.current;
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((h) => s.has(h)) && (s.add(c), w = !0);
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 h of z.current.get(c) ?? []) {
268
- if (s.has(h) || !r.has(h)) continue;
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 !== h && !s.has(V) && ((z.current.get(V) ?? []).includes(h) || n(V).includes(h))
271
- ) || (s.add(h), w = !0);
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, h) => u(h) - u(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), z.current.delete(w), T.current.add(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 && ((P = t.onUndone) == null || P.call(t, y)), b();
282
+ y.length && ((R = t.onUndone) == null || R.call(t, y)), b();
280
283
  },
281
284
  [o, b]
282
- ), $e = l(
285
+ ), je = l(
283
286
  (e) => {
284
- if (!g.current.has(e)) return;
285
- const t = g.current.get(e);
286
- E(o(e), t) && d.current.setFieldValue(e, null, t), g.current.delete(e), T.current.add(e), b();
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
- ), G = `${f}|${F ? "new" : "saved"}|${i.resetKey ?? ""}`, ye = S(G);
292
+ ), X = `${f}|${S ? "new" : "saved"}|${i.resetKey ?? ""}`, we = F(X);
290
293
  I(() => {
291
- ye.current !== G && (ye.current = G, g.current.clear(), q.current.clear(), T.current.clear(), z.current.clear(), H.current.clear(), B.current.clear(), se.current = !1, j.current += 1, b());
292
- }, [G, b]);
293
- const oe = l((e) => le.get(e) ?? null, [le]), je = l(() => g.current, []), A = l(
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 ie(t, O(r)).pick;
301
+ return le(t, O(r)).pick;
299
302
  },
300
303
  [U, O]
301
- ), pe = l(() => {
304
+ ), me = l(() => {
302
305
  m.invalidateQueries({ queryKey: Q(f) });
303
- }, [m, f]), we = l(
306
+ }, [m, f]), he = l(
304
307
  (e) => !v(o(e)),
305
308
  [o]
306
- ), me = l(
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 = A(e);
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, A]
315
- ), he = l(
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)) ?? Te(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
- ), ge = l(
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
- ae("/field-defaults/mine", {
340
+ ie("/field-defaults/mine", {
338
341
  collection: f,
339
342
  field: y,
340
- value: Y(s[y]),
341
- context: Ge(y, s, t.rulesFor)
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
- ), be = l(
356
+ ), ke = l(
354
357
  async (e) => {
355
- const t = A(e);
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
- ae("/field-defaults/mine", {
364
+ ie("/field-defaults/mine", {
362
365
  collection: f,
363
366
  field: e,
364
- value: Y(r),
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, A]
373
- ), ve = l(
375
+ [p, m, f, o, P]
376
+ ), Fe = l(
374
377
  async (e) => {
375
- const t = d.current, r = A(e), n = (r == null ? void 0 : r.context) ?? {}, s = [...K(e, t.rulesFor)].reverse(), u = [
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 h;
380
- return ((h = t.fieldLabel) == null ? void 0 : h.call(t, c)) ?? Te(c);
381
- }, [P, ...w] = await Promise.all([
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((h) => h ?? y(c)))
386
+ ...u.map((c) => D(c, n[c]).then((g) => g ?? y(c)))
384
387
  ]);
385
- return { value: P, context: w };
388
+ return { value: R, context: w };
386
389
  },
387
- [o, A, D]
388
- ), ke = l(
390
+ [o, P, D]
391
+ ), Se = l(
389
392
  async (e) => {
390
- const t = A(e);
391
- return t ? (await p.request(Je(`/field-defaults/mine/${t.id}`)), g.current.delete(e) && (T.current.add(e), b()), await m.invalidateQueries({ queryKey: Q(f) }), t) : null;
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, A, b]
394
- ), Fe = l(
396
+ [p, m, f, P, b]
397
+ ), xe = l(
395
398
  async (e) => {
396
399
  await p.request(
397
- ae("/field-defaults/mine", {
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
- ), Le = Ne(
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: R !== void 0 || $,
414
- failed: R === void 0 && $,
415
- isNew: F,
416
- defaultFor: A,
417
- isDefault: me,
418
- save: ge,
419
- update: be,
420
- describeUpdate: ve,
421
- clear: ke,
422
- restore: Fe,
423
- refresh: pe,
424
- hasValue: we,
425
- describeSave: he,
426
- applied: (e) => ee.has(e),
427
- hintFor: oe,
428
- undo: ce
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
- R,
432
- $,
433
- F,
434
- A,
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
- pe,
442
- we,
442
+ Se,
443
+ xe,
444
+ me,
443
445
  he,
444
- ee,
445
- oe,
446
- ce
446
+ be,
447
+ _,
448
+ ue,
449
+ oe
447
450
  ]
448
451
  );
449
- return { ledger: ee, hintFor: oe, undo: ce, onPersonChange: Ye, release: $e, appliedNow: je, context: Le };
452
+ return { ledger: _, hintFor: ue, undo: oe, onPersonChange: $e, release: je, appliedNow: Qe, context: He };
450
453
  }
451
454
  export {
452
- Xe as PersonalDefaultsContext,
453
- ft as linksBeyond,
455
+ et as PersonalDefaultsContext,
456
+ yt as linksBeyond,
454
457
  Q as personalDefaultsKey,
455
458
  E as sameDefaultValue,
456
- dt as usePersonalDefaults,
457
- lt as usePersonalDefaultsApi
459
+ pt as usePersonalDefaults,
460
+ dt as usePersonalDefaultsApi
458
461
  };