@nivaro/react 0.3.49 → 0.3.50

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 (32) hide show
  1. package/dist/components/InlineGridField.js +166 -105
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useSessionRecorder.js +1 -1
  4. package/dist/index.d.ts +25 -1
  5. package/dist/shared/components/ItemEditForm.js +4676 -4579
  6. package/dist/shared/components/QueryTable.js +461 -332
  7. package/dist/shared/components/item-edit/CatalogPickerField.js +1144 -1127
  8. package/dist/shared/components/item-edit/CloneDialog.js +192 -142
  9. package/dist/shared/components/item-edit/FieldRenderer.js +127 -126
  10. package/dist/shared/components/item-edit/FieldRow.js +236 -226
  11. package/dist/shared/components/item-edit/InlineGridField.js +92 -90
  12. package/dist/shared/components/item-edit/InlineTableField.js +3088 -2945
  13. package/dist/shared/components/item-edit/MidairCollisionDialog.js +175 -0
  14. package/dist/shared/components/item-edit/PlanGrid.js +162 -162
  15. package/dist/shared/components/item-edit/PolishFields.js +169 -162
  16. package/dist/shared/components/item-edit/RelationCombobox.js +186 -181
  17. package/dist/shared/components/item-edit/SummaryPanel.js +148 -135
  18. package/dist/shared/components/item-edit/ValidationSummary.js +64 -47
  19. package/dist/shared/components/item-edit/helpers.js +181 -155
  20. package/dist/shared/components/item-edit/line-midair.js +201 -0
  21. package/dist/shared/components/item-edit/soft-rules.js +27 -0
  22. package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
  23. package/dist/shared/components/panels/ItemLockBanner.js +414 -358
  24. package/dist/shared/components/panels/PipelinePanel.js +1157 -963
  25. package/dist/shared/components/panels/RecordIntegrityBanner.js +1 -1
  26. package/dist/shared/components/queue/QueueWorklist.js +870 -827
  27. package/dist/shared/components/queue/column-chooser.js +21 -0
  28. package/dist/shared/components/queue/live-state-aspect.js +6 -0
  29. package/dist/shared/components/ui/number-draft-input.js +93 -0
  30. package/dist/shared/components/widgets/ReviewListWidget.js +191 -166
  31. package/dist/shared/lib/error-hints.js +1 -0
  32. package/package.json +1 -1
@@ -1,33 +1,33 @@
1
- import { jsxs as u, jsx as n } from "react/jsx-runtime";
1
+ import { jsxs as u, jsx as s } from "react/jsx-runtime";
2
2
  import { useQuery as S } from "@tanstack/react-query";
3
- import { ChevronDown as $e, Loader2 as B, AlertTriangle as Je, Search as ze, X as He, Check as Ce } from "lucide-react";
4
- import { useState as $, useRef as I, useEffect as j, useLayoutEffect as Ye, useMemo as K } from "react";
5
- import { createPortal as Le } from "react-dom";
6
- import { useNivaroClient as ae, useItemEditAuth as We, useStaleFieldReporter as Xe } from "../../context.js";
7
- import { get as R, post as Ge } from "../../lib/commands.js";
8
- import { compareByMatch as Ve } from "../../lib/picker-rank.js";
9
- import { useRecordReader as je } from "../../lib/record-loader.js";
10
- import { useOnlineUsers as Ze } from "../../lib/use-online-users.js";
11
- import { SearchHighlight as Qe } from "../SearchHighlight.js";
12
- import { UserAvatar as Be } from "../UserAvatar.js";
13
- import { userOptionFilter as et, cn as J } from "../../lib/utils.js";
14
- import { applyDisplayTemplate as k } from "./helpers.js";
15
- import { collidingIds as tt, disambiguators as rt } from "./option-disambiguate.js";
16
- import { usePickerMissReport as nt } from "./picker-miss.js";
17
- import { useLatestSearch as st, narrowLocally as ot } from "./picker-search.js";
18
- function it(s) {
19
- return s.replace(/\(.*$/, "").trim().split(/\s+/).map((r) => r[0]).filter(Boolean).slice(0, 2).join("").toUpperCase() || "?";
3
+ import { ChevronDown as $e, Loader2 as B, AlertTriangle as ze, Search as He, X as Ye, Check as Ce } from "lucide-react";
4
+ import { useState as $, useRef as I, useEffect as j, useLayoutEffect as We, useMemo as K } from "react";
5
+ import { createPortal as je } from "react-dom";
6
+ import { useNivaroClient as ae, useItemEditAuth as Xe, useStaleFieldReporter as Ge } from "../../context.js";
7
+ import { get as R, post as Ve } from "../../lib/commands.js";
8
+ import { compareByMatch as Ze } from "../../lib/picker-rank.js";
9
+ import { useRecordReader as Re } from "../../lib/record-loader.js";
10
+ import { useOnlineUsers as Qe } from "../../lib/use-online-users.js";
11
+ import { SearchHighlight as Be } from "../SearchHighlight.js";
12
+ import { UserAvatar as et } from "../UserAvatar.js";
13
+ import { userOptionFilter as tt, cn as J } from "../../lib/utils.js";
14
+ import { applyDisplayTemplate as N } from "./helpers.js";
15
+ import { collidingIds as rt, disambiguators as nt } from "./option-disambiguate.js";
16
+ import { usePickerMissReport as st } from "./picker-miss.js";
17
+ import { useLatestSearch as it, narrowLocally as ot } from "./picker-search.js";
18
+ function at(n) {
19
+ return n.replace(/\(.*$/, "").trim().split(/\s+/).map((r) => r[0]).filter(Boolean).slice(0, 2).join("").toUpperCase() || "?";
20
20
  }
21
- function at(s) {
21
+ function lt(n) {
22
22
  const [r, d] = $(null), y = {
23
23
  onMouseEnter: (g) => {
24
- if (!s) return;
24
+ if (!n) return;
25
25
  const p = g.currentTarget.getBoundingClientRect(), m = window.innerHeight - p.bottom < 80;
26
26
  d({ x: p.left, y: m ? p.top - 58 : p.bottom + 4 });
27
27
  },
28
28
  onMouseLeave: () => d(null)
29
- }, q = s && r ? Le(
30
- /* @__PURE__ */ n(
29
+ }, q = n && r ? je(
30
+ /* @__PURE__ */ s(
31
31
  "div",
32
32
  {
33
33
  style: { position: "fixed", left: r.x, top: r.y, zIndex: 130 },
@@ -39,8 +39,11 @@ function at(s) {
39
39
  ) : null;
40
40
  return { bind: y, tip: q };
41
41
  }
42
- function lt({
43
- collection: s,
42
+ function Le(n, r) {
43
+ return n == null || n === "" || r == null || r === "" ? !1 : String(n) === String(r);
44
+ }
45
+ function dt({
46
+ collection: n,
44
47
  value: r,
45
48
  onChange: d,
46
49
  disabled: y,
@@ -49,22 +52,22 @@ function lt({
49
52
  autoSelectSingle: p,
50
53
  optionSort: m,
51
54
  requiredParent: F,
52
- facets: i,
55
+ facets: o,
53
56
  fieldKey: C,
54
57
  narrowedBy: l,
55
58
  pinned: f,
56
59
  missPlacement: _,
57
- defaultOpen: Re,
60
+ defaultOpen: Fe,
58
61
  onClose: le
59
62
  }) {
60
- const T = ae(), de = je(), [c, P] = $(Re ?? !1), [v, ce] = $(""), z = I(le);
63
+ const T = ae(), de = Re(), [c, P] = $(Fe ?? !1), [v, ce] = $(""), z = I(le);
61
64
  z.current = le;
62
65
  const ue = I(c);
63
66
  j(() => {
64
67
  var e;
65
68
  ue.current && !c && ((e = z.current) == null || e.call(z)), ue.current = c;
66
69
  }, [c]);
67
- const [Fe, Te] = $(!1), L = st(v, Fe), me = I(null), H = I(null);
70
+ const [Te, Ee] = $(!1), L = it(v, Te), me = I(null), H = I(null);
68
71
  j(() => {
69
72
  c ? setTimeout(() => {
70
73
  var e;
@@ -72,138 +75,138 @@ function lt({
72
75
  }, 30) : ce("");
73
76
  }, [c]), j(() => {
74
77
  if (!c) return;
75
- const e = (o) => {
78
+ const e = (i) => {
76
79
  var a;
77
- const t = o.target;
78
- (a = t == null ? void 0 : t.closest) != null && a.call(t, "[data-nvr-combobox-panel]") || H.current && !H.current.contains(o.target) && P(!1);
80
+ const t = i.target;
81
+ (a = t == null ? void 0 : t.closest) != null && a.call(t, "[data-nvr-combobox-panel]") || H.current && !H.current.contains(i.target) && P(!1);
79
82
  };
80
83
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
81
84
  }, [c]);
82
- const [pe, ee] = $(null), [fe, Ee] = $(null);
83
- Ye(() => {
85
+ const [pe, ee] = $(null), [fe, Oe] = $(null);
86
+ We(() => {
84
87
  if (!c) {
85
88
  ee(null);
86
89
  return;
87
90
  }
88
91
  const e = () => {
89
- const o = H.current;
90
- if (!o) return;
91
- const t = o.getBoundingClientRect(), a = o.closest('[role="dialog"]') ?? document.body;
92
- Ee(a);
93
- const Ne = window.innerHeight - t.bottom < 340 && t.top > window.innerHeight - t.bottom, ke = t.left, Se = Ne ? t.top - 4 : t.bottom + 4, qe = {
92
+ const i = H.current;
93
+ if (!i) return;
94
+ const t = i.getBoundingClientRect(), a = i.closest('[role="dialog"]') ?? document.body;
95
+ Oe(a);
96
+ const ke = window.innerHeight - t.bottom < 340 && t.top > window.innerHeight - t.bottom, Ne = t.left, Se = ke ? t.top - 4 : t.bottom + 4, qe = {
94
97
  minWidth: t.width,
95
98
  zIndex: 120,
96
- ...Ne ? { transform: "translateY(-100%)" } : {}
99
+ ...ke ? { transform: "translateY(-100%)" } : {}
97
100
  };
98
101
  if (a === document.body)
99
- ee({ position: "fixed", left: ke, top: Se, ...qe });
102
+ ee({ position: "fixed", left: Ne, top: Se, ...qe });
100
103
  else {
101
104
  const _e = a.getBoundingClientRect();
102
- ee({ position: "absolute", left: ke - _e.left, top: Se - _e.top, ...qe });
105
+ ee({ position: "absolute", left: Ne - _e.left, top: Se - _e.top, ...qe });
103
106
  }
104
107
  };
105
108
  return e(), window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
106
109
  window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
107
110
  };
108
111
  }, [c]);
109
- const { data: te, isPending: Oe } = S({
110
- queryKey: ["col-meta", s],
111
- queryFn: () => T.request(R(`/collections/${s}`)).then((e) => e.data),
112
+ const { data: te, isPending: Ie } = S({
113
+ queryKey: ["col-meta", n],
114
+ queryFn: () => T.request(R(`/collections/${n}`)).then((e) => e.data),
112
115
  staleTime: 3e5,
113
116
  retry: !1
114
- }), [re, Ie] = $({}), { data: he = [] } = S({
115
- queryKey: ["collection-meta", s],
117
+ }), [re, Ke] = $({}), { data: he = [] } = S({
118
+ queryKey: ["collection-meta", n],
116
119
  queryFn: () => T.request(
117
- R(`/collections/${s}`)
120
+ R(`/collections/${n}`)
118
121
  ).then(
119
122
  (e) => {
120
- var o;
121
- return ((o = e.data) == null ? void 0 : o.relations) ?? [];
123
+ var i;
124
+ return ((i = e.data) == null ? void 0 : i.relations) ?? [];
122
125
  }
123
126
  ),
124
- enabled: !!(i != null && i.length),
127
+ enabled: !!(o != null && o.length),
125
128
  staleTime: 10 * 6e4
126
- }), Ke = K(() => {
129
+ }), Pe = K(() => {
127
130
  const e = {};
128
- for (const o of i ?? []) {
131
+ for (const i of o ?? []) {
129
132
  const t = he.find(
130
- (a) => a.many_collection === s && a.many_field === o.field && !a.junction_field
133
+ (a) => a.many_collection === n && a.many_field === i.field && !a.junction_field
131
134
  );
132
- t != null && t.one_collection && (e[o.field] = t.one_collection);
135
+ t != null && t.one_collection && (e[i.field] = t.one_collection);
133
136
  }
134
137
  return e;
135
- }, [i, he, s]), E = s === "nivaro_users", Pe = Ze(E), ge = We().isAdmin, ne = K(() => {
138
+ }, [o, he, n]), E = n === "nivaro_users", Ue = Qe(E), ge = Xe().isAdmin, ne = K(() => {
136
139
  const e = [];
137
- E && e.push(et(ge)), g && e.push(g);
138
- for (const [o, t] of Object.entries(re))
139
- t != null && t !== "" && e.push({ [o]: { _eq: t } });
140
+ E && e.push(tt(ge)), g && e.push(g);
141
+ for (const [i, t] of Object.entries(re))
142
+ t != null && t !== "" && e.push({ [i]: { _eq: t } });
140
143
  if (e.length !== 0)
141
144
  return e.length === 1 ? e[0] : { _and: e };
142
145
  }, [g, re, ge]), Y = (te == null ? void 0 : te.display_template) ?? (E ? "{{first_name}} {{last_name}} ({{email}})" : null), b = K(() => {
143
146
  if (!Y) return;
144
- const e = [...Y.matchAll(/\{\{([\w.]+)\}\}/g)].map((o) => o[1]);
147
+ const e = [...Y.matchAll(/\{\{([\w.]+)\}\}/g)].map((i) => i[1]);
145
148
  if (e.length)
146
149
  return ["id", ...e].join(",");
147
- }, [Y]), N = ne ? JSON.stringify(ne) : void 0, U = m && !/^-?label$/.test(m) ? m : void 0, {
150
+ }, [Y]), k = ne ? JSON.stringify(ne) : void 0, U = m && !/^-?label$/.test(m) ? m : void 0, {
148
151
  data: h,
149
152
  isFetching: O,
150
153
  isPlaceholderData: be
151
154
  } = S({
152
155
  queryKey: [
153
156
  "relation-opts",
154
- s,
157
+ n,
155
158
  L,
156
- N,
159
+ k,
157
160
  b,
158
161
  U ?? ""
159
162
  ],
160
163
  queryFn: () => T.request(
161
- R(`/items/${s}`, {
164
+ R(`/items/${n}`, {
162
165
  limit: 200,
163
166
  picker: "1",
164
167
  ...L ? { search: L } : {},
165
- ...N ? { filter: N } : {},
168
+ ...k ? { filter: k } : {},
166
169
  ...b ? { fields: b } : {},
167
170
  ...U ? { sort: U } : {}
168
171
  })
169
172
  ).then((e) => e.data ?? []),
170
173
  // Wait for the display template: it decides `fields`, and starting before
171
174
  // it lands sent the whole first page twice.
172
- enabled: c && !Oe,
173
- staleTime: N ? 0 : 3e4,
175
+ enabled: c && !Ie,
176
+ staleTime: k ? 0 : 3e4,
174
177
  // A new SEARCH keeps the previous answer on screen (narrowed locally below)
175
178
  // instead of blanking the list behind a spinner. A changed filter, sort or
176
179
  // template never does — those rows may no longer be allowed.
177
- placeholderData: (e, o) => {
178
- const t = o == null ? void 0 : o.queryKey;
180
+ placeholderData: (e, i) => {
181
+ const t = i == null ? void 0 : i.queryKey;
179
182
  if (!(!e || !t))
180
- return t[1] === s && t[3] === N && t[4] === b && t[5] === (U ?? "") ? e : void 0;
183
+ return t[1] === n && t[3] === k && t[4] === b && t[5] === (U ?? "") ? e : void 0;
181
184
  }
182
185
  });
183
- j(() => Te(O), [O]), nt({
186
+ j(() => Ee(O), [O]), st({
184
187
  placement: _,
185
188
  open: c,
186
189
  search: L,
187
190
  settled: !O && !be && h !== void 0,
188
191
  count: (h == null ? void 0 : h.length) ?? 0
189
192
  });
190
- const { data: W, isLoading: Ue } = S({
191
- queryKey: ["relation-single", s, String(r), b],
192
- queryFn: () => de(s, r, b),
193
+ const { data: W, isLoading: Ae } = S({
194
+ queryKey: ["relation-single", n, String(r), b],
195
+ queryFn: () => de(n, r, b),
193
196
  enabled: !!r,
194
197
  staleTime: 6e4
195
198
  }), x = (f == null ? void 0 : f.id) != null && f.id !== "" ? String(f.id) : null, { data: A } = S({
196
- queryKey: ["relation-single", s, x ?? "", b],
197
- queryFn: () => de(s, x, b).catch(
199
+ queryKey: ["relation-single", n, x ?? "", b],
200
+ queryFn: () => de(n, x, b).catch(
198
201
  () => null
199
202
  ),
200
203
  enabled: !!x && c,
201
204
  staleTime: 6e4
202
- }), Ae = JSON.stringify(g ? { _and: [{ id: { _eq: r } }, g] } : { id: { _eq: r } }), { data: X } = S({
203
- queryKey: ["relation-avail", s, String(r), N],
205
+ }), Me = JSON.stringify(g ? { _and: [{ id: { _eq: r } }, g] } : { id: { _eq: r } }), { data: X } = S({
206
+ queryKey: ["relation-avail", n, String(r), k],
204
207
  queryFn: () => T.request(
205
- R(`/items/${s}`, {
206
- filter: Ae,
208
+ R(`/items/${n}`, {
209
+ filter: Me,
207
210
  picker: "1",
208
211
  limit: 1,
209
212
  fields: "id"
@@ -214,7 +217,7 @@ function lt({
214
217
  // the pin is available by construction — never probe it, never flag it.
215
218
  enabled: !!r && !!W && String(r) !== x,
216
219
  staleTime: 3e4
217
- }), M = !!r && String(r) !== x && X !== void 0 && X.length === 0, G = I(null), se = I(!1), xe = `${s}|${N ?? ""}`, Me = () => {
220
+ }), M = !!r && String(r) !== x && X !== void 0 && X.length === 0, G = I(null), se = I(!1), xe = `${n}|${k ?? ""}`, De = () => {
218
221
  se.current = !0, G.current = xe, d(null);
219
222
  }, V = r == null || r === "";
220
223
  j(() => {
@@ -223,35 +226,35 @@ function lt({
223
226
  if (!p || y || !V || se.current) return;
224
227
  const e = xe;
225
228
  G.current !== e && (G.current = e, T.request(
226
- R(`/items/${s}`, {
229
+ R(`/items/${n}`, {
227
230
  limit: 2,
228
231
  picker: "1",
229
232
  fields: "id",
230
- ...N ? { filter: N } : {}
233
+ ...k ? { filter: k } : {}
231
234
  })
232
- ).then((o) => {
235
+ ).then((i) => {
233
236
  var a;
234
- const t = o.data ?? [];
237
+ const t = i.data ?? [];
235
238
  t.length === 1 && ((a = t[0]) == null ? void 0 : a.id) != null && d(t[0].id);
236
239
  }).catch(() => {
237
240
  G.current = null;
238
241
  }));
239
- }, [p, y, V, s, N]);
240
- const w = Y, ye = r && W ? k(w, W) : null, oe = !be && v === L, Z = K(
242
+ }, [p, y, V, n, k]);
243
+ const w = Y, ye = r && W ? N(w, W) : null, ie = !be && v === L, Z = K(
241
244
  () => ot(
242
245
  h ?? [],
243
- (e) => k(w, e) || `#${e.id}`,
246
+ (e) => N(w, e) || `#${e.id}`,
244
247
  v,
245
- oe
248
+ ie
246
249
  ),
247
- [h, w, v, oe]
250
+ [h, w, v, ie]
248
251
  ), Q = K(
249
- () => tt(h ?? [], (e) => k(w, e) || `#${e.id}`),
252
+ () => rt(h ?? [], (e) => N(w, e) || `#${e.id}`),
250
253
  [h, w]
251
254
  ), { data: D } = S({
252
- queryKey: ["relation-opts-dups", s, Q.join(",")],
255
+ queryKey: ["relation-opts-dups", n, Q.join(",")],
253
256
  queryFn: () => T.request(
254
- R(`/items/${s}`, {
257
+ R(`/items/${n}`, {
255
258
  limit: Q.length,
256
259
  picker: "1",
257
260
  filter: JSON.stringify({ id: { _in: Q } }),
@@ -265,21 +268,21 @@ function lt({
265
268
  const e = new Map(
266
269
  (h ?? []).map((t) => [
267
270
  String(t.id),
268
- (k(w, t) || `#${t.id}`).trim().toLowerCase()
271
+ (N(w, t) || `#${t.id}`).trim().toLowerCase()
269
272
  ])
270
- ), o = /* @__PURE__ */ new Map();
273
+ ), i = /* @__PURE__ */ new Map();
271
274
  for (const t of D) {
272
275
  const a = e.get(String(t.id));
273
- a !== void 0 && o.set(a, [...o.get(a) ?? [], t]);
276
+ a !== void 0 && i.set(a, [...i.get(a) ?? [], t]);
274
277
  }
275
- return rt(
276
- [...o.values()],
278
+ return nt(
279
+ [...i.values()],
277
280
  ((b == null ? void 0 : b.split(",")) ?? []).map((t) => t.split(".")[0])
278
281
  );
279
- }, [D, h, w, b]), De = !!r && Ue && !W, ve = at(M), ie = Xe();
282
+ }, [D, h, w, b]), Je = !!r && Ae && !W, ve = lt(M), oe = Ge();
280
283
  return j(() => {
281
- !ie || !C || X === void 0 || ie(C, M);
282
- }, [ie, C, M, X]), F ? /* @__PURE__ */ u(
284
+ !oe || !C || X === void 0 || oe(C, M);
285
+ }, [oe, C, M, X]), F ? /* @__PURE__ */ u(
283
286
  "button",
284
287
  {
285
288
  type: "button",
@@ -291,7 +294,7 @@ function lt({
291
294
  F,
292
295
  " first"
293
296
  ] }),
294
- /* @__PURE__ */ n($e, { className: "h-4 w-4 shrink-0 opacity-50" })
297
+ /* @__PURE__ */ s($e, { className: "h-4 w-4 shrink-0 opacity-50" })
295
298
  ]
296
299
  }
297
300
  ) : (
@@ -309,7 +312,7 @@ function lt({
309
312
  M ? "border-amber-300 dark:border-amber-600" : "border-input"
310
313
  ),
311
314
  children: [
312
- De ? /* @__PURE__ */ n(B, { className: "h-3.5 w-3.5 animate-spin text-muted-foreground" }) : /* @__PURE__ */ u(
315
+ Je ? /* @__PURE__ */ s(B, { className: "h-3.5 w-3.5 animate-spin text-muted-foreground" }) : /* @__PURE__ */ u(
313
316
  "span",
314
317
  {
315
318
  className: J(
@@ -317,17 +320,17 @@ function lt({
317
320
  !ye && "text-muted-foreground"
318
321
  ),
319
322
  children: [
320
- M && /* @__PURE__ */ n(Je, { className: "h-3.5 w-3.5 shrink-0 text-amber-500" }),
321
- /* @__PURE__ */ n("span", { className: "truncate", children: ye ?? q ?? "Select…" })
323
+ M && /* @__PURE__ */ s(ze, { className: "h-3.5 w-3.5 shrink-0 text-amber-500" }),
324
+ /* @__PURE__ */ s("span", { className: "truncate", children: ye ?? q ?? "Select…" })
322
325
  ]
323
326
  }
324
327
  ),
325
- /* @__PURE__ */ n($e, { className: "h-4 w-4 shrink-0 opacity-50" })
328
+ /* @__PURE__ */ s($e, { className: "h-4 w-4 shrink-0 opacity-50" })
326
329
  ]
327
330
  }
328
331
  ),
329
332
  ve.tip,
330
- c && pe && fe && Le(
333
+ c && pe && fe && je(
331
334
  /* @__PURE__ */ u(
332
335
  "div",
333
336
  {
@@ -335,19 +338,19 @@ function lt({
335
338
  style: pe,
336
339
  className: J(
337
340
  "nvr-pop-in rounded-md border border-border bg-popover shadow-md",
338
- i != null && i.length ? "w-[560px] max-w-[92vw]" : "min-w-[240px] w-max max-w-[360px]"
341
+ o != null && o.length ? "w-[560px] max-w-[92vw]" : "min-w-[240px] w-max max-w-[360px]"
339
342
  ),
340
343
  children: [
341
- !!(i != null && i.length) && /* @__PURE__ */ n("div", { className: "grid grid-cols-2 gap-2 border-b border-border bg-slate-50/60 p-2 dark:bg-muted/40", children: i.map((e) => {
342
- const o = Ke[e.field];
343
- return o ? /* @__PURE__ */ u("div", { children: [
344
- /* @__PURE__ */ n("p", { className: "mb-0.5 text-[10px] font-medium uppercase tracking-wide text-slate-400", children: e.label ?? e.field }),
345
- /* @__PURE__ */ n(
346
- lt,
344
+ !!(o != null && o.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: o.map((e) => {
345
+ const i = Pe[e.field];
346
+ return i ? /* @__PURE__ */ u("div", { children: [
347
+ /* @__PURE__ */ s("p", { className: "mb-0.5 text-[10px] font-medium uppercase tracking-wide text-slate-400", children: e.label ?? e.field }),
348
+ /* @__PURE__ */ s(
349
+ dt,
347
350
  {
348
- collection: o,
351
+ collection: i,
349
352
  value: re[e.field] ?? null,
350
- onChange: (t) => Ie((a) => ({ ...a, [e.field]: t })),
353
+ onChange: (t) => Ke((a) => ({ ...a, [e.field]: t })),
351
354
  placeholder: "Any",
352
355
  optionSort: e.sort,
353
356
  extraFilter: e.filter
@@ -356,8 +359,8 @@ function lt({
356
359
  ] }, e.field) : null;
357
360
  }) }),
358
361
  /* @__PURE__ */ u("div", { className: "flex items-center border-b px-3", children: [
359
- /* @__PURE__ */ n(ze, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
360
- /* @__PURE__ */ n(
362
+ /* @__PURE__ */ s(He, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
363
+ /* @__PURE__ */ s(
361
364
  "input",
362
365
  {
363
366
  ref: me,
@@ -367,7 +370,7 @@ function lt({
367
370
  className: "flex h-9 w-full bg-transparent py-3 text-[13px] outline-none placeholder:text-muted-foreground"
368
371
  }
369
372
  ),
370
- O && h !== void 0 && /* @__PURE__ */ n(
373
+ O && h !== void 0 && /* @__PURE__ */ s(
371
374
  B,
372
375
  {
373
376
  "data-picker-searching": !0,
@@ -381,11 +384,11 @@ function lt({
381
384
  {
382
385
  type: "button",
383
386
  onClick: () => {
384
- Me(), P(!1);
387
+ De(), P(!1);
385
388
  },
386
389
  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",
387
390
  children: [
388
- /* @__PURE__ */ n(He, { className: "h-3.5 w-3.5 text-slate-400" }),
391
+ /* @__PURE__ */ s(Ye, { className: "h-3.5 w-3.5 text-slate-400" }),
389
392
  "Clear selection"
390
393
  ]
391
394
  }
@@ -396,33 +399,34 @@ function lt({
396
399
  type: "button",
397
400
  "data-nvr-pinned-option": !0,
398
401
  onClick: () => {
399
- d((A == null ? void 0 : A.id) ?? (f == null ? void 0 : f.id)), P(!1);
402
+ const e = (A == null ? void 0 : A.id) ?? (f == null ? void 0 : f.id);
403
+ Le(r, e) || d(e), P(!1);
400
404
  },
401
405
  className: "flex w-full items-center gap-2 border-b border-slate-100 bg-nvr-cyan/5 px-3 py-1.5 text-left text-[13px] hover:bg-nvr-cyan/10 dark:border-border",
402
406
  children: [
403
- /* @__PURE__ */ n(
407
+ /* @__PURE__ */ s(
404
408
  "div",
405
409
  {
406
410
  className: J(
407
411
  "flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",
408
412
  String(r) === x ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300"
409
413
  ),
410
- children: String(r) === x && /* @__PURE__ */ n(Ce, { className: "h-2.5 w-2.5 text-white" })
414
+ children: String(r) === x && /* @__PURE__ */ s(Ce, { className: "h-2.5 w-2.5 text-white" })
411
415
  }
412
416
  ),
413
- /* @__PURE__ */ n("span", { className: "min-w-0 flex-1 truncate", children: A ? k(w, A) || `#${x}` : `#${x}` }),
414
- /* @__PURE__ */ n("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" })
417
+ /* @__PURE__ */ s("span", { className: "min-w-0 flex-1 truncate", children: A ? N(w, A) || `#${x}` : `#${x}` }),
418
+ /* @__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" })
415
419
  ]
416
420
  }
417
421
  ),
418
- h === void 0 && O ? /* @__PURE__ */ n("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ n(B, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : Z.length === 0 && !oe ? /* @__PURE__ */ n("p", { className: "px-3 py-2 text-[13px] text-muted-foreground", children: "Searching…" }) : Z.length === 0 ? l && l.labels.length > 0 && !v.trim() ? /* @__PURE__ */ u("div", { className: "px-3 py-2 text-[12px] leading-5 text-muted-foreground", children: [
422
+ h === void 0 && O ? /* @__PURE__ */ s("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ s(B, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : Z.length === 0 && !ie ? /* @__PURE__ */ s("p", { className: "px-3 py-2 text-[13px] text-muted-foreground", children: "Searching…" }) : Z.length === 0 ? l && l.labels.length > 0 && !v.trim() ? /* @__PURE__ */ u("div", { className: "px-3 py-2 text-[12px] leading-5 text-muted-foreground", children: [
419
423
  /* @__PURE__ */ u("p", { children: [
420
424
  "No options for",
421
425
  " ",
422
- /* @__PURE__ */ n("span", { className: "font-medium text-foreground", children: l.labels.join(" · ") }),
426
+ /* @__PURE__ */ s("span", { className: "font-medium text-foreground", children: l.labels.join(" · ") }),
423
427
  l.onClear ? " — clear one to widen the list:" : "."
424
428
  ] }),
425
- l.onClear && /* @__PURE__ */ n("div", { className: "mt-1.5 flex flex-wrap gap-1.5", children: l.keys.map((e, o) => /* @__PURE__ */ u(
429
+ l.onClear && /* @__PURE__ */ s("div", { className: "mt-1.5 flex flex-wrap gap-1.5", children: l.keys.map((e, i) => /* @__PURE__ */ u(
426
430
  "button",
427
431
  {
428
432
  type: "button",
@@ -433,56 +437,56 @@ function lt({
433
437
  className: "rounded-md border border-border bg-background px-2 py-0.5 text-[11.5px] font-medium text-foreground transition-colors duration-150 hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan",
434
438
  children: [
435
439
  "Clear ",
436
- l.labels[o] ?? e
440
+ l.labels[i] ?? e
437
441
  ]
438
442
  },
439
443
  e
440
444
  )) })
441
- ] }) : /* @__PURE__ */ n("p", { className: "px-3 py-2 text-[13px] text-muted-foreground", children: v.trim() ? `No results for “${v.trim()}”` : "No results" }) : (U ? [...Z] : [...Z].sort(
442
- (e, o) => Ve(
443
- k(w, e),
444
- k(w, o),
445
+ ] }) : /* @__PURE__ */ s("p", { className: "px-3 py-2 text-[13px] text-muted-foreground", children: v.trim() ? `No results for “${v.trim()}”` : "No results" }) : (U ? [...Z] : [...Z].sort(
446
+ (e, i) => Ze(
447
+ N(w, e),
448
+ N(w, i),
445
449
  v,
446
450
  m === "-label"
447
451
  )
448
452
  )).filter((e) => !x || String(e.id) !== x).map((e) => {
449
- const o = k(w, e) || `#${e.id}`, t = String(e.id) === String(r);
453
+ const i = N(w, e) || `#${e.id}`, t = String(e.id) === String(r);
450
454
  return /* @__PURE__ */ u(
451
455
  "button",
452
456
  {
453
457
  type: "button",
454
458
  onClick: () => {
455
- d(e.id), P(!1);
459
+ Le(r, e.id) || d(e.id), P(!1);
456
460
  },
457
461
  className: "flex w-full items-center gap-2 px-3 py-1.5 text-[13px] text-left hover:bg-muted",
458
462
  children: [
459
- /* @__PURE__ */ n(
463
+ /* @__PURE__ */ s(
460
464
  "div",
461
465
  {
462
466
  className: J(
463
467
  "flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",
464
468
  t ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300"
465
469
  ),
466
- children: t && /* @__PURE__ */ n(Ce, { className: "h-2.5 w-2.5 text-white" })
470
+ children: t && /* @__PURE__ */ s(Ce, { className: "h-2.5 w-2.5 text-white" })
467
471
  }
468
472
  ),
469
- E && /* @__PURE__ */ n(
470
- Be,
473
+ E && /* @__PURE__ */ s(
474
+ et,
471
475
  {
472
476
  userId: e.id,
473
477
  className: "h-4 w-4",
474
- fallback: /* @__PURE__ */ n("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: it(o) })
478
+ 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: at(i) })
475
479
  }
476
480
  ),
477
- E && Pe.has(String(e.id).toUpperCase()) && /* @__PURE__ */ n(
481
+ E && Ue.has(String(e.id).toUpperCase()) && /* @__PURE__ */ s(
478
482
  "span",
479
483
  {
480
484
  className: "h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500",
481
485
  "data-tip": "Online now"
482
486
  }
483
487
  ),
484
- /* @__PURE__ */ n(Qe, { text: o, query: v }),
485
- we.has(String(e.id)) && /* @__PURE__ */ n(
488
+ /* @__PURE__ */ s(Be, { text: i, query: v }),
489
+ we.has(String(e.id)) && /* @__PURE__ */ s(
486
490
  "span",
487
491
  {
488
492
  className: "ml-auto max-w-[45%] shrink-0 truncate pl-2 text-[11.5px] text-muted-foreground",
@@ -496,10 +500,10 @@ function lt({
496
500
  );
497
501
  })
498
502
  ] }),
499
- !O && /* @__PURE__ */ n(
500
- dt,
503
+ !O && /* @__PURE__ */ s(
504
+ ct,
501
505
  {
502
- collection: s,
506
+ collection: n,
503
507
  search: L,
504
508
  filter: ne,
505
509
  narrowedLabels: (l == null ? void 0 : l.labels) ?? [],
@@ -514,24 +518,24 @@ function lt({
514
518
  ] })
515
519
  );
516
520
  }
517
- function dt({
518
- collection: s,
521
+ function ct({
522
+ collection: n,
519
523
  search: r,
520
524
  filter: d,
521
525
  narrowedLabels: y,
522
526
  auto: q
523
527
  }) {
524
- const g = ae(), [p, m] = $(!1), F = d ? JSON.stringify(d) : "", { data: i, isFetching: C } = S({
525
- queryKey: ["picker-narrowing", s, r, F],
528
+ const g = ae(), [p, m] = $(!1), F = d ? JSON.stringify(d) : "", { data: o, isFetching: C } = S({
529
+ queryKey: ["picker-narrowing", n, r, F],
526
530
  queryFn: () => g.request(
527
- Ge("/picker-narrowing", { collection: s, search: r, filter: d ?? null })
531
+ Ve("/picker-narrowing", { collection: n, search: r, filter: d ?? null })
528
532
  ).then((_) => _.data),
529
533
  enabled: p || q,
530
534
  staleTime: 3e4,
531
535
  retry: !1
532
536
  });
533
537
  if (!p && !q)
534
- return /* @__PURE__ */ n(
538
+ return /* @__PURE__ */ s(
535
539
  "button",
536
540
  {
537
541
  type: "button",
@@ -543,59 +547,60 @@ function dt({
543
547
  children: "Missing something?"
544
548
  }
545
549
  );
546
- if (C && !i)
547
- return /* @__PURE__ */ n("p", { className: "border-t border-border px-3 py-1.5 text-[11px] text-muted-foreground", children: "Checking what narrows this list…" });
548
- if (!i) return null;
550
+ if (C && !o)
551
+ 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…" });
552
+ if (!o) return null;
549
553
  const l = [], f = r ? `match “${r}”` : "exist";
550
- return i.by_field_filter > 0 && l.push(
551
- `${i.by_field_filter.toLocaleString()} more ${f} but this field only offers ${y.length ? `records that fit ${y.join(" · ")}` : "records its filter allows"}.`
552
- ), i.by_exclusions > 0 && l.push(
553
- `${i.by_exclusions.toLocaleString()} ${i.by_exclusions === 1 ? "is" : "are"} hidden from pickers by an admin.`
554
- ), i.scopes.length > 0 && l.push(`Your ${i.scopes.join(", ")} access narrows what you can pick here.`), i.row_filter && l.push("Your role only sees some of these records."), l.length === 0 && l.push(
554
+ return o.by_field_filter > 0 && l.push(
555
+ `${o.by_field_filter.toLocaleString()} more ${f} but this field only offers ${y.length ? `records that fit ${y.join(" · ")}` : "records its filter allows"}.`
556
+ ), o.by_exclusions > 0 && l.push(
557
+ `${o.by_exclusions.toLocaleString()} ${o.by_exclusions === 1 ? "is" : "are"} hidden from pickers by an admin.`
558
+ ), o.scopes.length > 0 && l.push(`Your ${o.scopes.join(", ")} access narrows what you can pick here.`), o.row_filter && l.push("Your role only sees some of these records."), l.length === 0 && l.push(
555
559
  r ? `Nothing else you can see matches “${r}”.` : "Nothing narrows this list — every record you can see is offered."
556
- ), /* @__PURE__ */ n(
560
+ ), /* @__PURE__ */ s(
557
561
  "div",
558
562
  {
559
563
  className: "space-y-0.5 border-t border-border px-3 py-1.5 text-[11px] leading-4 text-muted-foreground",
560
564
  "data-picker-narrowing": !0,
561
- "data-picker-narrowing-field": i.by_field_filter,
562
- "data-picker-narrowing-excluded": i.by_exclusions,
563
- children: l.map((_) => /* @__PURE__ */ n("p", { children: _ }, _))
565
+ "data-picker-narrowing-field": o.by_field_filter,
566
+ "data-picker-narrowing-excluded": o.by_exclusions,
567
+ children: l.map((_) => /* @__PURE__ */ s("p", { children: _ }, _))
564
568
  }
565
569
  );
566
570
  }
567
- function $t({
568
- collection: s,
571
+ function Ct({
572
+ collection: n,
569
573
  id: r,
570
574
  displayTemplate: d
571
575
  }) {
572
- const y = ae(), q = je(), g = s === "nivaro_files" || s === "directus_files", p = (() => {
576
+ const y = ae(), q = Re(), g = n === "nivaro_files" || n === "directus_files", p = (() => {
573
577
  if (!d || !d.includes(".")) return null;
574
- const i = [...d.matchAll(/\{\{([^}]+)\}\}/g)].map((C) => C[1].trim());
575
- return i.length > 0 ? ["id", ...i].join(",") : null;
578
+ const o = [...d.matchAll(/\{\{([^}]+)\}\}/g)].map((C) => C[1].trim());
579
+ return o.length > 0 ? ["id", ...o].join(",") : null;
576
580
  })(), { data: m, isLoading: F } = S({
577
- queryKey: ["relation-single", s, String(r), p ?? ""],
581
+ queryKey: ["relation-single", n, String(r), p ?? ""],
578
582
  queryFn: () => g ? (
579
583
  // The file's row, not its bytes: GET /files/:id downloads the whole
580
584
  // file (twice with the retry, 404 when storage lost it) only to read
581
585
  // its name, and a missing object left the raw id as the label.
582
586
  y.request(
583
587
  R(`/files/${encodeURIComponent(String(r))}/meta`)
584
- ).then((i) => i.data)
585
- ) : q(s, r, p),
586
- enabled: !!r && !!s,
588
+ ).then((o) => o.data)
589
+ ) : q(n, r, p),
590
+ enabled: !!r && !!n,
587
591
  staleTime: 6e4
588
592
  });
589
- if (F) return /* @__PURE__ */ n(B, { className: "h-3 w-3 animate-spin text-slate-400" });
590
- if (!m) return /* @__PURE__ */ n("span", { children: String(r ?? "") });
593
+ if (F) return /* @__PURE__ */ s(B, { className: "h-3 w-3 animate-spin text-slate-400" });
594
+ if (!m) return /* @__PURE__ */ s("span", { children: String(r ?? "") });
591
595
  if (g) {
592
- const i = m.title || m.filename_download || m.filename_disk || String(r);
593
- return /* @__PURE__ */ n("span", { children: i });
596
+ const o = m.title || m.filename_download || m.filename_disk || String(r);
597
+ return /* @__PURE__ */ s("span", { children: o });
594
598
  }
595
- return /* @__PURE__ */ n("span", { children: k(d, m) });
599
+ return /* @__PURE__ */ s("span", { children: N(d, m) });
596
600
  }
597
601
  export {
598
- $t as RelatedItemLabel,
599
- lt as RelationCombobox,
600
- at as useStaleTip
602
+ Ct as RelatedItemLabel,
603
+ dt as RelationCombobox,
604
+ Le as isSamePick,
605
+ lt as useStaleTip
601
606
  };