зеркало из https://github.com/microsoft/reactxp.git
Revert lodash imports due to issues on RN (#816)
This commit is contained in:
Родитель
076b1714b8
Коммит
c46ef2812f
|
@ -7,17 +7,17 @@
|
|||
* Imports a subset of lodash library needed for ReactXP's implementation.
|
||||
*/
|
||||
|
||||
import assign from 'lodash/assign';
|
||||
import clone from 'lodash/clone';
|
||||
import cloneDeep from 'lodash/cloneDeep';
|
||||
import flatten from 'lodash/flatten';
|
||||
import get from 'lodash/get';
|
||||
import isArray from 'lodash/isArray';
|
||||
import isEmpty from 'lodash/isEmpty';
|
||||
import isEqual from 'lodash/isEqual';
|
||||
import isNumber from 'lodash/isNumber';
|
||||
import map from 'lodash/map';
|
||||
import mapValues from 'lodash/mapValues';
|
||||
import assign = require('lodash/assign');
|
||||
import clone = require('lodash/clone');
|
||||
import cloneDeep = require('lodash/cloneDeep');
|
||||
import flatten = require('lodash/flatten');
|
||||
import get = require('lodash/get');
|
||||
import isArray = require('lodash/isArray');
|
||||
import isEmpty = require('lodash/isEmpty');
|
||||
import isEqual = require('lodash/isEqual');
|
||||
import isNumber = require('lodash/isNumber');
|
||||
import map = require('lodash/map');
|
||||
import mapValues = require('lodash/mapValues');
|
||||
|
||||
export interface Dictionary<T> {
|
||||
[index: string]: T;
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"esModuleInterop": true,
|
||||
"importHelpers": true,
|
||||
"declaration": true,
|
||||
"noResolve": false,
|
||||
"jsx": "react",
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import * as RX from 'reactxp';
|
||||
import extend from 'lodash/extend';
|
||||
import extend = require('lodash/extend');
|
||||
|
||||
import * as Types from '../common/Types';
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
import * as React from 'react';
|
||||
import * as RN from 'react-native';
|
||||
import * as RX from 'reactxp';
|
||||
import extend from 'lodash/extend';
|
||||
import extend = require('lodash/extend');
|
||||
|
||||
import * as Types from '../common/Types';
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"esModuleInterop": true,
|
||||
"importHelpers": true,
|
||||
"declaration": true,
|
||||
"noResolve": false,
|
||||
"jsx": "react",
|
||||
|
|
|
@ -37,14 +37,7 @@
|
|||
|
||||
import * as assert from 'assert';
|
||||
import * as RX from 'reactxp';
|
||||
import isUndefined from 'lodash/isUndefined';
|
||||
import isArray from 'lodash/isArray';
|
||||
import isEqual from 'lodash/isEqual';
|
||||
import findIndex from 'lodash/findIndex';
|
||||
import size from 'lodash/size';
|
||||
import each from 'lodash/each';
|
||||
import map from 'lodash/map';
|
||||
import defer from 'lodash/defer';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { VirtualListCell, VirtualListCellInfo } from './VirtualListCell';
|
||||
|
||||
|
@ -256,7 +249,7 @@ export class VirtualListView<ItemInfo extends VirtualListViewItemInfo>
|
|||
}
|
||||
|
||||
componentWillReceiveProps(nextProps: VirtualListViewProps<ItemInfo>): void {
|
||||
if (!isEqual(this.props, nextProps)) {
|
||||
if (!_.isEqual(this.props, nextProps)) {
|
||||
this._updateStateFromProps(nextProps, false);
|
||||
}
|
||||
}
|
||||
|
@ -310,7 +303,7 @@ export class VirtualListView<ItemInfo extends VirtualListViewItemInfo>
|
|||
this._minCullAmount = 3072;
|
||||
}
|
||||
|
||||
if (initialBuild || !isEqual(this.props.itemList, props.itemList)) {
|
||||
if (initialBuild || !_.isEqual(this.props.itemList, props.itemList)) {
|
||||
this._handleItemListChange(props);
|
||||
this._calcNewRenderedItemState(props);
|
||||
}
|
||||
|
@ -321,7 +314,7 @@ export class VirtualListView<ItemInfo extends VirtualListViewItemInfo>
|
|||
private _handleItemListChange(props: VirtualListViewProps<ItemInfo>) {
|
||||
// Build a new item map.
|
||||
const newItemMap: { [itemKey: string]: number } = {};
|
||||
each(props.itemList, (item, itemIndex) => {
|
||||
_.each(props.itemList, (item, itemIndex) => {
|
||||
// Make sure there are no duplicate keys.
|
||||
if (item.key in newItemMap) {
|
||||
assert.ok(false, 'Found a duplicate key: ' + item.key);
|
||||
|
@ -337,7 +330,7 @@ export class VirtualListView<ItemInfo extends VirtualListViewItemInfo>
|
|||
if (cell) {
|
||||
const oldItemIndex = this._itemMap[item.key];
|
||||
const oldItem = this.props.itemList[oldItemIndex];
|
||||
if (this.props.skipRenderIfItemUnchanged && !isEqual(oldItem, item)) {
|
||||
if (this.props.skipRenderIfItemUnchanged && !_.isEqual(oldItem, item)) {
|
||||
cell.shouldUpdate = true;
|
||||
}
|
||||
}
|
||||
|
@ -346,7 +339,7 @@ export class VirtualListView<ItemInfo extends VirtualListViewItemInfo>
|
|||
|
||||
// Stop tracking the heights of deleted items.
|
||||
const oldItems = (this.props && this.props.itemList) ? this.props.itemList : [];
|
||||
each(oldItems, (item, itemIndex) => {
|
||||
_.each(oldItems, (item, itemIndex) => {
|
||||
if (!(item.key in newItemMap)) {
|
||||
// If we're deleting an item that's above the current render block,
|
||||
// update the adjustment so we avoid an unnecessary scroll.
|
||||
|
@ -541,7 +534,7 @@ export class VirtualListView<ItemInfo extends VirtualListViewItemInfo>
|
|||
delete this._pendingMeasurements[itemKey];
|
||||
|
||||
// Are we done measuring things?
|
||||
if (size(this._pendingMeasurements) === 0) {
|
||||
if (_.size(this._pendingMeasurements) === 0) {
|
||||
needsRecalc = true;
|
||||
}
|
||||
}
|
||||
|
@ -568,9 +561,9 @@ export class VirtualListView<ItemInfo extends VirtualListViewItemInfo>
|
|||
// because we've received new props. We don't want to re-enter the
|
||||
// routines with the old props, so we'll defer and wait for this.props
|
||||
// to be updated.
|
||||
defer(() => {
|
||||
_.defer(() => {
|
||||
if (this._isMounted) {
|
||||
if (size(this._pendingAnimations) === 0 && this._isMounted) {
|
||||
if (_.size(this._pendingAnimations) === 0 && this._isMounted) {
|
||||
// Perform deferred actions now that all animations are complete.
|
||||
this._reconcileCorrections(this.props);
|
||||
}
|
||||
|
@ -620,7 +613,7 @@ export class VirtualListView<ItemInfo extends VirtualListViewItemInfo>
|
|||
return;
|
||||
}
|
||||
|
||||
if (size(this._pendingMeasurements) > 0) {
|
||||
if (_.size(this._pendingMeasurements) > 0) {
|
||||
// Don't bother if we're still measuring things. Wait for the last batch to end.
|
||||
return;
|
||||
}
|
||||
|
@ -790,7 +783,7 @@ export class VirtualListView<ItemInfo extends VirtualListViewItemInfo>
|
|||
};
|
||||
|
||||
// Try to add items to the bottom of the current render block.
|
||||
while (size(this._pendingMeasurements) < _maxSimultaneousMeasures) {
|
||||
while (_.size(this._pendingMeasurements) < _maxSimultaneousMeasures) {
|
||||
// Stop if we go beyond the bottom render limit.
|
||||
if (this._itemsBelowRenderBlock <= 0 ||
|
||||
this._heightAboveRenderAdjustment + this._heightAboveRenderBlock +
|
||||
|
@ -802,7 +795,7 @@ export class VirtualListView<ItemInfo extends VirtualListViewItemInfo>
|
|||
}
|
||||
|
||||
// Try to add an item to the top of the current render block.
|
||||
while (size(this._pendingMeasurements) < _maxSimultaneousMeasures) {
|
||||
while (_.size(this._pendingMeasurements) < _maxSimultaneousMeasures) {
|
||||
if (this._itemsAboveRenderBlock <= 0 ||
|
||||
this._heightAboveRenderAdjustment + this._heightAboveRenderBlock <= renderBlockTopLimit) {
|
||||
break;
|
||||
|
@ -812,7 +805,7 @@ export class VirtualListView<ItemInfo extends VirtualListViewItemInfo>
|
|||
}
|
||||
|
||||
// See if we've filled the screen and rendered it, and we're not waiting on any measurements.
|
||||
if (!this._isInitialFillComplete && !this._isRenderDirty && size(this._pendingMeasurements) === 0) {
|
||||
if (!this._isInitialFillComplete && !this._isRenderDirty && _.size(this._pendingMeasurements) === 0) {
|
||||
// Time for overrender. Recalc render lines.
|
||||
renderMargin = overdrawAmount;
|
||||
renderBlockTopLimit = this._lastScrollTop - renderMargin;
|
||||
|
@ -834,7 +827,7 @@ export class VirtualListView<ItemInfo extends VirtualListViewItemInfo>
|
|||
private _reconcileCorrections(props: VirtualListViewProps<ItemInfo>) {
|
||||
// If there are pending animations, don't adjust because it will disrupt
|
||||
// the animations. When all animations are complete, we will get called back.
|
||||
if (size(this._pendingAnimations) > 0) {
|
||||
if (_.size(this._pendingAnimations) > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -923,12 +916,12 @@ export class VirtualListView<ItemInfo extends VirtualListViewItemInfo>
|
|||
if (itemTemplate && isHeightConstant) {
|
||||
// See if we can find an exact match both in terms of template and previous key.
|
||||
// This has the greatest chance of rendering the same as previously.
|
||||
let bestOptionIndex = findIndex(this._recycledCells, cell => cell.itemTemplate === itemTemplate &&
|
||||
let bestOptionIndex = _.findIndex(this._recycledCells, cell => cell.itemTemplate === itemTemplate &&
|
||||
cell.cachedItemKey === itemKey && cell.height === height);
|
||||
|
||||
// We couldn't find an exact match. Try to find one with the same template.
|
||||
if (bestOptionIndex < 0) {
|
||||
bestOptionIndex = findIndex(this._recycledCells, cell => cell.itemTemplate === itemTemplate);
|
||||
bestOptionIndex = _.findIndex(this._recycledCells, cell => cell.itemTemplate === itemTemplate);
|
||||
}
|
||||
|
||||
if (bestOptionIndex >= 0) {
|
||||
|
@ -1066,7 +1059,7 @@ export class VirtualListView<ItemInfo extends VirtualListViewItemInfo>
|
|||
}
|
||||
}
|
||||
|
||||
each(this._recycledCells, virtualCellInfo => {
|
||||
_.each(this._recycledCells, virtualCellInfo => {
|
||||
assert.ok(virtualCellInfo, 'Recycled Cells array contains a null object');
|
||||
cellList.push({
|
||||
cellInfo: virtualCellInfo,
|
||||
|
@ -1080,7 +1073,7 @@ export class VirtualListView<ItemInfo extends VirtualListViewItemInfo>
|
|||
// change, and perf suffers.
|
||||
cellList = cellList.sort((a, b) => a.cellInfo.virtualKey < b.cellInfo.virtualKey ? 1 : -1);
|
||||
|
||||
each(cellList, cell => {
|
||||
_.each(cellList, cell => {
|
||||
let tabIndexValue: number;
|
||||
let isFocused = false;
|
||||
if (cell.item) {
|
||||
|
@ -1126,7 +1119,7 @@ export class VirtualListView<ItemInfo extends VirtualListViewItemInfo>
|
|||
|
||||
if (this.props.logInfo) {
|
||||
// [NOTE: For debugging] This shows the order in which virtual cells are laid out.
|
||||
let domOrder = map(cellList, c => {
|
||||
let domOrder = _.map(cellList, c => {
|
||||
const itemKey = c.item ? c.item.key : null;
|
||||
const itemIndex = c.item ? c.itemIndex : null;
|
||||
return 'vKey: ' + c.cellInfo.virtualKey + ' iKey: ' + itemKey + ' iIdx: ' + itemIndex;
|
||||
|
@ -1138,7 +1131,7 @@ export class VirtualListView<ItemInfo extends VirtualListViewItemInfo>
|
|||
const scrollViewStyle = [_styles.scrollContainer];
|
||||
let staticContainerStyle: (RX.Types.ViewStyleRuleSet | RX.Types.AnimatedViewStyleRuleSet)[] = [_styles.staticContainer];
|
||||
if (this.props.style) {
|
||||
if (isArray(this.props.style)) {
|
||||
if (_.isArray(this.props.style)) {
|
||||
staticContainerStyle = staticContainerStyle.concat(this.props.style as RX.Types.ViewStyleRuleSet[]);
|
||||
} else {
|
||||
staticContainerStyle.push(this.props.style as RX.Types.ViewStyleRuleSet);
|
||||
|
@ -1197,7 +1190,7 @@ export class VirtualListView<ItemInfo extends VirtualListViewItemInfo>
|
|||
}
|
||||
|
||||
private _selectSubsequentItem(direction: FocusDirection, retry = true) {
|
||||
let index = findIndex(this._navigatableItemsRendered, item => item.key === this.state.lastFocusedItemKey);
|
||||
let index = _.findIndex(this._navigatableItemsRendered, item => item.key === this.state.lastFocusedItemKey);
|
||||
|
||||
if (index !== -1 && index + direction > -1 && index + direction < this._navigatableItemsRendered.length) {
|
||||
let newElementForFocus = this.refs[this._navigatableItemsRendered[index + direction].vc_key] as VirtualListCell;
|
||||
|
@ -1264,7 +1257,7 @@ export class VirtualListView<ItemInfo extends VirtualListViewItemInfo>
|
|||
|
||||
// If we don't defer this, we can end up overflowing the stack
|
||||
// because one render immediately causes another render to be started.
|
||||
defer(() => {
|
||||
_.defer(() => {
|
||||
if (this._isMounted) {
|
||||
this._calcNewRenderedItemState(this.props);
|
||||
this._renderIfDirty(this.props);
|
||||
|
@ -1298,7 +1291,7 @@ export class VirtualListView<ItemInfo extends VirtualListViewItemInfo>
|
|||
}
|
||||
|
||||
private _isItemHeightKnown(item: VirtualListViewItemInfo) {
|
||||
return !item.measureHeight || !isUndefined(this._heightCache[item.key]);
|
||||
return !item.measureHeight || !_.isUndefined(this._heightCache[item.key]);
|
||||
}
|
||||
|
||||
private _getHeightOfItem(item: VirtualListViewItemInfo) {
|
||||
|
@ -1308,7 +1301,7 @@ export class VirtualListView<ItemInfo extends VirtualListViewItemInfo>
|
|||
}
|
||||
|
||||
// See if we have it cached
|
||||
if (!isUndefined(this._heightCache[item.key])) {
|
||||
if (!_.isUndefined(this._heightCache[item.key])) {
|
||||
return this._heightCache[item.key];
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"esModuleInterop": true,
|
||||
"importHelpers": true,
|
||||
"declaration": true,
|
||||
"noResolve": false,
|
||||
"jsx": "react",
|
||||
|
|
|
@ -7,12 +7,12 @@
|
|||
* Imports a subset of lodash library needed for ReactXP's implementation.
|
||||
*/
|
||||
|
||||
import clone from 'lodash/clone';
|
||||
import compact from 'lodash/compact';
|
||||
import filter from 'lodash/filter';
|
||||
import isEqual from 'lodash/isEqual';
|
||||
import pull from 'lodash/pull';
|
||||
import sortBy from 'lodash/sortBy';
|
||||
import clone = require('lodash/clone');
|
||||
import compact = require('lodash/compact');
|
||||
import filter = require('lodash/filter');
|
||||
import isEqual = require('lodash/isEqual');
|
||||
import pull = require('lodash/pull');
|
||||
import sortBy = require('lodash/sortBy');
|
||||
|
||||
export interface Dictionary<T> {
|
||||
[index: string]: T;
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
import * as PropTypes from 'prop-types';
|
||||
import * as React from 'react';
|
||||
import * as RN from 'react-native';
|
||||
import assert from 'assert';
|
||||
import * as assert from 'assert';
|
||||
|
||||
import { FocusArbitratorProvider } from '../common/utils/AutoFocusHelper';
|
||||
import { Button as ButtonBase } from '../common/Interfaces';
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
import * as PropTypes from 'prop-types';
|
||||
import * as React from 'react';
|
||||
import * as RN from 'react-native';
|
||||
import assert from 'assert';
|
||||
import * as assert from 'assert';
|
||||
|
||||
import { clone, extend } from './utils/lodashMini';
|
||||
import { FocusArbitratorProvider } from '../common/utils/AutoFocusHelper';
|
||||
|
|
|
@ -7,20 +7,20 @@
|
|||
* Import and re-export of part of the lodash module. This helps reduce bundle size.
|
||||
*/
|
||||
|
||||
import clone from 'lodash/clone';
|
||||
import compact from 'lodash/compact';
|
||||
import extend from 'lodash/extend';
|
||||
import filter from 'lodash/filter';
|
||||
import findIndex from 'lodash/findIndex';
|
||||
import findLast from 'lodash/findLast';
|
||||
import isArray from 'lodash/isArray';
|
||||
import isEqual from 'lodash/isEqual';
|
||||
import isUndefined from 'lodash/isUndefined';
|
||||
import last from 'lodash/last';
|
||||
import map from 'lodash/map';
|
||||
import max from 'lodash/max';
|
||||
import omit from 'lodash/omit';
|
||||
import union from 'lodash/union';
|
||||
import clone = require('lodash/clone');
|
||||
import compact = require('lodash/compact');
|
||||
import extend = require('lodash/extend');
|
||||
import filter = require('lodash/filter');
|
||||
import findIndex = require('lodash/findIndex');
|
||||
import findLast = require('lodash/findLast');
|
||||
import isArray = require('lodash/isArray');
|
||||
import isEqual = require('lodash/isEqual');
|
||||
import isUndefined = require('lodash/isUndefined');
|
||||
import last = require('lodash/last');
|
||||
import map = require('lodash/map');
|
||||
import max = require('lodash/max');
|
||||
import omit = require('lodash/omit');
|
||||
import union = require('lodash/union');
|
||||
|
||||
export {
|
||||
clone,
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* Web-specific implementation of the cross-platform Clipboard abstraction.
|
||||
*/
|
||||
import * as SyncTasks from 'synctasks';
|
||||
import escape from 'lodash/escape';
|
||||
import escape = require('lodash/escape');
|
||||
|
||||
import * as RX from '../common/Interfaces';
|
||||
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
* to animate the edits.
|
||||
*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import assert from 'assert';
|
||||
|
||||
import * as _ from './../utils/lodashMini';
|
||||
import { Types } from '../../common/Interfaces';
|
||||
|
|
|
@ -7,34 +7,34 @@
|
|||
* Import and re-export of part of the lodash module. This helps reduce bundle size.
|
||||
*/
|
||||
|
||||
import assign from 'lodash/assign';
|
||||
import clone from 'lodash/clone';
|
||||
import cloneDeep from 'lodash/cloneDeep';
|
||||
import defer from 'lodash/defer';
|
||||
import each from 'lodash/each';
|
||||
import endsWith from 'lodash/endsWith';
|
||||
import extend from 'lodash/extend';
|
||||
import filter from 'lodash/filter';
|
||||
import findIndex from 'lodash/findIndex';
|
||||
import findLast from 'lodash/findLast';
|
||||
import flatten from 'lodash/flatten';
|
||||
import get from 'lodash/get';
|
||||
import isArray from 'lodash/isArray';
|
||||
import isEmpty from 'lodash/isEmpty';
|
||||
import isEqual from 'lodash/isEqual';
|
||||
import isObject from 'lodash/isObject';
|
||||
import isUndefined from 'lodash/isUndefined';
|
||||
import kebabCase from 'lodash/kebabCase';
|
||||
import keys from 'lodash/keys';
|
||||
import map from 'lodash/map';
|
||||
import mapValues from 'lodash/mapValues';
|
||||
import max from 'lodash/max';
|
||||
import memoize from 'lodash/memoize';
|
||||
import merge from 'lodash/merge';
|
||||
import omit from 'lodash/omit';
|
||||
import remove from 'lodash/remove';
|
||||
import throttle from 'lodash/throttle';
|
||||
import union from 'lodash/union';
|
||||
import assign = require('lodash/assign');
|
||||
import clone = require('lodash/clone');
|
||||
import cloneDeep = require('lodash/cloneDeep');
|
||||
import defer = require('lodash/defer');
|
||||
import each = require('lodash/each');
|
||||
import endsWith = require('lodash/endsWith');
|
||||
import extend = require('lodash/extend');
|
||||
import filter = require('lodash/filter');
|
||||
import findIndex = require('lodash/findIndex');
|
||||
import findLast = require('lodash/findLast');
|
||||
import flatten = require('lodash/flatten');
|
||||
import get = require('lodash/get');
|
||||
import isArray = require('lodash/isArray');
|
||||
import isEmpty = require('lodash/isEmpty');
|
||||
import isEqual = require('lodash/isEqual');
|
||||
import isObject = require('lodash/isObject');
|
||||
import isUndefined = require('lodash/isUndefined');
|
||||
import kebabCase = require('lodash/kebabCase');
|
||||
import keys = require('lodash/keys');
|
||||
import map = require('lodash/map');
|
||||
import mapValues = require('lodash/mapValues');
|
||||
import max = require('lodash/max');
|
||||
import memoize = require('lodash/memoize');
|
||||
import merge = require('lodash/merge');
|
||||
import omit = require('lodash/omit');
|
||||
import remove = require('lodash/remove');
|
||||
import throttle = require('lodash/throttle');
|
||||
import union = require('lodash/union');
|
||||
|
||||
export {
|
||||
assign,
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*/
|
||||
|
||||
import * as React from 'react';
|
||||
import assert from 'assert';
|
||||
import * as assert from 'assert';
|
||||
|
||||
import { assign } from './../utils/lodashMini';
|
||||
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"experimentalDecorators": true,
|
||||
"esModuleInterop": true,
|
||||
"importHelpers": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitReturns": true,
|
||||
"noImplicitThis": true,
|
||||
|
@ -35,4 +33,4 @@
|
|||
"samples",
|
||||
"website"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче