@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,1768 +0,0 @@
1
- import { s as e, t } from "./DynamicIcon-DeRpAaXm.js";
2
- import { $ as n, B as r, Gn as i, I as a, Kn as o, L as s, Nn as c, S as l, W as u, Wn as d, Xt as f, Z as p, _t as m, an as h, b as g, bn as _, cn as v, fn as y, g as b, gt as ee, h as te, i as x, ln as ne, lt as S, mn as C, nt as w, on as re, ot as T, sn as ie, un as E, ut as D, v as O, z as k, zn as ae } from "./useCurrentScreen-DD3KdlMj.js";
3
- import { L as oe, N as se, P as ce, S as le, f as A, h as j, i as ue, l as de, o as fe, t as M, u as N, v as pe, w as me } from "./RefreshControl-CHvOUn0o.js";
4
- import { $ as he, D as ge, G as _e, H as ve, K as ye, L as P, M as be, O as xe, Q as Se, St as Ce, U as we, W as Te, X as Ee, Z as De, _ as Oe, a as ke, dt as Ae, et as je, ft as Me, i as Ne, nt as Pe, q as Fe, s as Ie, tt as Le, vt as Re, w as ze, z as Be } from "./registry-C3hbFTDQ.js";
5
- import { n as Ve, r as He, t as Ue } from "./dataTableStyles-vwD1mVOP.js";
6
- import { n as We, t as Ge } from "./LayoutRenderer-C8DQ61Vo.js";
7
- import { Fragment as Ke, useCallback as F, useEffect as I, useMemo as L, useRef as qe, useState as R } from "react";
8
- import { useLocation as Je, useParams as Ye, useSearchParams as Xe } from "react-router-dom";
9
- import { useQuery as Ze, useQueryClient as Qe } from "@tanstack/react-query";
10
- import { Fragment as $e, jsx as z, jsxs as B } from "react/jsx-runtime";
11
- //#region src/components/shared/AssociationTabs.tsx
12
- function et({ entityCode: e, recordId: n, associations: r, schema: i }) {
13
- let a = L(() => Object.entries(r), [r]), [o, s] = R(0);
14
- if (a.length === 0) return null;
15
- let [c, l] = a[o];
16
- return /* @__PURE__ */ z(Ce, {
17
- title: /* @__PURE__ */ z("div", {
18
- style: {
19
- display: "flex",
20
- alignItems: "center",
21
- gap: 4,
22
- borderBottom: "1px solid var(--divider)",
23
- margin: "-10px -14px 0 -14px",
24
- padding: "0 14px"
25
- },
26
- children: a.map(([e, n], r) => {
27
- let i = r === o;
28
- return /* @__PURE__ */ B("button", {
29
- onClick: (e) => {
30
- e.stopPropagation(), s(r);
31
- },
32
- style: {
33
- display: "inline-flex",
34
- alignItems: "center",
35
- gap: 6,
36
- padding: "10px 12px",
37
- fontSize: 12.5,
38
- background: "transparent",
39
- border: 0,
40
- borderBottom: `2px solid ${i ? "var(--accent)" : "transparent"}`,
41
- marginBottom: -1,
42
- color: i ? "var(--text)" : "var(--text-3)",
43
- cursor: "pointer",
44
- fontWeight: i ? 600 : 500
45
- },
46
- children: [n.display?.icon && /* @__PURE__ */ z(t, {
47
- name: n.display.icon,
48
- size: 13
49
- }), E(n.display?.name) || e]
50
- }, e);
51
- })
52
- }),
53
- collapsible: !1,
54
- padding: "0",
55
- children: /* @__PURE__ */ z(tt, {
56
- entityCode: e,
57
- recordId: n,
58
- assocKey: c,
59
- association: l,
60
- schema: i
61
- })
62
- });
63
- }
64
- function tt({ entityCode: t, recordId: n, assocKey: r, association: i, schema: a }) {
65
- let s = Ae(), c = te(), l = `${t}.${r}`, { data: u, isLoading: d } = Ze({
66
- queryKey: [
67
- "association",
68
- l,
69
- n
70
- ],
71
- queryFn: () => D(l, [n])
72
- }), f = u?.target_entity ?? i.target, p = a.entities[f], m = L(() => u?.ids ?? [], [u?.ids]), h = L(() => p?.fields.names().find((e) => p.fields.get(e)?.primary) ?? "id", [p]), g = L(() => m.slice(0, 50), [m]), { data: _, isLoading: v } = Ze({
73
- queryKey: [
74
- "association-records",
75
- f,
76
- g
77
- ],
78
- queryFn: () => S(f, {
79
- per_page: 50,
80
- filters: [{
81
- field: h,
82
- op: "in",
83
- value: g
84
- }]
85
- }),
86
- enabled: g.length > 0 && !!p
87
- }), y = _?.data ?? [], ee = _?.$refs, x = L(() => p ? p.fields.names().filter((e) => {
88
- let t = p.fields.get(e);
89
- return t && !t.primary && !t.auto && t.display?.is_listable !== !1;
90
- }).slice(0, 6) : [], [p]), ne = () => {
91
- let e = P(a, f);
92
- if (!e) return;
93
- let t = E(i.display?.name) || r, n = new URLSearchParams();
94
- n.set("filters", JSON.stringify([{
95
- field: h,
96
- op: "in",
97
- value: m
98
- }])), s(e.route, {
99
- title: t,
100
- icon: i.display?.icon || e.icon,
101
- search: n.toString()
102
- });
103
- }, C = {
104
- fontSize: 12.5,
105
- color: "var(--text-3)",
106
- padding: "14px 16px"
107
- };
108
- if (d || v) return /* @__PURE__ */ z("div", {
109
- style: C,
110
- children: "Loading…"
111
- });
112
- if (!p) return /* @__PURE__ */ z("div", {
113
- style: C,
114
- children: "Entity not found."
115
- });
116
- if (m.length === 0) return /* @__PURE__ */ z("div", {
117
- style: C,
118
- children: "No related records."
119
- });
120
- let w = P(a, f);
121
- return /* @__PURE__ */ B("div", {
122
- style: { padding: "8px 0" },
123
- children: [
124
- /* @__PURE__ */ B("table", {
125
- style: He,
126
- children: [/* @__PURE__ */ z("thead", { children: /* @__PURE__ */ z("tr", { children: x.map((e) => /* @__PURE__ */ z("th", {
127
- style: Ve,
128
- children: ie(p.fields.get(e), e, a.entities)
129
- }, e)) }) }), /* @__PURE__ */ z("tbody", { children: y.map((e, t) => /* @__PURE__ */ z("tr", { children: x.map((t) => {
130
- let n = p.fields.get(t);
131
- return n ? /* @__PURE__ */ z("td", {
132
- style: Ue,
133
- children: b({
134
- field: n,
135
- fieldName: t,
136
- value: e[t],
137
- mode: "display",
138
- record: e,
139
- refs: ee,
140
- locale: c
141
- })
142
- }, t) : /* @__PURE__ */ z("td", {}, t);
143
- }) }, t)) })]
144
- }),
145
- w && u && u.count > y.length && /* @__PURE__ */ z("div", {
146
- style: {
147
- padding: "10px 16px",
148
- textAlign: "center"
149
- },
150
- children: /* @__PURE__ */ B(o, {
151
- icon: /* @__PURE__ */ z(e.external, { size: 12 }),
152
- onClick: ne,
153
- children: [
154
- "View all ",
155
- u.count,
156
- " records"
157
- ]
158
- })
159
- }),
160
- w && y.length > 0 && u && u.count <= y.length && /* @__PURE__ */ z("div", {
161
- style: {
162
- padding: "10px 16px",
163
- textAlign: "center"
164
- },
165
- children: /* @__PURE__ */ z(o, {
166
- kind: "ghost",
167
- icon: /* @__PURE__ */ z(e.external, { size: 12 }),
168
- onClick: ne,
169
- children: "Open in list view"
170
- })
171
- })
172
- ]
173
- });
174
- }
175
- //#endregion
176
- //#region src/components/pages/RecordDocumentsPanel.tsx
177
- var nt = 4e3;
178
- function rt(e) {
179
- return e?.some((e) => e.status === "pending") ? nt : !1;
180
- }
181
- function it({ entityCode: t, objectId: n, canGenerateOne: r, canManageTemplates: i }) {
182
- let { data: a, isLoading: o, error: s } = Ze({
183
- queryKey: [
184
- j,
185
- t,
186
- n
187
- ],
188
- queryFn: async () => (await T("document.object_links", {
189
- entity: t,
190
- object_id: n
191
- })).result?.documents ?? [],
192
- enabled: !!(t && n) && (!!r || !!i),
193
- refetchInterval: (e) => rt(e.state.data)
194
- }), c = (a?.length ?? 0) > 0;
195
- return !r && !c ? null : /* @__PURE__ */ B(Ce, {
196
- title: /* @__PURE__ */ z(V, {}),
197
- collapsible: !1,
198
- padding: "0",
199
- children: [
200
- o && /* @__PURE__ */ z(H, {
201
- icon: /* @__PURE__ */ z(e.loader, { size: 14 }),
202
- text: "Loading documents..."
203
- }),
204
- s && /* @__PURE__ */ z(H, {
205
- icon: /* @__PURE__ */ z(e.warning, { size: 14 }),
206
- text: s instanceof Error ? s.message : String(s)
207
- }),
208
- !o && !s && (a?.length ?? 0) === 0 && /* @__PURE__ */ z(H, {
209
- icon: /* @__PURE__ */ z(e.file, { size: 14 }),
210
- text: "No generated documents"
211
- }),
212
- !o && !s && a && a.length > 0 && /* @__PURE__ */ z("div", {
213
- style: {
214
- display: "flex",
215
- flexDirection: "column"
216
- },
217
- children: a.map((e) => /* @__PURE__ */ z(at, {
218
- entityCode: t,
219
- objectId: n,
220
- doc: e
221
- }, e.generated_document_id))
222
- })
223
- ]
224
- });
225
- }
226
- function V() {
227
- return /* @__PURE__ */ B("div", {
228
- style: {
229
- display: "flex",
230
- alignItems: "center",
231
- gap: 6,
232
- margin: "-10px -14px 0 -14px",
233
- padding: "10px 14px",
234
- fontSize: 12.5,
235
- fontWeight: 600,
236
- color: "var(--text)"
237
- },
238
- children: [/* @__PURE__ */ z(e.file, { size: 13 }), "Documents"]
239
- });
240
- }
241
- function at({ entityCode: t, objectId: n, doc: i }) {
242
- let a = Qe(), [s, c] = R(!1), [l, u] = R(!1), [d, f] = R(!1), [p, m] = R(!1), [h, g] = R(null), _ = E(i.title) || i.filename || i.template_code, v = i.status === "ready" && i.download_url && !p;
243
- async function y() {
244
- c(!0), g(null);
245
- try {
246
- let e = (await T("document.download_format", {
247
- generated_document_id: i.generated_document_id,
248
- format: "pdf"
249
- })).result;
250
- e?.download_url && await k(e.download_url, e.filename);
251
- } catch (e) {
252
- r(e) ? (m(!0), g("Artifact unavailable")) : g(e instanceof Error ? e.message : String(e));
253
- } finally {
254
- c(!1);
255
- }
256
- }
257
- async function b() {
258
- if (i.download_url) {
259
- u(!0), g(null);
260
- try {
261
- await k(i.download_url, i.filename);
262
- } catch (e) {
263
- r(e) ? (m(!0), g("Artifact unavailable")) : g(e instanceof Error ? e.message : String(e));
264
- } finally {
265
- u(!1);
266
- }
267
- }
268
- }
269
- async function ee() {
270
- f(!0), g(null);
271
- try {
272
- await T("document.generate", {
273
- ...i.input ?? {},
274
- template_code: i.template_code,
275
- template_source: i.template_source,
276
- output_format: i.output_format
277
- }), await a.invalidateQueries({ queryKey: [
278
- j,
279
- t,
280
- n
281
- ] });
282
- } catch (e) {
283
- g(e instanceof Error ? e.message : String(e));
284
- } finally {
285
- f(!1);
286
- }
287
- }
288
- return /* @__PURE__ */ B("div", {
289
- style: {
290
- display: "grid",
291
- gridTemplateColumns: "minmax(0, 1fr) auto",
292
- gap: 12,
293
- alignItems: "center",
294
- padding: "11px 14px",
295
- borderTop: "1px solid var(--divider)"
296
- },
297
- children: [/* @__PURE__ */ B("div", {
298
- style: { minWidth: 0 },
299
- children: [
300
- /* @__PURE__ */ z("div", {
301
- style: {
302
- fontSize: 13,
303
- fontWeight: 600,
304
- color: "var(--text)",
305
- overflow: "hidden",
306
- textOverflow: "ellipsis",
307
- whiteSpace: "nowrap"
308
- },
309
- children: _
310
- }),
311
- /* @__PURE__ */ B("div", {
312
- style: {
313
- marginTop: 3,
314
- display: "flex",
315
- gap: 8,
316
- alignItems: "center",
317
- color: "var(--text-3)",
318
- fontSize: 11.5
319
- },
320
- children: [
321
- /* @__PURE__ */ z("span", { children: i.output_format.toUpperCase() }),
322
- /* @__PURE__ */ z("span", { children: p ? "artifact unavailable" : i.status }),
323
- /* @__PURE__ */ z("span", { children: i.ready_at || i.created_at })
324
- ]
325
- }),
326
- i.status === "failed" && i.error_text && /* @__PURE__ */ z("div", {
327
- style: {
328
- marginTop: 5,
329
- color: "var(--danger)",
330
- fontSize: 12
331
- },
332
- children: i.error_text
333
- }),
334
- h && /* @__PURE__ */ z("div", {
335
- style: {
336
- marginTop: 5,
337
- color: "var(--danger)",
338
- fontSize: 12
339
- },
340
- children: h
341
- })
342
- ]
343
- }), v ? /* @__PURE__ */ B("div", {
344
- style: {
345
- display: "flex",
346
- gap: 6
347
- },
348
- children: [/* @__PURE__ */ z(o, {
349
- kind: "ghost",
350
- size: "sm",
351
- icon: z(s ? e.loader : e.file, { size: 12 }),
352
- onClick: y,
353
- disabled: s,
354
- children: "PDF"
355
- }), /* @__PURE__ */ z(o, {
356
- kind: "default",
357
- size: "sm",
358
- icon: z(l ? e.loader : e.download, { size: 12 }),
359
- onClick: b,
360
- disabled: l,
361
- children: "Download"
362
- })]
363
- }) : p ? /* @__PURE__ */ z(o, {
364
- kind: "ghost",
365
- size: "sm",
366
- icon: z(d ? e.loader : e.file, { size: 12 }),
367
- onClick: ee,
368
- disabled: d,
369
- children: "Regenerate"
370
- }) : /* @__PURE__ */ z(o, {
371
- kind: "ghost",
372
- size: "sm",
373
- disabled: !0,
374
- children: i.status === "pending" ? "Pending" : "Unavailable"
375
- })]
376
- });
377
- }
378
- function H({ icon: e, text: t }) {
379
- return /* @__PURE__ */ B("div", {
380
- style: {
381
- display: "flex",
382
- alignItems: "center",
383
- gap: 8,
384
- padding: "14px",
385
- color: "var(--text-3)",
386
- fontSize: 12.5
387
- },
388
- children: [e, t]
389
- });
390
- }
391
- //#endregion
392
- //#region src/components/detail-layout/ErrorSummary.tsx
393
- function ot({ errors: t, onJump: n }) {
394
- if (t.length === 0) return null;
395
- let r = t.length !== 1;
396
- return /* @__PURE__ */ B("div", {
397
- role: "alert",
398
- style: {
399
- display: "flex",
400
- gap: 10,
401
- padding: "10px 12px",
402
- marginBottom: 12,
403
- borderRadius: 8,
404
- background: "var(--danger-soft)",
405
- border: "1px solid var(--danger-border)",
406
- color: "var(--text)"
407
- },
408
- children: [/* @__PURE__ */ z("span", {
409
- style: {
410
- color: "var(--danger)",
411
- marginTop: 1,
412
- display: "flex"
413
- },
414
- children: /* @__PURE__ */ z(e.warning, { size: 14 })
415
- }), /* @__PURE__ */ B("div", {
416
- style: {
417
- flex: 1,
418
- minWidth: 0
419
- },
420
- children: [/* @__PURE__ */ B("div", {
421
- style: {
422
- fontSize: 12.5,
423
- fontWeight: 600,
424
- marginBottom: 4
425
- },
426
- children: [
427
- t.length,
428
- " ",
429
- r ? "fields need" : "field needs",
430
- " attention"
431
- ]
432
- }), /* @__PURE__ */ z("ul", {
433
- style: {
434
- margin: 0,
435
- padding: 0,
436
- listStyle: "none",
437
- display: "flex",
438
- flexDirection: "column",
439
- gap: 2
440
- },
441
- children: t.map((e) => /* @__PURE__ */ z("li", { children: /* @__PURE__ */ B("button", {
442
- type: "button",
443
- onClick: n ? () => n(e.name) : void 0,
444
- style: {
445
- background: "transparent",
446
- border: 0,
447
- padding: 0,
448
- cursor: n ? "pointer" : "default",
449
- fontSize: 12,
450
- textAlign: "left",
451
- fontFamily: "inherit"
452
- },
453
- children: [
454
- /* @__PURE__ */ z("span", {
455
- style: {
456
- color: "var(--danger)",
457
- marginRight: 6
458
- },
459
- children: "•"
460
- }),
461
- /* @__PURE__ */ z("span", {
462
- style: {
463
- fontWeight: 500,
464
- color: "var(--text-2)"
465
- },
466
- children: e.label
467
- }),
468
- /* @__PURE__ */ B("span", {
469
- style: { color: "var(--text-3)" },
470
- children: [" - ", e.message]
471
- })
472
- ]
473
- }) }, e.name))
474
- })]
475
- })]
476
- });
477
- }
478
- //#endregion
479
- //#region src/components/shared/HighlightsStrip.tsx
480
- function st({ items: e }) {
481
- return e.length === 0 ? null : /* @__PURE__ */ z("div", {
482
- style: {
483
- display: "flex",
484
- alignItems: "center",
485
- flexWrap: "wrap",
486
- gap: "6px 0",
487
- fontSize: 12
488
- },
489
- children: e.map((e, t) => /* @__PURE__ */ B(Ke, { children: [t > 0 && /* @__PURE__ */ z("span", { style: {
490
- width: 1,
491
- height: 12,
492
- background: "var(--divider)",
493
- marginInline: 12
494
- } }), /* @__PURE__ */ B("span", {
495
- style: {
496
- display: "inline-flex",
497
- alignItems: "center",
498
- gap: 6,
499
- lineHeight: 1.3
500
- },
501
- children: [/* @__PURE__ */ z("span", {
502
- style: {
503
- color: "var(--text-3)",
504
- fontSize: 11.5
505
- },
506
- children: e.label
507
- }), /* @__PURE__ */ z("span", {
508
- style: { color: "var(--text)" },
509
- children: e.value
510
- })]
511
- })] }, t))
512
- });
513
- }
514
- //#endregion
515
- //#region src/components/detail-layout/DetailHighlights.tsx
516
- function ct({ screen: e, entity: t, entityCode: n, record: r, refs: i, objectStatuses: a, schema: o, locale: s }) {
517
- let c = e.highlights;
518
- if (!c || c.length === 0) return null;
519
- let l = [];
520
- for (let e of c) {
521
- let c = t.status_groups?.[e];
522
- if (c) {
523
- let t = a?.find((t) => t.group_code === e), n = t ? c.statuses.find((e) => e.code === t.status_code) : void 0;
524
- l.push({
525
- label: E(c.name),
526
- value: n ? /* @__PURE__ */ z(d, {
527
- tone: n.color ?? "slate",
528
- size: "xs",
529
- children: E(n.name)
530
- }) : /* @__PURE__ */ z("span", {
531
- style: { color: "var(--text-4)" },
532
- children: "—"
533
- })
534
- });
535
- continue;
536
- }
537
- if (t.fields.get(e) || t.files?.get(e)) {
538
- let a = je({
539
- entity: t,
540
- entityCode: n,
541
- fieldName: e,
542
- record: r,
543
- mode: "display",
544
- refs: i,
545
- entities: o.entities,
546
- screens: o.screens,
547
- surface: "list",
548
- locale: s
549
- });
550
- l.push({
551
- label: Le(t, e, o.entities),
552
- value: a
553
- });
554
- continue;
555
- }
556
- }
557
- return l.length === 0 ? null : /* @__PURE__ */ z(st, { items: l });
558
- }
559
- //#endregion
560
- //#region src/components/shared/AuditMetaStrip.tsx
561
- function U(e) {
562
- return e.by != null || e.at != null;
563
- }
564
- function lt({ lines: e }) {
565
- let t = e.filter(U);
566
- return t.length === 0 ? null : /* @__PURE__ */ z("div", {
567
- style: {
568
- display: "flex",
569
- flexWrap: "wrap",
570
- gap: "8px 24px",
571
- padding: "10px 14px",
572
- background: "var(--surface-2)",
573
- border: "1px solid var(--border)",
574
- borderRadius: 8,
575
- fontSize: 11.5,
576
- color: "var(--text-3)"
577
- },
578
- children: t.map((e, t) => /* @__PURE__ */ z(W, { line: e }, t))
579
- });
580
- }
581
- function W({ line: e }) {
582
- return /* @__PURE__ */ B("div", {
583
- style: {
584
- display: "flex",
585
- alignItems: "center",
586
- gap: 8,
587
- minWidth: 0
588
- },
589
- children: [/* @__PURE__ */ z("span", {
590
- style: {
591
- fontSize: 11,
592
- fontWeight: 600,
593
- color: "var(--text-4)",
594
- flexShrink: 0
595
- },
596
- children: e.label
597
- }), /* @__PURE__ */ B("span", {
598
- style: {
599
- display: "inline-flex",
600
- alignItems: "center",
601
- gap: 6,
602
- minWidth: 0
603
- },
604
- children: [
605
- e.by != null && /* @__PURE__ */ z("span", {
606
- style: { color: "var(--text-2)" },
607
- children: e.by
608
- }),
609
- e.by != null && e.at != null && /* @__PURE__ */ z("span", {
610
- style: { color: "var(--text-4)" },
611
- children: "·"
612
- }),
613
- e.at != null && /* @__PURE__ */ z("span", {
614
- className: "num",
615
- children: e.at
616
- })
617
- ]
618
- })]
619
- });
620
- }
621
- //#endregion
622
- //#region src/components/detail-layout/DetailAuditStrip.tsx
623
- function ut({ screen: e, entity: t, entityCode: n, record: r, refs: i, schema: a, locale: o }) {
624
- let s = e.audit;
625
- if (s?.enabled === !1) return null;
626
- let c = (e) => {
627
- if (!e || !t.fields.get(e)) return;
628
- let s = r[e];
629
- if (!(s == null || s === "")) return je({
630
- entity: t,
631
- entityCode: n,
632
- fieldName: e,
633
- record: r,
634
- mode: "display",
635
- refs: i,
636
- entities: a.entities,
637
- screens: a.screens,
638
- surface: "list",
639
- locale: o
640
- });
641
- };
642
- return /* @__PURE__ */ z(lt, { lines: s?.lines && s.lines.length > 0 ? s.lines.map((e) => ({
643
- label: E(e.label),
644
- at: c(e.at),
645
- by: c(e.by)
646
- })) : [{
647
- label: "Created",
648
- at: c("created_at"),
649
- by: c("created_by")
650
- }, {
651
- label: "Updated",
652
- at: c("updated_at"),
653
- by: c("updated_by")
654
- }] });
655
- }
656
- //#endregion
657
- //#region src/components/shared/RecordHeader.tsx
658
- function G({ icon: t, avatarName: n, title: r, recordId: a, description: o, highlights: s, mode: c, dirty: l = !1, showBack: u = !1, onBack: f, right: p, identityControls: m, showTitle: h = !0 }) {
659
- let g = ae(), _ = g.category === "phone" || g.width <= 520;
660
- return /* @__PURE__ */ B("div", {
661
- style: {
662
- display: "flex",
663
- alignItems: "flex-start",
664
- gap: 10,
665
- flexWrap: _ ? "wrap" : "nowrap",
666
- minWidth: 0
667
- },
668
- children: [
669
- h && u && /* @__PURE__ */ z("div", {
670
- style: {
671
- paddingTop: 4,
672
- flexShrink: 0
673
- },
674
- children: /* @__PURE__ */ z(i, {
675
- size: 26,
676
- icon: /* @__PURE__ */ z(e.back, { size: 14 }),
677
- title: "Back",
678
- onClick: f
679
- })
680
- }),
681
- h && (n || t) && /* @__PURE__ */ z("div", {
682
- style: {
683
- flexShrink: 0,
684
- paddingTop: 2
685
- },
686
- children: n ? /* @__PURE__ */ z(oe, {
687
- name: n,
688
- size: 32
689
- }) : /* @__PURE__ */ z("span", {
690
- style: {
691
- width: 32,
692
- height: 32,
693
- borderRadius: 8,
694
- background: "var(--accent-soft)",
695
- color: "var(--accent)",
696
- display: "flex",
697
- alignItems: "center",
698
- justifyContent: "center"
699
- },
700
- children: t
701
- })
702
- }),
703
- h && /* @__PURE__ */ B("div", {
704
- style: {
705
- flex: "1 1 0",
706
- minWidth: 0
707
- },
708
- children: [/* @__PURE__ */ B("div", {
709
- style: {
710
- display: "flex",
711
- alignItems: "center",
712
- gap: 8,
713
- flexWrap: "wrap"
714
- },
715
- children: [
716
- /* @__PURE__ */ z("h1", {
717
- style: {
718
- margin: 0,
719
- fontSize: "var(--page-title-size, var(--page-title-size-detail))",
720
- fontWeight: 600,
721
- letterSpacing: 0,
722
- lineHeight: "var(--page-title-line-height, var(--page-title-line-height-detail))",
723
- color: "var(--text)",
724
- minWidth: 0,
725
- overflow: "hidden",
726
- textOverflow: "ellipsis",
727
- whiteSpace: _ ? "normal" : "nowrap",
728
- overflowWrap: "anywhere",
729
- maxWidth: "100%"
730
- },
731
- children: r
732
- }),
733
- a && /* @__PURE__ */ z(se, { value: a }),
734
- o && /* @__PURE__ */ z(ce, {
735
- label: o,
736
- "data-testid": "detail-description-info"
737
- }),
738
- m,
739
- c === "edit" && l && /* @__PURE__ */ B("span", {
740
- style: {
741
- display: "inline-flex",
742
- alignItems: "center",
743
- gap: 5,
744
- fontSize: 11,
745
- color: "var(--warn)"
746
- },
747
- children: [/* @__PURE__ */ z("span", { style: {
748
- width: 6,
749
- height: 6,
750
- borderRadius: 999,
751
- background: "var(--warn)"
752
- } }), "Unsaved"]
753
- }),
754
- c === "create" && /* @__PURE__ */ z(d, {
755
- tone: "violet",
756
- size: "xs",
757
- dot: !0,
758
- children: "New record"
759
- })
760
- ]
761
- }), s && c === "display" && /* @__PURE__ */ z("div", {
762
- style: { marginTop: 8 },
763
- children: s
764
- })]
765
- }),
766
- p && /* @__PURE__ */ z("div", {
767
- role: "toolbar",
768
- "aria-label": "Page actions",
769
- style: {
770
- display: "flex",
771
- alignItems: "center",
772
- gap: 6,
773
- flex: _ ? "1 1 100%" : "0 1 auto",
774
- flexWrap: "wrap",
775
- justifyContent: _ ? "flex-start" : "flex-end",
776
- minWidth: 0
777
- },
778
- children: p
779
- })
780
- ]
781
- });
782
- }
783
- //#endregion
784
- //#region src/lib/children-validation.ts
785
- function dt(e, t, n) {
786
- let r = [];
787
- for (let [i, a] of e.fields) {
788
- if (!a.required || a.auto || n && a.primary || e.tenant_key && i === e.tenant_key || a.default !== void 0 && a.default !== null) continue;
789
- let o = t[i];
790
- (o == null || o === "") && r.push(i);
791
- }
792
- return r;
793
- }
794
- var ft = /^[^@\s]+@[^@\s]+\.[^@\s]+$/;
795
- function pt(e, t) {
796
- let n = [];
797
- for (let [r, i] of e.fields) {
798
- if (i.type !== "email") continue;
799
- let e = t[r];
800
- typeof e == "string" && e !== "" && !ft.test(e) && n.push(r);
801
- }
802
- return n;
803
- }
804
- function mt(e, t) {
805
- let n = /* @__PURE__ */ new Set();
806
- for (let r of Object.values(t.entities)) if (r.children) {
807
- for (let t of r.children) if (t.entity === e && t.foreign_key) {
808
- let e = Array.isArray(t.foreign_key) ? t.foreign_key : [t.foreign_key];
809
- for (let t of e) n.add(t);
810
- }
811
- }
812
- return n;
813
- }
814
- function ht(e, t) {
815
- if (!e || !t) return {};
816
- let n = {};
817
- for (let [r, i] of Object.entries(e)) {
818
- let e = t.entities[r];
819
- if (!e) continue;
820
- let a = mt(r, t), o = [];
821
- for (let [t, n] of e.fields) e.tenant_key && t === e.tenant_key || n.required && !n.auto && !n.primary && !a.has(t) && o.push(t);
822
- if (o.length !== 0) for (let e of i) {
823
- if (e._deleted) continue;
824
- let t = [];
825
- for (let n of o) {
826
- let r = e[n];
827
- (r == null || r === "") && t.push(n);
828
- }
829
- t.length > 0 && (n[r] || (n[r] = {}), n[r][e._key] = t);
830
- }
831
- }
832
- return n;
833
- }
834
- //#endregion
835
- //#region src/components/pages/SmartDetailPage.impl.tsx
836
- var gt = () => {};
837
- function _t(e, t) {
838
- return e.length === t.length && JSON.stringify(e) === JSON.stringify(t);
839
- }
840
- function vt(e, t) {
841
- if (e) {
842
- let n = C(re(e, t));
843
- if (n.replace(/^\|+|\|+$/g, "")) return n;
844
- }
845
- return t.id == null ? crypto.randomUUID() : _(t.id);
846
- }
847
- function yt({ screenCode: e }) {
848
- return /* @__PURE__ */ z(O, { children: /* @__PURE__ */ z(K, { screenCode: e }) });
849
- }
850
- function K({ screenCode: t }) {
851
- let { id: r } = Ye(), o = u(), [c, d] = Xe(), { data: _ } = ee(), b = m((e) => e.user), x = g(), S = ae(), w = _?.screens[t], T = w?.entity ? _?.entities[w.entity] : void 0, D = w?.entity, O = h(T, "create"), k = h(T, "update"), oe = h(T, "delete"), se = h(T, "restore"), ce = (() => {
852
- if (!T || !T.singleton || !T.prefilter) return;
853
- let e = ne(T);
854
- if (e.length !== 1) return;
855
- let t = T.prefilter[e[0]];
856
- if (t === "$caller.user_id") return b?.id;
857
- if (t === "$caller.tenant_id") return b?.tenant?.id;
858
- })(), A = ce !== void 0, j = A ? ce : r, M = !A && j === "new", N = L(() => {
859
- if (!j || M) return;
860
- if (!T) return j;
861
- let e = ne(T);
862
- if (e.length === 1) return { [e[0]]: j };
863
- let t = y(j, e.length);
864
- if (!t) return;
865
- let n = {};
866
- for (let r = 0; r < e.length; r++) n[e[r]] = t[r] ?? "";
867
- return n;
868
- }, [
869
- j,
870
- M,
871
- T
872
- ]), ge = L(() => {
873
- if (N) return typeof N == "string" ? N : C(N);
874
- }, [N]), P = ke(D, N), { data: be, isLoading: xe, error: Ce } = P, Ae = Fe((e) => e.degradedEntities), je = D ? ye(T?.realtime, Ae, D) : !1;
875
- pe(Ne(D, N), !M);
876
- let Le = ve(D ?? ""), Be = _e(D ?? ""), Ve = we(D ?? ""), He = Te(D ?? ""), Ue = Object.keys(T?.status_groups ?? {}).length > 0, Ke = be?.data, Ze = Ke?.$statuses, Qe = Ke?.$properties, tt = c.get("edit") === "true", [nt, rt] = R(M || tt), [V, at] = R({}), [H, st] = R({}), [U, lt] = R({}), [W, G] = R(void 0), [ft, mt] = R(!1), [yt, K] = R(void 0), [xt, St] = R({ show: !1 }), [wt, Tt] = R(!1), Et = M ? O : k, q = nt && Et, Dt = n();
877
- p(q && !M, Dt.enabled);
878
- let [Ot, kt] = R(() => {
879
- let e = parseInt(w?.sidebar_width || "380", 10);
880
- return isNaN(e) ? 380 : e;
881
- }), At = qe(null), J = qe(null), jt = F((e) => {
882
- e.preventDefault();
883
- let t = At.current;
884
- if (!t) return;
885
- let n = t.offsetWidth;
886
- J.current = {
887
- startX: e.clientX,
888
- startW: n
889
- };
890
- let r = (e) => {
891
- if (!J.current) return;
892
- let n = J.current.startX - e.clientX, r = Math.max(280, Math.min(800, J.current.startW + n));
893
- t.style.width = `${r}px`;
894
- }, i = () => {
895
- J.current && t && kt(parseInt(t.style.width, 10) || J.current.startW), J.current = null, document.removeEventListener("mousemove", r), document.removeEventListener("mouseup", i);
896
- };
897
- document.addEventListener("mousemove", r), document.addEventListener("mouseup", i);
898
- }, []), Y = be?.data, X = typeof Y?.$row_version == "string" ? Y.$row_version : void 0, Mt = Y?.$refs, Nt = qe(X);
899
- I(() => {
900
- if (!X) return;
901
- let e = Nt.current;
902
- Nt.current = X, e && e !== X && nt && mt(!0);
903
- }, [nt, X]);
904
- let Pt = !!T?.soft_delete, Ft = Pt && Y != null && Y[T.soft_delete] != null, Z = Je(), It = qe(null);
905
- fe({ scrollElementRef: It });
906
- let Lt = !M && Ce instanceof f && Ce.status === 404, Rt = qe(null);
907
- I(() => {
908
- if (!Lt) return;
909
- let e = le(Z);
910
- Rt.current !== e && (Rt.current = e, me.getState().kill(e));
911
- }, [Lt, Z]);
912
- let { openTab: zt, updateTabTitle: Bt, findTabByPathname: Vt } = Re();
913
- I(() => {
914
- if (!T || A || Dt.enabled) return;
915
- let e = Z.pathname, t = E(w?.display?.name) || E(T.display.name), n = w?.display?.icon || T.display.icon;
916
- Vt(e) || zt({
917
- pathname: e,
918
- search: "",
919
- title: M ? `New ${t}` : t,
920
- icon: n,
921
- closable: !0
922
- });
923
- }, [
924
- Z.pathname,
925
- w?.display?.name?.en,
926
- T?.display.name?.en,
927
- w?.display?.icon,
928
- T?.display.icon,
929
- M,
930
- A,
931
- Dt.enabled
932
- ]), I(() => {
933
- if (!Y || !T || A || Dt.enabled) return;
934
- let e = Vt(Z.pathname);
935
- if (e) {
936
- let t = E(w?.display?.name) || E(T.display.name), n = v(Y, T), r = n && !String(n).startsWith("/") ? String(n) : t;
937
- Bt(e.id, r);
938
- }
939
- }, [
940
- Y,
941
- T?.display.name?.en,
942
- T?.display.display_field,
943
- Z.pathname,
944
- A,
945
- Dt.enabled
946
- ]);
947
- let Ht = L(() => {
948
- if (!T || !Et) return /* @__PURE__ */ new Set();
949
- let e = /* @__PURE__ */ new Set();
950
- for (let [t, n] of T.fields) !n.auto && !n.primary && e.add(t);
951
- for (let [t] of T.files ?? []) e.add(t);
952
- return e;
953
- }, [T, Et]);
954
- I(() => {
955
- if (!(!tt || !Y || !T || !k)) {
956
- if (nt || rt(!0), Object.keys(V).length === 0) {
957
- let e = j ? ue(j) : null;
958
- e && De(Ee({
959
- entity: T,
960
- formData: e,
961
- record: void 0,
962
- isNew: !0
963
- })).forEach((e) => {
964
- x.registerDraft({
965
- fileId: e,
966
- discard: () => l(e)
967
- });
968
- });
969
- let t = {};
970
- Ht.forEach((n) => {
971
- let r = e ? e[n] : void 0;
972
- if (r !== void 0) {
973
- t[n] = r;
974
- return;
975
- }
976
- let i = he(T, Y, n);
977
- t[n] = Se(T, n) ? i ?? null : i ?? "";
978
- }), at(t);
979
- }
980
- if (T.children !== void 0 && T.children.length > 0 && W === void 0) {
981
- let e = Y.$children;
982
- if (e && Object.keys(e).length > 0) {
983
- let t = {};
984
- for (let [n, r] of Object.entries(e)) {
985
- let e = _?.entities[n];
986
- t[n] = r.map((t) => ({
987
- ...t,
988
- _key: vt(e, t)
989
- }));
990
- }
991
- G(t), K(e);
992
- } else G({}), K({});
993
- }
994
- d((e) => {
995
- let t = new URLSearchParams(e);
996
- return t.delete("edit"), t;
997
- }, { replace: !0 });
998
- }
999
- }, [
1000
- tt,
1001
- Y,
1002
- Ht,
1003
- k,
1004
- T,
1005
- W,
1006
- _
1007
- ]), I(() => {
1008
- !M || !O || !T?.children || T.children.length === 0 || W === void 0 && (G({}), K({}));
1009
- }, [
1010
- M,
1011
- O,
1012
- T?.children
1013
- ]);
1014
- let Ut = F(async () => {
1015
- if (await x.flushAllDrafts(), M) {
1016
- let e = w?.route?.replace("/:id", "") ?? "/";
1017
- o(e);
1018
- } else rt(!1), at({}), st({}), lt({}), G(void 0), K(void 0), Tt(!1);
1019
- }, [
1020
- x,
1021
- M,
1022
- w,
1023
- o
1024
- ]), Wt = F((e, t) => {
1025
- at((n) => ({
1026
- ...n,
1027
- [e]: t
1028
- }));
1029
- }, []), Q = L(() => {
1030
- if (!w?.route) return "/";
1031
- let e = w.route.split("/");
1032
- return e.pop(), e.join("/") || "/";
1033
- }, [w]), Gt = L(() => !_?.screens || !Q || Q === "/" ? !1 : Object.values(_.screens).some((e) => e.route === Q), [_, Q]), Kt = Oe({ fallback: F(() => {
1034
- if (!Gt) {
1035
- o("/");
1036
- return;
1037
- }
1038
- let e = Vt(Q)?.search ?? "";
1039
- o(e ? `${Q}?${e}` : Q);
1040
- }, [
1041
- Gt,
1042
- Q,
1043
- Vt,
1044
- o
1045
- ]) }), qt = !A && (Kt.hasOriginBack || Kt.allowFallbackBack && !!Gt), Jt = te(), Yt = L(() => {
1046
- if (!T) return {};
1047
- let e = {};
1048
- for (let t of dt(T, V, M)) Ht.has(t) && (e[t] = "Required");
1049
- for (let t of pt(T, V)) Ht.has(t) && (e[t] = "Invalid email address");
1050
- return e;
1051
- }, [
1052
- T,
1053
- V,
1054
- M,
1055
- Ht
1056
- ]), Xt = Object.keys(Yt).length > 0, Zt = F(() => {
1057
- if (!D || !T || M && !O || !M && !k || (Tt(!0), Xt)) return;
1058
- let e = {}, t = Ee({
1059
- entity: T,
1060
- formData: V,
1061
- record: Y,
1062
- isNew: M
1063
- }), n = De(t);
1064
- if (M) for (let [t, n] of Object.entries(V)) {
1065
- if (T.files?.has(t)) continue;
1066
- let r = Pe(T, t, n);
1067
- r !== "" && r != null && (e[t] = r);
1068
- }
1069
- else {
1070
- for (let [t, n] of Object.entries(V)) {
1071
- if (T.files?.has(t)) continue;
1072
- let r = Y ? he(T, Y, t) : void 0, i = Pe(T, t, n), a = Pe(T, t, r);
1073
- (i === "" ? null : i) !== (a === "" || a === void 0 ? null : a) && (e[t] = i);
1074
- }
1075
- X && (e.$row_version = X);
1076
- }
1077
- if (Object.keys(t).length > 0 && (e.$files = t), Object.keys(H).length > 0 && (e.$statuses = Object.entries(H).map(([e, t]) => ({
1078
- status_group_code: e,
1079
- status_code: t
1080
- }))), Object.keys(U).length > 0 && (e.$properties = Object.entries(U).map(([e, t]) => ({
1081
- property_code: e,
1082
- value: t
1083
- }))), W) {
1084
- let t = {};
1085
- for (let [e, n] of Object.entries(W)) {
1086
- let r = n.filter((e) => !e._deleted).map((e) => {
1087
- let { _key: t, _deleted: n, _dirty: r, ...i } = e;
1088
- return i;
1089
- }), i = yt?.[e] ?? [];
1090
- (M || !_t(r, i)) && (t[e] = r);
1091
- }
1092
- Object.keys(t).length > 0 && (e.$children = t);
1093
- }
1094
- if (!M && Object.keys(e).length === 0) {
1095
- rt(!1), st({}), lt({}), G(void 0), K(void 0), Tt(!1);
1096
- return;
1097
- }
1098
- let r = () => {
1099
- rt(!1), mt(!1), Tt(!1), st({}), lt({}), G(void 0), K(void 0);
1100
- };
1101
- M ? Le.mutate(e, { onSuccess: (e) => {
1102
- n.forEach((e) => x.markCommitted(e));
1103
- let t = e.data, i = C(T ? re(T, t) : {});
1104
- o(i ? `${Q}/${encodeURIComponent(i)}` : Q, { replace: !0 }), r();
1105
- } }) : N && Be.mutate({
1106
- pkValues: N,
1107
- data: e
1108
- }, {
1109
- onSuccess: () => {
1110
- n.forEach((e) => x.markCommitted(e)), r();
1111
- },
1112
- onError: (e) => {
1113
- e instanceof f && e.code === "STALE_OBJECT" && mt(!0);
1114
- }
1115
- });
1116
- }, [
1117
- x,
1118
- M,
1119
- O,
1120
- k,
1121
- D,
1122
- V,
1123
- Xt,
1124
- H,
1125
- U,
1126
- W,
1127
- yt,
1128
- Le,
1129
- Be,
1130
- T,
1131
- o,
1132
- Q,
1133
- Y,
1134
- X,
1135
- N
1136
- ]), Qt = F((e, t) => {
1137
- G((n) => ({
1138
- ...n ?? {},
1139
- [e]: t
1140
- }));
1141
- }, []), $t = F(() => {
1142
- !N || M || !oe || Ve.mutate(N, { onSuccess: () => {
1143
- me.getState().kill(le(Z)), o(Q, { replace: !0 });
1144
- } });
1145
- }, [
1146
- N,
1147
- M,
1148
- oe,
1149
- Ve,
1150
- o,
1151
- Q,
1152
- Z
1153
- ]), en = F(() => {
1154
- !N || M || !se || He.mutate(N);
1155
- }, [
1156
- N,
1157
- M,
1158
- se,
1159
- He
1160
- ]), tn = L(() => ht(W, _), [W, _]), nn = Object.keys(tn).length > 0;
1161
- if (!w || !T) return null;
1162
- if (!M && xe) return /* @__PURE__ */ z(ze, {});
1163
- if (!M && !Y || Lt) return /* @__PURE__ */ B("div", {
1164
- style: { padding: 24 },
1165
- children: [/* @__PURE__ */ B("div", {
1166
- style: {
1167
- display: "flex",
1168
- alignItems: "center",
1169
- gap: 8,
1170
- marginBottom: 8
1171
- },
1172
- children: [qt && /* @__PURE__ */ z(i, {
1173
- icon: /* @__PURE__ */ z(e.back, { size: 14 }),
1174
- onClick: Kt.goBack,
1175
- title: "Back"
1176
- }), /* @__PURE__ */ z("h1", {
1177
- style: {
1178
- margin: 0,
1179
- fontSize: 18,
1180
- fontWeight: 600,
1181
- color: "var(--text)"
1182
- },
1183
- children: "Not Found"
1184
- })]
1185
- }), /* @__PURE__ */ z("p", {
1186
- style: { color: "var(--text-3)" },
1187
- children: "Record not found."
1188
- })]
1189
- });
1190
- let rn = T.display, an = E(w.display?.name) || E(rn.name), on = v(Y, T), sn = M ? `New ${an}` : on ? String(on) : an, cn = Le.isPending || Be.isPending, ln = w.responsive?.[S.category]?.layout, un = ln?.tabs ?? (S.isPhone ? "sections" : void 0), dn = ln?.header_card === !0 ? Ie({
1191
- entity: T,
1192
- screen: w
1193
- }) : void 0, $ = {
1194
- schema: _,
1195
- entity: T,
1196
- entityCode: D,
1197
- recordId: ge ?? j ?? "",
1198
- record: q ? {
1199
- ...Y ?? {},
1200
- ...V
1201
- } : Y ?? {},
1202
- isNew: M,
1203
- mode: q ? "edit" : "display",
1204
- onFieldChange: q ? Wt : void 0,
1205
- refs: Mt,
1206
- objectProperties: (() => {
1207
- let e = Qe ?? [];
1208
- if (!q || Object.keys(U).length === 0) return e.length > 0 ? e : void 0;
1209
- let t = e.map((e) => U[e.property_code] === void 0 ? e : {
1210
- ...e,
1211
- value: U[e.property_code]
1212
- });
1213
- for (let [n, r] of Object.entries(U)) e.some((e) => e.property_code === n) || t.push({
1214
- property_code: n,
1215
- name: {},
1216
- type: "string",
1217
- value: r
1218
- });
1219
- return t;
1220
- })(),
1221
- onSetProperty: M || !k ? void 0 : q ? (e, t) => lt((n) => ({
1222
- ...n,
1223
- [e]: t
1224
- })) : void 0,
1225
- isPropertyPending: !1,
1226
- objectStatuses: (() => {
1227
- let e = Ze ?? [];
1228
- if (!q || Object.keys(H).length === 0) return e.length > 0 ? e : void 0;
1229
- let t = e.map((e) => H[e.group_code] === void 0 ? e : {
1230
- ...e,
1231
- status_code: H[e.group_code]
1232
- });
1233
- for (let [n, r] of Object.entries(H)) e.some((e) => e.group_code === n) || t.push({
1234
- group_code: n,
1235
- status_code: r,
1236
- status_name: {},
1237
- set_at: s()
1238
- });
1239
- return t;
1240
- })(),
1241
- onSetStatus: M || !k ? void 0 : q ? (e, t) => st((n) => ({
1242
- ...n,
1243
- [e]: t
1244
- })) : void 0,
1245
- isStatusPending: !1,
1246
- pendingChildren: q ? W : void 0,
1247
- onChildrenChange: q ? Qt : void 0,
1248
- childValidationErrors: q ? tn : void 0,
1249
- fieldErrors: q && wt ? Yt : void 0,
1250
- detailTabsPresentation: un,
1251
- relatedRecordsPresentation: ln?.related_records
1252
- }, fn = !!w.sidebar && w.sidebar.length > 0, pn = ln?.sidebar === "hidden", mn = fn && !pn && !S.isDesktop, hn = fn && !pn && S.isDesktop, gn = !M && Y ? /* @__PURE__ */ z(ct, {
1253
- screen: w,
1254
- entity: T,
1255
- entityCode: D,
1256
- record: Y,
1257
- refs: Mt,
1258
- objectStatuses: Ze,
1259
- schema: _,
1260
- locale: Jt
1261
- }) : void 0, _n = /* @__PURE__ */ z(Ct, {
1262
- title: sn,
1263
- recordId: j,
1264
- editing: q,
1265
- isNew: M,
1266
- isRecordDeleted: Ft,
1267
- dirty: nt,
1268
- isSaving: cn,
1269
- hasChildErrors: nn,
1270
- hasFieldErrors: wt && Xt,
1271
- canRestore: se,
1272
- entity: T,
1273
- screen: w,
1274
- globalActions: _?.actions,
1275
- entityCode: D,
1276
- record: Y,
1277
- id: j,
1278
- listRoute: Q,
1279
- listRouteExists: !!Gt,
1280
- highlights: gn,
1281
- showBack: qt,
1282
- onBack: Kt.goBack,
1283
- onCancelEdit: Ut,
1284
- onSave: Zt,
1285
- onRestore: en,
1286
- isRestoring: He.isPending,
1287
- refreshControl: {
1288
- refetch: P.refetch,
1289
- isFetching: P.isFetching,
1290
- isLoading: P.isLoading,
1291
- isLive: je
1292
- },
1293
- isRealtimeEntity: T?.realtime === !0,
1294
- canManageTemplates: de(_)
1295
- }), vn = Ft && /* @__PURE__ */ B("div", {
1296
- style: {
1297
- display: "flex",
1298
- alignItems: "center",
1299
- gap: 8,
1300
- padding: "10px 14px",
1301
- marginBottom: 12,
1302
- borderRadius: 8,
1303
- border: "1px solid var(--danger)",
1304
- background: "var(--danger-soft)",
1305
- color: "var(--danger)",
1306
- fontSize: 12.5
1307
- },
1308
- children: [/* @__PURE__ */ z(e.warning, { size: 14 }), /* @__PURE__ */ B("span", { children: ["This record was deleted on ", a(String(Y[T.soft_delete]))] })]
1309
- }), yn = ft && /* @__PURE__ */ B("div", {
1310
- style: {
1311
- display: "flex",
1312
- alignItems: "center",
1313
- gap: 8,
1314
- padding: "10px 14px",
1315
- marginBottom: 12,
1316
- borderRadius: 8,
1317
- border: "1px solid var(--warn)",
1318
- background: "var(--warn-soft)",
1319
- color: "var(--warn)",
1320
- fontSize: 12.5
1321
- },
1322
- children: [/* @__PURE__ */ z(e.warning, { size: 14 }), /* @__PURE__ */ z("span", { children: "This record changed on the server while you were viewing or editing it." })]
1323
- }), bn = q && wt && Xt && /* @__PURE__ */ z(ot, {
1324
- errors: Object.entries(Yt).map(([e, t]) => {
1325
- let n = T.fields.get(e);
1326
- return {
1327
- name: e,
1328
- label: n ? ie(n, e, _?.entities) : e,
1329
- message: t
1330
- };
1331
- }),
1332
- onJump: (e) => {
1333
- let t = document.getElementById(`${D}-${e}`);
1334
- t && (t.scrollIntoView({
1335
- block: "center",
1336
- behavior: "smooth"
1337
- }), t.focus?.());
1338
- }
1339
- }), xn = Ue && !M && !(w.items && w.items.length > 0) && /* @__PURE__ */ z("div", {
1340
- className: "mb-4",
1341
- children: /* @__PURE__ */ z(We, {
1342
- statusGroups: T.status_groups ?? {},
1343
- objectStatuses: $.objectStatuses,
1344
- onSetStatus: k && q ? (e, t) => st((n) => ({
1345
- ...n,
1346
- [e]: t
1347
- })) : gt,
1348
- isPending: !1,
1349
- mode: q ? "edit" : "display"
1350
- })
1351
- }), Sn = /* @__PURE__ */ B($e, { children: [
1352
- dn && (Y || M) && /* @__PURE__ */ z(bt, {
1353
- card: dn,
1354
- entity: T,
1355
- record: $.record,
1356
- objectStatuses: $.objectStatuses,
1357
- objectProperties: $.objectProperties
1358
- }),
1359
- w.items && w.items.length > 0 && (Y || M) && _ && /* @__PURE__ */ z(Ge, {
1360
- nodes: w.items,
1361
- ctx: $
1362
- }),
1363
- !M && j && D && T.associations && Object.keys(T.associations).length > 0 && _ && /* @__PURE__ */ z(et, {
1364
- entityCode: D,
1365
- recordId: ge ?? j ?? "",
1366
- associations: T.associations,
1367
- schema: _
1368
- }),
1369
- !M && j && D && /* @__PURE__ */ z(it, {
1370
- entityCode: D,
1371
- objectId: ge ?? j,
1372
- canGenerateOne: !!T?.documents?.generate_one,
1373
- canManageTemplates: de(_)
1374
- }),
1375
- !M && Y && _ && /* @__PURE__ */ z(ut, {
1376
- screen: w,
1377
- entity: T,
1378
- entityCode: D,
1379
- record: Y,
1380
- refs: Mt,
1381
- schema: _,
1382
- locale: Jt
1383
- })
1384
- ] }), Cn = /* @__PURE__ */ z(Me, {
1385
- open: xt.show,
1386
- onOpenChange: (e) => !e && St({ show: !1 }),
1387
- title: `Delete ${an}`,
1388
- description: xt.confirmation ? xt.confirmation : Pt ? `Are you sure you want to delete this ${an.toLowerCase()}? It can be restored later by an admin.` : `Are you sure you want to delete this ${an.toLowerCase()}? This action cannot be undone.`,
1389
- confirmLabel: "Delete",
1390
- onConfirm: $t,
1391
- destructive: !0
1392
- });
1393
- if (hn) return /* @__PURE__ */ B("div", {
1394
- style: {
1395
- height: "100%",
1396
- display: "flex",
1397
- overflow: "hidden",
1398
- background: "var(--background)"
1399
- },
1400
- children: [
1401
- /* @__PURE__ */ B("div", {
1402
- style: {
1403
- flex: 1,
1404
- minWidth: 0,
1405
- display: "flex",
1406
- flexDirection: "column",
1407
- height: "100%"
1408
- },
1409
- children: [/* @__PURE__ */ B("div", {
1410
- style: {
1411
- flexShrink: 0,
1412
- padding: "14px 20px 8px"
1413
- },
1414
- children: [
1415
- _n,
1416
- yn,
1417
- vn,
1418
- bn,
1419
- xn
1420
- ]
1421
- }), /* @__PURE__ */ z("div", {
1422
- ref: It,
1423
- style: {
1424
- flex: 1,
1425
- minHeight: 0,
1426
- overflowY: "auto",
1427
- padding: "4px 20px 24px",
1428
- display: "flex",
1429
- flexDirection: "column",
1430
- gap: 16
1431
- },
1432
- children: Sn
1433
- })]
1434
- }),
1435
- /* @__PURE__ */ z("div", {
1436
- className: "detail-resize-handle",
1437
- onMouseDown: jt,
1438
- title: "Drag to resize",
1439
- children: /* @__PURE__ */ z("div", { style: {
1440
- position: "absolute",
1441
- top: 0,
1442
- bottom: 0,
1443
- left: "50%",
1444
- transform: "translateX(-50%)",
1445
- width: 1,
1446
- background: "var(--border)"
1447
- } })
1448
- }),
1449
- /* @__PURE__ */ z("div", {
1450
- ref: At,
1451
- style: {
1452
- flexShrink: 0,
1453
- height: "100%",
1454
- width: `${Ot}px`
1455
- },
1456
- children: (Y || M) && _ && /* @__PURE__ */ z(Ge, {
1457
- nodes: w.sidebar,
1458
- ctx: $
1459
- })
1460
- }),
1461
- Cn
1462
- ]
1463
- });
1464
- let wn = S.isPhone ? 12 : 24;
1465
- return /* @__PURE__ */ B("div", {
1466
- style: {
1467
- height: "100%",
1468
- display: "flex",
1469
- flexDirection: "column",
1470
- overflow: "hidden",
1471
- background: "var(--background)"
1472
- },
1473
- children: [
1474
- /* @__PURE__ */ B("div", {
1475
- style: {
1476
- flexShrink: 0,
1477
- padding: S.isPhone ? "14px 12px 8px" : "24px 24px 8px"
1478
- },
1479
- children: [
1480
- _n,
1481
- yn,
1482
- vn,
1483
- bn,
1484
- xn
1485
- ]
1486
- }),
1487
- /* @__PURE__ */ B("div", {
1488
- ref: It,
1489
- style: {
1490
- flex: 1,
1491
- minHeight: 0,
1492
- overflowY: "auto",
1493
- padding: `4px ${wn}px calc(24px + var(--safe-area-bottom, 0px))`,
1494
- display: "flex",
1495
- flexDirection: "column",
1496
- gap: 16,
1497
- minWidth: 0,
1498
- WebkitOverflowScrolling: "touch"
1499
- },
1500
- children: [Sn, mn && (Y || M) && _ && /* @__PURE__ */ z("div", {
1501
- "data-testid": "detail-sidebar-inline",
1502
- style: {
1503
- display: "flex",
1504
- flexDirection: "column",
1505
- gap: 16,
1506
- minWidth: 0
1507
- },
1508
- children: /* @__PURE__ */ z(Ge, {
1509
- nodes: w.sidebar,
1510
- ctx: $
1511
- })
1512
- })]
1513
- }),
1514
- Cn
1515
- ]
1516
- });
1517
- }
1518
- function bt({ card: e, entity: t, record: n, objectStatuses: r, objectProperties: i }) {
1519
- let a = (e) => {
1520
- let a = xt(t, e, n, r, i);
1521
- return a != null && _(a) !== "";
1522
- }, o = (e) => _(xt(t, e, n, r, i)) || /* @__PURE__ */ z("span", {
1523
- style: { color: "var(--text-3)" },
1524
- children: "-"
1525
- }), s = _(e.titleUsesDisplay ? v(n, t) : e.titleField ? xt(t, e.titleField, n, r, i) : void 0) || E(t.display?.name) || "Record", c = e.badgeFields.filter((t) => !e.hideEmptyFields || a(t)), l = e.bodyFields.filter((t) => !e.hideEmptyFields || a(t)), u = e.metaFields.filter((t) => !e.hideEmptyFields || a(t));
1526
- return /* @__PURE__ */ B("section", {
1527
- "data-testid": "detail-header-card",
1528
- style: {
1529
- width: "100%",
1530
- minWidth: 0,
1531
- border: "1px solid var(--border)",
1532
- borderRadius: 8,
1533
- background: "var(--surface)",
1534
- boxShadow: "var(--shadow-xs)",
1535
- padding: 14,
1536
- boxSizing: "border-box"
1537
- },
1538
- children: [
1539
- /* @__PURE__ */ B("div", {
1540
- style: { minWidth: 0 },
1541
- children: [/* @__PURE__ */ z("div", {
1542
- style: {
1543
- fontSize: 15,
1544
- lineHeight: 1.25,
1545
- fontWeight: 700,
1546
- color: "var(--text)",
1547
- overflowWrap: "anywhere"
1548
- },
1549
- children: s
1550
- }), e.subtitleField && /* @__PURE__ */ z("div", {
1551
- style: {
1552
- marginTop: 4,
1553
- fontSize: 12.5,
1554
- lineHeight: 1.35,
1555
- color: "var(--text-3)",
1556
- overflowWrap: "anywhere"
1557
- },
1558
- children: o(e.subtitleField)
1559
- })]
1560
- }),
1561
- c.length > 0 && /* @__PURE__ */ z("div", {
1562
- style: {
1563
- display: "flex",
1564
- flexWrap: "wrap",
1565
- gap: 6,
1566
- marginTop: 10
1567
- },
1568
- children: c.map((e) => /* @__PURE__ */ z("span", {
1569
- style: {
1570
- minWidth: 0,
1571
- maxWidth: "100%",
1572
- borderRadius: 999,
1573
- background: "var(--surface-2)",
1574
- color: "var(--text-2)",
1575
- padding: "2px 8px",
1576
- fontSize: 12,
1577
- lineHeight: 1.4,
1578
- overflowWrap: "anywhere"
1579
- },
1580
- children: o(e)
1581
- }, e))
1582
- }),
1583
- l.length > 0 && /* @__PURE__ */ z("dl", {
1584
- style: {
1585
- display: "grid",
1586
- gridTemplateColumns: "minmax(84px, max-content) minmax(0, 1fr)",
1587
- gap: "6px 10px",
1588
- margin: "12px 0 0",
1589
- fontSize: 12.5,
1590
- lineHeight: 1.35
1591
- },
1592
- children: l.map((e) => /* @__PURE__ */ B("div", {
1593
- style: { display: "contents" },
1594
- children: [/* @__PURE__ */ z("dt", {
1595
- style: { color: "var(--text-3)" },
1596
- children: St(t, e)
1597
- }), /* @__PURE__ */ z("dd", {
1598
- style: {
1599
- margin: 0,
1600
- color: "var(--text-2)",
1601
- minWidth: 0,
1602
- overflowWrap: "anywhere"
1603
- },
1604
- children: o(e)
1605
- })]
1606
- }, e))
1607
- }),
1608
- u.length > 0 && /* @__PURE__ */ z("div", {
1609
- style: {
1610
- display: "flex",
1611
- flexWrap: "wrap",
1612
- gap: 10,
1613
- marginTop: 10,
1614
- color: "var(--text-3)",
1615
- fontSize: 11.5
1616
- },
1617
- children: u.map((e) => /* @__PURE__ */ B("span", {
1618
- style: {
1619
- minWidth: 0,
1620
- overflowWrap: "anywhere"
1621
- },
1622
- children: [
1623
- St(t, e),
1624
- ": ",
1625
- o(e)
1626
- ]
1627
- }, e))
1628
- })
1629
- ]
1630
- });
1631
- }
1632
- function xt(e, t, n, r, i) {
1633
- if (t.startsWith("$status.")) {
1634
- let e = t.slice(8), n = r?.find((t) => t.group_code === e);
1635
- return E(n?.status_name) || n?.status_code;
1636
- }
1637
- if (t.startsWith("$property.")) {
1638
- let e = t.slice(10);
1639
- return i?.find((t) => t.property_code === e)?.value;
1640
- }
1641
- return he(e, n, t);
1642
- }
1643
- function St(e, t) {
1644
- if (t.startsWith("$status.")) return t.slice(8);
1645
- if (t.startsWith("$property.")) return t.slice(10);
1646
- let n = e.fields.get(t);
1647
- return n ? ie(n, t) : t;
1648
- }
1649
- function Ct({ title: n, recordId: r, editing: i, isNew: a, isRecordDeleted: s, dirty: l, isSaving: d, hasChildErrors: f, hasFieldErrors: p, canRestore: m, entity: h, screen: g, globalActions: _, entityCode: v, record: y, id: b, listRoute: ee, listRouteExists: ne, highlights: S, showBack: C, onBack: re, onCancelEdit: ie, onSave: D, onRestore: O, isRestoring: k, refreshControl: ae, isRealtimeEntity: oe, canManageTemplates: se }) {
1650
- let { run: ce } = x(), j = A("detail"), ue = Ae(), de = u(), fe = te(), pe = Be(g?.action_layout, h?.action_layout, h?.actions, _, "detail_toolbar"), he = be(Be(g?.action_layout, h?.action_layout, h?.actions, _, "detail"), h?.actions, _, y ?? {}, []), _e = be(pe, h?.actions, _, y ?? {}, []), ve = L(() => {
1651
- if (!h) return;
1652
- let e = b ? [b] : [];
1653
- return {
1654
- entity: h,
1655
- entityCode: v ?? "",
1656
- screen: g,
1657
- screenRoute: g?.route ?? "",
1658
- selectedRows: y ? [y] : [],
1659
- selectedIds: e,
1660
- locale: fe,
1661
- tabNavigate: (e, t) => ue(e, {
1662
- title: t?.title,
1663
- icon: t?.icon,
1664
- search: t?.search
1665
- }),
1666
- runActionApi: (e, t) => T(e, t)
1667
- };
1668
- }, [
1669
- h,
1670
- v,
1671
- g,
1672
- b,
1673
- y,
1674
- fe,
1675
- ue
1676
- ]), ye = (e, t) => {
1677
- let n = ge(e, t, { row: y ?? void 0 });
1678
- if (n === null) return;
1679
- let r = b ? [b] : [], i = e === "__delete" && ne ? ee : null;
1680
- return ce({
1681
- action: t,
1682
- title: E(t.display?.name) || e,
1683
- row: y ?? void 0,
1684
- execute: (e) => T(n, w(e, r)),
1685
- onSuccess: i ? () => {
1686
- me.getState().kill(le(location)), de(i, { replace: !0 });
1687
- } : void 0
1688
- });
1689
- }, P = j.isVisible("show_actions") && !a && b && he.length > 0 ? /* @__PURE__ */ z(xe, {
1690
- layout: he,
1691
- row: y,
1692
- onRun: ye,
1693
- kind: "detail",
1694
- entityActions: h?.actions,
1695
- globalActions: _,
1696
- reservedRightWidth: 0,
1697
- widgetContext: ve,
1698
- constrain: !1
1699
- }) : null, Se = !a && b ? /* @__PURE__ */ z(M, {
1700
- liveObject: ae,
1701
- realtime: oe
1702
- }) : null, Ce = j.isVisible("show_actions") && !a && b && _e.length > 0 ? /* @__PURE__ */ B("div", {
1703
- style: {
1704
- display: "flex",
1705
- justifyContent: "flex-end",
1706
- alignItems: "center",
1707
- gap: 8,
1708
- marginTop: 10
1709
- },
1710
- children: [P ? null : Se, /* @__PURE__ */ z(xe, {
1711
- layout: _e,
1712
- row: y,
1713
- onRun: ye,
1714
- kind: "detail",
1715
- entityActions: h?.actions,
1716
- globalActions: _,
1717
- reservedRightWidth: 0,
1718
- widgetContext: ve,
1719
- ariaLabel: P ? "Detail toolbar actions" : "Page actions"
1720
- })]
1721
- }) : null, we = j.isVisible("show_actions") && !a && b && v ? /* @__PURE__ */ z(N, {
1722
- entityCode: v,
1723
- scope: "detail",
1724
- objectIds: [b],
1725
- capability: h?.documents,
1726
- canManageTemplates: se
1727
- }) : null, Te = s ? m ? /* @__PURE__ */ z(o, {
1728
- kind: "primary",
1729
- icon: z(k ? c : e.refresh, { size: 13 }),
1730
- onClick: O,
1731
- disabled: k,
1732
- children: k ? "Restoring…" : "Restore"
1733
- }) : null : i ? /* @__PURE__ */ B($e, { children: [/* @__PURE__ */ z(o, {
1734
- icon: /* @__PURE__ */ z(e.x, { size: 13 }),
1735
- onClick: ie,
1736
- disabled: d,
1737
- children: "Cancel"
1738
- }), /* @__PURE__ */ z(o, {
1739
- kind: "primary",
1740
- icon: z(d ? c : e.save, { size: 13 }),
1741
- onClick: D,
1742
- disabled: d || f || p,
1743
- title: f ? "Fix errors in child rows" : p ? "Fix the highlighted fields" : void 0,
1744
- children: d ? "Saving…" : "Save"
1745
- })] }) : !a && b ? P ? /* @__PURE__ */ B("span", {
1746
- style: { display: "contents" },
1747
- children: [we, P]
1748
- }) : we : null;
1749
- return /* @__PURE__ */ B($e, { children: [/* @__PURE__ */ z(G, {
1750
- icon: h?.display.icon ? /* @__PURE__ */ z(t, {
1751
- name: h.display.icon,
1752
- size: 16
1753
- }) : void 0,
1754
- title: n,
1755
- description: E(g?.display?.description) || E(h?.display?.description),
1756
- recordId: r,
1757
- highlights: S,
1758
- identityControls: !s && !i && !a ? Se : null,
1759
- mode: a ? "create" : i ? "edit" : "display",
1760
- dirty: l,
1761
- showBack: C,
1762
- onBack: re,
1763
- right: Te,
1764
- showTitle: j.isVisible("show_title")
1765
- }), Ce] });
1766
- }
1767
- //#endregion
1768
- export { yt as SmartDetailPage };