@nivaro/react 0.3.57 → 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 (69) 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 +37 -2
  6. package/dist/index.js +523 -520
  7. package/dist/shared/components/CollectionBrowserView.js +2693 -2619
  8. package/dist/shared/components/DataTable.js +538 -495
  9. package/dist/shared/components/ItemEditForm.js +4559 -4386
  10. package/dist/shared/components/PageRenderer.js +537 -508
  11. package/dist/shared/components/ProfileView.js +716 -715
  12. package/dist/shared/components/QueryTable.js +74 -74
  13. package/dist/shared/components/RecordReadView.js +367 -364
  14. package/dist/shared/components/ReportView.js +64 -39
  15. package/dist/shared/components/WidgetSlot.js +543 -520
  16. package/dist/shared/components/alerts/AlertManagerView.js +324 -317
  17. package/dist/shared/components/alerts/types.js +37 -14
  18. package/dist/shared/components/cbv/row-focus.js +19 -0
  19. package/dist/shared/components/help-videos/HelpVideoPlayer.js +152 -147
  20. package/dist/shared/components/integrations/console/SignalCard.js +59 -59
  21. package/dist/shared/components/integrations/console/tone.js +52 -30
  22. package/dist/shared/components/item-edit/CatalogPickerField.js +525 -505
  23. package/dist/shared/components/item-edit/FieldRenderer.js +22 -20
  24. package/dist/shared/components/item-edit/FieldRow.js +175 -173
  25. package/dist/shared/components/item-edit/GridBulkEditDialog.js +55 -54
  26. package/dist/shared/components/item-edit/InlineTableField.js +2487 -2442
  27. package/dist/shared/components/item-edit/M2MCombobox.js +321 -295
  28. package/dist/shared/components/item-edit/MidairCollisionDialog.js +1 -1
  29. package/dist/shared/components/item-edit/PlanGrid.js +973 -894
  30. package/dist/shared/components/item-edit/QuickCreateButton.js +335 -106
  31. package/dist/shared/components/item-edit/RecordLiveSync.js +77 -75
  32. package/dist/shared/components/item-edit/RelationCombobox.js +452 -335
  33. package/dist/shared/components/item-edit/RelationGroupedCombobox.js +262 -141
  34. package/dist/shared/components/item-edit/SummaryPanel.js +385 -358
  35. package/dist/shared/components/item-edit/duplicate-rehearsal.js +47 -0
  36. package/dist/shared/components/item-edit/line-midair.js +82 -75
  37. package/dist/shared/components/item-edit/option-disambiguate.js +44 -32
  38. package/dist/shared/components/item-edit/related-missing.js +45 -0
  39. package/dist/shared/components/item-edit/save-outcome.js +9 -7
  40. package/dist/shared/components/notifications/NotificationRulesEditor.js +130 -123
  41. package/dist/shared/components/panels/AccessDeniedPanel.js +52 -48
  42. package/dist/shared/components/panels/ItemLockBanner.js +213 -211
  43. package/dist/shared/components/panels/PipelinePanel.js +1140 -1053
  44. package/dist/shared/components/panels/RecordIntegrityBanner.js +114 -86
  45. package/dist/shared/components/panels/RevisionsPanel.js +316 -299
  46. package/dist/shared/components/panels/TaskPanel.js +265 -249
  47. package/dist/shared/components/panels/landing-state.js +27 -0
  48. package/dist/shared/components/pipeline/PipelineEditorView.js +110 -92
  49. package/dist/shared/components/profile/AiMemoryCard.js +12 -10
  50. package/dist/shared/components/queue/OwnerAvatars.js +80 -41
  51. package/dist/shared/components/queue/QueueQuickFilters.js +52 -52
  52. package/dist/shared/components/queue/QueueWorklist.js +1050 -1026
  53. package/dist/shared/components/queue/group-sums.js +27 -0
  54. package/dist/shared/components/queue/live-state-aspect.js +9 -5
  55. package/dist/shared/components/widgets/ReviewListWidget.js +175 -154
  56. package/dist/shared/lib/back-closes.js +25 -0
  57. package/dist/shared/lib/display-prefs.js +60 -52
  58. package/dist/shared/lib/draft-store.js +71 -48
  59. package/dist/shared/lib/expression.js +53 -53
  60. package/dist/shared/lib/form-usage-beacon.js +7 -7
  61. package/dist/shared/lib/list-page-memory.js +63 -0
  62. package/dist/shared/lib/live.js +44 -44
  63. package/dist/shared/lib/money-input.js +45 -0
  64. package/dist/shared/lib/own-writes.js +76 -28
  65. package/dist/shared/lib/request-gate.js +110 -109
  66. package/dist/shared/lib/sanitize-html.js +10 -6
  67. package/dist/shared/lib/staged-row-labels.js +18 -0
  68. package/dist/shared/lib/validation-rules.js +34 -19
  69. package/package.json +1 -1
@@ -1,254 +1,375 @@
1
- import { jsxs as d, jsx as r } from "react/jsx-runtime";
2
- import { useQuery as p } from "@tanstack/react-query";
3
- import { Loader2 as Z, AlertTriangle as me, ChevronDown as M, Search as ue, X as fe, Check as F, ChevronRight as he } from "lucide-react";
4
- import { useState as B, useRef as ee, useEffect as Q, useMemo as z } from "react";
5
- import { useNivaroClient as be } from "../../context.js";
6
- import { get as y } from "../../lib/commands.js";
7
- import { matchesAllTokens as pe, cn as L } from "../../lib/utils.js";
8
- import { applyDisplayTemplate as x } from "./helpers.js";
9
- import { useStaleTip as ye } from "./RelationCombobox.js";
10
- function Te({
11
- collection: m,
12
- value: s,
13
- onChange: j,
14
- groupField: o,
15
- optionField: l,
16
- disabled: P,
17
- placeholder: te,
18
- extraFilter: $,
19
- pinned: i
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
+ extraFilter: _,
20
+ pinned: c,
21
+ narrowedBy: J
20
22
  }) {
21
- const h = be(), [b, g] = B(!1), [w, X] = B(""), [ne, K] = B(/* @__PURE__ */ new Set()), H = ee(null), R = ee(null);
22
- Q(() => {
23
- b ? setTimeout(() => {
24
- var e;
25
- return (e = H.current) == null ? void 0 : e.focus();
26
- }, 30) : (X(""), K(/* @__PURE__ */ new Set()));
27
- }, [b]), Q(() => {
28
- if (!b) 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;
29
+ const r = document.activeElement;
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);
35
+ };
36
+ return window.addEventListener("keydown", e, !0), document.addEventListener("focusin", t), () => {
37
+ window.removeEventListener("keydown", e, !0), document.removeEventListener("focusin", t);
38
+ };
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;
29
57
  const e = (t) => {
30
- R.current && !R.current.contains(t.target) && g(!1);
58
+ $.current && !$.current.contains(t.target) && y(!1);
31
59
  };
32
60
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
33
- }, [b]);
34
- const { data: f } = p({
35
- queryKey: ["col-meta", m],
36
- queryFn: () => h.request(y(`/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),
37
65
  staleTime: 3e5,
38
66
  retry: !1
39
- }), O = z(
67
+ }), Y = z(
40
68
  () => {
41
69
  var e;
42
- return ((e = ((f == null ? void 0 : f.relations) ?? []).find((t) => t.many_field === o && !t.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;
43
71
  },
44
- [f, o]
45
- ), D = z(
72
+ [b, f]
73
+ ), Z = z(
46
74
  () => {
47
75
  var e;
48
- return ((e = ((f == null ? void 0 : f.relations) ?? []).find((t) => t.many_field === l && !t.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;
49
77
  },
50
- [f, l]
51
- ), { data: E } = p({
52
- queryKey: ["col-meta", O],
53
- queryFn: () => h.request(
54
- y(`/collections/${O}`)
78
+ [b, m]
79
+ ), { data: B } = N({
80
+ queryKey: ["col-meta", Y],
81
+ queryFn: () => g.request(
82
+ S(`/collections/${Y}`)
55
83
  ).then((e) => e.data),
56
- enabled: !!O,
84
+ enabled: !!Y,
57
85
  staleTime: 3e5,
58
86
  retry: !1
59
- }), { data: G } = p({
60
- queryKey: ["col-meta", D],
61
- queryFn: () => h.request(
62
- y(`/collections/${D}`)
87
+ }), { data: F } = N({
88
+ queryKey: ["col-meta", Z],
89
+ queryFn: () => g.request(
90
+ S(`/collections/${Z}`)
63
91
  ).then((e) => e.data),
64
- enabled: !!D,
92
+ enabled: !!Z,
65
93
  staleTime: 3e5,
66
94
  retry: !1
67
- }), U = `id,${o}.*,${l}.*`, N = $ ? JSON.stringify($) : void 0, { data: T, isFetching: re } = p({
68
- queryKey: ["relation-grouped-opts", m, o, l, N],
69
- queryFn: () => h.request(
70
- y(`/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}`, {
71
99
  limit: 1e3,
72
100
  picker: "1",
73
- fields: U,
74
- ...N ? { filter: N } : {}
101
+ fields: ce,
102
+ ...A ? { filter: A } : {}
75
103
  })
76
104
  ).then((e) => e.data ?? []),
77
- enabled: b,
78
- staleTime: N ? 0 : 3e4
79
- }), { data: S, isLoading: se } = p({
80
- queryKey: ["relation-grouped-single", m, String(s), o, l],
81
- queryFn: () => h.request(y(`/items/${m}/${s}`, { fields: U })).then((e) => e.data),
82
- enabled: !!s,
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,
83
111
  staleTime: 6e4
84
- }), ae = JSON.stringify($ ? { _and: [{ id: { _eq: s } }, $] } : { id: { _eq: s } }), { data: V } = p({
85
- queryKey: ["relation-avail", m, String(s), N],
86
- queryFn: () => h.request(
87
- y(`/items/${m}`, {
88
- filter: ae,
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,
89
117
  picker: "1",
90
118
  limit: 1,
91
119
  fields: "id"
92
120
  })
93
121
  ).then((e) => e.data ?? []),
94
- enabled: !!s && !!S,
122
+ enabled: !!i && !!R,
95
123
  staleTime: 3e4
96
- }), I = !!s && V !== void 0 && V.length === 0, _ = E == null ? void 0 : E.display_template, k = G == null ? void 0 : G.display_template, C = z(() => {
97
- const e = T ?? [], t = w.toLowerCase(), n = /* @__PURE__ */ new Map();
98
- for (const a of e) {
99
- const c = a[o], v = a[l], A = c ? String(c.id ?? "") : "__none__", Y = c ? x(_, c) : "—", de = v ? x(k, v) : String(a.id ?? "");
100
- t && !pe(`${Y} ${de}`, t) || (n.has(A) || n.set(A, { label: Y, items: [] }), n.get(A).items.push(a));
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();
126
+ for (const r of e) {
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));
101
129
  }
102
- return [...n.entries()].map(([a, c]) => ({ id: a, label: c.label, items: c.items }));
103
- }, [T, w, o, l, _, k]);
104
- Q(() => {
105
- w && K(new Set(C.map((e) => e.id)));
106
- }, [w, C]);
107
- function le(e) {
108
- K((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) => {
109
137
  const n = new Set(t);
110
138
  return n.has(e) ? n.delete(e) : n.add(e), n;
111
139
  });
112
140
  }
113
- const u = (i == null ? void 0 : i.id) != null && i.id !== "" ? String(i.id) : null, { data: oe } = p({
114
- queryKey: ["relation-grouped-single", m, u ?? "", o, l],
115
- queryFn: () => h.request(
116
- y(`/items/${m}/${u}`, { fields: `id,${o}.*,${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}.*` })
117
145
  ).then((e) => e.data).catch(() => null),
118
- enabled: !!u && b && !(T ?? []).some((e) => String(e.id) === u),
146
+ enabled: !!h && a && !(j ?? []).some((e) => String(e.id) === h),
119
147
  staleTime: 6e4
120
- }), q = u ? (T ?? []).find((e) => String(e.id) === u) ?? oe ?? null : null, ie = (e) => {
121
- const t = e[o], n = e[l], a = t ? x(_, t) : null, c = n ? x(k, n) : null;
122
- return [a, c].filter(Boolean).join(" — ") || `#${String(e.id)}`;
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));
123
166
  };
124
- let J = null;
125
- if (S) {
126
- const e = S[o], t = S[l], n = e ? x(_, e) : null, a = t ? x(k, t) : null;
127
- J = [n, a].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;
128
198
  }
129
- const ce = !!s && se && !S, W = ye(I);
130
- return /* @__PURE__ */ d("div", { ref: R, className: "relative", ...W.bind, children: [
199
+ const $e = !!i && we && !R, fe = je(ee);
200
+ return /* @__PURE__ */ d("div", { ref: $, className: "relative", ...fe.bind, children: [
131
201
  /* @__PURE__ */ d(
132
202
  "button",
133
203
  {
204
+ ref: I,
134
205
  type: "button",
135
- disabled: P,
136
- onClick: () => g((e) => !e),
137
- className: L(
138
- "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",
139
- I ? "border-amber-300 dark:border-amber-600" : "border-input"
206
+ disabled: V,
207
+ "aria-haspopup": "listbox",
208
+ "aria-expanded": a,
209
+ onClick: () => y((e) => !e),
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"
140
214
  ),
141
215
  children: [
142
- ce ? /* @__PURE__ */ r(Z, { 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(
143
217
  "span",
144
218
  {
145
- className: L(
219
+ className: E(
146
220
  "flex items-center gap-1.5 truncate min-w-0",
147
- !J && "text-muted-foreground"
221
+ !se && "text-muted-foreground"
148
222
  ),
149
223
  children: [
150
- I && /* @__PURE__ */ r(me, { className: "h-3.5 w-3.5 shrink-0 text-amber-500" }),
151
- /* @__PURE__ */ r("span", { className: "truncate", children: J ?? te ?? "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…" })
152
226
  ]
153
227
  }
154
228
  ),
155
- /* @__PURE__ */ r(M, { className: "h-4 w-4 shrink-0 opacity-50" })
229
+ /* @__PURE__ */ s(ye, { className: "h-4 w-4 shrink-0 opacity-50" })
156
230
  ]
157
231
  }
158
232
  ),
159
- W.tip,
160
- b && /* @__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: [
161
235
  /* @__PURE__ */ d("div", { className: "flex items-center border-b px-3", children: [
162
- /* @__PURE__ */ r(ue, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
163
- /* @__PURE__ */ r(
236
+ /* @__PURE__ */ s(Ee, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
237
+ /* @__PURE__ */ s(
164
238
  "input",
165
239
  {
166
- ref: H,
167
- value: w,
168
- onChange: (e) => X(e.target.value),
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,
169
249
  placeholder: "Search…",
170
250
  className: "flex h-9 w-full bg-transparent py-3 text-[13px] outline-none placeholder:text-muted-foreground"
171
251
  }
172
252
  )
173
253
  ] }),
174
- /* @__PURE__ */ d("div", { className: "max-h-64 overflow-y-auto py-1", children: [
175
- !!s && !P && /* @__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(
176
256
  "button",
177
257
  {
178
258
  type: "button",
259
+ tabIndex: -1,
179
260
  onClick: () => {
180
- j(null), g(!1);
261
+ oe(null), y(!1);
181
262
  },
182
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",
183
264
  children: [
184
- /* @__PURE__ */ r(fe, { className: "h-3.5 w-3.5 text-slate-400" }),
265
+ /* @__PURE__ */ s(_e, { className: "h-3.5 w-3.5 text-slate-400" }),
185
266
  "Clear selection"
186
267
  ]
187
268
  }
188
269
  ),
189
- u && /* @__PURE__ */ d(
270
+ M && /* @__PURE__ */ d(
190
271
  "button",
191
272
  {
192
273
  type: "button",
274
+ tabIndex: -1,
275
+ id: te(0),
276
+ role: "option",
277
+ "aria-selected": String(i) === h,
278
+ "data-nav-index": 0,
193
279
  "data-nvr-pinned-option": !0,
194
- onClick: () => {
195
- j((q == null ? void 0 : q.id) ?? (i == null ? void 0 : i.id)), g(!1);
196
- },
197
- 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
+ ),
198
286
  children: [
199
- /* @__PURE__ */ r(
287
+ /* @__PURE__ */ s(
200
288
  "div",
201
289
  {
202
- className: L(
290
+ className: E(
203
291
  "flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",
204
- String(s) === u ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300"
292
+ String(i) === h ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300"
205
293
  ),
206
- children: String(s) === u && /* @__PURE__ */ r(F, { 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" })
207
295
  }
208
296
  ),
209
- /* @__PURE__ */ r("span", { className: "min-w-0 flex-1 truncate", children: q ? ie(q) : `#${u}` }),
210
- /* @__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: (i == null ? void 0 : i.tag) ?? "Default" })
297
+ /* @__PURE__ */ s("span", { className: "min-w-0 flex-1 truncate", children: x ? ue(x) : "Loading…" }),
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" })
211
299
  ]
212
300
  }
213
301
  ),
214
- re ? /* @__PURE__ */ r("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ r(Z, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : C.length === 0 ? /* @__PURE__ */ r("p", { className: "px-3 py-2 text-[13px] text-muted-foreground", children: "No results" }) : C.map((e) => {
215
- const t = ne.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);
216
330
  return /* @__PURE__ */ d("div", { children: [
217
331
  /* @__PURE__ */ d(
218
332
  "button",
219
333
  {
220
334
  type: "button",
221
- onClick: () => le(e.id),
335
+ onClick: () => Ne(e.id),
222
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",
223
337
  children: [
224
- t ? /* @__PURE__ */ r(M, { className: "h-3 w-3 shrink-0" }) : /* @__PURE__ */ r(he, { 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" }),
225
339
  e.label,
226
- /* @__PURE__ */ r("span", { className: "ml-auto font-normal normal-case tracking-normal text-slate-400", children: e.items.length })
340
+ /* @__PURE__ */ s("span", { className: "ml-auto font-normal normal-case tracking-normal text-slate-400", children: e.items.length })
227
341
  ]
228
342
  }
229
343
  ),
230
344
  t && e.items.map((n) => {
231
- const a = n[l], c = a ? x(k, a) : String(n.id ?? ""), v = String(n.id) === String(s);
345
+ const r = L + G.indexOf(n), o = n[m], w = o ? q(O, o) : String(n.id ?? ""), k = String(n.id) === String(i);
232
346
  return /* @__PURE__ */ d(
233
347
  "button",
234
348
  {
235
349
  type: "button",
236
- onClick: () => {
237
- j(n.id), g(!1);
238
- },
239
- 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
+ ),
240
361
  children: [
241
- /* @__PURE__ */ r(
362
+ /* @__PURE__ */ s(
242
363
  "div",
243
364
  {
244
- className: L(
365
+ className: E(
245
366
  "flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",
246
- v ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300"
367
+ k ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300"
247
368
  ),
248
- children: v && /* @__PURE__ */ r(F, { className: "h-2.5 w-2.5 text-white" })
369
+ children: k && /* @__PURE__ */ s(be, { className: "h-2.5 w-2.5 text-white" })
249
370
  }
250
371
  ),
251
- c
372
+ w
252
373
  ]
253
374
  },
254
375
  String(n.id)
@@ -261,5 +382,5 @@ function Te({
261
382
  ] });
262
383
  }
263
384
  export {
264
- Te as RelationGroupedCombobox
385
+ Xe as RelationGroupedCombobox
265
386
  };