@hi-ui/table 4.0.13 → 4.1.0-beta.0

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