@declarion/react 0.48.2 → 0.50.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/Check-DAfMbQIw.js +38 -0
- package/dist-lib/{DraggableChildrenTable-p2ZSdwzj.js → DraggableChildrenTable-Dar8C-Z9.js} +31 -31
- package/dist-lib/DynamicIcon-DW5krHuX.js +280 -0
- package/dist-lib/{Grid-CjLFAKMZ.js → Grid-BkHtfsty.js} +2 -2
- package/dist-lib/{LayoutRenderer-DCscqXsv.js → LayoutRenderer-Cic7IAop.js} +601 -598
- package/dist-lib/ListCardsBody-Dko91bLv.js +287 -0
- package/dist-lib/{MarkdownRenderer-Sb7zcvj0.js → MarkdownRenderer-CJrVG5HZ.js} +1 -1
- package/dist-lib/RefreshControl-BS8WWL8i.js +430 -0
- package/dist-lib/{SmartDetailPage.impl-BAW-Tx_H.js → SmartDetailPage.impl-DxRDo0p2.js} +521 -516
- package/dist-lib/SmartListPage.impl-CNdq5Vts.js +2849 -0
- package/dist-lib/{SmartRecordListPage.impl-DtSSlGrI.js → SmartRecordListPage.impl-3ct7f4rT.js} +244 -241
- package/dist-lib/SortHeaderMenu-NgjkW8QZ.js +106 -0
- package/dist-lib/action-dispatch-hVrm3Hrg.js +1984 -0
- package/dist-lib/api/batch.d.ts +5 -2
- package/dist-lib/api/data.d.ts +35 -4
- package/dist-lib/api/entities.d.ts +3 -3
- package/dist-lib/cardProjection-BR-fXPvJ.js +757 -0
- package/dist-lib/components/{shared → actions}/ObjectActionBar.d.ts +1 -1
- package/dist-lib/components/{shared → actions}/ResponsiveActionBar.d.ts +1 -1
- package/dist-lib/components/fields/cells/factories/date.d.ts +2 -0
- package/dist-lib/components/file-widgets/upload.d.ts +6 -1
- package/dist-lib/components/layout/Layout.d.ts +1 -1
- package/dist-lib/components/layout/TopBar.d.ts +1 -1
- package/dist-lib/components/pages/SmartListPage.d.ts +2 -12
- package/dist-lib/components/pages/SmartListPage.impl.d.ts +4 -0
- package/dist-lib/components/pages/list/ListCardRow.d.ts +40 -0
- package/dist-lib/components/pages/list/ListCardsBody.d.ts +34 -0
- package/dist-lib/components/pages/list/ListFloatbar.d.ts +1 -1
- package/dist-lib/components/pages/list/ListFooter.d.ts +26 -0
- package/dist-lib/components/pages/list/ListHeader.d.ts +1 -1
- package/dist-lib/components/pages/list/ListNoRows.d.ts +32 -0
- package/dist-lib/components/pages/list/ListTable.d.ts +34 -0
- package/dist-lib/components/pages/list/ListTableRow.d.ts +18 -0
- package/dist-lib/components/pages/list/ListToolbar.d.ts +43 -0
- package/dist-lib/components/pages/list/SortHeaderMenu.d.ts +14 -0
- package/dist-lib/components/pages/list/page-size.d.ts +3 -0
- package/dist-lib/components/pages/list/sortable-header.d.ts +2 -0
- package/dist-lib/components/pages/list/useListColumnLayout.d.ts +37 -0
- package/dist-lib/components/pages/list/useListQuery.d.ts +66 -0
- package/dist-lib/components/pages/list/useListRowInteraction.d.ts +61 -0
- package/dist-lib/components/pages/list/useListSelection.d.ts +31 -0
- package/dist-lib/components/pages/list/useListSort.d.ts +45 -0
- package/dist-lib/components/pages/list/useListViews.d.ts +46 -0
- package/dist-lib/components/pages/list/useRowMenu.d.ts +1 -1
- package/dist-lib/components/primitives/Icons.d.ts +5 -0
- package/dist-lib/components/shared/RefreshControl.d.ts +17 -4
- package/dist-lib/field-classification-Bm0mgbwA.js +1134 -0
- package/dist-lib/format-count-BfRGwx2v.js +1551 -0
- package/dist-lib/hooks/useBrandingChrome.d.ts +17 -1
- package/dist-lib/hooks/useText.d.ts +3 -0
- package/dist-lib/hooks/useViews.d.ts +1 -1
- package/dist-lib/icons.js +1 -1
- package/dist-lib/index.d.ts +17 -15
- package/dist-lib/index.js +1784 -6288
- package/dist-lib/lib/messages.d.ts +7 -1
- package/dist-lib/lib/rowClickGesture.d.ts +12 -0
- package/dist-lib/lib/timestamp.d.ts +8 -3
- package/dist-lib/peekDraftStore-bb4WroTA.js +194 -0
- package/dist-lib/record-documents-key-8fdm7C10.js +27 -0
- package/dist-lib/registry-CgeGoWpW.js +1768 -0
- package/dist-lib/testing.d.ts +17 -2
- package/dist-lib/testing.js +72 -58
- package/dist-lib/types/api.d.ts +54 -12
- package/dist-lib/types/schema.d.ts +22 -6
- package/dist-lib/{useCurrentScreen-BshVTPVq.js → useCurrentScreen-D3XH5ptA.js} +1127 -1070
- package/dist-lib/useListQuery-CfuINl-0.js +87 -0
- package/dist-lib/useProperties-DNocaxBX.js +81 -0
- package/dist-lib/{useProperties-DrHFr0A1.js → useTabSearchMirror-d0BAUIcQ.js} +116 -194
- package/dist-lib/{value-B1O6QikE.js → value-D71J0sJq.js} +69 -69
- package/package.json +1 -1
- package/dist-lib/DynamicIcon-Dc2j-rg_.js +0 -275
- package/dist-lib/RefreshControl-Cnl9nE0x.js +0 -945
- package/dist-lib/registry-CCxnZW2b.js +0 -5281
- /package/dist-lib/components/{shared → actions}/ActionButton.d.ts +0 -0
- /package/dist-lib/components/{shared → actions}/ActionDialog.d.ts +0 -0
- /package/dist-lib/components/{shared → actions}/ActionResultDialog.d.ts +0 -0
- /package/dist-lib/components/{shared → actions}/ActionRunner.d.ts +0 -0
- /package/dist-lib/components/{mass-edit → actions}/PropertyGridEditor.d.ts +0 -0
- /package/dist-lib/components/{shared → actions}/RowActionsKebab.d.ts +0 -0
- /package/dist-lib/components/{shared → chrome}/AssociationTabs.d.ts +0 -0
- /package/dist-lib/components/{shared → chrome}/AuditMetaStrip.d.ts +0 -0
- /package/dist-lib/components/{shared → chrome}/Breadcrumbs.d.ts +0 -0
- /package/dist-lib/components/{shared → chrome}/HighlightsStrip.d.ts +0 -0
- /package/dist-lib/components/{shared → chrome}/PageHeader.d.ts +0 -0
- /package/dist-lib/components/{shared → chrome}/RecordHeader.d.ts +0 -0
- /package/dist-lib/components/{shell → layout}/CommandPalette.d.ts +0 -0
- /package/dist-lib/components/{columns → list}/ColumnPicker.d.ts +0 -0
- /package/dist-lib/components/{views → list}/ViewSwitcher.d.ts +0 -0
|
@@ -0,0 +1,2849 @@
|
|
|
1
|
+
import { s as e } from "./DynamicIcon-DW5krHuX.js";
|
|
2
|
+
import { $n as t, A as n, An as r, At as i, Cn as a, Ct as o, Dn as s, En as c, F as l, M as u, N as d, Pn as f, S as p, Sn as m, Tn as h, Zn as g, _, _n as v, bn as y, bt as b, cr as x, dr as S, er as C, fr as w, gt as T, h as E, i as D, jt as ee, lr as te, m as O, mt as k, pt as ne, q as re, rr as ie, rt as A, tt as ae, un as j, ur as oe, v as M, vn as N, w as se, wn as ce, x as P, xt as F, y as le, zn as I } from "./useCurrentScreen-D3XH5ptA.js";
|
|
3
|
+
import { a as ue, i as de, m as fe, s as pe, t as me } from "./RefreshControl-BS8WWL8i.js";
|
|
4
|
+
import { t as he } from "./Check-DAfMbQIw.js";
|
|
5
|
+
import { E as ge, F as _e, L as ve, O as ye, c as be, f as xe, j as Se, l as Ce, m as we, n as Te, p as Ee, w as De } from "./field-classification-Bm0mgbwA.js";
|
|
6
|
+
import { a as Oe, c as ke, f as Ae, h as je, l as Me, m as Ne, n as Pe, o as Fe, p as Ie, r as Le, t as Re } from "./action-dispatch-hVrm3Hrg.js";
|
|
7
|
+
import { a as ze, c as Be, f as Ve, i as He, l as Ue, m as We, n as Ge, o as Ke, p as qe, r as Je, s as Ye, t as Xe, u as L } from "./cardProjection-BR-fXPvJ.js";
|
|
8
|
+
import { l as Ze, m as Qe, n as $e, t as et } from "./useTabSearchMirror-d0BAUIcQ.js";
|
|
9
|
+
import { a as tt, c as nt, d as rt, f as it, l as at, o as ot, p as st, s as ct, t as R, u as lt } from "./format-count-BfRGwx2v.js";
|
|
10
|
+
import { a as ut, c as dt, i as ft, n as z, o as B, s as pt, t as mt } from "./peekDraftStore-bb4WroTA.js";
|
|
11
|
+
import { t as ht } from "./useListQuery-CfuINl-0.js";
|
|
12
|
+
import { Suspense as gt, createElement as V, lazy as _t, memo as H, useCallback as U, useEffect as W, useMemo as G, useRef as K, useState as q } from "react";
|
|
13
|
+
import { useSearchParams as vt } from "react-router";
|
|
14
|
+
import { useQueries as yt, useQueryClient as bt } from "@tanstack/react-query";
|
|
15
|
+
import { Fragment as J, jsx as Y, jsxs as X } from "react/jsx-runtime";
|
|
16
|
+
import { flexRender as xt, getCoreRowModel as St, useReactTable as Ct } from "@tanstack/react-table";
|
|
17
|
+
import { useVirtualizer as wt } from "@tanstack/react-virtual";
|
|
18
|
+
var Tt = [
|
|
19
|
+
25,
|
|
20
|
+
50,
|
|
21
|
+
100,
|
|
22
|
+
200,
|
|
23
|
+
500,
|
|
24
|
+
1e3
|
|
25
|
+
];
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/components/pages/list/filter-meta.ts
|
|
28
|
+
function Et(e, t, n) {
|
|
29
|
+
if (!e || !t) return [];
|
|
30
|
+
let r = e.filters ?? t.fields.names(), i = e.filter_operators ?? {}, a = [];
|
|
31
|
+
for (let o of r) {
|
|
32
|
+
let r = i[o];
|
|
33
|
+
if (!r || r.length === 0) continue;
|
|
34
|
+
if (o.startsWith("$status.")) {
|
|
35
|
+
let e = o.slice(8), n = t.status_groups?.[e];
|
|
36
|
+
if (!n) continue;
|
|
37
|
+
a.push({
|
|
38
|
+
code: o,
|
|
39
|
+
label: s(n.name) || e,
|
|
40
|
+
type: "status",
|
|
41
|
+
operators: r,
|
|
42
|
+
options: n.statuses.map((e) => ({
|
|
43
|
+
value: e.code,
|
|
44
|
+
label: s(e.name) || e.code,
|
|
45
|
+
color: e.color
|
|
46
|
+
}))
|
|
47
|
+
});
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (o.startsWith("$property.")) {
|
|
51
|
+
let e = o.slice(10), n = t.properties?.[e];
|
|
52
|
+
if (!n) continue;
|
|
53
|
+
a.push({
|
|
54
|
+
code: o,
|
|
55
|
+
label: s(n.name) || e,
|
|
56
|
+
type: "property",
|
|
57
|
+
operators: r
|
|
58
|
+
});
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
let c = t.fields.get(o);
|
|
62
|
+
if (!c) continue;
|
|
63
|
+
let l = ce(c, o, n), u = c.values?.map((e) => ({
|
|
64
|
+
value: e.code,
|
|
65
|
+
label: s(e.name) || e.code,
|
|
66
|
+
color: e.color
|
|
67
|
+
})), d = y(c.filter_special_values, e?.filter_special_values?.[o]);
|
|
68
|
+
a.push({
|
|
69
|
+
code: o,
|
|
70
|
+
label: l,
|
|
71
|
+
type: c.type,
|
|
72
|
+
operators: r,
|
|
73
|
+
options: u,
|
|
74
|
+
ref: c.ref,
|
|
75
|
+
specialValues: d.length > 0 ? d : void 0
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return a;
|
|
79
|
+
}
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/components/pages/list/useListSort.ts
|
|
82
|
+
function Dt({ searchParams: e, setSearchParams: t, screenSortDefault: n, commitScreenTabSearch: r }) {
|
|
83
|
+
let i = e.get("sort") ?? n ?? "", a = G(() => Ye(i), [i]), o = G(() => {
|
|
84
|
+
let e = /* @__PURE__ */ new Map();
|
|
85
|
+
for (let t of a) t.nulls && e.set(t.field, t.nulls);
|
|
86
|
+
return e;
|
|
87
|
+
}, [a]), s = G(() => L(i), [i]), c = G(() => a.map((e) => ({
|
|
88
|
+
id: e.field,
|
|
89
|
+
desc: e.dir === "desc"
|
|
90
|
+
})), [a]), l = U((n) => {
|
|
91
|
+
let i = n.slice(0, 5), a = new URLSearchParams(e);
|
|
92
|
+
i.length === 0 ? a.delete("sort") : a.set("sort", Ue(i)), a.set("page", "1"), r(a.toString()), t(a);
|
|
93
|
+
}, [
|
|
94
|
+
e,
|
|
95
|
+
r,
|
|
96
|
+
t
|
|
97
|
+
]);
|
|
98
|
+
return {
|
|
99
|
+
cols: a,
|
|
100
|
+
nullsByField: o,
|
|
101
|
+
forRequest: s,
|
|
102
|
+
tableSorting: c,
|
|
103
|
+
write: l,
|
|
104
|
+
applyColumn: U((e, t, n) => l([{
|
|
105
|
+
field: e,
|
|
106
|
+
dir: t,
|
|
107
|
+
...n ? { nulls: n } : {}
|
|
108
|
+
}]), [l]),
|
|
109
|
+
shiftClickColumn: U((e) => l(Ke(a, e)), [a, l]),
|
|
110
|
+
appendColumn: U((e, t, n) => l(ze(a, {
|
|
111
|
+
field: e,
|
|
112
|
+
dir: t,
|
|
113
|
+
...n ? { nulls: n } : {}
|
|
114
|
+
})), [a, l]),
|
|
115
|
+
clearColumn: U((e) => l(Be(a, e)), [a, l]),
|
|
116
|
+
clearAll: U(() => l([]), [l])
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region src/components/pages/list/useListSelection.ts
|
|
121
|
+
var Ot = {};
|
|
122
|
+
function kt(e, t) {
|
|
123
|
+
return r(e, a(e, t));
|
|
124
|
+
}
|
|
125
|
+
function At(e, t, n) {
|
|
126
|
+
if (!e || n.length === 0) return [];
|
|
127
|
+
let r = new Set(n);
|
|
128
|
+
return t.filter((t) => r.has(kt(e, t))).map((t) => a(e, t));
|
|
129
|
+
}
|
|
130
|
+
function jt(e, t, n) {
|
|
131
|
+
let [r, i] = rt("selection", Ot, { scope: "path" }), a = G(() => e?.fields.names().find((t) => e.fields.get(t)?.primary) ?? "id", [e]), o = U((t) => e ? kt(e, t) : I(t[a]), [e, a]), s = G(() => Object.keys(r).filter((e) => r[e]), [r]), c = G(() => At(e, t, s), [
|
|
132
|
+
e,
|
|
133
|
+
t,
|
|
134
|
+
s
|
|
135
|
+
]), l = G(() => {
|
|
136
|
+
if (s.length === 0) return [];
|
|
137
|
+
let e = /* @__PURE__ */ new Map();
|
|
138
|
+
for (let n of t) e.set(o(n), n);
|
|
139
|
+
return s.map((t) => e.get(t)).filter((e) => e !== void 0);
|
|
140
|
+
}, [
|
|
141
|
+
s,
|
|
142
|
+
t,
|
|
143
|
+
o
|
|
144
|
+
]);
|
|
145
|
+
return W(() => {
|
|
146
|
+
n || i((e) => {
|
|
147
|
+
let n = Object.keys(e);
|
|
148
|
+
if (n.length === 0) return e;
|
|
149
|
+
let r = new Set(t.map((e) => o(e))), i = {}, a = !1;
|
|
150
|
+
for (let t of n) r.has(t) ? i[t] = e[t] : a = !0;
|
|
151
|
+
return a ? i : e;
|
|
152
|
+
});
|
|
153
|
+
}, [
|
|
154
|
+
t,
|
|
155
|
+
n,
|
|
156
|
+
o,
|
|
157
|
+
i
|
|
158
|
+
]), {
|
|
159
|
+
state: r,
|
|
160
|
+
setState: i,
|
|
161
|
+
ids: s,
|
|
162
|
+
pkValues: c,
|
|
163
|
+
rows: l,
|
|
164
|
+
keyOf: o
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region src/components/pages/list/useListColumnLayout.ts
|
|
169
|
+
function Mt({ screenCode: e, screen: t, searchParams: n, setSearchParams: r }) {
|
|
170
|
+
let i = G(() => {
|
|
171
|
+
let e = n.get("columns");
|
|
172
|
+
return e ? e.split(",").filter(Boolean) : t?.default_columns ?? t?.columns ?? [];
|
|
173
|
+
}, [
|
|
174
|
+
n,
|
|
175
|
+
t?.default_columns,
|
|
176
|
+
t?.columns
|
|
177
|
+
]), { widths: a, prune: o, setWidths: s, resetWidths: c, resizeEduShown: l, markResizeEduShown: u } = ge(e), [d, f] = q(() => a);
|
|
178
|
+
W(() => {
|
|
179
|
+
f(a);
|
|
180
|
+
}, [a]);
|
|
181
|
+
let p = G(() => t?.columns ?? [], [t?.columns]);
|
|
182
|
+
W(() => {
|
|
183
|
+
p.length > 0 && o(p);
|
|
184
|
+
}, [p, o]);
|
|
185
|
+
let m = U((e) => {
|
|
186
|
+
if (e.length === 0) return;
|
|
187
|
+
let t = new URLSearchParams(n);
|
|
188
|
+
t.set("columns", e.join(",")), r(t);
|
|
189
|
+
}, [n, r]);
|
|
190
|
+
return {
|
|
191
|
+
visible: i,
|
|
192
|
+
sizing: d,
|
|
193
|
+
setSizing: f,
|
|
194
|
+
apply: m,
|
|
195
|
+
clear: U(() => {
|
|
196
|
+
let e = new URLSearchParams(n);
|
|
197
|
+
e.delete("columns"), r(e);
|
|
198
|
+
}, [n, r]),
|
|
199
|
+
move: U((e, t) => {
|
|
200
|
+
let n = i.indexOf(e);
|
|
201
|
+
if (n === -1) return;
|
|
202
|
+
let r = t === "up" ? n - 1 : n + 1;
|
|
203
|
+
if (r < 0 || r >= i.length) return;
|
|
204
|
+
let a = [...i];
|
|
205
|
+
[a[n], a[r]] = [a[r], a[n]], m(a);
|
|
206
|
+
}, [i, m]),
|
|
207
|
+
commitResize: U((e) => {
|
|
208
|
+
s(e), !l && (u(), A.info("Column width saved on this device", "Widths are personal and never shared. Column order, sort and filters can be saved into a view."));
|
|
209
|
+
}, [
|
|
210
|
+
s,
|
|
211
|
+
l,
|
|
212
|
+
u
|
|
213
|
+
]),
|
|
214
|
+
resetWidths: c
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
function Nt(e, t, n = 10) {
|
|
218
|
+
switch (t.type) {
|
|
219
|
+
case "down": return {
|
|
220
|
+
origin: {
|
|
221
|
+
x: t.x,
|
|
222
|
+
y: t.y
|
|
223
|
+
},
|
|
224
|
+
outcome: "pending"
|
|
225
|
+
};
|
|
226
|
+
case "move": return e ? Math.abs(t.x - e.x) > n || Math.abs(t.y - e.y) > n ? {
|
|
227
|
+
origin: null,
|
|
228
|
+
outcome: "idle"
|
|
229
|
+
} : {
|
|
230
|
+
origin: e,
|
|
231
|
+
outcome: "pending"
|
|
232
|
+
} : {
|
|
233
|
+
origin: null,
|
|
234
|
+
outcome: "idle"
|
|
235
|
+
};
|
|
236
|
+
case "release": return {
|
|
237
|
+
origin: null,
|
|
238
|
+
outcome: "idle"
|
|
239
|
+
};
|
|
240
|
+
case "held": return e ? {
|
|
241
|
+
origin: null,
|
|
242
|
+
outcome: "fire"
|
|
243
|
+
} : {
|
|
244
|
+
origin: null,
|
|
245
|
+
outcome: "idle"
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
function Pt(e) {
|
|
250
|
+
return e instanceof Element && e.closest("a, button, input, select, [role='button'], [role='menuitem']") !== null;
|
|
251
|
+
}
|
|
252
|
+
function Ft(e, t) {
|
|
253
|
+
return e != null && e.rowId === t ? "double" : "single";
|
|
254
|
+
}
|
|
255
|
+
//#endregion
|
|
256
|
+
//#region src/hooks/useLongPress.ts
|
|
257
|
+
function It(e) {
|
|
258
|
+
let t = K(null), n = K(null), r = K(!1), i = U(() => {
|
|
259
|
+
n.current !== null && clearTimeout(n.current), n.current = null;
|
|
260
|
+
}, []);
|
|
261
|
+
W(() => i, [i]);
|
|
262
|
+
let a = U((e) => {
|
|
263
|
+
let n = Nt(t.current, e);
|
|
264
|
+
return t.current = n.origin, n.outcome !== "pending" && i(), n;
|
|
265
|
+
}, [i]);
|
|
266
|
+
return {
|
|
267
|
+
handlers: {
|
|
268
|
+
onPointerDown: (o) => {
|
|
269
|
+
if (o.pointerType === "mouse" || Pt(o.target)) return;
|
|
270
|
+
r.current = !1, i();
|
|
271
|
+
let s = {
|
|
272
|
+
x: o.clientX,
|
|
273
|
+
y: o.clientY
|
|
274
|
+
};
|
|
275
|
+
a({
|
|
276
|
+
type: "down",
|
|
277
|
+
...s
|
|
278
|
+
}), n.current = setTimeout(() => {
|
|
279
|
+
let i = Nt(t.current, { type: "held" });
|
|
280
|
+
t.current = i.origin, n.current = null, i.outcome === "fire" && (r.current = !0, e(s));
|
|
281
|
+
}, 500);
|
|
282
|
+
},
|
|
283
|
+
onPointerMove: (e) => {
|
|
284
|
+
t.current && a({
|
|
285
|
+
type: "move",
|
|
286
|
+
x: e.clientX,
|
|
287
|
+
y: e.clientY
|
|
288
|
+
});
|
|
289
|
+
},
|
|
290
|
+
onPointerUp: () => void a({ type: "release" }),
|
|
291
|
+
onPointerCancel: () => void a({ type: "release" }),
|
|
292
|
+
onPointerLeave: () => void a({ type: "release" })
|
|
293
|
+
},
|
|
294
|
+
consumePressFired: U(() => {
|
|
295
|
+
let e = r.current;
|
|
296
|
+
return r.current = !1, e;
|
|
297
|
+
}, [])
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
//#endregion
|
|
301
|
+
//#region src/components/pages/list/useListRowInteraction.ts
|
|
302
|
+
function Lt({ entity: e, screen: t, screens: n, entities: i, searchParams: o, tabNavigate: c, commitScreenTabSearch: l, isPhone: u, canUpdate: d }) {
|
|
303
|
+
let [f, p] = q(null), [m, g] = q(null), _ = K(null), v = K(null);
|
|
304
|
+
W(() => () => {
|
|
305
|
+
v.current && clearTimeout(v.current.timer);
|
|
306
|
+
}, []);
|
|
307
|
+
let y = t?.on_row_click === "peek" && t.quick_peek?.enabled !== !1 && !u, x = U((i, u) => {
|
|
308
|
+
if (!e || !t) return;
|
|
309
|
+
let d = a(e, i), f = r(e, d), p = N(t, e, n, d);
|
|
310
|
+
if (!p) return;
|
|
311
|
+
if (u?.draft) {
|
|
312
|
+
z(f, u.draft);
|
|
313
|
+
let [e, t] = p.split("?", 2), n = new URLSearchParams(t ?? "");
|
|
314
|
+
n.set("edit", "true"), p = `${e}?${n.toString()}`;
|
|
315
|
+
}
|
|
316
|
+
let m = h(i, e) ?? s(e.display.name), g = t.display?.icon || e.display.icon;
|
|
317
|
+
l(o.toString()), c(p, {
|
|
318
|
+
title: m,
|
|
319
|
+
icon: g
|
|
320
|
+
});
|
|
321
|
+
}, [
|
|
322
|
+
e,
|
|
323
|
+
t,
|
|
324
|
+
n,
|
|
325
|
+
o,
|
|
326
|
+
c,
|
|
327
|
+
l
|
|
328
|
+
]), S = It(U((e) => {
|
|
329
|
+
let t = _.current;
|
|
330
|
+
t && g({
|
|
331
|
+
x: e.x,
|
|
332
|
+
y: e.y,
|
|
333
|
+
row: t
|
|
334
|
+
});
|
|
335
|
+
}, [])), C = U((t, n) => {
|
|
336
|
+
if (S.consumePressFired() || Pt(t.target)) return;
|
|
337
|
+
if (!y || !e) {
|
|
338
|
+
x(n);
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
let r = kt(e, n);
|
|
342
|
+
if (Ft(v.current, r) === "double") {
|
|
343
|
+
clearTimeout(v.current.timer), v.current = null, p(null), x(n);
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
v.current && clearTimeout(v.current.timer);
|
|
347
|
+
let i = setTimeout(() => {
|
|
348
|
+
v.current = null, p(n);
|
|
349
|
+
}, 250);
|
|
350
|
+
v.current = {
|
|
351
|
+
rowId: r,
|
|
352
|
+
timer: i
|
|
353
|
+
};
|
|
354
|
+
}, [
|
|
355
|
+
e,
|
|
356
|
+
y,
|
|
357
|
+
x,
|
|
358
|
+
S
|
|
359
|
+
]);
|
|
360
|
+
return {
|
|
361
|
+
peekAllowed: y,
|
|
362
|
+
peekRow: f,
|
|
363
|
+
setPeekRow: p,
|
|
364
|
+
peekFields: G(() => {
|
|
365
|
+
if (!y || !e || !f) return [];
|
|
366
|
+
let r = Le(e, t, f);
|
|
367
|
+
return Je(e, r, n).map((t) => {
|
|
368
|
+
if (e.files?.get(t)) return {
|
|
369
|
+
key: t,
|
|
370
|
+
label: Ne(e, t, i),
|
|
371
|
+
kind: "file",
|
|
372
|
+
readOnly: !d
|
|
373
|
+
};
|
|
374
|
+
let n = e.fields.get(t), r = d && !n.primary && !n.auto && !n.ref && n.files?.mode !== "rich_text_inline";
|
|
375
|
+
return {
|
|
376
|
+
key: t,
|
|
377
|
+
label: ce(n, t, i),
|
|
378
|
+
kind: "field",
|
|
379
|
+
field: n,
|
|
380
|
+
readOnly: !r
|
|
381
|
+
};
|
|
382
|
+
});
|
|
383
|
+
}, [
|
|
384
|
+
y,
|
|
385
|
+
f,
|
|
386
|
+
e,
|
|
387
|
+
t,
|
|
388
|
+
i,
|
|
389
|
+
n,
|
|
390
|
+
d
|
|
391
|
+
]),
|
|
392
|
+
peekActions: G(() => e?.actions ?? {}, [e?.actions]),
|
|
393
|
+
peekExecute: U(async (t, n, r) => {
|
|
394
|
+
let i = e?.fields.names().find((t) => e.fields.get(t)?.primary), a = i && f ? [I(f[i])] : void 0, o = n.entity ? `${n.entity}.${t}` : t;
|
|
395
|
+
return b(o, T(r, a));
|
|
396
|
+
}, [e, f]),
|
|
397
|
+
contextMenu: m,
|
|
398
|
+
setContextMenu: g,
|
|
399
|
+
pressedRow: _,
|
|
400
|
+
longPress: S,
|
|
401
|
+
onRowClick: C,
|
|
402
|
+
navigateToDetail: x
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
//#endregion
|
|
406
|
+
//#region src/components/pages/list/column-sizing.ts
|
|
407
|
+
function Rt(e) {
|
|
408
|
+
return `--header-${e}-size`;
|
|
409
|
+
}
|
|
410
|
+
function zt(e) {
|
|
411
|
+
return `--col-${e}-size`;
|
|
412
|
+
}
|
|
413
|
+
function Z(e) {
|
|
414
|
+
return `calc(var(${e}) * 1px)`;
|
|
415
|
+
}
|
|
416
|
+
function Bt(e) {
|
|
417
|
+
let t = e.getFlatHeaders(), n = {};
|
|
418
|
+
for (let e of t) n[Rt(e.id)] = e.getSize(), n[zt(e.column.id)] = e.column.getSize();
|
|
419
|
+
return n;
|
|
420
|
+
}
|
|
421
|
+
//#endregion
|
|
422
|
+
//#region src/components/pages/list/sortable-header.ts
|
|
423
|
+
var Vt = /* @__PURE__ */ new Set([
|
|
424
|
+
"secret",
|
|
425
|
+
"password",
|
|
426
|
+
"json",
|
|
427
|
+
"string_array",
|
|
428
|
+
"int_array",
|
|
429
|
+
"uuid_array"
|
|
430
|
+
]);
|
|
431
|
+
function Ht(e, t) {
|
|
432
|
+
if (e === "_actions" || e === "_select" || e.startsWith("$property.") || e.startsWith("$refs.")) return !1;
|
|
433
|
+
if (e.startsWith("$status.")) return !0;
|
|
434
|
+
let n = t?.fields.get(e);
|
|
435
|
+
return !n || t?.list_pagination === "cursor" && n.cross_store_sortable === !1 ? !1 : !Vt.has(n.type);
|
|
436
|
+
}
|
|
437
|
+
//#endregion
|
|
438
|
+
//#region src/components/pages/list/ListTable.tsx
|
|
439
|
+
var Ut = _t(() => import("./SortHeaderMenu-NgjkW8QZ.js").then((e) => ({ default: e.SortHeaderMenu }))), Wt = H(function({ virtualItems: e, topPad: t, bottomPad: n, colSpan: r, rows: i, renderRow: a }) {
|
|
440
|
+
return /* @__PURE__ */ X("tbody", { children: [
|
|
441
|
+
e.length > 0 && /* @__PURE__ */ Y("tr", { children: /* @__PURE__ */ Y("td", {
|
|
442
|
+
style: { height: t },
|
|
443
|
+
colSpan: r
|
|
444
|
+
}) }),
|
|
445
|
+
e.map((e) => a(i[e.index], e.index)),
|
|
446
|
+
e.length > 0 && /* @__PURE__ */ Y("tr", { children: /* @__PURE__ */ Y("td", {
|
|
447
|
+
style: { height: n },
|
|
448
|
+
colSpan: r
|
|
449
|
+
}) })
|
|
450
|
+
] });
|
|
451
|
+
}, (e, t) => t.isResizing);
|
|
452
|
+
function Gt({ table: t, columns: n, rows: r, entity: i, columnSizeVars: a, totalColumnsWidth: o, theadRef: s, virtualizer: c, visibleCols: l, headerReorder: u, sortCols: d, sortNullsMap: f, shiftClickColumn: p, applyColumnSort: m, appendColumnSort: h, clearColumnSort: g, clearAllSorts: _, renderRow: v, isResizingColumn: y }) {
|
|
453
|
+
return /* @__PURE__ */ X("table", {
|
|
454
|
+
"data-virtual-rows": "true",
|
|
455
|
+
style: {
|
|
456
|
+
...a,
|
|
457
|
+
tableLayout: "fixed",
|
|
458
|
+
width: "100%",
|
|
459
|
+
minWidth: o,
|
|
460
|
+
borderCollapse: "separate",
|
|
461
|
+
borderSpacing: 0,
|
|
462
|
+
fontSize: 12.5,
|
|
463
|
+
color: "var(--text)"
|
|
464
|
+
},
|
|
465
|
+
children: [/* @__PURE__ */ Y("thead", {
|
|
466
|
+
ref: s,
|
|
467
|
+
children: t.getHeaderGroups().map((t) => /* @__PURE__ */ X("tr", {
|
|
468
|
+
style: {
|
|
469
|
+
height: 32,
|
|
470
|
+
background: "var(--surface-2)"
|
|
471
|
+
},
|
|
472
|
+
children: [t.headers.map((t) => {
|
|
473
|
+
let n = Ht(t.id, i), r = t.column.getIsSorted(), a = t.id === "_select", o = t.id === "_actions", s = r ? d.findIndex((e) => e.field === t.id) + 1 : 0, c = d.length > 1 && s > 0, v = s > 0, y = d.length < 5, b = n ? t.column.getToggleSortingHandler() : void 0, x = n ? (e) => {
|
|
474
|
+
if (e.shiftKey) {
|
|
475
|
+
e.preventDefault(), p(t.id);
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
b?.(e);
|
|
479
|
+
} : void 0, S = !a && !o, C = S ? l.indexOf(t.id) : -1, w = u.dragColId === t.id, T = u.isDragging && C !== -1 && u.dropIndex === C, E = u.isDragging && C !== -1 && C === l.length - 1 && u.dropIndex === l.length;
|
|
480
|
+
return /* @__PURE__ */ X("th", {
|
|
481
|
+
"data-col-id": S ? t.id : void 0,
|
|
482
|
+
onMouseDown: S ? (e) => u.onHeaderMouseDown(t.id, e) : void 0,
|
|
483
|
+
onClick: (e) => {
|
|
484
|
+
u.consumeDragSuppression() || x?.(e);
|
|
485
|
+
},
|
|
486
|
+
style: {
|
|
487
|
+
padding: a ? "0 6px 0 12px" : o ? "0 6px" : "0 10px",
|
|
488
|
+
textAlign: "left",
|
|
489
|
+
fontWeight: 600,
|
|
490
|
+
fontSize: 11,
|
|
491
|
+
letterSpacing: "0.01em",
|
|
492
|
+
color: "var(--text-3)",
|
|
493
|
+
whiteSpace: "nowrap",
|
|
494
|
+
cursor: n ? "pointer" : "default",
|
|
495
|
+
opacity: w ? .4 : 1,
|
|
496
|
+
boxShadow: T ? "inset 2px 0 0 0 var(--accent)" : E ? "inset -2px 0 0 0 var(--accent)" : void 0,
|
|
497
|
+
width: Z(Rt(t.id)),
|
|
498
|
+
minWidth: Z(Rt(t.id)),
|
|
499
|
+
borderBottom: "1px solid var(--border)",
|
|
500
|
+
background: "var(--surface-2)",
|
|
501
|
+
position: "sticky",
|
|
502
|
+
top: 0,
|
|
503
|
+
left: a ? 0 : "auto",
|
|
504
|
+
zIndex: a ? 3 : 2
|
|
505
|
+
},
|
|
506
|
+
children: [t.isPlaceholder ? null : n ? /* @__PURE__ */ X("span", {
|
|
507
|
+
style: {
|
|
508
|
+
display: "inline-flex",
|
|
509
|
+
alignItems: "center",
|
|
510
|
+
gap: 4,
|
|
511
|
+
textTransform: "uppercase",
|
|
512
|
+
fontSize: 10.5,
|
|
513
|
+
letterSpacing: "0.04em"
|
|
514
|
+
},
|
|
515
|
+
children: [
|
|
516
|
+
xt(t.column.columnDef.header, t.getContext()),
|
|
517
|
+
/* @__PURE__ */ X("span", {
|
|
518
|
+
style: {
|
|
519
|
+
display: "inline-flex",
|
|
520
|
+
flexDirection: "column",
|
|
521
|
+
alignItems: "center",
|
|
522
|
+
lineHeight: 0
|
|
523
|
+
},
|
|
524
|
+
children: [r === "asc" ? /* @__PURE__ */ Y(e.arrowUp, { size: 11 }) : r === "desc" ? /* @__PURE__ */ Y(e.arrowDown, { size: 11 }) : /* @__PURE__ */ Y(e.sort, {
|
|
525
|
+
size: 11,
|
|
526
|
+
style: { opacity: .35 }
|
|
527
|
+
}), r && f.get(t.id) === "first" ? /* @__PURE__ */ Y("span", {
|
|
528
|
+
"aria-hidden": "true",
|
|
529
|
+
style: {
|
|
530
|
+
width: 4,
|
|
531
|
+
height: 4,
|
|
532
|
+
marginTop: 1,
|
|
533
|
+
borderRadius: 9999,
|
|
534
|
+
background: "var(--text-3)"
|
|
535
|
+
}
|
|
536
|
+
}) : null]
|
|
537
|
+
}),
|
|
538
|
+
c ? /* @__PURE__ */ Y("span", {
|
|
539
|
+
"aria-label": `Sort rank ${s}`,
|
|
540
|
+
style: {
|
|
541
|
+
fontSize: 10,
|
|
542
|
+
lineHeight: 1,
|
|
543
|
+
color: "var(--text-3)",
|
|
544
|
+
verticalAlign: "super",
|
|
545
|
+
fontVariantNumeric: "tabular-nums"
|
|
546
|
+
},
|
|
547
|
+
children: s
|
|
548
|
+
}) : null,
|
|
549
|
+
/* @__PURE__ */ Y(gt, {
|
|
550
|
+
fallback: null,
|
|
551
|
+
children: /* @__PURE__ */ Y(Ut, {
|
|
552
|
+
field: t.id,
|
|
553
|
+
activeDir: r,
|
|
554
|
+
activeNulls: f.get(t.id),
|
|
555
|
+
inMultiSort: v,
|
|
556
|
+
canAppend: y,
|
|
557
|
+
onApply: (e, n) => m(t.id, e, n),
|
|
558
|
+
onAppend: (e, n) => h(t.id, e, n),
|
|
559
|
+
onClearColumn: () => g(t.id),
|
|
560
|
+
onClearAll: _
|
|
561
|
+
})
|
|
562
|
+
})
|
|
563
|
+
]
|
|
564
|
+
}) : xt(t.column.columnDef.header, t.getContext()), t.column.getCanResize() && /* @__PURE__ */ Y("div", {
|
|
565
|
+
"data-testid": "col-resize-handle",
|
|
566
|
+
"aria-hidden": "true",
|
|
567
|
+
onMouseDown: (e) => {
|
|
568
|
+
e.stopPropagation(), t.getResizeHandler()(e);
|
|
569
|
+
},
|
|
570
|
+
onTouchStart: (e) => {
|
|
571
|
+
e.stopPropagation(), t.getResizeHandler()(e);
|
|
572
|
+
},
|
|
573
|
+
onClick: (e) => e.stopPropagation(),
|
|
574
|
+
style: {
|
|
575
|
+
position: "absolute",
|
|
576
|
+
top: 0,
|
|
577
|
+
right: 0,
|
|
578
|
+
height: "100%",
|
|
579
|
+
width: 9,
|
|
580
|
+
display: "flex",
|
|
581
|
+
justifyContent: "center",
|
|
582
|
+
cursor: "col-resize",
|
|
583
|
+
touchAction: "none",
|
|
584
|
+
userSelect: "none",
|
|
585
|
+
zIndex: 3
|
|
586
|
+
},
|
|
587
|
+
children: /* @__PURE__ */ Y("span", { style: {
|
|
588
|
+
width: 2,
|
|
589
|
+
height: "60%",
|
|
590
|
+
alignSelf: "center",
|
|
591
|
+
borderRadius: 1,
|
|
592
|
+
background: t.column.getIsResizing() ? "var(--accent)" : "var(--border)"
|
|
593
|
+
} })
|
|
594
|
+
})]
|
|
595
|
+
}, t.id);
|
|
596
|
+
}), /* @__PURE__ */ Y("th", {
|
|
597
|
+
"aria-hidden": "true",
|
|
598
|
+
style: {
|
|
599
|
+
borderBottom: "1px solid var(--border)",
|
|
600
|
+
background: "var(--surface-2)",
|
|
601
|
+
position: "sticky",
|
|
602
|
+
top: 0,
|
|
603
|
+
zIndex: 2
|
|
604
|
+
}
|
|
605
|
+
})]
|
|
606
|
+
}, t.id))
|
|
607
|
+
}), /* @__PURE__ */ Y(Wt, {
|
|
608
|
+
virtualItems: c.getVirtualItems(),
|
|
609
|
+
topPad: c.getVirtualItems()[0]?.start ?? 0,
|
|
610
|
+
bottomPad: c.getTotalSize() - (c.getVirtualItems().at(-1)?.end ?? 0),
|
|
611
|
+
colSpan: n.length + 1,
|
|
612
|
+
rows: r,
|
|
613
|
+
renderRow: v,
|
|
614
|
+
isResizing: !!y
|
|
615
|
+
})]
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
//#endregion
|
|
619
|
+
//#region src/components/pages/list/DataCell.tsx
|
|
620
|
+
function Kt({ cell: e }) {
|
|
621
|
+
let t = e.column.id === "_select", n = e.column.id === "_actions", r = e.column.columnDef.cell, i = typeof r == "function" ? r(e.getContext()) : r;
|
|
622
|
+
return /* @__PURE__ */ Y("td", {
|
|
623
|
+
title: typeof i == "string" ? i : void 0,
|
|
624
|
+
style: {
|
|
625
|
+
padding: t ? "0 6px 0 12px" : n ? "0 6px" : "0 10px",
|
|
626
|
+
verticalAlign: "middle",
|
|
627
|
+
borderBottom: "1px solid var(--divider)",
|
|
628
|
+
width: Z(zt(e.column.id)),
|
|
629
|
+
whiteSpace: "nowrap",
|
|
630
|
+
overflow: "hidden",
|
|
631
|
+
textOverflow: "ellipsis",
|
|
632
|
+
maxWidth: Z(zt(e.column.id)),
|
|
633
|
+
color: "var(--text)",
|
|
634
|
+
position: t ? "sticky" : "static",
|
|
635
|
+
left: t ? 0 : "auto",
|
|
636
|
+
zIndex: +!!t
|
|
637
|
+
},
|
|
638
|
+
onClick: t || n ? (e) => e.stopPropagation() : void 0,
|
|
639
|
+
children: i
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
//#endregion
|
|
643
|
+
//#region src/components/pages/list/ListTableRow.tsx
|
|
644
|
+
function qt({ row: e, rowIndex: t, entity: n, hasSoftDelete: r, zebra: i, hasDetailTarget: a, interaction: o, measureElement: s }) {
|
|
645
|
+
let c = e.original, l = r && c[n.soft_delete] != null, u = e.getIsSelected(), d = i && t % 2 == 1;
|
|
646
|
+
return /* @__PURE__ */ X("tr", {
|
|
647
|
+
"data-index": t,
|
|
648
|
+
"data-row-stripe": d ? "" : void 0,
|
|
649
|
+
"aria-selected": u,
|
|
650
|
+
ref: (e) => s(e),
|
|
651
|
+
style: {
|
|
652
|
+
height: "var(--row-h)",
|
|
653
|
+
cursor: a || o.peekAllowed ? "pointer" : "default",
|
|
654
|
+
opacity: l ? .5 : 1,
|
|
655
|
+
fontStyle: l ? "italic" : "normal",
|
|
656
|
+
transition: "background-color 120ms"
|
|
657
|
+
},
|
|
658
|
+
onClick: a || o.peekAllowed ? (e) => o.onRowClick(e, c) : void 0,
|
|
659
|
+
onContextMenu: (e) => {
|
|
660
|
+
e.preventDefault(), o.setContextMenu({
|
|
661
|
+
x: e.clientX,
|
|
662
|
+
y: e.clientY,
|
|
663
|
+
row: c
|
|
664
|
+
});
|
|
665
|
+
},
|
|
666
|
+
...o.longPress.handlers,
|
|
667
|
+
onPointerDown: (e) => {
|
|
668
|
+
o.pressedRow.current = c, o.longPress.handlers.onPointerDown(e);
|
|
669
|
+
},
|
|
670
|
+
children: [e.getVisibleCells().map((e) => /* @__PURE__ */ Y(Kt, { cell: e }, e.id)), /* @__PURE__ */ Y("td", {
|
|
671
|
+
"aria-hidden": "true",
|
|
672
|
+
style: { borderBottom: "1px solid var(--divider)" }
|
|
673
|
+
})]
|
|
674
|
+
}, e.id);
|
|
675
|
+
}
|
|
676
|
+
//#endregion
|
|
677
|
+
//#region src/components/pages/list/ListNoRows.tsx
|
|
678
|
+
function Jt(e) {
|
|
679
|
+
if (e instanceof j) {
|
|
680
|
+
let t = e.ext("field"), n = e.ext("value");
|
|
681
|
+
return t && n !== void 0 ? `${e.message} ${t}: "${n}"` : t ? `${e.message} ${t}` : e.message;
|
|
682
|
+
}
|
|
683
|
+
return e instanceof Error && e.message ? e.message : "Something went wrong. Please try again.";
|
|
684
|
+
}
|
|
685
|
+
function Yt({ isLoading: e, tableLoadingStale: t, isError: n, error: r, rowCount: i, entity: a, screen: o, screenName: c, screenIcon: l, isFiltered: u, canCreate: d, toolbarActions: f, onRetry: p }) {
|
|
686
|
+
let m = a.display;
|
|
687
|
+
return e && t ? /* @__PURE__ */ Y("div", {
|
|
688
|
+
style: { padding: "0 20px" },
|
|
689
|
+
children: /* @__PURE__ */ Y(lt, {
|
|
690
|
+
icon: "alert-circle",
|
|
691
|
+
title: "Still loading data",
|
|
692
|
+
description: "This table is taking longer than expected. Retry the request or check network and server health.",
|
|
693
|
+
action: /* @__PURE__ */ Y(w, {
|
|
694
|
+
kind: "primary",
|
|
695
|
+
size: "sm",
|
|
696
|
+
onClick: p,
|
|
697
|
+
children: "Retry"
|
|
698
|
+
})
|
|
699
|
+
})
|
|
700
|
+
}) : e ? /* @__PURE__ */ Y(Ve, { cols: o.columns?.length ?? 4 }) : n ? /* @__PURE__ */ Y("div", {
|
|
701
|
+
style: { padding: "0 20px" },
|
|
702
|
+
children: /* @__PURE__ */ Y(lt, {
|
|
703
|
+
icon: "alert-circle",
|
|
704
|
+
title: "Failed to load data",
|
|
705
|
+
description: Jt(r),
|
|
706
|
+
action: /* @__PURE__ */ Y(w, {
|
|
707
|
+
kind: "primary",
|
|
708
|
+
size: "sm",
|
|
709
|
+
onClick: p,
|
|
710
|
+
children: "Retry"
|
|
711
|
+
})
|
|
712
|
+
})
|
|
713
|
+
}) : i === 0 ? /* @__PURE__ */ Y("div", {
|
|
714
|
+
style: { padding: "0 20px" },
|
|
715
|
+
children: (() => {
|
|
716
|
+
let e = m.empty_state, t = s(e?.title), n = s(e?.body), r = ae(e?.learn_more_url), i = u ? "No results found" : t || `No ${s(m.name_plural).toLowerCase() || c.toLowerCase()} yet`, a = d && f.some(({ code: e }) => e === "__new" || e === "__create"), o;
|
|
717
|
+
return o = u ? "Try adjusting your search or filters" : n ? /* @__PURE__ */ X(J, { children: [n, r && /* @__PURE__ */ X(J, { children: [" ", /* @__PURE__ */ Y("a", {
|
|
718
|
+
href: r,
|
|
719
|
+
target: "_blank",
|
|
720
|
+
rel: "noopener noreferrer",
|
|
721
|
+
children: "Learn more"
|
|
722
|
+
})] })] }) : a ? `Create your first ${s(m.name).toLowerCase()} to get started` : void 0, /* @__PURE__ */ Y(lt, {
|
|
723
|
+
icon: l,
|
|
724
|
+
title: i,
|
|
725
|
+
description: o
|
|
726
|
+
});
|
|
727
|
+
})()
|
|
728
|
+
}) : null;
|
|
729
|
+
}
|
|
730
|
+
//#endregion
|
|
731
|
+
//#region src/components/pages/list/ListFooter.tsx
|
|
732
|
+
function Xt({ meta: n, isCursor: r, isPhone: i, rowsLoaded: a, selectedCount: o, countTotal: s, countStrategy: c, countLoading: l, countError: u, page: d, totalPages: f, goToPage: p, perPage: m, setPerPage: h, hasMorePages: g, fetchNextPage: _, isFetchingNextPage: v }) {
|
|
733
|
+
let y = pe("list");
|
|
734
|
+
return !n && !r ? null : /* @__PURE__ */ X("div", {
|
|
735
|
+
style: {
|
|
736
|
+
display: "flex",
|
|
737
|
+
alignItems: "center",
|
|
738
|
+
paddingTop: 8,
|
|
739
|
+
paddingBottom: 8,
|
|
740
|
+
...i ? ye(12) : {
|
|
741
|
+
paddingLeft: 14,
|
|
742
|
+
paddingRight: 14
|
|
743
|
+
},
|
|
744
|
+
background: "var(--surface-2)",
|
|
745
|
+
borderTop: "1px solid var(--border)",
|
|
746
|
+
fontSize: 11.5,
|
|
747
|
+
color: "var(--text-3)",
|
|
748
|
+
gap: 12,
|
|
749
|
+
flexWrap: "wrap"
|
|
750
|
+
},
|
|
751
|
+
children: [
|
|
752
|
+
y.isVisible("show_count") && /* @__PURE__ */ X(J, { children: [/* @__PURE__ */ Y("span", {
|
|
753
|
+
className: "num",
|
|
754
|
+
"data-testid": "list-footer-count",
|
|
755
|
+
style: {
|
|
756
|
+
display: "inline-flex",
|
|
757
|
+
alignItems: "center",
|
|
758
|
+
gap: 5
|
|
759
|
+
},
|
|
760
|
+
children: s === void 0 ? l && !u ? /* @__PURE__ */ Y("span", {
|
|
761
|
+
"data-testid": "list-footer-count-pending",
|
|
762
|
+
style: { display: "inline-flex" },
|
|
763
|
+
children: /* @__PURE__ */ Y(t, { size: 11 })
|
|
764
|
+
}) : /* @__PURE__ */ X(J, { children: [
|
|
765
|
+
a,
|
|
766
|
+
" ",
|
|
767
|
+
a === 1 ? "record" : "records"
|
|
768
|
+
] }) : /* @__PURE__ */ X(J, { children: [
|
|
769
|
+
a,
|
|
770
|
+
" of ",
|
|
771
|
+
R(s, c ?? "exact"),
|
|
772
|
+
" ",
|
|
773
|
+
s === 1 ? "record" : "records"
|
|
774
|
+
] })
|
|
775
|
+
}), /* @__PURE__ */ Y("span", { children: "·" })] }),
|
|
776
|
+
/* @__PURE__ */ X("span", { children: [
|
|
777
|
+
"Selected:",
|
|
778
|
+
" ",
|
|
779
|
+
/* @__PURE__ */ Y("span", {
|
|
780
|
+
className: "num",
|
|
781
|
+
style: {
|
|
782
|
+
color: "var(--text-2)",
|
|
783
|
+
fontWeight: 500
|
|
784
|
+
},
|
|
785
|
+
children: o
|
|
786
|
+
})
|
|
787
|
+
] }),
|
|
788
|
+
/* @__PURE__ */ Y("div", { style: { flex: i ? "1 1 100%" : 1 } }),
|
|
789
|
+
!i && /* @__PURE__ */ Y("span", { children: "Rows per page" }),
|
|
790
|
+
/* @__PURE__ */ Y("select", {
|
|
791
|
+
"aria-label": "Rows per page",
|
|
792
|
+
value: m,
|
|
793
|
+
onChange: (e) => h(parseInt(e.target.value, 10)),
|
|
794
|
+
style: {
|
|
795
|
+
fontSize: 11.5,
|
|
796
|
+
padding: "2px 4px",
|
|
797
|
+
background: "var(--surface)",
|
|
798
|
+
border: "1px solid var(--border)",
|
|
799
|
+
borderRadius: 4,
|
|
800
|
+
color: "var(--text-2)",
|
|
801
|
+
cursor: "pointer"
|
|
802
|
+
},
|
|
803
|
+
children: Tt.map((e) => /* @__PURE__ */ Y("option", {
|
|
804
|
+
value: e,
|
|
805
|
+
children: e
|
|
806
|
+
}, e))
|
|
807
|
+
}),
|
|
808
|
+
r ? g && /* @__PURE__ */ X("button", {
|
|
809
|
+
type: "button",
|
|
810
|
+
className: "num",
|
|
811
|
+
"data-testid": "list-footer-load-more",
|
|
812
|
+
onClick: _,
|
|
813
|
+
disabled: v,
|
|
814
|
+
style: {
|
|
815
|
+
display: "inline-flex",
|
|
816
|
+
alignItems: "center",
|
|
817
|
+
gap: 6,
|
|
818
|
+
padding: "2px 10px",
|
|
819
|
+
background: "var(--surface)",
|
|
820
|
+
border: "1px solid var(--border)",
|
|
821
|
+
borderRadius: 4,
|
|
822
|
+
color: "var(--text-2)",
|
|
823
|
+
cursor: v ? "default" : "pointer"
|
|
824
|
+
},
|
|
825
|
+
children: [v ? /* @__PURE__ */ Y(t, { size: 11 }) : null, "Load more"]
|
|
826
|
+
}) : (g || d > 1) && /* @__PURE__ */ X("div", {
|
|
827
|
+
style: {
|
|
828
|
+
display: "flex",
|
|
829
|
+
alignItems: "center",
|
|
830
|
+
gap: 4
|
|
831
|
+
},
|
|
832
|
+
children: [
|
|
833
|
+
/* @__PURE__ */ Y(S, {
|
|
834
|
+
size: 22,
|
|
835
|
+
icon: /* @__PURE__ */ Y(e.left, { size: 12 }),
|
|
836
|
+
onClick: () => p(d - 1),
|
|
837
|
+
disabled: d <= 1
|
|
838
|
+
}),
|
|
839
|
+
/* @__PURE__ */ X("span", {
|
|
840
|
+
className: "num",
|
|
841
|
+
style: { padding: "0 6px" },
|
|
842
|
+
children: [
|
|
843
|
+
"Page ",
|
|
844
|
+
d,
|
|
845
|
+
f === void 0 ? "" : ` of ${f}`
|
|
846
|
+
]
|
|
847
|
+
}),
|
|
848
|
+
/* @__PURE__ */ Y(S, {
|
|
849
|
+
size: 22,
|
|
850
|
+
icon: /* @__PURE__ */ Y(e.right, { size: 12 }),
|
|
851
|
+
onClick: () => p(d + 1),
|
|
852
|
+
disabled: f === void 0 ? !g : d >= f
|
|
853
|
+
})
|
|
854
|
+
]
|
|
855
|
+
})
|
|
856
|
+
]
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
//#endregion
|
|
860
|
+
//#region src/components/pages/ExportMenu.tsx
|
|
861
|
+
function Zt(e) {
|
|
862
|
+
return !(e && e.enabled === !1);
|
|
863
|
+
}
|
|
864
|
+
function Qt(e) {
|
|
865
|
+
return e == null ? "all matching rows" : `${e.toLocaleString()} ${e === 1 ? "row" : "rows"}`;
|
|
866
|
+
}
|
|
867
|
+
function $t(t) {
|
|
868
|
+
let { isPhone: n } = ie(), { entityCode: r, entity: i, screen: a, viewState: o, visibleColumns: s, selectedRowPKs: c, totalRows: l, pageSize: u, locale: d, align: f = "end", variant: p = "toolbar", onBeforeOpen: m } = t, [h, g] = q(!1), [_, v] = q(!1), [y, b] = q(null), S = K(null), T = Zt(i.export), E = Zt(a?.export);
|
|
869
|
+
if (!T || !E) return null;
|
|
870
|
+
async function D(e) {
|
|
871
|
+
b(null), v(!0);
|
|
872
|
+
try {
|
|
873
|
+
let t = dt(o, {
|
|
874
|
+
scope: e,
|
|
875
|
+
visibleColumns: s,
|
|
876
|
+
selectedRowPKs: e === "selected_rows" ? c : void 0,
|
|
877
|
+
locale: d
|
|
878
|
+
}), { blob: n, filename: i } = await F(r, t);
|
|
879
|
+
tn(n, i || `${r}-${en()}.csv`), g(!1);
|
|
880
|
+
} catch (e) {
|
|
881
|
+
let t = e instanceof j ? {
|
|
882
|
+
code: e.code,
|
|
883
|
+
message: e.message
|
|
884
|
+
} : {
|
|
885
|
+
code: "",
|
|
886
|
+
message: String(e)
|
|
887
|
+
};
|
|
888
|
+
b(t);
|
|
889
|
+
} finally {
|
|
890
|
+
v(!1);
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
if (p === "selection-menu-item") {
|
|
894
|
+
let t = _ || c.length === 0;
|
|
895
|
+
return /* @__PURE__ */ Y(C, {
|
|
896
|
+
icon: /* @__PURE__ */ Y(e.download, { size: 12 }),
|
|
897
|
+
"data-testid": "export-selection-menu-item",
|
|
898
|
+
onClick: t ? void 0 : () => {
|
|
899
|
+
m?.(), D("selected_rows");
|
|
900
|
+
},
|
|
901
|
+
children: _ ? "Exporting…" : "Export selection (CSV)"
|
|
902
|
+
});
|
|
903
|
+
}
|
|
904
|
+
let ee = c.length > 0, te = i.list_pagination === "cursor";
|
|
905
|
+
return /* @__PURE__ */ X(J, { children: [/* @__PURE__ */ Y(w, {
|
|
906
|
+
ref: S,
|
|
907
|
+
kind: "ghost",
|
|
908
|
+
size: "sm",
|
|
909
|
+
icon: /* @__PURE__ */ Y(e.download, { size: 12 }),
|
|
910
|
+
onClick: () => {
|
|
911
|
+
m?.(), g((e) => !e);
|
|
912
|
+
},
|
|
913
|
+
disabled: _,
|
|
914
|
+
"aria-label": "Export",
|
|
915
|
+
title: "Export",
|
|
916
|
+
children: n ? null : _ ? "Exporting…" : "Export"
|
|
917
|
+
}), /* @__PURE__ */ X(x, {
|
|
918
|
+
open: h,
|
|
919
|
+
anchor: S.current,
|
|
920
|
+
onClose: () => g(!1),
|
|
921
|
+
align: f,
|
|
922
|
+
width: 260,
|
|
923
|
+
children: [
|
|
924
|
+
/* @__PURE__ */ X(C, {
|
|
925
|
+
icon: /* @__PURE__ */ Y(e.download, { size: 12 }),
|
|
926
|
+
onClick: _ ? void 0 : () => void D("current_view"),
|
|
927
|
+
children: ["Current view (CSV) · ", Qt(l)]
|
|
928
|
+
}),
|
|
929
|
+
ee && /* @__PURE__ */ X(C, {
|
|
930
|
+
icon: /* @__PURE__ */ Y(e.check, { size: 12 }),
|
|
931
|
+
onClick: _ ? void 0 : () => void D("selected_rows"),
|
|
932
|
+
children: ["Selected rows (CSV) · ", c.length]
|
|
933
|
+
}),
|
|
934
|
+
te ? /* @__PURE__ */ Y(C, {
|
|
935
|
+
icon: /* @__PURE__ */ Y(e.columns, { size: 12 }),
|
|
936
|
+
"data-testid": "export-current-page-disabled",
|
|
937
|
+
disabled: !0,
|
|
938
|
+
children: "Current page · n/a (infinite scroll)"
|
|
939
|
+
}) : /* @__PURE__ */ X(C, {
|
|
940
|
+
icon: /* @__PURE__ */ Y(e.columns, { size: 12 }),
|
|
941
|
+
onClick: _ ? void 0 : () => void D("current_page"),
|
|
942
|
+
children: ["Current page (CSV) · ", u ? `${u} rows` : "page window"]
|
|
943
|
+
}),
|
|
944
|
+
/* @__PURE__ */ Y(C, {
|
|
945
|
+
icon: /* @__PURE__ */ Y(e.grid, { size: 12 }),
|
|
946
|
+
children: "XLSX (coming soon)"
|
|
947
|
+
}),
|
|
948
|
+
y && /* @__PURE__ */ Y("div", {
|
|
949
|
+
role: "alert",
|
|
950
|
+
style: {
|
|
951
|
+
padding: "6px 10px",
|
|
952
|
+
marginTop: 4,
|
|
953
|
+
fontSize: 12,
|
|
954
|
+
color: "var(--destructive)",
|
|
955
|
+
borderTop: "1px solid var(--border)"
|
|
956
|
+
},
|
|
957
|
+
children: y.message
|
|
958
|
+
})
|
|
959
|
+
]
|
|
960
|
+
})] });
|
|
961
|
+
}
|
|
962
|
+
function en() {
|
|
963
|
+
let e = /* @__PURE__ */ new Date(), t = (e) => String(e).padStart(2, "0");
|
|
964
|
+
return `${e.getUTCFullYear()}${t(e.getUTCMonth() + 1)}${t(e.getUTCDate())}-${t(e.getUTCHours())}${t(e.getUTCMinutes())}`;
|
|
965
|
+
}
|
|
966
|
+
function tn(e, t) {
|
|
967
|
+
let n = URL.createObjectURL(e), r = document.createElement("a");
|
|
968
|
+
r.href = n, r.download = t, r.style.display = "none", document.body.appendChild(r), r.click(), document.body.removeChild(r), setTimeout(() => URL.revokeObjectURL(n), 0);
|
|
969
|
+
}
|
|
970
|
+
//#endregion
|
|
971
|
+
//#region src/components/pages/list/ListToolbar.tsx
|
|
972
|
+
function nn({ screen: t, entity: n, entityCode: r, schema: i, screenCode: a, screenName: o, locale: c, isPhone: l, isCardsPresentation: u, sort: d, columns: f, views: p, query: m, selection: h, filters: _, searchValue: v, onSearchChange: y, onSaveView: b, page: T, perPage: E, includeDeleted: D, canViewDeleted: ee, onToggleDeleted: O, isLive: k }) {
|
|
973
|
+
let [ne, re] = q(!1), [ie, A] = q(!1), [ae, j] = q(!1), M = K(null), N = K(null), se = ve((e) => e.density), ce = () => {
|
|
974
|
+
let e = se === "compact" ? "comfortable" : se === "comfortable" ? "cozy" : "compact";
|
|
975
|
+
ve.getState().setMany({ density: e });
|
|
976
|
+
}, P = !l || ne || v !== "", F = (e) => {
|
|
977
|
+
if (e.startsWith("$status.")) {
|
|
978
|
+
let t = e.slice(8), r = n.status_groups?.[t];
|
|
979
|
+
return r ? s(r.name) || t : e;
|
|
980
|
+
}
|
|
981
|
+
if (e.startsWith("$property.")) {
|
|
982
|
+
let t = e.slice(10), r = n.properties?.[t];
|
|
983
|
+
return r ? s(r.name) || t : e;
|
|
984
|
+
}
|
|
985
|
+
return Ne(n, e, i?.entities);
|
|
986
|
+
}, le = (t.columns ?? []).filter((e) => Ht(e, n));
|
|
987
|
+
return /* @__PURE__ */ X("div", {
|
|
988
|
+
style: {
|
|
989
|
+
display: "flex",
|
|
990
|
+
alignItems: "center",
|
|
991
|
+
gap: l ? 6 : 8,
|
|
992
|
+
paddingTop: 0,
|
|
993
|
+
paddingBottom: 10,
|
|
994
|
+
...l ? ye(12) : {
|
|
995
|
+
paddingLeft: 20,
|
|
996
|
+
paddingRight: 20
|
|
997
|
+
},
|
|
998
|
+
flexWrap: "wrap"
|
|
999
|
+
},
|
|
1000
|
+
children: [
|
|
1001
|
+
/* @__PURE__ */ Y(ot, {
|
|
1002
|
+
views: p.all,
|
|
1003
|
+
activeViewId: p.activeId,
|
|
1004
|
+
isDirty: p.isDirty,
|
|
1005
|
+
onSelect: p.apply,
|
|
1006
|
+
onSaveAs: b
|
|
1007
|
+
}),
|
|
1008
|
+
P ? /* @__PURE__ */ X("div", {
|
|
1009
|
+
style: {
|
|
1010
|
+
position: "relative",
|
|
1011
|
+
width: l ? "100%" : 260,
|
|
1012
|
+
order: l ? -1 : 0
|
|
1013
|
+
},
|
|
1014
|
+
children: [/* @__PURE__ */ Y(g, {
|
|
1015
|
+
value: v,
|
|
1016
|
+
onChange: y,
|
|
1017
|
+
placeholder: `Search ${o.toLowerCase()}…`,
|
|
1018
|
+
prefix: /* @__PURE__ */ Y(e.search, { size: 13 })
|
|
1019
|
+
}), /* @__PURE__ */ Y("span", {
|
|
1020
|
+
style: {
|
|
1021
|
+
position: "absolute",
|
|
1022
|
+
right: 6,
|
|
1023
|
+
top: "50%",
|
|
1024
|
+
transform: "translateY(-50%)",
|
|
1025
|
+
pointerEvents: "none"
|
|
1026
|
+
},
|
|
1027
|
+
children: /* @__PURE__ */ Y(te, { children: "/" })
|
|
1028
|
+
})]
|
|
1029
|
+
}) : /* @__PURE__ */ Y(S, {
|
|
1030
|
+
icon: /* @__PURE__ */ Y(e.search, { size: 14 }),
|
|
1031
|
+
title: `Search ${o.toLowerCase()}`,
|
|
1032
|
+
onClick: () => re(!0)
|
|
1033
|
+
}),
|
|
1034
|
+
/* @__PURE__ */ X(w, {
|
|
1035
|
+
icon: /* @__PURE__ */ Y(e.filter, { size: 13 }),
|
|
1036
|
+
onClick: _.onOpen,
|
|
1037
|
+
active: _.count > 0,
|
|
1038
|
+
children: ["Filters", _.count > 0 && /* @__PURE__ */ Y(oe, {
|
|
1039
|
+
tone: "violet",
|
|
1040
|
+
size: "xs",
|
|
1041
|
+
style: { marginLeft: 4 },
|
|
1042
|
+
children: _.count
|
|
1043
|
+
})]
|
|
1044
|
+
}),
|
|
1045
|
+
u && /* @__PURE__ */ X(J, { children: [/* @__PURE__ */ X(w, {
|
|
1046
|
+
ref: M,
|
|
1047
|
+
icon: /* @__PURE__ */ Y(e.sort, { size: 13 }),
|
|
1048
|
+
onClick: () => A((e) => !e),
|
|
1049
|
+
active: ie || d.cols.length > 0,
|
|
1050
|
+
children: ["Sort", d.cols.length > 0 && /* @__PURE__ */ Y(oe, {
|
|
1051
|
+
tone: "slate",
|
|
1052
|
+
size: "xs",
|
|
1053
|
+
style: { marginLeft: 4 },
|
|
1054
|
+
children: d.cols.length
|
|
1055
|
+
})]
|
|
1056
|
+
}), /* @__PURE__ */ X(x, {
|
|
1057
|
+
open: ie,
|
|
1058
|
+
anchor: M.current,
|
|
1059
|
+
onClose: () => A(!1),
|
|
1060
|
+
align: "start",
|
|
1061
|
+
width: 280,
|
|
1062
|
+
children: [
|
|
1063
|
+
/* @__PURE__ */ Y("div", {
|
|
1064
|
+
style: {
|
|
1065
|
+
padding: "6px 8px 4px",
|
|
1066
|
+
fontSize: 10,
|
|
1067
|
+
color: "var(--text-3)",
|
|
1068
|
+
fontWeight: 700,
|
|
1069
|
+
letterSpacing: "0.08em",
|
|
1070
|
+
textTransform: "uppercase"
|
|
1071
|
+
},
|
|
1072
|
+
children: "Sort by"
|
|
1073
|
+
}),
|
|
1074
|
+
le.map((t) => {
|
|
1075
|
+
let n = d.cols.find((e) => e.field === t);
|
|
1076
|
+
return /* @__PURE__ */ Y(C, {
|
|
1077
|
+
icon: n ? n.dir === "desc" ? /* @__PURE__ */ Y(e.arrowDown, { size: 12 }) : /* @__PURE__ */ Y(e.arrowUp, { size: 12 }) : /* @__PURE__ */ Y("span", { style: {
|
|
1078
|
+
width: 12,
|
|
1079
|
+
display: "inline-block"
|
|
1080
|
+
} }),
|
|
1081
|
+
active: !!n,
|
|
1082
|
+
onClick: () => {
|
|
1083
|
+
d.applyColumn(t, n?.dir === "asc" ? "desc" : "asc", void 0), A(!1);
|
|
1084
|
+
},
|
|
1085
|
+
children: F(t)
|
|
1086
|
+
}, t);
|
|
1087
|
+
}),
|
|
1088
|
+
d.cols.length > 0 && /* @__PURE__ */ X(J, { children: [/* @__PURE__ */ Y(C, { divider: !0 }), /* @__PURE__ */ Y(C, {
|
|
1089
|
+
icon: /* @__PURE__ */ Y(e.x, { size: 12 }),
|
|
1090
|
+
onClick: () => {
|
|
1091
|
+
d.clearAll(), A(!1);
|
|
1092
|
+
},
|
|
1093
|
+
children: "Clear sort"
|
|
1094
|
+
})] })
|
|
1095
|
+
]
|
|
1096
|
+
})] }),
|
|
1097
|
+
!u && /* @__PURE__ */ Y(ct, {
|
|
1098
|
+
availableColumns: t.columns ?? [],
|
|
1099
|
+
visibleColumns: f.visible,
|
|
1100
|
+
onToggle: (e) => {
|
|
1101
|
+
let t = f.visible.includes(e) ? f.visible.filter((t) => t !== e) : [...f.visible, e];
|
|
1102
|
+
f.apply(t);
|
|
1103
|
+
},
|
|
1104
|
+
onMove: f.move,
|
|
1105
|
+
onReset: f.clear,
|
|
1106
|
+
onShowAll: () => f.apply(t.columns ?? []),
|
|
1107
|
+
onResetWidths: f.resetWidths,
|
|
1108
|
+
columnLabel: F
|
|
1109
|
+
}),
|
|
1110
|
+
!l && /* @__PURE__ */ Y("span", { style: {
|
|
1111
|
+
width: 1,
|
|
1112
|
+
height: 20,
|
|
1113
|
+
background: "var(--divider)"
|
|
1114
|
+
} }),
|
|
1115
|
+
!l && /* @__PURE__ */ Y(S, {
|
|
1116
|
+
icon: /* @__PURE__ */ Y(e.grid, { size: 14 }),
|
|
1117
|
+
title: "Density",
|
|
1118
|
+
active: se !== "compact",
|
|
1119
|
+
onClick: ce
|
|
1120
|
+
}),
|
|
1121
|
+
/* @__PURE__ */ Y(me, {
|
|
1122
|
+
liveObject: {
|
|
1123
|
+
refetch: m.retry,
|
|
1124
|
+
isFetching: m.isFetching,
|
|
1125
|
+
isLoading: m.isLoading,
|
|
1126
|
+
isLive: k
|
|
1127
|
+
},
|
|
1128
|
+
realtime: k
|
|
1129
|
+
}),
|
|
1130
|
+
!l && /* @__PURE__ */ Y("div", { style: { flex: 1 } }),
|
|
1131
|
+
!l && ee && /* @__PURE__ */ Y(w, {
|
|
1132
|
+
kind: "ghost",
|
|
1133
|
+
size: "sm",
|
|
1134
|
+
icon: Y(D ? e.eyeOff : e.eye, { size: 12 }),
|
|
1135
|
+
onClick: O,
|
|
1136
|
+
active: D,
|
|
1137
|
+
children: D ? "Hide deleted" : "Show deleted"
|
|
1138
|
+
}),
|
|
1139
|
+
l && /* @__PURE__ */ X(J, { children: [/* @__PURE__ */ Y(S, {
|
|
1140
|
+
ref: N,
|
|
1141
|
+
icon: /* @__PURE__ */ Y(e.more, { size: 14 }),
|
|
1142
|
+
title: "More",
|
|
1143
|
+
active: ae,
|
|
1144
|
+
onClick: () => j((e) => !e)
|
|
1145
|
+
}), /* @__PURE__ */ X(x, {
|
|
1146
|
+
open: ae,
|
|
1147
|
+
anchor: N.current,
|
|
1148
|
+
onClose: () => j(!1),
|
|
1149
|
+
align: "end",
|
|
1150
|
+
width: 220,
|
|
1151
|
+
children: [/* @__PURE__ */ Y(C, {
|
|
1152
|
+
icon: /* @__PURE__ */ Y(e.grid, { size: 13 }),
|
|
1153
|
+
onClick: () => {
|
|
1154
|
+
ce(), j(!1);
|
|
1155
|
+
},
|
|
1156
|
+
children: "Density"
|
|
1157
|
+
}), ee && /* @__PURE__ */ Y(C, {
|
|
1158
|
+
icon: Y(D ? e.eyeOff : e.eye, { size: 13 }),
|
|
1159
|
+
onClick: () => {
|
|
1160
|
+
O(), j(!1);
|
|
1161
|
+
},
|
|
1162
|
+
children: D ? "Hide deleted" : "Show deleted"
|
|
1163
|
+
})]
|
|
1164
|
+
})] }),
|
|
1165
|
+
r && n && /* @__PURE__ */ Y(pt, {
|
|
1166
|
+
entityCode: r,
|
|
1167
|
+
scope: "list",
|
|
1168
|
+
selectedIds: h.ids,
|
|
1169
|
+
viewState: {
|
|
1170
|
+
screenCode: a,
|
|
1171
|
+
jsonFilters: _.json,
|
|
1172
|
+
search: _.debouncedSearch,
|
|
1173
|
+
sort: d.forRequest,
|
|
1174
|
+
includeDeleted: D || void 0,
|
|
1175
|
+
page: T,
|
|
1176
|
+
perPage: E
|
|
1177
|
+
},
|
|
1178
|
+
locale: c,
|
|
1179
|
+
capability: n.documents,
|
|
1180
|
+
canManageTemplates: B(i)
|
|
1181
|
+
}),
|
|
1182
|
+
r && n && /* @__PURE__ */ Y($t, {
|
|
1183
|
+
entityCode: r,
|
|
1184
|
+
entity: n,
|
|
1185
|
+
screen: t,
|
|
1186
|
+
viewState: {
|
|
1187
|
+
screenCode: a,
|
|
1188
|
+
jsonFilters: _.json,
|
|
1189
|
+
search: _.debouncedSearch,
|
|
1190
|
+
sort: d.forRequest,
|
|
1191
|
+
includeDeleted: D || void 0,
|
|
1192
|
+
page: T,
|
|
1193
|
+
perPage: E
|
|
1194
|
+
},
|
|
1195
|
+
visibleColumns: f.visible,
|
|
1196
|
+
selectedRowPKs: h.pkValues,
|
|
1197
|
+
totalRows: m.countTotal,
|
|
1198
|
+
pageSize: E,
|
|
1199
|
+
locale: c
|
|
1200
|
+
})
|
|
1201
|
+
]
|
|
1202
|
+
});
|
|
1203
|
+
}
|
|
1204
|
+
//#endregion
|
|
1205
|
+
//#region src/components/pages/list/useListViews.ts
|
|
1206
|
+
function rn(e) {
|
|
1207
|
+
let t = new URLSearchParams(), n = e.get("search");
|
|
1208
|
+
n && t.set("search", n);
|
|
1209
|
+
for (let n of k) {
|
|
1210
|
+
let r = e.get(n);
|
|
1211
|
+
r !== null && t.set(n, r);
|
|
1212
|
+
}
|
|
1213
|
+
return t;
|
|
1214
|
+
}
|
|
1215
|
+
function an(e, t) {
|
|
1216
|
+
let n = I(t.id);
|
|
1217
|
+
n && e.setQueriesData({ queryKey: ["entity-data", "view"] }, (e) => !e || e.data.some((e) => I(e.id) === n) ? e : {
|
|
1218
|
+
...e,
|
|
1219
|
+
data: [t, ...e.data]
|
|
1220
|
+
});
|
|
1221
|
+
}
|
|
1222
|
+
function on({ screenCode: e, screen: t, searchParams: n, setSearchParams: r, userId: i, tenantId: a, filterError: o, filters: s, visibleColumns: c, sort: l }) {
|
|
1223
|
+
let u = bt(), d = it(e, i), f = n.get("view"), p = G(() => d.find((e) => e.id === f), [d, f]), m = Ce("view"), h = xe("view"), g = `dcl:smartlist:default-view-cleared:${e}`, _ = K(!1);
|
|
1224
|
+
W(() => {
|
|
1225
|
+
if (_.current) return;
|
|
1226
|
+
if (o) {
|
|
1227
|
+
_.current = !0;
|
|
1228
|
+
return;
|
|
1229
|
+
}
|
|
1230
|
+
if (!d || d.length === 0) return;
|
|
1231
|
+
if (n.get("view")) {
|
|
1232
|
+
_.current = !0;
|
|
1233
|
+
return;
|
|
1234
|
+
}
|
|
1235
|
+
if (typeof window < "u" && window.sessionStorage?.getItem(g)) {
|
|
1236
|
+
_.current = !0;
|
|
1237
|
+
return;
|
|
1238
|
+
}
|
|
1239
|
+
let e = d.find((e) => e.source === "personal" && e.is_default) ?? (t?.default_view ? d.find((e) => e.source === "system" && e.id === t.default_view) : void 0);
|
|
1240
|
+
if (!e || !e.id) return;
|
|
1241
|
+
_.current = !0;
|
|
1242
|
+
let i = rn(n);
|
|
1243
|
+
i.set("view", e.id), e.filters && Array.isArray(e.filters) && e.filters.length > 0 && i.set("filters", JSON.stringify(e.filters)), e.columns && e.columns.length > 0 && i.set("columns", e.columns.join(",")), e.sort && i.set("sort", e.sort), r(i, { replace: !0 });
|
|
1244
|
+
}, [
|
|
1245
|
+
d,
|
|
1246
|
+
o,
|
|
1247
|
+
n,
|
|
1248
|
+
r,
|
|
1249
|
+
g,
|
|
1250
|
+
t?.default_view
|
|
1251
|
+
]);
|
|
1252
|
+
let v = G(() => {
|
|
1253
|
+
if (!f || !p) return !1;
|
|
1254
|
+
let e = p.filters ?? [], n = p.columns?.length ? p.columns : t?.default_columns ?? t?.columns ?? [], r = p.sort ?? t?.sort_default ?? "";
|
|
1255
|
+
return JSON.stringify(s) !== JSON.stringify(e) || c.join(",") !== n.join(",") || (l ?? "") !== r;
|
|
1256
|
+
}, [
|
|
1257
|
+
f,
|
|
1258
|
+
p,
|
|
1259
|
+
s,
|
|
1260
|
+
c,
|
|
1261
|
+
l,
|
|
1262
|
+
t?.default_columns,
|
|
1263
|
+
t?.columns,
|
|
1264
|
+
t?.sort_default
|
|
1265
|
+
]), y = U((e) => {
|
|
1266
|
+
let i = new URLSearchParams(n), a = rn(n);
|
|
1267
|
+
e.id ? (a.set("view", e.id), e.filters && Array.isArray(e.filters) && e.filters.length > 0 && a.set("filters", JSON.stringify(e.filters)), e.columns && e.columns.length > 0 && a.set("columns", e.columns.join(",")), e.sort && a.set("sort", e.sort), a.set("page", "1")) : typeof window < "u" && window.sessionStorage?.setItem(g, "1"), r(a);
|
|
1268
|
+
let o = i.get("view"), s = o ? d.find((e) => e.id === o) : void 0, c = (s?.columns?.length ? s.columns : t?.default_columns ?? t?.columns ?? []).join(",");
|
|
1269
|
+
(i.get("columns") ?? c) !== c && A.info("View applied", "Your unsaved column changes were replaced.", { action: {
|
|
1270
|
+
label: "Undo",
|
|
1271
|
+
onClick: () => r(i)
|
|
1272
|
+
} });
|
|
1273
|
+
}, [
|
|
1274
|
+
n,
|
|
1275
|
+
r,
|
|
1276
|
+
g,
|
|
1277
|
+
d,
|
|
1278
|
+
t?.default_columns,
|
|
1279
|
+
t?.columns
|
|
1280
|
+
]), b = U(async () => {
|
|
1281
|
+
!p?.id || p.source !== "personal" || (await h.mutateAsync({
|
|
1282
|
+
pkValues: p.id,
|
|
1283
|
+
data: {
|
|
1284
|
+
filters: s,
|
|
1285
|
+
columns: c,
|
|
1286
|
+
sort: l ?? null
|
|
1287
|
+
}
|
|
1288
|
+
}), await u.invalidateQueries({ queryKey: ["entity-data", "view"] }));
|
|
1289
|
+
}, [
|
|
1290
|
+
p,
|
|
1291
|
+
h,
|
|
1292
|
+
s,
|
|
1293
|
+
c,
|
|
1294
|
+
l,
|
|
1295
|
+
u
|
|
1296
|
+
]);
|
|
1297
|
+
return {
|
|
1298
|
+
all: d,
|
|
1299
|
+
activeId: f,
|
|
1300
|
+
active: p,
|
|
1301
|
+
isDirty: v,
|
|
1302
|
+
apply: y,
|
|
1303
|
+
saveAsNew: U(async (t) => {
|
|
1304
|
+
if (!i || !a) return;
|
|
1305
|
+
let o = await m.mutateAsync({
|
|
1306
|
+
tenant_id: a,
|
|
1307
|
+
screen_code: e,
|
|
1308
|
+
user_id: i,
|
|
1309
|
+
name: { en: t },
|
|
1310
|
+
filters: s,
|
|
1311
|
+
columns: c,
|
|
1312
|
+
...l ? { sort: l } : {},
|
|
1313
|
+
is_shared: !1,
|
|
1314
|
+
is_default: !1
|
|
1315
|
+
}), d = I(o.data.id);
|
|
1316
|
+
if (!d) return;
|
|
1317
|
+
an(u, o.data), await u.invalidateQueries({ queryKey: ["entity-data", "view"] });
|
|
1318
|
+
let f = new URLSearchParams(n);
|
|
1319
|
+
f.set("view", d), r(f);
|
|
1320
|
+
}, [
|
|
1321
|
+
i,
|
|
1322
|
+
a,
|
|
1323
|
+
m,
|
|
1324
|
+
e,
|
|
1325
|
+
s,
|
|
1326
|
+
c,
|
|
1327
|
+
l,
|
|
1328
|
+
u,
|
|
1329
|
+
n,
|
|
1330
|
+
r
|
|
1331
|
+
]),
|
|
1332
|
+
overwriteActive: b,
|
|
1333
|
+
isSaving: m.isPending || h.isPending
|
|
1334
|
+
};
|
|
1335
|
+
}
|
|
1336
|
+
function sn(e) {
|
|
1337
|
+
return e && e.source === "personal" ? s(e.name) : null;
|
|
1338
|
+
}
|
|
1339
|
+
//#endregion
|
|
1340
|
+
//#region src/components/pages/list/use-filter-value-labels.ts
|
|
1341
|
+
var cn = 200;
|
|
1342
|
+
function ln(e, t, n, r) {
|
|
1343
|
+
let i = new Map(e.map((e) => [e.code, e])), a = un(i, t, n, r), c = yt({ queries: a.map((e) => {
|
|
1344
|
+
let t = {
|
|
1345
|
+
per_page: cn,
|
|
1346
|
+
filters: [{
|
|
1347
|
+
field: e.lookupField,
|
|
1348
|
+
op: "in",
|
|
1349
|
+
value: e.values
|
|
1350
|
+
}],
|
|
1351
|
+
count: "window"
|
|
1352
|
+
};
|
|
1353
|
+
return {
|
|
1354
|
+
queryKey: [
|
|
1355
|
+
"entity-data",
|
|
1356
|
+
e.entity,
|
|
1357
|
+
t
|
|
1358
|
+
],
|
|
1359
|
+
queryFn: ({ signal: n }) => o(e.entity, t, { signal: n }),
|
|
1360
|
+
staleTime: 6e4
|
|
1361
|
+
};
|
|
1362
|
+
}) }), l = {};
|
|
1363
|
+
if (n) for (let [e, t] of Object.entries(n)) l[e] = { ...t };
|
|
1364
|
+
let u = /* @__PURE__ */ new Set();
|
|
1365
|
+
return c.forEach((e, t) => {
|
|
1366
|
+
let n = a[t];
|
|
1367
|
+
if (!n) return;
|
|
1368
|
+
let r = e.data?.data;
|
|
1369
|
+
if (r) {
|
|
1370
|
+
let e = l[n.entity] ??= {};
|
|
1371
|
+
for (let t of r) {
|
|
1372
|
+
let r = I(t[n.lookupField]);
|
|
1373
|
+
r && (e[r] = t);
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
if (e.isLoading) for (let e of n.values) l[n.entity]?.[e] || u.add(`${n.entity}::${e}`);
|
|
1377
|
+
}), {
|
|
1378
|
+
labelFor: (e, t) => {
|
|
1379
|
+
let n = I(t), a = i.get(e);
|
|
1380
|
+
if (!a) return {
|
|
1381
|
+
status: "plain",
|
|
1382
|
+
raw: n
|
|
1383
|
+
};
|
|
1384
|
+
let o = a.specialValues?.find((e) => e.code === n);
|
|
1385
|
+
if (o) return {
|
|
1386
|
+
status: "special",
|
|
1387
|
+
label: s(o.label) || n,
|
|
1388
|
+
raw: n
|
|
1389
|
+
};
|
|
1390
|
+
if (a.options) {
|
|
1391
|
+
let e = a.options.find((e) => e.value === n);
|
|
1392
|
+
if (e) return {
|
|
1393
|
+
status: "resolved",
|
|
1394
|
+
label: e.label,
|
|
1395
|
+
raw: n
|
|
1396
|
+
};
|
|
1397
|
+
}
|
|
1398
|
+
if (a.type === "ref" && a.ref?.entity) {
|
|
1399
|
+
let e = a.ref.entity, t = l[e]?.[n];
|
|
1400
|
+
if (t) {
|
|
1401
|
+
let i = a.ref.display?.field ?? r?.[e]?.display?.display_field;
|
|
1402
|
+
return {
|
|
1403
|
+
status: "resolved",
|
|
1404
|
+
label: f(t, i, n),
|
|
1405
|
+
raw: n
|
|
1406
|
+
};
|
|
1407
|
+
}
|
|
1408
|
+
return u.has(`${e}::${n}`) ? {
|
|
1409
|
+
status: "loading",
|
|
1410
|
+
raw: n
|
|
1411
|
+
} : {
|
|
1412
|
+
status: "unresolved",
|
|
1413
|
+
raw: n
|
|
1414
|
+
};
|
|
1415
|
+
}
|
|
1416
|
+
return {
|
|
1417
|
+
status: "plain",
|
|
1418
|
+
raw: n
|
|
1419
|
+
};
|
|
1420
|
+
},
|
|
1421
|
+
refs: l
|
|
1422
|
+
};
|
|
1423
|
+
}
|
|
1424
|
+
function un(e, t, n, r) {
|
|
1425
|
+
let i = /* @__PURE__ */ new Map();
|
|
1426
|
+
for (let a of Ze(t)) {
|
|
1427
|
+
if (!a.field) continue;
|
|
1428
|
+
let t = e.get(a.field);
|
|
1429
|
+
if (!t || t.type !== "ref" || !t.ref?.entity) continue;
|
|
1430
|
+
let o = t.ref.entity, s = r?.[o], l = t.ref.field || (s ? c(s)[0] : "id") || "id", u = Array.isArray(a.value) ? a.value : [a.value];
|
|
1431
|
+
for (let e of u) {
|
|
1432
|
+
let r = I(e);
|
|
1433
|
+
if (!r || t.specialValues?.some((e) => e.code === r) || n?.[o]?.[r]) continue;
|
|
1434
|
+
let a = `${o}::${l}`, s = i.get(a);
|
|
1435
|
+
s || (s = {
|
|
1436
|
+
key: a,
|
|
1437
|
+
entity: o,
|
|
1438
|
+
lookupField: l,
|
|
1439
|
+
values: []
|
|
1440
|
+
}, i.set(a, s)), s.values.includes(r) || s.values.push(r);
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
let a = [...i.values()];
|
|
1444
|
+
for (let e of a) e.values.sort();
|
|
1445
|
+
return a.sort((e, t) => e.key.localeCompare(t.key)), a;
|
|
1446
|
+
}
|
|
1447
|
+
//#endregion
|
|
1448
|
+
//#region src/components/pages/list/SaveViewDialog.tsx
|
|
1449
|
+
function dn({ open: e, pending: t, onClose: n, onSave: r, overwriteViewName: i, onOverwrite: a }) {
|
|
1450
|
+
let [o, s] = q(""), c = !!(i && a);
|
|
1451
|
+
if (W(() => {
|
|
1452
|
+
e && s("");
|
|
1453
|
+
}, [e]), !e) return null;
|
|
1454
|
+
let l = o.trim();
|
|
1455
|
+
return /* @__PURE__ */ X(J, { children: [/* @__PURE__ */ Y("div", {
|
|
1456
|
+
onClick: n,
|
|
1457
|
+
style: {
|
|
1458
|
+
position: "fixed",
|
|
1459
|
+
inset: 0,
|
|
1460
|
+
background: "var(--scrim)",
|
|
1461
|
+
zIndex: 70
|
|
1462
|
+
}
|
|
1463
|
+
}), /* @__PURE__ */ X("div", {
|
|
1464
|
+
role: "dialog",
|
|
1465
|
+
"aria-label": "Save view",
|
|
1466
|
+
"aria-modal": "true",
|
|
1467
|
+
style: {
|
|
1468
|
+
position: "fixed",
|
|
1469
|
+
top: "50%",
|
|
1470
|
+
left: "50%",
|
|
1471
|
+
transform: "translate(-50%, -50%)",
|
|
1472
|
+
width: 360,
|
|
1473
|
+
maxWidth: "calc(100vw - 32px)",
|
|
1474
|
+
background: "var(--surface)",
|
|
1475
|
+
border: "1px solid var(--border)",
|
|
1476
|
+
borderRadius: 10,
|
|
1477
|
+
boxShadow: "var(--shadow-lg)",
|
|
1478
|
+
zIndex: 80,
|
|
1479
|
+
padding: 16,
|
|
1480
|
+
display: "flex",
|
|
1481
|
+
flexDirection: "column",
|
|
1482
|
+
gap: 12
|
|
1483
|
+
},
|
|
1484
|
+
children: [
|
|
1485
|
+
/* @__PURE__ */ X("div", { children: [/* @__PURE__ */ Y("h3", {
|
|
1486
|
+
style: {
|
|
1487
|
+
margin: 0,
|
|
1488
|
+
fontSize: 14,
|
|
1489
|
+
color: "var(--text)"
|
|
1490
|
+
},
|
|
1491
|
+
children: "Save view"
|
|
1492
|
+
}), /* @__PURE__ */ Y("p", {
|
|
1493
|
+
style: {
|
|
1494
|
+
margin: "4px 0 0",
|
|
1495
|
+
fontSize: 12,
|
|
1496
|
+
color: "var(--text-3)"
|
|
1497
|
+
},
|
|
1498
|
+
children: "Views save columns, order, filters, and sort. Widths stay personal to this device and are never part of a view."
|
|
1499
|
+
})] }),
|
|
1500
|
+
/* @__PURE__ */ X("label", {
|
|
1501
|
+
style: {
|
|
1502
|
+
display: "flex",
|
|
1503
|
+
flexDirection: "column",
|
|
1504
|
+
gap: 4
|
|
1505
|
+
},
|
|
1506
|
+
children: [/* @__PURE__ */ Y("span", {
|
|
1507
|
+
style: {
|
|
1508
|
+
fontSize: 11.5,
|
|
1509
|
+
color: "var(--text-3)",
|
|
1510
|
+
fontWeight: 500
|
|
1511
|
+
},
|
|
1512
|
+
children: "Name"
|
|
1513
|
+
}), /* @__PURE__ */ Y(g, {
|
|
1514
|
+
autoFocus: !0,
|
|
1515
|
+
"aria-label": "View name",
|
|
1516
|
+
value: o,
|
|
1517
|
+
onChange: s,
|
|
1518
|
+
placeholder: "My filtered view",
|
|
1519
|
+
onKeyDown: (e) => {
|
|
1520
|
+
e.key === "Escape" && n(), e.key === "Enter" && l && !t && r(l);
|
|
1521
|
+
}
|
|
1522
|
+
})]
|
|
1523
|
+
}),
|
|
1524
|
+
/* @__PURE__ */ X("div", {
|
|
1525
|
+
style: {
|
|
1526
|
+
display: "flex",
|
|
1527
|
+
justifyContent: "flex-end",
|
|
1528
|
+
gap: 8
|
|
1529
|
+
},
|
|
1530
|
+
children: [
|
|
1531
|
+
/* @__PURE__ */ Y(w, {
|
|
1532
|
+
onClick: n,
|
|
1533
|
+
disabled: t,
|
|
1534
|
+
children: "Cancel"
|
|
1535
|
+
}),
|
|
1536
|
+
c && /* @__PURE__ */ X(w, {
|
|
1537
|
+
onClick: () => void a(),
|
|
1538
|
+
disabled: t,
|
|
1539
|
+
children: [
|
|
1540
|
+
"Overwrite “",
|
|
1541
|
+
i,
|
|
1542
|
+
"”"
|
|
1543
|
+
]
|
|
1544
|
+
}),
|
|
1545
|
+
/* @__PURE__ */ Y(w, {
|
|
1546
|
+
kind: "primary",
|
|
1547
|
+
onClick: () => void r(l),
|
|
1548
|
+
disabled: !l || t,
|
|
1549
|
+
children: "Save as new"
|
|
1550
|
+
})
|
|
1551
|
+
]
|
|
1552
|
+
})
|
|
1553
|
+
]
|
|
1554
|
+
})] });
|
|
1555
|
+
}
|
|
1556
|
+
//#endregion
|
|
1557
|
+
//#region src/components/pages/list/ListHeader.tsx
|
|
1558
|
+
function fn({ title: t, description: n, toolbarActions: r, screenActionLayout: i, entityActionLayout: a, selectedIds: o, data: c, rowKey: l, onActionSuccess: u, widgetContext: d }) {
|
|
1559
|
+
let { run: f } = D(), { isPhone: p } = ie(), m = pe("list"), h = m.isVisible("show_title"), g = m.isVisible("show_actions"), v = be(), y = G(() => {
|
|
1560
|
+
let e = {};
|
|
1561
|
+
for (let { code: t, action: n } of r) e[t] = n;
|
|
1562
|
+
return e;
|
|
1563
|
+
}, [r]), x = G(() => P((i ?? a) || M(y, "list_toolbar"), y, void 0, "list_toolbar"), [
|
|
1564
|
+
i,
|
|
1565
|
+
a,
|
|
1566
|
+
y
|
|
1567
|
+
]), C = G(() => le(x, y, void 0, E, "Select one or more rows first"), [x, y]), w = G(() => {
|
|
1568
|
+
if (o.length === 0) return [];
|
|
1569
|
+
let e = /* @__PURE__ */ new Map();
|
|
1570
|
+
for (let t of c) e.set(l(t), t);
|
|
1571
|
+
return o.map((t) => e.get(t)).filter((e) => e !== void 0);
|
|
1572
|
+
}, [
|
|
1573
|
+
o,
|
|
1574
|
+
c,
|
|
1575
|
+
l
|
|
1576
|
+
]), ee = G(() => _(x, y, void 0, {}, w), [
|
|
1577
|
+
x,
|
|
1578
|
+
y,
|
|
1579
|
+
w
|
|
1580
|
+
]), te = o.length > 0 ? ee : C, O = (e, t) => {
|
|
1581
|
+
let n = Re(e, t, {});
|
|
1582
|
+
if (n === null) return;
|
|
1583
|
+
let r = s(t.display?.name) || e;
|
|
1584
|
+
return f({
|
|
1585
|
+
action: t,
|
|
1586
|
+
title: r,
|
|
1587
|
+
bulkSelection: w.length > 0 ? w : void 0,
|
|
1588
|
+
execute: async (e) => {
|
|
1589
|
+
let t = o.length > 0 ? o : void 0, r = await b(n, T(e, t));
|
|
1590
|
+
return t && t.length > 0 && u(), r;
|
|
1591
|
+
}
|
|
1592
|
+
});
|
|
1593
|
+
};
|
|
1594
|
+
return !h && !g ? null : /* @__PURE__ */ X("div", {
|
|
1595
|
+
style: {
|
|
1596
|
+
display: "flex",
|
|
1597
|
+
alignItems: "center",
|
|
1598
|
+
gap: 8,
|
|
1599
|
+
flexWrap: p ? "wrap" : "nowrap",
|
|
1600
|
+
paddingTop: p ? 12 : 16,
|
|
1601
|
+
paddingBottom: 10,
|
|
1602
|
+
...p ? ye(12) : {
|
|
1603
|
+
paddingLeft: 20,
|
|
1604
|
+
paddingRight: 20
|
|
1605
|
+
}
|
|
1606
|
+
},
|
|
1607
|
+
children: [
|
|
1608
|
+
h && v.hasOriginBack && /* @__PURE__ */ Y(S, {
|
|
1609
|
+
icon: /* @__PURE__ */ Y(e.back, { size: 14 }),
|
|
1610
|
+
title: "Back",
|
|
1611
|
+
onClick: v.goBack
|
|
1612
|
+
}),
|
|
1613
|
+
h && /* @__PURE__ */ Y("div", {
|
|
1614
|
+
style: {
|
|
1615
|
+
flex: p ? "1 1 100%" : "1 1 auto",
|
|
1616
|
+
minWidth: 0
|
|
1617
|
+
},
|
|
1618
|
+
children: /* @__PURE__ */ X("div", {
|
|
1619
|
+
style: {
|
|
1620
|
+
display: "flex",
|
|
1621
|
+
alignItems: "baseline",
|
|
1622
|
+
gap: 10
|
|
1623
|
+
},
|
|
1624
|
+
children: [/* @__PURE__ */ Y("h1", {
|
|
1625
|
+
style: {
|
|
1626
|
+
margin: 0,
|
|
1627
|
+
minWidth: 0,
|
|
1628
|
+
overflow: "hidden",
|
|
1629
|
+
textOverflow: "ellipsis",
|
|
1630
|
+
whiteSpace: "nowrap",
|
|
1631
|
+
fontSize: "var(--page-title-size, var(--page-title-size-list))",
|
|
1632
|
+
lineHeight: "var(--page-title-line-height, var(--page-title-line-height-list))",
|
|
1633
|
+
fontWeight: 600,
|
|
1634
|
+
letterSpacing: "-0.012em",
|
|
1635
|
+
color: "var(--text)"
|
|
1636
|
+
},
|
|
1637
|
+
children: t
|
|
1638
|
+
}), n && /* @__PURE__ */ Y(fe, {
|
|
1639
|
+
label: n,
|
|
1640
|
+
"data-testid": "list-description-info"
|
|
1641
|
+
})]
|
|
1642
|
+
})
|
|
1643
|
+
}),
|
|
1644
|
+
g && te.length > 0 && /* @__PURE__ */ Y(ke, {
|
|
1645
|
+
layout: te,
|
|
1646
|
+
kind: "toolbar",
|
|
1647
|
+
entityActions: y,
|
|
1648
|
+
onRun: O,
|
|
1649
|
+
widgetContext: d,
|
|
1650
|
+
ariaLabel: "List toolbar actions"
|
|
1651
|
+
})
|
|
1652
|
+
]
|
|
1653
|
+
});
|
|
1654
|
+
}
|
|
1655
|
+
//#endregion
|
|
1656
|
+
//#region src/components/pages/list/ListFloatbar.tsx
|
|
1657
|
+
function pn({ selectedIds: t, floatbarActions: n, screenActionLayout: r, entityActionLayout: i, data: a, rowKey: o, entityCode: c, entity: l, screen: u, onClear: d, onActionSuccess: f, widgetContext: p }) {
|
|
1658
|
+
let { run: m } = D(), h = G(() => {
|
|
1659
|
+
let e = {};
|
|
1660
|
+
for (let { code: t, action: r } of n) e[t] = r;
|
|
1661
|
+
return e;
|
|
1662
|
+
}, [n]), g = G(() => {
|
|
1663
|
+
if (t.length === 0) return [];
|
|
1664
|
+
let e = /* @__PURE__ */ new Map();
|
|
1665
|
+
for (let t of a) e.set(o(t), t);
|
|
1666
|
+
return t.map((t) => e.get(t)).filter((e) => e !== void 0);
|
|
1667
|
+
}, [
|
|
1668
|
+
t,
|
|
1669
|
+
a,
|
|
1670
|
+
o
|
|
1671
|
+
]), v = G(() => {
|
|
1672
|
+
if (!l || !u || g.length === 0) return r;
|
|
1673
|
+
let e = g.map((e) => Oe(l, u, e));
|
|
1674
|
+
return e.some((t) => t !== e[0]) ? r : Le(l, u, g[0])?.action_layout;
|
|
1675
|
+
}, [
|
|
1676
|
+
l,
|
|
1677
|
+
u,
|
|
1678
|
+
g,
|
|
1679
|
+
r
|
|
1680
|
+
]), y = G(() => P((v ?? i) || M(h, "list_floatbar"), h, void 0, "list_floatbar"), [
|
|
1681
|
+
v,
|
|
1682
|
+
i,
|
|
1683
|
+
h
|
|
1684
|
+
]), x = G(() => _(y, h, void 0, {}, g, Pe(l, g)), [
|
|
1685
|
+
y,
|
|
1686
|
+
h,
|
|
1687
|
+
g,
|
|
1688
|
+
l
|
|
1689
|
+
]);
|
|
1690
|
+
return x.length === 0 ? null : /* @__PURE__ */ X("div", {
|
|
1691
|
+
style: {
|
|
1692
|
+
position: "fixed",
|
|
1693
|
+
left: "50%",
|
|
1694
|
+
bottom: "calc(var(--tabbar-h) + var(--safe-area-bottom) + 14px)",
|
|
1695
|
+
transform: "translateX(-50%)",
|
|
1696
|
+
zIndex: 45,
|
|
1697
|
+
display: "flex",
|
|
1698
|
+
alignItems: "center",
|
|
1699
|
+
flexWrap: "wrap",
|
|
1700
|
+
gap: 8,
|
|
1701
|
+
padding: "6px 10px 6px 14px",
|
|
1702
|
+
maxWidth: "calc(100vw - var(--safe-area-left) - var(--safe-area-right) - 24px)",
|
|
1703
|
+
boxSizing: "border-box",
|
|
1704
|
+
background: "var(--text)",
|
|
1705
|
+
color: "var(--background)",
|
|
1706
|
+
borderRadius: 10,
|
|
1707
|
+
boxShadow: "var(--shadow-lg)",
|
|
1708
|
+
animation: "floatbarIn .15s ease-out"
|
|
1709
|
+
},
|
|
1710
|
+
children: [
|
|
1711
|
+
/* @__PURE__ */ Y("style", { children: "@keyframes floatbarIn{from{transform:translateX(-50%) translateY(8px);opacity:0}to{transform:translateX(-50%) translateY(0);opacity:1}}" }),
|
|
1712
|
+
/* @__PURE__ */ X("span", {
|
|
1713
|
+
style: {
|
|
1714
|
+
fontSize: 12.5,
|
|
1715
|
+
fontWeight: 600
|
|
1716
|
+
},
|
|
1717
|
+
children: [/* @__PURE__ */ Y("span", {
|
|
1718
|
+
style: {
|
|
1719
|
+
padding: "1px 7px",
|
|
1720
|
+
borderRadius: 4,
|
|
1721
|
+
background: "var(--accent)",
|
|
1722
|
+
color: "var(--accent-foreground)",
|
|
1723
|
+
marginRight: 6,
|
|
1724
|
+
fontSize: 11.5
|
|
1725
|
+
},
|
|
1726
|
+
children: t.length
|
|
1727
|
+
}), "selected"]
|
|
1728
|
+
}),
|
|
1729
|
+
/* @__PURE__ */ Y(ke, {
|
|
1730
|
+
layout: x,
|
|
1731
|
+
kind: "toolbar",
|
|
1732
|
+
entityActions: h,
|
|
1733
|
+
rowSelection: g,
|
|
1734
|
+
onRun: (e, n) => {
|
|
1735
|
+
let r = Re(e, n, {}, c);
|
|
1736
|
+
if (r !== null) return m({
|
|
1737
|
+
action: n,
|
|
1738
|
+
title: s(n.display?.name) || e,
|
|
1739
|
+
bulkSelection: g,
|
|
1740
|
+
entity: c,
|
|
1741
|
+
execute: async (e) => {
|
|
1742
|
+
let n = await b(r, T(e, t));
|
|
1743
|
+
return f(), n;
|
|
1744
|
+
}
|
|
1745
|
+
});
|
|
1746
|
+
},
|
|
1747
|
+
widgetContext: p,
|
|
1748
|
+
ariaLabel: "Floating action bar",
|
|
1749
|
+
constrain: !1
|
|
1750
|
+
}),
|
|
1751
|
+
/* @__PURE__ */ Y("button", {
|
|
1752
|
+
onClick: d,
|
|
1753
|
+
style: {
|
|
1754
|
+
background: "none",
|
|
1755
|
+
border: "none",
|
|
1756
|
+
color: "var(--background)",
|
|
1757
|
+
cursor: "pointer",
|
|
1758
|
+
opacity: .6,
|
|
1759
|
+
padding: "4px 6px",
|
|
1760
|
+
borderRadius: 6
|
|
1761
|
+
},
|
|
1762
|
+
title: "Clear selection",
|
|
1763
|
+
children: /* @__PURE__ */ Y(e.x, { size: 14 })
|
|
1764
|
+
})
|
|
1765
|
+
]
|
|
1766
|
+
});
|
|
1767
|
+
}
|
|
1768
|
+
//#endregion
|
|
1769
|
+
//#region src/components/pages/list/useRowMenu.ts
|
|
1770
|
+
function mn(e, t) {
|
|
1771
|
+
let n = (e) => e === "__peek" && !t.peek || e === "__open" && !t.open, r = [];
|
|
1772
|
+
for (let i of e) if (i.kind === "action") {
|
|
1773
|
+
if (n(i.code)) continue;
|
|
1774
|
+
r.push(i);
|
|
1775
|
+
} else {
|
|
1776
|
+
let e = mn(i.items, t);
|
|
1777
|
+
e.length > 0 && r.push({
|
|
1778
|
+
...i,
|
|
1779
|
+
items: e
|
|
1780
|
+
});
|
|
1781
|
+
}
|
|
1782
|
+
return r;
|
|
1783
|
+
}
|
|
1784
|
+
function hn(e, t) {
|
|
1785
|
+
for (let n of e) if (n.kind === "action") {
|
|
1786
|
+
if (n.code === t) return !0;
|
|
1787
|
+
} else if (hn(n.items, t)) return !0;
|
|
1788
|
+
return !1;
|
|
1789
|
+
}
|
|
1790
|
+
function gn({ row: e, rowId: t, screen: n, fullScreen: r, entity: i, entityCode: a, rowActions: o, tabNavigate: c, locale: l, peekAllowed: u, hasDetailTarget: d, onPeek: f }) {
|
|
1791
|
+
let { run: p } = D(), m = r.detail_screen === void 0 && n.detail_screen !== void 0 ? {
|
|
1792
|
+
...r,
|
|
1793
|
+
detail_screen: n.detail_screen
|
|
1794
|
+
} : r, h = Le(i, m, e) ?? m, g = G(() => {
|
|
1795
|
+
let e = {}, t = h.row_actions === void 0 ? void 0 : new Set(h.row_actions);
|
|
1796
|
+
for (let { code: n, action: r } of o) (!t || t.has(n)) && (e[n] = r);
|
|
1797
|
+
return e;
|
|
1798
|
+
}, [o, h.row_actions]), v = G(() => ({
|
|
1799
|
+
entity: i,
|
|
1800
|
+
entityCode: a ?? "",
|
|
1801
|
+
screen: h,
|
|
1802
|
+
screenRoute: h.route,
|
|
1803
|
+
selectedRows: [],
|
|
1804
|
+
selectedIds: [],
|
|
1805
|
+
locale: l,
|
|
1806
|
+
tabNavigate: (e, t) => c(e, {
|
|
1807
|
+
title: t?.title,
|
|
1808
|
+
icon: t?.icon,
|
|
1809
|
+
search: t?.search
|
|
1810
|
+
}),
|
|
1811
|
+
runActionApi: (e, t) => b(e, t),
|
|
1812
|
+
openPeek: (t) => f(t ?? e)
|
|
1813
|
+
}), [
|
|
1814
|
+
i,
|
|
1815
|
+
a,
|
|
1816
|
+
h,
|
|
1817
|
+
l,
|
|
1818
|
+
c,
|
|
1819
|
+
f,
|
|
1820
|
+
e
|
|
1821
|
+
]), y = G(() => {
|
|
1822
|
+
let e = h.action_layout ?? null, t = i.action_layout ?? null, n = e ?? t ?? M(g, "list_row");
|
|
1823
|
+
return P(n, g, void 0, "list_row");
|
|
1824
|
+
}, [
|
|
1825
|
+
h,
|
|
1826
|
+
i,
|
|
1827
|
+
g
|
|
1828
|
+
]), x = G(() => mn(_(y, g, void 0, e, [], Fe(i, e)), {
|
|
1829
|
+
peek: u,
|
|
1830
|
+
open: d
|
|
1831
|
+
}), [
|
|
1832
|
+
y,
|
|
1833
|
+
g,
|
|
1834
|
+
e,
|
|
1835
|
+
i,
|
|
1836
|
+
u,
|
|
1837
|
+
d
|
|
1838
|
+
]);
|
|
1839
|
+
return {
|
|
1840
|
+
layout: x,
|
|
1841
|
+
entityActions: g,
|
|
1842
|
+
runRowAction: U((n, r) => {
|
|
1843
|
+
let i = Re(n, r, { row: e });
|
|
1844
|
+
if (i !== null) return p({
|
|
1845
|
+
action: r,
|
|
1846
|
+
title: s(r.display?.name) || n,
|
|
1847
|
+
row: e,
|
|
1848
|
+
execute: (e) => b(i, T(e, [t]))
|
|
1849
|
+
});
|
|
1850
|
+
}, [
|
|
1851
|
+
p,
|
|
1852
|
+
t,
|
|
1853
|
+
e
|
|
1854
|
+
]),
|
|
1855
|
+
widgetContext: v,
|
|
1856
|
+
hasPeek: G(() => hn(x, O), [x])
|
|
1857
|
+
};
|
|
1858
|
+
}
|
|
1859
|
+
//#endregion
|
|
1860
|
+
//#region src/components/pages/list/RowActionsCell.tsx
|
|
1861
|
+
function _n({ row: t, rowId: n, screen: r, fullScreen: i, entity: a, entityCode: o, rowActions: s, tabNavigate: c, peekAllowed: l, hasDetailTarget: u, onPeek: d, locale: f }) {
|
|
1862
|
+
let { layout: p, entityActions: m, runRowAction: h, widgetContext: g, hasPeek: _ } = gn({
|
|
1863
|
+
row: t,
|
|
1864
|
+
rowId: n,
|
|
1865
|
+
screen: r,
|
|
1866
|
+
fullScreen: i,
|
|
1867
|
+
entity: a,
|
|
1868
|
+
entityCode: o,
|
|
1869
|
+
rowActions: s,
|
|
1870
|
+
tabNavigate: c,
|
|
1871
|
+
locale: f,
|
|
1872
|
+
peekAllowed: l,
|
|
1873
|
+
hasDetailTarget: u,
|
|
1874
|
+
onPeek: d
|
|
1875
|
+
});
|
|
1876
|
+
return /* @__PURE__ */ X("div", {
|
|
1877
|
+
className: "sl-row-actions",
|
|
1878
|
+
style: {
|
|
1879
|
+
display: "flex",
|
|
1880
|
+
alignItems: "center",
|
|
1881
|
+
gap: 2,
|
|
1882
|
+
justifyContent: "flex-end"
|
|
1883
|
+
},
|
|
1884
|
+
children: [_ && /* @__PURE__ */ Y(S, {
|
|
1885
|
+
size: 22,
|
|
1886
|
+
icon: /* @__PURE__ */ Y(e.eye, { size: 12 }),
|
|
1887
|
+
onClick: (e) => {
|
|
1888
|
+
e.stopPropagation(), d(t);
|
|
1889
|
+
},
|
|
1890
|
+
title: "Peek"
|
|
1891
|
+
}), p.length > 0 && /* @__PURE__ */ Y(ke, {
|
|
1892
|
+
layout: p,
|
|
1893
|
+
row: t,
|
|
1894
|
+
kind: "row",
|
|
1895
|
+
entityActions: m,
|
|
1896
|
+
onRun: h,
|
|
1897
|
+
widgetContext: g,
|
|
1898
|
+
ariaLabel: "Row actions"
|
|
1899
|
+
})]
|
|
1900
|
+
});
|
|
1901
|
+
}
|
|
1902
|
+
//#endregion
|
|
1903
|
+
//#region src/components/pages/list/columns.ts
|
|
1904
|
+
function vn(t, n, r, i) {
|
|
1905
|
+
let a = Te(n, r);
|
|
1906
|
+
if (!a || a.read !== "denied") return i ? V("span", { title: i }, t) : t;
|
|
1907
|
+
let o = a.required_permission ? `Locked column: requires "${a.required_permission}"` : `Locked column: ${a.classification} classification`;
|
|
1908
|
+
return V("span", {
|
|
1909
|
+
title: o,
|
|
1910
|
+
"aria-label": o,
|
|
1911
|
+
className: "inline-flex items-center gap-1"
|
|
1912
|
+
}, V(e.lock, { size: 12 }), t);
|
|
1913
|
+
}
|
|
1914
|
+
function Q(e) {
|
|
1915
|
+
return {
|
|
1916
|
+
minSize: Math.min(60, e),
|
|
1917
|
+
maxSize: Math.max(De, e)
|
|
1918
|
+
};
|
|
1919
|
+
}
|
|
1920
|
+
function yn(e) {
|
|
1921
|
+
let { visibleCols: t, entity: n, screen: r, schema: i, entityCode: a, rowActions: o, hasBatchActions: c, hasExplicitRowActions: l, canUpdate: d, canDelete: f, peekEnabled: p, hasDetailTarget: m, userLocale: h, tabNavigate: g, refsRef: _, rowSelectionKey: v, setPeekRow: y } = e;
|
|
1922
|
+
if (t.length === 0 || !n) return [];
|
|
1923
|
+
let b = [];
|
|
1924
|
+
c && b.push({
|
|
1925
|
+
id: "_select",
|
|
1926
|
+
enableResizing: !1,
|
|
1927
|
+
header: ({ table: e }) => V(he, {
|
|
1928
|
+
checked: e.getIsAllRowsSelected(),
|
|
1929
|
+
indeterminate: e.getIsSomeRowsSelected(),
|
|
1930
|
+
onChange: () => e.toggleAllRowsSelected()
|
|
1931
|
+
}),
|
|
1932
|
+
size: 34,
|
|
1933
|
+
cell: ({ row: e }) => V("span", { "data-testid": "row-select-checkbox" }, V(he, {
|
|
1934
|
+
checked: e.getIsSelected(),
|
|
1935
|
+
onChange: () => e.toggleSelected()
|
|
1936
|
+
}))
|
|
1937
|
+
});
|
|
1938
|
+
for (let e of t) {
|
|
1939
|
+
if (e.startsWith("$status.")) {
|
|
1940
|
+
let t = e.slice(8), r = n.status_groups?.[t];
|
|
1941
|
+
if (!r) continue;
|
|
1942
|
+
let i = new Map(r.statuses.map((e) => [e.code, e]));
|
|
1943
|
+
b.push({
|
|
1944
|
+
id: e,
|
|
1945
|
+
header: s(r.name) || t,
|
|
1946
|
+
size: 140,
|
|
1947
|
+
...Q(140),
|
|
1948
|
+
cell: ({ row: e }) => {
|
|
1949
|
+
let n = e.original.$statuses?.find((e) => e.group_code === t);
|
|
1950
|
+
if (!n) return V("span", { className: "text-sm text-muted-foreground" }, "-");
|
|
1951
|
+
let r = i.get(n.status_code);
|
|
1952
|
+
return V(oe, {
|
|
1953
|
+
tone: r?.color ?? "slate",
|
|
1954
|
+
size: "xs"
|
|
1955
|
+
}, s(r?.name) || n.status_code);
|
|
1956
|
+
}
|
|
1957
|
+
});
|
|
1958
|
+
continue;
|
|
1959
|
+
}
|
|
1960
|
+
if (e.startsWith("$property.")) {
|
|
1961
|
+
let t = e.slice(10), r = n.properties?.[t];
|
|
1962
|
+
if (!r) continue;
|
|
1963
|
+
b.push({
|
|
1964
|
+
id: e,
|
|
1965
|
+
header: () => vn(s(r.name) || t, n, t, s(r.description) || void 0),
|
|
1966
|
+
size: 150,
|
|
1967
|
+
...Q(150),
|
|
1968
|
+
enableSorting: !1,
|
|
1969
|
+
cell: ({ row: e }) => {
|
|
1970
|
+
let n = e.original.$properties?.find((e) => e.property_code === t);
|
|
1971
|
+
return !n || n.value == null ? V("span", { className: "text-sm text-muted-foreground" }, "-") : V("span", { className: "text-sm" }, I(n.value));
|
|
1972
|
+
}
|
|
1973
|
+
});
|
|
1974
|
+
continue;
|
|
1975
|
+
}
|
|
1976
|
+
if (e === "$evidence") {
|
|
1977
|
+
b.push({
|
|
1978
|
+
id: e,
|
|
1979
|
+
header: "Evidence",
|
|
1980
|
+
size: 140,
|
|
1981
|
+
...Q(140),
|
|
1982
|
+
enableSorting: !1,
|
|
1983
|
+
cell: ({ row: e }) => {
|
|
1984
|
+
let t = e.original.$evidence?.verdict ?? "unverified";
|
|
1985
|
+
return V(oe, {
|
|
1986
|
+
tone: ut(t),
|
|
1987
|
+
size: "xs",
|
|
1988
|
+
dot: !0
|
|
1989
|
+
}, ft(t));
|
|
1990
|
+
}
|
|
1991
|
+
});
|
|
1992
|
+
continue;
|
|
1993
|
+
}
|
|
1994
|
+
if (n.files?.get(e)) {
|
|
1995
|
+
b.push({
|
|
1996
|
+
id: e,
|
|
1997
|
+
accessorFn: (t) => t.$files?.[e] ?? null,
|
|
1998
|
+
header: () => vn(Ne(n, e, i?.entities), n, e),
|
|
1999
|
+
size: 150,
|
|
2000
|
+
...Q(150),
|
|
2001
|
+
cell: ({ row: t }) => Ie({
|
|
2002
|
+
entity: n,
|
|
2003
|
+
entityCode: a,
|
|
2004
|
+
fieldName: e,
|
|
2005
|
+
record: t.original,
|
|
2006
|
+
mode: "display",
|
|
2007
|
+
surface: "list",
|
|
2008
|
+
refs: _.current,
|
|
2009
|
+
locale: h
|
|
2010
|
+
})
|
|
2011
|
+
});
|
|
2012
|
+
continue;
|
|
2013
|
+
}
|
|
2014
|
+
let t = n.fields.get(e);
|
|
2015
|
+
if (!t) continue;
|
|
2016
|
+
let r = ce(t, e, i?.entities), o = t.display?.width, c = u({
|
|
2017
|
+
field: t,
|
|
2018
|
+
fieldName: e,
|
|
2019
|
+
surface: "list",
|
|
2020
|
+
entity: n,
|
|
2021
|
+
entities: i?.entities,
|
|
2022
|
+
screens: i?.screens,
|
|
2023
|
+
refs: () => _.current,
|
|
2024
|
+
locale: h
|
|
2025
|
+
});
|
|
2026
|
+
b.push({
|
|
2027
|
+
id: e,
|
|
2028
|
+
accessorKey: e,
|
|
2029
|
+
header: () => vn(r, n, e, s(t.display?.description) || void 0),
|
|
2030
|
+
enableSorting: t.type !== "json",
|
|
2031
|
+
size: o ?? 150,
|
|
2032
|
+
...Q(o ?? 150),
|
|
2033
|
+
cell: ({ getValue: e, row: t }) => c(e(), t.original)
|
|
2034
|
+
});
|
|
2035
|
+
}
|
|
2036
|
+
return (!l && d || !l && f || o.length > 0) && b.push({
|
|
2037
|
+
id: "_actions",
|
|
2038
|
+
enableResizing: !1,
|
|
2039
|
+
header: "",
|
|
2040
|
+
size: 40,
|
|
2041
|
+
cell: ({ row: e }) => V(_n, {
|
|
2042
|
+
row: e.original,
|
|
2043
|
+
rowId: v(n, e.original),
|
|
2044
|
+
screen: r,
|
|
2045
|
+
fullScreen: r,
|
|
2046
|
+
entity: n,
|
|
2047
|
+
entityCode: a,
|
|
2048
|
+
rowActions: o,
|
|
2049
|
+
tabNavigate: g,
|
|
2050
|
+
peekAllowed: p,
|
|
2051
|
+
hasDetailTarget: m,
|
|
2052
|
+
onPeek: y,
|
|
2053
|
+
locale: h
|
|
2054
|
+
})
|
|
2055
|
+
}), b;
|
|
2056
|
+
}
|
|
2057
|
+
//#endregion
|
|
2058
|
+
//#region src/components/pages/list/RowContextMenu.tsx
|
|
2059
|
+
function bn({ x: e, y: t, row: n, rowId: r, screen: i, fullScreen: a, entity: o, entityCode: s, rowActions: c, tabNavigate: l, locale: u, peekAllowed: d, hasDetailTarget: f, onPeek: p, onClose: m }) {
|
|
2060
|
+
let { layout: h, entityActions: g, runRowAction: _, widgetContext: v } = gn({
|
|
2061
|
+
row: n,
|
|
2062
|
+
rowId: r,
|
|
2063
|
+
screen: i,
|
|
2064
|
+
fullScreen: a,
|
|
2065
|
+
entity: o,
|
|
2066
|
+
entityCode: s,
|
|
2067
|
+
rowActions: c,
|
|
2068
|
+
tabNavigate: l,
|
|
2069
|
+
locale: u,
|
|
2070
|
+
peekAllowed: d,
|
|
2071
|
+
hasDetailTarget: f,
|
|
2072
|
+
onPeek: p
|
|
2073
|
+
}), [y, b] = q(null), S = U((e, t) => (m(), _(e, t)), [m, _]);
|
|
2074
|
+
return h.length === 0 ? null : /* @__PURE__ */ X(J, { children: [/* @__PURE__ */ Y("div", {
|
|
2075
|
+
onClick: m,
|
|
2076
|
+
onContextMenu: (e) => {
|
|
2077
|
+
e.preventDefault(), m();
|
|
2078
|
+
},
|
|
2079
|
+
style: {
|
|
2080
|
+
position: "fixed",
|
|
2081
|
+
inset: 0,
|
|
2082
|
+
zIndex: 190
|
|
2083
|
+
}
|
|
2084
|
+
}), /* @__PURE__ */ Y(x, {
|
|
2085
|
+
open: !0,
|
|
2086
|
+
anchor: null,
|
|
2087
|
+
anchorPoint: {
|
|
2088
|
+
x: e,
|
|
2089
|
+
y: t
|
|
2090
|
+
},
|
|
2091
|
+
onClose: m,
|
|
2092
|
+
width: 220,
|
|
2093
|
+
children: /* @__PURE__ */ Y("div", {
|
|
2094
|
+
onClick: m,
|
|
2095
|
+
children: /* @__PURE__ */ Y(Me, {
|
|
2096
|
+
layout: h,
|
|
2097
|
+
entityActions: g,
|
|
2098
|
+
onRun: S,
|
|
2099
|
+
loading: y,
|
|
2100
|
+
onLoadingChange: b,
|
|
2101
|
+
row: n,
|
|
2102
|
+
widgetContext: v
|
|
2103
|
+
})
|
|
2104
|
+
})
|
|
2105
|
+
})] });
|
|
2106
|
+
}
|
|
2107
|
+
//#endregion
|
|
2108
|
+
//#region src/components/pages/list/useHeaderReorder.ts
|
|
2109
|
+
var xn = 5, Sn = 48, Cn = 18;
|
|
2110
|
+
function wn({ visibleCols: e, onReorder: t, scrollElRef: n, theadRef: r }) {
|
|
2111
|
+
let [i, a] = q(null), [o, s] = q(null), [c, l] = q(!1), u = K(null), d = K(!1), f = K(!1), p = K([]), m = K(null), h = K(0), g = K(null), _ = K(0), v = U(() => {
|
|
2112
|
+
g.current !== null && (cancelAnimationFrame(g.current), g.current = null);
|
|
2113
|
+
}, []), y = U(() => {
|
|
2114
|
+
u.current = null, d.current = !1, p.current = [], m.current = null, v(), a(null), s(null), l(!1);
|
|
2115
|
+
}, [v]), b = U((e) => {
|
|
2116
|
+
let t = p.current, r = e + ((n.current?.scrollLeft ?? 0) - _.current);
|
|
2117
|
+
for (let e = 0; e < t.length; e++) if (r < (t[e].left + t[e].right) / 2) return e;
|
|
2118
|
+
return t.length;
|
|
2119
|
+
}, [n]), x = U(() => {
|
|
2120
|
+
let e = n.current;
|
|
2121
|
+
if (!d.current || !e) {
|
|
2122
|
+
g.current = null;
|
|
2123
|
+
return;
|
|
2124
|
+
}
|
|
2125
|
+
let t = e.getBoundingClientRect(), r = h.current, i = 0;
|
|
2126
|
+
if (r < t.left + Sn ? i = -Math.ceil((t.left + Sn - r) / Sn * Cn) : r > t.right - Sn && (i = Math.ceil((r - (t.right - Sn)) / Sn * Cn)), i !== 0) {
|
|
2127
|
+
e.scrollLeft += i;
|
|
2128
|
+
let t = b(h.current);
|
|
2129
|
+
m.current = t, s(t);
|
|
2130
|
+
}
|
|
2131
|
+
g.current = requestAnimationFrame(x);
|
|
2132
|
+
}, [n, b]), S = U((e, t) => {
|
|
2133
|
+
t.button === 0 && (u.current = {
|
|
2134
|
+
colId: e,
|
|
2135
|
+
x: t.clientX
|
|
2136
|
+
}, d.current = !1, f.current = !1);
|
|
2137
|
+
}, []), C = U(() => f.current ? (f.current = !1, !0) : !1, []);
|
|
2138
|
+
return W(() => {
|
|
2139
|
+
let i = (t) => {
|
|
2140
|
+
let i = u.current;
|
|
2141
|
+
if (!i) return;
|
|
2142
|
+
if (h.current = t.clientX, !d.current) {
|
|
2143
|
+
if (Math.abs(t.clientX - i.x) < xn) return;
|
|
2144
|
+
let o = r.current, s = [];
|
|
2145
|
+
if (o) for (let t of e) {
|
|
2146
|
+
let e = o.querySelector(`[data-col-id="${CSS.escape(t)}"]`);
|
|
2147
|
+
if (e) {
|
|
2148
|
+
let n = e.getBoundingClientRect();
|
|
2149
|
+
s.push({
|
|
2150
|
+
id: t,
|
|
2151
|
+
left: n.left,
|
|
2152
|
+
right: n.right
|
|
2153
|
+
});
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
p.current = s, _.current = n.current?.scrollLeft ?? 0, d.current = !0, f.current = !0, a(i.colId), l(!0), g.current === null && (g.current = requestAnimationFrame(x));
|
|
2157
|
+
}
|
|
2158
|
+
let o = b(t.clientX);
|
|
2159
|
+
m.current = o, s(o);
|
|
2160
|
+
}, o = (n) => {
|
|
2161
|
+
let r = u.current;
|
|
2162
|
+
if (r && d.current && n) {
|
|
2163
|
+
let n = e.indexOf(r.colId), i = m.current ?? n;
|
|
2164
|
+
if (n !== -1) {
|
|
2165
|
+
let a = e.filter((e, t) => t !== n);
|
|
2166
|
+
i > n && --i, i = Math.max(0, Math.min(i, a.length));
|
|
2167
|
+
let o = [
|
|
2168
|
+
...a.slice(0, i),
|
|
2169
|
+
r.colId,
|
|
2170
|
+
...a.slice(i)
|
|
2171
|
+
];
|
|
2172
|
+
o.some((t, n) => t !== e[n]) && t(o);
|
|
2173
|
+
}
|
|
2174
|
+
}
|
|
2175
|
+
y();
|
|
2176
|
+
}, c = () => o(!0), v = (e) => {
|
|
2177
|
+
e.key === "Escape" && d.current && o(!1);
|
|
2178
|
+
};
|
|
2179
|
+
return window.addEventListener("mousemove", i), window.addEventListener("mouseup", c), window.addEventListener("keydown", v), () => {
|
|
2180
|
+
window.removeEventListener("mousemove", i), window.removeEventListener("mouseup", c), window.removeEventListener("keydown", v);
|
|
2181
|
+
};
|
|
2182
|
+
}, [
|
|
2183
|
+
e,
|
|
2184
|
+
t,
|
|
2185
|
+
r,
|
|
2186
|
+
n,
|
|
2187
|
+
b,
|
|
2188
|
+
x,
|
|
2189
|
+
y
|
|
2190
|
+
]), W(() => y, [y]), {
|
|
2191
|
+
dragColId: i,
|
|
2192
|
+
dropIndex: o,
|
|
2193
|
+
isDragging: c,
|
|
2194
|
+
onHeaderMouseDown: S,
|
|
2195
|
+
consumeDragSuppression: C
|
|
2196
|
+
};
|
|
2197
|
+
}
|
|
2198
|
+
//#endregion
|
|
2199
|
+
//#region src/components/pages/SmartListPage.impl.tsx
|
|
2200
|
+
var Tn = _t(() => import("./ListCardsBody-Dko91bLv.js").then((e) => ({ default: e.ListCardsBody })));
|
|
2201
|
+
function En({ screenCode: e }) {
|
|
2202
|
+
return /* @__PURE__ */ Y(d, { children: /* @__PURE__ */ Y(Dn, { screenCode: e }) });
|
|
2203
|
+
}
|
|
2204
|
+
function Dn({ screenCode: e }) {
|
|
2205
|
+
let t = Se(), [a, o] = vt(), { data: c } = i(), d = n(), [f, h] = q(!1), [g, _] = q(!1), { filters: y, filterError: x, activeCount: S, setFilters: C, clearFilters: T } = st(), E = ee((e) => e.user), D = ee((e) => e.activeTenant), te = l(), O = c?.screens[e], k = O?.entity ? c?.entities[O.entity] : void 0, A = O?.entity, ae = m(k, "create"), j = m(k, "update"), oe = m(k, "delete"), M = c?.actions, N = G(() => p(se(k?.actions, O?.actions, "list_toolbar", M), k), [
|
|
2206
|
+
k,
|
|
2207
|
+
O?.actions,
|
|
2208
|
+
M
|
|
2209
|
+
]), P = G(() => p(se(k?.actions, void 0, "list_floatbar", M), k), [k, M]), F = G(() => {
|
|
2210
|
+
let e = /* @__PURE__ */ new Map(), t = (t) => {
|
|
2211
|
+
for (let n of se(k?.actions, t, "list_row", M)) e.set(n.code, n);
|
|
2212
|
+
};
|
|
2213
|
+
t(O?.row_actions);
|
|
2214
|
+
for (let e of O?.variants?.items() ?? []) e.row_actions !== void 0 && t(e.row_actions);
|
|
2215
|
+
return p([...e.values()], k);
|
|
2216
|
+
}, [
|
|
2217
|
+
k,
|
|
2218
|
+
O,
|
|
2219
|
+
M
|
|
2220
|
+
]), le = O?.row_actions !== void 0, fe = G(() => P.length > 0 || k?.export?.enabled !== !1 && O?.export?.enabled !== !1, [
|
|
2221
|
+
P,
|
|
2222
|
+
k?.export?.enabled,
|
|
2223
|
+
O?.export?.enabled
|
|
2224
|
+
]), pe = !!k?.soft_delete, me = pe && (E?.permissions ?? []).some((e) => e === "feature:view_deleted" || e === "feature:*" || e === "*"), he = me && a.get("include_deleted") === "true", ge = ne(), { openTab: ye, updateTabSearch: be, findTabByPathname: Ce } = _e();
|
|
2225
|
+
$e(O, k, a.toString()), et(O?.route);
|
|
2226
|
+
let Te = U((e) => {
|
|
2227
|
+
if (!O?.route || !k || ge.enabled) return;
|
|
2228
|
+
let t = Ce(O.route);
|
|
2229
|
+
if (t) {
|
|
2230
|
+
be(t.id, e);
|
|
2231
|
+
return;
|
|
2232
|
+
}
|
|
2233
|
+
ye({
|
|
2234
|
+
pathname: O.route,
|
|
2235
|
+
search: e,
|
|
2236
|
+
title: s(O.display?.name) || s(k.display.name_plural),
|
|
2237
|
+
icon: O.display?.icon || k.display.icon,
|
|
2238
|
+
closable: !0
|
|
2239
|
+
});
|
|
2240
|
+
}, [
|
|
2241
|
+
O,
|
|
2242
|
+
k,
|
|
2243
|
+
ge.enabled,
|
|
2244
|
+
Ce,
|
|
2245
|
+
be,
|
|
2246
|
+
ye
|
|
2247
|
+
]), De = parseInt(a.get("page") ?? "1", 10), Oe = (() => {
|
|
2248
|
+
let e = parseInt(a.get("per_page") ?? "", 10);
|
|
2249
|
+
return !Number.isFinite(e) || e <= 0 || e > 1e3 ? 200 : e;
|
|
2250
|
+
})(), ke = a.get("search") ?? "", Me = Dt({
|
|
2251
|
+
searchParams: a,
|
|
2252
|
+
setSearchParams: o,
|
|
2253
|
+
screenSortDefault: O?.sort_default,
|
|
2254
|
+
commitScreenTabSearch: Te
|
|
2255
|
+
}), { cols: Ne, nullsByField: Pe, forRequest: Fe, tableSorting: Ie, write: Re, applyColumn: ze, shiftClickColumn: Be, appendColumn: Ve, clearColumn: Ue, clearAll: Ke } = Me, Je = G(() => Et(O, k, c?.entities), [
|
|
2256
|
+
O,
|
|
2257
|
+
k,
|
|
2258
|
+
c?.entities
|
|
2259
|
+
]), Ye = Mt({
|
|
2260
|
+
screenCode: e,
|
|
2261
|
+
screen: O,
|
|
2262
|
+
searchParams: a,
|
|
2263
|
+
setSearchParams: o
|
|
2264
|
+
}), { visible: L, sizing: Ze, setSizing: rt, apply: it, commitResize: ot } = Ye, ct = on({
|
|
2265
|
+
screenCode: e,
|
|
2266
|
+
screen: O,
|
|
2267
|
+
searchParams: a,
|
|
2268
|
+
setSearchParams: o,
|
|
2269
|
+
userId: E?.id,
|
|
2270
|
+
tenantId: D?.id,
|
|
2271
|
+
filterError: !!x,
|
|
2272
|
+
filters: y,
|
|
2273
|
+
visibleColumns: L,
|
|
2274
|
+
sort: Fe
|
|
2275
|
+
}), { active: R, saveAsNew: lt, overwriteActive: ut, isSaving: dt } = ct, ft = re(ke, 300), z = ie(), B = G(() => {
|
|
2276
|
+
let e = O?.responsive?.[z.category]?.presentation;
|
|
2277
|
+
return e === "table" || e === "cards" ? e : z.category === "phone" ? "cards" : "table";
|
|
2278
|
+
}, [O?.responsive, z.category]), pt = G(() => Xe({
|
|
2279
|
+
entity: k,
|
|
2280
|
+
screen: O,
|
|
2281
|
+
savedViewColumns: R?.columns
|
|
2282
|
+
}), [
|
|
2283
|
+
k,
|
|
2284
|
+
O,
|
|
2285
|
+
R?.columns
|
|
2286
|
+
]), V = G(() => Ge({
|
|
2287
|
+
entity: k,
|
|
2288
|
+
screen: O,
|
|
2289
|
+
presentation: B,
|
|
2290
|
+
visibleColumns: L,
|
|
2291
|
+
card: pt,
|
|
2292
|
+
rowActions: F,
|
|
2293
|
+
toolbarActions: N,
|
|
2294
|
+
bulkActions: P,
|
|
2295
|
+
sort: Ne,
|
|
2296
|
+
screens: c?.screens
|
|
2297
|
+
}), [
|
|
2298
|
+
k,
|
|
2299
|
+
O,
|
|
2300
|
+
B,
|
|
2301
|
+
L,
|
|
2302
|
+
pt,
|
|
2303
|
+
F,
|
|
2304
|
+
N,
|
|
2305
|
+
P,
|
|
2306
|
+
Ne,
|
|
2307
|
+
c?.screens
|
|
2308
|
+
]), _t = ht({
|
|
2309
|
+
entity: k,
|
|
2310
|
+
entityCode: A,
|
|
2311
|
+
screen: O,
|
|
2312
|
+
screenCode: e,
|
|
2313
|
+
page: De,
|
|
2314
|
+
perPage: Oe,
|
|
2315
|
+
sortForRequest: Fe,
|
|
2316
|
+
debouncedSearch: ft,
|
|
2317
|
+
filters: y,
|
|
2318
|
+
filterError: !!x,
|
|
2319
|
+
includeDeleted: he,
|
|
2320
|
+
expand: V.expandFields,
|
|
2321
|
+
select: V.selectFields,
|
|
2322
|
+
runCountQuery: !0,
|
|
2323
|
+
urlKey: `${A ?? ""}|${a.toString()}`
|
|
2324
|
+
}), { rows: H, meta: yt, refs: bt, isLoading: xt, isFetching: Tt, isError: Ot, error: At, isLoadingStale: Nt, retry: Pt, countTotal: Ft, countStrategy: It, countLoading: Rt, countError: zt, totalPages: Z, hasMorePages: Vt, isCursor: Ht, fetchNextPage: Ut, isFetchingNextPage: Wt } = _t, Kt = jt(k, H, Tt), { state: Jt, setState: Zt, ids: Qt, pkValues: $t, rows: en, keyOf: tn } = Kt, rn = we((e) => e.degradedEntities), an = Ee(k?.realtime, rn, A ?? ""), cn = xe(A ?? ""), un = K(bt);
|
|
2325
|
+
un.current = bt;
|
|
2326
|
+
let mn = G(() => {
|
|
2327
|
+
let e = /* @__PURE__ */ new Map();
|
|
2328
|
+
if (!k) return e;
|
|
2329
|
+
for (let t of He(k, O, R?.columns)) {
|
|
2330
|
+
if (t.startsWith("$") || k.files?.get(t)) continue;
|
|
2331
|
+
let n = k.fields.get(t);
|
|
2332
|
+
n && e.set(t, u({
|
|
2333
|
+
field: n,
|
|
2334
|
+
fieldName: t,
|
|
2335
|
+
surface: "list",
|
|
2336
|
+
entity: k,
|
|
2337
|
+
entities: c?.entities,
|
|
2338
|
+
screens: c?.screens,
|
|
2339
|
+
refs: () => un.current,
|
|
2340
|
+
locale: d
|
|
2341
|
+
}));
|
|
2342
|
+
}
|
|
2343
|
+
return e;
|
|
2344
|
+
}, [
|
|
2345
|
+
k,
|
|
2346
|
+
O,
|
|
2347
|
+
R?.columns,
|
|
2348
|
+
c?.entities,
|
|
2349
|
+
c?.screens,
|
|
2350
|
+
un,
|
|
2351
|
+
d
|
|
2352
|
+
]), { labelFor: hn, refs: gn } = ln(Je, y, bt, c?.entities), _n = Lt({
|
|
2353
|
+
entity: k,
|
|
2354
|
+
screen: O,
|
|
2355
|
+
screens: c?.screens,
|
|
2356
|
+
entities: c?.entities,
|
|
2357
|
+
searchParams: a,
|
|
2358
|
+
tabNavigate: t,
|
|
2359
|
+
commitScreenTabSearch: Te,
|
|
2360
|
+
isPhone: z.category === "phone",
|
|
2361
|
+
canUpdate: j
|
|
2362
|
+
}), { peekAllowed: vn, peekRow: Q, setPeekRow: xn, peekFields: Sn, peekActions: Cn, peekExecute: En, contextMenu: Dn, setContextMenu: On } = _n, kn = G(() => !O || !k ? !1 : v(O, "_", k, c?.screens) !== null, [
|
|
2363
|
+
O,
|
|
2364
|
+
k,
|
|
2365
|
+
c?.screens
|
|
2366
|
+
]), An = G(() => yn({
|
|
2367
|
+
visibleCols: L,
|
|
2368
|
+
entity: k,
|
|
2369
|
+
screen: O,
|
|
2370
|
+
schema: c,
|
|
2371
|
+
entityCode: A,
|
|
2372
|
+
rowActions: F,
|
|
2373
|
+
hasBatchActions: fe,
|
|
2374
|
+
hasExplicitRowActions: le,
|
|
2375
|
+
canUpdate: j,
|
|
2376
|
+
canDelete: oe,
|
|
2377
|
+
peekEnabled: vn,
|
|
2378
|
+
hasDetailTarget: kn,
|
|
2379
|
+
userLocale: d,
|
|
2380
|
+
tabNavigate: t,
|
|
2381
|
+
refsRef: un,
|
|
2382
|
+
rowSelectionKey: kt,
|
|
2383
|
+
setPeekRow: xn
|
|
2384
|
+
}), [
|
|
2385
|
+
O,
|
|
2386
|
+
k,
|
|
2387
|
+
L,
|
|
2388
|
+
t,
|
|
2389
|
+
fe,
|
|
2390
|
+
F,
|
|
2391
|
+
le,
|
|
2392
|
+
A,
|
|
2393
|
+
vn,
|
|
2394
|
+
kn,
|
|
2395
|
+
c,
|
|
2396
|
+
d,
|
|
2397
|
+
j,
|
|
2398
|
+
oe,
|
|
2399
|
+
un,
|
|
2400
|
+
xn
|
|
2401
|
+
]), jn = Ct({
|
|
2402
|
+
data: H,
|
|
2403
|
+
columns: An,
|
|
2404
|
+
getCoreRowModel: St(),
|
|
2405
|
+
manualSorting: !0,
|
|
2406
|
+
manualPagination: !0,
|
|
2407
|
+
enableColumnResizing: !0,
|
|
2408
|
+
columnResizeMode: "onChange",
|
|
2409
|
+
onColumnSizingChange: rt,
|
|
2410
|
+
state: {
|
|
2411
|
+
sorting: Ie,
|
|
2412
|
+
rowSelection: Jt,
|
|
2413
|
+
columnSizing: Ze
|
|
2414
|
+
},
|
|
2415
|
+
onSortingChange: (e) => {
|
|
2416
|
+
let t = (typeof e == "function" ? e(Ie) : e).slice(0, 5);
|
|
2417
|
+
if (t.length === 0) {
|
|
2418
|
+
Re([]);
|
|
2419
|
+
return;
|
|
2420
|
+
}
|
|
2421
|
+
let n = t.map((e) => {
|
|
2422
|
+
let t = Pe.get(e.id);
|
|
2423
|
+
return {
|
|
2424
|
+
field: e.id,
|
|
2425
|
+
dir: e.desc ? "desc" : "asc",
|
|
2426
|
+
...t ? { nulls: t } : {}
|
|
2427
|
+
};
|
|
2428
|
+
});
|
|
2429
|
+
Re(n);
|
|
2430
|
+
},
|
|
2431
|
+
onRowSelectionChange: Zt,
|
|
2432
|
+
getRowId: tn,
|
|
2433
|
+
rowCount: Ft ?? H.length
|
|
2434
|
+
}), Mn = jn.getState().columnSizingInfo.isResizingColumn, Nn = K(!1);
|
|
2435
|
+
W(() => {
|
|
2436
|
+
let e = !!Nn.current && !Mn;
|
|
2437
|
+
Nn.current = Mn, e && ot(jn.getState().columnSizing);
|
|
2438
|
+
}, [
|
|
2439
|
+
Mn,
|
|
2440
|
+
ot,
|
|
2441
|
+
jn
|
|
2442
|
+
]);
|
|
2443
|
+
let Pn = Bt(jn), Fn = jn.getTotalSize();
|
|
2444
|
+
W(() => {
|
|
2445
|
+
let e = (e) => {
|
|
2446
|
+
let t = e.target?.tagName;
|
|
2447
|
+
if (t === "INPUT" || t === "TEXTAREA" || t === "SELECT") {
|
|
2448
|
+
e.key === "Escape" && (e.target.blur(), h(!1));
|
|
2449
|
+
return;
|
|
2450
|
+
}
|
|
2451
|
+
e.key === "/" && !e.metaKey && !e.ctrlKey && (e.preventDefault(), document.querySelector("[placeholder*=\"Search\"]")?.focus()), e.key === "f" && !e.metaKey && !e.ctrlKey && (e.preventDefault(), h((e) => !e)), e.key === "Escape" && h(!1);
|
|
2452
|
+
};
|
|
2453
|
+
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
2454
|
+
}, []);
|
|
2455
|
+
let In = K(null), { rows: Ln } = jn.getRowModel(), Rn = K(null), zn = wn({
|
|
2456
|
+
visibleCols: L,
|
|
2457
|
+
onReorder: it,
|
|
2458
|
+
scrollElRef: In,
|
|
2459
|
+
theadRef: Rn
|
|
2460
|
+
}), Bn = ve((e) => e.density), Vn = ve((e) => e.zebra), Hn = de(), $ = wt({
|
|
2461
|
+
count: Ln.length,
|
|
2462
|
+
getScrollElement: () => In.current,
|
|
2463
|
+
estimateSize: () => B === "cards" ? 142 : 48,
|
|
2464
|
+
overscan: 10,
|
|
2465
|
+
initialOffset: Hn
|
|
2466
|
+
}), Un = G(() => Ln.map((e) => e.id), [Ln]);
|
|
2467
|
+
ue({
|
|
2468
|
+
virtualizer: $,
|
|
2469
|
+
scrollElementRef: In,
|
|
2470
|
+
rowKeys: Un
|
|
2471
|
+
}), W(() => {
|
|
2472
|
+
$.measure();
|
|
2473
|
+
}, [Bn, $]), W(() => {
|
|
2474
|
+
$.measure();
|
|
2475
|
+
}, [
|
|
2476
|
+
z.width,
|
|
2477
|
+
z.height,
|
|
2478
|
+
B,
|
|
2479
|
+
$
|
|
2480
|
+
]);
|
|
2481
|
+
let Wn = U((e) => {
|
|
2482
|
+
o((t) => {
|
|
2483
|
+
let n = new URLSearchParams(t);
|
|
2484
|
+
return e ? n.set("search", e) : n.delete("search"), n.set("page", "1"), n;
|
|
2485
|
+
});
|
|
2486
|
+
}, [o]), Gn = U(() => {
|
|
2487
|
+
o((e) => {
|
|
2488
|
+
let t = new URLSearchParams(e);
|
|
2489
|
+
return t.get("include_deleted") ? t.delete("include_deleted") : t.set("include_deleted", "true"), t.set("page", "1"), t;
|
|
2490
|
+
});
|
|
2491
|
+
}, [o]), Kn = U((e) => {
|
|
2492
|
+
o((t) => {
|
|
2493
|
+
let n = new URLSearchParams(t);
|
|
2494
|
+
return n.set("page", String(e)), n;
|
|
2495
|
+
});
|
|
2496
|
+
}, [o]);
|
|
2497
|
+
W(() => {
|
|
2498
|
+
Z !== void 0 && De > Z && Kn(Z);
|
|
2499
|
+
}, [
|
|
2500
|
+
Z,
|
|
2501
|
+
De,
|
|
2502
|
+
Kn
|
|
2503
|
+
]);
|
|
2504
|
+
let qn = U((e) => {
|
|
2505
|
+
o((t) => {
|
|
2506
|
+
let n = new URLSearchParams(t);
|
|
2507
|
+
return n.set("per_page", String(e)), n.set("page", "1"), n;
|
|
2508
|
+
});
|
|
2509
|
+
}, [o]);
|
|
2510
|
+
if (!O || !k) return null;
|
|
2511
|
+
let Jn = k.display, Yn = s(O.display?.name) || s(Jn.name), Xn = O.display?.icon || Jn.icon, Zn = s(O.display?.description) || s(Jn.description), Qn = z.category === "phone", $n = B === "cards", er = $t.map((e) => r(k, e)), tr = {
|
|
2512
|
+
entity: k,
|
|
2513
|
+
entityCode: A ?? "",
|
|
2514
|
+
screen: O,
|
|
2515
|
+
screenRoute: O.route,
|
|
2516
|
+
selectedRows: en,
|
|
2517
|
+
selectedIds: er,
|
|
2518
|
+
locale: d,
|
|
2519
|
+
tabNavigate: (e, n) => t(e, {
|
|
2520
|
+
title: n?.title,
|
|
2521
|
+
icon: n?.icon,
|
|
2522
|
+
search: n?.search
|
|
2523
|
+
}),
|
|
2524
|
+
runActionApi: (e, t) => b(e, t)
|
|
2525
|
+
};
|
|
2526
|
+
return /* @__PURE__ */ X("div", {
|
|
2527
|
+
style: {
|
|
2528
|
+
display: "flex",
|
|
2529
|
+
flexDirection: "column",
|
|
2530
|
+
height: "100%",
|
|
2531
|
+
background: "var(--background)"
|
|
2532
|
+
},
|
|
2533
|
+
children: [
|
|
2534
|
+
/* @__PURE__ */ X(J, { children: [
|
|
2535
|
+
/* @__PURE__ */ Y(fn, {
|
|
2536
|
+
title: Yn,
|
|
2537
|
+
description: Zn,
|
|
2538
|
+
toolbarActions: N,
|
|
2539
|
+
screenActionLayout: O.action_layout,
|
|
2540
|
+
entityActionLayout: k.action_layout,
|
|
2541
|
+
selectedIds: Qt,
|
|
2542
|
+
data: H,
|
|
2543
|
+
rowKey: tn,
|
|
2544
|
+
onActionSuccess: () => Zt({}),
|
|
2545
|
+
widgetContext: tr
|
|
2546
|
+
}),
|
|
2547
|
+
/* @__PURE__ */ Y(nn, {
|
|
2548
|
+
screen: O,
|
|
2549
|
+
entity: k,
|
|
2550
|
+
entityCode: A,
|
|
2551
|
+
schema: c,
|
|
2552
|
+
screenCode: e,
|
|
2553
|
+
screenName: Yn,
|
|
2554
|
+
locale: d,
|
|
2555
|
+
isPhone: Qn,
|
|
2556
|
+
isCardsPresentation: $n,
|
|
2557
|
+
sort: Me,
|
|
2558
|
+
columns: Ye,
|
|
2559
|
+
views: ct,
|
|
2560
|
+
query: _t,
|
|
2561
|
+
selection: Kt,
|
|
2562
|
+
filters: {
|
|
2563
|
+
json: y,
|
|
2564
|
+
debouncedSearch: ft,
|
|
2565
|
+
count: S,
|
|
2566
|
+
onOpen: () => h(!0)
|
|
2567
|
+
},
|
|
2568
|
+
searchValue: ke,
|
|
2569
|
+
onSearchChange: Wn,
|
|
2570
|
+
onSaveView: () => _(!0),
|
|
2571
|
+
page: De,
|
|
2572
|
+
perPage: Oe,
|
|
2573
|
+
includeDeleted: he,
|
|
2574
|
+
canViewDeleted: me,
|
|
2575
|
+
onToggleDeleted: Gn,
|
|
2576
|
+
isLive: an
|
|
2577
|
+
}),
|
|
2578
|
+
x && /* @__PURE__ */ X("div", {
|
|
2579
|
+
role: "alert",
|
|
2580
|
+
"data-testid": "filter-url-error",
|
|
2581
|
+
style: {
|
|
2582
|
+
margin: "0 20px 10px",
|
|
2583
|
+
padding: "8px 10px",
|
|
2584
|
+
border: "1px solid var(--danger)",
|
|
2585
|
+
borderRadius: 6,
|
|
2586
|
+
color: "var(--danger)",
|
|
2587
|
+
fontSize: 12,
|
|
2588
|
+
display: "flex",
|
|
2589
|
+
alignItems: "center",
|
|
2590
|
+
gap: 8
|
|
2591
|
+
},
|
|
2592
|
+
children: [/* @__PURE__ */ X("span", { children: [x, " Showing this list without URL filters."] }), /* @__PURE__ */ Y(w, {
|
|
2593
|
+
kind: "ghost",
|
|
2594
|
+
size: "xs",
|
|
2595
|
+
onClick: T,
|
|
2596
|
+
children: "Clear"
|
|
2597
|
+
})]
|
|
2598
|
+
}),
|
|
2599
|
+
y.length > 0 && /* @__PURE__ */ Y("div", {
|
|
2600
|
+
style: { padding: "0 20px 10px" },
|
|
2601
|
+
children: /* @__PURE__ */ Y(nt, {
|
|
2602
|
+
filters: y,
|
|
2603
|
+
resolveValue: hn,
|
|
2604
|
+
onRemove: (e) => C(Qe(y, e)),
|
|
2605
|
+
onClearAll: T,
|
|
2606
|
+
onChipClick: () => h(!0),
|
|
2607
|
+
fieldLabel: (e) => {
|
|
2608
|
+
if (e.startsWith("$status.")) {
|
|
2609
|
+
let t = e.slice(8), n = k.status_groups?.[t];
|
|
2610
|
+
return n ? s(n.name) || t : e;
|
|
2611
|
+
}
|
|
2612
|
+
if (e.startsWith("$property.")) {
|
|
2613
|
+
let t = e.slice(10), n = k.properties?.[t];
|
|
2614
|
+
return n ? s(n.name) || t : e;
|
|
2615
|
+
}
|
|
2616
|
+
let t = k.fields.get(e);
|
|
2617
|
+
return t ? ce(t, e, c?.entities) : e;
|
|
2618
|
+
}
|
|
2619
|
+
})
|
|
2620
|
+
})
|
|
2621
|
+
] }),
|
|
2622
|
+
/* @__PURE__ */ Y(Yt, {
|
|
2623
|
+
isLoading: xt,
|
|
2624
|
+
tableLoadingStale: Nt,
|
|
2625
|
+
isError: Ot,
|
|
2626
|
+
error: At,
|
|
2627
|
+
rowCount: H.length,
|
|
2628
|
+
entity: k,
|
|
2629
|
+
screen: O,
|
|
2630
|
+
screenName: Yn,
|
|
2631
|
+
screenIcon: Xn,
|
|
2632
|
+
isFiltered: !!ft || S > 0,
|
|
2633
|
+
canCreate: ae,
|
|
2634
|
+
toolbarActions: N,
|
|
2635
|
+
onRetry: Pt
|
|
2636
|
+
}),
|
|
2637
|
+
xt || Ot || H.length === 0 ? null : /* @__PURE__ */ Y("div", {
|
|
2638
|
+
style: {
|
|
2639
|
+
flex: 1,
|
|
2640
|
+
minHeight: 0,
|
|
2641
|
+
padding: "0 20px 16px",
|
|
2642
|
+
display: "flex",
|
|
2643
|
+
flexDirection: "column"
|
|
2644
|
+
},
|
|
2645
|
+
children: /* @__PURE__ */ X("div", {
|
|
2646
|
+
style: {
|
|
2647
|
+
background: "var(--surface)",
|
|
2648
|
+
border: "1px solid var(--border)",
|
|
2649
|
+
borderRadius: 8,
|
|
2650
|
+
overflow: "hidden",
|
|
2651
|
+
boxShadow: "var(--shadow-xs)",
|
|
2652
|
+
display: "flex",
|
|
2653
|
+
flexDirection: "column",
|
|
2654
|
+
flex: 1,
|
|
2655
|
+
minHeight: 0
|
|
2656
|
+
},
|
|
2657
|
+
children: [/* @__PURE__ */ Y("div", {
|
|
2658
|
+
ref: In,
|
|
2659
|
+
"data-testid": "list-scroll",
|
|
2660
|
+
"data-presentation": B,
|
|
2661
|
+
style: {
|
|
2662
|
+
overflow: "auto",
|
|
2663
|
+
flex: 1,
|
|
2664
|
+
minHeight: 0
|
|
2665
|
+
},
|
|
2666
|
+
children: B === "cards" ? /* @__PURE__ */ Y(gt, {
|
|
2667
|
+
fallback: null,
|
|
2668
|
+
children: /* @__PURE__ */ Y(Tn, {
|
|
2669
|
+
rows: Ln,
|
|
2670
|
+
virtualizer: $,
|
|
2671
|
+
entity: k,
|
|
2672
|
+
screen: O,
|
|
2673
|
+
entityCode: A,
|
|
2674
|
+
entities: c?.entities,
|
|
2675
|
+
savedViewColumns: R?.columns,
|
|
2676
|
+
refs: un.current,
|
|
2677
|
+
locale: d,
|
|
2678
|
+
renderers: mn,
|
|
2679
|
+
rowActions: F,
|
|
2680
|
+
tabNavigate: t,
|
|
2681
|
+
interaction: _n,
|
|
2682
|
+
hasSoftDelete: pe,
|
|
2683
|
+
zebra: Vn,
|
|
2684
|
+
hasBatchActions: fe,
|
|
2685
|
+
hasDetailTarget: kn,
|
|
2686
|
+
rowKey: tn
|
|
2687
|
+
})
|
|
2688
|
+
}) : /* @__PURE__ */ Y(Gt, {
|
|
2689
|
+
table: jn,
|
|
2690
|
+
columns: An,
|
|
2691
|
+
rows: Ln,
|
|
2692
|
+
entity: k,
|
|
2693
|
+
columnSizeVars: Pn,
|
|
2694
|
+
totalColumnsWidth: Fn,
|
|
2695
|
+
theadRef: Rn,
|
|
2696
|
+
virtualizer: $,
|
|
2697
|
+
visibleCols: L,
|
|
2698
|
+
headerReorder: zn,
|
|
2699
|
+
sortCols: Ne,
|
|
2700
|
+
sortNullsMap: Pe,
|
|
2701
|
+
shiftClickColumn: Be,
|
|
2702
|
+
applyColumnSort: ze,
|
|
2703
|
+
appendColumnSort: Ve,
|
|
2704
|
+
clearColumnSort: Ue,
|
|
2705
|
+
clearAllSorts: Ke,
|
|
2706
|
+
renderRow: (e, t) => /* @__PURE__ */ Y(qt, {
|
|
2707
|
+
row: e,
|
|
2708
|
+
rowIndex: t,
|
|
2709
|
+
entity: k,
|
|
2710
|
+
hasSoftDelete: pe,
|
|
2711
|
+
zebra: Vn,
|
|
2712
|
+
hasDetailTarget: kn,
|
|
2713
|
+
interaction: _n,
|
|
2714
|
+
measureElement: $.measureElement
|
|
2715
|
+
}, e.id),
|
|
2716
|
+
isResizingColumn: Mn
|
|
2717
|
+
})
|
|
2718
|
+
}), /* @__PURE__ */ Y(Xt, {
|
|
2719
|
+
meta: yt,
|
|
2720
|
+
isCursor: Ht,
|
|
2721
|
+
isPhone: Qn,
|
|
2722
|
+
rowsLoaded: H.length,
|
|
2723
|
+
selectedCount: Qt.length,
|
|
2724
|
+
countTotal: Ft,
|
|
2725
|
+
countStrategy: It,
|
|
2726
|
+
countLoading: Rt,
|
|
2727
|
+
countError: zt,
|
|
2728
|
+
page: De,
|
|
2729
|
+
totalPages: Z,
|
|
2730
|
+
goToPage: Kn,
|
|
2731
|
+
perPage: Oe,
|
|
2732
|
+
setPerPage: qn,
|
|
2733
|
+
hasMorePages: Vt,
|
|
2734
|
+
fetchNextPage: Ut,
|
|
2735
|
+
isFetchingNextPage: Wt
|
|
2736
|
+
})]
|
|
2737
|
+
})
|
|
2738
|
+
}),
|
|
2739
|
+
/* @__PURE__ */ Y(at, {
|
|
2740
|
+
open: f,
|
|
2741
|
+
onClose: () => h(!1),
|
|
2742
|
+
filters: y,
|
|
2743
|
+
onApply: C,
|
|
2744
|
+
availableFields: Je,
|
|
2745
|
+
defaultFilters: O?.default_filters,
|
|
2746
|
+
refs: gn
|
|
2747
|
+
}),
|
|
2748
|
+
/* @__PURE__ */ Y(dn, {
|
|
2749
|
+
open: g,
|
|
2750
|
+
pending: dt,
|
|
2751
|
+
onClose: () => _(!1),
|
|
2752
|
+
overwriteViewName: sn(R),
|
|
2753
|
+
onOverwrite: async () => {
|
|
2754
|
+
await ut(), _(!1);
|
|
2755
|
+
},
|
|
2756
|
+
onSave: async (e) => {
|
|
2757
|
+
await lt(e), _(!1);
|
|
2758
|
+
}
|
|
2759
|
+
}),
|
|
2760
|
+
Qt.length > 0 && /* @__PURE__ */ Y(pn, {
|
|
2761
|
+
selectedIds: Qt,
|
|
2762
|
+
floatbarActions: P,
|
|
2763
|
+
screenActionLayout: O.action_layout,
|
|
2764
|
+
entityActionLayout: k.action_layout,
|
|
2765
|
+
data: H,
|
|
2766
|
+
rowKey: tn,
|
|
2767
|
+
entityCode: A,
|
|
2768
|
+
entity: k,
|
|
2769
|
+
screen: O,
|
|
2770
|
+
onClear: () => Zt({}),
|
|
2771
|
+
onActionSuccess: () => Zt({}),
|
|
2772
|
+
widgetContext: tr
|
|
2773
|
+
}),
|
|
2774
|
+
Dn && k && O && /* @__PURE__ */ Y(bn, {
|
|
2775
|
+
x: Dn.x,
|
|
2776
|
+
y: Dn.y,
|
|
2777
|
+
row: Dn.row,
|
|
2778
|
+
rowId: tn(Dn.row),
|
|
2779
|
+
screen: O,
|
|
2780
|
+
fullScreen: O,
|
|
2781
|
+
entity: k,
|
|
2782
|
+
entityCode: A,
|
|
2783
|
+
rowActions: F,
|
|
2784
|
+
tabNavigate: t,
|
|
2785
|
+
locale: d,
|
|
2786
|
+
peekAllowed: vn,
|
|
2787
|
+
hasDetailTarget: kn,
|
|
2788
|
+
onPeek: xn,
|
|
2789
|
+
onClose: () => On(null)
|
|
2790
|
+
}),
|
|
2791
|
+
vn && Q && k && /* @__PURE__ */ Y(tt, {
|
|
2792
|
+
entity: k,
|
|
2793
|
+
entityCode: A,
|
|
2794
|
+
record: Q,
|
|
2795
|
+
title: (() => {
|
|
2796
|
+
let e = O.columns?.find((e) => !e.startsWith("$status.") && !e.startsWith("$property."));
|
|
2797
|
+
return e ? I(Q[e] ?? s(k.display.name)) : s(k.display.name);
|
|
2798
|
+
})(),
|
|
2799
|
+
recordId: (() => {
|
|
2800
|
+
let e = k.fields.names()?.find((e) => k.fields.get(e)?.primary);
|
|
2801
|
+
return e ? I(Q[e]) : void 0;
|
|
2802
|
+
})(),
|
|
2803
|
+
fields: Sn,
|
|
2804
|
+
screen: Le(k, O, Q),
|
|
2805
|
+
actions: Cn,
|
|
2806
|
+
screenActionLayout: Le(k, O, Q)?.action_layout,
|
|
2807
|
+
entityActionLayout: k.action_layout,
|
|
2808
|
+
executeAction: En,
|
|
2809
|
+
onClose: () => {
|
|
2810
|
+
if (k && Q) {
|
|
2811
|
+
let e = k.fields.names()?.find((e) => k.fields.get(e)?.primary);
|
|
2812
|
+
e && mt(I(Q[e]));
|
|
2813
|
+
}
|
|
2814
|
+
xn(null);
|
|
2815
|
+
},
|
|
2816
|
+
onOpen: (e) => {
|
|
2817
|
+
let t = Q;
|
|
2818
|
+
xn(null), _n.navigateToDetail(t, { draft: e });
|
|
2819
|
+
},
|
|
2820
|
+
onSave: (e) => {
|
|
2821
|
+
xn(e);
|
|
2822
|
+
let t = k.fields.names()?.find((e) => k.fields.get(e)?.primary);
|
|
2823
|
+
if (!t) return;
|
|
2824
|
+
let n = I(e[t]), r = {};
|
|
2825
|
+
for (let t of k.fields.names()) {
|
|
2826
|
+
let n = Ae(k, e, t), i = Ae(k, Q, t), a = je(k, t, n), o = je(k, t, i);
|
|
2827
|
+
(a === "" ? null : a) !== (o === "" || o === void 0 ? null : o) && (r[t] = a);
|
|
2828
|
+
}
|
|
2829
|
+
let i = qe({
|
|
2830
|
+
entity: k,
|
|
2831
|
+
formData: e,
|
|
2832
|
+
record: Q,
|
|
2833
|
+
isNew: !1
|
|
2834
|
+
});
|
|
2835
|
+
if (Object.keys(i).length > 0 && (r.$files = i), Object.keys(r).length === 0) return;
|
|
2836
|
+
let a = We(i);
|
|
2837
|
+
cn.mutate({
|
|
2838
|
+
pkValues: n,
|
|
2839
|
+
data: r
|
|
2840
|
+
}, { onSuccess: () => {
|
|
2841
|
+
a.forEach((e) => te.markCommitted(e));
|
|
2842
|
+
} });
|
|
2843
|
+
}
|
|
2844
|
+
})
|
|
2845
|
+
]
|
|
2846
|
+
});
|
|
2847
|
+
}
|
|
2848
|
+
//#endregion
|
|
2849
|
+
export { En as SmartListPage, _n as t };
|