@nivaro/react 0.3.25 → 0.3.27
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/item-edit/M2MCombobox.js +117 -116
- package/dist/shared/components/item-edit/RelationCombobox.js +173 -167
- package/dist/shared/components/panels/ItemLockBanner.js +354 -307
- package/dist/shared/lib/picker-rank.js +21 -0
- package/package.json +1 -1
|
@@ -9,7 +9,7 @@ import { noteReplayEvent as _e, createReplayCheckoutState as De } from "../share
|
|
|
9
9
|
import { emitReplayTap as Te, setReplayRecorderMode as N, registerReplayCapture as qe, clipEndOffset as Le, withClipKind as Pe } from "../shared/lib/replay-capture.js";
|
|
10
10
|
import { instrumentConsole as Ne, instrumentRequests as Fe, redactSecrets as Me } from "../shared/lib/replay-context.js";
|
|
11
11
|
import { instrumentSocket as Oe } from "../shared/lib/replay-socket.js";
|
|
12
|
-
const Ue = "nivaro-react@0.3.
|
|
12
|
+
const Ue = "nivaro-react@0.3.27", j = 1e4, We = 150, He = 3e3, Ke = 600, $e = (n) => `nvr_replay_resume${n ? `:${n}` : ""}`, G = () => typeof navigator > "u" || navigator.onLine !== !1;
|
|
13
13
|
function Be(n) {
|
|
14
14
|
return typeof n.url != "string" || typeof fetch != "function" ? null : (f, a) => {
|
|
15
15
|
const u = typeof n.getToken == "function" ? n.getToken() : void 0, d = { "Content-Type": "application/json" };
|
|
@@ -2,38 +2,39 @@ import { jsx as n, jsxs as c } from "react/jsx-runtime";
|
|
|
2
2
|
import { useQuery as w } from "@tanstack/react-query";
|
|
3
3
|
import { ChevronDown as te, Loader2 as ae, AlertTriangle as ce, X as oe, Check as de } from "lucide-react";
|
|
4
4
|
import { useState as ne, useRef as me, useEffect as ue } from "react";
|
|
5
|
-
import { useNivaroClient as fe, useItemEditAuth as pe, useDrilldown as
|
|
6
|
-
import { parseAllowedCollections as
|
|
7
|
-
import { get as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
return s.replace(/\(.*$/, "").trim().split(/\s+/).map((o) => o[0]).filter(Boolean).slice(0, 2).join("").toUpperCase() || "?";
|
|
19
|
-
}
|
|
5
|
+
import { useNivaroClient as fe, useItemEditAuth as pe, useDrilldown as Ie } from "../../context.js";
|
|
6
|
+
import { parseAllowedCollections as Ae } from "../../lib/allowed-collections.js";
|
|
7
|
+
import { get as q } from "../../lib/commands.js";
|
|
8
|
+
import { compareByMatch as he } from "../../lib/picker-rank.js";
|
|
9
|
+
import { useRecordReader as Ke } from "../../lib/record-loader.js";
|
|
10
|
+
import { useOnlineUsers as be } from "../../lib/use-online-users.js";
|
|
11
|
+
import { cn as Q, userOptionFilter as ye } from "../../lib/utils.js";
|
|
12
|
+
import { UserAvatar as xe } from "../UserAvatar.js";
|
|
13
|
+
import { Command as ve, CommandInput as ge, CommandList as ke, CommandEmpty as we, CommandGroup as Ne, CommandItem as Se } from "../ui/command.js";
|
|
14
|
+
import { Popover as _e, PopoverTrigger as qe, PopoverContent as Ce } from "../ui/popover.js";
|
|
15
|
+
import { applyDisplayTemplate as Le } from "./helpers.js";
|
|
16
|
+
import { useM2MStaging as je } from "./M2MStagingContext.js";
|
|
17
|
+
import { useStaleTip as Je, RelatedItemLabel as ie } from "./RelationCombobox.js";
|
|
20
18
|
function Fe(s) {
|
|
21
|
-
return
|
|
19
|
+
return s.replace(/\(.*$/, "").trim().split(/\s+/).map((o) => o[0]).filter(Boolean).slice(0, 2).join("").toUpperCase() || "?";
|
|
22
20
|
}
|
|
23
21
|
function Te(s) {
|
|
22
|
+
return Ae(s == null ? void 0 : s.one_allowed_collections);
|
|
23
|
+
}
|
|
24
|
+
function Oe(s) {
|
|
24
25
|
if (!s) return null;
|
|
25
26
|
if (s.one_collection) return s.one_collection;
|
|
26
|
-
const o =
|
|
27
|
+
const o = Te(s);
|
|
27
28
|
return o.length === 0 ? null : o.some((N) => N === "directus_users" || N === "nivaro_users") ? "nivaro_users" : o[0];
|
|
28
29
|
}
|
|
29
|
-
function
|
|
30
|
+
function nt(s) {
|
|
30
31
|
if (!s || s.one_collection) return null;
|
|
31
|
-
const o =
|
|
32
|
+
const o = Te(s);
|
|
32
33
|
if (o.length === 0) return null;
|
|
33
34
|
const N = o.includes("directus_users") ? "directus_users" : o.includes("nivaro_users") ? "nivaro_users" : o[0];
|
|
34
35
|
return { field: s.one_collection_field ?? "collection", value: N };
|
|
35
36
|
}
|
|
36
|
-
function
|
|
37
|
+
function lt({
|
|
37
38
|
relation: s,
|
|
38
39
|
parentId: o,
|
|
39
40
|
allRelations: N,
|
|
@@ -43,57 +44,57 @@ function tt({
|
|
|
43
44
|
onCountChange: J,
|
|
44
45
|
drilldown: D
|
|
45
46
|
}) {
|
|
46
|
-
const y = fe(), W =
|
|
47
|
+
const y = fe(), W = Ie(), t = je(), [P, C] = ne(!1), [x, T] = ne(""), le = N.find(
|
|
47
48
|
(e) => e.many_collection === s.many_collection && e.many_field === s.junction_field && e.id !== s.id
|
|
48
|
-
), r =
|
|
49
|
+
), r = Oe(le), v = s.junction_field ?? "", R = s.many_field ?? "", d = s.one_field ?? `${s.many_collection}.${v}`, { data: a } = w({
|
|
49
50
|
queryKey: ["col-meta", r],
|
|
50
|
-
queryFn: () => y.request(
|
|
51
|
+
queryFn: () => y.request(q(`/collections/${r}`)).then((e) => e.data),
|
|
51
52
|
enabled: !!r,
|
|
52
53
|
staleTime: 3e5,
|
|
53
54
|
retry: !1
|
|
54
55
|
}), { data: X = [] } = w({
|
|
55
56
|
queryKey: ["m2m-items", s.many_collection, R, o],
|
|
56
57
|
queryFn: () => y.request(
|
|
57
|
-
|
|
58
|
+
q(`/items/${s.many_collection}`, {
|
|
58
59
|
filter: JSON.stringify({ [R]: { _eq: o } }),
|
|
59
60
|
limit: 200,
|
|
60
|
-
fields: `id,${
|
|
61
|
+
fields: `id,${v}`
|
|
61
62
|
})
|
|
62
63
|
).then((e) => e.data ?? []),
|
|
63
64
|
staleTime: 3e4,
|
|
64
65
|
enabled: !!o && o !== "new"
|
|
65
|
-
}), re = pe().isAdmin, z = r === "nivaro_users" ?
|
|
66
|
+
}), re = pe().isAdmin, z = r === "nivaro_users" ? ye(re) : null, E = be(r === "nivaro_users"), H = h ? z ? { _and: [h, z] } : h : z, L = H ? JSON.stringify(H) : void 0, g = b && !/^-?label$/.test(b) ? b : void 0, S = (() => {
|
|
66
67
|
const e = a == null ? void 0 : a.display_template;
|
|
67
68
|
if (!e || !e.includes(".")) return null;
|
|
68
69
|
const i = [...e.matchAll(/\{\{([^}]+)\}\}/g)].map((u) => u[1].trim());
|
|
69
70
|
return i.length === 0 ? null : ["id", ...i].join(",");
|
|
70
|
-
})(), { data: O = [], isFetching:
|
|
71
|
+
})(), { data: O = [], isFetching: B } = w({
|
|
71
72
|
queryKey: [
|
|
72
73
|
"m2m-options",
|
|
73
74
|
r,
|
|
75
|
+
x,
|
|
74
76
|
L,
|
|
75
|
-
|
|
76
|
-
v ?? "",
|
|
77
|
+
g ?? "",
|
|
77
78
|
S ?? ""
|
|
78
79
|
],
|
|
79
80
|
queryFn: () => y.request(
|
|
80
|
-
|
|
81
|
+
q(`/items/${r}`, {
|
|
81
82
|
limit: 200,
|
|
82
|
-
search:
|
|
83
|
-
filter:
|
|
83
|
+
search: x || void 0,
|
|
84
|
+
filter: L,
|
|
84
85
|
picker: "1",
|
|
85
86
|
// A dotted display template ({{core_category.name}}) needs the
|
|
86
87
|
// nested expansion — a bare row only carries the FK id.
|
|
87
88
|
...S ? { fields: S } : {},
|
|
88
|
-
...
|
|
89
|
+
...g ? { sort: g } : {}
|
|
89
90
|
})
|
|
90
91
|
).then((e) => e.data ?? []),
|
|
91
92
|
enabled: P && !!r,
|
|
92
|
-
staleTime:
|
|
93
|
-
}),
|
|
94
|
-
queryKey: ["m2m-avail", r, _.join(","),
|
|
93
|
+
staleTime: L ? 0 : 3e4
|
|
94
|
+
}), V = (t == null ? void 0 : t.getStagedLinks(d)) ?? [], k = (t == null ? void 0 : t.getStagedUnlinks(d)) ?? /* @__PURE__ */ new Set(), U = X.filter((e) => !k.has(e.id)), f = new Set(U.map((e) => String(e[v]))), _ = [...f], Y = JSON.stringify(h ? { _and: [{ id: { _in: _ } }, h] } : { id: { _in: _ } }), { data: m } = w({
|
|
95
|
+
queryKey: ["m2m-avail", r, _.join(","), L],
|
|
95
96
|
queryFn: () => y.request(
|
|
96
|
-
|
|
97
|
+
q(`/items/${r}`, {
|
|
97
98
|
filter: Y,
|
|
98
99
|
picker: "1",
|
|
99
100
|
limit: 200,
|
|
@@ -102,10 +103,10 @@ function tt({
|
|
|
102
103
|
).then((e) => e.data ?? []),
|
|
103
104
|
enabled: !!r && _.length > 0,
|
|
104
105
|
staleTime: 3e4
|
|
105
|
-
}), Z = new Set((m ?? []).map((e) => String(e.id))), $ = m !== void 0 ? new Set(_.filter((e) => !Z.has(e))) : /* @__PURE__ */ new Set(), I = new Set(
|
|
106
|
-
|
|
106
|
+
}), Z = new Set((m ?? []).map((e) => String(e.id))), $ = m !== void 0 ? new Set(_.filter((e) => !Z.has(e))) : /* @__PURE__ */ new Set(), I = new Set(V.map(String)), A = /* @__PURE__ */ new Set([...f, ...I]), j = me(J);
|
|
107
|
+
j.current = J, ue(() => {
|
|
107
108
|
var e;
|
|
108
|
-
(e =
|
|
109
|
+
(e = j.current) == null || e.call(j, A.size);
|
|
109
110
|
}, [A.size]);
|
|
110
111
|
function G(e) {
|
|
111
112
|
const i = String(e);
|
|
@@ -113,16 +114,16 @@ function tt({
|
|
|
113
114
|
t == null || t.unstageLink(d, e);
|
|
114
115
|
return;
|
|
115
116
|
}
|
|
116
|
-
const u = X.find((M) => String(M[
|
|
117
|
+
const u = X.find((M) => String(M[v]) === i);
|
|
117
118
|
if (u) {
|
|
118
|
-
|
|
119
|
+
k.has(u.id) ? t == null || t.unstageUnlink(d, u.id) : t == null || t.stageUnlink(d, u.id);
|
|
119
120
|
return;
|
|
120
121
|
}
|
|
121
122
|
t == null || t.stageLink(d, e);
|
|
122
123
|
}
|
|
123
|
-
function
|
|
124
|
+
function F(e) {
|
|
124
125
|
const i = (a == null ? void 0 : a.display_template) ?? null;
|
|
125
|
-
return i ?
|
|
126
|
+
return i ? Le(i, e) : String(e._display ?? e.id ?? "");
|
|
126
127
|
}
|
|
127
128
|
return K ? /* @__PURE__ */ c(
|
|
128
129
|
"button",
|
|
@@ -140,20 +141,20 @@ function tt({
|
|
|
140
141
|
]
|
|
141
142
|
}
|
|
142
143
|
) : /* @__PURE__ */ n("div", { children: /* @__PURE__ */ c(
|
|
143
|
-
|
|
144
|
+
_e,
|
|
144
145
|
{
|
|
145
146
|
open: P,
|
|
146
147
|
onOpenChange: (e) => {
|
|
147
|
-
|
|
148
|
+
C(e), e || T("");
|
|
148
149
|
},
|
|
149
150
|
children: [
|
|
150
|
-
/* @__PURE__ */ n(
|
|
151
|
+
/* @__PURE__ */ n(qe, { asChild: !0, children: /* @__PURE__ */ c(
|
|
151
152
|
"div",
|
|
152
153
|
{
|
|
153
154
|
role: "button",
|
|
154
155
|
tabIndex: 0,
|
|
155
156
|
onKeyDown: (e) => {
|
|
156
|
-
(e.key === "Enter" || e.key === " ") && (e.preventDefault(),
|
|
157
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), C((i) => !i));
|
|
157
158
|
},
|
|
158
159
|
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
160
|
children: [
|
|
@@ -166,7 +167,7 @@ function tt({
|
|
|
166
167
|
},
|
|
167
168
|
children: [
|
|
168
169
|
U.map((e) => {
|
|
169
|
-
const i = e[
|
|
170
|
+
const i = e[v], u = $.has(String(i));
|
|
170
171
|
return /* @__PURE__ */ c(
|
|
171
172
|
"span",
|
|
172
173
|
{
|
|
@@ -221,7 +222,7 @@ function tt({
|
|
|
221
222
|
String(e.id)
|
|
222
223
|
);
|
|
223
224
|
}),
|
|
224
|
-
|
|
225
|
+
V.map((e) => /* @__PURE__ */ c(
|
|
225
226
|
"span",
|
|
226
227
|
{
|
|
227
228
|
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",
|
|
@@ -255,24 +256,24 @@ function tt({
|
|
|
255
256
|
]
|
|
256
257
|
}
|
|
257
258
|
) }),
|
|
258
|
-
/* @__PURE__ */ n(Ce, { className: "w-[320px] p-0", align: "start", children: /* @__PURE__ */ c(
|
|
259
|
+
/* @__PURE__ */ n(Ce, { className: "w-[320px] p-0", align: "start", children: /* @__PURE__ */ c(ve, { shouldFilter: !1, children: [
|
|
259
260
|
/* @__PURE__ */ n(
|
|
260
|
-
|
|
261
|
+
ge,
|
|
261
262
|
{
|
|
262
263
|
placeholder: "Search…",
|
|
263
|
-
value:
|
|
264
|
+
value: x,
|
|
264
265
|
onValueChange: T,
|
|
265
266
|
className: "h-9 text-[13px]"
|
|
266
267
|
}
|
|
267
268
|
),
|
|
268
|
-
/* @__PURE__ */ c(
|
|
269
|
-
|
|
270
|
-
/* @__PURE__ */ n(
|
|
271
|
-
(e, i) => b === "-label"
|
|
269
|
+
/* @__PURE__ */ c(ke, { children: [
|
|
270
|
+
B ? /* @__PURE__ */ n("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ n(ae, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : /* @__PURE__ */ n(we, { className: "py-3 text-left text-[12px] text-muted-foreground px-3", children: "No results" }),
|
|
271
|
+
/* @__PURE__ */ n(Ne, { children: !B && (g ? [...O] : [...O].sort(
|
|
272
|
+
(e, i) => he(F(e), F(i), x, b === "-label")
|
|
272
273
|
)).map((e) => {
|
|
273
274
|
const i = String(e.id), u = A.has(i);
|
|
274
275
|
return /* @__PURE__ */ c(
|
|
275
|
-
|
|
276
|
+
Se,
|
|
276
277
|
{
|
|
277
278
|
value: i,
|
|
278
279
|
onSelect: () => G(e.id),
|
|
@@ -289,11 +290,11 @@ function tt({
|
|
|
289
290
|
}
|
|
290
291
|
),
|
|
291
292
|
r === "nivaro_users" && /* @__PURE__ */ n(
|
|
292
|
-
|
|
293
|
+
xe,
|
|
293
294
|
{
|
|
294
295
|
userId: i,
|
|
295
296
|
className: "h-4 w-4",
|
|
296
|
-
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:
|
|
297
|
+
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: Fe(F(e)) })
|
|
297
298
|
}
|
|
298
299
|
),
|
|
299
300
|
r === "nivaro_users" && E.has(i.toUpperCase()) && /* @__PURE__ */ n(
|
|
@@ -303,7 +304,7 @@ function tt({
|
|
|
303
304
|
"data-tip": "Online now"
|
|
304
305
|
}
|
|
305
306
|
),
|
|
306
|
-
/* @__PURE__ */ n("span", { className: "truncate", children:
|
|
307
|
+
/* @__PURE__ */ n("span", { className: "truncate", children: F(e) })
|
|
307
308
|
]
|
|
308
309
|
},
|
|
309
310
|
i
|
|
@@ -315,7 +316,7 @@ function tt({
|
|
|
315
316
|
}
|
|
316
317
|
) });
|
|
317
318
|
}
|
|
318
|
-
function
|
|
319
|
+
function rt({
|
|
319
320
|
relation: s,
|
|
320
321
|
parentId: o,
|
|
321
322
|
allRelations: N,
|
|
@@ -325,44 +326,44 @@ function nt({
|
|
|
325
326
|
onCountChange: J,
|
|
326
327
|
readOnly: D
|
|
327
328
|
}) {
|
|
328
|
-
const y = fe(), W =
|
|
329
|
+
const y = fe(), W = Ke(), t = je(), [P, C] = ne(!1), [x, T] = ne(""), le = N.find(
|
|
329
330
|
(l) => l.many_collection === s.many_collection && l.many_field === s.junction_field && l.id !== s.id
|
|
330
|
-
), r =
|
|
331
|
+
), r = Oe(le), v = s.junction_field ?? "", R = s.many_field ?? "", d = s.one_field ?? `${s.many_collection}.${v}`, { data: a } = w({
|
|
331
332
|
queryKey: ["col-meta", r],
|
|
332
|
-
queryFn: () => y.request(
|
|
333
|
+
queryFn: () => y.request(q(`/collections/${r}`)).then((l) => l.data),
|
|
333
334
|
enabled: !!r,
|
|
334
335
|
staleTime: 3e5,
|
|
335
336
|
retry: !1
|
|
336
337
|
}), { data: X = [], isFetching: re } = w({
|
|
337
338
|
queryKey: ["m2m-items", s.many_collection, R, o],
|
|
338
339
|
queryFn: () => y.request(
|
|
339
|
-
|
|
340
|
+
q(`/items/${s.many_collection}`, {
|
|
340
341
|
filter: JSON.stringify({ [R]: { _eq: o } }),
|
|
341
342
|
limit: 1,
|
|
342
|
-
fields: `id,${
|
|
343
|
+
fields: `id,${v}`
|
|
343
344
|
})
|
|
344
345
|
).then((l) => l.data ?? []),
|
|
345
346
|
staleTime: 3e4,
|
|
346
347
|
enabled: !!o && o !== "new"
|
|
347
|
-
}), z = pe().isAdmin, E = r === "nivaro_users" ?
|
|
348
|
+
}), z = pe().isAdmin, E = r === "nivaro_users" ? ye(z) : null, H = be(r === "nivaro_users"), L = h ? E ? { _and: [h, E] } : h : E, g = L ? JSON.stringify(L) : void 0, S = b && !/^-?label$/.test(b) ? b : void 0, O = (() => {
|
|
348
349
|
const l = a == null ? void 0 : a.display_template;
|
|
349
350
|
if (!l || !l.includes(".")) return null;
|
|
350
|
-
const
|
|
351
|
-
return
|
|
352
|
-
})(), { data:
|
|
351
|
+
const p = [...l.matchAll(/\{\{([^}]+)\}\}/g)].map((ee) => ee[1].trim());
|
|
352
|
+
return p.length === 0 ? null : ["id", ...p].join(",");
|
|
353
|
+
})(), { data: B = [], isFetching: V } = w({
|
|
353
354
|
queryKey: [
|
|
354
355
|
"m2m-options",
|
|
355
356
|
r,
|
|
356
|
-
|
|
357
|
-
|
|
357
|
+
x,
|
|
358
|
+
g,
|
|
358
359
|
S ?? "",
|
|
359
360
|
O ?? ""
|
|
360
361
|
],
|
|
361
362
|
queryFn: () => y.request(
|
|
362
|
-
|
|
363
|
+
q(`/items/${r}`, {
|
|
363
364
|
limit: 200,
|
|
364
|
-
search:
|
|
365
|
-
filter:
|
|
365
|
+
search: x || void 0,
|
|
366
|
+
filter: g,
|
|
366
367
|
picker: "1",
|
|
367
368
|
// A dotted display template ({{core_category.name}}) needs the
|
|
368
369
|
// nested expansion — a bare row only carries the FK id.
|
|
@@ -371,8 +372,8 @@ function nt({
|
|
|
371
372
|
})
|
|
372
373
|
).then((l) => l.data ?? []),
|
|
373
374
|
enabled: P && !!r,
|
|
374
|
-
staleTime:
|
|
375
|
-
}),
|
|
375
|
+
staleTime: g ? 0 : 3e4
|
|
376
|
+
}), k = (t == null ? void 0 : t.getStagedLinks(d)) ?? [], U = (t == null ? void 0 : t.getStagedUnlinks(d)) ?? /* @__PURE__ */ new Set(), f = X.find((l) => !U.has(l.id)) ?? null, _ = f ? f[v] : null, Y = k.length > 0 ? k[k.length - 1] : null, m = Y ?? _, Z = k.length > 0 || U.size > 0, $ = me(J);
|
|
376
377
|
$.current = J, ue(() => {
|
|
377
378
|
var l;
|
|
378
379
|
(l = $.current) == null || l.call($, m != null ? 1 : 0);
|
|
@@ -382,10 +383,10 @@ function nt({
|
|
|
382
383
|
queryFn: () => W(r, m),
|
|
383
384
|
enabled: !!r && m != null,
|
|
384
385
|
staleTime: 6e4
|
|
385
|
-
}), A = JSON.stringify(h ? { _and: [{ id: { _eq: m } }, h] } : { id: { _eq: m } }), { data:
|
|
386
|
-
queryKey: ["relation-avail", r, String(m),
|
|
386
|
+
}), A = JSON.stringify(h ? { _and: [{ id: { _eq: m } }, h] } : { id: { _eq: m } }), { data: j } = w({
|
|
387
|
+
queryKey: ["relation-avail", r, String(m), g],
|
|
387
388
|
queryFn: () => y.request(
|
|
388
|
-
|
|
389
|
+
q(`/items/${r}`, {
|
|
389
390
|
filter: A,
|
|
390
391
|
picker: "1",
|
|
391
392
|
limit: 1,
|
|
@@ -394,20 +395,20 @@ function nt({
|
|
|
394
395
|
).then((l) => l.data ?? []),
|
|
395
396
|
enabled: !!r && m != null && !!I,
|
|
396
397
|
staleTime: 3e4
|
|
397
|
-
}), G =
|
|
398
|
+
}), G = j !== void 0 && j.length === 0, F = Je(G), e = (a == null ? void 0 : a.display_template) ?? null;
|
|
398
399
|
function i(l) {
|
|
399
|
-
return e ?
|
|
400
|
+
return e ? Le(e, l) : String(l.name ?? l.title ?? l.label ?? l.id ?? "");
|
|
400
401
|
}
|
|
401
|
-
const u =
|
|
402
|
+
const u = B.find((l) => String(l.id) === String(m)) ?? I, M = m != null && !I && !u, se = u ? i(u) : null;
|
|
402
403
|
if (D)
|
|
403
404
|
return /* @__PURE__ */ n("span", { className: "block truncate text-[12px] text-slate-700 dark:text-slate-200", children: M ? "…" : se ?? "—" });
|
|
404
|
-
function
|
|
405
|
-
for (const
|
|
406
|
-
|
|
405
|
+
function Ue(l) {
|
|
406
|
+
for (const p of k) t == null || t.unstageLink(d, p);
|
|
407
|
+
f && !U.has(f.id) && (t == null || t.stageUnlink(d, f.id)), String(l) === String(_) && f ? t == null || t.unstageUnlink(d, f.id) : String(l) !== String(m) && (t == null || t.stageLink(d, l)), C(!1), T("");
|
|
407
408
|
}
|
|
408
|
-
function
|
|
409
|
-
for (const l of
|
|
410
|
-
|
|
409
|
+
function $e() {
|
|
410
|
+
for (const l of k) t == null || t.unstageLink(d, l);
|
|
411
|
+
f && (t == null || t.stageUnlink(d, f.id)), C(!1);
|
|
411
412
|
}
|
|
412
413
|
return K ? /* @__PURE__ */ c(
|
|
413
414
|
"button",
|
|
@@ -424,16 +425,16 @@ function nt({
|
|
|
424
425
|
/* @__PURE__ */ n(te, { className: "h-4 w-4 shrink-0 opacity-50" })
|
|
425
426
|
]
|
|
426
427
|
}
|
|
427
|
-
) : /* @__PURE__ */ c("div", { ...
|
|
428
|
+
) : /* @__PURE__ */ c("div", { ...F.bind, children: [
|
|
428
429
|
/* @__PURE__ */ c(
|
|
429
|
-
|
|
430
|
+
_e,
|
|
430
431
|
{
|
|
431
432
|
open: P,
|
|
432
433
|
onOpenChange: (l) => {
|
|
433
|
-
|
|
434
|
+
C(l), l || T("");
|
|
434
435
|
},
|
|
435
436
|
children: [
|
|
436
|
-
/* @__PURE__ */ n(
|
|
437
|
+
/* @__PURE__ */ n(qe, { asChild: !0, children: /* @__PURE__ */ c(
|
|
437
438
|
"button",
|
|
438
439
|
{
|
|
439
440
|
type: "button",
|
|
@@ -459,12 +460,12 @@ function nt({
|
|
|
459
460
|
]
|
|
460
461
|
}
|
|
461
462
|
) }),
|
|
462
|
-
/* @__PURE__ */ n(Ce, { className: "w-[320px] p-0", align: "start", children: /* @__PURE__ */ c(
|
|
463
|
+
/* @__PURE__ */ n(Ce, { className: "w-[320px] p-0", align: "start", children: /* @__PURE__ */ c(ve, { shouldFilter: !1, children: [
|
|
463
464
|
/* @__PURE__ */ n(
|
|
464
|
-
|
|
465
|
+
ge,
|
|
465
466
|
{
|
|
466
467
|
placeholder: "Search…",
|
|
467
|
-
value:
|
|
468
|
+
value: x,
|
|
468
469
|
onValueChange: T,
|
|
469
470
|
className: "h-9 text-[12px]"
|
|
470
471
|
}
|
|
@@ -474,7 +475,7 @@ function nt({
|
|
|
474
475
|
{
|
|
475
476
|
type: "button",
|
|
476
477
|
onClick: () => {
|
|
477
|
-
|
|
478
|
+
$e(), C(!1);
|
|
478
479
|
},
|
|
479
480
|
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",
|
|
480
481
|
children: [
|
|
@@ -483,17 +484,17 @@ function nt({
|
|
|
483
484
|
]
|
|
484
485
|
}
|
|
485
486
|
),
|
|
486
|
-
/* @__PURE__ */ c(
|
|
487
|
-
|
|
488
|
-
!
|
|
489
|
-
(l,
|
|
487
|
+
/* @__PURE__ */ c(ke, { children: [
|
|
488
|
+
V ? /* @__PURE__ */ n("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ n(ae, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : /* @__PURE__ */ n(we, { className: "py-3 text-left text-[12px] text-muted-foreground px-3", children: "No results" }),
|
|
489
|
+
!V && /* @__PURE__ */ n(Ne, { children: [...B].sort(
|
|
490
|
+
(l, p) => S ? 0 : he(i(l), i(p), x, b === "-label")
|
|
490
491
|
).map((l) => {
|
|
491
|
-
const
|
|
492
|
+
const p = String(l.id), ee = String(m) === p;
|
|
492
493
|
return /* @__PURE__ */ c(
|
|
493
|
-
|
|
494
|
+
Se,
|
|
494
495
|
{
|
|
495
|
-
value:
|
|
496
|
-
onSelect: () =>
|
|
496
|
+
value: p,
|
|
497
|
+
onSelect: () => Ue(l.id),
|
|
497
498
|
className: "flex items-center gap-2 text-[12px]",
|
|
498
499
|
children: [
|
|
499
500
|
/* @__PURE__ */ n(
|
|
@@ -507,14 +508,14 @@ function nt({
|
|
|
507
508
|
}
|
|
508
509
|
),
|
|
509
510
|
r === "nivaro_users" && /* @__PURE__ */ n(
|
|
510
|
-
|
|
511
|
+
xe,
|
|
511
512
|
{
|
|
512
|
-
userId:
|
|
513
|
+
userId: p,
|
|
513
514
|
className: "h-4 w-4",
|
|
514
|
-
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:
|
|
515
|
+
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: Fe(i(l)) })
|
|
515
516
|
}
|
|
516
517
|
),
|
|
517
|
-
r === "nivaro_users" && H.has(
|
|
518
|
+
r === "nivaro_users" && H.has(p.toUpperCase()) && /* @__PURE__ */ n(
|
|
518
519
|
"span",
|
|
519
520
|
{
|
|
520
521
|
className: "h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500",
|
|
@@ -524,7 +525,7 @@ function nt({
|
|
|
524
525
|
/* @__PURE__ */ n("span", { className: "truncate", children: i(l) })
|
|
525
526
|
]
|
|
526
527
|
},
|
|
527
|
-
|
|
528
|
+
p
|
|
528
529
|
);
|
|
529
530
|
}) })
|
|
530
531
|
] })
|
|
@@ -532,12 +533,12 @@ function nt({
|
|
|
532
533
|
]
|
|
533
534
|
}
|
|
534
535
|
),
|
|
535
|
-
|
|
536
|
+
F.tip
|
|
536
537
|
] });
|
|
537
538
|
}
|
|
538
539
|
export {
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
540
|
+
lt as M2MCombobox,
|
|
541
|
+
rt as M2MSingleSelectCombobox,
|
|
542
|
+
nt as m2aWriteMeta,
|
|
543
|
+
Oe as resolveM2MRelatedCollection
|
|
543
544
|
};
|