@nivaro/react 0.3.24 → 0.3.26
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/index.d.ts +45 -26
- package/dist/shared/components/FilePreviewLightbox.js +56 -35
- package/dist/shared/components/ItemEditForm.js +4309 -4263
- package/dist/shared/components/PageRenderer.js +63 -62
- package/dist/shared/components/RecordReadView.js +229 -229
- package/dist/shared/components/ReportView.js +123 -120
- package/dist/shared/components/ai/AiMarkdown.js +168 -148
- package/dist/shared/components/chat/RoomParts.js +120 -119
- package/dist/shared/components/chat/chat-core.js +228 -224
- package/dist/shared/components/item-edit/FieldRenderer.js +333 -333
- package/dist/shared/components/item-edit/FieldRow.js +413 -394
- package/dist/shared/components/item-edit/GroupSection.js +637 -635
- package/dist/shared/components/item-edit/InlineGridField.js +89 -90
- package/dist/shared/components/item-edit/M2MCombobox.js +117 -116
- package/dist/shared/components/item-edit/QuickPicker.js +9 -9
- package/dist/shared/components/item-edit/RawEditSheet.js +80 -79
- package/dist/shared/components/item-edit/RelationCombobox.js +173 -167
- package/dist/shared/components/item-edit/RowMatchPanel.js +1 -1
- package/dist/shared/components/item-edit/m2m-invalidate.js +19 -0
- package/dist/shared/components/item-edit/record-lookups.js +15 -0
- package/dist/shared/components/item-edit/render-stability.js +147 -0
- package/dist/shared/components/layout-editor/FormMapButton.js +5 -4
- package/dist/shared/lib/picker-rank.js +21 -0
- package/dist/shared/lib/safe-href.js +10 -0
- package/dist/shared/lib/socket-realtime.js +107 -78
- package/package.json +6 -6
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
import { jsxs as c, jsx as n } from "react/jsx-runtime";
|
|
2
|
-
import { useQuery as
|
|
2
|
+
import { useQuery as S } from "@tanstack/react-query";
|
|
3
3
|
import { ChevronDown as Se, Loader2 as Q, AlertTriangle as Ue, Search as Ae, X as Me, Check as qe } from "lucide-react";
|
|
4
|
-
import { useState as
|
|
4
|
+
import { useState as $, useRef as Z, useEffect as O, useLayoutEffect as De, useMemo as I } from "react";
|
|
5
5
|
import { createPortal as _e } from "react-dom";
|
|
6
6
|
import { useNivaroClient as ie, useItemEditAuth as Je, useStaleFieldReporter as ze } from "../../context.js";
|
|
7
7
|
import { get as j, post as He } from "../../lib/commands.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
import { compareByMatch as Ye } from "../../lib/picker-rank.js";
|
|
9
|
+
import { useRecordReader as $e } from "../../lib/record-loader.js";
|
|
10
|
+
import { useOnlineUsers as We } from "../../lib/use-online-users.js";
|
|
11
|
+
import { UserAvatar as Xe } from "../UserAvatar.js";
|
|
12
|
+
import { userOptionFilter as Ge, cn as D } from "../../lib/utils.js";
|
|
13
|
+
import { applyDisplayTemplate as k } from "./helpers.js";
|
|
14
|
+
import { collidingIds as Ve, disambiguators as Ze } from "./option-disambiguate.js";
|
|
15
|
+
import { usePickerMissReport as Qe } from "./picker-miss.js";
|
|
16
|
+
import { useLatestSearch as Be, narrowLocally as et } from "./picker-search.js";
|
|
17
|
+
function tt(s) {
|
|
18
|
+
return s.replace(/\(.*$/, "").trim().split(/\s+/).map((r) => r[0]).filter(Boolean).slice(0, 2).join("").toUpperCase() || "?";
|
|
18
19
|
}
|
|
19
|
-
function
|
|
20
|
-
const [r, d] =
|
|
21
|
-
onMouseEnter: (
|
|
22
|
-
if (!
|
|
23
|
-
const m =
|
|
20
|
+
function rt(s) {
|
|
21
|
+
const [r, d] = $(null), x = {
|
|
22
|
+
onMouseEnter: (h) => {
|
|
23
|
+
if (!s) return;
|
|
24
|
+
const m = h.currentTarget.getBoundingClientRect(), u = window.innerHeight - m.bottom < 80;
|
|
24
25
|
d({ x: m.left, y: u ? m.top - 58 : m.bottom + 4 });
|
|
25
26
|
},
|
|
26
27
|
onMouseLeave: () => d(null)
|
|
27
|
-
},
|
|
28
|
+
}, q = s && r ? _e(
|
|
28
29
|
/* @__PURE__ */ n(
|
|
29
30
|
"div",
|
|
30
31
|
{
|
|
@@ -35,49 +36,49 @@ function tt(o) {
|
|
|
35
36
|
),
|
|
36
37
|
document.body
|
|
37
38
|
) : null;
|
|
38
|
-
return { bind:
|
|
39
|
+
return { bind: x, tip: q };
|
|
39
40
|
}
|
|
40
|
-
function
|
|
41
|
-
collection:
|
|
41
|
+
function nt({
|
|
42
|
+
collection: s,
|
|
42
43
|
value: r,
|
|
43
44
|
onChange: d,
|
|
44
|
-
disabled:
|
|
45
|
-
placeholder:
|
|
46
|
-
extraFilter:
|
|
45
|
+
disabled: x,
|
|
46
|
+
placeholder: q,
|
|
47
|
+
extraFilter: h,
|
|
47
48
|
autoSelectSingle: m,
|
|
48
49
|
optionSort: u,
|
|
49
50
|
requiredParent: R,
|
|
50
51
|
facets: i,
|
|
51
|
-
fieldKey:
|
|
52
|
+
fieldKey: C,
|
|
52
53
|
narrowedBy: l,
|
|
53
54
|
pinned: p,
|
|
54
|
-
missPlacement:
|
|
55
|
+
missPlacement: _
|
|
55
56
|
}) {
|
|
56
|
-
const F = ie(), ae =
|
|
57
|
+
const F = ie(), ae = $e(), [y, K] = $(!1), [N, le] = $(""), [Ce, Le] = $(!1), L = Be(N, Ce), de = Z(null), J = Z(null);
|
|
57
58
|
O(() => {
|
|
58
|
-
|
|
59
|
+
y ? setTimeout(() => {
|
|
59
60
|
var e;
|
|
60
61
|
return (e = de.current) == null ? void 0 : e.focus();
|
|
61
62
|
}, 30) : le("");
|
|
62
|
-
}, [
|
|
63
|
-
if (!
|
|
64
|
-
const e = (
|
|
63
|
+
}, [y]), O(() => {
|
|
64
|
+
if (!y) return;
|
|
65
|
+
const e = (o) => {
|
|
65
66
|
var a;
|
|
66
|
-
const t =
|
|
67
|
-
(a = t == null ? void 0 : t.closest) != null && a.call(t, "[data-nvr-combobox-panel]") || J.current && !J.current.contains(
|
|
67
|
+
const t = o.target;
|
|
68
|
+
(a = t == null ? void 0 : t.closest) != null && a.call(t, "[data-nvr-combobox-panel]") || J.current && !J.current.contains(o.target) && K(!1);
|
|
68
69
|
};
|
|
69
70
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
70
|
-
}, [
|
|
71
|
-
const [ce, B] =
|
|
71
|
+
}, [y]);
|
|
72
|
+
const [ce, B] = $(null), [ue, je] = $(null);
|
|
72
73
|
De(() => {
|
|
73
|
-
if (!
|
|
74
|
+
if (!y) {
|
|
74
75
|
B(null);
|
|
75
76
|
return;
|
|
76
77
|
}
|
|
77
78
|
const e = () => {
|
|
78
|
-
const
|
|
79
|
-
if (!
|
|
80
|
-
const t =
|
|
79
|
+
const o = J.current;
|
|
80
|
+
if (!o) return;
|
|
81
|
+
const t = o.getBoundingClientRect(), a = o.closest('[role="dialog"]') ?? document.body;
|
|
81
82
|
je(a);
|
|
82
83
|
const ye = window.innerHeight - t.bottom < 340 && t.top > window.innerHeight - t.bottom, we = t.left, ve = ye ? t.top - 4 : t.bottom + 4, Ne = {
|
|
83
84
|
minWidth: t.width,
|
|
@@ -94,104 +95,104 @@ function rt({
|
|
|
94
95
|
return e(), window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
|
|
95
96
|
window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
|
|
96
97
|
};
|
|
97
|
-
}, [
|
|
98
|
-
const { data: ee, isPending: Re } =
|
|
99
|
-
queryKey: ["col-meta",
|
|
100
|
-
queryFn: () => F.request(j(`/collections/${
|
|
98
|
+
}, [y]);
|
|
99
|
+
const { data: ee, isPending: Re } = S({
|
|
100
|
+
queryKey: ["col-meta", s],
|
|
101
|
+
queryFn: () => F.request(j(`/collections/${s}`)).then((e) => e.data),
|
|
101
102
|
staleTime: 3e5,
|
|
102
103
|
retry: !1
|
|
103
|
-
}), [te, Fe] =
|
|
104
|
-
queryKey: ["collection-meta",
|
|
104
|
+
}), [te, Fe] = $({}), { data: me = [] } = S({
|
|
105
|
+
queryKey: ["collection-meta", s],
|
|
105
106
|
queryFn: () => F.request(
|
|
106
|
-
j(`/collections/${
|
|
107
|
+
j(`/collections/${s}`)
|
|
107
108
|
).then(
|
|
108
109
|
(e) => {
|
|
109
|
-
var
|
|
110
|
-
return ((
|
|
110
|
+
var o;
|
|
111
|
+
return ((o = e.data) == null ? void 0 : o.relations) ?? [];
|
|
111
112
|
}
|
|
112
113
|
),
|
|
113
114
|
enabled: !!(i != null && i.length),
|
|
114
115
|
staleTime: 10 * 6e4
|
|
115
116
|
}), Te = I(() => {
|
|
116
117
|
const e = {};
|
|
117
|
-
for (const
|
|
118
|
+
for (const o of i ?? []) {
|
|
118
119
|
const t = me.find(
|
|
119
|
-
(a) => a.many_collection ===
|
|
120
|
+
(a) => a.many_collection === s && a.many_field === o.field && !a.junction_field
|
|
120
121
|
);
|
|
121
|
-
t != null && t.one_collection && (e[
|
|
122
|
+
t != null && t.one_collection && (e[o.field] = t.one_collection);
|
|
122
123
|
}
|
|
123
124
|
return e;
|
|
124
|
-
}, [i, me,
|
|
125
|
+
}, [i, me, s]), T = s === "nivaro_users", Ee = We(T), pe = Je().isAdmin, re = I(() => {
|
|
125
126
|
const e = [];
|
|
126
|
-
T && e.push(
|
|
127
|
-
for (const [
|
|
128
|
-
t != null && t !== "" && e.push({ [
|
|
127
|
+
T && e.push(Ge(pe)), h && e.push(h);
|
|
128
|
+
for (const [o, t] of Object.entries(te))
|
|
129
|
+
t != null && t !== "" && e.push({ [o]: { _eq: t } });
|
|
129
130
|
if (e.length !== 0)
|
|
130
131
|
return e.length === 1 ? e[0] : { _and: e };
|
|
131
|
-
}, [
|
|
132
|
+
}, [h, te, pe]), z = (ee == null ? void 0 : ee.display_template) ?? (T ? "{{first_name}} {{last_name}} ({{email}})" : null), g = I(() => {
|
|
132
133
|
if (!z) return;
|
|
133
|
-
const e = [...z.matchAll(/\{\{([\w.]+)\}\}/g)].map((
|
|
134
|
+
const e = [...z.matchAll(/\{\{([\w.]+)\}\}/g)].map((o) => o[1]);
|
|
134
135
|
if (e.length)
|
|
135
136
|
return ["id", ...e].join(",");
|
|
136
|
-
}, [z]),
|
|
137
|
+
}, [z]), v = re ? JSON.stringify(re) : void 0, P = u && !/^-?label$/.test(u) ? u : void 0, {
|
|
137
138
|
data: f,
|
|
138
139
|
isFetching: E,
|
|
139
140
|
isPlaceholderData: fe
|
|
140
|
-
} =
|
|
141
|
+
} = S({
|
|
141
142
|
queryKey: [
|
|
142
143
|
"relation-opts",
|
|
143
|
-
|
|
144
|
+
s,
|
|
144
145
|
L,
|
|
145
|
-
|
|
146
|
-
|
|
146
|
+
v,
|
|
147
|
+
g,
|
|
147
148
|
P ?? ""
|
|
148
149
|
],
|
|
149
150
|
queryFn: () => F.request(
|
|
150
|
-
j(`/items/${
|
|
151
|
+
j(`/items/${s}`, {
|
|
151
152
|
limit: 200,
|
|
152
153
|
picker: "1",
|
|
153
154
|
...L ? { search: L } : {},
|
|
154
|
-
...
|
|
155
|
-
...
|
|
155
|
+
...v ? { filter: v } : {},
|
|
156
|
+
...g ? { fields: g } : {},
|
|
156
157
|
...P ? { sort: P } : {}
|
|
157
158
|
})
|
|
158
159
|
).then((e) => e.data ?? []),
|
|
159
160
|
// Wait for the display template: it decides `fields`, and starting before
|
|
160
161
|
// it lands sent the whole first page twice.
|
|
161
|
-
enabled:
|
|
162
|
-
staleTime:
|
|
162
|
+
enabled: y && !Re,
|
|
163
|
+
staleTime: v ? 0 : 3e4,
|
|
163
164
|
// A new SEARCH keeps the previous answer on screen (narrowed locally below)
|
|
164
165
|
// instead of blanking the list behind a spinner. A changed filter, sort or
|
|
165
166
|
// template never does — those rows may no longer be allowed.
|
|
166
|
-
placeholderData: (e,
|
|
167
|
-
const t =
|
|
167
|
+
placeholderData: (e, o) => {
|
|
168
|
+
const t = o == null ? void 0 : o.queryKey;
|
|
168
169
|
if (!(!e || !t))
|
|
169
|
-
return t[1] ===
|
|
170
|
+
return t[1] === s && t[3] === v && t[4] === g && t[5] === (P ?? "") ? e : void 0;
|
|
170
171
|
}
|
|
171
172
|
});
|
|
172
|
-
O(() => Le(E), [E]),
|
|
173
|
-
placement:
|
|
174
|
-
open:
|
|
173
|
+
O(() => Le(E), [E]), Qe({
|
|
174
|
+
placement: _,
|
|
175
|
+
open: y,
|
|
175
176
|
search: L,
|
|
176
177
|
settled: !E && !fe && f !== void 0,
|
|
177
178
|
count: (f == null ? void 0 : f.length) ?? 0
|
|
178
179
|
});
|
|
179
|
-
const { data: H, isLoading: Oe } =
|
|
180
|
-
queryKey: ["relation-single",
|
|
181
|
-
queryFn: () => ae(
|
|
180
|
+
const { data: H, isLoading: Oe } = S({
|
|
181
|
+
queryKey: ["relation-single", s, String(r), g],
|
|
182
|
+
queryFn: () => ae(s, r, g),
|
|
182
183
|
enabled: !!r,
|
|
183
184
|
staleTime: 6e4
|
|
184
|
-
}),
|
|
185
|
-
queryKey: ["relation-single",
|
|
186
|
-
queryFn: () => ae(
|
|
185
|
+
}), b = (p == null ? void 0 : p.id) != null && p.id !== "" ? String(p.id) : null, { data: U } = S({
|
|
186
|
+
queryKey: ["relation-single", s, b ?? "", g],
|
|
187
|
+
queryFn: () => ae(s, b, g).catch(
|
|
187
188
|
() => null
|
|
188
189
|
),
|
|
189
|
-
enabled: !!
|
|
190
|
+
enabled: !!b && y,
|
|
190
191
|
staleTime: 6e4
|
|
191
|
-
}), Ie = JSON.stringify(
|
|
192
|
-
queryKey: ["relation-avail",
|
|
192
|
+
}), Ie = JSON.stringify(h ? { _and: [{ id: { _eq: r } }, h] } : { id: { _eq: r } }), { data: Y } = S({
|
|
193
|
+
queryKey: ["relation-avail", s, String(r), v],
|
|
193
194
|
queryFn: () => F.request(
|
|
194
|
-
j(`/items/${
|
|
195
|
+
j(`/items/${s}`, {
|
|
195
196
|
filter: Ie,
|
|
196
197
|
picker: "1",
|
|
197
198
|
limit: 1,
|
|
@@ -201,74 +202,74 @@ function rt({
|
|
|
201
202
|
// The pinned option is offered OUTSIDE the option filter (a type's generic
|
|
202
203
|
// item is excluded from the general list on purpose), so a value that IS
|
|
203
204
|
// the pin is available by construction — never probe it, never flag it.
|
|
204
|
-
enabled: !!r && !!H && String(r) !==
|
|
205
|
+
enabled: !!r && !!H && String(r) !== b,
|
|
205
206
|
staleTime: 3e4
|
|
206
|
-
}), A = !!r && String(r) !==
|
|
207
|
+
}), A = !!r && String(r) !== b && Y !== void 0 && Y.length === 0, W = Z(null), ne = Z(!1), he = `${s}|${v ?? ""}`, Ke = () => {
|
|
207
208
|
ne.current = !0, W.current = he, d(null);
|
|
208
209
|
}, X = r == null || r === "";
|
|
209
210
|
O(() => {
|
|
210
211
|
X || (ne.current = !1);
|
|
211
212
|
}, [X]), O(() => {
|
|
212
|
-
if (!m ||
|
|
213
|
+
if (!m || x || !X || ne.current) return;
|
|
213
214
|
const e = he;
|
|
214
215
|
W.current !== e && (W.current = e, F.request(
|
|
215
|
-
j(`/items/${
|
|
216
|
+
j(`/items/${s}`, {
|
|
216
217
|
limit: 2,
|
|
217
218
|
picker: "1",
|
|
218
219
|
fields: "id",
|
|
219
|
-
...
|
|
220
|
+
...v ? { filter: v } : {}
|
|
220
221
|
})
|
|
221
|
-
).then((
|
|
222
|
+
).then((o) => {
|
|
222
223
|
var a;
|
|
223
|
-
const t =
|
|
224
|
+
const t = o.data ?? [];
|
|
224
225
|
t.length === 1 && ((a = t[0]) == null ? void 0 : a.id) != null && d(t[0].id);
|
|
225
226
|
}).catch(() => {
|
|
226
227
|
W.current = null;
|
|
227
228
|
}));
|
|
228
|
-
}, [m,
|
|
229
|
-
const
|
|
230
|
-
() =>
|
|
229
|
+
}, [m, x, X, s, v]);
|
|
230
|
+
const w = z, ge = r && H ? k(w, H) : null, se = !fe && N === L, G = I(
|
|
231
|
+
() => et(
|
|
231
232
|
f ?? [],
|
|
232
|
-
(e) =>
|
|
233
|
-
|
|
233
|
+
(e) => k(w, e) || `#${e.id}`,
|
|
234
|
+
N,
|
|
234
235
|
se
|
|
235
236
|
),
|
|
236
|
-
[f,
|
|
237
|
+
[f, w, N, se]
|
|
237
238
|
), V = I(
|
|
238
|
-
() =>
|
|
239
|
-
[f,
|
|
240
|
-
), { data: M } =
|
|
241
|
-
queryKey: ["relation-opts-dups",
|
|
239
|
+
() => Ve(f ?? [], (e) => k(w, e) || `#${e.id}`),
|
|
240
|
+
[f, w]
|
|
241
|
+
), { data: M } = S({
|
|
242
|
+
queryKey: ["relation-opts-dups", s, V.join(",")],
|
|
242
243
|
queryFn: () => F.request(
|
|
243
|
-
j(`/items/${
|
|
244
|
+
j(`/items/${s}`, {
|
|
244
245
|
limit: V.length,
|
|
245
246
|
picker: "1",
|
|
246
247
|
filter: JSON.stringify({ id: { _in: V } }),
|
|
247
248
|
fields: "*"
|
|
248
249
|
})
|
|
249
250
|
).then((e) => e.data ?? []),
|
|
250
|
-
enabled:
|
|
251
|
+
enabled: y && V.length > 0 && !T,
|
|
251
252
|
staleTime: 6e4
|
|
252
253
|
}), be = I(() => {
|
|
253
254
|
if (!(M != null && M.length)) return /* @__PURE__ */ new Map();
|
|
254
255
|
const e = new Map(
|
|
255
256
|
(f ?? []).map((t) => [
|
|
256
257
|
String(t.id),
|
|
257
|
-
(
|
|
258
|
+
(k(w, t) || `#${t.id}`).trim().toLowerCase()
|
|
258
259
|
])
|
|
259
|
-
),
|
|
260
|
+
), o = /* @__PURE__ */ new Map();
|
|
260
261
|
for (const t of M) {
|
|
261
262
|
const a = e.get(String(t.id));
|
|
262
|
-
a !== void 0 &&
|
|
263
|
+
a !== void 0 && o.set(a, [...o.get(a) ?? [], t]);
|
|
263
264
|
}
|
|
264
|
-
return
|
|
265
|
-
[...
|
|
266
|
-
((
|
|
265
|
+
return Ze(
|
|
266
|
+
[...o.values()],
|
|
267
|
+
((g == null ? void 0 : g.split(",")) ?? []).map((t) => t.split(".")[0])
|
|
267
268
|
);
|
|
268
|
-
}, [M, f,
|
|
269
|
+
}, [M, f, w, g]), Pe = !!r && Oe && !H, xe = rt(A), oe = ze();
|
|
269
270
|
return O(() => {
|
|
270
|
-
!oe ||
|
|
271
|
-
}, [oe,
|
|
271
|
+
!oe || !C || Y === void 0 || oe(C, A);
|
|
272
|
+
}, [oe, C, A, Y]), R ? /* @__PURE__ */ c(
|
|
272
273
|
"button",
|
|
273
274
|
{
|
|
274
275
|
type: "button",
|
|
@@ -291,7 +292,7 @@ function rt({
|
|
|
291
292
|
"button",
|
|
292
293
|
{
|
|
293
294
|
type: "button",
|
|
294
|
-
disabled:
|
|
295
|
+
disabled: x,
|
|
295
296
|
onClick: () => K((e) => !e),
|
|
296
297
|
className: D(
|
|
297
298
|
"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",
|
|
@@ -307,7 +308,7 @@ function rt({
|
|
|
307
308
|
),
|
|
308
309
|
children: [
|
|
309
310
|
A && /* @__PURE__ */ n(Ue, { className: "h-3.5 w-3.5 shrink-0 text-amber-500" }),
|
|
310
|
-
/* @__PURE__ */ n("span", { className: "truncate", children: ge ??
|
|
311
|
+
/* @__PURE__ */ n("span", { className: "truncate", children: ge ?? q ?? "Select…" })
|
|
311
312
|
]
|
|
312
313
|
}
|
|
313
314
|
),
|
|
@@ -316,7 +317,7 @@ function rt({
|
|
|
316
317
|
}
|
|
317
318
|
),
|
|
318
319
|
xe.tip,
|
|
319
|
-
|
|
320
|
+
y && ce && ue && _e(
|
|
320
321
|
/* @__PURE__ */ c(
|
|
321
322
|
"div",
|
|
322
323
|
{
|
|
@@ -328,13 +329,13 @@ function rt({
|
|
|
328
329
|
),
|
|
329
330
|
children: [
|
|
330
331
|
!!(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) => {
|
|
331
|
-
const
|
|
332
|
-
return
|
|
332
|
+
const o = Te[e.field];
|
|
333
|
+
return o ? /* @__PURE__ */ c("div", { children: [
|
|
333
334
|
/* @__PURE__ */ n("p", { className: "mb-0.5 text-[10px] font-medium uppercase tracking-wide text-slate-400", children: e.label ?? e.field }),
|
|
334
335
|
/* @__PURE__ */ n(
|
|
335
|
-
|
|
336
|
+
nt,
|
|
336
337
|
{
|
|
337
|
-
collection:
|
|
338
|
+
collection: o,
|
|
338
339
|
value: te[e.field] ?? null,
|
|
339
340
|
onChange: (t) => Fe((a) => ({ ...a, [e.field]: t })),
|
|
340
341
|
placeholder: "Any",
|
|
@@ -350,7 +351,7 @@ function rt({
|
|
|
350
351
|
"input",
|
|
351
352
|
{
|
|
352
353
|
ref: de,
|
|
353
|
-
value:
|
|
354
|
+
value: N,
|
|
354
355
|
onChange: (e) => le(e.target.value),
|
|
355
356
|
placeholder: "Search…",
|
|
356
357
|
className: "flex h-9 w-full bg-transparent py-3 text-[13px] outline-none placeholder:text-muted-foreground"
|
|
@@ -365,7 +366,7 @@ function rt({
|
|
|
365
366
|
)
|
|
366
367
|
] }),
|
|
367
368
|
/* @__PURE__ */ c("div", { className: "max-h-52 overflow-y-auto py-1", children: [
|
|
368
|
-
!!r && !
|
|
369
|
+
!!r && !x && /* @__PURE__ */ c(
|
|
369
370
|
"button",
|
|
370
371
|
{
|
|
371
372
|
type: "button",
|
|
@@ -379,7 +380,7 @@ function rt({
|
|
|
379
380
|
]
|
|
380
381
|
}
|
|
381
382
|
),
|
|
382
|
-
|
|
383
|
+
b && /* @__PURE__ */ c(
|
|
383
384
|
"button",
|
|
384
385
|
{
|
|
385
386
|
type: "button",
|
|
@@ -394,24 +395,24 @@ function rt({
|
|
|
394
395
|
{
|
|
395
396
|
className: D(
|
|
396
397
|
"flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",
|
|
397
|
-
String(r) ===
|
|
398
|
+
String(r) === b ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300"
|
|
398
399
|
),
|
|
399
|
-
children: String(r) ===
|
|
400
|
+
children: String(r) === b && /* @__PURE__ */ n(qe, { className: "h-2.5 w-2.5 text-white" })
|
|
400
401
|
}
|
|
401
402
|
),
|
|
402
|
-
/* @__PURE__ */ n("span", { className: "min-w-0 flex-1 truncate", children: U ?
|
|
403
|
+
/* @__PURE__ */ n("span", { className: "min-w-0 flex-1 truncate", children: U ? k(w, U) || `#${b}` : `#${b}` }),
|
|
403
404
|
/* @__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" })
|
|
404
405
|
]
|
|
405
406
|
}
|
|
406
407
|
),
|
|
407
|
-
f === void 0 && E ? /* @__PURE__ */ n("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ n(Q, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : G.length === 0 && !se ? /* @__PURE__ */ n("p", { className: "px-3 py-2 text-[13px] text-muted-foreground", children: "Searching…" }) : G.length === 0 ? l && l.labels.length > 0 && !
|
|
408
|
+
f === void 0 && E ? /* @__PURE__ */ n("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ n(Q, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : G.length === 0 && !se ? /* @__PURE__ */ n("p", { className: "px-3 py-2 text-[13px] text-muted-foreground", children: "Searching…" }) : G.length === 0 ? l && l.labels.length > 0 && !N.trim() ? /* @__PURE__ */ c("div", { className: "px-3 py-2 text-[12px] leading-5 text-muted-foreground", children: [
|
|
408
409
|
/* @__PURE__ */ c("p", { children: [
|
|
409
410
|
"No options for",
|
|
410
411
|
" ",
|
|
411
412
|
/* @__PURE__ */ n("span", { className: "font-medium text-foreground", children: l.labels.join(" · ") }),
|
|
412
413
|
l.onClear ? " — clear one to widen the list:" : "."
|
|
413
414
|
] }),
|
|
414
|
-
l.onClear && /* @__PURE__ */ n("div", { className: "mt-1.5 flex flex-wrap gap-1.5", children: l.keys.map((e,
|
|
415
|
+
l.onClear && /* @__PURE__ */ n("div", { className: "mt-1.5 flex flex-wrap gap-1.5", children: l.keys.map((e, o) => /* @__PURE__ */ c(
|
|
415
416
|
"button",
|
|
416
417
|
{
|
|
417
418
|
type: "button",
|
|
@@ -422,15 +423,20 @@ function rt({
|
|
|
422
423
|
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",
|
|
423
424
|
children: [
|
|
424
425
|
"Clear ",
|
|
425
|
-
l.labels[
|
|
426
|
+
l.labels[o] ?? e
|
|
426
427
|
]
|
|
427
428
|
},
|
|
428
429
|
e
|
|
429
430
|
)) })
|
|
430
|
-
] }) : /* @__PURE__ */ n("p", { className: "px-3 py-2 text-[13px] text-muted-foreground", children:
|
|
431
|
-
(e,
|
|
432
|
-
|
|
433
|
-
|
|
431
|
+
] }) : /* @__PURE__ */ n("p", { className: "px-3 py-2 text-[13px] text-muted-foreground", children: N.trim() ? `No results for “${N.trim()}”` : "No results" }) : (P ? [...G] : [...G].sort(
|
|
432
|
+
(e, o) => Ye(
|
|
433
|
+
k(w, e),
|
|
434
|
+
k(w, o),
|
|
435
|
+
N,
|
|
436
|
+
u === "-label"
|
|
437
|
+
)
|
|
438
|
+
)).filter((e) => !b || String(e.id) !== b).map((e) => {
|
|
439
|
+
const o = k(w, e) || `#${e.id}`, t = String(e.id) === String(r);
|
|
434
440
|
return /* @__PURE__ */ c(
|
|
435
441
|
"button",
|
|
436
442
|
{
|
|
@@ -451,11 +457,11 @@ function rt({
|
|
|
451
457
|
}
|
|
452
458
|
),
|
|
453
459
|
T && /* @__PURE__ */ n(
|
|
454
|
-
|
|
460
|
+
Xe,
|
|
455
461
|
{
|
|
456
462
|
userId: e.id,
|
|
457
463
|
className: "h-4 w-4",
|
|
458
|
-
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:
|
|
464
|
+
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: tt(o) })
|
|
459
465
|
}
|
|
460
466
|
),
|
|
461
467
|
T && Ee.has(String(e.id).toUpperCase()) && /* @__PURE__ */ n(
|
|
@@ -465,7 +471,7 @@ function rt({
|
|
|
465
471
|
"data-tip": "Online now"
|
|
466
472
|
}
|
|
467
473
|
),
|
|
468
|
-
|
|
474
|
+
o,
|
|
469
475
|
be.has(String(e.id)) && /* @__PURE__ */ n(
|
|
470
476
|
"span",
|
|
471
477
|
{
|
|
@@ -481,9 +487,9 @@ function rt({
|
|
|
481
487
|
})
|
|
482
488
|
] }),
|
|
483
489
|
!E && /* @__PURE__ */ n(
|
|
484
|
-
|
|
490
|
+
st,
|
|
485
491
|
{
|
|
486
|
-
collection:
|
|
492
|
+
collection: s,
|
|
487
493
|
search: L,
|
|
488
494
|
filter: re,
|
|
489
495
|
narrowedLabels: (l == null ? void 0 : l.labels) ?? [],
|
|
@@ -498,41 +504,41 @@ function rt({
|
|
|
498
504
|
] })
|
|
499
505
|
);
|
|
500
506
|
}
|
|
501
|
-
function
|
|
502
|
-
collection:
|
|
507
|
+
function st({
|
|
508
|
+
collection: s,
|
|
503
509
|
search: r,
|
|
504
510
|
filter: d,
|
|
505
|
-
narrowedLabels:
|
|
506
|
-
auto:
|
|
511
|
+
narrowedLabels: x,
|
|
512
|
+
auto: q
|
|
507
513
|
}) {
|
|
508
|
-
const
|
|
509
|
-
queryKey: ["picker-narrowing",
|
|
510
|
-
queryFn: () =>
|
|
511
|
-
He("/picker-narrowing", { collection:
|
|
512
|
-
).then((
|
|
513
|
-
enabled: m ||
|
|
514
|
+
const h = ie(), [m, u] = $(!1), R = d ? JSON.stringify(d) : "", { data: i, isFetching: C } = S({
|
|
515
|
+
queryKey: ["picker-narrowing", s, r, R],
|
|
516
|
+
queryFn: () => h.request(
|
|
517
|
+
He("/picker-narrowing", { collection: s, search: r, filter: d ?? null })
|
|
518
|
+
).then((_) => _.data),
|
|
519
|
+
enabled: m || q,
|
|
514
520
|
staleTime: 3e4,
|
|
515
521
|
retry: !1
|
|
516
522
|
});
|
|
517
|
-
if (!m && !
|
|
523
|
+
if (!m && !q)
|
|
518
524
|
return /* @__PURE__ */ n(
|
|
519
525
|
"button",
|
|
520
526
|
{
|
|
521
527
|
type: "button",
|
|
522
|
-
onClick: (
|
|
523
|
-
|
|
528
|
+
onClick: (_) => {
|
|
529
|
+
_.stopPropagation(), u(!0);
|
|
524
530
|
},
|
|
525
531
|
className: "w-full border-t border-border px-3 py-1.5 text-left text-[11px] text-muted-foreground hover:text-foreground",
|
|
526
532
|
"data-picker-narrowing-ask": !0,
|
|
527
533
|
children: "Missing something?"
|
|
528
534
|
}
|
|
529
535
|
);
|
|
530
|
-
if (
|
|
536
|
+
if (C && !i)
|
|
531
537
|
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…" });
|
|
532
538
|
if (!i) return null;
|
|
533
539
|
const l = [], p = r ? `match “${r}”` : "exist";
|
|
534
540
|
return i.by_field_filter > 0 && l.push(
|
|
535
|
-
`${i.by_field_filter.toLocaleString()} more ${p} but this field only offers ${
|
|
541
|
+
`${i.by_field_filter.toLocaleString()} more ${p} but this field only offers ${x.length ? `records that fit ${x.join(" · ")}` : "records its filter allows"}.`
|
|
536
542
|
), i.by_exclusions > 0 && l.push(
|
|
537
543
|
`${i.by_exclusions.toLocaleString()} ${i.by_exclusions === 1 ? "is" : "are"} hidden from pickers by an admin.`
|
|
538
544
|
), i.scopes.length > 0 && l.push(`Your ${i.scopes.join(", ")} access narrows what you can pick here.`), i.row_filter && l.push("Your role only sees some of these records."), l.length === 0 && l.push(
|
|
@@ -544,42 +550,42 @@ function nt({
|
|
|
544
550
|
"data-picker-narrowing": !0,
|
|
545
551
|
"data-picker-narrowing-field": i.by_field_filter,
|
|
546
552
|
"data-picker-narrowing-excluded": i.by_exclusions,
|
|
547
|
-
children: l.map((
|
|
553
|
+
children: l.map((_) => /* @__PURE__ */ n("p", { children: _ }, _))
|
|
548
554
|
}
|
|
549
555
|
);
|
|
550
556
|
}
|
|
551
|
-
function
|
|
552
|
-
collection:
|
|
557
|
+
function vt({
|
|
558
|
+
collection: s,
|
|
553
559
|
id: r,
|
|
554
560
|
displayTemplate: d
|
|
555
561
|
}) {
|
|
556
|
-
const
|
|
562
|
+
const x = ie(), q = $e(), h = s === "nivaro_files" || s === "directus_files", m = (() => {
|
|
557
563
|
if (!d || !d.includes(".")) return null;
|
|
558
|
-
const i = [...d.matchAll(/\{\{([^}]+)\}\}/g)].map((
|
|
564
|
+
const i = [...d.matchAll(/\{\{([^}]+)\}\}/g)].map((C) => C[1].trim());
|
|
559
565
|
return i.length > 0 ? ["id", ...i].join(",") : null;
|
|
560
|
-
})(), { data: u, isLoading: R } =
|
|
561
|
-
queryKey: ["relation-single",
|
|
562
|
-
queryFn: () =>
|
|
566
|
+
})(), { data: u, isLoading: R } = S({
|
|
567
|
+
queryKey: ["relation-single", s, String(r), m ?? ""],
|
|
568
|
+
queryFn: () => h ? (
|
|
563
569
|
// The file's row, not its bytes: GET /files/:id downloads the whole
|
|
564
570
|
// file (twice with the retry, 404 when storage lost it) only to read
|
|
565
571
|
// its name, and a missing object left the raw id as the label.
|
|
566
|
-
|
|
572
|
+
x.request(
|
|
567
573
|
j(`/files/${encodeURIComponent(String(r))}/meta`)
|
|
568
574
|
).then((i) => i.data)
|
|
569
|
-
) :
|
|
570
|
-
enabled: !!r && !!
|
|
575
|
+
) : q(s, r, m),
|
|
576
|
+
enabled: !!r && !!s,
|
|
571
577
|
staleTime: 6e4
|
|
572
578
|
});
|
|
573
579
|
if (R) return /* @__PURE__ */ n(Q, { className: "h-3 w-3 animate-spin text-slate-400" });
|
|
574
580
|
if (!u) return /* @__PURE__ */ n("span", { children: String(r ?? "") });
|
|
575
|
-
if (
|
|
581
|
+
if (h) {
|
|
576
582
|
const i = u.title || u.filename_download || u.filename_disk || String(r);
|
|
577
583
|
return /* @__PURE__ */ n("span", { children: i });
|
|
578
584
|
}
|
|
579
|
-
return /* @__PURE__ */ n("span", { children:
|
|
585
|
+
return /* @__PURE__ */ n("span", { children: k(d, u) });
|
|
580
586
|
}
|
|
581
587
|
export {
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
588
|
+
vt as RelatedItemLabel,
|
|
589
|
+
nt as RelationCombobox,
|
|
590
|
+
rt as useStaleTip
|
|
585
591
|
};
|