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

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 (109) hide show
  1. package/dist/Cascader/Cascader.js +147 -182
  2. package/dist/Cascader/CascaderContext.d.ts +4 -10
  3. package/dist/Cascader/CascaderContext.js +2 -6
  4. package/dist/Cascader/CascaderDropdown.js +1 -1
  5. package/dist/Cascader/CascaderMenu.d.ts +0 -7
  6. package/dist/Cascader/CascaderMenu.js +4 -77
  7. package/dist/Cascader/Utils.d.ts +0 -2
  8. package/dist/Cascader/Utils.js +0 -44
  9. package/dist/Cascader/index.d.ts +1 -1
  10. package/dist/Cascader/typings.d.ts +2 -18
  11. package/dist/Cascader/useCascader.d.ts +1 -15
  12. package/dist/Cascader/useCascader.js +14 -41
  13. package/dist/DatePicker/DatePicker.js +5 -5
  14. package/dist/Empty/ImgEmpty.js +1 -1
  15. package/dist/Tree/DirectoryTree.d.ts +6 -13
  16. package/dist/Tree/DirectoryTree.js +32 -81
  17. package/dist/Tree/DropIndicator.d.ts +4 -2
  18. package/dist/Tree/DropIndicator.js +7 -2
  19. package/dist/Tree/Indent.d.ts +2 -2
  20. package/dist/Tree/Indent.js +4 -4
  21. package/dist/Tree/MotionTreeNode.d.ts +4 -5
  22. package/dist/Tree/MotionTreeNode.js +69 -52
  23. package/dist/Tree/NodeList.d.ts +15 -11
  24. package/dist/Tree/NodeList.js +38 -29
  25. package/dist/Tree/RCTree.d.ts +77 -75
  26. package/dist/Tree/RCTree.js +199 -188
  27. package/dist/Tree/Tree.d.ts +3 -3
  28. package/dist/Tree/Tree.js +27 -27
  29. package/dist/Tree/TreeNode.d.ts +5 -90
  30. package/dist/Tree/TreeNode.js +320 -422
  31. package/dist/Tree/contextTypes.d.ts +36 -30
  32. package/dist/Tree/contextTypes.js +17 -4
  33. package/dist/Tree/index.d.ts +2 -2
  34. package/dist/Tree/typings.d.ts +60 -19
  35. package/dist/Tree/typings.js +1 -13
  36. package/dist/Tree/typings.tsx--bak +245 -0
  37. package/dist/Tree/useUnmount.d.ts +5 -0
  38. package/dist/{VirtualList/index.js → Tree/useUnmount.js} +25 -10
  39. package/dist/Tree/util.d.ts +17 -21
  40. package/dist/Tree/util.js +21 -52
  41. package/dist/Tree/utils/conductUtil.d.ts +2 -2
  42. package/dist/Tree/utils/conductUtil.js +14 -3
  43. package/dist/Tree/utils/dictUtil.d.ts +7 -3
  44. package/dist/Tree/utils/dictUtil.js +49 -32
  45. package/dist/Tree/utils/diffUtil.d.ts +4 -3
  46. package/dist/Tree/utils/keyUtil.d.ts +2 -0
  47. package/dist/{VirtualList/utils/isFirefox.js → Tree/utils/keyUtil.js} +8 -7
  48. package/dist/Tree/utils/motion.js +6 -5
  49. package/dist/Tree/utils/treeUtil.d.ts +16 -18
  50. package/dist/Tree/utils/treeUtil.js +35 -14
  51. package/dist/TreeSelect/Utils.d.ts +1 -1
  52. package/dist/Util/base.d.ts +1 -1
  53. package/dist/Util/base.js +14 -2
  54. package/dist/index.css +6 -4
  55. package/dist/index.d.ts +3 -5
  56. package/dist/index.js +0 -5
  57. package/dist/theme-chalk/calendar/month-table.scss +1 -1
  58. package/dist/theme-chalk/input/input.scss +5 -3
  59. package/package.json +2 -1
  60. package/dist/Tree/utils/KeyCode.d.ts +0 -436
  61. package/dist/Tree/utils/KeyCode.js +0 -550
  62. package/dist/VirtualList/Filler.d.ts +0 -16
  63. package/dist/VirtualList/Filler.js +0 -78
  64. package/dist/VirtualList/Item.d.ts +0 -7
  65. package/dist/VirtualList/Item.js +0 -37
  66. package/dist/VirtualList/ScrollBar.d.ts +0 -43
  67. package/dist/VirtualList/ScrollBar.js +0 -216
  68. package/dist/VirtualList/VirtualList.d.ts +0 -36
  69. package/dist/VirtualList/VirtualList.js +0 -280
  70. package/dist/VirtualList/hooks/useChildren.d.ts +0 -3
  71. package/dist/VirtualList/hooks/useChildren.js +0 -46
  72. package/dist/VirtualList/hooks/useDiffItem.d.ts +0 -2
  73. package/dist/VirtualList/hooks/useDiffItem.js +0 -39
  74. package/dist/VirtualList/hooks/useFrameWheel.d.ts +0 -6
  75. package/dist/VirtualList/hooks/useFrameWheel.js +0 -72
  76. package/dist/VirtualList/hooks/useHeights.d.ts +0 -3
  77. package/dist/VirtualList/hooks/useHeights.js +0 -83
  78. package/dist/VirtualList/hooks/useLayoutEffect.d.ts +0 -6
  79. package/dist/VirtualList/hooks/useLayoutEffect.js +0 -30
  80. package/dist/VirtualList/hooks/useMobileTouchMove.d.ts +0 -2
  81. package/dist/VirtualList/hooks/useMobileTouchMove.js +0 -92
  82. package/dist/VirtualList/hooks/useOriginScroll.d.ts +0 -2
  83. package/dist/VirtualList/hooks/useOriginScroll.js +0 -56
  84. package/dist/VirtualList/hooks/useScrollTo.d.ts +0 -5
  85. package/dist/VirtualList/hooks/useScrollTo.js +0 -111
  86. package/dist/VirtualList/index.d.ts +0 -2
  87. package/dist/VirtualList/interface.d.ts +0 -8
  88. package/dist/VirtualList/interface.js +0 -17
  89. package/dist/VirtualList/mock.d.ts +0 -6
  90. package/dist/VirtualList/mock.js +0 -29
  91. package/dist/VirtualList/utils/CacheMap.d.ts +0 -7
  92. package/dist/VirtualList/utils/CacheMap.js +0 -36
  93. package/dist/VirtualList/utils/algorithmUtil.d.ts +0 -23
  94. package/dist/VirtualList/utils/algorithmUtil.js +0 -81
  95. package/dist/VirtualList/utils/findDOMNode.d.ts +0 -5
  96. package/dist/VirtualList/utils/findDOMNode.js +0 -30
  97. package/dist/VirtualList/utils/isFirefox.d.ts +0 -2
  98. package/dist/VirtualList/utils/raf.d.ts +0 -5
  99. package/dist/VirtualList/utils/raf.js +0 -57
  100. package/dist/theme-chalk/bak/common/popup.scss +0 -47
  101. package/dist/theme-chalk/bak/common/transition.scss +0 -118
  102. package/dist/theme-chalk/bak/common/var.scss +0 -1476
  103. package/dist/theme-chalk/bak/mixins/_button.scss +0 -224
  104. package/dist/theme-chalk/bak/mixins/_col.scss +0 -38
  105. package/dist/theme-chalk/bak/mixins/_var.scss +0 -55
  106. package/dist/theme-chalk/bak/mixins/config.scss +0 -5
  107. package/dist/theme-chalk/bak/mixins/function.scss +0 -85
  108. package/dist/theme-chalk/bak/mixins/mixins.scss +0 -215
  109. package/dist/theme-chalk/bak/mixins/utils.scss +0 -39
@@ -1,72 +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/useFrameWheel.ts
30
- var useFrameWheel_exports = {};
31
- __export(useFrameWheel_exports, {
32
- default: () => useFrameWheel
33
- });
34
- module.exports = __toCommonJS(useFrameWheel_exports);
35
- var import_react = require("react");
36
- var import_isFirefox = __toESM(require("../utils/isFirefox"));
37
- var import_raf = __toESM(require("../utils/raf"));
38
- var import_useOriginScroll = __toESM(require("./useOriginScroll"));
39
- function useFrameWheel(inVirtual, isScrollAtTop, isScrollAtBottom, onWheelDelta) {
40
- const offsetRef = (0, import_react.useRef)(0);
41
- const nextFrameRef = (0, import_react.useRef)(null);
42
- const wheelValueRef = (0, import_react.useRef)(null);
43
- const isMouseScrollRef = (0, import_react.useRef)(false);
44
- const originScroll = (0, import_useOriginScroll.default)(isScrollAtTop, isScrollAtBottom);
45
- function onWheel(event) {
46
- if (!inVirtual) {
47
- return;
48
- }
49
- import_raf.default.cancel(nextFrameRef.current);
50
- const { deltaY } = event;
51
- offsetRef.current += deltaY;
52
- wheelValueRef.current = deltaY;
53
- if (originScroll(deltaY)) {
54
- return;
55
- }
56
- if (!import_isFirefox.default) {
57
- event.preventDefault();
58
- }
59
- nextFrameRef.current = (0, import_raf.default)(() => {
60
- const patchMultiple = isMouseScrollRef.current ? 10 : 1;
61
- onWheelDelta(offsetRef.current * patchMultiple);
62
- offsetRef.current = 0;
63
- });
64
- }
65
- function onFireFoxScroll(event) {
66
- if (!inVirtual) {
67
- return;
68
- }
69
- isMouseScrollRef.current = event.detail === wheelValueRef.current;
70
- }
71
- return [onWheel, onFireFoxScroll];
72
- }
@@ -1,3 +0,0 @@
1
- import type { GetKey } from '../interface';
2
- import CacheMap from '../utils/CacheMap';
3
- export default function useHeights<T>(getKey: GetKey<T>, onItemAdd?: (item: T) => void, onItemRemove?: (item: T) => void): [(item: T, instance: HTMLElement) => void, () => void, CacheMap, number];
@@ -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,17 +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 __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from))
8
- if (!__hasOwnProp.call(to, key) && key !== except)
9
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
- }
11
- return to;
12
- };
13
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
-
15
- // src/VirtualList/interface.ts
16
- var interface_exports = {};
17
- module.exports = __toCommonJS(interface_exports);
@@ -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;