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