@hi-ui/table 4.0.12 → 4.1.0-beta.0
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 +24 -0
- package/lib/cjs/BaseTable.js +7 -4
- package/lib/cjs/Table.js +19 -6
- package/lib/cjs/TableBody.js +88 -8
- package/lib/cjs/TableCell.js +42 -1
- package/lib/cjs/TableRow.js +42 -2
- package/lib/cjs/_virtual/index.js +18 -0
- package/lib/cjs/_virtual/index2.js +18 -0
- package/lib/cjs/_virtual/react-is.development.js +16 -0
- package/lib/cjs/_virtual/react-is.production.min.js +16 -0
- package/lib/cjs/hooks/use-check.js +28 -4
- package/lib/cjs/hooks/use-col-width.js +37 -8
- package/lib/cjs/hooks/use-pagination.js +51 -9
- package/lib/cjs/node_modules/classnames/index.js +76 -0
- package/lib/cjs/node_modules/rc-resize-observer/es/index.js +236 -0
- package/lib/cjs/node_modules/rc-resize-observer/node_modules/rc-util/es/Children/toArray.js +51 -0
- package/lib/cjs/node_modules/rc-resize-observer/node_modules/rc-util/es/Dom/findDOMNode.js +40 -0
- package/lib/cjs/node_modules/rc-resize-observer/node_modules/rc-util/es/ref.js +77 -0
- package/lib/cjs/node_modules/rc-resize-observer/node_modules/rc-util/es/warning.js +42 -0
- package/lib/cjs/node_modules/rc-util/es/Dom/canUseDom.js +20 -0
- package/lib/cjs/node_modules/rc-util/es/Dom/findDOMNode.js +40 -0
- package/lib/cjs/node_modules/rc-util/es/hooks/useLayoutEffect.js +49 -0
- package/lib/cjs/node_modules/rc-util/es/raf.js +72 -0
- package/lib/cjs/node_modules/rc-virtual-list/es/Filler.js +135 -0
- package/lib/cjs/node_modules/rc-virtual-list/es/Item.js +53 -0
- package/lib/cjs/node_modules/rc-virtual-list/es/List.js +550 -0
- package/lib/cjs/node_modules/rc-virtual-list/es/ScrollBar.js +431 -0
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useChildren.js +60 -0
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useDiffItem.js +129 -0
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useFrameWheel.js +64 -0
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useHeights.js +182 -0
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useMobileTouchMove.js +93 -0
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useOriginScroll.js +56 -0
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useScrollTo.js +154 -0
- package/lib/cjs/node_modules/rc-virtual-list/es/index.js +18 -0
- package/lib/cjs/node_modules/rc-virtual-list/es/utils/CacheMap.js +65 -0
- package/lib/cjs/node_modules/rc-virtual-list/es/utils/algorithmUtil.js +85 -0
- package/lib/cjs/node_modules/rc-virtual-list/es/utils/isFirefox.js +27 -0
- package/lib/cjs/node_modules/react-is/cjs/react-is.development.js +208 -0
- package/lib/cjs/node_modules/react-is/cjs/react-is.production.min.js +158 -0
- package/lib/cjs/node_modules/react-is/index.js +26 -0
- package/lib/cjs/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js +1127 -0
- package/lib/cjs/styles/index.scss.js +1 -1
- package/lib/cjs/use-table.js +4 -2
- package/lib/esm/BaseTable.js +24 -21
- package/lib/esm/Table.js +28 -15
- package/lib/esm/TableAdvancedFilter.js +13 -13
- package/lib/esm/TableBody.js +100 -21
- package/lib/esm/TableCell.js +50 -9
- package/lib/esm/TableColumnMenu.js +16 -16
- package/lib/esm/TableEmbedRow.js +4 -4
- package/lib/esm/TableHeader.js +10 -10
- package/lib/esm/TableRow.js +53 -13
- package/lib/esm/TableSettingMenu.js +14 -14
- package/lib/esm/_virtual/index.js +13 -0
- package/lib/esm/_virtual/index2.js +13 -0
- package/lib/esm/_virtual/react-is.development.js +11 -0
- package/lib/esm/_virtual/react-is.production.min.js +11 -0
- package/lib/esm/hooks/use-check.js +32 -8
- package/lib/esm/hooks/use-col-width.js +44 -15
- package/lib/esm/hooks/use-colgroup.js +4 -4
- package/lib/esm/hooks/use-drag.js +2 -2
- package/lib/esm/hooks/use-embed-expand.js +2 -2
- package/lib/esm/hooks/use-pagination.js +51 -10
- package/lib/esm/icons/index.js +5 -5
- package/lib/esm/node_modules/classnames/index.js +69 -0
- package/lib/esm/node_modules/rc-resize-observer/es/index.js +177 -0
- package/lib/esm/node_modules/rc-resize-observer/node_modules/rc-util/es/Children/toArray.js +33 -0
- package/lib/esm/node_modules/rc-resize-observer/node_modules/rc-util/es/Dom/findDOMNode.js +23 -0
- package/lib/esm/node_modules/rc-resize-observer/node_modules/rc-util/es/ref.js +57 -0
- package/lib/esm/node_modules/rc-resize-observer/node_modules/rc-util/es/warning.js +34 -0
- package/lib/esm/node_modules/rc-util/es/Dom/canUseDom.js +14 -0
- package/lib/esm/node_modules/rc-util/es/Dom/findDOMNode.js +23 -0
- package/lib/esm/node_modules/rc-util/es/hooks/useLayoutEffect.js +17 -0
- package/lib/esm/node_modules/rc-util/es/raf.js +66 -0
- package/lib/esm/node_modules/rc-virtual-list/es/Filler.js +103 -0
- package/lib/esm/node_modules/rc-virtual-list/es/Item.js +23 -0
- package/lib/esm/node_modules/rc-virtual-list/es/List.js +508 -0
- package/lib/esm/node_modules/rc-virtual-list/es/ScrollBar.js +399 -0
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useChildren.js +29 -0
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useDiffItem.js +98 -0
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useFrameWheel.js +55 -0
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useHeights.js +150 -0
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useMobileTouchMove.js +85 -0
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useOriginScroll.js +50 -0
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useScrollTo.js +123 -0
- package/lib/esm/node_modules/rc-virtual-list/es/index.js +11 -0
- package/lib/esm/node_modules/rc-virtual-list/es/utils/CacheMap.js +59 -0
- package/lib/esm/node_modules/rc-virtual-list/es/utils/algorithmUtil.js +80 -0
- package/lib/esm/node_modules/rc-virtual-list/es/utils/isFirefox.js +21 -0
- package/lib/esm/node_modules/react-is/cjs/react-is.development.js +200 -0
- package/lib/esm/node_modules/react-is/cjs/react-is.production.min.js +151 -0
- package/lib/esm/node_modules/react-is/index.js +20 -0
- package/lib/esm/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js +1122 -0
- package/lib/esm/styles/index.scss.js +1 -1
- package/lib/esm/use-table.js +12 -10
- package/lib/types/Table.d.ts +1 -1
- package/lib/types/TableCell.d.ts +4 -0
- package/lib/types/context.d.ts +2 -0
- package/lib/types/hooks/use-check.d.ts +1 -1
- package/lib/types/hooks/use-col-width.d.ts +2 -1
- package/lib/types/hooks/use-pagination.d.ts +7 -2
- package/lib/types/types.d.ts +7 -3
- package/lib/types/use-table.d.ts +14 -1
- package/package.json +6 -7
- package/LICENSE +0 -21
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/table
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/table#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
Object.defineProperty(exports, '__esModule', {
|
|
13
|
+
value: true
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
var React = require('react');
|
|
17
|
+
|
|
18
|
+
var index = require('../../classnames/index.js');
|
|
19
|
+
|
|
20
|
+
var raf = require('../../rc-util/es/raf.js');
|
|
21
|
+
|
|
22
|
+
function _interopNamespace(e) {
|
|
23
|
+
if (e && e.__esModule) return e;
|
|
24
|
+
var n = Object.create(null);
|
|
25
|
+
|
|
26
|
+
if (e) {
|
|
27
|
+
Object.keys(e).forEach(function (k) {
|
|
28
|
+
if (k !== 'default') {
|
|
29
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
30
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function get() {
|
|
33
|
+
return e[k];
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
n["default"] = e;
|
|
41
|
+
return Object.freeze(n);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
45
|
+
|
|
46
|
+
function _typeof(obj) {
|
|
47
|
+
"@babel/helpers - typeof";
|
|
48
|
+
|
|
49
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
50
|
+
return typeof obj;
|
|
51
|
+
} : function (obj) {
|
|
52
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
53
|
+
}, _typeof(obj);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function _defineProperty(obj, key, value) {
|
|
57
|
+
if (key in obj) {
|
|
58
|
+
Object.defineProperty(obj, key, {
|
|
59
|
+
value: value,
|
|
60
|
+
enumerable: true,
|
|
61
|
+
configurable: true,
|
|
62
|
+
writable: true
|
|
63
|
+
});
|
|
64
|
+
} else {
|
|
65
|
+
obj[key] = value;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return obj;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function _classCallCheck(instance, Constructor) {
|
|
72
|
+
if (!(instance instanceof Constructor)) {
|
|
73
|
+
throw new TypeError("Cannot call a class as a function");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function _defineProperties(target, props) {
|
|
78
|
+
for (var i = 0; i < props.length; i++) {
|
|
79
|
+
var descriptor = props[i];
|
|
80
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
81
|
+
descriptor.configurable = true;
|
|
82
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
83
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
88
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
89
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
90
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
91
|
+
writable: false
|
|
92
|
+
});
|
|
93
|
+
return Constructor;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function _inherits(subClass, superClass) {
|
|
97
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
98
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
102
|
+
constructor: {
|
|
103
|
+
value: subClass,
|
|
104
|
+
writable: true,
|
|
105
|
+
configurable: true
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
Object.defineProperty(subClass, "prototype", {
|
|
109
|
+
writable: false
|
|
110
|
+
});
|
|
111
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function _setPrototypeOf(o, p) {
|
|
115
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
116
|
+
o.__proto__ = p;
|
|
117
|
+
return o;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
return _setPrototypeOf(o, p);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function _createSuper(Derived) {
|
|
124
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
125
|
+
|
|
126
|
+
return function _createSuperInternal() {
|
|
127
|
+
var Super = _getPrototypeOf(Derived),
|
|
128
|
+
result;
|
|
129
|
+
|
|
130
|
+
if (hasNativeReflectConstruct) {
|
|
131
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
|
132
|
+
|
|
133
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
134
|
+
} else {
|
|
135
|
+
result = Super.apply(this, arguments);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return _possibleConstructorReturn(this, result);
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function _possibleConstructorReturn(self, call) {
|
|
143
|
+
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
144
|
+
return call;
|
|
145
|
+
} else if (call !== void 0) {
|
|
146
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return _assertThisInitialized(self);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function _assertThisInitialized(self) {
|
|
153
|
+
if (self === void 0) {
|
|
154
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return self;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function _isNativeReflectConstruct() {
|
|
161
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
162
|
+
if (Reflect.construct.sham) return false;
|
|
163
|
+
if (typeof Proxy === "function") return true;
|
|
164
|
+
|
|
165
|
+
try {
|
|
166
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
167
|
+
return true;
|
|
168
|
+
} catch (e) {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function _getPrototypeOf(o) {
|
|
174
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
175
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
176
|
+
};
|
|
177
|
+
return _getPrototypeOf(o);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
var MIN_SIZE = 20;
|
|
181
|
+
|
|
182
|
+
function getPageY(e) {
|
|
183
|
+
return 'touches' in e ? e.touches[0].pageY : e.pageY;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
var ScrollBar = /*#__PURE__*/function (_React$Component) {
|
|
187
|
+
_inherits(ScrollBar, _React$Component);
|
|
188
|
+
|
|
189
|
+
var _super = _createSuper(ScrollBar);
|
|
190
|
+
|
|
191
|
+
function ScrollBar() {
|
|
192
|
+
var _this;
|
|
193
|
+
|
|
194
|
+
_classCallCheck(this, ScrollBar);
|
|
195
|
+
|
|
196
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
197
|
+
args[_key] = arguments[_key];
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
201
|
+
_this.moveRaf = null;
|
|
202
|
+
_this.scrollbarRef = /*#__PURE__*/React__namespace.createRef();
|
|
203
|
+
_this.thumbRef = /*#__PURE__*/React__namespace.createRef();
|
|
204
|
+
_this.visibleTimeout = null;
|
|
205
|
+
_this.state = {
|
|
206
|
+
dragging: false,
|
|
207
|
+
pageY: null,
|
|
208
|
+
startTop: null,
|
|
209
|
+
visible: false
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
_this.delayHidden = function () {
|
|
213
|
+
clearTimeout(_this.visibleTimeout);
|
|
214
|
+
|
|
215
|
+
_this.setState({
|
|
216
|
+
visible: true
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
_this.visibleTimeout = setTimeout(function () {
|
|
220
|
+
_this.setState({
|
|
221
|
+
visible: false
|
|
222
|
+
});
|
|
223
|
+
}, 2000);
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
_this.onScrollbarTouchStart = function (e) {
|
|
227
|
+
e.preventDefault();
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
_this.onContainerMouseDown = function (e) {
|
|
231
|
+
e.stopPropagation();
|
|
232
|
+
e.preventDefault();
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
_this.patchEvents = function () {
|
|
236
|
+
window.addEventListener('mousemove', _this.onMouseMove);
|
|
237
|
+
window.addEventListener('mouseup', _this.onMouseUp);
|
|
238
|
+
|
|
239
|
+
_this.thumbRef.current.addEventListener('touchmove', _this.onMouseMove);
|
|
240
|
+
|
|
241
|
+
_this.thumbRef.current.addEventListener('touchend', _this.onMouseUp);
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
_this.removeEvents = function () {
|
|
245
|
+
var _this$scrollbarRef$cu;
|
|
246
|
+
|
|
247
|
+
window.removeEventListener('mousemove', _this.onMouseMove);
|
|
248
|
+
window.removeEventListener('mouseup', _this.onMouseUp);
|
|
249
|
+
(_this$scrollbarRef$cu = _this.scrollbarRef.current) === null || _this$scrollbarRef$cu === void 0 ? void 0 : _this$scrollbarRef$cu.removeEventListener('touchstart', _this.onScrollbarTouchStart);
|
|
250
|
+
|
|
251
|
+
if (_this.thumbRef.current) {
|
|
252
|
+
_this.thumbRef.current.removeEventListener('touchstart', _this.onMouseDown);
|
|
253
|
+
|
|
254
|
+
_this.thumbRef.current.removeEventListener('touchmove', _this.onMouseMove);
|
|
255
|
+
|
|
256
|
+
_this.thumbRef.current.removeEventListener('touchend', _this.onMouseUp);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
raf["default"].cancel(_this.moveRaf);
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
_this.onMouseDown = function (e) {
|
|
263
|
+
var onStartMove = _this.props.onStartMove;
|
|
264
|
+
|
|
265
|
+
_this.setState({
|
|
266
|
+
dragging: true,
|
|
267
|
+
pageY: getPageY(e),
|
|
268
|
+
startTop: _this.getTop()
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
onStartMove();
|
|
272
|
+
|
|
273
|
+
_this.patchEvents();
|
|
274
|
+
|
|
275
|
+
e.stopPropagation();
|
|
276
|
+
e.preventDefault();
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
_this.onMouseMove = function (e) {
|
|
280
|
+
var _this$state = _this.state,
|
|
281
|
+
dragging = _this$state.dragging,
|
|
282
|
+
pageY = _this$state.pageY,
|
|
283
|
+
startTop = _this$state.startTop;
|
|
284
|
+
var onScroll = _this.props.onScroll;
|
|
285
|
+
raf["default"].cancel(_this.moveRaf);
|
|
286
|
+
|
|
287
|
+
if (dragging) {
|
|
288
|
+
var offsetY = getPageY(e) - pageY;
|
|
289
|
+
var newTop = startTop + offsetY;
|
|
290
|
+
|
|
291
|
+
var enableScrollRange = _this.getEnableScrollRange();
|
|
292
|
+
|
|
293
|
+
var enableHeightRange = _this.getEnableHeightRange();
|
|
294
|
+
|
|
295
|
+
var ptg = enableHeightRange ? newTop / enableHeightRange : 0;
|
|
296
|
+
var newScrollTop = Math.ceil(ptg * enableScrollRange);
|
|
297
|
+
_this.moveRaf = raf["default"](function () {
|
|
298
|
+
onScroll(newScrollTop);
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
_this.onMouseUp = function () {
|
|
304
|
+
var onStopMove = _this.props.onStopMove;
|
|
305
|
+
|
|
306
|
+
_this.setState({
|
|
307
|
+
dragging: false
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
onStopMove();
|
|
311
|
+
|
|
312
|
+
_this.removeEvents();
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
_this.getSpinHeight = function () {
|
|
316
|
+
var _this$props = _this.props,
|
|
317
|
+
height = _this$props.height,
|
|
318
|
+
count = _this$props.count;
|
|
319
|
+
var baseHeight = height / count * 10;
|
|
320
|
+
baseHeight = Math.max(baseHeight, MIN_SIZE);
|
|
321
|
+
baseHeight = Math.min(baseHeight, height / 2);
|
|
322
|
+
return Math.floor(baseHeight);
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
_this.getEnableScrollRange = function () {
|
|
326
|
+
var _this$props2 = _this.props,
|
|
327
|
+
scrollHeight = _this$props2.scrollHeight,
|
|
328
|
+
height = _this$props2.height;
|
|
329
|
+
return scrollHeight - height || 0;
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
_this.getEnableHeightRange = function () {
|
|
333
|
+
var height = _this.props.height;
|
|
334
|
+
|
|
335
|
+
var spinHeight = _this.getSpinHeight();
|
|
336
|
+
|
|
337
|
+
return height - spinHeight || 0;
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
_this.getTop = function () {
|
|
341
|
+
var scrollTop = _this.props.scrollTop;
|
|
342
|
+
|
|
343
|
+
var enableScrollRange = _this.getEnableScrollRange();
|
|
344
|
+
|
|
345
|
+
var enableHeightRange = _this.getEnableHeightRange();
|
|
346
|
+
|
|
347
|
+
if (scrollTop === 0 || enableScrollRange === 0) {
|
|
348
|
+
return 0;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
var ptg = scrollTop / enableScrollRange;
|
|
352
|
+
return ptg * enableHeightRange;
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
_this.showScroll = function () {
|
|
356
|
+
var _this$props3 = _this.props,
|
|
357
|
+
height = _this$props3.height,
|
|
358
|
+
scrollHeight = _this$props3.scrollHeight;
|
|
359
|
+
return scrollHeight > height;
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
return _this;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
_createClass(ScrollBar, [{
|
|
366
|
+
key: "componentDidMount",
|
|
367
|
+
value: function componentDidMount() {
|
|
368
|
+
this.scrollbarRef.current.addEventListener('touchstart', this.onScrollbarTouchStart);
|
|
369
|
+
this.thumbRef.current.addEventListener('touchstart', this.onMouseDown);
|
|
370
|
+
}
|
|
371
|
+
}, {
|
|
372
|
+
key: "componentDidUpdate",
|
|
373
|
+
value: function componentDidUpdate(prevProps) {
|
|
374
|
+
if (prevProps.scrollTop !== this.props.scrollTop) {
|
|
375
|
+
this.delayHidden();
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}, {
|
|
379
|
+
key: "componentWillUnmount",
|
|
380
|
+
value: function componentWillUnmount() {
|
|
381
|
+
this.removeEvents();
|
|
382
|
+
clearTimeout(this.visibleTimeout);
|
|
383
|
+
}
|
|
384
|
+
}, {
|
|
385
|
+
key: "render",
|
|
386
|
+
value: // ====================== Render =======================
|
|
387
|
+
function render() {
|
|
388
|
+
var _this$state2 = this.state,
|
|
389
|
+
dragging = _this$state2.dragging,
|
|
390
|
+
visible = _this$state2.visible;
|
|
391
|
+
var prefixCls = this.props.prefixCls;
|
|
392
|
+
var spinHeight = this.getSpinHeight();
|
|
393
|
+
var top = this.getTop();
|
|
394
|
+
var canScroll = this.showScroll();
|
|
395
|
+
var mergedVisible = canScroll && visible;
|
|
396
|
+
return /*#__PURE__*/React__namespace.createElement("div", {
|
|
397
|
+
ref: this.scrollbarRef,
|
|
398
|
+
className: index["default"]("".concat(prefixCls, "-scrollbar"), _defineProperty({}, "".concat(prefixCls, "-scrollbar-show"), canScroll)),
|
|
399
|
+
style: {
|
|
400
|
+
width: 8,
|
|
401
|
+
top: 0,
|
|
402
|
+
bottom: 0,
|
|
403
|
+
right: 0,
|
|
404
|
+
position: 'absolute',
|
|
405
|
+
display: mergedVisible ? null : 'none'
|
|
406
|
+
},
|
|
407
|
+
onMouseDown: this.onContainerMouseDown,
|
|
408
|
+
onMouseMove: this.delayHidden
|
|
409
|
+
}, /*#__PURE__*/React__namespace.createElement("div", {
|
|
410
|
+
ref: this.thumbRef,
|
|
411
|
+
className: index["default"]("".concat(prefixCls, "-scrollbar-thumb"), _defineProperty({}, "".concat(prefixCls, "-scrollbar-thumb-moving"), dragging)),
|
|
412
|
+
style: {
|
|
413
|
+
width: '100%',
|
|
414
|
+
height: spinHeight,
|
|
415
|
+
top: top,
|
|
416
|
+
left: 0,
|
|
417
|
+
position: 'absolute',
|
|
418
|
+
background: 'rgba(0, 0, 0, 0.5)',
|
|
419
|
+
borderRadius: 99,
|
|
420
|
+
cursor: 'pointer',
|
|
421
|
+
userSelect: 'none'
|
|
422
|
+
},
|
|
423
|
+
onMouseDown: this.onMouseDown
|
|
424
|
+
}));
|
|
425
|
+
}
|
|
426
|
+
}]);
|
|
427
|
+
|
|
428
|
+
return ScrollBar;
|
|
429
|
+
}(React__namespace.Component);
|
|
430
|
+
|
|
431
|
+
exports["default"] = ScrollBar;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/table
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/table#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
Object.defineProperty(exports, '__esModule', {
|
|
13
|
+
value: true
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
var React = require('react');
|
|
17
|
+
|
|
18
|
+
var Item = require('../Item.js');
|
|
19
|
+
|
|
20
|
+
function _interopNamespace(e) {
|
|
21
|
+
if (e && e.__esModule) return e;
|
|
22
|
+
var n = Object.create(null);
|
|
23
|
+
|
|
24
|
+
if (e) {
|
|
25
|
+
Object.keys(e).forEach(function (k) {
|
|
26
|
+
if (k !== 'default') {
|
|
27
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
28
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: function get() {
|
|
31
|
+
return e[k];
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
n["default"] = e;
|
|
39
|
+
return Object.freeze(n);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
43
|
+
|
|
44
|
+
function useChildren(list, startIndex, endIndex, setNodeRef, renderFunc, _ref) {
|
|
45
|
+
var getKey = _ref.getKey;
|
|
46
|
+
return list.slice(startIndex, endIndex + 1).map(function (item, index) {
|
|
47
|
+
var eleIndex = startIndex + index;
|
|
48
|
+
var node = renderFunc(item, eleIndex, {// style: status === 'MEASURE_START' ? { visibility: 'hidden' } : {},
|
|
49
|
+
});
|
|
50
|
+
var key = getKey(item);
|
|
51
|
+
return /*#__PURE__*/React__namespace.createElement(Item.Item, {
|
|
52
|
+
key: key,
|
|
53
|
+
setRef: function setRef(ele) {
|
|
54
|
+
return setNodeRef(item, ele);
|
|
55
|
+
}
|
|
56
|
+
}, node);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
exports["default"] = useChildren;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/table
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/table#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
Object.defineProperty(exports, '__esModule', {
|
|
13
|
+
value: true
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
var React = require('react');
|
|
17
|
+
|
|
18
|
+
var algorithmUtil = require('../utils/algorithmUtil.js');
|
|
19
|
+
|
|
20
|
+
function _interopNamespace(e) {
|
|
21
|
+
if (e && e.__esModule) return e;
|
|
22
|
+
var n = Object.create(null);
|
|
23
|
+
|
|
24
|
+
if (e) {
|
|
25
|
+
Object.keys(e).forEach(function (k) {
|
|
26
|
+
if (k !== 'default') {
|
|
27
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
28
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: function get() {
|
|
31
|
+
return e[k];
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
n["default"] = e;
|
|
39
|
+
return Object.freeze(n);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
43
|
+
|
|
44
|
+
function _slicedToArray(arr, i) {
|
|
45
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function _nonIterableRest() {
|
|
49
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
53
|
+
if (!o) return;
|
|
54
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
55
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
56
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
57
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
58
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function _arrayLikeToArray(arr, len) {
|
|
62
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
63
|
+
|
|
64
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
65
|
+
arr2[i] = arr[i];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return arr2;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function _iterableToArrayLimit(arr, i) {
|
|
72
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
73
|
+
|
|
74
|
+
if (_i == null) return;
|
|
75
|
+
var _arr = [];
|
|
76
|
+
var _n = true;
|
|
77
|
+
var _d = false;
|
|
78
|
+
|
|
79
|
+
var _s, _e;
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
83
|
+
_arr.push(_s.value);
|
|
84
|
+
|
|
85
|
+
if (i && _arr.length === i) break;
|
|
86
|
+
}
|
|
87
|
+
} catch (err) {
|
|
88
|
+
_d = true;
|
|
89
|
+
_e = err;
|
|
90
|
+
} finally {
|
|
91
|
+
try {
|
|
92
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
93
|
+
} finally {
|
|
94
|
+
if (_d) throw _e;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return _arr;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function _arrayWithHoles(arr) {
|
|
102
|
+
if (Array.isArray(arr)) return arr;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function useDiffItem(data, getKey, onDiff) {
|
|
106
|
+
var _React$useState = React__namespace.useState(data),
|
|
107
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
108
|
+
prevData = _React$useState2[0],
|
|
109
|
+
setPrevData = _React$useState2[1];
|
|
110
|
+
|
|
111
|
+
var _React$useState3 = React__namespace.useState(null),
|
|
112
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
113
|
+
diffItem = _React$useState4[0],
|
|
114
|
+
setDiffItem = _React$useState4[1];
|
|
115
|
+
|
|
116
|
+
React__namespace.useEffect(function () {
|
|
117
|
+
var diff = algorithmUtil.findListDiffIndex(prevData || [], data || [], getKey);
|
|
118
|
+
|
|
119
|
+
if ((diff === null || diff === void 0 ? void 0 : diff.index) !== undefined) {
|
|
120
|
+
onDiff === null || onDiff === void 0 ? void 0 : onDiff(diff.index);
|
|
121
|
+
setDiffItem(data[diff.index]);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
setPrevData(data);
|
|
125
|
+
}, [data]);
|
|
126
|
+
return [diffItem];
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
exports["default"] = useDiffItem;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/table
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/table#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
Object.defineProperty(exports, '__esModule', {
|
|
13
|
+
value: true
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
var React = require('react');
|
|
17
|
+
|
|
18
|
+
var raf = require('../../../rc-util/es/raf.js');
|
|
19
|
+
|
|
20
|
+
var isFirefox = require('../utils/isFirefox.js');
|
|
21
|
+
|
|
22
|
+
var useOriginScroll = require('./useOriginScroll.js');
|
|
23
|
+
|
|
24
|
+
function useFrameWheel(inVirtual, isScrollAtTop, isScrollAtBottom, onWheelDelta) {
|
|
25
|
+
var offsetRef = React.useRef(0);
|
|
26
|
+
var nextFrameRef = React.useRef(null); // Firefox patch
|
|
27
|
+
|
|
28
|
+
var wheelValueRef = React.useRef(null);
|
|
29
|
+
var isMouseScrollRef = React.useRef(false); // Scroll status sync
|
|
30
|
+
|
|
31
|
+
var originScroll = useOriginScroll["default"](isScrollAtTop, isScrollAtBottom);
|
|
32
|
+
|
|
33
|
+
function onWheel(event) {
|
|
34
|
+
if (!inVirtual) return;
|
|
35
|
+
raf["default"].cancel(nextFrameRef.current);
|
|
36
|
+
var deltaY = event.deltaY;
|
|
37
|
+
offsetRef.current += deltaY;
|
|
38
|
+
wheelValueRef.current = deltaY; // Do nothing when scroll at the edge, Skip check when is in scroll
|
|
39
|
+
|
|
40
|
+
if (originScroll(deltaY)) return; // Proxy of scroll events
|
|
41
|
+
|
|
42
|
+
if (!isFirefox["default"]) {
|
|
43
|
+
event.preventDefault();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
nextFrameRef.current = raf["default"](function () {
|
|
47
|
+
// Patch a multiple for Firefox to fix wheel number too small
|
|
48
|
+
// ref: https://github.com/ant-design/ant-design/issues/26372#issuecomment-679460266
|
|
49
|
+
var patchMultiple = isMouseScrollRef.current ? 10 : 1;
|
|
50
|
+
onWheelDelta(offsetRef.current * patchMultiple);
|
|
51
|
+
offsetRef.current = 0;
|
|
52
|
+
});
|
|
53
|
+
} // A patch for firefox
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
function onFireFoxScroll(event) {
|
|
57
|
+
if (!inVirtual) return;
|
|
58
|
+
isMouseScrollRef.current = event.detail === wheelValueRef.current;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return [onWheel, onFireFoxScroll];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
exports["default"] = useFrameWheel;
|