@nivaro/react 0.3.58 → 0.3.59

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 (43) hide show
  1. package/dist/components/fields/RelationField.js +110 -80
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useRelationOptions.js +1 -0
  4. package/dist/hooks/useSessionRecorder.js +1 -1
  5. package/dist/index.d.ts +32 -1
  6. package/dist/index.js +523 -520
  7. package/dist/shared/components/CollectionBrowserView.js +2083 -2052
  8. package/dist/shared/components/DataTable.js +497 -465
  9. package/dist/shared/components/ItemEditForm.js +4430 -4282
  10. package/dist/shared/components/PageRenderer.js +537 -508
  11. package/dist/shared/components/QueryTable.js +74 -74
  12. package/dist/shared/components/WidgetSlot.js +543 -520
  13. package/dist/shared/components/alerts/AlertManagerView.js +269 -275
  14. package/dist/shared/components/alerts/types.js +37 -14
  15. package/dist/shared/components/item-edit/FieldRenderer.js +22 -20
  16. package/dist/shared/components/item-edit/GridBulkEditDialog.js +55 -54
  17. package/dist/shared/components/item-edit/InlineTableField.js +2461 -2421
  18. package/dist/shared/components/item-edit/M2MCombobox.js +141 -137
  19. package/dist/shared/components/item-edit/PlanGrid.js +876 -820
  20. package/dist/shared/components/item-edit/QuickCreateButton.js +323 -130
  21. package/dist/shared/components/item-edit/RelationCombobox.js +408 -375
  22. package/dist/shared/components/item-edit/RelationGroupedCombobox.js +255 -156
  23. package/dist/shared/components/item-edit/SummaryPanel.js +356 -343
  24. package/dist/shared/components/item-edit/duplicate-rehearsal.js +47 -0
  25. package/dist/shared/components/item-edit/line-midair.js +82 -75
  26. package/dist/shared/components/item-edit/save-outcome.js +6 -4
  27. package/dist/shared/components/panels/ItemLockBanner.js +212 -209
  28. package/dist/shared/components/panels/PipelinePanel.js +775 -737
  29. package/dist/shared/components/panels/RecordIntegrityBanner.js +114 -86
  30. package/dist/shared/components/panels/RevisionsPanel.js +313 -299
  31. package/dist/shared/components/pipeline/PipelineEditorView.js +26 -16
  32. package/dist/shared/components/queue/QueueQuickFilters.js +13 -13
  33. package/dist/shared/components/queue/QueueWorklist.js +978 -953
  34. package/dist/shared/components/queue/live-state-aspect.js +9 -5
  35. package/dist/shared/components/widgets/ReviewListWidget.js +152 -149
  36. package/dist/shared/lib/display-prefs.js +60 -52
  37. package/dist/shared/lib/draft-store.js +71 -48
  38. package/dist/shared/lib/expression.js +53 -53
  39. package/dist/shared/lib/list-page-memory.js +42 -20
  40. package/dist/shared/lib/money-input.js +45 -0
  41. package/dist/shared/lib/sanitize-html.js +10 -6
  42. package/dist/shared/lib/staged-row-labels.js +18 -0
  43. package/package.json +1 -1
@@ -1,279 +1,378 @@
1
- import { jsxs as d, jsx as s } from "react/jsx-runtime";
2
- import { useQuery as g } from "@tanstack/react-query";
3
- import { Loader2 as F, AlertTriangle as ue, ChevronDown as ee, Search as fe, X as pe, Check as te, ChevronRight as be } from "lucide-react";
4
- import { useState as P, useRef as Q, useEffect as C, useMemo as z } from "react";
5
- import { useNivaroClient as he } from "../../context.js";
6
- import { get as x } from "../../lib/commands.js";
7
- import { matchesAllTokens as ye, cn as j } from "../../lib/utils.js";
8
- import { applyDisplayTemplate as w } from "./helpers.js";
9
- import { NAMELESS_LABEL as ge } from "./option-disambiguate.js";
10
- import { useStaleTip as xe } from "./RelationCombobox.js";
11
- function Ee({
12
- collection: m,
13
- value: o,
14
- onChange: K,
15
- groupField: i,
16
- optionField: l,
17
- disabled: X,
18
- placeholder: ne,
1
+ import { jsxs as d, jsx as s, Fragment as Le } from "react/jsx-runtime";
2
+ import { useQuery as N } from "@tanstack/react-query";
3
+ import { Loader2 as he, AlertTriangle as Te, ChevronDown as ye, Search as Ee, X as _e, Check as be, ChevronRight as Ie } from "lucide-react";
4
+ import { useState as Q, useRef as ae, useId as Ke, useEffect as T, useMemo as z } from "react";
5
+ import { useNivaroClient as Ce } from "../../context.js";
6
+ import { get as S } from "../../lib/commands.js";
7
+ import { matchesAllTokens as ge, cn as E } from "../../lib/utils.js";
8
+ import { applyDisplayTemplate as q } from "./helpers.js";
9
+ import { NAMELESS_LABEL as Ae } from "./option-disambiguate.js";
10
+ import { useStaleTip as je } from "./RelationCombobox.js";
11
+ function Xe({
12
+ collection: p,
13
+ value: i,
14
+ onChange: oe,
15
+ groupField: f,
16
+ optionField: m,
17
+ disabled: V,
18
+ placeholder: xe,
19
19
  extraFilter: _,
20
- pinned: c
20
+ pinned: c,
21
+ narrowedBy: J
21
22
  }) {
22
- const h = he(), [u, y] = P(!1), [N, H] = P(""), [re, R] = P(/* @__PURE__ */ new Set()), U = Q(null), v = Q(null), V = Q(null);
23
- C(() => {
24
- if (!u) return;
25
- const e = (t) => {
26
- var a, b;
27
- if (t.key !== "Escape") return;
23
+ const g = Ce(), [a, y] = Q(!1), [u, P] = Q(""), [X, H] = Q(/* @__PURE__ */ new Set()), ie = ae(null), $ = ae(null), I = ae(null), W = Ke(), [le, K] = Q(-1);
24
+ T(() => {
25
+ if (!a) return;
26
+ const e = (n) => {
27
+ var o, w;
28
+ if (n.key !== "Escape") return;
28
29
  const r = document.activeElement;
29
- r !== document.body && !(r && ((a = v.current) != null && a.contains(r))) || (t.preventDefault(), t.stopPropagation(), y(!1), (b = V.current) == null || b.focus());
30
- }, n = (t) => {
31
- var a;
32
- const r = t.target;
33
- r && r !== document.body && !((a = v.current) != null && a.contains(r)) && y(!1);
30
+ r !== document.body && !(r && ((o = $.current) != null && o.contains(r))) || (n.preventDefault(), n.stopPropagation(), y(!1), (w = I.current) == null || w.focus());
31
+ }, t = (n) => {
32
+ var o;
33
+ const r = n.target;
34
+ r && r !== document.body && !((o = $.current) != null && o.contains(r)) && y(!1);
34
35
  };
35
- return window.addEventListener("keydown", e, !0), document.addEventListener("focusin", n), () => {
36
- window.removeEventListener("keydown", e, !0), document.removeEventListener("focusin", n);
36
+ return window.addEventListener("keydown", e, !0), document.addEventListener("focusin", t), () => {
37
+ window.removeEventListener("keydown", e, !0), document.removeEventListener("focusin", t);
37
38
  };
38
- }, [u]), C(() => {
39
- u ? setTimeout(() => {
40
- var e;
41
- return (e = U.current) == null ? void 0 : e.focus();
42
- }, 30) : (H(""), R(/* @__PURE__ */ new Set()));
43
- }, [u]), C(() => {
44
- if (!u) return;
45
- const e = (n) => {
46
- v.current && !v.current.contains(n.target) && y(!1);
39
+ }, [a]);
40
+ const C = () => {
41
+ var n;
42
+ const e = ie.current;
43
+ if (!e || document.activeElement === e) return;
44
+ e.focus({ preventScroll: !0 });
45
+ const t = e.value.length;
46
+ (n = e.setSelectionRange) == null || n.call(e, t, t);
47
+ };
48
+ T(() => {
49
+ if (a) {
50
+ document.activeElement === I.current && C();
51
+ const e = setTimeout(C, 30);
52
+ return () => clearTimeout(e);
53
+ } else
54
+ P(""), H(/* @__PURE__ */ new Set());
55
+ }, [a]), T(() => {
56
+ if (!a) return;
57
+ const e = (t) => {
58
+ $.current && !$.current.contains(t.target) && y(!1);
47
59
  };
48
60
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
49
- }, [u]);
50
- const { data: p } = g({
51
- queryKey: ["col-meta", m],
52
- queryFn: () => h.request(x(`/collections/${m}`)).then((e) => e.data),
61
+ }, [a]);
62
+ const { data: b } = N({
63
+ queryKey: ["col-meta", p],
64
+ queryFn: () => g.request(S(`/collections/${p}`)).then((e) => e.data),
53
65
  staleTime: 3e5,
54
66
  retry: !1
55
- }), D = z(
67
+ }), Y = z(
56
68
  () => {
57
69
  var e;
58
- return ((e = ((p == null ? void 0 : p.relations) ?? []).find((n) => n.many_field === i && !n.junction_field)) == null ? void 0 : e.one_collection) ?? null;
70
+ return ((e = ((b == null ? void 0 : b.relations) ?? []).find((t) => t.many_field === f && !t.junction_field)) == null ? void 0 : e.one_collection) ?? null;
59
71
  },
60
- [p, i]
61
- ), O = z(
72
+ [b, f]
73
+ ), Z = z(
62
74
  () => {
63
75
  var e;
64
- return ((e = ((p == null ? void 0 : p.relations) ?? []).find((n) => n.many_field === l && !n.junction_field)) == null ? void 0 : e.one_collection) ?? null;
76
+ return ((e = ((b == null ? void 0 : b.relations) ?? []).find((t) => t.many_field === m && !t.junction_field)) == null ? void 0 : e.one_collection) ?? null;
65
77
  },
66
- [p, l]
67
- ), { data: A } = g({
68
- queryKey: ["col-meta", D],
69
- queryFn: () => h.request(
70
- x(`/collections/${D}`)
78
+ [b, m]
79
+ ), { data: B } = N({
80
+ queryKey: ["col-meta", Y],
81
+ queryFn: () => g.request(
82
+ S(`/collections/${Y}`)
71
83
  ).then((e) => e.data),
72
- enabled: !!D,
84
+ enabled: !!Y,
73
85
  staleTime: 3e5,
74
86
  retry: !1
75
- }), { data: G } = g({
76
- queryKey: ["col-meta", O],
77
- queryFn: () => h.request(
78
- x(`/collections/${O}`)
87
+ }), { data: F } = N({
88
+ queryKey: ["col-meta", Z],
89
+ queryFn: () => g.request(
90
+ S(`/collections/${Z}`)
79
91
  ).then((e) => e.data),
80
- enabled: !!O,
92
+ enabled: !!Z,
81
93
  staleTime: 3e5,
82
94
  retry: !1
83
- }), W = `id,${i}.*,${l}.*`, k = _ ? JSON.stringify(_) : void 0, { data: T, isFetching: se } = g({
84
- queryKey: ["relation-grouped-opts", m, i, l, k],
85
- queryFn: () => h.request(
86
- x(`/items/${m}`, {
95
+ }), ce = `id,${f}.*,${m}.*`, A = _ ? JSON.stringify(_) : void 0, { data: j, isFetching: ve } = N({
96
+ queryKey: ["relation-grouped-opts", p, f, m, A],
97
+ queryFn: () => g.request(
98
+ S(`/items/${p}`, {
87
99
  limit: 1e3,
88
100
  picker: "1",
89
- fields: W,
90
- ...k ? { filter: k } : {}
101
+ fields: ce,
102
+ ...A ? { filter: A } : {}
91
103
  })
92
104
  ).then((e) => e.data ?? []),
93
- enabled: u,
94
- staleTime: k ? 0 : 3e4
95
- }), { data: S, isLoading: ae } = g({
96
- queryKey: ["relation-grouped-single", m, String(o), i, l],
97
- queryFn: () => h.request(x(`/items/${m}/${o}`, { fields: W })).then((e) => e.data),
98
- enabled: !!o,
105
+ enabled: a,
106
+ staleTime: A ? 0 : 3e4
107
+ }), { data: R, isLoading: we } = N({
108
+ queryKey: ["relation-grouped-single", p, String(i), f, m],
109
+ queryFn: () => g.request(S(`/items/${p}/${i}`, { fields: ce })).then((e) => e.data),
110
+ enabled: !!i,
99
111
  staleTime: 6e4
100
- }), oe = JSON.stringify(_ ? { _and: [{ id: { _eq: o } }, _] } : { id: { _eq: o } }), { data: Y } = g({
101
- queryKey: ["relation-avail", m, String(o), k],
102
- queryFn: () => h.request(
103
- x(`/items/${m}`, {
104
- filter: oe,
112
+ }), ke = JSON.stringify(_ ? { _and: [{ id: { _eq: i } }, _] } : { id: { _eq: i } }), { data: de } = N({
113
+ queryKey: ["relation-avail", p, String(i), A],
114
+ queryFn: () => g.request(
115
+ S(`/items/${p}`, {
116
+ filter: ke,
105
117
  picker: "1",
106
118
  limit: 1,
107
119
  fields: "id"
108
120
  })
109
121
  ).then((e) => e.data ?? []),
110
- enabled: !!o && !!S,
122
+ enabled: !!i && !!R,
111
123
  staleTime: 3e4
112
- }), I = !!o && Y !== void 0 && Y.length === 0, $ = A == null ? void 0 : A.display_template, q = G == null ? void 0 : G.display_template, E = z(() => {
113
- const e = T ?? [], n = N.toLowerCase(), t = /* @__PURE__ */ new Map();
124
+ }), ee = !!i && de !== void 0 && de.length === 0, U = B == null ? void 0 : B.display_template, O = F == null ? void 0 : F.display_template, D = z(() => {
125
+ const e = j ?? [], t = u.toLowerCase(), n = /* @__PURE__ */ new Map();
114
126
  for (const r of e) {
115
- const a = r[i], b = r[l], J = a ? String(a.id ?? "") : "__none__", M = a ? w($, a) : "—", me = b ? w(q, b) : String(r.id ?? "");
116
- n && !ye(`${M} ${me}`, n) || (t.has(J) || t.set(J, { label: M, items: [] }), t.get(J).items.push(r));
127
+ const o = r[f], w = r[m], k = o ? String(o.id ?? "") : "__none__", pe = o ? q(U, o) : "—", De = w ? q(O, w) : String(r.id ?? "");
128
+ t && !ge(`${pe} ${De}`, t) || (n.has(k) || n.set(k, { label: pe, items: [] }), n.get(k).items.push(r));
117
129
  }
118
- return [...t.entries()].map(([r, a]) => ({ id: r, label: a.label, items: a.items }));
119
- }, [T, N, i, l, $, q]);
120
- C(() => {
121
- N && R(new Set(E.map((e) => e.id)));
122
- }, [N, E]);
123
- function le(e) {
124
- R((n) => {
125
- const t = new Set(n);
126
- return t.has(e) ? t.delete(e) : t.add(e), t;
130
+ return [...n.entries()].map(([r, o]) => ({ id: r, label: o.label, items: o.items }));
131
+ }, [j, u, f, m, U, O]);
132
+ T(() => {
133
+ u && H(new Set(D.map((e) => e.id)));
134
+ }, [u, D]);
135
+ function Ne(e) {
136
+ H((t) => {
137
+ const n = new Set(t);
138
+ return n.has(e) ? n.delete(e) : n.add(e), n;
127
139
  });
128
140
  }
129
- const f = (c == null ? void 0 : c.id) != null && c.id !== "" ? String(c.id) : null, { data: ie } = g({
130
- queryKey: ["relation-grouped-single", m, f ?? "", i, l],
131
- queryFn: () => h.request(
132
- x(`/items/${m}/${f}`, { fields: `id,${i}.*,${l}.*` })
141
+ const h = (c == null ? void 0 : c.id) != null && c.id !== "" ? String(c.id) : null, { data: Se } = N({
142
+ queryKey: ["relation-grouped-single", p, h ?? "", f, m],
143
+ queryFn: () => g.request(
144
+ S(`/items/${p}/${h}`, { fields: `id,${f}.*,${m}.*` })
133
145
  ).then((e) => e.data).catch(() => null),
134
- enabled: !!f && u && !(T ?? []).some((e) => String(e.id) === f),
146
+ enabled: !!h && a && !(j ?? []).some((e) => String(e.id) === h),
135
147
  staleTime: 6e4
136
- }), L = f ? (T ?? []).find((e) => String(e.id) === f) ?? ie ?? null : null, ce = (e) => {
137
- const n = e[i], t = e[l], r = n ? w($, n) : null, a = t ? w(q, t) : null;
138
- return [r, a].filter(Boolean).join(" — ") || ge;
148
+ }), x = h ? (j ?? []).find((e) => String(e.id) === h) ?? Se ?? null : null, ue = (e) => {
149
+ const t = e[f], n = e[m], r = t ? q(U, t) : null, o = n ? q(O, n) : null;
150
+ return [r, o].filter(Boolean).join(" — ") || Ae;
151
+ }, M = !!h && (!u.trim() || ge(
152
+ `${x ? ue(x) : ""} ${(c == null ? void 0 : c.tag) ?? "Default"}`,
153
+ u.replace(/[-_/]+/g, " ")
154
+ )), L = M ? 1 : 0, G = z(
155
+ () => D.filter((e) => X.has(e.id)).flatMap((e) => e.items),
156
+ [D, X]
157
+ ), v = L + G.length, l = le >= v ? v - 1 : le;
158
+ T(() => {
159
+ K(a && u.trim() ? G.length ? L : M ? 0 : -1 : -1);
160
+ }, [a, u, L, G.length, M]);
161
+ const te = (e) => `${W}-opt-${e}`, ne = (e) => {
162
+ var t;
163
+ String(e) !== String(i) && oe(e), y(!1), (t = I.current) == null || t.focus();
164
+ }, re = (e) => {
165
+ e < 0 || e >= v || (e < L ? ne((x == null ? void 0 : x.id) ?? (c == null ? void 0 : c.id)) : ne(G[e - L].id));
139
166
  };
140
- let B = null;
141
- if (S) {
142
- const e = S[i], n = S[l], t = e ? w($, e) : null, r = n ? w(q, n) : null;
143
- B = [t, r].filter(Boolean).join(" — ") || null;
167
+ T(() => {
168
+ var t, n;
169
+ if (!a || l < 0) return;
170
+ const e = (t = $.current) == null ? void 0 : t.querySelector(`[data-nav-index="${l}"]`);
171
+ (n = e == null ? void 0 : e.scrollIntoView) == null || n.call(e, { block: "nearest" });
172
+ }, [a, l]);
173
+ const me = (e) => {
174
+ var t;
175
+ if (e.key === "ArrowDown")
176
+ e.preventDefault(), v > 0 && K(l < 0 ? 0 : Math.min(l + 1, v - 1));
177
+ else if (e.key === "ArrowUp")
178
+ e.preventDefault(), v > 0 && K(l <= 0 ? 0 : l - 1);
179
+ else if (e.key === "Enter") {
180
+ if (e.preventDefault(), j === void 0) return;
181
+ l >= 0 ? re(l) : u.trim() && v === 1 && re(0);
182
+ } else e.key === "Tab" && (y(!1), (t = I.current) == null || t.focus());
183
+ }, qe = (e) => {
184
+ if (V) return;
185
+ const t = e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey && (a || e.key !== " ");
186
+ if (!a && (e.key === "ArrowDown" || e.key === "ArrowUp"))
187
+ e.preventDefault(), y(!0);
188
+ else if (t) {
189
+ e.preventDefault();
190
+ const n = e.key;
191
+ P((r) => r + n), a ? C() : y(!0);
192
+ } else a && e.key === "Backspace" ? (e.preventDefault(), P((n) => n.slice(0, -1)), C()) : a && (e.key === "Enter" || e.key === "ArrowDown" || e.key === "ArrowUp") && (me(e), C());
193
+ };
194
+ let se = null;
195
+ if (R) {
196
+ const e = R[f], t = R[m], n = e ? q(U, e) : null, r = t ? q(O, t) : null;
197
+ se = [n, r].filter(Boolean).join(" — ") || null;
144
198
  }
145
- const de = !!o && ae && !S, Z = xe(I);
146
- return /* @__PURE__ */ d("div", { ref: v, className: "relative", ...Z.bind, children: [
199
+ const $e = !!i && we && !R, fe = je(ee);
200
+ return /* @__PURE__ */ d("div", { ref: $, className: "relative", ...fe.bind, children: [
147
201
  /* @__PURE__ */ d(
148
202
  "button",
149
203
  {
150
- ref: V,
204
+ ref: I,
151
205
  type: "button",
152
- disabled: X,
206
+ disabled: V,
153
207
  "aria-haspopup": "listbox",
154
- "aria-expanded": u,
208
+ "aria-expanded": a,
155
209
  onClick: () => y((e) => !e),
156
- className: j(
157
- "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",
158
- I ? "border-amber-300 dark:border-amber-600" : "border-input"
210
+ onKeyDown: qe,
211
+ className: E(
212
+ "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 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/60 disabled:pointer-events-none disabled:opacity-50",
213
+ ee ? "border-amber-300 dark:border-amber-600" : "border-input"
159
214
  ),
160
215
  children: [
161
- de ? /* @__PURE__ */ s(F, { className: "h-3.5 w-3.5 animate-spin text-muted-foreground" }) : /* @__PURE__ */ d(
216
+ $e ? /* @__PURE__ */ s(he, { className: "h-3.5 w-3.5 animate-spin text-muted-foreground" }) : /* @__PURE__ */ d(
162
217
  "span",
163
218
  {
164
- className: j(
219
+ className: E(
165
220
  "flex items-center gap-1.5 truncate min-w-0",
166
- !B && "text-muted-foreground"
221
+ !se && "text-muted-foreground"
167
222
  ),
168
223
  children: [
169
- I && /* @__PURE__ */ s(ue, { className: "h-3.5 w-3.5 shrink-0 text-amber-500" }),
170
- /* @__PURE__ */ s("span", { className: "truncate", children: B ?? ne ?? "Select…" })
224
+ ee && /* @__PURE__ */ s(Te, { className: "h-3.5 w-3.5 shrink-0 text-amber-500" }),
225
+ /* @__PURE__ */ s("span", { className: "truncate", children: se ?? xe ?? "Select…" })
171
226
  ]
172
227
  }
173
228
  ),
174
- /* @__PURE__ */ s(ee, { className: "h-4 w-4 shrink-0 opacity-50" })
229
+ /* @__PURE__ */ s(ye, { className: "h-4 w-4 shrink-0 opacity-50" })
175
230
  ]
176
231
  }
177
232
  ),
178
- Z.tip,
179
- u && /* @__PURE__ */ d("div", { className: "absolute z-50 mt-1 min-w-[280px] w-max max-w-[420px] rounded-md border border-border bg-popover shadow-md", children: [
233
+ fe.tip,
234
+ a && /* @__PURE__ */ d("div", { className: "absolute z-50 mt-1 min-w-[280px] w-max max-w-[420px] rounded-md border border-border bg-popover shadow-md", children: [
180
235
  /* @__PURE__ */ d("div", { className: "flex items-center border-b px-3", children: [
181
- /* @__PURE__ */ s(fe, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
236
+ /* @__PURE__ */ s(Ee, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
182
237
  /* @__PURE__ */ s(
183
238
  "input",
184
239
  {
185
- ref: U,
186
- value: N,
187
- onChange: (e) => H(e.target.value),
188
- onKeyDown: (e) => {
189
- e.key === "Enter" && e.preventDefault();
190
- },
240
+ ref: ie,
241
+ value: u,
242
+ onChange: (e) => P(e.target.value),
243
+ onKeyDown: me,
244
+ role: "combobox",
245
+ "aria-expanded": !0,
246
+ "aria-autocomplete": "list",
247
+ "aria-controls": `${W}-list`,
248
+ "aria-activedescendant": l >= 0 ? te(l) : void 0,
191
249
  placeholder: "Search…",
192
250
  className: "flex h-9 w-full bg-transparent py-3 text-[13px] outline-none placeholder:text-muted-foreground"
193
251
  }
194
252
  )
195
253
  ] }),
196
- /* @__PURE__ */ d("div", { className: "max-h-64 overflow-y-auto py-1", children: [
197
- !!o && !X && /* @__PURE__ */ d(
254
+ /* @__PURE__ */ d("div", { id: `${W}-list`, role: "listbox", className: "max-h-64 overflow-y-auto py-1", children: [
255
+ !!i && !V && /* @__PURE__ */ d(
198
256
  "button",
199
257
  {
200
258
  type: "button",
259
+ tabIndex: -1,
201
260
  onClick: () => {
202
- K(null), y(!1);
261
+ oe(null), y(!1);
203
262
  },
204
263
  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",
205
264
  children: [
206
- /* @__PURE__ */ s(pe, { className: "h-3.5 w-3.5 text-slate-400" }),
265
+ /* @__PURE__ */ s(_e, { className: "h-3.5 w-3.5 text-slate-400" }),
207
266
  "Clear selection"
208
267
  ]
209
268
  }
210
269
  ),
211
- f && /* @__PURE__ */ d(
270
+ M && /* @__PURE__ */ d(
212
271
  "button",
213
272
  {
214
273
  type: "button",
274
+ tabIndex: -1,
275
+ id: te(0),
276
+ role: "option",
277
+ "aria-selected": String(i) === h,
278
+ "data-nav-index": 0,
215
279
  "data-nvr-pinned-option": !0,
216
- onClick: () => {
217
- K((L == null ? void 0 : L.id) ?? (c == null ? void 0 : c.id)), y(!1);
218
- },
219
- 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",
280
+ onClick: () => re(0),
281
+ onMouseMove: () => l !== 0 && K(0),
282
+ className: E(
283
+ "flex w-full items-center gap-2 border-b border-slate-100 px-3 py-1.5 text-left text-[13px] hover:bg-nvr-cyan/10 dark:border-border",
284
+ l === 0 ? "bg-nvr-cyan/10" : "bg-nvr-cyan/5"
285
+ ),
220
286
  children: [
221
287
  /* @__PURE__ */ s(
222
288
  "div",
223
289
  {
224
- className: j(
290
+ className: E(
225
291
  "flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",
226
- String(o) === f ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300"
292
+ String(i) === h ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300"
227
293
  ),
228
- children: String(o) === f && /* @__PURE__ */ s(te, { className: "h-2.5 w-2.5 text-white" })
294
+ children: String(i) === h && /* @__PURE__ */ s(be, { className: "h-2.5 w-2.5 text-white" })
229
295
  }
230
296
  ),
231
- /* @__PURE__ */ s("span", { className: "min-w-0 flex-1 truncate", children: L ? ce(L) : "Loading…" }),
297
+ /* @__PURE__ */ s("span", { className: "min-w-0 flex-1 truncate", children: x ? ue(x) : "Loading…" }),
232
298
  /* @__PURE__ */ s("span", { className: "shrink-0 rounded bg-nvr-cyan/15 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-slate-700 dark:text-foreground", children: (c == null ? void 0 : c.tag) ?? "Default" })
233
299
  ]
234
300
  }
235
301
  ),
236
- se ? /* @__PURE__ */ s("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ s(F, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : E.length === 0 ? /* @__PURE__ */ s("p", { className: "px-3 py-2 text-[13px] text-muted-foreground", children: "No results" }) : E.map((e) => {
237
- const n = re.has(e.id);
302
+ ve ? /* @__PURE__ */ s("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ s(he, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : D.length === 0 ? u.trim() && M ? null : u.trim() ? /* @__PURE__ */ d("p", { className: "px-3 py-2 text-[13px] text-muted-foreground", children: [
303
+ "No results for “",
304
+ u.trim(),
305
+ "”"
306
+ ] }) : _ ? (
307
+ // Nothing at all fits this record: say what narrows the list
308
+ // (a project with no line categories set up — army9 b01) so
309
+ // the person knows who can fix it, instead of a bare "No results".
310
+ /* @__PURE__ */ d(
311
+ "p",
312
+ {
313
+ className: "px-3 py-2 text-[12px] leading-5 text-muted-foreground",
314
+ "data-nvr-empty-narrowed": !0,
315
+ children: [
316
+ J != null && J.labels.length ? /* @__PURE__ */ d(Le, { children: [
317
+ "Nothing set up for this",
318
+ " ",
319
+ /* @__PURE__ */ s("span", { className: "font-medium text-foreground", children: J.labels.join(" · ") }),
320
+ " ",
321
+ "yet."
322
+ ] }) : "Nothing set up for this record yet.",
323
+ " ",
324
+ "Pick a different one, or ask an administrator to add options for it."
325
+ ]
326
+ }
327
+ )
328
+ ) : /* @__PURE__ */ s("p", { className: "px-3 py-2 text-[13px] text-muted-foreground", children: "No results" }) : D.map((e) => {
329
+ const t = X.has(e.id);
238
330
  return /* @__PURE__ */ d("div", { children: [
239
331
  /* @__PURE__ */ d(
240
332
  "button",
241
333
  {
242
334
  type: "button",
243
- onClick: () => le(e.id),
335
+ onClick: () => Ne(e.id),
244
336
  className: "flex w-full items-center gap-1.5 px-3 py-1.5 text-[11px] font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400 hover:bg-muted",
245
337
  children: [
246
- n ? /* @__PURE__ */ s(ee, { className: "h-3 w-3 shrink-0" }) : /* @__PURE__ */ s(be, { className: "h-3 w-3 shrink-0" }),
338
+ t ? /* @__PURE__ */ s(ye, { className: "h-3 w-3 shrink-0" }) : /* @__PURE__ */ s(Ie, { className: "h-3 w-3 shrink-0" }),
247
339
  e.label,
248
340
  /* @__PURE__ */ s("span", { className: "ml-auto font-normal normal-case tracking-normal text-slate-400", children: e.items.length })
249
341
  ]
250
342
  }
251
343
  ),
252
- n && e.items.map((t) => {
253
- const r = t[l], a = r ? w(q, r) : String(t.id ?? ""), b = String(t.id) === String(o);
344
+ t && e.items.map((n) => {
345
+ const r = L + G.indexOf(n), o = n[m], w = o ? q(O, o) : String(n.id ?? ""), k = String(n.id) === String(i);
254
346
  return /* @__PURE__ */ d(
255
347
  "button",
256
348
  {
257
349
  type: "button",
258
- onClick: () => {
259
- K(t.id), y(!1);
260
- },
261
- className: "flex w-full items-center gap-2 pl-8 pr-3 py-1.5 text-[13px] text-left hover:bg-muted",
350
+ tabIndex: -1,
351
+ id: te(r),
352
+ role: "option",
353
+ "aria-selected": k,
354
+ "data-nav-index": r,
355
+ onClick: () => ne(n.id),
356
+ onMouseMove: () => l !== r && K(r),
357
+ className: E(
358
+ "flex w-full items-center gap-2 pl-8 pr-3 py-1.5 text-[13px] text-left hover:bg-muted",
359
+ l === r && "bg-muted"
360
+ ),
262
361
  children: [
263
362
  /* @__PURE__ */ s(
264
363
  "div",
265
364
  {
266
- className: j(
365
+ className: E(
267
366
  "flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",
268
- b ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300"
367
+ k ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300"
269
368
  ),
270
- children: b && /* @__PURE__ */ s(te, { className: "h-2.5 w-2.5 text-white" })
369
+ children: k && /* @__PURE__ */ s(be, { className: "h-2.5 w-2.5 text-white" })
271
370
  }
272
371
  ),
273
- a
372
+ w
274
373
  ]
275
374
  },
276
- String(t.id)
375
+ String(n.id)
277
376
  );
278
377
  })
279
378
  ] }, e.id);
@@ -283,5 +382,5 @@ function Ee({
283
382
  ] });
284
383
  }
285
384
  export {
286
- Ee as RelationGroupedCombobox
385
+ Xe as RelationGroupedCombobox
287
386
  };