@nivaro/react 0.3.99 → 0.3.101
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/useFormSchema.js +82 -85
- package/dist/hooks/useSessionRecorder.js +206 -175
- package/dist/index.d.ts +84 -16
- package/dist/index.js +627 -622
- package/dist/lib/commands.js +15 -11
- package/dist/shared/components/ActivityEntry.js +5 -5
- package/dist/shared/components/CollectionBrowserView.js +516 -503
- package/dist/shared/components/ItemEditForm.js +3471 -3465
- package/dist/shared/components/JobsTray.js +76 -61
- package/dist/shared/components/MyWorkView.js +133 -126
- package/dist/shared/components/NotificationBell.js +322 -289
- package/dist/shared/components/RecordCompare.js +38 -40
- package/dist/shared/components/RecordReadView.js +119 -119
- package/dist/shared/components/TipLayer.js +56 -41
- package/dist/shared/components/cbv/FoundElsewhere.js +61 -0
- package/dist/shared/components/integrations/console/SignalCard.js +40 -40
- package/dist/shared/components/integrations/console/drill/SubmissionDrill.js +95 -73
- package/dist/shared/components/integrations/console/drill/status.js +23 -18
- package/dist/shared/components/item-edit/InlineGridField.js +45 -45
- package/dist/shared/components/item-edit/InlineTableField.js +750 -749
- package/dist/shared/components/item-edit/QuickPickerDialog.js +44 -44
- package/dist/shared/components/item-edit/RawEditSheet.js +122 -114
- package/dist/shared/components/item-edit/RecordInsights.js +86 -86
- package/dist/shared/components/item-edit/RelationCombobox.js +454 -378
- package/dist/shared/components/item-edit/SummaryPanel.js +56 -48
- package/dist/shared/components/item-edit/header-path-preview.js +46 -34
- package/dist/shared/components/item-edit/related-missing.js +75 -19
- package/dist/shared/components/notifications/DeliveryChips.js +1 -2
- package/dist/shared/components/notifications/NotificationCenterView.js +249 -226
- package/dist/shared/components/panels/AccessDeniedPanel.js +31 -28
- package/dist/shared/components/panels/BackgroundMove.js +242 -0
- package/dist/shared/components/panels/MoveAdvisory.js +204 -0
- package/dist/shared/components/panels/PipelinePanel.js +1459 -1220
- package/dist/shared/components/panels/RecordIntegrityBanner.js +113 -112
- package/dist/shared/components/profile/ActivityFeedCard.js +322 -0
- package/dist/shared/components/profile/DayTimeline.js +145 -140
- package/dist/shared/components/profile/PersonAccess.js +679 -383
- package/dist/shared/components/profile/PersonActivity.js +404 -427
- package/dist/shared/components/profile/PersonDidPanel.js +248 -134
- package/dist/shared/components/profile/PersonProfile.js +33 -32
- package/dist/shared/components/profile/journey-view.js +166 -0
- package/dist/shared/lib/activity-sentence.js +319 -236
- package/dist/shared/lib/commands.js +18 -14
- package/dist/shared/lib/error-hints.js +1 -1
- package/dist/shared/lib/job-failure-text.js +12 -0
- package/dist/shared/lib/jobs-tray.js +60 -41
- package/dist/shared/lib/move-failure.js +19 -0
- package/dist/shared/lib/obligation-banner.js +22 -21
- package/dist/shared/lib/partner-failure.js +83 -0
- package/dist/shared/lib/prefetch.js +73 -73
- package/dist/shared/lib/replay-checkout.js +18 -13
- package/dist/shared/lib/replay-context.js +90 -77
- package/dist/shared/lib/replay-idle.js +21 -0
- package/dist/shared/lib/replay-socket.js +21 -17
- package/dist/shared/lib/rum.js +56 -51
- package/dist/shared/lib/safe-error.js +17 -13
- package/dist/shared/lib/stale-chunk.js +69 -26
- package/dist/shared/lib/system-collections.js +20 -0
- package/package.json +1 -1
|
@@ -1,33 +1,33 @@
|
|
|
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
|
-
import { retryRelatedRead as
|
|
19
|
-
function
|
|
1
|
+
import { jsxs as m, jsx as s, Fragment as ft } from "react/jsx-runtime";
|
|
2
|
+
import { useQuery as I } from "@tanstack/react-query";
|
|
3
|
+
import { ChevronDown as mt, Loader2 as ye, AlertTriangle as Kt, Search as Ft, X as Ot, Check as pt } from "lucide-react";
|
|
4
|
+
import { useState as F, useRef as D, useEffect as w, useId as gt, useLayoutEffect as ht, useMemo as K } from "react";
|
|
5
|
+
import { createPortal as xt } from "react-dom";
|
|
6
|
+
import { useNivaroClient as Te, useItemEditAuth as Tt, useStaleFieldReporter as jt } from "../../context.js";
|
|
7
|
+
import { get as G, post as Mt } from "../../lib/commands.js";
|
|
8
|
+
import { compareByMatch as Pt } from "../../lib/picker-rank.js";
|
|
9
|
+
import { useRecordReader as vt } from "../../lib/record-loader.js";
|
|
10
|
+
import { useOnlineUsers as Ut } from "../../lib/use-online-users.js";
|
|
11
|
+
import { SearchHighlight as Ht } from "../SearchHighlight.js";
|
|
12
|
+
import { UserAvatar as Jt } from "../UserAvatar.js";
|
|
13
|
+
import { userOptionFilter as zt, matchesAllTokens as Yt, cn as U } from "../../lib/utils.js";
|
|
14
|
+
import { applyDisplayTemplate as k } from "./helpers.js";
|
|
15
|
+
import { collidingIds as Wt, disambiguators as Gt, isNamelessLabel as ee, NAMELESS_LABEL as le } from "./option-disambiguate.js";
|
|
16
|
+
import { usePickerMissReport as Vt } from "./picker-miss.js";
|
|
17
|
+
import { useLatestSearch as Xt, onlyCloseMatches as bt, labelOnlyMatches as Zt, narrowLocally as Qt, PICKER_PAGE as Bt } from "./picker-search.js";
|
|
18
|
+
import { retryRelatedRead as wt, useRelatedMissing as kt, RelatedMissingLabel as Nt } from "./related-missing.js";
|
|
19
|
+
function en(o) {
|
|
20
20
|
return o.replace(/\(.*$/, "").trim().split(/\s+/).map((r) => r[0]).filter(Boolean).slice(0, 2).join("").toUpperCase() || "?";
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
const [r,
|
|
24
|
-
onMouseEnter: (
|
|
22
|
+
function tn(o) {
|
|
23
|
+
const [r, h] = F(null), g = {
|
|
24
|
+
onMouseEnter: (C) => {
|
|
25
25
|
if (!o) return;
|
|
26
|
-
const
|
|
27
|
-
|
|
26
|
+
const x = C.currentTarget.getBoundingClientRect(), N = window.innerHeight - x.bottom < 80;
|
|
27
|
+
h({ x: x.left, y: N ? x.top - 58 : x.bottom + 4 });
|
|
28
28
|
},
|
|
29
|
-
onMouseLeave: () =>
|
|
30
|
-
},
|
|
29
|
+
onMouseLeave: () => h(null)
|
|
30
|
+
}, O = o && r ? xt(
|
|
31
31
|
/* @__PURE__ */ s(
|
|
32
32
|
"div",
|
|
33
33
|
{
|
|
@@ -38,229 +38,239 @@ function Zt(o) {
|
|
|
38
38
|
),
|
|
39
39
|
document.body
|
|
40
40
|
) : null;
|
|
41
|
-
return { bind:
|
|
41
|
+
return { bind: g, tip: O };
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function yt(o, r) {
|
|
44
44
|
return o == null || o === "" || r == null || r === "" ? !1 : String(o) === String(r);
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function nn({
|
|
47
47
|
collection: o,
|
|
48
48
|
value: r,
|
|
49
|
-
onChange:
|
|
50
|
-
disabled:
|
|
51
|
-
placeholder:
|
|
52
|
-
extraFilter:
|
|
53
|
-
autoSelectSingle:
|
|
54
|
-
optionSort:
|
|
55
|
-
requiredParent:
|
|
56
|
-
facets:
|
|
57
|
-
fieldKey:
|
|
58
|
-
narrowedBy:
|
|
49
|
+
onChange: h,
|
|
50
|
+
disabled: g,
|
|
51
|
+
placeholder: O,
|
|
52
|
+
extraFilter: C,
|
|
53
|
+
autoSelectSingle: x,
|
|
54
|
+
optionSort: N,
|
|
55
|
+
requiredParent: $,
|
|
56
|
+
facets: l,
|
|
57
|
+
fieldKey: T,
|
|
58
|
+
narrowedBy: d,
|
|
59
59
|
pinned: f,
|
|
60
|
-
missPlacement:
|
|
61
|
-
defaultOpen:
|
|
62
|
-
onClose:
|
|
63
|
-
displayTemplate:
|
|
60
|
+
missPlacement: y,
|
|
61
|
+
defaultOpen: xe,
|
|
62
|
+
onClose: je,
|
|
63
|
+
displayTemplate: St
|
|
64
64
|
}) {
|
|
65
|
-
const
|
|
66
|
-
de.current =
|
|
67
|
-
const
|
|
68
|
-
|
|
65
|
+
const V = Te(), Me = vt(), [i, R] = F(xe ?? !1), [c, ce] = F(""), de = D(je);
|
|
66
|
+
de.current = je;
|
|
67
|
+
const Pe = D(i);
|
|
68
|
+
w(() => {
|
|
69
69
|
var e;
|
|
70
|
-
|
|
71
|
-
}, [
|
|
72
|
-
const [
|
|
70
|
+
Pe.current && !i && ((e = de.current) == null || e.call(de)), Pe.current = i;
|
|
71
|
+
}, [i]);
|
|
72
|
+
const [Lt, _t] = F(!1), j = Xt(c, Lt), Ue = D(null), X = D(null), ve = D(null), H = D(null), we = gt(), He = gt(), [Je, J] = F(-1), M = D(null), te = () => {
|
|
73
73
|
var t;
|
|
74
|
-
const e =
|
|
74
|
+
const e = Ue.current;
|
|
75
75
|
if (!e || document.activeElement === e) return;
|
|
76
76
|
e.focus({ preventScroll: !0 });
|
|
77
77
|
const n = e.value.length;
|
|
78
78
|
(t = e.setSelectionRange) == null || t.call(e, n, n);
|
|
79
79
|
};
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}, [
|
|
83
|
-
const
|
|
80
|
+
w(() => {
|
|
81
|
+
i ? setTimeout(te, 30) : (ce(""), M.current = null);
|
|
82
|
+
}, [i]);
|
|
83
|
+
const ke = D(!1), Ne = () => {
|
|
84
84
|
var e;
|
|
85
|
-
|
|
85
|
+
R(!1), (e = H.current) == null || e.focus(), ke.current = !0;
|
|
86
86
|
};
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
w(() => {
|
|
88
|
+
var n;
|
|
89
|
+
if (!ke.current) return;
|
|
90
|
+
ke.current = !1;
|
|
91
|
+
const e = document.activeElement;
|
|
92
|
+
(!e || e === document.body) && ((n = H.current) == null || n.focus());
|
|
93
|
+
}), w(() => {
|
|
94
|
+
if (!i) return;
|
|
89
95
|
const e = (n) => {
|
|
90
|
-
var
|
|
96
|
+
var E, q, ae;
|
|
91
97
|
if (n.key !== "Escape") return;
|
|
92
98
|
const t = document.activeElement;
|
|
93
|
-
(t === document.body || t && ((
|
|
99
|
+
(t === document.body || t && ((E = ve.current) != null && E.contains(t) || (q = X.current) != null && q.contains(t))) && (n.preventDefault(), n.stopPropagation(), R(!1), (ae = H.current) == null || ae.focus());
|
|
94
100
|
};
|
|
95
101
|
return window.addEventListener("keydown", e, !0), () => window.removeEventListener("keydown", e, !0);
|
|
96
|
-
}, [
|
|
97
|
-
if (!
|
|
102
|
+
}, [i]), w(() => {
|
|
103
|
+
if (!i) return;
|
|
98
104
|
const e = (n) => {
|
|
99
|
-
var
|
|
105
|
+
var a, E;
|
|
100
106
|
const t = n.target;
|
|
101
|
-
!t || t === document.body || (
|
|
107
|
+
!t || t === document.body || (a = t.closest) != null && a.call(t, "[data-nvr-combobox-panel]") || (E = X.current) != null && E.contains(t) || R(!1);
|
|
102
108
|
};
|
|
103
109
|
return document.addEventListener("focusin", e), () => document.removeEventListener("focusin", e);
|
|
104
|
-
}, [
|
|
105
|
-
if (!
|
|
110
|
+
}, [i]), w(() => {
|
|
111
|
+
if (!i) return;
|
|
106
112
|
const e = (n) => {
|
|
107
|
-
var
|
|
113
|
+
var a;
|
|
108
114
|
const t = n.target;
|
|
109
|
-
(
|
|
115
|
+
(a = t == null ? void 0 : t.closest) != null && a.call(t, "[data-nvr-combobox-panel]") || X.current && !X.current.contains(n.target) && R(!1);
|
|
110
116
|
};
|
|
111
117
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
112
|
-
}, [
|
|
113
|
-
const [
|
|
114
|
-
|
|
115
|
-
if (!
|
|
116
|
-
|
|
118
|
+
}, [i]);
|
|
119
|
+
const [Se, Le] = F(null), [_e, Et] = F(null);
|
|
120
|
+
ht(() => {
|
|
121
|
+
if (!i) {
|
|
122
|
+
Le(null);
|
|
117
123
|
return;
|
|
118
124
|
}
|
|
119
125
|
const e = () => {
|
|
120
|
-
const n =
|
|
126
|
+
const n = X.current;
|
|
121
127
|
if (!n) return;
|
|
122
|
-
const t = n.getBoundingClientRect(),
|
|
123
|
-
|
|
124
|
-
const
|
|
128
|
+
const t = n.getBoundingClientRect(), a = n.closest('[role="dialog"]') ?? document.body;
|
|
129
|
+
Et(a);
|
|
130
|
+
const E = window.innerHeight - t.bottom < 340 && t.top > window.innerHeight - t.bottom, q = t.left, ae = E ? t.top - 4 : t.bottom + 4, dt = {
|
|
125
131
|
minWidth: t.width,
|
|
126
132
|
zIndex: 120,
|
|
127
|
-
...
|
|
133
|
+
...E ? { transform: "translateY(-100%)" } : {}
|
|
128
134
|
};
|
|
129
|
-
if (
|
|
130
|
-
|
|
135
|
+
if (a === document.body)
|
|
136
|
+
Le({ position: "fixed", left: q, top: ae, ...dt });
|
|
131
137
|
else {
|
|
132
|
-
const
|
|
133
|
-
|
|
138
|
+
const ut = a.getBoundingClientRect();
|
|
139
|
+
Le({ position: "absolute", left: q - ut.left, top: ae - ut.top, ...dt });
|
|
134
140
|
}
|
|
135
141
|
};
|
|
136
142
|
return e(), window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
|
|
137
143
|
window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
|
|
138
144
|
};
|
|
139
|
-
}, [
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}, [
|
|
144
|
-
const { data:
|
|
145
|
+
}, [i]);
|
|
146
|
+
const ze = i && !!Se && !!_e;
|
|
147
|
+
ht(() => {
|
|
148
|
+
ze && document.activeElement === H.current && te();
|
|
149
|
+
}, [ze]);
|
|
150
|
+
const { data: Ee, isPending: Ye } = I({
|
|
145
151
|
queryKey: ["col-meta", o],
|
|
146
|
-
queryFn: () =>
|
|
152
|
+
queryFn: () => V.request(G(`/collections/${o}`)).then((e) => e.data),
|
|
147
153
|
staleTime: 3e5,
|
|
148
154
|
retry: !1
|
|
149
|
-
}), [
|
|
155
|
+
}), [Ce, Ct] = F({}), { data: We = [] } = I({
|
|
150
156
|
queryKey: ["collection-meta", o],
|
|
151
|
-
queryFn: () =>
|
|
152
|
-
|
|
157
|
+
queryFn: () => V.request(
|
|
158
|
+
G(`/collections/${o}`)
|
|
153
159
|
).then(
|
|
154
160
|
(e) => {
|
|
155
161
|
var n;
|
|
156
162
|
return ((n = e.data) == null ? void 0 : n.relations) ?? [];
|
|
157
163
|
}
|
|
158
164
|
),
|
|
159
|
-
enabled: !!(
|
|
165
|
+
enabled: !!(l != null && l.length),
|
|
160
166
|
staleTime: 10 * 6e4
|
|
161
|
-
}),
|
|
167
|
+
}), $t = K(() => {
|
|
162
168
|
const e = {};
|
|
163
|
-
for (const n of
|
|
164
|
-
const t =
|
|
165
|
-
(
|
|
169
|
+
for (const n of l ?? []) {
|
|
170
|
+
const t = We.find(
|
|
171
|
+
(a) => a.many_collection === o && a.many_field === n.field && !a.junction_field
|
|
166
172
|
);
|
|
167
173
|
t != null && t.one_collection && (e[n.field] = t.one_collection);
|
|
168
174
|
}
|
|
169
175
|
return e;
|
|
170
|
-
}, [
|
|
176
|
+
}, [l, We, o]), Z = o === "nivaro_users", qt = Ut(Z), Ge = Tt().isAdmin, $e = K(() => {
|
|
171
177
|
const e = [];
|
|
172
|
-
|
|
173
|
-
for (const [n, t] of Object.entries(
|
|
178
|
+
Z && e.push(zt(Ge)), C && e.push(C);
|
|
179
|
+
for (const [n, t] of Object.entries(Ce))
|
|
174
180
|
t != null && t !== "" && e.push({ [n]: { _eq: t } });
|
|
175
181
|
if (e.length !== 0)
|
|
176
182
|
return e.length === 1 ? e[0] : { _and: e };
|
|
177
|
-
}, [
|
|
178
|
-
if (!
|
|
179
|
-
const e = [...
|
|
183
|
+
}, [C, Ce, Ge]), Q = St || (Ee == null ? void 0 : Ee.display_template) || (Z ? "{{first_name}} {{last_name}} ({{email}})" : null), v = K(() => {
|
|
184
|
+
if (!Q) return;
|
|
185
|
+
const e = [...Q.matchAll(/\{\{([\w.]+)\}\}/g)].map((n) => n[1]);
|
|
180
186
|
if (e.length)
|
|
181
187
|
return [.../* @__PURE__ */ new Set(["id", ...e])].join(",");
|
|
182
|
-
}, [
|
|
183
|
-
|
|
184
|
-
limit:
|
|
188
|
+
}, [Q]), S = $e ? JSON.stringify($e) : void 0, z = N && !/^-?label$/.test(N) ? N : void 0, Ve = (e) => V.request(
|
|
189
|
+
G(`/items/${o}`, {
|
|
190
|
+
limit: Bt,
|
|
185
191
|
picker: "1",
|
|
186
192
|
// Typo pass (fix11-search): only when the exact search finds nothing,
|
|
187
193
|
// the server answers close matches, each marked `fuzzy`.
|
|
188
194
|
...e.trim() ? { search: e.trim(), typo: "1" } : {},
|
|
189
|
-
...
|
|
190
|
-
...
|
|
191
|
-
...
|
|
195
|
+
...S ? { filter: S } : {},
|
|
196
|
+
...v ? { fields: v } : {},
|
|
197
|
+
...z ? { sort: z } : {}
|
|
192
198
|
})
|
|
193
199
|
).then((n) => n.data ?? []), {
|
|
194
200
|
data: u,
|
|
195
|
-
isFetching:
|
|
196
|
-
isPlaceholderData:
|
|
197
|
-
} =
|
|
201
|
+
isFetching: Y,
|
|
202
|
+
isPlaceholderData: qe
|
|
203
|
+
} = I({
|
|
198
204
|
queryKey: [
|
|
199
205
|
"relation-opts",
|
|
200
206
|
o,
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
207
|
+
j,
|
|
208
|
+
S,
|
|
209
|
+
v,
|
|
210
|
+
z ?? ""
|
|
205
211
|
],
|
|
206
|
-
queryFn: () =>
|
|
212
|
+
queryFn: () => Ve(j),
|
|
207
213
|
// Wait for the display template: it decides `fields`, and starting before
|
|
208
214
|
// it lands sent the whole first page twice.
|
|
209
|
-
enabled:
|
|
210
|
-
staleTime:
|
|
215
|
+
enabled: i && !Ye,
|
|
216
|
+
staleTime: S ? 0 : 3e4,
|
|
211
217
|
// A new SEARCH keeps the previous answer on screen (narrowed locally below)
|
|
212
218
|
// instead of blanking the list behind a spinner. A changed filter, sort or
|
|
213
219
|
// template never does — those rows may no longer be allowed.
|
|
214
220
|
placeholderData: (e, n) => {
|
|
215
221
|
const t = n == null ? void 0 : n.queryKey;
|
|
216
222
|
if (!(!e || !t))
|
|
217
|
-
return t[1] === o && t[3] ===
|
|
223
|
+
return t[1] === o && t[3] === S && t[4] === v && t[5] === (z ?? "") ? e : void 0;
|
|
218
224
|
}
|
|
219
225
|
});
|
|
220
|
-
|
|
221
|
-
const ue = !!
|
|
222
|
-
queryKey: ["relation-opts", o, "",
|
|
223
|
-
queryFn: () =>
|
|
224
|
-
enabled:
|
|
225
|
-
staleTime:
|
|
226
|
-
}),
|
|
227
|
-
() => ue && fe ?
|
|
226
|
+
w(() => _t(Y), [Y]);
|
|
227
|
+
const ue = !!j.trim() && c === j && !qe && !Y && u !== void 0 && (u.length === 0 || bt(u)), { data: fe } = I({
|
|
228
|
+
queryKey: ["relation-opts", o, "", S, v, z ?? ""],
|
|
229
|
+
queryFn: () => Ve(""),
|
|
230
|
+
enabled: i && !Ye && ue,
|
|
231
|
+
staleTime: S ? 0 : 3e4
|
|
232
|
+
}), A = K(
|
|
233
|
+
() => ue && fe ? Zt(
|
|
228
234
|
fe,
|
|
229
|
-
(e) =>
|
|
230
|
-
|
|
235
|
+
(e) => k(Q, e) || "",
|
|
236
|
+
c
|
|
231
237
|
) : null,
|
|
232
|
-
[ue, fe,
|
|
233
|
-
),
|
|
234
|
-
|
|
235
|
-
placement:
|
|
236
|
-
open:
|
|
237
|
-
search:
|
|
238
|
-
settled: !
|
|
239
|
-
count: (
|
|
238
|
+
[ue, fe, Q, c]
|
|
239
|
+
), Xe = ue && fe === void 0, ne = !!u && bt(u) && !(A && A.length > 0);
|
|
240
|
+
Vt({
|
|
241
|
+
placement: y,
|
|
242
|
+
open: i,
|
|
243
|
+
search: j,
|
|
244
|
+
settled: !Y && !qe && u !== void 0 && !Xe,
|
|
245
|
+
count: (A == null ? void 0 : A.length) ?? (u == null ? void 0 : u.length) ?? 0
|
|
240
246
|
});
|
|
241
247
|
const {
|
|
242
248
|
data: re,
|
|
243
|
-
isLoading:
|
|
244
|
-
error:
|
|
245
|
-
isFetched:
|
|
246
|
-
} =
|
|
247
|
-
queryKey: ["relation-single", o, String(r),
|
|
248
|
-
queryFn: () =>
|
|
249
|
+
isLoading: Ze,
|
|
250
|
+
error: Qe,
|
|
251
|
+
isFetched: Rt
|
|
252
|
+
} = I({
|
|
253
|
+
queryKey: ["relation-single", o, String(r), v],
|
|
254
|
+
queryFn: () => Me(o, r, v),
|
|
249
255
|
enabled: !!r,
|
|
250
256
|
staleTime: 6e4,
|
|
251
|
-
retry:
|
|
252
|
-
}),
|
|
253
|
-
|
|
254
|
-
|
|
257
|
+
retry: wt
|
|
258
|
+
}), Be = !!r && !Ze && Rt && !re, { settling: et } = kt(
|
|
259
|
+
Qe,
|
|
260
|
+
Be ? o : null,
|
|
261
|
+
r
|
|
262
|
+
), L = (f == null ? void 0 : f.id) != null && f.id !== "" ? String(f.id) : null, { data: P } = I({
|
|
263
|
+
queryKey: ["relation-single", o, L ?? "", v],
|
|
264
|
+
queryFn: () => Me(o, L, v).catch(
|
|
255
265
|
() => null
|
|
256
266
|
),
|
|
257
|
-
enabled: !!
|
|
267
|
+
enabled: !!L && i,
|
|
258
268
|
staleTime: 6e4
|
|
259
|
-
}),
|
|
260
|
-
queryKey: ["relation-avail", o, String(r),
|
|
261
|
-
queryFn: () =>
|
|
262
|
-
|
|
263
|
-
filter:
|
|
269
|
+
}), Dt = JSON.stringify(C ? { _and: [{ id: { _eq: r } }, C] } : { id: { _eq: r } }), { data: me } = I({
|
|
270
|
+
queryKey: ["relation-avail", o, String(r), S],
|
|
271
|
+
queryFn: () => V.request(
|
|
272
|
+
G(`/items/${o}`, {
|
|
273
|
+
filter: Dt,
|
|
264
274
|
picker: "1",
|
|
265
275
|
limit: 1,
|
|
266
276
|
fields: "id"
|
|
@@ -269,211 +279,264 @@ function Qt({
|
|
|
269
279
|
// The pinned option is offered OUTSIDE the option filter (a type's generic
|
|
270
280
|
// item is excluded from the general list on purpose), so a value that IS
|
|
271
281
|
// the pin is available by construction — never probe it, never flag it.
|
|
272
|
-
enabled: !!r && !!re && String(r) !==
|
|
282
|
+
enabled: !!r && !!re && String(r) !== L,
|
|
273
283
|
staleTime: 3e4
|
|
274
|
-
}), oe = !!r && String(r) !==
|
|
275
|
-
|
|
284
|
+
}), oe = !!r && String(r) !== L && me !== void 0 && me.length === 0, pe = D(null), Re = D(!1), tt = `${o}|${S ?? ""}`, It = () => {
|
|
285
|
+
Re.current = !0, pe.current = tt, h(null);
|
|
276
286
|
}, ge = r == null || r === "";
|
|
277
|
-
|
|
278
|
-
ge || (
|
|
279
|
-
}, [ge]),
|
|
280
|
-
if (!
|
|
281
|
-
const e =
|
|
282
|
-
pe.current !== e && (pe.current = e,
|
|
283
|
-
|
|
287
|
+
w(() => {
|
|
288
|
+
ge || (Re.current = !1);
|
|
289
|
+
}, [ge]), w(() => {
|
|
290
|
+
if (!x || g || !ge || Re.current) return;
|
|
291
|
+
const e = tt;
|
|
292
|
+
pe.current !== e && (pe.current = e, V.request(
|
|
293
|
+
G(`/items/${o}`, {
|
|
284
294
|
limit: 2,
|
|
285
295
|
picker: "1",
|
|
286
296
|
fields: "id",
|
|
287
|
-
...
|
|
297
|
+
...S ? { filter: S } : {}
|
|
288
298
|
})
|
|
289
299
|
).then((n) => {
|
|
290
|
-
var
|
|
300
|
+
var a;
|
|
291
301
|
const t = n.data ?? [];
|
|
292
|
-
t.length === 1 && ((
|
|
302
|
+
t.length === 1 && ((a = t[0]) == null ? void 0 : a.id) != null && h(t[0].id);
|
|
293
303
|
}).catch(() => {
|
|
294
304
|
pe.current = null;
|
|
295
305
|
}));
|
|
296
|
-
}, [
|
|
297
|
-
const
|
|
298
|
-
() => (
|
|
306
|
+
}, [x, g, ge, o, S]);
|
|
307
|
+
const b = Q, De = r && re ? k(b, re) : null, Ie = De === null ? null : ee(De) ? le : De, W = !qe && c === j && !Xe, Ae = K(
|
|
308
|
+
() => (A && (A.length > 0 || !(u != null && u.length)) ? A : null) ?? Qt(
|
|
299
309
|
u ?? [],
|
|
300
|
-
(e) =>
|
|
310
|
+
(e) => k(b, e) || `#${e.id}`,
|
|
301
311
|
// The server also reads a joined code by its parts ("2026-NNO-POWER"
|
|
302
312
|
// finds 2026-WEST-NNO-HE-POWERING, services/search-synonyms.ts), so
|
|
303
313
|
// the list narrowed while that search is out does too.
|
|
304
|
-
|
|
305
|
-
|
|
314
|
+
c.replace(/[-_/]+/g, " "),
|
|
315
|
+
W
|
|
306
316
|
),
|
|
307
|
-
[u,
|
|
308
|
-
), he =
|
|
309
|
-
() =>
|
|
310
|
-
[u,
|
|
311
|
-
), { data: se } =
|
|
317
|
+
[u, b, c, W, A]
|
|
318
|
+
), he = K(
|
|
319
|
+
() => Wt(u ?? [], (e) => k(b, e) || `#${e.id}`),
|
|
320
|
+
[u, b]
|
|
321
|
+
), { data: se } = I({
|
|
312
322
|
queryKey: ["relation-opts-dups", o, he.join(",")],
|
|
313
|
-
queryFn: () =>
|
|
314
|
-
|
|
323
|
+
queryFn: () => V.request(
|
|
324
|
+
G(`/items/${o}`, {
|
|
315
325
|
limit: he.length,
|
|
316
326
|
picker: "1",
|
|
317
327
|
filter: JSON.stringify({ id: { _in: he } }),
|
|
318
328
|
fields: "*"
|
|
319
329
|
})
|
|
320
330
|
).then((e) => e.data ?? []),
|
|
321
|
-
enabled:
|
|
331
|
+
enabled: i && he.length > 0 && !Z,
|
|
322
332
|
staleTime: 6e4
|
|
323
|
-
}),
|
|
333
|
+
}), nt = K(() => {
|
|
324
334
|
if (!(se != null && se.length)) return /* @__PURE__ */ new Map();
|
|
325
335
|
const e = new Map(
|
|
326
336
|
(u ?? []).map((t) => [
|
|
327
337
|
String(t.id),
|
|
328
|
-
(
|
|
338
|
+
(k(b, t) || `#${t.id}`).trim().toLowerCase()
|
|
329
339
|
])
|
|
330
340
|
), n = /* @__PURE__ */ new Map();
|
|
331
341
|
for (const t of se) {
|
|
332
|
-
const
|
|
333
|
-
|
|
342
|
+
const a = e.get(String(t.id));
|
|
343
|
+
a !== void 0 && n.set(a, [...n.get(a) ?? [], t]);
|
|
334
344
|
}
|
|
335
|
-
return
|
|
345
|
+
return Gt(
|
|
336
346
|
[...n.values()],
|
|
337
|
-
((
|
|
347
|
+
((v == null ? void 0 : v.split(",")) ?? []).map((t) => t.split(".")[0])
|
|
338
348
|
);
|
|
339
|
-
}, [se, u,
|
|
340
|
-
() => (u ?? []).some((e) => !
|
|
341
|
-
[u,
|
|
342
|
-
), ie =
|
|
343
|
-
() => (
|
|
344
|
-
(e, n) =>
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
+
}, [se, u, b, v]), At = !!r && Ze && !re || et, rt = tn(oe), ot = K(
|
|
350
|
+
() => (u ?? []).some((e) => !ee(k(b, e))),
|
|
351
|
+
[u, b]
|
|
352
|
+
), ie = K(
|
|
353
|
+
() => (z ? [...Ae] : [...Ae].sort(
|
|
354
|
+
(e, n) => Pt(
|
|
355
|
+
k(b, e),
|
|
356
|
+
k(b, n),
|
|
357
|
+
c,
|
|
358
|
+
N === "-label"
|
|
349
359
|
)
|
|
350
|
-
)).filter((e) => !
|
|
351
|
-
(e) => !
|
|
360
|
+
)).filter((e) => !L || String(e.id) !== L).filter(
|
|
361
|
+
(e) => !ot || String(e.id) === String(r) || !ee(k(b, e))
|
|
352
362
|
),
|
|
353
|
-
[
|
|
354
|
-
),
|
|
355
|
-
`${
|
|
356
|
-
|
|
357
|
-
)),
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
}, [
|
|
361
|
-
const
|
|
362
|
-
const e = (
|
|
363
|
-
|
|
364
|
-
},
|
|
365
|
-
|
|
363
|
+
[Ae, z, b, c, N, L, r, ot]
|
|
364
|
+
), st = P && !ee(k(b, P)) ? k(b, P) : le, Ke = !!L && (!c.trim() || Yt(
|
|
365
|
+
`${P ? st : ""} ${(f == null ? void 0 : f.tag) ?? "Default"}`,
|
|
366
|
+
c.replace(/[-_/]+/g, " ")
|
|
367
|
+
)), B = Ke ? 1 : 0, _ = B + ie.length, p = Je >= _ ? _ - 1 : Je;
|
|
368
|
+
w(() => {
|
|
369
|
+
J(i && c.trim() && !ne ? B : -1);
|
|
370
|
+
}, [i, c, B, ne]);
|
|
371
|
+
const Fe = (e) => `${we}-opt-${e}`, it = () => {
|
|
372
|
+
const e = (P == null ? void 0 : P.id) ?? (f == null ? void 0 : f.id);
|
|
373
|
+
yt(r, e) || h(e), Ne();
|
|
374
|
+
}, at = (e) => {
|
|
375
|
+
yt(r, e.id) || h(e.id), Ne();
|
|
366
376
|
}, be = (e) => {
|
|
367
|
-
e < 0 || e >=
|
|
377
|
+
e < 0 || e >= _ || (e < B ? it() : at(ie[e - B]));
|
|
368
378
|
};
|
|
369
|
-
|
|
379
|
+
w(() => {
|
|
370
380
|
var n, t;
|
|
371
|
-
if (!
|
|
372
|
-
const e = (n =
|
|
381
|
+
if (!i || p < 0) return;
|
|
382
|
+
const e = (n = ve.current) == null ? void 0 : n.querySelector(`[data-nav-index="${p}"]`);
|
|
373
383
|
(t = e == null ? void 0 : e.scrollIntoView) == null || t.call(e, { block: "nearest" });
|
|
374
|
-
}, [
|
|
375
|
-
const e =
|
|
384
|
+
}, [i, p]), w(() => {
|
|
385
|
+
const e = M.current;
|
|
376
386
|
if (e !== null) {
|
|
377
|
-
if (!
|
|
378
|
-
|
|
387
|
+
if (!i || e !== c) {
|
|
388
|
+
M.current = null;
|
|
379
389
|
return;
|
|
380
390
|
}
|
|
381
|
-
|
|
391
|
+
W && (M.current = null, p >= 0 ? be(p) : _ === 1 && u !== void 0 && !ne && be(0));
|
|
382
392
|
}
|
|
383
|
-
}, [
|
|
384
|
-
const
|
|
393
|
+
}, [i, c, W, p, _]);
|
|
394
|
+
const lt = (e) => {
|
|
385
395
|
var n;
|
|
386
|
-
e.key === "ArrowDown" ? (e.preventDefault(),
|
|
387
|
-
},
|
|
388
|
-
if (
|
|
389
|
-
const n = e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey && (
|
|
390
|
-
if (!
|
|
391
|
-
e.preventDefault(),
|
|
396
|
+
e.key === "ArrowDown" ? (e.preventDefault(), _ > 0 && J(p < 0 ? 0 : Math.min(p + 1, _ - 1))) : e.key === "ArrowUp" ? (e.preventDefault(), _ > 0 && J(p <= 0 ? 0 : p - 1)) : e.key === "Home" && _ > 0 && !c ? (e.preventDefault(), J(0)) : e.key === "End" && _ > 0 && !c ? (e.preventDefault(), J(_ - 1)) : e.key === "Enter" ? (e.preventDefault(), c.trim() && !W ? M.current = c : p >= 0 ? be(p) : _ === 1 && W && u !== void 0 && !ne && be(0)) : e.key === "Tab" && (R(!1), (n = H.current) == null || n.focus());
|
|
397
|
+
}, ct = (e) => {
|
|
398
|
+
if (g) return;
|
|
399
|
+
const n = e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey && (i || e.key !== " ");
|
|
400
|
+
if (!i && (e.key === "ArrowDown" || e.key === "ArrowUp"))
|
|
401
|
+
e.preventDefault(), R(!0);
|
|
392
402
|
else if (n) {
|
|
393
403
|
e.preventDefault();
|
|
394
404
|
const t = e.key;
|
|
395
|
-
|
|
396
|
-
} else
|
|
397
|
-
},
|
|
398
|
-
return
|
|
399
|
-
!
|
|
400
|
-
}, [
|
|
405
|
+
M.current = null, ce((a) => t === " " && (a === "" || a.endsWith(" ")) ? a : a + t), i ? te() : R(!0);
|
|
406
|
+
} else i && e.key === "Backspace" ? (e.preventDefault(), M.current = null, ce((t) => t.slice(0, -1)), te()) : i && (e.key === "Enter" || e.key === "ArrowDown" || e.key === "ArrowUp" || e.key === "Home" || e.key === "End") && (lt(e), te());
|
|
407
|
+
}, Oe = jt();
|
|
408
|
+
return w(() => {
|
|
409
|
+
!Oe || !T || me === void 0 || Oe(T, oe);
|
|
410
|
+
}, [Oe, T, oe, me]), $ ? /* @__PURE__ */ m(
|
|
401
411
|
"button",
|
|
402
412
|
{
|
|
403
413
|
type: "button",
|
|
404
414
|
disabled: !0,
|
|
405
415
|
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",
|
|
406
416
|
children: [
|
|
407
|
-
/* @__PURE__ */
|
|
417
|
+
/* @__PURE__ */ m("span", { className: "truncate text-muted-foreground", children: [
|
|
408
418
|
"Select ",
|
|
409
|
-
|
|
419
|
+
$,
|
|
410
420
|
" first"
|
|
411
421
|
] }),
|
|
412
|
-
/* @__PURE__ */ s(
|
|
422
|
+
/* @__PURE__ */ s(mt, { className: "h-4 w-4 shrink-0 opacity-50" })
|
|
413
423
|
]
|
|
414
424
|
}
|
|
415
425
|
) : (
|
|
416
426
|
// Stale tooltip binds on the WRAPPER: a disabled trigger button swallows
|
|
417
427
|
// mouse events, so a locked-but-stale field would never show the hint.
|
|
418
|
-
/* @__PURE__ */
|
|
419
|
-
|
|
428
|
+
/* @__PURE__ */ m("div", { ref: X, className: "relative", ...rt.bind, children: [
|
|
429
|
+
Be && !et ? (
|
|
430
|
+
// A value the reader cannot open is words, not a button: the field
|
|
431
|
+
// says the value is hidden from them (or gone) and, when it may be
|
|
432
|
+
// edited, offers the one thing they can do about it. It used to be
|
|
433
|
+
// the picker's own button reading "Record not found" — a broken
|
|
434
|
+
// record with a control that explained nothing (production review
|
|
435
|
+
// 2026-11-12); locked, that button was dead as well.
|
|
436
|
+
// biome-ignore lint/a11y/noStaticElementInteractions: a pointer shortcut only; "Change" inside is the control a keyboard and a screen reader reach
|
|
437
|
+
// biome-ignore lint/a11y/useKeyWithClickEvents: as above — the keys are handled on "Change"
|
|
438
|
+
/* @__PURE__ */ m(
|
|
439
|
+
"div",
|
|
440
|
+
{
|
|
441
|
+
"data-related-unavailable-field": "",
|
|
442
|
+
onClick: g ? void 0 : (e) => {
|
|
443
|
+
e.target.closest("button") || R((n) => !n);
|
|
444
|
+
},
|
|
445
|
+
className: U(
|
|
446
|
+
"flex h-9 w-full items-center gap-2 rounded-md border border-slate-200 bg-slate-50 px-3 text-sm dark:border-border dark:bg-muted/40",
|
|
447
|
+
!g && "cursor-pointer"
|
|
448
|
+
),
|
|
449
|
+
children: [
|
|
450
|
+
/* @__PURE__ */ s("span", { className: "min-w-0 flex-1 truncate", children: /* @__PURE__ */ s(
|
|
451
|
+
Nt,
|
|
452
|
+
{
|
|
453
|
+
error: Qe,
|
|
454
|
+
collection: o,
|
|
455
|
+
id: r,
|
|
456
|
+
labelId: He
|
|
457
|
+
}
|
|
458
|
+
) }),
|
|
459
|
+
!g && /* @__PURE__ */ s(
|
|
460
|
+
"button",
|
|
461
|
+
{
|
|
462
|
+
ref: H,
|
|
463
|
+
type: "button",
|
|
464
|
+
"aria-haspopup": "listbox",
|
|
465
|
+
"aria-expanded": i,
|
|
466
|
+
"aria-describedby": He,
|
|
467
|
+
onClick: () => R((e) => !e),
|
|
468
|
+
onKeyDown: ct,
|
|
469
|
+
className: "-mr-1 shrink-0 rounded border border-slate-300 px-2 py-0.5 text-[11px] font-medium text-slate-700 hover:bg-slate-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/60 dark:border-slate-600",
|
|
470
|
+
children: "Change"
|
|
471
|
+
}
|
|
472
|
+
)
|
|
473
|
+
]
|
|
474
|
+
}
|
|
475
|
+
)
|
|
476
|
+
) : /* @__PURE__ */ m(
|
|
420
477
|
"button",
|
|
421
478
|
{
|
|
422
|
-
ref:
|
|
479
|
+
ref: H,
|
|
423
480
|
type: "button",
|
|
424
|
-
disabled:
|
|
481
|
+
disabled: g,
|
|
425
482
|
"aria-haspopup": "listbox",
|
|
426
|
-
"aria-expanded":
|
|
427
|
-
onClick: () =>
|
|
428
|
-
onKeyDown:
|
|
429
|
-
className:
|
|
483
|
+
"aria-expanded": i,
|
|
484
|
+
onClick: () => R((e) => !e),
|
|
485
|
+
onKeyDown: ct,
|
|
486
|
+
className: U(
|
|
430
487
|
"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",
|
|
431
488
|
oe ? "border-amber-300 dark:border-amber-600" : "border-input"
|
|
432
489
|
),
|
|
433
490
|
children: [
|
|
434
|
-
|
|
491
|
+
At ? /* @__PURE__ */ s(ye, { className: "h-3.5 w-3.5 animate-spin text-muted-foreground" }) : /* @__PURE__ */ m(
|
|
435
492
|
"span",
|
|
436
493
|
{
|
|
437
|
-
className:
|
|
494
|
+
className: U(
|
|
438
495
|
"flex items-center gap-1.5 truncate min-w-0",
|
|
439
|
-
(!
|
|
496
|
+
(!Ie || Ie === le) && "text-muted-foreground"
|
|
440
497
|
),
|
|
441
498
|
children: [
|
|
442
|
-
oe && /* @__PURE__ */
|
|
443
|
-
/* @__PURE__ */ s(
|
|
499
|
+
oe && /* @__PURE__ */ m(ft, { children: [
|
|
500
|
+
/* @__PURE__ */ s(
|
|
501
|
+
Kt,
|
|
502
|
+
{
|
|
503
|
+
"aria-hidden": "true",
|
|
504
|
+
className: "h-3.5 w-3.5 shrink-0 text-amber-500"
|
|
505
|
+
}
|
|
506
|
+
),
|
|
444
507
|
/* @__PURE__ */ s("span", { className: "sr-only", children: "Not an available option: " })
|
|
445
508
|
] }),
|
|
446
|
-
|
|
509
|
+
/* @__PURE__ */ s("span", { className: "truncate", children: Ie ?? O ?? "Select…" })
|
|
447
510
|
]
|
|
448
511
|
}
|
|
449
512
|
),
|
|
450
|
-
/* @__PURE__ */ s(
|
|
513
|
+
/* @__PURE__ */ s(mt, { className: "h-4 w-4 shrink-0 opacity-50" })
|
|
451
514
|
]
|
|
452
515
|
}
|
|
453
516
|
),
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
/* @__PURE__ */
|
|
517
|
+
rt.tip,
|
|
518
|
+
i && Se && _e && xt(
|
|
519
|
+
/* @__PURE__ */ m(
|
|
457
520
|
"div",
|
|
458
521
|
{
|
|
459
|
-
ref:
|
|
522
|
+
ref: ve,
|
|
460
523
|
"data-nvr-combobox-panel": "",
|
|
461
|
-
style:
|
|
462
|
-
className:
|
|
524
|
+
style: Se,
|
|
525
|
+
className: U(
|
|
463
526
|
"nvr-pop-in rounded-md border border-border bg-popover shadow-md",
|
|
464
|
-
|
|
527
|
+
l != null && l.length ? "w-[560px] max-w-[92vw]" : "min-w-[240px] w-max max-w-[360px]"
|
|
465
528
|
),
|
|
466
529
|
children: [
|
|
467
|
-
!!(
|
|
468
|
-
const n =
|
|
469
|
-
return n ? /* @__PURE__ */
|
|
530
|
+
!!(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) => {
|
|
531
|
+
const n = $t[e.field];
|
|
532
|
+
return n ? /* @__PURE__ */ m("div", { children: [
|
|
470
533
|
/* @__PURE__ */ s("p", { className: "mb-0.5 text-[10px] font-medium uppercase tracking-wide text-slate-400", children: e.label ?? e.field }),
|
|
471
534
|
/* @__PURE__ */ s(
|
|
472
|
-
|
|
535
|
+
nn,
|
|
473
536
|
{
|
|
474
537
|
collection: n,
|
|
475
|
-
value:
|
|
476
|
-
onChange: (t) =>
|
|
538
|
+
value: Ce[e.field] ?? null,
|
|
539
|
+
onChange: (t) => Ct((a) => ({ ...a, [e.field]: t })),
|
|
477
540
|
placeholder: "Any",
|
|
478
541
|
optionSort: e.sort,
|
|
479
542
|
extraFilter: e.filter
|
|
@@ -481,27 +544,27 @@ function Qt({
|
|
|
481
544
|
)
|
|
482
545
|
] }, e.field) : null;
|
|
483
546
|
}) }),
|
|
484
|
-
/* @__PURE__ */
|
|
485
|
-
/* @__PURE__ */ s(
|
|
547
|
+
/* @__PURE__ */ m("div", { className: "flex items-center border-b px-3", children: [
|
|
548
|
+
/* @__PURE__ */ s(Ft, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
|
|
486
549
|
/* @__PURE__ */ s(
|
|
487
550
|
"input",
|
|
488
551
|
{
|
|
489
|
-
ref:
|
|
490
|
-
value:
|
|
552
|
+
ref: Ue,
|
|
553
|
+
value: c,
|
|
491
554
|
onChange: (e) => {
|
|
492
|
-
|
|
555
|
+
M.current = null, ce(e.target.value);
|
|
493
556
|
},
|
|
494
|
-
onKeyDown:
|
|
557
|
+
onKeyDown: lt,
|
|
495
558
|
role: "combobox",
|
|
496
559
|
"aria-expanded": !0,
|
|
497
560
|
"aria-autocomplete": "list",
|
|
498
|
-
"aria-controls": `${
|
|
499
|
-
"aria-activedescendant":
|
|
561
|
+
"aria-controls": `${we}-list`,
|
|
562
|
+
"aria-activedescendant": p >= 0 ? Fe(p) : void 0,
|
|
500
563
|
placeholder: "Search…",
|
|
501
564
|
className: "flex h-9 w-full bg-transparent py-3 text-[13px] outline-none placeholder:text-muted-foreground"
|
|
502
565
|
}
|
|
503
566
|
),
|
|
504
|
-
|
|
567
|
+
Y && u !== void 0 && /* @__PURE__ */ s(
|
|
505
568
|
ye,
|
|
506
569
|
{
|
|
507
570
|
"data-picker-searching": !0,
|
|
@@ -509,142 +572,142 @@ function Qt({
|
|
|
509
572
|
}
|
|
510
573
|
)
|
|
511
574
|
] }),
|
|
512
|
-
/* @__PURE__ */
|
|
513
|
-
!!r && !
|
|
575
|
+
/* @__PURE__ */ m("div", { id: `${we}-list`, role: "listbox", className: "max-h-52 overflow-y-auto py-1", children: [
|
|
576
|
+
!!r && !g && /* @__PURE__ */ m(
|
|
514
577
|
"button",
|
|
515
578
|
{
|
|
516
579
|
type: "button",
|
|
517
580
|
tabIndex: -1,
|
|
518
581
|
onClick: () => {
|
|
519
|
-
|
|
582
|
+
It(), Ne();
|
|
520
583
|
},
|
|
521
584
|
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",
|
|
522
585
|
children: [
|
|
523
|
-
/* @__PURE__ */ s(
|
|
586
|
+
/* @__PURE__ */ s(Ot, { className: "h-3.5 w-3.5 text-slate-400" }),
|
|
524
587
|
"Clear selection"
|
|
525
588
|
]
|
|
526
589
|
}
|
|
527
590
|
),
|
|
528
|
-
|
|
591
|
+
Ke && /* @__PURE__ */ m(
|
|
529
592
|
"button",
|
|
530
593
|
{
|
|
531
594
|
type: "button",
|
|
532
595
|
tabIndex: -1,
|
|
533
|
-
id:
|
|
596
|
+
id: Fe(0),
|
|
534
597
|
role: "option",
|
|
535
|
-
"aria-selected": String(r) ===
|
|
598
|
+
"aria-selected": String(r) === L,
|
|
536
599
|
"data-nav-index": 0,
|
|
537
600
|
"data-nvr-pinned-option": !0,
|
|
538
|
-
onClick:
|
|
539
|
-
onMouseMove: () =>
|
|
540
|
-
className:
|
|
601
|
+
onClick: it,
|
|
602
|
+
onMouseMove: () => p !== 0 && J(0),
|
|
603
|
+
className: U(
|
|
541
604
|
"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",
|
|
542
|
-
|
|
605
|
+
p === 0 ? "bg-nvr-cyan/10" : "bg-nvr-cyan/5"
|
|
543
606
|
),
|
|
544
607
|
children: [
|
|
545
608
|
/* @__PURE__ */ s(
|
|
546
609
|
"div",
|
|
547
610
|
{
|
|
548
|
-
className:
|
|
611
|
+
className: U(
|
|
549
612
|
"flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",
|
|
550
|
-
String(r) ===
|
|
613
|
+
String(r) === L ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300"
|
|
551
614
|
),
|
|
552
|
-
children: String(r) ===
|
|
615
|
+
children: String(r) === L && /* @__PURE__ */ s(pt, { className: "h-2.5 w-2.5 text-white" })
|
|
553
616
|
}
|
|
554
617
|
),
|
|
555
|
-
/* @__PURE__ */ s("span", { className: "min-w-0 flex-1 truncate", children:
|
|
618
|
+
/* @__PURE__ */ s("span", { className: "min-w-0 flex-1 truncate", children: P === void 0 ? "Loading…" : st }),
|
|
556
619
|
/* @__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" })
|
|
557
620
|
]
|
|
558
621
|
}
|
|
559
622
|
),
|
|
560
|
-
u === void 0 &&
|
|
561
|
-
/* @__PURE__ */
|
|
623
|
+
u === void 0 && Y ? /* @__PURE__ */ s("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ s(ye, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : ie.length === 0 && !W ? /* @__PURE__ */ s("p", { className: "px-3 py-2 text-[13px] text-muted-foreground", children: "Searching…" }) : ie.length === 0 ? Ke && c.trim() ? null : d && d.labels.length > 0 && !c.trim() ? /* @__PURE__ */ m("div", { className: "px-3 py-2 text-[12px] leading-5 text-muted-foreground", children: [
|
|
624
|
+
/* @__PURE__ */ m("p", { children: [
|
|
562
625
|
"No options for",
|
|
563
626
|
" ",
|
|
564
|
-
/* @__PURE__ */ s("span", { className: "font-medium text-foreground", children:
|
|
565
|
-
|
|
627
|
+
/* @__PURE__ */ s("span", { className: "font-medium text-foreground", children: d.labels.join(" · ") }),
|
|
628
|
+
d.onClear ? " — clear one to widen the list:" : ". Change it, or ask an administrator to add options for it."
|
|
566
629
|
] }),
|
|
567
|
-
|
|
568
|
-
(e, n) =>
|
|
630
|
+
d.onClear && /* @__PURE__ */ s("div", { className: "mt-1.5 flex flex-wrap gap-1.5", children: d.keys.map(
|
|
631
|
+
(e, n) => d.clearable && !d.clearable.includes(e) ? null : /* @__PURE__ */ m(
|
|
569
632
|
"button",
|
|
570
633
|
{
|
|
571
634
|
type: "button",
|
|
572
635
|
onClick: (t) => {
|
|
573
|
-
var
|
|
574
|
-
t.stopPropagation(), (
|
|
636
|
+
var a;
|
|
637
|
+
t.stopPropagation(), (a = d.onClear) == null || a.call(d, e);
|
|
575
638
|
},
|
|
576
639
|
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",
|
|
577
640
|
children: [
|
|
578
641
|
"Clear ",
|
|
579
|
-
|
|
642
|
+
d.labels[n] ?? e
|
|
580
643
|
]
|
|
581
644
|
},
|
|
582
645
|
e
|
|
583
646
|
)
|
|
584
647
|
) })
|
|
585
|
-
] }) : /* @__PURE__ */ s("p", { className: "px-3 py-2 text-[13px] text-muted-foreground", children:
|
|
586
|
-
ne && /* @__PURE__ */
|
|
648
|
+
] }) : /* @__PURE__ */ s("p", { className: "px-3 py-2 text-[13px] text-muted-foreground", children: c.trim() ? `No results for “${c.trim()}”` : "No results" }) : /* @__PURE__ */ m(ft, { children: [
|
|
649
|
+
ne && /* @__PURE__ */ m(
|
|
587
650
|
"p",
|
|
588
651
|
{
|
|
589
652
|
"data-picker-close-matches": !0,
|
|
590
653
|
className: "px-3 pb-1 pt-2 text-[11.5px] text-muted-foreground",
|
|
591
654
|
children: [
|
|
592
655
|
"No exact match for “",
|
|
593
|
-
|
|
656
|
+
c.trim(),
|
|
594
657
|
"” — did you mean:"
|
|
595
658
|
]
|
|
596
659
|
}
|
|
597
660
|
),
|
|
598
661
|
ie.map((e, n) => {
|
|
599
|
-
const t =
|
|
600
|
-
return /* @__PURE__ */
|
|
662
|
+
const t = k(b, e), a = ee(t) ? le : t, E = String(e.id) === String(r), q = n + B;
|
|
663
|
+
return /* @__PURE__ */ m(
|
|
601
664
|
"button",
|
|
602
665
|
{
|
|
603
666
|
type: "button",
|
|
604
667
|
tabIndex: -1,
|
|
605
|
-
id:
|
|
668
|
+
id: Fe(q),
|
|
606
669
|
role: "option",
|
|
607
|
-
"aria-selected":
|
|
608
|
-
"data-nav-index":
|
|
609
|
-
onClick: () =>
|
|
610
|
-
onMouseMove: () =>
|
|
611
|
-
className:
|
|
670
|
+
"aria-selected": E,
|
|
671
|
+
"data-nav-index": q,
|
|
672
|
+
onClick: () => at(e),
|
|
673
|
+
onMouseMove: () => p !== q && J(q),
|
|
674
|
+
className: U(
|
|
612
675
|
"flex w-full items-center gap-2 px-3 py-1.5 text-[13px] text-left hover:bg-muted",
|
|
613
|
-
|
|
676
|
+
p === q && "bg-muted"
|
|
614
677
|
),
|
|
615
678
|
children: [
|
|
616
679
|
/* @__PURE__ */ s(
|
|
617
680
|
"div",
|
|
618
681
|
{
|
|
619
|
-
className:
|
|
682
|
+
className: U(
|
|
620
683
|
"flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",
|
|
621
|
-
|
|
684
|
+
E ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300"
|
|
622
685
|
),
|
|
623
|
-
children:
|
|
686
|
+
children: E && /* @__PURE__ */ s(pt, { className: "h-2.5 w-2.5 text-white" })
|
|
624
687
|
}
|
|
625
688
|
),
|
|
626
|
-
|
|
627
|
-
|
|
689
|
+
Z && /* @__PURE__ */ s(
|
|
690
|
+
Jt,
|
|
628
691
|
{
|
|
629
692
|
userId: e.id,
|
|
630
693
|
className: "h-4 w-4",
|
|
631
|
-
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:
|
|
694
|
+
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: en(a) })
|
|
632
695
|
}
|
|
633
696
|
),
|
|
634
|
-
|
|
697
|
+
Z && qt.has(String(e.id).toUpperCase()) && /* @__PURE__ */ s(
|
|
635
698
|
"span",
|
|
636
699
|
{
|
|
637
700
|
className: "h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500",
|
|
638
701
|
"data-tip": "Online now"
|
|
639
702
|
}
|
|
640
703
|
),
|
|
641
|
-
/* @__PURE__ */ s(
|
|
642
|
-
|
|
704
|
+
/* @__PURE__ */ s(Ht, { text: a, query: c }),
|
|
705
|
+
nt.has(String(e.id)) && /* @__PURE__ */ s(
|
|
643
706
|
"span",
|
|
644
707
|
{
|
|
645
708
|
className: "ml-auto max-w-[45%] shrink-0 truncate pl-2 text-[11.5px] text-muted-foreground",
|
|
646
709
|
"data-option-detail": !0,
|
|
647
|
-
children:
|
|
710
|
+
children: nt.get(String(e.id))
|
|
648
711
|
}
|
|
649
712
|
)
|
|
650
713
|
]
|
|
@@ -654,109 +717,122 @@ function Qt({
|
|
|
654
717
|
})
|
|
655
718
|
] })
|
|
656
719
|
] }),
|
|
657
|
-
!
|
|
658
|
-
|
|
720
|
+
!Y && /* @__PURE__ */ s(
|
|
721
|
+
rn,
|
|
659
722
|
{
|
|
660
723
|
collection: o,
|
|
661
|
-
search:
|
|
662
|
-
filter:
|
|
663
|
-
narrowedLabels: (
|
|
664
|
-
auto: (u ?? []).length === 0 && !!
|
|
724
|
+
search: j,
|
|
725
|
+
filter: $e,
|
|
726
|
+
narrowedLabels: (d == null ? void 0 : d.labels) ?? [],
|
|
727
|
+
auto: (u ?? []).length === 0 && !!j
|
|
665
728
|
}
|
|
666
729
|
)
|
|
667
730
|
]
|
|
668
731
|
}
|
|
669
732
|
),
|
|
670
|
-
|
|
733
|
+
_e
|
|
671
734
|
)
|
|
672
735
|
] })
|
|
673
736
|
);
|
|
674
737
|
}
|
|
675
|
-
function
|
|
738
|
+
function rn({
|
|
676
739
|
collection: o,
|
|
677
740
|
search: r,
|
|
678
|
-
filter:
|
|
679
|
-
narrowedLabels:
|
|
680
|
-
auto:
|
|
741
|
+
filter: h,
|
|
742
|
+
narrowedLabels: g,
|
|
743
|
+
auto: O
|
|
681
744
|
}) {
|
|
682
|
-
const
|
|
683
|
-
queryKey: ["picker-narrowing", o, r,
|
|
684
|
-
queryFn: () =>
|
|
685
|
-
|
|
686
|
-
).then((
|
|
687
|
-
enabled:
|
|
745
|
+
const C = Te(), [x, N] = F(!1), $ = h ? JSON.stringify(h) : "", { data: l, isFetching: T } = I({
|
|
746
|
+
queryKey: ["picker-narrowing", o, r, $],
|
|
747
|
+
queryFn: () => C.request(
|
|
748
|
+
Mt("/picker-narrowing", { collection: o, search: r, filter: h ?? null })
|
|
749
|
+
).then((y) => y.data),
|
|
750
|
+
enabled: x || O,
|
|
688
751
|
staleTime: 3e4,
|
|
689
752
|
retry: !1
|
|
690
753
|
});
|
|
691
|
-
if (!
|
|
754
|
+
if (!x && !O)
|
|
692
755
|
return /* @__PURE__ */ s(
|
|
693
756
|
"button",
|
|
694
757
|
{
|
|
695
758
|
type: "button",
|
|
696
|
-
onClick: (
|
|
697
|
-
|
|
759
|
+
onClick: (y) => {
|
|
760
|
+
y.stopPropagation(), N(!0);
|
|
698
761
|
},
|
|
699
762
|
className: "w-full border-t border-border px-3 py-1.5 text-left text-[11px] text-muted-foreground hover:text-foreground",
|
|
700
763
|
"data-picker-narrowing-ask": !0,
|
|
701
764
|
children: "Missing something?"
|
|
702
765
|
}
|
|
703
766
|
);
|
|
704
|
-
if (
|
|
767
|
+
if (T && !l)
|
|
705
768
|
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…" });
|
|
706
|
-
if (!
|
|
707
|
-
const
|
|
708
|
-
return
|
|
709
|
-
`${
|
|
710
|
-
),
|
|
711
|
-
`${
|
|
712
|
-
),
|
|
769
|
+
if (!l) return null;
|
|
770
|
+
const d = [], f = r ? `match “${r}”` : "exist";
|
|
771
|
+
return l.by_field_filter > 0 && d.push(
|
|
772
|
+
`${l.by_field_filter.toLocaleString()} more ${f} but this field only offers ${g.length ? `records that fit ${g.join(" · ")}` : "records its filter allows"}.`
|
|
773
|
+
), l.by_exclusions > 0 && d.push(
|
|
774
|
+
`${l.by_exclusions.toLocaleString()} ${l.by_exclusions === 1 ? "is" : "are"} hidden from pickers by an admin.`
|
|
775
|
+
), l.scopes.length > 0 && d.push(`Your ${l.scopes.join(", ")} access narrows what you can pick here.`), l.row_filter && d.push("Your role only sees some of these records."), d.length === 0 && d.push(
|
|
713
776
|
r ? `Nothing else you can see matches “${r}”.` : "Nothing narrows this list — every record you can see is offered."
|
|
714
777
|
), /* @__PURE__ */ s(
|
|
715
778
|
"div",
|
|
716
779
|
{
|
|
717
780
|
className: "space-y-0.5 border-t border-border px-3 py-1.5 text-[11px] leading-4 text-muted-foreground",
|
|
718
781
|
"data-picker-narrowing": !0,
|
|
719
|
-
"data-picker-narrowing-field":
|
|
720
|
-
"data-picker-narrowing-excluded":
|
|
721
|
-
children:
|
|
782
|
+
"data-picker-narrowing-field": l.by_field_filter,
|
|
783
|
+
"data-picker-narrowing-excluded": l.by_exclusions,
|
|
784
|
+
children: d.map((y) => /* @__PURE__ */ s("p", { children: y }, y))
|
|
722
785
|
}
|
|
723
786
|
);
|
|
724
787
|
}
|
|
725
|
-
function
|
|
788
|
+
function Nn({
|
|
726
789
|
collection: o,
|
|
727
790
|
id: r,
|
|
728
|
-
displayTemplate:
|
|
791
|
+
displayTemplate: h,
|
|
792
|
+
explainMissing: g
|
|
729
793
|
}) {
|
|
730
|
-
const
|
|
731
|
-
if (!
|
|
732
|
-
const
|
|
733
|
-
return
|
|
734
|
-
})(), { data:
|
|
735
|
-
queryKey: ["relation-single", o, String(r),
|
|
736
|
-
queryFn: () =>
|
|
794
|
+
const O = Te(), C = vt(), x = o === "nivaro_files" || o === "directus_files", N = (() => {
|
|
795
|
+
if (!h || !h.includes(".")) return null;
|
|
796
|
+
const y = [...h.matchAll(/\{\{([^}]+)\}\}/g)].map((xe) => xe[1].trim());
|
|
797
|
+
return y.length > 0 ? ["id", ...y].join(",") : null;
|
|
798
|
+
})(), { data: $, isLoading: l, error: T } = I({
|
|
799
|
+
queryKey: ["relation-single", o, String(r), N ?? ""],
|
|
800
|
+
queryFn: () => x ? (
|
|
737
801
|
// The file's row, not its bytes: GET /files/:id downloads the whole
|
|
738
802
|
// file (twice with the retry, 404 when storage lost it) only to read
|
|
739
803
|
// its name, and a missing object left the raw id as the label.
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
).then((
|
|
743
|
-
) :
|
|
804
|
+
O.request(
|
|
805
|
+
G(`/files/${encodeURIComponent(String(r))}/meta`)
|
|
806
|
+
).then((y) => y.data)
|
|
807
|
+
) : C(o, r, N),
|
|
744
808
|
enabled: !!r && !!o,
|
|
745
809
|
staleTime: 6e4,
|
|
746
|
-
retry:
|
|
747
|
-
})
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
810
|
+
retry: wt
|
|
811
|
+
}), { settling: d } = kt(
|
|
812
|
+
T,
|
|
813
|
+
g && !l && !$ ? o : null,
|
|
814
|
+
r
|
|
815
|
+
);
|
|
816
|
+
if (l || d) return /* @__PURE__ */ s(ye, { className: "h-3 w-3 animate-spin text-slate-400" });
|
|
817
|
+
if (!$)
|
|
818
|
+
return r == null || r === "" ? null : /* @__PURE__ */ s(
|
|
819
|
+
Nt,
|
|
820
|
+
{
|
|
821
|
+
error: T,
|
|
822
|
+
collection: g ? o : null,
|
|
823
|
+
id: g ? r : null
|
|
824
|
+
}
|
|
825
|
+
);
|
|
826
|
+
if (x) {
|
|
827
|
+
const y = $.title || $.filename_download || $.filename_disk || String(r);
|
|
828
|
+
return /* @__PURE__ */ s("span", { children: y });
|
|
753
829
|
}
|
|
754
|
-
const
|
|
755
|
-
return
|
|
830
|
+
const f = k(h, $);
|
|
831
|
+
return ee(f) ? /* @__PURE__ */ s("span", { className: "italic text-muted-foreground", children: le }) : /* @__PURE__ */ s("span", { children: f });
|
|
756
832
|
}
|
|
757
833
|
export {
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
834
|
+
Nn as RelatedItemLabel,
|
|
835
|
+
nn as RelationCombobox,
|
|
836
|
+
yt as isSamePick,
|
|
837
|
+
tn as useStaleTip
|
|
762
838
|
};
|