@monolith-forensics/monolith-ui 1.1.90 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DateInput/DateInput.d.ts +2 -1
- package/dist/DateInput/DateInput.js +9 -6
- package/dist/DropDownMenu/DropDownMenu.js +41 -35
- package/dist/Input/Input.d.ts +1 -3
- package/dist/Input/Input.js +5 -4
- package/dist/Loader/Loader.js +0 -1
- package/dist/MonolithUIProvider/GlobalStyle.d.ts +1 -0
- package/dist/MonolithUIProvider/GlobalStyle.js +17 -0
- package/dist/MonolithUIProvider/MonolithUIProvider.d.ts +131 -7
- package/dist/MonolithUIProvider/MonolithUIProvider.js +4 -4
- package/dist/MonolithUIProvider/index.d.ts +1 -1
- package/dist/MonolithUIProvider/index.js +1 -1
- package/dist/QueryFilter/DefaultOperators.d.ts +77 -0
- package/dist/QueryFilter/DefaultOperators.js +22 -0
- package/dist/QueryFilter/QueryFilter.d.ts +5 -0
- package/dist/QueryFilter/QueryFilter.js +224 -0
- package/dist/QueryFilter/index.d.ts +3 -0
- package/dist/QueryFilter/index.js +3 -0
- package/dist/QueryFilter/types.d.ts +51 -0
- package/dist/QueryFilter/types.js +1 -0
- package/dist/QueryFilter/useQueryFilter.d.ts +3 -0
- package/dist/QueryFilter/useQueryFilter.js +36 -0
- package/dist/Table/ActionButton.d.ts +4 -0
- package/dist/Table/ActionButton.js +11 -0
- package/dist/Table/ActionCell.d.ts +4 -0
- package/dist/Table/ActionCell.js +13 -0
- package/dist/Table/Column.d.ts +3 -0
- package/dist/Table/Column.js +5 -0
- package/dist/Table/ColumnResizer.d.ts +14 -0
- package/dist/Table/ColumnResizer.js +45 -0
- package/dist/Table/LoadingIndicator.d.ts +4 -0
- package/dist/Table/LoadingIndicator.js +76 -0
- package/dist/Table/RenderSkeleton.d.ts +6 -0
- package/dist/Table/RenderSkeleton.js +25 -0
- package/dist/Table/SelectionCell.d.ts +4 -0
- package/dist/Table/SelectionCell.js +12 -0
- package/dist/Table/StateStorage.d.ts +27 -0
- package/dist/Table/StateStorage.js +98 -0
- package/dist/Table/StaticRows.d.ts +5 -0
- package/dist/Table/StaticRows.js +10 -0
- package/dist/Table/Table.d.ts +2 -92
- package/dist/Table/Table.js +73 -679
- package/dist/Table/TableComponents.d.ts +16 -0
- package/dist/Table/TableComponents.js +144 -0
- package/dist/Table/TableDefaults.d.ts +25 -0
- package/dist/Table/TableDefaults.js +25 -0
- package/dist/Table/TableHeader.d.ts +3 -0
- package/dist/Table/TableHeader.js +93 -0
- package/dist/Table/TableMenu/InfoBadge.d.ts +10 -0
- package/dist/Table/TableMenu/InfoBadge.js +23 -0
- package/dist/Table/TableMenu/TableMenu.d.ts +2 -0
- package/dist/Table/TableMenu/TableMenu.js +108 -0
- package/dist/Table/TableMenu/index.d.ts +2 -0
- package/dist/Table/TableMenu/index.js +2 -0
- package/dist/Table/TableProvider.d.ts +4 -0
- package/dist/Table/TableProvider.js +499 -0
- package/dist/Table/TableRow.d.ts +3 -0
- package/dist/Table/TableRow.js +27 -0
- package/dist/Table/Utils/index.d.ts +3 -0
- package/dist/Table/Utils/index.js +3 -0
- package/dist/Table/Utils/resizeHandler.d.ts +3 -0
- package/dist/Table/Utils/resizeHandler.js +84 -0
- package/dist/Table/Utils/resolveColumnReorder.d.ts +3 -0
- package/dist/Table/Utils/resolveColumnReorder.js +5 -0
- package/dist/Table/Utils/resolveColumnResize.d.ts +3 -0
- package/dist/Table/Utils/resolveColumnResize.js +5 -0
- package/dist/Table/Utils/syncColumnState.d.ts +3 -0
- package/dist/Table/Utils/syncColumnState.js +26 -0
- package/dist/Table/VirtualIzedRows.d.ts +11 -0
- package/dist/Table/VirtualIzedRows.js +26 -0
- package/dist/Table/enums.d.ts +10 -0
- package/dist/Table/enums.js +12 -0
- package/dist/Table/index.d.ts +4 -3
- package/dist/Table/index.js +4 -2
- package/dist/Table/types.d.ts +267 -0
- package/dist/Table/types.js +1 -0
- package/dist/Table/useTable.d.ts +3 -0
- package/dist/Table/useTable.js +10 -0
- package/dist/TextInput/TextInput.d.ts +2 -3
- package/dist/TextInput/TextInput.js +5 -4
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useDelayedBoolean.d.ts +2 -0
- package/dist/hooks/useDelayedBoolean.js +17 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -2
- package/dist/theme/getTheme.d.ts +3 -0
- package/dist/theme/getTheme.js +13 -0
- package/dist/theme/index.d.ts +3 -168
- package/dist/theme/index.js +3 -12
- package/dist/theme/variants.d.ts +7 -172
- package/dist/theme/variants.js +6 -5
- package/package.json +2 -1
package/dist/Table/Table.js
CHANGED
|
@@ -9,415 +9,58 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
12
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
14
|
+
import Column from "./Column";
|
|
15
15
|
import { useOverlayScrollbars } from "overlayscrollbars-react";
|
|
16
|
-
import "
|
|
16
|
+
import { StyledTable } from "./TableComponents";
|
|
17
|
+
import TableHeader from "./TableHeader";
|
|
18
|
+
import TableProvider from "./TableProvider";
|
|
17
19
|
import shortUUID from "short-uuid";
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
return null;
|
|
20
|
+
import VirtualizedRows from "./VirtualIzedRows";
|
|
21
|
+
import StaticRows from "./StaticRows";
|
|
22
|
+
import TableMenu from "./TableMenu";
|
|
23
|
+
import useTable from "./useTable";
|
|
24
|
+
import LoadingIndicator from "./LoadingIndicator";
|
|
25
|
+
const TableContent = () => {
|
|
26
|
+
const { columnState, tableElement, headerRowElm, tableDimensions, targetElm, listElm, rowHeight, headerRowHeight, compactState, virtualized, loading, } = useTable();
|
|
27
|
+
const visibleColumnCount = columnState.filter((column) => column.visible === true).length;
|
|
28
|
+
return (_jsxs(_Fragment, { children: [_jsx(TableMenu, {}), _jsxs(StyledTable, { className: "mfui-table", ref: tableElement, "data-compact": compactState, children: [_jsx(LoadingIndicator, { visible: loading }), _jsx(TableHeader, { headerRowElm: headerRowElm }), visibleColumnCount === 0 && _jsx(_Fragment, {}), virtualized === true ? (_jsx(VirtualizedRows, { tableDimensions: tableDimensions, targetElm: targetElm, listElm: listElm, rowHeight: rowHeight, headerRowHeight: headerRowHeight })) : (_jsx(StaticRows, { targetElm: targetElm, listElm: listElm }))] })] }));
|
|
28
29
|
};
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
& .tr:hover td {
|
|
45
|
-
background-color: ${({ theme }) => theme.palette.action.hover};
|
|
46
|
-
}
|
|
47
|
-
`;
|
|
48
|
-
const StyledTr = styled.tr `
|
|
49
|
-
position: relative;
|
|
50
|
-
height: ${({ compact, rowHeight }) => rowHeight ? rowHeight : compact ? 28 : 38}px;
|
|
51
|
-
width: 100%;
|
|
52
|
-
display: flex;
|
|
53
|
-
|
|
54
|
-
& .action-button {
|
|
55
|
-
opacity: 0;
|
|
56
|
-
border-radius: 4px;
|
|
57
|
-
}
|
|
58
|
-
* .custom-action-button {
|
|
59
|
-
opacity: 0;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
&:hover .action-button,
|
|
63
|
-
&:hover .custom-action-button {
|
|
64
|
-
opacity: 1;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
&.focused .td {
|
|
68
|
-
border-top: 1px solid ${({ theme }) => theme.palette.primary.main};
|
|
69
|
-
border-bottom: 1px solid ${({ theme }) => theme.palette.primary.main} !important;
|
|
70
|
-
transition: border 0.3s ease;
|
|
71
|
-
}
|
|
72
|
-
&.focused .td:first-child {
|
|
73
|
-
border-left: 1px solid ${({ theme }) => theme.palette.primary.main};
|
|
74
|
-
}
|
|
75
|
-
&.focused .td:last-child {
|
|
76
|
-
border-right: 1px solid ${({ theme }) => theme.palette.primary.main};
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// last item in row
|
|
80
|
-
& .td:last-child {
|
|
81
|
-
width: auto !important;
|
|
82
|
-
max-width: none !important;
|
|
83
|
-
}
|
|
84
|
-
`;
|
|
85
|
-
const StyledHeaderRow = styled(StyledTr) `
|
|
86
|
-
height: ${({ compact, headerHeight }) => headerHeight ? headerHeight : compact ? 28 : 38}px;
|
|
87
|
-
|
|
88
|
-
display: table-row;
|
|
89
|
-
|
|
90
|
-
// last item in row
|
|
91
|
-
& .th:last-child {
|
|
92
|
-
width: auto !important;
|
|
93
|
-
max-width: none !important;
|
|
94
|
-
}
|
|
95
|
-
`;
|
|
96
|
-
const StyledTd = styled.td `
|
|
97
|
-
position: relative;
|
|
98
|
-
display: flex;
|
|
99
|
-
align-items: center;
|
|
100
|
-
flex: 1;
|
|
101
|
-
padding: ${({ compact }) => (compact ? "3px" : "8px")};
|
|
102
|
-
font-size: ${({ compact }) => (compact ? "10px" : "12px")};
|
|
103
|
-
overflow: hidden;
|
|
104
|
-
text-overflow: ellipsis;
|
|
105
|
-
white-space: nowrap;
|
|
106
|
-
|
|
107
|
-
background-color: ${({ theme }) => theme.palette.background.default};
|
|
108
|
-
|
|
109
|
-
border-bottom: 1px solid ${({ theme }) => theme.palette.divider};
|
|
110
|
-
|
|
111
|
-
&:first-child {
|
|
112
|
-
border-left: 1px solid ${({ theme }) => theme.palette.divider};
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
&:last-child {
|
|
116
|
-
border-right: 1px solid ${({ theme }) => theme.palette.divider};
|
|
117
|
-
}
|
|
118
|
-
`;
|
|
119
|
-
const StyledTh = styled.th `
|
|
120
|
-
position: sticky;
|
|
121
|
-
top: 0;
|
|
122
|
-
z-index: 1;
|
|
123
|
-
flex: 1;
|
|
124
|
-
vertical-align: middle;
|
|
125
|
-
user-select: none;
|
|
126
|
-
padding: ${({ compact }) => (compact ? "3px" : "8px")};
|
|
127
|
-
font-size: ${({ compact }) => (compact ? "10px" : "12px")};
|
|
128
|
-
text-align: left;
|
|
129
|
-
font-weight: bold;
|
|
130
|
-
overflow: hidden;
|
|
131
|
-
text-overflow: ellipsis;
|
|
132
|
-
white-space: nowrap;
|
|
133
|
-
|
|
134
|
-
background-color: ${({ theme }) => theme.palette.background.alt};
|
|
135
|
-
|
|
136
|
-
border-top: 1px solid ${({ theme }) => theme.palette.divider};
|
|
137
|
-
border-bottom: 1px solid ${({ theme }) => theme.palette.divider};
|
|
138
|
-
|
|
139
|
-
.action-header {
|
|
140
|
-
display: flex;
|
|
141
|
-
align-content: center;
|
|
142
|
-
align-items: center;
|
|
143
|
-
cursor: pointer;
|
|
144
|
-
color: ${({ theme }) => theme.palette.text.secondary};
|
|
145
|
-
margin-right: 5;
|
|
146
|
-
margin-left: 3;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
&:first-child {
|
|
150
|
-
border-left: 1px solid ${({ theme }) => theme.palette.divider};
|
|
151
|
-
border-top-left-radius: 4px;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
&:last-child {
|
|
155
|
-
border-right: 1px solid ${({ theme }) => theme.palette.divider};
|
|
156
|
-
border-top-right-radius: 4px;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
&:hover {
|
|
160
|
-
background-color: ${({ theme }) => theme.name === Themes.DARK ? "#2e2e2e" : "#f5f5f5"};
|
|
161
|
-
cursor: pointer;
|
|
162
|
-
}
|
|
163
|
-
&.dragging:active {
|
|
164
|
-
cursor: grabbing;
|
|
165
|
-
}
|
|
166
|
-
&.dragover .resizer {
|
|
167
|
-
opacity: 1;
|
|
168
|
-
background: ${(props) => props.theme.palette.primary.main};
|
|
169
|
-
cursor: grabbing;
|
|
170
|
-
}
|
|
171
|
-
`;
|
|
172
|
-
const enableResizeClass = (dataField) => {
|
|
173
|
-
document
|
|
174
|
-
.querySelectorAll(`.resizer.column-${dataField}`)
|
|
175
|
-
.forEach((resizer) => {
|
|
176
|
-
resizer.classList.add("isResizing");
|
|
177
|
-
});
|
|
178
|
-
};
|
|
179
|
-
const disableResizeClass = (dataField) => {
|
|
180
|
-
document
|
|
181
|
-
.querySelectorAll(`.resizer.column-${dataField}`)
|
|
182
|
-
.forEach((resizer) => {
|
|
183
|
-
resizer.classList.remove("isResizing");
|
|
30
|
+
const Table = (_a) => {
|
|
31
|
+
var { data, children } = _a, props = __rest(_a, ["data", "children"]) // pass through props straight to table context
|
|
32
|
+
;
|
|
33
|
+
const tableElement = useRef(null);
|
|
34
|
+
const targetElm = useRef(null);
|
|
35
|
+
const listElm = useRef(null);
|
|
36
|
+
const headerRowElm = useRef(null);
|
|
37
|
+
// check if children is array and convert if not
|
|
38
|
+
if (!Array.isArray(children)) {
|
|
39
|
+
children = [children];
|
|
40
|
+
}
|
|
41
|
+
const [tableDimensions, setTableDimensions] = useState({
|
|
42
|
+
width: 0,
|
|
43
|
+
height: 0,
|
|
184
44
|
});
|
|
185
|
-
|
|
186
|
-
const resizeHandler = ({ event, columnId, columnProps, onResize, onResizeFinished, }) => {
|
|
187
|
-
let col = event.target
|
|
188
|
-
.parentElement;
|
|
189
|
-
let newColumns = [];
|
|
190
|
-
let x = 0;
|
|
191
|
-
let w = 0;
|
|
192
|
-
const mouseMoveHandler = function (e) {
|
|
193
|
-
const selectedColumn = document.querySelectorAll(`.col-${columnId}`);
|
|
194
|
-
const columnHeaders = document.querySelectorAll(`.th.col-${columnId}`);
|
|
195
|
-
const dx = e.clientX - x;
|
|
196
|
-
let newWidth = w + dx;
|
|
197
|
-
if (newWidth < MIN_COLUMN_WIDTH) {
|
|
198
|
-
newWidth = MIN_COLUMN_WIDTH;
|
|
199
|
-
}
|
|
200
|
-
selectedColumn.forEach((col) => {
|
|
201
|
-
var _a;
|
|
202
|
-
col.style.width = `${newWidth}px`;
|
|
203
|
-
col.style.maxWidth = `${newWidth}px`;
|
|
204
|
-
col.style.minWidth = `${newWidth}px`;
|
|
205
|
-
newColumns.push({
|
|
206
|
-
dataField: ((_a = col === null || col === void 0 ? void 0 : col.dataset) === null || _a === void 0 ? void 0 : _a.field) || "",
|
|
207
|
-
width: newWidth,
|
|
208
|
-
});
|
|
209
|
-
});
|
|
210
|
-
newColumns = Array.from(columnHeaders).map((col) => {
|
|
211
|
-
var _a;
|
|
212
|
-
return {
|
|
213
|
-
dataField: ((_a = col === null || col === void 0 ? void 0 : col.dataset) === null || _a === void 0 ? void 0 : _a.field) || "",
|
|
214
|
-
width: newWidth,
|
|
215
|
-
};
|
|
216
|
-
});
|
|
217
|
-
onResize({
|
|
218
|
-
columns: newColumns,
|
|
219
|
-
});
|
|
220
|
-
};
|
|
221
|
-
const mouseUpHandler = function () {
|
|
45
|
+
const handleOnScroll = (event) => {
|
|
222
46
|
var _a, _b, _c;
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
document.addEventListener("mouseup", mouseUpHandler);
|
|
239
|
-
enableResizeClass(columnId);
|
|
240
|
-
};
|
|
241
|
-
const Resizer = styled(({ className, resizeHandler, onResize = () => { }, onResizeFinished, column, }) => {
|
|
242
|
-
return (_jsx("div", { className: `${className} resizer column-${column.props.columnId}`, onClick: (e) => {
|
|
243
|
-
e.stopPropagation();
|
|
244
|
-
e.nativeEvent.stopImmediatePropagation();
|
|
245
|
-
e.preventDefault();
|
|
246
|
-
}, onMouseDown: (e) => {
|
|
247
|
-
e.stopPropagation();
|
|
248
|
-
e.nativeEvent.stopImmediatePropagation();
|
|
249
|
-
e.preventDefault();
|
|
250
|
-
if (resizeHandler)
|
|
251
|
-
resizeHandler({
|
|
252
|
-
event: e,
|
|
253
|
-
columnId: column.props.columnId,
|
|
254
|
-
columnProps: column.props,
|
|
255
|
-
onResize: onResize,
|
|
256
|
-
onResizeFinished: onResizeFinished,
|
|
257
|
-
});
|
|
258
|
-
} }));
|
|
259
|
-
}) `
|
|
260
|
-
&.resizer {
|
|
261
|
-
position: absolute;
|
|
262
|
-
right: 0;
|
|
263
|
-
top: 0;
|
|
264
|
-
height: 100%;
|
|
265
|
-
width: 3px;
|
|
266
|
-
background-color: ${(props) => props.theme.palette.divider};
|
|
267
|
-
cursor: col-resize;
|
|
268
|
-
user-select: none;
|
|
269
|
-
touch-action: none;
|
|
270
|
-
opacity: 0;
|
|
271
|
-
&.isResizing {
|
|
272
|
-
opacity: 1;
|
|
273
|
-
background: ${(props) => props.theme.palette.primary.main};
|
|
274
|
-
}
|
|
275
|
-
// dragover css
|
|
276
|
-
&.dragover {
|
|
277
|
-
opacity: 1;
|
|
278
|
-
background: ${(props) => props.theme.palette.primary.main};
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
`;
|
|
282
|
-
const HeaderRowComponent = ({ columns, _compact, resizeState, headerHeight, onHeaderClick, onColumnResize, dropColumn, dragColumn, showSelection, selectAll, selectionState, handleSelectAll, handleColumnReorder, }) => {
|
|
283
|
-
return (_jsx(StyledThead, { children: _jsx(StyledHeaderRow, { compact: _compact, headerHeight: headerHeight, children: columns.map((column) => {
|
|
284
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
285
|
-
let savedColSize = ((_c = (_b = (_a = resizeState === null || resizeState === void 0 ? void 0 : resizeState.current) === null || _a === void 0 ? void 0 : _a.columns) === null || _b === void 0 ? void 0 : _b.find((col) => col.dataField === column.props.dataField)) === null || _c === void 0 ? void 0 : _c.width) || MIN_COLUMN_WIDTH;
|
|
286
|
-
if (savedColSize < MIN_COLUMN_WIDTH) {
|
|
287
|
-
savedColSize = MIN_COLUMN_WIDTH;
|
|
288
|
-
}
|
|
289
|
-
return (_jsxs(StyledTh, Object.assign({}, column.props, { className: `th ${((_d = column === null || column === void 0 ? void 0 : column.props) === null || _d === void 0 ? void 0 : _d.columnId) ? `col-${column.props.columnId}` : ""}`, "data-field": column.props.dataField, "data-type": "th", compact: _compact, onClick: (e) => {
|
|
290
|
-
if (column.props.allowSorting !== false)
|
|
291
|
-
onHeaderClick === null || onHeaderClick === void 0 ? void 0 : onHeaderClick(column.props);
|
|
292
|
-
}, draggable: column.props.allowReorder !== false ? true : false, onDragOver: (e) => {
|
|
293
|
-
e.preventDefault();
|
|
294
|
-
e.dataTransfer.dropEffect = "move";
|
|
295
|
-
}, onDragEnter: (e) => {
|
|
296
|
-
e.target.classList.add("dragover");
|
|
297
|
-
dropColumn.current = column.props;
|
|
298
|
-
}, onDragLeave: (e) => {
|
|
299
|
-
e.target.classList.remove("dragover");
|
|
300
|
-
}, onDrop: (e) => {
|
|
301
|
-
e.preventDefault();
|
|
302
|
-
e.target.classList.remove("dragover");
|
|
303
|
-
handleColumnReorder(dragColumn.current, dropColumn.current);
|
|
304
|
-
}, onDragStart: (e) => {
|
|
305
|
-
//set dragging class
|
|
306
|
-
dragColumn.current = column.props;
|
|
307
|
-
e.target.classList.add("dragging");
|
|
308
|
-
}, onDragEnd: (e) => {
|
|
309
|
-
e.target.classList.remove("dragging");
|
|
310
|
-
}, style: {
|
|
311
|
-
width: ((_e = column === null || column === void 0 ? void 0 : column.props) === null || _e === void 0 ? void 0 : _e.width)
|
|
312
|
-
? (_f = column === null || column === void 0 ? void 0 : column.props) === null || _f === void 0 ? void 0 : _f.width
|
|
313
|
-
: savedColSize || "auto",
|
|
314
|
-
maxWidth: ((_g = column === null || column === void 0 ? void 0 : column.props) === null || _g === void 0 ? void 0 : _g.width)
|
|
315
|
-
? (_h = column === null || column === void 0 ? void 0 : column.props) === null || _h === void 0 ? void 0 : _h.width
|
|
316
|
-
: savedColSize || "auto",
|
|
317
|
-
minWidth: ((_j = column === null || column === void 0 ? void 0 : column.props) === null || _j === void 0 ? void 0 : _j.width)
|
|
318
|
-
? (_k = column === null || column === void 0 ? void 0 : column.props) === null || _k === void 0 ? void 0 : _k.width
|
|
319
|
-
: savedColSize || MIN_COLUMN_WIDTH,
|
|
320
|
-
}, children: [_jsxs("div", { style: {
|
|
321
|
-
display: "flex",
|
|
322
|
-
alignContent: "center",
|
|
323
|
-
alignItems: "center",
|
|
324
|
-
pointerEvents: column.props.dataField === "action" ? "all" : "none",
|
|
325
|
-
}, children: [showSelection && column.props.dataField === "action" ? (_jsx("div", { className: "action-header", children: selectAll && (_jsx(CheckBox, { value: selectionState === "all", partialCheck: selectionState.includes("some"), onChange: handleSelectAll })) })) : (_jsx("div", { children: column.props.caption })), ((_m = (_l = column.props) === null || _l === void 0 ? void 0 : _l.sorting) === null || _m === void 0 ? void 0 : _m.active) && (_jsx("div", { style: { marginLeft: 5 }, children: column.props.sorting.direction === "asc" ? (_jsx(ArrowUpIcon, { size: 12 })) : (_jsx(ArrowDownIcon, { size: 12 })) }))] }), ((_o = column === null || column === void 0 ? void 0 : column.props) === null || _o === void 0 ? void 0 : _o.resizeEnabled) !== false && (_jsx(Resizer, { resizeHandler: resizeHandler, column: column, onResize: (e) => {
|
|
326
|
-
resizeState.current = e;
|
|
327
|
-
}, onResizeFinished: (e) => {
|
|
328
|
-
onColumnResize === null || onColumnResize === void 0 ? void 0 : onColumnResize(e);
|
|
329
|
-
} }))] }), shortUUID.generate()));
|
|
330
|
-
}) }) }));
|
|
331
|
-
};
|
|
332
|
-
const InnerElement = forwardRef((_a, ref) => {
|
|
333
|
-
var { children, columns, resizeState, _compact, stripes, onHeaderClick, dropColumn, dragColumn, showSelection, selectAll, selectionState, handleSelectAll, handleColumnReorder, onColumnResize, headerHeight } = _a, rest = __rest(_a, ["children", "columns", "resizeState", "_compact", "stripes", "onHeaderClick", "dropColumn", "dragColumn", "showSelection", "selectAll", "selectionState", "handleSelectAll", "handleColumnReorder", "onColumnResize", "headerHeight"]);
|
|
334
|
-
return (_jsxs(StyledTable, Object.assign({ ref: ref }, rest, { children: [_jsx(HeaderRowComponent, { columns: columns, resizeState: resizeState, _compact: _compact, headerHeight: headerHeight, onHeaderClick: onHeaderClick, dropColumn: dropColumn, dragColumn: dragColumn, showSelection: showSelection, selectAll: selectAll, selectionState: selectionState, handleSelectAll: handleSelectAll, handleColumnReorder: handleColumnReorder, onColumnResize: onColumnResize }), _jsx(StyledTbody, { className: "tbody" + (stripes ? " striped" : ""), stripes: stripes, children: children })] })));
|
|
335
|
-
});
|
|
336
|
-
const Row = ({ data, index, style }) => {
|
|
337
|
-
const { data: dataRows, columns, focusedRow, keyValue, _compact, queryKey, reloadFn, headerHeight, resizeState, onRowUpdated, onRowClick, onRowDoubleClick, } = data;
|
|
338
|
-
const item = (dataRows === null || dataRows === void 0 ? void 0 : dataRows[index]) || {};
|
|
339
|
-
const handleRowUpdated = (data) => {
|
|
340
|
-
onRowUpdated === null || onRowUpdated === void 0 ? void 0 : onRowUpdated({ rowData: item, updateData: data });
|
|
341
|
-
};
|
|
342
|
-
const isRowFocused = focusedRow
|
|
343
|
-
? focusedRow[keyValue] === item[keyValue]
|
|
344
|
-
: false;
|
|
345
|
-
const row = columns.map((column) => {
|
|
346
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3;
|
|
347
|
-
let value = null;
|
|
348
|
-
let savedColSize = ((_c = (_b = (_a = resizeState === null || resizeState === void 0 ? void 0 : resizeState.current) === null || _a === void 0 ? void 0 : _a.columns) === null || _b === void 0 ? void 0 : _b.find((col) => col.dataField === column.props.dataField)) === null || _c === void 0 ? void 0 : _c.width) || MIN_COLUMN_WIDTH;
|
|
349
|
-
if (savedColSize < MIN_COLUMN_WIDTH) {
|
|
350
|
-
savedColSize = MIN_COLUMN_WIDTH;
|
|
351
|
-
}
|
|
352
|
-
// parse datafield dot syntax
|
|
353
|
-
if ((_d = column.props.dataField) === null || _d === void 0 ? void 0 : _d.includes(".")) {
|
|
354
|
-
const fields = (_e = column.props.dataField) === null || _e === void 0 ? void 0 : _e.split(".");
|
|
355
|
-
value = fields.reduce((acc, field) => {
|
|
356
|
-
return acc === null || acc === void 0 ? void 0 : acc[field];
|
|
357
|
-
}, item);
|
|
47
|
+
(_a = props.onScroll) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
48
|
+
const { scrollTop, scrollHeight, clientHeight, scrollLeft } = event.currentTarget;
|
|
49
|
+
// move header row horizontally with the scroll
|
|
50
|
+
const headerRow = headerRowElm.current;
|
|
51
|
+
if (headerRow) {
|
|
52
|
+
// shift position of header row
|
|
53
|
+
headerRow.style.transform = `translateX(-${scrollLeft}px)`; // move header row horizontally with the scroll
|
|
54
|
+
}
|
|
55
|
+
// scroll to top
|
|
56
|
+
if (scrollTop <= 250) {
|
|
57
|
+
(_b = props.onScrollToTop) === null || _b === void 0 ? void 0 : _b.call(props, event);
|
|
58
|
+
}
|
|
59
|
+
// Scroll to bottom
|
|
60
|
+
if (scrollHeight - scrollTop <= clientHeight + 250) {
|
|
61
|
+
(_c = props.onScrollToBottom) === null || _c === void 0 ? void 0 : _c.call(props, event);
|
|
358
62
|
}
|
|
359
|
-
else
|
|
360
|
-
value = item === null || item === void 0 ? void 0 : item[column.props.dataField];
|
|
361
|
-
// format date values
|
|
362
|
-
if (column.props.dataType === "date" &&
|
|
363
|
-
((_g = (_f = column === null || column === void 0 ? void 0 : column.props) === null || _f === void 0 ? void 0 : _f.format) === null || _g === void 0 ? void 0 : _g.type) &&
|
|
364
|
-
value) {
|
|
365
|
-
const dateFormat = (_j = (_h = column === null || column === void 0 ? void 0 : column.props) === null || _h === void 0 ? void 0 : _h.format) === null || _j === void 0 ? void 0 : _j.type;
|
|
366
|
-
value = moment(value).format(dateFormat);
|
|
367
|
-
}
|
|
368
|
-
if (column.props.render) {
|
|
369
|
-
return (_jsxs(StyledTd, { className: `td ${((_k = column === null || column === void 0 ? void 0 : column.props) === null || _k === void 0 ? void 0 : _k.columnId) ? `col-${column.props.columnId}` : ""}`, title: ((_l = column === null || column === void 0 ? void 0 : column.props) === null || _l === void 0 ? void 0 : _l.titleRender) ? (_m = column === null || column === void 0 ? void 0 : column.props) === null || _m === void 0 ? void 0 : _m.titleRender(item) : null, compact: _compact, style: Object.assign({ width: ((_o = column === null || column === void 0 ? void 0 : column.props) === null || _o === void 0 ? void 0 : _o.width)
|
|
370
|
-
? (_p = column === null || column === void 0 ? void 0 : column.props) === null || _p === void 0 ? void 0 : _p.width
|
|
371
|
-
: savedColSize || "auto", maxWidth: ((_q = column === null || column === void 0 ? void 0 : column.props) === null || _q === void 0 ? void 0 : _q.width)
|
|
372
|
-
? (_r = column === null || column === void 0 ? void 0 : column.props) === null || _r === void 0 ? void 0 : _r.width
|
|
373
|
-
: savedColSize || "auto", minWidth: ((_s = column === null || column === void 0 ? void 0 : column.props) === null || _s === void 0 ? void 0 : _s.width)
|
|
374
|
-
? (_t = column === null || column === void 0 ? void 0 : column.props) === null || _t === void 0 ? void 0 : _t.width
|
|
375
|
-
: savedColSize || MIN_COLUMN_WIDTH }, (((_u = column === null || column === void 0 ? void 0 : column.props) === null || _u === void 0 ? void 0 : _u.style) || {})), "data-type": "td", children: [column.props.resizeEnabled !== false && _jsx(Resizer, { column: column }), column.props.render(item, {
|
|
376
|
-
queryKey: queryKey || "",
|
|
377
|
-
reload: reloadFn,
|
|
378
|
-
onRowUpdated: handleRowUpdated,
|
|
379
|
-
})] }, shortUUID.generate()));
|
|
380
|
-
}
|
|
381
|
-
return (_jsxs(StyledTd, { className: `td ${((_v = column === null || column === void 0 ? void 0 : column.props) === null || _v === void 0 ? void 0 : _v.columnId) ? `col-${column.props.columnId}` : ""}`, compact: _compact, title: ((_w = column === null || column === void 0 ? void 0 : column.props) === null || _w === void 0 ? void 0 : _w.titleRender) ? (_x = column === null || column === void 0 ? void 0 : column.props) === null || _x === void 0 ? void 0 : _x.titleRender(item) : null, "data-type": "td", style: {
|
|
382
|
-
width: ((_y = column === null || column === void 0 ? void 0 : column.props) === null || _y === void 0 ? void 0 : _y.width)
|
|
383
|
-
? (_z = column === null || column === void 0 ? void 0 : column.props) === null || _z === void 0 ? void 0 : _z.width
|
|
384
|
-
: savedColSize || "auto",
|
|
385
|
-
maxWidth: ((_0 = column === null || column === void 0 ? void 0 : column.props) === null || _0 === void 0 ? void 0 : _0.width)
|
|
386
|
-
? (_1 = column === null || column === void 0 ? void 0 : column.props) === null || _1 === void 0 ? void 0 : _1.width
|
|
387
|
-
: savedColSize || "auto",
|
|
388
|
-
minWidth: ((_2 = column === null || column === void 0 ? void 0 : column.props) === null || _2 === void 0 ? void 0 : _2.width)
|
|
389
|
-
? (_3 = column === null || column === void 0 ? void 0 : column.props) === null || _3 === void 0 ? void 0 : _3.width
|
|
390
|
-
: savedColSize || MIN_COLUMN_WIDTH,
|
|
391
|
-
}, children: [column.props.resizeEnabled !== false && _jsx(Resizer, { column: column }), value] }, shortUUID.generate()));
|
|
392
|
-
});
|
|
393
|
-
return (_jsx(StyledTr, { className: `tr${isRowFocused ? " focused" : ""}`, "data-key": item[keyValue], "data-type": "tr", "data-even": index % 2 === 0 ? "true" : "false", compact: _compact, onClick: (e) => {
|
|
394
|
-
// dblclick event
|
|
395
|
-
if (e.detail === 2) {
|
|
396
|
-
onRowDoubleClick === null || onRowDoubleClick === void 0 ? void 0 : onRowDoubleClick(item);
|
|
397
|
-
}
|
|
398
|
-
else {
|
|
399
|
-
onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(item);
|
|
400
|
-
}
|
|
401
|
-
}, style: Object.assign(Object.assign({}, style), { top: ((style === null || style === void 0 ? void 0 : style.top) || 0) + headerHeight }), children: row }, shortUUID.generate()));
|
|
402
|
-
};
|
|
403
|
-
export const useTable = () => {
|
|
404
|
-
const [tableInstance, setTableInstance] = useState(null);
|
|
405
|
-
return {
|
|
406
|
-
setTableInstance,
|
|
407
|
-
toggleCompact: () => tableInstance === null || tableInstance === void 0 ? void 0 : tableInstance.toggleCompact(),
|
|
408
|
-
toggleStripes: () => tableInstance === null || tableInstance === void 0 ? void 0 : tableInstance.toggleStripes(),
|
|
409
|
-
isCompact: (tableInstance === null || tableInstance === void 0 ? void 0 : tableInstance.isCompact) || false,
|
|
410
|
-
isStriped: (tableInstance === null || tableInstance === void 0 ? void 0 : tableInstance.isStriped) || false,
|
|
411
|
-
getVirtualSelectionTotal: () => (tableInstance === null || tableInstance === void 0 ? void 0 : tableInstance.getVirtualSelectionTotal()) || 0,
|
|
412
|
-
getSelectedRows: () => (tableInstance === null || tableInstance === void 0 ? void 0 : tableInstance.getSelectedRows()) || [],
|
|
413
|
-
getExcludedRows: () => (tableInstance === null || tableInstance === void 0 ? void 0 : tableInstance.getExcludedRows()) || [],
|
|
414
|
-
getSelectionState: () => (tableInstance === null || tableInstance === void 0 ? void 0 : tableInstance.getSelectionState()) || {},
|
|
415
|
-
clearSelections: () => tableInstance === null || tableInstance === void 0 ? void 0 : tableInstance.clearSelections(),
|
|
416
|
-
onColumnResize: (e) => tableInstance === null || tableInstance === void 0 ? void 0 : tableInstance.onColumnResize(e),
|
|
417
63
|
};
|
|
418
|
-
};
|
|
419
|
-
const Table = styled(({ className, children, data, rowHeight, headerHeight, tableInstance, queryKey, totalRecords, compact, focusedRow, keyValue, onScroll, allowColumnResize, allowColumnReorder, showActionColumn, showSelection, selectAll, reloadFn, onColumnReorder, onSelectionChanged, onActionButtonClick, onHeaderClick, onColumnResize, onRowUpdated, onRowClick, onRowDoubleClick, }) => {
|
|
420
|
-
const rootRef = useRef(null);
|
|
421
64
|
const [initialize, getInstance] = useOverlayScrollbars({
|
|
422
65
|
options: {
|
|
423
66
|
scrollbars: {
|
|
@@ -425,291 +68,42 @@ const Table = styled(({ className, children, data, rowHeight, headerHeight, tabl
|
|
|
425
68
|
autoHideDelay: 500,
|
|
426
69
|
},
|
|
427
70
|
},
|
|
428
|
-
events: {
|
|
71
|
+
events: {
|
|
72
|
+
scroll: (_, event) => handleOnScroll(event),
|
|
73
|
+
},
|
|
429
74
|
});
|
|
430
|
-
const
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
const [_compact, setCompact] = useState(compact);
|
|
435
|
-
const [stripes, setStripes] = useState(false);
|
|
436
|
-
const [selectedRows, setSelectedRows] = useState([]);
|
|
437
|
-
const [virtualSelectionTotal, setVirtualSelectionTotal] = useState(0);
|
|
438
|
-
const [excludedRows, setExcludedRows] = useState([]);
|
|
439
|
-
const [selectionState, setSelectionState] = useState("none");
|
|
440
|
-
const resizeState = useRef([]);
|
|
441
|
-
// check if children is an array
|
|
442
|
-
children = useMemo(() => {
|
|
443
|
-
return Array.isArray(children) ? children : [children];
|
|
444
|
-
}, [children]);
|
|
445
|
-
let columns = useMemo(() => children === null || children === void 0 ? void 0 : children.map((column) => {
|
|
446
|
-
var _a, _b, _c;
|
|
447
|
-
return cloneElement(column, {
|
|
448
|
-
columnId: shortUUID.generate(), // Set unique ID for each column
|
|
449
|
-
allowResize: allowColumnResize !== undefined
|
|
450
|
-
? allowColumnResize
|
|
451
|
-
: (_a = column === null || column === void 0 ? void 0 : column.props) === null || _a === void 0 ? void 0 : _a.allowResize,
|
|
452
|
-
allowReorder: allowColumnReorder !== undefined
|
|
453
|
-
? allowColumnReorder
|
|
454
|
-
: (_b = column === null || column === void 0 ? void 0 : column.props) === null || _b === void 0 ? void 0 : _b.allowReorder,
|
|
455
|
-
resizeEnabled: allowColumnResize !== undefined
|
|
456
|
-
? allowColumnResize
|
|
457
|
-
: (_c = column === null || column === void 0 ? void 0 : column.props) === null || _c === void 0 ? void 0 : _c.resizeEnabled,
|
|
458
|
-
});
|
|
459
|
-
}), [children]);
|
|
460
|
-
const [columnOrder, setColumnOrder] = useState(columns.map((col, index) => {
|
|
461
|
-
var _a, _b;
|
|
462
|
-
return {
|
|
463
|
-
column: (_a = col.props) === null || _a === void 0 ? void 0 : _a.dataField,
|
|
464
|
-
order: ((_b = col.props) === null || _b === void 0 ? void 0 : _b.order) || index,
|
|
465
|
-
};
|
|
466
|
-
}));
|
|
467
|
-
const handleColumnReorder = (dragColumn, dropColumn) => {
|
|
468
|
-
var _a;
|
|
469
|
-
const dropColumnOrder = (_a = columnOrder.find((col) => col.column === dropColumn.dataField)) === null || _a === void 0 ? void 0 : _a.order;
|
|
470
|
-
const newColumnOrder = columnOrder.map((col) => {
|
|
471
|
-
if (col.column === dragColumn.dataField) {
|
|
472
|
-
return { column: col.column, order: dropColumnOrder + 1 };
|
|
473
|
-
}
|
|
474
|
-
else {
|
|
475
|
-
return col.order > dropColumnOrder
|
|
476
|
-
? Object.assign(Object.assign({}, col), { order: col.order + 1 }) : col;
|
|
477
|
-
}
|
|
478
|
-
});
|
|
479
|
-
onColumnReorder === null || onColumnReorder === void 0 ? void 0 : onColumnReorder(newColumnOrder);
|
|
480
|
-
setColumnOrder(newColumnOrder);
|
|
481
|
-
};
|
|
482
|
-
const handleSelectAll = () => {
|
|
483
|
-
let newSelectionState = null;
|
|
484
|
-
let newVirtualSelectionTotal = null;
|
|
485
|
-
if (selectionState === "all") {
|
|
486
|
-
// clear current selections
|
|
487
|
-
setSelectedRows([]);
|
|
488
|
-
// turn off all rows selected
|
|
489
|
-
newSelectionState = "none";
|
|
490
|
-
setSelectionState("none");
|
|
491
|
-
// clear excluded rows
|
|
492
|
-
setExcludedRows([]);
|
|
493
|
-
newVirtualSelectionTotal = 0;
|
|
494
|
-
setVirtualSelectionTotal(newVirtualSelectionTotal);
|
|
495
|
-
}
|
|
496
|
-
else {
|
|
497
|
-
// turn on all rows selected
|
|
498
|
-
newSelectionState = "all";
|
|
499
|
-
setSelectionState("all");
|
|
500
|
-
// clear excluded rows
|
|
501
|
-
setExcludedRows([]);
|
|
502
|
-
newVirtualSelectionTotal = totalRecords;
|
|
503
|
-
setVirtualSelectionTotal(newVirtualSelectionTotal);
|
|
504
|
-
}
|
|
505
|
-
onSelectionChanged === null || onSelectionChanged === void 0 ? void 0 : onSelectionChanged({
|
|
506
|
-
selectedRows: [],
|
|
507
|
-
excludedRows: [],
|
|
508
|
-
selectionState: newSelectionState,
|
|
509
|
-
virtualSelectionTotal: newVirtualSelectionTotal,
|
|
510
|
-
});
|
|
511
|
-
};
|
|
512
|
-
const handleSelectRow = ({ rowData, checked, }) => {
|
|
513
|
-
let newSelectedRows = [];
|
|
514
|
-
let newExcludedRows = [];
|
|
515
|
-
let newSelectionState = null;
|
|
516
|
-
let newVirtualSelectionTotal = null;
|
|
517
|
-
if (selectionState === "all") {
|
|
518
|
-
newExcludedRows = [...excludedRows, rowData];
|
|
519
|
-
newSelectionState = "someExcluded";
|
|
520
|
-
newVirtualSelectionTotal = totalRecords ? totalRecords - 1 : 0;
|
|
521
|
-
}
|
|
522
|
-
else if (selectionState === "none") {
|
|
523
|
-
newSelectedRows = [rowData];
|
|
524
|
-
newSelectionState = "someIncluded";
|
|
525
|
-
newVirtualSelectionTotal = 1;
|
|
526
|
-
}
|
|
527
|
-
else if (selectionState === "someExcluded") {
|
|
528
|
-
newSelectionState = "someExcluded";
|
|
529
|
-
newSelectedRows = selectedRows;
|
|
530
|
-
if (checked) {
|
|
531
|
-
// remove from excluded rows
|
|
532
|
-
newExcludedRows = excludedRows.filter((row) => keyValue ? (row === null || row === void 0 ? void 0 : row[keyValue]) !== (rowData === null || rowData === void 0 ? void 0 : rowData[keyValue]) : false);
|
|
533
|
-
newVirtualSelectionTotal = virtualSelectionTotal
|
|
534
|
-
? virtualSelectionTotal + 1
|
|
535
|
-
: 0;
|
|
536
|
-
}
|
|
537
|
-
else {
|
|
538
|
-
// add to excluded rows
|
|
539
|
-
newExcludedRows = [...excludedRows, rowData];
|
|
540
|
-
newVirtualSelectionTotal = virtualSelectionTotal
|
|
541
|
-
? virtualSelectionTotal - 1
|
|
542
|
-
: 0;
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
else if (selectionState === "someIncluded") {
|
|
546
|
-
newSelectionState = "someIncluded";
|
|
547
|
-
newExcludedRows = excludedRows;
|
|
548
|
-
if (checked) {
|
|
549
|
-
// add to selected rows
|
|
550
|
-
newSelectedRows = [...selectedRows, rowData];
|
|
551
|
-
newVirtualSelectionTotal = virtualSelectionTotal
|
|
552
|
-
? virtualSelectionTotal + 1
|
|
553
|
-
: 0;
|
|
554
|
-
}
|
|
555
|
-
else {
|
|
556
|
-
// remove from selected rows
|
|
557
|
-
newSelectedRows = selectedRows.filter((row) => keyValue ? row[keyValue] !== rowData[keyValue] : false);
|
|
558
|
-
newVirtualSelectionTotal = virtualSelectionTotal
|
|
559
|
-
? virtualSelectionTotal - 1
|
|
560
|
-
: 0;
|
|
561
|
-
}
|
|
75
|
+
const getTableDimensions = () => {
|
|
76
|
+
if (tableElement.current) {
|
|
77
|
+
const { width, height } = tableElement.current.getBoundingClientRect();
|
|
78
|
+
setTableDimensions({ width, height });
|
|
562
79
|
}
|
|
563
|
-
if (newVirtualSelectionTotal === totalRecords) {
|
|
564
|
-
newSelectionState = "all";
|
|
565
|
-
}
|
|
566
|
-
else if (newVirtualSelectionTotal === 0) {
|
|
567
|
-
newSelectionState = "none";
|
|
568
|
-
}
|
|
569
|
-
setSelectedRows(newSelectedRows);
|
|
570
|
-
setExcludedRows(newExcludedRows);
|
|
571
|
-
setVirtualSelectionTotal(newVirtualSelectionTotal);
|
|
572
|
-
setSelectionState(newSelectionState);
|
|
573
|
-
onSelectionChanged === null || onSelectionChanged === void 0 ? void 0 : onSelectionChanged({
|
|
574
|
-
selectedRows: newSelectedRows,
|
|
575
|
-
excludedRows: newExcludedRows,
|
|
576
|
-
selectionState: newSelectionState,
|
|
577
|
-
virtualSelectionTotal: newVirtualSelectionTotal,
|
|
578
|
-
});
|
|
579
80
|
};
|
|
580
|
-
// sort columns
|
|
581
|
-
columns = useMemo(() => columns.sort((a, b) => {
|
|
582
|
-
var _a, _b;
|
|
583
|
-
const aOrder = (_a = columnOrder.find((col) => col.column === a.props.dataField)) === null || _a === void 0 ? void 0 : _a.order;
|
|
584
|
-
const bOrder = (_b = columnOrder.find((col) => col.column === b.props.dataField)) === null || _b === void 0 ? void 0 : _b.order;
|
|
585
|
-
return aOrder - bOrder;
|
|
586
|
-
}), [columnOrder, columns]);
|
|
587
|
-
const hiddenColumns = columns
|
|
588
|
-
.filter((col) => col.props.visible === false)
|
|
589
|
-
.map((col) => col.props.dataField);
|
|
590
|
-
// insert action column as first column
|
|
591
|
-
showActionColumn &&
|
|
592
|
-
(columns = [
|
|
593
|
-
_jsx(Column, { className: "action-column", dataField: "action", allowSorting: false, allowReorder: false, caption: "", width: showSelection ? 55 : 35, resizeEnabled: false, render: (rowData) => (_jsxs("div", { className: "action-column-container", children: [showSelection && (_jsx("div", { className: "action-button", children: _jsx(CheckBox, { value: selectionState === "all"
|
|
594
|
-
? true
|
|
595
|
-
: selectionState === "someIncluded"
|
|
596
|
-
? !!selectedRows.find((row) => keyValue
|
|
597
|
-
? row[keyValue] === rowData[keyValue]
|
|
598
|
-
: false)
|
|
599
|
-
: selectionState === "someExcluded"
|
|
600
|
-
? !excludedRows.find((row) => keyValue
|
|
601
|
-
? row[keyValue] === rowData[keyValue]
|
|
602
|
-
: false)
|
|
603
|
-
: false, onChange: (newValue) => handleSelectRow({ rowData, checked: newValue }) }) })), _jsx("div", { className: "action-button", title: "Show More Details", onClick: (e) => {
|
|
604
|
-
onActionButtonClick === null || onActionButtonClick === void 0 ? void 0 : onActionButtonClick(rowData);
|
|
605
|
-
}, children: _jsx(Maximize2Icon, { size: _compact ? 8 : 12 }) })] })) }, shortUUID.generate()),
|
|
606
|
-
...columns,
|
|
607
|
-
]);
|
|
608
81
|
useEffect(() => {
|
|
609
|
-
if (targetElm && listElm) {
|
|
82
|
+
if (targetElm.current && listElm.current) {
|
|
610
83
|
initialize({
|
|
611
|
-
target: targetElm,
|
|
84
|
+
target: targetElm.current,
|
|
612
85
|
elements: {
|
|
613
|
-
viewport: listElm,
|
|
86
|
+
viewport: listElm.current,
|
|
614
87
|
},
|
|
615
88
|
});
|
|
616
89
|
return () => { var _a; return (_a = getInstance()) === null || _a === void 0 ? void 0 : _a.destroy(); };
|
|
617
90
|
}
|
|
618
|
-
}, [targetElm, listElm]);
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
});
|
|
637
|
-
}
|
|
638
|
-
}, [
|
|
639
|
-
selectedRows,
|
|
640
|
-
excludedRows,
|
|
641
|
-
virtualSelectionTotal,
|
|
642
|
-
selectionState,
|
|
643
|
-
_compact,
|
|
644
|
-
stripes,
|
|
645
|
-
tableInstance,
|
|
646
|
-
]);
|
|
647
|
-
useEffect(() => {
|
|
648
|
-
// Scroll to selected row if outside of viewport
|
|
649
|
-
if (focusedRow) {
|
|
650
|
-
const focusedRowElm = keyValue
|
|
651
|
-
? document.querySelector(`[data-type="tr"][data-key="${focusedRow[keyValue]}"]`)
|
|
652
|
-
: null;
|
|
653
|
-
if (focusedRowElm) {
|
|
654
|
-
focusedRowElm.scrollIntoView({
|
|
655
|
-
behavior: "smooth",
|
|
656
|
-
block: "nearest",
|
|
657
|
-
inline: "nearest",
|
|
658
|
-
});
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
}, [focusedRow]);
|
|
662
|
-
return (_jsx("div", { ref: rootRef, className: className + " table-wrapper", children: _jsx(AutoSizer, { children: ({ height, width }) => (_jsx("div", { style: { width, height }, "data-overlayscrollbars": "", ref: setTargetElm, children: _jsx(FixedSizeList, { overscanCount: 10, itemData: {
|
|
663
|
-
data,
|
|
664
|
-
columns: columns.filter((col) => !hiddenColumns.includes(col.props.dataField)),
|
|
665
|
-
focusedRow,
|
|
666
|
-
keyValue,
|
|
667
|
-
_compact,
|
|
668
|
-
queryKey,
|
|
669
|
-
reloadFn,
|
|
670
|
-
rowHeight: rowHeight ? rowHeight : _compact ? 28 : 38,
|
|
671
|
-
headerHeight: headerHeight
|
|
672
|
-
? headerHeight
|
|
673
|
-
: _compact
|
|
674
|
-
? 28
|
|
675
|
-
: 38,
|
|
676
|
-
resizeState,
|
|
677
|
-
onRowUpdated,
|
|
678
|
-
onRowClick,
|
|
679
|
-
onRowDoubleClick,
|
|
680
|
-
tableWidth: width,
|
|
681
|
-
}, height: height, innerElementType: (props) => (_jsx(InnerElement, Object.assign({}, props, { columns: columns.filter((col) => !hiddenColumns.includes(col.props.dataField)), tableWidth: width, resizeState: resizeState, _compact: _compact, stripes: stripes, onHeaderClick: onHeaderClick, dropColumn: dropColumn, dragColumn: dragColumn, showSelection: showSelection, selectAll: selectAll, selectionState: selectionState, handleSelectAll: handleSelectAll, handleColumnReorder: handleColumnReorder, onColumnResize: onColumnResize }))), itemCount: data === null || data === void 0 ? void 0 : data.length, itemSize: rowHeight ? rowHeight : _compact ? 28 : 38, width: width, outerRef: setListElm, children: Row }) })) }) }));
|
|
682
|
-
}) `
|
|
683
|
-
position: relative;
|
|
684
|
-
flex: 1 1 auto;
|
|
685
|
-
overflow: hidden;
|
|
686
|
-
display: flex;
|
|
687
|
-
flex-direction: column;
|
|
688
|
-
|
|
689
|
-
.os-scrollbar {
|
|
690
|
-
pointer-events: auto;
|
|
691
|
-
visibility: visible;
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
.action-column {
|
|
695
|
-
max-width: 55px;
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
.action-column-container {
|
|
699
|
-
display: flex;
|
|
700
|
-
align-content: center;
|
|
701
|
-
align-items: center;
|
|
702
|
-
padding: 4px;
|
|
703
|
-
color: ${({ theme }) => theme.palette.text.secondary};
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
.action-button {
|
|
707
|
-
display: flex;
|
|
708
|
-
align-content: center;
|
|
709
|
-
align-items: center;
|
|
710
|
-
cursor: pointer;
|
|
711
|
-
color: ${({ theme }) => theme.palette.primary.main};
|
|
712
|
-
margin-right: 5px;
|
|
713
|
-
}
|
|
714
|
-
`;
|
|
91
|
+
}, [targetElm, listElm, initialize, getInstance]);
|
|
92
|
+
useLayoutEffect(() => {
|
|
93
|
+
const element = tableElement.current;
|
|
94
|
+
if (!element)
|
|
95
|
+
return;
|
|
96
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
97
|
+
getTableDimensions();
|
|
98
|
+
});
|
|
99
|
+
resizeObserver.observe(element);
|
|
100
|
+
return () => {
|
|
101
|
+
resizeObserver.unobserve(element);
|
|
102
|
+
};
|
|
103
|
+
}, []);
|
|
104
|
+
const __data = useMemo(() => data === null || data === void 0 ? void 0 : data.map((d, i) => (Object.assign(Object.assign({}, d), { __key: shortUUID.generate(), __index: i }))), [data]);
|
|
105
|
+
return (_jsx(TableProvider, Object.assign({ columns: children
|
|
106
|
+
.filter((child) => child.type === Column)
|
|
107
|
+
.map((child) => child.props), data: __data, tableElement: tableElement, headerRowElm: headerRowElm, tableDimensions: tableDimensions, targetElm: targetElm, listElm: listElm }, props, { children: _jsx(TableContent, {}) })));
|
|
108
|
+
};
|
|
715
109
|
export default Table;
|