@enact/ui 4.5.2 → 4.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/AnnounceDecorator/Announce.js +1 -40
  2. package/AnnounceDecorator/AnnounceDecorator.js +3 -21
  3. package/AnnounceDecorator/tests/Announce-specs.js +2 -7
  4. package/AnnounceDecorator/tests/AnnounceDecorator-specs.js +2 -6
  5. package/AnnounceDecorator/tests/useAnnounce-specs.js +8 -19
  6. package/AnnounceDecorator/useAnnounce.js +0 -6
  7. package/BodyText/BodyText.js +6 -26
  8. package/BodyText/tests/BodyText-specs.js +0 -19
  9. package/Button/Button.js +26 -56
  10. package/Button/tests/Button-specs.js +0 -26
  11. package/CHANGELOG.md +4 -0
  12. package/Cancelable/Cancelable.js +8 -47
  13. package/Cancelable/cancelHandler.js +5 -12
  14. package/Cancelable/modalHandler.js +3 -11
  15. package/Cancelable/tests/Cancelable-specs.js +3 -57
  16. package/Changeable/Changeable.js +2 -34
  17. package/Changeable/tests/Changeable-specs.js +20 -66
  18. package/ComponentOverride/ComponentOverride.js +1 -13
  19. package/FloatingLayer/FloatingLayer.js +17 -73
  20. package/FloatingLayer/FloatingLayerContainer.js +0 -15
  21. package/FloatingLayer/FloatingLayerDecorator.js +4 -17
  22. package/FloatingLayer/Scrim.js +9 -53
  23. package/FloatingLayer/index.js +0 -4
  24. package/FloatingLayer/tests/FloatingLayer-specs.js +8 -22
  25. package/FloatingLayer/tests/Scrim-specs.js +0 -9
  26. package/FloatingLayer/tests/useFloatingLayerDecorator-specs.js +0 -13
  27. package/FloatingLayer/useFloatingLayer.js +3 -14
  28. package/FloatingLayer/useFloatingLayerDecorator.js +3 -11
  29. package/ForwardRef/ForwardRef.js +1 -10
  30. package/GridListImageItem/GridListImageItem.js +17 -50
  31. package/Group/Group.js +4 -35
  32. package/Group/GroupItem.js +15 -32
  33. package/Group/tests/Group-specs.js +0 -32
  34. package/Heading/Heading.js +7 -35
  35. package/Heading/tests/Heading-specs.js +81 -14
  36. package/Icon/Icon.js +14 -48
  37. package/Icon/tests/Icon-specs.js +0 -22
  38. package/IconButton/IconButton.js +12 -50
  39. package/IconButton/tests/IconButton-specs.js +0 -7
  40. package/Image/Image.js +16 -45
  41. package/Image/tests/Image-specs.js +0 -14
  42. package/ImageItem/ImageItem.js +17 -46
  43. package/ImageItem/tests/ImageItem-specs.js +0 -25
  44. package/Item/Item.js +8 -32
  45. package/Item/tests/Item-specs.js +0 -24
  46. package/LabeledIcon/LabeledIcon.js +19 -50
  47. package/LabeledIcon/tests/LabeledIcon-specs.js +0 -14
  48. package/Layout/Cell.js +11 -37
  49. package/Layout/Layout.js +14 -37
  50. package/Layout/tests/Layout-specs.js +10 -39
  51. package/Marquee/MarqueeBase.js +29 -63
  52. package/Marquee/MarqueeController.js +11 -72
  53. package/Marquee/MarqueeDecorator.js +62 -196
  54. package/Marquee/index.js +1 -5
  55. package/Marquee/tests/Marquee-specs.js +258 -87
  56. package/Measurable/Measurable.js +12 -34
  57. package/Measurable/tests/Measurable-specs.js +115 -0
  58. package/Media/Media.js +15 -65
  59. package/Media/tests/Media-specs.js +168 -0
  60. package/Placeholder/PlaceholderControllerDecorator.js +7 -43
  61. package/Placeholder/PlaceholderDecorator.js +7 -38
  62. package/Placeholder/index.js +0 -4
  63. package/Placeholder/tests/PlaceholderControllerDecorator-specs.js +25 -0
  64. package/Placeholder/tests/PlaceholderDecorator-specs.js +28 -0
  65. package/ProgressBar/ProgressBar.js +13 -44
  66. package/ProgressBar/tests/ProgressBar-specs.js +0 -17
  67. package/RadioDecorator/RadioControllerDecorator.js +1 -29
  68. package/RadioDecorator/RadioDecorator.js +4 -42
  69. package/RadioDecorator/tests/RadioDecorator-specs.js +12 -49
  70. package/Repeater/Repeater.js +9 -33
  71. package/Repeater/tests/Repeater-specs.js +0 -38
  72. package/Resizable/Resizable.js +7 -35
  73. package/Resizable/tests/Resizable-specs.js +34 -0
  74. package/Routable/Link.js +8 -44
  75. package/Routable/Routable.js +10 -33
  76. package/Routable/Route.js +0 -6
  77. package/Routable/Router.js +13 -56
  78. package/Routable/tests/Routable-specs.js +7 -33
  79. package/Routable/tests/Router-specs.js +18 -44
  80. package/Routable/useLink.js +4 -8
  81. package/Routable/util.js +18 -24
  82. package/Scrollable/ScrollAnimator.js +49 -65
  83. package/Scrollable/ScrollThumb.js +2 -13
  84. package/Scrollable/Scrollable.js +179 -386
  85. package/Scrollable/ScrollableNative.js +188 -391
  86. package/Scrollable/Scrollbar.js +28 -100
  87. package/Scroller/Scroller.js +15 -39
  88. package/Scroller/ScrollerBasic.js +34 -89
  89. package/Scroller/UiScrollerBase.js +31 -84
  90. package/Skinnable/Skinnable.js +11 -38
  91. package/Skinnable/tests/Skinnable-specs.js +3 -74
  92. package/Skinnable/tests/useSkins-specs.js +1 -13
  93. package/Skinnable/tests/util-specs.js +0 -14
  94. package/Skinnable/useSkins.js +8 -15
  95. package/Skinnable/util.js +9 -20
  96. package/Slider/Knob.js +5 -24
  97. package/Slider/PositionDecorator.js +16 -54
  98. package/Slider/Slider.js +26 -64
  99. package/Slider/tests/Slider-specs.js +94 -7
  100. package/Slider/utils.js +0 -2
  101. package/SlotItem/SlotItem.js +15 -41
  102. package/SlotItem/tests/SlotItem-specs.js +0 -5
  103. package/Slottable/Slottable.js +4 -12
  104. package/Slottable/tests/Slottable-specs.js +19 -46
  105. package/Slottable/tests/useSlots-specs.js +27 -65
  106. package/Slottable/useSlots.js +8 -33
  107. package/Spinner/Spinner.js +15 -42
  108. package/Spinner/tests/Spinner-specs.js +0 -15
  109. package/ToggleIcon/ToggleIcon.js +10 -36
  110. package/ToggleIcon/tests/ToggleIcon-specs.js +0 -16
  111. package/ToggleItem/ToggleItem.js +15 -52
  112. package/ToggleItem/tests/ToggleItem-specs.js +0 -30
  113. package/Toggleable/Toggle.js +1 -15
  114. package/Toggleable/Toggleable.js +12 -45
  115. package/Toggleable/tests/Toggleable-specs.js +28 -96
  116. package/Toggleable/useToggle.js +3 -19
  117. package/Touchable/ClickAllow.js +5 -14
  118. package/Touchable/Drag.js +16 -54
  119. package/Touchable/Flick.js +11 -42
  120. package/Touchable/Hold.js +21 -68
  121. package/Touchable/Touch.js +37 -65
  122. package/Touchable/Touchable.js +32 -71
  123. package/Touchable/config.js +8 -22
  124. package/Touchable/tests/Touchable-specs.js +270 -119
  125. package/Touchable/tests/useTouch-specs.js +6 -80
  126. package/Touchable/useTouch.js +17 -34
  127. package/Transition/Transition.js +37 -118
  128. package/Transition/tests/Transition-specs.js +20 -60
  129. package/ViewManager/Arranger.js +10 -22
  130. package/ViewManager/TransitionGroup.js +31 -106
  131. package/ViewManager/View.js +35 -91
  132. package/ViewManager/ViewManager.js +19 -83
  133. package/ViewManager/tests/View-specs.js +0 -17
  134. package/ViewManager/tests/ViewManager-specs.js +236 -305
  135. package/ViewManager/tests/test-utils.js +0 -8
  136. package/VirtualList/UiVirtualListBase.js +256 -406
  137. package/VirtualList/VirtualList.js +29 -69
  138. package/VirtualList/VirtualListBase.js +0 -3
  139. package/VirtualList/VirtualListBasic.js +270 -428
  140. package/VirtualList/tests/VirtualList-specs.js +9 -37
  141. package/internal/IdProvider/IdProvider.js +7 -21
  142. package/internal/IdProvider/Provider.js +4 -17
  143. package/internal/IdProvider/tests/IdProvider-specs.js +44 -0
  144. package/internal/IdProvider/tests/useId-specs.js +7 -22
  145. package/internal/IdProvider/useId.js +0 -6
  146. package/internal/Pure/Pure.js +3 -30
  147. package/internal/Pure/tests/Pure-specs.js +88 -0
  148. package/internal/localized-fonts/localized-fonts.js +33 -62
  149. package/internal/localized-fonts/tests/localized-fonts-specs.js +33 -0
  150. package/internal/selection/selection.js +1 -6
  151. package/internal/selection/tests/selection-specs.js +6 -4
  152. package/internal/validators/tests/validators-specs.js +80 -0
  153. package/internal/validators/validators.js +14 -34
  154. package/package.json +8 -2
  155. package/resolution/ResolutionDecorator.js +4 -40
  156. package/resolution/index.js +0 -7
  157. package/resolution/resolution.js +42 -80
  158. package/resolution/tests/ResolutionDecorator-specs.js +4 -11
  159. package/resolution/tests/resolution-specs.js +2 -2
  160. package/useControlledState/tests/useControlledState-specs.js +15 -46
  161. package/useControlledState/useControlledState.js +11 -22
  162. package/useScroll/ScrollAnimator.js +49 -65
  163. package/useScroll/Scrollbar.js +22 -58
  164. package/useScroll/ScrollbarTrack.js +3 -19
  165. package/useScroll/useScroll.js +267 -454
  166. package/useScroll/utilDOM.js +8 -14
  167. package/useScroll/utilEvent.js +0 -4
@@ -4,77 +4,45 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = exports.UiVirtualListBaseNative = exports.UiVirtualListBase = void 0;
7
-
8
7
  var _classnames = _interopRequireDefault(require("classnames"));
9
-
10
8
  var _handle = require("@enact/core/handle");
11
-
12
9
  var _platform = require("@enact/core/platform");
13
-
14
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
15
-
16
11
  var _equals = _interopRequireDefault(require("ramda/src/equals"));
17
-
18
12
  var _react = require("react");
19
-
20
13
  var _UiVirtualListModule = _interopRequireDefault(require("./UiVirtualList.module.css"));
21
-
22
14
  var _jsxRuntime = require("react/jsx-runtime");
23
-
24
15
  var _excluded = ["className", "containerProps", "itemsRenderer", "style"];
25
-
26
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
27
-
28
17
  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; }
29
-
30
18
  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; }
31
-
32
19
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
33
-
34
20
  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."); }
35
-
36
21
  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); }
37
-
38
22
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
39
-
40
23
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
41
-
42
24
  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; }
43
-
44
25
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
45
-
46
26
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
47
-
48
27
  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; }
49
-
50
28
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
51
-
52
29
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
53
-
54
30
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
55
-
56
31
  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 } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
57
-
58
32
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
59
-
60
33
  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); }; }
61
-
62
34
  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); }
63
-
64
35
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
65
-
66
36
  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; } }
67
-
68
37
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
69
-
70
38
  var nop = function nop() {},
71
- JS = 'JS',
72
- Native = 'Native';
73
-
39
+ JS = 'JS',
40
+ Native = 'Native';
74
41
  var gridListItemSizeShape = _propTypes["default"].shape({
75
42
  minHeight: _propTypes["default"].number.isRequired,
76
43
  minWidth: _propTypes["default"].number.isRequired
77
44
  });
45
+
78
46
  /**
79
47
  * The base version of the virtual list component.
80
48
  *
@@ -83,22 +51,16 @@ var gridListItemSizeShape = _propTypes["default"].shape({
83
51
  * @ui
84
52
  * @private
85
53
  */
86
-
87
-
88
54
  var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
89
55
  var _class;
90
-
91
56
  return _class = /*#__PURE__*/function (_Component) {
92
57
  _inherits(VirtualListCore, _Component);
93
-
94
58
  var _super = _createSuper(VirtualListCore);
95
-
96
59
  /* No displayName here. We set displayName to returned components of this factory function. */
60
+
97
61
  function VirtualListCore(_props) {
98
62
  var _this;
99
-
100
63
  _classCallCheck(this, VirtualListCore);
101
-
102
64
  var nextState = null;
103
65
  _this = _super.call(this, _props);
104
66
  _this.scrollBounds = {
@@ -128,59 +90,46 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
128
90
  _this.scrollPositionTarget = 0;
129
91
  _this.itemPositions = [];
130
92
  _this.indexToScrollIntoView = -1;
131
-
132
93
  _this.updateScrollPosition = function (_ref) {
133
94
  var x = _ref.x,
134
- y = _ref.y;
95
+ y = _ref.y;
135
96
  var rtl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _this.props.rtl;
136
-
137
97
  if (type === Native) {
138
98
  _this.scrollToPosition(x, y, rtl);
139
99
  } else {
140
100
  _this.setScrollPosition(x, y, rtl, x, y);
141
101
  }
142
102
  };
143
-
144
103
  _this.isVertical = function () {
145
104
  return _this.isPrimaryDirectionVertical;
146
105
  };
147
-
148
106
  _this.isHorizontal = function () {
149
107
  return !_this.isPrimaryDirectionVertical;
150
108
  };
151
-
152
109
  _this.getScrollBounds = function () {
153
110
  return _this.scrollBounds;
154
111
  };
155
-
156
112
  _this.getMoreInfo = function () {
157
113
  return _this.moreInfo;
158
114
  };
159
-
160
115
  _this.getItemBottomPosition = function (index) {
161
116
  var itemPosition = _this.itemPositions[index],
162
- itemSize = _this.props.itemSizes[index];
163
-
117
+ itemSize = _this.props.itemSizes[index];
164
118
  if (itemPosition && (itemSize || itemSize === 0)) {
165
119
  return itemPosition.position + itemSize;
166
120
  } else {
167
121
  return index * _this.primary.gridSize - _this.props.spacing;
168
122
  }
169
123
  };
170
-
171
124
  _this.getItemTopPositionFromPreviousItemBottomPosition = function (index, spacing) {
172
125
  return index === 0 ? 0 : _this.getItemBottomPosition(index - 1) + spacing;
173
126
  };
174
-
175
127
  _this.getItemPosition = function (index) {
176
128
  var stickTo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'start';
177
-
178
129
  var _assertThisInitialize = _assertThisInitialized(_this),
179
- primary = _assertThisInitialize.primary,
180
- position = _this.getGridPosition(index);
181
-
130
+ primary = _assertThisInitialize.primary,
131
+ position = _this.getGridPosition(index);
182
132
  var offset = 0;
183
-
184
133
  if (stickTo === 'start') {
185
134
  offset = 0;
186
135
  } else if (_this.props.itemSizes) {
@@ -188,14 +137,12 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
188
137
  } else {
189
138
  offset = primary.clientSize - primary.itemSize;
190
139
  }
191
-
192
140
  position.primaryPosition -= offset;
193
141
  return _this.gridPositionToItemPosition(position);
194
142
  };
195
-
196
143
  _this.gridPositionToItemPosition = function (_ref2) {
197
144
  var primaryPosition = _ref2.primaryPosition,
198
- secondaryPosition = _ref2.secondaryPosition;
145
+ secondaryPosition = _ref2.secondaryPosition;
199
146
  return _this.isPrimaryDirectionVertical ? {
200
147
  left: secondaryPosition,
201
148
  top: primaryPosition
@@ -204,7 +151,6 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
204
151
  top: secondaryPosition
205
152
  };
206
153
  };
207
-
208
154
  _this.getXY = function (primaryPosition, secondaryPosition) {
209
155
  return _this.isPrimaryDirectionVertical ? {
210
156
  x: secondaryPosition,
@@ -214,45 +160,40 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
214
160
  y: secondaryPosition
215
161
  };
216
162
  };
217
-
218
163
  _this.getClientSize = function (node) {
219
164
  return {
220
165
  clientWidth: node.clientWidth,
221
166
  clientHeight: node.clientHeight
222
167
  };
223
168
  };
224
-
225
169
  _this.getStatesAndUpdateBounds = function (props) {
226
170
  var firstIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
227
-
228
171
  var dataSize = props.dataSize,
229
- overhang = props.overhang,
230
- updateStatesAndBounds = props.updateStatesAndBounds,
231
- _assertThisInitialize2 = _assertThisInitialized(_this),
232
- dimensionToExtent = _assertThisInitialize2.dimensionToExtent,
233
- primary = _assertThisInitialize2.primary,
234
- moreInfo = _assertThisInitialize2.moreInfo,
235
- scrollPosition = _assertThisInitialize2.scrollPosition,
236
- numOfItems = Math.min(dataSize, dimensionToExtent * (Math.ceil(primary.clientSize / primary.gridSize) + overhang)),
237
- wasFirstIndexMax = _this.maxFirstIndex < moreInfo.firstVisibleIndex - dimensionToExtent && firstIndex === _this.maxFirstIndex,
238
- dataSizeDiff = dataSize - _this.curDataSize;
172
+ overhang = props.overhang,
173
+ updateStatesAndBounds = props.updateStatesAndBounds,
174
+ _assertThisInitialize2 = _assertThisInitialized(_this),
175
+ dimensionToExtent = _assertThisInitialize2.dimensionToExtent,
176
+ primary = _assertThisInitialize2.primary,
177
+ moreInfo = _assertThisInitialize2.moreInfo,
178
+ scrollPosition = _assertThisInitialize2.scrollPosition,
179
+ numOfItems = Math.min(dataSize, dimensionToExtent * (Math.ceil(primary.clientSize / primary.gridSize) + overhang)),
180
+ wasFirstIndexMax = _this.maxFirstIndex < moreInfo.firstVisibleIndex - dimensionToExtent && firstIndex === _this.maxFirstIndex,
181
+ dataSizeDiff = dataSize - _this.curDataSize;
182
+ var newFirstIndex = firstIndex;
239
183
 
240
- var newFirstIndex = firstIndex; // When calling setState() except in didScroll(), `shouldUpdateBounds` should be `true`
184
+ // When calling setState() except in didScroll(), `shouldUpdateBounds` should be `true`
241
185
  // so that setState() in didScroll() could be called to override state.
242
186
  // Before calling setState() except in didScroll(), getStatesAndUpdateBounds() is always called.
243
187
  // So `shouldUpdateBounds` is true here.
244
-
245
188
  _this.shouldUpdateBounds = true;
246
189
  _this.maxFirstIndex = Math.ceil((dataSize - numOfItems) / dimensionToExtent) * dimensionToExtent;
247
- _this.curDataSize = dataSize; // reset children
190
+ _this.curDataSize = dataSize;
248
191
 
192
+ // reset children
249
193
  _this.cc = [];
250
194
  _this.itemPositions = []; // For individually sized item
251
-
252
195
  _this.calculateScrollBounds(props);
253
-
254
196
  _this.updateMoreInfo(dataSize, scrollPosition);
255
-
256
197
  if (!(updateStatesAndBounds && updateStatesAndBounds({
257
198
  cbScrollTo: props.cbScrollTo,
258
199
  numOfItems: numOfItems,
@@ -261,48 +202,40 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
261
202
  }))) {
262
203
  newFirstIndex = _this.calculateFirstIndex(props, wasFirstIndexMax, dataSizeDiff, firstIndex);
263
204
  }
264
-
265
205
  return {
266
206
  firstIndex: Math.min(newFirstIndex, _this.maxFirstIndex),
267
207
  numOfItems: numOfItems
268
208
  };
269
209
  };
270
-
271
210
  _this.setContainerSize = function () {
272
211
  if (_this.contentRef.current) {
273
212
  _this.contentRef.current.style.width = _this.scrollBounds.scrollWidth + (_this.isPrimaryDirectionVertical ? -1 : 0) + 'px';
274
213
  _this.contentRef.current.style.height = _this.scrollBounds.scrollHeight + (_this.isPrimaryDirectionVertical ? 0 : -1) + 'px';
275
214
  }
276
215
  };
277
-
278
216
  _this.getItemNode = function (index) {
279
217
  var ref = _this.itemContainerRef.current;
280
218
  return ref ? ref.children[index % _this.state.numOfItems] : null;
281
219
  };
282
-
283
220
  _this.applyStyleToNewNode = function (index) {
284
221
  var _this2;
285
-
286
222
  var _this$props = _this.props,
287
- itemRenderer = _this$props.itemRenderer,
288
- getComponentProps = _this$props.getComponentProps,
289
- key = index % _this.state.numOfItems,
290
- itemElement = itemRenderer(_objectSpread(_objectSpread({}, _this.props.childProps), {}, {
291
- key: key,
292
- index: index
293
- })),
294
- componentProps = getComponentProps && getComponentProps(index) || {};
295
-
223
+ itemRenderer = _this$props.itemRenderer,
224
+ getComponentProps = _this$props.getComponentProps,
225
+ key = index % _this.state.numOfItems,
226
+ itemElement = itemRenderer(_objectSpread(_objectSpread({}, _this.props.childProps), {}, {
227
+ key: key,
228
+ index: index
229
+ })),
230
+ componentProps = getComponentProps && getComponentProps(index) || {};
296
231
  for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
297
232
  rest[_key - 1] = arguments[_key];
298
233
  }
299
-
300
234
  _this.cc[key] = /*#__PURE__*/(0, _react.cloneElement)(itemElement, _objectSpread(_objectSpread({}, componentProps), {}, {
301
235
  className: (0, _classnames["default"])(_UiVirtualListModule["default"].listItem, itemElement.props.className),
302
236
  style: _objectSpread(_objectSpread({}, itemElement.props.style), (_this2 = _this).composeStyle.apply(_this2, rest))
303
237
  }));
304
238
  };
305
-
306
239
  _this.applyStyleToHideNode = function (index) {
307
240
  var key = index % _this.state.numOfItems;
308
241
  _this.cc[key] = /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
@@ -311,15 +244,12 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
311
244
  }
312
245
  }, key);
313
246
  };
314
-
315
247
  _this.getScrollHeight = function () {
316
248
  return _this.isPrimaryDirectionVertical ? _this.getVirtualScrollDimension() : _this.scrollBounds.clientHeight;
317
249
  };
318
-
319
250
  _this.getScrollWidth = function () {
320
251
  return _this.isPrimaryDirectionVertical ? _this.scrollBounds.clientWidth : _this.getVirtualScrollDimension();
321
252
  };
322
-
323
253
  _this.getVirtualScrollDimension = function () {
324
254
  if (_this.props.itemSizes) {
325
255
  return _this.props.itemSizes.reduce(function (total, size, index) {
@@ -327,53 +257,40 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
327
257
  }, 0);
328
258
  } else {
329
259
  var _assertThisInitialize3 = _assertThisInitialized(_this),
330
- dimensionToExtent = _assertThisInitialize3.dimensionToExtent,
331
- primary = _assertThisInitialize3.primary,
332
- curDataSize = _assertThisInitialize3.curDataSize,
333
- spacing = _this.props.spacing;
334
-
260
+ dimensionToExtent = _assertThisInitialize3.dimensionToExtent,
261
+ primary = _assertThisInitialize3.primary,
262
+ curDataSize = _assertThisInitialize3.curDataSize,
263
+ spacing = _this.props.spacing;
335
264
  return Math.ceil(curDataSize / dimensionToExtent) * primary.gridSize - spacing;
336
265
  }
337
266
  };
338
-
339
267
  _this.syncClientSize = function () {
340
268
  var _assertThisInitialize4 = _assertThisInitialized(_this),
341
- props = _assertThisInitialize4.props,
342
- node = _this.containerRef.current;
343
-
269
+ props = _assertThisInitialize4.props,
270
+ node = _this.containerRef.current;
344
271
  if (!props.clientSize && !node) {
345
272
  return false;
346
273
  }
347
-
348
274
  var _ref3 = props.clientSize || _this.getClientSize(node),
349
- clientWidth = _ref3.clientWidth,
350
- clientHeight = _ref3.clientHeight,
351
- _assertThisInitialize5 = _assertThisInitialized(_this),
352
- scrollBounds = _assertThisInitialize5.scrollBounds;
353
-
275
+ clientWidth = _ref3.clientWidth,
276
+ clientHeight = _ref3.clientHeight,
277
+ _assertThisInitialize5 = _assertThisInitialized(_this),
278
+ scrollBounds = _assertThisInitialize5.scrollBounds;
354
279
  if (clientWidth !== scrollBounds.clientWidth || clientHeight !== scrollBounds.clientHeight) {
355
280
  _this.calculateMetrics(props);
356
-
357
281
  _this.setState(_this.getStatesAndUpdateBounds(props));
358
-
359
282
  _this.setContainerSize();
360
-
361
283
  return true;
362
284
  }
363
-
364
285
  return false;
365
286
  };
366
-
367
287
  _this.containerRef = /*#__PURE__*/(0, _react.createRef)();
368
288
  _this.contentRef = /*#__PURE__*/(0, _react.createRef)();
369
289
  _this.itemContainerRef = /*#__PURE__*/(0, _react.createRef)();
370
-
371
290
  if (_props.clientSize) {
372
291
  _this.calculateMetrics(_props);
373
-
374
292
  nextState = _this.getStatesAndUpdateBounds(_props);
375
293
  }
376
-
377
294
  _this.state = _objectSpread({
378
295
  firstIndex: 0,
379
296
  numOfItems: 0,
@@ -384,10 +301,10 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
384
301
  }, nextState);
385
302
  return _this;
386
303
  }
387
-
388
304
  _createClass(VirtualListCore, [{
389
305
  key: "componentDidMount",
390
- value: // Calculate metrics for VirtualList after the 1st render to know client W/H.
306
+ value:
307
+ // Calculate metrics for VirtualList after the 1st render to know client W/H.
391
308
  function componentDidMount() {
392
309
  if (!this.props.clientSize) {
393
310
  this.calculateMetrics(this.props);
@@ -395,7 +312,6 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
395
312
  } else {
396
313
  this.emitUpdateItems();
397
314
  }
398
-
399
315
  if (this.props.itemSizes) {
400
316
  this.adjustItemPositionWithItemSize();
401
317
  } else {
@@ -407,19 +323,19 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
407
323
  value: function componentDidUpdate(prevProps, prevState) {
408
324
  var deferScrollTo = false;
409
325
  var _this$state = this.state,
410
- firstIndex = _this$state.firstIndex,
411
- numOfItems = _this$state.numOfItems;
412
- this.shouldUpdateBounds = false; // TODO: remove `this.hasDataSizeChanged` and fix ui/Scrollable*
326
+ firstIndex = _this$state.firstIndex,
327
+ numOfItems = _this$state.numOfItems;
328
+ this.shouldUpdateBounds = false;
413
329
 
330
+ // TODO: remove `this.hasDataSizeChanged` and fix ui/Scrollable*
414
331
  this.hasDataSizeChanged = prevProps.dataSize !== this.props.dataSize;
415
-
416
332
  if (prevState.firstIndex !== firstIndex || prevState.numOfItems !== numOfItems) {
417
333
  this.emitUpdateItems();
418
- } // When an item expands or shrinks,
334
+ }
335
+
336
+ // When an item expands or shrinks,
419
337
  // we need to calculate the item position again and
420
338
  // the item needs to scroll into view if the item does not show fully.
421
-
422
-
423
339
  if (this.props.itemSizes) {
424
340
  if (this.itemPositions.length > this.props.itemSizes.length) {
425
341
  // The item with `this.props.itemSizes.length` index is not rendered yet.
@@ -431,19 +347,17 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
431
347
  } else {
432
348
  var indexToScrollIntoView = this.indexToScrollIntoView;
433
349
  this.adjustItemPositionWithItemSize();
434
-
435
350
  if (indexToScrollIntoView !== -1) {
436
351
  // Currently we support expandable items in only vertical VirtualList.
437
352
  // So the top and bottom of the boundaries are checked.
438
353
  var scrollBounds = {
439
- top: this.scrollPosition,
440
- bottom: this.scrollPosition + this.scrollBounds.clientHeight
441
- },
442
- itemBounds = {
443
- top: this.getGridPosition(indexToScrollIntoView).primaryPosition,
444
- bottom: this.getItemBottomPosition(indexToScrollIntoView)
445
- };
446
-
354
+ top: this.scrollPosition,
355
+ bottom: this.scrollPosition + this.scrollBounds.clientHeight
356
+ },
357
+ itemBounds = {
358
+ top: this.getGridPosition(indexToScrollIntoView).primaryPosition,
359
+ bottom: this.getItemBottomPosition(indexToScrollIntoView)
360
+ };
447
361
  if (itemBounds.top < scrollBounds.top) {
448
362
  this.props.cbScrollTo({
449
363
  index: indexToScrollIntoView,
@@ -458,24 +372,21 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
458
372
  });
459
373
  }
460
374
  }
461
-
462
375
  this.indexToScrollIntoView = -1;
463
376
  }
464
377
  }
465
-
466
378
  if (prevProps.direction !== this.props.direction || prevProps.overhang !== this.props.overhang || prevProps.spacing !== this.props.spacing || !(0, _equals["default"])(prevProps.itemSize, this.props.itemSize)) {
467
379
  var _this$getXY = this.getXY(this.scrollPosition, 0),
468
- x = _this$getXY.x,
469
- y = _this$getXY.y;
470
-
380
+ x = _this$getXY.x,
381
+ y = _this$getXY.y;
471
382
  this.calculateMetrics(this.props);
472
383
  this.setState(this.getStatesAndUpdateBounds(this.props));
473
384
  this.setContainerSize();
474
385
  var _this$scrollBounds = this.scrollBounds,
475
- clientHeight = _this$scrollBounds.clientHeight,
476
- clientWidth = _this$scrollBounds.clientWidth,
477
- scrollHeight = _this$scrollBounds.scrollHeight,
478
- scrollWidth = _this$scrollBounds.scrollWidth;
386
+ clientHeight = _this$scrollBounds.clientHeight,
387
+ clientWidth = _this$scrollBounds.clientWidth,
388
+ scrollHeight = _this$scrollBounds.scrollHeight,
389
+ scrollWidth = _this$scrollBounds.scrollWidth;
479
390
  var xMax = scrollWidth - clientWidth;
480
391
  var yMax = scrollHeight - clientHeight;
481
392
  this.updateScrollPosition({
@@ -491,9 +402,7 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
491
402
  } else if (prevProps.rtl !== this.props.rtl) {
492
403
  this.updateScrollPosition(this.getXY(this.scrollPosition, 0));
493
404
  }
494
-
495
405
  var maxPos = this.isPrimaryDirectionVertical ? this.scrollBounds.maxTop : this.scrollBounds.maxLeft;
496
-
497
406
  if (!deferScrollTo && this.scrollPosition > maxPos) {
498
407
  this.props.cbScrollTo({
499
408
  position: this.isPrimaryDirectionVertical ? {
@@ -509,26 +418,23 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
509
418
  key: "getGridPosition",
510
419
  value: function getGridPosition(index) {
511
420
  var _this$props2 = this.props,
512
- dataSize = _this$props2.dataSize,
513
- itemSizes = _this$props2.itemSizes,
514
- dimensionToExtent = this.dimensionToExtent,
515
- itemPositions = this.itemPositions,
516
- primary = this.primary,
517
- secondary = this.secondary,
518
- secondaryPosition = index % dimensionToExtent * secondary.gridSize,
519
- extent = Math.floor(index / dimensionToExtent);
421
+ dataSize = _this$props2.dataSize,
422
+ itemSizes = _this$props2.itemSizes,
423
+ dimensionToExtent = this.dimensionToExtent,
424
+ itemPositions = this.itemPositions,
425
+ primary = this.primary,
426
+ secondary = this.secondary,
427
+ secondaryPosition = index % dimensionToExtent * secondary.gridSize,
428
+ extent = Math.floor(index / dimensionToExtent);
520
429
  var primaryPosition;
521
-
522
430
  if (itemSizes && typeof itemSizes[index] !== 'undefined' && dataSize > index) {
523
431
  var firstIndexInExtent = extent * dimensionToExtent;
524
-
525
432
  if (!itemPositions[firstIndexInExtent]) {
526
433
  // Cache individually sized item positions
527
434
  for (var i = itemPositions.length; i <= index; i++) {
528
435
  this.calculateAndCacheItemPosition(i);
529
436
  }
530
437
  }
531
-
532
438
  if (itemPositions[firstIndexInExtent]) {
533
439
  primaryPosition = itemPositions[firstIndexInExtent].position;
534
440
  } else {
@@ -537,20 +443,20 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
537
443
  } else {
538
444
  primaryPosition = extent * primary.gridSize;
539
445
  }
540
-
541
446
  return {
542
447
  primaryPosition: primaryPosition,
543
448
  secondaryPosition: secondaryPosition
544
449
  };
545
- } // For individually sized item
450
+ }
546
451
 
452
+ // For individually sized item
547
453
  }, {
548
454
  key: "emitUpdateItems",
549
455
  value: function emitUpdateItems() {
550
456
  var dataSize = this.props.dataSize;
551
457
  var _this$state2 = this.state,
552
- firstIndex = _this$state2.firstIndex,
553
- numOfItems = _this$state2.numOfItems;
458
+ firstIndex = _this$state2.firstIndex,
459
+ numOfItems = _this$state2.numOfItems;
554
460
  (0, _handle.forward)('onUpdateItems', {
555
461
  firstIndex: firstIndex,
556
462
  lastIndex: Math.min(firstIndex + numOfItems, dataSize)
@@ -560,33 +466,29 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
560
466
  key: "calculateMetrics",
561
467
  value: function calculateMetrics(props) {
562
468
  var clientSize = props.clientSize,
563
- direction = props.direction,
564
- itemSize = props.itemSize,
565
- overhang = props.overhang,
566
- spacing = props.spacing,
567
- node = this.containerRef.current;
568
-
469
+ direction = props.direction,
470
+ itemSize = props.itemSize,
471
+ overhang = props.overhang,
472
+ spacing = props.spacing,
473
+ node = this.containerRef.current;
569
474
  if (!clientSize && !node) {
570
475
  return;
571
476
  }
572
-
573
477
  var _ref4 = clientSize || this.getClientSize(node),
574
- clientWidth = _ref4.clientWidth,
575
- clientHeight = _ref4.clientHeight,
576
- heightInfo = {
577
- clientSize: clientHeight,
578
- minItemSize: itemSize.minHeight || null,
579
- itemSize: itemSize
580
- },
581
- widthInfo = {
582
- clientSize: clientWidth,
583
- minItemSize: itemSize.minWidth || null,
584
- itemSize: itemSize
585
- };
586
-
478
+ clientWidth = _ref4.clientWidth,
479
+ clientHeight = _ref4.clientHeight,
480
+ heightInfo = {
481
+ clientSize: clientHeight,
482
+ minItemSize: itemSize.minHeight || null,
483
+ itemSize: itemSize
484
+ },
485
+ widthInfo = {
486
+ clientSize: clientWidth,
487
+ minItemSize: itemSize.minWidth || null,
488
+ itemSize: itemSize
489
+ };
587
490
  var primary, secondary, dimensionToExtent, thresholdBase;
588
491
  this.isPrimaryDirectionVertical = direction === 'vertical';
589
-
590
492
  if (this.isPrimaryDirectionVertical) {
591
493
  primary = heightInfo;
592
494
  secondary = widthInfo;
@@ -594,21 +496,18 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
594
496
  primary = widthInfo;
595
497
  secondary = heightInfo;
596
498
  }
597
-
598
499
  dimensionToExtent = 1;
599
500
  this.isItemSized = primary.minItemSize && secondary.minItemSize;
600
-
601
501
  if (this.isItemSized) {
602
502
  // the number of columns is the ratio of the available width plus the spacing
603
503
  // by the minimum item width plus the spacing
604
- dimensionToExtent = Math.max(Math.floor((secondary.clientSize + spacing) / (secondary.minItemSize + spacing)), 1); // the actual item width is a ratio of the remaining width after all columns
504
+ dimensionToExtent = Math.max(Math.floor((secondary.clientSize + spacing) / (secondary.minItemSize + spacing)), 1);
505
+ // the actual item width is a ratio of the remaining width after all columns
605
506
  // and spacing are accounted for and the number of columns that we know we should have
606
-
607
- secondary.itemSize = Math.floor((secondary.clientSize - spacing * (dimensionToExtent - 1)) / dimensionToExtent); // the actual item height is related to the item width
608
-
507
+ secondary.itemSize = Math.floor((secondary.clientSize - spacing * (dimensionToExtent - 1)) / dimensionToExtent);
508
+ // the actual item height is related to the item width
609
509
  primary.itemSize = Math.floor(primary.minItemSize * (secondary.itemSize / secondary.minItemSize));
610
510
  }
611
-
612
511
  primary.gridSize = primary.itemSize + spacing;
613
512
  secondary.gridSize = secondary.itemSize + spacing;
614
513
  thresholdBase = primary.gridSize * Math.ceil(overhang / 2);
@@ -619,10 +518,10 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
619
518
  };
620
519
  this.dimensionToExtent = dimensionToExtent;
621
520
  this.primary = primary;
622
- this.secondary = secondary; // reset
521
+ this.secondary = secondary;
623
522
 
523
+ // reset
624
524
  this.scrollPosition = 0;
625
-
626
525
  if (type === JS && this.contentRef.current) {
627
526
  this.contentRef.current.style.transform = null;
628
527
  }
@@ -631,16 +530,15 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
631
530
  key: "calculateFirstIndex",
632
531
  value: function calculateFirstIndex(props, wasFirstIndexMax, dataSizeDiff, firstIndex) {
633
532
  var overhang = props.overhang,
634
- dimensionToExtent = this.dimensionToExtent,
635
- isPrimaryDirectionVertical = this.isPrimaryDirectionVertical,
636
- maxFirstIndex = this.maxFirstIndex,
637
- primary = this.primary,
638
- scrollBounds = this.scrollBounds,
639
- scrollPosition = this.scrollPosition,
640
- threshold = this.threshold,
641
- gridSize = primary.gridSize;
533
+ dimensionToExtent = this.dimensionToExtent,
534
+ isPrimaryDirectionVertical = this.isPrimaryDirectionVertical,
535
+ maxFirstIndex = this.maxFirstIndex,
536
+ primary = this.primary,
537
+ scrollBounds = this.scrollBounds,
538
+ scrollPosition = this.scrollPosition,
539
+ threshold = this.threshold,
540
+ gridSize = primary.gridSize;
642
541
  var newFirstIndex = firstIndex;
643
-
644
542
  if (wasFirstIndexMax && dataSizeDiff > 0) {
645
543
  // If dataSize increased from bottom, we need adjust firstIndex
646
544
  // If this is a gridlist and dataSizeDiff is smaller than 1 line, we are adjusting firstIndex without threshold change.
@@ -649,15 +547,17 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
649
547
  } else {
650
548
  // For other bottom adding case, we need to update firstIndex and threshold.
651
549
  var maxPos = isPrimaryDirectionVertical ? scrollBounds.maxTop : scrollBounds.maxLeft,
652
- maxOfMin = maxPos - threshold.base,
653
- numOfUpperLine = Math.floor(overhang / 2),
654
- firstIndexFromPosition = Math.floor(scrollPosition / gridSize),
655
- expectedFirstIndex = Math.max(0, firstIndexFromPosition - numOfUpperLine); // To navigate with 5way, we need to adjust firstIndex to the next line
550
+ maxOfMin = maxPos - threshold.base,
551
+ numOfUpperLine = Math.floor(overhang / 2),
552
+ firstIndexFromPosition = Math.floor(scrollPosition / gridSize),
553
+ expectedFirstIndex = Math.max(0, firstIndexFromPosition - numOfUpperLine);
554
+
555
+ // To navigate with 5way, we need to adjust firstIndex to the next line
656
556
  // since at the bottom we have num of overhang lines for upper side but none for bottom side
657
557
  // So we add numOfUpperLine at the top and rest lines at the bottom
558
+ newFirstIndex = Math.min(maxFirstIndex, expectedFirstIndex * dimensionToExtent);
658
559
 
659
- newFirstIndex = Math.min(maxFirstIndex, expectedFirstIndex * dimensionToExtent); // We need to update threshold also since we moved the firstIndex
660
-
560
+ // We need to update threshold also since we moved the firstIndex
661
561
  threshold.max = Math.min(maxPos, threshold.max + gridSize);
662
562
  threshold.min = Math.min(maxOfMin, threshold.max - gridSize);
663
563
  }
@@ -665,33 +565,30 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
665
565
  // Other cases, we can keep the min value between firstIndex and maxFirstIndex. No need to change threshold
666
566
  newFirstIndex = Math.min(firstIndex, maxFirstIndex);
667
567
  }
668
-
669
568
  return newFirstIndex;
670
569
  }
671
570
  }, {
672
571
  key: "calculateScrollBounds",
673
572
  value: function calculateScrollBounds(props) {
674
573
  var clientSize = props.clientSize,
675
- node = this.containerRef.current;
676
-
574
+ node = this.containerRef.current;
677
575
  if (!clientSize && !node) {
678
576
  return;
679
577
  }
680
-
681
578
  var scrollBounds = this.scrollBounds,
682
- isPrimaryDirectionVertical = this.isPrimaryDirectionVertical,
683
- _ref5 = clientSize || this.getClientSize(node),
684
- clientWidth = _ref5.clientWidth,
685
- clientHeight = _ref5.clientHeight;
686
-
579
+ isPrimaryDirectionVertical = this.isPrimaryDirectionVertical,
580
+ _ref5 = clientSize || this.getClientSize(node),
581
+ clientWidth = _ref5.clientWidth,
582
+ clientHeight = _ref5.clientHeight;
687
583
  var maxPos;
688
584
  scrollBounds.clientWidth = clientWidth;
689
585
  scrollBounds.clientHeight = clientHeight;
690
586
  scrollBounds.scrollWidth = this.getScrollWidth();
691
587
  scrollBounds.scrollHeight = this.getScrollHeight();
692
588
  scrollBounds.maxLeft = Math.max(0, scrollBounds.scrollWidth - clientWidth);
693
- scrollBounds.maxTop = Math.max(0, scrollBounds.scrollHeight - clientHeight); // correct position
589
+ scrollBounds.maxTop = Math.max(0, scrollBounds.scrollHeight - clientHeight);
694
590
 
591
+ // correct position
695
592
  maxPos = isPrimaryDirectionVertical ? scrollBounds.maxTop : scrollBounds.maxLeft;
696
593
  this.syncThreshold(maxPos);
697
594
  }
@@ -699,47 +596,42 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
699
596
  key: "updateMoreInfo",
700
597
  value: function updateMoreInfo(dataSize, primaryPosition) {
701
598
  var dimensionToExtent = this.dimensionToExtent,
702
- moreInfo = this.moreInfo,
703
- _this$primary = this.primary,
704
- itemSize = _this$primary.itemSize,
705
- gridSize = _this$primary.gridSize,
706
- clientSize = _this$primary.clientSize;
707
-
599
+ moreInfo = this.moreInfo,
600
+ _this$primary = this.primary,
601
+ itemSize = _this$primary.itemSize,
602
+ gridSize = _this$primary.gridSize,
603
+ clientSize = _this$primary.clientSize;
708
604
  if (dataSize <= 0) {
709
605
  moreInfo.firstVisibleIndex = null;
710
606
  moreInfo.lastVisibleIndex = null;
711
607
  } else if (this.props.itemSizes) {
712
608
  var _this$state3 = this.state,
713
- firstIndex = _this$state3.firstIndex,
714
- numOfItems = _this$state3.numOfItems;
609
+ firstIndex = _this$state3.firstIndex,
610
+ numOfItems = _this$state3.numOfItems;
715
611
  var isPrimaryDirectionVertical = this.isPrimaryDirectionVertical,
716
- _this$scrollBounds2 = this.scrollBounds,
717
- clientWidth = _this$scrollBounds2.clientWidth,
718
- clientHeight = _this$scrollBounds2.clientHeight,
719
- scrollPosition = this.scrollPosition;
612
+ _this$scrollBounds2 = this.scrollBounds,
613
+ clientWidth = _this$scrollBounds2.clientWidth,
614
+ clientHeight = _this$scrollBounds2.clientHeight,
615
+ scrollPosition = this.scrollPosition;
720
616
  var size = isPrimaryDirectionVertical ? clientHeight : clientWidth;
721
617
  var firstVisibleIndex = null,
722
- lastVisibleIndex = null;
723
-
618
+ lastVisibleIndex = null;
724
619
  for (var i = firstIndex; i < firstIndex + numOfItems; i++) {
725
620
  if (scrollPosition <= this.getItemBottomPosition(i)) {
726
621
  firstVisibleIndex = i;
727
622
  break;
728
623
  }
729
624
  }
730
-
731
625
  for (var _i = firstIndex + numOfItems - 1; _i >= firstIndex; _i--) {
732
626
  if (scrollPosition + size >= this.getItemBottomPosition(_i) - this.props.itemSizes[_i]) {
733
627
  lastVisibleIndex = _i;
734
628
  break;
735
629
  }
736
630
  }
737
-
738
631
  if (firstVisibleIndex > lastVisibleIndex) {
739
632
  firstVisibleIndex = null;
740
633
  lastVisibleIndex = null;
741
634
  }
742
-
743
635
  moreInfo.firstVisibleIndex = firstVisibleIndex;
744
636
  moreInfo.lastVisibleIndex = lastVisibleIndex;
745
637
  } else {
@@ -751,7 +643,6 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
751
643
  key: "syncThreshold",
752
644
  value: function syncThreshold(maxPos) {
753
645
  var threshold = this.threshold;
754
-
755
646
  if (threshold.max > maxPos) {
756
647
  if (maxPos < threshold.base) {
757
648
  threshold.max = threshold.base;
@@ -761,46 +652,44 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
761
652
  threshold.min = maxPos - threshold.base;
762
653
  }
763
654
  }
764
- } // Native only
655
+ }
765
656
 
657
+ // Native only
766
658
  }, {
767
659
  key: "scrollToPosition",
768
660
  value: function scrollToPosition(x, y) {
769
661
  var rtl = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.props.rtl;
770
-
771
662
  if (this.containerRef.current) {
772
663
  if (this.isPrimaryDirectionVertical) {
773
664
  this.scrollPositionTarget = y;
774
665
  } else {
775
666
  this.scrollPositionTarget = x;
776
667
  }
777
-
778
668
  if (rtl) {
779
669
  x = _platform.platform.ios || _platform.platform.safari || _platform.platform.chrome >= 85 || _platform.platform.androidChrome >= 85 ? -x : this.scrollBounds.maxLeft - x;
780
670
  }
781
-
782
671
  this.containerRef.current.scrollTo(x, y);
783
672
  }
784
- } // JS only
673
+ }
785
674
 
675
+ // JS only
786
676
  }, {
787
677
  key: "setScrollPosition",
788
678
  value: function setScrollPosition(x, y) {
789
679
  var rtl = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.props.rtl;
790
680
  var targetX = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
791
681
  var targetY = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
792
-
793
682
  if (this.contentRef.current) {
794
- this.contentRef.current.style.transform = "translate3d(".concat(rtl ? x : -x, "px, -").concat(y, "px, 0)"); // The `x`, `y` as parameters in scrollToPosition() are the position when stopping scrolling.
683
+ this.contentRef.current.style.transform = "translate3d(".concat(rtl ? x : -x, "px, -").concat(y, "px, 0)");
684
+
685
+ // The `x`, `y` as parameters in scrollToPosition() are the position when stopping scrolling.
795
686
  // But the `x`, `y` as parameters in setScrollPosition() are the position between current position and the position stopping scrolling.
796
687
  // To know the position when stopping scrolling here, `targetX` and `targetY` are passed and cached in `this.scrollPositionTarget`.
797
-
798
688
  if (this.isPrimaryDirectionVertical) {
799
689
  this.scrollPositionTarget = targetY;
800
690
  } else {
801
691
  this.scrollPositionTarget = targetX;
802
692
  }
803
-
804
693
  this.didScroll(x, y);
805
694
  }
806
695
  }
@@ -808,51 +697,48 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
808
697
  key: "didScroll",
809
698
  value: function didScroll(x, y) {
810
699
  var _this$props3 = this.props,
811
- dataSize = _this$props3.dataSize,
812
- spacing = _this$props3.spacing,
813
- itemSizes = _this$props3.itemSizes,
814
- firstIndex = this.state.firstIndex,
815
- isPrimaryDirectionVertical = this.isPrimaryDirectionVertical,
816
- threshold = this.threshold,
817
- dimensionToExtent = this.dimensionToExtent,
818
- maxFirstIndex = this.maxFirstIndex,
819
- scrollBounds = this.scrollBounds,
820
- itemPositions = this.itemPositions,
821
- _this$primary2 = this.primary,
822
- clientSize = _this$primary2.clientSize,
823
- gridSize = _this$primary2.gridSize,
824
- maxPos = isPrimaryDirectionVertical ? scrollBounds.maxTop : scrollBounds.maxLeft;
700
+ dataSize = _this$props3.dataSize,
701
+ spacing = _this$props3.spacing,
702
+ itemSizes = _this$props3.itemSizes,
703
+ firstIndex = this.state.firstIndex,
704
+ isPrimaryDirectionVertical = this.isPrimaryDirectionVertical,
705
+ threshold = this.threshold,
706
+ dimensionToExtent = this.dimensionToExtent,
707
+ maxFirstIndex = this.maxFirstIndex,
708
+ scrollBounds = this.scrollBounds,
709
+ itemPositions = this.itemPositions,
710
+ _this$primary2 = this.primary,
711
+ clientSize = _this$primary2.clientSize,
712
+ gridSize = _this$primary2.gridSize,
713
+ maxPos = isPrimaryDirectionVertical ? scrollBounds.maxTop : scrollBounds.maxLeft;
825
714
  var newFirstIndex = firstIndex,
826
- index,
827
- pos,
828
- size,
829
- itemPosition;
830
-
715
+ index,
716
+ pos,
717
+ size,
718
+ itemPosition;
831
719
  if (isPrimaryDirectionVertical) {
832
720
  pos = y;
833
721
  } else {
834
722
  pos = x;
835
723
  }
836
-
837
724
  if (pos > threshold.max || pos < threshold.min) {
838
725
  var newThresholdMin = -Infinity,
839
- newThresholdMax = Infinity;
840
-
726
+ newThresholdMax = Infinity;
841
727
  if (this.props.itemSizes) {
842
728
  var overhangBefore = Math.floor(this.props.overhang / 2);
843
- var firstRenderedIndex = -1; // find an item which is known as placed the first rendered item's position
729
+ var firstRenderedIndex = -1;
844
730
 
731
+ // find an item which is known as placed the first rendered item's position
845
732
  for (index = 0; index < dataSize; index += dimensionToExtent) {
846
733
  itemPosition = itemPositions[index];
847
734
  size = itemSizes[index];
848
-
849
735
  if (itemPosition && size && itemPosition.position + size >= pos && itemPosition.position <= pos + clientSize) {
850
736
  firstRenderedIndex = index;
851
737
  break;
852
738
  }
853
- } // found an item which is visible within a current viewport
854
-
739
+ }
855
740
 
741
+ // found an item which is visible within a current viewport
856
742
  if (index < dataSize) {
857
743
  if (itemPosition.position <= pos) {
858
744
  newFirstIndex = firstRenderedIndex - overhangBefore * dimensionToExtent;
@@ -871,92 +757,87 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
871
757
  newThresholdMin = (firstExtent + overhangBefore) * gridSize;
872
758
  newThresholdMax = newThresholdMin + gridSize;
873
759
  }
874
-
875
760
  newFirstIndex = Math.max(0, Math.min(maxFirstIndex, newFirstIndex));
876
761
  } else {
877
762
  var _overhangBefore = Math.floor(this.props.overhang / 2),
878
- _firstExtent = Math.max(0, Math.min(Math.floor(maxFirstIndex / dimensionToExtent), Math.floor((pos - gridSize * _overhangBefore) / gridSize)));
879
-
763
+ _firstExtent = Math.max(0, Math.min(Math.floor(maxFirstIndex / dimensionToExtent), Math.floor((pos - gridSize * _overhangBefore) / gridSize)));
880
764
  newFirstIndex = _firstExtent * dimensionToExtent;
881
765
  newThresholdMin = (_firstExtent + _overhangBefore) * gridSize;
882
766
  newThresholdMax = newThresholdMin + gridSize;
883
767
  }
884
-
885
768
  threshold.min = newFirstIndex === 0 ? -Infinity : newThresholdMin;
886
769
  threshold.max = newFirstIndex === maxFirstIndex ? Infinity : newThresholdMax;
887
770
  }
888
-
889
771
  this.syncThreshold(maxPos);
890
772
  this.scrollPosition = pos;
891
773
  this.updateMoreInfo(dataSize, pos);
892
-
893
774
  if (this.shouldUpdateBounds || firstIndex !== newFirstIndex) {
894
775
  this.setState({
895
776
  firstIndex: newFirstIndex
896
777
  });
897
778
  }
898
- } // For individually sized item
779
+ }
899
780
 
781
+ // For individually sized item
900
782
  }, {
901
783
  key: "calculateAndCacheItemPosition",
902
784
  value: function calculateAndCacheItemPosition(index) {
903
785
  var itemSizes = this.props.itemSizes;
904
-
905
786
  if (!this.itemPositions[index] && itemSizes[index]) {
906
787
  var spacing = this.props.spacing,
907
- position = this.getItemTopPositionFromPreviousItemBottomPosition(index, spacing);
788
+ position = this.getItemTopPositionFromPreviousItemBottomPosition(index, spacing);
908
789
  this.itemPositions[index] = {
909
790
  position: position
910
791
  };
911
792
  }
912
- } // For individually sized item
793
+ }
913
794
 
795
+ // For individually sized item
914
796
  }, {
915
797
  key: "applyItemPositionToDOMElement",
916
798
  value: function applyItemPositionToDOMElement(index) {
917
799
  var _this$props4 = this.props,
918
- direction = _this$props4.direction,
919
- rtl = _this$props4.rtl,
920
- numOfItems = this.state.numOfItems,
921
- itemPositions = this.itemPositions,
922
- childNode = this.itemContainerRef.current.children[index % numOfItems];
923
-
800
+ direction = _this$props4.direction,
801
+ rtl = _this$props4.rtl,
802
+ numOfItems = this.state.numOfItems,
803
+ itemPositions = this.itemPositions,
804
+ childNode = this.itemContainerRef.current.children[index % numOfItems];
924
805
  if (childNode && itemPositions[index]) {
925
806
  var position = itemPositions[index].position;
926
-
927
807
  if (direction === 'vertical') {
928
808
  childNode.style.transform = "translate3d(0, ".concat(position, "px, 0)");
929
809
  } else {
930
810
  childNode.style.transform = "translate3d(".concat(position * (rtl ? -1 : 1), "px, 0, 0)");
931
811
  }
932
812
  }
933
- } // For individually sized item
813
+ }
934
814
 
815
+ // For individually sized item
935
816
  }, {
936
817
  key: "updateThresholdWithItemPosition",
937
818
  value: function updateThresholdWithItemPosition() {
938
819
  var overhang = this.props.overhang,
939
- firstIndex = this.state.firstIndex,
940
- maxFirstIndex = this.maxFirstIndex,
941
- numOfUpperLine = Math.floor(overhang / 2);
820
+ firstIndex = this.state.firstIndex,
821
+ maxFirstIndex = this.maxFirstIndex,
822
+ numOfUpperLine = Math.floor(overhang / 2);
942
823
  this.threshold.min = firstIndex === 0 ? -Infinity : this.getItemBottomPosition(firstIndex + numOfUpperLine);
943
824
  this.threshold.max = firstIndex === maxFirstIndex ? Infinity : this.getItemBottomPosition(firstIndex + (numOfUpperLine + 1));
944
- } // For individually sized item
825
+ }
945
826
 
827
+ // For individually sized item
946
828
  }, {
947
829
  key: "updateScrollBoundsWithItemPositions",
948
830
  value: function updateScrollBoundsWithItemPositions() {
949
831
  var _this$props5 = this.props,
950
- dataSize = _this$props5.dataSize,
951
- itemSizes = _this$props5.itemSizes,
952
- spacing = _this$props5.spacing,
953
- _this$state4 = this.state,
954
- firstIndex = _this$state4.firstIndex,
955
- numOfItems = _this$state4.numOfItems,
956
- isPrimaryDirectionVertical = this.isPrimaryDirectionVertical,
957
- itemPositions = this.itemPositions,
958
- scrollBoundsDimension = isPrimaryDirectionVertical ? 'scrollHeight' : 'scrollWidth';
959
-
832
+ dataSize = _this$props5.dataSize,
833
+ itemSizes = _this$props5.itemSizes,
834
+ spacing = _this$props5.spacing,
835
+ _this$state4 = this.state,
836
+ firstIndex = _this$state4.firstIndex,
837
+ numOfItems = _this$state4.numOfItems,
838
+ isPrimaryDirectionVertical = this.isPrimaryDirectionVertical,
839
+ itemPositions = this.itemPositions,
840
+ scrollBoundsDimension = isPrimaryDirectionVertical ? 'scrollHeight' : 'scrollWidth';
960
841
  if (itemPositions.length === dataSize) {
961
842
  // all item sizes are known
962
843
  this.scrollBounds[scrollBoundsDimension] = itemSizes.reduce(function (acc, cur) {
@@ -965,45 +846,46 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
965
846
  } else {
966
847
  for (var index = firstIndex + numOfItems - 1; index < dataSize; index++) {
967
848
  var nextInfo = itemPositions[index + 1];
968
-
969
849
  if (!nextInfo) {
970
850
  var endPosition = this.getItemBottomPosition(index);
971
-
972
851
  if (endPosition > this.scrollBounds[scrollBoundsDimension]) {
973
852
  this.scrollBounds[scrollBoundsDimension] = endPosition;
974
853
  }
975
-
976
854
  break;
977
855
  }
978
856
  }
979
857
  }
980
-
981
858
  this.scrollBounds.maxTop = Math.max(0, this.scrollBounds.scrollHeight - this.scrollBounds.clientHeight);
982
- } // For individually sized item
859
+ }
983
860
 
861
+ // For individually sized item
984
862
  }, {
985
863
  key: "adjustItemPositionWithItemSize",
986
864
  value: function adjustItemPositionWithItemSize() {
987
865
  if (this.itemContainerRef.current) {
988
866
  var dataSize = this.props.dataSize,
989
- _this$state5 = this.state,
990
- firstIndex = _this$state5.firstIndex,
991
- numOfItems = _this$state5.numOfItems,
992
- lastIndex = firstIndex + numOfItems - 1; // Cache individually sized item positions
993
- // and adjust item DOM element positions
867
+ _this$state5 = this.state,
868
+ firstIndex = _this$state5.firstIndex,
869
+ numOfItems = _this$state5.numOfItems,
870
+ lastIndex = firstIndex + numOfItems - 1;
994
871
 
872
+ // Cache individually sized item positions
873
+ // and adjust item DOM element positions
995
874
  for (var index = firstIndex; index <= lastIndex; index++) {
996
875
  this.calculateAndCacheItemPosition(index);
997
876
  this.applyItemPositionToDOMElement(index);
998
- } // Update threshold based on this.itemPositions
999
-
877
+ }
1000
878
 
1001
- this.updateThresholdWithItemPosition(); // Update scroll bounds based on this.itemPositions
879
+ // Update threshold based on this.itemPositions
880
+ this.updateThresholdWithItemPosition();
1002
881
 
1003
- this.updateScrollBoundsWithItemPositions(); // Set container size based on this.scrollbounds
882
+ // Update scroll bounds based on this.itemPositions
883
+ this.updateScrollBoundsWithItemPositions();
1004
884
 
1005
- this.setContainerSize(); // Update moreInfo based on this.itemPositions
885
+ // Set container size based on this.scrollbounds
886
+ this.setContainerSize();
1006
887
 
888
+ // Update moreInfo based on this.itemPositions
1007
889
  this.updateMoreInfo(dataSize, this.scrollPosition);
1008
890
  }
1009
891
  }
@@ -1011,63 +893,56 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
1011
893
  key: "composeStyle",
1012
894
  value: function composeStyle(width, height, primaryPosition, secondaryPosition) {
1013
895
  var _this$getXY2 = this.getXY(primaryPosition, secondaryPosition),
1014
- x = _this$getXY2.x,
1015
- y = _this$getXY2.y,
1016
- style = {
1017
- position: 'absolute',
1018
-
1019
- /* FIXME: RTL / this calculation only works for Chrome */
1020
- transform: "translate3d(".concat(this.props.rtl ? -x : x, "px, ").concat(y, "px, 0)")
1021
- };
1022
-
896
+ x = _this$getXY2.x,
897
+ y = _this$getXY2.y,
898
+ style = {
899
+ position: 'absolute',
900
+ /* FIXME: RTL / this calculation only works for Chrome */
901
+ transform: "translate3d(".concat(this.props.rtl ? -x : x, "px, ").concat(y, "px, 0)")
902
+ };
1023
903
  if (this.isItemSized) {
1024
904
  style.width = width;
1025
905
  style.height = height;
1026
906
  }
1027
-
1028
907
  return style;
1029
908
  }
1030
909
  }, {
1031
910
  key: "positionItems",
1032
911
  value: function positionItems() {
1033
912
  var _this$props6 = this.props,
1034
- dataSize = _this$props6.dataSize,
1035
- itemSizes = _this$props6.itemSizes,
1036
- _this$state6 = this.state,
1037
- firstIndex = _this$state6.firstIndex,
1038
- numOfItems = _this$state6.numOfItems,
1039
- cc = this.cc,
1040
- isPrimaryDirectionVertical = this.isPrimaryDirectionVertical,
1041
- dimensionToExtent = this.dimensionToExtent,
1042
- primary = this.primary,
1043
- secondary = this.secondary,
1044
- itemPositions = this.itemPositions;
913
+ dataSize = _this$props6.dataSize,
914
+ itemSizes = _this$props6.itemSizes,
915
+ _this$state6 = this.state,
916
+ firstIndex = _this$state6.firstIndex,
917
+ numOfItems = _this$state6.numOfItems,
918
+ cc = this.cc,
919
+ isPrimaryDirectionVertical = this.isPrimaryDirectionVertical,
920
+ dimensionToExtent = this.dimensionToExtent,
921
+ primary = this.primary,
922
+ secondary = this.secondary,
923
+ itemPositions = this.itemPositions;
1045
924
  var hideTo = 0,
1046
- updateFrom = cc.length ? this.state.updateFrom : firstIndex,
1047
- updateTo = cc.length ? this.state.updateTo : firstIndex + numOfItems;
1048
-
925
+ updateFrom = cc.length ? this.state.updateFrom : firstIndex,
926
+ updateTo = cc.length ? this.state.updateTo : firstIndex + numOfItems;
1049
927
  if (updateFrom >= updateTo) {
1050
928
  return;
1051
929
  } else if (updateTo > dataSize) {
1052
930
  hideTo = updateTo;
1053
931
  updateTo = dataSize;
1054
932
  }
1055
-
1056
933
  var width,
1057
- height,
1058
- _this$getGridPosition = this.getGridPosition(updateFrom),
1059
- primaryPosition = _this$getGridPosition.primaryPosition,
1060
- secondaryPosition = _this$getGridPosition.secondaryPosition;
1061
-
934
+ height,
935
+ _this$getGridPosition = this.getGridPosition(updateFrom),
936
+ primaryPosition = _this$getGridPosition.primaryPosition,
937
+ secondaryPosition = _this$getGridPosition.secondaryPosition;
1062
938
  width = (isPrimaryDirectionVertical ? secondary.itemSize : primary.itemSize) + 'px';
1063
- height = (isPrimaryDirectionVertical ? primary.itemSize : secondary.itemSize) + 'px'; // positioning items
939
+ height = (isPrimaryDirectionVertical ? primary.itemSize : secondary.itemSize) + 'px';
1064
940
 
941
+ // positioning items
1065
942
  for (var i = updateFrom, j = updateFrom % dimensionToExtent; i < updateTo; i++) {
1066
943
  this.applyStyleToNewNode(i, width, height, primaryPosition, secondaryPosition);
1067
-
1068
944
  if (++j === dimensionToExtent) {
1069
945
  secondaryPosition = 0;
1070
-
1071
946
  if (this.props.itemSizes) {
1072
947
  if (itemPositions[i + 1] || itemPositions[i + 1] === 0) {
1073
948
  primaryPosition = itemPositions[i + 1].position;
@@ -1079,27 +954,25 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
1079
954
  } else {
1080
955
  primaryPosition += primary.gridSize;
1081
956
  }
1082
-
1083
957
  j = 0;
1084
958
  } else {
1085
959
  secondaryPosition += secondary.gridSize;
1086
960
  }
1087
961
  }
1088
-
1089
962
  for (var _i2 = updateTo; _i2 < hideTo; _i2++) {
1090
963
  this.applyStyleToHideNode(_i2);
1091
964
  }
1092
965
  }
1093
966
  }, {
1094
967
  key: "getContainerClasses",
1095
- value: // render
968
+ value:
969
+ // render
970
+
1096
971
  function getContainerClasses(className) {
1097
972
  var containerClass = null;
1098
-
1099
973
  if (type === Native) {
1100
974
  containerClass = this.isPrimaryDirectionVertical ? _UiVirtualListModule["default"].vertical : _UiVirtualListModule["default"].horizontal;
1101
975
  }
1102
-
1103
976
  return (0, _classnames["default"])(_UiVirtualListModule["default"].virtualList, containerClass, className);
1104
977
  }
1105
978
  }, {
@@ -1111,17 +984,16 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
1111
984
  key: "render",
1112
985
  value: function render() {
1113
986
  var _this$props7 = this.props,
1114
- className = _this$props7.className,
1115
- containerProps = _this$props7.containerProps,
1116
- itemsRenderer = _this$props7.itemsRenderer,
1117
- style = _this$props7.style,
1118
- rest = _objectWithoutProperties(_this$props7, _excluded),
1119
- cc = this.cc,
1120
- itemContainerRef = this.itemContainerRef,
1121
- primary = this.primary,
1122
- containerClasses = this.getContainerClasses(className),
1123
- contentClasses = this.getContentClasses();
1124
-
987
+ className = _this$props7.className,
988
+ containerProps = _this$props7.containerProps,
989
+ itemsRenderer = _this$props7.itemsRenderer,
990
+ style = _this$props7.style,
991
+ rest = _objectWithoutProperties(_this$props7, _excluded),
992
+ cc = this.cc,
993
+ itemContainerRef = this.itemContainerRef,
994
+ primary = this.primary,
995
+ containerClasses = this.getContainerClasses(className),
996
+ contentClasses = this.getContentClasses();
1125
997
  delete rest.cbScrollTo;
1126
998
  delete rest.childProps;
1127
999
  delete rest.clientSize;
@@ -1140,11 +1012,9 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
1140
1012
  delete rest.rtl;
1141
1013
  delete rest.spacing;
1142
1014
  delete rest.updateStatesAndBounds;
1143
-
1144
1015
  if (primary) {
1145
1016
  this.positionItems();
1146
1017
  }
1147
-
1148
1018
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({
1149
1019
  className: containerClasses
1150
1020
  }, containerProps), {}, {
@@ -1165,24 +1035,21 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
1165
1035
  key: "getDerivedStateFromProps",
1166
1036
  value: function getDerivedStateFromProps(props, state) {
1167
1037
  var shouldInvalidate = state.prevFirstIndex === state.firstIndex || state.prevChildProps !== props.childProps,
1168
- diff = state.firstIndex - state.prevFirstIndex,
1169
- updateTo = -state.numOfItems >= diff || diff > 0 || shouldInvalidate ? state.firstIndex + state.numOfItems : state.prevFirstIndex,
1170
- updateFrom = 0 >= diff || diff >= state.numOfItems || shouldInvalidate ? state.firstIndex : state.prevFirstIndex + state.numOfItems,
1171
- nextUpdateFromAndTo = state.updateFrom !== updateFrom || state.updateTo !== updateTo ? {
1172
- updateFrom: updateFrom,
1173
- updateTo: updateTo
1174
- } : null;
1038
+ diff = state.firstIndex - state.prevFirstIndex,
1039
+ updateTo = -state.numOfItems >= diff || diff > 0 || shouldInvalidate ? state.firstIndex + state.numOfItems : state.prevFirstIndex,
1040
+ updateFrom = 0 >= diff || diff >= state.numOfItems || shouldInvalidate ? state.firstIndex : state.prevFirstIndex + state.numOfItems,
1041
+ nextUpdateFromAndTo = state.updateFrom !== updateFrom || state.updateTo !== updateTo ? {
1042
+ updateFrom: updateFrom,
1043
+ updateTo: updateTo
1044
+ } : null;
1175
1045
  return _objectSpread(_objectSpread({}, nextUpdateFromAndTo), {}, {
1176
1046
  prevChildProps: props.childProps,
1177
1047
  prevFirstIndex: state.firstIndex
1178
1048
  });
1179
1049
  }
1180
1050
  }]);
1181
-
1182
1051
  return VirtualListCore;
1183
- }(_react.Component), _class.propTypes =
1184
- /** @lends ui/VirtualList.VirtualListBase.prototype */
1185
- {
1052
+ }(_react.Component), _class.propTypes = /** @lends ui/VirtualList.VirtualListBase.prototype */{
1186
1053
  /**
1187
1054
  * The rendering function called for each item in the list.
1188
1055
  *
@@ -1210,7 +1077,6 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
1210
1077
  * @public
1211
1078
  */
1212
1079
  itemRenderer: _propTypes["default"].func.isRequired,
1213
-
1214
1080
  /**
1215
1081
  * The size of an item for the list; valid values are either a number for `VirtualList`
1216
1082
  * or an object that has `minWidth` and `minHeight` for `VirtualGridList`.
@@ -1220,7 +1086,6 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
1220
1086
  * @private
1221
1087
  */
1222
1088
  itemSize: _propTypes["default"].oneOfType([_propTypes["default"].number, gridListItemSizeShape]).isRequired,
1223
-
1224
1089
  /**
1225
1090
  * The render function for the items.
1226
1091
  *
@@ -1229,7 +1094,6 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
1229
1094
  * @private
1230
1095
  */
1231
1096
  itemsRenderer: _propTypes["default"].func.isRequired,
1232
-
1233
1097
  /**
1234
1098
  * Callback method of scrollTo.
1235
1099
  * Normally, [Scrollable]{@link ui/Scrollable.Scrollable} should set this value.
@@ -1238,7 +1102,6 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
1238
1102
  * @private
1239
1103
  */
1240
1104
  cbScrollTo: _propTypes["default"].func,
1241
-
1242
1105
  /**
1243
1106
  * Additional props included in the object passed to the `itemsRenderer` callback.
1244
1107
  *
@@ -1246,7 +1109,6 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
1246
1109
  * @public
1247
1110
  */
1248
1111
  childProps: _propTypes["default"].object,
1249
-
1250
1112
  /**
1251
1113
  * Client size of the list; valid values are an object that has `clientWidth` and `clientHeight`.
1252
1114
  *
@@ -1259,7 +1121,6 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
1259
1121
  clientHeight: _propTypes["default"].number.isRequired,
1260
1122
  clientWidth: _propTypes["default"].number.isRequired
1261
1123
  }),
1262
-
1263
1124
  /**
1264
1125
  * An object with properties to be passed to the container DOM.
1265
1126
  *
@@ -1267,7 +1128,6 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
1267
1128
  * @private
1268
1129
  */
1269
1130
  containerProps: _propTypes["default"].object,
1270
-
1271
1131
  /**
1272
1132
  * The number of items of data the list contains.
1273
1133
  *
@@ -1276,7 +1136,6 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
1276
1136
  * @public
1277
1137
  */
1278
1138
  dataSize: _propTypes["default"].number,
1279
-
1280
1139
  /**
1281
1140
  * The layout direction of the list.
1282
1141
  *
@@ -1289,7 +1148,6 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
1289
1148
  * @public
1290
1149
  */
1291
1150
  direction: _propTypes["default"].oneOf(['horizontal', 'vertical']),
1292
-
1293
1151
  /**
1294
1152
  * Called to get the props for list items.
1295
1153
  *
@@ -1297,7 +1155,6 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
1297
1155
  * @private
1298
1156
  */
1299
1157
  getComponentProps: _propTypes["default"].func,
1300
-
1301
1158
  /**
1302
1159
  * The array for individually sized items.
1303
1160
  *
@@ -1305,7 +1162,6 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
1305
1162
  * @private
1306
1163
  */
1307
1164
  itemSizes: _propTypes["default"].arrayOf(_propTypes["default"].number),
1308
-
1309
1165
  /**
1310
1166
  * Called when the range of items has updated.
1311
1167
  *
@@ -1315,7 +1171,6 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
1315
1171
  * @private
1316
1172
  */
1317
1173
  onUpdateItems: _propTypes["default"].func,
1318
-
1319
1174
  /**
1320
1175
  * Number of spare DOM node.
1321
1176
  * `3` is good for the default value experimentally and
@@ -1326,7 +1181,6 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
1326
1181
  * @private
1327
1182
  */
1328
1183
  overhang: _propTypes["default"].number,
1329
-
1330
1184
  /**
1331
1185
  * When `true`, the list will scroll by page. Otherwise the list will scroll by item.
1332
1186
  *
@@ -1335,7 +1189,6 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
1335
1189
  * @private
1336
1190
  */
1337
1191
  pageScroll: _propTypes["default"].bool,
1338
-
1339
1192
  /**
1340
1193
  * `true` if RTL, `false` if LTR.
1341
1194
  *
@@ -1343,7 +1196,6 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
1343
1196
  * @private
1344
1197
  */
1345
1198
  rtl: _propTypes["default"].bool,
1346
-
1347
1199
  /**
1348
1200
  * The spacing between items.
1349
1201
  *
@@ -1352,7 +1204,6 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
1352
1204
  * @public
1353
1205
  */
1354
1206
  spacing: _propTypes["default"].number,
1355
-
1356
1207
  /**
1357
1208
  * Called to execute additional logic in a themed component when updating states and bounds.
1358
1209
  *
@@ -1371,6 +1222,7 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
1371
1222
  spacing: 0
1372
1223
  }, _class;
1373
1224
  };
1225
+
1374
1226
  /**
1375
1227
  * A basic base component for
1376
1228
  * [VirtualList]{@link ui/VirtualList.VirtualList} and [VirtualGridList]{@link ui/VirtualList.VirtualGridList}.
@@ -1380,11 +1232,10 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
1380
1232
  * @ui
1381
1233
  * @public
1382
1234
  */
1383
-
1384
-
1385
1235
  var VirtualListBase = VirtualListBaseFactory(JS);
1386
1236
  exports.UiVirtualListBase = VirtualListBase;
1387
1237
  VirtualListBase.displayName = 'ui:VirtualListBase';
1238
+
1388
1239
  /**
1389
1240
  * A basic base component for
1390
1241
  * [VirtualListNative]{@link ui/VirtualList.VirtualListNative} and [VirtualGridListNative]{@link ui/VirtualList.VirtualGridListNative}.
@@ -1394,10 +1245,10 @@ VirtualListBase.displayName = 'ui:VirtualListBase';
1394
1245
  * @ui
1395
1246
  * @private
1396
1247
  */
1397
-
1398
1248
  var VirtualListBaseNative = VirtualListBaseFactory(Native);
1399
1249
  exports.UiVirtualListBaseNative = VirtualListBaseNative;
1400
1250
  VirtualListBaseNative.displayName = 'ui:VirtualListBaseNative';
1251
+
1401
1252
  /**
1402
1253
  * A callback function that receives a reference to the `scrollTo` feature.
1403
1254
  *
@@ -1551,6 +1402,5 @@ VirtualListBaseNative.displayName = 'ui:VirtualListBaseNative';
1551
1402
  * @default 'auto'
1552
1403
  * @public
1553
1404
  */
1554
-
1555
1405
  var _default = VirtualListBase;
1556
1406
  exports["default"] = _default;