@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
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
2
2
|
import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
3
3
|
import _taggedTemplateLiteral from "@babel/runtime-corejs3/helpers/taggedTemplateLiteral";
|
|
4
|
-
|
|
5
4
|
var _templateObject;
|
|
6
|
-
|
|
7
5
|
import _spliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/splice";
|
|
8
6
|
import React from 'react';
|
|
9
7
|
import styled from 'styled-components';
|
|
@@ -13,12 +11,11 @@ import cx from 'classnames';
|
|
|
13
11
|
import { Classes } from '../../base/styles';
|
|
14
12
|
var ExtendIconStyle = styled.span(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n font-size:12px;\n margin-left:4px;\n"])));
|
|
15
13
|
var stateKey = 'colExtend';
|
|
16
|
-
|
|
17
14
|
var ExpandIcon = function ExpandIcon(_ref) {
|
|
18
15
|
var style = _ref.style,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
className = _ref.className,
|
|
17
|
+
size = _ref.size,
|
|
18
|
+
isExtend = _ref.isExtend;
|
|
22
19
|
return isExtend ? /*#__PURE__*/React.createElement("svg", {
|
|
23
20
|
className: className,
|
|
24
21
|
width: size,
|
|
@@ -37,29 +34,23 @@ var ExpandIcon = function ExpandIcon(_ref) {
|
|
|
37
34
|
d: "M321.652913 178.347087C309.449029 166.143203 309.449029 146.356797 321.652913 134.152913C333.856797 121.949029 353.643203 121.949029 365.847088 134.152913L709.597087 477.902913C721.800972 490.106797 721.800972 509.893203 709.597087 522.097087L365.847088 865.847087C353.643203 878.050972 333.856797 878.050972 321.652913 865.847087C309.449029 853.643203 309.449029 833.856797 321.652913 821.652913L643.305825 500L321.652913 178.347087z"
|
|
38
35
|
}));
|
|
39
36
|
};
|
|
40
|
-
|
|
41
37
|
export var colGroupExtendable = function colGroupExtendable() {
|
|
42
38
|
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
43
39
|
return function (pipeline) {
|
|
44
40
|
var _a, _b;
|
|
45
|
-
|
|
46
41
|
var columns = pipeline.getColumns();
|
|
47
42
|
var curState = (_b = (_a = opts.extendStatus) !== null && _a !== void 0 ? _a : pipeline.getStateAtKey(stateKey)) !== null && _b !== void 0 ? _b : {};
|
|
48
|
-
|
|
49
43
|
var processColumns = function processColumns(columns) {
|
|
50
44
|
// 当组合列可伸缩,且处于收缩状态时,只渲染一个子列,其他不渲染
|
|
51
45
|
var toggle = function toggle(col) {
|
|
52
46
|
// 对应的 col 进行状态切换
|
|
53
47
|
var changedValue = _defineProperty({}, col.code, !curState[col.code]);
|
|
54
|
-
|
|
55
48
|
curState[col.code] = !curState[col.code];
|
|
56
49
|
pipeline.setStateAtKey(stateKey, _extends({}, curState));
|
|
57
50
|
(opts === null || opts === void 0 ? void 0 : opts.onChangeExtendStatus) && opts.onChangeExtendStatus(curState, changedValue);
|
|
58
51
|
};
|
|
59
|
-
|
|
60
52
|
var addIcon = function addIcon(col) {
|
|
61
53
|
var result = _extends({}, col);
|
|
62
|
-
|
|
63
54
|
var curColState = curState[col.code];
|
|
64
55
|
var displaycolExtendIcon = typeof opts.extendIcon === 'function' ? opts.extendIcon(curColState) : opts.extendIcon;
|
|
65
56
|
var addIconNode = /*#__PURE__*/React.createElement(React.Fragment, null, internals.safeRenderHeader(_extends({}, col)), /*#__PURE__*/React.createElement(ExtendIconStyle, {
|
|
@@ -81,24 +72,18 @@ export var colGroupExtendable = function colGroupExtendable() {
|
|
|
81
72
|
result.title = addIconNode;
|
|
82
73
|
return result;
|
|
83
74
|
};
|
|
84
|
-
|
|
85
75
|
return makeRecursiveMapper(function (col) {
|
|
86
76
|
var _a;
|
|
87
|
-
|
|
88
77
|
var _ref2 = (col === null || col === void 0 ? void 0 : col.features) || {},
|
|
89
|
-
|
|
90
|
-
|
|
78
|
+
showExtendIcon = _ref2.showExtendIcon;
|
|
91
79
|
if (showExtendIcon === true && ((_a = col.children) === null || _a === void 0 ? void 0 : _a.length) > 1) {
|
|
92
80
|
var _context;
|
|
93
|
-
|
|
94
81
|
col = addIcon(col);
|
|
95
82
|
curState[col.code] === false && _spliceInstanceProperty(_context = col.children).call(_context, 1, col.children.length);
|
|
96
83
|
}
|
|
97
|
-
|
|
98
84
|
return col;
|
|
99
85
|
})(columns);
|
|
100
86
|
};
|
|
101
|
-
|
|
102
87
|
pipeline.columns(processColumns(columns));
|
|
103
88
|
return pipeline;
|
|
104
89
|
};
|
|
@@ -6,55 +6,46 @@ import { makeRecursiveMapper, mergeCellProps, collectNodes, isLeafNode, isSelect
|
|
|
6
6
|
import { FILL_COLUMN_CODE } from './autoFill';
|
|
7
7
|
var stateKey = 'columnDrag';
|
|
8
8
|
var SCROLL_SIZE = 30;
|
|
9
|
-
|
|
10
9
|
function disableSelect(event) {
|
|
11
10
|
event.preventDefault();
|
|
12
11
|
}
|
|
13
|
-
|
|
14
12
|
function sortColumns(columns, sort) {
|
|
15
13
|
var res = new Array(columns.length);
|
|
16
|
-
|
|
17
14
|
var lastColumns = _toConsumableArray(columns);
|
|
18
|
-
|
|
19
15
|
while (columns.length) {
|
|
20
16
|
var cloumn = columns.pop();
|
|
21
17
|
res[sort[cloumn.code]] = cloumn;
|
|
22
18
|
}
|
|
23
|
-
|
|
24
19
|
if (_filterInstanceProperty(res).call(res, Boolean).length !== lastColumns.length) {
|
|
25
20
|
return lastColumns;
|
|
26
21
|
}
|
|
27
|
-
|
|
28
22
|
return res;
|
|
29
23
|
}
|
|
30
|
-
|
|
31
24
|
function stopClickPropagation(e) {
|
|
32
25
|
e.stopPropagation();
|
|
33
26
|
}
|
|
34
|
-
|
|
35
27
|
export function columnDrag() {
|
|
36
28
|
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
37
29
|
return function (pipeline) {
|
|
38
30
|
var _pipeline$getStateAtK = pipeline.getStateAtKey(stateKey, {}),
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
cloumnsTranslateData = _pipeline$getStateAtK.cloumnsTranslateData;
|
|
41
32
|
var columns = pipeline.getColumns();
|
|
42
|
-
var tableBody = pipeline.ref.current.domHelper && pipeline.ref.current.domHelper.tableBody;
|
|
33
|
+
var tableBody = pipeline.ref.current.domHelper && pipeline.ref.current.domHelper.tableBody;
|
|
34
|
+
// if (cloumnsSortData) {
|
|
43
35
|
// columns = sortColumns(columns, cloumnsSortData)
|
|
44
36
|
// }
|
|
45
|
-
|
|
46
37
|
pipeline.columns(_filterInstanceProperty(columns).call(columns, function (column) {
|
|
47
38
|
return column;
|
|
48
39
|
}));
|
|
49
40
|
return pipeline.mapColumns(makeRecursiveMapper(function (col, recursiveFlatMapInfo) {
|
|
50
41
|
var path = recursiveFlatMapInfo.path,
|
|
51
|
-
|
|
42
|
+
isLeaf = recursiveFlatMapInfo.isLeaf;
|
|
52
43
|
var style = cloumnsTranslateData ? {
|
|
53
44
|
transition: '.3s',
|
|
54
45
|
transform: "translate3d(".concat(cloumnsTranslateData[col.code], "px, 0px, 0px)")
|
|
55
46
|
} : {};
|
|
56
|
-
var prevGetCellProps = col.getCellProps;
|
|
57
|
-
|
|
47
|
+
var prevGetCellProps = col.getCellProps;
|
|
48
|
+
// !col.code: 选择列 col.lock: 固定列 不允许拖拽
|
|
58
49
|
if (col.lock || !col.code) return col;
|
|
59
50
|
return _extends(_extends({}, col), {
|
|
60
51
|
getCellProps: function getCellProps(value, record, rowIndex) {
|
|
@@ -68,8 +59,8 @@ export function columnDrag() {
|
|
|
68
59
|
if (e.button !== 0 || !e.currentTarget.contains(e.target)) {
|
|
69
60
|
return;
|
|
70
61
|
}
|
|
71
|
-
|
|
72
|
-
|
|
62
|
+
window.addEventListener('selectstart', disableSelect);
|
|
63
|
+
// const cx = e.clientX
|
|
73
64
|
// const width = col.width
|
|
74
65
|
// const a = startIndex
|
|
75
66
|
// const b = endIndex
|
|
@@ -77,13 +68,10 @@ export function columnDrag() {
|
|
|
77
68
|
// let newColumn = [...columns]
|
|
78
69
|
// let newStartIndex = startIndex
|
|
79
70
|
// let endIdx = endIndex
|
|
80
|
-
|
|
81
71
|
var columnMoved = false;
|
|
82
72
|
var columns = pipeline.getColumns();
|
|
83
|
-
|
|
84
73
|
var _pipeline$getStateAtK2 = pipeline.getStateAtKey(stateKey, {}),
|
|
85
|
-
|
|
86
|
-
|
|
74
|
+
cloumnsTranslateData = _pipeline$getStateAtK2.cloumnsTranslateData;
|
|
87
75
|
var cloumnsSortData = {};
|
|
88
76
|
columns.forEach(function (item, index) {
|
|
89
77
|
cloumnsSortData[item.code] = index;
|
|
@@ -97,21 +85,17 @@ export function columnDrag() {
|
|
|
97
85
|
var allColumns = collectNodes(columns);
|
|
98
86
|
var tableBodyClientRect = tableBody.getBoundingClientRect();
|
|
99
87
|
var startScrollLeft = pipeline.ref.current.domHelper.virtual.scrollLeft;
|
|
100
|
-
|
|
101
88
|
var updateScrollPosition = function updateScrollPosition(client) {
|
|
102
89
|
var clientX = client.clientX;
|
|
103
90
|
var left = tableBodyClientRect.left,
|
|
104
|
-
|
|
105
|
-
|
|
91
|
+
width = tableBodyClientRect.width;
|
|
106
92
|
if (clientX + SCROLL_SIZE >= left + width) {
|
|
107
93
|
pipeline.ref.current.domHelper.virtual.scrollLeft += SCROLL_SIZE;
|
|
108
94
|
}
|
|
109
|
-
|
|
110
95
|
if (clientX - SCROLL_SIZE <= left) {
|
|
111
96
|
pipeline.ref.current.domHelper.virtual.scrollLeft -= SCROLL_SIZE;
|
|
112
97
|
}
|
|
113
98
|
};
|
|
114
|
-
|
|
115
99
|
function handleMouseMove(e) {
|
|
116
100
|
var client = {
|
|
117
101
|
clientX: e.clientX,
|
|
@@ -119,17 +103,15 @@ export function columnDrag() {
|
|
|
119
103
|
};
|
|
120
104
|
var scrollDistance = pipeline.ref.current.domHelper.virtual.scrollLeft - startScrollLeft;
|
|
121
105
|
var leftPosition = startX - scrollDistance; // 表头最左边起点
|
|
122
|
-
|
|
123
106
|
updateScrollPosition(client);
|
|
124
|
-
|
|
125
107
|
if (e.clientX - leftPosition < 20) {
|
|
126
108
|
return;
|
|
127
109
|
} else {
|
|
128
110
|
e.stopPropagation();
|
|
129
111
|
}
|
|
130
|
-
|
|
131
112
|
document.body.style.userSelect = 'none';
|
|
132
|
-
currentTarget.style.cursor = 'move';
|
|
113
|
+
currentTarget.style.cursor = 'move';
|
|
114
|
+
// 循环计算每一个的位置
|
|
133
115
|
// if (startIndex !== replaceIndex) {
|
|
134
116
|
// const optionColumn = columns[startIndex]
|
|
135
117
|
// const move = startIndex > replaceIndex ? 1 : -1
|
|
@@ -152,21 +134,18 @@ export function columnDrag() {
|
|
|
152
134
|
// index++
|
|
153
135
|
// }
|
|
154
136
|
// 重置位置信息
|
|
155
|
-
|
|
156
137
|
cloumnsTranslateData = {};
|
|
157
138
|
allColumns.forEach(function (item) {
|
|
158
139
|
cloumnsTranslateData[item.code] = 0;
|
|
159
|
-
});
|
|
160
|
-
|
|
140
|
+
});
|
|
141
|
+
// 计算平移位置
|
|
161
142
|
var replaceIndex = 0;
|
|
162
143
|
var totalWitdth = getColumnWidth(columns[replaceIndex]);
|
|
163
|
-
|
|
164
144
|
while (totalWitdth < e.clientX - leftPosition && replaceIndex < columns.length - 1) {
|
|
165
145
|
replaceIndex++;
|
|
166
146
|
totalWitdth += getColumnWidth(columns[replaceIndex]);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
|
|
147
|
+
}
|
|
148
|
+
// 需要取最新startIndex, 不能直接用makeRecursiveMapper提供的startIndex(因为map时还没添加选择列、充满列等后面use添加的列)
|
|
170
149
|
var startIndex;
|
|
171
150
|
columns.forEach(function (column, index) {
|
|
172
151
|
if (column.code === col.code) {
|
|
@@ -175,63 +154,53 @@ export function columnDrag() {
|
|
|
175
154
|
});
|
|
176
155
|
var optionColumn = columns[startIndex];
|
|
177
156
|
var index = replaceIndex;
|
|
178
|
-
|
|
179
157
|
if (startIndex > replaceIndex) {
|
|
180
158
|
// 左移
|
|
181
159
|
while (index < startIndex) {
|
|
182
160
|
var _columns$index = columns[index],
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
161
|
+
code = _columns$index.code,
|
|
162
|
+
lock = _columns$index.lock,
|
|
163
|
+
width = _columns$index.width,
|
|
164
|
+
children = _columns$index.children;
|
|
188
165
|
if (enableMove({
|
|
189
166
|
code: code,
|
|
190
167
|
lock: lock
|
|
191
168
|
})) {
|
|
192
169
|
cloumnsTranslateData[code] += optionColumn.width;
|
|
193
|
-
|
|
194
170
|
if (isLeafNode(columns[index])) {
|
|
195
171
|
cloumnsTranslateData[optionColumn.code] -= width;
|
|
196
172
|
} else {
|
|
197
173
|
cloumnsTranslateData[optionColumn.code] -= getColumnWidth(columns[index]);
|
|
198
174
|
moveAllChildren(children, cloumnsTranslateData, optionColumn.width);
|
|
199
175
|
}
|
|
200
|
-
|
|
201
176
|
columnMoved = true;
|
|
202
177
|
}
|
|
203
|
-
|
|
204
178
|
index++;
|
|
205
179
|
}
|
|
206
180
|
} else if (startIndex < replaceIndex) {
|
|
207
181
|
// 右移
|
|
208
182
|
while (startIndex < index) {
|
|
209
183
|
var _columns$index2 = columns[index],
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
184
|
+
_code = _columns$index2.code,
|
|
185
|
+
_lock = _columns$index2.lock,
|
|
186
|
+
_width = _columns$index2.width,
|
|
187
|
+
_children = _columns$index2.children;
|
|
215
188
|
if (enableMove({
|
|
216
189
|
code: _code,
|
|
217
190
|
lock: _lock
|
|
218
191
|
})) {
|
|
219
192
|
cloumnsTranslateData[_code] -= optionColumn.width;
|
|
220
|
-
|
|
221
193
|
if (isLeafNode(columns[index])) {
|
|
222
194
|
cloumnsTranslateData[optionColumn.code] += _width;
|
|
223
195
|
} else {
|
|
224
196
|
cloumnsTranslateData[optionColumn.code] += getColumnWidth(columns[index]);
|
|
225
197
|
moveAllChildren(_children, cloumnsTranslateData, optionColumn.width, true);
|
|
226
198
|
}
|
|
227
|
-
|
|
228
199
|
columnMoved = true;
|
|
229
200
|
}
|
|
230
|
-
|
|
231
201
|
index--;
|
|
232
202
|
}
|
|
233
203
|
}
|
|
234
|
-
|
|
235
204
|
window.requestAnimationFrame(function () {
|
|
236
205
|
pipeline.setStateAtKey(stateKey, {
|
|
237
206
|
cloumnsTranslateData: cloumnsTranslateData
|
|
@@ -239,29 +208,24 @@ export function columnDrag() {
|
|
|
239
208
|
moveData = [startIndex, replaceIndex];
|
|
240
209
|
});
|
|
241
210
|
}
|
|
242
|
-
|
|
243
211
|
function handleMouseUp(e) {
|
|
244
212
|
document.body.removeEventListener('mousemove', handleMouseMove);
|
|
245
213
|
document.body.removeEventListener('mouseup', handleMouseUp);
|
|
246
214
|
window.removeEventListener('selectstart', disableSelect);
|
|
247
|
-
|
|
248
215
|
if (_isMoveWhenClicking(mouseDownClientX, mouseDownClientY, e.clientX, e.clientY)) {
|
|
249
216
|
e.stopPropagation(); // 存在移动就阻止冒泡
|
|
250
|
-
|
|
251
217
|
currentTarget.addEventListener('click', stopClickPropagation); // 阻止列头点击事件,防止拖动后触发列头过滤事件
|
|
252
218
|
}
|
|
253
|
-
|
|
254
219
|
window.requestAnimationFrame(function () {
|
|
255
220
|
// 取消阻止列头点击事件
|
|
256
221
|
currentTarget.removeEventListener('click', stopClickPropagation);
|
|
257
222
|
currentTarget = null;
|
|
258
|
-
|
|
259
223
|
var _moveData = moveData,
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
224
|
+
_moveData2 = _slicedToArray(_moveData, 2),
|
|
225
|
+
startIndex = _moveData2[0],
|
|
226
|
+
replaceIndex = _moveData2[1];
|
|
227
|
+
var optionColumn = columns[startIndex];
|
|
228
|
+
// const move = startIndex > replaceIndex ? 1 : -1
|
|
265
229
|
// let index = Math.min(startIndex, replaceIndex)
|
|
266
230
|
// while (index < Math.max(startIndex, replaceIndex) && index > 0) {
|
|
267
231
|
// const code = columns[index].code
|
|
@@ -269,16 +233,13 @@ export function columnDrag() {
|
|
|
269
233
|
// cloumnsSortData[code] += move
|
|
270
234
|
// index += move
|
|
271
235
|
// }
|
|
272
|
-
|
|
273
236
|
var index = replaceIndex;
|
|
274
|
-
|
|
275
237
|
if (startIndex > replaceIndex) {
|
|
276
238
|
// 左移
|
|
277
239
|
while (index < startIndex) {
|
|
278
240
|
var _columns$index3 = columns[index],
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
241
|
+
code = _columns$index3.code,
|
|
242
|
+
lock = _columns$index3.lock;
|
|
282
243
|
if (enableMove({
|
|
283
244
|
code: code,
|
|
284
245
|
lock: lock
|
|
@@ -287,16 +248,14 @@ export function columnDrag() {
|
|
|
287
248
|
cloumnsSortData[optionColumn.code] -= 1;
|
|
288
249
|
columnMoved = true;
|
|
289
250
|
}
|
|
290
|
-
|
|
291
251
|
index++;
|
|
292
252
|
}
|
|
293
253
|
} else if (startIndex < replaceIndex) {
|
|
294
254
|
// 右移
|
|
295
255
|
while (index > startIndex) {
|
|
296
256
|
var _columns$index4 = columns[index],
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
257
|
+
_code2 = _columns$index4.code,
|
|
258
|
+
_lock2 = _columns$index4.lock;
|
|
300
259
|
if (enableMove({
|
|
301
260
|
code: _code2,
|
|
302
261
|
lock: _lock2
|
|
@@ -305,29 +264,23 @@ export function columnDrag() {
|
|
|
305
264
|
cloumnsSortData[optionColumn.code] += 1;
|
|
306
265
|
columnMoved = true;
|
|
307
266
|
}
|
|
308
|
-
|
|
309
267
|
index--;
|
|
310
268
|
}
|
|
311
269
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
270
|
+
var onColumnDragStopped = opts.onColumnDragStopped;
|
|
271
|
+
// 拖拽结束返回列顺序
|
|
315
272
|
if (onColumnDragStopped) {
|
|
316
273
|
var _context;
|
|
317
|
-
|
|
318
274
|
var isRowDragColumn = function isRowDragColumn(code) {
|
|
319
275
|
var rowDragColumnKey = pipeline.getFeatureOptions('rowDragColumnKey');
|
|
320
276
|
return code === rowDragColumnKey;
|
|
321
277
|
};
|
|
322
|
-
|
|
323
278
|
var newColumns = _filterInstanceProperty(_context = sortColumns(columns, cloumnsSortData)).call(_context, function (column) {
|
|
324
279
|
return column.code !== FILL_COLUMN_CODE && !isRowDragColumn(column.code) && !isSelectColumn(column);
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
|
|
280
|
+
});
|
|
281
|
+
// TODO drag需要在resize之后use,否则这里返回的列对应的宽度不是拖拽后的
|
|
328
282
|
onColumnDragStopped(columnMoved, newColumns);
|
|
329
283
|
}
|
|
330
|
-
|
|
331
284
|
pipeline.setStateAtKey(stateKey, {
|
|
332
285
|
cloumnsTranslateData: null
|
|
333
286
|
});
|
|
@@ -336,7 +289,6 @@ export function columnDrag() {
|
|
|
336
289
|
currentTarget.style.opacity = '';
|
|
337
290
|
currentTarget.style.cursor = '';
|
|
338
291
|
}
|
|
339
|
-
|
|
340
292
|
var onColumnDragStart = opts.onColumnDragStart;
|
|
341
293
|
onColumnDragStart && onColumnDragStart(col);
|
|
342
294
|
document.body.addEventListener('mousemove', handleMouseMove);
|
|
@@ -348,45 +300,37 @@ export function columnDrag() {
|
|
|
348
300
|
}));
|
|
349
301
|
};
|
|
350
302
|
}
|
|
351
|
-
|
|
352
303
|
function enableMove(_ref) {
|
|
353
304
|
var lock = _ref.lock,
|
|
354
|
-
|
|
305
|
+
code = _ref.code;
|
|
355
306
|
return code && code !== FILL_COLUMN_CODE && !lock;
|
|
356
307
|
}
|
|
357
|
-
|
|
358
308
|
function getColumnWidth(col) {
|
|
359
309
|
if (col.children) {
|
|
360
310
|
return col.children.reduce(function (acc, col) {
|
|
361
311
|
return acc + getColumnWidth(col);
|
|
362
312
|
}, 0);
|
|
363
313
|
}
|
|
364
|
-
|
|
365
314
|
return col.width;
|
|
366
315
|
}
|
|
367
|
-
|
|
368
316
|
function moveAllChildren(cols, cloumnsTranslateData, width, isMinus) {
|
|
369
317
|
cols.forEach(function (col) {
|
|
370
318
|
var _a;
|
|
371
|
-
|
|
372
319
|
var code = col.code,
|
|
373
|
-
|
|
320
|
+
children = col.children;
|
|
374
321
|
var movedWidth = (_a = cloumnsTranslateData[code]) !== null && _a !== void 0 ? _a : 0;
|
|
375
322
|
cloumnsTranslateData[code] = movedWidth + (isMinus ? -width : width);
|
|
376
|
-
|
|
377
323
|
if (!isLeafNode(col)) {
|
|
378
324
|
moveAllChildren(children, cloumnsTranslateData, width);
|
|
379
325
|
}
|
|
380
326
|
});
|
|
381
327
|
}
|
|
382
|
-
|
|
383
328
|
function _isMoveWhenClicking(mouseDownClientX, mouseDownClientY, mouseUpClientX, mouseUpClientY) {
|
|
384
329
|
var xDiff = mouseUpClientX - mouseDownClientX;
|
|
385
|
-
var yDiff = mouseUpClientY - mouseDownClientY;
|
|
386
|
-
|
|
330
|
+
var yDiff = mouseUpClientY - mouseDownClientY;
|
|
331
|
+
// 鼠标点按和松开的偏移量大于5px,认为存在移动
|
|
387
332
|
if (Math.sqrt(xDiff * xDiff + yDiff * yDiff) > 5) {
|
|
388
333
|
return true;
|
|
389
334
|
}
|
|
390
|
-
|
|
391
335
|
return false;
|
|
392
336
|
}
|
|
@@ -19,63 +19,49 @@ export function filter() {
|
|
|
19
19
|
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
20
20
|
return function step(pipeline) {
|
|
21
21
|
var _a, _b;
|
|
22
|
-
|
|
23
22
|
var dataSource = pipeline.getDataSource();
|
|
24
23
|
var columns = pipeline.getColumns();
|
|
25
24
|
var filters = opts.filters,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
defaultFilters = opts.defaultFilters,
|
|
26
|
+
onChangeFilters = opts.onChangeFilters,
|
|
27
|
+
keepDataSource = opts.keepDataSource,
|
|
28
|
+
mode = opts.mode,
|
|
29
|
+
filterIcon = opts.filterIcon,
|
|
30
|
+
stopClickEventPropagation = opts.stopClickEventPropagation,
|
|
31
|
+
stopESCKeyDownEventPropagation = opts.stopESCKeyDownEventPropagation,
|
|
32
|
+
hideFilterPopupHeader = opts.hideFilterPopupHeader,
|
|
33
|
+
getPopupParent = opts.getPopupParent;
|
|
35
34
|
var inputFilters = (_b = (_a = filters !== null && filters !== void 0 ? filters : pipeline.getStateAtKey(stateKey)) !== null && _a !== void 0 ? _a : defaultFilters) !== null && _b !== void 0 ? _b : [];
|
|
36
35
|
inputFilters = mode === 'single' ? _sliceInstanceProperty(inputFilters).call(inputFilters, 0, 1) : inputFilters;
|
|
37
36
|
var inputFiltersMap = new _Map(_mapInstanceProperty(inputFilters).call(inputFilters, function (filterItem) {
|
|
38
37
|
return [filterItem.code, _extends({}, filterItem)];
|
|
39
38
|
}));
|
|
40
39
|
var localeText = pipeline.ctx.localeText;
|
|
41
|
-
|
|
42
40
|
function processColumns(columns) {
|
|
43
41
|
return _mapInstanceProperty(columns).call(columns, dfs);
|
|
44
|
-
|
|
45
42
|
function dfs(col) {
|
|
46
43
|
var _a, _b, _c, _d, _e;
|
|
47
|
-
|
|
48
44
|
var result = _extends({}, col);
|
|
49
|
-
|
|
50
45
|
var filterable = col.code && ((_a = col.features) === null || _a === void 0 ? void 0 : _a.filterable);
|
|
51
46
|
var filterActive = !!(filterable && (inputFiltersMap === null || inputFiltersMap === void 0 ? void 0 : inputFiltersMap.get(col.code)));
|
|
52
|
-
|
|
53
47
|
if (filterable) {
|
|
54
|
-
var _cx;
|
|
55
|
-
|
|
56
48
|
var handleFilterChanged = function handleFilterChanged(filterItem) {
|
|
57
49
|
var nextFiltersMap = new _Map(inputFiltersMap);
|
|
58
|
-
|
|
59
50
|
var currentFilter = _extends({
|
|
60
51
|
code: col.code
|
|
61
52
|
}, filterItem);
|
|
62
|
-
|
|
63
53
|
if (filterItem == null) {
|
|
64
54
|
nextFiltersMap.delete(col.code);
|
|
65
55
|
} else {
|
|
66
56
|
if (mode === 'single') {
|
|
67
57
|
nextFiltersMap.clear();
|
|
68
58
|
}
|
|
69
|
-
|
|
70
59
|
nextFiltersMap.set(col.code, currentFilter);
|
|
71
60
|
}
|
|
72
|
-
|
|
73
61
|
var nextFilters = _Array$from(_valuesInstanceProperty(nextFiltersMap).call(nextFiltersMap));
|
|
74
|
-
|
|
75
62
|
onChangeFilters === null || onChangeFilters === void 0 ? void 0 : onChangeFilters(nextFilters, currentFilter);
|
|
76
63
|
pipeline.setStateAtKey(stateKey, nextFilters);
|
|
77
64
|
};
|
|
78
|
-
|
|
79
65
|
var setFilter = function setFilter(filter, filterCondition) {
|
|
80
66
|
handleFilterChanged(!filter ? undefined : {
|
|
81
67
|
code: col.code,
|
|
@@ -83,10 +69,8 @@ export function filter() {
|
|
|
83
69
|
filterCondition: filterCondition
|
|
84
70
|
});
|
|
85
71
|
};
|
|
86
|
-
|
|
87
72
|
var filterPanel = (_b = col.features) === null || _b === void 0 ? void 0 : _b.filterPanel;
|
|
88
73
|
var colFilterIcon = (_d = (_c = col.features) === null || _c === void 0 ? void 0 : _c.filterIcon) !== null && _d !== void 0 ? _d : filterIcon;
|
|
89
|
-
|
|
90
74
|
var _Filter = /*#__PURE__*/React.createElement(Filter, {
|
|
91
75
|
key: "".concat(col.code, "_filter"),
|
|
92
76
|
FilterPanelContent: filterPanel,
|
|
@@ -95,54 +79,44 @@ export function filter() {
|
|
|
95
79
|
setFilterModel: handleFilterChanged,
|
|
96
80
|
setFilter: setFilter,
|
|
97
81
|
isFilterActive: filterActive,
|
|
98
|
-
className: cx((
|
|
82
|
+
className: cx(_defineProperty(_defineProperty({}, Classes.tableFilterTrigger, true), "active", filterActive)),
|
|
99
83
|
stopClickEventPropagation: stopClickEventPropagation,
|
|
100
84
|
stopESCKeyDownEventPropagation: stopESCKeyDownEventPropagation,
|
|
101
85
|
hideFilterPopupHeader: hideFilterPopupHeader,
|
|
102
86
|
getPopupParent: getPopupParent,
|
|
103
87
|
localeText: localeText
|
|
104
88
|
});
|
|
105
|
-
|
|
106
89
|
if (col.renderHeader) {
|
|
107
90
|
result.title = col.renderHeader(result.title, _Filter);
|
|
108
91
|
} else {
|
|
109
92
|
var _context, _context2;
|
|
110
|
-
|
|
111
93
|
result.title = _concatInstanceProperty(_context = []).call(_context, _toConsumableArray(_concatInstanceProperty(_context2 = []).call(_context2, (_e = result.title) !== null && _e !== void 0 ? _e : [internals.safeRenderHeader(_extends({}, col))])), [_Filter]);
|
|
112
|
-
}
|
|
94
|
+
}
|
|
95
|
+
// result.headerCellProps = mergeCellProps(col.headerCellProps, {
|
|
113
96
|
// style: {
|
|
114
97
|
// paddingRight: '18px'
|
|
115
98
|
// }
|
|
116
99
|
// })
|
|
117
|
-
|
|
118
100
|
}
|
|
119
|
-
|
|
120
101
|
if (!isLeafNode(col)) {
|
|
121
102
|
var _context3;
|
|
122
|
-
|
|
123
103
|
result.children = _mapInstanceProperty(_context3 = col.children).call(_context3, dfs);
|
|
124
104
|
}
|
|
125
|
-
|
|
126
105
|
return result;
|
|
127
106
|
}
|
|
128
107
|
}
|
|
129
|
-
|
|
130
108
|
function processDataSource(dataSource) {
|
|
131
109
|
var _context4, _context5;
|
|
132
|
-
|
|
133
110
|
var filtersKeys = [];
|
|
134
111
|
inputFiltersMap.forEach(function (value, key) {
|
|
135
112
|
filtersKeys.push(key);
|
|
136
113
|
});
|
|
137
|
-
|
|
138
114
|
if (keepDataSource || filtersKeys.length <= 0) {
|
|
139
115
|
return dataSource;
|
|
140
116
|
}
|
|
141
|
-
|
|
142
117
|
var columns = pipeline.getColumns();
|
|
143
118
|
var columnsMap = new _Map(_mapInstanceProperty(_context4 = _filterInstanceProperty(_context5 = collectNodes(columns, 'leaf-only')).call(_context5, function (col) {
|
|
144
119
|
var _a, _b;
|
|
145
|
-
|
|
146
120
|
return ((_a = col.features) === null || _a === void 0 ? void 0 : _a.filterable) !== false && ((_b = col.features) === null || _b === void 0 ? void 0 : _b.filterable) != null;
|
|
147
121
|
})).call(_context4, function (col) {
|
|
148
122
|
return [col.code, col];
|
|
@@ -150,15 +124,12 @@ export function filter() {
|
|
|
150
124
|
var defaultFilterOptionsMap = new _Map(_mapInstanceProperty(DEFAULT_FILTER_OPTIONS).call(DEFAULT_FILTER_OPTIONS, function (item) {
|
|
151
125
|
return [item.key, _extends({}, item)];
|
|
152
126
|
}));
|
|
153
|
-
|
|
154
127
|
function isMatchedFilterCondition(record) {
|
|
155
128
|
return filtersKeys.every(function (key) {
|
|
156
129
|
var _a, _b;
|
|
157
|
-
|
|
158
130
|
var filterItem = inputFiltersMap.get(key);
|
|
159
131
|
var filterable = (_b = (_a = columnsMap.get(key)) === null || _a === void 0 ? void 0 : _a.features) === null || _b === void 0 ? void 0 : _b.filterable;
|
|
160
132
|
var comparisonFn;
|
|
161
|
-
|
|
162
133
|
if (typeof filterable === 'function') {
|
|
163
134
|
comparisonFn = filterable;
|
|
164
135
|
} else if (defaultFilterOptionsMap.get(filterItem.filterCondition)) {
|
|
@@ -167,40 +138,30 @@ export function filter() {
|
|
|
167
138
|
console.warn("\u5217[".concat(key, "]\u672A\u914D\u7F6E\u7B5B\u9009\u51FD\u6570\uFF0C\u8BF7\u8BBE\u7F6E column.features.filterable \u6765\u4F5C\u4E3A\u8BE5\u5217\u7684\u7B5B\u9009\u51FD\u6570, \u76EE\u524D\u4F7F\u7528\u9ED8\u8BA4\u5305\u542B\u7B5B\u9009\u51FD\u6570"));
|
|
168
139
|
comparisonFn = _filterInstanceProperty(defaultFilterOptionsMap.get('contain'));
|
|
169
140
|
}
|
|
170
|
-
|
|
171
141
|
return comparisonFn(_filterInstanceProperty(filterItem), filterItem)(internals.safeGetValue(columnsMap.get(key), record, -1), record);
|
|
172
142
|
});
|
|
173
143
|
}
|
|
174
|
-
|
|
175
144
|
return layeredFilter(dataSource, isMatchedFilterCondition);
|
|
176
145
|
}
|
|
177
|
-
|
|
178
146
|
pipeline.dataSource(processDataSource(dataSource));
|
|
179
147
|
pipeline.columns(processColumns(columns));
|
|
180
148
|
return pipeline;
|
|
181
149
|
};
|
|
182
150
|
}
|
|
183
|
-
|
|
184
151
|
function layeredFilter(array, matchFn) {
|
|
185
152
|
return dfs(array);
|
|
186
|
-
|
|
187
153
|
function dfs(rows) {
|
|
188
154
|
var _context6;
|
|
189
|
-
|
|
190
155
|
var parentMatched = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
191
156
|
return _filterInstanceProperty(_context6 = _mapInstanceProperty(rows).call(rows, function (row) {
|
|
192
157
|
var currentMatched = matchFn(row);
|
|
193
|
-
|
|
194
158
|
if (isLeafNode(row)) {
|
|
195
159
|
return (parentMatched || currentMatched) && _extends({}, row);
|
|
196
160
|
}
|
|
197
|
-
|
|
198
161
|
var children = row.children;
|
|
199
|
-
|
|
200
162
|
var rowAfterFilterChildren = _extends(_extends({}, row), {
|
|
201
163
|
children: dfs(children, parentMatched || currentMatched)
|
|
202
164
|
});
|
|
203
|
-
|
|
204
165
|
var matchedByChildren = !isLeafNode(rowAfterFilterChildren);
|
|
205
166
|
return (parentMatched || currentMatched || matchedByChildren) && rowAfterFilterChildren;
|
|
206
167
|
})).call(_context6, Boolean);
|