@lemon-fe/components 0.1.119 → 0.1.123
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/es/Actions/index.js +17 -45
- package/es/Actions/index.less +6 -8
- package/es/BaseTable/Actions.d.ts +1 -0
- package/es/BaseTable/Actions.js +8 -30
- package/es/BaseTable/ResizeHeaderCell.js +12 -39
- package/es/BaseTable/VirtualBody.js +11 -50
- package/es/BaseTable/index.d.ts +1 -0
- package/es/BaseTable/index.js +109 -196
- package/es/BaseTable/index.less +7 -8
- package/es/BaseTable/utils.js +0 -4
- package/es/ColorPicker/index.js +13 -31
- package/es/Dropdown/index.js +9 -19
- package/es/DurationPicker/index.d.ts +1 -0
- package/es/DurationPicker/index.js +12 -40
- package/es/DurationPicker/index.less +5 -7
- package/es/EditableTable/EditableCell.js +9 -12
- package/es/EditableTable/EditableTableFormItem.d.ts +1 -0
- package/es/EditableTable/EditableTableFormItem.js +8 -16
- package/es/EditableTable/Table.js +28 -103
- package/es/EditableTable/index.less +2 -2
- package/es/EditableTable/util.d.ts +1 -1
- package/es/EditableTable/util.js +23 -99
- package/es/Filter/index.d.ts +8 -1
- package/es/Filter/index.js +118 -196
- package/es/Filter/index.less +1 -1
- package/es/Filter/typings.d.ts +1 -0
- package/es/FormHorizontal/index.js +0 -5
- package/es/FormHorizontal/index.less +3 -3
- package/es/FormInline/index.js +5 -21
- package/es/FormInline/index.less +5 -5
- package/es/FormLayout/index.js +6 -11
- package/es/FormLayout/index.less +5 -7
- package/es/FormTable/index.js +12 -46
- package/es/FormTable/index.less +2 -2
- package/es/Icons/BigTip/index.js +2 -14
- package/es/Icons/Calendar.js +0 -5
- package/es/Icons/Close.js +0 -5
- package/es/Icons/CollapseUp.js +0 -5
- package/es/Icons/DarkSearch.js +0 -5
- package/es/Icons/Down.js +0 -5
- package/es/Icons/Empty.js +0 -2
- package/es/Icons/LookUp.js +0 -5
- package/es/Icons/More.js +0 -5
- package/es/Icons/Search.js +0 -5
- package/es/Icons/Tip.js +2 -19
- package/es/InputMaxLength/index.js +9 -29
- package/es/InputMaxLength/index.less +2 -2
- package/es/Layout/index.js +23 -45
- package/es/MainFramework/components/DropMenu/index.d.ts +1 -0
- package/es/MainFramework/components/DropMenu/index.js +8 -19
- package/es/MainFramework/components/Menu/index.d.ts +1 -0
- package/es/MainFramework/components/Menu/index.js +22 -88
- package/es/MainFramework/components/RefreshButton/index.d.ts +1 -0
- package/es/MainFramework/components/RefreshButton/index.js +5 -14
- package/es/MainFramework/components/TabBar/index.d.ts +1 -0
- package/es/MainFramework/components/TabBar/index.js +6 -21
- package/es/MainFramework/index.js +18 -18
- package/es/PageLoading/index.js +0 -2
- package/es/PageLoading/index.less +0 -2
- package/es/Popup/index.js +30 -73
- package/es/Popup/index.less +0 -2
- package/es/Portal/index.js +13 -31
- package/es/Section/TabBar.js +6 -16
- package/es/Section/index.js +14 -22
- package/es/Section/index.less +6 -8
- package/es/SelectView/index.d.ts +1 -1
- package/es/SelectView/index.js +25 -62
- package/es/SelectView/index.less +7 -7
- package/es/SiderTree/TreeNodeTitle.d.ts +1 -0
- package/es/SiderTree/TreeNodeTitle.js +8 -24
- package/es/SiderTree/index.js +15 -50
- package/es/SiderTree/index.less +5 -5
- package/es/SymbolIcon/index.js +4 -9
- package/es/TabBar/index.js +7 -17
- package/es/Table/index.d.ts +2 -1
- package/es/Table/index.js +90 -124
- package/es/TipMark/index.js +7 -17
- package/es/TipMark/index.less +0 -2
- package/es/index.less +0 -1
- package/es/init.js +11 -27
- package/es/overrides.less +26 -26
- package/es/utils.js +0 -2
- package/es/utils.less +10 -10
- package/package.json +4 -4
- package/es/Table/index.less +0 -1
package/es/Actions/index.js
CHANGED
|
@@ -1,47 +1,32 @@
|
|
|
1
1
|
var _excluded = ["disabled", "dropDown", "text", "onClick", "icon", "action"];
|
|
2
|
-
|
|
3
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
|
|
5
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
-
|
|
7
4
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
-
|
|
9
5
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
10
|
-
|
|
11
6
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
12
|
-
|
|
13
7
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
14
|
-
|
|
15
8
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
16
|
-
|
|
17
9
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
18
|
-
|
|
19
10
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
20
|
-
|
|
21
11
|
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
22
|
-
|
|
23
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
24
|
-
|
|
25
13
|
import React, { Fragment, useState } from 'react';
|
|
26
14
|
import { Space, Dropdown, Menu, Button, Popover } from 'antd';
|
|
27
15
|
import classNames from 'classnames';
|
|
28
16
|
import Icons from '../Icons';
|
|
29
17
|
import { PREFIX_CLS } from '../constants';
|
|
30
|
-
|
|
31
18
|
function Actions(props) {
|
|
32
19
|
var actions = props.actions,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
20
|
+
className = props.className,
|
|
21
|
+
style = props.style,
|
|
22
|
+
_props$prefixCls = props.prefixCls,
|
|
23
|
+
prefixCls = _props$prefixCls === void 0 ? PREFIX_CLS : _props$prefixCls,
|
|
24
|
+
_props$maxShowCount = props.maxShowCount,
|
|
25
|
+
maxShowCount = _props$maxShowCount === void 0 ? 3 : _props$maxShowCount;
|
|
40
26
|
var _useState = useState(false),
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
27
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
28
|
+
visible = _useState2[0],
|
|
29
|
+
setVisible = _useState2[1];
|
|
45
30
|
var visibleBtns = actions.slice(0, maxShowCount);
|
|
46
31
|
var collapsedBtns = actions.slice(maxShowCount);
|
|
47
32
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -54,29 +39,24 @@ function Actions(props) {
|
|
|
54
39
|
if (item === null) {
|
|
55
40
|
return item;
|
|
56
41
|
}
|
|
57
|
-
|
|
58
42
|
if ( /*#__PURE__*/React.isValidElement(item)) {
|
|
59
43
|
return /*#__PURE__*/React.createElement(Fragment, {
|
|
60
44
|
key: index
|
|
61
45
|
}, item);
|
|
62
46
|
}
|
|
63
|
-
|
|
64
47
|
var disabled = item.disabled,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
48
|
+
dropDown = item.dropDown,
|
|
49
|
+
text = item.text,
|
|
50
|
+
onClick = item.onClick,
|
|
51
|
+
icon = item.icon,
|
|
52
|
+
action = item.action,
|
|
53
|
+
rest = _objectWithoutProperties(item, _excluded);
|
|
72
54
|
if ( /*#__PURE__*/React.isValidElement(text)) {
|
|
73
55
|
return /*#__PURE__*/React.createElement(Fragment, {
|
|
74
56
|
key: index
|
|
75
57
|
}, text);
|
|
76
58
|
}
|
|
77
|
-
|
|
78
59
|
var handleClick = onClick || action;
|
|
79
|
-
|
|
80
60
|
if (Array.isArray(dropDown)) {
|
|
81
61
|
var overlay = /*#__PURE__*/React.createElement(Menu, null, dropDown.map(function (subItem) {
|
|
82
62
|
if (subItem) {
|
|
@@ -89,7 +69,6 @@ function Actions(props) {
|
|
|
89
69
|
}, subItem.text);
|
|
90
70
|
}
|
|
91
71
|
}));
|
|
92
|
-
|
|
93
72
|
if (handleClick !== undefined) {
|
|
94
73
|
return /*#__PURE__*/React.createElement(Dropdown.Button, {
|
|
95
74
|
key: text,
|
|
@@ -98,16 +77,14 @@ function Actions(props) {
|
|
|
98
77
|
onClick: handleClick,
|
|
99
78
|
buttonsRender: function buttonsRender(_ref) {
|
|
100
79
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
80
|
+
leftBtn = _ref2[0],
|
|
81
|
+
_ = _ref2[1];
|
|
104
82
|
return [leftBtn, /*#__PURE__*/React.createElement(Button, {
|
|
105
83
|
icon: /*#__PURE__*/React.createElement(Icons.More, null)
|
|
106
84
|
})];
|
|
107
85
|
}
|
|
108
86
|
}, text);
|
|
109
87
|
}
|
|
110
|
-
|
|
111
88
|
return /*#__PURE__*/React.createElement(Dropdown, {
|
|
112
89
|
key: text,
|
|
113
90
|
disabled: disabled,
|
|
@@ -123,7 +100,6 @@ function Actions(props) {
|
|
|
123
100
|
}
|
|
124
101
|
})));
|
|
125
102
|
}
|
|
126
|
-
|
|
127
103
|
return /*#__PURE__*/React.createElement(Button, _objectSpread({
|
|
128
104
|
key: text,
|
|
129
105
|
disabled: disabled,
|
|
@@ -140,13 +116,11 @@ function Actions(props) {
|
|
|
140
116
|
if (item === null) {
|
|
141
117
|
return item;
|
|
142
118
|
}
|
|
143
|
-
|
|
144
119
|
if ( /*#__PURE__*/React.isValidElement(item)) {
|
|
145
120
|
return /*#__PURE__*/React.createElement(Fragment, {
|
|
146
121
|
key: index
|
|
147
122
|
}, item);
|
|
148
123
|
}
|
|
149
|
-
|
|
150
124
|
var disabled = item.disabled;
|
|
151
125
|
return /*#__PURE__*/React.createElement("div", {
|
|
152
126
|
className: classNames("".concat(prefixCls, "-actions-popover-item"), _defineProperty({}, "".concat(prefixCls, "-actions-popover-item-disabled"), disabled)),
|
|
@@ -155,7 +129,6 @@ function Actions(props) {
|
|
|
155
129
|
if (!disabled) {
|
|
156
130
|
var handleClick = item.onClick || item.action;
|
|
157
131
|
setVisible(false);
|
|
158
|
-
|
|
159
132
|
if (handleClick) {
|
|
160
133
|
handleClick();
|
|
161
134
|
}
|
|
@@ -167,5 +140,4 @@ function Actions(props) {
|
|
|
167
140
|
icon: /*#__PURE__*/React.createElement(Icons.More, null)
|
|
168
141
|
})) : null));
|
|
169
142
|
}
|
|
170
|
-
|
|
171
143
|
export default Actions;
|
package/es/Actions/index.less
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
@import '../theme.less';
|
|
2
|
-
|
|
3
1
|
.@{prefixCls}-actions {
|
|
4
2
|
&-popover {
|
|
5
|
-
|
|
3
|
+
&.@{ant-prefix}-popover {
|
|
6
4
|
padding-top: 0;
|
|
7
5
|
}
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
.@{ant-prefix}-popover-inner {
|
|
10
8
|
padding: 8px 0;
|
|
11
9
|
border-radius: 8px;
|
|
12
10
|
}
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
.@{ant-prefix}-popover-inner-content {
|
|
15
13
|
padding: 0;
|
|
16
14
|
}
|
|
17
15
|
|
|
18
|
-
|
|
16
|
+
.@{ant-prefix}-popover-arrow {
|
|
19
17
|
display: none;
|
|
20
18
|
}
|
|
21
19
|
|
|
@@ -47,7 +45,7 @@
|
|
|
47
45
|
}
|
|
48
46
|
}
|
|
49
47
|
|
|
50
|
-
|
|
48
|
+
.@{ant-prefix}-btn:not(.@{ant-prefix}-btn-icon-only) {
|
|
51
49
|
min-width: 80px;
|
|
52
50
|
padding: 4px 12px;
|
|
53
51
|
|
|
@@ -58,7 +56,7 @@
|
|
|
58
56
|
}
|
|
59
57
|
}
|
|
60
58
|
|
|
61
|
-
|
|
59
|
+
.@{ant-prefix}-btn-default {
|
|
62
60
|
.@{prefixCls}-symbol-icon {
|
|
63
61
|
opacity: 0.7;
|
|
64
62
|
}
|
package/es/BaseTable/Actions.js
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
-
|
|
3
2
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
|
-
|
|
5
3
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
|
-
|
|
7
4
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
-
|
|
9
5
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
10
|
-
|
|
11
6
|
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
12
|
-
|
|
13
7
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
|
-
|
|
15
8
|
import React, { useRef, useState } from 'react';
|
|
16
9
|
import classNames from 'classnames';
|
|
17
10
|
import { createPortal } from 'react-dom';
|
|
@@ -19,55 +12,44 @@ import { PREFIX_CLS } from '../constants';
|
|
|
19
12
|
import Icons from '../Icons';
|
|
20
13
|
export default function Actions(props) {
|
|
21
14
|
var actionsProp = props.actions,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
row = props.row,
|
|
16
|
+
index = props.index;
|
|
25
17
|
var _useState = useState(null),
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
19
|
+
pop = _useState2[0],
|
|
20
|
+
setPop = _useState2[1];
|
|
30
21
|
var _useState3 = useState(false),
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
22
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
23
|
+
visible = _useState4[0],
|
|
24
|
+
setVisible = _useState4[1];
|
|
35
25
|
var prefixCls = "".concat(PREFIX_CLS, "-table-operator");
|
|
36
26
|
var ref = useRef(null);
|
|
37
|
-
|
|
38
27
|
var openPop = function openPop(data) {
|
|
39
28
|
setPop(data);
|
|
40
29
|
setTimeout(function () {
|
|
41
30
|
setVisible(true);
|
|
42
31
|
}, 16);
|
|
43
32
|
};
|
|
44
|
-
|
|
45
33
|
var closePop = function closePop() {
|
|
46
34
|
if (visible === false) {
|
|
47
35
|
setPop(null);
|
|
48
36
|
return;
|
|
49
37
|
}
|
|
50
|
-
|
|
51
38
|
if (ref.current !== null) {
|
|
52
39
|
var node = ref.current;
|
|
53
40
|
setVisible(false);
|
|
54
|
-
|
|
55
41
|
var handler = function handler() {
|
|
56
42
|
node.removeEventListener('transitionend', handler);
|
|
57
43
|
setPop(null);
|
|
58
44
|
};
|
|
59
|
-
|
|
60
45
|
node.addEventListener('transitionend', handler);
|
|
61
46
|
}
|
|
62
47
|
};
|
|
63
|
-
|
|
64
48
|
var actions = typeof actionsProp === 'function' ? actionsProp(row, index) : actionsProp;
|
|
65
|
-
|
|
66
49
|
var getKey = function getKey(item, idx) {
|
|
67
50
|
var key = item.key || (typeof item.text === 'string' ? item.text : idx);
|
|
68
51
|
return key;
|
|
69
52
|
};
|
|
70
|
-
|
|
71
53
|
return /*#__PURE__*/React.createElement("div", {
|
|
72
54
|
className: prefixCls,
|
|
73
55
|
onMouseLeave: closePop
|
|
@@ -75,7 +57,6 @@ export default function Actions(props) {
|
|
|
75
57
|
if (item === null) {
|
|
76
58
|
return null;
|
|
77
59
|
}
|
|
78
|
-
|
|
79
60
|
var key = getKey(item, idx);
|
|
80
61
|
var dropDown = item.dropDown ? item.dropDown.filter(function (item) {
|
|
81
62
|
return item !== null;
|
|
@@ -92,7 +73,6 @@ export default function Actions(props) {
|
|
|
92
73
|
if (item.disabled) {
|
|
93
74
|
return;
|
|
94
75
|
}
|
|
95
|
-
|
|
96
76
|
if (dropDown.length > 0) {
|
|
97
77
|
var rect = e.target.getBoundingClientRect();
|
|
98
78
|
openPop({
|
|
@@ -103,7 +83,6 @@ export default function Actions(props) {
|
|
|
103
83
|
});
|
|
104
84
|
} else {
|
|
105
85
|
var _item$onClick;
|
|
106
|
-
|
|
107
86
|
(_item$onClick = item.onClick) === null || _item$onClick === void 0 ? void 0 : _item$onClick.call(item, row, index);
|
|
108
87
|
}
|
|
109
88
|
}
|
|
@@ -126,7 +105,6 @@ export default function Actions(props) {
|
|
|
126
105
|
onClick: function onClick() {
|
|
127
106
|
if (!item.disabled) {
|
|
128
107
|
var _item$onClick2;
|
|
129
|
-
|
|
130
108
|
closePop();
|
|
131
109
|
(_item$onClick2 = item.onClick) === null || _item$onClick2 === void 0 ? void 0 : _item$onClick2.call(item, row, index);
|
|
132
110
|
}
|
|
@@ -1,110 +1,83 @@
|
|
|
1
1
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
-
|
|
3
2
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
-
|
|
5
3
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
-
|
|
7
4
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
8
|
-
|
|
9
5
|
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
10
|
-
|
|
11
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
-
|
|
13
7
|
import React, { useState, useRef, useEffect } from 'react';
|
|
14
8
|
import { Resizable } from 'react-resizable';
|
|
15
9
|
export default function ResizeHeaderCell(props) {
|
|
16
10
|
var children = props.children,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
prefixCls = props.prefixCls,
|
|
12
|
+
fullTableRef = props.fullTableRef,
|
|
13
|
+
width = props.width,
|
|
14
|
+
onChange = props.onChange;
|
|
22
15
|
var _useState = useState(width),
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
17
|
+
size = _useState2[0],
|
|
18
|
+
setSize = _useState2[1];
|
|
27
19
|
var indicator = useRef();
|
|
28
20
|
var handle = useRef(null);
|
|
29
|
-
|
|
30
21
|
var _useState3 = useState(0),
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
22
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
23
|
+
offset = _useState4[0],
|
|
24
|
+
setOffset = _useState4[1];
|
|
35
25
|
useEffect(function () {
|
|
36
26
|
setSize(width);
|
|
37
27
|
}, [width]);
|
|
38
|
-
|
|
39
28
|
var getTable = function getTable() {
|
|
40
29
|
if (fullTableRef.current === null) {
|
|
41
30
|
return null;
|
|
42
31
|
}
|
|
43
|
-
|
|
44
32
|
return fullTableRef.current.querySelector('.ant-table');
|
|
45
33
|
};
|
|
46
|
-
|
|
47
34
|
var handleResizeStart = function handleResizeStart() {
|
|
48
35
|
var table = getTable();
|
|
49
|
-
|
|
50
36
|
if (table === null) {
|
|
51
37
|
return;
|
|
52
38
|
}
|
|
53
|
-
|
|
54
39
|
var elm = document.createElement('div');
|
|
55
40
|
elm.style.height = "".concat(table.offsetHeight || 0, "px");
|
|
56
41
|
elm.classList.add("".concat(prefixCls, "-resizable-indicator"));
|
|
57
|
-
|
|
58
42
|
if (table) {
|
|
59
43
|
table.appendChild(elm);
|
|
60
44
|
table.classList.add("".concat(prefixCls, "-resizing-col"));
|
|
61
45
|
indicator.current = elm;
|
|
62
|
-
|
|
63
46
|
if (handle.current !== null) {
|
|
64
47
|
var _handle$current = handle.current,
|
|
65
|
-
|
|
66
|
-
|
|
48
|
+
parent = _handle$current.offsetParent,
|
|
49
|
+
left = _handle$current.offsetLeft;
|
|
67
50
|
var node = handle.current.parentNode;
|
|
68
|
-
|
|
69
51
|
while (node !== null && node !== table) {
|
|
70
52
|
left -= node.scrollLeft;
|
|
71
|
-
|
|
72
53
|
if (node === parent) {
|
|
73
54
|
left += node.offsetLeft;
|
|
74
55
|
parent = node.offsetParent;
|
|
75
56
|
}
|
|
76
|
-
|
|
77
57
|
node = node.parentNode;
|
|
78
58
|
}
|
|
79
|
-
|
|
80
59
|
setOffset(left - size);
|
|
81
60
|
indicator.current.style.left = "".concat(left, "px");
|
|
82
61
|
}
|
|
83
62
|
}
|
|
84
63
|
};
|
|
85
|
-
|
|
86
64
|
var handleResizeStop = function handleResizeStop() {
|
|
87
65
|
var table = getTable();
|
|
88
|
-
|
|
89
66
|
if (table !== null && indicator.current !== undefined) {
|
|
90
67
|
table.removeChild(indicator.current);
|
|
91
68
|
table.classList.remove("".concat(prefixCls, "-resizing-col"));
|
|
92
|
-
|
|
93
69
|
if (onChange) {
|
|
94
70
|
onChange(size);
|
|
95
71
|
}
|
|
96
72
|
}
|
|
97
73
|
};
|
|
98
|
-
|
|
99
74
|
var handleResize = function handleResize(e, data) {
|
|
100
75
|
e.preventDefault();
|
|
101
|
-
|
|
102
76
|
if (indicator.current) {
|
|
103
77
|
setSize(data.size.width);
|
|
104
78
|
indicator.current.style.left = "".concat(offset + data.size.width, "px");
|
|
105
79
|
}
|
|
106
80
|
};
|
|
107
|
-
|
|
108
81
|
return /*#__PURE__*/React.createElement(Resizable, {
|
|
109
82
|
width: size,
|
|
110
83
|
height: 0,
|
|
@@ -1,27 +1,15 @@
|
|
|
1
1
|
var _excluded = ["children"];
|
|
2
|
-
|
|
3
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
|
|
5
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
-
|
|
7
4
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
-
|
|
9
5
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
10
|
-
|
|
11
6
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
12
|
-
|
|
13
7
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
14
|
-
|
|
15
8
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
16
|
-
|
|
17
9
|
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
18
|
-
|
|
19
10
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
20
|
-
|
|
21
11
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
22
|
-
|
|
23
12
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
24
|
-
|
|
25
13
|
import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
26
14
|
import { useThrottle } from '@lemon-fe/hooks';
|
|
27
15
|
import { get } from 'lodash';
|
|
@@ -29,47 +17,35 @@ import BaseTableContext from './BaseTableContext';
|
|
|
29
17
|
import { PREFIX_CLS } from '../constants';
|
|
30
18
|
export default function VirtualList(props) {
|
|
31
19
|
var children = props.children,
|
|
32
|
-
|
|
33
|
-
|
|
20
|
+
restProps = _objectWithoutProperties(props, _excluded);
|
|
34
21
|
var ref = useRef(null);
|
|
35
|
-
|
|
36
22
|
var _useContext = useContext(BaseTableContext),
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
23
|
+
scrollY = _useContext.scrollY,
|
|
24
|
+
_useContext$rowHeight = _useContext.rowHeight,
|
|
25
|
+
rowHeight = _useContext$rowHeight === void 0 ? 37 : _useContext$rowHeight;
|
|
41
26
|
var _useState = useState(null),
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
27
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
28
|
+
range = _useState2[0],
|
|
29
|
+
setRange = _useState2[1];
|
|
46
30
|
var getRange = function getRange() {
|
|
47
31
|
var height = Number(scrollY);
|
|
48
|
-
|
|
49
32
|
if (isNaN(height)) {
|
|
50
33
|
return null;
|
|
51
34
|
}
|
|
52
|
-
|
|
53
35
|
var body = ref.current;
|
|
54
|
-
|
|
55
36
|
if (body === null) {
|
|
56
37
|
return null;
|
|
57
38
|
}
|
|
58
|
-
|
|
59
39
|
var scroller = body.closest('.ant-table-body');
|
|
60
|
-
|
|
61
40
|
if (scroller === null) {
|
|
62
41
|
return null;
|
|
63
42
|
}
|
|
64
|
-
|
|
65
43
|
var pageSize = Math.ceil(height / rowHeight);
|
|
66
44
|
var offset = Math.round(scroller.scrollTop / rowHeight);
|
|
67
45
|
var start = offset - Math.floor(pageSize / 2);
|
|
68
|
-
|
|
69
46
|
if (start < 0) {
|
|
70
47
|
start = 0;
|
|
71
48
|
}
|
|
72
|
-
|
|
73
49
|
var end = offset + pageSize + Math.ceil(pageSize / 2) - 1;
|
|
74
50
|
var bufferSpace = height * 0.3;
|
|
75
51
|
return {
|
|
@@ -79,21 +55,16 @@ export default function VirtualList(props) {
|
|
|
79
55
|
isBottom: body.offsetHeight + body.offsetTop - (scroller.scrollTop + height) <= bufferSpace
|
|
80
56
|
};
|
|
81
57
|
};
|
|
82
|
-
|
|
83
58
|
var handleScroll = useThrottle(function () {
|
|
84
59
|
var mRange = getRange();
|
|
85
|
-
|
|
86
60
|
if (mRange === null) {
|
|
87
61
|
return;
|
|
88
62
|
}
|
|
89
|
-
|
|
90
63
|
var isTop = mRange.isTop,
|
|
91
|
-
|
|
92
|
-
|
|
64
|
+
isBottom = mRange.isBottom;
|
|
93
65
|
if (!isTop && !isBottom) {
|
|
94
66
|
return;
|
|
95
67
|
}
|
|
96
|
-
|
|
97
68
|
setRange(mRange);
|
|
98
69
|
}, 300, {
|
|
99
70
|
trailing: true
|
|
@@ -103,45 +74,35 @@ export default function VirtualList(props) {
|
|
|
103
74
|
}, [get(children, ['1', 'length']), rowHeight, scrollY]);
|
|
104
75
|
var render = useMemo(function () {
|
|
105
76
|
var _children = _slicedToArray(children, 2),
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
77
|
+
measureRow = _children[0],
|
|
78
|
+
rows = _children[1];
|
|
109
79
|
if (!Array.isArray(rows)) {
|
|
110
80
|
return [children, 0, 0];
|
|
111
81
|
}
|
|
112
|
-
|
|
113
82
|
if (range === null) {
|
|
114
83
|
return [measureRow, 0, 0];
|
|
115
84
|
}
|
|
116
|
-
|
|
117
85
|
var list = [];
|
|
118
86
|
var max = rows.length - 1;
|
|
119
87
|
var start = range.start,
|
|
120
|
-
|
|
121
|
-
|
|
88
|
+
end = range.end;
|
|
122
89
|
if (end > max) {
|
|
123
90
|
end = max;
|
|
124
91
|
}
|
|
125
|
-
|
|
126
92
|
for (var i = start; i <= end; i += 1) {
|
|
127
93
|
list.push(rows[i]);
|
|
128
94
|
}
|
|
129
|
-
|
|
130
95
|
return [[measureRow, list], start * rowHeight, (max - end) * rowHeight];
|
|
131
96
|
}, [children, range]);
|
|
132
97
|
useEffect(function () {
|
|
133
98
|
var _ref$current;
|
|
134
|
-
|
|
135
99
|
if (ref.current === null) {
|
|
136
100
|
return;
|
|
137
101
|
}
|
|
138
|
-
|
|
139
102
|
var tableBody = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.closest('.ant-table-body');
|
|
140
|
-
|
|
141
103
|
if (tableBody === null) {
|
|
142
104
|
return;
|
|
143
105
|
}
|
|
144
|
-
|
|
145
106
|
tableBody.addEventListener('scroll', handleScroll);
|
|
146
107
|
return function () {
|
|
147
108
|
tableBody.removeEventListener('scroll', handleScroll);
|