@nivaro/react 0.3.10 → 0.3.12

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 (50) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useNivaroForm.js +1 -1
  3. package/dist/hooks/useSessionRecorder.js +109 -102
  4. package/dist/index.d.ts +34 -3
  5. package/dist/shared/components/CollectionBrowserView.js +1546 -1477
  6. package/dist/shared/components/ItemEditForm.js +4332 -4195
  7. package/dist/shared/components/PageRenderer.js +512 -465
  8. package/dist/shared/components/ProfileView.js +115 -109
  9. package/dist/shared/components/QueryStatStrip.js +74 -70
  10. package/dist/shared/components/ReportView.js +818 -827
  11. package/dist/shared/components/SheetHeaderBody.js +16 -14
  12. package/dist/shared/components/chat/ChatPanel.js +492 -472
  13. package/dist/shared/components/item-edit/CatalogPickerField.js +1029 -933
  14. package/dist/shared/components/item-edit/FieldRenderer.js +161 -156
  15. package/dist/shared/components/item-edit/FieldRow.js +20 -19
  16. package/dist/shared/components/item-edit/FilePickerField.js +52 -40
  17. package/dist/shared/components/item-edit/GroupSection.js +221 -221
  18. package/dist/shared/components/item-edit/InlineGridField.js +41 -41
  19. package/dist/shared/components/item-edit/InlineTableField.js +2249 -2238
  20. package/dist/shared/components/item-edit/M2MCombobox.js +46 -44
  21. package/dist/shared/components/item-edit/NestedRelationEditor.js +11 -11
  22. package/dist/shared/components/item-edit/QuickPicker.js +263 -216
  23. package/dist/shared/components/item-edit/RelationCombobox.js +285 -245
  24. package/dist/shared/components/item-edit/RichTextEditorImpl.js +42 -32
  25. package/dist/shared/components/item-edit/RowHistorySheet.js +130 -134
  26. package/dist/shared/components/item-edit/SummaryPanel.js +305 -279
  27. package/dist/shared/components/item-edit/UserChip.js +301 -233
  28. package/dist/shared/components/item-edit/helpers.js +133 -134
  29. package/dist/shared/components/item-edit/line-qty.js +57 -0
  30. package/dist/shared/components/item-edit/option-disambiguate.js +53 -0
  31. package/dist/shared/components/panels/AddendumLinesDiff.js +87 -90
  32. package/dist/shared/components/panels/CommentPanel.js +350 -315
  33. package/dist/shared/components/panels/ItemLockBanner.js +297 -230
  34. package/dist/shared/components/panels/PipelinePanel.js +719 -701
  35. package/dist/shared/components/profile/PersonAdminTools.js +168 -144
  36. package/dist/shared/components/profile/PersonProfile.js +42 -41
  37. package/dist/shared/components/profile/session-actions.js +52 -0
  38. package/dist/shared/components/queue/QueueQuickFilters.js +43 -41
  39. package/dist/shared/components/queue/QueueWorklist.js +1005 -935
  40. package/dist/shared/components/widgets/ReviewListWidget.js +99 -93
  41. package/dist/shared/lib/obligation-banner.js +14 -13
  42. package/dist/shared/lib/obligation-reason-text.js +13 -0
  43. package/dist/shared/lib/query-filter-seed.js +34 -11
  44. package/dist/shared/lib/replay-checkout.js +20 -0
  45. package/dist/shared/lib/sanitize-html.js +24 -15
  46. package/dist/shared/lib/sheet-def.js +38 -22
  47. package/dist/shared/lib/unique-options.js +10 -0
  48. package/dist/shared/lib/utils.js +57 -43
  49. package/dist/shared/lib/validation-rules.js +58 -34
  50. package/package.json +1 -1
@@ -1,185 +1,186 @@
1
- import { jsxs as c, jsx as r } from "react/jsx-runtime";
1
+ import { jsxs as c, jsx as n } from "react/jsx-runtime";
2
2
  import { useQuery as k } from "@tanstack/react-query";
3
- import { ChevronDown as ye, Loader2 as te, AlertTriangle as je, Search as Fe, X as Te, Check as we } from "lucide-react";
4
- import { useState as S, useRef as H, useEffect as j, useLayoutEffect as Ee, useMemo as ee } from "react";
5
- import { createPortal as ve } from "react-dom";
6
- import { useNivaroClient as re, useItemEditAuth as Oe, useStaleFieldReporter as Ae } from "../../context.js";
7
- import { get as F, post as Ke } from "../../lib/commands.js";
8
- import { useRecordReader as Ne } from "../../lib/record-loader.js";
9
- import { useOnlineUsers as Ue } from "../../lib/use-online-users.js";
10
- import { UserAvatar as Ie } from "../UserAvatar.js";
11
- import { userOptionFilter as Pe, cn as U } from "../../lib/utils.js";
12
- import { applyDisplayTemplate as N } from "./helpers.js";
13
- import { usePickerMissReport as De } from "./picker-miss.js";
14
- function ze(s) {
15
- return s.replace(/\(.*$/, "").trim().split(/\s+/).map((t) => t[0]).filter(Boolean).slice(0, 2).join("").toUpperCase() || "?";
3
+ import { ChevronDown as Ne, Loader2 as ne, AlertTriangle as Ee, Search as Oe, X as Ie, Check as ke } from "lucide-react";
4
+ import { useState as q, useRef as X, useEffect as E, useLayoutEffect as Ke, useMemo as U } from "react";
5
+ import { createPortal as Se } from "react-dom";
6
+ import { useNivaroClient as se, useItemEditAuth as Ae, useStaleFieldReporter as Ue } from "../../context.js";
7
+ import { get as $, post as Me } from "../../lib/commands.js";
8
+ import { useRecordReader as _e } from "../../lib/record-loader.js";
9
+ import { useOnlineUsers as Pe } from "../../lib/use-online-users.js";
10
+ import { UserAvatar as De } from "../UserAvatar.js";
11
+ import { userOptionFilter as Je, cn as M } from "../../lib/utils.js";
12
+ import { applyDisplayTemplate as v } from "./helpers.js";
13
+ import { collidingIds as ze, disambiguators as Qe } from "./option-disambiguate.js";
14
+ import { usePickerMissReport as He } from "./picker-miss.js";
15
+ function Ye(s) {
16
+ return s.replace(/\(.*$/, "").trim().split(/\s+/).map((r) => r[0]).filter(Boolean).slice(0, 2).join("").toUpperCase() || "?";
16
17
  }
17
- function Je(s) {
18
- const [t, d] = S(null), h = {
18
+ function We(s) {
19
+ const [r, d] = q(null), h = {
19
20
  onMouseEnter: (f) => {
20
21
  if (!s) return;
21
22
  const m = f.currentTarget.getBoundingClientRect(), u = window.innerHeight - m.bottom < 80;
22
23
  d({ x: m.left, y: u ? m.top - 58 : m.bottom + 4 });
23
24
  },
24
25
  onMouseLeave: () => d(null)
25
- }, y = s && t ? ve(
26
- /* @__PURE__ */ r(
26
+ }, S = s && r ? Se(
27
+ /* @__PURE__ */ n(
27
28
  "div",
28
29
  {
29
- style: { position: "fixed", left: t.x, top: t.y, zIndex: 130 },
30
+ style: { position: "fixed", left: r.x, top: r.y, zIndex: 130 },
30
31
  className: "pointer-events-none max-w-[300px] rounded-md border border-amber-200 bg-amber-50 px-2.5 py-1.5 text-[11.5px] leading-snug text-amber-800 shadow-md dark:border-amber-500/40 dark:bg-[#2a2113] dark:text-amber-300",
31
32
  children: "Current value is not an available option — clear to pick another"
32
33
  }
33
34
  ),
34
35
  document.body
35
36
  ) : null;
36
- return { bind: h, tip: y };
37
+ return { bind: h, tip: S };
37
38
  }
38
- function Me({
39
+ function Xe({
39
40
  collection: s,
40
- value: t,
41
+ value: r,
41
42
  onChange: d,
42
43
  disabled: h,
43
- placeholder: y,
44
+ placeholder: S,
44
45
  extraFilter: f,
45
46
  autoSelectSingle: m,
46
47
  optionSort: u,
47
- requiredParent: $,
48
- facets: o,
49
- fieldKey: _,
50
- narrowedBy: l,
48
+ requiredParent: L,
49
+ facets: i,
50
+ fieldKey: C,
51
+ narrowedBy: a,
51
52
  pinned: p,
52
- missPlacement: w
53
+ missPlacement: _
53
54
  }) {
54
- const T = re(), ne = Ne(), [g, E] = S(!1), [L, se] = S(""), [R, oe] = S(""), ie = H(null), I = H(null);
55
- j(() => {
56
- g ? setTimeout(() => {
55
+ const j = se(), oe = _e(), [x, O] = q(!1), [R, ie] = q(""), [T, le] = q(""), ae = X(null), P = X(null);
56
+ E(() => {
57
+ x ? setTimeout(() => {
57
58
  var e;
58
- return (e = ie.current) == null ? void 0 : e.focus();
59
- }, 30) : (se(""), oe(""));
60
- }, [g]), j(() => {
61
- const e = setTimeout(() => oe(L), 300);
59
+ return (e = ae.current) == null ? void 0 : e.focus();
60
+ }, 30) : (ie(""), le(""));
61
+ }, [x]), E(() => {
62
+ const e = setTimeout(() => le(R), 300);
62
63
  return () => clearTimeout(e);
63
- }, [L]), j(() => {
64
- if (!g) return;
65
- const e = (i) => {
66
- var a;
67
- const n = i.target;
68
- (a = n == null ? void 0 : n.closest) != null && a.call(n, "[data-nvr-combobox-panel]") || I.current && !I.current.contains(i.target) && E(!1);
64
+ }, [R]), E(() => {
65
+ if (!x) return;
66
+ const e = (o) => {
67
+ var l;
68
+ const t = o.target;
69
+ (l = t == null ? void 0 : t.closest) != null && l.call(t, "[data-nvr-combobox-panel]") || P.current && !P.current.contains(o.target) && O(!1);
69
70
  };
70
71
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
71
- }, [g]);
72
- const [le, Y] = S(null), [ae, ke] = S(null);
73
- Ee(() => {
74
- if (!g) {
75
- Y(null);
72
+ }, [x]);
73
+ const [de, G] = q(null), [ce, qe] = q(null);
74
+ Ke(() => {
75
+ if (!x) {
76
+ G(null);
76
77
  return;
77
78
  }
78
79
  const e = () => {
79
- const i = I.current;
80
- if (!i) return;
81
- const n = i.getBoundingClientRect(), a = i.closest('[role="dialog"]') ?? document.body;
82
- ke(a);
83
- const fe = window.innerHeight - n.bottom < 340 && n.top > window.innerHeight - n.bottom, be = n.left, he = fe ? n.top - 4 : n.bottom + 4, ge = {
84
- minWidth: n.width,
80
+ const o = P.current;
81
+ if (!o) return;
82
+ const t = o.getBoundingClientRect(), l = o.closest('[role="dialog"]') ?? document.body;
83
+ qe(l);
84
+ const he = window.innerHeight - t.bottom < 340 && t.top > window.innerHeight - t.bottom, xe = t.left, ye = he ? t.top - 4 : t.bottom + 4, we = {
85
+ minWidth: t.width,
85
86
  zIndex: 120,
86
- ...fe ? { transform: "translateY(-100%)" } : {}
87
+ ...he ? { transform: "translateY(-100%)" } : {}
87
88
  };
88
- if (a === document.body)
89
- Y({ position: "fixed", left: be, top: he, ...ge });
89
+ if (l === document.body)
90
+ G({ position: "fixed", left: xe, top: ye, ...we });
90
91
  else {
91
- const xe = a.getBoundingClientRect();
92
- Y({ position: "absolute", left: be - xe.left, top: he - xe.top, ...ge });
92
+ const ve = l.getBoundingClientRect();
93
+ G({ position: "absolute", left: xe - ve.left, top: ye - ve.top, ...we });
93
94
  }
94
95
  };
95
96
  return e(), window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
96
97
  window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
97
98
  };
98
- }, [g]);
99
- const { data: W } = k({
99
+ }, [x]);
100
+ const { data: V } = k({
100
101
  queryKey: ["col-meta", s],
101
- queryFn: () => T.request(F(`/collections/${s}`)).then((e) => e.data),
102
+ queryFn: () => j.request($(`/collections/${s}`)).then((e) => e.data),
102
103
  staleTime: 3e5,
103
104
  retry: !1
104
- }), [X, Se] = S({}), { data: de = [] } = k({
105
+ }), [Z, Ce] = q({}), { data: ue = [] } = k({
105
106
  queryKey: ["collection-meta", s],
106
- queryFn: () => T.request(
107
- F(`/collections/${s}`)
107
+ queryFn: () => j.request(
108
+ $(`/collections/${s}`)
108
109
  ).then(
109
110
  (e) => {
110
- var i;
111
- return ((i = e.data) == null ? void 0 : i.relations) ?? [];
111
+ var o;
112
+ return ((o = e.data) == null ? void 0 : o.relations) ?? [];
112
113
  }
113
114
  ),
114
- enabled: !!(o != null && o.length),
115
+ enabled: !!(i != null && i.length),
115
116
  staleTime: 10 * 6e4
116
- }), _e = ee(() => {
117
+ }), $e = U(() => {
117
118
  const e = {};
118
- for (const i of o ?? []) {
119
- const n = de.find(
120
- (a) => a.many_collection === s && a.many_field === i.field && !a.junction_field
119
+ for (const o of i ?? []) {
120
+ const t = ue.find(
121
+ (l) => l.many_collection === s && l.many_field === o.field && !l.junction_field
121
122
  );
122
- n != null && n.one_collection && (e[i.field] = n.one_collection);
123
+ t != null && t.one_collection && (e[o.field] = t.one_collection);
123
124
  }
124
125
  return e;
125
- }, [o, de, s]), O = s === "nivaro_users", qe = Ue(O), ce = Oe().isAdmin, G = ee(() => {
126
+ }, [i, ue, s]), F = s === "nivaro_users", Le = Pe(F), me = Ae().isAdmin, B = U(() => {
126
127
  const e = [];
127
- O && e.push(Pe(ce)), f && e.push(f);
128
- for (const [i, n] of Object.entries(X))
129
- n != null && n !== "" && e.push({ [i]: { _eq: n } });
128
+ F && e.push(Je(me)), f && e.push(f);
129
+ for (const [o, t] of Object.entries(Z))
130
+ t != null && t !== "" && e.push({ [o]: { _eq: t } });
130
131
  if (e.length !== 0)
131
132
  return e.length === 1 ? e[0] : { _and: e };
132
- }, [f, X, ce]), P = (W == null ? void 0 : W.display_template) ?? (O ? "{{first_name}} {{last_name}} ({{email}})" : null), q = ee(() => {
133
- if (!P) return;
134
- const e = [...P.matchAll(/\{\{([\w.]+)\}\}/g)].map((i) => i[1]);
133
+ }, [f, Z, me]), D = (V == null ? void 0 : V.display_template) ?? (F ? "{{first_name}} {{last_name}} ({{email}})" : null), y = U(() => {
134
+ if (!D) return;
135
+ const e = [...D.matchAll(/\{\{([\w.]+)\}\}/g)].map((o) => o[1]);
135
136
  if (e.length)
136
137
  return ["id", ...e].join(",");
137
- }, [P]), x = G ? JSON.stringify(G) : void 0, D = u && !/^-?label$/.test(u) ? u : void 0, { data: v, isFetching: V } = k({
138
+ }, [D]), N = B ? JSON.stringify(B) : void 0, J = u && !/^-?label$/.test(u) ? u : void 0, { data: b, isFetching: ee } = k({
138
139
  queryKey: [
139
140
  "relation-opts",
140
141
  s,
141
- R,
142
- x,
143
- q,
144
- D ?? ""
142
+ T,
143
+ N,
144
+ y,
145
+ J ?? ""
145
146
  ],
146
- queryFn: () => T.request(
147
- F(`/items/${s}`, {
147
+ queryFn: () => j.request(
148
+ $(`/items/${s}`, {
148
149
  limit: 200,
149
150
  picker: "1",
150
- ...R ? { search: R } : {},
151
- ...x ? { filter: x } : {},
152
- ...q ? { fields: q } : {},
153
- ...D ? { sort: D } : {}
151
+ ...T ? { search: T } : {},
152
+ ...N ? { filter: N } : {},
153
+ ...y ? { fields: y } : {},
154
+ ...J ? { sort: J } : {}
154
155
  })
155
156
  ).then((e) => e.data ?? []),
156
- enabled: g,
157
- staleTime: x ? 0 : 3e4
157
+ enabled: x,
158
+ staleTime: N ? 0 : 3e4
158
159
  });
159
- De({
160
- placement: w,
161
- open: g,
162
- search: R,
163
- settled: !V && v !== void 0,
164
- count: (v == null ? void 0 : v.length) ?? 0
160
+ He({
161
+ placement: _,
162
+ open: x,
163
+ search: T,
164
+ settled: !ee && b !== void 0,
165
+ count: (b == null ? void 0 : b.length) ?? 0
165
166
  });
166
- const { data: z, isLoading: Ce } = k({
167
- queryKey: ["relation-single", s, String(t), q],
168
- queryFn: () => ne(s, t, q),
169
- enabled: !!t,
167
+ const { data: z, isLoading: je } = k({
168
+ queryKey: ["relation-single", s, String(r), y],
169
+ queryFn: () => oe(s, r, y),
170
+ enabled: !!r,
170
171
  staleTime: 6e4
171
- }), b = (p == null ? void 0 : p.id) != null && p.id !== "" ? String(p.id) : null, { data: A } = k({
172
- queryKey: ["relation-single", s, b ?? "", q],
173
- queryFn: () => ne(s, b, q).catch(
172
+ }), g = (p == null ? void 0 : p.id) != null && p.id !== "" ? String(p.id) : null, { data: I } = k({
173
+ queryKey: ["relation-single", s, g ?? "", y],
174
+ queryFn: () => oe(s, g, y).catch(
174
175
  () => null
175
176
  ),
176
- enabled: !!b && g,
177
+ enabled: !!g && x,
177
178
  staleTime: 6e4
178
- }), $e = JSON.stringify(f ? { _and: [{ id: { _eq: t } }, f] } : { id: { _eq: t } }), { data: J } = k({
179
- queryKey: ["relation-avail", s, String(t), x],
180
- queryFn: () => T.request(
181
- F(`/items/${s}`, {
182
- filter: $e,
179
+ }), Re = JSON.stringify(f ? { _and: [{ id: { _eq: r } }, f] } : { id: { _eq: r } }), { data: Q } = k({
180
+ queryKey: ["relation-avail", s, String(r), N],
181
+ queryFn: () => j.request(
182
+ $(`/items/${s}`, {
183
+ filter: Re,
183
184
  picker: "1",
184
185
  limit: 1,
185
186
  fields: "id"
@@ -188,35 +189,66 @@ function Me({
188
189
  // The pinned option is offered OUTSIDE the option filter (a type's generic
189
190
  // item is excluded from the general list on purpose), so a value that IS
190
191
  // the pin is available by construction — never probe it, never flag it.
191
- enabled: !!t && !!z && String(t) !== b,
192
+ enabled: !!r && !!z && String(r) !== g,
192
193
  staleTime: 3e4
193
- }), K = !!t && String(t) !== b && J !== void 0 && J.length === 0, M = H(null), Z = H(!1), ue = `${s}|${x ?? ""}`, Le = () => {
194
- Z.current = !0, M.current = ue, d(null);
195
- }, Q = t == null || t === "";
196
- j(() => {
197
- Q || (Z.current = !1);
198
- }, [Q]), j(() => {
199
- if (!m || h || !Q || Z.current) return;
200
- const e = ue;
201
- M.current !== e && (M.current = e, T.request(
202
- F(`/items/${s}`, {
194
+ }), K = !!r && String(r) !== g && Q !== void 0 && Q.length === 0, H = X(null), te = X(!1), pe = `${s}|${N ?? ""}`, Te = () => {
195
+ te.current = !0, H.current = pe, d(null);
196
+ }, Y = r == null || r === "";
197
+ E(() => {
198
+ Y || (te.current = !1);
199
+ }, [Y]), E(() => {
200
+ if (!m || h || !Y || te.current) return;
201
+ const e = pe;
202
+ H.current !== e && (H.current = e, j.request(
203
+ $(`/items/${s}`, {
203
204
  limit: 2,
204
205
  picker: "1",
205
206
  fields: "id",
206
- ...x ? { filter: x } : {}
207
+ ...N ? { filter: N } : {}
207
208
  })
208
- ).then((i) => {
209
- var a;
210
- const n = i.data ?? [];
211
- n.length === 1 && ((a = n[0]) == null ? void 0 : a.id) != null && d(n[0].id);
209
+ ).then((o) => {
210
+ var l;
211
+ const t = o.data ?? [];
212
+ t.length === 1 && ((l = t[0]) == null ? void 0 : l.id) != null && d(t[0].id);
212
213
  }).catch(() => {
213
- M.current = null;
214
+ H.current = null;
214
215
  }));
215
- }, [m, h, Q, s, x]);
216
- const C = P, me = t && z ? N(C, z) : null, Re = !!t && Ce && !z, pe = Je(K), B = Ae();
217
- return j(() => {
218
- !B || !_ || J === void 0 || B(_, K);
219
- }, [B, _, K, J]), $ ? /* @__PURE__ */ c(
216
+ }, [m, h, Y, s, N]);
217
+ const w = D, fe = r && z ? v(w, z) : null, W = U(
218
+ () => ze(b ?? [], (e) => v(w, e) || `#${e.id}`),
219
+ [b, w]
220
+ ), { data: A } = k({
221
+ queryKey: ["relation-opts-dups", s, W.join(",")],
222
+ queryFn: () => j.request(
223
+ $(`/items/${s}`, {
224
+ limit: W.length,
225
+ picker: "1",
226
+ filter: JSON.stringify({ id: { _in: W } }),
227
+ fields: "*"
228
+ })
229
+ ).then((e) => e.data ?? []),
230
+ enabled: x && W.length > 0 && !F,
231
+ staleTime: 6e4
232
+ }), be = U(() => {
233
+ if (!(A != null && A.length)) return /* @__PURE__ */ new Map();
234
+ const e = new Map(
235
+ (b ?? []).map((t) => [
236
+ String(t.id),
237
+ (v(w, t) || `#${t.id}`).trim().toLowerCase()
238
+ ])
239
+ ), o = /* @__PURE__ */ new Map();
240
+ for (const t of A) {
241
+ const l = e.get(String(t.id));
242
+ l !== void 0 && o.set(l, [...o.get(l) ?? [], t]);
243
+ }
244
+ return Qe(
245
+ [...o.values()],
246
+ ((y == null ? void 0 : y.split(",")) ?? []).map((t) => t.split(".")[0])
247
+ );
248
+ }, [A, b, w, y]), Fe = !!r && je && !z, ge = We(K), re = Ue();
249
+ return E(() => {
250
+ !re || !C || Q === void 0 || re(C, K);
251
+ }, [re, C, K, Q]), L ? /* @__PURE__ */ c(
220
252
  "button",
221
253
  {
222
254
  type: "button",
@@ -225,66 +257,66 @@ function Me({
225
257
  children: [
226
258
  /* @__PURE__ */ c("span", { className: "truncate text-muted-foreground", children: [
227
259
  "Select ",
228
- $,
260
+ L,
229
261
  " first"
230
262
  ] }),
231
- /* @__PURE__ */ r(ye, { className: "h-4 w-4 shrink-0 opacity-50" })
263
+ /* @__PURE__ */ n(Ne, { className: "h-4 w-4 shrink-0 opacity-50" })
232
264
  ]
233
265
  }
234
266
  ) : (
235
267
  // Stale tooltip binds on the WRAPPER: a disabled trigger button swallows
236
268
  // mouse events, so a locked-but-stale field would never show the hint.
237
- /* @__PURE__ */ c("div", { ref: I, className: "relative", ...pe.bind, children: [
269
+ /* @__PURE__ */ c("div", { ref: P, className: "relative", ...ge.bind, children: [
238
270
  /* @__PURE__ */ c(
239
271
  "button",
240
272
  {
241
273
  type: "button",
242
274
  disabled: h,
243
- onClick: () => E((e) => !e),
244
- className: U(
275
+ onClick: () => O((e) => !e),
276
+ className: M(
245
277
  "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 disabled:pointer-events-none disabled:opacity-50",
246
278
  K ? "border-amber-300 dark:border-amber-600" : "border-input"
247
279
  ),
248
280
  children: [
249
- Re ? /* @__PURE__ */ r(te, { className: "h-3.5 w-3.5 animate-spin text-muted-foreground" }) : /* @__PURE__ */ c(
281
+ Fe ? /* @__PURE__ */ n(ne, { className: "h-3.5 w-3.5 animate-spin text-muted-foreground" }) : /* @__PURE__ */ c(
250
282
  "span",
251
283
  {
252
- className: U(
284
+ className: M(
253
285
  "flex items-center gap-1.5 truncate min-w-0",
254
- !me && "text-muted-foreground"
286
+ !fe && "text-muted-foreground"
255
287
  ),
256
288
  children: [
257
- K && /* @__PURE__ */ r(je, { className: "h-3.5 w-3.5 shrink-0 text-amber-500" }),
258
- /* @__PURE__ */ r("span", { className: "truncate", children: me ?? y ?? "Select…" })
289
+ K && /* @__PURE__ */ n(Ee, { className: "h-3.5 w-3.5 shrink-0 text-amber-500" }),
290
+ /* @__PURE__ */ n("span", { className: "truncate", children: fe ?? S ?? "Select…" })
259
291
  ]
260
292
  }
261
293
  ),
262
- /* @__PURE__ */ r(ye, { className: "h-4 w-4 shrink-0 opacity-50" })
294
+ /* @__PURE__ */ n(Ne, { className: "h-4 w-4 shrink-0 opacity-50" })
263
295
  ]
264
296
  }
265
297
  ),
266
- pe.tip,
267
- g && le && ae && ve(
298
+ ge.tip,
299
+ x && de && ce && Se(
268
300
  /* @__PURE__ */ c(
269
301
  "div",
270
302
  {
271
303
  "data-nvr-combobox-panel": "",
272
- style: le,
273
- className: U(
304
+ style: de,
305
+ className: M(
274
306
  "nvr-pop-in rounded-md border border-border bg-popover shadow-md",
275
- o != null && o.length ? "w-[560px] max-w-[92vw]" : "min-w-[240px] w-max max-w-[360px]"
307
+ i != null && i.length ? "w-[560px] max-w-[92vw]" : "min-w-[240px] w-max max-w-[360px]"
276
308
  ),
277
309
  children: [
278
- !!(o != null && o.length) && /* @__PURE__ */ r("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) => {
279
- const i = _e[e.field];
280
- return i ? /* @__PURE__ */ c("div", { children: [
281
- /* @__PURE__ */ r("p", { className: "mb-0.5 text-[10px] font-medium uppercase tracking-wide text-slate-400", children: e.label ?? e.field }),
282
- /* @__PURE__ */ r(
283
- Me,
310
+ !!(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) => {
311
+ const o = $e[e.field];
312
+ return o ? /* @__PURE__ */ c("div", { children: [
313
+ /* @__PURE__ */ n("p", { className: "mb-0.5 text-[10px] font-medium uppercase tracking-wide text-slate-400", children: e.label ?? e.field }),
314
+ /* @__PURE__ */ n(
315
+ Xe,
284
316
  {
285
- collection: i,
286
- value: X[e.field] ?? null,
287
- onChange: (n) => Se((a) => ({ ...a, [e.field]: n })),
317
+ collection: o,
318
+ value: Z[e.field] ?? null,
319
+ onChange: (t) => Ce((l) => ({ ...l, [e.field]: t })),
288
320
  placeholder: "Any",
289
321
  optionSort: e.sort,
290
322
  extraFilter: e.filter
@@ -293,219 +325,227 @@ function Me({
293
325
  ] }, e.field) : null;
294
326
  }) }),
295
327
  /* @__PURE__ */ c("div", { className: "flex items-center border-b px-3", children: [
296
- /* @__PURE__ */ r(Fe, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
297
- /* @__PURE__ */ r(
328
+ /* @__PURE__ */ n(Oe, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
329
+ /* @__PURE__ */ n(
298
330
  "input",
299
331
  {
300
- ref: ie,
301
- value: L,
302
- onChange: (e) => se(e.target.value),
332
+ ref: ae,
333
+ value: R,
334
+ onChange: (e) => ie(e.target.value),
303
335
  placeholder: "Search…",
304
336
  className: "flex h-9 w-full bg-transparent py-3 text-[13px] outline-none placeholder:text-muted-foreground"
305
337
  }
306
338
  )
307
339
  ] }),
308
340
  /* @__PURE__ */ c("div", { className: "max-h-52 overflow-y-auto py-1", children: [
309
- !!t && !h && /* @__PURE__ */ c(
341
+ !!r && !h && /* @__PURE__ */ c(
310
342
  "button",
311
343
  {
312
344
  type: "button",
313
345
  onClick: () => {
314
- Le(), E(!1);
346
+ Te(), O(!1);
315
347
  },
316
348
  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",
317
349
  children: [
318
- /* @__PURE__ */ r(Te, { className: "h-3.5 w-3.5 text-slate-400" }),
350
+ /* @__PURE__ */ n(Ie, { className: "h-3.5 w-3.5 text-slate-400" }),
319
351
  "Clear selection"
320
352
  ]
321
353
  }
322
354
  ),
323
- b && /* @__PURE__ */ c(
355
+ g && /* @__PURE__ */ c(
324
356
  "button",
325
357
  {
326
358
  type: "button",
327
359
  "data-nvr-pinned-option": !0,
328
360
  onClick: () => {
329
- d((A == null ? void 0 : A.id) ?? (p == null ? void 0 : p.id)), E(!1);
361
+ d((I == null ? void 0 : I.id) ?? (p == null ? void 0 : p.id)), O(!1);
330
362
  },
331
363
  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",
332
364
  children: [
333
- /* @__PURE__ */ r(
365
+ /* @__PURE__ */ n(
334
366
  "div",
335
367
  {
336
- className: U(
368
+ className: M(
337
369
  "flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",
338
- String(t) === b ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300"
370
+ String(r) === g ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300"
339
371
  ),
340
- children: String(t) === b && /* @__PURE__ */ r(we, { className: "h-2.5 w-2.5 text-white" })
372
+ children: String(r) === g && /* @__PURE__ */ n(ke, { className: "h-2.5 w-2.5 text-white" })
341
373
  }
342
374
  ),
343
- /* @__PURE__ */ r("span", { className: "min-w-0 flex-1 truncate", children: A ? N(C, A) || `#${b}` : `#${b}` }),
344
- /* @__PURE__ */ r("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: (p == null ? void 0 : p.tag) ?? "Default" })
375
+ /* @__PURE__ */ n("span", { className: "min-w-0 flex-1 truncate", children: I ? v(w, I) || `#${g}` : `#${g}` }),
376
+ /* @__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: (p == null ? void 0 : p.tag) ?? "Default" })
345
377
  ]
346
378
  }
347
379
  ),
348
- V ? /* @__PURE__ */ r("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ r(te, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : (v ?? []).length === 0 ? l && l.labels.length > 0 && !L.trim() ? /* @__PURE__ */ c("div", { className: "px-3 py-2 text-[12px] leading-5 text-muted-foreground", children: [
380
+ ee ? /* @__PURE__ */ n("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ n(ne, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : (b ?? []).length === 0 ? a && a.labels.length > 0 && !R.trim() ? /* @__PURE__ */ c("div", { className: "px-3 py-2 text-[12px] leading-5 text-muted-foreground", children: [
349
381
  /* @__PURE__ */ c("p", { children: [
350
382
  "No options for",
351
383
  " ",
352
- /* @__PURE__ */ r("span", { className: "font-medium text-foreground", children: l.labels.join(" · ") }),
353
- l.onClear ? " — clear one to widen the list:" : "."
384
+ /* @__PURE__ */ n("span", { className: "font-medium text-foreground", children: a.labels.join(" · ") }),
385
+ a.onClear ? " — clear one to widen the list:" : "."
354
386
  ] }),
355
- l.onClear && /* @__PURE__ */ r("div", { className: "mt-1.5 flex flex-wrap gap-1.5", children: l.keys.map((e, i) => /* @__PURE__ */ c(
387
+ a.onClear && /* @__PURE__ */ n("div", { className: "mt-1.5 flex flex-wrap gap-1.5", children: a.keys.map((e, o) => /* @__PURE__ */ c(
356
388
  "button",
357
389
  {
358
390
  type: "button",
359
- onClick: (n) => {
360
- var a;
361
- n.stopPropagation(), (a = l.onClear) == null || a.call(l, e);
391
+ onClick: (t) => {
392
+ var l;
393
+ t.stopPropagation(), (l = a.onClear) == null || l.call(a, e);
362
394
  },
363
395
  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",
364
396
  children: [
365
397
  "Clear ",
366
- l.labels[i] ?? e
398
+ a.labels[o] ?? e
367
399
  ]
368
400
  },
369
401
  e
370
402
  )) })
371
- ] }) : /* @__PURE__ */ r("p", { className: "px-3 py-2 text-[13px] text-muted-foreground", children: L.trim() ? `No results for “${L.trim()}”` : "No results" }) : (D ? [...v ?? []] : [...v ?? []].sort(
372
- (e, i) => u === "-label" ? N(C, i).localeCompare(N(C, e)) : N(C, e).localeCompare(N(C, i))
373
- )).filter((e) => !b || String(e.id) !== b).map((e) => {
374
- const i = N(C, e) || `#${e.id}`, n = String(e.id) === String(t);
403
+ ] }) : /* @__PURE__ */ n("p", { className: "px-3 py-2 text-[13px] text-muted-foreground", children: R.trim() ? `No results for “${R.trim()}”` : "No results" }) : (J ? [...b ?? []] : [...b ?? []].sort(
404
+ (e, o) => u === "-label" ? v(w, o).localeCompare(v(w, e)) : v(w, e).localeCompare(v(w, o))
405
+ )).filter((e) => !g || String(e.id) !== g).map((e) => {
406
+ const o = v(w, e) || `#${e.id}`, t = String(e.id) === String(r);
375
407
  return /* @__PURE__ */ c(
376
408
  "button",
377
409
  {
378
410
  type: "button",
379
411
  onClick: () => {
380
- d(e.id), E(!1);
412
+ d(e.id), O(!1);
381
413
  },
382
414
  className: "flex w-full items-center gap-2 px-3 py-1.5 text-[13px] text-left hover:bg-muted",
383
415
  children: [
384
- /* @__PURE__ */ r(
416
+ /* @__PURE__ */ n(
385
417
  "div",
386
418
  {
387
- className: U(
419
+ className: M(
388
420
  "flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",
389
- n ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300"
421
+ t ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300"
390
422
  ),
391
- children: n && /* @__PURE__ */ r(we, { className: "h-2.5 w-2.5 text-white" })
423
+ children: t && /* @__PURE__ */ n(ke, { className: "h-2.5 w-2.5 text-white" })
392
424
  }
393
425
  ),
394
- O && /* @__PURE__ */ r(
395
- Ie,
426
+ F && /* @__PURE__ */ n(
427
+ De,
396
428
  {
397
429
  userId: e.id,
398
430
  className: "h-4 w-4",
399
- fallback: /* @__PURE__ */ r("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: ze(i) })
431
+ 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: Ye(o) })
400
432
  }
401
433
  ),
402
- O && qe.has(String(e.id).toUpperCase()) && /* @__PURE__ */ r(
434
+ F && Le.has(String(e.id).toUpperCase()) && /* @__PURE__ */ n(
403
435
  "span",
404
436
  {
405
437
  className: "h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500",
406
438
  "data-tip": "Online now"
407
439
  }
408
440
  ),
409
- i
441
+ o,
442
+ be.has(String(e.id)) && /* @__PURE__ */ n(
443
+ "span",
444
+ {
445
+ className: "ml-auto max-w-[45%] shrink-0 truncate pl-2 text-[11.5px] text-muted-foreground",
446
+ "data-option-detail": !0,
447
+ children: be.get(String(e.id))
448
+ }
449
+ )
410
450
  ]
411
451
  },
412
452
  String(e.id)
413
453
  );
414
454
  })
415
455
  ] }),
416
- !V && /* @__PURE__ */ r(
417
- Qe,
456
+ !ee && /* @__PURE__ */ n(
457
+ Ge,
418
458
  {
419
459
  collection: s,
420
- search: R,
421
- filter: G,
422
- narrowedLabels: (l == null ? void 0 : l.labels) ?? [],
423
- auto: (v ?? []).length === 0 && !!R
460
+ search: T,
461
+ filter: B,
462
+ narrowedLabels: (a == null ? void 0 : a.labels) ?? [],
463
+ auto: (b ?? []).length === 0 && !!T
424
464
  }
425
465
  )
426
466
  ]
427
467
  }
428
468
  ),
429
- ae
469
+ ce
430
470
  )
431
471
  ] })
432
472
  );
433
473
  }
434
- function Qe({
474
+ function Ge({
435
475
  collection: s,
436
- search: t,
476
+ search: r,
437
477
  filter: d,
438
478
  narrowedLabels: h,
439
- auto: y
479
+ auto: S
440
480
  }) {
441
- const f = re(), [m, u] = S(!1), $ = d ? JSON.stringify(d) : "", { data: o, isFetching: _ } = k({
442
- queryKey: ["picker-narrowing", s, t, $],
481
+ const f = se(), [m, u] = q(!1), L = d ? JSON.stringify(d) : "", { data: i, isFetching: C } = k({
482
+ queryKey: ["picker-narrowing", s, r, L],
443
483
  queryFn: () => f.request(
444
- Ke("/picker-narrowing", { collection: s, search: t, filter: d ?? null })
445
- ).then((w) => w.data),
446
- enabled: m || y,
484
+ Me("/picker-narrowing", { collection: s, search: r, filter: d ?? null })
485
+ ).then((_) => _.data),
486
+ enabled: m || S,
447
487
  staleTime: 3e4,
448
488
  retry: !1
449
489
  });
450
- if (!m && !y)
451
- return /* @__PURE__ */ r(
490
+ if (!m && !S)
491
+ return /* @__PURE__ */ n(
452
492
  "button",
453
493
  {
454
494
  type: "button",
455
- onClick: (w) => {
456
- w.stopPropagation(), u(!0);
495
+ onClick: (_) => {
496
+ _.stopPropagation(), u(!0);
457
497
  },
458
498
  className: "w-full border-t border-border px-3 py-1.5 text-left text-[11px] text-muted-foreground hover:text-foreground",
459
499
  "data-picker-narrowing-ask": !0,
460
500
  children: "Missing something?"
461
501
  }
462
502
  );
463
- if (_ && !o)
464
- return /* @__PURE__ */ r("p", { className: "border-t border-border px-3 py-1.5 text-[11px] text-muted-foreground", children: "Checking what narrows this list…" });
465
- if (!o) return null;
466
- const l = [], p = t ? `match “${t}”` : "exist";
467
- return o.by_field_filter > 0 && l.push(
468
- `${o.by_field_filter.toLocaleString()} more ${p} but this field only offers ${h.length ? `records that fit ${h.join(" · ")}` : "records its filter allows"}.`
469
- ), o.by_exclusions > 0 && l.push(
470
- `${o.by_exclusions.toLocaleString()} ${o.by_exclusions === 1 ? "is" : "are"} hidden from pickers by an admin.`
471
- ), 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(
472
- t ? `Nothing else you can see matches “${t}”.` : "Nothing narrows this list — every record you can see is offered."
473
- ), /* @__PURE__ */ r(
503
+ if (C && !i)
504
+ 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…" });
505
+ if (!i) return null;
506
+ const a = [], p = r ? `match “${r}”` : "exist";
507
+ return i.by_field_filter > 0 && a.push(
508
+ `${i.by_field_filter.toLocaleString()} more ${p} but this field only offers ${h.length ? `records that fit ${h.join(" · ")}` : "records its filter allows"}.`
509
+ ), i.by_exclusions > 0 && a.push(
510
+ `${i.by_exclusions.toLocaleString()} ${i.by_exclusions === 1 ? "is" : "are"} hidden from pickers by an admin.`
511
+ ), i.scopes.length > 0 && a.push(`Your ${i.scopes.join(", ")} access narrows what you can pick here.`), i.row_filter && a.push("Your role only sees some of these records."), a.length === 0 && a.push(
512
+ r ? `Nothing else you can see matches “${r}”.` : "Nothing narrows this list — every record you can see is offered."
513
+ ), /* @__PURE__ */ n(
474
514
  "div",
475
515
  {
476
516
  className: "space-y-0.5 border-t border-border px-3 py-1.5 text-[11px] leading-4 text-muted-foreground",
477
517
  "data-picker-narrowing": !0,
478
- "data-picker-narrowing-field": o.by_field_filter,
479
- "data-picker-narrowing-excluded": o.by_exclusions,
480
- children: l.map((w) => /* @__PURE__ */ r("p", { children: w }, w))
518
+ "data-picker-narrowing-field": i.by_field_filter,
519
+ "data-picker-narrowing-excluded": i.by_exclusions,
520
+ children: a.map((_) => /* @__PURE__ */ n("p", { children: _ }, _))
481
521
  }
482
522
  );
483
523
  }
484
- function ot({
524
+ function ut({
485
525
  collection: s,
486
- id: t,
526
+ id: r,
487
527
  displayTemplate: d
488
528
  }) {
489
- const h = re(), y = Ne(), f = s === "nivaro_files" || s === "directus_files", m = (() => {
529
+ const h = se(), S = _e(), f = s === "nivaro_files" || s === "directus_files", m = (() => {
490
530
  if (!d || !d.includes(".")) return null;
491
- const o = [...d.matchAll(/\{\{([^}]+)\}\}/g)].map((_) => _[1].trim());
492
- return o.length > 0 ? ["id", ...o].join(",") : null;
493
- })(), { data: u, isLoading: $ } = k({
494
- queryKey: ["relation-single", s, String(t), m ?? ""],
495
- queryFn: () => f ? h.request(F(`/files/${t}`)).then((o) => o.data) : y(s, t, m),
496
- enabled: !!t && !!s,
531
+ const i = [...d.matchAll(/\{\{([^}]+)\}\}/g)].map((C) => C[1].trim());
532
+ return i.length > 0 ? ["id", ...i].join(",") : null;
533
+ })(), { data: u, isLoading: L } = k({
534
+ queryKey: ["relation-single", s, String(r), m ?? ""],
535
+ queryFn: () => f ? h.request($(`/files/${r}`)).then((i) => i.data) : S(s, r, m),
536
+ enabled: !!r && !!s,
497
537
  staleTime: 6e4
498
538
  });
499
- if ($) return /* @__PURE__ */ r(te, { className: "h-3 w-3 animate-spin text-slate-400" });
500
- if (!u) return /* @__PURE__ */ r("span", { children: String(t ?? "") });
539
+ if (L) return /* @__PURE__ */ n(ne, { className: "h-3 w-3 animate-spin text-slate-400" });
540
+ if (!u) return /* @__PURE__ */ n("span", { children: String(r ?? "") });
501
541
  if (f) {
502
- const o = u.title || u.filename_download || u.filename_disk || String(t);
503
- return /* @__PURE__ */ r("span", { children: o });
542
+ const i = u.title || u.filename_download || u.filename_disk || String(r);
543
+ return /* @__PURE__ */ n("span", { children: i });
504
544
  }
505
- return /* @__PURE__ */ r("span", { children: N(d, u) });
545
+ return /* @__PURE__ */ n("span", { children: v(d, u) });
506
546
  }
507
547
  export {
508
- ot as RelatedItemLabel,
509
- Me as RelationCombobox,
510
- Je as useStaleTip
548
+ ut as RelatedItemLabel,
549
+ Xe as RelationCombobox,
550
+ We as useStaleTip
511
551
  };