@nivaro/react 0.3.65 → 0.3.66

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 (25) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +13 -4
  4. package/dist/shared/components/CollectionBrowserView.js +2509 -2668
  5. package/dist/shared/components/ItemEditForm.js +3910 -3771
  6. package/dist/shared/components/MyWorkView.js +124 -113
  7. package/dist/shared/components/ProfileView.js +483 -472
  8. package/dist/shared/components/ReportView.js +1100 -1094
  9. package/dist/shared/components/bulk/BulkCompareButton.js +62 -0
  10. package/dist/shared/components/bulk/MessageStakeholders.js +235 -0
  11. package/dist/shared/components/item-edit/CatalogPickerField.js +240 -238
  12. package/dist/shared/components/item-edit/GroupSection.js +555 -538
  13. package/dist/shared/components/item-edit/M2MCombobox.js +414 -349
  14. package/dist/shared/components/item-edit/MidairCollisionDialog.js +211 -187
  15. package/dist/shared/components/item-edit/RelationCombobox.js +327 -311
  16. package/dist/shared/components/item-edit/SummaryPanel.js +146 -144
  17. package/dist/shared/components/item-edit/UserChip.js +264 -229
  18. package/dist/shared/components/item-edit/cascade-clear-notice.js +23 -19
  19. package/dist/shared/components/item-edit/header-path-preview.js +52 -0
  20. package/dist/shared/components/item-edit/line-merge.js +73 -47
  21. package/dist/shared/components/item-edit/picker-search.js +25 -21
  22. package/dist/shared/components/queue/QueueWorklist.js +799 -772
  23. package/dist/shared/lib/obligation-reason-text.js +1 -1
  24. package/dist/shared/lib/quick-filter-cascade.js +29 -19
  25. package/package.json +1 -1
@@ -1,13 +1,13 @@
1
- import { jsx as r, jsxs as h } from "react/jsx-runtime";
1
+ import { jsx as i, jsxs as h } from "react/jsx-runtime";
2
2
  import { useQuery as $ } from "@tanstack/react-query";
3
3
  import { Check as ye, Copy as pe, ChevronRight as he, Loader2 as xe } from "lucide-react";
4
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
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";
8
+ import { cn as v, titleCase as ee, toLocalDateString as Se, choiceLabel as Ne } from "../../lib/utils.js";
9
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";
10
+ import { SYSTEM_FIELDS as qe, SENTINEL_FIELDS as Te, applyDisplayTemplate as ie, parseJson as re, richTextToPlain as te } from "./helpers.js";
11
11
  import { resolveM2MRelatedCollection as $e, m2mIdKey as ne } from "./M2MCombobox.js";
12
12
  import { RelatedItemLabel as oe } from "./RelationCombobox.js";
13
13
  const se = ge({});
@@ -24,7 +24,7 @@ function je({
24
24
  maxValues: c
25
25
  }) {
26
26
  var K, T;
27
- const i = U(), u = e.many_field ?? "", f = e.junction_field ?? (() => {
27
+ const r = U(), m = e.many_field ?? "", f = e.junction_field ?? (() => {
28
28
  const t = a.find(
29
29
  (s) => s.many_collection === e.many_collection && s.id !== e.id
30
30
  );
@@ -33,7 +33,7 @@ function je({
33
33
  (t) => t.many_collection === e.many_collection && t.many_field === f && t.id !== e.id
34
34
  )) == null ? void 0 : K.one_collection) ?? null, { data: b } = $({
35
35
  queryKey: ["summary-junction-relations", e.many_collection],
36
- queryFn: () => i.request(
36
+ queryFn: () => r.request(
37
37
  L(`/data-model/relations/for/${e.many_collection}`)
38
38
  ).then((t) => t.data ?? []).catch(() => []),
39
39
  enabled: !g && !!e.many_collection && !!f,
@@ -41,23 +41,23 @@ function je({
41
41
  }), o = g ?? ((T = b == null ? void 0 : b.find(
42
42
  (t) => t.many_collection === e.many_collection && t.many_field === f && !!t.one_collection
43
43
  )) == null ? void 0 : T.one_collection) ?? null, { data: d = [] } = $({
44
- queryKey: ["m2m-items", e.many_collection, u, n],
45
- queryFn: () => i.request(
44
+ queryKey: ["m2m-items", e.many_collection, m, n],
45
+ queryFn: () => r.request(
46
46
  L(`/items/${e.many_collection}`, {
47
- filter: JSON.stringify({ [u]: { _eq: n } }),
47
+ filter: JSON.stringify({ [m]: { _eq: n } }),
48
48
  limit: 200,
49
49
  fields: `id,${f}`
50
50
  })
51
51
  ).then((t) => t.data ?? []),
52
52
  staleTime: 3e4,
53
53
  enabled: !!n && n !== "new"
54
- }), m = o ? void 0 : [...a, ...b ?? []].find(
54
+ }), u = o ? void 0 : [...a, ...b ?? []].find(
55
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(
56
+ ), k = (u == null ? void 0 : u.one_collection_field) ?? null, E = u ? $e(u) : null, { data: F = [] } = $({
57
+ queryKey: ["summary-m2a-items", e.many_collection, m, n, k],
58
+ queryFn: () => r.request(
59
59
  L(`/items/${e.many_collection}`, {
60
- filter: JSON.stringify({ [u]: { _eq: n } }),
60
+ filter: JSON.stringify({ [m]: { _eq: n } }),
61
61
  limit: 200,
62
62
  fields: `id,${f},${k}`
63
63
  })
@@ -66,10 +66,10 @@ function je({
66
66
  enabled: !!k && !!n && n !== "new"
67
67
  }), I = o === "nivaro_files" || o === "directus_files", { data: O } = $({
68
68
  queryKey: ["col-meta", o],
69
- queryFn: () => i.request(L(`/collections/${o}`)).then((t) => t.data),
69
+ queryFn: () => r.request(L(`/collections/${o}`)).then((t) => t.data),
70
70
  enabled: !!o && !I,
71
71
  staleTime: 3e5
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(), _ = [
72
+ }), w = (l == null ? void 0 : l.getStagedLinks(p)) ?? [], R = (l == null ? void 0 : l.getStagedUnlinks(p)) ?? /* @__PURE__ */ new Set(), S = d.filter((t) => !R.has(t.id)), j = /* @__PURE__ */ new Set(), _ = [
73
73
  ...w,
74
74
  ...S.map((t) => t[f]).filter((t) => t != null)
75
75
  ].filter((t) => {
@@ -77,13 +77,13 @@ function je({
77
77
  return j.has(s) ? !1 : (j.add(s), !0);
78
78
  });
79
79
  if (_.length === 0)
80
- return /* @__PURE__ */ r("span", { className: "text-slate-400 dark:text-slate-500", children: "—" });
80
+ return /* @__PURE__ */ i("span", { className: "text-slate-400 dark:text-slate-500", children: "—" });
81
81
  if (o) {
82
82
  const s = _.slice(0, 5), x = _.length - 5;
83
83
  return /* @__PURE__ */ h("span", { className: "text-[12px] text-slate-700 dark:text-slate-200", children: [
84
84
  s.map((y, P) => /* @__PURE__ */ h("span", { children: [
85
85
  P > 0 && ", ",
86
- /* @__PURE__ */ r(
86
+ /* @__PURE__ */ i(
87
87
  oe,
88
88
  {
89
89
  collection: o,
@@ -99,27 +99,27 @@ function je({
99
99
  ] })
100
100
  ] });
101
101
  }
102
- const M = /* @__PURE__ */ new Set(), q = (k ? [
103
- ...F.filter((t) => !D.has(t.id) && t[f] != null && t[k]).map((t) => ({
102
+ const D = /* @__PURE__ */ new Set(), q = (k ? [
103
+ ...F.filter((t) => !R.has(t.id) && t[f] != null && t[k]).map((t) => ({
104
104
  key: String(t.id),
105
105
  collection: Le(String(t[k])),
106
106
  id: t[f]
107
107
  })),
108
- ...R ? w.map((t) => ({
108
+ ...E ? w.map((t) => ({
109
109
  key: `staged-${String(t)}`,
110
- collection: R,
110
+ collection: E,
111
111
  id: t
112
112
  })) : []
113
113
  ] : []).filter((t) => {
114
114
  const s = `${t.collection}|${ne(t.id)}`;
115
- return M.has(s) ? !1 : (M.add(s), !0);
115
+ return D.has(s) ? !1 : (D.add(s), !0);
116
116
  });
117
- if (q.length > 0 && (w.length === 0 || R)) {
117
+ if (q.length > 0 && (w.length === 0 || E)) {
118
118
  const t = q.length - 5;
119
119
  return /* @__PURE__ */ h("span", { className: "text-[12px] text-slate-700 dark:text-slate-200", children: [
120
120
  q.slice(0, 5).map((s, x) => /* @__PURE__ */ h("span", { children: [
121
121
  x > 0 && ", ",
122
- /* @__PURE__ */ r(X, { collection: s.collection, id: s.id })
122
+ /* @__PURE__ */ i(X, { collection: s.collection, id: s.id })
123
123
  ] }, s.key)),
124
124
  t > 0 && /* @__PURE__ */ h("span", { className: "text-slate-400 dark:text-slate-500", children: [
125
125
  " +",
@@ -151,9 +151,9 @@ function ce(e) {
151
151
  }
152
152
  function X({ collection: e, id: n }) {
153
153
  const a = ce(e);
154
- return /* @__PURE__ */ r(oe, { collection: e, id: n, displayTemplate: a ?? void 0 });
154
+ return /* @__PURE__ */ i(oe, { collection: e, id: n, displayTemplate: a ?? void 0 });
155
155
  }
156
- const Me = ["name", "title", "label", "subject", "description", "line_number"], Ce = ["amount", "total", "cost"], v = (e) => {
156
+ const Me = ["name", "title", "label", "subject", "description", "line_number"], Ce = ["amount", "total", "cost"], C = (e) => {
157
157
  if (typeof e == "number") return Number.isFinite(e) ? e : null;
158
158
  if (typeof e == "string" && e.trim() !== "") {
159
159
  const n = Number(e);
@@ -162,21 +162,21 @@ const Me = ["name", "title", "label", "subject", "description", "line_number"],
162
162
  return null;
163
163
  };
164
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);
165
+ const n = Ce.find((l) => e.some((c) => C(c[l]) !== null)), a = e.some((l) => C(l.price) !== null && C(l.quantity) !== null);
166
166
  return n || a ? {
167
167
  currency: !0,
168
168
  of: (l) => {
169
- const c = n ? v(l[n]) : null;
169
+ const c = n ? C(l[n]) : null;
170
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;
171
+ const r = C(l.price), m = C(l.quantity);
172
+ return r !== null && m !== null ? Math.round(r * m * 100) / 100 : null;
173
173
  }
174
- } : e.some((l) => v(l.quantity) !== null) ? { currency: !1, of: (l) => v(l.quantity) } : null;
174
+ } : e.some((l) => C(l.quantity) !== null) ? { currency: !1, of: (l) => C(l.quantity) } : null;
175
175
  }
176
176
  const V = 4, H = 200;
177
177
  function Ee(e, n) {
178
178
  if (n) {
179
- const a = re(n, e).replace(/\s*[·|\-–—/]\s*(?=[·|\-–—/]|$)/g, "").replace(/^\s*[·|\-–—/]\s*/, "").trim();
179
+ const a = ie(n, e).replace(/\s*[·|\-–—/]\s*(?=[·|\-–—/]|$)/g, "").replace(/^\s*[·|\-–—/]\s*/, "").trim();
180
180
  if (a !== "") return a;
181
181
  }
182
182
  for (const a of Me) {
@@ -195,17 +195,17 @@ function Re(e) {
195
195
  function De(e, n, a) {
196
196
  if (!n || a.length === 0) return e;
197
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);
198
+ for (const c of new Set(a.map((r) => r.split(".")[0]))) {
199
+ const r = n[c];
200
+ r !== null && typeof r == "object" && (l[c] = r);
201
201
  }
202
202
  return l;
203
203
  }
204
204
  const Ke = ["cifa", "item", "catalog_item", "product", "part", "material"], Ae = /* @__PURE__ */ new Set(["nivaro_users", "directus_users"]);
205
205
  function Pe(e, n, a) {
206
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];
207
+ (r) => r.many_collection === n && !!r.many_field && r.many_field !== a && !r.junction_field && !!r.one_collection && !Ae.has(r.one_collection)
208
+ ), c = Ke.map((r) => l.find((m) => m.many_field === r)).find(Boolean) ?? l[0];
209
209
  return c != null && c.many_field && c.one_collection ? { field: c.many_field, collection: c.one_collection } : null;
210
210
  }
211
211
  function de({
@@ -216,7 +216,7 @@ function de({
216
216
  expanded: c
217
217
  }) {
218
218
  var K, T;
219
- const i = U(), u = _e(se), f = l && Object.keys(l).length > 0 ? {
219
+ const r = U(), m = _e(se), f = l && Object.keys(l).length > 0 ? {
220
220
  _and: [
221
221
  { [n]: { _eq: a } },
222
222
  Object.fromEntries(
@@ -234,7 +234,7 @@ function de({
234
234
  a,
235
235
  l ? JSON.stringify(l) : ""
236
236
  ],
237
- queryFn: () => i.request(
237
+ queryFn: () => r.request(
238
238
  L(`/items/${e}`, {
239
239
  filter: JSON.stringify(f),
240
240
  limit: H
@@ -244,41 +244,41 @@ function de({
244
244
  staleTime: 3e4
245
245
  }), b = ce(e), { data: o = [] } = $({
246
246
  queryKey: ["collection-relations", e],
247
- queryFn: () => i.request(L(`/collections/${e}`)).then((t) => {
247
+ queryFn: () => r.request(L(`/collections/${e}`)).then((t) => {
248
248
  var s;
249
249
  return ((s = t.data) == null ? void 0 : s.relations) ?? [];
250
250
  }),
251
251
  staleTime: 10 * 6e4
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 } = $({
252
+ }), d = Pe(o, e, n), u = Re(b), k = [...new Set(u.map((t) => t.split(".")[0]))], E = u.length ? JSON.stringify((p ?? []).map((t) => [t.id, ...k.map((s) => t[s] ?? null)])) : "", { data: F } = $({
253
253
  queryKey: [
254
254
  "o2m-summary-labels",
255
255
  e,
256
256
  n,
257
257
  a,
258
258
  l ? JSON.stringify(l) : "",
259
- m.join(","),
260
- R
259
+ u.join(","),
260
+ E
261
261
  ],
262
- queryFn: () => i.request(
262
+ queryFn: () => r.request(
263
263
  L(`/items/${e}`, {
264
264
  filter: JSON.stringify(f),
265
- fields: ["id", ...m].join(","),
265
+ fields: ["id", ...u].join(","),
266
266
  limit: H
267
267
  })
268
268
  ).then((t) => t.data ?? []).catch(() => []),
269
- enabled: m.length > 0 && !!a && a !== "new" && ((p == null ? void 0 : p.length) ?? 0) > 0,
269
+ enabled: u.length > 0 && !!a && a !== "new" && ((p == null ? void 0 : p.length) ?? 0) > 0,
270
270
  staleTime: 6e4
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(
271
+ }), I = new Map((F ?? []).map((t) => [String(t.id), t])), O = `${e}.${n}`, w = (K = m.deletes) == null ? void 0 : K.get(O), R = (((T = m.rows) == null ? void 0 : T.get(O)) ?? []).filter(
272
272
  (t) => Oe(t, l)
273
273
  ), S = [
274
274
  ...(p ?? []).filter((t) => !(w != null && w.has(String(t.id)))),
275
- ...D
275
+ ...R
276
276
  ];
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" });
277
+ if (g && R.length === 0)
278
+ return /* @__PURE__ */ i(xe, { className: "h-3 w-3 animate-spin text-slate-400 dark:text-slate-500" });
279
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;
280
+ return /* @__PURE__ */ i("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), D = _ && !j ? Math.round(S.reduce((t, s) => t + (_.of(s) ?? 0), 0) * 100) / 100 : null, q = (_ == null ? void 0 : _.currency) ?? !1;
282
282
  return /* @__PURE__ */ h("span", { className: "block", children: [
283
283
  /* @__PURE__ */ h("span", { className: "flex items-baseline gap-2", children: [
284
284
  /* @__PURE__ */ h("span", { className: "text-slate-700 dark:text-slate-200", children: [
@@ -286,11 +286,12 @@ function de({
286
286
  " row",
287
287
  S.length !== 1 ? "s" : ""
288
288
  ] }),
289
- M !== null && /* @__PURE__ */ r("span", { className: "tabular-nums text-[11px] text-slate-500 dark:text-slate-400", children: q ? M.toLocaleString(void 0, {
289
+ D !== null && /* @__PURE__ */ i("span", { className: "tabular-nums text-[11px] text-slate-500 dark:text-slate-400", children: q ? D.toLocaleString(void 0, {
290
290
  style: "currency",
291
291
  currency: "USD",
292
- maximumFractionDigits: M % 1 === 0 ? 0 : 2
293
- }) : M.toLocaleString() })
292
+ minimumFractionDigits: 2,
293
+ maximumFractionDigits: 2
294
+ }) : D.toLocaleString() })
294
295
  ] }),
295
296
  /* @__PURE__ */ h("span", { className: "mt-1 block space-y-0.5", children: [
296
297
  (c ? S : S.slice(0, V)).map((t, s) => /* @__PURE__ */ h(
@@ -298,16 +299,17 @@ function de({
298
299
  {
299
300
  className: "flex items-baseline justify-between gap-2 text-[11px] text-slate-500 dark:text-slate-400",
300
301
  children: [
301
- /* @__PURE__ */ r("span", { className: "truncate", children: Ee(
302
- De(t, I.get(String(t.id)), m),
302
+ /* @__PURE__ */ i("span", { className: "truncate", children: Ee(
303
+ De(t, I.get(String(t.id)), u),
303
304
  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: (() => {
305
+ ) ?? (d && t[d.field] != null && t[d.field] !== "" ? /* @__PURE__ */ i(X, { collection: d.collection, id: t[d.field] }) : `Row ${s + 1}`) }),
306
+ _ && _.of(t) !== null && /* @__PURE__ */ i("span", { className: "shrink-0 tabular-nums", children: (() => {
306
307
  const x = _.of(t);
307
308
  return q ? x.toLocaleString(void 0, {
308
309
  style: "currency",
309
310
  currency: "USD",
310
- maximumFractionDigits: x % 1 === 0 ? 0 : 2
311
+ minimumFractionDigits: 2,
312
+ maximumFractionDigits: 2
311
313
  }) : x.toLocaleString();
312
314
  })() })
313
315
  ]
@@ -324,7 +326,7 @@ function de({
324
326
  }
325
327
  function Fe(e) {
326
328
  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 }) });
329
+ return /* @__PURE__ */ i("span", { className: v("inline-block max-w-full rounded-sm", n && "nvr-value-pulse-bg"), children: /* @__PURE__ */ i(Ie, { ...e }) });
328
330
  }
329
331
  function Ie({
330
332
  field: e,
@@ -332,10 +334,10 @@ function Ie({
332
334
  relations: a,
333
335
  collection: l,
334
336
  itemId: c,
335
- staging: i
337
+ staging: r
336
338
  }) {
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 m = e.interface ?? "", f = /* @__PURE__ */ new Set(["select-multiple-m2m", "files-m2m", "files", "relation-grouped"]);
340
+ if (!f.has(m) && c) {
339
341
  const o = a.find(
340
342
  (d) => !d.junction_field && (d.one_field === e.field || d.many_collection === e.field) && (d.one_collection === l || d.one_collection == null)
341
343
  );
@@ -347,7 +349,7 @@ function Ie({
347
349
  return {};
348
350
  }
349
351
  })();
350
- return /* @__PURE__ */ r(
352
+ return /* @__PURE__ */ i(
351
353
  de,
352
354
  {
353
355
  relatedCollection: o.many_collection,
@@ -358,59 +360,59 @@ function Ie({
358
360
  );
359
361
  }
360
362
  }
361
- if (f.has(u) && c) {
363
+ if (f.has(m) && c) {
362
364
  const o = a.find(
363
- (m) => m.one_collection === l && (m.one_field === e.field || m.junction_field != null && m.many_collection === e.field)
365
+ (u) => u.one_collection === l && (u.one_field === e.field || u.junction_field != null && u.many_collection === e.field)
364
366
  ), d = o ? o.junction_field ? o : (() => {
365
- const m = a.find(
367
+ const u = a.find(
366
368
  (k) => k.many_collection === o.many_collection && k.id !== o.id
367
369
  );
368
- return m ? { ...o, junction_field: m.many_field } : null;
370
+ return u ? { ...o, junction_field: u.many_field } : null;
369
371
  })() : null;
370
372
  if (d) {
371
- const m = ie(e.options);
372
- return /* @__PURE__ */ r(
373
+ const u = re(e.options);
374
+ return /* @__PURE__ */ i(
373
375
  je,
374
376
  {
375
377
  relation: d,
376
378
  parentId: c,
377
379
  allRelations: a,
378
- staging: i,
379
- maxValues: m == null ? void 0 : m.max_values
380
+ staging: r,
381
+ maxValues: u == null ? void 0 : u.max_values
380
382
  }
381
383
  );
382
384
  }
383
385
  }
384
386
  const p = n == null || n === "";
385
387
  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);
388
+ return /* @__PURE__ */ i("span", { className: "text-slate-700 dark:text-slate-200", children: "No" });
389
+ if (p) return /* @__PURE__ */ i("span", { className: "text-slate-400 dark:text-slate-500", children: "—" });
390
+ if (m === "extension-editorjs" || m === "input-rich-text-html" || m === "rich_text" || m === "wysiwyg" || typeof n == "string") {
391
+ const o = He(n, m);
390
392
  if (o !== null)
391
- return /* @__PURE__ */ r("span", { className: "truncate text-slate-700 dark:text-slate-200", title: o, children: o || "—" });
393
+ return /* @__PURE__ */ i("span", { className: "truncate text-slate-700 dark:text-slate-200", title: o, children: o || "—" });
392
394
  }
393
395
  if (typeof n == "boolean")
394
- return /* @__PURE__ */ r("span", { className: "text-slate-700 dark:text-slate-200", children: n ? "Yes" : "No" });
396
+ return /* @__PURE__ */ i("span", { className: "text-slate-700 dark:text-slate-200", children: n ? "Yes" : "No" });
395
397
  const g = a.find(
396
398
  (o) => o.many_collection === l && o.many_field === e.field && !o.junction_field
397
399
  );
398
400
  if (g != null && g.one_collection)
399
- return /* @__PURE__ */ r(X, { collection: g.one_collection, id: n });
401
+ return /* @__PURE__ */ i(X, { collection: g.one_collection, id: n });
400
402
  if (e.type === "datetime" || e.type === "date")
401
403
  try {
402
- return /* @__PURE__ */ r("span", { className: "text-slate-700 dark:text-slate-200", children: Se(n) });
404
+ return /* @__PURE__ */ i("span", { className: "text-slate-700 dark:text-slate-200", children: Se(n) });
403
405
  } catch {
404
406
  }
405
407
  const b = Je(e.options, n);
406
- return /* @__PURE__ */ r("span", { className: "truncate text-slate-700 dark:text-slate-200", children: b ?? String(n) });
408
+ return /* @__PURE__ */ i("span", { className: "truncate text-slate-700 dark:text-slate-200", children: b ?? String(n) });
407
409
  }
408
410
  function Je(e, n) {
409
411
  var c;
410
412
  if (n == null || typeof n == "object") return null;
411
- const a = ie(
413
+ const a = re(
412
414
  e
413
- ), l = (c = a == null ? void 0 : a.choices) == null ? void 0 : c.find((i) => i && String(i.value) === String(n));
415
+ ), l = (c = a == null ? void 0 : a.choices) == null ? void 0 : c.find((r) => r && String(r.value) === String(n));
414
416
  return (l == null ? void 0 : l.text) != null ? Ne(l.text) : null;
415
417
  }
416
418
  const Ve = /* @__PURE__ */ new Set([
@@ -445,24 +447,24 @@ const le = (e) => {
445
447
  return n.length > 48 ? `${n.slice(0, 48)}…` : n;
446
448
  };
447
449
  function ae(e, n) {
448
- const a = U(), l = ke(), c = !!e && n != null && n !== "", { data: i } = $({
450
+ const a = U(), l = ke(), c = !!e && n != null && n !== "", { data: r } = $({
449
451
  queryKey: ["cbv-collection-meta", e],
450
452
  queryFn: () => a.request(L(`/collections/${e}`)).then((p) => p.data),
451
453
  enabled: c,
452
454
  staleTime: 10 * 6e4,
453
455
  retry: !1
454
- }), { data: u } = $({
456
+ }), { data: m } = $({
455
457
  queryKey: ["rrv-related", e, String(n)],
456
458
  queryFn: () => l(e, n).catch(() => null),
457
- enabled: c && !!i,
459
+ enabled: c && !!r,
458
460
  staleTime: 6e4,
459
461
  retry: !1
460
462
  });
461
463
  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 (!m) return "a linked record";
465
+ const f = ie(r == null ? void 0 : r.display_template, m).trim();
464
466
  if (f) return f;
465
- for (const p of ["name", "title", "label", "number", "email"]) if (u[p]) return String(u[p]);
467
+ for (const p of ["name", "title", "label", "number", "email"]) if (m[p]) return String(m[p]);
466
468
  return "a linked record";
467
469
  }
468
470
  function We({
@@ -471,16 +473,16 @@ function We({
471
473
  to: a,
472
474
  detail: l,
473
475
  relations: c,
474
- collection: i,
475
- onRevert: u
476
+ collection: r,
477
+ onRevert: m
476
478
  }) {
477
479
  var o;
478
480
  const f = ((o = c.find(
479
- (d) => d.many_collection === i && d.many_field === e.field && !!d.one_collection
481
+ (d) => d.many_collection === r && d.many_field === e.field && !!d.one_collection
480
482
  )) == 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 ? (
483
+ return m ? (
482
484
  // biome-ignore lint/a11y/useSemanticElements: nested inside the row's <button> — a real <button> is invalid there
483
- /* @__PURE__ */ r(
485
+ /* @__PURE__ */ i(
484
486
  "span",
485
487
  {
486
488
  role: "button",
@@ -489,16 +491,16 @@ function We({
489
491
  "data-tip": `${b} · click to revert`,
490
492
  "aria-label": "Revert this change",
491
493
  onClick: (d) => {
492
- d.stopPropagation(), u();
494
+ d.stopPropagation(), m();
493
495
  },
494
496
  onKeyDown: (d) => {
495
- (d.key === "Enter" || d.key === " ") && (d.preventDefault(), d.stopPropagation(), u());
497
+ (d.key === "Enter" || d.key === " ") && (d.preventDefault(), d.stopPropagation(), m());
496
498
  },
497
499
  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",
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" })
500
+ 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" })
499
501
  }
500
502
  )
501
- ) : /* @__PURE__ */ r(
503
+ ) : /* @__PURE__ */ i(
502
504
  "span",
503
505
  {
504
506
  "data-summary-changed": !0,
@@ -507,55 +509,55 @@ function We({
507
509
  }
508
510
  );
509
511
  }
510
- function rt({
512
+ function it({
511
513
  allSteps: e,
512
514
  groupedMap: n,
513
515
  ungroupedFields: a,
514
516
  sectionGroups: l,
515
517
  draft: c,
516
- relations: i,
517
- collection: u,
518
+ relations: r,
519
+ collection: m,
518
520
  itemId: f,
519
521
  staging: p,
520
522
  errors: g,
521
523
  staleFields: b,
522
524
  aliasEmptiness: o,
523
525
  layoutFields: d,
524
- changedFields: m,
526
+ changedFields: u,
525
527
  onRevertChange: k,
526
- onFieldClick: R,
528
+ onFieldClick: E,
527
529
  stagedO2MRows: F,
528
530
  stagedO2MDeletes: I
529
531
  }) {
530
- const [O, w] = Z(null), [D, S] = Z(null), j = be(/* @__PURE__ */ new Map()), q = [
532
+ const [O, w] = Z(null), [R, S] = Z(null), j = be(/* @__PURE__ */ new Map()), q = [
531
533
  ...!e.some((t) => t.key === "__general__") && a.length > 0 ? [{ key: "__general__", label: "General" }] : [],
532
534
  ...e
533
535
  ].map((t) => {
534
536
  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
537
  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
+ }).filter((t) => t.fields.length > 0), K = new Set(q.flatMap((t) => t.fields.map((s) => s.field))), T = f && f !== "new" ? r.filter(
539
+ (t) => !t.junction_field && t.many_field && t.many_collection && (t.one_collection === m || t.one_collection == null) && t.one_field != null && !K.has(t.one_field) && // Off-layout aliases stay out — the sidebar summarizes THIS layout.
538
540
  (!d || d.has(t.one_field))
539
541
  ) : [];
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
+ return q.length === 0 && T.length === 0 ? null : /* @__PURE__ */ i(se.Provider, { value: { rows: F, deletes: I }, children: /* @__PURE__ */ h("div", { className: "overflow-hidden bg-white dark:bg-card", children: [
543
+ /* @__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" }) }),
542
544
  q.map(({ step: t, fields: s }, x) => /* @__PURE__ */ h("div", { children: [
543
- /* @__PURE__ */ r(
545
+ /* @__PURE__ */ i(
544
546
  "div",
545
547
  {
546
- className: E(
548
+ className: v(
547
549
  "bg-slate-100 px-4 py-2 border-b border-slate-200 dark:bg-white/[0.06] dark:border-border/80",
548
550
  x > 0 && "border-t border-slate-200 dark:border-border/80"
549
551
  ),
550
- children: /* @__PURE__ */ r("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: t.label })
552
+ children: /* @__PURE__ */ i("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: t.label })
551
553
  }
552
554
  ),
553
555
  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;
556
+ const N = c[y.field], M = y.label ?? ee(y.field), A = !!(g != null && g[y.field]), J = o == null ? void 0 : o[y.field], me = J !== void 0 ? J === !0 : N == null || typeof N == "string" && N.trim() === "" || Array.isArray(N) && N.length === 0, ue = J === null, W = !!y.required && me && !A && !ue, Y = (b == null ? void 0 : b.has(y.field)) ?? !1;
555
557
  return /* @__PURE__ */ h(
556
558
  "div",
557
559
  {
558
- className: E(
560
+ className: v(
559
561
  "group/row flex items-stretch",
560
562
  P < s.length - 1 && "border-b border-slate-100 dark:border-border/60",
561
563
  A ? "bg-red-50 dark:bg-red-900/10" : W || Y ? "bg-amber-50/70 dark:bg-amber-900/10" : ""
@@ -565,8 +567,8 @@ function rt({
565
567
  "button",
566
568
  {
567
569
  type: "button",
568
- onClick: () => R(t.key, y.field),
569
- className: E(
570
+ onClick: () => E(t.key, y.field),
571
+ className: v(
570
572
  "flex flex-1 flex-col px-4 py-2 text-left transition-colors duration-150 min-w-0",
571
573
  A ? "hover:bg-red-50 dark:hover:bg-red-900/15" : "hover:bg-slate-50 dark:hover:bg-white/[0.03]"
572
574
  ),
@@ -574,26 +576,26 @@ function rt({
574
576
  /* @__PURE__ */ h(
575
577
  "span",
576
578
  {
577
- className: E(
579
+ className: v(
578
580
  "flex items-center gap-1 text-[10px] font-medium truncate",
579
581
  A ? "text-red-500 dark:text-red-400" : W || Y ? "text-amber-700 dark:text-amber-400" : "text-slate-400 dark:text-slate-500"
580
582
  ),
581
583
  children: [
582
- /* @__PURE__ */ r("span", { className: "truncate", children: C }),
583
- (m == null ? void 0 : m[y.field]) && /* @__PURE__ */ r(
584
+ /* @__PURE__ */ i("span", { className: "truncate", children: M }),
585
+ (u == null ? void 0 : u[y.field]) && /* @__PURE__ */ i(
584
586
  We,
585
587
  {
586
588
  field: y,
587
- from: m[y.field].from,
588
- detail: m[y.field].detail,
589
+ from: u[y.field].from,
590
+ detail: u[y.field].detail,
589
591
  to: N,
590
- relations: i,
591
- collection: u,
592
+ relations: r,
593
+ collection: m,
592
594
  onRevert: k ? () => k(y.field) : void 0
593
595
  }
594
596
  ),
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(
597
+ 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" }),
598
+ Y && /* @__PURE__ */ i(
597
599
  "span",
598
600
  {
599
601
  title: "This value is no longer one of the available options",
@@ -604,20 +606,20 @@ function rt({
604
606
  ]
605
607
  }
606
608
  ),
607
- /* @__PURE__ */ r(
609
+ /* @__PURE__ */ i(
608
610
  "span",
609
611
  {
610
612
  ref: (B) => {
611
613
  j.current.set(y.field, B);
612
614
  },
613
615
  className: "mt-0.5 w-full text-[12px] min-w-0 overflow-hidden",
614
- children: /* @__PURE__ */ r(
616
+ children: /* @__PURE__ */ i(
615
617
  Fe,
616
618
  {
617
619
  field: y,
618
620
  val: N,
619
- relations: i,
620
- collection: u,
621
+ relations: r,
622
+ collection: m,
621
623
  itemId: f,
622
624
  staging: p
623
625
  }
@@ -627,7 +629,7 @@ function rt({
627
629
  ]
628
630
  }
629
631
  ),
630
- /* @__PURE__ */ r(
632
+ /* @__PURE__ */ i(
631
633
  "button",
632
634
  {
633
635
  type: "button",
@@ -642,11 +644,11 @@ function rt({
642
644
  1500
643
645
  );
644
646
  },
645
- className: E(
647
+ className: v(
646
648
  "flex items-center px-2 opacity-0 group-hover/row:opacity-100 transition-all duration-150",
647
649
  O === y.field ? "text-emerald-500" : "text-slate-400 hover:text-slate-600 dark:text-slate-500 dark:hover:text-slate-300"
648
650
  ),
649
- children: O === y.field ? /* @__PURE__ */ r(ye, { className: "h-3 w-3" }) : /* @__PURE__ */ r(pe, { className: "h-3 w-3" })
651
+ children: O === y.field ? /* @__PURE__ */ i(ye, { className: "h-3 w-3" }) : /* @__PURE__ */ i(pe, { className: "h-3 w-3" })
650
652
  }
651
653
  )
652
654
  ]
@@ -656,13 +658,13 @@ function rt({
656
658
  })
657
659
  ] }, t.key)),
658
660
  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" }) }),
661
+ /* @__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" }) }),
660
662
  T.map((t, s) => {
661
- const x = t.one_field ?? t.many_collection ?? "", y = D === x;
662
- return /* @__PURE__ */ r(
663
+ const x = t.one_field ?? t.many_collection ?? "", y = R === x;
664
+ return /* @__PURE__ */ i(
663
665
  "div",
664
666
  {
665
- className: E(
667
+ className: v(
666
668
  "flex items-stretch",
667
669
  s < T.length - 1 && "border-b border-slate-100 dark:border-border/60"
668
670
  ),
@@ -672,13 +674,13 @@ function rt({
672
674
  type: "button",
673
675
  onClick: () => {
674
676
  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
+ const P = t.many_collection ?? "", N = /(^|_)(notes?|comments?)$/i.test(P), M = document.querySelector(`[data-o2m-collection="${P}"]`) ?? (N ? document.querySelector('[data-panel="notes"]') : null);
678
+ if (!M) {
677
679
  S((J) => J === x ? null : x);
678
680
  return;
679
681
  }
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(
682
+ M.getAttribute("data-panel-expanded") === "false" && ((A = M.querySelector("[data-panel-toggle]")) == null || A.click()), M.scrollIntoView({ behavior: "smooth", block: "center" }), M.classList.add("ring-2", "ring-nvr-cyan", "ring-offset-2", "rounded-md"), setTimeout(
683
+ () => M.classList.remove(
682
684
  "ring-2",
683
685
  "ring-nvr-cyan",
684
686
  "ring-offset-2",
@@ -690,10 +692,10 @@ function rt({
690
692
  className: "flex flex-1 flex-col px-4 py-2 min-w-0 text-left transition-colors hover:bg-nvr-cyan/5",
691
693
  children: [
692
694
  /* @__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(
695
+ /* @__PURE__ */ i(
694
696
  he,
695
697
  {
696
- className: E(
698
+ className: v(
697
699
  "h-3 w-3 shrink-0 transition-transform",
698
700
  y && "rotate-90"
699
701
  )
@@ -701,7 +703,7 @@ function rt({
701
703
  ),
702
704
  ee(t.one_field ?? t.many_collection ?? "")
703
705
  ] }),
704
- /* @__PURE__ */ r("span", { className: "mt-0.5 text-[12px]", children: /* @__PURE__ */ r(
706
+ /* @__PURE__ */ i("span", { className: "mt-0.5 text-[12px]", children: /* @__PURE__ */ i(
705
707
  de,
706
708
  {
707
709
  relatedCollection: t.many_collection ?? "",
@@ -724,7 +726,7 @@ export {
724
726
  je as M2MSummaryCount,
725
727
  X as M2OSummaryValue,
726
728
  Fe as SummaryFieldValue,
727
- rt as SummaryPanel,
729
+ it as SummaryPanel,
728
730
  ve as o2mAmountOf,
729
731
  Pe as o2mItemRelation,
730
732
  Ee as o2mRowLabel,