@apdesign/web-react 1.1.1 → 1.1.2
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/dist/arco-icon.min.js +1 -1
- package/dist/arco.development.js +4 -4
- package/dist/arco.min.js +3 -3
- package/es/Button/index.d.ts +3 -3
- package/es/DatePicker/util.d.ts +1 -1
- package/es/Menu/context.d.ts +1 -1
- package/es/Typography/base.d.ts +1 -1
- package/es/_class/VirtualList/index.js +16 -13
- package/es/_class/VirtualList/utils/itemUtil.js +8 -6
- package/es/_util/constant.d.ts +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/lib/_class/VirtualList/index.js +16 -13
- package/lib/_class/VirtualList/utils/itemUtil.js +8 -6
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/package.json +1 -1
package/es/Button/index.d.ts
CHANGED
|
@@ -2,12 +2,12 @@ import React from 'react';
|
|
|
2
2
|
import Group from './group';
|
|
3
3
|
import { ButtonProps } from './interface';
|
|
4
4
|
declare const ButtonComponent: React.ForwardRefExoticComponent<Partial<{
|
|
5
|
-
htmlType?: "button" | "
|
|
6
|
-
} & import("./interface").BaseButtonProps & Omit<React.ButtonHTMLAttributes<any>, "className" | "
|
|
5
|
+
htmlType?: "button" | "submit" | "reset";
|
|
6
|
+
} & import("./interface").BaseButtonProps & Omit<React.ButtonHTMLAttributes<any>, "className" | "type" | "onClick"> & {
|
|
7
7
|
href: string;
|
|
8
8
|
target?: string;
|
|
9
9
|
anchorProps?: React.HTMLProps<HTMLAnchorElement>;
|
|
10
|
-
} & Omit<React.AnchorHTMLAttributes<any>, "className" | "
|
|
10
|
+
} & Omit<React.AnchorHTMLAttributes<any>, "className" | "type" | "onClick">> & React.RefAttributes<unknown>> & {
|
|
11
11
|
__BYTE_BUTTON: boolean;
|
|
12
12
|
Group: typeof Group;
|
|
13
13
|
};
|
package/es/DatePicker/util.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Dayjs } from 'dayjs';
|
|
2
2
|
export declare function isTimeArrayChange(prevTime: Dayjs[], nextTime: Dayjs[]): boolean;
|
|
3
|
-
export declare function getAvailableDayjsLength(value: any):
|
|
3
|
+
export declare function getAvailableDayjsLength(value: any): 1 | 0 | 2;
|
|
4
4
|
export declare function isDisabledDate(cellDate: any, disabledDate: any, mode: any): boolean;
|
|
5
5
|
declare type WeekStartType = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
6
6
|
export declare function getDefaultWeekStart(dayjsLocale: string): WeekStartType;
|
package/es/Menu/context.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare type HotkeyInfo = {
|
|
|
6
6
|
type: 'sibling' | 'generation' | 'enter';
|
|
7
7
|
};
|
|
8
8
|
export declare type ResetHotkeyInfo = (activeKey?: string) => void;
|
|
9
|
-
declare const MenuContext: import("react").Context<Pick<MenuProps, "
|
|
9
|
+
declare const MenuContext: import("react").Context<Pick<MenuProps, "mode" | "triggerProps" | "collapse" | "inDropdown" | "theme" | "levelIndent" | "icons" | "autoScrollIntoView" | "selectedKeys" | "openKeys" | "scrollConfig" | "tooltipProps"> & {
|
|
10
10
|
id?: string;
|
|
11
11
|
prefixCls?: string;
|
|
12
12
|
onClickMenuItem?: (key: string, event: any) => void;
|
package/es/Typography/base.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TypographyParagraphProps, TypographyTitleProps } from './interface';
|
|
3
3
|
declare const _default: React.ForwardRefExoticComponent<TypographyParagraphProps & TypographyTitleProps & import("./interface").CommonProps & {
|
|
4
|
-
componentType: "
|
|
4
|
+
componentType: "Text" | "Title" | "Paragraph";
|
|
5
5
|
} & React.RefAttributes<unknown>>;
|
|
6
6
|
export default _default;
|
|
@@ -36,7 +36,6 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
36
36
|
}
|
|
37
37
|
return ar;
|
|
38
38
|
};
|
|
39
|
-
var _a;
|
|
40
39
|
import React, { useEffect, useImperativeHandle, useRef, useMemo, useState, } from 'react';
|
|
41
40
|
import { getValidScrollTop, getCompareItemRelativeTop, getItemAbsoluteTop, getItemRelativeTop, getNodeHeight, getRangeIndex, getScrollPercentage, GHOST_ITEM_KEY, getLongestItemIndex, getLocationItem, } from './utils/itemUtil';
|
|
42
41
|
import { raf, caf } from '../../_util/raf';
|
|
@@ -49,7 +48,6 @@ import useIsFirstRender from '../../_util/hooks/useIsFirstRender';
|
|
|
49
48
|
import useForceUpdate from '../../_util/hooks/useForceUpdate';
|
|
50
49
|
import ResizeObserver from '../../_util/resizeObserver';
|
|
51
50
|
import useIsomorphicLayoutEffect from '../../_util/hooks/useIsomorphicLayoutEffect';
|
|
52
|
-
var __TABLE_PADDING__ = (_a = window.__TABLE_PADDING__) !== null && _a !== void 0 ? _a : 0;
|
|
53
51
|
// height of the virtual element, used to calculate total height of the virtual list
|
|
54
52
|
var DEFAULT_VIRTUAL_ITEM_HEIGHT = 32;
|
|
55
53
|
var KEY_VIRTUAL_ITEM_HEIGHT = "__virtual_item_height_" + Math.random().toFixed(5).slice(2);
|
|
@@ -88,11 +86,12 @@ var useCacheChildrenNodes = function (children) {
|
|
|
88
86
|
};
|
|
89
87
|
};
|
|
90
88
|
var VirtualList = React.forwardRef(function (props, ref) {
|
|
91
|
-
var
|
|
89
|
+
var _a, _b;
|
|
90
|
+
var style = props.style, className = props.className, children = props.children, _c = props.data, data = _c === void 0 ? [] : _c, itemKey = props.itemKey, _d = props.threshold, threshold = _d === void 0 ? 100 : _d, _e = props.wrapper, WrapperTagName = _e === void 0 ? 'div' : _e, _f = props.height, propHeight = _f === void 0 ? '100%' : _f, _g = props.isStaticItemHeight, isStaticItemHeight = _g === void 0 ? true : _g, propItemHeight = props.itemHeight, measureLongestItem = props.measureLongestItem, scrollOptions = props.scrollOptions, onScroll = props.onScroll, _h = props.needFiller, needFiller = _h === void 0 ? true : _h, outerStyle = props.outerStyle, innerStyle = props.innerStyle, _j = props.wrapperChild, WrapperChildTagName = _j === void 0 ? React.Fragment : _j, restProps = __rest(props, ["style", "className", "children", "data", "itemKey", "threshold", "wrapper", "height", "isStaticItemHeight", "itemHeight", "measureLongestItem", "scrollOptions", "onScroll", "needFiller", "outerStyle", "innerStyle", "wrapperChild"]);
|
|
92
91
|
// Compatible with setting the height of the list through style.maxHeight
|
|
93
92
|
var styleListMaxHeight = (style && style.maxHeight) || propHeight;
|
|
94
93
|
var refItemHeightMap = useRef({});
|
|
95
|
-
var
|
|
94
|
+
var _k = __read(useState(200), 2), stateHeight = _k[0], setStateHeight = _k[1];
|
|
96
95
|
var renderChild = useCacheChildrenNodes(children);
|
|
97
96
|
useComputeVirtualItemHeight(refItemHeightMap);
|
|
98
97
|
// Elements with the same height, the height of the item is based on the first rendering
|
|
@@ -102,8 +101,10 @@ var VirtualList = React.forwardRef(function (props, ref) {
|
|
|
102
101
|
DEFAULT_VIRTUAL_ITEM_HEIGHT;
|
|
103
102
|
var viewportHeight = isNumber(styleListMaxHeight) ? styleListMaxHeight : stateHeight;
|
|
104
103
|
var itemCountVisible = Math.ceil(viewportHeight / itemHeight);
|
|
105
|
-
var itemTotalHeight = itemHeight * itemCount
|
|
106
|
-
var isVirtual = threshold !== null &&
|
|
104
|
+
var itemTotalHeight = itemHeight * itemCount;
|
|
105
|
+
var isVirtual = threshold !== null &&
|
|
106
|
+
itemCount >= threshold &&
|
|
107
|
+
itemTotalHeight + ((_a = window.__TABLE_PADDING__) !== null && _a !== void 0 ? _a : 0) > viewportHeight;
|
|
107
108
|
var refList = useRef(null);
|
|
108
109
|
var refRafId = useRef(null);
|
|
109
110
|
var refLockScroll = useRef(false);
|
|
@@ -121,7 +122,7 @@ var VirtualList = React.forwardRef(function (props, ref) {
|
|
|
121
122
|
}
|
|
122
123
|
return { top: 0, bottom: 0 };
|
|
123
124
|
}, [refList.current]);
|
|
124
|
-
var
|
|
125
|
+
var _l = __read(useStateWithPromise({
|
|
125
126
|
// measure status
|
|
126
127
|
status: 'NONE',
|
|
127
128
|
// render range info
|
|
@@ -132,7 +133,7 @@ var VirtualList = React.forwardRef(function (props, ref) {
|
|
|
132
133
|
// scroll info
|
|
133
134
|
startItemTop: 0,
|
|
134
135
|
scrollTop: 0,
|
|
135
|
-
}), 2), state =
|
|
136
|
+
}), 2), state = _l[0], setState = _l[1];
|
|
136
137
|
var prevData = usePrevious(data) || [];
|
|
137
138
|
var isFirstRender = useIsFirstRender();
|
|
138
139
|
var getItemKey = function (item, index) {
|
|
@@ -228,12 +229,13 @@ var VirtualList = React.forwardRef(function (props, ref) {
|
|
|
228
229
|
};
|
|
229
230
|
// Modify the state and recalculate the position in the next render
|
|
230
231
|
var virtualListScrollHandler = function (event, isInit) {
|
|
232
|
+
var _a;
|
|
231
233
|
if (isInit === void 0) { isInit = false; }
|
|
232
234
|
// Do NOT use refList.current.scrollHeight
|
|
233
235
|
// We should use Filler's height as total scroll height
|
|
234
236
|
// Filler's translate style may make refList.current.scrollHeight larger than Filler's height
|
|
235
|
-
var scrollHeight = itemTotalHeight;
|
|
236
|
-
var
|
|
237
|
+
var scrollHeight = itemTotalHeight + ((_a = window.__TABLE_PADDING__) !== null && _a !== void 0 ? _a : 0);
|
|
238
|
+
var _b = refList.current, rawScrollTop = _b.scrollTop, clientHeight = _b.clientHeight;
|
|
237
239
|
var scrollTop = getValidScrollTop(rawScrollTop, scrollHeight - clientHeight);
|
|
238
240
|
// Prevent jitter
|
|
239
241
|
if (!isInit && (scrollTop === state.scrollTop || refLockScroll.current)) {
|
|
@@ -244,7 +246,7 @@ var VirtualList = React.forwardRef(function (props, ref) {
|
|
|
244
246
|
clientHeight: clientHeight,
|
|
245
247
|
scrollHeight: scrollHeight,
|
|
246
248
|
});
|
|
247
|
-
var
|
|
249
|
+
var _c = getRangeIndex(scrollPtg, itemCount, itemCountVisible), itemIndex = _c.itemIndex, itemOffsetPtg = _c.itemOffsetPtg, startIndex = _c.startIndex, endIndex = _c.endIndex;
|
|
248
250
|
setState(__assign(__assign({}, state), { scrollTop: scrollTop, itemIndex: itemIndex, itemOffsetPtg: itemOffsetPtg, startIndex: startIndex, endIndex: endIndex, status: 'MEASURE_START' }));
|
|
249
251
|
event && (onScroll === null || onScroll === void 0 ? void 0 : onScroll(event, { index: itemIndex }));
|
|
250
252
|
};
|
|
@@ -264,6 +266,7 @@ var VirtualList = React.forwardRef(function (props, ref) {
|
|
|
264
266
|
}, [itemCountVisible]);
|
|
265
267
|
// Handle additions and deletions of list items or switching the virtual state
|
|
266
268
|
useEffect(function () {
|
|
269
|
+
var _a;
|
|
267
270
|
if (!refList.current)
|
|
268
271
|
return;
|
|
269
272
|
var changedItemIndex = null;
|
|
@@ -281,7 +284,7 @@ var VirtualList = React.forwardRef(function (props, ref) {
|
|
|
281
284
|
itemOffsetPtg: state.itemOffsetPtg,
|
|
282
285
|
scrollPtg: getScrollPercentage({
|
|
283
286
|
scrollTop: state.scrollTop,
|
|
284
|
-
scrollHeight: prevData.length * itemHeight + __TABLE_PADDING__,
|
|
287
|
+
scrollHeight: prevData.length * itemHeight + ((_a = window.__TABLE_PADDING__) !== null && _a !== void 0 ? _a : 0),
|
|
285
288
|
clientHeight: clientHeight,
|
|
286
289
|
}),
|
|
287
290
|
clientHeight: clientHeight,
|
|
@@ -478,7 +481,7 @@ var VirtualList = React.forwardRef(function (props, ref) {
|
|
|
478
481
|
}
|
|
479
482
|
}, getTargetDOMNode: function () { return refList.current; } },
|
|
480
483
|
React.createElement(WrapperTagName, __assign({ ref: refList, style: __assign(__assign({ overflowY: 'auto', overflowAnchor: 'none' }, style), { maxHeight: styleListMaxHeight }), className: className, onScroll: isVirtual ? virtualListScrollHandler : rawListScrollHandler }, restProps), isVirtual ? (React.createElement(React.Fragment, null,
|
|
481
|
-
React.createElement(Filler, { height: itemTotalHeight, outerStyle: outerStyle, innerStyle: innerStyle, offset: state.status === 'MEASURE_DONE' ? state.startItemTop : 0 },
|
|
484
|
+
React.createElement(Filler, { height: itemTotalHeight + ((_b = window.__TABLE_PADDING__) !== null && _b !== void 0 ? _b : 0), outerStyle: outerStyle, innerStyle: innerStyle, offset: state.status === 'MEASURE_DONE' ? state.startItemTop : 0 },
|
|
482
485
|
React.createElement(WrapperChildTagName, null, renderChildren(data.slice(state.startIndex, state.endIndex + 1), state.startIndex))),
|
|
483
486
|
renderLongestItem())) : needFiller ? (React.createElement(Filler, { height: viewportHeight, outerStyle: outerStyle, innerStyle: innerStyle },
|
|
484
487
|
React.createElement(WrapperChildTagName, null, renderChildren(data, 0)))) : (React.createElement(WrapperChildTagName, null, renderChildren(data, 0))))));
|
|
@@ -9,10 +9,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
var _a;
|
|
13
12
|
import { findDOMNode } from '../../../_util/react-dom';
|
|
14
13
|
import getStringLength from '../../../_util/getStringLength';
|
|
15
|
-
var __TABLE_PADDING__ = (_a = window.__TABLE_PADDING__) !== null && _a !== void 0 ? _a : 0;
|
|
16
14
|
/**
|
|
17
15
|
* 为了计算方便,定位元素的下标可能返回数组长度,代表最后一个元素
|
|
18
16
|
*/
|
|
@@ -56,11 +54,12 @@ export function getValidScrollTop(scrollTop, scrollRange) {
|
|
|
56
54
|
* 视口已滚动距离 / 总可滚动距离
|
|
57
55
|
*/
|
|
58
56
|
export function getScrollPercentage(_a) {
|
|
57
|
+
var _b, _c;
|
|
59
58
|
var scrollTop = _a.scrollTop, scrollHeight = _a.scrollHeight, clientHeight = _a.clientHeight;
|
|
60
|
-
var scrollRange = scrollHeight - clientHeight - __TABLE_PADDING__;
|
|
59
|
+
var scrollRange = scrollHeight - clientHeight - ((_b = window.__TABLE_PADDING__) !== null && _b !== void 0 ? _b : 0);
|
|
61
60
|
return scrollRange <= 0
|
|
62
61
|
? 0
|
|
63
|
-
: getValidScrollTop(Math.max(scrollTop - __TABLE_PADDING__, 0), scrollRange) / scrollRange;
|
|
62
|
+
: getValidScrollTop(Math.max(scrollTop - ((_c = window.__TABLE_PADDING__) !== null && _c !== void 0 ? _c : 0), 0), scrollRange) / scrollRange;
|
|
64
63
|
}
|
|
65
64
|
/**
|
|
66
65
|
* 计算需要渲染的元素的开始下标、结束下标和用于定位的元素下标
|
|
@@ -80,15 +79,18 @@ export function getRangeIndex(scrollPtg, itemCount, visibleCount) {
|
|
|
80
79
|
* 计算元素相对于视口顶部的偏移量
|
|
81
80
|
*/
|
|
82
81
|
export function getItemRelativeTop(_a) {
|
|
82
|
+
var _b;
|
|
83
83
|
var itemHeight = _a.itemHeight, itemOffsetPtg = _a.itemOffsetPtg, scrollPtg = _a.scrollPtg, clientHeight = _a.clientHeight;
|
|
84
|
-
return Math.floor((clientHeight + __TABLE_PADDING__)
|
|
84
|
+
return Math.floor((clientHeight + ((_b = window.__TABLE_PADDING__) !== null && _b !== void 0 ? _b : 0)) * scrollPtg -
|
|
85
|
+
itemHeight * itemOffsetPtg);
|
|
85
86
|
}
|
|
86
87
|
/**
|
|
87
88
|
* 计算元素相对于整个滚动区域顶部的偏移量
|
|
88
89
|
*/
|
|
89
90
|
export function getItemAbsoluteTop(_a) {
|
|
91
|
+
var _b;
|
|
90
92
|
var scrollTop = _a.scrollTop, rest = __rest(_a, ["scrollTop"]);
|
|
91
|
-
return Math.max(scrollTop - __TABLE_PADDING__, 0) + getItemRelativeTop(rest);
|
|
93
|
+
return (Math.max(scrollTop - ((_b = window.__TABLE_PADDING__) !== null && _b !== void 0 ? _b : 0), 0) + getItemRelativeTop(rest));
|
|
92
94
|
}
|
|
93
95
|
/**
|
|
94
96
|
* 计算某一指定下标的元素相对于视口顶部的偏移量
|
package/es/_util/constant.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare const NOOP: () => void;
|
|
2
2
|
export declare function newArray(length: number): any;
|
|
3
|
-
export declare function pickTriggerPropsFromRest(rest: any): Pick<any, "
|
|
3
|
+
export declare function pickTriggerPropsFromRest(rest: any): Pick<any, "onClick" | "onFocus" | "onBlur" | "tabIndex" | "onContextMenu" | "onMouseEnter" | "onMouseLeave" | "onMouseMove">;
|
package/es/index.d.ts
CHANGED
|
@@ -139,4 +139,4 @@ export type { WatermarkProps } from './Watermark/interface';
|
|
|
139
139
|
export { default as Watermark } from './Watermark';
|
|
140
140
|
export type { ImageProps, ImagePreviewProps, ImagePreviewActionProps, ImagePreviewGroupProps } from './Image/interface';
|
|
141
141
|
export { default as Image } from './Image';
|
|
142
|
-
export declare const version = "1.1.
|
|
142
|
+
export declare const version = "1.1.2";
|
package/es/index.js
CHANGED
|
@@ -59,7 +59,6 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
59
59
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
60
60
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
61
61
|
};
|
|
62
|
-
var _a;
|
|
63
62
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
64
63
|
var react_1 = __importStar(require("react"));
|
|
65
64
|
var itemUtil_1 = require("./utils/itemUtil");
|
|
@@ -73,7 +72,6 @@ var useIsFirstRender_1 = __importDefault(require("../../_util/hooks/useIsFirstRe
|
|
|
73
72
|
var useForceUpdate_1 = __importDefault(require("../../_util/hooks/useForceUpdate"));
|
|
74
73
|
var resizeObserver_1 = __importDefault(require("../../_util/resizeObserver"));
|
|
75
74
|
var useIsomorphicLayoutEffect_1 = __importDefault(require("../../_util/hooks/useIsomorphicLayoutEffect"));
|
|
76
|
-
var __TABLE_PADDING__ = (_a = window.__TABLE_PADDING__) !== null && _a !== void 0 ? _a : 0;
|
|
77
75
|
// height of the virtual element, used to calculate total height of the virtual list
|
|
78
76
|
var DEFAULT_VIRTUAL_ITEM_HEIGHT = 32;
|
|
79
77
|
var KEY_VIRTUAL_ITEM_HEIGHT = "__virtual_item_height_" + Math.random().toFixed(5).slice(2);
|
|
@@ -112,11 +110,12 @@ var useCacheChildrenNodes = function (children) {
|
|
|
112
110
|
};
|
|
113
111
|
};
|
|
114
112
|
var VirtualList = react_1.default.forwardRef(function (props, ref) {
|
|
115
|
-
var
|
|
113
|
+
var _a, _b;
|
|
114
|
+
var style = props.style, className = props.className, children = props.children, _c = props.data, data = _c === void 0 ? [] : _c, itemKey = props.itemKey, _d = props.threshold, threshold = _d === void 0 ? 100 : _d, _e = props.wrapper, WrapperTagName = _e === void 0 ? 'div' : _e, _f = props.height, propHeight = _f === void 0 ? '100%' : _f, _g = props.isStaticItemHeight, isStaticItemHeight = _g === void 0 ? true : _g, propItemHeight = props.itemHeight, measureLongestItem = props.measureLongestItem, scrollOptions = props.scrollOptions, onScroll = props.onScroll, _h = props.needFiller, needFiller = _h === void 0 ? true : _h, outerStyle = props.outerStyle, innerStyle = props.innerStyle, _j = props.wrapperChild, WrapperChildTagName = _j === void 0 ? react_1.default.Fragment : _j, restProps = __rest(props, ["style", "className", "children", "data", "itemKey", "threshold", "wrapper", "height", "isStaticItemHeight", "itemHeight", "measureLongestItem", "scrollOptions", "onScroll", "needFiller", "outerStyle", "innerStyle", "wrapperChild"]);
|
|
116
115
|
// Compatible with setting the height of the list through style.maxHeight
|
|
117
116
|
var styleListMaxHeight = (style && style.maxHeight) || propHeight;
|
|
118
117
|
var refItemHeightMap = (0, react_1.useRef)({});
|
|
119
|
-
var
|
|
118
|
+
var _k = __read((0, react_1.useState)(200), 2), stateHeight = _k[0], setStateHeight = _k[1];
|
|
120
119
|
var renderChild = useCacheChildrenNodes(children);
|
|
121
120
|
useComputeVirtualItemHeight(refItemHeightMap);
|
|
122
121
|
// Elements with the same height, the height of the item is based on the first rendering
|
|
@@ -126,8 +125,10 @@ var VirtualList = react_1.default.forwardRef(function (props, ref) {
|
|
|
126
125
|
DEFAULT_VIRTUAL_ITEM_HEIGHT;
|
|
127
126
|
var viewportHeight = (0, is_1.isNumber)(styleListMaxHeight) ? styleListMaxHeight : stateHeight;
|
|
128
127
|
var itemCountVisible = Math.ceil(viewportHeight / itemHeight);
|
|
129
|
-
var itemTotalHeight = itemHeight * itemCount
|
|
130
|
-
var isVirtual = threshold !== null &&
|
|
128
|
+
var itemTotalHeight = itemHeight * itemCount;
|
|
129
|
+
var isVirtual = threshold !== null &&
|
|
130
|
+
itemCount >= threshold &&
|
|
131
|
+
itemTotalHeight + ((_a = window.__TABLE_PADDING__) !== null && _a !== void 0 ? _a : 0) > viewportHeight;
|
|
131
132
|
var refList = (0, react_1.useRef)(null);
|
|
132
133
|
var refRafId = (0, react_1.useRef)(null);
|
|
133
134
|
var refLockScroll = (0, react_1.useRef)(false);
|
|
@@ -145,7 +146,7 @@ var VirtualList = react_1.default.forwardRef(function (props, ref) {
|
|
|
145
146
|
}
|
|
146
147
|
return { top: 0, bottom: 0 };
|
|
147
148
|
}, [refList.current]);
|
|
148
|
-
var
|
|
149
|
+
var _l = __read((0, useStateWithPromise_1.default)({
|
|
149
150
|
// measure status
|
|
150
151
|
status: 'NONE',
|
|
151
152
|
// render range info
|
|
@@ -156,7 +157,7 @@ var VirtualList = react_1.default.forwardRef(function (props, ref) {
|
|
|
156
157
|
// scroll info
|
|
157
158
|
startItemTop: 0,
|
|
158
159
|
scrollTop: 0,
|
|
159
|
-
}), 2), state =
|
|
160
|
+
}), 2), state = _l[0], setState = _l[1];
|
|
160
161
|
var prevData = (0, usePrevious_1.default)(data) || [];
|
|
161
162
|
var isFirstRender = (0, useIsFirstRender_1.default)();
|
|
162
163
|
var getItemKey = function (item, index) {
|
|
@@ -252,12 +253,13 @@ var VirtualList = react_1.default.forwardRef(function (props, ref) {
|
|
|
252
253
|
};
|
|
253
254
|
// Modify the state and recalculate the position in the next render
|
|
254
255
|
var virtualListScrollHandler = function (event, isInit) {
|
|
256
|
+
var _a;
|
|
255
257
|
if (isInit === void 0) { isInit = false; }
|
|
256
258
|
// Do NOT use refList.current.scrollHeight
|
|
257
259
|
// We should use Filler's height as total scroll height
|
|
258
260
|
// Filler's translate style may make refList.current.scrollHeight larger than Filler's height
|
|
259
|
-
var scrollHeight = itemTotalHeight;
|
|
260
|
-
var
|
|
261
|
+
var scrollHeight = itemTotalHeight + ((_a = window.__TABLE_PADDING__) !== null && _a !== void 0 ? _a : 0);
|
|
262
|
+
var _b = refList.current, rawScrollTop = _b.scrollTop, clientHeight = _b.clientHeight;
|
|
261
263
|
var scrollTop = (0, itemUtil_1.getValidScrollTop)(rawScrollTop, scrollHeight - clientHeight);
|
|
262
264
|
// Prevent jitter
|
|
263
265
|
if (!isInit && (scrollTop === state.scrollTop || refLockScroll.current)) {
|
|
@@ -268,7 +270,7 @@ var VirtualList = react_1.default.forwardRef(function (props, ref) {
|
|
|
268
270
|
clientHeight: clientHeight,
|
|
269
271
|
scrollHeight: scrollHeight,
|
|
270
272
|
});
|
|
271
|
-
var
|
|
273
|
+
var _c = (0, itemUtil_1.getRangeIndex)(scrollPtg, itemCount, itemCountVisible), itemIndex = _c.itemIndex, itemOffsetPtg = _c.itemOffsetPtg, startIndex = _c.startIndex, endIndex = _c.endIndex;
|
|
272
274
|
setState(__assign(__assign({}, state), { scrollTop: scrollTop, itemIndex: itemIndex, itemOffsetPtg: itemOffsetPtg, startIndex: startIndex, endIndex: endIndex, status: 'MEASURE_START' }));
|
|
273
275
|
event && (onScroll === null || onScroll === void 0 ? void 0 : onScroll(event, { index: itemIndex }));
|
|
274
276
|
};
|
|
@@ -288,6 +290,7 @@ var VirtualList = react_1.default.forwardRef(function (props, ref) {
|
|
|
288
290
|
}, [itemCountVisible]);
|
|
289
291
|
// Handle additions and deletions of list items or switching the virtual state
|
|
290
292
|
(0, react_1.useEffect)(function () {
|
|
293
|
+
var _a;
|
|
291
294
|
if (!refList.current)
|
|
292
295
|
return;
|
|
293
296
|
var changedItemIndex = null;
|
|
@@ -305,7 +308,7 @@ var VirtualList = react_1.default.forwardRef(function (props, ref) {
|
|
|
305
308
|
itemOffsetPtg: state.itemOffsetPtg,
|
|
306
309
|
scrollPtg: (0, itemUtil_1.getScrollPercentage)({
|
|
307
310
|
scrollTop: state.scrollTop,
|
|
308
|
-
scrollHeight: prevData.length * itemHeight + __TABLE_PADDING__,
|
|
311
|
+
scrollHeight: prevData.length * itemHeight + ((_a = window.__TABLE_PADDING__) !== null && _a !== void 0 ? _a : 0),
|
|
309
312
|
clientHeight: clientHeight,
|
|
310
313
|
}),
|
|
311
314
|
clientHeight: clientHeight,
|
|
@@ -502,7 +505,7 @@ var VirtualList = react_1.default.forwardRef(function (props, ref) {
|
|
|
502
505
|
}
|
|
503
506
|
}, getTargetDOMNode: function () { return refList.current; } },
|
|
504
507
|
react_1.default.createElement(WrapperTagName, __assign({ ref: refList, style: __assign(__assign({ overflowY: 'auto', overflowAnchor: 'none' }, style), { maxHeight: styleListMaxHeight }), className: className, onScroll: isVirtual ? virtualListScrollHandler : rawListScrollHandler }, restProps), isVirtual ? (react_1.default.createElement(react_1.default.Fragment, null,
|
|
505
|
-
react_1.default.createElement(Filler_1.default, { height: itemTotalHeight, outerStyle: outerStyle, innerStyle: innerStyle, offset: state.status === 'MEASURE_DONE' ? state.startItemTop : 0 },
|
|
508
|
+
react_1.default.createElement(Filler_1.default, { height: itemTotalHeight + ((_b = window.__TABLE_PADDING__) !== null && _b !== void 0 ? _b : 0), outerStyle: outerStyle, innerStyle: innerStyle, offset: state.status === 'MEASURE_DONE' ? state.startItemTop : 0 },
|
|
506
509
|
react_1.default.createElement(WrapperChildTagName, null, renderChildren(data.slice(state.startIndex, state.endIndex + 1), state.startIndex))),
|
|
507
510
|
renderLongestItem())) : needFiller ? (react_1.default.createElement(Filler_1.default, { height: viewportHeight, outerStyle: outerStyle, innerStyle: innerStyle },
|
|
508
511
|
react_1.default.createElement(WrapperChildTagName, null, renderChildren(data, 0)))) : (react_1.default.createElement(WrapperChildTagName, null, renderChildren(data, 0))))));
|
|
@@ -13,12 +13,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
13
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
|
-
var _a;
|
|
17
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
17
|
exports.getLongestItemIndex = exports.getCompareItemRelativeTop = exports.getItemAbsoluteTop = exports.getItemRelativeTop = exports.getRangeIndex = exports.getScrollPercentage = exports.getValidScrollTop = exports.getNodeHeight = exports.getLocationItem = exports.GHOST_ITEM_KEY = void 0;
|
|
19
18
|
var react_dom_1 = require("../../../_util/react-dom");
|
|
20
19
|
var getStringLength_1 = __importDefault(require("../../../_util/getStringLength"));
|
|
21
|
-
var __TABLE_PADDING__ = (_a = window.__TABLE_PADDING__) !== null && _a !== void 0 ? _a : 0;
|
|
22
20
|
/**
|
|
23
21
|
* 为了计算方便,定位元素的下标可能返回数组长度,代表最后一个元素
|
|
24
22
|
*/
|
|
@@ -65,11 +63,12 @@ exports.getValidScrollTop = getValidScrollTop;
|
|
|
65
63
|
* 视口已滚动距离 / 总可滚动距离
|
|
66
64
|
*/
|
|
67
65
|
function getScrollPercentage(_a) {
|
|
66
|
+
var _b, _c;
|
|
68
67
|
var scrollTop = _a.scrollTop, scrollHeight = _a.scrollHeight, clientHeight = _a.clientHeight;
|
|
69
|
-
var scrollRange = scrollHeight - clientHeight - __TABLE_PADDING__;
|
|
68
|
+
var scrollRange = scrollHeight - clientHeight - ((_b = window.__TABLE_PADDING__) !== null && _b !== void 0 ? _b : 0);
|
|
70
69
|
return scrollRange <= 0
|
|
71
70
|
? 0
|
|
72
|
-
: getValidScrollTop(Math.max(scrollTop - __TABLE_PADDING__, 0), scrollRange) / scrollRange;
|
|
71
|
+
: getValidScrollTop(Math.max(scrollTop - ((_c = window.__TABLE_PADDING__) !== null && _c !== void 0 ? _c : 0), 0), scrollRange) / scrollRange;
|
|
73
72
|
}
|
|
74
73
|
exports.getScrollPercentage = getScrollPercentage;
|
|
75
74
|
/**
|
|
@@ -91,16 +90,19 @@ exports.getRangeIndex = getRangeIndex;
|
|
|
91
90
|
* 计算元素相对于视口顶部的偏移量
|
|
92
91
|
*/
|
|
93
92
|
function getItemRelativeTop(_a) {
|
|
93
|
+
var _b;
|
|
94
94
|
var itemHeight = _a.itemHeight, itemOffsetPtg = _a.itemOffsetPtg, scrollPtg = _a.scrollPtg, clientHeight = _a.clientHeight;
|
|
95
|
-
return Math.floor((clientHeight + __TABLE_PADDING__)
|
|
95
|
+
return Math.floor((clientHeight + ((_b = window.__TABLE_PADDING__) !== null && _b !== void 0 ? _b : 0)) * scrollPtg -
|
|
96
|
+
itemHeight * itemOffsetPtg);
|
|
96
97
|
}
|
|
97
98
|
exports.getItemRelativeTop = getItemRelativeTop;
|
|
98
99
|
/**
|
|
99
100
|
* 计算元素相对于整个滚动区域顶部的偏移量
|
|
100
101
|
*/
|
|
101
102
|
function getItemAbsoluteTop(_a) {
|
|
103
|
+
var _b;
|
|
102
104
|
var scrollTop = _a.scrollTop, rest = __rest(_a, ["scrollTop"]);
|
|
103
|
-
return Math.max(scrollTop - __TABLE_PADDING__, 0) + getItemRelativeTop(rest);
|
|
105
|
+
return (Math.max(scrollTop - ((_b = window.__TABLE_PADDING__) !== null && _b !== void 0 ? _b : 0), 0) + getItemRelativeTop(rest));
|
|
104
106
|
}
|
|
105
107
|
exports.getItemAbsoluteTop = getItemAbsoluteTop;
|
|
106
108
|
/**
|
package/lib/index.d.ts
CHANGED
|
@@ -139,4 +139,4 @@ export type { WatermarkProps } from './Watermark/interface';
|
|
|
139
139
|
export { default as Watermark } from './Watermark';
|
|
140
140
|
export type { ImageProps, ImagePreviewProps, ImagePreviewActionProps, ImagePreviewGroupProps } from './Image/interface';
|
|
141
141
|
export { default as Image } from './Image';
|
|
142
|
-
export declare const version = "1.1.
|
|
142
|
+
export declare const version = "1.1.2";
|
package/lib/index.js
CHANGED
|
@@ -147,4 +147,4 @@ var Watermark_1 = require("./Watermark");
|
|
|
147
147
|
Object.defineProperty(exports, "Watermark", { enumerable: true, get: function () { return __importDefault(Watermark_1).default; } });
|
|
148
148
|
var Image_1 = require("./Image");
|
|
149
149
|
Object.defineProperty(exports, "Image", { enumerable: true, get: function () { return __importDefault(Image_1).default; } });
|
|
150
|
-
exports.version = '1.1.
|
|
150
|
+
exports.version = '1.1.2';
|