@nivaro/react 0.3.16 → 0.3.18

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