@para-ui/core 4.0.20 → 4.0.22
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/Breadcrumbs/index.js +2 -2
- package/Button/SplitButton.d.ts +1 -1
- package/Button/index.js +2 -2
- package/ButtonGroup/index.js +2 -2
- package/Cascader/OptionList/Column.d.ts +1 -1
- package/Cascader/index.js +5 -5
- package/ColorPicker/chromePicker/index.d.ts +1 -2
- package/ColorPicker/compactPicker/index.d.ts +1 -2
- package/ColorPicker/sketchPicker/index.d.ts +1 -2
- package/ColorPicker/swatchesPicker/index.d.ts +1 -2
- package/ComboSelect/index.js +4 -4
- package/Container/index.d.ts +1 -1
- package/CopyText/index.js +2 -2
- package/CycleSelector/index.js +4 -4
- package/DatePicker/PickerButton.d.ts +1 -2
- package/DatePicker/PickerTag.d.ts +1 -2
- package/DatePicker/index.js +3 -3
- package/Descriptions/index.js +2 -2
- package/Desktop/index.js +3 -3
- package/DragVerify/index.js +3 -2
- package/Drawer/index.js +2 -2
- package/DynamicMultiBox/formItem.d.ts +1 -2
- package/DynamicMultiBox/index.js +7 -7
- package/DynamicMultiBox/interface.d.ts +1 -1
- package/DynamicMultiBox/rowForm.d.ts +1 -1
- package/Empty/images/index.d.ts +2 -3
- package/Empty/index.js +4 -3
- package/Form/index.js +5 -5
- package/FormItem/index.js +5 -5
- package/FunctionModal/index.js +4 -5
- package/FunctionModal/modalContext.d.ts +1 -2
- package/GlobalContext/index.js +3 -39
- package/InputLang/index.js +3 -3
- package/Message/index.d.ts +1 -1
- package/Modal/index.js +3 -4
- package/MultiBox/index.js +3 -3
- package/OperateBtn/index.js +2 -2
- package/PageHeader/index.js +2 -2
- package/Pagination/index.js +6 -6
- package/ParauiProvider/index.d.ts +2 -2
- package/ParauiProvider/index.js +2 -2
- package/PopConfirm/index.js +2 -2
- package/Prompt/index.d.ts +1 -1
- package/Querying/images/index.d.ts +2 -3
- package/Querying/index.js +4 -3
- package/QuickReply/index.js +5 -5
- package/README.md +8 -0
- package/Search/index.js +2 -2
- package/Select/index.js +3 -3
- package/SelectInput/index.js +4 -4
- package/Selector/index.js +6 -6
- package/SelectorPicker/index.js +3 -3
- package/SingleBox/index.js +3 -3
- package/Switch/index.js +3 -2
- package/Table/index.js +3 -3
- package/Tabs/index.js +2 -2
- package/TextEditor/index.js +2 -2
- package/TextField/index.js +2 -2
- package/TimePicker/index.js +3 -3
- package/Timeline/TimelineItem.d.ts +1 -1
- package/ToggleButton/index.js +2 -2
- package/Tooltip/utils.d.ts +1 -1
- package/Transfer/box.d.ts +1 -1
- package/Transfer/index.d.ts +1 -1
- package/Transfer/index.js +4 -4
- package/Tree/index.js +5 -5
- package/Tree/utils/treeUtil.d.ts +1 -1
- package/Upload/index.js +3 -4
- package/_verture/defineProperty-6f62bb2a.js +34 -0
- package/_verture/{index-cc76d8d5.js → index-066d47d4.js} +793 -681
- package/_verture/{index-9bef932a.js → index-0f5ee6f7.js} +1 -1
- package/_verture/{index-356d88fa.js → index-4b965dd7.js} +1 -1
- package/_verture/{index-02b7a0b7.js → index-b892f976.js} +6 -2
- package/_verture/{intl-f2f27722.js → index-ca413216.js} +54 -1
- package/_verture/{sortable.esm-49896035.js → sortable.esm-76fe46a4.js} +597 -1029
- package/_verture/{useFormatMessage-eb13cf56.js → useFormatMessage-1fc7c957.js} +1 -1
- package/_verture/{useGlobalProps-1e416658.js → useGlobalProps-4ae1a007.js} +1 -1
- package/index.js +10 -13
- package/package.json +12 -17
- package/umd/AutoBox.js +11 -11
- package/umd/AutoTips.js +11 -11
- package/umd/Badge.js +1 -1
- package/umd/Breadcrumbs.js +11 -11
- package/umd/Button.js +11 -11
- package/umd/ButtonGroup.js +11 -11
- package/umd/Carousel.js +9 -9
- package/umd/Cascader.js +11 -11
- package/umd/Checkbox.js +11 -11
- package/umd/CheckboxGroup.js +11 -11
- package/umd/Collapse.js +10 -10
- package/umd/CollapseBox.js +1 -1
- package/umd/CollapseLayout.js +4 -4
- package/umd/ColorPicker.js +1 -1
- package/umd/ComboSelect.js +11 -11
- package/umd/Container.js +1 -1
- package/umd/CopyText.js +11 -11
- package/umd/CycleSelector.js +11 -11
- package/umd/DatePicker.js +11 -11
- package/umd/Descriptions.js +11 -11
- package/umd/Desktop.js +11 -11
- package/umd/DragVerify.js +4 -4
- package/umd/Drawer.js +11 -11
- package/umd/Dropdown.js +8 -8
- package/umd/DynamicMultiBox.js +14 -14
- package/umd/Empty.js +1 -1
- package/umd/Form.js +11 -11
- package/umd/FormItem.js +11 -11
- package/umd/FunctionModal.js +11 -11
- package/umd/GlobalContext.js +1 -1
- package/umd/Help.js +11 -11
- package/umd/HelperText.js +1 -1
- package/umd/InputLang.js +11 -11
- package/umd/InputNumber.js +11 -11
- package/umd/Label.js +11 -11
- package/umd/Loading.js +4 -4
- package/umd/Menu.js +11 -11
- package/umd/Message.js +4 -4
- package/umd/Modal.js +11 -11
- package/umd/MultiBox.js +11 -11
- package/umd/Notification.js +10 -10
- package/umd/OperateBtn.js +11 -11
- package/umd/PageHeader.js +11 -11
- package/umd/Pagination.js +11 -11
- package/umd/ParauiProvider.js +1 -1
- package/umd/PasswordRules.js +4 -4
- package/umd/PopConfirm.js +11 -11
- package/umd/PopMenu.js +11 -11
- package/umd/Popover.js +11 -11
- package/umd/Progress.js +9 -9
- package/umd/Prompt.js +4 -4
- package/umd/Querying.js +1 -1
- package/umd/QuickReply.js +14 -14
- package/umd/Radio.js +11 -11
- package/umd/RadioGroup.js +11 -11
- package/umd/Search.js +11 -11
- package/umd/Select.js +11 -11
- package/umd/SelectInput.js +11 -11
- package/umd/Selector.js +11 -11
- package/umd/SelectorPicker.js +11 -11
- package/umd/SingleBox.js +11 -11
- package/umd/Slider.js +8 -8
- package/umd/Status.js +4 -4
- package/umd/Stepper.js +11 -11
- package/umd/Switch.js +11 -11
- package/umd/Table.js +11 -11
- package/umd/Tabs.js +11 -11
- package/umd/Tag.js +11 -11
- package/umd/TextEditor.js +24 -24
- package/umd/TextField.js +11 -11
- package/umd/TimePicker.js +11 -11
- package/umd/Timeline.js +1 -1
- package/umd/Title.js +11 -11
- package/umd/ToggleButton.js +11 -11
- package/umd/Tooltip.js +11 -11
- package/umd/Transfer.js +13 -13
- package/umd/Tree.js +11 -11
- package/umd/Upload.js +12 -12
- package/umd/Utils.js +1 -1
- package/_verture/defineProperty-1d116156.js +0 -34
- package/_verture/index-c568f272.js +0 -18
- /package/_verture/{modalContext-3ba6ca8f.js → modalContext-c8cc3107.js} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _ as __rest } from './tslib.es6-55ed4bd2.js';
|
|
2
2
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
3
3
|
import { _ as _toConsumableArray, a as _iterableToArray } from './toConsumableArray-8f4c9589.js';
|
|
4
|
-
import { _ as _defineProperty,
|
|
4
|
+
import { _ as _defineProperty, t as toPropertyKey } from './defineProperty-6f62bb2a.js';
|
|
5
5
|
import { _ as _slicedToArray, a as _arrayWithHoles, b as _nonIterableRest } from './slicedToArray-a8206399.js';
|
|
6
6
|
import { _ as _typeof$1 } from './typeof-adeedc13.js';
|
|
7
7
|
import * as React$4 from 'react';
|
|
@@ -21,7 +21,7 @@ import { Forbid } from '@para-ui/icons';
|
|
|
21
21
|
import { $ as $prefixCls } from './constant-5317fc89.js';
|
|
22
22
|
import LoadingOutlined from '@para-ui/icons/LoadingF';
|
|
23
23
|
import AutoTips from '../AutoTips/index.js';
|
|
24
|
-
import { u as useFormatMessage } from './useFormatMessage-
|
|
24
|
+
import { u as useFormatMessage } from './useFormatMessage-1fc7c957.js';
|
|
25
25
|
import { UUID } from '@paraview/lib';
|
|
26
26
|
import { s as styleInject } from './style-inject.es-300983ab.js';
|
|
27
27
|
|
|
@@ -65,12 +65,11 @@ function _objectSpread2(e) {
|
|
|
65
65
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
66
66
|
if (source == null) return {};
|
|
67
67
|
var target = {};
|
|
68
|
-
var
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
target[key] = source[key];
|
|
68
|
+
for (var key in source) {
|
|
69
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
70
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
71
|
+
target[key] = source[key];
|
|
72
|
+
}
|
|
74
73
|
}
|
|
75
74
|
return target;
|
|
76
75
|
}
|
|
@@ -231,8 +230,19 @@ var preWarningFns = [];
|
|
|
231
230
|
var preMessage = function preMessage(fn) {
|
|
232
231
|
preWarningFns.push(fn);
|
|
233
232
|
};
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Warning if condition not match.
|
|
236
|
+
* @param valid Condition
|
|
237
|
+
* @param message Warning message
|
|
238
|
+
* @example
|
|
239
|
+
* ```js
|
|
240
|
+
* warning(false, 'some error'); // print some error
|
|
241
|
+
* warning(true, 'some error'); // print nothing
|
|
242
|
+
* warning(1 === 2, 'some error'); // print some error
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
234
245
|
function warning(valid, message) {
|
|
235
|
-
// Support uglify
|
|
236
246
|
if (process.env.NODE_ENV !== 'production' && !valid && console !== undefined) {
|
|
237
247
|
var finalMessage = preWarningFns.reduce(function (msg, preMessageFn) {
|
|
238
248
|
return preMessageFn(msg !== null && msg !== void 0 ? msg : '', 'warning');
|
|
@@ -242,8 +252,9 @@ function warning(valid, message) {
|
|
|
242
252
|
}
|
|
243
253
|
}
|
|
244
254
|
}
|
|
255
|
+
|
|
256
|
+
/** @see Similar to {@link warning} */
|
|
245
257
|
function note(valid, message) {
|
|
246
|
-
// Support uglify
|
|
247
258
|
if (process.env.NODE_ENV !== 'production' && !valid && console !== undefined) {
|
|
248
259
|
var finalMessage = preWarningFns.reduce(function (msg, preMessageFn) {
|
|
249
260
|
return preMessageFn(msg !== null && msg !== void 0 ? msg : '', 'note');
|
|
@@ -262,16 +273,19 @@ function call(method, valid, message) {
|
|
|
262
273
|
warned[message] = true;
|
|
263
274
|
}
|
|
264
275
|
}
|
|
276
|
+
|
|
277
|
+
/** @see Same as {@link warning}, but only warn once for the same message */
|
|
265
278
|
function warningOnce(valid, message) {
|
|
266
279
|
call(warning, valid, message);
|
|
267
280
|
}
|
|
281
|
+
|
|
282
|
+
/** @see Same as {@link warning}, but only warn once for the same message */
|
|
268
283
|
function noteOnce(valid, message) {
|
|
269
284
|
call(note, valid, message);
|
|
270
285
|
}
|
|
271
286
|
warningOnce.preMessage = preMessage;
|
|
272
287
|
warningOnce.resetWarned = resetWarned;
|
|
273
288
|
warningOnce.noteOnce = noteOnce;
|
|
274
|
-
/* eslint-enable */
|
|
275
289
|
|
|
276
290
|
var classnames = {exports: {}};
|
|
277
291
|
|
|
@@ -288,39 +302,57 @@ var classnames = {exports: {}};
|
|
|
288
302
|
|
|
289
303
|
var hasOwn = {}.hasOwnProperty;
|
|
290
304
|
|
|
291
|
-
function classNames() {
|
|
292
|
-
var classes =
|
|
305
|
+
function classNames () {
|
|
306
|
+
var classes = '';
|
|
293
307
|
|
|
294
308
|
for (var i = 0; i < arguments.length; i++) {
|
|
295
309
|
var arg = arguments[i];
|
|
296
|
-
if (
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
310
|
+
if (arg) {
|
|
311
|
+
classes = appendClass(classes, parseValue(arg));
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
return classes;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
function parseValue (arg) {
|
|
319
|
+
if (typeof arg === 'string' || typeof arg === 'number') {
|
|
320
|
+
return arg;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
if (typeof arg !== 'object') {
|
|
324
|
+
return '';
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
if (Array.isArray(arg)) {
|
|
328
|
+
return classNames.apply(null, arg);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
|
|
332
|
+
return arg.toString();
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
var classes = '';
|
|
336
|
+
|
|
337
|
+
for (var key in arg) {
|
|
338
|
+
if (hasOwn.call(arg, key) && arg[key]) {
|
|
339
|
+
classes = appendClass(classes, key);
|
|
320
340
|
}
|
|
321
341
|
}
|
|
322
342
|
|
|
323
|
-
return classes
|
|
343
|
+
return classes;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function appendClass (value, newClass) {
|
|
347
|
+
if (!newClass) {
|
|
348
|
+
return value;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (value) {
|
|
352
|
+
return value + ' ' + newClass;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
return value + newClass;
|
|
324
356
|
}
|
|
325
357
|
|
|
326
358
|
if (module.exports) {
|
|
@@ -1154,24 +1186,22 @@ function useMemo(getValue, condition, shouldUpdate) {
|
|
|
1154
1186
|
return cacheRef.current.value;
|
|
1155
1187
|
}
|
|
1156
1188
|
|
|
1157
|
-
function fillRef(ref, node) {
|
|
1189
|
+
var fillRef = function fillRef(ref, node) {
|
|
1158
1190
|
if (typeof ref === 'function') {
|
|
1159
1191
|
ref(node);
|
|
1160
1192
|
} else if (_typeof$1(ref) === 'object' && ref && 'current' in ref) {
|
|
1161
1193
|
ref.current = node;
|
|
1162
1194
|
}
|
|
1163
|
-
}
|
|
1195
|
+
};
|
|
1164
1196
|
|
|
1165
1197
|
/**
|
|
1166
1198
|
* Merge refs into one ref function to support ref passing.
|
|
1167
1199
|
*/
|
|
1168
|
-
function composeRef() {
|
|
1200
|
+
var composeRef = function composeRef() {
|
|
1169
1201
|
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1170
1202
|
refs[_key] = arguments[_key];
|
|
1171
1203
|
}
|
|
1172
|
-
var refList = refs.filter(
|
|
1173
|
-
return ref;
|
|
1174
|
-
});
|
|
1204
|
+
var refList = refs.filter(Boolean);
|
|
1175
1205
|
if (refList.length <= 1) {
|
|
1176
1206
|
return refList[0];
|
|
1177
1207
|
}
|
|
@@ -1180,8 +1210,8 @@ function composeRef() {
|
|
|
1180
1210
|
fillRef(ref, node);
|
|
1181
1211
|
});
|
|
1182
1212
|
};
|
|
1183
|
-
}
|
|
1184
|
-
function useComposeRef() {
|
|
1213
|
+
};
|
|
1214
|
+
var useComposeRef = function useComposeRef() {
|
|
1185
1215
|
for (var _len2 = arguments.length, refs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
1186
1216
|
refs[_key2] = arguments[_key2];
|
|
1187
1217
|
}
|
|
@@ -1192,23 +1222,22 @@ function useComposeRef() {
|
|
|
1192
1222
|
return ref !== next[i];
|
|
1193
1223
|
});
|
|
1194
1224
|
});
|
|
1195
|
-
}
|
|
1196
|
-
function supportRef(nodeOrComponent) {
|
|
1225
|
+
};
|
|
1226
|
+
var supportRef = function supportRef(nodeOrComponent) {
|
|
1197
1227
|
var _type$prototype, _nodeOrComponent$prot;
|
|
1198
1228
|
var type = reactIs.exports.isMemo(nodeOrComponent) ? nodeOrComponent.type.type : nodeOrComponent.type;
|
|
1199
1229
|
|
|
1200
1230
|
// Function component node
|
|
1201
|
-
if (typeof type === 'function' && !((_type$prototype = type.prototype) !== null && _type$prototype !== void 0 && _type$prototype.render)) {
|
|
1231
|
+
if (typeof type === 'function' && !((_type$prototype = type.prototype) !== null && _type$prototype !== void 0 && _type$prototype.render) && type.$$typeof !== reactIs.exports.ForwardRef) {
|
|
1202
1232
|
return false;
|
|
1203
1233
|
}
|
|
1204
1234
|
|
|
1205
1235
|
// Class component
|
|
1206
|
-
if (typeof nodeOrComponent === 'function' && !((_nodeOrComponent$prot = nodeOrComponent.prototype) !== null && _nodeOrComponent$prot !== void 0 && _nodeOrComponent$prot.render)) {
|
|
1236
|
+
if (typeof nodeOrComponent === 'function' && !((_nodeOrComponent$prot = nodeOrComponent.prototype) !== null && _nodeOrComponent$prot !== void 0 && _nodeOrComponent$prot.render) && nodeOrComponent.$$typeof !== reactIs.exports.ForwardRef) {
|
|
1207
1237
|
return false;
|
|
1208
1238
|
}
|
|
1209
1239
|
return true;
|
|
1210
|
-
}
|
|
1211
|
-
/* eslint-enable */
|
|
1240
|
+
};
|
|
1212
1241
|
|
|
1213
1242
|
var TransBtn = function TransBtn(_ref) {
|
|
1214
1243
|
var className = _ref.className,
|
|
@@ -2466,7 +2495,7 @@ function _defineProperties(target, props) {
|
|
|
2466
2495
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
2467
2496
|
descriptor.configurable = true;
|
|
2468
2497
|
if ("value" in descriptor) descriptor.writable = true;
|
|
2469
|
-
Object.defineProperty(target,
|
|
2498
|
+
Object.defineProperty(target, toPropertyKey(descriptor.key), descriptor);
|
|
2470
2499
|
}
|
|
2471
2500
|
}
|
|
2472
2501
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
@@ -2511,15 +2540,12 @@ function _getPrototypeOf(o) {
|
|
|
2511
2540
|
}
|
|
2512
2541
|
|
|
2513
2542
|
function _isNativeReflectConstruct() {
|
|
2514
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
2515
|
-
if (Reflect.construct.sham) return false;
|
|
2516
|
-
if (typeof Proxy === "function") return true;
|
|
2517
2543
|
try {
|
|
2518
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
return
|
|
2522
|
-
}
|
|
2544
|
+
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
2545
|
+
} catch (t) {}
|
|
2546
|
+
return (_isNativeReflectConstruct = function _isNativeReflectConstruct() {
|
|
2547
|
+
return !!t;
|
|
2548
|
+
})();
|
|
2523
2549
|
}
|
|
2524
2550
|
|
|
2525
2551
|
function _assertThisInitialized(self) {
|
|
@@ -3903,7 +3929,7 @@ function injectCSS(css) {
|
|
|
3903
3929
|
if (prepend) {
|
|
3904
3930
|
// If is queue `prepend`, it will prepend first style and then append rest style
|
|
3905
3931
|
if (isPrependQueue) {
|
|
3906
|
-
var existStyle = findStyles(container).filter(function (node) {
|
|
3932
|
+
var existStyle = (option.styles || findStyles(container)).filter(function (node) {
|
|
3907
3933
|
// Ignore style which not injected by rc-util with prepend
|
|
3908
3934
|
if (!['prepend', 'prependQueue'].includes(node.getAttribute(APPEND_ORDER))) {
|
|
3909
3935
|
return false;
|
|
@@ -3929,7 +3955,7 @@ function injectCSS(css) {
|
|
|
3929
3955
|
function findExistNode(key) {
|
|
3930
3956
|
var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
3931
3957
|
var container = getContainer(option);
|
|
3932
|
-
return findStyles(container).find(function (node) {
|
|
3958
|
+
return (option.styles || findStyles(container)).find(function (node) {
|
|
3933
3959
|
return node.getAttribute(getMark(option)) === key;
|
|
3934
3960
|
});
|
|
3935
3961
|
}
|
|
@@ -3957,8 +3983,12 @@ function syncRealContainer(container, option) {
|
|
|
3957
3983
|
}
|
|
3958
3984
|
}
|
|
3959
3985
|
function updateCSS(css, key) {
|
|
3960
|
-
var
|
|
3961
|
-
var container = getContainer(
|
|
3986
|
+
var originOption = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
3987
|
+
var container = getContainer(originOption);
|
|
3988
|
+
var styles = findStyles(container);
|
|
3989
|
+
var option = _objectSpread2(_objectSpread2({}, originOption), {}, {
|
|
3990
|
+
styles: styles
|
|
3991
|
+
});
|
|
3962
3992
|
|
|
3963
3993
|
// Sync real parent
|
|
3964
3994
|
syncRealContainer(container, option);
|
|
@@ -3980,43 +4010,60 @@ function updateCSS(css, key) {
|
|
|
3980
4010
|
}
|
|
3981
4011
|
|
|
3982
4012
|
/* eslint-disable no-param-reassign */
|
|
4013
|
+
function measureScrollbarSize(ele) {
|
|
4014
|
+
var randomId = "rc-scrollbar-measure-".concat(Math.random().toString(36).substring(7));
|
|
4015
|
+
var measureEle = document.createElement('div');
|
|
4016
|
+
measureEle.id = randomId;
|
|
4017
|
+
|
|
4018
|
+
// Create Style
|
|
4019
|
+
var measureStyle = measureEle.style;
|
|
4020
|
+
measureStyle.position = 'absolute';
|
|
4021
|
+
measureStyle.left = '0';
|
|
4022
|
+
measureStyle.top = '0';
|
|
4023
|
+
measureStyle.width = '100px';
|
|
4024
|
+
measureStyle.height = '100px';
|
|
4025
|
+
measureStyle.overflow = 'scroll';
|
|
4026
|
+
|
|
4027
|
+
// Clone Style if needed
|
|
4028
|
+
var fallbackWidth;
|
|
4029
|
+
var fallbackHeight;
|
|
4030
|
+
if (ele) {
|
|
4031
|
+
var targetStyle = getComputedStyle(ele);
|
|
4032
|
+
measureStyle.scrollbarColor = targetStyle.scrollbarColor;
|
|
4033
|
+
measureStyle.scrollbarWidth = targetStyle.scrollbarWidth;
|
|
4034
|
+
|
|
4035
|
+
// Set Webkit style
|
|
4036
|
+
var webkitScrollbarStyle = getComputedStyle(ele, '::-webkit-scrollbar');
|
|
4037
|
+
var width = parseInt(webkitScrollbarStyle.width, 10);
|
|
4038
|
+
var height = parseInt(webkitScrollbarStyle.height, 10);
|
|
4039
|
+
|
|
4040
|
+
// Try wrap to handle CSP case
|
|
4041
|
+
try {
|
|
4042
|
+
var widthStyle = width ? "width: ".concat(webkitScrollbarStyle.width, ";") : '';
|
|
4043
|
+
var heightStyle = height ? "height: ".concat(webkitScrollbarStyle.height, ";") : '';
|
|
4044
|
+
updateCSS("\n#".concat(randomId, "::-webkit-scrollbar {\n").concat(widthStyle, "\n").concat(heightStyle, "\n}"), randomId);
|
|
4045
|
+
} catch (e) {
|
|
4046
|
+
// Can't wrap, just log error
|
|
4047
|
+
console.error(e);
|
|
4048
|
+
|
|
4049
|
+
// Get from style directly
|
|
4050
|
+
fallbackWidth = width;
|
|
4051
|
+
fallbackHeight = height;
|
|
4052
|
+
}
|
|
4053
|
+
}
|
|
4054
|
+
document.body.appendChild(measureEle);
|
|
4055
|
+
|
|
4056
|
+
// Measure. Get fallback style if provided
|
|
4057
|
+
var scrollWidth = ele && fallbackWidth && !isNaN(fallbackWidth) ? fallbackWidth : measureEle.offsetWidth - measureEle.clientWidth;
|
|
4058
|
+
var scrollHeight = ele && fallbackHeight && !isNaN(fallbackHeight) ? fallbackHeight : measureEle.offsetHeight - measureEle.clientHeight;
|
|
3983
4059
|
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
inner.style.width = '100%';
|
|
3992
|
-
inner.style.height = '200px';
|
|
3993
|
-
var outer = document.createElement('div');
|
|
3994
|
-
var outerStyle = outer.style;
|
|
3995
|
-
outerStyle.position = 'absolute';
|
|
3996
|
-
outerStyle.top = '0';
|
|
3997
|
-
outerStyle.left = '0';
|
|
3998
|
-
outerStyle.pointerEvents = 'none';
|
|
3999
|
-
outerStyle.visibility = 'hidden';
|
|
4000
|
-
outerStyle.width = '200px';
|
|
4001
|
-
outerStyle.height = '150px';
|
|
4002
|
-
outerStyle.overflow = 'hidden';
|
|
4003
|
-
outer.appendChild(inner);
|
|
4004
|
-
document.body.appendChild(outer);
|
|
4005
|
-
var widthContained = inner.offsetWidth;
|
|
4006
|
-
outer.style.overflow = 'scroll';
|
|
4007
|
-
var widthScroll = inner.offsetWidth;
|
|
4008
|
-
if (widthContained === widthScroll) {
|
|
4009
|
-
widthScroll = outer.clientWidth;
|
|
4010
|
-
}
|
|
4011
|
-
document.body.removeChild(outer);
|
|
4012
|
-
cached = widthContained - widthScroll;
|
|
4013
|
-
}
|
|
4014
|
-
return cached;
|
|
4015
|
-
}
|
|
4016
|
-
function ensureSize(str) {
|
|
4017
|
-
var match = str.match(/^(.*)px$/);
|
|
4018
|
-
var value = Number(match === null || match === void 0 ? void 0 : match[1]);
|
|
4019
|
-
return Number.isNaN(value) ? getScrollBarSize() : value;
|
|
4060
|
+
// Clean up
|
|
4061
|
+
document.body.removeChild(measureEle);
|
|
4062
|
+
removeCSS(randomId);
|
|
4063
|
+
return {
|
|
4064
|
+
width: scrollWidth,
|
|
4065
|
+
height: scrollHeight
|
|
4066
|
+
};
|
|
4020
4067
|
}
|
|
4021
4068
|
function getTargetScrollBarSize(target) {
|
|
4022
4069
|
if (typeof document === 'undefined' || !target || !(target instanceof Element)) {
|
|
@@ -4025,13 +4072,7 @@ function getTargetScrollBarSize(target) {
|
|
|
4025
4072
|
height: 0
|
|
4026
4073
|
};
|
|
4027
4074
|
}
|
|
4028
|
-
|
|
4029
|
-
width = _getComputedStyle.width,
|
|
4030
|
-
height = _getComputedStyle.height;
|
|
4031
|
-
return {
|
|
4032
|
-
width: ensureSize(width),
|
|
4033
|
-
height: ensureSize(height)
|
|
4034
|
-
};
|
|
4075
|
+
return measureScrollbarSize(target);
|
|
4035
4076
|
}
|
|
4036
4077
|
|
|
4037
4078
|
/**
|
|
@@ -5355,7 +5396,9 @@ var _excluded$6 = ["prefixCls", "children", "action", "showAction", "hideAction"
|
|
|
5355
5396
|
// Removed Props List
|
|
5356
5397
|
// Seems this can be auto
|
|
5357
5398
|
// getDocument?: (element?: HTMLElement) => Document;
|
|
5399
|
+
|
|
5358
5400
|
// New version will not wrap popup with `rc-trigger-popup-content` when multiple children
|
|
5401
|
+
|
|
5359
5402
|
function generateTrigger() {
|
|
5360
5403
|
var PortalComponent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Portal;
|
|
5361
5404
|
var Trigger = /*#__PURE__*/React$4.forwardRef(function (props, ref) {
|
|
@@ -5703,9 +5746,9 @@ function generateTrigger() {
|
|
|
5703
5746
|
wrapperAction('onPointerEnter', true, mouseEnterDelay, function (event) {
|
|
5704
5747
|
setMousePosByEvent(event);
|
|
5705
5748
|
});
|
|
5706
|
-
onPopupMouseEnter = function onPopupMouseEnter() {
|
|
5749
|
+
onPopupMouseEnter = function onPopupMouseEnter(event) {
|
|
5707
5750
|
// Only trigger re-open when popup is visible
|
|
5708
|
-
if (mergedOpen || inMotion) {
|
|
5751
|
+
if ((mergedOpen || inMotion) && popupEle !== null && popupEle !== void 0 && popupEle.contains(event.target)) {
|
|
5709
5752
|
triggerOpen(true, mouseEnterDelay);
|
|
5710
5753
|
}
|
|
5711
5754
|
};
|
|
@@ -6930,16 +6973,15 @@ var Filler = /*#__PURE__*/React$4.forwardRef(function (_ref, ref) {
|
|
|
6930
6973
|
flexDirection: 'column'
|
|
6931
6974
|
};
|
|
6932
6975
|
if (offsetY !== undefined) {
|
|
6933
|
-
var _objectSpread2$1;
|
|
6934
6976
|
// Not set `width` since this will break `sticky: right`
|
|
6935
6977
|
outerStyle = {
|
|
6936
6978
|
height: height,
|
|
6937
6979
|
position: 'relative',
|
|
6938
6980
|
overflow: 'hidden'
|
|
6939
6981
|
};
|
|
6940
|
-
innerStyle = _objectSpread2(_objectSpread2({}, innerStyle), {}, (
|
|
6982
|
+
innerStyle = _objectSpread2(_objectSpread2({}, innerStyle), {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
|
|
6941
6983
|
transform: "translateY(".concat(offsetY, "px)")
|
|
6942
|
-
},
|
|
6984
|
+
}, rtl ? 'marginRight' : 'marginLeft', -offsetX), "position", 'absolute'), "left", 0), "right", 0), "top", 0));
|
|
6943
6985
|
}
|
|
6944
6986
|
return /*#__PURE__*/React$4.createElement("div", {
|
|
6945
6987
|
style: outerStyle
|
|
@@ -6958,265 +7000,292 @@ var Filler = /*#__PURE__*/React$4.forwardRef(function (_ref, ref) {
|
|
|
6958
7000
|
});
|
|
6959
7001
|
Filler.displayName = 'Filler';
|
|
6960
7002
|
|
|
6961
|
-
function
|
|
6962
|
-
var
|
|
6963
|
-
|
|
7003
|
+
function Item(_ref) {
|
|
7004
|
+
var children = _ref.children,
|
|
7005
|
+
setRef = _ref.setRef;
|
|
7006
|
+
var refFunc = React$4.useCallback(function (node) {
|
|
7007
|
+
setRef(node);
|
|
7008
|
+
}, []);
|
|
7009
|
+
return /*#__PURE__*/React$4.cloneElement(children, {
|
|
7010
|
+
ref: refFunc
|
|
7011
|
+
});
|
|
6964
7012
|
}
|
|
6965
|
-
|
|
6966
|
-
|
|
6967
|
-
var
|
|
6968
|
-
|
|
6969
|
-
|
|
6970
|
-
|
|
6971
|
-
|
|
6972
|
-
|
|
6973
|
-
|
|
6974
|
-
|
|
6975
|
-
|
|
6976
|
-
|
|
6977
|
-
|
|
6978
|
-
|
|
6979
|
-
|
|
7013
|
+
|
|
7014
|
+
function useChildren(list, startIndex, endIndex, scrollWidth, setNodeRef, renderFunc, _ref) {
|
|
7015
|
+
var getKey = _ref.getKey;
|
|
7016
|
+
return list.slice(startIndex, endIndex + 1).map(function (item, index) {
|
|
7017
|
+
var eleIndex = startIndex + index;
|
|
7018
|
+
var node = renderFunc(item, eleIndex, {
|
|
7019
|
+
style: {
|
|
7020
|
+
width: scrollWidth
|
|
7021
|
+
}
|
|
7022
|
+
});
|
|
7023
|
+
var key = getKey(item);
|
|
7024
|
+
return /*#__PURE__*/React$4.createElement(Item, {
|
|
7025
|
+
key: key,
|
|
7026
|
+
setRef: function setRef(ele) {
|
|
7027
|
+
return setNodeRef(item, ele);
|
|
7028
|
+
}
|
|
7029
|
+
}, node);
|
|
7030
|
+
});
|
|
7031
|
+
}
|
|
7032
|
+
|
|
7033
|
+
/**
|
|
7034
|
+
* Get index with specific start index one by one. e.g.
|
|
7035
|
+
* min: 3, max: 9, start: 6
|
|
7036
|
+
*
|
|
7037
|
+
* Return index is:
|
|
7038
|
+
* [0]: 6
|
|
7039
|
+
* [1]: 7
|
|
7040
|
+
* [2]: 5
|
|
7041
|
+
* [3]: 8
|
|
7042
|
+
* [4]: 4
|
|
7043
|
+
* [5]: 9
|
|
7044
|
+
* [6]: 3
|
|
7045
|
+
*/
|
|
7046
|
+
|
|
7047
|
+
/**
|
|
7048
|
+
* We assume that 2 list has only 1 item diff and others keeping the order.
|
|
7049
|
+
* So we can use dichotomy algorithm to find changed one.
|
|
7050
|
+
*/
|
|
7051
|
+
function findListDiffIndex(originList, targetList, getKey) {
|
|
7052
|
+
var originLen = originList.length;
|
|
7053
|
+
var targetLen = targetList.length;
|
|
7054
|
+
var shortList;
|
|
7055
|
+
var longList;
|
|
7056
|
+
if (originLen === 0 && targetLen === 0) {
|
|
7057
|
+
return null;
|
|
7058
|
+
}
|
|
7059
|
+
if (originLen < targetLen) {
|
|
7060
|
+
shortList = originList;
|
|
7061
|
+
longList = targetList;
|
|
7062
|
+
} else {
|
|
7063
|
+
shortList = targetList;
|
|
7064
|
+
longList = originList;
|
|
7065
|
+
}
|
|
7066
|
+
var notExistKey = {
|
|
7067
|
+
__EMPTY_ITEM__: true
|
|
7068
|
+
};
|
|
7069
|
+
function getItemKey(item) {
|
|
7070
|
+
if (item !== undefined) {
|
|
7071
|
+
return getKey(item);
|
|
7072
|
+
}
|
|
7073
|
+
return notExistKey;
|
|
7074
|
+
}
|
|
7075
|
+
|
|
7076
|
+
// Loop to find diff one
|
|
7077
|
+
var diffIndex = null;
|
|
7078
|
+
var multiple = Math.abs(originLen - targetLen) !== 1;
|
|
7079
|
+
for (var i = 0; i < longList.length; i += 1) {
|
|
7080
|
+
var shortKey = getItemKey(shortList[i]);
|
|
7081
|
+
var longKey = getItemKey(longList[i]);
|
|
7082
|
+
if (shortKey !== longKey) {
|
|
7083
|
+
diffIndex = i;
|
|
7084
|
+
multiple = multiple || shortKey !== getItemKey(longList[i + 1]);
|
|
7085
|
+
break;
|
|
7086
|
+
}
|
|
7087
|
+
}
|
|
7088
|
+
return diffIndex === null ? null : {
|
|
7089
|
+
index: diffIndex,
|
|
7090
|
+
multiple: multiple
|
|
7091
|
+
};
|
|
7092
|
+
}
|
|
7093
|
+
|
|
7094
|
+
function useDiffItem(data, getKey, onDiff) {
|
|
7095
|
+
var _React$useState = React$4.useState(data),
|
|
6980
7096
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
6981
|
-
|
|
6982
|
-
|
|
7097
|
+
prevData = _React$useState2[0],
|
|
7098
|
+
setPrevData = _React$useState2[1];
|
|
6983
7099
|
var _React$useState3 = React$4.useState(null),
|
|
6984
7100
|
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
6985
|
-
|
|
6986
|
-
|
|
6987
|
-
|
|
6988
|
-
|
|
6989
|
-
|
|
6990
|
-
|
|
6991
|
-
|
|
6992
|
-
// ========================= Refs =========================
|
|
6993
|
-
var scrollbarRef = React$4.useRef();
|
|
6994
|
-
var thumbRef = React$4.useRef();
|
|
6995
|
-
// ======================= Visible ========================
|
|
6996
|
-
var _React$useState7 = React$4.useState(false),
|
|
6997
|
-
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
6998
|
-
visible = _React$useState8[0],
|
|
6999
|
-
setVisible = _React$useState8[1];
|
|
7000
|
-
var visibleTimeoutRef = React$4.useRef();
|
|
7001
|
-
var delayHidden = function delayHidden() {
|
|
7002
|
-
clearTimeout(visibleTimeoutRef.current);
|
|
7003
|
-
setVisible(true);
|
|
7004
|
-
visibleTimeoutRef.current = setTimeout(function () {
|
|
7005
|
-
setVisible(false);
|
|
7006
|
-
}, 3000);
|
|
7007
|
-
};
|
|
7008
|
-
// ======================== Range =========================
|
|
7009
|
-
var enableScrollRange = scrollRange - containerSize || 0;
|
|
7010
|
-
var enableOffsetRange = containerSize - spinSize || 0;
|
|
7011
|
-
// `scrollWidth` < `clientWidth` means no need to show scrollbar
|
|
7012
|
-
var canScroll = enableScrollRange > 0;
|
|
7013
|
-
// ========================= Top ==========================
|
|
7014
|
-
var top = React$4.useMemo(function () {
|
|
7015
|
-
if (scrollOffset === 0 || enableScrollRange === 0) {
|
|
7016
|
-
return 0;
|
|
7101
|
+
diffItem = _React$useState4[0],
|
|
7102
|
+
setDiffItem = _React$useState4[1];
|
|
7103
|
+
React$4.useEffect(function () {
|
|
7104
|
+
var diff = findListDiffIndex(prevData || [], data || [], getKey);
|
|
7105
|
+
if ((diff === null || diff === void 0 ? void 0 : diff.index) !== undefined) {
|
|
7106
|
+
onDiff === null || onDiff === void 0 || onDiff(diff.index);
|
|
7107
|
+
setDiffItem(data[diff.index]);
|
|
7017
7108
|
}
|
|
7018
|
-
|
|
7019
|
-
|
|
7020
|
-
|
|
7021
|
-
|
|
7022
|
-
|
|
7023
|
-
|
|
7024
|
-
|
|
7025
|
-
|
|
7026
|
-
//
|
|
7027
|
-
var
|
|
7028
|
-
|
|
7029
|
-
|
|
7030
|
-
|
|
7031
|
-
|
|
7109
|
+
setPrevData(data);
|
|
7110
|
+
}, [data]);
|
|
7111
|
+
return [diffItem];
|
|
7112
|
+
}
|
|
7113
|
+
|
|
7114
|
+
var isFF = (typeof navigator === "undefined" ? "undefined" : _typeof$1(navigator)) === 'object' && /Firefox/i.test(navigator.userAgent);
|
|
7115
|
+
|
|
7116
|
+
var useOriginScroll = (function (isScrollAtTop, isScrollAtBottom) {
|
|
7117
|
+
// Do lock for a wheel when scrolling
|
|
7118
|
+
var lockRef = useRef(false);
|
|
7119
|
+
var lockTimeoutRef = useRef(null);
|
|
7120
|
+
function lockScroll() {
|
|
7121
|
+
clearTimeout(lockTimeoutRef.current);
|
|
7122
|
+
lockRef.current = true;
|
|
7123
|
+
lockTimeoutRef.current = setTimeout(function () {
|
|
7124
|
+
lockRef.current = false;
|
|
7125
|
+
}, 50);
|
|
7126
|
+
}
|
|
7127
|
+
|
|
7128
|
+
// Pass to ref since global add is in closure
|
|
7129
|
+
var scrollPingRef = useRef({
|
|
7130
|
+
top: isScrollAtTop,
|
|
7131
|
+
bottom: isScrollAtBottom
|
|
7032
7132
|
});
|
|
7033
|
-
|
|
7034
|
-
|
|
7035
|
-
|
|
7036
|
-
|
|
7037
|
-
|
|
7038
|
-
|
|
7039
|
-
|
|
7040
|
-
|
|
7041
|
-
|
|
7042
|
-
|
|
7043
|
-
|
|
7044
|
-
|
|
7045
|
-
|
|
7046
|
-
|
|
7047
|
-
|
|
7048
|
-
// React make event as passive, but we need to preventDefault
|
|
7049
|
-
// Add event on dom directly instead.
|
|
7050
|
-
// ref: https://github.com/facebook/react/issues/9809
|
|
7051
|
-
React$4.useEffect(function () {
|
|
7052
|
-
var onScrollbarTouchStart = function onScrollbarTouchStart(e) {
|
|
7053
|
-
e.preventDefault();
|
|
7054
|
-
};
|
|
7055
|
-
var scrollbarEle = scrollbarRef.current;
|
|
7056
|
-
var thumbEle = thumbRef.current;
|
|
7057
|
-
scrollbarEle.addEventListener('touchstart', onScrollbarTouchStart);
|
|
7058
|
-
thumbEle.addEventListener('touchstart', onThumbMouseDown);
|
|
7059
|
-
return function () {
|
|
7060
|
-
scrollbarEle.removeEventListener('touchstart', onScrollbarTouchStart);
|
|
7061
|
-
thumbEle.removeEventListener('touchstart', onThumbMouseDown);
|
|
7062
|
-
};
|
|
7063
|
-
}, []);
|
|
7064
|
-
// Pass to effect
|
|
7065
|
-
var enableScrollRangeRef = React$4.useRef();
|
|
7066
|
-
enableScrollRangeRef.current = enableScrollRange;
|
|
7067
|
-
var enableOffsetRangeRef = React$4.useRef();
|
|
7068
|
-
enableOffsetRangeRef.current = enableOffsetRange;
|
|
7069
|
-
React$4.useEffect(function () {
|
|
7070
|
-
if (dragging) {
|
|
7071
|
-
var moveRafId;
|
|
7072
|
-
var onMouseMove = function onMouseMove(e) {
|
|
7073
|
-
var _stateRef$current = stateRef.current,
|
|
7074
|
-
stateDragging = _stateRef$current.dragging,
|
|
7075
|
-
statePageY = _stateRef$current.pageY,
|
|
7076
|
-
stateStartTop = _stateRef$current.startTop;
|
|
7077
|
-
wrapperRaf.cancel(moveRafId);
|
|
7078
|
-
if (stateDragging) {
|
|
7079
|
-
var offset = getPageXY(e, horizontal) - statePageY;
|
|
7080
|
-
var newTop = stateStartTop;
|
|
7081
|
-
if (!isLTR && horizontal) {
|
|
7082
|
-
newTop -= offset;
|
|
7083
|
-
} else {
|
|
7084
|
-
newTop += offset;
|
|
7085
|
-
}
|
|
7086
|
-
var tmpEnableScrollRange = enableScrollRangeRef.current;
|
|
7087
|
-
var tmpEnableOffsetRange = enableOffsetRangeRef.current;
|
|
7088
|
-
var ptg = tmpEnableOffsetRange ? newTop / tmpEnableOffsetRange : 0;
|
|
7089
|
-
var newScrollTop = Math.ceil(ptg * tmpEnableScrollRange);
|
|
7090
|
-
newScrollTop = Math.max(newScrollTop, 0);
|
|
7091
|
-
newScrollTop = Math.min(newScrollTop, tmpEnableScrollRange);
|
|
7092
|
-
moveRafId = wrapperRaf(function () {
|
|
7093
|
-
onScroll(newScrollTop, horizontal);
|
|
7094
|
-
});
|
|
7095
|
-
}
|
|
7096
|
-
};
|
|
7097
|
-
var onMouseUp = function onMouseUp() {
|
|
7098
|
-
setDragging(false);
|
|
7099
|
-
onStopMove();
|
|
7100
|
-
};
|
|
7101
|
-
window.addEventListener('mousemove', onMouseMove);
|
|
7102
|
-
window.addEventListener('touchmove', onMouseMove);
|
|
7103
|
-
window.addEventListener('mouseup', onMouseUp);
|
|
7104
|
-
window.addEventListener('touchend', onMouseUp);
|
|
7105
|
-
return function () {
|
|
7106
|
-
window.removeEventListener('mousemove', onMouseMove);
|
|
7107
|
-
window.removeEventListener('touchmove', onMouseMove);
|
|
7108
|
-
window.removeEventListener('mouseup', onMouseUp);
|
|
7109
|
-
window.removeEventListener('touchend', onMouseUp);
|
|
7110
|
-
wrapperRaf.cancel(moveRafId);
|
|
7111
|
-
};
|
|
7133
|
+
scrollPingRef.current.top = isScrollAtTop;
|
|
7134
|
+
scrollPingRef.current.bottom = isScrollAtBottom;
|
|
7135
|
+
return function (deltaY) {
|
|
7136
|
+
var smoothOffset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
7137
|
+
var originScroll =
|
|
7138
|
+
// Pass origin wheel when on the top
|
|
7139
|
+
deltaY < 0 && scrollPingRef.current.top ||
|
|
7140
|
+
// Pass origin wheel when on the bottom
|
|
7141
|
+
deltaY > 0 && scrollPingRef.current.bottom;
|
|
7142
|
+
if (smoothOffset && originScroll) {
|
|
7143
|
+
// No need lock anymore when it's smooth offset from touchMove interval
|
|
7144
|
+
clearTimeout(lockTimeoutRef.current);
|
|
7145
|
+
lockRef.current = false;
|
|
7146
|
+
} else if (!originScroll || lockRef.current) {
|
|
7147
|
+
lockScroll();
|
|
7112
7148
|
}
|
|
7113
|
-
|
|
7114
|
-
React$4.useEffect(function () {
|
|
7115
|
-
delayHidden();
|
|
7116
|
-
}, [scrollOffset]);
|
|
7117
|
-
// ====================== Imperative ======================
|
|
7118
|
-
React$4.useImperativeHandle(ref, function () {
|
|
7119
|
-
return {
|
|
7120
|
-
delayHidden: delayHidden
|
|
7121
|
-
};
|
|
7122
|
-
});
|
|
7123
|
-
// ======================== Render ========================
|
|
7124
|
-
var scrollbarPrefixCls = "".concat(prefixCls, "-scrollbar");
|
|
7125
|
-
var containerStyle = {
|
|
7126
|
-
position: 'absolute',
|
|
7127
|
-
visibility: visible && canScroll ? null : 'hidden'
|
|
7128
|
-
};
|
|
7129
|
-
var thumbStyle = {
|
|
7130
|
-
position: 'absolute',
|
|
7131
|
-
background: 'rgba(0, 0, 0, 0.5)',
|
|
7132
|
-
borderRadius: 99,
|
|
7133
|
-
cursor: 'pointer',
|
|
7134
|
-
userSelect: 'none'
|
|
7149
|
+
return !lockRef.current && originScroll;
|
|
7135
7150
|
};
|
|
7136
|
-
|
|
7137
|
-
|
|
7138
|
-
|
|
7139
|
-
|
|
7140
|
-
|
|
7141
|
-
|
|
7142
|
-
|
|
7143
|
-
|
|
7144
|
-
|
|
7145
|
-
|
|
7146
|
-
|
|
7147
|
-
|
|
7148
|
-
|
|
7151
|
+
});
|
|
7152
|
+
|
|
7153
|
+
function useFrameWheel(inVirtual, isScrollAtTop, isScrollAtBottom, horizontalScroll,
|
|
7154
|
+
/***
|
|
7155
|
+
* Return `true` when you need to prevent default event
|
|
7156
|
+
*/
|
|
7157
|
+
onWheelDelta) {
|
|
7158
|
+
var offsetRef = useRef(0);
|
|
7159
|
+
var nextFrameRef = useRef(null);
|
|
7160
|
+
|
|
7161
|
+
// Firefox patch
|
|
7162
|
+
var wheelValueRef = useRef(null);
|
|
7163
|
+
var isMouseScrollRef = useRef(false);
|
|
7164
|
+
|
|
7165
|
+
// Scroll status sync
|
|
7166
|
+
var originScroll = useOriginScroll(isScrollAtTop, isScrollAtBottom);
|
|
7167
|
+
function onWheelY(event, deltaY) {
|
|
7168
|
+
wrapperRaf.cancel(nextFrameRef.current);
|
|
7169
|
+
offsetRef.current += deltaY;
|
|
7170
|
+
wheelValueRef.current = deltaY;
|
|
7171
|
+
|
|
7172
|
+
// Do nothing when scroll at the edge, Skip check when is in scroll
|
|
7173
|
+
if (originScroll(deltaY)) return;
|
|
7174
|
+
|
|
7175
|
+
// Proxy of scroll events
|
|
7176
|
+
if (!isFF) {
|
|
7177
|
+
event.preventDefault();
|
|
7149
7178
|
}
|
|
7150
|
-
|
|
7151
|
-
|
|
7152
|
-
|
|
7153
|
-
|
|
7154
|
-
|
|
7155
|
-
|
|
7156
|
-
|
|
7179
|
+
nextFrameRef.current = wrapperRaf(function () {
|
|
7180
|
+
// Patch a multiple for Firefox to fix wheel number too small
|
|
7181
|
+
// ref: https://github.com/ant-design/ant-design/issues/26372#issuecomment-679460266
|
|
7182
|
+
var patchMultiple = isMouseScrollRef.current ? 10 : 1;
|
|
7183
|
+
onWheelDelta(offsetRef.current * patchMultiple);
|
|
7184
|
+
offsetRef.current = 0;
|
|
7185
|
+
});
|
|
7186
|
+
}
|
|
7187
|
+
function onWheelX(event, deltaX) {
|
|
7188
|
+
onWheelDelta(deltaX, true);
|
|
7189
|
+
if (!isFF) {
|
|
7190
|
+
event.preventDefault();
|
|
7191
|
+
}
|
|
7192
|
+
}
|
|
7193
|
+
|
|
7194
|
+
// Check for which direction does wheel do. `sx` means `shift + wheel`
|
|
7195
|
+
var wheelDirectionRef = useRef(null);
|
|
7196
|
+
var wheelDirectionCleanRef = useRef(null);
|
|
7197
|
+
function onWheel(event) {
|
|
7198
|
+
if (!inVirtual) return;
|
|
7199
|
+
|
|
7200
|
+
// Wait for 2 frame to clean direction
|
|
7201
|
+
wrapperRaf.cancel(wheelDirectionCleanRef.current);
|
|
7202
|
+
wheelDirectionCleanRef.current = wrapperRaf(function () {
|
|
7203
|
+
wheelDirectionRef.current = null;
|
|
7204
|
+
}, 2);
|
|
7205
|
+
var deltaX = event.deltaX,
|
|
7206
|
+
deltaY = event.deltaY,
|
|
7207
|
+
shiftKey = event.shiftKey;
|
|
7208
|
+
var mergedDeltaX = deltaX;
|
|
7209
|
+
var mergedDeltaY = deltaY;
|
|
7210
|
+
if (wheelDirectionRef.current === 'sx' || !wheelDirectionRef.current && (shiftKey || false) && deltaY && !deltaX) {
|
|
7211
|
+
mergedDeltaX = deltaY;
|
|
7212
|
+
mergedDeltaY = 0;
|
|
7213
|
+
wheelDirectionRef.current = 'sx';
|
|
7214
|
+
}
|
|
7215
|
+
var absX = Math.abs(mergedDeltaX);
|
|
7216
|
+
var absY = Math.abs(mergedDeltaY);
|
|
7217
|
+
if (wheelDirectionRef.current === null) {
|
|
7218
|
+
wheelDirectionRef.current = horizontalScroll && absX > absY ? 'x' : 'y';
|
|
7219
|
+
}
|
|
7220
|
+
if (wheelDirectionRef.current === 'y') {
|
|
7221
|
+
onWheelY(event, mergedDeltaY);
|
|
7157
7222
|
} else {
|
|
7158
|
-
|
|
7223
|
+
onWheelX(event, mergedDeltaX);
|
|
7159
7224
|
}
|
|
7160
|
-
// Thumb
|
|
7161
|
-
thumbStyle.width = '100%';
|
|
7162
|
-
thumbStyle.height = spinSize;
|
|
7163
|
-
thumbStyle.top = top;
|
|
7164
7225
|
}
|
|
7165
|
-
return /*#__PURE__*/React$4.createElement("div", {
|
|
7166
|
-
ref: scrollbarRef,
|
|
7167
|
-
className: classNames(scrollbarPrefixCls, (_classNames = {}, _defineProperty(_classNames, "".concat(scrollbarPrefixCls, "-horizontal"), horizontal), _defineProperty(_classNames, "".concat(scrollbarPrefixCls, "-vertical"), !horizontal), _defineProperty(_classNames, "".concat(scrollbarPrefixCls, "-visible"), visible), _classNames)),
|
|
7168
|
-
style: _objectSpread2(_objectSpread2({}, containerStyle), style),
|
|
7169
|
-
onMouseDown: onContainerMouseDown,
|
|
7170
|
-
onMouseMove: delayHidden
|
|
7171
|
-
}, /*#__PURE__*/React$4.createElement("div", {
|
|
7172
|
-
ref: thumbRef,
|
|
7173
|
-
className: classNames("".concat(scrollbarPrefixCls, "-thumb"), _defineProperty({}, "".concat(scrollbarPrefixCls, "-thumb-moving"), dragging)),
|
|
7174
|
-
style: _objectSpread2(_objectSpread2({}, thumbStyle), propsThumbStyle),
|
|
7175
|
-
onMouseDown: onThumbMouseDown
|
|
7176
|
-
}));
|
|
7177
|
-
});
|
|
7178
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
7179
|
-
ScrollBar.displayName = 'ScrollBar';
|
|
7180
|
-
}
|
|
7181
7226
|
|
|
7182
|
-
|
|
7183
|
-
|
|
7184
|
-
|
|
7185
|
-
|
|
7186
|
-
|
|
7187
|
-
|
|
7188
|
-
return /*#__PURE__*/React$4.cloneElement(children, {
|
|
7189
|
-
ref: refFunc
|
|
7190
|
-
});
|
|
7227
|
+
// A patch for firefox
|
|
7228
|
+
function onFireFoxScroll(event) {
|
|
7229
|
+
if (!inVirtual) return;
|
|
7230
|
+
isMouseScrollRef.current = event.detail === wheelValueRef.current;
|
|
7231
|
+
}
|
|
7232
|
+
return [onWheel, onFireFoxScroll];
|
|
7191
7233
|
}
|
|
7192
7234
|
|
|
7193
|
-
|
|
7194
|
-
|
|
7195
|
-
|
|
7196
|
-
|
|
7197
|
-
|
|
7198
|
-
|
|
7199
|
-
|
|
7200
|
-
|
|
7201
|
-
|
|
7202
|
-
|
|
7203
|
-
|
|
7204
|
-
|
|
7205
|
-
|
|
7206
|
-
|
|
7235
|
+
/**
|
|
7236
|
+
* Size info need loop query for the `heights` which will has the perf issue.
|
|
7237
|
+
* Let cache result for each render phase.
|
|
7238
|
+
*/
|
|
7239
|
+
function useGetSize(mergedData, getKey, heights, itemHeight) {
|
|
7240
|
+
var _React$useMemo = React$4.useMemo(function () {
|
|
7241
|
+
return [new Map(), []];
|
|
7242
|
+
}, [mergedData, heights.id, itemHeight]),
|
|
7243
|
+
_React$useMemo2 = _slicedToArray(_React$useMemo, 2),
|
|
7244
|
+
key2Index = _React$useMemo2[0],
|
|
7245
|
+
bottomList = _React$useMemo2[1];
|
|
7246
|
+
var getSize = function getSize(startKey) {
|
|
7247
|
+
var endKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : startKey;
|
|
7248
|
+
// Get from cache first
|
|
7249
|
+
var startIndex = key2Index.get(startKey);
|
|
7250
|
+
var endIndex = key2Index.get(endKey);
|
|
7251
|
+
|
|
7252
|
+
// Loop to fill the cache
|
|
7253
|
+
if (startIndex === undefined || endIndex === undefined) {
|
|
7254
|
+
var dataLen = mergedData.length;
|
|
7255
|
+
for (var i = bottomList.length; i < dataLen; i += 1) {
|
|
7256
|
+
var _heights$get;
|
|
7257
|
+
var item = mergedData[i];
|
|
7258
|
+
var key = getKey(item);
|
|
7259
|
+
key2Index.set(key, i);
|
|
7260
|
+
var cacheHeight = (_heights$get = heights.get(key)) !== null && _heights$get !== void 0 ? _heights$get : itemHeight;
|
|
7261
|
+
bottomList[i] = (bottomList[i - 1] || 0) + cacheHeight;
|
|
7262
|
+
if (key === startKey) {
|
|
7263
|
+
startIndex = i;
|
|
7264
|
+
}
|
|
7265
|
+
if (key === endKey) {
|
|
7266
|
+
endIndex = i;
|
|
7267
|
+
}
|
|
7268
|
+
if (startIndex !== undefined && endIndex !== undefined) {
|
|
7269
|
+
break;
|
|
7270
|
+
}
|
|
7207
7271
|
}
|
|
7208
|
-
}
|
|
7209
|
-
|
|
7272
|
+
}
|
|
7273
|
+
return {
|
|
7274
|
+
top: bottomList[startIndex - 1] || 0,
|
|
7275
|
+
bottom: bottomList[endIndex]
|
|
7276
|
+
};
|
|
7277
|
+
};
|
|
7278
|
+
return getSize;
|
|
7210
7279
|
}
|
|
7211
7280
|
|
|
7212
7281
|
// Firefox has low performance of map.
|
|
7213
7282
|
var CacheMap = /*#__PURE__*/function () {
|
|
7214
7283
|
function CacheMap() {
|
|
7215
7284
|
_classCallCheck(this, CacheMap);
|
|
7216
|
-
this
|
|
7285
|
+
_defineProperty(this, "maps", void 0);
|
|
7217
7286
|
// Used for cache key
|
|
7218
7287
|
// `useMemo` no need to update if `id` not change
|
|
7219
|
-
this
|
|
7288
|
+
_defineProperty(this, "id", 0);
|
|
7220
7289
|
this.maps = Object.create(null);
|
|
7221
7290
|
}
|
|
7222
7291
|
_createClass(CacheMap, [{
|
|
@@ -7258,6 +7327,7 @@ function useHeights(getKey, onItemAdd, onItemRemove) {
|
|
|
7258
7327
|
}
|
|
7259
7328
|
}
|
|
7260
7329
|
});
|
|
7330
|
+
|
|
7261
7331
|
// Always trigger update mark to tell parent that should re-calculate heights when resized
|
|
7262
7332
|
setUpdatedMark(function (c) {
|
|
7263
7333
|
return c + 1;
|
|
@@ -7278,12 +7348,13 @@ function useHeights(getKey, onItemAdd, onItemRemove) {
|
|
|
7278
7348
|
} else {
|
|
7279
7349
|
instanceRef.current.delete(key);
|
|
7280
7350
|
}
|
|
7351
|
+
|
|
7281
7352
|
// Instance changed
|
|
7282
7353
|
if (!origin !== !instance) {
|
|
7283
7354
|
if (instance) {
|
|
7284
|
-
onItemAdd === null || onItemAdd === void 0
|
|
7355
|
+
onItemAdd === null || onItemAdd === void 0 || onItemAdd(item);
|
|
7285
7356
|
} else {
|
|
7286
|
-
onItemRemove === null || onItemRemove === void 0
|
|
7357
|
+
onItemRemove === null || onItemRemove === void 0 || onItemRemove(item);
|
|
7287
7358
|
}
|
|
7288
7359
|
}
|
|
7289
7360
|
}
|
|
@@ -7293,6 +7364,69 @@ function useHeights(getKey, onItemAdd, onItemRemove) {
|
|
|
7293
7364
|
return [setInstanceRef, collectHeight, heightsRef.current, updatedMark];
|
|
7294
7365
|
}
|
|
7295
7366
|
|
|
7367
|
+
var SMOOTH_PTG = 14 / 15;
|
|
7368
|
+
function useMobileTouchMove(inVirtual, listRef, callback) {
|
|
7369
|
+
var touchedRef = useRef(false);
|
|
7370
|
+
var touchYRef = useRef(0);
|
|
7371
|
+
var elementRef = useRef(null);
|
|
7372
|
+
|
|
7373
|
+
// Smooth scroll
|
|
7374
|
+
var intervalRef = useRef(null);
|
|
7375
|
+
|
|
7376
|
+
/* eslint-disable prefer-const */
|
|
7377
|
+
var cleanUpEvents;
|
|
7378
|
+
var onTouchMove = function onTouchMove(e) {
|
|
7379
|
+
if (touchedRef.current) {
|
|
7380
|
+
var currentY = Math.ceil(e.touches[0].pageY);
|
|
7381
|
+
var _offsetY = touchYRef.current - currentY;
|
|
7382
|
+
touchYRef.current = currentY;
|
|
7383
|
+
if (callback(_offsetY)) {
|
|
7384
|
+
e.preventDefault();
|
|
7385
|
+
}
|
|
7386
|
+
|
|
7387
|
+
// Smooth interval
|
|
7388
|
+
clearInterval(intervalRef.current);
|
|
7389
|
+
intervalRef.current = setInterval(function () {
|
|
7390
|
+
_offsetY *= SMOOTH_PTG;
|
|
7391
|
+
if (!callback(_offsetY, true) || Math.abs(_offsetY) <= 0.1) {
|
|
7392
|
+
clearInterval(intervalRef.current);
|
|
7393
|
+
}
|
|
7394
|
+
}, 16);
|
|
7395
|
+
}
|
|
7396
|
+
};
|
|
7397
|
+
var onTouchEnd = function onTouchEnd() {
|
|
7398
|
+
touchedRef.current = false;
|
|
7399
|
+
cleanUpEvents();
|
|
7400
|
+
};
|
|
7401
|
+
var onTouchStart = function onTouchStart(e) {
|
|
7402
|
+
cleanUpEvents();
|
|
7403
|
+
if (e.touches.length === 1 && !touchedRef.current) {
|
|
7404
|
+
touchedRef.current = true;
|
|
7405
|
+
touchYRef.current = Math.ceil(e.touches[0].pageY);
|
|
7406
|
+
elementRef.current = e.target;
|
|
7407
|
+
elementRef.current.addEventListener('touchmove', onTouchMove);
|
|
7408
|
+
elementRef.current.addEventListener('touchend', onTouchEnd);
|
|
7409
|
+
}
|
|
7410
|
+
};
|
|
7411
|
+
cleanUpEvents = function cleanUpEvents() {
|
|
7412
|
+
if (elementRef.current) {
|
|
7413
|
+
elementRef.current.removeEventListener('touchmove', onTouchMove);
|
|
7414
|
+
elementRef.current.removeEventListener('touchend', onTouchEnd);
|
|
7415
|
+
}
|
|
7416
|
+
};
|
|
7417
|
+
useLayoutEffect$3(function () {
|
|
7418
|
+
if (inVirtual) {
|
|
7419
|
+
listRef.current.addEventListener('touchstart', onTouchStart);
|
|
7420
|
+
}
|
|
7421
|
+
return function () {
|
|
7422
|
+
var _listRef$current;
|
|
7423
|
+
(_listRef$current = listRef.current) === null || _listRef$current === void 0 || _listRef$current.removeEventListener('touchstart', onTouchStart);
|
|
7424
|
+
cleanUpEvents();
|
|
7425
|
+
clearInterval(intervalRef.current);
|
|
7426
|
+
};
|
|
7427
|
+
}, [inVirtual]);
|
|
7428
|
+
}
|
|
7429
|
+
|
|
7296
7430
|
var MAX_TIMES = 10;
|
|
7297
7431
|
function useScrollTo(containerRef, data, heights, itemHeight, getKey, collectHeight, syncScrollTop, triggerFlash) {
|
|
7298
7432
|
var scrollRef = React$4.useRef();
|
|
@@ -7300,6 +7434,7 @@ function useScrollTo(containerRef, data, heights, itemHeight, getKey, collectHei
|
|
|
7300
7434
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
7301
7435
|
syncState = _React$useState2[0],
|
|
7302
7436
|
setSyncState = _React$useState2[1];
|
|
7437
|
+
|
|
7303
7438
|
// ========================== Sync Scroll ==========================
|
|
7304
7439
|
useLayoutEffect$3(function () {
|
|
7305
7440
|
if (syncState && syncState.times < MAX_TIMES) {
|
|
@@ -7319,9 +7454,11 @@ function useScrollTo(containerRef, data, heights, itemHeight, getKey, collectHei
|
|
|
7319
7454
|
var needCollectHeight = false;
|
|
7320
7455
|
var newTargetAlign = targetAlign;
|
|
7321
7456
|
var targetTop = null;
|
|
7457
|
+
|
|
7322
7458
|
// Go to next frame if height not exist
|
|
7323
7459
|
if (height) {
|
|
7324
7460
|
var mergedAlign = targetAlign || originAlign;
|
|
7461
|
+
|
|
7325
7462
|
// Get top & bottom
|
|
7326
7463
|
var stackTop = 0;
|
|
7327
7464
|
var itemTop = 0;
|
|
@@ -7334,6 +7471,7 @@ function useScrollTo(containerRef, data, heights, itemHeight, getKey, collectHei
|
|
|
7334
7471
|
itemBottom = itemTop + (cacheHeight === undefined ? itemHeight : cacheHeight);
|
|
7335
7472
|
stackTop = itemBottom;
|
|
7336
7473
|
}
|
|
7474
|
+
|
|
7337
7475
|
// Check if need sync height (visible range has item not record height)
|
|
7338
7476
|
var leftHeight = mergedAlign === 'top' ? offset : height - offset;
|
|
7339
7477
|
for (var _i = maxLen; _i >= 0; _i -= 1) {
|
|
@@ -7348,6 +7486,7 @@ function useScrollTo(containerRef, data, heights, itemHeight, getKey, collectHei
|
|
|
7348
7486
|
break;
|
|
7349
7487
|
}
|
|
7350
7488
|
}
|
|
7489
|
+
|
|
7351
7490
|
// Scroll to
|
|
7352
7491
|
switch (mergedAlign) {
|
|
7353
7492
|
case 'top':
|
|
@@ -7370,11 +7509,13 @@ function useScrollTo(containerRef, data, heights, itemHeight, getKey, collectHei
|
|
|
7370
7509
|
if (targetTop !== null) {
|
|
7371
7510
|
syncScrollTop(targetTop);
|
|
7372
7511
|
}
|
|
7512
|
+
|
|
7373
7513
|
// One more time for sync
|
|
7374
7514
|
if (targetTop !== syncState.lastTop) {
|
|
7375
7515
|
needCollectHeight = true;
|
|
7376
7516
|
}
|
|
7377
7517
|
}
|
|
7518
|
+
|
|
7378
7519
|
// Trigger next effect
|
|
7379
7520
|
if (needCollectHeight) {
|
|
7380
7521
|
setSyncState(_objectSpread2(_objectSpread2({}, syncState), {}, {
|
|
@@ -7387,6 +7528,7 @@ function useScrollTo(containerRef, data, heights, itemHeight, getKey, collectHei
|
|
|
7387
7528
|
warningOnce(false, 'Seems `scrollTo` with `rc-virtual-list` reach the max limitation. Please fire issue for us. Thanks.');
|
|
7388
7529
|
}
|
|
7389
7530
|
}, [syncState, containerRef.current]);
|
|
7531
|
+
|
|
7390
7532
|
// =========================== Scroll To ===========================
|
|
7391
7533
|
return function (arg) {
|
|
7392
7534
|
// When not argument provided, we think dev may want to show the scrollbar
|
|
@@ -7394,342 +7536,276 @@ function useScrollTo(containerRef, data, heights, itemHeight, getKey, collectHei
|
|
|
7394
7536
|
triggerFlash();
|
|
7395
7537
|
return;
|
|
7396
7538
|
}
|
|
7397
|
-
|
|
7398
|
-
|
|
7399
|
-
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
|
|
7403
|
-
var
|
|
7404
|
-
|
|
7405
|
-
|
|
7406
|
-
|
|
7407
|
-
|
|
7408
|
-
|
|
7409
|
-
|
|
7410
|
-
|
|
7411
|
-
|
|
7412
|
-
|
|
7413
|
-
|
|
7414
|
-
|
|
7415
|
-
|
|
7416
|
-
|
|
7417
|
-
|
|
7418
|
-
|
|
7419
|
-
|
|
7420
|
-
|
|
7421
|
-
}
|
|
7422
|
-
|
|
7423
|
-
/**
|
|
7424
|
-
* Get index with specific start index one by one. e.g.
|
|
7425
|
-
* min: 3, max: 9, start: 6
|
|
7426
|
-
*
|
|
7427
|
-
* Return index is:
|
|
7428
|
-
* [0]: 6
|
|
7429
|
-
* [1]: 7
|
|
7430
|
-
* [2]: 5
|
|
7431
|
-
* [3]: 8
|
|
7432
|
-
* [4]: 4
|
|
7433
|
-
* [5]: 9
|
|
7434
|
-
* [6]: 3
|
|
7435
|
-
*/
|
|
7436
|
-
/**
|
|
7437
|
-
* We assume that 2 list has only 1 item diff and others keeping the order.
|
|
7438
|
-
* So we can use dichotomy algorithm to find changed one.
|
|
7439
|
-
*/
|
|
7440
|
-
function findListDiffIndex(originList, targetList, getKey) {
|
|
7441
|
-
var originLen = originList.length;
|
|
7442
|
-
var targetLen = targetList.length;
|
|
7443
|
-
var shortList;
|
|
7444
|
-
var longList;
|
|
7445
|
-
if (originLen === 0 && targetLen === 0) {
|
|
7446
|
-
return null;
|
|
7447
|
-
}
|
|
7448
|
-
if (originLen < targetLen) {
|
|
7449
|
-
shortList = originList;
|
|
7450
|
-
longList = targetList;
|
|
7451
|
-
} else {
|
|
7452
|
-
shortList = targetList;
|
|
7453
|
-
longList = originList;
|
|
7454
|
-
}
|
|
7455
|
-
var notExistKey = {
|
|
7456
|
-
__EMPTY_ITEM__: true
|
|
7457
|
-
};
|
|
7458
|
-
function getItemKey(item) {
|
|
7459
|
-
if (item !== undefined) {
|
|
7460
|
-
return getKey(item);
|
|
7461
|
-
}
|
|
7462
|
-
return notExistKey;
|
|
7463
|
-
}
|
|
7464
|
-
// Loop to find diff one
|
|
7465
|
-
var diffIndex = null;
|
|
7466
|
-
var multiple = Math.abs(originLen - targetLen) !== 1;
|
|
7467
|
-
for (var i = 0; i < longList.length; i += 1) {
|
|
7468
|
-
var shortKey = getItemKey(shortList[i]);
|
|
7469
|
-
var longKey = getItemKey(longList[i]);
|
|
7470
|
-
if (shortKey !== longKey) {
|
|
7471
|
-
diffIndex = i;
|
|
7472
|
-
multiple = multiple || shortKey !== getItemKey(longList[i + 1]);
|
|
7473
|
-
break;
|
|
7474
|
-
}
|
|
7475
|
-
}
|
|
7476
|
-
return diffIndex === null ? null : {
|
|
7477
|
-
index: diffIndex,
|
|
7478
|
-
multiple: multiple
|
|
7539
|
+
|
|
7540
|
+
// Normal scroll logic
|
|
7541
|
+
wrapperRaf.cancel(scrollRef.current);
|
|
7542
|
+
if (typeof arg === 'number') {
|
|
7543
|
+
syncScrollTop(arg);
|
|
7544
|
+
} else if (arg && _typeof$1(arg) === 'object') {
|
|
7545
|
+
var index;
|
|
7546
|
+
var align = arg.align;
|
|
7547
|
+
if ('index' in arg) {
|
|
7548
|
+
index = arg.index;
|
|
7549
|
+
} else {
|
|
7550
|
+
index = data.findIndex(function (item) {
|
|
7551
|
+
return getKey(item) === arg.key;
|
|
7552
|
+
});
|
|
7553
|
+
}
|
|
7554
|
+
var _arg$offset = arg.offset,
|
|
7555
|
+
offset = _arg$offset === void 0 ? 0 : _arg$offset;
|
|
7556
|
+
setSyncState({
|
|
7557
|
+
times: 0,
|
|
7558
|
+
index: index,
|
|
7559
|
+
offset: offset,
|
|
7560
|
+
originAlign: align
|
|
7561
|
+
});
|
|
7562
|
+
}
|
|
7479
7563
|
};
|
|
7480
7564
|
}
|
|
7481
7565
|
|
|
7482
|
-
function
|
|
7483
|
-
var
|
|
7566
|
+
function getPageXY(e, horizontal) {
|
|
7567
|
+
var obj = 'touches' in e ? e.touches[0] : e;
|
|
7568
|
+
return obj[horizontal ? 'pageX' : 'pageY'];
|
|
7569
|
+
}
|
|
7570
|
+
var ScrollBar = /*#__PURE__*/React$4.forwardRef(function (props, ref) {
|
|
7571
|
+
var prefixCls = props.prefixCls,
|
|
7572
|
+
rtl = props.rtl,
|
|
7573
|
+
scrollOffset = props.scrollOffset,
|
|
7574
|
+
scrollRange = props.scrollRange,
|
|
7575
|
+
onStartMove = props.onStartMove,
|
|
7576
|
+
onStopMove = props.onStopMove,
|
|
7577
|
+
onScroll = props.onScroll,
|
|
7578
|
+
horizontal = props.horizontal,
|
|
7579
|
+
spinSize = props.spinSize,
|
|
7580
|
+
containerSize = props.containerSize,
|
|
7581
|
+
style = props.style,
|
|
7582
|
+
propsThumbStyle = props.thumbStyle;
|
|
7583
|
+
var _React$useState = React$4.useState(false),
|
|
7484
7584
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
7485
|
-
|
|
7486
|
-
|
|
7585
|
+
dragging = _React$useState2[0],
|
|
7586
|
+
setDragging = _React$useState2[1];
|
|
7487
7587
|
var _React$useState3 = React$4.useState(null),
|
|
7488
7588
|
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
7489
|
-
|
|
7490
|
-
|
|
7491
|
-
React$4.
|
|
7492
|
-
|
|
7493
|
-
|
|
7494
|
-
|
|
7495
|
-
|
|
7589
|
+
pageXY = _React$useState4[0],
|
|
7590
|
+
setPageXY = _React$useState4[1];
|
|
7591
|
+
var _React$useState5 = React$4.useState(null),
|
|
7592
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
7593
|
+
startTop = _React$useState6[0],
|
|
7594
|
+
setStartTop = _React$useState6[1];
|
|
7595
|
+
var isLTR = !rtl;
|
|
7596
|
+
|
|
7597
|
+
// ========================= Refs =========================
|
|
7598
|
+
var scrollbarRef = React$4.useRef();
|
|
7599
|
+
var thumbRef = React$4.useRef();
|
|
7600
|
+
|
|
7601
|
+
// ======================= Visible ========================
|
|
7602
|
+
var _React$useState7 = React$4.useState(false),
|
|
7603
|
+
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
7604
|
+
visible = _React$useState8[0],
|
|
7605
|
+
setVisible = _React$useState8[1];
|
|
7606
|
+
var visibleTimeoutRef = React$4.useRef();
|
|
7607
|
+
var delayHidden = function delayHidden() {
|
|
7608
|
+
clearTimeout(visibleTimeoutRef.current);
|
|
7609
|
+
setVisible(true);
|
|
7610
|
+
visibleTimeoutRef.current = setTimeout(function () {
|
|
7611
|
+
setVisible(false);
|
|
7612
|
+
}, 3000);
|
|
7613
|
+
};
|
|
7614
|
+
|
|
7615
|
+
// ======================== Range =========================
|
|
7616
|
+
var enableScrollRange = scrollRange - containerSize || 0;
|
|
7617
|
+
var enableOffsetRange = containerSize - spinSize || 0;
|
|
7618
|
+
|
|
7619
|
+
// ========================= Top ==========================
|
|
7620
|
+
var top = React$4.useMemo(function () {
|
|
7621
|
+
if (scrollOffset === 0 || enableScrollRange === 0) {
|
|
7622
|
+
return 0;
|
|
7496
7623
|
}
|
|
7497
|
-
|
|
7498
|
-
|
|
7499
|
-
|
|
7500
|
-
}
|
|
7624
|
+
var ptg = scrollOffset / enableScrollRange;
|
|
7625
|
+
return ptg * enableOffsetRange;
|
|
7626
|
+
}, [scrollOffset, enableScrollRange, enableOffsetRange]);
|
|
7501
7627
|
|
|
7502
|
-
|
|
7628
|
+
// ====================== Container =======================
|
|
7629
|
+
var onContainerMouseDown = function onContainerMouseDown(e) {
|
|
7630
|
+
e.stopPropagation();
|
|
7631
|
+
e.preventDefault();
|
|
7632
|
+
};
|
|
7503
7633
|
|
|
7504
|
-
|
|
7505
|
-
|
|
7506
|
-
|
|
7507
|
-
|
|
7508
|
-
|
|
7509
|
-
|
|
7510
|
-
lockRef.current = true;
|
|
7511
|
-
lockTimeoutRef.current = setTimeout(function () {
|
|
7512
|
-
lockRef.current = false;
|
|
7513
|
-
}, 50);
|
|
7514
|
-
}
|
|
7515
|
-
// Pass to ref since global add is in closure
|
|
7516
|
-
var scrollPingRef = useRef({
|
|
7517
|
-
top: isScrollAtTop,
|
|
7518
|
-
bottom: isScrollAtBottom
|
|
7634
|
+
// ======================== Thumb =========================
|
|
7635
|
+
var stateRef = React$4.useRef({
|
|
7636
|
+
top: top,
|
|
7637
|
+
dragging: dragging,
|
|
7638
|
+
pageY: pageXY,
|
|
7639
|
+
startTop: startTop
|
|
7519
7640
|
});
|
|
7520
|
-
|
|
7521
|
-
|
|
7522
|
-
|
|
7523
|
-
|
|
7524
|
-
|
|
7525
|
-
|
|
7526
|
-
|
|
7527
|
-
|
|
7528
|
-
|
|
7529
|
-
|
|
7530
|
-
|
|
7531
|
-
|
|
7532
|
-
|
|
7533
|
-
} else if (!originScroll || lockRef.current) {
|
|
7534
|
-
lockScroll();
|
|
7535
|
-
}
|
|
7536
|
-
return !lockRef.current && originScroll;
|
|
7641
|
+
stateRef.current = {
|
|
7642
|
+
top: top,
|
|
7643
|
+
dragging: dragging,
|
|
7644
|
+
pageY: pageXY,
|
|
7645
|
+
startTop: startTop
|
|
7646
|
+
};
|
|
7647
|
+
var onThumbMouseDown = function onThumbMouseDown(e) {
|
|
7648
|
+
setDragging(true);
|
|
7649
|
+
setPageXY(getPageXY(e, horizontal));
|
|
7650
|
+
setStartTop(stateRef.current.top);
|
|
7651
|
+
onStartMove();
|
|
7652
|
+
e.stopPropagation();
|
|
7653
|
+
e.preventDefault();
|
|
7537
7654
|
};
|
|
7538
|
-
});
|
|
7539
7655
|
|
|
7540
|
-
|
|
7541
|
-
/***
|
|
7542
|
-
* Return `true` when you need to prevent default event
|
|
7543
|
-
*/
|
|
7544
|
-
onWheelDelta) {
|
|
7545
|
-
var offsetRef = useRef(0);
|
|
7546
|
-
var nextFrameRef = useRef(null);
|
|
7547
|
-
// Firefox patch
|
|
7548
|
-
var wheelValueRef = useRef(null);
|
|
7549
|
-
var isMouseScrollRef = useRef(false);
|
|
7550
|
-
// Scroll status sync
|
|
7551
|
-
var originScroll = useOriginScroll(isScrollAtTop, isScrollAtBottom);
|
|
7552
|
-
function onWheelY(event, deltaY) {
|
|
7553
|
-
wrapperRaf.cancel(nextFrameRef.current);
|
|
7554
|
-
offsetRef.current += deltaY;
|
|
7555
|
-
wheelValueRef.current = deltaY;
|
|
7556
|
-
// Do nothing when scroll at the edge, Skip check when is in scroll
|
|
7557
|
-
if (originScroll(deltaY)) return;
|
|
7558
|
-
// Proxy of scroll events
|
|
7559
|
-
if (!isFF) {
|
|
7560
|
-
event.preventDefault();
|
|
7561
|
-
}
|
|
7562
|
-
nextFrameRef.current = wrapperRaf(function () {
|
|
7563
|
-
// Patch a multiple for Firefox to fix wheel number too small
|
|
7564
|
-
// ref: https://github.com/ant-design/ant-design/issues/26372#issuecomment-679460266
|
|
7565
|
-
var patchMultiple = isMouseScrollRef.current ? 10 : 1;
|
|
7566
|
-
onWheelDelta(offsetRef.current * patchMultiple);
|
|
7567
|
-
offsetRef.current = 0;
|
|
7568
|
-
});
|
|
7569
|
-
}
|
|
7570
|
-
function onWheelX(event, deltaX) {
|
|
7571
|
-
onWheelDelta(deltaX, true);
|
|
7572
|
-
if (!isFF) {
|
|
7573
|
-
event.preventDefault();
|
|
7574
|
-
}
|
|
7575
|
-
}
|
|
7576
|
-
// Check for which direction does wheel do. `sx` means `shift + wheel`
|
|
7577
|
-
var wheelDirectionRef = useRef(null);
|
|
7578
|
-
var wheelDirectionCleanRef = useRef(null);
|
|
7579
|
-
function onWheel(event) {
|
|
7580
|
-
if (!inVirtual) return;
|
|
7581
|
-
// Wait for 2 frame to clean direction
|
|
7582
|
-
wrapperRaf.cancel(wheelDirectionCleanRef.current);
|
|
7583
|
-
wheelDirectionCleanRef.current = wrapperRaf(function () {
|
|
7584
|
-
wheelDirectionRef.current = null;
|
|
7585
|
-
}, 2);
|
|
7586
|
-
var deltaX = event.deltaX,
|
|
7587
|
-
deltaY = event.deltaY,
|
|
7588
|
-
shiftKey = event.shiftKey;
|
|
7589
|
-
var mergedDeltaX = deltaX;
|
|
7590
|
-
var mergedDeltaY = deltaY;
|
|
7591
|
-
if (wheelDirectionRef.current === 'sx' || !wheelDirectionRef.current && (shiftKey || false) && deltaY && !deltaX) {
|
|
7592
|
-
mergedDeltaX = deltaY;
|
|
7593
|
-
mergedDeltaY = 0;
|
|
7594
|
-
wheelDirectionRef.current = 'sx';
|
|
7595
|
-
}
|
|
7596
|
-
var absX = Math.abs(mergedDeltaX);
|
|
7597
|
-
var absY = Math.abs(mergedDeltaY);
|
|
7598
|
-
if (wheelDirectionRef.current === null) {
|
|
7599
|
-
wheelDirectionRef.current = horizontalScroll && absX > absY ? 'x' : 'y';
|
|
7600
|
-
}
|
|
7601
|
-
if (wheelDirectionRef.current === 'y') {
|
|
7602
|
-
onWheelY(event, mergedDeltaY);
|
|
7603
|
-
} else {
|
|
7604
|
-
onWheelX(event, mergedDeltaX);
|
|
7605
|
-
}
|
|
7606
|
-
}
|
|
7607
|
-
// A patch for firefox
|
|
7608
|
-
function onFireFoxScroll(event) {
|
|
7609
|
-
if (!inVirtual) return;
|
|
7610
|
-
isMouseScrollRef.current = event.detail === wheelValueRef.current;
|
|
7611
|
-
}
|
|
7612
|
-
return [onWheel, onFireFoxScroll];
|
|
7613
|
-
}
|
|
7656
|
+
// ======================== Effect ========================
|
|
7614
7657
|
|
|
7615
|
-
|
|
7616
|
-
|
|
7617
|
-
|
|
7618
|
-
|
|
7619
|
-
|
|
7620
|
-
|
|
7621
|
-
|
|
7622
|
-
|
|
7623
|
-
|
|
7624
|
-
|
|
7625
|
-
|
|
7626
|
-
|
|
7627
|
-
|
|
7628
|
-
|
|
7629
|
-
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
|
|
7633
|
-
|
|
7634
|
-
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
|
|
7658
|
+
// React make event as passive, but we need to preventDefault
|
|
7659
|
+
// Add event on dom directly instead.
|
|
7660
|
+
// ref: https://github.com/facebook/react/issues/9809
|
|
7661
|
+
React$4.useEffect(function () {
|
|
7662
|
+
var onScrollbarTouchStart = function onScrollbarTouchStart(e) {
|
|
7663
|
+
e.preventDefault();
|
|
7664
|
+
};
|
|
7665
|
+
var scrollbarEle = scrollbarRef.current;
|
|
7666
|
+
var thumbEle = thumbRef.current;
|
|
7667
|
+
scrollbarEle.addEventListener('touchstart', onScrollbarTouchStart);
|
|
7668
|
+
thumbEle.addEventListener('touchstart', onThumbMouseDown);
|
|
7669
|
+
return function () {
|
|
7670
|
+
scrollbarEle.removeEventListener('touchstart', onScrollbarTouchStart);
|
|
7671
|
+
thumbEle.removeEventListener('touchstart', onThumbMouseDown);
|
|
7672
|
+
};
|
|
7673
|
+
}, []);
|
|
7674
|
+
|
|
7675
|
+
// Pass to effect
|
|
7676
|
+
var enableScrollRangeRef = React$4.useRef();
|
|
7677
|
+
enableScrollRangeRef.current = enableScrollRange;
|
|
7678
|
+
var enableOffsetRangeRef = React$4.useRef();
|
|
7679
|
+
enableOffsetRangeRef.current = enableOffsetRange;
|
|
7680
|
+
React$4.useEffect(function () {
|
|
7681
|
+
if (dragging) {
|
|
7682
|
+
var moveRafId;
|
|
7683
|
+
var onMouseMove = function onMouseMove(e) {
|
|
7684
|
+
var _stateRef$current = stateRef.current,
|
|
7685
|
+
stateDragging = _stateRef$current.dragging,
|
|
7686
|
+
statePageY = _stateRef$current.pageY,
|
|
7687
|
+
stateStartTop = _stateRef$current.startTop;
|
|
7688
|
+
wrapperRaf.cancel(moveRafId);
|
|
7689
|
+
if (stateDragging) {
|
|
7690
|
+
var offset = getPageXY(e, horizontal) - statePageY;
|
|
7691
|
+
var newTop = stateStartTop;
|
|
7692
|
+
if (!isLTR && horizontal) {
|
|
7693
|
+
newTop -= offset;
|
|
7694
|
+
} else {
|
|
7695
|
+
newTop += offset;
|
|
7696
|
+
}
|
|
7697
|
+
var tmpEnableScrollRange = enableScrollRangeRef.current;
|
|
7698
|
+
var tmpEnableOffsetRange = enableOffsetRangeRef.current;
|
|
7699
|
+
var ptg = tmpEnableOffsetRange ? newTop / tmpEnableOffsetRange : 0;
|
|
7700
|
+
var newScrollTop = Math.ceil(ptg * tmpEnableScrollRange);
|
|
7701
|
+
newScrollTop = Math.max(newScrollTop, 0);
|
|
7702
|
+
newScrollTop = Math.min(newScrollTop, tmpEnableScrollRange);
|
|
7703
|
+
moveRafId = wrapperRaf(function () {
|
|
7704
|
+
onScroll(newScrollTop, horizontal);
|
|
7705
|
+
});
|
|
7638
7706
|
}
|
|
7639
|
-
}
|
|
7707
|
+
};
|
|
7708
|
+
var onMouseUp = function onMouseUp() {
|
|
7709
|
+
setDragging(false);
|
|
7710
|
+
onStopMove();
|
|
7711
|
+
};
|
|
7712
|
+
window.addEventListener('mousemove', onMouseMove);
|
|
7713
|
+
window.addEventListener('touchmove', onMouseMove);
|
|
7714
|
+
window.addEventListener('mouseup', onMouseUp);
|
|
7715
|
+
window.addEventListener('touchend', onMouseUp);
|
|
7716
|
+
return function () {
|
|
7717
|
+
window.removeEventListener('mousemove', onMouseMove);
|
|
7718
|
+
window.removeEventListener('touchmove', onMouseMove);
|
|
7719
|
+
window.removeEventListener('mouseup', onMouseUp);
|
|
7720
|
+
window.removeEventListener('touchend', onMouseUp);
|
|
7721
|
+
wrapperRaf.cancel(moveRafId);
|
|
7722
|
+
};
|
|
7640
7723
|
}
|
|
7724
|
+
}, [dragging]);
|
|
7725
|
+
React$4.useEffect(function () {
|
|
7726
|
+
delayHidden();
|
|
7727
|
+
}, [scrollOffset]);
|
|
7728
|
+
|
|
7729
|
+
// ====================== Imperative ======================
|
|
7730
|
+
React$4.useImperativeHandle(ref, function () {
|
|
7731
|
+
return {
|
|
7732
|
+
delayHidden: delayHidden
|
|
7733
|
+
};
|
|
7734
|
+
});
|
|
7735
|
+
|
|
7736
|
+
// ======================== Render ========================
|
|
7737
|
+
var scrollbarPrefixCls = "".concat(prefixCls, "-scrollbar");
|
|
7738
|
+
var containerStyle = {
|
|
7739
|
+
position: 'absolute',
|
|
7740
|
+
visibility: visible ? null : 'hidden'
|
|
7641
7741
|
};
|
|
7642
|
-
var
|
|
7643
|
-
|
|
7644
|
-
|
|
7645
|
-
|
|
7646
|
-
|
|
7647
|
-
|
|
7648
|
-
if (e.touches.length === 1 && !touchedRef.current) {
|
|
7649
|
-
touchedRef.current = true;
|
|
7650
|
-
touchYRef.current = Math.ceil(e.touches[0].pageY);
|
|
7651
|
-
elementRef.current = e.target;
|
|
7652
|
-
elementRef.current.addEventListener('touchmove', onTouchMove);
|
|
7653
|
-
elementRef.current.addEventListener('touchend', onTouchEnd);
|
|
7654
|
-
}
|
|
7742
|
+
var thumbStyle = {
|
|
7743
|
+
position: 'absolute',
|
|
7744
|
+
background: 'rgba(0, 0, 0, 0.5)',
|
|
7745
|
+
borderRadius: 99,
|
|
7746
|
+
cursor: 'pointer',
|
|
7747
|
+
userSelect: 'none'
|
|
7655
7748
|
};
|
|
7656
|
-
|
|
7657
|
-
|
|
7658
|
-
|
|
7659
|
-
|
|
7749
|
+
if (horizontal) {
|
|
7750
|
+
// Container
|
|
7751
|
+
containerStyle.height = 8;
|
|
7752
|
+
containerStyle.left = 0;
|
|
7753
|
+
containerStyle.right = 0;
|
|
7754
|
+
containerStyle.bottom = 0;
|
|
7755
|
+
|
|
7756
|
+
// Thumb
|
|
7757
|
+
thumbStyle.height = '100%';
|
|
7758
|
+
thumbStyle.width = spinSize;
|
|
7759
|
+
if (isLTR) {
|
|
7760
|
+
thumbStyle.left = top;
|
|
7761
|
+
} else {
|
|
7762
|
+
thumbStyle.right = top;
|
|
7660
7763
|
}
|
|
7661
|
-
}
|
|
7662
|
-
|
|
7663
|
-
|
|
7664
|
-
|
|
7764
|
+
} else {
|
|
7765
|
+
// Container
|
|
7766
|
+
containerStyle.width = 8;
|
|
7767
|
+
containerStyle.top = 0;
|
|
7768
|
+
containerStyle.bottom = 0;
|
|
7769
|
+
if (isLTR) {
|
|
7770
|
+
containerStyle.right = 0;
|
|
7771
|
+
} else {
|
|
7772
|
+
containerStyle.left = 0;
|
|
7665
7773
|
}
|
|
7666
|
-
|
|
7667
|
-
|
|
7668
|
-
|
|
7669
|
-
|
|
7670
|
-
|
|
7671
|
-
|
|
7672
|
-
|
|
7774
|
+
|
|
7775
|
+
// Thumb
|
|
7776
|
+
thumbStyle.width = '100%';
|
|
7777
|
+
thumbStyle.height = spinSize;
|
|
7778
|
+
thumbStyle.top = top;
|
|
7779
|
+
}
|
|
7780
|
+
return /*#__PURE__*/React$4.createElement("div", {
|
|
7781
|
+
ref: scrollbarRef,
|
|
7782
|
+
className: classNames(scrollbarPrefixCls, _defineProperty(_defineProperty(_defineProperty({}, "".concat(scrollbarPrefixCls, "-horizontal"), horizontal), "".concat(scrollbarPrefixCls, "-vertical"), !horizontal), "".concat(scrollbarPrefixCls, "-visible"), visible)),
|
|
7783
|
+
style: _objectSpread2(_objectSpread2({}, containerStyle), style),
|
|
7784
|
+
onMouseDown: onContainerMouseDown,
|
|
7785
|
+
onMouseMove: delayHidden
|
|
7786
|
+
}, /*#__PURE__*/React$4.createElement("div", {
|
|
7787
|
+
ref: thumbRef,
|
|
7788
|
+
className: classNames("".concat(scrollbarPrefixCls, "-thumb"), _defineProperty({}, "".concat(scrollbarPrefixCls, "-thumb-moving"), dragging)),
|
|
7789
|
+
style: _objectSpread2(_objectSpread2({}, thumbStyle), propsThumbStyle),
|
|
7790
|
+
onMouseDown: onThumbMouseDown
|
|
7791
|
+
}));
|
|
7792
|
+
});
|
|
7793
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
7794
|
+
ScrollBar.displayName = 'ScrollBar';
|
|
7673
7795
|
}
|
|
7674
7796
|
|
|
7675
7797
|
var MIN_SIZE = 20;
|
|
7676
7798
|
function getSpinSize() {
|
|
7677
7799
|
var containerSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
7678
7800
|
var scrollRange = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
7679
|
-
var baseSize = containerSize / scrollRange *
|
|
7801
|
+
var baseSize = containerSize / scrollRange * containerSize;
|
|
7680
7802
|
if (isNaN(baseSize)) {
|
|
7681
7803
|
baseSize = 0;
|
|
7682
7804
|
}
|
|
7683
7805
|
baseSize = Math.max(baseSize, MIN_SIZE);
|
|
7684
|
-
baseSize = Math.min(baseSize, containerSize / 2);
|
|
7685
7806
|
return Math.floor(baseSize);
|
|
7686
7807
|
}
|
|
7687
7808
|
|
|
7688
|
-
/**
|
|
7689
|
-
* Size info need loop query for the `heights` which will has the perf issue.
|
|
7690
|
-
* Let cache result for each render phase.
|
|
7691
|
-
*/
|
|
7692
|
-
function useGetSize(mergedData, getKey, heights, itemHeight) {
|
|
7693
|
-
var _React$useMemo = React$4.useMemo(function () {
|
|
7694
|
-
return [new Map(), []];
|
|
7695
|
-
}, [mergedData, heights.id, itemHeight]),
|
|
7696
|
-
_React$useMemo2 = _slicedToArray(_React$useMemo, 2),
|
|
7697
|
-
key2Index = _React$useMemo2[0],
|
|
7698
|
-
bottomList = _React$useMemo2[1];
|
|
7699
|
-
var getSize = function getSize(startKey) {
|
|
7700
|
-
var endKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : startKey;
|
|
7701
|
-
// Get from cache first
|
|
7702
|
-
var startIndex = key2Index.get(startKey);
|
|
7703
|
-
var endIndex = key2Index.get(endKey);
|
|
7704
|
-
// Loop to fill the cache
|
|
7705
|
-
if (startIndex === undefined || endIndex === undefined) {
|
|
7706
|
-
var dataLen = mergedData.length;
|
|
7707
|
-
for (var i = bottomList.length; i < dataLen; i += 1) {
|
|
7708
|
-
var _heights$get;
|
|
7709
|
-
var item = mergedData[i];
|
|
7710
|
-
var key = getKey(item);
|
|
7711
|
-
key2Index.set(key, i);
|
|
7712
|
-
var cacheHeight = (_heights$get = heights.get(key)) !== null && _heights$get !== void 0 ? _heights$get : itemHeight;
|
|
7713
|
-
bottomList[i] = (bottomList[i - 1] || 0) + cacheHeight;
|
|
7714
|
-
if (key === startKey) {
|
|
7715
|
-
startIndex = i;
|
|
7716
|
-
}
|
|
7717
|
-
if (key === endKey) {
|
|
7718
|
-
endIndex = i;
|
|
7719
|
-
}
|
|
7720
|
-
if (startIndex !== undefined && endIndex !== undefined) {
|
|
7721
|
-
break;
|
|
7722
|
-
}
|
|
7723
|
-
}
|
|
7724
|
-
}
|
|
7725
|
-
return {
|
|
7726
|
-
top: bottomList[startIndex - 1] || 0,
|
|
7727
|
-
bottom: bottomList[endIndex]
|
|
7728
|
-
};
|
|
7729
|
-
};
|
|
7730
|
-
return getSize;
|
|
7731
|
-
}
|
|
7732
|
-
|
|
7733
7809
|
var _excluded$2 = ["prefixCls", "className", "height", "itemHeight", "fullHeight", "style", "data", "children", "itemKey", "virtual", "direction", "scrollWidth", "component", "onScroll", "onVirtualScroll", "onVisibleChange", "innerProps", "extraRender", "styles"];
|
|
7734
7810
|
var EMPTY_DATA = [];
|
|
7735
7811
|
var ScrollStyle = {
|
|
@@ -7760,15 +7836,39 @@ function RawList(props, ref) {
|
|
|
7760
7836
|
extraRender = props.extraRender,
|
|
7761
7837
|
styles = props.styles,
|
|
7762
7838
|
restProps = _objectWithoutProperties(props, _excluded$2);
|
|
7839
|
+
|
|
7840
|
+
// =============================== Item Key ===============================
|
|
7841
|
+
var getKey = React$4.useCallback(function (item) {
|
|
7842
|
+
if (typeof itemKey === 'function') {
|
|
7843
|
+
return itemKey(item);
|
|
7844
|
+
}
|
|
7845
|
+
return item === null || item === void 0 ? void 0 : item[itemKey];
|
|
7846
|
+
}, [itemKey]);
|
|
7847
|
+
|
|
7848
|
+
// ================================ Height ================================
|
|
7849
|
+
var _useHeights = useHeights(getKey, null, null),
|
|
7850
|
+
_useHeights2 = _slicedToArray(_useHeights, 4),
|
|
7851
|
+
setInstanceRef = _useHeights2[0],
|
|
7852
|
+
collectHeight = _useHeights2[1],
|
|
7853
|
+
heights = _useHeights2[2],
|
|
7854
|
+
heightUpdatedMark = _useHeights2[3];
|
|
7855
|
+
|
|
7763
7856
|
// ================================= MISC =================================
|
|
7764
7857
|
var useVirtual = !!(virtual !== false && height && itemHeight);
|
|
7765
|
-
var
|
|
7858
|
+
var containerHeight = React$4.useMemo(function () {
|
|
7859
|
+
return Object.values(heights.maps).reduce(function (total, curr) {
|
|
7860
|
+
return total + curr;
|
|
7861
|
+
}, 0);
|
|
7862
|
+
}, [heights.id, heights.maps]);
|
|
7863
|
+
var inVirtual = useVirtual && data && (Math.max(itemHeight * data.length, containerHeight) > height || !!scrollWidth);
|
|
7766
7864
|
var isRTL = direction === 'rtl';
|
|
7767
7865
|
var mergedClassName = classNames(prefixCls, _defineProperty({}, "".concat(prefixCls, "-rtl"), isRTL), className);
|
|
7768
7866
|
var mergedData = data || EMPTY_DATA;
|
|
7769
7867
|
var componentRef = useRef();
|
|
7770
7868
|
var fillerInnerRef = useRef();
|
|
7869
|
+
|
|
7771
7870
|
// =============================== Item Key ===============================
|
|
7871
|
+
|
|
7772
7872
|
var _useState = useState$1(0),
|
|
7773
7873
|
_useState2 = _slicedToArray(_useState, 2),
|
|
7774
7874
|
offsetTop = _useState2[0],
|
|
@@ -7787,16 +7887,10 @@ function RawList(props, ref) {
|
|
|
7787
7887
|
var onScrollbarStopMove = function onScrollbarStopMove() {
|
|
7788
7888
|
setScrollMoving(false);
|
|
7789
7889
|
};
|
|
7790
|
-
// =============================== Item Key ===============================
|
|
7791
|
-
var getKey = React$4.useCallback(function (item) {
|
|
7792
|
-
if (typeof itemKey === 'function') {
|
|
7793
|
-
return itemKey(item);
|
|
7794
|
-
}
|
|
7795
|
-
return item === null || item === void 0 ? void 0 : item[itemKey];
|
|
7796
|
-
}, [itemKey]);
|
|
7797
7890
|
var sharedConfig = {
|
|
7798
7891
|
getKey: getKey
|
|
7799
7892
|
};
|
|
7893
|
+
|
|
7800
7894
|
// ================================ Scroll ================================
|
|
7801
7895
|
function syncScrollTop(newTop) {
|
|
7802
7896
|
setOffsetTop(function (origin) {
|
|
@@ -7811,6 +7905,7 @@ function RawList(props, ref) {
|
|
|
7811
7905
|
return alignedTop;
|
|
7812
7906
|
});
|
|
7813
7907
|
}
|
|
7908
|
+
|
|
7814
7909
|
// ================================ Legacy ================================
|
|
7815
7910
|
// Put ref here since the range is generate by follow
|
|
7816
7911
|
var rangeRef = useRef({
|
|
@@ -7822,13 +7917,7 @@ function RawList(props, ref) {
|
|
|
7822
7917
|
_useDiffItem2 = _slicedToArray(_useDiffItem, 1),
|
|
7823
7918
|
diffItem = _useDiffItem2[0];
|
|
7824
7919
|
diffItemRef.current = diffItem;
|
|
7825
|
-
|
|
7826
|
-
var _useHeights = useHeights(getKey, null, null),
|
|
7827
|
-
_useHeights2 = _slicedToArray(_useHeights, 4),
|
|
7828
|
-
setInstanceRef = _useHeights2[0],
|
|
7829
|
-
collectHeight = _useHeights2[1],
|
|
7830
|
-
heights = _useHeights2[2],
|
|
7831
|
-
heightUpdatedMark = _useHeights2[3];
|
|
7920
|
+
|
|
7832
7921
|
// ========================== Visible Calculation =========================
|
|
7833
7922
|
var _React$useMemo = React$4.useMemo(function () {
|
|
7834
7923
|
if (!useVirtual) {
|
|
@@ -7839,6 +7928,7 @@ function RawList(props, ref) {
|
|
|
7839
7928
|
offset: undefined
|
|
7840
7929
|
};
|
|
7841
7930
|
}
|
|
7931
|
+
|
|
7842
7932
|
// Always use virtual scroll bar in avoid shaking
|
|
7843
7933
|
if (!inVirtual) {
|
|
7844
7934
|
var _fillerInnerRef$curre;
|
|
@@ -7855,21 +7945,24 @@ function RawList(props, ref) {
|
|
|
7855
7945
|
var endIndex;
|
|
7856
7946
|
var dataLen = mergedData.length;
|
|
7857
7947
|
for (var i = 0; i < dataLen; i += 1) {
|
|
7858
|
-
var
|
|
7859
|
-
var key = getKey(
|
|
7948
|
+
var _item = mergedData[i];
|
|
7949
|
+
var key = getKey(_item);
|
|
7860
7950
|
var cacheHeight = heights.get(key);
|
|
7861
7951
|
var currentItemBottom = itemTop + (cacheHeight === undefined ? itemHeight : cacheHeight);
|
|
7952
|
+
|
|
7862
7953
|
// Check item top in the range
|
|
7863
7954
|
if (currentItemBottom >= offsetTop && startIndex === undefined) {
|
|
7864
7955
|
startIndex = i;
|
|
7865
7956
|
startOffset = itemTop;
|
|
7866
7957
|
}
|
|
7958
|
+
|
|
7867
7959
|
// Check item bottom in the range. We will render additional one item for motion usage
|
|
7868
7960
|
if (currentItemBottom > offsetTop + height && endIndex === undefined) {
|
|
7869
7961
|
endIndex = i;
|
|
7870
7962
|
}
|
|
7871
7963
|
itemTop = currentItemBottom;
|
|
7872
7964
|
}
|
|
7965
|
+
|
|
7873
7966
|
// When scrollTop at the end but data cut to small count will reach this
|
|
7874
7967
|
if (startIndex === undefined) {
|
|
7875
7968
|
startIndex = 0;
|
|
@@ -7879,6 +7972,7 @@ function RawList(props, ref) {
|
|
|
7879
7972
|
if (endIndex === undefined) {
|
|
7880
7973
|
endIndex = mergedData.length - 1;
|
|
7881
7974
|
}
|
|
7975
|
+
|
|
7882
7976
|
// Give cache to improve scroll experience
|
|
7883
7977
|
endIndex = Math.min(endIndex + 1, mergedData.length - 1);
|
|
7884
7978
|
return {
|
|
@@ -7894,6 +7988,7 @@ function RawList(props, ref) {
|
|
|
7894
7988
|
fillerOffset = _React$useMemo.offset;
|
|
7895
7989
|
rangeRef.current.start = start;
|
|
7896
7990
|
rangeRef.current.end = end;
|
|
7991
|
+
|
|
7897
7992
|
// ================================= Size =================================
|
|
7898
7993
|
var _React$useState = React$4.useState({
|
|
7899
7994
|
width: 0,
|
|
@@ -7908,6 +8003,7 @@ function RawList(props, ref) {
|
|
|
7908
8003
|
height: sizeInfo.height || sizeInfo.offsetHeight
|
|
7909
8004
|
});
|
|
7910
8005
|
};
|
|
8006
|
+
|
|
7911
8007
|
// Hack on scrollbar to enable flash call
|
|
7912
8008
|
var verticalScrollBarRef = useRef();
|
|
7913
8009
|
var horizontalScrollBarRef = useRef();
|
|
@@ -7917,6 +8013,7 @@ function RawList(props, ref) {
|
|
|
7917
8013
|
var verticalScrollBarSpinSize = React$4.useMemo(function () {
|
|
7918
8014
|
return getSpinSize(size.height, scrollHeight);
|
|
7919
8015
|
}, [size.height, scrollHeight]);
|
|
8016
|
+
|
|
7920
8017
|
// =============================== In Range ===============================
|
|
7921
8018
|
var maxScrollHeight = scrollHeight - height;
|
|
7922
8019
|
var maxScrollHeightRef = useRef(maxScrollHeight);
|
|
@@ -7932,6 +8029,7 @@ function RawList(props, ref) {
|
|
|
7932
8029
|
var isScrollAtTop = offsetTop <= 0;
|
|
7933
8030
|
var isScrollAtBottom = offsetTop >= maxScrollHeight;
|
|
7934
8031
|
var originScroll = useOriginScroll(isScrollAtTop, isScrollAtBottom);
|
|
8032
|
+
|
|
7935
8033
|
// ================================ Scroll ================================
|
|
7936
8034
|
var getVirtualScrollInfo = function getVirtualScrollInfo() {
|
|
7937
8035
|
return {
|
|
@@ -7940,9 +8038,10 @@ function RawList(props, ref) {
|
|
|
7940
8038
|
};
|
|
7941
8039
|
};
|
|
7942
8040
|
var lastVirtualScrollInfoRef = useRef(getVirtualScrollInfo());
|
|
7943
|
-
var triggerScroll = useEvent$2(function () {
|
|
8041
|
+
var triggerScroll = useEvent$2(function (params) {
|
|
7944
8042
|
if (onVirtualScroll) {
|
|
7945
|
-
var nextInfo = getVirtualScrollInfo();
|
|
8043
|
+
var nextInfo = _objectSpread2(_objectSpread2({}, getVirtualScrollInfo()), params);
|
|
8044
|
+
|
|
7946
8045
|
// Trigger when offset changed
|
|
7947
8046
|
if (lastVirtualScrollInfoRef.current.x !== nextInfo.x || lastVirtualScrollInfoRef.current.y !== nextInfo.y) {
|
|
7948
8047
|
onVirtualScroll(nextInfo);
|
|
@@ -7961,19 +8060,21 @@ function RawList(props, ref) {
|
|
|
7961
8060
|
syncScrollTop(newOffset);
|
|
7962
8061
|
}
|
|
7963
8062
|
}
|
|
8063
|
+
|
|
7964
8064
|
// When data size reduce. It may trigger native scroll event back to fit scroll position
|
|
7965
8065
|
function onFallbackScroll(e) {
|
|
7966
8066
|
var newScrollTop = e.currentTarget.scrollTop;
|
|
7967
8067
|
if (newScrollTop !== offsetTop) {
|
|
7968
8068
|
syncScrollTop(newScrollTop);
|
|
7969
8069
|
}
|
|
8070
|
+
|
|
7970
8071
|
// Trigger origin onScroll
|
|
7971
|
-
onScroll === null || onScroll === void 0
|
|
8072
|
+
onScroll === null || onScroll === void 0 || onScroll(e);
|
|
7972
8073
|
triggerScroll();
|
|
7973
8074
|
}
|
|
7974
8075
|
var keepInHorizontalRange = function keepInHorizontalRange(nextOffsetLeft) {
|
|
7975
8076
|
var tmpOffsetLeft = nextOffsetLeft;
|
|
7976
|
-
var max = scrollWidth - size.width;
|
|
8077
|
+
var max = !!scrollWidth ? scrollWidth - size.width : 0;
|
|
7977
8078
|
tmpOffsetLeft = Math.max(tmpOffsetLeft, 0);
|
|
7978
8079
|
tmpOffsetLeft = Math.min(tmpOffsetLeft, max);
|
|
7979
8080
|
return tmpOffsetLeft;
|
|
@@ -7981,6 +8082,7 @@ function RawList(props, ref) {
|
|
|
7981
8082
|
var onWheelDelta = useEvent$2(function (offsetXY, fromHorizontal) {
|
|
7982
8083
|
if (fromHorizontal) {
|
|
7983
8084
|
// Horizontal scroll no need sync virtual position
|
|
8085
|
+
|
|
7984
8086
|
flushSync(function () {
|
|
7985
8087
|
setOffsetLeft(function (left) {
|
|
7986
8088
|
var nextOffsetLeft = left + (isRTL ? -offsetXY : offsetXY);
|
|
@@ -7995,11 +8097,13 @@ function RawList(props, ref) {
|
|
|
7995
8097
|
});
|
|
7996
8098
|
}
|
|
7997
8099
|
});
|
|
8100
|
+
|
|
7998
8101
|
// Since this added in global,should use ref to keep update
|
|
7999
8102
|
var _useFrameWheel = useFrameWheel(useVirtual, isScrollAtTop, isScrollAtBottom, !!scrollWidth, onWheelDelta),
|
|
8000
8103
|
_useFrameWheel2 = _slicedToArray(_useFrameWheel, 2),
|
|
8001
8104
|
onRawWheel = _useFrameWheel2[0],
|
|
8002
8105
|
onFireFoxScroll = _useFrameWheel2[1];
|
|
8106
|
+
|
|
8003
8107
|
// Mobile touch move
|
|
8004
8108
|
useMobileTouchMove(useVirtual, componentRef, function (deltaY, smoothOffset) {
|
|
8005
8109
|
if (originScroll(deltaY, smoothOffset)) {
|
|
@@ -8028,19 +8132,23 @@ function RawList(props, ref) {
|
|
|
8028
8132
|
componentEle.removeEventListener('MozMousePixelScroll', onMozMousePixelScroll);
|
|
8029
8133
|
};
|
|
8030
8134
|
}, [useVirtual]);
|
|
8135
|
+
|
|
8031
8136
|
// Sync scroll left
|
|
8032
8137
|
useLayoutEffect$3(function () {
|
|
8033
8138
|
if (scrollWidth) {
|
|
8034
|
-
|
|
8035
|
-
|
|
8139
|
+
var newOffsetLeft = keepInHorizontalRange(offsetLeft);
|
|
8140
|
+
setOffsetLeft(newOffsetLeft);
|
|
8141
|
+
triggerScroll({
|
|
8142
|
+
x: newOffsetLeft
|
|
8036
8143
|
});
|
|
8037
8144
|
}
|
|
8038
8145
|
}, [size.width, scrollWidth]);
|
|
8146
|
+
|
|
8039
8147
|
// ================================= Ref ==================================
|
|
8040
8148
|
var delayHideScrollBar = function delayHideScrollBar() {
|
|
8041
8149
|
var _verticalScrollBarRef, _horizontalScrollBarR;
|
|
8042
|
-
(_verticalScrollBarRef = verticalScrollBarRef.current) === null || _verticalScrollBarRef === void 0
|
|
8043
|
-
(_horizontalScrollBarR = horizontalScrollBarRef.current) === null || _horizontalScrollBarR === void 0
|
|
8150
|
+
(_verticalScrollBarRef = verticalScrollBarRef.current) === null || _verticalScrollBarRef === void 0 || _verticalScrollBarRef.delayHidden();
|
|
8151
|
+
(_horizontalScrollBarR = horizontalScrollBarRef.current) === null || _horizontalScrollBarR === void 0 || _horizontalScrollBarR.delayHidden();
|
|
8044
8152
|
};
|
|
8045
8153
|
var _scrollTo = useScrollTo(componentRef, mergedData, heights, itemHeight, getKey, function () {
|
|
8046
8154
|
return collectHeight(true);
|
|
@@ -8057,6 +8165,7 @@ function RawList(props, ref) {
|
|
|
8057
8165
|
if (config.left !== undefined) {
|
|
8058
8166
|
setOffsetLeft(keepInHorizontalRange(config.left));
|
|
8059
8167
|
}
|
|
8168
|
+
|
|
8060
8169
|
// Scroll Y
|
|
8061
8170
|
_scrollTo(config.top);
|
|
8062
8171
|
} else {
|
|
@@ -8065,6 +8174,7 @@ function RawList(props, ref) {
|
|
|
8065
8174
|
}
|
|
8066
8175
|
};
|
|
8067
8176
|
});
|
|
8177
|
+
|
|
8068
8178
|
// ================================ Effect ================================
|
|
8069
8179
|
/** We need told outside that some list not rendered */
|
|
8070
8180
|
useLayoutEffect$3(function () {
|
|
@@ -8073,6 +8183,7 @@ function RawList(props, ref) {
|
|
|
8073
8183
|
onVisibleChange(renderList, mergedData);
|
|
8074
8184
|
}
|
|
8075
8185
|
}, [start, end, mergedData]);
|
|
8186
|
+
|
|
8076
8187
|
// ================================ Extra =================================
|
|
8077
8188
|
var getSize = useGetSize(mergedData, getKey, heights, itemHeight);
|
|
8078
8189
|
var extraContent = extraRender === null || extraRender === void 0 ? void 0 : extraRender({
|
|
@@ -8084,6 +8195,7 @@ function RawList(props, ref) {
|
|
|
8084
8195
|
rtl: isRTL,
|
|
8085
8196
|
getSize: getSize
|
|
8086
8197
|
});
|
|
8198
|
+
|
|
8087
8199
|
// ================================ Render ================================
|
|
8088
8200
|
var listChildren = useChildren(mergedData, start, end, scrollWidth, setInstanceRef, children, sharedConfig);
|
|
8089
8201
|
var componentStyle = null;
|
|
@@ -8140,7 +8252,7 @@ function RawList(props, ref) {
|
|
|
8140
8252
|
containerSize: size.height,
|
|
8141
8253
|
style: styles === null || styles === void 0 ? void 0 : styles.verticalScrollBar,
|
|
8142
8254
|
thumbStyle: styles === null || styles === void 0 ? void 0 : styles.verticalScrollBarThumb
|
|
8143
|
-
}), inVirtual && scrollWidth && /*#__PURE__*/React$4.createElement(ScrollBar, {
|
|
8255
|
+
}), inVirtual && scrollWidth > size.width && /*#__PURE__*/React$4.createElement(ScrollBar, {
|
|
8144
8256
|
ref: horizontalScrollBarRef,
|
|
8145
8257
|
prefixCls: prefixCls,
|
|
8146
8258
|
scrollOffset: offsetLeft,
|
|
@@ -9286,7 +9398,7 @@ var interopRequireWildcard = {exports: {}};
|
|
|
9286
9398
|
__proto__: null
|
|
9287
9399
|
},
|
|
9288
9400
|
a = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
9289
|
-
for (var u in e) if ("default" !== u &&
|
|
9401
|
+
for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
|
|
9290
9402
|
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
|
|
9291
9403
|
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u];
|
|
9292
9404
|
}
|