@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
@@ -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
- prefixCls = _props$prefixCls === void 0 ? 'rc-virtual-list' : _props$prefixCls,
190
- className = props.className,
191
- height = props.height,
192
- itemHeight = props.itemHeight,
193
- _props$fullHeight = props.fullHeight,
194
- fullHeight = _props$fullHeight === void 0 ? true : _props$fullHeight,
195
- style = props.style,
196
- data = props.data,
197
- children = props.children,
198
- itemKey = props.itemKey,
199
- virtual = props.virtual,
200
- _props$component = props.component,
201
- Component = _props$component === void 0 ? 'div' : _props$component,
202
- onScroll = props.onScroll,
203
- onVisibleChange = props.onVisibleChange,
204
- restProps = _objectWithoutProperties(props, _excluded); // ================================= MISC =================================
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
- _useState2 = _slicedToArray(_useState, 2),
212
- scrollTop = _useState2[0],
213
- setScrollTop = _useState2[1];
214
-
174
+ _useState2 = _slicedToArray(_useState, 2),
175
+ scrollTop = _useState2[0],
176
+ setScrollTop = _useState2[1];
215
177
  var _useState3 = useState(false),
216
- _useState4 = _slicedToArray(_useState3, 2),
217
- scrollMoving = _useState4[0],
218
- setScrollMoving = _useState4[1];
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
- _useDiffItem2 = _slicedToArray(_useDiffItem, 1),
264
- diffItem = _useDiffItem2[0];
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
- _useHeights2 = _slicedToArray(_useHeights, 4),
270
- setInstanceRef = _useHeights2[0],
271
- collectHeight = _useHeights2[1],
272
- heights = _useHeights2[2],
273
- heightUpdatedMark = _useHeights2[3]; // ========================== Visible Calculation =========================
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
- if (!useVirtual) {
278
- return {
279
- scrollHeight: undefined,
280
- start: 0,
281
- end: mergedData.length - 1,
282
- offset: undefined
283
- };
284
- } // Always use virtual scroll bar in avoid shaking
285
- // Always use virtual scroll bar in avoid shaking
286
-
287
-
288
- if (!inVirtual) {
289
- var _fillerInnerRef$curre;
290
-
291
- return {
292
- scrollHeight: ((_fillerInnerRef$curre = fillerInnerRef.current) === null || _fillerInnerRef$curre === void 0 ? void 0 : _fillerInnerRef$curre.offsetHeight) || 0,
293
- start: 0,
294
- end: mergedData.length - 1,
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
- itemTop = currentItemBottom;
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
- endIndex = Math.min(endIndex + 1, mergedData.length);
344
- return {
345
- scrollHeight: itemTop,
346
- start: startIndex,
347
- end: endIndex,
348
- offset: startOffset
349
- };
350
- }, [inVirtual, useVirtual, scrollTop, mergedData, heightUpdatedMark, height]),
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
- syncScrollTop(function (top) {
398
- var newTop = top + offsetY;
399
- return newTop;
400
- });
401
- }),
402
- _useFrameWheel2 = _slicedToArray(_useFrameWheel, 2),
403
- onRawWheel = _useFrameWheel2[0],
404
- onFireFoxScroll = _useFrameWheel2[1]; // Mobile touch move
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 };