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