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