@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.
- package/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +62 -8
- package/dist/shared/components/CollectionBrowserView.js +3127 -3204
- package/dist/shared/components/ConformanceView.js +235 -221
- package/dist/shared/components/DataTable.js +478 -459
- package/dist/shared/components/ItemEditForm.js +4842 -4500
- package/dist/shared/components/MyWorkView.js +124 -113
- package/dist/shared/components/PageRenderer.js +146 -138
- package/dist/shared/components/ProfileView.js +483 -472
- package/dist/shared/components/RecordDrilldownSheet.js +73 -65
- package/dist/shared/components/ReportView.js +1100 -1094
- package/dist/shared/components/bulk/BulkActionButtons.js +72 -72
- package/dist/shared/components/bulk/BulkCompareButton.js +62 -0
- package/dist/shared/components/bulk/BulkFieldUpdate.js +114 -103
- package/dist/shared/components/bulk/BulkFieldUpdateButton.js +73 -0
- package/dist/shared/components/bulk/MessageStakeholders.js +235 -0
- package/dist/shared/components/bulk/bulk-field-options.js +29 -23
- package/dist/shared/components/integrations/IntegrationObligationsView.js +191 -173
- package/dist/shared/components/integrations/IntegrationStatusLines.js +101 -85
- package/dist/shared/components/integrations/RecordIntegrationPreview.js +11 -9
- package/dist/shared/components/integrations/SendCurrentData.js +126 -0
- package/dist/shared/components/item-edit/CatalogPickerField.js +1535 -1440
- package/dist/shared/components/item-edit/FieldRenderer.js +49 -45
- package/dist/shared/components/item-edit/FieldRow.js +413 -403
- package/dist/shared/components/item-edit/GroupSection.js +555 -538
- package/dist/shared/components/item-edit/InlineTableField.js +2903 -2816
- package/dist/shared/components/item-edit/M2MCombobox.js +407 -338
- package/dist/shared/components/item-edit/MidairCollisionDialog.js +367 -116
- package/dist/shared/components/item-edit/NestedRelationEditor.js +171 -163
- package/dist/shared/components/item-edit/PlanGrid.js +783 -724
- package/dist/shared/components/item-edit/QuickCreateButton.js +291 -224
- package/dist/shared/components/item-edit/RecordInsights.js +113 -111
- package/dist/shared/components/item-edit/RecordLiveSync.js +4 -1
- package/dist/shared/components/item-edit/RelationCombobox.js +398 -364
- package/dist/shared/components/item-edit/SummaryPanel.js +146 -144
- package/dist/shared/components/item-edit/UserChip.js +264 -229
- package/dist/shared/components/item-edit/cascade-clear-notice.js +56 -0
- package/dist/shared/components/item-edit/collision-format.js +37 -0
- package/dist/shared/components/item-edit/field-a11y.js +25 -0
- package/dist/shared/components/item-edit/header-path-preview.js +52 -0
- package/dist/shared/components/item-edit/line-merge.js +84 -0
- package/dist/shared/components/item-edit/line-midair.js +94 -87
- package/dist/shared/components/item-edit/move-guard.js +17 -0
- package/dist/shared/components/item-edit/picker-search.js +27 -16
- package/dist/shared/components/item-edit/rail-width.js +8 -0
- package/dist/shared/components/monitoring/InactiveUserLinksView.js +126 -124
- package/dist/shared/components/panels/AccessDeniedPanel.js +96 -55
- package/dist/shared/components/panels/CommentPanel.js +142 -136
- package/dist/shared/components/panels/ItemLockBanner.js +246 -240
- package/dist/shared/components/panels/PipelinePanel.js +1366 -1194
- package/dist/shared/components/panels/RevisionsPanel.js +106 -102
- package/dist/shared/components/panels/SlaBreachBanner.js +16 -20
- package/dist/shared/components/panels/SlaClock.js +90 -68
- package/dist/shared/components/queue/QueueItemSheet.js +94 -87
- package/dist/shared/components/queue/QueueWorklist.js +1522 -1347
- package/dist/shared/components/queue/worklist-csv.js +75 -0
- package/dist/shared/components/queue/worklist-helpers.js +20 -0
- package/dist/shared/components/widgets/ReviewListWidget.js +226 -207
- package/dist/shared/lib/bulk-copy.js +17 -0
- package/dist/shared/lib/cbv-export.js +122 -0
- package/dist/shared/lib/delete-offer.js +13 -0
- package/dist/shared/lib/error-hints.js +1 -0
- package/dist/shared/lib/leave-guard.js +41 -26
- package/dist/shared/lib/list-link.js +72 -56
- package/dist/shared/lib/live-queries.js +32 -30
- package/dist/shared/lib/moved-notice.js +25 -0
- package/dist/shared/lib/notification-target.js +56 -54
- package/dist/shared/lib/obligation-banner.js +11 -8
- package/dist/shared/lib/obligation-reason-text.js +6 -6
- package/dist/shared/lib/quick-filter-cascade.js +29 -19
- package/dist/shared/lib/sort-cycle.js +6 -0
- package/dist/shared/lib/summary-mode.js +59 -41
- package/package.json +1 -1
|
@@ -1,295 +1,303 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useQueryClient as
|
|
3
|
-
import { Plus as
|
|
4
|
-
import {
|
|
5
|
-
import { createPortal as
|
|
6
|
-
import { useNivaroClient as
|
|
7
|
-
import { get as
|
|
8
|
-
import { userErrorMessage as
|
|
9
|
-
import { titleCase as
|
|
10
|
-
import { parseJson as
|
|
11
|
-
function
|
|
12
|
-
targetCollection:
|
|
13
|
-
config:
|
|
14
|
-
value:
|
|
15
|
-
|
|
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
|
|
18
|
-
queryKey: ["quick-create-m2m",
|
|
19
|
-
queryFn: () =>
|
|
20
|
-
(
|
|
21
|
-
var
|
|
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
|
-
(((
|
|
24
|
-
(
|
|
25
|
-
).map((
|
|
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:
|
|
30
|
+
enabled: c,
|
|
30
31
|
staleTime: 5 * 6e4
|
|
31
|
-
}), { data: q } =
|
|
32
|
-
queryKey: ["quick-create-fields",
|
|
33
|
-
queryFn: () =>
|
|
34
|
-
enabled:
|
|
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
|
-
}),
|
|
37
|
-
var
|
|
38
|
-
return typeof
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
if (!
|
|
43
|
-
|
|
44
|
-
|
|
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
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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:
|
|
72
|
-
width:
|
|
66
|
+
left: y,
|
|
67
|
+
width: l,
|
|
73
68
|
zIndex: 120,
|
|
74
|
-
...
|
|
69
|
+
...u ? { bottom: window.innerHeight - i.top + 4 } : { top: i.bottom + 4 }
|
|
75
70
|
});
|
|
76
71
|
};
|
|
77
|
-
return
|
|
78
|
-
window.removeEventListener("scroll",
|
|
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
|
-
}, [
|
|
81
|
-
var
|
|
82
|
-
!
|
|
83
|
-
}, [
|
|
84
|
-
if (!
|
|
85
|
-
const
|
|
86
|
-
var
|
|
87
|
-
const
|
|
88
|
-
(
|
|
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",
|
|
91
|
-
}, [
|
|
92
|
-
const
|
|
93
|
-
var
|
|
94
|
-
|
|
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
|
-
|
|
97
|
-
if (!
|
|
98
|
-
const
|
|
99
|
-
var
|
|
100
|
-
if (
|
|
101
|
-
const
|
|
102
|
-
(
|
|
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",
|
|
105
|
-
}, [
|
|
106
|
-
async function
|
|
107
|
-
var
|
|
108
|
-
if (
|
|
109
|
-
for (const
|
|
110
|
-
if (
|
|
111
|
-
|
|
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
|
|
115
|
-
if (
|
|
116
|
-
|
|
117
|
-
|
|
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
|
-
|
|
123
|
-
const
|
|
124
|
-
for (const
|
|
125
|
-
const
|
|
126
|
-
if (
|
|
127
|
-
const
|
|
128
|
-
|
|
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
|
-
|
|
126
|
+
u != null && u !== "" && (n[a.field] = u, i[a.field] = R(u));
|
|
132
127
|
}
|
|
133
|
-
for (const
|
|
134
|
-
const
|
|
135
|
-
|
|
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
|
|
139
|
-
if (
|
|
140
|
-
if (
|
|
141
|
-
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
-
|
|
158
|
+
I(!1);
|
|
151
159
|
}
|
|
152
160
|
}
|
|
153
|
-
const
|
|
154
|
-
return /* @__PURE__ */
|
|
155
|
-
/* @__PURE__ */
|
|
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:
|
|
161
|
-
"aria-expanded":
|
|
168
|
+
title: o.title ?? `New ${w(e)}`,
|
|
169
|
+
"aria-expanded": c,
|
|
162
170
|
"aria-haspopup": "dialog",
|
|
163
|
-
onClick: () =>
|
|
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
|
-
|
|
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__ */
|
|
170
|
-
|
|
177
|
+
/* @__PURE__ */ v(se, { className: "h-3.5 w-3.5" }),
|
|
178
|
+
o.label ?? "New"
|
|
171
179
|
]
|
|
172
180
|
}
|
|
173
181
|
),
|
|
174
|
-
|
|
175
|
-
/* @__PURE__ */
|
|
182
|
+
c && ue(
|
|
183
|
+
/* @__PURE__ */ b(
|
|
176
184
|
"div",
|
|
177
185
|
{
|
|
178
|
-
ref:
|
|
186
|
+
ref: L,
|
|
179
187
|
role: "dialog",
|
|
180
|
-
"aria-label":
|
|
188
|
+
"aria-label": o.title ?? `New ${w(e)}`,
|
|
181
189
|
"data-quick-create-panel": "",
|
|
182
|
-
style:
|
|
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__ */
|
|
186
|
-
|
|
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
|
-
|
|
201
|
+
D($),
|
|
194
202
|
" on the form first — the new ",
|
|
195
|
-
|
|
203
|
+
V,
|
|
196
204
|
" takes",
|
|
197
205
|
" ",
|
|
198
|
-
|
|
206
|
+
$.length === 1 ? "it" : "them",
|
|
199
207
|
" from there."
|
|
200
208
|
]
|
|
201
209
|
}
|
|
202
210
|
),
|
|
203
|
-
|
|
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
|
-
|
|
217
|
+
D(F),
|
|
210
218
|
" ",
|
|
211
|
-
|
|
219
|
+
F.length === 1 ? "is" : "are",
|
|
212
220
|
" not filled in yet — the new ",
|
|
213
|
-
|
|
221
|
+
V,
|
|
214
222
|
" picks ",
|
|
215
|
-
|
|
223
|
+
F.length === 1 ? "it" : "them",
|
|
216
224
|
" up from the form as you fill ",
|
|
217
|
-
|
|
225
|
+
F.length === 1 ? "it" : "them",
|
|
218
226
|
" in."
|
|
219
227
|
]
|
|
220
228
|
}
|
|
221
229
|
),
|
|
222
|
-
/* @__PURE__ */
|
|
223
|
-
const
|
|
224
|
-
return /* @__PURE__ */
|
|
225
|
-
/* @__PURE__ */
|
|
226
|
-
/* @__PURE__ */
|
|
227
|
-
|
|
228
|
-
|
|
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
|
-
|
|
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
|
-
|
|
244
|
+
p ? "font-medium text-amber-700 dark:text-amber-300" : ""
|
|
237
245
|
),
|
|
238
246
|
children: [
|
|
239
|
-
|
|
247
|
+
y,
|
|
240
248
|
"/",
|
|
241
|
-
|
|
249
|
+
l.max
|
|
242
250
|
]
|
|
243
251
|
}
|
|
244
252
|
)
|
|
245
253
|
] }),
|
|
246
|
-
/* @__PURE__ */
|
|
254
|
+
/* @__PURE__ */ v(
|
|
247
255
|
"input",
|
|
248
256
|
{
|
|
249
|
-
value:
|
|
250
|
-
"aria-invalid":
|
|
251
|
-
"aria-describedby":
|
|
252
|
-
onChange: (
|
|
253
|
-
onKeyDown: (
|
|
254
|
-
|
|
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
|
-
|
|
266
|
+
p ? "border-amber-400 dark:border-amber-500" : "border-input"
|
|
259
267
|
)
|
|
260
268
|
}
|
|
261
269
|
),
|
|
262
|
-
|
|
270
|
+
p && /* @__PURE__ */ v(
|
|
263
271
|
"span",
|
|
264
272
|
{
|
|
265
|
-
id:
|
|
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: (
|
|
276
|
+
children: (l == null ? void 0 : l.message) ?? `${i} takes at most ${l == null ? void 0 : l.max} characters.`
|
|
269
277
|
}
|
|
270
278
|
)
|
|
271
|
-
] },
|
|
279
|
+
] }, n.field);
|
|
272
280
|
}) }),
|
|
273
|
-
|
|
274
|
-
/* @__PURE__ */
|
|
275
|
-
/* @__PURE__ */
|
|
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:
|
|
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__ */
|
|
292
|
+
/* @__PURE__ */ b(
|
|
285
293
|
"button",
|
|
286
294
|
{
|
|
287
295
|
type: "button",
|
|
288
|
-
disabled:
|
|
289
|
-
onClick: () => void
|
|
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
|
-
|
|
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
|
-
|
|
309
|
+
he(k.current)
|
|
302
310
|
)
|
|
303
311
|
] });
|
|
304
312
|
}
|
|
305
|
-
function
|
|
306
|
-
return (
|
|
313
|
+
function he(e) {
|
|
314
|
+
return (e == null ? void 0 : e.closest('[role="dialog"]')) ?? document.body;
|
|
307
315
|
}
|
|
308
|
-
function
|
|
309
|
-
if (!
|
|
310
|
-
const
|
|
311
|
-
if (
|
|
312
|
-
return { max:
|
|
313
|
-
const
|
|
314
|
-
if (Number.isFinite(
|
|
315
|
-
const
|
|
316
|
-
return Number.isInteger(
|
|
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
|
|
319
|
-
return
|
|
320
|
-
const
|
|
321
|
-
return
|
|
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
|
|
325
|
-
if (!
|
|
326
|
-
const
|
|
327
|
-
for (const
|
|
328
|
-
if (typeof
|
|
329
|
-
const
|
|
330
|
-
if (
|
|
331
|
-
const
|
|
332
|
-
if (Array.isArray(
|
|
333
|
-
const
|
|
334
|
-
|
|
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
|
|
367
|
+
return r;
|
|
337
368
|
}
|
|
338
|
-
|
|
339
|
-
|
|
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
|
|
342
|
-
|
|
374
|
+
function We(e) {
|
|
375
|
+
if (e)
|
|
376
|
+
for (const o of [...N.values()]) o.formKey === e && O(o);
|
|
343
377
|
}
|
|
344
|
-
function
|
|
345
|
-
|
|
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
|
|
351
|
-
return
|
|
381
|
+
function ke(e) {
|
|
382
|
+
return e != null && typeof e == "object" ? e.id : e;
|
|
352
383
|
}
|
|
353
|
-
function
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
(
|
|
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
|
-
|
|
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
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
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
|
};
|