@synerise/ds-table 0.60.1 → 0.60.3
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/CHANGELOG.md +19 -0
- package/dist/Cell/Action/ActionCell.js +5 -11
- package/dist/Cell/Action/ActionCell.styles.js +2 -1
- package/dist/Cell/AvatarLabel/AvatarLabel.js +10 -18
- package/dist/Cell/Copyable/Copyable.styles.js +2 -1
- package/dist/Cell/Copyable/CopyableCell.js +6 -12
- package/dist/Cell/Editable/EditableCell.js +7 -14
- package/dist/Cell/FlagLabel/FlagLabelCell.js +2 -7
- package/dist/Cell/FlagLabel/FlagLabelCell.styles.js +2 -1
- package/dist/Cell/IconLabel/IconLabel.js +2 -7
- package/dist/Cell/IconLabel/IconLabel.styles.js +2 -1
- package/dist/Cell/IconTooltipCell/IconTooltipCell.js +7 -13
- package/dist/Cell/LabelsWithShowMore/LabelsWithShowMore.js +8 -14
- package/dist/Cell/LabelsWithShowMore/Modal/Modal.js +8 -12
- package/dist/Cell/Star/StarCell.d.ts +4 -3
- package/dist/Cell/Star/StarCell.js +5 -10
- package/dist/Cell/Star/StarCell.styles.d.ts +2 -6
- package/dist/Cell/StatusLabel/StatusLabel.js +3 -8
- package/dist/Cell/TagIcon/TagIcon.js +1 -6
- package/dist/Cell/TagIcon/TagIcon.styles.js +2 -1
- package/dist/ColumnSortMenu/SortIcons.js +3 -15
- package/dist/ColumnSortMenu/SortRenderer.js +8 -14
- package/dist/ColumnSortMenu/TitleWithSort.js +3 -7
- package/dist/ColumnSortMenu/columnWithSortButtons.js +0 -10
- package/dist/ColumnSortMenu/groupedColumnsSort.js +2 -15
- package/dist/ColumnSortMenu/replaceSortButtons.js +0 -7
- package/dist/ColumnSortMenu/useSortState.js +4 -40
- package/dist/DefaultTable/DefaultTable.js +26 -50
- package/dist/FilterTrigger/FilterTrigger.js +16 -20
- package/dist/GroupTable/GroupTable.js +24 -40
- package/dist/GroupTable/GroupTable.styles.js +2 -2
- package/dist/GroupTable/GroupTableBody/GroupTableBody.js +12 -17
- package/dist/GroupTable/GroupTableHeader/GroupTableHeader.js +6 -7
- package/dist/InfiniteScroll/BackToTopButton.js +0 -1
- package/dist/InfiniteScroll/InfiniteLoaderItem.js +9 -12
- package/dist/InfiniteScroll/OuterListElement.js +7 -25
- package/dist/InfiniteScroll/utils.js +2 -2
- package/dist/ItemsMenu/ItemsMenu.js +0 -2
- package/dist/ItemsMenu/ItemsMenu.styles.js +2 -1
- package/dist/RowSelection/RowSelectionColumn.js +12 -22
- package/dist/Table.js +26 -40
- package/dist/TableHeader/TableHeader.js +21 -28
- package/dist/TableHeader/TableLimit/TableLimit.js +4 -7
- package/dist/TableHeader/TableSelection.js +13 -34
- package/dist/TreeTable/TreeTable.js +9 -11
- package/dist/TreeTable/TreeTable.styles.js +0 -2
- package/dist/VirtualTable/VirtualTable.js +101 -178
- package/dist/VirtualTable/VirtualTable.styles.js +0 -3
- package/dist/VirtualTable/VirtualTableRow.js +10 -26
- package/dist/constants/TableSkeleton.constants.js +0 -1
- package/dist/hooks/useRowKey/useRowKey.js +3 -1
- package/dist/hooks/useRowStar/useRowStar.js +6 -12
- package/dist/utils/calculateColumnWidths.js +0 -5
- package/dist/utils/calculatePixels.js +4 -10
- package/dist/utils/getRecordSelectionStatus.js +2 -3
- package/dist/utils/getSkeletonProps.js +7 -15
- package/dist/utils/getValueFromPath.js +2 -1
- package/dist/utils/isRecordSelectable.js +2 -4
- package/dist/utils/locale.js +0 -5
- package/package.json +27 -27
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
var _excluded = ["style"];
|
|
2
|
-
|
|
3
2
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
-
|
|
5
3
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
6
|
-
|
|
7
4
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
8
|
-
|
|
9
5
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
10
|
-
|
|
11
6
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
12
|
-
|
|
13
7
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
14
|
-
|
|
15
8
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
16
|
-
|
|
17
9
|
import React, { useCallback, useState, useRef, forwardRef, useEffect, useMemo, useImperativeHandle } from 'react';
|
|
18
10
|
import { FixedSizeList as List } from 'react-window';
|
|
19
11
|
import ResizeObserver from 'rc-resize-observer';
|
|
@@ -35,34 +27,32 @@ import { getChildrenColumnName } from '../utils/getChildrenColumnName';
|
|
|
35
27
|
var relativeInlineStyle = {
|
|
36
28
|
position: 'relative'
|
|
37
29
|
};
|
|
38
|
-
|
|
39
30
|
var VirtualTable = function VirtualTable(props, forwardedRef) {
|
|
40
31
|
var _infiniteScroll$prevP2, _infiniteScroll$prevP4;
|
|
41
|
-
|
|
42
32
|
var _props$columns = props.columns,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
33
|
+
columns = _props$columns === void 0 ? [] : _props$columns,
|
|
34
|
+
scroll = props.scroll,
|
|
35
|
+
className = props.className,
|
|
36
|
+
_props$cellHeight = props.cellHeight,
|
|
37
|
+
cellHeight = _props$cellHeight === void 0 ? 52 : _props$cellHeight,
|
|
38
|
+
infiniteScroll = props.infiniteScroll,
|
|
39
|
+
selection = props.selection,
|
|
40
|
+
onRowClick = props.onRowClick,
|
|
41
|
+
rowKey = props.rowKey,
|
|
42
|
+
rowStar = props.rowStar,
|
|
43
|
+
_props$initialWidth = props.initialWidth,
|
|
44
|
+
initialWidth = _props$initialWidth === void 0 ? 0 : _props$initialWidth,
|
|
45
|
+
_props$dataSource = props.dataSource,
|
|
46
|
+
dataSource = _props$dataSource === void 0 ? [] : _props$dataSource,
|
|
47
|
+
dataSourceFull = props.dataSourceFull,
|
|
48
|
+
dataSourceTotalCount = props.dataSourceTotalCount,
|
|
49
|
+
expandable = props.expandable,
|
|
50
|
+
locale = props.locale,
|
|
51
|
+
loading = props.loading,
|
|
52
|
+
sticky = props.sticky,
|
|
53
|
+
onListRefChange = props.onListRefChange,
|
|
54
|
+
onItemsRendered = props.onItemsRendered,
|
|
55
|
+
onScrollToRecordIndex = props.onScrollToRecordIndex;
|
|
66
56
|
var intl = useIntl();
|
|
67
57
|
var tableLocale = useTableLocale(intl, locale);
|
|
68
58
|
var listRef = useRef(null);
|
|
@@ -71,15 +61,12 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
|
|
|
71
61
|
var containerRef = useRef(null);
|
|
72
62
|
var horizontalScrollRef = useRef(null);
|
|
73
63
|
var customBodyOnScrollRef = useRef();
|
|
74
|
-
|
|
75
64
|
var _useState = useState(false),
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
65
|
+
isHeaderVisible = _useState[0],
|
|
66
|
+
setIsHeaderVisible = _useState[1];
|
|
79
67
|
var _useState2 = useState(null),
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
68
|
+
firstItem = _useState2[0],
|
|
69
|
+
setFirstItem = _useState2[1];
|
|
83
70
|
var childrenColumnName = getChildrenColumnName(expandable == null ? void 0 : expandable.childrenColumnName);
|
|
84
71
|
var hasInfiniteScroll = Boolean(infiniteScroll);
|
|
85
72
|
var isSticky = Boolean(sticky);
|
|
@@ -88,7 +75,6 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
|
|
|
88
75
|
var updateFirstItem = useCallback(function (findFirstItem) {
|
|
89
76
|
var prevFirstItemIndex = dataSource.findIndex(findFirstItem);
|
|
90
77
|
setFirstItem(dataSource[0]);
|
|
91
|
-
|
|
92
78
|
if (prevFirstItemIndex >= 0 && listRef != null && listRef.current) {
|
|
93
79
|
if (onScrollToRecordIndex) {
|
|
94
80
|
onScrollToRecordIndex(prevFirstItemIndex, function () {
|
|
@@ -110,34 +96,27 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
|
|
|
110
96
|
if (!(infiniteScroll != null && infiniteScroll.prevPage) || dataSourceEmpty) {
|
|
111
97
|
return;
|
|
112
98
|
}
|
|
113
|
-
|
|
114
99
|
if (firstItem === null) {
|
|
115
100
|
setFirstItem(dataSource[0]);
|
|
116
101
|
return;
|
|
117
102
|
}
|
|
118
|
-
|
|
119
103
|
if (rowKey === undefined) {
|
|
120
104
|
var firstItemStringified = JSON.stringify(firstItem);
|
|
121
|
-
|
|
122
105
|
if (JSON.stringify(dataSource[0]) !== firstItemStringified) {
|
|
123
106
|
updateFirstItem(function (item) {
|
|
124
107
|
return JSON.stringify(item) === firstItemStringified;
|
|
125
108
|
});
|
|
126
109
|
}
|
|
127
|
-
|
|
128
110
|
return;
|
|
129
111
|
}
|
|
130
|
-
|
|
131
112
|
if (typeof rowKey === 'string') {
|
|
132
113
|
if (dataSource[0][rowKey] !== firstItem[rowKey]) {
|
|
133
114
|
updateFirstItem(function (item) {
|
|
134
115
|
return item[rowKey] === firstItem[rowKey];
|
|
135
116
|
});
|
|
136
117
|
}
|
|
137
|
-
|
|
138
118
|
return;
|
|
139
119
|
}
|
|
140
|
-
|
|
141
120
|
if (typeof rowKey === 'function') {
|
|
142
121
|
if (rowKey(dataSource[0]) !== rowKey(firstItem)) {
|
|
143
122
|
updateFirstItem(function (item) {
|
|
@@ -151,7 +130,6 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
|
|
|
151
130
|
}, [dataSource, dataSourceEmpty, rowKey, firstItem, infiniteScroll, updateFirstItem]);
|
|
152
131
|
useEffect(function () {
|
|
153
132
|
var _infiniteScroll$prevP;
|
|
154
|
-
|
|
155
133
|
if (listRef.current && infiniteScroll != null && (_infiniteScroll$prevP = infiniteScroll.prevPage) != null && _infiniteScroll$prevP.hasMore) {
|
|
156
134
|
listRef.current.scrollTo(INFINITE_LOADED_ITEM_HEIGHT);
|
|
157
135
|
}
|
|
@@ -165,37 +143,29 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
|
|
|
165
143
|
scrollToTop: scrollToTop
|
|
166
144
|
};
|
|
167
145
|
});
|
|
168
|
-
|
|
169
146
|
var _useState3 = useState(initialWidth),
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
147
|
+
tableWidth = _useState3[0],
|
|
148
|
+
setTableWidth = _useState3[1];
|
|
173
149
|
var _useState4 = useState(initialWidth),
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
150
|
+
scrollWidth = _useState4[0],
|
|
151
|
+
setScrollWidth = _useState4[1];
|
|
177
152
|
var _useState5 = useState(0),
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
153
|
+
titleBarHeight = _useState5[0],
|
|
154
|
+
setTitleBarHeight = _useState5[1];
|
|
181
155
|
var _useRowStar = useRowStar((rowStar == null ? void 0 : rowStar.starredRowKeys) || []),
|
|
182
|
-
|
|
183
|
-
|
|
156
|
+
getRowStarColumn = _useRowStar.getRowStarColumn;
|
|
184
157
|
|
|
158
|
+
// deprecated, verify if not used and remove
|
|
185
159
|
useEffect(function () {
|
|
186
160
|
listRef.current && onListRefChange && onListRefChange(listRef);
|
|
187
161
|
});
|
|
188
|
-
|
|
189
162
|
var _useRowKey = useRowKey(rowKey),
|
|
190
|
-
|
|
191
|
-
|
|
163
|
+
getRowKey = _useRowKey.getRowKey;
|
|
192
164
|
var allData = dataSourceFull || dataSource;
|
|
193
|
-
|
|
194
165
|
var propsForRowStar = _objectSpread({}, props, {
|
|
195
166
|
rowStar: _objectSpread({}, rowStar, {
|
|
196
167
|
onClick: function onClick(e) {
|
|
197
168
|
e.stopPropagation();
|
|
198
|
-
|
|
199
169
|
if (typeof (rowStar == null ? void 0 : rowStar.onClick) === 'function') {
|
|
200
170
|
rowStar.onClick(e);
|
|
201
171
|
}
|
|
@@ -204,25 +174,21 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
|
|
|
204
174
|
getRowKey: getRowKey,
|
|
205
175
|
locale: tableLocale
|
|
206
176
|
});
|
|
207
|
-
|
|
208
177
|
var rowStarColumn = getRowStarColumn(propsForRowStar);
|
|
209
178
|
var selectedRecords = useMemo(function () {
|
|
210
179
|
if (selection) {
|
|
211
180
|
var _ref = selection,
|
|
212
|
-
|
|
181
|
+
selectedRowKeys = _ref.selectedRowKeys;
|
|
213
182
|
var selectedRows = [];
|
|
214
183
|
allData.forEach(function (row) {
|
|
215
184
|
var key = getRowKey(row);
|
|
216
185
|
var rowChildren = row[childrenColumnName];
|
|
217
|
-
|
|
218
186
|
if (key && selectedRowKeys.indexOf(key) >= 0) {
|
|
219
187
|
selectedRows = [].concat(selectedRows, [row]);
|
|
220
188
|
}
|
|
221
|
-
|
|
222
189
|
if (rowChildren !== undefined && Array.isArray(rowChildren)) {
|
|
223
190
|
rowChildren.forEach(function (child) {
|
|
224
191
|
var childKey = getRowKey(child);
|
|
225
|
-
|
|
226
192
|
if (childKey && selectedRowKeys.indexOf(childKey) >= 0) {
|
|
227
193
|
selectedRows = [].concat(selectedRows, [child]);
|
|
228
194
|
}
|
|
@@ -231,25 +197,21 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
|
|
|
231
197
|
});
|
|
232
198
|
return selectedRows;
|
|
233
199
|
}
|
|
234
|
-
|
|
235
200
|
return [];
|
|
236
201
|
}, [allData, childrenColumnName, getRowKey, selection]);
|
|
237
202
|
var renderRowSelection = useCallback(function (key, record) {
|
|
238
203
|
var _ref2 = selection,
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
204
|
+
selectedRowKeys = _ref2.selectedRowKeys,
|
|
205
|
+
limit = _ref2.limit,
|
|
206
|
+
independentSelectionExpandedRows = _ref2.independentSelectionExpandedRows,
|
|
207
|
+
onChange = _ref2.onChange,
|
|
208
|
+
checkRowSelectionStatus = _ref2.checkRowSelectionStatus;
|
|
245
209
|
var handleChange = function handleChange(keys, records) {
|
|
246
210
|
if (isSticky && listScrollTopRef.current) {
|
|
247
211
|
setIsHeaderVisible(true);
|
|
248
212
|
}
|
|
249
|
-
|
|
250
213
|
onChange(keys, records);
|
|
251
214
|
};
|
|
252
|
-
|
|
253
215
|
return /*#__PURE__*/React.createElement(RowSelectionColumn, {
|
|
254
216
|
rowKey: rowKey,
|
|
255
217
|
record: record,
|
|
@@ -276,78 +238,68 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
|
|
|
276
238
|
var cumulativeRightOffset = 0;
|
|
277
239
|
var cumulativeLeftOffset = 0;
|
|
278
240
|
var firstFixedRightFound = false;
|
|
279
|
-
|
|
280
241
|
var _virtualColumns$reduc = virtualColumns.reduce(function (prev, column, index) {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
242
|
+
var left = cumulativeLeftOffset;
|
|
243
|
+
var right = cumulativeRightOffset;
|
|
244
|
+
var width = columnWidths[index];
|
|
245
|
+
if (column.fixed === 'right') {
|
|
246
|
+
cumulativeRightOffset += width;
|
|
247
|
+
var fixedFirst = !firstFixedRightFound;
|
|
248
|
+
if (!firstFixedRightFound) {
|
|
249
|
+
firstFixedRightFound = true;
|
|
250
|
+
}
|
|
251
|
+
return _objectSpread({}, prev, {
|
|
252
|
+
fixedRight: [].concat(prev.fixedRight, [_objectSpread({}, column, {
|
|
253
|
+
fixedFirst: fixedFirst,
|
|
254
|
+
right: right,
|
|
255
|
+
width: width
|
|
256
|
+
})])
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
if (column.fixed === 'left') {
|
|
260
|
+
cumulativeLeftOffset += width;
|
|
261
|
+
var prevFixedLeft = prev.fixedLeft;
|
|
262
|
+
var newFixedLeft = prevFixedLeft.length ? [].concat(prevFixedLeft, [_objectSpread({}, prevFixedLeft.pop(), {
|
|
263
|
+
fixedFirst: false
|
|
264
|
+
}), _objectSpread({}, column, {
|
|
265
|
+
fixedFirst: true,
|
|
266
|
+
left: left,
|
|
267
|
+
width: width
|
|
268
|
+
})]) : [].concat(prevFixedLeft, [_objectSpread({}, column, {
|
|
269
|
+
fixedFirst: true,
|
|
270
|
+
left: left,
|
|
271
|
+
width: width
|
|
272
|
+
})]);
|
|
273
|
+
return _objectSpread({}, prev, {
|
|
274
|
+
fixedLeft: newFixedLeft
|
|
275
|
+
});
|
|
291
276
|
}
|
|
292
|
-
|
|
293
277
|
return _objectSpread({}, prev, {
|
|
294
|
-
|
|
295
|
-
fixedFirst: fixedFirst,
|
|
296
|
-
right: right,
|
|
278
|
+
remaining: [].concat(prev.remaining, [_objectSpread({}, column, {
|
|
297
279
|
width: width
|
|
298
280
|
})])
|
|
299
281
|
});
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
fixedFirst: true,
|
|
309
|
-
left: left,
|
|
310
|
-
width: width
|
|
311
|
-
})]) : [].concat(prevFixedLeft, [_objectSpread({}, column, {
|
|
312
|
-
fixedFirst: true,
|
|
313
|
-
left: left,
|
|
314
|
-
width: width
|
|
315
|
-
})]);
|
|
316
|
-
return _objectSpread({}, prev, {
|
|
317
|
-
fixedLeft: newFixedLeft
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
return _objectSpread({}, prev, {
|
|
322
|
-
remaining: [].concat(prev.remaining, [_objectSpread({}, column, {
|
|
323
|
-
width: width
|
|
324
|
-
})])
|
|
325
|
-
});
|
|
326
|
-
}, {
|
|
327
|
-
fixedLeft: [],
|
|
328
|
-
fixedRight: [],
|
|
329
|
-
remaining: []
|
|
330
|
-
}),
|
|
331
|
-
fixedLeft = _virtualColumns$reduc.fixedLeft,
|
|
332
|
-
remaining = _virtualColumns$reduc.remaining,
|
|
333
|
-
fixedRight = _virtualColumns$reduc.fixedRight;
|
|
334
|
-
|
|
282
|
+
}, {
|
|
283
|
+
fixedLeft: [],
|
|
284
|
+
fixedRight: [],
|
|
285
|
+
remaining: []
|
|
286
|
+
}),
|
|
287
|
+
fixedLeft = _virtualColumns$reduc.fixedLeft,
|
|
288
|
+
remaining = _virtualColumns$reduc.remaining,
|
|
289
|
+
fixedRight = _virtualColumns$reduc.fixedRight;
|
|
335
290
|
return [].concat(fixedLeft, remaining, fixedRight);
|
|
336
291
|
}, [tableWidth, virtualColumns]);
|
|
337
292
|
var infiniteLoaderOffset = useMemo(function () {
|
|
338
293
|
var _infiniteScroll$prevP3;
|
|
339
|
-
|
|
340
294
|
if (isSticky && infiniteScroll != null && (_infiniteScroll$prevP3 = infiniteScroll.prevPage) != null && _infiniteScroll$prevP3.hasMore) {
|
|
341
295
|
return infiniteLoaderItemHeight * 2;
|
|
342
296
|
}
|
|
343
|
-
|
|
344
297
|
return infiniteLoaderItemHeight;
|
|
345
298
|
}, [isSticky, infiniteScroll == null || (_infiniteScroll$prevP4 = infiniteScroll.prevPage) == null ? void 0 : _infiniteScroll$prevP4.hasMore]);
|
|
346
299
|
var listInnerElementType = useMemo(function () {
|
|
347
300
|
return forwardRef(function (_ref3, innerElementRef) {
|
|
348
301
|
var style = _ref3.style,
|
|
349
|
-
|
|
350
|
-
|
|
302
|
+
rest = _objectWithoutPropertiesLoose(_ref3, _excluded);
|
|
351
303
|
return /*#__PURE__*/React.createElement(S.InnerListElement, _extends({
|
|
352
304
|
ref: innerElementRef,
|
|
353
305
|
style: _objectSpread({}, style, {
|
|
@@ -360,14 +312,11 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
|
|
|
360
312
|
if (!listRef.current) {
|
|
361
313
|
return;
|
|
362
314
|
}
|
|
363
|
-
|
|
364
315
|
listRef.current.scrollTo(top);
|
|
365
316
|
}, []);
|
|
366
|
-
|
|
367
317
|
var scrollToTop = function scrollToTop() {
|
|
368
318
|
scrollTo(0);
|
|
369
319
|
};
|
|
370
|
-
|
|
371
320
|
var outerElement = useMemo(function () {
|
|
372
321
|
return OuterListElement(containerRef, isSticky);
|
|
373
322
|
}, [isSticky]);
|
|
@@ -391,10 +340,8 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
|
|
|
391
340
|
get: function get() {
|
|
392
341
|
if (outerListRef.current) {
|
|
393
342
|
var _outerListRef$current;
|
|
394
|
-
|
|
395
343
|
return (_outerListRef$current = outerListRef.current) == null ? void 0 : _outerListRef$current.scrollLeft;
|
|
396
344
|
}
|
|
397
|
-
|
|
398
345
|
return null;
|
|
399
346
|
},
|
|
400
347
|
set: function set(scrollLeft) {
|
|
@@ -418,67 +365,53 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
|
|
|
418
365
|
}, [connectObject, isSticky]);
|
|
419
366
|
var renderBody = useCallback(function (rawData, meta, defaultTableProps) {
|
|
420
367
|
var _expandable$expandedR;
|
|
421
|
-
|
|
422
368
|
var onScroll = meta.onScroll,
|
|
423
|
-
|
|
424
|
-
customBodyOnScrollRef.current = onScroll;
|
|
369
|
+
ref = meta.ref;
|
|
370
|
+
customBodyOnScrollRef.current = onScroll;
|
|
371
|
+
// sticky header feature does NOT work without the ref assigned to a html node in the document.
|
|
425
372
|
// without sticky header the ref needs to point to the connect proxy in order for the header and body components to scroll in sync
|
|
426
373
|
// this gets resolved in antd 5.9.0, when antd supports virtualisation out of the box (but not infinite loader)
|
|
427
|
-
|
|
428
374
|
if (!isSticky) {
|
|
429
375
|
// @ts-ignore
|
|
430
376
|
ref.current = connectObject;
|
|
431
377
|
}
|
|
432
|
-
|
|
433
378
|
var renderVirtualList = function renderVirtualList(data) {
|
|
434
379
|
var _infiniteScroll$nextP, _infiniteScroll$prevP5;
|
|
435
|
-
|
|
436
380
|
var listHeight = data.length * cellHeight - scroll.y + infiniteLoaderOffset;
|
|
437
381
|
var listMaxScroll = stickyScrollThreshold && infiniteScroll != null && infiniteScroll.maxScroll ? infiniteScroll.maxScroll - stickyScrollThreshold : listHeight;
|
|
438
|
-
|
|
439
382
|
var handleListScroll = function handleListScroll(_ref4) {
|
|
440
383
|
var scrollOffset = _ref4.scrollOffset,
|
|
441
|
-
|
|
442
|
-
|
|
384
|
+
scrollDirection = _ref4.scrollDirection;
|
|
443
385
|
if (!infiniteScroll || loading || listMaxScroll <= 0) {
|
|
444
386
|
return;
|
|
445
387
|
}
|
|
446
|
-
|
|
447
388
|
var onScrollTopReach = infiniteScroll.onScrollTopReach,
|
|
448
|
-
|
|
449
|
-
|
|
389
|
+
isLoading = infiniteScroll.isLoading,
|
|
390
|
+
onScrollEndReach = infiniteScroll.onScrollEndReach;
|
|
450
391
|
var roundedOffset = Math.ceil(scrollOffset);
|
|
451
392
|
listScrollTopRef.current = roundedOffset;
|
|
452
|
-
|
|
453
393
|
if (isSticky && scrollDirection === 'forward' && containerRef.current) {
|
|
454
394
|
setIsHeaderVisible(false);
|
|
455
395
|
}
|
|
456
|
-
|
|
457
396
|
if (isSticky && scrollDirection === 'backward' && containerRef.current) {
|
|
458
397
|
setIsHeaderVisible(roundedOffset > 0);
|
|
459
398
|
}
|
|
460
|
-
|
|
461
399
|
if (isLoading) {
|
|
462
400
|
return;
|
|
463
401
|
}
|
|
464
|
-
|
|
465
402
|
if (scrollDirection === 'forward' && roundedOffset >= listMaxScroll - LOAD_DATA_OFFSET && typeof onScrollEndReach === 'function') {
|
|
466
403
|
onScrollEndReach();
|
|
467
404
|
} else if (scrollDirection === 'backward' && (offsetScroll && roundedOffset <= offsetScroll + LOAD_DATA_OFFSET || roundedOffset < LOAD_DATA_OFFSET) && typeof onScrollTopReach === 'function') {
|
|
468
405
|
onScrollTopReach();
|
|
469
406
|
}
|
|
470
407
|
};
|
|
471
|
-
|
|
472
408
|
var itemData = createItemData(data, defaultTableProps);
|
|
473
409
|
var scrollableHeight = isSticky ? scroll.y - HEADER_ROW_HEIGHT : scroll.y;
|
|
474
|
-
|
|
475
410
|
if (infiniteScroll != null && (_infiniteScroll$nextP = infiniteScroll.nextPage) != null && _infiniteScroll$nextP.hasMore && (_infiniteScroll$prevP5 = infiniteScroll.prevPage) != null && _infiniteScroll$prevP5.hasMore) {
|
|
476
411
|
scrollableHeight += cellHeight;
|
|
477
412
|
}
|
|
478
|
-
|
|
479
413
|
var handleBodyScroll = function handleBodyScroll(event) {
|
|
480
414
|
var scrollLeft = event.currentTarget.scrollLeft;
|
|
481
|
-
|
|
482
415
|
if (isSticky) {
|
|
483
416
|
var info = {
|
|
484
417
|
scrollLeft: scrollLeft,
|
|
@@ -486,20 +419,19 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
|
|
|
486
419
|
};
|
|
487
420
|
onScroll(info);
|
|
488
421
|
}
|
|
489
|
-
|
|
490
422
|
if (horizontalScrollRef.current && horizontalScrollRef.current.scrollLeft !== scrollLeft) {
|
|
491
423
|
horizontalScrollRef.current.scrollTo({
|
|
492
424
|
left: scrollLeft
|
|
493
425
|
});
|
|
494
426
|
}
|
|
495
427
|
};
|
|
496
|
-
|
|
497
428
|
return /*#__PURE__*/React.createElement(S.VirtualListWrapper, {
|
|
498
429
|
listWidth: tableWidth,
|
|
499
430
|
"data-testid": "virtual-list-wrapper",
|
|
500
431
|
isSticky: isSticky,
|
|
501
432
|
listHeight: listHeight + HEADER_ROW_HEIGHT,
|
|
502
|
-
onScroll: handleBodyScroll
|
|
433
|
+
onScroll: handleBodyScroll
|
|
434
|
+
// @ts-ignore
|
|
503
435
|
,
|
|
504
436
|
ref: isSticky ? ref : undefined
|
|
505
437
|
}, /*#__PURE__*/React.createElement(List, {
|
|
@@ -515,8 +447,8 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
|
|
|
515
447
|
width: scrollWidth,
|
|
516
448
|
itemData: itemData,
|
|
517
449
|
itemKey: function itemKey(index) {
|
|
518
|
-
var key = getRowKey(data[index]);
|
|
519
|
-
|
|
450
|
+
var key = getRowKey(data[index]);
|
|
451
|
+
// @ts-ignore
|
|
520
452
|
return String(key instanceof String ? key.toLowerCase() : key);
|
|
521
453
|
},
|
|
522
454
|
outerElementType: outerElement,
|
|
@@ -525,27 +457,21 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
|
|
|
525
457
|
innerElementType: infiniteScroll && listInnerElementType
|
|
526
458
|
}, VirtualTableRow));
|
|
527
459
|
};
|
|
528
|
-
|
|
529
460
|
if (expandable != null && (_expandable$expandedR = expandable.expandedRowKeys) != null && _expandable$expandedR.length) {
|
|
530
461
|
var expandedRows = rawData.reduce(function (result, currentRow) {
|
|
531
462
|
var _expandable$expandedR2;
|
|
532
|
-
|
|
533
463
|
var key = getRowKey(currentRow);
|
|
534
464
|
var rowChildren = currentRow[childrenColumnName];
|
|
535
|
-
|
|
536
465
|
if (key !== undefined && expandable != null && (_expandable$expandedR2 = expandable.expandedRowKeys) != null && _expandable$expandedR2.includes(key) && Array.isArray(rowChildren) && rowChildren.length) {
|
|
537
466
|
return [].concat(result, [currentRow], rowChildren.map(function (child, index) {
|
|
538
467
|
var _objectSpread2;
|
|
539
|
-
|
|
540
468
|
return _objectSpread({}, child, (_objectSpread2 = {}, _objectSpread2[EXPANDED_ROW_PROPERTY] = true, _objectSpread2.index = index, _objectSpread2));
|
|
541
469
|
}));
|
|
542
470
|
}
|
|
543
|
-
|
|
544
471
|
return [].concat(result, [currentRow]);
|
|
545
472
|
}, []);
|
|
546
473
|
return renderVirtualList(expandedRows);
|
|
547
474
|
}
|
|
548
|
-
|
|
549
475
|
return renderVirtualList(rawData);
|
|
550
476
|
}, [connectObject, expandable == null ? void 0 : expandable.expandedRowKeys, cellHeight, scroll.y, isSticky, stickyScrollThreshold, infiniteScroll, createItemData, tableWidth, scrollWidth, onItemsRendered, outerElement, listInnerElementType, loading, offsetScroll, getRowKey, infiniteLoaderOffset, childrenColumnName]);
|
|
551
477
|
var columnsSliceStartIndex = Number(!!selection) + Number(!!rowStar);
|
|
@@ -572,14 +498,12 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
|
|
|
572
498
|
titleElement && setTitleBarHeight(titleElement.clientHeight);
|
|
573
499
|
}
|
|
574
500
|
}, [tableWidth, mergedColumns.length, dataSource.length, loading]);
|
|
575
|
-
|
|
576
501
|
var _useElementInView = useElementInView({
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
502
|
+
rootMargin: "0px 0px 12px 0px",
|
|
503
|
+
threshold: 0
|
|
504
|
+
}, containerRef),
|
|
505
|
+
isStuck = _useElementInView.isIntersecting,
|
|
506
|
+
elementRef = _useElementInView.elementRef;
|
|
583
507
|
return /*#__PURE__*/React.createElement(S.VirtualTableWrapper, {
|
|
584
508
|
isSticky: isSticky,
|
|
585
509
|
titleBarTop: offsetStickyHeader || 0,
|
|
@@ -618,5 +542,4 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
|
|
|
618
542
|
scrollWidth: scrollWidth
|
|
619
543
|
})) : null);
|
|
620
544
|
};
|
|
621
|
-
|
|
622
545
|
export default forwardRef(VirtualTable);
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import styled, { css } from 'styled-components';
|
|
2
2
|
import Scrollbar from '@synerise/ds-scrollbar';
|
|
3
|
-
|
|
4
3
|
var numberToPixels = function numberToPixels(num) {
|
|
5
4
|
return num + "px";
|
|
6
5
|
};
|
|
7
|
-
|
|
8
6
|
var getColumnWidth = function getColumnWidth(props) {
|
|
9
7
|
return props.width ? numberToPixels(props.width) : 'initial';
|
|
10
8
|
};
|
|
11
|
-
|
|
12
9
|
export var RowWrapper = styled.div.withConfig({
|
|
13
10
|
displayName: "VirtualTablestyles__RowWrapper",
|
|
14
11
|
componentId: "aehkhc-0"
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
-
|
|
3
2
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
|
|
5
3
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
-
|
|
7
4
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
8
|
-
|
|
9
5
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
10
|
-
|
|
11
6
|
import React, { memo, useCallback, useMemo } from 'react';
|
|
12
7
|
import classNames from 'classnames';
|
|
13
8
|
import { areEqual } from 'react-window';
|
|
@@ -16,36 +11,31 @@ import { EXPANDED_ROW_PROPERTY } from './constants';
|
|
|
16
11
|
import * as S from './VirtualTable.styles';
|
|
17
12
|
import { getValueFromPath, calculatePixels } from '../utils';
|
|
18
13
|
export var INFINITE_LOADED_ITEM_HEIGHT = 64;
|
|
19
|
-
|
|
20
14
|
var isColumnSortingActive = function isColumnSortingActive(columns, column) {
|
|
21
15
|
return !!columns.find(function (c) {
|
|
22
16
|
return c.key === column.key && !!c.sortOrder;
|
|
23
17
|
});
|
|
24
18
|
};
|
|
25
|
-
|
|
26
19
|
var calculateToPixelsIfDefined = function calculateToPixelsIfDefined(value) {
|
|
27
20
|
return value ? calculatePixels(value) : value;
|
|
28
21
|
};
|
|
29
|
-
|
|
30
22
|
function VirtualTableRow(_ref) {
|
|
31
23
|
var _infiniteScroll$prevP3;
|
|
32
|
-
|
|
33
24
|
var index = _ref.index,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
25
|
+
style = _ref.style,
|
|
26
|
+
_ref$data = _ref.data,
|
|
27
|
+
mergedColumns = _ref$data.mergedColumns,
|
|
28
|
+
onRowClick = _ref$data.onRowClick,
|
|
29
|
+
selection = _ref$data.selection,
|
|
30
|
+
rowStar = _ref$data.rowStar,
|
|
31
|
+
dataSource = _ref$data.dataSource,
|
|
32
|
+
cellHeight = _ref$data.cellHeight,
|
|
33
|
+
infiniteScroll = _ref$data.infiniteScroll,
|
|
34
|
+
defaultTableProps = _ref$data.defaultTableProps;
|
|
44
35
|
var renderColumn = useCallback(function (column, rowData, columnIndex) {
|
|
45
36
|
if (rowData[EXPANDED_ROW_PROPERTY] && column.childRender) {
|
|
46
37
|
return column.childRender(getValueFromPath(rowData, column.dataIndex), rowData, columnIndex);
|
|
47
38
|
}
|
|
48
|
-
|
|
49
39
|
return column.render ? column.render(getValueFromPath(rowData, column.dataIndex), rowData, columnIndex) : getValueFromPath(rowData, column.dataIndex);
|
|
50
40
|
}, []);
|
|
51
41
|
var rowData = useMemo(function () {
|
|
@@ -55,24 +45,19 @@ function VirtualTableRow(_ref) {
|
|
|
55
45
|
var isVisible = false;
|
|
56
46
|
var infiniteLoaderItemProps;
|
|
57
47
|
var top = style.top;
|
|
58
|
-
|
|
59
48
|
if (position === 'TOP') {
|
|
60
49
|
var _infiniteScroll$prevP;
|
|
61
|
-
|
|
62
50
|
isVisible = Boolean(infiniteScroll && ((_infiniteScroll$prevP = infiniteScroll.prevPage) == null ? void 0 : _infiniteScroll$prevP.hasMore) && index === 0);
|
|
63
51
|
infiniteLoaderItemProps = infiniteScroll == null ? void 0 : infiniteScroll.prevPage;
|
|
64
52
|
top = "0px";
|
|
65
53
|
}
|
|
66
|
-
|
|
67
54
|
if (position === 'BOTTOM') {
|
|
68
55
|
var _infiniteScroll$prevP2;
|
|
69
|
-
|
|
70
56
|
isVisible = Boolean(index === dataSource.length - 1);
|
|
71
57
|
infiniteLoaderItemProps = infiniteScroll == null ? void 0 : infiniteScroll.nextPage;
|
|
72
58
|
var prevDataInfiniteLoaderHeight = infiniteScroll != null && (_infiniteScroll$prevP2 = infiniteScroll.prevPage) != null && _infiniteScroll$prevP2.hasMore ? INFINITE_LOADED_ITEM_HEIGHT : 0;
|
|
73
59
|
top = Number(style.top) + cellHeight + prevDataInfiniteLoaderHeight + "px";
|
|
74
60
|
}
|
|
75
|
-
|
|
76
61
|
return infiniteLoaderItemProps && isVisible && /*#__PURE__*/React.createElement(S.RowWrapper, {
|
|
77
62
|
style: _objectSpread({}, style, {
|
|
78
63
|
top: top,
|
|
@@ -121,5 +106,4 @@ function VirtualTableRow(_ref) {
|
|
|
121
106
|
}, renderColumn(column, rowData, columnIndex));
|
|
122
107
|
})), infiniteLoader('BOTTOM'));
|
|
123
108
|
}
|
|
124
|
-
|
|
125
109
|
export default memo(VirtualTableRow, areEqual);
|