@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.
Files changed (41) 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 +4196 -4163
  5. package/dist/shared/components/NotificationBell.js +163 -150
  6. package/dist/shared/components/PageRenderer.js +645 -593
  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/DraftRecoveryBanner.js +52 -54
  14. package/dist/shared/components/item-edit/FieldAffordances.js +145 -136
  15. package/dist/shared/components/item-edit/FieldRenderer.js +366 -326
  16. package/dist/shared/components/item-edit/InlineTableField.js +3047 -2932
  17. package/dist/shared/components/item-edit/NestedRelationEditor.js +149 -143
  18. package/dist/shared/components/item-edit/PersonalDefaultControl.js +12 -11
  19. package/dist/shared/components/item-edit/PlanGrid.js +718 -705
  20. package/dist/shared/components/item-edit/RelationCombobox.js +23 -20
  21. package/dist/shared/components/item-edit/SummaryPanel.js +415 -361
  22. package/dist/shared/components/item-edit/line-qty.js +115 -53
  23. package/dist/shared/components/item-edit/save-outcome.js +48 -0
  24. package/dist/shared/components/item-edit/save-refusal.js +18 -18
  25. package/dist/shared/components/item-edit/stale-banner.js +13 -0
  26. package/dist/shared/components/item-edit/usePersonalDefaults.js +225 -220
  27. package/dist/shared/components/panels/CommentPanel.js +204 -197
  28. package/dist/shared/components/panels/ItemLockBanner.js +318 -291
  29. package/dist/shared/components/panels/PipelinePanel.js +1388 -1218
  30. package/dist/shared/components/panels/RecordIntegrityBanner.js +201 -172
  31. package/dist/shared/components/panels/RevisionsPanel.js +101 -106
  32. package/dist/shared/components/panels/TransitionRequirementsDialog.js +564 -534
  33. package/dist/shared/components/panels/requirement-side-effects.js +46 -29
  34. package/dist/shared/components/queue/QueueItemSheet.js +219 -146
  35. package/dist/shared/components/queue/QueueWorklist.js +738 -730
  36. package/dist/shared/components/widgets/ReviewListWidget.js +236 -201
  37. package/dist/shared/lib/activity-sentence.js +236 -227
  38. package/dist/shared/lib/draft-store.js +35 -29
  39. package/dist/shared/lib/page-widget-access.js +11 -0
  40. package/dist/shared/lib/record-ref.js +43 -34
  41. 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 Ie, useQuery as Ue } from "@tanstack/react-query";
2
+ import { useRef as S, useMemo as Ce, useState as ae, useEffect as I, useCallback as l, createContext as _e, useContext as Je } from "react";
3
+ import { useNivaroClient as We } from "../../context.js";
4
+ import { get as Ge, put as ie, del as Xe } from "../../lib/commands.js";
5
+ import { isEmptyValue as v, pickDefault as le, cascadeParents as K, orderTopDown as Ze, captureContext as et } from "../../lib/personal-defaults.js";
6
+ import { titleCase as Ve } from "../../lib/utils.js";
7
+ const tt = _e(null);
8
+ function yt() {
9
+ return Je(tt);
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 rt = /* @__PURE__ */ new Set(["integer", "bigInteger", "float", "decimal", "number", "double"]), nt = /* @__PURE__ */ new Set(["date"]), st = /* @__PURE__ */ new Set(["dateTime", "datetime", "timestamp", "time"]);
18
+ function N(i, f, F) {
19
19
  if (v(i) && v(f)) return !0;
20
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)) {
23
- const p = Number(M), m = Number(k);
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];
29
- }, m = p(M), d = p(k);
30
- if (m && d) return m === d;
31
- } else if (tt.has(F)) {
32
- const p = Date.parse(String(M)), m = Date.parse(String(k));
33
- if (Number.isFinite(p) && Number.isFinite(m)) return p === m;
21
+ const M = L(i), k = L(f);
22
+ if (rt.has(F)) {
23
+ const p = Number(M), h = Number(k);
24
+ if (Number.isFinite(p) && Number.isFinite(h)) return p === h;
25
+ } else if (nt.has(F)) {
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
+ }, h = p(M), d = p(k);
30
+ if (h && d) return h === d;
31
+ } else if (st.has(F)) {
32
+ const p = Date.parse(String(M)), h = Date.parse(String(k));
33
+ if (Number.isFinite(p) && Number.isFinite(h)) return p === h;
34
34
  }
35
35
  }
36
- const N = (M) => {
37
- const k = Y(M);
36
+ const E = (M) => {
37
+ const k = L(M);
38
38
  return Array.isArray(k) ? k.map((p) => String(p)).sort() : String(k);
39
39
  };
40
- return JSON.stringify(N(i)) === JSON.stringify(N(f));
40
+ return JSON.stringify(E(i)) === JSON.stringify(E(f));
41
41
  }
42
- function ft(i, f) {
42
+ function pt(i, f) {
43
43
  let F = 0;
44
- for (const [N, M] of i) {
45
- const k = f.get(N);
44
+ for (const [E, M] of i) {
45
+ const k = f.get(E);
46
46
  for (const p of M) k != null && k.has(String(p)) || F++;
47
47
  }
48
48
  return F;
49
49
  }
50
- function rt(i) {
50
+ function ct(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 wt(i) {
54
+ const { collection: f, isNew: F, disabled: E, enabled: M = !0, ready: k = !0 } = i, p = We(), h = Ie(), d = S(i);
55
55
  d.current = i;
56
- const { data: R, isError: $ } = Be({
56
+ const { data: q, isError: Y } = Ue({
57
57
  queryKey: Q(f),
58
- queryFn: () => p.request(_e("/field-defaults/mine", { collection: f })).then((e) => e.data ?? []),
58
+ queryFn: () => p.request(Ge("/field-defaults/mine", { collection: f })).then((e) => e.data ?? []),
59
59
  staleTime: 5 * 6e4,
60
60
  enabled: !!f && M
61
- }), U = Ne(() => {
61
+ }), U = Ce(() => {
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 = S(U);
69
+ ee.current = U;
70
+ const m = S(/* @__PURE__ */ new Map()), [_, Ke] = ae(() => /* @__PURE__ */ new Map()), A = S(/* @__PURE__ */ new Map()), [te, Le] = ae(() => /* @__PURE__ */ new Map()), T = S(/* @__PURE__ */ new Set()), H = S(/* @__PURE__ */ new Map()), J = S(!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 = S(_), de = S(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, m.current)) {
78
+ const t = new Map(m.current);
79
+ fe.current = t, Ke(t);
80
+ }
81
+ if (!e(de.current, A.current)) {
82
+ const t = new Map(A.current);
83
+ de.current = t, Le(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
+ ct(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
+ }, []), $ = S(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
+ m.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
+ m.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 Me, qe, De, Ee, Ne, Te;
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) || !(((Me = r.canFill) == null ? void 0 : Me.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 && !(((qe = r.replaceable) == null ? void 0 : qe.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(
137
- (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);
139
+ const a = (De = s.find(
140
+ (x) => x.context && C in x.context && !N(x.context[C], w[C])
141
+ )) == null ? void 0 : De.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(), Be = [
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
+ N(o(a), x) ? G(a, null, x) : m.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 Be) {
154
+ const x = g[a], Oe = r.layoutAllows(a) && !T.current.has(a) && (((Ee = r.canFill) == null ? void 0 : Ee.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 (Oe === null)
157
+ return j(), [];
158
+ if (!Oe || !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 Pe = 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 (Pe === null)
165
+ return j(), [];
166
+ if (!Pe)
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 (!N(o(e), u) || !(((Ne = r.canFill) == null ? void 0 : Ne.call(r, e)) ?? !0))
175
+ return j(), [];
176
+ const Re = le(s, O(R));
177
+ return ((Te = Re.pick) == null ? void 0 : Te.id) !== c.id || Object.keys(Re.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
+ m.current.has(u) && ((s = (n = d.current).afterApply) == null || s.call(n, u, m.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 Ze(
211
+ [...ee.current.keys()].filter((t) => e.layoutAllows(t)),
209
212
  e.rulesFor
210
213
  );
211
- }, []), se = S(!1);
214
+ }, []), ce = S(!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
+ !F || E || !k || ce.current || q === void 0 || (ce.current = !0, ne(se()));
217
+ }, [F, E, 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 m.current)
220
+ N(o(t), r) || (m.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 = S(/* @__PURE__ */ new Set()), B = S(/* @__PURE__ */ new Map()), [Ye, $e] = ae(0), je = 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 = m.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 [...m.current])
234
+ K(n, r).includes(e) && (B.current.set(n, s), m.current.delete(n), t = !0);
235
+ t && b(), z.current.add(e), $e((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 (N(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
+ }, [Ye]);
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 = m.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
+ N(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
+ ), Qe = 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 (!m.current.has(e)) return;
288
+ const t = m.current.get(e);
289
+ N(o(e), t) && d.current.setFieldValue(e, null, t), m.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}|${F ? "new" : "saved"}|${i.resetKey ?? ""}`, we = S(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, m.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]), He = l(() => m.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(() => {
302
- m.invalidateQueries({ queryKey: Q(f) });
303
- }, [m, f]), we = l(
304
+ ), he = l(() => {
305
+ h.invalidateQueries({ queryKey: Q(f) });
306
+ }, [h, f]), me = 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);
312
- return !!r && E(r.value, t, (s = (n = d.current).fieldType) == null ? void 0 : s.call(n, e));
314
+ const r = P(e);
315
+ return !!r && N(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)) ?? Ve(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: et(y, s, t.rulesFor)
342
345
  })
343
346
  );
344
347
  try {
@@ -346,113 +349,115 @@ function dt(i) {
346
349
  for (const y of [...n].reverse())
347
350
  t.layoutAllows(y) && !v(s[y]) && await u(y);
348
351
  } finally {
349
- await m.invalidateQueries({ queryKey: Q(f) });
352
+ await h.invalidateQueries({ queryKey: Q(f) });
350
353
  }
351
354
  },
352
- [p, m, f, o, O]
353
- ), be = l(
355
+ [p, h, f, o, O]
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
  );
368
371
  } finally {
369
- await m.invalidateQueries({ queryKey: Q(f) });
372
+ await h.invalidateQueries({ queryKey: Q(f) });
370
373
  }
371
374
  },
372
- [p, m, f, o, A]
373
- ), ve = l(
375
+ [p, h, 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)) ?? Ve(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(Xe(`/field-defaults/mine/${t.id}`)), m.current.delete(e) && (T.current.add(e), b()), await h.invalidateQueries({ queryKey: Q(f) }), t) : null;
392
395
  },
393
- [p, m, f, A, b]
394
- ), Fe = l(
396
+ [p, h, 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,
401
404
  context: e.context ?? {}
402
405
  })
403
- ), await m.invalidateQueries({ queryKey: Q(f) });
406
+ ), await h.invalidateQueries({ queryKey: Q(f) });
404
407
  },
405
- [p, m, f]
406
- ), Le = Ne(
408
+ [p, h, f]
409
+ ), Ae = F && !E && !k, ze = Ce(
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 && $,
416
+ loaded: q !== void 0 || Y,
417
+ failed: q === void 0 && Y,
415
418
  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
419
+ held: Ae,
420
+ defaultFor: P,
421
+ isDefault: ge,
422
+ save: ve,
423
+ update: ke,
424
+ describeUpdate: Fe,
425
+ clear: Se,
426
+ restore: xe,
427
+ refresh: he,
428
+ hasValue: me,
429
+ describeSave: be,
430
+ applied: (e) => _.has(e),
431
+ hintFor: ue,
432
+ undo: oe
429
433
  }),
430
434
  [
431
- R,
432
- $,
435
+ q,
436
+ Y,
433
437
  F,
434
- A,
435
- me,
438
+ Ae,
439
+ P,
436
440
  ge,
437
- be,
438
441
  ve,
439
442
  ke,
440
443
  Fe,
441
- pe,
442
- we,
444
+ Se,
445
+ xe,
443
446
  he,
444
- ee,
445
- oe,
446
- ce
447
+ me,
448
+ be,
449
+ _,
450
+ ue,
451
+ oe
447
452
  ]
448
453
  );
449
- return { ledger: ee, hintFor: oe, undo: ce, onPersonChange: Ye, release: $e, appliedNow: je, context: Le };
454
+ return { ledger: _, hintFor: ue, undo: oe, onPersonChange: je, release: Qe, appliedNow: He, context: ze };
450
455
  }
451
456
  export {
452
- Xe as PersonalDefaultsContext,
453
- ft as linksBeyond,
457
+ tt as PersonalDefaultsContext,
458
+ pt as linksBeyond,
454
459
  Q as personalDefaultsKey,
455
- E as sameDefaultValue,
456
- dt as usePersonalDefaults,
457
- lt as usePersonalDefaultsApi
460
+ N as sameDefaultValue,
461
+ wt as usePersonalDefaults,
462
+ yt as usePersonalDefaultsApi
458
463
  };