Latest updates from IceHrmPro
This commit is contained in:
23
web/node_modules/rc-virtual-list/lib/utils/algorithmUtil.d.ts
generated
vendored
Normal file
23
web/node_modules/rc-virtual-list/lib/utils/algorithmUtil.d.ts
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import { Key } from './itemUtil';
|
||||
/**
|
||||
* Get index with specific start index one by one. e.g.
|
||||
* min: 3, max: 9, start: 6
|
||||
*
|
||||
* Return index is:
|
||||
* [0]: 6
|
||||
* [1]: 7
|
||||
* [2]: 5
|
||||
* [3]: 8
|
||||
* [4]: 4
|
||||
* [5]: 9
|
||||
* [6]: 3
|
||||
*/
|
||||
export declare function getIndexByStartLoc(min: number, max: number, start: number, index: number): number;
|
||||
/**
|
||||
* We assume that 2 list has only 1 item diff and others keeping the order.
|
||||
* So we can use dichotomy algorithm to find changed one.
|
||||
*/
|
||||
export declare function findListDiffIndex<T>(originList: T[], targetList: T[], getKey: (item: T) => Key): {
|
||||
index: number;
|
||||
multiple: boolean;
|
||||
} | null;
|
||||
99
web/node_modules/rc-virtual-list/lib/utils/algorithmUtil.js
generated
vendored
Normal file
99
web/node_modules/rc-virtual-list/lib/utils/algorithmUtil.js
generated
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getIndexByStartLoc = getIndexByStartLoc;
|
||||
exports.findListDiffIndex = findListDiffIndex;
|
||||
|
||||
/**
|
||||
* Get index with specific start index one by one. e.g.
|
||||
* min: 3, max: 9, start: 6
|
||||
*
|
||||
* Return index is:
|
||||
* [0]: 6
|
||||
* [1]: 7
|
||||
* [2]: 5
|
||||
* [3]: 8
|
||||
* [4]: 4
|
||||
* [5]: 9
|
||||
* [6]: 3
|
||||
*/
|
||||
function getIndexByStartLoc(min, max, start, index) {
|
||||
var beforeCount = start - min;
|
||||
var afterCount = max - start;
|
||||
var balanceCount = Math.min(beforeCount, afterCount) * 2; // Balance
|
||||
|
||||
if (index <= balanceCount) {
|
||||
var stepIndex = Math.floor(index / 2);
|
||||
|
||||
if (index % 2) {
|
||||
return start + stepIndex + 1;
|
||||
}
|
||||
|
||||
return start - stepIndex;
|
||||
} // One is out of range
|
||||
|
||||
|
||||
if (beforeCount > afterCount) {
|
||||
return start - (index - afterCount);
|
||||
}
|
||||
|
||||
return start + (index - beforeCount);
|
||||
}
|
||||
/**
|
||||
* We assume that 2 list has only 1 item diff and others keeping the order.
|
||||
* So we can use dichotomy algorithm to find changed one.
|
||||
*/
|
||||
|
||||
|
||||
function findListDiffIndex(originList, targetList, getKey) {
|
||||
var originLen = originList.length;
|
||||
var targetLen = targetList.length;
|
||||
var shortList;
|
||||
var longList;
|
||||
|
||||
if (originLen === 0 && targetLen === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (originLen < targetLen) {
|
||||
shortList = originList;
|
||||
longList = targetList;
|
||||
} else {
|
||||
shortList = targetList;
|
||||
longList = originList;
|
||||
}
|
||||
|
||||
var notExistKey = {
|
||||
__EMPTY_ITEM__: true
|
||||
};
|
||||
|
||||
function getItemKey(item) {
|
||||
if (item !== undefined) {
|
||||
return getKey(item);
|
||||
}
|
||||
|
||||
return notExistKey;
|
||||
} // Loop to find diff one
|
||||
|
||||
|
||||
var diffIndex = null;
|
||||
var multiple = Math.abs(originLen - targetLen) !== 1;
|
||||
|
||||
for (var i = 0; i < longList.length; i += 1) {
|
||||
var shortKey = getItemKey(shortList[i]);
|
||||
var longKey = getItemKey(longList[i]);
|
||||
|
||||
if (shortKey !== longKey) {
|
||||
diffIndex = i;
|
||||
multiple = multiple || shortKey !== getItemKey(longList[i + 1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return diffIndex === null ? null : {
|
||||
index: diffIndex,
|
||||
multiple: multiple
|
||||
};
|
||||
}
|
||||
64
web/node_modules/rc-virtual-list/lib/utils/itemUtil.d.ts
generated
vendored
Normal file
64
web/node_modules/rc-virtual-list/lib/utils/itemUtil.d.ts
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* Our algorithm have additional one ghost item
|
||||
* whose index as `data.length` to simplify the calculation
|
||||
*/
|
||||
export declare const GHOST_ITEM_KEY = "__rc_ghost_item__";
|
||||
export declare type Key = string | number;
|
||||
/**
|
||||
* Safari has the elasticity effect which provides negative `scrollTop` value.
|
||||
* We should ignore it since will make scroll animation shake.
|
||||
*/
|
||||
export declare function alignScrollTop(scrollTop: number, scrollRange: number): number;
|
||||
export declare function getScrollPercentage({ scrollTop, scrollHeight, clientHeight, }: {
|
||||
scrollTop: number;
|
||||
scrollHeight: number;
|
||||
clientHeight: number;
|
||||
}): number;
|
||||
export declare function getElementScrollPercentage(element: HTMLElement | null): number;
|
||||
/**
|
||||
* Get node `offsetHeight`. We prefer node is a dom element directly.
|
||||
* But if not provided, downgrade to `findDOMNode` to get the real dom element.
|
||||
*/
|
||||
export declare function getNodeHeight(node: HTMLElement): number;
|
||||
/**
|
||||
* Get display items start, end, located item index. This is pure math calculation
|
||||
*/
|
||||
export declare function getRangeIndex(scrollPtg: number, itemCount: number, visibleCount: number): {
|
||||
itemIndex: number;
|
||||
itemOffsetPtg: number;
|
||||
startIndex: number;
|
||||
endIndex: number;
|
||||
};
|
||||
interface ItemTopConfig {
|
||||
itemIndex: number;
|
||||
itemElementHeights: {
|
||||
[key: string]: number;
|
||||
};
|
||||
itemOffsetPtg: number;
|
||||
scrollTop: number;
|
||||
scrollPtg: number;
|
||||
clientHeight: number;
|
||||
getItemKey: (index: number) => Key;
|
||||
}
|
||||
/**
|
||||
* Calculate the located item related top with current window height
|
||||
*/
|
||||
export declare function getItemRelativeTop({ itemIndex, itemOffsetPtg, itemElementHeights, scrollPtg, clientHeight, getItemKey, }: Omit<ItemTopConfig, 'scrollTop'>): number;
|
||||
/**
|
||||
* Calculate the located item absolute top with whole scroll height
|
||||
*/
|
||||
export declare function getItemAbsoluteTop({ scrollTop, ...rest }: ItemTopConfig): number;
|
||||
interface CompareItemConfig {
|
||||
locatedItemRelativeTop: number;
|
||||
locatedItemIndex: number;
|
||||
compareItemIndex: number;
|
||||
getItemKey: (index: number) => Key;
|
||||
startIndex: number;
|
||||
endIndex: number;
|
||||
itemElementHeights: {
|
||||
[key: string]: number;
|
||||
};
|
||||
}
|
||||
export declare function getCompareItemRelativeTop({ locatedItemRelativeTop, locatedItemIndex, compareItemIndex, startIndex, endIndex, getItemKey, itemElementHeights, }: CompareItemConfig): number;
|
||||
export declare function requireVirtual(height: number, itemHeight: number, count: number, virtual: boolean): boolean;
|
||||
export {};
|
||||
187
web/node_modules/rc-virtual-list/lib/utils/itemUtil.js
generated
vendored
Normal file
187
web/node_modules/rc-virtual-list/lib/utils/itemUtil.js
generated
vendored
Normal file
@@ -0,0 +1,187 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.alignScrollTop = alignScrollTop;
|
||||
exports.getScrollPercentage = getScrollPercentage;
|
||||
exports.getElementScrollPercentage = getElementScrollPercentage;
|
||||
exports.getNodeHeight = getNodeHeight;
|
||||
exports.getRangeIndex = getRangeIndex;
|
||||
exports.getItemRelativeTop = getItemRelativeTop;
|
||||
exports.getItemAbsoluteTop = getItemAbsoluteTop;
|
||||
exports.getCompareItemRelativeTop = getCompareItemRelativeTop;
|
||||
exports.requireVirtual = requireVirtual;
|
||||
exports.GHOST_ITEM_KEY = void 0;
|
||||
|
||||
var _findDOMNode = _interopRequireDefault(require("rc-util/lib/Dom/findDOMNode"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
||||
|
||||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
||||
|
||||
/**
|
||||
* Our algorithm have additional one ghost item
|
||||
* whose index as `data.length` to simplify the calculation
|
||||
*/
|
||||
var GHOST_ITEM_KEY = '__rc_ghost_item__';
|
||||
/**
|
||||
* Get location item and its align percentage with the scroll percentage.
|
||||
* We should measure current scroll position to decide which item is the location item.
|
||||
* And then fill the top count and bottom count with the base of location item.
|
||||
*
|
||||
* `total` should be the real count instead of `total - 1` in calculation.
|
||||
*/
|
||||
|
||||
exports.GHOST_ITEM_KEY = GHOST_ITEM_KEY;
|
||||
|
||||
function getLocationItem(scrollPtg, total) {
|
||||
var itemIndex = Math.floor(scrollPtg * total);
|
||||
var itemTopPtg = itemIndex / total;
|
||||
var itemBottomPtg = (itemIndex + 1) / total;
|
||||
var itemOffsetPtg = (scrollPtg - itemTopPtg) / (itemBottomPtg - itemTopPtg);
|
||||
return {
|
||||
index: itemIndex,
|
||||
offsetPtg: itemOffsetPtg
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Safari has the elasticity effect which provides negative `scrollTop` value.
|
||||
* We should ignore it since will make scroll animation shake.
|
||||
*/
|
||||
|
||||
|
||||
function alignScrollTop(scrollTop, scrollRange) {
|
||||
if (scrollTop < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (scrollTop >= scrollRange) {
|
||||
return scrollRange;
|
||||
}
|
||||
|
||||
return scrollTop;
|
||||
}
|
||||
|
||||
function getScrollPercentage(_ref) {
|
||||
var scrollTop = _ref.scrollTop,
|
||||
scrollHeight = _ref.scrollHeight,
|
||||
clientHeight = _ref.clientHeight;
|
||||
|
||||
if (scrollHeight <= clientHeight) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
var scrollRange = scrollHeight - clientHeight;
|
||||
var alignedScrollTop = alignScrollTop(scrollTop, scrollRange);
|
||||
var scrollTopPtg = alignedScrollTop / scrollRange;
|
||||
return scrollTopPtg;
|
||||
}
|
||||
|
||||
function getElementScrollPercentage(element) {
|
||||
if (!element) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return getScrollPercentage(element);
|
||||
}
|
||||
/**
|
||||
* Get node `offsetHeight`. We prefer node is a dom element directly.
|
||||
* But if not provided, downgrade to `findDOMNode` to get the real dom element.
|
||||
*/
|
||||
|
||||
|
||||
function getNodeHeight(node) {
|
||||
var element = (0, _findDOMNode.default)(node);
|
||||
return element ? element.offsetHeight : 0;
|
||||
}
|
||||
/**
|
||||
* Get display items start, end, located item index. This is pure math calculation
|
||||
*/
|
||||
|
||||
|
||||
function getRangeIndex(scrollPtg, itemCount, visibleCount) {
|
||||
var _getLocationItem = getLocationItem(scrollPtg, itemCount),
|
||||
index = _getLocationItem.index,
|
||||
offsetPtg = _getLocationItem.offsetPtg;
|
||||
|
||||
var beforeCount = Math.ceil(scrollPtg * visibleCount);
|
||||
var afterCount = Math.ceil((1 - scrollPtg) * visibleCount);
|
||||
return {
|
||||
itemIndex: index,
|
||||
itemOffsetPtg: offsetPtg,
|
||||
startIndex: Math.max(0, index - beforeCount),
|
||||
endIndex: Math.min(itemCount - 1, index + afterCount)
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Calculate the located item related top with current window height
|
||||
*/
|
||||
|
||||
|
||||
function getItemRelativeTop(_ref2) {
|
||||
var itemIndex = _ref2.itemIndex,
|
||||
itemOffsetPtg = _ref2.itemOffsetPtg,
|
||||
itemElementHeights = _ref2.itemElementHeights,
|
||||
scrollPtg = _ref2.scrollPtg,
|
||||
clientHeight = _ref2.clientHeight,
|
||||
getItemKey = _ref2.getItemKey;
|
||||
var locatedItemHeight = itemElementHeights[getItemKey(itemIndex)] || 0;
|
||||
var locatedItemTop = scrollPtg * clientHeight;
|
||||
var locatedItemOffset = itemOffsetPtg * locatedItemHeight;
|
||||
return Math.floor(locatedItemTop - locatedItemOffset);
|
||||
}
|
||||
/**
|
||||
* Calculate the located item absolute top with whole scroll height
|
||||
*/
|
||||
|
||||
|
||||
function getItemAbsoluteTop(_ref3) {
|
||||
var scrollTop = _ref3.scrollTop,
|
||||
rest = _objectWithoutProperties(_ref3, ["scrollTop"]);
|
||||
|
||||
return scrollTop + getItemRelativeTop(rest);
|
||||
}
|
||||
|
||||
function getCompareItemRelativeTop(_ref4) {
|
||||
var locatedItemRelativeTop = _ref4.locatedItemRelativeTop,
|
||||
locatedItemIndex = _ref4.locatedItemIndex,
|
||||
compareItemIndex = _ref4.compareItemIndex,
|
||||
startIndex = _ref4.startIndex,
|
||||
endIndex = _ref4.endIndex,
|
||||
getItemKey = _ref4.getItemKey,
|
||||
itemElementHeights = _ref4.itemElementHeights;
|
||||
var originCompareItemTop = locatedItemRelativeTop;
|
||||
var compareItemKey = getItemKey(compareItemIndex);
|
||||
|
||||
if (compareItemIndex <= locatedItemIndex) {
|
||||
for (var index = locatedItemIndex; index >= startIndex; index -= 1) {
|
||||
var key = getItemKey(index);
|
||||
|
||||
if (key === compareItemKey) {
|
||||
break;
|
||||
}
|
||||
|
||||
var prevItemKey = getItemKey(index - 1);
|
||||
originCompareItemTop -= itemElementHeights[prevItemKey] || 0;
|
||||
}
|
||||
} else {
|
||||
for (var _index = locatedItemIndex; _index <= endIndex; _index += 1) {
|
||||
var _key = getItemKey(_index);
|
||||
|
||||
if (_key === compareItemKey) {
|
||||
break;
|
||||
}
|
||||
|
||||
originCompareItemTop += itemElementHeights[_key] || 0;
|
||||
}
|
||||
}
|
||||
|
||||
return originCompareItemTop;
|
||||
}
|
||||
|
||||
function requireVirtual(height, itemHeight, count, virtual) {
|
||||
return virtual !== false && typeof height === 'number' && count * itemHeight > height;
|
||||
}
|
||||
Reference in New Issue
Block a user