virtual-scroller 1.7.6 → 1.8.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/CHANGELOG.md +29 -1
- package/README.md +139 -33
- package/babel.config.js +25 -0
- package/babel.js +5 -0
- package/bundle/index-bypass.html +1 -1
- package/bundle/index-dom.html +1 -1
- package/bundle/index-grid.html +1 -2
- package/bundle/index-scrollableContainer.html +1 -1
- package/bundle/index-tbody-scrollableContainer.html +2 -0
- package/bundle/index-tbody.html +2 -0
- package/bundle/virtual-scroller-dom.js +1 -1
- package/bundle/virtual-scroller-dom.js.map +1 -1
- package/bundle/virtual-scroller-react.js +1 -1
- package/bundle/virtual-scroller-react.js.map +1 -1
- package/bundle/virtual-scroller.js +1 -1
- package/bundle/virtual-scroller.js.map +1 -1
- package/commonjs/BeforeResize.js +319 -0
- package/commonjs/BeforeResize.js.map +1 -0
- package/commonjs/DOM/Engine.js +46 -0
- package/commonjs/DOM/Engine.js.map +1 -0
- package/commonjs/DOM/ItemsContainer.js +78 -0
- package/commonjs/DOM/ItemsContainer.js.map +1 -0
- package/commonjs/DOM/{WaitForStylesToLoad.js → ListTopOffsetWatcher.js} +56 -35
- package/commonjs/DOM/ListTopOffsetWatcher.js.map +1 -0
- package/commonjs/DOM/ScrollableContainer.js +56 -81
- package/commonjs/DOM/ScrollableContainer.js.map +1 -1
- package/commonjs/DOM/VirtualScroller.js +20 -15
- package/commonjs/DOM/VirtualScroller.js.map +1 -1
- package/commonjs/DOM/tbody.js +2 -2
- package/commonjs/ItemHeights.js +13 -20
- package/commonjs/ItemHeights.js.map +1 -1
- package/commonjs/Layout.js +588 -215
- package/commonjs/Layout.js.map +1 -1
- package/commonjs/Layout.test.js +191 -0
- package/commonjs/Layout.test.js.map +1 -0
- package/commonjs/ListHeightChangeWatcher.js +126 -0
- package/commonjs/ListHeightChangeWatcher.js.map +1 -0
- package/commonjs/Resize.js +22 -21
- package/commonjs/Resize.js.map +1 -1
- package/commonjs/Scroll.js +148 -88
- package/commonjs/Scroll.js.map +1 -1
- package/commonjs/VirtualScroller.js +1269 -390
- package/commonjs/VirtualScroller.js.map +1 -1
- package/commonjs/getItemCoordinates.js.map +1 -1
- package/commonjs/getItemsDiff.js.map +1 -1
- package/commonjs/getVerticalSpacing.js +8 -8
- package/commonjs/getVerticalSpacing.js.map +1 -1
- package/commonjs/react/VirtualScroller.js +31 -37
- package/commonjs/react/VirtualScroller.js.map +1 -1
- package/commonjs/utility/debounce.js +26 -4
- package/commonjs/utility/debounce.js.map +1 -1
- package/commonjs/utility/debug.js +51 -12
- package/commonjs/utility/debug.js.map +1 -1
- package/commonjs/utility/getStateSnapshot.js +50 -0
- package/commonjs/utility/getStateSnapshot.js.map +1 -0
- package/commonjs/utility/px.js +1 -1
- package/commonjs/utility/px.js.map +1 -1
- package/commonjs/utility/px.test.js +14 -0
- package/commonjs/utility/px.test.js.map +1 -0
- package/commonjs/utility/shallowEqual.js +1 -1
- package/commonjs/utility/shallowEqual.js.map +1 -1
- package/commonjs/utility/throttle.js.map +1 -1
- package/dom/index.d.ts +23 -0
- package/index.d.ts +84 -0
- package/modules/BeforeResize.js +310 -0
- package/modules/BeforeResize.js.map +1 -0
- package/modules/DOM/Engine.js +27 -0
- package/modules/DOM/Engine.js.map +1 -0
- package/modules/DOM/ItemsContainer.js +71 -0
- package/modules/DOM/ItemsContainer.js.map +1 -0
- package/modules/DOM/{WaitForStylesToLoad.js → ListTopOffsetWatcher.js} +57 -35
- package/modules/DOM/ListTopOffsetWatcher.js.map +1 -0
- package/modules/DOM/ScrollableContainer.js +55 -80
- package/modules/DOM/ScrollableContainer.js.map +1 -1
- package/modules/DOM/VirtualScroller.js +15 -14
- package/modules/DOM/VirtualScroller.js.map +1 -1
- package/modules/ItemHeights.js +8 -19
- package/modules/ItemHeights.js.map +1 -1
- package/modules/Layout.js +582 -213
- package/modules/Layout.js.map +1 -1
- package/modules/Layout.test.js +185 -0
- package/modules/Layout.test.js.map +1 -0
- package/modules/ListHeightChangeWatcher.js +119 -0
- package/modules/ListHeightChangeWatcher.js.map +1 -0
- package/modules/Resize.js +21 -20
- package/modules/Resize.js.map +1 -1
- package/modules/Scroll.js +148 -87
- package/modules/Scroll.js.map +1 -1
- package/modules/VirtualScroller.js +1263 -390
- package/modules/VirtualScroller.js.map +1 -1
- package/modules/getItemCoordinates.js.map +1 -1
- package/modules/getItemsDiff.js.map +1 -1
- package/modules/getVerticalSpacing.js +8 -8
- package/modules/getVerticalSpacing.js.map +1 -1
- package/modules/react/VirtualScroller.js +31 -37
- package/modules/react/VirtualScroller.js.map +1 -1
- package/modules/utility/debounce.js +26 -4
- package/modules/utility/debounce.js.map +1 -1
- package/modules/utility/debug.js +47 -10
- package/modules/utility/debug.js.map +1 -1
- package/modules/utility/getStateSnapshot.js +43 -0
- package/modules/utility/getStateSnapshot.js.map +1 -0
- package/modules/utility/px.js +1 -1
- package/modules/utility/px.js.map +1 -1
- package/modules/utility/px.test.js +9 -0
- package/modules/utility/px.test.js.map +1 -0
- package/modules/utility/shallowEqual.js +1 -1
- package/modules/utility/shallowEqual.js.map +1 -1
- package/modules/utility/throttle.js.map +1 -1
- package/package.json +24 -22
- package/react/index.d.ts +27 -0
- package/source/BeforeResize.js +317 -0
- package/source/DOM/Engine.js +32 -0
- package/source/DOM/ItemsContainer.js +48 -0
- package/source/DOM/{WaitForStylesToLoad.js → ListTopOffsetWatcher.js} +48 -22
- package/source/DOM/ScrollableContainer.js +39 -56
- package/source/DOM/VirtualScroller.js +6 -7
- package/source/ItemHeights.js +10 -15
- package/source/Layout.js +626 -252
- package/source/Layout.test.js +171 -0
- package/source/ListHeightChangeWatcher.js +94 -0
- package/source/Resize.js +23 -15
- package/source/Scroll.js +139 -78
- package/source/VirtualScroller.js +1240 -286
- package/source/getVerticalSpacing.js +7 -7
- package/source/react/VirtualScroller.js +2 -18
- package/source/utility/debounce.js +20 -3
- package/source/utility/debug.js +34 -3
- package/source/utility/getStateSnapshot.js +36 -0
- package/source/utility/px.js +1 -1
- package/source/utility/px.test.js +9 -0
- package/website/index-bypass.html +195 -0
- package/website/index-grid.html +0 -1
- package/website/index-scrollableContainer.html +208 -0
- package/website/index-tbody-scrollableContainer.html +68 -0
- package/website/index-tbody.html +55 -0
- package/commonjs/DOM/RenderingEngine.js +0 -33
- package/commonjs/DOM/RenderingEngine.js.map +0 -1
- package/commonjs/DOM/Screen.js +0 -87
- package/commonjs/DOM/Screen.js.map +0 -1
- package/commonjs/DOM/WaitForStylesToLoad.js.map +0 -1
- package/commonjs/RestoreScroll.js +0 -118
- package/commonjs/RestoreScroll.js.map +0 -1
- package/modules/DOM/RenderingEngine.js +0 -19
- package/modules/DOM/RenderingEngine.js.map +0 -1
- package/modules/DOM/Screen.js +0 -80
- package/modules/DOM/Screen.js.map +0 -1
- package/modules/DOM/WaitForStylesToLoad.js.map +0 -1
- package/modules/RestoreScroll.js +0 -111
- package/modules/RestoreScroll.js.map +0 -1
- package/source/DOM/RenderingEngine.js +0 -22
- package/source/DOM/Screen.js +0 -51
- package/source/RestoreScroll.js +0 -86
|
@@ -15,6 +15,8 @@ var _debug = require("../utility/debug");
|
|
|
15
15
|
|
|
16
16
|
var _px = _interopRequireDefault(require("../utility/px"));
|
|
17
17
|
|
|
18
|
+
var _excluded = ["as", "itemComponent", "itemComponentProps", "items", "estimatedItemHeight", "bypass", "preserveScrollPositionOnPrependItems", "preserveScrollPosition", "initialScrollPosition", "onScrollPositionChange", "measureItemsBatchSize", "scrollableContainer", "getScrollableContainer", "getColumnsCount", "initialState", "initialCustomState", "onStateChange", "onItemInitialRender", "onItemFirstRender", "getItemId", "onMount", "className"];
|
|
19
|
+
|
|
18
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
21
|
|
|
20
22
|
function _extends() { _extends = Object.assign || 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); }
|
|
@@ -23,7 +25,7 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
23
25
|
|
|
24
26
|
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; }
|
|
25
27
|
|
|
26
|
-
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
28
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
27
29
|
|
|
28
30
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
29
31
|
|
|
@@ -31,15 +33,19 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|
|
31
33
|
|
|
32
34
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
33
35
|
|
|
34
|
-
function
|
|
36
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
35
37
|
|
|
36
|
-
function
|
|
38
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
39
|
+
|
|
40
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
41
|
+
|
|
42
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
37
43
|
|
|
38
44
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
39
45
|
|
|
40
|
-
function
|
|
46
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
41
47
|
|
|
42
|
-
function
|
|
48
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
43
49
|
|
|
44
50
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
45
51
|
|
|
@@ -47,11 +53,19 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
47
53
|
// https://github.com/facebook/prop-types/issues/200
|
|
48
54
|
var elementType = _propTypes["default"].elementType || _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].func, _propTypes["default"].object]);
|
|
49
55
|
|
|
50
|
-
var VirtualScroller =
|
|
51
|
-
/*#__PURE__*/
|
|
52
|
-
function (_React$Component) {
|
|
56
|
+
var VirtualScroller = /*#__PURE__*/function (_React$Component) {
|
|
53
57
|
_inherits(VirtualScroller, _React$Component);
|
|
54
58
|
|
|
59
|
+
var _super = _createSuper(VirtualScroller);
|
|
60
|
+
|
|
61
|
+
// `this.state` is already reserved for `virtual-scroller`.
|
|
62
|
+
// static getDerivedStateFromProps(props, state) {
|
|
63
|
+
// return {
|
|
64
|
+
// prevProps: {
|
|
65
|
+
// items: props.items
|
|
66
|
+
// }
|
|
67
|
+
// }
|
|
68
|
+
// }
|
|
55
69
|
// Handler function caches.
|
|
56
70
|
// Just so that the props passed to `itemComponent`
|
|
57
71
|
// are not changed on every `.render()` and so
|
|
@@ -65,10 +79,10 @@ function (_React$Component) {
|
|
|
65
79
|
|
|
66
80
|
_classCallCheck(this, VirtualScroller);
|
|
67
81
|
|
|
68
|
-
_this =
|
|
82
|
+
_this = _super.call(this, props); // `this.previousItemsProperty` is only used for comparing
|
|
69
83
|
// `previousItems` with `newItems` inside `render()`.
|
|
70
84
|
|
|
71
|
-
_defineProperty(_assertThisInitialized(_this), "container", _react["default"].createRef());
|
|
85
|
+
_defineProperty(_assertThisInitialized(_this), "container", /*#__PURE__*/_react["default"].createRef());
|
|
72
86
|
|
|
73
87
|
_defineProperty(_assertThisInitialized(_this), "onItemStateChange", new Array(_this.props.items.length));
|
|
74
88
|
|
|
@@ -124,8 +138,6 @@ function (_React$Component) {
|
|
|
124
138
|
initialCustomState = _this$props.initialCustomState,
|
|
125
139
|
onStateChange = _this$props.onStateChange,
|
|
126
140
|
estimatedItemHeight = _this$props.estimatedItemHeight,
|
|
127
|
-
preserveScrollPositionOfTheBottomOfTheListOnMount = _this$props.preserveScrollPositionOfTheBottomOfTheListOnMount,
|
|
128
|
-
preserveScrollPositionAtBottomOnMount = _this$props.preserveScrollPositionAtBottomOnMount,
|
|
129
141
|
initialScrollPosition = _this$props.initialScrollPosition,
|
|
130
142
|
onScrollPositionChange = _this$props.onScrollPositionChange,
|
|
131
143
|
measureItemsBatchSize = _this$props.measureItemsBatchSize,
|
|
@@ -145,10 +157,6 @@ function (_React$Component) {
|
|
|
145
157
|
onItemInitialRender: this.onItemInitialRender,
|
|
146
158
|
// `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.
|
|
147
159
|
onItemFirstRender: this.onItemFirstRender,
|
|
148
|
-
preserveScrollPositionOfTheBottomOfTheListOnMount: preserveScrollPositionOfTheBottomOfTheListOnMount,
|
|
149
|
-
// `preserveScrollPositionAtBottomOnMount` property name is deprecated,
|
|
150
|
-
// use `preserveScrollPositionOfTheBottomOfTheListOnMount` property instead.
|
|
151
|
-
preserveScrollPositionAtBottomOnMount: preserveScrollPositionAtBottomOnMount,
|
|
152
160
|
initialScrollPosition: initialScrollPosition,
|
|
153
161
|
onScrollPositionChange: onScrollPositionChange,
|
|
154
162
|
shouldUpdateLayoutOnScreenResize: this.shouldUpdateLayoutOnScreenResize,
|
|
@@ -359,7 +367,7 @@ function (_React$Component) {
|
|
|
359
367
|
key: "getItemRef",
|
|
360
368
|
value: function getItemRef(i) {
|
|
361
369
|
if (!this.itemRefs[i]) {
|
|
362
|
-
this.itemRefs[i] = _react["default"].createRef();
|
|
370
|
+
this.itemRefs[i] = /*#__PURE__*/_react["default"].createRef();
|
|
363
371
|
}
|
|
364
372
|
|
|
365
373
|
return this.itemRefs[i];
|
|
@@ -475,8 +483,6 @@ function (_React$Component) {
|
|
|
475
483
|
bypass = _this$props4.bypass,
|
|
476
484
|
preserveScrollPositionOnPrependItems = _this$props4.preserveScrollPositionOnPrependItems,
|
|
477
485
|
preserveScrollPosition = _this$props4.preserveScrollPosition,
|
|
478
|
-
preserveScrollPositionOfTheBottomOfTheListOnMount = _this$props4.preserveScrollPositionOfTheBottomOfTheListOnMount,
|
|
479
|
-
preserveScrollPositionAtBottomOnMount = _this$props4.preserveScrollPositionAtBottomOnMount,
|
|
480
486
|
initialScrollPosition = _this$props4.initialScrollPosition,
|
|
481
487
|
onScrollPositionChange = _this$props4.onScrollPositionChange,
|
|
482
488
|
measureItemsBatchSize = _this$props4.measureItemsBatchSize,
|
|
@@ -491,7 +497,7 @@ function (_React$Component) {
|
|
|
491
497
|
getItemId = _this$props4.getItemId,
|
|
492
498
|
onMount = _this$props4.onMount,
|
|
493
499
|
className = _this$props4.className,
|
|
494
|
-
rest = _objectWithoutProperties(_this$props4,
|
|
500
|
+
rest = _objectWithoutProperties(_this$props4, _excluded);
|
|
495
501
|
|
|
496
502
|
var _this$virtualScroller = this.virtualScroller.getState(),
|
|
497
503
|
items = _this$virtualScroller.items,
|
|
@@ -581,7 +587,7 @@ function (_React$Component) {
|
|
|
581
587
|
if (prependedItemsCount > 0) {
|
|
582
588
|
if (preserveScrollPositionOnPrependItems || preserveScrollPosition) {
|
|
583
589
|
if (firstShownItemIndex === 0) {
|
|
584
|
-
this.virtualScroller.
|
|
590
|
+
this.virtualScroller.listHeightChangeWatcher.snapshot({
|
|
585
591
|
previousItems: previousItems,
|
|
586
592
|
newItems: newItems,
|
|
587
593
|
prependedItemsCount: prependedItemsCount
|
|
@@ -602,7 +608,7 @@ function (_React$Component) {
|
|
|
602
608
|
}
|
|
603
609
|
|
|
604
610
|
var tbody = this.virtualScroller.tbody;
|
|
605
|
-
return _react["default"].createElement(AsComponent, _extends({}, rest, {
|
|
611
|
+
return /*#__PURE__*/_react["default"].createElement(AsComponent, _extends({}, rest, {
|
|
606
612
|
ref: this.container,
|
|
607
613
|
className: tbody ? className ? className + ' ' + 'VirtualScroller' : 'VirtualScroller' : className,
|
|
608
614
|
style: {
|
|
@@ -611,7 +617,7 @@ function (_React$Component) {
|
|
|
611
617
|
}
|
|
612
618
|
}), items.map(function (item, i) {
|
|
613
619
|
if (i >= firstShownItemIndex && i <= lastShownItemIndex) {
|
|
614
|
-
return _react["default"].createElement(Component, _extends({}, itemComponentProps, {
|
|
620
|
+
return /*#__PURE__*/_react["default"].createElement(Component, _extends({}, itemComponentProps, {
|
|
615
621
|
key: _this6.getItemKey(item, i),
|
|
616
622
|
ref: _this6.shouldUseRefs() ? _this6.getItemRef(i) : undefined,
|
|
617
623
|
state: itemStates && itemStates[i],
|
|
@@ -639,7 +645,7 @@ exports["default"] = VirtualScroller;
|
|
|
639
645
|
|
|
640
646
|
_defineProperty(VirtualScroller, "propTypes", {
|
|
641
647
|
as: elementType,
|
|
642
|
-
items: _propTypes["default"].arrayOf(_propTypes["default"].
|
|
648
|
+
items: _propTypes["default"].arrayOf(_propTypes["default"].any).isRequired,
|
|
643
649
|
itemComponent: elementType.isRequired,
|
|
644
650
|
itemComponentProps: _propTypes["default"].object,
|
|
645
651
|
estimatedItemHeight: _propTypes["default"].number,
|
|
@@ -649,10 +655,6 @@ _defineProperty(VirtualScroller, "propTypes", {
|
|
|
649
655
|
// `preserveScrollPosition` property name is deprecated,
|
|
650
656
|
// use `preserveScrollPositionOnPrependItems` instead.
|
|
651
657
|
preserveScrollPosition: _propTypes["default"].bool,
|
|
652
|
-
preserveScrollPositionOfTheBottomOfTheListOnMount: _propTypes["default"].bool,
|
|
653
|
-
// `preserveScrollPositionAtBottomOnMount` property name is deprecated,
|
|
654
|
-
// use `preserveScrollPositionOfTheBottomOfTheListOnMount` property instead.
|
|
655
|
-
preserveScrollPositionAtBottomOnMount: _propTypes["default"].bool,
|
|
656
658
|
measureItemsBatchSize: _propTypes["default"].number,
|
|
657
659
|
scrollableContainer: _propTypes["default"].any,
|
|
658
660
|
// `getScrollableContainer` property is deprecated.
|
|
@@ -683,15 +685,7 @@ _defineProperty(VirtualScroller, "propTypes", {
|
|
|
683
685
|
});
|
|
684
686
|
|
|
685
687
|
_defineProperty(VirtualScroller, "defaultProps", {
|
|
686
|
-
as: 'div'
|
|
687
|
-
// static getDerivedStateFromProps(props, state) {
|
|
688
|
-
// return {
|
|
689
|
-
// prevProps: {
|
|
690
|
-
// items: props.items
|
|
691
|
-
// }
|
|
692
|
-
// }
|
|
693
|
-
// }
|
|
694
|
-
|
|
688
|
+
as: 'div'
|
|
695
689
|
});
|
|
696
690
|
|
|
697
691
|
function isComponentClass(Component) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../source/react/VirtualScroller.js"],"names":["elementType","PropTypes","oneOfType","string","func","object","VirtualScroller","props","React","createRef","Array","items","length","virtualScroller","updateLayout","onItemInitialRender","onItemFirstRender","previousItemsProperty","generateItemKeyPrefix","createVirtualScroller","AsComponent","as","initialState","initialCustomState","onStateChange","estimatedItemHeight","preserveScrollPositionOfTheBottomOfTheListOnMount","preserveScrollPositionAtBottomOnMount","initialScrollPosition","onScrollPositionChange","measureItemsBatchSize","scrollableContainer","getScrollableContainer","getColumnsCount","getItemId","bypass","VirtualScrollerCore","container","current","_useTimeoutInRenderLoop","shouldUpdateLayoutOnScreenResize","tbody","state","customState","getState","setState","newState","willUpdateState","didUpdateState","itemComponent","isComponentClass","item","i","itemKeyPrefix","renderItem","getItemIndex","undefined","JSON","stringify","shouldUseRefs","itemRefs","forceUpdate","_isMounted","indexOf","onItemHeightChange","onItemStateChange","itemState","prefix","String","Math","random","slice","itemKeyPrefixes","push","onMount","listen","prevProps","prevState","preserveScrollPosition","preserveScrollPositionOnPrependItems","setItems","stop","Component","itemComponentProps","_items","className","rest","itemStates","firstShownItemIndex","lastShownItemIndex","beforeItemsHeight","afterItemsHeight","newItems","previousItems","itemsPropertyWasChanged","itemsDiff","getItemsDiff","prependedItemsCount","appendedItemsCount","restoreScroll","captureScroll","paddingTop","paddingBottom","map","getItemKey","getItemRef","getOnItemStateChange","getOnItemHeightChange","arrayOf","isRequired","number","bool","any","shape","itemHeights","columnsCount","verticalSpacing","prototype","isReactComponent"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AAEA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;AACA;AACA,IAAMA,WAAW,GAAGC,sBAAUD,W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ACA","sourcesContent":["import React from 'react'\r\nimport PropTypes from 'prop-types'\r\n\r\nimport VirtualScrollerCore from '../VirtualScroller'\r\n\r\nimport { reportError } from '../utility/debug'\r\nimport px from '../utility/px'\r\n\r\n// `PropTypes.elementType` is available in some version of `prop-types`.\r\n// https://github.com/facebook/prop-types/issues/200\r\nconst elementType = PropTypes.elementType || PropTypes.oneOfType([\r\n\tPropTypes.string,\r\n\tPropTypes.func,\r\n\tPropTypes.object\r\n])\r\n\r\nexport default class VirtualScroller extends React.Component {\r\n\tstatic propTypes = {\r\n\t\tas: elementType,\r\n\t\titems: PropTypes.arrayOf(PropTypes.object).isRequired,\r\n\t\titemComponent: elementType.isRequired,\r\n\t\titemComponentProps: PropTypes.object,\r\n\t\testimatedItemHeight: PropTypes.number,\r\n\t\tbypass: PropTypes.bool,\r\n\t\t// bypassBatchSize: PropTypes.number,\r\n\t\tpreserveScrollPositionOnPrependItems: PropTypes.bool,\r\n\t\t// `preserveScrollPosition` property name is deprecated,\r\n\t\t// use `preserveScrollPositionOnPrependItems` instead.\r\n\t\tpreserveScrollPosition: PropTypes.bool,\r\n\t\tpreserveScrollPositionOfTheBottomOfTheListOnMount: PropTypes.bool,\r\n\t\t// `preserveScrollPositionAtBottomOnMount` property name is deprecated,\r\n\t\t// use `preserveScrollPositionOfTheBottomOfTheListOnMount` property instead.\r\n\t\tpreserveScrollPositionAtBottomOnMount: PropTypes.bool,\r\n\t\tmeasureItemsBatchSize: PropTypes.number,\r\n\t\tscrollableContainer: PropTypes.any,\r\n\t\t// `getScrollableContainer` property is deprecated.\r\n\t\t// Use `scrollableContainer` instead.\r\n\t\tgetScrollableContainer: PropTypes.func,\r\n\t\tgetColumnsCount: PropTypes.func,\r\n\t\tgetItemId: PropTypes.func,\r\n\t\tclassName: PropTypes.string,\r\n\t\tonMount: PropTypes.func,\r\n\t\tonItemInitialRender: PropTypes.func,\r\n\t\t// `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.\r\n\t\tonItemFirstRender: PropTypes.func,\r\n\t\tinitialScrollPosition: PropTypes.number,\r\n\t\tonScrollPositionChange: PropTypes.func,\r\n\t\tonStateChange: PropTypes.func,\r\n\t\tinitialCustomState: PropTypes.object,\r\n\t\tinitialState: PropTypes.shape({\r\n\t\t\titems: PropTypes.arrayOf(PropTypes.object).isRequired,\r\n\t\t\titemStates: PropTypes.arrayOf(PropTypes.any),\r\n\t\t\tfirstShownItemIndex: PropTypes.number.isRequired,\r\n\t\t\tlastShownItemIndex: PropTypes.number.isRequired,\r\n\t\t\tbeforeItemsHeight: PropTypes.number.isRequired,\r\n\t\t\tafterItemsHeight: PropTypes.number.isRequired,\r\n\t\t\titemHeights: PropTypes.arrayOf(PropTypes.number).isRequired,\r\n\t\t\tcolumnsCount: PropTypes.number,\r\n\t\t\tverticalSpacing: PropTypes.number\r\n\t\t})\r\n\t}\r\n\r\n\tstatic defaultProps = {\r\n\t\tas: 'div'\r\n\t}\r\n\r\n\t// `this.state` is already reserved for `virtual-scroller`.\r\n\t// static getDerivedStateFromProps(props, state) {\r\n\t// \treturn {\r\n\t// \t\tprevProps: {\r\n\t// \t\t\titems: props.items\r\n\t// \t\t}\r\n\t// \t}\r\n\t// }\r\n\r\n\tcontainer = React.createRef()\r\n\r\n\t// Handler function caches.\r\n\t// Just so that the props passed to `itemComponent`\r\n\t// are not changed on every `.render()` and so\r\n\t// `itemComponent` won't re-render if it's a `PureComponent`.\r\n\tonItemStateChange = new Array(this.props.items.length)\r\n\tonItemHeightChange = new Array(this.props.items.length)\r\n\r\n\t// Item refs for `.renderItem(i)`.\r\n\titemRefs = new Array(this.props.items.length)\r\n\r\n\t// List items are rendered with `key`s\r\n\t// so that React doesn't reuse `itemComponent`s\r\n\t// in cases when `items` are changed.\r\n\titemKeyPrefixes = []\r\n\r\n\tconstructor(props) {\r\n\t\tsuper(props)\r\n\t\t// `this.previousItemsProperty` is only used for comparing\r\n\t\t// `previousItems` with `newItems` inside `render()`.\r\n\t\tthis.previousItemsProperty = props.items\r\n\t\t// Generate unique `key` prefix for list item components.\r\n\t\tthis.generateItemKeyPrefix()\r\n\t\t// Create `VirtualScroller` instance.\r\n\t\tthis.createVirtualScroller()\r\n\t}\r\n\r\n\tcreateVirtualScroller() {\r\n\t\tconst {\r\n\t\t\tas: AsComponent,\r\n\t\t\titems,\r\n\t\t\tinitialState,\r\n\t\t\tinitialCustomState,\r\n\t\t\tonStateChange,\r\n\t\t\testimatedItemHeight,\r\n\t\t\tpreserveScrollPositionOfTheBottomOfTheListOnMount,\r\n\t\t\t// `preserveScrollPositionAtBottomOnMount` property name is deprecated,\r\n\t\t\t// use `preserveScrollPositionOfTheBottomOfTheListOnMount` property instead.\r\n\t\t\tpreserveScrollPositionAtBottomOnMount,\r\n\t\t\tinitialScrollPosition,\r\n\t\t\tonScrollPositionChange,\r\n\t\t\tmeasureItemsBatchSize,\r\n\t\t\tscrollableContainer,\r\n\t\t\t// `getScrollableContainer` property is deprecated.\r\n\t\t\t// Use `scrollableContainer` instead.\r\n\t\t\tgetScrollableContainer,\r\n\t\t\tgetColumnsCount,\r\n\t\t\tgetItemId,\r\n\t\t\tbypass,\r\n\t\t\t// bypassBatchSize\r\n\t\t} = this.props\r\n\t\t// Create `virtual-scroller` instance.\r\n\t\tthis.virtualScroller = new VirtualScrollerCore(\r\n\t\t\t() => this.container.current,\r\n\t\t\titems,\r\n\t\t\t{\r\n\t\t\t\t_useTimeoutInRenderLoop: true,\r\n\t\t\t\testimatedItemHeight,\r\n\t\t\t\tbypass,\r\n\t\t\t\t// bypassBatchSize,\r\n\t\t\t\tonItemInitialRender: this.onItemInitialRender,\r\n\t\t\t\t// `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.\r\n\t\t\t\tonItemFirstRender: this.onItemFirstRender,\r\n\t\t\t\tpreserveScrollPositionOfTheBottomOfTheListOnMount,\r\n\t\t\t\t// `preserveScrollPositionAtBottomOnMount` property name is deprecated,\r\n\t\t\t\t// use `preserveScrollPositionOfTheBottomOfTheListOnMount` property instead.\r\n\t\t\t\tpreserveScrollPositionAtBottomOnMount,\r\n\t\t\t\tinitialScrollPosition,\r\n\t\t\t\tonScrollPositionChange,\r\n\t\t\t\tshouldUpdateLayoutOnScreenResize: this.shouldUpdateLayoutOnScreenResize,\r\n\t\t\t\tmeasureItemsBatchSize,\r\n\t\t\t\tscrollableContainer,\r\n\t\t\t\t// `getScrollableContainer` property is deprecated.\r\n\t\t\t\t// Use `scrollableContainer` instead.\r\n\t\t\t\tgetScrollableContainer,\r\n\t\t\t\tgetColumnsCount,\r\n\t\t\t\tgetItemId,\r\n\t\t\t\ttbody: AsComponent === 'tbody',\r\n\t\t\t\tstate: initialState,\r\n\t\t\t\tcustomState: initialCustomState,\r\n\t\t\t\tonStateChange,\r\n\t\t\t\tgetState: () => this.state,\r\n\t\t\t\tsetState: (newState, { willUpdateState, didUpdateState }) => {\r\n\t\t\t\t\tthis.willUpdateState = willUpdateState\r\n\t\t\t\t\tthis.didUpdateState = didUpdateState\r\n\t\t\t\t\tif (this.state) {\r\n\t\t\t\t\t\t// Update existing state.\r\n\t\t\t\t\t\t//\r\n\t\t\t\t\t\t// In case of hypothetically rewriting this in React hooks,\r\n\t\t\t\t\t\t// it wouldn't simply be `setState({ ...prevState, ...newState })`.\r\n\t\t\t\t\t\t// The reason is that `setState()` would be \"asynchronous\" (not immediate),\r\n\t\t\t\t\t\t// and `...prevState` would be stale in cases when more than a single\r\n\t\t\t\t\t\t// `setState()` call is made before the state actually updates,\r\n\t\t\t\t\t\t// making `prevState` stale, and, as a consequence, losing some\r\n\t\t\t\t\t\t// of the state updates.\r\n\t\t\t\t\t\t// For example, the first `setState()` call updates shown item indexes,\r\n\t\t\t\t\t\t// and the second `setState()` call updates `verticalSpacing`:\r\n\t\t\t\t\t\t// if it was simply `setState({ ...prevState, ...newState })`,\r\n\t\t\t\t\t\t// then the second state update could overwrite the first state update,\r\n\t\t\t\t\t\t// resulting in incorrect items being shown/hidden.\r\n\t\t\t\t\t\t//\r\n\t\t\t\t\t\t// I guess, in hooks, it could be something like:\r\n\t\t\t\t\t\t//\r\n\t\t\t\t\t\t// const [firstShownItemIndex, setFirstShownItemIndex] = useState()\r\n\t\t\t\t\t\t// ...\r\n\t\t\t\t\t\t// const setState = useCallback((newState) => {\r\n\t\t\t\t\t\t// \tfor (const key in newState) {\r\n\t\t\t\t\t\t// \t\tswitch (key) {\r\n\t\t\t\t\t\t// \t\t\tcase 'firstShownItemIndex':\r\n\t\t\t\t\t\t// \t\t\t\tsetFirstShownItemIndex(newState[key])\r\n\t\t\t\t\t\t// \t\t\t\tbreak\r\n\t\t\t\t\t\t// \t\t\t...\r\n\t\t\t\t\t\t// \t\t}\r\n\t\t\t\t\t\t// \t}\r\n\t\t\t\t\t\t// \tsetFirstShownItemIndex\r\n\t\t\t\t\t\t// }, [])\r\n\t\t\t\t\t\t// const virtualScroller = new VirtualScrollerCore({\r\n\t\t\t\t\t\t// \tsetState,\r\n\t\t\t\t\t\t// \t...\r\n\t\t\t\t\t\t// })\r\n\t\t\t\t\t\t// // `getState()` function would be updated on every render.\r\n\t\t\t\t\t\t// virtualScroller.getState = () => ({\r\n\t\t\t\t\t\t// \tfirstShownItemIndex,\r\n\t\t\t\t\t\t// \t...\r\n\t\t\t\t\t\t// })\r\n\t\t\t\t\t\t//\r\n\t\t\t\t\t\t// But as long as it uses the classic `this.setState()`,\r\n\t\t\t\t\t\t// it's fine and simple.\r\n\t\t\t\t\t\tthis.setState(newState)\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\t// Set initial state.\r\n\t\t\t\t\t\twillUpdateState(newState)\r\n\t\t\t\t\t\tthis.state = newState\r\n\t\t\t\t\t\tdidUpdateState()\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t)\r\n\t}\r\n\r\n\t// This is a proxy for `VirtualScroller`'s `.updateLayout` instance method.\r\n\tupdateLayout = () => this.virtualScroller.updateLayout()\r\n\r\n\t// `.layout()` method name is deprecated, use `.updateLayout()` instead.\r\n\tlayout = () => this.updateLayout()\r\n\r\n\t// This proxy is required for cases when\r\n\t// `onItemInitialRender` property changes at subsequent renders.\r\n\t// For example, if it's passed as an \"anonymous\" function:\r\n\t// `<VirtualScroller onItemInitialRender={() => ...}/>`.\r\n\t// In such cases, if this \"proxy\" workaround hasn't been implemented,\r\n\t// the `VirtualScroller` instance would have the reference to the old function.\r\n\tonItemInitialRender = (...args) => {\r\n\t\tconst { onItemInitialRender } = this.props\r\n\t\tif (onItemInitialRender) {\r\n\t\t\tonItemInitialRender(...args)\r\n\t\t}\r\n\t}\r\n\r\n\t// This proxy is required for cases when\r\n\t// `onItemFirstRender` property changes at subsequent renders.\r\n\t// For example, if it's passed as an \"anonymous\" function:\r\n\t// `<VirtualScroller onItemFirstRender={() => ...}/>`.\r\n\t// In such cases, if this \"proxy\" workaround hasn't been implemented,\r\n\t// the `VirtualScroller` instance would have the reference to the old function.\r\n\t// `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.\r\n\tonItemFirstRender = (...args) => {\r\n\t\tconst { onItemFirstRender } = this.props\r\n\t\tif (onItemFirstRender) {\r\n\t\t\tonItemFirstRender(...args)\r\n\t\t}\r\n\t}\r\n\r\n\tshouldUseRefs() {\r\n\t\t// There's no way to detect if `ref` can be passed to `component`:\r\n\t\t// https://github.com/facebook/react/issues/16309\r\n\t\t// So it only uses `ref`s for `React.Component`s.\r\n\t\tconst { itemComponent } = this.props\r\n\t\treturn isComponentClass(itemComponent)\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a `key` for an `item`'s element.\r\n\t * @param {object} item — The item.\r\n\t * @param {number} i — Item's index in `items` list.\r\n\t * @return {any}\r\n\t */\r\n\tgetItemKey(item, i) {\r\n\t\tconst { getItemId } = this.props\r\n\t\tif (getItemId) {\r\n\t\t\treturn getItemId(item)\r\n\t\t}\r\n\t\treturn `${this.itemKeyPrefix}:${i}`\r\n\t}\r\n\r\n\t/**\r\n\t * A proxy to `VirtualScroller.getItemCoordinates(i)`.\r\n\t * @param {number} i\r\n\t * @return {object}\r\n\t */\r\n\t/*\r\n\tgetItemCoordinates(i) {\r\n\t\treturn this.virtualScroller.getItemCoordinates(i)\r\n\t}\r\n\t*/\r\n\r\n\t/**\r\n\t * `updateItem(i)` has been renamed to `renderItem(i)`.\r\n\t * @param {number} i\r\n\t */\r\n\tupdateItem(i) {\r\n\t\treturn this.renderItem(i)\r\n\t}\r\n\r\n\t/**\r\n\t * Re-renders an item.\r\n\t * @param {number} i\r\n\t */\r\n\trenderItem(i) {\r\n\t\ti = this.getItemIndex(i)\r\n\t\tif (i === undefined) {\r\n\t\t\treturn reportError(`Item ${JSON.stringify(i)} not found when calling \".renderItem()\"`)\r\n\t\t}\r\n\t\tif (this.shouldUseRefs()) {\r\n\t\t\t// The item may be non-rendered when `.renderItem(i)` is called on it.\r\n\t\t\t// For example, when there's a \"parent comment\" having several \"replies\"\r\n\t\t\t// each of which has an autogenerated quote of the \"parent comment\"\r\n\t\t\t// and then the \"parent comment\" is updated (for example, a YouTube video\r\n\t\t\t// link gets parsed into an embedded video player) and all of its \"replies\"\r\n\t\t\t// should be updated too to show the parsed video title instead of the URL,\r\n\t\t\t// so `.renderItem(i)` is simply called on all of the \"parent post\"'s replies\r\n\t\t\t// regardless of some of those replies being rendered or not.\r\n\t\t\tif (this.itemRefs[i] && this.itemRefs[i].current) {\r\n\t\t\t\tconst { items } = this.props\r\n\t\t\t\t// Stores `item` here because the `i` index\r\n\t\t\t\t// might have changed when the callback is called,\r\n\t\t\t\t// or the item even may have been removed.\r\n\t\t\t\tconst item = items[i]\r\n\t\t\t\tthis.itemRefs[i].current.forceUpdate(() => {\r\n\t\t\t\t\tif (this._isMounted) {\r\n\t\t\t\t\t\t// Recalculates the `i` index here because it\r\n\t\t\t\t\t\t// might have changed when the callback is called,\r\n\t\t\t\t\t\t// or the item even may have been removed.\r\n\t\t\t\t\t\tconst i = items.indexOf(item)\r\n\t\t\t\t\t\tif (i >= 0) {\r\n\t\t\t\t\t\t\tthis.virtualScroller.onItemHeightChange(i)\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t})\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tgetItemIndex(i) {\r\n\t\tif (typeof i === 'number') {\r\n\t\t\treturn i\r\n\t\t}\r\n\t\tif (typeof i === 'object' && i !== null) {\r\n\t\t\tconst { items, getItemId } = this.props\r\n\t\t\tconst item = i\r\n\t\t\ti = 0\r\n\t\t\twhile (i < items.length) {\r\n\t\t\t\tif (getItemId) {\r\n\t\t\t\t\tif (getItemId(item) === getItemId(items[i])) {\r\n\t\t\t\t\t\treturn i\r\n\t\t\t\t\t}\r\n\t\t\t\t} else {\r\n\t\t\t\t\tif (item === items[i]) {\r\n\t\t\t\t\t\treturn i\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\ti++\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// Functional components can't have a `ref` assigned to them.\r\n\t// Item `ref`s are only used for calling `.renderItem(i)` instance method,\r\n\t// because `.renderItem(i)` calls `.forceUpdate()` on item `i`.\r\n\t// If a developer is not using the `.renderItem(i)` instance method\r\n\t// then `ref`s aren't required and will be omitted.\r\n\tgetItemRef(i) {\r\n\t\tif (!this.itemRefs[i]) {\r\n\t\t\tthis.itemRefs[i] = React.createRef()\r\n\t\t}\r\n\t\treturn this.itemRefs[i]\r\n\t}\r\n\r\n\tgetOnItemStateChange(i) {\r\n\t\tif (!this.onItemStateChange[i]) {\r\n\t\t\tthis.onItemStateChange[i] = (itemState) => this.virtualScroller.onItemStateChange(i, itemState)\r\n\t\t}\r\n\t\treturn this.onItemStateChange[i]\r\n\t}\r\n\r\n\tgetOnItemHeightChange(i) {\r\n\t\tif (!this.onItemHeightChange[i]) {\r\n\t\t\tthis.onItemHeightChange[i] = () => this.virtualScroller.onItemHeightChange(i)\r\n\t\t}\r\n\t\treturn this.onItemHeightChange[i]\r\n\t}\r\n\r\n\tgenerateItemKeyPrefix() {\r\n\t\tconst prefix = String(Math.random()).slice(2)\r\n\t\tif (this.itemKeyPrefixes.indexOf(prefix) >= 0) {\r\n\t\t\treturn this.generateItemKeyPrefix()\r\n\t\t}\r\n\t\tthis.itemKeyPrefixes.push(prefix)\r\n\t\tthis.itemKeyPrefix = prefix\r\n\t}\r\n\r\n\tcomponentDidMount() {\r\n\t\tconst { onMount } = this.props\r\n\t\t// `onMount()` option is deprecated due to no longer being used.\r\n\t\t// If someone thinks there's a valid use case for it, create an issue.\r\n\t\tif (onMount) {\r\n\t\t\tonMount()\r\n\t\t}\r\n\t\tthis._isMounted = true\r\n\t\t// Start listening to scroll events.\r\n\t\tthis.virtualScroller.listen()\r\n\t}\r\n\r\n\t// `getSnapshotBeforeUpdate()` is called right before `componentDidUpdate()`.\r\n\tgetSnapshotBeforeUpdate(prevProps, prevState) {\r\n\t\tif (this.state !== prevState) {\r\n\t\t\tthis.willUpdateState(this.state, prevState)\r\n\t\t}\r\n\t\t// Returns `null` to avoid React warning:\r\n\t\t// \"A snapshot value (or null) must be returned. You have returned undefined\".\r\n\t\treturn null\r\n\t}\r\n\r\n\t// `componentDidUpdate()` is called immediately after React component has re-rendered.\r\n\t// That would correspond to `useLayoutEffect()` in React Hooks.\r\n\tcomponentDidUpdate(prevProps, prevState) {\r\n\t\t// If `state` did change.\r\n\t\tif (this.state !== prevState) {\r\n\t\t\tthis.didUpdateState(prevState)\r\n\t\t}\r\n\t\t// If `items` property did change then update `virtual-scroller` items.\r\n\t\t// This could have been done in `.render()` but `.setItems()` calls\r\n\t\t// `.setState()` internally which would result in React throwing an error.\r\n\t\tconst {\r\n\t\t\titems,\r\n\t\t\tpreserveScrollPosition,\r\n\t\t\tpreserveScrollPositionOnPrependItems\r\n\t\t} = this.props\r\n\t\tif (items !== prevProps.items) {\r\n\t\t\tthis.virtualScroller.setItems(items, {\r\n\t\t\t\t// `preserveScrollPosition` property name is deprecated,\r\n\t\t\t\t// use `preserveScrollPositionOnPrependItems` instead.\r\n\t\t\t\tpreserveScrollPositionOnPrependItems: preserveScrollPositionOnPrependItems || preserveScrollPosition\r\n\t\t\t})\r\n\t\t}\r\n\t}\r\n\r\n\tcomponentWillUnmount() {\r\n\t\tthis._isMounted = false\r\n\t\t// Stop listening to scroll events.\r\n\t\tthis.virtualScroller.stop()\r\n\t}\r\n\r\n\trender() {\r\n\t\tconst {\r\n\t\t\tas: AsComponent,\r\n\t\t\titemComponent: Component,\r\n\t\t\titemComponentProps,\r\n\t\t\t// Rest\r\n\t\t\titems: _items,\r\n\t\t\testimatedItemHeight,\r\n\t\t\tbypass,\r\n\t\t\t// bypassBatchSize,\r\n\t\t\tpreserveScrollPositionOnPrependItems,\r\n\t\t\t// `preserveScrollPosition` property name is deprecated,\r\n\t\t\t// use `preserveScrollPositionOnPrependItems` instead.\r\n\t\t\tpreserveScrollPosition,\r\n\t\t\tpreserveScrollPositionOfTheBottomOfTheListOnMount,\r\n\t\t\t// `preserveScrollPositionAtBottomOnMount` property name is deprecated,\r\n\t\t\t// use `preserveScrollPositionOfTheBottomOfTheListOnMount` property instead.\r\n\t\t\tpreserveScrollPositionAtBottomOnMount,\r\n\t\t\tinitialScrollPosition,\r\n\t\t\tonScrollPositionChange,\r\n\t\t\tmeasureItemsBatchSize,\r\n\t\t\tscrollableContainer,\r\n\t\t\t// `getScrollableContainer` property is deprecated.\r\n\t\t\t// Use `scrollableContainer` instead.\r\n\t\t\tgetScrollableContainer,\r\n\t\t\tgetColumnsCount,\r\n\t\t\tinitialState,\r\n\t\t\tinitialCustomState,\r\n\t\t\tonStateChange,\r\n\t\t\tonItemInitialRender,\r\n\t\t\t// `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.\r\n\t\t\tonItemFirstRender,\r\n\t\t\tgetItemId,\r\n\t\t\tonMount,\r\n\t\t\tclassName,\r\n\t\t\t...rest\r\n\t\t} = this.props\r\n\t\tconst {\r\n\t\t\titems,\r\n\t\t\titemStates,\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex,\r\n\t\t\tbeforeItemsHeight,\r\n\t\t\tafterItemsHeight\r\n\t\t} = this.virtualScroller.getState()\r\n\t\t// If `items` are about to be changed then\r\n\t\t// store the scroll Y position for the first one\r\n\t\t// of the current items.\r\n\t\t// Previously it was being done in `componentDidUpdate()`\r\n\t\t// but it was later found out that it wouldn't work\r\n\t\t// for \"Show previous\" button because it would\r\n\t\t// get hidden before `componentDidUpdate()` is called.\r\n\t\t//\r\n\t\t// Consider this code example:\r\n\t\t//\r\n\t\t// const { fromIndex, items } = this.state\r\n\t\t// const items = allItems.slice(fromIndex)\r\n\t\t// return (\r\n\t\t// \t{fromIndex > 0 &&\r\n\t\t// \t\t<button onClick={this.onShowPrevious}>\r\n\t\t// \t\t\tShow previous\r\n\t\t// \t\t</button>\r\n\t\t// \t}\r\n\t\t// \t<VirtualScroller\r\n\t\t// \t\titems={items}\r\n\t\t// \t\titemComponent={ItemComponent}/>\r\n\t\t// )\r\n\t\t//\r\n\t\t// Consider a user clicks \"Show previous\" to show the items from the start.\r\n\t\t// By the time `componentDidUpdate()` is called on `<VirtualScroller/>`,\r\n\t\t// the \"Show previous\" button has already been hidden\r\n\t\t// (because there're no more \"previous\" items)\r\n\t\t// which results in the scroll Y position jumping forward\r\n\t\t// by the height of that \"Show previous\" button.\r\n\t\t// This is because `<VirtualScroller/>` captures scroll Y\r\n\t\t// position when items are prepended via `.setItems()`\r\n\t\t// when the \"Show previous\" button is still being shown,\r\n\t\t// and then restores scroll Y position in `.didUpdateState()`\r\n\t\t// when the \"Show previous\" button has already been hidden:\r\n\t\t// that's the reason for the scroll Y \"jump\".\r\n\t\t//\r\n\t\t// To prevent that, scroll Y position is captured at `render()`\r\n\t\t// time rather than later in `componentDidUpdate()`: this way,\r\n\t\t// scroll Y position is captured while the \"Show previous\" button\r\n\t\t// is still being shown.\r\n\t\t//\r\n\t\tconst newItems = this.props.items\r\n\t\tconst previousItems = items // this.virtualScroller.getState().items\r\n\t\t// There's one case when `newItems !== previousItems` is `true`\r\n\t\t// from the start: when `initialState.items` are passed.\r\n\t\t// To handle that single case `this.previousItemsProperty`\r\n\t\t// is tracked and `this.itemsPropertyHasChanged` flag is set.\r\n\t\tif (!this.itemsPropertyWasChanged) {\r\n\t\t\tthis.itemsPropertyWasChanged = this.props.items !== this.previousItemsProperty\r\n\t\t}\r\n\t\tthis.previousItemsProperty = this.props.items\r\n\t\tif (this.itemsPropertyWasChanged && newItems !== previousItems) {\r\n\t\t\tconst itemsDiff = this.virtualScroller.getItemsDiff(previousItems, newItems)\r\n\t\t\tif (itemsDiff && itemsDiff.prependedItemsCount === 0 && itemsDiff.appendedItemsCount > 0) {\r\n\t\t\t\t// If it's just items that have been appended\r\n\t\t\t\t// then no need to re-generate the prefix\r\n\t\t\t\t// and to fix scroll position and to clear caches.\r\n\t\t\t} else {\r\n\t\t\t\t// If the items update was incremental, then it's possible\r\n\t\t\t\t// that some items were prepended, and so the scroll Y position\r\n\t\t\t\t// should be restored after rendering those new items\r\n\t\t\t\t// in order for the currently shown items to stay\r\n\t\t\t\t// on the same position on screen.\r\n\t\t\t\t// (only if explicitly opted into using this feature)\r\n\t\t\t\t//\r\n\t\t\t\t// If the items update wasn't incremental\r\n\t\t\t\t// then there's no point in restoring scroll position.\r\n\t\t\t\t//\r\n\t\t\t\t// `preserveScrollPosition` property name is deprecated,\r\n\t\t\t\t// use `preserveScrollPositionOnPrependItems` instead.\r\n\t\t\t\t//\r\n\t\t\t\tif (itemsDiff) {\r\n\t\t\t\t\tconst { prependedItemsCount } = itemsDiff\r\n\t\t\t\t\tif (prependedItemsCount > 0) {\r\n\t\t\t\t\t\tif (preserveScrollPositionOnPrependItems || preserveScrollPosition) {\r\n\t\t\t\t\t\t\tif (firstShownItemIndex === 0) {\r\n\t\t\t\t\t\t\t\tthis.virtualScroller.restoreScroll.captureScroll({\r\n\t\t\t\t\t\t\t\t\tpreviousItems,\r\n\t\t\t\t\t\t\t\t\tnewItems,\r\n\t\t\t\t\t\t\t\t\tprependedItemsCount\r\n\t\t\t\t\t\t\t\t})\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\t// Reset the unique `key` prefix for item component keys.\r\n\t\t\t\tif (!getItemId) {\r\n\t\t\t\t\tthis.generateItemKeyPrefix()\r\n\t\t\t\t}\r\n\t\t\t\t// Reset item refs.\r\n\t\t\t\tthis.itemRefs = new Array(newItems.length)\r\n\t\t\t}\r\n\t\t}\r\n\t\tconst tbody = this.virtualScroller.tbody\r\n\t\treturn (\r\n\t\t\t<AsComponent\r\n\t\t\t\t{...rest}\r\n\t\t\t\tref={this.container}\r\n\t\t\t\tclassName={tbody ? (className ? className + ' ' + 'VirtualScroller' : 'VirtualScroller') : className}\r\n\t\t\t\tstyle={{\r\n\t\t\t\t\tpaddingTop: tbody ? undefined : px(beforeItemsHeight),\r\n\t\t\t\t\tpaddingBottom: tbody ? undefined : px(afterItemsHeight)\r\n\t\t\t\t}}>\r\n\t\t\t\t{items.map((item, i) => {\r\n\t\t\t\t\tif (i >= firstShownItemIndex && i <= lastShownItemIndex) {\r\n\t\t\t\t\t\treturn (\r\n\t\t\t\t\t\t\t<Component\r\n\t\t\t\t\t\t\t\t{...itemComponentProps}\r\n\t\t\t\t\t\t\t\tkey={this.getItemKey(item, i)}\r\n\t\t\t\t\t\t\t\tref={this.shouldUseRefs() ? this.getItemRef(i) : undefined}\r\n\t\t\t\t\t\t\t\tstate={itemStates && itemStates[i]}\r\n\t\t\t\t\t\t\t\tonStateChange={this.getOnItemStateChange(i)}\r\n\t\t\t\t\t\t\t\tonHeightChange={this.getOnItemHeightChange(i)}>\r\n\t\t\t\t\t\t\t\t{item}\r\n\t\t\t\t\t\t\t</Component>\r\n\t\t\t\t\t\t)\r\n\t\t\t\t\t}\r\n\t\t\t\t\treturn null\r\n\t\t\t\t})}\r\n\t\t\t</AsComponent>\r\n\t\t)\r\n\t}\r\n}\r\n\r\n/**\r\n * Checks if the argument is a `React.Component` class.\r\n * https://overreacted.io/how-does-react-tell-a-class-from-a-function/\r\n * @param {any} Component\r\n * @return {object} [result] Returns `undefined` if it's not a `React.Component`. Returns an empty object if it's a `React.Component` (`.isReactComponent` is an empty object).\r\n */\r\nfunction isComponentClass(Component) {\r\n\t// return Component.prototype instanceof React.Component\r\n\t// `React.memo()` returns `.prototype === undefined` for some reason.\r\n\treturn Component.prototype && Component.prototype.isReactComponent\r\n}\r\n"],"file":"VirtualScroller.js"}
|
|
1
|
+
{"version":3,"sources":["../../source/react/VirtualScroller.js"],"names":["elementType","PropTypes","oneOfType","string","func","object","VirtualScroller","props","React","createRef","Array","items","length","virtualScroller","updateLayout","onItemInitialRender","onItemFirstRender","previousItemsProperty","generateItemKeyPrefix","createVirtualScroller","AsComponent","as","initialState","initialCustomState","onStateChange","estimatedItemHeight","initialScrollPosition","onScrollPositionChange","measureItemsBatchSize","scrollableContainer","getScrollableContainer","getColumnsCount","getItemId","bypass","VirtualScrollerCore","container","current","_useTimeoutInRenderLoop","shouldUpdateLayoutOnScreenResize","tbody","state","customState","getState","setState","newState","willUpdateState","didUpdateState","itemComponent","isComponentClass","item","i","itemKeyPrefix","renderItem","getItemIndex","undefined","JSON","stringify","shouldUseRefs","itemRefs","forceUpdate","_isMounted","indexOf","onItemHeightChange","onItemStateChange","itemState","prefix","String","Math","random","slice","itemKeyPrefixes","push","onMount","listen","prevProps","prevState","preserveScrollPosition","preserveScrollPositionOnPrependItems","setItems","stop","Component","itemComponentProps","_items","className","rest","itemStates","firstShownItemIndex","lastShownItemIndex","beforeItemsHeight","afterItemsHeight","newItems","previousItems","itemsPropertyWasChanged","itemsDiff","getItemsDiff","prependedItemsCount","appendedItemsCount","listHeightChangeWatcher","snapshot","paddingTop","paddingBottom","map","getItemKey","getItemRef","getOnItemStateChange","getOnItemHeightChange","arrayOf","any","isRequired","number","bool","shape","itemHeights","columnsCount","verticalSpacing","protot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B;AACAY,EAAAA,iBAAiB,EAAEf,sBAAUG,IAvBX;AAwBlBsB,EAAAA,qBAAqB,EAAEzB,sBAAU4G,MAxBf;AAyBlBlF,EAAAA,sBAAsB,EAAE1B,sBAAUG,IAzBhB;AA0BlBoB,EAAAA,aAAa,EAAEvB,sBAAUG,IA1BP;AA2BlBmB,EAAAA,kBAAkB,EAAEtB,sBAAUI,MA3BZ;AA4BlBiB,EAAAA,YAAY,EAAErB,sBAAU8G,KAAV,CAAgB;AAC7BpG,IAAAA,KAAK,EAAEV,sBAAUyG,OAAV,CAAkBzG,sBAAUI,MAA5B,EAAoCuG,UADd;AAE7BvB,IAAAA,UAAU,EAAEpF,sBAAUyG,OAAV,CAAkBzG,sBAAU0G,GAA5B,CAFiB;AAG7BrB,IAAAA,mBAAmB,EAAErF,sBAAU4G,MAAV,CAAiBD,UAHT;AAI7BrB,IAAAA,kBAAkB,EAAEtF,sBAAU4G,MAAV,CAAiBD,UAJR;AAK7BpB,IAAAA,iBAAiB,EAAEvF,sBAAU4G,MAAV,CAAiBD,UALP;AAM7BnB,IAAAA,gBAAgB,EAAExF,sBAAU4G,MAAV,CAAiBD,UANN;AAO7BI,IAAAA,WAAW,EAAE/G,sBAAUyG,OAAV,CAAkBzG,sBAAU4G,MAA5B,EAAoCD,UAPpB;AAQ7BK,IAAAA,YAAY,EAAEhH,sBAAU4G,MARK;AAS7BK,IAAAA,eAAe,EAAEjH,sBAAU4G;AATE,GAAhB;AA5BI,C;;gBADCvG,e,kBA0CE;AACrBe,EAAAA,EAAE,EAAE;AADiB,C;;AA4hBvB,SAAS2B,gBAAT,CAA0BgC,SAA1B,EAAqC;AACpC;AACA;AACA,SAAOA,SAAS,CAACmC,SAAV,IAAuBnC,SAAS,CAACmC,SAAV,CAAoBC,gBAAlD;AACA","sourcesContent":["import React from 'react'\r\nimport PropTypes from 'prop-types'\r\n\r\nimport VirtualScrollerCore from '../VirtualScroller'\r\n\r\nimport { reportError } from '../utility/debug'\r\nimport px from '../utility/px'\r\n\r\n// `PropTypes.elementType` is available in some version of `prop-types`.\r\n// https://github.com/facebook/prop-types/issues/200\r\nconst elementType = PropTypes.elementType || PropTypes.oneOfType([\r\n\tPropTypes.string,\r\n\tPropTypes.func,\r\n\tPropTypes.object\r\n])\r\n\r\nexport default class VirtualScroller extends React.Component {\r\n\tstatic propTypes = {\r\n\t\tas: elementType,\r\n\t\titems: PropTypes.arrayOf(PropTypes.any).isRequired,\r\n\t\titemComponent: elementType.isRequired,\r\n\t\titemComponentProps: PropTypes.object,\r\n\t\testimatedItemHeight: PropTypes.number,\r\n\t\tbypass: PropTypes.bool,\r\n\t\t// bypassBatchSize: PropTypes.number,\r\n\t\tpreserveScrollPositionOnPrependItems: PropTypes.bool,\r\n\t\t// `preserveScrollPosition` property name is deprecated,\r\n\t\t// use `preserveScrollPositionOnPrependItems` instead.\r\n\t\tpreserveScrollPosition: PropTypes.bool,\r\n\t\tmeasureItemsBatchSize: PropTypes.number,\r\n\t\tscrollableContainer: PropTypes.any,\r\n\t\t// `getScrollableContainer` property is deprecated.\r\n\t\t// Use `scrollableContainer` instead.\r\n\t\tgetScrollableContainer: PropTypes.func,\r\n\t\tgetColumnsCount: PropTypes.func,\r\n\t\tgetItemId: PropTypes.func,\r\n\t\tclassName: PropTypes.string,\r\n\t\tonMount: PropTypes.func,\r\n\t\tonItemInitialRender: PropTypes.func,\r\n\t\t// `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.\r\n\t\tonItemFirstRender: PropTypes.func,\r\n\t\tinitialScrollPosition: PropTypes.number,\r\n\t\tonScrollPositionChange: PropTypes.func,\r\n\t\tonStateChange: PropTypes.func,\r\n\t\tinitialCustomState: PropTypes.object,\r\n\t\tinitialState: PropTypes.shape({\r\n\t\t\titems: PropTypes.arrayOf(PropTypes.object).isRequired,\r\n\t\t\titemStates: PropTypes.arrayOf(PropTypes.any),\r\n\t\t\tfirstShownItemIndex: PropTypes.number.isRequired,\r\n\t\t\tlastShownItemIndex: PropTypes.number.isRequired,\r\n\t\t\tbeforeItemsHeight: PropTypes.number.isRequired,\r\n\t\t\tafterItemsHeight: PropTypes.number.isRequired,\r\n\t\t\titemHeights: PropTypes.arrayOf(PropTypes.number).isRequired,\r\n\t\t\tcolumnsCount: PropTypes.number,\r\n\t\t\tverticalSpacing: PropTypes.number\r\n\t\t})\r\n\t}\r\n\r\n\tstatic defaultProps = {\r\n\t\tas: 'div'\r\n\t}\r\n\r\n\t// `this.state` is already reserved for `virtual-scroller`.\r\n\t// static getDerivedStateFromProps(props, state) {\r\n\t// \treturn {\r\n\t// \t\tprevProps: {\r\n\t// \t\t\titems: props.items\r\n\t// \t\t}\r\n\t// \t}\r\n\t// }\r\n\r\n\tcontainer = React.createRef()\r\n\r\n\t// Handler function caches.\r\n\t// Just so that the props passed to `itemComponent`\r\n\t// are not changed on every `.render()` and so\r\n\t// `itemComponent` won't re-render if it's a `PureComponent`.\r\n\tonItemStateChange = new Array(this.props.items.length)\r\n\tonItemHeightChange = new Array(this.props.items.length)\r\n\r\n\t// Item refs for `.renderItem(i)`.\r\n\titemRefs = new Array(this.props.items.length)\r\n\r\n\t// List items are rendered with `key`s\r\n\t// so that React doesn't reuse `itemComponent`s\r\n\t// in cases when `items` are changed.\r\n\titemKeyPrefixes = []\r\n\r\n\tconstructor(props) {\r\n\t\tsuper(props)\r\n\t\t// `this.previousItemsProperty` is only used for comparing\r\n\t\t// `previousItems` with `newItems` inside `render()`.\r\n\t\tthis.previousItemsProperty = props.items\r\n\t\t// Generate unique `key` prefix for list item components.\r\n\t\tthis.generateItemKeyPrefix()\r\n\t\t// Create `VirtualScroller` instance.\r\n\t\tthis.createVirtualScroller()\r\n\t}\r\n\r\n\tcreateVirtualScroller() {\r\n\t\tconst {\r\n\t\t\tas: AsComponent,\r\n\t\t\titems,\r\n\t\t\tinitialState,\r\n\t\t\tinitialCustomState,\r\n\t\t\tonStateChange,\r\n\t\t\testimatedItemHeight,\r\n\t\t\tinitialScrollPosition,\r\n\t\t\tonScrollPositionChange,\r\n\t\t\tmeasureItemsBatchSize,\r\n\t\t\tscrollableContainer,\r\n\t\t\t// `getScrollableContainer` property is deprecated.\r\n\t\t\t// Use `scrollableContainer` instead.\r\n\t\t\tgetScrollableContainer,\r\n\t\t\tgetColumnsCount,\r\n\t\t\tgetItemId,\r\n\t\t\tbypass,\r\n\t\t\t// bypassBatchSize\r\n\t\t} = this.props\r\n\t\t// Create `virtual-scroller` instance.\r\n\t\tthis.virtualScroller = new VirtualScrollerCore(\r\n\t\t\t() => this.container.current,\r\n\t\t\titems,\r\n\t\t\t{\r\n\t\t\t\t_useTimeoutInRenderLoop: true,\r\n\t\t\t\testimatedItemHeight,\r\n\t\t\t\tbypass,\r\n\t\t\t\t// bypassBatchSize,\r\n\t\t\t\tonItemInitialRender: this.onItemInitialRender,\r\n\t\t\t\t// `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.\r\n\t\t\t\tonItemFirstRender: this.onItemFirstRender,\r\n\t\t\t\tinitialScrollPosition,\r\n\t\t\t\tonScrollPositionChange,\r\n\t\t\t\tshouldUpdateLayoutOnScreenResize: this.shouldUpdateLayoutOnScreenResize,\r\n\t\t\t\tmeasureItemsBatchSize,\r\n\t\t\t\tscrollableContainer,\r\n\t\t\t\t// `getScrollableContainer` property is deprecated.\r\n\t\t\t\t// Use `scrollableContainer` instead.\r\n\t\t\t\tgetScrollableContainer,\r\n\t\t\t\tgetColumnsCount,\r\n\t\t\t\tgetItemId,\r\n\t\t\t\ttbody: AsComponent === 'tbody',\r\n\t\t\t\tstate: initialState,\r\n\t\t\t\tcustomState: initialCustomState,\r\n\t\t\t\tonStateChange,\r\n\t\t\t\tgetState: () => this.state,\r\n\t\t\t\tsetState: (newState, { willUpdateState, didUpdateState }) => {\r\n\t\t\t\t\tthis.willUpdateState = willUpdateState\r\n\t\t\t\t\tthis.didUpdateState = didUpdateState\r\n\t\t\t\t\tif (this.state) {\r\n\t\t\t\t\t\t// Update existing state.\r\n\t\t\t\t\t\t//\r\n\t\t\t\t\t\t// In case of hypothetically rewriting this in React hooks,\r\n\t\t\t\t\t\t// it wouldn't simply be `setState({ ...prevState, ...newState })`.\r\n\t\t\t\t\t\t// The reason is that `setState()` would be \"asynchronous\" (not immediate),\r\n\t\t\t\t\t\t// and `...prevState` would be stale in cases when more than a single\r\n\t\t\t\t\t\t// `setState()` call is made before the state actually updates,\r\n\t\t\t\t\t\t// making `prevState` stale, and, as a consequence, losing some\r\n\t\t\t\t\t\t// of the state updates.\r\n\t\t\t\t\t\t// For example, the first `setState()` call updates shown item indexes,\r\n\t\t\t\t\t\t// and the second `setState()` call updates `verticalSpacing`:\r\n\t\t\t\t\t\t// if it was simply `setState({ ...prevState, ...newState })`,\r\n\t\t\t\t\t\t// then the second state update could overwrite the first state update,\r\n\t\t\t\t\t\t// resulting in incorrect items being shown/hidden.\r\n\t\t\t\t\t\t//\r\n\t\t\t\t\t\t// I guess, in hooks, it could be something like:\r\n\t\t\t\t\t\t//\r\n\t\t\t\t\t\t// const [firstShownItemIndex, setFirstShownItemIndex] = useState()\r\n\t\t\t\t\t\t// ...\r\n\t\t\t\t\t\t// const setState = useCallback((newState) => {\r\n\t\t\t\t\t\t// \tfor (const key in newState) {\r\n\t\t\t\t\t\t// \t\tswitch (key) {\r\n\t\t\t\t\t\t// \t\t\tcase 'firstShownItemIndex':\r\n\t\t\t\t\t\t// \t\t\t\tsetFirstShownItemIndex(newState[key])\r\n\t\t\t\t\t\t// \t\t\t\tbreak\r\n\t\t\t\t\t\t// \t\t\t...\r\n\t\t\t\t\t\t// \t\t}\r\n\t\t\t\t\t\t// \t}\r\n\t\t\t\t\t\t// \tsetFirstShownItemIndex\r\n\t\t\t\t\t\t// }, [])\r\n\t\t\t\t\t\t// const virtualScroller = new VirtualScrollerCore({\r\n\t\t\t\t\t\t// \tsetState,\r\n\t\t\t\t\t\t// \t...\r\n\t\t\t\t\t\t// })\r\n\t\t\t\t\t\t// // `getState()` function would be updated on every render.\r\n\t\t\t\t\t\t// virtualScroller.getState = () => ({\r\n\t\t\t\t\t\t// \tfirstShownItemIndex,\r\n\t\t\t\t\t\t// \t...\r\n\t\t\t\t\t\t// })\r\n\t\t\t\t\t\t//\r\n\t\t\t\t\t\t// But as long as it uses the classic `this.setState()`,\r\n\t\t\t\t\t\t// it's fine and simple.\r\n\t\t\t\t\t\tthis.setState(newState)\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\t// Set initial state.\r\n\t\t\t\t\t\twillUpdateState(newState)\r\n\t\t\t\t\t\tthis.state = newState\r\n\t\t\t\t\t\tdidUpdateState()\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t)\r\n\t}\r\n\r\n\t// This is a proxy for `VirtualScroller`'s `.updateLayout` instance method.\r\n\tupdateLayout = () => this.virtualScroller.updateLayout()\r\n\r\n\t// `.layout()` method name is deprecated, use `.updateLayout()` instead.\r\n\tlayout = () => this.updateLayout()\r\n\r\n\t// This proxy is required for cases when\r\n\t// `onItemInitialRender` property changes at subsequent renders.\r\n\t// For example, if it's passed as an \"anonymous\" function:\r\n\t// `<VirtualScroller onItemInitialRender={() => ...}/>`.\r\n\t// In such cases, if this \"proxy\" workaround hasn't been implemented,\r\n\t// the `VirtualScroller` instance would have the reference to the old function.\r\n\tonItemInitialRender = (...args) => {\r\n\t\tconst { onItemInitialRender } = this.props\r\n\t\tif (onItemInitialRender) {\r\n\t\t\tonItemInitialRender(...args)\r\n\t\t}\r\n\t}\r\n\r\n\t// This proxy is required for cases when\r\n\t// `onItemFirstRender` property changes at subsequent renders.\r\n\t// For example, if it's passed as an \"anonymous\" function:\r\n\t// `<VirtualScroller onItemFirstRender={() => ...}/>`.\r\n\t// In such cases, if this \"proxy\" workaround hasn't been implemented,\r\n\t// the `VirtualScroller` instance would have the reference to the old function.\r\n\t// `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.\r\n\tonItemFirstRender = (...args) => {\r\n\t\tconst { onItemFirstRender } = this.props\r\n\t\tif (onItemFirstRender) {\r\n\t\t\tonItemFirstRender(...args)\r\n\t\t}\r\n\t}\r\n\r\n\tshouldUseRefs() {\r\n\t\t// There's no way to detect if `ref` can be passed to `component`:\r\n\t\t// https://github.com/facebook/react/issues/16309\r\n\t\t// So it only uses `ref`s for `React.Component`s.\r\n\t\tconst { itemComponent } = this.props\r\n\t\treturn isComponentClass(itemComponent)\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a `key` for an `item`'s element.\r\n\t * @param {object} item — The item.\r\n\t * @param {number} i — Item's index in `items` list.\r\n\t * @return {any}\r\n\t */\r\n\tgetItemKey(item, i) {\r\n\t\tconst { getItemId } = this.props\r\n\t\tif (getItemId) {\r\n\t\t\treturn getItemId(item)\r\n\t\t}\r\n\t\treturn `${this.itemKeyPrefix}:${i}`\r\n\t}\r\n\r\n\t/**\r\n\t * A proxy to `VirtualScroller.getItemCoordinates(i)`.\r\n\t * @param {number} i\r\n\t * @return {object}\r\n\t */\r\n\t/*\r\n\tgetItemCoordinates(i) {\r\n\t\treturn this.virtualScroller.getItemCoordinates(i)\r\n\t}\r\n\t*/\r\n\r\n\t/**\r\n\t * `updateItem(i)` has been renamed to `renderItem(i)`.\r\n\t * @param {number} i\r\n\t */\r\n\tupdateItem(i) {\r\n\t\treturn this.renderItem(i)\r\n\t}\r\n\r\n\t/**\r\n\t * Re-renders an item.\r\n\t * @param {number} i\r\n\t */\r\n\trenderItem(i) {\r\n\t\ti = this.getItemIndex(i)\r\n\t\tif (i === undefined) {\r\n\t\t\treturn reportError(`Item ${JSON.stringify(i)} not found when calling \".renderItem()\"`)\r\n\t\t}\r\n\t\tif (this.shouldUseRefs()) {\r\n\t\t\t// The item may be non-rendered when `.renderItem(i)` is called on it.\r\n\t\t\t// For example, when there's a \"parent comment\" having several \"replies\"\r\n\t\t\t// each of which has an autogenerated quote of the \"parent comment\"\r\n\t\t\t// and then the \"parent comment\" is updated (for example, a YouTube video\r\n\t\t\t// link gets parsed into an embedded video player) and all of its \"replies\"\r\n\t\t\t// should be updated too to show the parsed video title instead of the URL,\r\n\t\t\t// so `.renderItem(i)` is simply called on all of the \"parent post\"'s replies\r\n\t\t\t// regardless of some of those replies being rendered or not.\r\n\t\t\tif (this.itemRefs[i] && this.itemRefs[i].current) {\r\n\t\t\t\tconst { items } = this.props\r\n\t\t\t\t// Stores `item` here because the `i` index\r\n\t\t\t\t// might have changed when the callback is called,\r\n\t\t\t\t// or the item even may have been removed.\r\n\t\t\t\tconst item = items[i]\r\n\t\t\t\tthis.itemRefs[i].current.forceUpdate(() => {\r\n\t\t\t\t\tif (this._isMounted) {\r\n\t\t\t\t\t\t// Recalculates the `i` index here because it\r\n\t\t\t\t\t\t// might have changed when the callback is called,\r\n\t\t\t\t\t\t// or the item even may have been removed.\r\n\t\t\t\t\t\tconst i = items.indexOf(item)\r\n\t\t\t\t\t\tif (i >= 0) {\r\n\t\t\t\t\t\t\tthis.virtualScroller.onItemHeightChange(i)\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t})\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tgetItemIndex(i) {\r\n\t\tif (typeof i === 'number') {\r\n\t\t\treturn i\r\n\t\t}\r\n\t\tif (typeof i === 'object' && i !== null) {\r\n\t\t\tconst { items, getItemId } = this.props\r\n\t\t\tconst item = i\r\n\t\t\ti = 0\r\n\t\t\twhile (i < items.length) {\r\n\t\t\t\tif (getItemId) {\r\n\t\t\t\t\tif (getItemId(item) === getItemId(items[i])) {\r\n\t\t\t\t\t\treturn i\r\n\t\t\t\t\t}\r\n\t\t\t\t} else {\r\n\t\t\t\t\tif (item === items[i]) {\r\n\t\t\t\t\t\treturn i\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\ti++\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// Functional components can't have a `ref` assigned to them.\r\n\t// Item `ref`s are only used for calling `.renderItem(i)` instance method,\r\n\t// because `.renderItem(i)` calls `.forceUpdate()` on item `i`.\r\n\t// If a developer is not using the `.renderItem(i)` instance method\r\n\t// then `ref`s aren't required and will be omitted.\r\n\tgetItemRef(i) {\r\n\t\tif (!this.itemRefs[i]) {\r\n\t\t\tthis.itemRefs[i] = React.createRef()\r\n\t\t}\r\n\t\treturn this.itemRefs[i]\r\n\t}\r\n\r\n\tgetOnItemStateChange(i) {\r\n\t\tif (!this.onItemStateChange[i]) {\r\n\t\t\tthis.onItemStateChange[i] = (itemState) => this.virtualScroller.onItemStateChange(i, itemState)\r\n\t\t}\r\n\t\treturn this.onItemStateChange[i]\r\n\t}\r\n\r\n\tgetOnItemHeightChange(i) {\r\n\t\tif (!this.onItemHeightChange[i]) {\r\n\t\t\tthis.onItemHeightChange[i] = () => this.virtualScroller.onItemHeightChange(i)\r\n\t\t}\r\n\t\treturn this.onItemHeightChange[i]\r\n\t}\r\n\r\n\tgenerateItemKeyPrefix() {\r\n\t\tconst prefix = String(Math.random()).slice(2)\r\n\t\tif (this.itemKeyPrefixes.indexOf(prefix) >= 0) {\r\n\t\t\treturn this.generateItemKeyPrefix()\r\n\t\t}\r\n\t\tthis.itemKeyPrefixes.push(prefix)\r\n\t\tthis.itemKeyPrefix = prefix\r\n\t}\r\n\r\n\tcomponentDidMount() {\r\n\t\tconst { onMount } = this.props\r\n\t\t// `onMount()` option is deprecated due to no longer being used.\r\n\t\t// If someone thinks there's a valid use case for it, create an issue.\r\n\t\tif (onMount) {\r\n\t\t\tonMount()\r\n\t\t}\r\n\t\tthis._isMounted = true\r\n\t\t// Start listening to scroll events.\r\n\t\tthis.virtualScroller.listen()\r\n\t}\r\n\r\n\t// `getSnapshotBeforeUpdate()` is called right before `componentDidUpdate()`.\r\n\tgetSnapshotBeforeUpdate(prevProps, prevState) {\r\n\t\tif (this.state !== prevState) {\r\n\t\t\tthis.willUpdateState(this.state, prevState)\r\n\t\t}\r\n\t\t// Returns `null` to avoid React warning:\r\n\t\t// \"A snapshot value (or null) must be returned. You have returned undefined\".\r\n\t\treturn null\r\n\t}\r\n\r\n\t// `componentDidUpdate()` is called immediately after React component has re-rendered.\r\n\t// That would correspond to `useLayoutEffect()` in React Hooks.\r\n\tcomponentDidUpdate(prevProps, prevState) {\r\n\t\t// If `state` did change.\r\n\t\tif (this.state !== prevState) {\r\n\t\t\tthis.didUpdateState(prevState)\r\n\t\t}\r\n\t\t// If `items` property did change then update `virtual-scroller` items.\r\n\t\t// This could have been done in `.render()` but `.setItems()` calls\r\n\t\t// `.setState()` internally which would result in React throwing an error.\r\n\t\tconst {\r\n\t\t\titems,\r\n\t\t\tpreserveScrollPosition,\r\n\t\t\tpreserveScrollPositionOnPrependItems\r\n\t\t} = this.props\r\n\t\tif (items !== prevProps.items) {\r\n\t\t\tthis.virtualScroller.setItems(items, {\r\n\t\t\t\t// `preserveScrollPosition` property name is deprecated,\r\n\t\t\t\t// use `preserveScrollPositionOnPrependItems` instead.\r\n\t\t\t\tpreserveScrollPositionOnPrependItems: preserveScrollPositionOnPrependItems || preserveScrollPosition\r\n\t\t\t})\r\n\t\t}\r\n\t}\r\n\r\n\tcomponentWillUnmount() {\r\n\t\tthis._isMounted = false\r\n\t\t// Stop listening to scroll events.\r\n\t\tthis.virtualScroller.stop()\r\n\t}\r\n\r\n\trender() {\r\n\t\tconst {\r\n\t\t\tas: AsComponent,\r\n\t\t\titemComponent: Component,\r\n\t\t\titemComponentProps,\r\n\t\t\t// Rest\r\n\t\t\titems: _items,\r\n\t\t\testimatedItemHeight,\r\n\t\t\tbypass,\r\n\t\t\t// bypassBatchSize,\r\n\t\t\tpreserveScrollPositionOnPrependItems,\r\n\t\t\t// `preserveScrollPosition` property name is deprecated,\r\n\t\t\t// use `preserveScrollPositionOnPrependItems` instead.\r\n\t\t\tpreserveScrollPosition,\r\n\t\t\tinitialScrollPosition,\r\n\t\t\tonScrollPositionChange,\r\n\t\t\tmeasureItemsBatchSize,\r\n\t\t\tscrollableContainer,\r\n\t\t\t// `getScrollableContainer` property is deprecated.\r\n\t\t\t// Use `scrollableContainer` instead.\r\n\t\t\tgetScrollableContainer,\r\n\t\t\tgetColumnsCount,\r\n\t\t\tinitialState,\r\n\t\t\tinitialCustomState,\r\n\t\t\tonStateChange,\r\n\t\t\tonItemInitialRender,\r\n\t\t\t// `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.\r\n\t\t\tonItemFirstRender,\r\n\t\t\tgetItemId,\r\n\t\t\tonMount,\r\n\t\t\tclassName,\r\n\t\t\t...rest\r\n\t\t} = this.props\r\n\t\tconst {\r\n\t\t\titems,\r\n\t\t\titemStates,\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex,\r\n\t\t\tbeforeItemsHeight,\r\n\t\t\tafterItemsHeight\r\n\t\t} = this.virtualScroller.getState()\r\n\t\t// If `items` are about to be changed then\r\n\t\t// store the scroll Y position for the first one\r\n\t\t// of the current items.\r\n\t\t// Previously it was being done in `componentDidUpdate()`\r\n\t\t// but it was later found out that it wouldn't work\r\n\t\t// for \"Show previous\" button because it would\r\n\t\t// get hidden before `componentDidUpdate()` is called.\r\n\t\t//\r\n\t\t// Consider this code example:\r\n\t\t//\r\n\t\t// const { fromIndex, items } = this.state\r\n\t\t// const items = allItems.slice(fromIndex)\r\n\t\t// return (\r\n\t\t// \t{fromIndex > 0 &&\r\n\t\t// \t\t<button onClick={this.onShowPrevious}>\r\n\t\t// \t\t\tShow previous\r\n\t\t// \t\t</button>\r\n\t\t// \t}\r\n\t\t// \t<VirtualScroller\r\n\t\t// \t\titems={items}\r\n\t\t// \t\titemComponent={ItemComponent}/>\r\n\t\t// )\r\n\t\t//\r\n\t\t// Consider a user clicks \"Show previous\" to show the items from the start.\r\n\t\t// By the time `componentDidUpdate()` is called on `<VirtualScroller/>`,\r\n\t\t// the \"Show previous\" button has already been hidden\r\n\t\t// (because there're no more \"previous\" items)\r\n\t\t// which results in the scroll Y position jumping forward\r\n\t\t// by the height of that \"Show previous\" button.\r\n\t\t// This is because `<VirtualScroller/>` captures scroll Y\r\n\t\t// position when items are prepended via `.setItems()`\r\n\t\t// when the \"Show previous\" button is still being shown,\r\n\t\t// and then restores scroll Y position in `.didUpdateState()`\r\n\t\t// when the \"Show previous\" button has already been hidden:\r\n\t\t// that's the reason for the scroll Y \"jump\".\r\n\t\t//\r\n\t\t// To prevent that, scroll Y position is captured at `render()`\r\n\t\t// time rather than later in `componentDidUpdate()`: this way,\r\n\t\t// scroll Y position is captured while the \"Show previous\" button\r\n\t\t// is still being shown.\r\n\t\t//\r\n\t\tconst newItems = this.props.items\r\n\t\tconst previousItems = items // this.virtualScroller.getState().items\r\n\t\t// There's one case when `newItems !== previousItems` is `true`\r\n\t\t// from the start: when `initialState.items` are passed.\r\n\t\t// To handle that single case `this.previousItemsProperty`\r\n\t\t// is tracked and `this.itemsPropertyHasChanged` flag is set.\r\n\t\tif (!this.itemsPropertyWasChanged) {\r\n\t\t\tthis.itemsPropertyWasChanged = this.props.items !== this.previousItemsProperty\r\n\t\t}\r\n\t\tthis.previousItemsProperty = this.props.items\r\n\t\tif (this.itemsPropertyWasChanged && newItems !== previousItems) {\r\n\t\t\tconst itemsDiff = this.virtualScroller.getItemsDiff(previousItems, newItems)\r\n\t\t\tif (itemsDiff && itemsDiff.prependedItemsCount === 0 && itemsDiff.appendedItemsCount > 0) {\r\n\t\t\t\t// If it's just items that have been appended\r\n\t\t\t\t// then no need to re-generate the prefix\r\n\t\t\t\t// and to fix scroll position and to clear caches.\r\n\t\t\t} else {\r\n\t\t\t\t// If the items update was incremental, then it's possible\r\n\t\t\t\t// that some items were prepended, and so the scroll Y position\r\n\t\t\t\t// should be restored after rendering those new items\r\n\t\t\t\t// in order for the currently shown items to stay\r\n\t\t\t\t// on the same position on screen.\r\n\t\t\t\t// (only if explicitly opted into using this feature)\r\n\t\t\t\t//\r\n\t\t\t\t// If the items update wasn't incremental\r\n\t\t\t\t// then there's no point in restoring scroll position.\r\n\t\t\t\t//\r\n\t\t\t\t// `preserveScrollPosition` property name is deprecated,\r\n\t\t\t\t// use `preserveScrollPositionOnPrependItems` instead.\r\n\t\t\t\t//\r\n\t\t\t\tif (itemsDiff) {\r\n\t\t\t\t\tconst { prependedItemsCount } = itemsDiff\r\n\t\t\t\t\tif (prependedItemsCount > 0) {\r\n\t\t\t\t\t\tif (preserveScrollPositionOnPrependItems || preserveScrollPosition) {\r\n\t\t\t\t\t\t\tif (firstShownItemIndex === 0) {\r\n\t\t\t\t\t\t\t\tthis.virtualScroller.listHeightChangeWatcher.snapshot({\r\n\t\t\t\t\t\t\t\t\tpreviousItems,\r\n\t\t\t\t\t\t\t\t\tnewItems,\r\n\t\t\t\t\t\t\t\t\tprependedItemsCount\r\n\t\t\t\t\t\t\t\t})\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\t// Reset the unique `key` prefix for item component keys.\r\n\t\t\t\tif (!getItemId) {\r\n\t\t\t\t\tthis.generateItemKeyPrefix()\r\n\t\t\t\t}\r\n\t\t\t\t// Reset item refs.\r\n\t\t\t\tthis.itemRefs = new Array(newItems.length)\r\n\t\t\t}\r\n\t\t}\r\n\t\tconst tbody = this.virtualScroller.tbody\r\n\t\treturn (\r\n\t\t\t<AsComponent\r\n\t\t\t\t{...rest}\r\n\t\t\t\tref={this.container}\r\n\t\t\t\tclassName={tbody ? (className ? className + ' ' + 'VirtualScroller' : 'VirtualScroller') : className}\r\n\t\t\t\tstyle={{\r\n\t\t\t\t\tpaddingTop: tbody ? undefined : px(beforeItemsHeight),\r\n\t\t\t\t\tpaddingBottom: tbody ? undefined : px(afterItemsHeight)\r\n\t\t\t\t}}>\r\n\t\t\t\t{items.map((item, i) => {\r\n\t\t\t\t\tif (i >= firstShownItemIndex && i <= lastShownItemIndex) {\r\n\t\t\t\t\t\treturn (\r\n\t\t\t\t\t\t\t<Component\r\n\t\t\t\t\t\t\t\t{...itemComponentProps}\r\n\t\t\t\t\t\t\t\tkey={this.getItemKey(item, i)}\r\n\t\t\t\t\t\t\t\tref={this.shouldUseRefs() ? this.getItemRef(i) : undefined}\r\n\t\t\t\t\t\t\t\tstate={itemStates && itemStates[i]}\r\n\t\t\t\t\t\t\t\tonStateChange={this.getOnItemStateChange(i)}\r\n\t\t\t\t\t\t\t\tonHeightChange={this.getOnItemHeightChange(i)}>\r\n\t\t\t\t\t\t\t\t{item}\r\n\t\t\t\t\t\t\t</Component>\r\n\t\t\t\t\t\t)\r\n\t\t\t\t\t}\r\n\t\t\t\t\treturn null\r\n\t\t\t\t})}\r\n\t\t\t</AsComponent>\r\n\t\t)\r\n\t}\r\n}\r\n\r\n/**\r\n * Checks if the argument is a `React.Component` class.\r\n * https://overreacted.io/how-does-react-tell-a-class-from-a-function/\r\n * @param {any} Component\r\n * @return {object} [result] Returns `undefined` if it's not a `React.Component`. Returns an empty object if it's a `React.Component` (`.isReactComponent` is an empty object).\r\n */\r\nfunction isComponentClass(Component) {\r\n\t// return Component.prototype instanceof React.Component\r\n\t// `React.memo()` returns `.prototype === undefined` for some reason.\r\n\treturn Component.prototype && Component.prototype.isReactComponent\r\n}\r\n"],"file":"VirtualScroller.js"}
|
|
@@ -16,9 +16,15 @@ var _requestAnimationFrameTimeout = require("request-animation-frame-timeout");
|
|
|
16
16
|
* Same as `lodash`'s `debounce()` for functions with no arguments.
|
|
17
17
|
* @param {function} func
|
|
18
18
|
* @param {number} interval
|
|
19
|
+
* @param {function} [options.onStart]
|
|
20
|
+
* @param {function} [options.onStop]
|
|
19
21
|
* @return {function}
|
|
20
22
|
*/
|
|
21
23
|
function debounce(func, interval) {
|
|
24
|
+
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
25
|
+
onStart = _ref.onStart,
|
|
26
|
+
onStop = _ref.onStop;
|
|
27
|
+
|
|
22
28
|
var timeout;
|
|
23
29
|
return function () {
|
|
24
30
|
var _this = this;
|
|
@@ -27,10 +33,26 @@ function debounce(func, interval) {
|
|
|
27
33
|
args[_key] = arguments[_key];
|
|
28
34
|
}
|
|
29
35
|
|
|
30
|
-
(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
return new Promise(function (resolve) {
|
|
37
|
+
if (timeout) {
|
|
38
|
+
(0, _requestAnimationFrameTimeout.clearTimeout)(timeout);
|
|
39
|
+
} else {
|
|
40
|
+
if (onStart) {
|
|
41
|
+
onStart();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
timeout = (0, _requestAnimationFrameTimeout.setTimeout)(function () {
|
|
46
|
+
timeout = undefined;
|
|
47
|
+
|
|
48
|
+
if (onStop) {
|
|
49
|
+
onStop();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
func.apply(_this, args);
|
|
53
|
+
resolve();
|
|
54
|
+
}, interval);
|
|
55
|
+
});
|
|
34
56
|
};
|
|
35
57
|
}
|
|
36
58
|
//# sourceMappingURL=debounce.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../source/utility/debounce.js"],"names":["debounce","func","interval","timeout","args","apply"],"mappings":";;;;;;;AAIA;;AAJA;AACA;AACA;AACA;;AAGA
|
|
1
|
+
{"version":3,"sources":["../../source/utility/debounce.js"],"names":["debounce","func","interval","onStart","onStop","timeout","args","Promise","resolve","undefined","apply"],"mappings":";;;;;;;AAIA;;AAJA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,QAAT,CAAkBC,IAAlB,EAAwBC,QAAxB,EAA4D;AAAA,iFAAJ,EAAI;AAAA,MAAxBC,OAAwB,QAAxBA,OAAwB;AAAA,MAAfC,MAAe,QAAfA,MAAe;;AAC1E,MAAIC,OAAJ;AACA,SAAO,YAAkB;AAAA;;AAAA,sCAANC,IAAM;AAANA,MAAAA,IAAM;AAAA;;AACxB,WAAO,IAAIC,OAAJ,CAAY,UAACC,OAAD,EAAa;AAC/B,UAAIH,OAAJ,EAAa;AACZ,wDAAaA,OAAb;AACA,OAFD,MAEO;AACN,YAAIF,OAAJ,EAAa;AACZA,UAAAA,OAAO;AACP;AACD;;AACDE,MAAAA,OAAO,GAAG,8CAAW,YAAM;AAC1BA,QAAAA,OAAO,GAAGI,SAAV;;AACA,YAAIL,MAAJ,EAAY;AACXA,UAAAA,MAAM;AACN;;AACDH,QAAAA,IAAI,CAACS,KAAL,CAAW,KAAX,EAAiBJ,IAAjB;AACAE,QAAAA,OAAO;AACP,OAPS,EAOPN,QAPO,CAAV;AAQA,KAhBM,CAAP;AAiBA,GAlBD;AAmBA","sourcesContent":["// For some weird reason, in Chrome, `setTimeout()` would lag up to a second (or more) behind.\r\n// Turns out, Chrome developers have deprecated `setTimeout()` API entirely without asking anyone.\r\n// Replacing `setTimeout()` with `requestAnimationFrame()` can work around that Chrome bug.\r\n// https://github.com/bvaughn/react-virtualized/issues/722\r\nimport { setTimeout, clearTimeout } from 'request-animation-frame-timeout'\r\n\r\n/**\r\n * Same as `lodash`'s `debounce()` for functions with no arguments.\r\n * @param {function} func\r\n * @param {number} interval\r\n * @param {function} [options.onStart]\r\n * @param {function} [options.onStop]\r\n * @return {function}\r\n */\r\nexport default function debounce(func, interval, { onStart, onStop } = {}) {\r\n\tlet timeout\r\n\treturn function(...args) {\r\n\t\treturn new Promise((resolve) => {\r\n\t\t\tif (timeout) {\r\n\t\t\t\tclearTimeout(timeout)\r\n\t\t\t} else {\r\n\t\t\t\tif (onStart) {\r\n\t\t\t\t\tonStart()\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\ttimeout = setTimeout(() => {\r\n\t\t\t\ttimeout = undefined\r\n\t\t\t\tif (onStop) {\r\n\t\t\t\t\tonStop()\r\n\t\t\t\t}\r\n\t\t\t\tfunc.apply(this, args)\r\n\t\t\t\tresolve()\r\n\t\t\t}, interval)\r\n\t\t})\r\n\t}\r\n}\r\n"],"file":"debounce.js"}
|
|
@@ -4,17 +4,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = log;
|
|
7
|
-
exports.warn = warn;
|
|
8
|
-
exports.reportError = reportError;
|
|
9
7
|
exports.isDebug = isDebug;
|
|
8
|
+
exports.isWarn = isWarn;
|
|
9
|
+
exports.reportError = reportError;
|
|
10
|
+
exports.warn = warn;
|
|
11
|
+
|
|
12
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
13
|
+
|
|
14
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
15
|
|
|
11
|
-
function
|
|
16
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
12
17
|
|
|
13
|
-
function
|
|
18
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
14
19
|
|
|
15
|
-
function
|
|
20
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
16
21
|
|
|
17
|
-
function
|
|
22
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
18
23
|
|
|
19
24
|
function log() {
|
|
20
25
|
if (isDebug()) {
|
|
@@ -29,13 +34,19 @@ function log() {
|
|
|
29
34
|
}
|
|
30
35
|
|
|
31
36
|
function warn() {
|
|
32
|
-
|
|
37
|
+
if (isWarn()) {
|
|
38
|
+
var _console2;
|
|
33
39
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
41
|
+
args[_key2] = arguments[_key2];
|
|
42
|
+
}
|
|
37
43
|
|
|
38
|
-
|
|
44
|
+
if (warningsAreErrors()) {
|
|
45
|
+
return reportError.apply(this, args);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
(_console2 = console).warn.apply(_console2, _toConsumableArray(['[virtual-scroller]'].concat(args)));
|
|
49
|
+
}
|
|
39
50
|
}
|
|
40
51
|
|
|
41
52
|
function reportError() {
|
|
@@ -66,8 +77,36 @@ function reportError() {
|
|
|
66
77
|
}
|
|
67
78
|
|
|
68
79
|
function isDebug() {
|
|
80
|
+
var debug = getDebug();
|
|
81
|
+
|
|
82
|
+
if (debug !== undefined) {
|
|
83
|
+
return debug === true || debug === 'debug';
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function isWarn() {
|
|
88
|
+
// const debug = getDebug()
|
|
89
|
+
// return debug === undefined
|
|
90
|
+
// || debug === true
|
|
91
|
+
// || debug === 'debug'
|
|
92
|
+
// || debug === 'warn'
|
|
93
|
+
//
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function getDebug() {
|
|
98
|
+
return getGlobalVariable('VirtualScrollerDebug');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function warningsAreErrors() {
|
|
102
|
+
return getGlobalVariable('VirtualScrollerWarningsAreErrors');
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function getGlobalVariable(name) {
|
|
69
106
|
if (typeof window !== 'undefined') {
|
|
70
|
-
return window
|
|
107
|
+
return window[name];
|
|
108
|
+
} else if (typeof global !== 'undefined') {
|
|
109
|
+
return global[name];
|
|
71
110
|
}
|
|
72
111
|
}
|
|
73
112
|
//# sourceMappingURL=debug.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../source/utility/debug.js"],"names":["log","isDebug","args","console","concat","warn","
|
|
1
|
+
{"version":3,"sources":["../../source/utility/debug.js"],"names":["log","isDebug","args","console","concat","warn","isWarn","warningsAreErrors","reportError","apply","window","setTimeout","Error","join","error","debug","getDebug","undefined","getGlobalVariable","name","global"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAe,SAASA,GAAT,GAAsB;AACpC,MAAIC,OAAO,EAAX,EAAe;AAAA;;AAAA,sCADeC,IACf;AADeA,MAAAA,IACf;AAAA;;AACd,gBAAAC,OAAO,EAACH,GAAR,oCAAe,CAAC,oBAAD,EAAuBI,MAAvB,CAA8BF,IAA9B,CAAf;AACA;AACD;;AAEM,SAASG,IAAT,GAAuB;AAC7B,MAAIC,MAAM,EAAV,EAAc;AAAA;;AAAA,uCADSJ,IACT;AADSA,MAAAA,IACT;AAAA;;AACb,QAAIK,iBAAiB,EAArB,EAAyB;AACxB,aAAOC,WAAW,CAACC,KAAZ,CAAkB,IAAlB,EAAwBP,IAAxB,CAAP;AACA;;AACD,iBAAAC,OAAO,EAACE,IAAR,qCAAgB,CAAC,oBAAD,EAAuBD,MAAvB,CAA8BF,IAA9B,CAAhB;AACA;AACD;;AAEM,SAASM,WAAT,GAA8B;AAAA,qCAANN,IAAM;AAANA,IAAAA,IAAM;AAAA;;AACpC,MAAI,OAAOQ,MAAP,KAAkB,WAAtB,EAAmC;AAClC;AACA;AACA;AACAV,IAAAA,GAAG,CAACS,KAAJ,CAAU,IAAV,EAAgB,CAAC,OAAD,EAAUL,MAAV,CAAiBF,IAAjB,CAAhB;AACAS,IAAAA,UAAU,CAAC,YAAM;AAChB;AACA;AACA;AACA;AACA;AACA;AACA,YAAM,IAAIC,KAAJ,CAAU,CAAC,oBAAD,EAAuBR,MAAvB,CAA8BF,IAA9B,EAAoCW,IAApC,CAAyC,GAAzC,CAAV,CAAN;AACA,KARS,EAQP,CARO,CAAV;AASA,GAdD,MAcO;AAAA;;AACN;AACA,iBAAAV,OAAO,EAACW,KAAR,qCAAiB,CAAC,oBAAD,EAAuBV,MAAvB,CAA8BF,IAA9B,CAAjB;AACA;AACD;;AAEM,SAASD,OAAT,GAAmB;AACzB,MAAMc,KAAK,GAAGC,QAAQ,EAAtB;;AACA,MAAID,KAAK,KAAKE,SAAd,EAAyB;AACxB,WAAOF,KAAK,KAAK,IAAV,IAAkBA,KAAK,KAAK,OAAnC;AACA;AACD;;AAEM,SAAST,MAAT,GAAkB;AACxB;AACA;AACA;AACA;AACA;AACA;AACA,SAAO,IAAP;AACA;;AAED,SAASU,QAAT,GAAoB;AACnB,SAAOE,iBAAiB,CAAC,sBAAD,CAAxB;AACA;;AAED,SAASX,iBAAT,GAA6B;AAC5B,SAAOW,iBAAiB,CAAC,kCAAD,CAAxB;AACA;;AAED,SAASA,iBAAT,CAA2BC,IAA3B,EAAiC;AAChC,MAAI,OAAOT,MAAP,KAAkB,WAAtB,EAAmC;AAClC,WAAOA,MAAM,CAACS,IAAD,CAAb;AACA,GAFD,MAEO,IAAI,OAAOC,MAAP,KAAkB,WAAtB,EAAmC;AACzC,WAAOA,MAAM,CAACD,IAAD,CAAb;AACA;AACD","sourcesContent":["export default function log(...args) {\r\n\tif (isDebug()) {\r\n\t\tconsole.log(...['[virtual-scroller]'].concat(args))\r\n\t}\r\n}\r\n\r\nexport function warn(...args) {\r\n\tif (isWarn()) {\r\n\t\tif (warningsAreErrors()) {\r\n\t\t\treturn reportError.apply(this, args)\r\n\t\t}\r\n\t\tconsole.warn(...['[virtual-scroller]'].concat(args))\r\n\t}\r\n}\r\n\r\nexport function reportError(...args) {\r\n\tif (typeof window !== 'undefined') {\r\n\t\t// In a web browser.\r\n\t\t// Output a debug message immediately so that it's known\r\n\t\t// at which point did the error occur between other debug logs.\r\n\t\tlog.apply(this, ['ERROR'].concat(args))\r\n\t\tsetTimeout(() => {\r\n\t\t\t// Throw an error in a timeout so that it doesn't interrupt the application's flow.\r\n\t\t\t// At the same time, by throwing a client-side error, such error could be spotted\r\n\t\t\t// in some error monitoring software like `sentry.io`, while also being visible\r\n\t\t\t// in the console.\r\n\t\t\t// The `.join(' ')` part doesn't support stringifying JSON objects,\r\n\t\t\t// but those don't seem to be used in any of the error messages.\r\n\t\t\tthrow new Error(['[virtual-scroller]'].concat(args).join(' '))\r\n\t\t}, 0)\r\n\t} else {\r\n\t\t// On a server.\r\n\t\tconsole.error(...['[virtual-scroller]'].concat(args))\r\n\t}\r\n}\r\n\r\nexport function isDebug() {\r\n\tconst debug = getDebug()\r\n\tif (debug !== undefined) {\r\n\t\treturn debug === true || debug === 'debug'\r\n\t}\r\n}\r\n\r\nexport function isWarn() {\r\n\t// const debug = getDebug()\r\n\t// return debug === undefined\r\n\t// \t|| debug === true\r\n\t// \t|| debug === 'debug'\r\n\t// \t|| debug === 'warn'\r\n\t//\r\n\treturn true\r\n}\r\n\r\nfunction getDebug() {\r\n\treturn getGlobalVariable('VirtualScrollerDebug')\r\n}\r\n\r\nfunction warningsAreErrors() {\r\n\treturn getGlobalVariable('VirtualScrollerWarningsAreErrors')\r\n}\r\n\r\nfunction getGlobalVariable(name) {\r\n\tif (typeof window !== 'undefined') {\r\n\t\treturn window[name]\r\n\t} else if (typeof global !== 'undefined') {\r\n\t\treturn global[name]\r\n\t}\r\n}"],"file":"debug.js"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = getStateSnapshot;
|
|
7
|
+
|
|
8
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
9
|
+
|
|
10
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
11
|
+
|
|
12
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
+
|
|
14
|
+
// Creates a snapshot of a `state` or a partial update of a `state`.
|
|
15
|
+
// Is only used for logging state snapshots for later debug.
|
|
16
|
+
//
|
|
17
|
+
// When `state` is output to the browser console via `console.log()`,
|
|
18
|
+
// it is explorable in real time. That also means that if that `state`
|
|
19
|
+
// is modified later, the user will see the modified state, not the
|
|
20
|
+
// original one. In the current implementation, `state` is not strictly
|
|
21
|
+
// "immutable": things like individual item heights (including "before resize" ones)
|
|
22
|
+
// or states are updated in-place — `state.itemHeights[i] = newItemHeight` or
|
|
23
|
+
// `state.itemStates[i] = newItemState`. That's because those `state` properties
|
|
24
|
+
// are the ones that don’t affect the presentation, so there's no need to re-render
|
|
25
|
+
// the list when those do change — updating those properties is just an effect of
|
|
26
|
+
// some change rather than cause for one.
|
|
27
|
+
//
|
|
28
|
+
// So, when outputting `state` via `console.log()` for debug, it makes sense to
|
|
29
|
+
// snapshot it so that the developer, while debugging later, sees the correct
|
|
30
|
+
// item heights or item states.
|
|
31
|
+
//
|
|
32
|
+
function getStateSnapshot(state) {
|
|
33
|
+
var stateSnapshot = _objectSpread({}, state);
|
|
34
|
+
|
|
35
|
+
if (state.itemHeights) {
|
|
36
|
+
stateSnapshot.itemHeights = state.itemHeights.slice();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (state.itemStates) {
|
|
40
|
+
stateSnapshot.itemStates = state.itemStates.slice();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (state.beforeResize) {
|
|
44
|
+
stateSnapshot.beforeResize = _objectSpread({}, state.beforeResize);
|
|
45
|
+
stateSnapshot.beforeResize.itemHeights = state.beforeResize.itemHeights.slice();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return stateSnapshot;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=getStateSnapshot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../source/utility/getStateSnapshot.js"],"names":["getStateSnapshot","state","stateSnapshot","itemHeights","slice","itemStates","beforeResize"],"mappings":";;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,gBAAT,CAA0BC,KAA1B,EAAiC;AAC/C,MAAIC,aAAa,qBACbD,KADa,CAAjB;;AAGA,MAAIA,KAAK,CAACE,WAAV,EAAuB;AACtBD,IAAAA,aAAa,CAACC,WAAd,GAA4BF,KAAK,CAACE,WAAN,CAAkBC,KAAlB,EAA5B;AACA;;AACD,MAAIH,KAAK,CAACI,UAAV,EAAsB;AACrBH,IAAAA,aAAa,CAACG,UAAd,GAA2BJ,KAAK,CAACI,UAAN,CAAiBD,KAAjB,EAA3B;AACA;;AACD,MAAIH,KAAK,CAACK,YAAV,EAAwB;AACvBJ,IAAAA,aAAa,CAACI,YAAd,qBACIL,KAAK,CAACK,YADV;AAGAJ,IAAAA,aAAa,CAACI,YAAd,CAA2BH,WAA3B,GAAyCF,KAAK,CAACK,YAAN,CAAmBH,WAAnB,CAA+BC,KAA/B,EAAzC;AACA;;AACD,SAAOF,aAAP;AACA","sourcesContent":["// Creates a snapshot of a `state` or a partial update of a `state`.\r\n// Is only used for logging state snapshots for later debug.\r\n//\r\n// When `state` is output to the browser console via `console.log()`,\r\n// it is explorable in real time. That also means that if that `state`\r\n// is modified later, the user will see the modified state, not the\r\n// original one. In the current implementation, `state` is not strictly\r\n// \"immutable\": things like individual item heights (including \"before resize\" ones)\r\n// or states are updated in-place — `state.itemHeights[i] = newItemHeight` or\r\n// `state.itemStates[i] = newItemState`. That's because those `state` properties\r\n// are the ones that don’t affect the presentation, so there's no need to re-render\r\n// the list when those do change — updating those properties is just an effect of\r\n// some change rather than cause for one.\r\n//\r\n// So, when outputting `state` via `console.log()` for debug, it makes sense to\r\n// snapshot it so that the developer, while debugging later, sees the correct\r\n// item heights or item states.\r\n//\r\nexport default function getStateSnapshot(state) {\r\n\tlet stateSnapshot = {\r\n\t\t...state\r\n\t}\r\n\tif (state.itemHeights) {\r\n\t\tstateSnapshot.itemHeights = state.itemHeights.slice()\r\n\t}\r\n\tif (state.itemStates) {\r\n\t\tstateSnapshot.itemStates = state.itemStates.slice()\r\n\t}\r\n\tif (state.beforeResize) {\r\n\t\tstateSnapshot.beforeResize = {\r\n\t\t\t...state.beforeResize\r\n\t\t}\r\n\t\tstateSnapshot.beforeResize.itemHeights = state.beforeResize.itemHeights.slice()\r\n\t}\r\n\treturn stateSnapshot\r\n}"],"file":"getStateSnapshot.js"}
|