@hi-ui/table 4.3.1 → 4.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -0
- package/lib/cjs/BaseTable.js +136 -189
- package/lib/cjs/ColGroupContent.js +5 -28
- package/lib/cjs/SettingDrawer.js +76 -127
- package/lib/cjs/Table.js +107 -171
- package/lib/cjs/TableAdvancedFilter.js +49 -85
- package/lib/cjs/TableBody.js +33 -69
- package/lib/cjs/TableCell.js +56 -102
- package/lib/cjs/TableColumnMenu.js +39 -77
- package/lib/cjs/TableEmbedRow.js +11 -38
- package/lib/cjs/TableHeader.js +8 -33
- package/lib/cjs/TableRow.js +48 -88
- package/lib/cjs/TableSettingMenu.js +48 -94
- package/lib/cjs/TbodyContent.js +28 -56
- package/lib/cjs/TheadContent.js +20 -49
- package/lib/cjs/_virtual/index.js +0 -3
- package/lib/cjs/_virtual/index2.js +0 -3
- package/lib/cjs/_virtual/react-is.development.js +0 -3
- package/lib/cjs/_virtual/react-is.production.min.js +0 -3
- package/lib/cjs/context.js +0 -9
- package/lib/cjs/hooks/use-async-switch.js +13 -51
- package/lib/cjs/hooks/use-check.js +47 -77
- package/lib/cjs/hooks/use-col-hidden.js +16 -28
- package/lib/cjs/hooks/use-col-set.js +5 -18
- package/lib/cjs/hooks/use-col-sorter.js +18 -32
- package/lib/cjs/hooks/use-col-width.js +21 -57
- package/lib/cjs/hooks/use-colgroup.js +63 -85
- package/lib/cjs/hooks/use-drag.js +10 -31
- package/lib/cjs/hooks/use-embed-expand.js +23 -68
- package/lib/cjs/hooks/use-expand.js +32 -64
- package/lib/cjs/hooks/use-pagination.js +19 -50
- package/lib/cjs/hooks/use-queue.js +2 -14
- package/lib/cjs/icons/index.js +4 -21
- package/lib/cjs/index.js +0 -4
- package/lib/cjs/node_modules/classnames/index.js +2 -11
- package/lib/cjs/node_modules/perfect-scrollbar/dist/perfect-scrollbar.esm.js +31 -227
- package/lib/cjs/node_modules/rc-resize-observer/es/index.js +10 -68
- package/lib/cjs/node_modules/rc-resize-observer/node_modules/rc-util/es/Children/toArray.js +1 -17
- package/lib/cjs/node_modules/rc-resize-observer/node_modules/rc-util/es/Dom/findDOMNode.js +1 -14
- package/lib/cjs/node_modules/rc-resize-observer/node_modules/rc-util/es/ref.js +1 -25
- package/lib/cjs/node_modules/rc-resize-observer/node_modules/rc-util/es/warning.js +1 -5
- package/lib/cjs/node_modules/rc-util/es/Dom/canUseDom.js +0 -2
- package/lib/cjs/node_modules/rc-util/es/Dom/findDOMNode.js +1 -14
- package/lib/cjs/node_modules/rc-util/es/hooks/useLayoutEffect.js +2 -9
- package/lib/cjs/node_modules/rc-util/es/raf.js +0 -11
- package/lib/cjs/node_modules/rc-virtual-list/es/Filler.js +6 -25
- package/lib/cjs/node_modules/rc-virtual-list/es/Item.js +3 -14
- package/lib/cjs/node_modules/rc-virtual-list/es/List.js +103 -194
- package/lib/cjs/node_modules/rc-virtual-list/es/ScrollBar.js +16 -96
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useChildren.js +2 -11
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useDiffItem.js +8 -34
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useFrameWheel.js +0 -10
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useHeights.js +6 -39
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useMobileTouchMove.js +0 -16
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useOriginScroll.js +4 -9
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useScrollTo.js +3 -28
- package/lib/cjs/node_modules/rc-virtual-list/es/index.js +0 -2
- package/lib/cjs/node_modules/rc-virtual-list/es/utils/CacheMap.js +2 -9
- package/lib/cjs/node_modules/rc-virtual-list/es/utils/algorithmUtil.js +0 -15
- package/lib/cjs/node_modules/rc-virtual-list/es/utils/isFirefox.js +0 -2
- package/lib/cjs/node_modules/react-is/cjs/react-is.development.js +3 -29
- package/lib/cjs/node_modules/react-is/cjs/react-is.production.min.js +19 -45
- package/lib/cjs/node_modules/react-is/index.js +0 -5
- package/lib/cjs/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js +83 -248
- package/lib/cjs/packages/hooks/use-merge-refs/lib/esm/index.js +3 -14
- package/lib/cjs/packages/ui/scrollbar/lib/esm/Scrollbar.js +48 -86
- package/lib/cjs/packages/ui/scrollbar/lib/esm/styles/index.scss.js +1 -15
- package/lib/cjs/packages/ui/scrollbar/lib/esm/utils/index.js +0 -13
- package/lib/cjs/styles/index.scss.js +1 -4
- package/lib/cjs/use-table.js +268 -355
- package/lib/cjs/utils/index.js +11 -45
- package/lib/esm/BaseTable.js +117 -138
- package/lib/esm/ColGroupContent.js +3 -9
- package/lib/esm/SettingDrawer.js +64 -83
- package/lib/esm/Table.js +97 -124
- package/lib/esm/TableAdvancedFilter.js +37 -47
- package/lib/esm/TableBody.js +24 -34
- package/lib/esm/TableCell.js +48 -72
- package/lib/esm/TableColumnMenu.js +24 -38
- package/lib/esm/TableEmbedRow.js +8 -15
- package/lib/esm/TableHeader.js +5 -11
- package/lib/esm/TableRow.js +36 -51
- package/lib/esm/TableSettingMenu.js +33 -49
- package/lib/esm/TbodyContent.js +20 -27
- package/lib/esm/TheadContent.js +14 -21
- package/lib/esm/context.js +0 -4
- package/lib/esm/hooks/use-async-switch.js +9 -28
- package/lib/esm/hooks/use-check.js +42 -55
- package/lib/esm/hooks/use-col-hidden.js +16 -21
- package/lib/esm/hooks/use-col-set.js +5 -13
- package/lib/esm/hooks/use-col-sorter.js +18 -23
- package/lib/esm/hooks/use-col-width.js +14 -34
- package/lib/esm/hooks/use-colgroup.js +60 -66
- package/lib/esm/hooks/use-drag.js +9 -13
- package/lib/esm/hooks/use-embed-expand.js +20 -42
- package/lib/esm/hooks/use-expand.js +32 -56
- package/lib/esm/hooks/use-pagination.js +13 -25
- package/lib/esm/hooks/use-queue.js +2 -10
- package/lib/esm/node_modules/classnames/index.js +2 -9
- package/lib/esm/node_modules/perfect-scrollbar/dist/perfect-scrollbar.esm.js +31 -228
- package/lib/esm/node_modules/rc-resize-observer/es/index.js +3 -26
- package/lib/esm/node_modules/rc-resize-observer/node_modules/rc-util/es/Children/toArray.js +0 -3
- package/lib/esm/node_modules/rc-resize-observer/node_modules/rc-util/es/Dom/findDOMNode.js +1 -2
- package/lib/esm/node_modules/rc-resize-observer/node_modules/rc-util/es/ref.js +0 -8
- package/lib/esm/node_modules/rc-resize-observer/node_modules/rc-util/es/warning.js +0 -5
- package/lib/esm/node_modules/rc-util/es/Dom/canUseDom.js +0 -1
- package/lib/esm/node_modules/rc-util/es/Dom/findDOMNode.js +1 -2
- package/lib/esm/node_modules/rc-util/es/hooks/useLayoutEffect.js +1 -0
- package/lib/esm/node_modules/rc-util/es/raf.js +0 -10
- package/lib/esm/node_modules/rc-virtual-list/es/Filler.js +4 -15
- package/lib/esm/node_modules/rc-virtual-list/es/Item.js +1 -3
- package/lib/esm/node_modules/rc-virtual-list/es/List.js +101 -174
- package/lib/esm/node_modules/rc-virtual-list/es/ScrollBar.js +14 -86
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useChildren.js +0 -2
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useDiffItem.js +6 -25
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useFrameWheel.js +0 -6
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useHeights.js +4 -28
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useMobileTouchMove.js +0 -13
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useOriginScroll.js +4 -8
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useScrollTo.js +1 -19
- package/lib/esm/node_modules/rc-virtual-list/es/index.js +1 -1
- package/lib/esm/node_modules/rc-virtual-list/es/utils/CacheMap.js +2 -8
- package/lib/esm/node_modules/rc-virtual-list/es/utils/algorithmUtil.js +1 -12
- package/lib/esm/node_modules/rc-virtual-list/es/utils/isFirefox.js +0 -1
- package/lib/esm/node_modules/react-is/cjs/react-is.development.js +4 -27
- package/lib/esm/node_modules/react-is/cjs/react-is.production.min.js +20 -44
- package/lib/esm/node_modules/react-is/index.js +0 -1
- package/lib/esm/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js +82 -248
- package/lib/esm/packages/hooks/use-merge-refs/lib/esm/index.js +3 -9
- package/lib/esm/packages/ui/scrollbar/lib/esm/Scrollbar.js +47 -64
- package/lib/esm/packages/ui/scrollbar/lib/esm/styles/index.scss.js +1 -3
- package/lib/esm/packages/ui/scrollbar/lib/esm/utils/index.js +0 -10
- package/lib/esm/styles/index.scss.js +1 -3
- package/lib/esm/use-table.js +261 -318
- package/lib/esm/utils/index.js +11 -41
- package/lib/types/BaseTable.d.ts +2 -2
- package/package.json +33 -33
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
import * as React from 'react';
|
|
11
11
|
import classNames from '../../classnames/index.js';
|
|
12
12
|
import wrapperRaf from '../../rc-util/es/raf.js';
|
|
13
|
-
|
|
14
13
|
function _typeof(obj) {
|
|
15
14
|
"@babel/helpers - typeof";
|
|
16
15
|
|
|
@@ -20,7 +19,6 @@ function _typeof(obj) {
|
|
|
20
19
|
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
21
20
|
}, _typeof(obj);
|
|
22
21
|
}
|
|
23
|
-
|
|
24
22
|
function _defineProperty(obj, key, value) {
|
|
25
23
|
if (key in obj) {
|
|
26
24
|
Object.defineProperty(obj, key, {
|
|
@@ -32,16 +30,13 @@ function _defineProperty(obj, key, value) {
|
|
|
32
30
|
} else {
|
|
33
31
|
obj[key] = value;
|
|
34
32
|
}
|
|
35
|
-
|
|
36
33
|
return obj;
|
|
37
34
|
}
|
|
38
|
-
|
|
39
35
|
function _classCallCheck(instance, Constructor) {
|
|
40
36
|
if (!(instance instanceof Constructor)) {
|
|
41
37
|
throw new TypeError("Cannot call a class as a function");
|
|
42
38
|
}
|
|
43
39
|
}
|
|
44
|
-
|
|
45
40
|
function _defineProperties(target, props) {
|
|
46
41
|
for (var i = 0; i < props.length; i++) {
|
|
47
42
|
var descriptor = props[i];
|
|
@@ -51,7 +46,6 @@ function _defineProperties(target, props) {
|
|
|
51
46
|
Object.defineProperty(target, descriptor.key, descriptor);
|
|
52
47
|
}
|
|
53
48
|
}
|
|
54
|
-
|
|
55
49
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
56
50
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
57
51
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
@@ -60,12 +54,10 @@ function _createClass(Constructor, protoProps, staticProps) {
|
|
|
60
54
|
});
|
|
61
55
|
return Constructor;
|
|
62
56
|
}
|
|
63
|
-
|
|
64
57
|
function _inherits(subClass, superClass) {
|
|
65
58
|
if (typeof superClass !== "function" && superClass !== null) {
|
|
66
59
|
throw new TypeError("Super expression must either be null or a function");
|
|
67
60
|
}
|
|
68
|
-
|
|
69
61
|
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
70
62
|
constructor: {
|
|
71
63
|
value: subClass,
|
|
@@ -78,58 +70,45 @@ function _inherits(subClass, superClass) {
|
|
|
78
70
|
});
|
|
79
71
|
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
80
72
|
}
|
|
81
|
-
|
|
82
73
|
function _setPrototypeOf(o, p) {
|
|
83
74
|
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
84
75
|
o.__proto__ = p;
|
|
85
76
|
return o;
|
|
86
77
|
};
|
|
87
|
-
|
|
88
78
|
return _setPrototypeOf(o, p);
|
|
89
79
|
}
|
|
90
|
-
|
|
91
80
|
function _createSuper(Derived) {
|
|
92
81
|
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
93
|
-
|
|
94
82
|
return function _createSuperInternal() {
|
|
95
83
|
var Super = _getPrototypeOf(Derived),
|
|
96
|
-
|
|
97
|
-
|
|
84
|
+
result;
|
|
98
85
|
if (hasNativeReflectConstruct) {
|
|
99
86
|
var NewTarget = _getPrototypeOf(this).constructor;
|
|
100
|
-
|
|
101
87
|
result = Reflect.construct(Super, arguments, NewTarget);
|
|
102
88
|
} else {
|
|
103
89
|
result = Super.apply(this, arguments);
|
|
104
90
|
}
|
|
105
|
-
|
|
106
91
|
return _possibleConstructorReturn(this, result);
|
|
107
92
|
};
|
|
108
93
|
}
|
|
109
|
-
|
|
110
94
|
function _possibleConstructorReturn(self, call) {
|
|
111
95
|
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
112
96
|
return call;
|
|
113
97
|
} else if (call !== void 0) {
|
|
114
98
|
throw new TypeError("Derived constructors may only return object or undefined");
|
|
115
99
|
}
|
|
116
|
-
|
|
117
100
|
return _assertThisInitialized(self);
|
|
118
101
|
}
|
|
119
|
-
|
|
120
102
|
function _assertThisInitialized(self) {
|
|
121
103
|
if (self === void 0) {
|
|
122
104
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
123
105
|
}
|
|
124
|
-
|
|
125
106
|
return self;
|
|
126
107
|
}
|
|
127
|
-
|
|
128
108
|
function _isNativeReflectConstruct() {
|
|
129
109
|
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
130
110
|
if (Reflect.construct.sham) return false;
|
|
131
111
|
if (typeof Proxy === "function") return true;
|
|
132
|
-
|
|
133
112
|
try {
|
|
134
113
|
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
135
114
|
return true;
|
|
@@ -137,34 +116,25 @@ function _isNativeReflectConstruct() {
|
|
|
137
116
|
return false;
|
|
138
117
|
}
|
|
139
118
|
}
|
|
140
|
-
|
|
141
119
|
function _getPrototypeOf(o) {
|
|
142
120
|
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
143
121
|
return o.__proto__ || Object.getPrototypeOf(o);
|
|
144
122
|
};
|
|
145
123
|
return _getPrototypeOf(o);
|
|
146
124
|
}
|
|
147
|
-
|
|
148
125
|
var MIN_SIZE = 20;
|
|
149
|
-
|
|
150
126
|
function getPageY(e) {
|
|
151
127
|
return 'touches' in e ? e.touches[0].pageY : e.pageY;
|
|
152
128
|
}
|
|
153
|
-
|
|
154
129
|
var ScrollBar = /*#__PURE__*/function (_React$Component) {
|
|
155
130
|
_inherits(ScrollBar, _React$Component);
|
|
156
|
-
|
|
157
131
|
var _super = _createSuper(ScrollBar);
|
|
158
|
-
|
|
159
132
|
function ScrollBar() {
|
|
160
133
|
var _this;
|
|
161
|
-
|
|
162
134
|
_classCallCheck(this, ScrollBar);
|
|
163
|
-
|
|
164
135
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
165
136
|
args[_key] = arguments[_key];
|
|
166
137
|
}
|
|
167
|
-
|
|
168
138
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
169
139
|
_this.moveRaf = null;
|
|
170
140
|
_this.scrollbarRef = /*#__PURE__*/React.createRef();
|
|
@@ -176,90 +146,66 @@ var ScrollBar = /*#__PURE__*/function (_React$Component) {
|
|
|
176
146
|
startTop: null,
|
|
177
147
|
visible: false
|
|
178
148
|
};
|
|
179
|
-
|
|
180
149
|
_this.delayHidden = function () {
|
|
181
150
|
clearTimeout(_this.visibleTimeout);
|
|
182
|
-
|
|
183
151
|
_this.setState({
|
|
184
152
|
visible: true
|
|
185
153
|
});
|
|
186
|
-
|
|
187
154
|
_this.visibleTimeout = setTimeout(function () {
|
|
188
155
|
_this.setState({
|
|
189
156
|
visible: false
|
|
190
157
|
});
|
|
191
158
|
}, 2000);
|
|
192
159
|
};
|
|
193
|
-
|
|
194
160
|
_this.onScrollbarTouchStart = function (e) {
|
|
195
161
|
e.preventDefault();
|
|
196
162
|
};
|
|
197
|
-
|
|
198
163
|
_this.onContainerMouseDown = function (e) {
|
|
199
164
|
e.stopPropagation();
|
|
200
165
|
e.preventDefault();
|
|
201
166
|
};
|
|
202
|
-
|
|
203
167
|
_this.patchEvents = function () {
|
|
204
168
|
window.addEventListener('mousemove', _this.onMouseMove);
|
|
205
169
|
window.addEventListener('mouseup', _this.onMouseUp);
|
|
206
|
-
|
|
207
170
|
_this.thumbRef.current.addEventListener('touchmove', _this.onMouseMove);
|
|
208
|
-
|
|
209
171
|
_this.thumbRef.current.addEventListener('touchend', _this.onMouseUp);
|
|
210
172
|
};
|
|
211
|
-
|
|
212
173
|
_this.removeEvents = function () {
|
|
213
174
|
var _this$scrollbarRef$cu;
|
|
214
|
-
|
|
215
175
|
window.removeEventListener('mousemove', _this.onMouseMove);
|
|
216
176
|
window.removeEventListener('mouseup', _this.onMouseUp);
|
|
217
177
|
(_this$scrollbarRef$cu = _this.scrollbarRef.current) === null || _this$scrollbarRef$cu === void 0 ? void 0 : _this$scrollbarRef$cu.removeEventListener('touchstart', _this.onScrollbarTouchStart);
|
|
218
|
-
|
|
219
178
|
if (_this.thumbRef.current) {
|
|
220
179
|
_this.thumbRef.current.removeEventListener('touchstart', _this.onMouseDown);
|
|
221
|
-
|
|
222
180
|
_this.thumbRef.current.removeEventListener('touchmove', _this.onMouseMove);
|
|
223
|
-
|
|
224
181
|
_this.thumbRef.current.removeEventListener('touchend', _this.onMouseUp);
|
|
225
182
|
}
|
|
226
|
-
|
|
227
183
|
wrapperRaf.cancel(_this.moveRaf);
|
|
228
184
|
};
|
|
229
|
-
|
|
230
185
|
_this.onMouseDown = function (e) {
|
|
231
186
|
var onStartMove = _this.props.onStartMove;
|
|
232
|
-
|
|
233
187
|
_this.setState({
|
|
234
188
|
dragging: true,
|
|
235
189
|
pageY: getPageY(e),
|
|
236
190
|
startTop: _this.getTop()
|
|
237
191
|
});
|
|
238
|
-
|
|
239
192
|
onStartMove();
|
|
240
|
-
|
|
241
193
|
_this.patchEvents();
|
|
242
|
-
|
|
243
194
|
e.stopPropagation();
|
|
244
195
|
e.preventDefault();
|
|
245
196
|
};
|
|
246
|
-
|
|
247
197
|
_this.onMouseMove = function (e) {
|
|
248
198
|
var _this$state = _this.state,
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
199
|
+
dragging = _this$state.dragging,
|
|
200
|
+
pageY = _this$state.pageY,
|
|
201
|
+
startTop = _this$state.startTop;
|
|
252
202
|
var onScroll = _this.props.onScroll;
|
|
253
203
|
wrapperRaf.cancel(_this.moveRaf);
|
|
254
|
-
|
|
255
204
|
if (dragging) {
|
|
256
205
|
var offsetY = getPageY(e) - pageY;
|
|
257
206
|
var newTop = startTop + offsetY;
|
|
258
|
-
|
|
259
207
|
var enableScrollRange = _this.getEnableScrollRange();
|
|
260
|
-
|
|
261
208
|
var enableHeightRange = _this.getEnableHeightRange();
|
|
262
|
-
|
|
263
209
|
var ptg = enableHeightRange ? newTop / enableHeightRange : 0;
|
|
264
210
|
var newScrollTop = Math.ceil(ptg * enableScrollRange);
|
|
265
211
|
_this.moveRaf = wrapperRaf(function () {
|
|
@@ -267,69 +213,52 @@ var ScrollBar = /*#__PURE__*/function (_React$Component) {
|
|
|
267
213
|
});
|
|
268
214
|
}
|
|
269
215
|
};
|
|
270
|
-
|
|
271
216
|
_this.onMouseUp = function () {
|
|
272
217
|
var onStopMove = _this.props.onStopMove;
|
|
273
|
-
|
|
274
218
|
_this.setState({
|
|
275
219
|
dragging: false
|
|
276
220
|
});
|
|
277
|
-
|
|
278
221
|
onStopMove();
|
|
279
|
-
|
|
280
222
|
_this.removeEvents();
|
|
281
223
|
};
|
|
282
|
-
|
|
283
224
|
_this.getSpinHeight = function () {
|
|
284
225
|
var _this$props = _this.props,
|
|
285
|
-
|
|
286
|
-
|
|
226
|
+
height = _this$props.height,
|
|
227
|
+
count = _this$props.count;
|
|
287
228
|
var baseHeight = height / count * 10;
|
|
288
229
|
baseHeight = Math.max(baseHeight, MIN_SIZE);
|
|
289
230
|
baseHeight = Math.min(baseHeight, height / 2);
|
|
290
231
|
return Math.floor(baseHeight);
|
|
291
232
|
};
|
|
292
|
-
|
|
293
233
|
_this.getEnableScrollRange = function () {
|
|
294
234
|
var _this$props2 = _this.props,
|
|
295
|
-
|
|
296
|
-
|
|
235
|
+
scrollHeight = _this$props2.scrollHeight,
|
|
236
|
+
height = _this$props2.height;
|
|
297
237
|
return scrollHeight - height || 0;
|
|
298
238
|
};
|
|
299
|
-
|
|
300
239
|
_this.getEnableHeightRange = function () {
|
|
301
240
|
var height = _this.props.height;
|
|
302
|
-
|
|
303
241
|
var spinHeight = _this.getSpinHeight();
|
|
304
|
-
|
|
305
242
|
return height - spinHeight || 0;
|
|
306
243
|
};
|
|
307
|
-
|
|
308
244
|
_this.getTop = function () {
|
|
309
245
|
var scrollTop = _this.props.scrollTop;
|
|
310
|
-
|
|
311
246
|
var enableScrollRange = _this.getEnableScrollRange();
|
|
312
|
-
|
|
313
247
|
var enableHeightRange = _this.getEnableHeightRange();
|
|
314
|
-
|
|
315
248
|
if (scrollTop === 0 || enableScrollRange === 0) {
|
|
316
249
|
return 0;
|
|
317
250
|
}
|
|
318
|
-
|
|
319
251
|
var ptg = scrollTop / enableScrollRange;
|
|
320
252
|
return ptg * enableHeightRange;
|
|
321
253
|
};
|
|
322
|
-
|
|
323
254
|
_this.showScroll = function () {
|
|
324
255
|
var _this$props3 = _this.props,
|
|
325
|
-
|
|
326
|
-
|
|
256
|
+
height = _this$props3.height,
|
|
257
|
+
scrollHeight = _this$props3.scrollHeight;
|
|
327
258
|
return scrollHeight > height;
|
|
328
259
|
};
|
|
329
|
-
|
|
330
260
|
return _this;
|
|
331
261
|
}
|
|
332
|
-
|
|
333
262
|
_createClass(ScrollBar, [{
|
|
334
263
|
key: "componentDidMount",
|
|
335
264
|
value: function componentDidMount() {
|
|
@@ -351,11 +280,12 @@ var ScrollBar = /*#__PURE__*/function (_React$Component) {
|
|
|
351
280
|
}
|
|
352
281
|
}, {
|
|
353
282
|
key: "render",
|
|
354
|
-
value:
|
|
283
|
+
value:
|
|
284
|
+
// ====================== Render =======================
|
|
355
285
|
function render() {
|
|
356
286
|
var _this$state2 = this.state,
|
|
357
|
-
|
|
358
|
-
|
|
287
|
+
dragging = _this$state2.dragging,
|
|
288
|
+
visible = _this$state2.visible;
|
|
359
289
|
var prefixCls = this.props.prefixCls;
|
|
360
290
|
var spinHeight = this.getSpinHeight();
|
|
361
291
|
var top = this.getTop();
|
|
@@ -392,8 +322,6 @@ var ScrollBar = /*#__PURE__*/function (_React$Component) {
|
|
|
392
322
|
}));
|
|
393
323
|
}
|
|
394
324
|
}]);
|
|
395
|
-
|
|
396
325
|
return ScrollBar;
|
|
397
326
|
}(React.Component);
|
|
398
|
-
|
|
399
327
|
export { ScrollBar as default };
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import * as React from 'react';
|
|
11
11
|
import { Item } from '../Item.js';
|
|
12
|
-
|
|
13
12
|
function useChildren(list, startIndex, endIndex, setNodeRef, renderFunc, _ref) {
|
|
14
13
|
var getKey = _ref.getKey;
|
|
15
14
|
return list.slice(startIndex, endIndex + 1).map(function (item, index) {
|
|
@@ -25,5 +24,4 @@ function useChildren(list, startIndex, endIndex, setNodeRef, renderFunc, _ref) {
|
|
|
25
24
|
}, node);
|
|
26
25
|
});
|
|
27
26
|
}
|
|
28
|
-
|
|
29
27
|
export { useChildren as default };
|
|
@@ -9,15 +9,12 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import * as React from 'react';
|
|
11
11
|
import { findListDiffIndex } from '../utils/algorithmUtil.js';
|
|
12
|
-
|
|
13
12
|
function _slicedToArray(arr, i) {
|
|
14
13
|
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
15
14
|
}
|
|
16
|
-
|
|
17
15
|
function _nonIterableRest() {
|
|
18
16
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
19
17
|
}
|
|
20
|
-
|
|
21
18
|
function _unsupportedIterableToArray(o, minLen) {
|
|
22
19
|
if (!o) return;
|
|
23
20
|
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
@@ -26,31 +23,23 @@ function _unsupportedIterableToArray(o, minLen) {
|
|
|
26
23
|
if (n === "Map" || n === "Set") return Array.from(o);
|
|
27
24
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
28
25
|
}
|
|
29
|
-
|
|
30
26
|
function _arrayLikeToArray(arr, len) {
|
|
31
27
|
if (len == null || len > arr.length) len = arr.length;
|
|
32
|
-
|
|
33
28
|
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
34
29
|
arr2[i] = arr[i];
|
|
35
30
|
}
|
|
36
|
-
|
|
37
31
|
return arr2;
|
|
38
32
|
}
|
|
39
|
-
|
|
40
33
|
function _iterableToArrayLimit(arr, i) {
|
|
41
34
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
42
|
-
|
|
43
35
|
if (_i == null) return;
|
|
44
36
|
var _arr = [];
|
|
45
37
|
var _n = true;
|
|
46
38
|
var _d = false;
|
|
47
|
-
|
|
48
39
|
var _s, _e;
|
|
49
|
-
|
|
50
40
|
try {
|
|
51
41
|
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
52
42
|
_arr.push(_s.value);
|
|
53
|
-
|
|
54
43
|
if (i && _arr.length === i) break;
|
|
55
44
|
}
|
|
56
45
|
} catch (err) {
|
|
@@ -63,36 +52,28 @@ function _iterableToArrayLimit(arr, i) {
|
|
|
63
52
|
if (_d) throw _e;
|
|
64
53
|
}
|
|
65
54
|
}
|
|
66
|
-
|
|
67
55
|
return _arr;
|
|
68
56
|
}
|
|
69
|
-
|
|
70
57
|
function _arrayWithHoles(arr) {
|
|
71
58
|
if (Array.isArray(arr)) return arr;
|
|
72
59
|
}
|
|
73
|
-
|
|
74
60
|
function useDiffItem(data, getKey, onDiff) {
|
|
75
61
|
var _React$useState = React.useState(data),
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
62
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
63
|
+
prevData = _React$useState2[0],
|
|
64
|
+
setPrevData = _React$useState2[1];
|
|
80
65
|
var _React$useState3 = React.useState(null),
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
66
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
67
|
+
diffItem = _React$useState4[0],
|
|
68
|
+
setDiffItem = _React$useState4[1];
|
|
85
69
|
React.useEffect(function () {
|
|
86
70
|
var diff = findListDiffIndex(prevData || [], data || [], getKey);
|
|
87
|
-
|
|
88
71
|
if ((diff === null || diff === void 0 ? void 0 : diff.index) !== undefined) {
|
|
89
72
|
onDiff === null || onDiff === void 0 ? void 0 : onDiff(diff.index);
|
|
90
73
|
setDiffItem(data[diff.index]);
|
|
91
74
|
}
|
|
92
|
-
|
|
93
75
|
setPrevData(data);
|
|
94
76
|
}, [data]);
|
|
95
77
|
return [diffItem];
|
|
96
78
|
}
|
|
97
|
-
|
|
98
79
|
export { useDiffItem as default };
|
|
@@ -11,7 +11,6 @@ import { useRef } from 'react';
|
|
|
11
11
|
import wrapperRaf from '../../../rc-util/es/raf.js';
|
|
12
12
|
import isFF from '../utils/isFirefox.js';
|
|
13
13
|
import useOriginScroll from './useOriginScroll.js';
|
|
14
|
-
|
|
15
14
|
function useFrameWheel(inVirtual, isScrollAtTop, isScrollAtBottom, onWheelDelta) {
|
|
16
15
|
var offsetRef = useRef(0);
|
|
17
16
|
var nextFrameRef = useRef(null); // Firefox patch
|
|
@@ -20,7 +19,6 @@ function useFrameWheel(inVirtual, isScrollAtTop, isScrollAtBottom, onWheelDelta)
|
|
|
20
19
|
var isMouseScrollRef = useRef(false); // Scroll status sync
|
|
21
20
|
|
|
22
21
|
var originScroll = useOriginScroll(isScrollAtTop, isScrollAtBottom);
|
|
23
|
-
|
|
24
22
|
function onWheel(event) {
|
|
25
23
|
if (!inVirtual) return;
|
|
26
24
|
wrapperRaf.cancel(nextFrameRef.current);
|
|
@@ -33,7 +31,6 @@ function useFrameWheel(inVirtual, isScrollAtTop, isScrollAtBottom, onWheelDelta)
|
|
|
33
31
|
if (!isFF) {
|
|
34
32
|
event.preventDefault();
|
|
35
33
|
}
|
|
36
|
-
|
|
37
34
|
nextFrameRef.current = wrapperRaf(function () {
|
|
38
35
|
// Patch a multiple for Firefox to fix wheel number too small
|
|
39
36
|
// ref: https://github.com/ant-design/ant-design/issues/26372#issuecomment-679460266
|
|
@@ -43,13 +40,10 @@ function useFrameWheel(inVirtual, isScrollAtTop, isScrollAtBottom, onWheelDelta)
|
|
|
43
40
|
});
|
|
44
41
|
} // A patch for firefox
|
|
45
42
|
|
|
46
|
-
|
|
47
43
|
function onFireFoxScroll(event) {
|
|
48
44
|
if (!inVirtual) return;
|
|
49
45
|
isMouseScrollRef.current = event.detail === wheelValueRef.current;
|
|
50
46
|
}
|
|
51
|
-
|
|
52
47
|
return [onWheel, onFireFoxScroll];
|
|
53
48
|
}
|
|
54
|
-
|
|
55
49
|
export { useFrameWheel as default };
|
|
@@ -12,15 +12,12 @@ import { useRef, useEffect } from 'react';
|
|
|
12
12
|
import findDOMNode from '../../../rc-util/es/Dom/findDOMNode.js';
|
|
13
13
|
import wrapperRaf from '../../../rc-util/es/raf.js';
|
|
14
14
|
import CacheMap from '../utils/CacheMap.js';
|
|
15
|
-
|
|
16
15
|
function _slicedToArray(arr, i) {
|
|
17
16
|
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
18
17
|
}
|
|
19
|
-
|
|
20
18
|
function _nonIterableRest() {
|
|
21
19
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
22
20
|
}
|
|
23
|
-
|
|
24
21
|
function _unsupportedIterableToArray(o, minLen) {
|
|
25
22
|
if (!o) return;
|
|
26
23
|
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
@@ -29,31 +26,23 @@ function _unsupportedIterableToArray(o, minLen) {
|
|
|
29
26
|
if (n === "Map" || n === "Set") return Array.from(o);
|
|
30
27
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
31
28
|
}
|
|
32
|
-
|
|
33
29
|
function _arrayLikeToArray(arr, len) {
|
|
34
30
|
if (len == null || len > arr.length) len = arr.length;
|
|
35
|
-
|
|
36
31
|
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
37
32
|
arr2[i] = arr[i];
|
|
38
33
|
}
|
|
39
|
-
|
|
40
34
|
return arr2;
|
|
41
35
|
}
|
|
42
|
-
|
|
43
36
|
function _iterableToArrayLimit(arr, i) {
|
|
44
37
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
45
|
-
|
|
46
38
|
if (_i == null) return;
|
|
47
39
|
var _arr = [];
|
|
48
40
|
var _n = true;
|
|
49
41
|
var _d = false;
|
|
50
|
-
|
|
51
42
|
var _s, _e;
|
|
52
|
-
|
|
53
43
|
try {
|
|
54
44
|
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
55
45
|
_arr.push(_s.value);
|
|
56
|
-
|
|
57
46
|
if (i && _arr.length === i) break;
|
|
58
47
|
}
|
|
59
48
|
} catch (err) {
|
|
@@ -66,18 +55,15 @@ function _iterableToArrayLimit(arr, i) {
|
|
|
66
55
|
if (_d) throw _e;
|
|
67
56
|
}
|
|
68
57
|
}
|
|
69
|
-
|
|
70
58
|
return _arr;
|
|
71
59
|
}
|
|
72
|
-
|
|
73
60
|
function _arrayWithHoles(arr) {
|
|
74
61
|
if (Array.isArray(arr)) return arr;
|
|
75
62
|
}
|
|
63
|
+
|
|
76
64
|
/**
|
|
77
65
|
* To get exact height to avoid scrolling deviation
|
|
78
66
|
*/
|
|
79
|
-
|
|
80
|
-
|
|
81
67
|
function getOuterHeight(el) {
|
|
82
68
|
var height = el.offsetHeight;
|
|
83
69
|
var computedStyle = window.getComputedStyle(el);
|
|
@@ -85,21 +71,17 @@ function getOuterHeight(el) {
|
|
|
85
71
|
height += parseInt(computedStyle.marginBottom, 10);
|
|
86
72
|
return height;
|
|
87
73
|
}
|
|
88
|
-
|
|
89
74
|
function useHeights(getKey, onItemAdd, onItemRemove) {
|
|
90
75
|
var _React$useState = React.useState(0),
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
76
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
77
|
+
updatedMark = _React$useState2[0],
|
|
78
|
+
setUpdatedMark = _React$useState2[1];
|
|
95
79
|
var instanceRef = useRef(new Map());
|
|
96
80
|
var heightsRef = useRef(new CacheMap());
|
|
97
81
|
var collectRafRef = useRef();
|
|
98
|
-
|
|
99
82
|
function cancelRaf() {
|
|
100
83
|
wrapperRaf.cancel(collectRafRef.current);
|
|
101
84
|
}
|
|
102
|
-
|
|
103
85
|
function collectHeight() {
|
|
104
86
|
cancelRaf();
|
|
105
87
|
collectRafRef.current = wrapperRaf(function () {
|
|
@@ -107,7 +89,6 @@ function useHeights(getKey, onItemAdd, onItemRemove) {
|
|
|
107
89
|
if (element && element.offsetParent) {
|
|
108
90
|
var htmlElement = findDOMNode(element);
|
|
109
91
|
var outerHeight = getOuterHeight(htmlElement);
|
|
110
|
-
|
|
111
92
|
if (heightsRef.current.get(key) !== outerHeight) {
|
|
112
93
|
heightsRef.current.set(key, outerHeight);
|
|
113
94
|
}
|
|
@@ -119,11 +100,9 @@ function useHeights(getKey, onItemAdd, onItemRemove) {
|
|
|
119
100
|
});
|
|
120
101
|
});
|
|
121
102
|
}
|
|
122
|
-
|
|
123
103
|
function setInstanceRef(item, instance) {
|
|
124
104
|
var key = getKey(item);
|
|
125
105
|
var origin = instanceRef.current.get(key);
|
|
126
|
-
|
|
127
106
|
if (instance) {
|
|
128
107
|
instanceRef.current.set(key, instance);
|
|
129
108
|
collectHeight();
|
|
@@ -131,7 +110,6 @@ function useHeights(getKey, onItemAdd, onItemRemove) {
|
|
|
131
110
|
instanceRef.current["delete"](key);
|
|
132
111
|
} // Instance changed
|
|
133
112
|
|
|
134
|
-
|
|
135
113
|
if (!origin !== !instance) {
|
|
136
114
|
if (instance) {
|
|
137
115
|
onItemAdd === null || onItemAdd === void 0 ? void 0 : onItemAdd(item);
|
|
@@ -140,11 +118,9 @@ function useHeights(getKey, onItemAdd, onItemRemove) {
|
|
|
140
118
|
}
|
|
141
119
|
}
|
|
142
120
|
}
|
|
143
|
-
|
|
144
121
|
useEffect(function () {
|
|
145
122
|
return cancelRaf;
|
|
146
123
|
}, []);
|
|
147
124
|
return [setInstanceRef, collectHeight, heightsRef.current, updatedMark];
|
|
148
125
|
}
|
|
149
|
-
|
|
150
126
|
export { useHeights as default };
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
import { useRef } from 'react';
|
|
11
11
|
import useLayoutEffect from '../../../rc-util/es/hooks/useLayoutEffect.js';
|
|
12
12
|
var SMOOTH_PTG = 14 / 15;
|
|
13
|
-
|
|
14
13
|
function useMobileTouchMove(inVirtual, listRef, callback) {
|
|
15
14
|
var touchedRef = useRef(false);
|
|
16
15
|
var touchYRef = useRef(0);
|
|
@@ -20,37 +19,30 @@ function useMobileTouchMove(inVirtual, listRef, callback) {
|
|
|
20
19
|
/* eslint-disable prefer-const */
|
|
21
20
|
|
|
22
21
|
var cleanUpEvents;
|
|
23
|
-
|
|
24
22
|
var onTouchMove = function onTouchMove(e) {
|
|
25
23
|
if (touchedRef.current) {
|
|
26
24
|
var currentY = Math.ceil(e.touches[0].pageY);
|
|
27
25
|
var offsetY = touchYRef.current - currentY;
|
|
28
26
|
touchYRef.current = currentY;
|
|
29
|
-
|
|
30
27
|
if (callback(offsetY)) {
|
|
31
28
|
e.preventDefault();
|
|
32
29
|
} // Smooth interval
|
|
33
30
|
|
|
34
|
-
|
|
35
31
|
clearInterval(intervalRef.current);
|
|
36
32
|
intervalRef.current = setInterval(function () {
|
|
37
33
|
offsetY *= SMOOTH_PTG;
|
|
38
|
-
|
|
39
34
|
if (!callback(offsetY, true) || Math.abs(offsetY) <= 0.1) {
|
|
40
35
|
clearInterval(intervalRef.current);
|
|
41
36
|
}
|
|
42
37
|
}, 16);
|
|
43
38
|
}
|
|
44
39
|
};
|
|
45
|
-
|
|
46
40
|
var onTouchEnd = function onTouchEnd() {
|
|
47
41
|
touchedRef.current = false;
|
|
48
42
|
cleanUpEvents();
|
|
49
43
|
};
|
|
50
|
-
|
|
51
44
|
var onTouchStart = function onTouchStart(e) {
|
|
52
45
|
cleanUpEvents();
|
|
53
|
-
|
|
54
46
|
if (e.touches.length === 1 && !touchedRef.current) {
|
|
55
47
|
touchedRef.current = true;
|
|
56
48
|
touchYRef.current = Math.ceil(e.touches[0].pageY);
|
|
@@ -59,27 +51,22 @@ function useMobileTouchMove(inVirtual, listRef, callback) {
|
|
|
59
51
|
elementRef.current.addEventListener('touchend', onTouchEnd);
|
|
60
52
|
}
|
|
61
53
|
};
|
|
62
|
-
|
|
63
54
|
cleanUpEvents = function cleanUpEvents() {
|
|
64
55
|
if (elementRef.current) {
|
|
65
56
|
elementRef.current.removeEventListener('touchmove', onTouchMove);
|
|
66
57
|
elementRef.current.removeEventListener('touchend', onTouchEnd);
|
|
67
58
|
}
|
|
68
59
|
};
|
|
69
|
-
|
|
70
60
|
useLayoutEffect(function () {
|
|
71
61
|
if (inVirtual) {
|
|
72
62
|
listRef.current.addEventListener('touchstart', onTouchStart);
|
|
73
63
|
}
|
|
74
|
-
|
|
75
64
|
return function () {
|
|
76
65
|
var _listRef$current;
|
|
77
|
-
|
|
78
66
|
(_listRef$current = listRef.current) === null || _listRef$current === void 0 ? void 0 : _listRef$current.removeEventListener('touchstart', onTouchStart);
|
|
79
67
|
cleanUpEvents();
|
|
80
68
|
clearInterval(intervalRef.current);
|
|
81
69
|
};
|
|
82
70
|
}, [inVirtual]);
|
|
83
71
|
}
|
|
84
|
-
|
|
85
72
|
export { useMobileTouchMove as default };
|