@aloudata/aloudata-design 1.10.6 → 1.10.8
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/ConfigProvider/getUserList.d.ts +1 -0
- package/dist/MemberPicker/components/MemberSelection.js +2 -1
- package/dist/MemberPicker/components/MultipleOption.js +1 -0
- package/dist/MemberPicker/components/NickLabel.js +1 -1
- package/dist/MemberPicker/components/Panel.js +1 -0
- package/dist/MemberPicker/components/PanelWrapper.js +4 -1
- package/dist/MemberPicker/components/UserGroupSelection.d.ts +1 -1
- package/dist/MemberPicker/components/UserGroupSelection.js +41 -21
- package/dist/MemberPicker/index.js +9 -3
- package/dist/MemberPicker/style/index.less +58 -6
- package/dist/Switch/index.js +3 -3
- package/dist/Table/components/Pagination/index.d.ts +9 -0
- package/dist/Table/components/Pagination/index.js +26 -0
- package/dist/Table/index.d.ts +3 -3
- package/dist/Table/index.js +26 -9
- package/dist/Table/types.d.ts +4 -0
- package/dist/Tree/style/index.less +2 -2
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -54,7 +54,8 @@ export default function MemberSelection(props) {
|
|
|
54
54
|
}), /*#__PURE__*/React.createElement(Spin, {
|
|
55
55
|
tip: "Loading",
|
|
56
56
|
spinning: loading,
|
|
57
|
-
size: "small"
|
|
57
|
+
size: "small",
|
|
58
|
+
className: "ald-member-picker-user-list"
|
|
58
59
|
}, /*#__PURE__*/React.createElement(ScrollArea, {
|
|
59
60
|
className: classNames('ald-member-picker-member-list', {
|
|
60
61
|
'ald-member-picker-member-list-null': userList.length === 0 && !loading
|
|
@@ -38,6 +38,7 @@ export default function MultipleList(params) {
|
|
|
38
38
|
account: getAccount(user)
|
|
39
39
|
})), isUserGroup(user) && hasNextLevel && /*#__PURE__*/React.createElement(Button, {
|
|
40
40
|
type: "link",
|
|
41
|
+
className: "ald-member-picker-btn",
|
|
41
42
|
onClick: function onClick(e) {
|
|
42
43
|
onNextLevel === null || onNextLevel === void 0 ? void 0 : onNextLevel(user);
|
|
43
44
|
e.stopPropagation();
|
|
@@ -14,7 +14,7 @@ var NickLabel = function NickLabel(_ref) {
|
|
|
14
14
|
size: 20
|
|
15
15
|
}, innerName), /*#__PURE__*/React.createElement("div", {
|
|
16
16
|
className: "ald-member-picker-nick-label-name",
|
|
17
|
-
title: "".concat(name, "(").concat(account, ")")
|
|
17
|
+
title: account ? "".concat(name, "(").concat(account, ")") : "".concat(name)
|
|
18
18
|
}, innerName));
|
|
19
19
|
};
|
|
20
20
|
export default /*#__PURE__*/memo(NickLabel);
|
|
@@ -96,7 +96,10 @@ export var PanelWrapper = function PanelWrapper(_ref) {
|
|
|
96
96
|
} else {
|
|
97
97
|
var id = [];
|
|
98
98
|
if (!value) return;
|
|
99
|
-
if (Array.isArray(value) && value.length === 0)
|
|
99
|
+
if (Array.isArray(value) && value.length === 0) {
|
|
100
|
+
setSelectedUserList([]);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
100
103
|
if (!Array.isArray(value)) {
|
|
101
104
|
id = [value];
|
|
102
105
|
} else {
|
|
@@ -10,5 +10,5 @@ interface IProps {
|
|
|
10
10
|
onSearchValueChange?: (value: string) => void;
|
|
11
11
|
width: number;
|
|
12
12
|
}
|
|
13
|
-
declare const UserGroupSelection: ({ className, userGroupList, multiple, onChange, selectedUsersGroup: selectedUsersGroups,
|
|
13
|
+
declare const UserGroupSelection: ({ className, userGroupList, multiple, onChange, selectedUsersGroup: selectedUsersGroups, loading, width, }: IProps) => React.JSX.Element;
|
|
14
14
|
export default UserGroupSelection;
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
4
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
5
1
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
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."); }
|
|
7
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); }
|
|
@@ -11,9 +7,9 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
11
7
|
import { Breadcrumb } from 'antd';
|
|
12
8
|
import classNames from 'classnames';
|
|
13
9
|
import _ from 'lodash';
|
|
14
|
-
import React, {
|
|
10
|
+
import React, { useState } from 'react';
|
|
15
11
|
import Empty from "../../Empty";
|
|
16
|
-
import { SearchLine } from "../../Icon";
|
|
12
|
+
import { ChevronLeftLine, SearchLine } from "../../Icon";
|
|
17
13
|
import Input from "../../Input";
|
|
18
14
|
import ScrollArea from "../../ScrollArea";
|
|
19
15
|
import Spin from "../../Spin";
|
|
@@ -26,7 +22,6 @@ var UserGroupSelection = function UserGroupSelection(_ref) {
|
|
|
26
22
|
multiple = _ref.multiple,
|
|
27
23
|
_onChange = _ref.onChange,
|
|
28
24
|
selectedUsersGroups = _ref.selectedUsersGroup,
|
|
29
|
-
onSearchValueChange = _ref.onSearchValueChange,
|
|
30
25
|
loading = _ref.loading,
|
|
31
26
|
width = _ref.width;
|
|
32
27
|
var _useState = useState(''),
|
|
@@ -37,14 +32,28 @@ var UserGroupSelection = function UserGroupSelection(_ref) {
|
|
|
37
32
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
38
33
|
groupPath = _useState4[0],
|
|
39
34
|
setGroupPath = _useState4[1];
|
|
40
|
-
var
|
|
41
|
-
useEffect(function () {
|
|
42
|
-
onSearchValueChange === null || onSearchValueChange === void 0 ? void 0 : onSearchValueChange(deferredSearchValue);
|
|
43
|
-
}, [deferredSearchValue, onSearchValueChange]);
|
|
44
|
-
var userGroupListInLevel = userGroupList.filter(function (userGroup) {
|
|
35
|
+
var filterUserList = (!!searchKey ? userGroupList : userGroupList.filter(function (userGroup) {
|
|
45
36
|
var _$last;
|
|
46
37
|
if (groupPath.length === 0) return !userGroup.parentId;else return userGroup.parentId === ((_$last = _.last(groupPath)) === null || _$last === void 0 ? void 0 : _$last.groupId);
|
|
38
|
+
})).filter(function (group) {
|
|
39
|
+
return group.name.toLowerCase().includes(searchKey.trim().toLowerCase());
|
|
47
40
|
});
|
|
41
|
+
var getPath = function getPath(group) {
|
|
42
|
+
var thisGroup = group;
|
|
43
|
+
var result = [_.cloneDeep(thisGroup)];
|
|
44
|
+
while (thisGroup.parentId) {
|
|
45
|
+
var tempGroup = userGroupList.find(
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-loop-func
|
|
47
|
+
function (userGroup) {
|
|
48
|
+
return userGroup.groupId === thisGroup.parentId;
|
|
49
|
+
});
|
|
50
|
+
if (tempGroup) {
|
|
51
|
+
result.push(tempGroup);
|
|
52
|
+
thisGroup = tempGroup;
|
|
53
|
+
} else break;
|
|
54
|
+
}
|
|
55
|
+
return result.reverse();
|
|
56
|
+
};
|
|
48
57
|
return /*#__PURE__*/React.createElement("div", {
|
|
49
58
|
className: classNames(className, 'ald-member-picker-member-list-wrap')
|
|
50
59
|
}, /*#__PURE__*/React.createElement(Input, {
|
|
@@ -53,6 +62,7 @@ var UserGroupSelection = function UserGroupSelection(_ref) {
|
|
|
53
62
|
}),
|
|
54
63
|
className: 'ald-member-picker-search-input',
|
|
55
64
|
autoFocus: true,
|
|
65
|
+
value: searchKey,
|
|
56
66
|
onChange: function onChange(e) {
|
|
57
67
|
setSearchKey(e.target.value);
|
|
58
68
|
}
|
|
@@ -62,13 +72,21 @@ var UserGroupSelection = function UserGroupSelection(_ref) {
|
|
|
62
72
|
image: Empty.PRESENTED_IMAGE_SEARCH,
|
|
63
73
|
className: "ald-member-picker-member-list-empty"
|
|
64
74
|
}), groupPath.length !== 0 && /*#__PURE__*/React.createElement(ScrollArea, {
|
|
65
|
-
className: "ald-member-picker-
|
|
66
|
-
}, /*#__PURE__*/React.createElement(Breadcrumb,
|
|
75
|
+
className: "ald-member-picker-breadcrumb-scroll"
|
|
76
|
+
}, /*#__PURE__*/React.createElement(Breadcrumb, {
|
|
77
|
+
className: "ald-member-picker-breadcrumb"
|
|
78
|
+
}, /*#__PURE__*/React.createElement(Breadcrumb.Item, {
|
|
79
|
+
className: "ald-member-picker-breadcrumb-item",
|
|
67
80
|
onClick: function onClick() {
|
|
68
81
|
setGroupPath([]);
|
|
69
82
|
}
|
|
70
|
-
}, "
|
|
83
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
84
|
+
className: "ald-member-picker-breadcrumb-item-inner"
|
|
85
|
+
}, /*#__PURE__*/React.createElement(ChevronLeftLine, {
|
|
86
|
+
size: 16
|
|
87
|
+
}), "\u7528\u6237\u7EC4")), groupPath.map(function (group) {
|
|
71
88
|
return /*#__PURE__*/React.createElement(Breadcrumb.Item, {
|
|
89
|
+
className: "ald-member-picker-breadcrumb-item",
|
|
72
90
|
key: group.groupId,
|
|
73
91
|
onClick: function onClick() {
|
|
74
92
|
setGroupPath(function (groups) {
|
|
@@ -80,11 +98,14 @@ var UserGroupSelection = function UserGroupSelection(_ref) {
|
|
|
80
98
|
});
|
|
81
99
|
});
|
|
82
100
|
}
|
|
83
|
-
},
|
|
101
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
102
|
+
className: "ald-member-picker-breadcrumb-item-inner"
|
|
103
|
+
}, group.name));
|
|
84
104
|
}))), /*#__PURE__*/React.createElement(Spin, {
|
|
85
105
|
tip: "Loading",
|
|
86
106
|
spinning: loading,
|
|
87
|
-
size: "small"
|
|
107
|
+
size: "small",
|
|
108
|
+
className: "ald-member-picker-user-list"
|
|
88
109
|
}, /*#__PURE__*/React.createElement(ScrollArea, {
|
|
89
110
|
className: classNames('ald-member-picker-member-list', {
|
|
90
111
|
'ald-member-picker-member-list-null': userGroupList.length === 0 && !loading
|
|
@@ -96,7 +117,7 @@ var UserGroupSelection = function UserGroupSelection(_ref) {
|
|
|
96
117
|
width: width,
|
|
97
118
|
overflow: 'hidden'
|
|
98
119
|
}
|
|
99
|
-
},
|
|
120
|
+
}, filterUserList.map(function (userGroup) {
|
|
100
121
|
var isSelected = selectedUsersGroups.some(function (selectUserGroup) {
|
|
101
122
|
return selectUserGroup.groupId === userGroup.groupId;
|
|
102
123
|
});
|
|
@@ -113,9 +134,8 @@ var UserGroupSelection = function UserGroupSelection(_ref) {
|
|
|
113
134
|
return group.parentId === userGroup.groupId;
|
|
114
135
|
}),
|
|
115
136
|
onNextLevel: function onNextLevel(userGroup) {
|
|
116
|
-
setGroupPath(
|
|
117
|
-
|
|
118
|
-
});
|
|
137
|
+
setGroupPath(getPath(userGroup));
|
|
138
|
+
setSearchKey('');
|
|
119
139
|
}
|
|
120
140
|
}) : /*#__PURE__*/React.createElement(SingleOption, {
|
|
121
141
|
key: userGroup.groupId,
|
|
@@ -105,12 +105,15 @@ var Component = function Component(_ref) {
|
|
|
105
105
|
loading = _useRequest.loading,
|
|
106
106
|
run = _useRequest.run;
|
|
107
107
|
var totalUserList = useMemo(function () {
|
|
108
|
-
var totalUsers = searchUserList.concat(selectedUserList)
|
|
108
|
+
var totalUsers = searchUserList.concat(selectedUserList.filter(function (item) {
|
|
109
|
+
var name = (item.type === EUserType.USER ? item.nickname : item.name) || '';
|
|
110
|
+
return name.toUpperCase().includes(searchString.trim().toUpperCase());
|
|
111
|
+
}));
|
|
109
112
|
return _.uniqBy(totalUsers, function (data) {
|
|
110
113
|
if (data.type === EUserType.USER) return data.userId;
|
|
111
114
|
return data.groupId;
|
|
112
115
|
});
|
|
113
|
-
}, [searchUserList, selectedUserList]);
|
|
116
|
+
}, [searchString, searchUserList, selectedUserList]);
|
|
114
117
|
useEffect(function () {
|
|
115
118
|
if (!dropdownOpen) return;
|
|
116
119
|
run();
|
|
@@ -123,7 +126,10 @@ var Component = function Component(_ref) {
|
|
|
123
126
|
} else {
|
|
124
127
|
var id = [];
|
|
125
128
|
if (!value) return;
|
|
126
|
-
if (Array.isArray(value) && value.length === 0)
|
|
129
|
+
if (Array.isArray(value) && value.length === 0) {
|
|
130
|
+
setSelectedUserList([]);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
127
133
|
if (!Array.isArray(value)) {
|
|
128
134
|
id = [value];
|
|
129
135
|
} else {
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
@import '../../message/style/index.less';
|
|
8
8
|
@import '../../Spin/style/index.less';
|
|
9
9
|
|
|
10
|
+
@btnWidth: 30px;
|
|
11
|
+
|
|
10
12
|
.ald-member-picker-wrapper {
|
|
11
13
|
box-sizing: border-box;
|
|
12
14
|
border: 1px solid var(--colors-gray-400, #dbdbdb);
|
|
@@ -36,6 +38,9 @@
|
|
|
36
38
|
|
|
37
39
|
.ald-member-picker-member-list-wrap {
|
|
38
40
|
&.ald-member-picker-member-selection-multiple {
|
|
41
|
+
height: 100%;
|
|
42
|
+
display: flex;
|
|
43
|
+
flex-direction: column;
|
|
39
44
|
width: 100%;
|
|
40
45
|
}
|
|
41
46
|
|
|
@@ -47,27 +52,31 @@
|
|
|
47
52
|
border: none;
|
|
48
53
|
border-bottom: 1px solid var(--colors-gray-300, #e8e8e8);
|
|
49
54
|
border-radius: 0;
|
|
55
|
+
flex: 0 0 32px;
|
|
50
56
|
|
|
51
57
|
&.ant-input-affix-wrapper-focused {
|
|
52
58
|
border-color: #dbdbdb;
|
|
53
59
|
}
|
|
54
60
|
}
|
|
55
61
|
|
|
62
|
+
.ald-member-picker-breadcrumb-scroll {
|
|
63
|
+
flex: 0 0 40px;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.ald-member-picker-user-list {
|
|
67
|
+
flex: 1;
|
|
68
|
+
}
|
|
69
|
+
|
|
56
70
|
.ald-member-picker-member-list-empty {
|
|
57
71
|
min-height: 180px;
|
|
58
72
|
}
|
|
59
73
|
|
|
60
74
|
.ald-member-picker-member-list {
|
|
61
|
-
height:
|
|
62
|
-
min-height: 180px;
|
|
75
|
+
height: 200px;
|
|
63
76
|
|
|
64
77
|
&.ald-member-picker-member-list-null {
|
|
65
78
|
display: none;
|
|
66
79
|
}
|
|
67
|
-
|
|
68
|
-
.ald-member-picker-member-scroll {
|
|
69
|
-
height: 240px;
|
|
70
|
-
}
|
|
71
80
|
}
|
|
72
81
|
}
|
|
73
82
|
|
|
@@ -137,6 +146,7 @@
|
|
|
137
146
|
justify-content: space-between;
|
|
138
147
|
|
|
139
148
|
.ald-member-picker-label {
|
|
149
|
+
flex: 1;
|
|
140
150
|
display: flex;
|
|
141
151
|
gap: 4px;
|
|
142
152
|
}
|
|
@@ -236,14 +246,56 @@
|
|
|
236
246
|
white-space: nowrap;
|
|
237
247
|
text-overflow: ellipsis;
|
|
238
248
|
overflow: hidden;
|
|
249
|
+
max-width: 140px;
|
|
239
250
|
}
|
|
240
251
|
}
|
|
241
252
|
|
|
242
253
|
.ald-member-tabs {
|
|
243
254
|
background-color: #fff;
|
|
244
255
|
height: 100%;
|
|
256
|
+
width: 100%;
|
|
245
257
|
|
|
246
258
|
.ant-tabs-nav {
|
|
247
259
|
margin-bottom: 0 !important;
|
|
248
260
|
}
|
|
249
261
|
}
|
|
262
|
+
|
|
263
|
+
.ald-member-picker-btn {
|
|
264
|
+
flex: 0 0 @btnWidth;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
.ald-member-picker-breadcrumb-item {
|
|
268
|
+
cursor: pointer;
|
|
269
|
+
overflow-x: hidden;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.ant-breadcrumb.ald-member-picker-breadcrumb[class] {
|
|
273
|
+
height: 40px;
|
|
274
|
+
padding: 0 8px;
|
|
275
|
+
line-height: 40px;
|
|
276
|
+
border-bottom: 1px solid #e8e8e8;
|
|
277
|
+
|
|
278
|
+
&.ant-breadcrumb ol {
|
|
279
|
+
display: flex;
|
|
280
|
+
flex-wrap: nowrap;
|
|
281
|
+
height: 40px;
|
|
282
|
+
white-space: nowrap;
|
|
283
|
+
|
|
284
|
+
& li {
|
|
285
|
+
display: inline-block;
|
|
286
|
+
height: 40px;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
.ald-member-picker-header-wrapper {
|
|
292
|
+
width: 100%;
|
|
293
|
+
height: 100%;
|
|
294
|
+
display: flex;
|
|
295
|
+
gap: 2px;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.ald-member-picker-breadcrumb-item-inner {
|
|
299
|
+
display: flex;
|
|
300
|
+
align-items: center;
|
|
301
|
+
}
|
package/dist/Switch/index.js
CHANGED
|
@@ -32,10 +32,10 @@ var Switch = function Switch(_ref) {
|
|
|
32
32
|
var disabled = React.useContext(DisabledContext);
|
|
33
33
|
var mergedDisabled = customDisabled !== null && customDisabled !== void 0 ? customDisabled : disabled;
|
|
34
34
|
var onChangeCB = function onChangeCB(isChecked, event) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
onChange(isChecked, event);
|
|
35
|
+
if (checked === undefined) {
|
|
36
|
+
setUserChecked(isChecked);
|
|
38
37
|
}
|
|
38
|
+
if (typeof onChange === 'function') onChange(isChecked, event);
|
|
39
39
|
};
|
|
40
40
|
var currentDisabled = loading ? true : mergedDisabled;
|
|
41
41
|
useEffect(function () {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ITableProps } from '../../types';
|
|
3
|
+
export default function TablePagination<TDataItem extends object>(props: IProps<TDataItem>): React.JSX.Element | undefined;
|
|
4
|
+
interface IProps<TDataItem extends object> {
|
|
5
|
+
pagination?: ITableProps<TDataItem>['pagination'];
|
|
6
|
+
scroll?: ITableProps<TDataItem>['scroll'];
|
|
7
|
+
scrollToFirstRow: () => void;
|
|
8
|
+
}
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
import React, { useCallback } from 'react';
|
|
3
|
+
import { Pagination } from "../../..";
|
|
4
|
+
import { prefixCls } from "../../helper";
|
|
5
|
+
export default function TablePagination(props) {
|
|
6
|
+
var pagination = props.pagination,
|
|
7
|
+
_props$scroll = props.scroll,
|
|
8
|
+
scroll = _props$scroll === void 0 ? {} : _props$scroll,
|
|
9
|
+
scrollToFirstRow = props.scrollToFirstRow;
|
|
10
|
+
var onChangePage = useCallback(function (page) {
|
|
11
|
+
var _ref = pagination || {},
|
|
12
|
+
_ref$onChange = _ref.onChange,
|
|
13
|
+
onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange;
|
|
14
|
+
var _scroll$scrollToFirst = scroll.scrollToFirstRowOnChange,
|
|
15
|
+
scrollToFirstRowOnChange = _scroll$scrollToFirst === void 0 ? true : _scroll$scrollToFirst;
|
|
16
|
+
if (scrollToFirstRowOnChange) {
|
|
17
|
+
scrollToFirstRow();
|
|
18
|
+
}
|
|
19
|
+
onChange(page);
|
|
20
|
+
}, [scrollToFirstRow, scroll, pagination]);
|
|
21
|
+
return pagination && /*#__PURE__*/React.createElement("div", {
|
|
22
|
+
className: prefixCls('pagination')
|
|
23
|
+
}, /*#__PURE__*/React.createElement(Pagination, _extends({}, pagination, {
|
|
24
|
+
onChange: onChangePage
|
|
25
|
+
})));
|
|
26
|
+
}
|
package/dist/Table/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ITableProps } from './types';
|
|
3
|
-
declare
|
|
4
|
-
export default
|
|
2
|
+
import { ITableProps, ITableRef } from './types';
|
|
3
|
+
declare const _default: React.ForwardRefExoticComponent<ITableProps<object> & React.RefAttributes<ITableRef>>;
|
|
4
|
+
export default _default;
|
package/dist/Table/index.js
CHANGED
|
@@ -12,13 +12,14 @@ import { flexRender, getCoreRowModel, useReactTable } from '@tanstack/react-tabl
|
|
|
12
12
|
import classnames from 'classnames';
|
|
13
13
|
import _ from 'lodash';
|
|
14
14
|
import ResizeObserver from 'rc-resize-observer';
|
|
15
|
-
import React, { useMemo, useState } from 'react';
|
|
16
|
-
import { Empty,
|
|
15
|
+
import React, { forwardRef, useCallback, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
16
|
+
import { Empty, ScrollArea, Spin } from '..';
|
|
17
|
+
import Pagination from "./components/Pagination";
|
|
17
18
|
import { getTableColumns, prefixCls } from "./helper";
|
|
18
19
|
import useScrollX from "./hooks/useScroll";
|
|
19
20
|
// 32 行高 + 1 底线高度
|
|
20
21
|
var HEADER_HEIGHT = 33;
|
|
21
|
-
function Table(props) {
|
|
22
|
+
function Table(props, ref) {
|
|
22
23
|
var _classnames;
|
|
23
24
|
var columns = props.columns,
|
|
24
25
|
data = props.data,
|
|
@@ -38,6 +39,7 @@ function Table(props) {
|
|
|
38
39
|
_useState2 = _slicedToArray(_useState, 2),
|
|
39
40
|
totalSize = _useState2[0],
|
|
40
41
|
setTotalSize = _useState2[1];
|
|
42
|
+
var tableBodyRef = useRef(null);
|
|
41
43
|
var y = scroll.y;
|
|
42
44
|
var _useScrollX = useScrollX({
|
|
43
45
|
totalSize: totalSize,
|
|
@@ -46,6 +48,17 @@ function Table(props) {
|
|
|
46
48
|
realWidth = _useScrollX.realWidth,
|
|
47
49
|
onBodyScroll = _useScrollX.onBodyScroll,
|
|
48
50
|
headerRef = _useScrollX.headerRef;
|
|
51
|
+
var scrollToFirstRow = useCallback(function () {
|
|
52
|
+
if (!tableBodyRef.current) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
tableBodyRef.current.scrollTop = 0;
|
|
56
|
+
}, []);
|
|
57
|
+
useImperativeHandle(ref, function () {
|
|
58
|
+
return {
|
|
59
|
+
scrollToFirstRow: scrollToFirstRow
|
|
60
|
+
};
|
|
61
|
+
});
|
|
49
62
|
var tableColumns = useMemo(function () {
|
|
50
63
|
if (!totalSize || !realWidth) {
|
|
51
64
|
return [];
|
|
@@ -146,11 +159,13 @@ function Table(props) {
|
|
|
146
159
|
},
|
|
147
160
|
className: prefixCls('body-scroll')
|
|
148
161
|
}, /*#__PURE__*/React.createElement(ScrollArea, {
|
|
149
|
-
onViewportScroll: onBodyScroll
|
|
162
|
+
onViewportScroll: onBodyScroll,
|
|
163
|
+
ref: tableBodyRef
|
|
150
164
|
}, bodyContent))) : /*#__PURE__*/React.createElement("div", {
|
|
151
165
|
className: prefixCls('content')
|
|
152
166
|
}, headerContent, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(ScrollArea, {
|
|
153
|
-
onViewportScroll: onBodyScroll
|
|
167
|
+
onViewportScroll: onBodyScroll,
|
|
168
|
+
ref: tableBodyRef
|
|
154
169
|
}, bodyContent)));
|
|
155
170
|
var tableStyle = {};
|
|
156
171
|
if (y) {
|
|
@@ -170,8 +185,10 @@ function Table(props) {
|
|
|
170
185
|
}
|
|
171
186
|
}, /*#__PURE__*/React.createElement("div", {
|
|
172
187
|
className: classnames(prefixCls('main'), _defineProperty({}, prefixCls('overflow-hidden'), !!y))
|
|
173
|
-
}, tableContent)),
|
|
174
|
-
|
|
175
|
-
|
|
188
|
+
}, tableContent)), /*#__PURE__*/React.createElement(Pagination, {
|
|
189
|
+
pagination: pagination,
|
|
190
|
+
scroll: scroll,
|
|
191
|
+
scrollToFirstRow: scrollToFirstRow
|
|
192
|
+
}));
|
|
176
193
|
}
|
|
177
|
-
export default Table;
|
|
194
|
+
export default /*#__PURE__*/forwardRef(Table);
|
package/dist/Table/types.d.ts
CHANGED
|
@@ -14,9 +14,13 @@ export interface ITableProps<TDataItem extends object> {
|
|
|
14
14
|
empty?: React.ReactNode;
|
|
15
15
|
rowClassName?: (record: TDataItem, index: number) => string;
|
|
16
16
|
}
|
|
17
|
+
export interface ITableRef {
|
|
18
|
+
scrollToFirstRow: () => void;
|
|
19
|
+
}
|
|
17
20
|
export interface IScroll {
|
|
18
21
|
x?: number | string;
|
|
19
22
|
y?: number | string;
|
|
23
|
+
scrollToFirstRowOnChange?: boolean;
|
|
20
24
|
}
|
|
21
25
|
export interface ITableColumn<TDataItem = unknown> {
|
|
22
26
|
title: string | React.ReactNode;
|
package/dist/index.d.ts
CHANGED
|
@@ -78,7 +78,7 @@ export type { IStepProps as StepProps, IStepsProps as StepsProps, } from './Step
|
|
|
78
78
|
export { default as Switch } from './Switch';
|
|
79
79
|
export type { ISwitchProps as SwitchProps } from './Switch';
|
|
80
80
|
export { default as Table } from './Table';
|
|
81
|
-
export type { ITableColumn, ITableProps } from './Table/types';
|
|
81
|
+
export type { ITableColumn, ITableProps, ITableRef } from './Table/types';
|
|
82
82
|
export { default as Tabs } from './Tabs';
|
|
83
83
|
export type { ITabsProps as TabsProps, TabsSize } from './Tabs';
|
|
84
84
|
export { default as Tag } from './Tag';
|