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