@nivaro/react 0.3.57 → 0.3.58
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 +5 -1
- package/dist/shared/components/CollectionBrowserView.js +2633 -2590
- package/dist/shared/components/DataTable.js +247 -236
- package/dist/shared/components/ItemEditForm.js +1693 -1668
- package/dist/shared/components/ProfileView.js +716 -715
- package/dist/shared/components/RecordReadView.js +367 -364
- package/dist/shared/components/ReportView.js +64 -39
- package/dist/shared/components/alerts/AlertManagerView.js +284 -271
- package/dist/shared/components/cbv/row-focus.js +19 -0
- package/dist/shared/components/help-videos/HelpVideoPlayer.js +152 -147
- package/dist/shared/components/integrations/console/SignalCard.js +59 -59
- package/dist/shared/components/integrations/console/tone.js +52 -30
- package/dist/shared/components/item-edit/CatalogPickerField.js +525 -505
- package/dist/shared/components/item-edit/FieldRow.js +175 -173
- package/dist/shared/components/item-edit/InlineTableField.js +407 -402
- package/dist/shared/components/item-edit/M2MCombobox.js +313 -291
- package/dist/shared/components/item-edit/MidairCollisionDialog.js +1 -1
- package/dist/shared/components/item-edit/PlanGrid.js +826 -803
- package/dist/shared/components/item-edit/QuickCreateButton.js +115 -79
- package/dist/shared/components/item-edit/RecordLiveSync.js +77 -75
- package/dist/shared/components/item-edit/RelationCombobox.js +412 -328
- package/dist/shared/components/item-edit/RelationGroupedCombobox.js +147 -125
- package/dist/shared/components/item-edit/SummaryPanel.js +406 -392
- package/dist/shared/components/item-edit/option-disambiguate.js +44 -32
- package/dist/shared/components/item-edit/related-missing.js +45 -0
- package/dist/shared/components/item-edit/save-outcome.js +5 -5
- package/dist/shared/components/notifications/NotificationRulesEditor.js +130 -123
- package/dist/shared/components/panels/AccessDeniedPanel.js +52 -48
- package/dist/shared/components/panels/ItemLockBanner.js +2 -3
- package/dist/shared/components/panels/PipelinePanel.js +1027 -978
- package/dist/shared/components/panels/RevisionsPanel.js +4 -1
- package/dist/shared/components/panels/TaskPanel.js +265 -249
- package/dist/shared/components/panels/landing-state.js +27 -0
- package/dist/shared/components/pipeline/PipelineEditorView.js +86 -78
- package/dist/shared/components/profile/AiMemoryCard.js +12 -10
- package/dist/shared/components/queue/OwnerAvatars.js +80 -41
- package/dist/shared/components/queue/QueueQuickFilters.js +48 -48
- package/dist/shared/components/queue/QueueWorklist.js +357 -358
- package/dist/shared/components/queue/group-sums.js +27 -0
- package/dist/shared/components/widgets/ReviewListWidget.js +186 -168
- package/dist/shared/lib/back-closes.js +25 -0
- package/dist/shared/lib/form-usage-beacon.js +7 -7
- package/dist/shared/lib/list-page-memory.js +41 -0
- package/dist/shared/lib/live.js +44 -44
- package/dist/shared/lib/own-writes.js +76 -28
- package/dist/shared/lib/request-gate.js +110 -109
- package/dist/shared/lib/validation-rules.js +34 -19
- package/package.json +1 -1
|
@@ -1,212 +1,235 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useQuery as
|
|
3
|
-
import { ChevronDown as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { createPortal as
|
|
6
|
-
import { useNivaroClient as
|
|
7
|
-
import { get 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
|
-
|
|
19
|
-
|
|
1
|
+
import { jsxs as h, jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { useQuery as C } from "@tanstack/react-query";
|
|
3
|
+
import { ChevronDown as Ve, Loader2 as ce, AlertTriangle as ft, Search as mt, X as pt, Check as We } from "lucide-react";
|
|
4
|
+
import { useState as E, useRef as j, useEffect as L, useId as gt, useLayoutEffect as bt, useMemo as T } from "react";
|
|
5
|
+
import { createPortal as Ge } from "react-dom";
|
|
6
|
+
import { useNivaroClient as Le, useItemEditAuth as ht, useStaleFieldReporter as xt } from "../../context.js";
|
|
7
|
+
import { get as P, post as yt } from "../../lib/commands.js";
|
|
8
|
+
import { compareByMatch as wt } from "../../lib/picker-rank.js";
|
|
9
|
+
import { useRecordReader as Ze } from "../../lib/record-loader.js";
|
|
10
|
+
import { useOnlineUsers as vt } from "../../lib/use-online-users.js";
|
|
11
|
+
import { SearchHighlight as kt } from "../SearchHighlight.js";
|
|
12
|
+
import { UserAvatar as Nt } from "../UserAvatar.js";
|
|
13
|
+
import { userOptionFilter as St, matchesAllTokens as _t, cn as O } from "../../lib/utils.js";
|
|
14
|
+
import { applyDisplayTemplate as S } from "./helpers.js";
|
|
15
|
+
import { collidingIds as Lt, disambiguators as qt, isNamelessLabel as X, NAMELESS_LABEL as ee } from "./option-disambiguate.js";
|
|
16
|
+
import { usePickerMissReport as $t } from "./picker-miss.js";
|
|
17
|
+
import { useLatestSearch as Ct, narrowLocally as Et } from "./picker-search.js";
|
|
18
|
+
import { retryRelatedRead as Rt, RelatedMissingLabel as Dt } from "./related-missing.js";
|
|
19
|
+
function It(o) {
|
|
20
|
+
return o.replace(/\(.*$/, "").trim().split(/\s+/).map((n) => n[0]).filter(Boolean).slice(0, 2).join("").toUpperCase() || "?";
|
|
20
21
|
}
|
|
21
|
-
function
|
|
22
|
-
const [
|
|
23
|
-
onMouseEnter: (
|
|
24
|
-
if (!
|
|
25
|
-
const
|
|
26
|
-
|
|
22
|
+
function At(o) {
|
|
23
|
+
const [n, f] = E(null), y = {
|
|
24
|
+
onMouseEnter: (w) => {
|
|
25
|
+
if (!o) return;
|
|
26
|
+
const x = w.currentTarget.getBoundingClientRect(), p = window.innerHeight - x.bottom < 80;
|
|
27
|
+
f({ x: x.left, y: p ? x.top - 58 : x.bottom + 4 });
|
|
27
28
|
},
|
|
28
|
-
onMouseLeave: () =>
|
|
29
|
-
},
|
|
29
|
+
onMouseLeave: () => f(null)
|
|
30
|
+
}, R = o && n ? Ge(
|
|
30
31
|
/* @__PURE__ */ s(
|
|
31
32
|
"div",
|
|
32
33
|
{
|
|
33
|
-
style: { position: "fixed", left:
|
|
34
|
+
style: { position: "fixed", left: n.x, top: n.y, zIndex: 130 },
|
|
34
35
|
className: "pointer-events-none max-w-[300px] rounded-md border border-amber-200 bg-amber-50 px-2.5 py-1.5 text-[11.5px] leading-snug text-amber-800 shadow-md dark:border-amber-500/40 dark:bg-[#2a2113] dark:text-amber-300",
|
|
35
36
|
children: "Current value is not an available option — clear to pick another"
|
|
36
37
|
}
|
|
37
38
|
),
|
|
38
39
|
document.body
|
|
39
40
|
) : null;
|
|
40
|
-
return { bind: y, tip:
|
|
41
|
+
return { bind: y, tip: R };
|
|
41
42
|
}
|
|
42
|
-
function
|
|
43
|
-
return
|
|
43
|
+
function Xe(o, n) {
|
|
44
|
+
return o == null || o === "" || n == null || n === "" ? !1 : String(o) === String(n);
|
|
44
45
|
}
|
|
45
|
-
function
|
|
46
|
-
collection:
|
|
47
|
-
value:
|
|
48
|
-
onChange:
|
|
46
|
+
function Kt({
|
|
47
|
+
collection: o,
|
|
48
|
+
value: n,
|
|
49
|
+
onChange: f,
|
|
49
50
|
disabled: y,
|
|
50
|
-
placeholder:
|
|
51
|
-
extraFilter:
|
|
52
|
-
autoSelectSingle:
|
|
53
|
-
optionSort:
|
|
54
|
-
requiredParent:
|
|
55
|
-
facets:
|
|
56
|
-
fieldKey:
|
|
57
|
-
narrowedBy:
|
|
58
|
-
pinned:
|
|
59
|
-
missPlacement:
|
|
60
|
-
defaultOpen:
|
|
61
|
-
onClose:
|
|
51
|
+
placeholder: R,
|
|
52
|
+
extraFilter: w,
|
|
53
|
+
autoSelectSingle: x,
|
|
54
|
+
optionSort: p,
|
|
55
|
+
requiredParent: U,
|
|
56
|
+
facets: l,
|
|
57
|
+
fieldKey: D,
|
|
58
|
+
narrowedBy: i,
|
|
59
|
+
pinned: d,
|
|
60
|
+
missPlacement: I,
|
|
61
|
+
defaultOpen: Qe,
|
|
62
|
+
onClose: qe
|
|
62
63
|
}) {
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
64
|
+
const H = Le(), $e = Ze(), [c, A] = E(Qe ?? !1), [u, de] = E(""), te = j(qe);
|
|
65
|
+
te.current = qe;
|
|
66
|
+
const Ce = j(c);
|
|
67
|
+
L(() => {
|
|
67
68
|
var e;
|
|
68
|
-
|
|
69
|
+
Ce.current && !c && ((e = te.current) == null || e.call(te)), Ce.current = c;
|
|
69
70
|
}, [c]);
|
|
70
|
-
const [
|
|
71
|
-
|
|
71
|
+
const [Be, et] = E(!1), M = Ct(u, Be), Ee = j(null), J = j(null), ue = j(null), ne = j(null), fe = gt(), [Re, F] = E(-1);
|
|
72
|
+
L(() => {
|
|
72
73
|
c ? setTimeout(() => {
|
|
73
74
|
var e;
|
|
74
|
-
return (e =
|
|
75
|
-
}, 30) :
|
|
76
|
-
}, [c])
|
|
75
|
+
return (e = Ee.current) == null ? void 0 : e.focus();
|
|
76
|
+
}, 30) : de("");
|
|
77
|
+
}, [c]);
|
|
78
|
+
const me = () => {
|
|
79
|
+
var e;
|
|
80
|
+
A(!1), (e = ne.current) == null || e.focus();
|
|
81
|
+
};
|
|
82
|
+
L(() => {
|
|
83
|
+
if (!c) return;
|
|
84
|
+
const e = (r) => {
|
|
85
|
+
var N, _, B;
|
|
86
|
+
if (r.key !== "Escape") return;
|
|
87
|
+
const t = document.activeElement;
|
|
88
|
+
(t === document.body || t && ((N = ue.current) != null && N.contains(t) || (_ = J.current) != null && _.contains(t))) && (r.preventDefault(), r.stopPropagation(), A(!1), (B = ne.current) == null || B.focus());
|
|
89
|
+
};
|
|
90
|
+
return window.addEventListener("keydown", e, !0), () => window.removeEventListener("keydown", e, !0);
|
|
91
|
+
}, [c]), L(() => {
|
|
77
92
|
if (!c) return;
|
|
78
|
-
const e = (
|
|
79
|
-
var
|
|
80
|
-
const t =
|
|
81
|
-
|
|
93
|
+
const e = (r) => {
|
|
94
|
+
var a, N;
|
|
95
|
+
const t = r.target;
|
|
96
|
+
!t || t === document.body || (a = t.closest) != null && a.call(t, "[data-nvr-combobox-panel]") || (N = J.current) != null && N.contains(t) || A(!1);
|
|
97
|
+
};
|
|
98
|
+
return document.addEventListener("focusin", e), () => document.removeEventListener("focusin", e);
|
|
99
|
+
}, [c]), L(() => {
|
|
100
|
+
if (!c) return;
|
|
101
|
+
const e = (r) => {
|
|
102
|
+
var a;
|
|
103
|
+
const t = r.target;
|
|
104
|
+
(a = t == null ? void 0 : t.closest) != null && a.call(t, "[data-nvr-combobox-panel]") || J.current && !J.current.contains(r.target) && A(!1);
|
|
82
105
|
};
|
|
83
106
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
84
107
|
}, [c]);
|
|
85
|
-
const [
|
|
86
|
-
|
|
108
|
+
const [De, pe] = E(null), [Ie, tt] = E(null);
|
|
109
|
+
bt(() => {
|
|
87
110
|
if (!c) {
|
|
88
|
-
|
|
111
|
+
pe(null);
|
|
89
112
|
return;
|
|
90
113
|
}
|
|
91
114
|
const e = () => {
|
|
92
|
-
const
|
|
93
|
-
if (!
|
|
94
|
-
const t =
|
|
95
|
-
|
|
96
|
-
const
|
|
115
|
+
const r = J.current;
|
|
116
|
+
if (!r) return;
|
|
117
|
+
const t = r.getBoundingClientRect(), a = r.closest('[role="dialog"]') ?? document.body;
|
|
118
|
+
tt(a);
|
|
119
|
+
const N = window.innerHeight - t.bottom < 340 && t.top > window.innerHeight - t.bottom, _ = t.left, B = N ? t.top - 4 : t.bottom + 4, ze = {
|
|
97
120
|
minWidth: t.width,
|
|
98
121
|
zIndex: 120,
|
|
99
|
-
...
|
|
122
|
+
...N ? { transform: "translateY(-100%)" } : {}
|
|
100
123
|
};
|
|
101
|
-
if (
|
|
102
|
-
|
|
124
|
+
if (a === document.body)
|
|
125
|
+
pe({ position: "fixed", left: _, top: B, ...ze });
|
|
103
126
|
else {
|
|
104
|
-
const
|
|
105
|
-
|
|
127
|
+
const Ye = a.getBoundingClientRect();
|
|
128
|
+
pe({ position: "absolute", left: _ - Ye.left, top: B - Ye.top, ...ze });
|
|
106
129
|
}
|
|
107
130
|
};
|
|
108
131
|
return e(), window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
|
|
109
132
|
window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
|
|
110
133
|
};
|
|
111
134
|
}, [c]);
|
|
112
|
-
const { data:
|
|
113
|
-
queryKey: ["col-meta",
|
|
114
|
-
queryFn: () =>
|
|
135
|
+
const { data: ge, isPending: nt } = C({
|
|
136
|
+
queryKey: ["col-meta", o],
|
|
137
|
+
queryFn: () => H.request(P(`/collections/${o}`)).then((e) => e.data),
|
|
115
138
|
staleTime: 3e5,
|
|
116
139
|
retry: !1
|
|
117
|
-
}), [
|
|
118
|
-
queryKey: ["collection-meta",
|
|
119
|
-
queryFn: () =>
|
|
120
|
-
|
|
140
|
+
}), [be, rt] = E({}), { data: Ae = [] } = C({
|
|
141
|
+
queryKey: ["collection-meta", o],
|
|
142
|
+
queryFn: () => H.request(
|
|
143
|
+
P(`/collections/${o}`)
|
|
121
144
|
).then(
|
|
122
145
|
(e) => {
|
|
123
|
-
var
|
|
124
|
-
return ((
|
|
146
|
+
var r;
|
|
147
|
+
return ((r = e.data) == null ? void 0 : r.relations) ?? [];
|
|
125
148
|
}
|
|
126
149
|
),
|
|
127
|
-
enabled: !!(
|
|
150
|
+
enabled: !!(l != null && l.length),
|
|
128
151
|
staleTime: 10 * 6e4
|
|
129
|
-
}),
|
|
152
|
+
}), ot = T(() => {
|
|
130
153
|
const e = {};
|
|
131
|
-
for (const
|
|
132
|
-
const t =
|
|
133
|
-
(
|
|
154
|
+
for (const r of l ?? []) {
|
|
155
|
+
const t = Ae.find(
|
|
156
|
+
(a) => a.many_collection === o && a.many_field === r.field && !a.junction_field
|
|
134
157
|
);
|
|
135
|
-
t != null && t.one_collection && (e[
|
|
158
|
+
t != null && t.one_collection && (e[r.field] = t.one_collection);
|
|
136
159
|
}
|
|
137
160
|
return e;
|
|
138
|
-
}, [
|
|
161
|
+
}, [l, Ae, o]), z = o === "nivaro_users", st = vt(z), Ke = ht().isAdmin, he = T(() => {
|
|
139
162
|
const e = [];
|
|
140
|
-
|
|
141
|
-
for (const [
|
|
142
|
-
t != null && t !== "" && e.push({ [
|
|
163
|
+
z && e.push(St(Ke)), w && e.push(w);
|
|
164
|
+
for (const [r, t] of Object.entries(be))
|
|
165
|
+
t != null && t !== "" && e.push({ [r]: { _eq: t } });
|
|
143
166
|
if (e.length !== 0)
|
|
144
167
|
return e.length === 1 ? e[0] : { _and: e };
|
|
145
|
-
}, [
|
|
146
|
-
if (!
|
|
147
|
-
const e = [...
|
|
168
|
+
}, [w, be, Ke]), re = (ge == null ? void 0 : ge.display_template) ?? (z ? "{{first_name}} {{last_name}} ({{email}})" : null), v = T(() => {
|
|
169
|
+
if (!re) return;
|
|
170
|
+
const e = [...re.matchAll(/\{\{([\w.]+)\}\}/g)].map((r) => r[1]);
|
|
148
171
|
if (e.length)
|
|
149
172
|
return ["id", ...e].join(",");
|
|
150
|
-
}, [
|
|
151
|
-
data:
|
|
152
|
-
isFetching:
|
|
153
|
-
isPlaceholderData:
|
|
154
|
-
} =
|
|
173
|
+
}, [re]), q = he ? JSON.stringify(he) : void 0, Y = p && !/^-?label$/.test(p) ? p : void 0, {
|
|
174
|
+
data: g,
|
|
175
|
+
isFetching: V,
|
|
176
|
+
isPlaceholderData: je
|
|
177
|
+
} = C({
|
|
155
178
|
queryKey: [
|
|
156
179
|
"relation-opts",
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
180
|
+
o,
|
|
181
|
+
M,
|
|
182
|
+
q,
|
|
183
|
+
v,
|
|
184
|
+
Y ?? ""
|
|
162
185
|
],
|
|
163
|
-
queryFn: () =>
|
|
164
|
-
|
|
186
|
+
queryFn: () => H.request(
|
|
187
|
+
P(`/items/${o}`, {
|
|
165
188
|
limit: 200,
|
|
166
189
|
picker: "1",
|
|
167
|
-
...
|
|
168
|
-
...
|
|
169
|
-
...
|
|
170
|
-
...
|
|
190
|
+
...M ? { search: M } : {},
|
|
191
|
+
...q ? { filter: q } : {},
|
|
192
|
+
...v ? { fields: v } : {},
|
|
193
|
+
...Y ? { sort: Y } : {}
|
|
171
194
|
})
|
|
172
195
|
).then((e) => e.data ?? []),
|
|
173
196
|
// Wait for the display template: it decides `fields`, and starting before
|
|
174
197
|
// it lands sent the whole first page twice.
|
|
175
|
-
enabled: c && !
|
|
176
|
-
staleTime:
|
|
198
|
+
enabled: c && !nt,
|
|
199
|
+
staleTime: q ? 0 : 3e4,
|
|
177
200
|
// A new SEARCH keeps the previous answer on screen (narrowed locally below)
|
|
178
201
|
// instead of blanking the list behind a spinner. A changed filter, sort or
|
|
179
202
|
// template never does — those rows may no longer be allowed.
|
|
180
|
-
placeholderData: (e,
|
|
181
|
-
const t =
|
|
203
|
+
placeholderData: (e, r) => {
|
|
204
|
+
const t = r == null ? void 0 : r.queryKey;
|
|
182
205
|
if (!(!e || !t))
|
|
183
|
-
return t[1] ===
|
|
206
|
+
return t[1] === o && t[3] === q && t[4] === v && t[5] === (Y ?? "") ? e : void 0;
|
|
184
207
|
}
|
|
185
208
|
});
|
|
186
|
-
|
|
187
|
-
placement:
|
|
209
|
+
L(() => et(V), [V]), $t({
|
|
210
|
+
placement: I,
|
|
188
211
|
open: c,
|
|
189
|
-
search:
|
|
190
|
-
settled: !
|
|
191
|
-
count: (
|
|
212
|
+
search: M,
|
|
213
|
+
settled: !V && !je && g !== void 0,
|
|
214
|
+
count: (g == null ? void 0 : g.length) ?? 0
|
|
192
215
|
});
|
|
193
|
-
const { data:
|
|
194
|
-
queryKey: ["relation-single",
|
|
195
|
-
queryFn: () =>
|
|
196
|
-
enabled: !!
|
|
216
|
+
const { data: oe, isLoading: it } = C({
|
|
217
|
+
queryKey: ["relation-single", o, String(n), v],
|
|
218
|
+
queryFn: () => $e(o, n, v),
|
|
219
|
+
enabled: !!n,
|
|
197
220
|
staleTime: 6e4
|
|
198
|
-
}),
|
|
199
|
-
queryKey: ["relation-single",
|
|
200
|
-
queryFn: () =>
|
|
221
|
+
}), k = (d == null ? void 0 : d.id) != null && d.id !== "" ? String(d.id) : null, { data: K } = C({
|
|
222
|
+
queryKey: ["relation-single", o, k ?? "", v],
|
|
223
|
+
queryFn: () => $e(o, k, v).catch(
|
|
201
224
|
() => null
|
|
202
225
|
),
|
|
203
|
-
enabled: !!
|
|
226
|
+
enabled: !!k && c,
|
|
204
227
|
staleTime: 6e4
|
|
205
|
-
}),
|
|
206
|
-
queryKey: ["relation-avail",
|
|
207
|
-
queryFn: () =>
|
|
208
|
-
|
|
209
|
-
filter:
|
|
228
|
+
}), at = JSON.stringify(w ? { _and: [{ id: { _eq: n } }, w] } : { id: { _eq: n } }), { data: se } = C({
|
|
229
|
+
queryKey: ["relation-avail", o, String(n), q],
|
|
230
|
+
queryFn: () => H.request(
|
|
231
|
+
P(`/items/${o}`, {
|
|
232
|
+
filter: at,
|
|
210
233
|
picker: "1",
|
|
211
234
|
limit: 1,
|
|
212
235
|
fields: "id"
|
|
@@ -215,145 +238,191 @@ function dt({
|
|
|
215
238
|
// The pinned option is offered OUTSIDE the option filter (a type's generic
|
|
216
239
|
// item is excluded from the general list on purpose), so a value that IS
|
|
217
240
|
// the pin is available by construction — never probe it, never flag it.
|
|
218
|
-
enabled: !!
|
|
241
|
+
enabled: !!n && !!oe && String(n) !== k,
|
|
219
242
|
staleTime: 3e4
|
|
220
|
-
}),
|
|
221
|
-
|
|
222
|
-
},
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}, [
|
|
226
|
-
if (!
|
|
227
|
-
const e =
|
|
228
|
-
|
|
229
|
-
|
|
243
|
+
}), G = !!n && String(n) !== k && se !== void 0 && se.length === 0, ie = j(null), xe = j(!1), Te = `${o}|${q ?? ""}`, lt = () => {
|
|
244
|
+
xe.current = !0, ie.current = Te, f(null);
|
|
245
|
+
}, ae = n == null || n === "";
|
|
246
|
+
L(() => {
|
|
247
|
+
ae || (xe.current = !1);
|
|
248
|
+
}, [ae]), L(() => {
|
|
249
|
+
if (!x || y || !ae || xe.current) return;
|
|
250
|
+
const e = Te;
|
|
251
|
+
ie.current !== e && (ie.current = e, H.request(
|
|
252
|
+
P(`/items/${o}`, {
|
|
230
253
|
limit: 2,
|
|
231
254
|
picker: "1",
|
|
232
255
|
fields: "id",
|
|
233
|
-
...
|
|
256
|
+
...q ? { filter: q } : {}
|
|
234
257
|
})
|
|
235
|
-
).then((
|
|
236
|
-
var
|
|
237
|
-
const t =
|
|
238
|
-
t.length === 1 && ((
|
|
258
|
+
).then((r) => {
|
|
259
|
+
var a;
|
|
260
|
+
const t = r.data ?? [];
|
|
261
|
+
t.length === 1 && ((a = t[0]) == null ? void 0 : a.id) != null && f(t[0].id);
|
|
239
262
|
}).catch(() => {
|
|
240
|
-
|
|
263
|
+
ie.current = null;
|
|
241
264
|
}));
|
|
242
|
-
}, [
|
|
243
|
-
const
|
|
244
|
-
() =>
|
|
245
|
-
|
|
246
|
-
(e) =>
|
|
265
|
+
}, [x, y, ae, o, q]);
|
|
266
|
+
const m = re, ye = n && oe ? S(m, oe) : null, we = ye === null ? null : X(ye) ? ee : ye, ve = !je && u === M, ke = T(
|
|
267
|
+
() => Et(
|
|
268
|
+
g ?? [],
|
|
269
|
+
(e) => S(m, e) || `#${e.id}`,
|
|
247
270
|
// The server also reads a joined code by its parts ("2026-NNO-POWER"
|
|
248
271
|
// finds 2026-WEST-NNO-HE-POWERING, services/search-synonyms.ts), so
|
|
249
272
|
// the list narrowed while that search is out does too.
|
|
250
|
-
|
|
251
|
-
|
|
273
|
+
u.replace(/[-_/]+/g, " "),
|
|
274
|
+
ve
|
|
252
275
|
),
|
|
253
|
-
[
|
|
254
|
-
),
|
|
255
|
-
() =>
|
|
256
|
-
[
|
|
257
|
-
), { data:
|
|
258
|
-
queryKey: ["relation-opts-dups",
|
|
259
|
-
queryFn: () =>
|
|
260
|
-
|
|
261
|
-
limit:
|
|
276
|
+
[g, m, u, ve]
|
|
277
|
+
), le = T(
|
|
278
|
+
() => Lt(g ?? [], (e) => S(m, e) || `#${e.id}`),
|
|
279
|
+
[g, m]
|
|
280
|
+
), { data: Z } = C({
|
|
281
|
+
queryKey: ["relation-opts-dups", o, le.join(",")],
|
|
282
|
+
queryFn: () => H.request(
|
|
283
|
+
P(`/items/${o}`, {
|
|
284
|
+
limit: le.length,
|
|
262
285
|
picker: "1",
|
|
263
|
-
filter: JSON.stringify({ id: { _in:
|
|
286
|
+
filter: JSON.stringify({ id: { _in: le } }),
|
|
264
287
|
fields: "*"
|
|
265
288
|
})
|
|
266
289
|
).then((e) => e.data ?? []),
|
|
267
|
-
enabled: c &&
|
|
290
|
+
enabled: c && le.length > 0 && !z,
|
|
268
291
|
staleTime: 6e4
|
|
269
|
-
}),
|
|
270
|
-
if (!(
|
|
292
|
+
}), Me = T(() => {
|
|
293
|
+
if (!(Z != null && Z.length)) return /* @__PURE__ */ new Map();
|
|
271
294
|
const e = new Map(
|
|
272
|
-
(
|
|
295
|
+
(g ?? []).map((t) => [
|
|
273
296
|
String(t.id),
|
|
274
|
-
(
|
|
297
|
+
(S(m, t) || `#${t.id}`).trim().toLowerCase()
|
|
275
298
|
])
|
|
276
|
-
),
|
|
277
|
-
for (const t of
|
|
278
|
-
const
|
|
279
|
-
|
|
299
|
+
), r = /* @__PURE__ */ new Map();
|
|
300
|
+
for (const t of Z) {
|
|
301
|
+
const a = e.get(String(t.id));
|
|
302
|
+
a !== void 0 && r.set(a, [...r.get(a) ?? [], t]);
|
|
280
303
|
}
|
|
281
|
-
return
|
|
282
|
-
[...
|
|
283
|
-
((
|
|
304
|
+
return qt(
|
|
305
|
+
[...r.values()],
|
|
306
|
+
((v == null ? void 0 : v.split(",")) ?? []).map((t) => t.split(".")[0])
|
|
284
307
|
);
|
|
285
|
-
}, [
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
308
|
+
}, [Z, g, m, v]), ct = !!n && it && !oe, Fe = At(G), Oe = T(
|
|
309
|
+
() => (g ?? []).some((e) => !X(S(m, e))),
|
|
310
|
+
[g, m]
|
|
311
|
+
), Q = T(
|
|
312
|
+
() => (Y ? [...ke] : [...ke].sort(
|
|
313
|
+
(e, r) => wt(
|
|
314
|
+
S(m, e),
|
|
315
|
+
S(m, r),
|
|
316
|
+
u,
|
|
317
|
+
p === "-label"
|
|
318
|
+
)
|
|
319
|
+
)).filter((e) => !k || String(e.id) !== k).filter(
|
|
320
|
+
(e) => !Oe || String(e.id) === String(n) || !X(S(m, e))
|
|
321
|
+
),
|
|
322
|
+
[ke, Y, m, u, p, k, n, Oe]
|
|
323
|
+
), Pe = K && !X(S(m, K)) ? S(m, K) : ee, Ne = !!k && (!u.trim() || _t(
|
|
324
|
+
`${K ? Pe : ""} ${(d == null ? void 0 : d.tag) ?? "Default"}`,
|
|
325
|
+
u.replace(/[-_/]+/g, " ")
|
|
326
|
+
)), W = Ne ? 1 : 0, $ = W + Q.length, b = Re >= $ ? $ - 1 : Re;
|
|
327
|
+
L(() => {
|
|
328
|
+
F(c && u.trim() ? W : -1);
|
|
329
|
+
}, [c, u, W]);
|
|
330
|
+
const Se = (e) => `${fe}-opt-${e}`, Ue = () => {
|
|
331
|
+
const e = (K == null ? void 0 : K.id) ?? (d == null ? void 0 : d.id);
|
|
332
|
+
Xe(n, e) || f(e), me();
|
|
333
|
+
}, He = (e) => {
|
|
334
|
+
Xe(n, e.id) || f(e.id), me();
|
|
335
|
+
}, Je = (e) => {
|
|
336
|
+
e < 0 || e >= $ || (e < W ? Ue() : He(Q[e - W]));
|
|
337
|
+
};
|
|
338
|
+
L(() => {
|
|
339
|
+
var r, t;
|
|
340
|
+
if (!c || b < 0) return;
|
|
341
|
+
const e = (r = ue.current) == null ? void 0 : r.querySelector(`[data-nav-index="${b}"]`);
|
|
342
|
+
(t = e == null ? void 0 : e.scrollIntoView) == null || t.call(e, { block: "nearest" });
|
|
343
|
+
}, [c, b]);
|
|
344
|
+
const dt = (e) => {
|
|
345
|
+
var r;
|
|
346
|
+
e.key === "ArrowDown" ? (e.preventDefault(), $ > 0 && F(b < 0 ? 0 : Math.min(b + 1, $ - 1))) : e.key === "ArrowUp" ? (e.preventDefault(), $ > 0 && F(b <= 0 ? 0 : b - 1)) : e.key === "Home" && $ > 0 && !u ? (e.preventDefault(), F(0)) : e.key === "End" && $ > 0 && !u ? (e.preventDefault(), F($ - 1)) : e.key === "Enter" ? (e.preventDefault(), b >= 0 ? Je(b) : $ === 1 && Je(0)) : e.key === "Tab" && (A(!1), (r = ne.current) == null || r.focus());
|
|
347
|
+
}, ut = (e) => {
|
|
348
|
+
y || (!c && (e.key === "ArrowDown" || e.key === "ArrowUp") ? (e.preventDefault(), A(!0)) : !c && e.key.length === 1 && e.key !== " " && !e.ctrlKey && !e.metaKey && !e.altKey && (e.preventDefault(), A(!0), de(e.key)));
|
|
349
|
+
}, _e = xt();
|
|
350
|
+
return L(() => {
|
|
351
|
+
!_e || !D || se === void 0 || _e(D, G);
|
|
352
|
+
}, [_e, D, G, se]), U ? /* @__PURE__ */ h(
|
|
289
353
|
"button",
|
|
290
354
|
{
|
|
291
355
|
type: "button",
|
|
292
356
|
disabled: !0,
|
|
293
357
|
className: "flex h-9 w-full items-center justify-between gap-2 rounded-md border border-input bg-background px-3 text-sm text-left opacity-50 cursor-not-allowed",
|
|
294
358
|
children: [
|
|
295
|
-
/* @__PURE__ */
|
|
359
|
+
/* @__PURE__ */ h("span", { className: "truncate text-muted-foreground", children: [
|
|
296
360
|
"Select ",
|
|
297
|
-
|
|
361
|
+
U,
|
|
298
362
|
" first"
|
|
299
363
|
] }),
|
|
300
|
-
/* @__PURE__ */ s(
|
|
364
|
+
/* @__PURE__ */ s(Ve, { className: "h-4 w-4 shrink-0 opacity-50" })
|
|
301
365
|
]
|
|
302
366
|
}
|
|
303
367
|
) : (
|
|
304
368
|
// Stale tooltip binds on the WRAPPER: a disabled trigger button swallows
|
|
305
369
|
// mouse events, so a locked-but-stale field would never show the hint.
|
|
306
|
-
/* @__PURE__ */
|
|
307
|
-
/* @__PURE__ */
|
|
370
|
+
/* @__PURE__ */ h("div", { ref: J, className: "relative", ...Fe.bind, children: [
|
|
371
|
+
/* @__PURE__ */ h(
|
|
308
372
|
"button",
|
|
309
373
|
{
|
|
374
|
+
ref: ne,
|
|
310
375
|
type: "button",
|
|
311
376
|
disabled: y,
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
377
|
+
"aria-haspopup": "listbox",
|
|
378
|
+
"aria-expanded": c,
|
|
379
|
+
onClick: () => A((e) => !e),
|
|
380
|
+
onKeyDown: ut,
|
|
381
|
+
className: O(
|
|
382
|
+
"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 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/60 disabled:pointer-events-none disabled:opacity-50",
|
|
383
|
+
G ? "border-amber-300 dark:border-amber-600" : "border-input"
|
|
316
384
|
),
|
|
317
385
|
children: [
|
|
318
|
-
|
|
386
|
+
ct ? /* @__PURE__ */ s(ce, { className: "h-3.5 w-3.5 animate-spin text-muted-foreground" }) : /* @__PURE__ */ h(
|
|
319
387
|
"span",
|
|
320
388
|
{
|
|
321
|
-
className:
|
|
389
|
+
className: O(
|
|
322
390
|
"flex items-center gap-1.5 truncate min-w-0",
|
|
323
|
-
!
|
|
391
|
+
(!we || we === ee) && "text-muted-foreground"
|
|
324
392
|
),
|
|
325
393
|
children: [
|
|
326
|
-
|
|
327
|
-
/* @__PURE__ */ s("span", { className: "truncate", children:
|
|
394
|
+
G && /* @__PURE__ */ s(ft, { className: "h-3.5 w-3.5 shrink-0 text-amber-500" }),
|
|
395
|
+
/* @__PURE__ */ s("span", { className: "truncate", children: we ?? R ?? "Select…" })
|
|
328
396
|
]
|
|
329
397
|
}
|
|
330
398
|
),
|
|
331
|
-
/* @__PURE__ */ s(
|
|
399
|
+
/* @__PURE__ */ s(Ve, { className: "h-4 w-4 shrink-0 opacity-50" })
|
|
332
400
|
]
|
|
333
401
|
}
|
|
334
402
|
),
|
|
335
|
-
|
|
336
|
-
c &&
|
|
337
|
-
/* @__PURE__ */
|
|
403
|
+
Fe.tip,
|
|
404
|
+
c && De && Ie && Ge(
|
|
405
|
+
/* @__PURE__ */ h(
|
|
338
406
|
"div",
|
|
339
407
|
{
|
|
408
|
+
ref: ue,
|
|
340
409
|
"data-nvr-combobox-panel": "",
|
|
341
|
-
style:
|
|
342
|
-
className:
|
|
410
|
+
style: De,
|
|
411
|
+
className: O(
|
|
343
412
|
"nvr-pop-in rounded-md border border-border bg-popover shadow-md",
|
|
344
|
-
|
|
413
|
+
l != null && l.length ? "w-[560px] max-w-[92vw]" : "min-w-[240px] w-max max-w-[360px]"
|
|
345
414
|
),
|
|
346
415
|
children: [
|
|
347
|
-
!!(
|
|
348
|
-
const
|
|
349
|
-
return
|
|
416
|
+
!!(l != null && l.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: l.map((e) => {
|
|
417
|
+
const r = ot[e.field];
|
|
418
|
+
return r ? /* @__PURE__ */ h("div", { children: [
|
|
350
419
|
/* @__PURE__ */ s("p", { className: "mb-0.5 text-[10px] font-medium uppercase tracking-wide text-slate-400", children: e.label ?? e.field }),
|
|
351
420
|
/* @__PURE__ */ s(
|
|
352
|
-
|
|
421
|
+
Kt,
|
|
353
422
|
{
|
|
354
|
-
collection:
|
|
355
|
-
value:
|
|
356
|
-
onChange: (t) =>
|
|
423
|
+
collection: r,
|
|
424
|
+
value: be[e.field] ?? null,
|
|
425
|
+
onChange: (t) => rt((a) => ({ ...a, [e.field]: t })),
|
|
357
426
|
placeholder: "Any",
|
|
358
427
|
optionSort: e.sort,
|
|
359
428
|
extraFilter: e.filter
|
|
@@ -361,142 +430,155 @@ function dt({
|
|
|
361
430
|
)
|
|
362
431
|
] }, e.field) : null;
|
|
363
432
|
}) }),
|
|
364
|
-
/* @__PURE__ */
|
|
365
|
-
/* @__PURE__ */ s(
|
|
433
|
+
/* @__PURE__ */ h("div", { className: "flex items-center border-b px-3", children: [
|
|
434
|
+
/* @__PURE__ */ s(mt, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
|
|
366
435
|
/* @__PURE__ */ s(
|
|
367
436
|
"input",
|
|
368
437
|
{
|
|
369
|
-
ref:
|
|
370
|
-
value:
|
|
371
|
-
onChange: (e) =>
|
|
438
|
+
ref: Ee,
|
|
439
|
+
value: u,
|
|
440
|
+
onChange: (e) => de(e.target.value),
|
|
441
|
+
onKeyDown: dt,
|
|
442
|
+
role: "combobox",
|
|
443
|
+
"aria-expanded": !0,
|
|
444
|
+
"aria-autocomplete": "list",
|
|
445
|
+
"aria-controls": `${fe}-list`,
|
|
446
|
+
"aria-activedescendant": b >= 0 ? Se(b) : void 0,
|
|
372
447
|
placeholder: "Search…",
|
|
373
448
|
className: "flex h-9 w-full bg-transparent py-3 text-[13px] outline-none placeholder:text-muted-foreground"
|
|
374
449
|
}
|
|
375
450
|
),
|
|
376
|
-
|
|
377
|
-
|
|
451
|
+
V && g !== void 0 && /* @__PURE__ */ s(
|
|
452
|
+
ce,
|
|
378
453
|
{
|
|
379
454
|
"data-picker-searching": !0,
|
|
380
455
|
className: "ml-2 h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground"
|
|
381
456
|
}
|
|
382
457
|
)
|
|
383
458
|
] }),
|
|
384
|
-
/* @__PURE__ */
|
|
385
|
-
!!
|
|
459
|
+
/* @__PURE__ */ h("div", { id: `${fe}-list`, role: "listbox", className: "max-h-52 overflow-y-auto py-1", children: [
|
|
460
|
+
!!n && !y && /* @__PURE__ */ h(
|
|
386
461
|
"button",
|
|
387
462
|
{
|
|
388
463
|
type: "button",
|
|
464
|
+
tabIndex: -1,
|
|
389
465
|
onClick: () => {
|
|
390
|
-
|
|
466
|
+
lt(), me();
|
|
391
467
|
},
|
|
392
468
|
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",
|
|
393
469
|
children: [
|
|
394
|
-
/* @__PURE__ */ s(
|
|
470
|
+
/* @__PURE__ */ s(pt, { className: "h-3.5 w-3.5 text-slate-400" }),
|
|
395
471
|
"Clear selection"
|
|
396
472
|
]
|
|
397
473
|
}
|
|
398
474
|
),
|
|
399
|
-
|
|
475
|
+
Ne && /* @__PURE__ */ h(
|
|
400
476
|
"button",
|
|
401
477
|
{
|
|
402
478
|
type: "button",
|
|
479
|
+
tabIndex: -1,
|
|
480
|
+
id: Se(0),
|
|
481
|
+
role: "option",
|
|
482
|
+
"aria-selected": String(n) === k,
|
|
483
|
+
"data-nav-index": 0,
|
|
403
484
|
"data-nvr-pinned-option": !0,
|
|
404
|
-
onClick:
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
485
|
+
onClick: Ue,
|
|
486
|
+
onMouseMove: () => b !== 0 && F(0),
|
|
487
|
+
className: O(
|
|
488
|
+
"flex w-full items-center gap-2 border-b border-slate-100 px-3 py-1.5 text-left text-[13px] hover:bg-nvr-cyan/10 dark:border-border",
|
|
489
|
+
b === 0 ? "bg-nvr-cyan/10" : "bg-nvr-cyan/5"
|
|
490
|
+
),
|
|
409
491
|
children: [
|
|
410
492
|
/* @__PURE__ */ s(
|
|
411
493
|
"div",
|
|
412
494
|
{
|
|
413
|
-
className:
|
|
495
|
+
className: O(
|
|
414
496
|
"flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",
|
|
415
|
-
String(
|
|
497
|
+
String(n) === k ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300"
|
|
416
498
|
),
|
|
417
|
-
children: String(
|
|
499
|
+
children: String(n) === k && /* @__PURE__ */ s(We, { className: "h-2.5 w-2.5 text-white" })
|
|
418
500
|
}
|
|
419
501
|
),
|
|
420
|
-
/* @__PURE__ */ s("span", { className: "min-w-0 flex-1 truncate", children:
|
|
421
|
-
/* @__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: (
|
|
502
|
+
/* @__PURE__ */ s("span", { className: "min-w-0 flex-1 truncate", children: K === void 0 ? "Loading…" : Pe }),
|
|
503
|
+
/* @__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: (d == null ? void 0 : d.tag) ?? "Default" })
|
|
422
504
|
]
|
|
423
505
|
}
|
|
424
506
|
),
|
|
425
|
-
|
|
426
|
-
/* @__PURE__ */
|
|
507
|
+
g === void 0 && V ? /* @__PURE__ */ s("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ s(ce, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : Q.length === 0 && !ve ? /* @__PURE__ */ s("p", { className: "px-3 py-2 text-[13px] text-muted-foreground", children: "Searching…" }) : Q.length === 0 ? Ne && u.trim() ? null : i && i.labels.length > 0 && !u.trim() ? /* @__PURE__ */ h("div", { className: "px-3 py-2 text-[12px] leading-5 text-muted-foreground", children: [
|
|
508
|
+
/* @__PURE__ */ h("p", { children: [
|
|
427
509
|
"No options for",
|
|
428
510
|
" ",
|
|
429
|
-
/* @__PURE__ */ s("span", { className: "font-medium text-foreground", children:
|
|
430
|
-
|
|
511
|
+
/* @__PURE__ */ s("span", { className: "font-medium text-foreground", children: i.labels.join(" · ") }),
|
|
512
|
+
i.onClear ? " — clear one to widen the list:" : "."
|
|
431
513
|
] }),
|
|
432
|
-
|
|
433
|
-
(e,
|
|
514
|
+
i.onClear && /* @__PURE__ */ s("div", { className: "mt-1.5 flex flex-wrap gap-1.5", children: i.keys.map(
|
|
515
|
+
(e, r) => i.clearable && !i.clearable.includes(e) ? null : /* @__PURE__ */ h(
|
|
434
516
|
"button",
|
|
435
517
|
{
|
|
436
518
|
type: "button",
|
|
437
519
|
onClick: (t) => {
|
|
438
|
-
var
|
|
439
|
-
t.stopPropagation(), (
|
|
520
|
+
var a;
|
|
521
|
+
t.stopPropagation(), (a = i.onClear) == null || a.call(i, e);
|
|
440
522
|
},
|
|
441
523
|
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",
|
|
442
524
|
children: [
|
|
443
525
|
"Clear ",
|
|
444
|
-
|
|
526
|
+
i.labels[r] ?? e
|
|
445
527
|
]
|
|
446
528
|
},
|
|
447
529
|
e
|
|
448
530
|
)
|
|
449
531
|
) })
|
|
450
|
-
] }) : /* @__PURE__ */ s("p", { className: "px-3 py-2 text-[13px] text-muted-foreground", children:
|
|
451
|
-
(e,
|
|
452
|
-
|
|
453
|
-
k(w, i),
|
|
454
|
-
v,
|
|
455
|
-
m === "-label"
|
|
456
|
-
)
|
|
457
|
-
)).filter((e) => !x || String(e.id) !== x).map((e) => {
|
|
458
|
-
const i = k(w, e) || `#${e.id}`, t = String(e.id) === String(r);
|
|
459
|
-
return /* @__PURE__ */ u(
|
|
532
|
+
] }) : /* @__PURE__ */ s("p", { className: "px-3 py-2 text-[13px] text-muted-foreground", children: u.trim() ? `No results for “${u.trim()}”` : "No results" }) : Q.map((e, r) => {
|
|
533
|
+
const t = S(m, e), a = X(t) ? ee : t, N = String(e.id) === String(n), _ = r + W;
|
|
534
|
+
return /* @__PURE__ */ h(
|
|
460
535
|
"button",
|
|
461
536
|
{
|
|
462
537
|
type: "button",
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
538
|
+
tabIndex: -1,
|
|
539
|
+
id: Se(_),
|
|
540
|
+
role: "option",
|
|
541
|
+
"aria-selected": N,
|
|
542
|
+
"data-nav-index": _,
|
|
543
|
+
onClick: () => He(e),
|
|
544
|
+
onMouseMove: () => b !== _ && F(_),
|
|
545
|
+
className: O(
|
|
546
|
+
"flex w-full items-center gap-2 px-3 py-1.5 text-[13px] text-left hover:bg-muted",
|
|
547
|
+
b === _ && "bg-muted"
|
|
548
|
+
),
|
|
467
549
|
children: [
|
|
468
550
|
/* @__PURE__ */ s(
|
|
469
551
|
"div",
|
|
470
552
|
{
|
|
471
|
-
className:
|
|
553
|
+
className: O(
|
|
472
554
|
"flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",
|
|
473
|
-
|
|
555
|
+
N ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300"
|
|
474
556
|
),
|
|
475
|
-
children:
|
|
557
|
+
children: N && /* @__PURE__ */ s(We, { className: "h-2.5 w-2.5 text-white" })
|
|
476
558
|
}
|
|
477
559
|
),
|
|
478
|
-
|
|
479
|
-
|
|
560
|
+
z && /* @__PURE__ */ s(
|
|
561
|
+
Nt,
|
|
480
562
|
{
|
|
481
563
|
userId: e.id,
|
|
482
564
|
className: "h-4 w-4",
|
|
483
|
-
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:
|
|
565
|
+
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: It(a) })
|
|
484
566
|
}
|
|
485
567
|
),
|
|
486
|
-
|
|
568
|
+
z && st.has(String(e.id).toUpperCase()) && /* @__PURE__ */ s(
|
|
487
569
|
"span",
|
|
488
570
|
{
|
|
489
571
|
className: "h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500",
|
|
490
572
|
"data-tip": "Online now"
|
|
491
573
|
}
|
|
492
574
|
),
|
|
493
|
-
/* @__PURE__ */ s(
|
|
494
|
-
|
|
575
|
+
/* @__PURE__ */ s(kt, { text: a, query: u }),
|
|
576
|
+
Me.has(String(e.id)) && /* @__PURE__ */ s(
|
|
495
577
|
"span",
|
|
496
578
|
{
|
|
497
579
|
className: "ml-auto max-w-[45%] shrink-0 truncate pl-2 text-[11.5px] text-muted-foreground",
|
|
498
580
|
"data-option-detail": !0,
|
|
499
|
-
children:
|
|
581
|
+
children: Me.get(String(e.id))
|
|
500
582
|
}
|
|
501
583
|
)
|
|
502
584
|
]
|
|
@@ -505,107 +587,109 @@ function dt({
|
|
|
505
587
|
);
|
|
506
588
|
})
|
|
507
589
|
] }),
|
|
508
|
-
!
|
|
509
|
-
|
|
590
|
+
!V && /* @__PURE__ */ s(
|
|
591
|
+
jt,
|
|
510
592
|
{
|
|
511
|
-
collection:
|
|
512
|
-
search:
|
|
513
|
-
filter:
|
|
514
|
-
narrowedLabels: (
|
|
515
|
-
auto: (
|
|
593
|
+
collection: o,
|
|
594
|
+
search: M,
|
|
595
|
+
filter: he,
|
|
596
|
+
narrowedLabels: (i == null ? void 0 : i.labels) ?? [],
|
|
597
|
+
auto: (g ?? []).length === 0 && !!M
|
|
516
598
|
}
|
|
517
599
|
)
|
|
518
600
|
]
|
|
519
601
|
}
|
|
520
602
|
),
|
|
521
|
-
|
|
603
|
+
Ie
|
|
522
604
|
)
|
|
523
605
|
] })
|
|
524
606
|
);
|
|
525
607
|
}
|
|
526
|
-
function
|
|
527
|
-
collection:
|
|
528
|
-
search:
|
|
529
|
-
filter:
|
|
608
|
+
function jt({
|
|
609
|
+
collection: o,
|
|
610
|
+
search: n,
|
|
611
|
+
filter: f,
|
|
530
612
|
narrowedLabels: y,
|
|
531
|
-
auto:
|
|
613
|
+
auto: R
|
|
532
614
|
}) {
|
|
533
|
-
const
|
|
534
|
-
queryKey: ["picker-narrowing",
|
|
535
|
-
queryFn: () =>
|
|
536
|
-
|
|
537
|
-
).then((
|
|
538
|
-
enabled:
|
|
615
|
+
const w = Le(), [x, p] = E(!1), U = f ? JSON.stringify(f) : "", { data: l, isFetching: D } = C({
|
|
616
|
+
queryKey: ["picker-narrowing", o, n, U],
|
|
617
|
+
queryFn: () => w.request(
|
|
618
|
+
yt("/picker-narrowing", { collection: o, search: n, filter: f ?? null })
|
|
619
|
+
).then((I) => I.data),
|
|
620
|
+
enabled: x || R,
|
|
539
621
|
staleTime: 3e4,
|
|
540
622
|
retry: !1
|
|
541
623
|
});
|
|
542
|
-
if (!
|
|
624
|
+
if (!x && !R)
|
|
543
625
|
return /* @__PURE__ */ s(
|
|
544
626
|
"button",
|
|
545
627
|
{
|
|
546
628
|
type: "button",
|
|
547
|
-
onClick: (
|
|
548
|
-
|
|
629
|
+
onClick: (I) => {
|
|
630
|
+
I.stopPropagation(), p(!0);
|
|
549
631
|
},
|
|
550
632
|
className: "w-full border-t border-border px-3 py-1.5 text-left text-[11px] text-muted-foreground hover:text-foreground",
|
|
551
633
|
"data-picker-narrowing-ask": !0,
|
|
552
634
|
children: "Missing something?"
|
|
553
635
|
}
|
|
554
636
|
);
|
|
555
|
-
if (
|
|
637
|
+
if (D && !l)
|
|
556
638
|
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…" });
|
|
557
|
-
if (!
|
|
558
|
-
const
|
|
559
|
-
return
|
|
560
|
-
`${
|
|
561
|
-
),
|
|
562
|
-
`${
|
|
563
|
-
),
|
|
564
|
-
|
|
639
|
+
if (!l) return null;
|
|
640
|
+
const i = [], d = n ? `match “${n}”` : "exist";
|
|
641
|
+
return l.by_field_filter > 0 && i.push(
|
|
642
|
+
`${l.by_field_filter.toLocaleString()} more ${d} but this field only offers ${y.length ? `records that fit ${y.join(" · ")}` : "records its filter allows"}.`
|
|
643
|
+
), l.by_exclusions > 0 && i.push(
|
|
644
|
+
`${l.by_exclusions.toLocaleString()} ${l.by_exclusions === 1 ? "is" : "are"} hidden from pickers by an admin.`
|
|
645
|
+
), l.scopes.length > 0 && i.push(`Your ${l.scopes.join(", ")} access narrows what you can pick here.`), l.row_filter && i.push("Your role only sees some of these records."), i.length === 0 && i.push(
|
|
646
|
+
n ? `Nothing else you can see matches “${n}”.` : "Nothing narrows this list — every record you can see is offered."
|
|
565
647
|
), /* @__PURE__ */ s(
|
|
566
648
|
"div",
|
|
567
649
|
{
|
|
568
650
|
className: "space-y-0.5 border-t border-border px-3 py-1.5 text-[11px] leading-4 text-muted-foreground",
|
|
569
651
|
"data-picker-narrowing": !0,
|
|
570
|
-
"data-picker-narrowing-field":
|
|
571
|
-
"data-picker-narrowing-excluded":
|
|
572
|
-
children:
|
|
652
|
+
"data-picker-narrowing-field": l.by_field_filter,
|
|
653
|
+
"data-picker-narrowing-excluded": l.by_exclusions,
|
|
654
|
+
children: i.map((I) => /* @__PURE__ */ s("p", { children: I }, I))
|
|
573
655
|
}
|
|
574
656
|
);
|
|
575
657
|
}
|
|
576
|
-
function
|
|
577
|
-
collection:
|
|
578
|
-
id:
|
|
579
|
-
displayTemplate:
|
|
658
|
+
function tn({
|
|
659
|
+
collection: o,
|
|
660
|
+
id: n,
|
|
661
|
+
displayTemplate: f
|
|
580
662
|
}) {
|
|
581
|
-
const y =
|
|
582
|
-
if (!
|
|
583
|
-
const
|
|
584
|
-
return
|
|
585
|
-
})(), { data:
|
|
586
|
-
queryKey: ["relation-single",
|
|
587
|
-
queryFn: () =>
|
|
663
|
+
const y = Le(), R = Ze(), w = o === "nivaro_files" || o === "directus_files", x = (() => {
|
|
664
|
+
if (!f || !f.includes(".")) return null;
|
|
665
|
+
const i = [...f.matchAll(/\{\{([^}]+)\}\}/g)].map((d) => d[1].trim());
|
|
666
|
+
return i.length > 0 ? ["id", ...i].join(",") : null;
|
|
667
|
+
})(), { data: p, isLoading: U, error: l } = C({
|
|
668
|
+
queryKey: ["relation-single", o, String(n), x ?? ""],
|
|
669
|
+
queryFn: () => w ? (
|
|
588
670
|
// The file's row, not its bytes: GET /files/:id downloads the whole
|
|
589
671
|
// file (twice with the retry, 404 when storage lost it) only to read
|
|
590
672
|
// its name, and a missing object left the raw id as the label.
|
|
591
673
|
y.request(
|
|
592
|
-
|
|
593
|
-
).then((
|
|
594
|
-
) :
|
|
595
|
-
enabled: !!
|
|
596
|
-
staleTime: 6e4
|
|
674
|
+
P(`/files/${encodeURIComponent(String(n))}/meta`)
|
|
675
|
+
).then((i) => i.data)
|
|
676
|
+
) : R(o, n, x),
|
|
677
|
+
enabled: !!n && !!o,
|
|
678
|
+
staleTime: 6e4,
|
|
679
|
+
retry: Rt
|
|
597
680
|
});
|
|
598
|
-
if (
|
|
599
|
-
if (!
|
|
600
|
-
if (
|
|
601
|
-
const
|
|
602
|
-
return /* @__PURE__ */ s("span", { children:
|
|
681
|
+
if (U) return /* @__PURE__ */ s(ce, { className: "h-3 w-3 animate-spin text-slate-400" });
|
|
682
|
+
if (!p) return n == null || n === "" ? null : /* @__PURE__ */ s(Dt, { error: l });
|
|
683
|
+
if (w) {
|
|
684
|
+
const i = p.title || p.filename_download || p.filename_disk || String(n);
|
|
685
|
+
return /* @__PURE__ */ s("span", { children: i });
|
|
603
686
|
}
|
|
604
|
-
|
|
687
|
+
const D = S(f, p);
|
|
688
|
+
return X(D) ? /* @__PURE__ */ s("span", { className: "italic text-muted-foreground", children: ee }) : /* @__PURE__ */ s("span", { children: D });
|
|
605
689
|
}
|
|
606
690
|
export {
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
691
|
+
tn as RelatedItemLabel,
|
|
692
|
+
Kt as RelationCombobox,
|
|
693
|
+
Xe as isSamePick,
|
|
694
|
+
At as useStaleTip
|
|
611
695
|
};
|