@apdesign/web-react 1.0.3 → 1.1.1

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,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" | "submit" | "reset";
6
- } & import("./interface").BaseButtonProps & Omit<React.ButtonHTMLAttributes<any>, "className" | "type" | "onClick"> & {
5
+ htmlType?: "button" | "reset" | "submit";
6
+ } & import("./interface").BaseButtonProps & Omit<React.ButtonHTMLAttributes<any>, "className" | "onClick" | "type"> & {
7
7
  href: string;
8
8
  target?: string;
9
9
  anchorProps?: React.HTMLProps<HTMLAnchorElement>;
10
- } & Omit<React.AnchorHTMLAttributes<any>, "className" | "type" | "onClick">> & React.RefAttributes<unknown>> & {
10
+ } & Omit<React.AnchorHTMLAttributes<any>, "className" | "onClick" | "type">> & React.RefAttributes<unknown>> & {
11
11
  __BYTE_BUTTON: boolean;
12
12
  Group: typeof Group;
13
13
  };
@@ -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): 1 | 0 | 2;
3
+ export declare function getAvailableDayjsLength(value: any): 0 | 1 | 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, "mode" | "triggerProps" | "collapse" | "inDropdown" | "theme" | "levelIndent" | "icons" | "autoScrollIntoView" | "selectedKeys" | "openKeys" | "scrollConfig" | "tooltipProps"> & {
9
+ declare const MenuContext: import("react").Context<Pick<MenuProps, "collapse" | "inDropdown" | "theme" | "mode" | "levelIndent" | "icons" | "autoScrollIntoView" | "selectedKeys" | "openKeys" | "scrollConfig" | "triggerProps" | "tooltipProps"> & {
10
10
  id?: string;
11
11
  prefixCls?: string;
12
12
  onClickMenuItem?: (key: string, event: any) => void;
@@ -36,6 +36,7 @@ var __read = (this && this.__read) || function (o, n) {
36
36
  }
37
37
  return ar;
38
38
  };
39
+ var _a;
39
40
  import React, { useEffect, useImperativeHandle, useRef, useMemo, useState, } from 'react';
40
41
  import { getValidScrollTop, getCompareItemRelativeTop, getItemAbsoluteTop, getItemRelativeTop, getNodeHeight, getRangeIndex, getScrollPercentage, GHOST_ITEM_KEY, getLongestItemIndex, getLocationItem, } from './utils/itemUtil';
41
42
  import { raf, caf } from '../../_util/raf';
@@ -48,6 +49,7 @@ import useIsFirstRender from '../../_util/hooks/useIsFirstRender';
48
49
  import useForceUpdate from '../../_util/hooks/useForceUpdate';
49
50
  import ResizeObserver from '../../_util/resizeObserver';
50
51
  import useIsomorphicLayoutEffect from '../../_util/hooks/useIsomorphicLayoutEffect';
52
+ var __TABLE_PADDING__ = (_a = window.__TABLE_PADDING__) !== null && _a !== void 0 ? _a : 0;
51
53
  // height of the virtual element, used to calculate total height of the virtual list
52
54
  var DEFAULT_VIRTUAL_ITEM_HEIGHT = 32;
53
55
  var KEY_VIRTUAL_ITEM_HEIGHT = "__virtual_item_height_" + Math.random().toFixed(5).slice(2);
@@ -100,7 +102,7 @@ var VirtualList = React.forwardRef(function (props, ref) {
100
102
  DEFAULT_VIRTUAL_ITEM_HEIGHT;
101
103
  var viewportHeight = isNumber(styleListMaxHeight) ? styleListMaxHeight : stateHeight;
102
104
  var itemCountVisible = Math.ceil(viewportHeight / itemHeight);
103
- var itemTotalHeight = itemHeight * itemCount;
105
+ var itemTotalHeight = itemHeight * itemCount + __TABLE_PADDING__;
104
106
  var isVirtual = threshold !== null && itemCount >= threshold && itemTotalHeight > viewportHeight;
105
107
  var refList = useRef(null);
106
108
  var refRafId = useRef(null);
@@ -279,7 +281,7 @@ var VirtualList = React.forwardRef(function (props, ref) {
279
281
  itemOffsetPtg: state.itemOffsetPtg,
280
282
  scrollPtg: getScrollPercentage({
281
283
  scrollTop: state.scrollTop,
282
- scrollHeight: prevData.length * itemHeight,
284
+ scrollHeight: prevData.length * itemHeight + __TABLE_PADDING__,
283
285
  clientHeight: clientHeight,
284
286
  }),
285
287
  clientHeight: clientHeight,
@@ -9,8 +9,10 @@ var __rest = (this && this.__rest) || function (s, e) {
9
9
  }
10
10
  return t;
11
11
  };
12
+ var _a;
12
13
  import { findDOMNode } from '../../../_util/react-dom';
13
14
  import getStringLength from '../../../_util/getStringLength';
15
+ var __TABLE_PADDING__ = (_a = window.__TABLE_PADDING__) !== null && _a !== void 0 ? _a : 0;
14
16
  /**
15
17
  * 为了计算方便,定位元素的下标可能返回数组长度,代表最后一个元素
16
18
  */
@@ -55,8 +57,10 @@ export function getValidScrollTop(scrollTop, scrollRange) {
55
57
  */
56
58
  export function getScrollPercentage(_a) {
57
59
  var scrollTop = _a.scrollTop, scrollHeight = _a.scrollHeight, clientHeight = _a.clientHeight;
58
- var scrollRange = scrollHeight - clientHeight;
59
- return scrollRange <= 0 ? 0 : getValidScrollTop(scrollTop, scrollRange) / scrollRange;
60
+ var scrollRange = scrollHeight - clientHeight - __TABLE_PADDING__;
61
+ return scrollRange <= 0
62
+ ? 0
63
+ : getValidScrollTop(Math.max(scrollTop - __TABLE_PADDING__, 0), scrollRange) / scrollRange;
60
64
  }
61
65
  /**
62
66
  * 计算需要渲染的元素的开始下标、结束下标和用于定位的元素下标
@@ -77,14 +81,14 @@ export function getRangeIndex(scrollPtg, itemCount, visibleCount) {
77
81
  */
78
82
  export function getItemRelativeTop(_a) {
79
83
  var itemHeight = _a.itemHeight, itemOffsetPtg = _a.itemOffsetPtg, scrollPtg = _a.scrollPtg, clientHeight = _a.clientHeight;
80
- return Math.floor(clientHeight * scrollPtg - itemHeight * itemOffsetPtg);
84
+ return Math.floor((clientHeight + __TABLE_PADDING__) * scrollPtg - itemHeight * itemOffsetPtg);
81
85
  }
82
86
  /**
83
87
  * 计算元素相对于整个滚动区域顶部的偏移量
84
88
  */
85
89
  export function getItemAbsoluteTop(_a) {
86
90
  var scrollTop = _a.scrollTop, rest = __rest(_a, ["scrollTop"]);
87
- return scrollTop + getItemRelativeTop(rest);
91
+ return Math.max(scrollTop - __TABLE_PADDING__, 0) + getItemRelativeTop(rest);
88
92
  }
89
93
  /**
90
94
  * 计算某一指定下标的元素相对于视口顶部的偏移量
@@ -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" | "onFocus" | "onBlur" | "tabIndex" | "onContextMenu" | "onMouseEnter" | "onMouseLeave" | "onMouseMove">;
3
+ export declare function pickTriggerPropsFromRest(rest: any): Pick<any, "tabIndex" | "onFocus" | "onBlur" | "onClick" | "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.0.3";
142
+ export declare const version = "1.1.1";
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.0.3';
72
+ export var version = '1.1.1';
@@ -59,6 +59,7 @@ 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;
62
63
  Object.defineProperty(exports, "__esModule", { value: true });
63
64
  var react_1 = __importStar(require("react"));
64
65
  var itemUtil_1 = require("./utils/itemUtil");
@@ -72,6 +73,7 @@ var useIsFirstRender_1 = __importDefault(require("../../_util/hooks/useIsFirstRe
72
73
  var useForceUpdate_1 = __importDefault(require("../../_util/hooks/useForceUpdate"));
73
74
  var resizeObserver_1 = __importDefault(require("../../_util/resizeObserver"));
74
75
  var useIsomorphicLayoutEffect_1 = __importDefault(require("../../_util/hooks/useIsomorphicLayoutEffect"));
76
+ var __TABLE_PADDING__ = (_a = window.__TABLE_PADDING__) !== null && _a !== void 0 ? _a : 0;
75
77
  // height of the virtual element, used to calculate total height of the virtual list
76
78
  var DEFAULT_VIRTUAL_ITEM_HEIGHT = 32;
77
79
  var KEY_VIRTUAL_ITEM_HEIGHT = "__virtual_item_height_" + Math.random().toFixed(5).slice(2);
@@ -124,7 +126,7 @@ var VirtualList = react_1.default.forwardRef(function (props, ref) {
124
126
  DEFAULT_VIRTUAL_ITEM_HEIGHT;
125
127
  var viewportHeight = (0, is_1.isNumber)(styleListMaxHeight) ? styleListMaxHeight : stateHeight;
126
128
  var itemCountVisible = Math.ceil(viewportHeight / itemHeight);
127
- var itemTotalHeight = itemHeight * itemCount;
129
+ var itemTotalHeight = itemHeight * itemCount + __TABLE_PADDING__;
128
130
  var isVirtual = threshold !== null && itemCount >= threshold && itemTotalHeight > viewportHeight;
129
131
  var refList = (0, react_1.useRef)(null);
130
132
  var refRafId = (0, react_1.useRef)(null);
@@ -303,7 +305,7 @@ var VirtualList = react_1.default.forwardRef(function (props, ref) {
303
305
  itemOffsetPtg: state.itemOffsetPtg,
304
306
  scrollPtg: (0, itemUtil_1.getScrollPercentage)({
305
307
  scrollTop: state.scrollTop,
306
- scrollHeight: prevData.length * itemHeight,
308
+ scrollHeight: prevData.length * itemHeight + __TABLE_PADDING__,
307
309
  clientHeight: clientHeight,
308
310
  }),
309
311
  clientHeight: clientHeight,
@@ -13,10 +13,12 @@ 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;
16
17
  Object.defineProperty(exports, "__esModule", { value: true });
17
18
  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
19
  var react_dom_1 = require("../../../_util/react-dom");
19
20
  var getStringLength_1 = __importDefault(require("../../../_util/getStringLength"));
21
+ var __TABLE_PADDING__ = (_a = window.__TABLE_PADDING__) !== null && _a !== void 0 ? _a : 0;
20
22
  /**
21
23
  * 为了计算方便,定位元素的下标可能返回数组长度,代表最后一个元素
22
24
  */
@@ -64,8 +66,10 @@ exports.getValidScrollTop = getValidScrollTop;
64
66
  */
65
67
  function getScrollPercentage(_a) {
66
68
  var scrollTop = _a.scrollTop, scrollHeight = _a.scrollHeight, clientHeight = _a.clientHeight;
67
- var scrollRange = scrollHeight - clientHeight;
68
- return scrollRange <= 0 ? 0 : getValidScrollTop(scrollTop, scrollRange) / scrollRange;
69
+ var scrollRange = scrollHeight - clientHeight - __TABLE_PADDING__;
70
+ return scrollRange <= 0
71
+ ? 0
72
+ : getValidScrollTop(Math.max(scrollTop - __TABLE_PADDING__, 0), scrollRange) / scrollRange;
69
73
  }
70
74
  exports.getScrollPercentage = getScrollPercentage;
71
75
  /**
@@ -88,7 +92,7 @@ exports.getRangeIndex = getRangeIndex;
88
92
  */
89
93
  function getItemRelativeTop(_a) {
90
94
  var itemHeight = _a.itemHeight, itemOffsetPtg = _a.itemOffsetPtg, scrollPtg = _a.scrollPtg, clientHeight = _a.clientHeight;
91
- return Math.floor(clientHeight * scrollPtg - itemHeight * itemOffsetPtg);
95
+ return Math.floor((clientHeight + __TABLE_PADDING__) * scrollPtg - itemHeight * itemOffsetPtg);
92
96
  }
93
97
  exports.getItemRelativeTop = getItemRelativeTop;
94
98
  /**
@@ -96,7 +100,7 @@ exports.getItemRelativeTop = getItemRelativeTop;
96
100
  */
97
101
  function getItemAbsoluteTop(_a) {
98
102
  var scrollTop = _a.scrollTop, rest = __rest(_a, ["scrollTop"]);
99
- return scrollTop + getItemRelativeTop(rest);
103
+ return Math.max(scrollTop - __TABLE_PADDING__, 0) + getItemRelativeTop(rest);
100
104
  }
101
105
  exports.getItemAbsoluteTop = getItemAbsoluteTop;
102
106
  /**
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.0.3";
142
+ export declare const version = "1.1.1";
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.0.3';
150
+ exports.version = '1.1.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apdesign/web-react",
3
- "version": "1.0.3",
3
+ "version": "1.1.1",
4
4
  "description": "AP Design React UI Library.",
5
5
  "module": "./es/index.js",
6
6
  "main": "./lib/index.js",