diff --git a/package.json b/package.json index b96fb2e8eb490..1287463c98d8b 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,8 @@ "gh-actions-build": "./.github/scripts/buildActions.sh", "gh-actions-validate": "./.github/scripts/validateActionsAndWorkflows.sh", "analyze-packages": "ANALYZE_BUNDLE=true webpack --config config/webpack/webpack.prod.js", - "check-metro-bundler-port": "node config/checkMetroBundlerPort.js" + "check-metro-bundler-port": "node config/checkMetroBundlerPort.js", + "postinstall": "patch-package" }, "dependencies": { "@formatjs/intl-getcanonicallocales": "^1.5.8", @@ -70,6 +71,7 @@ "moment": "^2.27.0", "moment-timezone": "^0.5.31", "onfido-sdk-ui": "^6.7.2", + "patch-package": "^6.4.7", "prop-types": "^15.7.2", "pusher-js": "^7.0.0", "react": "^17.0.2", diff --git a/patches/react-native-web+0.15.7.patch b/patches/react-native-web+0.15.7.patch new file mode 100644 index 0000000000000..9dce95e624ada --- /dev/null +++ b/patches/react-native-web+0.15.7.patch @@ -0,0 +1,1039 @@ +diff --git a/node_modules/react-native-web/dist/vendor/react-native/VirtualizedList/index.js b/node_modules/react-native-web/dist/vendor/react-native/VirtualizedList/index.js +index f8e8684..9e01d9f 100644 +--- a/node_modules/react-native-web/dist/vendor/react-native/VirtualizedList/index.js ++++ b/node_modules/react-native-web/dist/vendor/react-native/VirtualizedList/index.js +@@ -84,7 +84,15 @@ var VirtualizedList = /*#__PURE__*/function (_React$PureComponent) { + + var _proto = VirtualizedList.prototype; + +- // scrollToEnd may be janky without getItemLayout prop ++ _proto.pushOrUnshift = function pushOrUnshift(input, item) { ++ if (this.props.inverted) { ++ input.unshift(item); ++ } else { ++ input.push(item); ++ } ++ } // scrollToEnd may be janky without getItemLayout prop ++ ; ++ + _proto.scrollToEnd = function scrollToEnd(params) { + var animated = params ? params.animated : true; + var veryLast = this.props.getItemCount(this.props.data) - 1; +@@ -267,83 +275,83 @@ var VirtualizedList = /*#__PURE__*/function (_React$PureComponent) { + }; + + function VirtualizedList(_props, context) { +- var _this; ++ var _this2; + +- _this = _React$PureComponent.call(this, _props, context) || this; ++ _this2 = _React$PureComponent.call(this, _props, context) || this; + +- _this._getScrollMetrics = function () { +- return _this._scrollMetrics; ++ _this2._getScrollMetrics = function () { ++ return _this2._scrollMetrics; + }; + +- _this._getOutermostParentListRef = function () { +- if (_this._isNestedWithSameOrientation()) { +- return _this.context.virtualizedList.getOutermostParentListRef(); ++ _this2._getOutermostParentListRef = function () { ++ if (_this2._isNestedWithSameOrientation()) { ++ return _this2.context.virtualizedList.getOutermostParentListRef(); + } else { +- return _assertThisInitialized(_this); ++ return _assertThisInitialized(_this2); + } + }; + +- _this._getNestedChildState = function (key) { +- var existingChildData = _this._nestedChildLists.get(key); ++ _this2._getNestedChildState = function (key) { ++ var existingChildData = _this2._nestedChildLists.get(key); + + return existingChildData && existingChildData.state; + }; + +- _this._registerAsNestedChild = function (childList) { ++ _this2._registerAsNestedChild = function (childList) { + // Register the mapping between this child key and the cellKey for its cell +- var childListsInCell = _this._cellKeysToChildListKeys.get(childList.cellKey) || new Set(); ++ var childListsInCell = _this2._cellKeysToChildListKeys.get(childList.cellKey) || new Set(); + childListsInCell.add(childList.key); + +- _this._cellKeysToChildListKeys.set(childList.cellKey, childListsInCell); ++ _this2._cellKeysToChildListKeys.set(childList.cellKey, childListsInCell); + +- var existingChildData = _this._nestedChildLists.get(childList.key); ++ var existingChildData = _this2._nestedChildLists.get(childList.key); + + if (existingChildData && existingChildData.ref !== null) { + console.error('A VirtualizedList contains a cell which itself contains ' + 'more than one VirtualizedList of the same orientation as the parent ' + 'list. You must pass a unique listKey prop to each sibling list.'); + } + +- _this._nestedChildLists.set(childList.key, { ++ _this2._nestedChildLists.set(childList.key, { + ref: childList.ref, + state: null + }); + +- if (_this._hasInteracted) { ++ if (_this2._hasInteracted) { + childList.ref.recordInteraction(); + } + }; + +- _this._unregisterAsNestedChild = function (childList) { +- _this._nestedChildLists.set(childList.key, { ++ _this2._unregisterAsNestedChild = function (childList) { ++ _this2._nestedChildLists.set(childList.key, { + ref: null, + state: childList.state + }); + }; + +- _this._onUpdateSeparators = function (keys, newProps) { ++ _this2._onUpdateSeparators = function (keys, newProps) { + keys.forEach(function (key) { +- var ref = key != null && _this._cellRefs[key]; ++ var ref = key != null && _this2._cellRefs[key]; + ref && ref.updateSeparatorProps(newProps); + }); + }; + +- _this._averageCellLength = 0; +- _this._cellKeysToChildListKeys = new Map(); +- _this._cellRefs = {}; +- _this._frames = {}; +- _this._footerLength = 0; +- _this._hasDataChangedSinceEndReached = true; +- _this._hasDoneInitialScroll = false; +- _this._hasInteracted = false; +- _this._hasMore = false; +- _this._hasWarned = {}; +- _this._headerLength = 0; +- _this._hiPriInProgress = false; +- _this._highestMeasuredFrameIndex = 0; +- _this._indicesToKeys = new Map(); +- _this._nestedChildLists = new Map(); +- _this._offsetFromParentVirtualizedList = 0; +- _this._prevParentOffset = 0; +- _this._scrollMetrics = { ++ _this2._averageCellLength = 0; ++ _this2._cellKeysToChildListKeys = new Map(); ++ _this2._cellRefs = {}; ++ _this2._frames = {}; ++ _this2._footerLength = 0; ++ _this2._hasDataChangedSinceEndReached = true; ++ _this2._hasDoneInitialScroll = false; ++ _this2._hasInteracted = false; ++ _this2._hasMore = false; ++ _this2._hasWarned = {}; ++ _this2._headerLength = 0; ++ _this2._hiPriInProgress = false; ++ _this2._highestMeasuredFrameIndex = 0; ++ _this2._indicesToKeys = new Map(); ++ _this2._nestedChildLists = new Map(); ++ _this2._offsetFromParentVirtualizedList = 0; ++ _this2._prevParentOffset = 0; ++ _this2._scrollMetrics = { + contentLength: 0, + dOffset: 0, + dt: 10, +@@ -352,20 +360,20 @@ var VirtualizedList = /*#__PURE__*/function (_React$PureComponent) { + velocity: 0, + visibleLength: 0 + }; +- _this._scrollRef = null; +- _this._sentEndForContentLength = 0; +- _this._totalCellLength = 0; +- _this._totalCellsMeasured = 0; +- _this._viewabilityTuples = []; +- +- _this._captureScrollRef = function (ref) { +- _this._scrollRef = ref; ++ _this2._scrollRef = null; ++ _this2._sentEndForContentLength = 0; ++ _this2._totalCellLength = 0; ++ _this2._totalCellsMeasured = 0; ++ _this2._viewabilityTuples = []; ++ ++ _this2._captureScrollRef = function (ref) { ++ _this2._scrollRef = ref; + }; + +- _this._defaultRenderScrollComponent = function (props) { ++ _this2._defaultRenderScrollComponent = function (props) { + var onRefresh = props.onRefresh; + +- if (_this._isNestedWithSameOrientation()) { ++ if (_this2._isNestedWithSameOrientation()) { + // $FlowFixMe - Typing ReactNativeComponent revealed errors + return /*#__PURE__*/React.createElement(View, props); + } else if (onRefresh) { +@@ -387,75 +395,75 @@ var VirtualizedList = /*#__PURE__*/function (_React$PureComponent) { + } + }; + +- _this._onCellUnmount = function (cellKey) { +- var curr = _this._frames[cellKey]; ++ _this2._onCellUnmount = function (cellKey) { ++ var curr = _this2._frames[cellKey]; + + if (curr) { +- _this._frames[cellKey] = _objectSpread(_objectSpread({}, curr), {}, { ++ _this2._frames[cellKey] = _objectSpread(_objectSpread({}, curr), {}, { + inLayout: false + }); + } + }; + +- _this._onLayout = function (e) { +- if (_this._isNestedWithSameOrientation()) { ++ _this2._onLayout = function (e) { ++ if (_this2._isNestedWithSameOrientation()) { + // Need to adjust our scroll metrics to be relative to our containing + // VirtualizedList before we can make claims about list item viewability +- _this.measureLayoutRelativeToContainingList(); ++ _this2.measureLayoutRelativeToContainingList(); + } else { +- _this._scrollMetrics.visibleLength = _this._selectLength(e.nativeEvent.layout); ++ _this2._scrollMetrics.visibleLength = _this2._selectLength(e.nativeEvent.layout); + } + +- _this.props.onLayout && _this.props.onLayout(e); ++ _this2.props.onLayout && _this2.props.onLayout(e); + +- _this._scheduleCellsToRenderUpdate(); ++ _this2._scheduleCellsToRenderUpdate(); + +- _this._maybeCallOnEndReached(); ++ _this2._maybeCallOnEndReached(); + }; + +- _this._onLayoutEmpty = function (e) { +- _this.props.onLayout && _this.props.onLayout(e); ++ _this2._onLayoutEmpty = function (e) { ++ _this2.props.onLayout && _this2.props.onLayout(e); + }; + +- _this._onLayoutFooter = function (e) { +- _this._footerLength = _this._selectLength(e.nativeEvent.layout); ++ _this2._onLayoutFooter = function (e) { ++ _this2._footerLength = _this2._selectLength(e.nativeEvent.layout); + }; + +- _this._onLayoutHeader = function (e) { +- _this._headerLength = _this._selectLength(e.nativeEvent.layout); ++ _this2._onLayoutHeader = function (e) { ++ _this2._headerLength = _this2._selectLength(e.nativeEvent.layout); + }; + +- _this._onContentSizeChange = function (width, height) { +- if (width > 0 && height > 0 && _this.props.initialScrollIndex != null && _this.props.initialScrollIndex > 0 && !_this._hasDoneInitialScroll) { +- _this.scrollToIndex({ ++ _this2._onContentSizeChange = function (width, height) { ++ if (width > 0 && height > 0 && _this2.props.initialScrollIndex != null && _this2.props.initialScrollIndex > 0 && !_this2._hasDoneInitialScroll) { ++ _this2.scrollToIndex({ + animated: false, +- index: _this.props.initialScrollIndex ++ index: _this2.props.initialScrollIndex + }); + +- _this._hasDoneInitialScroll = true; ++ _this2._hasDoneInitialScroll = true; + } + +- if (_this.props.onContentSizeChange) { +- _this.props.onContentSizeChange(width, height); ++ if (_this2.props.onContentSizeChange) { ++ _this2.props.onContentSizeChange(width, height); + } + +- _this._scrollMetrics.contentLength = _this._selectLength({ ++ _this2._scrollMetrics.contentLength = _this2._selectLength({ + height: height, + width: width + }); + +- _this._scheduleCellsToRenderUpdate(); ++ _this2._scheduleCellsToRenderUpdate(); + +- _this._maybeCallOnEndReached(); ++ _this2._maybeCallOnEndReached(); + }; + +- _this._convertParentScrollMetrics = function (metrics) { ++ _this2._convertParentScrollMetrics = function (metrics) { + // Offset of the top of the nested list relative to the top of its parent's viewport +- var offset = metrics.offset - _this._offsetFromParentVirtualizedList; // Child's visible length is the same as its parent's ++ var offset = metrics.offset - _this2._offsetFromParentVirtualizedList; // Child's visible length is the same as its parent's + + var visibleLength = metrics.visibleLength; +- var dOffset = offset - _this._scrollMetrics.offset; +- var contentLength = _this._scrollMetrics.contentLength; ++ var dOffset = offset - _this2._scrollMetrics.offset; ++ var contentLength = _this2._scrollMetrics.contentLength; + return { + visibleLength: visibleLength, + contentLength: contentLength, +@@ -464,56 +472,61 @@ var VirtualizedList = /*#__PURE__*/function (_React$PureComponent) { + }; + }; + +- _this._onScroll = function (e) { +- _this._nestedChildLists.forEach(function (childList) { ++ _this2._onScroll = function (e) { ++ var contentOffset = _this2.props.inverted ? { ++ x: -e.nativeEvent.contentOffset.x, ++ y: -e.nativeEvent.contentOffset.y ++ } : e.nativeEvent.contentOffset; ++ ++ _this2._nestedChildLists.forEach(function (childList) { + childList.ref && childList.ref._onScroll(e); + }); + +- if (_this.props.onScroll) { +- _this.props.onScroll(e); ++ if (_this2.props.onScroll) { ++ _this2.props.onScroll(e); + } + + var timestamp = e.timeStamp; + +- var visibleLength = _this._selectLength(e.nativeEvent.layoutMeasurement); ++ var visibleLength = _this2._selectLength(e.nativeEvent.layoutMeasurement); + +- var contentLength = _this._selectLength(e.nativeEvent.contentSize); ++ var contentLength = _this2._selectLength(e.nativeEvent.contentSize); + +- var offset = _this._selectOffset(e.nativeEvent.contentOffset); ++ var offset = _this2._selectOffset(contentOffset); + +- var dOffset = offset - _this._scrollMetrics.offset; ++ var dOffset = offset - _this2._scrollMetrics.offset; + +- if (_this._isNestedWithSameOrientation()) { +- if (_this._scrollMetrics.contentLength === 0) { ++ if (_this2._isNestedWithSameOrientation()) { ++ if (_this2._scrollMetrics.contentLength === 0) { + // Ignore scroll events until onLayout has been called and we + // know our offset from our offset from our parent + return; + } + +- var _this$_convertParentS = _this._convertParentScrollMetrics({ ++ var _this2$_convertParent = _this2._convertParentScrollMetrics({ + visibleLength: visibleLength, + offset: offset + }); + +- visibleLength = _this$_convertParentS.visibleLength; +- contentLength = _this$_convertParentS.contentLength; +- offset = _this$_convertParentS.offset; +- dOffset = _this$_convertParentS.dOffset; ++ visibleLength = _this2$_convertParent.visibleLength; ++ contentLength = _this2$_convertParent.contentLength; ++ offset = _this2$_convertParent.offset; ++ dOffset = _this2$_convertParent.dOffset; + } + +- var dt = _this._scrollMetrics.timestamp ? Math.max(1, timestamp - _this._scrollMetrics.timestamp) : 1; ++ var dt = _this2._scrollMetrics.timestamp ? Math.max(1, timestamp - _this2._scrollMetrics.timestamp) : 1; + var velocity = dOffset / dt; + +- if (dt > 500 && _this._scrollMetrics.dt > 500 && contentLength > 5 * visibleLength && !_this._hasWarned.perf) { ++ if (dt > 500 && _this2._scrollMetrics.dt > 500 && contentLength > 5 * visibleLength && !_this2._hasWarned.perf) { + infoLog('VirtualizedList: You have a large list that is slow to update - make sure your ' + 'renderItem function renders components that follow React performance best practices ' + 'like PureComponent, shouldComponentUpdate, etc.', { + dt: dt, +- prevDt: _this._scrollMetrics.dt, ++ prevDt: _this2._scrollMetrics.dt, + contentLength: contentLength + }); +- _this._hasWarned.perf = true; ++ _this2._hasWarned.perf = true; + } + +- _this._scrollMetrics = { ++ _this2._scrollMetrics = { + contentLength: contentLength, + dt: dt, + dOffset: dOffset, +@@ -523,71 +536,71 @@ var VirtualizedList = /*#__PURE__*/function (_React$PureComponent) { + visibleLength: visibleLength + }; + +- _this._updateViewableItems(_this.props.data); ++ _this2._updateViewableItems(_this2.props.data); + +- if (!_this.props) { ++ if (!_this2.props) { + return; + } + +- _this._maybeCallOnEndReached(); ++ _this2._maybeCallOnEndReached(); + + if (velocity !== 0) { +- _this._fillRateHelper.activate(); ++ _this2._fillRateHelper.activate(); + } + +- _this._computeBlankness(); ++ _this2._computeBlankness(); + +- _this._scheduleCellsToRenderUpdate(); ++ _this2._scheduleCellsToRenderUpdate(); + }; + +- _this._onScrollBeginDrag = function (e) { +- _this._nestedChildLists.forEach(function (childList) { ++ _this2._onScrollBeginDrag = function (e) { ++ _this2._nestedChildLists.forEach(function (childList) { + childList.ref && childList.ref._onScrollBeginDrag(e); + }); + +- _this._viewabilityTuples.forEach(function (tuple) { ++ _this2._viewabilityTuples.forEach(function (tuple) { + tuple.viewabilityHelper.recordInteraction(); + }); + +- _this._hasInteracted = true; +- _this.props.onScrollBeginDrag && _this.props.onScrollBeginDrag(e); ++ _this2._hasInteracted = true; ++ _this2.props.onScrollBeginDrag && _this2.props.onScrollBeginDrag(e); + }; + +- _this._onScrollEndDrag = function (e) { ++ _this2._onScrollEndDrag = function (e) { + var velocity = e.nativeEvent.velocity; + + if (velocity) { +- _this._scrollMetrics.velocity = _this._selectOffset(velocity); ++ _this2._scrollMetrics.velocity = _this2._selectOffset(velocity); + } + +- _this._computeBlankness(); ++ _this2._computeBlankness(); + +- _this.props.onScrollEndDrag && _this.props.onScrollEndDrag(e); ++ _this2.props.onScrollEndDrag && _this2.props.onScrollEndDrag(e); + }; + +- _this._onMomentumScrollEnd = function (e) { +- _this._scrollMetrics.velocity = 0; ++ _this2._onMomentumScrollEnd = function (e) { ++ _this2._scrollMetrics.velocity = 0; + +- _this._computeBlankness(); ++ _this2._computeBlankness(); + +- _this.props.onMomentumScrollEnd && _this.props.onMomentumScrollEnd(e); ++ _this2.props.onMomentumScrollEnd && _this2.props.onMomentumScrollEnd(e); + }; + +- _this._updateCellsToRender = function () { +- var _this$props3 = _this.props, +- data = _this$props3.data, +- getItemCount = _this$props3.getItemCount, +- onEndReachedThreshold = _this$props3.onEndReachedThreshold; ++ _this2._updateCellsToRender = function () { ++ var _this2$props = _this2.props, ++ data = _this2$props.data, ++ getItemCount = _this2$props.getItemCount, ++ onEndReachedThreshold = _this2$props.onEndReachedThreshold; + +- var isVirtualizationDisabled = _this._isVirtualizationDisabled(); ++ var isVirtualizationDisabled = _this2._isVirtualizationDisabled(); + +- _this._updateViewableItems(data); ++ _this2._updateViewableItems(data); + + if (!data) { + return; + } + +- _this.setState(function (state) { ++ _this2.setState(function (state) { + var newState; + + if (!isVirtualizationDisabled) { +@@ -595,33 +608,33 @@ var VirtualizedList = /*#__PURE__*/function (_React$PureComponent) { + // and wipe out the initialNumToRender rendered elements. + // So let's wait until the scroll view metrics have been set up. And until then, + // we will trust the initialNumToRender suggestion +- if (_this._scrollMetrics.visibleLength) { ++ if (_this2._scrollMetrics.visibleLength) { + // If we have a non-zero initialScrollIndex and run this before we've scrolled, + // we'll wipe out the initialNumToRender rendered elements starting at initialScrollIndex. + // So let's wait until we've scrolled the view to the right place. And until then, + // we will trust the initialScrollIndex suggestion. +- if (!_this.props.initialScrollIndex || _this._scrollMetrics.offset) { +- newState = computeWindowedRenderLimits(_this.props, state, _this._getFrameMetricsApprox, _this._scrollMetrics); ++ if (!_this2.props.initialScrollIndex || _this2._scrollMetrics.offset) { ++ newState = computeWindowedRenderLimits(_this2.props, state, _this2._getFrameMetricsApprox, _this2._scrollMetrics); + } + } + } else { +- var _this$_scrollMetrics = _this._scrollMetrics, +- contentLength = _this$_scrollMetrics.contentLength, +- offset = _this$_scrollMetrics.offset, +- visibleLength = _this$_scrollMetrics.visibleLength; ++ var _this2$_scrollMetrics = _this2._scrollMetrics, ++ contentLength = _this2$_scrollMetrics.contentLength, ++ offset = _this2$_scrollMetrics.offset, ++ visibleLength = _this2$_scrollMetrics.visibleLength; + var distanceFromEnd = contentLength - visibleLength - offset; + var renderAhead = + /* $FlowFixMe(>=0.63.0 site=react_native_fb) This comment suppresses + * an error found when Flow v0.63 was deployed. To see the error + * delete this comment and run Flow. */ +- distanceFromEnd < onEndReachedThreshold * visibleLength ? _this.props.maxToRenderPerBatch : 0; ++ distanceFromEnd < onEndReachedThreshold * visibleLength ? _this2.props.maxToRenderPerBatch : 0; + newState = { + first: 0, + last: Math.min(state.last + renderAhead, getItemCount(data) - 1) + }; + } + +- if (newState && _this._nestedChildLists.size > 0) { ++ if (newState && _this2._nestedChildLists.size > 0) { + var newFirst = newState.first; + var newLast = newState.last; // If some cell in the new state has a child list in it, we should only render + // up through that item, so that we give that list a chance to render. +@@ -629,9 +642,9 @@ var VirtualizedList = /*#__PURE__*/function (_React$PureComponent) { + // their items. + + for (var ii = newFirst; ii <= newLast; ii++) { +- var cellKeyForIndex = _this._indicesToKeys.get(ii); ++ var cellKeyForIndex = _this2._indicesToKeys.get(ii); + +- var childListKeys = cellKeyForIndex && _this._cellKeysToChildListKeys.get(cellKeyForIndex); ++ var childListKeys = cellKeyForIndex && _this2._cellKeysToChildListKeys.get(cellKeyForIndex); + + if (!childListKeys) { + continue; +@@ -642,7 +655,7 @@ var VirtualizedList = /*#__PURE__*/function (_React$PureComponent) { + for (var _iterator = _createForOfIteratorHelperLoose(childListKeys), _step; !(_step = _iterator()).done;) { + var childKey = _step.value; + +- var childList = _this._nestedChildLists.get(childKey); ++ var childList = _this2._nestedChildLists.get(childKey); + + if (childList && childList.ref && childList.ref.hasMore()) { + someChildHasMore = true; +@@ -661,11 +674,11 @@ var VirtualizedList = /*#__PURE__*/function (_React$PureComponent) { + }); + }; + +- _this._createViewToken = function (index, isViewable) { +- var _this$props4 = _this.props, +- data = _this$props4.data, +- getItem = _this$props4.getItem, +- keyExtractor = _this$props4.keyExtractor; ++ _this2._createViewToken = function (index, isViewable) { ++ var _this2$props2 = _this2.props, ++ data = _this2$props2.data, ++ getItem = _this2$props2.getItem, ++ keyExtractor = _this2$props2.keyExtractor; + var item = getItem(data, index); + return { + index: index, +@@ -675,33 +688,33 @@ var VirtualizedList = /*#__PURE__*/function (_React$PureComponent) { + }; + }; + +- _this._getFrameMetricsApprox = function (index) { +- var frame = _this._getFrameMetrics(index); ++ _this2._getFrameMetricsApprox = function (index) { ++ var frame = _this2._getFrameMetrics(index); + + if (frame && frame.index === index) { + // check for invalid frames due to row re-ordering + return frame; + } else { +- var getItemLayout = _this.props.getItemLayout; ++ var getItemLayout = _this2.props.getItemLayout; + invariant(!getItemLayout, 'Should not have to estimate frames when a measurement metrics function is provided'); + return { +- length: _this._averageCellLength, +- offset: _this._averageCellLength * index ++ length: _this2._averageCellLength, ++ offset: _this2._averageCellLength * index + }; + } + }; + +- _this._getFrameMetrics = function (index) { +- var _this$props5 = _this.props, +- data = _this$props5.data, +- getItem = _this$props5.getItem, +- getItemCount = _this$props5.getItemCount, +- getItemLayout = _this$props5.getItemLayout, +- keyExtractor = _this$props5.keyExtractor; ++ _this2._getFrameMetrics = function (index) { ++ var _this2$props3 = _this2.props, ++ data = _this2$props3.data, ++ getItem = _this2$props3.getItem, ++ getItemCount = _this2$props3.getItemCount, ++ getItemLayout = _this2$props3.getItemLayout, ++ keyExtractor = _this2$props3.keyExtractor; + invariant(getItemCount(data) > index, 'Tried to get frame for out of range index ' + index); + var item = getItem(data, index); + +- var frame = item && _this._frames[keyExtractor(item, index)]; ++ var frame = item && _this2._frames[keyExtractor(item, index)]; + + if (!frame || frame.index !== index) { + if (getItemLayout) { +@@ -731,40 +744,40 @@ var VirtualizedList = /*#__PURE__*/function (_React$PureComponent) { + + invariant(!_props.onScroll || !_props.onScroll.__isNative, 'Components based on VirtualizedList must be wrapped with Animated.createAnimatedComponent ' + 'to support native onScroll events with useNativeDriver'); + invariant(_props.windowSize > 0, 'VirtualizedList: The windowSize prop must be present and set to a value greater than 0.'); +- _this._fillRateHelper = new FillRateHelper(_this._getFrameMetrics); +- _this._updateCellsToRenderBatcher = new Batchinator(_this._updateCellsToRender, _this.props.updateCellsBatchingPeriod); ++ _this2._fillRateHelper = new FillRateHelper(_this2._getFrameMetrics); ++ _this2._updateCellsToRenderBatcher = new Batchinator(_this2._updateCellsToRender, _this2.props.updateCellsBatchingPeriod); + +- if (_this.props.viewabilityConfigCallbackPairs) { +- _this._viewabilityTuples = _this.props.viewabilityConfigCallbackPairs.map(function (pair) { ++ if (_this2.props.viewabilityConfigCallbackPairs) { ++ _this2._viewabilityTuples = _this2.props.viewabilityConfigCallbackPairs.map(function (pair) { + return { + viewabilityHelper: new ViewabilityHelper(pair.viewabilityConfig), + onViewableItemsChanged: pair.onViewableItemsChanged + }; + }); +- } else if (_this.props.onViewableItemsChanged) { +- _this._viewabilityTuples.push({ +- viewabilityHelper: new ViewabilityHelper(_this.props.viewabilityConfig), +- onViewableItemsChanged: _this.props.onViewableItemsChanged ++ } else if (_this2.props.onViewableItemsChanged) { ++ _this2.pushOrUnshift(_this2._viewabilityTuples, { ++ viewabilityHelper: new ViewabilityHelper(_this2.props.viewabilityConfig), ++ onViewableItemsChanged: _this2.props.onViewableItemsChanged + }); + } + + var initialState = { +- first: _this.props.initialScrollIndex || 0, +- last: Math.min(_this.props.getItemCount(_this.props.data), (_this.props.initialScrollIndex || 0) + _this.props.initialNumToRender) - 1 ++ first: _this2.props.initialScrollIndex || 0, ++ last: Math.min(_this2.props.getItemCount(_this2.props.data), (_this2.props.initialScrollIndex || 0) + _this2.props.initialNumToRender) - 1 + }; + +- if (_this._isNestedWithSameOrientation()) { +- var storedState = _this.context.virtualizedList.getNestedChildState(_this.props.listKey || _this._getCellKey()); ++ if (_this2._isNestedWithSameOrientation()) { ++ var storedState = _this2.context.virtualizedList.getNestedChildState(_this2.props.listKey || _this2._getCellKey()); + + if (storedState) { + initialState = storedState; +- _this.state = storedState; +- _this._frames = storedState.frames; ++ _this2.state = storedState; ++ _this2._frames = storedState.frames; + } + } + +- _this.state = initialState; +- return _this; ++ _this2.state = initialState; ++ return _this2; + } + + _proto.componentDidMount = function componentDidMount() { +@@ -815,16 +828,16 @@ var VirtualizedList = /*#__PURE__*/function (_React$PureComponent) { + }; + + _proto._pushCells = function _pushCells(cells, stickyHeaderIndices, stickyIndicesFromProps, first, last, inversionStyle) { +- var _this2 = this; ++ var _this3 = this; + +- var _this$props6 = this.props, +- CellRendererComponent = _this$props6.CellRendererComponent, +- ItemSeparatorComponent = _this$props6.ItemSeparatorComponent, +- data = _this$props6.data, +- getItem = _this$props6.getItem, +- getItemCount = _this$props6.getItemCount, +- horizontal = _this$props6.horizontal, +- keyExtractor = _this$props6.keyExtractor; ++ var _this$props3 = this.props, ++ CellRendererComponent = _this$props3.CellRendererComponent, ++ ItemSeparatorComponent = _this$props3.ItemSeparatorComponent, ++ data = _this$props3.data, ++ getItem = _this$props3.getItem, ++ getItemCount = _this$props3.getItemCount, ++ horizontal = _this$props3.horizontal, ++ keyExtractor = _this$props3.keyExtractor; + var stickyOffset = this.props.ListHeaderComponent ? 1 : 0; + var end = getItemCount(data) - 1; + var prevCellKey; +@@ -834,33 +847,34 @@ var VirtualizedList = /*#__PURE__*/function (_React$PureComponent) { + var item = getItem(data, ii); + var key = keyExtractor(item, ii); + +- _this2._indicesToKeys.set(ii, key); ++ _this3._indicesToKeys.set(ii, key); + + if (stickyIndicesFromProps.has(ii + stickyOffset)) { +- stickyHeaderIndices.push(cells.length); ++ _this3.pushOrUnshift(stickyHeaderIndices, cells.length); + } + +- cells.push( /*#__PURE__*/React.createElement(CellRenderer, { ++ _this3.pushOrUnshift(cells, /*#__PURE__*/React.createElement(CellRenderer, { + CellRendererComponent: CellRendererComponent, + ItemSeparatorComponent: ii < end ? ItemSeparatorComponent : undefined, + cellKey: key, +- fillRateHelper: _this2._fillRateHelper, ++ fillRateHelper: _this3._fillRateHelper, + horizontal: horizontal, + index: ii, + inversionStyle: inversionStyle, + item: item, + key: key, + prevCellKey: prevCellKey, +- onUpdateSeparators: _this2._onUpdateSeparators, ++ onUpdateSeparators: _this3._onUpdateSeparators, + onLayout: function onLayout(e) { +- return _this2._onCellLayout(e, key, ii); ++ return _this3._onCellLayout(e, key, ii); + }, +- onUnmount: _this2._onCellUnmount, +- parentProps: _this2.props, ++ onUnmount: _this3._onCellUnmount, ++ parentProps: _this3.props, + ref: function ref(_ref) { +- _this2._cellRefs[key] = _ref; ++ _this3._cellRefs[key] = _ref; + } + })); ++ + prevCellKey = key; + }; + +@@ -879,20 +893,20 @@ var VirtualizedList = /*#__PURE__*/function (_React$PureComponent) { + }; + + _proto.render = function render() { +- var _this3 = this; ++ var _this4 = this; + + if (__DEV__) { + var flatStyles = flattenStyle(this.props.contentContainerStyle); + warning(flatStyles == null || flatStyles.flexWrap !== 'wrap', '`flexWrap: `wrap`` is not supported with the `VirtualizedList` components.' + 'Consider using `numColumns` with `FlatList` instead.'); + } + +- var _this$props7 = this.props, +- ListEmptyComponent = _this$props7.ListEmptyComponent, +- ListFooterComponent = _this$props7.ListFooterComponent, +- ListHeaderComponent = _this$props7.ListHeaderComponent; +- var _this$props8 = this.props, +- data = _this$props8.data, +- horizontal = _this$props8.horizontal; ++ var _this$props4 = this.props, ++ ListEmptyComponent = _this$props4.ListEmptyComponent, ++ ListFooterComponent = _this$props4.ListFooterComponent, ++ ListHeaderComponent = _this$props4.ListHeaderComponent; ++ var _this$props5 = this.props, ++ data = _this$props5.data, ++ horizontal = _this$props5.horizontal; + + var isVirtualizationDisabled = this._isVirtualizationDisabled(); + +@@ -903,14 +917,14 @@ var VirtualizedList = /*#__PURE__*/function (_React$PureComponent) { + + if (ListHeaderComponent) { + if (stickyIndicesFromProps.has(0)) { +- stickyHeaderIndices.push(0); ++ this.pushOrUnshift(stickyHeaderIndices, 0); + } + + var element = /*#__PURE__*/React.isValidElement(ListHeaderComponent) ? ListHeaderComponent : + /*#__PURE__*/ + // $FlowFixMe + React.createElement(ListHeaderComponent, null); +- cells.push( /*#__PURE__*/React.createElement(VirtualizedCellWrapper, { ++ this.pushOrUnshift(cells, /*#__PURE__*/React.createElement(VirtualizedCellWrapper, { + cellKey: this._getCellKey() + '-header', + key: "$header" + }, /*#__PURE__*/React.createElement(View, { +@@ -950,7 +964,7 @@ var VirtualizedList = /*#__PURE__*/function (_React$PureComponent) { + var stickyBlock = this._getFrameMetricsApprox(ii); + + var leadSpace = stickyBlock.offset - initBlock.offset - (this.props.initialScrollIndex ? 0 : initBlock.length); +- cells.push( /*#__PURE__*/React.createElement(View, { ++ this.pushOrUnshift(cells, /*#__PURE__*/React.createElement(View, { + key: "$sticky_lead", + style: (_ref2 = {}, _ref2[spacerKey] = leadSpace, _ref2) + })); +@@ -958,7 +972,7 @@ var VirtualizedList = /*#__PURE__*/function (_React$PureComponent) { + this._pushCells(cells, stickyHeaderIndices, stickyIndicesFromProps, ii, ii, inversionStyle); + + var trailSpace = this._getFrameMetricsApprox(first).offset - (stickyBlock.offset + stickyBlock.length); +- cells.push( /*#__PURE__*/React.createElement(View, { ++ this.pushOrUnshift(cells, /*#__PURE__*/React.createElement(View, { + key: "$sticky_trail", + style: (_ref3 = {}, _ref3[spacerKey] = trailSpace, _ref3) + })); +@@ -975,7 +989,7 @@ var VirtualizedList = /*#__PURE__*/function (_React$PureComponent) { + + var firstSpace = this._getFrameMetricsApprox(first).offset - (_initBlock.offset + _initBlock.length); + +- cells.push( /*#__PURE__*/React.createElement(View, { ++ this.pushOrUnshift(cells, /*#__PURE__*/React.createElement(View, { + key: "$lead_spacer", + style: (_ref4 = {}, _ref4[spacerKey] = firstSpace, _ref4) + })); +@@ -1002,7 +1016,7 @@ var VirtualizedList = /*#__PURE__*/function (_React$PureComponent) { + var endFrame = this._getFrameMetricsApprox(end); + + var tailSpacerLength = endFrame.offset + endFrame.length - (lastFrame.offset + lastFrame.length); +- cells.push( /*#__PURE__*/React.createElement(View, { ++ this.pushOrUnshift(cells, /*#__PURE__*/React.createElement(View, { + key: "$tail_spacer", + style: (_ref5 = {}, _ref5[spacerKey] = tailSpacerLength, _ref5) + })); +@@ -1013,10 +1027,10 @@ var VirtualizedList = /*#__PURE__*/function (_React$PureComponent) { + // $FlowFixMe + React.createElement(ListEmptyComponent, null); + +- cells.push( /*#__PURE__*/React.cloneElement(_element, { ++ this.pushOrUnshift(cells, /*#__PURE__*/React.cloneElement(_element, { + key: '$empty', + onLayout: function onLayout(event) { +- _this3._onLayoutEmpty(event); ++ _this4._onLayoutEmpty(event); + + if (_element.props.onLayout) { + _element.props.onLayout(event); +@@ -1032,7 +1046,7 @@ var VirtualizedList = /*#__PURE__*/function (_React$PureComponent) { + // $FlowFixMe + React.createElement(ListFooterComponent, null); + +- cells.push( /*#__PURE__*/React.createElement(VirtualizedCellWrapper, { ++ this.pushOrUnshift(cells, /*#__PURE__*/React.createElement(VirtualizedCellWrapper, { + cellKey: this._getCellKey() + '-footer', + key: "$footer" + }, /*#__PURE__*/React.createElement(View, { +@@ -1077,9 +1091,9 @@ var VirtualizedList = /*#__PURE__*/function (_React$PureComponent) { + }; + + _proto.componentDidUpdate = function componentDidUpdate(prevProps) { +- var _this$props9 = this.props, +- data = _this$props9.data, +- extraData = _this$props9.extraData; ++ var _this$props6 = this.props, ++ data = _this$props6.data, ++ extraData = _this$props6.extraData; + + if (data !== prevProps.data || extraData !== prevProps.extraData) { + this._hasDataChangedSinceEndReached = true; // clear the viewableIndices cache to also trigger +@@ -1153,7 +1167,7 @@ var VirtualizedList = /*#__PURE__*/function (_React$PureComponent) { + }; + + _proto.measureLayoutRelativeToContainingList = function measureLayoutRelativeToContainingList() { +- var _this4 = this; ++ var _this5 = this; + + // TODO (T35574538): findNodeHandle sometimes crashes with "Unable to find + // node on an unmounted component" during scrolling +@@ -1165,19 +1179,19 @@ var VirtualizedList = /*#__PURE__*/function (_React$PureComponent) { + + + this._scrollRef.measureLayout(this.context.virtualizedList.getOutermostParentListRef().getScrollRef().getNativeScrollRef(), function (x, y, width, height) { +- _this4._offsetFromParentVirtualizedList = _this4._selectOffset({ ++ _this5._offsetFromParentVirtualizedList = _this5._selectOffset({ + x: x, + y: y + }); +- _this4._scrollMetrics.contentLength = _this4._selectLength({ ++ _this5._scrollMetrics.contentLength = _this5._selectLength({ + width: width, + height: height + }); + +- var scrollMetrics = _this4._convertParentScrollMetrics(_this4.context.virtualizedList.getScrollMetrics()); ++ var scrollMetrics = _this5._convertParentScrollMetrics(_this5.context.virtualizedList.getScrollMetrics()); + +- _this4._scrollMetrics.visibleLength = scrollMetrics.visibleLength; +- _this4._scrollMetrics.offset = scrollMetrics.offset; ++ _this5._scrollMetrics.visibleLength = scrollMetrics.visibleLength; ++ _this5._scrollMetrics.offset = scrollMetrics.offset; + }, function (error) { + console.warn("VirtualizedList: Encountered an error while measuring a list's" + ' offset from its containing VirtualizedList.'); + }); +@@ -1199,7 +1213,7 @@ var VirtualizedList = /*#__PURE__*/function (_React$PureComponent) { + + + if (frame.inLayout) { +- framesInLayout.push(frame); ++ this.pushOrUnshift(framesInLayout, frame); + } + } + +@@ -1242,15 +1256,15 @@ var VirtualizedList = /*#__PURE__*/function (_React$PureComponent) { + }; + + _proto._maybeCallOnEndReached = function _maybeCallOnEndReached() { +- var _this$props10 = this.props, +- data = _this$props10.data, +- getItemCount = _this$props10.getItemCount, +- onEndReached = _this$props10.onEndReached, +- onEndReachedThreshold = _this$props10.onEndReachedThreshold; +- var _this$_scrollMetrics2 = this._scrollMetrics, +- contentLength = _this$_scrollMetrics2.contentLength, +- visibleLength = _this$_scrollMetrics2.visibleLength, +- offset = _this$_scrollMetrics2.offset; ++ var _this$props7 = this.props, ++ data = _this$props7.data, ++ getItemCount = _this$props7.getItemCount, ++ onEndReached = _this$props7.onEndReached, ++ onEndReachedThreshold = _this$props7.onEndReachedThreshold; ++ var _this$_scrollMetrics = this._scrollMetrics, ++ contentLength = _this$_scrollMetrics.contentLength, ++ visibleLength = _this$_scrollMetrics.visibleLength, ++ offset = _this$_scrollMetrics.offset; + var distanceFromEnd = contentLength - visibleLength - offset; + + if (onEndReached && this.state.last === getItemCount(data) - 1 && +@@ -1271,10 +1285,10 @@ var VirtualizedList = /*#__PURE__*/function (_React$PureComponent) { + var _this$state2 = this.state, + first = _this$state2.first, + last = _this$state2.last; +- var _this$_scrollMetrics3 = this._scrollMetrics, +- offset = _this$_scrollMetrics3.offset, +- visibleLength = _this$_scrollMetrics3.visibleLength, +- velocity = _this$_scrollMetrics3.velocity; ++ var _this$_scrollMetrics2 = this._scrollMetrics, ++ offset = _this$_scrollMetrics2.offset, ++ visibleLength = _this$_scrollMetrics2.visibleLength, ++ velocity = _this$_scrollMetrics2.velocity; + var itemCount = this.props.getItemCount(this.props.data); + var hiPri = false; + var scrollingThreshold = +@@ -1322,12 +1336,12 @@ var VirtualizedList = /*#__PURE__*/function (_React$PureComponent) { + ; + + _proto._updateViewableItems = function _updateViewableItems(data) { +- var _this5 = this; ++ var _this6 = this; + + var getItemCount = this.props.getItemCount; + + this._viewabilityTuples.forEach(function (tuple) { +- tuple.viewabilityHelper.onUpdate(getItemCount(data), _this5._scrollMetrics.offset, _this5._scrollMetrics.visibleLength, _this5._getFrameMetrics, _this5._createViewToken, tuple.onViewableItemsChanged, _this5.state); ++ tuple.viewabilityHelper.onUpdate(getItemCount(data), _this6._scrollMetrics.offset, _this6._scrollMetrics.visibleLength, _this6._getFrameMetrics, _this6._createViewToken, tuple.onViewableItemsChanged, _this6.state); + }); + }; + +@@ -1391,47 +1405,47 @@ var CellRenderer = /*#__PURE__*/function (_React$Component) { + _inheritsLoose(CellRenderer, _React$Component); + + function CellRenderer() { +- var _this6; ++ var _this7; + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + +- _this6 = _React$Component.call.apply(_React$Component, [this].concat(args)) || this; +- _this6.state = { ++ _this7 = _React$Component.call.apply(_React$Component, [this].concat(args)) || this; ++ _this7.state = { + separatorProps: { + highlighted: false, +- leadingItem: _this6.props.item ++ leadingItem: _this7.props.item + } + }; +- _this6._separators = { ++ _this7._separators = { + highlight: function highlight() { +- var _this6$props = _this6.props, +- cellKey = _this6$props.cellKey, +- prevCellKey = _this6$props.prevCellKey; ++ var _this7$props = _this7.props, ++ cellKey = _this7$props.cellKey, ++ prevCellKey = _this7$props.prevCellKey; + +- _this6.props.onUpdateSeparators([cellKey, prevCellKey], { ++ _this7.props.onUpdateSeparators([cellKey, prevCellKey], { + highlighted: true + }); + }, + unhighlight: function unhighlight() { +- var _this6$props2 = _this6.props, +- cellKey = _this6$props2.cellKey, +- prevCellKey = _this6$props2.prevCellKey; ++ var _this7$props2 = _this7.props, ++ cellKey = _this7$props2.cellKey, ++ prevCellKey = _this7$props2.prevCellKey; + +- _this6.props.onUpdateSeparators([cellKey, prevCellKey], { ++ _this7.props.onUpdateSeparators([cellKey, prevCellKey], { + highlighted: false + }); + }, + updateProps: function updateProps(select, newProps) { +- var _this6$props3 = _this6.props, +- cellKey = _this6$props3.cellKey, +- prevCellKey = _this6$props3.prevCellKey; ++ var _this7$props3 = _this7.props, ++ cellKey = _this7$props3.cellKey, ++ prevCellKey = _this7$props3.prevCellKey; + +- _this6.props.onUpdateSeparators([select === 'leading' ? prevCellKey : cellKey], newProps); ++ _this7.props.onUpdateSeparators([select === 'leading' ? prevCellKey : cellKey], newProps); + } + }; +- return _this6; ++ return _this7; + } + + var _proto2 = CellRenderer.prototype; +@@ -1459,15 +1473,15 @@ var CellRenderer = /*#__PURE__*/function (_React$Component) { + }; + + _proto2.render = function render() { +- var _this$props11 = this.props, +- CellRendererComponent = _this$props11.CellRendererComponent, +- ItemSeparatorComponent = _this$props11.ItemSeparatorComponent, +- fillRateHelper = _this$props11.fillRateHelper, +- horizontal = _this$props11.horizontal, +- item = _this$props11.item, +- index = _this$props11.index, +- inversionStyle = _this$props11.inversionStyle, +- parentProps = _this$props11.parentProps; ++ var _this$props8 = this.props, ++ CellRendererComponent = _this$props8.CellRendererComponent, ++ ItemSeparatorComponent = _this$props8.ItemSeparatorComponent, ++ fillRateHelper = _this$props8.fillRateHelper, ++ horizontal = _this$props8.horizontal, ++ item = _this$props8.item, ++ index = _this$props8.index, ++ inversionStyle = _this$props8.inversionStyle, ++ parentProps = _this$props8.parentProps; + var renderItem = parentProps.renderItem, + getItemLayout = parentProps.getItemLayout; + invariant(renderItem, 'no renderItem!'); +@@ -1546,14 +1560,10 @@ VirtualizedCellWrapper.childContextTypes = { + }; + var styles = StyleSheet.create({ + verticallyInverted: { +- transform: [{ +- scaleY: -1 +- }] ++ flexDirection: 'column-reverse' + }, + horizontallyInverted: { +- transform: [{ +- scaleX: -1 +- }] ++ flexDirection: 'row-reverse' + }, + row: { + flexDirection: 'row' diff --git a/src/components/InvertedFlatList/index.js b/src/components/InvertedFlatList/index.js index a2dd20b2c9992..0647131b9906c 100644 --- a/src/components/InvertedFlatList/index.js +++ b/src/components/InvertedFlatList/index.js @@ -19,7 +19,6 @@ class InvertedFlatList extends React.Component { constructor(props) { super(props); - this.invertedWheelEvent = this.invertedWheelEvent.bind(this); this.list = undefined; } @@ -30,28 +29,6 @@ class InvertedFlatList extends React.Component { } else { this.props.innerRef(this.list); } - - if (this.list) { - this.list - .getScrollableNode() - .addEventListener('wheel', this.invertedWheelEvent); - - this.list.setNativeProps({ - style: { - transform: 'translate3d(0,0,0) scaleY(-1)', - }, - }); - } - } - - componentWillUnmount() { - this.list.getScrollableNode() - .removeEventListener('wheel', this.invertedWheelEvent); - } - - invertedWheelEvent(e) { - this.list.getScrollableNode().scrollTop -= e.deltaY; - e.preventDefault(); } render() {