first commit
This commit is contained in:
16
frontend/node_modules/rc-virtual-list/es/utils/CacheMap.d.ts
generated
vendored
Normal file
16
frontend/node_modules/rc-virtual-list/es/utils/CacheMap.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import type React from 'react';
|
||||
declare class CacheMap {
|
||||
maps: Record<string, number>;
|
||||
id: number;
|
||||
diffRecords: Map<React.Key, number>;
|
||||
constructor();
|
||||
set(key: React.Key, value: number): void;
|
||||
get(key: React.Key): number;
|
||||
/**
|
||||
* CacheMap will record the key changed.
|
||||
* To help to know what's update in the next render.
|
||||
*/
|
||||
resetRecord(): void;
|
||||
getRecord(): Map<React.Key, number>;
|
||||
}
|
||||
export default CacheMap;
|
||||
46
frontend/node_modules/rc-virtual-list/es/utils/CacheMap.js
generated
vendored
Normal file
46
frontend/node_modules/rc-virtual-list/es/utils/CacheMap.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
||||
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
||||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
||||
// Firefox has low performance of map.
|
||||
var CacheMap = /*#__PURE__*/function () {
|
||||
function CacheMap() {
|
||||
_classCallCheck(this, CacheMap);
|
||||
_defineProperty(this, "maps", void 0);
|
||||
// Used for cache key
|
||||
// `useMemo` no need to update if `id` not change
|
||||
_defineProperty(this, "id", 0);
|
||||
_defineProperty(this, "diffRecords", new Map());
|
||||
this.maps = Object.create(null);
|
||||
}
|
||||
_createClass(CacheMap, [{
|
||||
key: "set",
|
||||
value: function set(key, value) {
|
||||
// Record prev value
|
||||
this.diffRecords.set(key, this.maps[key]);
|
||||
this.maps[key] = value;
|
||||
this.id += 1;
|
||||
}
|
||||
}, {
|
||||
key: "get",
|
||||
value: function get(key) {
|
||||
return this.maps[key];
|
||||
}
|
||||
|
||||
/**
|
||||
* CacheMap will record the key changed.
|
||||
* To help to know what's update in the next render.
|
||||
*/
|
||||
}, {
|
||||
key: "resetRecord",
|
||||
value: function resetRecord() {
|
||||
this.diffRecords.clear();
|
||||
}
|
||||
}, {
|
||||
key: "getRecord",
|
||||
value: function getRecord() {
|
||||
return this.diffRecords;
|
||||
}
|
||||
}]);
|
||||
return CacheMap;
|
||||
}();
|
||||
export default CacheMap;
|
||||
23
frontend/node_modules/rc-virtual-list/es/utils/algorithmUtil.d.ts
generated
vendored
Normal file
23
frontend/node_modules/rc-virtual-list/es/utils/algorithmUtil.d.ts
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import type * as React from 'react';
|
||||
/**
|
||||
* 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) => React.Key): {
|
||||
index: number;
|
||||
multiple: boolean;
|
||||
} | null;
|
||||
80
frontend/node_modules/rc-virtual-list/es/utils/algorithmUtil.js
generated
vendored
Normal file
80
frontend/node_modules/rc-virtual-list/es/utils/algorithmUtil.js
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* 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 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.
|
||||
*/
|
||||
export 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
|
||||
};
|
||||
}
|
||||
2
frontend/node_modules/rc-virtual-list/es/utils/isFirefox.d.ts
generated
vendored
Normal file
2
frontend/node_modules/rc-virtual-list/es/utils/isFirefox.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
declare const isFF: boolean;
|
||||
export default isFF;
|
||||
3
frontend/node_modules/rc-virtual-list/es/utils/isFirefox.js
generated
vendored
Normal file
3
frontend/node_modules/rc-virtual-list/es/utils/isFirefox.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
||||
var isFF = (typeof navigator === "undefined" ? "undefined" : _typeof(navigator)) === 'object' && /Firefox/i.test(navigator.userAgent);
|
||||
export default isFF;
|
||||
1
frontend/node_modules/rc-virtual-list/es/utils/scrollbarUtil.d.ts
generated
vendored
Normal file
1
frontend/node_modules/rc-virtual-list/es/utils/scrollbarUtil.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function getSpinSize(containerSize?: number, scrollRange?: number): number;
|
||||
11
frontend/node_modules/rc-virtual-list/es/utils/scrollbarUtil.js
generated
vendored
Normal file
11
frontend/node_modules/rc-virtual-list/es/utils/scrollbarUtil.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
var MIN_SIZE = 20;
|
||||
export function getSpinSize() {
|
||||
var containerSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
||||
var scrollRange = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
||||
var baseSize = containerSize / scrollRange * containerSize;
|
||||
if (isNaN(baseSize)) {
|
||||
baseSize = 0;
|
||||
}
|
||||
baseSize = Math.max(baseSize, MIN_SIZE);
|
||||
return Math.floor(baseSize);
|
||||
}
|
||||
Reference in New Issue
Block a user