@nivaro/react 0.3.65 → 0.3.67

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/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +21 -5
  4. package/dist/shared/components/ActivityEntry.js +28 -28
  5. package/dist/shared/components/CollectionBrowserView.js +2432 -2592
  6. package/dist/shared/components/ItemEditForm.js +3912 -3773
  7. package/dist/shared/components/MyWorkView.js +124 -113
  8. package/dist/shared/components/ProfileView.js +483 -472
  9. package/dist/shared/components/RecordCompare.js +149 -129
  10. package/dist/shared/components/ReportView.js +1100 -1094
  11. package/dist/shared/components/bulk/BulkCompareButton.js +62 -0
  12. package/dist/shared/components/bulk/MessageStakeholders.js +235 -0
  13. package/dist/shared/components/integrations/IntegrationObligationsView.js +199 -187
  14. package/dist/shared/components/integrations/console/EventsView.js +22 -24
  15. package/dist/shared/components/integrations/console/SubmissionRow.js +6 -13
  16. package/dist/shared/components/integrations/console/drill/SubmissionDrill.js +29 -28
  17. package/dist/shared/components/integrations/console/tone.js +22 -21
  18. package/dist/shared/components/item-edit/CatalogPickerField.js +240 -238
  19. package/dist/shared/components/item-edit/FieldRow.js +193 -193
  20. package/dist/shared/components/item-edit/GroupSection.js +559 -542
  21. package/dist/shared/components/item-edit/M2MCombobox.js +414 -349
  22. package/dist/shared/components/item-edit/MidairCollisionDialog.js +211 -187
  23. package/dist/shared/components/item-edit/RecordInsights.js +46 -45
  24. package/dist/shared/components/item-edit/RelationCombobox.js +327 -311
  25. package/dist/shared/components/item-edit/SummaryPanel.js +146 -144
  26. package/dist/shared/components/item-edit/UserChip.js +264 -229
  27. package/dist/shared/components/item-edit/cascade-clear-notice.js +23 -19
  28. package/dist/shared/components/item-edit/header-path-preview.js +52 -0
  29. package/dist/shared/components/item-edit/line-merge.js +73 -47
  30. package/dist/shared/components/item-edit/picker-search.js +25 -21
  31. package/dist/shared/components/panels/BranchLanes.js +7 -7
  32. package/dist/shared/components/panels/CommentPanel.js +72 -72
  33. package/dist/shared/components/panels/PipelinePanel.js +261 -261
  34. package/dist/shared/components/panels/RecordIntegrityBanner.js +78 -78
  35. package/dist/shared/components/panels/RevisionsPanel.js +220 -220
  36. package/dist/shared/components/panels/TaskPanel.js +75 -75
  37. package/dist/shared/components/queue/QueueWorklist.js +1007 -979
  38. package/dist/shared/lib/compare-value.js +73 -0
  39. package/dist/shared/lib/format-value.js +19 -18
  40. package/dist/shared/lib/obligation-reason-text.js +1 -1
  41. package/dist/shared/lib/quick-filter-cascade.js +29 -19
  42. package/dist/shared/lib/utils.js +59 -57
  43. package/package.json +1 -1
@@ -1,161 +1,163 @@
1
- import { jsx as l, jsxs as d } from "react/jsx-runtime";
1
+ import { jsx as r, jsxs as c } from "react/jsx-runtime";
2
2
  import { useQuery as q } from "@tanstack/react-query";
3
- import { ChevronDown as re, Loader2 as ce, AlertTriangle as ue, X as de, Check as me } from "lucide-react";
4
- import { useState as se, useRef as fe, useEffect as pe } from "react";
5
- import { useNivaroClient as he, useItemEditAuth as be, useDrilldown as Je } from "../../context.js";
6
- import { parseAllowedCollections as Pe } from "../../lib/allowed-collections.js";
3
+ import { ChevronDown as ae, Loader2 as ue, AlertTriangle as he, X as me, Check as ye } from "lucide-react";
4
+ import { useState as E, useRef as fe, useEffect as pe } from "react";
5
+ import { useNivaroClient as be, useItemEditAuth as xe, useDrilldown as Ee } from "../../context.js";
6
+ import { parseAllowedCollections as Re } from "../../lib/allowed-collections.js";
7
7
  import { get as U } from "../../lib/commands.js";
8
- import { compareByMatch as ye } from "../../lib/picker-rank.js";
9
- import { useRecordReader as Ee } from "../../lib/record-loader.js";
10
- import { useOnlineUsers as xe } from "../../lib/use-online-users.js";
11
- import { cn as Q, userOptionFilter as ge, matchesAllTokens as Re } from "../../lib/utils.js";
12
- import { UserAvatar as ve } from "../UserAvatar.js";
13
- import { Command as ke, CommandInput as we, CommandList as Se, CommandEmpty as Ne, CommandGroup as _e, CommandItem as Le } from "../ui/command.js";
14
- import { Popover as Ce, PopoverTrigger as Oe, PopoverContent as qe } from "../ui/popover.js";
15
- import { applyDisplayTemplate as Fe } from "./helpers.js";
16
- import { useM2MStaging as je } from "./M2MStagingContext.js";
17
- import { useStaleTip as ze, RelatedItemLabel as oe } from "./RelationCombobox.js";
18
- function Te(n) {
8
+ import { compareByMatch as ge } from "../../lib/picker-rank.js";
9
+ import { useRecordReader as ze } from "../../lib/record-loader.js";
10
+ import { useOnlineUsers as ve } from "../../lib/use-online-users.js";
11
+ import { cn as X, userOptionFilter as ke, matchesAllTokens as Ge } from "../../lib/utils.js";
12
+ import { UserAvatar as we } from "../UserAvatar.js";
13
+ import { Command as Se, CommandInput as Ne, CommandList as _e, CommandEmpty as Ce, CommandGroup as Le, CommandItem as Oe } from "../ui/command.js";
14
+ import { Popover as Fe, PopoverTrigger as qe, PopoverContent as je } from "../ui/popover.js";
15
+ import { applyDisplayTemplate as Te } from "./helpers.js";
16
+ import { useM2MStaging as Ae } from "./M2MStagingContext.js";
17
+ import { onlyCloseMatches as Ve } from "./picker-search.js";
18
+ import { useStaleTip as Be, RelatedItemLabel as de } from "./RelationCombobox.js";
19
+ function Ie(n) {
19
20
  return n.replace(/\(.*$/, "").trim().split(/\s+/).map((i) => i[0]).filter(Boolean).slice(0, 2).join("").toUpperCase() || "?";
20
21
  }
21
- function Ie(n) {
22
- return Pe(n == null ? void 0 : n.one_allowed_collections);
22
+ function Ue(n) {
23
+ return Re(n == null ? void 0 : n.one_allowed_collections);
23
24
  }
24
- function Ae(n) {
25
+ function Ke(n) {
25
26
  if (!n) return null;
26
27
  if (n.one_collection) return n.one_collection;
27
- const i = Ie(n);
28
- return i.length === 0 ? null : i.some((p) => p === "directus_users" || p === "nivaro_users") ? "nivaro_users" : i[0];
28
+ const i = Ue(n);
29
+ return i.length === 0 ? null : i.some((f) => f === "directus_users" || f === "nivaro_users") ? "nivaro_users" : i[0];
29
30
  }
30
- function ot(n) {
31
+ function ft(n) {
31
32
  if (!n || n.one_collection) return null;
32
- const i = Ie(n);
33
+ const i = Ue(n);
33
34
  if (i.length === 0) return null;
34
- const p = i.includes("directus_users") ? "directus_users" : i.includes("nivaro_users") ? "nivaro_users" : i[0];
35
- return { field: n.one_collection_field ?? "collection", value: p };
35
+ const f = i.includes("directus_users") ? "directus_users" : i.includes("nivaro_users") ? "nivaro_users" : i[0];
36
+ return { field: n.one_collection_field ?? "collection", value: f };
36
37
  }
37
- function W(n) {
38
+ function Q(n) {
38
39
  return String(n).toLowerCase();
39
40
  }
40
- function ct({
41
+ function pt({
41
42
  relation: n,
42
43
  parentId: i,
43
- allRelations: p,
44
- extraFilter: u,
45
- optionSort: h,
46
- requiredParent: N,
47
- onCountChange: _,
48
- drilldown: F
44
+ allRelations: f,
45
+ extraFilter: d,
46
+ optionSort: p,
47
+ requiredParent: w,
48
+ onCountChange: x,
49
+ drilldown: b
49
50
  }) {
50
- const x = he(), T = Je(), t = je(), [k, v] = se(!1), [y, L] = se(""), I = p.find(
51
+ const v = be(), A = Ee(), t = Ae(), [N, S] = E(!1), [m, L] = E(""), j = f.find(
51
52
  (e) => e.many_collection === n.many_collection && e.many_field === n.junction_field && e.id !== n.id
52
- ), s = Ae(I), C = n.junction_field ?? "", P = n.many_field ?? "", m = n.one_field ?? `${n.many_collection}.${C}`, { data: o } = q({
53
+ ), s = Ke(j), O = n.junction_field ?? "", R = n.many_field ?? "", h = n.one_field ?? `${n.many_collection}.${O}`, { data: o } = q({
53
54
  queryKey: ["col-meta", s],
54
- queryFn: () => x.request(U(`/collections/${s}`)).then((e) => e.data),
55
+ queryFn: () => v.request(U(`/collections/${s}`)).then((e) => e.data),
55
56
  enabled: !!s,
56
57
  staleTime: 3e5,
57
58
  retry: !1
58
- }), { data: X = [] } = q({
59
- queryKey: ["m2m-items", n.many_collection, P, i],
60
- queryFn: () => x.request(
59
+ }), { data: H = [] } = q({
60
+ queryKey: ["m2m-items", n.many_collection, R, i],
61
+ queryFn: () => v.request(
61
62
  U(`/items/${n.many_collection}`, {
62
- filter: JSON.stringify({ [P]: { _eq: i } }),
63
+ filter: JSON.stringify({ [R]: { _eq: i } }),
63
64
  limit: 200,
64
- fields: `id,${C}`
65
+ fields: `id,${O}`
65
66
  })
66
67
  ).then((e) => e.data ?? []),
67
68
  staleTime: 3e4,
68
69
  enabled: !!i && i !== "new"
69
- }), ae = be().isAdmin, E = s === "nivaro_users" ? ge(ae) : null, R = xe(s === "nivaro_users"), H = u ? E ? { _and: [u, E] } : u : E, z = H ? JSON.stringify(H) : void 0, M = h && !/^-?label$/.test(h) ? h : void 0, Y = (() => {
70
+ }), ce = xe().isAdmin, z = s === "nivaro_users" ? ke(ce) : null, G = ve(s === "nivaro_users"), Y = d ? z ? { _and: [d, z] } : d : z, V = Y ? JSON.stringify(Y) : void 0, B = p && !/^-?label$/.test(p) ? p : void 0, Z = (() => {
70
71
  const e = o == null ? void 0 : o.display_template;
71
72
  if (!e || !e.includes(".")) return null;
72
- const a = [...e.matchAll(/\{\{([^}]+)\}\}/g)].map((c) => c[1].trim());
73
+ const a = [...e.matchAll(/\{\{([^}]+)\}\}/g)].map((u) => u[1].trim());
73
74
  return a.length === 0 ? null : ["id", ...a].join(",");
74
75
  })(), {
75
- options: Z,
76
- isLoading: B,
77
- localSearch: G
78
- } = Ue({
79
- client: x,
76
+ options: ee,
77
+ isLoading: K,
78
+ localSearch: $,
79
+ closeMatches: te
80
+ } = $e({
81
+ client: v,
80
82
  relatedCollection: s,
81
- search: y,
82
- filterParam: z,
83
- serverSort: M,
84
- templateNestedFields: Y,
85
- enabled: k && !!s,
86
- labelOf: w
87
- }), ee = (t == null ? void 0 : t.getStagedLinks(m)) ?? [], O = (t == null ? void 0 : t.getStagedUnlinks(m)) ?? /* @__PURE__ */ new Set(), K = X.filter((e) => !O.has(e.id)), g = new Set(K.map((e) => String(e[C]))), j = [...g], te = JSON.stringify(u ? { _and: [{ id: { _in: j } }, u] } : { id: { _in: j } }), { data: f } = q({
88
- queryKey: ["m2m-avail", s, j.join(","), z],
89
- queryFn: () => x.request(
83
+ search: m,
84
+ filterParam: V,
85
+ serverSort: B,
86
+ templateNestedFields: Z,
87
+ enabled: N && !!s,
88
+ labelOf: _
89
+ }), ne = Pe(!!te, m), re = (t == null ? void 0 : t.getStagedLinks(h)) ?? [], F = (t == null ? void 0 : t.getStagedUnlinks(h)) ?? /* @__PURE__ */ new Set(), D = H.filter((e) => !F.has(e.id)), k = new Set(D.map((e) => String(e[O]))), T = [...k], le = JSON.stringify(d ? { _and: [{ id: { _in: T } }, d] } : { id: { _in: T } }), { data: y } = q({
90
+ queryKey: ["m2m-avail", s, T.join(","), V],
91
+ queryFn: () => v.request(
90
92
  U(`/items/${s}`, {
91
- filter: te,
93
+ filter: le,
92
94
  picker: "1",
93
95
  limit: 200,
94
96
  fields: "id"
95
97
  })
96
98
  ).then((e) => e.data ?? []),
97
- enabled: !!s && j.length > 0,
99
+ enabled: !!s && T.length > 0,
98
100
  staleTime: 3e4
99
- }), ne = new Set((f ?? []).map((e) => String(e.id))), $ = f !== void 0 ? new Set(j.filter((e) => !ne.has(e))) : /* @__PURE__ */ new Set(), D = new Set(ee.map(W)), J = /* @__PURE__ */ new Set([...[...g].map(W), ...D]), A = fe(_);
100
- A.current = _, pe(() => {
101
+ }), se = new Set((y ?? []).map((e) => String(e.id))), P = y !== void 0 ? new Set(T.filter((e) => !se.has(e))) : /* @__PURE__ */ new Set(), J = new Set(re.map(Q)), M = /* @__PURE__ */ new Set([...[...k].map(Q), ...J]), I = fe(x);
102
+ I.current = x, pe(() => {
101
103
  var e;
102
- (e = A.current) == null || e.call(A, J.size);
103
- }, [J.size]);
104
- function V(e) {
105
- const a = W(e);
106
- if (D.has(a)) {
107
- t == null || t.unstageLink(m, e);
104
+ (e = I.current) == null || e.call(I, M.size);
105
+ }, [M.size]);
106
+ function W(e) {
107
+ const a = Q(e);
108
+ if (J.has(a)) {
109
+ t == null || t.unstageLink(h, e);
108
110
  return;
109
111
  }
110
- const c = X.find((S) => W(S[C]) === a);
111
- if (c) {
112
- O.has(c.id) ? t == null || t.unstageUnlink(m, c.id) : t == null || t.stageUnlink(m, c.id);
112
+ const u = H.find((C) => Q(C[O]) === a);
113
+ if (u) {
114
+ F.has(u.id) ? t == null || t.unstageUnlink(h, u.id) : t == null || t.stageUnlink(h, u.id);
113
115
  return;
114
116
  }
115
- t == null || t.stageLink(m, e);
117
+ t == null || t.stageLink(h, e);
116
118
  }
117
- function w(e) {
119
+ function _(e) {
118
120
  const a = (o == null ? void 0 : o.display_template) ?? null;
119
- return a ? Fe(a, e) : String(e._display ?? e.id ?? "");
121
+ return a ? Te(a, e) : String(e._display ?? e.id ?? "");
120
122
  }
121
- return N ? /* @__PURE__ */ d(
123
+ return w ? /* @__PURE__ */ c(
122
124
  "button",
123
125
  {
124
126
  type: "button",
125
127
  disabled: !0,
126
128
  className: "flex h-9 w-full items-center justify-between gap-2 rounded-md border border-input bg-background px-3 text-sm text-muted-foreground opacity-50 cursor-not-allowed",
127
129
  children: [
128
- /* @__PURE__ */ d("span", { className: "truncate", children: [
130
+ /* @__PURE__ */ c("span", { className: "truncate", children: [
129
131
  "Select ",
130
- N,
132
+ w,
131
133
  " first"
132
134
  ] }),
133
- /* @__PURE__ */ l(re, { className: "h-4 w-4 shrink-0 opacity-50" })
135
+ /* @__PURE__ */ r(ae, { className: "h-4 w-4 shrink-0 opacity-50" })
134
136
  ]
135
137
  }
136
- ) : /* @__PURE__ */ l("div", { children: /* @__PURE__ */ d(
137
- Ce,
138
+ ) : /* @__PURE__ */ r("div", { children: /* @__PURE__ */ c(
139
+ Fe,
138
140
  {
139
- open: k,
141
+ open: N,
140
142
  onOpenChange: (e) => {
141
- v(e), e || L("");
143
+ S(e), e || L("");
142
144
  },
143
145
  children: [
144
- /* @__PURE__ */ l(Oe, { asChild: !0, children: /* @__PURE__ */ d(
146
+ /* @__PURE__ */ r(qe, { asChild: !0, children: /* @__PURE__ */ c(
145
147
  "div",
146
148
  {
147
149
  role: "button",
148
150
  tabIndex: 0,
149
151
  onKeyDown: (e) => {
150
- if (e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey && (k || y !== "" || e.key !== " ")) {
152
+ if (e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey && (N || m !== "" || e.key !== " ")) {
151
153
  e.preventDefault();
152
- const c = e.key;
153
- L((S) => c === " " && (S === "" || S.endsWith(" ")) ? S : S + c), k || v(!0);
154
- } else (e.key === "Enter" || e.key === " " || !k && e.key === "ArrowDown") && (e.preventDefault(), v((c) => !c));
154
+ const u = e.key;
155
+ L((C) => u === " " && (C === "" || C.endsWith(" ")) ? C : C + u), N || S(!0);
156
+ } else (e.key === "Enter" || e.key === " " || !N && e.key === "ArrowDown") && (e.preventDefault(), S((u) => !u));
155
157
  },
156
158
  className: "flex min-h-9 w-full cursor-pointer items-center justify-between gap-2 rounded-md border border-input bg-background px-3 py-1 text-sm text-left font-normal hover:bg-muted",
157
159
  children: [
158
- J.size > 0 ? /* @__PURE__ */ d(
160
+ M.size > 0 ? /* @__PURE__ */ c(
159
161
  "span",
160
162
  {
161
163
  className: "flex min-w-0 flex-1 flex-wrap items-center gap-1",
@@ -163,32 +165,32 @@ function ct({
163
165
  e.target.closest("button") && e.stopPropagation();
164
166
  },
165
167
  children: [
166
- K.map((e) => {
167
- const a = e[C], c = $.has(String(a));
168
- return /* @__PURE__ */ d(
168
+ D.map((e) => {
169
+ const a = e[O], u = P.has(String(a));
170
+ return /* @__PURE__ */ c(
169
171
  "span",
170
172
  {
171
- title: c ? "This record is no longer an available option" : void 0,
172
- className: Q(
173
+ title: u ? "This record is no longer an available option" : void 0,
174
+ className: X(
173
175
  "inline-flex items-center gap-1 rounded-full border pl-2.5 pr-1.5 py-0.5 text-[12px]",
174
- c ? "border-amber-300 bg-amber-50 text-amber-700 dark:border-amber-600 dark:bg-amber-950/30 dark:text-amber-400" : "border-slate-200 bg-slate-50 text-slate-700 dark:border-border dark:bg-muted dark:text-slate-200"
176
+ u ? "border-amber-300 bg-amber-50 text-amber-700 dark:border-amber-600 dark:bg-amber-950/30 dark:text-amber-400" : "border-slate-200 bg-slate-50 text-slate-700 dark:border-border dark:bg-muted dark:text-slate-200"
175
177
  ),
176
178
  children: [
177
- c && /* @__PURE__ */ l(ue, { className: "h-3 w-3 shrink-0 text-amber-500" }),
178
- s && (F && T ? /* @__PURE__ */ l(
179
+ u && /* @__PURE__ */ r(he, { className: "h-3 w-3 shrink-0 text-amber-500" }),
180
+ s && (b && A ? /* @__PURE__ */ r(
179
181
  "button",
180
182
  {
181
183
  type: "button",
182
184
  title: "Open detail panel",
183
- onClick: () => T.open({
185
+ onClick: () => A.open({
184
186
  collection: s,
185
187
  itemId: String(a),
186
- layoutId: F.layout_id,
187
- width: F.width
188
+ layoutId: b.layout_id,
189
+ width: b.width
188
190
  }),
189
191
  className: "underline decoration-slate-300 decoration-dotted underline-offset-2 hover:text-[#172940] hover:decoration-nvr-cyan dark:hover:text-nvr-cyan",
190
- children: /* @__PURE__ */ l(
191
- oe,
192
+ children: /* @__PURE__ */ r(
193
+ de,
192
194
  {
193
195
  collection: s,
194
196
  id: a,
@@ -196,22 +198,22 @@ function ct({
196
198
  }
197
199
  )
198
200
  }
199
- ) : /* @__PURE__ */ l(
200
- oe,
201
+ ) : /* @__PURE__ */ r(
202
+ de,
201
203
  {
202
204
  collection: s,
203
205
  id: a,
204
206
  displayTemplate: o == null ? void 0 : o.display_template
205
207
  }
206
208
  )),
207
- /* @__PURE__ */ l(
209
+ /* @__PURE__ */ r(
208
210
  "button",
209
211
  {
210
212
  type: "button",
211
213
  "aria-label": "Remove",
212
- onClick: () => t == null ? void 0 : t.stageUnlink(m, e.id),
214
+ onClick: () => t == null ? void 0 : t.stageUnlink(h, e.id),
213
215
  className: "rounded-full p-0.5 text-slate-400 hover:text-red-500",
214
- children: /* @__PURE__ */ l(de, { className: "h-3 w-3" })
216
+ children: /* @__PURE__ */ r(me, { className: "h-3 w-3" })
215
217
  }
216
218
  )
217
219
  ]
@@ -219,27 +221,27 @@ function ct({
219
221
  String(e.id)
220
222
  );
221
223
  }),
222
- ee.map((e) => /* @__PURE__ */ d(
224
+ re.map((e) => /* @__PURE__ */ c(
223
225
  "span",
224
226
  {
225
227
  className: "inline-flex items-center gap-1 rounded-full border border-dashed border-nvr-cyan/50 bg-nvr-cyan/5 pl-2.5 pr-1.5 py-0.5 text-[12px] text-slate-600 dark:text-slate-300",
226
228
  children: [
227
- s ? /* @__PURE__ */ l(
228
- oe,
229
+ s ? /* @__PURE__ */ r(
230
+ de,
229
231
  {
230
232
  collection: s,
231
233
  id: e,
232
234
  displayTemplate: o == null ? void 0 : o.display_template
233
235
  }
234
236
  ) : String(e),
235
- /* @__PURE__ */ l(
237
+ /* @__PURE__ */ r(
236
238
  "button",
237
239
  {
238
240
  type: "button",
239
241
  "aria-label": "Remove",
240
- onClick: () => t == null ? void 0 : t.unstageLink(m, e),
242
+ onClick: () => t == null ? void 0 : t.unstageLink(h, e),
241
243
  className: "rounded-full p-0.5 text-slate-400 hover:text-red-500",
242
- children: /* @__PURE__ */ l(de, { className: "h-3 w-3" })
244
+ children: /* @__PURE__ */ r(me, { className: "h-3 w-3" })
243
245
  }
244
246
  )
245
247
  ]
@@ -248,327 +250,390 @@ function ct({
248
250
  ))
249
251
  ]
250
252
  }
251
- ) : /* @__PURE__ */ l("span", { className: "truncate text-muted-foreground", children: "Select items…" }),
252
- /* @__PURE__ */ l(re, { className: "h-4 w-4 shrink-0 opacity-50" })
253
+ ) : /* @__PURE__ */ r("span", { className: "truncate text-muted-foreground", children: "Select items…" }),
254
+ /* @__PURE__ */ r(ae, { className: "h-4 w-4 shrink-0 opacity-50" })
253
255
  ]
254
256
  }
255
257
  ) }),
256
- /* @__PURE__ */ l(qe, { className: "w-[320px] p-0", align: "start", children: /* @__PURE__ */ d(ke, { shouldFilter: !1, children: [
257
- /* @__PURE__ */ l(
258
- we,
259
- {
260
- placeholder: "Search…",
261
- value: y,
262
- onValueChange: L,
263
- className: "h-9 text-[13px]"
264
- }
265
- ),
266
- /* @__PURE__ */ d(Se, { children: [
267
- B ? /* @__PURE__ */ l("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ l(ce, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : /* @__PURE__ */ l(Ne, { className: "py-3 text-left text-[12px] text-muted-foreground px-3", children: "No results" }),
268
- /* @__PURE__ */ l(_e, { children: !B && (M ? [...ie(Z, y, G, w)] : [...ie(Z, y, G, w)].sort(
269
- (e, a) => ye(w(e), w(a), y, h === "-label")
270
- )).map((e) => {
271
- const a = String(e.id), c = J.has(W(a));
272
- return /* @__PURE__ */ d(
273
- Le,
258
+ /* @__PURE__ */ r(je, { className: "w-[320px] p-0", align: "start", children: /* @__PURE__ */ c(
259
+ Se,
260
+ {
261
+ shouldFilter: !1,
262
+ ...ne,
263
+ children: [
264
+ /* @__PURE__ */ r(
265
+ Ne,
274
266
  {
275
- value: a,
276
- onSelect: () => V(e.id),
277
- className: "flex items-center gap-2 text-[13px]",
278
- children: [
279
- /* @__PURE__ */ l(
280
- "div",
281
- {
282
- className: Q(
283
- "flex h-4 w-4 shrink-0 items-center justify-center rounded border",
284
- c ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300 dark:border-slate-500"
267
+ placeholder: "Search…",
268
+ value: m,
269
+ onValueChange: L,
270
+ className: "h-9 text-[13px]"
271
+ }
272
+ ),
273
+ /* @__PURE__ */ c(_e, { children: [
274
+ K ? /* @__PURE__ */ r("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ r(ue, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : /* @__PURE__ */ r(Ce, { className: "py-3 text-left text-[12px] text-muted-foreground px-3", children: "No results" }),
275
+ !K && te && /* @__PURE__ */ c(
276
+ "p",
277
+ {
278
+ "data-picker-close-matches": !0,
279
+ className: "px-3 pb-1 pt-2 text-[11.5px] text-muted-foreground",
280
+ children: [
281
+ "No exact match for “",
282
+ m.trim(),
283
+ "” — did you mean:"
284
+ ]
285
+ }
286
+ ),
287
+ /* @__PURE__ */ r(Le, { children: !K && (B ? [...oe(ee, m, $, _)] : [...oe(ee, m, $, _)].sort(
288
+ (e, a) => ge(_(e), _(a), m, p === "-label")
289
+ )).map((e) => {
290
+ const a = String(e.id), u = M.has(Q(a));
291
+ return /* @__PURE__ */ c(
292
+ Oe,
293
+ {
294
+ value: a,
295
+ onSelect: () => W(e.id),
296
+ className: "flex items-center gap-2 text-[13px]",
297
+ children: [
298
+ /* @__PURE__ */ r(
299
+ "div",
300
+ {
301
+ className: X(
302
+ "flex h-4 w-4 shrink-0 items-center justify-center rounded border",
303
+ u ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300 dark:border-slate-500"
304
+ ),
305
+ children: u && /* @__PURE__ */ r(ye, { className: "h-2.5 w-2.5 text-white" })
306
+ }
285
307
  ),
286
- children: c && /* @__PURE__ */ l(me, { className: "h-2.5 w-2.5 text-white" })
287
- }
288
- ),
289
- s === "nivaro_users" && /* @__PURE__ */ l(
290
- ve,
291
- {
292
- userId: a,
293
- className: "h-4 w-4",
294
- fallback: /* @__PURE__ */ l("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: Te(w(e)) })
295
- }
296
- ),
297
- s === "nivaro_users" && R.has(a.toUpperCase()) && /* @__PURE__ */ l(
298
- "span",
299
- {
300
- className: "h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500",
301
- "data-tip": "Online now"
302
- }
303
- ),
304
- /* @__PURE__ */ l("span", { className: "truncate", children: w(e) })
305
- ]
306
- },
307
- a
308
- );
309
- }) })
310
- ] })
311
- ] }) })
308
+ s === "nivaro_users" && /* @__PURE__ */ r(
309
+ we,
310
+ {
311
+ userId: a,
312
+ className: "h-4 w-4",
313
+ fallback: /* @__PURE__ */ r("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-nvr-cyan/20 text-[8px] font-bold text-nvr-navy dark:text-nvr-cyan", children: Ie(_(e)) })
314
+ }
315
+ ),
316
+ s === "nivaro_users" && G.has(a.toUpperCase()) && /* @__PURE__ */ r(
317
+ "span",
318
+ {
319
+ className: "h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500",
320
+ "data-tip": "Online now"
321
+ }
322
+ ),
323
+ /* @__PURE__ */ r("span", { className: "truncate", children: _(e) })
324
+ ]
325
+ },
326
+ a
327
+ );
328
+ }) })
329
+ ] })
330
+ ]
331
+ }
332
+ ) })
312
333
  ]
313
334
  }
314
335
  ) });
315
336
  }
316
- function Ue(n) {
317
- const { client: i, relatedCollection: p, search: u, filterParam: h, serverSort: N, templateNestedFields: _ } = n, F = (I) => i.request(
318
- U(`/items/${p}`, {
319
- limit: Ke,
320
- search: I || void 0,
321
- filter: h,
337
+ function $e(n) {
338
+ const { client: i, relatedCollection: f, search: d, filterParam: p, serverSort: w, templateNestedFields: x } = n, b = (j) => i.request(
339
+ U(`/items/${f}`, {
340
+ limit: De,
341
+ search: j || void 0,
342
+ // Typo pass (fix11-search): close matches only when the exact search finds nothing.
343
+ ...j ? { typo: "1" } : {},
344
+ filter: p,
322
345
  picker: "1",
323
346
  // A dotted display template ({{core_category.name}}) needs the
324
347
  // nested expansion — a bare row only carries the FK id.
325
- ..._ ? { fields: _ } : {},
326
- ...N ? { sort: N } : {}
348
+ ...x ? { fields: x } : {},
349
+ ...w ? { sort: w } : {}
327
350
  })
328
- ).then((s) => s.data ?? []), x = (I) => [
351
+ ).then((s) => s.data ?? []), v = (j) => [
329
352
  "m2m-options",
353
+ f,
354
+ j,
330
355
  p,
331
- I,
332
- h,
333
- N ?? "",
334
- _ ?? ""
335
- ], T = h ? 0 : 3e4, { data: t, isFetching: k } = q({
336
- queryKey: x(""),
337
- queryFn: () => F(""),
356
+ w ?? "",
357
+ x ?? ""
358
+ ], A = p ? 0 : 3e4, { data: t, isFetching: N } = q({
359
+ queryKey: v(""),
360
+ queryFn: () => b(""),
338
361
  enabled: n.enabled,
339
- staleTime: T
340
- }), v = Me(t, u, n.labelOf), { data: y, isFetching: L } = q({
341
- queryKey: x(u),
342
- queryFn: () => F(u),
343
- enabled: n.enabled && v,
344
- staleTime: T
362
+ staleTime: A
363
+ }), S = We(t, d, n.labelOf), { data: m, isFetching: L } = q({
364
+ queryKey: v(d),
365
+ queryFn: () => b(d),
366
+ enabled: n.enabled && S,
367
+ staleTime: A
345
368
  });
346
- return v ? { options: y ?? [], isLoading: !y && L, localSearch: !1 } : { options: t ?? [], isLoading: !t && k, localSearch: !!u };
369
+ return S ? {
370
+ options: m ?? [],
371
+ isLoading: !m && L,
372
+ localSearch: !1,
373
+ closeMatches: Ve(m)
374
+ } : { options: t ?? [], isLoading: !t && N, localSearch: !!d };
347
375
  }
348
- const Ke = 200;
349
- function Me(n, i, p) {
350
- return i.trim() ? !n || n.length >= Ke ? !0 : ie(n, i, !0, p).length === 0 : !1;
376
+ const De = 200;
377
+ function We(n, i, f) {
378
+ return i.trim() ? !n || n.length >= De ? !0 : oe(n, i, !0, f).length === 0 : !1;
351
379
  }
352
- function ie(n, i, p, u) {
353
- return !p || !i.trim() ? n : n.filter((h) => Re(u(h), i));
380
+ function oe(n, i, f, d) {
381
+ return !f || !i.trim() ? n : n.filter((p) => Ge(d(p), i));
354
382
  }
355
- function dt({
383
+ function ht({
356
384
  relation: n,
357
385
  parentId: i,
358
- allRelations: p,
359
- extraFilter: u,
360
- optionSort: h,
361
- requiredParent: N,
362
- onCountChange: _,
363
- readOnly: F
386
+ allRelations: f,
387
+ extraFilter: d,
388
+ optionSort: p,
389
+ requiredParent: w,
390
+ onCountChange: x,
391
+ readOnly: b
364
392
  }) {
365
- const x = he(), T = Ee(), t = je(), [k, v] = se(!1), [y, L] = se(""), I = p.find(
366
- (r) => r.many_collection === n.many_collection && r.many_field === n.junction_field && r.id !== n.id
367
- ), s = Ae(I), C = n.junction_field ?? "", P = n.many_field ?? "", m = n.one_field ?? `${n.many_collection}.${C}`, { data: o } = q({
393
+ const v = be(), A = ze(), t = Ae(), [N, S] = E(!1), [m, L] = E(""), j = f.find(
394
+ (l) => l.many_collection === n.many_collection && l.many_field === n.junction_field && l.id !== n.id
395
+ ), s = Ke(j), O = n.junction_field ?? "", R = n.many_field ?? "", h = n.one_field ?? `${n.many_collection}.${O}`, { data: o } = q({
368
396
  queryKey: ["col-meta", s],
369
- queryFn: () => x.request(U(`/collections/${s}`)).then((r) => r.data),
397
+ queryFn: () => v.request(U(`/collections/${s}`)).then((l) => l.data),
370
398
  enabled: !!s,
371
399
  staleTime: 3e5,
372
400
  retry: !1
373
- }), { data: X = [], isFetching: ae } = q({
374
- queryKey: ["m2m-items", n.many_collection, P, i],
375
- queryFn: () => x.request(
401
+ }), { data: H = [], isFetching: ce } = q({
402
+ queryKey: ["m2m-items", n.many_collection, R, i],
403
+ queryFn: () => v.request(
376
404
  U(`/items/${n.many_collection}`, {
377
- filter: JSON.stringify({ [P]: { _eq: i } }),
405
+ filter: JSON.stringify({ [R]: { _eq: i } }),
378
406
  limit: 1,
379
- fields: `id,${C}`
407
+ fields: `id,${O}`
380
408
  })
381
- ).then((r) => r.data ?? []),
409
+ ).then((l) => l.data ?? []),
382
410
  staleTime: 3e4,
383
411
  enabled: !!i && i !== "new"
384
- }), E = be().isAdmin, R = s === "nivaro_users" ? ge(E) : null, H = xe(s === "nivaro_users"), z = u ? R ? { _and: [u, R] } : u : R, M = z ? JSON.stringify(z) : void 0, Y = h && !/^-?label$/.test(h) ? h : void 0, Z = (() => {
385
- const r = o == null ? void 0 : o.display_template;
386
- if (!r || !r.includes(".")) return null;
387
- const b = [...r.matchAll(/\{\{([^}]+)\}\}/g)].map((le) => le[1].trim());
388
- return b.length === 0 ? null : ["id", ...b].join(",");
412
+ }), z = xe().isAdmin, G = s === "nivaro_users" ? ke(z) : null, Y = ve(s === "nivaro_users"), V = d ? G ? { _and: [d, G] } : d : G, B = V ? JSON.stringify(V) : void 0, Z = p && !/^-?label$/.test(p) ? p : void 0, ee = (() => {
413
+ const l = o == null ? void 0 : o.display_template;
414
+ if (!l || !l.includes(".")) return null;
415
+ const g = [...l.matchAll(/\{\{([^}]+)\}\}/g)].map((ie) => ie[1].trim());
416
+ return g.length === 0 ? null : ["id", ...g].join(",");
389
417
  })(), {
390
- options: B,
391
- isLoading: G,
392
- localSearch: ee
393
- } = Ue({
394
- client: x,
418
+ options: K,
419
+ isLoading: $,
420
+ localSearch: te,
421
+ closeMatches: ne
422
+ } = $e({
423
+ client: v,
395
424
  relatedCollection: s,
396
- search: y,
397
- filterParam: M,
398
- serverSort: Y,
399
- templateNestedFields: Z,
400
- enabled: k && !!s,
425
+ search: m,
426
+ filterParam: B,
427
+ serverSort: Z,
428
+ templateNestedFields: ee,
429
+ enabled: N && !!s,
401
430
  labelOf: e
402
- }), O = (t == null ? void 0 : t.getStagedLinks(m)) ?? [], K = (t == null ? void 0 : t.getStagedUnlinks(m)) ?? /* @__PURE__ */ new Set(), g = X.find((r) => !K.has(r.id)) ?? null, j = g ? g[C] : null, te = O.length > 0 ? O[O.length - 1] : null, f = te ?? j, ne = O.length > 0 || K.size > 0, $ = fe(_);
403
- $.current = _, pe(() => {
404
- var r;
405
- (r = $.current) == null || r.call($, f != null ? 1 : 0);
406
- }, [f]);
407
- const { data: D } = q({
408
- queryKey: ["relation-single", s, String(f)],
409
- queryFn: () => T(s, f),
410
- enabled: !!s && f != null,
431
+ }), re = Pe(!!ne, m), F = (t == null ? void 0 : t.getStagedLinks(h)) ?? [], D = (t == null ? void 0 : t.getStagedUnlinks(h)) ?? /* @__PURE__ */ new Set(), k = H.find((l) => !D.has(l.id)) ?? null, T = k ? k[O] : null, le = F.length > 0 ? F[F.length - 1] : null, y = le ?? T, se = F.length > 0 || D.size > 0, P = fe(x);
432
+ P.current = x, pe(() => {
433
+ var l;
434
+ (l = P.current) == null || l.call(P, y != null ? 1 : 0);
435
+ }, [y]);
436
+ const { data: J } = q({
437
+ queryKey: ["relation-single", s, String(y)],
438
+ queryFn: () => A(s, y),
439
+ enabled: !!s && y != null,
411
440
  staleTime: 6e4
412
- }), J = JSON.stringify(u ? { _and: [{ id: { _eq: f } }, u] } : { id: { _eq: f } }), { data: A } = q({
413
- queryKey: ["relation-avail", s, String(f), M],
414
- queryFn: () => x.request(
441
+ }), M = JSON.stringify(d ? { _and: [{ id: { _eq: y } }, d] } : { id: { _eq: y } }), { data: I } = q({
442
+ queryKey: ["relation-avail", s, String(y), B],
443
+ queryFn: () => v.request(
415
444
  U(`/items/${s}`, {
416
- filter: J,
445
+ filter: M,
417
446
  picker: "1",
418
447
  limit: 1,
419
448
  fields: "id"
420
449
  })
421
- ).then((r) => r.data ?? []),
422
- enabled: !!s && f != null && !!D,
450
+ ).then((l) => l.data ?? []),
451
+ enabled: !!s && y != null && !!J,
423
452
  staleTime: 3e4
424
- }), V = A !== void 0 && A.length === 0, w = ze(V);
425
- function e(r) {
426
- const b = (o == null ? void 0 : o.display_template) ?? null;
427
- return b ? Fe(b, r) : String(r.name ?? r.title ?? r.label ?? r.id ?? "");
453
+ }), W = I !== void 0 && I.length === 0, _ = Be(W);
454
+ function e(l) {
455
+ const g = (o == null ? void 0 : o.display_template) ?? null;
456
+ return g ? Te(g, l) : String(l.name ?? l.title ?? l.label ?? l.id ?? "");
428
457
  }
429
- const a = B.find((r) => String(r.id) === String(f)) ?? D, c = f != null && !D && !a, S = a ? e(a) : null;
430
- if (F)
431
- return /* @__PURE__ */ l("span", { className: "block truncate text-[12px] text-slate-700 dark:text-slate-200", children: c ? "…" : S ?? "—" });
432
- function $e(r) {
433
- for (const b of O) t == null || t.unstageLink(m, b);
434
- g && !K.has(g.id) && (t == null || t.stageUnlink(m, g.id)), String(r) === String(j) && g ? t == null || t.unstageUnlink(m, g.id) : String(r) !== String(f) && (t == null || t.stageLink(m, r)), v(!1), L("");
458
+ const a = K.find((l) => String(l.id) === String(y)) ?? J, u = y != null && !J && !a, C = a ? e(a) : null;
459
+ if (b)
460
+ return /* @__PURE__ */ r("span", { className: "block truncate text-[12px] text-slate-700 dark:text-slate-200", children: u ? "…" : C ?? "—" });
461
+ function Je(l) {
462
+ for (const g of F) t == null || t.unstageLink(h, g);
463
+ k && !D.has(k.id) && (t == null || t.stageUnlink(h, k.id)), String(l) === String(T) && k ? t == null || t.unstageUnlink(h, k.id) : String(l) !== String(y) && (t == null || t.stageLink(h, l)), S(!1), L("");
435
464
  }
436
- function De() {
437
- for (const r of O) t == null || t.unstageLink(m, r);
438
- g && (t == null || t.stageUnlink(m, g.id)), v(!1);
465
+ function Me() {
466
+ for (const l of F) t == null || t.unstageLink(h, l);
467
+ k && (t == null || t.stageUnlink(h, k.id)), S(!1);
439
468
  }
440
- return N ? /* @__PURE__ */ d(
469
+ return w ? /* @__PURE__ */ c(
441
470
  "button",
442
471
  {
443
472
  type: "button",
444
473
  disabled: !0,
445
474
  className: "w-full h-9 px-3 text-[12px] border border-input rounded-md bg-background text-left flex items-center justify-between opacity-50 cursor-not-allowed",
446
475
  children: [
447
- /* @__PURE__ */ d("span", { className: "truncate text-muted-foreground", children: [
476
+ /* @__PURE__ */ c("span", { className: "truncate text-muted-foreground", children: [
448
477
  "Select ",
449
- N,
478
+ w,
450
479
  " first"
451
480
  ] }),
452
- /* @__PURE__ */ l(re, { className: "h-4 w-4 shrink-0 opacity-50" })
481
+ /* @__PURE__ */ r(ae, { className: "h-4 w-4 shrink-0 opacity-50" })
453
482
  ]
454
483
  }
455
- ) : /* @__PURE__ */ d("div", { ...w.bind, children: [
456
- /* @__PURE__ */ d(
457
- Ce,
484
+ ) : /* @__PURE__ */ c("div", { ..._.bind, children: [
485
+ /* @__PURE__ */ c(
486
+ Fe,
458
487
  {
459
- open: k,
460
- onOpenChange: (r) => {
461
- v(r), r || L("");
488
+ open: N,
489
+ onOpenChange: (l) => {
490
+ S(l), l || L("");
462
491
  },
463
492
  children: [
464
- /* @__PURE__ */ l(Oe, { asChild: !0, children: /* @__PURE__ */ d(
493
+ /* @__PURE__ */ r(qe, { asChild: !0, children: /* @__PURE__ */ c(
465
494
  "button",
466
495
  {
467
496
  type: "button",
468
- className: Q(
497
+ className: X(
469
498
  "w-full h-9 px-3 text-[12px] border rounded-md bg-background text-left flex items-center justify-between hover:bg-muted cursor-pointer transition-colors disabled:pointer-events-none disabled:opacity-50",
470
- V ? "border-amber-300 dark:border-amber-600" : ne ? "border-nvr-cyan/50" : "border-input"
499
+ W ? "border-amber-300 dark:border-amber-600" : se ? "border-nvr-cyan/50" : "border-input"
471
500
  ),
472
501
  children: [
473
- c || ae && te == null && i !== "new" ? /* @__PURE__ */ l(ce, { className: "h-3.5 w-3.5 animate-spin text-muted-foreground" }) : /* @__PURE__ */ d(
502
+ u || ce && le == null && i !== "new" ? /* @__PURE__ */ r(ue, { className: "h-3.5 w-3.5 animate-spin text-muted-foreground" }) : /* @__PURE__ */ c(
474
503
  "span",
475
504
  {
476
- className: Q(
505
+ className: X(
477
506
  "flex items-center gap-1.5 truncate min-w-0",
478
- S ? ne ? "text-nvr-cyan" : "text-slate-800 dark:text-slate-100" : "text-muted-foreground"
507
+ C ? se ? "text-nvr-cyan" : "text-slate-800 dark:text-slate-100" : "text-muted-foreground"
479
508
  ),
480
509
  children: [
481
- V && /* @__PURE__ */ l(ue, { className: "h-3.5 w-3.5 shrink-0 text-amber-500" }),
482
- /* @__PURE__ */ l("span", { className: "truncate", children: S ?? "Select…" })
510
+ W && /* @__PURE__ */ r(he, { className: "h-3.5 w-3.5 shrink-0 text-amber-500" }),
511
+ /* @__PURE__ */ r("span", { className: "truncate", children: C ?? "Select…" })
483
512
  ]
484
513
  }
485
514
  ),
486
- /* @__PURE__ */ l(re, { className: "h-4 w-4 shrink-0 opacity-50" })
515
+ /* @__PURE__ */ r(ae, { className: "h-4 w-4 shrink-0 opacity-50" })
487
516
  ]
488
517
  }
489
518
  ) }),
490
- /* @__PURE__ */ l(qe, { className: "w-[320px] p-0", align: "start", children: /* @__PURE__ */ d(ke, { shouldFilter: !1, children: [
491
- /* @__PURE__ */ l(
492
- we,
493
- {
494
- placeholder: "Search…",
495
- value: y,
496
- onValueChange: L,
497
- className: "h-9 text-[12px]"
498
- }
499
- ),
500
- f != null && /* @__PURE__ */ d(
501
- "button",
502
- {
503
- type: "button",
504
- onClick: () => {
505
- De(), v(!1);
506
- },
507
- 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",
508
- children: [
509
- /* @__PURE__ */ l(de, { className: "h-3.5 w-3.5 text-slate-400" }),
510
- "Clear selection"
511
- ]
512
- }
513
- ),
514
- /* @__PURE__ */ d(Se, { children: [
515
- G ? /* @__PURE__ */ l("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ l(ce, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : /* @__PURE__ */ l(Ne, { className: "py-3 text-left text-[12px] text-muted-foreground px-3", children: "No results" }),
516
- !G && /* @__PURE__ */ l(_e, { children: [...ie(B, y, ee, e)].sort(
517
- (r, b) => Y ? 0 : ye(e(r), e(b), y, h === "-label")
518
- ).map((r) => {
519
- const b = String(r.id), le = String(f) === b;
520
- return /* @__PURE__ */ d(
521
- Le,
519
+ /* @__PURE__ */ r(je, { className: "w-[320px] p-0", align: "start", children: /* @__PURE__ */ c(
520
+ Se,
521
+ {
522
+ shouldFilter: !1,
523
+ ...re,
524
+ children: [
525
+ /* @__PURE__ */ r(
526
+ Ne,
527
+ {
528
+ placeholder: "Search…",
529
+ value: m,
530
+ onValueChange: L,
531
+ className: "h-9 text-[12px]"
532
+ }
533
+ ),
534
+ y != null && /* @__PURE__ */ c(
535
+ "button",
522
536
  {
523
- value: b,
524
- onSelect: () => $e(r.id),
525
- className: "flex items-center gap-2 text-[12px]",
537
+ type: "button",
538
+ onClick: () => {
539
+ Me(), S(!1);
540
+ },
541
+ 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",
526
542
  children: [
527
- /* @__PURE__ */ l(
528
- "div",
529
- {
530
- className: Q(
531
- "flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",
532
- le ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300 dark:border-slate-500"
533
- ),
534
- children: le && /* @__PURE__ */ l(me, { className: "h-2.5 w-2.5 text-white" })
535
- }
536
- ),
537
- s === "nivaro_users" && /* @__PURE__ */ l(
538
- ve,
539
- {
540
- userId: b,
541
- className: "h-4 w-4",
542
- fallback: /* @__PURE__ */ l("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: Te(e(r)) })
543
- }
544
- ),
545
- s === "nivaro_users" && H.has(b.toUpperCase()) && /* @__PURE__ */ l(
546
- "span",
547
- {
548
- className: "h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500",
549
- "data-tip": "Online now"
550
- }
551
- ),
552
- /* @__PURE__ */ l("span", { className: "truncate", children: e(r) })
543
+ /* @__PURE__ */ r(me, { className: "h-3.5 w-3.5 text-slate-400" }),
544
+ "Clear selection"
553
545
  ]
554
- },
555
- b
556
- );
557
- }) })
558
- ] })
559
- ] }) })
546
+ }
547
+ ),
548
+ /* @__PURE__ */ c(_e, { children: [
549
+ $ ? /* @__PURE__ */ r("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ r(ue, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : /* @__PURE__ */ r(Ce, { className: "py-3 text-left text-[12px] text-muted-foreground px-3", children: "No results" }),
550
+ !$ && ne && /* @__PURE__ */ c(
551
+ "p",
552
+ {
553
+ "data-picker-close-matches": !0,
554
+ className: "px-3 pb-1 pt-2 text-[11.5px] text-muted-foreground",
555
+ children: [
556
+ "No exact match for “",
557
+ m.trim(),
558
+ "” — did you mean:"
559
+ ]
560
+ }
561
+ ),
562
+ !$ && /* @__PURE__ */ r(Le, { children: [...oe(K, m, te, e)].sort(
563
+ (l, g) => Z ? 0 : ge(e(l), e(g), m, p === "-label")
564
+ ).map((l) => {
565
+ const g = String(l.id), ie = String(y) === g;
566
+ return /* @__PURE__ */ c(
567
+ Oe,
568
+ {
569
+ value: g,
570
+ onSelect: () => Je(l.id),
571
+ className: "flex items-center gap-2 text-[12px]",
572
+ children: [
573
+ /* @__PURE__ */ r(
574
+ "div",
575
+ {
576
+ className: X(
577
+ "flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",
578
+ ie ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300 dark:border-slate-500"
579
+ ),
580
+ children: ie && /* @__PURE__ */ r(ye, { className: "h-2.5 w-2.5 text-white" })
581
+ }
582
+ ),
583
+ s === "nivaro_users" && /* @__PURE__ */ r(
584
+ we,
585
+ {
586
+ userId: g,
587
+ className: "h-4 w-4",
588
+ fallback: /* @__PURE__ */ r("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-nvr-cyan/20 text-[8px] font-bold text-nvr-navy dark:text-nvr-cyan", children: Ie(e(l)) })
589
+ }
590
+ ),
591
+ s === "nivaro_users" && Y.has(g.toUpperCase()) && /* @__PURE__ */ r(
592
+ "span",
593
+ {
594
+ className: "h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500",
595
+ "data-tip": "Online now"
596
+ }
597
+ ),
598
+ /* @__PURE__ */ r("span", { className: "truncate", children: e(l) })
599
+ ]
600
+ },
601
+ g
602
+ );
603
+ }) })
604
+ ] })
605
+ ]
606
+ }
607
+ ) })
560
608
  ]
561
609
  }
562
610
  ),
563
- w.tip
611
+ _.tip
564
612
  ] });
565
613
  }
614
+ function Pe(n, i) {
615
+ const [f, d] = E(null), [p, w] = E(!1), x = fe(!1);
616
+ return pe(() => {
617
+ d(null), x.current = !1;
618
+ }, [i]), n ? {
619
+ value: f ?? (p ? " " : ""),
620
+ onValueChange: (b) => {
621
+ x.current ? d(b) : w((v) => !v);
622
+ },
623
+ onKeyDownCapture: (b) => {
624
+ b.key === "ArrowDown" || b.key === "ArrowUp" ? x.current = !0 : b.key === "Enter" && !x.current && (b.preventDefault(), b.stopPropagation());
625
+ },
626
+ onPointerMoveCapture: () => {
627
+ x.current = !0;
628
+ }
629
+ } : {};
630
+ }
566
631
  export {
567
- ct as M2MCombobox,
568
- dt as M2MSingleSelectCombobox,
569
- ot as m2aWriteMeta,
570
- Me as m2mAsksServer,
571
- W as m2mIdKey,
572
- ie as narrowM2MOptions,
573
- Ae as resolveM2MRelatedCollection
632
+ pt as M2MCombobox,
633
+ ht as M2MSingleSelectCombobox,
634
+ ft as m2aWriteMeta,
635
+ We as m2mAsksServer,
636
+ Q as m2mIdKey,
637
+ oe as narrowM2MOptions,
638
+ Ke as resolveM2MRelatedCollection
574
639
  };