@nivaro/react 0.3.64 → 0.3.66

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