@nivaro/react 0.3.64 → 0.3.66

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 (74) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +62 -8
  4. package/dist/shared/components/CollectionBrowserView.js +3127 -3204
  5. package/dist/shared/components/ConformanceView.js +235 -221
  6. package/dist/shared/components/DataTable.js +478 -459
  7. package/dist/shared/components/ItemEditForm.js +4842 -4500
  8. package/dist/shared/components/MyWorkView.js +124 -113
  9. package/dist/shared/components/PageRenderer.js +146 -138
  10. package/dist/shared/components/ProfileView.js +483 -472
  11. package/dist/shared/components/RecordDrilldownSheet.js +73 -65
  12. package/dist/shared/components/ReportView.js +1100 -1094
  13. package/dist/shared/components/bulk/BulkActionButtons.js +72 -72
  14. package/dist/shared/components/bulk/BulkCompareButton.js +62 -0
  15. package/dist/shared/components/bulk/BulkFieldUpdate.js +114 -103
  16. package/dist/shared/components/bulk/BulkFieldUpdateButton.js +73 -0
  17. package/dist/shared/components/bulk/MessageStakeholders.js +235 -0
  18. package/dist/shared/components/bulk/bulk-field-options.js +29 -23
  19. package/dist/shared/components/integrations/IntegrationObligationsView.js +191 -173
  20. package/dist/shared/components/integrations/IntegrationStatusLines.js +101 -85
  21. package/dist/shared/components/integrations/RecordIntegrationPreview.js +11 -9
  22. package/dist/shared/components/integrations/SendCurrentData.js +126 -0
  23. package/dist/shared/components/item-edit/CatalogPickerField.js +1535 -1440
  24. package/dist/shared/components/item-edit/FieldRenderer.js +49 -45
  25. package/dist/shared/components/item-edit/FieldRow.js +413 -403
  26. package/dist/shared/components/item-edit/GroupSection.js +555 -538
  27. package/dist/shared/components/item-edit/InlineTableField.js +2903 -2816
  28. package/dist/shared/components/item-edit/M2MCombobox.js +407 -338
  29. package/dist/shared/components/item-edit/MidairCollisionDialog.js +367 -116
  30. package/dist/shared/components/item-edit/NestedRelationEditor.js +171 -163
  31. package/dist/shared/components/item-edit/PlanGrid.js +783 -724
  32. package/dist/shared/components/item-edit/QuickCreateButton.js +291 -224
  33. package/dist/shared/components/item-edit/RecordInsights.js +113 -111
  34. package/dist/shared/components/item-edit/RecordLiveSync.js +4 -1
  35. package/dist/shared/components/item-edit/RelationCombobox.js +398 -364
  36. package/dist/shared/components/item-edit/SummaryPanel.js +146 -144
  37. package/dist/shared/components/item-edit/UserChip.js +264 -229
  38. package/dist/shared/components/item-edit/cascade-clear-notice.js +56 -0
  39. package/dist/shared/components/item-edit/collision-format.js +37 -0
  40. package/dist/shared/components/item-edit/field-a11y.js +25 -0
  41. package/dist/shared/components/item-edit/header-path-preview.js +52 -0
  42. package/dist/shared/components/item-edit/line-merge.js +84 -0
  43. package/dist/shared/components/item-edit/line-midair.js +94 -87
  44. package/dist/shared/components/item-edit/move-guard.js +17 -0
  45. package/dist/shared/components/item-edit/picker-search.js +27 -16
  46. package/dist/shared/components/item-edit/rail-width.js +8 -0
  47. package/dist/shared/components/monitoring/InactiveUserLinksView.js +126 -124
  48. package/dist/shared/components/panels/AccessDeniedPanel.js +96 -55
  49. package/dist/shared/components/panels/CommentPanel.js +142 -136
  50. package/dist/shared/components/panels/ItemLockBanner.js +246 -240
  51. package/dist/shared/components/panels/PipelinePanel.js +1366 -1194
  52. package/dist/shared/components/panels/RevisionsPanel.js +106 -102
  53. package/dist/shared/components/panels/SlaBreachBanner.js +16 -20
  54. package/dist/shared/components/panels/SlaClock.js +90 -68
  55. package/dist/shared/components/queue/QueueItemSheet.js +94 -87
  56. package/dist/shared/components/queue/QueueWorklist.js +1522 -1347
  57. package/dist/shared/components/queue/worklist-csv.js +75 -0
  58. package/dist/shared/components/queue/worklist-helpers.js +20 -0
  59. package/dist/shared/components/widgets/ReviewListWidget.js +226 -207
  60. package/dist/shared/lib/bulk-copy.js +17 -0
  61. package/dist/shared/lib/cbv-export.js +122 -0
  62. package/dist/shared/lib/delete-offer.js +13 -0
  63. package/dist/shared/lib/error-hints.js +1 -0
  64. package/dist/shared/lib/leave-guard.js +41 -26
  65. package/dist/shared/lib/list-link.js +72 -56
  66. package/dist/shared/lib/live-queries.js +32 -30
  67. package/dist/shared/lib/moved-notice.js +25 -0
  68. package/dist/shared/lib/notification-target.js +56 -54
  69. package/dist/shared/lib/obligation-banner.js +11 -8
  70. package/dist/shared/lib/obligation-reason-text.js +6 -6
  71. package/dist/shared/lib/quick-filter-cascade.js +29 -19
  72. package/dist/shared/lib/sort-cycle.js +6 -0
  73. package/dist/shared/lib/summary-mode.js +59 -41
  74. package/package.json +1 -1
@@ -1,295 +1,303 @@
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
1
+ import { jsxs as b, jsx as v } from "react/jsx-runtime";
2
+ import { useQueryClient as oe, useQuery as G } from "@tanstack/react-query";
3
+ import { Plus as se, Loader2 as le } from "lucide-react";
4
+ import { useEffect as K, useState as S, useRef as P, useLayoutEffect as ae } from "react";
5
+ import { createPortal as ue } from "react-dom";
6
+ import { useNivaroClient as de, useParentDraft as ce } from "../../context.js";
7
+ import { get as X, patch as fe, post as me } from "../../lib/commands.js";
8
+ import { userErrorMessage as pe } from "../../lib/safe-error.js";
9
+ import { titleCase as w, cn as H } from "../../lib/utils.js";
10
+ import { parseJson as Y } from "./helpers.js";
11
+ function _e({
12
+ targetCollection: e,
13
+ config: o,
14
+ value: r,
15
+ field: s,
16
+ onCreated: t
16
17
  }) {
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(
20
- (e) => {
21
- var r;
18
+ const f = de(), m = oe(), d = ce(), [c, h] = S(!1), [E, W] = S({}), [z, I] = S(!1), [B, x] = S(null), k = P(null), L = P(null), { data: A } = G({
19
+ queryKey: ["quick-create-m2m", e],
20
+ queryFn: () => f.request(X(`/collections/${e}`)).then(
21
+ (n) => {
22
+ var i;
22
23
  return new Set(
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))
24
+ (((i = n.data) == null ? void 0 : i.relations) ?? []).filter(
25
+ (l) => l.one_collection === e && !!l.one_field && !!l.junction_field
26
+ ).map((l) => String(l.one_field))
26
27
  );
27
28
  }
28
29
  ),
29
- enabled: l,
30
+ enabled: c,
30
31
  staleTime: 5 * 6e4
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,
32
+ }), { data: q } = G({
33
+ queryKey: ["quick-create-fields", e],
34
+ queryFn: () => f.request(X(`/field-config/${e}`)).then((n) => Array.isArray(n.data) ? n.data : []).catch(() => []),
35
+ enabled: c,
35
36
  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);
37
+ }), j = (o.fields ?? []).filter((n) => n.from === void 0), C = (o.fields ?? []).filter((n) => n.from !== void 0), T = (n) => {
38
+ var i;
39
+ return typeof n == "string" && n.startsWith("$parent.") ? ((i = d == null ? void 0 : d.draft) == null ? void 0 : i[n.slice(8)]) ?? null : n;
40
+ }, $ = be(C, T), F = ye(C, T, d == null ? void 0 : d.fieldLabels), Q = P(null), [ne, re] = S(null);
41
+ K(() => {
42
+ const n = Q.current;
43
+ if (!n) return;
44
+ const i = N.get(n);
45
+ i && !i.field && (i.value = r);
46
+ }, [r]), qe(d, d != null && d.formKey ? null : ne), K(
47
+ () => () => {
48
+ const n = Q.current, i = n ? N.get(n) : void 0;
49
+ i && !i.formKey && O(i);
50
+ },
51
+ []
52
+ );
53
+ const [M, J] = S(null);
54
+ ae(() => {
55
+ if (!c) {
56
+ J(null);
45
57
  return;
46
58
  }
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({
59
+ const n = () => {
60
+ var g, _;
61
+ const i = (g = k.current) == null ? void 0 : g.getBoundingClientRect();
62
+ if (!i) return;
63
+ const l = Math.min(288, window.innerWidth - 16), y = Math.max(8, Math.min(i.right - l, window.innerWidth - l - 8)), p = window.innerHeight - i.bottom, a = ((_ = L.current) == null ? void 0 : _.offsetHeight) ?? 260, u = p < a + 12 && i.top > p;
64
+ J({
70
65
  position: "fixed",
71
- left: m,
72
- width: n,
66
+ left: y,
67
+ width: l,
73
68
  zIndex: 120,
74
- ...s ? { bottom: window.innerHeight - r.top + 4 } : { top: r.bottom + 4 }
69
+ ...u ? { bottom: window.innerHeight - i.top + 4 } : { top: i.bottom + 4 }
75
70
  });
76
71
  };
77
- return e(), window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
78
- window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
72
+ return n(), window.addEventListener("scroll", n, !0), window.addEventListener("resize", n), () => {
73
+ window.removeEventListener("scroll", n, !0), window.removeEventListener("resize", n);
79
74
  };
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));
75
+ }, [c]), K(() => {
76
+ var n, i;
77
+ !c || !M || (i = (n = L.current) == null ? void 0 : n.querySelector("input")) == null || i.focus({ preventScroll: !0 });
78
+ }, [c, !!M]), K(() => {
79
+ if (!c) return;
80
+ const n = (i) => {
81
+ var y, p;
82
+ const l = i.target;
83
+ (y = L.current) != null && y.contains(l) || (p = k.current) != null && p.contains(l) || (h(!1), x(null));
89
84
  };
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();
85
+ return document.addEventListener("mousedown", n), () => document.removeEventListener("mousedown", n);
86
+ }, [c]);
87
+ const ie = () => {
88
+ var n;
89
+ h(!1), x(null), (n = k.current) == null || n.focus();
95
90
  };
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());
91
+ K(() => {
92
+ if (!c) return;
93
+ const n = (i) => {
94
+ var p, a, u;
95
+ if (i.key !== "Escape") return;
96
+ const l = document.activeElement;
97
+ (l === document.body || l && ((p = L.current) != null && p.contains(l) || (a = k.current) != null && a.contains(l))) && (i.preventDefault(), i.stopPropagation(), h(!1), x(null), (u = k.current) == null || u.focus());
103
98
  };
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`);
99
+ return window.addEventListener("keydown", n, !0), () => window.removeEventListener("keydown", n, !0);
100
+ }, [c]);
101
+ async function U() {
102
+ var l, y, p;
103
+ if ($.length > 0) return;
104
+ for (const a of j) {
105
+ if (a.required && !(E[a.field] ?? "").trim()) {
106
+ x(`${a.label ?? w(a.field)} is required`);
112
107
  return;
113
108
  }
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`
109
+ const u = Z(q == null ? void 0 : q.find((_) => _.field === a.field)), g = (E[a.field] ?? "").trim().length;
110
+ if (u && !u.soft && g > u.max) {
111
+ x(
112
+ u.message ?? `${a.label ?? w(a.field)} takes at most ${u.max} characters`
118
113
  );
119
114
  return;
120
115
  }
121
116
  }
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));
117
+ I(!0), x(null);
118
+ const n = {}, i = {};
119
+ for (const a of C) {
120
+ const u = T(a.from);
121
+ if (A != null && A.has(a.field)) {
122
+ const g = te(u);
123
+ g.length > 0 && (n[a.field] = g, i[a.field] = R(g));
129
124
  continue;
130
125
  }
131
- s != null && s !== "" && (e[i.field] = s, r[i.field] = I(s));
126
+ u != null && u !== "" && (n[a.field] = u, i[a.field] = R(u));
132
127
  }
133
- for (const i of _) {
134
- const s = (v[i.field] ?? "").trim();
135
- s !== "" && (e[i.field] = s);
128
+ for (const a of j) {
129
+ const u = (E[a.field] ?? "").trim();
130
+ u !== "" && (n[a.field] = u);
136
131
  }
137
132
  try {
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(
133
+ const a = await f.request(me(`/items/${e}`, n)), u = (l = a.data) == null ? void 0 : l.id;
134
+ if (u == null) throw new Error("Created record returned no id");
135
+ if (m.invalidateQueries({ queryKey: ["relation-opts", e] }), ((y = a.meta) == null ? void 0 : y.readable) === !1) {
136
+ x(
142
137
  "Created, but it is outside what you can see, so it can't be selected here. Ask an administrator to check your access."
143
138
  ), W({});
144
139
  return;
145
140
  }
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"));
141
+ Q.current = xe({
142
+ id: u,
143
+ targetCollection: e,
144
+ parentCollection: (d == null ? void 0 : d.collection) ?? null,
145
+ formKey: (d == null ? void 0 : d.formKey) ?? null,
146
+ field: s,
147
+ seeds: C,
148
+ written: i,
149
+ m2mAliases: A ?? /* @__PURE__ */ new Set(),
150
+ request: (g) => f.request(g),
151
+ invalidate: () => {
152
+ m.invalidateQueries({ queryKey: ["relation-avail", e] }), m.invalidateQueries({ queryKey: ["relation-opts", e] }), m.invalidateQueries({ queryKey: ["relation-single", e] });
153
+ }
154
+ }), re(Q.current), t(u), h(!1), W({}), (p = k.current) == null || p.focus();
155
+ } catch (a) {
156
+ x(pe(a, "Create failed"));
149
157
  } finally {
150
- O(!1);
158
+ I(!1);
151
159
  }
152
160
  }
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(
161
+ const V = (o.label ?? w(e)).replace(/^New\s+/i, "").toLowerCase();
162
+ return /* @__PURE__ */ b("div", { className: "relative shrink-0", children: [
163
+ /* @__PURE__ */ b(
156
164
  "button",
157
165
  {
158
166
  ref: k,
159
167
  type: "button",
160
- title: d.title ?? `New ${g(t)}`,
161
- "aria-expanded": l,
168
+ title: o.title ?? `New ${w(e)}`,
169
+ "aria-expanded": c,
162
170
  "aria-haspopup": "dialog",
163
- onClick: () => b((e) => !e),
171
+ onClick: () => h((n) => !n),
164
172
  className: H(
165
173
  "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"
174
+ c ? "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"
167
175
  ),
168
176
  children: [
169
- /* @__PURE__ */ x(ne, { className: "h-3.5 w-3.5" }),
170
- d.label ?? "New"
177
+ /* @__PURE__ */ v(se, { className: "h-3.5 w-3.5" }),
178
+ o.label ?? "New"
171
179
  ]
172
180
  }
173
181
  ),
174
- l && se(
175
- /* @__PURE__ */ h(
182
+ c && ue(
183
+ /* @__PURE__ */ b(
176
184
  "div",
177
185
  {
178
- ref: E,
186
+ ref: L,
179
187
  role: "dialog",
180
- "aria-label": d.title ?? `New ${g(t)}`,
188
+ "aria-label": o.title ?? `New ${w(e)}`,
181
189
  "data-quick-create-panel": "",
182
- style: R ?? { position: "fixed", visibility: "hidden", top: 0, left: 0 },
190
+ style: M ?? { position: "fixed", visibility: "hidden", top: 0, left: 0 },
183
191
  className: "nvr-pop-in max-h-[80vh] overflow-y-auto rounded-md border border-border bg-background p-3 shadow-md",
184
192
  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(
193
+ /* @__PURE__ */ v("p", { className: "mb-2 text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: o.title ?? `New ${w(e)}` }),
194
+ $.length > 0 && /* @__PURE__ */ b(
187
195
  "p",
188
196
  {
189
197
  "data-quick-create-missing": !0,
190
198
  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
199
  children: [
192
200
  "Pick ",
193
- G(S),
201
+ D($),
194
202
  " on the form first — the new ",
195
- D,
203
+ V,
196
204
  " takes",
197
205
  " ",
198
- S.length === 1 ? "it" : "them",
206
+ $.length === 1 ? "it" : "them",
199
207
  " from there."
200
208
  ]
201
209
  }
202
210
  ),
203
- S.length === 0 && L.length > 0 && /* @__PURE__ */ h(
211
+ $.length === 0 && F.length > 0 && /* @__PURE__ */ b(
204
212
  "p",
205
213
  {
206
214
  "data-quick-create-later": !0,
207
215
  className: "mb-2 text-[11.5px] leading-snug text-muted-foreground",
208
216
  children: [
209
- G(L),
217
+ D(F),
210
218
  " ",
211
- L.length === 1 ? "is" : "are",
219
+ F.length === 1 ? "is" : "are",
212
220
  " not filled in yet — the new ",
213
- D,
221
+ V,
214
222
  " picks ",
215
- L.length === 1 ? "it" : "them",
223
+ F.length === 1 ? "it" : "them",
216
224
  " up from the form as you fill ",
217
- L.length === 1 ? "it" : "them",
225
+ F.length === 1 ? "it" : "them",
218
226
  " in."
219
227
  ]
220
228
  }
221
229
  ),
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: "*" })
230
+ /* @__PURE__ */ v("div", { className: "flex flex-col gap-2", children: j.map((n) => {
231
+ const i = n.label ?? w(n.field), l = Z(q == null ? void 0 : q.find((u) => u.field === n.field)), y = (E[n.field] ?? "").length, p = !!l && y > l.max, a = `qc-${n.field}-limit`;
232
+ return /* @__PURE__ */ b("label", { className: "flex flex-col gap-1", children: [
233
+ /* @__PURE__ */ b("span", { className: "flex items-baseline justify-between gap-2 text-[11px] text-slate-500 dark:text-slate-400", children: [
234
+ /* @__PURE__ */ b("span", { children: [
235
+ i,
236
+ n.required && /* @__PURE__ */ v("span", { className: "ml-0.5 text-red-500", children: "*" })
229
237
  ] }),
230
- n && m >= n.max * 0.6 && /* @__PURE__ */ h(
238
+ l && y >= l.max * 0.6 && /* @__PURE__ */ b(
231
239
  "span",
232
240
  {
233
241
  "data-quick-create-count": !0,
234
242
  className: H(
235
243
  "tabular-nums",
236
- f ? "font-medium text-amber-700 dark:text-amber-300" : ""
244
+ p ? "font-medium text-amber-700 dark:text-amber-300" : ""
237
245
  ),
238
246
  children: [
239
- m,
247
+ y,
240
248
  "/",
241
- n.max
249
+ l.max
242
250
  ]
243
251
  }
244
252
  )
245
253
  ] }),
246
- /* @__PURE__ */ x(
254
+ /* @__PURE__ */ v(
247
255
  "input",
248
256
  {
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());
257
+ value: E[n.field] ?? "",
258
+ "aria-invalid": p || void 0,
259
+ "aria-describedby": p ? a : void 0,
260
+ onChange: (u) => W((g) => ({ ...g, [n.field]: u.target.value })),
261
+ onKeyDown: (u) => {
262
+ u.key === "Enter" && (u.preventDefault(), U());
255
263
  },
256
264
  className: H(
257
265
  "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"
266
+ p ? "border-amber-400 dark:border-amber-500" : "border-input"
259
267
  )
260
268
  }
261
269
  ),
262
- f && /* @__PURE__ */ x(
270
+ p && /* @__PURE__ */ v(
263
271
  "span",
264
272
  {
265
- id: i,
273
+ id: a,
266
274
  "data-quick-create-limit": !0,
267
275
  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.`
276
+ children: (l == null ? void 0 : l.message) ?? `${i} takes at most ${l == null ? void 0 : l.max} characters.`
269
277
  }
270
278
  )
271
- ] }, e.field);
279
+ ] }, n.field);
272
280
  }) }),
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(
281
+ B && /* @__PURE__ */ v("p", { role: "alert", className: "mt-2 text-[11px] text-red-600 dark:text-red-400", children: B }),
282
+ /* @__PURE__ */ b("div", { className: "mt-3 flex justify-end gap-2", children: [
283
+ /* @__PURE__ */ v(
276
284
  "button",
277
285
  {
278
286
  type: "button",
279
- onClick: ee,
287
+ onClick: ie,
280
288
  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
289
  children: "Cancel"
282
290
  }
283
291
  ),
284
- /* @__PURE__ */ h(
292
+ /* @__PURE__ */ b(
285
293
  "button",
286
294
  {
287
295
  type: "button",
288
- disabled: M || S.length > 0 || $.length > 0 && !N,
289
- onClick: () => void B(),
296
+ disabled: z || $.length > 0 || C.length > 0 && !A,
297
+ onClick: () => void U(),
290
298
  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
299
  children: [
292
- M && /* @__PURE__ */ x(re, { className: "h-3 w-3 animate-spin" }),
300
+ z && /* @__PURE__ */ v(le, { className: "h-3 w-3 animate-spin" }),
293
301
  "Create & select"
294
302
  ]
295
303
  }
@@ -298,71 +306,130 @@ function $e({
298
306
  ]
299
307
  }
300
308
  ),
301
- ce(k.current)
309
+ he(k.current)
302
310
  )
303
311
  ] });
304
312
  }
305
- function ce(t) {
306
- return (t == null ? void 0 : t.closest('[role="dialog"]')) ?? document.body;
313
+ function he(e) {
314
+ return (e == null ? void 0 : e.closest('[role="dialog"]')) ?? document.body;
307
315
  }
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;
316
+ function Z(e) {
317
+ if (!e) return null;
318
+ const o = Y(e.validation_rules), r = Array.isArray(o) ? o.find((d) => (d == null ? void 0 : d.type) === "max") : null, s = Number(r == null ? void 0 : r.value);
319
+ if (r && Number.isFinite(s) && s > 0)
320
+ return { max: s, soft: !!r.soft, message: r.message || void 0 };
321
+ const t = Y(e.options), f = Number(t == null ? void 0 : t.max_length);
322
+ if (Number.isFinite(f) && f > 0) return { max: f, soft: !1 };
323
+ const m = Number(e.max_length);
324
+ return Number.isInteger(m) && m > 0 ? { max: m, soft: !1 } : null;
317
325
  }
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);
326
+ function ye(e, o, r) {
327
+ return e.filter((s) => !s.required && typeof s.from == "string" && s.from.startsWith("$parent.")).filter((s) => ee(o(s.from))).map((s) => {
328
+ const t = String(s.from).slice(8);
329
+ return s.label ?? (r == null ? void 0 : r[t]) ?? w(t);
322
330
  });
323
331
  }
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);
332
+ function ge(e, o, r, s) {
333
+ if (!s) return null;
334
+ const t = {}, f = {};
335
+ for (const m of e) {
336
+ if (typeof m.from != "string" || !m.from.startsWith("$parent.")) continue;
337
+ const d = o(m.from);
338
+ if (ee(d)) continue;
339
+ const c = s.has(m.field) ? te(d) : d;
340
+ if (Array.isArray(c) && c.length === 0) continue;
341
+ const h = R(c);
342
+ r[m.field] !== h && (t[m.field] = c, f[m.field] = h);
343
+ }
344
+ return Object.keys(t).length ? { patch: t, written: f } : null;
345
+ }
346
+ function R(e) {
347
+ return Array.isArray(e) ? e.map((o) => String(o)).join(",") : String(e ?? "");
348
+ }
349
+ function ee(e) {
350
+ return e == null || e === "" || Array.isArray(e) && e.length === 0;
351
+ }
352
+ function be(e, o) {
353
+ return e.filter((r) => r.required && typeof r.from == "string" && r.from.startsWith("$parent.")).filter((r) => {
354
+ const s = o(r.from);
355
+ return s == null || s === "" || Array.isArray(s) && s.length === 0;
356
+ }).map((r) => r.label ?? w(String(r.from).slice(8)));
357
+ }
358
+ function D(e) {
359
+ return e.length <= 1 ? e[0] ?? "" : `${e.slice(0, -1).join(", ")} and ${e[e.length - 1]}`;
360
+ }
361
+ function te(e) {
362
+ const o = Array.isArray(e) ? e : [e], r = [];
363
+ for (const s of o) {
364
+ const t = s != null && typeof s == "object" ? s.id : s;
365
+ (typeof t == "string" && t !== "" || typeof t == "number") && r.push(t);
335
366
  }
336
- return Object.keys(u).length ? { patch: u, written: p } : null;
367
+ return r;
337
368
  }
338
- function I(t) {
339
- return Array.isArray(t) ? t.map((d) => String(d)).join(",") : String(t ?? "");
369
+ const N = /* @__PURE__ */ new Map(), ve = 60 * 6e4, we = 500;
370
+ function xe(e) {
371
+ const o = `${e.formKey ?? ""}|${e.parentCollection ?? ""}|${e.targetCollection}|${String(e.id)}`, r = N.get(o);
372
+ return r != null && r.timer && clearTimeout(r.timer), N.set(o, { ...e, key: o, timer: null, pendingSig: null, at: Date.now() }), o;
340
373
  }
341
- function X(t) {
342
- return t == null || t === "" || Array.isArray(t) && t.length === 0;
374
+ function We(e) {
375
+ if (e)
376
+ for (const o of [...N.values()]) o.formKey === e && O(o);
343
377
  }
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)));
378
+ function O(e) {
379
+ e.timer && clearTimeout(e.timer), N.delete(e.key);
349
380
  }
350
- function G(t) {
351
- return t.length <= 1 ? t[0] ?? "" : `${t.slice(0, -1).join(", ")} and ${t[t.length - 1]}`;
381
+ function ke(e) {
382
+ return e != null && typeof e == "object" ? e.id : e;
352
383
  }
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);
384
+ function Ne(e, o, r = {}) {
385
+ if (N.size === 0 || !e) return;
386
+ const s = Date.now();
387
+ for (const t of [...N.values()]) {
388
+ if (s - t.at > ve) {
389
+ O(t);
390
+ continue;
391
+ }
392
+ if ((t.formKey ? t.formKey !== r.formKey : t.key !== r.mine) || t.parentCollection && o && t.parentCollection !== o) continue;
393
+ if (r.isNew === !1) {
394
+ O(t);
395
+ continue;
396
+ }
397
+ const f = ke(t.field ? e[t.field] : t.value);
398
+ if (f == null || f === "") continue;
399
+ if (String(f) !== String(t.id)) {
400
+ O(t);
401
+ continue;
402
+ }
403
+ const m = (h) => typeof h == "string" && h.startsWith("$parent.") ? e[h.slice(8)] ?? null : h, d = ge(t.seeds, m, t.written, t.m2mAliases);
404
+ if (!d) {
405
+ t.timer && clearTimeout(t.timer), t.timer = null, t.pendingSig = null;
406
+ continue;
407
+ }
408
+ const c = JSON.stringify(d.patch);
409
+ t.timer && t.pendingSig === c || (t.timer && clearTimeout(t.timer), t.pendingSig = c, t.timer = setTimeout(() => {
410
+ t.timer = null, t.pendingSig = null, t.request(fe(`/items/${t.targetCollection}/${t.id}`, d.patch)).then(() => {
411
+ t.written = { ...t.written, ...d.written }, t.invalidate();
412
+ }).catch(() => {
413
+ });
414
+ }, we));
358
415
  }
359
- return o;
416
+ }
417
+ function qe(e, o) {
418
+ const r = e == null ? void 0 : e.draft, s = e == null ? void 0 : e.collection, t = e == null ? void 0 : e.formKey, f = e == null ? void 0 : e.isNew;
419
+ K(() => {
420
+ Ne(r, s, { formKey: t, isNew: f, mine: o });
421
+ }, [r, s, t, f, o]);
360
422
  }
361
423
  export {
362
- $e as QuickCreateButton,
363
- C as fieldLimit,
364
- pe as missingRequiredSeeds,
365
- fe as pendingOptionalSeeds,
366
- me as seedFollowPatch,
367
- I as seedKey
424
+ we as FOLLOW_DEBOUNCE_MS,
425
+ _e as QuickCreateButton,
426
+ We as endQuickCreateFollows,
427
+ Z as fieldLimit,
428
+ be as missingRequiredSeeds,
429
+ ye as pendingOptionalSeeds,
430
+ Ne as runQuickCreateFollow,
431
+ ge as seedFollowPatch,
432
+ R as seedKey,
433
+ xe as startQuickCreateFollow,
434
+ qe as useQuickCreateFollow
368
435
  };