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.
Files changed (153) hide show
  1. package/CHANGELOG.md +29 -1
  2. package/README.md +139 -33
  3. package/babel.config.js +25 -0
  4. package/babel.js +5 -0
  5. package/bundle/index-bypass.html +1 -1
  6. package/bundle/index-dom.html +1 -1
  7. package/bundle/index-grid.html +1 -2
  8. package/bundle/index-scrollableContainer.html +1 -1
  9. package/bundle/index-tbody-scrollableContainer.html +2 -0
  10. package/bundle/index-tbody.html +2 -0
  11. package/bundle/virtual-scroller-dom.js +1 -1
  12. package/bundle/virtual-scroller-dom.js.map +1 -1
  13. package/bundle/virtual-scroller-react.js +1 -1
  14. package/bundle/virtual-scroller-react.js.map +1 -1
  15. package/bundle/virtual-scroller.js +1 -1
  16. package/bundle/virtual-scroller.js.map +1 -1
  17. package/commonjs/BeforeResize.js +319 -0
  18. package/commonjs/BeforeResize.js.map +1 -0
  19. package/commonjs/DOM/Engine.js +46 -0
  20. package/commonjs/DOM/Engine.js.map +1 -0
  21. package/commonjs/DOM/ItemsContainer.js +78 -0
  22. package/commonjs/DOM/ItemsContainer.js.map +1 -0
  23. package/commonjs/DOM/{WaitForStylesToLoad.js → ListTopOffsetWatcher.js} +56 -35
  24. package/commonjs/DOM/ListTopOffsetWatcher.js.map +1 -0
  25. package/commonjs/DOM/ScrollableContainer.js +56 -81
  26. package/commonjs/DOM/ScrollableContainer.js.map +1 -1
  27. package/commonjs/DOM/VirtualScroller.js +20 -15
  28. package/commonjs/DOM/VirtualScroller.js.map +1 -1
  29. package/commonjs/DOM/tbody.js +2 -2
  30. package/commonjs/ItemHeights.js +13 -20
  31. package/commonjs/ItemHeights.js.map +1 -1
  32. package/commonjs/Layout.js +588 -215
  33. package/commonjs/Layout.js.map +1 -1
  34. package/commonjs/Layout.test.js +191 -0
  35. package/commonjs/Layout.test.js.map +1 -0
  36. package/commonjs/ListHeightChangeWatcher.js +126 -0
  37. package/commonjs/ListHeightChangeWatcher.js.map +1 -0
  38. package/commonjs/Resize.js +22 -21
  39. package/commonjs/Resize.js.map +1 -1
  40. package/commonjs/Scroll.js +148 -88
  41. package/commonjs/Scroll.js.map +1 -1
  42. package/commonjs/VirtualScroller.js +1269 -390
  43. package/commonjs/VirtualScroller.js.map +1 -1
  44. package/commonjs/getItemCoordinates.js.map +1 -1
  45. package/commonjs/getItemsDiff.js.map +1 -1
  46. package/commonjs/getVerticalSpacing.js +8 -8
  47. package/commonjs/getVerticalSpacing.js.map +1 -1
  48. package/commonjs/react/VirtualScroller.js +31 -37
  49. package/commonjs/react/VirtualScroller.js.map +1 -1
  50. package/commonjs/utility/debounce.js +26 -4
  51. package/commonjs/utility/debounce.js.map +1 -1
  52. package/commonjs/utility/debug.js +51 -12
  53. package/commonjs/utility/debug.js.map +1 -1
  54. package/commonjs/utility/getStateSnapshot.js +50 -0
  55. package/commonjs/utility/getStateSnapshot.js.map +1 -0
  56. package/commonjs/utility/px.js +1 -1
  57. package/commonjs/utility/px.js.map +1 -1
  58. package/commonjs/utility/px.test.js +14 -0
  59. package/commonjs/utility/px.test.js.map +1 -0
  60. package/commonjs/utility/shallowEqual.js +1 -1
  61. package/commonjs/utility/shallowEqual.js.map +1 -1
  62. package/commonjs/utility/throttle.js.map +1 -1
  63. package/dom/index.d.ts +23 -0
  64. package/index.d.ts +84 -0
  65. package/modules/BeforeResize.js +310 -0
  66. package/modules/BeforeResize.js.map +1 -0
  67. package/modules/DOM/Engine.js +27 -0
  68. package/modules/DOM/Engine.js.map +1 -0
  69. package/modules/DOM/ItemsContainer.js +71 -0
  70. package/modules/DOM/ItemsContainer.js.map +1 -0
  71. package/modules/DOM/{WaitForStylesToLoad.js → ListTopOffsetWatcher.js} +57 -35
  72. package/modules/DOM/ListTopOffsetWatcher.js.map +1 -0
  73. package/modules/DOM/ScrollableContainer.js +55 -80
  74. package/modules/DOM/ScrollableContainer.js.map +1 -1
  75. package/modules/DOM/VirtualScroller.js +15 -14
  76. package/modules/DOM/VirtualScroller.js.map +1 -1
  77. package/modules/ItemHeights.js +8 -19
  78. package/modules/ItemHeights.js.map +1 -1
  79. package/modules/Layout.js +582 -213
  80. package/modules/Layout.js.map +1 -1
  81. package/modules/Layout.test.js +185 -0
  82. package/modules/Layout.test.js.map +1 -0
  83. package/modules/ListHeightChangeWatcher.js +119 -0
  84. package/modules/ListHeightChangeWatcher.js.map +1 -0
  85. package/modules/Resize.js +21 -20
  86. package/modules/Resize.js.map +1 -1
  87. package/modules/Scroll.js +148 -87
  88. package/modules/Scroll.js.map +1 -1
  89. package/modules/VirtualScroller.js +1263 -390
  90. package/modules/VirtualScroller.js.map +1 -1
  91. package/modules/getItemCoordinates.js.map +1 -1
  92. package/modules/getItemsDiff.js.map +1 -1
  93. package/modules/getVerticalSpacing.js +8 -8
  94. package/modules/getVerticalSpacing.js.map +1 -1
  95. package/modules/react/VirtualScroller.js +31 -37
  96. package/modules/react/VirtualScroller.js.map +1 -1
  97. package/modules/utility/debounce.js +26 -4
  98. package/modules/utility/debounce.js.map +1 -1
  99. package/modules/utility/debug.js +47 -10
  100. package/modules/utility/debug.js.map +1 -1
  101. package/modules/utility/getStateSnapshot.js +43 -0
  102. package/modules/utility/getStateSnapshot.js.map +1 -0
  103. package/modules/utility/px.js +1 -1
  104. package/modules/utility/px.js.map +1 -1
  105. package/modules/utility/px.test.js +9 -0
  106. package/modules/utility/px.test.js.map +1 -0
  107. package/modules/utility/shallowEqual.js +1 -1
  108. package/modules/utility/shallowEqual.js.map +1 -1
  109. package/modules/utility/throttle.js.map +1 -1
  110. package/package.json +24 -22
  111. package/react/index.d.ts +27 -0
  112. package/source/BeforeResize.js +317 -0
  113. package/source/DOM/Engine.js +32 -0
  114. package/source/DOM/ItemsContainer.js +48 -0
  115. package/source/DOM/{WaitForStylesToLoad.js → ListTopOffsetWatcher.js} +48 -22
  116. package/source/DOM/ScrollableContainer.js +39 -56
  117. package/source/DOM/VirtualScroller.js +6 -7
  118. package/source/ItemHeights.js +10 -15
  119. package/source/Layout.js +626 -252
  120. package/source/Layout.test.js +171 -0
  121. package/source/ListHeightChangeWatcher.js +94 -0
  122. package/source/Resize.js +23 -15
  123. package/source/Scroll.js +139 -78
  124. package/source/VirtualScroller.js +1240 -286
  125. package/source/getVerticalSpacing.js +7 -7
  126. package/source/react/VirtualScroller.js +2 -18
  127. package/source/utility/debounce.js +20 -3
  128. package/source/utility/debug.js +34 -3
  129. package/source/utility/getStateSnapshot.js +36 -0
  130. package/source/utility/px.js +1 -1
  131. package/source/utility/px.test.js +9 -0
  132. package/website/index-bypass.html +195 -0
  133. package/website/index-grid.html +0 -1
  134. package/website/index-scrollableContainer.html +208 -0
  135. package/website/index-tbody-scrollableContainer.html +68 -0
  136. package/website/index-tbody.html +55 -0
  137. package/commonjs/DOM/RenderingEngine.js +0 -33
  138. package/commonjs/DOM/RenderingEngine.js.map +0 -1
  139. package/commonjs/DOM/Screen.js +0 -87
  140. package/commonjs/DOM/Screen.js.map +0 -1
  141. package/commonjs/DOM/WaitForStylesToLoad.js.map +0 -1
  142. package/commonjs/RestoreScroll.js +0 -118
  143. package/commonjs/RestoreScroll.js.map +0 -1
  144. package/modules/DOM/RenderingEngine.js +0 -19
  145. package/modules/DOM/RenderingEngine.js.map +0 -1
  146. package/modules/DOM/Screen.js +0 -80
  147. package/modules/DOM/Screen.js.map +0 -1
  148. package/modules/DOM/WaitForStylesToLoad.js.map +0 -1
  149. package/modules/RestoreScroll.js +0 -111
  150. package/modules/RestoreScroll.js.map +0 -1
  151. package/source/DOM/RenderingEngine.js +0 -22
  152. package/source/DOM/Screen.js +0 -51
  153. package/source/RestoreScroll.js +0 -86
@@ -1,10 +1,12 @@
1
+ var _excluded = ["as", "itemComponent", "itemComponentProps", "items", "estimatedItemHeight", "bypass", "preserveScrollPositionOnPrependItems", "preserveScrollPosition", "initialScrollPosition", "onScrollPositionChange", "measureItemsBatchSize", "scrollableContainer", "getScrollableContainer", "getColumnsCount", "initialState", "initialCustomState", "onStateChange", "onItemInitialRender", "onItemFirstRender", "getItemId", "onMount", "className"];
2
+
1
3
  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); }
2
4
 
3
5
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
4
6
 
5
7
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
6
8
 
7
- 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); }
9
+ 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); }
8
10
 
9
11
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10
12
 
@@ -12,15 +14,19 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
12
14
 
13
15
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
14
16
 
15
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
17
+ 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); }
16
18
 
17
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
19
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
20
+
21
+ 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); }; }
22
+
23
+ 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); }
18
24
 
19
25
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
20
26
 
21
- 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); }
27
+ 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; } }
22
28
 
23
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
29
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
24
30
 
25
31
  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; }
26
32
 
@@ -33,11 +39,19 @@ import px from '../utility/px'; // `PropTypes.elementType` is available in some
33
39
 
34
40
  var elementType = PropTypes.elementType || PropTypes.oneOfType([PropTypes.string, PropTypes.func, PropTypes.object]);
35
41
 
36
- var VirtualScroller =
37
- /*#__PURE__*/
38
- function (_React$Component) {
42
+ var VirtualScroller = /*#__PURE__*/function (_React$Component) {
39
43
  _inherits(VirtualScroller, _React$Component);
40
44
 
45
+ var _super = _createSuper(VirtualScroller);
46
+
47
+ // `this.state` is already reserved for `virtual-scroller`.
48
+ // static getDerivedStateFromProps(props, state) {
49
+ // return {
50
+ // prevProps: {
51
+ // items: props.items
52
+ // }
53
+ // }
54
+ // }
41
55
  // Handler function caches.
42
56
  // Just so that the props passed to `itemComponent`
43
57
  // are not changed on every `.render()` and so
@@ -51,10 +65,10 @@ function (_React$Component) {
51
65
 
52
66
  _classCallCheck(this, VirtualScroller);
53
67
 
54
- _this = _possibleConstructorReturn(this, _getPrototypeOf(VirtualScroller).call(this, props)); // `this.previousItemsProperty` is only used for comparing
68
+ _this = _super.call(this, props); // `this.previousItemsProperty` is only used for comparing
55
69
  // `previousItems` with `newItems` inside `render()`.
56
70
 
57
- _defineProperty(_assertThisInitialized(_this), "container", React.createRef());
71
+ _defineProperty(_assertThisInitialized(_this), "container", /*#__PURE__*/React.createRef());
58
72
 
59
73
  _defineProperty(_assertThisInitialized(_this), "onItemStateChange", new Array(_this.props.items.length));
60
74
 
@@ -110,8 +124,6 @@ function (_React$Component) {
110
124
  initialCustomState = _this$props.initialCustomState,
111
125
  onStateChange = _this$props.onStateChange,
112
126
  estimatedItemHeight = _this$props.estimatedItemHeight,
113
- preserveScrollPositionOfTheBottomOfTheListOnMount = _this$props.preserveScrollPositionOfTheBottomOfTheListOnMount,
114
- preserveScrollPositionAtBottomOnMount = _this$props.preserveScrollPositionAtBottomOnMount,
115
127
  initialScrollPosition = _this$props.initialScrollPosition,
116
128
  onScrollPositionChange = _this$props.onScrollPositionChange,
117
129
  measureItemsBatchSize = _this$props.measureItemsBatchSize,
@@ -131,10 +143,6 @@ function (_React$Component) {
131
143
  onItemInitialRender: this.onItemInitialRender,
132
144
  // `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.
133
145
  onItemFirstRender: this.onItemFirstRender,
134
- preserveScrollPositionOfTheBottomOfTheListOnMount: preserveScrollPositionOfTheBottomOfTheListOnMount,
135
- // `preserveScrollPositionAtBottomOnMount` property name is deprecated,
136
- // use `preserveScrollPositionOfTheBottomOfTheListOnMount` property instead.
137
- preserveScrollPositionAtBottomOnMount: preserveScrollPositionAtBottomOnMount,
138
146
  initialScrollPosition: initialScrollPosition,
139
147
  onScrollPositionChange: onScrollPositionChange,
140
148
  shouldUpdateLayoutOnScreenResize: this.shouldUpdateLayoutOnScreenResize,
@@ -345,7 +353,7 @@ function (_React$Component) {
345
353
  key: "getItemRef",
346
354
  value: function getItemRef(i) {
347
355
  if (!this.itemRefs[i]) {
348
- this.itemRefs[i] = React.createRef();
356
+ this.itemRefs[i] = /*#__PURE__*/React.createRef();
349
357
  }
350
358
 
351
359
  return this.itemRefs[i];
@@ -461,8 +469,6 @@ function (_React$Component) {
461
469
  bypass = _this$props4.bypass,
462
470
  preserveScrollPositionOnPrependItems = _this$props4.preserveScrollPositionOnPrependItems,
463
471
  preserveScrollPosition = _this$props4.preserveScrollPosition,
464
- preserveScrollPositionOfTheBottomOfTheListOnMount = _this$props4.preserveScrollPositionOfTheBottomOfTheListOnMount,
465
- preserveScrollPositionAtBottomOnMount = _this$props4.preserveScrollPositionAtBottomOnMount,
466
472
  initialScrollPosition = _this$props4.initialScrollPosition,
467
473
  onScrollPositionChange = _this$props4.onScrollPositionChange,
468
474
  measureItemsBatchSize = _this$props4.measureItemsBatchSize,
@@ -477,7 +483,7 @@ function (_React$Component) {
477
483
  getItemId = _this$props4.getItemId,
478
484
  onMount = _this$props4.onMount,
479
485
  className = _this$props4.className,
480
- rest = _objectWithoutProperties(_this$props4, ["as", "itemComponent", "itemComponentProps", "items", "estimatedItemHeight", "bypass", "preserveScrollPositionOnPrependItems", "preserveScrollPosition", "preserveScrollPositionOfTheBottomOfTheListOnMount", "preserveScrollPositionAtBottomOnMount", "initialScrollPosition", "onScrollPositionChange", "measureItemsBatchSize", "scrollableContainer", "getScrollableContainer", "getColumnsCount", "initialState", "initialCustomState", "onStateChange", "onItemInitialRender", "onItemFirstRender", "getItemId", "onMount", "className"]);
486
+ rest = _objectWithoutProperties(_this$props4, _excluded);
481
487
 
482
488
  var _this$virtualScroller = this.virtualScroller.getState(),
483
489
  items = _this$virtualScroller.items,
@@ -567,7 +573,7 @@ function (_React$Component) {
567
573
  if (prependedItemsCount > 0) {
568
574
  if (preserveScrollPositionOnPrependItems || preserveScrollPosition) {
569
575
  if (firstShownItemIndex === 0) {
570
- this.virtualScroller.restoreScroll.captureScroll({
576
+ this.virtualScroller.listHeightChangeWatcher.snapshot({
571
577
  previousItems: previousItems,
572
578
  newItems: newItems,
573
579
  prependedItemsCount: prependedItemsCount
@@ -588,7 +594,7 @@ function (_React$Component) {
588
594
  }
589
595
 
590
596
  var tbody = this.virtualScroller.tbody;
591
- return React.createElement(AsComponent, _extends({}, rest, {
597
+ return /*#__PURE__*/React.createElement(AsComponent, _extends({}, rest, {
592
598
  ref: this.container,
593
599
  className: tbody ? className ? className + ' ' + 'VirtualScroller' : 'VirtualScroller' : className,
594
600
  style: {
@@ -597,7 +603,7 @@ function (_React$Component) {
597
603
  }
598
604
  }), items.map(function (item, i) {
599
605
  if (i >= firstShownItemIndex && i <= lastShownItemIndex) {
600
- return React.createElement(Component, _extends({}, itemComponentProps, {
606
+ return /*#__PURE__*/React.createElement(Component, _extends({}, itemComponentProps, {
601
607
  key: _this6.getItemKey(item, i),
602
608
  ref: _this6.shouldUseRefs() ? _this6.getItemRef(i) : undefined,
603
609
  state: itemStates && itemStates[i],
@@ -623,7 +629,7 @@ function (_React$Component) {
623
629
 
624
630
  _defineProperty(VirtualScroller, "propTypes", {
625
631
  as: elementType,
626
- items: PropTypes.arrayOf(PropTypes.object).isRequired,
632
+ items: PropTypes.arrayOf(PropTypes.any).isRequired,
627
633
  itemComponent: elementType.isRequired,
628
634
  itemComponentProps: PropTypes.object,
629
635
  estimatedItemHeight: PropTypes.number,
@@ -633,10 +639,6 @@ _defineProperty(VirtualScroller, "propTypes", {
633
639
  // `preserveScrollPosition` property name is deprecated,
634
640
  // use `preserveScrollPositionOnPrependItems` instead.
635
641
  preserveScrollPosition: PropTypes.bool,
636
- preserveScrollPositionOfTheBottomOfTheListOnMount: PropTypes.bool,
637
- // `preserveScrollPositionAtBottomOnMount` property name is deprecated,
638
- // use `preserveScrollPositionOfTheBottomOfTheListOnMount` property instead.
639
- preserveScrollPositionAtBottomOnMount: PropTypes.bool,
640
642
  measureItemsBatchSize: PropTypes.number,
641
643
  scrollableContainer: PropTypes.any,
642
644
  // `getScrollableContainer` property is deprecated.
@@ -667,15 +669,7 @@ _defineProperty(VirtualScroller, "propTypes", {
667
669
  });
668
670
 
669
671
  _defineProperty(VirtualScroller, "defaultProps", {
670
- as: 'div' // `this.state` is already reserved for `virtual-scroller`.
671
- // static getDerivedStateFromProps(props, state) {
672
- // return {
673
- // prevProps: {
674
- // items: props.items
675
- // }
676
- // }
677
- // }
678
-
672
+ as: 'div'
679
673
  });
680
674
 
681
675
  export { VirtualScroller as default };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../source/react/VirtualScroller.js"],"names":["React","PropTypes","VirtualScrollerCore","reportError","px","elementType","oneOfType","string","func","object","VirtualScroller","props","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","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,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AAEA,OAAOC,mBAAP,MAAgC,oBAAhC;AAEA,SAASC,WAAT,QAA4B,kBAA5B;AACA,OAA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AC+G;AATE,GAAhB;AAhCI,C;;gBADCtG,e,kBA8CE;AACrBc,EAAAA,EAAE,EAAE,KADiB,CAItB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAXsB,C;;SA9CFd,e;;AAslBrB,SAAS0C,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.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":["React","PropTypes","VirtualScrollerCore","reportError","px","elementType","oneOfType","string","func","object","VirtualScroller","props","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","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","prototype","isReactComponent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AAEA,OAAOC,mBAAP,MAAgC,oBAAhC;AAEA,SAASC,WAAT,QAA4B,kBAA5B;AACA,OAAOC,EAAP,MAAe,eAAf,C,CAEA;AACA;;AACA,IAAMC,WAAW,GAAGJ,SAAS,CAACI,WAAV,IAAyBJ,SAAS,CAACK,SAAV,CAAoB,CAChEL,SAAS,CAACM,MADsD,EAEhEN,SAAS,CAACO,IAFsD,EAGhEP,SAAS,CAACQ,MAHsD,CAApB,CAA7C;;IAMqBC,e;;;;;AA8CpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AACA;AACA;AACA;AAIA;AAGA;AACA;AACA;AAGA,2BAAYC,KAAZ,EAAmB;AAAA;;AAAA;;AAClB,8BAAMA,KAAN,EADkB,CAElB;AACA;;AAHkB,6EAjBPX,KAAK,CAACY,SAAN,EAiBO;;AAAA,wEAXC,IAAIC,KAAJ,CAAU,MAAKF,KAAL,CAAWG,KAAX,CAAiBC,MAA3B,CAWD;;AAAA,yEAVE,IAAIF,KAAJ,CAAU,MAAKF,KAAL,CAAWG,KAAX,CAAiBC,MAA3B,CAUF;;AAAA,+DAPR,IAAIF,KAAJ,CAAU,MAAKF,KAAL,CAAWG,KAAX,CAAiBC,MAA3B,CAOQ;;AAAA,sEAFD,EAEC;;AAAA,mEAqHJ;AAAA,aAAM,MAAKC,eAAL,C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P;AAM7BnB,IAAAA,gBAAgB,EAAE1F,SAAS,CAAC8G,MAAV,CAAiBD,UANN;AAO7BI,IAAAA,WAAW,EAAEjH,SAAS,CAAC2G,OAAV,CAAkB3G,SAAS,CAAC8G,MAA5B,EAAoCD,UAPpB;AAQ7BK,IAAAA,YAAY,EAAElH,SAAS,CAAC8G,MARK;AAS7BK,IAAAA,eAAe,EAAEnH,SAAS,CAAC8G;AATE,GAAhB;AA5BI,C;;gBADCrG,e,kBA0CE;AACrBc,EAAAA,EAAE,EAAE;AADiB,C;;SA1CFd,e;;AAskBrB,SAASwC,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"}
@@ -7,10 +7,16 @@ import { setTimeout, clearTimeout } from 'request-animation-frame-timeout';
7
7
  * Same as `lodash`'s `debounce()` for functions with no arguments.
8
8
  * @param {function} func
9
9
  * @param {number} interval
10
+ * @param {function} [options.onStart]
11
+ * @param {function} [options.onStop]
10
12
  * @return {function}
11
13
  */
12
14
 
13
15
  export default function debounce(func, interval) {
16
+ var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
17
+ onStart = _ref.onStart,
18
+ onStop = _ref.onStop;
19
+
14
20
  var timeout;
15
21
  return function () {
16
22
  var _this = this;
@@ -19,10 +25,26 @@ export default function debounce(func, interval) {
19
25
  args[_key] = arguments[_key];
20
26
  }
21
27
 
22
- clearTimeout(timeout);
23
- timeout = setTimeout(function () {
24
- return func.apply(_this, args);
25
- }, interval);
28
+ return new Promise(function (resolve) {
29
+ if (timeout) {
30
+ clearTimeout(timeout);
31
+ } else {
32
+ if (onStart) {
33
+ onStart();
34
+ }
35
+ }
36
+
37
+ timeout = setTimeout(function () {
38
+ timeout = undefined;
39
+
40
+ if (onStop) {
41
+ onStop();
42
+ }
43
+
44
+ func.apply(_this, args);
45
+ resolve();
46
+ }, interval);
47
+ });
26
48
  };
27
49
  }
28
50
  //# sourceMappingURL=debounce.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../source/utility/debounce.js"],"names":["setTimeout","clearTimeout","debounce","func","interval","timeout","args","apply"],"mappings":"AAAA;AACA;AACA;AACA;AACA,SAASA,UAAT,EAAqBC,YAArB,QAAyC,iCAAzC;AAEA;;;;;;;AAMA,eAAe,SAASC,QAAT,CAAkBC,IAAlB,EAAwBC,QAAxB,EAAkC;AAChD,MAAIC,OAAJ;AACA,SAAO,YAAkB;AAAA;;AAAA,sCAANC,IAAM;AAANA,MAAAA,IAAM;AAAA;;AACxBL,IAAAA,YAAY,CAACI,OAAD,CAAZ;AACAA,IAAAA,OAAO,GAAGL,UAAU,CAAC;AAAA,aAAMG,IAAI,CAACI,KAAL,CAAW,KAAX,EAAiBD,IAAjB,CAAN;AAAA,KAAD,EAA+BF,QAA/B,CAApB;AACA,GAHD;AAIA","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 * @return {function}\r\n */\r\nexport default function debounce(func, interval) {\r\n\tlet timeout\r\n\treturn function(...args) {\r\n\t\tclearTimeout(timeout)\r\n\t\ttimeout = setTimeout(() => func.apply(this, args), interval)\r\n\t}\r\n}\r\n"],"file":"debounce.js"}
1
+ {"version":3,"sources":["../../source/utility/debounce.js"],"names":["setTimeout","clearTimeout","debounce","func","interval","onStart","onStop","timeout","args","Promise","resolve","undefined","apply"],"mappings":"AAAA;AACA;AACA;AACA;AACA,SAASA,UAAT,EAAqBC,YAArB,QAAyC,iCAAzC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,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;AACZN,QAAAA,YAAY,CAACM,OAAD,CAAZ;AACA,OAFD,MAEO;AACN,YAAIF,OAAJ,EAAa;AACZA,UAAAA,OAAO;AACP;AACD;;AACDE,MAAAA,OAAO,GAAGP,UAAU,CAAC,YAAM;AAC1BO,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,OAPmB,EAOjBN,QAPiB,CAApB;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"}
@@ -1,10 +1,14 @@
1
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
2
 
3
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
3
+ 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."); }
4
4
 
5
- function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
5
+ 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); }
6
6
 
7
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
7
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
8
+
9
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
10
+
11
+ 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; }
8
12
 
9
13
  export default function log() {
10
14
  if (isDebug()) {
@@ -18,13 +22,19 @@ export default function log() {
18
22
  }
19
23
  }
20
24
  export function warn() {
21
- var _console2;
25
+ if (isWarn()) {
26
+ var _console2;
22
27
 
23
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
24
- args[_key2] = arguments[_key2];
25
- }
28
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
29
+ args[_key2] = arguments[_key2];
30
+ }
26
31
 
27
- (_console2 = console).warn.apply(_console2, _toConsumableArray(['[virtual-scroller]'].concat(args)));
32
+ if (warningsAreErrors()) {
33
+ return reportError.apply(this, args);
34
+ }
35
+
36
+ (_console2 = console).warn.apply(_console2, _toConsumableArray(['[virtual-scroller]'].concat(args)));
37
+ }
28
38
  }
29
39
  export function reportError() {
30
40
  for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
@@ -53,8 +63,35 @@ export function reportError() {
53
63
  }
54
64
  }
55
65
  export function isDebug() {
66
+ var debug = getDebug();
67
+
68
+ if (debug !== undefined) {
69
+ return debug === true || debug === 'debug';
70
+ }
71
+ }
72
+ export function isWarn() {
73
+ // const debug = getDebug()
74
+ // return debug === undefined
75
+ // || debug === true
76
+ // || debug === 'debug'
77
+ // || debug === 'warn'
78
+ //
79
+ return true;
80
+ }
81
+
82
+ function getDebug() {
83
+ return getGlobalVariable('VirtualScrollerDebug');
84
+ }
85
+
86
+ function warningsAreErrors() {
87
+ return getGlobalVariable('VirtualScrollerWarningsAreErrors');
88
+ }
89
+
90
+ function getGlobalVariable(name) {
56
91
  if (typeof window !== 'undefined') {
57
- return window.VirtualScrollerDebug === true || window.VirtualScrollerDebug === 'debug';
92
+ return window[name];
93
+ } else if (typeof global !== 'undefined') {
94
+ return global[name];
58
95
  }
59
96
  }
60
97
  //# sourceMappingURL=debug.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../source/utility/debug.js"],"names":["log","isDebug","args","console","concat","warn","reportError","window","apply","setTimeout","Error","join","error","VirtualScrollerDebug"],"mappings":";;;;;;;;AAAA,eAAe,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;AAED,OAAO,SAASG,IAAT,GAAuB;AAAA;;AAAA,qCAANH,IAAM;AAANA,IAAAA,IAAM;AAAA;;AAC7B,eAAAC,OAAO,EAACE,IAAR,qCAAgB,CAAC,oBAAD,EAAuBD,MAAvB,CAA8BF,IAA9B,CAAhB;AACA;AAED,OAAO,SAASI,WAAT,GAA8B;AAAA,qCAANJ,IAAM;AAANA,IAAAA,IAAM;AAAA;;AACpC,MAAI,OAAOK,MAAP,KAAkB,WAAtB,EAAmC;AAClC;AACA;AACA;AACAP,IAAAA,GAAG,CAACQ,KAAJ,CAAU,IAAV,EAAgB,CAAC,OAAD,EAAUJ,MAAV,CAAiBF,IAAjB,CAAhB;AACAO,IAAAA,UAAU,CAAC,YAAM;AAChB;AACA;AACA;AACA;AACA;AACA;AACA,YAAM,IAAIC,KAAJ,CAAU,CAAC,oBAAD,EAAuBN,MAAvB,CAA8BF,IAA9B,EAAoCS,IAApC,CAAyC,GAAzC,CAAV,CAAN;AACA,KARS,EAQP,CARO,CAAV;AASA,GAdD,MAcO;AAAA;;AACN;AACA,iBAAAR,OAAO,EAACS,KAAR,qCAAiB,CAAC,oBAAD,EAAuBR,MAAvB,CAA8BF,IAA9B,CAAjB;AACA;AACD;AAED,OAAO,SAASD,OAAT,GAAmB;AACzB,MAAI,OAAOM,MAAP,KAAkB,WAAtB,EAAmC;AAClC,WAAOA,MAAM,CAACM,oBAAP,KAAgC,IAAhC,IACHN,MAAM,CAACM,oBAAP,KAAgC,OADpC;AAEA;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\tconsole.warn(...['[virtual-scroller]'].concat(args))\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\tif (typeof window !== 'undefined') {\r\n\t\treturn window.VirtualScrollerDebug === true\r\n\t\t\t|| window.VirtualScrollerDebug === 'debug'\r\n\t}\r\n}"],"file":"debug.js"}
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":";;;;;;;;;;;;AAAA,eAAe,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;AAED,OAAO,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,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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,43 @@
1
+ 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; }
2
+
3
+ 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; }
4
+
5
+ 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; }
6
+
7
+ // Creates a snapshot of a `state` or a partial update of a `state`.
8
+ // Is only used for logging state snapshots for later debug.
9
+ //
10
+ // When `state` is output to the browser console via `console.log()`,
11
+ // it is explorable in real time. That also means that if that `state`
12
+ // is modified later, the user will see the modified state, not the
13
+ // original one. In the current implementation, `state` is not strictly
14
+ // "immutable": things like individual item heights (including "before resize" ones)
15
+ // or states are updated in-place — `state.itemHeights[i] = newItemHeight` or
16
+ // `state.itemStates[i] = newItemState`. That's because those `state` properties
17
+ // are the ones that don’t affect the presentation, so there's no need to re-render
18
+ // the list when those do change — updating those properties is just an effect of
19
+ // some change rather than cause for one.
20
+ //
21
+ // So, when outputting `state` via `console.log()` for debug, it makes sense to
22
+ // snapshot it so that the developer, while debugging later, sees the correct
23
+ // item heights or item states.
24
+ //
25
+ export default function getStateSnapshot(state) {
26
+ var stateSnapshot = _objectSpread({}, state);
27
+
28
+ if (state.itemHeights) {
29
+ stateSnapshot.itemHeights = state.itemHeights.slice();
30
+ }
31
+
32
+ if (state.itemStates) {
33
+ stateSnapshot.itemStates = state.itemStates.slice();
34
+ }
35
+
36
+ if (state.beforeResize) {
37
+ stateSnapshot.beforeResize = _objectSpread({}, state.beforeResize);
38
+ stateSnapshot.beforeResize.itemHeights = state.beforeResize.itemHeights.slice();
39
+ }
40
+
41
+ return stateSnapshot;
42
+ }
43
+ //# 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;AACA,eAAe,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"}
@@ -7,6 +7,6 @@
7
7
  */
8
8
  export default function px(number) {
9
9
  // Fractional pixels are used on "retina" screens.
10
- return number.toFixed(2) + 'px';
10
+ return (number % 1 === 0 ? number : number.toFixed(2)) + 'px';
11
11
  }
12
12
  //# sourceMappingURL=px.js.map