@nivaro/react 0.3.57 → 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 (69) 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 +37 -2
  6. package/dist/index.js +523 -520
  7. package/dist/shared/components/CollectionBrowserView.js +2693 -2619
  8. package/dist/shared/components/DataTable.js +538 -495
  9. package/dist/shared/components/ItemEditForm.js +4559 -4386
  10. package/dist/shared/components/PageRenderer.js +537 -508
  11. package/dist/shared/components/ProfileView.js +716 -715
  12. package/dist/shared/components/QueryTable.js +74 -74
  13. package/dist/shared/components/RecordReadView.js +367 -364
  14. package/dist/shared/components/ReportView.js +64 -39
  15. package/dist/shared/components/WidgetSlot.js +543 -520
  16. package/dist/shared/components/alerts/AlertManagerView.js +324 -317
  17. package/dist/shared/components/alerts/types.js +37 -14
  18. package/dist/shared/components/cbv/row-focus.js +19 -0
  19. package/dist/shared/components/help-videos/HelpVideoPlayer.js +152 -147
  20. package/dist/shared/components/integrations/console/SignalCard.js +59 -59
  21. package/dist/shared/components/integrations/console/tone.js +52 -30
  22. package/dist/shared/components/item-edit/CatalogPickerField.js +525 -505
  23. package/dist/shared/components/item-edit/FieldRenderer.js +22 -20
  24. package/dist/shared/components/item-edit/FieldRow.js +175 -173
  25. package/dist/shared/components/item-edit/GridBulkEditDialog.js +55 -54
  26. package/dist/shared/components/item-edit/InlineTableField.js +2487 -2442
  27. package/dist/shared/components/item-edit/M2MCombobox.js +321 -295
  28. package/dist/shared/components/item-edit/MidairCollisionDialog.js +1 -1
  29. package/dist/shared/components/item-edit/PlanGrid.js +973 -894
  30. package/dist/shared/components/item-edit/QuickCreateButton.js +335 -106
  31. package/dist/shared/components/item-edit/RecordLiveSync.js +77 -75
  32. package/dist/shared/components/item-edit/RelationCombobox.js +452 -335
  33. package/dist/shared/components/item-edit/RelationGroupedCombobox.js +262 -141
  34. package/dist/shared/components/item-edit/SummaryPanel.js +385 -358
  35. package/dist/shared/components/item-edit/duplicate-rehearsal.js +47 -0
  36. package/dist/shared/components/item-edit/line-midair.js +82 -75
  37. package/dist/shared/components/item-edit/option-disambiguate.js +44 -32
  38. package/dist/shared/components/item-edit/related-missing.js +45 -0
  39. package/dist/shared/components/item-edit/save-outcome.js +9 -7
  40. package/dist/shared/components/notifications/NotificationRulesEditor.js +130 -123
  41. package/dist/shared/components/panels/AccessDeniedPanel.js +52 -48
  42. package/dist/shared/components/panels/ItemLockBanner.js +213 -211
  43. package/dist/shared/components/panels/PipelinePanel.js +1140 -1053
  44. package/dist/shared/components/panels/RecordIntegrityBanner.js +114 -86
  45. package/dist/shared/components/panels/RevisionsPanel.js +316 -299
  46. package/dist/shared/components/panels/TaskPanel.js +265 -249
  47. package/dist/shared/components/panels/landing-state.js +27 -0
  48. package/dist/shared/components/pipeline/PipelineEditorView.js +110 -92
  49. package/dist/shared/components/profile/AiMemoryCard.js +12 -10
  50. package/dist/shared/components/queue/OwnerAvatars.js +80 -41
  51. package/dist/shared/components/queue/QueueQuickFilters.js +52 -52
  52. package/dist/shared/components/queue/QueueWorklist.js +1050 -1026
  53. package/dist/shared/components/queue/group-sums.js +27 -0
  54. package/dist/shared/components/queue/live-state-aspect.js +9 -5
  55. package/dist/shared/components/widgets/ReviewListWidget.js +175 -154
  56. package/dist/shared/lib/back-closes.js +25 -0
  57. package/dist/shared/lib/display-prefs.js +60 -52
  58. package/dist/shared/lib/draft-store.js +71 -48
  59. package/dist/shared/lib/expression.js +53 -53
  60. package/dist/shared/lib/form-usage-beacon.js +7 -7
  61. package/dist/shared/lib/list-page-memory.js +63 -0
  62. package/dist/shared/lib/live.js +44 -44
  63. package/dist/shared/lib/money-input.js +45 -0
  64. package/dist/shared/lib/own-writes.js +76 -28
  65. package/dist/shared/lib/request-gate.js +110 -109
  66. package/dist/shared/lib/sanitize-html.js +10 -6
  67. package/dist/shared/lib/staged-row-labels.js +18 -0
  68. package/dist/shared/lib/validation-rules.js +34 -19
  69. package/package.json +1 -1
@@ -1,139 +1,368 @@
1
- import { jsxs as o, jsx as l } from "react/jsx-runtime";
2
- import { useQueryClient as S, useQuery as Q } from "@tanstack/react-query";
3
- import { Plus as _, Loader2 as E } from "lucide-react";
4
- import { useState as m } from "react";
5
- import { useNivaroClient as F, useParentDraft as K } from "../../context.js";
6
- import { get as P, post as z } from "../../lib/commands.js";
7
- import { userErrorMessage as A } from "../../lib/safe-error.js";
8
- import { cn as B, titleCase as p } from "../../lib/utils.js";
9
- function H({
10
- targetCollection: r,
11
- config: i,
12
- onCreated: c
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({
12
+ targetCollection: t,
13
+ config: d,
14
+ value: o,
15
+ onCreated: a
13
16
  }) {
14
- const a = F(), d = S(), x = K(), [h, b] = m(!1), [y, N] = m({}), [g, k] = m(!1), [w, u] = m(null), { data: f } = Q({
15
- queryKey: ["quick-create-m2m", r],
16
- queryFn: () => a.request(P(`/collections/${r}`)).then(
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({
18
+ queryKey: ["quick-create-m2m", t],
19
+ queryFn: () => u.request(U(`/collections/${t}`)).then(
17
20
  (e) => {
18
- var s;
21
+ var r;
19
22
  return new Set(
20
- (((s = e.data) == null ? void 0 : s.relations) ?? []).filter(
21
- (t) => t.one_collection === r && !!t.one_field && !!t.junction_field
22
- ).map((t) => String(t.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: h,
29
+ enabled: l,
27
30
  staleTime: 5 * 6e4
28
- }), v = (i.fields ?? []).filter((e) => e.from === void 0), q = (i.fields ?? []).filter((e) => e.from !== void 0), C = (e) => {
29
- var s;
30
- return typeof e == "string" && e.startsWith("$parent.") ? ((s = x == null ? void 0 : x.draft) == null ? void 0 : s[e.slice(8)]) ?? null : e;
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();
31
95
  };
32
- async function j() {
33
- var s;
34
- for (const t of v)
35
- if (t.required && !(y[t.field] ?? "").trim()) {
36
- u(`${t.label ?? p(t.field)} is required`);
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
+ );
37
119
  return;
38
120
  }
39
- k(!0), u(null);
40
- const e = {};
41
- for (const t of q) {
42
- const n = C(t.from);
43
- if (f != null && f.has(t.field)) {
44
- const $ = I(n);
45
- $.length > 0 && (e[t.field] = $);
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));
46
129
  continue;
47
130
  }
48
- n != null && n !== "" && (e[t.field] = n);
131
+ s != null && s !== "" && (e[i.field] = s, r[i.field] = I(s));
49
132
  }
50
- for (const t of v) {
51
- const n = (y[t.field] ?? "").trim();
52
- n !== "" && (e[t.field] = n);
133
+ for (const i of _) {
134
+ const s = (v[i.field] ?? "").trim();
135
+ s !== "" && (e[i.field] = s);
53
136
  }
54
137
  try {
55
- const n = (s = (await a.request(
56
- z(`/items/${r}`, e)
57
- )).data) == null ? void 0 : s.id;
58
- if (n == null) throw new Error("Created record returned no id");
59
- d.invalidateQueries({ queryKey: ["relation-opts", r] }), c(n), b(!1), N({});
60
- } catch (t) {
61
- u(A(t, "Create failed"));
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(
142
+ "Created, but it is outside what you can see, so it can't be selected here. Ask an administrator to check your access."
143
+ ), W({});
144
+ return;
145
+ }
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"));
62
149
  } finally {
63
- k(!1);
150
+ O(!1);
64
151
  }
65
152
  }
66
- return /* @__PURE__ */ o("div", { className: "relative shrink-0", children: [
67
- /* @__PURE__ */ o(
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(
68
156
  "button",
69
157
  {
158
+ ref: k,
70
159
  type: "button",
71
- title: i.title ?? `New ${p(r)}`,
160
+ title: d.title ?? `New ${g(t)}`,
161
+ "aria-expanded": l,
162
+ "aria-haspopup": "dialog",
72
163
  onClick: () => b((e) => !e),
73
- className: B(
74
- "inline-flex h-9 items-center gap-1 rounded-md border px-2.5 text-[12px] transition-colors",
75
- h ? "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"
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"
76
167
  ),
77
168
  children: [
78
- /* @__PURE__ */ l(_, { className: "h-3.5 w-3.5" }),
79
- i.label ?? "New"
169
+ /* @__PURE__ */ x(ne, { className: "h-3.5 w-3.5" }),
170
+ d.label ?? "New"
80
171
  ]
81
172
  }
82
173
  ),
83
- h && /* @__PURE__ */ o("div", { className: "absolute right-0 z-50 mt-1 w-72 rounded-md border border-border bg-background p-3 shadow-md", children: [
84
- /* @__PURE__ */ l("p", { className: "mb-2 text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: i.title ?? `New ${p(r)}` }),
85
- /* @__PURE__ */ l("div", { className: "flex flex-col gap-2", children: v.map((e) => /* @__PURE__ */ o("label", { className: "flex flex-col gap-1", children: [
86
- /* @__PURE__ */ o("span", { className: "text-[11px] text-slate-500", children: [
87
- e.label ?? p(e.field),
88
- e.required && /* @__PURE__ */ l("span", { className: "ml-0.5 text-red-500", children: "*" })
89
- ] }),
90
- /* @__PURE__ */ l(
91
- "input",
92
- {
93
- value: y[e.field] ?? "",
94
- onChange: (s) => N((t) => ({ ...t, [e.field]: s.target.value })),
95
- className: "h-8 rounded border border-input bg-background px-2 text-[13px] outline-none focus:border-nvr-cyan"
96
- }
97
- )
98
- ] }, e.field)) }),
99
- w && /* @__PURE__ */ l("p", { className: "mt-2 text-[11px] text-red-600 dark:text-red-400", children: w }),
100
- /* @__PURE__ */ o("div", { className: "mt-3 flex justify-end gap-2", children: [
101
- /* @__PURE__ */ l(
102
- "button",
103
- {
104
- type: "button",
105
- onClick: () => {
106
- b(!1), u(null);
107
- },
108
- className: "h-7 rounded px-2 text-[12px] text-slate-500 hover:text-slate-700",
109
- children: "Cancel"
110
- }
111
- ),
112
- /* @__PURE__ */ o(
113
- "button",
114
- {
115
- type: "button",
116
- disabled: g || q.length > 0 && !f,
117
- onClick: () => void j(),
118
- 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",
119
- children: [
120
- g && /* @__PURE__ */ l(E, { className: "h-3 w-3 animate-spin" }),
121
- "Create & select"
122
- ]
123
- }
124
- )
125
- ] })
126
- ] })
174
+ l && se(
175
+ /* @__PURE__ */ h(
176
+ "div",
177
+ {
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",
184
+ children: [
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
+ ] })
298
+ ]
299
+ }
300
+ ),
301
+ ce(k.current)
302
+ )
127
303
  ] });
128
304
  }
129
- function I(r) {
130
- const i = Array.isArray(r) ? r : [r], c = [];
131
- for (const a of i) {
132
- const d = a != null && typeof a == "object" ? a.id : a;
133
- (typeof d == "string" && d !== "" || typeof d == "number") && c.push(d);
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;
337
+ }
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) {
351
+ return t.length <= 1 ? t[0] ?? "" : `${t.slice(0, -1).join(", ")} and ${t[t.length - 1]}`;
352
+ }
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);
134
358
  }
135
- return c;
359
+ return o;
136
360
  }
137
361
  export {
138
- H as QuickCreateButton
362
+ $e as QuickCreateButton,
363
+ C as fieldLimit,
364
+ pe as missingRequiredSeeds,
365
+ fe as pendingOptionalSeeds,
366
+ me as seedFollowPatch,
367
+ I as seedKey
139
368
  };