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