@aloudata/aloudata-design 2.7.2 → 2.7.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.
Files changed (31) hide show
  1. package/dist/Icon/components/SortAscendingOrderColor.d.ts +11 -0
  2. package/dist/Icon/components/SortAscendingOrderColor.js +36 -0
  3. package/dist/Icon/components/SortColor.d.ts +11 -0
  4. package/dist/Icon/components/SortColor.js +33 -0
  5. package/dist/Icon/components/SortDescendingOrderColor.d.ts +11 -0
  6. package/dist/Icon/components/SortDescendingOrderColor.js +36 -0
  7. package/dist/Icon/index.d.ts +3 -0
  8. package/dist/Icon/index.js +3 -0
  9. package/dist/Icon/svg/Sort-Ascending-order-Color.svg +4 -0
  10. package/dist/Icon/svg/Sort-Color.svg +4 -0
  11. package/dist/Icon/svg/Sort-Descending-order-Color.svg +4 -0
  12. package/dist/Select/index.js +4 -2
  13. package/dist/Table/components/ExpandCell.d.ts +2 -1
  14. package/dist/Table/components/ExpandCell.js +26 -10
  15. package/dist/Table/components/Footer/index.d.ts +13 -0
  16. package/dist/Table/components/Footer/index.js +77 -0
  17. package/dist/Table/components/Header.d.ts +1 -1
  18. package/dist/Table/components/Header.js +50 -4
  19. package/dist/Table/helper.d.ts +4 -1
  20. package/dist/Table/helper.js +4 -2
  21. package/dist/Table/hooks/useExpandable.d.ts +1 -0
  22. package/dist/Table/hooks/useExpandable.js +4 -4
  23. package/dist/Table/hooks/useRowSelection.d.ts +17 -0
  24. package/dist/Table/hooks/useRowSelection.js +164 -0
  25. package/dist/Table/index.js +33 -18
  26. package/dist/Table/style/index.less +77 -8
  27. package/dist/Table/types.d.ts +21 -0
  28. package/dist/ald.min.css +1 -1
  29. package/package.json +1 -1
  30. package/dist/Table/components/Pagination/index.d.ts +0 -10
  31. package/dist/Table/components/Pagination/index.js +0 -28
@@ -0,0 +1,164 @@
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
+ 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; }
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; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
8
+ 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."); }
9
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
10
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
11
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
12
+ 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."); }
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); }
14
+ 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; }
15
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
16
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
+ import React, { useCallback, useState } from 'react';
18
+ import Checkbox from "../../Checkbox";
19
+ import { getRowKey, prefixCls } from "../helper";
20
+ export default function useRowSelection(props) {
21
+ var _rowSelection$items;
22
+ var columns = props.columns,
23
+ rowSelection = props.rowSelection,
24
+ rowKey = props.rowKey,
25
+ data = props.data;
26
+ var _useState = useState((rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.selectedRowKeys) || (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.defaultSelectedRowKeys) || []),
27
+ _useState2 = _slicedToArray(_useState, 2),
28
+ selectedRowKeysState = _useState2[0],
29
+ setSelectedRowKeysState = _useState2[1];
30
+ var selectedRowKeys = (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.selectedRowKeys) || selectedRowKeysState;
31
+ var getSelectedRows = useCallback(function (rowKeys) {
32
+ return data.filter(function (record) {
33
+ return rowKeys.includes(getRowKey(record, rowKey));
34
+ });
35
+ }, [data, rowKey]);
36
+ var changeSelectedRowKeys = useCallback(function (newSelectedRowKeys) {
37
+ var _rowSelection$onChang;
38
+ // 过滤出存在于 data 中的 selectedRowKeys
39
+ var visibleSelectedRowKeys = data.map(function (record) {
40
+ return getRowKey(record, rowKey);
41
+ }).filter(function (key) {
42
+ return newSelectedRowKeys.includes(key);
43
+ });
44
+ setSelectedRowKeysState(visibleSelectedRowKeys);
45
+ var selectedRows = getSelectedRows(visibleSelectedRowKeys);
46
+ rowSelection === null || rowSelection === void 0 ? void 0 : (_rowSelection$onChang = rowSelection.onChange) === null || _rowSelection$onChang === void 0 ? void 0 : _rowSelection$onChang.call(rowSelection, visibleSelectedRowKeys, selectedRows);
47
+ }, [getSelectedRows, rowSelection, data, rowKey]);
48
+ var checkboxAllStatus = getCheckboxAllStatus(data, selectedRowKeys, rowKey);
49
+ var selectAll = useCallback(function () {
50
+ var newKeys = data.map(function (record) {
51
+ return getRowKey(record, rowKey);
52
+ });
53
+ changeSelectedRowKeys(newKeys);
54
+ }, [data, rowKey, changeSelectedRowKeys]);
55
+ var unSelectAll = useCallback(function () {
56
+ changeSelectedRowKeys([]);
57
+ }, [changeSelectedRowKeys]);
58
+ var onClickAllCheckbox = useCallback(function () {
59
+ if (rowSelection !== null && rowSelection !== void 0 && rowSelection.selectedRowKeys) {
60
+ // 受控情况
61
+ return;
62
+ }
63
+ if (checkboxAllStatus === 'all') {
64
+ unSelectAll();
65
+ } else {
66
+ selectAll();
67
+ }
68
+ }, [checkboxAllStatus, unSelectAll, selectAll, rowSelection]);
69
+ var onClickCheckbox = useCallback(function (key, isChecked) {
70
+ return function () {
71
+ if (rowSelection !== null && rowSelection !== void 0 && rowSelection.selectedRowKeys) {
72
+ // 受控情况
73
+ return;
74
+ }
75
+ var newKeys = isChecked ? selectedRowKeys.filter(function (keyItem) {
76
+ return keyItem !== key;
77
+ }) : [].concat(_toConsumableArray(selectedRowKeys), [key]);
78
+ changeSelectedRowKeys(newKeys);
79
+ };
80
+ }, [selectedRowKeys, rowSelection, changeSelectedRowKeys]);
81
+
82
+ // 全选按钮
83
+ var getCheckboxAllNode = function getCheckboxAllNode(children) {
84
+ return /*#__PURE__*/React.createElement("div", {
85
+ className: prefixCls('row-selection-all')
86
+ }, /*#__PURE__*/React.createElement(Checkbox, {
87
+ onClick: onClickAllCheckbox,
88
+ checked: checkboxAllStatus === 'all',
89
+ indeterminate: checkboxAllStatus === 'indeterminate'
90
+ }, children));
91
+ };
92
+ if (!rowSelection) {
93
+ return {
94
+ columns: columns,
95
+ isRowSelectionEnabled: false,
96
+ getCheckboxAllNode: getCheckboxAllNode,
97
+ selectedRowKeys: [],
98
+ unSelectAll: unSelectAll,
99
+ isShowRowSelectionInFooter: false,
100
+ items: [],
101
+ onChange: function onChange() {}
102
+ };
103
+ }
104
+ if (!rowKey) {
105
+ throw new Error('rowKey is required when rowSelection is enabled');
106
+ }
107
+ var rowSelectionColumn = {
108
+ dataIndex: '',
109
+ title: getCheckboxAllNode(),
110
+ width: 48,
111
+ render: function render(text, record) {
112
+ var key = getRowKey(record, rowKey);
113
+ var isChecked = !!(selectedRowKeys !== null && selectedRowKeys !== void 0 && selectedRowKeys.includes(key));
114
+ return /*#__PURE__*/React.createElement("div", {
115
+ className: prefixCls('row-selection-item')
116
+ }, /*#__PURE__*/React.createElement(Checkbox, {
117
+ onClick: onClickCheckbox(key, isChecked),
118
+ checked: isChecked
119
+ }));
120
+ },
121
+ fixed: rowSelection.fixed ? 'left' : undefined
122
+ };
123
+ var selectedRowKeysInCurrPage = data.map(function (record) {
124
+ return getRowKey(record, rowKey);
125
+ }).filter(function (key) {
126
+ return selectedRowKeys.includes(key);
127
+ });
128
+ var isShowRowSelectionInFooter = selectedRowKeysInCurrPage.length > 0;
129
+ var items = ((_rowSelection$items = rowSelection.items) === null || _rowSelection$items === void 0 ? void 0 : _rowSelection$items.map(function (operationItem) {
130
+ return _objectSpread(_objectSpread({}, operationItem), {}, {
131
+ onClick: function onClick(e) {
132
+ operationItem.onClick(selectedRowKeysInCurrPage, getSelectedRows(selectedRowKeysInCurrPage), e);
133
+ }
134
+ });
135
+ })) || [];
136
+ return {
137
+ columns: [rowSelectionColumn].concat(_toConsumableArray(columns)),
138
+ isRowSelectionEnabled: true,
139
+ getCheckboxAllNode: getCheckboxAllNode,
140
+ selectedRowKeys: selectedRowKeysInCurrPage,
141
+ unSelectAll: unSelectAll,
142
+ isShowRowSelectionInFooter: isShowRowSelectionInFooter,
143
+ items: items,
144
+ onChange: changeSelectedRowKeys
145
+ };
146
+ }
147
+ function getCheckboxAllStatus(data, selectedRowKeys, rowKey) {
148
+ var selectedKeysInData = data.map(function (record) {
149
+ var key = getRowKey(record, rowKey);
150
+ if (selectedRowKeys.includes(key)) {
151
+ return key;
152
+ }
153
+ return null;
154
+ }).filter(function (key) {
155
+ return key !== null;
156
+ });
157
+ if (selectedKeysInData.length === 0) {
158
+ return 'none';
159
+ }
160
+ if (selectedKeysInData.length === data.length) {
161
+ return 'all';
162
+ }
163
+ return 'indeterminate';
164
+ }
@@ -17,16 +17,17 @@ import ResizeObserver from 'rc-resize-observer';
17
17
  import React, { forwardRef, useCallback, useImperativeHandle, useMemo, useState } from 'react';
18
18
  import { Empty, Spin } from '..';
19
19
  import ExpandCell from "./components/ExpandCell";
20
- import Pagination from "./components/Pagination";
20
+ import Footer from "./components/Footer";
21
21
  import { getRowKey, getTableColumns, prefixCls } from "./helper";
22
22
  import useExpandable from "./hooks/useExpandable";
23
23
  import useFixed from "./hooks/useFixed";
24
+ import useRowSelection from "./hooks/useRowSelection";
24
25
  import useScroll from "./hooks/useScroll";
25
26
  var HEADER_HEIGHT = 41;
27
+ var FOOTER_HEIGHT = 52;
26
28
  function Table(props, ref) {
27
29
  var _classnames, _classnames5, _classnames6;
28
- var columns = props.columns,
29
- data = props.data,
30
+ var data = props.data,
30
31
  rowKey = props.rowKey,
31
32
  columnSizing = props.columnSizing,
32
33
  sticky = props.sticky,
@@ -41,6 +42,7 @@ function Table(props, ref) {
41
42
  } : _props$rowClassName,
42
43
  onRowClick = props.onRowClick,
43
44
  onError = props.onError,
45
+ onSort = props.onSort,
44
46
  expandable = props.expandable;
45
47
  var _useState = useState(null),
46
48
  _useState2 = _slicedToArray(_useState, 2),
@@ -74,16 +76,18 @@ function Table(props, ref) {
74
76
  data: data,
75
77
  rowKey: rowKey
76
78
  });
79
+ var rowSelectionInfo = useRowSelection(props);
77
80
  var tableColumns = useMemo(function () {
78
81
  if (!totalSize || !realWidth) {
79
82
  return [];
80
83
  }
81
84
  return getTableColumns({
82
- columns: columns,
85
+ columns: rowSelectionInfo.columns,
83
86
  totalWidth: realWidth,
84
- onError: onError
87
+ onError: onError,
88
+ onSort: onSort
85
89
  });
86
- }, [columns, totalSize, realWidth, onError]);
90
+ }, [totalSize, realWidth, onError, onSort, rowSelectionInfo.columns]);
87
91
  var getColumnFixedInfo = useFixed({
88
92
  tableColumns: tableColumns,
89
93
  y: y,
@@ -122,6 +126,8 @@ function Table(props, ref) {
122
126
  }
123
127
  }, _.map(headerGroup.headers, function (header, index) {
124
128
  var _classnames2;
129
+ // 选择行的列不能拖动宽度
130
+ var showResizer = columnSizing && !(!!rowSelectionInfo.isRowSelectionEnabled && index === 0);
125
131
  var _getColumnFixedInfo = getColumnFixedInfo(index, true),
126
132
  fixedClassName = _getColumnFixedInfo.className,
127
133
  fixedStyle = _getColumnFixedInfo.style;
@@ -131,7 +137,7 @@ function Table(props, ref) {
131
137
  width: header.getSize()
132
138
  }, fixedStyle),
133
139
  key: header.id
134
- }, flexRender(header.column.columnDef.header, header.getContext()), columnSizing && /*#__PURE__*/React.createElement("div", {
140
+ }, flexRender(header.column.columnDef.header, header.getContext()), showResizer && /*#__PURE__*/React.createElement("div", {
135
141
  onMouseDown: header.getResizeHandler(),
136
142
  onTouchStart: header.getResizeHandler(),
137
143
  className: classnames(prefixCls('resizer'), (_classnames2 = {}, _defineProperty(_classnames2, prefixCls('self-resizing'), header.column.getIsResizing()), _defineProperty(_classnames2, prefixCls('resizing'), tableInstance.getState().columnSizingInfo.isResizingColumn), _classnames2))
@@ -156,10 +162,12 @@ function Table(props, ref) {
156
162
  onRowClick(rowData, rowIndex);
157
163
  };
158
164
  }, [onRowClick]);
159
- var isShowPagination = pagination && pagination.total > pagination.pageSize;
165
+ var isShowPagination = !!(pagination && pagination.total > pagination.pageSize);
166
+ var isShowRowSelection = rowSelectionInfo.isShowRowSelectionInFooter;
167
+ var isShowFooter = isShowPagination || isShowRowSelection;
160
168
 
161
169
  // 空态切换 size 的阈值
162
- var EMPTY_SMALL_SIZE_HEIGHT = 288;
170
+ var EMPTY_SMALL_SIZE_HEIGHT = 436;
163
171
  var isSmallEmpty = totalSize && totalSize.height < EMPTY_SMALL_SIZE_HEIGHT;
164
172
  var isEmpty = rows.length === 0 && !loading;
165
173
 
@@ -169,12 +177,16 @@ function Table(props, ref) {
169
177
  style: {
170
178
  width: realWidth
171
179
  }
172
- }, isEmpty ? emptyComponent || /*#__PURE__*/React.createElement("div", {
180
+ }, isEmpty ? /*#__PURE__*/React.createElement("div", {
181
+ style: {
182
+ width: totalSize === null || totalSize === void 0 ? void 0 : totalSize.width
183
+ }
184
+ }, emptyComponent || /*#__PURE__*/React.createElement("div", {
173
185
  className: classnames(prefixCls('empty'), _defineProperty({}, prefixCls('empty-small'), isSmallEmpty))
174
186
  }, /*#__PURE__*/React.createElement(Empty, {
175
187
  image: isSmallEmpty ? null : Empty.PRESENTED_IMAGE_SEARCH,
176
188
  size: isSmallEmpty ? 'small' : undefined
177
- })) : _.map(rows, function (row, rowIndex) {
189
+ }))) : _.map(rows, function (row, rowIndex) {
178
190
  var _classnames4;
179
191
  return /*#__PURE__*/React.createElement("div", {
180
192
  key: row.id,
@@ -193,6 +205,7 @@ function Table(props, ref) {
193
205
  }, fixedStyle)
194
206
  }, expandableInfo.isExpandable && colIndex === 0 ? /*#__PURE__*/React.createElement(ExpandCell, {
195
207
  expandableInfo: expandableInfo,
208
+ expandable: expandable,
196
209
  data: row.original,
197
210
  rowKey: rowKey
198
211
  }, tdContent) : tdContent);
@@ -204,12 +217,18 @@ function Table(props, ref) {
204
217
  className: prefixCls('content')
205
218
  }, headerContent, /*#__PURE__*/React.createElement("div", {
206
219
  style: {
207
- height: y && totalSize ? totalSize.height - HEADER_HEIGHT : 'auto'
220
+ height: y && totalSize ? totalSize.height - HEADER_HEIGHT - (isShowFooter ? FOOTER_HEIGHT : 0) : 'auto'
208
221
  },
209
222
  className: classnames(prefixCls('body-scroll'), (_classnames5 = {}, _defineProperty(_classnames5, prefixCls('scroll-y'), y !== undefined), _defineProperty(_classnames5, prefixCls('scroll-hidden'), isEmpty), _classnames5)),
210
223
  ref: bodyRef,
211
224
  onScroll: onBodyScroll
212
- }, bodyContent)));
225
+ }, bodyContent), isShowFooter && /*#__PURE__*/React.createElement(Footer, {
226
+ rowSelectionInfo: rowSelectionInfo,
227
+ isShowPagination: isShowPagination,
228
+ pagination: pagination,
229
+ scroll: scroll,
230
+ scrollToFirstRow: scrollToFirstRow
231
+ })));
213
232
  var tableStyle = {};
214
233
  if (y) {
215
234
  tableStyle.height = y;
@@ -228,10 +247,6 @@ function Table(props, ref) {
228
247
  }
229
248
  }, /*#__PURE__*/React.createElement("div", {
230
249
  className: classnames(prefixCls('main'), (_classnames6 = {}, _defineProperty(_classnames6, prefixCls('overflow-hidden'), !!y), _defineProperty(_classnames6, prefixCls('ping-left'), isPingLeft), _defineProperty(_classnames6, prefixCls('ping-right'), isPingRight), _classnames6))
231
- }, tableContent)), isShowPagination && /*#__PURE__*/React.createElement(Pagination, {
232
- pagination: pagination,
233
- scroll: scroll,
234
- scrollToFirstRow: scrollToFirstRow
235
- }));
250
+ }, tableContent)));
236
251
  }
237
252
  export default /*#__PURE__*/forwardRef(Table);
@@ -3,6 +3,8 @@
3
3
  @import '../../Spin/style/index.less';
4
4
  @import '../../ScrollArea/style/index.less';
5
5
  @import '../../Empty/style/index.less';
6
+ @import '../../Checkbox/style/index.less';
7
+ @import '../../TextLink/style/index.less';
6
8
 
7
9
  @header-height: 40px;
8
10
 
@@ -163,6 +165,29 @@
163
165
  display: flex;
164
166
  align-items: center;
165
167
  color: var(--alias-colors-text-subtle, #4b5563);
168
+
169
+ &.ald-table-th-sortable {
170
+ cursor: pointer;
171
+ }
172
+
173
+ .ald-table-sort-th-inner {
174
+ display: flex;
175
+ column-gap: 4px;
176
+ align-items: center;
177
+ width: 100%;
178
+ }
179
+
180
+ .ald-table-sort-title {
181
+ overflow: hidden;
182
+ text-overflow: ellipsis;
183
+ white-space: nowrap;
184
+ }
185
+
186
+ .ald-table-sort-btn {
187
+ display: flex;
188
+ align-items: center;
189
+ flex: 0 0 auto;
190
+ }
166
191
  }
167
192
 
168
193
  .ald-table-td-default {
@@ -225,11 +250,20 @@
225
250
 
226
251
  .ald-table-expand-btn {
227
252
  width: 16px;
253
+ height: 100%;
228
254
  cursor: pointer;
229
255
  margin-right: 6px;
230
256
  display: flex;
231
- height: 100%;
257
+ flex-direction: column;
258
+ justify-content: center;
232
259
  align-items: center;
260
+
261
+ &-inner {
262
+ width: 16px;
263
+ height: 16px;
264
+ display: flex;
265
+ align-items: center;
266
+ }
233
267
  }
234
268
 
235
269
  .ald-table-td-default {
@@ -255,13 +289,6 @@
255
289
  }
256
290
  }
257
291
 
258
- .ald-table-pagination {
259
- padding-top: 16px;
260
- display: flex;
261
- justify-content: end;
262
- border-top: 1px solid var(--alias-colors-border-default, #e5e7eb);
263
- }
264
-
265
292
  .ald-table-loading {
266
293
  position: absolute;
267
294
  top: 50%;
@@ -312,3 +339,45 @@
312
339
  margin-top: 20px;
313
340
  }
314
341
  }
342
+
343
+ /** 选择行 **/
344
+ .ald-table-row-selection-all {
345
+ display: flex;
346
+ align-items: center;
347
+ width: 100%;
348
+ height: 100%;
349
+ justify-content: center;
350
+ }
351
+
352
+ /** Footer **/
353
+ .ald-table-footer {
354
+ padding: 16px;
355
+ display: flex;
356
+ justify-content: space-between;
357
+ border-top: 1px solid var(--alias-colors-border-default, #e5e7eb);
358
+ }
359
+
360
+ .ald-table-footer-row-selection {
361
+ display: flex;
362
+ align-items: center;
363
+ column-gap: 16px;
364
+ font-size: 14px;
365
+ line-height: 20px;
366
+
367
+ .ald-table-footer-row-selection-selected-num {
368
+ cursor: inherit !important;
369
+ }
370
+ }
371
+
372
+ .ald-table-footer-row-selection-btn {
373
+ display: flex;
374
+ align-items: center;
375
+ column-gap: 6px;
376
+ }
377
+
378
+ .ald-table-pager {
379
+ display: flex;
380
+ justify-content: flex-end;
381
+ align-items: center;
382
+ flex: 1 1 auto;
383
+ }
@@ -16,6 +16,8 @@ export interface ITableProps<TDataItem extends object> {
16
16
  onRowClick?: (record: TDataItem, index: number) => void;
17
17
  onError?: (errorInfo: ITableCellErrorInfo) => void;
18
18
  expandable?: ITableExpandable<TDataItem> | boolean;
19
+ onSort?: (columnKey: string, order: 'ascend' | 'descend' | null) => void;
20
+ rowSelection?: IRowSelection<TDataItem>;
19
21
  }
20
22
  export type TRowKey<TDataItem extends object> = string | ((record: TDataItem) => string | number);
21
23
  export interface ITableCellErrorInfo {
@@ -42,6 +44,19 @@ export interface ITableColumn<TDataItem = unknown> {
42
44
  noPadding?: boolean;
43
45
  align?: 'left' | 'center' | 'right';
44
46
  fixed?: 'left' | 'right';
47
+ sortOrder?: 'ascend' | 'descend' | null;
48
+ }
49
+ export interface IRowSelection<TDataItem extends object> {
50
+ fixed?: boolean;
51
+ selectedRowKeys?: string[];
52
+ defaultSelectedRowKeys?: string[];
53
+ items?: IRowSelectionBtnItem<TDataItem>[];
54
+ onChange?: (selectedRowKeys: string[], selectedRows: TDataItem[]) => void;
55
+ }
56
+ export interface IRowSelectionBtnItem<TDataItem extends object> {
57
+ key: string;
58
+ label: string;
59
+ onClick: (selectedRowKeys: string[], selectedRows: TDataItem[], e: React.MouseEvent) => void;
45
60
  }
46
61
  export interface IInnerTableColumn<TDataItem = unknown> extends ITableColumn<TDataItem> {
47
62
  columnWidths: number[];
@@ -52,4 +67,10 @@ export interface ITableExpandable<TDataItem = unknown> {
52
67
  defaultExpandedRowKeys?: string[];
53
68
  expandedRowKeys?: string[];
54
69
  onExpand?: (record: TDataItem, isExpanded: boolean) => void;
70
+ expandIcon?: (params: IExpandIconProps<TDataItem>) => React.ReactNode;
71
+ }
72
+ export interface IExpandIconProps<TDataItem = unknown> {
73
+ record: TDataItem;
74
+ onExpand: (record: TDataItem, isExpanded: boolean) => void;
75
+ isExpanded: boolean;
55
76
  }