@kdcloudjs/table 1.0.1 → 1.0.4
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/LICENSE +1 -1
- package/README.md +34 -33
- package/dist/@kdcloudjs/table.css +1 -1
- package/dist/@kdcloudjs/table.css.map +1 -1
- package/dist/@kdcloudjs/table.js +6555 -3388
- package/dist/@kdcloudjs/table.js.map +1 -1
- package/dist/@kdcloudjs/table.min.css +1 -1
- package/dist/@kdcloudjs/table.min.js +32 -24
- package/dist/@kdcloudjs/table.min.js.map +1 -1
- package/es/_utils/hooks.js +1 -2
- package/es/_utils/numberUtil.js +3 -4
- package/es/locale/locale.js +1 -2
- package/es/table/base/calculations.js +3 -4
- package/es/table/base/empty.js +2 -2
- package/es/table/base/header.d.ts +6 -2
- package/es/table/base/header.js +41 -22
- package/es/table/base/helpers/SpanManager.js +1 -1
- package/es/table/base/helpers/TableDOMUtils.d.ts +3 -0
- package/es/table/base/helpers/TableDOMUtils.js +23 -5
- package/es/table/base/helpers/getRichVisibleRectsStream.d.ts +23 -0
- package/es/table/base/helpers/getRichVisibleRectsStream.js +216 -0
- package/es/table/base/html-table.d.ts +3 -1
- package/es/table/base/html-table.js +43 -26
- package/es/table/base/interfaces.d.ts +1 -0
- package/es/table/base/renderTemplates.d.ts +1 -0
- package/es/table/base/renderTemplates.js +344 -0
- package/es/table/base/styles.d.ts +24 -0
- package/es/table/base/styles.js +31 -9
- package/es/table/base/table.d.ts +12 -4
- package/es/table/base/table.js +183 -136
- package/es/table/base/utils.d.ts +6 -3
- package/es/table/base/utils.js +27 -6
- package/es/table/common-views.js +3 -3
- package/es/table/pipeline/features/autoFill.js +7 -1
- package/es/table/pipeline/features/columnDrag.js +168 -59
- package/es/table/pipeline/features/columnFilter.js +7 -9
- package/es/table/pipeline/features/columnResizeWidth.d.ts +3 -0
- package/es/table/pipeline/features/columnResizeWidth.js +11 -4
- package/es/table/pipeline/features/contextMenu.js +78 -31
- package/es/table/pipeline/features/filter/Filter.js +74 -37
- package/es/table/pipeline/features/index.d.ts +1 -0
- package/es/table/pipeline/features/index.js +2 -1
- package/es/table/pipeline/features/multiSelect.js +85 -79
- package/es/table/pipeline/features/rangeSelection.d.ts +10 -0
- package/es/table/pipeline/features/rangeSelection.js +231 -0
- package/es/table/pipeline/features/rowDetail.js +39 -16
- package/es/table/pipeline/features/rowGrouping.js +2 -1
- package/es/table/pipeline/features/singleSelect.js +4 -1
- package/es/table/pipeline/features/sort.js +2 -3
- package/es/table/pipeline/features/treeMode.js +4 -4
- package/es/table/pipeline/pipeline.d.ts +8 -0
- package/es/table/pipeline/pipeline.js +49 -5
- package/es/table/pivot/cross-table/buildCrossTable.js +1 -2
- package/es/table/pivot/cross-tree-table/buildCrossTreeTable.js +1 -2
- package/es/table/pivot/pivot-utils/builders.js +1 -2
- package/es/table/pivot/pivot-utils/convert-utils.js +5 -4
- package/es/table/transforms/autoWidth.js +1 -2
- package/es/table/transforms/sort.js +1 -2
- package/es/table/transforms/treeMode.js +1 -2
- package/es/table/utils/applyTransforms.js +1 -3
- package/es/table/utils/browserType.d.ts +6 -0
- package/es/table/utils/browserType.js +6 -0
- package/es/table/utils/buildTree.js +4 -5
- package/es/table/utils/collectNodes.js +1 -2
- package/es/table/utils/exportTableAsExcel.js +1 -2
- package/es/table/utils/getTreeDepth.js +1 -2
- package/es/table/utils/groupBy.js +1 -2
- package/es/table/utils/index.d.ts +1 -0
- package/es/table/utils/index.js +2 -1
- package/es/table/utils/layeredSort.js +5 -2
- package/es/table/utils/makeRecursiveMapper.js +4 -5
- package/es/table/utils/others.d.ts +1 -1
- package/es/table/utils/others.js +20 -14
- package/es/table/utils/traverseColumn.js +1 -2
- package/es/table/utils/tree-data-helpers/StrictTreeDataHelper.js +4 -5
- package/es/table/utils/tree-data-helpers/TreeDataHelper.js +4 -5
- package/lib/_utils/formatUtil.js +1 -1
- package/lib/_utils/hooks.js +2 -4
- package/lib/_utils/numberUtil.js +7 -9
- package/lib/_utils/usePopper.js +9 -1
- package/lib/config-provider/configProvider.js +9 -1
- package/lib/config-provider/index.js +5 -5
- package/lib/locale/index.js +14 -6
- package/lib/locale/locale.js +2 -4
- package/lib/table/base/calculations.js +4 -6
- package/lib/table/base/empty.js +11 -3
- package/lib/table/base/header.d.ts +6 -2
- package/lib/table/base/header.js +39 -19
- package/lib/table/base/helpers/SpanManager.js +1 -1
- package/lib/table/base/helpers/TableDOMUtils.d.ts +3 -0
- package/lib/table/base/helpers/TableDOMUtils.js +21 -5
- package/lib/table/base/helpers/getRichVisibleRectsStream.d.ts +23 -0
- package/lib/table/base/helpers/getRichVisibleRectsStream.js +246 -0
- package/lib/table/base/html-table.d.ts +3 -1
- package/lib/table/base/html-table.js +44 -26
- package/lib/table/base/index.js +4 -4
- package/lib/table/base/interfaces.d.ts +1 -0
- package/lib/table/base/renderTemplates.d.ts +1 -0
- package/lib/table/base/renderTemplates.js +370 -0
- package/lib/table/base/styles.d.ts +24 -0
- package/lib/table/base/styles.js +42 -13
- package/lib/table/base/table.d.ts +12 -4
- package/lib/table/base/table.js +191 -137
- package/lib/table/base/utils.d.ts +6 -3
- package/lib/table/base/utils.js +47 -10
- package/lib/table/common-views.js +3 -3
- package/lib/table/pipeline/features/autoFill.js +9 -2
- package/lib/table/pipeline/features/columnDrag.js +168 -59
- package/lib/table/pipeline/features/columnFilter.js +6 -9
- package/lib/table/pipeline/features/columnResizeWidth.d.ts +3 -0
- package/lib/table/pipeline/features/columnResizeWidth.js +21 -5
- package/lib/table/pipeline/features/contextMenu.js +89 -32
- package/lib/table/pipeline/features/filter/DefaultFilterContent.js +10 -2
- package/lib/table/pipeline/features/filter/Filter.js +88 -37
- package/lib/table/pipeline/features/filter/FilterPanel.js +10 -2
- package/lib/table/pipeline/features/filter/index.js +4 -4
- package/lib/table/pipeline/features/index.d.ts +1 -0
- package/lib/table/pipeline/features/index.js +37 -27
- package/lib/table/pipeline/features/multiSelect.js +81 -75
- package/lib/table/pipeline/features/rangeSelection.d.ts +10 -0
- package/lib/table/pipeline/features/rangeSelection.js +256 -0
- package/lib/table/pipeline/features/rowDetail.js +42 -16
- package/lib/table/pipeline/features/rowGrouping.js +3 -1
- package/lib/table/pipeline/features/singleSelect.js +4 -1
- package/lib/table/pipeline/features/sort.js +2 -4
- package/lib/table/pipeline/features/treeMode.js +6 -6
- package/lib/table/pipeline/index.js +11 -3
- package/lib/table/pipeline/pipeline.d.ts +8 -0
- package/lib/table/pipeline/pipeline.js +50 -7
- package/lib/table/pivot/cross-table/buildCrossTable.js +1 -3
- package/lib/table/pivot/cross-table/index.js +4 -4
- package/lib/table/pivot/cross-tree-table/buildCrossTreeTable.js +1 -3
- package/lib/table/pivot/pivot-utils/builders.js +2 -4
- package/lib/table/pivot/pivot-utils/convert-utils.js +7 -5
- package/lib/table/pivot/pivot-utils/index.js +4 -4
- package/lib/table/transforms/autoWidth.js +10 -4
- package/lib/table/transforms/columnResize.js +10 -2
- package/lib/table/transforms/index.js +32 -32
- package/lib/table/transforms/sort.js +10 -4
- package/lib/table/transforms/treeMode.js +9 -3
- package/lib/table/utils/applyTransforms.js +1 -5
- package/lib/table/utils/browserType.d.ts +6 -0
- package/lib/table/utils/browserType.js +13 -0
- package/lib/table/utils/buildTree.js +1 -3
- package/lib/table/utils/collectNodes.js +1 -3
- package/lib/table/utils/copyToClipboard.js +1 -1
- package/lib/table/utils/element.js +3 -3
- package/lib/table/utils/exportTableAsExcel.js +1 -3
- package/lib/table/utils/getTreeDepth.js +1 -3
- package/lib/table/utils/groupBy.js +1 -3
- package/lib/table/utils/index.d.ts +1 -0
- package/lib/table/utils/index.js +57 -49
- package/lib/table/utils/layeredSort.js +6 -2
- package/lib/table/utils/makeRecursiveMapper.js +1 -3
- package/lib/table/utils/others.d.ts +1 -1
- package/lib/table/utils/others.js +23 -18
- package/lib/table/utils/traverseColumn.js +1 -3
- package/lib/table/utils/tree-data-helpers/StrictTreeDataHelper.js +5 -7
- package/lib/table/utils/tree-data-helpers/TreeDataHelper.js +5 -7
- package/package.json +6 -2
- package/dist/kd-table.css +0 -422
- package/dist/kd-table.css.map +0 -1
- package/dist/kd-table.js +0 -38578
- package/dist/kd-table.js.map +0 -1
- package/dist/kd-table.min.css +0 -9
- package/dist/kd-table.min.js +0 -208
- package/dist/kd-table.min.js.map +0 -1
- package/es/table/base/helpers/__test__/visible-part.test.d.ts +0 -1
- package/es/table/base/helpers/__test__/visible-part.test.js +0 -28
- package/es/table/base/helpers/visible-part.d.ts +0 -23
- package/es/table/base/helpers/visible-part.js +0 -58
- package/es/table/pipeline/features/__test__/multiSelect.test.d.ts +0 -1
- package/es/table/pipeline/features/__test__/multiSelect.test.js +0 -152
- package/es/table/pipeline/features/__test__/rowDetail.test.d.ts +0 -1
- package/es/table/pipeline/features/__test__/rowDetail.test.js +0 -223
- package/es/table/pipeline/features/__test__/rowGrouping.test.d.ts +0 -1
- package/es/table/pipeline/features/__test__/rowGrouping.test.js +0 -120
- package/es/table/pipeline/features/__test__/singleSelect.test.d.ts +0 -1
- package/es/table/pipeline/features/__test__/singleSelect.test.js +0 -191
- package/es/table/pipeline/features/__test__/sort.test.d.ts +0 -1
- package/es/table/pipeline/features/__test__/sort.test.js +0 -213
- package/es/table/pipeline/features/__test__/tips.test.d.ts +0 -1
- package/es/table/pipeline/features/__test__/tips.test.js +0 -123
- package/es/table/pipeline/features/__test__/treeMode.test.d.ts +0 -1
- package/es/table/pipeline/features/__test__/treeMode.test.js +0 -202
- package/es/table/pipeline/features/filter/__test__/Filter.test.d.ts +0 -1
- package/es/table/pipeline/features/filter/__test__/Filter.test.js +0 -29
- package/lib/table/base/helpers/__test__/visible-part.test.d.ts +0 -1
- package/lib/table/base/helpers/__test__/visible-part.test.js +0 -31
- package/lib/table/base/helpers/visible-part.d.ts +0 -23
- package/lib/table/base/helpers/visible-part.js +0 -72
- package/lib/table/pipeline/features/__test__/multiSelect.test.d.ts +0 -1
- package/lib/table/pipeline/features/__test__/multiSelect.test.js +0 -163
- package/lib/table/pipeline/features/__test__/rowDetail.test.d.ts +0 -1
- package/lib/table/pipeline/features/__test__/rowDetail.test.js +0 -230
- package/lib/table/pipeline/features/__test__/rowGrouping.test.d.ts +0 -1
- package/lib/table/pipeline/features/__test__/rowGrouping.test.js +0 -129
- package/lib/table/pipeline/features/__test__/singleSelect.test.d.ts +0 -1
- package/lib/table/pipeline/features/__test__/singleSelect.test.js +0 -201
- package/lib/table/pipeline/features/__test__/sort.test.d.ts +0 -1
- package/lib/table/pipeline/features/__test__/sort.test.js +0 -218
- package/lib/table/pipeline/features/__test__/tips.test.d.ts +0 -1
- package/lib/table/pipeline/features/__test__/tips.test.js +0 -133
- package/lib/table/pipeline/features/__test__/treeMode.test.d.ts +0 -1
- package/lib/table/pipeline/features/__test__/treeMode.test.js +0 -206
- package/lib/table/pipeline/features/filter/__test__/Filter.test.d.ts +0 -1
- package/lib/table/pipeline/features/filter/__test__/Filter.test.js +0 -36
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
2
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
2
3
|
import _flatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/flat";
|
|
3
4
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
5
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
4
6
|
import cx from 'classnames';
|
|
5
7
|
import React from 'react';
|
|
6
8
|
import { internals } from '../internals';
|
|
7
9
|
import { Colgroup } from './colgroup';
|
|
8
10
|
import SpanManager from './helpers/SpanManager';
|
|
9
11
|
import { Classes } from './styles';
|
|
12
|
+
import { getScrollbarSize } from './utils';
|
|
10
13
|
export function HtmlTable(_ref) {
|
|
11
14
|
var tbodyHtmlTag = _ref.tbodyHtmlTag,
|
|
12
15
|
getRowProps = _ref.getRowProps,
|
|
13
16
|
primaryKey = _ref.primaryKey,
|
|
17
|
+
hasScrollY = _ref.hasScrollY,
|
|
14
18
|
data = _ref.data,
|
|
15
19
|
verInfo = _ref.verticalRenderInfo,
|
|
16
|
-
hozInfo = _ref.horizontalRenderInfo
|
|
20
|
+
hozInfo = _ref.horizontalRenderInfo,
|
|
21
|
+
tbodyPosition = _ref.tbodyPosition;
|
|
17
22
|
|
|
18
23
|
var flat = _flatInstanceProperty(hozInfo),
|
|
19
24
|
hoz = hozInfo.horizontalRenderRange;
|
|
@@ -27,26 +32,39 @@ export function HtmlTable(_ref) {
|
|
|
27
32
|
}), /*#__PURE__*/React.createElement(tbodyHtmlTag, null, _mapInstanceProperty(data).call(data, renderRow)));
|
|
28
33
|
|
|
29
34
|
function renderRow(record, i) {
|
|
30
|
-
var _context;
|
|
35
|
+
var _cx, _context;
|
|
31
36
|
|
|
32
37
|
var rowIndex = verInfo.offset + i;
|
|
33
38
|
spanManager.stripUpwards(rowIndex);
|
|
34
39
|
var rowProps = getRowProps(record, rowIndex);
|
|
35
|
-
var rowClass = cx(Classes.tableRow, {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
var rowClass = cx(Classes.tableRow, (_cx = {}, _defineProperty(_cx, Classes.first, rowIndex === verInfo.first), _defineProperty(_cx, Classes.last, rowIndex === verInfo.last), _defineProperty(_cx, Classes.even, rowIndex % 2 === 0), _defineProperty(_cx, Classes.odd, rowIndex % 2 === 1), _cx), rowProps === null || rowProps === void 0 ? void 0 : rowProps.className);
|
|
41
|
+
|
|
42
|
+
var visibleColumnDescriptor = _concatInstanceProperty(_context = hozInfo.visible).call(_context); // 左中右区域渲染,存在融合单元格时需要适配rowspan属性
|
|
43
|
+
// 如果固定的列均存在融合单元格,需空白一列做占位,否则融合的单元格不会渲染,导致显示异常
|
|
44
|
+
// 这里无法区分是否存在融合列,默认左右固定区域均添加占位空白列
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
if (['left', 'right'].indexOf(tbodyPosition) > -1) {
|
|
48
|
+
visibleColumnDescriptor.push({
|
|
49
|
+
type: 'blank',
|
|
50
|
+
blankSide: 'left',
|
|
51
|
+
width: 0,
|
|
52
|
+
isPlacehoder: true
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
41
56
|
return /*#__PURE__*/React.createElement("tr", _extends({}, rowProps, {
|
|
42
57
|
className: rowClass,
|
|
43
|
-
key: internals.safeGetRowKey(primaryKey, record, rowIndex),
|
|
58
|
+
key: (rowProps === null || rowProps === void 0 ? void 0 : rowProps['data-row-detail-key']) ? rowProps['data-row-detail-key'] : internals.safeGetRowKey(primaryKey, record, rowIndex),
|
|
44
59
|
"data-rowindex": rowIndex,
|
|
45
60
|
"data-role": 'table-row'
|
|
46
|
-
}), _mapInstanceProperty(
|
|
61
|
+
}), _mapInstanceProperty(visibleColumnDescriptor).call(visibleColumnDescriptor, function (descriptor) {
|
|
47
62
|
if (descriptor.type === 'blank') {
|
|
48
63
|
return /*#__PURE__*/React.createElement("td", {
|
|
49
|
-
key: descriptor.blankSide
|
|
64
|
+
key: descriptor.blankSide,
|
|
65
|
+
style: {
|
|
66
|
+
visibility: descriptor.isPlacehoder ? 'hidden' : undefined
|
|
67
|
+
}
|
|
50
68
|
});
|
|
51
69
|
}
|
|
52
70
|
|
|
@@ -55,6 +73,8 @@ export function HtmlTable(_ref) {
|
|
|
55
73
|
}
|
|
56
74
|
|
|
57
75
|
function renderBodyCell(record, rowIndex, column, colIndex) {
|
|
76
|
+
var _cx2;
|
|
77
|
+
|
|
58
78
|
var _a, _b, _c;
|
|
59
79
|
|
|
60
80
|
if (spanManager.testSkip(rowIndex, colIndex)) {
|
|
@@ -84,38 +104,35 @@ export function HtmlTable(_ref) {
|
|
|
84
104
|
if (cellProps.rowSpan != null) {
|
|
85
105
|
rowSpan = cellProps.rowSpan;
|
|
86
106
|
}
|
|
87
|
-
}
|
|
88
|
-
|
|
107
|
+
}
|
|
89
108
|
|
|
90
|
-
rowSpan = Math.min(rowSpan, verInfo.limit - rowIndex);
|
|
91
|
-
colSpan = Math.min(colSpan, leftFlatCount + hoz.rightIndex - colIndex);
|
|
92
109
|
var hasSpan = colSpan > 1 || rowSpan > 1;
|
|
93
110
|
|
|
94
111
|
if (hasSpan) {
|
|
95
112
|
spanManager.add(rowIndex, colIndex, colSpan, rowSpan);
|
|
96
|
-
}
|
|
113
|
+
} // rowSpan/colSpan 不能过大,避免 rowSpan/colSpan 影响因虚拟滚动而未渲染的单元格
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
rowSpan = Math.min(rowSpan, verInfo.limit - rowIndex);
|
|
117
|
+
colSpan = Math.min(colSpan, hozInfo.visible.length - colIndex); // todo: 右侧有列固定的情况下colSpan计算不对,这里先限制一下
|
|
97
118
|
|
|
119
|
+
rowSpan = Math.max(rowSpan, 1);
|
|
120
|
+
colSpan = Math.max(colSpan, 1);
|
|
98
121
|
var positionStyle = {};
|
|
122
|
+
var scrollbarWidth = hasScrollY ? getScrollbarSize().width : 0;
|
|
99
123
|
|
|
100
124
|
if (colIndex < leftFlatCount) {
|
|
101
125
|
positionStyle.position = 'sticky';
|
|
102
126
|
positionStyle.left = hozInfo.stickyLeftMap.get(colIndex);
|
|
103
127
|
} else if (colIndex >= fullFlatCount - rightFlatCount) {
|
|
104
128
|
positionStyle.position = 'sticky';
|
|
105
|
-
positionStyle.right = hozInfo.stickyRightMap.get(colIndex);
|
|
129
|
+
positionStyle.right = hozInfo.stickyRightMap.get(colIndex) - scrollbarWidth;
|
|
106
130
|
}
|
|
107
131
|
|
|
108
132
|
return /*#__PURE__*/React.createElement('td', _extends(_extends(_extends(_extends({
|
|
109
133
|
key: colIndex
|
|
110
134
|
}, cellProps), {
|
|
111
|
-
className: cx(Classes.tableCell, cellProps.className, {
|
|
112
|
-
// class
|
|
113
|
-
first: colIndex === 0,
|
|
114
|
-
last: colIndex + colSpan === fullFlatCount,
|
|
115
|
-
'lock-left': colIndex < leftFlatCount,
|
|
116
|
-
'lock-right': colIndex >= fullFlatCount - rightFlatCount,
|
|
117
|
-
'row-span': rowSpan > 1
|
|
118
|
-
})
|
|
135
|
+
className: cx(Classes.tableCell, cellProps.className, (_cx2 = {}, _defineProperty(_cx2, Classes.first, colIndex === 0), _defineProperty(_cx2, Classes.last, colIndex + colSpan === fullFlatCount), _defineProperty(_cx2, Classes.lockLeft, colIndex < leftFlatCount || tbodyPosition === 'left'), _defineProperty(_cx2, Classes.lockRight, colIndex >= fullFlatCount - rightFlatCount), _defineProperty(_cx2, Classes.rowSpan, rowSpan > 1), _cx2))
|
|
119
136
|
}), hasSpan ? {
|
|
120
137
|
colSpan: colSpan,
|
|
121
138
|
rowSpan: rowSpan
|
|
@@ -127,6 +144,6 @@ export function HtmlTable(_ref) {
|
|
|
127
144
|
'data-role': 'table-cell',
|
|
128
145
|
'data-rowindex': rowIndex,
|
|
129
146
|
'data-code': column.code
|
|
130
|
-
}), cellContent);
|
|
147
|
+
}), tbodyPosition === 'center' && positionStyle.position === 'sticky' ? null : cellContent);
|
|
131
148
|
}
|
|
132
149
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function getTableHeaderRenderTemplate(type: string): any;
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
2
|
+
import _Map from "@babel/runtime-corejs3/core-js-stable/map";
|
|
3
|
+
import _flatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/flat";
|
|
4
|
+
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
5
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* @Author: wqhui
|
|
9
|
+
* @Date: 2022-03-14 11:21:12
|
|
10
|
+
* @Description: 不同情况的渲染模板,比如IE下的
|
|
11
|
+
*/
|
|
12
|
+
import React, { useEffect, useRef } from 'react';
|
|
13
|
+
import ReactDom from 'react-dom';
|
|
14
|
+
import cx from 'classnames';
|
|
15
|
+
import { HtmlTable } from './html-table';
|
|
16
|
+
import { Classes } from './styles';
|
|
17
|
+
import { composeRowPropsGetter, getScrollbarSize } from './utils';
|
|
18
|
+
import { getTreeDepth, browserType } from '../utils';
|
|
19
|
+
import TableHeader from './header';
|
|
20
|
+
var TEMPLATES = new _Map();
|
|
21
|
+
|
|
22
|
+
function renderTableHeaderInIE(info, props) {
|
|
23
|
+
var stickyTop = props.stickyTop,
|
|
24
|
+
hasHeader = props.hasHeader;
|
|
25
|
+
|
|
26
|
+
var flat = _flatInstanceProperty(info),
|
|
27
|
+
nested = info.nested,
|
|
28
|
+
visible = info.visible,
|
|
29
|
+
hasLockColumn = info.hasLockColumn;
|
|
30
|
+
|
|
31
|
+
var left = flat.left,
|
|
32
|
+
right = flat.right;
|
|
33
|
+
var leftNested = nested.left,
|
|
34
|
+
rightNested = nested.right,
|
|
35
|
+
full = nested.full;
|
|
36
|
+
var rowCount = getTreeDepth(full) + 1;
|
|
37
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
38
|
+
className: cx(Classes.tableHeader)
|
|
39
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
40
|
+
className: cx(Classes.tableHeaderMain, 'no-scrollbar'),
|
|
41
|
+
style: {
|
|
42
|
+
top: stickyTop === 0 ? undefined : stickyTop,
|
|
43
|
+
display: hasHeader ? undefined : 'none'
|
|
44
|
+
}
|
|
45
|
+
}, /*#__PURE__*/React.createElement(TableHeader, {
|
|
46
|
+
info: info,
|
|
47
|
+
theaderPosition: hasLockColumn ? 'center' : undefined
|
|
48
|
+
})), left.length > 0 ? /*#__PURE__*/React.createElement("div", {
|
|
49
|
+
className: Classes.fixedLeft
|
|
50
|
+
}, /*#__PURE__*/React.createElement(TableHeader, {
|
|
51
|
+
info: _extends(_extends({}, info), {
|
|
52
|
+
flat: {
|
|
53
|
+
center: left,
|
|
54
|
+
full: left,
|
|
55
|
+
left: [],
|
|
56
|
+
right: []
|
|
57
|
+
},
|
|
58
|
+
nested: {
|
|
59
|
+
center: leftNested,
|
|
60
|
+
full: leftNested,
|
|
61
|
+
left: [],
|
|
62
|
+
right: []
|
|
63
|
+
},
|
|
64
|
+
visible: _sliceInstanceProperty(visible).call(visible, 0, left.length),
|
|
65
|
+
horizontalRenderRange: {
|
|
66
|
+
leftIndex: 0,
|
|
67
|
+
leftBlank: 0,
|
|
68
|
+
rightIndex: left.length,
|
|
69
|
+
rightBlank: 0
|
|
70
|
+
}
|
|
71
|
+
}),
|
|
72
|
+
theaderPosition: "left",
|
|
73
|
+
rowCount: rowCount
|
|
74
|
+
})) : null, right.length > 0 ? /*#__PURE__*/React.createElement("div", {
|
|
75
|
+
className: Classes.fixedRight
|
|
76
|
+
}, /*#__PURE__*/React.createElement(TableHeader, {
|
|
77
|
+
info: _extends(_extends({}, info), {
|
|
78
|
+
flat: {
|
|
79
|
+
center: right,
|
|
80
|
+
full: right,
|
|
81
|
+
left: [],
|
|
82
|
+
right: []
|
|
83
|
+
},
|
|
84
|
+
nested: {
|
|
85
|
+
center: rightNested,
|
|
86
|
+
full: rightNested,
|
|
87
|
+
left: [],
|
|
88
|
+
right: []
|
|
89
|
+
},
|
|
90
|
+
visible: _sliceInstanceProperty(visible).call(visible, visible.length - right.length),
|
|
91
|
+
horizontalRenderRange: {
|
|
92
|
+
leftIndex: 0,
|
|
93
|
+
leftBlank: 0,
|
|
94
|
+
rightIndex: right.length,
|
|
95
|
+
rightBlank: 0
|
|
96
|
+
}
|
|
97
|
+
}),
|
|
98
|
+
theaderPosition: 'right',
|
|
99
|
+
rowCount: rowCount
|
|
100
|
+
})) : null);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function renderTableBodyInIE(info, props, extra) {
|
|
104
|
+
var dataSource = props.dataSource,
|
|
105
|
+
getRowProps = props.getRowProps,
|
|
106
|
+
primaryKey = props.primaryKey;
|
|
107
|
+
var _info$verticalRenderR = info.verticalRenderRange,
|
|
108
|
+
topIndex = _info$verticalRenderR.topIndex,
|
|
109
|
+
bottomBlank = _info$verticalRenderR.bottomBlank,
|
|
110
|
+
topBlank = _info$verticalRenderR.topBlank,
|
|
111
|
+
bottomIndex = _info$verticalRenderR.bottomIndex;
|
|
112
|
+
|
|
113
|
+
var flat = _flatInstanceProperty(info),
|
|
114
|
+
visible = info.visible,
|
|
115
|
+
hasLockColumn = info.hasLockColumn;
|
|
116
|
+
|
|
117
|
+
var left = flat.left,
|
|
118
|
+
right = flat.right;
|
|
119
|
+
var verticalRenderInfo = {
|
|
120
|
+
first: 0,
|
|
121
|
+
offset: topIndex,
|
|
122
|
+
limit: bottomIndex,
|
|
123
|
+
last: dataSource.length - 1
|
|
124
|
+
};
|
|
125
|
+
var commonProps = {
|
|
126
|
+
getRowProps: composeRowPropsGetter(getRowProps, extra.rowProps),
|
|
127
|
+
primaryKey: primaryKey,
|
|
128
|
+
data: _sliceInstanceProperty(dataSource).call(dataSource, topIndex, bottomIndex)
|
|
129
|
+
};
|
|
130
|
+
var scrollbarWidth = extra.hasScrollY ? getScrollbarSize().width : 0;
|
|
131
|
+
var fixedRightTableStyle = {
|
|
132
|
+
right: -scrollbarWidth
|
|
133
|
+
};
|
|
134
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
135
|
+
className: cx(Classes.tableBody, Classes.horizontalScrollContainer)
|
|
136
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
137
|
+
className: Classes.virtual
|
|
138
|
+
}, topBlank > 0 && /*#__PURE__*/React.createElement("div", {
|
|
139
|
+
key: "top-blank",
|
|
140
|
+
className: cx(Classes.virtualBlank, 'top'),
|
|
141
|
+
style: {
|
|
142
|
+
height: topBlank
|
|
143
|
+
}
|
|
144
|
+
}), /*#__PURE__*/React.createElement(HtmlTable, _extends({
|
|
145
|
+
tbodyHtmlTag: "tbody"
|
|
146
|
+
}, commonProps, {
|
|
147
|
+
tbodyPosition: hasLockColumn ? 'center' : undefined,
|
|
148
|
+
horizontalRenderInfo: info,
|
|
149
|
+
verticalRenderInfo: verticalRenderInfo
|
|
150
|
+
})), bottomBlank > 0 && /*#__PURE__*/React.createElement("div", {
|
|
151
|
+
key: "bottom-blank",
|
|
152
|
+
className: cx(Classes.virtualBlank, 'bottom'),
|
|
153
|
+
style: {
|
|
154
|
+
height: bottomBlank
|
|
155
|
+
}
|
|
156
|
+
})), left.length > 0 ? /*#__PURE__*/React.createElement("div", {
|
|
157
|
+
className: Classes.fixedLeft
|
|
158
|
+
}, topBlank > 0 && /*#__PURE__*/React.createElement("div", {
|
|
159
|
+
key: "top-blank",
|
|
160
|
+
className: cx(Classes.virtualBlank, 'top'),
|
|
161
|
+
style: {
|
|
162
|
+
height: topBlank
|
|
163
|
+
}
|
|
164
|
+
}), /*#__PURE__*/React.createElement(HtmlTable, _extends({
|
|
165
|
+
tbodyHtmlTag: "tbody"
|
|
166
|
+
}, commonProps, {
|
|
167
|
+
tbodyPosition: "left",
|
|
168
|
+
horizontalRenderInfo: _extends(_extends({}, info), {
|
|
169
|
+
flat: {
|
|
170
|
+
center: left,
|
|
171
|
+
full: left,
|
|
172
|
+
left: [],
|
|
173
|
+
right: []
|
|
174
|
+
},
|
|
175
|
+
visible: _sliceInstanceProperty(visible).call(visible, 0, left.length)
|
|
176
|
+
}),
|
|
177
|
+
verticalRenderInfo: verticalRenderInfo
|
|
178
|
+
})), bottomBlank > 0 && /*#__PURE__*/React.createElement("div", {
|
|
179
|
+
key: "bottom-blank",
|
|
180
|
+
className: cx(Classes.virtualBlank, 'bottom'),
|
|
181
|
+
style: {
|
|
182
|
+
height: bottomBlank
|
|
183
|
+
}
|
|
184
|
+
})) : null, right.length > 0 ? /*#__PURE__*/React.createElement("div", {
|
|
185
|
+
className: Classes.fixedRight,
|
|
186
|
+
style: fixedRightTableStyle
|
|
187
|
+
}, topBlank > 0 && /*#__PURE__*/React.createElement("div", {
|
|
188
|
+
key: "top-blank",
|
|
189
|
+
className: cx(Classes.virtualBlank, 'top'),
|
|
190
|
+
style: {
|
|
191
|
+
height: topBlank
|
|
192
|
+
}
|
|
193
|
+
}), /*#__PURE__*/React.createElement(HtmlTable, _extends({
|
|
194
|
+
tbodyHtmlTag: "tbody"
|
|
195
|
+
}, commonProps, {
|
|
196
|
+
tbodyPosition: "right",
|
|
197
|
+
hasScrollY: extra.hasScrollY,
|
|
198
|
+
horizontalRenderInfo: _extends(_extends({}, info), {
|
|
199
|
+
flat: {
|
|
200
|
+
center: right,
|
|
201
|
+
full: right,
|
|
202
|
+
left: [],
|
|
203
|
+
right: []
|
|
204
|
+
},
|
|
205
|
+
visible: _sliceInstanceProperty(visible).call(visible, visible.length - right.length)
|
|
206
|
+
}),
|
|
207
|
+
verticalRenderInfo: verticalRenderInfo
|
|
208
|
+
})), bottomBlank > 0 && /*#__PURE__*/React.createElement("div", {
|
|
209
|
+
key: "bottom-blank",
|
|
210
|
+
className: cx(Classes.virtualBlank, 'bottom'),
|
|
211
|
+
style: {
|
|
212
|
+
height: bottomBlank
|
|
213
|
+
}
|
|
214
|
+
})) : null, /*#__PURE__*/React.createElement("div", {
|
|
215
|
+
className: Classes.rowDetailContainer
|
|
216
|
+
}));
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function renderTableFooterInIE(info, props, extra) {
|
|
220
|
+
var _props$footerDataSour = props.footerDataSource,
|
|
221
|
+
footerDataSource = _props$footerDataSour === void 0 ? [] : _props$footerDataSour,
|
|
222
|
+
getRowProps = props.getRowProps,
|
|
223
|
+
primaryKey = props.primaryKey,
|
|
224
|
+
stickyBottom = props.stickyBottom;
|
|
225
|
+
|
|
226
|
+
var _getRowProps = composeRowPropsGetter(getRowProps, extra.rowProps);
|
|
227
|
+
|
|
228
|
+
var flat = _flatInstanceProperty(info),
|
|
229
|
+
visible = info.visible,
|
|
230
|
+
hasLockColumn = info.hasLockColumn;
|
|
231
|
+
|
|
232
|
+
var left = flat.left,
|
|
233
|
+
right = flat.right;
|
|
234
|
+
var verticalRenderInfo = {
|
|
235
|
+
offset: 0,
|
|
236
|
+
first: 0,
|
|
237
|
+
last: footerDataSource.length - 1,
|
|
238
|
+
limit: Infinity
|
|
239
|
+
};
|
|
240
|
+
var commonProps = {
|
|
241
|
+
data: footerDataSource,
|
|
242
|
+
getRowProps: _getRowProps,
|
|
243
|
+
primaryKey: primaryKey,
|
|
244
|
+
verticalRenderInfo: verticalRenderInfo
|
|
245
|
+
};
|
|
246
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
247
|
+
className: cx(Classes.tableFooter),
|
|
248
|
+
style: {
|
|
249
|
+
bottom: stickyBottom === 0 ? undefined : stickyBottom
|
|
250
|
+
}
|
|
251
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
252
|
+
className: cx(Classes.tableFooterMain, Classes.horizontalScrollContainer)
|
|
253
|
+
}, /*#__PURE__*/React.createElement(HtmlTable, _extends({
|
|
254
|
+
tbodyHtmlTag: "tfoot"
|
|
255
|
+
}, commonProps, {
|
|
256
|
+
tbodyPosition: hasLockColumn ? 'center' : undefined,
|
|
257
|
+
horizontalRenderInfo: info
|
|
258
|
+
}))), left.length > 0 ? /*#__PURE__*/React.createElement("div", {
|
|
259
|
+
className: Classes.fixedLeft
|
|
260
|
+
}, /*#__PURE__*/React.createElement(HtmlTable, _extends({
|
|
261
|
+
tbodyHtmlTag: "tfoot"
|
|
262
|
+
}, commonProps, {
|
|
263
|
+
tbodyPosition: "left",
|
|
264
|
+
horizontalRenderInfo: _extends(_extends({}, info), {
|
|
265
|
+
flat: {
|
|
266
|
+
center: left,
|
|
267
|
+
full: left,
|
|
268
|
+
left: [],
|
|
269
|
+
right: []
|
|
270
|
+
},
|
|
271
|
+
visible: _sliceInstanceProperty(visible).call(visible, 0, left.length)
|
|
272
|
+
})
|
|
273
|
+
}))) : null, right.length > 0 ? /*#__PURE__*/React.createElement("div", {
|
|
274
|
+
className: Classes.fixedRight
|
|
275
|
+
}, /*#__PURE__*/React.createElement(HtmlTable, _extends({
|
|
276
|
+
tbodyHtmlTag: "tfoot"
|
|
277
|
+
}, commonProps, {
|
|
278
|
+
tbodyPosition: "right",
|
|
279
|
+
horizontalRenderInfo: _extends(_extends({}, info), {
|
|
280
|
+
flat: {
|
|
281
|
+
center: right,
|
|
282
|
+
full: right,
|
|
283
|
+
left: [],
|
|
284
|
+
right: []
|
|
285
|
+
},
|
|
286
|
+
visible: _sliceInstanceProperty(visible).call(visible, visible.length - right.length)
|
|
287
|
+
})
|
|
288
|
+
}))) : null);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function renderRowDetailInIE(params) {
|
|
292
|
+
var domHelper = params.domHelper;
|
|
293
|
+
if (!domHelper) return;
|
|
294
|
+
var artTable = domHelper.artTable;
|
|
295
|
+
var rowDetailContainer = artTable && artTable.querySelector(".".concat(Classes.rowDetailContainer));
|
|
296
|
+
return /*#__PURE__*/ReactDom.createPortal( /*#__PURE__*/React.createElement(RowDetail, _extends({}, params)), rowDetailContainer);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function RowDetail(props) {
|
|
300
|
+
var detailRef = useRef(null);
|
|
301
|
+
var row = props.row,
|
|
302
|
+
rowIndex = props.rowIndex,
|
|
303
|
+
domHelper = props.domHelper,
|
|
304
|
+
renderDetail = props.renderDetail;
|
|
305
|
+
var artTable = domHelper.artTable;
|
|
306
|
+
useEffect(function () {
|
|
307
|
+
var selector = function selector(position) {
|
|
308
|
+
var _context, _context2;
|
|
309
|
+
|
|
310
|
+
return _concatInstanceProperty(_context = _concatInstanceProperty(_context2 = ".".concat(position, " .")).call(_context2, Classes.tableRow, "[data-rowindex=\"")).call(_context, rowIndex, "\"]");
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
var itemRect = detailRef.current && detailRef.current.getBoundingClientRect();
|
|
314
|
+
var targetRow = artTable.querySelector(selector(Classes.tableBody));
|
|
315
|
+
var targetRowLeft = artTable.querySelector(selector(Classes.fixedLeft));
|
|
316
|
+
var targetRowRight = artTable.querySelector(selector(Classes.fixedRight));
|
|
317
|
+
|
|
318
|
+
if (itemRect.height) {
|
|
319
|
+
targetRow && (targetRow.style.height = itemRect.height + 'px');
|
|
320
|
+
targetRowLeft && (targetRowLeft.style.height = itemRect.height + 'px');
|
|
321
|
+
targetRowRight && (targetRowRight.style.height = itemRect.height + 'px');
|
|
322
|
+
}
|
|
323
|
+
}, []);
|
|
324
|
+
useEffect(function () {
|
|
325
|
+
// 这时候行才渲染完,只能在这里设置偏移量
|
|
326
|
+
var offsetTop = domHelper.getRowTop(rowIndex) || 0;
|
|
327
|
+
detailRef.current.style.transform = "translateY(".concat(offsetTop + 'px', ")");
|
|
328
|
+
});
|
|
329
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
330
|
+
ref: detailRef,
|
|
331
|
+
className: Classes.rowDetailItem
|
|
332
|
+
}, renderDetail(row, rowIndex));
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
if (browserType.isIE) {
|
|
336
|
+
TEMPLATES.set('header', renderTableHeaderInIE);
|
|
337
|
+
TEMPLATES.set('body', renderTableBodyInIE);
|
|
338
|
+
TEMPLATES.set('footer', renderTableFooterInIE);
|
|
339
|
+
TEMPLATES.set('rowDetail', renderRowDetailInIE);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
export default function getTableHeaderRenderTemplate(type) {
|
|
343
|
+
return TEMPLATES.get(type);
|
|
344
|
+
}
|
|
@@ -3,10 +3,12 @@ export declare const Classes: {
|
|
|
3
3
|
/** BaseTable 表格组件的外层包裹 div */
|
|
4
4
|
readonly artTableWrapper: string;
|
|
5
5
|
readonly artTable: string;
|
|
6
|
+
readonly tableHeaderMain: string;
|
|
6
7
|
readonly tableHeader: string;
|
|
7
8
|
readonly tableBody: string;
|
|
8
9
|
readonly virtual: string;
|
|
9
10
|
readonly tableFooter: string;
|
|
11
|
+
readonly tableFooterMain: string;
|
|
10
12
|
/** 表格行 */
|
|
11
13
|
readonly tableRow: string;
|
|
12
14
|
/** 表头行 */
|
|
@@ -21,6 +23,7 @@ export declare const Classes: {
|
|
|
21
23
|
readonly stickyScroll: string;
|
|
22
24
|
readonly stickyScrollItem: string;
|
|
23
25
|
readonly horizontalScrollContainer: string;
|
|
26
|
+
readonly verticalScrollPlaceholder: string;
|
|
24
27
|
readonly lockShadowMask: string;
|
|
25
28
|
readonly lockShadow: string;
|
|
26
29
|
readonly leftLockShadow: string;
|
|
@@ -37,12 +40,33 @@ export declare const Classes: {
|
|
|
37
40
|
readonly button: string;
|
|
38
41
|
readonly buttonPrimary: string;
|
|
39
42
|
readonly filterIcon: string;
|
|
43
|
+
readonly tableCellRangeSelected: string;
|
|
44
|
+
readonly tableCellRangeTop: string;
|
|
45
|
+
readonly tableCellRangeLeft: string;
|
|
46
|
+
readonly tableCellRangeBottom: string;
|
|
47
|
+
readonly tableCellRangeRight: string;
|
|
48
|
+
readonly fixedLeft: string;
|
|
49
|
+
readonly fixedRight: string;
|
|
50
|
+
readonly rowDetailContainer: string;
|
|
51
|
+
readonly rowDetailItem: string;
|
|
52
|
+
readonly emptyColCell: string;
|
|
53
|
+
readonly first: string;
|
|
54
|
+
readonly last: string;
|
|
55
|
+
readonly even: string;
|
|
56
|
+
readonly odd: string;
|
|
57
|
+
readonly lockLeft: string;
|
|
58
|
+
readonly lockRight: string;
|
|
59
|
+
readonly rowSpan: string;
|
|
60
|
+
readonly leaf: string;
|
|
61
|
+
readonly expanded: string;
|
|
62
|
+
readonly collapsed: string;
|
|
40
63
|
};
|
|
41
64
|
export declare const MenuClasses: {
|
|
42
65
|
menu: string;
|
|
43
66
|
menuList: string;
|
|
44
67
|
menuOption: string;
|
|
45
68
|
menuOptionActive: string;
|
|
69
|
+
menuOptionDisable: string;
|
|
46
70
|
menuOptionText: string;
|
|
47
71
|
};
|
|
48
72
|
export declare type BaseTableCSSVariables = Partial<{
|