@douyinfe/semi-ui 2.0.9-alpha.4 → 2.1.0-alpha.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/css/semi.css +14 -1
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +1625 -2525
- package/dist/umd/semi-ui.js.map +1 -1
- package/dist/umd/semi-ui.min.js +1 -1
- package/dist/umd/semi-ui.min.js.map +1 -1
- package/lib/es/_base/baseComponent.js +1 -5
- package/lib/es/_portal/index.js +7 -17
- package/lib/es/_utils/index.js +13 -16
- package/lib/es/breadcrumb/index.js +2 -4
- package/lib/es/breadcrumb/item.js +4 -6
- package/lib/es/button/index.d.ts +0 -1
- package/lib/es/button/index.js +2 -4
- package/lib/es/calendar/monthCalendar.js +9 -11
- package/lib/es/cascader/index.d.ts +1 -0
- package/lib/es/cascader/index.js +23 -14
- package/lib/es/cascader/item.js +1 -2
- package/lib/es/collapse/item.js +1 -2
- package/lib/es/collapsible/index.js +9 -9
- package/lib/es/datePicker/dateInput.js +9 -29
- package/lib/es/datePicker/datePicker.js +12 -49
- package/lib/es/datePicker/footer.js +1 -2
- package/lib/es/datePicker/index.js +12 -15
- package/lib/es/datePicker/yearAndMonth.js +17 -23
- package/lib/es/dropdown/dropdownDivider.js +1 -2
- package/lib/es/form/baseForm.d.ts +4 -10
- package/lib/es/form/field.d.ts +4 -22
- package/lib/es/form/field.js +2 -18
- package/lib/es/form/hoc/withField.d.ts +1 -1
- package/lib/es/form/hoc/withField.js +3 -14
- package/lib/es/iconButton/index.d.ts +0 -1
- package/lib/es/iconButton/index.js +0 -1
- package/lib/es/inputNumber/index.js +4 -12
- package/lib/es/locale/localeConsumer.js +3 -6
- package/lib/es/modal/ConfirmModal.js +2 -2
- package/lib/es/modal/confirm.js +2 -2
- package/lib/es/modal/useModal/HookModal.js +2 -2
- package/lib/es/motions/Rotate.js +4 -6
- package/lib/es/navigation/CollapseButton.js +7 -9
- package/lib/es/navigation/Item.js +7 -33
- package/lib/es/navigation/OpenIconTransition.js +4 -6
- package/lib/es/navigation/SubNav.js +6 -33
- package/lib/es/navigation/SubNavTransition.js +5 -7
- package/lib/es/navigation/index.js +6 -24
- package/lib/es/notification/NoticeTransition.js +5 -7
- package/lib/es/notification/index.js +8 -16
- package/lib/es/notification/useNotification/index.js +7 -11
- package/lib/es/overflowList/index.js +4 -9
- package/lib/es/overflowList/intersectionObserver.js +1 -2
- package/lib/es/popconfirm/index.d.ts +5 -1
- package/lib/es/popconfirm/index.js +10 -4
- package/lib/es/popover/Arrow.js +1 -3
- package/lib/es/popover/index.d.ts +3 -1
- package/lib/es/popover/index.js +4 -8
- package/lib/es/radio/context.d.ts +1 -1
- package/lib/es/radio/radio.d.ts +2 -2
- package/lib/es/radio/radioGroup.d.ts +4 -4
- package/lib/es/resizeObserver/index.js +1 -2
- package/lib/es/scrollList/scrollItem.js +24 -40
- package/lib/es/select/index.js +19 -16
- package/lib/es/select/option.js +8 -10
- package/lib/es/select/utils.d.ts +1 -1
- package/lib/es/select/utils.js +10 -4
- package/lib/es/select/virtualRow.js +5 -6
- package/lib/es/sideSheet/SideSheetTransition.js +1 -3
- package/lib/es/slider/index.js +11 -23
- package/lib/es/spin/icon.js +1 -3
- package/lib/es/table/Body/BaseRow.js +8 -16
- package/lib/es/table/Body/SectionRow.js +3 -6
- package/lib/es/table/Body/index.js +32 -49
- package/lib/es/table/Column.js +1 -2
- package/lib/es/table/ColumnFilter.js +2 -6
- package/lib/es/table/ColumnSelection.js +1 -5
- package/lib/es/table/HeadTable.js +3 -4
- package/lib/es/table/ResizableTable.js +20 -31
- package/lib/es/table/Table.js +63 -160
- package/lib/es/table/TableCell.js +3 -5
- package/lib/es/table/TableContextProvider.js +15 -16
- package/lib/es/table/TableHeader.js +1 -4
- package/lib/es/table/utils.js +1 -3
- package/lib/es/tabs/TabBar.d.ts +4 -2
- package/lib/es/tabs/TabBar.js +12 -4
- package/lib/es/tabs/TabPane.d.ts +2 -1
- package/lib/es/tabs/TabPane.js +3 -2
- package/lib/es/tabs/TabPaneTransition.js +9 -12
- package/lib/es/tabs/index.d.ts +3 -1
- package/lib/es/tabs/index.js +83 -14
- package/lib/es/tabs/interface.d.ts +6 -1
- package/lib/es/tagInput/index.d.ts +3 -0
- package/lib/es/tagInput/index.js +6 -1
- package/lib/es/timePicker/Combobox.js +5 -6
- package/lib/es/timePicker/TimeInput.js +3 -11
- package/lib/es/timePicker/TimePicker.js +7 -21
- package/lib/es/timePicker/index.js +12 -15
- package/lib/es/toast/ToastTransition.js +8 -12
- package/lib/es/toast/useToast/index.js +3 -6
- package/lib/es/tooltip/TooltipStyledTransition.js +10 -14
- package/lib/es/tooltip/index.d.ts +3 -0
- package/lib/es/tooltip/index.js +22 -28
- package/lib/es/transfer/index.js +15 -18
- package/lib/es/tree/index.js +28 -38
- package/lib/es/tree/interface.d.ts +2 -2
- package/lib/es/treeSelect/index.d.ts +2 -11
- package/lib/es/treeSelect/index.js +32 -44
- package/lib/es/typography/title.d.ts +1 -1
- package/lib/es/typography/util.js +3 -12
- package/lib/es/upload/fileCard.js +53 -62
- package/lib/es/upload/index.d.ts +1 -1
- package/lib/es/upload/index.js +23 -32
- package/package.json +8 -8
package/lib/es/table/Table.js
CHANGED
|
@@ -65,41 +65,28 @@ import { logger, cloneDeep, mergeComponents } from './utils';
|
|
|
65
65
|
|
|
66
66
|
class Table extends BaseComponent {
|
|
67
67
|
constructor(props, context) {
|
|
68
|
-
|
|
68
|
+
super(props); // TODO: notify when data don't have key
|
|
69
69
|
|
|
70
|
-
super(props);
|
|
71
|
-
_this = this;
|
|
72
|
-
|
|
73
|
-
// TODO: notify when data don't have key
|
|
74
70
|
this._warnIfNoKey = () => {
|
|
75
71
|
if ((this.props.rowSelection || this.props.expandedRowRender) && some(this.props.dataSource, record => this.foundation.getRecordKey(record) == null)) {
|
|
76
72
|
logger.error('You must specify a key for each element in the dataSource or use "rowKey" to specify an attribute name as the primary key!');
|
|
77
73
|
}
|
|
78
74
|
};
|
|
79
75
|
|
|
80
|
-
this._invokeRowSelection =
|
|
81
|
-
const func = get(
|
|
76
|
+
this._invokeRowSelection = (funcName, ...args) => {
|
|
77
|
+
const func = get(this.state, ['rowSelection', funcName]);
|
|
82
78
|
|
|
83
79
|
if (typeof func === 'function') {
|
|
84
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
85
|
-
args[_key - 1] = arguments[_key];
|
|
86
|
-
}
|
|
87
|
-
|
|
88
80
|
func(...args);
|
|
89
81
|
}
|
|
90
82
|
};
|
|
91
83
|
|
|
92
|
-
this._invokeColumnFn =
|
|
84
|
+
this._invokeColumnFn = (key, funcName, ...args) => {
|
|
93
85
|
if (key && funcName) {
|
|
94
|
-
const column =
|
|
95
|
-
|
|
86
|
+
const column = this.foundation.getQuery(key);
|
|
96
87
|
const func = get(column, funcName, null);
|
|
97
88
|
|
|
98
89
|
if (typeof func === 'function') {
|
|
99
|
-
for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
|
100
|
-
args[_key2 - 2] = arguments[_key2];
|
|
101
|
-
}
|
|
102
|
-
|
|
103
90
|
func(...args);
|
|
104
91
|
}
|
|
105
92
|
}
|
|
@@ -128,29 +115,19 @@ class Table extends BaseComponent {
|
|
|
128
115
|
this.getColumns = (columns, children) => !_Array$isArray(columns) || !columns || !columns.length ? getColumns(children) : columns; // @ts-ignore
|
|
129
116
|
|
|
130
117
|
|
|
131
|
-
this.getCellWidths =
|
|
132
|
-
return _this.foundation.getCellWidths(...arguments);
|
|
133
|
-
}; // @ts-ignore
|
|
118
|
+
this.getCellWidths = (...args) => this.foundation.getCellWidths(...args); // @ts-ignore
|
|
134
119
|
|
|
135
120
|
|
|
136
|
-
this.setHeadWidths =
|
|
137
|
-
return _this.foundation.setHeadWidths(...arguments);
|
|
138
|
-
}; // @ts-ignore
|
|
121
|
+
this.setHeadWidths = (...args) => this.foundation.setHeadWidths(...args); // @ts-ignore
|
|
139
122
|
|
|
140
123
|
|
|
141
|
-
this.getHeadWidths =
|
|
142
|
-
return _this.foundation.getHeadWidths(...arguments);
|
|
143
|
-
}; // @ts-ignore
|
|
124
|
+
this.getHeadWidths = (...args) => this.foundation.getHeadWidths(...args); // @ts-ignore
|
|
144
125
|
|
|
145
126
|
|
|
146
|
-
this.mergedRowExpandable =
|
|
147
|
-
return _this.foundation.mergedRowExpandable(...arguments);
|
|
148
|
-
}; // @ts-ignore
|
|
127
|
+
this.mergedRowExpandable = (...args) => this.foundation.mergedRowExpandable(...args); // @ts-ignore
|
|
149
128
|
|
|
150
129
|
|
|
151
|
-
this.setBodyHasScrollbar =
|
|
152
|
-
return _this.foundation.setBodyHasScrollbar(...arguments);
|
|
153
|
-
};
|
|
130
|
+
this.setBodyHasScrollbar = (...args) => this.foundation.setBodyHasScrollbar(...args);
|
|
154
131
|
|
|
155
132
|
this.handleWheel = event => {
|
|
156
133
|
const {
|
|
@@ -295,13 +272,11 @@ class Table extends BaseComponent {
|
|
|
295
272
|
}
|
|
296
273
|
};
|
|
297
274
|
|
|
298
|
-
this.renderSelection =
|
|
299
|
-
let record = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
300
|
-
let inHeader = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
275
|
+
this.renderSelection = (record = {}, inHeader = false) => {
|
|
301
276
|
const {
|
|
302
277
|
rowSelection,
|
|
303
278
|
disabledRowKeysSet
|
|
304
|
-
} =
|
|
279
|
+
} = this.state;
|
|
305
280
|
|
|
306
281
|
if (rowSelection && typeof rowSelection === 'object') {
|
|
307
282
|
const {
|
|
@@ -313,25 +288,21 @@ class Table extends BaseComponent {
|
|
|
313
288
|
|
|
314
289
|
if (inHeader) {
|
|
315
290
|
const columnKey = get(rowSelection, 'key', strings.DEFAULT_KEY_COLUMN_SELECTION);
|
|
316
|
-
const allRowKeys =
|
|
317
|
-
const allRowKeysSet =
|
|
318
|
-
|
|
319
|
-
const
|
|
320
|
-
|
|
321
|
-
const hasRowSelected = _this.foundation.hasRowSelected(selectedRowKeys, allRowKeysSet);
|
|
322
|
-
|
|
291
|
+
const allRowKeys = this.cachedFilteredSortedRowKeys;
|
|
292
|
+
const allRowKeysSet = this.cachedFilteredSortedRowKeysSet;
|
|
293
|
+
const allIsSelected = this.foundation.allIsSelected(selectedRowKeysSet, disabledRowKeysSet, allRowKeys);
|
|
294
|
+
const hasRowSelected = this.foundation.hasRowSelected(selectedRowKeys, allRowKeysSet);
|
|
323
295
|
return /*#__PURE__*/React.createElement(ColumnSelection, {
|
|
324
296
|
disabled: disabled,
|
|
325
297
|
key: columnKey,
|
|
326
298
|
selected: allIsSelected,
|
|
327
299
|
indeterminate: hasRowSelected && !allIsSelected,
|
|
328
300
|
onChange: (status, e) => {
|
|
329
|
-
|
|
301
|
+
this.toggleSelectAllRow(status, e);
|
|
330
302
|
}
|
|
331
303
|
});
|
|
332
304
|
} else {
|
|
333
|
-
const key =
|
|
334
|
-
|
|
305
|
+
const key = this.foundation.getRecordKey(record);
|
|
335
306
|
const selected = selectedRowKeysSet.has(key);
|
|
336
307
|
|
|
337
308
|
const checkboxPropsFn = () => typeof getCheckboxProps === 'function' ? getCheckboxProps(record) : {};
|
|
@@ -339,7 +310,7 @@ class Table extends BaseComponent {
|
|
|
339
310
|
return /*#__PURE__*/React.createElement(ColumnSelection, {
|
|
340
311
|
getCheckboxProps: checkboxPropsFn,
|
|
341
312
|
selected: selected,
|
|
342
|
-
onChange: (status, e) =>
|
|
313
|
+
onChange: (status, e) => this.toggleSelectRow(status, key, e)
|
|
343
314
|
});
|
|
344
315
|
}
|
|
345
316
|
}
|
|
@@ -347,15 +318,11 @@ class Table extends BaseComponent {
|
|
|
347
318
|
return null;
|
|
348
319
|
};
|
|
349
320
|
|
|
350
|
-
this.renderRowSelectionCallback =
|
|
351
|
-
let record = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
352
|
-
return _this.renderSelection(record);
|
|
353
|
-
};
|
|
321
|
+
this.renderRowSelectionCallback = (text, record = {}) => this.renderSelection(record);
|
|
354
322
|
|
|
355
323
|
this.renderTitleSelectionCallback = () => this.renderSelection(null, true);
|
|
356
324
|
|
|
357
|
-
this.normalizeSelectionColumn =
|
|
358
|
-
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
325
|
+
this.normalizeSelectionColumn = (props = {}) => {
|
|
359
326
|
const {
|
|
360
327
|
rowSelection,
|
|
361
328
|
prefixCls
|
|
@@ -373,16 +340,15 @@ class Table extends BaseComponent {
|
|
|
373
340
|
}
|
|
374
341
|
|
|
375
342
|
column.className = classnames(column.className, "".concat(prefixCls, "-column-selection"));
|
|
376
|
-
column.title =
|
|
377
|
-
column.render =
|
|
343
|
+
column.title = this.renderTitleSelectionCallback;
|
|
344
|
+
column.render = this.renderRowSelectionCallback;
|
|
378
345
|
}
|
|
379
346
|
|
|
380
347
|
return column;
|
|
381
348
|
}; // If there is a scroll bar, manually construct a column and insert it into the header
|
|
382
349
|
|
|
383
350
|
|
|
384
|
-
this.normalizeScrollbarColumn =
|
|
385
|
-
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
351
|
+
this.normalizeScrollbarColumn = (props = {}) => {
|
|
386
352
|
const {
|
|
387
353
|
scrollbarWidth = 0
|
|
388
354
|
} = props;
|
|
@@ -401,33 +367,27 @@ class Table extends BaseComponent {
|
|
|
401
367
|
*/
|
|
402
368
|
|
|
403
369
|
|
|
404
|
-
this.renderExpandIcon =
|
|
405
|
-
let record = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
406
|
-
let isNested = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
407
|
-
let groupKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
370
|
+
this.renderExpandIcon = (record = {}, isNested = false, groupKey = null) => {
|
|
408
371
|
const {
|
|
409
372
|
expandedRowKeys
|
|
410
|
-
} =
|
|
373
|
+
} = this.state;
|
|
411
374
|
const {
|
|
412
375
|
expandIcon
|
|
413
|
-
} =
|
|
414
|
-
const key = typeof groupKey === 'string' || typeof groupKey === 'number' ? groupKey :
|
|
376
|
+
} = this.props;
|
|
377
|
+
const key = typeof groupKey === 'string' || typeof groupKey === 'number' ? groupKey : this.foundation.getRecordKey(record);
|
|
415
378
|
return /*#__PURE__*/React.createElement(ExpandedIcon, {
|
|
416
379
|
key: key,
|
|
417
380
|
componentType: isNested ? 'tree' : 'expand',
|
|
418
381
|
expanded: includes(expandedRowKeys, key),
|
|
419
382
|
expandIcon: expandIcon,
|
|
420
|
-
onClick: (expanded, e) =>
|
|
383
|
+
onClick: (expanded, e) => this.handleRowExpanded(expanded, key, e)
|
|
421
384
|
});
|
|
422
385
|
}; // @ts-ignore
|
|
423
386
|
|
|
424
387
|
|
|
425
|
-
this.handleRowExpanded =
|
|
426
|
-
return _this.foundation.handleRowExpanded(...arguments);
|
|
427
|
-
};
|
|
388
|
+
this.handleRowExpanded = (...args) => this.foundation.handleRowExpanded(...args);
|
|
428
389
|
|
|
429
|
-
this.normalizeExpandColumn =
|
|
430
|
-
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
390
|
+
this.normalizeExpandColumn = (props = {}) => {
|
|
431
391
|
let column = null;
|
|
432
392
|
const {
|
|
433
393
|
prefixCls,
|
|
@@ -439,12 +399,7 @@ class Table extends BaseComponent {
|
|
|
439
399
|
key: strings.DEFAULT_KEY_COLUMN_EXPAND
|
|
440
400
|
};
|
|
441
401
|
column.className = classnames(column.className, "".concat(prefixCls, "-column-expand"));
|
|
442
|
-
column.render = expandIcon !== false ?
|
|
443
|
-
let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
444
|
-
let record = arguments.length > 1 ? arguments[1] : undefined;
|
|
445
|
-
let index = arguments.length > 2 ? arguments[2] : undefined;
|
|
446
|
-
return _this.adapter.mergedRowExpandable(record) ? _this.renderExpandIcon(record) : null;
|
|
447
|
-
} : () => null;
|
|
402
|
+
column.render = expandIcon !== false ? (text = '', record, index) => this.adapter.mergedRowExpandable(record) ? this.renderExpandIcon(record) : null : () => null;
|
|
448
403
|
return column;
|
|
449
404
|
};
|
|
450
405
|
/**
|
|
@@ -454,34 +409,30 @@ class Table extends BaseComponent {
|
|
|
454
409
|
*/
|
|
455
410
|
|
|
456
411
|
|
|
457
|
-
this.addFnsInColumn =
|
|
458
|
-
let column = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
459
|
-
|
|
412
|
+
this.addFnsInColumn = (column = {}) => {
|
|
460
413
|
if (column && (column.sorter || column.filters || column.useFullRender)) {
|
|
461
414
|
const {
|
|
462
415
|
dataIndex,
|
|
463
416
|
title: rawTitle,
|
|
464
417
|
useFullRender
|
|
465
418
|
} = column;
|
|
466
|
-
|
|
467
|
-
const curQuery = _this.foundation.getQuery(dataIndex);
|
|
468
|
-
|
|
419
|
+
const curQuery = this.foundation.getQuery(dataIndex);
|
|
469
420
|
const titleMap = {};
|
|
470
421
|
const titleArr = []; // useFullRender adds select buttons to each column
|
|
471
422
|
|
|
472
423
|
if (useFullRender) {
|
|
473
|
-
titleMap.selection =
|
|
424
|
+
titleMap.selection = this.renderSelection(null, true);
|
|
474
425
|
}
|
|
475
426
|
|
|
476
427
|
const stateSortOrder = get(curQuery, 'sortOrder');
|
|
477
428
|
const defaultSortOrder = get(curQuery, 'defaultSortOrder', false);
|
|
478
|
-
const sortOrder =
|
|
429
|
+
const sortOrder = this.foundation.isSortOrderValid(stateSortOrder) ? stateSortOrder : defaultSortOrder;
|
|
479
430
|
|
|
480
431
|
if (typeof column.sorter === 'function' || column.sorter === true) {
|
|
481
432
|
const sorter = /*#__PURE__*/React.createElement(ColumnSorter, {
|
|
482
433
|
key: strings.DEFAULT_KEY_COLUMN_SORTER,
|
|
483
434
|
sortOrder: sortOrder,
|
|
484
|
-
onClick: e =>
|
|
435
|
+
onClick: e => this.foundation.handleSort(column, e)
|
|
485
436
|
});
|
|
486
437
|
useFullRender && (titleMap.sorter = sorter);
|
|
487
438
|
titleArr.push(sorter);
|
|
@@ -491,8 +442,8 @@ class Table extends BaseComponent {
|
|
|
491
442
|
const filter = /*#__PURE__*/React.createElement(ColumnFilter, _Object$assign({
|
|
492
443
|
key: strings.DEFAULT_KEY_COLUMN_FILTER
|
|
493
444
|
}, curQuery, {
|
|
494
|
-
onFilterDropdownVisibleChange: visible =>
|
|
495
|
-
onSelect: data =>
|
|
445
|
+
onFilterDropdownVisibleChange: visible => this.foundation.toggleShowFilter(dataIndex, visible),
|
|
446
|
+
onSelect: data => this.foundation.handleFilterSelect(dataIndex, data)
|
|
496
447
|
}));
|
|
497
448
|
useFullRender && (titleMap.filter = filter);
|
|
498
449
|
titleArr.push(filter);
|
|
@@ -541,8 +492,7 @@ class Table extends BaseComponent {
|
|
|
541
492
|
});
|
|
542
493
|
};
|
|
543
494
|
|
|
544
|
-
this.renderTitle =
|
|
545
|
-
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
495
|
+
this.renderTitle = (props = {}) => {
|
|
546
496
|
let {
|
|
547
497
|
title
|
|
548
498
|
} = props;
|
|
@@ -560,16 +510,14 @@ class Table extends BaseComponent {
|
|
|
560
510
|
}, title) : null;
|
|
561
511
|
};
|
|
562
512
|
|
|
563
|
-
this.renderEmpty =
|
|
564
|
-
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
513
|
+
this.renderEmpty = (props = {}) => {
|
|
565
514
|
const {
|
|
566
515
|
prefixCls,
|
|
567
516
|
empty,
|
|
568
517
|
dataSource
|
|
569
518
|
} = props;
|
|
570
519
|
const wrapCls = "".concat(prefixCls, "-placeholder");
|
|
571
|
-
|
|
572
|
-
const isEmpty = _this.foundation.isEmpty(dataSource);
|
|
520
|
+
const isEmpty = this.foundation.isEmpty(dataSource);
|
|
573
521
|
|
|
574
522
|
if (!isEmpty) {
|
|
575
523
|
return null;
|
|
@@ -585,8 +533,7 @@ class Table extends BaseComponent {
|
|
|
585
533
|
}, empty || locale.emptyText)));
|
|
586
534
|
};
|
|
587
535
|
|
|
588
|
-
this.renderFooter =
|
|
589
|
-
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
536
|
+
this.renderFooter = (props = {}) => {
|
|
590
537
|
let {
|
|
591
538
|
footer
|
|
592
539
|
} = props;
|
|
@@ -703,13 +650,10 @@ class Table extends BaseComponent {
|
|
|
703
650
|
const childrenColumnName = 'children';
|
|
704
651
|
let columns = cloneDeep(cachedColumns); // eslint-disable-next-line @typescript-eslint/no-shadow
|
|
705
652
|
|
|
706
|
-
const addFns =
|
|
707
|
-
let columns = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
708
|
-
|
|
653
|
+
const addFns = (columns = []) => {
|
|
709
654
|
if (_Array$isArray(columns) && columns.length) {
|
|
710
655
|
each(columns, (column, index, originColumns) => {
|
|
711
|
-
const newColumn =
|
|
712
|
-
|
|
656
|
+
const newColumn = this.addFnsInColumn(column);
|
|
713
657
|
const children = column[childrenColumnName];
|
|
714
658
|
|
|
715
659
|
if (_Array$isArray(children) && children.length) {
|
|
@@ -839,8 +783,6 @@ class Table extends BaseComponent {
|
|
|
839
783
|
}
|
|
840
784
|
|
|
841
785
|
get adapter() {
|
|
842
|
-
var _this2 = this;
|
|
843
|
-
|
|
844
786
|
return _Object$assign(_Object$assign({}, super.adapter), {
|
|
845
787
|
resetScrollY: () => {
|
|
846
788
|
if (this.bodyWrapRef.current) {
|
|
@@ -892,12 +834,10 @@ class Table extends BaseComponent {
|
|
|
892
834
|
setExpandedRowKeys: expandedRowKeys => this.setState({
|
|
893
835
|
expandedRowKeys: [...expandedRowKeys]
|
|
894
836
|
}),
|
|
895
|
-
setQuery:
|
|
896
|
-
let
|
|
897
|
-
let queries = [..._this2.state.queries];
|
|
837
|
+
setQuery: (query = {}) => {
|
|
838
|
+
let queries = [...this.state.queries];
|
|
898
839
|
queries = mergeQueries(query, queries);
|
|
899
|
-
|
|
900
|
-
_this2.setState({
|
|
840
|
+
this.setState({
|
|
901
841
|
queries
|
|
902
842
|
});
|
|
903
843
|
},
|
|
@@ -929,43 +869,13 @@ class Table extends BaseComponent {
|
|
|
929
869
|
getCachedFilteredSortedRowKeys: () => this.cachedFilteredSortedRowKeys,
|
|
930
870
|
getCachedFilteredSortedRowKeysSet: () => this.cachedFilteredSortedRowKeysSet,
|
|
931
871
|
notifyFilterDropdownVisibleChange: (visible, dataIndex) => this._invokeColumnFn(dataIndex, 'onFilterDropdownVisibleChange', visible),
|
|
932
|
-
notifyChange:
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
return _this2.props.onExpandedRowsChange(...arguments);
|
|
940
|
-
},
|
|
941
|
-
notifySelect: function () {
|
|
942
|
-
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
943
|
-
args[_key3] = arguments[_key3];
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
return _this2._invokeRowSelection('onSelect', ...args);
|
|
947
|
-
},
|
|
948
|
-
notifySelectAll: function () {
|
|
949
|
-
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
950
|
-
args[_key4] = arguments[_key4];
|
|
951
|
-
}
|
|
952
|
-
|
|
953
|
-
return _this2._invokeRowSelection('onSelectAll', ...args);
|
|
954
|
-
},
|
|
955
|
-
notifySelectInvert: function () {
|
|
956
|
-
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
957
|
-
args[_key5] = arguments[_key5];
|
|
958
|
-
}
|
|
959
|
-
|
|
960
|
-
return _this2._invokeRowSelection('onSelectInvert', ...args);
|
|
961
|
-
},
|
|
962
|
-
notifySelectionChange: function () {
|
|
963
|
-
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
964
|
-
args[_key6] = arguments[_key6];
|
|
965
|
-
}
|
|
966
|
-
|
|
967
|
-
return _this2._invokeRowSelection('onChange', ...args);
|
|
968
|
-
},
|
|
872
|
+
notifyChange: (...args) => this.props.onChange(...args),
|
|
873
|
+
notifyExpand: (...args) => this.props.onExpand(...args),
|
|
874
|
+
notifyExpandedRowsChange: (...args) => this.props.onExpandedRowsChange(...args),
|
|
875
|
+
notifySelect: (...args) => this._invokeRowSelection('onSelect', ...args),
|
|
876
|
+
notifySelectAll: (...args) => this._invokeRowSelection('onSelectAll', ...args),
|
|
877
|
+
notifySelectInvert: (...args) => this._invokeRowSelection('onSelectInvert', ...args),
|
|
878
|
+
notifySelectionChange: (...args) => this._invokeRowSelection('onChange', ...args),
|
|
969
879
|
isAnyColumnFixed: columns => some(this.getColumns(columns || this.props.columns, this.props.children), column => Boolean(column.fixed)),
|
|
970
880
|
useFixedHeader: () => {
|
|
971
881
|
const {
|
|
@@ -978,12 +888,10 @@ class Table extends BaseComponent {
|
|
|
978
888
|
|
|
979
889
|
return false;
|
|
980
890
|
},
|
|
981
|
-
setHeadWidths:
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
if (!equalWith(_this2.state.headWidths[index], headWidths)) {
|
|
891
|
+
setHeadWidths: (headWidths, index = 0) => {
|
|
892
|
+
if (!equalWith(this.state.headWidths[index], headWidths)) {
|
|
985
893
|
// The map call depends on the last state
|
|
986
|
-
|
|
894
|
+
this.setState(state => {
|
|
987
895
|
const newHeadWidths = [...state.headWidths];
|
|
988
896
|
newHeadWidths[index] = [...headWidths];
|
|
989
897
|
return {
|
|
@@ -992,23 +900,18 @@ class Table extends BaseComponent {
|
|
|
992
900
|
});
|
|
993
901
|
}
|
|
994
902
|
},
|
|
995
|
-
getHeadWidths:
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
if (_this2.state.headWidths.length && typeof index === 'number') {
|
|
999
|
-
const configs = _this2.state.headWidths[index] || [];
|
|
903
|
+
getHeadWidths: (index = 0) => {
|
|
904
|
+
if (this.state.headWidths.length && typeof index === 'number') {
|
|
905
|
+
const configs = this.state.headWidths[index] || [];
|
|
1000
906
|
return _mapInstanceProperty(configs).call(configs, item => item.width);
|
|
1001
907
|
}
|
|
1002
908
|
|
|
1003
909
|
return [];
|
|
1004
910
|
},
|
|
1005
911
|
// This method is called by row rendering function
|
|
1006
|
-
getCellWidths:
|
|
1007
|
-
let flattenedWidths = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
1008
|
-
let ignoreScrollBarKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1009
|
-
|
|
912
|
+
getCellWidths: (flattenedColumns, flattenedWidths = null, ignoreScrollBarKey = false) => {
|
|
1010
913
|
if (_Array$isArray(flattenedColumns) && flattenedColumns.length) {
|
|
1011
|
-
flattenedWidths = flattenedWidths == null &&
|
|
914
|
+
flattenedWidths = flattenedWidths == null && this.state.headWidths.length ? flattenDeep(this.state.headWidths) : [];
|
|
1012
915
|
|
|
1013
916
|
if (_Array$isArray(flattenedWidths) && flattenedWidths.length) {
|
|
1014
917
|
return _reduceInstanceProperty(flattenedColumns).call(flattenedColumns, (result, column) => {
|
|
@@ -39,16 +39,14 @@ export default class TableCell extends BaseComponent {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
get adapter() {
|
|
42
|
-
var _this = this;
|
|
43
|
-
|
|
44
42
|
return _Object$assign(_Object$assign({}, super.adapter), {
|
|
45
|
-
notifyClick:
|
|
43
|
+
notifyClick: (...args) => {
|
|
46
44
|
const {
|
|
47
45
|
onClick
|
|
48
|
-
} =
|
|
46
|
+
} = this.props;
|
|
49
47
|
|
|
50
48
|
if (typeof onClick === 'function') {
|
|
51
|
-
onClick(...
|
|
49
|
+
onClick(...args);
|
|
52
50
|
}
|
|
53
51
|
}
|
|
54
52
|
});
|
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
2
|
import Context from './table-context';
|
|
3
3
|
|
|
4
|
-
const TableContextProvider =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} = _ref;
|
|
4
|
+
const TableContextProvider = ({
|
|
5
|
+
children,
|
|
6
|
+
anyColumnFixed,
|
|
7
|
+
flattenedColumns,
|
|
8
|
+
tableWidth,
|
|
9
|
+
headWidths,
|
|
10
|
+
setHeadWidths,
|
|
11
|
+
getHeadWidths,
|
|
12
|
+
getCellWidths,
|
|
13
|
+
handleRowExpanded,
|
|
14
|
+
renderExpandIcon,
|
|
15
|
+
renderSelection,
|
|
16
|
+
getVirtualizedListRef,
|
|
17
|
+
setBodyHasScrollbar
|
|
18
|
+
}) => {
|
|
20
19
|
const tableContextValue = useMemo(() => ({
|
|
21
20
|
anyColumnFixed,
|
|
22
21
|
flattenedColumns,
|
|
@@ -15,10 +15,7 @@ import TableHeaderRow from './TableHeaderRow';
|
|
|
15
15
|
function parseHeaderRows(columns) {
|
|
16
16
|
const rows = []; // eslint-disable-next-line @typescript-eslint/no-shadow
|
|
17
17
|
|
|
18
|
-
function fillRowCells(columns, colIndex) {
|
|
19
|
-
let parents = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
20
|
-
let rowIndex = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
21
|
-
let level = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
|
18
|
+
function fillRowCells(columns, colIndex, parents = [], rowIndex = 0, level = 0) {
|
|
22
19
|
// Init rows
|
|
23
20
|
rows[rowIndex] = rows[rowIndex] || [];
|
|
24
21
|
let currentColIndex = colIndex;
|
package/lib/es/table/utils.js
CHANGED
|
@@ -17,11 +17,9 @@ const scrollbarMeasure = {
|
|
|
17
17
|
* @returns {number}
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
export function measureScrollbar() {
|
|
20
|
+
export function measureScrollbar(direction = 'vertical') {
|
|
21
21
|
var _context;
|
|
22
22
|
|
|
23
|
-
let direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'vertical';
|
|
24
|
-
|
|
25
23
|
if (typeof document === 'undefined' || typeof window === 'undefined') {
|
|
26
24
|
return 0;
|
|
27
25
|
}
|
package/lib/es/tabs/TabBar.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { MouseEvent, ReactNode } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import {
|
|
3
|
+
import { PlainTab, TabBarProps } from './interface';
|
|
4
4
|
export interface TabBarState {
|
|
5
5
|
endInd: number;
|
|
6
6
|
rePosKey: number;
|
|
@@ -22,6 +22,8 @@ declare class TabBar extends React.Component<TabBarProps, TabBarState> {
|
|
|
22
22
|
tabBarExtraContent: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
23
23
|
tabPosition: PropTypes.Requireable<string>;
|
|
24
24
|
type: PropTypes.Requireable<string>;
|
|
25
|
+
closable: PropTypes.Requireable<boolean>;
|
|
26
|
+
deleteTabItem: PropTypes.Requireable<(...args: any[]) => any>;
|
|
25
27
|
};
|
|
26
28
|
uuid: string;
|
|
27
29
|
constructor(props: TabBarProps);
|
package/lib/es/tabs/TabBar.js
CHANGED
|
@@ -24,7 +24,7 @@ import OverflowList from '../overflowList';
|
|
|
24
24
|
import Dropdown from '../dropdown';
|
|
25
25
|
import Button from '../button';
|
|
26
26
|
import { isEmpty } from 'lodash-es';
|
|
27
|
-
import { IconChevronRight,
|
|
27
|
+
import { IconChevronLeft, IconChevronRight, IconClose } from '@douyinfe/semi-icons';
|
|
28
28
|
import { getUuidv4 } from '@douyinfe/semi-foundation/lib/es/utils/uuid';
|
|
29
29
|
|
|
30
30
|
class TabBar extends React.Component {
|
|
@@ -51,9 +51,15 @@ class TabBar extends React.Component {
|
|
|
51
51
|
|
|
52
52
|
this.renderTabItem = panel => {
|
|
53
53
|
const {
|
|
54
|
-
size
|
|
54
|
+
size,
|
|
55
|
+
type,
|
|
56
|
+
deleteTabItem
|
|
55
57
|
} = this.props;
|
|
56
58
|
const panelIcon = panel.icon ? this.renderIcon(panel.icon) : null;
|
|
59
|
+
const closableIcon = type === 'card' && panel.closable ? /*#__PURE__*/React.createElement(IconClose, {
|
|
60
|
+
className: "".concat(cssClasses.TABS_TAB, "-icon-close"),
|
|
61
|
+
onClick: e => deleteTabItem(panel.itemKey, e)
|
|
62
|
+
}) : null;
|
|
57
63
|
let events = {};
|
|
58
64
|
const key = panel.itemKey;
|
|
59
65
|
|
|
@@ -76,7 +82,7 @@ class TabBar extends React.Component {
|
|
|
76
82
|
}, events, {
|
|
77
83
|
className: className,
|
|
78
84
|
key: this._getItemKey(key)
|
|
79
|
-
}), panelIcon, panel.tab);
|
|
85
|
+
}), panelIcon, panel.tab, closableIcon);
|
|
80
86
|
};
|
|
81
87
|
|
|
82
88
|
this.renderTabComponents = list => _mapInstanceProperty(list).call(list, panel => this.renderTabItem(panel));
|
|
@@ -278,6 +284,8 @@ TabBar.propTypes = {
|
|
|
278
284
|
style: PropTypes.object,
|
|
279
285
|
tabBarExtraContent: PropTypes.node,
|
|
280
286
|
tabPosition: PropTypes.oneOf(strings.POSITION_MAP),
|
|
281
|
-
type: PropTypes.oneOf(strings.TYPE_MAP)
|
|
287
|
+
type: PropTypes.oneOf(strings.TYPE_MAP),
|
|
288
|
+
closable: PropTypes.bool,
|
|
289
|
+
deleteTabItem: PropTypes.func
|
|
282
290
|
};
|
|
283
291
|
export default TabBar;
|
package/lib/es/tabs/TabPane.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { PureComponent, ReactNode } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import {
|
|
3
|
+
import { PlainTab, TabPaneProps } from './interface';
|
|
4
4
|
declare class TabPane extends PureComponent<TabPaneProps> {
|
|
5
5
|
static isTabPane: boolean;
|
|
6
6
|
static contextType: React.Context<import("./interface").TabContextValue>;
|
|
@@ -12,6 +12,7 @@ declare class TabPane extends PureComponent<TabPaneProps> {
|
|
|
12
12
|
itemKey: PropTypes.Requireable<string>;
|
|
13
13
|
tab: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
14
14
|
icon: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
15
|
+
closable: PropTypes.Requireable<boolean>;
|
|
15
16
|
};
|
|
16
17
|
lastActiveKey: string;
|
|
17
18
|
ref: React.RefObject<HTMLDivElement>;
|
package/lib/es/tabs/TabPane.js
CHANGED
|
@@ -15,7 +15,7 @@ var __rest = this && this.__rest || function (s, e) {
|
|
|
15
15
|
return t;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
import React, {
|
|
18
|
+
import React, { createRef, PureComponent } from 'react';
|
|
19
19
|
import PropTypes from 'prop-types';
|
|
20
20
|
import cls from 'classnames';
|
|
21
21
|
import { cssClasses } from '@douyinfe/semi-foundation/lib/es/tabs/constants';
|
|
@@ -131,6 +131,7 @@ TabPane.propTypes = {
|
|
|
131
131
|
disabled: PropTypes.bool,
|
|
132
132
|
itemKey: PropTypes.string,
|
|
133
133
|
tab: PropTypes.node,
|
|
134
|
-
icon: PropTypes.node
|
|
134
|
+
icon: PropTypes.node,
|
|
135
|
+
closable: PropTypes.bool
|
|
135
136
|
};
|
|
136
137
|
export default TabPane;
|