@declarion/react 0.40.0 → 0.40.1

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.
@@ -1,84 +1,84 @@
1
1
  import { s as e } from "./DynamicIcon-DeRpAaXm.js";
2
- import { A as t, Cn as n, F as r, Fn as i, Jn as a, Kn as o, N as s, Pn as c, Sn as l, Tn as u, Un as d, X as f, bn as p, er as ee, it as m, jt as h, or as te, q as ne, sr as g } from "./useCurrentScreen-mw8TfE8q.js";
3
- import { G as _, K as v, U as y, W as b, Y as x, _ as re, a as S, c as C, k as w, q as T, s as E, w as ie } from "./registry-DFtAh6zc.js";
4
- import { b as D, d as O, f as k, g as A, m as ae, n as j, p as oe, r as M, s as N } from "./useProperties-gMdnhdhO.js";
5
- import { t as P } from "./LayoutRenderer-D4oTfZhV.js";
6
- import { useCallback as F, useEffect as I, useMemo as L, useRef as R, useState as se } from "react";
7
- import { useSearchParams as ce } from "react-router-dom";
8
- import { Fragment as le, jsx as z, jsxs as B } from "react/jsx-runtime";
2
+ import { A as t, Cn as n, F as r, Fn as i, N as a, Pn as o, Sn as s, Tn as c, Wn as l, X as u, Yn as d, bn as f, cr as p, it as m, jt as ee, q as te, qn as h, sr as ne, tr as re } from "./useCurrentScreen-C33VZcNn.js";
3
+ import { G as g, K as _, U as ie, W as v, Y as y, _ as ae, a as b, c as x, k as S, q as C, s as w, w as oe } from "./registry-DbZX1hy8.js";
4
+ import { _ as T, c as E, f as D, h as O, m as se, n as k, p as A, r as j, x as M } from "./useProperties-BgAEk8X9.js";
5
+ import { t as N } from "./LayoutRenderer-Cbh-pY26.js";
6
+ import { useCallback as P, useEffect as F, useMemo as I, useRef as L, useState as ce } from "react";
7
+ import { useSearchParams as le } from "react-router-dom";
8
+ import { Fragment as R, jsx as z, jsxs as B } from "react/jsx-runtime";
9
9
  //#region src/components/pages/SmartRecordListPage.impl.tsx
10
10
  function V({ screenCode: t }) {
11
- let [n, r] = ce(), { data: a } = h(), s = ee(), c = a?.screens[t], p = c?.entity ? a?.entities[c.entity] : void 0, m = c?.entity;
12
- ae(c, p, n.toString()), A(c?.route);
13
- let g = re(), _ = n.get("selected") ?? null, v = n.get("search") ?? "", y = ne(v, 300), b = n.get("sort") ?? c?.sort_default ?? "", x = L(() => {
14
- let e = O(n);
11
+ let [n, r] = le(), { data: a } = ee(), o = re(), d = a?.screens[t], f = d?.entity ? a?.entities[d.entity] : void 0, p = d?.entity;
12
+ O(d, f, n.toString()), T(d?.route);
13
+ let m = ae(), g = n.get("selected") ?? null, _ = n.get("search") ?? "", ie = te(_, 300), v = n.get("sort") ?? d?.sort_default ?? "", y = I(() => {
14
+ let e = D(n);
15
15
  return e.length > 0 ? e : void 0;
16
- }, [n]), S = L(() => c?.columns ?? p?.fields.names().filter((e) => !p.fields.get(e)?.primary && !p.fields.get(e)?.auto && p.fields.get(e)?.display?.is_listable !== !1).slice(0, 4) ?? [], [c?.columns, p]), w = L(() => {
17
- let e = c?.responsive?.[s.category]?.presentation;
18
- return s.category === "phone" ? "drilldown" : e === "split" || e === "drilldown" || e === "stacked" ? e : "split";
19
- }, [c?.responsive, s.category]), T = L(() => {
20
- let e = c?.responsive?.[s.category];
21
- return e?.list?.presentation === "table" || e?.list?.presentation === "cards" ? e.list.presentation : e?.presentation === "table" || e?.presentation === "cards" ? e.presentation : s.category === "phone" ? "cards" : "table";
22
- }, [c?.responsive, s.category]), ie = c?.responsive?.[s.category]?.layout?.related_records, j = L(() => E({
23
- entity: p,
24
- screen: c
25
- }), [p, c]), M = L(() => C({
26
- entity: p,
27
- screen: c,
28
- presentation: T,
29
- visibleColumns: S,
30
- card: j,
31
- sort: b
16
+ }, [n]), b = I(() => d?.columns ?? f?.fields.names().filter((e) => !f.fields.get(e)?.primary && !f.fields.get(e)?.auto && f.fields.get(e)?.display?.is_listable !== !1).slice(0, 4) ?? [], [d?.columns, f]), S = I(() => {
17
+ let e = d?.responsive?.[o.category]?.presentation;
18
+ return o.category === "phone" ? "drilldown" : e === "split" || e === "drilldown" || e === "stacked" ? e : "split";
19
+ }, [d?.responsive, o.category]), C = I(() => {
20
+ let e = d?.responsive?.[o.category];
21
+ return e?.list?.presentation === "table" || e?.list?.presentation === "cards" ? e.list.presentation : e?.presentation === "table" || e?.presentation === "cards" ? e.presentation : o.category === "phone" ? "cards" : "table";
22
+ }, [d?.responsive, o.category]), oe = d?.responsive?.[o.category]?.layout?.related_records, k = I(() => w({
23
+ entity: f,
24
+ screen: d
25
+ }), [f, d]), j = I(() => x({
26
+ entity: f,
27
+ screen: d,
28
+ presentation: C,
29
+ visibleColumns: b,
30
+ card: k,
31
+ sort: v
32
32
  }), [
33
- p,
34
- c,
35
- T,
36
- S,
37
- j,
38
- b
39
- ]), P = p?.list_pagination === "cursor", { data: V, isLoading: H } = f(m, {
33
+ f,
34
+ d,
35
+ C,
36
+ b,
37
+ k,
38
+ v
39
+ ]), N = f?.list_pagination === "cursor", { data: V, isLoading: H } = u(p, {
40
40
  page: 1,
41
41
  per_page: 200,
42
- sort: b || void 0,
43
- search: y || void 0,
44
- filters: x,
45
- select: M.selectFields,
46
- expand: M.expandFields,
42
+ sort: v || void 0,
43
+ search: ie || void 0,
44
+ filters: y,
45
+ select: j.selectFields,
46
+ expand: j.expandFields,
47
47
  preview: !0,
48
- screen: c?.fixed_filters ? t : void 0
49
- }, !P), U = D(m, {
50
- sort: b || void 0,
51
- search: y || void 0,
52
- filters: x,
53
- select: M.selectFields,
54
- expand: M.expandFields,
48
+ screen: d?.fixed_filters ? t : void 0
49
+ }, !N), U = M(p, {
50
+ sort: v || void 0,
51
+ search: ie || void 0,
52
+ filters: y,
53
+ select: j.selectFields,
54
+ expand: j.expandFields,
55
55
  preview: !0,
56
- screen: c?.fixed_filters ? t : void 0,
56
+ screen: d?.fixed_filters ? t : void 0,
57
57
  limit: 200
58
- }, P), W = P ? U.rows : V?.data ?? [], K = P ? U.refs : V?.$refs, q = P ? U.isLoading : H, de = L(() => p?.fields.names().find((e) => p.fields.get(e)?.primary) ?? "id", [p]), fe = F((e, t) => {
58
+ }, N), W = N ? U.rows : V?.data ?? [], K = N ? U.refs : V?.$refs, q = N ? U.isLoading : H, de = I(() => f?.fields.names().find((e) => f.fields.get(e)?.primary) ?? "id", [f]), fe = P((e, t) => {
59
59
  r((t) => {
60
60
  let n = new URLSearchParams(t);
61
61
  return e ? n.set("selected", e) : n.delete("selected"), n;
62
62
  }, { replace: t?.replace ?? !0 });
63
- }, [r]), pe = F((e) => {
63
+ }, [r]), pe = P((e) => {
64
64
  r((t) => {
65
65
  let n = new URLSearchParams(t);
66
66
  return e ? n.set("search", e) : n.delete("search"), n;
67
67
  }, { replace: !0 });
68
- }, [r]), me = F((e, t) => {
68
+ }, [r]), me = P((e, t) => {
69
69
  r((n) => {
70
- let r = new URLSearchParams(n), i = O(n), a;
71
- return a = t && t !== "__all__" ? [...k(i, e), N(e, t)] : k(i, e), oe(a, r), r;
70
+ let r = new URLSearchParams(n), i = D(n), a;
71
+ return a = t && t !== "__all__" ? [...A(i, e), E(e, t)] : A(i, e), se(a, r), r;
72
72
  }, { replace: !0 });
73
- }, [r]), J = (c?.list_resizable ?? !1) && w === "split" && s.category !== "phone" && !s.touch, Y = R(null), [X, Z] = se(null), Q = R(!1), $ = c?.list_width;
74
- I(() => {
73
+ }, [r]), J = (d?.list_resizable ?? !1) && S === "split" && o.category !== "phone" && !o.touch, Y = L(null), [X, Z] = ce(null), Q = L(!1), $ = d?.list_width;
74
+ F(() => {
75
75
  !J || !$?.endsWith("%") || Z(null);
76
76
  }, [
77
77
  J,
78
78
  $,
79
- s.width,
80
- s.height
81
- ]), I(() => {
79
+ o.width,
80
+ o.height
81
+ ]), F(() => {
82
82
  if (!J || X !== null) return;
83
83
  let e = Y.current;
84
84
  if (e) if ($ && $.endsWith("%")) {
@@ -89,13 +89,13 @@ function V({ screenCode: t }) {
89
89
  J,
90
90
  $,
91
91
  X,
92
- p
92
+ f
93
93
  ]);
94
- let he = R(null);
95
- I(() => () => {
94
+ let he = L(null);
95
+ F(() => () => {
96
96
  he.current?.();
97
97
  }, []);
98
- let ge = F((e) => {
98
+ let ge = P((e) => {
99
99
  e.preventDefault(), Q.current = !0;
100
100
  let t = e.clientX, n = X ?? 320, r = (e) => {
101
101
  if (!Q.current) return;
@@ -106,14 +106,14 @@ function V({ screenCode: t }) {
106
106
  };
107
107
  document.body.style.cursor = "col-resize", document.body.style.userSelect = "none", document.addEventListener("mousemove", r), document.addEventListener("mouseup", i), he.current = i;
108
108
  }, [X]);
109
- if (!a || !c || !p) return null;
110
- let _e = x?.length ?? 0, ve = w === "split" || w === "stacked" || !_, ye = w === "split" || w === "stacked" || !!_, be = w !== "split" && _ ? () => fe(null, { replace: !0 }) : void 0, xe = w === "split" ? J && X !== null ? X : c.list_width ?? "320px" : "100%";
109
+ if (!a || !d || !f) return null;
110
+ let _e = y?.length ?? 0, ve = S === "split" || S === "stacked" || !g, ye = S === "split" || S === "stacked" || !!g, be = S !== "split" && g ? () => fe(null, { replace: !0 }) : void 0, xe = S === "split" ? J && X !== null ? X : d.list_width ?? "320px" : "100%";
111
111
  return /* @__PURE__ */ B("div", {
112
112
  ref: Y,
113
- "data-record-list-presentation": w,
113
+ "data-record-list-presentation": S,
114
114
  style: {
115
115
  display: "flex",
116
- flexDirection: w === "stacked" ? "column" : "row",
116
+ flexDirection: S === "stacked" ? "column" : "row",
117
117
  height: "100%",
118
118
  minWidth: 0,
119
119
  overflow: "hidden"
@@ -122,15 +122,15 @@ function V({ screenCode: t }) {
122
122
  ve && /* @__PURE__ */ B("div", {
123
123
  "data-testid": "record-list-panel",
124
124
  style: {
125
- flex: w === "split" ? "none" : "1 1 auto",
125
+ flex: S === "split" ? "none" : "1 1 auto",
126
126
  display: "flex",
127
127
  flexDirection: "column",
128
128
  overflow: "hidden",
129
- borderRight: w === "split" && !J ? "1px solid var(--divider)" : "none",
130
- borderBottom: w === "stacked" ? "1px solid var(--divider)" : "none",
129
+ borderRight: S === "split" && !J ? "1px solid var(--divider)" : "none",
130
+ borderBottom: S === "stacked" ? "1px solid var(--divider)" : "none",
131
131
  width: xe,
132
132
  minWidth: 0,
133
- height: w === "stacked" ? "50%" : "100%"
133
+ height: S === "stacked" ? "50%" : "100%"
134
134
  },
135
135
  children: [/* @__PURE__ */ B("div", {
136
136
  style: {
@@ -141,51 +141,51 @@ function V({ screenCode: t }) {
141
141
  borderBottom: "1px solid var(--divider)"
142
142
  },
143
143
  children: [
144
- g.hasOriginBack && /* @__PURE__ */ B("div", {
144
+ m.hasOriginBack && /* @__PURE__ */ B("div", {
145
145
  style: {
146
146
  display: "flex",
147
147
  alignItems: "center",
148
148
  gap: 8
149
149
  },
150
- children: [/* @__PURE__ */ z(te, {
150
+ children: [/* @__PURE__ */ z(ne, {
151
151
  icon: /* @__PURE__ */ z(e.back, { size: 14 }),
152
152
  title: "Back",
153
- onClick: g.goBack
153
+ onClick: m.goBack
154
154
  }), /* @__PURE__ */ z("span", {
155
155
  style: {
156
156
  fontSize: 12.5,
157
157
  fontWeight: 600,
158
158
  color: "var(--text)"
159
159
  },
160
- children: u(c.display?.name) || u(p.display.name_plural)
160
+ children: c(d.display?.name) || c(f.display.name_plural)
161
161
  })]
162
162
  }),
163
- /* @__PURE__ */ z(o, {
164
- value: v,
163
+ /* @__PURE__ */ z(h, {
164
+ value: _,
165
165
  onChange: pe,
166
- placeholder: `Search ${u(p.display.name_plural)}…`,
166
+ placeholder: `Search ${c(f.display.name_plural)}…`,
167
167
  prefix: /* @__PURE__ */ z(e.search, { size: 13 })
168
168
  }),
169
- c.filters && c.filters.length > 0 && /* @__PURE__ */ z("div", {
169
+ d.filters && d.filters.length > 0 && /* @__PURE__ */ z("div", {
170
170
  style: {
171
171
  display: "flex",
172
172
  flexWrap: "wrap",
173
173
  gap: 6
174
174
  },
175
- children: c.filters.map((e) => {
176
- let t = p.fields.get(e);
175
+ children: d.filters.map((e) => {
176
+ let t = f.fields.get(e);
177
177
  if (!t?.values) return null;
178
- let n = x?.find((t) => t.field === e && t.op === "eq")?.value ?? "__all__", r = l(t, e, a.entities);
178
+ let n = y?.find((t) => t.field === e && t.op === "eq")?.value ?? "__all__", r = s(t, e, a.entities);
179
179
  return /* @__PURE__ */ z("div", {
180
180
  style: { minWidth: 120 },
181
- children: /* @__PURE__ */ z(d, {
181
+ children: /* @__PURE__ */ z(l, {
182
182
  value: n,
183
183
  options: [{
184
184
  value: "__all__",
185
185
  label: `All ${r}`
186
186
  }, ...t.values.map((e) => ({
187
187
  value: e.code,
188
- label: u(e.name) || e.code
188
+ label: c(e.name) || e.code
189
189
  }))],
190
190
  onChange: (t) => me(e, t),
191
191
  placeholder: r
@@ -201,7 +201,7 @@ function V({ screenCode: t }) {
201
201
  fontSize: 11,
202
202
  color: "var(--text-3)"
203
203
  },
204
- children: [/* @__PURE__ */ z("span", { children: q ? "Loading…" : `${W.length} ${u(p.display.name_plural)}` }), _e > 0 && /* @__PURE__ */ z("button", {
204
+ children: [/* @__PURE__ */ z("span", { children: q ? "Loading…" : `${W.length} ${c(f.display.name_plural)}` }), _e > 0 && /* @__PURE__ */ z("button", {
205
205
  onClick: () => r((e) => {
206
206
  let t = new URLSearchParams(e);
207
207
  return t.delete("filters"), t;
@@ -223,10 +223,10 @@ function V({ screenCode: t }) {
223
223
  style: {
224
224
  flex: 1,
225
225
  overflowY: "auto",
226
- padding: T === "cards" ? 10 : 0,
227
- display: T === "cards" ? "flex" : "block",
226
+ padding: C === "cards" ? 10 : 0,
227
+ display: C === "cards" ? "flex" : "block",
228
228
  flexDirection: "column",
229
- gap: T === "cards" ? 10 : void 0
229
+ gap: C === "cards" ? 10 : void 0
230
230
  },
231
231
  children: q ? /* @__PURE__ */ z("div", {
232
232
  style: {
@@ -248,19 +248,19 @@ function V({ screenCode: t }) {
248
248
  color: "var(--text-3)"
249
249
  },
250
250
  children: "No records found"
251
- }) : /* @__PURE__ */ B(le, { children: [W.map((e) => {
251
+ }) : /* @__PURE__ */ B(R, { children: [W.map((e) => {
252
252
  let t = i(e[de]);
253
253
  return /* @__PURE__ */ z(ue, {
254
254
  record: e,
255
- entity: p,
256
- columns: S,
257
- card: j,
258
- presentation: T,
255
+ entity: f,
256
+ columns: b,
257
+ card: k,
258
+ presentation: C,
259
259
  refs: K,
260
- isSelected: t === _,
261
- onClick: () => fe(t, { replace: w === "split" })
260
+ isSelected: t === g,
261
+ onClick: () => fe(t, { replace: S === "split" })
262
262
  }, t);
263
- }), P && U.hasMore && /* @__PURE__ */ z("button", {
263
+ }), N && U.hasMore && /* @__PURE__ */ z("button", {
264
264
  type: "button",
265
265
  "data-testid": "record-list-load-more",
266
266
  onClick: () => void U.fetchNextPage(),
@@ -298,17 +298,17 @@ function V({ screenCode: t }) {
298
298
  flex: 1,
299
299
  minWidth: 0,
300
300
  overflow: "hidden",
301
- height: w === "stacked" ? "50%" : "100%"
301
+ height: S === "stacked" ? "50%" : "100%"
302
302
  },
303
- children: _ ? /* @__PURE__ */ z(G, {
304
- entityCode: m,
305
- recordId: _,
306
- items: c.items,
303
+ children: g ? /* @__PURE__ */ z(G, {
304
+ entityCode: p,
305
+ recordId: g,
306
+ items: d.items,
307
307
  schema: a,
308
- entity: p,
308
+ entity: f,
309
309
  onBackToList: be,
310
- relatedRecordsPresentation: ie
311
- }, _) : /* @__PURE__ */ z("div", {
310
+ relatedRecordsPresentation: oe
311
+ }, g) : /* @__PURE__ */ z("div", {
312
312
  style: {
313
313
  display: "flex",
314
314
  alignItems: "center",
@@ -320,7 +320,7 @@ function V({ screenCode: t }) {
320
320
  style: { fontSize: 12.5 },
321
321
  children: [
322
322
  "Select a ",
323
- u(p.display.name),
323
+ c(f.display.name),
324
324
  " to view details"
325
325
  ]
326
326
  })
@@ -365,7 +365,7 @@ function ue({ record: e, entity: n, columns: r, card: i, presentation: a, refs:
365
365
  color: "var(--text-3)",
366
366
  overflowWrap: "anywhere"
367
367
  },
368
- children: T({
368
+ children: C({
369
369
  entity: n,
370
370
  fieldName: i.subtitleField,
371
371
  record: e,
@@ -390,7 +390,7 @@ function ue({ record: e, entity: n, columns: r, card: i, presentation: a, refs:
390
390
  maxWidth: "100%",
391
391
  overflowWrap: "anywhere"
392
392
  },
393
- children: T({
393
+ children: C({
394
394
  entity: n,
395
395
  fieldName: t,
396
396
  record: e,
@@ -428,7 +428,7 @@ function ue({ record: e, entity: n, columns: r, card: i, presentation: a, refs:
428
428
  minWidth: 0,
429
429
  overflowWrap: "anywhere"
430
430
  },
431
- children: T({
431
+ children: C({
432
432
  entity: n,
433
433
  fieldName: t,
434
434
  record: e,
@@ -474,7 +474,7 @@ function ue({ record: e, entity: n, columns: r, card: i, presentation: a, refs:
474
474
  whiteSpace: "nowrap",
475
475
  color: "var(--text)"
476
476
  },
477
- children: T({
477
+ children: C({
478
478
  entity: n,
479
479
  fieldName: u,
480
480
  record: e,
@@ -497,7 +497,7 @@ function ue({ record: e, entity: n, columns: r, card: i, presentation: a, refs:
497
497
  textOverflow: "ellipsis",
498
498
  whiteSpace: "nowrap"
499
499
  },
500
- children: T({
500
+ children: C({
501
501
  entity: n,
502
502
  fieldName: d,
503
503
  record: e,
@@ -512,9 +512,9 @@ function ue({ record: e, entity: n, columns: r, card: i, presentation: a, refs:
512
512
  gap: 4,
513
513
  flexShrink: 0
514
514
  },
515
- children: f.map((t) => v(n, e, t) == null ? null : /* @__PURE__ */ z("div", {
515
+ children: f.map((t) => _(n, e, t) == null ? null : /* @__PURE__ */ z("div", {
516
516
  style: { fontSize: 11 },
517
- children: T({
517
+ children: C({
518
518
  entity: n,
519
519
  fieldName: t,
520
520
  record: e,
@@ -528,7 +528,7 @@ function ue({ record: e, entity: n, columns: r, card: i, presentation: a, refs:
528
528
  });
529
529
  }
530
530
  function H(e, t, n) {
531
- let r = v(e, t, n);
531
+ let r = _(e, t, n);
532
532
  return !(r == null || r === "" || Array.isArray(r) && r.length === 0);
533
533
  }
534
534
  function U({ entity: e, record: r, field: i, refs: a }) {
@@ -540,28 +540,28 @@ function U({ entity: e, record: r, field: i, refs: a }) {
540
540
  color: "var(--text)",
541
541
  overflowWrap: "anywhere"
542
542
  },
543
- children: (i ? T({
543
+ children: (i ? C({
544
544
  entity: e,
545
545
  fieldName: i,
546
546
  record: r,
547
547
  mode: "display",
548
548
  refs: a,
549
549
  locale: o
550
- }) : s) || u(e.display.name)
550
+ }) : s) || c(e.display.name)
551
551
  });
552
552
  }
553
553
  function W({ entity: e, record: t, fieldName: n, refs: r, locale: i }) {
554
- let a = v(e, t, n);
554
+ let a = _(e, t, n);
555
555
  if (a == null || a === "") return null;
556
556
  let o = e.fields.get(n);
557
- return o ? /* @__PURE__ */ B(le, { children: [/* @__PURE__ */ z("dt", {
557
+ return o ? /* @__PURE__ */ B(R, { children: [/* @__PURE__ */ z("dt", {
558
558
  style: {
559
559
  color: "var(--text-3)",
560
560
  fontSize: 11.5,
561
561
  minWidth: 0,
562
562
  overflowWrap: "anywhere"
563
563
  },
564
- children: l(o, n)
564
+ children: s(o, n)
565
565
  }), /* @__PURE__ */ z("dd", {
566
566
  style: {
567
567
  margin: 0,
@@ -570,7 +570,7 @@ function W({ entity: e, record: t, fieldName: n, refs: r, locale: i }) {
570
570
  minWidth: 0,
571
571
  overflowWrap: "anywhere"
572
572
  },
573
- children: T({
573
+ children: C({
574
574
  entity: e,
575
575
  fieldName: n,
576
576
  record: t,
@@ -580,100 +580,100 @@ function W({ entity: e, record: t, fieldName: n, refs: r, locale: i }) {
580
580
  })
581
581
  })] }) : null;
582
582
  }
583
- function G({ entityCode: e, recordId: t, items: n, schema: r, entity: i, onBackToList: a, relatedRecordsPresentation: o }) {
584
- return /* @__PURE__ */ z(s, { children: /* @__PURE__ */ z(K, {
583
+ function G({ entityCode: e, recordId: t, items: n, schema: r, entity: i, onBackToList: o, relatedRecordsPresentation: s }) {
584
+ return /* @__PURE__ */ z(a, { children: /* @__PURE__ */ z(K, {
585
585
  entityCode: e,
586
586
  recordId: t,
587
587
  items: n,
588
588
  schema: r,
589
589
  entity: i,
590
- onBackToList: a,
591
- relatedRecordsPresentation: o
590
+ onBackToList: o,
591
+ relatedRecordsPresentation: s
592
592
  }) });
593
593
  }
594
- function K({ entityCode: t, recordId: o, items: s, schema: l, entity: d, onBackToList: f, relatedRecordsPresentation: ee }) {
595
- let h = p(d, "update"), { data: ne, isLoading: re } = S(t, L(() => o ? c(d, o) : void 0, [o, d])), C = w(t), T = r(), [E, D] = se(!1), [O, k] = se({}), A = ne?.data, ae = A?.$statuses, oe = A?.$properties, N = M(t, o), I = j(t, o), R = L(() => {
594
+ function K({ entityCode: t, recordId: a, items: s, schema: l, entity: u, onBackToList: ee, relatedRecordsPresentation: te }) {
595
+ let h = f(u, "update"), { data: re, isLoading: ae } = b(t, I(() => a ? o(u, a) : void 0, [a, u])), x = S(t), C = r(), [w, T] = ce(!1), [E, D] = ce({}), O = re?.data, se = O?.$statuses, A = O?.$properties, M = j(t, a), F = k(t, a), L = I(() => {
596
596
  let e = /* @__PURE__ */ new Set();
597
- for (let [t, n] of d.fields) !n.auto && !n.primary && e.add(t);
598
- for (let [t] of d.files ?? []) e.add(t);
597
+ for (let [t, n] of u.fields) !n.auto && !n.primary && e.add(t);
598
+ for (let [t] of u.files ?? []) e.add(t);
599
599
  return e;
600
- }, [d]), ce = F(() => {
601
- if (A) {
600
+ }, [u]), le = P(() => {
601
+ if (O) {
602
602
  let e = {};
603
- R.forEach((t) => {
604
- let n = v(d, A, t);
605
- e[t] = _(d, t) ? n ?? null : n ?? "";
606
- }), k(e);
603
+ L.forEach((t) => {
604
+ let n = _(u, O, t);
605
+ e[t] = g(u, t) ? n ?? null : n ?? "";
606
+ }), D(e);
607
607
  }
608
- D(!0);
608
+ T(!0);
609
609
  }, [
610
- A,
611
- R,
612
- d
613
- ]), V = F(async () => {
614
- await T.flushAllDrafts(), D(!1), k({});
615
- }, [T]), ue = F(() => {
616
- let e = {}, t = y({
617
- entity: d,
618
- formData: O,
619
- record: A,
610
+ O,
611
+ L,
612
+ u
613
+ ]), V = P(async () => {
614
+ await C.flushAllDrafts(), T(!1), D({});
615
+ }, [C]), ue = P(() => {
616
+ let e = {}, t = ie({
617
+ entity: u,
618
+ formData: E,
619
+ record: O,
620
620
  isNew: !1
621
- }), n = b(t);
622
- for (let [t, n] of Object.entries(O)) d.files?.has(t) || (e[t] = x(d, t, n));
621
+ }), n = v(t);
622
+ for (let [t, n] of Object.entries(E)) u.files?.has(t) || (e[t] = y(u, t, n));
623
623
  if (Object.keys(t).length > 0 && (e.$files = t), Object.keys(e).length === 0) {
624
- D(!1), k({});
624
+ T(!1), D({});
625
625
  return;
626
626
  }
627
- C.mutate({
628
- pkValues: o,
627
+ x.mutate({
628
+ pkValues: a,
629
629
  data: e
630
630
  }, {
631
631
  onSuccess: () => {
632
- n.forEach((e) => T.markCommitted(e)), D(!1), k({}), m.success("Saved");
632
+ n.forEach((e) => C.markCommitted(e)), T(!1), D({}), m.success("Saved");
633
633
  },
634
634
  onError: () => m.error("Failed to save")
635
635
  });
636
636
  }, [
637
- T,
638
637
  C,
639
- o,
640
- d,
641
- O,
642
- A
643
- ]), H = F((e, t) => {
644
- k((n) => ({
638
+ x,
639
+ a,
640
+ u,
641
+ E,
642
+ O
643
+ ]), H = P((e, t) => {
644
+ D((n) => ({
645
645
  ...n,
646
646
  [e]: t
647
647
  }));
648
648
  }, []);
649
- if (re) return /* @__PURE__ */ z(ie, {});
650
- if (!A) return null;
651
- let U = n(A, d), W = d.display?.display_field, G = U ? void 0 : W ? A[W] : A[d.fields.names()[0]], K = U || (G != null && typeof G != "object" ? i(G) : u(d.display.name)), q = A?.$refs, de = {
649
+ if (ae) return /* @__PURE__ */ z(oe, {});
650
+ if (!O) return null;
651
+ let U = n(O, u), W = u.display?.display_field, G = U ? void 0 : W ? O[W] : O[u.fields.names()[0]], K = U || (G != null && typeof G != "object" ? i(G) : c(u.display.name)), q = O?.$refs, de = {
652
652
  schema: l,
653
- entity: d,
653
+ entity: u,
654
654
  entityCode: t,
655
- recordId: o,
656
- record: E ? {
657
- ...A,
658
- ...O
659
- } : A,
655
+ recordId: a,
656
+ record: w ? {
657
+ ...O,
658
+ ...E
659
+ } : O,
660
660
  isNew: !1,
661
- mode: E ? "edit" : "display",
662
- onFieldChange: E ? H : void 0,
661
+ mode: w ? "edit" : "display",
662
+ onFieldChange: w ? H : void 0,
663
663
  refs: q,
664
- objectProperties: oe ?? void 0,
665
- onSetProperty: h ? (e, t) => I.mutate({
664
+ objectProperties: A ?? void 0,
665
+ onSetProperty: h ? (e, t) => F.mutate({
666
666
  propertyCode: e,
667
667
  value: t
668
668
  }) : void 0,
669
- isPropertyPending: I.isPending,
670
- objectStatuses: ae ?? void 0,
671
- onSetStatus: h ? (e, t) => N.mutate({
669
+ isPropertyPending: F.isPending,
670
+ objectStatuses: se ?? void 0,
671
+ onSetStatus: h ? (e, t) => M.mutate({
672
672
  groupCode: e,
673
673
  statusCode: t
674
674
  }) : void 0,
675
- isStatusPending: N.isPending,
676
- relatedRecordsPresentation: ee
675
+ isStatusPending: M.isPending,
676
+ relatedRecordsPresentation: te
677
677
  };
678
678
  return /* @__PURE__ */ B("div", {
679
679
  style: {
@@ -710,26 +710,26 @@ function K({ entityCode: t, recordId: o, items: s, schema: l, entity: d, onBackT
710
710
  alignItems: "center",
711
711
  gap: 6
712
712
  },
713
- children: [f && /* @__PURE__ */ z(te, {
713
+ children: [ee && /* @__PURE__ */ z(ne, {
714
714
  icon: /* @__PURE__ */ z(e.back, { size: 14 }),
715
715
  title: "Back to list",
716
- onClick: f
717
- }), h && (E ? /* @__PURE__ */ B(le, { children: [/* @__PURE__ */ z(g, {
716
+ onClick: ee
717
+ }), h && (w ? /* @__PURE__ */ B(R, { children: [/* @__PURE__ */ z(p, {
718
718
  size: "xs",
719
719
  icon: /* @__PURE__ */ z(e.x, { size: 12 }),
720
720
  onClick: V,
721
721
  children: "Cancel"
722
- }), /* @__PURE__ */ z(g, {
722
+ }), /* @__PURE__ */ z(p, {
723
723
  kind: "primary",
724
724
  size: "xs",
725
- icon: C.isPending ? /* @__PURE__ */ z(a, { size: 12 }) : /* @__PURE__ */ z(e.save, { size: 12 }),
725
+ icon: x.isPending ? /* @__PURE__ */ z(d, { size: 12 }) : /* @__PURE__ */ z(e.save, { size: 12 }),
726
726
  onClick: ue,
727
- disabled: C.isPending,
728
- children: C.isPending ? "Saving…" : "Save"
729
- })] }) : /* @__PURE__ */ z(g, {
727
+ disabled: x.isPending,
728
+ children: x.isPending ? "Saving…" : "Save"
729
+ })] }) : /* @__PURE__ */ z(p, {
730
730
  size: "xs",
731
731
  icon: /* @__PURE__ */ z(e.edit, { size: 12 }),
732
- onClick: ce,
732
+ onClick: le,
733
733
  children: "Edit"
734
734
  }))]
735
735
  })]
@@ -742,7 +742,7 @@ function K({ entityCode: t, recordId: o, items: s, schema: l, entity: d, onBackT
742
742
  flexDirection: "column",
743
743
  gap: 12
744
744
  },
745
- children: s && s.length > 0 ? /* @__PURE__ */ z(P, {
745
+ children: s && s.length > 0 ? /* @__PURE__ */ z(N, {
746
746
  nodes: s,
747
747
  ctx: de
748
748
  }) : /* @__PURE__ */ B("p", {