@declarion/react 0.38.5 → 0.40.0

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 (50) hide show
  1. package/dist-lib/{DraggableChildrenTable-DvJO6-m0.js → DraggableChildrenTable-Ctmn0liO.js} +27 -27
  2. package/dist-lib/{Grid-D2ArPFCz.js → Grid-BsIkTp3u.js} +42 -42
  3. package/dist-lib/{LayoutRenderer-C8DQ61Vo.js → LayoutRenderer-D4oTfZhV.js} +833 -731
  4. package/dist-lib/{MarkdownRenderer-CSuODN70.js → MarkdownRenderer-B-2CrtjU.js} +1 -1
  5. package/dist-lib/{RefreshControl-CHvOUn0o.js → RefreshControl-VQf34HKZ.js} +302 -220
  6. package/dist-lib/SmartDetailPage.impl-HMaLVDlV.js +1802 -0
  7. package/dist-lib/SmartRecordListPage.impl-Cxm7qvlZ.js +763 -0
  8. package/dist-lib/api/params.d.ts +12 -11
  9. package/dist-lib/components/columns/ColumnPicker.d.ts +11 -1
  10. package/dist-lib/components/detail-layout/EvidenceBlock.d.ts +6 -0
  11. package/dist-lib/components/detail-layout/useManualColumnResize.d.ts +25 -0
  12. package/dist-lib/components/list/QuickPeek.d.ts +11 -2
  13. package/dist-lib/components/pages/list/{ListBulkBar.d.ts → ListFloatbar.d.ts} +3 -3
  14. package/dist-lib/components/pages/list/RowActionsCell.d.ts +8 -10
  15. package/dist-lib/components/pages/list/RowContextMenu.d.ts +29 -0
  16. package/dist-lib/components/pages/list/SaveViewDialog.d.ts +5 -1
  17. package/dist-lib/components/pages/list/cardProjection.d.ts +1 -1
  18. package/dist-lib/components/pages/list/column-sizing.d.ts +15 -0
  19. package/dist-lib/components/pages/list/columns.d.ts +3 -0
  20. package/dist-lib/components/pages/list/useHeaderReorder.d.ts +26 -0
  21. package/dist-lib/components/pages/list/useRowMenu.d.ts +47 -0
  22. package/dist-lib/components/pages/profile/Profile.d.ts +3 -0
  23. package/dist-lib/components/pages/tenant-params/TenantParamsPage.d.ts +2 -0
  24. package/dist-lib/components/params/ParamsBlock.d.ts +25 -0
  25. package/dist-lib/components/params/param-editors.d.ts +28 -0
  26. package/dist-lib/components/primitives/Dropdown.d.ts +10 -1
  27. package/dist-lib/components/shared/ActionButton.d.ts +1 -7
  28. package/dist-lib/components/shared/ActionDialog.d.ts +2 -2
  29. package/dist-lib/components/shared/ResponsiveActionBar.d.ts +45 -23
  30. package/dist-lib/declarion-react.css +1 -1
  31. package/dist-lib/hooks/useParams.d.ts +45 -1
  32. package/dist-lib/index.d.ts +0 -2
  33. package/dist-lib/index.js +3561 -2570
  34. package/dist-lib/lib/actions.d.ts +44 -3
  35. package/dist-lib/lib/evidence-verdict.d.ts +11 -0
  36. package/dist-lib/lib/rowClickGesture.d.ts +14 -0
  37. package/dist-lib/registry-DFtAh6zc.js +4991 -0
  38. package/dist-lib/stores/list-layout.d.ts +86 -0
  39. package/dist-lib/testing.js +27 -27
  40. package/dist-lib/types/api.d.ts +29 -1
  41. package/dist-lib/types/schema.d.ts +12 -0
  42. package/dist-lib/{useCurrentScreen-DD3KdlMj.js → useCurrentScreen-mw8TfE8q.js} +596 -382
  43. package/dist-lib/{useProperties-CliP5qvg.js → useProperties-gMdnhdhO.js} +117 -117
  44. package/dist-lib/{value-CNy3_xCA.js → value-t9ETvWIJ.js} +4 -4
  45. package/package.json +1 -1
  46. package/dist-lib/SmartDetailPage.impl-Cl306lX3.js +0 -1768
  47. package/dist-lib/SmartRecordListPage.impl-j8bhyL4e.js +0 -763
  48. package/dist-lib/components/list/RowMenu.d.ts +0 -23
  49. package/dist-lib/components/shared/ActionConfirmDialog.d.ts +0 -10
  50. package/dist-lib/registry-C3hbFTDQ.js +0 -5400
@@ -1,763 +0,0 @@
1
- import { s as e } from "./DynamicIcon-DeRpAaXm.js";
2
- import { F as t, Gn as n, Kn as r, M as i, Nn as a, On as o, U as s, an as c, b as l, bn as u, cn as d, gt as ee, h as f, jn as te, sn as p, un as m, v as h, yn as g, zn as ne } from "./useCurrentScreen-DD3KdlMj.js";
3
- import { $ as _, G as v, Q as re, X as y, Z as b, _ as ie, a as x, c as S, et as C, nt as w, s as T, w as ae } from "./registry-C3hbFTDQ.js";
4
- import { b as E, d as D, f as O, g as k, m as oe, n as A, p as se, r as j, s as M } from "./useProperties-CliP5qvg.js";
5
- import { t as N } from "./LayoutRenderer-C8DQ61Vo.js";
6
- import { useCallback as P, useEffect as F, useMemo as I, useRef as L, useState as R } from "react";
7
- import { useSearchParams as ce } from "react-router-dom";
8
- import { Fragment as z, jsx as B, jsxs as V } from "react/jsx-runtime";
9
- //#region src/components/pages/SmartRecordListPage.impl.tsx
10
- function H({ screenCode: r }) {
11
- let [a, s] = ce(), { data: c } = ee(), l = ne(), d = c?.screens[r], f = d?.entity ? c?.entities[d.entity] : void 0, h = d?.entity;
12
- oe(d, f, a.toString()), k(d?.route);
13
- let g = ie(), _ = a.get("selected") ?? null, v = a.get("search") ?? "", re = i(v, 300), y = a.get("sort") ?? d?.sort_default ?? "", b = I(() => {
14
- let e = D(a);
15
- return e.length > 0 ? e : void 0;
16
- }, [a]), x = 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]), C = I(() => {
17
- let e = d?.responsive?.[l.category]?.presentation;
18
- return l.category === "phone" ? "drilldown" : e === "split" || e === "drilldown" || e === "stacked" ? e : "split";
19
- }, [d?.responsive, l.category]), w = I(() => {
20
- let e = d?.responsive?.[l.category];
21
- return e?.list?.presentation === "table" || e?.list?.presentation === "cards" ? e.list.presentation : e?.presentation === "table" || e?.presentation === "cards" ? e.presentation : l.category === "phone" ? "cards" : "table";
22
- }, [d?.responsive, l.category]), ae = d?.responsive?.[l.category]?.layout?.related_records, A = I(() => T({
23
- entity: f,
24
- screen: d
25
- }), [f, d]), j = I(() => S({
26
- entity: f,
27
- screen: d,
28
- presentation: w,
29
- visibleColumns: x,
30
- card: A,
31
- sort: y
32
- }), [
33
- f,
34
- d,
35
- w,
36
- x,
37
- A,
38
- y
39
- ]), N = f?.list_pagination === "cursor", { data: H, isLoading: U } = t(h, {
40
- page: 1,
41
- per_page: 200,
42
- sort: y || void 0,
43
- search: re || void 0,
44
- filters: b,
45
- select: j.selectFields,
46
- expand: j.expandFields,
47
- preview: !0,
48
- screen: d?.fixed_filters ? r : void 0
49
- }, !N), W = E(h, {
50
- sort: y || void 0,
51
- search: re || void 0,
52
- filters: b,
53
- select: j.selectFields,
54
- expand: j.expandFields,
55
- preview: !0,
56
- screen: d?.fixed_filters ? r : void 0,
57
- limit: 200
58
- }, N), G = N ? W.rows : H?.data ?? [], q = N ? W.refs : H?.$refs, J = N ? W.isLoading : U, ue = I(() => f?.fields.names().find((e) => f.fields.get(e)?.primary) ?? "id", [f]), de = P((e, t) => {
59
- s((t) => {
60
- let n = new URLSearchParams(t);
61
- return e ? n.set("selected", e) : n.delete("selected"), n;
62
- }, { replace: t?.replace ?? !0 });
63
- }, [s]), fe = P((e) => {
64
- s((t) => {
65
- let n = new URLSearchParams(t);
66
- return e ? n.set("search", e) : n.delete("search"), n;
67
- }, { replace: !0 });
68
- }, [s]), pe = P((e, t) => {
69
- s((n) => {
70
- let r = new URLSearchParams(n), i = D(n), a;
71
- return a = t && t !== "__all__" ? [...O(i, e), M(e, t)] : O(i, e), se(a, r), r;
72
- }, { replace: !0 });
73
- }, [s]), Y = (d?.list_resizable ?? !1) && C === "split" && l.category !== "phone" && !l.touch, me = L(null), [X, Z] = R(null), Q = L(!1), $ = d?.list_width;
74
- F(() => {
75
- !Y || !$?.endsWith("%") || Z(null);
76
- }, [
77
- Y,
78
- $,
79
- l.width,
80
- l.height
81
- ]), F(() => {
82
- if (!Y || X !== null) return;
83
- let e = me.current;
84
- if (e) if ($ && $.endsWith("%")) {
85
- let t = parseFloat($) / 100;
86
- Z(Math.round(e.getBoundingClientRect().width * t));
87
- } else Z($ && parseInt($, 10) || 320);
88
- }, [
89
- Y,
90
- $,
91
- X,
92
- f
93
- ]);
94
- let he = L(null);
95
- F(() => () => {
96
- he.current?.();
97
- }, []);
98
- let ge = P((e) => {
99
- e.preventDefault(), Q.current = !0;
100
- let t = e.clientX, n = X ?? 320, r = (e) => {
101
- if (!Q.current) return;
102
- let r = (me.current?.getBoundingClientRect().width ?? window.innerWidth) - 300, i = Math.max(200, Math.min(r, n + e.clientX - t));
103
- Z(i);
104
- }, i = () => {
105
- Q.current = !1, document.removeEventListener("mousemove", r), document.removeEventListener("mouseup", i), document.body.style.cursor = "", document.body.style.userSelect = "", he.current = null;
106
- };
107
- document.body.style.cursor = "col-resize", document.body.style.userSelect = "none", document.addEventListener("mousemove", r), document.addEventListener("mouseup", i), he.current = i;
108
- }, [X]);
109
- if (!c || !d || !f) return null;
110
- let _e = b?.length ?? 0, ve = C === "split" || C === "stacked" || !_, ye = C === "split" || C === "stacked" || !!_, be = C !== "split" && _ ? () => de(null, { replace: !0 }) : void 0, xe = C === "split" ? Y && X !== null ? X : d.list_width ?? "320px" : "100%";
111
- return /* @__PURE__ */ V("div", {
112
- ref: me,
113
- "data-record-list-presentation": C,
114
- style: {
115
- display: "flex",
116
- flexDirection: C === "stacked" ? "column" : "row",
117
- height: "100%",
118
- minWidth: 0,
119
- overflow: "hidden"
120
- },
121
- children: [
122
- ve && /* @__PURE__ */ V("div", {
123
- "data-testid": "record-list-panel",
124
- style: {
125
- flex: C === "split" ? "none" : "1 1 auto",
126
- display: "flex",
127
- flexDirection: "column",
128
- overflow: "hidden",
129
- borderRight: C === "split" && !Y ? "1px solid var(--divider)" : "none",
130
- borderBottom: C === "stacked" ? "1px solid var(--divider)" : "none",
131
- width: xe,
132
- minWidth: 0,
133
- height: C === "stacked" ? "50%" : "100%"
134
- },
135
- children: [/* @__PURE__ */ V("div", {
136
- style: {
137
- padding: 12,
138
- display: "flex",
139
- flexDirection: "column",
140
- gap: 8,
141
- borderBottom: "1px solid var(--divider)"
142
- },
143
- children: [
144
- g.hasOriginBack && /* @__PURE__ */ V("div", {
145
- style: {
146
- display: "flex",
147
- alignItems: "center",
148
- gap: 8
149
- },
150
- children: [/* @__PURE__ */ B(n, {
151
- icon: /* @__PURE__ */ B(e.back, { size: 14 }),
152
- title: "Back",
153
- onClick: g.goBack
154
- }), /* @__PURE__ */ B("span", {
155
- style: {
156
- fontSize: 12.5,
157
- fontWeight: 600,
158
- color: "var(--text)"
159
- },
160
- children: m(d.display?.name) || m(f.display.name_plural)
161
- })]
162
- }),
163
- /* @__PURE__ */ B(te, {
164
- value: v,
165
- onChange: fe,
166
- placeholder: `Search ${m(f.display.name_plural)}…`,
167
- prefix: /* @__PURE__ */ B(e.search, { size: 13 })
168
- }),
169
- d.filters && d.filters.length > 0 && /* @__PURE__ */ B("div", {
170
- style: {
171
- display: "flex",
172
- flexWrap: "wrap",
173
- gap: 6
174
- },
175
- children: d.filters.map((e) => {
176
- let t = f.fields.get(e);
177
- if (!t?.values) return null;
178
- let n = b?.find((t) => t.field === e && t.op === "eq")?.value ?? "__all__", r = p(t, e, c.entities);
179
- return /* @__PURE__ */ B("div", {
180
- style: { minWidth: 120 },
181
- children: /* @__PURE__ */ B(o, {
182
- value: n,
183
- options: [{
184
- value: "__all__",
185
- label: `All ${r}`
186
- }, ...t.values.map((e) => ({
187
- value: e.code,
188
- label: m(e.name) || e.code
189
- }))],
190
- onChange: (t) => pe(e, t),
191
- placeholder: r
192
- })
193
- }, e);
194
- })
195
- }),
196
- /* @__PURE__ */ V("div", {
197
- style: {
198
- display: "flex",
199
- alignItems: "center",
200
- justifyContent: "space-between",
201
- fontSize: 11,
202
- color: "var(--text-3)"
203
- },
204
- children: [/* @__PURE__ */ B("span", { children: J ? "Loading…" : `${G.length} ${m(f.display.name_plural)}` }), _e > 0 && /* @__PURE__ */ B("button", {
205
- onClick: () => s((e) => {
206
- let t = new URLSearchParams(e);
207
- return t.delete("filters"), t;
208
- }, { replace: !0 }),
209
- style: {
210
- background: "transparent",
211
- border: 0,
212
- color: "var(--accent)",
213
- cursor: "pointer",
214
- fontSize: 11,
215
- textDecoration: "underline",
216
- padding: 0
217
- },
218
- children: "Clear filters"
219
- })]
220
- })
221
- ]
222
- }), /* @__PURE__ */ B("div", {
223
- style: {
224
- flex: 1,
225
- overflowY: "auto",
226
- padding: w === "cards" ? 10 : 0,
227
- display: w === "cards" ? "flex" : "block",
228
- flexDirection: "column",
229
- gap: w === "cards" ? 10 : void 0
230
- },
231
- children: J ? /* @__PURE__ */ B("div", {
232
- style: {
233
- padding: 12,
234
- display: "flex",
235
- flexDirection: "column",
236
- gap: 6
237
- },
238
- children: Array.from({ length: 8 }).map((e, t) => /* @__PURE__ */ B("div", { style: {
239
- height: 48,
240
- borderRadius: 6,
241
- background: "var(--surface-3)"
242
- } }, t))
243
- }) : G.length === 0 ? /* @__PURE__ */ B("div", {
244
- style: {
245
- padding: 28,
246
- textAlign: "center",
247
- fontSize: 12.5,
248
- color: "var(--text-3)"
249
- },
250
- children: "No records found"
251
- }) : /* @__PURE__ */ V(z, { children: [G.map((e) => {
252
- let t = u(e[ue]);
253
- return /* @__PURE__ */ B(le, {
254
- record: e,
255
- entity: f,
256
- columns: x,
257
- card: A,
258
- presentation: w,
259
- refs: q,
260
- isSelected: t === _,
261
- onClick: () => de(t, { replace: C === "split" })
262
- }, t);
263
- }), N && W.hasMore && /* @__PURE__ */ B("button", {
264
- type: "button",
265
- "data-testid": "record-list-load-more",
266
- onClick: () => void W.fetchNextPage(),
267
- disabled: W.isFetchingNextPage,
268
- style: {
269
- width: "100%",
270
- padding: "8px 12px",
271
- fontSize: 12,
272
- background: "transparent",
273
- border: "none",
274
- borderTop: "1px solid var(--divider)",
275
- color: "var(--text-2)",
276
- cursor: W.isFetchingNextPage ? "default" : "pointer"
277
- },
278
- children: W.isFetchingNextPage ? "Loading…" : "Load more"
279
- })] })
280
- })]
281
- }),
282
- Y && /* @__PURE__ */ B("div", {
283
- "data-testid": "record-list-resize-handle",
284
- onMouseDown: ge,
285
- style: {
286
- flex: "none",
287
- width: 1,
288
- cursor: "col-resize",
289
- background: "var(--divider)",
290
- transition: "background-color .12s"
291
- },
292
- onMouseEnter: (e) => e.currentTarget.style.background = "var(--border-strong)",
293
- onMouseLeave: (e) => e.currentTarget.style.background = "var(--divider)"
294
- }),
295
- ye && /* @__PURE__ */ B("div", {
296
- "data-testid": "record-detail-panel",
297
- style: {
298
- flex: 1,
299
- minWidth: 0,
300
- overflow: "hidden",
301
- height: C === "stacked" ? "50%" : "100%"
302
- },
303
- children: _ ? /* @__PURE__ */ B(K, {
304
- entityCode: h,
305
- recordId: _,
306
- items: d.items,
307
- schema: c,
308
- entity: f,
309
- onBackToList: be,
310
- relatedRecordsPresentation: ae
311
- }, _) : /* @__PURE__ */ B("div", {
312
- style: {
313
- display: "flex",
314
- alignItems: "center",
315
- justifyContent: "center",
316
- height: "100%",
317
- color: "var(--text-3)"
318
- },
319
- children: /* @__PURE__ */ V("p", {
320
- style: { fontSize: 12.5 },
321
- children: [
322
- "Select a ",
323
- m(f.display.name),
324
- " to view details"
325
- ]
326
- })
327
- })
328
- })
329
- ]
330
- });
331
- }
332
- function le({ record: e, entity: t, columns: n, card: r, presentation: i, refs: a, isSelected: o, onClick: s }) {
333
- let c = f();
334
- if (i === "cards") {
335
- let n = r.badgeFields.filter((n) => U(t, e, n)), i = r.bodyFields.filter((n) => U(t, e, n)), l = r.metaFields.filter((n) => U(t, e, n));
336
- return /* @__PURE__ */ V("button", {
337
- type: "button",
338
- "data-testid": "record-list-card",
339
- "aria-current": o ? "true" : void 0,
340
- onClick: s,
341
- style: {
342
- width: "100%",
343
- textAlign: "left",
344
- padding: 12,
345
- border: "1px solid var(--border)",
346
- borderRadius: 8,
347
- background: o ? "var(--row-selected-bg)" : "var(--surface)",
348
- color: "var(--text)",
349
- cursor: "pointer",
350
- display: "flex",
351
- flexDirection: "column",
352
- gap: 8,
353
- boxShadow: o ? "inset 3px 0 0 var(--accent)" : "none"
354
- },
355
- children: [
356
- /* @__PURE__ */ B(W, {
357
- entity: t,
358
- record: e,
359
- field: r.titleField,
360
- refs: a
361
- }),
362
- r.subtitleField && /* @__PURE__ */ B("div", {
363
- style: {
364
- fontSize: 12,
365
- color: "var(--text-3)",
366
- overflowWrap: "anywhere"
367
- },
368
- children: C({
369
- entity: t,
370
- fieldName: r.subtitleField,
371
- record: e,
372
- mode: "display",
373
- refs: a,
374
- locale: c
375
- })
376
- }),
377
- n.length > 0 && /* @__PURE__ */ B("div", {
378
- style: {
379
- display: "flex",
380
- flexWrap: "wrap",
381
- gap: 6
382
- },
383
- children: n.map((n) => /* @__PURE__ */ B("span", {
384
- style: {
385
- border: "1px solid var(--border)",
386
- borderRadius: 999,
387
- padding: "2px 7px",
388
- fontSize: 11,
389
- color: "var(--text-2)",
390
- maxWidth: "100%",
391
- overflowWrap: "anywhere"
392
- },
393
- children: C({
394
- entity: t,
395
- fieldName: n,
396
- record: e,
397
- mode: "display",
398
- refs: a,
399
- locale: c
400
- })
401
- }, n))
402
- }),
403
- i.length > 0 && /* @__PURE__ */ B("dl", {
404
- style: {
405
- display: "grid",
406
- gridTemplateColumns: "minmax(72px, max-content) minmax(0, 1fr)",
407
- gap: "5px 10px",
408
- margin: 0
409
- },
410
- children: i.map((n) => /* @__PURE__ */ B(G, {
411
- entity: t,
412
- record: e,
413
- fieldName: n,
414
- refs: a,
415
- locale: c
416
- }, n))
417
- }),
418
- l.length > 0 && /* @__PURE__ */ B("div", {
419
- style: {
420
- display: "flex",
421
- flexWrap: "wrap",
422
- gap: 8,
423
- fontSize: 11,
424
- color: "var(--text-3)"
425
- },
426
- children: l.map((n) => /* @__PURE__ */ B("span", {
427
- style: {
428
- minWidth: 0,
429
- overflowWrap: "anywhere"
430
- },
431
- children: C({
432
- entity: t,
433
- fieldName: n,
434
- record: e,
435
- mode: "display",
436
- refs: a,
437
- locale: c
438
- })
439
- }, n))
440
- })
441
- ]
442
- });
443
- }
444
- let l = n[0], u = n[1], d = n.slice(2, 4);
445
- return /* @__PURE__ */ V("button", {
446
- onClick: s,
447
- style: {
448
- width: "100%",
449
- textAlign: "left",
450
- padding: "10px 12px",
451
- borderBottom: "1px solid var(--divider)",
452
- background: o ? "var(--row-selected-bg)" : "transparent",
453
- borderLeft: o ? "2px solid var(--accent)" : "2px solid transparent",
454
- cursor: "pointer",
455
- transition: "background-color .12s",
456
- display: "flex",
457
- flexDirection: "column",
458
- gap: 2,
459
- border: "1px solid transparent",
460
- borderBottomColor: "var(--divider)"
461
- },
462
- onMouseEnter: (e) => {
463
- o || (e.currentTarget.style.background = "var(--surface-3)");
464
- },
465
- onMouseLeave: (e) => {
466
- o || (e.currentTarget.style.background = "transparent");
467
- },
468
- children: [l && /* @__PURE__ */ B("div", {
469
- style: {
470
- fontSize: 12.5,
471
- fontWeight: 500,
472
- overflow: "hidden",
473
- textOverflow: "ellipsis",
474
- whiteSpace: "nowrap",
475
- color: "var(--text)"
476
- },
477
- children: C({
478
- entity: t,
479
- fieldName: l,
480
- record: e,
481
- mode: "display",
482
- refs: a,
483
- locale: c
484
- })
485
- }), /* @__PURE__ */ V("div", {
486
- style: {
487
- display: "flex",
488
- alignItems: "center",
489
- gap: 6
490
- },
491
- children: [u && /* @__PURE__ */ B("div", {
492
- style: {
493
- fontSize: 11,
494
- color: "var(--text-3)",
495
- flex: 1,
496
- overflow: "hidden",
497
- textOverflow: "ellipsis",
498
- whiteSpace: "nowrap"
499
- },
500
- children: C({
501
- entity: t,
502
- fieldName: u,
503
- record: e,
504
- mode: "display",
505
- refs: a,
506
- locale: c
507
- })
508
- }), /* @__PURE__ */ B("div", {
509
- style: {
510
- display: "flex",
511
- alignItems: "center",
512
- gap: 4,
513
- flexShrink: 0
514
- },
515
- children: d.map((n) => _(t, e, n) == null ? null : /* @__PURE__ */ B("div", {
516
- style: { fontSize: 11 },
517
- children: C({
518
- entity: t,
519
- fieldName: n,
520
- record: e,
521
- mode: "display",
522
- refs: a,
523
- locale: c
524
- })
525
- }, n))
526
- })]
527
- })]
528
- });
529
- }
530
- function U(e, t, n) {
531
- let r = _(e, t, n);
532
- return !(r == null || r === "" || Array.isArray(r) && r.length === 0);
533
- }
534
- function W({ entity: e, record: t, field: n, refs: r }) {
535
- let i = f(), a = d(t, e);
536
- return /* @__PURE__ */ B("div", {
537
- style: {
538
- fontSize: 13.5,
539
- fontWeight: 600,
540
- color: "var(--text)",
541
- overflowWrap: "anywhere"
542
- },
543
- children: (n ? C({
544
- entity: e,
545
- fieldName: n,
546
- record: t,
547
- mode: "display",
548
- refs: r,
549
- locale: i
550
- }) : a) || m(e.display.name)
551
- });
552
- }
553
- function G({ entity: e, record: t, fieldName: n, refs: r, locale: i }) {
554
- let a = _(e, t, n);
555
- if (a == null || a === "") return null;
556
- let o = e.fields.get(n);
557
- return o ? /* @__PURE__ */ V(z, { children: [/* @__PURE__ */ B("dt", {
558
- style: {
559
- color: "var(--text-3)",
560
- fontSize: 11.5,
561
- minWidth: 0,
562
- overflowWrap: "anywhere"
563
- },
564
- children: p(o, n)
565
- }), /* @__PURE__ */ B("dd", {
566
- style: {
567
- margin: 0,
568
- color: "var(--text)",
569
- fontSize: 12,
570
- minWidth: 0,
571
- overflowWrap: "anywhere"
572
- },
573
- children: C({
574
- entity: e,
575
- fieldName: n,
576
- record: t,
577
- mode: "display",
578
- refs: r,
579
- locale: i
580
- })
581
- })] }) : null;
582
- }
583
- function K({ entityCode: e, recordId: t, items: n, schema: r, entity: i, onBackToList: a, relatedRecordsPresentation: o }) {
584
- return /* @__PURE__ */ B(h, { children: /* @__PURE__ */ B(q, {
585
- entityCode: e,
586
- recordId: t,
587
- items: n,
588
- schema: r,
589
- entity: i,
590
- onBackToList: a,
591
- relatedRecordsPresentation: o
592
- }) });
593
- }
594
- function q({ entityCode: t, recordId: i, items: o, schema: ee, entity: f, onBackToList: te, relatedRecordsPresentation: p }) {
595
- let h = c(f, "update"), { data: ne, isLoading: ie } = x(t, I(() => i ? g(f, i) : void 0, [i, f])), S = v(t), C = l(), [T, E] = R(!1), [D, O] = R({}), k = ne?.data, oe = k?.$statuses, se = k?.$properties, M = j(t, i), F = A(t, i), L = I(() => {
596
- let e = /* @__PURE__ */ new Set();
597
- for (let [t, n] of f.fields) !n.auto && !n.primary && e.add(t);
598
- for (let [t] of f.files ?? []) e.add(t);
599
- return e;
600
- }, [f]), ce = P(() => {
601
- if (k) {
602
- let e = {};
603
- L.forEach((t) => {
604
- let n = _(f, k, t);
605
- e[t] = re(f, t) ? n ?? null : n ?? "";
606
- }), O(e);
607
- }
608
- E(!0);
609
- }, [
610
- k,
611
- L,
612
- f
613
- ]), H = P(async () => {
614
- await C.flushAllDrafts(), E(!1), O({});
615
- }, [C]), le = P(() => {
616
- let e = {}, t = y({
617
- entity: f,
618
- formData: D,
619
- record: k,
620
- isNew: !1
621
- }), n = b(t);
622
- for (let [t, n] of Object.entries(D)) f.files?.has(t) || (e[t] = w(f, t, n));
623
- if (Object.keys(t).length > 0 && (e.$files = t), Object.keys(e).length === 0) {
624
- E(!1), O({});
625
- return;
626
- }
627
- S.mutate({
628
- pkValues: i,
629
- data: e
630
- }, {
631
- onSuccess: () => {
632
- n.forEach((e) => C.markCommitted(e)), E(!1), O({}), s.success("Saved");
633
- },
634
- onError: () => s.error("Failed to save")
635
- });
636
- }, [
637
- C,
638
- S,
639
- i,
640
- f,
641
- D,
642
- k
643
- ]), U = P((e, t) => {
644
- O((n) => ({
645
- ...n,
646
- [e]: t
647
- }));
648
- }, []);
649
- if (ie) return /* @__PURE__ */ B(ae, {});
650
- if (!k) return null;
651
- let W = d(k, f), G = f.display?.display_field, K = W ? void 0 : G ? k[G] : k[f.fields.names()[0]], q = W || (K != null && typeof K != "object" ? u(K) : m(f.display.name)), J = k?.$refs, ue = {
652
- schema: ee,
653
- entity: f,
654
- entityCode: t,
655
- recordId: i,
656
- record: T ? {
657
- ...k,
658
- ...D
659
- } : k,
660
- isNew: !1,
661
- mode: T ? "edit" : "display",
662
- onFieldChange: T ? U : void 0,
663
- refs: J,
664
- objectProperties: se ?? void 0,
665
- onSetProperty: h ? (e, t) => F.mutate({
666
- propertyCode: e,
667
- value: t
668
- }) : void 0,
669
- isPropertyPending: F.isPending,
670
- objectStatuses: oe ?? void 0,
671
- onSetStatus: h ? (e, t) => M.mutate({
672
- groupCode: e,
673
- statusCode: t
674
- }) : void 0,
675
- isStatusPending: M.isPending,
676
- relatedRecordsPresentation: p
677
- };
678
- return /* @__PURE__ */ V("div", {
679
- style: {
680
- display: "flex",
681
- flexDirection: "column",
682
- height: "100%"
683
- },
684
- children: [/* @__PURE__ */ V("div", {
685
- style: {
686
- display: "flex",
687
- alignItems: "center",
688
- justifyContent: "space-between",
689
- padding: "10px 16px",
690
- borderBottom: "1px solid var(--divider)",
691
- position: "sticky",
692
- top: 0,
693
- background: "var(--surface)",
694
- zIndex: 10
695
- },
696
- children: [/* @__PURE__ */ B("h2", {
697
- style: {
698
- margin: 0,
699
- fontSize: 13,
700
- fontWeight: 600,
701
- overflow: "hidden",
702
- textOverflow: "ellipsis",
703
- whiteSpace: "nowrap",
704
- color: "var(--text)"
705
- },
706
- children: q
707
- }), /* @__PURE__ */ V("div", {
708
- style: {
709
- display: "flex",
710
- alignItems: "center",
711
- gap: 6
712
- },
713
- children: [te && /* @__PURE__ */ B(n, {
714
- icon: /* @__PURE__ */ B(e.back, { size: 14 }),
715
- title: "Back to list",
716
- onClick: te
717
- }), h && (T ? /* @__PURE__ */ V(z, { children: [/* @__PURE__ */ B(r, {
718
- size: "xs",
719
- icon: /* @__PURE__ */ B(e.x, { size: 12 }),
720
- onClick: H,
721
- children: "Cancel"
722
- }), /* @__PURE__ */ B(r, {
723
- kind: "primary",
724
- size: "xs",
725
- icon: S.isPending ? /* @__PURE__ */ B(a, { size: 12 }) : /* @__PURE__ */ B(e.save, { size: 12 }),
726
- onClick: le,
727
- disabled: S.isPending,
728
- children: S.isPending ? "Saving…" : "Save"
729
- })] }) : /* @__PURE__ */ B(r, {
730
- size: "xs",
731
- icon: /* @__PURE__ */ B(e.edit, { size: 12 }),
732
- onClick: ce,
733
- children: "Edit"
734
- }))]
735
- })]
736
- }), /* @__PURE__ */ B("div", {
737
- style: {
738
- flex: 1,
739
- overflowY: "auto",
740
- padding: 16,
741
- display: "flex",
742
- flexDirection: "column",
743
- gap: 12
744
- },
745
- children: o && o.length > 0 ? /* @__PURE__ */ B(N, {
746
- nodes: o,
747
- ctx: ue
748
- }) : /* @__PURE__ */ V("p", {
749
- style: {
750
- fontSize: 12.5,
751
- color: "var(--text-3)"
752
- },
753
- children: [
754
- "No layout configured. Add ",
755
- /* @__PURE__ */ B("code", { children: "items:" }),
756
- " to the screen definition."
757
- ]
758
- })
759
- })]
760
- });
761
- }
762
- //#endregion
763
- export { H as SmartRecordListPage };