@nivaro/react 0.3.10 → 0.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/full.css +1 -1
- package/dist/hooks/useNivaroForm.js +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +34 -3
- package/dist/shared/components/CollectionBrowserView.js +1546 -1477
- package/dist/shared/components/ItemEditForm.js +4332 -4195
- package/dist/shared/components/PageRenderer.js +512 -465
- package/dist/shared/components/QueryStatStrip.js +74 -70
- package/dist/shared/components/ReportView.js +818 -827
- package/dist/shared/components/SheetHeaderBody.js +16 -14
- package/dist/shared/components/item-edit/CatalogPickerField.js +1029 -933
- package/dist/shared/components/item-edit/FieldRenderer.js +161 -156
- package/dist/shared/components/item-edit/FieldRow.js +20 -19
- package/dist/shared/components/item-edit/FilePickerField.js +52 -40
- package/dist/shared/components/item-edit/GroupSection.js +221 -221
- package/dist/shared/components/item-edit/InlineGridField.js +41 -41
- package/dist/shared/components/item-edit/InlineTableField.js +2249 -2238
- package/dist/shared/components/item-edit/M2MCombobox.js +46 -44
- package/dist/shared/components/item-edit/NestedRelationEditor.js +11 -11
- package/dist/shared/components/item-edit/QuickPicker.js +263 -216
- package/dist/shared/components/item-edit/RelationCombobox.js +285 -245
- package/dist/shared/components/item-edit/RichTextEditorImpl.js +42 -32
- package/dist/shared/components/item-edit/RowHistorySheet.js +130 -134
- package/dist/shared/components/item-edit/SummaryPanel.js +305 -279
- package/dist/shared/components/item-edit/helpers.js +133 -134
- package/dist/shared/components/item-edit/line-qty.js +57 -0
- package/dist/shared/components/item-edit/option-disambiguate.js +53 -0
- package/dist/shared/components/panels/AddendumLinesDiff.js +87 -90
- package/dist/shared/components/panels/CommentPanel.js +350 -315
- package/dist/shared/components/panels/ItemLockBanner.js +297 -230
- package/dist/shared/components/panels/PipelinePanel.js +719 -701
- package/dist/shared/components/queue/QueueQuickFilters.js +43 -41
- package/dist/shared/components/queue/QueueWorklist.js +1005 -935
- package/dist/shared/components/widgets/ReviewListWidget.js +99 -93
- package/dist/shared/lib/obligation-banner.js +14 -13
- package/dist/shared/lib/obligation-reason-text.js +13 -0
- package/dist/shared/lib/query-filter-seed.js +34 -11
- package/dist/shared/lib/sanitize-html.js +24 -15
- package/dist/shared/lib/sheet-def.js +38 -22
- package/dist/shared/lib/unique-options.js +10 -0
- package/dist/shared/lib/utils.js +57 -43
- package/dist/shared/lib/validation-rules.js +58 -34
- package/package.json +1 -1
|
@@ -1,185 +1,186 @@
|
|
|
1
|
-
import { jsxs as c, jsx as
|
|
1
|
+
import { jsxs as c, jsx as n } from "react/jsx-runtime";
|
|
2
2
|
import { useQuery as k } from "@tanstack/react-query";
|
|
3
|
-
import { ChevronDown as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { createPortal as
|
|
6
|
-
import { useNivaroClient as
|
|
7
|
-
import { get as
|
|
8
|
-
import { useRecordReader as
|
|
9
|
-
import { useOnlineUsers as
|
|
10
|
-
import { UserAvatar as
|
|
11
|
-
import { userOptionFilter as
|
|
12
|
-
import { applyDisplayTemplate as
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
import { ChevronDown as Ne, Loader2 as ne, AlertTriangle as Ee, Search as Oe, X as Ie, Check as ke } from "lucide-react";
|
|
4
|
+
import { useState as q, useRef as X, useEffect as E, useLayoutEffect as Ke, useMemo as U } from "react";
|
|
5
|
+
import { createPortal as Se } from "react-dom";
|
|
6
|
+
import { useNivaroClient as se, useItemEditAuth as Ae, useStaleFieldReporter as Ue } from "../../context.js";
|
|
7
|
+
import { get as $, post as Me } from "../../lib/commands.js";
|
|
8
|
+
import { useRecordReader as _e } from "../../lib/record-loader.js";
|
|
9
|
+
import { useOnlineUsers as Pe } from "../../lib/use-online-users.js";
|
|
10
|
+
import { UserAvatar as De } from "../UserAvatar.js";
|
|
11
|
+
import { userOptionFilter as Je, cn as M } from "../../lib/utils.js";
|
|
12
|
+
import { applyDisplayTemplate as v } from "./helpers.js";
|
|
13
|
+
import { collidingIds as ze, disambiguators as Qe } from "./option-disambiguate.js";
|
|
14
|
+
import { usePickerMissReport as He } from "./picker-miss.js";
|
|
15
|
+
function Ye(s) {
|
|
16
|
+
return s.replace(/\(.*$/, "").trim().split(/\s+/).map((r) => r[0]).filter(Boolean).slice(0, 2).join("").toUpperCase() || "?";
|
|
16
17
|
}
|
|
17
|
-
function
|
|
18
|
-
const [
|
|
18
|
+
function We(s) {
|
|
19
|
+
const [r, d] = q(null), h = {
|
|
19
20
|
onMouseEnter: (f) => {
|
|
20
21
|
if (!s) return;
|
|
21
22
|
const m = f.currentTarget.getBoundingClientRect(), u = window.innerHeight - m.bottom < 80;
|
|
22
23
|
d({ x: m.left, y: u ? m.top - 58 : m.bottom + 4 });
|
|
23
24
|
},
|
|
24
25
|
onMouseLeave: () => d(null)
|
|
25
|
-
},
|
|
26
|
-
/* @__PURE__ */
|
|
26
|
+
}, S = s && r ? Se(
|
|
27
|
+
/* @__PURE__ */ n(
|
|
27
28
|
"div",
|
|
28
29
|
{
|
|
29
|
-
style: { position: "fixed", left:
|
|
30
|
+
style: { position: "fixed", left: r.x, top: r.y, zIndex: 130 },
|
|
30
31
|
className: "pointer-events-none max-w-[300px] rounded-md border border-amber-200 bg-amber-50 px-2.5 py-1.5 text-[11.5px] leading-snug text-amber-800 shadow-md dark:border-amber-500/40 dark:bg-[#2a2113] dark:text-amber-300",
|
|
31
32
|
children: "Current value is not an available option — clear to pick another"
|
|
32
33
|
}
|
|
33
34
|
),
|
|
34
35
|
document.body
|
|
35
36
|
) : null;
|
|
36
|
-
return { bind: h, tip:
|
|
37
|
+
return { bind: h, tip: S };
|
|
37
38
|
}
|
|
38
|
-
function
|
|
39
|
+
function Xe({
|
|
39
40
|
collection: s,
|
|
40
|
-
value:
|
|
41
|
+
value: r,
|
|
41
42
|
onChange: d,
|
|
42
43
|
disabled: h,
|
|
43
|
-
placeholder:
|
|
44
|
+
placeholder: S,
|
|
44
45
|
extraFilter: f,
|
|
45
46
|
autoSelectSingle: m,
|
|
46
47
|
optionSort: u,
|
|
47
|
-
requiredParent:
|
|
48
|
-
facets:
|
|
49
|
-
fieldKey:
|
|
50
|
-
narrowedBy:
|
|
48
|
+
requiredParent: L,
|
|
49
|
+
facets: i,
|
|
50
|
+
fieldKey: C,
|
|
51
|
+
narrowedBy: a,
|
|
51
52
|
pinned: p,
|
|
52
|
-
missPlacement:
|
|
53
|
+
missPlacement: _
|
|
53
54
|
}) {
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
const j = se(), oe = _e(), [x, O] = q(!1), [R, ie] = q(""), [T, le] = q(""), ae = X(null), P = X(null);
|
|
56
|
+
E(() => {
|
|
57
|
+
x ? setTimeout(() => {
|
|
57
58
|
var e;
|
|
58
|
-
return (e =
|
|
59
|
-
}, 30) : (
|
|
60
|
-
}, [
|
|
61
|
-
const e = setTimeout(() =>
|
|
59
|
+
return (e = ae.current) == null ? void 0 : e.focus();
|
|
60
|
+
}, 30) : (ie(""), le(""));
|
|
61
|
+
}, [x]), E(() => {
|
|
62
|
+
const e = setTimeout(() => le(R), 300);
|
|
62
63
|
return () => clearTimeout(e);
|
|
63
|
-
}, [
|
|
64
|
-
if (!
|
|
65
|
-
const e = (
|
|
66
|
-
var
|
|
67
|
-
const
|
|
68
|
-
(
|
|
64
|
+
}, [R]), E(() => {
|
|
65
|
+
if (!x) return;
|
|
66
|
+
const e = (o) => {
|
|
67
|
+
var l;
|
|
68
|
+
const t = o.target;
|
|
69
|
+
(l = t == null ? void 0 : t.closest) != null && l.call(t, "[data-nvr-combobox-panel]") || P.current && !P.current.contains(o.target) && O(!1);
|
|
69
70
|
};
|
|
70
71
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
71
|
-
}, [
|
|
72
|
-
const [
|
|
73
|
-
|
|
74
|
-
if (!
|
|
75
|
-
|
|
72
|
+
}, [x]);
|
|
73
|
+
const [de, G] = q(null), [ce, qe] = q(null);
|
|
74
|
+
Ke(() => {
|
|
75
|
+
if (!x) {
|
|
76
|
+
G(null);
|
|
76
77
|
return;
|
|
77
78
|
}
|
|
78
79
|
const e = () => {
|
|
79
|
-
const
|
|
80
|
-
if (!
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
minWidth:
|
|
80
|
+
const o = P.current;
|
|
81
|
+
if (!o) return;
|
|
82
|
+
const t = o.getBoundingClientRect(), l = o.closest('[role="dialog"]') ?? document.body;
|
|
83
|
+
qe(l);
|
|
84
|
+
const he = window.innerHeight - t.bottom < 340 && t.top > window.innerHeight - t.bottom, xe = t.left, ye = he ? t.top - 4 : t.bottom + 4, we = {
|
|
85
|
+
minWidth: t.width,
|
|
85
86
|
zIndex: 120,
|
|
86
|
-
...
|
|
87
|
+
...he ? { transform: "translateY(-100%)" } : {}
|
|
87
88
|
};
|
|
88
|
-
if (
|
|
89
|
-
|
|
89
|
+
if (l === document.body)
|
|
90
|
+
G({ position: "fixed", left: xe, top: ye, ...we });
|
|
90
91
|
else {
|
|
91
|
-
const
|
|
92
|
-
|
|
92
|
+
const ve = l.getBoundingClientRect();
|
|
93
|
+
G({ position: "absolute", left: xe - ve.left, top: ye - ve.top, ...we });
|
|
93
94
|
}
|
|
94
95
|
};
|
|
95
96
|
return e(), window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
|
|
96
97
|
window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
|
|
97
98
|
};
|
|
98
|
-
}, [
|
|
99
|
-
const { data:
|
|
99
|
+
}, [x]);
|
|
100
|
+
const { data: V } = k({
|
|
100
101
|
queryKey: ["col-meta", s],
|
|
101
|
-
queryFn: () =>
|
|
102
|
+
queryFn: () => j.request($(`/collections/${s}`)).then((e) => e.data),
|
|
102
103
|
staleTime: 3e5,
|
|
103
104
|
retry: !1
|
|
104
|
-
}), [
|
|
105
|
+
}), [Z, Ce] = q({}), { data: ue = [] } = k({
|
|
105
106
|
queryKey: ["collection-meta", s],
|
|
106
|
-
queryFn: () =>
|
|
107
|
-
|
|
107
|
+
queryFn: () => j.request(
|
|
108
|
+
$(`/collections/${s}`)
|
|
108
109
|
).then(
|
|
109
110
|
(e) => {
|
|
110
|
-
var
|
|
111
|
-
return ((
|
|
111
|
+
var o;
|
|
112
|
+
return ((o = e.data) == null ? void 0 : o.relations) ?? [];
|
|
112
113
|
}
|
|
113
114
|
),
|
|
114
|
-
enabled: !!(
|
|
115
|
+
enabled: !!(i != null && i.length),
|
|
115
116
|
staleTime: 10 * 6e4
|
|
116
|
-
}),
|
|
117
|
+
}), $e = U(() => {
|
|
117
118
|
const e = {};
|
|
118
|
-
for (const
|
|
119
|
-
const
|
|
120
|
-
(
|
|
119
|
+
for (const o of i ?? []) {
|
|
120
|
+
const t = ue.find(
|
|
121
|
+
(l) => l.many_collection === s && l.many_field === o.field && !l.junction_field
|
|
121
122
|
);
|
|
122
|
-
|
|
123
|
+
t != null && t.one_collection && (e[o.field] = t.one_collection);
|
|
123
124
|
}
|
|
124
125
|
return e;
|
|
125
|
-
}, [
|
|
126
|
+
}, [i, ue, s]), F = s === "nivaro_users", Le = Pe(F), me = Ae().isAdmin, B = U(() => {
|
|
126
127
|
const e = [];
|
|
127
|
-
|
|
128
|
-
for (const [
|
|
129
|
-
|
|
128
|
+
F && e.push(Je(me)), f && e.push(f);
|
|
129
|
+
for (const [o, t] of Object.entries(Z))
|
|
130
|
+
t != null && t !== "" && e.push({ [o]: { _eq: t } });
|
|
130
131
|
if (e.length !== 0)
|
|
131
132
|
return e.length === 1 ? e[0] : { _and: e };
|
|
132
|
-
}, [f,
|
|
133
|
-
if (!
|
|
134
|
-
const e = [...
|
|
133
|
+
}, [f, Z, me]), D = (V == null ? void 0 : V.display_template) ?? (F ? "{{first_name}} {{last_name}} ({{email}})" : null), y = U(() => {
|
|
134
|
+
if (!D) return;
|
|
135
|
+
const e = [...D.matchAll(/\{\{([\w.]+)\}\}/g)].map((o) => o[1]);
|
|
135
136
|
if (e.length)
|
|
136
137
|
return ["id", ...e].join(",");
|
|
137
|
-
}, [
|
|
138
|
+
}, [D]), N = B ? JSON.stringify(B) : void 0, J = u && !/^-?label$/.test(u) ? u : void 0, { data: b, isFetching: ee } = k({
|
|
138
139
|
queryKey: [
|
|
139
140
|
"relation-opts",
|
|
140
141
|
s,
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
142
|
+
T,
|
|
143
|
+
N,
|
|
144
|
+
y,
|
|
145
|
+
J ?? ""
|
|
145
146
|
],
|
|
146
|
-
queryFn: () =>
|
|
147
|
-
|
|
147
|
+
queryFn: () => j.request(
|
|
148
|
+
$(`/items/${s}`, {
|
|
148
149
|
limit: 200,
|
|
149
150
|
picker: "1",
|
|
150
|
-
...
|
|
151
|
-
...
|
|
152
|
-
...
|
|
153
|
-
...
|
|
151
|
+
...T ? { search: T } : {},
|
|
152
|
+
...N ? { filter: N } : {},
|
|
153
|
+
...y ? { fields: y } : {},
|
|
154
|
+
...J ? { sort: J } : {}
|
|
154
155
|
})
|
|
155
156
|
).then((e) => e.data ?? []),
|
|
156
|
-
enabled:
|
|
157
|
-
staleTime:
|
|
157
|
+
enabled: x,
|
|
158
|
+
staleTime: N ? 0 : 3e4
|
|
158
159
|
});
|
|
159
|
-
|
|
160
|
-
placement:
|
|
161
|
-
open:
|
|
162
|
-
search:
|
|
163
|
-
settled: !
|
|
164
|
-
count: (
|
|
160
|
+
He({
|
|
161
|
+
placement: _,
|
|
162
|
+
open: x,
|
|
163
|
+
search: T,
|
|
164
|
+
settled: !ee && b !== void 0,
|
|
165
|
+
count: (b == null ? void 0 : b.length) ?? 0
|
|
165
166
|
});
|
|
166
|
-
const { data: z, isLoading:
|
|
167
|
-
queryKey: ["relation-single", s, String(
|
|
168
|
-
queryFn: () =>
|
|
169
|
-
enabled: !!
|
|
167
|
+
const { data: z, isLoading: je } = k({
|
|
168
|
+
queryKey: ["relation-single", s, String(r), y],
|
|
169
|
+
queryFn: () => oe(s, r, y),
|
|
170
|
+
enabled: !!r,
|
|
170
171
|
staleTime: 6e4
|
|
171
|
-
}),
|
|
172
|
-
queryKey: ["relation-single", s,
|
|
173
|
-
queryFn: () =>
|
|
172
|
+
}), g = (p == null ? void 0 : p.id) != null && p.id !== "" ? String(p.id) : null, { data: I } = k({
|
|
173
|
+
queryKey: ["relation-single", s, g ?? "", y],
|
|
174
|
+
queryFn: () => oe(s, g, y).catch(
|
|
174
175
|
() => null
|
|
175
176
|
),
|
|
176
|
-
enabled: !!
|
|
177
|
+
enabled: !!g && x,
|
|
177
178
|
staleTime: 6e4
|
|
178
|
-
}),
|
|
179
|
-
queryKey: ["relation-avail", s, String(
|
|
180
|
-
queryFn: () =>
|
|
181
|
-
|
|
182
|
-
filter:
|
|
179
|
+
}), Re = JSON.stringify(f ? { _and: [{ id: { _eq: r } }, f] } : { id: { _eq: r } }), { data: Q } = k({
|
|
180
|
+
queryKey: ["relation-avail", s, String(r), N],
|
|
181
|
+
queryFn: () => j.request(
|
|
182
|
+
$(`/items/${s}`, {
|
|
183
|
+
filter: Re,
|
|
183
184
|
picker: "1",
|
|
184
185
|
limit: 1,
|
|
185
186
|
fields: "id"
|
|
@@ -188,35 +189,66 @@ function Me({
|
|
|
188
189
|
// The pinned option is offered OUTSIDE the option filter (a type's generic
|
|
189
190
|
// item is excluded from the general list on purpose), so a value that IS
|
|
190
191
|
// the pin is available by construction — never probe it, never flag it.
|
|
191
|
-
enabled: !!
|
|
192
|
+
enabled: !!r && !!z && String(r) !== g,
|
|
192
193
|
staleTime: 3e4
|
|
193
|
-
}), K = !!
|
|
194
|
-
|
|
195
|
-
},
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}, [
|
|
199
|
-
if (!m || h || !
|
|
200
|
-
const e =
|
|
201
|
-
|
|
202
|
-
|
|
194
|
+
}), K = !!r && String(r) !== g && Q !== void 0 && Q.length === 0, H = X(null), te = X(!1), pe = `${s}|${N ?? ""}`, Te = () => {
|
|
195
|
+
te.current = !0, H.current = pe, d(null);
|
|
196
|
+
}, Y = r == null || r === "";
|
|
197
|
+
E(() => {
|
|
198
|
+
Y || (te.current = !1);
|
|
199
|
+
}, [Y]), E(() => {
|
|
200
|
+
if (!m || h || !Y || te.current) return;
|
|
201
|
+
const e = pe;
|
|
202
|
+
H.current !== e && (H.current = e, j.request(
|
|
203
|
+
$(`/items/${s}`, {
|
|
203
204
|
limit: 2,
|
|
204
205
|
picker: "1",
|
|
205
206
|
fields: "id",
|
|
206
|
-
...
|
|
207
|
+
...N ? { filter: N } : {}
|
|
207
208
|
})
|
|
208
|
-
).then((
|
|
209
|
-
var
|
|
210
|
-
const
|
|
211
|
-
|
|
209
|
+
).then((o) => {
|
|
210
|
+
var l;
|
|
211
|
+
const t = o.data ?? [];
|
|
212
|
+
t.length === 1 && ((l = t[0]) == null ? void 0 : l.id) != null && d(t[0].id);
|
|
212
213
|
}).catch(() => {
|
|
213
|
-
|
|
214
|
+
H.current = null;
|
|
214
215
|
}));
|
|
215
|
-
}, [m, h,
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
216
|
+
}, [m, h, Y, s, N]);
|
|
217
|
+
const w = D, fe = r && z ? v(w, z) : null, W = U(
|
|
218
|
+
() => ze(b ?? [], (e) => v(w, e) || `#${e.id}`),
|
|
219
|
+
[b, w]
|
|
220
|
+
), { data: A } = k({
|
|
221
|
+
queryKey: ["relation-opts-dups", s, W.join(",")],
|
|
222
|
+
queryFn: () => j.request(
|
|
223
|
+
$(`/items/${s}`, {
|
|
224
|
+
limit: W.length,
|
|
225
|
+
picker: "1",
|
|
226
|
+
filter: JSON.stringify({ id: { _in: W } }),
|
|
227
|
+
fields: "*"
|
|
228
|
+
})
|
|
229
|
+
).then((e) => e.data ?? []),
|
|
230
|
+
enabled: x && W.length > 0 && !F,
|
|
231
|
+
staleTime: 6e4
|
|
232
|
+
}), be = U(() => {
|
|
233
|
+
if (!(A != null && A.length)) return /* @__PURE__ */ new Map();
|
|
234
|
+
const e = new Map(
|
|
235
|
+
(b ?? []).map((t) => [
|
|
236
|
+
String(t.id),
|
|
237
|
+
(v(w, t) || `#${t.id}`).trim().toLowerCase()
|
|
238
|
+
])
|
|
239
|
+
), o = /* @__PURE__ */ new Map();
|
|
240
|
+
for (const t of A) {
|
|
241
|
+
const l = e.get(String(t.id));
|
|
242
|
+
l !== void 0 && o.set(l, [...o.get(l) ?? [], t]);
|
|
243
|
+
}
|
|
244
|
+
return Qe(
|
|
245
|
+
[...o.values()],
|
|
246
|
+
((y == null ? void 0 : y.split(",")) ?? []).map((t) => t.split(".")[0])
|
|
247
|
+
);
|
|
248
|
+
}, [A, b, w, y]), Fe = !!r && je && !z, ge = We(K), re = Ue();
|
|
249
|
+
return E(() => {
|
|
250
|
+
!re || !C || Q === void 0 || re(C, K);
|
|
251
|
+
}, [re, C, K, Q]), L ? /* @__PURE__ */ c(
|
|
220
252
|
"button",
|
|
221
253
|
{
|
|
222
254
|
type: "button",
|
|
@@ -225,66 +257,66 @@ function Me({
|
|
|
225
257
|
children: [
|
|
226
258
|
/* @__PURE__ */ c("span", { className: "truncate text-muted-foreground", children: [
|
|
227
259
|
"Select ",
|
|
228
|
-
|
|
260
|
+
L,
|
|
229
261
|
" first"
|
|
230
262
|
] }),
|
|
231
|
-
/* @__PURE__ */
|
|
263
|
+
/* @__PURE__ */ n(Ne, { className: "h-4 w-4 shrink-0 opacity-50" })
|
|
232
264
|
]
|
|
233
265
|
}
|
|
234
266
|
) : (
|
|
235
267
|
// Stale tooltip binds on the WRAPPER: a disabled trigger button swallows
|
|
236
268
|
// mouse events, so a locked-but-stale field would never show the hint.
|
|
237
|
-
/* @__PURE__ */ c("div", { ref:
|
|
269
|
+
/* @__PURE__ */ c("div", { ref: P, className: "relative", ...ge.bind, children: [
|
|
238
270
|
/* @__PURE__ */ c(
|
|
239
271
|
"button",
|
|
240
272
|
{
|
|
241
273
|
type: "button",
|
|
242
274
|
disabled: h,
|
|
243
|
-
onClick: () =>
|
|
244
|
-
className:
|
|
275
|
+
onClick: () => O((e) => !e),
|
|
276
|
+
className: M(
|
|
245
277
|
"flex h-9 w-full items-center justify-between gap-2 rounded-md border bg-background px-3 text-sm text-left hover:bg-muted disabled:pointer-events-none disabled:opacity-50",
|
|
246
278
|
K ? "border-amber-300 dark:border-amber-600" : "border-input"
|
|
247
279
|
),
|
|
248
280
|
children: [
|
|
249
|
-
|
|
281
|
+
Fe ? /* @__PURE__ */ n(ne, { className: "h-3.5 w-3.5 animate-spin text-muted-foreground" }) : /* @__PURE__ */ c(
|
|
250
282
|
"span",
|
|
251
283
|
{
|
|
252
|
-
className:
|
|
284
|
+
className: M(
|
|
253
285
|
"flex items-center gap-1.5 truncate min-w-0",
|
|
254
|
-
!
|
|
286
|
+
!fe && "text-muted-foreground"
|
|
255
287
|
),
|
|
256
288
|
children: [
|
|
257
|
-
K && /* @__PURE__ */
|
|
258
|
-
/* @__PURE__ */
|
|
289
|
+
K && /* @__PURE__ */ n(Ee, { className: "h-3.5 w-3.5 shrink-0 text-amber-500" }),
|
|
290
|
+
/* @__PURE__ */ n("span", { className: "truncate", children: fe ?? S ?? "Select…" })
|
|
259
291
|
]
|
|
260
292
|
}
|
|
261
293
|
),
|
|
262
|
-
/* @__PURE__ */
|
|
294
|
+
/* @__PURE__ */ n(Ne, { className: "h-4 w-4 shrink-0 opacity-50" })
|
|
263
295
|
]
|
|
264
296
|
}
|
|
265
297
|
),
|
|
266
|
-
|
|
267
|
-
|
|
298
|
+
ge.tip,
|
|
299
|
+
x && de && ce && Se(
|
|
268
300
|
/* @__PURE__ */ c(
|
|
269
301
|
"div",
|
|
270
302
|
{
|
|
271
303
|
"data-nvr-combobox-panel": "",
|
|
272
|
-
style:
|
|
273
|
-
className:
|
|
304
|
+
style: de,
|
|
305
|
+
className: M(
|
|
274
306
|
"nvr-pop-in rounded-md border border-border bg-popover shadow-md",
|
|
275
|
-
|
|
307
|
+
i != null && i.length ? "w-[560px] max-w-[92vw]" : "min-w-[240px] w-max max-w-[360px]"
|
|
276
308
|
),
|
|
277
309
|
children: [
|
|
278
|
-
!!(
|
|
279
|
-
const
|
|
280
|
-
return
|
|
281
|
-
/* @__PURE__ */
|
|
282
|
-
/* @__PURE__ */
|
|
283
|
-
|
|
310
|
+
!!(i != null && i.length) && /* @__PURE__ */ n("div", { className: "grid grid-cols-2 gap-2 border-b border-border bg-slate-50/60 p-2 dark:bg-muted/40", children: i.map((e) => {
|
|
311
|
+
const o = $e[e.field];
|
|
312
|
+
return o ? /* @__PURE__ */ c("div", { children: [
|
|
313
|
+
/* @__PURE__ */ n("p", { className: "mb-0.5 text-[10px] font-medium uppercase tracking-wide text-slate-400", children: e.label ?? e.field }),
|
|
314
|
+
/* @__PURE__ */ n(
|
|
315
|
+
Xe,
|
|
284
316
|
{
|
|
285
|
-
collection:
|
|
286
|
-
value:
|
|
287
|
-
onChange: (
|
|
317
|
+
collection: o,
|
|
318
|
+
value: Z[e.field] ?? null,
|
|
319
|
+
onChange: (t) => Ce((l) => ({ ...l, [e.field]: t })),
|
|
288
320
|
placeholder: "Any",
|
|
289
321
|
optionSort: e.sort,
|
|
290
322
|
extraFilter: e.filter
|
|
@@ -293,219 +325,227 @@ function Me({
|
|
|
293
325
|
] }, e.field) : null;
|
|
294
326
|
}) }),
|
|
295
327
|
/* @__PURE__ */ c("div", { className: "flex items-center border-b px-3", children: [
|
|
296
|
-
/* @__PURE__ */
|
|
297
|
-
/* @__PURE__ */
|
|
328
|
+
/* @__PURE__ */ n(Oe, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
|
|
329
|
+
/* @__PURE__ */ n(
|
|
298
330
|
"input",
|
|
299
331
|
{
|
|
300
|
-
ref:
|
|
301
|
-
value:
|
|
302
|
-
onChange: (e) =>
|
|
332
|
+
ref: ae,
|
|
333
|
+
value: R,
|
|
334
|
+
onChange: (e) => ie(e.target.value),
|
|
303
335
|
placeholder: "Search…",
|
|
304
336
|
className: "flex h-9 w-full bg-transparent py-3 text-[13px] outline-none placeholder:text-muted-foreground"
|
|
305
337
|
}
|
|
306
338
|
)
|
|
307
339
|
] }),
|
|
308
340
|
/* @__PURE__ */ c("div", { className: "max-h-52 overflow-y-auto py-1", children: [
|
|
309
|
-
!!
|
|
341
|
+
!!r && !h && /* @__PURE__ */ c(
|
|
310
342
|
"button",
|
|
311
343
|
{
|
|
312
344
|
type: "button",
|
|
313
345
|
onClick: () => {
|
|
314
|
-
|
|
346
|
+
Te(), O(!1);
|
|
315
347
|
},
|
|
316
348
|
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",
|
|
317
349
|
children: [
|
|
318
|
-
/* @__PURE__ */
|
|
350
|
+
/* @__PURE__ */ n(Ie, { className: "h-3.5 w-3.5 text-slate-400" }),
|
|
319
351
|
"Clear selection"
|
|
320
352
|
]
|
|
321
353
|
}
|
|
322
354
|
),
|
|
323
|
-
|
|
355
|
+
g && /* @__PURE__ */ c(
|
|
324
356
|
"button",
|
|
325
357
|
{
|
|
326
358
|
type: "button",
|
|
327
359
|
"data-nvr-pinned-option": !0,
|
|
328
360
|
onClick: () => {
|
|
329
|
-
d((
|
|
361
|
+
d((I == null ? void 0 : I.id) ?? (p == null ? void 0 : p.id)), O(!1);
|
|
330
362
|
},
|
|
331
363
|
className: "flex w-full items-center gap-2 border-b border-slate-100 bg-nvr-cyan/5 px-3 py-1.5 text-left text-[13px] hover:bg-nvr-cyan/10 dark:border-border",
|
|
332
364
|
children: [
|
|
333
|
-
/* @__PURE__ */
|
|
365
|
+
/* @__PURE__ */ n(
|
|
334
366
|
"div",
|
|
335
367
|
{
|
|
336
|
-
className:
|
|
368
|
+
className: M(
|
|
337
369
|
"flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",
|
|
338
|
-
String(
|
|
370
|
+
String(r) === g ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300"
|
|
339
371
|
),
|
|
340
|
-
children: String(
|
|
372
|
+
children: String(r) === g && /* @__PURE__ */ n(ke, { className: "h-2.5 w-2.5 text-white" })
|
|
341
373
|
}
|
|
342
374
|
),
|
|
343
|
-
/* @__PURE__ */
|
|
344
|
-
/* @__PURE__ */
|
|
375
|
+
/* @__PURE__ */ n("span", { className: "min-w-0 flex-1 truncate", children: I ? v(w, I) || `#${g}` : `#${g}` }),
|
|
376
|
+
/* @__PURE__ */ n("span", { className: "shrink-0 rounded bg-nvr-cyan/15 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-slate-700 dark:text-foreground", children: (p == null ? void 0 : p.tag) ?? "Default" })
|
|
345
377
|
]
|
|
346
378
|
}
|
|
347
379
|
),
|
|
348
|
-
|
|
380
|
+
ee ? /* @__PURE__ */ n("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ n(ne, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : (b ?? []).length === 0 ? a && a.labels.length > 0 && !R.trim() ? /* @__PURE__ */ c("div", { className: "px-3 py-2 text-[12px] leading-5 text-muted-foreground", children: [
|
|
349
381
|
/* @__PURE__ */ c("p", { children: [
|
|
350
382
|
"No options for",
|
|
351
383
|
" ",
|
|
352
|
-
/* @__PURE__ */
|
|
353
|
-
|
|
384
|
+
/* @__PURE__ */ n("span", { className: "font-medium text-foreground", children: a.labels.join(" · ") }),
|
|
385
|
+
a.onClear ? " — clear one to widen the list:" : "."
|
|
354
386
|
] }),
|
|
355
|
-
|
|
387
|
+
a.onClear && /* @__PURE__ */ n("div", { className: "mt-1.5 flex flex-wrap gap-1.5", children: a.keys.map((e, o) => /* @__PURE__ */ c(
|
|
356
388
|
"button",
|
|
357
389
|
{
|
|
358
390
|
type: "button",
|
|
359
|
-
onClick: (
|
|
360
|
-
var
|
|
361
|
-
|
|
391
|
+
onClick: (t) => {
|
|
392
|
+
var l;
|
|
393
|
+
t.stopPropagation(), (l = a.onClear) == null || l.call(a, e);
|
|
362
394
|
},
|
|
363
395
|
className: "rounded-md border border-border bg-background px-2 py-0.5 text-[11.5px] font-medium text-foreground transition-colors duration-150 hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan",
|
|
364
396
|
children: [
|
|
365
397
|
"Clear ",
|
|
366
|
-
|
|
398
|
+
a.labels[o] ?? e
|
|
367
399
|
]
|
|
368
400
|
},
|
|
369
401
|
e
|
|
370
402
|
)) })
|
|
371
|
-
] }) : /* @__PURE__ */
|
|
372
|
-
(e,
|
|
373
|
-
)).filter((e) => !
|
|
374
|
-
const
|
|
403
|
+
] }) : /* @__PURE__ */ n("p", { className: "px-3 py-2 text-[13px] text-muted-foreground", children: R.trim() ? `No results for “${R.trim()}”` : "No results" }) : (J ? [...b ?? []] : [...b ?? []].sort(
|
|
404
|
+
(e, o) => u === "-label" ? v(w, o).localeCompare(v(w, e)) : v(w, e).localeCompare(v(w, o))
|
|
405
|
+
)).filter((e) => !g || String(e.id) !== g).map((e) => {
|
|
406
|
+
const o = v(w, e) || `#${e.id}`, t = String(e.id) === String(r);
|
|
375
407
|
return /* @__PURE__ */ c(
|
|
376
408
|
"button",
|
|
377
409
|
{
|
|
378
410
|
type: "button",
|
|
379
411
|
onClick: () => {
|
|
380
|
-
d(e.id),
|
|
412
|
+
d(e.id), O(!1);
|
|
381
413
|
},
|
|
382
414
|
className: "flex w-full items-center gap-2 px-3 py-1.5 text-[13px] text-left hover:bg-muted",
|
|
383
415
|
children: [
|
|
384
|
-
/* @__PURE__ */
|
|
416
|
+
/* @__PURE__ */ n(
|
|
385
417
|
"div",
|
|
386
418
|
{
|
|
387
|
-
className:
|
|
419
|
+
className: M(
|
|
388
420
|
"flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",
|
|
389
|
-
|
|
421
|
+
t ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300"
|
|
390
422
|
),
|
|
391
|
-
children:
|
|
423
|
+
children: t && /* @__PURE__ */ n(ke, { className: "h-2.5 w-2.5 text-white" })
|
|
392
424
|
}
|
|
393
425
|
),
|
|
394
|
-
|
|
395
|
-
|
|
426
|
+
F && /* @__PURE__ */ n(
|
|
427
|
+
De,
|
|
396
428
|
{
|
|
397
429
|
userId: e.id,
|
|
398
430
|
className: "h-4 w-4",
|
|
399
|
-
fallback: /* @__PURE__ */
|
|
431
|
+
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: Ye(o) })
|
|
400
432
|
}
|
|
401
433
|
),
|
|
402
|
-
|
|
434
|
+
F && Le.has(String(e.id).toUpperCase()) && /* @__PURE__ */ n(
|
|
403
435
|
"span",
|
|
404
436
|
{
|
|
405
437
|
className: "h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500",
|
|
406
438
|
"data-tip": "Online now"
|
|
407
439
|
}
|
|
408
440
|
),
|
|
409
|
-
|
|
441
|
+
o,
|
|
442
|
+
be.has(String(e.id)) && /* @__PURE__ */ n(
|
|
443
|
+
"span",
|
|
444
|
+
{
|
|
445
|
+
className: "ml-auto max-w-[45%] shrink-0 truncate pl-2 text-[11.5px] text-muted-foreground",
|
|
446
|
+
"data-option-detail": !0,
|
|
447
|
+
children: be.get(String(e.id))
|
|
448
|
+
}
|
|
449
|
+
)
|
|
410
450
|
]
|
|
411
451
|
},
|
|
412
452
|
String(e.id)
|
|
413
453
|
);
|
|
414
454
|
})
|
|
415
455
|
] }),
|
|
416
|
-
!
|
|
417
|
-
|
|
456
|
+
!ee && /* @__PURE__ */ n(
|
|
457
|
+
Ge,
|
|
418
458
|
{
|
|
419
459
|
collection: s,
|
|
420
|
-
search:
|
|
421
|
-
filter:
|
|
422
|
-
narrowedLabels: (
|
|
423
|
-
auto: (
|
|
460
|
+
search: T,
|
|
461
|
+
filter: B,
|
|
462
|
+
narrowedLabels: (a == null ? void 0 : a.labels) ?? [],
|
|
463
|
+
auto: (b ?? []).length === 0 && !!T
|
|
424
464
|
}
|
|
425
465
|
)
|
|
426
466
|
]
|
|
427
467
|
}
|
|
428
468
|
),
|
|
429
|
-
|
|
469
|
+
ce
|
|
430
470
|
)
|
|
431
471
|
] })
|
|
432
472
|
);
|
|
433
473
|
}
|
|
434
|
-
function
|
|
474
|
+
function Ge({
|
|
435
475
|
collection: s,
|
|
436
|
-
search:
|
|
476
|
+
search: r,
|
|
437
477
|
filter: d,
|
|
438
478
|
narrowedLabels: h,
|
|
439
|
-
auto:
|
|
479
|
+
auto: S
|
|
440
480
|
}) {
|
|
441
|
-
const f =
|
|
442
|
-
queryKey: ["picker-narrowing", s,
|
|
481
|
+
const f = se(), [m, u] = q(!1), L = d ? JSON.stringify(d) : "", { data: i, isFetching: C } = k({
|
|
482
|
+
queryKey: ["picker-narrowing", s, r, L],
|
|
443
483
|
queryFn: () => f.request(
|
|
444
|
-
|
|
445
|
-
).then((
|
|
446
|
-
enabled: m ||
|
|
484
|
+
Me("/picker-narrowing", { collection: s, search: r, filter: d ?? null })
|
|
485
|
+
).then((_) => _.data),
|
|
486
|
+
enabled: m || S,
|
|
447
487
|
staleTime: 3e4,
|
|
448
488
|
retry: !1
|
|
449
489
|
});
|
|
450
|
-
if (!m && !
|
|
451
|
-
return /* @__PURE__ */
|
|
490
|
+
if (!m && !S)
|
|
491
|
+
return /* @__PURE__ */ n(
|
|
452
492
|
"button",
|
|
453
493
|
{
|
|
454
494
|
type: "button",
|
|
455
|
-
onClick: (
|
|
456
|
-
|
|
495
|
+
onClick: (_) => {
|
|
496
|
+
_.stopPropagation(), u(!0);
|
|
457
497
|
},
|
|
458
498
|
className: "w-full border-t border-border px-3 py-1.5 text-left text-[11px] text-muted-foreground hover:text-foreground",
|
|
459
499
|
"data-picker-narrowing-ask": !0,
|
|
460
500
|
children: "Missing something?"
|
|
461
501
|
}
|
|
462
502
|
);
|
|
463
|
-
if (
|
|
464
|
-
return /* @__PURE__ */
|
|
465
|
-
if (!
|
|
466
|
-
const
|
|
467
|
-
return
|
|
468
|
-
`${
|
|
469
|
-
),
|
|
470
|
-
`${
|
|
471
|
-
),
|
|
472
|
-
|
|
473
|
-
), /* @__PURE__ */
|
|
503
|
+
if (C && !i)
|
|
504
|
+
return /* @__PURE__ */ n("p", { className: "border-t border-border px-3 py-1.5 text-[11px] text-muted-foreground", children: "Checking what narrows this list…" });
|
|
505
|
+
if (!i) return null;
|
|
506
|
+
const a = [], p = r ? `match “${r}”` : "exist";
|
|
507
|
+
return i.by_field_filter > 0 && a.push(
|
|
508
|
+
`${i.by_field_filter.toLocaleString()} more ${p} but this field only offers ${h.length ? `records that fit ${h.join(" · ")}` : "records its filter allows"}.`
|
|
509
|
+
), i.by_exclusions > 0 && a.push(
|
|
510
|
+
`${i.by_exclusions.toLocaleString()} ${i.by_exclusions === 1 ? "is" : "are"} hidden from pickers by an admin.`
|
|
511
|
+
), i.scopes.length > 0 && a.push(`Your ${i.scopes.join(", ")} access narrows what you can pick here.`), i.row_filter && a.push("Your role only sees some of these records."), a.length === 0 && a.push(
|
|
512
|
+
r ? `Nothing else you can see matches “${r}”.` : "Nothing narrows this list — every record you can see is offered."
|
|
513
|
+
), /* @__PURE__ */ n(
|
|
474
514
|
"div",
|
|
475
515
|
{
|
|
476
516
|
className: "space-y-0.5 border-t border-border px-3 py-1.5 text-[11px] leading-4 text-muted-foreground",
|
|
477
517
|
"data-picker-narrowing": !0,
|
|
478
|
-
"data-picker-narrowing-field":
|
|
479
|
-
"data-picker-narrowing-excluded":
|
|
480
|
-
children:
|
|
518
|
+
"data-picker-narrowing-field": i.by_field_filter,
|
|
519
|
+
"data-picker-narrowing-excluded": i.by_exclusions,
|
|
520
|
+
children: a.map((_) => /* @__PURE__ */ n("p", { children: _ }, _))
|
|
481
521
|
}
|
|
482
522
|
);
|
|
483
523
|
}
|
|
484
|
-
function
|
|
524
|
+
function ut({
|
|
485
525
|
collection: s,
|
|
486
|
-
id:
|
|
526
|
+
id: r,
|
|
487
527
|
displayTemplate: d
|
|
488
528
|
}) {
|
|
489
|
-
const h =
|
|
529
|
+
const h = se(), S = _e(), f = s === "nivaro_files" || s === "directus_files", m = (() => {
|
|
490
530
|
if (!d || !d.includes(".")) return null;
|
|
491
|
-
const
|
|
492
|
-
return
|
|
493
|
-
})(), { data: u, isLoading:
|
|
494
|
-
queryKey: ["relation-single", s, String(
|
|
495
|
-
queryFn: () => f ? h.request(
|
|
496
|
-
enabled: !!
|
|
531
|
+
const i = [...d.matchAll(/\{\{([^}]+)\}\}/g)].map((C) => C[1].trim());
|
|
532
|
+
return i.length > 0 ? ["id", ...i].join(",") : null;
|
|
533
|
+
})(), { data: u, isLoading: L } = k({
|
|
534
|
+
queryKey: ["relation-single", s, String(r), m ?? ""],
|
|
535
|
+
queryFn: () => f ? h.request($(`/files/${r}`)).then((i) => i.data) : S(s, r, m),
|
|
536
|
+
enabled: !!r && !!s,
|
|
497
537
|
staleTime: 6e4
|
|
498
538
|
});
|
|
499
|
-
if (
|
|
500
|
-
if (!u) return /* @__PURE__ */
|
|
539
|
+
if (L) return /* @__PURE__ */ n(ne, { className: "h-3 w-3 animate-spin text-slate-400" });
|
|
540
|
+
if (!u) return /* @__PURE__ */ n("span", { children: String(r ?? "") });
|
|
501
541
|
if (f) {
|
|
502
|
-
const
|
|
503
|
-
return /* @__PURE__ */
|
|
542
|
+
const i = u.title || u.filename_download || u.filename_disk || String(r);
|
|
543
|
+
return /* @__PURE__ */ n("span", { children: i });
|
|
504
544
|
}
|
|
505
|
-
return /* @__PURE__ */
|
|
545
|
+
return /* @__PURE__ */ n("span", { children: v(d, u) });
|
|
506
546
|
}
|
|
507
547
|
export {
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
548
|
+
ut as RelatedItemLabel,
|
|
549
|
+
Xe as RelationCombobox,
|
|
550
|
+
We as useStaleTip
|
|
511
551
|
};
|