@aloudata/aloudata-design 2.10.1 → 2.10.3
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/Table/helper.d.ts +1 -1
- package/dist/Table/hooks/useExpandable.d.ts +1 -0
- package/dist/Table/hooks/useExpandable.js +41 -12
- package/dist/Table/index.js +35 -8
- package/dist/Table/style/index.less +16 -1
- package/dist/Table/types.d.ts +2 -0
- package/dist/ald.min.css +1 -1
- package/dist/message/index.d.ts +3 -3
- package/dist/message/index.js +19 -9
- package/dist/message/style/index.less +1 -1
- package/dist/notification/index.d.ts +5 -5
- package/dist/notification/index.js +89 -73
- package/dist/notification/style/index.less +1 -1
- package/package.json +1 -1
- /package/dist/style/components/{toastify.less → toastify.css} +0 -0
package/dist/Table/helper.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export declare function getTableColumns<TDataItem extends object>({ columns, tot
|
|
|
21
21
|
render?: ((text: any, record: TDataItem, rowIndex: number) => import("react").ReactNode) | undefined;
|
|
22
22
|
ellipsis?: boolean | undefined;
|
|
23
23
|
noPadding?: boolean | undefined;
|
|
24
|
-
align?: "
|
|
24
|
+
align?: "left" | "center" | "right" | undefined;
|
|
25
25
|
fixed?: "left" | "right" | undefined;
|
|
26
26
|
sortOrder?: "ascend" | "descend" | null | undefined;
|
|
27
27
|
};
|
|
@@ -24,28 +24,32 @@ export default function useExpandable(props) {
|
|
|
24
24
|
_expandable$defaultEx = expandable.defaultExpandAllRows,
|
|
25
25
|
defaultExpandAllRows = _expandable$defaultEx === void 0 ? true : _expandable$defaultEx,
|
|
26
26
|
defaultExpandedRowKeys = expandable.defaultExpandedRowKeys,
|
|
27
|
-
childrenColumnName = expandable.childrenColumnName
|
|
27
|
+
childrenColumnName = expandable.childrenColumnName,
|
|
28
|
+
expandedRowRender = expandable.expandedRowRender;
|
|
28
29
|
var columnName = getChildrenColumnName(childrenColumnName);
|
|
29
30
|
var flattenList = useMemo(function () {
|
|
30
31
|
return flattenChildren(data, columnName);
|
|
31
32
|
}, [columnName, data]);
|
|
33
|
+
var isRenderCustomExpandRow = !!expandedRowRender;
|
|
32
34
|
var allCategoryRowKeys = useMemo(function () {
|
|
33
|
-
return getAllExpandRowKeys(flattenList, columnName, defaultExpandAllRows, rowKey);
|
|
34
|
-
}, [columnName, flattenList, defaultExpandAllRows, rowKey]);
|
|
35
|
+
return getAllExpandRowKeys(flattenList, columnName, isRenderCustomExpandRow, defaultExpandAllRows, rowKey);
|
|
36
|
+
}, [columnName, flattenList, defaultExpandAllRows, rowKey, isRenderCustomExpandRow]);
|
|
35
37
|
|
|
36
38
|
// 考虑 defaultExpandAllRows 的情况
|
|
37
39
|
var _useState = useState(expandedRowKeys || defaultExpandedRowKeys || allCategoryRowKeys || []),
|
|
38
40
|
_useState2 = _slicedToArray(_useState, 2),
|
|
39
41
|
expandedKeys = _useState2[0],
|
|
40
42
|
setExpandedKeys = _useState2[1];
|
|
43
|
+
|
|
44
|
+
// 只有在 Map 中的存在 rowKey 的数据行才可见
|
|
41
45
|
var expandItemMap = useMemo(function () {
|
|
42
46
|
var listData = data.map(function (dataItem) {
|
|
43
|
-
return getListItemsByTree(dataItem, expandedKeys, rowKey, childrenColumnName);
|
|
47
|
+
return getListItemsByTree(dataItem, expandedKeys, !!expandedRowRender, rowKey, childrenColumnName);
|
|
44
48
|
}).flat();
|
|
45
49
|
return _.keyBy(listData, function (dataItem) {
|
|
46
50
|
return dataItem.rowKey;
|
|
47
51
|
});
|
|
48
|
-
}, [childrenColumnName, data, expandedKeys, rowKey]);
|
|
52
|
+
}, [childrenColumnName, data, expandedKeys, rowKey, expandedRowRender]);
|
|
49
53
|
useEffect(function () {
|
|
50
54
|
if (expandedRowKeys) {
|
|
51
55
|
// 展开收起完全受控的情况
|
|
@@ -91,20 +95,30 @@ export default function useExpandable(props) {
|
|
|
91
95
|
data: visibleList
|
|
92
96
|
};
|
|
93
97
|
}
|
|
94
|
-
function getListItemsByTree(currNode, expandedKeys,
|
|
95
|
-
|
|
98
|
+
function getListItemsByTree(currNode, expandedKeys, isRenderCustomExpandRow,
|
|
99
|
+
// 是否渲染自定义展开行
|
|
100
|
+
getKey, childrenColumnName) {
|
|
101
|
+
var level = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
|
|
96
102
|
var subNodes = _.get(currNode, getChildrenColumnName(childrenColumnName));
|
|
97
103
|
var isLeaf = !subNodes;
|
|
98
104
|
var rowKey = getRowKey(currNode, getKey);
|
|
105
|
+
var isExpanded = expandedKeys.includes(rowKey);
|
|
99
106
|
if (isLeaf) {
|
|
100
|
-
|
|
107
|
+
var leafNode = {
|
|
101
108
|
isLeaf: true,
|
|
102
109
|
level: level,
|
|
103
110
|
rowKey: rowKey
|
|
104
|
-
}
|
|
111
|
+
};
|
|
112
|
+
if (isRenderCustomExpandRow) {
|
|
113
|
+
leafNode.isLeaf = false;
|
|
114
|
+
var customExpandRowKey = getCustomExpandRowKey(rowKey);
|
|
115
|
+
leafNode.customExpandRowKey = customExpandRowKey;
|
|
116
|
+
leafNode.isExpanded = isExpanded;
|
|
117
|
+
return [leafNode];
|
|
118
|
+
}
|
|
119
|
+
return [leafNode];
|
|
105
120
|
}
|
|
106
121
|
// 是目录的情况
|
|
107
|
-
var isExpanded = expandedKeys.includes(rowKey);
|
|
108
122
|
var curr = {
|
|
109
123
|
isLeaf: false,
|
|
110
124
|
level: level,
|
|
@@ -117,20 +131,35 @@ function getListItemsByTree(currNode, expandedKeys, getKey, childrenColumnName)
|
|
|
117
131
|
curr.isExpanded = true;
|
|
118
132
|
// 子目录是展开的情况
|
|
119
133
|
var subItems = (subNodes === null || subNodes === void 0 ? void 0 : subNodes.map(function (child) {
|
|
120
|
-
return getListItemsByTree(child, expandedKeys, getKey, childrenColumnName, level + 1);
|
|
134
|
+
return getListItemsByTree(child, expandedKeys, isRenderCustomExpandRow, getKey, childrenColumnName, level + 1);
|
|
121
135
|
})) || [];
|
|
122
136
|
return [curr].concat(_toConsumableArray(_.flatten(subItems)));
|
|
123
137
|
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* 为自定义展开行生成唯一的 key
|
|
141
|
+
* @param rowKey
|
|
142
|
+
* @returns
|
|
143
|
+
*/
|
|
144
|
+
function getCustomExpandRowKey(rowKey) {
|
|
145
|
+
return "".concat(rowKey, "-expand");
|
|
146
|
+
}
|
|
124
147
|
export function getExpandableConfig(expandable) {
|
|
125
148
|
if (typeof expandable === 'boolean') {
|
|
126
149
|
return {};
|
|
127
150
|
}
|
|
128
151
|
return expandable || {};
|
|
129
152
|
}
|
|
130
|
-
function getAllExpandRowKeys(list, childrenColumnName, defaultExpandAllRows, rowKey) {
|
|
153
|
+
function getAllExpandRowKeys(list, childrenColumnName, isRenderCustomExpandRow, defaultExpandAllRows, rowKey) {
|
|
131
154
|
if (!defaultExpandAllRows) {
|
|
132
155
|
return undefined;
|
|
133
156
|
}
|
|
157
|
+
if (isRenderCustomExpandRow) {
|
|
158
|
+
// 自定义展开行的情况,即使是叶子节点也可以展开
|
|
159
|
+
return list.map(function (item) {
|
|
160
|
+
return getRowKey(item, rowKey);
|
|
161
|
+
});
|
|
162
|
+
}
|
|
134
163
|
var itemsWithChildrenProp = list.filter(function (item) {
|
|
135
164
|
return !!_.get(item, childrenColumnName);
|
|
136
165
|
});
|
package/dist/Table/index.js
CHANGED
|
@@ -19,15 +19,16 @@ import { Empty, Spin } from '..';
|
|
|
19
19
|
import ExpandCell from "./components/ExpandCell";
|
|
20
20
|
import Footer from "./components/Footer";
|
|
21
21
|
import { getRowKey, getTableColumns, prefixCls } from "./helper";
|
|
22
|
-
import useExpandable from "./hooks/useExpandable";
|
|
22
|
+
import useExpandable, { getExpandableConfig } from "./hooks/useExpandable";
|
|
23
23
|
import useFixed from "./hooks/useFixed";
|
|
24
24
|
import useRowSelection from "./hooks/useRowSelection";
|
|
25
25
|
import useScroll from "./hooks/useScroll";
|
|
26
26
|
var HEADER_HEIGHT = 41;
|
|
27
27
|
var FOOTER_HEIGHT = 52;
|
|
28
28
|
function Table(props, ref) {
|
|
29
|
-
var _classnames, _classnames5,
|
|
29
|
+
var _classnames, _classnames5, _classnames7;
|
|
30
30
|
var data = props.data,
|
|
31
|
+
bordered = props.bordered,
|
|
31
32
|
rowKey = props.rowKey,
|
|
32
33
|
columnSizing = props.columnSizing,
|
|
33
34
|
sticky = props.sticky,
|
|
@@ -76,6 +77,7 @@ function Table(props, ref) {
|
|
|
76
77
|
data: data,
|
|
77
78
|
rowKey: rowKey
|
|
78
79
|
});
|
|
80
|
+
var expandableConfig = getExpandableConfig(expandable);
|
|
79
81
|
var rowSelectionInfo = useRowSelection(props);
|
|
80
82
|
var tableColumns = useMemo(function () {
|
|
81
83
|
if (!totalSize || !realWidth) {
|
|
@@ -186,10 +188,11 @@ function Table(props, ref) {
|
|
|
186
188
|
}, /*#__PURE__*/React.createElement(Empty, {
|
|
187
189
|
image: isSmallEmpty ? null : Empty.PRESENTED_IMAGE_SEARCH,
|
|
188
190
|
size: isSmallEmpty ? 'small' : undefined
|
|
189
|
-
}))) : _.
|
|
191
|
+
}))) : _.reduce(rows, function (rowList, row, rowIndex) {
|
|
190
192
|
var _classnames4;
|
|
191
|
-
|
|
192
|
-
|
|
193
|
+
var rowId = row.id;
|
|
194
|
+
var rowNode = /*#__PURE__*/React.createElement("div", {
|
|
195
|
+
key: rowId,
|
|
193
196
|
className: classnames(prefixCls('tr'), (_classnames4 = {}, _defineProperty(_classnames4, prefixCls('row-hover'), typeof onRowClick === 'function'), _defineProperty(_classnames4, prefixCls('no-border-tr'), isShowPagination && rowIndex === rows.length - 1), _classnames4), rowClassName(row.original, rowIndex)),
|
|
194
197
|
onClick: onClickRow(row.original, rowIndex)
|
|
195
198
|
}, _.map(row.getVisibleCells(), function (cell, colIndex) {
|
|
@@ -210,7 +213,31 @@ function Table(props, ref) {
|
|
|
210
213
|
rowKey: rowKey
|
|
211
214
|
}, tdContent) : tdContent);
|
|
212
215
|
}));
|
|
213
|
-
|
|
216
|
+
rowList.push(rowNode);
|
|
217
|
+
|
|
218
|
+
// 渲染额外展开的行
|
|
219
|
+
var expandItem = expandableInfo.expandItemMap[rowId];
|
|
220
|
+
var customExpandRowKey = expandableInfo.isExpandable && (expandItem === null || expandItem === void 0 ? void 0 : expandItem.customExpandRowKey);
|
|
221
|
+
var hasCustomExpandRowKey = !!customExpandRowKey;
|
|
222
|
+
if (hasCustomExpandRowKey) {
|
|
223
|
+
// 在该行的下面追加自定义展开行
|
|
224
|
+
var expandedRowRender = expandableConfig.expandedRowRender;
|
|
225
|
+
if (typeof expandedRowRender !== 'function') {
|
|
226
|
+
console.error('expandedRowRender must be a function');
|
|
227
|
+
return rowList;
|
|
228
|
+
}
|
|
229
|
+
if ((expandItem === null || expandItem === void 0 ? void 0 : expandItem.isExpanded) !== true) {
|
|
230
|
+
return rowList;
|
|
231
|
+
}
|
|
232
|
+
var customRow = /*#__PURE__*/React.createElement("div", {
|
|
233
|
+
key: customExpandRowKey,
|
|
234
|
+
className: classnames(prefixCls('tr')),
|
|
235
|
+
onClick: onClickRow(row.original, rowIndex)
|
|
236
|
+
}, expandedRowRender(row.original, expandItem.level + 1));
|
|
237
|
+
rowList.push(customRow);
|
|
238
|
+
}
|
|
239
|
+
return rowList;
|
|
240
|
+
}, []));
|
|
214
241
|
var tableContent = /*#__PURE__*/React.createElement(Spin, {
|
|
215
242
|
spinning: !!loading
|
|
216
243
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -234,7 +261,7 @@ function Table(props, ref) {
|
|
|
234
261
|
tableStyle.height = y;
|
|
235
262
|
}
|
|
236
263
|
return /*#__PURE__*/React.createElement("div", {
|
|
237
|
-
className: prefixCls('container'),
|
|
264
|
+
className: classnames(prefixCls('container'), _defineProperty({}, prefixCls('bordered'), bordered)),
|
|
238
265
|
style: tableStyle
|
|
239
266
|
}, /*#__PURE__*/React.createElement(ResizeObserver, {
|
|
240
267
|
onResize: function onResize(size) {
|
|
@@ -246,7 +273,7 @@ function Table(props, ref) {
|
|
|
246
273
|
});
|
|
247
274
|
}
|
|
248
275
|
}, /*#__PURE__*/React.createElement("div", {
|
|
249
|
-
className: classnames(prefixCls('main'), (
|
|
276
|
+
className: classnames(prefixCls('main'), (_classnames7 = {}, _defineProperty(_classnames7, prefixCls('overflow-hidden'), !!y), _defineProperty(_classnames7, prefixCls('ping-left'), isPingLeft), _defineProperty(_classnames7, prefixCls('ping-right'), isPingRight), _classnames7))
|
|
250
277
|
}, tableContent)));
|
|
251
278
|
}
|
|
252
279
|
export default /*#__PURE__*/forwardRef(Table);
|
|
@@ -12,6 +12,19 @@
|
|
|
12
12
|
display: flex;
|
|
13
13
|
flex-direction: column;
|
|
14
14
|
width: 100%;
|
|
15
|
+
|
|
16
|
+
&.ald-table-bordered {
|
|
17
|
+
border: 1px solid var(--alias-colors-border-default, #e5e7eb);
|
|
18
|
+
|
|
19
|
+
.ald-table-main .ald-table-th,
|
|
20
|
+
.ald-table-header-scroll-placeholder {
|
|
21
|
+
border-bottom: 1px solid var(--alias-colors-border-default, #e5e7eb);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.ald-table-main .ald-table-tr:last-child .ald-table-td {
|
|
25
|
+
border-bottom: 0;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
15
28
|
}
|
|
16
29
|
|
|
17
30
|
.ald-table-main {
|
|
@@ -311,12 +324,14 @@
|
|
|
311
324
|
}
|
|
312
325
|
|
|
313
326
|
.ald-table-header-scroll-placeholder {
|
|
314
|
-
|
|
327
|
+
// 1px 是 border-bottom 高度
|
|
328
|
+
height: @header-height + 1px;
|
|
315
329
|
position: sticky;
|
|
316
330
|
right: 0;
|
|
317
331
|
background: var(--alias-colors-bg-skeleton-strong, #f3f4f6);
|
|
318
332
|
z-index: 2;
|
|
319
333
|
flex: 0 0 auto;
|
|
334
|
+
border-bottom: 1px solid var(--alias-colors-border-subtle, #f3f4f6);
|
|
320
335
|
}
|
|
321
336
|
|
|
322
337
|
.ald-table-body-scroll {
|
package/dist/Table/types.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export interface ITableProps<TDataItem extends object> {
|
|
|
19
19
|
expandable?: ITableExpandable<TDataItem> | boolean;
|
|
20
20
|
onSort?: (columnKey: string, order: 'ascend' | 'descend' | null) => void;
|
|
21
21
|
rowSelection?: IRowSelection<TDataItem>;
|
|
22
|
+
bordered?: boolean;
|
|
22
23
|
}
|
|
23
24
|
export type TRowKey<TDataItem extends object> = string | ((record: TDataItem) => string | number);
|
|
24
25
|
export interface ITableCellErrorInfo {
|
|
@@ -70,6 +71,7 @@ export interface ITableExpandable<TDataItem = unknown> {
|
|
|
70
71
|
expandedRowKeys?: string[];
|
|
71
72
|
onExpand?: (record: TDataItem, isExpanded: boolean) => void;
|
|
72
73
|
expandIcon?: (params: IExpandIconProps<TDataItem>) => React.ReactNode;
|
|
74
|
+
expandedRowRender?: (record: TDataItem, indent: number) => React.ReactNode;
|
|
73
75
|
}
|
|
74
76
|
export interface IExpandIconProps<TDataItem = unknown> {
|
|
75
77
|
record: TDataItem;
|