@kdcloudjs/table 1.2.0-canary.1 → 1.2.0-canary.2

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.
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  *
3
- * @kdcloudjs/table v1.1.6-canary.4
3
+ * @kdcloudjs/table v1.2.0-canary.1
4
4
  *
5
5
  * Copyright 2020-present, Kingdee, Inc.
6
6
  * All rights reserved.
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  *
3
- * @kdcloudjs/table v1.1.6-canary.4
3
+ * @kdcloudjs/table v1.2.0-canary.1
4
4
  *
5
5
  * Copyright 2020-present, Kingdee, Inc.
6
6
  * All rights reserved.
@@ -8029,6 +8029,9 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
8029
8029
 
8030
8030
 
8031
8031
 
8032
+ var fullRowsSetKey = 'fullRowsSetKey';
8033
+ var allEnableKeys = 'allEnableKeys';
8034
+ var selectValueSetKey = 'selectValueSetKey';
8032
8035
  function multiSelect() {
8033
8036
  var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
8034
8037
  return function multiSelectStep(pipeline) {
@@ -8059,10 +8062,9 @@ function multiSelect() {
8059
8062
  action: action
8060
8063
  });
8061
8064
  };
8062
-
8063
- var dataSource = pipeline.getDataSource();
8064
8065
  /** dataSource 中包含的所有 keys */
8065
8066
 
8067
+
8066
8068
  var fullKeySet = new Set();
8067
8069
  /** 所有有效的 keys(disable 状态为 false) */
8068
8070
 
@@ -8071,7 +8073,7 @@ function multiSelect() {
8071
8073
  var isAllChecked = set.size !== 0; // 当前不存在选中则默认为false
8072
8074
 
8073
8075
  var isAnyChecked = false;
8074
- var flatDataSource = Object(_utils__WEBPACK_IMPORTED_MODULE_17__["collectNodes"])(dataSource);
8076
+ var flatDataSource = Object(_utils__WEBPACK_IMPORTED_MODULE_17__["collectNodes"])(pipeline.getDataSource());
8075
8077
  flatDataSource.forEach(function (row, rowIndex) {
8076
8078
  var rowKey = _internals__WEBPACK_IMPORTED_MODULE_15__["internals"].safeGetRowKey(primaryKey, row, rowIndex);
8077
8079
  fullKeySet.add(rowKey); // 在 allKeys 中排除被禁用的 key
@@ -8099,6 +8101,8 @@ function multiSelect() {
8099
8101
  checked: isAllChecked,
8100
8102
  indeterminate: !isAllChecked && isAnyChecked,
8101
8103
  onChange: function onChange(_) {
8104
+ var allKeys = pipeline.getFeatureOptions(allEnableKeys);
8105
+
8102
8106
  if (isAllChecked) {
8103
8107
  _onChange(_utils_others__WEBPACK_IMPORTED_MODULE_16__["arrayUtils"].diff(value, allKeys), '', allKeys, 'uncheck-all');
8104
8108
  } else {
@@ -8119,9 +8123,11 @@ function multiSelect() {
8119
8123
  var rowKey = _internals__WEBPACK_IMPORTED_MODULE_15__["internals"].safeGetRowKey(primaryKey, row, rowIndex);
8120
8124
  var checkboxCellProps = {};
8121
8125
  var preCellProps = (_opts$checkboxColumn = opts.checkboxColumn) === null || _opts$checkboxColumn === void 0 ? void 0 : (_opts$checkboxColumn$ = _opts$checkboxColumn.getCellProps) === null || _opts$checkboxColumn$ === void 0 ? void 0 : _opts$checkboxColumn$.call(_opts$checkboxColumn, value, row, rowIndex);
8126
+ var fullRowsSet = pipeline.getFeatureOptions(fullRowsSetKey) || new Set();
8127
+ var selectValueSet = pipeline.getFeatureOptions(selectValueSetKey) || new Set();
8122
8128
 
8123
- if (fullKeySet.has(rowKey) && clickArea === 'cell') {
8124
- var prevChecked = set.has(rowKey);
8129
+ if (fullRowsSet.has(rowKey) && clickArea === 'cell') {
8130
+ var prevChecked = selectValueSet.has(rowKey);
8125
8131
  var disabled = isDisabled(row, rowIndex);
8126
8132
  checkboxCellProps = {
8127
8133
  style: {
@@ -8145,7 +8151,8 @@ function multiSelect() {
8145
8151
  }
8146
8152
 
8147
8153
  var key = _internals__WEBPACK_IMPORTED_MODULE_15__["internals"].safeGetRowKey(primaryKey, row, rowIndex);
8148
- var checked = set.has(key);
8154
+ var selectValueSet = pipeline.getFeatureOptions(selectValueSetKey) || new Set();
8155
+ var checked = selectValueSet.has(key);
8149
8156
  return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_14___default.a.createElement(Checkbox, {
8150
8157
  checked: checked,
8151
8158
  disabled: isDisabled(row, rowIndex),
@@ -8183,8 +8190,9 @@ function multiSelect() {
8183
8190
 
8184
8191
  pipeline.appendRowPropsGetter(function (row, rowIndex) {
8185
8192
  var rowKey = _internals__WEBPACK_IMPORTED_MODULE_15__["internals"].safeGetRowKey(primaryKey, row, rowIndex);
8193
+ var fullRowsSet = pipeline.getFeatureOptions(fullRowsSetKey) || new Set();
8186
8194
 
8187
- if (!fullKeySet.has(rowKey)) {
8195
+ if (!fullRowsSet.has(rowKey)) {
8188
8196
  // rowKey 不在 fullKeySet 中说明这一行是在 multiSelect 之后才生成的,multiSelect 不对之后生成的行进行处理
8189
8197
  return;
8190
8198
  }
@@ -8192,7 +8200,8 @@ function multiSelect() {
8192
8200
  var style = {};
8193
8201
  var className;
8194
8202
  var onClick;
8195
- var checked = set.has(rowKey);
8203
+ var selectValueSet = pipeline.getFeatureOptions(selectValueSetKey) || new Set();
8204
+ var checked = selectValueSet.has(rowKey);
8196
8205
 
8197
8206
  if (opts.highlightRowWhenSelected && checked) {
8198
8207
  className = 'highlight';
@@ -8219,22 +8228,32 @@ function multiSelect() {
8219
8228
  style: style,
8220
8229
  onClick: onClick
8221
8230
  };
8222
- });
8231
+ }); // 只保留一份到pipeline, 避免行数据过多时内容被握住
8232
+
8233
+ pipeline.setFeatureOptions(fullRowsSetKey, fullKeySet);
8234
+ pipeline.setFeatureOptions(allEnableKeys, allKeys);
8235
+ pipeline.setFeatureOptions(selectValueSetKey, set);
8236
+ fullKeySet = null;
8237
+ allKeys = null;
8238
+ set = null;
8223
8239
  return pipeline;
8224
8240
 
8225
8241
  function onCheckboxChange(prevChecked, key, batch) {
8226
8242
  var batchKeys = [key];
8227
8243
 
8228
8244
  if (batch && lastKey) {
8229
- var lastIdx = allKeys.indexOf(lastKey);
8230
- var cntIdx = allKeys.indexOf(key);
8245
+ var _allKeys = pipeline.getFeatureOptions(allEnableKeys);
8246
+
8247
+ var lastIdx = _allKeys.indexOf(lastKey);
8248
+
8249
+ var cntIdx = _allKeys.indexOf(key);
8231
8250
 
8232
8251
  var _ref5 = lastIdx < cntIdx ? [lastIdx, cntIdx] : [cntIdx, lastIdx],
8233
8252
  _ref6 = _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_5___default()(_ref5, 2),
8234
8253
  start = _ref6[0],
8235
8254
  end = _ref6[1];
8236
8255
 
8237
- batchKeys = allKeys.slice(start, end + 1);
8256
+ batchKeys = _allKeys.slice(start, end + 1);
8238
8257
  }
8239
8258
 
8240
8259
  if (prevChecked) {