@aloudata/aloudata-design 2.12.4 → 2.12.5
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 +1 -1
- package/dist/MemberPicker/components/MultipleOption.js +1 -1
- package/dist/MemberPicker/components/NickLabel.d.ts +1 -1
- package/dist/MemberPicker/components/NickLabel.js +2 -2
- package/dist/MemberPicker/components/Panel.d.ts +1 -1
- package/dist/MemberPicker/components/Panel.js +9 -9
- package/dist/MemberPicker/components/PanelWrapper.d.ts +2 -2
- package/dist/MemberPicker/components/PanelWrapper.js +3 -16
- package/dist/MemberPicker/components/SelectedMemberTags.js +1 -1
- package/dist/MemberPicker/components/SingleOption.js +1 -1
- package/dist/MemberPicker/utils/getUsersWithUserId.d.ts +1 -1
- package/dist/MemberPicker/utils/getUsersWithUserId.js +2 -2
- package/dist/MemberPicker/utils/index.d.ts +1 -1
- package/dist/MemberPicker/utils/index.js +1 -1
- package/dist/Table/helper.d.ts +6 -8
- package/dist/Table/helper.js +14 -13
- package/dist/Table/hooks/useFixed.d.ts +2 -1
- package/dist/Table/hooks/useFixed.js +4 -4
- package/dist/Table/hooks/useRowSelection.js +3 -1
- package/dist/Table/hooks/useScroll.d.ts +3 -2
- package/dist/Table/hooks/useScroll.js +23 -16
- package/dist/Table/index.js +25 -19
- package/dist/Table/style/index.less +32 -32
- package/dist/Table/tests/helper.d.ts +14 -0
- package/dist/Table/tests/helper.js +41 -0
- package/dist/Table/types.d.ts +1 -0
- package/dist/ald.min.css +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -0
- package/package.json +8 -3
package/dist/Table/index.js
CHANGED
|
@@ -14,7 +14,7 @@ import { flexRender, getCoreRowModel, useReactTable } from '@tanstack/react-tabl
|
|
|
14
14
|
import classnames from 'classnames';
|
|
15
15
|
import _ from 'lodash';
|
|
16
16
|
import ResizeObserver from 'rc-resize-observer';
|
|
17
|
-
import React, { forwardRef, useCallback, useImperativeHandle, useMemo, useState } from 'react';
|
|
17
|
+
import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useState } from 'react';
|
|
18
18
|
import { Empty, Spin } from '..';
|
|
19
19
|
import ExpandCell from "./components/ExpandCell";
|
|
20
20
|
import Footer from "./components/Footer";
|
|
@@ -54,13 +54,14 @@ function Table(props, ref) {
|
|
|
54
54
|
totalSize: totalSize,
|
|
55
55
|
scroll: scroll
|
|
56
56
|
}),
|
|
57
|
-
|
|
57
|
+
containerWidth = _useScroll.containerWidth,
|
|
58
58
|
onBodyScroll = _useScroll.onBodyScroll,
|
|
59
59
|
headerRef = _useScroll.headerRef,
|
|
60
60
|
bodyRef = _useScroll.bodyRef,
|
|
61
61
|
isPingLeft = _useScroll.isPingLeft,
|
|
62
62
|
isPingRight = _useScroll.isPingRight,
|
|
63
|
-
scrollbarWidth = _useScroll.scrollbarWidth
|
|
63
|
+
scrollbarWidth = _useScroll.scrollbarWidth,
|
|
64
|
+
changeIsPing = _useScroll.changeIsPing;
|
|
64
65
|
var scrollToFirstRow = useCallback(function () {
|
|
65
66
|
if (!bodyRef.current) {
|
|
66
67
|
return;
|
|
@@ -80,21 +81,13 @@ function Table(props, ref) {
|
|
|
80
81
|
var expandableConfig = getExpandableConfig(expandable);
|
|
81
82
|
var rowSelectionInfo = useRowSelection(props);
|
|
82
83
|
var tableColumns = useMemo(function () {
|
|
83
|
-
if (!totalSize || !realWidth) {
|
|
84
|
-
return [];
|
|
85
|
-
}
|
|
86
84
|
return getTableColumns({
|
|
87
85
|
columns: rowSelectionInfo.columns,
|
|
88
|
-
|
|
86
|
+
containerWidth: containerWidth || 0,
|
|
89
87
|
onError: onError,
|
|
90
88
|
onSort: onSort
|
|
91
89
|
});
|
|
92
|
-
}, [
|
|
93
|
-
var getColumnFixedInfo = useFixed({
|
|
94
|
-
tableColumns: tableColumns,
|
|
95
|
-
y: y,
|
|
96
|
-
scrollbarWidth: scrollbarWidth
|
|
97
|
-
});
|
|
90
|
+
}, [containerWidth, onError, onSort, rowSelectionInfo.columns]);
|
|
98
91
|
var tableInstance = useReactTable({
|
|
99
92
|
columns: tableColumns,
|
|
100
93
|
// 排除掉被折叠的行
|
|
@@ -105,9 +98,18 @@ function Table(props, ref) {
|
|
|
105
98
|
},
|
|
106
99
|
columnResizeMode: 'onChange'
|
|
107
100
|
});
|
|
101
|
+
var headerGroups = tableInstance.getHeaderGroups();
|
|
102
|
+
var columnWidths = headerGroups[0].headers.map(function (header) {
|
|
103
|
+
return header.getSize();
|
|
104
|
+
});
|
|
105
|
+
var getColumnFixedInfo = useFixed({
|
|
106
|
+
columnWidths: columnWidths,
|
|
107
|
+
tableColumns: tableColumns,
|
|
108
|
+
y: y,
|
|
109
|
+
scrollbarWidth: scrollbarWidth
|
|
110
|
+
});
|
|
108
111
|
|
|
109
112
|
// 渲染 header
|
|
110
|
-
var headerGroups = tableInstance.getHeaderGroups();
|
|
111
113
|
var _tableInstance$getRow = tableInstance.getRowModel(),
|
|
112
114
|
rows = _tableInstance$getRow.rows;
|
|
113
115
|
var isStickyWork = !!sticky && y === undefined;
|
|
@@ -115,8 +117,13 @@ function Table(props, ref) {
|
|
|
115
117
|
if (isStickyWork && _.get(sticky, 'offsetHeader')) {
|
|
116
118
|
headerStyle.top = _.get(sticky, 'offsetHeader', 0);
|
|
117
119
|
}
|
|
120
|
+
var totalColumnsWidth = _.sum(columnWidths);
|
|
121
|
+
useEffect(function () {
|
|
122
|
+
// 总列宽改变时,重新计算是否需要显示固定列的阴影
|
|
123
|
+
changeIsPing();
|
|
124
|
+
}, [changeIsPing, totalColumnsWidth]);
|
|
118
125
|
var headerContent = /*#__PURE__*/React.createElement("div", {
|
|
119
|
-
className: classnames(prefixCls('header'), (_classnames = {}, _defineProperty(_classnames, prefixCls('overflow-x'), true), _defineProperty(_classnames, prefixCls('sticky'), isStickyWork), _classnames)),
|
|
126
|
+
className: classnames(prefixCls('header'), (_classnames = {}, _defineProperty(_classnames, prefixCls('overflow-x'), true), _defineProperty(_classnames, prefixCls('sticky'), isStickyWork), _defineProperty(_classnames, prefixCls('resizing'), tableInstance.getState().columnSizingInfo.isResizingColumn), _classnames)),
|
|
120
127
|
ref: headerRef,
|
|
121
128
|
style: headerStyle
|
|
122
129
|
}, _.map(headerGroups, function (headerGroup) {
|
|
@@ -124,10 +131,9 @@ function Table(props, ref) {
|
|
|
124
131
|
className: prefixCls('tr'),
|
|
125
132
|
key: headerGroup.id,
|
|
126
133
|
style: {
|
|
127
|
-
width:
|
|
134
|
+
width: totalColumnsWidth
|
|
128
135
|
}
|
|
129
136
|
}, _.map(headerGroup.headers, function (header, index) {
|
|
130
|
-
var _classnames2;
|
|
131
137
|
// 选择行的列不能拖动宽度
|
|
132
138
|
var showResizer = columnSizing && !(!!rowSelectionInfo.isRowSelectionEnabled && index === 0);
|
|
133
139
|
var _getColumnFixedInfo = getColumnFixedInfo(index, true),
|
|
@@ -142,7 +148,7 @@ function Table(props, ref) {
|
|
|
142
148
|
}, flexRender(header.column.columnDef.header, header.getContext()), showResizer && /*#__PURE__*/React.createElement("div", {
|
|
143
149
|
onMouseDown: header.getResizeHandler(),
|
|
144
150
|
onTouchStart: header.getResizeHandler(),
|
|
145
|
-
className: classnames(prefixCls('resizer'), (
|
|
151
|
+
className: classnames(prefixCls('resizer'), _defineProperty({}, prefixCls('self-resizing'), header.column.getIsResizing()))
|
|
146
152
|
}));
|
|
147
153
|
}), y !== undefined && /*#__PURE__*/React.createElement("div", {
|
|
148
154
|
className: prefixCls('header-scroll-placeholder'),
|
|
@@ -177,7 +183,7 @@ function Table(props, ref) {
|
|
|
177
183
|
var bodyContent = /*#__PURE__*/React.createElement("div", {
|
|
178
184
|
className: prefixCls('body'),
|
|
179
185
|
style: {
|
|
180
|
-
width:
|
|
186
|
+
width: totalColumnsWidth
|
|
181
187
|
}
|
|
182
188
|
}, isEmpty ? /*#__PURE__*/React.createElement("div", {
|
|
183
189
|
style: {
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
@import '../../TextLink/style/index.less';
|
|
8
8
|
|
|
9
9
|
@header-height: 40px;
|
|
10
|
+
@fixed-z-index: 2;
|
|
10
11
|
|
|
11
12
|
.ald-table-container {
|
|
12
13
|
display: flex;
|
|
@@ -38,29 +39,8 @@
|
|
|
38
39
|
flex-direction: column;
|
|
39
40
|
border-spacing: 0;
|
|
40
41
|
|
|
41
|
-
.
|
|
42
|
-
|
|
43
|
-
top: 0;
|
|
44
|
-
left: 0;
|
|
45
|
-
width: 100%;
|
|
46
|
-
height: 300px;
|
|
47
|
-
max-height: 100%;
|
|
48
|
-
z-index: 2;
|
|
49
|
-
|
|
50
|
-
.spinner-mask {
|
|
51
|
-
opacity: 0;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.ald-table-spin-mask {
|
|
56
|
-
position: absolute;
|
|
57
|
-
top: 0;
|
|
58
|
-
left: 0;
|
|
59
|
-
width: 100%;
|
|
60
|
-
height: 100%;
|
|
61
|
-
background: #fff;
|
|
62
|
-
opacity: 0.4;
|
|
63
|
-
z-index: 1;
|
|
42
|
+
.spinner-mask {
|
|
43
|
+
z-index: @fixed-z-index + 1;
|
|
64
44
|
}
|
|
65
45
|
}
|
|
66
46
|
|
|
@@ -73,18 +53,27 @@
|
|
|
73
53
|
cursor: col-resize;
|
|
74
54
|
user-select: none;
|
|
75
55
|
touch-action: none;
|
|
56
|
+
background: var(--alias-colors-bg-skeleton-strong, #f3f4f6);
|
|
76
57
|
|
|
77
58
|
&::after {
|
|
59
|
+
position: absolute;
|
|
78
60
|
content: '';
|
|
79
61
|
display: block;
|
|
80
|
-
height:
|
|
62
|
+
height: 16px;
|
|
81
63
|
width: 1px;
|
|
82
|
-
position: absolute;
|
|
83
|
-
top: 50%;
|
|
84
|
-
right: -1px;
|
|
85
64
|
z-index: 1;
|
|
86
|
-
|
|
87
|
-
|
|
65
|
+
top: 50%;
|
|
66
|
+
transform: translate(4px, -50%);
|
|
67
|
+
background: var(--alias-colors-border-strong, #d1d5db);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
&.ald-table-self-resizing {
|
|
71
|
+
width: 2px;
|
|
72
|
+
background-color: #126fdd;
|
|
73
|
+
|
|
74
|
+
&::after {
|
|
75
|
+
display: none;
|
|
76
|
+
}
|
|
88
77
|
}
|
|
89
78
|
}
|
|
90
79
|
|
|
@@ -105,7 +94,7 @@
|
|
|
105
94
|
&.ald-table-fixed-left,
|
|
106
95
|
&.ald-table-fixed-right {
|
|
107
96
|
position: sticky;
|
|
108
|
-
z-index:
|
|
97
|
+
z-index: @fixed-z-index;
|
|
109
98
|
}
|
|
110
99
|
}
|
|
111
100
|
|
|
@@ -174,6 +163,7 @@
|
|
|
174
163
|
padding: @td-padding-size;
|
|
175
164
|
font-size: 12px;
|
|
176
165
|
overflow: hidden;
|
|
166
|
+
white-space: nowrap;
|
|
177
167
|
height: @header-height;
|
|
178
168
|
display: flex;
|
|
179
169
|
align-items: center;
|
|
@@ -320,7 +310,11 @@
|
|
|
320
310
|
}
|
|
321
311
|
|
|
322
312
|
.ald-table-header {
|
|
323
|
-
background
|
|
313
|
+
background: var(--alias-colors-bg-skeleton-strong, #f3f4f6);
|
|
314
|
+
|
|
315
|
+
&.ald-table-resizing {
|
|
316
|
+
cursor: col-resize;
|
|
317
|
+
}
|
|
324
318
|
}
|
|
325
319
|
|
|
326
320
|
.ald-table-header-scroll-placeholder {
|
|
@@ -362,7 +356,13 @@
|
|
|
362
356
|
align-items: center;
|
|
363
357
|
width: 100%;
|
|
364
358
|
height: 100%;
|
|
365
|
-
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
.ald-table-row-selection-all-header-wrap {
|
|
362
|
+
padding: 0 16px;
|
|
363
|
+
display: flex;
|
|
364
|
+
align-items: center;
|
|
365
|
+
height: 100%;
|
|
366
366
|
}
|
|
367
367
|
|
|
368
368
|
/** Footer **/
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare function getTableProps(): {
|
|
2
|
+
columns: import("../types").ITableColumn<object>[];
|
|
3
|
+
data: {
|
|
4
|
+
id: string;
|
|
5
|
+
firstName: string;
|
|
6
|
+
lastName: string;
|
|
7
|
+
date: string;
|
|
8
|
+
description: string;
|
|
9
|
+
}[];
|
|
10
|
+
scroll: {
|
|
11
|
+
x: string;
|
|
12
|
+
y: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
export function getTableProps() {
|
|
3
|
+
var columns = [{
|
|
4
|
+
title: 'First Name',
|
|
5
|
+
dataIndex: 'firstName',
|
|
6
|
+
width: '20%'
|
|
7
|
+
}, {
|
|
8
|
+
title: 'Last Name',
|
|
9
|
+
dataIndex: 'lastName',
|
|
10
|
+
width: '20%'
|
|
11
|
+
}, {
|
|
12
|
+
title: 'Date',
|
|
13
|
+
dataIndex: 'date',
|
|
14
|
+
width: '20%'
|
|
15
|
+
}, {
|
|
16
|
+
title: 'description',
|
|
17
|
+
dataIndex: 'description',
|
|
18
|
+
width: '30%'
|
|
19
|
+
}, {
|
|
20
|
+
title: 'Action',
|
|
21
|
+
dataIndex: '',
|
|
22
|
+
width: 60
|
|
23
|
+
}];
|
|
24
|
+
var data = _.map(_.range(10), function (i) {
|
|
25
|
+
return {
|
|
26
|
+
id: i.toString(),
|
|
27
|
+
firstName: "firstName_".concat(i),
|
|
28
|
+
lastName: "lastName_".concat(i),
|
|
29
|
+
date: "date_".concat(i),
|
|
30
|
+
description: "description_".concat(i)
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
return {
|
|
34
|
+
columns: columns,
|
|
35
|
+
data: data,
|
|
36
|
+
scroll: {
|
|
37
|
+
x: '100%',
|
|
38
|
+
y: '100%'
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
package/dist/Table/types.d.ts
CHANGED
|
@@ -41,6 +41,7 @@ export interface ITableColumn<TDataItem = unknown> {
|
|
|
41
41
|
title: string | React.ReactNode;
|
|
42
42
|
dataIndex?: string;
|
|
43
43
|
width?: number | string;
|
|
44
|
+
minWidth?: number;
|
|
44
45
|
render?: (text: any, record: TDataItem, rowIndex: number) => React.ReactNode;
|
|
45
46
|
ellipsis?: boolean;
|
|
46
47
|
noPadding?: boolean;
|