@enact/ui 4.9.2 → 5.0.0-alpha.2

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