@para-ui/core 4.0.21 → 4.0.24

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 (129) hide show
  1. package/AutoTips/index.js +11 -0
  2. package/Button/index.js +1 -1
  3. package/ButtonGroup/index.js +1 -1
  4. package/Cascader/index.js +7 -6
  5. package/ComboSelect/index.js +2 -2
  6. package/CopyText/index.js +1 -1
  7. package/CycleSelector/index.js +1 -1
  8. package/DatePicker/index.js +1 -1
  9. package/Descriptions/index.js +1 -1
  10. package/Desktop/index.js +1 -1
  11. package/Drawer/index.js +1 -1
  12. package/Dropdown/index.js +1 -1
  13. package/DynamicMultiBox/index.js +2 -2
  14. package/Empty/index.js +0 -6
  15. package/Form/index.js +11 -8
  16. package/FormItem/index.js +3 -3
  17. package/FunctionModal/index.js +3 -3
  18. package/Image/PreviewGroup.d.ts +20 -0
  19. package/Image/index.d.ts +10 -0
  20. package/Image/index.js +1485 -0
  21. package/InputLang/index.js +1 -1
  22. package/Modal/index.js +1 -1
  23. package/MultiBox/index.js +1 -1
  24. package/OperateBtn/index.js +1 -1
  25. package/PageHeader/index.js +1 -1
  26. package/Pagination/index.js +1 -1
  27. package/PopConfirm/index.js +1 -1
  28. package/Popover/index.js +1 -1
  29. package/Querying/index.js +0 -12
  30. package/QuickReply/index.js +1 -1
  31. package/README.md +17 -0
  32. package/Search/index.js +1 -1
  33. package/Select/index.d.ts +2 -0
  34. package/Select/index.js +27 -10
  35. package/SelectInput/index.js +1 -1
  36. package/Selector/index.js +3 -326
  37. package/SelectorPicker/index.js +2 -1
  38. package/SingleBox/index.js +1 -1
  39. package/Slider/index.js +29 -14
  40. package/Slider/interface.d.ts +4 -0
  41. package/Table/index.js +9 -3
  42. package/Tabs/index.js +1 -1
  43. package/TextField/index.js +5 -4
  44. package/TimePicker/index.js +1 -1
  45. package/ToggleButton/index.js +1 -1
  46. package/Transfer/index.js +1 -1
  47. package/Tree/index.js +2 -2
  48. package/Upload/ImgCrop/EasyCrop.d.ts +2 -2
  49. package/Upload/ImgCrop/constants.d.ts +12 -0
  50. package/Upload/ImgCrop/interface.d.ts +10 -0
  51. package/Upload/index.js +1182 -527
  52. package/Upload/interface.d.ts +43 -0
  53. package/Upload/util.d.ts +7 -0
  54. package/_verture/Portal-5bd49559.js +1698 -0
  55. package/_verture/{index-f59b0bc0.js → index-2a6adf4d.js} +772 -2458
  56. package/_verture/index-8ac46bd9.js +327 -0
  57. package/_verture/{index-c77ccb98.js → index-bbe5660a.js} +7 -3
  58. package/_verture/{index-389675ab.js → index-bde7aabe.js} +1 -1
  59. package/index.d.ts +2 -0
  60. package/index.js +19 -12
  61. package/locale/index.js +2 -2
  62. package/package.json +3 -2
  63. package/umd/AutoBox.js +3 -3
  64. package/umd/AutoTips.js +4 -4
  65. package/umd/Breadcrumbs.js +5 -5
  66. package/umd/Button.js +5 -5
  67. package/umd/ButtonGroup.js +5 -5
  68. package/umd/Cascader.js +3 -3
  69. package/umd/Checkbox.js +2 -2
  70. package/umd/CheckboxGroup.js +2 -2
  71. package/umd/Collapse.js +2 -2
  72. package/umd/CollapseBox.js +1 -1
  73. package/umd/ComboSelect.js +5 -5
  74. package/umd/CopyText.js +5 -5
  75. package/umd/CycleSelector.js +4 -4
  76. package/umd/DatePicker.js +5 -5
  77. package/umd/Descriptions.js +3 -3
  78. package/umd/Desktop.js +4 -4
  79. package/umd/Drawer.js +3 -3
  80. package/umd/Dropdown.js +3 -3
  81. package/umd/DynamicMultiBox.js +5 -5
  82. package/umd/Empty.js +1 -1
  83. package/umd/Form.js +5 -5
  84. package/umd/FormItem.js +5 -5
  85. package/umd/FunctionModal.js +6 -6
  86. package/umd/Help.js +2 -2
  87. package/umd/Image.js +42 -0
  88. package/umd/InputLang.js +5 -5
  89. package/umd/InputNumber.js +2 -2
  90. package/umd/Label.js +2 -2
  91. package/umd/Menu.js +2 -2
  92. package/umd/Modal.js +7 -7
  93. package/umd/MultiBox.js +4 -4
  94. package/umd/Notification.js +1 -1
  95. package/umd/OperateBtn.js +5 -5
  96. package/umd/PageHeader.js +3 -3
  97. package/umd/Pagination.js +4 -4
  98. package/umd/PopConfirm.js +4 -4
  99. package/umd/PopMenu.js +3 -3
  100. package/umd/Popover.js +3 -3
  101. package/umd/Progress.js +1 -1
  102. package/umd/Querying.js +1 -1
  103. package/umd/QuickReply.js +5 -5
  104. package/umd/Radio.js +2 -2
  105. package/umd/RadioGroup.js +2 -2
  106. package/umd/Search.js +4 -4
  107. package/umd/Select.js +4 -4
  108. package/umd/SelectInput.js +4 -4
  109. package/umd/Selector.js +4 -4
  110. package/umd/SelectorPicker.js +5 -5
  111. package/umd/SingleBox.js +4 -4
  112. package/umd/Slider.js +3 -3
  113. package/umd/Stepper.js +2 -2
  114. package/umd/Switch.js +2 -2
  115. package/umd/Table.js +6 -6
  116. package/umd/Tabs.js +5 -5
  117. package/umd/Tag.js +2 -2
  118. package/umd/TextEditor.js +17 -17
  119. package/umd/TextField.js +3 -3
  120. package/umd/TimePicker.js +5 -5
  121. package/umd/Title.js +6 -6
  122. package/umd/ToggleButton.js +5 -5
  123. package/umd/Tooltip.js +2 -2
  124. package/umd/Transfer.js +4 -4
  125. package/umd/Tree.js +3 -3
  126. package/umd/Upload.js +6 -6
  127. package/umd/locale.js +1 -1
  128. /package/_verture/{index-fa1ee687.js → index-8cfd01fd.js} +0 -0
  129. /package/_verture/{modalContext-c8cc3107.js → modalContext-0c08a396.js} +0 -0
@@ -1,15 +1,16 @@
1
1
  import { _ as __rest } from './tslib.es6-55ed4bd2.js';
2
2
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
3
+ import { c as clsx, _ as _objectSpread2, r as reactIs, s as supportRef, u as useComposeRef, w as warning, a as _extends, b as _objectWithoutProperties, d as wrapperRaf, e as useEvent$2, f as useLayoutEffect$3, g as composeRef, K as KeyCode, h as fillRef, P as Portal, i as warningOnce, j as useMergedState$2, k as canUseDom$1, l as useMemo$1, n as noteOnce } from './Portal-5bd49559.js';
3
4
  import { _ as _toConsumableArray, a as _iterableToArray } from './toConsumableArray-8f4c9589.js';
4
- import { _ as _defineProperty, t as toPropertyKey } from './defineProperty-6f62bb2a.js';
5
+ import { t as toPropertyKey, _ as _defineProperty } from './defineProperty-6f62bb2a.js';
5
6
  import { _ as _slicedToArray, a as _arrayWithHoles, b as _nonIterableRest } from './slicedToArray-a8206399.js';
6
7
  import { _ as _typeof$1 } from './typeof-adeedc13.js';
7
8
  import * as React$4 from 'react';
8
- import React__default, { useState as useState$1, useMemo as useMemo$1, useCallback, useRef, useEffect } from 'react';
9
- import ReactDOM, { unstable_batchedUpdates, createPortal, flushSync } from 'react-dom';
9
+ import React__default, { useState as useState$1, useMemo, useCallback, useRef, useEffect } from 'react';
10
+ import ReactDOM, { unstable_batchedUpdates, flushSync } from 'react-dom';
10
11
  import CSSMotion from 'rc-motion';
11
12
  import { _ as _unsupportedIterableToArray } from './unsupportedIterableToArray-cb478f24.js';
12
- import clsx from 'clsx';
13
+ import clsx$1 from 'clsx';
13
14
  import { _ as _typeof$2 } from './typeof-6ec38efd.js';
14
15
  import { conductCheck } from 'rc-tree/lib/utils/conductUtil';
15
16
  import Right from '@para-ui/icons/Right';
@@ -25,1402 +26,192 @@ import { u as useFormatMessage } from './useFormatMessage-1fc7c957.js';
25
26
  import { UUID } from '@paraview/lib';
26
27
  import { s as styleInject } from './style-inject.es-300983ab.js';
27
28
 
28
- function _extends() {
29
- _extends = Object.assign ? Object.assign.bind() : function (target) {
30
- for (var i = 1; i < arguments.length; i++) {
31
- var source = arguments[i];
32
- for (var key in source) {
33
- if (Object.prototype.hasOwnProperty.call(source, key)) {
34
- target[key] = source[key];
35
- }
36
- }
37
- }
38
- return target;
39
- };
40
- return _extends.apply(this, arguments);
41
- }
42
-
43
- function ownKeys(e, r) {
44
- var t = Object.keys(e);
45
- if (Object.getOwnPropertySymbols) {
46
- var o = Object.getOwnPropertySymbols(e);
47
- r && (o = o.filter(function (r) {
48
- return Object.getOwnPropertyDescriptor(e, r).enumerable;
49
- })), t.push.apply(t, o);
50
- }
51
- return t;
52
- }
53
- function _objectSpread2(e) {
54
- for (var r = 1; r < arguments.length; r++) {
55
- var t = null != arguments[r] ? arguments[r] : {};
56
- r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
57
- _defineProperty(e, r, t[r]);
58
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
59
- Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
60
- });
61
- }
62
- return e;
63
- }
64
-
65
- function _objectWithoutPropertiesLoose(source, excluded) {
66
- if (source == null) return {};
67
- var target = {};
68
- var sourceKeys = Object.keys(source);
69
- var key, i;
70
- for (i = 0; i < sourceKeys.length; i++) {
71
- key = sourceKeys[i];
72
- if (excluded.indexOf(key) >= 0) continue;
73
- target[key] = source[key];
29
+ var isMobile = (function () {
30
+ if (typeof navigator === 'undefined' || typeof window === 'undefined') {
31
+ return false;
74
32
  }
75
- return target;
76
- }
33
+ var agent = navigator.userAgent || navigator.vendor || window.opera;
34
+ return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(agent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(agent === null || agent === void 0 ? void 0 : agent.substr(0, 4));
35
+ });
77
36
 
78
- function _objectWithoutProperties(source, excluded) {
79
- if (source == null) return {};
80
- var target = _objectWithoutPropertiesLoose(source, excluded);
81
- var key, i;
82
- if (Object.getOwnPropertySymbols) {
83
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
84
- for (i = 0; i < sourceSymbolKeys.length; i++) {
85
- key = sourceSymbolKeys[i];
86
- if (excluded.indexOf(key) >= 0) continue;
87
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
88
- target[key] = source[key];
89
- }
37
+ var TransBtn = function TransBtn(_ref) {
38
+ var className = _ref.className,
39
+ customizeIcon = _ref.customizeIcon,
40
+ customizeIconProps = _ref.customizeIconProps,
41
+ _onMouseDown = _ref.onMouseDown,
42
+ onClick = _ref.onClick,
43
+ children = _ref.children;
44
+ var icon;
45
+ if (typeof customizeIcon === 'function') {
46
+ icon = customizeIcon(customizeIconProps);
47
+ } else {
48
+ icon = customizeIcon;
90
49
  }
91
- return target;
92
- }
50
+ return /*#__PURE__*/React$4.createElement("span", {
51
+ className: className,
52
+ onMouseDown: function onMouseDown(event) {
53
+ event.preventDefault();
54
+ if (_onMouseDown) {
55
+ _onMouseDown(event);
56
+ }
57
+ },
58
+ style: {
59
+ userSelect: 'none',
60
+ WebkitUserSelect: 'none'
61
+ },
62
+ unselectable: "on",
63
+ onClick: onClick,
64
+ "aria-hidden": true
65
+ }, icon !== undefined ? icon : /*#__PURE__*/React$4.createElement("span", {
66
+ className: clsx(className.split(/\s+/).map(function (cls) {
67
+ return "".concat(cls, "-icon");
68
+ }))
69
+ }, children));
70
+ };
93
71
 
94
- function useEvent$2(callback) {
95
- var fnRef = React$4.useRef();
96
- fnRef.current = callback;
97
- var memoFn = React$4.useCallback(function () {
98
- var _fnRef$current;
99
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
100
- args[_key] = arguments[_key];
72
+ function useAllowClear(prefixCls, onClearMouseDown, displayValues, allowClear, clearIcon) {
73
+ var disabled = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
74
+ var mergedSearchValue = arguments.length > 6 ? arguments[6] : undefined;
75
+ var mode = arguments.length > 7 ? arguments[7] : undefined;
76
+ var mergedClearIcon = React__default.useMemo(function () {
77
+ if (_typeof$1(allowClear) === "object") {
78
+ return allowClear.clearIcon;
101
79
  }
102
- return (_fnRef$current = fnRef.current) === null || _fnRef$current === void 0 ? void 0 : _fnRef$current.call.apply(_fnRef$current, [fnRef].concat(args));
103
- }, []);
104
- return memoFn;
80
+ if (!!clearIcon) return clearIcon;
81
+ }, [allowClear, clearIcon]);
82
+ var mergedAllowClear = React__default.useMemo(function () {
83
+ if (!disabled && !!allowClear && (displayValues.length || mergedSearchValue) && !(mode === 'combobox' && mergedSearchValue === '')) {
84
+ return true;
85
+ }
86
+ return false;
87
+ }, [allowClear, disabled, displayValues.length, mergedSearchValue, mode]);
88
+ return {
89
+ allowClear: mergedAllowClear,
90
+ clearIcon: /*#__PURE__*/React__default.createElement(TransBtn, {
91
+ className: "".concat(prefixCls, "-clear"),
92
+ onMouseDown: onClearMouseDown,
93
+ customizeIcon: mergedClearIcon
94
+ }, "\xD7")
95
+ };
105
96
  }
106
97
 
107
- function canUseDom$1() {
108
- return !!(typeof window !== 'undefined' && window.document && window.document.createElement);
98
+ /**
99
+ * BaseSelect provide some parsed data into context.
100
+ * You can use this hooks to get them.
101
+ */
102
+ var BaseSelectContext = /*#__PURE__*/React$4.createContext(null);
103
+ function useBaseProps() {
104
+ return React$4.useContext(BaseSelectContext);
109
105
  }
110
106
 
111
107
  /**
112
- * Wrap `React.useLayoutEffect` which will not throw warning message in test env
108
+ * Similar with `useLock`, but this hook will always execute last value.
109
+ * When set to `true`, it will keep `true` for a short time even if `false` is set.
113
110
  */
114
- var useInternalLayoutEffect$1 = process.env.NODE_ENV !== 'test' && canUseDom$1() ? React$4.useLayoutEffect : React$4.useEffect;
115
- var useLayoutEffect$3 = function useLayoutEffect(callback, deps) {
116
- var firstMountRef = React$4.useRef(true);
117
- useInternalLayoutEffect$1(function () {
118
- return callback(firstMountRef.current);
119
- }, deps);
120
-
121
- // We tell react that first mount has passed
122
- useInternalLayoutEffect$1(function () {
123
- firstMountRef.current = false;
124
- return function () {
125
- firstMountRef.current = true;
126
- };
111
+ function useDelayReset() {
112
+ var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
113
+ var _React$useState = React$4.useState(false),
114
+ _React$useState2 = _slicedToArray(_React$useState, 2),
115
+ bool = _React$useState2[0],
116
+ setBool = _React$useState2[1];
117
+ var delayRef = React$4.useRef(null);
118
+ var cancelLatest = function cancelLatest() {
119
+ window.clearTimeout(delayRef.current);
120
+ };
121
+ React$4.useEffect(function () {
122
+ return cancelLatest;
127
123
  }, []);
128
- };
129
- var useLayoutUpdateEffect = function useLayoutUpdateEffect(callback, deps) {
130
- useLayoutEffect$3(function (firstMount) {
131
- if (!firstMount) {
132
- return callback();
133
- }
134
- }, deps);
135
- };
124
+ var delaySetBool = function delaySetBool(value, callback) {
125
+ cancelLatest();
126
+ delayRef.current = window.setTimeout(function () {
127
+ setBool(value);
128
+ if (callback) {
129
+ callback();
130
+ }
131
+ }, timeout);
132
+ };
133
+ return [bool, delaySetBool, cancelLatest];
134
+ }
136
135
 
137
136
  /**
138
- * Same as React.useState but `setState` accept `ignoreDestroy` param to not to setState after destroyed.
139
- * We do not make this auto is to avoid real memory leak.
140
- * Developer should confirm it's safe to ignore themselves.
137
+ * Locker return cached mark.
138
+ * If set to `true`, will return `true` in a short time even if set `false`.
139
+ * If set to `false` and then set to `true`, will change to `true`.
140
+ * And after time duration, it will back to `null` automatically.
141
141
  */
142
- function useSafeState$1(defaultValue) {
143
- var destroyRef = React$4.useRef(false);
144
- var _React$useState = React$4.useState(defaultValue),
145
- _React$useState2 = _slicedToArray(_React$useState, 2),
146
- value = _React$useState2[0],
147
- setValue = _React$useState2[1];
142
+ function useLock() {
143
+ var duration = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 250;
144
+ var lockRef = React$4.useRef(null);
145
+ var timeoutRef = React$4.useRef(null);
146
+
147
+ // Clean up
148
148
  React$4.useEffect(function () {
149
- destroyRef.current = false;
150
149
  return function () {
151
- destroyRef.current = true;
150
+ window.clearTimeout(timeoutRef.current);
152
151
  };
153
152
  }, []);
154
- function safeSetState(updater, ignoreDestroy) {
155
- if (ignoreDestroy && destroyRef.current) {
156
- return;
153
+ function doLock(locked) {
154
+ if (locked || lockRef.current === null) {
155
+ lockRef.current = locked;
157
156
  }
158
- setValue(updater);
157
+ window.clearTimeout(timeoutRef.current);
158
+ timeoutRef.current = window.setTimeout(function () {
159
+ lockRef.current = null;
160
+ }, duration);
159
161
  }
160
- return [value, safeSetState];
161
- }
162
-
163
- /** We only think `undefined` is empty */
164
- function hasValue$2(value) {
165
- return value !== undefined;
162
+ return [function () {
163
+ return lockRef.current;
164
+ }, doLock];
166
165
  }
167
166
 
168
- /**
169
- * Similar to `useState` but will use props value if provided.
170
- * Note that internal use rc-util `useState` hook.
171
- */
172
- function useMergedState$2(defaultStateValue, option) {
173
- var _ref = option || {},
174
- defaultValue = _ref.defaultValue,
175
- value = _ref.value,
176
- onChange = _ref.onChange,
177
- postState = _ref.postState;
178
-
179
- // ======================= Init =======================
180
- var _useState = useSafeState$1(function () {
181
- if (hasValue$2(value)) {
182
- return value;
183
- } else if (hasValue$2(defaultValue)) {
184
- return typeof defaultValue === 'function' ? defaultValue() : defaultValue;
185
- } else {
186
- return typeof defaultStateValue === 'function' ? defaultStateValue() : defaultStateValue;
167
+ function useSelectTriggerControl(elements, open, triggerOpen, customizedTrigger) {
168
+ var propsRef = React$4.useRef(null);
169
+ propsRef.current = {
170
+ open: open,
171
+ triggerOpen: triggerOpen,
172
+ customizedTrigger: customizedTrigger
173
+ };
174
+ React$4.useEffect(function () {
175
+ function onGlobalMouseDown(event) {
176
+ var _propsRef$current;
177
+ // If trigger is customized, Trigger will take control of popupVisible
178
+ if ((_propsRef$current = propsRef.current) !== null && _propsRef$current !== void 0 && _propsRef$current.customizedTrigger) {
179
+ return;
180
+ }
181
+ var target = event.target;
182
+ if (target.shadowRoot && event.composed) {
183
+ target = event.composedPath()[0] || target;
184
+ }
185
+ if (propsRef.current.open && elements().filter(function (element) {
186
+ return element;
187
+ }).every(function (element) {
188
+ return !element.contains(target) && element !== target;
189
+ })) {
190
+ // Should trigger close
191
+ propsRef.current.triggerOpen(false);
187
192
  }
188
- }),
189
- _useState2 = _slicedToArray(_useState, 2),
190
- innerValue = _useState2[0],
191
- setInnerValue = _useState2[1];
192
- var mergedValue = value !== undefined ? value : innerValue;
193
- var postMergedValue = postState ? postState(mergedValue) : mergedValue;
194
-
195
- // ====================== Change ======================
196
- var onChangeFn = useEvent$2(onChange);
197
- var _useState3 = useSafeState$1([mergedValue]),
198
- _useState4 = _slicedToArray(_useState3, 2),
199
- prevValue = _useState4[0],
200
- setPrevValue = _useState4[1];
201
- useLayoutUpdateEffect(function () {
202
- var prev = prevValue[0];
203
- if (innerValue !== prev) {
204
- onChangeFn(innerValue, prev);
205
- }
206
- }, [prevValue]);
207
-
208
- // Sync value back to `undefined` when it from control to un-control
209
- useLayoutUpdateEffect(function () {
210
- if (!hasValue$2(value)) {
211
- setInnerValue(value);
212
193
  }
213
- }, [value]);
214
-
215
- // ====================== Update ======================
216
- var triggerChange = useEvent$2(function (updater, ignoreDestroy) {
217
- setInnerValue(updater, ignoreDestroy);
218
- setPrevValue([mergedValue], ignoreDestroy);
219
- });
220
- return [postMergedValue, triggerChange];
194
+ window.addEventListener('mousedown', onGlobalMouseDown);
195
+ return function () {
196
+ return window.removeEventListener('mousedown', onGlobalMouseDown);
197
+ };
198
+ }, []);
221
199
  }
222
200
 
223
- /* eslint-disable no-console */
224
- var warned = {};
225
- var preWarningFns = [];
226
-
227
- /**
228
- * Pre warning enable you to parse content before console.error.
229
- * Modify to null will prevent warning.
230
- */
231
- var preMessage = function preMessage(fn) {
232
- preWarningFns.push(fn);
233
- };
201
+ var attributes = "accept acceptCharset accessKey action allowFullScreen allowTransparency\n alt async autoComplete autoFocus autoPlay capture cellPadding cellSpacing challenge\n charSet checked classID className colSpan cols content contentEditable contextMenu\n controls coords crossOrigin data dateTime default defer dir disabled download draggable\n encType form formAction formEncType formMethod formNoValidate formTarget frameBorder\n headers height hidden high href hrefLang htmlFor httpEquiv icon id inputMode integrity\n is keyParams keyType kind label lang list loop low manifest marginHeight marginWidth max maxLength media\n mediaGroup method min minLength multiple muted name noValidate nonce open\n optimum pattern placeholder poster preload radioGroup readOnly rel required\n reversed role rowSpan rows sandbox scope scoped scrolling seamless selected\n shape size sizes span spellCheck src srcDoc srcLang srcSet start step style\n summary tabIndex target title type useMap value width wmode wrap";
202
+ var eventsName = "onCopy onCut onPaste onCompositionEnd onCompositionStart onCompositionUpdate onKeyDown\n onKeyPress onKeyUp onFocus onBlur onChange onInput onSubmit onClick onContextMenu onDoubleClick\n onDrag onDragEnd onDragEnter onDragExit onDragLeave onDragOver onDragStart onDrop onMouseDown\n onMouseEnter onMouseLeave onMouseMove onMouseOut onMouseOver onMouseUp onSelect onTouchCancel\n onTouchEnd onTouchMove onTouchStart onScroll onWheel onAbort onCanPlay onCanPlayThrough\n onDurationChange onEmptied onEncrypted onEnded onError onLoadedData onLoadedMetadata\n onLoadStart onPause onPlay onPlaying onProgress onRateChange onSeeked onSeeking onStalled onSuspend onTimeUpdate onVolumeChange onWaiting onLoad onError";
203
+ var propList = "".concat(attributes, " ").concat(eventsName).split(/[\s\n]+/);
234
204
 
205
+ /* eslint-enable max-len */
206
+ var ariaPrefix = 'aria-';
207
+ var dataPrefix = 'data-';
208
+ function match(key, prefix) {
209
+ return key.indexOf(prefix) === 0;
210
+ }
235
211
  /**
236
- * Warning if condition not match.
237
- * @param valid Condition
238
- * @param message Warning message
239
- * @example
240
- * ```js
241
- * warning(false, 'some error'); // print some error
242
- * warning(true, 'some error'); // print nothing
243
- * warning(1 === 2, 'some error'); // print some error
244
- * ```
245
- */
246
- function warning(valid, message) {
247
- if (process.env.NODE_ENV !== 'production' && !valid && console !== undefined) {
248
- var finalMessage = preWarningFns.reduce(function (msg, preMessageFn) {
249
- return preMessageFn(msg !== null && msg !== void 0 ? msg : '', 'warning');
250
- }, message);
251
- if (finalMessage) {
252
- console.error("Warning: ".concat(finalMessage));
253
- }
254
- }
255
- }
256
-
257
- /** @see Similar to {@link warning} */
258
- function note(valid, message) {
259
- if (process.env.NODE_ENV !== 'production' && !valid && console !== undefined) {
260
- var finalMessage = preWarningFns.reduce(function (msg, preMessageFn) {
261
- return preMessageFn(msg !== null && msg !== void 0 ? msg : '', 'note');
262
- }, message);
263
- if (finalMessage) {
264
- console.warn("Note: ".concat(finalMessage));
265
- }
266
- }
267
- }
268
- function resetWarned() {
269
- warned = {};
270
- }
271
- function call(method, valid, message) {
272
- if (!valid && !warned[message]) {
273
- method(false, message);
274
- warned[message] = true;
275
- }
276
- }
277
-
278
- /** @see Same as {@link warning}, but only warn once for the same message */
279
- function warningOnce(valid, message) {
280
- call(warning, valid, message);
281
- }
282
-
283
- /** @see Same as {@link warning}, but only warn once for the same message */
284
- function noteOnce(valid, message) {
285
- call(note, valid, message);
286
- }
287
- warningOnce.preMessage = preMessage;
288
- warningOnce.resetWarned = resetWarned;
289
- warningOnce.noteOnce = noteOnce;
290
-
291
- var classnames = {exports: {}};
292
-
293
- /*!
294
- Copyright (c) 2018 Jed Watson.
295
- Licensed under the MIT License (MIT), see
296
- http://jedwatson.github.io/classnames
297
- */
298
-
299
- (function (module) {
300
- /* global define */
301
-
302
- (function () {
303
-
304
- var hasOwn = {}.hasOwnProperty;
305
-
306
- function classNames () {
307
- var classes = '';
308
-
309
- for (var i = 0; i < arguments.length; i++) {
310
- var arg = arguments[i];
311
- if (arg) {
312
- classes = appendClass(classes, parseValue(arg));
313
- }
314
- }
315
-
316
- return classes;
317
- }
318
-
319
- function parseValue (arg) {
320
- if (typeof arg === 'string' || typeof arg === 'number') {
321
- return arg;
322
- }
323
-
324
- if (typeof arg !== 'object') {
325
- return '';
326
- }
327
-
328
- if (Array.isArray(arg)) {
329
- return classNames.apply(null, arg);
330
- }
331
-
332
- if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
333
- return arg.toString();
334
- }
335
-
336
- var classes = '';
337
-
338
- for (var key in arg) {
339
- if (hasOwn.call(arg, key) && arg[key]) {
340
- classes = appendClass(classes, key);
341
- }
342
- }
343
-
344
- return classes;
345
- }
346
-
347
- function appendClass (value, newClass) {
348
- if (!newClass) {
349
- return value;
350
- }
351
-
352
- if (value) {
353
- return value + ' ' + newClass;
354
- }
355
-
356
- return value + newClass;
357
- }
358
-
359
- if (module.exports) {
360
- classNames.default = classNames;
361
- module.exports = classNames;
362
- } else {
363
- window.classNames = classNames;
364
- }
365
- }());
366
- } (classnames));
367
-
368
- var classNames = classnames.exports;
369
-
370
- var isMobile = (function () {
371
- if (typeof navigator === 'undefined' || typeof window === 'undefined') {
372
- return false;
373
- }
374
- var agent = navigator.userAgent || navigator.vendor || window.opera;
375
- return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(agent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(agent === null || agent === void 0 ? void 0 : agent.substr(0, 4));
376
- });
377
-
378
- /**
379
- * @ignore
380
- * some key-codes definition and utils from closure-library
381
- * @author yiminghe@gmail.com
382
- */
383
-
384
- var KeyCode = {
385
- /**
386
- * MAC_ENTER
387
- */
388
- MAC_ENTER: 3,
389
- /**
390
- * BACKSPACE
391
- */
392
- BACKSPACE: 8,
393
- /**
394
- * TAB
395
- */
396
- TAB: 9,
397
- /**
398
- * NUMLOCK on FF/Safari Mac
399
- */
400
- NUM_CENTER: 12,
401
- // NUMLOCK on FF/Safari Mac
402
- /**
403
- * ENTER
404
- */
405
- ENTER: 13,
406
- /**
407
- * SHIFT
408
- */
409
- SHIFT: 16,
410
- /**
411
- * CTRL
412
- */
413
- CTRL: 17,
414
- /**
415
- * ALT
416
- */
417
- ALT: 18,
418
- /**
419
- * PAUSE
420
- */
421
- PAUSE: 19,
422
- /**
423
- * CAPS_LOCK
424
- */
425
- CAPS_LOCK: 20,
426
- /**
427
- * ESC
428
- */
429
- ESC: 27,
430
- /**
431
- * SPACE
432
- */
433
- SPACE: 32,
434
- /**
435
- * PAGE_UP
436
- */
437
- PAGE_UP: 33,
438
- // also NUM_NORTH_EAST
439
- /**
440
- * PAGE_DOWN
441
- */
442
- PAGE_DOWN: 34,
443
- // also NUM_SOUTH_EAST
444
- /**
445
- * END
446
- */
447
- END: 35,
448
- // also NUM_SOUTH_WEST
449
- /**
450
- * HOME
451
- */
452
- HOME: 36,
453
- // also NUM_NORTH_WEST
454
- /**
455
- * LEFT
456
- */
457
- LEFT: 37,
458
- // also NUM_WEST
459
- /**
460
- * UP
461
- */
462
- UP: 38,
463
- // also NUM_NORTH
464
- /**
465
- * RIGHT
466
- */
467
- RIGHT: 39,
468
- // also NUM_EAST
469
- /**
470
- * DOWN
471
- */
472
- DOWN: 40,
473
- // also NUM_SOUTH
474
- /**
475
- * PRINT_SCREEN
476
- */
477
- PRINT_SCREEN: 44,
478
- /**
479
- * INSERT
480
- */
481
- INSERT: 45,
482
- // also NUM_INSERT
483
- /**
484
- * DELETE
485
- */
486
- DELETE: 46,
487
- // also NUM_DELETE
488
- /**
489
- * ZERO
490
- */
491
- ZERO: 48,
492
- /**
493
- * ONE
494
- */
495
- ONE: 49,
496
- /**
497
- * TWO
498
- */
499
- TWO: 50,
500
- /**
501
- * THREE
502
- */
503
- THREE: 51,
504
- /**
505
- * FOUR
506
- */
507
- FOUR: 52,
508
- /**
509
- * FIVE
510
- */
511
- FIVE: 53,
512
- /**
513
- * SIX
514
- */
515
- SIX: 54,
516
- /**
517
- * SEVEN
518
- */
519
- SEVEN: 55,
520
- /**
521
- * EIGHT
522
- */
523
- EIGHT: 56,
524
- /**
525
- * NINE
526
- */
527
- NINE: 57,
528
- /**
529
- * QUESTION_MARK
530
- */
531
- QUESTION_MARK: 63,
532
- // needs localization
533
- /**
534
- * A
535
- */
536
- A: 65,
537
- /**
538
- * B
539
- */
540
- B: 66,
541
- /**
542
- * C
543
- */
544
- C: 67,
545
- /**
546
- * D
547
- */
548
- D: 68,
549
- /**
550
- * E
551
- */
552
- E: 69,
553
- /**
554
- * F
555
- */
556
- F: 70,
557
- /**
558
- * G
559
- */
560
- G: 71,
561
- /**
562
- * H
563
- */
564
- H: 72,
565
- /**
566
- * I
567
- */
568
- I: 73,
569
- /**
570
- * J
571
- */
572
- J: 74,
573
- /**
574
- * K
575
- */
576
- K: 75,
577
- /**
578
- * L
579
- */
580
- L: 76,
581
- /**
582
- * M
583
- */
584
- M: 77,
585
- /**
586
- * N
587
- */
588
- N: 78,
589
- /**
590
- * O
591
- */
592
- O: 79,
593
- /**
594
- * P
595
- */
596
- P: 80,
597
- /**
598
- * Q
599
- */
600
- Q: 81,
601
- /**
602
- * R
603
- */
604
- R: 82,
605
- /**
606
- * S
607
- */
608
- S: 83,
609
- /**
610
- * T
611
- */
612
- T: 84,
613
- /**
614
- * U
615
- */
616
- U: 85,
617
- /**
618
- * V
619
- */
620
- V: 86,
621
- /**
622
- * W
623
- */
624
- W: 87,
625
- /**
626
- * X
627
- */
628
- X: 88,
629
- /**
630
- * Y
631
- */
632
- Y: 89,
633
- /**
634
- * Z
635
- */
636
- Z: 90,
637
- /**
638
- * META
639
- */
640
- META: 91,
641
- // WIN_KEY_LEFT
642
- /**
643
- * WIN_KEY_RIGHT
644
- */
645
- WIN_KEY_RIGHT: 92,
646
- /**
647
- * CONTEXT_MENU
648
- */
649
- CONTEXT_MENU: 93,
650
- /**
651
- * NUM_ZERO
652
- */
653
- NUM_ZERO: 96,
654
- /**
655
- * NUM_ONE
656
- */
657
- NUM_ONE: 97,
658
- /**
659
- * NUM_TWO
660
- */
661
- NUM_TWO: 98,
662
- /**
663
- * NUM_THREE
664
- */
665
- NUM_THREE: 99,
666
- /**
667
- * NUM_FOUR
668
- */
669
- NUM_FOUR: 100,
670
- /**
671
- * NUM_FIVE
672
- */
673
- NUM_FIVE: 101,
674
- /**
675
- * NUM_SIX
676
- */
677
- NUM_SIX: 102,
678
- /**
679
- * NUM_SEVEN
680
- */
681
- NUM_SEVEN: 103,
682
- /**
683
- * NUM_EIGHT
684
- */
685
- NUM_EIGHT: 104,
686
- /**
687
- * NUM_NINE
688
- */
689
- NUM_NINE: 105,
690
- /**
691
- * NUM_MULTIPLY
692
- */
693
- NUM_MULTIPLY: 106,
694
- /**
695
- * NUM_PLUS
696
- */
697
- NUM_PLUS: 107,
698
- /**
699
- * NUM_MINUS
700
- */
701
- NUM_MINUS: 109,
702
- /**
703
- * NUM_PERIOD
704
- */
705
- NUM_PERIOD: 110,
706
- /**
707
- * NUM_DIVISION
708
- */
709
- NUM_DIVISION: 111,
710
- /**
711
- * F1
712
- */
713
- F1: 112,
714
- /**
715
- * F2
716
- */
717
- F2: 113,
718
- /**
719
- * F3
720
- */
721
- F3: 114,
722
- /**
723
- * F4
724
- */
725
- F4: 115,
726
- /**
727
- * F5
728
- */
729
- F5: 116,
730
- /**
731
- * F6
732
- */
733
- F6: 117,
734
- /**
735
- * F7
736
- */
737
- F7: 118,
738
- /**
739
- * F8
740
- */
741
- F8: 119,
742
- /**
743
- * F9
744
- */
745
- F9: 120,
746
- /**
747
- * F10
748
- */
749
- F10: 121,
750
- /**
751
- * F11
752
- */
753
- F11: 122,
754
- /**
755
- * F12
756
- */
757
- F12: 123,
758
- /**
759
- * NUMLOCK
760
- */
761
- NUMLOCK: 144,
762
- /**
763
- * SEMICOLON
764
- */
765
- SEMICOLON: 186,
766
- // needs localization
767
- /**
768
- * DASH
769
- */
770
- DASH: 189,
771
- // needs localization
772
- /**
773
- * EQUALS
774
- */
775
- EQUALS: 187,
776
- // needs localization
777
- /**
778
- * COMMA
779
- */
780
- COMMA: 188,
781
- // needs localization
782
- /**
783
- * PERIOD
784
- */
785
- PERIOD: 190,
786
- // needs localization
787
- /**
788
- * SLASH
789
- */
790
- SLASH: 191,
791
- // needs localization
792
- /**
793
- * APOSTROPHE
794
- */
795
- APOSTROPHE: 192,
796
- // needs localization
797
- /**
798
- * SINGLE_QUOTE
799
- */
800
- SINGLE_QUOTE: 222,
801
- // needs localization
802
- /**
803
- * OPEN_SQUARE_BRACKET
804
- */
805
- OPEN_SQUARE_BRACKET: 219,
806
- // needs localization
807
- /**
808
- * BACKSLASH
809
- */
810
- BACKSLASH: 220,
811
- // needs localization
812
- /**
813
- * CLOSE_SQUARE_BRACKET
814
- */
815
- CLOSE_SQUARE_BRACKET: 221,
816
- // needs localization
817
- /**
818
- * WIN_KEY
819
- */
820
- WIN_KEY: 224,
821
- /**
822
- * MAC_FF_META
823
- */
824
- MAC_FF_META: 224,
825
- // Firefox (Gecko) fires this for the meta key instead of 91
826
- /**
827
- * WIN_IME
828
- */
829
- WIN_IME: 229,
830
- // ======================== Function ========================
831
- /**
832
- * whether text and modified key is entered at the same time.
833
- */
834
- isTextModifyingKeyEvent: function isTextModifyingKeyEvent(e) {
835
- var keyCode = e.keyCode;
836
- if (e.altKey && !e.ctrlKey || e.metaKey ||
837
- // Function keys don't generate text
838
- keyCode >= KeyCode.F1 && keyCode <= KeyCode.F12) {
839
- return false;
840
- }
841
-
842
- // The following keys are quite harmless, even in combination with
843
- // CTRL, ALT or SHIFT.
844
- switch (keyCode) {
845
- case KeyCode.ALT:
846
- case KeyCode.CAPS_LOCK:
847
- case KeyCode.CONTEXT_MENU:
848
- case KeyCode.CTRL:
849
- case KeyCode.DOWN:
850
- case KeyCode.END:
851
- case KeyCode.ESC:
852
- case KeyCode.HOME:
853
- case KeyCode.INSERT:
854
- case KeyCode.LEFT:
855
- case KeyCode.MAC_FF_META:
856
- case KeyCode.META:
857
- case KeyCode.NUMLOCK:
858
- case KeyCode.NUM_CENTER:
859
- case KeyCode.PAGE_DOWN:
860
- case KeyCode.PAGE_UP:
861
- case KeyCode.PAUSE:
862
- case KeyCode.PRINT_SCREEN:
863
- case KeyCode.RIGHT:
864
- case KeyCode.SHIFT:
865
- case KeyCode.UP:
866
- case KeyCode.WIN_KEY:
867
- case KeyCode.WIN_KEY_RIGHT:
868
- return false;
869
- default:
870
- return true;
871
- }
872
- },
873
- /**
874
- * whether character is entered.
875
- */
876
- isCharacterKey: function isCharacterKey(keyCode) {
877
- if (keyCode >= KeyCode.ZERO && keyCode <= KeyCode.NINE) {
878
- return true;
879
- }
880
- if (keyCode >= KeyCode.NUM_ZERO && keyCode <= KeyCode.NUM_MULTIPLY) {
881
- return true;
882
- }
883
- if (keyCode >= KeyCode.A && keyCode <= KeyCode.Z) {
884
- return true;
885
- }
886
-
887
- // Safari sends zero key code for non-latin characters.
888
- if (window.navigator.userAgent.indexOf('WebKit') !== -1 && keyCode === 0) {
889
- return true;
890
- }
891
- switch (keyCode) {
892
- case KeyCode.SPACE:
893
- case KeyCode.QUESTION_MARK:
894
- case KeyCode.NUM_PLUS:
895
- case KeyCode.NUM_MINUS:
896
- case KeyCode.NUM_PERIOD:
897
- case KeyCode.NUM_DIVISION:
898
- case KeyCode.SEMICOLON:
899
- case KeyCode.DASH:
900
- case KeyCode.EQUALS:
901
- case KeyCode.COMMA:
902
- case KeyCode.PERIOD:
903
- case KeyCode.SLASH:
904
- case KeyCode.APOSTROPHE:
905
- case KeyCode.SINGLE_QUOTE:
906
- case KeyCode.OPEN_SQUARE_BRACKET:
907
- case KeyCode.BACKSLASH:
908
- case KeyCode.CLOSE_SQUARE_BRACKET:
909
- return true;
910
- default:
911
- return false;
912
- }
913
- }
914
- };
915
-
916
- var reactIs = {exports: {}};
917
-
918
- var reactIs_production_min = {};
919
-
920
- /**
921
- * @license React
922
- * react-is.production.min.js
923
- *
924
- * Copyright (c) Facebook, Inc. and its affiliates.
925
- *
926
- * This source code is licensed under the MIT license found in the
927
- * LICENSE file in the root directory of this source tree.
928
- */
929
-
930
- var hasRequiredReactIs_production_min;
931
-
932
- function requireReactIs_production_min () {
933
- if (hasRequiredReactIs_production_min) return reactIs_production_min;
934
- hasRequiredReactIs_production_min = 1;
935
- var b=Symbol.for("react.element"),c=Symbol.for("react.portal"),d=Symbol.for("react.fragment"),e=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),g=Symbol.for("react.provider"),h=Symbol.for("react.context"),k=Symbol.for("react.server_context"),l=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),n=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),t=Symbol.for("react.offscreen"),u;u=Symbol.for("react.module.reference");
936
- function v(a){if("object"===typeof a&&null!==a){var r=a.$$typeof;switch(r){case b:switch(a=a.type,a){case d:case f:case e:case m:case n:return a;default:switch(a=a&&a.$$typeof,a){case k:case h:case l:case q:case p:case g:return a;default:return r}}case c:return r}}}reactIs_production_min.ContextConsumer=h;reactIs_production_min.ContextProvider=g;reactIs_production_min.Element=b;reactIs_production_min.ForwardRef=l;reactIs_production_min.Fragment=d;reactIs_production_min.Lazy=q;reactIs_production_min.Memo=p;reactIs_production_min.Portal=c;reactIs_production_min.Profiler=f;reactIs_production_min.StrictMode=e;reactIs_production_min.Suspense=m;
937
- reactIs_production_min.SuspenseList=n;reactIs_production_min.isAsyncMode=function(){return !1};reactIs_production_min.isConcurrentMode=function(){return !1};reactIs_production_min.isContextConsumer=function(a){return v(a)===h};reactIs_production_min.isContextProvider=function(a){return v(a)===g};reactIs_production_min.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===b};reactIs_production_min.isForwardRef=function(a){return v(a)===l};reactIs_production_min.isFragment=function(a){return v(a)===d};reactIs_production_min.isLazy=function(a){return v(a)===q};reactIs_production_min.isMemo=function(a){return v(a)===p};
938
- reactIs_production_min.isPortal=function(a){return v(a)===c};reactIs_production_min.isProfiler=function(a){return v(a)===f};reactIs_production_min.isStrictMode=function(a){return v(a)===e};reactIs_production_min.isSuspense=function(a){return v(a)===m};reactIs_production_min.isSuspenseList=function(a){return v(a)===n};
939
- reactIs_production_min.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===d||a===f||a===e||a===m||a===n||a===t||"object"===typeof a&&null!==a&&(a.$$typeof===q||a.$$typeof===p||a.$$typeof===g||a.$$typeof===h||a.$$typeof===l||a.$$typeof===u||void 0!==a.getModuleId)?!0:!1};reactIs_production_min.typeOf=v;
940
- return reactIs_production_min;
941
- }
942
-
943
- var reactIs_development = {};
944
-
945
- /**
946
- * @license React
947
- * react-is.development.js
948
- *
949
- * Copyright (c) Facebook, Inc. and its affiliates.
950
- *
951
- * This source code is licensed under the MIT license found in the
952
- * LICENSE file in the root directory of this source tree.
953
- */
954
-
955
- var hasRequiredReactIs_development;
956
-
957
- function requireReactIs_development () {
958
- if (hasRequiredReactIs_development) return reactIs_development;
959
- hasRequiredReactIs_development = 1;
960
-
961
- if (process.env.NODE_ENV !== "production") {
962
- (function() {
963
-
964
- // ATTENTION
965
- // When adding new symbols to this file,
966
- // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
967
- // The Symbol used to tag the ReactElement-like types.
968
- var REACT_ELEMENT_TYPE = Symbol.for('react.element');
969
- var REACT_PORTAL_TYPE = Symbol.for('react.portal');
970
- var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
971
- var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');
972
- var REACT_PROFILER_TYPE = Symbol.for('react.profiler');
973
- var REACT_PROVIDER_TYPE = Symbol.for('react.provider');
974
- var REACT_CONTEXT_TYPE = Symbol.for('react.context');
975
- var REACT_SERVER_CONTEXT_TYPE = Symbol.for('react.server_context');
976
- var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
977
- var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
978
- var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
979
- var REACT_MEMO_TYPE = Symbol.for('react.memo');
980
- var REACT_LAZY_TYPE = Symbol.for('react.lazy');
981
- var REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen');
982
-
983
- // -----------------------------------------------------------------------------
984
-
985
- var enableScopeAPI = false; // Experimental Create Event Handle API.
986
- var enableCacheElement = false;
987
- var enableTransitionTracing = false; // No known bugs, but needs performance testing
988
-
989
- var enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber
990
- // stuff. Intended to enable React core members to more easily debug scheduling
991
- // issues in DEV builds.
992
-
993
- var enableDebugTracing = false; // Track which Fiber(s) schedule render work.
994
-
995
- var REACT_MODULE_REFERENCE;
996
-
997
- {
998
- REACT_MODULE_REFERENCE = Symbol.for('react.module.reference');
999
- }
1000
-
1001
- function isValidElementType(type) {
1002
- if (typeof type === 'string' || typeof type === 'function') {
1003
- return true;
1004
- } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
1005
-
1006
-
1007
- if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing ) {
1008
- return true;
1009
- }
1010
-
1011
- if (typeof type === 'object' && type !== null) {
1012
- if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
1013
- // types supported by any Flight configuration anywhere since
1014
- // we don't know which Flight build this will end up being used
1015
- // with.
1016
- type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) {
1017
- return true;
1018
- }
1019
- }
1020
-
1021
- return false;
1022
- }
1023
-
1024
- function typeOf(object) {
1025
- if (typeof object === 'object' && object !== null) {
1026
- var $$typeof = object.$$typeof;
1027
-
1028
- switch ($$typeof) {
1029
- case REACT_ELEMENT_TYPE:
1030
- var type = object.type;
1031
-
1032
- switch (type) {
1033
- case REACT_FRAGMENT_TYPE:
1034
- case REACT_PROFILER_TYPE:
1035
- case REACT_STRICT_MODE_TYPE:
1036
- case REACT_SUSPENSE_TYPE:
1037
- case REACT_SUSPENSE_LIST_TYPE:
1038
- return type;
1039
-
1040
- default:
1041
- var $$typeofType = type && type.$$typeof;
1042
-
1043
- switch ($$typeofType) {
1044
- case REACT_SERVER_CONTEXT_TYPE:
1045
- case REACT_CONTEXT_TYPE:
1046
- case REACT_FORWARD_REF_TYPE:
1047
- case REACT_LAZY_TYPE:
1048
- case REACT_MEMO_TYPE:
1049
- case REACT_PROVIDER_TYPE:
1050
- return $$typeofType;
1051
-
1052
- default:
1053
- return $$typeof;
1054
- }
1055
-
1056
- }
1057
-
1058
- case REACT_PORTAL_TYPE:
1059
- return $$typeof;
1060
- }
1061
- }
1062
-
1063
- return undefined;
1064
- }
1065
- var ContextConsumer = REACT_CONTEXT_TYPE;
1066
- var ContextProvider = REACT_PROVIDER_TYPE;
1067
- var Element = REACT_ELEMENT_TYPE;
1068
- var ForwardRef = REACT_FORWARD_REF_TYPE;
1069
- var Fragment = REACT_FRAGMENT_TYPE;
1070
- var Lazy = REACT_LAZY_TYPE;
1071
- var Memo = REACT_MEMO_TYPE;
1072
- var Portal = REACT_PORTAL_TYPE;
1073
- var Profiler = REACT_PROFILER_TYPE;
1074
- var StrictMode = REACT_STRICT_MODE_TYPE;
1075
- var Suspense = REACT_SUSPENSE_TYPE;
1076
- var SuspenseList = REACT_SUSPENSE_LIST_TYPE;
1077
- var hasWarnedAboutDeprecatedIsAsyncMode = false;
1078
- var hasWarnedAboutDeprecatedIsConcurrentMode = false; // AsyncMode should be deprecated
1079
-
1080
- function isAsyncMode(object) {
1081
- {
1082
- if (!hasWarnedAboutDeprecatedIsAsyncMode) {
1083
- hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
1084
-
1085
- console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 18+.');
1086
- }
1087
- }
1088
-
1089
- return false;
1090
- }
1091
- function isConcurrentMode(object) {
1092
- {
1093
- if (!hasWarnedAboutDeprecatedIsConcurrentMode) {
1094
- hasWarnedAboutDeprecatedIsConcurrentMode = true; // Using console['warn'] to evade Babel and ESLint
1095
-
1096
- console['warn']('The ReactIs.isConcurrentMode() alias has been deprecated, ' + 'and will be removed in React 18+.');
1097
- }
1098
- }
1099
-
1100
- return false;
1101
- }
1102
- function isContextConsumer(object) {
1103
- return typeOf(object) === REACT_CONTEXT_TYPE;
1104
- }
1105
- function isContextProvider(object) {
1106
- return typeOf(object) === REACT_PROVIDER_TYPE;
1107
- }
1108
- function isElement(object) {
1109
- return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
1110
- }
1111
- function isForwardRef(object) {
1112
- return typeOf(object) === REACT_FORWARD_REF_TYPE;
1113
- }
1114
- function isFragment(object) {
1115
- return typeOf(object) === REACT_FRAGMENT_TYPE;
1116
- }
1117
- function isLazy(object) {
1118
- return typeOf(object) === REACT_LAZY_TYPE;
1119
- }
1120
- function isMemo(object) {
1121
- return typeOf(object) === REACT_MEMO_TYPE;
1122
- }
1123
- function isPortal(object) {
1124
- return typeOf(object) === REACT_PORTAL_TYPE;
1125
- }
1126
- function isProfiler(object) {
1127
- return typeOf(object) === REACT_PROFILER_TYPE;
1128
- }
1129
- function isStrictMode(object) {
1130
- return typeOf(object) === REACT_STRICT_MODE_TYPE;
1131
- }
1132
- function isSuspense(object) {
1133
- return typeOf(object) === REACT_SUSPENSE_TYPE;
1134
- }
1135
- function isSuspenseList(object) {
1136
- return typeOf(object) === REACT_SUSPENSE_LIST_TYPE;
1137
- }
1138
-
1139
- reactIs_development.ContextConsumer = ContextConsumer;
1140
- reactIs_development.ContextProvider = ContextProvider;
1141
- reactIs_development.Element = Element;
1142
- reactIs_development.ForwardRef = ForwardRef;
1143
- reactIs_development.Fragment = Fragment;
1144
- reactIs_development.Lazy = Lazy;
1145
- reactIs_development.Memo = Memo;
1146
- reactIs_development.Portal = Portal;
1147
- reactIs_development.Profiler = Profiler;
1148
- reactIs_development.StrictMode = StrictMode;
1149
- reactIs_development.Suspense = Suspense;
1150
- reactIs_development.SuspenseList = SuspenseList;
1151
- reactIs_development.isAsyncMode = isAsyncMode;
1152
- reactIs_development.isConcurrentMode = isConcurrentMode;
1153
- reactIs_development.isContextConsumer = isContextConsumer;
1154
- reactIs_development.isContextProvider = isContextProvider;
1155
- reactIs_development.isElement = isElement;
1156
- reactIs_development.isForwardRef = isForwardRef;
1157
- reactIs_development.isFragment = isFragment;
1158
- reactIs_development.isLazy = isLazy;
1159
- reactIs_development.isMemo = isMemo;
1160
- reactIs_development.isPortal = isPortal;
1161
- reactIs_development.isProfiler = isProfiler;
1162
- reactIs_development.isStrictMode = isStrictMode;
1163
- reactIs_development.isSuspense = isSuspense;
1164
- reactIs_development.isSuspenseList = isSuspenseList;
1165
- reactIs_development.isValidElementType = isValidElementType;
1166
- reactIs_development.typeOf = typeOf;
1167
- })();
1168
- }
1169
- return reactIs_development;
1170
- }
1171
-
1172
- (function (module) {
1173
-
1174
- if (process.env.NODE_ENV === 'production') {
1175
- module.exports = requireReactIs_production_min();
1176
- } else {
1177
- module.exports = requireReactIs_development();
1178
- }
1179
- } (reactIs));
1180
-
1181
- function useMemo(getValue, condition, shouldUpdate) {
1182
- var cacheRef = React$4.useRef({});
1183
- if (!('value' in cacheRef.current) || shouldUpdate(cacheRef.current.condition, condition)) {
1184
- cacheRef.current.value = getValue();
1185
- cacheRef.current.condition = condition;
1186
- }
1187
- return cacheRef.current.value;
1188
- }
1189
-
1190
- function fillRef(ref, node) {
1191
- if (typeof ref === 'function') {
1192
- ref(node);
1193
- } else if (_typeof$1(ref) === 'object' && ref && 'current' in ref) {
1194
- ref.current = node;
1195
- }
1196
- }
1197
-
1198
- /**
1199
- * Merge refs into one ref function to support ref passing.
1200
- */
1201
- function composeRef() {
1202
- for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
1203
- refs[_key] = arguments[_key];
1204
- }
1205
- var refList = refs.filter(function (ref) {
1206
- return ref;
1207
- });
1208
- if (refList.length <= 1) {
1209
- return refList[0];
1210
- }
1211
- return function (node) {
1212
- refs.forEach(function (ref) {
1213
- fillRef(ref, node);
1214
- });
1215
- };
1216
- }
1217
- function useComposeRef() {
1218
- for (var _len2 = arguments.length, refs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
1219
- refs[_key2] = arguments[_key2];
1220
- }
1221
- return useMemo(function () {
1222
- return composeRef.apply(void 0, refs);
1223
- }, refs, function (prev, next) {
1224
- return prev.length !== next.length || prev.every(function (ref, i) {
1225
- return ref !== next[i];
1226
- });
1227
- });
1228
- }
1229
- function supportRef(nodeOrComponent) {
1230
- var _type$prototype, _nodeOrComponent$prot;
1231
- var type = reactIs.exports.isMemo(nodeOrComponent) ? nodeOrComponent.type.type : nodeOrComponent.type;
1232
-
1233
- // Function component node
1234
- if (typeof type === 'function' && !((_type$prototype = type.prototype) !== null && _type$prototype !== void 0 && _type$prototype.render) && type.$$typeof !== reactIs.exports.ForwardRef) {
1235
- return false;
1236
- }
1237
-
1238
- // Class component
1239
- if (typeof nodeOrComponent === 'function' && !((_nodeOrComponent$prot = nodeOrComponent.prototype) !== null && _nodeOrComponent$prot !== void 0 && _nodeOrComponent$prot.render) && nodeOrComponent.$$typeof !== reactIs.exports.ForwardRef) {
1240
- return false;
1241
- }
1242
- return true;
1243
- }
1244
- /* eslint-enable */
1245
-
1246
- var TransBtn = function TransBtn(_ref) {
1247
- var className = _ref.className,
1248
- customizeIcon = _ref.customizeIcon,
1249
- customizeIconProps = _ref.customizeIconProps,
1250
- _onMouseDown = _ref.onMouseDown,
1251
- onClick = _ref.onClick,
1252
- children = _ref.children;
1253
- var icon;
1254
- if (typeof customizeIcon === 'function') {
1255
- icon = customizeIcon(customizeIconProps);
1256
- } else {
1257
- icon = customizeIcon;
1258
- }
1259
- return /*#__PURE__*/React$4.createElement("span", {
1260
- className: className,
1261
- onMouseDown: function onMouseDown(event) {
1262
- event.preventDefault();
1263
- if (_onMouseDown) {
1264
- _onMouseDown(event);
1265
- }
1266
- },
1267
- style: {
1268
- userSelect: 'none',
1269
- WebkitUserSelect: 'none'
1270
- },
1271
- unselectable: "on",
1272
- onClick: onClick,
1273
- "aria-hidden": true
1274
- }, icon !== undefined ? icon : /*#__PURE__*/React$4.createElement("span", {
1275
- className: classNames(className.split(/\s+/).map(function (cls) {
1276
- return "".concat(cls, "-icon");
1277
- }))
1278
- }, children));
1279
- };
1280
-
1281
- function useAllowClear(prefixCls, onClearMouseDown, displayValues, allowClear, clearIcon) {
1282
- var disabled = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
1283
- var mergedSearchValue = arguments.length > 6 ? arguments[6] : undefined;
1284
- var mode = arguments.length > 7 ? arguments[7] : undefined;
1285
- var mergedClearIcon = React__default.useMemo(function () {
1286
- if (_typeof$1(allowClear) === "object") {
1287
- return allowClear.clearIcon;
1288
- }
1289
- if (!!clearIcon) return clearIcon;
1290
- }, [allowClear, clearIcon]);
1291
- var mergedAllowClear = React__default.useMemo(function () {
1292
- if (!disabled && !!allowClear && (displayValues.length || mergedSearchValue) && !(mode === 'combobox' && mergedSearchValue === '')) {
1293
- return true;
1294
- }
1295
- return false;
1296
- }, [allowClear, disabled, displayValues.length, mergedSearchValue, mode]);
1297
- return {
1298
- allowClear: mergedAllowClear,
1299
- clearIcon: /*#__PURE__*/React__default.createElement(TransBtn, {
1300
- className: "".concat(prefixCls, "-clear"),
1301
- onMouseDown: onClearMouseDown,
1302
- customizeIcon: mergedClearIcon
1303
- }, "\xD7")
1304
- };
1305
- }
1306
-
1307
- /**
1308
- * BaseSelect provide some parsed data into context.
1309
- * You can use this hooks to get them.
1310
- */
1311
- var BaseSelectContext = /*#__PURE__*/React$4.createContext(null);
1312
- function useBaseProps() {
1313
- return React$4.useContext(BaseSelectContext);
1314
- }
1315
-
1316
- /**
1317
- * Similar with `useLock`, but this hook will always execute last value.
1318
- * When set to `true`, it will keep `true` for a short time even if `false` is set.
1319
- */
1320
- function useDelayReset() {
1321
- var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
1322
- var _React$useState = React$4.useState(false),
1323
- _React$useState2 = _slicedToArray(_React$useState, 2),
1324
- bool = _React$useState2[0],
1325
- setBool = _React$useState2[1];
1326
- var delayRef = React$4.useRef(null);
1327
- var cancelLatest = function cancelLatest() {
1328
- window.clearTimeout(delayRef.current);
1329
- };
1330
- React$4.useEffect(function () {
1331
- return cancelLatest;
1332
- }, []);
1333
- var delaySetBool = function delaySetBool(value, callback) {
1334
- cancelLatest();
1335
- delayRef.current = window.setTimeout(function () {
1336
- setBool(value);
1337
- if (callback) {
1338
- callback();
1339
- }
1340
- }, timeout);
1341
- };
1342
- return [bool, delaySetBool, cancelLatest];
1343
- }
1344
-
1345
- /**
1346
- * Locker return cached mark.
1347
- * If set to `true`, will return `true` in a short time even if set `false`.
1348
- * If set to `false` and then set to `true`, will change to `true`.
1349
- * And after time duration, it will back to `null` automatically.
1350
- */
1351
- function useLock() {
1352
- var duration = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 250;
1353
- var lockRef = React$4.useRef(null);
1354
- var timeoutRef = React$4.useRef(null);
1355
-
1356
- // Clean up
1357
- React$4.useEffect(function () {
1358
- return function () {
1359
- window.clearTimeout(timeoutRef.current);
1360
- };
1361
- }, []);
1362
- function doLock(locked) {
1363
- if (locked || lockRef.current === null) {
1364
- lockRef.current = locked;
1365
- }
1366
- window.clearTimeout(timeoutRef.current);
1367
- timeoutRef.current = window.setTimeout(function () {
1368
- lockRef.current = null;
1369
- }, duration);
1370
- }
1371
- return [function () {
1372
- return lockRef.current;
1373
- }, doLock];
1374
- }
1375
-
1376
- function useSelectTriggerControl(elements, open, triggerOpen, customizedTrigger) {
1377
- var propsRef = React$4.useRef(null);
1378
- propsRef.current = {
1379
- open: open,
1380
- triggerOpen: triggerOpen,
1381
- customizedTrigger: customizedTrigger
1382
- };
1383
- React$4.useEffect(function () {
1384
- function onGlobalMouseDown(event) {
1385
- var _propsRef$current;
1386
- // If trigger is customized, Trigger will take control of popupVisible
1387
- if ((_propsRef$current = propsRef.current) !== null && _propsRef$current !== void 0 && _propsRef$current.customizedTrigger) {
1388
- return;
1389
- }
1390
- var target = event.target;
1391
- if (target.shadowRoot && event.composed) {
1392
- target = event.composedPath()[0] || target;
1393
- }
1394
- if (propsRef.current.open && elements().filter(function (element) {
1395
- return element;
1396
- }).every(function (element) {
1397
- return !element.contains(target) && element !== target;
1398
- })) {
1399
- // Should trigger close
1400
- propsRef.current.triggerOpen(false);
1401
- }
1402
- }
1403
- window.addEventListener('mousedown', onGlobalMouseDown);
1404
- return function () {
1405
- return window.removeEventListener('mousedown', onGlobalMouseDown);
1406
- };
1407
- }, []);
1408
- }
1409
-
1410
- var attributes = "accept acceptCharset accessKey action allowFullScreen allowTransparency\n alt async autoComplete autoFocus autoPlay capture cellPadding cellSpacing challenge\n charSet checked classID className colSpan cols content contentEditable contextMenu\n controls coords crossOrigin data dateTime default defer dir disabled download draggable\n encType form formAction formEncType formMethod formNoValidate formTarget frameBorder\n headers height hidden high href hrefLang htmlFor httpEquiv icon id inputMode integrity\n is keyParams keyType kind label lang list loop low manifest marginHeight marginWidth max maxLength media\n mediaGroup method min minLength multiple muted name noValidate nonce open\n optimum pattern placeholder poster preload radioGroup readOnly rel required\n reversed role rowSpan rows sandbox scope scoped scrolling seamless selected\n shape size sizes span spellCheck src srcDoc srcLang srcSet start step style\n summary tabIndex target title type useMap value width wmode wrap";
1411
- var eventsName = "onCopy onCut onPaste onCompositionEnd onCompositionStart onCompositionUpdate onKeyDown\n onKeyPress onKeyUp onFocus onBlur onChange onInput onSubmit onClick onContextMenu onDoubleClick\n onDrag onDragEnd onDragEnter onDragExit onDragLeave onDragOver onDragStart onDrop onMouseDown\n onMouseEnter onMouseLeave onMouseMove onMouseOut onMouseOver onMouseUp onSelect onTouchCancel\n onTouchEnd onTouchMove onTouchStart onScroll onWheel onAbort onCanPlay onCanPlayThrough\n onDurationChange onEmptied onEncrypted onEnded onError onLoadedData onLoadedMetadata\n onLoadStart onPause onPlay onPlaying onProgress onRateChange onSeeked onSeeking onStalled onSuspend onTimeUpdate onVolumeChange onWaiting onLoad onError";
1412
- var propList = "".concat(attributes, " ").concat(eventsName).split(/[\s\n]+/);
1413
-
1414
- /* eslint-enable max-len */
1415
- var ariaPrefix = 'aria-';
1416
- var dataPrefix = 'data-';
1417
- function match(key, prefix) {
1418
- return key.indexOf(prefix) === 0;
1419
- }
1420
- /**
1421
- * Picker props from exist props with filter
1422
- * @param props Passed props
1423
- * @param ariaOnly boolean | { aria?: boolean; data?: boolean; attr?: boolean; } filter config
212
+ * Picker props from exist props with filter
213
+ * @param props Passed props
214
+ * @param ariaOnly boolean | { aria?: boolean; data?: boolean; attr?: boolean; } filter config
1424
215
  */
1425
216
  function pickAttrs(props) {
1426
217
  var ariaOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
@@ -2781,7 +1572,7 @@ function InternalItem(props, ref) {
2781
1572
  overflowProps['aria-hidden'] = true;
2782
1573
  }
2783
1574
  var itemNode = /*#__PURE__*/React$4.createElement(Component, _extends({
2784
- className: classNames(!invalidate && prefixCls, className),
1575
+ className: clsx(!invalidate && prefixCls, className),
2785
1576
  style: _objectSpread2(_objectSpread2({}, overflowStyle), style)
2786
1577
  }, overflowProps, restProps, {
2787
1578
  ref: ref
@@ -2793,66 +1584,12 @@ function InternalItem(props, ref) {
2793
1584
  internalRegisterSize(offsetWidth);
2794
1585
  },
2795
1586
  disabled: responsiveDisabled
2796
- }, itemNode);
2797
- }
2798
- return itemNode;
2799
- }
2800
- var Item$1 = /*#__PURE__*/React$4.forwardRef(InternalItem);
2801
- Item$1.displayName = 'Item';
2802
-
2803
- var raf = function raf(callback) {
2804
- return +setTimeout(callback, 16);
2805
- };
2806
- var caf = function caf(num) {
2807
- return clearTimeout(num);
2808
- };
2809
- if (typeof window !== 'undefined' && 'requestAnimationFrame' in window) {
2810
- raf = function raf(callback) {
2811
- return window.requestAnimationFrame(callback);
2812
- };
2813
- caf = function caf(handle) {
2814
- return window.cancelAnimationFrame(handle);
2815
- };
2816
- }
2817
- var rafUUID = 0;
2818
- var rafIds = new Map();
2819
- function cleanup(id) {
2820
- rafIds.delete(id);
2821
- }
2822
- var wrapperRaf = function wrapperRaf(callback) {
2823
- var times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
2824
- rafUUID += 1;
2825
- var id = rafUUID;
2826
- function callRef(leftTimes) {
2827
- if (leftTimes === 0) {
2828
- // Clean up
2829
- cleanup(id);
2830
-
2831
- // Trigger
2832
- callback();
2833
- } else {
2834
- // Next raf
2835
- var realId = raf(function () {
2836
- callRef(leftTimes - 1);
2837
- });
2838
-
2839
- // Bind real raf id
2840
- rafIds.set(id, realId);
2841
- }
1587
+ }, itemNode);
2842
1588
  }
2843
- callRef(times);
2844
- return id;
2845
- };
2846
- wrapperRaf.cancel = function (id) {
2847
- var realId = rafIds.get(id);
2848
- cleanup(id);
2849
- return caf(realId);
2850
- };
2851
- if (process.env.NODE_ENV !== 'production') {
2852
- wrapperRaf.ids = function () {
2853
- return rafIds;
2854
- };
1589
+ return itemNode;
2855
1590
  }
1591
+ var Item$1 = /*#__PURE__*/React$4.forwardRef(InternalItem);
1592
+ Item$1.displayName = 'Item';
2856
1593
 
2857
1594
  function channelUpdate(callback) {
2858
1595
  if (typeof MessageChannel === 'undefined') {
@@ -2932,7 +1669,7 @@ var InternalRawItem = function InternalRawItem(props, ref) {
2932
1669
  value: null
2933
1670
  }, /*#__PURE__*/React$4.createElement(Item$1, _extends({
2934
1671
  ref: ref,
2935
- className: classNames(contextClassName, className)
1672
+ className: clsx(contextClassName, className)
2936
1673
  }, restContext, restProps)));
2937
1674
  };
2938
1675
  var RawItem = /*#__PURE__*/React$4.forwardRef(InternalRawItem);
@@ -3018,7 +1755,7 @@ function Overflow(props, ref) {
3018
1755
  * When is `responsive`, we will always render rest node to get the real width of it for calculation
3019
1756
  */
3020
1757
  var showRest = shouldResponsive || typeof maxCount === 'number' && data.length > maxCount;
3021
- var mergedData = useMemo$1(function () {
1758
+ var mergedData = useMemo(function () {
3022
1759
  var items = data;
3023
1760
  if (shouldResponsive) {
3024
1761
  if (containerWidth === null && fullySSR) {
@@ -3031,7 +1768,7 @@ function Overflow(props, ref) {
3031
1768
  }
3032
1769
  return items;
3033
1770
  }, [data, itemWidth, containerWidth, maxCount, shouldResponsive]);
3034
- var omittedItems = useMemo$1(function () {
1771
+ var omittedItems = useMemo(function () {
3035
1772
  if (shouldResponsive) {
3036
1773
  return data.slice(mergedDisplayCount + 1);
3037
1774
  }
@@ -3190,7 +1927,7 @@ function Overflow(props, ref) {
3190
1927
  }, renderRawRest(omittedItems));
3191
1928
  }
3192
1929
  var overflowNode = /*#__PURE__*/React$4.createElement(Component, _extends({
3193
- className: classNames(!invalidate && prefixCls, className),
1930
+ className: clsx(!invalidate && prefixCls, className),
3194
1931
  style: style,
3195
1932
  ref: ref
3196
1933
  }, restProps), mergedData.map(internalRenderItemNode), showRest ? restNode : null, suffix && /*#__PURE__*/React$4.createElement(Item$1, _extends({}, itemSharedProps, {
@@ -3258,7 +1995,7 @@ var Input = function Input(_ref, ref) {
3258
1995
  tabIndex: tabIndex,
3259
1996
  autoComplete: autoComplete || 'off',
3260
1997
  autoFocus: autoFocus,
3261
- className: classNames("".concat(prefixCls, "-selection-search-input"), (_inputNode2 = inputNode) === null || _inputNode2 === void 0 ? void 0 : (_inputNode2$props = _inputNode2.props) === null || _inputNode2$props === void 0 ? void 0 : _inputNode2$props.className),
1998
+ className: clsx("".concat(prefixCls, "-selection-search-input"), (_inputNode2 = inputNode) === null || _inputNode2 === void 0 ? void 0 : (_inputNode2$props = _inputNode2.props) === null || _inputNode2$props === void 0 ? void 0 : _inputNode2$props.className),
3262
1999
  role: 'combobox',
3263
2000
  'aria-label': 'Search',
3264
2001
  'aria-expanded': open,
@@ -3425,7 +2162,7 @@ var SelectSelector = function SelectSelector(props) {
3425
2162
  // >>> Render Selector Node. Includes Item & Rest
3426
2163
  function defaultRenderSelector(item, content, itemDisabled, closable, onClose) {
3427
2164
  return /*#__PURE__*/React$4.createElement("span", {
3428
- className: classNames("".concat(selectionPrefixCls, "-item"), _defineProperty({}, "".concat(selectionPrefixCls, "-item-disabled"), itemDisabled)),
2165
+ className: clsx("".concat(selectionPrefixCls, "-item"), _defineProperty({}, "".concat(selectionPrefixCls, "-item-disabled"), itemDisabled)),
3429
2166
  title: getTitle(item)
3430
2167
  }, /*#__PURE__*/React$4.createElement("span", {
3431
2168
  className: "".concat(selectionPrefixCls, "-item-content")
@@ -3782,436 +2519,6 @@ var Selector = function Selector(props, ref) {
3782
2519
  var ForwardSelector = /*#__PURE__*/React$4.forwardRef(Selector);
3783
2520
  ForwardSelector.displayName = 'Selector';
3784
2521
 
3785
- var OrderContext = /*#__PURE__*/React$4.createContext(null);
3786
-
3787
- var EMPTY_LIST = [];
3788
-
3789
- /**
3790
- * Will add `div` to document. Nest call will keep order
3791
- * @param render Render DOM in document
3792
- */
3793
- function useDom(render, debug) {
3794
- var _React$useState = React$4.useState(function () {
3795
- if (!canUseDom$1()) {
3796
- return null;
3797
- }
3798
- var defaultEle = document.createElement('div');
3799
- if (process.env.NODE_ENV !== 'production' && debug) {
3800
- defaultEle.setAttribute('data-debug', debug);
3801
- }
3802
- return defaultEle;
3803
- }),
3804
- _React$useState2 = _slicedToArray(_React$useState, 1),
3805
- ele = _React$useState2[0];
3806
-
3807
- // ========================== Order ==========================
3808
- var appendedRef = React$4.useRef(false);
3809
- var queueCreate = React$4.useContext(OrderContext);
3810
- var _React$useState3 = React$4.useState(EMPTY_LIST),
3811
- _React$useState4 = _slicedToArray(_React$useState3, 2),
3812
- queue = _React$useState4[0],
3813
- setQueue = _React$useState4[1];
3814
- var mergedQueueCreate = queueCreate || (appendedRef.current ? undefined : function (appendFn) {
3815
- setQueue(function (origin) {
3816
- var newQueue = [appendFn].concat(_toConsumableArray(origin));
3817
- return newQueue;
3818
- });
3819
- });
3820
-
3821
- // =========================== DOM ===========================
3822
- function append() {
3823
- if (!ele.parentElement) {
3824
- document.body.appendChild(ele);
3825
- }
3826
- appendedRef.current = true;
3827
- }
3828
- function cleanup() {
3829
- var _ele$parentElement;
3830
- (_ele$parentElement = ele.parentElement) === null || _ele$parentElement === void 0 ? void 0 : _ele$parentElement.removeChild(ele);
3831
- appendedRef.current = false;
3832
- }
3833
- useLayoutEffect$3(function () {
3834
- if (render) {
3835
- if (queueCreate) {
3836
- queueCreate(append);
3837
- } else {
3838
- append();
3839
- }
3840
- } else {
3841
- cleanup();
3842
- }
3843
- return cleanup;
3844
- }, [render]);
3845
- useLayoutEffect$3(function () {
3846
- if (queue.length) {
3847
- queue.forEach(function (appendFn) {
3848
- return appendFn();
3849
- });
3850
- setQueue(EMPTY_LIST);
3851
- }
3852
- }, [queue]);
3853
- return [ele, mergedQueueCreate];
3854
- }
3855
-
3856
- function contains(root, n) {
3857
- if (!root) {
3858
- return false;
3859
- }
3860
-
3861
- // Use native if support
3862
- if (root.contains) {
3863
- return root.contains(n);
3864
- }
3865
-
3866
- // `document.contains` not support with IE11
3867
- var node = n;
3868
- while (node) {
3869
- if (node === root) {
3870
- return true;
3871
- }
3872
- node = node.parentNode;
3873
- }
3874
- return false;
3875
- }
3876
-
3877
- var APPEND_ORDER = 'data-rc-order';
3878
- var APPEND_PRIORITY = 'data-rc-priority';
3879
- var MARK_KEY = "rc-util-key";
3880
- var containerCache = new Map();
3881
- function getMark() {
3882
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
3883
- mark = _ref.mark;
3884
- if (mark) {
3885
- return mark.startsWith('data-') ? mark : "data-".concat(mark);
3886
- }
3887
- return MARK_KEY;
3888
- }
3889
- function getContainer(option) {
3890
- if (option.attachTo) {
3891
- return option.attachTo;
3892
- }
3893
- var head = document.querySelector('head');
3894
- return head || document.body;
3895
- }
3896
- function getOrder(prepend) {
3897
- if (prepend === 'queue') {
3898
- return 'prependQueue';
3899
- }
3900
- return prepend ? 'prepend' : 'append';
3901
- }
3902
-
3903
- /**
3904
- * Find style which inject by rc-util
3905
- */
3906
- function findStyles(container) {
3907
- return Array.from((containerCache.get(container) || container).children).filter(function (node) {
3908
- return node.tagName === 'STYLE';
3909
- });
3910
- }
3911
- function injectCSS(css) {
3912
- var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3913
- if (!canUseDom$1()) {
3914
- return null;
3915
- }
3916
- var csp = option.csp,
3917
- prepend = option.prepend,
3918
- _option$priority = option.priority,
3919
- priority = _option$priority === void 0 ? 0 : _option$priority;
3920
- var mergedOrder = getOrder(prepend);
3921
- var isPrependQueue = mergedOrder === 'prependQueue';
3922
- var styleNode = document.createElement('style');
3923
- styleNode.setAttribute(APPEND_ORDER, mergedOrder);
3924
- if (isPrependQueue && priority) {
3925
- styleNode.setAttribute(APPEND_PRIORITY, "".concat(priority));
3926
- }
3927
- if (csp !== null && csp !== void 0 && csp.nonce) {
3928
- styleNode.nonce = csp === null || csp === void 0 ? void 0 : csp.nonce;
3929
- }
3930
- styleNode.innerHTML = css;
3931
- var container = getContainer(option);
3932
- var firstChild = container.firstChild;
3933
- if (prepend) {
3934
- // If is queue `prepend`, it will prepend first style and then append rest style
3935
- if (isPrependQueue) {
3936
- var existStyle = (option.styles || findStyles(container)).filter(function (node) {
3937
- // Ignore style which not injected by rc-util with prepend
3938
- if (!['prepend', 'prependQueue'].includes(node.getAttribute(APPEND_ORDER))) {
3939
- return false;
3940
- }
3941
-
3942
- // Ignore style which priority less then new style
3943
- var nodePriority = Number(node.getAttribute(APPEND_PRIORITY) || 0);
3944
- return priority >= nodePriority;
3945
- });
3946
- if (existStyle.length) {
3947
- container.insertBefore(styleNode, existStyle[existStyle.length - 1].nextSibling);
3948
- return styleNode;
3949
- }
3950
- }
3951
-
3952
- // Use `insertBefore` as `prepend`
3953
- container.insertBefore(styleNode, firstChild);
3954
- } else {
3955
- container.appendChild(styleNode);
3956
- }
3957
- return styleNode;
3958
- }
3959
- function findExistNode(key) {
3960
- var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3961
- var container = getContainer(option);
3962
- return (option.styles || findStyles(container)).find(function (node) {
3963
- return node.getAttribute(getMark(option)) === key;
3964
- });
3965
- }
3966
- function removeCSS(key) {
3967
- var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3968
- var existNode = findExistNode(key, option);
3969
- if (existNode) {
3970
- var container = getContainer(option);
3971
- container.removeChild(existNode);
3972
- }
3973
- }
3974
-
3975
- /**
3976
- * qiankun will inject `appendChild` to insert into other
3977
- */
3978
- function syncRealContainer(container, option) {
3979
- var cachedRealContainer = containerCache.get(container);
3980
-
3981
- // Find real container when not cached or cached container removed
3982
- if (!cachedRealContainer || !contains(document, cachedRealContainer)) {
3983
- var placeholderStyle = injectCSS('', option);
3984
- var parentNode = placeholderStyle.parentNode;
3985
- containerCache.set(container, parentNode);
3986
- container.removeChild(placeholderStyle);
3987
- }
3988
- }
3989
- function updateCSS(css, key) {
3990
- var originOption = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
3991
- var container = getContainer(originOption);
3992
- var styles = findStyles(container);
3993
- var option = _objectSpread2(_objectSpread2({}, originOption), {}, {
3994
- styles: styles
3995
- });
3996
-
3997
- // Sync real parent
3998
- syncRealContainer(container, option);
3999
- var existNode = findExistNode(key, option);
4000
- if (existNode) {
4001
- var _option$csp, _option$csp2;
4002
- if ((_option$csp = option.csp) !== null && _option$csp !== void 0 && _option$csp.nonce && existNode.nonce !== ((_option$csp2 = option.csp) === null || _option$csp2 === void 0 ? void 0 : _option$csp2.nonce)) {
4003
- var _option$csp3;
4004
- existNode.nonce = (_option$csp3 = option.csp) === null || _option$csp3 === void 0 ? void 0 : _option$csp3.nonce;
4005
- }
4006
- if (existNode.innerHTML !== css) {
4007
- existNode.innerHTML = css;
4008
- }
4009
- return existNode;
4010
- }
4011
- var newNode = injectCSS(css, option);
4012
- newNode.setAttribute(getMark(option), key);
4013
- return newNode;
4014
- }
4015
-
4016
- /* eslint-disable no-param-reassign */
4017
- function measureScrollbarSize(ele) {
4018
- var randomId = "rc-scrollbar-measure-".concat(Math.random().toString(36).substring(7));
4019
- var measureEle = document.createElement('div');
4020
- measureEle.id = randomId;
4021
-
4022
- // Create Style
4023
- var measureStyle = measureEle.style;
4024
- measureStyle.position = 'absolute';
4025
- measureStyle.left = '0';
4026
- measureStyle.top = '0';
4027
- measureStyle.width = '100px';
4028
- measureStyle.height = '100px';
4029
- measureStyle.overflow = 'scroll';
4030
-
4031
- // Clone Style if needed
4032
- var fallbackWidth;
4033
- var fallbackHeight;
4034
- if (ele) {
4035
- var targetStyle = getComputedStyle(ele);
4036
- measureStyle.scrollbarColor = targetStyle.scrollbarColor;
4037
- measureStyle.scrollbarWidth = targetStyle.scrollbarWidth;
4038
-
4039
- // Set Webkit style
4040
- var webkitScrollbarStyle = getComputedStyle(ele, '::-webkit-scrollbar');
4041
- var width = parseInt(webkitScrollbarStyle.width, 10);
4042
- var height = parseInt(webkitScrollbarStyle.height, 10);
4043
-
4044
- // Try wrap to handle CSP case
4045
- try {
4046
- var widthStyle = width ? "width: ".concat(webkitScrollbarStyle.width, ";") : '';
4047
- var heightStyle = height ? "height: ".concat(webkitScrollbarStyle.height, ";") : '';
4048
- updateCSS("\n#".concat(randomId, "::-webkit-scrollbar {\n").concat(widthStyle, "\n").concat(heightStyle, "\n}"), randomId);
4049
- } catch (e) {
4050
- // Can't wrap, just log error
4051
- console.error(e);
4052
-
4053
- // Get from style directly
4054
- fallbackWidth = width;
4055
- fallbackHeight = height;
4056
- }
4057
- }
4058
- document.body.appendChild(measureEle);
4059
-
4060
- // Measure. Get fallback style if provided
4061
- var scrollWidth = ele && fallbackWidth && !isNaN(fallbackWidth) ? fallbackWidth : measureEle.offsetWidth - measureEle.clientWidth;
4062
- var scrollHeight = ele && fallbackHeight && !isNaN(fallbackHeight) ? fallbackHeight : measureEle.offsetHeight - measureEle.clientHeight;
4063
-
4064
- // Clean up
4065
- document.body.removeChild(measureEle);
4066
- removeCSS(randomId);
4067
- return {
4068
- width: scrollWidth,
4069
- height: scrollHeight
4070
- };
4071
- }
4072
- function getTargetScrollBarSize(target) {
4073
- if (typeof document === 'undefined' || !target || !(target instanceof Element)) {
4074
- return {
4075
- width: 0,
4076
- height: 0
4077
- };
4078
- }
4079
- return measureScrollbarSize(target);
4080
- }
4081
-
4082
- /**
4083
- * Test usage export. Do not use in your production
4084
- */
4085
- function isBodyOverflowing() {
4086
- return document.body.scrollHeight > (window.innerHeight || document.documentElement.clientHeight) && window.innerWidth > document.body.offsetWidth;
4087
- }
4088
-
4089
- var UNIQUE_ID = "rc-util-locker-".concat(Date.now());
4090
- var uuid$3 = 0;
4091
- function useScrollLocker(lock) {
4092
- var mergedLock = !!lock;
4093
- var _React$useState = React$4.useState(function () {
4094
- uuid$3 += 1;
4095
- return "".concat(UNIQUE_ID, "_").concat(uuid$3);
4096
- }),
4097
- _React$useState2 = _slicedToArray(_React$useState, 1),
4098
- id = _React$useState2[0];
4099
- useLayoutEffect$3(function () {
4100
- if (mergedLock) {
4101
- var scrollbarSize = getTargetScrollBarSize(document.body).width;
4102
- var isOverflow = isBodyOverflowing();
4103
- updateCSS("\nhtml body {\n overflow-y: hidden;\n ".concat(isOverflow ? "width: calc(100% - ".concat(scrollbarSize, "px);") : '', "\n}"), id);
4104
- } else {
4105
- removeCSS(id);
4106
- }
4107
- return function () {
4108
- removeCSS(id);
4109
- };
4110
- }, [mergedLock, id]);
4111
- }
4112
-
4113
- var inline = false;
4114
- function inlineMock(nextInline) {
4115
- if (typeof nextInline === 'boolean') {
4116
- inline = nextInline;
4117
- }
4118
- return inline;
4119
- }
4120
-
4121
- var getPortalContainer = function getPortalContainer(getContainer) {
4122
- if (getContainer === false) {
4123
- return false;
4124
- }
4125
- if (!canUseDom$1() || !getContainer) {
4126
- return null;
4127
- }
4128
- if (typeof getContainer === 'string') {
4129
- return document.querySelector(getContainer);
4130
- }
4131
- if (typeof getContainer === 'function') {
4132
- return getContainer();
4133
- }
4134
- return getContainer;
4135
- };
4136
- var Portal = /*#__PURE__*/React$4.forwardRef(function (props, ref) {
4137
- var open = props.open,
4138
- autoLock = props.autoLock,
4139
- getContainer = props.getContainer,
4140
- debug = props.debug,
4141
- _props$autoDestroy = props.autoDestroy,
4142
- autoDestroy = _props$autoDestroy === void 0 ? true : _props$autoDestroy,
4143
- children = props.children;
4144
- var _React$useState = React$4.useState(open),
4145
- _React$useState2 = _slicedToArray(_React$useState, 2),
4146
- shouldRender = _React$useState2[0],
4147
- setShouldRender = _React$useState2[1];
4148
- var mergedRender = shouldRender || open;
4149
-
4150
- // ========================= Warning =========================
4151
- if (process.env.NODE_ENV !== 'production') {
4152
- warningOnce(canUseDom$1() || !open, "Portal only work in client side. Please call 'useEffect' to show Portal instead default render in SSR.");
4153
- }
4154
-
4155
- // ====================== Should Render ======================
4156
- React$4.useEffect(function () {
4157
- if (autoDestroy || open) {
4158
- setShouldRender(open);
4159
- }
4160
- }, [open, autoDestroy]);
4161
-
4162
- // ======================== Container ========================
4163
- var _React$useState3 = React$4.useState(function () {
4164
- return getPortalContainer(getContainer);
4165
- }),
4166
- _React$useState4 = _slicedToArray(_React$useState3, 2),
4167
- innerContainer = _React$useState4[0],
4168
- setInnerContainer = _React$useState4[1];
4169
- React$4.useEffect(function () {
4170
- var customizeContainer = getPortalContainer(getContainer);
4171
-
4172
- // Tell component that we check this in effect which is safe to be `null`
4173
- setInnerContainer(customizeContainer !== null && customizeContainer !== void 0 ? customizeContainer : null);
4174
- });
4175
- var _useDom = useDom(mergedRender && !innerContainer, debug),
4176
- _useDom2 = _slicedToArray(_useDom, 2),
4177
- defaultContainer = _useDom2[0],
4178
- queueCreate = _useDom2[1];
4179
- var mergedContainer = innerContainer !== null && innerContainer !== void 0 ? innerContainer : defaultContainer;
4180
-
4181
- // ========================= Locker ==========================
4182
- useScrollLocker(autoLock && open && canUseDom$1() && (mergedContainer === defaultContainer || mergedContainer === document.body));
4183
-
4184
- // =========================== Ref ===========================
4185
- var childRef = null;
4186
- if (children && supportRef(children) && ref) {
4187
- var _ref = children;
4188
- childRef = _ref.ref;
4189
- }
4190
- var mergedRef = useComposeRef(childRef, ref);
4191
-
4192
- // ========================= Render ==========================
4193
- // Do not render when nothing need render
4194
- // When innerContainer is `undefined`, it may not ready since user use ref in the same render
4195
- if (!mergedRender || !canUseDom$1() || innerContainer === undefined) {
4196
- return null;
4197
- }
4198
-
4199
- // Render inline
4200
- var renderInline = mergedContainer === false || inlineMock();
4201
- var reffedChildren = children;
4202
- if (ref) {
4203
- reffedChildren = /*#__PURE__*/React$4.cloneElement(children, {
4204
- ref: mergedRef
4205
- });
4206
- }
4207
- return /*#__PURE__*/React$4.createElement(OrderContext.Provider, {
4208
- value: queueCreate
4209
- }, renderInline ? reffedChildren : /*#__PURE__*/createPortal(reffedChildren, mergedContainer));
4210
- });
4211
- if (process.env.NODE_ENV !== 'production') {
4212
- Portal.displayName = 'Portal';
4213
- }
4214
-
4215
2522
  function getRoot(ele) {
4216
2523
  var _ele$getRootNode;
4217
2524
  return ele === null || ele === void 0 || (_ele$getRootNode = ele.getRootNode) === null || _ele$getRootNode === void 0 ? void 0 : _ele$getRootNode.call(ele);
@@ -4332,7 +2639,7 @@ function Arrow(props) {
4332
2639
  }
4333
2640
  return /*#__PURE__*/React$4.createElement("div", {
4334
2641
  ref: arrowRef,
4335
- className: classNames("".concat(prefixCls, "-arrow"), className),
2642
+ className: clsx("".concat(prefixCls, "-arrow"), className),
4336
2643
  style: alignStyle
4337
2644
  }, content);
4338
2645
  }
@@ -4356,7 +2663,7 @@ function Mask(props) {
4356
2663
  style: {
4357
2664
  zIndex: zIndex
4358
2665
  },
4359
- className: classNames("".concat(prefixCls, "-mask"), className)
2666
+ className: clsx("".concat(prefixCls, "-mask"), className)
4360
2667
  });
4361
2668
  });
4362
2669
  }
@@ -4514,7 +2821,7 @@ var Popup = /*#__PURE__*/React$4.forwardRef(function (props, ref) {
4514
2821
  }), function (_ref, motionRef) {
4515
2822
  var motionClassName = _ref.className,
4516
2823
  motionStyle = _ref.style;
4517
- var cls = classNames(prefixCls, motionClassName, className);
2824
+ var cls = clsx(prefixCls, motionClassName, className);
4518
2825
  return /*#__PURE__*/React$4.createElement("div", {
4519
2826
  ref: composeRef(resizeObserverRef, ref, motionRef),
4520
2827
  className: cls,
@@ -5641,7 +3948,7 @@ function generateTrigger() {
5641
3948
  }, [JSON.stringify(popupAlign)]);
5642
3949
  var alignedClassName = React$4.useMemo(function () {
5643
3950
  var baseClassName = getAlignPopupClassName(builtinPlacements, prefixCls, alignInfo, alignPoint);
5644
- return classNames(baseClassName, getPopupClassNameFromAlign === null || getPopupClassNameFromAlign === void 0 ? void 0 : getPopupClassNameFromAlign(alignInfo));
3951
+ return clsx(baseClassName, getPopupClassNameFromAlign === null || getPopupClassNameFromAlign === void 0 ? void 0 : getPopupClassNameFromAlign(alignInfo));
5645
3952
  }, [alignInfo, getPopupClassNameFromAlign, builtinPlacements, prefixCls, alignPoint]);
5646
3953
 
5647
3954
  // ============================ Refs ============================
@@ -5804,7 +4111,7 @@ function generateTrigger() {
5804
4111
 
5805
4112
  // ========================= ClassName ==========================
5806
4113
  if (className) {
5807
- cloneProps.className = classNames(originChildProps.className, className);
4114
+ cloneProps.className = clsx(originChildProps.className, className);
5808
4115
  }
5809
4116
 
5810
4117
  // =========================== Render ===========================
@@ -5848,7 +4155,7 @@ function generateTrigger() {
5848
4155
  ref: setPopupRef,
5849
4156
  prefixCls: prefixCls,
5850
4157
  popup: popup,
5851
- className: classNames(popupClassName, alignedClassName),
4158
+ className: clsx(popupClassName, alignedClassName),
5852
4159
  style: popupStyle,
5853
4160
  target: targetEle,
5854
4161
  onMouseEnter: onPopupMouseEnter,
@@ -6023,7 +4330,7 @@ var SelectTrigger = function SelectTrigger(props, ref) {
6023
4330
  popupAlign: dropdownAlign,
6024
4331
  popupVisible: visible,
6025
4332
  getPopupContainer: getPopupContainer,
6026
- popupClassName: classNames(dropdownClassName, _defineProperty({}, "".concat(dropdownPrefixCls, "-empty"), empty)),
4333
+ popupClassName: clsx(dropdownClassName, _defineProperty({}, "".concat(dropdownPrefixCls, "-empty"), empty)),
6027
4334
  popupStyle: popupStyle,
6028
4335
  getTriggerDOMNode: getTriggerDOMNode,
6029
4336
  onPopupVisibleChange: onPopupVisibleChange
@@ -6581,7 +4888,7 @@ var BaseSelect = /*#__PURE__*/React$4.forwardRef(function (props, ref) {
6581
4888
  var arrowNode;
6582
4889
  if (showSuffixIcon) {
6583
4890
  arrowNode = /*#__PURE__*/React$4.createElement(TransBtn, {
6584
- className: classNames("".concat(prefixCls, "-arrow"), _defineProperty({}, "".concat(prefixCls, "-arrow-loading"), loading)),
4891
+ className: clsx("".concat(prefixCls, "-arrow"), _defineProperty({}, "".concat(prefixCls, "-arrow-loading"), loading)),
6585
4892
  customizeIcon: suffixIcon,
6586
4893
  customizeIconProps: {
6587
4894
  loading: loading,
@@ -6614,7 +4921,7 @@ var BaseSelect = /*#__PURE__*/React$4.forwardRef(function (props, ref) {
6614
4921
  });
6615
4922
 
6616
4923
  // ============================= Select =============================
6617
- var mergedClassName = classNames(prefixCls, className, (_classNames2 = {}, _defineProperty(_classNames2, "".concat(prefixCls, "-focused"), mockFocused), _defineProperty(_classNames2, "".concat(prefixCls, "-multiple"), multiple), _defineProperty(_classNames2, "".concat(prefixCls, "-single"), !multiple), _defineProperty(_classNames2, "".concat(prefixCls, "-allow-clear"), allowClear), _defineProperty(_classNames2, "".concat(prefixCls, "-show-arrow"), showSuffixIcon), _defineProperty(_classNames2, "".concat(prefixCls, "-disabled"), disabled), _defineProperty(_classNames2, "".concat(prefixCls, "-loading"), loading), _defineProperty(_classNames2, "".concat(prefixCls, "-open"), mergedOpen), _defineProperty(_classNames2, "".concat(prefixCls, "-customize-input"), customizeInputElement), _defineProperty(_classNames2, "".concat(prefixCls, "-show-search"), mergedShowSearch), _classNames2));
4924
+ var mergedClassName = clsx(prefixCls, className, (_classNames2 = {}, _defineProperty(_classNames2, "".concat(prefixCls, "-focused"), mockFocused), _defineProperty(_classNames2, "".concat(prefixCls, "-multiple"), multiple), _defineProperty(_classNames2, "".concat(prefixCls, "-single"), !multiple), _defineProperty(_classNames2, "".concat(prefixCls, "-allow-clear"), allowClear), _defineProperty(_classNames2, "".concat(prefixCls, "-show-arrow"), showSuffixIcon), _defineProperty(_classNames2, "".concat(prefixCls, "-disabled"), disabled), _defineProperty(_classNames2, "".concat(prefixCls, "-loading"), loading), _defineProperty(_classNames2, "".concat(prefixCls, "-open"), mergedOpen), _defineProperty(_classNames2, "".concat(prefixCls, "-customize-input"), customizeInputElement), _defineProperty(_classNames2, "".concat(prefixCls, "-show-search"), mergedShowSearch), _classNames2));
6618
4925
 
6619
4926
  // >>> Selector
6620
4927
  var selectorNode = /*#__PURE__*/React$4.createElement(RefSelectTrigger, {
@@ -6998,271 +5305,288 @@ var Filler = /*#__PURE__*/React$4.forwardRef(function (_ref, ref) {
6998
5305
  }
6999
5306
  }, /*#__PURE__*/React$4.createElement("div", _extends({
7000
5307
  style: innerStyle,
7001
- className: classNames(_defineProperty({}, "".concat(prefixCls, "-holder-inner"), prefixCls)),
5308
+ className: clsx(_defineProperty({}, "".concat(prefixCls, "-holder-inner"), prefixCls)),
7002
5309
  ref: ref
7003
5310
  }, innerProps), children, extra)));
7004
5311
  });
7005
5312
  Filler.displayName = 'Filler';
7006
5313
 
7007
- function getPageXY(e, horizontal) {
7008
- var obj = 'touches' in e ? e.touches[0] : e;
7009
- return obj[horizontal ? 'pageX' : 'pageY'];
5314
+ function Item(_ref) {
5315
+ var children = _ref.children,
5316
+ setRef = _ref.setRef;
5317
+ var refFunc = React$4.useCallback(function (node) {
5318
+ setRef(node);
5319
+ }, []);
5320
+ return /*#__PURE__*/React$4.cloneElement(children, {
5321
+ ref: refFunc
5322
+ });
7010
5323
  }
7011
- var ScrollBar = /*#__PURE__*/React$4.forwardRef(function (props, ref) {
7012
- var prefixCls = props.prefixCls,
7013
- rtl = props.rtl,
7014
- scrollOffset = props.scrollOffset,
7015
- scrollRange = props.scrollRange,
7016
- onStartMove = props.onStartMove,
7017
- onStopMove = props.onStopMove,
7018
- onScroll = props.onScroll,
7019
- horizontal = props.horizontal,
7020
- spinSize = props.spinSize,
7021
- containerSize = props.containerSize,
7022
- style = props.style,
7023
- propsThumbStyle = props.thumbStyle;
7024
- var _React$useState = React$4.useState(false),
5324
+
5325
+ function useChildren(list, startIndex, endIndex, scrollWidth, setNodeRef, renderFunc, _ref) {
5326
+ var getKey = _ref.getKey;
5327
+ return list.slice(startIndex, endIndex + 1).map(function (item, index) {
5328
+ var eleIndex = startIndex + index;
5329
+ var node = renderFunc(item, eleIndex, {
5330
+ style: {
5331
+ width: scrollWidth
5332
+ }
5333
+ });
5334
+ var key = getKey(item);
5335
+ return /*#__PURE__*/React$4.createElement(Item, {
5336
+ key: key,
5337
+ setRef: function setRef(ele) {
5338
+ return setNodeRef(item, ele);
5339
+ }
5340
+ }, node);
5341
+ });
5342
+ }
5343
+
5344
+ /**
5345
+ * Get index with specific start index one by one. e.g.
5346
+ * min: 3, max: 9, start: 6
5347
+ *
5348
+ * Return index is:
5349
+ * [0]: 6
5350
+ * [1]: 7
5351
+ * [2]: 5
5352
+ * [3]: 8
5353
+ * [4]: 4
5354
+ * [5]: 9
5355
+ * [6]: 3
5356
+ */
5357
+
5358
+ /**
5359
+ * We assume that 2 list has only 1 item diff and others keeping the order.
5360
+ * So we can use dichotomy algorithm to find changed one.
5361
+ */
5362
+ function findListDiffIndex(originList, targetList, getKey) {
5363
+ var originLen = originList.length;
5364
+ var targetLen = targetList.length;
5365
+ var shortList;
5366
+ var longList;
5367
+ if (originLen === 0 && targetLen === 0) {
5368
+ return null;
5369
+ }
5370
+ if (originLen < targetLen) {
5371
+ shortList = originList;
5372
+ longList = targetList;
5373
+ } else {
5374
+ shortList = targetList;
5375
+ longList = originList;
5376
+ }
5377
+ var notExistKey = {
5378
+ __EMPTY_ITEM__: true
5379
+ };
5380
+ function getItemKey(item) {
5381
+ if (item !== undefined) {
5382
+ return getKey(item);
5383
+ }
5384
+ return notExistKey;
5385
+ }
5386
+
5387
+ // Loop to find diff one
5388
+ var diffIndex = null;
5389
+ var multiple = Math.abs(originLen - targetLen) !== 1;
5390
+ for (var i = 0; i < longList.length; i += 1) {
5391
+ var shortKey = getItemKey(shortList[i]);
5392
+ var longKey = getItemKey(longList[i]);
5393
+ if (shortKey !== longKey) {
5394
+ diffIndex = i;
5395
+ multiple = multiple || shortKey !== getItemKey(longList[i + 1]);
5396
+ break;
5397
+ }
5398
+ }
5399
+ return diffIndex === null ? null : {
5400
+ index: diffIndex,
5401
+ multiple: multiple
5402
+ };
5403
+ }
5404
+
5405
+ function useDiffItem(data, getKey, onDiff) {
5406
+ var _React$useState = React$4.useState(data),
7025
5407
  _React$useState2 = _slicedToArray(_React$useState, 2),
7026
- dragging = _React$useState2[0],
7027
- setDragging = _React$useState2[1];
5408
+ prevData = _React$useState2[0],
5409
+ setPrevData = _React$useState2[1];
7028
5410
  var _React$useState3 = React$4.useState(null),
7029
5411
  _React$useState4 = _slicedToArray(_React$useState3, 2),
7030
- pageXY = _React$useState4[0],
7031
- setPageXY = _React$useState4[1];
7032
- var _React$useState5 = React$4.useState(null),
7033
- _React$useState6 = _slicedToArray(_React$useState5, 2),
7034
- startTop = _React$useState6[0],
7035
- setStartTop = _React$useState6[1];
7036
- var isLTR = !rtl;
7037
-
7038
- // ========================= Refs =========================
7039
- var scrollbarRef = React$4.useRef();
7040
- var thumbRef = React$4.useRef();
5412
+ diffItem = _React$useState4[0],
5413
+ setDiffItem = _React$useState4[1];
5414
+ React$4.useEffect(function () {
5415
+ var diff = findListDiffIndex(prevData || [], data || [], getKey);
5416
+ if ((diff === null || diff === void 0 ? void 0 : diff.index) !== undefined) {
5417
+ onDiff === null || onDiff === void 0 || onDiff(diff.index);
5418
+ setDiffItem(data[diff.index]);
5419
+ }
5420
+ setPrevData(data);
5421
+ }, [data]);
5422
+ return [diffItem];
5423
+ }
7041
5424
 
7042
- // ======================= Visible ========================
7043
- var _React$useState7 = React$4.useState(false),
7044
- _React$useState8 = _slicedToArray(_React$useState7, 2),
7045
- visible = _React$useState8[0],
7046
- setVisible = _React$useState8[1];
7047
- var visibleTimeoutRef = React$4.useRef();
7048
- var delayHidden = function delayHidden() {
7049
- clearTimeout(visibleTimeoutRef.current);
7050
- setVisible(true);
7051
- visibleTimeoutRef.current = setTimeout(function () {
7052
- setVisible(false);
7053
- }, 3000);
7054
- };
5425
+ var isFF = (typeof navigator === "undefined" ? "undefined" : _typeof$1(navigator)) === 'object' && /Firefox/i.test(navigator.userAgent);
7055
5426
 
7056
- // ======================== Range =========================
7057
- var enableScrollRange = scrollRange - containerSize || 0;
7058
- var enableOffsetRange = containerSize - spinSize || 0;
5427
+ var useOriginScroll = (function (isScrollAtTop, isScrollAtBottom) {
5428
+ // Do lock for a wheel when scrolling
5429
+ var lockRef = useRef(false);
5430
+ var lockTimeoutRef = useRef(null);
5431
+ function lockScroll() {
5432
+ clearTimeout(lockTimeoutRef.current);
5433
+ lockRef.current = true;
5434
+ lockTimeoutRef.current = setTimeout(function () {
5435
+ lockRef.current = false;
5436
+ }, 50);
5437
+ }
7059
5438
 
7060
- // ========================= Top ==========================
7061
- var top = React$4.useMemo(function () {
7062
- if (scrollOffset === 0 || enableScrollRange === 0) {
7063
- return 0;
5439
+ // Pass to ref since global add is in closure
5440
+ var scrollPingRef = useRef({
5441
+ top: isScrollAtTop,
5442
+ bottom: isScrollAtBottom
5443
+ });
5444
+ scrollPingRef.current.top = isScrollAtTop;
5445
+ scrollPingRef.current.bottom = isScrollAtBottom;
5446
+ return function (deltaY) {
5447
+ var smoothOffset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
5448
+ var originScroll =
5449
+ // Pass origin wheel when on the top
5450
+ deltaY < 0 && scrollPingRef.current.top ||
5451
+ // Pass origin wheel when on the bottom
5452
+ deltaY > 0 && scrollPingRef.current.bottom;
5453
+ if (smoothOffset && originScroll) {
5454
+ // No need lock anymore when it's smooth offset from touchMove interval
5455
+ clearTimeout(lockTimeoutRef.current);
5456
+ lockRef.current = false;
5457
+ } else if (!originScroll || lockRef.current) {
5458
+ lockScroll();
7064
5459
  }
7065
- var ptg = scrollOffset / enableScrollRange;
7066
- return ptg * enableOffsetRange;
7067
- }, [scrollOffset, enableScrollRange, enableOffsetRange]);
7068
-
7069
- // ====================== Container =======================
7070
- var onContainerMouseDown = function onContainerMouseDown(e) {
7071
- e.stopPropagation();
7072
- e.preventDefault();
5460
+ return !lockRef.current && originScroll;
7073
5461
  };
5462
+ });
7074
5463
 
7075
- // ======================== Thumb =========================
7076
- var stateRef = React$4.useRef({
7077
- top: top,
7078
- dragging: dragging,
7079
- pageY: pageXY,
7080
- startTop: startTop
7081
- });
7082
- stateRef.current = {
7083
- top: top,
7084
- dragging: dragging,
7085
- pageY: pageXY,
7086
- startTop: startTop
7087
- };
7088
- var onThumbMouseDown = function onThumbMouseDown(e) {
7089
- setDragging(true);
7090
- setPageXY(getPageXY(e, horizontal));
7091
- setStartTop(stateRef.current.top);
7092
- onStartMove();
7093
- e.stopPropagation();
7094
- e.preventDefault();
7095
- };
5464
+ function useFrameWheel(inVirtual, isScrollAtTop, isScrollAtBottom, horizontalScroll,
5465
+ /***
5466
+ * Return `true` when you need to prevent default event
5467
+ */
5468
+ onWheelDelta) {
5469
+ var offsetRef = useRef(0);
5470
+ var nextFrameRef = useRef(null);
7096
5471
 
7097
- // ======================== Effect ========================
5472
+ // Firefox patch
5473
+ var wheelValueRef = useRef(null);
5474
+ var isMouseScrollRef = useRef(false);
7098
5475
 
7099
- // React make event as passive, but we need to preventDefault
7100
- // Add event on dom directly instead.
7101
- // ref: https://github.com/facebook/react/issues/9809
7102
- React$4.useEffect(function () {
7103
- var onScrollbarTouchStart = function onScrollbarTouchStart(e) {
7104
- e.preventDefault();
7105
- };
7106
- var scrollbarEle = scrollbarRef.current;
7107
- var thumbEle = thumbRef.current;
7108
- scrollbarEle.addEventListener('touchstart', onScrollbarTouchStart);
7109
- thumbEle.addEventListener('touchstart', onThumbMouseDown);
7110
- return function () {
7111
- scrollbarEle.removeEventListener('touchstart', onScrollbarTouchStart);
7112
- thumbEle.removeEventListener('touchstart', onThumbMouseDown);
7113
- };
7114
- }, []);
5476
+ // Scroll status sync
5477
+ var originScroll = useOriginScroll(isScrollAtTop, isScrollAtBottom);
5478
+ function onWheelY(event, deltaY) {
5479
+ wrapperRaf.cancel(nextFrameRef.current);
5480
+ offsetRef.current += deltaY;
5481
+ wheelValueRef.current = deltaY;
7115
5482
 
7116
- // Pass to effect
7117
- var enableScrollRangeRef = React$4.useRef();
7118
- enableScrollRangeRef.current = enableScrollRange;
7119
- var enableOffsetRangeRef = React$4.useRef();
7120
- enableOffsetRangeRef.current = enableOffsetRange;
7121
- React$4.useEffect(function () {
7122
- if (dragging) {
7123
- var moveRafId;
7124
- var onMouseMove = function onMouseMove(e) {
7125
- var _stateRef$current = stateRef.current,
7126
- stateDragging = _stateRef$current.dragging,
7127
- statePageY = _stateRef$current.pageY,
7128
- stateStartTop = _stateRef$current.startTop;
7129
- wrapperRaf.cancel(moveRafId);
7130
- if (stateDragging) {
7131
- var offset = getPageXY(e, horizontal) - statePageY;
7132
- var newTop = stateStartTop;
7133
- if (!isLTR && horizontal) {
7134
- newTop -= offset;
7135
- } else {
7136
- newTop += offset;
7137
- }
7138
- var tmpEnableScrollRange = enableScrollRangeRef.current;
7139
- var tmpEnableOffsetRange = enableOffsetRangeRef.current;
7140
- var ptg = tmpEnableOffsetRange ? newTop / tmpEnableOffsetRange : 0;
7141
- var newScrollTop = Math.ceil(ptg * tmpEnableScrollRange);
7142
- newScrollTop = Math.max(newScrollTop, 0);
7143
- newScrollTop = Math.min(newScrollTop, tmpEnableScrollRange);
7144
- moveRafId = wrapperRaf(function () {
7145
- onScroll(newScrollTop, horizontal);
7146
- });
7147
- }
7148
- };
7149
- var onMouseUp = function onMouseUp() {
7150
- setDragging(false);
7151
- onStopMove();
7152
- };
7153
- window.addEventListener('mousemove', onMouseMove);
7154
- window.addEventListener('touchmove', onMouseMove);
7155
- window.addEventListener('mouseup', onMouseUp);
7156
- window.addEventListener('touchend', onMouseUp);
7157
- return function () {
7158
- window.removeEventListener('mousemove', onMouseMove);
7159
- window.removeEventListener('touchmove', onMouseMove);
7160
- window.removeEventListener('mouseup', onMouseUp);
7161
- window.removeEventListener('touchend', onMouseUp);
7162
- wrapperRaf.cancel(moveRafId);
7163
- };
7164
- }
7165
- }, [dragging]);
7166
- React$4.useEffect(function () {
7167
- delayHidden();
7168
- }, [scrollOffset]);
5483
+ // Do nothing when scroll at the edge, Skip check when is in scroll
5484
+ if (originScroll(deltaY)) return;
7169
5485
 
7170
- // ====================== Imperative ======================
7171
- React$4.useImperativeHandle(ref, function () {
7172
- return {
7173
- delayHidden: delayHidden
7174
- };
7175
- });
5486
+ // Proxy of scroll events
5487
+ if (!isFF) {
5488
+ event.preventDefault();
5489
+ }
5490
+ nextFrameRef.current = wrapperRaf(function () {
5491
+ // Patch a multiple for Firefox to fix wheel number too small
5492
+ // ref: https://github.com/ant-design/ant-design/issues/26372#issuecomment-679460266
5493
+ var patchMultiple = isMouseScrollRef.current ? 10 : 1;
5494
+ onWheelDelta(offsetRef.current * patchMultiple);
5495
+ offsetRef.current = 0;
5496
+ });
5497
+ }
5498
+ function onWheelX(event, deltaX) {
5499
+ onWheelDelta(deltaX, true);
5500
+ if (!isFF) {
5501
+ event.preventDefault();
5502
+ }
5503
+ }
7176
5504
 
7177
- // ======================== Render ========================
7178
- var scrollbarPrefixCls = "".concat(prefixCls, "-scrollbar");
7179
- var containerStyle = {
7180
- position: 'absolute',
7181
- visibility: visible ? null : 'hidden'
7182
- };
7183
- var thumbStyle = {
7184
- position: 'absolute',
7185
- background: 'rgba(0, 0, 0, 0.5)',
7186
- borderRadius: 99,
7187
- cursor: 'pointer',
7188
- userSelect: 'none'
7189
- };
7190
- if (horizontal) {
7191
- // Container
7192
- containerStyle.height = 8;
7193
- containerStyle.left = 0;
7194
- containerStyle.right = 0;
7195
- containerStyle.bottom = 0;
5505
+ // Check for which direction does wheel do. `sx` means `shift + wheel`
5506
+ var wheelDirectionRef = useRef(null);
5507
+ var wheelDirectionCleanRef = useRef(null);
5508
+ function onWheel(event) {
5509
+ if (!inVirtual) return;
7196
5510
 
7197
- // Thumb
7198
- thumbStyle.height = '100%';
7199
- thumbStyle.width = spinSize;
7200
- if (isLTR) {
7201
- thumbStyle.left = top;
7202
- } else {
7203
- thumbStyle.right = top;
5511
+ // Wait for 2 frame to clean direction
5512
+ wrapperRaf.cancel(wheelDirectionCleanRef.current);
5513
+ wheelDirectionCleanRef.current = wrapperRaf(function () {
5514
+ wheelDirectionRef.current = null;
5515
+ }, 2);
5516
+ var deltaX = event.deltaX,
5517
+ deltaY = event.deltaY,
5518
+ shiftKey = event.shiftKey;
5519
+ var mergedDeltaX = deltaX;
5520
+ var mergedDeltaY = deltaY;
5521
+ if (wheelDirectionRef.current === 'sx' || !wheelDirectionRef.current && (shiftKey || false) && deltaY && !deltaX) {
5522
+ mergedDeltaX = deltaY;
5523
+ mergedDeltaY = 0;
5524
+ wheelDirectionRef.current = 'sx';
7204
5525
  }
7205
- } else {
7206
- // Container
7207
- containerStyle.width = 8;
7208
- containerStyle.top = 0;
7209
- containerStyle.bottom = 0;
7210
- if (isLTR) {
7211
- containerStyle.right = 0;
5526
+ var absX = Math.abs(mergedDeltaX);
5527
+ var absY = Math.abs(mergedDeltaY);
5528
+ if (wheelDirectionRef.current === null) {
5529
+ wheelDirectionRef.current = horizontalScroll && absX > absY ? 'x' : 'y';
5530
+ }
5531
+ if (wheelDirectionRef.current === 'y') {
5532
+ onWheelY(event, mergedDeltaY);
7212
5533
  } else {
7213
- containerStyle.left = 0;
5534
+ onWheelX(event, mergedDeltaX);
7214
5535
  }
5536
+ }
7215
5537
 
7216
- // Thumb
7217
- thumbStyle.width = '100%';
7218
- thumbStyle.height = spinSize;
7219
- thumbStyle.top = top;
5538
+ // A patch for firefox
5539
+ function onFireFoxScroll(event) {
5540
+ if (!inVirtual) return;
5541
+ isMouseScrollRef.current = event.detail === wheelValueRef.current;
7220
5542
  }
7221
- return /*#__PURE__*/React$4.createElement("div", {
7222
- ref: scrollbarRef,
7223
- className: classNames(scrollbarPrefixCls, _defineProperty(_defineProperty(_defineProperty({}, "".concat(scrollbarPrefixCls, "-horizontal"), horizontal), "".concat(scrollbarPrefixCls, "-vertical"), !horizontal), "".concat(scrollbarPrefixCls, "-visible"), visible)),
7224
- style: _objectSpread2(_objectSpread2({}, containerStyle), style),
7225
- onMouseDown: onContainerMouseDown,
7226
- onMouseMove: delayHidden
7227
- }, /*#__PURE__*/React$4.createElement("div", {
7228
- ref: thumbRef,
7229
- className: classNames("".concat(scrollbarPrefixCls, "-thumb"), _defineProperty({}, "".concat(scrollbarPrefixCls, "-thumb-moving"), dragging)),
7230
- style: _objectSpread2(_objectSpread2({}, thumbStyle), propsThumbStyle),
7231
- onMouseDown: onThumbMouseDown
7232
- }));
7233
- });
7234
- if (process.env.NODE_ENV !== 'production') {
7235
- ScrollBar.displayName = 'ScrollBar';
5543
+ return [onWheel, onFireFoxScroll];
7236
5544
  }
7237
5545
 
7238
- function Item(_ref) {
7239
- var children = _ref.children,
7240
- setRef = _ref.setRef;
7241
- var refFunc = React$4.useCallback(function (node) {
7242
- setRef(node);
7243
- }, []);
7244
- return /*#__PURE__*/React$4.cloneElement(children, {
7245
- ref: refFunc
7246
- });
7247
- }
5546
+ /**
5547
+ * Size info need loop query for the `heights` which will has the perf issue.
5548
+ * Let cache result for each render phase.
5549
+ */
5550
+ function useGetSize(mergedData, getKey, heights, itemHeight) {
5551
+ var _React$useMemo = React$4.useMemo(function () {
5552
+ return [new Map(), []];
5553
+ }, [mergedData, heights.id, itemHeight]),
5554
+ _React$useMemo2 = _slicedToArray(_React$useMemo, 2),
5555
+ key2Index = _React$useMemo2[0],
5556
+ bottomList = _React$useMemo2[1];
5557
+ var getSize = function getSize(startKey) {
5558
+ var endKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : startKey;
5559
+ // Get from cache first
5560
+ var startIndex = key2Index.get(startKey);
5561
+ var endIndex = key2Index.get(endKey);
7248
5562
 
7249
- function useChildren(list, startIndex, endIndex, scrollWidth, setNodeRef, renderFunc, _ref) {
7250
- var getKey = _ref.getKey;
7251
- return list.slice(startIndex, endIndex + 1).map(function (item, index) {
7252
- var eleIndex = startIndex + index;
7253
- var node = renderFunc(item, eleIndex, {
7254
- style: {
7255
- width: scrollWidth
7256
- }
7257
- });
7258
- var key = getKey(item);
7259
- return /*#__PURE__*/React$4.createElement(Item, {
7260
- key: key,
7261
- setRef: function setRef(ele) {
7262
- return setNodeRef(item, ele);
5563
+ // Loop to fill the cache
5564
+ if (startIndex === undefined || endIndex === undefined) {
5565
+ var dataLen = mergedData.length;
5566
+ for (var i = bottomList.length; i < dataLen; i += 1) {
5567
+ var _heights$get;
5568
+ var item = mergedData[i];
5569
+ var key = getKey(item);
5570
+ key2Index.set(key, i);
5571
+ var cacheHeight = (_heights$get = heights.get(key)) !== null && _heights$get !== void 0 ? _heights$get : itemHeight;
5572
+ bottomList[i] = (bottomList[i - 1] || 0) + cacheHeight;
5573
+ if (key === startKey) {
5574
+ startIndex = i;
5575
+ }
5576
+ if (key === endKey) {
5577
+ endIndex = i;
5578
+ }
5579
+ if (startIndex !== undefined && endIndex !== undefined) {
5580
+ break;
5581
+ }
7263
5582
  }
7264
- }, node);
7265
- });
5583
+ }
5584
+ return {
5585
+ top: bottomList[startIndex - 1] || 0,
5586
+ bottom: bottomList[endIndex]
5587
+ };
5588
+ };
5589
+ return getSize;
7266
5590
  }
7267
5591
 
7268
5592
  // Firefox has low performance of map.
@@ -7351,6 +5675,69 @@ function useHeights(getKey, onItemAdd, onItemRemove) {
7351
5675
  return [setInstanceRef, collectHeight, heightsRef.current, updatedMark];
7352
5676
  }
7353
5677
 
5678
+ var SMOOTH_PTG = 14 / 15;
5679
+ function useMobileTouchMove(inVirtual, listRef, callback) {
5680
+ var touchedRef = useRef(false);
5681
+ var touchYRef = useRef(0);
5682
+ var elementRef = useRef(null);
5683
+
5684
+ // Smooth scroll
5685
+ var intervalRef = useRef(null);
5686
+
5687
+ /* eslint-disable prefer-const */
5688
+ var cleanUpEvents;
5689
+ var onTouchMove = function onTouchMove(e) {
5690
+ if (touchedRef.current) {
5691
+ var currentY = Math.ceil(e.touches[0].pageY);
5692
+ var _offsetY = touchYRef.current - currentY;
5693
+ touchYRef.current = currentY;
5694
+ if (callback(_offsetY)) {
5695
+ e.preventDefault();
5696
+ }
5697
+
5698
+ // Smooth interval
5699
+ clearInterval(intervalRef.current);
5700
+ intervalRef.current = setInterval(function () {
5701
+ _offsetY *= SMOOTH_PTG;
5702
+ if (!callback(_offsetY, true) || Math.abs(_offsetY) <= 0.1) {
5703
+ clearInterval(intervalRef.current);
5704
+ }
5705
+ }, 16);
5706
+ }
5707
+ };
5708
+ var onTouchEnd = function onTouchEnd() {
5709
+ touchedRef.current = false;
5710
+ cleanUpEvents();
5711
+ };
5712
+ var onTouchStart = function onTouchStart(e) {
5713
+ cleanUpEvents();
5714
+ if (e.touches.length === 1 && !touchedRef.current) {
5715
+ touchedRef.current = true;
5716
+ touchYRef.current = Math.ceil(e.touches[0].pageY);
5717
+ elementRef.current = e.target;
5718
+ elementRef.current.addEventListener('touchmove', onTouchMove);
5719
+ elementRef.current.addEventListener('touchend', onTouchEnd);
5720
+ }
5721
+ };
5722
+ cleanUpEvents = function cleanUpEvents() {
5723
+ if (elementRef.current) {
5724
+ elementRef.current.removeEventListener('touchmove', onTouchMove);
5725
+ elementRef.current.removeEventListener('touchend', onTouchEnd);
5726
+ }
5727
+ };
5728
+ useLayoutEffect$3(function () {
5729
+ if (inVirtual) {
5730
+ listRef.current.addEventListener('touchstart', onTouchStart);
5731
+ }
5732
+ return function () {
5733
+ var _listRef$current;
5734
+ (_listRef$current = listRef.current) === null || _listRef$current === void 0 || _listRef$current.removeEventListener('touchstart', onTouchStart);
5735
+ cleanUpEvents();
5736
+ clearInterval(intervalRef.current);
5737
+ };
5738
+ }, [inVirtual]);
5739
+ }
5740
+
7354
5741
  var MAX_TIMES = 10;
7355
5742
  function useScrollTo(containerRef, data, heights, itemHeight, getKey, collectHeight, syncScrollTop, triggerFlash) {
7356
5743
  var scrollRef = React$4.useRef();
@@ -7452,304 +5839,270 @@ function useScrollTo(containerRef, data, heights, itemHeight, getKey, collectHei
7452
5839
  warningOnce(false, 'Seems `scrollTo` with `rc-virtual-list` reach the max limitation. Please fire issue for us. Thanks.');
7453
5840
  }
7454
5841
  }, [syncState, containerRef.current]);
7455
-
7456
- // =========================== Scroll To ===========================
7457
- return function (arg) {
7458
- // When not argument provided, we think dev may want to show the scrollbar
7459
- if (arg === null || arg === undefined) {
7460
- triggerFlash();
7461
- return;
7462
- }
7463
-
7464
- // Normal scroll logic
7465
- wrapperRaf.cancel(scrollRef.current);
7466
- if (typeof arg === 'number') {
7467
- syncScrollTop(arg);
7468
- } else if (arg && _typeof$1(arg) === 'object') {
7469
- var index;
7470
- var align = arg.align;
7471
- if ('index' in arg) {
7472
- index = arg.index;
7473
- } else {
7474
- index = data.findIndex(function (item) {
7475
- return getKey(item) === arg.key;
7476
- });
7477
- }
7478
- var _arg$offset = arg.offset,
7479
- offset = _arg$offset === void 0 ? 0 : _arg$offset;
7480
- setSyncState({
7481
- times: 0,
7482
- index: index,
7483
- offset: offset,
7484
- originAlign: align
7485
- });
7486
- }
7487
- };
7488
- }
7489
-
7490
- /**
7491
- * Get index with specific start index one by one. e.g.
7492
- * min: 3, max: 9, start: 6
7493
- *
7494
- * Return index is:
7495
- * [0]: 6
7496
- * [1]: 7
7497
- * [2]: 5
7498
- * [3]: 8
7499
- * [4]: 4
7500
- * [5]: 9
7501
- * [6]: 3
7502
- */
7503
-
7504
- /**
7505
- * We assume that 2 list has only 1 item diff and others keeping the order.
7506
- * So we can use dichotomy algorithm to find changed one.
7507
- */
7508
- function findListDiffIndex(originList, targetList, getKey) {
7509
- var originLen = originList.length;
7510
- var targetLen = targetList.length;
7511
- var shortList;
7512
- var longList;
7513
- if (originLen === 0 && targetLen === 0) {
7514
- return null;
7515
- }
7516
- if (originLen < targetLen) {
7517
- shortList = originList;
7518
- longList = targetList;
7519
- } else {
7520
- shortList = targetList;
7521
- longList = originList;
7522
- }
7523
- var notExistKey = {
7524
- __EMPTY_ITEM__: true
7525
- };
7526
- function getItemKey(item) {
7527
- if (item !== undefined) {
7528
- return getKey(item);
5842
+
5843
+ // =========================== Scroll To ===========================
5844
+ return function (arg) {
5845
+ // When not argument provided, we think dev may want to show the scrollbar
5846
+ if (arg === null || arg === undefined) {
5847
+ triggerFlash();
5848
+ return;
7529
5849
  }
7530
- return notExistKey;
7531
- }
7532
5850
 
7533
- // Loop to find diff one
7534
- var diffIndex = null;
7535
- var multiple = Math.abs(originLen - targetLen) !== 1;
7536
- for (var i = 0; i < longList.length; i += 1) {
7537
- var shortKey = getItemKey(shortList[i]);
7538
- var longKey = getItemKey(longList[i]);
7539
- if (shortKey !== longKey) {
7540
- diffIndex = i;
7541
- multiple = multiple || shortKey !== getItemKey(longList[i + 1]);
7542
- break;
5851
+ // Normal scroll logic
5852
+ wrapperRaf.cancel(scrollRef.current);
5853
+ if (typeof arg === 'number') {
5854
+ syncScrollTop(arg);
5855
+ } else if (arg && _typeof$1(arg) === 'object') {
5856
+ var index;
5857
+ var align = arg.align;
5858
+ if ('index' in arg) {
5859
+ index = arg.index;
5860
+ } else {
5861
+ index = data.findIndex(function (item) {
5862
+ return getKey(item) === arg.key;
5863
+ });
5864
+ }
5865
+ var _arg$offset = arg.offset,
5866
+ offset = _arg$offset === void 0 ? 0 : _arg$offset;
5867
+ setSyncState({
5868
+ times: 0,
5869
+ index: index,
5870
+ offset: offset,
5871
+ originAlign: align
5872
+ });
7543
5873
  }
7544
- }
7545
- return diffIndex === null ? null : {
7546
- index: diffIndex,
7547
- multiple: multiple
7548
5874
  };
7549
5875
  }
7550
5876
 
7551
- function useDiffItem(data, getKey, onDiff) {
7552
- var _React$useState = React$4.useState(data),
5877
+ function getPageXY(e, horizontal) {
5878
+ var obj = 'touches' in e ? e.touches[0] : e;
5879
+ return obj[horizontal ? 'pageX' : 'pageY'];
5880
+ }
5881
+ var ScrollBar = /*#__PURE__*/React$4.forwardRef(function (props, ref) {
5882
+ var prefixCls = props.prefixCls,
5883
+ rtl = props.rtl,
5884
+ scrollOffset = props.scrollOffset,
5885
+ scrollRange = props.scrollRange,
5886
+ onStartMove = props.onStartMove,
5887
+ onStopMove = props.onStopMove,
5888
+ onScroll = props.onScroll,
5889
+ horizontal = props.horizontal,
5890
+ spinSize = props.spinSize,
5891
+ containerSize = props.containerSize,
5892
+ style = props.style,
5893
+ propsThumbStyle = props.thumbStyle;
5894
+ var _React$useState = React$4.useState(false),
7553
5895
  _React$useState2 = _slicedToArray(_React$useState, 2),
7554
- prevData = _React$useState2[0],
7555
- setPrevData = _React$useState2[1];
5896
+ dragging = _React$useState2[0],
5897
+ setDragging = _React$useState2[1];
7556
5898
  var _React$useState3 = React$4.useState(null),
7557
5899
  _React$useState4 = _slicedToArray(_React$useState3, 2),
7558
- diffItem = _React$useState4[0],
7559
- setDiffItem = _React$useState4[1];
7560
- React$4.useEffect(function () {
7561
- var diff = findListDiffIndex(prevData || [], data || [], getKey);
7562
- if ((diff === null || diff === void 0 ? void 0 : diff.index) !== undefined) {
7563
- onDiff === null || onDiff === void 0 || onDiff(diff.index);
7564
- setDiffItem(data[diff.index]);
7565
- }
7566
- setPrevData(data);
7567
- }, [data]);
7568
- return [diffItem];
7569
- }
7570
-
7571
- var isFF = (typeof navigator === "undefined" ? "undefined" : _typeof$1(navigator)) === 'object' && /Firefox/i.test(navigator.userAgent);
5900
+ pageXY = _React$useState4[0],
5901
+ setPageXY = _React$useState4[1];
5902
+ var _React$useState5 = React$4.useState(null),
5903
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
5904
+ startTop = _React$useState6[0],
5905
+ setStartTop = _React$useState6[1];
5906
+ var isLTR = !rtl;
7572
5907
 
7573
- var useOriginScroll = (function (isScrollAtTop, isScrollAtBottom) {
7574
- // Do lock for a wheel when scrolling
7575
- var lockRef = useRef(false);
7576
- var lockTimeoutRef = useRef(null);
7577
- function lockScroll() {
7578
- clearTimeout(lockTimeoutRef.current);
7579
- lockRef.current = true;
7580
- lockTimeoutRef.current = setTimeout(function () {
7581
- lockRef.current = false;
7582
- }, 50);
7583
- }
5908
+ // ========================= Refs =========================
5909
+ var scrollbarRef = React$4.useRef();
5910
+ var thumbRef = React$4.useRef();
7584
5911
 
7585
- // Pass to ref since global add is in closure
7586
- var scrollPingRef = useRef({
7587
- top: isScrollAtTop,
7588
- bottom: isScrollAtBottom
7589
- });
7590
- scrollPingRef.current.top = isScrollAtTop;
7591
- scrollPingRef.current.bottom = isScrollAtBottom;
7592
- return function (deltaY) {
7593
- var smoothOffset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
7594
- var originScroll =
7595
- // Pass origin wheel when on the top
7596
- deltaY < 0 && scrollPingRef.current.top ||
7597
- // Pass origin wheel when on the bottom
7598
- deltaY > 0 && scrollPingRef.current.bottom;
7599
- if (smoothOffset && originScroll) {
7600
- // No need lock anymore when it's smooth offset from touchMove interval
7601
- clearTimeout(lockTimeoutRef.current);
7602
- lockRef.current = false;
7603
- } else if (!originScroll || lockRef.current) {
7604
- lockScroll();
7605
- }
7606
- return !lockRef.current && originScroll;
5912
+ // ======================= Visible ========================
5913
+ var _React$useState7 = React$4.useState(false),
5914
+ _React$useState8 = _slicedToArray(_React$useState7, 2),
5915
+ visible = _React$useState8[0],
5916
+ setVisible = _React$useState8[1];
5917
+ var visibleTimeoutRef = React$4.useRef();
5918
+ var delayHidden = function delayHidden() {
5919
+ clearTimeout(visibleTimeoutRef.current);
5920
+ setVisible(true);
5921
+ visibleTimeoutRef.current = setTimeout(function () {
5922
+ setVisible(false);
5923
+ }, 3000);
7607
5924
  };
7608
- });
7609
-
7610
- function useFrameWheel(inVirtual, isScrollAtTop, isScrollAtBottom, horizontalScroll,
7611
- /***
7612
- * Return `true` when you need to prevent default event
7613
- */
7614
- onWheelDelta) {
7615
- var offsetRef = useRef(0);
7616
- var nextFrameRef = useRef(null);
7617
-
7618
- // Firefox patch
7619
- var wheelValueRef = useRef(null);
7620
- var isMouseScrollRef = useRef(false);
7621
-
7622
- // Scroll status sync
7623
- var originScroll = useOriginScroll(isScrollAtTop, isScrollAtBottom);
7624
- function onWheelY(event, deltaY) {
7625
- wrapperRaf.cancel(nextFrameRef.current);
7626
- offsetRef.current += deltaY;
7627
- wheelValueRef.current = deltaY;
7628
-
7629
- // Do nothing when scroll at the edge, Skip check when is in scroll
7630
- if (originScroll(deltaY)) return;
7631
-
7632
- // Proxy of scroll events
7633
- if (!isFF) {
7634
- event.preventDefault();
7635
- }
7636
- nextFrameRef.current = wrapperRaf(function () {
7637
- // Patch a multiple for Firefox to fix wheel number too small
7638
- // ref: https://github.com/ant-design/ant-design/issues/26372#issuecomment-679460266
7639
- var patchMultiple = isMouseScrollRef.current ? 10 : 1;
7640
- onWheelDelta(offsetRef.current * patchMultiple);
7641
- offsetRef.current = 0;
7642
- });
7643
- }
7644
- function onWheelX(event, deltaX) {
7645
- onWheelDelta(deltaX, true);
7646
- if (!isFF) {
7647
- event.preventDefault();
7648
- }
7649
- }
7650
5925
 
7651
- // Check for which direction does wheel do. `sx` means `shift + wheel`
7652
- var wheelDirectionRef = useRef(null);
7653
- var wheelDirectionCleanRef = useRef(null);
7654
- function onWheel(event) {
7655
- if (!inVirtual) return;
5926
+ // ======================== Range =========================
5927
+ var enableScrollRange = scrollRange - containerSize || 0;
5928
+ var enableOffsetRange = containerSize - spinSize || 0;
7656
5929
 
7657
- // Wait for 2 frame to clean direction
7658
- wrapperRaf.cancel(wheelDirectionCleanRef.current);
7659
- wheelDirectionCleanRef.current = wrapperRaf(function () {
7660
- wheelDirectionRef.current = null;
7661
- }, 2);
7662
- var deltaX = event.deltaX,
7663
- deltaY = event.deltaY,
7664
- shiftKey = event.shiftKey;
7665
- var mergedDeltaX = deltaX;
7666
- var mergedDeltaY = deltaY;
7667
- if (wheelDirectionRef.current === 'sx' || !wheelDirectionRef.current && (shiftKey || false) && deltaY && !deltaX) {
7668
- mergedDeltaX = deltaY;
7669
- mergedDeltaY = 0;
7670
- wheelDirectionRef.current = 'sx';
7671
- }
7672
- var absX = Math.abs(mergedDeltaX);
7673
- var absY = Math.abs(mergedDeltaY);
7674
- if (wheelDirectionRef.current === null) {
7675
- wheelDirectionRef.current = horizontalScroll && absX > absY ? 'x' : 'y';
7676
- }
7677
- if (wheelDirectionRef.current === 'y') {
7678
- onWheelY(event, mergedDeltaY);
7679
- } else {
7680
- onWheelX(event, mergedDeltaX);
5930
+ // ========================= Top ==========================
5931
+ var top = React$4.useMemo(function () {
5932
+ if (scrollOffset === 0 || enableScrollRange === 0) {
5933
+ return 0;
7681
5934
  }
7682
- }
5935
+ var ptg = scrollOffset / enableScrollRange;
5936
+ return ptg * enableOffsetRange;
5937
+ }, [scrollOffset, enableScrollRange, enableOffsetRange]);
7683
5938
 
7684
- // A patch for firefox
7685
- function onFireFoxScroll(event) {
7686
- if (!inVirtual) return;
7687
- isMouseScrollRef.current = event.detail === wheelValueRef.current;
7688
- }
7689
- return [onWheel, onFireFoxScroll];
7690
- }
5939
+ // ====================== Container =======================
5940
+ var onContainerMouseDown = function onContainerMouseDown(e) {
5941
+ e.stopPropagation();
5942
+ e.preventDefault();
5943
+ };
7691
5944
 
7692
- var SMOOTH_PTG = 14 / 15;
7693
- function useMobileTouchMove(inVirtual, listRef, callback) {
7694
- var touchedRef = useRef(false);
7695
- var touchYRef = useRef(0);
7696
- var elementRef = useRef(null);
5945
+ // ======================== Thumb =========================
5946
+ var stateRef = React$4.useRef({
5947
+ top: top,
5948
+ dragging: dragging,
5949
+ pageY: pageXY,
5950
+ startTop: startTop
5951
+ });
5952
+ stateRef.current = {
5953
+ top: top,
5954
+ dragging: dragging,
5955
+ pageY: pageXY,
5956
+ startTop: startTop
5957
+ };
5958
+ var onThumbMouseDown = function onThumbMouseDown(e) {
5959
+ setDragging(true);
5960
+ setPageXY(getPageXY(e, horizontal));
5961
+ setStartTop(stateRef.current.top);
5962
+ onStartMove();
5963
+ e.stopPropagation();
5964
+ e.preventDefault();
5965
+ };
7697
5966
 
7698
- // Smooth scroll
7699
- var intervalRef = useRef(null);
5967
+ // ======================== Effect ========================
7700
5968
 
7701
- /* eslint-disable prefer-const */
7702
- var cleanUpEvents;
7703
- var onTouchMove = function onTouchMove(e) {
7704
- if (touchedRef.current) {
7705
- var currentY = Math.ceil(e.touches[0].pageY);
7706
- var _offsetY = touchYRef.current - currentY;
7707
- touchYRef.current = currentY;
7708
- if (callback(_offsetY)) {
7709
- e.preventDefault();
7710
- }
5969
+ // React make event as passive, but we need to preventDefault
5970
+ // Add event on dom directly instead.
5971
+ // ref: https://github.com/facebook/react/issues/9809
5972
+ React$4.useEffect(function () {
5973
+ var onScrollbarTouchStart = function onScrollbarTouchStart(e) {
5974
+ e.preventDefault();
5975
+ };
5976
+ var scrollbarEle = scrollbarRef.current;
5977
+ var thumbEle = thumbRef.current;
5978
+ scrollbarEle.addEventListener('touchstart', onScrollbarTouchStart);
5979
+ thumbEle.addEventListener('touchstart', onThumbMouseDown);
5980
+ return function () {
5981
+ scrollbarEle.removeEventListener('touchstart', onScrollbarTouchStart);
5982
+ thumbEle.removeEventListener('touchstart', onThumbMouseDown);
5983
+ };
5984
+ }, []);
7711
5985
 
7712
- // Smooth interval
7713
- clearInterval(intervalRef.current);
7714
- intervalRef.current = setInterval(function () {
7715
- _offsetY *= SMOOTH_PTG;
7716
- if (!callback(_offsetY, true) || Math.abs(_offsetY) <= 0.1) {
7717
- clearInterval(intervalRef.current);
5986
+ // Pass to effect
5987
+ var enableScrollRangeRef = React$4.useRef();
5988
+ enableScrollRangeRef.current = enableScrollRange;
5989
+ var enableOffsetRangeRef = React$4.useRef();
5990
+ enableOffsetRangeRef.current = enableOffsetRange;
5991
+ React$4.useEffect(function () {
5992
+ if (dragging) {
5993
+ var moveRafId;
5994
+ var onMouseMove = function onMouseMove(e) {
5995
+ var _stateRef$current = stateRef.current,
5996
+ stateDragging = _stateRef$current.dragging,
5997
+ statePageY = _stateRef$current.pageY,
5998
+ stateStartTop = _stateRef$current.startTop;
5999
+ wrapperRaf.cancel(moveRafId);
6000
+ if (stateDragging) {
6001
+ var offset = getPageXY(e, horizontal) - statePageY;
6002
+ var newTop = stateStartTop;
6003
+ if (!isLTR && horizontal) {
6004
+ newTop -= offset;
6005
+ } else {
6006
+ newTop += offset;
6007
+ }
6008
+ var tmpEnableScrollRange = enableScrollRangeRef.current;
6009
+ var tmpEnableOffsetRange = enableOffsetRangeRef.current;
6010
+ var ptg = tmpEnableOffsetRange ? newTop / tmpEnableOffsetRange : 0;
6011
+ var newScrollTop = Math.ceil(ptg * tmpEnableScrollRange);
6012
+ newScrollTop = Math.max(newScrollTop, 0);
6013
+ newScrollTop = Math.min(newScrollTop, tmpEnableScrollRange);
6014
+ moveRafId = wrapperRaf(function () {
6015
+ onScroll(newScrollTop, horizontal);
6016
+ });
7718
6017
  }
7719
- }, 16);
6018
+ };
6019
+ var onMouseUp = function onMouseUp() {
6020
+ setDragging(false);
6021
+ onStopMove();
6022
+ };
6023
+ window.addEventListener('mousemove', onMouseMove);
6024
+ window.addEventListener('touchmove', onMouseMove);
6025
+ window.addEventListener('mouseup', onMouseUp);
6026
+ window.addEventListener('touchend', onMouseUp);
6027
+ return function () {
6028
+ window.removeEventListener('mousemove', onMouseMove);
6029
+ window.removeEventListener('touchmove', onMouseMove);
6030
+ window.removeEventListener('mouseup', onMouseUp);
6031
+ window.removeEventListener('touchend', onMouseUp);
6032
+ wrapperRaf.cancel(moveRafId);
6033
+ };
7720
6034
  }
6035
+ }, [dragging]);
6036
+ React$4.useEffect(function () {
6037
+ delayHidden();
6038
+ }, [scrollOffset]);
6039
+
6040
+ // ====================== Imperative ======================
6041
+ React$4.useImperativeHandle(ref, function () {
6042
+ return {
6043
+ delayHidden: delayHidden
6044
+ };
6045
+ });
6046
+
6047
+ // ======================== Render ========================
6048
+ var scrollbarPrefixCls = "".concat(prefixCls, "-scrollbar");
6049
+ var containerStyle = {
6050
+ position: 'absolute',
6051
+ visibility: visible ? null : 'hidden'
7721
6052
  };
7722
- var onTouchEnd = function onTouchEnd() {
7723
- touchedRef.current = false;
7724
- cleanUpEvents();
7725
- };
7726
- var onTouchStart = function onTouchStart(e) {
7727
- cleanUpEvents();
7728
- if (e.touches.length === 1 && !touchedRef.current) {
7729
- touchedRef.current = true;
7730
- touchYRef.current = Math.ceil(e.touches[0].pageY);
7731
- elementRef.current = e.target;
7732
- elementRef.current.addEventListener('touchmove', onTouchMove);
7733
- elementRef.current.addEventListener('touchend', onTouchEnd);
7734
- }
6053
+ var thumbStyle = {
6054
+ position: 'absolute',
6055
+ background: 'rgba(0, 0, 0, 0.5)',
6056
+ borderRadius: 99,
6057
+ cursor: 'pointer',
6058
+ userSelect: 'none'
7735
6059
  };
7736
- cleanUpEvents = function cleanUpEvents() {
7737
- if (elementRef.current) {
7738
- elementRef.current.removeEventListener('touchmove', onTouchMove);
7739
- elementRef.current.removeEventListener('touchend', onTouchEnd);
6060
+ if (horizontal) {
6061
+ // Container
6062
+ containerStyle.height = 8;
6063
+ containerStyle.left = 0;
6064
+ containerStyle.right = 0;
6065
+ containerStyle.bottom = 0;
6066
+
6067
+ // Thumb
6068
+ thumbStyle.height = '100%';
6069
+ thumbStyle.width = spinSize;
6070
+ if (isLTR) {
6071
+ thumbStyle.left = top;
6072
+ } else {
6073
+ thumbStyle.right = top;
7740
6074
  }
7741
- };
7742
- useLayoutEffect$3(function () {
7743
- if (inVirtual) {
7744
- listRef.current.addEventListener('touchstart', onTouchStart);
6075
+ } else {
6076
+ // Container
6077
+ containerStyle.width = 8;
6078
+ containerStyle.top = 0;
6079
+ containerStyle.bottom = 0;
6080
+ if (isLTR) {
6081
+ containerStyle.right = 0;
6082
+ } else {
6083
+ containerStyle.left = 0;
7745
6084
  }
7746
- return function () {
7747
- var _listRef$current;
7748
- (_listRef$current = listRef.current) === null || _listRef$current === void 0 || _listRef$current.removeEventListener('touchstart', onTouchStart);
7749
- cleanUpEvents();
7750
- clearInterval(intervalRef.current);
7751
- };
7752
- }, [inVirtual]);
6085
+
6086
+ // Thumb
6087
+ thumbStyle.width = '100%';
6088
+ thumbStyle.height = spinSize;
6089
+ thumbStyle.top = top;
6090
+ }
6091
+ return /*#__PURE__*/React$4.createElement("div", {
6092
+ ref: scrollbarRef,
6093
+ className: clsx(scrollbarPrefixCls, _defineProperty(_defineProperty(_defineProperty({}, "".concat(scrollbarPrefixCls, "-horizontal"), horizontal), "".concat(scrollbarPrefixCls, "-vertical"), !horizontal), "".concat(scrollbarPrefixCls, "-visible"), visible)),
6094
+ style: _objectSpread2(_objectSpread2({}, containerStyle), style),
6095
+ onMouseDown: onContainerMouseDown,
6096
+ onMouseMove: delayHidden
6097
+ }, /*#__PURE__*/React$4.createElement("div", {
6098
+ ref: thumbRef,
6099
+ className: clsx("".concat(scrollbarPrefixCls, "-thumb"), _defineProperty({}, "".concat(scrollbarPrefixCls, "-thumb-moving"), dragging)),
6100
+ style: _objectSpread2(_objectSpread2({}, thumbStyle), propsThumbStyle),
6101
+ onMouseDown: onThumbMouseDown
6102
+ }));
6103
+ });
6104
+ if (process.env.NODE_ENV !== 'production') {
6105
+ ScrollBar.displayName = 'ScrollBar';
7753
6106
  }
7754
6107
 
7755
6108
  var MIN_SIZE = 20;
@@ -7764,52 +6117,6 @@ function getSpinSize() {
7764
6117
  return Math.floor(baseSize);
7765
6118
  }
7766
6119
 
7767
- /**
7768
- * Size info need loop query for the `heights` which will has the perf issue.
7769
- * Let cache result for each render phase.
7770
- */
7771
- function useGetSize(mergedData, getKey, heights, itemHeight) {
7772
- var _React$useMemo = React$4.useMemo(function () {
7773
- return [new Map(), []];
7774
- }, [mergedData, heights.id, itemHeight]),
7775
- _React$useMemo2 = _slicedToArray(_React$useMemo, 2),
7776
- key2Index = _React$useMemo2[0],
7777
- bottomList = _React$useMemo2[1];
7778
- var getSize = function getSize(startKey) {
7779
- var endKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : startKey;
7780
- // Get from cache first
7781
- var startIndex = key2Index.get(startKey);
7782
- var endIndex = key2Index.get(endKey);
7783
-
7784
- // Loop to fill the cache
7785
- if (startIndex === undefined || endIndex === undefined) {
7786
- var dataLen = mergedData.length;
7787
- for (var i = bottomList.length; i < dataLen; i += 1) {
7788
- var _heights$get;
7789
- var item = mergedData[i];
7790
- var key = getKey(item);
7791
- key2Index.set(key, i);
7792
- var cacheHeight = (_heights$get = heights.get(key)) !== null && _heights$get !== void 0 ? _heights$get : itemHeight;
7793
- bottomList[i] = (bottomList[i - 1] || 0) + cacheHeight;
7794
- if (key === startKey) {
7795
- startIndex = i;
7796
- }
7797
- if (key === endKey) {
7798
- endIndex = i;
7799
- }
7800
- if (startIndex !== undefined && endIndex !== undefined) {
7801
- break;
7802
- }
7803
- }
7804
- }
7805
- return {
7806
- top: bottomList[startIndex - 1] || 0,
7807
- bottom: bottomList[endIndex]
7808
- };
7809
- };
7810
- return getSize;
7811
- }
7812
-
7813
6120
  var _excluded$2 = ["prefixCls", "className", "height", "itemHeight", "fullHeight", "style", "data", "children", "itemKey", "virtual", "direction", "scrollWidth", "component", "onScroll", "onVirtualScroll", "onVisibleChange", "innerProps", "extraRender", "styles"];
7814
6121
  var EMPTY_DATA = [];
7815
6122
  var ScrollStyle = {
@@ -7841,11 +6148,32 @@ function RawList(props, ref) {
7841
6148
  styles = props.styles,
7842
6149
  restProps = _objectWithoutProperties(props, _excluded$2);
7843
6150
 
6151
+ // =============================== Item Key ===============================
6152
+ var getKey = React$4.useCallback(function (item) {
6153
+ if (typeof itemKey === 'function') {
6154
+ return itemKey(item);
6155
+ }
6156
+ return item === null || item === void 0 ? void 0 : item[itemKey];
6157
+ }, [itemKey]);
6158
+
6159
+ // ================================ Height ================================
6160
+ var _useHeights = useHeights(getKey, null, null),
6161
+ _useHeights2 = _slicedToArray(_useHeights, 4),
6162
+ setInstanceRef = _useHeights2[0],
6163
+ collectHeight = _useHeights2[1],
6164
+ heights = _useHeights2[2],
6165
+ heightUpdatedMark = _useHeights2[3];
6166
+
7844
6167
  // ================================= MISC =================================
7845
6168
  var useVirtual = !!(virtual !== false && height && itemHeight);
7846
- var inVirtual = useVirtual && data && (itemHeight * data.length > height || !!scrollWidth);
6169
+ var containerHeight = React$4.useMemo(function () {
6170
+ return Object.values(heights.maps).reduce(function (total, curr) {
6171
+ return total + curr;
6172
+ }, 0);
6173
+ }, [heights.id, heights.maps]);
6174
+ var inVirtual = useVirtual && data && (Math.max(itemHeight * data.length, containerHeight) > height || !!scrollWidth);
7847
6175
  var isRTL = direction === 'rtl';
7848
- var mergedClassName = classNames(prefixCls, _defineProperty({}, "".concat(prefixCls, "-rtl"), isRTL), className);
6176
+ var mergedClassName = clsx(prefixCls, _defineProperty({}, "".concat(prefixCls, "-rtl"), isRTL), className);
7849
6177
  var mergedData = data || EMPTY_DATA;
7850
6178
  var componentRef = useRef();
7851
6179
  var fillerInnerRef = useRef();
@@ -7870,14 +6198,6 @@ function RawList(props, ref) {
7870
6198
  var onScrollbarStopMove = function onScrollbarStopMove() {
7871
6199
  setScrollMoving(false);
7872
6200
  };
7873
-
7874
- // =============================== Item Key ===============================
7875
- var getKey = React$4.useCallback(function (item) {
7876
- if (typeof itemKey === 'function') {
7877
- return itemKey(item);
7878
- }
7879
- return item === null || item === void 0 ? void 0 : item[itemKey];
7880
- }, [itemKey]);
7881
6201
  var sharedConfig = {
7882
6202
  getKey: getKey
7883
6203
  };
@@ -7909,14 +6229,6 @@ function RawList(props, ref) {
7909
6229
  diffItem = _useDiffItem2[0];
7910
6230
  diffItemRef.current = diffItem;
7911
6231
 
7912
- // ================================ Height ================================
7913
- var _useHeights = useHeights(getKey, null, null),
7914
- _useHeights2 = _slicedToArray(_useHeights, 4),
7915
- setInstanceRef = _useHeights2[0],
7916
- collectHeight = _useHeights2[1],
7917
- heights = _useHeights2[2],
7918
- heightUpdatedMark = _useHeights2[3];
7919
-
7920
6232
  // ========================== Visible Calculation =========================
7921
6233
  var _React$useMemo = React$4.useMemo(function () {
7922
6234
  if (!useVirtual) {
@@ -8037,9 +6349,9 @@ function RawList(props, ref) {
8037
6349
  };
8038
6350
  };
8039
6351
  var lastVirtualScrollInfoRef = useRef(getVirtualScrollInfo());
8040
- var triggerScroll = useEvent$2(function () {
6352
+ var triggerScroll = useEvent$2(function (params) {
8041
6353
  if (onVirtualScroll) {
8042
- var nextInfo = getVirtualScrollInfo();
6354
+ var nextInfo = _objectSpread2(_objectSpread2({}, getVirtualScrollInfo()), params);
8043
6355
 
8044
6356
  // Trigger when offset changed
8045
6357
  if (lastVirtualScrollInfoRef.current.x !== nextInfo.x || lastVirtualScrollInfoRef.current.y !== nextInfo.y) {
@@ -8073,7 +6385,7 @@ function RawList(props, ref) {
8073
6385
  }
8074
6386
  var keepInHorizontalRange = function keepInHorizontalRange(nextOffsetLeft) {
8075
6387
  var tmpOffsetLeft = nextOffsetLeft;
8076
- var max = scrollWidth - size.width;
6388
+ var max = !!scrollWidth ? scrollWidth - size.width : 0;
8077
6389
  tmpOffsetLeft = Math.max(tmpOffsetLeft, 0);
8078
6390
  tmpOffsetLeft = Math.min(tmpOffsetLeft, max);
8079
6391
  return tmpOffsetLeft;
@@ -8135,8 +6447,10 @@ function RawList(props, ref) {
8135
6447
  // Sync scroll left
8136
6448
  useLayoutEffect$3(function () {
8137
6449
  if (scrollWidth) {
8138
- setOffsetLeft(function (left) {
8139
- return keepInHorizontalRange(left);
6450
+ var newOffsetLeft = keepInHorizontalRange(offsetLeft);
6451
+ setOffsetLeft(newOffsetLeft);
6452
+ triggerScroll({
6453
+ x: newOffsetLeft
8140
6454
  });
8141
6455
  }
8142
6456
  }, [size.width, scrollWidth]);
@@ -8313,7 +6627,7 @@ var OptionList = function OptionList(_, ref) {
8313
6627
  listHeight = _React$useContext.listHeight,
8314
6628
  listItemHeight = _React$useContext.listItemHeight;
8315
6629
  var itemPrefixCls = "".concat(prefixCls, "-item");
8316
- var memoFlattenOptions = useMemo(function () {
6630
+ var memoFlattenOptions = useMemo$1(function () {
8317
6631
  return flattenOptions;
8318
6632
  }, [open, flattenOptions], function (prev, next) {
8319
6633
  return next[0] && prev[1] !== next[1];
@@ -8564,7 +6878,7 @@ var OptionList = function OptionList(_, ref) {
8564
6878
  var _data$title;
8565
6879
  var groupTitle = (_data$title = data.title) !== null && _data$title !== void 0 ? _data$title : isTitleType(label) ? label.toString() : undefined;
8566
6880
  return /*#__PURE__*/React$4.createElement("div", {
8567
- className: classNames(itemPrefixCls, "".concat(itemPrefixCls, "-group")),
6881
+ className: clsx(itemPrefixCls, "".concat(itemPrefixCls, "-group")),
8568
6882
  title: groupTitle
8569
6883
  }, label !== undefined ? label : key);
8570
6884
  }
@@ -8579,7 +6893,7 @@ var OptionList = function OptionList(_, ref) {
8579
6893
  // Option
8580
6894
  var selected = isSelected(value);
8581
6895
  var optionPrefixCls = "".concat(itemPrefixCls, "-option");
8582
- var optionClassName = classNames(itemPrefixCls, optionPrefixCls, className, (_classNames = {}, _defineProperty(_classNames, "".concat(optionPrefixCls, "-grouped"), groupOption), _defineProperty(_classNames, "".concat(optionPrefixCls, "-active"), activeIndex === itemIndex && !disabled), _defineProperty(_classNames, "".concat(optionPrefixCls, "-disabled"), disabled), _defineProperty(_classNames, "".concat(optionPrefixCls, "-selected"), selected), _classNames));
6896
+ var optionClassName = clsx(itemPrefixCls, optionPrefixCls, className, (_classNames = {}, _defineProperty(_classNames, "".concat(optionPrefixCls, "-grouped"), groupOption), _defineProperty(_classNames, "".concat(optionPrefixCls, "-active"), activeIndex === itemIndex && !disabled), _defineProperty(_classNames, "".concat(optionPrefixCls, "-disabled"), disabled), _defineProperty(_classNames, "".concat(optionPrefixCls, "-selected"), selected), _classNames));
8583
6897
  var mergedLabel = getLabel(item);
8584
6898
  var iconVisible = !menuItemSelectedIcon || typeof menuItemSelectedIcon === 'function' || selected;
8585
6899
 
@@ -10074,7 +8388,7 @@ function Column(_ref) {
10074
8388
  };
10075
8389
  // >>>>> Render
10076
8390
  return jsxs("li", Object.assign({
10077
- className: classNames(menuItemPrefixCls, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(menuItemPrefixCls, "-expand"), !isMergedLeaf), "".concat(menuItemPrefixCls, "-active"), activeValue === value || activeValue === fullPathKey), "".concat(menuItemPrefixCls, "-disabled"), disabled), "".concat(menuItemPrefixCls, "-loading"), isLoading)),
8391
+ className: clsx(menuItemPrefixCls, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(menuItemPrefixCls, "-expand"), !isMergedLeaf), "".concat(menuItemPrefixCls, "-active"), activeValue === value || activeValue === fullPathKey), "".concat(menuItemPrefixCls, "-disabled"), disabled), "".concat(menuItemPrefixCls, "-loading"), isLoading)),
10078
8392
  style: dropdownMenuColumnStyle,
10079
8393
  role: "menuitemcheckbox",
10080
8394
  "aria-checked": checked,
@@ -10340,7 +8654,7 @@ var RefOptionList = /*#__PURE__*/React$4.forwardRef(function (props, ref) {
10340
8654
  open: open
10341
8655
  }, {
10342
8656
  children: jsx("div", Object.assign({
10343
- className: classNames("".concat(mergedPrefixCls, "-menus"), _defineProperty(_defineProperty({}, "".concat(mergedPrefixCls, "-menu-empty"), isEmpty), "".concat(mergedPrefixCls, "-rtl"), rtl)),
8657
+ className: clsx("".concat(mergedPrefixCls, "-menus"), _defineProperty(_defineProperty({}, "".concat(mergedPrefixCls, "-menu-empty"), isEmpty), "".concat(mergedPrefixCls, "-rtl"), rtl)),
10344
8658
  ref: containerRef
10345
8659
  }, {
10346
8660
  children: columnNodes
@@ -10629,11 +8943,11 @@ const Cascader = /*#__PURE__*/React$4.forwardRef((props, ref) => {
10629
8943
  }
10630
8944
  };
10631
8945
  const childrenMemo = React$4.useMemo(() => {
10632
- const contentClass = clsx("".concat($prefixCls, "-cascader-select-content"), {
8946
+ const contentClass = clsx$1("".concat($prefixCls, "-cascader-select-content"), {
10633
8947
  ["".concat($prefixCls, "-cascader-select-value")]: inputLabel,
10634
8948
  ["".concat($prefixCls, "-cascader-select-disabled")]: disabled
10635
8949
  });
10636
- const svgClass = clsx("select-svg", {
8950
+ const svgClass = clsx$1("select-svg", {
10637
8951
  ["select-svg-open"]: dropdownVisible
10638
8952
  });
10639
8953
  return children ? children : jsxs("div", Object.assign({