@depup/react-virtualized 9.22.6-depup.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +34 -0
- package/changes.json +22 -0
- package/dist/commonjs/ArrowKeyStepper/ArrowKeyStepper.example.js +184 -0
- package/dist/commonjs/ArrowKeyStepper/ArrowKeyStepper.jest.js +338 -0
- package/dist/commonjs/ArrowKeyStepper/ArrowKeyStepper.js +204 -0
- package/dist/commonjs/ArrowKeyStepper/index.js +19 -0
- package/dist/commonjs/ArrowKeyStepper/types.js +5 -0
- package/dist/commonjs/AutoSizer/AutoSizer.example.js +104 -0
- package/dist/commonjs/AutoSizer/AutoSizer.jest.js +341 -0
- package/dist/commonjs/AutoSizer/AutoSizer.js +199 -0
- package/dist/commonjs/AutoSizer/AutoSizer.ssr.js +25 -0
- package/dist/commonjs/AutoSizer/index.js +19 -0
- package/dist/commonjs/CellMeasurer/CellMeasurer.DynamicHeightGrid.example.js +100 -0
- package/dist/commonjs/CellMeasurer/CellMeasurer.DynamicHeightList.example.js +99 -0
- package/dist/commonjs/CellMeasurer/CellMeasurer.DynamicHeightTableColumn.example.js +107 -0
- package/dist/commonjs/CellMeasurer/CellMeasurer.DynamicWidthGrid.example.js +102 -0
- package/dist/commonjs/CellMeasurer/CellMeasurer.DynamicWidthMultiGrid.example.js +107 -0
- package/dist/commonjs/CellMeasurer/CellMeasurer.example.js +129 -0
- package/dist/commonjs/CellMeasurer/CellMeasurer.jest.js +345 -0
- package/dist/commonjs/CellMeasurer/CellMeasurer.js +195 -0
- package/dist/commonjs/CellMeasurer/CellMeasurerCache.jest.js +298 -0
- package/dist/commonjs/CellMeasurer/CellMeasurerCache.js +202 -0
- package/dist/commonjs/CellMeasurer/index.js +22 -0
- package/dist/commonjs/CellMeasurer/types.js +14 -0
- package/dist/commonjs/Collection/Collection.example.js +231 -0
- package/dist/commonjs/Collection/Collection.jest.js +829 -0
- package/dist/commonjs/Collection/Collection.js +266 -0
- package/dist/commonjs/Collection/CollectionView.js +553 -0
- package/dist/commonjs/Collection/Section.jest.js +63 -0
- package/dist/commonjs/Collection/Section.js +57 -0
- package/dist/commonjs/Collection/SectionManager.jest.js +121 -0
- package/dist/commonjs/Collection/SectionManager.js +134 -0
- package/dist/commonjs/Collection/TestData.js +77 -0
- package/dist/commonjs/Collection/index.js +15 -0
- package/dist/commonjs/Collection/types.js +22 -0
- package/dist/commonjs/Collection/utils/calculateSizeAndPositionData.jest.js +34 -0
- package/dist/commonjs/Collection/utils/calculateSizeAndPositionData.js +38 -0
- package/dist/commonjs/ColumnSizer/ColumnSizer.example.js +159 -0
- package/dist/commonjs/ColumnSizer/ColumnSizer.jest.js +129 -0
- package/dist/commonjs/ColumnSizer/ColumnSizer.js +103 -0
- package/dist/commonjs/ColumnSizer/index.js +15 -0
- package/dist/commonjs/Grid/Grid.example.js +330 -0
- package/dist/commonjs/Grid/Grid.jest.js +2561 -0
- package/dist/commonjs/Grid/Grid.js +1432 -0
- package/dist/commonjs/Grid/Grid.ssr.js +62 -0
- package/dist/commonjs/Grid/accessibilityOverscanIndicesGetter.jest.js +92 -0
- package/dist/commonjs/Grid/accessibilityOverscanIndicesGetter.js +40 -0
- package/dist/commonjs/Grid/defaultCellRangeRenderer.js +139 -0
- package/dist/commonjs/Grid/defaultOverscanIndicesGetter.jest.js +92 -0
- package/dist/commonjs/Grid/defaultOverscanIndicesGetter.js +36 -0
- package/dist/commonjs/Grid/index.js +40 -0
- package/dist/commonjs/Grid/types.js +8 -0
- package/dist/commonjs/Grid/utils/CellSizeAndPositionManager.jest.js +375 -0
- package/dist/commonjs/Grid/utils/CellSizeAndPositionManager.js +296 -0
- package/dist/commonjs/Grid/utils/ScalingCellSizeAndPositionManager.jest.js +201 -0
- package/dist/commonjs/Grid/utils/ScalingCellSizeAndPositionManager.js +204 -0
- package/dist/commonjs/Grid/utils/calculateSizeAndPositionDataAndUpdateScrollOffset.jest.js +84 -0
- package/dist/commonjs/Grid/utils/calculateSizeAndPositionDataAndUpdateScrollOffset.js +59 -0
- package/dist/commonjs/Grid/utils/maxElementSize.js +22 -0
- package/dist/commonjs/Grid/utils/updateScrollIndexHelper.jest.js +180 -0
- package/dist/commonjs/Grid/utils/updateScrollIndexHelper.js +85 -0
- package/dist/commonjs/InfiniteLoader/InfiniteLoader.example.js +179 -0
- package/dist/commonjs/InfiniteLoader/InfiniteLoader.jest.js +571 -0
- package/dist/commonjs/InfiniteLoader/InfiniteLoader.js +274 -0
- package/dist/commonjs/InfiniteLoader/index.js +15 -0
- package/dist/commonjs/List/List.example.js +236 -0
- package/dist/commonjs/List/List.jest.js +517 -0
- package/dist/commonjs/List/List.js +318 -0
- package/dist/commonjs/List/index.js +19 -0
- package/dist/commonjs/List/types.js +6 -0
- package/dist/commonjs/Masonry/Masonry.example.js +287 -0
- package/dist/commonjs/Masonry/Masonry.jest.js +450 -0
- package/dist/commonjs/Masonry/Masonry.js +431 -0
- package/dist/commonjs/Masonry/PositionCache.js +88 -0
- package/dist/commonjs/Masonry/createCellPositioner.js +59 -0
- package/dist/commonjs/Masonry/index.js +22 -0
- package/dist/commonjs/MultiGrid/CellMeasurerCacheDecorator.js +106 -0
- package/dist/commonjs/MultiGrid/MultiGrid.example.js +131 -0
- package/dist/commonjs/MultiGrid/MultiGrid.jest.js +584 -0
- package/dist/commonjs/MultiGrid/MultiGrid.js +743 -0
- package/dist/commonjs/MultiGrid/index.js +15 -0
- package/dist/commonjs/ScrollSync/ScrollSync.example.js +257 -0
- package/dist/commonjs/ScrollSync/ScrollSync.jest.js +66 -0
- package/dist/commonjs/ScrollSync/ScrollSync.js +88 -0
- package/dist/commonjs/ScrollSync/index.js +15 -0
- package/dist/commonjs/Table/Column.jest.js +90 -0
- package/dist/commonjs/Table/Column.js +93 -0
- package/dist/commonjs/Table/SortDirection.js +19 -0
- package/dist/commonjs/Table/SortIndicator.js +40 -0
- package/dist/commonjs/Table/Table.example.js +325 -0
- package/dist/commonjs/Table/Table.jest.js +1257 -0
- package/dist/commonjs/Table/Table.js +742 -0
- package/dist/commonjs/Table/createMultiSort.jest.js +165 -0
- package/dist/commonjs/Table/createMultiSort.js +99 -0
- package/dist/commonjs/Table/defaultCellDataGetter.js +21 -0
- package/dist/commonjs/Table/defaultCellRenderer.js +19 -0
- package/dist/commonjs/Table/defaultHeaderRenderer.js +35 -0
- package/dist/commonjs/Table/defaultHeaderRowRenderer.js +21 -0
- package/dist/commonjs/Table/defaultRowRenderer.js +87 -0
- package/dist/commonjs/Table/index.js +78 -0
- package/dist/commonjs/Table/types.js +39 -0
- package/dist/commonjs/WindowScroller/WindowScroller.e2e.js +298 -0
- package/dist/commonjs/WindowScroller/WindowScroller.example.js +167 -0
- package/dist/commonjs/WindowScroller/WindowScroller.header-resize.e2e.js +359 -0
- package/dist/commonjs/WindowScroller/WindowScroller.jest.js +536 -0
- package/dist/commonjs/WindowScroller/WindowScroller.js +268 -0
- package/dist/commonjs/WindowScroller/WindowScroller.ssr.js +25 -0
- package/dist/commonjs/WindowScroller/index.js +23 -0
- package/dist/commonjs/WindowScroller/utils/dimensions.js +89 -0
- package/dist/commonjs/WindowScroller/utils/onScroll.js +70 -0
- package/dist/commonjs/index.js +180 -0
- package/dist/commonjs/jest-setup.js +7 -0
- package/dist/commonjs/utils/TestHelper.js +36 -0
- package/dist/commonjs/utils/animationFrame.js +29 -0
- package/dist/commonjs/utils/createCallbackMemoizer.jest.js +219 -0
- package/dist/commonjs/utils/createCallbackMemoizer.js +31 -0
- package/dist/commonjs/utils/getUpdatedOffsetForIndex.jest.js +68 -0
- package/dist/commonjs/utils/getUpdatedOffsetForIndex.js +38 -0
- package/dist/commonjs/utils/initCellMetadata.js +37 -0
- package/dist/commonjs/utils/requestAnimationTimeout.js +38 -0
- package/dist/commonjs/vendor/binarySearchBounds.js +200 -0
- package/dist/commonjs/vendor/detectElementResize.js +192 -0
- package/dist/commonjs/vendor/intervalTree.js +361 -0
- package/dist/es/ArrowKeyStepper/ArrowKeyStepper.example.js +176 -0
- package/dist/es/ArrowKeyStepper/ArrowKeyStepper.jest.js +332 -0
- package/dist/es/ArrowKeyStepper/ArrowKeyStepper.js +197 -0
- package/dist/es/ArrowKeyStepper/index.js +3 -0
- package/dist/es/ArrowKeyStepper/types.js +4 -0
- package/dist/es/AutoSizer/AutoSizer.example.js +96 -0
- package/dist/es/AutoSizer/AutoSizer.jest.js +335 -0
- package/dist/es/AutoSizer/AutoSizer.js +190 -0
- package/dist/es/AutoSizer/AutoSizer.js.flow +200 -0
- package/dist/es/AutoSizer/AutoSizer.ssr.js +19 -0
- package/dist/es/AutoSizer/index.js +2 -0
- package/dist/es/AutoSizer/index.js.flow +4 -0
- package/dist/es/CellMeasurer/CellMeasurer.DynamicHeightGrid.example.js +91 -0
- package/dist/es/CellMeasurer/CellMeasurer.DynamicHeightList.example.js +90 -0
- package/dist/es/CellMeasurer/CellMeasurer.DynamicHeightTableColumn.example.js +98 -0
- package/dist/es/CellMeasurer/CellMeasurer.DynamicWidthGrid.example.js +93 -0
- package/dist/es/CellMeasurer/CellMeasurer.DynamicWidthMultiGrid.example.js +98 -0
- package/dist/es/CellMeasurer/CellMeasurer.example.js +120 -0
- package/dist/es/CellMeasurer/CellMeasurer.jest.js +340 -0
- package/dist/es/CellMeasurer/CellMeasurer.js +187 -0
- package/dist/es/CellMeasurer/CellMeasurerCache.jest.js +293 -0
- package/dist/es/CellMeasurer/CellMeasurerCache.js +196 -0
- package/dist/es/CellMeasurer/index.js +4 -0
- package/dist/es/CellMeasurer/types.js +13 -0
- package/dist/es/Collection/Collection.example.js +223 -0
- package/dist/es/Collection/Collection.jest.js +824 -0
- package/dist/es/Collection/Collection.js +257 -0
- package/dist/es/Collection/CollectionView.js +544 -0
- package/dist/es/Collection/Section.jest.js +60 -0
- package/dist/es/Collection/Section.js +51 -0
- package/dist/es/Collection/SectionManager.jest.js +118 -0
- package/dist/es/Collection/SectionManager.js +128 -0
- package/dist/es/Collection/TestData.js +71 -0
- package/dist/es/Collection/index.js +3 -0
- package/dist/es/Collection/types.js +21 -0
- package/dist/es/Collection/utils/calculateSizeAndPositionData.jest.js +31 -0
- package/dist/es/Collection/utils/calculateSizeAndPositionData.js +31 -0
- package/dist/es/ColumnSizer/ColumnSizer.example.js +150 -0
- package/dist/es/ColumnSizer/ColumnSizer.jest.js +123 -0
- package/dist/es/ColumnSizer/ColumnSizer.js +95 -0
- package/dist/es/ColumnSizer/index.js +3 -0
- package/dist/es/Grid/Grid.example.js +321 -0
- package/dist/es/Grid/Grid.jest.js +2555 -0
- package/dist/es/Grid/Grid.js +1425 -0
- package/dist/es/Grid/Grid.ssr.js +57 -0
- package/dist/es/Grid/accessibilityOverscanIndicesGetter.jest.js +87 -0
- package/dist/es/Grid/accessibilityOverscanIndicesGetter.js +33 -0
- package/dist/es/Grid/defaultCellRangeRenderer.js +134 -0
- package/dist/es/Grid/defaultOverscanIndicesGetter.jest.js +87 -0
- package/dist/es/Grid/defaultOverscanIndicesGetter.js +29 -0
- package/dist/es/Grid/index.js +15 -0
- package/dist/es/Grid/types.js +96 -0
- package/dist/es/Grid/utils/CellSizeAndPositionManager.jest.js +372 -0
- package/dist/es/Grid/utils/CellSizeAndPositionManager.js +290 -0
- package/dist/es/Grid/utils/ScalingCellSizeAndPositionManager.jest.js +198 -0
- package/dist/es/Grid/utils/ScalingCellSizeAndPositionManager.js +198 -0
- package/dist/es/Grid/utils/calculateSizeAndPositionDataAndUpdateScrollOffset.jest.js +81 -0
- package/dist/es/Grid/utils/calculateSizeAndPositionDataAndUpdateScrollOffset.js +53 -0
- package/dist/es/Grid/utils/maxElementSize.js +16 -0
- package/dist/es/Grid/utils/updateScrollIndexHelper.jest.js +174 -0
- package/dist/es/Grid/utils/updateScrollIndexHelper.js +79 -0
- package/dist/es/InfiniteLoader/InfiniteLoader.example.js +170 -0
- package/dist/es/InfiniteLoader/InfiniteLoader.jest.js +565 -0
- package/dist/es/InfiniteLoader/InfiniteLoader.js +263 -0
- package/dist/es/InfiniteLoader/index.js +3 -0
- package/dist/es/List/List.example.js +227 -0
- package/dist/es/List/List.jest.js +511 -0
- package/dist/es/List/List.js +312 -0
- package/dist/es/List/index.js +3 -0
- package/dist/es/List/types.js +21 -0
- package/dist/es/Masonry/Masonry.example.js +278 -0
- package/dist/es/Masonry/Masonry.jest.js +444 -0
- package/dist/es/Masonry/Masonry.js +421 -0
- package/dist/es/Masonry/PositionCache.js +82 -0
- package/dist/es/Masonry/createCellPositioner.js +53 -0
- package/dist/es/Masonry/index.js +4 -0
- package/dist/es/MultiGrid/CellMeasurerCacheDecorator.js +100 -0
- package/dist/es/MultiGrid/MultiGrid.example.js +122 -0
- package/dist/es/MultiGrid/MultiGrid.jest.js +579 -0
- package/dist/es/MultiGrid/MultiGrid.js +733 -0
- package/dist/es/MultiGrid/index.js +3 -0
- package/dist/es/ScrollSync/ScrollSync.example.js +248 -0
- package/dist/es/ScrollSync/ScrollSync.jest.js +60 -0
- package/dist/es/ScrollSync/ScrollSync.js +80 -0
- package/dist/es/ScrollSync/index.js +3 -0
- package/dist/es/Table/Column.jest.js +84 -0
- package/dist/es/Table/Column.js +85 -0
- package/dist/es/Table/SortDirection.js +13 -0
- package/dist/es/Table/SortIndicator.js +31 -0
- package/dist/es/Table/Table.example.js +316 -0
- package/dist/es/Table/Table.jest.js +1251 -0
- package/dist/es/Table/Table.js +735 -0
- package/dist/es/Table/createMultiSort.jest.js +162 -0
- package/dist/es/Table/createMultiSort.js +93 -0
- package/dist/es/Table/defaultCellDataGetter.js +15 -0
- package/dist/es/Table/defaultCellRenderer.js +13 -0
- package/dist/es/Table/defaultHeaderRenderer.js +25 -0
- package/dist/es/Table/defaultHeaderRowRenderer.js +12 -0
- package/dist/es/Table/defaultRowRenderer.js +77 -0
- package/dist/es/Table/index.js +12 -0
- package/dist/es/Table/types.js +38 -0
- package/dist/es/WindowScroller/WindowScroller.e2e.js +295 -0
- package/dist/es/WindowScroller/WindowScroller.example.js +158 -0
- package/dist/es/WindowScroller/WindowScroller.header-resize.e2e.js +356 -0
- package/dist/es/WindowScroller/WindowScroller.jest.js +530 -0
- package/dist/es/WindowScroller/WindowScroller.js +259 -0
- package/dist/es/WindowScroller/WindowScroller.js.flow +277 -0
- package/dist/es/WindowScroller/WindowScroller.ssr.js +19 -0
- package/dist/es/WindowScroller/index.js +3 -0
- package/dist/es/WindowScroller/index.js.flow +6 -0
- package/dist/es/WindowScroller/utils/dimensions.js +81 -0
- package/dist/es/WindowScroller/utils/dimensions.js.flow +91 -0
- package/dist/es/WindowScroller/utils/onScroll.js +64 -0
- package/dist/es/WindowScroller/utils/onScroll.js.flow +94 -0
- package/dist/es/index.js +13 -0
- package/dist/es/jest-setup.js +5 -0
- package/dist/es/utils/TestHelper.js +30 -0
- package/dist/es/utils/animationFrame.js +23 -0
- package/dist/es/utils/createCallbackMemoizer.jest.js +216 -0
- package/dist/es/utils/createCallbackMemoizer.js +25 -0
- package/dist/es/utils/getUpdatedOffsetForIndex.jest.js +65 -0
- package/dist/es/utils/getUpdatedOffsetForIndex.js +32 -0
- package/dist/es/utils/initCellMetadata.js +31 -0
- package/dist/es/utils/requestAnimationTimeout.js +32 -0
- package/dist/es/vendor/binarySearchBounds.js +194 -0
- package/dist/es/vendor/detectElementResize.js +186 -0
- package/dist/es/vendor/intervalTree.js +354 -0
- package/dist/umd/react-virtualized.js +4638 -0
- package/package.json +188 -0
- package/styles.css +80 -0
|
@@ -0,0 +1,553 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
12
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
13
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
14
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
+
var _clsx = _interopRequireDefault(require("clsx"));
|
|
16
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
17
|
+
var React = _interopRequireWildcard(require("react"));
|
|
18
|
+
var _reactLifecyclesCompat = require("react-lifecycles-compat");
|
|
19
|
+
var _createCallbackMemoizer = _interopRequireDefault(require("../utils/createCallbackMemoizer"));
|
|
20
|
+
var _scrollbarSize = _interopRequireDefault(require("dom-helpers/scrollbarSize"));
|
|
21
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
22
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
23
|
+
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; }
|
|
24
|
+
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) { (0, _defineProperty2["default"])(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; }
|
|
25
|
+
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
|
|
26
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
27
|
+
// @TODO Merge Collection and CollectionView
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Specifies the number of milliseconds during which to disable pointer events while a scroll is in progress.
|
|
31
|
+
* This improves performance and makes scrolling smoother.
|
|
32
|
+
*/
|
|
33
|
+
var IS_SCROLLING_TIMEOUT = 150;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Controls whether the Grid updates the DOM element's scrollLeft/scrollTop based on the current state or just observes it.
|
|
37
|
+
* This prevents Grid from interrupting mouse-wheel animations (see issue #2).
|
|
38
|
+
*/
|
|
39
|
+
var SCROLL_POSITION_CHANGE_REASONS = {
|
|
40
|
+
OBSERVED: 'observed',
|
|
41
|
+
REQUESTED: 'requested'
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Monitors changes in properties (eg. cellCount) and state (eg. scroll offsets) to determine when rendering needs to occur.
|
|
46
|
+
* This component does not render any visible content itself; it defers to the specified :cellLayoutManager.
|
|
47
|
+
*/
|
|
48
|
+
var CollectionView = /*#__PURE__*/function (_React$PureComponent) {
|
|
49
|
+
function CollectionView() {
|
|
50
|
+
var _this;
|
|
51
|
+
(0, _classCallCheck2["default"])(this, CollectionView);
|
|
52
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
53
|
+
args[_key] = arguments[_key];
|
|
54
|
+
}
|
|
55
|
+
_this = _callSuper(this, CollectionView, [].concat(args));
|
|
56
|
+
|
|
57
|
+
// If this component is being rendered server-side, getScrollbarSize() will return undefined.
|
|
58
|
+
// We handle this case in componentDidMount()
|
|
59
|
+
(0, _defineProperty2["default"])(_this, "state", {
|
|
60
|
+
isScrolling: false,
|
|
61
|
+
scrollLeft: 0,
|
|
62
|
+
scrollTop: 0
|
|
63
|
+
});
|
|
64
|
+
(0, _defineProperty2["default"])(_this, "_calculateSizeAndPositionDataOnNextUpdate", false);
|
|
65
|
+
// Invokes callbacks only when their values have changed.
|
|
66
|
+
(0, _defineProperty2["default"])(_this, "_onSectionRenderedMemoizer", (0, _createCallbackMemoizer["default"])());
|
|
67
|
+
(0, _defineProperty2["default"])(_this, "_onScrollMemoizer", (0, _createCallbackMemoizer["default"])(false));
|
|
68
|
+
(0, _defineProperty2["default"])(_this, "_invokeOnSectionRenderedHelper", function () {
|
|
69
|
+
var _this$props = _this.props,
|
|
70
|
+
cellLayoutManager = _this$props.cellLayoutManager,
|
|
71
|
+
onSectionRendered = _this$props.onSectionRendered;
|
|
72
|
+
_this._onSectionRenderedMemoizer({
|
|
73
|
+
callback: onSectionRendered,
|
|
74
|
+
indices: {
|
|
75
|
+
indices: cellLayoutManager.getLastRenderedIndices()
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
(0, _defineProperty2["default"])(_this, "_setScrollingContainerRef", function (ref) {
|
|
80
|
+
_this._scrollingContainer = ref;
|
|
81
|
+
});
|
|
82
|
+
(0, _defineProperty2["default"])(_this, "_updateScrollPositionForScrollToCell", function () {
|
|
83
|
+
var _this$props2 = _this.props,
|
|
84
|
+
cellLayoutManager = _this$props2.cellLayoutManager,
|
|
85
|
+
height = _this$props2.height,
|
|
86
|
+
scrollToAlignment = _this$props2.scrollToAlignment,
|
|
87
|
+
scrollToCell = _this$props2.scrollToCell,
|
|
88
|
+
width = _this$props2.width;
|
|
89
|
+
var _this$state = _this.state,
|
|
90
|
+
scrollLeft = _this$state.scrollLeft,
|
|
91
|
+
scrollTop = _this$state.scrollTop;
|
|
92
|
+
if (scrollToCell >= 0) {
|
|
93
|
+
var scrollPosition = cellLayoutManager.getScrollPositionForCell({
|
|
94
|
+
align: scrollToAlignment,
|
|
95
|
+
cellIndex: scrollToCell,
|
|
96
|
+
height: height,
|
|
97
|
+
scrollLeft: scrollLeft,
|
|
98
|
+
scrollTop: scrollTop,
|
|
99
|
+
width: width
|
|
100
|
+
});
|
|
101
|
+
if (scrollPosition.scrollLeft !== scrollLeft || scrollPosition.scrollTop !== scrollTop) {
|
|
102
|
+
_this._setScrollPosition(scrollPosition);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
(0, _defineProperty2["default"])(_this, "_onScroll", function (event) {
|
|
107
|
+
// In certain edge-cases React dispatches an onScroll event with an invalid target.scrollLeft / target.scrollTop.
|
|
108
|
+
// This invalid event can be detected by comparing event.target to this component's scrollable DOM element.
|
|
109
|
+
// See issue #404 for more information.
|
|
110
|
+
if (event.target !== _this._scrollingContainer) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Prevent pointer events from interrupting a smooth scroll
|
|
115
|
+
_this._enablePointerEventsAfterDelay();
|
|
116
|
+
|
|
117
|
+
// When this component is shrunk drastically, React dispatches a series of back-to-back scroll events,
|
|
118
|
+
// Gradually converging on a scrollTop that is within the bounds of the new, smaller height.
|
|
119
|
+
// This causes a series of rapid renders that is slow for long lists.
|
|
120
|
+
// We can avoid that by doing some simple bounds checking to ensure that scrollTop never exceeds the total height.
|
|
121
|
+
var _this$props3 = _this.props,
|
|
122
|
+
cellLayoutManager = _this$props3.cellLayoutManager,
|
|
123
|
+
height = _this$props3.height,
|
|
124
|
+
isScrollingChange = _this$props3.isScrollingChange,
|
|
125
|
+
width = _this$props3.width;
|
|
126
|
+
var scrollbarSize = _this._scrollbarSize;
|
|
127
|
+
var _cellLayoutManager$ge = cellLayoutManager.getTotalSize(),
|
|
128
|
+
totalHeight = _cellLayoutManager$ge.height,
|
|
129
|
+
totalWidth = _cellLayoutManager$ge.width;
|
|
130
|
+
var scrollLeft = Math.max(0, Math.min(totalWidth - width + scrollbarSize, event.target.scrollLeft));
|
|
131
|
+
var scrollTop = Math.max(0, Math.min(totalHeight - height + scrollbarSize, event.target.scrollTop));
|
|
132
|
+
|
|
133
|
+
// Certain devices (like Apple touchpad) rapid-fire duplicate events.
|
|
134
|
+
// Don't force a re-render if this is the case.
|
|
135
|
+
// The mouse may move faster then the animation frame does.
|
|
136
|
+
// Use requestAnimationFrame to avoid over-updating.
|
|
137
|
+
if (_this.state.scrollLeft !== scrollLeft || _this.state.scrollTop !== scrollTop) {
|
|
138
|
+
// Browsers with cancelable scroll events (eg. Firefox) interrupt scrolling animations if scrollTop/scrollLeft is set.
|
|
139
|
+
// Other browsers (eg. Safari) don't scroll as well without the help under certain conditions (DOM or style changes during scrolling).
|
|
140
|
+
// All things considered, this seems to be the best current work around that I'm aware of.
|
|
141
|
+
// For more information see https://github.com/bvaughn/react-virtualized/pull/124
|
|
142
|
+
var scrollPositionChangeReason = event.cancelable ? SCROLL_POSITION_CHANGE_REASONS.OBSERVED : SCROLL_POSITION_CHANGE_REASONS.REQUESTED;
|
|
143
|
+
|
|
144
|
+
// Synchronously set :isScrolling the first time (since _setNextState will reschedule its animation frame each time it's called)
|
|
145
|
+
if (!_this.state.isScrolling) {
|
|
146
|
+
isScrollingChange(true);
|
|
147
|
+
}
|
|
148
|
+
_this.setState({
|
|
149
|
+
isScrolling: true,
|
|
150
|
+
scrollLeft: scrollLeft,
|
|
151
|
+
scrollPositionChangeReason: scrollPositionChangeReason,
|
|
152
|
+
scrollTop: scrollTop
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
_this._invokeOnScrollMemoizer({
|
|
156
|
+
scrollLeft: scrollLeft,
|
|
157
|
+
scrollTop: scrollTop,
|
|
158
|
+
totalWidth: totalWidth,
|
|
159
|
+
totalHeight: totalHeight
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
_this._scrollbarSize = (0, _scrollbarSize["default"])();
|
|
163
|
+
if (_this._scrollbarSize === undefined) {
|
|
164
|
+
_this._scrollbarSizeMeasured = false;
|
|
165
|
+
_this._scrollbarSize = 0;
|
|
166
|
+
} else {
|
|
167
|
+
_this._scrollbarSizeMeasured = true;
|
|
168
|
+
}
|
|
169
|
+
return _this;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Forced recompute of cell sizes and positions.
|
|
174
|
+
* This function should be called if cell sizes have changed but nothing else has.
|
|
175
|
+
* Since cell positions are calculated by callbacks, the collection view has no way of detecting when the underlying data has changed.
|
|
176
|
+
*/
|
|
177
|
+
(0, _inherits2["default"])(CollectionView, _React$PureComponent);
|
|
178
|
+
return (0, _createClass2["default"])(CollectionView, [{
|
|
179
|
+
key: "recomputeCellSizesAndPositions",
|
|
180
|
+
value: function recomputeCellSizesAndPositions() {
|
|
181
|
+
this._calculateSizeAndPositionDataOnNextUpdate = true;
|
|
182
|
+
this.forceUpdate();
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/* ---------------------------- Component lifecycle methods ---------------------------- */
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* @private
|
|
189
|
+
* This method updates scrollLeft/scrollTop in state for the following conditions:
|
|
190
|
+
* 1) Empty content (0 rows or columns)
|
|
191
|
+
* 2) New scroll props overriding the current state
|
|
192
|
+
* 3) Cells-count or cells-size has changed, making previous scroll offsets invalid
|
|
193
|
+
*/
|
|
194
|
+
}, {
|
|
195
|
+
key: "componentDidMount",
|
|
196
|
+
value: function componentDidMount() {
|
|
197
|
+
var _this$props4 = this.props,
|
|
198
|
+
cellLayoutManager = _this$props4.cellLayoutManager,
|
|
199
|
+
scrollLeft = _this$props4.scrollLeft,
|
|
200
|
+
scrollToCell = _this$props4.scrollToCell,
|
|
201
|
+
scrollTop = _this$props4.scrollTop;
|
|
202
|
+
|
|
203
|
+
// If this component was first rendered server-side, scrollbar size will be undefined.
|
|
204
|
+
// In that event we need to remeasure.
|
|
205
|
+
if (!this._scrollbarSizeMeasured) {
|
|
206
|
+
this._scrollbarSize = (0, _scrollbarSize["default"])();
|
|
207
|
+
this._scrollbarSizeMeasured = true;
|
|
208
|
+
this.setState({});
|
|
209
|
+
}
|
|
210
|
+
if (scrollToCell >= 0) {
|
|
211
|
+
this._updateScrollPositionForScrollToCell();
|
|
212
|
+
} else if (scrollLeft >= 0 || scrollTop >= 0) {
|
|
213
|
+
this._setScrollPosition({
|
|
214
|
+
scrollLeft: scrollLeft,
|
|
215
|
+
scrollTop: scrollTop
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Update onSectionRendered callback.
|
|
220
|
+
this._invokeOnSectionRenderedHelper();
|
|
221
|
+
var _cellLayoutManager$ge2 = cellLayoutManager.getTotalSize(),
|
|
222
|
+
totalHeight = _cellLayoutManager$ge2.height,
|
|
223
|
+
totalWidth = _cellLayoutManager$ge2.width;
|
|
224
|
+
|
|
225
|
+
// Initialize onScroll callback.
|
|
226
|
+
this._invokeOnScrollMemoizer({
|
|
227
|
+
scrollLeft: scrollLeft || 0,
|
|
228
|
+
scrollTop: scrollTop || 0,
|
|
229
|
+
totalHeight: totalHeight,
|
|
230
|
+
totalWidth: totalWidth
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
}, {
|
|
234
|
+
key: "componentDidUpdate",
|
|
235
|
+
value: function componentDidUpdate(prevProps, prevState) {
|
|
236
|
+
var _this$props5 = this.props,
|
|
237
|
+
height = _this$props5.height,
|
|
238
|
+
scrollToAlignment = _this$props5.scrollToAlignment,
|
|
239
|
+
scrollToCell = _this$props5.scrollToCell,
|
|
240
|
+
width = _this$props5.width;
|
|
241
|
+
var _this$state2 = this.state,
|
|
242
|
+
scrollLeft = _this$state2.scrollLeft,
|
|
243
|
+
scrollPositionChangeReason = _this$state2.scrollPositionChangeReason,
|
|
244
|
+
scrollTop = _this$state2.scrollTop;
|
|
245
|
+
|
|
246
|
+
// Make sure requested changes to :scrollLeft or :scrollTop get applied.
|
|
247
|
+
// Assigning to scrollLeft/scrollTop tells the browser to interrupt any running scroll animations,
|
|
248
|
+
// And to discard any pending async changes to the scroll position that may have happened in the meantime (e.g. on a separate scrolling thread).
|
|
249
|
+
// So we only set these when we require an adjustment of the scroll position.
|
|
250
|
+
// See issue #2 for more information.
|
|
251
|
+
if (scrollPositionChangeReason === SCROLL_POSITION_CHANGE_REASONS.REQUESTED) {
|
|
252
|
+
if (scrollLeft >= 0 && scrollLeft !== prevState.scrollLeft && scrollLeft !== this._scrollingContainer.scrollLeft) {
|
|
253
|
+
this._scrollingContainer.scrollLeft = scrollLeft;
|
|
254
|
+
}
|
|
255
|
+
if (scrollTop >= 0 && scrollTop !== prevState.scrollTop && scrollTop !== this._scrollingContainer.scrollTop) {
|
|
256
|
+
this._scrollingContainer.scrollTop = scrollTop;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// Update scroll offsets if the current :scrollToCell values requires it
|
|
261
|
+
if (height !== prevProps.height || scrollToAlignment !== prevProps.scrollToAlignment || scrollToCell !== prevProps.scrollToCell || width !== prevProps.width) {
|
|
262
|
+
this._updateScrollPositionForScrollToCell();
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Update onRowsRendered callback if start/stop indices have changed
|
|
266
|
+
this._invokeOnSectionRenderedHelper();
|
|
267
|
+
}
|
|
268
|
+
}, {
|
|
269
|
+
key: "componentWillUnmount",
|
|
270
|
+
value: function componentWillUnmount() {
|
|
271
|
+
if (this._disablePointerEventsTimeoutId) {
|
|
272
|
+
clearTimeout(this._disablePointerEventsTimeoutId);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}, {
|
|
276
|
+
key: "render",
|
|
277
|
+
value: function render() {
|
|
278
|
+
var _this$props6 = this.props,
|
|
279
|
+
autoHeight = _this$props6.autoHeight,
|
|
280
|
+
cellCount = _this$props6.cellCount,
|
|
281
|
+
cellLayoutManager = _this$props6.cellLayoutManager,
|
|
282
|
+
className = _this$props6.className,
|
|
283
|
+
height = _this$props6.height,
|
|
284
|
+
horizontalOverscanSize = _this$props6.horizontalOverscanSize,
|
|
285
|
+
id = _this$props6.id,
|
|
286
|
+
noContentRenderer = _this$props6.noContentRenderer,
|
|
287
|
+
style = _this$props6.style,
|
|
288
|
+
verticalOverscanSize = _this$props6.verticalOverscanSize,
|
|
289
|
+
width = _this$props6.width;
|
|
290
|
+
var _this$state3 = this.state,
|
|
291
|
+
isScrolling = _this$state3.isScrolling,
|
|
292
|
+
scrollLeft = _this$state3.scrollLeft,
|
|
293
|
+
scrollTop = _this$state3.scrollTop;
|
|
294
|
+
|
|
295
|
+
// Memoization reset
|
|
296
|
+
if (this._lastRenderedCellCount !== cellCount || this._lastRenderedCellLayoutManager !== cellLayoutManager || this._calculateSizeAndPositionDataOnNextUpdate) {
|
|
297
|
+
this._lastRenderedCellCount = cellCount;
|
|
298
|
+
this._lastRenderedCellLayoutManager = cellLayoutManager;
|
|
299
|
+
this._calculateSizeAndPositionDataOnNextUpdate = false;
|
|
300
|
+
cellLayoutManager.calculateSizeAndPositionData();
|
|
301
|
+
}
|
|
302
|
+
var _cellLayoutManager$ge3 = cellLayoutManager.getTotalSize(),
|
|
303
|
+
totalHeight = _cellLayoutManager$ge3.height,
|
|
304
|
+
totalWidth = _cellLayoutManager$ge3.width;
|
|
305
|
+
|
|
306
|
+
// Safely expand the rendered area by the specified overscan amount
|
|
307
|
+
var left = Math.max(0, scrollLeft - horizontalOverscanSize);
|
|
308
|
+
var top = Math.max(0, scrollTop - verticalOverscanSize);
|
|
309
|
+
var right = Math.min(totalWidth, scrollLeft + width + horizontalOverscanSize);
|
|
310
|
+
var bottom = Math.min(totalHeight, scrollTop + height + verticalOverscanSize);
|
|
311
|
+
var childrenToDisplay = height > 0 && width > 0 ? cellLayoutManager.cellRenderers({
|
|
312
|
+
height: bottom - top,
|
|
313
|
+
isScrolling: isScrolling,
|
|
314
|
+
width: right - left,
|
|
315
|
+
x: left,
|
|
316
|
+
y: top
|
|
317
|
+
}) : [];
|
|
318
|
+
var collectionStyle = {
|
|
319
|
+
boxSizing: 'border-box',
|
|
320
|
+
direction: 'ltr',
|
|
321
|
+
height: autoHeight ? 'auto' : height,
|
|
322
|
+
position: 'relative',
|
|
323
|
+
WebkitOverflowScrolling: 'touch',
|
|
324
|
+
width: width,
|
|
325
|
+
willChange: 'transform'
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
// Force browser to hide scrollbars when we know they aren't necessary.
|
|
329
|
+
// Otherwise once scrollbars appear they may not disappear again.
|
|
330
|
+
// For more info see issue #116
|
|
331
|
+
var verticalScrollBarSize = totalHeight > height ? this._scrollbarSize : 0;
|
|
332
|
+
var horizontalScrollBarSize = totalWidth > width ? this._scrollbarSize : 0;
|
|
333
|
+
|
|
334
|
+
// Also explicitly init styles to 'auto' if scrollbars are required.
|
|
335
|
+
// This works around an obscure edge case where external CSS styles have not yet been loaded,
|
|
336
|
+
// But an initial scroll index of offset is set as an external prop.
|
|
337
|
+
// Without this style, Grid would render the correct range of cells but would NOT update its internal offset.
|
|
338
|
+
// This was originally reported via clauderic/react-infinite-calendar/issues/23
|
|
339
|
+
collectionStyle.overflowX = totalWidth + verticalScrollBarSize <= width ? 'hidden' : 'auto';
|
|
340
|
+
collectionStyle.overflowY = totalHeight + horizontalScrollBarSize <= height ? 'hidden' : 'auto';
|
|
341
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
342
|
+
ref: this._setScrollingContainerRef,
|
|
343
|
+
"aria-label": this.props['aria-label'],
|
|
344
|
+
className: (0, _clsx["default"])('ReactVirtualized__Collection', className),
|
|
345
|
+
id: id,
|
|
346
|
+
onScroll: this._onScroll,
|
|
347
|
+
role: "grid",
|
|
348
|
+
style: _objectSpread(_objectSpread({}, collectionStyle), style),
|
|
349
|
+
tabIndex: 0
|
|
350
|
+
}, cellCount > 0 && /*#__PURE__*/React.createElement("div", {
|
|
351
|
+
className: "ReactVirtualized__Collection__innerScrollContainer",
|
|
352
|
+
style: {
|
|
353
|
+
height: totalHeight,
|
|
354
|
+
maxHeight: totalHeight,
|
|
355
|
+
maxWidth: totalWidth,
|
|
356
|
+
overflow: 'hidden',
|
|
357
|
+
pointerEvents: isScrolling ? 'none' : '',
|
|
358
|
+
width: totalWidth
|
|
359
|
+
}
|
|
360
|
+
}, childrenToDisplay), cellCount === 0 && noContentRenderer());
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/* ---------------------------- Helper methods ---------------------------- */
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Sets an :isScrolling flag for a small window of time.
|
|
367
|
+
* This flag is used to disable pointer events on the scrollable portion of the Collection.
|
|
368
|
+
* This prevents jerky/stuttery mouse-wheel scrolling.
|
|
369
|
+
*/
|
|
370
|
+
}, {
|
|
371
|
+
key: "_enablePointerEventsAfterDelay",
|
|
372
|
+
value: function _enablePointerEventsAfterDelay() {
|
|
373
|
+
var _this2 = this;
|
|
374
|
+
if (this._disablePointerEventsTimeoutId) {
|
|
375
|
+
clearTimeout(this._disablePointerEventsTimeoutId);
|
|
376
|
+
}
|
|
377
|
+
this._disablePointerEventsTimeoutId = setTimeout(function () {
|
|
378
|
+
var isScrollingChange = _this2.props.isScrollingChange;
|
|
379
|
+
isScrollingChange(false);
|
|
380
|
+
_this2._disablePointerEventsTimeoutId = null;
|
|
381
|
+
_this2.setState({
|
|
382
|
+
isScrolling: false
|
|
383
|
+
});
|
|
384
|
+
}, IS_SCROLLING_TIMEOUT);
|
|
385
|
+
}
|
|
386
|
+
}, {
|
|
387
|
+
key: "_invokeOnScrollMemoizer",
|
|
388
|
+
value: function _invokeOnScrollMemoizer(_ref) {
|
|
389
|
+
var _this3 = this;
|
|
390
|
+
var scrollLeft = _ref.scrollLeft,
|
|
391
|
+
scrollTop = _ref.scrollTop,
|
|
392
|
+
totalHeight = _ref.totalHeight,
|
|
393
|
+
totalWidth = _ref.totalWidth;
|
|
394
|
+
this._onScrollMemoizer({
|
|
395
|
+
callback: function callback(_ref2) {
|
|
396
|
+
var scrollLeft = _ref2.scrollLeft,
|
|
397
|
+
scrollTop = _ref2.scrollTop;
|
|
398
|
+
var _this3$props = _this3.props,
|
|
399
|
+
height = _this3$props.height,
|
|
400
|
+
onScroll = _this3$props.onScroll,
|
|
401
|
+
width = _this3$props.width;
|
|
402
|
+
onScroll({
|
|
403
|
+
clientHeight: height,
|
|
404
|
+
clientWidth: width,
|
|
405
|
+
scrollHeight: totalHeight,
|
|
406
|
+
scrollLeft: scrollLeft,
|
|
407
|
+
scrollTop: scrollTop,
|
|
408
|
+
scrollWidth: totalWidth
|
|
409
|
+
});
|
|
410
|
+
},
|
|
411
|
+
indices: {
|
|
412
|
+
scrollLeft: scrollLeft,
|
|
413
|
+
scrollTop: scrollTop
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
}, {
|
|
418
|
+
key: "_setScrollPosition",
|
|
419
|
+
value: function _setScrollPosition(_ref3) {
|
|
420
|
+
var scrollLeft = _ref3.scrollLeft,
|
|
421
|
+
scrollTop = _ref3.scrollTop;
|
|
422
|
+
var newState = {
|
|
423
|
+
scrollPositionChangeReason: SCROLL_POSITION_CHANGE_REASONS.REQUESTED
|
|
424
|
+
};
|
|
425
|
+
if (scrollLeft >= 0) {
|
|
426
|
+
newState.scrollLeft = scrollLeft;
|
|
427
|
+
}
|
|
428
|
+
if (scrollTop >= 0) {
|
|
429
|
+
newState.scrollTop = scrollTop;
|
|
430
|
+
}
|
|
431
|
+
if (scrollLeft >= 0 && scrollLeft !== this.state.scrollLeft || scrollTop >= 0 && scrollTop !== this.state.scrollTop) {
|
|
432
|
+
this.setState(newState);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}], [{
|
|
436
|
+
key: "getDerivedStateFromProps",
|
|
437
|
+
value: function getDerivedStateFromProps(nextProps, prevState) {
|
|
438
|
+
if (nextProps.cellCount === 0 && (prevState.scrollLeft !== 0 || prevState.scrollTop !== 0)) {
|
|
439
|
+
return {
|
|
440
|
+
scrollLeft: 0,
|
|
441
|
+
scrollTop: 0,
|
|
442
|
+
scrollPositionChangeReason: SCROLL_POSITION_CHANGE_REASONS.REQUESTED
|
|
443
|
+
};
|
|
444
|
+
} else if (nextProps.scrollLeft !== prevState.scrollLeft || nextProps.scrollTop !== prevState.scrollTop) {
|
|
445
|
+
return {
|
|
446
|
+
scrollLeft: nextProps.scrollLeft != null ? nextProps.scrollLeft : prevState.scrollLeft,
|
|
447
|
+
scrollTop: nextProps.scrollTop != null ? nextProps.scrollTop : prevState.scrollTop,
|
|
448
|
+
scrollPositionChangeReason: SCROLL_POSITION_CHANGE_REASONS.REQUESTED
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
return null;
|
|
452
|
+
}
|
|
453
|
+
}]);
|
|
454
|
+
}(React.PureComponent);
|
|
455
|
+
(0, _defineProperty2["default"])(CollectionView, "defaultProps", {
|
|
456
|
+
'aria-label': 'grid',
|
|
457
|
+
horizontalOverscanSize: 0,
|
|
458
|
+
noContentRenderer: function noContentRenderer() {
|
|
459
|
+
return null;
|
|
460
|
+
},
|
|
461
|
+
onScroll: function onScroll() {
|
|
462
|
+
return null;
|
|
463
|
+
},
|
|
464
|
+
onSectionRendered: function onSectionRendered() {
|
|
465
|
+
return null;
|
|
466
|
+
},
|
|
467
|
+
scrollToAlignment: 'auto',
|
|
468
|
+
scrollToCell: -1,
|
|
469
|
+
style: {},
|
|
470
|
+
verticalOverscanSize: 0
|
|
471
|
+
});
|
|
472
|
+
CollectionView.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
473
|
+
'aria-label': _propTypes["default"].string,
|
|
474
|
+
/**
|
|
475
|
+
* Removes fixed height from the scrollingContainer so that the total height
|
|
476
|
+
* of rows can stretch the window. Intended for use with WindowScroller
|
|
477
|
+
*/
|
|
478
|
+
autoHeight: _propTypes["default"].bool,
|
|
479
|
+
/**
|
|
480
|
+
* Number of cells in collection.
|
|
481
|
+
*/
|
|
482
|
+
cellCount: _propTypes["default"].number.isRequired,
|
|
483
|
+
/**
|
|
484
|
+
* Calculates cell sizes and positions and manages rendering the appropriate cells given a specified window.
|
|
485
|
+
*/
|
|
486
|
+
cellLayoutManager: _propTypes["default"].object.isRequired,
|
|
487
|
+
/**
|
|
488
|
+
* Optional custom CSS class name to attach to root Collection element.
|
|
489
|
+
*/
|
|
490
|
+
className: _propTypes["default"].string,
|
|
491
|
+
/**
|
|
492
|
+
* Height of Collection; this property determines the number of visible (vs virtualized) rows.
|
|
493
|
+
*/
|
|
494
|
+
height: _propTypes["default"].number.isRequired,
|
|
495
|
+
/**
|
|
496
|
+
* Optional custom id to attach to root Collection element.
|
|
497
|
+
*/
|
|
498
|
+
id: _propTypes["default"].string,
|
|
499
|
+
/**
|
|
500
|
+
* Enables the `Collection` to horiontally "overscan" its content similar to how `Grid` does.
|
|
501
|
+
* This can reduce flicker around the edges when a user scrolls quickly.
|
|
502
|
+
*/
|
|
503
|
+
horizontalOverscanSize: _propTypes["default"].number.isRequired,
|
|
504
|
+
isScrollingChange: _propTypes["default"].func,
|
|
505
|
+
/**
|
|
506
|
+
* Optional renderer to be used in place of rows when either :rowCount or :cellCount is 0.
|
|
507
|
+
*/
|
|
508
|
+
noContentRenderer: _propTypes["default"].func.isRequired,
|
|
509
|
+
/**
|
|
510
|
+
* Callback invoked whenever the scroll offset changes within the inner scrollable region.
|
|
511
|
+
* This callback can be used to sync scrolling between lists, tables, or grids.
|
|
512
|
+
* ({ clientHeight, clientWidth, scrollHeight, scrollLeft, scrollTop, scrollWidth }): void
|
|
513
|
+
*/
|
|
514
|
+
onScroll: _propTypes["default"].func.isRequired,
|
|
515
|
+
/**
|
|
516
|
+
* Callback invoked with information about the section of the Collection that was just rendered.
|
|
517
|
+
* This callback is passed a named :indices parameter which is an Array of the most recently rendered section indices.
|
|
518
|
+
*/
|
|
519
|
+
onSectionRendered: _propTypes["default"].func.isRequired,
|
|
520
|
+
/**
|
|
521
|
+
* Horizontal offset.
|
|
522
|
+
*/
|
|
523
|
+
scrollLeft: _propTypes["default"].number,
|
|
524
|
+
/**
|
|
525
|
+
* Controls scroll-to-cell behavior of the Grid.
|
|
526
|
+
* The default ("auto") scrolls the least amount possible to ensure that the specified cell is fully visible.
|
|
527
|
+
* Use "start" to align cells to the top/left of the Grid and "end" to align bottom/right.
|
|
528
|
+
*/
|
|
529
|
+
scrollToAlignment: _propTypes["default"].oneOf(['auto', 'end', 'start', 'center']).isRequired,
|
|
530
|
+
/**
|
|
531
|
+
* Cell index to ensure visible (by forcefully scrolling if necessary).
|
|
532
|
+
*/
|
|
533
|
+
scrollToCell: _propTypes["default"].number.isRequired,
|
|
534
|
+
/**
|
|
535
|
+
* Vertical offset.
|
|
536
|
+
*/
|
|
537
|
+
scrollTop: _propTypes["default"].number,
|
|
538
|
+
/**
|
|
539
|
+
* Optional custom inline style to attach to root Collection element.
|
|
540
|
+
*/
|
|
541
|
+
style: _propTypes["default"].object,
|
|
542
|
+
/**
|
|
543
|
+
* Enables the `Collection` to vertically "overscan" its content similar to how `Grid` does.
|
|
544
|
+
* This can reduce flicker around the edges when a user scrolls quickly.
|
|
545
|
+
*/
|
|
546
|
+
verticalOverscanSize: _propTypes["default"].number.isRequired,
|
|
547
|
+
/**
|
|
548
|
+
* Width of Collection; this property determines the number of visible (vs virtualized) columns.
|
|
549
|
+
*/
|
|
550
|
+
width: _propTypes["default"].number.isRequired
|
|
551
|
+
} : {};
|
|
552
|
+
(0, _reactLifecyclesCompat.polyfill)(CollectionView);
|
|
553
|
+
var _default = exports["default"] = CollectionView;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _Section = _interopRequireDefault(require("./Section"));
|
|
5
|
+
describe('Section', function () {
|
|
6
|
+
function helper() {
|
|
7
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
8
|
+
_ref$height = _ref.height,
|
|
9
|
+
height = _ref$height === void 0 ? 100 : _ref$height,
|
|
10
|
+
_ref$width = _ref.width,
|
|
11
|
+
width = _ref$width === void 0 ? 200 : _ref$width,
|
|
12
|
+
_ref$x = _ref.x,
|
|
13
|
+
x = _ref$x === void 0 ? 0 : _ref$x,
|
|
14
|
+
_ref$y = _ref.y,
|
|
15
|
+
y = _ref$y === void 0 ? 0 : _ref$y;
|
|
16
|
+
return new _Section["default"]({
|
|
17
|
+
height: height,
|
|
18
|
+
width: width,
|
|
19
|
+
x: x,
|
|
20
|
+
y: y
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
it('should add a new cell index', function () {
|
|
24
|
+
var section = helper();
|
|
25
|
+
expect(section.getCellIndices()).toEqual([]);
|
|
26
|
+
section.addCellIndex({
|
|
27
|
+
index: 0
|
|
28
|
+
});
|
|
29
|
+
expect(section.getCellIndices()).toEqual([0]);
|
|
30
|
+
section.addCellIndex({
|
|
31
|
+
index: 1
|
|
32
|
+
});
|
|
33
|
+
expect(section.getCellIndices()).toEqual([0, 1]);
|
|
34
|
+
});
|
|
35
|
+
it('should not add a duplicate cell index', function () {
|
|
36
|
+
var section = helper();
|
|
37
|
+
section.addCellIndex({
|
|
38
|
+
index: 0
|
|
39
|
+
});
|
|
40
|
+
section.addCellIndex({
|
|
41
|
+
index: 1
|
|
42
|
+
});
|
|
43
|
+
section.addCellIndex({
|
|
44
|
+
index: 0
|
|
45
|
+
});
|
|
46
|
+
section.addCellIndex({
|
|
47
|
+
index: 1
|
|
48
|
+
});
|
|
49
|
+
section.addCellIndex({
|
|
50
|
+
index: 2
|
|
51
|
+
});
|
|
52
|
+
expect(section.getCellIndices()).toEqual([0, 1, 2]);
|
|
53
|
+
});
|
|
54
|
+
it('should define a working toString() method for debugging', function () {
|
|
55
|
+
var section = helper({
|
|
56
|
+
height: 100,
|
|
57
|
+
width: 200,
|
|
58
|
+
x: 25,
|
|
59
|
+
y: 50
|
|
60
|
+
});
|
|
61
|
+
expect(section.toString()).toEqual('25,50 200x100');
|
|
62
|
+
});
|
|
63
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = void 0;
|
|
8
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
+
/*:: import type {Index, SizeAndPositionInfo} from './types';*/
|
|
11
|
+
/**
|
|
12
|
+
* A section of the Window.
|
|
13
|
+
* Window Sections are used to group nearby cells.
|
|
14
|
+
* This enables us to more quickly determine which cells to display in a given region of the Window.
|
|
15
|
+
* Sections have a fixed size and contain 0 to many cells (tracked by their indices).
|
|
16
|
+
*/
|
|
17
|
+
var Section = exports["default"] = /*#__PURE__*/function () {
|
|
18
|
+
function Section(_ref /*:: */) {
|
|
19
|
+
var height = _ref /*:: */.height,
|
|
20
|
+
width = _ref /*:: */.width,
|
|
21
|
+
x = _ref /*:: */.x,
|
|
22
|
+
y = _ref /*:: */.y;
|
|
23
|
+
(0, _classCallCheck2["default"])(this, Section);
|
|
24
|
+
this.height = height;
|
|
25
|
+
this.width = width;
|
|
26
|
+
this.x = x;
|
|
27
|
+
this.y = y;
|
|
28
|
+
this._indexMap = {};
|
|
29
|
+
this._indices = [];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Add a cell to this section. */
|
|
33
|
+
return (0, _createClass2["default"])(Section, [{
|
|
34
|
+
key: "addCellIndex",
|
|
35
|
+
value: function addCellIndex(_ref2 /*:: */) {
|
|
36
|
+
var index = _ref2 /*:: */.index;
|
|
37
|
+
if (!this._indexMap[index]) {
|
|
38
|
+
this._indexMap[index] = true;
|
|
39
|
+
this._indices.push(index);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Get all cell indices that have been added to this section. */
|
|
44
|
+
}, {
|
|
45
|
+
key: "getCellIndices",
|
|
46
|
+
value: function getCellIndices() /*: Array<number>*/{
|
|
47
|
+
return this._indices;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Intended for debugger/test purposes only */
|
|
51
|
+
}, {
|
|
52
|
+
key: "toString",
|
|
53
|
+
value: function toString() {
|
|
54
|
+
return "".concat(this.x, ",").concat(this.y, " ").concat(this.width, "x").concat(this.height);
|
|
55
|
+
}
|
|
56
|
+
}]);
|
|
57
|
+
}();
|