material-react-table 0.19.0 → 0.20.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/MaterialReactTable.d.ts +1 -2
- package/dist/material-react-table.cjs.development.js +405 -348
- package/dist/material-react-table.cjs.development.js.map +1 -1
- package/dist/material-react-table.cjs.production.min.js +1 -1
- package/dist/material-react-table.cjs.production.min.js.map +1 -1
- package/dist/material-react-table.esm.js +19 -8
- package/dist/material-react-table.esm.js.map +1 -1
- package/package.json +4 -4
- package/src/MaterialReactTable.tsx +2 -2
- package/src/body/MRT_TableBody.tsx +21 -13
|
@@ -6365,40 +6365,28 @@ var MRT_TableHead = function MRT_TableHead(_ref) {
|
|
|
6365
6365
|
}));
|
|
6366
6366
|
};
|
|
6367
6367
|
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
}
|
|
6379
|
-
|
|
6380
|
-
return target;
|
|
6381
|
-
};
|
|
6382
|
-
|
|
6383
|
-
return _extends$1.apply(this, arguments);
|
|
6384
|
-
}
|
|
6385
|
-
|
|
6386
|
-
function _objectWithoutPropertiesLoose$2(source, excluded) {
|
|
6387
|
-
if (source == null) return {};
|
|
6388
|
-
var target = {};
|
|
6389
|
-
var sourceKeys = Object.keys(source);
|
|
6390
|
-
var key, i;
|
|
6391
|
-
|
|
6392
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
6393
|
-
key = sourceKeys[i];
|
|
6394
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
6395
|
-
target[key] = source[key];
|
|
6396
|
-
}
|
|
6397
|
-
|
|
6398
|
-
return target;
|
|
6399
|
-
}
|
|
6368
|
+
/**
|
|
6369
|
+
* react-virtual
|
|
6370
|
+
*
|
|
6371
|
+
* Copyright (c) TanStack
|
|
6372
|
+
*
|
|
6373
|
+
* This source code is licensed under the MIT license found in the
|
|
6374
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
6375
|
+
*
|
|
6376
|
+
* @license MIT
|
|
6377
|
+
*/
|
|
6400
6378
|
|
|
6401
|
-
|
|
6379
|
+
/**
|
|
6380
|
+
* virtual-core
|
|
6381
|
+
*
|
|
6382
|
+
* Copyright (c) TanStack
|
|
6383
|
+
*
|
|
6384
|
+
* This source code is licensed under the MIT license found in the
|
|
6385
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
6386
|
+
*
|
|
6387
|
+
* @license MIT
|
|
6388
|
+
*/
|
|
6389
|
+
var props = ["bottom", "height", "left", "right", "top", "width"];
|
|
6402
6390
|
|
|
6403
6391
|
var rectChanged = function rectChanged(a, b) {
|
|
6404
6392
|
if (a === void 0) {
|
|
@@ -6468,355 +6456,383 @@ function observeRect(node, cb) {
|
|
|
6468
6456
|
};
|
|
6469
6457
|
}
|
|
6470
6458
|
|
|
6471
|
-
|
|
6459
|
+
function memo(getDeps, fn, opts) {
|
|
6460
|
+
let deps = [];
|
|
6461
|
+
let result;
|
|
6462
|
+
return () => {
|
|
6463
|
+
let depTime;
|
|
6464
|
+
if (opts.key && opts.debug != null && opts.debug()) depTime = Date.now();
|
|
6465
|
+
const newDeps = getDeps();
|
|
6466
|
+
const depsChanged = newDeps.length !== deps.length || newDeps.some((dep, index) => deps[index] !== dep);
|
|
6472
6467
|
|
|
6473
|
-
|
|
6474
|
-
|
|
6475
|
-
|
|
6476
|
-
width: 0,
|
|
6477
|
-
height: 0
|
|
6478
|
-
};
|
|
6479
|
-
}
|
|
6468
|
+
if (!depsChanged) {
|
|
6469
|
+
return result;
|
|
6470
|
+
}
|
|
6480
6471
|
|
|
6481
|
-
|
|
6482
|
-
|
|
6483
|
-
|
|
6472
|
+
deps = newDeps;
|
|
6473
|
+
let resultTime;
|
|
6474
|
+
if (opts.key && opts.debug != null && opts.debug()) resultTime = Date.now();
|
|
6475
|
+
result = fn(...newDeps);
|
|
6476
|
+
opts == null ? void 0 : opts.onChange == null ? void 0 : opts.onChange(result);
|
|
6484
6477
|
|
|
6485
|
-
|
|
6486
|
-
|
|
6487
|
-
|
|
6478
|
+
if (opts.key && opts.debug != null && opts.debug()) {
|
|
6479
|
+
const depEndTime = Math.round((Date.now() - depTime) * 100) / 100;
|
|
6480
|
+
const resultEndTime = Math.round((Date.now() - resultTime) * 100) / 100;
|
|
6481
|
+
const resultFpsPercentage = resultEndTime / 16;
|
|
6488
6482
|
|
|
6489
|
-
|
|
6490
|
-
|
|
6491
|
-
if (nodeRef.current !== element) {
|
|
6492
|
-
setElement(nodeRef.current);
|
|
6493
|
-
}
|
|
6494
|
-
});
|
|
6495
|
-
useIsomorphicLayoutEffect$1(function () {
|
|
6496
|
-
if (element && !initialRectSet.current) {
|
|
6497
|
-
initialRectSet.current = true;
|
|
6483
|
+
const pad = (str, num) => {
|
|
6484
|
+
str = String(str);
|
|
6498
6485
|
|
|
6499
|
-
|
|
6486
|
+
while (str.length < num) {
|
|
6487
|
+
str = ' ' + str;
|
|
6488
|
+
}
|
|
6500
6489
|
|
|
6501
|
-
|
|
6502
|
-
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
}, [element]);
|
|
6506
|
-
React__default.useEffect(function () {
|
|
6507
|
-
if (!element) {
|
|
6508
|
-
return;
|
|
6490
|
+
return str;
|
|
6491
|
+
};
|
|
6492
|
+
|
|
6493
|
+
console.info("%c\u23F1 " + pad(resultEndTime, 5) + " /" + pad(depEndTime, 5) + " ms", "\n font-size: .6rem;\n font-weight: bold;\n color: hsl(" + Math.max(0, Math.min(120 - 120 * resultFpsPercentage, 120)) + "deg 100% 31%);", opts == null ? void 0 : opts.key);
|
|
6509
6494
|
}
|
|
6510
6495
|
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
rect: rect
|
|
6514
|
-
});
|
|
6515
|
-
});
|
|
6516
|
-
observer.observe();
|
|
6517
|
-
return function () {
|
|
6518
|
-
observer.unobserve();
|
|
6519
|
-
};
|
|
6520
|
-
}, [element]);
|
|
6521
|
-
return rect;
|
|
6496
|
+
return result;
|
|
6497
|
+
};
|
|
6522
6498
|
}
|
|
6523
6499
|
|
|
6524
|
-
|
|
6525
|
-
|
|
6500
|
+
//
|
|
6501
|
+
const defaultKeyExtractor = index => index;
|
|
6502
|
+
const defaultRangeExtractor = range => {
|
|
6503
|
+
const start = Math.max(range.startIndex - range.overscan, 0);
|
|
6504
|
+
const end = Math.min(range.endIndex + range.overscan, range.count - 1);
|
|
6505
|
+
const arr = [];
|
|
6526
6506
|
|
|
6527
|
-
|
|
6528
|
-
|
|
6507
|
+
for (let i = start; i <= end; i++) {
|
|
6508
|
+
arr.push(i);
|
|
6529
6509
|
}
|
|
6530
6510
|
|
|
6531
|
-
return
|
|
6532
|
-
}
|
|
6533
|
-
|
|
6534
|
-
var defaultEstimateSize = function defaultEstimateSize() {
|
|
6535
|
-
return 50;
|
|
6511
|
+
return arr;
|
|
6536
6512
|
};
|
|
6513
|
+
const observeElementRect = (instance, cb) => {
|
|
6514
|
+
const observer = observeRect(instance.scrollElement, rect => {
|
|
6515
|
+
cb(rect);
|
|
6516
|
+
});
|
|
6537
6517
|
|
|
6538
|
-
|
|
6539
|
-
|
|
6540
|
-
}
|
|
6518
|
+
if (!instance.scrollElement) {
|
|
6519
|
+
return;
|
|
6520
|
+
}
|
|
6541
6521
|
|
|
6542
|
-
|
|
6543
|
-
|
|
6544
|
-
return
|
|
6522
|
+
cb(instance.scrollElement.getBoundingClientRect());
|
|
6523
|
+
observer.observe();
|
|
6524
|
+
return () => {
|
|
6525
|
+
observer.unobserve();
|
|
6526
|
+
};
|
|
6545
6527
|
};
|
|
6528
|
+
const observeElementOffset = (instance, cb) => {
|
|
6529
|
+
const onScroll = () => cb(instance.scrollElement[instance.options.horizontal ? 'scrollLeft' : 'scrollTop']);
|
|
6546
6530
|
|
|
6547
|
-
|
|
6548
|
-
|
|
6549
|
-
var end = Math.min(range.end + range.overscan, range.size - 1);
|
|
6550
|
-
var arr = [];
|
|
6551
|
-
|
|
6552
|
-
for (var i = start; i <= end; i++) {
|
|
6553
|
-
arr.push(i);
|
|
6531
|
+
if (!instance.scrollElement) {
|
|
6532
|
+
return;
|
|
6554
6533
|
}
|
|
6555
6534
|
|
|
6556
|
-
|
|
6535
|
+
onScroll();
|
|
6536
|
+
instance.scrollElement.addEventListener('scroll', onScroll, {
|
|
6537
|
+
capture: false,
|
|
6538
|
+
passive: true
|
|
6539
|
+
});
|
|
6540
|
+
return () => {
|
|
6541
|
+
instance.scrollElement.removeEventListener('scroll', onScroll);
|
|
6542
|
+
};
|
|
6557
6543
|
};
|
|
6558
|
-
|
|
6559
|
-
|
|
6560
|
-
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
|
|
6565
|
-
|
|
6566
|
-
overscan = _ref$overscan === void 0 ? 1 : _ref$overscan,
|
|
6567
|
-
_ref$paddingStart = _ref.paddingStart,
|
|
6568
|
-
paddingStart = _ref$paddingStart === void 0 ? 0 : _ref$paddingStart,
|
|
6569
|
-
_ref$paddingEnd = _ref.paddingEnd,
|
|
6570
|
-
paddingEnd = _ref$paddingEnd === void 0 ? 0 : _ref$paddingEnd,
|
|
6571
|
-
parentRef = _ref.parentRef,
|
|
6572
|
-
horizontal = _ref.horizontal,
|
|
6573
|
-
scrollToFn = _ref.scrollToFn,
|
|
6574
|
-
useObserver = _ref.useObserver,
|
|
6575
|
-
initialRect = _ref.initialRect,
|
|
6576
|
-
onScrollElement = _ref.onScrollElement,
|
|
6577
|
-
scrollOffsetFn = _ref.scrollOffsetFn,
|
|
6578
|
-
_ref$keyExtractor = _ref.keyExtractor,
|
|
6579
|
-
keyExtractor = _ref$keyExtractor === void 0 ? defaultKeyExtractor : _ref$keyExtractor,
|
|
6580
|
-
_ref$measureSize = _ref.measureSize,
|
|
6581
|
-
measureSize = _ref$measureSize === void 0 ? defaultMeasureSize : _ref$measureSize,
|
|
6582
|
-
_ref$rangeExtractor = _ref.rangeExtractor,
|
|
6583
|
-
rangeExtractor = _ref$rangeExtractor === void 0 ? defaultRangeExtractor : _ref$rangeExtractor;
|
|
6584
|
-
var sizeKey = horizontal ? 'width' : 'height';
|
|
6585
|
-
var scrollKey = horizontal ? 'scrollLeft' : 'scrollTop';
|
|
6586
|
-
var latestRef = React__default.useRef({
|
|
6587
|
-
scrollOffset: 0,
|
|
6588
|
-
measurements: []
|
|
6544
|
+
const measureElement = (element, instance) => {
|
|
6545
|
+
return element.getBoundingClientRect()[instance.options.horizontal ? 'width' : 'height'];
|
|
6546
|
+
};
|
|
6547
|
+
const elementScroll = (offset, canSmooth, instance) => {
|
|
6548
|
+
var _instance$scrollEleme2;
|
|
6549
|
+
(_instance$scrollEleme2 = instance.scrollElement) == null ? void 0 : _instance$scrollEleme2.scrollTo({
|
|
6550
|
+
[instance.options.horizontal ? 'left' : 'top']: offset,
|
|
6551
|
+
behavior: canSmooth ? 'smooth' : undefined
|
|
6589
6552
|
});
|
|
6553
|
+
};
|
|
6554
|
+
class Virtualizer {
|
|
6555
|
+
constructor(_opts) {
|
|
6556
|
+
var _this = this;
|
|
6557
|
+
|
|
6558
|
+
this.unsubs = [];
|
|
6559
|
+
this.scrollElement = null;
|
|
6560
|
+
this.measurementsCache = [];
|
|
6561
|
+
this.itemMeasurementsCache = {};
|
|
6562
|
+
this.pendingMeasuredCacheIndexes = [];
|
|
6563
|
+
|
|
6564
|
+
this.setOptions = opts => {
|
|
6565
|
+
Object.entries(opts).forEach(_ref => {
|
|
6566
|
+
let [key, value] = _ref;
|
|
6567
|
+
if (typeof value === 'undefined') delete opts[key];
|
|
6568
|
+
});
|
|
6569
|
+
this.options = {
|
|
6570
|
+
debug: false,
|
|
6571
|
+
initialOffset: 0,
|
|
6572
|
+
overscan: 1,
|
|
6573
|
+
paddingStart: 0,
|
|
6574
|
+
paddingEnd: 0,
|
|
6575
|
+
scrollPaddingStart: 0,
|
|
6576
|
+
scrollPaddingEnd: 0,
|
|
6577
|
+
horizontal: false,
|
|
6578
|
+
getItemKey: defaultKeyExtractor,
|
|
6579
|
+
rangeExtractor: defaultRangeExtractor,
|
|
6580
|
+
enableSmoothScroll: true,
|
|
6581
|
+
onChange: () => {},
|
|
6582
|
+
measureElement,
|
|
6583
|
+
initialRect: {
|
|
6584
|
+
width: 0,
|
|
6585
|
+
height: 0
|
|
6586
|
+
},
|
|
6587
|
+
...opts
|
|
6588
|
+
};
|
|
6589
|
+
};
|
|
6590
6590
|
|
|
6591
|
-
|
|
6592
|
-
|
|
6593
|
-
setScrollOffset = _React$useState[1];
|
|
6591
|
+
this.notify = () => {
|
|
6592
|
+
var _this$options$onChang, _this$options;
|
|
6594
6593
|
|
|
6595
|
-
|
|
6596
|
-
|
|
6594
|
+
(_this$options$onChang = (_this$options = this.options).onChange) == null ? void 0 : _this$options$onChang.call(_this$options, this);
|
|
6595
|
+
};
|
|
6597
6596
|
|
|
6598
|
-
|
|
6599
|
-
|
|
6597
|
+
this.cleanup = () => {
|
|
6598
|
+
this.unsubs.filter(Boolean).forEach(d => d());
|
|
6599
|
+
this.unsubs = [];
|
|
6600
|
+
};
|
|
6600
6601
|
|
|
6601
|
-
|
|
6602
|
-
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
|
-
}
|
|
6606
|
-
}, [parentRef, scrollKey]);
|
|
6607
|
-
var resolvedScrollToFn = scrollToFn || defaultScrollToFn;
|
|
6608
|
-
scrollToFn = React__default.useCallback(function (offset) {
|
|
6609
|
-
resolvedScrollToFn(offset, defaultScrollToFn);
|
|
6610
|
-
}, [defaultScrollToFn, resolvedScrollToFn]);
|
|
6602
|
+
this._didMount = () => {
|
|
6603
|
+
return () => {
|
|
6604
|
+
this.cleanup();
|
|
6605
|
+
};
|
|
6606
|
+
};
|
|
6611
6607
|
|
|
6612
|
-
|
|
6613
|
-
|
|
6614
|
-
|
|
6608
|
+
this._willUpdate = () => {
|
|
6609
|
+
const scrollElement = this.options.getScrollElement();
|
|
6610
|
+
|
|
6611
|
+
if (this.scrollElement !== scrollElement) {
|
|
6612
|
+
this.cleanup();
|
|
6613
|
+
this.scrollElement = scrollElement;
|
|
6614
|
+
this.unsubs.push(this.options.observeElementRect(this, rect => {
|
|
6615
|
+
this.scrollRect = rect;
|
|
6616
|
+
this.notify();
|
|
6617
|
+
}));
|
|
6618
|
+
this.unsubs.push(this.options.observeElementOffset(this, offset => {
|
|
6619
|
+
this.scrollOffset = offset;
|
|
6620
|
+
this.notify();
|
|
6621
|
+
}));
|
|
6622
|
+
}
|
|
6623
|
+
};
|
|
6615
6624
|
|
|
6616
|
-
|
|
6617
|
-
|
|
6618
|
-
|
|
6619
|
-
var pendingMeasuredCacheIndexesRef = React__default.useRef([]);
|
|
6620
|
-
var measurements = React__default.useMemo(function () {
|
|
6621
|
-
var min = pendingMeasuredCacheIndexesRef.current.length > 0 ? Math.min.apply(Math, pendingMeasuredCacheIndexesRef.current) : 0;
|
|
6622
|
-
pendingMeasuredCacheIndexesRef.current = [];
|
|
6623
|
-
var measurements = latestRef.current.measurements.slice(0, min);
|
|
6625
|
+
this.getSize = () => {
|
|
6626
|
+
return this.scrollRect[this.options.horizontal ? 'width' : 'height'];
|
|
6627
|
+
};
|
|
6624
6628
|
|
|
6625
|
-
|
|
6626
|
-
|
|
6627
|
-
|
|
6629
|
+
this.getMeasurements = memo(() => [this.options.count, this.options.paddingStart, this.options.getItemKey, this.itemMeasurementsCache], (count, paddingStart, getItemKey, measurementsCache) => {
|
|
6630
|
+
const min = this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
|
|
6631
|
+
this.pendingMeasuredCacheIndexes = [];
|
|
6632
|
+
const measurements = this.measurementsCache.slice(0, min);
|
|
6633
|
+
|
|
6634
|
+
for (let i = min; i < count; i++) {
|
|
6635
|
+
const key = getItemKey(i);
|
|
6636
|
+
const measuredSize = measurementsCache[key];
|
|
6637
|
+
const start = measurements[i - 1] ? measurements[i - 1].end : paddingStart;
|
|
6638
|
+
const size = typeof measuredSize === 'number' ? measuredSize : this.options.estimateSize(i);
|
|
6639
|
+
const end = start + size;
|
|
6640
|
+
measurements[i] = {
|
|
6641
|
+
index: i,
|
|
6642
|
+
start,
|
|
6643
|
+
size,
|
|
6644
|
+
end,
|
|
6645
|
+
key
|
|
6646
|
+
};
|
|
6647
|
+
}
|
|
6628
6648
|
|
|
6629
|
-
|
|
6649
|
+
this.measurementsCache = measurements;
|
|
6650
|
+
return measurements;
|
|
6651
|
+
}, {
|
|
6652
|
+
key: 'getMeasurements',
|
|
6653
|
+
debug: () => this.options.debug
|
|
6654
|
+
});
|
|
6655
|
+
this.calculateRange = memo(() => [this.getMeasurements(), this.getSize(), this.scrollOffset], (measurements, outerSize, scrollOffset) => {
|
|
6656
|
+
return calculateRange({
|
|
6657
|
+
measurements,
|
|
6658
|
+
outerSize,
|
|
6659
|
+
scrollOffset
|
|
6660
|
+
});
|
|
6661
|
+
}, {
|
|
6662
|
+
key: 'calculateRange',
|
|
6663
|
+
debug: () => this.options.debug
|
|
6664
|
+
});
|
|
6665
|
+
this.getIndexes = memo(() => [this.options.rangeExtractor, this.calculateRange(), this.options.overscan, this.options.count], (rangeExtractor, range, overscan, count) => {
|
|
6666
|
+
return rangeExtractor({ ...range,
|
|
6667
|
+
overscan,
|
|
6668
|
+
count: count
|
|
6669
|
+
});
|
|
6670
|
+
}, {
|
|
6671
|
+
key: 'getIndexes'
|
|
6672
|
+
});
|
|
6673
|
+
this.getVirtualItems = memo(() => [this.getIndexes(), this.getMeasurements(), this.options.measureElement], (indexes, measurements, measureElement) => {
|
|
6674
|
+
const virtualItems = [];
|
|
6675
|
+
|
|
6676
|
+
for (let k = 0, len = indexes.length; k < len; k++) {
|
|
6677
|
+
const i = indexes[k];
|
|
6678
|
+
const measurement = measurements[i];
|
|
6679
|
+
const item = { ...measurement,
|
|
6680
|
+
measureElement: measurableItem => {
|
|
6681
|
+
if (measurableItem) {
|
|
6682
|
+
const measuredItemSize = measureElement(measurableItem, this);
|
|
6683
|
+
|
|
6684
|
+
if (measuredItemSize !== item.size) {
|
|
6685
|
+
if (item.start < this.scrollOffset) {
|
|
6686
|
+
if ( this.options.debug) console.info('correction', measuredItemSize - item.size);
|
|
6687
|
+
|
|
6688
|
+
if (!this.destinationOffset) {
|
|
6689
|
+
this._scrollToOffset(this.scrollOffset + (measuredItemSize - item.size), false);
|
|
6690
|
+
}
|
|
6691
|
+
}
|
|
6630
6692
|
|
|
6631
|
-
|
|
6693
|
+
this.pendingMeasuredCacheIndexes.push(i);
|
|
6694
|
+
this.itemMeasurementsCache = { ...this.itemMeasurementsCache,
|
|
6695
|
+
[item.key]: measuredItemSize
|
|
6696
|
+
};
|
|
6697
|
+
this.notify();
|
|
6698
|
+
}
|
|
6699
|
+
}
|
|
6700
|
+
}
|
|
6701
|
+
};
|
|
6702
|
+
virtualItems.push(item);
|
|
6703
|
+
}
|
|
6632
6704
|
|
|
6633
|
-
|
|
6705
|
+
return virtualItems;
|
|
6706
|
+
}, {
|
|
6707
|
+
key: 'getIndexes'
|
|
6708
|
+
});
|
|
6634
6709
|
|
|
6635
|
-
|
|
6636
|
-
|
|
6637
|
-
|
|
6638
|
-
|
|
6639
|
-
|
|
6640
|
-
|
|
6641
|
-
|
|
6642
|
-
|
|
6710
|
+
this.scrollToOffset = function (toOffset, _temp) {
|
|
6711
|
+
let {
|
|
6712
|
+
align
|
|
6713
|
+
} = _temp === void 0 ? {
|
|
6714
|
+
align: 'start'
|
|
6715
|
+
} : _temp;
|
|
6716
|
+
|
|
6717
|
+
const attempt = () => {
|
|
6718
|
+
const offset = _this.scrollOffset;
|
|
6719
|
+
|
|
6720
|
+
const size = _this.getSize();
|
|
6721
|
+
|
|
6722
|
+
if (align === 'auto') {
|
|
6723
|
+
if (toOffset <= offset) {
|
|
6724
|
+
align = 'start';
|
|
6725
|
+
} else if (toOffset >= offset + size) {
|
|
6726
|
+
align = 'end';
|
|
6727
|
+
} else {
|
|
6728
|
+
align = 'start';
|
|
6729
|
+
}
|
|
6730
|
+
}
|
|
6643
6731
|
|
|
6644
|
-
|
|
6645
|
-
|
|
6646
|
-
|
|
6647
|
-
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
|
|
6652
|
-
useIsomorphicLayoutEffect$1(function () {
|
|
6653
|
-
if (!element) {
|
|
6654
|
-
setScrollOffset(0);
|
|
6655
|
-
return;
|
|
6656
|
-
}
|
|
6732
|
+
if (align === 'start') {
|
|
6733
|
+
_this._scrollToOffset(toOffset, true);
|
|
6734
|
+
} else if (align === 'end') {
|
|
6735
|
+
_this._scrollToOffset(toOffset - size, true);
|
|
6736
|
+
} else if (align === 'center') {
|
|
6737
|
+
_this._scrollToOffset(toOffset - size / 2, true);
|
|
6738
|
+
}
|
|
6739
|
+
};
|
|
6657
6740
|
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
|
|
6741
|
+
attempt();
|
|
6742
|
+
requestAnimationFrame(() => {
|
|
6743
|
+
attempt();
|
|
6744
|
+
});
|
|
6661
6745
|
};
|
|
6662
6746
|
|
|
6663
|
-
|
|
6664
|
-
|
|
6665
|
-
|
|
6666
|
-
|
|
6667
|
-
|
|
6668
|
-
|
|
6669
|
-
|
|
6670
|
-
};
|
|
6671
|
-
}, [element, scrollKey]);
|
|
6672
|
-
|
|
6673
|
-
var _calculateRange = calculateRange(latestRef.current),
|
|
6674
|
-
start = _calculateRange.start,
|
|
6675
|
-
end = _calculateRange.end;
|
|
6676
|
-
|
|
6677
|
-
var indexes = React__default.useMemo(function () {
|
|
6678
|
-
return rangeExtractor({
|
|
6679
|
-
start: start,
|
|
6680
|
-
end: end,
|
|
6681
|
-
overscan: overscan,
|
|
6682
|
-
size: measurements.length
|
|
6683
|
-
});
|
|
6684
|
-
}, [start, end, overscan, measurements.length, rangeExtractor]);
|
|
6685
|
-
var measureSizeRef = React__default.useRef(measureSize);
|
|
6686
|
-
measureSizeRef.current = measureSize;
|
|
6687
|
-
var virtualItems = React__default.useMemo(function () {
|
|
6688
|
-
var virtualItems = [];
|
|
6689
|
-
|
|
6690
|
-
var _loop = function _loop(k, len) {
|
|
6691
|
-
var i = indexes[k];
|
|
6692
|
-
var measurement = measurements[i];
|
|
6693
|
-
|
|
6694
|
-
var item = _extends$1(_extends$1({}, measurement), {}, {
|
|
6695
|
-
measureRef: function measureRef(el) {
|
|
6696
|
-
if (el) {
|
|
6697
|
-
var measuredSize = measureSizeRef.current(el, horizontal);
|
|
6698
|
-
|
|
6699
|
-
if (measuredSize !== item.size) {
|
|
6700
|
-
var _scrollOffset = latestRef.current.scrollOffset;
|
|
6701
|
-
|
|
6702
|
-
if (item.start < _scrollOffset) {
|
|
6703
|
-
defaultScrollToFn(_scrollOffset + (measuredSize - item.size));
|
|
6704
|
-
}
|
|
6747
|
+
this.scrollToIndex = function (index, _temp2) {
|
|
6748
|
+
let {
|
|
6749
|
+
align,
|
|
6750
|
+
...rest
|
|
6751
|
+
} = _temp2 === void 0 ? {
|
|
6752
|
+
align: 'auto'
|
|
6753
|
+
} : _temp2;
|
|
6705
6754
|
|
|
6706
|
-
|
|
6707
|
-
setMeasuredCache(function (old) {
|
|
6708
|
-
var _extends2;
|
|
6755
|
+
const measurements = _this.getMeasurements();
|
|
6709
6756
|
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
|
|
6713
|
-
|
|
6757
|
+
const offset = _this.scrollOffset;
|
|
6758
|
+
|
|
6759
|
+
const size = _this.getSize();
|
|
6760
|
+
|
|
6761
|
+
const {
|
|
6762
|
+
count
|
|
6763
|
+
} = _this.options;
|
|
6764
|
+
const measurement = measurements[Math.max(0, Math.min(index, count - 1))];
|
|
6765
|
+
|
|
6766
|
+
if (!measurement) {
|
|
6767
|
+
return;
|
|
6768
|
+
}
|
|
6769
|
+
|
|
6770
|
+
if (align === 'auto') {
|
|
6771
|
+
if (measurement.end >= offset + size - _this.options.scrollPaddingEnd) {
|
|
6772
|
+
align = 'end';
|
|
6773
|
+
} else if (measurement.start <= offset + _this.options.scrollPaddingStart) {
|
|
6774
|
+
align = 'start';
|
|
6775
|
+
} else {
|
|
6776
|
+
return;
|
|
6714
6777
|
}
|
|
6715
|
-
}
|
|
6778
|
+
}
|
|
6716
6779
|
|
|
6717
|
-
|
|
6780
|
+
const toOffset = align === 'end' ? measurement.end + _this.options.scrollPaddingEnd : measurement.start - _this.options.scrollPaddingStart;
|
|
6781
|
+
|
|
6782
|
+
_this.scrollToOffset(toOffset, {
|
|
6783
|
+
align,
|
|
6784
|
+
...rest
|
|
6785
|
+
});
|
|
6718
6786
|
};
|
|
6719
6787
|
|
|
6720
|
-
|
|
6721
|
-
|
|
6722
|
-
}
|
|
6788
|
+
this.getTotalSize = () => {
|
|
6789
|
+
var _this$getMeasurements;
|
|
6723
6790
|
|
|
6724
|
-
|
|
6725
|
-
|
|
6726
|
-
var mountedRef = React__default.useRef(false);
|
|
6727
|
-
useIsomorphicLayoutEffect$1(function () {
|
|
6728
|
-
if (mountedRef.current) {
|
|
6729
|
-
setMeasuredCache({});
|
|
6730
|
-
}
|
|
6791
|
+
return (((_this$getMeasurements = this.getMeasurements()[this.options.count - 1]) == null ? void 0 : _this$getMeasurements.end) || this.options.paddingStart) + this.options.paddingEnd;
|
|
6792
|
+
};
|
|
6731
6793
|
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
|
|
6735
|
-
|
|
6736
|
-
|
|
6737
|
-
align = _ref2$align === void 0 ? 'start' : _ref2$align;
|
|
6794
|
+
this._scrollToOffset = (offset, canSmooth) => {
|
|
6795
|
+
clearTimeout(this.scrollCheckFrame);
|
|
6796
|
+
this.destinationOffset = offset;
|
|
6797
|
+
this.options.scrollToFn(offset, this.options.enableSmoothScroll && canSmooth, this);
|
|
6798
|
+
let scrollCheckFrame;
|
|
6738
6799
|
|
|
6739
|
-
|
|
6740
|
-
|
|
6741
|
-
|
|
6800
|
+
const check = () => {
|
|
6801
|
+
let lastOffset = this.scrollOffset;
|
|
6802
|
+
this.scrollCheckFrame = scrollCheckFrame = setTimeout(() => {
|
|
6803
|
+
if (this.scrollCheckFrame !== scrollCheckFrame) {
|
|
6804
|
+
return;
|
|
6805
|
+
}
|
|
6742
6806
|
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
|
|
6746
|
-
|
|
6747
|
-
align = 'end';
|
|
6748
|
-
} else {
|
|
6749
|
-
align = 'start';
|
|
6750
|
-
}
|
|
6751
|
-
}
|
|
6807
|
+
if (this.scrollOffset === lastOffset) {
|
|
6808
|
+
this.destinationOffset = undefined;
|
|
6809
|
+
return;
|
|
6810
|
+
}
|
|
6752
6811
|
|
|
6753
|
-
|
|
6754
|
-
|
|
6755
|
-
|
|
6756
|
-
|
|
6757
|
-
} else if (align === 'center') {
|
|
6758
|
-
scrollToFn(toOffset - outerSize / 2);
|
|
6759
|
-
}
|
|
6760
|
-
}, [scrollToFn]);
|
|
6761
|
-
var tryScrollToIndex = React__default.useCallback(function (index, _temp2) {
|
|
6762
|
-
var _ref3 = _temp2 === void 0 ? {} : _temp2,
|
|
6763
|
-
_ref3$align = _ref3.align,
|
|
6764
|
-
align = _ref3$align === void 0 ? 'auto' : _ref3$align,
|
|
6765
|
-
rest = _objectWithoutPropertiesLoose$2(_ref3, ["align"]);
|
|
6812
|
+
lastOffset = this.scrollOffset;
|
|
6813
|
+
check();
|
|
6814
|
+
}, 100);
|
|
6815
|
+
};
|
|
6766
6816
|
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
scrollOffset = _latestRef$current2.scrollOffset,
|
|
6770
|
-
outerSize = _latestRef$current2.outerSize;
|
|
6771
|
-
var measurement = measurements[Math.max(0, Math.min(index, size - 1))];
|
|
6817
|
+
check();
|
|
6818
|
+
};
|
|
6772
6819
|
|
|
6773
|
-
|
|
6774
|
-
|
|
6775
|
-
|
|
6820
|
+
this.measure = () => {
|
|
6821
|
+
this.itemMeasurementsCache = {};
|
|
6822
|
+
this.notify();
|
|
6823
|
+
};
|
|
6776
6824
|
|
|
6777
|
-
|
|
6778
|
-
|
|
6779
|
-
|
|
6780
|
-
|
|
6781
|
-
align = 'start';
|
|
6782
|
-
} else {
|
|
6783
|
-
return;
|
|
6784
|
-
}
|
|
6785
|
-
}
|
|
6825
|
+
this.setOptions(_opts);
|
|
6826
|
+
this.scrollRect = this.options.initialRect;
|
|
6827
|
+
this.scrollOffset = this.options.initialOffset;
|
|
6828
|
+
}
|
|
6786
6829
|
|
|
6787
|
-
var toOffset = align === 'center' ? measurement.start + measurement.size / 2 : align === 'end' ? measurement.end : measurement.start;
|
|
6788
|
-
scrollToOffset(toOffset, _extends$1({
|
|
6789
|
-
align: align
|
|
6790
|
-
}, rest));
|
|
6791
|
-
}, [scrollToOffset, size]);
|
|
6792
|
-
var scrollToIndex = React__default.useCallback(function () {
|
|
6793
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
6794
|
-
args[_key] = arguments[_key];
|
|
6795
|
-
}
|
|
6796
|
-
|
|
6797
|
-
// We do a double request here because of
|
|
6798
|
-
// dynamic sizes which can cause offset shift
|
|
6799
|
-
// and end up in the wrong spot. Unfortunately,
|
|
6800
|
-
// we can't know about those dynamic sizes until
|
|
6801
|
-
// we try and render them. So double down!
|
|
6802
|
-
tryScrollToIndex.apply(void 0, args);
|
|
6803
|
-
requestAnimationFrame(function () {
|
|
6804
|
-
tryScrollToIndex.apply(void 0, args);
|
|
6805
|
-
});
|
|
6806
|
-
}, [tryScrollToIndex]);
|
|
6807
|
-
return {
|
|
6808
|
-
virtualItems: virtualItems,
|
|
6809
|
-
totalSize: totalSize,
|
|
6810
|
-
scrollToOffset: scrollToOffset,
|
|
6811
|
-
scrollToIndex: scrollToIndex,
|
|
6812
|
-
measure: measure
|
|
6813
|
-
};
|
|
6814
6830
|
}
|
|
6815
6831
|
|
|
6816
|
-
|
|
6832
|
+
const findNearestBinarySearch = (low, high, getCurrentValue, value) => {
|
|
6817
6833
|
while (low <= high) {
|
|
6818
|
-
|
|
6819
|
-
|
|
6834
|
+
const middle = (low + high) / 2 | 0;
|
|
6835
|
+
const currentValue = getCurrentValue(middle);
|
|
6820
6836
|
|
|
6821
6837
|
if (currentValue < value) {
|
|
6822
6838
|
low = middle + 1;
|
|
@@ -6834,27 +6850,57 @@ var findNearestBinarySearch = function findNearestBinarySearch(low, high, getCur
|
|
|
6834
6850
|
}
|
|
6835
6851
|
};
|
|
6836
6852
|
|
|
6837
|
-
function calculateRange(
|
|
6838
|
-
|
|
6839
|
-
|
|
6840
|
-
|
|
6841
|
-
|
|
6853
|
+
function calculateRange(_ref2) {
|
|
6854
|
+
let {
|
|
6855
|
+
measurements,
|
|
6856
|
+
outerSize,
|
|
6857
|
+
scrollOffset
|
|
6858
|
+
} = _ref2;
|
|
6859
|
+
const count = measurements.length - 1;
|
|
6842
6860
|
|
|
6843
|
-
|
|
6844
|
-
return measurements[index].start;
|
|
6845
|
-
};
|
|
6861
|
+
const getOffset = index => measurements[index].start;
|
|
6846
6862
|
|
|
6847
|
-
|
|
6848
|
-
|
|
6863
|
+
const startIndex = findNearestBinarySearch(0, count, getOffset, scrollOffset);
|
|
6864
|
+
let endIndex = startIndex;
|
|
6849
6865
|
|
|
6850
|
-
while (
|
|
6851
|
-
|
|
6866
|
+
while (endIndex < count && measurements[endIndex].end < scrollOffset + outerSize) {
|
|
6867
|
+
endIndex++;
|
|
6852
6868
|
}
|
|
6853
6869
|
|
|
6854
6870
|
return {
|
|
6855
|
-
|
|
6856
|
-
|
|
6871
|
+
startIndex,
|
|
6872
|
+
endIndex
|
|
6873
|
+
};
|
|
6874
|
+
}
|
|
6875
|
+
|
|
6876
|
+
const useIsomorphicLayoutEffect$1 = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
|
|
6877
|
+
|
|
6878
|
+
function useVirtualizerBase(options) {
|
|
6879
|
+
const rerender = React.useReducer(() => ({}), {})[1];
|
|
6880
|
+
const resolvedOptions = { ...options,
|
|
6881
|
+
onChange: instance => {
|
|
6882
|
+
rerender();
|
|
6883
|
+
options.onChange == null ? void 0 : options.onChange(instance);
|
|
6884
|
+
}
|
|
6857
6885
|
};
|
|
6886
|
+
const [instance] = React.useState(() => new Virtualizer(resolvedOptions));
|
|
6887
|
+
instance.setOptions(resolvedOptions);
|
|
6888
|
+
React.useEffect(() => {
|
|
6889
|
+
return instance._didMount();
|
|
6890
|
+
}, []);
|
|
6891
|
+
useIsomorphicLayoutEffect$1(() => {
|
|
6892
|
+
return instance._willUpdate();
|
|
6893
|
+
});
|
|
6894
|
+
return instance;
|
|
6895
|
+
}
|
|
6896
|
+
|
|
6897
|
+
function useVirtualizer(options) {
|
|
6898
|
+
return useVirtualizerBase({
|
|
6899
|
+
observeElementRect: observeElementRect,
|
|
6900
|
+
observeElementOffset: observeElementOffset,
|
|
6901
|
+
scrollToFn: elementScroll,
|
|
6902
|
+
...options
|
|
6903
|
+
});
|
|
6858
6904
|
}
|
|
6859
6905
|
|
|
6860
6906
|
var MRT_EditCellTextField = function MRT_EditCellTextField(_ref) {
|
|
@@ -7262,14 +7308,25 @@ var MRT_TableBody = function MRT_TableBody(_ref) {
|
|
|
7262
7308
|
|
|
7263
7309
|
return enablePagination ? getRowModel().rows : getPrePaginationRowModel().rows;
|
|
7264
7310
|
}, [enableGlobalFilterRankedResults, enableGlobalFilterRankedResults && globalFilter || !enablePagination ? getPrePaginationRowModel().rows : getRowModel().rows, globalFilter]);
|
|
7265
|
-
var rowVirtualizer = enableRowVirtualization ?
|
|
7266
|
-
|
|
7267
|
-
|
|
7268
|
-
|
|
7311
|
+
var rowVirtualizer = enableRowVirtualization ? useVirtualizer(_extends({
|
|
7312
|
+
count: rows.length,
|
|
7313
|
+
estimateSize: function estimateSize() {
|
|
7314
|
+
return density === 'compact' ? 25 : 50;
|
|
7315
|
+
},
|
|
7316
|
+
getScrollElement: function getScrollElement() {
|
|
7317
|
+
return tableContainerRef.current;
|
|
7318
|
+
},
|
|
7319
|
+
overscan: density === 'compact' ? 30 : 10
|
|
7269
7320
|
}, virtualizerProps)) : {};
|
|
7270
|
-
var virtualRows = rowVirtualizer.
|
|
7271
|
-
var paddingTop =
|
|
7272
|
-
var paddingBottom =
|
|
7321
|
+
var virtualRows = enableRowVirtualization ? rowVirtualizer.getVirtualItems() : [];
|
|
7322
|
+
var paddingTop = 0;
|
|
7323
|
+
var paddingBottom = 0;
|
|
7324
|
+
|
|
7325
|
+
if (enableRowVirtualization) {
|
|
7326
|
+
paddingTop = virtualRows.length > 0 ? virtualRows[0].start : 0;
|
|
7327
|
+
paddingBottom = virtualRows.length > 0 ? rowVirtualizer.getTotalSize() - virtualRows[virtualRows.length - 1].end : 0;
|
|
7328
|
+
}
|
|
7329
|
+
|
|
7273
7330
|
return React__default.createElement(material.TableBody, Object.assign({}, tableBodyProps), enableRowVirtualization && paddingTop > 0 && React__default.createElement("tr", null, React__default.createElement("td", {
|
|
7274
7331
|
style: {
|
|
7275
7332
|
height: paddingTop + "px"
|