@nivaro/react 0.3.122 → 0.3.123
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/hooks/useSessionRecorder.js +1 -1
- package/dist/shared/components/ItemEditForm.js +2712 -2696
- package/dist/shared/components/item-edit/M2MCombobox.js +387 -376
- package/dist/shared/components/item-edit/cascade-clear-notice.js +49 -41
- package/dist/shared/components/item-edit/staged-links.js +38 -37
- package/dist/shared/lib/error-hints.js +1 -1
- package/package.json +1 -1
|
@@ -1,284 +1,284 @@
|
|
|
1
|
-
import { jsx as n, jsxs as
|
|
2
|
-
import { useQuery as
|
|
3
|
-
import { ChevronDown as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { useNivaroClient as
|
|
6
|
-
import { parseAllowedCollections as
|
|
1
|
+
import { jsx as n, jsxs as h } from "react/jsx-runtime";
|
|
2
|
+
import { useQuery as q } from "@tanstack/react-query";
|
|
3
|
+
import { ChevronDown as he, Loader2 as Ce, AlertTriangle as Ie, X as qe, Check as Oe, Mail as at } from "lucide-react";
|
|
4
|
+
import { useState as H, useRef as Le, useEffect as Fe } from "react";
|
|
5
|
+
import { useNivaroClient as Te, useItemEditAuth as De, useDrilldown as ot } from "../../context.js";
|
|
6
|
+
import { parseAllowedCollections as ct } from "../../lib/allowed-collections.js";
|
|
7
7
|
import { get as $ } from "../../lib/commands.js";
|
|
8
|
-
import { pickerOptionsMeta as
|
|
9
|
-
import { useOptionBadges as
|
|
10
|
-
import { compareByMatch as
|
|
11
|
-
import { useRecordReader as
|
|
12
|
-
import { useOnlineUsers as
|
|
13
|
-
import { cn as
|
|
14
|
-
import { UserAvatar as
|
|
15
|
-
import { RecordPickerBadges as
|
|
16
|
-
import { Command as
|
|
17
|
-
import { Popover as
|
|
18
|
-
import { applyDisplayTemplate as
|
|
19
|
-
import { useM2MStaging as
|
|
20
|
-
import { onlyCloseMatches as
|
|
21
|
-
import { useStaleTip as
|
|
22
|
-
function
|
|
23
|
-
return t.replace(/\(.*$/, "").trim().split(/\s+/).map((
|
|
8
|
+
import { pickerOptionsMeta as dt } from "../../lib/live-pickers.js";
|
|
9
|
+
import { useOptionBadges as ut } from "../../lib/picker-badges.js";
|
|
10
|
+
import { compareByMatch as Me } from "../../lib/picker-rank.js";
|
|
11
|
+
import { useRecordReader as mt } from "../../lib/record-loader.js";
|
|
12
|
+
import { useOnlineUsers as Ee } from "../../lib/use-online-users.js";
|
|
13
|
+
import { cn as X, userOptionFilter as Je, matchesAllTokens as ft } from "../../lib/utils.js";
|
|
14
|
+
import { UserAvatar as ze } from "../UserAvatar.js";
|
|
15
|
+
import { RecordPickerBadges as pt, PickerBadgeList as ht } from "./PickerBadges.js";
|
|
16
|
+
import { Command as Be, CommandInput as Ge, CommandList as Re, CommandEmpty as Ve, CommandGroup as $e, CommandItem as Ke } from "../ui/command.js";
|
|
17
|
+
import { Popover as We, PopoverTrigger as Ze, PopoverContent as Qe } from "../ui/popover.js";
|
|
18
|
+
import { applyDisplayTemplate as ye } from "./helpers.js";
|
|
19
|
+
import { useM2MStaging as Xe } from "./M2MStagingContext.js";
|
|
20
|
+
import { onlyCloseMatches as yt } from "./picker-search.js";
|
|
21
|
+
import { useStaleTip as bt, RelatedItemLabel as me } from "./RelationCombobox.js";
|
|
22
|
+
function He(t) {
|
|
23
|
+
return t.replace(/\(.*$/, "").trim().split(/\s+/).map((s) => s[0]).filter(Boolean).slice(0, 2).join("").toUpperCase() || "?";
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
return
|
|
25
|
+
function oe(t) {
|
|
26
|
+
return ct(t == null ? void 0 : t.one_allowed_collections);
|
|
27
27
|
}
|
|
28
|
-
const
|
|
29
|
-
function
|
|
30
|
-
return `m2a:${t}:${String(
|
|
28
|
+
const xt = /^m2a:([A-Za-z_][A-Za-z0-9_]*):(.+)$/;
|
|
29
|
+
function be(t, s) {
|
|
30
|
+
return `m2a:${t}:${String(s)}`;
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function fe(t) {
|
|
33
33
|
if (typeof t != "string") return null;
|
|
34
|
-
const
|
|
35
|
-
return
|
|
34
|
+
const s = t.match(xt);
|
|
35
|
+
return s ? { collection: s[1], id: s[2] } : null;
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function gt(t) {
|
|
38
38
|
if (!t || t.one_collection) return [];
|
|
39
|
-
const
|
|
40
|
-
return
|
|
39
|
+
const s = oe(t);
|
|
40
|
+
return s.length < 2 ? [] : s.filter((d) => d !== "directus_users" && d !== "nivaro_users");
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
const
|
|
44
|
-
queryKey: ["m2a-extra-options",
|
|
42
|
+
function Ye(t, s, d, a) {
|
|
43
|
+
const o = gt(s), { data: v } = q({
|
|
44
|
+
queryKey: ["m2a-extra-options", o.join(",")],
|
|
45
45
|
queryFn: async () => {
|
|
46
46
|
const f = [];
|
|
47
|
-
for (const m of
|
|
48
|
-
const [
|
|
49
|
-
t.request($(`/collections/${m}`)).then((
|
|
50
|
-
t.request($(`/items/${m}`, { limit: 500 })).then((
|
|
47
|
+
for (const m of o) {
|
|
48
|
+
const [O, r] = await Promise.all([
|
|
49
|
+
t.request($(`/collections/${m}`)).then((y) => y.data).catch(() => null),
|
|
50
|
+
t.request($(`/items/${m}`, { limit: 500 })).then((y) => y.data ?? []).catch(() => [])
|
|
51
51
|
]);
|
|
52
|
-
for (const
|
|
52
|
+
for (const y of r)
|
|
53
53
|
f.push({
|
|
54
|
-
token:
|
|
54
|
+
token: be(m, y.id),
|
|
55
55
|
collection: m,
|
|
56
|
-
label:
|
|
56
|
+
label: ye((O == null ? void 0 : O.display_template) ?? null, y)
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
return f;
|
|
60
60
|
},
|
|
61
|
-
enabled:
|
|
61
|
+
enabled: a && o.length > 0,
|
|
62
62
|
staleTime: 6e4
|
|
63
|
-
}),
|
|
64
|
-
return (v ?? []).filter((f) => !
|
|
63
|
+
}), g = d.trim().toLowerCase();
|
|
64
|
+
return (v ?? []).filter((f) => !g || f.label.toLowerCase().includes(g)).sort((f, m) => f.label.localeCompare(m.label)).slice(0, 25);
|
|
65
65
|
}
|
|
66
|
-
function
|
|
66
|
+
function et({
|
|
67
67
|
options: t,
|
|
68
|
-
isSelected:
|
|
68
|
+
isSelected: s,
|
|
69
69
|
onPick: d,
|
|
70
|
-
round:
|
|
70
|
+
round: a
|
|
71
71
|
}) {
|
|
72
|
-
return t.length === 0 ? null : /* @__PURE__ */ n(
|
|
73
|
-
const v =
|
|
74
|
-
return /* @__PURE__ */
|
|
75
|
-
|
|
72
|
+
return t.length === 0 ? null : /* @__PURE__ */ n($e, { heading: "External emails", "data-m2a-extra-options": "", children: t.map((o) => {
|
|
73
|
+
const v = s(o.token);
|
|
74
|
+
return /* @__PURE__ */ h(
|
|
75
|
+
Ke,
|
|
76
76
|
{
|
|
77
|
-
value:
|
|
78
|
-
onSelect: () => d(
|
|
77
|
+
value: o.token,
|
|
78
|
+
onSelect: () => d(o.token),
|
|
79
79
|
className: "flex items-center gap-2 text-[12px]",
|
|
80
80
|
children: [
|
|
81
81
|
/* @__PURE__ */ n(
|
|
82
82
|
"div",
|
|
83
83
|
{
|
|
84
|
-
className:
|
|
84
|
+
className: X(
|
|
85
85
|
"flex h-4 w-4 shrink-0 items-center justify-center border transition-colors",
|
|
86
|
-
|
|
86
|
+
a ? "rounded-full" : "rounded",
|
|
87
87
|
v ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300 dark:border-slate-500"
|
|
88
88
|
),
|
|
89
|
-
children: v && /* @__PURE__ */ n(
|
|
89
|
+
children: v && /* @__PURE__ */ n(Oe, { className: "h-2.5 w-2.5 text-white" })
|
|
90
90
|
}
|
|
91
91
|
),
|
|
92
|
-
/* @__PURE__ */ n(
|
|
93
|
-
/* @__PURE__ */ n("span", { className: "truncate", children:
|
|
92
|
+
/* @__PURE__ */ n(at, { className: "h-3.5 w-3.5 shrink-0 text-slate-400", "aria-hidden": !0 }),
|
|
93
|
+
/* @__PURE__ */ n("span", { className: "truncate", children: o.label })
|
|
94
94
|
]
|
|
95
95
|
},
|
|
96
|
-
|
|
96
|
+
o.token
|
|
97
97
|
);
|
|
98
98
|
}) });
|
|
99
99
|
}
|
|
100
|
-
function
|
|
101
|
-
return !t || t.one_collection ||
|
|
100
|
+
function tt(t) {
|
|
101
|
+
return !t || t.one_collection || oe(t).length < 2 ? null : t.one_collection_field || "collection";
|
|
102
102
|
}
|
|
103
|
-
function
|
|
104
|
-
if (!
|
|
105
|
-
const
|
|
106
|
-
if (typeof
|
|
107
|
-
const
|
|
108
|
-
return
|
|
103
|
+
function pe(t, s, d) {
|
|
104
|
+
if (!s || !t) return d;
|
|
105
|
+
const a = t[s];
|
|
106
|
+
if (typeof a != "string" || !a.trim()) return d;
|
|
107
|
+
const o = a.trim();
|
|
108
|
+
return o === "directus_users" || o === "nivaro_users" ? "nivaro_users" : o;
|
|
109
109
|
}
|
|
110
|
-
function
|
|
111
|
-
const d =
|
|
110
|
+
function Pe({ collection: t, id: s }) {
|
|
111
|
+
const d = Te(), { data: a } = q({
|
|
112
112
|
queryKey: ["col-meta", t],
|
|
113
|
-
queryFn: () => d.request($(`/collections/${t}`)).then((
|
|
113
|
+
queryFn: () => d.request($(`/collections/${t}`)).then((o) => o.data),
|
|
114
114
|
staleTime: 3e5,
|
|
115
115
|
retry: !1
|
|
116
116
|
});
|
|
117
|
-
return /* @__PURE__ */ n("span", { "data-m2a-collection": t, children: /* @__PURE__ */ n(
|
|
117
|
+
return /* @__PURE__ */ n("span", { "data-m2a-collection": t, children: /* @__PURE__ */ n(me, { collection: t, id: s, displayTemplate: a == null ? void 0 : a.display_template }) });
|
|
118
118
|
}
|
|
119
|
-
function
|
|
120
|
-
return !t || t.one_collection ? 0 :
|
|
119
|
+
function Jt(t) {
|
|
120
|
+
return !t || t.one_collection ? 0 : oe(t).length;
|
|
121
121
|
}
|
|
122
|
-
function
|
|
122
|
+
function nt(t) {
|
|
123
123
|
if (!t) return null;
|
|
124
124
|
if (t.one_collection) return t.one_collection;
|
|
125
|
-
const
|
|
126
|
-
return
|
|
125
|
+
const s = oe(t);
|
|
126
|
+
return s.length === 0 ? null : s.some((d) => d === "directus_users" || d === "nivaro_users") ? "nivaro_users" : s[0];
|
|
127
127
|
}
|
|
128
|
-
function
|
|
128
|
+
function zt(t) {
|
|
129
129
|
if (!t || t.one_collection) return null;
|
|
130
|
-
const
|
|
131
|
-
if (
|
|
132
|
-
const d =
|
|
130
|
+
const s = oe(t);
|
|
131
|
+
if (s.length === 0) return null;
|
|
132
|
+
const d = s.includes("directus_users") ? "directus_users" : s.includes("nivaro_users") ? "nivaro_users" : s[0];
|
|
133
133
|
return { field: t.one_collection_field ?? "collection", value: d };
|
|
134
134
|
}
|
|
135
|
-
function
|
|
135
|
+
function j(t) {
|
|
136
136
|
return String(t).toLowerCase();
|
|
137
137
|
}
|
|
138
|
-
function
|
|
138
|
+
function Bt({
|
|
139
139
|
relation: t,
|
|
140
|
-
parentId:
|
|
140
|
+
parentId: s,
|
|
141
141
|
allRelations: d,
|
|
142
|
-
extraFilter:
|
|
143
|
-
optionSort:
|
|
142
|
+
extraFilter: a,
|
|
143
|
+
optionSort: o,
|
|
144
144
|
requiredParent: v,
|
|
145
|
-
onCountChange:
|
|
145
|
+
onCountChange: g,
|
|
146
146
|
drilldown: f
|
|
147
147
|
}) {
|
|
148
|
-
const m =
|
|
148
|
+
const m = Te(), O = ot(), r = Xe(), [y, K] = H(!1), [x, L] = H(""), U = d.find(
|
|
149
149
|
(e) => e.many_collection === t.many_collection && e.many_field === t.junction_field && e.id !== t.id
|
|
150
|
-
), i =
|
|
150
|
+
), i = nt(U), w = t.junction_field ?? "", Y = t.many_field ?? "", k = t.one_field ?? `${t.many_collection}.${w}`, F = tt(U), { data: b } = q({
|
|
151
151
|
queryKey: ["col-meta", i],
|
|
152
152
|
queryFn: () => m.request($(`/collections/${i}`)).then((e) => e.data),
|
|
153
153
|
enabled: !!i,
|
|
154
154
|
staleTime: 3e5,
|
|
155
155
|
retry: !1
|
|
156
|
-
}), { data:
|
|
156
|
+
}), { data: G = [] } = q({
|
|
157
157
|
// An M2A read carries the discriminator: its own key (same prefix, so every
|
|
158
158
|
// ['m2m-items', junction, …] invalidation still refreshes it).
|
|
159
159
|
queryKey: [
|
|
160
160
|
"m2m-items",
|
|
161
161
|
t.many_collection,
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
...
|
|
162
|
+
Y,
|
|
163
|
+
s,
|
|
164
|
+
...F ? ["m2a"] : []
|
|
165
165
|
],
|
|
166
166
|
queryFn: () => m.request(
|
|
167
167
|
$(`/items/${t.many_collection}`, {
|
|
168
|
-
filter: JSON.stringify({ [
|
|
168
|
+
filter: JSON.stringify({ [Y]: { _eq: s } }),
|
|
169
169
|
limit: 200,
|
|
170
|
-
fields: `id,${
|
|
170
|
+
fields: `id,${w}${F ? `,${F}` : ""}`
|
|
171
171
|
})
|
|
172
172
|
).then((e) => e.data ?? []),
|
|
173
173
|
staleTime: 3e4,
|
|
174
|
-
enabled: !!
|
|
175
|
-
}),
|
|
176
|
-
const e =
|
|
174
|
+
enabled: !!s && s !== "new"
|
|
175
|
+
}), ee = (e) => pe(e, F, i), ge = De().isAdmin, D = i === "nivaro_users" ? Je(ge) : null, ke = Ee(i === "nivaro_users"), te = a ? D ? { _and: [a, D] } : a : D, ne = te ? JSON.stringify(te) : void 0, re = o && !/^-?label$/.test(o) ? o : void 0, ve = (() => {
|
|
176
|
+
const e = b == null ? void 0 : b.display_template;
|
|
177
177
|
if (!e || !e.includes(".")) return null;
|
|
178
|
-
const
|
|
179
|
-
return
|
|
178
|
+
const c = [...e.matchAll(/\{\{([^}]+)\}\}/g)].map((u) => u[1].trim());
|
|
179
|
+
return c.length === 0 ? null : ["id", ...c].join(",");
|
|
180
180
|
})(), {
|
|
181
|
-
options:
|
|
182
|
-
isLoading:
|
|
183
|
-
localSearch:
|
|
184
|
-
closeMatches:
|
|
185
|
-
} =
|
|
181
|
+
options: R,
|
|
182
|
+
isLoading: M,
|
|
183
|
+
localSearch: ce,
|
|
184
|
+
closeMatches: le
|
|
185
|
+
} = rt({
|
|
186
186
|
client: m,
|
|
187
187
|
relatedCollection: i,
|
|
188
|
-
search:
|
|
189
|
-
filterParam:
|
|
190
|
-
serverSort:
|
|
191
|
-
templateNestedFields:
|
|
192
|
-
enabled:
|
|
193
|
-
labelOf:
|
|
194
|
-
}),
|
|
195
|
-
new Set(
|
|
188
|
+
search: x,
|
|
189
|
+
filterParam: ne,
|
|
190
|
+
serverSort: re,
|
|
191
|
+
templateNestedFields: ve,
|
|
192
|
+
enabled: y && !!i,
|
|
193
|
+
labelOf: I
|
|
194
|
+
}), we = st(!!le, x), _e = Ye(m, U, x, y), T = (r == null ? void 0 : r.getStagedLinks(k)) ?? [], E = (r == null ? void 0 : r.getStagedUnlinks(k)) ?? /* @__PURE__ */ new Set(), S = G.filter((e) => !E.has(e.id));
|
|
195
|
+
new Set(S.map((e) => String(e[w])));
|
|
196
196
|
const V = (e) => {
|
|
197
|
-
const
|
|
198
|
-
return
|
|
199
|
-
},
|
|
197
|
+
const c = ee(e);
|
|
198
|
+
return c && c !== i ? be(c, e[w]) : e[w];
|
|
199
|
+
}, N = [
|
|
200
200
|
...new Set(
|
|
201
|
-
|
|
201
|
+
S.filter((e) => ee(e) === i).map((e) => String(e[w]))
|
|
202
202
|
)
|
|
203
|
-
],
|
|
204
|
-
queryKey: ["m2m-avail", i,
|
|
203
|
+
], _ = JSON.stringify(a ? { _and: [{ id: { _in: N } }, a] } : { id: { _in: N } }), { data: se } = q({
|
|
204
|
+
queryKey: ["m2m-avail", i, N.join(","), ne],
|
|
205
205
|
queryFn: () => m.request(
|
|
206
206
|
$(`/items/${i}`, {
|
|
207
|
-
filter:
|
|
207
|
+
filter: _,
|
|
208
208
|
picker: "1",
|
|
209
209
|
limit: 200,
|
|
210
210
|
fields: "id"
|
|
211
211
|
})
|
|
212
212
|
).then((e) => e.data ?? []),
|
|
213
|
-
enabled: !!i &&
|
|
213
|
+
enabled: !!i && N.length > 0,
|
|
214
214
|
staleTime: 3e4
|
|
215
|
-
}),
|
|
216
|
-
...
|
|
217
|
-
...
|
|
218
|
-
]),
|
|
215
|
+
}), W = new Set((se ?? []).map((e) => String(e.id))), J = se !== void 0 ? new Set(N.filter((e) => !W.has(e))) : /* @__PURE__ */ new Set(), A = new Set(T.map(j)), P = /* @__PURE__ */ new Set([
|
|
216
|
+
...S.map((e) => j(V(e))),
|
|
217
|
+
...A
|
|
218
|
+
]), ie = ut(
|
|
219
219
|
i,
|
|
220
|
-
(
|
|
221
|
-
|
|
222
|
-
),
|
|
223
|
-
|
|
220
|
+
(R ?? []).map((e) => e.id),
|
|
221
|
+
y && i !== "nivaro_users"
|
|
222
|
+
), Z = Le(g);
|
|
223
|
+
Z.current = g, Fe(() => {
|
|
224
224
|
var e;
|
|
225
|
-
(e =
|
|
225
|
+
(e = Z.current) == null || e.call(Z, P.size);
|
|
226
226
|
}, [P.size]);
|
|
227
|
-
function
|
|
228
|
-
const
|
|
229
|
-
if (
|
|
230
|
-
r == null || r.unstageLink(
|
|
227
|
+
function de(e) {
|
|
228
|
+
const c = j(e);
|
|
229
|
+
if (A.has(c)) {
|
|
230
|
+
r == null || r.unstageLink(k, e);
|
|
231
231
|
return;
|
|
232
232
|
}
|
|
233
|
-
const u =
|
|
233
|
+
const u = G.find((C) => j(V(C)) === c);
|
|
234
234
|
if (u) {
|
|
235
|
-
|
|
235
|
+
E.has(u.id) ? r == null || r.unstageUnlink(k, u.id) : r == null || r.stageUnlink(k, u.id);
|
|
236
236
|
return;
|
|
237
237
|
}
|
|
238
|
-
r == null || r.stageLink(
|
|
238
|
+
r == null || r.stageLink(k, e);
|
|
239
239
|
}
|
|
240
|
-
function
|
|
241
|
-
const
|
|
242
|
-
return
|
|
240
|
+
function I(e) {
|
|
241
|
+
const c = (b == null ? void 0 : b.display_template) ?? null;
|
|
242
|
+
return c ? ye(c, e) : String(e._display ?? e.id ?? "");
|
|
243
243
|
}
|
|
244
|
-
return v ? /* @__PURE__ */
|
|
244
|
+
return v ? /* @__PURE__ */ h(
|
|
245
245
|
"button",
|
|
246
246
|
{
|
|
247
247
|
type: "button",
|
|
248
248
|
disabled: !0,
|
|
249
249
|
className: "flex h-9 w-full items-center justify-between gap-2 rounded-md border border-input bg-background px-3 text-sm text-muted-foreground opacity-50 cursor-not-allowed",
|
|
250
250
|
children: [
|
|
251
|
-
/* @__PURE__ */
|
|
251
|
+
/* @__PURE__ */ h("span", { className: "truncate", children: [
|
|
252
252
|
"Select ",
|
|
253
253
|
v,
|
|
254
254
|
" first"
|
|
255
255
|
] }),
|
|
256
|
-
/* @__PURE__ */ n(
|
|
256
|
+
/* @__PURE__ */ n(he, { className: "h-4 w-4 shrink-0 opacity-50" })
|
|
257
257
|
]
|
|
258
258
|
}
|
|
259
|
-
) : /* @__PURE__ */ n("div", { children: /* @__PURE__ */
|
|
260
|
-
|
|
259
|
+
) : /* @__PURE__ */ n("div", { children: /* @__PURE__ */ h(
|
|
260
|
+
We,
|
|
261
261
|
{
|
|
262
|
-
open:
|
|
262
|
+
open: y,
|
|
263
263
|
onOpenChange: (e) => {
|
|
264
|
-
|
|
264
|
+
K(e), e || L("");
|
|
265
265
|
},
|
|
266
266
|
children: [
|
|
267
|
-
/* @__PURE__ */ n(
|
|
267
|
+
/* @__PURE__ */ n(Ze, { asChild: !0, children: /* @__PURE__ */ h(
|
|
268
268
|
"div",
|
|
269
269
|
{
|
|
270
270
|
role: "button",
|
|
271
271
|
tabIndex: 0,
|
|
272
272
|
onKeyDown: (e) => {
|
|
273
|
-
if (e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey && (
|
|
273
|
+
if (e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey && (y || x !== "" || e.key !== " ")) {
|
|
274
274
|
e.preventDefault();
|
|
275
275
|
const u = e.key;
|
|
276
|
-
|
|
277
|
-
} else (e.key === "Enter" || e.key === " " || !
|
|
276
|
+
L((C) => u === " " && (C === "" || C.endsWith(" ")) ? C : C + u), y || K(!0);
|
|
277
|
+
} else (e.key === "Enter" || e.key === " " || !y && e.key === "ArrowDown") && (e.preventDefault(), K((u) => !u));
|
|
278
278
|
},
|
|
279
279
|
className: "flex min-h-9 w-full cursor-pointer items-center justify-between gap-2 rounded-md border border-input bg-background px-3 py-1 text-sm text-left font-normal hover:bg-muted",
|
|
280
280
|
children: [
|
|
281
|
-
P.size > 0 ? /* @__PURE__ */
|
|
281
|
+
P.size > 0 ? /* @__PURE__ */ h(
|
|
282
282
|
"span",
|
|
283
283
|
{
|
|
284
284
|
className: "flex min-w-0 flex-1 flex-wrap items-center gap-1",
|
|
@@ -286,60 +286,60 @@ function Jt({
|
|
|
286
286
|
e.target.closest("button") && e.stopPropagation();
|
|
287
287
|
},
|
|
288
288
|
children: [
|
|
289
|
-
|
|
290
|
-
const
|
|
291
|
-
return /* @__PURE__ */
|
|
289
|
+
S.map((e) => {
|
|
290
|
+
const c = e[w], u = ee(e), C = u !== i, Q = !C && J.has(String(c));
|
|
291
|
+
return /* @__PURE__ */ h(
|
|
292
292
|
"span",
|
|
293
293
|
{
|
|
294
|
-
title:
|
|
295
|
-
className:
|
|
294
|
+
title: Q ? "This record is no longer an available option" : void 0,
|
|
295
|
+
className: X(
|
|
296
296
|
"inline-flex items-center gap-1 rounded-full border pl-2.5 pr-1.5 py-0.5 text-[12px]",
|
|
297
|
-
|
|
297
|
+
Q ? "border-amber-300 bg-amber-50 text-amber-700 dark:border-amber-600 dark:bg-amber-950/30 dark:text-amber-400" : "border-slate-200 bg-slate-50 text-slate-700 dark:border-border dark:bg-muted dark:text-slate-200"
|
|
298
298
|
),
|
|
299
299
|
children: [
|
|
300
|
-
|
|
300
|
+
Q && /* @__PURE__ */ n(Ie, { className: "h-3 w-3 shrink-0 text-amber-500" }),
|
|
301
301
|
u && (C ? (
|
|
302
302
|
// An external email (or another allowed kind): its own
|
|
303
303
|
// table, its own label — never read as a person.
|
|
304
|
-
/* @__PURE__ */ n(
|
|
305
|
-
) : f &&
|
|
304
|
+
/* @__PURE__ */ n(Pe, { collection: u, id: c })
|
|
305
|
+
) : f && O ? /* @__PURE__ */ n(
|
|
306
306
|
"button",
|
|
307
307
|
{
|
|
308
308
|
type: "button",
|
|
309
309
|
title: "Open detail panel",
|
|
310
|
-
onClick: () =>
|
|
310
|
+
onClick: () => O.open({
|
|
311
311
|
collection: u,
|
|
312
|
-
itemId: String(
|
|
312
|
+
itemId: String(c),
|
|
313
313
|
layoutId: f.layout_id,
|
|
314
314
|
width: f.width
|
|
315
315
|
}),
|
|
316
316
|
className: "underline decoration-slate-300 decoration-dotted underline-offset-2 hover:text-[#172940] hover:decoration-nvr-cyan dark:hover:text-nvr-cyan",
|
|
317
317
|
children: /* @__PURE__ */ n(
|
|
318
|
-
|
|
318
|
+
me,
|
|
319
319
|
{
|
|
320
320
|
collection: u,
|
|
321
|
-
id:
|
|
322
|
-
displayTemplate:
|
|
321
|
+
id: c,
|
|
322
|
+
displayTemplate: b == null ? void 0 : b.display_template
|
|
323
323
|
}
|
|
324
324
|
)
|
|
325
325
|
}
|
|
326
326
|
) : /* @__PURE__ */ n(
|
|
327
|
-
|
|
327
|
+
me,
|
|
328
328
|
{
|
|
329
329
|
collection: u,
|
|
330
|
-
id:
|
|
331
|
-
displayTemplate:
|
|
330
|
+
id: c,
|
|
331
|
+
displayTemplate: b == null ? void 0 : b.display_template
|
|
332
332
|
}
|
|
333
333
|
)),
|
|
334
|
-
u && !C && u !== "nivaro_users" && /* @__PURE__ */ n(
|
|
334
|
+
u && !C && u !== "nivaro_users" && /* @__PURE__ */ n(pt, { collection: u, id: c }),
|
|
335
335
|
/* @__PURE__ */ n(
|
|
336
336
|
"button",
|
|
337
337
|
{
|
|
338
338
|
type: "button",
|
|
339
339
|
"aria-label": "Remove",
|
|
340
|
-
onClick: () => r == null ? void 0 : r.stageUnlink(
|
|
340
|
+
onClick: () => r == null ? void 0 : r.stageUnlink(k, e.id),
|
|
341
341
|
className: "rounded-full p-0.5 text-slate-400 hover:text-red-500",
|
|
342
|
-
children: /* @__PURE__ */ n(
|
|
342
|
+
children: /* @__PURE__ */ n(qe, { className: "h-3 w-3" })
|
|
343
343
|
}
|
|
344
344
|
)
|
|
345
345
|
]
|
|
@@ -347,23 +347,23 @@ function Jt({
|
|
|
347
347
|
String(e.id)
|
|
348
348
|
);
|
|
349
349
|
}),
|
|
350
|
-
|
|
350
|
+
T.map((e) => /* @__PURE__ */ h(
|
|
351
351
|
"span",
|
|
352
352
|
{
|
|
353
353
|
className: "inline-flex items-center gap-1 rounded-full border border-dashed border-nvr-cyan/50 bg-nvr-cyan/5 pl-2.5 pr-1.5 py-0.5 text-[12px] text-slate-600 dark:text-slate-300",
|
|
354
354
|
children: [
|
|
355
|
-
|
|
356
|
-
|
|
355
|
+
fe(e) ? /* @__PURE__ */ n(
|
|
356
|
+
Pe,
|
|
357
357
|
{
|
|
358
|
-
collection:
|
|
359
|
-
id:
|
|
358
|
+
collection: fe(e).collection,
|
|
359
|
+
id: fe(e).id
|
|
360
360
|
}
|
|
361
361
|
) : i ? /* @__PURE__ */ n(
|
|
362
|
-
|
|
362
|
+
me,
|
|
363
363
|
{
|
|
364
364
|
collection: i,
|
|
365
365
|
id: e,
|
|
366
|
-
displayTemplate:
|
|
366
|
+
displayTemplate: b == null ? void 0 : b.display_template
|
|
367
367
|
}
|
|
368
368
|
) : String(e),
|
|
369
369
|
/* @__PURE__ */ n(
|
|
@@ -371,9 +371,9 @@ function Jt({
|
|
|
371
371
|
{
|
|
372
372
|
type: "button",
|
|
373
373
|
"aria-label": "Remove",
|
|
374
|
-
onClick: () => r == null ? void 0 : r.unstageLink(
|
|
374
|
+
onClick: () => r == null ? void 0 : r.unstageLink(k, e),
|
|
375
375
|
className: "rounded-full p-0.5 text-slate-400 hover:text-red-500",
|
|
376
|
-
children: /* @__PURE__ */ n(
|
|
376
|
+
children: /* @__PURE__ */ n(qe, { className: "h-3 w-3" })
|
|
377
377
|
}
|
|
378
378
|
)
|
|
379
379
|
]
|
|
@@ -383,88 +383,88 @@ function Jt({
|
|
|
383
383
|
]
|
|
384
384
|
}
|
|
385
385
|
) : /* @__PURE__ */ n("span", { className: "truncate text-muted-foreground", children: "Select items…" }),
|
|
386
|
-
/* @__PURE__ */ n(
|
|
386
|
+
/* @__PURE__ */ n(he, { className: "h-4 w-4 shrink-0 opacity-50" })
|
|
387
387
|
]
|
|
388
388
|
}
|
|
389
389
|
) }),
|
|
390
|
-
/* @__PURE__ */ n(
|
|
391
|
-
|
|
390
|
+
/* @__PURE__ */ n(Qe, { className: "w-[320px] p-0", align: "start", children: /* @__PURE__ */ h(
|
|
391
|
+
Be,
|
|
392
392
|
{
|
|
393
393
|
shouldFilter: !1,
|
|
394
|
-
...
|
|
394
|
+
...we,
|
|
395
395
|
children: [
|
|
396
396
|
/* @__PURE__ */ n(
|
|
397
|
-
|
|
397
|
+
Ge,
|
|
398
398
|
{
|
|
399
399
|
placeholder: "Search…",
|
|
400
|
-
value:
|
|
401
|
-
onValueChange:
|
|
400
|
+
value: x,
|
|
401
|
+
onValueChange: L,
|
|
402
402
|
className: "h-9 text-[13px]"
|
|
403
403
|
}
|
|
404
404
|
),
|
|
405
|
-
/* @__PURE__ */
|
|
406
|
-
|
|
407
|
-
!
|
|
405
|
+
/* @__PURE__ */ h(Re, { children: [
|
|
406
|
+
M ? /* @__PURE__ */ n("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ n(Ce, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : /* @__PURE__ */ n(Ve, { className: "py-3 text-left text-[12px] text-muted-foreground px-3", children: "No results" }),
|
|
407
|
+
!M && le && /* @__PURE__ */ h(
|
|
408
408
|
"p",
|
|
409
409
|
{
|
|
410
410
|
"data-picker-close-matches": !0,
|
|
411
411
|
className: "px-3 pb-1 pt-2 text-[11.5px] text-muted-foreground",
|
|
412
412
|
children: [
|
|
413
413
|
"No exact match for “",
|
|
414
|
-
|
|
414
|
+
x.trim(),
|
|
415
415
|
"” — did you mean:"
|
|
416
416
|
]
|
|
417
417
|
}
|
|
418
418
|
),
|
|
419
|
-
/* @__PURE__ */ n(
|
|
420
|
-
(e,
|
|
419
|
+
/* @__PURE__ */ n($e, { children: !M && (re ? [...xe(R, x, ce, I)] : [...xe(R, x, ce, I)].sort(
|
|
420
|
+
(e, c) => Me(I(e), I(c), x, o === "-label")
|
|
421
421
|
)).map((e) => {
|
|
422
|
-
const
|
|
423
|
-
return /* @__PURE__ */
|
|
424
|
-
|
|
422
|
+
const c = String(e.id), u = P.has(j(c));
|
|
423
|
+
return /* @__PURE__ */ h(
|
|
424
|
+
Ke,
|
|
425
425
|
{
|
|
426
|
-
value:
|
|
427
|
-
onSelect: () =>
|
|
426
|
+
value: c,
|
|
427
|
+
onSelect: () => de(e.id),
|
|
428
428
|
className: "flex items-center gap-2 text-[13px]",
|
|
429
429
|
children: [
|
|
430
430
|
/* @__PURE__ */ n(
|
|
431
431
|
"div",
|
|
432
432
|
{
|
|
433
|
-
className:
|
|
433
|
+
className: X(
|
|
434
434
|
"flex h-4 w-4 shrink-0 items-center justify-center rounded border",
|
|
435
435
|
u ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300 dark:border-slate-500"
|
|
436
436
|
),
|
|
437
|
-
children: u && /* @__PURE__ */ n(
|
|
437
|
+
children: u && /* @__PURE__ */ n(Oe, { className: "h-2.5 w-2.5 text-white" })
|
|
438
438
|
}
|
|
439
439
|
),
|
|
440
440
|
i === "nivaro_users" && /* @__PURE__ */ n(
|
|
441
|
-
|
|
441
|
+
ze,
|
|
442
442
|
{
|
|
443
|
-
userId:
|
|
443
|
+
userId: c,
|
|
444
444
|
className: "h-4 w-4",
|
|
445
|
-
fallback: /* @__PURE__ */ n("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-nvr-cyan/20 text-[8px] font-bold text-nvr-navy dark:text-nvr-cyan", children:
|
|
445
|
+
fallback: /* @__PURE__ */ n("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-nvr-cyan/20 text-[8px] font-bold text-nvr-navy dark:text-nvr-cyan", children: He(I(e)) })
|
|
446
446
|
}
|
|
447
447
|
),
|
|
448
|
-
i === "nivaro_users" &&
|
|
448
|
+
i === "nivaro_users" && ke.has(c.toUpperCase()) && /* @__PURE__ */ n(
|
|
449
449
|
"span",
|
|
450
450
|
{
|
|
451
451
|
className: "h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500",
|
|
452
452
|
"data-tip": "Online now"
|
|
453
453
|
}
|
|
454
454
|
),
|
|
455
|
-
/* @__PURE__ */ n("span", { className: "truncate", children:
|
|
456
|
-
/* @__PURE__ */ n(
|
|
455
|
+
/* @__PURE__ */ n("span", { className: "truncate", children: I(e) }),
|
|
456
|
+
/* @__PURE__ */ n(ht, { badges: ie[c] })
|
|
457
457
|
]
|
|
458
458
|
},
|
|
459
|
-
|
|
459
|
+
c
|
|
460
460
|
);
|
|
461
461
|
}) }),
|
|
462
462
|
/* @__PURE__ */ n(
|
|
463
|
-
|
|
463
|
+
et,
|
|
464
464
|
{
|
|
465
|
-
options:
|
|
466
|
-
isSelected: (e) => P.has(
|
|
467
|
-
onPick: (e) =>
|
|
465
|
+
options: _e,
|
|
466
|
+
isSelected: (e) => P.has(j(e)),
|
|
467
|
+
onPick: (e) => de(e),
|
|
468
468
|
round: !1
|
|
469
469
|
}
|
|
470
470
|
)
|
|
@@ -476,293 +476,304 @@ function Jt({
|
|
|
476
476
|
}
|
|
477
477
|
) });
|
|
478
478
|
}
|
|
479
|
-
function
|
|
480
|
-
const { client:
|
|
479
|
+
function rt(t) {
|
|
480
|
+
const { client: s, relatedCollection: d, search: a, filterParam: o, serverSort: v, templateNestedFields: g } = t, f = (i) => s.request(
|
|
481
481
|
$(`/items/${d}`, {
|
|
482
|
-
limit:
|
|
482
|
+
limit: lt,
|
|
483
483
|
search: i || void 0,
|
|
484
484
|
// Typo pass (fix11-search): close matches only when the exact search finds nothing.
|
|
485
485
|
...i ? { typo: "1" } : {},
|
|
486
|
-
filter:
|
|
486
|
+
filter: o,
|
|
487
487
|
picker: "1",
|
|
488
488
|
// A dotted display template ({{core_category.name}}) needs the
|
|
489
489
|
// nested expansion — a bare row only carries the FK id.
|
|
490
|
-
...
|
|
490
|
+
...g ? { fields: g } : {},
|
|
491
491
|
...v ? { sort: v } : {}
|
|
492
492
|
})
|
|
493
|
-
).then((
|
|
493
|
+
).then((w) => w.data ?? []), m = (i) => [
|
|
494
494
|
"m2m-options",
|
|
495
495
|
d,
|
|
496
496
|
i,
|
|
497
|
-
|
|
497
|
+
o,
|
|
498
498
|
v ?? "",
|
|
499
|
-
|
|
500
|
-
],
|
|
499
|
+
g ?? ""
|
|
500
|
+
], O = o ? 0 : 3e4, r = dt(d), { data: y, isFetching: K } = q({
|
|
501
501
|
queryKey: m(""),
|
|
502
502
|
queryFn: () => f(""),
|
|
503
503
|
enabled: t.enabled,
|
|
504
|
-
staleTime:
|
|
504
|
+
staleTime: O,
|
|
505
505
|
meta: r
|
|
506
|
-
}),
|
|
507
|
-
queryKey: m(
|
|
508
|
-
queryFn: () => f(
|
|
509
|
-
enabled: t.enabled &&
|
|
510
|
-
staleTime:
|
|
506
|
+
}), x = kt(y, a, t.labelOf), { data: L, isFetching: U } = q({
|
|
507
|
+
queryKey: m(a),
|
|
508
|
+
queryFn: () => f(a),
|
|
509
|
+
enabled: t.enabled && x,
|
|
510
|
+
staleTime: O,
|
|
511
511
|
meta: r
|
|
512
512
|
});
|
|
513
|
-
return
|
|
514
|
-
options:
|
|
515
|
-
isLoading: !
|
|
513
|
+
return x ? {
|
|
514
|
+
options: L ?? [],
|
|
515
|
+
isLoading: !L && U,
|
|
516
516
|
localSearch: !1,
|
|
517
|
-
closeMatches:
|
|
518
|
-
} : { options:
|
|
517
|
+
closeMatches: yt(L)
|
|
518
|
+
} : { options: y ?? [], isLoading: !y && K, localSearch: !!a };
|
|
519
519
|
}
|
|
520
|
-
const
|
|
521
|
-
function
|
|
522
|
-
return
|
|
520
|
+
const lt = 200;
|
|
521
|
+
function kt(t, s, d) {
|
|
522
|
+
return s.trim() ? !t || t.length >= lt ? !0 : xe(t, s, !0, d).length === 0 : !1;
|
|
523
523
|
}
|
|
524
|
-
function
|
|
525
|
-
return !d || !
|
|
524
|
+
function xe(t, s, d, a) {
|
|
525
|
+
return !d || !s.trim() ? t : t.filter((o) => ft(a(o), s));
|
|
526
526
|
}
|
|
527
|
-
function
|
|
527
|
+
function Gt({
|
|
528
528
|
relation: t,
|
|
529
|
-
parentId:
|
|
529
|
+
parentId: s,
|
|
530
530
|
allRelations: d,
|
|
531
|
-
extraFilter:
|
|
532
|
-
optionSort:
|
|
531
|
+
extraFilter: a,
|
|
532
|
+
optionSort: o,
|
|
533
533
|
requiredParent: v,
|
|
534
|
-
onCountChange:
|
|
534
|
+
onCountChange: g,
|
|
535
535
|
readOnly: f
|
|
536
536
|
}) {
|
|
537
|
-
const m =
|
|
538
|
-
(
|
|
539
|
-
), i =
|
|
537
|
+
const m = Te(), O = mt(), r = Xe(), [y, K] = H(!1), [x, L] = H(""), U = d.find(
|
|
538
|
+
(l) => l.many_collection === t.many_collection && l.many_field === t.junction_field && l.id !== t.id
|
|
539
|
+
), i = nt(U), w = t.junction_field ?? "", Y = t.many_field ?? "", k = t.one_field ?? `${t.many_collection}.${w}`, { data: F } = q({
|
|
540
540
|
queryKey: ["col-meta", i],
|
|
541
|
-
queryFn: () => m.request($(`/collections/${i}`)).then((
|
|
541
|
+
queryFn: () => m.request($(`/collections/${i}`)).then((l) => l.data),
|
|
542
542
|
enabled: !!i,
|
|
543
543
|
staleTime: 3e5,
|
|
544
544
|
retry: !1
|
|
545
|
-
}),
|
|
545
|
+
}), b = tt(U), { data: G = [], isFetching: ee } = q({
|
|
546
546
|
queryKey: [
|
|
547
547
|
"m2m-items",
|
|
548
548
|
t.many_collection,
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
...
|
|
549
|
+
Y,
|
|
550
|
+
s,
|
|
551
|
+
...b ? ["m2a"] : []
|
|
552
552
|
],
|
|
553
553
|
queryFn: () => m.request(
|
|
554
554
|
$(`/items/${t.many_collection}`, {
|
|
555
|
-
filter: JSON.stringify({ [
|
|
555
|
+
filter: JSON.stringify({ [Y]: { _eq: s } }),
|
|
556
556
|
limit: 1,
|
|
557
|
-
fields: `id,${
|
|
557
|
+
fields: `id,${w}${b ? `,${b}` : ""}`
|
|
558
558
|
})
|
|
559
|
-
).then((
|
|
559
|
+
).then((l) => l.data ?? []),
|
|
560
560
|
staleTime: 3e4,
|
|
561
|
-
enabled: !!
|
|
562
|
-
}),
|
|
563
|
-
const
|
|
564
|
-
if (!
|
|
565
|
-
const
|
|
566
|
-
return
|
|
561
|
+
enabled: !!s && s !== "new"
|
|
562
|
+
}), ge = De().isAdmin, D = i === "nivaro_users" ? Je(ge) : null, ke = Ee(i === "nivaro_users"), te = a ? D ? { _and: [a, D] } : a : D, ne = te ? JSON.stringify(te) : void 0, re = o && !/^-?label$/.test(o) ? o : void 0, ve = (() => {
|
|
563
|
+
const l = F == null ? void 0 : F.display_template;
|
|
564
|
+
if (!l || !l.includes(".")) return null;
|
|
565
|
+
const p = [...l.matchAll(/\{\{([^}]+)\}\}/g)].map((ae) => ae[1].trim());
|
|
566
|
+
return p.length === 0 ? null : ["id", ...p].join(",");
|
|
567
567
|
})(), {
|
|
568
|
-
options:
|
|
569
|
-
isLoading:
|
|
570
|
-
localSearch:
|
|
571
|
-
closeMatches:
|
|
572
|
-
} =
|
|
568
|
+
options: R,
|
|
569
|
+
isLoading: M,
|
|
570
|
+
localSearch: ce,
|
|
571
|
+
closeMatches: le
|
|
572
|
+
} = rt({
|
|
573
573
|
client: m,
|
|
574
574
|
relatedCollection: i,
|
|
575
|
-
search:
|
|
576
|
-
filterParam:
|
|
577
|
-
serverSort:
|
|
578
|
-
templateNestedFields:
|
|
579
|
-
enabled:
|
|
575
|
+
search: x,
|
|
576
|
+
filterParam: ne,
|
|
577
|
+
serverSort: re,
|
|
578
|
+
templateNestedFields: ve,
|
|
579
|
+
enabled: y && !!i,
|
|
580
580
|
labelOf: z
|
|
581
|
-
}),
|
|
582
|
-
|
|
583
|
-
var
|
|
584
|
-
(
|
|
585
|
-
}, [
|
|
586
|
-
const
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
581
|
+
}), we = st(!!le, x), _e = Ye(m, U, x, y), T = (r == null ? void 0 : r.getStagedLinks(k)) ?? [], E = (r == null ? void 0 : r.getStagedUnlinks(k)) ?? /* @__PURE__ */ new Set(), S = G.find((l) => !E.has(l.id)) ?? null, V = S ? S[w] : null, N = T.length > 0 ? T[T.length - 1] : null, _ = N ?? V, se = T.length > 0 || E.size > 0, W = Le(g);
|
|
582
|
+
W.current = g, Fe(() => {
|
|
583
|
+
var l;
|
|
584
|
+
(l = W.current) == null || l.call(W, _ != null ? 1 : 0);
|
|
585
|
+
}, [_]);
|
|
586
|
+
const J = fe(N), A = N != null ? (J == null ? void 0 : J.collection) ?? i : pe(S, b, i), P = J ? J.id : _, ie = pe(S, b, i), Z = S == null ? null : ie && ie !== i ? be(ie, V) : String(V), de = N != null ? String(N) : Z, I = (l) => {
|
|
587
|
+
const p = pe(l, b, i);
|
|
588
|
+
return j(
|
|
589
|
+
p && p !== i ? be(p, l[w]) : l[w]
|
|
590
|
+
);
|
|
591
|
+
}, e = A !== i, { data: c } = q({
|
|
592
|
+
queryKey: ["col-meta", A],
|
|
593
|
+
queryFn: () => m.request($(`/collections/${A}`)).then((l) => l.data),
|
|
594
|
+
enabled: e && !!A,
|
|
590
595
|
staleTime: 3e5,
|
|
591
596
|
retry: !1
|
|
592
|
-
}), { data:
|
|
593
|
-
queryKey: ["relation-single",
|
|
594
|
-
queryFn: () =>
|
|
595
|
-
enabled: !!
|
|
597
|
+
}), { data: u } = q({
|
|
598
|
+
queryKey: ["relation-single", A, String(P)],
|
|
599
|
+
queryFn: () => O(A, P),
|
|
600
|
+
enabled: !!A && P != null,
|
|
596
601
|
staleTime: 6e4
|
|
597
|
-
}),
|
|
598
|
-
queryKey: ["relation-avail", i, String(
|
|
602
|
+
}), C = JSON.stringify(a ? { _and: [{ id: { _eq: _ } }, a] } : { id: { _eq: _ } }), { data: Q } = q({
|
|
603
|
+
queryKey: ["relation-avail", i, String(_), ne],
|
|
599
604
|
queryFn: () => m.request(
|
|
600
605
|
$(`/items/${i}`, {
|
|
601
|
-
filter:
|
|
606
|
+
filter: C,
|
|
602
607
|
picker: "1",
|
|
603
608
|
limit: 1,
|
|
604
609
|
fields: "id"
|
|
605
610
|
})
|
|
606
|
-
).then((
|
|
607
|
-
enabled: !!i && !
|
|
611
|
+
).then((l) => l.data ?? []),
|
|
612
|
+
enabled: !!i && !e && _ != null && !!u,
|
|
608
613
|
staleTime: 3e4
|
|
609
|
-
}),
|
|
610
|
-
function z(
|
|
611
|
-
const
|
|
612
|
-
return
|
|
614
|
+
}), Se = !e && Q !== void 0 && Q.length === 0, Ae = bt(Se);
|
|
615
|
+
function z(l) {
|
|
616
|
+
const p = (F == null ? void 0 : F.display_template) ?? null;
|
|
617
|
+
return p ? ye(p, l) : String(l.name ?? l.title ?? l.label ?? l.id ?? "");
|
|
613
618
|
}
|
|
614
|
-
const
|
|
619
|
+
const ue = e ? u : R.find((l) => String(l.id) === String(_)) ?? u, je = _ != null && !u && !ue, Ne = ue ? e ? ye((c == null ? void 0 : c.display_template) ?? null, ue) : z(ue) : null;
|
|
615
620
|
if (f)
|
|
616
|
-
return /* @__PURE__ */ n("span", { className: "block truncate text-[12px] text-slate-700 dark:text-slate-200", children:
|
|
617
|
-
function
|
|
618
|
-
|
|
619
|
-
|
|
621
|
+
return /* @__PURE__ */ n("span", { className: "block truncate text-[12px] text-slate-700 dark:text-slate-200", children: je ? "…" : Ne ?? "—" });
|
|
622
|
+
function Ue(l) {
|
|
623
|
+
const p = G.find((B) => I(B) === j(l)) ?? null;
|
|
624
|
+
if (!(!p && T.length === 1 && j(T[0]) === j(l))) {
|
|
625
|
+
for (const B of T) r == null || r.unstageLink(k, B);
|
|
626
|
+
for (const B of G)
|
|
627
|
+
B !== p && !E.has(B.id) && (r == null || r.stageUnlink(k, B.id));
|
|
628
|
+
p ? E.has(p.id) && (r == null || r.unstageUnlink(k, p.id)) : r == null || r.stageLink(k, l);
|
|
629
|
+
}
|
|
630
|
+
K(!1), L("");
|
|
620
631
|
}
|
|
621
|
-
function
|
|
622
|
-
for (const
|
|
623
|
-
|
|
632
|
+
function it() {
|
|
633
|
+
for (const l of T) r == null || r.unstageLink(k, l);
|
|
634
|
+
S && (r == null || r.stageUnlink(k, S.id)), K(!1);
|
|
624
635
|
}
|
|
625
|
-
return v ? /* @__PURE__ */
|
|
636
|
+
return v ? /* @__PURE__ */ h(
|
|
626
637
|
"button",
|
|
627
638
|
{
|
|
628
639
|
type: "button",
|
|
629
640
|
disabled: !0,
|
|
630
641
|
className: "w-full h-9 px-3 text-[12px] border border-input rounded-md bg-background text-left flex items-center justify-between opacity-50 cursor-not-allowed",
|
|
631
642
|
children: [
|
|
632
|
-
/* @__PURE__ */
|
|
643
|
+
/* @__PURE__ */ h("span", { className: "truncate text-muted-foreground", children: [
|
|
633
644
|
"Select ",
|
|
634
645
|
v,
|
|
635
646
|
" first"
|
|
636
647
|
] }),
|
|
637
|
-
/* @__PURE__ */ n(
|
|
648
|
+
/* @__PURE__ */ n(he, { className: "h-4 w-4 shrink-0 opacity-50" })
|
|
638
649
|
]
|
|
639
650
|
}
|
|
640
|
-
) : /* @__PURE__ */
|
|
641
|
-
/* @__PURE__ */
|
|
642
|
-
|
|
651
|
+
) : /* @__PURE__ */ h("div", { ...Ae.bind, children: [
|
|
652
|
+
/* @__PURE__ */ h(
|
|
653
|
+
We,
|
|
643
654
|
{
|
|
644
|
-
open:
|
|
645
|
-
onOpenChange: (
|
|
646
|
-
|
|
655
|
+
open: y,
|
|
656
|
+
onOpenChange: (l) => {
|
|
657
|
+
K(l), l || L("");
|
|
647
658
|
},
|
|
648
659
|
children: [
|
|
649
|
-
/* @__PURE__ */ n(
|
|
660
|
+
/* @__PURE__ */ n(Ze, { asChild: !0, children: /* @__PURE__ */ h(
|
|
650
661
|
"button",
|
|
651
662
|
{
|
|
652
663
|
type: "button",
|
|
653
|
-
className:
|
|
664
|
+
className: X(
|
|
654
665
|
"w-full h-9 px-3 text-[12px] border rounded-md bg-background text-left flex items-center justify-between hover:bg-muted cursor-pointer transition-colors disabled:pointer-events-none disabled:opacity-50",
|
|
655
|
-
|
|
666
|
+
Se ? "border-amber-300 dark:border-amber-600" : se ? "border-nvr-cyan/50" : "border-input"
|
|
656
667
|
),
|
|
657
668
|
children: [
|
|
658
|
-
|
|
669
|
+
je || ee && N == null && s !== "new" ? /* @__PURE__ */ n(Ce, { className: "h-3.5 w-3.5 animate-spin text-muted-foreground" }) : /* @__PURE__ */ h(
|
|
659
670
|
"span",
|
|
660
671
|
{
|
|
661
|
-
className:
|
|
672
|
+
className: X(
|
|
662
673
|
"flex items-center gap-1.5 truncate min-w-0",
|
|
663
|
-
|
|
674
|
+
Ne ? se ? "text-nvr-cyan" : "text-slate-800 dark:text-slate-100" : "text-muted-foreground"
|
|
664
675
|
),
|
|
665
676
|
children: [
|
|
666
|
-
|
|
667
|
-
/* @__PURE__ */ n("span", { className: "truncate", children:
|
|
677
|
+
Se && /* @__PURE__ */ n(Ie, { className: "h-3.5 w-3.5 shrink-0 text-amber-500" }),
|
|
678
|
+
/* @__PURE__ */ n("span", { className: "truncate", children: Ne ?? "Select…" })
|
|
668
679
|
]
|
|
669
680
|
}
|
|
670
681
|
),
|
|
671
|
-
/* @__PURE__ */ n(
|
|
682
|
+
/* @__PURE__ */ n(he, { className: "h-4 w-4 shrink-0 opacity-50" })
|
|
672
683
|
]
|
|
673
684
|
}
|
|
674
685
|
) }),
|
|
675
|
-
/* @__PURE__ */ n(
|
|
676
|
-
|
|
686
|
+
/* @__PURE__ */ n(Qe, { className: "w-[320px] p-0", align: "start", children: /* @__PURE__ */ h(
|
|
687
|
+
Be,
|
|
677
688
|
{
|
|
678
689
|
shouldFilter: !1,
|
|
679
|
-
...
|
|
690
|
+
...we,
|
|
680
691
|
children: [
|
|
681
692
|
/* @__PURE__ */ n(
|
|
682
|
-
|
|
693
|
+
Ge,
|
|
683
694
|
{
|
|
684
695
|
placeholder: "Search…",
|
|
685
|
-
value:
|
|
686
|
-
onValueChange:
|
|
696
|
+
value: x,
|
|
697
|
+
onValueChange: L,
|
|
687
698
|
className: "h-9 text-[12px]"
|
|
688
699
|
}
|
|
689
700
|
),
|
|
690
|
-
|
|
701
|
+
_ != null && /* @__PURE__ */ h(
|
|
691
702
|
"button",
|
|
692
703
|
{
|
|
693
704
|
type: "button",
|
|
694
705
|
onClick: () => {
|
|
695
|
-
|
|
706
|
+
it(), K(!1);
|
|
696
707
|
},
|
|
697
708
|
className: "flex w-full items-center gap-2 px-3 py-1.5 text-[13px] text-slate-500 hover:bg-muted border-b border-slate-100 dark:text-slate-400 dark:border-border",
|
|
698
709
|
children: [
|
|
699
|
-
/* @__PURE__ */ n(
|
|
710
|
+
/* @__PURE__ */ n(qe, { className: "h-3.5 w-3.5 text-slate-400" }),
|
|
700
711
|
"Clear selection"
|
|
701
712
|
]
|
|
702
713
|
}
|
|
703
714
|
),
|
|
704
|
-
/* @__PURE__ */
|
|
705
|
-
|
|
706
|
-
!
|
|
715
|
+
/* @__PURE__ */ h(Re, { children: [
|
|
716
|
+
M ? /* @__PURE__ */ n("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ n(Ce, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : /* @__PURE__ */ n(Ve, { className: "py-3 text-left text-[12px] text-muted-foreground px-3", children: "No results" }),
|
|
717
|
+
!M && le && /* @__PURE__ */ h(
|
|
707
718
|
"p",
|
|
708
719
|
{
|
|
709
720
|
"data-picker-close-matches": !0,
|
|
710
721
|
className: "px-3 pb-1 pt-2 text-[11.5px] text-muted-foreground",
|
|
711
722
|
children: [
|
|
712
723
|
"No exact match for “",
|
|
713
|
-
|
|
724
|
+
x.trim(),
|
|
714
725
|
"” — did you mean:"
|
|
715
726
|
]
|
|
716
727
|
}
|
|
717
728
|
),
|
|
718
|
-
!
|
|
719
|
-
(
|
|
720
|
-
).map((
|
|
721
|
-
const
|
|
722
|
-
return /* @__PURE__ */
|
|
723
|
-
|
|
729
|
+
!M && /* @__PURE__ */ n($e, { children: [...xe(R, x, ce, z)].sort(
|
|
730
|
+
(l, p) => re ? 0 : Me(z(l), z(p), x, o === "-label")
|
|
731
|
+
).map((l) => {
|
|
732
|
+
const p = String(l.id), ae = String(_) === p;
|
|
733
|
+
return /* @__PURE__ */ h(
|
|
734
|
+
Ke,
|
|
724
735
|
{
|
|
725
|
-
value:
|
|
726
|
-
onSelect: () =>
|
|
736
|
+
value: p,
|
|
737
|
+
onSelect: () => Ue(l.id),
|
|
727
738
|
className: "flex items-center gap-2 text-[12px]",
|
|
728
739
|
children: [
|
|
729
740
|
/* @__PURE__ */ n(
|
|
730
741
|
"div",
|
|
731
742
|
{
|
|
732
|
-
className:
|
|
743
|
+
className: X(
|
|
733
744
|
"flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",
|
|
734
|
-
|
|
745
|
+
ae ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300 dark:border-slate-500"
|
|
735
746
|
),
|
|
736
|
-
children:
|
|
747
|
+
children: ae && /* @__PURE__ */ n(Oe, { className: "h-2.5 w-2.5 text-white" })
|
|
737
748
|
}
|
|
738
749
|
),
|
|
739
750
|
i === "nivaro_users" && /* @__PURE__ */ n(
|
|
740
|
-
|
|
751
|
+
ze,
|
|
741
752
|
{
|
|
742
|
-
userId:
|
|
753
|
+
userId: p,
|
|
743
754
|
className: "h-4 w-4",
|
|
744
|
-
fallback: /* @__PURE__ */ n("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-nvr-cyan/20 text-[8px] font-bold text-nvr-navy dark:text-nvr-cyan", children:
|
|
755
|
+
fallback: /* @__PURE__ */ n("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-nvr-cyan/20 text-[8px] font-bold text-nvr-navy dark:text-nvr-cyan", children: He(z(l)) })
|
|
745
756
|
}
|
|
746
757
|
),
|
|
747
|
-
i === "nivaro_users" &&
|
|
758
|
+
i === "nivaro_users" && ke.has(p.toUpperCase()) && /* @__PURE__ */ n(
|
|
748
759
|
"span",
|
|
749
760
|
{
|
|
750
761
|
className: "h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500",
|
|
751
762
|
"data-tip": "Online now"
|
|
752
763
|
}
|
|
753
764
|
),
|
|
754
|
-
/* @__PURE__ */ n("span", { className: "truncate", children: z(
|
|
765
|
+
/* @__PURE__ */ n("span", { className: "truncate", children: z(l) })
|
|
755
766
|
]
|
|
756
767
|
},
|
|
757
|
-
|
|
768
|
+
p
|
|
758
769
|
);
|
|
759
770
|
}) }),
|
|
760
771
|
/* @__PURE__ */ n(
|
|
761
|
-
|
|
772
|
+
et,
|
|
762
773
|
{
|
|
763
|
-
options:
|
|
764
|
-
isSelected: (
|
|
765
|
-
onPick: (
|
|
774
|
+
options: _e,
|
|
775
|
+
isSelected: (l) => de === l,
|
|
776
|
+
onPick: (l) => Ue(l),
|
|
766
777
|
round: !0
|
|
767
778
|
}
|
|
768
779
|
)
|
|
@@ -773,39 +784,39 @@ function zt({
|
|
|
773
784
|
]
|
|
774
785
|
}
|
|
775
786
|
),
|
|
776
|
-
|
|
787
|
+
Ae.tip
|
|
777
788
|
] });
|
|
778
789
|
}
|
|
779
|
-
function
|
|
780
|
-
const [d,
|
|
781
|
-
return
|
|
782
|
-
|
|
783
|
-
}, [
|
|
784
|
-
value: d ?? (
|
|
790
|
+
function st(t, s) {
|
|
791
|
+
const [d, a] = H(null), [o, v] = H(!1), g = Le(!1);
|
|
792
|
+
return Fe(() => {
|
|
793
|
+
a(null), g.current = !1;
|
|
794
|
+
}, [s]), t ? {
|
|
795
|
+
value: d ?? (o ? " " : ""),
|
|
785
796
|
onValueChange: (f) => {
|
|
786
|
-
|
|
797
|
+
g.current ? a(f) : v((m) => !m);
|
|
787
798
|
},
|
|
788
799
|
onKeyDownCapture: (f) => {
|
|
789
|
-
f.key === "ArrowDown" || f.key === "ArrowUp" ?
|
|
800
|
+
f.key === "ArrowDown" || f.key === "ArrowUp" ? g.current = !0 : f.key === "Enter" && !g.current && (f.preventDefault(), f.stopPropagation());
|
|
790
801
|
},
|
|
791
802
|
onPointerMoveCapture: () => {
|
|
792
|
-
|
|
803
|
+
g.current = !0;
|
|
793
804
|
}
|
|
794
805
|
} : {};
|
|
795
806
|
}
|
|
796
807
|
export {
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
808
|
+
Bt as M2MCombobox,
|
|
809
|
+
Gt as M2MSingleSelectCombobox,
|
|
810
|
+
Pe as OwnCollectionLabel,
|
|
811
|
+
Jt as m2aAllowedCount,
|
|
812
|
+
tt as m2aDiscriminator,
|
|
813
|
+
gt as m2aExtraCollections,
|
|
814
|
+
pe as m2aRowCollection,
|
|
815
|
+
be as m2aToken,
|
|
816
|
+
zt as m2aWriteMeta,
|
|
817
|
+
kt as m2mAsksServer,
|
|
818
|
+
j as m2mIdKey,
|
|
819
|
+
xe as narrowM2MOptions,
|
|
820
|
+
fe as parseM2aToken,
|
|
821
|
+
nt as resolveM2MRelatedCollection
|
|
811
822
|
};
|