@kdcloudjs/table 1.1.4 → 1.1.5-canary.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.
- package/dist/@kdcloudjs/table.css +1 -1
- package/dist/@kdcloudjs/table.js +860 -310
- package/dist/@kdcloudjs/table.js.map +1 -1
- package/dist/@kdcloudjs/table.min.css +1 -1
- package/dist/@kdcloudjs/table.min.js +10 -9
- package/dist/@kdcloudjs/table.min.js.map +1 -1
- package/es/table/base/html-table.js +1 -1
- package/es/table/base/styles.d.ts +11 -2
- package/es/table/base/styles.js +18 -7
- package/es/table/base/table.d.ts +2 -0
- package/es/table/base/table.js +32 -54
- package/es/table/base/utils.d.ts +7 -0
- package/es/table/base/utils.js +36 -2
- package/es/table/pipeline/features/colGroupExtendable.d.ts +6 -0
- package/es/table/pipeline/features/colGroupExtendable.js +103 -0
- package/es/table/pipeline/features/columnDrag.js +5 -4
- package/es/table/pipeline/features/columnFilter.d.ts +4 -2
- package/es/table/pipeline/features/columnFilter.js +39 -19
- package/es/table/pipeline/features/columnResizeWidth.js +1 -1
- package/es/table/pipeline/features/filter/DefaultFilterContent.js +22 -2
- package/es/table/pipeline/features/filter/DefaultFilterIcon.d.ts +5 -0
- package/es/table/pipeline/features/filter/DefaultFilterIcon.js +20 -0
- package/es/table/pipeline/features/filter/Filter.d.ts +3 -2
- package/es/table/pipeline/features/filter/Filter.js +54 -35
- package/es/table/pipeline/features/filter/FilterPanel.d.ts +2 -1
- package/es/table/pipeline/features/filter/FilterPanel.js +40 -21
- package/es/table/pipeline/features/filter/util.js +4 -4
- package/es/table/pipeline/features/footerDataSource.d.ts +9 -0
- package/es/table/pipeline/features/footerDataSource.js +25 -0
- package/es/table/pipeline/features/index.d.ts +2 -0
- package/es/table/pipeline/features/index.js +3 -1
- package/es/table/pipeline/features/multiSelect.js +7 -2
- package/es/table/pipeline/features/rangeSelection.d.ts +1 -1
- package/es/table/pipeline/features/rangeSelection.js +170 -30
- package/es/table/pipeline/features/singleSelect.js +4 -0
- package/es/table/pipeline/features/treeMode.d.ts +2 -0
- package/es/table/pipeline/features/treeMode.js +20 -21
- package/es/table/pipeline/pipeline.d.ts +5 -1
- package/es/table/pipeline/pipeline.js +11 -10
- package/es/table/utils/element.d.ts +1 -0
- package/es/table/utils/element.js +4 -0
- package/es/table/utils/keyCode.d.ts +5 -0
- package/es/table/utils/keyCode.js +5 -0
- package/es/table/utils/mergeCellProps.js +2 -6
- package/lib/table/base/html-table.js +1 -1
- package/lib/table/base/styles.d.ts +11 -2
- package/lib/table/base/styles.js +18 -7
- package/lib/table/base/table.d.ts +2 -0
- package/lib/table/base/table.js +32 -54
- package/lib/table/base/utils.d.ts +7 -0
- package/lib/table/base/utils.js +43 -2
- package/lib/table/pipeline/features/colGroupExtendable.d.ts +6 -0
- package/lib/table/pipeline/features/colGroupExtendable.js +124 -0
- package/lib/table/pipeline/features/columnDrag.js +5 -4
- package/lib/table/pipeline/features/columnFilter.d.ts +4 -2
- package/lib/table/pipeline/features/columnFilter.js +37 -19
- package/lib/table/pipeline/features/columnResizeWidth.js +1 -1
- package/lib/table/pipeline/features/filter/DefaultFilterContent.js +23 -1
- package/lib/table/pipeline/features/filter/DefaultFilterIcon.d.ts +5 -0
- package/lib/table/pipeline/features/filter/DefaultFilterIcon.js +30 -0
- package/lib/table/pipeline/features/filter/Filter.d.ts +3 -2
- package/lib/table/pipeline/features/filter/Filter.js +57 -35
- package/lib/table/pipeline/features/filter/FilterPanel.d.ts +2 -1
- package/lib/table/pipeline/features/filter/FilterPanel.js +42 -20
- package/lib/table/pipeline/features/filter/util.js +4 -4
- package/lib/table/pipeline/features/footerDataSource.d.ts +9 -0
- package/lib/table/pipeline/features/footerDataSource.js +41 -0
- package/lib/table/pipeline/features/index.d.ts +2 -0
- package/lib/table/pipeline/features/index.js +23 -1
- package/lib/table/pipeline/features/multiSelect.js +6 -1
- package/lib/table/pipeline/features/rangeSelection.d.ts +1 -1
- package/lib/table/pipeline/features/rangeSelection.js +173 -32
- package/lib/table/pipeline/features/singleSelect.js +4 -0
- package/lib/table/pipeline/features/treeMode.d.ts +2 -0
- package/lib/table/pipeline/features/treeMode.js +21 -23
- package/lib/table/pipeline/pipeline.d.ts +5 -1
- package/lib/table/pipeline/pipeline.js +12 -10
- package/lib/table/utils/element.d.ts +1 -0
- package/lib/table/utils/element.js +6 -0
- package/lib/table/utils/keyCode.d.ts +5 -0
- package/lib/table/utils/keyCode.js +12 -0
- package/lib/table/utils/mergeCellProps.js +2 -6
- package/package.json +3 -3
|
@@ -3,6 +3,7 @@ import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
|
3
3
|
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
4
4
|
import _findIndexInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find-index";
|
|
5
5
|
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
6
|
+
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
6
7
|
import { mergeCellProps, makeRecursiveMapper, isElementInEventPath, collectNodes } from '../../utils';
|
|
7
8
|
import { findByTree } from '../../utils/others';
|
|
8
9
|
import { fromEvent } from 'rxjs';
|
|
@@ -10,40 +11,42 @@ import { map, takeUntil } from 'rxjs/operators';
|
|
|
10
11
|
import { Classes } from '../../base/styles';
|
|
11
12
|
import cx from 'classnames';
|
|
12
13
|
export var rangeSelectionKey = 'rangeSelection';
|
|
13
|
-
export var
|
|
14
|
+
export var lastClickCellKey = 'lastClickCell';
|
|
14
15
|
export function rangeSelection(opts) {
|
|
15
16
|
return function step(pipeline) {
|
|
16
17
|
var SCROLL_SIZE = 30;
|
|
17
18
|
var tableBody = pipeline.ref.current.domHelper && pipeline.ref.current.domHelper.tableBody;
|
|
19
|
+
var tableFooter = pipeline.ref.current.domHelper && pipeline.ref.current.domHelper.tableFooter;
|
|
18
20
|
|
|
19
21
|
if (!tableBody) {
|
|
20
22
|
return pipeline;
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
var columns = pipeline.getColumns();
|
|
26
|
+
var dataSource = pipeline.getDataSource();
|
|
24
27
|
|
|
25
28
|
var rangeSelectedChange = function rangeSelectedChange(rangeSelection) {
|
|
26
29
|
var _a;
|
|
27
30
|
|
|
28
31
|
pipeline.setStateAtKey(rangeSelectionKey, rangeSelection);
|
|
29
32
|
(_a = opts === null || opts === void 0 ? void 0 : opts.rangeSelectedChange) === null || _a === void 0 ? void 0 : _a.call(opts, rangeSelection);
|
|
30
|
-
};
|
|
31
|
-
// pipeline.setFeatureOptions(rangeSelectionKey, {
|
|
32
|
-
// optionKey: rangeSelectionKey,
|
|
33
|
-
// rangeSelectedChange: rangeSelectedChange
|
|
34
|
-
// })
|
|
35
|
-
// }
|
|
36
|
-
|
|
33
|
+
};
|
|
37
34
|
|
|
38
35
|
var setRangeSelection = function setRangeSelection(startDragCell, draggingCell) {
|
|
39
|
-
if (!startDragCell || !draggingCell
|
|
36
|
+
if (!startDragCell || !draggingCell) return;
|
|
40
37
|
var rangeColumns = getRangeColumns(startDragCell, draggingCell, columns);
|
|
41
|
-
|
|
38
|
+
|
|
39
|
+
var _getRangeSelectionRow = getRangeSelectionRowInfo(startDragCell, draggingCell, dataSource),
|
|
40
|
+
startRow = _getRangeSelectionRow.startRow,
|
|
41
|
+
endRow = _getRangeSelectionRow.endRow,
|
|
42
|
+
footerRowRange = _getRangeSelectionRow.footerRowRange;
|
|
43
|
+
|
|
42
44
|
var rangeSelection = {
|
|
43
|
-
startRow:
|
|
44
|
-
endRow:
|
|
45
|
+
startRow: startRow,
|
|
46
|
+
endRow: endRow,
|
|
45
47
|
columns: rangeColumns,
|
|
46
|
-
startColumn: startDragCell.column
|
|
48
|
+
startColumn: startDragCell.column,
|
|
49
|
+
footerRowRange: footerRowRange
|
|
47
50
|
};
|
|
48
51
|
rangeSelectedChange(rangeSelection);
|
|
49
52
|
};
|
|
@@ -54,23 +57,23 @@ export function rangeSelection(opts) {
|
|
|
54
57
|
|
|
55
58
|
if (clickCell) {
|
|
56
59
|
if (event.shiftKey) {
|
|
57
|
-
var _lastClickCell = pipeline.getStateAtKey(
|
|
60
|
+
var _lastClickCell = pipeline.getStateAtKey(lastClickCellKey);
|
|
58
61
|
|
|
59
62
|
if (_lastClickCell) {
|
|
60
63
|
setRangeSelection(_lastClickCell, clickCell);
|
|
61
64
|
} else {
|
|
62
65
|
// 第一次进来就按住shift键,这时候要记住点击的单元格
|
|
63
|
-
pipeline.setStateAtKey(
|
|
66
|
+
pipeline.setStateAtKey(lastClickCellKey, clickCell);
|
|
64
67
|
}
|
|
65
68
|
} else {
|
|
66
|
-
pipeline.setStateAtKey(
|
|
67
|
-
|
|
69
|
+
pipeline.setStateAtKey(lastClickCellKey, clickCell);
|
|
70
|
+
setRangeSelection(clickCell, clickCell);
|
|
68
71
|
}
|
|
69
72
|
}
|
|
70
73
|
};
|
|
71
74
|
|
|
72
75
|
var onMouseDown = function onMouseDown(mouseDownEvent) {
|
|
73
|
-
if (mouseDownEvent.button !== 0 || !isElementInEventPath(tableBody, mouseDownEvent.nativeEvent)) return; // mouseDownEvent.preventDefault()
|
|
76
|
+
if (mouseDownEvent.button !== 0 || !(isElementInEventPath(tableBody, mouseDownEvent.nativeEvent) || isElementInEventPath(tableFooter, mouseDownEvent.nativeEvent))) return; // mouseDownEvent.preventDefault()
|
|
74
77
|
// shift + 点击选中
|
|
75
78
|
|
|
76
79
|
shiftKeySelect(mouseDownEvent);
|
|
@@ -126,18 +129,23 @@ export function rangeSelection(opts) {
|
|
|
126
129
|
};
|
|
127
130
|
|
|
128
131
|
var onKeyDown = function onKeyDown(e) {
|
|
129
|
-
if (!isElementInEventPath(tableBody, e.nativeEvent)) return;
|
|
132
|
+
if (!(isElementInEventPath(tableBody, e.nativeEvent) || isElementInEventPath(tableFooter, e.nativeEvent))) return;
|
|
130
133
|
|
|
131
134
|
if ((e.ctrlKey || e.metaKey) && e.key === 'a') {
|
|
132
135
|
var rowLen = pipeline.getDataSource().length;
|
|
136
|
+
var footerDataSource = pipeline.getFooterDataSource() || []; // 焦点位于可编辑的单元格内不做全选
|
|
133
137
|
|
|
134
|
-
if (columns.length && rowLen) {
|
|
138
|
+
if (columns.length && rowLen && !getElementEditable(e.target)) {
|
|
135
139
|
opts.preventkDefaultOfKeyDownEvent !== false && e.preventDefault();
|
|
136
140
|
rangeSelectedChange({
|
|
137
141
|
startRow: 0,
|
|
138
142
|
endRow: rowLen - 1,
|
|
139
|
-
columns: columns,
|
|
140
|
-
startColumn: columns[0]
|
|
143
|
+
columns: collectNodes(columns, 'leaf-only'),
|
|
144
|
+
startColumn: columns[0],
|
|
145
|
+
footerRowRange: footerDataSource.length > 0 ? {
|
|
146
|
+
startRow: 0,
|
|
147
|
+
endRow: footerDataSource.length - 1
|
|
148
|
+
} : null
|
|
141
149
|
});
|
|
142
150
|
}
|
|
143
151
|
}
|
|
@@ -146,7 +154,8 @@ export function rangeSelection(opts) {
|
|
|
146
154
|
pipeline.addTableProps({
|
|
147
155
|
onMouseDown: onMouseDown,
|
|
148
156
|
onKeyDown: onKeyDown,
|
|
149
|
-
tabIndex: -1
|
|
157
|
+
tabIndex: -1,
|
|
158
|
+
className: cx([Classes.rangeSelection])
|
|
150
159
|
}); // todo: 后面可以把mousedown放到一个流里面
|
|
151
160
|
|
|
152
161
|
return pipeline.mapColumns(makeRecursiveMapper(function (col) {
|
|
@@ -162,15 +171,29 @@ export function rangeSelection(opts) {
|
|
|
162
171
|
var _cx;
|
|
163
172
|
|
|
164
173
|
var prevCellProps = prevGetCellProps === null || prevGetCellProps === void 0 ? void 0 : prevGetCellProps(value, record, rowIndex);
|
|
174
|
+
var isInFooter = record[pipeline.getFeatureOptions('footerRowMetaKey')];
|
|
165
175
|
var startRow = rangeSelection.startRow,
|
|
166
176
|
endRow = rangeSelection.endRow,
|
|
167
|
-
columns = rangeSelection.columns
|
|
168
|
-
|
|
169
|
-
|
|
177
|
+
columns = rangeSelection.columns,
|
|
178
|
+
footerRowRange = rangeSelection.footerRowRange;
|
|
179
|
+
|
|
180
|
+
var _getRowIndex = getRowIndex(startRow, endRow),
|
|
181
|
+
startRowIndex = _getRowIndex.startRowIndex,
|
|
182
|
+
endRowIndex = _getRowIndex.endRowIndex;
|
|
183
|
+
|
|
184
|
+
var _getFooterRowIndex = getFooterRowIndex(footerRowRange),
|
|
185
|
+
footerStartRowIndex = _getFooterRowIndex.startRowIndex,
|
|
186
|
+
footerEndRowIndex = _getFooterRowIndex.endRowIndex;
|
|
187
|
+
|
|
170
188
|
var startCol = columns[0];
|
|
171
189
|
var endCol = columns[columns.length - 1];
|
|
172
|
-
var
|
|
173
|
-
var
|
|
190
|
+
var bodyMatch = !isInFooter && rowIndex >= startRowIndex && rowIndex <= endRowIndex;
|
|
191
|
+
var footerMatch = isInFooter && footerRowRange && rowIndex >= footerStartRowIndex && rowIndex <= footerEndRowIndex;
|
|
192
|
+
var match = footerMatch || bodyMatch;
|
|
193
|
+
var matchSingleCell = match && isCellRangeSingleCell(rangeSelection); // 单个范围选中单元格不显示样式
|
|
194
|
+
|
|
195
|
+
var showCellRangeStyle = match && !matchSingleCell;
|
|
196
|
+
var className = cx((_cx = {}, _defineProperty(_cx, Classes.tableCellRangeSingleCell, matchSingleCell), _defineProperty(_cx, Classes.tableCellRangeSelected, showCellRangeStyle), _defineProperty(_cx, Classes.tableCellRangeTop, showCellRangeStyle && (isInFooter ? startRowIndex !== -1 ? false : rowIndex === footerStartRowIndex : rowIndex === startRowIndex)), _defineProperty(_cx, Classes.tableCellRangeLeft, showCellRangeStyle && col.code === startCol.code), _defineProperty(_cx, Classes.tableCellRangeBottom, showCellRangeStyle && (isInFooter ? rowIndex === footerEndRowIndex : footerRowRange ? false : rowIndex === endRowIndex)), _defineProperty(_cx, Classes.tableCellRangeRight, showCellRangeStyle && col.code === endCol.code), _cx));
|
|
174
197
|
return mergeCellProps(prevCellProps, {
|
|
175
198
|
className: className
|
|
176
199
|
});
|
|
@@ -196,7 +219,8 @@ function getTargetCell(target, columns) {
|
|
|
196
219
|
rowIndex: parseInt(target.getAttribute('data-rowindex')),
|
|
197
220
|
rowSpan: parseInt(target.getAttribute('rowspan') || 1),
|
|
198
221
|
code: columnCode,
|
|
199
|
-
column: column
|
|
222
|
+
column: column,
|
|
223
|
+
isInFooter: isEleInFooter(target)
|
|
200
224
|
}
|
|
201
225
|
};
|
|
202
226
|
}();
|
|
@@ -211,7 +235,19 @@ function getTargetCell(target, columns) {
|
|
|
211
235
|
}
|
|
212
236
|
|
|
213
237
|
function isSameCell(cell1, cell2) {
|
|
214
|
-
return cell1.rowIndex === cell2.rowIndex && cell1.code === cell2.code;
|
|
238
|
+
return cell1.rowIndex === cell2.rowIndex && cell1.code === cell2.code && cell1.isInFooter === cell2.isInFooter;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function isEleInFooter(target) {
|
|
242
|
+
while (target && !target.classList.contains(Classes.artTable)) {
|
|
243
|
+
if (target.classList.contains(Classes.tableFooter)) {
|
|
244
|
+
return true;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
target = target.parentElement;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return false;
|
|
215
251
|
}
|
|
216
252
|
|
|
217
253
|
function getRangeColumns(startCell, endCell, columns) {
|
|
@@ -230,4 +266,108 @@ function getRangeColumns(startCell, endCell, columns) {
|
|
|
230
266
|
} else {
|
|
231
267
|
return _sliceInstanceProperty(flatColumns).call(flatColumns, endIndex, startIndex + 1);
|
|
232
268
|
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function getRangeSelectionRowInfo(startCell, endCell, dataSource) {
|
|
272
|
+
var footerRowRange = null;
|
|
273
|
+
var startRow = -1;
|
|
274
|
+
var endRow = -1;
|
|
275
|
+
|
|
276
|
+
var _getCellRangeRow = getCellRangeRow(startCell, endCell),
|
|
277
|
+
_startRow = _getCellRangeRow.startRow,
|
|
278
|
+
_endRow = _getCellRangeRow.endRow; // 两个单元格都在表体
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
if (!startCell.isInFooter && !endCell.isInFooter) {
|
|
282
|
+
startRow = _startRow;
|
|
283
|
+
endRow = _endRow;
|
|
284
|
+
} else if (startCell.isInFooter && endCell.isInFooter) {
|
|
285
|
+
// 两个单元格都在表底
|
|
286
|
+
footerRowRange = {
|
|
287
|
+
startRow: _startRow,
|
|
288
|
+
endRow: _endRow
|
|
289
|
+
};
|
|
290
|
+
} else {
|
|
291
|
+
// 一个单元格在表体,一个在表底
|
|
292
|
+
if (startCell.isInFooter) {
|
|
293
|
+
startRow = dataSource.length - 1;
|
|
294
|
+
endRow = endCell.rowIndex;
|
|
295
|
+
footerRowRange = {
|
|
296
|
+
startRow: startCell.rowIndex,
|
|
297
|
+
endRow: 0
|
|
298
|
+
};
|
|
299
|
+
} else {
|
|
300
|
+
startRow = startCell.rowIndex;
|
|
301
|
+
endRow = dataSource.length - 1;
|
|
302
|
+
footerRowRange = {
|
|
303
|
+
startRow: 0,
|
|
304
|
+
endRow: endCell.rowIndex
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
return {
|
|
310
|
+
startRow: startRow,
|
|
311
|
+
endRow: endRow,
|
|
312
|
+
footerRowRange: footerRowRange
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function getCellRangeRow(startCell, endCell) {
|
|
317
|
+
if (isSameCell(startCell, endCell)) {
|
|
318
|
+
return {
|
|
319
|
+
startRow: startCell.rowIndex,
|
|
320
|
+
endRow: startCell.rowIndex
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
var isTopToBottom = startCell.rowIndex <= endCell.rowIndex;
|
|
325
|
+
var startRow = isTopToBottom ? startCell.rowIndex : startCell.rowIndex + startCell.rowSpan - 1;
|
|
326
|
+
var endRow = isTopToBottom ? endCell.rowIndex + endCell.rowSpan - 1 : endCell.rowIndex;
|
|
327
|
+
return {
|
|
328
|
+
startRow: startRow,
|
|
329
|
+
endRow: endRow
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
function isCellRangeSingleCell(rangeSelection) {
|
|
334
|
+
var startRow = rangeSelection.startRow,
|
|
335
|
+
endRow = rangeSelection.endRow,
|
|
336
|
+
columns = rangeSelection.columns,
|
|
337
|
+
footerRowRange = rangeSelection.footerRowRange;
|
|
338
|
+
var isBodySingleCell = !footerRowRange && startRow === endRow && columns.length === 1;
|
|
339
|
+
var isFooterSingleCell = startRow === -1 && footerRowRange.startRow === footerRowRange.endRow && columns.length === 1;
|
|
340
|
+
return isBodySingleCell || isFooterSingleCell;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
function getRowIndex(startRow, endRow) {
|
|
344
|
+
var isReverse = startRow > endRow;
|
|
345
|
+
var startRowIndex = isReverse ? endRow : startRow;
|
|
346
|
+
var endRowIndex = isReverse ? startRow : endRow;
|
|
347
|
+
return {
|
|
348
|
+
startRowIndex: startRowIndex,
|
|
349
|
+
endRowIndex: endRowIndex
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
function getFooterRowIndex(footerRowRange) {
|
|
354
|
+
if (footerRowRange) {
|
|
355
|
+
return getRowIndex(footerRowRange.startRow, footerRowRange.endRow);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
return {
|
|
359
|
+
startRowIndex: -1,
|
|
360
|
+
endRowIndex: -1
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
function getElementEditable(target) {
|
|
365
|
+
var _context2;
|
|
366
|
+
|
|
367
|
+
if (!target) return;
|
|
368
|
+
|
|
369
|
+
if (_includesInstanceProperty(_context2 = ['input', 'textarea']).call(_context2, target.tagName.toLowerCase())) {
|
|
370
|
+
if (target.type === 'checkbox') return;
|
|
371
|
+
return !target.disabled && !target.readOnly;
|
|
372
|
+
}
|
|
233
373
|
}
|
|
@@ -60,6 +60,10 @@ export function singleSelect() {
|
|
|
60
60
|
return preCellProps;
|
|
61
61
|
},
|
|
62
62
|
render: function render(_, row, rowIndex) {
|
|
63
|
+
if (row[pipeline.getFeatureOptions('footerRowMetaKey')]) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
|
|
63
67
|
var rowKey = internals.safeGetRowKey(primaryKey, row, rowIndex);
|
|
64
68
|
return /*#__PURE__*/React.createElement(Radio, {
|
|
65
69
|
checked: value === rowKey,
|
|
@@ -32,6 +32,8 @@ export interface TreeModeFeatureOptions {
|
|
|
32
32
|
stopClickEventPropagation?: boolean;
|
|
33
33
|
/** 指定表格每一行元信息的记录字段 */
|
|
34
34
|
treeMetaKey?: string | symbol;
|
|
35
|
+
/** 指定展开列 */
|
|
36
|
+
expandColCode?: string;
|
|
35
37
|
}
|
|
36
38
|
export declare function treeMode(opts?: TreeModeFeatureOptions): (pipeline: TablePipeline) => TablePipeline;
|
|
37
39
|
export {};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
1
2
|
import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
|
|
2
3
|
import _getIteratorMethod from "@babel/runtime-corejs3/core-js/get-iterator-method";
|
|
3
|
-
import _toArray from "@babel/runtime-corejs3/helpers/toArray";
|
|
4
4
|
import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
5
5
|
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
6
6
|
import _toConsumableArray from "@babel/runtime-corejs3/helpers/toConsumableArray";
|
|
7
7
|
|
|
8
8
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "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; } } }; }
|
|
9
9
|
|
|
10
|
-
function _unsupportedIterableToArray(o, minLen) { var
|
|
10
|
+
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); }
|
|
11
11
|
|
|
12
12
|
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; }
|
|
13
13
|
|
|
@@ -15,7 +15,7 @@ import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
|
|
|
15
15
|
import _Set from "@babel/runtime-corejs3/core-js-stable/set";
|
|
16
16
|
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
17
17
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
18
|
-
import
|
|
18
|
+
import _findIndexInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find-index";
|
|
19
19
|
import cx from 'classnames';
|
|
20
20
|
import React from 'react';
|
|
21
21
|
import { ExpansionCell, icons, InlineFlexCell } from '../../common-views';
|
|
@@ -31,11 +31,6 @@ export function treeMode() {
|
|
|
31
31
|
var stateKey = 'treeMode';
|
|
32
32
|
var ctx = pipeline.ctx;
|
|
33
33
|
var primaryKey = pipeline.ensurePrimaryKey('treeMode');
|
|
34
|
-
|
|
35
|
-
if (typeof primaryKey !== 'string') {
|
|
36
|
-
throw new Error('treeMode 仅支持字符串作为 primaryKey');
|
|
37
|
-
}
|
|
38
|
-
|
|
39
34
|
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 : [];
|
|
40
35
|
var openKeySet = new _Set(openKeys);
|
|
41
36
|
|
|
@@ -90,7 +85,7 @@ export function treeMode() {
|
|
|
90
85
|
try {
|
|
91
86
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
92
87
|
var node = _step.value;
|
|
93
|
-
var rowKey = node
|
|
88
|
+
var rowKey = internals.safeGetRowKey(primaryKey, node, -1);
|
|
94
89
|
var expanded = openKeySet.has(rowKey);
|
|
95
90
|
var isLeaf = isLeafNode(node, {
|
|
96
91
|
depth: depth,
|
|
@@ -120,18 +115,20 @@ export function treeMode() {
|
|
|
120
115
|
}
|
|
121
116
|
|
|
122
117
|
function processColumns(columns) {
|
|
123
|
-
var _context2;
|
|
124
|
-
|
|
125
118
|
if (columns.length === 0) {
|
|
126
119
|
return columns;
|
|
127
120
|
}
|
|
128
121
|
|
|
129
|
-
var
|
|
130
|
-
|
|
131
|
-
|
|
122
|
+
var expandColIndex = _findIndexInstanceProperty(columns).call(columns, function (_ref) {
|
|
123
|
+
var code = _ref.code;
|
|
124
|
+
return code && opts.expandColCode === code;
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
expandColIndex = expandColIndex === -1 ? 0 : expandColIndex;
|
|
128
|
+
var expandCol = columns[expandColIndex];
|
|
132
129
|
|
|
133
130
|
var render = function render(value, record, recordIndex) {
|
|
134
|
-
var content = internals.safeRender(
|
|
131
|
+
var content = internals.safeRender(expandCol, record, recordIndex);
|
|
135
132
|
|
|
136
133
|
if (record[treeMetaKey] == null) {
|
|
137
134
|
// 没有 treeMeta 信息的话,就返回原先的渲染结果
|
|
@@ -191,7 +188,7 @@ export function treeMode() {
|
|
|
191
188
|
};
|
|
192
189
|
|
|
193
190
|
var getCellProps = function getCellProps(value, record, rowIndex) {
|
|
194
|
-
var prevProps = internals.safeGetCellProps(
|
|
191
|
+
var prevProps = internals.safeGetCellProps(expandCol, record, rowIndex);
|
|
195
192
|
|
|
196
193
|
if (record[treeMetaKey] == null) {
|
|
197
194
|
// 没有 treeMeta 信息的话,就返回原先的 cellProps
|
|
@@ -220,15 +217,17 @@ export function treeMode() {
|
|
|
220
217
|
});
|
|
221
218
|
};
|
|
222
219
|
|
|
223
|
-
|
|
220
|
+
columns[expandColIndex] = _extends(_extends({}, expandCol), {
|
|
224
221
|
title: /*#__PURE__*/React.createElement("span", {
|
|
225
222
|
style: {
|
|
226
|
-
marginLeft: iconIndent + iconWidth + iconGap
|
|
223
|
+
marginLeft: iconIndent + iconWidth + iconGap,
|
|
224
|
+
display: 'flex'
|
|
227
225
|
}
|
|
228
|
-
}, internals.safeRenderHeader(
|
|
226
|
+
}, internals.safeRenderHeader(expandCol)),
|
|
229
227
|
render: render,
|
|
230
|
-
getCellProps: clickArea === 'cell' ? getCellProps :
|
|
231
|
-
})
|
|
228
|
+
getCellProps: clickArea === 'cell' ? getCellProps : expandCol.getCellProps
|
|
229
|
+
});
|
|
230
|
+
return _toConsumableArray(columns);
|
|
232
231
|
}
|
|
233
232
|
};
|
|
234
233
|
}
|
|
@@ -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,6 +88,10 @@ 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;
|
|
91
95
|
}
|
|
92
96
|
export declare function useTablePipeline(ctx?: Partial<TablePipelineCtx>): TablePipeline;
|
|
93
97
|
export {};
|
|
@@ -8,6 +8,7 @@ import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instan
|
|
|
8
8
|
import { useState, useRef } from 'react';
|
|
9
9
|
import { mergeCellProps } from '../utils';
|
|
10
10
|
import { autoFillTableWidth, tableWidthKey } from './features/autoFill';
|
|
11
|
+
import { rangeSelectionKey } from './features/rangeSelection';
|
|
11
12
|
/**
|
|
12
13
|
* 表格数据处理流水线。TablePipeline 提供了表格数据处理过程中的一些上下方与工具方法,包括……
|
|
13
14
|
*
|
|
@@ -276,19 +277,19 @@ export var TablePipeline = /*#__PURE__*/function () {
|
|
|
276
277
|
|
|
277
278
|
result.setTableDomHelper = function (domHelper) {
|
|
278
279
|
_this2.ref.current.domHelper = domHelper;
|
|
279
|
-
};
|
|
280
|
-
// result.clearRangeSelectionStatus = () => {
|
|
281
|
-
// const { rangeSelectedChange } = this.getFeatureOptions(rangeSelectionKey)
|
|
282
|
-
// const rangeSelection = this.getStateAtKey(rangeSelectionKey)
|
|
283
|
-
// if (rangeSelection) {
|
|
284
|
-
// rangeSelectedChange?.(null)
|
|
285
|
-
// }
|
|
286
|
-
// }
|
|
287
|
-
// }
|
|
288
|
-
|
|
280
|
+
};
|
|
289
281
|
|
|
290
282
|
return result;
|
|
291
283
|
}
|
|
284
|
+
/**
|
|
285
|
+
* 清除范围选中内容
|
|
286
|
+
*/
|
|
287
|
+
|
|
288
|
+
}, {
|
|
289
|
+
key: "clearRangeSelection",
|
|
290
|
+
value: function clearRangeSelection() {
|
|
291
|
+
this.setStateAtKey(rangeSelectionKey, null);
|
|
292
|
+
}
|
|
292
293
|
}]);
|
|
293
294
|
|
|
294
295
|
return TablePipeline;
|
|
@@ -225,4 +225,8 @@ export function keepWithinBounds(popupParent, popup, x, y, isPerfect) {
|
|
|
225
225
|
x: x,
|
|
226
226
|
y: y
|
|
227
227
|
};
|
|
228
|
+
}
|
|
229
|
+
export function hasScroll(ele) {
|
|
230
|
+
var isHorizontal = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
231
|
+
return isHorizontal ? ele.scrollWidth > ele.clientWidth : ele.scrollHeight > ele.clientHeight;
|
|
228
232
|
}
|
|
@@ -5,13 +5,9 @@ import cx from 'classnames';
|
|
|
5
5
|
|
|
6
6
|
function composeEventHandler(handler1, handler2) {
|
|
7
7
|
return function () {
|
|
8
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
9
|
-
args[_key] = arguments[_key];
|
|
10
|
-
}
|
|
11
|
-
|
|
12
8
|
// 先执行原有的事件回调函数
|
|
13
|
-
handler1(
|
|
14
|
-
handler2(
|
|
9
|
+
handler1.apply(void 0, arguments);
|
|
10
|
+
handler2.apply(void 0, arguments); // 事件回调函数没有返回值,故这里不进行 return
|
|
15
11
|
};
|
|
16
12
|
}
|
|
17
13
|
/** 合并两个 cellProps(单元格属性)对象,返回一个合并后的全新对象。
|
|
@@ -141,7 +141,7 @@ function HtmlTable(_ref) {
|
|
|
141
141
|
positionStyle.left = hozInfo.stickyLeftMap.get(colIndex);
|
|
142
142
|
} else if (colIndex >= fullFlatCount - rightFlatCount) {
|
|
143
143
|
positionStyle.position = 'sticky';
|
|
144
|
-
positionStyle.right = hozInfo.stickyRightMap.get(colIndex) - stickyRightOffset;
|
|
144
|
+
positionStyle.right = hozInfo.stickyRightMap.get(colIndex) - (typeof stickyRightOffset === 'number' ? stickyRightOffset : 0);
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
return /*#__PURE__*/_react.default.createElement('td', (0, _extends2.default)((0, _extends2.default)((0, _extends2.default)((0, _extends2.default)({
|
|
@@ -2,6 +2,7 @@ export declare const LOCK_SHADOW_PADDING = 20;
|
|
|
2
2
|
export declare const Classes: {
|
|
3
3
|
/** BaseTable 表格组件的外层包裹 div */
|
|
4
4
|
readonly artTableWrapper: string;
|
|
5
|
+
readonly artTableBordered: string;
|
|
5
6
|
readonly artTable: string;
|
|
6
7
|
readonly tableHeaderMain: string;
|
|
7
8
|
readonly tableHeader: string;
|
|
@@ -37,9 +38,12 @@ export declare const Classes: {
|
|
|
37
38
|
readonly tableHeaderCellLine: string;
|
|
38
39
|
readonly tableFilterTrigger: string;
|
|
39
40
|
readonly tableSortIcon: string;
|
|
41
|
+
readonly tableExtendIcon: string;
|
|
40
42
|
readonly button: string;
|
|
41
43
|
readonly buttonPrimary: string;
|
|
42
44
|
readonly filterIcon: string;
|
|
45
|
+
readonly rangeSelection: string;
|
|
46
|
+
readonly tableCellRangeSingleCell: string;
|
|
43
47
|
readonly tableCellRangeSelected: string;
|
|
44
48
|
readonly tableCellRangeTop: string;
|
|
45
49
|
readonly tableCellRangeLeft: string;
|
|
@@ -60,6 +64,9 @@ export declare const Classes: {
|
|
|
60
64
|
readonly leaf: string;
|
|
61
65
|
readonly expanded: string;
|
|
62
66
|
readonly collapsed: string;
|
|
67
|
+
readonly popup: string;
|
|
68
|
+
readonly popupHeader: string;
|
|
69
|
+
readonly popupBody: string;
|
|
63
70
|
};
|
|
64
71
|
export declare const MenuClasses: {
|
|
65
72
|
menu: string;
|
|
@@ -112,13 +119,13 @@ export declare type BaseTableCSSVariables = Partial<{
|
|
|
112
119
|
'--border-color': string;
|
|
113
120
|
/** 单元格边框,默认为 1px solid #dfe3e8 */
|
|
114
121
|
'--cell-border': string;
|
|
115
|
-
/** 单元格上下边框,默认为 #dfe3e8 */
|
|
122
|
+
/** 单元格上下边框,默认为 none ,默认值为 1px solid #dfe3e8 */
|
|
116
123
|
'--cell-border-horizontal': string;
|
|
117
124
|
/** 单元格左右边框,默认为 #dfe3e8 */
|
|
118
125
|
'--cell-border-vertical': string;
|
|
119
126
|
/** 表头单元格边框,默认为 1px solid #dfe3e8 */
|
|
120
127
|
'--header-cell-border': string;
|
|
121
|
-
/** 表头单元格上下边框,默认为 1px solid #dfe3e8 */
|
|
128
|
+
/** 表头单元格上下边框,默认为 none ,默认值为 1px solid #dfe3e8 */
|
|
122
129
|
'--header-cell-border-horizontal': string;
|
|
123
130
|
/** 表头单元格左右边框,默认为 1px solid #dfe3e8 */
|
|
124
131
|
'--header-cell-border-vertical': string;
|
|
@@ -148,7 +155,9 @@ export declare const defaultCSSVariables: {
|
|
|
148
155
|
'--cell-border-horizontal': string;
|
|
149
156
|
'---cell-border-vertical': string;
|
|
150
157
|
'--header-cell-border': string;
|
|
158
|
+
'--cell-border-vertical': string;
|
|
151
159
|
'--header-cell-border-horizontal': string;
|
|
160
|
+
'--header-cell-border-vertical': string;
|
|
152
161
|
};
|
|
153
162
|
export declare const variableConst: string;
|
|
154
163
|
export declare const StyledArtTableWrapper: any;
|