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