@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,190 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
4
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
5
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
|
+
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; }
|
|
8
|
+
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; }
|
|
9
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
10
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
11
|
+
import * as React from 'react';
|
|
12
|
+
import createDetectElementResize from '../vendor/detectElementResize';
|
|
13
|
+
/*:: type Size = {
|
|
14
|
+
height: number,
|
|
15
|
+
width: number,
|
|
16
|
+
};*/
|
|
17
|
+
/*:: type Props = {
|
|
18
|
+
/** Function responsible for rendering children.*-/
|
|
19
|
+
children: Size => React.Element<*>,
|
|
20
|
+
|
|
21
|
+
/** Optional custom CSS class name to attach to root AutoSizer element. *-/
|
|
22
|
+
className?: string,
|
|
23
|
+
|
|
24
|
+
/** Default height to use for initial render; useful for SSR *-/
|
|
25
|
+
defaultHeight?: number,
|
|
26
|
+
|
|
27
|
+
/** Default width to use for initial render; useful for SSR *-/
|
|
28
|
+
defaultWidth?: number,
|
|
29
|
+
|
|
30
|
+
/** Disable dynamic :height property *-/
|
|
31
|
+
disableHeight: boolean,
|
|
32
|
+
|
|
33
|
+
/** Disable dynamic :width property *-/
|
|
34
|
+
disableWidth: boolean,
|
|
35
|
+
|
|
36
|
+
/** Nonce of the inlined stylesheet for Content Security Policy *-/
|
|
37
|
+
nonce?: string,
|
|
38
|
+
|
|
39
|
+
/** Callback to be invoked on-resize *-/
|
|
40
|
+
onResize: Size => void,
|
|
41
|
+
|
|
42
|
+
/** Optional inline style *-/
|
|
43
|
+
style: ?Object,
|
|
44
|
+
};*/
|
|
45
|
+
/*:: type State = {
|
|
46
|
+
height: number,
|
|
47
|
+
width: number,
|
|
48
|
+
};*/
|
|
49
|
+
/*:: type ResizeHandler = (element: HTMLElement, onResize: () => void) => void;*/
|
|
50
|
+
/*:: type DetectElementResize = {
|
|
51
|
+
addResizeListener: ResizeHandler,
|
|
52
|
+
removeResizeListener: ResizeHandler,
|
|
53
|
+
};*/
|
|
54
|
+
var AutoSizer = /*#__PURE__*/function (_React$Component) {
|
|
55
|
+
function AutoSizer() {
|
|
56
|
+
var _this;
|
|
57
|
+
_classCallCheck(this, AutoSizer);
|
|
58
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
59
|
+
args[_key] = arguments[_key];
|
|
60
|
+
}
|
|
61
|
+
_this = _callSuper(this, AutoSizer, [].concat(args));
|
|
62
|
+
_defineProperty(_this, "state", {
|
|
63
|
+
height: _this.props.defaultHeight || 0,
|
|
64
|
+
width: _this.props.defaultWidth || 0
|
|
65
|
+
});
|
|
66
|
+
_defineProperty(_this, "_parentNode", void 0);
|
|
67
|
+
_defineProperty(_this, "_autoSizer", void 0);
|
|
68
|
+
_defineProperty(_this, "_window", void 0);
|
|
69
|
+
// uses any instead of Window because Flow doesn't have window type
|
|
70
|
+
_defineProperty(_this, "_detectElementResize", void 0);
|
|
71
|
+
_defineProperty(_this, "_onResize", function () {
|
|
72
|
+
var _this$props = _this.props,
|
|
73
|
+
disableHeight = _this$props.disableHeight,
|
|
74
|
+
disableWidth = _this$props.disableWidth,
|
|
75
|
+
onResize = _this$props.onResize;
|
|
76
|
+
if (_this._parentNode) {
|
|
77
|
+
// Guard against AutoSizer component being removed from the DOM immediately after being added.
|
|
78
|
+
// This can result in invalid style values which can result in NaN values if we don't handle them.
|
|
79
|
+
// See issue #150 for more context.
|
|
80
|
+
|
|
81
|
+
var height = _this._parentNode.offsetHeight || 0;
|
|
82
|
+
var width = _this._parentNode.offsetWidth || 0;
|
|
83
|
+
var win = _this._window || window;
|
|
84
|
+
var style = win.getComputedStyle(_this._parentNode) || {};
|
|
85
|
+
var paddingLeft = parseInt(style.paddingLeft, 10) || 0;
|
|
86
|
+
var paddingRight = parseInt(style.paddingRight, 10) || 0;
|
|
87
|
+
var paddingTop = parseInt(style.paddingTop, 10) || 0;
|
|
88
|
+
var paddingBottom = parseInt(style.paddingBottom, 10) || 0;
|
|
89
|
+
var newHeight = height - paddingTop - paddingBottom;
|
|
90
|
+
var newWidth = width - paddingLeft - paddingRight;
|
|
91
|
+
if (!disableHeight && _this.state.height !== newHeight || !disableWidth && _this.state.width !== newWidth) {
|
|
92
|
+
_this.setState({
|
|
93
|
+
height: height - paddingTop - paddingBottom,
|
|
94
|
+
width: width - paddingLeft - paddingRight
|
|
95
|
+
});
|
|
96
|
+
onResize({
|
|
97
|
+
height: height,
|
|
98
|
+
width: width
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
_defineProperty(_this, "_setRef", function (autoSizer /*: ?HTMLElement*/) {
|
|
104
|
+
_this._autoSizer = autoSizer;
|
|
105
|
+
});
|
|
106
|
+
return _this;
|
|
107
|
+
}
|
|
108
|
+
_inherits(AutoSizer, _React$Component);
|
|
109
|
+
return _createClass(AutoSizer, [{
|
|
110
|
+
key: "componentDidMount",
|
|
111
|
+
value: function componentDidMount() {
|
|
112
|
+
var nonce = this.props.nonce;
|
|
113
|
+
if (this._autoSizer && this._autoSizer.parentNode && this._autoSizer.parentNode.ownerDocument && this._autoSizer.parentNode.ownerDocument.defaultView && this._autoSizer.parentNode instanceof this._autoSizer.parentNode.ownerDocument.defaultView.HTMLElement) {
|
|
114
|
+
// Delay access of parentNode until mount.
|
|
115
|
+
// This handles edge-cases where the component has already been unmounted before its ref has been set,
|
|
116
|
+
// As well as libraries like react-lite which have a slightly different lifecycle.
|
|
117
|
+
this._parentNode = this._autoSizer.parentNode;
|
|
118
|
+
this._window = this._autoSizer.parentNode.ownerDocument.defaultView;
|
|
119
|
+
|
|
120
|
+
// Defer requiring resize handler in order to support server-side rendering.
|
|
121
|
+
// See issue #41
|
|
122
|
+
this._detectElementResize = createDetectElementResize(nonce, this._window);
|
|
123
|
+
this._detectElementResize.addResizeListener(this._parentNode, this._onResize);
|
|
124
|
+
this._onResize();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}, {
|
|
128
|
+
key: "componentWillUnmount",
|
|
129
|
+
value: function componentWillUnmount() {
|
|
130
|
+
if (this._detectElementResize && this._parentNode) {
|
|
131
|
+
this._detectElementResize.removeResizeListener(this._parentNode, this._onResize);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}, {
|
|
135
|
+
key: "render",
|
|
136
|
+
value: function render() {
|
|
137
|
+
var _this$props2 = this.props,
|
|
138
|
+
children = _this$props2.children,
|
|
139
|
+
className = _this$props2.className,
|
|
140
|
+
disableHeight = _this$props2.disableHeight,
|
|
141
|
+
disableWidth = _this$props2.disableWidth,
|
|
142
|
+
style = _this$props2.style;
|
|
143
|
+
var _this$state = this.state,
|
|
144
|
+
height = _this$state.height,
|
|
145
|
+
width = _this$state.width;
|
|
146
|
+
|
|
147
|
+
// Outer div should not force width/height since that may prevent containers from shrinking.
|
|
148
|
+
// Inner component should overflow and use calculated width/height.
|
|
149
|
+
// See issue #68 for more information.
|
|
150
|
+
var outerStyle /*: Object*/ = {
|
|
151
|
+
overflow: 'visible'
|
|
152
|
+
};
|
|
153
|
+
var childParams /*: Object*/ = {};
|
|
154
|
+
if (!disableHeight) {
|
|
155
|
+
outerStyle.height = 0;
|
|
156
|
+
childParams.height = height;
|
|
157
|
+
}
|
|
158
|
+
if (!disableWidth) {
|
|
159
|
+
outerStyle.width = 0;
|
|
160
|
+
childParams.width = width;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* TODO: Avoid rendering children before the initial measurements have been collected.
|
|
165
|
+
* At best this would just be wasting cycles.
|
|
166
|
+
* Add this check into version 10 though as it could break too many ref callbacks in version 9.
|
|
167
|
+
* Note that if default width/height props were provided this would still work with SSR.
|
|
168
|
+
if (
|
|
169
|
+
height !== 0 &&
|
|
170
|
+
width !== 0
|
|
171
|
+
) {
|
|
172
|
+
child = children({ height, width })
|
|
173
|
+
}
|
|
174
|
+
*/
|
|
175
|
+
|
|
176
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
177
|
+
className: className,
|
|
178
|
+
ref: this._setRef,
|
|
179
|
+
style: _objectSpread(_objectSpread({}, outerStyle), style)
|
|
180
|
+
}, children(childParams));
|
|
181
|
+
}
|
|
182
|
+
}]);
|
|
183
|
+
}(React.Component);
|
|
184
|
+
_defineProperty(AutoSizer, "defaultProps", {
|
|
185
|
+
onResize: function onResize() {},
|
|
186
|
+
disableHeight: false,
|
|
187
|
+
disableWidth: false,
|
|
188
|
+
style: {}
|
|
189
|
+
});
|
|
190
|
+
export { AutoSizer as default };
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/** @flow */
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import createDetectElementResize from '../vendor/detectElementResize';
|
|
5
|
+
|
|
6
|
+
type Size = {
|
|
7
|
+
height: number,
|
|
8
|
+
width: number,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
type Props = {
|
|
12
|
+
/** Function responsible for rendering children.*/
|
|
13
|
+
children: Size => React.Element<*>,
|
|
14
|
+
|
|
15
|
+
/** Optional custom CSS class name to attach to root AutoSizer element. */
|
|
16
|
+
className?: string,
|
|
17
|
+
|
|
18
|
+
/** Default height to use for initial render; useful for SSR */
|
|
19
|
+
defaultHeight?: number,
|
|
20
|
+
|
|
21
|
+
/** Default width to use for initial render; useful for SSR */
|
|
22
|
+
defaultWidth?: number,
|
|
23
|
+
|
|
24
|
+
/** Disable dynamic :height property */
|
|
25
|
+
disableHeight: boolean,
|
|
26
|
+
|
|
27
|
+
/** Disable dynamic :width property */
|
|
28
|
+
disableWidth: boolean,
|
|
29
|
+
|
|
30
|
+
/** Nonce of the inlined stylesheet for Content Security Policy */
|
|
31
|
+
nonce?: string,
|
|
32
|
+
|
|
33
|
+
/** Callback to be invoked on-resize */
|
|
34
|
+
onResize: Size => void,
|
|
35
|
+
|
|
36
|
+
/** Optional inline style */
|
|
37
|
+
style: ?Object,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
type State = {
|
|
41
|
+
height: number,
|
|
42
|
+
width: number,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
type ResizeHandler = (element: HTMLElement, onResize: () => void) => void;
|
|
46
|
+
|
|
47
|
+
type DetectElementResize = {
|
|
48
|
+
addResizeListener: ResizeHandler,
|
|
49
|
+
removeResizeListener: ResizeHandler,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export default class AutoSizer extends React.Component<Props, State> {
|
|
53
|
+
static defaultProps = {
|
|
54
|
+
onResize: () => {},
|
|
55
|
+
disableHeight: false,
|
|
56
|
+
disableWidth: false,
|
|
57
|
+
style: {},
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
state = {
|
|
61
|
+
height: this.props.defaultHeight || 0,
|
|
62
|
+
width: this.props.defaultWidth || 0,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
_parentNode: ?HTMLElement;
|
|
66
|
+
_autoSizer: ?HTMLElement;
|
|
67
|
+
_window: ?any; // uses any instead of Window because Flow doesn't have window type
|
|
68
|
+
_detectElementResize: DetectElementResize;
|
|
69
|
+
|
|
70
|
+
componentDidMount() {
|
|
71
|
+
const {nonce} = this.props;
|
|
72
|
+
if (
|
|
73
|
+
this._autoSizer &&
|
|
74
|
+
this._autoSizer.parentNode &&
|
|
75
|
+
this._autoSizer.parentNode.ownerDocument &&
|
|
76
|
+
this._autoSizer.parentNode.ownerDocument.defaultView &&
|
|
77
|
+
this._autoSizer.parentNode instanceof
|
|
78
|
+
this._autoSizer.parentNode.ownerDocument.defaultView.HTMLElement
|
|
79
|
+
) {
|
|
80
|
+
// Delay access of parentNode until mount.
|
|
81
|
+
// This handles edge-cases where the component has already been unmounted before its ref has been set,
|
|
82
|
+
// As well as libraries like react-lite which have a slightly different lifecycle.
|
|
83
|
+
this._parentNode = this._autoSizer.parentNode;
|
|
84
|
+
this._window = this._autoSizer.parentNode.ownerDocument.defaultView;
|
|
85
|
+
|
|
86
|
+
// Defer requiring resize handler in order to support server-side rendering.
|
|
87
|
+
// See issue #41
|
|
88
|
+
this._detectElementResize = createDetectElementResize(
|
|
89
|
+
nonce,
|
|
90
|
+
this._window,
|
|
91
|
+
);
|
|
92
|
+
this._detectElementResize.addResizeListener(
|
|
93
|
+
this._parentNode,
|
|
94
|
+
this._onResize,
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
this._onResize();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
componentWillUnmount() {
|
|
102
|
+
if (this._detectElementResize && this._parentNode) {
|
|
103
|
+
this._detectElementResize.removeResizeListener(
|
|
104
|
+
this._parentNode,
|
|
105
|
+
this._onResize,
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
render() {
|
|
111
|
+
const {
|
|
112
|
+
children,
|
|
113
|
+
className,
|
|
114
|
+
disableHeight,
|
|
115
|
+
disableWidth,
|
|
116
|
+
style,
|
|
117
|
+
} = this.props;
|
|
118
|
+
const {height, width} = this.state;
|
|
119
|
+
|
|
120
|
+
// Outer div should not force width/height since that may prevent containers from shrinking.
|
|
121
|
+
// Inner component should overflow and use calculated width/height.
|
|
122
|
+
// See issue #68 for more information.
|
|
123
|
+
const outerStyle: Object = {overflow: 'visible'};
|
|
124
|
+
const childParams: Object = {};
|
|
125
|
+
|
|
126
|
+
if (!disableHeight) {
|
|
127
|
+
outerStyle.height = 0;
|
|
128
|
+
childParams.height = height;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (!disableWidth) {
|
|
132
|
+
outerStyle.width = 0;
|
|
133
|
+
childParams.width = width;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* TODO: Avoid rendering children before the initial measurements have been collected.
|
|
138
|
+
* At best this would just be wasting cycles.
|
|
139
|
+
* Add this check into version 10 though as it could break too many ref callbacks in version 9.
|
|
140
|
+
* Note that if default width/height props were provided this would still work with SSR.
|
|
141
|
+
if (
|
|
142
|
+
height !== 0 &&
|
|
143
|
+
width !== 0
|
|
144
|
+
) {
|
|
145
|
+
child = children({ height, width })
|
|
146
|
+
}
|
|
147
|
+
*/
|
|
148
|
+
|
|
149
|
+
return (
|
|
150
|
+
<div
|
|
151
|
+
className={className}
|
|
152
|
+
ref={this._setRef}
|
|
153
|
+
style={{
|
|
154
|
+
...outerStyle,
|
|
155
|
+
...style,
|
|
156
|
+
}}>
|
|
157
|
+
{children(childParams)}
|
|
158
|
+
</div>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
_onResize = () => {
|
|
163
|
+
const {disableHeight, disableWidth, onResize} = this.props;
|
|
164
|
+
|
|
165
|
+
if (this._parentNode) {
|
|
166
|
+
// Guard against AutoSizer component being removed from the DOM immediately after being added.
|
|
167
|
+
// This can result in invalid style values which can result in NaN values if we don't handle them.
|
|
168
|
+
// See issue #150 for more context.
|
|
169
|
+
|
|
170
|
+
const height = this._parentNode.offsetHeight || 0;
|
|
171
|
+
const width = this._parentNode.offsetWidth || 0;
|
|
172
|
+
|
|
173
|
+
const win = this._window || window;
|
|
174
|
+
const style = win.getComputedStyle(this._parentNode) || {};
|
|
175
|
+
const paddingLeft = parseInt(style.paddingLeft, 10) || 0;
|
|
176
|
+
const paddingRight = parseInt(style.paddingRight, 10) || 0;
|
|
177
|
+
const paddingTop = parseInt(style.paddingTop, 10) || 0;
|
|
178
|
+
const paddingBottom = parseInt(style.paddingBottom, 10) || 0;
|
|
179
|
+
|
|
180
|
+
const newHeight = height - paddingTop - paddingBottom;
|
|
181
|
+
const newWidth = width - paddingLeft - paddingRight;
|
|
182
|
+
|
|
183
|
+
if (
|
|
184
|
+
(!disableHeight && this.state.height !== newHeight) ||
|
|
185
|
+
(!disableWidth && this.state.width !== newWidth)
|
|
186
|
+
) {
|
|
187
|
+
this.setState({
|
|
188
|
+
height: height - paddingTop - paddingBottom,
|
|
189
|
+
width: width - paddingLeft - paddingRight,
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
onResize({height, width});
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
_setRef = (autoSizer: ?HTMLElement) => {
|
|
198
|
+
this._autoSizer = autoSizer;
|
|
199
|
+
};
|
|
200
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment node
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import * as ReactDOMServer from 'react-dom/server';
|
|
7
|
+
import AutoSizer from './AutoSizer';
|
|
8
|
+
test('should render content with default widths and heights initially', function () {
|
|
9
|
+
var rendered = ReactDOMServer.renderToString(/*#__PURE__*/React.createElement(AutoSizer, {
|
|
10
|
+
defaultHeight: 100,
|
|
11
|
+
defaultWidth: 200
|
|
12
|
+
}, function (_ref) {
|
|
13
|
+
var height = _ref.height,
|
|
14
|
+
width = _ref.width;
|
|
15
|
+
return /*#__PURE__*/React.createElement("div", null, "height:".concat(height, ";width:").concat(width));
|
|
16
|
+
}));
|
|
17
|
+
expect(rendered).toContain('height:100');
|
|
18
|
+
expect(rendered).toContain('width:200');
|
|
19
|
+
});
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
|
+
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; }
|
|
8
|
+
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; }
|
|
9
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
10
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
11
|
+
import Immutable from 'immutable';
|
|
12
|
+
import PropTypes from 'prop-types';
|
|
13
|
+
import * as React from 'react';
|
|
14
|
+
import CellMeasurer from './CellMeasurer';
|
|
15
|
+
import CellMeasurerCache from './CellMeasurerCache';
|
|
16
|
+
import Grid from '../Grid';
|
|
17
|
+
import styles from './CellMeasurer.example.css';
|
|
18
|
+
var DynamicHeightGrid = /*#__PURE__*/function (_React$PureComponent) {
|
|
19
|
+
function DynamicHeightGrid(props, context) {
|
|
20
|
+
var _this;
|
|
21
|
+
_classCallCheck(this, DynamicHeightGrid);
|
|
22
|
+
_this = _callSuper(this, DynamicHeightGrid, [props, context]);
|
|
23
|
+
_this._cache = new CellMeasurerCache({
|
|
24
|
+
defaultWidth: 150,
|
|
25
|
+
fixedWidth: true
|
|
26
|
+
});
|
|
27
|
+
_this._cellRenderer = _this._cellRenderer.bind(_this);
|
|
28
|
+
return _this;
|
|
29
|
+
}
|
|
30
|
+
_inherits(DynamicHeightGrid, _React$PureComponent);
|
|
31
|
+
return _createClass(DynamicHeightGrid, [{
|
|
32
|
+
key: "render",
|
|
33
|
+
value: function render() {
|
|
34
|
+
var width = this.props.width;
|
|
35
|
+
return /*#__PURE__*/React.createElement(Grid, {
|
|
36
|
+
className: styles.BodyGrid,
|
|
37
|
+
columnCount: 50,
|
|
38
|
+
columnWidth: 150,
|
|
39
|
+
deferredMeasurementCache: this._cache,
|
|
40
|
+
height: 400,
|
|
41
|
+
overscanColumnCount: 0,
|
|
42
|
+
overscanRowCount: 2,
|
|
43
|
+
cellRenderer: this._cellRenderer,
|
|
44
|
+
rowCount: 1000,
|
|
45
|
+
rowHeight: this._cache.rowHeight,
|
|
46
|
+
width: width
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}, {
|
|
50
|
+
key: "_cellRenderer",
|
|
51
|
+
value: function _cellRenderer(_ref) {
|
|
52
|
+
var columnIndex = _ref.columnIndex,
|
|
53
|
+
key = _ref.key,
|
|
54
|
+
parent = _ref.parent,
|
|
55
|
+
rowIndex = _ref.rowIndex,
|
|
56
|
+
style = _ref.style;
|
|
57
|
+
var _this$props = this.props,
|
|
58
|
+
getClassName = _this$props.getClassName,
|
|
59
|
+
getContent = _this$props.getContent,
|
|
60
|
+
list = _this$props.list;
|
|
61
|
+
var datum = list.get((rowIndex + columnIndex) % list.size);
|
|
62
|
+
var classNames = getClassName({
|
|
63
|
+
columnIndex: columnIndex,
|
|
64
|
+
rowIndex: rowIndex
|
|
65
|
+
});
|
|
66
|
+
var content = getContent({
|
|
67
|
+
index: rowIndex,
|
|
68
|
+
datum: datum
|
|
69
|
+
});
|
|
70
|
+
return /*#__PURE__*/React.createElement(CellMeasurer, {
|
|
71
|
+
cache: this._cache,
|
|
72
|
+
columnIndex: columnIndex,
|
|
73
|
+
key: key,
|
|
74
|
+
parent: parent,
|
|
75
|
+
rowIndex: rowIndex
|
|
76
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
77
|
+
className: classNames,
|
|
78
|
+
style: _objectSpread(_objectSpread({}, style), {}, {
|
|
79
|
+
width: 150
|
|
80
|
+
})
|
|
81
|
+
}, content));
|
|
82
|
+
}
|
|
83
|
+
}]);
|
|
84
|
+
}(React.PureComponent);
|
|
85
|
+
export { DynamicHeightGrid as default };
|
|
86
|
+
DynamicHeightGrid.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
87
|
+
getClassName: PropTypes.func.isRequired,
|
|
88
|
+
getContent: PropTypes.func.isRequired,
|
|
89
|
+
list: PropTypes.instanceOf(Immutable.List).isRequired,
|
|
90
|
+
width: PropTypes.number.isRequired
|
|
91
|
+
} : {};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
4
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
5
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
7
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
8
|
+
import Immutable from 'immutable';
|
|
9
|
+
import PropTypes from 'prop-types';
|
|
10
|
+
import * as React from 'react';
|
|
11
|
+
import CellMeasurer from './CellMeasurer';
|
|
12
|
+
import CellMeasurerCache from './CellMeasurerCache';
|
|
13
|
+
import List from '../List';
|
|
14
|
+
import styles from './CellMeasurer.example.css';
|
|
15
|
+
var DynamicHeightList = /*#__PURE__*/function (_React$PureComponent) {
|
|
16
|
+
function DynamicHeightList(props, context) {
|
|
17
|
+
var _this;
|
|
18
|
+
_classCallCheck(this, DynamicHeightList);
|
|
19
|
+
_this = _callSuper(this, DynamicHeightList, [props, context]);
|
|
20
|
+
_this._cache = new CellMeasurerCache({
|
|
21
|
+
fixedWidth: true,
|
|
22
|
+
minHeight: 50
|
|
23
|
+
});
|
|
24
|
+
_this._rowRenderer = _this._rowRenderer.bind(_this);
|
|
25
|
+
return _this;
|
|
26
|
+
}
|
|
27
|
+
_inherits(DynamicHeightList, _React$PureComponent);
|
|
28
|
+
return _createClass(DynamicHeightList, [{
|
|
29
|
+
key: "render",
|
|
30
|
+
value: function render() {
|
|
31
|
+
var width = this.props.width;
|
|
32
|
+
return /*#__PURE__*/React.createElement(List, {
|
|
33
|
+
className: styles.BodyGrid,
|
|
34
|
+
deferredMeasurementCache: this._cache,
|
|
35
|
+
height: 400,
|
|
36
|
+
overscanRowCount: 0,
|
|
37
|
+
rowCount: 1000,
|
|
38
|
+
rowHeight: this._cache.rowHeight,
|
|
39
|
+
rowRenderer: this._rowRenderer,
|
|
40
|
+
width: width
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}, {
|
|
44
|
+
key: "_rowRenderer",
|
|
45
|
+
value: function _rowRenderer(_ref) {
|
|
46
|
+
var index = _ref.index,
|
|
47
|
+
key = _ref.key,
|
|
48
|
+
parent = _ref.parent,
|
|
49
|
+
style = _ref.style;
|
|
50
|
+
var _this$props = this.props,
|
|
51
|
+
getClassName = _this$props.getClassName,
|
|
52
|
+
list = _this$props.list;
|
|
53
|
+
var datum = list.get(index % list.size);
|
|
54
|
+
var classNames = getClassName({
|
|
55
|
+
columnIndex: 0,
|
|
56
|
+
rowIndex: index
|
|
57
|
+
});
|
|
58
|
+
var imageWidth = 300;
|
|
59
|
+
var imageHeight = datum.size * (1 + index % 3);
|
|
60
|
+
var source = "https://www.fillmurray.com/".concat(imageWidth, "/").concat(imageHeight);
|
|
61
|
+
return /*#__PURE__*/React.createElement(CellMeasurer, {
|
|
62
|
+
cache: this._cache,
|
|
63
|
+
columnIndex: 0,
|
|
64
|
+
key: key,
|
|
65
|
+
rowIndex: index,
|
|
66
|
+
parent: parent
|
|
67
|
+
}, function (_ref2) {
|
|
68
|
+
var measure = _ref2.measure,
|
|
69
|
+
registerChild = _ref2.registerChild;
|
|
70
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
71
|
+
ref: registerChild,
|
|
72
|
+
className: classNames,
|
|
73
|
+
style: style
|
|
74
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
75
|
+
onLoad: measure,
|
|
76
|
+
src: source,
|
|
77
|
+
style: {
|
|
78
|
+
width: imageWidth
|
|
79
|
+
}
|
|
80
|
+
}));
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}]);
|
|
84
|
+
}(React.PureComponent);
|
|
85
|
+
export { DynamicHeightList as default };
|
|
86
|
+
DynamicHeightList.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
87
|
+
getClassName: PropTypes.func.isRequired,
|
|
88
|
+
list: PropTypes.instanceOf(Immutable.List).isRequired,
|
|
89
|
+
width: PropTypes.number.isRequired
|
|
90
|
+
} : {};
|