@nivaro/react 0.3.99 → 0.3.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useFormSchema.js +82 -85
  3. package/dist/hooks/useSessionRecorder.js +206 -175
  4. package/dist/index.d.ts +38 -13
  5. package/dist/index.js +182 -180
  6. package/dist/lib/commands.js +15 -11
  7. package/dist/shared/components/CollectionBrowserView.js +516 -503
  8. package/dist/shared/components/ItemEditForm.js +3021 -3019
  9. package/dist/shared/components/JobsTray.js +20 -16
  10. package/dist/shared/components/MyWorkView.js +133 -126
  11. package/dist/shared/components/NotificationBell.js +314 -288
  12. package/dist/shared/components/RecordCompare.js +38 -40
  13. package/dist/shared/components/RecordReadView.js +119 -119
  14. package/dist/shared/components/cbv/FoundElsewhere.js +61 -0
  15. package/dist/shared/components/item-edit/InlineGridField.js +45 -45
  16. package/dist/shared/components/item-edit/InlineTableField.js +750 -749
  17. package/dist/shared/components/item-edit/QuickPickerDialog.js +44 -44
  18. package/dist/shared/components/item-edit/RawEditSheet.js +122 -114
  19. package/dist/shared/components/item-edit/RelationCombobox.js +454 -378
  20. package/dist/shared/components/item-edit/SummaryPanel.js +56 -48
  21. package/dist/shared/components/item-edit/related-missing.js +75 -19
  22. package/dist/shared/components/notifications/NotificationCenterView.js +249 -226
  23. package/dist/shared/components/panels/AccessDeniedPanel.js +31 -28
  24. package/dist/shared/components/panels/BackgroundMove.js +175 -0
  25. package/dist/shared/components/panels/MoveAdvisory.js +204 -0
  26. package/dist/shared/components/panels/PipelinePanel.js +1450 -1219
  27. package/dist/shared/components/panels/RecordIntegrityBanner.js +113 -112
  28. package/dist/shared/lib/commands.js +18 -14
  29. package/dist/shared/lib/error-hints.js +1 -1
  30. package/dist/shared/lib/job-failure-text.js +12 -0
  31. package/dist/shared/lib/move-failure.js +9 -0
  32. package/dist/shared/lib/obligation-banner.js +15 -14
  33. package/dist/shared/lib/partner-failure.js +71 -0
  34. package/dist/shared/lib/prefetch.js +73 -73
  35. package/dist/shared/lib/replay-checkout.js +18 -13
  36. package/dist/shared/lib/replay-context.js +90 -77
  37. package/dist/shared/lib/replay-idle.js +21 -0
  38. package/dist/shared/lib/replay-socket.js +21 -17
  39. package/dist/shared/lib/rum.js +56 -51
  40. package/dist/shared/lib/safe-error.js +17 -13
  41. package/dist/shared/lib/stale-chunk.js +69 -26
  42. package/dist/shared/lib/system-collections.js +20 -0
  43. package/package.json +1 -1
@@ -1,18 +1,18 @@
1
- import { jsx as p, Fragment as T, jsxs as g } from "react/jsx-runtime";
1
+ import { jsx as p, Fragment as Q, jsxs as g } from "react/jsx-runtime";
2
2
  import { useQuery as _ } from "@tanstack/react-query";
3
- import { useState as F, useMemo as b, useCallback as P } from "react";
3
+ import { useState as N, useMemo as b, useCallback as F } from "react";
4
4
  import { useNivaroClient as D } from "../../context.js";
5
- import { get as x } from "../../lib/commands.js";
6
- import { titleCase as A } from "../../lib/utils.js";
7
- import { Dialog as I, DialogContent as S, DialogHeader as H, DialogTitle as J } from "../ui/dialog.js";
8
- import { Popover as R, PopoverAnchor as z, PopoverContent as B } from "../ui/popover.js";
9
- import { QuickPicker as E } from "./QuickPicker.js";
10
- function G(n, l) {
5
+ import { get as P, getActiveLayout as T } from "../../lib/commands.js";
6
+ import { titleCase as I } from "../../lib/utils.js";
7
+ import { Dialog as S, DialogContent as H, DialogHeader as J, DialogTitle as R } from "../ui/dialog.js";
8
+ import { Popover as z, PopoverAnchor as B, PopoverContent as E } from "../ui/popover.js";
9
+ import { QuickPicker as G } from "./QuickPicker.js";
10
+ function U(n, l) {
11
11
  var c;
12
12
  const o = D(), { data: r, isLoading: h } = _({
13
13
  queryKey: ["active-layout", n ?? "", l ?? null, "new"],
14
14
  queryFn: () => o.request(
15
- x("/collection-layouts/active", {
15
+ T({
16
16
  collection: n,
17
17
  ...l ? { slug: l } : {}
18
18
  })
@@ -26,7 +26,7 @@ function G(n, l) {
26
26
  return Array.isArray(s) ? s.filter((d) => typeof d == "string") : [];
27
27
  }, [r]), layoutId: ((c = r == null ? void 0 : r.layout) == null ? void 0 : c.id) ?? null, loading: h };
28
28
  }
29
- function ie({
29
+ function re({
30
30
  collection: n,
31
31
  layoutSlug: l,
32
32
  open: o,
@@ -35,22 +35,22 @@ function ie({
35
35
  noun: y = "record",
36
36
  anchorEl: c
37
37
  }) {
38
- const s = D(), { steps: f, layoutId: d } = G(o ? n : null, l), { data: a = [] } = _({
38
+ const s = D(), { steps: f, layoutId: d } = U(o ? n : null, l), { data: a = [] } = _({
39
39
  queryKey: ["field-config", n, d],
40
40
  queryFn: () => s.request(
41
- x(`/field-config/${n}`, d ? { layout_id: String(d) } : {})
41
+ P(`/field-config/${n}`, d ? { layout_id: String(d) } : {})
42
42
  ).then((e) => e.data ?? []),
43
43
  enabled: o && !!n,
44
44
  staleTime: 6e4
45
45
  }), { data: u = [] } = _({
46
46
  queryKey: ["relations-for", n],
47
- queryFn: () => s.request(x(`/data-model/relations/for/${n}`)).then((e) => e.data ?? []),
47
+ queryFn: () => s.request(P(`/data-model/relations/for/${n}`)).then((e) => e.data ?? []),
48
48
  enabled: o && !!n,
49
49
  staleTime: 3e5
50
- }), [q, C] = F({}), [k, w] = F({}), M = b(
51
- () => Object.fromEntries(a.map((e) => [e.field, e.label || A(e.field)])),
50
+ }), [x, q] = N({}), [k, C] = N({}), L = b(
51
+ () => Object.fromEntries(a.map((e) => [e.field, e.label || I(e.field)])),
52
52
  [a]
53
- ), $ = b(() => {
53
+ ), M = b(() => {
54
54
  const e = {};
55
55
  for (const t of a)
56
56
  try {
@@ -59,48 +59,48 @@ function ie({
59
59
  } catch {
60
60
  }
61
61
  return e;
62
- }, [a]), K = P(
62
+ }, [a]), $ = F(
63
63
  (e) => {
64
- var N;
64
+ var v;
65
65
  const t = u.find(
66
66
  (m) => m.one_collection === n && m.one_field === e
67
67
  );
68
68
  if (!t) return e;
69
- const i = t.junction_field ?? ((N = u.find((m) => m.many_collection === t.many_collection && m.id !== t.id)) == null ? void 0 : N.many_field);
69
+ const i = t.junction_field ?? ((v = u.find((m) => m.many_collection === t.many_collection && m.id !== t.id)) == null ? void 0 : v.many_field);
70
70
  return t.one_field ?? `${t.many_collection}.${i ?? ""}`;
71
71
  },
72
72
  [u, n]
73
- ), L = P((e) => k[e] ?? [], [k]), O = () => {
74
- C({}), w({});
75
- }, Q = () => {
73
+ ), A = F((e) => k[e] ?? [], [k]), w = () => {
74
+ q({}), C({});
75
+ }, K = () => {
76
76
  const e = {};
77
77
  for (const [t, i] of Object.entries(k))
78
- i.length && (e[K(t)] = i);
79
- h({ ...q, ...Object.keys(e).length ? { __links: e } : {} }), O();
80
- }, j = /* @__PURE__ */ p(T, { children: f.length > 0 && a.length > 0 && u.length > 0 && /* @__PURE__ */ p(
81
- E,
78
+ i.length && (e[$(t)] = i);
79
+ h({ ...x, ...Object.keys(e).length ? { __links: e } : {} }), w();
80
+ }, O = /* @__PURE__ */ p(Q, { children: f.length > 0 && a.length > 0 && u.length > 0 && /* @__PURE__ */ p(
81
+ G,
82
82
  {
83
83
  collection: n,
84
84
  itemId: "new",
85
85
  steps: f,
86
86
  fieldConfig: a,
87
87
  relations: u,
88
- draft: q,
89
- getM2M: L,
90
- onChange: (e, t) => C((i) => ({ ...i, [e]: t })),
91
- onM2MChange: (e, t) => w((i) => ({ ...i, [e]: t })),
92
- fieldLabels: M,
93
- fieldOptionFilters: $,
94
- onFinish: Q,
88
+ draft: x,
89
+ getM2M: A,
90
+ onChange: (e, t) => q((i) => ({ ...i, [e]: t })),
91
+ onM2MChange: (e, t) => C((i) => ({ ...i, [e]: t })),
92
+ fieldLabels: L,
93
+ fieldOptionFilters: M,
94
+ onFinish: K,
95
95
  finishLabel: `Create ${y}`
96
96
  }
97
- ) }), v = (e) => {
98
- e || O(), r(e);
97
+ ) }), j = (e) => {
98
+ e || w(), r(e);
99
99
  };
100
- return c ? /* @__PURE__ */ g(R, { open: o, onOpenChange: v, children: [
101
- /* @__PURE__ */ p(z, { virtualRef: { current: c } }),
100
+ return c ? /* @__PURE__ */ g(z, { open: o, onOpenChange: j, children: [
101
+ /* @__PURE__ */ p(B, { virtualRef: { current: c } }),
102
102
  /* @__PURE__ */ g(
103
- B,
103
+ E,
104
104
  {
105
105
  align: "end",
106
106
  sideOffset: 6,
@@ -111,19 +111,19 @@ function ie({
111
111
  "New ",
112
112
  y
113
113
  ] }),
114
- j
114
+ O
115
115
  ]
116
116
  }
117
117
  )
118
- ] }) : /* @__PURE__ */ p(I, { open: o, onOpenChange: v, children: /* @__PURE__ */ g(S, { className: "max-w-[540px]", "data-quick-picker-dialog": !0, children: [
119
- /* @__PURE__ */ p(H, { children: /* @__PURE__ */ g(J, { className: "text-[15px]", children: [
118
+ ] }) : /* @__PURE__ */ p(S, { open: o, onOpenChange: j, children: /* @__PURE__ */ g(H, { className: "max-w-[540px]", "data-quick-picker-dialog": !0, children: [
119
+ /* @__PURE__ */ p(J, { children: /* @__PURE__ */ g(R, { className: "text-[15px]", children: [
120
120
  "New ",
121
121
  y
122
122
  ] }) }),
123
- j
123
+ O
124
124
  ] }) });
125
125
  }
126
126
  export {
127
- ie as QuickPickerDialog,
128
- G as useQuickPickerSteps
127
+ re as QuickPickerDialog,
128
+ U as useQuickPickerSteps
129
129
  };
@@ -1,175 +1,183 @@
1
1
  import { jsx as l, jsxs as f } from "react/jsx-runtime";
2
- import { useQueryClient as Y, useQuery as U } from "@tanstack/react-query";
3
- import { Wrench as Z, ShieldAlert as I, Loader2 as F } from "lucide-react";
4
- import { useState as w, useMemo as P } from "react";
5
- import { toast as Q } from "sonner";
6
- import { useNivaroClient as ee } from "../../context.js";
7
- import { get as $, patch as te, del as ne, post as ae } 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 re, SheetContent as ie, SheetHeader as se, SheetTitle as le } from "../ui/sheet.js";
11
- import { ChangeReasonDialog as oe, changeReasonChallenge as ce } from "./ChangeReasonDialog.js";
12
- import { FieldRenderer as de } from "./FieldRenderer.js";
13
- import { M2MCombobox as me, m2aAllowedCount as fe, m2aWriteMeta as ue } from "./M2MCombobox.js";
14
- import { M2MStagingContext as D } from "./M2MStagingContext.js";
15
- import { invalidateM2MFor as pe } from "./m2m-invalidate.js";
16
- import { RawM2ALinks as he } from "./RawM2ALinks.js";
17
- function E(i, s) {
2
+ import { useQueryClient as Z, useQuery as U } from "@tanstack/react-query";
3
+ import { Wrench as I, ShieldAlert as ee, Loader2 as P } from "lucide-react";
4
+ import { useState as _, useMemo as Q } from "react";
5
+ import { toast as T } from "sonner";
6
+ import { useNivaroClient as te } from "../../context.js";
7
+ import { get as $, patch as ne, del as ie, post as ae } from "../../lib/commands.js";
8
+ import { isFileCollection as re } from "../../lib/system-collections.js";
9
+ import { titleCase as W } from "../../lib/utils.js";
10
+ import { Button as D } from "../ui/button.js";
11
+ import { Sheet as se, SheetContent as le, SheetHeader as oe, SheetTitle as ce } from "../ui/sheet.js";
12
+ import { ChangeReasonDialog as de, changeReasonChallenge as me } from "./ChangeReasonDialog.js";
13
+ import { FieldRenderer as fe } from "./FieldRenderer.js";
14
+ import { M2MCombobox as ue, m2aAllowedCount as pe, m2aWriteMeta as he } from "./M2MCombobox.js";
15
+ import { M2MStagingContext as E } from "./M2MStagingContext.js";
16
+ import { invalidateM2MFor as ge } from "./m2m-invalidate.js";
17
+ import { RawM2ALinks as ye } from "./RawM2ALinks.js";
18
+ function J(r, s) {
18
19
  const u = (p) => p == null || p === "";
19
- return u(i) && u(s) ? !0 : typeof i == "number" || typeof s == "number" ? Number(i) === Number(s) : typeof i == "boolean" || typeof s == "boolean" ? String(i) === String(s) : typeof i == "object" || typeof s == "object" ? JSON.stringify(i) === JSON.stringify(s) : String(i) === String(s);
20
+ return u(r) && u(s) ? !0 : typeof r == "number" || typeof s == "number" ? Number(r) === Number(s) : typeof r == "boolean" || typeof s == "boolean" ? String(r) === String(s) : typeof r == "object" || typeof s == "object" ? JSON.stringify(r) === JSON.stringify(s) : String(r) === String(s);
20
21
  }
21
- function J(i) {
22
- if (i == null || i === "") return "∅";
23
- const s = typeof i == "object" ? JSON.stringify(i) : String(i);
22
+ function R(r) {
23
+ if (r == null || r === "") return "∅";
24
+ const s = typeof r == "object" ? JSON.stringify(r) : String(r);
24
25
  return s.length > 60 ? `${s.slice(0, 57)}…` : s;
25
26
  }
26
- function Oe({
27
- collection: i,
27
+ function Ae({
28
+ collection: r,
28
29
  itemId: s,
29
30
  open: u,
30
31
  onClose: p,
31
32
  onSaved: S
32
33
  }) {
33
- const h = ee(), M = Y(), [m, j] = w({}), [g, v] = w(/* @__PURE__ */ new Map()), [y, _] = w(/* @__PURE__ */ new Map()), [k, L] = w(!1), [B, q] = w(null), { data: c } = U({
34
- queryKey: ["raw-edit-config", i],
34
+ const h = te(), M = Z(), [m, j] = _({}), [g, v] = _(/* @__PURE__ */ new Map()), [y, k] = _(/* @__PURE__ */ new Map()), [N, L] = _(!1), [B, C] = _(null), { data: c } = U({
35
+ queryKey: ["raw-edit-config", r],
35
36
  queryFn: async () => {
36
- const [e, n] = await Promise.all([
37
- h.request($(`/field-config/${i}`)).then((r) => r.data ?? []),
38
- h.request($(`/collections/${i}`)).then((r) => r.data)
37
+ const [e, t] = await Promise.all([
38
+ h.request($(`/field-config/${r}`)).then((n) => n.data ?? []),
39
+ h.request($(`/collections/${r}`)).then((n) => n.data)
39
40
  ]);
40
- return { fields: e, relations: n.relations ?? [] };
41
+ return { fields: e, relations: t.relations ?? [] };
41
42
  },
42
43
  enabled: u,
43
44
  staleTime: 6e4
44
45
  }), { data: o, isLoading: H } = U({
45
- queryKey: ["raw-edit-record", i, s],
46
- queryFn: () => h.request($(`/items/${i}/${s}`)).then((e) => e.data),
46
+ queryKey: ["raw-edit-record", r, s],
47
+ queryFn: () => h.request($(`/items/${r}/${s}`)).then((e) => e.data),
47
48
  enabled: u,
48
49
  staleTime: 0
49
- }), G = P(() => {
50
- const e = (c == null ? void 0 : c.fields) ?? [], n = (c == null ? void 0 : c.relations) ?? [], r = (t) => n.some((a) => a.one_collection === i && a.one_field === t.field);
51
- return e.filter((t) => !t.field.startsWith("__")).map((t) => ({
50
+ }), G = Q(() => {
51
+ const e = (c == null ? void 0 : c.fields) ?? [], t = (c == null ? void 0 : c.relations) ?? [], n = (i) => t.some((a) => a.one_collection === r && a.one_field === i.field);
52
+ return e.filter((i) => !i.field.startsWith("__")).map((i) => ({
52
53
  // Strip every conditional/curation config — raw mode ignores them all
53
54
  field: {
54
- ...t,
55
+ ...i,
55
56
  hidden: !1,
56
57
  readonly: !1,
57
58
  visibility_rules: null,
58
59
  lock_condition: null,
59
60
  dependency_config: null
60
61
  },
61
- alias: r(t),
62
- m2mRel: n.find(
63
- (a) => a.one_collection === i && a.one_field === t.field && a.junction_field != null
62
+ alias: n(i),
63
+ m2mRel: t.find(
64
+ (a) => a.one_collection === r && a.one_field === i.field && a.junction_field != null
64
65
  )
65
- })).sort((t, a) => (t.field.sort ?? 0) - (a.field.sort ?? 0));
66
- }, [c, i]), N = (c == null ? void 0 : c.relations) ?? [], O = (e) => N.find(
67
- (n) => n.one_collection === i && n.one_field === e && n.junction_field != null
68
- ), z = (e) => {
69
- const n = N.find(
70
- (r) => r.many_collection === e.many_collection && r.many_field === e.junction_field && r.id !== e.id
66
+ })).sort((i, a) => (i.field.sort ?? 0) - (a.field.sort ?? 0));
67
+ }, [c, r]), x = (c == null ? void 0 : c.relations) ?? [], O = (e) => x.find(
68
+ (t) => t.one_collection === r && t.one_field === e && t.junction_field != null
69
+ ), F = (e) => {
70
+ const t = x.find(
71
+ (n) => n.many_collection === e.many_collection && n.many_field === e.junction_field && n.id !== e.id
71
72
  );
72
- return !n || n.one_collection || fe(n) < 2 ? null : n.one_collection_field || "collection";
73
- }, A = P(
73
+ return !t || t.one_collection || pe(t) < 2 ? null : t.one_collection_field || "collection";
74
+ }, V = (e) => {
75
+ var t;
76
+ return re(
77
+ (t = x.find(
78
+ (n) => n.many_collection === e.many_collection && n.many_field === e.junction_field && n.id !== e.id
79
+ )) == null ? void 0 : t.one_collection
80
+ );
81
+ }, z = Q(
74
82
  () => ({
75
83
  getStagedLinks: (e) => g.get(e) ?? [],
76
84
  getStagedUnlinks: (e) => y.get(e) ?? /* @__PURE__ */ new Set(),
77
- stageLink: (e, n) => v((r) => {
78
- const t = new Map(r);
79
- return t.set(e, [...t.get(e) ?? [], n]), t;
85
+ stageLink: (e, t) => v((n) => {
86
+ const i = new Map(n);
87
+ return i.set(e, [...i.get(e) ?? [], t]), i;
80
88
  }),
81
- unstageLink: (e, n) => v((r) => {
82
- const t = new Map(r);
83
- return t.set(
89
+ unstageLink: (e, t) => v((n) => {
90
+ const i = new Map(n);
91
+ return i.set(
84
92
  e,
85
- (t.get(e) ?? []).filter((a) => String(a) !== String(n))
86
- ), t;
93
+ (i.get(e) ?? []).filter((a) => String(a) !== String(t))
94
+ ), i;
87
95
  }),
88
- stageUnlink: (e, n) => _((r) => {
89
- const t = new Map(r), a = new Set(t.get(e) ?? []);
90
- return a.add(n), t.set(e, a), t;
96
+ stageUnlink: (e, t) => k((n) => {
97
+ const i = new Map(n), a = new Set(i.get(e) ?? []);
98
+ return a.add(t), i.set(e, a), i;
91
99
  }),
92
- unstageUnlink: (e, n) => _((r) => {
93
- const t = new Map(r), a = new Set(t.get(e) ?? []);
94
- return a.delete(n), t.set(e, a), t;
100
+ unstageUnlink: (e, t) => k((n) => {
101
+ const i = new Map(n), a = new Set(i.get(e) ?? []);
102
+ return a.delete(t), i.set(e, a), i;
95
103
  })
96
104
  }),
97
105
  [g, y]
98
- ), V = [...g.values()].some((e) => e.length > 0) || [...y.values()].some((e) => e.size > 0), K = Object.keys(m).length > 0 || V, R = async (e) => {
99
- var n;
106
+ ), X = [...g.values()].some((e) => e.length > 0) || [...y.values()].some((e) => e.size > 0), A = Object.keys(m).length > 0 || X, K = async (e) => {
107
+ var t;
100
108
  L(!0);
101
109
  try {
102
110
  if (Object.keys(m).length > 0) {
103
- const t = { ...m };
104
- e && (t._change_reason = e), await h.request(te(`/items/${i}/${s}`, t));
111
+ const i = { ...m };
112
+ e && (i._change_reason = e), await h.request(ne(`/items/${r}/${s}`, i));
105
113
  }
106
- const r = [];
107
- for (const [t, a] of y.entries()) {
114
+ const n = [];
115
+ for (const [i, a] of y.entries()) {
108
116
  if (!a.size) continue;
109
- const d = O(t);
117
+ const d = O(i);
110
118
  if (d)
111
- for (const x of a)
112
- r.push(h.request(ne(`/items/${d.many_collection}/${x}`)).catch(() => {
119
+ for (const b of a)
120
+ n.push(h.request(ie(`/items/${d.many_collection}/${b}`)).catch(() => {
113
121
  }));
114
122
  }
115
- for (const [t, a] of g.entries()) {
123
+ for (const [i, a] of g.entries()) {
116
124
  if (!a.length) continue;
117
- const d = O(t);
125
+ const d = O(i);
118
126
  if (!d) continue;
119
- const x = N.find(
120
- (b) => b.many_collection === d.many_collection && b.many_field === d.junction_field && b.id !== d.id
121
- ), C = ue(x), X = C ? { [C.field]: C.value } : {};
122
- for (const b of a)
123
- r.push(
127
+ const b = x.find(
128
+ (w) => w.many_collection === d.many_collection && w.many_field === d.junction_field && w.id !== d.id
129
+ ), q = he(b), Y = q ? { [q.field]: q.value } : {};
130
+ for (const w of a)
131
+ n.push(
124
132
  h.request(
125
133
  ae(`/items/${d.many_collection}`, {
126
134
  [d.many_field ?? ""]: s,
127
- [d.junction_field ?? ""]: b,
128
- ...X
135
+ [d.junction_field ?? ""]: w,
136
+ ...Y
129
137
  })
130
138
  ).catch(() => {
131
139
  })
132
140
  );
133
141
  }
134
- await Promise.all(r), Q.success("Raw changes saved"), j({}), v(/* @__PURE__ */ new Map()), _(/* @__PURE__ */ new Map()), M.invalidateQueries({ queryKey: ["item", i, String(s)] }), M.invalidateQueries({ queryKey: ["raw-edit-record", i, s] }), pe(M, [s]), S == null || S(), p();
135
- } catch (r) {
136
- const t = ce(r);
137
- if (t) {
138
- q(t);
142
+ await Promise.all(n), T.success("Raw changes saved"), j({}), v(/* @__PURE__ */ new Map()), k(/* @__PURE__ */ new Map()), M.invalidateQueries({ queryKey: ["item", r, String(s)] }), M.invalidateQueries({ queryKey: ["raw-edit-record", r, s] }), ge(M, [s]), S == null || S(), p();
143
+ } catch (n) {
144
+ const i = me(n);
145
+ if (i) {
146
+ C(i);
139
147
  return;
140
148
  }
141
- const a = r == null ? void 0 : r.response;
142
- Q.error(((n = a == null ? void 0 : a.data) == null ? void 0 : n.error) ?? (a == null ? void 0 : a.error) ?? "Save failed");
149
+ const a = n == null ? void 0 : n.response;
150
+ T.error(((t = a == null ? void 0 : a.data) == null ? void 0 : t.error) ?? (a == null ? void 0 : a.error) ?? "Save failed");
143
151
  } finally {
144
152
  L(!1);
145
153
  }
146
154
  };
147
155
  return /* @__PURE__ */ l(
148
- re,
156
+ se,
149
157
  {
150
158
  open: u,
151
159
  onOpenChange: (e) => {
152
- e || k || (j({}), v(/* @__PURE__ */ new Map()), _(/* @__PURE__ */ new Map()), p());
160
+ e || N || (j({}), v(/* @__PURE__ */ new Map()), k(/* @__PURE__ */ new Map()), p());
153
161
  },
154
162
  children: /* @__PURE__ */ f(
155
- ie,
163
+ le,
156
164
  {
157
165
  side: "right",
158
166
  className: "flex w-[1040px] max-w-[94vw] flex-col p-0 sm:max-w-[94vw]",
159
167
  children: [
160
- /* @__PURE__ */ l(se, { className: "shrink-0 border-b border-slate-200 px-5 py-3 dark:border-border", children: /* @__PURE__ */ f(le, { className: "flex items-center gap-2 text-[14px]", children: [
161
- /* @__PURE__ */ l(Z, { className: "h-4 w-4 text-nvr-cyan" }),
168
+ /* @__PURE__ */ l(oe, { className: "shrink-0 border-b border-slate-200 px-5 py-3 dark:border-border", children: /* @__PURE__ */ f(ce, { className: "flex items-center gap-2 text-[14px]", children: [
169
+ /* @__PURE__ */ l(I, { className: "h-4 w-4 text-nvr-cyan" }),
162
170
  "Raw edit — ",
163
- T(i),
171
+ W(r),
164
172
  " #",
165
173
  s
166
174
  ] }) }),
167
175
  /* @__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: [
168
- /* @__PURE__ */ l(I, { className: "h-3.5 w-3.5 shrink-0" }),
176
+ /* @__PURE__ */ l(ee, { className: "h-3.5 w-3.5 shrink-0" }),
169
177
  "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."
170
178
  ] }),
171
- /* @__PURE__ */ l("div", { className: "min-h-0 flex-1 overflow-y-auto px-5 py-4", children: H || !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: G.map(({ field: e, alias: n, m2mRel: r }) => {
172
- const t = e.field in m ? m[e.field] : o == null ? void 0 : o[e.field], a = e.field in m && !E(m[e.field], o == null ? void 0 : o[e.field]);
179
+ /* @__PURE__ */ l("div", { className: "min-h-0 flex-1 overflow-y-auto px-5 py-4", children: H || !c ? /* @__PURE__ */ l("div", { className: "flex justify-center py-10", children: /* @__PURE__ */ l(P, { className: "h-5 w-5 animate-spin text-slate-400" }) }) : /* @__PURE__ */ l("div", { className: "space-y-3", children: G.map(({ field: e, alias: t, m2mRel: n }) => {
180
+ const i = e.field in m ? m[e.field] : o == null ? void 0 : o[e.field], a = e.field in m && !J(m[e.field], o == null ? void 0 : o[e.field]);
173
181
  return /* @__PURE__ */ f(
174
182
  "div",
175
183
  {
@@ -179,7 +187,7 @@ function Oe({
179
187
  children: [
180
188
  /* @__PURE__ */ f("div", { className: "pt-1.5", children: [
181
189
  /* @__PURE__ */ f("p", { className: "text-[12px] font-medium text-slate-700 dark:text-slate-200", children: [
182
- e.label || T(e.field),
190
+ e.label || W(e.field),
183
191
  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" })
184
192
  ] }),
185
193
  /* @__PURE__ */ l("p", { className: "font-mono text-[10.5px] text-slate-400", children: e.field }),
@@ -187,35 +195,35 @@ function Oe({
187
195
  "p",
188
196
  {
189
197
  className: "mt-0.5 truncate text-[10.5px] text-slate-400",
190
- "data-tip": `Was: ${J(o == null ? void 0 : o[e.field])}`,
198
+ "data-tip": `Was: ${R(o == null ? void 0 : o[e.field])}`,
191
199
  children: [
192
200
  "was ",
193
- J(o == null ? void 0 : o[e.field])
201
+ R(o == null ? void 0 : o[e.field])
194
202
  ]
195
203
  }
196
204
  )
197
205
  ] }),
198
- e.field === "id" ? /* @__PURE__ */ l("p", { className: "pt-1.5 font-mono text-[12px] text-slate-500", children: String(t ?? "") }) : n && r && z(r) ? (
206
+ e.field === "id" ? /* @__PURE__ */ l("p", { className: "pt-1.5 font-mono text-[12px] text-slate-500", children: String(i ?? "") }) : t && n && F(n) ? (
199
207
  // A ship-to contact is a person OR an external email: the
200
208
  // plain picker read every link as a person, so an external
201
209
  // email showed "Record not found". List each link as it is.
202
- /* @__PURE__ */ l(D.Provider, { value: A, children: /* @__PURE__ */ l(
203
- he,
210
+ /* @__PURE__ */ l(E.Provider, { value: z, children: /* @__PURE__ */ l(
211
+ ye,
204
212
  {
205
- collection: i,
213
+ collection: r,
206
214
  itemId: s,
207
215
  field: e.field,
208
- discriminator: z(r)
216
+ discriminator: F(n)
209
217
  }
210
218
  ) })
211
- ) : n && r ? /* @__PURE__ */ l(D.Provider, { value: A, children: /* @__PURE__ */ l(me, { relation: r, parentId: s, allRelations: N }) }) : 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(
212
- de,
219
+ ) : t && n && V(n) ? /* @__PURE__ */ l("p", { className: "pt-1.5 text-[11.5px] italic text-slate-500 dark:text-slate-400", children: "Files — edit through the normal form" }) : t && n ? /* @__PURE__ */ l(E.Provider, { value: z, children: /* @__PURE__ */ l(ue, { relation: n, parentId: s, allRelations: x }) }) : t ? /* @__PURE__ */ l("p", { className: "pt-1.5 text-[11.5px] italic text-slate-500 dark:text-slate-400", children: "Child rows (one-to-many) — edit through the normal form" }) : /* @__PURE__ */ l(
220
+ fe,
213
221
  {
214
222
  field: e,
215
- value: t,
216
- onChange: (d) => j((x) => ({ ...x, [e.field]: d })),
223
+ value: i,
224
+ onChange: (d) => j((b) => ({ ...b, [e.field]: d })),
217
225
  relations: c.relations,
218
- collection: i,
226
+ collection: r,
219
227
  itemId: s
220
228
  }
221
229
  )
@@ -226,22 +234,22 @@ function Oe({
226
234
  }) }) }),
227
235
  /* @__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: [
228
236
  /* @__PURE__ */ l("span", { className: "text-[11.5px] text-slate-400", children: (() => {
229
- if (!K) return "No changes yet";
230
- const e = Object.keys(m).filter((n) => !E(m[n], o == null ? void 0 : o[n])).length + [...g.values()].filter((n) => n.length > 0).length + [...y.values()].filter((n) => n.size > 0).length;
237
+ if (!A) return "No changes yet";
238
+ const e = Object.keys(m).filter((t) => !J(m[t], o == null ? void 0 : o[t])).length + [...g.values()].filter((t) => t.length > 0).length + [...y.values()].filter((t) => t.size > 0).length;
231
239
  return e === 0 ? "No changes yet" : `${e} field${e !== 1 ? "s" : ""} changed`;
232
240
  })() }),
233
241
  /* @__PURE__ */ f("div", { className: "flex gap-2", children: [
234
- /* @__PURE__ */ l(W, { variant: "outline", size: "sm", onClick: p, disabled: k, children: "Cancel" }),
235
- /* @__PURE__ */ l(W, { size: "sm", onClick: () => void R(), disabled: !K || k, children: k ? /* @__PURE__ */ l(F, { className: "h-3.5 w-3.5 animate-spin" }) : "Save raw changes" })
242
+ /* @__PURE__ */ l(D, { variant: "outline", size: "sm", onClick: p, disabled: N, children: "Cancel" }),
243
+ /* @__PURE__ */ l(D, { size: "sm", onClick: () => void K(), disabled: !A || N, children: N ? /* @__PURE__ */ l(P, { className: "h-3.5 w-3.5 animate-spin" }) : "Save raw changes" })
236
244
  ] })
237
245
  ] }),
238
246
  /* @__PURE__ */ l(
239
- oe,
247
+ de,
240
248
  {
241
249
  challenge: B,
242
- onCancel: () => q(null),
250
+ onCancel: () => C(null),
243
251
  onSubmit: (e) => {
244
- q(null), R(e);
252
+ C(null), K(e);
245
253
  }
246
254
  }
247
255
  )
@@ -252,5 +260,5 @@ function Oe({
252
260
  );
253
261
  }
254
262
  export {
255
- Oe as RawEditSheet
263
+ Ae as RawEditSheet
256
264
  };