@kdcloudjs/table 1.1.3-canary.9 → 1.1.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 (47) hide show
  1. package/dist/@kdcloudjs/table.css +1 -1
  2. package/dist/@kdcloudjs/table.js +113 -359
  3. package/dist/@kdcloudjs/table.js.map +1 -1
  4. package/dist/@kdcloudjs/table.min.css +1 -1
  5. package/dist/@kdcloudjs/table.min.js +6 -6
  6. package/dist/@kdcloudjs/table.min.js.map +1 -1
  7. package/es/table/base/html-table.js +1 -1
  8. package/es/table/base/styles.d.ts +0 -2
  9. package/es/table/base/styles.js +1 -3
  10. package/es/table/base/table.js +3 -4
  11. package/es/table/pipeline/features/columnDrag.js +10 -19
  12. package/es/table/pipeline/features/columnFilter.d.ts +1 -1
  13. package/es/table/pipeline/features/columnFilter.js +15 -35
  14. package/es/table/pipeline/features/filter/util.js +4 -4
  15. package/es/table/pipeline/features/index.d.ts +0 -1
  16. package/es/table/pipeline/features/index.js +1 -2
  17. package/es/table/pipeline/features/multiSelect.js +2 -7
  18. package/es/table/pipeline/features/rangeSelection.d.ts +1 -1
  19. package/es/table/pipeline/features/rangeSelection.js +28 -156
  20. package/es/table/pipeline/features/singleSelect.js +0 -4
  21. package/es/table/pipeline/features/treeMode.d.ts +0 -2
  22. package/es/table/pipeline/features/treeMode.js +20 -18
  23. package/es/table/pipeline/pipeline.d.ts +1 -5
  24. package/es/table/pipeline/pipeline.js +10 -11
  25. package/lib/table/base/html-table.js +1 -1
  26. package/lib/table/base/styles.d.ts +0 -2
  27. package/lib/table/base/styles.js +1 -3
  28. package/lib/table/base/table.js +3 -4
  29. package/lib/table/pipeline/features/columnDrag.js +10 -19
  30. package/lib/table/pipeline/features/columnFilter.d.ts +1 -1
  31. package/lib/table/pipeline/features/columnFilter.js +15 -33
  32. package/lib/table/pipeline/features/filter/util.js +4 -4
  33. package/lib/table/pipeline/features/index.d.ts +0 -1
  34. package/lib/table/pipeline/features/index.js +1 -15
  35. package/lib/table/pipeline/features/multiSelect.js +1 -6
  36. package/lib/table/pipeline/features/rangeSelection.d.ts +1 -1
  37. package/lib/table/pipeline/features/rangeSelection.js +30 -158
  38. package/lib/table/pipeline/features/singleSelect.js +0 -4
  39. package/lib/table/pipeline/features/treeMode.d.ts +0 -2
  40. package/lib/table/pipeline/features/treeMode.js +22 -19
  41. package/lib/table/pipeline/pipeline.d.ts +1 -5
  42. package/lib/table/pipeline/pipeline.js +10 -12
  43. package/package.json +3 -3
  44. package/es/table/pipeline/features/footerDataSource.d.ts +0 -9
  45. package/es/table/pipeline/features/footerDataSource.js +0 -25
  46. package/lib/table/pipeline/features/footerDataSource.d.ts +0 -9
  47. package/lib/table/pipeline/features/footerDataSource.js +0 -41
@@ -7,7 +7,7 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
- exports.lastClickCellKey = void 0;
10
+ exports.lastClickCell = void 0;
11
11
  exports.rangeSelection = rangeSelection;
12
12
  exports.rangeSelectionKey = void 0;
13
13
 
@@ -35,44 +35,42 @@ var _classnames = _interopRequireDefault(require("classnames"));
35
35
 
36
36
  var rangeSelectionKey = 'rangeSelection';
37
37
  exports.rangeSelectionKey = rangeSelectionKey;
38
- var lastClickCellKey = 'lastClickCell';
39
- exports.lastClickCellKey = lastClickCellKey;
38
+ var lastClickCell = 'lastClickCell';
39
+ exports.lastClickCell = lastClickCell;
40
40
 
41
41
  function rangeSelection(opts) {
42
42
  return function step(pipeline) {
43
43
  var SCROLL_SIZE = 30;
44
44
  var tableBody = pipeline.ref.current.domHelper && pipeline.ref.current.domHelper.tableBody;
45
- var tableFooter = pipeline.ref.current.domHelper && pipeline.ref.current.domHelper.tableFooter;
46
45
 
47
46
  if (!tableBody) {
48
47
  return pipeline;
49
48
  }
50
49
 
51
50
  var columns = pipeline.getColumns();
52
- var dataSource = pipeline.getDataSource();
53
51
 
54
52
  var rangeSelectedChange = function rangeSelectedChange(rangeSelection) {
55
53
  var _a;
56
54
 
57
55
  pipeline.setStateAtKey(rangeSelectionKey, rangeSelection);
58
56
  (_a = opts === null || opts === void 0 ? void 0 : opts.rangeSelectedChange) === null || _a === void 0 ? void 0 : _a.call(opts, rangeSelection);
59
- };
57
+ }; // if (!pipeline.getFeatureOptions(rangeSelectionKey)) {
58
+ // pipeline.setFeatureOptions(rangeSelectionKey, {
59
+ // optionKey: rangeSelectionKey,
60
+ // rangeSelectedChange: rangeSelectedChange
61
+ // })
62
+ // }
63
+
60
64
 
61
65
  var setRangeSelection = function setRangeSelection(startDragCell, draggingCell) {
62
- if (!startDragCell || !draggingCell) return;
66
+ if (!startDragCell || !draggingCell || isSameCell(startDragCell, draggingCell)) return;
63
67
  var rangeColumns = getRangeColumns(startDragCell, draggingCell, columns);
64
-
65
- var _getRangeSelectionRow = getRangeSelectionRowInfo(startDragCell, draggingCell, dataSource),
66
- startRow = _getRangeSelectionRow.startRow,
67
- endRow = _getRangeSelectionRow.endRow,
68
- footerRowRange = _getRangeSelectionRow.footerRowRange;
69
-
68
+ var isTopToBottom = startDragCell.rowIndex <= draggingCell.rowIndex;
70
69
  var rangeSelection = {
71
- startRow: startRow,
72
- endRow: endRow,
70
+ startRow: isTopToBottom ? startDragCell.rowIndex : startDragCell.rowIndex + startDragCell.rowSpan - 1,
71
+ endRow: isTopToBottom ? draggingCell.rowIndex + draggingCell.rowSpan - 1 : draggingCell.rowIndex,
73
72
  columns: rangeColumns,
74
- startColumn: startDragCell.column,
75
- footerRowRange: footerRowRange
73
+ startColumn: startDragCell.column
76
74
  };
77
75
  rangeSelectedChange(rangeSelection);
78
76
  };
@@ -83,23 +81,23 @@ function rangeSelection(opts) {
83
81
 
84
82
  if (clickCell) {
85
83
  if (event.shiftKey) {
86
- var _lastClickCell = pipeline.getStateAtKey(lastClickCellKey);
84
+ var _lastClickCell = pipeline.getStateAtKey(lastClickCell);
87
85
 
88
86
  if (_lastClickCell) {
89
87
  setRangeSelection(_lastClickCell, clickCell);
90
88
  } else {
91
89
  // 第一次进来就按住shift键,这时候要记住点击的单元格
92
- pipeline.setStateAtKey(lastClickCellKey, clickCell);
90
+ pipeline.setStateAtKey(lastClickCell, clickCell);
93
91
  }
94
92
  } else {
95
- pipeline.setStateAtKey(lastClickCellKey, clickCell);
96
- setRangeSelection(clickCell, clickCell);
93
+ pipeline.setStateAtKey(lastClickCell, clickCell);
94
+ rangeSelectedChange(null);
97
95
  }
98
96
  }
99
97
  };
100
98
 
101
99
  var onMouseDown = function onMouseDown(mouseDownEvent) {
102
- if (mouseDownEvent.button !== 0 || !((0, _utils.isElementInEventPath)(tableBody, mouseDownEvent.nativeEvent) || (0, _utils.isElementInEventPath)(tableFooter, mouseDownEvent.nativeEvent))) return; // mouseDownEvent.preventDefault()
100
+ if (mouseDownEvent.button !== 0 || !(0, _utils.isElementInEventPath)(tableBody, mouseDownEvent.nativeEvent)) return; // mouseDownEvent.preventDefault()
103
101
  // shift + 点击选中
104
102
 
105
103
  shiftKeySelect(mouseDownEvent);
@@ -155,11 +153,10 @@ function rangeSelection(opts) {
155
153
  };
156
154
 
157
155
  var onKeyDown = function onKeyDown(e) {
158
- if (!((0, _utils.isElementInEventPath)(tableBody, e.nativeEvent) || (0, _utils.isElementInEventPath)(tableFooter, e.nativeEvent))) return;
156
+ if (!(0, _utils.isElementInEventPath)(tableBody, e.nativeEvent)) return;
159
157
 
160
158
  if ((e.ctrlKey || e.metaKey) && e.key === 'a') {
161
159
  var rowLen = pipeline.getDataSource().length;
162
- var footerDataSource = pipeline.getFooterDataSource() || [];
163
160
 
164
161
  if (columns.length && rowLen) {
165
162
  opts.preventkDefaultOfKeyDownEvent !== false && e.preventDefault();
@@ -167,11 +164,7 @@ function rangeSelection(opts) {
167
164
  startRow: 0,
168
165
  endRow: rowLen - 1,
169
166
  columns: columns,
170
- startColumn: columns[0],
171
- footerRowRange: footerDataSource.length > 0 ? {
172
- startRow: 0,
173
- endRow: footerDataSource.length - 1
174
- } : null
167
+ startColumn: columns[0]
175
168
  });
176
169
  }
177
170
  }
@@ -180,8 +173,7 @@ function rangeSelection(opts) {
180
173
  pipeline.addTableProps({
181
174
  onMouseDown: onMouseDown,
182
175
  onKeyDown: onKeyDown,
183
- tabIndex: -1,
184
- className: (0, _classnames.default)([_styles.Classes.rangeSelection])
176
+ tabIndex: -1
185
177
  }); // todo: 后面可以把mousedown放到一个流里面
186
178
 
187
179
  return pipeline.mapColumns((0, _utils.makeRecursiveMapper)(function (col) {
@@ -197,29 +189,15 @@ function rangeSelection(opts) {
197
189
  var _cx;
198
190
 
199
191
  var prevCellProps = prevGetCellProps === null || prevGetCellProps === void 0 ? void 0 : prevGetCellProps(value, record, rowIndex);
200
- var isInFooter = record[pipeline.getFeatureOptions('footerRowMetaKey')];
201
192
  var startRow = rangeSelection.startRow,
202
193
  endRow = rangeSelection.endRow,
203
- columns = rangeSelection.columns,
204
- footerRowRange = rangeSelection.footerRowRange;
205
-
206
- var _getRowIndex = getRowIndex(startRow, endRow),
207
- startRowIndex = _getRowIndex.startRowIndex,
208
- endRowIndex = _getRowIndex.endRowIndex;
209
-
210
- var _getFooterRowIndex = getFooterRowIndex(footerRowRange),
211
- footerStartRowIndex = _getFooterRowIndex.startRowIndex,
212
- footerEndRowIndex = _getFooterRowIndex.endRowIndex;
213
-
194
+ columns = rangeSelection.columns;
195
+ var startIndex = startRow < endRow ? startRow : endRow;
196
+ var endIndex = startRow < endRow ? endRow : startRow;
214
197
  var startCol = columns[0];
215
198
  var endCol = columns[columns.length - 1];
216
- var bodyMatch = !isInFooter && rowIndex >= startRowIndex && rowIndex <= endRowIndex;
217
- var footerMatch = isInFooter && footerRowRange && rowIndex >= footerStartRowIndex && rowIndex <= footerEndRowIndex;
218
- var match = footerMatch || bodyMatch;
219
- var matchSingleCell = match && isCellRangeSingleCell(rangeSelection); // 单个范围选中单元格不显示样式
220
-
221
- var showCellRangeStyle = match && !matchSingleCell;
222
- var className = (0, _classnames.default)((_cx = {}, (0, _defineProperty2.default)(_cx, _styles.Classes.tableCellRangeSingleCell, matchSingleCell), (0, _defineProperty2.default)(_cx, _styles.Classes.tableCellRangeSelected, showCellRangeStyle), (0, _defineProperty2.default)(_cx, _styles.Classes.tableCellRangeTop, showCellRangeStyle && (isInFooter ? startRowIndex !== -1 ? false : rowIndex === footerStartRowIndex : rowIndex === startRowIndex)), (0, _defineProperty2.default)(_cx, _styles.Classes.tableCellRangeLeft, showCellRangeStyle && col.code === startCol.code), (0, _defineProperty2.default)(_cx, _styles.Classes.tableCellRangeBottom, showCellRangeStyle && (isInFooter ? rowIndex === footerEndRowIndex : footerRowRange ? false : rowIndex === endRowIndex)), (0, _defineProperty2.default)(_cx, _styles.Classes.tableCellRangeRight, showCellRangeStyle && col.code === endCol.code), _cx));
199
+ var match = rowIndex >= startIndex && rowIndex <= endIndex;
200
+ var className = (0, _classnames.default)((_cx = {}, (0, _defineProperty2.default)(_cx, _styles.Classes.tableCellRangeSelected, match), (0, _defineProperty2.default)(_cx, _styles.Classes.tableCellRangeTop, rowIndex === startIndex), (0, _defineProperty2.default)(_cx, _styles.Classes.tableCellRangeLeft, col.code === startCol.code && match), (0, _defineProperty2.default)(_cx, _styles.Classes.tableCellRangeBottom, rowIndex === endIndex), (0, _defineProperty2.default)(_cx, _styles.Classes.tableCellRangeRight, col.code === endCol.code && match), _cx));
223
201
  return (0, _utils.mergeCellProps)(prevCellProps, {
224
202
  className: className
225
203
  });
@@ -245,8 +223,7 @@ function getTargetCell(target, columns) {
245
223
  rowIndex: parseInt(target.getAttribute('data-rowindex')),
246
224
  rowSpan: parseInt(target.getAttribute('rowspan') || 1),
247
225
  code: columnCode,
248
- column: column,
249
- isInFooter: isEleInFooter(target)
226
+ column: column
250
227
  }
251
228
  };
252
229
  }();
@@ -261,19 +238,7 @@ function getTargetCell(target, columns) {
261
238
  }
262
239
 
263
240
  function isSameCell(cell1, cell2) {
264
- return cell1.rowIndex === cell2.rowIndex && cell1.code === cell2.code && cell1.isInFooter === cell2.isInFooter;
265
- }
266
-
267
- function isEleInFooter(target) {
268
- while (target && !target.classList.contains(_styles.Classes.artTable)) {
269
- if (target.classList.contains(_styles.Classes.tableFooter)) {
270
- return true;
271
- }
272
-
273
- target = target.parentElement;
274
- }
275
-
276
- return false;
241
+ return cell1.rowIndex === cell2.rowIndex && cell1.code === cell2.code;
277
242
  }
278
243
 
279
244
  function getRangeColumns(startCell, endCell, columns) {
@@ -290,97 +255,4 @@ function getRangeColumns(startCell, endCell, columns) {
290
255
  } else {
291
256
  return (0, _slice.default)(flatColumns).call(flatColumns, endIndex, startIndex + 1);
292
257
  }
293
- }
294
-
295
- function getRangeSelectionRowInfo(startCell, endCell, dataSource) {
296
- var footerRowRange = null;
297
- var startRow = -1;
298
- var endRow = -1;
299
-
300
- var _getCellRangeRow = getCellRangeRow(startCell, endCell),
301
- _startRow = _getCellRangeRow.startRow,
302
- _endRow = _getCellRangeRow.endRow; // 两个单元格都在表体
303
-
304
-
305
- if (!startCell.isInFooter && !endCell.isInFooter) {
306
- startRow = _startRow;
307
- endRow = _endRow;
308
- } else if (startCell.isInFooter && endCell.isInFooter) {
309
- // 两个单元格都在表底
310
- footerRowRange = {
311
- startRow: _startRow,
312
- endRow: _endRow
313
- };
314
- } else {
315
- // 一个单元格在表体,一个在表底
316
- if (startCell.isInFooter) {
317
- startRow = dataSource.length - 1;
318
- endRow = endCell.rowIndex;
319
- footerRowRange = {
320
- startRow: startCell.rowIndex,
321
- endRow: 0
322
- };
323
- } else {
324
- startRow = startCell.rowIndex;
325
- endRow = dataSource.length - 1;
326
- footerRowRange = {
327
- startRow: 0,
328
- endRow: endCell.rowIndex
329
- };
330
- }
331
- }
332
-
333
- return {
334
- startRow: startRow,
335
- endRow: endRow,
336
- footerRowRange: footerRowRange
337
- };
338
- }
339
-
340
- function getCellRangeRow(startCell, endCell) {
341
- if (isSameCell(startCell, endCell)) {
342
- return {
343
- startRow: startCell.rowIndex,
344
- endRow: startCell.rowIndex
345
- };
346
- }
347
-
348
- var isTopToBottom = startCell.rowIndex <= endCell.rowIndex;
349
- var startRow = isTopToBottom ? startCell.rowIndex : startCell.rowIndex + startCell.rowSpan - 1;
350
- var endRow = isTopToBottom ? endCell.rowIndex + endCell.rowSpan - 1 : endCell.rowIndex;
351
- return {
352
- startRow: startRow,
353
- endRow: endRow
354
- };
355
- }
356
-
357
- function isCellRangeSingleCell(rangeSelection) {
358
- var startRow = rangeSelection.startRow,
359
- endRow = rangeSelection.endRow,
360
- columns = rangeSelection.columns,
361
- footerRowRange = rangeSelection.footerRowRange;
362
- var isBodySingleCell = !footerRowRange && startRow === endRow && columns.length === 1;
363
- var isFooterSingleCell = startRow === -1 && footerRowRange.startRow === footerRowRange.endRow && columns.length === 1;
364
- return isBodySingleCell || isFooterSingleCell;
365
- }
366
-
367
- function getRowIndex(startRow, endRow) {
368
- var isReverse = startRow > endRow;
369
- var startRowIndex = isReverse ? endRow : startRow;
370
- var endRowIndex = isReverse ? startRow : endRow;
371
- return {
372
- startRowIndex: startRowIndex,
373
- endRowIndex: endRowIndex
374
- };
375
- }
376
-
377
- function getFooterRowIndex(footerRowRange) {
378
- if (footerRowRange) {
379
- return getRowIndex(footerRowRange.startRow, footerRowRange.endRow);
380
- }
381
-
382
- return {
383
- startRowIndex: -1,
384
- endRowIndex: -1
385
- };
386
258
  }
@@ -76,10 +76,6 @@ function singleSelect() {
76
76
  return preCellProps;
77
77
  },
78
78
  render: function render(_, row, rowIndex) {
79
- if (row[pipeline.getFeatureOptions('footerRowMetaKey')]) {
80
- return null;
81
- }
82
-
83
79
  var rowKey = _internals.internals.safeGetRowKey(primaryKey, row, rowIndex);
84
80
 
85
81
  return /*#__PURE__*/_react.default.createElement(Radio, {
@@ -32,8 +32,6 @@ export interface TreeModeFeatureOptions {
32
32
  stopClickEventPropagation?: boolean;
33
33
  /** 指定表格每一行元信息的记录字段 */
34
34
  treeMetaKey?: string | symbol;
35
- /** 指定展开列 */
36
- expandColCode?: string;
37
35
  }
38
36
  export declare function treeMode(opts?: TreeModeFeatureOptions): (pipeline: TablePipeline) => TablePipeline;
39
37
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _sliceInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/slice");
3
+ var _sliceInstanceProperty2 = require("@babel/runtime-corejs3/core-js-stable/instance/slice");
4
4
 
5
5
  var _Array$from = require("@babel/runtime-corejs3/core-js-stable/array/from");
6
6
 
@@ -16,6 +16,8 @@ Object.defineProperty(exports, "__esModule", {
16
16
  exports.treeMetaSymbol = void 0;
17
17
  exports.treeMode = treeMode;
18
18
 
19
+ var _toArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/toArray"));
20
+
19
21
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
20
22
 
21
23
  var _extends3 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
@@ -30,7 +32,7 @@ var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-sta
30
32
 
31
33
  var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
32
34
 
33
- var _findIndex = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find-index"));
35
+ var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
34
36
 
35
37
  var _classnames = _interopRequireDefault(require("classnames"));
36
38
 
@@ -46,7 +48,7 @@ var _styles = require("../../base/styles");
46
48
 
47
49
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol2 !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
48
50
 
49
- function _unsupportedIterableToArray(o, minLen) { var _context2; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context2 = Object.prototype.toString.call(o)).call(_context2, 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); }
51
+ function _unsupportedIterableToArray(o, minLen) { var _context3; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty2(_context3 = Object.prototype.toString.call(o)).call(_context3, 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); }
50
52
 
51
53
  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; }
52
54
 
@@ -61,6 +63,11 @@ function treeMode() {
61
63
  var stateKey = 'treeMode';
62
64
  var ctx = pipeline.ctx;
63
65
  var primaryKey = pipeline.ensurePrimaryKey('treeMode');
66
+
67
+ if (typeof primaryKey !== 'string') {
68
+ throw new Error('treeMode 仅支持字符串作为 primaryKey');
69
+ }
70
+
64
71
  var openKeys = (_c = (_b = (_a = opts.openKeys) !== null && _a !== void 0 ? _a : pipeline.getStateAtKey(stateKey)) !== null && _b !== void 0 ? _b : opts.defaultOpenKeys) !== null && _c !== void 0 ? _c : [];
65
72
  var openKeySet = new _set.default(openKeys);
66
73
 
@@ -115,9 +122,7 @@ function treeMode() {
115
122
  try {
116
123
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
117
124
  var node = _step.value;
118
-
119
- var rowKey = _internals.internals.safeGetRowKey(primaryKey, node, -1);
120
-
125
+ var rowKey = node[primaryKey];
121
126
  var expanded = openKeySet.has(rowKey);
122
127
  var isLeaf = isLeafNode(node, {
123
128
  depth: depth,
@@ -147,19 +152,18 @@ function treeMode() {
147
152
  }
148
153
 
149
154
  function processColumns(columns) {
155
+ var _context2;
156
+
150
157
  if (columns.length === 0) {
151
158
  return columns;
152
159
  }
153
160
 
154
- var expandColIndex = (0, _findIndex.default)(columns).call(columns, function (_ref) {
155
- var code = _ref.code;
156
- return code && opts.expandColCode === code;
157
- });
158
- expandColIndex = expandColIndex === -1 ? 0 : expandColIndex;
159
- var expandCol = columns[expandColIndex];
161
+ var _columns = (0, _toArray2.default)(columns),
162
+ firstCol = _columns[0],
163
+ others = (0, _slice.default)(_columns).call(_columns, 1);
160
164
 
161
165
  var render = function render(value, record, recordIndex) {
162
- var content = _internals.internals.safeRender(expandCol, record, recordIndex);
166
+ var content = _internals.internals.safeRender(firstCol, record, recordIndex);
163
167
 
164
168
  if (record[treeMetaKey] == null) {
165
169
  // 没有 treeMeta 信息的话,就返回原先的渲染结果
@@ -219,7 +223,7 @@ function treeMode() {
219
223
  };
220
224
 
221
225
  var getCellProps = function getCellProps(value, record, rowIndex) {
222
- var prevProps = _internals.internals.safeGetCellProps(expandCol, record, rowIndex);
226
+ var prevProps = _internals.internals.safeGetCellProps(firstCol, record, rowIndex);
223
227
 
224
228
  if (record[treeMetaKey] == null) {
225
229
  // 没有 treeMeta 信息的话,就返回原先的 cellProps
@@ -248,16 +252,15 @@ function treeMode() {
248
252
  });
249
253
  };
250
254
 
251
- columns[expandColIndex] = (0, _extends3.default)((0, _extends3.default)({}, expandCol), {
255
+ return (0, _concat.default)(_context2 = [(0, _extends3.default)((0, _extends3.default)({}, firstCol), {
252
256
  title: /*#__PURE__*/_react.default.createElement("span", {
253
257
  style: {
254
258
  marginLeft: iconIndent + iconWidth + iconGap
255
259
  }
256
- }, _internals.internals.safeRenderHeader(expandCol)),
260
+ }, _internals.internals.safeRenderHeader(firstCol)),
257
261
  render: render,
258
- getCellProps: clickArea === 'cell' ? getCellProps : expandCol.getCellProps
259
- });
260
- return (0, _toConsumableArray2.default)(columns);
262
+ getCellProps: clickArea === 'cell' ? getCellProps : firstCol.getCellProps
263
+ })]).call(_context2, (0, _toConsumableArray2.default)(others));
261
264
  }
262
265
  };
263
266
  }
@@ -36,7 +36,7 @@ export declare class TablePipeline {
36
36
  private _tableProps;
37
37
  private _dataSource;
38
38
  private _columns;
39
- private _footerDataSource?;
39
+ private _footerDataSource;
40
40
  static defaultIndents: TablePipelineIndentsConfig;
41
41
  readonly ctx: TablePipelineCtx;
42
42
  private readonly state;
@@ -88,10 +88,6 @@ export declare class TablePipeline {
88
88
  setFeatureOptions(optionKey: string, value: any): void;
89
89
  /** 获取 BaseTable 的 props,结果中包含 dataSource/columns/primaryKey/getRowProps 四个字段 */
90
90
  getProps(this: TablePipeline): TableProps;
91
- /**
92
- * 清除范围选中内容
93
- */
94
- clearRangeSelection(): void;
95
91
  }
96
92
  export declare function useTablePipeline(ctx?: Partial<TablePipelineCtx>): TablePipeline;
97
93
  export {};
@@ -28,8 +28,6 @@ var _utils = require("../utils");
28
28
 
29
29
  var _autoFill = require("./features/autoFill");
30
30
 
31
- var _rangeSelection = require("./features/rangeSelection");
32
-
33
31
  /**
34
32
  * 表格数据处理流水线。TablePipeline 提供了表格数据处理过程中的一些上下方与工具方法,包括……
35
33
  *
@@ -294,18 +292,18 @@ var TablePipeline = /*#__PURE__*/function () {
294
292
 
295
293
  result.setTableDomHelper = function (domHelper) {
296
294
  _this2.ref.current.domHelper = domHelper;
297
- };
295
+ }; // if (this.getFeatureOptions(rangeSelectionKey)) {
296
+ // result.clearRangeSelectionStatus = () => {
297
+ // const { rangeSelectedChange } = this.getFeatureOptions(rangeSelectionKey)
298
+ // const rangeSelection = this.getStateAtKey(rangeSelectionKey)
299
+ // if (rangeSelection) {
300
+ // rangeSelectedChange?.(null)
301
+ // }
302
+ // }
303
+ // }
298
304
 
299
- return result;
300
- }
301
- /**
302
- * 清除范围选中内容
303
- */
304
305
 
305
- }, {
306
- key: "clearRangeSelection",
307
- value: function clearRangeSelection() {
308
- this.setStateAtKey(_rangeSelection.rangeSelectionKey, null);
306
+ return result;
309
307
  }
310
308
  }]);
311
309
  return TablePipeline;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kdcloudjs/table",
3
- "version": "1.1.3-canary.9",
3
+ "version": "1.1.3",
4
4
  "description": "金蝶 react table 组件",
5
5
  "title": "table",
6
6
  "keywords": [
@@ -54,8 +54,8 @@
54
54
  "test:update": "jest --config .jest.js --cache=false -u",
55
55
  "test:ci": "jest --config .jest.js --coverage --ci --update-snapshot",
56
56
  "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --skip-unstable",
57
- "pub": "npm run test:all && npm run build && cross-env PUB_ENV=pub np --no-cleanup --no-tests",
58
- "pub:canary": "npm run build && cross-env PUB_ENV=pub np --no-cleanup --anyBranch --no-tests --tag=canary",
57
+ "pub": "npm run build && cross-env PUB_ENV=pub np --no-cleanup --no-tests",
58
+ "pub:beta": "npm run test:all && npm run build && cross-env PUB_ENV=pub np --no-cleanup --anyBranch --no-tests --tag=beta",
59
59
  "new": "node scripts/create-component.js",
60
60
  "kd-ui": "npm install @kingdee-ui/kui --registry http://npm.kingdee.com/"
61
61
  },
@@ -1,9 +0,0 @@
1
- import { TablePipeline } from '../pipeline';
2
- export interface FooterDataSourceFeatureOptions {
3
- /** 指定表格页脚每一行元信息的记录字段 */
4
- footerRowMetaKey?: string | symbol;
5
- /** 表格页脚数据源 */
6
- dataSource?: any[];
7
- }
8
- export declare const footerRowMetaSymbol: unique symbol;
9
- export declare function footerDataSource(opts?: FooterDataSourceFeatureOptions): (pipeline: TablePipeline) => TablePipeline;
@@ -1,25 +0,0 @@
1
- import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
2
- import _extends from "@babel/runtime-corejs3/helpers/extends";
3
- import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
4
- import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
5
- export var footerRowMetaSymbol = _Symbol('footer-row');
6
- export function footerDataSource() {
7
- var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
8
- return function footerDataSourceStep(pipeline) {
9
- var _a, _b;
10
-
11
- var footerDataSource = (_a = opts.dataSource) !== null && _a !== void 0 ? _a : pipeline.getFooterDataSource();
12
- var footerRowMetaKey = (_b = opts.footerRowMetaKey) !== null && _b !== void 0 ? _b : footerRowMetaSymbol;
13
- pipeline.setFeatureOptions('footerRowMetaKey', footerRowMetaKey);
14
-
15
- if (footerDataSource) {
16
- pipeline.footerDataSource(_mapInstanceProperty(footerDataSource).call(footerDataSource, function (row) {
17
- return _extends(_defineProperty({}, footerRowMetaKey, true), row);
18
- }));
19
- } else {
20
- console.warn('调用 pipeline.use(features.footerDataSource()) 前请先设置页脚数据源,设置方法有:pipeline.use(features.footerDataSource({dataSource:any[]})) 或者 pipeline.footerDataSource(any[])');
21
- }
22
-
23
- return pipeline;
24
- };
25
- }
@@ -1,9 +0,0 @@
1
- import { TablePipeline } from '../pipeline';
2
- export interface FooterDataSourceFeatureOptions {
3
- /** 指定表格页脚每一行元信息的记录字段 */
4
- footerRowMetaKey?: string | symbol;
5
- /** 表格页脚数据源 */
6
- dataSource?: any[];
7
- }
8
- export declare const footerRowMetaSymbol: unique symbol;
9
- export declare function footerDataSource(opts?: FooterDataSourceFeatureOptions): (pipeline: TablePipeline) => TablePipeline;
@@ -1,41 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.footerDataSource = footerDataSource;
9
- exports.footerRowMetaSymbol = void 0;
10
-
11
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
12
-
13
- var _extends3 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
14
-
15
- var _symbol = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/symbol"));
16
-
17
- var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
18
-
19
- var footerRowMetaSymbol = (0, _symbol.default)('footer-row');
20
- exports.footerRowMetaSymbol = footerRowMetaSymbol;
21
-
22
- function footerDataSource() {
23
- var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
24
- return function footerDataSourceStep(pipeline) {
25
- var _a, _b;
26
-
27
- var footerDataSource = (_a = opts.dataSource) !== null && _a !== void 0 ? _a : pipeline.getFooterDataSource();
28
- var footerRowMetaKey = (_b = opts.footerRowMetaKey) !== null && _b !== void 0 ? _b : footerRowMetaSymbol;
29
- pipeline.setFeatureOptions('footerRowMetaKey', footerRowMetaKey);
30
-
31
- if (footerDataSource) {
32
- pipeline.footerDataSource((0, _map.default)(footerDataSource).call(footerDataSource, function (row) {
33
- return (0, _extends3.default)((0, _defineProperty2.default)({}, footerRowMetaKey, true), row);
34
- }));
35
- } else {
36
- console.warn('调用 pipeline.use(features.footerDataSource()) 前请先设置页脚数据源,设置方法有:pipeline.use(features.footerDataSource({dataSource:any[]})) 或者 pipeline.footerDataSource(any[])');
37
- }
38
-
39
- return pipeline;
40
- };
41
- }