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