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