@aloudata/aloudata-design 0.4.8-beta.14 → 0.4.8-beta.16
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/dist/Avatar/component/Avatar/index.js +16 -5
- package/dist/Breadcrumb/index.js +16 -6
- package/dist/Button/index.js +32 -15
- package/dist/Button/style/variables.less +3 -3
- package/dist/Checkbox/component/CheckboxGroup/index.js +10 -4
- package/dist/Checkbox/index.js +8 -1
- package/dist/Checkbox/type.js +1 -0
- package/dist/ConfigProvider/defaultRenderEmpty.js +5 -0
- package/dist/ConfigProvider/sizeContext.js +1 -1
- package/dist/Divider/index.js +3 -0
- package/dist/DoubleCircleIcon/index.js +9 -7
- package/dist/Dropdown/Button.js +11 -7
- package/dist/Dropdown/index.js +9 -3
- package/dist/Dropdown/style/index.less +4 -0
- package/dist/Empty/image/Data.js +2 -0
- package/dist/Empty/image/Search.js +2 -0
- package/dist/Empty/image/SearchSmall.js +2 -0
- package/dist/Empty/image/User.js +2 -0
- package/dist/Empty/image/WorkBook.js +2 -0
- package/dist/Empty/index.js +23 -13
- package/dist/Icon/components/Icon.js +13 -9
- package/dist/Icon/components/createFromScripts.js +8 -2
- package/dist/Input/components/Group/index.js +9 -4
- package/dist/Input/components/Input/index.js +9 -3
- package/dist/Input/components/Password/index.js +10 -5
- package/dist/Input/components/TextArea/index.js +11 -6
- package/dist/Input/style/index.less +1 -1
- package/dist/InputNumber/index.js +12 -7
- package/dist/Menu/SubMenu.js +6 -1
- package/dist/Menu/index.js +7 -2
- package/dist/Menu/style/index.less +5 -0
- package/dist/Modal/index.js +129 -107
- package/dist/Modal/locale.js +6 -4
- package/dist/Modal/style/index.less +2 -1
- package/dist/Navigator/components/Header/index.js +2 -0
- package/dist/Navigator/components/Menu/index.js +19 -8
- package/dist/Navigator/components/MenuItem/index.js +9 -6
- package/dist/Navigator/index.js +7 -5
- package/dist/Popconfirm/index.js +27 -19
- package/dist/Popover/index.js +9 -2
- package/dist/Radio/components/Group/index.js +34 -26
- package/dist/Radio/components/Radio/index.js +18 -10
- package/dist/Select/components/MultipleOption.js +6 -4
- package/dist/Select/components/SingleOption.js +7 -5
- package/dist/Select/index.js +94 -44
- package/dist/Select/style/index.less +1 -0
- package/dist/Spin/CustomIcon/index.js +2 -0
- package/dist/Spin/index.js +10 -1
- package/dist/Steps/components/ProcessIcon/index.js +2 -0
- package/dist/Steps/components/Step/index.js +8 -2
- package/dist/Steps/index.js +10 -8
- package/dist/Switch/index.js +30 -18
- package/dist/Table/Table.js +129 -86
- package/dist/Table/components/Empty/index.js +2 -0
- package/dist/Table/components/Loading/index.js +2 -0
- package/dist/Table/components/TableBodyRowList/index.js +39 -19
- package/dist/Table/components/TableHead/index.js +86 -55
- package/dist/Table/hooks/useFrame.js +24 -9
- package/dist/Table/style/index.less +1 -1
- package/dist/Table/utils.js +27 -8
- package/dist/Tabs/index.js +32 -17
- package/dist/Tooltip/index.js +12 -12
- package/dist/Tooltip/style/index.less +7 -1
- package/dist/Tree/index.js +4 -2
- package/dist/_utils/hooks/useControlledState.js +21 -9
- package/dist/_utils/hooks/useId.js +5 -4
- package/dist/_utils/hooks/usePrefixCls.js +5 -2
- package/dist/index.js +1 -2
- package/dist/locale-provider/index.js +33 -8
- package/dist/message/index.js +7 -3
- package/dist/notification/demo/index.js +1 -0
- package/dist/notification/index.js +48 -39
- package/package.json +2 -2
package/dist/Steps/index.js
CHANGED
|
@@ -4,16 +4,17 @@ import classNames from 'classnames';
|
|
|
4
4
|
import { CustomDot } from "./components/CustomDot";
|
|
5
5
|
import { Step } from "./components/Step";
|
|
6
6
|
var INITIAL = 0;
|
|
7
|
+
|
|
7
8
|
function Steps(_ref) {
|
|
8
9
|
var className = _ref.className,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
current = _ref.current,
|
|
11
|
+
_ref$direction = _ref.direction,
|
|
12
|
+
direction = _ref$direction === void 0 ? 'horizontal' : _ref$direction,
|
|
13
|
+
_ref$defaultCurrent = _ref.defaultCurrent,
|
|
14
|
+
defaultCurrent = _ref$defaultCurrent === void 0 ? INITIAL : _ref$defaultCurrent,
|
|
15
|
+
status = _ref.status,
|
|
16
|
+
children = _ref.children,
|
|
17
|
+
items = _ref.items;
|
|
17
18
|
return /*#__PURE__*/React.createElement(AntdSteps, {
|
|
18
19
|
className: classNames('ald-steps', className),
|
|
19
20
|
current: current,
|
|
@@ -28,5 +29,6 @@ function Steps(_ref) {
|
|
|
28
29
|
type: "default"
|
|
29
30
|
}, children);
|
|
30
31
|
}
|
|
32
|
+
|
|
31
33
|
Steps.Step = Step;
|
|
32
34
|
export default Steps;
|
package/dist/Switch/index.js
CHANGED
|
@@ -1,37 +1,48 @@
|
|
|
1
1
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
|
|
2
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."); }
|
|
4
|
+
|
|
3
5
|
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); }
|
|
4
|
-
|
|
5
|
-
function
|
|
6
|
+
|
|
7
|
+
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
|
+
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
|
+
|
|
6
11
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
+
|
|
7
13
|
import { Switch as AntdSwitch } from 'antd';
|
|
8
14
|
import React, { useState, useEffect } from 'react';
|
|
9
15
|
import classnames from 'classnames';
|
|
16
|
+
|
|
10
17
|
var Switch = function Switch(_ref) {
|
|
11
18
|
var _ref$className = _ref.className,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
|
20
|
+
_ref$disabled = _ref.disabled,
|
|
21
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
22
|
+
_ref$loading = _ref.loading,
|
|
23
|
+
loading = _ref$loading === void 0 ? false : _ref$loading,
|
|
24
|
+
_ref$size = _ref.size,
|
|
25
|
+
size = _ref$size === void 0 ? 'middle' : _ref$size,
|
|
26
|
+
checked = _ref.checked,
|
|
27
|
+
_ref$defaultChecked = _ref.defaultChecked,
|
|
28
|
+
defaultChecked = _ref$defaultChecked === void 0 ? false : _ref$defaultChecked,
|
|
29
|
+
onChange = _ref.onChange,
|
|
30
|
+
onClick = _ref.onClick,
|
|
31
|
+
children = _ref.children;
|
|
32
|
+
|
|
25
33
|
var _useState = useState(typeof checked === 'undefined' ? defaultChecked : checked),
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
34
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
35
|
+
userChecked = _useState2[0],
|
|
36
|
+
setUserChecked = _useState2[1];
|
|
37
|
+
|
|
29
38
|
var onChangeCB = function onChangeCB(isChecked, event) {
|
|
30
39
|
setUserChecked(isChecked);
|
|
40
|
+
|
|
31
41
|
if (typeof onChange === 'function') {
|
|
32
42
|
onChange(isChecked, event);
|
|
33
43
|
}
|
|
34
44
|
};
|
|
45
|
+
|
|
35
46
|
var currentDisabled = loading ? true : disabled;
|
|
36
47
|
useEffect(function () {
|
|
37
48
|
if (typeof checked === 'boolean') {
|
|
@@ -55,4 +66,5 @@ var Switch = function Switch(_ref) {
|
|
|
55
66
|
className: "ald-switch-text"
|
|
56
67
|
}, children));
|
|
57
68
|
};
|
|
69
|
+
|
|
58
70
|
export default Switch;
|
package/dist/Table/Table.js
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
3
|
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
|
+
|
|
4
5
|
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; }
|
|
5
|
-
|
|
6
|
-
function
|
|
7
|
-
|
|
6
|
+
|
|
7
|
+
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
|
+
|
|
8
9
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
10
|
+
|
|
9
11
|
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
|
+
|
|
10
13
|
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); }
|
|
11
|
-
|
|
12
|
-
function
|
|
14
|
+
|
|
15
|
+
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
|
+
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
|
+
|
|
13
19
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
20
|
+
|
|
14
21
|
/* eslint-disable no-unneeded-ternary */
|
|
15
22
|
/// <reference types ='./react-table-config' />
|
|
16
23
|
import classnames from 'classnames';
|
|
@@ -29,80 +36,91 @@ import { useTimeoutLock } from "./hooks/useFrame";
|
|
|
29
36
|
var tableHeadRowHeight = 44;
|
|
30
37
|
var SCROLLBAR_SIZE = 15;
|
|
31
38
|
var ZERO = 0;
|
|
39
|
+
|
|
32
40
|
function Table(props, ref) {
|
|
33
41
|
var _classnames3;
|
|
42
|
+
|
|
34
43
|
var tableKey = props.key,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
44
|
+
columns = props.columns,
|
|
45
|
+
data = props.data,
|
|
46
|
+
onRowSelected = props.onRowSelected,
|
|
47
|
+
loadMore = props.loadMore,
|
|
48
|
+
loading = props.loading,
|
|
49
|
+
hasNextPage = props.hasNextPage,
|
|
50
|
+
_props$sortable = props.sortable,
|
|
51
|
+
sortable = _props$sortable === void 0 ? false : _props$sortable,
|
|
52
|
+
defaultSort = props.defaultSort,
|
|
53
|
+
_props$resizeColumn = props.resizeColumn,
|
|
54
|
+
resizeColumn = _props$resizeColumn === void 0 ? false : _props$resizeColumn,
|
|
55
|
+
allSortDirections = props.sortDirections,
|
|
56
|
+
_props$onChange = props.onChange,
|
|
57
|
+
onChange = _props$onChange === void 0 ? function () {} : _props$onChange,
|
|
58
|
+
_props$scrollThreshol = props.scrollThreshold,
|
|
59
|
+
scrollThreshold = _props$scrollThreshol === void 0 ? '150px' : _props$scrollThreshol,
|
|
60
|
+
_props$rowClassName = props.rowClassName,
|
|
61
|
+
rowClassName = _props$rowClassName === void 0 ? '' : _props$rowClassName,
|
|
62
|
+
_props$ellipsis = props.ellipsis,
|
|
63
|
+
ellipsis = _props$ellipsis === void 0 ? true : _props$ellipsis,
|
|
64
|
+
rowKey = props.rowKey,
|
|
65
|
+
height = props.height;
|
|
66
|
+
|
|
57
67
|
var _useState = useState(undefined),
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
68
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
69
|
+
tableClientWidth = _useState2[0],
|
|
70
|
+
setTableClientWidth = _useState2[1];
|
|
71
|
+
|
|
61
72
|
var _useState3 = useState(undefined),
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
73
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
74
|
+
tableClientHeight = _useState4[0],
|
|
75
|
+
setTableClientHeight = _useState4[1];
|
|
76
|
+
|
|
65
77
|
var prefixCls = usePrefixCls('', 'ald-table');
|
|
66
78
|
var tableRef = useRef(null);
|
|
67
79
|
var tableHeadRef = useRef(null);
|
|
68
80
|
var tableBodyRef = useRef(null);
|
|
69
81
|
var columnsWidthMapRef = useRef();
|
|
70
82
|
var columnsTotalWidthRef = useRef(ZERO);
|
|
83
|
+
|
|
71
84
|
var _useState5 = useState(false),
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
85
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
86
|
+
loadMoreLoading = _useState6[0],
|
|
87
|
+
setLoadMoreLoading = _useState6[1];
|
|
88
|
+
|
|
75
89
|
var lastOffsetLeftRef = useRef(ZERO);
|
|
76
90
|
var lastOffsetTopRef = useRef(ZERO);
|
|
91
|
+
|
|
77
92
|
var _useTimeoutLock = useTimeoutLock(),
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
93
|
+
_useTimeoutLock2 = _slicedToArray(_useTimeoutLock, 2),
|
|
94
|
+
setScrollTarget = _useTimeoutLock2[0],
|
|
95
|
+
getScrollTarget = _useTimeoutLock2[1]; // 初始化进入时 渲染表格容器宽度
|
|
96
|
+
|
|
81
97
|
|
|
82
|
-
// 初始化进入时 渲染表格容器宽度
|
|
83
98
|
useEffect(function () {
|
|
84
99
|
if (tableRef.current) {
|
|
85
100
|
setTableClientWidth(tableRef.current.clientWidth);
|
|
86
101
|
}
|
|
87
|
-
}, []);
|
|
102
|
+
}, []); // 转换外部传入的columns
|
|
88
103
|
|
|
89
|
-
// 转换外部传入的columns
|
|
90
104
|
var newColumns = useMemo(function () {
|
|
91
105
|
if (!tableClientWidth) {
|
|
92
106
|
return [];
|
|
93
107
|
}
|
|
108
|
+
|
|
94
109
|
var _getColumnsWidthMap = getColumnsWidthMap(columns, tableClientWidth, columnsWidthMapRef.current),
|
|
95
|
-
|
|
96
|
-
|
|
110
|
+
columnsWidthMap = _getColumnsWidthMap.columnsWidthMap,
|
|
111
|
+
totalColumnWidth = _getColumnsWidthMap.totalColumnWidth;
|
|
112
|
+
|
|
97
113
|
columnsWidthMapRef.current = columnsWidthMap;
|
|
98
114
|
columnsTotalWidthRef.current = totalColumnWidth;
|
|
99
115
|
return columns.map(function (column, index) {
|
|
100
116
|
var _columnsWidthMapRef$c, _columnsWidthMapRef$c2;
|
|
101
|
-
|
|
102
|
-
// 不设置dataIndex同时进行排序 则报错
|
|
117
|
+
|
|
118
|
+
var key = index.toString(); // 不设置dataIndex同时进行排序 则报错
|
|
119
|
+
|
|
103
120
|
if (column.dataIndex === undefined && sortable) {
|
|
104
121
|
message.error('不支持未设置dataIndex时进行排序设置');
|
|
105
122
|
}
|
|
123
|
+
|
|
106
124
|
return _objectSpread(_objectSpread({}, column), {}, {
|
|
107
125
|
width: (_columnsWidthMapRef$c = columnsWidthMapRef.current) === null || _columnsWidthMapRef$c === void 0 ? void 0 : (_columnsWidthMapRef$c2 = _columnsWidthMapRef$c.get(key)) === null || _columnsWidthMapRef$c2 === void 0 ? void 0 : _columnsWidthMapRef$c2.width,
|
|
108
126
|
Header: column.title ? column.title : function () {
|
|
@@ -111,36 +129,38 @@ function Table(props, ref) {
|
|
|
111
129
|
disableSortBy: !sortable || typeof column.sorter === 'boolean',
|
|
112
130
|
accessor: column.dataIndex,
|
|
113
131
|
Cell: function (_Cell) {
|
|
114
|
-
function Cell(
|
|
132
|
+
function Cell(_x) {
|
|
115
133
|
return _Cell.apply(this, arguments);
|
|
116
134
|
}
|
|
135
|
+
|
|
117
136
|
Cell.toString = function () {
|
|
118
137
|
return _Cell.toString();
|
|
119
138
|
};
|
|
139
|
+
|
|
120
140
|
return Cell;
|
|
121
141
|
}(function (_ref) {
|
|
122
142
|
var row = _ref.row,
|
|
123
|
-
|
|
143
|
+
value = _ref.value;
|
|
124
144
|
return typeof column.render === 'function' ? column.render(value, row.original, row.index) : value;
|
|
125
145
|
})
|
|
126
146
|
});
|
|
127
147
|
});
|
|
128
|
-
}, [columns, sortable, tableClientWidth]);
|
|
129
|
-
|
|
130
|
-
// 将rowId转为React Table支持的值
|
|
148
|
+
}, [columns, sortable, tableClientWidth]); // 将rowId转为React Table支持的值
|
|
131
149
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
150
|
+
|
|
132
151
|
var transformRowId = function transformRowId(row, relativeIndex, parent) {
|
|
133
152
|
if (rowKey && parent) {
|
|
134
153
|
if (typeof rowKey === 'string') {
|
|
135
154
|
return [rowKey, relativeIndex].join('.');
|
|
136
155
|
}
|
|
156
|
+
|
|
137
157
|
if (typeof rowKey === 'function') {
|
|
138
158
|
return [rowKey(row), relativeIndex].join('.');
|
|
139
159
|
}
|
|
140
160
|
}
|
|
161
|
+
|
|
141
162
|
return relativeIndex.toString();
|
|
142
163
|
};
|
|
143
|
-
|
|
144
164
|
/**
|
|
145
165
|
* 计算初始传递给 React Table的排序字段
|
|
146
166
|
* 1. 不存在 sortable 或者存在loadMore(内部滚动时),不进行排序操作防止内部滚动时冲突;
|
|
@@ -148,46 +168,57 @@ function Table(props, ref) {
|
|
|
148
168
|
* 3. 如果给了排序但没有默认,则按第一行排序
|
|
149
169
|
* @returns
|
|
150
170
|
*/
|
|
171
|
+
|
|
172
|
+
|
|
151
173
|
var getTableInitSort = function getTableInitSort() {
|
|
152
174
|
var EMPTY_SIZE = 0;
|
|
175
|
+
|
|
153
176
|
if (!sortable || loadMore || newColumns.length === EMPTY_SIZE) {
|
|
154
177
|
return [];
|
|
155
178
|
}
|
|
179
|
+
|
|
156
180
|
if (defaultSort && defaultSort.id) {
|
|
157
181
|
return [defaultSort];
|
|
158
182
|
}
|
|
183
|
+
|
|
159
184
|
var firstColumnSortData = {
|
|
160
185
|
id: newColumns[ZERO].accessor,
|
|
161
186
|
desc: !!(newColumns[ZERO].sortOrder && newColumns[ZERO].sortOrder === 'descend')
|
|
162
187
|
};
|
|
188
|
+
|
|
163
189
|
if (firstColumnSortData.id) {
|
|
164
190
|
return [firstColumnSortData];
|
|
165
191
|
}
|
|
192
|
+
|
|
166
193
|
return [];
|
|
167
194
|
};
|
|
195
|
+
|
|
168
196
|
var _useTable = useTable({
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
197
|
+
columns: newColumns,
|
|
198
|
+
// 对齐columns属性
|
|
199
|
+
data: data,
|
|
200
|
+
disableMultiSort: true,
|
|
201
|
+
disableSortBy: !sortable,
|
|
202
|
+
getRowId: transformRowId,
|
|
203
|
+
initialState: {
|
|
204
|
+
sortBy: getTableInitSort()
|
|
205
|
+
}
|
|
206
|
+
}, useBlockLayout, useSortBy, useRowSelect, useResizeColumns),
|
|
207
|
+
getTableProps = _useTable.getTableProps,
|
|
208
|
+
getTableBodyProps = _useTable.getTableBodyProps,
|
|
209
|
+
headerGroups = _useTable.headerGroups,
|
|
210
|
+
rows = _useTable.rows,
|
|
211
|
+
prepareRow = _useTable.prepareRow,
|
|
212
|
+
setSortBy = _useTable.setSortBy;
|
|
213
|
+
|
|
185
214
|
var scrollToTop = function scrollToTop() {
|
|
186
215
|
var INITIAL_OFFSET_TOP = 0;
|
|
216
|
+
|
|
187
217
|
if (tableBodyRef && tableBodyRef.current) {
|
|
188
218
|
tableBodyRef.current.scrollTop = INITIAL_OFFSET_TOP;
|
|
189
219
|
}
|
|
190
220
|
};
|
|
221
|
+
|
|
191
222
|
React.useImperativeHandle(ref, function () {
|
|
192
223
|
return {
|
|
193
224
|
backToTop: function backToTop() {
|
|
@@ -197,8 +228,7 @@ function Table(props, ref) {
|
|
|
197
228
|
});
|
|
198
229
|
var tableHeadNode = /*#__PURE__*/React.createElement(TableHead, {
|
|
199
230
|
canResizeColumn: resizeColumn,
|
|
200
|
-
headerGroups: headerGroups
|
|
201
|
-
// tableContentWidth={columnsTotalWidthRef.current}
|
|
231
|
+
headerGroups: headerGroups // tableContentWidth={columnsTotalWidthRef.current}
|
|
202
232
|
,
|
|
203
233
|
defaultSort: defaultSort,
|
|
204
234
|
sortable: sortable,
|
|
@@ -217,21 +247,23 @@ function Table(props, ref) {
|
|
|
217
247
|
rowClassName: rowClassName,
|
|
218
248
|
ellipsis: ellipsis,
|
|
219
249
|
onRowSelected: onRowSelected
|
|
220
|
-
});
|
|
250
|
+
}); // 渲染没有设置高度的表格
|
|
221
251
|
|
|
222
|
-
// 渲染没有设置高度的表格
|
|
223
252
|
var renderTableWithoutHeight = function renderTableWithoutHeight() {
|
|
224
253
|
var renderNoHeightTableBody = function renderNoHeightTableBody() {
|
|
225
254
|
if (loading && !rows.length) {
|
|
226
255
|
return /*#__PURE__*/React.createElement(Loading, null);
|
|
227
256
|
}
|
|
257
|
+
|
|
228
258
|
if (!loading && !rows.length) {
|
|
229
259
|
return /*#__PURE__*/React.createElement(Empty, null);
|
|
230
260
|
}
|
|
261
|
+
|
|
231
262
|
return /*#__PURE__*/React.createElement("div", {
|
|
232
263
|
className: "".concat(prefixCls, "-list")
|
|
233
264
|
}, tableRowListNode);
|
|
234
265
|
};
|
|
266
|
+
|
|
235
267
|
return /*#__PURE__*/React.createElement("div", {
|
|
236
268
|
className: classnames("".concat(prefixCls, "-inner-wrap"))
|
|
237
269
|
}, tableHeadNode, /*#__PURE__*/React.createElement("div", _extends({}, getTableBodyProps(), {
|
|
@@ -241,58 +273,64 @@ function Table(props, ref) {
|
|
|
241
273
|
}
|
|
242
274
|
}), renderNoHeightTableBody()));
|
|
243
275
|
};
|
|
276
|
+
|
|
244
277
|
var forceScroll = useCallback(function (scrollLeftNum, target) {
|
|
245
278
|
if (!target) {
|
|
246
279
|
return;
|
|
247
280
|
}
|
|
281
|
+
|
|
248
282
|
if (typeof target === 'function') {
|
|
249
283
|
target(scrollLeftNum);
|
|
250
284
|
} else if (target.scrollLeft !== scrollLeftNum) {
|
|
251
285
|
// eslint-disable-next-line no-param-reassign
|
|
252
286
|
target.scrollLeft = scrollLeftNum;
|
|
253
287
|
}
|
|
254
|
-
}, []);
|
|
288
|
+
}, []); // 内部滚动时 纵向的滚动
|
|
255
289
|
|
|
256
|
-
// 内部滚动时 纵向的滚动
|
|
257
290
|
var onBodyVerticalScroll = useCallback(function (target) {
|
|
258
291
|
if (!tableClientHeight) {
|
|
259
292
|
return;
|
|
260
293
|
}
|
|
294
|
+
|
|
261
295
|
var scrollHeight = target.scrollHeight,
|
|
262
|
-
|
|
263
|
-
|
|
296
|
+
clientHeight = target.clientHeight,
|
|
297
|
+
scrollTop = target.scrollTop;
|
|
264
298
|
var currentPosToBottomGap = scrollHeight - clientHeight - scrollTop; // 当前滚动条到底部的距离
|
|
265
299
|
|
|
266
300
|
var scrollThresholdValue = getValidScrollThreshold(scrollThreshold, tableClientHeight);
|
|
301
|
+
|
|
267
302
|
if (currentPosToBottomGap < scrollThresholdValue && hasNextPage && !loadMoreLoading) {
|
|
268
303
|
var _ref2;
|
|
304
|
+
|
|
269
305
|
setLoadMoreLoading(true);
|
|
270
306
|
(_ref2 = loadMore()) === null || _ref2 === void 0 ? void 0 : _ref2.then(function () {
|
|
271
307
|
setLoadMoreLoading(false);
|
|
272
308
|
});
|
|
273
309
|
}
|
|
310
|
+
|
|
274
311
|
lastOffsetTopRef.current = scrollTop;
|
|
275
|
-
}, [hasNextPage, loadMore, loadMoreLoading, scrollThreshold, tableClientHeight]);
|
|
312
|
+
}, [hasNextPage, loadMore, loadMoreLoading, scrollThreshold, tableClientHeight]); // 内部滚动 对于滚动的处理
|
|
276
313
|
|
|
277
|
-
// 内部滚动 对于滚动的处理
|
|
278
314
|
var onBodyScroll = useCallback(function (e) {
|
|
279
315
|
var currentTarget = e.target;
|
|
316
|
+
|
|
280
317
|
if (!currentTarget) {
|
|
281
318
|
return;
|
|
282
319
|
}
|
|
320
|
+
|
|
283
321
|
var scrollLeftNum = currentTarget.scrollLeft;
|
|
284
|
-
var scrollTopNum = currentTarget.scrollTop;
|
|
322
|
+
var scrollTopNum = currentTarget.scrollTop; // 纵向滚动
|
|
285
323
|
|
|
286
|
-
// 纵向滚动
|
|
287
324
|
if (scrollTopNum !== lastOffsetLeftRef.current) {
|
|
288
325
|
onBodyVerticalScroll(currentTarget);
|
|
289
326
|
}
|
|
327
|
+
|
|
290
328
|
if (scrollLeftNum === lastOffsetLeftRef.current) {
|
|
291
329
|
return;
|
|
292
330
|
}
|
|
293
|
-
var compareTarget = currentTarget;
|
|
294
331
|
|
|
295
|
-
// 横向滚动
|
|
332
|
+
var compareTarget = currentTarget; // 横向滚动
|
|
333
|
+
|
|
296
334
|
if (!getScrollTarget() || getScrollTarget() === compareTarget) {
|
|
297
335
|
setScrollTarget(compareTarget);
|
|
298
336
|
forceScroll(scrollLeftNum, tableBodyRef.current);
|
|
@@ -304,20 +342,22 @@ function Table(props, ref) {
|
|
|
304
342
|
if (!hasNextPage) {
|
|
305
343
|
setLoadMoreLoading(false);
|
|
306
344
|
}
|
|
307
|
-
}, [hasNextPage]);
|
|
345
|
+
}, [hasNextPage]); // 渲染有设置高度的表格
|
|
308
346
|
|
|
309
|
-
// 渲染有设置高度的表格
|
|
310
347
|
var renderTableWithHeight = function renderTableWithHeight() {
|
|
311
348
|
if (!tableClientWidth || !tableClientHeight) {
|
|
312
349
|
return null;
|
|
313
350
|
}
|
|
351
|
+
|
|
314
352
|
var renderNoHeightTableBody = function renderNoHeightTableBody() {
|
|
315
353
|
if (loading && !rows.length) {
|
|
316
354
|
return /*#__PURE__*/React.createElement(Loading, null);
|
|
317
355
|
}
|
|
356
|
+
|
|
318
357
|
if (!loading && !rows.length) {
|
|
319
358
|
return /*#__PURE__*/React.createElement(Empty, null);
|
|
320
359
|
}
|
|
360
|
+
|
|
321
361
|
return /*#__PURE__*/React.createElement("div", {
|
|
322
362
|
style: {
|
|
323
363
|
overflow: 'overlay',
|
|
@@ -328,6 +368,7 @@ function Table(props, ref) {
|
|
|
328
368
|
onScroll: onBodyScroll
|
|
329
369
|
}, tableRowListNode, loadMoreLoading && /*#__PURE__*/React.createElement(Loading, null));
|
|
330
370
|
};
|
|
371
|
+
|
|
331
372
|
return /*#__PURE__*/React.createElement("div", {
|
|
332
373
|
className: classnames("".concat(prefixCls, "-inner-wrap"), _defineProperty({}, "".concat(prefixCls, "-innerScroll"), !!height))
|
|
333
374
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -337,6 +378,7 @@ function Table(props, ref) {
|
|
|
337
378
|
className: classnames("".concat(prefixCls, "-tbody"), _defineProperty({}, "".concat(prefixCls, "-tbody-innerScroll"), !!height))
|
|
338
379
|
}), renderNoHeightTableBody()));
|
|
339
380
|
};
|
|
381
|
+
|
|
340
382
|
return /*#__PURE__*/React.createElement("div", {
|
|
341
383
|
key: tableKey,
|
|
342
384
|
className: prefixCls,
|
|
@@ -347,7 +389,7 @@ function Table(props, ref) {
|
|
|
347
389
|
}, /*#__PURE__*/React.createElement(ResizeObserver, {
|
|
348
390
|
onResize: function onResize(_ref3) {
|
|
349
391
|
var clientWidth = _ref3.width,
|
|
350
|
-
|
|
392
|
+
clientHeight = _ref3.height;
|
|
351
393
|
setTableClientWidth(clientWidth);
|
|
352
394
|
setTableClientHeight(clientHeight);
|
|
353
395
|
}
|
|
@@ -355,4 +397,5 @@ function Table(props, ref) {
|
|
|
355
397
|
className: classnames("".concat(prefixCls, "-table-wrap"), (_classnames3 = {}, _defineProperty(_classnames3, "".concat(prefixCls, "-init-loading"), data.length === ZERO && loading), _defineProperty(_classnames3, "".concat(prefixCls, "-empty"), data.length === ZERO && loading), _classnames3))
|
|
356
398
|
}), height ? renderTableWithHeight() : renderTableWithoutHeight())));
|
|
357
399
|
}
|
|
400
|
+
|
|
358
401
|
export default /*#__PURE__*/React.forwardRef(Table);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import Empty from "../../../Empty";
|
|
3
3
|
import usePrefixCls from "../../../_utils/hooks/usePrefixCls";
|
|
4
|
+
|
|
4
5
|
function LoadingNode() {
|
|
5
6
|
var prefixCls = usePrefixCls('', 'ald-table');
|
|
6
7
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -11,4 +12,5 @@ function LoadingNode() {
|
|
|
11
12
|
image: Empty.PRESENTED_IMAGE_DATA
|
|
12
13
|
}));
|
|
13
14
|
}
|
|
15
|
+
|
|
14
16
|
export default LoadingNode;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import Spin from "../../../Spin";
|
|
3
3
|
import usePrefixCls from "../../../_utils/hooks/usePrefixCls";
|
|
4
|
+
|
|
4
5
|
function LoadingNode() {
|
|
5
6
|
var prefixCls = usePrefixCls('', 'ald-table');
|
|
6
7
|
return /*#__PURE__*/React.createElement(Spin, {
|
|
@@ -9,4 +10,5 @@ function LoadingNode() {
|
|
|
9
10
|
className: "".concat(prefixCls, "-loading")
|
|
10
11
|
}));
|
|
11
12
|
}
|
|
13
|
+
|
|
12
14
|
export default LoadingNode;
|