@hi-ui/table 4.3.1 → 4.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -0
- package/lib/cjs/BaseTable.js +136 -189
- package/lib/cjs/ColGroupContent.js +5 -28
- package/lib/cjs/SettingDrawer.js +76 -127
- package/lib/cjs/Table.js +107 -171
- package/lib/cjs/TableAdvancedFilter.js +49 -85
- package/lib/cjs/TableBody.js +33 -69
- package/lib/cjs/TableCell.js +56 -102
- package/lib/cjs/TableColumnMenu.js +39 -77
- package/lib/cjs/TableEmbedRow.js +11 -38
- package/lib/cjs/TableHeader.js +8 -33
- package/lib/cjs/TableRow.js +48 -88
- package/lib/cjs/TableSettingMenu.js +48 -94
- package/lib/cjs/TbodyContent.js +28 -56
- package/lib/cjs/TheadContent.js +20 -49
- package/lib/cjs/_virtual/index.js +0 -3
- package/lib/cjs/_virtual/index2.js +0 -3
- package/lib/cjs/_virtual/react-is.development.js +0 -3
- package/lib/cjs/_virtual/react-is.production.min.js +0 -3
- package/lib/cjs/context.js +0 -9
- package/lib/cjs/hooks/use-async-switch.js +13 -51
- package/lib/cjs/hooks/use-check.js +47 -77
- package/lib/cjs/hooks/use-col-hidden.js +16 -28
- package/lib/cjs/hooks/use-col-set.js +5 -18
- package/lib/cjs/hooks/use-col-sorter.js +18 -32
- package/lib/cjs/hooks/use-col-width.js +21 -57
- package/lib/cjs/hooks/use-colgroup.js +63 -85
- package/lib/cjs/hooks/use-drag.js +10 -31
- package/lib/cjs/hooks/use-embed-expand.js +23 -68
- package/lib/cjs/hooks/use-expand.js +32 -64
- package/lib/cjs/hooks/use-pagination.js +19 -50
- package/lib/cjs/hooks/use-queue.js +2 -14
- package/lib/cjs/icons/index.js +4 -21
- package/lib/cjs/index.js +0 -4
- package/lib/cjs/node_modules/classnames/index.js +2 -11
- package/lib/cjs/node_modules/perfect-scrollbar/dist/perfect-scrollbar.esm.js +31 -227
- package/lib/cjs/node_modules/rc-resize-observer/es/index.js +10 -68
- package/lib/cjs/node_modules/rc-resize-observer/node_modules/rc-util/es/Children/toArray.js +1 -17
- package/lib/cjs/node_modules/rc-resize-observer/node_modules/rc-util/es/Dom/findDOMNode.js +1 -14
- package/lib/cjs/node_modules/rc-resize-observer/node_modules/rc-util/es/ref.js +1 -25
- package/lib/cjs/node_modules/rc-resize-observer/node_modules/rc-util/es/warning.js +1 -5
- package/lib/cjs/node_modules/rc-util/es/Dom/canUseDom.js +0 -2
- package/lib/cjs/node_modules/rc-util/es/Dom/findDOMNode.js +1 -14
- package/lib/cjs/node_modules/rc-util/es/hooks/useLayoutEffect.js +2 -9
- package/lib/cjs/node_modules/rc-util/es/raf.js +0 -11
- package/lib/cjs/node_modules/rc-virtual-list/es/Filler.js +6 -25
- package/lib/cjs/node_modules/rc-virtual-list/es/Item.js +3 -14
- package/lib/cjs/node_modules/rc-virtual-list/es/List.js +103 -194
- package/lib/cjs/node_modules/rc-virtual-list/es/ScrollBar.js +16 -96
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useChildren.js +2 -11
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useDiffItem.js +8 -34
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useFrameWheel.js +0 -10
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useHeights.js +6 -39
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useMobileTouchMove.js +0 -16
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useOriginScroll.js +4 -9
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useScrollTo.js +3 -28
- package/lib/cjs/node_modules/rc-virtual-list/es/index.js +0 -2
- package/lib/cjs/node_modules/rc-virtual-list/es/utils/CacheMap.js +2 -9
- package/lib/cjs/node_modules/rc-virtual-list/es/utils/algorithmUtil.js +0 -15
- package/lib/cjs/node_modules/rc-virtual-list/es/utils/isFirefox.js +0 -2
- package/lib/cjs/node_modules/react-is/cjs/react-is.development.js +3 -29
- package/lib/cjs/node_modules/react-is/cjs/react-is.production.min.js +19 -45
- package/lib/cjs/node_modules/react-is/index.js +0 -5
- package/lib/cjs/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js +83 -248
- package/lib/cjs/packages/hooks/use-merge-refs/lib/esm/index.js +3 -14
- package/lib/cjs/packages/ui/scrollbar/lib/esm/Scrollbar.js +48 -86
- package/lib/cjs/packages/ui/scrollbar/lib/esm/styles/index.scss.js +1 -15
- package/lib/cjs/packages/ui/scrollbar/lib/esm/utils/index.js +0 -13
- package/lib/cjs/styles/index.scss.js +1 -4
- package/lib/cjs/use-table.js +268 -355
- package/lib/cjs/utils/index.js +11 -45
- package/lib/esm/BaseTable.js +117 -138
- package/lib/esm/ColGroupContent.js +3 -9
- package/lib/esm/SettingDrawer.js +64 -83
- package/lib/esm/Table.js +97 -124
- package/lib/esm/TableAdvancedFilter.js +37 -47
- package/lib/esm/TableBody.js +24 -34
- package/lib/esm/TableCell.js +48 -72
- package/lib/esm/TableColumnMenu.js +24 -38
- package/lib/esm/TableEmbedRow.js +8 -15
- package/lib/esm/TableHeader.js +5 -11
- package/lib/esm/TableRow.js +36 -51
- package/lib/esm/TableSettingMenu.js +33 -49
- package/lib/esm/TbodyContent.js +20 -27
- package/lib/esm/TheadContent.js +14 -21
- package/lib/esm/context.js +0 -4
- package/lib/esm/hooks/use-async-switch.js +9 -28
- package/lib/esm/hooks/use-check.js +42 -55
- package/lib/esm/hooks/use-col-hidden.js +16 -21
- package/lib/esm/hooks/use-col-set.js +5 -13
- package/lib/esm/hooks/use-col-sorter.js +18 -23
- package/lib/esm/hooks/use-col-width.js +14 -34
- package/lib/esm/hooks/use-colgroup.js +60 -66
- package/lib/esm/hooks/use-drag.js +9 -13
- package/lib/esm/hooks/use-embed-expand.js +20 -42
- package/lib/esm/hooks/use-expand.js +32 -56
- package/lib/esm/hooks/use-pagination.js +13 -25
- package/lib/esm/hooks/use-queue.js +2 -10
- package/lib/esm/node_modules/classnames/index.js +2 -9
- package/lib/esm/node_modules/perfect-scrollbar/dist/perfect-scrollbar.esm.js +31 -228
- package/lib/esm/node_modules/rc-resize-observer/es/index.js +3 -26
- package/lib/esm/node_modules/rc-resize-observer/node_modules/rc-util/es/Children/toArray.js +0 -3
- package/lib/esm/node_modules/rc-resize-observer/node_modules/rc-util/es/Dom/findDOMNode.js +1 -2
- package/lib/esm/node_modules/rc-resize-observer/node_modules/rc-util/es/ref.js +0 -8
- package/lib/esm/node_modules/rc-resize-observer/node_modules/rc-util/es/warning.js +0 -5
- package/lib/esm/node_modules/rc-util/es/Dom/canUseDom.js +0 -1
- package/lib/esm/node_modules/rc-util/es/Dom/findDOMNode.js +1 -2
- package/lib/esm/node_modules/rc-util/es/hooks/useLayoutEffect.js +1 -0
- package/lib/esm/node_modules/rc-util/es/raf.js +0 -10
- package/lib/esm/node_modules/rc-virtual-list/es/Filler.js +4 -15
- package/lib/esm/node_modules/rc-virtual-list/es/Item.js +1 -3
- package/lib/esm/node_modules/rc-virtual-list/es/List.js +101 -174
- package/lib/esm/node_modules/rc-virtual-list/es/ScrollBar.js +14 -86
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useChildren.js +0 -2
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useDiffItem.js +6 -25
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useFrameWheel.js +0 -6
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useHeights.js +4 -28
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useMobileTouchMove.js +0 -13
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useOriginScroll.js +4 -8
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useScrollTo.js +1 -19
- package/lib/esm/node_modules/rc-virtual-list/es/index.js +1 -1
- package/lib/esm/node_modules/rc-virtual-list/es/utils/CacheMap.js +2 -8
- package/lib/esm/node_modules/rc-virtual-list/es/utils/algorithmUtil.js +1 -12
- package/lib/esm/node_modules/rc-virtual-list/es/utils/isFirefox.js +0 -1
- package/lib/esm/node_modules/react-is/cjs/react-is.development.js +4 -27
- package/lib/esm/node_modules/react-is/cjs/react-is.production.min.js +20 -44
- package/lib/esm/node_modules/react-is/index.js +0 -1
- package/lib/esm/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js +82 -248
- package/lib/esm/packages/hooks/use-merge-refs/lib/esm/index.js +3 -9
- package/lib/esm/packages/ui/scrollbar/lib/esm/Scrollbar.js +47 -64
- package/lib/esm/packages/ui/scrollbar/lib/esm/styles/index.scss.js +1 -3
- package/lib/esm/packages/ui/scrollbar/lib/esm/utils/index.js +0 -10
- package/lib/esm/styles/index.scss.js +1 -3
- package/lib/esm/use-table.js +261 -318
- package/lib/esm/utils/index.js +11 -41
- package/lib/types/BaseTable.d.ts +2 -2
- package/package.json +33 -33
|
@@ -21,38 +21,30 @@ import useMobileTouchMove from './hooks/useMobileTouchMove.js';
|
|
|
21
21
|
import useOriginScroll from './hooks/useOriginScroll.js';
|
|
22
22
|
import useLayoutEffect from '../../rc-util/es/hooks/useLayoutEffect.js';
|
|
23
23
|
var _excluded = ["prefixCls", "className", "height", "itemHeight", "fullHeight", "style", "data", "children", "itemKey", "virtual", "component", "onScroll", "onVisibleChange"];
|
|
24
|
-
|
|
25
24
|
function _extends() {
|
|
26
25
|
_extends = Object.assign || function (target) {
|
|
27
26
|
for (var i = 1; i < arguments.length; i++) {
|
|
28
27
|
var source = arguments[i];
|
|
29
|
-
|
|
30
28
|
for (var key in source) {
|
|
31
29
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
32
30
|
target[key] = source[key];
|
|
33
31
|
}
|
|
34
32
|
}
|
|
35
33
|
}
|
|
36
|
-
|
|
37
34
|
return target;
|
|
38
35
|
};
|
|
39
|
-
|
|
40
36
|
return _extends.apply(this, arguments);
|
|
41
37
|
}
|
|
42
|
-
|
|
43
38
|
function ownKeys(object, enumerableOnly) {
|
|
44
39
|
var keys = Object.keys(object);
|
|
45
|
-
|
|
46
40
|
if (Object.getOwnPropertySymbols) {
|
|
47
41
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
48
42
|
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
49
43
|
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
50
44
|
})), keys.push.apply(keys, symbols);
|
|
51
45
|
}
|
|
52
|
-
|
|
53
46
|
return keys;
|
|
54
47
|
}
|
|
55
|
-
|
|
56
48
|
function _objectSpread(target) {
|
|
57
49
|
for (var i = 1; i < arguments.length; i++) {
|
|
58
50
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
@@ -62,10 +54,8 @@ function _objectSpread(target) {
|
|
|
62
54
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
63
55
|
});
|
|
64
56
|
}
|
|
65
|
-
|
|
66
57
|
return target;
|
|
67
58
|
}
|
|
68
|
-
|
|
69
59
|
function _defineProperty(obj, key, value) {
|
|
70
60
|
if (key in obj) {
|
|
71
61
|
Object.defineProperty(obj, key, {
|
|
@@ -77,18 +67,14 @@ function _defineProperty(obj, key, value) {
|
|
|
77
67
|
} else {
|
|
78
68
|
obj[key] = value;
|
|
79
69
|
}
|
|
80
|
-
|
|
81
70
|
return obj;
|
|
82
71
|
}
|
|
83
|
-
|
|
84
72
|
function _slicedToArray(arr, i) {
|
|
85
73
|
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
86
74
|
}
|
|
87
|
-
|
|
88
75
|
function _nonIterableRest() {
|
|
89
76
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
90
77
|
}
|
|
91
|
-
|
|
92
78
|
function _unsupportedIterableToArray(o, minLen) {
|
|
93
79
|
if (!o) return;
|
|
94
80
|
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
@@ -97,31 +83,23 @@ function _unsupportedIterableToArray(o, minLen) {
|
|
|
97
83
|
if (n === "Map" || n === "Set") return Array.from(o);
|
|
98
84
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
99
85
|
}
|
|
100
|
-
|
|
101
86
|
function _arrayLikeToArray(arr, len) {
|
|
102
87
|
if (len == null || len > arr.length) len = arr.length;
|
|
103
|
-
|
|
104
88
|
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
105
89
|
arr2[i] = arr[i];
|
|
106
90
|
}
|
|
107
|
-
|
|
108
91
|
return arr2;
|
|
109
92
|
}
|
|
110
|
-
|
|
111
93
|
function _iterableToArrayLimit(arr, i) {
|
|
112
94
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
113
|
-
|
|
114
95
|
if (_i == null) return;
|
|
115
96
|
var _arr = [];
|
|
116
97
|
var _n = true;
|
|
117
98
|
var _d = false;
|
|
118
|
-
|
|
119
99
|
var _s, _e;
|
|
120
|
-
|
|
121
100
|
try {
|
|
122
101
|
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
123
102
|
_arr.push(_s.value);
|
|
124
|
-
|
|
125
103
|
if (i && _arr.length === i) break;
|
|
126
104
|
}
|
|
127
105
|
} catch (err) {
|
|
@@ -134,24 +112,17 @@ function _iterableToArrayLimit(arr, i) {
|
|
|
134
112
|
if (_d) throw _e;
|
|
135
113
|
}
|
|
136
114
|
}
|
|
137
|
-
|
|
138
115
|
return _arr;
|
|
139
116
|
}
|
|
140
|
-
|
|
141
117
|
function _arrayWithHoles(arr) {
|
|
142
118
|
if (Array.isArray(arr)) return arr;
|
|
143
119
|
}
|
|
144
|
-
|
|
145
120
|
function _objectWithoutProperties(source, excluded) {
|
|
146
121
|
if (source == null) return {};
|
|
147
|
-
|
|
148
122
|
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
149
|
-
|
|
150
123
|
var key, i;
|
|
151
|
-
|
|
152
124
|
if (Object.getOwnPropertySymbols) {
|
|
153
125
|
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
154
|
-
|
|
155
126
|
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
156
127
|
key = sourceSymbolKeys[i];
|
|
157
128
|
if (excluded.indexOf(key) >= 0) continue;
|
|
@@ -159,64 +130,54 @@ function _objectWithoutProperties(source, excluded) {
|
|
|
159
130
|
target[key] = source[key];
|
|
160
131
|
}
|
|
161
132
|
}
|
|
162
|
-
|
|
163
133
|
return target;
|
|
164
134
|
}
|
|
165
|
-
|
|
166
135
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
167
136
|
if (source == null) return {};
|
|
168
137
|
var target = {};
|
|
169
138
|
var sourceKeys = Object.keys(source);
|
|
170
139
|
var key, i;
|
|
171
|
-
|
|
172
140
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
173
141
|
key = sourceKeys[i];
|
|
174
142
|
if (excluded.indexOf(key) >= 0) continue;
|
|
175
143
|
target[key] = source[key];
|
|
176
144
|
}
|
|
177
|
-
|
|
178
145
|
return target;
|
|
179
146
|
}
|
|
180
|
-
|
|
181
147
|
var EMPTY_DATA = [];
|
|
182
148
|
var ScrollStyle = {
|
|
183
149
|
overflowY: 'auto',
|
|
184
150
|
overflowAnchor: 'none'
|
|
185
151
|
};
|
|
186
|
-
|
|
187
152
|
function RawList(props, ref) {
|
|
188
153
|
var _props$prefixCls = props.prefixCls,
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
154
|
+
prefixCls = _props$prefixCls === void 0 ? 'rc-virtual-list' : _props$prefixCls,
|
|
155
|
+
className = props.className,
|
|
156
|
+
height = props.height,
|
|
157
|
+
itemHeight = props.itemHeight,
|
|
158
|
+
_props$fullHeight = props.fullHeight,
|
|
159
|
+
fullHeight = _props$fullHeight === void 0 ? true : _props$fullHeight,
|
|
160
|
+
style = props.style,
|
|
161
|
+
data = props.data,
|
|
162
|
+
children = props.children,
|
|
163
|
+
itemKey = props.itemKey,
|
|
164
|
+
virtual = props.virtual,
|
|
165
|
+
_props$component = props.component,
|
|
166
|
+
Component = _props$component === void 0 ? 'div' : _props$component,
|
|
167
|
+
onScroll = props.onScroll,
|
|
168
|
+
onVisibleChange = props.onVisibleChange,
|
|
169
|
+
restProps = _objectWithoutProperties(props, _excluded); // ================================= MISC =================================
|
|
206
170
|
|
|
207
171
|
var useVirtual = !!(virtual !== false && height && itemHeight);
|
|
208
172
|
var inVirtual = useVirtual && data && itemHeight * data.length > height;
|
|
209
|
-
|
|
210
173
|
var _useState = useState(0),
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
174
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
175
|
+
scrollTop = _useState2[0],
|
|
176
|
+
setScrollTop = _useState2[1];
|
|
215
177
|
var _useState3 = useState(false),
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
178
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
179
|
+
scrollMoving = _useState4[0],
|
|
180
|
+
setScrollMoving = _useState4[1];
|
|
220
181
|
var mergedClassName = classNames(prefixCls, className);
|
|
221
182
|
var mergedData = data || EMPTY_DATA;
|
|
222
183
|
var componentRef = useRef();
|
|
@@ -228,7 +189,6 @@ function RawList(props, ref) {
|
|
|
228
189
|
if (typeof itemKey === 'function') {
|
|
229
190
|
return itemKey(item);
|
|
230
191
|
}
|
|
231
|
-
|
|
232
192
|
return item === null || item === void 0 ? void 0 : item[itemKey];
|
|
233
193
|
}, [itemKey]);
|
|
234
194
|
var sharedConfig = {
|
|
@@ -238,13 +198,11 @@ function RawList(props, ref) {
|
|
|
238
198
|
function syncScrollTop(newTop) {
|
|
239
199
|
setScrollTop(function (origin) {
|
|
240
200
|
var value;
|
|
241
|
-
|
|
242
201
|
if (typeof newTop === 'function') {
|
|
243
202
|
value = newTop(origin);
|
|
244
203
|
} else {
|
|
245
204
|
value = newTop;
|
|
246
205
|
}
|
|
247
|
-
|
|
248
206
|
var alignedTop = keepInRange(value);
|
|
249
207
|
componentRef.current.scrollTop = alignedTop;
|
|
250
208
|
return alignedTop;
|
|
@@ -252,125 +210,107 @@ function RawList(props, ref) {
|
|
|
252
210
|
} // ================================ Legacy ================================
|
|
253
211
|
// Put ref here since the range is generate by follow
|
|
254
212
|
|
|
255
|
-
|
|
256
213
|
var rangeRef = useRef({
|
|
257
214
|
start: 0,
|
|
258
215
|
end: mergedData.length
|
|
259
216
|
});
|
|
260
217
|
var diffItemRef = useRef();
|
|
261
|
-
|
|
262
218
|
var _useDiffItem = useDiffItem(mergedData, getKey),
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
219
|
+
_useDiffItem2 = _slicedToArray(_useDiffItem, 1),
|
|
220
|
+
diffItem = _useDiffItem2[0];
|
|
266
221
|
diffItemRef.current = diffItem; // ================================ Height ================================
|
|
267
222
|
|
|
268
223
|
var _useHeights = useHeights(getKey, null, null),
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
224
|
+
_useHeights2 = _slicedToArray(_useHeights, 4),
|
|
225
|
+
setInstanceRef = _useHeights2[0],
|
|
226
|
+
collectHeight = _useHeights2[1],
|
|
227
|
+
heights = _useHeights2[2],
|
|
228
|
+
heightUpdatedMark = _useHeights2[3]; // ========================== Visible Calculation =========================
|
|
275
229
|
|
|
276
230
|
var _React$useMemo = React.useMemo(function () {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
offset: undefined
|
|
296
|
-
};
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
var itemTop = 0;
|
|
300
|
-
var startIndex;
|
|
301
|
-
var startOffset;
|
|
302
|
-
var endIndex;
|
|
303
|
-
var dataLen = mergedData.length;
|
|
304
|
-
|
|
305
|
-
for (var i = 0; i < dataLen; i += 1) {
|
|
306
|
-
var item = mergedData[i];
|
|
307
|
-
var key = getKey(item);
|
|
308
|
-
var cacheHeight = heights.get(key);
|
|
309
|
-
var currentItemBottom = itemTop + (cacheHeight === undefined ? itemHeight : cacheHeight); // Check item top in the range
|
|
310
|
-
// Check item top in the range
|
|
311
|
-
|
|
312
|
-
if (currentItemBottom >= scrollTop && startIndex === undefined) {
|
|
313
|
-
startIndex = i;
|
|
314
|
-
startOffset = itemTop;
|
|
315
|
-
} // Check item bottom in the range. We will render additional one item for motion usage
|
|
316
|
-
// Check item bottom in the range. We will render additional one item for motion usage
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
if (currentItemBottom > scrollTop + height && endIndex === undefined) {
|
|
320
|
-
endIndex = i;
|
|
231
|
+
if (!useVirtual) {
|
|
232
|
+
return {
|
|
233
|
+
scrollHeight: undefined,
|
|
234
|
+
start: 0,
|
|
235
|
+
end: mergedData.length - 1,
|
|
236
|
+
offset: undefined
|
|
237
|
+
};
|
|
238
|
+
} // Always use virtual scroll bar in avoid shaking
|
|
239
|
+
|
|
240
|
+
// Always use virtual scroll bar in avoid shaking
|
|
241
|
+
if (!inVirtual) {
|
|
242
|
+
var _fillerInnerRef$curre;
|
|
243
|
+
return {
|
|
244
|
+
scrollHeight: ((_fillerInnerRef$curre = fillerInnerRef.current) === null || _fillerInnerRef$curre === void 0 ? void 0 : _fillerInnerRef$curre.offsetHeight) || 0,
|
|
245
|
+
start: 0,
|
|
246
|
+
end: mergedData.length - 1,
|
|
247
|
+
offset: undefined
|
|
248
|
+
};
|
|
321
249
|
}
|
|
250
|
+
var itemTop = 0;
|
|
251
|
+
var startIndex;
|
|
252
|
+
var startOffset;
|
|
253
|
+
var endIndex;
|
|
254
|
+
var dataLen = mergedData.length;
|
|
255
|
+
for (var i = 0; i < dataLen; i += 1) {
|
|
256
|
+
var item = mergedData[i];
|
|
257
|
+
var key = getKey(item);
|
|
258
|
+
var cacheHeight = heights.get(key);
|
|
259
|
+
var currentItemBottom = itemTop + (cacheHeight === undefined ? itemHeight : cacheHeight); // Check item top in the range
|
|
260
|
+
|
|
261
|
+
// Check item top in the range
|
|
262
|
+
if (currentItemBottom >= scrollTop && startIndex === undefined) {
|
|
263
|
+
startIndex = i;
|
|
264
|
+
startOffset = itemTop;
|
|
265
|
+
} // Check item bottom in the range. We will render additional one item for motion usage
|
|
266
|
+
|
|
267
|
+
// Check item bottom in the range. We will render additional one item for motion usage
|
|
268
|
+
if (currentItemBottom > scrollTop + height && endIndex === undefined) {
|
|
269
|
+
endIndex = i;
|
|
270
|
+
}
|
|
271
|
+
itemTop = currentItemBottom;
|
|
272
|
+
} // Fallback to normal if not match. This code should never reach
|
|
322
273
|
|
|
323
|
-
|
|
324
|
-
} // Fallback to normal if not match. This code should never reach
|
|
325
|
-
|
|
326
|
-
/* istanbul ignore next */
|
|
327
|
-
// Fallback to normal if not match. This code should never reach
|
|
328
|
-
|
|
329
|
-
/* istanbul ignore next */
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
if (startIndex === undefined) {
|
|
333
|
-
startIndex = 0;
|
|
334
|
-
startOffset = 0;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
if (endIndex === undefined) {
|
|
338
|
-
endIndex = mergedData.length - 1;
|
|
339
|
-
} // Give cache to improve scroll experience
|
|
340
|
-
// Give cache to improve scroll experience
|
|
274
|
+
/* istanbul ignore next */
|
|
341
275
|
|
|
276
|
+
// Fallback to normal if not match. This code should never reach
|
|
342
277
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
scrollHeight = _React$useMemo.scrollHeight,
|
|
352
|
-
start = _React$useMemo.start,
|
|
353
|
-
end = _React$useMemo.end,
|
|
354
|
-
offset = _React$useMemo.offset;
|
|
278
|
+
/* istanbul ignore next */
|
|
279
|
+
if (startIndex === undefined) {
|
|
280
|
+
startIndex = 0;
|
|
281
|
+
startOffset = 0;
|
|
282
|
+
}
|
|
283
|
+
if (endIndex === undefined) {
|
|
284
|
+
endIndex = mergedData.length - 1;
|
|
285
|
+
} // Give cache to improve scroll experience
|
|
355
286
|
|
|
287
|
+
// Give cache to improve scroll experience
|
|
288
|
+
endIndex = Math.min(endIndex + 1, mergedData.length);
|
|
289
|
+
return {
|
|
290
|
+
scrollHeight: itemTop,
|
|
291
|
+
start: startIndex,
|
|
292
|
+
end: endIndex,
|
|
293
|
+
offset: startOffset
|
|
294
|
+
};
|
|
295
|
+
}, [inVirtual, useVirtual, scrollTop, mergedData, heightUpdatedMark, height]),
|
|
296
|
+
scrollHeight = _React$useMemo.scrollHeight,
|
|
297
|
+
start = _React$useMemo.start,
|
|
298
|
+
end = _React$useMemo.end,
|
|
299
|
+
offset = _React$useMemo.offset;
|
|
356
300
|
rangeRef.current.start = start;
|
|
357
301
|
rangeRef.current.end = end; // =============================== In Range ===============================
|
|
358
302
|
|
|
359
303
|
var maxScrollHeight = scrollHeight - height;
|
|
360
304
|
var maxScrollHeightRef = useRef(maxScrollHeight);
|
|
361
305
|
maxScrollHeightRef.current = maxScrollHeight;
|
|
362
|
-
|
|
363
306
|
function keepInRange(newScrollTop) {
|
|
364
307
|
var newTop = newScrollTop;
|
|
365
|
-
|
|
366
308
|
if (!Number.isNaN(maxScrollHeightRef.current)) {
|
|
367
309
|
newTop = Math.min(newTop, maxScrollHeightRef.current);
|
|
368
310
|
}
|
|
369
|
-
|
|
370
311
|
newTop = Math.max(newTop, 0);
|
|
371
312
|
return newTop;
|
|
372
313
|
}
|
|
373
|
-
|
|
374
314
|
var isScrollAtTop = scrollTop <= 0;
|
|
375
315
|
var isScrollAtBottom = scrollTop >= maxScrollHeight;
|
|
376
316
|
var originScroll = useOriginScroll(isScrollAtTop, isScrollAtBottom); // ================================ Scroll ================================
|
|
@@ -380,35 +320,29 @@ function RawList(props, ref) {
|
|
|
380
320
|
syncScrollTop(newTop);
|
|
381
321
|
} // When data size reduce. It may trigger native scroll event back to fit scroll position
|
|
382
322
|
|
|
383
|
-
|
|
384
323
|
function onFallbackScroll(e) {
|
|
385
324
|
var newScrollTop = e.currentTarget.scrollTop;
|
|
386
|
-
|
|
387
325
|
if (newScrollTop !== scrollTop) {
|
|
388
326
|
syncScrollTop(newScrollTop);
|
|
389
327
|
} // Trigger origin onScroll
|
|
390
328
|
|
|
391
|
-
|
|
392
329
|
onScroll === null || onScroll === void 0 ? void 0 : onScroll(e);
|
|
393
330
|
} // Since this added in global,should use ref to keep update
|
|
394
331
|
|
|
395
|
-
|
|
396
332
|
var _useFrameWheel = useFrameWheel(useVirtual, isScrollAtTop, isScrollAtBottom, function (offsetY) {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
333
|
+
syncScrollTop(function (top) {
|
|
334
|
+
var newTop = top + offsetY;
|
|
335
|
+
return newTop;
|
|
336
|
+
});
|
|
337
|
+
}),
|
|
338
|
+
_useFrameWheel2 = _slicedToArray(_useFrameWheel, 2),
|
|
339
|
+
onRawWheel = _useFrameWheel2[0],
|
|
340
|
+
onFireFoxScroll = _useFrameWheel2[1]; // Mobile touch move
|
|
406
341
|
|
|
407
342
|
useMobileTouchMove(useVirtual, componentRef, function (deltaY, smoothOffset) {
|
|
408
343
|
if (originScroll(deltaY, smoothOffset)) {
|
|
409
344
|
return false;
|
|
410
345
|
}
|
|
411
|
-
|
|
412
346
|
onRawWheel({
|
|
413
347
|
preventDefault: function preventDefault() {},
|
|
414
348
|
deltaY: deltaY
|
|
@@ -422,7 +356,6 @@ function RawList(props, ref) {
|
|
|
422
356
|
e.preventDefault();
|
|
423
357
|
}
|
|
424
358
|
}
|
|
425
|
-
|
|
426
359
|
componentRef.current.addEventListener('wheel', onRawWheel);
|
|
427
360
|
componentRef.current.addEventListener('DOMMouseScroll', onFireFoxScroll);
|
|
428
361
|
componentRef.current.addEventListener('MozMousePixelScroll', onMozMousePixelScroll);
|
|
@@ -437,7 +370,6 @@ function RawList(props, ref) {
|
|
|
437
370
|
|
|
438
371
|
var scrollTo = useScrollTo(componentRef, mergedData, heights, itemHeight, getKey, collectHeight, syncScrollTop, function () {
|
|
439
372
|
var _scrollBarRef$current;
|
|
440
|
-
|
|
441
373
|
(_scrollBarRef$current = scrollBarRef.current) === null || _scrollBarRef$current === void 0 ? void 0 : _scrollBarRef$current.delayHidden();
|
|
442
374
|
});
|
|
443
375
|
React.useImperativeHandle(ref, function () {
|
|
@@ -457,19 +389,15 @@ function RawList(props, ref) {
|
|
|
457
389
|
|
|
458
390
|
var listChildren = useChildren(mergedData, start, end, setInstanceRef, children, sharedConfig);
|
|
459
391
|
var componentStyle = null;
|
|
460
|
-
|
|
461
392
|
if (height) {
|
|
462
393
|
componentStyle = _objectSpread(_defineProperty({}, fullHeight ? 'height' : 'maxHeight', height), ScrollStyle);
|
|
463
|
-
|
|
464
394
|
if (useVirtual) {
|
|
465
395
|
componentStyle.overflowY = 'hidden';
|
|
466
|
-
|
|
467
396
|
if (scrollMoving) {
|
|
468
397
|
componentStyle.pointerEvents = 'none';
|
|
469
398
|
}
|
|
470
399
|
}
|
|
471
400
|
}
|
|
472
|
-
|
|
473
401
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
474
402
|
style: _objectSpread(_objectSpread({}, style), {}, {
|
|
475
403
|
position: 'relative'
|
|
@@ -502,7 +430,6 @@ function RawList(props, ref) {
|
|
|
502
430
|
}
|
|
503
431
|
}));
|
|
504
432
|
}
|
|
505
|
-
|
|
506
433
|
var List = /*#__PURE__*/React.forwardRef(RawList);
|
|
507
434
|
List.displayName = 'List';
|
|
508
435
|
export { RawList, List as default };
|