@declarion/react 0.57.0 → 0.59.2

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