@nivaro/react 0.3.58 → 0.3.60

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