@nivaro/react 0.3.57 → 0.3.59

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 (69) hide show
  1. package/dist/components/fields/RelationField.js +110 -80
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useRelationOptions.js +1 -0
  4. package/dist/hooks/useSessionRecorder.js +1 -1
  5. package/dist/index.d.ts +37 -2
  6. package/dist/index.js +523 -520
  7. package/dist/shared/components/CollectionBrowserView.js +2693 -2619
  8. package/dist/shared/components/DataTable.js +538 -495
  9. package/dist/shared/components/ItemEditForm.js +4559 -4386
  10. package/dist/shared/components/PageRenderer.js +537 -508
  11. package/dist/shared/components/ProfileView.js +716 -715
  12. package/dist/shared/components/QueryTable.js +74 -74
  13. package/dist/shared/components/RecordReadView.js +367 -364
  14. package/dist/shared/components/ReportView.js +64 -39
  15. package/dist/shared/components/WidgetSlot.js +543 -520
  16. package/dist/shared/components/alerts/AlertManagerView.js +324 -317
  17. package/dist/shared/components/alerts/types.js +37 -14
  18. package/dist/shared/components/cbv/row-focus.js +19 -0
  19. package/dist/shared/components/help-videos/HelpVideoPlayer.js +152 -147
  20. package/dist/shared/components/integrations/console/SignalCard.js +59 -59
  21. package/dist/shared/components/integrations/console/tone.js +52 -30
  22. package/dist/shared/components/item-edit/CatalogPickerField.js +525 -505
  23. package/dist/shared/components/item-edit/FieldRenderer.js +22 -20
  24. package/dist/shared/components/item-edit/FieldRow.js +175 -173
  25. package/dist/shared/components/item-edit/GridBulkEditDialog.js +55 -54
  26. package/dist/shared/components/item-edit/InlineTableField.js +2487 -2442
  27. package/dist/shared/components/item-edit/M2MCombobox.js +321 -295
  28. package/dist/shared/components/item-edit/MidairCollisionDialog.js +1 -1
  29. package/dist/shared/components/item-edit/PlanGrid.js +973 -894
  30. package/dist/shared/components/item-edit/QuickCreateButton.js +335 -106
  31. package/dist/shared/components/item-edit/RecordLiveSync.js +77 -75
  32. package/dist/shared/components/item-edit/RelationCombobox.js +452 -335
  33. package/dist/shared/components/item-edit/RelationGroupedCombobox.js +262 -141
  34. package/dist/shared/components/item-edit/SummaryPanel.js +385 -358
  35. package/dist/shared/components/item-edit/duplicate-rehearsal.js +47 -0
  36. package/dist/shared/components/item-edit/line-midair.js +82 -75
  37. package/dist/shared/components/item-edit/option-disambiguate.js +44 -32
  38. package/dist/shared/components/item-edit/related-missing.js +45 -0
  39. package/dist/shared/components/item-edit/save-outcome.js +9 -7
  40. package/dist/shared/components/notifications/NotificationRulesEditor.js +130 -123
  41. package/dist/shared/components/panels/AccessDeniedPanel.js +52 -48
  42. package/dist/shared/components/panels/ItemLockBanner.js +213 -211
  43. package/dist/shared/components/panels/PipelinePanel.js +1140 -1053
  44. package/dist/shared/components/panels/RecordIntegrityBanner.js +114 -86
  45. package/dist/shared/components/panels/RevisionsPanel.js +316 -299
  46. package/dist/shared/components/panels/TaskPanel.js +265 -249
  47. package/dist/shared/components/panels/landing-state.js +27 -0
  48. package/dist/shared/components/pipeline/PipelineEditorView.js +110 -92
  49. package/dist/shared/components/profile/AiMemoryCard.js +12 -10
  50. package/dist/shared/components/queue/OwnerAvatars.js +80 -41
  51. package/dist/shared/components/queue/QueueQuickFilters.js +52 -52
  52. package/dist/shared/components/queue/QueueWorklist.js +1050 -1026
  53. package/dist/shared/components/queue/group-sums.js +27 -0
  54. package/dist/shared/components/queue/live-state-aspect.js +9 -5
  55. package/dist/shared/components/widgets/ReviewListWidget.js +175 -154
  56. package/dist/shared/lib/back-closes.js +25 -0
  57. package/dist/shared/lib/display-prefs.js +60 -52
  58. package/dist/shared/lib/draft-store.js +71 -48
  59. package/dist/shared/lib/expression.js +53 -53
  60. package/dist/shared/lib/form-usage-beacon.js +7 -7
  61. package/dist/shared/lib/list-page-memory.js +63 -0
  62. package/dist/shared/lib/live.js +44 -44
  63. package/dist/shared/lib/money-input.js +45 -0
  64. package/dist/shared/lib/own-writes.js +76 -28
  65. package/dist/shared/lib/request-gate.js +110 -109
  66. package/dist/shared/lib/sanitize-html.js +10 -6
  67. package/dist/shared/lib/staged-row-labels.js +18 -0
  68. package/dist/shared/lib/validation-rules.js +34 -19
  69. package/package.json +1 -1
@@ -1,321 +1,346 @@
1
- import { jsx as r, jsxs as b } from "react/jsx-runtime";
1
+ import { jsx as r, jsxs as h } from "react/jsx-runtime";
2
2
  import { useQuery as $ } from "@tanstack/react-query";
3
- import { Check as ue, Copy as fe, ChevronRight as ye, Loader2 as pe } from "lucide-react";
4
- import { useState as z, useRef as he, createContext as be, useContext as xe } from "react";
3
+ import { Check as ye, Copy as pe, ChevronRight as he, Loader2 as xe } from "lucide-react";
4
+ import { useState as Z, useRef as be, createContext as ge, useContext as _e } from "react";
5
5
  import { useNivaroClient as U } from "../../context.js";
6
- import { get as O } from "../../lib/commands.js";
7
- import { useRecordReader as ge } from "../../lib/record-loader.js";
8
- import { cn as R, titleCase as Z, toLocalDateString as _e, choiceLabel as ke } from "../../lib/utils.js";
9
- import { useChangePulse as Se } from "./GroupSection.js";
10
- import { SYSTEM_FIELDS as Ne, SENTINEL_FIELDS as we, applyDisplayTemplate as le, parseJson as ae, richTextToPlain as ee } from "./helpers.js";
11
- import { RelatedItemLabel as ie } from "./RelationCombobox.js";
12
- const re = be({});
13
- function qe(e, n) {
6
+ import { get as L } from "../../lib/commands.js";
7
+ import { useRecordReader as ke } from "../../lib/record-loader.js";
8
+ import { cn as E, titleCase as ee, toLocalDateString as Se, choiceLabel as Ne } from "../../lib/utils.js";
9
+ import { useChangePulse as we } from "./GroupSection.js";
10
+ import { SYSTEM_FIELDS as qe, SENTINEL_FIELDS as Te, applyDisplayTemplate as re, parseJson as ie, richTextToPlain as te } from "./helpers.js";
11
+ import { resolveM2MRelatedCollection as $e, m2mIdKey as ne } from "./M2MCombobox.js";
12
+ import { RelatedItemLabel as oe } from "./RelationCombobox.js";
13
+ const se = ge({});
14
+ function Oe(e, n) {
14
15
  return n ? Object.entries(n).every(
15
- ([l, a]) => a !== null && typeof a == "object" || String(e[l] ?? "") === String(a ?? "")
16
+ ([a, l]) => l !== null && typeof l == "object" || String(e[a] ?? "") === String(l ?? "")
16
17
  ) : !0;
17
18
  }
18
- function Te({
19
+ function je({
19
20
  relation: e,
20
21
  parentId: n,
21
- allRelations: l,
22
- staging: a,
23
- maxValues: f
22
+ allRelations: a,
23
+ staging: l,
24
+ maxValues: c
24
25
  }) {
25
- var L, S, M;
26
- const s = U(), m = e.many_field ?? "", y = e.junction_field ?? (() => {
27
- const i = l.find(
28
- (N) => N.many_collection === e.many_collection && N.id !== e.id
26
+ var K, T;
27
+ const i = U(), u = e.many_field ?? "", f = e.junction_field ?? (() => {
28
+ const t = a.find(
29
+ (s) => s.many_collection === e.many_collection && s.id !== e.id
29
30
  );
30
- return (i == null ? void 0 : i.many_field) ?? "";
31
- })(), h = e.one_field ?? `${e.many_collection}.${y}`, k = ((L = l.find(
32
- (i) => i.many_collection === e.many_collection && i.many_field === y && i.id !== e.id
33
- )) == null ? void 0 : L.one_collection) ?? null, { data: g } = $({
31
+ return (t == null ? void 0 : t.many_field) ?? "";
32
+ })(), p = e.one_field ?? `${e.many_collection}.${f}`, g = ((K = a.find(
33
+ (t) => t.many_collection === e.many_collection && t.many_field === f && t.id !== e.id
34
+ )) == null ? void 0 : K.one_collection) ?? null, { data: b } = $({
34
35
  queryKey: ["summary-junction-relations", e.many_collection],
35
- queryFn: () => s.request(
36
- O(`/data-model/relations/for/${e.many_collection}`)
37
- ).then((i) => i.data ?? []).catch(() => []),
38
- enabled: !k && !!e.many_collection && !!y,
36
+ queryFn: () => i.request(
37
+ L(`/data-model/relations/for/${e.many_collection}`)
38
+ ).then((t) => t.data ?? []).catch(() => []),
39
+ enabled: !g && !!e.many_collection && !!f,
39
40
  staleTime: 10 * 6e4
40
- }), o = k ?? ((S = g == null ? void 0 : g.find(
41
- (i) => i.many_collection === e.many_collection && i.many_field === y && !!i.one_collection
42
- )) == null ? void 0 : S.one_collection) ?? null, { data: c = [] } = $({
43
- queryKey: ["m2m-items", e.many_collection, m, n],
44
- queryFn: () => s.request(
45
- O(`/items/${e.many_collection}`, {
46
- filter: JSON.stringify({ [m]: { _eq: n } }),
41
+ }), o = g ?? ((T = b == null ? void 0 : b.find(
42
+ (t) => t.many_collection === e.many_collection && t.many_field === f && !!t.one_collection
43
+ )) == null ? void 0 : T.one_collection) ?? null, { data: d = [] } = $({
44
+ queryKey: ["m2m-items", e.many_collection, u, n],
45
+ queryFn: () => i.request(
46
+ L(`/items/${e.many_collection}`, {
47
+ filter: JSON.stringify({ [u]: { _eq: n } }),
47
48
  limit: 200,
48
- fields: `id,${y}`
49
+ fields: `id,${f}`
49
50
  })
50
- ).then((i) => i.data ?? []),
51
+ ).then((t) => t.data ?? []),
51
52
  staleTime: 3e4,
52
53
  enabled: !!n && n !== "new"
53
- }), d = o ? null : ((M = [...l, ...g ?? []].find(
54
- (i) => i.many_collection === e.many_collection && i.many_field === y && !!i.one_collection_field
55
- )) == null ? void 0 : M.one_collection_field) ?? null, { data: j = [] } = $({
56
- queryKey: ["summary-m2a-items", e.many_collection, m, n, d],
57
- queryFn: () => s.request(
58
- O(`/items/${e.many_collection}`, {
59
- filter: JSON.stringify({ [m]: { _eq: n } }),
54
+ }), m = o ? void 0 : [...a, ...b ?? []].find(
55
+ (t) => t.many_collection === e.many_collection && t.many_field === f && !!t.one_collection_field
56
+ ), k = (m == null ? void 0 : m.one_collection_field) ?? null, R = m ? $e(m) : null, { data: F = [] } = $({
57
+ queryKey: ["summary-m2a-items", e.many_collection, u, n, k],
58
+ queryFn: () => i.request(
59
+ L(`/items/${e.many_collection}`, {
60
+ filter: JSON.stringify({ [u]: { _eq: n } }),
60
61
  limit: 200,
61
- fields: `id,${y},${d}`
62
+ fields: `id,${f},${k}`
62
63
  })
63
- ).then((i) => i.data ?? []),
64
+ ).then((t) => t.data ?? []),
64
65
  staleTime: 3e4,
65
- enabled: !!d && !!n && n !== "new"
66
- }), P = o === "nivaro_files" || o === "directus_files", { data: D } = $({
66
+ enabled: !!k && !!n && n !== "new"
67
+ }), I = o === "nivaro_files" || o === "directus_files", { data: O } = $({
67
68
  queryKey: ["col-meta", o],
68
- queryFn: () => s.request(O(`/collections/${o}`)).then((i) => i.data),
69
- enabled: !!o && !P,
69
+ queryFn: () => i.request(L(`/collections/${o}`)).then((t) => t.data),
70
+ enabled: !!o && !I,
70
71
  staleTime: 3e5
71
- }), K = (a == null ? void 0 : a.getStagedLinks(h)) ?? [], v = (a == null ? void 0 : a.getStagedUnlinks(h)) ?? /* @__PURE__ */ new Set(), C = c.filter((i) => !v.has(i.id)), q = [
72
- ...K,
73
- ...C.map((i) => i[y]).filter((i) => i != null)
74
- ];
75
- if (q.length === 0)
72
+ }), w = (l == null ? void 0 : l.getStagedLinks(p)) ?? [], D = (l == null ? void 0 : l.getStagedUnlinks(p)) ?? /* @__PURE__ */ new Set(), S = d.filter((t) => !D.has(t.id)), j = /* @__PURE__ */ new Set(), _ = [
73
+ ...w,
74
+ ...S.map((t) => t[f]).filter((t) => t != null)
75
+ ].filter((t) => {
76
+ const s = ne(t);
77
+ return j.has(s) ? !1 : (j.add(s), !0);
78
+ });
79
+ if (_.length === 0)
76
80
  return /* @__PURE__ */ r("span", { className: "text-slate-400 dark:text-slate-500", children: "—" });
77
81
  if (o) {
78
- const N = q.slice(0, 5), w = q.length - 5;
79
- return /* @__PURE__ */ b("span", { className: "text-[12px] text-slate-700 dark:text-slate-200", children: [
80
- N.map((t, u) => /* @__PURE__ */ b("span", { children: [
81
- u > 0 && ", ",
82
+ const s = _.slice(0, 5), x = _.length - 5;
83
+ return /* @__PURE__ */ h("span", { className: "text-[12px] text-slate-700 dark:text-slate-200", children: [
84
+ s.map((y, P) => /* @__PURE__ */ h("span", { children: [
85
+ P > 0 && ", ",
82
86
  /* @__PURE__ */ r(
83
- ie,
87
+ oe,
84
88
  {
85
89
  collection: o,
86
- id: t,
87
- displayTemplate: D == null ? void 0 : D.display_template
90
+ id: y,
91
+ displayTemplate: O == null ? void 0 : O.display_template
88
92
  }
89
93
  )
90
- ] }, String(t))),
91
- w > 0 && /* @__PURE__ */ b("span", { className: "text-slate-400 dark:text-slate-500", children: [
94
+ ] }, String(y))),
95
+ x > 0 && /* @__PURE__ */ h("span", { className: "text-slate-400 dark:text-slate-500", children: [
92
96
  " +",
93
- w,
97
+ x,
94
98
  " more"
95
99
  ] })
96
100
  ] });
97
101
  }
98
- const _ = d ? j.filter((i) => !v.has(i.id) && i[y] != null && i[d]).slice(0, 5) : [];
99
- if (_.length > 0 && K.length === 0) {
100
- const i = q.length - _.length;
101
- return /* @__PURE__ */ b("span", { className: "text-[12px] text-slate-700 dark:text-slate-200", children: [
102
- _.map((N, w) => /* @__PURE__ */ b("span", { children: [
103
- w > 0 && ", ",
104
- /* @__PURE__ */ r(
105
- X,
106
- {
107
- collection: $e(String(N[d])),
108
- id: N[y]
109
- }
110
- )
111
- ] }, String(N.id))),
112
- i > 0 && /* @__PURE__ */ b("span", { className: "text-slate-400 dark:text-slate-500", children: [
102
+ const M = /* @__PURE__ */ new Set(), q = (k ? [
103
+ ...F.filter((t) => !D.has(t.id) && t[f] != null && t[k]).map((t) => ({
104
+ key: String(t.id),
105
+ collection: Le(String(t[k])),
106
+ id: t[f]
107
+ })),
108
+ ...R ? w.map((t) => ({
109
+ key: `staged-${String(t)}`,
110
+ collection: R,
111
+ id: t
112
+ })) : []
113
+ ] : []).filter((t) => {
114
+ const s = `${t.collection}|${ne(t.id)}`;
115
+ return M.has(s) ? !1 : (M.add(s), !0);
116
+ });
117
+ if (q.length > 0 && (w.length === 0 || R)) {
118
+ const t = q.length - 5;
119
+ return /* @__PURE__ */ h("span", { className: "text-[12px] text-slate-700 dark:text-slate-200", children: [
120
+ q.slice(0, 5).map((s, x) => /* @__PURE__ */ h("span", { children: [
121
+ x > 0 && ", ",
122
+ /* @__PURE__ */ r(X, { collection: s.collection, id: s.id })
123
+ ] }, s.key)),
124
+ t > 0 && /* @__PURE__ */ h("span", { className: "text-slate-400 dark:text-slate-500", children: [
113
125
  " +",
114
- i,
126
+ t,
115
127
  " more"
116
128
  ] })
117
129
  ] });
118
130
  }
119
- return /* @__PURE__ */ b("span", { className: "text-slate-700 dark:text-slate-200", children: [
120
- q.length,
131
+ return /* @__PURE__ */ h("span", { className: "text-slate-700 dark:text-slate-200", children: [
132
+ _.length,
121
133
  " item",
122
- q.length !== 1 ? "s" : ""
134
+ _.length !== 1 ? "s" : ""
123
135
  ] });
124
136
  }
125
- function $e(e) {
137
+ function Le(e) {
126
138
  return e === "directus_users" ? "nivaro_users" : e;
127
139
  }
128
- function se(e) {
140
+ function ce(e) {
129
141
  const n = U();
130
142
  return $({
131
143
  queryKey: ["summary-display-template", e],
132
- queryFn: () => n.request(O(`/collections/${e}`)).then((l) => {
133
- var a;
134
- return ((a = l.data) == null ? void 0 : a.display_template) ?? null;
144
+ queryFn: () => n.request(L(`/collections/${e}`)).then((a) => {
145
+ var l;
146
+ return ((l = a.data) == null ? void 0 : l.display_template) ?? null;
135
147
  }).catch(() => null),
136
148
  enabled: !!e,
137
149
  staleTime: 10 * 6e4
138
150
  }).data;
139
151
  }
140
152
  function X({ collection: e, id: n }) {
141
- const l = se(e);
142
- return /* @__PURE__ */ r(ie, { collection: e, id: n, displayTemplate: l ?? void 0 });
153
+ const a = ce(e);
154
+ return /* @__PURE__ */ r(oe, { collection: e, id: n, displayTemplate: a ?? void 0 });
143
155
  }
144
- const je = ["name", "title", "label", "subject", "description", "line_number"], Le = ["amount", "total", "cost", "price", "quantity"], V = 4, I = 200;
145
- function Oe(e, n) {
156
+ const Me = ["name", "title", "label", "subject", "description", "line_number"], Ce = ["amount", "total", "cost"], v = (e) => {
157
+ if (typeof e == "number") return Number.isFinite(e) ? e : null;
158
+ if (typeof e == "string" && e.trim() !== "") {
159
+ const n = Number(e);
160
+ return Number.isFinite(n) ? n : null;
161
+ }
162
+ return null;
163
+ };
164
+ function ve(e) {
165
+ const n = Ce.find((l) => e.some((c) => v(c[l]) !== null)), a = e.some((l) => v(l.price) !== null && v(l.quantity) !== null);
166
+ return n || a ? {
167
+ currency: !0,
168
+ of: (l) => {
169
+ const c = n ? v(l[n]) : null;
170
+ if (c !== null) return c;
171
+ const i = v(l.price), u = v(l.quantity);
172
+ return i !== null && u !== null ? Math.round(i * u * 100) / 100 : null;
173
+ }
174
+ } : e.some((l) => v(l.quantity) !== null) ? { currency: !1, of: (l) => v(l.quantity) } : null;
175
+ }
176
+ const V = 4, H = 200;
177
+ function Ee(e, n) {
146
178
  if (n) {
147
- const l = le(n, e).replace(/\s*[·|\-–—/]\s*(?=[·|\-–—/]|$)/g, "").replace(/^\s*[·|\-–—/]\s*/, "").trim();
148
- if (l !== "") return l;
179
+ const a = re(n, e).replace(/\s*[·|\-–—/]\s*(?=[·|\-–—/]|$)/g, "").replace(/^\s*[·|\-–—/]\s*/, "").trim();
180
+ if (a !== "") return a;
149
181
  }
150
- for (const l of je) {
151
- const a = e[l];
152
- if (a != null && String(a).trim() !== "") return String(a).trim();
182
+ for (const a of Me) {
183
+ const l = e[a];
184
+ if (l != null && String(l).trim() !== "") return String(l).trim();
153
185
  }
154
186
  return null;
155
187
  }
156
- function ve(e) {
188
+ function Re(e) {
157
189
  if (!e) return [];
158
190
  const n = /* @__PURE__ */ new Set();
159
- for (const l of e.matchAll(/\{\{\s*([\w.]+)\s*\}\}/g))
160
- l[1].includes(".") && !l[1].startsWith(".") && n.add(l[1]);
191
+ for (const a of e.matchAll(/\{\{\s*([\w.]+)\s*\}\}/g))
192
+ a[1].includes(".") && !a[1].startsWith(".") && n.add(a[1]);
161
193
  return [...n];
162
194
  }
163
- function Ce(e, n, l) {
164
- if (!n || l.length === 0) return e;
165
- const a = { ...e };
166
- for (const f of new Set(l.map((s) => s.split(".")[0]))) {
167
- const s = n[f];
168
- s !== null && typeof s == "object" && (a[f] = s);
195
+ function De(e, n, a) {
196
+ if (!n || a.length === 0) return e;
197
+ const l = { ...e };
198
+ for (const c of new Set(a.map((i) => i.split(".")[0]))) {
199
+ const i = n[c];
200
+ i !== null && typeof i == "object" && (l[c] = i);
169
201
  }
170
- return a;
202
+ return l;
171
203
  }
172
- const Me = ["cifa", "item", "catalog_item", "product", "part", "material"], Ee = /* @__PURE__ */ new Set(["nivaro_users", "directus_users"]);
173
- function Re(e, n, l) {
174
- const a = e.filter(
175
- (s) => s.many_collection === n && !!s.many_field && s.many_field !== l && !s.junction_field && !!s.one_collection && !Ee.has(s.one_collection)
176
- ), f = Me.map((s) => a.find((m) => m.many_field === s)).find(Boolean) ?? a[0];
177
- return f != null && f.many_field && f.one_collection ? { field: f.many_field, collection: f.one_collection } : null;
204
+ const Ke = ["cifa", "item", "catalog_item", "product", "part", "material"], Ae = /* @__PURE__ */ new Set(["nivaro_users", "directus_users"]);
205
+ function Pe(e, n, a) {
206
+ const l = e.filter(
207
+ (i) => i.many_collection === n && !!i.many_field && i.many_field !== a && !i.junction_field && !!i.one_collection && !Ae.has(i.one_collection)
208
+ ), c = Ke.map((i) => l.find((u) => u.many_field === i)).find(Boolean) ?? l[0];
209
+ return c != null && c.many_field && c.one_collection ? { field: c.many_field, collection: c.one_collection } : null;
178
210
  }
179
- function oe({
211
+ function de({
180
212
  relatedCollection: e,
181
213
  manyField: n,
182
- parentId: l,
183
- rowFilter: a,
184
- expanded: f
214
+ parentId: a,
215
+ rowFilter: l,
216
+ expanded: c
185
217
  }) {
186
- var N, w;
187
- const s = U(), m = xe(re), y = a && Object.keys(a).length > 0 ? {
218
+ var K, T;
219
+ const i = U(), u = _e(se), f = l && Object.keys(l).length > 0 ? {
188
220
  _and: [
189
- { [n]: { _eq: l } },
221
+ { [n]: { _eq: a } },
190
222
  Object.fromEntries(
191
- Object.entries(a).map(([t, u]) => [
223
+ Object.entries(l).map(([t, s]) => [
192
224
  t,
193
- u !== null && typeof u == "object" ? u : { _eq: u }
225
+ s !== null && typeof s == "object" ? s : { _eq: s }
194
226
  ])
195
227
  )
196
228
  ]
197
- } : { [n]: { _eq: l } }, { data: h, isLoading: k } = $({
229
+ } : { [n]: { _eq: a } }, { data: p, isLoading: g } = $({
198
230
  queryKey: [
199
231
  "o2m-rows",
200
232
  e,
201
233
  n,
202
- l,
203
- a ? JSON.stringify(a) : ""
234
+ a,
235
+ l ? JSON.stringify(l) : ""
204
236
  ],
205
- queryFn: () => s.request(
206
- O(`/items/${e}`, {
207
- filter: JSON.stringify(y),
208
- limit: I
237
+ queryFn: () => i.request(
238
+ L(`/items/${e}`, {
239
+ filter: JSON.stringify(f),
240
+ limit: H
209
241
  })
210
242
  ).then((t) => t.data ?? []),
211
- enabled: !!l && l !== "new",
243
+ enabled: !!a && a !== "new",
212
244
  staleTime: 3e4
213
- }), g = se(e), { data: o = [] } = $({
245
+ }), b = ce(e), { data: o = [] } = $({
214
246
  queryKey: ["collection-relations", e],
215
- queryFn: () => s.request(O(`/collections/${e}`)).then((t) => {
216
- var u;
217
- return ((u = t.data) == null ? void 0 : u.relations) ?? [];
247
+ queryFn: () => i.request(L(`/collections/${e}`)).then((t) => {
248
+ var s;
249
+ return ((s = t.data) == null ? void 0 : s.relations) ?? [];
218
250
  }),
219
251
  staleTime: 10 * 6e4
220
- }), c = Re(o, e, n), d = ve(g), j = [...new Set(d.map((t) => t.split(".")[0]))], P = d.length ? JSON.stringify((h ?? []).map((t) => [t.id, ...j.map((u) => t[u] ?? null)])) : "", { data: D } = $({
252
+ }), d = Pe(o, e, n), m = Re(b), k = [...new Set(m.map((t) => t.split(".")[0]))], R = m.length ? JSON.stringify((p ?? []).map((t) => [t.id, ...k.map((s) => t[s] ?? null)])) : "", { data: F } = $({
221
253
  queryKey: [
222
254
  "o2m-summary-labels",
223
255
  e,
224
256
  n,
225
- l,
226
- a ? JSON.stringify(a) : "",
227
- d.join(","),
228
- P
257
+ a,
258
+ l ? JSON.stringify(l) : "",
259
+ m.join(","),
260
+ R
229
261
  ],
230
- queryFn: () => s.request(
231
- O(`/items/${e}`, {
232
- filter: JSON.stringify(y),
233
- fields: ["id", ...d].join(","),
234
- limit: I
262
+ queryFn: () => i.request(
263
+ L(`/items/${e}`, {
264
+ filter: JSON.stringify(f),
265
+ fields: ["id", ...m].join(","),
266
+ limit: H
235
267
  })
236
268
  ).then((t) => t.data ?? []).catch(() => []),
237
- enabled: d.length > 0 && !!l && l !== "new" && ((h == null ? void 0 : h.length) ?? 0) > 0,
269
+ enabled: m.length > 0 && !!a && a !== "new" && ((p == null ? void 0 : p.length) ?? 0) > 0,
238
270
  staleTime: 6e4
239
- }), K = new Map((D ?? []).map((t) => [String(t.id), t])), v = `${e}.${n}`, C = (N = m.deletes) == null ? void 0 : N.get(v), q = (((w = m.rows) == null ? void 0 : w.get(v)) ?? []).filter(
240
- (t) => qe(t, a)
241
- ), _ = [
242
- ...(h ?? []).filter((t) => !(C != null && C.has(String(t.id)))),
243
- ...q
271
+ }), I = new Map((F ?? []).map((t) => [String(t.id), t])), O = `${e}.${n}`, w = (K = u.deletes) == null ? void 0 : K.get(O), D = (((T = u.rows) == null ? void 0 : T.get(O)) ?? []).filter(
272
+ (t) => Oe(t, l)
273
+ ), S = [
274
+ ...(p ?? []).filter((t) => !(w != null && w.has(String(t.id)))),
275
+ ...D
244
276
  ];
245
- if (k && q.length === 0)
246
- return /* @__PURE__ */ r(pe, { className: "h-3 w-3 animate-spin text-slate-400 dark:text-slate-500" });
247
- if (_.length === 0)
277
+ if (g && D.length === 0)
278
+ return /* @__PURE__ */ r(xe, { className: "h-3 w-3 animate-spin text-slate-400 dark:text-slate-500" });
279
+ if (S.length === 0)
248
280
  return /* @__PURE__ */ r("span", { className: "italic text-[11px] text-slate-400 dark:text-slate-500", children: "None yet" });
249
- const L = ((h == null ? void 0 : h.length) ?? 0) >= I, S = Le.find(
250
- (t) => _.some(
251
- (u) => typeof u[t] == "number" || typeof u[t] == "string" && u[t] !== "" && !Number.isNaN(Number(u[t]))
252
- )
253
- ), M = S && !L ? _.reduce((t, u) => {
254
- const x = Number(u[S]);
255
- return t + (Number.isFinite(x) ? x : 0);
256
- }, 0) : null, i = S ? S !== "quantity" : !1;
257
- return /* @__PURE__ */ b("span", { className: "block", children: [
258
- /* @__PURE__ */ b("span", { className: "flex items-baseline gap-2", children: [
259
- /* @__PURE__ */ b("span", { className: "text-slate-700 dark:text-slate-200", children: [
260
- L ? `${I}+` : _.length,
281
+ const j = ((p == null ? void 0 : p.length) ?? 0) >= H, _ = ve(S), M = _ && !j ? Math.round(S.reduce((t, s) => t + (_.of(s) ?? 0), 0) * 100) / 100 : null, q = (_ == null ? void 0 : _.currency) ?? !1;
282
+ return /* @__PURE__ */ h("span", { className: "block", children: [
283
+ /* @__PURE__ */ h("span", { className: "flex items-baseline gap-2", children: [
284
+ /* @__PURE__ */ h("span", { className: "text-slate-700 dark:text-slate-200", children: [
285
+ j ? `${H}+` : S.length,
261
286
  " row",
262
- _.length !== 1 ? "s" : ""
287
+ S.length !== 1 ? "s" : ""
263
288
  ] }),
264
- M !== null && /* @__PURE__ */ r("span", { className: "tabular-nums text-[11px] text-slate-500 dark:text-slate-400", children: i ? M.toLocaleString(void 0, {
289
+ M !== null && /* @__PURE__ */ r("span", { className: "tabular-nums text-[11px] text-slate-500 dark:text-slate-400", children: q ? M.toLocaleString(void 0, {
265
290
  style: "currency",
266
291
  currency: "USD",
267
292
  maximumFractionDigits: M % 1 === 0 ? 0 : 2
268
293
  }) : M.toLocaleString() })
269
294
  ] }),
270
- /* @__PURE__ */ b("span", { className: "mt-1 block space-y-0.5", children: [
271
- (f ? _ : _.slice(0, V)).map((t, u) => /* @__PURE__ */ b(
295
+ /* @__PURE__ */ h("span", { className: "mt-1 block space-y-0.5", children: [
296
+ (c ? S : S.slice(0, V)).map((t, s) => /* @__PURE__ */ h(
272
297
  "span",
273
298
  {
274
299
  className: "flex items-baseline justify-between gap-2 text-[11px] text-slate-500 dark:text-slate-400",
275
300
  children: [
276
- /* @__PURE__ */ r("span", { className: "truncate", children: Oe(
277
- Ce(t, K.get(String(t.id)), d),
278
- g ?? null
279
- ) ?? (c && t[c.field] != null && t[c.field] !== "" ? /* @__PURE__ */ r(X, { collection: c.collection, id: t[c.field] }) : `Row ${u + 1}`) }),
280
- S && t[S] !== null && t[S] !== void 0 && /* @__PURE__ */ r("span", { className: "shrink-0 tabular-nums", children: (() => {
281
- const x = Number(t[S]);
282
- return Number.isFinite(x) ? i ? x.toLocaleString(void 0, {
301
+ /* @__PURE__ */ r("span", { className: "truncate", children: Ee(
302
+ De(t, I.get(String(t.id)), m),
303
+ b ?? null
304
+ ) ?? (d && t[d.field] != null && t[d.field] !== "" ? /* @__PURE__ */ r(X, { collection: d.collection, id: t[d.field] }) : `Row ${s + 1}`) }),
305
+ _ && _.of(t) !== null && /* @__PURE__ */ r("span", { className: "shrink-0 tabular-nums", children: (() => {
306
+ const x = _.of(t);
307
+ return q ? x.toLocaleString(void 0, {
283
308
  style: "currency",
284
309
  currency: "USD",
285
310
  maximumFractionDigits: x % 1 === 0 ? 0 : 2
286
- }) : x.toLocaleString() : String(t[S]);
311
+ }) : x.toLocaleString();
287
312
  })() })
288
313
  ]
289
314
  },
290
- String(t.id ?? u)
315
+ String(t.id ?? s)
291
316
  )),
292
- !f && _.length > V && /* @__PURE__ */ b("span", { className: "block text-[11px] italic text-slate-400 dark:text-slate-500", children: [
317
+ !c && S.length > V && /* @__PURE__ */ h("span", { className: "block text-[11px] italic text-slate-400 dark:text-slate-500", children: [
293
318
  "+",
294
- L ? `${_.length - V}+` : _.length - V,
319
+ j ? `${S.length - V}+` : S.length - V,
295
320
  " more"
296
321
  ] })
297
322
  ] })
298
323
  ] });
299
324
  }
300
- function De(e) {
301
- const n = Se(e.val);
302
- return /* @__PURE__ */ r("span", { className: R("inline-block max-w-full rounded-sm", n && "nvr-value-pulse-bg"), children: /* @__PURE__ */ r(Ae, { ...e }) });
325
+ function Fe(e) {
326
+ const n = we(e.val);
327
+ return /* @__PURE__ */ r("span", { className: E("inline-block max-w-full rounded-sm", n && "nvr-value-pulse-bg"), children: /* @__PURE__ */ r(Ie, { ...e }) });
303
328
  }
304
- function Ae({
329
+ function Ie({
305
330
  field: e,
306
331
  val: n,
307
- relations: l,
308
- collection: a,
309
- itemId: f,
310
- staging: s
332
+ relations: a,
333
+ collection: l,
334
+ itemId: c,
335
+ staging: i
311
336
  }) {
312
- const m = e.interface ?? "", y = /* @__PURE__ */ new Set(["select-multiple-m2m", "files-m2m", "files", "relation-grouped"]);
313
- if (!y.has(m) && f) {
314
- const o = l.find(
315
- (c) => !c.junction_field && (c.one_field === e.field || c.many_collection === e.field) && (c.one_collection === a || c.one_collection == null)
337
+ const u = e.interface ?? "", f = /* @__PURE__ */ new Set(["select-multiple-m2m", "files-m2m", "files", "relation-grouped"]);
338
+ if (!f.has(u) && c) {
339
+ const o = a.find(
340
+ (d) => !d.junction_field && (d.one_field === e.field || d.many_collection === e.field) && (d.one_collection === l || d.one_collection == null)
316
341
  );
317
342
  if (o != null && o.many_collection && o.many_field) {
318
- const c = (() => {
343
+ const d = (() => {
319
344
  try {
320
345
  return typeof e.options == "string" ? JSON.parse(e.options) : e.options ?? {};
321
346
  } catch {
@@ -323,84 +348,84 @@ function Ae({
323
348
  }
324
349
  })();
325
350
  return /* @__PURE__ */ r(
326
- oe,
351
+ de,
327
352
  {
328
353
  relatedCollection: o.many_collection,
329
354
  manyField: o.many_field,
330
- parentId: f,
331
- rowFilter: c.row_filter && typeof c.row_filter == "object" ? c.row_filter : void 0
355
+ parentId: c,
356
+ rowFilter: d.row_filter && typeof d.row_filter == "object" ? d.row_filter : void 0
332
357
  }
333
358
  );
334
359
  }
335
360
  }
336
- if (y.has(m) && f) {
337
- const o = l.find(
338
- (d) => d.one_collection === a && (d.one_field === e.field || d.junction_field != null && d.many_collection === e.field)
339
- ), c = o ? o.junction_field ? o : (() => {
340
- const d = l.find(
341
- (j) => j.many_collection === o.many_collection && j.id !== o.id
361
+ if (f.has(u) && c) {
362
+ const o = a.find(
363
+ (m) => m.one_collection === l && (m.one_field === e.field || m.junction_field != null && m.many_collection === e.field)
364
+ ), d = o ? o.junction_field ? o : (() => {
365
+ const m = a.find(
366
+ (k) => k.many_collection === o.many_collection && k.id !== o.id
342
367
  );
343
- return d ? { ...o, junction_field: d.many_field } : null;
368
+ return m ? { ...o, junction_field: m.many_field } : null;
344
369
  })() : null;
345
- if (c) {
346
- const d = ae(e.options);
370
+ if (d) {
371
+ const m = ie(e.options);
347
372
  return /* @__PURE__ */ r(
348
- Te,
373
+ je,
349
374
  {
350
- relation: c,
351
- parentId: f,
352
- allRelations: l,
353
- staging: s,
354
- maxValues: d == null ? void 0 : d.max_values
375
+ relation: d,
376
+ parentId: c,
377
+ allRelations: a,
378
+ staging: i,
379
+ maxValues: m == null ? void 0 : m.max_values
355
380
  }
356
381
  );
357
382
  }
358
383
  }
359
- const h = n == null || n === "";
360
- if (h && e.type === "boolean")
384
+ const p = n == null || n === "";
385
+ if (p && e.type === "boolean")
361
386
  return /* @__PURE__ */ r("span", { className: "text-slate-700 dark:text-slate-200", children: "No" });
362
- if (h) return /* @__PURE__ */ r("span", { className: "text-slate-400 dark:text-slate-500", children: "—" });
363
- if (m === "extension-editorjs" || m === "input-rich-text-html" || m === "rich_text" || m === "wysiwyg" || typeof n == "string") {
364
- const o = Fe(n, m);
387
+ if (p) return /* @__PURE__ */ r("span", { className: "text-slate-400 dark:text-slate-500", children: "—" });
388
+ if (u === "extension-editorjs" || u === "input-rich-text-html" || u === "rich_text" || u === "wysiwyg" || typeof n == "string") {
389
+ const o = He(n, u);
365
390
  if (o !== null)
366
391
  return /* @__PURE__ */ r("span", { className: "truncate text-slate-700 dark:text-slate-200", title: o, children: o || "—" });
367
392
  }
368
393
  if (typeof n == "boolean")
369
394
  return /* @__PURE__ */ r("span", { className: "text-slate-700 dark:text-slate-200", children: n ? "Yes" : "No" });
370
- const k = l.find(
371
- (o) => o.many_collection === a && o.many_field === e.field && !o.junction_field
395
+ const g = a.find(
396
+ (o) => o.many_collection === l && o.many_field === e.field && !o.junction_field
372
397
  );
373
- if (k != null && k.one_collection)
374
- return /* @__PURE__ */ r(X, { collection: k.one_collection, id: n });
398
+ if (g != null && g.one_collection)
399
+ return /* @__PURE__ */ r(X, { collection: g.one_collection, id: n });
375
400
  if (e.type === "datetime" || e.type === "date")
376
401
  try {
377
- return /* @__PURE__ */ r("span", { className: "text-slate-700 dark:text-slate-200", children: _e(n) });
402
+ return /* @__PURE__ */ r("span", { className: "text-slate-700 dark:text-slate-200", children: Se(n) });
378
403
  } catch {
379
404
  }
380
- const g = Ke(e.options, n);
381
- return /* @__PURE__ */ r("span", { className: "truncate text-slate-700 dark:text-slate-200", children: g ?? String(n) });
405
+ const b = Je(e.options, n);
406
+ return /* @__PURE__ */ r("span", { className: "truncate text-slate-700 dark:text-slate-200", children: b ?? String(n) });
382
407
  }
383
- function Ke(e, n) {
384
- var f;
408
+ function Je(e, n) {
409
+ var c;
385
410
  if (n == null || typeof n == "object") return null;
386
- const l = ae(
411
+ const a = ie(
387
412
  e
388
- ), a = (f = l == null ? void 0 : l.choices) == null ? void 0 : f.find((s) => s && String(s.value) === String(n));
389
- return (a == null ? void 0 : a.text) != null ? ke(a.text) : null;
413
+ ), l = (c = a == null ? void 0 : a.choices) == null ? void 0 : c.find((i) => i && String(i.value) === String(n));
414
+ return (l == null ? void 0 : l.text) != null ? Ne(l.text) : null;
390
415
  }
391
- const Pe = /* @__PURE__ */ new Set([
416
+ const Ve = /* @__PURE__ */ new Set([
392
417
  "extension-editorjs",
393
418
  "input-rich-text-html",
394
419
  "rich_text",
395
420
  "wysiwyg"
396
421
  ]);
397
- function Fe(e, n) {
422
+ function He(e, n) {
398
423
  if (typeof e != "string") return null;
399
- if (Pe.has(n)) return ee(e);
400
- const l = e.trim();
401
- return l.startsWith("{") && /"blocks"\s*:/.test(l) ? ee(e) : null;
424
+ if (Ve.has(n)) return te(e);
425
+ const a = e.trim();
426
+ return a.startsWith("{") && /"blocks"\s*:/.test(a) ? te(e) : null;
402
427
  }
403
- function Je(e) {
428
+ function Ue(e) {
404
429
  if (e == null || e === "") return "—";
405
430
  if (typeof e == "boolean") return e ? "Yes" : "No";
406
431
  const n = String(e);
@@ -411,7 +436,7 @@ function Je(e) {
411
436
  }
412
437
  return n;
413
438
  }
414
- const te = (e) => {
439
+ const le = (e) => {
415
440
  if (e == null || e === "") return "empty";
416
441
  if (typeof e == "boolean") return e ? "Yes" : "No";
417
442
  if (typeof e == "object")
@@ -419,41 +444,41 @@ const te = (e) => {
419
444
  const n = String(e).replace(/<[^>]+>/g, "").trim();
420
445
  return n.length > 48 ? `${n.slice(0, 48)}…` : n;
421
446
  };
422
- function ne(e, n) {
423
- const l = U(), a = ge(), f = !!e && n != null && n !== "", { data: s } = $({
447
+ function ae(e, n) {
448
+ const a = U(), l = ke(), c = !!e && n != null && n !== "", { data: i } = $({
424
449
  queryKey: ["cbv-collection-meta", e],
425
- queryFn: () => l.request(O(`/collections/${e}`)).then((h) => h.data),
426
- enabled: f,
450
+ queryFn: () => a.request(L(`/collections/${e}`)).then((p) => p.data),
451
+ enabled: c,
427
452
  staleTime: 10 * 6e4,
428
453
  retry: !1
429
- }), { data: m } = $({
454
+ }), { data: u } = $({
430
455
  queryKey: ["rrv-related", e, String(n)],
431
- queryFn: () => a(e, n).catch(() => null),
432
- enabled: f && !!s,
456
+ queryFn: () => l(e, n).catch(() => null),
457
+ enabled: c && !!i,
433
458
  staleTime: 6e4,
434
459
  retry: !1
435
460
  });
436
- if (!f) return null;
437
- if (!m) return "a linked record";
438
- const y = le(s == null ? void 0 : s.display_template, m).trim();
439
- if (y) return y;
440
- for (const h of ["name", "title", "label", "number", "email"]) if (m[h]) return String(m[h]);
461
+ if (!c) return null;
462
+ if (!u) return "a linked record";
463
+ const f = re(i == null ? void 0 : i.display_template, u).trim();
464
+ if (f) return f;
465
+ for (const p of ["name", "title", "label", "number", "email"]) if (u[p]) return String(u[p]);
441
466
  return "a linked record";
442
467
  }
443
- function Ve({
468
+ function We({
444
469
  field: e,
445
470
  from: n,
446
- to: l,
447
- detail: a,
448
- relations: f,
449
- collection: s,
450
- onRevert: m
471
+ to: a,
472
+ detail: l,
473
+ relations: c,
474
+ collection: i,
475
+ onRevert: u
451
476
  }) {
452
477
  var o;
453
- const y = ((o = f.find(
454
- (c) => c.many_collection === s && c.many_field === e.field && !!c.one_collection
455
- )) == null ? void 0 : o.one_collection) ?? null, h = ne(y, n), k = ne(y, l), g = a ? `Unsaved — ${a}` : `Unsaved — was ${h ?? te(n)} → now ${k ?? te(l)}`;
456
- return m ? (
478
+ const f = ((o = c.find(
479
+ (d) => d.many_collection === i && d.many_field === e.field && !!d.one_collection
480
+ )) == null ? void 0 : o.one_collection) ?? null, p = ae(f, n), g = ae(f, a), b = l ? `Unsaved — ${l}` : `Unsaved — was ${p ?? le(n)} → now ${g ?? le(a)}`;
481
+ return u ? (
457
482
  // biome-ignore lint/a11y/useSemanticElements: nested inside the row's <button> — a real <button> is invalid there
458
483
  /* @__PURE__ */ r(
459
484
  "span",
@@ -461,13 +486,13 @@ function Ve({
461
486
  role: "button",
462
487
  tabIndex: 0,
463
488
  "data-summary-changed": !0,
464
- "data-tip": `${g} · click to revert`,
489
+ "data-tip": `${b} · click to revert`,
465
490
  "aria-label": "Revert this change",
466
- onClick: (c) => {
467
- c.stopPropagation(), m();
491
+ onClick: (d) => {
492
+ d.stopPropagation(), u();
468
493
  },
469
- onKeyDown: (c) => {
470
- (c.key === "Enter" || c.key === " ") && (c.preventDefault(), c.stopPropagation(), m());
494
+ onKeyDown: (d) => {
495
+ (d.key === "Enter" || d.key === " ") && (d.preventDefault(), d.stopPropagation(), u());
471
496
  },
472
497
  className: "group/dot inline-flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center rounded-full hover:bg-amber-100 dark:hover:bg-amber-500/20",
473
498
  children: /* @__PURE__ */ r("span", { className: "h-1.5 w-1.5 rounded-full bg-amber-400 ring-2 ring-amber-100 group-hover/dot:ring-amber-200 dark:ring-amber-500/30" })
@@ -477,98 +502,98 @@ function Ve({
477
502
  "span",
478
503
  {
479
504
  "data-summary-changed": !0,
480
- "data-tip": g,
505
+ "data-tip": b,
481
506
  className: "h-1.5 w-1.5 shrink-0 rounded-full bg-amber-400 ring-2 ring-amber-100 dark:ring-amber-500/30"
482
507
  }
483
508
  );
484
509
  }
485
- function et({
510
+ function rt({
486
511
  allSteps: e,
487
512
  groupedMap: n,
488
- ungroupedFields: l,
489
- sectionGroups: a,
490
- draft: f,
491
- relations: s,
492
- collection: m,
493
- itemId: y,
494
- staging: h,
495
- errors: k,
496
- staleFields: g,
513
+ ungroupedFields: a,
514
+ sectionGroups: l,
515
+ draft: c,
516
+ relations: i,
517
+ collection: u,
518
+ itemId: f,
519
+ staging: p,
520
+ errors: g,
521
+ staleFields: b,
497
522
  aliasEmptiness: o,
498
- layoutFields: c,
499
- changedFields: d,
500
- onRevertChange: j,
501
- onFieldClick: P,
502
- stagedO2MRows: D,
503
- stagedO2MDeletes: K
523
+ layoutFields: d,
524
+ changedFields: m,
525
+ onRevertChange: k,
526
+ onFieldClick: R,
527
+ stagedO2MRows: F,
528
+ stagedO2MDeletes: I
504
529
  }) {
505
- const [v, C] = z(null), [q, _] = z(null), L = he(/* @__PURE__ */ new Map()), i = [
506
- ...!e.some((t) => t.key === "__general__") && l.length > 0 ? [{ key: "__general__", label: "General" }] : [],
530
+ const [O, w] = Z(null), [D, S] = Z(null), j = be(/* @__PURE__ */ new Map()), q = [
531
+ ...!e.some((t) => t.key === "__general__") && a.length > 0 ? [{ key: "__general__", label: "General" }] : [],
507
532
  ...e
508
533
  ].map((t) => {
509
- const u = (t.key === "__general__" ? [...l, ...a.flatMap((x) => n[x.key] ?? [])] : n[t.key] ?? []).filter((x) => !x.hidden && !Ne.has(x.field) && !we.has(x.field));
510
- return { step: t, fields: u };
511
- }).filter((t) => t.fields.length > 0), N = new Set(i.flatMap((t) => t.fields.map((u) => u.field))), w = y && y !== "new" ? s.filter(
512
- (t) => !t.junction_field && t.many_field && t.many_collection && (t.one_collection === m || t.one_collection == null) && t.one_field != null && !N.has(t.one_field) && // Off-layout aliases stay out — the sidebar summarizes THIS layout.
513
- (!c || c.has(t.one_field))
534
+ const s = (t.key === "__general__" ? [...a, ...l.flatMap((x) => n[x.key] ?? [])] : n[t.key] ?? []).filter((x) => !x.hidden && !qe.has(x.field) && !Te.has(x.field));
535
+ return { step: t, fields: s };
536
+ }).filter((t) => t.fields.length > 0), K = new Set(q.flatMap((t) => t.fields.map((s) => s.field))), T = f && f !== "new" ? i.filter(
537
+ (t) => !t.junction_field && t.many_field && t.many_collection && (t.one_collection === u || t.one_collection == null) && t.one_field != null && !K.has(t.one_field) && // Off-layout aliases stay out — the sidebar summarizes THIS layout.
538
+ (!d || d.has(t.one_field))
514
539
  ) : [];
515
- return i.length === 0 && w.length === 0 ? null : /* @__PURE__ */ r(re.Provider, { value: { rows: D, deletes: K }, children: /* @__PURE__ */ b("div", { className: "overflow-hidden bg-white dark:bg-card", children: [
540
+ return q.length === 0 && T.length === 0 ? null : /* @__PURE__ */ r(se.Provider, { value: { rows: F, deletes: I }, children: /* @__PURE__ */ h("div", { className: "overflow-hidden bg-white dark:bg-card", children: [
516
541
  /* @__PURE__ */ r("div", { className: "bg-slate-200 border-b border-slate-300 px-4 py-2.5 dark:bg-white/[0.1] dark:border-border", children: /* @__PURE__ */ r("span", { className: "text-[12px] font-semibold text-slate-700 dark:text-slate-200", children: "Summary" }) }),
517
- i.map(({ step: t, fields: u }, x) => /* @__PURE__ */ b("div", { children: [
542
+ q.map(({ step: t, fields: s }, x) => /* @__PURE__ */ h("div", { children: [
518
543
  /* @__PURE__ */ r(
519
544
  "div",
520
545
  {
521
- className: R(
546
+ className: E(
522
547
  "bg-slate-100 px-4 py-2 border-b border-slate-200 dark:bg-white/[0.06] dark:border-border/80",
523
548
  x > 0 && "border-t border-slate-200 dark:border-border/80"
524
549
  ),
525
550
  children: /* @__PURE__ */ r("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: t.label })
526
551
  }
527
552
  ),
528
- u.map((p, J) => {
529
- const T = f[p.field], E = p.label ?? Z(p.field), A = !!(k != null && k[p.field]), F = o == null ? void 0 : o[p.field], ce = F !== void 0 ? F === !0 : T == null || typeof T == "string" && T.trim() === "" || Array.isArray(T) && T.length === 0, de = F === null, H = !!p.required && ce && !A && !de, W = (g == null ? void 0 : g.has(p.field)) ?? !1;
530
- return /* @__PURE__ */ b(
553
+ s.map((y, P) => {
554
+ const N = c[y.field], C = y.label ?? ee(y.field), A = !!(g != null && g[y.field]), J = o == null ? void 0 : o[y.field], ue = J !== void 0 ? J === !0 : N == null || typeof N == "string" && N.trim() === "" || Array.isArray(N) && N.length === 0, me = J === null, W = !!y.required && ue && !A && !me, Y = (b == null ? void 0 : b.has(y.field)) ?? !1;
555
+ return /* @__PURE__ */ h(
531
556
  "div",
532
557
  {
533
- className: R(
558
+ className: E(
534
559
  "group/row flex items-stretch",
535
- J < u.length - 1 && "border-b border-slate-100 dark:border-border/60",
536
- A ? "bg-red-50 dark:bg-red-900/10" : H || W ? "bg-amber-50/70 dark:bg-amber-900/10" : ""
560
+ P < s.length - 1 && "border-b border-slate-100 dark:border-border/60",
561
+ A ? "bg-red-50 dark:bg-red-900/10" : W || Y ? "bg-amber-50/70 dark:bg-amber-900/10" : ""
537
562
  ),
538
563
  children: [
539
- /* @__PURE__ */ b(
564
+ /* @__PURE__ */ h(
540
565
  "button",
541
566
  {
542
567
  type: "button",
543
- onClick: () => P(t.key, p.field),
544
- className: R(
568
+ onClick: () => R(t.key, y.field),
569
+ className: E(
545
570
  "flex flex-1 flex-col px-4 py-2 text-left transition-colors duration-150 min-w-0",
546
571
  A ? "hover:bg-red-50 dark:hover:bg-red-900/15" : "hover:bg-slate-50 dark:hover:bg-white/[0.03]"
547
572
  ),
548
573
  children: [
549
- /* @__PURE__ */ b(
574
+ /* @__PURE__ */ h(
550
575
  "span",
551
576
  {
552
- className: R(
577
+ className: E(
553
578
  "flex items-center gap-1 text-[10px] font-medium truncate",
554
- A ? "text-red-500 dark:text-red-400" : H || W ? "text-amber-700 dark:text-amber-400" : "text-slate-400 dark:text-slate-500"
579
+ A ? "text-red-500 dark:text-red-400" : W || Y ? "text-amber-700 dark:text-amber-400" : "text-slate-400 dark:text-slate-500"
555
580
  ),
556
581
  children: [
557
- /* @__PURE__ */ r("span", { className: "truncate", children: E }),
558
- (d == null ? void 0 : d[p.field]) && /* @__PURE__ */ r(
559
- Ve,
582
+ /* @__PURE__ */ r("span", { className: "truncate", children: C }),
583
+ (m == null ? void 0 : m[y.field]) && /* @__PURE__ */ r(
584
+ We,
560
585
  {
561
- field: p,
562
- from: d[p.field].from,
563
- detail: d[p.field].detail,
564
- to: T,
565
- relations: s,
566
- collection: m,
567
- onRevert: j ? () => j(p.field) : void 0
586
+ field: y,
587
+ from: m[y.field].from,
588
+ detail: m[y.field].detail,
589
+ to: N,
590
+ relations: i,
591
+ collection: u,
592
+ onRevert: k ? () => k(y.field) : void 0
568
593
  }
569
594
  ),
570
- H && /* @__PURE__ */ r("span", { className: "shrink-0 rounded bg-amber-100 px-1 text-[9px] font-semibold uppercase tracking-wide text-amber-700 dark:bg-amber-900/30 dark:text-amber-400", children: "required" }),
571
- W && /* @__PURE__ */ r(
595
+ W && /* @__PURE__ */ r("span", { className: "shrink-0 rounded bg-amber-100 px-1 text-[9px] font-semibold uppercase tracking-wide text-amber-700 dark:bg-amber-900/30 dark:text-amber-400", children: "required" }),
596
+ Y && /* @__PURE__ */ r(
572
597
  "span",
573
598
  {
574
599
  title: "This value is no longer one of the available options",
@@ -583,18 +608,18 @@ function et({
583
608
  "span",
584
609
  {
585
610
  ref: (B) => {
586
- L.current.set(p.field, B);
611
+ j.current.set(y.field, B);
587
612
  },
588
613
  className: "mt-0.5 w-full text-[12px] min-w-0 overflow-hidden",
589
614
  children: /* @__PURE__ */ r(
590
- De,
615
+ Fe,
591
616
  {
592
- field: p,
593
- val: T,
594
- relations: s,
595
- collection: m,
596
- itemId: y,
597
- staging: h
617
+ field: y,
618
+ val: N,
619
+ relations: i,
620
+ collection: u,
621
+ itemId: f,
622
+ staging: p
598
623
  }
599
624
  )
600
625
  }
@@ -608,52 +633,52 @@ function et({
608
633
  type: "button",
609
634
  title: "Copy value",
610
635
  onClick: (B) => {
611
- var Y, G;
636
+ var G, Q;
612
637
  B.stopPropagation();
613
- const me = ((G = (Y = L.current.get(p.field)) == null ? void 0 : Y.textContent) == null ? void 0 : G.trim()) ?? Je(T);
614
- navigator.clipboard.writeText(me).catch(() => {
615
- }), C(p.field), setTimeout(
616
- () => C((Q) => Q === p.field ? null : Q),
638
+ const fe = ((Q = (G = j.current.get(y.field)) == null ? void 0 : G.textContent) == null ? void 0 : Q.trim()) ?? Ue(N);
639
+ navigator.clipboard.writeText(fe).catch(() => {
640
+ }), w(y.field), setTimeout(
641
+ () => w((z) => z === y.field ? null : z),
617
642
  1500
618
643
  );
619
644
  },
620
- className: R(
645
+ className: E(
621
646
  "flex items-center px-2 opacity-0 group-hover/row:opacity-100 transition-all duration-150",
622
- v === p.field ? "text-emerald-500" : "text-slate-400 hover:text-slate-600 dark:text-slate-500 dark:hover:text-slate-300"
647
+ O === y.field ? "text-emerald-500" : "text-slate-400 hover:text-slate-600 dark:text-slate-500 dark:hover:text-slate-300"
623
648
  ),
624
- children: v === p.field ? /* @__PURE__ */ r(ue, { className: "h-3 w-3" }) : /* @__PURE__ */ r(fe, { className: "h-3 w-3" })
649
+ children: O === y.field ? /* @__PURE__ */ r(ye, { className: "h-3 w-3" }) : /* @__PURE__ */ r(pe, { className: "h-3 w-3" })
625
650
  }
626
651
  )
627
652
  ]
628
653
  },
629
- p.field
654
+ y.field
630
655
  );
631
656
  })
632
657
  ] }, t.key)),
633
- w.length > 0 && /* @__PURE__ */ b("div", { children: [
658
+ T.length > 0 && /* @__PURE__ */ h("div", { children: [
634
659
  /* @__PURE__ */ r("div", { className: "bg-slate-100 px-4 py-2 border-y border-slate-200 dark:bg-white/[0.06] dark:border-border/80", children: /* @__PURE__ */ r("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Related" }) }),
635
- w.map((t, u) => {
636
- const x = t.one_field ?? t.many_collection ?? "", p = q === x;
660
+ T.map((t, s) => {
661
+ const x = t.one_field ?? t.many_collection ?? "", y = D === x;
637
662
  return /* @__PURE__ */ r(
638
663
  "div",
639
664
  {
640
- className: R(
665
+ className: E(
641
666
  "flex items-stretch",
642
- u < w.length - 1 && "border-b border-slate-100 dark:border-border/60"
667
+ s < T.length - 1 && "border-b border-slate-100 dark:border-border/60"
643
668
  ),
644
- children: /* @__PURE__ */ b(
669
+ children: /* @__PURE__ */ h(
645
670
  "button",
646
671
  {
647
672
  type: "button",
648
673
  onClick: () => {
649
674
  var A;
650
- const J = t.many_collection ?? "", T = /(^|_)(notes?|comments?)$/i.test(J), E = document.querySelector(`[data-o2m-collection="${J}"]`) ?? (T ? document.querySelector('[data-panel="notes"]') : null);
651
- if (!E) {
652
- _((F) => F === x ? null : x);
675
+ const P = t.many_collection ?? "", N = /(^|_)(notes?|comments?)$/i.test(P), C = document.querySelector(`[data-o2m-collection="${P}"]`) ?? (N ? document.querySelector('[data-panel="notes"]') : null);
676
+ if (!C) {
677
+ S((J) => J === x ? null : x);
653
678
  return;
654
679
  }
655
- E.getAttribute("data-panel-expanded") === "false" && ((A = E.querySelector("[data-panel-toggle]")) == null || A.click()), E.scrollIntoView({ behavior: "smooth", block: "center" }), E.classList.add("ring-2", "ring-nvr-cyan", "ring-offset-2", "rounded-md"), setTimeout(
656
- () => E.classList.remove(
680
+ C.getAttribute("data-panel-expanded") === "false" && ((A = C.querySelector("[data-panel-toggle]")) == null || A.click()), C.scrollIntoView({ behavior: "smooth", block: "center" }), C.classList.add("ring-2", "ring-nvr-cyan", "ring-offset-2", "rounded-md"), setTimeout(
681
+ () => C.classList.remove(
657
682
  "ring-2",
658
683
  "ring-nvr-cyan",
659
684
  "ring-offset-2",
@@ -664,25 +689,25 @@ function et({
664
689
  },
665
690
  className: "flex flex-1 flex-col px-4 py-2 min-w-0 text-left transition-colors hover:bg-nvr-cyan/5",
666
691
  children: [
667
- /* @__PURE__ */ b("span", { className: "flex items-center gap-1 text-[10px] font-medium truncate text-slate-400 dark:text-slate-500", children: [
692
+ /* @__PURE__ */ h("span", { className: "flex items-center gap-1 text-[10px] font-medium truncate text-slate-400 dark:text-slate-500", children: [
668
693
  /* @__PURE__ */ r(
669
- ye,
694
+ he,
670
695
  {
671
- className: R(
696
+ className: E(
672
697
  "h-3 w-3 shrink-0 transition-transform",
673
- p && "rotate-90"
698
+ y && "rotate-90"
674
699
  )
675
700
  }
676
701
  ),
677
- Z(t.one_field ?? t.many_collection ?? "")
702
+ ee(t.one_field ?? t.many_collection ?? "")
678
703
  ] }),
679
704
  /* @__PURE__ */ r("span", { className: "mt-0.5 text-[12px]", children: /* @__PURE__ */ r(
680
- oe,
705
+ de,
681
706
  {
682
707
  relatedCollection: t.many_collection ?? "",
683
708
  manyField: t.many_field,
684
- parentId: y,
685
- expanded: p
709
+ parentId: f,
710
+ expanded: y
686
711
  }
687
712
  ) })
688
713
  ]
@@ -696,13 +721,15 @@ function et({
696
721
  ] }) });
697
722
  }
698
723
  export {
724
+ je as M2MSummaryCount,
699
725
  X as M2OSummaryValue,
700
- De as SummaryFieldValue,
701
- et as SummaryPanel,
702
- Re as o2mItemRelation,
703
- Oe as o2mRowLabel,
704
- Ke as summaryChoiceLabel,
705
- Fe as summaryPlainText,
706
- ve as templateRelationPaths,
707
- Ce as withTemplateRelations
726
+ Fe as SummaryFieldValue,
727
+ rt as SummaryPanel,
728
+ ve as o2mAmountOf,
729
+ Pe as o2mItemRelation,
730
+ Ee as o2mRowLabel,
731
+ Je as summaryChoiceLabel,
732
+ He as summaryPlainText,
733
+ Re as templateRelationPaths,
734
+ De as withTemplateRelations
708
735
  };