@nivaro/react 0.3.58 → 0.3.59

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 (43) hide show
  1. package/dist/components/fields/RelationField.js +110 -80
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useRelationOptions.js +1 -0
  4. package/dist/hooks/useSessionRecorder.js +1 -1
  5. package/dist/index.d.ts +32 -1
  6. package/dist/index.js +523 -520
  7. package/dist/shared/components/CollectionBrowserView.js +2083 -2052
  8. package/dist/shared/components/DataTable.js +497 -465
  9. package/dist/shared/components/ItemEditForm.js +4430 -4282
  10. package/dist/shared/components/PageRenderer.js +537 -508
  11. package/dist/shared/components/QueryTable.js +74 -74
  12. package/dist/shared/components/WidgetSlot.js +543 -520
  13. package/dist/shared/components/alerts/AlertManagerView.js +269 -275
  14. package/dist/shared/components/alerts/types.js +37 -14
  15. package/dist/shared/components/item-edit/FieldRenderer.js +22 -20
  16. package/dist/shared/components/item-edit/GridBulkEditDialog.js +55 -54
  17. package/dist/shared/components/item-edit/InlineTableField.js +2461 -2421
  18. package/dist/shared/components/item-edit/M2MCombobox.js +141 -137
  19. package/dist/shared/components/item-edit/PlanGrid.js +876 -820
  20. package/dist/shared/components/item-edit/QuickCreateButton.js +323 -130
  21. package/dist/shared/components/item-edit/RelationCombobox.js +408 -375
  22. package/dist/shared/components/item-edit/RelationGroupedCombobox.js +255 -156
  23. package/dist/shared/components/item-edit/SummaryPanel.js +356 -343
  24. package/dist/shared/components/item-edit/duplicate-rehearsal.js +47 -0
  25. package/dist/shared/components/item-edit/line-midair.js +82 -75
  26. package/dist/shared/components/item-edit/save-outcome.js +6 -4
  27. package/dist/shared/components/panels/ItemLockBanner.js +212 -209
  28. package/dist/shared/components/panels/PipelinePanel.js +775 -737
  29. package/dist/shared/components/panels/RecordIntegrityBanner.js +114 -86
  30. package/dist/shared/components/panels/RevisionsPanel.js +313 -299
  31. package/dist/shared/components/pipeline/PipelineEditorView.js +26 -16
  32. package/dist/shared/components/queue/QueueQuickFilters.js +13 -13
  33. package/dist/shared/components/queue/QueueWorklist.js +978 -953
  34. package/dist/shared/components/queue/live-state-aspect.js +9 -5
  35. package/dist/shared/components/widgets/ReviewListWidget.js +152 -149
  36. package/dist/shared/lib/display-prefs.js +60 -52
  37. package/dist/shared/lib/draft-store.js +71 -48
  38. package/dist/shared/lib/expression.js +53 -53
  39. package/dist/shared/lib/list-page-memory.js +42 -20
  40. package/dist/shared/lib/money-input.js +45 -0
  41. package/dist/shared/lib/sanitize-html.js +10 -6
  42. package/dist/shared/lib/staged-row-labels.js +18 -0
  43. package/package.json +1 -1
@@ -1,175 +1,368 @@
1
- import { jsxs as d, jsx as c } from "react/jsx-runtime";
2
- import { useQueryClient as A, useQuery as P } from "@tanstack/react-query";
3
- import { Plus as Q, Loader2 as _ } from "lucide-react";
4
- import { useState as x } from "react";
5
- import { useNivaroClient as D, useParentDraft as F } from "../../context.js";
6
- import { get as K, post as W } from "../../lib/commands.js";
7
- import { userErrorMessage as L } from "../../lib/safe-error.js";
8
- import { cn as z, titleCase as m } from "../../lib/utils.js";
9
- function X({
1
+ import { jsxs as h, jsx as x } from "react/jsx-runtime";
2
+ import { useQueryClient as te, useQuery as J } from "@tanstack/react-query";
3
+ import { Plus as ne, Loader2 as re } from "lucide-react";
4
+ import { useState as K, useRef as F, useEffect as Q, useLayoutEffect as ie } from "react";
5
+ import { createPortal as se } from "react-dom";
6
+ import { useNivaroClient as oe, useParentDraft as ae } from "../../context.js";
7
+ import { get as U, patch as le, post as de } from "../../lib/commands.js";
8
+ import { userErrorMessage as ue } from "../../lib/safe-error.js";
9
+ import { titleCase as g, cn as H } from "../../lib/utils.js";
10
+ import { parseJson as V } from "./helpers.js";
11
+ function $e({
10
12
  targetCollection: t,
11
- config: l,
12
- onCreated: s
13
+ config: d,
14
+ value: o,
15
+ onCreated: a
13
16
  }) {
14
- const i = D(), u = A(), y = F(), [g, h] = x(!1), [v, k] = x({}), [w, $] = x(!1), [S, f] = x(null), { data: b } = P({
17
+ const u = oe(), p = te(), c = ae(), [l, b] = K(!1), [v, W] = K({}), [M, O] = K(!1), [T, w] = K(null), k = F(null), E = F(null), { data: N } = J({
15
18
  queryKey: ["quick-create-m2m", t],
16
- queryFn: () => i.request(K(`/collections/${t}`)).then(
19
+ queryFn: () => u.request(U(`/collections/${t}`)).then(
17
20
  (e) => {
18
- var n;
21
+ var r;
19
22
  return new Set(
20
- (((n = e.data) == null ? void 0 : n.relations) ?? []).filter(
21
- (o) => o.one_collection === t && !!o.one_field && !!o.junction_field
22
- ).map((o) => String(o.one_field))
23
+ (((r = e.data) == null ? void 0 : r.relations) ?? []).filter(
24
+ (n) => n.one_collection === t && !!n.one_field && !!n.junction_field
25
+ ).map((n) => String(n.one_field))
23
26
  );
24
27
  }
25
28
  ),
26
- enabled: g,
29
+ enabled: l,
27
30
  staleTime: 5 * 6e4
28
- }), N = (l.fields ?? []).filter((e) => e.from === void 0), q = (l.fields ?? []).filter((e) => e.from !== void 0), j = (e) => {
29
- var n;
30
- return typeof e == "string" && e.startsWith("$parent.") ? ((n = y == null ? void 0 : y.draft) == null ? void 0 : n[e.slice(8)]) ?? null : e;
31
- }, p = B(q, j);
32
- async function C() {
33
- var n, o;
34
- if (p.length > 0) return;
35
- for (const r of N)
36
- if (r.required && !(v[r.field] ?? "").trim()) {
37
- f(`${r.label ?? m(r.field)} is required`);
31
+ }), { data: q } = J({
32
+ queryKey: ["quick-create-fields", t],
33
+ queryFn: () => u.request(U(`/field-config/${t}`)).then((e) => Array.isArray(e.data) ? e.data : []).catch(() => []),
34
+ enabled: l,
35
+ staleTime: 5 * 6e4
36
+ }), _ = (d.fields ?? []).filter((e) => e.from === void 0), $ = (d.fields ?? []).filter((e) => e.from !== void 0), A = (e) => {
37
+ var r;
38
+ return typeof e == "string" && e.startsWith("$parent.") ? ((r = c == null ? void 0 : c.draft) == null ? void 0 : r[e.slice(8)]) ?? null : e;
39
+ }, S = pe($, A), L = fe($, A, c == null ? void 0 : c.fieldLabels), j = F(null), Z = JSON.stringify($.map((e) => A(e.from) ?? null));
40
+ Q(() => {
41
+ const e = j.current;
42
+ if (!e) return;
43
+ if (o == null || String(o) !== String(e.id)) {
44
+ o != null && o !== "" && (j.current = null);
45
+ return;
46
+ }
47
+ const r = me($, A, e.written, N);
48
+ if (!r) return;
49
+ const n = setTimeout(() => {
50
+ u.request(le(`/items/${t}/${e.id}`, r.patch)).then(() => {
51
+ var m;
52
+ ((m = j.current) == null ? void 0 : m.id) === e.id && (j.current = { id: e.id, written: { ...e.written, ...r.written } }), p.invalidateQueries({ queryKey: ["relation-avail", t] }), p.invalidateQueries({ queryKey: ["relation-opts", t] }), p.invalidateQueries({ queryKey: ["relation-single", t] });
53
+ }).catch(() => {
54
+ });
55
+ }, 500);
56
+ return () => clearTimeout(n);
57
+ }, [Z, o, N, t]);
58
+ const [R, z] = K(null);
59
+ ie(() => {
60
+ if (!l) {
61
+ z(null);
62
+ return;
63
+ }
64
+ const e = () => {
65
+ var y, P;
66
+ const r = (y = k.current) == null ? void 0 : y.getBoundingClientRect();
67
+ if (!r) return;
68
+ const n = Math.min(288, window.innerWidth - 16), m = Math.max(8, Math.min(r.right - n, window.innerWidth - n - 8)), f = window.innerHeight - r.bottom, i = ((P = E.current) == null ? void 0 : P.offsetHeight) ?? 260, s = f < i + 12 && r.top > f;
69
+ z({
70
+ position: "fixed",
71
+ left: m,
72
+ width: n,
73
+ zIndex: 120,
74
+ ...s ? { bottom: window.innerHeight - r.top + 4 } : { top: r.bottom + 4 }
75
+ });
76
+ };
77
+ return e(), window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
78
+ window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
79
+ };
80
+ }, [l]), Q(() => {
81
+ var e, r;
82
+ !l || !R || (r = (e = E.current) == null ? void 0 : e.querySelector("input")) == null || r.focus({ preventScroll: !0 });
83
+ }, [l, !!R]), Q(() => {
84
+ if (!l) return;
85
+ const e = (r) => {
86
+ var m, f;
87
+ const n = r.target;
88
+ (m = E.current) != null && m.contains(n) || (f = k.current) != null && f.contains(n) || (b(!1), w(null));
89
+ };
90
+ return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
91
+ }, [l]);
92
+ const ee = () => {
93
+ var e;
94
+ b(!1), w(null), (e = k.current) == null || e.focus();
95
+ };
96
+ Q(() => {
97
+ if (!l) return;
98
+ const e = (r) => {
99
+ var f, i, s;
100
+ if (r.key !== "Escape") return;
101
+ const n = document.activeElement;
102
+ (n === document.body || n && ((f = E.current) != null && f.contains(n) || (i = k.current) != null && i.contains(n))) && (r.preventDefault(), r.stopPropagation(), b(!1), w(null), (s = k.current) == null || s.focus());
103
+ };
104
+ return window.addEventListener("keydown", e, !0), () => window.removeEventListener("keydown", e, !0);
105
+ }, [l]);
106
+ async function B() {
107
+ var n, m, f;
108
+ if (S.length > 0) return;
109
+ for (const i of _) {
110
+ if (i.required && !(v[i.field] ?? "").trim()) {
111
+ w(`${i.label ?? g(i.field)} is required`);
112
+ return;
113
+ }
114
+ const s = C(q == null ? void 0 : q.find((P) => P.field === i.field)), y = (v[i.field] ?? "").trim().length;
115
+ if (s && !s.soft && y > s.max) {
116
+ w(
117
+ s.message ?? `${i.label ?? g(i.field)} takes at most ${s.max} characters`
118
+ );
38
119
  return;
39
120
  }
40
- $(!0), f(null);
41
- const e = {};
42
- for (const r of q) {
43
- const a = j(r.from);
44
- if (b != null && b.has(r.field)) {
45
- const E = M(a);
46
- E.length > 0 && (e[r.field] = E);
121
+ }
122
+ O(!0), w(null);
123
+ const e = {}, r = {};
124
+ for (const i of $) {
125
+ const s = A(i.from);
126
+ if (N != null && N.has(i.field)) {
127
+ const y = Y(s);
128
+ y.length > 0 && (e[i.field] = y, r[i.field] = I(y));
47
129
  continue;
48
130
  }
49
- a != null && a !== "" && (e[r.field] = a);
131
+ s != null && s !== "" && (e[i.field] = s, r[i.field] = I(s));
50
132
  }
51
- for (const r of N) {
52
- const a = (v[r.field] ?? "").trim();
53
- a !== "" && (e[r.field] = a);
133
+ for (const i of _) {
134
+ const s = (v[i.field] ?? "").trim();
135
+ s !== "" && (e[i.field] = s);
54
136
  }
55
137
  try {
56
- const r = await i.request(W(`/items/${t}`, e)), a = (n = r.data) == null ? void 0 : n.id;
57
- if (a == null) throw new Error("Created record returned no id");
58
- if (u.invalidateQueries({ queryKey: ["relation-opts", t] }), ((o = r.meta) == null ? void 0 : o.readable) === !1) {
59
- f(
138
+ const i = await u.request(de(`/items/${t}`, e)), s = (n = i.data) == null ? void 0 : n.id;
139
+ if (s == null) throw new Error("Created record returned no id");
140
+ if (p.invalidateQueries({ queryKey: ["relation-opts", t] }), ((m = i.meta) == null ? void 0 : m.readable) === !1) {
141
+ w(
60
142
  "Created, but it is outside what you can see, so it can't be selected here. Ask an administrator to check your access."
61
- ), k({});
143
+ ), W({});
62
144
  return;
63
145
  }
64
- s(a), h(!1), k({});
65
- } catch (r) {
66
- f(L(r, "Create failed"));
146
+ j.current = { id: s, written: r }, a(s), b(!1), W({}), (f = k.current) == null || f.focus();
147
+ } catch (i) {
148
+ w(ue(i, "Create failed"));
67
149
  } finally {
68
- $(!1);
150
+ O(!1);
69
151
  }
70
152
  }
71
- return /* @__PURE__ */ d("div", { className: "relative shrink-0", children: [
72
- /* @__PURE__ */ d(
153
+ const D = (d.label ?? g(t)).replace(/^New\s+/i, "").toLowerCase();
154
+ return /* @__PURE__ */ h("div", { className: "relative shrink-0", children: [
155
+ /* @__PURE__ */ h(
73
156
  "button",
74
157
  {
158
+ ref: k,
75
159
  type: "button",
76
- title: l.title ?? `New ${m(t)}`,
77
- onClick: () => h((e) => !e),
78
- className: z(
79
- "inline-flex h-9 items-center gap-1 rounded-md border px-2.5 text-[12px] transition-colors",
80
- g ? "border-nvr-cyan bg-nvr-cyan/10 text-nvr-cyan" : "border-input text-slate-600 hover:border-slate-400 hover:text-slate-800 dark:text-slate-300"
160
+ title: d.title ?? `New ${g(t)}`,
161
+ "aria-expanded": l,
162
+ "aria-haspopup": "dialog",
163
+ onClick: () => b((e) => !e),
164
+ className: H(
165
+ "inline-flex h-9 items-center gap-1 rounded-md border px-2.5 text-[12px] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/60",
166
+ l ? "border-nvr-cyan bg-nvr-cyan/10 text-nvr-cyan" : "border-input text-slate-600 hover:border-slate-400 hover:text-slate-800 dark:text-slate-300"
81
167
  ),
82
168
  children: [
83
- /* @__PURE__ */ c(Q, { className: "h-3.5 w-3.5" }),
84
- l.label ?? "New"
169
+ /* @__PURE__ */ x(ne, { className: "h-3.5 w-3.5" }),
170
+ d.label ?? "New"
85
171
  ]
86
172
  }
87
173
  ),
88
- g && /* @__PURE__ */ d("div", { className: "absolute right-0 z-50 mt-1 w-72 rounded-md border border-border bg-background p-3 shadow-md", children: [
89
- /* @__PURE__ */ c("p", { className: "mb-2 text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: l.title ?? `New ${m(t)}` }),
90
- p.length > 0 && /* @__PURE__ */ d(
91
- "p",
174
+ l && se(
175
+ /* @__PURE__ */ h(
176
+ "div",
92
177
  {
93
- "data-quick-create-missing": !0,
94
- className: "mb-2 rounded border border-amber-200 bg-amber-50 px-2 py-1.5 text-[11.5px] leading-snug text-amber-800 dark:border-amber-500/40 dark:bg-[#2a2113] dark:text-amber-300",
178
+ ref: E,
179
+ role: "dialog",
180
+ "aria-label": d.title ?? `New ${g(t)}`,
181
+ "data-quick-create-panel": "",
182
+ style: R ?? { position: "fixed", visibility: "hidden", top: 0, left: 0 },
183
+ className: "nvr-pop-in max-h-[80vh] overflow-y-auto rounded-md border border-border bg-background p-3 shadow-md",
95
184
  children: [
96
- "Pick ",
97
- I(p),
98
- " on the form first — the new",
99
- " ",
100
- (l.label ?? m(t)).replace(/^New\s+/i, "").toLowerCase(),
101
- " ",
102
- "takes ",
103
- p.length === 1 ? "it" : "them",
104
- " from there."
185
+ /* @__PURE__ */ x("p", { className: "mb-2 text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: d.title ?? `New ${g(t)}` }),
186
+ S.length > 0 && /* @__PURE__ */ h(
187
+ "p",
188
+ {
189
+ "data-quick-create-missing": !0,
190
+ className: "mb-2 rounded border border-amber-200 bg-amber-50 px-2 py-1.5 text-[11.5px] leading-snug text-amber-800 dark:border-amber-500/40 dark:bg-[#2a2113] dark:text-amber-300",
191
+ children: [
192
+ "Pick ",
193
+ G(S),
194
+ " on the form first — the new ",
195
+ D,
196
+ " takes",
197
+ " ",
198
+ S.length === 1 ? "it" : "them",
199
+ " from there."
200
+ ]
201
+ }
202
+ ),
203
+ S.length === 0 && L.length > 0 && /* @__PURE__ */ h(
204
+ "p",
205
+ {
206
+ "data-quick-create-later": !0,
207
+ className: "mb-2 text-[11.5px] leading-snug text-muted-foreground",
208
+ children: [
209
+ G(L),
210
+ " ",
211
+ L.length === 1 ? "is" : "are",
212
+ " not filled in yet — the new ",
213
+ D,
214
+ " picks ",
215
+ L.length === 1 ? "it" : "them",
216
+ " up from the form as you fill ",
217
+ L.length === 1 ? "it" : "them",
218
+ " in."
219
+ ]
220
+ }
221
+ ),
222
+ /* @__PURE__ */ x("div", { className: "flex flex-col gap-2", children: _.map((e) => {
223
+ const r = e.label ?? g(e.field), n = C(q == null ? void 0 : q.find((s) => s.field === e.field)), m = (v[e.field] ?? "").length, f = !!n && m > n.max, i = `qc-${e.field}-limit`;
224
+ return /* @__PURE__ */ h("label", { className: "flex flex-col gap-1", children: [
225
+ /* @__PURE__ */ h("span", { className: "flex items-baseline justify-between gap-2 text-[11px] text-slate-500 dark:text-slate-400", children: [
226
+ /* @__PURE__ */ h("span", { children: [
227
+ r,
228
+ e.required && /* @__PURE__ */ x("span", { className: "ml-0.5 text-red-500", children: "*" })
229
+ ] }),
230
+ n && m >= n.max * 0.6 && /* @__PURE__ */ h(
231
+ "span",
232
+ {
233
+ "data-quick-create-count": !0,
234
+ className: H(
235
+ "tabular-nums",
236
+ f ? "font-medium text-amber-700 dark:text-amber-300" : ""
237
+ ),
238
+ children: [
239
+ m,
240
+ "/",
241
+ n.max
242
+ ]
243
+ }
244
+ )
245
+ ] }),
246
+ /* @__PURE__ */ x(
247
+ "input",
248
+ {
249
+ value: v[e.field] ?? "",
250
+ "aria-invalid": f || void 0,
251
+ "aria-describedby": f ? i : void 0,
252
+ onChange: (s) => W((y) => ({ ...y, [e.field]: s.target.value })),
253
+ onKeyDown: (s) => {
254
+ s.key === "Enter" && (s.preventDefault(), B());
255
+ },
256
+ className: H(
257
+ "h-8 rounded border bg-background px-2 text-[13px] outline-none focus:border-nvr-cyan",
258
+ f ? "border-amber-400 dark:border-amber-500" : "border-input"
259
+ )
260
+ }
261
+ ),
262
+ f && /* @__PURE__ */ x(
263
+ "span",
264
+ {
265
+ id: i,
266
+ "data-quick-create-limit": !0,
267
+ className: "text-[11px] leading-snug text-amber-700 dark:text-amber-300",
268
+ children: (n == null ? void 0 : n.message) ?? `${r} takes at most ${n == null ? void 0 : n.max} characters.`
269
+ }
270
+ )
271
+ ] }, e.field);
272
+ }) }),
273
+ T && /* @__PURE__ */ x("p", { role: "alert", className: "mt-2 text-[11px] text-red-600 dark:text-red-400", children: T }),
274
+ /* @__PURE__ */ h("div", { className: "mt-3 flex justify-end gap-2", children: [
275
+ /* @__PURE__ */ x(
276
+ "button",
277
+ {
278
+ type: "button",
279
+ onClick: ee,
280
+ className: "h-7 rounded px-2 text-[12px] text-slate-500 hover:text-slate-700 dark:text-slate-400 dark:hover:text-slate-200",
281
+ children: "Cancel"
282
+ }
283
+ ),
284
+ /* @__PURE__ */ h(
285
+ "button",
286
+ {
287
+ type: "button",
288
+ disabled: M || S.length > 0 || $.length > 0 && !N,
289
+ onClick: () => void B(),
290
+ className: "inline-flex h-7 items-center gap-1 rounded bg-nvr-cyan px-2.5 text-[12px] font-medium text-white hover:brightness-110 disabled:opacity-50",
291
+ children: [
292
+ M && /* @__PURE__ */ x(re, { className: "h-3 w-3 animate-spin" }),
293
+ "Create & select"
294
+ ]
295
+ }
296
+ )
297
+ ] })
105
298
  ]
106
299
  }
107
300
  ),
108
- /* @__PURE__ */ c("div", { className: "flex flex-col gap-2", children: N.map((e) => /* @__PURE__ */ d("label", { className: "flex flex-col gap-1", children: [
109
- /* @__PURE__ */ d("span", { className: "text-[11px] text-slate-500", children: [
110
- e.label ?? m(e.field),
111
- e.required && /* @__PURE__ */ c("span", { className: "ml-0.5 text-red-500", children: "*" })
112
- ] }),
113
- /* @__PURE__ */ c(
114
- "input",
115
- {
116
- value: v[e.field] ?? "",
117
- onChange: (n) => k((o) => ({ ...o, [e.field]: n.target.value })),
118
- onKeyDown: (n) => {
119
- n.key === "Enter" ? (n.preventDefault(), C()) : n.key === "Escape" && (n.preventDefault(), n.stopPropagation(), h(!1), f(null));
120
- },
121
- className: "h-8 rounded border border-input bg-background px-2 text-[13px] outline-none focus:border-nvr-cyan"
122
- }
123
- )
124
- ] }, e.field)) }),
125
- S && /* @__PURE__ */ c("p", { className: "mt-2 text-[11px] text-red-600 dark:text-red-400", children: S }),
126
- /* @__PURE__ */ d("div", { className: "mt-3 flex justify-end gap-2", children: [
127
- /* @__PURE__ */ c(
128
- "button",
129
- {
130
- type: "button",
131
- onClick: () => {
132
- h(!1), f(null);
133
- },
134
- className: "h-7 rounded px-2 text-[12px] text-slate-500 hover:text-slate-700",
135
- children: "Cancel"
136
- }
137
- ),
138
- /* @__PURE__ */ d(
139
- "button",
140
- {
141
- type: "button",
142
- disabled: w || p.length > 0 || q.length > 0 && !b,
143
- onClick: () => void C(),
144
- className: "inline-flex h-7 items-center gap-1 rounded bg-nvr-cyan px-2.5 text-[12px] font-medium text-white hover:brightness-110 disabled:opacity-50",
145
- children: [
146
- w && /* @__PURE__ */ c(_, { className: "h-3 w-3 animate-spin" }),
147
- "Create & select"
148
- ]
149
- }
150
- )
151
- ] })
152
- ] })
301
+ ce(k.current)
302
+ )
153
303
  ] });
154
304
  }
155
- function B(t, l) {
156
- return t.filter((s) => s.required && typeof s.from == "string" && s.from.startsWith("$parent.")).filter((s) => {
157
- const i = l(s.from);
158
- return i == null || i === "" || Array.isArray(i) && i.length === 0;
159
- }).map((s) => s.label ?? m(String(s.from).slice(8)));
305
+ function ce(t) {
306
+ return (t == null ? void 0 : t.closest('[role="dialog"]')) ?? document.body;
307
+ }
308
+ function C(t) {
309
+ if (!t) return null;
310
+ const d = V(t.validation_rules), o = Array.isArray(d) ? d.find((l) => (l == null ? void 0 : l.type) === "max") : null, a = Number(o == null ? void 0 : o.value);
311
+ if (o && Number.isFinite(a) && a > 0)
312
+ return { max: a, soft: !!o.soft, message: o.message || void 0 };
313
+ const u = V(t.options), p = Number(u == null ? void 0 : u.max_length);
314
+ if (Number.isFinite(p) && p > 0) return { max: p, soft: !1 };
315
+ const c = Number(t.max_length);
316
+ return Number.isInteger(c) && c > 0 ? { max: c, soft: !1 } : null;
317
+ }
318
+ function fe(t, d, o) {
319
+ return t.filter((a) => !a.required && typeof a.from == "string" && a.from.startsWith("$parent.")).filter((a) => X(d(a.from))).map((a) => {
320
+ const u = String(a.from).slice(8);
321
+ return a.label ?? (o == null ? void 0 : o[u]) ?? g(u);
322
+ });
323
+ }
324
+ function me(t, d, o, a) {
325
+ if (!a) return null;
326
+ const u = {}, p = {};
327
+ for (const c of t) {
328
+ if (typeof c.from != "string" || !c.from.startsWith("$parent.")) continue;
329
+ const l = d(c.from);
330
+ if (X(l)) continue;
331
+ const b = a.has(c.field) ? Y(l) : l;
332
+ if (Array.isArray(b) && b.length === 0) continue;
333
+ const v = I(b);
334
+ o[c.field] !== v && (u[c.field] = b, p[c.field] = v);
335
+ }
336
+ return Object.keys(u).length ? { patch: u, written: p } : null;
160
337
  }
161
338
  function I(t) {
339
+ return Array.isArray(t) ? t.map((d) => String(d)).join(",") : String(t ?? "");
340
+ }
341
+ function X(t) {
342
+ return t == null || t === "" || Array.isArray(t) && t.length === 0;
343
+ }
344
+ function pe(t, d) {
345
+ return t.filter((o) => o.required && typeof o.from == "string" && o.from.startsWith("$parent.")).filter((o) => {
346
+ const a = d(o.from);
347
+ return a == null || a === "" || Array.isArray(a) && a.length === 0;
348
+ }).map((o) => o.label ?? g(String(o.from).slice(8)));
349
+ }
350
+ function G(t) {
162
351
  return t.length <= 1 ? t[0] ?? "" : `${t.slice(0, -1).join(", ")} and ${t[t.length - 1]}`;
163
352
  }
164
- function M(t) {
165
- const l = Array.isArray(t) ? t : [t], s = [];
166
- for (const i of l) {
167
- const u = i != null && typeof i == "object" ? i.id : i;
168
- (typeof u == "string" && u !== "" || typeof u == "number") && s.push(u);
353
+ function Y(t) {
354
+ const d = Array.isArray(t) ? t : [t], o = [];
355
+ for (const a of d) {
356
+ const u = a != null && typeof a == "object" ? a.id : a;
357
+ (typeof u == "string" && u !== "" || typeof u == "number") && o.push(u);
169
358
  }
170
- return s;
359
+ return o;
171
360
  }
172
361
  export {
173
- X as QuickCreateButton,
174
- B as missingRequiredSeeds
362
+ $e as QuickCreateButton,
363
+ C as fieldLimit,
364
+ pe as missingRequiredSeeds,
365
+ fe as pendingOptionalSeeds,
366
+ me as seedFollowPatch,
367
+ I as seedKey
175
368
  };