@ucloud-fe/react-components 1.16.0 → 1.17.1

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.
@@ -801,6 +801,7 @@ var MultipleListSelector = /*#__PURE__*/_react.default.memo(function MultipleSel
801
801
  value = props.value,
802
802
  onChange = props.onChange,
803
803
  placeholder = props.placeholder,
804
+ renderContent = props.renderContent,
804
805
  search = props.search,
805
806
  _props$searchValue = props.searchValue,
806
807
  searchValue = _props$searchValue === void 0 ? '' : _props$searchValue,
@@ -825,10 +826,10 @@ var MultipleListSelector = /*#__PURE__*/_react.default.memo(function MultipleSel
825
826
  (0, _newArrowCheck2.default)(this, _this14);
826
827
  return {
827
828
  key: v,
828
- children: childrenMap.has(v) ? childrenMap.get(v) : v
829
+ children: childrenMap.has(v) ? renderContent ? renderContent(v) : childrenMap.get(v) : v
829
830
  };
830
831
  }.bind(this));
831
- }.bind(this), [childrenMap, value]);
832
+ }.bind(this), [childrenMap, value, renderContent]);
832
833
  var handleClose = (0, _react.useCallback)(function (key) {
833
834
  var _this15 = this;
834
835
 
@@ -923,6 +924,7 @@ var MultipleSelector = /*#__PURE__*/_react.default.memo(function MultipleSelecto
923
924
  value = props.value,
924
925
  onChange = props.onChange,
925
926
  placeholder = props.placeholder,
927
+ renderContent = props.renderContent,
926
928
  search = props.search,
927
929
  _props$searchValue2 = props.searchValue,
928
930
  searchValue = _props$searchValue2 === void 0 ? '' : _props$searchValue2,
@@ -946,10 +948,10 @@ var MultipleSelector = /*#__PURE__*/_react.default.memo(function MultipleSelecto
946
948
  (0, _newArrowCheck2.default)(this, _this17);
947
949
  return {
948
950
  key: v,
949
- children: childrenMap.has(v) ? childrenMap.get(v) : v
951
+ children: childrenMap.has(v) ? renderContent ? renderContent(v) : childrenMap.get(v) : v
950
952
  };
951
953
  }.bind(this));
952
- }.bind(this), [childrenMap, value]);
954
+ }.bind(this), [childrenMap, value, renderContent]);
953
955
  var handleClose = (0, _react.useCallback)(function (key) {
954
956
  var _this18 = this;
955
957
 
@@ -237,6 +237,16 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
237
237
 
238
238
  (0, _newArrowCheck2.default)(this, _this6);
239
239
 
240
+ if (rowSelection.resetSelected) {
241
+ _this2.onSelectedRowKeysChange({});
242
+
243
+ _this2.setState({
244
+ indeterminateSelectedRowKeyMap: {}
245
+ });
246
+
247
+ return;
248
+ }
249
+
240
250
  if (rowSelection.multiple !== false && rowSelection.linkage && flatDataSourceKeys.length) {
241
251
  var _Object$keys$reduce = Object.keys(selectedRowKeyMap).reduce(function (p, key) {
242
252
  (0, _newArrowCheck2.default)(this, _this7);
@@ -406,18 +416,34 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
406
416
  var _this14 = this;
407
417
 
408
418
  (0, _newArrowCheck2.default)(this, _this3);
409
- var rowSelection = _this2.props.rowSelection;
419
+ var _this2$props = _this2.props,
420
+ rowSelection = _this2$props.rowSelection,
421
+ dataSource = _this2$props.dataSource;
410
422
  var parentSelectedRowKeys = _this2.state.parentSelectedRowKeys;
411
423
  if (!rowSelection) return;
412
424
  var selectedRowKeys = [];
413
425
  (0, _each2.default)(selectedRowKeyMap, function (selected, key) {
414
426
  (0, _newArrowCheck2.default)(this, _this14);
415
427
  selected && selectedRowKeys.push(key);
428
+ }.bind(this)); // 计算所有选中的行数据,包括折叠的子项
429
+
430
+ var flatDataSource = _this2.flatDataSource(dataSource);
431
+
432
+ flatDataSource.forEach(function (item) {
433
+ (0, _newArrowCheck2.default)(this, _this14);
434
+
435
+ if (selectedRowKeyMap[item.key]) {
436
+ _this2._selectedRowsMap[item.key] = item.record;
437
+ }
416
438
  }.bind(this));
417
439
 
418
440
  if ((0, _isObject2.default)(rowSelection)) {
419
441
  if (rowSelection.onChange) {
420
- rowSelection.onChange(selectedRowKeys);
442
+ var selectedRows = selectedRowKeys.map(function (key) {
443
+ (0, _newArrowCheck2.default)(this, _this14);
444
+ return _this2._selectedRowsMap[key];
445
+ }.bind(this));
446
+ rowSelection.onChange(selectedRowKeys, selectedRows);
421
447
  }
422
448
 
423
449
  if (!('selectedRowKeys' in rowSelection)) {
@@ -682,10 +708,10 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
682
708
  var _this20 = this;
683
709
 
684
710
  (0, _newArrowCheck2.default)(this, _this3);
685
- var _this2$props = _this2.props,
686
- dataSource = _this2$props.dataSource,
687
- handleSearch = _this2$props.handleSearch,
688
- doNotHandleCondition = _this2$props.doNotHandleCondition;
711
+ var _this2$props2 = _this2.props,
712
+ dataSource = _this2$props2.dataSource,
713
+ handleSearch = _this2$props2.handleSearch,
714
+ doNotHandleCondition = _this2$props2.doNotHandleCondition;
689
715
  var _this2$state2 = _this2.state,
690
716
  order = _this2$state2.order,
691
717
  searchValue = _this2$state2.searchValue;
@@ -1001,10 +1027,10 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
1001
1027
  var _this31 = this;
1002
1028
 
1003
1029
  (0, _newArrowCheck2.default)(this, _this3);
1004
- var _this2$props2 = _this2.props,
1005
- dragSorting = _this2$props2.dragSorting,
1006
- expandedRowRender = _this2$props2.expandedRowRender,
1007
- columns = _this2$props2.columns;
1030
+ var _this2$props3 = _this2.props,
1031
+ dragSorting = _this2$props3.dragSorting,
1032
+ expandedRowRender = _this2$props3.expandedRowRender,
1033
+ columns = _this2$props3.columns;
1008
1034
  if (!dragSorting) return false; // 排序暂不支持有展开行配置的table
1009
1035
 
1010
1036
  if (expandedRowRender || columns && columns.findIndex(function (column) {
@@ -1022,13 +1048,13 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
1022
1048
  var _this32 = this;
1023
1049
 
1024
1050
  (0, _newArrowCheck2.default)(this, _this3);
1025
- var _this2$props3 = _this2.props,
1026
- columns = _this2$props3.columns,
1027
- rowSelection = _this2$props3.rowSelection,
1028
- columnPlaceholder = _this2$props3.columnPlaceholder,
1029
- locale = _this2$props3.locale,
1030
- dataSource = _this2$props3.dataSource,
1031
- columnResizable = _this2$props3.columnResizable;
1051
+ var _this2$props4 = _this2.props,
1052
+ columns = _this2$props4.columns,
1053
+ rowSelection = _this2$props4.rowSelection,
1054
+ columnPlaceholder = _this2$props4.columnPlaceholder,
1055
+ locale = _this2$props4.locale,
1056
+ dataSource = _this2$props4.dataSource,
1057
+ columnResizable = _this2$props4.columnResizable;
1032
1058
  var _this2$state3 = _this2.state,
1033
1059
  _this2$state3$order = _this2$state3.order,
1034
1060
  currentOrder = _this2$state3$order === void 0 ? {} : _this2$state3$order,
@@ -1577,10 +1603,10 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
1577
1603
 
1578
1604
  _this2.onRow = function (record, index) {
1579
1605
  (0, _newArrowCheck2.default)(this, _this3);
1580
- var _this2$props4 = _this2.props,
1581
- _this2$props4$onRow = _this2$props4.onRow,
1582
- onRow = _this2$props4$onRow === void 0 ? noop : _this2$props4$onRow,
1583
- contextMenu = _this2$props4.contextMenu;
1606
+ var _this2$props5 = _this2.props,
1607
+ _this2$props5$onRow = _this2$props5.onRow,
1608
+ onRow = _this2$props5$onRow === void 0 ? noop : _this2$props5$onRow,
1609
+ contextMenu = _this2$props5.contextMenu;
1584
1610
  return _objectSpread(_objectSpread({}, onRow(record, index)), {}, {
1585
1611
  record: record,
1586
1612
  contextMenu: contextMenu
@@ -1608,7 +1634,8 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
1608
1634
  columnConfig: _props.defaultColumnConfig,
1609
1635
  searchValue: ''
1610
1636
  };
1611
- _this2.tableId = "uc_table_uid_".concat(uid++); // init pagination
1637
+ _this2.tableId = "uc_table_uid_".concat(uid++);
1638
+ _this2._selectedRowsMap = {}; // init pagination
1612
1639
 
1613
1640
  var _pagination = _props.pagination;
1614
1641
 
@@ -1665,9 +1692,15 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
1665
1692
 
1666
1693
  (0, _createClass2.default)(Table, [{
1667
1694
  key: "initLinkageRowSelectionMap",
1668
- value: function initLinkageRowSelectionMap(nowSelectedRowKeyMap, checked, key, flatDataSourceKeys, indeterminateSelectedRowKeyMap) {
1695
+ value: function initLinkageRowSelectionMap() {
1669
1696
  var _this41 = this;
1670
1697
 
1698
+ var nowSelectedRowKeyMap = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1699
+ var checked = arguments.length > 1 ? arguments[1] : undefined;
1700
+ var key = arguments.length > 2 ? arguments[2] : undefined;
1701
+ var flatDataSourceKeys = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
1702
+ var indeterminateSelectedRowKeyMap = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
1703
+
1671
1704
  if (!flatDataSourceKeys.length) {
1672
1705
  return {
1673
1706
  mergeMap: {},
@@ -1689,7 +1722,11 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
1689
1722
  }.bind(this)); // 禁用需要剔除的key
1690
1723
 
1691
1724
  var disabledItems = this.initDisabledOfRow(flatDataSourceKeys);
1692
- indeterminate[String(record.key)] = false; // 子被动全选
1725
+
1726
+ if (record) {
1727
+ indeterminate[String(record.key)] = false;
1728
+ } // 子被动全选
1729
+
1693
1730
 
1694
1731
  if (record && record.childrenKeys && record.childrenKeys.length > 0) {
1695
1732
  record.childrenKeys.forEach(function (childKey) {
@@ -1745,7 +1782,7 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
1745
1782
  }
1746
1783
  }
1747
1784
 
1748
- if (record.parent) {
1785
+ if (record && record.parent) {
1749
1786
  changeParentChecked(record.parent, checked, disabledItems);
1750
1787
  }
1751
1788
 
@@ -2089,7 +2126,12 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
2089
2126
  * 需配合 columns.children 使用,控制是否开启父子联动,默认关闭
2090
2127
  * @default false
2091
2128
  */
2092
- linkage: _propTypes.default.bool
2129
+ linkage: _propTypes.default.bool,
2130
+
2131
+ /**
2132
+ * dataSource变更时, 是否重置选中项 ,默认为false
2133
+ */
2134
+ resetSelected: _propTypes.default.bool
2093
2135
  }), _propTypes.default.oneOf([true])]),
2094
2136
 
2095
2137
  /** 拖拽排序 */
@@ -657,7 +657,7 @@ var TabBar = function TabBar(props) {
657
657
  justifyContent: "space-between",
658
658
  alignItems: "center"
659
659
  }, /*#__PURE__*/_react.default.createElement(_Box.default, {
660
- flex: 1,
660
+ flex: "1",
661
661
  className: (0, _classnames8.default)((0, _defineProperty2.default)({}, "".concat(_style2.prefixCls, "-srcoll-box"), 1))
662
662
  }, /*#__PURE__*/_react.default.createElement(ScrollableTabBarNode, props, /*#__PURE__*/_react.default.createElement(TabBarTabsNode, props), styleType === 'ink' ? /*#__PURE__*/_react.default.createElement(InkTabBarNode, props) : null)), /*#__PURE__*/_react.default.createElement(_Box.default, {
663
663
  justifyContent: "flex-end",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ucloud-fe/react-components",
3
- "version": "1.16.0",
3
+ "version": "1.17.1",
4
4
  "title": "UCloud react components",
5
5
  "description": "UCloud react components",
6
6
  "keywords": [