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