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