react-window 1.8.6 → 1.8.8
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/README.md +69 -1
- package/dist/index-dev.umd.js +1 -1
- package/dist/index-dev.umd.js.map +1 -1
- package/dist/index-prod.umd.js +1 -1
- package/dist/index-prod.umd.js.map +1 -1
- package/dist/index.cjs.js +82 -85
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +81 -84
- package/dist/index.esm.js.map +1 -1
- package/package.json +14 -11
- package/src/FixedSizeList.js +9 -2
- package/src/VariableSizeList.js +3 -2
- package/src/createListComponent.js +23 -3
- package/CHANGELOG.md +0 -121
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
2
|
-
import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';
|
|
3
2
|
import _assertThisInitialized from '@babel/runtime/helpers/esm/assertThisInitialized';
|
|
3
|
+
import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';
|
|
4
4
|
import memoizeOne from 'memoize-one';
|
|
5
5
|
import { createElement, PureComponent } from 'react';
|
|
6
6
|
import _objectWithoutPropertiesLoose from '@babel/runtime/helpers/esm/objectWithoutPropertiesLoose';
|
|
@@ -115,20 +115,14 @@ var devWarningsTagName = null;
|
|
|
115
115
|
|
|
116
116
|
if (process.env.NODE_ENV !== 'production') {
|
|
117
117
|
if (typeof window !== 'undefined' && typeof window.WeakSet !== 'undefined') {
|
|
118
|
-
devWarningsOverscanCount =
|
|
119
|
-
/*#__PURE__*/
|
|
120
|
-
new WeakSet();
|
|
121
|
-
devWarningsOverscanRowsColumnsCount =
|
|
122
|
-
/*#__PURE__*/
|
|
123
|
-
new WeakSet();
|
|
124
|
-
devWarningsTagName =
|
|
125
|
-
/*#__PURE__*/
|
|
126
|
-
new WeakSet();
|
|
118
|
+
devWarningsOverscanCount = /*#__PURE__*/new WeakSet();
|
|
119
|
+
devWarningsOverscanRowsColumnsCount = /*#__PURE__*/new WeakSet();
|
|
120
|
+
devWarningsTagName = /*#__PURE__*/new WeakSet();
|
|
127
121
|
}
|
|
128
122
|
}
|
|
129
123
|
|
|
130
124
|
function createGridComponent(_ref2) {
|
|
131
|
-
var _class
|
|
125
|
+
var _class;
|
|
132
126
|
|
|
133
127
|
var getColumnOffset = _ref2.getColumnOffset,
|
|
134
128
|
getColumnStartIndexForOffset = _ref2.getColumnStartIndexForOffset,
|
|
@@ -145,9 +139,7 @@ function createGridComponent(_ref2) {
|
|
|
145
139
|
initInstanceProps = _ref2.initInstanceProps,
|
|
146
140
|
shouldResetStyleCacheOnItemSizeChange = _ref2.shouldResetStyleCacheOnItemSizeChange,
|
|
147
141
|
validateProps = _ref2.validateProps;
|
|
148
|
-
return
|
|
149
|
-
/*#__PURE__*/
|
|
150
|
-
function (_PureComponent) {
|
|
142
|
+
return _class = /*#__PURE__*/function (_PureComponent) {
|
|
151
143
|
_inheritsLoose(Grid, _PureComponent);
|
|
152
144
|
|
|
153
145
|
// Always use explicit constructor for React components.
|
|
@@ -157,11 +149,11 @@ function createGridComponent(_ref2) {
|
|
|
157
149
|
var _this;
|
|
158
150
|
|
|
159
151
|
_this = _PureComponent.call(this, props) || this;
|
|
160
|
-
_this._instanceProps = initInstanceProps(_this.props, _assertThisInitialized(
|
|
152
|
+
_this._instanceProps = initInstanceProps(_this.props, _assertThisInitialized(_this));
|
|
161
153
|
_this._resetIsScrollingTimeoutId = null;
|
|
162
154
|
_this._outerRef = void 0;
|
|
163
155
|
_this.state = {
|
|
164
|
-
instance: _assertThisInitialized(
|
|
156
|
+
instance: _assertThisInitialized(_this),
|
|
165
157
|
isScrolling: false,
|
|
166
158
|
horizontalScrollDirection: 'forward',
|
|
167
159
|
scrollLeft: typeof _this.props.initialScrollLeft === 'number' ? _this.props.initialScrollLeft : 0,
|
|
@@ -570,11 +562,11 @@ function createGridComponent(_ref2) {
|
|
|
570
562
|
|
|
571
563
|
this._callOnScroll(_scrollLeft, _scrollTop, _horizontalScrollDirection, _verticalScrollDirection, _scrollUpdateWasRequested);
|
|
572
564
|
}
|
|
573
|
-
}
|
|
565
|
+
} // Lazily create and cache item styles while scrolling,
|
|
574
566
|
// So that pure component sCU will prevent re-renders.
|
|
575
567
|
// We maintain this cache, and pass a style prop rather than index,
|
|
576
568
|
// So that List can clear cached styles and force item re-render if necessary.
|
|
577
|
-
|
|
569
|
+
;
|
|
578
570
|
|
|
579
571
|
_proto._getHorizontalRangeToRender = function _getHorizontalRangeToRender() {
|
|
580
572
|
var _this$props6 = this.props,
|
|
@@ -633,7 +625,7 @@ function createGridComponent(_ref2) {
|
|
|
633
625
|
direction: 'ltr',
|
|
634
626
|
itemData: undefined,
|
|
635
627
|
useIsScrolling: false
|
|
636
|
-
},
|
|
628
|
+
}, _class;
|
|
637
629
|
}
|
|
638
630
|
|
|
639
631
|
var validateSharedProps = function validateSharedProps(_ref5, _ref6) {
|
|
@@ -881,9 +873,7 @@ var getOffsetForIndexAndAlignment = function getOffsetForIndexAndAlignment(itemT
|
|
|
881
873
|
}
|
|
882
874
|
};
|
|
883
875
|
|
|
884
|
-
var VariableSizeGrid =
|
|
885
|
-
/*#__PURE__*/
|
|
886
|
-
createGridComponent({
|
|
876
|
+
var VariableSizeGrid = /*#__PURE__*/createGridComponent({
|
|
887
877
|
getColumnOffset: function getColumnOffset(props, index, instanceProps) {
|
|
888
878
|
return getItemMetadata('column', props, index, instanceProps).offset;
|
|
889
879
|
},
|
|
@@ -1030,17 +1020,13 @@ var devWarningsTagName$1 = null;
|
|
|
1030
1020
|
|
|
1031
1021
|
if (process.env.NODE_ENV !== 'production') {
|
|
1032
1022
|
if (typeof window !== 'undefined' && typeof window.WeakSet !== 'undefined') {
|
|
1033
|
-
devWarningsDirection =
|
|
1034
|
-
/*#__PURE__*/
|
|
1035
|
-
new WeakSet();
|
|
1036
|
-
devWarningsTagName$1 =
|
|
1037
|
-
/*#__PURE__*/
|
|
1038
|
-
new WeakSet();
|
|
1023
|
+
devWarningsDirection = /*#__PURE__*/new WeakSet();
|
|
1024
|
+
devWarningsTagName$1 = /*#__PURE__*/new WeakSet();
|
|
1039
1025
|
}
|
|
1040
1026
|
}
|
|
1041
1027
|
|
|
1042
1028
|
function createListComponent(_ref) {
|
|
1043
|
-
var _class
|
|
1029
|
+
var _class;
|
|
1044
1030
|
|
|
1045
1031
|
var getItemOffset = _ref.getItemOffset,
|
|
1046
1032
|
getEstimatedTotalSize = _ref.getEstimatedTotalSize,
|
|
@@ -1051,9 +1037,7 @@ function createListComponent(_ref) {
|
|
|
1051
1037
|
initInstanceProps = _ref.initInstanceProps,
|
|
1052
1038
|
shouldResetStyleCacheOnItemSizeChange = _ref.shouldResetStyleCacheOnItemSizeChange,
|
|
1053
1039
|
validateProps = _ref.validateProps;
|
|
1054
|
-
return
|
|
1055
|
-
/*#__PURE__*/
|
|
1056
|
-
function (_PureComponent) {
|
|
1040
|
+
return _class = /*#__PURE__*/function (_PureComponent) {
|
|
1057
1041
|
_inheritsLoose(List, _PureComponent);
|
|
1058
1042
|
|
|
1059
1043
|
// Always use explicit constructor for React components.
|
|
@@ -1063,11 +1047,11 @@ function createListComponent(_ref) {
|
|
|
1063
1047
|
var _this;
|
|
1064
1048
|
|
|
1065
1049
|
_this = _PureComponent.call(this, props) || this;
|
|
1066
|
-
_this._instanceProps = initInstanceProps(_this.props, _assertThisInitialized(
|
|
1050
|
+
_this._instanceProps = initInstanceProps(_this.props, _assertThisInitialized(_this));
|
|
1067
1051
|
_this._outerRef = void 0;
|
|
1068
1052
|
_this._resetIsScrollingTimeoutId = null;
|
|
1069
1053
|
_this.state = {
|
|
1070
|
-
instance: _assertThisInitialized(
|
|
1054
|
+
instance: _assertThisInitialized(_this),
|
|
1071
1055
|
isScrolling: false,
|
|
1072
1056
|
scrollDirection: 'forward',
|
|
1073
1057
|
scrollOffset: typeof _this.props.initialScrollOffset === 'number' ? _this.props.initialScrollOffset : 0,
|
|
@@ -1261,17 +1245,34 @@ function createListComponent(_ref) {
|
|
|
1261
1245
|
align = 'auto';
|
|
1262
1246
|
}
|
|
1263
1247
|
|
|
1264
|
-
var
|
|
1248
|
+
var _this$props2 = this.props,
|
|
1249
|
+
itemCount = _this$props2.itemCount,
|
|
1250
|
+
layout = _this$props2.layout;
|
|
1265
1251
|
var scrollOffset = this.state.scrollOffset;
|
|
1266
|
-
index = Math.max(0, Math.min(index, itemCount - 1));
|
|
1267
|
-
|
|
1252
|
+
index = Math.max(0, Math.min(index, itemCount - 1)); // The scrollbar size should be considered when scrolling an item into view, to ensure it's fully visible.
|
|
1253
|
+
// But we only need to account for its size when it's actually visible.
|
|
1254
|
+
// This is an edge case for lists; normally they only scroll in the dominant direction.
|
|
1255
|
+
|
|
1256
|
+
var scrollbarSize = 0;
|
|
1257
|
+
|
|
1258
|
+
if (this._outerRef) {
|
|
1259
|
+
var outerRef = this._outerRef;
|
|
1260
|
+
|
|
1261
|
+
if (layout === 'vertical') {
|
|
1262
|
+
scrollbarSize = outerRef.scrollWidth > outerRef.clientWidth ? getScrollbarSize() : 0;
|
|
1263
|
+
} else {
|
|
1264
|
+
scrollbarSize = outerRef.scrollHeight > outerRef.clientHeight ? getScrollbarSize() : 0;
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
this.scrollTo(getOffsetForIndexAndAlignment(this.props, index, align, scrollOffset, this._instanceProps, scrollbarSize));
|
|
1268
1269
|
};
|
|
1269
1270
|
|
|
1270
1271
|
_proto.componentDidMount = function componentDidMount() {
|
|
1271
|
-
var _this$
|
|
1272
|
-
direction = _this$
|
|
1273
|
-
initialScrollOffset = _this$
|
|
1274
|
-
layout = _this$
|
|
1272
|
+
var _this$props3 = this.props,
|
|
1273
|
+
direction = _this$props3.direction,
|
|
1274
|
+
initialScrollOffset = _this$props3.initialScrollOffset,
|
|
1275
|
+
layout = _this$props3.layout;
|
|
1275
1276
|
|
|
1276
1277
|
if (typeof initialScrollOffset === 'number' && this._outerRef != null) {
|
|
1277
1278
|
var outerRef = this._outerRef; // TODO Deprecate direction "horizontal"
|
|
@@ -1287,9 +1288,9 @@ function createListComponent(_ref) {
|
|
|
1287
1288
|
};
|
|
1288
1289
|
|
|
1289
1290
|
_proto.componentDidUpdate = function componentDidUpdate() {
|
|
1290
|
-
var _this$
|
|
1291
|
-
direction = _this$
|
|
1292
|
-
layout = _this$
|
|
1291
|
+
var _this$props4 = this.props,
|
|
1292
|
+
direction = _this$props4.direction,
|
|
1293
|
+
layout = _this$props4.layout;
|
|
1293
1294
|
var _this$state = this.state,
|
|
1294
1295
|
scrollOffset = _this$state.scrollOffset,
|
|
1295
1296
|
scrollUpdateWasRequested = _this$state.scrollUpdateWasRequested;
|
|
@@ -1335,24 +1336,24 @@ function createListComponent(_ref) {
|
|
|
1335
1336
|
};
|
|
1336
1337
|
|
|
1337
1338
|
_proto.render = function render() {
|
|
1338
|
-
var _this$
|
|
1339
|
-
children = _this$
|
|
1340
|
-
className = _this$
|
|
1341
|
-
direction = _this$
|
|
1342
|
-
height = _this$
|
|
1343
|
-
innerRef = _this$
|
|
1344
|
-
innerElementType = _this$
|
|
1345
|
-
innerTagName = _this$
|
|
1346
|
-
itemCount = _this$
|
|
1347
|
-
itemData = _this$
|
|
1348
|
-
_this$
|
|
1349
|
-
itemKey = _this$
|
|
1350
|
-
layout = _this$
|
|
1351
|
-
outerElementType = _this$
|
|
1352
|
-
outerTagName = _this$
|
|
1353
|
-
style = _this$
|
|
1354
|
-
useIsScrolling = _this$
|
|
1355
|
-
width = _this$
|
|
1339
|
+
var _this$props5 = this.props,
|
|
1340
|
+
children = _this$props5.children,
|
|
1341
|
+
className = _this$props5.className,
|
|
1342
|
+
direction = _this$props5.direction,
|
|
1343
|
+
height = _this$props5.height,
|
|
1344
|
+
innerRef = _this$props5.innerRef,
|
|
1345
|
+
innerElementType = _this$props5.innerElementType,
|
|
1346
|
+
innerTagName = _this$props5.innerTagName,
|
|
1347
|
+
itemCount = _this$props5.itemCount,
|
|
1348
|
+
itemData = _this$props5.itemData,
|
|
1349
|
+
_this$props5$itemKey = _this$props5.itemKey,
|
|
1350
|
+
itemKey = _this$props5$itemKey === void 0 ? defaultItemKey$1 : _this$props5$itemKey,
|
|
1351
|
+
layout = _this$props5.layout,
|
|
1352
|
+
outerElementType = _this$props5.outerElementType,
|
|
1353
|
+
outerTagName = _this$props5.outerTagName,
|
|
1354
|
+
style = _this$props5.style,
|
|
1355
|
+
useIsScrolling = _this$props5.useIsScrolling,
|
|
1356
|
+
width = _this$props5.width;
|
|
1356
1357
|
var isScrolling = this.state.isScrolling; // TODO Deprecate direction "horizontal"
|
|
1357
1358
|
|
|
1358
1359
|
var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
|
|
@@ -1426,16 +1427,16 @@ function createListComponent(_ref) {
|
|
|
1426
1427
|
|
|
1427
1428
|
this._callOnScroll(_scrollDirection, _scrollOffset, _scrollUpdateWasRequested);
|
|
1428
1429
|
}
|
|
1429
|
-
}
|
|
1430
|
+
} // Lazily create and cache item styles while scrolling,
|
|
1430
1431
|
// So that pure component sCU will prevent re-renders.
|
|
1431
1432
|
// We maintain this cache, and pass a style prop rather than index,
|
|
1432
1433
|
// So that List can clear cached styles and force item re-render if necessary.
|
|
1433
|
-
|
|
1434
|
+
;
|
|
1434
1435
|
|
|
1435
1436
|
_proto._getRangeToRender = function _getRangeToRender() {
|
|
1436
|
-
var _this$
|
|
1437
|
-
itemCount = _this$
|
|
1438
|
-
overscanCount = _this$
|
|
1437
|
+
var _this$props6 = this.props,
|
|
1438
|
+
itemCount = _this$props6.itemCount,
|
|
1439
|
+
overscanCount = _this$props6.overscanCount;
|
|
1439
1440
|
var _this$state3 = this.state,
|
|
1440
1441
|
isScrolling = _this$state3.isScrolling,
|
|
1441
1442
|
scrollDirection = _this$state3.scrollDirection,
|
|
@@ -1461,7 +1462,7 @@ function createListComponent(_ref) {
|
|
|
1461
1462
|
layout: 'vertical',
|
|
1462
1463
|
overscanCount: 2,
|
|
1463
1464
|
useIsScrolling: false
|
|
1464
|
-
},
|
|
1465
|
+
}, _class;
|
|
1465
1466
|
} // NOTE: I considered further wrapping individual items with a pure ListItem component.
|
|
1466
1467
|
// This would avoid ever calling the render function for the same index more than once,
|
|
1467
1468
|
// But it would also add the overhead of a lot of components/fibers.
|
|
@@ -1632,9 +1633,7 @@ var getEstimatedTotalSize = function getEstimatedTotalSize(_ref2, _ref3) {
|
|
|
1632
1633
|
return totalSizeOfMeasuredItems + totalSizeOfUnmeasuredItems;
|
|
1633
1634
|
};
|
|
1634
1635
|
|
|
1635
|
-
var VariableSizeList =
|
|
1636
|
-
/*#__PURE__*/
|
|
1637
|
-
createListComponent({
|
|
1636
|
+
var VariableSizeList = /*#__PURE__*/createListComponent({
|
|
1638
1637
|
getItemOffset: function getItemOffset(props, index, instanceProps) {
|
|
1639
1638
|
return getItemMetadata$1(props, index, instanceProps).offset;
|
|
1640
1639
|
},
|
|
@@ -1642,7 +1641,7 @@ createListComponent({
|
|
|
1642
1641
|
return instanceProps.itemMetadataMap[index].size;
|
|
1643
1642
|
},
|
|
1644
1643
|
getEstimatedTotalSize: getEstimatedTotalSize,
|
|
1645
|
-
getOffsetForIndexAndAlignment: function getOffsetForIndexAndAlignment(props, index, align, scrollOffset, instanceProps) {
|
|
1644
|
+
getOffsetForIndexAndAlignment: function getOffsetForIndexAndAlignment(props, index, align, scrollOffset, instanceProps, scrollbarSize) {
|
|
1646
1645
|
var direction = props.direction,
|
|
1647
1646
|
height = props.height,
|
|
1648
1647
|
layout = props.layout,
|
|
@@ -1655,7 +1654,7 @@ createListComponent({
|
|
|
1655
1654
|
|
|
1656
1655
|
var estimatedTotalSize = getEstimatedTotalSize(props, instanceProps);
|
|
1657
1656
|
var maxOffset = Math.max(0, Math.min(estimatedTotalSize - size, itemMetadata.offset));
|
|
1658
|
-
var minOffset = Math.max(0, itemMetadata.offset - size + itemMetadata.size);
|
|
1657
|
+
var minOffset = Math.max(0, itemMetadata.offset - size + itemMetadata.size + scrollbarSize);
|
|
1659
1658
|
|
|
1660
1659
|
if (align === 'smart') {
|
|
1661
1660
|
if (scrollOffset >= minOffset - size && scrollOffset <= maxOffset + size) {
|
|
@@ -1751,9 +1750,7 @@ createListComponent({
|
|
|
1751
1750
|
}
|
|
1752
1751
|
});
|
|
1753
1752
|
|
|
1754
|
-
var FixedSizeGrid =
|
|
1755
|
-
/*#__PURE__*/
|
|
1756
|
-
createGridComponent({
|
|
1753
|
+
var FixedSizeGrid = /*#__PURE__*/createGridComponent({
|
|
1757
1754
|
getColumnOffset: function getColumnOffset(_ref, index) {
|
|
1758
1755
|
var columnWidth = _ref.columnWidth;
|
|
1759
1756
|
return index * columnWidth;
|
|
@@ -1931,9 +1928,7 @@ createGridComponent({
|
|
|
1931
1928
|
}
|
|
1932
1929
|
});
|
|
1933
1930
|
|
|
1934
|
-
var FixedSizeList =
|
|
1935
|
-
/*#__PURE__*/
|
|
1936
|
-
createListComponent({
|
|
1931
|
+
var FixedSizeList = /*#__PURE__*/createListComponent({
|
|
1937
1932
|
getItemOffset: function getItemOffset(_ref, index) {
|
|
1938
1933
|
var itemSize = _ref.itemSize;
|
|
1939
1934
|
return index * itemSize;
|
|
@@ -1947,7 +1942,7 @@ createListComponent({
|
|
|
1947
1942
|
itemSize = _ref3.itemSize;
|
|
1948
1943
|
return itemSize * itemCount;
|
|
1949
1944
|
},
|
|
1950
|
-
getOffsetForIndexAndAlignment: function getOffsetForIndexAndAlignment(_ref4, index, align, scrollOffset) {
|
|
1945
|
+
getOffsetForIndexAndAlignment: function getOffsetForIndexAndAlignment(_ref4, index, align, scrollOffset, instanceProps, scrollbarSize) {
|
|
1951
1946
|
var direction = _ref4.direction,
|
|
1952
1947
|
height = _ref4.height,
|
|
1953
1948
|
itemCount = _ref4.itemCount,
|
|
@@ -1959,7 +1954,7 @@ createListComponent({
|
|
|
1959
1954
|
var size = isHorizontal ? width : height;
|
|
1960
1955
|
var lastItemOffset = Math.max(0, itemCount * itemSize - size);
|
|
1961
1956
|
var maxOffset = Math.min(lastItemOffset, index * itemSize);
|
|
1962
|
-
var minOffset = Math.max(0, index * itemSize - size + itemSize);
|
|
1957
|
+
var minOffset = Math.max(0, index * itemSize - size + itemSize + scrollbarSize);
|
|
1963
1958
|
|
|
1964
1959
|
if (align === 'smart') {
|
|
1965
1960
|
if (scrollOffset >= minOffset - size && scrollOffset <= maxOffset + size) {
|
|
@@ -2055,15 +2050,17 @@ function shallowDiffers(prev, next) {
|
|
|
2055
2050
|
return false;
|
|
2056
2051
|
}
|
|
2057
2052
|
|
|
2053
|
+
var _excluded = ["style"],
|
|
2054
|
+
_excluded2 = ["style"];
|
|
2058
2055
|
// It knows to compare individual style props and ignore the wrapper object.
|
|
2059
2056
|
// See https://reactjs.org/docs/react-api.html#reactmemo
|
|
2060
2057
|
|
|
2061
2058
|
function areEqual(prevProps, nextProps) {
|
|
2062
2059
|
var prevStyle = prevProps.style,
|
|
2063
|
-
prevRest = _objectWithoutPropertiesLoose(prevProps,
|
|
2060
|
+
prevRest = _objectWithoutPropertiesLoose(prevProps, _excluded);
|
|
2064
2061
|
|
|
2065
2062
|
var nextStyle = nextProps.style,
|
|
2066
|
-
nextRest = _objectWithoutPropertiesLoose(nextProps,
|
|
2063
|
+
nextRest = _objectWithoutPropertiesLoose(nextProps, _excluded2);
|
|
2067
2064
|
|
|
2068
2065
|
return !shallowDiffers(prevStyle, nextStyle) && !shallowDiffers(prevRest, nextRest);
|
|
2069
2066
|
}
|
|
@@ -2075,5 +2072,5 @@ function shouldComponentUpdate(nextProps, nextState) {
|
|
|
2075
2072
|
return !areEqual(this.props, nextProps) || shallowDiffers(this.state, nextState);
|
|
2076
2073
|
}
|
|
2077
2074
|
|
|
2078
|
-
export {
|
|
2075
|
+
export { FixedSizeGrid, FixedSizeList, VariableSizeGrid, VariableSizeList, areEqual, shouldComponentUpdate };
|
|
2079
2076
|
//# sourceMappingURL=index.esm.js.map
|