@enact/ui 4.5.2 → 4.5.4

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