@nivaro/react 0.3.49 → 0.3.51

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 (46) 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 +38 -4
  5. package/dist/shared/components/ItemEditForm.js +5258 -5034
  6. package/dist/shared/components/QueryTable.js +489 -347
  7. package/dist/shared/components/ReportView.js +105 -99
  8. package/dist/shared/components/alerts/AlertManagerView.js +327 -301
  9. package/dist/shared/components/item-edit/CatalogPickerField.js +1230 -1175
  10. package/dist/shared/components/item-edit/CloneDialog.js +192 -142
  11. package/dist/shared/components/item-edit/DraftRecoveryBanner.js +58 -53
  12. package/dist/shared/components/item-edit/FieldRenderer.js +249 -244
  13. package/dist/shared/components/item-edit/FieldRow.js +402 -370
  14. package/dist/shared/components/item-edit/FilePickerField.js +315 -307
  15. package/dist/shared/components/item-edit/InlineGridField.js +92 -90
  16. package/dist/shared/components/item-edit/InlineTableField.js +3119 -2951
  17. package/dist/shared/components/item-edit/MidairCollisionDialog.js +175 -0
  18. package/dist/shared/components/item-edit/PlanGrid.js +162 -162
  19. package/dist/shared/components/item-edit/PolishFields.js +169 -162
  20. package/dist/shared/components/item-edit/RecordHeaderActions.js +76 -75
  21. package/dist/shared/components/item-edit/RecordLiveSync.js +93 -91
  22. package/dist/shared/components/item-edit/RelationCombobox.js +198 -191
  23. package/dist/shared/components/item-edit/SummaryPanel.js +282 -259
  24. package/dist/shared/components/item-edit/UserChip.js +233 -200
  25. package/dist/shared/components/item-edit/ValidationSummary.js +64 -47
  26. package/dist/shared/components/item-edit/header-midair.js +51 -0
  27. package/dist/shared/components/item-edit/helpers.js +181 -155
  28. package/dist/shared/components/item-edit/line-midair.js +207 -0
  29. package/dist/shared/components/item-edit/soft-rules.js +27 -0
  30. package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
  31. package/dist/shared/components/panels/CommentPanel.js +290 -284
  32. package/dist/shared/components/panels/ItemLockBanner.js +414 -358
  33. package/dist/shared/components/panels/PipelinePanel.js +1241 -992
  34. package/dist/shared/components/panels/RecordIntegrityBanner.js +1 -1
  35. package/dist/shared/components/panels/TaskPanel.js +71 -61
  36. package/dist/shared/components/panels/TransitionRequirementsDialog.js +569 -439
  37. package/dist/shared/components/panels/requirement-side-effects.js +40 -0
  38. package/dist/shared/components/queue/QueueWorklist.js +925 -871
  39. package/dist/shared/components/queue/column-chooser.js +21 -0
  40. package/dist/shared/components/queue/live-state-aspect.js +6 -0
  41. package/dist/shared/components/ui/number-draft-input.js +93 -0
  42. package/dist/shared/components/widgets/ReviewListWidget.js +191 -166
  43. package/dist/shared/lib/draft-store.js +48 -34
  44. package/dist/shared/lib/error-hints.js +1 -0
  45. package/dist/shared/lib/query-stats.js +60 -60
  46. 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";
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
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() || "?";
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
- narrowedBy: l,
57
+ narrowedBy: a,
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,33 +75,33 @@ function lt({
72
75
  }, 30) : ce("");
73
76
  }, [c]), j(() => {
74
77
  if (!c) return;
75
- const e = (o) => {
76
- 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);
78
+ const e = (i) => {
79
+ var l;
80
+ const t = i.target;
81
+ (l = t == null ? void 0 : t.closest) != null && l.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);
92
+ const i = H.current;
93
+ if (!i) return;
94
+ const t = i.getBoundingClientRect(), l = i.closest('[role="dialog"]') ?? document.body;
95
+ Oe(l);
93
96
  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 = {
94
97
  minWidth: t.width,
95
98
  zIndex: 120,
96
99
  ...Ne ? { transform: "translateY(-100%)" } : {}
97
100
  };
98
- if (a === document.body)
101
+ if (l === document.body)
99
102
  ee({ position: "fixed", left: ke, top: Se, ...qe });
100
103
  else {
101
- const _e = a.getBoundingClientRect();
104
+ const _e = l.getBoundingClientRect();
102
105
  ee({ position: "absolute", left: ke - _e.left, top: Se - _e.top, ...qe });
103
106
  }
104
107
  };
@@ -106,42 +109,42 @@ function lt({
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
+ (l) => l.many_collection === n && l.many_field === i.field && !l.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
150
  }, [Y]), N = ne ? JSON.stringify(ne) : void 0, U = m && !/^-?label$/.test(m) ? m : void 0, {
@@ -151,14 +154,14 @@ function lt({
151
154
  } = S({
152
155
  queryKey: [
153
156
  "relation-opts",
154
- s,
157
+ n,
155
158
  L,
156
159
  N,
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 } : {},
@@ -169,41 +172,41 @@ function lt({
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,
175
+ enabled: c && !Ie,
173
176
  staleTime: N ? 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] === N && 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), N],
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}|${N ?? ""}`, 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
233
  ...N ? { filter: N } : {}
231
234
  })
232
- ).then((o) => {
233
- var a;
234
- const t = o.data ?? [];
235
- t.length === 1 && ((a = t[0]) == null ? void 0 : a.id) != null && d(t[0].id);
235
+ ).then((i) => {
236
+ var l;
237
+ const t = i.data ?? [];
238
+ t.length === 1 && ((l = t[0]) == null ? void 0 : l.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, N]);
243
+ const w = Y, ye = r && W ? k(w, W) : null, ie = !be && v === L, Z = K(
241
244
  () => ot(
242
245
  h ?? [],
243
246
  (e) => k(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) => k(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 } }),
@@ -267,19 +270,19 @@ function lt({
267
270
  String(t.id),
268
271
  (k(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
- const a = e.get(String(t.id));
273
- a !== void 0 && o.set(a, [...o.get(a) ?? [], t]);
275
+ const l = e.get(String(t.id));
276
+ l !== void 0 && i.set(l, [...i.get(l) ?? [], 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((l) => ({ ...l, [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,93 +399,96 @@ 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 ? k(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 ? a && a.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(" · ") }),
423
- l.onClear ? " — clear one to widen the list:" : "."
426
+ /* @__PURE__ */ s("span", { className: "font-medium text-foreground", children: a.labels.join(" · ") }),
427
+ a.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(
426
- "button",
427
- {
428
- type: "button",
429
- onClick: (t) => {
430
- var a;
431
- t.stopPropagation(), (a = l.onClear) == null || a.call(l, e);
429
+ a.onClear && /* @__PURE__ */ s("div", { className: "mt-1.5 flex flex-wrap gap-1.5", children: a.keys.map(
430
+ (e, i) => a.clearable && !a.clearable.includes(e) ? null : /* @__PURE__ */ u(
431
+ "button",
432
+ {
433
+ type: "button",
434
+ onClick: (t) => {
435
+ var l;
436
+ t.stopPropagation(), (l = a.onClear) == null || l.call(a, e);
437
+ },
438
+ 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",
439
+ children: [
440
+ "Clear ",
441
+ a.labels[i] ?? e
442
+ ]
432
443
  },
433
- 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
- children: [
435
- "Clear ",
436
- l.labels[o] ?? e
437
- ]
438
- },
439
- e
440
- )) })
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(
444
+ e
445
+ )
446
+ ) })
447
+ ] }) : /* @__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(
448
+ (e, i) => Ze(
443
449
  k(w, e),
444
- k(w, o),
450
+ k(w, i),
445
451
  v,
446
452
  m === "-label"
447
453
  )
448
454
  )).filter((e) => !x || String(e.id) !== x).map((e) => {
449
- const o = k(w, e) || `#${e.id}`, t = String(e.id) === String(r);
455
+ const i = k(w, e) || `#${e.id}`, t = String(e.id) === String(r);
450
456
  return /* @__PURE__ */ u(
451
457
  "button",
452
458
  {
453
459
  type: "button",
454
460
  onClick: () => {
455
- d(e.id), P(!1);
461
+ Le(r, e.id) || d(e.id), P(!1);
456
462
  },
457
463
  className: "flex w-full items-center gap-2 px-3 py-1.5 text-[13px] text-left hover:bg-muted",
458
464
  children: [
459
- /* @__PURE__ */ n(
465
+ /* @__PURE__ */ s(
460
466
  "div",
461
467
  {
462
468
  className: J(
463
469
  "flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",
464
470
  t ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300"
465
471
  ),
466
- children: t && /* @__PURE__ */ n(Ce, { className: "h-2.5 w-2.5 text-white" })
472
+ children: t && /* @__PURE__ */ s(Ce, { className: "h-2.5 w-2.5 text-white" })
467
473
  }
468
474
  ),
469
- E && /* @__PURE__ */ n(
470
- Be,
475
+ E && /* @__PURE__ */ s(
476
+ et,
471
477
  {
472
478
  userId: e.id,
473
479
  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) })
480
+ 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
481
  }
476
482
  ),
477
- E && Pe.has(String(e.id).toUpperCase()) && /* @__PURE__ */ n(
483
+ E && Ue.has(String(e.id).toUpperCase()) && /* @__PURE__ */ s(
478
484
  "span",
479
485
  {
480
486
  className: "h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500",
481
487
  "data-tip": "Online now"
482
488
  }
483
489
  ),
484
- /* @__PURE__ */ n(Qe, { text: o, query: v }),
485
- we.has(String(e.id)) && /* @__PURE__ */ n(
490
+ /* @__PURE__ */ s(Be, { text: i, query: v }),
491
+ we.has(String(e.id)) && /* @__PURE__ */ s(
486
492
  "span",
487
493
  {
488
494
  className: "ml-auto max-w-[45%] shrink-0 truncate pl-2 text-[11.5px] text-muted-foreground",
@@ -496,13 +502,13 @@ function lt({
496
502
  );
497
503
  })
498
504
  ] }),
499
- !O && /* @__PURE__ */ n(
500
- dt,
505
+ !O && /* @__PURE__ */ s(
506
+ ct,
501
507
  {
502
- collection: s,
508
+ collection: n,
503
509
  search: L,
504
510
  filter: ne,
505
- narrowedLabels: (l == null ? void 0 : l.labels) ?? [],
511
+ narrowedLabels: (a == null ? void 0 : a.labels) ?? [],
506
512
  auto: (h ?? []).length === 0 && !!L
507
513
  }
508
514
  )
@@ -514,24 +520,24 @@ function lt({
514
520
  ] })
515
521
  );
516
522
  }
517
- function dt({
518
- collection: s,
523
+ function ct({
524
+ collection: n,
519
525
  search: r,
520
526
  filter: d,
521
527
  narrowedLabels: y,
522
528
  auto: q
523
529
  }) {
524
- const g = ae(), [p, m] = $(!1), F = d ? JSON.stringify(d) : "", { data: i, isFetching: C } = S({
525
- queryKey: ["picker-narrowing", s, r, F],
530
+ const g = ae(), [p, m] = $(!1), F = d ? JSON.stringify(d) : "", { data: o, isFetching: C } = S({
531
+ queryKey: ["picker-narrowing", n, r, F],
526
532
  queryFn: () => g.request(
527
- Ge("/picker-narrowing", { collection: s, search: r, filter: d ?? null })
533
+ Ve("/picker-narrowing", { collection: n, search: r, filter: d ?? null })
528
534
  ).then((_) => _.data),
529
535
  enabled: p || q,
530
536
  staleTime: 3e4,
531
537
  retry: !1
532
538
  });
533
539
  if (!p && !q)
534
- return /* @__PURE__ */ n(
540
+ return /* @__PURE__ */ s(
535
541
  "button",
536
542
  {
537
543
  type: "button",
@@ -543,59 +549,60 @@ function dt({
543
549
  children: "Missing something?"
544
550
  }
545
551
  );
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;
549
- 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(
552
+ if (C && !o)
553
+ 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…" });
554
+ if (!o) return null;
555
+ const a = [], f = r ? `match “${r}”` : "exist";
556
+ return o.by_field_filter > 0 && a.push(
557
+ `${o.by_field_filter.toLocaleString()} more ${f} but this field only offers ${y.length ? `records that fit ${y.join(" · ")}` : "records its filter allows"}.`
558
+ ), o.by_exclusions > 0 && a.push(
559
+ `${o.by_exclusions.toLocaleString()} ${o.by_exclusions === 1 ? "is" : "are"} hidden from pickers by an admin.`
560
+ ), o.scopes.length > 0 && a.push(`Your ${o.scopes.join(", ")} access narrows what you can pick here.`), o.row_filter && a.push("Your role only sees some of these records."), a.length === 0 && a.push(
555
561
  r ? `Nothing else you can see matches “${r}”.` : "Nothing narrows this list — every record you can see is offered."
556
- ), /* @__PURE__ */ n(
562
+ ), /* @__PURE__ */ s(
557
563
  "div",
558
564
  {
559
565
  className: "space-y-0.5 border-t border-border px-3 py-1.5 text-[11px] leading-4 text-muted-foreground",
560
566
  "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: _ }, _))
567
+ "data-picker-narrowing-field": o.by_field_filter,
568
+ "data-picker-narrowing-excluded": o.by_exclusions,
569
+ children: a.map((_) => /* @__PURE__ */ s("p", { children: _ }, _))
564
570
  }
565
571
  );
566
572
  }
567
- function $t({
568
- collection: s,
573
+ function Ct({
574
+ collection: n,
569
575
  id: r,
570
576
  displayTemplate: d
571
577
  }) {
572
- const y = ae(), q = je(), g = s === "nivaro_files" || s === "directus_files", p = (() => {
578
+ const y = ae(), q = Re(), g = n === "nivaro_files" || n === "directus_files", p = (() => {
573
579
  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;
580
+ const o = [...d.matchAll(/\{\{([^}]+)\}\}/g)].map((C) => C[1].trim());
581
+ return o.length > 0 ? ["id", ...o].join(",") : null;
576
582
  })(), { data: m, isLoading: F } = S({
577
- queryKey: ["relation-single", s, String(r), p ?? ""],
583
+ queryKey: ["relation-single", n, String(r), p ?? ""],
578
584
  queryFn: () => g ? (
579
585
  // The file's row, not its bytes: GET /files/:id downloads the whole
580
586
  // file (twice with the retry, 404 when storage lost it) only to read
581
587
  // its name, and a missing object left the raw id as the label.
582
588
  y.request(
583
589
  R(`/files/${encodeURIComponent(String(r))}/meta`)
584
- ).then((i) => i.data)
585
- ) : q(s, r, p),
586
- enabled: !!r && !!s,
590
+ ).then((o) => o.data)
591
+ ) : q(n, r, p),
592
+ enabled: !!r && !!n,
587
593
  staleTime: 6e4
588
594
  });
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 ?? "") });
595
+ if (F) return /* @__PURE__ */ s(B, { className: "h-3 w-3 animate-spin text-slate-400" });
596
+ if (!m) return /* @__PURE__ */ s("span", { children: String(r ?? "") });
591
597
  if (g) {
592
- const i = m.title || m.filename_download || m.filename_disk || String(r);
593
- return /* @__PURE__ */ n("span", { children: i });
598
+ const o = m.title || m.filename_download || m.filename_disk || String(r);
599
+ return /* @__PURE__ */ s("span", { children: o });
594
600
  }
595
- return /* @__PURE__ */ n("span", { children: k(d, m) });
601
+ return /* @__PURE__ */ s("span", { children: k(d, m) });
596
602
  }
597
603
  export {
598
- $t as RelatedItemLabel,
599
- lt as RelationCombobox,
600
- at as useStaleTip
604
+ Ct as RelatedItemLabel,
605
+ dt as RelationCombobox,
606
+ Le as isSamePick,
607
+ lt as useStaleTip
601
608
  };