@qsxy/element-plus-react 1.0.0-next.5 → 1.0.0-next.8

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.
Files changed (119) hide show
  1. package/dist/Avatar/Avatar.d.ts +4 -0
  2. package/dist/Avatar/Avatar.js +86 -0
  3. package/dist/Avatar/index.d.ts +2 -0
  4. package/dist/{VirtualList → Avatar}/index.js +7 -7
  5. package/dist/Avatar/typings.d.ts +21 -0
  6. package/dist/{VirtualList/interface.js → Avatar/typings.js} +3 -3
  7. package/dist/Cascader/Cascader.js +147 -182
  8. package/dist/Cascader/CascaderContext.d.ts +4 -10
  9. package/dist/Cascader/CascaderContext.js +2 -6
  10. package/dist/Cascader/CascaderDropdown.js +1 -1
  11. package/dist/Cascader/CascaderMenu.d.ts +0 -7
  12. package/dist/Cascader/CascaderMenu.js +4 -77
  13. package/dist/Cascader/Utils.d.ts +0 -2
  14. package/dist/Cascader/Utils.js +0 -44
  15. package/dist/Cascader/index.d.ts +1 -1
  16. package/dist/Cascader/typings.d.ts +2 -18
  17. package/dist/Cascader/useCascader.d.ts +1 -15
  18. package/dist/Cascader/useCascader.js +14 -41
  19. package/dist/DatePicker/DatePicker.js +5 -5
  20. package/dist/Empty/ImgEmpty.js +1 -1
  21. package/dist/Loading/Loading.js +14 -4
  22. package/dist/Tree/DirectoryTree.d.ts +6 -13
  23. package/dist/Tree/DirectoryTree.js +32 -81
  24. package/dist/Tree/DropIndicator.d.ts +4 -2
  25. package/dist/Tree/DropIndicator.js +7 -2
  26. package/dist/Tree/Indent.d.ts +2 -2
  27. package/dist/Tree/Indent.js +4 -4
  28. package/dist/Tree/MotionTreeNode.d.ts +4 -5
  29. package/dist/Tree/MotionTreeNode.js +69 -52
  30. package/dist/Tree/NodeList.d.ts +15 -11
  31. package/dist/Tree/NodeList.js +38 -29
  32. package/dist/Tree/RCTree.d.ts +77 -75
  33. package/dist/Tree/RCTree.js +199 -188
  34. package/dist/Tree/Tree.d.ts +3 -3
  35. package/dist/Tree/Tree.js +27 -27
  36. package/dist/Tree/TreeNode.d.ts +5 -90
  37. package/dist/Tree/TreeNode.js +320 -422
  38. package/dist/Tree/contextTypes.d.ts +36 -30
  39. package/dist/Tree/contextTypes.js +17 -4
  40. package/dist/Tree/index.d.ts +2 -2
  41. package/dist/Tree/typings.d.ts +60 -19
  42. package/dist/Tree/typings.js +1 -13
  43. package/dist/Tree/typings.tsx--bak +245 -0
  44. package/dist/Tree/useUnmount.d.ts +5 -0
  45. package/dist/{VirtualList/hooks/useChildren.js → Tree/useUnmount.js} +24 -16
  46. package/dist/Tree/util.d.ts +17 -21
  47. package/dist/Tree/util.js +21 -52
  48. package/dist/Tree/utils/conductUtil.d.ts +2 -2
  49. package/dist/Tree/utils/conductUtil.js +14 -3
  50. package/dist/Tree/utils/dictUtil.d.ts +7 -3
  51. package/dist/Tree/utils/dictUtil.js +49 -32
  52. package/dist/Tree/utils/diffUtil.d.ts +4 -3
  53. package/dist/Tree/utils/keyUtil.d.ts +2 -0
  54. package/dist/{VirtualList/utils/isFirefox.js → Tree/utils/keyUtil.js} +8 -7
  55. package/dist/Tree/utils/motion.js +6 -5
  56. package/dist/Tree/utils/treeUtil.d.ts +16 -18
  57. package/dist/Tree/utils/treeUtil.js +35 -14
  58. package/dist/TreeSelect/Utils.d.ts +1 -1
  59. package/dist/Util/base.d.ts +1 -1
  60. package/dist/Util/base.js +14 -2
  61. package/dist/hooks/useClassNames.d.ts +1 -0
  62. package/dist/hooks/useClassNames.js +11 -1
  63. package/dist/index.css +58 -6
  64. package/dist/index.d.ts +5 -5
  65. package/dist/index.js +3 -5
  66. package/dist/theme-chalk/avatar/index.scss +50 -0
  67. package/dist/theme-chalk/calendar/month-table.scss +1 -1
  68. package/dist/theme-chalk/index.scss +1 -0
  69. package/dist/theme-chalk/input/input.scss +5 -3
  70. package/dist/theme-chalk/loading/index.scss +5 -7
  71. package/package.json +2 -1
  72. package/dist/Tree/utils/KeyCode.d.ts +0 -436
  73. package/dist/Tree/utils/KeyCode.js +0 -550
  74. package/dist/VirtualList/Filler.d.ts +0 -16
  75. package/dist/VirtualList/Filler.js +0 -78
  76. package/dist/VirtualList/Item.d.ts +0 -7
  77. package/dist/VirtualList/Item.js +0 -37
  78. package/dist/VirtualList/ScrollBar.d.ts +0 -43
  79. package/dist/VirtualList/ScrollBar.js +0 -216
  80. package/dist/VirtualList/VirtualList.d.ts +0 -36
  81. package/dist/VirtualList/VirtualList.js +0 -280
  82. package/dist/VirtualList/hooks/useChildren.d.ts +0 -3
  83. package/dist/VirtualList/hooks/useDiffItem.d.ts +0 -2
  84. package/dist/VirtualList/hooks/useDiffItem.js +0 -39
  85. package/dist/VirtualList/hooks/useFrameWheel.d.ts +0 -6
  86. package/dist/VirtualList/hooks/useFrameWheel.js +0 -72
  87. package/dist/VirtualList/hooks/useHeights.d.ts +0 -3
  88. package/dist/VirtualList/hooks/useHeights.js +0 -83
  89. package/dist/VirtualList/hooks/useLayoutEffect.d.ts +0 -6
  90. package/dist/VirtualList/hooks/useLayoutEffect.js +0 -30
  91. package/dist/VirtualList/hooks/useMobileTouchMove.d.ts +0 -2
  92. package/dist/VirtualList/hooks/useMobileTouchMove.js +0 -92
  93. package/dist/VirtualList/hooks/useOriginScroll.d.ts +0 -2
  94. package/dist/VirtualList/hooks/useOriginScroll.js +0 -56
  95. package/dist/VirtualList/hooks/useScrollTo.d.ts +0 -5
  96. package/dist/VirtualList/hooks/useScrollTo.js +0 -111
  97. package/dist/VirtualList/index.d.ts +0 -2
  98. package/dist/VirtualList/interface.d.ts +0 -8
  99. package/dist/VirtualList/mock.d.ts +0 -6
  100. package/dist/VirtualList/mock.js +0 -29
  101. package/dist/VirtualList/utils/CacheMap.d.ts +0 -7
  102. package/dist/VirtualList/utils/CacheMap.js +0 -36
  103. package/dist/VirtualList/utils/algorithmUtil.d.ts +0 -23
  104. package/dist/VirtualList/utils/algorithmUtil.js +0 -81
  105. package/dist/VirtualList/utils/findDOMNode.d.ts +0 -5
  106. package/dist/VirtualList/utils/findDOMNode.js +0 -30
  107. package/dist/VirtualList/utils/isFirefox.d.ts +0 -2
  108. package/dist/VirtualList/utils/raf.d.ts +0 -5
  109. package/dist/VirtualList/utils/raf.js +0 -57
  110. package/dist/theme-chalk/bak/common/popup.scss +0 -47
  111. package/dist/theme-chalk/bak/common/transition.scss +0 -118
  112. package/dist/theme-chalk/bak/common/var.scss +0 -1476
  113. package/dist/theme-chalk/bak/mixins/_button.scss +0 -224
  114. package/dist/theme-chalk/bak/mixins/_col.scss +0 -38
  115. package/dist/theme-chalk/bak/mixins/_var.scss +0 -55
  116. package/dist/theme-chalk/bak/mixins/config.scss +0 -5
  117. package/dist/theme-chalk/bak/mixins/function.scss +0 -85
  118. package/dist/theme-chalk/bak/mixins/mixins.scss +0 -215
  119. package/dist/theme-chalk/bak/mixins/utils.scss +0 -39
@@ -1,83 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/VirtualList/hooks/useHeights.tsx
30
- var useHeights_exports = {};
31
- __export(useHeights_exports, {
32
- default: () => useHeights
33
- });
34
- module.exports = __toCommonJS(useHeights_exports);
35
- var import_react = require("react");
36
- var import_CacheMap = __toESM(require("../utils/CacheMap"));
37
- var import_findDOMNode = __toESM(require("../utils/findDOMNode"));
38
- var import_raf = __toESM(require("../utils/raf"));
39
- function useHeights(getKey, onItemAdd, onItemRemove) {
40
- const [updatedMark, setUpdatedMark] = (0, import_react.useState)(0);
41
- const instanceRef = (0, import_react.useRef)(/* @__PURE__ */ new Map());
42
- const heightsRef = (0, import_react.useRef)(new import_CacheMap.default());
43
- const collectRafRef = (0, import_react.useRef)();
44
- function cancelRaf() {
45
- import_raf.default.cancel(collectRafRef.current);
46
- }
47
- function collectHeight() {
48
- cancelRaf();
49
- collectRafRef.current = (0, import_raf.default)(() => {
50
- instanceRef.current.forEach((element, key) => {
51
- if (element && element.offsetParent) {
52
- const htmlElement = (0, import_findDOMNode.default)(element);
53
- const { offsetHeight } = htmlElement;
54
- if (heightsRef.current.get(key) !== offsetHeight) {
55
- heightsRef.current.set(key, htmlElement.offsetHeight);
56
- }
57
- }
58
- });
59
- setUpdatedMark((c) => c + 1);
60
- });
61
- }
62
- function setInstanceRef(item, instance) {
63
- const key = getKey(item);
64
- const origin = instanceRef.current.get(key);
65
- if (instance) {
66
- instanceRef.current.set(key, instance);
67
- collectHeight();
68
- } else {
69
- instanceRef.current.delete(key);
70
- }
71
- if (!origin !== !instance) {
72
- if (instance) {
73
- onItemAdd == null ? void 0 : onItemAdd(item);
74
- } else {
75
- onItemRemove == null ? void 0 : onItemRemove(item);
76
- }
77
- }
78
- }
79
- (0, import_react.useEffect)(() => {
80
- return cancelRaf;
81
- }, []);
82
- return [setInstanceRef, collectHeight, heightsRef.current, updatedMark];
83
- }
@@ -1,6 +0,0 @@
1
- import { useEffect } from 'react';
2
- /**
3
- * Wrap `useLayoutEffect` which will not throw warning message in test env
4
- */
5
- declare const useLayoutEffect: typeof useEffect;
6
- export default useLayoutEffect;
@@ -1,30 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/VirtualList/hooks/useLayoutEffect.ts
20
- var useLayoutEffect_exports = {};
21
- __export(useLayoutEffect_exports, {
22
- default: () => useLayoutEffect_default
23
- });
24
- module.exports = __toCommonJS(useLayoutEffect_exports);
25
- var import_react = require("react");
26
- function canUseDom() {
27
- return !!(typeof window !== "undefined" && window.document && window.document.createElement);
28
- }
29
- var useLayoutEffect = canUseDom() ? import_react.useLayoutEffect : import_react.useEffect;
30
- var useLayoutEffect_default = useLayoutEffect;
@@ -1,2 +0,0 @@
1
- import { RefObject } from 'react';
2
- export default function useMobileTouchMove(inVirtual: boolean, listRef: RefObject<HTMLDivElement>, callback: (offsetY: number, smoothOffset?: boolean) => boolean): void;
@@ -1,92 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/VirtualList/hooks/useMobileTouchMove.ts
30
- var useMobileTouchMove_exports = {};
31
- __export(useMobileTouchMove_exports, {
32
- default: () => useMobileTouchMove
33
- });
34
- module.exports = __toCommonJS(useMobileTouchMove_exports);
35
- var import_react = require("react");
36
- var import_useLayoutEffect = __toESM(require("./useLayoutEffect"));
37
- var SMOOTH_PTG = 14 / 15;
38
- function useMobileTouchMove(inVirtual, listRef, callback) {
39
- const touchedRef = (0, import_react.useRef)(false);
40
- const touchYRef = (0, import_react.useRef)(0);
41
- const elementRef = (0, import_react.useRef)(null);
42
- const intervalRef = (0, import_react.useRef)(null);
43
- let cleanUpEvents;
44
- const onTouchMove = (e) => {
45
- if (touchedRef.current) {
46
- const currentY = Math.ceil(e.touches[0].pageY);
47
- let offsetY = touchYRef.current - currentY;
48
- touchYRef.current = currentY;
49
- if (callback(offsetY)) {
50
- e.preventDefault();
51
- }
52
- clearInterval(intervalRef.current);
53
- intervalRef.current = setInterval(() => {
54
- offsetY *= SMOOTH_PTG;
55
- if (!callback(offsetY, true) || Math.abs(offsetY) <= 0.1) {
56
- clearInterval(intervalRef.current);
57
- }
58
- }, 16);
59
- }
60
- };
61
- const onTouchEnd = () => {
62
- touchedRef.current = false;
63
- cleanUpEvents();
64
- };
65
- const onTouchStart = (e) => {
66
- cleanUpEvents();
67
- if (e.touches.length === 1 && !touchedRef.current) {
68
- touchedRef.current = true;
69
- touchYRef.current = Math.ceil(e.touches[0].pageY);
70
- elementRef.current = e.target;
71
- elementRef.current.addEventListener("touchmove", onTouchMove);
72
- elementRef.current.addEventListener("touchend", onTouchEnd);
73
- }
74
- };
75
- cleanUpEvents = () => {
76
- if (elementRef.current) {
77
- elementRef.current.removeEventListener("touchmove", onTouchMove);
78
- elementRef.current.removeEventListener("touchend", onTouchEnd);
79
- }
80
- };
81
- (0, import_useLayoutEffect.default)(() => {
82
- if (inVirtual) {
83
- listRef.current.addEventListener("touchstart", onTouchStart);
84
- }
85
- return () => {
86
- var _a;
87
- (_a = listRef.current) == null ? void 0 : _a.removeEventListener("touchstart", onTouchStart);
88
- cleanUpEvents();
89
- clearInterval(intervalRef.current);
90
- };
91
- }, [inVirtual]);
92
- }
@@ -1,2 +0,0 @@
1
- declare const _default: (isScrollAtTop: boolean, isScrollAtBottom: boolean) => (deltaY: number, smoothOffset?: boolean) => boolean;
2
- export default _default;
@@ -1,56 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/VirtualList/hooks/useOriginScroll.ts
20
- var useOriginScroll_exports = {};
21
- __export(useOriginScroll_exports, {
22
- default: () => useOriginScroll_default
23
- });
24
- module.exports = __toCommonJS(useOriginScroll_exports);
25
- var import_react = require("react");
26
- var useOriginScroll_default = (isScrollAtTop, isScrollAtBottom) => {
27
- const lockRef = (0, import_react.useRef)(false);
28
- const lockTimeoutRef = (0, import_react.useRef)(null);
29
- function lockScroll() {
30
- clearTimeout(lockTimeoutRef.current);
31
- lockRef.current = true;
32
- lockTimeoutRef.current = setTimeout(() => {
33
- lockRef.current = false;
34
- }, 50);
35
- }
36
- const scrollPingRef = (0, import_react.useRef)({
37
- top: isScrollAtTop,
38
- bottom: isScrollAtBottom
39
- });
40
- scrollPingRef.current.top = isScrollAtTop;
41
- scrollPingRef.current.bottom = isScrollAtBottom;
42
- return (deltaY, smoothOffset = false) => {
43
- const originScroll = (
44
- // Pass origin wheel when on the top
45
- deltaY < 0 && scrollPingRef.current.top || // Pass origin wheel when on the bottom
46
- deltaY > 0 && scrollPingRef.current.bottom
47
- );
48
- if (smoothOffset && originScroll) {
49
- clearTimeout(lockTimeoutRef.current);
50
- lockRef.current = false;
51
- } else if (!originScroll || lockRef.current) {
52
- lockScroll();
53
- }
54
- return !lockRef.current && originScroll;
55
- };
56
- };
@@ -1,5 +0,0 @@
1
- import { RefObject } from 'react';
2
- import type { ScrollTo } from '../VirtualList';
3
- import type { GetKey } from '../interface';
4
- import type CacheMap from '../utils/CacheMap';
5
- export default function useScrollTo<T>(containerRef: RefObject<HTMLDivElement>, data: T[], heights: CacheMap, itemHeight: number, getKey: GetKey<T>, collectHeight: () => void, syncScrollTop: (newTop: number) => void, triggerFlash: () => void): ScrollTo;
@@ -1,111 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/VirtualList/hooks/useScrollTo.tsx
30
- var useScrollTo_exports = {};
31
- __export(useScrollTo_exports, {
32
- default: () => useScrollTo
33
- });
34
- module.exports = __toCommonJS(useScrollTo_exports);
35
- var import_react = require("react");
36
- var import_raf = __toESM(require("../utils/raf"));
37
- function useScrollTo(containerRef, data, heights, itemHeight, getKey, collectHeight, syncScrollTop, triggerFlash) {
38
- const scrollRef = (0, import_react.useRef)();
39
- return (arg) => {
40
- if (arg === null || arg === void 0) {
41
- triggerFlash();
42
- return;
43
- }
44
- import_raf.default.cancel(scrollRef.current);
45
- if (typeof arg === "number") {
46
- syncScrollTop(arg);
47
- } else if (arg && typeof arg === "object") {
48
- let index;
49
- const { align } = arg;
50
- if ("index" in arg) {
51
- ({ index } = arg);
52
- } else {
53
- index = data.findIndex((item) => getKey(item) === arg.key);
54
- }
55
- const { offset = 0 } = arg;
56
- const syncScroll = (times, targetAlign) => {
57
- if (times < 0 || !containerRef.current) {
58
- return;
59
- }
60
- const height = containerRef.current.clientHeight;
61
- let needCollectHeight = false;
62
- let newTargetAlign = targetAlign;
63
- if (height) {
64
- const mergedAlign = targetAlign || align;
65
- let stackTop = 0;
66
- let itemTop = 0;
67
- let itemBottom = 0;
68
- const maxLen = Math.min(data.length, index);
69
- for (let i = 0; i <= maxLen; i += 1) {
70
- const key = getKey(data[i]);
71
- itemTop = stackTop;
72
- const cacheHeight = heights.get(key);
73
- itemBottom = itemTop + (cacheHeight === void 0 ? itemHeight : cacheHeight);
74
- stackTop = itemBottom;
75
- if (i === index && cacheHeight === void 0) {
76
- needCollectHeight = true;
77
- }
78
- }
79
- let targetTop = null;
80
- switch (mergedAlign) {
81
- case "top":
82
- targetTop = itemTop - offset;
83
- break;
84
- case "bottom":
85
- targetTop = itemBottom - height + offset;
86
- break;
87
- default: {
88
- const { scrollTop } = containerRef.current;
89
- const scrollBottom = scrollTop + height;
90
- if (itemTop < scrollTop) {
91
- newTargetAlign = "top";
92
- } else if (itemBottom > scrollBottom) {
93
- newTargetAlign = "bottom";
94
- }
95
- }
96
- }
97
- if (targetTop !== null && targetTop !== containerRef.current.scrollTop) {
98
- syncScrollTop(targetTop);
99
- }
100
- }
101
- scrollRef.current = (0, import_raf.default)(() => {
102
- if (needCollectHeight) {
103
- collectHeight();
104
- }
105
- syncScroll(times - 1, newTargetAlign);
106
- });
107
- };
108
- syncScroll(3);
109
- }
110
- };
111
- }
@@ -1,2 +0,0 @@
1
- export { default as VirtualList } from './VirtualList';
2
- export type { ListProps, ListRef, ScrollTo } from './VirtualList';
@@ -1,8 +0,0 @@
1
- import React, { Key } from 'react';
2
- export type RenderFunc<T> = (item: T, index: number, props: {
3
- style?: React.CSSProperties;
4
- }) => React.ReactElement;
5
- export interface SharedConfig<T> {
6
- getKey: (item: T) => Key;
7
- }
8
- export type GetKey<T> = (item: T) => Key;
@@ -1,6 +0,0 @@
1
- import React, { Ref } from 'react';
2
- import { ListProps, ListRef } from './VirtualList';
3
- declare const List: <Item = any>(props: ListProps<Item> & {
4
- ref?: Ref<ListRef>;
5
- }) => React.ReactElement;
6
- export default List;
@@ -1,29 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/VirtualList/mock.tsx
20
- var mock_exports = {};
21
- __export(mock_exports, {
22
- default: () => mock_default
23
- });
24
- module.exports = __toCommonJS(mock_exports);
25
- var import_react = require("react");
26
- var import_VirtualList = require("./VirtualList");
27
- var List = (0, import_react.forwardRef)((props, ref) => (0, import_VirtualList.RawList)({ ...props, virtual: false }, ref));
28
- List.displayName = "List";
29
- var mock_default = List;
@@ -1,7 +0,0 @@
1
- declare class CacheMap {
2
- maps: Record<string, number>;
3
- constructor();
4
- set(key: string | number, value: number): void;
5
- get(key: string | number): number;
6
- }
7
- export default CacheMap;
@@ -1,36 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/VirtualList/utils/CacheMap.ts
20
- var CacheMap_exports = {};
21
- __export(CacheMap_exports, {
22
- default: () => CacheMap_default
23
- });
24
- module.exports = __toCommonJS(CacheMap_exports);
25
- var CacheMap = class {
26
- constructor() {
27
- this.maps = /* @__PURE__ */ Object.create(null);
28
- }
29
- set(key, value) {
30
- this.maps[key] = value;
31
- }
32
- get(key) {
33
- return this.maps[key];
34
- }
35
- };
36
- var CacheMap_default = CacheMap;
@@ -1,23 +0,0 @@
1
- import { Key } from 'react';
2
- /**
3
- * Get index with specific start index one by one. e.g.
4
- * min: 3, max: 9, start: 6
5
- *
6
- * Return index is:
7
- * [0]: 6
8
- * [1]: 7
9
- * [2]: 5
10
- * [3]: 8
11
- * [4]: 4
12
- * [5]: 9
13
- * [6]: 3
14
- */
15
- export declare function getIndexByStartLoc(min: number, max: number, start: number, index: number): number;
16
- /**
17
- * We assume that 2 list has only 1 item diff and others keeping the order.
18
- * So we can use dichotomy algorithm to find changed one.
19
- */
20
- export declare function findListDiffIndex<T>(originList: T[], targetList: T[], getKey: (item: T) => Key): {
21
- index: number;
22
- multiple: boolean;
23
- } | null;
@@ -1,81 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/VirtualList/utils/algorithmUtil.ts
20
- var algorithmUtil_exports = {};
21
- __export(algorithmUtil_exports, {
22
- findListDiffIndex: () => findListDiffIndex,
23
- getIndexByStartLoc: () => getIndexByStartLoc
24
- });
25
- module.exports = __toCommonJS(algorithmUtil_exports);
26
- function getIndexByStartLoc(min, max, start, index) {
27
- const beforeCount = start - min;
28
- const afterCount = max - start;
29
- const balanceCount = Math.min(beforeCount, afterCount) * 2;
30
- if (index <= balanceCount) {
31
- const stepIndex = Math.floor(index / 2);
32
- if (index % 2) {
33
- return start + stepIndex + 1;
34
- }
35
- return start - stepIndex;
36
- }
37
- if (beforeCount > afterCount) {
38
- return start - (index - afterCount);
39
- }
40
- return start + (index - beforeCount);
41
- }
42
- function findListDiffIndex(originList, targetList, getKey) {
43
- const originLen = originList.length;
44
- const targetLen = targetList.length;
45
- let shortList;
46
- let longList;
47
- if (originLen === 0 && targetLen === 0) {
48
- return null;
49
- }
50
- if (originLen < targetLen) {
51
- shortList = originList;
52
- longList = targetList;
53
- } else {
54
- shortList = targetList;
55
- longList = originList;
56
- }
57
- const notExistKey = { __EMPTY_ITEM__: true };
58
- function getItemKey(item) {
59
- if (item !== void 0) {
60
- return getKey(item);
61
- }
62
- return notExistKey;
63
- }
64
- let diffIndex = null;
65
- let multiple = Math.abs(originLen - targetLen) !== 1;
66
- for (let i = 0; i < longList.length; i += 1) {
67
- const shortKey = getItemKey(shortList[i]);
68
- const longKey = getItemKey(longList[i]);
69
- if (shortKey !== longKey) {
70
- diffIndex = i;
71
- multiple = multiple || shortKey !== getItemKey(longList[i + 1]);
72
- break;
73
- }
74
- }
75
- return diffIndex === null ? null : { index: diffIndex, multiple };
76
- }
77
- // Annotate the CommonJS export names for ESM import in node:
78
- 0 && (module.exports = {
79
- findListDiffIndex,
80
- getIndexByStartLoc
81
- });
@@ -1,5 +0,0 @@
1
- import React from 'react';
2
- /**
3
- * Return if a node is a DOM node. Else will return by `findDOMNode`
4
- */
5
- export default function findDOMNode<T = Element | Text>(node: React.ReactElement | HTMLElement): T;
@@ -1,30 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/VirtualList/utils/findDOMNode.ts
20
- var findDOMNode_exports = {};
21
- __export(findDOMNode_exports, {
22
- default: () => findDOMNode
23
- });
24
- module.exports = __toCommonJS(findDOMNode_exports);
25
- function findDOMNode(node) {
26
- if (node instanceof HTMLElement) {
27
- return node;
28
- }
29
- return ReactDOM.findDOMNode(node);
30
- }
@@ -1,2 +0,0 @@
1
- declare const isFF: boolean;
2
- export default isFF;
@@ -1,5 +0,0 @@
1
- declare function wrapperRaf(callback: () => void, times?: number): number;
2
- declare namespace wrapperRaf {
3
- var cancel: (id: number) => void;
4
- }
5
- export default wrapperRaf;