@enact/ui 4.5.2 → 4.6.1

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