@nivaro/react 0.3.118 → 0.3.120

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.
@@ -32,11 +32,11 @@ function F(e, a, s) {
32
32
  };
33
33
  }, [e]);
34
34
  }
35
- function be(e) {
35
+ function ge(e) {
36
36
  const a = String(e ?? "").trim();
37
37
  return !a || /^redacted\b/i.test(a) ? "" : a.split(/\s+/).map((s) => s[0]).filter(Boolean).slice(0, 2).join("").toUpperCase();
38
38
  }
39
- function ge(e, a) {
39
+ function be(e, a) {
40
40
  const s = String(e ?? "").trim();
41
41
  return s || [a == null ? void 0 : a.first_name, a == null ? void 0 : a.last_name].filter(Boolean).join(" ").trim();
42
42
  }
@@ -49,7 +49,7 @@ function ue({
49
49
  enabled: !!s && !!e.id && !String(e.name ?? "").trim(),
50
50
  staleTime: 30 * 6e4,
51
51
  retry: !1
52
- }), d = ge(e.name, i), c = be(d), m = /^redacted\b/i.test(d);
52
+ }), d = be(e.name, i), c = ge(d), m = /^redacted\b/i.test(d);
53
53
  return /* @__PURE__ */ t(
54
54
  "span",
55
55
  {
@@ -77,15 +77,15 @@ function ve({
77
77
  nameLabel: s = !1,
78
78
  standIn: i = null
79
79
  }) {
80
- const d = S(null), c = S(null), m = S(null), [r, p] = j(null), [h, b] = j({ x: 0, y: 0 }), g = () => {
80
+ const d = S(null), c = S(null), m = S(null), [r, p] = j(null), [h, g] = j({ x: 0, y: 0 }), b = () => {
81
81
  m.current && clearTimeout(m.current), m.current = null;
82
82
  }, o = (n) => {
83
83
  var u;
84
- g();
84
+ b();
85
85
  const f = (u = d.current) == null ? void 0 : u.getBoundingClientRect();
86
- f && b({ x: f.left, y: f.bottom + 6 }), p((y) => y === "pin" ? "pin" : n);
86
+ f && g({ x: f.left, y: f.bottom + 6 }), p((y) => y === "pin" ? "pin" : n);
87
87
  }, w = () => {
88
- g(), m.current = setTimeout(() => p((n) => n === "pin" ? n : null), 160);
88
+ b(), m.current = setTimeout(() => p((n) => n === "pin" ? n : null), 160);
89
89
  };
90
90
  if (q.useLayoutEffect(() => {
91
91
  var U;
@@ -98,7 +98,7 @@ function ve({
98
98
  const O = (U = d.current) == null ? void 0 : U.getBoundingClientRect();
99
99
  y = Math.max(8, ((O == null ? void 0 : O.top) ?? y) - f.height - 6);
100
100
  }
101
- (u !== h.x || y !== h.y) && b({ x: u, y });
101
+ (u !== h.x || y !== h.y) && g({ x: u, y });
102
102
  }, [r, h]), F(
103
103
  !!r,
104
104
  (n) => {
@@ -156,7 +156,7 @@ function ve({
156
156
  {
157
157
  ref: c,
158
158
  style: ke(d.current, h),
159
- onMouseEnter: g,
159
+ onMouseEnter: b,
160
160
  onMouseLeave: w,
161
161
  onMouseDown: (n) => {
162
162
  n.stopPropagation(), p("pin");
@@ -214,31 +214,31 @@ function He({
214
214
  collection: e,
215
215
  itemId: a
216
216
  }) {
217
- var b;
217
+ var g;
218
218
  const s = T(), {
219
219
  data: i = [],
220
220
  isLoading: d,
221
221
  isFetching: c
222
222
  } = _({
223
223
  queryKey: ["pipeline-owners-resolved", e, a],
224
- queryFn: () => s.request(ee(`/pipelines/instance/${e}/owners/batch`, { ids: [a] })).then((g) => {
224
+ queryFn: () => s.request(ee(`/pipelines/instance/${e}/owners/batch`, { ids: [a] })).then((b) => {
225
225
  var o;
226
- return ((o = g.data) == null ? void 0 : o[a]) ?? [];
226
+ return ((o = b.data) == null ? void 0 : o[a]) ?? [];
227
227
  }),
228
228
  enabled: !!s && !!e && !!a && a !== "new",
229
229
  staleTime: 3e4,
230
230
  // Keep this RECORD's last answer while a move re-asks (the tile used to go
231
231
  // blank for ~2 s after Submit) — never another record's (b01-N15).
232
- placeholderData: (g, o) => (o == null ? void 0 : o.queryKey[1]) === e && String(o == null ? void 0 : o.queryKey[2]) === String(a) ? g : void 0
232
+ placeholderData: (b, o) => (o == null ? void 0 : o.queryKey[1]) === e && String(o == null ? void 0 : o.queryKey[2]) === String(a) ? b : void 0
233
233
  }), { data: m } = _({
234
234
  queryKey: ["pipeline-instance", e, a],
235
- queryFn: () => s.request(L(`/pipelines/instance/${e}/${a}`)).then((g) => g.data ?? null),
235
+ queryFn: () => s.request(L(`/pipelines/instance/${e}/${a}`)).then((b) => b.data ?? null),
236
236
  enabled: !!s && !!e && !!a && a !== "new",
237
237
  staleTime: 1e4
238
238
  });
239
239
  if (d || c && i.length === 0)
240
240
  return /* @__PURE__ */ t("span", { className: "animate-pulse h-3 w-20 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))] inline-block" });
241
- const r = (m == null ? void 0 : m.stand_in_reason) ?? null, p = (b = m == null ? void 0 : m.instance) == null ? void 0 : b.current_state, h = r && (!p || String(p).toUpperCase() === r.state.id.toUpperCase()) ? r : null;
241
+ const r = (m == null ? void 0 : m.stand_in_reason) ?? null, p = (g = m == null ? void 0 : m.instance) == null ? void 0 : g.current_state, h = r && (!p || String(p).toUpperCase() === r.state.id.toUpperCase()) ? r : null;
242
242
  return /* @__PURE__ */ t(ve, { users: i, nameLabel: !0, standIn: h });
243
243
  }
244
244
  function Je({
@@ -286,7 +286,7 @@ function ye({
286
286
  open: p = !1
287
287
  }) {
288
288
  var C;
289
- const { isAdmin: h, userId: b } = Q(), g = !!b && b.toUpperCase() === a.toUpperCase(), o = pe(a, p), w = re().roomOf(a), v = ((C = e == null ? void 0 : e.manager_name) == null ? void 0 : C.trim()) || null, N = (() => {
289
+ const { isAdmin: h, userId: g } = Q(), b = !!g && g.toUpperCase() === a.toUpperCase(), o = pe(a, p), w = re().roomOf(a), v = ((C = e == null ? void 0 : e.manager_name) == null ? void 0 : C.trim()) || null, N = (() => {
290
290
  const n = e == null ? void 0 : e.timezone;
291
291
  if (!n) return null;
292
292
  try {
@@ -468,7 +468,7 @@ function ye({
468
468
  }
469
469
  )
470
470
  ] }),
471
- h && !g && /* @__PURE__ */ t(
471
+ h && !b && /* @__PURE__ */ t(
472
472
  Ne,
473
473
  {
474
474
  userId: a,
@@ -488,10 +488,10 @@ function Ne({
488
488
  const [i, d] = j(!1), [c, m] = j("");
489
489
  E(() => {
490
490
  if (!i || c.trim()) return;
491
- const g = setTimeout(() => d(!1), de);
492
- return () => clearTimeout(g);
491
+ const b = setTimeout(() => d(!1), de);
492
+ return () => clearTimeout(b);
493
493
  }, [i, c]);
494
- const r = ce(e, { onDone: s }), p = me(e, a, { onDone: s }), h = () => p.mutate({ message: c }), b = "flex flex-1 items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-[11px] font-medium transition-colors disabled:opacity-50";
494
+ const r = ce(e, { onDone: s }), p = me(e, a, { onDone: s }), h = () => p.mutate({ message: c }), g = "flex flex-1 items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-[11px] font-medium transition-colors disabled:opacity-50";
495
495
  return /* @__PURE__ */ l("div", { className: "border-t border-slate-100 p-2 dark:border-border", "data-user-card-admin": !0, children: [
496
496
  /* @__PURE__ */ l("div", { className: "flex items-center gap-1", children: [
497
497
  /* @__PURE__ */ l(
@@ -502,7 +502,7 @@ function Ne({
502
502
  onClick: () => r.mutate({}),
503
503
  "data-tip": "Every tab they have open shows a 15-second countdown, then reloads",
504
504
  className: P(
505
- b,
505
+ g,
506
506
  "text-amber-800 hover:bg-amber-50 dark:text-amber-300 dark:hover:bg-amber-500/10"
507
507
  ),
508
508
  "data-user-card-reload": !0,
@@ -520,7 +520,7 @@ function Ne({
520
520
  onClick: () => i ? h() : d(!0),
521
521
  "data-tip": i ? "Click again to sign them out of every session" : "Ends every session they have, on every app — they can sign in again",
522
522
  className: P(
523
- b,
523
+ g,
524
524
  i ? "bg-red-600 text-white hover:bg-red-700" : "text-amber-800 hover:bg-amber-50 dark:text-amber-300 dark:hover:bg-amber-500/10"
525
525
  ),
526
526
  "data-user-card-sign-out": i ? "armed" : "",
@@ -557,7 +557,7 @@ function Ce({
557
557
  },
558
558
  () => p(!1)
559
559
  );
560
- const { data: b, isLoading: g } = _({
560
+ const { data: g, isLoading: b } = _({
561
561
  ...D(i, e),
562
562
  enabled: !!i && !!e,
563
563
  staleTime: 12e4
@@ -567,30 +567,35 @@ function Ce({
567
567
  enabled: !!i && !!e && r,
568
568
  staleTime: 15e3,
569
569
  refetchInterval: r ? 2e4 : !1
570
- }), w = b ? [b.first_name, b.last_name].filter(Boolean).join(" ") || b.email : e, v = w.split(" ").map((x) => x[0]).filter(Boolean).slice(0, 2).join("").toUpperCase(), N = (o == null ? void 0 : o.online) ?? !1;
571
- return g && !s ? a === "compact" ? /* @__PURE__ */ t("span", { className: "animate-pulse inline-block h-3.5 w-16 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))]" }) : /* @__PURE__ */ l("span", { className: "inline-flex items-center gap-1.5 rounded-full border border-slate-200 bg-slate-50 py-0.5 pl-0.5 pr-2.5", children: [
570
+ }), w = g ? [g.first_name, g.last_name].filter(Boolean).join(" ") || g.email : e, v = w.split(" ").map((x) => x[0]).filter(Boolean).slice(0, 2).join("").toUpperCase(), N = (o == null ? void 0 : o.online) ?? !1;
571
+ return b && !s ? a === "compact" ? /* @__PURE__ */ t("span", { className: "animate-pulse inline-block h-3.5 w-16 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))]" }) : /* @__PURE__ */ l("span", { className: "inline-flex items-center gap-1.5 rounded-full border border-slate-200 bg-slate-50 py-0.5 pl-0.5 pr-2.5", children: [
572
572
  /* @__PURE__ */ t("span", { className: "flex h-6 w-6 shrink-0 rounded-full animate-pulse bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))]" }),
573
573
  /* @__PURE__ */ t("span", { className: "animate-pulse h-2.5 w-16 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))] inline-block" })
574
574
  ] }) : /* @__PURE__ */ l(fe, { open: r, onOpenChange: p, children: [
575
- /* @__PURE__ */ t(xe, { asChild: !0, "data-nvr-user-chip": h, children: s || (a === "compact" ? /* @__PURE__ */ l("span", { className: "inline-flex cursor-pointer items-center gap-1 rounded-full bg-slate-100 dark:bg-slate-800 py-px pl-px pr-1.5 hover:bg-slate-200 dark:hover:bg-slate-700 transition-colors", children: [
576
- /* @__PURE__ */ t(
577
- M,
578
- {
579
- userId: e,
580
- className: "h-4 w-4",
581
- fallback: /* @__PURE__ */ t(
582
- "span",
583
- {
584
- "data-copy-skip": !0,
585
- "aria-hidden": "true",
586
- className: "flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-nvr-cyan/20 text-[9px] font-bold text-nvr-navy dark:text-nvr-cyan",
587
- children: v
588
- }
589
- )
590
- }
591
- ),
592
- /* @__PURE__ */ t("span", { className: "text-[11px] font-medium text-slate-600 dark:text-slate-300", children: w })
593
- ] }) : /* @__PURE__ */ l("div", { className: "inline-flex cursor-pointer items-center gap-1.5 rounded-full border border-slate-200 bg-slate-50 py-0.5 pl-0.5 pr-2.5 hover:bg-slate-100 dark:border-border dark:bg-card dark:hover:bg-accent transition-colors", children: [
575
+ /* @__PURE__ */ t(xe, { asChild: !0, "data-nvr-user-chip": h, children: s || (a === "compact" ? (
576
+ // align-middle: a photo has no text baseline, so an inline-flex chip whose first item
577
+ // is an <img> sat on the photo's bottom edge — raised, and the row grew a few px
578
+ // (list cells with a photo were taller than ones with initials).
579
+ /* @__PURE__ */ l("span", { className: "inline-flex cursor-pointer items-center gap-1 rounded-full bg-slate-100 py-px pl-px pr-1.5 align-middle transition-colors hover:bg-slate-200 dark:bg-slate-800 dark:hover:bg-slate-700", children: [
580
+ /* @__PURE__ */ t(
581
+ M,
582
+ {
583
+ userId: e,
584
+ className: "h-4 w-4",
585
+ fallback: /* @__PURE__ */ t(
586
+ "span",
587
+ {
588
+ "data-copy-skip": !0,
589
+ "aria-hidden": "true",
590
+ className: "flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-nvr-cyan/20 text-[9px] font-bold text-nvr-navy dark:text-nvr-cyan",
591
+ children: v
592
+ }
593
+ )
594
+ }
595
+ ),
596
+ /* @__PURE__ */ t("span", { className: "text-[11px] font-medium text-slate-600 dark:text-slate-300", children: w })
597
+ ] })
598
+ ) : /* @__PURE__ */ l("div", { className: "inline-flex cursor-pointer items-center gap-1.5 rounded-full border border-slate-200 bg-slate-50 py-0.5 pl-0.5 pr-2.5 align-middle transition-colors hover:bg-slate-100 dark:border-border dark:bg-card dark:hover:bg-accent", children: [
594
599
  /* @__PURE__ */ t(
595
600
  M,
596
601
  {
@@ -612,7 +617,7 @@ function Ce({
612
617
  /* @__PURE__ */ t(
613
618
  ye,
614
619
  {
615
- user: b,
620
+ user: g,
616
621
  userId: e,
617
622
  initials: v,
618
623
  navigate: d,
@@ -631,7 +636,7 @@ export {
631
636
  Ne as UserCardAdminRow,
632
637
  Ce as UserChip,
633
638
  ve as UserRosterCluster,
634
- be as rosterInitials,
639
+ ge as rosterInitials,
635
640
  we as rosterLabel,
636
- ge as rosterName
641
+ be as rosterName
637
642
  };
@@ -0,0 +1,6 @@
1
+ function o(n, r, e) {
2
+ return !e || !n || n === "original" ? !1 : !r.some((i) => String(i.id) === n);
3
+ }
4
+ export {
5
+ o as addendumViewGone
6
+ };
@@ -1,29 +1,29 @@
1
1
  import { jsxs as c, jsx as l } from "react/jsx-runtime";
2
- import { ChevronRight as M, X as F, Search as R, Loader2 as k } from "lucide-react";
2
+ import { ChevronRight as M, X as k, Search as F, Loader2 as R } from "lucide-react";
3
3
  import { useState as E, useRef as O, useLayoutEffect as z, useEffect as H } from "react";
4
4
  import { createPortal as $ } from "react-dom";
5
5
  import { titleCase as _ } from "../../../lib/utils.js";
6
- import { Popover as B, PopoverTrigger as T, PopoverContent as q } from "../../ui/popover.js";
7
- import { useCollectionBody as Q } from "../collection-meta.js";
6
+ import { Popover as B, PopoverTrigger as T, PopoverContent as W } from "../../ui/popover.js";
7
+ import { useCollectionBody as q } from "../collection-meta.js";
8
8
  function V({
9
9
  collection: n,
10
- fields: d,
10
+ fields: f,
11
11
  relations: u,
12
- value: a,
12
+ value: r,
13
13
  valueLabel: h,
14
- onChange: r,
15
- onClear: f,
16
- placeholder: i,
17
- walk: w
14
+ onChange: a,
15
+ onClear: p,
16
+ placeholder: s,
17
+ walk: v
18
18
  }) {
19
- const [o, s] = E(!1), [m, p] = E(""), x = O(null), y = O(null), [b, L] = E(null);
19
+ const [o, i] = E(!1), [x, m] = E(""), y = O(null), b = O(null), [g, L] = E(null);
20
20
  z(() => {
21
21
  if (!o) return;
22
22
  const t = () => {
23
23
  var N;
24
- const e = (N = x.current) == null ? void 0 : N.getBoundingClientRect();
25
- if (!e) return;
26
- const C = Math.min(e.left, window.innerWidth - 288 - 8), j = Math.min(e.bottom + 4, window.innerHeight - 60);
24
+ const d = (N = y.current) == null ? void 0 : N.getBoundingClientRect();
25
+ if (!d) return;
26
+ const C = Math.min(d.left, window.innerWidth - 288 - 8), j = Math.min(d.bottom + 4, window.innerHeight - 60);
27
27
  L({ top: j, left: Math.max(8, C) });
28
28
  };
29
29
  return t(), window.addEventListener("scroll", t, !0), window.addEventListener("resize", t), () => {
@@ -31,67 +31,70 @@ function V({
31
31
  };
32
32
  }, [o]), H(() => {
33
33
  if (!o) return;
34
- const t = (e) => {
34
+ const t = (d) => {
35
35
  var C, j, N;
36
- const v = e.target;
37
- (C = x.current) != null && C.contains(v) || (j = y.current) != null && j.contains(v) || (N = v.closest) != null && N.call(v, "[data-radix-popper-content-wrapper]") || s(!1);
36
+ const e = d.target;
37
+ (C = y.current) != null && C.contains(e) || (j = b.current) != null && j.contains(e) || (N = e.closest) != null && N.call(e, "[data-radix-popper-content-wrapper]") || i(!1);
38
38
  };
39
39
  return document.addEventListener("mousedown", t), () => document.removeEventListener("mousedown", t);
40
40
  }, [o]);
41
- const g = [...d].sort((t, e) => t.field.localeCompare(e.field)).filter((t) => t.field.toLowerCase().includes(m.trim().toLowerCase()));
41
+ const w = [...f].sort((t, d) => t.field.localeCompare(d.field)).filter((t) => t.field.toLowerCase().includes(x.trim().toLowerCase()));
42
42
  return /* @__PURE__ */ c("div", { className: "relative", children: [
43
43
  /* @__PURE__ */ c(
44
44
  "button",
45
45
  {
46
46
  type: "button",
47
- ref: x,
48
- onClick: () => s((t) => !t),
49
- className: `flex h-8 w-full items-center justify-between gap-1.5 rounded-md border border-slate-200 bg-white text-[13px] text-slate-700 hover:border-slate-300 ${a && f ? "pl-2.5 pr-8" : "px-2.5"}`,
47
+ ref: y,
48
+ onClick: () => i((t) => !t),
49
+ className: `flex h-8 w-full items-center justify-between gap-1.5 rounded-md border border-slate-200 bg-white text-[13px] text-slate-700 hover:border-slate-300 ${r && p ? "pl-2.5 pr-8" : "px-2.5"}`,
50
50
  children: [
51
51
  /* @__PURE__ */ l(
52
52
  "span",
53
53
  {
54
- className: a ? "font-mono text-[12px] flex-1 text-left truncate" : "text-slate-400 flex-1 text-left truncate whitespace-nowrap",
55
- children: h || a || i || "Select field…"
54
+ className: (
55
+ // A readable label (valueLabel) reads like the rest of the UI; only a raw path is mono.
56
+ r && h ? "text-[12.5px] flex-1 text-left truncate" : r ? "font-mono text-[12px] flex-1 text-left truncate" : "text-slate-400 flex-1 text-left truncate whitespace-nowrap"
57
+ ),
58
+ children: h || r || s || "Select field…"
56
59
  }
57
60
  ),
58
61
  /* @__PURE__ */ l(M, { className: "h-3.5 w-3.5 text-slate-400 shrink-0" })
59
62
  ]
60
63
  }
61
64
  ),
62
- a && f && /* @__PURE__ */ l(
65
+ r && p && /* @__PURE__ */ l(
63
66
  "button",
64
67
  {
65
68
  type: "button",
66
69
  onClick: (t) => {
67
- t.stopPropagation(), f();
70
+ t.stopPropagation(), p();
68
71
  },
69
72
  className: "absolute right-2 top-1/2 -translate-y-1/2 flex h-5 w-5 items-center justify-center rounded text-slate-400 hover:bg-slate-100 hover:text-slate-600 dark:hover:bg-muted dark:hover:text-slate-300",
70
- children: /* @__PURE__ */ l(F, { className: "h-3 w-3" })
73
+ children: /* @__PURE__ */ l(k, { className: "h-3 w-3" })
71
74
  }
72
75
  ),
73
- o && b && $(
76
+ o && g && $(
74
77
  /* @__PURE__ */ l(
75
78
  "div",
76
79
  {
77
- ref: y,
78
- style: { position: "fixed", top: b.top, left: b.left },
80
+ ref: b,
81
+ style: { position: "fixed", top: g.top, left: g.left },
79
82
  className: "z-50 w-72 rounded-xl border border-slate-200 bg-white shadow-lg dark:border-border dark:bg-card",
80
83
  children: /* @__PURE__ */ c("div", { className: "p-2", children: [
81
84
  /* @__PURE__ */ c("div", { className: "relative mb-1.5", children: [
82
- /* @__PURE__ */ l(R, { className: "absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400" }),
85
+ /* @__PURE__ */ l(F, { className: "absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400" }),
83
86
  /* @__PURE__ */ l(
84
87
  "input",
85
88
  {
86
- value: m,
87
- onChange: (t) => p(t.target.value),
89
+ value: x,
90
+ onChange: (t) => m(t.target.value),
88
91
  placeholder: "Search fields…",
89
92
  className: "h-8 w-full rounded-md border border-slate-200 bg-slate-50 pl-8 pr-3 text-[13px] placeholder-slate-400 focus:border-nvr-cyan/50 focus:outline-none focus:ring-2 focus:ring-nvr-cyan/30"
90
93
  }
91
94
  )
92
95
  ] }),
93
96
  /* @__PURE__ */ c("div", { className: "max-h-72 overflow-y-auto", children: [
94
- g.map((t) => /* @__PURE__ */ l(
97
+ w.map((t) => /* @__PURE__ */ l(
95
98
  P,
96
99
  {
97
100
  field: t,
@@ -100,14 +103,14 @@ function V({
100
103
  pathPrefix: [],
101
104
  labelPrefix: [],
102
105
  depth: 0,
103
- walk: w,
104
- onSelect: (e) => {
105
- r(e), s(!1);
106
+ walk: v,
107
+ onSelect: (d) => {
108
+ a(d), i(!1);
106
109
  }
107
110
  },
108
111
  t.field
109
112
  )),
110
- g.length === 0 && /* @__PURE__ */ l("div", { className: "px-2 py-3 text-center text-[12px] text-slate-400", children: "No fields" })
113
+ w.length === 0 && /* @__PURE__ */ l("div", { className: "px-2 py-3 text-center text-[12px] text-slate-400", children: "No fields" })
111
114
  ] })
112
115
  ] })
113
116
  }
@@ -116,70 +119,70 @@ function V({
116
119
  )
117
120
  ] });
118
121
  }
119
- function W({
122
+ function Q({
120
123
  relatedCollection: n,
121
- pathPrefix: d,
124
+ pathPrefix: f,
122
125
  labelPrefix: u,
123
- onSelect: a,
126
+ onSelect: r,
124
127
  walk: h
125
128
  }) {
126
- const { data: r, isLoading: f } = Q(n);
127
- if (f)
129
+ const { data: a, isLoading: p } = q(n);
130
+ if (p)
128
131
  return /* @__PURE__ */ c("div", { className: "py-2 text-[12px] text-slate-400 flex items-center gap-2 px-2", children: [
129
- /* @__PURE__ */ l(k, { className: "h-3.5 w-3.5 animate-spin" }),
132
+ /* @__PURE__ */ l(R, { className: "h-3.5 w-3.5 animate-spin" }),
130
133
  "Loading…"
131
134
  ] });
132
- const i = [...((r == null ? void 0 : r.fields) ?? []).filter((o) => !o.hidden)].sort(
133
- (o, s) => o.field.localeCompare(s.field)
134
- ), w = (r == null ? void 0 : r.relations) ?? [];
135
+ const s = [...((a == null ? void 0 : a.fields) ?? []).filter((o) => !o.hidden)].sort(
136
+ (o, i) => o.field.localeCompare(i.field)
137
+ ), v = (a == null ? void 0 : a.relations) ?? [];
135
138
  return /* @__PURE__ */ c("div", { className: "max-h-64 overflow-y-auto", children: [
136
- i.map((o) => /* @__PURE__ */ l(
139
+ s.map((o) => /* @__PURE__ */ l(
137
140
  P,
138
141
  {
139
142
  field: o,
140
143
  collection: n,
141
- relations: w,
142
- pathPrefix: d,
144
+ relations: v,
145
+ pathPrefix: f,
143
146
  labelPrefix: u,
144
147
  depth: 0,
145
148
  walk: h,
146
- onSelect: a
149
+ onSelect: r
147
150
  },
148
151
  o.field
149
152
  )),
150
- i.length === 0 && /* @__PURE__ */ l("div", { className: "px-2 py-1.5 text-[12px] text-slate-400", children: "No fields" })
153
+ s.length === 0 && /* @__PURE__ */ l("div", { className: "px-2 py-1.5 text-[12px] text-slate-400", children: "No fields" })
151
154
  ] });
152
155
  }
153
156
  function P({
154
157
  field: n,
155
- collection: d,
158
+ collection: f,
156
159
  relations: u,
157
- pathPrefix: a,
160
+ pathPrefix: r,
158
161
  labelPrefix: h,
159
- depth: r,
160
- onSelect: f,
161
- walk: i
162
+ depth: a,
163
+ onSelect: p,
164
+ walk: s
162
165
  }) {
163
- const [w, o] = E(!1), s = u.find(
164
- (e) => e.many_collection === d && e.many_field === n.field && e.junction_field === null && e.one_collection
165
- ) ?? null, m = s ? null : u.find(
166
- (e) => e.many_collection === d && e.many_field === n.field && e.junction_field !== null && e.one_collection
167
- ) ?? null, p = !s && !m ? u.find(
168
- (e) => e.one_collection === d && e.one_field === n.field && e.junction_field !== null && e.many_collection
169
- ) ?? null : null, x = m ?? p, y = !s && !x ? u.find(
170
- (e) => e.one_collection === d && e.one_field === n.field && e.junction_field === null && e.many_collection
171
- ) ?? null : null, b = p ? u.find(
172
- (e) => e.many_collection === p.many_collection && e.many_field === p.junction_field && e.one_collection
173
- ) ?? null : null, L = (s == null ? void 0 : s.one_collection) ?? (m == null ? void 0 : m.one_collection) ?? (b == null ? void 0 : b.one_collection) ?? (p == null ? void 0 : p.many_collection) ?? (y == null ? void 0 : y.many_collection) ?? null;
174
- if (i != null && i.m2oOnly && L && !s) return null;
175
- const g = (i == null ? void 0 : i.maxHops) != null && a.length >= i.maxHops ? null : L, t = s ? "M2O" : x ? "M2M" : y ? "O2M" : null;
176
- return g ? /* @__PURE__ */ c(B, { open: w, onOpenChange: o, children: [
166
+ const [v, o] = E(!1), i = u.find(
167
+ (e) => e.many_collection === f && e.many_field === n.field && e.junction_field === null && e.one_collection
168
+ ) ?? null, x = i ? null : u.find(
169
+ (e) => e.many_collection === f && e.many_field === n.field && e.junction_field !== null && e.one_collection
170
+ ) ?? null, m = !i && !x ? u.find(
171
+ (e) => e.one_collection === f && e.one_field === n.field && e.junction_field !== null && e.many_collection
172
+ ) ?? null : null, y = x ?? m, b = !i && !y ? u.find(
173
+ (e) => e.one_collection === f && e.one_field === n.field && e.junction_field === null && e.many_collection
174
+ ) ?? null : null, g = m ? u.find(
175
+ (e) => e.many_collection === m.many_collection && e.many_field === m.junction_field && e.one_collection
176
+ ) ?? null : null, L = (i == null ? void 0 : i.one_collection) ?? (x == null ? void 0 : x.one_collection) ?? (g == null ? void 0 : g.one_collection) ?? (m == null ? void 0 : m.many_collection) ?? (b == null ? void 0 : b.many_collection) ?? null;
177
+ if (s != null && s.m2oOnly && L && !i) return null;
178
+ const w = (s == null ? void 0 : s.maxHops) != null && r.length >= s.maxHops ? null : L, t = i ? "M2O" : y ? "M2M" : b ? "O2M" : null, d = typeof window < "u" && window.innerWidth < 640;
179
+ return w ? /* @__PURE__ */ c(B, { open: v, onOpenChange: o, children: [
177
180
  /* @__PURE__ */ l(T, { asChild: !0, children: /* @__PURE__ */ c(
178
181
  "button",
179
182
  {
180
183
  type: "button",
181
- className: "flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[13px] text-slate-700 hover:bg-slate-50 data-[state=open]:bg-slate-100",
182
- style: { paddingLeft: `${0.5 + r * 1}rem` },
184
+ className: "flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[13px] text-slate-700 hover:bg-slate-50 data-[state=open]:bg-slate-100 dark:data-[state=open]:bg-muted",
185
+ style: { paddingLeft: `${0.5 + a * 1}rem` },
183
186
  children: [
184
187
  /* @__PURE__ */ l("span", { className: "flex-1", children: _(n.field) }),
185
188
  t && /* @__PURE__ */ l("span", { className: "rounded px-1 py-0.5 text-[10px] font-medium bg-slate-100 text-slate-500", children: t }),
@@ -187,48 +190,58 @@ function P({
187
190
  ]
188
191
  }
189
192
  ) }),
190
- /* @__PURE__ */ c(q, { side: "right", align: "start", sideOffset: 4, className: "w-56 p-1", children: [
191
- (s || x) && /* @__PURE__ */ l(
192
- "button",
193
- {
194
- type: "button",
195
- onClick: () => {
196
- f({
197
- path: [...a, n.field],
198
- pathLabels: [...h, _(n.field)],
199
- fieldType: n.type,
200
- relatedCollection: g ?? void 0
201
- }), o(!1);
202
- },
203
- className: "w-full rounded-md px-2 py-1 text-left text-[12px] text-slate-500 hover:bg-slate-50 italic",
204
- children: "(select this field)"
205
- }
206
- ),
207
- /* @__PURE__ */ l(
208
- W,
209
- {
210
- relatedCollection: g,
211
- pathPrefix: [...a, n.field],
212
- labelPrefix: [...h, _(n.field)],
213
- walk: i,
214
- onSelect: (e) => {
215
- f(e), o(!1);
216
- }
217
- }
218
- )
219
- ] })
193
+ /* @__PURE__ */ c(
194
+ W,
195
+ {
196
+ side: d ? "bottom" : "right",
197
+ align: d ? "end" : "start",
198
+ sideOffset: 4,
199
+ collisionPadding: 8,
200
+ className: "w-56 p-1",
201
+ children: [
202
+ (i || y) && /* @__PURE__ */ l(
203
+ "button",
204
+ {
205
+ type: "button",
206
+ onClick: () => {
207
+ p({
208
+ path: [...r, n.field],
209
+ pathLabels: [...h, _(n.field)],
210
+ fieldType: n.type,
211
+ relatedCollection: w ?? void 0
212
+ }), o(!1);
213
+ },
214
+ className: "w-full rounded-md px-2 py-1 text-left text-[12px] text-slate-500 hover:bg-slate-50 italic",
215
+ children: "(select this field)"
216
+ }
217
+ ),
218
+ /* @__PURE__ */ l(
219
+ Q,
220
+ {
221
+ relatedCollection: w,
222
+ pathPrefix: [...r, n.field],
223
+ labelPrefix: [...h, _(n.field)],
224
+ walk: s,
225
+ onSelect: (e) => {
226
+ p(e), o(!1);
227
+ }
228
+ }
229
+ )
230
+ ]
231
+ }
232
+ )
220
233
  ] }) : /* @__PURE__ */ l(
221
234
  "button",
222
235
  {
223
236
  type: "button",
224
- onClick: () => f({
225
- path: [...a, n.field],
237
+ onClick: () => p({
238
+ path: [...r, n.field],
226
239
  pathLabels: [...h, _(n.field)],
227
240
  fieldType: n.type,
228
- relatedCollection: r > 0 ? d : void 0
241
+ relatedCollection: a > 0 ? f : void 0
229
242
  }),
230
243
  className: "w-full rounded-md px-2 py-1.5 text-left text-[13px] text-slate-700 hover:bg-slate-50",
231
- style: { paddingLeft: `${0.5 + r * 1}rem` },
244
+ style: { paddingLeft: `${0.5 + a * 1}rem` },
232
245
  children: _(n.field)
233
246
  }
234
247
  );