@gridsuite/commons-ui 0.30.1 → 0.31.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.
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports["default"] = exports.ColumnHeader = void 0;
|
|
5
5
|
|
|
6
|
-
var _react =
|
|
6
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
7
7
|
|
|
8
8
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
9
9
|
|
|
@@ -17,6 +17,10 @@ var _ArrowDownward = _interopRequireDefault(require("@mui/icons-material/ArrowDo
|
|
|
17
17
|
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
19
|
|
|
20
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
+
|
|
22
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
+
|
|
20
24
|
/**
|
|
21
25
|
* Copyright (c) 2022, RTE (http://www.rte-france.com)
|
|
22
26
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
@@ -110,14 +114,17 @@ var ColumnHeader = _react["default"].forwardRef(function (props, ref) {
|
|
|
110
114
|
setHovered(evt.type === 'mouseenter');
|
|
111
115
|
}, []);
|
|
112
116
|
|
|
117
|
+
var topmostDiv = (0, _react.useRef)();
|
|
118
|
+
|
|
113
119
|
var handleFilterClick = _react["default"].useMemo(function () {
|
|
114
120
|
if (!onFilterClick) return undefined;
|
|
115
121
|
return function (evt) {
|
|
116
|
-
onFilterClick(evt,
|
|
122
|
+
onFilterClick(evt, topmostDiv.current);
|
|
117
123
|
};
|
|
118
124
|
}, [onFilterClick]);
|
|
119
125
|
|
|
120
126
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
127
|
+
ref: topmostDiv,
|
|
121
128
|
onMouseEnter: onHover,
|
|
122
129
|
onMouseLeave: onHover,
|
|
123
130
|
className: (0, _clsx["default"])(classes.divFlex, numeric && classes.divNum, className),
|
|
@@ -182,7 +182,7 @@ var KeyedColumnsRowIndexer = /*#__PURE__*/function () {
|
|
|
182
182
|
_this._bumpVersion();
|
|
183
183
|
});
|
|
184
184
|
|
|
185
|
-
_defineProperty(this, "preFilterRowMapping", function (columns, rows) {
|
|
185
|
+
_defineProperty(this, "preFilterRowMapping", function (columns, rows, rowFilter) {
|
|
186
186
|
if (!(rows === null || rows === void 0 ? void 0 : rows.length) || !(columns === null || columns === void 0 ? void 0 : columns.length)) return null;
|
|
187
187
|
var ri = [];
|
|
188
188
|
var cs = {};
|
|
@@ -231,6 +231,10 @@ var KeyedColumnsRowIndexer = /*#__PURE__*/function () {
|
|
|
231
231
|
acceptsRow &= acceptsCell;
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
+
if (acceptsRow && rowFilter) {
|
|
235
|
+
acceptsRow = rowFilter(row);
|
|
236
|
+
}
|
|
237
|
+
|
|
234
238
|
if (acceptsRow && _this.byRowFilter) {
|
|
235
239
|
acceptsRow = _this.byRowFilter(row);
|
|
236
240
|
}
|
|
@@ -491,7 +495,6 @@ var KeyedColumnsRowIndexer = /*#__PURE__*/function () {
|
|
|
491
495
|
_this._bumpVersion();
|
|
492
496
|
});
|
|
493
497
|
|
|
494
|
-
console.debug('KeyedColumnsRowIndexer');
|
|
495
498
|
this._versionSetter = versionSetter;
|
|
496
499
|
this.version = 0;
|
|
497
500
|
this.filterVersion = 0;
|
|
@@ -112,19 +112,26 @@ var AmongChooser = function AmongChooser(props) {
|
|
|
112
112
|
var options = props.options,
|
|
113
113
|
value = props.value,
|
|
114
114
|
setValue = props.setValue,
|
|
115
|
-
id = props.id
|
|
116
|
-
|
|
115
|
+
id = props.id,
|
|
116
|
+
onDropDownVisibility = props.onDropDownVisibility;
|
|
117
|
+
return /*#__PURE__*/_react["default"].createElement("span", null, /*#__PURE__*/_react["default"].createElement(_material.Autocomplete, {
|
|
117
118
|
id: id,
|
|
118
119
|
value: value !== null && value !== void 0 ? value : [],
|
|
119
120
|
multiple: true,
|
|
120
121
|
onChange: function onChange(evt, newVal) {
|
|
121
122
|
setValue(newVal);
|
|
122
123
|
},
|
|
123
|
-
|
|
124
|
-
|
|
124
|
+
onClose: function onClose() {
|
|
125
|
+
return onDropDownVisibility(false);
|
|
126
|
+
},
|
|
127
|
+
onOpen: function onOpen() {
|
|
128
|
+
return onDropDownVisibility(true);
|
|
129
|
+
},
|
|
130
|
+
options: options,
|
|
125
131
|
renderInput: function renderInput(props) {
|
|
126
|
-
return /*#__PURE__*/_react["default"].createElement(_material.TextField
|
|
127
|
-
|
|
132
|
+
return /*#__PURE__*/_react["default"].createElement(_material.TextField, _extends({
|
|
133
|
+
autoFocus: true
|
|
134
|
+
}, props));
|
|
128
135
|
},
|
|
129
136
|
renderTags: function renderTags(val, getTagsProps) {
|
|
130
137
|
return val.map(function (code, index) {
|
|
@@ -140,6 +147,22 @@ var AmongChooser = function AmongChooser(props) {
|
|
|
140
147
|
}));
|
|
141
148
|
};
|
|
142
149
|
|
|
150
|
+
function makeIndexRecord(viewIndexToModel, rows) {
|
|
151
|
+
return {
|
|
152
|
+
viewIndexToModel: viewIndexToModel,
|
|
153
|
+
rowGetter: !viewIndexToModel ? function (viewIndex) {
|
|
154
|
+
return rows[viewIndex];
|
|
155
|
+
} : function (viewIndex) {
|
|
156
|
+
if (viewIndex >= viewIndexToModel.length || viewIndex < 0) {
|
|
157
|
+
return {};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
var modelIndex = viewIndexToModel[viewIndex];
|
|
161
|
+
return rows[modelIndex];
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
143
166
|
var initIndexer = function initIndexer(props, oldProps, versionSetter) {
|
|
144
167
|
if (!props.sortable) {
|
|
145
168
|
return null;
|
|
@@ -147,29 +170,75 @@ var initIndexer = function initIndexer(props, oldProps, versionSetter) {
|
|
|
147
170
|
|
|
148
171
|
if (props.indexer) {
|
|
149
172
|
return props.indexer;
|
|
150
|
-
} else if (!props.sort) {
|
|
151
|
-
return new _KeyedColumnsRowIndexer.KeyedColumnsRowIndexer(true, true, null, versionSetter);
|
|
152
|
-
} else if (typeof props.sort === 'function') {
|
|
153
|
-
return new _KeyedColumnsRowIndexer.KeyedColumnsRowIndexer(true, true, function (cbfgs, done_cb) {
|
|
154
|
-
console.debug('dummy func, now :-/');
|
|
155
|
-
done_cb(true);
|
|
156
|
-
}, versionSetter);
|
|
157
|
-
} else if (typeof props.sort === 'object') {
|
|
158
|
-
return props.sort;
|
|
159
|
-
} else {
|
|
160
|
-
console.warn('unknown type of sort', props.sort);
|
|
161
173
|
}
|
|
162
174
|
|
|
163
175
|
return new _KeyedColumnsRowIndexer.KeyedColumnsRowIndexer(true, true, null, versionSetter);
|
|
164
176
|
};
|
|
165
177
|
|
|
178
|
+
var preFilterData = (0, _memoizeOne["default"])(function (columns, rows, filterFromProps, indexer, filterVersion // filterVersion is unused directly, used only as a workaround just to reset the memoization
|
|
179
|
+
) {
|
|
180
|
+
return indexer.preFilterRowMapping(columns, rows, filterFromProps);
|
|
181
|
+
});
|
|
182
|
+
var reorderIndex = (0, _memoizeOne["default"])(function (indexer, indirectionVersion, rows, columns, filterFromProps, sortFromProps) {
|
|
183
|
+
if (!rows) return {
|
|
184
|
+
viewIndexToModel: [],
|
|
185
|
+
rowGetter: function rowGetter(viewIndex) {
|
|
186
|
+
return viewIndex;
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
var highestCodedColumn = !indexer ? 0 : indexer.highestCodedColumn(columns);
|
|
190
|
+
|
|
191
|
+
if (sortFromProps && highestCodedColumn) {
|
|
192
|
+
var colIdx = Math.abs(highestCodedColumn) - 1;
|
|
193
|
+
var reorderedIndex = sortFromProps(columns[colIdx].dataKey, highestCodedColumn > 0, !!columns[colIdx].numeric);
|
|
194
|
+
return makeIndexRecord(reorderedIndex, rows);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (sortFromProps) {
|
|
198
|
+
try {
|
|
199
|
+
var viewIndexToModel = sortFromProps(null, false, false);
|
|
200
|
+
return makeIndexRecord(viewIndexToModel, rows);
|
|
201
|
+
} catch (e) {
|
|
202
|
+
//some external sort functions may expect to only be called
|
|
203
|
+
//when the user has select a column. Catch their errors and ignore
|
|
204
|
+
console.warn('error in external sort. consider adding support for datakey=null in your external sort function');
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (indexer) {
|
|
209
|
+
var prefiltered = preFilterData(columns, rows, filterFromProps, indexer, indirectionVersion);
|
|
210
|
+
|
|
211
|
+
var _reorderedIndex = indexer.makeGroupAndSortIndirector(prefiltered, columns);
|
|
212
|
+
|
|
213
|
+
return makeIndexRecord(_reorderedIndex, rows);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (filterFromProps) {
|
|
217
|
+
var _viewIndexToModel = rows.map(function (r, i) {
|
|
218
|
+
return [r, i];
|
|
219
|
+
}).filter(function (_ref) {
|
|
220
|
+
var r = _ref[0],
|
|
221
|
+
idx = _ref[1];
|
|
222
|
+
return filterFromProps(r);
|
|
223
|
+
}).map(function (_ref2) {
|
|
224
|
+
var r = _ref2[0],
|
|
225
|
+
j = _ref2[1];
|
|
226
|
+
return j;
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
return makeIndexRecord(_viewIndexToModel, rows);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return makeIndexRecord(null, rows);
|
|
233
|
+
});
|
|
234
|
+
|
|
166
235
|
var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
|
|
167
236
|
_inheritsLoose(MuiVirtualizedTable, _React$PureComponent);
|
|
168
237
|
|
|
169
|
-
function MuiVirtualizedTable(
|
|
238
|
+
function MuiVirtualizedTable(props, context) {
|
|
170
239
|
var _this;
|
|
171
240
|
|
|
172
|
-
_this = _React$PureComponent.call(this,
|
|
241
|
+
_this = _React$PureComponent.call(this, props, context) || this;
|
|
173
242
|
|
|
174
243
|
_defineProperty(_assertThisInitialized(_this), "setVersion", function (v) {
|
|
175
244
|
_this.setState({
|
|
@@ -177,65 +246,6 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
177
246
|
});
|
|
178
247
|
});
|
|
179
248
|
|
|
180
|
-
_defineProperty(_assertThisInitialized(_this), "preFilterData", (0, _memoizeOne["default"])(function (columns, rows) {
|
|
181
|
-
return _this.state.indexer.preFilterRowMapping(columns, rows);
|
|
182
|
-
}));
|
|
183
|
-
|
|
184
|
-
_defineProperty(_assertThisInitialized(_this), "reorderIndex", (0, _memoizeOne["default"])(function (indirectorVersion, rows, columns) {
|
|
185
|
-
var indexer = _this.state.indexer;
|
|
186
|
-
if (!rows) return {
|
|
187
|
-
viewIndexToModel: [],
|
|
188
|
-
rowGetter: function rowGetter(viewIndex) {
|
|
189
|
-
return viewIndex;
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
var props = _this.props;
|
|
193
|
-
|
|
194
|
-
if (indexer && props.sort) {
|
|
195
|
-
var highestCodedColumn = indexer.highestCodedColumn(props.columns);
|
|
196
|
-
|
|
197
|
-
if (highestCodedColumn !== 0) {
|
|
198
|
-
var colIdx = Math.abs(highestCodedColumn) - 1;
|
|
199
|
-
var ret = props.sort(props.columns[colIdx].dataKey, highestCodedColumn > 0, !!props.columns[colIdx].numeric);
|
|
200
|
-
return {
|
|
201
|
-
viewIndexToModel: ret,
|
|
202
|
-
rowGetter: function rowGetter(viewIndex) {
|
|
203
|
-
if (viewIndex >= ret.length || viewIndex < 0) {
|
|
204
|
-
return {};
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
var modelIndex = ret[viewIndex];
|
|
208
|
-
return rows[modelIndex];
|
|
209
|
-
}
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
} else if (indexer) {
|
|
213
|
-
var prefiltered = _this.preFilterData(columns, rows);
|
|
214
|
-
|
|
215
|
-
var reorderedIndex = indexer.makeGroupAndSortIndirector(prefiltered, columns);
|
|
216
|
-
return {
|
|
217
|
-
viewIndexToModel: reorderedIndex,
|
|
218
|
-
rowGetter: function rowGetter(viewIndex) {
|
|
219
|
-
if (reorderedIndex === null) return rows[viewIndex];
|
|
220
|
-
|
|
221
|
-
if (viewIndex >= reorderedIndex.length || viewIndex < 0) {
|
|
222
|
-
return {};
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
var modelIndex = reorderedIndex[viewIndex];
|
|
226
|
-
return rows[modelIndex];
|
|
227
|
-
}
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
return {
|
|
232
|
-
viewIndexToModel: null,
|
|
233
|
-
rowGetter: function rowGetter(viewIndex) {
|
|
234
|
-
return rows[viewIndex];
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
}));
|
|
238
|
-
|
|
239
249
|
_defineProperty(_assertThisInitialized(_this), "computeDataWidth", function (text) {
|
|
240
250
|
return getTextWidth(text || '') + 2 * DEFAULT_CELL_PADDING;
|
|
241
251
|
});
|
|
@@ -268,10 +278,6 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
268
278
|
}));
|
|
269
279
|
|
|
270
280
|
_defineProperty(_assertThisInitialized(_this), "openPopover", function (popoverTarget, colKey) {
|
|
271
|
-
if (_this.state.indexer.delegatorCallback) {
|
|
272
|
-
return; // retro compatibility stops here ;-)
|
|
273
|
-
}
|
|
274
|
-
|
|
275
281
|
var col = _this.props.columns.find(function (c) {
|
|
276
282
|
return c.dataKey === colKey;
|
|
277
283
|
});
|
|
@@ -280,24 +286,34 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
280
286
|
return;
|
|
281
287
|
}
|
|
282
288
|
|
|
289
|
+
_this.dropDownVisible = false;
|
|
290
|
+
|
|
283
291
|
_this.setState({
|
|
284
292
|
popoverAnchorEl: popoverTarget,
|
|
285
293
|
popoverColKey: colKey
|
|
286
294
|
});
|
|
287
295
|
});
|
|
288
296
|
|
|
297
|
+
_defineProperty(_assertThisInitialized(_this), "handleKeyDownOnPopover", function (evt) {
|
|
298
|
+
if (evt.key === 'Enter' && !_this.dropDownVisible) {
|
|
299
|
+
_this.closePopover(evt, 'enterKeyDown');
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
|
|
289
303
|
_defineProperty(_assertThisInitialized(_this), "closePopover", function (evt, reason) {
|
|
290
304
|
var bumpsVersion = false;
|
|
291
305
|
|
|
292
|
-
if (reason === 'backdropClick') {
|
|
306
|
+
if (reason === 'backdropClick' || reason === 'enterKeyDown') {
|
|
293
307
|
bumpsVersion = _this._commitFilterChange();
|
|
294
308
|
}
|
|
295
309
|
|
|
296
|
-
_this.setState({
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
310
|
+
_this.setState(function (state, props) {
|
|
311
|
+
return {
|
|
312
|
+
popoverAnchorEl: null,
|
|
313
|
+
popoverColKey: null,
|
|
314
|
+
deferredFilterChange: null,
|
|
315
|
+
indirectionVersion: state.indirectionVersion + (bumpsVersion ? 1 : 0)
|
|
316
|
+
};
|
|
301
317
|
});
|
|
302
318
|
});
|
|
303
319
|
|
|
@@ -309,9 +325,7 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
309
325
|
var outerParams = _this.state.indexer.getColFilterOuterParams(colKey);
|
|
310
326
|
|
|
311
327
|
var userParams = !_this.props.defersFilterChanges || !_this.state.deferredFilterChange ? _this.state.indexer.getColFilterUserParams(colKey) : _this.state.deferredFilterChange.newVal;
|
|
312
|
-
|
|
313
|
-
var prefiltered = _this.preFilterData(_this.props.columns, _this.props.rows);
|
|
314
|
-
|
|
328
|
+
var prefiltered = preFilterData(_this.props.columns, _this.props.rows, _this.props.filter, _this.state.indexer, _this.state.indirectionVersion);
|
|
315
329
|
var options = [];
|
|
316
330
|
|
|
317
331
|
if (outerParams) {
|
|
@@ -336,6 +350,8 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
336
350
|
}
|
|
337
351
|
}
|
|
338
352
|
|
|
353
|
+
options.sort();
|
|
354
|
+
|
|
339
355
|
var col = _this.props.columns.find(function (c) {
|
|
340
356
|
return c.dataKey === colKey;
|
|
341
357
|
});
|
|
@@ -344,9 +360,13 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
344
360
|
options: options,
|
|
345
361
|
value: userParams,
|
|
346
362
|
id: 'fielt' + colKey,
|
|
347
|
-
label: (_col$label = col === null || col === void 0 ? void 0 : col.label) !== null && _col$label !== void 0 ? _col$label : "\u2208"
|
|
363
|
+
label: (_col$label = col === null || col === void 0 ? void 0 : col.label) !== null && _col$label !== void 0 ? _col$label : "\u2208" // "contained in" math symbol
|
|
364
|
+
,
|
|
348
365
|
setValue: function setValue(newVal) {
|
|
349
366
|
_this.onFilterParamsChange(newVal, colKey);
|
|
367
|
+
},
|
|
368
|
+
onDropDownVisibility: function onDropDownVisibility(visible) {
|
|
369
|
+
return _this.dropDownVisible = visible;
|
|
350
370
|
}
|
|
351
371
|
});
|
|
352
372
|
});
|
|
@@ -396,26 +416,28 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
396
416
|
}
|
|
397
417
|
});
|
|
398
418
|
|
|
399
|
-
_defineProperty(_assertThisInitialized(_this), "filterClickHandler", function (evt,
|
|
419
|
+
_defineProperty(_assertThisInitialized(_this), "filterClickHandler", function (evt, target, columnIndex) {
|
|
420
|
+
var _target$parentNode;
|
|
421
|
+
|
|
422
|
+
// ColumnHeader to (header) TableCell
|
|
423
|
+
var retargeted = (_target$parentNode = target.parentNode) !== null && _target$parentNode !== void 0 ? _target$parentNode : target;
|
|
400
424
|
var colKey = _this.props.columns[columnIndex].dataKey;
|
|
401
425
|
|
|
402
426
|
_this.openPopover(retargeted, colKey);
|
|
403
427
|
});
|
|
404
428
|
|
|
405
|
-
_defineProperty(_assertThisInitialized(_this), "sortableHeader", function (
|
|
429
|
+
_defineProperty(_assertThisInitialized(_this), "sortableHeader", function (_ref3) {
|
|
406
430
|
var _prefiltered$colsStat2;
|
|
407
431
|
|
|
408
|
-
var label =
|
|
409
|
-
columnIndex =
|
|
432
|
+
var label = _ref3.label,
|
|
433
|
+
columnIndex = _ref3.columnIndex;
|
|
410
434
|
var columns = _this.props.columns;
|
|
411
435
|
var indexer = _this.state.indexer;
|
|
412
436
|
var colKey = columns[columnIndex].dataKey;
|
|
413
437
|
var signedRank = indexer.columnSortingSignedRank(colKey);
|
|
414
438
|
var userParams = indexer.getColFilterUserParams(colKey);
|
|
415
439
|
var numeric = columns[columnIndex].numeric;
|
|
416
|
-
|
|
417
|
-
var prefiltered = _this.preFilterData(columns, _this.props.rows);
|
|
418
|
-
|
|
440
|
+
var prefiltered = preFilterData(columns, _this.props.rows, _this.props.filter, indexer, indexer.filterVersion);
|
|
419
441
|
var colStat = prefiltered === null || prefiltered === void 0 ? void 0 : (_prefiltered$colsStat2 = prefiltered.colsStats) === null || _prefiltered$colsStat2 === void 0 ? void 0 : _prefiltered$colsStat2[colKey];
|
|
420
442
|
var filterLevel = 0;
|
|
421
443
|
|
|
@@ -424,8 +446,10 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
424
446
|
var userSelectedCount = userParams === null || userParams === void 0 ? void 0 : userParams.length;
|
|
425
447
|
filterLevel += userSelectedCount ? 1 : 0;
|
|
426
448
|
filterLevel += userSelectedCount >= countSeen ? 2 : 0;
|
|
427
|
-
} // disable filtering when
|
|
428
|
-
//
|
|
449
|
+
} // disable filtering when either:
|
|
450
|
+
// - the column is numeric, we only handle tags for string values
|
|
451
|
+
// - a cellRenderer is defined, as we have no simple way to match for chosen value(s)
|
|
452
|
+
// - using an external sort, because it would hardly know about the indexer filtering
|
|
429
453
|
|
|
430
454
|
|
|
431
455
|
var onFilterClick = numeric || _this.props.sort || columns[columnIndex].cellRenderer ? undefined : function (ev, retargeted) {
|
|
@@ -446,8 +470,8 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
446
470
|
});
|
|
447
471
|
});
|
|
448
472
|
|
|
449
|
-
_defineProperty(_assertThisInitialized(_this), "simpleHeaderRenderer", function (
|
|
450
|
-
var label =
|
|
473
|
+
_defineProperty(_assertThisInitialized(_this), "simpleHeaderRenderer", function (_ref4) {
|
|
474
|
+
var label = _ref4.label;
|
|
451
475
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
452
476
|
ref: function ref(element) {
|
|
453
477
|
_this._registerHeader(label, element);
|
|
@@ -455,11 +479,11 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
455
479
|
}, label);
|
|
456
480
|
});
|
|
457
481
|
|
|
458
|
-
_defineProperty(_assertThisInitialized(_this), "getRowClassName", function (
|
|
482
|
+
_defineProperty(_assertThisInitialized(_this), "getRowClassName", function (_ref5) {
|
|
459
483
|
var _rowGetter, _rowGetter2, _clsx;
|
|
460
484
|
|
|
461
|
-
var index =
|
|
462
|
-
rowGetter =
|
|
485
|
+
var index = _ref5.index,
|
|
486
|
+
rowGetter = _ref5.rowGetter;
|
|
463
487
|
var _this$props = _this.props,
|
|
464
488
|
classes = _this$props.classes,
|
|
465
489
|
onRowClick = _this$props.onRowClick;
|
|
@@ -474,12 +498,12 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
474
498
|
}
|
|
475
499
|
});
|
|
476
500
|
|
|
477
|
-
_defineProperty(_assertThisInitialized(_this), "cellRenderer", function (
|
|
501
|
+
_defineProperty(_assertThisInitialized(_this), "cellRenderer", function (_ref6) {
|
|
478
502
|
var _rows$rowIndex, _rows$rowIndex2, _clsx2;
|
|
479
503
|
|
|
480
|
-
var cellData =
|
|
481
|
-
columnIndex =
|
|
482
|
-
rowIndex =
|
|
504
|
+
var cellData = _ref6.cellData,
|
|
505
|
+
columnIndex = _ref6.columnIndex,
|
|
506
|
+
rowIndex = _ref6.rowIndex;
|
|
483
507
|
var _this$props2 = _this.props,
|
|
484
508
|
columns = _this$props2.columns,
|
|
485
509
|
classes = _this$props2.classes,
|
|
@@ -531,20 +555,20 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
531
555
|
/* The {...otherProps} just above would hold the slot onRowClick */
|
|
532
556
|
_this.onClickableRowClick,
|
|
533
557
|
rowCount: (_reorderedIndex$lengt = reorderedIndex === null || reorderedIndex === void 0 ? void 0 : reorderedIndex.length) !== null && _reorderedIndex$lengt !== void 0 ? _reorderedIndex$lengt : otherProps.rows.length,
|
|
534
|
-
rowClassName: function rowClassName(
|
|
535
|
-
var index =
|
|
558
|
+
rowClassName: function rowClassName(_ref7) {
|
|
559
|
+
var index = _ref7.index;
|
|
536
560
|
return _this.getRowClassName({
|
|
537
561
|
index: index,
|
|
538
562
|
rowGetter: _rowGetter3
|
|
539
563
|
});
|
|
540
564
|
},
|
|
541
|
-
rowGetter: function rowGetter(
|
|
542
|
-
var index =
|
|
565
|
+
rowGetter: function rowGetter(_ref8) {
|
|
566
|
+
var index = _ref8.index;
|
|
543
567
|
return _rowGetter3(index);
|
|
544
568
|
}
|
|
545
|
-
}), otherProps.columns.map(function (
|
|
546
|
-
var dataKey =
|
|
547
|
-
other = _objectWithoutPropertiesLoose(
|
|
569
|
+
}), otherProps.columns.map(function (_ref9, index) {
|
|
570
|
+
var dataKey = _ref9.dataKey,
|
|
571
|
+
other = _objectWithoutPropertiesLoose(_ref9, _excluded2);
|
|
548
572
|
|
|
549
573
|
return /*#__PURE__*/_react["default"].createElement(_reactVirtualized.Column, _extends({
|
|
550
574
|
key: dataKey,
|
|
@@ -574,8 +598,7 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
574
598
|
_defineProperty(_assertThisInitialized(_this), "getCSVData", function () {
|
|
575
599
|
var _reorderedIndex$viewI, _reorderedIndex$viewI2;
|
|
576
600
|
|
|
577
|
-
var reorderedIndex =
|
|
578
|
-
|
|
601
|
+
var reorderedIndex = reorderIndex(_this.state.indexer, _this.state.indirectionVersion, _this.props.rows, _this.props.columns, _this.props.filter, _this.props.sort);
|
|
579
602
|
var rowsCount = (_reorderedIndex$viewI = (_reorderedIndex$viewI2 = reorderedIndex.viewIndexToModel) === null || _reorderedIndex$viewI2 === void 0 ? void 0 : _reorderedIndex$viewI2.length) !== null && _reorderedIndex$viewI !== void 0 ? _reorderedIndex$viewI : _this.props.rows.length;
|
|
580
603
|
var csvData = [];
|
|
581
604
|
|
|
@@ -630,9 +653,8 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
630
653
|
_this.observer = new IntersectionObserver(_this._computeHeaderSize, _options);
|
|
631
654
|
_this.state = {
|
|
632
655
|
headerHeight: _this.props.headerHeight,
|
|
633
|
-
indexer: initIndexer(
|
|
656
|
+
indexer: initIndexer(props, null, _this.setVersion),
|
|
634
657
|
indirectionVersion: 0,
|
|
635
|
-
reorderIndex: null,
|
|
636
658
|
popoverAnchorEl: null,
|
|
637
659
|
popoverColKey: null,
|
|
638
660
|
deferredFilterChange: null
|
|
@@ -643,11 +665,22 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
643
665
|
var _proto = MuiVirtualizedTable.prototype;
|
|
644
666
|
|
|
645
667
|
_proto.componentDidUpdate = function componentDidUpdate(oldProps) {
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
668
|
+
var _this2 = this;
|
|
669
|
+
|
|
670
|
+
if (oldProps.indexer !== this.props.indexer || oldProps.sortable !== this.props.sortable) {
|
|
671
|
+
this.setState(function (state) {
|
|
672
|
+
var _state$indirectionVer;
|
|
673
|
+
|
|
674
|
+
return {
|
|
675
|
+
indexer: initIndexer(_this2.props, oldProps, _this2.setVersion),
|
|
676
|
+
indirectionVersion: ((_state$indirectionVer = state === null || state === void 0 ? void 0 : state.indirectionVersion) !== null && _state$indirectionVer !== void 0 ? _state$indirectionVer : 0) + 1
|
|
677
|
+
};
|
|
649
678
|
});
|
|
650
679
|
}
|
|
680
|
+
|
|
681
|
+
if (oldProps.headerHeight !== this.props.headerHeight) {
|
|
682
|
+
this._computeHeaderSize();
|
|
683
|
+
}
|
|
651
684
|
};
|
|
652
685
|
|
|
653
686
|
_proto.componentDidMount = function componentDidMount() {
|
|
@@ -729,7 +762,7 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
729
762
|
};
|
|
730
763
|
|
|
731
764
|
_proto.makeHeaderRenderer = function makeHeaderRenderer(dataKey, columnIndex) {
|
|
732
|
-
var
|
|
765
|
+
var _this3 = this;
|
|
733
766
|
|
|
734
767
|
var _this$props4 = this.props,
|
|
735
768
|
columns = _this$props4.columns,
|
|
@@ -740,27 +773,27 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
740
773
|
className: (0, _clsx3["default"])(classes.tableCell, classes.flexContainer, classes.noClick, classes.header),
|
|
741
774
|
variant: "head",
|
|
742
775
|
style: {
|
|
743
|
-
height:
|
|
776
|
+
height: _this3.state.headerHeight
|
|
744
777
|
},
|
|
745
778
|
align: columns[columnIndex].numeric || false ? 'right' : 'left',
|
|
746
779
|
ref: function ref(e) {
|
|
747
|
-
return
|
|
780
|
+
return _this3._registerObserver(e);
|
|
748
781
|
}
|
|
749
|
-
},
|
|
782
|
+
}, _this3.props.sortable && _this3.state.indexer ? _this3.sortableHeader(_extends({}, headerProps, {
|
|
750
783
|
columnIndex: columnIndex,
|
|
751
784
|
key: {
|
|
752
785
|
dataKey: dataKey
|
|
753
786
|
}
|
|
754
|
-
})) :
|
|
787
|
+
})) : _this3.simpleHeaderRenderer(_extends({}, headerProps)));
|
|
755
788
|
};
|
|
756
789
|
};
|
|
757
790
|
|
|
758
791
|
_proto.render = function render() {
|
|
759
|
-
var
|
|
792
|
+
var _this4 = this;
|
|
760
793
|
|
|
761
|
-
var
|
|
762
|
-
viewIndexToModel =
|
|
763
|
-
rowGetter =
|
|
794
|
+
var _reorderIndex = reorderIndex(this.state.indexer, this.state.indirectionVersion, this.props.rows, this.props.columns, this.props.filter, this.props.sort),
|
|
795
|
+
viewIndexToModel = _reorderIndex.viewIndexToModel,
|
|
796
|
+
rowGetter = _reorderIndex.rowGetter;
|
|
764
797
|
|
|
765
798
|
var sizes = this.sizes(this.props.columns, this.props.rows, rowGetter);
|
|
766
799
|
var csvHeaders = this.csvHeaders(this.props.columns, this.props.exportCSVDataKeys);
|
|
@@ -789,22 +822,28 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
789
822
|
style: {
|
|
790
823
|
flexGrow: 1
|
|
791
824
|
}
|
|
792
|
-
}, /*#__PURE__*/_react["default"].createElement(_reactVirtualized.AutoSizer, null, function (
|
|
793
|
-
var height =
|
|
794
|
-
width =
|
|
795
|
-
return
|
|
825
|
+
}, /*#__PURE__*/_react["default"].createElement(_reactVirtualized.AutoSizer, null, function (_ref10) {
|
|
826
|
+
var height = _ref10.height,
|
|
827
|
+
width = _ref10.width;
|
|
828
|
+
return _this4.makeSizedTable(height, width, sizes, viewIndexToModel, rowGetter);
|
|
796
829
|
})), this.state.popoverAnchorEl && /*#__PURE__*/_react["default"].createElement(_material.Popover, {
|
|
797
830
|
anchorEl: this.state.popoverAnchorEl,
|
|
798
831
|
anchorOrigin: {
|
|
799
|
-
vertical: '
|
|
800
|
-
horizontal: '
|
|
832
|
+
vertical: 'bottom',
|
|
833
|
+
horizontal: 'left'
|
|
801
834
|
},
|
|
802
835
|
transformOrigin: {
|
|
803
|
-
vertical: '
|
|
804
|
-
horizontal: '
|
|
836
|
+
vertical: 'top',
|
|
837
|
+
horizontal: 'left'
|
|
805
838
|
},
|
|
839
|
+
onKeyDownCapture: this.handleKeyDownOnPopover,
|
|
806
840
|
onClose: this.closePopover,
|
|
807
|
-
open: !!this.state.popoverAnchorEl
|
|
841
|
+
open: !!this.state.popoverAnchorEl,
|
|
842
|
+
PaperProps: {
|
|
843
|
+
style: {
|
|
844
|
+
minWidth: '20ex'
|
|
845
|
+
}
|
|
846
|
+
}
|
|
808
847
|
}, this.makeColumnFilterEditor()));
|
|
809
848
|
};
|
|
810
849
|
|