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