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