@nivaro/react 0.3.96 → 0.3.97

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.
@@ -9,7 +9,7 @@ import { noteReplayEvent as _e, createReplayCheckoutState as De } from "../share
9
9
  import { emitReplayTap as Te, setReplayRecorderMode as N, registerReplayCapture as qe, clipEndOffset as Le, withClipKind as Pe } from "../shared/lib/replay-capture.js";
10
10
  import { instrumentConsole as Ne, instrumentRequests as Fe, redactSecrets as Me } from "../shared/lib/replay-context.js";
11
11
  import { instrumentSocket as Oe } from "../shared/lib/replay-socket.js";
12
- const Ue = "nivaro-react@0.3.96", j = 1e4, We = 150, He = 3e3, Ke = 600, $e = (n) => `nvr_replay_resume${n ? `:${n}` : ""}`, G = () => typeof navigator > "u" || navigator.onLine !== !1;
12
+ const Ue = "nivaro-react@0.3.97", j = 1e4, We = 150, He = 3e3, Ke = 600, $e = (n) => `nvr_replay_resume${n ? `:${n}` : ""}`, G = () => typeof navigator > "u" || navigator.onLine !== !1;
13
13
  function Be(n) {
14
14
  return typeof n.url != "string" || typeof fetch != "function" ? null : (f, a) => {
15
15
  const u = typeof n.getToken == "function" ? n.getToken() : void 0, d = { "Content-Type": "application/json" };
@@ -1,45 +1,48 @@
1
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 ae, Loader2 as ue, AlertTriangle as he, X as me, Check as ye } from "lucide-react";
3
+ import { ChevronDown as ae, Loader2 as ue, AlertTriangle as ye, X as me, Check as be } from "lucide-react";
4
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";
5
+ import { useNivaroClient as xe, useItemEditAuth as ge, useDrilldown as Ee } from "../../context.js";
6
+ import { parseAllowedCollections as ze } from "../../lib/allowed-collections.js";
7
7
  import { get as U } from "../../lib/commands.js";
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";
8
+ import { compareByMatch as ve } from "../../lib/picker-rank.js";
9
+ import { useRecordReader as Ge } from "../../lib/record-loader.js";
10
+ import { useOnlineUsers as ke } from "../../lib/use-online-users.js";
11
+ import { cn as X, userOptionFilter as we, matchesAllTokens as Re } from "../../lib/utils.js";
12
+ import { UserAvatar as Se } from "../UserAvatar.js";
13
+ import { Command as Ne, CommandInput as _e, CommandList as Ce, CommandEmpty as Le, CommandGroup as Oe, CommandItem as Fe } from "../ui/command.js";
14
+ import { Popover as qe, PopoverTrigger as je, PopoverContent as Te } from "../ui/popover.js";
15
+ import { applyDisplayTemplate as Ae } from "./helpers.js";
16
+ import { useM2MStaging as Ie } from "./M2MStagingContext.js";
17
17
  import { onlyCloseMatches as Ve } from "./picker-search.js";
18
18
  import { useStaleTip as Be, RelatedItemLabel as de } from "./RelationCombobox.js";
19
- function Ie(n) {
20
- return n.replace(/\(.*$/, "").trim().split(/\s+/).map((i) => i[0]).filter(Boolean).slice(0, 2).join("").toUpperCase() || "?";
19
+ function Ue(t) {
20
+ return t.replace(/\(.*$/, "").trim().split(/\s+/).map((i) => i[0]).filter(Boolean).slice(0, 2).join("").toUpperCase() || "?";
21
21
  }
22
- function Ue(n) {
23
- return Re(n == null ? void 0 : n.one_allowed_collections);
22
+ function he(t) {
23
+ return ze(t == null ? void 0 : t.one_allowed_collections);
24
24
  }
25
- function Ke(n) {
26
- if (!n) return null;
27
- if (n.one_collection) return n.one_collection;
28
- const i = Ue(n);
25
+ function ft(t) {
26
+ return !t || t.one_collection ? 0 : he(t).length;
27
+ }
28
+ function Ke(t) {
29
+ if (!t) return null;
30
+ if (t.one_collection) return t.one_collection;
31
+ const i = he(t);
29
32
  return i.length === 0 ? null : i.some((f) => f === "directus_users" || f === "nivaro_users") ? "nivaro_users" : i[0];
30
33
  }
31
- function ft(n) {
32
- if (!n || n.one_collection) return null;
33
- const i = Ue(n);
34
+ function pt(t) {
35
+ if (!t || t.one_collection) return null;
36
+ const i = he(t);
34
37
  if (i.length === 0) return null;
35
38
  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 };
39
+ return { field: t.one_collection_field ?? "collection", value: f };
37
40
  }
38
- function Q(n) {
39
- return String(n).toLowerCase();
41
+ function Q(t) {
42
+ return String(t).toLowerCase();
40
43
  }
41
- function pt({
42
- relation: n,
44
+ function ht({
45
+ relation: t,
43
46
  parentId: i,
44
47
  allRelations: f,
45
48
  extraFilter: d,
@@ -48,26 +51,26 @@ function pt({
48
51
  onCountChange: x,
49
52
  drilldown: b
50
53
  }) {
51
- const v = be(), A = Ee(), t = Ae(), [N, S] = E(!1), [m, L] = E(""), j = f.find(
52
- (e) => e.many_collection === n.many_collection && e.many_field === n.junction_field && e.id !== n.id
53
- ), s = Ke(j), O = n.junction_field ?? "", R = n.many_field ?? "", h = n.one_field ?? `${n.many_collection}.${O}`, { data: o } = q({
54
+ const v = xe(), A = Ee(), n = Ie(), [N, S] = E(!1), [m, L] = E(""), j = f.find(
55
+ (e) => e.many_collection === t.many_collection && e.many_field === t.junction_field && e.id !== t.id
56
+ ), s = Ke(j), O = t.junction_field ?? "", z = t.many_field ?? "", h = t.one_field ?? `${t.many_collection}.${O}`, { data: o } = q({
54
57
  queryKey: ["col-meta", s],
55
58
  queryFn: () => v.request(U(`/collections/${s}`)).then((e) => e.data),
56
59
  enabled: !!s,
57
60
  staleTime: 3e5,
58
61
  retry: !1
59
62
  }), { data: H = [] } = q({
60
- queryKey: ["m2m-items", n.many_collection, R, i],
63
+ queryKey: ["m2m-items", t.many_collection, z, i],
61
64
  queryFn: () => v.request(
62
- U(`/items/${n.many_collection}`, {
63
- filter: JSON.stringify({ [R]: { _eq: i } }),
65
+ U(`/items/${t.many_collection}`, {
66
+ filter: JSON.stringify({ [z]: { _eq: i } }),
64
67
  limit: 200,
65
68
  fields: `id,${O}`
66
69
  })
67
70
  ).then((e) => e.data ?? []),
68
71
  staleTime: 3e4,
69
72
  enabled: !!i && i !== "new"
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 = (() => {
73
+ }), ce = ge().isAdmin, G = s === "nivaro_users" ? we(ce) : null, R = ke(s === "nivaro_users"), Y = d ? G ? { _and: [d, G] } : d : G, V = Y ? JSON.stringify(Y) : void 0, B = p && !/^-?label$/.test(p) ? p : void 0, Z = (() => {
71
74
  const e = o == null ? void 0 : o.display_template;
72
75
  if (!e || !e.includes(".")) return null;
73
76
  const a = [...e.matchAll(/\{\{([^}]+)\}\}/g)].map((u) => u[1].trim());
@@ -86,7 +89,7 @@ function pt({
86
89
  templateNestedFields: Z,
87
90
  enabled: N && !!s,
88
91
  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({
92
+ }), ne = Pe(!!te, m), re = (n == null ? void 0 : n.getStagedLinks(h)) ?? [], F = (n == null ? void 0 : n.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
93
  queryKey: ["m2m-avail", s, T.join(","), V],
91
94
  queryFn: () => v.request(
92
95
  U(`/items/${s}`, {
@@ -106,19 +109,19 @@ function pt({
106
109
  function W(e) {
107
110
  const a = Q(e);
108
111
  if (J.has(a)) {
109
- t == null || t.unstageLink(h, e);
112
+ n == null || n.unstageLink(h, e);
110
113
  return;
111
114
  }
112
115
  const u = H.find((C) => Q(C[O]) === a);
113
116
  if (u) {
114
- F.has(u.id) ? t == null || t.unstageUnlink(h, u.id) : t == null || t.stageUnlink(h, u.id);
117
+ F.has(u.id) ? n == null || n.unstageUnlink(h, u.id) : n == null || n.stageUnlink(h, u.id);
115
118
  return;
116
119
  }
117
- t == null || t.stageLink(h, e);
120
+ n == null || n.stageLink(h, e);
118
121
  }
119
122
  function _(e) {
120
123
  const a = (o == null ? void 0 : o.display_template) ?? null;
121
- return a ? Te(a, e) : String(e._display ?? e.id ?? "");
124
+ return a ? Ae(a, e) : String(e._display ?? e.id ?? "");
122
125
  }
123
126
  return w ? /* @__PURE__ */ c(
124
127
  "button",
@@ -136,14 +139,14 @@ function pt({
136
139
  ]
137
140
  }
138
141
  ) : /* @__PURE__ */ r("div", { children: /* @__PURE__ */ c(
139
- Fe,
142
+ qe,
140
143
  {
141
144
  open: N,
142
145
  onOpenChange: (e) => {
143
146
  S(e), e || L("");
144
147
  },
145
148
  children: [
146
- /* @__PURE__ */ r(qe, { asChild: !0, children: /* @__PURE__ */ c(
149
+ /* @__PURE__ */ r(je, { asChild: !0, children: /* @__PURE__ */ c(
147
150
  "div",
148
151
  {
149
152
  role: "button",
@@ -176,7 +179,7 @@ function pt({
176
179
  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"
177
180
  ),
178
181
  children: [
179
- u && /* @__PURE__ */ r(he, { className: "h-3 w-3 shrink-0 text-amber-500" }),
182
+ u && /* @__PURE__ */ r(ye, { className: "h-3 w-3 shrink-0 text-amber-500" }),
180
183
  s && (b && A ? /* @__PURE__ */ r(
181
184
  "button",
182
185
  {
@@ -211,7 +214,7 @@ function pt({
211
214
  {
212
215
  type: "button",
213
216
  "aria-label": "Remove",
214
- onClick: () => t == null ? void 0 : t.stageUnlink(h, e.id),
217
+ onClick: () => n == null ? void 0 : n.stageUnlink(h, e.id),
215
218
  className: "rounded-full p-0.5 text-slate-400 hover:text-red-500",
216
219
  children: /* @__PURE__ */ r(me, { className: "h-3 w-3" })
217
220
  }
@@ -239,7 +242,7 @@ function pt({
239
242
  {
240
243
  type: "button",
241
244
  "aria-label": "Remove",
242
- onClick: () => t == null ? void 0 : t.unstageLink(h, e),
245
+ onClick: () => n == null ? void 0 : n.unstageLink(h, e),
243
246
  className: "rounded-full p-0.5 text-slate-400 hover:text-red-500",
244
247
  children: /* @__PURE__ */ r(me, { className: "h-3 w-3" })
245
248
  }
@@ -255,14 +258,14 @@ function pt({
255
258
  ]
256
259
  }
257
260
  ) }),
258
- /* @__PURE__ */ r(je, { className: "w-[320px] p-0", align: "start", children: /* @__PURE__ */ c(
259
- Se,
261
+ /* @__PURE__ */ r(Te, { className: "w-[320px] p-0", align: "start", children: /* @__PURE__ */ c(
262
+ Ne,
260
263
  {
261
264
  shouldFilter: !1,
262
265
  ...ne,
263
266
  children: [
264
267
  /* @__PURE__ */ r(
265
- Ne,
268
+ _e,
266
269
  {
267
270
  placeholder: "Search…",
268
271
  value: m,
@@ -270,8 +273,8 @@ function pt({
270
273
  className: "h-9 text-[13px]"
271
274
  }
272
275
  ),
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" }),
276
+ /* @__PURE__ */ c(Ce, { children: [
277
+ 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(Le, { className: "py-3 text-left text-[12px] text-muted-foreground px-3", children: "No results" }),
275
278
  !K && te && /* @__PURE__ */ c(
276
279
  "p",
277
280
  {
@@ -284,12 +287,12 @@ function pt({
284
287
  ]
285
288
  }
286
289
  ),
287
- /* @__PURE__ */ r(Le, { children: !K && (B ? [...oe(ee, m, $, _)] : [...oe(ee, m, $, _)].sort(
288
- (e, a) => ge(_(e), _(a), m, p === "-label")
290
+ /* @__PURE__ */ r(Oe, { children: !K && (B ? [...oe(ee, m, $, _)] : [...oe(ee, m, $, _)].sort(
291
+ (e, a) => ve(_(e), _(a), m, p === "-label")
289
292
  )).map((e) => {
290
293
  const a = String(e.id), u = M.has(Q(a));
291
294
  return /* @__PURE__ */ c(
292
- Oe,
295
+ Fe,
293
296
  {
294
297
  value: a,
295
298
  onSelect: () => W(e.id),
@@ -302,18 +305,18 @@ function pt({
302
305
  "flex h-4 w-4 shrink-0 items-center justify-center rounded border",
303
306
  u ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300 dark:border-slate-500"
304
307
  ),
305
- children: u && /* @__PURE__ */ r(ye, { className: "h-2.5 w-2.5 text-white" })
308
+ children: u && /* @__PURE__ */ r(be, { className: "h-2.5 w-2.5 text-white" })
306
309
  }
307
310
  ),
308
311
  s === "nivaro_users" && /* @__PURE__ */ r(
309
- we,
312
+ Se,
310
313
  {
311
314
  userId: a,
312
315
  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)) })
316
+ 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: Ue(_(e)) })
314
317
  }
315
318
  ),
316
- s === "nivaro_users" && G.has(a.toUpperCase()) && /* @__PURE__ */ r(
319
+ s === "nivaro_users" && R.has(a.toUpperCase()) && /* @__PURE__ */ r(
317
320
  "span",
318
321
  {
319
322
  className: "h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500",
@@ -334,8 +337,8 @@ function pt({
334
337
  }
335
338
  ) });
336
339
  }
337
- function $e(n) {
338
- const { client: i, relatedCollection: f, search: d, filterParam: p, serverSort: w, templateNestedFields: x } = n, b = (j) => i.request(
340
+ function $e(t) {
341
+ const { client: i, relatedCollection: f, search: d, filterParam: p, serverSort: w, templateNestedFields: x } = t, b = (j) => i.request(
339
342
  U(`/items/${f}`, {
340
343
  limit: De,
341
344
  search: j || void 0,
@@ -355,15 +358,15 @@ function $e(n) {
355
358
  p,
356
359
  w ?? "",
357
360
  x ?? ""
358
- ], A = p ? 0 : 3e4, { data: t, isFetching: N } = q({
361
+ ], A = p ? 0 : 3e4, { data: n, isFetching: N } = q({
359
362
  queryKey: v(""),
360
363
  queryFn: () => b(""),
361
- enabled: n.enabled,
364
+ enabled: t.enabled,
362
365
  staleTime: A
363
- }), S = We(t, d, n.labelOf), { data: m, isFetching: L } = q({
366
+ }), S = We(n, d, t.labelOf), { data: m, isFetching: L } = q({
364
367
  queryKey: v(d),
365
368
  queryFn: () => b(d),
366
- enabled: n.enabled && S,
369
+ enabled: t.enabled && S,
367
370
  staleTime: A
368
371
  });
369
372
  return S ? {
@@ -371,17 +374,17 @@ function $e(n) {
371
374
  isLoading: !m && L,
372
375
  localSearch: !1,
373
376
  closeMatches: Ve(m)
374
- } : { options: t ?? [], isLoading: !t && N, localSearch: !!d };
377
+ } : { options: n ?? [], isLoading: !n && N, localSearch: !!d };
375
378
  }
376
379
  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;
380
+ function We(t, i, f) {
381
+ return i.trim() ? !t || t.length >= De ? !0 : oe(t, i, !0, f).length === 0 : !1;
379
382
  }
380
- function oe(n, i, f, d) {
381
- return !f || !i.trim() ? n : n.filter((p) => Ge(d(p), i));
383
+ function oe(t, i, f, d) {
384
+ return !f || !i.trim() ? t : t.filter((p) => Re(d(p), i));
382
385
  }
383
- function ht({
384
- relation: n,
386
+ function yt({
387
+ relation: t,
385
388
  parentId: i,
386
389
  allRelations: f,
387
390
  extraFilter: d,
@@ -390,26 +393,26 @@ function ht({
390
393
  onCountChange: x,
391
394
  readOnly: b
392
395
  }) {
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({
396
+ const v = xe(), A = Ge(), n = Ie(), [N, S] = E(!1), [m, L] = E(""), j = f.find(
397
+ (l) => l.many_collection === t.many_collection && l.many_field === t.junction_field && l.id !== t.id
398
+ ), s = Ke(j), O = t.junction_field ?? "", z = t.many_field ?? "", h = t.one_field ?? `${t.many_collection}.${O}`, { data: o } = q({
396
399
  queryKey: ["col-meta", s],
397
400
  queryFn: () => v.request(U(`/collections/${s}`)).then((l) => l.data),
398
401
  enabled: !!s,
399
402
  staleTime: 3e5,
400
403
  retry: !1
401
404
  }), { data: H = [], isFetching: ce } = q({
402
- queryKey: ["m2m-items", n.many_collection, R, i],
405
+ queryKey: ["m2m-items", t.many_collection, z, i],
403
406
  queryFn: () => v.request(
404
- U(`/items/${n.many_collection}`, {
405
- filter: JSON.stringify({ [R]: { _eq: i } }),
407
+ U(`/items/${t.many_collection}`, {
408
+ filter: JSON.stringify({ [z]: { _eq: i } }),
406
409
  limit: 1,
407
410
  fields: `id,${O}`
408
411
  })
409
412
  ).then((l) => l.data ?? []),
410
413
  staleTime: 3e4,
411
414
  enabled: !!i && i !== "new"
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 = (() => {
415
+ }), G = ge().isAdmin, R = s === "nivaro_users" ? we(G) : null, Y = ke(s === "nivaro_users"), V = d ? R ? { _and: [d, R] } : d : R, B = V ? JSON.stringify(V) : void 0, Z = p && !/^-?label$/.test(p) ? p : void 0, ee = (() => {
413
416
  const l = o == null ? void 0 : o.display_template;
414
417
  if (!l || !l.includes(".")) return null;
415
418
  const g = [...l.matchAll(/\{\{([^}]+)\}\}/g)].map((ie) => ie[1].trim());
@@ -428,7 +431,7 @@ function ht({
428
431
  templateNestedFields: ee,
429
432
  enabled: N && !!s,
430
433
  labelOf: e
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);
434
+ }), re = Pe(!!ne, m), F = (n == null ? void 0 : n.getStagedLinks(h)) ?? [], D = (n == null ? void 0 : n.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
435
  P.current = x, pe(() => {
433
436
  var l;
434
437
  (l = P.current) == null || l.call(P, y != null ? 1 : 0);
@@ -453,18 +456,18 @@ function ht({
453
456
  }), W = I !== void 0 && I.length === 0, _ = Be(W);
454
457
  function e(l) {
455
458
  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 ?? "");
459
+ return g ? Ae(g, l) : String(l.name ?? l.title ?? l.label ?? l.id ?? "");
457
460
  }
458
461
  const a = K.find((l) => String(l.id) === String(y)) ?? J, u = y != null && !J && !a, C = a ? e(a) : null;
459
462
  if (b)
460
463
  return /* @__PURE__ */ r("span", { className: "block truncate text-[12px] text-slate-700 dark:text-slate-200", children: u ? "…" : C ?? "—" });
461
464
  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("");
465
+ for (const g of F) n == null || n.unstageLink(h, g);
466
+ k && !D.has(k.id) && (n == null || n.stageUnlink(h, k.id)), String(l) === String(T) && k ? n == null || n.unstageUnlink(h, k.id) : String(l) !== String(y) && (n == null || n.stageLink(h, l)), S(!1), L("");
464
467
  }
465
468
  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);
469
+ for (const l of F) n == null || n.unstageLink(h, l);
470
+ k && (n == null || n.stageUnlink(h, k.id)), S(!1);
468
471
  }
469
472
  return w ? /* @__PURE__ */ c(
470
473
  "button",
@@ -483,14 +486,14 @@ function ht({
483
486
  }
484
487
  ) : /* @__PURE__ */ c("div", { ..._.bind, children: [
485
488
  /* @__PURE__ */ c(
486
- Fe,
489
+ qe,
487
490
  {
488
491
  open: N,
489
492
  onOpenChange: (l) => {
490
493
  S(l), l || L("");
491
494
  },
492
495
  children: [
493
- /* @__PURE__ */ r(qe, { asChild: !0, children: /* @__PURE__ */ c(
496
+ /* @__PURE__ */ r(je, { asChild: !0, children: /* @__PURE__ */ c(
494
497
  "button",
495
498
  {
496
499
  type: "button",
@@ -507,7 +510,7 @@ function ht({
507
510
  C ? se ? "text-nvr-cyan" : "text-slate-800 dark:text-slate-100" : "text-muted-foreground"
508
511
  ),
509
512
  children: [
510
- W && /* @__PURE__ */ r(he, { className: "h-3.5 w-3.5 shrink-0 text-amber-500" }),
513
+ W && /* @__PURE__ */ r(ye, { className: "h-3.5 w-3.5 shrink-0 text-amber-500" }),
511
514
  /* @__PURE__ */ r("span", { className: "truncate", children: C ?? "Select…" })
512
515
  ]
513
516
  }
@@ -516,14 +519,14 @@ function ht({
516
519
  ]
517
520
  }
518
521
  ) }),
519
- /* @__PURE__ */ r(je, { className: "w-[320px] p-0", align: "start", children: /* @__PURE__ */ c(
520
- Se,
522
+ /* @__PURE__ */ r(Te, { className: "w-[320px] p-0", align: "start", children: /* @__PURE__ */ c(
523
+ Ne,
521
524
  {
522
525
  shouldFilter: !1,
523
526
  ...re,
524
527
  children: [
525
528
  /* @__PURE__ */ r(
526
- Ne,
529
+ _e,
527
530
  {
528
531
  placeholder: "Search…",
529
532
  value: m,
@@ -545,8 +548,8 @@ function ht({
545
548
  ]
546
549
  }
547
550
  ),
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" }),
551
+ /* @__PURE__ */ c(Ce, { children: [
552
+ $ ? /* @__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(Le, { className: "py-3 text-left text-[12px] text-muted-foreground px-3", children: "No results" }),
550
553
  !$ && ne && /* @__PURE__ */ c(
551
554
  "p",
552
555
  {
@@ -559,12 +562,12 @@ function ht({
559
562
  ]
560
563
  }
561
564
  ),
562
- !$ && /* @__PURE__ */ r(Le, { children: [...oe(K, m, te, e)].sort(
563
- (l, g) => Z ? 0 : ge(e(l), e(g), m, p === "-label")
565
+ !$ && /* @__PURE__ */ r(Oe, { children: [...oe(K, m, te, e)].sort(
566
+ (l, g) => Z ? 0 : ve(e(l), e(g), m, p === "-label")
564
567
  ).map((l) => {
565
568
  const g = String(l.id), ie = String(y) === g;
566
569
  return /* @__PURE__ */ c(
567
- Oe,
570
+ Fe,
568
571
  {
569
572
  value: g,
570
573
  onSelect: () => Je(l.id),
@@ -577,15 +580,15 @@ function ht({
577
580
  "flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",
578
581
  ie ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300 dark:border-slate-500"
579
582
  ),
580
- children: ie && /* @__PURE__ */ r(ye, { className: "h-2.5 w-2.5 text-white" })
583
+ children: ie && /* @__PURE__ */ r(be, { className: "h-2.5 w-2.5 text-white" })
581
584
  }
582
585
  ),
583
586
  s === "nivaro_users" && /* @__PURE__ */ r(
584
- we,
587
+ Se,
585
588
  {
586
589
  userId: g,
587
590
  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)) })
591
+ 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: Ue(e(l)) })
589
592
  }
590
593
  ),
591
594
  s === "nivaro_users" && Y.has(g.toUpperCase()) && /* @__PURE__ */ r(
@@ -611,11 +614,11 @@ function ht({
611
614
  _.tip
612
615
  ] });
613
616
  }
614
- function Pe(n, i) {
617
+ function Pe(t, i) {
615
618
  const [f, d] = E(null), [p, w] = E(!1), x = fe(!1);
616
619
  return pe(() => {
617
620
  d(null), x.current = !1;
618
- }, [i]), n ? {
621
+ }, [i]), t ? {
619
622
  value: f ?? (p ? " " : ""),
620
623
  onValueChange: (b) => {
621
624
  x.current ? d(b) : w((v) => !v);
@@ -629,9 +632,10 @@ function Pe(n, i) {
629
632
  } : {};
630
633
  }
631
634
  export {
632
- pt as M2MCombobox,
633
- ht as M2MSingleSelectCombobox,
634
- ft as m2aWriteMeta,
635
+ ht as M2MCombobox,
636
+ yt as M2MSingleSelectCombobox,
637
+ ft as m2aAllowedCount,
638
+ pt as m2aWriteMeta,
635
639
  We as m2mAsksServer,
636
640
  Q as m2mIdKey,
637
641
  oe as narrowM2MOptions,
@@ -1,52 +1,52 @@
1
1
  import { jsx as l, jsxs as f } from "react/jsx-runtime";
2
- import { useQueryClient as V, useQuery as U } from "@tanstack/react-query";
3
- import { Wrench as X, ShieldAlert as Y, Loader2 as F } from "lucide-react";
4
- import { useState as w, useMemo as K } from "react";
5
- import { toast as Q } from "sonner";
6
- import { useNivaroClient as Z } from "../../context.js";
7
- import { get as C, patch as I, del as ee, post as te } from "../../lib/commands.js";
8
- import { titleCase as T } from "../../lib/utils.js";
9
- import { Button as W } from "../ui/button.js";
10
- import { Sheet as ne, SheetContent as ae, SheetHeader as re, SheetTitle as se } from "../ui/sheet.js";
11
- import { ChangeReasonDialog as ie, changeReasonChallenge as le } from "./ChangeReasonDialog.js";
12
- import { FieldRenderer as oe } from "./FieldRenderer.js";
13
- import { M2MCombobox as ce, m2aWriteMeta as de } from "./M2MCombobox.js";
14
- import { M2MStagingContext as me } from "./M2MStagingContext.js";
15
- import { invalidateM2MFor as fe } from "./m2m-invalidate.js";
16
- function A(a, i) {
2
+ import { useQueryClient as X, useQuery as R } from "@tanstack/react-query";
3
+ import { Wrench as Y, ShieldAlert as Z, Loader2 as U } from "lucide-react";
4
+ import { useState as w, useMemo as A } from "react";
5
+ import { toast as F } from "sonner";
6
+ import { useNivaroClient as I } from "../../context.js";
7
+ import { get as $, patch as ee, del as te, post as ne } from "../../lib/commands.js";
8
+ import { titleCase as Q } from "../../lib/utils.js";
9
+ import { Button as T } from "../ui/button.js";
10
+ import { Sheet as ae, SheetContent as re, SheetHeader as se, SheetTitle as ie } from "../ui/sheet.js";
11
+ import { ChangeReasonDialog as le, changeReasonChallenge as oe } from "./ChangeReasonDialog.js";
12
+ import { FieldRenderer as ce } from "./FieldRenderer.js";
13
+ import { M2MCombobox as de, m2aAllowedCount as me, m2aWriteMeta as fe } from "./M2MCombobox.js";
14
+ import { M2MStagingContext as ue } from "./M2MStagingContext.js";
15
+ import { invalidateM2MFor as pe } from "./m2m-invalidate.js";
16
+ function W(s, i) {
17
17
  const u = (p) => p == null || p === "";
18
- return u(a) && u(i) ? !0 : typeof a == "number" || typeof i == "number" ? Number(a) === Number(i) : typeof a == "boolean" || typeof i == "boolean" ? String(a) === String(i) : typeof a == "object" || typeof i == "object" ? JSON.stringify(a) === JSON.stringify(i) : String(a) === String(i);
18
+ return u(s) && u(i) ? !0 : typeof s == "number" || typeof i == "number" ? Number(s) === Number(i) : typeof s == "boolean" || typeof i == "boolean" ? String(s) === String(i) : typeof s == "object" || typeof i == "object" ? JSON.stringify(s) === JSON.stringify(i) : String(s) === String(i);
19
19
  }
20
- function E(a) {
21
- if (a == null || a === "") return "∅";
22
- const i = typeof a == "object" ? JSON.stringify(a) : String(a);
20
+ function E(s) {
21
+ if (s == null || s === "") return "∅";
22
+ const i = typeof s == "object" ? JSON.stringify(s) : String(s);
23
23
  return i.length > 60 ? `${i.slice(0, 57)}…` : i;
24
24
  }
25
- function qe({
26
- collection: a,
25
+ function $e({
26
+ collection: s,
27
27
  itemId: i,
28
28
  open: u,
29
29
  onClose: p,
30
30
  onSaved: S
31
31
  }) {
32
- const h = Z(), M = V(), [m, _] = w({}), [g, v] = w(/* @__PURE__ */ new Map()), [x, N] = w(/* @__PURE__ */ new Map()), [k, L] = w(!1), [J, j] = w(null), { data: c } = U({
33
- queryKey: ["raw-edit-config", a],
32
+ const h = I(), M = X(), [m, j] = w({}), [g, v] = w(/* @__PURE__ */ new Map()), [x, k] = w(/* @__PURE__ */ new Map()), [N, L] = w(!1), [J, q] = w(null), { data: c } = R({
33
+ queryKey: ["raw-edit-config", s],
34
34
  queryFn: async () => {
35
- const [e, r] = await Promise.all([
36
- h.request(C(`/field-config/${a}`)).then((s) => s.data ?? []),
37
- h.request(C(`/collections/${a}`)).then((s) => s.data)
35
+ const [e, n] = await Promise.all([
36
+ h.request($(`/field-config/${s}`)).then((r) => r.data ?? []),
37
+ h.request($(`/collections/${s}`)).then((r) => r.data)
38
38
  ]);
39
- return { fields: e, relations: r.relations ?? [] };
39
+ return { fields: e, relations: n.relations ?? [] };
40
40
  },
41
41
  enabled: u,
42
42
  staleTime: 6e4
43
- }), { data: o, isLoading: P } = U({
44
- queryKey: ["raw-edit-record", a, i],
45
- queryFn: () => h.request(C(`/items/${a}/${i}`)).then((e) => e.data),
43
+ }), { data: o, isLoading: P } = R({
44
+ queryKey: ["raw-edit-record", s, i],
45
+ queryFn: () => h.request($(`/items/${s}/${i}`)).then((e) => e.data),
46
46
  enabled: u,
47
47
  staleTime: 0
48
- }), D = K(() => {
49
- const e = (c == null ? void 0 : c.fields) ?? [], r = (c == null ? void 0 : c.relations) ?? [], s = (t) => r.some((n) => n.one_collection === a && n.one_field === t.field);
48
+ }), D = A(() => {
49
+ const e = (c == null ? void 0 : c.fields) ?? [], n = (c == null ? void 0 : c.relations) ?? [], r = (t) => n.some((a) => a.one_collection === s && a.one_field === t.field);
50
50
  return e.filter((t) => !t.field.startsWith("__")).map((t) => ({
51
51
  // Strip every conditional/curation config — raw mode ignores them all
52
52
  field: {
@@ -57,127 +57,132 @@ function qe({
57
57
  lock_condition: null,
58
58
  dependency_config: null
59
59
  },
60
- alias: s(t),
61
- m2mRel: r.find(
62
- (n) => n.one_collection === a && n.one_field === t.field && n.junction_field != null
60
+ alias: r(t),
61
+ m2mRel: n.find(
62
+ (a) => a.one_collection === s && a.one_field === t.field && a.junction_field != null
63
63
  )
64
- })).sort((t, n) => (t.field.sort ?? 0) - (n.field.sort ?? 0));
65
- }, [c, a]), q = (c == null ? void 0 : c.relations) ?? [], O = (e) => q.find(
66
- (r) => r.one_collection === a && r.one_field === e && r.junction_field != null
67
- ), B = K(
64
+ })).sort((t, a) => (t.field.sort ?? 0) - (a.field.sort ?? 0));
65
+ }, [c, s]), _ = (c == null ? void 0 : c.relations) ?? [], O = (e) => _.find(
66
+ (n) => n.one_collection === s && n.one_field === e && n.junction_field != null
67
+ ), B = (e) => {
68
+ const n = _.find(
69
+ (r) => r.many_collection === e.many_collection && r.many_field === e.junction_field && r.id !== e.id
70
+ );
71
+ return !n || n.one_collection ? !1 : me(n) > 1;
72
+ }, H = A(
68
73
  () => ({
69
74
  getStagedLinks: (e) => g.get(e) ?? [],
70
75
  getStagedUnlinks: (e) => x.get(e) ?? /* @__PURE__ */ new Set(),
71
- stageLink: (e, r) => v((s) => {
72
- const t = new Map(s);
73
- return t.set(e, [...t.get(e) ?? [], r]), t;
76
+ stageLink: (e, n) => v((r) => {
77
+ const t = new Map(r);
78
+ return t.set(e, [...t.get(e) ?? [], n]), t;
74
79
  }),
75
- unstageLink: (e, r) => v((s) => {
76
- const t = new Map(s);
80
+ unstageLink: (e, n) => v((r) => {
81
+ const t = new Map(r);
77
82
  return t.set(
78
83
  e,
79
- (t.get(e) ?? []).filter((n) => String(n) !== String(r))
84
+ (t.get(e) ?? []).filter((a) => String(a) !== String(n))
80
85
  ), t;
81
86
  }),
82
- stageUnlink: (e, r) => N((s) => {
83
- const t = new Map(s), n = new Set(t.get(e) ?? []);
84
- return n.add(r), t.set(e, n), t;
87
+ stageUnlink: (e, n) => k((r) => {
88
+ const t = new Map(r), a = new Set(t.get(e) ?? []);
89
+ return a.add(n), t.set(e, a), t;
85
90
  }),
86
- unstageUnlink: (e, r) => N((s) => {
87
- const t = new Map(s), n = new Set(t.get(e) ?? []);
88
- return n.delete(r), t.set(e, n), t;
91
+ unstageUnlink: (e, n) => k((r) => {
92
+ const t = new Map(r), a = new Set(t.get(e) ?? []);
93
+ return a.delete(n), t.set(e, a), t;
89
94
  })
90
95
  }),
91
96
  [g, x]
92
- ), H = [...g.values()].some((e) => e.length > 0) || [...x.values()].some((e) => e.size > 0), R = Object.keys(m).length > 0 || H, z = async (e) => {
93
- var r;
97
+ ), G = [...g.values()].some((e) => e.length > 0) || [...x.values()].some((e) => e.size > 0), z = Object.keys(m).length > 0 || G, K = async (e) => {
98
+ var n;
94
99
  L(!0);
95
100
  try {
96
101
  if (Object.keys(m).length > 0) {
97
102
  const t = { ...m };
98
- e && (t._change_reason = e), await h.request(I(`/items/${a}/${i}`, t));
103
+ e && (t._change_reason = e), await h.request(ee(`/items/${s}/${i}`, t));
99
104
  }
100
- const s = [];
101
- for (const [t, n] of x.entries()) {
102
- if (!n.size) continue;
105
+ const r = [];
106
+ for (const [t, a] of x.entries()) {
107
+ if (!a.size) continue;
103
108
  const d = O(t);
104
109
  if (d)
105
- for (const y of n)
106
- s.push(h.request(ee(`/items/${d.many_collection}/${y}`)).catch(() => {
110
+ for (const y of a)
111
+ r.push(h.request(te(`/items/${d.many_collection}/${y}`)).catch(() => {
107
112
  }));
108
113
  }
109
- for (const [t, n] of g.entries()) {
110
- if (!n.length) continue;
114
+ for (const [t, a] of g.entries()) {
115
+ if (!a.length) continue;
111
116
  const d = O(t);
112
117
  if (!d) continue;
113
- const y = q.find(
118
+ const y = _.find(
114
119
  (b) => b.many_collection === d.many_collection && b.many_field === d.junction_field && b.id !== d.id
115
- ), $ = de(y), G = $ ? { [$.field]: $.value } : {};
116
- for (const b of n)
117
- s.push(
120
+ ), C = fe(y), V = C ? { [C.field]: C.value } : {};
121
+ for (const b of a)
122
+ r.push(
118
123
  h.request(
119
- te(`/items/${d.many_collection}`, {
124
+ ne(`/items/${d.many_collection}`, {
120
125
  [d.many_field ?? ""]: i,
121
126
  [d.junction_field ?? ""]: b,
122
- ...G
127
+ ...V
123
128
  })
124
129
  ).catch(() => {
125
130
  })
126
131
  );
127
132
  }
128
- await Promise.all(s), Q.success("Raw changes saved"), _({}), v(/* @__PURE__ */ new Map()), N(/* @__PURE__ */ new Map()), M.invalidateQueries({ queryKey: ["item", a, String(i)] }), M.invalidateQueries({ queryKey: ["raw-edit-record", a, i] }), fe(M, [i]), S == null || S(), p();
129
- } catch (s) {
130
- const t = le(s);
133
+ await Promise.all(r), F.success("Raw changes saved"), j({}), v(/* @__PURE__ */ new Map()), k(/* @__PURE__ */ new Map()), M.invalidateQueries({ queryKey: ["item", s, String(i)] }), M.invalidateQueries({ queryKey: ["raw-edit-record", s, i] }), pe(M, [i]), S == null || S(), p();
134
+ } catch (r) {
135
+ const t = oe(r);
131
136
  if (t) {
132
- j(t);
137
+ q(t);
133
138
  return;
134
139
  }
135
- const n = s == null ? void 0 : s.response;
136
- Q.error(((r = n == null ? void 0 : n.data) == null ? void 0 : r.error) ?? (n == null ? void 0 : n.error) ?? "Save failed");
140
+ const a = r == null ? void 0 : r.response;
141
+ F.error(((n = a == null ? void 0 : a.data) == null ? void 0 : n.error) ?? (a == null ? void 0 : a.error) ?? "Save failed");
137
142
  } finally {
138
143
  L(!1);
139
144
  }
140
145
  };
141
146
  return /* @__PURE__ */ l(
142
- ne,
147
+ ae,
143
148
  {
144
149
  open: u,
145
150
  onOpenChange: (e) => {
146
- e || k || (_({}), v(/* @__PURE__ */ new Map()), N(/* @__PURE__ */ new Map()), p());
151
+ e || N || (j({}), v(/* @__PURE__ */ new Map()), k(/* @__PURE__ */ new Map()), p());
147
152
  },
148
153
  children: /* @__PURE__ */ f(
149
- ae,
154
+ re,
150
155
  {
151
156
  side: "right",
152
157
  className: "flex w-[1040px] max-w-[94vw] flex-col p-0 sm:max-w-[94vw]",
153
158
  children: [
154
- /* @__PURE__ */ l(re, { className: "shrink-0 border-b border-slate-200 px-5 py-3 dark:border-border", children: /* @__PURE__ */ f(se, { className: "flex items-center gap-2 text-[14px]", children: [
155
- /* @__PURE__ */ l(X, { className: "h-4 w-4 text-nvr-cyan" }),
159
+ /* @__PURE__ */ l(se, { className: "shrink-0 border-b border-slate-200 px-5 py-3 dark:border-border", children: /* @__PURE__ */ f(ie, { className: "flex items-center gap-2 text-[14px]", children: [
160
+ /* @__PURE__ */ l(Y, { className: "h-4 w-4 text-nvr-cyan" }),
156
161
  "Raw edit — ",
157
- T(a),
162
+ Q(s),
158
163
  " #",
159
164
  i
160
165
  ] }) }),
161
166
  /* @__PURE__ */ f("p", { className: "flex shrink-0 items-center gap-2 border-b border-amber-200 bg-amber-50 px-5 py-2 text-[12px] text-amber-800 dark:border-amber-500/20 dark:bg-amber-500/10 dark:text-amber-300", children: [
162
- /* @__PURE__ */ l(Y, { className: "h-3.5 w-3.5 shrink-0" }),
167
+ /* @__PURE__ */ l(Z, { className: "h-3.5 w-3.5 shrink-0" }),
163
168
  "Admin raw mode — visibility rules, locks, cascades and layout restrictions are bypassed. Server-side validation still applies. Every change is recorded in the revision history."
164
169
  ] }),
165
- /* @__PURE__ */ l("div", { className: "min-h-0 flex-1 overflow-y-auto px-5 py-4", children: P || !c ? /* @__PURE__ */ l("div", { className: "flex justify-center py-10", children: /* @__PURE__ */ l(F, { className: "h-5 w-5 animate-spin text-slate-400" }) }) : /* @__PURE__ */ l("div", { className: "space-y-3", children: D.map(({ field: e, alias: r, m2mRel: s }) => {
166
- const t = e.field in m ? m[e.field] : o == null ? void 0 : o[e.field], n = e.field in m && !A(m[e.field], o == null ? void 0 : o[e.field]);
170
+ /* @__PURE__ */ l("div", { className: "min-h-0 flex-1 overflow-y-auto px-5 py-4", children: P || !c ? /* @__PURE__ */ l("div", { className: "flex justify-center py-10", children: /* @__PURE__ */ l(U, { className: "h-5 w-5 animate-spin text-slate-400" }) }) : /* @__PURE__ */ l("div", { className: "space-y-3", children: D.map(({ field: e, alias: n, m2mRel: r }) => {
171
+ const t = e.field in m ? m[e.field] : o == null ? void 0 : o[e.field], a = e.field in m && !W(m[e.field], o == null ? void 0 : o[e.field]);
167
172
  return /* @__PURE__ */ f(
168
173
  "div",
169
174
  {
170
- className: `grid grid-cols-[220px_1fr] items-start gap-3 rounded-md ${n ? "-mx-2 bg-amber-50 px-2 py-1 ring-1 ring-amber-200 dark:bg-amber-400/10 dark:ring-amber-500/30" : ""}`,
171
- "data-raw-changed": n ? e.field : void 0,
175
+ className: `grid grid-cols-[220px_1fr] items-start gap-3 rounded-md ${a ? "-mx-2 bg-amber-50 px-2 py-1 ring-1 ring-amber-200 dark:bg-amber-400/10 dark:ring-amber-500/30" : ""}`,
176
+ "data-raw-changed": a ? e.field : void 0,
172
177
  "data-raw-field": e.field,
173
178
  children: [
174
179
  /* @__PURE__ */ f("div", { className: "pt-1.5", children: [
175
180
  /* @__PURE__ */ f("p", { className: "text-[12px] font-medium text-slate-700 dark:text-slate-200", children: [
176
- e.label || T(e.field),
177
- n && /* @__PURE__ */ l("span", { className: "ml-1.5 rounded bg-amber-200/70 px-1 text-[9px] font-semibold uppercase tracking-wide text-amber-900 dark:bg-amber-500/20 dark:text-amber-200", children: "changed" })
181
+ e.label || Q(e.field),
182
+ a && /* @__PURE__ */ l("span", { className: "ml-1.5 rounded bg-amber-200/70 px-1 text-[9px] font-semibold uppercase tracking-wide text-amber-900 dark:bg-amber-500/20 dark:text-amber-200", children: "changed" })
178
183
  ] }),
179
184
  /* @__PURE__ */ l("p", { className: "font-mono text-[10.5px] text-slate-400", children: e.field }),
180
- n && /* @__PURE__ */ f(
185
+ a && /* @__PURE__ */ f(
181
186
  "p",
182
187
  {
183
188
  className: "mt-0.5 truncate text-[10.5px] text-slate-400",
@@ -189,14 +194,26 @@ function qe({
189
194
  }
190
195
  )
191
196
  ] }),
192
- e.field === "id" ? /* @__PURE__ */ l("p", { className: "pt-1.5 font-mono text-[12px] text-slate-500", children: String(t ?? "") }) : r && s ? /* @__PURE__ */ l(me.Provider, { value: B, children: /* @__PURE__ */ l(ce, { relation: s, parentId: i, allRelations: q }) }) : r ? /* @__PURE__ */ l("p", { className: "pt-1.5 text-[11.5px] italic text-slate-400", children: "Child rows (one-to-many) — edit through the normal form" }) : /* @__PURE__ */ l(
193
- oe,
197
+ e.field === "id" ? /* @__PURE__ */ l("p", { className: "pt-1.5 font-mono text-[12px] text-slate-500", children: String(t ?? "") }) : n && r && B(r) ? (
198
+ // A ship-to contact is a person OR an external email: the
199
+ // picker here reads every link as a person, so an external
200
+ // email showed "Record not found". The normal form edits it.
201
+ /* @__PURE__ */ l(
202
+ "p",
203
+ {
204
+ className: "pt-1.5 text-[11.5px] italic text-slate-400",
205
+ "data-raw-m2a": e.field,
206
+ children: "Links to more than one kind of record — edit through the normal form"
207
+ }
208
+ )
209
+ ) : n && r ? /* @__PURE__ */ l(ue.Provider, { value: H, children: /* @__PURE__ */ l(de, { relation: r, parentId: i, allRelations: _ }) }) : n ? /* @__PURE__ */ l("p", { className: "pt-1.5 text-[11.5px] italic text-slate-400", children: "Child rows (one-to-many) — edit through the normal form" }) : /* @__PURE__ */ l(
210
+ ce,
194
211
  {
195
212
  field: e,
196
213
  value: t,
197
- onChange: (d) => _((y) => ({ ...y, [e.field]: d })),
214
+ onChange: (d) => j((y) => ({ ...y, [e.field]: d })),
198
215
  relations: c.relations,
199
- collection: a,
216
+ collection: s,
200
217
  itemId: i
201
218
  }
202
219
  )
@@ -207,22 +224,22 @@ function qe({
207
224
  }) }) }),
208
225
  /* @__PURE__ */ f("div", { className: "flex shrink-0 items-center justify-between gap-3 border-t border-slate-200 px-5 py-3 dark:border-border", children: [
209
226
  /* @__PURE__ */ l("span", { className: "text-[11.5px] text-slate-400", children: (() => {
210
- if (!R) return "No changes yet";
211
- const e = Object.keys(m).filter((r) => !A(m[r], o == null ? void 0 : o[r])).length + [...g.values()].filter((r) => r.length > 0).length + [...x.values()].filter((r) => r.size > 0).length;
227
+ if (!z) return "No changes yet";
228
+ const e = Object.keys(m).filter((n) => !W(m[n], o == null ? void 0 : o[n])).length + [...g.values()].filter((n) => n.length > 0).length + [...x.values()].filter((n) => n.size > 0).length;
212
229
  return e === 0 ? "No changes yet" : `${e} field${e !== 1 ? "s" : ""} changed`;
213
230
  })() }),
214
231
  /* @__PURE__ */ f("div", { className: "flex gap-2", children: [
215
- /* @__PURE__ */ l(W, { variant: "outline", size: "sm", onClick: p, disabled: k, children: "Cancel" }),
216
- /* @__PURE__ */ l(W, { size: "sm", onClick: () => void z(), disabled: !R || k, children: k ? /* @__PURE__ */ l(F, { className: "h-3.5 w-3.5 animate-spin" }) : "Save raw changes" })
232
+ /* @__PURE__ */ l(T, { variant: "outline", size: "sm", onClick: p, disabled: N, children: "Cancel" }),
233
+ /* @__PURE__ */ l(T, { size: "sm", onClick: () => void K(), disabled: !z || N, children: N ? /* @__PURE__ */ l(U, { className: "h-3.5 w-3.5 animate-spin" }) : "Save raw changes" })
217
234
  ] })
218
235
  ] }),
219
236
  /* @__PURE__ */ l(
220
- ie,
237
+ le,
221
238
  {
222
239
  challenge: J,
223
- onCancel: () => j(null),
240
+ onCancel: () => q(null),
224
241
  onSubmit: (e) => {
225
- j(null), z(e);
242
+ q(null), K(e);
226
243
  }
227
244
  }
228
245
  )
@@ -233,5 +250,5 @@ function qe({
233
250
  );
234
251
  }
235
252
  export {
236
- qe as RawEditSheet
253
+ $e as RawEditSheet
237
254
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nivaro/react",
3
- "version": "0.3.96",
3
+ "version": "0.3.97",
4
4
  "description": "React hooks and components for Nivaro CMS forms",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",