@nivaro/react 0.3.64 → 0.3.66

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 (74) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +62 -8
  4. package/dist/shared/components/CollectionBrowserView.js +3127 -3204
  5. package/dist/shared/components/ConformanceView.js +235 -221
  6. package/dist/shared/components/DataTable.js +478 -459
  7. package/dist/shared/components/ItemEditForm.js +4842 -4500
  8. package/dist/shared/components/MyWorkView.js +124 -113
  9. package/dist/shared/components/PageRenderer.js +146 -138
  10. package/dist/shared/components/ProfileView.js +483 -472
  11. package/dist/shared/components/RecordDrilldownSheet.js +73 -65
  12. package/dist/shared/components/ReportView.js +1100 -1094
  13. package/dist/shared/components/bulk/BulkActionButtons.js +72 -72
  14. package/dist/shared/components/bulk/BulkCompareButton.js +62 -0
  15. package/dist/shared/components/bulk/BulkFieldUpdate.js +114 -103
  16. package/dist/shared/components/bulk/BulkFieldUpdateButton.js +73 -0
  17. package/dist/shared/components/bulk/MessageStakeholders.js +235 -0
  18. package/dist/shared/components/bulk/bulk-field-options.js +29 -23
  19. package/dist/shared/components/integrations/IntegrationObligationsView.js +191 -173
  20. package/dist/shared/components/integrations/IntegrationStatusLines.js +101 -85
  21. package/dist/shared/components/integrations/RecordIntegrationPreview.js +11 -9
  22. package/dist/shared/components/integrations/SendCurrentData.js +126 -0
  23. package/dist/shared/components/item-edit/CatalogPickerField.js +1535 -1440
  24. package/dist/shared/components/item-edit/FieldRenderer.js +49 -45
  25. package/dist/shared/components/item-edit/FieldRow.js +413 -403
  26. package/dist/shared/components/item-edit/GroupSection.js +555 -538
  27. package/dist/shared/components/item-edit/InlineTableField.js +2903 -2816
  28. package/dist/shared/components/item-edit/M2MCombobox.js +407 -338
  29. package/dist/shared/components/item-edit/MidairCollisionDialog.js +367 -116
  30. package/dist/shared/components/item-edit/NestedRelationEditor.js +171 -163
  31. package/dist/shared/components/item-edit/PlanGrid.js +783 -724
  32. package/dist/shared/components/item-edit/QuickCreateButton.js +291 -224
  33. package/dist/shared/components/item-edit/RecordInsights.js +113 -111
  34. package/dist/shared/components/item-edit/RecordLiveSync.js +4 -1
  35. package/dist/shared/components/item-edit/RelationCombobox.js +398 -364
  36. package/dist/shared/components/item-edit/SummaryPanel.js +146 -144
  37. package/dist/shared/components/item-edit/UserChip.js +264 -229
  38. package/dist/shared/components/item-edit/cascade-clear-notice.js +56 -0
  39. package/dist/shared/components/item-edit/collision-format.js +37 -0
  40. package/dist/shared/components/item-edit/field-a11y.js +25 -0
  41. package/dist/shared/components/item-edit/header-path-preview.js +52 -0
  42. package/dist/shared/components/item-edit/line-merge.js +84 -0
  43. package/dist/shared/components/item-edit/line-midair.js +94 -87
  44. package/dist/shared/components/item-edit/move-guard.js +17 -0
  45. package/dist/shared/components/item-edit/picker-search.js +27 -16
  46. package/dist/shared/components/item-edit/rail-width.js +8 -0
  47. package/dist/shared/components/monitoring/InactiveUserLinksView.js +126 -124
  48. package/dist/shared/components/panels/AccessDeniedPanel.js +96 -55
  49. package/dist/shared/components/panels/CommentPanel.js +142 -136
  50. package/dist/shared/components/panels/ItemLockBanner.js +246 -240
  51. package/dist/shared/components/panels/PipelinePanel.js +1366 -1194
  52. package/dist/shared/components/panels/RevisionsPanel.js +106 -102
  53. package/dist/shared/components/panels/SlaBreachBanner.js +16 -20
  54. package/dist/shared/components/panels/SlaClock.js +90 -68
  55. package/dist/shared/components/queue/QueueItemSheet.js +94 -87
  56. package/dist/shared/components/queue/QueueWorklist.js +1522 -1347
  57. package/dist/shared/components/queue/worklist-csv.js +75 -0
  58. package/dist/shared/components/queue/worklist-helpers.js +20 -0
  59. package/dist/shared/components/widgets/ReviewListWidget.js +226 -207
  60. package/dist/shared/lib/bulk-copy.js +17 -0
  61. package/dist/shared/lib/cbv-export.js +122 -0
  62. package/dist/shared/lib/delete-offer.js +13 -0
  63. package/dist/shared/lib/error-hints.js +1 -0
  64. package/dist/shared/lib/leave-guard.js +41 -26
  65. package/dist/shared/lib/list-link.js +72 -56
  66. package/dist/shared/lib/live-queries.js +32 -30
  67. package/dist/shared/lib/moved-notice.js +25 -0
  68. package/dist/shared/lib/notification-target.js +56 -54
  69. package/dist/shared/lib/obligation-banner.js +11 -8
  70. package/dist/shared/lib/obligation-reason-text.js +6 -6
  71. package/dist/shared/lib/quick-filter-cascade.js +29 -19
  72. package/dist/shared/lib/sort-cycle.js +6 -0
  73. package/dist/shared/lib/summary-mode.js +59 -41
  74. package/package.json +1 -1
@@ -1,124 +1,126 @@
1
- import { jsx as l, jsxs as c } from "react/jsx-runtime";
2
- import { useQuery as L } 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 Pe } from "../../context.js";
6
- import { parseAllowedCollections as De } from "../../lib/allowed-collections.js";
1
+ import { jsx as r, jsxs as c } from "react/jsx-runtime";
2
+ import { useQuery as q } from "@tanstack/react-query";
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 W, 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 Se, CommandList as we, CommandEmpty as Ne, CommandGroup as _e, CommandItem as Le } from "../ui/command.js";
14
- import { Popover as Ce, PopoverTrigger as qe, PopoverContent as Oe } 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) {
19
- return n.replace(/\(.*$/, "").trim().split(/\s+/).map((i) => i[0]).filter(Boolean).slice(0, 2).join("").toUpperCase() || "?";
20
- }
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";
21
19
  function Ie(n) {
22
- return De(n == null ? void 0 : n.one_allowed_collections);
20
+ return n.replace(/\(.*$/, "").trim().split(/\s+/).map((i) => i[0]).filter(Boolean).slice(0, 2).join("").toUpperCase() || "?";
23
21
  }
24
22
  function Ue(n) {
23
+ return Re(n == null ? void 0 : n.one_allowed_collections);
24
+ }
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
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
+ allRelations: f,
44
45
  extraFilter: d,
45
- optionSort: h,
46
- requiredParent: S,
47
- onCountChange: w,
48
- drilldown: C
46
+ optionSort: p,
47
+ requiredParent: w,
48
+ onCountChange: x,
49
+ drilldown: b
49
50
  }) {
50
- const x = he(), F = Pe(), t = je(), [j, v] = se(!1), [y, q] = se(""), T = 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 = Ue(T), N = n.junction_field ?? "", P = n.many_field ?? "", u = n.one_field ?? `${n.many_collection}.${N}`, { data: o } = L({
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 = [] } = L({
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,${N}`
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, D = s === "nivaro_users" ? ge(ae) : null, E = xe(s === "nivaro_users"), H = d ? D ? { _and: [d, D] } : d : D, R = H ? JSON.stringify(H) : void 0, z = 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((f) => f[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: M,
77
- localSearch: B
78
- } = Ae({
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: R,
83
- serverSort: z,
84
- templateNestedFields: Y,
85
- enabled: j && !!s,
86
- labelOf: k
87
- }), ee = (t == null ? void 0 : t.getStagedLinks(u)) ?? [], _ = (t == null ? void 0 : t.getStagedUnlinks(u)) ?? /* @__PURE__ */ new Set(), A = X.filter((e) => !_.has(e.id)), g = new Set(A.map((e) => String(e[N]))), O = [...g], te = JSON.stringify(d ? { _and: [{ id: { _in: O } }, d] } : { id: { _in: O } }), { data: m } = L({
88
- queryKey: ["m2m-avail", s, O.join(","), R],
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 && O.length > 0,
99
+ enabled: !!s && T.length > 0,
98
100
  staleTime: 3e4
99
- }), ne = new Set((m ?? []).map((e) => String(e.id))), $ = m !== void 0 ? new Set(O.filter((e) => !ne.has(e))) : /* @__PURE__ */ new Set(), K = new Set(ee.map(Q)), J = /* @__PURE__ */ new Set([...[...g].map(Q), ...K]), I = fe(w);
100
- I.current = w, 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 = I.current) == null || e.call(I, J.size);
103
- }, [J.size]);
104
- function G(e) {
104
+ (e = I.current) == null || e.call(I, M.size);
105
+ }, [M.size]);
106
+ function W(e) {
105
107
  const a = Q(e);
106
- if (K.has(a)) {
107
- t == null || t.unstageLink(u, e);
108
+ if (J.has(a)) {
109
+ t == null || t.unstageLink(h, e);
108
110
  return;
109
111
  }
110
- const f = X.find((V) => Q(V[N]) === a);
111
- if (f) {
112
- _.has(f.id) ? t == null || t.unstageUnlink(u, f.id) : t == null || t.stageUnlink(u, f.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(u, e);
117
+ t == null || t.stageLink(h, e);
116
118
  }
117
- function k(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 S ? /* @__PURE__ */ c(
123
+ return w ? /* @__PURE__ */ c(
122
124
  "button",
123
125
  {
124
126
  type: "button",
@@ -127,31 +129,35 @@ function ct({
127
129
  children: [
128
130
  /* @__PURE__ */ c("span", { className: "truncate", children: [
129
131
  "Select ",
130
- S,
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__ */ c(
137
- Ce,
138
+ ) : /* @__PURE__ */ r("div", { children: /* @__PURE__ */ c(
139
+ Fe,
138
140
  {
139
- open: j,
141
+ open: N,
140
142
  onOpenChange: (e) => {
141
- v(e), e || q("");
143
+ S(e), e || L("");
142
144
  },
143
145
  children: [
144
- /* @__PURE__ */ l(qe, { asChild: !0, children: /* @__PURE__ */ c(
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
- (e.key === "Enter" || e.key === " ") && (e.preventDefault(), v((a) => !a));
152
+ if (e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey && (N || m !== "" || e.key !== " ")) {
153
+ e.preventDefault();
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));
151
157
  },
152
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",
153
159
  children: [
154
- J.size > 0 ? /* @__PURE__ */ c(
160
+ M.size > 0 ? /* @__PURE__ */ c(
155
161
  "span",
156
162
  {
157
163
  className: "flex min-w-0 flex-1 flex-wrap items-center gap-1",
@@ -159,32 +165,32 @@ function ct({
159
165
  e.target.closest("button") && e.stopPropagation();
160
166
  },
161
167
  children: [
162
- A.map((e) => {
163
- const a = e[N], f = $.has(String(a));
168
+ D.map((e) => {
169
+ const a = e[O], u = P.has(String(a));
164
170
  return /* @__PURE__ */ c(
165
171
  "span",
166
172
  {
167
- title: f ? "This record is no longer an available option" : void 0,
168
- className: W(
173
+ title: u ? "This record is no longer an available option" : void 0,
174
+ className: X(
169
175
  "inline-flex items-center gap-1 rounded-full border pl-2.5 pr-1.5 py-0.5 text-[12px]",
170
- f ? "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"
171
177
  ),
172
178
  children: [
173
- f && /* @__PURE__ */ l(ue, { className: "h-3 w-3 shrink-0 text-amber-500" }),
174
- s && (C && F ? /* @__PURE__ */ l(
179
+ u && /* @__PURE__ */ r(he, { className: "h-3 w-3 shrink-0 text-amber-500" }),
180
+ s && (b && A ? /* @__PURE__ */ r(
175
181
  "button",
176
182
  {
177
183
  type: "button",
178
184
  title: "Open detail panel",
179
- onClick: () => F.open({
185
+ onClick: () => A.open({
180
186
  collection: s,
181
187
  itemId: String(a),
182
- layoutId: C.layout_id,
183
- width: C.width
188
+ layoutId: b.layout_id,
189
+ width: b.width
184
190
  }),
185
191
  className: "underline decoration-slate-300 decoration-dotted underline-offset-2 hover:text-[#172940] hover:decoration-nvr-cyan dark:hover:text-nvr-cyan",
186
- children: /* @__PURE__ */ l(
187
- oe,
192
+ children: /* @__PURE__ */ r(
193
+ de,
188
194
  {
189
195
  collection: s,
190
196
  id: a,
@@ -192,22 +198,22 @@ function ct({
192
198
  }
193
199
  )
194
200
  }
195
- ) : /* @__PURE__ */ l(
196
- oe,
201
+ ) : /* @__PURE__ */ r(
202
+ de,
197
203
  {
198
204
  collection: s,
199
205
  id: a,
200
206
  displayTemplate: o == null ? void 0 : o.display_template
201
207
  }
202
208
  )),
203
- /* @__PURE__ */ l(
209
+ /* @__PURE__ */ r(
204
210
  "button",
205
211
  {
206
212
  type: "button",
207
213
  "aria-label": "Remove",
208
- onClick: () => t == null ? void 0 : t.stageUnlink(u, e.id),
214
+ onClick: () => t == null ? void 0 : t.stageUnlink(h, e.id),
209
215
  className: "rounded-full p-0.5 text-slate-400 hover:text-red-500",
210
- children: /* @__PURE__ */ l(de, { className: "h-3 w-3" })
216
+ children: /* @__PURE__ */ r(me, { className: "h-3 w-3" })
211
217
  }
212
218
  )
213
219
  ]
@@ -215,27 +221,27 @@ function ct({
215
221
  String(e.id)
216
222
  );
217
223
  }),
218
- ee.map((e) => /* @__PURE__ */ c(
224
+ re.map((e) => /* @__PURE__ */ c(
219
225
  "span",
220
226
  {
221
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",
222
228
  children: [
223
- s ? /* @__PURE__ */ l(
224
- oe,
229
+ s ? /* @__PURE__ */ r(
230
+ de,
225
231
  {
226
232
  collection: s,
227
233
  id: e,
228
234
  displayTemplate: o == null ? void 0 : o.display_template
229
235
  }
230
236
  ) : String(e),
231
- /* @__PURE__ */ l(
237
+ /* @__PURE__ */ r(
232
238
  "button",
233
239
  {
234
240
  type: "button",
235
241
  "aria-label": "Remove",
236
- onClick: () => t == null ? void 0 : t.unstageLink(u, e),
242
+ onClick: () => t == null ? void 0 : t.unstageLink(h, e),
237
243
  className: "rounded-full p-0.5 text-slate-400 hover:text-red-500",
238
- children: /* @__PURE__ */ l(de, { className: "h-3 w-3" })
244
+ children: /* @__PURE__ */ r(me, { className: "h-3 w-3" })
239
245
  }
240
246
  )
241
247
  ]
@@ -244,196 +250,223 @@ function ct({
244
250
  ))
245
251
  ]
246
252
  }
247
- ) : /* @__PURE__ */ l("span", { className: "truncate text-muted-foreground", children: "Select items…" }),
248
- /* @__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" })
249
255
  ]
250
256
  }
251
257
  ) }),
252
- /* @__PURE__ */ l(Oe, { className: "w-[320px] p-0", align: "start", children: /* @__PURE__ */ c(ke, { shouldFilter: !1, children: [
253
- /* @__PURE__ */ l(
254
- Se,
255
- {
256
- placeholder: "Search…",
257
- value: y,
258
- onValueChange: q,
259
- className: "h-9 text-[13px]"
260
- }
261
- ),
262
- /* @__PURE__ */ c(we, { children: [
263
- M ? /* @__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" }),
264
- /* @__PURE__ */ l(_e, { children: !M && (z ? [...ie(Z, y, B, k)] : [...ie(Z, y, B, k)].sort(
265
- (e, a) => ye(k(e), k(a), y, h === "-label")
266
- )).map((e) => {
267
- const a = String(e.id), f = J.has(Q(a));
268
- return /* @__PURE__ */ c(
269
- 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,
270
266
  {
271
- value: a,
272
- onSelect: () => G(e.id),
273
- className: "flex items-center gap-2 text-[13px]",
274
- children: [
275
- /* @__PURE__ */ l(
276
- "div",
277
- {
278
- className: W(
279
- "flex h-4 w-4 shrink-0 items-center justify-center rounded border",
280
- f ? "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
+ }
281
307
  ),
282
- children: f && /* @__PURE__ */ l(me, { className: "h-2.5 w-2.5 text-white" })
283
- }
284
- ),
285
- s === "nivaro_users" && /* @__PURE__ */ l(
286
- ve,
287
- {
288
- userId: a,
289
- className: "h-4 w-4",
290
- 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(k(e)) })
291
- }
292
- ),
293
- s === "nivaro_users" && E.has(a.toUpperCase()) && /* @__PURE__ */ l(
294
- "span",
295
- {
296
- className: "h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500",
297
- "data-tip": "Online now"
298
- }
299
- ),
300
- /* @__PURE__ */ l("span", { className: "truncate", children: k(e) })
301
- ]
302
- },
303
- a
304
- );
305
- }) })
306
- ] })
307
- ] }) })
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
+ ) })
308
333
  ]
309
334
  }
310
335
  ) });
311
336
  }
312
- function Ae(n) {
313
- const { client: i, relatedCollection: p, search: d, filterParam: h, serverSort: S, templateNestedFields: w } = n, C = (T) => i.request(
314
- U(`/items/${p}`, {
315
- limit: $e,
316
- search: T || void 0,
317
- 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,
318
345
  picker: "1",
319
346
  // A dotted display template ({{core_category.name}}) needs the
320
347
  // nested expansion — a bare row only carries the FK id.
321
- ...w ? { fields: w } : {},
322
- ...S ? { sort: S } : {}
348
+ ...x ? { fields: x } : {},
349
+ ...w ? { sort: w } : {}
323
350
  })
324
- ).then((s) => s.data ?? []), x = (T) => [
351
+ ).then((s) => s.data ?? []), v = (j) => [
325
352
  "m2m-options",
353
+ f,
354
+ j,
326
355
  p,
327
- T,
328
- h,
329
- S ?? "",
330
- w ?? ""
331
- ], F = h ? 0 : 3e4, { data: t, isFetching: j } = L({
332
- queryKey: x(""),
333
- queryFn: () => C(""),
356
+ w ?? "",
357
+ x ?? ""
358
+ ], A = p ? 0 : 3e4, { data: t, isFetching: N } = q({
359
+ queryKey: v(""),
360
+ queryFn: () => b(""),
334
361
  enabled: n.enabled,
335
- staleTime: F
336
- }), v = Me(t, d, n.labelOf), { data: y, isFetching: q } = L({
337
- queryKey: x(d),
338
- queryFn: () => C(d),
339
- enabled: n.enabled && v,
340
- staleTime: F
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
341
368
  });
342
- return v ? { options: y ?? [], isLoading: !y && q, localSearch: !1 } : { options: t ?? [], isLoading: !t && j, localSearch: !!d };
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 };
343
375
  }
344
- const $e = 200;
345
- function Me(n, i, p) {
346
- return i.trim() ? !n || n.length >= $e ? !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;
347
379
  }
348
- function ie(n, i, p, d) {
349
- return !p || !i.trim() ? n : n.filter((h) => Re(d(h), i));
380
+ function oe(n, i, f, d) {
381
+ return !f || !i.trim() ? n : n.filter((p) => Ge(d(p), i));
350
382
  }
351
- function dt({
383
+ function ht({
352
384
  relation: n,
353
385
  parentId: i,
354
- allRelations: p,
386
+ allRelations: f,
355
387
  extraFilter: d,
356
- optionSort: h,
357
- requiredParent: S,
358
- onCountChange: w,
359
- readOnly: C
388
+ optionSort: p,
389
+ requiredParent: w,
390
+ onCountChange: x,
391
+ readOnly: b
360
392
  }) {
361
- const x = he(), F = Ee(), t = je(), [j, v] = se(!1), [y, q] = se(""), T = p.find(
362
- (r) => r.many_collection === n.many_collection && r.many_field === n.junction_field && r.id !== n.id
363
- ), s = Ue(T), N = n.junction_field ?? "", P = n.many_field ?? "", u = n.one_field ?? `${n.many_collection}.${N}`, { data: o } = L({
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({
364
396
  queryKey: ["col-meta", s],
365
- queryFn: () => x.request(U(`/collections/${s}`)).then((r) => r.data),
397
+ queryFn: () => v.request(U(`/collections/${s}`)).then((l) => l.data),
366
398
  enabled: !!s,
367
399
  staleTime: 3e5,
368
400
  retry: !1
369
- }), { data: X = [], isFetching: ae } = L({
370
- queryKey: ["m2m-items", n.many_collection, P, i],
371
- queryFn: () => x.request(
401
+ }), { data: H = [], isFetching: ce } = q({
402
+ queryKey: ["m2m-items", n.many_collection, R, i],
403
+ queryFn: () => v.request(
372
404
  U(`/items/${n.many_collection}`, {
373
- filter: JSON.stringify({ [P]: { _eq: i } }),
405
+ filter: JSON.stringify({ [R]: { _eq: i } }),
374
406
  limit: 1,
375
- fields: `id,${N}`
407
+ fields: `id,${O}`
376
408
  })
377
- ).then((r) => r.data ?? []),
409
+ ).then((l) => l.data ?? []),
378
410
  staleTime: 3e4,
379
411
  enabled: !!i && i !== "new"
380
- }), D = be().isAdmin, E = s === "nivaro_users" ? ge(D) : null, H = xe(s === "nivaro_users"), R = d ? E ? { _and: [d, E] } : d : E, z = R ? JSON.stringify(R) : void 0, Y = h && !/^-?label$/.test(h) ? h : void 0, Z = (() => {
381
- const r = o == null ? void 0 : o.display_template;
382
- if (!r || !r.includes(".")) return null;
383
- const b = [...r.matchAll(/\{\{([^}]+)\}\}/g)].map((le) => le[1].trim());
384
- 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(",");
385
417
  })(), {
386
- options: M,
387
- isLoading: B,
388
- localSearch: ee
389
- } = Ae({
390
- client: x,
418
+ options: K,
419
+ isLoading: $,
420
+ localSearch: te,
421
+ closeMatches: ne
422
+ } = $e({
423
+ client: v,
391
424
  relatedCollection: s,
392
- search: y,
393
- filterParam: z,
394
- serverSort: Y,
395
- templateNestedFields: Z,
396
- enabled: j && !!s,
425
+ search: m,
426
+ filterParam: B,
427
+ serverSort: Z,
428
+ templateNestedFields: ee,
429
+ enabled: N && !!s,
397
430
  labelOf: e
398
- }), _ = (t == null ? void 0 : t.getStagedLinks(u)) ?? [], A = (t == null ? void 0 : t.getStagedUnlinks(u)) ?? /* @__PURE__ */ new Set(), g = X.find((r) => !A.has(r.id)) ?? null, O = g ? g[N] : null, te = _.length > 0 ? _[_.length - 1] : null, m = te ?? O, ne = _.length > 0 || A.size > 0, $ = fe(w);
399
- $.current = w, pe(() => {
400
- var r;
401
- (r = $.current) == null || r.call($, m != null ? 1 : 0);
402
- }, [m]);
403
- const { data: K } = L({
404
- queryKey: ["relation-single", s, String(m)],
405
- queryFn: () => F(s, m),
406
- enabled: !!s && m != 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,
407
440
  staleTime: 6e4
408
- }), J = JSON.stringify(d ? { _and: [{ id: { _eq: m } }, d] } : { id: { _eq: m } }), { data: I } = L({
409
- queryKey: ["relation-avail", s, String(m), z],
410
- 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(
411
444
  U(`/items/${s}`, {
412
- filter: J,
445
+ filter: M,
413
446
  picker: "1",
414
447
  limit: 1,
415
448
  fields: "id"
416
449
  })
417
- ).then((r) => r.data ?? []),
418
- enabled: !!s && m != null && !!K,
450
+ ).then((l) => l.data ?? []),
451
+ enabled: !!s && y != null && !!J,
419
452
  staleTime: 3e4
420
- }), G = I !== void 0 && I.length === 0, k = ze(G);
421
- function e(r) {
422
- const b = (o == null ? void 0 : o.display_template) ?? null;
423
- 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 ?? "");
424
457
  }
425
- const a = M.find((r) => String(r.id) === String(m)) ?? K, f = m != null && !K && !a, V = a ? e(a) : null;
426
- if (C)
427
- return /* @__PURE__ */ l("span", { className: "block truncate text-[12px] text-slate-700 dark:text-slate-200", children: f ? "…" : V ?? "—" });
428
- function Ke(r) {
429
- for (const b of _) t == null || t.unstageLink(u, b);
430
- g && !A.has(g.id) && (t == null || t.stageUnlink(u, g.id)), String(r) === String(O) && g ? t == null || t.unstageUnlink(u, g.id) : String(r) !== String(m) && (t == null || t.stageLink(u, r)), v(!1), q("");
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("");
431
464
  }
432
- function Je() {
433
- for (const r of _) t == null || t.unstageLink(u, r);
434
- g && (t == null || t.stageUnlink(u, 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);
435
468
  }
436
- return S ? /* @__PURE__ */ c(
469
+ return w ? /* @__PURE__ */ c(
437
470
  "button",
438
471
  {
439
472
  type: "button",
@@ -442,129 +475,165 @@ function dt({
442
475
  children: [
443
476
  /* @__PURE__ */ c("span", { className: "truncate text-muted-foreground", children: [
444
477
  "Select ",
445
- S,
478
+ w,
446
479
  " first"
447
480
  ] }),
448
- /* @__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" })
449
482
  ]
450
483
  }
451
- ) : /* @__PURE__ */ c("div", { ...k.bind, children: [
484
+ ) : /* @__PURE__ */ c("div", { ..._.bind, children: [
452
485
  /* @__PURE__ */ c(
453
- Ce,
486
+ Fe,
454
487
  {
455
- open: j,
456
- onOpenChange: (r) => {
457
- v(r), r || q("");
488
+ open: N,
489
+ onOpenChange: (l) => {
490
+ S(l), l || L("");
458
491
  },
459
492
  children: [
460
- /* @__PURE__ */ l(qe, { asChild: !0, children: /* @__PURE__ */ c(
493
+ /* @__PURE__ */ r(qe, { asChild: !0, children: /* @__PURE__ */ c(
461
494
  "button",
462
495
  {
463
496
  type: "button",
464
- className: W(
497
+ className: X(
465
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",
466
- G ? "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"
467
500
  ),
468
501
  children: [
469
- f || ae && te == null && i !== "new" ? /* @__PURE__ */ l(ce, { className: "h-3.5 w-3.5 animate-spin text-muted-foreground" }) : /* @__PURE__ */ c(
502
+ u || ce && le == null && i !== "new" ? /* @__PURE__ */ r(ue, { className: "h-3.5 w-3.5 animate-spin text-muted-foreground" }) : /* @__PURE__ */ c(
470
503
  "span",
471
504
  {
472
- className: W(
505
+ className: X(
473
506
  "flex items-center gap-1.5 truncate min-w-0",
474
- V ? 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"
475
508
  ),
476
509
  children: [
477
- G && /* @__PURE__ */ l(ue, { className: "h-3.5 w-3.5 shrink-0 text-amber-500" }),
478
- /* @__PURE__ */ l("span", { className: "truncate", children: V ?? "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…" })
479
512
  ]
480
513
  }
481
514
  ),
482
- /* @__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" })
483
516
  ]
484
517
  }
485
518
  ) }),
486
- /* @__PURE__ */ l(Oe, { className: "w-[320px] p-0", align: "start", children: /* @__PURE__ */ c(ke, { shouldFilter: !1, children: [
487
- /* @__PURE__ */ l(
488
- Se,
489
- {
490
- placeholder: "Search…",
491
- value: y,
492
- onValueChange: q,
493
- className: "h-9 text-[12px]"
494
- }
495
- ),
496
- m != null && /* @__PURE__ */ c(
497
- "button",
498
- {
499
- type: "button",
500
- onClick: () => {
501
- Je(), v(!1);
502
- },
503
- 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",
504
- children: [
505
- /* @__PURE__ */ l(de, { className: "h-3.5 w-3.5 text-slate-400" }),
506
- "Clear selection"
507
- ]
508
- }
509
- ),
510
- /* @__PURE__ */ c(we, { children: [
511
- 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" }),
512
- !B && /* @__PURE__ */ l(_e, { children: [...ie(M, y, ee, e)].sort(
513
- (r, b) => Y ? 0 : ye(e(r), e(b), y, h === "-label")
514
- ).map((r) => {
515
- const b = String(r.id), le = String(m) === b;
516
- return /* @__PURE__ */ c(
517
- 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",
518
536
  {
519
- value: b,
520
- onSelect: () => Ke(r.id),
521
- 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",
522
542
  children: [
523
- /* @__PURE__ */ l(
524
- "div",
525
- {
526
- className: W(
527
- "flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",
528
- le ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300 dark:border-slate-500"
529
- ),
530
- children: le && /* @__PURE__ */ l(me, { className: "h-2.5 w-2.5 text-white" })
531
- }
532
- ),
533
- s === "nivaro_users" && /* @__PURE__ */ l(
534
- ve,
535
- {
536
- userId: b,
537
- className: "h-4 w-4",
538
- 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)) })
539
- }
540
- ),
541
- s === "nivaro_users" && H.has(b.toUpperCase()) && /* @__PURE__ */ l(
542
- "span",
543
- {
544
- className: "h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500",
545
- "data-tip": "Online now"
546
- }
547
- ),
548
- /* @__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"
549
545
  ]
550
- },
551
- b
552
- );
553
- }) })
554
- ] })
555
- ] }) })
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
+ ) })
556
608
  ]
557
609
  }
558
610
  ),
559
- k.tip
611
+ _.tip
560
612
  ] });
561
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
+ }
562
631
  export {
563
- ct as M2MCombobox,
564
- dt as M2MSingleSelectCombobox,
565
- ot as m2aWriteMeta,
566
- Me as m2mAsksServer,
632
+ pt as M2MCombobox,
633
+ ht as M2MSingleSelectCombobox,
634
+ ft as m2aWriteMeta,
635
+ We as m2mAsksServer,
567
636
  Q as m2mIdKey,
568
- ie as narrowM2MOptions,
569
- Ue as resolveM2MRelatedCollection
637
+ oe as narrowM2MOptions,
638
+ Ke as resolveM2MRelatedCollection
570
639
  };