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