@nivaro/react 0.3.63 → 0.3.65

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