@kdcloudjs/table 1.2.1-canary.6 → 1.2.2-canary.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.
- package/LICENSE +568 -568
- package/README.md +111 -111
- package/dist/@kdcloudjs/table.css +1 -1
- package/dist/@kdcloudjs/table.js +5480 -6087
- package/dist/@kdcloudjs/table.js.map +1 -1
- package/dist/@kdcloudjs/table.min.css +1 -1
- package/dist/@kdcloudjs/table.min.js +18 -16
- package/dist/@kdcloudjs/table.min.js.map +1 -1
- package/dist/kd-ui-complete.less +777 -777
- package/es/_utils/arrayUtil.js +0 -3
- package/es/_utils/devwarning.js +0 -1
- package/es/_utils/formatUtil.js +36 -101
- package/es/_utils/hooks.js +21 -45
- package/es/_utils/index.js +0 -2
- package/es/_utils/numberUtil.js +32 -55
- package/es/_utils/omit.js +0 -2
- package/es/_utils/type.js +0 -2
- package/es/_utils/usePopper.js +81 -144
- package/es/config-provider/compDefaultProps.js +0 -1
- package/es/config-provider/configProvider.js +2 -7
- package/es/config-provider/defaultConfig.js +0 -1
- package/es/index.js +0 -2
- package/es/locale/locale.js +11 -50
- package/es/style/color/colors.less +1 -1
- package/es/style/core/index.less +1 -1
- package/es/style/core/motion/other.less +27 -27
- package/es/style/core/motion/slide.less +53 -53
- package/es/style/core/motion.less +1 -1
- package/es/style/core/reset.less +185 -185
- package/es/style/index.less +1 -1
- package/es/style/mixins/index.less +18 -18
- package/es/style/mixins/overlay.less +21 -21
- package/es/style/mixins/reset.less +12 -12
- package/es/style/themes/default.less +445 -445
- package/es/table/base/calculations.js +25 -75
- package/es/table/base/colgroup.js +0 -1
- package/es/table/base/empty.js +6 -6
- package/es/table/base/globalStyleComponent.d.ts +4 -0
- package/es/table/base/globalStyleComponent.js +24 -0
- package/es/table/base/header.js +21 -76
- package/es/table/base/helpers/SpanManager.js +4 -11
- package/es/table/base/helpers/TableDOMUtils.js +9 -34
- package/es/table/base/helpers/__test__/SpanManager.test.js +2 -2
- package/es/table/base/helpers/__test__/TableDOMUtils.test.js +0 -1
- package/es/table/base/helpers/getRichVisibleRectsStream.js +13 -45
- package/es/table/base/helpers/rowHeightManager.js +0 -28
- package/es/table/base/html-table.js +17 -39
- package/es/table/base/loading.js +8 -10
- package/es/table/base/renderTemplates.js +42 -60
- package/es/table/base/styles.d.ts +10 -0
- package/es/table/base/styles.js +17 -16
- package/es/table/base/table.js +113 -201
- package/es/table/base/utils.js +17 -57
- package/es/table/common-views.js +0 -7
- package/es/table/interfaces.d.ts +38 -0
- package/es/table/internals.js +0 -13
- package/es/table/pipeline/const.d.ts +3 -0
- package/es/table/pipeline/const.js +3 -0
- package/es/table/pipeline/features/autoFill.js +11 -40
- package/es/table/pipeline/features/autoRowSpan.js +1 -14
- package/es/table/pipeline/features/colGroupExtendable.js +4 -19
- package/es/table/pipeline/features/columnDrag.js +41 -97
- package/es/table/pipeline/features/columnFilter.js +12 -51
- package/es/table/pipeline/features/columnHover.js +1 -7
- package/es/table/pipeline/features/columnRangeHover.js +1 -8
- package/es/table/pipeline/features/columnResizeWidth.js +13 -39
- package/es/table/pipeline/features/contextMenu.js +22 -95
- package/es/table/pipeline/features/featureApi/RowDragApi.d.ts +15 -0
- package/es/table/pipeline/features/featureApi/RowDragApi.js +66 -0
- package/es/table/pipeline/features/featureApi/utils.d.ts +2 -0
- package/es/table/pipeline/features/featureApi/utils.js +10 -0
- package/es/table/pipeline/features/filter/DefaultFilterContent.js +14 -30
- package/es/table/pipeline/features/filter/DefaultFilterIcon.js +1 -1
- package/es/table/pipeline/features/filter/Filter.js +27 -51
- package/es/table/pipeline/features/filter/FilterPanel.js +11 -25
- package/es/table/pipeline/features/filter/util.js +0 -4
- package/es/table/pipeline/features/footerDataSource.js +0 -3
- package/es/table/pipeline/features/mergeCellHover.js +0 -1
- package/es/table/pipeline/features/multiSelect.js +15 -57
- package/es/table/pipeline/features/rangeSelection.js +73 -152
- package/es/table/pipeline/features/rowDetail.js +4 -43
- package/es/table/pipeline/features/rowDrag.d.ts +10 -12
- package/es/table/pipeline/features/rowDrag.js +491 -236
- package/es/table/pipeline/features/rowGrouping.js +4 -37
- package/es/table/pipeline/features/singleSelect.js +0 -24
- package/es/table/pipeline/features/sort.js +38 -96
- package/es/table/pipeline/features/tips.js +4 -10
- package/es/table/pipeline/features/treeMode.d.ts +1 -0
- package/es/table/pipeline/features/treeMode.js +38 -57
- package/es/table/pipeline/features/treeSelect.js +2 -28
- package/es/table/pipeline/pipeline.d.ts +3 -0
- package/es/table/pipeline/pipeline.js +35 -54
- package/es/table/pivot/cross-table/buildCrossTable.js +21 -72
- package/es/table/pivot/cross-table/cross-table.js +23 -31
- package/es/table/pivot/cross-tree-table/buildCrossTreeTable.js +22 -57
- package/es/table/pivot/cross-tree-table/cross-tree-table.js +36 -61
- package/es/table/pivot/pivot-utils/buildDrillTree.js +10 -23
- package/es/table/pivot/pivot-utils/builders.js +34 -74
- package/es/table/pivot/pivot-utils/convert-utils.js +16 -42
- package/es/table/pivot/pivot-utils/simpleEncode.js +0 -1
- package/es/table/style/index.less +1 -1
- package/es/table/transforms/autoRowSpan.js +1 -15
- package/es/table/transforms/autoWidth.js +13 -35
- package/es/table/transforms/buildTree.js +1 -2
- package/es/table/transforms/columnHover.js +9 -15
- package/es/table/transforms/columnRangeHover.js +12 -19
- package/es/table/transforms/columnResize.js +18 -42
- package/es/table/transforms/flatten.js +0 -3
- package/es/table/transforms/orderField.js +0 -3
- package/es/table/transforms/sort.js +42 -101
- package/es/table/transforms/tips.js +5 -10
- package/es/table/transforms/treeMode.js +36 -77
- package/es/table/transforms/visible.js +0 -2
- package/es/table/use/useResizeObserver.js +1 -4
- package/es/table/utils/applyTransforms.js +0 -1
- package/es/table/utils/browserType.js +12 -19
- package/es/table/utils/buildTree.js +7 -22
- package/es/table/utils/collectNodes.js +4 -13
- package/es/table/utils/console.js +0 -14
- package/es/table/utils/copyToClipboard.js +0 -4
- package/es/table/utils/element.js +14 -41
- package/es/table/utils/exportTableAsExcel.js +7 -43
- package/es/table/utils/getTreeDepth.js +4 -12
- package/es/table/utils/groupBy.js +4 -13
- package/es/table/utils/layeredFilter.js +0 -4
- package/es/table/utils/layeredSort.js +0 -5
- package/es/table/utils/makeRecursiveMapper.js +4 -15
- package/es/table/utils/mergeCellProps.js +6 -14
- package/es/table/utils/others.js +6 -19
- package/es/table/utils/proto.js +2 -30
- package/es/table/utils/smartCompare.js +4 -12
- package/es/table/utils/traverseColumn.js +5 -18
- package/es/table/utils/tree-data-helpers/StrictTreeDataHelper.js +8 -30
- package/es/table/utils/tree-data-helpers/TreeDataHelper.js +19 -74
- package/es/table/utils/uiDegrade.js +0 -5
- package/lib/_utils/arrayUtil.js +2 -8
- package/lib/_utils/devwarning.js +0 -5
- package/lib/_utils/formatUtil.js +36 -105
- package/lib/_utils/hooks.js +21 -56
- package/lib/_utils/index.js +2 -9
- package/lib/_utils/numberUtil.js +32 -63
- package/lib/_utils/omit.js +0 -5
- package/lib/_utils/react-children.js +0 -5
- package/lib/_utils/type.js +3 -11
- package/lib/_utils/usePopper.js +86 -173
- package/lib/config-provider/ConfigContext.js +2 -6
- package/lib/config-provider/compDefaultProps.js +1 -3
- package/lib/config-provider/configProvider.js +6 -22
- package/lib/config-provider/defaultConfig.js +1 -7
- package/lib/config-provider/index.js +1 -8
- package/lib/index.js +2 -8
- package/lib/locale/index.js +3 -11
- package/lib/locale/locale.js +15 -71
- package/lib/locale/zh-CN.js +1 -2
- package/lib/style/color/colors.less +1 -1
- package/lib/style/components.less +1 -1
- package/lib/style/core/index.less +1 -1
- package/lib/style/core/motion/other.less +27 -27
- package/lib/style/core/motion/slide.less +53 -53
- package/lib/style/core/motion.less +1 -1
- package/lib/style/core/reset.less +185 -185
- package/lib/style/index.less +1 -1
- package/lib/style/mixins/index.less +18 -18
- package/lib/style/mixins/overlay.less +21 -21
- package/lib/style/mixins/reset.less +12 -12
- package/lib/style/themes/default.less +445 -445
- package/lib/table/base/calculations.js +25 -86
- package/lib/table/base/colgroup.js +0 -5
- package/lib/table/base/empty.js +8 -20
- package/lib/table/base/globalStyleComponent.d.ts +4 -0
- package/lib/table/base/globalStyleComponent.js +35 -0
- package/lib/table/base/header.js +21 -86
- package/lib/table/base/helpers/SpanManager.js +6 -16
- package/lib/table/base/helpers/TableDOMUtils.js +9 -37
- package/lib/table/base/helpers/__test__/SpanManager.test.js +2 -4
- package/lib/table/base/helpers/__test__/TableDOMUtils.test.js +0 -5
- package/lib/table/base/helpers/__test__/rowHeightManager.test.js +0 -1
- package/lib/table/base/helpers/getRichVisibleRectsStream.js +15 -65
- package/lib/table/base/helpers/rowHeightManager.js +0 -33
- package/lib/table/base/html-table.js +17 -49
- package/lib/table/base/index.js +0 -2
- package/lib/table/base/loading.js +8 -14
- package/lib/table/base/renderTemplates.js +45 -76
- package/lib/table/base/styles.d.ts +10 -0
- package/lib/table/base/styles.js +24 -42
- package/lib/table/base/table.js +125 -245
- package/lib/table/base/utils.js +27 -109
- package/lib/table/common-views.js +4 -24
- package/lib/table/index.js +0 -13
- package/lib/table/interfaces.d.ts +38 -0
- package/lib/table/internals.js +2 -17
- package/lib/table/pipeline/const.d.ts +3 -0
- package/lib/table/pipeline/const.js +9 -0
- package/lib/table/pipeline/features/autoFill.js +14 -53
- package/lib/table/pipeline/features/autoRowSpan.js +1 -19
- package/lib/table/pipeline/features/buildTree.js +0 -2
- package/lib/table/pipeline/features/colGroupExtendable.js +6 -35
- package/lib/table/pipeline/features/columnDrag.js +41 -103
- package/lib/table/pipeline/features/columnFilter.js +12 -65
- package/lib/table/pipeline/features/columnHover.js +1 -11
- package/lib/table/pipeline/features/columnRangeHover.js +1 -13
- package/lib/table/pipeline/features/columnResizeWidth.js +18 -63
- package/lib/table/pipeline/features/contextMenu.js +24 -121
- package/lib/table/pipeline/features/featureApi/RowDragApi.d.ts +15 -0
- package/lib/table/pipeline/features/featureApi/RowDragApi.js +72 -0
- package/lib/table/pipeline/features/featureApi/utils.d.ts +2 -0
- package/lib/table/pipeline/features/featureApi/utils.js +17 -0
- package/lib/table/pipeline/features/filter/DefaultFilterContent.js +17 -52
- package/lib/table/pipeline/features/filter/DefaultFilterIcon.js +1 -4
- package/lib/table/pipeline/features/filter/Filter.js +30 -77
- package/lib/table/pipeline/features/filter/FilterPanel.js +14 -44
- package/lib/table/pipeline/features/filter/index.js +0 -5
- package/lib/table/pipeline/features/filter/util.js +2 -10
- package/lib/table/pipeline/features/footerDataSource.js +1 -12
- package/lib/table/pipeline/features/index.js +0 -23
- package/lib/table/pipeline/features/mergeCellHover.js +0 -5
- package/lib/table/pipeline/features/multiSelect.js +15 -71
- package/lib/table/pipeline/features/rangeSelection.js +75 -173
- package/lib/table/pipeline/features/rowDetail.js +4 -67
- package/lib/table/pipeline/features/rowDrag.d.ts +10 -12
- package/lib/table/pipeline/features/rowDrag.js +494 -252
- package/lib/table/pipeline/features/rowGrouping.js +4 -57
- package/lib/table/pipeline/features/singleSelect.js +0 -34
- package/lib/table/pipeline/features/sort.js +37 -115
- package/lib/table/pipeline/features/tips.js +4 -19
- package/lib/table/pipeline/features/treeMode.d.ts +1 -0
- package/lib/table/pipeline/features/treeMode.js +40 -80
- package/lib/table/pipeline/features/treeSelect.js +2 -36
- package/lib/table/pipeline/index.js +2 -10
- package/lib/table/pipeline/pipeline.d.ts +3 -0
- package/lib/table/pipeline/pipeline.js +36 -65
- package/lib/table/pivot/cross-table/buildCrossTable.js +21 -83
- package/lib/table/pivot/cross-table/constants.js +1 -2
- package/lib/table/pivot/cross-table/cross-table.js +25 -42
- package/lib/table/pivot/cross-table/index.js +0 -4
- package/lib/table/pivot/cross-tree-table/buildCrossTreeTable.js +22 -70
- package/lib/table/pivot/cross-tree-table/cross-tree-table.js +37 -73
- package/lib/table/pivot/cross-tree-table/index.js +0 -3
- package/lib/table/pivot/pivot-utils/buildDrillTree.js +10 -29
- package/lib/table/pivot/pivot-utils/builders.js +34 -85
- package/lib/table/pivot/pivot-utils/convert-utils.js +16 -60
- package/lib/table/pivot/pivot-utils/index.js +0 -7
- package/lib/table/pivot/pivot-utils/simpleEncode.js +0 -2
- package/lib/table/style/css.js +0 -1
- package/lib/table/style/index.js +0 -1
- package/lib/table/style/index.less +1 -1
- package/lib/table/transforms/autoRowSpan.js +1 -21
- package/lib/table/transforms/autoWidth.js +15 -58
- package/lib/table/transforms/buildTree.js +1 -4
- package/lib/table/transforms/columnHover.js +9 -22
- package/lib/table/transforms/columnRangeHover.js +12 -27
- package/lib/table/transforms/columnResize.js +20 -63
- package/lib/table/transforms/flatten.js +0 -5
- package/lib/table/transforms/index.js +0 -12
- package/lib/table/transforms/orderField.js +0 -7
- package/lib/table/transforms/sort.js +44 -127
- package/lib/table/transforms/tips.js +5 -20
- package/lib/table/transforms/treeMode.js +38 -106
- package/lib/table/transforms/visible.js +0 -7
- package/lib/table/transforms/warnTransformsDeprecated.js +0 -4
- package/lib/table/use/useResizeObserver.js +2 -10
- package/lib/table/utils/applyTransforms.js +0 -2
- package/lib/table/utils/browserType.js +14 -23
- package/lib/table/utils/buildTree.js +7 -33
- package/lib/table/utils/collectNodes.js +4 -18
- package/lib/table/utils/console.js +2 -19
- package/lib/table/utils/copyToClipboard.js +1 -8
- package/lib/table/utils/element.js +14 -46
- package/lib/table/utils/exportTableAsExcel.js +7 -52
- package/lib/table/utils/getTreeDepth.js +4 -17
- package/lib/table/utils/groupBy.js +4 -17
- package/lib/table/utils/index.js +0 -22
- package/lib/table/utils/isGroupColumn.js +0 -3
- package/lib/table/utils/isLeafNode.js +0 -1
- package/lib/table/utils/keyCode.js +1 -2
- package/lib/table/utils/layeredFilter.js +0 -10
- package/lib/table/utils/layeredSort.js +0 -10
- package/lib/table/utils/makeRecursiveMapper.js +4 -24
- package/lib/table/utils/mergeCellProps.js +6 -18
- package/lib/table/utils/others.js +7 -36
- package/lib/table/utils/proto.js +3 -35
- package/lib/table/utils/selectColumn.js +2 -5
- package/lib/table/utils/smartCompare.js +4 -13
- package/lib/table/utils/traverseColumn.js +5 -25
- package/lib/table/utils/tree-data-helpers/StrictTreeDataHelper.js +10 -41
- package/lib/table/utils/tree-data-helpers/TreeDataHelper.js +21 -90
- package/lib/table/utils/uiDegrade.js +1 -8
- package/package.json +218 -218
|
@@ -3,7 +3,6 @@ import _Set from "@babel/runtime-corejs3/core-js-stable/set";
|
|
|
3
3
|
import { isLeafNode, traverseColumn } from '../utils';
|
|
4
4
|
import { warnTransformsDeprecated } from './warnTransformsDeprecated';
|
|
5
5
|
/** @deprecated transform 用法已经过时,请使用 pipeline 来对表格进行拓展 */
|
|
6
|
-
|
|
7
6
|
export function makeVisibleTransform(visibleCodes) {
|
|
8
7
|
warnTransformsDeprecated('makeVisibleTransform');
|
|
9
8
|
var set = new _Set(visibleCodes);
|
|
@@ -11,7 +10,6 @@ export function makeVisibleTransform(visibleCodes) {
|
|
|
11
10
|
if (!isLeafNode(column)) {
|
|
12
11
|
return column;
|
|
13
12
|
}
|
|
14
|
-
|
|
15
13
|
return set.has(column.code) ? column : _extends(_extends({}, column), {
|
|
16
14
|
hidden: true
|
|
17
15
|
});
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import ResizeObserver from 'resize-observer-polyfill';
|
|
4
|
-
|
|
5
4
|
var useResizeObserver = function useResizeObserver(callbck, _ref) {
|
|
6
5
|
var _ref2 = _slicedToArray(_ref, 1),
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
element = _ref2[0];
|
|
9
7
|
React.useEffect(function () {
|
|
10
8
|
var resizeObserver = new ResizeObserver(function () {
|
|
11
9
|
callbck();
|
|
@@ -16,5 +14,4 @@ var useResizeObserver = function useResizeObserver(callbck, _ref) {
|
|
|
16
14
|
};
|
|
17
15
|
}, []);
|
|
18
16
|
};
|
|
19
|
-
|
|
20
17
|
export default useResizeObserver;
|
|
@@ -6,7 +6,6 @@ export default function applyTransforms(input) {
|
|
|
6
6
|
for (var _len = arguments.length, transforms = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
7
7
|
transforms[_key - 1] = arguments[_key];
|
|
8
8
|
}
|
|
9
|
-
|
|
10
9
|
return transforms.reduce(function (v, fn) {
|
|
11
10
|
return fn(v);
|
|
12
11
|
}, input);
|
|
@@ -7,50 +7,44 @@ export var browserType = {
|
|
|
7
7
|
isChrome: browserData.name === 'Chrome',
|
|
8
8
|
isSafari: browserData.name === 'Safari'
|
|
9
9
|
};
|
|
10
|
-
|
|
11
10
|
function getBrowserData() {
|
|
12
11
|
var ua = navigator.userAgent;
|
|
13
12
|
var browser = {};
|
|
14
|
-
var match;
|
|
15
|
-
|
|
13
|
+
var match;
|
|
14
|
+
// 旧Edge浏览器可能隐藏其版本号,因此我们需要特别处理
|
|
16
15
|
if (match = ua.match(/Edge\/(.*?)(?=\s|$)/)) {
|
|
17
16
|
browser.name = 'Edge';
|
|
18
17
|
browser.version = match[1];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
}
|
|
19
|
+
// 新Edge浏览器
|
|
22
20
|
if (!browser.name) {
|
|
23
21
|
if (match = ua.match(/Edg\/(.*?)(?=\s|$)/)) {
|
|
24
22
|
browser.name = 'NewEdge';
|
|
25
23
|
browser.version = match[1];
|
|
26
24
|
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
}
|
|
26
|
+
// 如果未找到Edge版本,尝试Chrome
|
|
30
27
|
if (!browser.name) {
|
|
31
28
|
if (match = ua.match(/Chrome\/(.*?)(?=\s|$)/)) {
|
|
32
29
|
browser.name = 'Chrome';
|
|
33
30
|
browser.version = match[1];
|
|
34
31
|
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
}
|
|
33
|
+
// 如果未找到Chrome版本,尝试Safari
|
|
38
34
|
if (!browser.name) {
|
|
39
35
|
if (match = ua.match(/Safari\/(.*?)(?=\s|$)/)) {
|
|
40
36
|
browser.name = 'Safari';
|
|
41
37
|
browser.version = match[1];
|
|
42
38
|
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
}
|
|
40
|
+
// 如果未找到Safari版本,尝试Firefox
|
|
46
41
|
if (!browser.name) {
|
|
47
42
|
if (match = ua.match(/Firefox\/(.*?)(?=\s|$)/)) {
|
|
48
43
|
browser.name = 'Firefox';
|
|
49
44
|
browser.version = match[1];
|
|
50
45
|
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
}
|
|
47
|
+
// 如果未找到Firefox版本,尝试IE
|
|
54
48
|
if (!browser.name) {
|
|
55
49
|
if (/Trident\/(\d+)/.test(ua)) {
|
|
56
50
|
browser.name = 'IE';
|
|
@@ -61,6 +55,5 @@ function getBrowserData() {
|
|
|
61
55
|
browser.version = match[1];
|
|
62
56
|
}
|
|
63
57
|
}
|
|
64
|
-
|
|
65
58
|
return browser;
|
|
66
59
|
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
2
|
-
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
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); }
|
|
6
|
-
|
|
7
|
-
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; }
|
|
8
|
-
|
|
2
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof _Symbol && _getIteratorMethod(r) || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, 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 o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
3
|
+
function _unsupportedIterableToArray(r, a) { if (r) { var _context2; if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = _sliceInstanceProperty(_context2 = {}.toString.call(r)).call(_context2, 8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? _Array$from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
9
5
|
import _Map from "@babel/runtime-corejs3/core-js-stable/map";
|
|
10
6
|
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
11
7
|
import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
|
|
@@ -43,17 +39,13 @@ import { flatMap } from './others';
|
|
|
43
39
|
* },
|
|
44
40
|
* ])
|
|
45
41
|
*/
|
|
46
|
-
|
|
47
42
|
export default function buildTree(idProp, parentIdProp, items) {
|
|
48
43
|
var _context;
|
|
49
|
-
|
|
50
44
|
var wrapperMap = new _Map();
|
|
51
|
-
|
|
52
45
|
var ensure = function ensure(id) {
|
|
53
46
|
if (wrapperMap.has(id)) {
|
|
54
47
|
return wrapperMap.get(id);
|
|
55
48
|
}
|
|
56
|
-
|
|
57
49
|
var wrapper = {
|
|
58
50
|
id: id,
|
|
59
51
|
parent: null,
|
|
@@ -63,10 +55,8 @@ export default function buildTree(idProp, parentIdProp, items) {
|
|
|
63
55
|
wrapperMap.set(id, wrapper);
|
|
64
56
|
return wrapper;
|
|
65
57
|
};
|
|
66
|
-
|
|
67
58
|
var _iterator = _createForOfIteratorHelper(items),
|
|
68
|
-
|
|
69
|
-
|
|
59
|
+
_step;
|
|
70
60
|
try {
|
|
71
61
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
72
62
|
var item = _step.value;
|
|
@@ -81,24 +71,20 @@ export default function buildTree(idProp, parentIdProp, items) {
|
|
|
81
71
|
} finally {
|
|
82
72
|
_iterator.f();
|
|
83
73
|
}
|
|
84
|
-
|
|
85
74
|
var topLevelWrappers = flatMap(_filterInstanceProperty(_context = _Array$from(_valuesInstanceProperty(wrapperMap).call(wrapperMap))).call(_context, function (wrapper) {
|
|
86
75
|
return wrapper.parent == null;
|
|
87
76
|
}), function (wrapper) {
|
|
88
77
|
return wrapper.children;
|
|
89
78
|
});
|
|
90
|
-
return unwrapRecursively(topLevelWrappers);
|
|
91
|
-
|
|
79
|
+
return unwrapRecursively(topLevelWrappers);
|
|
80
|
+
// todo 可能存在无线递归的情况
|
|
92
81
|
function unwrapRecursively(wrapperArray) {
|
|
93
82
|
var result = [];
|
|
94
|
-
|
|
95
83
|
var _iterator2 = _createForOfIteratorHelper(wrapperArray),
|
|
96
|
-
|
|
97
|
-
|
|
84
|
+
_step2;
|
|
98
85
|
try {
|
|
99
86
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
100
87
|
var wrapper = _step2.value;
|
|
101
|
-
|
|
102
88
|
if (wrapper.children.length === 0) {
|
|
103
89
|
result.push(wrapper.item);
|
|
104
90
|
} else {
|
|
@@ -112,7 +98,6 @@ export default function buildTree(idProp, parentIdProp, items) {
|
|
|
112
98
|
} finally {
|
|
113
99
|
_iterator2.f();
|
|
114
100
|
}
|
|
115
|
-
|
|
116
101
|
return result;
|
|
117
102
|
}
|
|
118
103
|
}
|
|
@@ -2,13 +2,9 @@ import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instan
|
|
|
2
2
|
import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
|
|
3
3
|
import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
|
|
4
4
|
import _getIteratorMethod from "@babel/runtime-corejs3/core-js/get-iterator-method";
|
|
5
|
-
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
-
function _unsupportedIterableToArray(o, minLen) { var _context; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context = Object.prototype.toString.call(o)).call(_context, 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); }
|
|
9
|
-
|
|
10
|
-
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; }
|
|
11
|
-
|
|
5
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof _Symbol && _getIteratorMethod(r) || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, 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 o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
6
|
+
function _unsupportedIterableToArray(r, a) { if (r) { var _context; if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = _sliceInstanceProperty(_context = {}.toString.call(r)).call(_context, 8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? _Array$from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
7
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
12
8
|
import isLeafNode from './isLeafNode';
|
|
13
9
|
/** 遍历所有节点,并将节点收集到一个数组中.
|
|
14
10
|
* order 参数可用于指定遍历规则:
|
|
@@ -16,25 +12,20 @@ import isLeafNode from './isLeafNode';
|
|
|
16
12
|
* * `post` 后续遍历
|
|
17
13
|
* * `leaf-only` 忽略内部节点,只收集叶子节点
|
|
18
14
|
* */
|
|
19
|
-
|
|
20
15
|
export default function collectNodes(nodes) {
|
|
21
16
|
var order = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'pre';
|
|
22
17
|
var result = [];
|
|
23
18
|
dfs(nodes);
|
|
24
19
|
return result;
|
|
25
|
-
|
|
26
20
|
function dfs(nodes) {
|
|
27
21
|
if (nodes == null) {
|
|
28
22
|
return;
|
|
29
23
|
}
|
|
30
|
-
|
|
31
24
|
var _iterator = _createForOfIteratorHelper(nodes),
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
_step;
|
|
34
26
|
try {
|
|
35
27
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
36
28
|
var node = _step.value;
|
|
37
|
-
|
|
38
29
|
if (isLeafNode(node)) {
|
|
39
30
|
result.push(node);
|
|
40
31
|
} else {
|
|
@@ -1,55 +1,41 @@
|
|
|
1
1
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
2
|
-
|
|
3
2
|
function isOutput() {
|
|
4
3
|
return true;
|
|
5
4
|
}
|
|
6
|
-
|
|
7
5
|
function log() {
|
|
8
6
|
if (isOutput()) {
|
|
9
7
|
var _console, _context;
|
|
10
|
-
|
|
11
8
|
for (var _len = arguments.length, msg = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
12
9
|
msg[_key] = arguments[_key];
|
|
13
10
|
}
|
|
14
|
-
|
|
15
11
|
(_console = console).log.apply(_console, _concatInstanceProperty(_context = ['[kd-table]']).call(_context, msg));
|
|
16
12
|
}
|
|
17
13
|
}
|
|
18
|
-
|
|
19
14
|
function warn() {
|
|
20
15
|
if (isOutput()) {
|
|
21
16
|
var _console2, _context2;
|
|
22
|
-
|
|
23
17
|
for (var _len2 = arguments.length, msg = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
24
18
|
msg[_key2] = arguments[_key2];
|
|
25
19
|
}
|
|
26
|
-
|
|
27
20
|
(_console2 = console).warn.apply(_console2, _concatInstanceProperty(_context2 = ['[kd-table]']).call(_context2, msg));
|
|
28
21
|
}
|
|
29
22
|
}
|
|
30
|
-
|
|
31
23
|
function error() {
|
|
32
24
|
var _console3, _context3;
|
|
33
|
-
|
|
34
25
|
for (var _len3 = arguments.length, msg = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
35
26
|
msg[_key3] = arguments[_key3];
|
|
36
27
|
}
|
|
37
|
-
|
|
38
28
|
(_console3 = console).error.apply(_console3, _concatInstanceProperty(_context3 = ['[kd-table]']).call(_context3, msg));
|
|
39
29
|
}
|
|
40
|
-
|
|
41
30
|
function table() {
|
|
42
31
|
if (isOutput()) {
|
|
43
32
|
var _console4, _context4;
|
|
44
|
-
|
|
45
33
|
for (var _len4 = arguments.length, msg = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
46
34
|
msg[_key4] = arguments[_key4];
|
|
47
35
|
}
|
|
48
|
-
|
|
49
36
|
(_console4 = console).table.apply(_console4, _concatInstanceProperty(_context4 = ['[kd-table]']).call(_context4, msg));
|
|
50
37
|
}
|
|
51
38
|
}
|
|
52
|
-
|
|
53
39
|
export default {
|
|
54
40
|
log: log,
|
|
55
41
|
warn: warn,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import console from './console';
|
|
2
|
-
|
|
3
2
|
var copyDataToClipboard = function copyDataToClipboard(data) {
|
|
4
3
|
return function (element) {
|
|
5
4
|
element.value = data;
|
|
@@ -9,7 +8,6 @@ var copyDataToClipboard = function copyDataToClipboard(data) {
|
|
|
9
8
|
document.body.removeChild(element);
|
|
10
9
|
};
|
|
11
10
|
};
|
|
12
|
-
|
|
13
11
|
function executeOnTempElement(callback) {
|
|
14
12
|
var eTempInput = document.createElement('textarea');
|
|
15
13
|
eTempInput.style.width = '1px';
|
|
@@ -19,12 +17,10 @@ function executeOnTempElement(callback) {
|
|
|
19
17
|
eTempInput.style.position = 'absolute';
|
|
20
18
|
eTempInput.style.opacity = '0.0';
|
|
21
19
|
document.body.appendChild(eTempInput);
|
|
22
|
-
|
|
23
20
|
try {
|
|
24
21
|
callback(eTempInput);
|
|
25
22
|
} catch (err) {
|
|
26
23
|
console.warn('Browser does not support document.execCommand(\'copy\') for clipboard operations');
|
|
27
24
|
}
|
|
28
25
|
}
|
|
29
|
-
|
|
30
26
|
export { copyDataToClipboard, executeOnTempElement };
|
|
@@ -57,34 +57,27 @@ export function getEventPath(event) {
|
|
|
57
57
|
// Firefox supports composePath
|
|
58
58
|
return event.composedPath();
|
|
59
59
|
}
|
|
60
|
-
|
|
61
60
|
return createEventPath(event);
|
|
62
61
|
}
|
|
63
|
-
|
|
64
62
|
function createEventPath(event) {
|
|
65
63
|
var res = [];
|
|
66
64
|
var pointer = event.target;
|
|
67
|
-
|
|
68
65
|
while (pointer) {
|
|
69
66
|
res.push(pointer);
|
|
70
67
|
pointer = pointer.parentElement;
|
|
71
68
|
}
|
|
72
|
-
|
|
73
69
|
return res;
|
|
74
70
|
}
|
|
75
|
-
|
|
76
71
|
;
|
|
77
72
|
/**
|
|
78
73
|
* 获取点击事件是否发生在元素内部
|
|
79
74
|
* @param ele
|
|
80
75
|
* @param event
|
|
81
76
|
*/
|
|
82
|
-
|
|
83
77
|
export function isElementInEventPath(ele, event) {
|
|
84
78
|
if (!ele || !event) {
|
|
85
79
|
return false;
|
|
86
80
|
}
|
|
87
|
-
|
|
88
81
|
var path = getEventPath(event);
|
|
89
82
|
return path.indexOf(ele) >= 0;
|
|
90
83
|
}
|
|
@@ -93,21 +86,16 @@ export function isElementInEventPath(ele, event) {
|
|
|
93
86
|
* @param path
|
|
94
87
|
* @param isTargetCb
|
|
95
88
|
*/
|
|
96
|
-
|
|
97
89
|
export function getTargetEleInEventPath(path, isTargetCb) {
|
|
98
90
|
var target;
|
|
99
91
|
var l = 0;
|
|
100
|
-
|
|
101
92
|
while (!target && l < path.length) {
|
|
102
93
|
var ele = path[l];
|
|
103
|
-
|
|
104
94
|
if (isTargetCb(ele)) {
|
|
105
95
|
target = ele;
|
|
106
96
|
}
|
|
107
|
-
|
|
108
97
|
l++;
|
|
109
98
|
}
|
|
110
|
-
|
|
111
99
|
return target;
|
|
112
100
|
}
|
|
113
101
|
/**
|
|
@@ -115,7 +103,6 @@ export function getTargetEleInEventPath(path, isTargetCb) {
|
|
|
115
103
|
* @param event
|
|
116
104
|
* @param popupParent
|
|
117
105
|
*/
|
|
118
|
-
|
|
119
106
|
export function calculatePointerRelative(event, popupParent) {
|
|
120
107
|
var parentRect = popupParent.getBoundingClientRect();
|
|
121
108
|
var documentRect = document.documentElement.getBoundingClientRect();
|
|
@@ -129,7 +116,6 @@ export function calculatePointerRelative(event, popupParent) {
|
|
|
129
116
|
* @param event
|
|
130
117
|
* @param popupParent
|
|
131
118
|
*/
|
|
132
|
-
|
|
133
119
|
export function calculatePopupRelative(trigger, popupParent, offset) {
|
|
134
120
|
var triggerRect = trigger.getBoundingClientRect();
|
|
135
121
|
var parent = popupParent === document.body ? document.documentElement : popupParent;
|
|
@@ -139,48 +125,39 @@ export function calculatePopupRelative(trigger, popupParent, offset) {
|
|
|
139
125
|
y: triggerRect.top - parentRect.top - (offset ? offset.y : 0)
|
|
140
126
|
};
|
|
141
127
|
}
|
|
142
|
-
|
|
143
128
|
function getPerfectX(_ref) {
|
|
144
129
|
var x = _ref.x,
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
130
|
+
maxX = _ref.maxX,
|
|
131
|
+
width = _ref.width,
|
|
132
|
+
isPerfectX = _ref.isPerfectX;
|
|
149
133
|
if (isPerfectX && Math.max(x, 0) > Math.abs(maxX)) {
|
|
150
134
|
//看左侧空间是否足够
|
|
151
135
|
var parentAvailableWidth = x;
|
|
152
|
-
|
|
153
136
|
if (width <= parentAvailableWidth) {
|
|
154
137
|
return x - width; //空间足够,往左侧偏移
|
|
155
138
|
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
|
|
139
|
+
}
|
|
140
|
+
//目前位置,最大支持的位置
|
|
159
141
|
return Math.min(Math.max(x, 0), Math.abs(maxX));
|
|
160
142
|
}
|
|
161
|
-
|
|
162
143
|
function getPerfectY(_ref2) {
|
|
163
144
|
var y = _ref2.y,
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
145
|
+
maxY = _ref2.maxY,
|
|
146
|
+
height = _ref2.height,
|
|
147
|
+
scrollTop = _ref2.scrollTop,
|
|
148
|
+
isBody = _ref2.isBody,
|
|
149
|
+
isPerfectY = _ref2.isPerfectY;
|
|
170
150
|
if (isPerfectY && Math.max(y, 0) > Math.abs(maxY)) {
|
|
171
151
|
//看下上方空间是否足够
|
|
172
152
|
var parentAvailableHeight = isBody ? y - scrollTop : y;
|
|
173
|
-
|
|
174
153
|
if (height <= parentAvailableHeight) {
|
|
175
154
|
//上方空间足够,向上展示
|
|
176
155
|
return y - height;
|
|
177
156
|
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
|
|
157
|
+
}
|
|
158
|
+
//目前位置,最大支持的位置
|
|
181
159
|
return Math.min(Math.max(y, 0), Math.abs(maxY));
|
|
182
160
|
}
|
|
183
|
-
|
|
184
161
|
export function keepWithinBounds(popupParent, popup, x, y, isPerfect) {
|
|
185
162
|
var parentRect = popupParent.getBoundingClientRect();
|
|
186
163
|
var docElement = document.documentElement;
|
|
@@ -189,14 +166,12 @@ export function keepWithinBounds(popupParent, popup, x, y, isPerfect) {
|
|
|
189
166
|
var parentAvailableWidth = parentRect.width;
|
|
190
167
|
var parentAvailableHeight = parentRect.height;
|
|
191
168
|
var isBody = popupParent === document.body;
|
|
192
|
-
|
|
193
169
|
if (isBody) {
|
|
194
170
|
//ducument的宽度减去 父元素到document边界的的宽度,就是剩余可显示的宽度
|
|
195
|
-
parentAvailableWidth = docRect.width - Math.abs(docRect.left - parentRect.left);
|
|
196
|
-
|
|
171
|
+
parentAvailableWidth = docRect.width - Math.abs(docRect.left - parentRect.left);
|
|
172
|
+
//ducument的高度加上滚动条的高度减去 父元素到document边界的的宽度,就是剩余可显示的高度
|
|
197
173
|
parentAvailableHeight = docRect.height + docElement.scrollTop - Math.abs(docRect.top - parentRect.top);
|
|
198
174
|
}
|
|
199
|
-
|
|
200
175
|
if (x) {
|
|
201
176
|
var width = popupRect.width;
|
|
202
177
|
var maxX = parentAvailableWidth - width;
|
|
@@ -207,7 +182,6 @@ export function keepWithinBounds(popupParent, popup, x, y, isPerfect) {
|
|
|
207
182
|
isPerfectX: isPerfect
|
|
208
183
|
});
|
|
209
184
|
}
|
|
210
|
-
|
|
211
185
|
if (y) {
|
|
212
186
|
var height = popupRect.height;
|
|
213
187
|
var maxY = parentAvailableHeight - height;
|
|
@@ -220,7 +194,6 @@ export function keepWithinBounds(popupParent, popup, x, y, isPerfect) {
|
|
|
220
194
|
isPerfectY: isPerfect
|
|
221
195
|
});
|
|
222
196
|
}
|
|
223
|
-
|
|
224
197
|
return {
|
|
225
198
|
x: x,
|
|
226
199
|
y: y
|
|
@@ -4,23 +4,17 @@ import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instan
|
|
|
4
4
|
import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
|
|
5
5
|
import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
|
|
6
6
|
import _getIteratorMethod from "@babel/runtime-corejs3/core-js/get-iterator-method";
|
|
7
|
-
|
|
8
|
-
function
|
|
9
|
-
|
|
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
|
-
|
|
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
|
-
|
|
7
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof _Symbol && _getIteratorMethod(r) || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, 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 o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
8
|
+
function _unsupportedIterableToArray(r, a) { if (r) { var _context2; if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = _sliceInstanceProperty(_context2 = {}.toString.call(r)).call(_context2, 8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? _Array$from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
9
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
14
10
|
import SpanManager from '../base/helpers/SpanManager';
|
|
15
11
|
import { internals } from '../internals';
|
|
16
12
|
import collectNodes from './collectNodes';
|
|
17
13
|
import getTreeDepth from './getTreeDepth';
|
|
18
14
|
import isLeafNode from './isLeafNode';
|
|
19
|
-
|
|
20
15
|
function safeGetSpanRect(column, record, rowIndex, colIndex) {
|
|
21
16
|
var colSpan = 1;
|
|
22
17
|
var rowSpan = 1;
|
|
23
|
-
|
|
24
18
|
if (column.getSpanRect) {
|
|
25
19
|
var value = internals.safeGetValue(column, record, rowIndex);
|
|
26
20
|
var spanRect = column.getSpanRect(value, record, rowIndex);
|
|
@@ -28,17 +22,14 @@ function safeGetSpanRect(column, record, rowIndex, colIndex) {
|
|
|
28
22
|
rowSpan = spanRect == null ? 1 : spanRect.bottom - rowIndex;
|
|
29
23
|
} else {
|
|
30
24
|
var cellProps = internals.safeGetCellProps(column, record, rowIndex);
|
|
31
|
-
|
|
32
25
|
if (cellProps.colSpan != null) {
|
|
33
26
|
colSpan = cellProps.colSpan;
|
|
34
27
|
}
|
|
35
|
-
|
|
36
28
|
if (cellProps.rowSpan != null) {
|
|
37
29
|
rowSpan = cellProps.rowSpan;
|
|
38
30
|
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
31
|
+
}
|
|
32
|
+
// 注意这里没有考虑「rowSpan/colSpan 不能过大,避免 rowSpan/colSpan 影响因虚拟滚动而未渲染的单元格」
|
|
42
33
|
return {
|
|
43
34
|
top: rowIndex,
|
|
44
35
|
bottom: rowIndex + rowSpan,
|
|
@@ -46,16 +37,14 @@ function safeGetSpanRect(column, record, rowIndex, colIndex) {
|
|
|
46
37
|
right: colIndex + colSpan
|
|
47
38
|
};
|
|
48
39
|
}
|
|
49
|
-
|
|
50
40
|
function move(_ref, dx, dy) {
|
|
51
41
|
var c = _ref.c,
|
|
52
|
-
|
|
42
|
+
r = _ref.r;
|
|
53
43
|
return {
|
|
54
44
|
c: c + dx,
|
|
55
45
|
r: r + dy
|
|
56
46
|
};
|
|
57
47
|
}
|
|
58
|
-
|
|
59
48
|
function sanitizeCellDatum(value) {
|
|
60
49
|
if (value === Infinity || value === -Infinity || typeof value === 'number' && isNaN(value)) {
|
|
61
50
|
return null;
|
|
@@ -64,8 +53,6 @@ function sanitizeCellDatum(value) {
|
|
|
64
53
|
}
|
|
65
54
|
}
|
|
66
55
|
/** 根据 BaseTable 的 dataSource 和 column,将表格数据导出为 Excel 文件 */
|
|
67
|
-
|
|
68
|
-
|
|
69
56
|
export default function exportTableAsExcel(xlsxPackage, dataSource, columns, filename) {
|
|
70
57
|
var sheet = xlsxPackage.utils.aoa_to_sheet([]);
|
|
71
58
|
var topHeaderHeight = getTreeDepth(columns) + 1;
|
|
@@ -81,30 +68,22 @@ export default function exportTableAsExcel(xlsxPackage, dataSource, columns, fil
|
|
|
81
68
|
Sheet1: sheet
|
|
82
69
|
}
|
|
83
70
|
}, filename);
|
|
84
|
-
|
|
85
71
|
function addTopHeaders(origin) {
|
|
86
72
|
dfs(columns, 0, 0);
|
|
87
|
-
|
|
88
73
|
function dfs(cols, startDx, startDy) {
|
|
89
74
|
var _a;
|
|
90
|
-
|
|
91
75
|
var start = move(origin, startDx, startDy);
|
|
92
76
|
var offsetX = 0;
|
|
93
|
-
|
|
94
77
|
var _iterator = _createForOfIteratorHelper(cols),
|
|
95
|
-
|
|
96
|
-
|
|
78
|
+
_step;
|
|
97
79
|
try {
|
|
98
80
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
99
81
|
var col = _step.value;
|
|
100
|
-
|
|
101
82
|
if ((_a = col.features) === null || _a === void 0 ? void 0 : _a.noExport) {
|
|
102
83
|
continue;
|
|
103
84
|
}
|
|
104
|
-
|
|
105
85
|
var current = move(start, offsetX, 0);
|
|
106
86
|
addOne(col.name, current);
|
|
107
|
-
|
|
108
87
|
if (isLeafNode(col)) {
|
|
109
88
|
offsetX += 1;
|
|
110
89
|
mergeCells(current, 1, topHeaderHeight - startDy);
|
|
@@ -119,66 +98,51 @@ export default function exportTableAsExcel(xlsxPackage, dataSource, columns, fil
|
|
|
119
98
|
} finally {
|
|
120
99
|
_iterator.f();
|
|
121
100
|
}
|
|
122
|
-
|
|
123
101
|
return offsetX;
|
|
124
102
|
}
|
|
125
103
|
}
|
|
126
|
-
|
|
127
104
|
function addDataPart(origin) {
|
|
128
105
|
var _context;
|
|
129
|
-
|
|
130
106
|
var leafColumns = _filterInstanceProperty(_context = collectNodes(columns, 'leaf-only')).call(_context, function (col) {
|
|
131
107
|
var _a;
|
|
132
|
-
|
|
133
108
|
return !((_a = col.features) === null || _a === void 0 ? void 0 : _a.noExport);
|
|
134
109
|
});
|
|
135
|
-
|
|
136
110
|
var spanManager = new SpanManager();
|
|
137
|
-
|
|
138
111
|
var dataPart = _mapInstanceProperty(dataSource).call(dataSource, function (record, rowIndex) {
|
|
139
112
|
spanManager.stripUpwards(rowIndex);
|
|
140
113
|
return _mapInstanceProperty(leafColumns).call(leafColumns, function (col, colIndex) {
|
|
141
114
|
if (spanManager.testSkip(rowIndex, colIndex)) {
|
|
142
115
|
return null;
|
|
143
116
|
}
|
|
144
|
-
|
|
145
117
|
var spanRect = safeGetSpanRect(col, record, rowIndex, colIndex);
|
|
146
118
|
var rowSpan = spanRect.bottom - spanRect.top;
|
|
147
119
|
var colSpan = spanRect.right - spanRect.left;
|
|
148
|
-
|
|
149
120
|
if (rowSpan > 1 || colSpan > 1) {
|
|
150
121
|
spanManager.add(spanRect.top, spanRect.left, colSpan, rowSpan);
|
|
151
122
|
mergeCells(move(origin, spanRect.left, spanRect.top), colSpan, rowSpan);
|
|
152
123
|
}
|
|
153
|
-
|
|
154
124
|
return sanitizeCellDatum(internals.safeGetValue(col, record, rowIndex));
|
|
155
125
|
});
|
|
156
126
|
});
|
|
157
|
-
|
|
158
127
|
add(dataPart, origin);
|
|
159
128
|
}
|
|
160
|
-
|
|
161
129
|
function add(data, origin) {
|
|
162
130
|
xlsxPackage.utils.sheet_add_aoa(sheet, data, {
|
|
163
131
|
origin: origin
|
|
164
132
|
});
|
|
165
133
|
}
|
|
166
|
-
|
|
167
134
|
function addOne(datum, origin) {
|
|
168
135
|
xlsxPackage.utils.sheet_add_aoa(sheet, [[datum]], {
|
|
169
136
|
origin: origin
|
|
170
137
|
});
|
|
171
138
|
}
|
|
172
|
-
|
|
173
139
|
function mergeCells(addr, width, height) {
|
|
174
140
|
if (width === 1 && height === 1) {
|
|
175
141
|
return;
|
|
176
142
|
}
|
|
177
|
-
|
|
178
143
|
if (sheet['!merges'] == null) {
|
|
179
144
|
sheet['!merges'] = [];
|
|
180
145
|
}
|
|
181
|
-
|
|
182
146
|
sheet['!merges'].push({
|
|
183
147
|
s: addr,
|
|
184
148
|
e: move(addr, width - 1, height - 1)
|