react-window 1.8.4 → 1.8.7
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 +74 -1
- package/dist/index-dev.umd.js +2 -0
- package/dist/index-dev.umd.js.map +1 -0
- package/dist/index-prod.umd.js +2 -0
- package/dist/index-prod.umd.js.map +1 -0
- package/dist/index.cjs.js +51 -60
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +50 -59
- package/dist/index.esm.js.map +1 -1
- package/package.json +23 -17
- package/src/createGridComponent.js +8 -5
- package/src/createListComponent.js +4 -1
- package/CHANGELOG.md +0 -115
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,
|
|
@@ -208,11 +200,17 @@ function createGridComponent(_ref2) {
|
|
|
208
200
|
if (itemStyleCache.hasOwnProperty(key)) {
|
|
209
201
|
style = itemStyleCache[key];
|
|
210
202
|
} else {
|
|
211
|
-
var
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
203
|
+
var _offset = getColumnOffset(_this.props, columnIndex, _this._instanceProps);
|
|
204
|
+
|
|
205
|
+
var isRtl = direction === 'rtl';
|
|
206
|
+
itemStyleCache[key] = style = {
|
|
207
|
+
position: 'absolute',
|
|
208
|
+
left: isRtl ? undefined : _offset,
|
|
209
|
+
right: isRtl ? _offset : undefined,
|
|
210
|
+
top: getRowOffset(_this.props, rowIndex, _this._instanceProps),
|
|
211
|
+
height: getRowHeight(_this.props, rowIndex, _this._instanceProps),
|
|
212
|
+
width: getColumnWidth(_this.props, columnIndex, _this._instanceProps)
|
|
213
|
+
};
|
|
216
214
|
}
|
|
217
215
|
|
|
218
216
|
return style;
|
|
@@ -564,11 +562,11 @@ function createGridComponent(_ref2) {
|
|
|
564
562
|
|
|
565
563
|
this._callOnScroll(_scrollLeft, _scrollTop, _horizontalScrollDirection, _verticalScrollDirection, _scrollUpdateWasRequested);
|
|
566
564
|
}
|
|
567
|
-
}
|
|
565
|
+
} // Lazily create and cache item styles while scrolling,
|
|
568
566
|
// So that pure component sCU will prevent re-renders.
|
|
569
567
|
// We maintain this cache, and pass a style prop rather than index,
|
|
570
568
|
// So that List can clear cached styles and force item re-render if necessary.
|
|
571
|
-
|
|
569
|
+
;
|
|
572
570
|
|
|
573
571
|
_proto._getHorizontalRangeToRender = function _getHorizontalRangeToRender() {
|
|
574
572
|
var _this$props6 = this.props,
|
|
@@ -627,7 +625,7 @@ function createGridComponent(_ref2) {
|
|
|
627
625
|
direction: 'ltr',
|
|
628
626
|
itemData: undefined,
|
|
629
627
|
useIsScrolling: false
|
|
630
|
-
},
|
|
628
|
+
}, _class;
|
|
631
629
|
}
|
|
632
630
|
|
|
633
631
|
var validateSharedProps = function validateSharedProps(_ref5, _ref6) {
|
|
@@ -875,9 +873,7 @@ var getOffsetForIndexAndAlignment = function getOffsetForIndexAndAlignment(itemT
|
|
|
875
873
|
}
|
|
876
874
|
};
|
|
877
875
|
|
|
878
|
-
var VariableSizeGrid =
|
|
879
|
-
/*#__PURE__*/
|
|
880
|
-
createGridComponent({
|
|
876
|
+
var VariableSizeGrid = /*#__PURE__*/createGridComponent({
|
|
881
877
|
getColumnOffset: function getColumnOffset(props, index, instanceProps) {
|
|
882
878
|
return getItemMetadata('column', props, index, instanceProps).offset;
|
|
883
879
|
},
|
|
@@ -1024,17 +1020,13 @@ var devWarningsTagName$1 = null;
|
|
|
1024
1020
|
|
|
1025
1021
|
if (process.env.NODE_ENV !== 'production') {
|
|
1026
1022
|
if (typeof window !== 'undefined' && typeof window.WeakSet !== 'undefined') {
|
|
1027
|
-
devWarningsDirection =
|
|
1028
|
-
/*#__PURE__*/
|
|
1029
|
-
new WeakSet();
|
|
1030
|
-
devWarningsTagName$1 =
|
|
1031
|
-
/*#__PURE__*/
|
|
1032
|
-
new WeakSet();
|
|
1023
|
+
devWarningsDirection = /*#__PURE__*/new WeakSet();
|
|
1024
|
+
devWarningsTagName$1 = /*#__PURE__*/new WeakSet();
|
|
1033
1025
|
}
|
|
1034
1026
|
}
|
|
1035
1027
|
|
|
1036
1028
|
function createListComponent(_ref) {
|
|
1037
|
-
var _class
|
|
1029
|
+
var _class;
|
|
1038
1030
|
|
|
1039
1031
|
var getItemOffset = _ref.getItemOffset,
|
|
1040
1032
|
getEstimatedTotalSize = _ref.getEstimatedTotalSize,
|
|
@@ -1045,9 +1037,7 @@ function createListComponent(_ref) {
|
|
|
1045
1037
|
initInstanceProps = _ref.initInstanceProps,
|
|
1046
1038
|
shouldResetStyleCacheOnItemSizeChange = _ref.shouldResetStyleCacheOnItemSizeChange,
|
|
1047
1039
|
validateProps = _ref.validateProps;
|
|
1048
|
-
return
|
|
1049
|
-
/*#__PURE__*/
|
|
1050
|
-
function (_PureComponent) {
|
|
1040
|
+
return _class = /*#__PURE__*/function (_PureComponent) {
|
|
1051
1041
|
_inheritsLoose(List, _PureComponent);
|
|
1052
1042
|
|
|
1053
1043
|
// Always use explicit constructor for React components.
|
|
@@ -1057,11 +1047,11 @@ function createListComponent(_ref) {
|
|
|
1057
1047
|
var _this;
|
|
1058
1048
|
|
|
1059
1049
|
_this = _PureComponent.call(this, props) || this;
|
|
1060
|
-
_this._instanceProps = initInstanceProps(_this.props, _assertThisInitialized(
|
|
1050
|
+
_this._instanceProps = initInstanceProps(_this.props, _assertThisInitialized(_this));
|
|
1061
1051
|
_this._outerRef = void 0;
|
|
1062
1052
|
_this._resetIsScrollingTimeoutId = null;
|
|
1063
1053
|
_this.state = {
|
|
1064
|
-
instance: _assertThisInitialized(
|
|
1054
|
+
instance: _assertThisInitialized(_this),
|
|
1065
1055
|
isScrolling: false,
|
|
1066
1056
|
scrollDirection: 'forward',
|
|
1067
1057
|
scrollOffset: typeof _this.props.initialScrollOffset === 'number' ? _this.props.initialScrollOffset : 0,
|
|
@@ -1099,16 +1089,21 @@ function createListComponent(_ref) {
|
|
|
1099
1089
|
if (itemStyleCache.hasOwnProperty(index)) {
|
|
1100
1090
|
style = itemStyleCache[index];
|
|
1101
1091
|
} else {
|
|
1102
|
-
var _style;
|
|
1103
|
-
|
|
1104
1092
|
var _offset = getItemOffset(_this.props, index, _this._instanceProps);
|
|
1105
1093
|
|
|
1106
1094
|
var size = getItemSize(_this.props, index, _this._instanceProps); // TODO Deprecate direction "horizontal"
|
|
1107
1095
|
|
|
1108
1096
|
var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1097
|
+
var isRtl = direction === 'rtl';
|
|
1098
|
+
var offsetHorizontal = isHorizontal ? _offset : 0;
|
|
1099
|
+
itemStyleCache[index] = style = {
|
|
1100
|
+
position: 'absolute',
|
|
1101
|
+
left: isRtl ? undefined : offsetHorizontal,
|
|
1102
|
+
right: isRtl ? offsetHorizontal : undefined,
|
|
1103
|
+
top: !isHorizontal ? _offset : 0,
|
|
1104
|
+
height: !isHorizontal ? size : '100%',
|
|
1105
|
+
width: isHorizontal ? size : '100%'
|
|
1106
|
+
};
|
|
1112
1107
|
}
|
|
1113
1108
|
|
|
1114
1109
|
return style;
|
|
@@ -1415,11 +1410,11 @@ function createListComponent(_ref) {
|
|
|
1415
1410
|
|
|
1416
1411
|
this._callOnScroll(_scrollDirection, _scrollOffset, _scrollUpdateWasRequested);
|
|
1417
1412
|
}
|
|
1418
|
-
}
|
|
1413
|
+
} // Lazily create and cache item styles while scrolling,
|
|
1419
1414
|
// So that pure component sCU will prevent re-renders.
|
|
1420
1415
|
// We maintain this cache, and pass a style prop rather than index,
|
|
1421
1416
|
// So that List can clear cached styles and force item re-render if necessary.
|
|
1422
|
-
|
|
1417
|
+
;
|
|
1423
1418
|
|
|
1424
1419
|
_proto._getRangeToRender = function _getRangeToRender() {
|
|
1425
1420
|
var _this$props5 = this.props,
|
|
@@ -1450,7 +1445,7 @@ function createListComponent(_ref) {
|
|
|
1450
1445
|
layout: 'vertical',
|
|
1451
1446
|
overscanCount: 2,
|
|
1452
1447
|
useIsScrolling: false
|
|
1453
|
-
},
|
|
1448
|
+
}, _class;
|
|
1454
1449
|
} // NOTE: I considered further wrapping individual items with a pure ListItem component.
|
|
1455
1450
|
// This would avoid ever calling the render function for the same index more than once,
|
|
1456
1451
|
// But it would also add the overhead of a lot of components/fibers.
|
|
@@ -1621,9 +1616,7 @@ var getEstimatedTotalSize = function getEstimatedTotalSize(_ref2, _ref3) {
|
|
|
1621
1616
|
return totalSizeOfMeasuredItems + totalSizeOfUnmeasuredItems;
|
|
1622
1617
|
};
|
|
1623
1618
|
|
|
1624
|
-
var VariableSizeList =
|
|
1625
|
-
/*#__PURE__*/
|
|
1626
|
-
createListComponent({
|
|
1619
|
+
var VariableSizeList = /*#__PURE__*/createListComponent({
|
|
1627
1620
|
getItemOffset: function getItemOffset(props, index, instanceProps) {
|
|
1628
1621
|
return getItemMetadata$1(props, index, instanceProps).offset;
|
|
1629
1622
|
},
|
|
@@ -1740,9 +1733,7 @@ createListComponent({
|
|
|
1740
1733
|
}
|
|
1741
1734
|
});
|
|
1742
1735
|
|
|
1743
|
-
var FixedSizeGrid =
|
|
1744
|
-
/*#__PURE__*/
|
|
1745
|
-
createGridComponent({
|
|
1736
|
+
var FixedSizeGrid = /*#__PURE__*/createGridComponent({
|
|
1746
1737
|
getColumnOffset: function getColumnOffset(_ref, index) {
|
|
1747
1738
|
var columnWidth = _ref.columnWidth;
|
|
1748
1739
|
return index * columnWidth;
|
|
@@ -1920,9 +1911,7 @@ createGridComponent({
|
|
|
1920
1911
|
}
|
|
1921
1912
|
});
|
|
1922
1913
|
|
|
1923
|
-
var FixedSizeList =
|
|
1924
|
-
/*#__PURE__*/
|
|
1925
|
-
createListComponent({
|
|
1914
|
+
var FixedSizeList = /*#__PURE__*/createListComponent({
|
|
1926
1915
|
getItemOffset: function getItemOffset(_ref, index) {
|
|
1927
1916
|
var itemSize = _ref.itemSize;
|
|
1928
1917
|
return index * itemSize;
|
|
@@ -2044,15 +2033,17 @@ function shallowDiffers(prev, next) {
|
|
|
2044
2033
|
return false;
|
|
2045
2034
|
}
|
|
2046
2035
|
|
|
2036
|
+
var _excluded = ["style"],
|
|
2037
|
+
_excluded2 = ["style"];
|
|
2047
2038
|
// It knows to compare individual style props and ignore the wrapper object.
|
|
2048
2039
|
// See https://reactjs.org/docs/react-api.html#reactmemo
|
|
2049
2040
|
|
|
2050
2041
|
function areEqual(prevProps, nextProps) {
|
|
2051
2042
|
var prevStyle = prevProps.style,
|
|
2052
|
-
prevRest = _objectWithoutPropertiesLoose(prevProps,
|
|
2043
|
+
prevRest = _objectWithoutPropertiesLoose(prevProps, _excluded);
|
|
2053
2044
|
|
|
2054
2045
|
var nextStyle = nextProps.style,
|
|
2055
|
-
nextRest = _objectWithoutPropertiesLoose(nextProps,
|
|
2046
|
+
nextRest = _objectWithoutPropertiesLoose(nextProps, _excluded2);
|
|
2056
2047
|
|
|
2057
2048
|
return !shallowDiffers(prevStyle, nextStyle) && !shallowDiffers(prevRest, nextRest);
|
|
2058
2049
|
}
|
|
@@ -2064,5 +2055,5 @@ function shouldComponentUpdate(nextProps, nextState) {
|
|
|
2064
2055
|
return !areEqual(this.props, nextProps) || shallowDiffers(this.state, nextState);
|
|
2065
2056
|
}
|
|
2066
2057
|
|
|
2067
|
-
export {
|
|
2058
|
+
export { FixedSizeGrid, FixedSizeList, VariableSizeGrid, VariableSizeList, areEqual, shouldComponentUpdate };
|
|
2068
2059
|
//# sourceMappingURL=index.esm.js.map
|