@kdcloudjs/table 1.2.1-canary.6 → 1.2.1-canary.7-hotfix.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@kdcloudjs/table.css +1 -1
- package/dist/@kdcloudjs/table.css.map +0 -0
- package/dist/@kdcloudjs/table.js +1755 -3334
- package/dist/@kdcloudjs/table.js.map +1 -1
- package/dist/@kdcloudjs/table.min.css +1 -1
- package/dist/@kdcloudjs/table.min.js +16 -16
- package/dist/@kdcloudjs/table.min.js.map +1 -1
- package/dist/default-theme.js +0 -0
- package/dist/kd-ui-complete.less +0 -0
- package/dist/kd-ui.less +0 -0
- package/dist/theme.js +0 -0
- package/es/_utils/arrayUtil.js +0 -3
- package/es/_utils/devwarning.js +0 -1
- package/es/_utils/formatUtil.js +35 -96
- package/es/_utils/hooks.js +18 -42
- 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 +74 -137
- 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 +5 -43
- package/es/table/base/calculations.js +22 -72
- package/es/table/base/colgroup.js +0 -1
- package/es/table/base/empty.js +4 -4
- package/es/table/base/header.js +16 -69
- package/es/table/base/helpers/SpanManager.js +3 -9
- package/es/table/base/helpers/TableDOMUtils.js +4 -28
- 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 +14 -35
- package/es/table/base/loading.js +6 -8
- package/es/table/base/renderTemplates.js +26 -44
- package/es/table/base/styles.js +0 -9
- package/es/table/base/table.js +95 -181
- package/es/table/base/utils.js +14 -54
- package/es/table/common-views.js +0 -7
- package/es/table/internals.js +0 -13
- 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 -96
- package/es/table/pipeline/features/columnFilter.js +11 -48
- 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 +11 -37
- package/es/table/pipeline/features/contextMenu.js +18 -89
- package/es/table/pipeline/features/filter/DefaultFilterContent.js +10 -25
- package/es/table/pipeline/features/filter/DefaultFilterIcon.js +1 -1
- package/es/table/pipeline/features/filter/Filter.js +25 -48
- 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 +63 -142
- package/es/table/pipeline/features/rowDetail.js +2 -41
- package/es/table/pipeline/features/rowDrag.js +38 -76
- package/es/table/pipeline/features/rowGrouping.js +2 -35
- package/es/table/pipeline/features/singleSelect.js +0 -24
- package/es/table/pipeline/features/sort.js +32 -89
- package/es/table/pipeline/features/tips.js +0 -6
- package/es/table/pipeline/features/treeMode.js +14 -46
- package/es/table/pipeline/features/treeSelect.js +0 -26
- package/es/table/pipeline/pipeline.js +11 -51
- package/es/table/pivot/cross-table/buildCrossTable.js +15 -64
- package/es/table/pivot/cross-table/cross-table.js +22 -28
- package/es/table/pivot/cross-tree-table/buildCrossTreeTable.js +14 -47
- package/es/table/pivot/cross-tree-table/cross-tree-table.js +28 -50
- package/es/table/pivot/pivot-utils/buildDrillTree.js +10 -23
- package/es/table/pivot/pivot-utils/builders.js +31 -71
- package/es/table/pivot/pivot-utils/convert-utils.js +13 -39
- package/es/table/pivot/pivot-utils/simpleEncode.js +0 -1
- package/es/table/transforms/autoRowSpan.js +1 -15
- package/es/table/transforms/autoWidth.js +10 -32
- 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 +15 -37
- package/es/table/transforms/flatten.js +0 -3
- package/es/table/transforms/orderField.js +0 -3
- package/es/table/transforms/sort.js +36 -93
- package/es/table/transforms/tips.js +1 -6
- package/es/table/transforms/treeMode.js +30 -69
- 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 +4 -19
- package/es/table/utils/collectNodes.js +1 -10
- 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 +4 -40
- package/es/table/utils/getTreeDepth.js +1 -9
- package/es/table/utils/groupBy.js +1 -10
- package/es/table/utils/layeredFilter.js +0 -4
- package/es/table/utils/layeredSort.js +0 -5
- package/es/table/utils/makeRecursiveMapper.js +1 -12
- package/es/table/utils/mergeCellProps.js +6 -13
- package/es/table/utils/others.js +3 -16
- package/es/table/utils/proto.js +2 -30
- package/es/table/utils/smartCompare.js +4 -12
- package/es/table/utils/traverseColumn.js +2 -15
- package/es/table/utils/tree-data-helpers/StrictTreeDataHelper.js +1 -22
- package/es/table/utils/tree-data-helpers/TreeDataHelper.js +15 -69
- package/es/table/utils/uiDegrade.js +0 -5
- package/lib/_utils/arrayUtil.js +0 -5
- package/lib/_utils/devwarning.js +0 -5
- package/lib/_utils/formatUtil.js +35 -100
- package/lib/_utils/hooks.js +18 -53
- package/lib/_utils/index.js +0 -6
- 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 +0 -6
- package/lib/_utils/usePopper.js +74 -158
- package/lib/config-provider/ConfigContext.js +1 -4
- package/lib/config-provider/compDefaultProps.js +0 -1
- package/lib/config-provider/configProvider.js +3 -18
- package/lib/config-provider/defaultConfig.js +0 -5
- package/lib/config-provider/index.js +0 -6
- package/lib/index.js +2 -8
- package/lib/locale/index.js +0 -7
- package/lib/locale/locale.js +5 -57
- package/lib/table/base/calculations.js +22 -83
- package/lib/table/base/colgroup.js +0 -5
- package/lib/table/base/empty.js +4 -16
- package/lib/table/base/header.js +16 -79
- package/lib/table/base/helpers/SpanManager.js +3 -11
- package/lib/table/base/helpers/TableDOMUtils.js +2 -28
- 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 +13 -63
- package/lib/table/base/helpers/rowHeightManager.js +0 -33
- package/lib/table/base/html-table.js +14 -45
- package/lib/table/base/index.js +0 -2
- package/lib/table/base/loading.js +6 -12
- package/lib/table/base/renderTemplates.js +27 -58
- package/lib/table/base/styles.js +0 -21
- package/lib/table/base/table.js +95 -214
- package/lib/table/base/utils.js +14 -89
- package/lib/table/common-views.js +0 -16
- package/lib/table/index.js +0 -13
- package/lib/table/internals.js +0 -14
- package/lib/table/pipeline/features/autoFill.js +11 -47
- 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 +4 -32
- package/lib/table/pipeline/features/columnDrag.js +41 -102
- package/lib/table/pipeline/features/columnFilter.js +11 -62
- 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 +11 -53
- package/lib/table/pipeline/features/contextMenu.js +18 -113
- package/lib/table/pipeline/features/filter/DefaultFilterContent.js +10 -43
- package/lib/table/pipeline/features/filter/DefaultFilterIcon.js +1 -4
- package/lib/table/pipeline/features/filter/Filter.js +25 -70
- package/lib/table/pipeline/features/filter/FilterPanel.js +11 -40
- package/lib/table/pipeline/features/filter/index.js +0 -5
- package/lib/table/pipeline/features/filter/util.js +0 -7
- package/lib/table/pipeline/features/footerDataSource.js +0 -10
- 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 +63 -159
- package/lib/table/pipeline/features/rowDetail.js +2 -65
- package/lib/table/pipeline/features/rowDrag.js +38 -87
- package/lib/table/pipeline/features/rowGrouping.js +2 -55
- package/lib/table/pipeline/features/singleSelect.js +0 -34
- package/lib/table/pipeline/features/sort.js +31 -108
- package/lib/table/pipeline/features/tips.js +0 -15
- package/lib/table/pipeline/features/treeMode.js +14 -67
- package/lib/table/pipeline/features/treeSelect.js +0 -34
- package/lib/table/pipeline/index.js +0 -8
- package/lib/table/pipeline/pipeline.js +11 -60
- package/lib/table/pivot/cross-table/buildCrossTable.js +15 -75
- package/lib/table/pivot/cross-table/cross-table.js +22 -36
- package/lib/table/pivot/cross-table/index.js +0 -4
- package/lib/table/pivot/cross-tree-table/buildCrossTreeTable.js +14 -60
- package/lib/table/pivot/cross-tree-table/cross-tree-table.js +28 -60
- 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 +31 -82
- package/lib/table/pivot/pivot-utils/convert-utils.js +13 -57
- 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/transforms/autoRowSpan.js +1 -21
- package/lib/table/transforms/autoWidth.js +10 -53
- 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 +15 -56
- 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 +36 -117
- package/lib/table/transforms/tips.js +1 -16
- package/lib/table/transforms/treeMode.js +30 -96
- package/lib/table/transforms/visible.js +0 -7
- package/lib/table/transforms/warnTransformsDeprecated.js +0 -4
- package/lib/table/use/useResizeObserver.js +1 -8
- package/lib/table/utils/applyTransforms.js +0 -2
- package/lib/table/utils/browserType.js +12 -19
- package/lib/table/utils/buildTree.js +4 -30
- package/lib/table/utils/collectNodes.js +1 -15
- package/lib/table/utils/console.js +0 -16
- package/lib/table/utils/copyToClipboard.js +0 -6
- package/lib/table/utils/element.js +14 -46
- package/lib/table/utils/exportTableAsExcel.js +4 -49
- package/lib/table/utils/getTreeDepth.js +1 -14
- package/lib/table/utils/groupBy.js +1 -14
- 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/layeredFilter.js +0 -10
- package/lib/table/utils/layeredSort.js +0 -10
- package/lib/table/utils/makeRecursiveMapper.js +1 -21
- package/lib/table/utils/mergeCellProps.js +6 -17
- package/lib/table/utils/others.js +3 -31
- package/lib/table/utils/proto.js +2 -33
- package/lib/table/utils/selectColumn.js +0 -1
- package/lib/table/utils/smartCompare.js +4 -13
- package/lib/table/utils/traverseColumn.js +2 -22
- package/lib/table/utils/tree-data-helpers/StrictTreeDataHelper.js +1 -30
- package/lib/table/utils/tree-data-helpers/TreeDataHelper.js +15 -82
- package/lib/table/utils/uiDegrade.js +1 -8
- package/package.json +2 -1
- package/lib/style/color/colors.less +0 -2
- package/lib/style/core/index.less +0 -2
- package/lib/style/core/motion/other.less +0 -28
- package/lib/style/core/motion/slide.less +0 -53
- package/lib/style/core/motion.less +0 -2
- package/lib/style/core/reset.less +0 -186
- package/lib/style/index.css +0 -410
- package/lib/style/index.less +0 -2
- package/lib/style/mixins/index.less +0 -19
- package/lib/style/mixins/overlay.less +0 -22
- package/lib/style/mixins/reset.less +0 -13
- package/lib/style/themes/default.less +0 -445
- package/lib/style/themes/index.less +0 -1
- package/lib/table/style/index.css +0 -0
- package/lib/table/style/index.less +0 -1
|
@@ -4,15 +4,10 @@ import _getIteratorMethod from "@babel/runtime-corejs3/core-js/get-iterator-meth
|
|
|
4
4
|
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
5
5
|
import _taggedTemplateLiteral from "@babel/runtime-corejs3/helpers/taggedTemplateLiteral";
|
|
6
6
|
import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
7
|
-
|
|
8
7
|
var _templateObject;
|
|
9
|
-
|
|
10
8
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
11
|
-
|
|
12
9
|
function _unsupportedIterableToArray(o, minLen) { var _context4; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context4 = Object.prototype.toString.call(o)).call(_context4, 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); }
|
|
13
|
-
|
|
14
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; }
|
|
15
|
-
|
|
16
11
|
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
17
12
|
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
18
13
|
import _Map from "@babel/runtime-corejs3/core-js-stable/map";
|
|
@@ -23,15 +18,14 @@ import React from 'react';
|
|
|
23
18
|
import styled from 'styled-components';
|
|
24
19
|
import cx from 'classnames';
|
|
25
20
|
import { internals } from '../../internals';
|
|
26
|
-
import { collectNodes, isLeafNode, layeredSort, mergeCellProps, smartCompare
|
|
21
|
+
import { collectNodes, isLeafNode, layeredSort, mergeCellProps, smartCompare } from '../../utils';
|
|
27
22
|
import { Classes } from '../../base/styles';
|
|
28
|
-
|
|
29
23
|
function SortIcon(_ref) {
|
|
30
24
|
var _ref$size = _ref.size,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
size = _ref$size === void 0 ? 32 : _ref$size,
|
|
26
|
+
style = _ref.style,
|
|
27
|
+
className = _ref.className,
|
|
28
|
+
order = _ref.order;
|
|
35
29
|
return /*#__PURE__*/React.createElement("svg", {
|
|
36
30
|
style: style,
|
|
37
31
|
className: className,
|
|
@@ -52,16 +46,14 @@ function SortIcon(_ref) {
|
|
|
52
46
|
d: "M24 24L16 32 8 24z "
|
|
53
47
|
}));
|
|
54
48
|
}
|
|
55
|
-
|
|
56
49
|
function DefaultSortHeaderCell(_ref2) {
|
|
57
50
|
var _cx;
|
|
58
|
-
|
|
59
51
|
var children = _ref2.children,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
52
|
+
column = _ref2.column,
|
|
53
|
+
onToggle = _ref2.onToggle,
|
|
54
|
+
sortOrder = _ref2.sortOrder,
|
|
55
|
+
sortIndex = _ref2.sortIndex,
|
|
56
|
+
sortOptions = _ref2.sortOptions;
|
|
65
57
|
// 通过 justify-content 来与 col.align 保持对齐方向一致
|
|
66
58
|
var justifyContent = column.align === 'right' ? 'flex-end' : column.align === 'center' ? 'center' : 'flex-start';
|
|
67
59
|
return /*#__PURE__*/React.createElement(TableHeaderCell, {
|
|
@@ -89,48 +81,39 @@ function DefaultSortHeaderCell(_ref2) {
|
|
|
89
81
|
}
|
|
90
82
|
}, sortIndex + 1));
|
|
91
83
|
}
|
|
92
|
-
|
|
93
84
|
function hasAnySortableColumns(cols) {
|
|
94
85
|
return cols.some(function (col) {
|
|
95
86
|
var _a;
|
|
96
|
-
|
|
97
87
|
return Boolean((_a = col.features) === null || _a === void 0 ? void 0 : _a.sortable) || !isLeafNode(col) && hasAnySortableColumns(col.children);
|
|
98
88
|
});
|
|
99
89
|
}
|
|
100
|
-
|
|
101
90
|
var TableHeaderCell = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n cursor: pointer;\n display: flex;\n align-items: center;\n // flex: auto;\n"])));
|
|
102
91
|
var stateKey = 'sort';
|
|
103
92
|
export function sort() {
|
|
104
93
|
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
105
94
|
return function sortStep(pipeline) {
|
|
106
95
|
var _a, _b, _c;
|
|
107
|
-
|
|
108
96
|
var _opts$orders = opts.orders,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
97
|
+
orders = _opts$orders === void 0 ? ['desc', 'asc', 'none'] : _opts$orders,
|
|
98
|
+
_opts$mode = opts.mode,
|
|
99
|
+
mode = _opts$mode === void 0 ? 'multiple' : _opts$mode,
|
|
100
|
+
_opts$SortHeaderCell = opts.SortHeaderCell,
|
|
101
|
+
SortHeaderCell = _opts$SortHeaderCell === void 0 ? DefaultSortHeaderCell : _opts$SortHeaderCell,
|
|
102
|
+
keepDataSource = opts.keepDataSource,
|
|
103
|
+
highlightColumnWhenActive = opts.highlightColumnWhenActive,
|
|
104
|
+
stopClickEventPropagation = opts.stopClickEventPropagation,
|
|
105
|
+
sortIconHoverShow = opts.sortIconHoverShow;
|
|
118
106
|
var inputSorts = (_c = (_b = (_a = opts.sorts) !== null && _a !== void 0 ? _a : pipeline.getStateAtKey(stateKey)) !== null && _b !== void 0 ? _b : opts.defaultSorts) !== null && _c !== void 0 ? _c : [];
|
|
119
|
-
|
|
120
107
|
var activeSorts = _filterInstanceProperty(inputSorts).call(inputSorts, function (s) {
|
|
121
108
|
return s.order !== 'none';
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
|
|
109
|
+
});
|
|
110
|
+
// 单字段排序的情况下 sorts 中只有第一个排序字段才会生效
|
|
125
111
|
var sorts = mode === 'multiple' ? activeSorts : _sliceInstanceProperty(activeSorts).call(activeSorts, 0, 1);
|
|
126
|
-
|
|
127
112
|
var onChangeSortsInMultipleMode = function onChangeSortsInMultipleMode(nextSorts, currentSort) {
|
|
128
113
|
var _a;
|
|
129
|
-
|
|
130
114
|
(_a = opts.onChangeSorts) === null || _a === void 0 ? void 0 : _a.call(opts, nextSorts, currentSort);
|
|
131
115
|
pipeline.setStateAtKey(stateKey, nextSorts);
|
|
132
116
|
};
|
|
133
|
-
|
|
134
117
|
var onChangeSorts = mode === 'multiple' ? onChangeSortsInMultipleMode : function (nextSorts, currentSort) {
|
|
135
118
|
// 单字段排序的情况下,nextSorts 中只有最后一个排序字段才会生效
|
|
136
119
|
var len = nextSorts.length;
|
|
@@ -153,56 +136,41 @@ export function sort() {
|
|
|
153
136
|
}));
|
|
154
137
|
var dataSource = pipeline.getDataSource();
|
|
155
138
|
var columns = pipeline.getColumns();
|
|
156
|
-
|
|
157
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
158
|
-
if (!hasAnySortableColumns(columns)) {
|
|
159
|
-
console.warn('commonTransform.sort 缺少可排序的列,请通过 column.features.sortable 来指定哪些列可排序', columns);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
139
|
pipeline.dataSource(processDataSource(dataSource));
|
|
164
140
|
pipeline.columns(processColumns(columns));
|
|
165
141
|
return pipeline;
|
|
166
|
-
|
|
167
142
|
function processDataSource(dataSource) {
|
|
168
143
|
var _context, _context2;
|
|
169
|
-
|
|
170
144
|
if (keepDataSource) {
|
|
171
145
|
return dataSource;
|
|
172
146
|
}
|
|
173
|
-
|
|
174
147
|
if (sortMap.size === 0) {
|
|
175
148
|
return dataSource;
|
|
176
149
|
}
|
|
177
|
-
|
|
178
150
|
var sortColumnsMap = new _Map(_mapInstanceProperty(_context = _filterInstanceProperty(_context2 = collectNodes(columns, 'leaf-only')).call(_context2, function (col) {
|
|
179
151
|
var _a, _b;
|
|
180
|
-
|
|
181
152
|
return ((_a = col.features) === null || _a === void 0 ? void 0 : _a.sortable) !== false && ((_b = col.features) === null || _b === void 0 ? void 0 : _b.sortable) != null;
|
|
182
153
|
})).call(_context, function (col) {
|
|
183
154
|
return [col.code, col];
|
|
184
155
|
}));
|
|
185
156
|
return layeredSort(dataSource, function (x, y) {
|
|
186
157
|
var _iterator = _createForOfIteratorHelper(sorts),
|
|
187
|
-
|
|
188
|
-
|
|
158
|
+
_step;
|
|
189
159
|
try {
|
|
190
160
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
191
161
|
var _step$value = _step.value,
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
var column = sortColumnsMap.get(code);
|
|
195
|
-
|
|
162
|
+
code = _step$value.code,
|
|
163
|
+
order = _step$value.order;
|
|
164
|
+
var column = sortColumnsMap.get(code);
|
|
165
|
+
// 如果 code 对应的 column 不可排序,我们跳过该 code
|
|
196
166
|
if (column == null) {
|
|
197
167
|
continue;
|
|
198
168
|
}
|
|
199
|
-
|
|
200
169
|
var sortable = column.features.sortable;
|
|
201
170
|
var compareFn = typeof sortable === 'function' ? sortable : smartCompare;
|
|
202
171
|
var xValue = internals.safeGetValue(column, x, -1);
|
|
203
172
|
var yValue = internals.safeGetValue(column, y, -1);
|
|
204
173
|
var cmp = compareFn(xValue, yValue, x, y);
|
|
205
|
-
|
|
206
174
|
if (cmp !== 0) {
|
|
207
175
|
return cmp * (order === 'asc' ? 1 : -1);
|
|
208
176
|
}
|
|
@@ -212,16 +180,13 @@ export function sort() {
|
|
|
212
180
|
} finally {
|
|
213
181
|
_iterator.f();
|
|
214
182
|
}
|
|
215
|
-
|
|
216
183
|
return 0;
|
|
217
184
|
});
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
|
|
185
|
+
}
|
|
186
|
+
// 在「升序 - 降序 - 不排序」之间不断切换
|
|
221
187
|
function toggle(code) {
|
|
222
188
|
var sort = sortMap.get(code);
|
|
223
189
|
var currentSort;
|
|
224
|
-
|
|
225
190
|
if (sort == null) {
|
|
226
191
|
currentSort = {
|
|
227
192
|
code: code,
|
|
@@ -232,15 +197,12 @@ export function sort() {
|
|
|
232
197
|
var index = _findIndexInstanceProperty(sorts).call(sorts, function (s) {
|
|
233
198
|
return s.code === code;
|
|
234
199
|
});
|
|
235
|
-
|
|
236
200
|
var nextSorts = _sliceInstanceProperty(sorts).call(sorts, 0, index + 1);
|
|
237
|
-
|
|
238
201
|
var nextOrder = getNextOrder(sort.order);
|
|
239
202
|
currentSort = {
|
|
240
203
|
code: code,
|
|
241
204
|
order: nextOrder
|
|
242
205
|
};
|
|
243
|
-
|
|
244
206
|
if (nextOrder === 'none') {
|
|
245
207
|
nextSorts.pop();
|
|
246
208
|
} else {
|
|
@@ -248,41 +210,31 @@ export function sort() {
|
|
|
248
210
|
order: nextOrder
|
|
249
211
|
});
|
|
250
212
|
}
|
|
251
|
-
|
|
252
213
|
onChangeSorts(nextSorts, currentSort);
|
|
253
214
|
}
|
|
254
215
|
}
|
|
255
|
-
|
|
256
216
|
function processColumns(columns) {
|
|
257
217
|
return _mapInstanceProperty(columns).call(columns, dfs);
|
|
258
|
-
|
|
259
218
|
function dfs(col) {
|
|
260
219
|
var _a;
|
|
261
|
-
|
|
262
220
|
var result = _extends({}, col);
|
|
263
|
-
|
|
264
221
|
var sortable = col.code && (((_a = col.features) === null || _a === void 0 ? void 0 : _a.sortable) || sortMap.has(col.code));
|
|
265
222
|
var active = sortable && sortMap.has(col.code);
|
|
266
|
-
|
|
267
223
|
if (sortable) {
|
|
268
224
|
var sortIndex = -1;
|
|
269
225
|
var sortOrder = 'none';
|
|
270
|
-
|
|
271
226
|
if (active) {
|
|
272
227
|
var _sortMap$get = sortMap.get(col.code),
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
228
|
+
order = _sortMap$get.order,
|
|
229
|
+
index = _sortMap$get.index;
|
|
276
230
|
sortOrder = order;
|
|
277
231
|
sortIndex = index;
|
|
278
|
-
|
|
279
232
|
if (highlightColumnWhenActive) {
|
|
280
233
|
result.headerCellProps = mergeCellProps(col.headerCellProps, {
|
|
281
234
|
style: {
|
|
282
235
|
background: 'var(--header-highlight-bgcolor)'
|
|
283
236
|
}
|
|
284
237
|
});
|
|
285
|
-
|
|
286
238
|
result.getCellProps = function (value, row, rowIndex) {
|
|
287
239
|
var prevCellProps = internals.safeGetCellProps(col, row, rowIndex);
|
|
288
240
|
return mergeCellProps(prevCellProps, {
|
|
@@ -293,13 +245,11 @@ export function sort() {
|
|
|
293
245
|
};
|
|
294
246
|
}
|
|
295
247
|
}
|
|
296
|
-
|
|
297
248
|
var sortNode = /*#__PURE__*/React.createElement(SortHeaderCell, {
|
|
298
249
|
onToggle: function onToggle(e) {
|
|
299
250
|
if (stopClickEventPropagation) {
|
|
300
251
|
e.stopPropagation();
|
|
301
252
|
}
|
|
302
|
-
|
|
303
253
|
toggle(col.code);
|
|
304
254
|
},
|
|
305
255
|
sortOrder: sortOrder,
|
|
@@ -309,22 +259,19 @@ export function sort() {
|
|
|
309
259
|
}, internals.safeRenderHeader(_extends(_extends({}, col), {
|
|
310
260
|
title: col.title && col.title[0] ? col.title[0] : col.title
|
|
311
261
|
})));
|
|
312
|
-
|
|
313
262
|
var _sortNodeWithoutTitle = /*#__PURE__*/React.createElement(SortHeaderCell, {
|
|
314
263
|
onToggle: function onToggle(e) {
|
|
315
264
|
if (stopClickEventPropagation) {
|
|
316
265
|
e.stopPropagation();
|
|
317
266
|
}
|
|
318
|
-
|
|
319
267
|
toggle(col.code);
|
|
320
268
|
},
|
|
321
269
|
sortOrder: sortOrder,
|
|
322
270
|
column: col,
|
|
323
271
|
sortIndex: sortIndex,
|
|
324
272
|
sortOptions: sortOptions
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
|
|
273
|
+
});
|
|
274
|
+
// 开启标题行高自适应后,修改表头的渲染结构
|
|
328
275
|
if (col.renderHeader) {
|
|
329
276
|
result.title = col.renderHeader(result.title, _sortNodeWithoutTitle);
|
|
330
277
|
} else {
|
|
@@ -335,17 +282,13 @@ export function sort() {
|
|
|
335
282
|
}
|
|
336
283
|
}
|
|
337
284
|
}
|
|
338
|
-
|
|
339
285
|
if (!isLeafNode(col)) {
|
|
340
286
|
var _context3;
|
|
341
|
-
|
|
342
287
|
result.children = _mapInstanceProperty(_context3 = col.children).call(_context3, dfs);
|
|
343
288
|
}
|
|
344
|
-
|
|
345
289
|
return result;
|
|
346
290
|
}
|
|
347
291
|
}
|
|
348
|
-
|
|
349
292
|
function getNextOrder(order) {
|
|
350
293
|
var idx = orders.indexOf(order);
|
|
351
294
|
return orders[idx === orders.length - 1 ? 0 : idx + 1];
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
2
2
|
import _taggedTemplateLiteral from "@babel/runtime-corejs3/helpers/taggedTemplateLiteral";
|
|
3
|
-
|
|
4
3
|
var _templateObject;
|
|
5
|
-
|
|
6
4
|
import React from 'react';
|
|
7
5
|
import styled from 'styled-components';
|
|
8
6
|
import { icons } from '../../common-views';
|
|
@@ -13,18 +11,14 @@ export function tips() {
|
|
|
13
11
|
return function tipsSteap(pipeline) {
|
|
14
12
|
var Balloon = pipeline.ctx.components.Balloon;
|
|
15
13
|
var Tooltip = pipeline.ctx.components.Tooltip;
|
|
16
|
-
|
|
17
14
|
if (Balloon == null && Tooltip == null) {
|
|
18
15
|
throw new Error('使用 tips 之前需要通过 pipeline context 设置 components.Balloon / components.Tooltip');
|
|
19
16
|
}
|
|
20
|
-
|
|
21
17
|
return pipeline.mapColumns(makeRecursiveMapper(function (col) {
|
|
22
18
|
var _a;
|
|
23
|
-
|
|
24
19
|
if (!((_a = col.features) === null || _a === void 0 ? void 0 : _a.tips)) {
|
|
25
20
|
return col;
|
|
26
21
|
}
|
|
27
|
-
|
|
28
22
|
var justifyContent = col.align === 'right' ? 'flex-end' : col.align === 'center' ? 'center' : 'flex-start';
|
|
29
23
|
return _extends(_extends({}, col), {
|
|
30
24
|
title: /*#__PURE__*/React.createElement(HeaderCellWithTips, {
|
|
@@ -4,13 +4,9 @@ import _getIteratorMethod from "@babel/runtime-corejs3/core-js/get-iterator-meth
|
|
|
4
4
|
import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
5
5
|
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
6
6
|
import _toConsumableArray from "@babel/runtime-corejs3/helpers/toConsumableArray";
|
|
7
|
-
|
|
8
7
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
9
|
-
|
|
10
8
|
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
9
|
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
|
-
|
|
14
10
|
import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
|
|
15
11
|
import _Set from "@babel/runtime-corejs3/core-js-stable/set";
|
|
16
12
|
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
@@ -27,66 +23,57 @@ export function treeMode() {
|
|
|
27
23
|
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
28
24
|
return function treeModeStep(pipeline) {
|
|
29
25
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
30
|
-
|
|
31
26
|
var stateKey = 'treeMode';
|
|
32
27
|
var ctx = pipeline.ctx;
|
|
33
28
|
var primaryKey = pipeline.ensurePrimaryKey('treeMode');
|
|
34
29
|
var openKeys = (_c = (_b = (_a = opts.openKeys) !== null && _a !== void 0 ? _a : pipeline.getStateAtKey(stateKey)) !== null && _b !== void 0 ? _b : opts.defaultOpenKeys) !== null && _c !== void 0 ? _c : [];
|
|
30
|
+
var curSort = pipeline.getStateAtKey('sort');
|
|
35
31
|
var openKeySet = new _Set(openKeys);
|
|
36
|
-
|
|
37
32
|
var onChangeOpenKeys = function onChangeOpenKeys(nextKeys, key, action) {
|
|
38
33
|
var _a;
|
|
39
|
-
|
|
40
34
|
(_a = opts.onChangeOpenKeys) === null || _a === void 0 ? void 0 : _a.call(opts, nextKeys, key, action);
|
|
41
35
|
pipeline.setStateAtKey(stateKey, nextKeys, {
|
|
42
36
|
key: key,
|
|
43
37
|
action: action
|
|
44
38
|
});
|
|
45
39
|
};
|
|
46
|
-
|
|
47
40
|
var toggle = function toggle(rowKey) {
|
|
48
41
|
var expanded = openKeySet.has(rowKey);
|
|
49
|
-
|
|
50
42
|
if (expanded) {
|
|
51
43
|
onChangeOpenKeys(_filterInstanceProperty(openKeys).call(openKeys, function (key) {
|
|
52
44
|
return key !== rowKey;
|
|
53
45
|
}), rowKey, 'collapse');
|
|
54
46
|
} else {
|
|
55
47
|
var _context;
|
|
56
|
-
|
|
57
48
|
onChangeOpenKeys(_concatInstanceProperty(_context = []).call(_context, _toConsumableArray(openKeys), [rowKey]), rowKey, 'expand');
|
|
58
49
|
}
|
|
59
50
|
};
|
|
60
|
-
|
|
61
51
|
var isLeafNode = (_d = opts.isLeafNode) !== null && _d !== void 0 ? _d : standardIsLeafNode;
|
|
62
52
|
var clickArea = (_e = opts.clickArea) !== null && _e !== void 0 ? _e : 'cell';
|
|
63
53
|
var treeMetaKey = (_f = opts.treeMetaKey) !== null && _f !== void 0 ? _f : treeMetaSymbol;
|
|
64
|
-
var stopClickEventPropagation = Boolean(opts.stopClickEventPropagation);
|
|
65
|
-
|
|
54
|
+
var stopClickEventPropagation = Boolean(opts.stopClickEventPropagation);
|
|
55
|
+
// indents
|
|
66
56
|
var iconWidth = ctx.indents.iconWidth;
|
|
67
57
|
var iconIndent = (_g = opts.iconIndent) !== null && _g !== void 0 ? _g : ctx.indents.iconIndent;
|
|
68
58
|
var iconGap = (_h = opts.iconGap) !== null && _h !== void 0 ? _h : ctx.indents.iconGap;
|
|
69
59
|
var indentSize = (_j = opts.indentSize) !== null && _j !== void 0 ? _j : ctx.indents.indentSize;
|
|
70
60
|
var Icon = opts.icon;
|
|
71
61
|
return pipeline.mapDataSource(processDataSource).mapColumns(processColumns);
|
|
72
|
-
|
|
73
62
|
function processDataSource(input) {
|
|
74
|
-
if (pipeline.isSameInputDataSource() && openKeys === pipeline.getFeatureOptions('lastOpenKeys')) {
|
|
63
|
+
if (pipeline.isSameInputDataSource() && openKeys === pipeline.getFeatureOptions('lastOpenKeys') && curSort === pipeline.getFeatureOptions('lastSort')) {
|
|
75
64
|
return pipeline.getFeatureOptions('lastTreeMode');
|
|
76
65
|
}
|
|
77
|
-
|
|
78
|
-
pipeline.setFeatureOptions('
|
|
66
|
+
pipeline.setFeatureOptions('lastOpenKeys', openKeys);
|
|
67
|
+
pipeline.setFeatureOptions('lastSort', curSort);
|
|
79
68
|
var result = [];
|
|
80
69
|
dfs(input, 0);
|
|
81
|
-
|
|
82
70
|
function dfs(nodes, depth) {
|
|
71
|
+
var parentNode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
83
72
|
if (nodes == null) {
|
|
84
73
|
return;
|
|
85
74
|
}
|
|
86
|
-
|
|
87
75
|
var _iterator = _createForOfIteratorHelper(nodes),
|
|
88
|
-
|
|
89
|
-
|
|
76
|
+
_step;
|
|
90
77
|
try {
|
|
91
78
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
92
79
|
var node = _step.value;
|
|
@@ -104,7 +91,6 @@ export function treeMode() {
|
|
|
104
91
|
rowKey: rowKey
|
|
105
92
|
};
|
|
106
93
|
result.push(_extends(_defineProperty({}, treeMetaKey, treeMeta), node));
|
|
107
|
-
|
|
108
94
|
if (!isLeaf && expanded) {
|
|
109
95
|
dfs(node.children, depth + 1);
|
|
110
96
|
}
|
|
@@ -115,39 +101,31 @@ export function treeMode() {
|
|
|
115
101
|
_iterator.f();
|
|
116
102
|
}
|
|
117
103
|
}
|
|
118
|
-
|
|
119
104
|
pipeline.setFeatureOptions('lastTreeMode', result);
|
|
120
105
|
return result;
|
|
121
106
|
}
|
|
122
|
-
|
|
123
107
|
function processColumns(columns) {
|
|
124
108
|
if (columns.length === 0) {
|
|
125
109
|
return columns;
|
|
126
110
|
}
|
|
127
|
-
|
|
128
111
|
var expandColIndex = _findIndexInstanceProperty(columns).call(columns, function (_ref) {
|
|
129
112
|
var code = _ref.code;
|
|
130
113
|
return code && opts.expandColCode === code;
|
|
131
114
|
});
|
|
132
|
-
|
|
133
115
|
expandColIndex = expandColIndex === -1 ? 0 : expandColIndex;
|
|
134
116
|
var expandCol = columns[expandColIndex];
|
|
135
|
-
|
|
136
117
|
var render = function render(value, record, recordIndex) {
|
|
137
118
|
var content = internals.safeRender(expandCol, record, recordIndex);
|
|
138
|
-
|
|
139
119
|
if (record[treeMetaKey] == null) {
|
|
140
120
|
// 没有 treeMeta 信息的话,就返回原先的渲染结果
|
|
141
121
|
return content;
|
|
142
122
|
}
|
|
143
|
-
|
|
144
123
|
var _record$treeMetaKey = record[treeMetaKey],
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
124
|
+
rowKey = _record$treeMetaKey.rowKey,
|
|
125
|
+
depth = _record$treeMetaKey.depth,
|
|
126
|
+
isLeaf = _record$treeMetaKey.isLeaf,
|
|
127
|
+
expanded = _record$treeMetaKey.expanded;
|
|
149
128
|
var indent = iconIndent + depth * indentSize;
|
|
150
|
-
|
|
151
129
|
if (isLeaf) {
|
|
152
130
|
return /*#__PURE__*/React.createElement(InlineFlexCell, {
|
|
153
131
|
className: cx('expansion-cell', Classes.leaf)
|
|
@@ -157,15 +135,12 @@ export function treeMode() {
|
|
|
157
135
|
}
|
|
158
136
|
}, content));
|
|
159
137
|
}
|
|
160
|
-
|
|
161
138
|
var onClick = function onClick(e) {
|
|
162
139
|
if (stopClickEventPropagation) {
|
|
163
140
|
e.stopPropagation();
|
|
164
141
|
}
|
|
165
|
-
|
|
166
142
|
toggle(rowKey);
|
|
167
143
|
};
|
|
168
|
-
|
|
169
144
|
var expandCls = expanded ? Classes.expanded : Classes.collapsed;
|
|
170
145
|
return /*#__PURE__*/React.createElement(ExpansionCell, {
|
|
171
146
|
className: cx('expansion-cell', expandCls),
|
|
@@ -192,29 +167,23 @@ export function treeMode() {
|
|
|
192
167
|
onClick: clickArea === 'icon' ? onClick : undefined
|
|
193
168
|
}), content);
|
|
194
169
|
};
|
|
195
|
-
|
|
196
170
|
var getCellProps = function getCellProps(value, record, rowIndex) {
|
|
197
171
|
var prevProps = internals.safeGetCellProps(expandCol, record, rowIndex);
|
|
198
|
-
|
|
199
172
|
if (record[treeMetaKey] == null) {
|
|
200
173
|
// 没有 treeMeta 信息的话,就返回原先的 cellProps
|
|
201
174
|
return prevProps;
|
|
202
175
|
}
|
|
203
|
-
|
|
204
176
|
var _record$treeMetaKey2 = record[treeMetaKey],
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
177
|
+
isLeaf = _record$treeMetaKey2.isLeaf,
|
|
178
|
+
rowKey = _record$treeMetaKey2.rowKey;
|
|
208
179
|
if (isLeaf) {
|
|
209
180
|
return prevProps;
|
|
210
181
|
}
|
|
211
|
-
|
|
212
182
|
return mergeCellProps(prevProps, {
|
|
213
183
|
onClick: function onClick(e) {
|
|
214
184
|
if (stopClickEventPropagation) {
|
|
215
185
|
e.stopPropagation();
|
|
216
186
|
}
|
|
217
|
-
|
|
218
187
|
toggle(rowKey);
|
|
219
188
|
},
|
|
220
189
|
style: {
|
|
@@ -222,7 +191,6 @@ export function treeMode() {
|
|
|
222
191
|
}
|
|
223
192
|
});
|
|
224
193
|
};
|
|
225
|
-
|
|
226
194
|
columns[expandColIndex] = _extends(_extends({}, expandCol), {
|
|
227
195
|
title: /*#__PURE__*/React.createElement("span", {
|
|
228
196
|
style: {
|
|
@@ -9,31 +9,23 @@ var STATE_KEY = 'treeSelect';
|
|
|
9
9
|
export function treeSelect(opts) {
|
|
10
10
|
return function treeSelectStep(pipeline) {
|
|
11
11
|
var _ref, _context;
|
|
12
|
-
|
|
13
12
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
14
|
-
|
|
15
13
|
var Checkbox = pipeline.ctx.components.Checkbox;
|
|
16
|
-
|
|
17
14
|
if (Checkbox == null) {
|
|
18
15
|
throw new Error('使用 treeSelect 之前需要通过 pipeline context 设置 components.Checkbox');
|
|
19
16
|
}
|
|
20
|
-
|
|
21
17
|
var primaryKey = pipeline.ensurePrimaryKey('treeSelect');
|
|
22
|
-
|
|
23
18
|
if (typeof primaryKey !== 'string') {
|
|
24
19
|
throw new Error('treeSelect 仅支持字符串作为 primaryKey');
|
|
25
20
|
}
|
|
26
|
-
|
|
27
21
|
var clickArea = (_a = opts.clickArea) !== null && _a !== void 0 ? _a : 'checkbox';
|
|
28
22
|
var isDisabled = (_b = opts.isDisabled) !== null && _b !== void 0 ? _b : always(false);
|
|
29
23
|
var isDetached = (_c = opts.idDetached) !== null && _c !== void 0 ? _c : always(false);
|
|
30
24
|
var value = (_f = (_e = (_d = opts.value) !== null && _d !== void 0 ? _d : pipeline.getStateAtKey(STATE_KEY)) !== null && _e !== void 0 ? _e : opts.defaultValue) !== null && _f !== void 0 ? _f : [];
|
|
31
25
|
var tree = opts.rootKey != null ? [(_ref = {}, _defineProperty(_ref, primaryKey, opts.rootKey), _defineProperty(_ref, "children", opts.tree), _ref)] : opts.tree;
|
|
32
|
-
|
|
33
26
|
var getNodeValue = function getNodeValue(node) {
|
|
34
27
|
return node[primaryKey];
|
|
35
28
|
};
|
|
36
|
-
|
|
37
29
|
var treeDataHelper = opts.checkStrictly ? new StrictTreeDataHelper({
|
|
38
30
|
value: value,
|
|
39
31
|
getNodeValue: getNodeValue,
|
|
@@ -45,15 +37,12 @@ export function treeSelect(opts) {
|
|
|
45
37
|
tree: tree,
|
|
46
38
|
checkedStrategy: (_g = opts.checkedStrategy) !== null && _g !== void 0 ? _g : 'parent'
|
|
47
39
|
});
|
|
48
|
-
|
|
49
40
|
var onToggleKey = function onToggleKey(key) {
|
|
50
41
|
var _a;
|
|
51
|
-
|
|
52
42
|
var nextValue = treeDataHelper.getValueAfterToggle(key);
|
|
53
43
|
pipeline.setStateAtKey(STATE_KEY, nextValue);
|
|
54
44
|
(_a = opts.onChange) === null || _a === void 0 ? void 0 : _a.call(opts, nextValue);
|
|
55
45
|
};
|
|
56
|
-
|
|
57
46
|
var makeCheckbox = function makeCheckbox(key, root, row) {
|
|
58
47
|
return /*#__PURE__*/React.createElement(Checkbox, {
|
|
59
48
|
checked: treeDataHelper.isChecked(key),
|
|
@@ -64,7 +53,6 @@ export function treeSelect(opts) {
|
|
|
64
53
|
} : undefined
|
|
65
54
|
});
|
|
66
55
|
};
|
|
67
|
-
|
|
68
56
|
var checkboxColumn = _extends(_extends({
|
|
69
57
|
name: '',
|
|
70
58
|
width: 50,
|
|
@@ -76,13 +64,10 @@ export function treeSelect(opts) {
|
|
|
76
64
|
},
|
|
77
65
|
getCellProps: function getCellProps(value, row) {
|
|
78
66
|
var rowKey = row[primaryKey];
|
|
79
|
-
|
|
80
67
|
if (clickArea !== 'cell') {
|
|
81
68
|
return;
|
|
82
69
|
}
|
|
83
|
-
|
|
84
70
|
var disabled = isDisabled(row);
|
|
85
|
-
|
|
86
71
|
if (disabled) {
|
|
87
72
|
return {
|
|
88
73
|
style: {
|
|
@@ -90,7 +75,6 @@ export function treeSelect(opts) {
|
|
|
90
75
|
}
|
|
91
76
|
};
|
|
92
77
|
}
|
|
93
|
-
|
|
94
78
|
return {
|
|
95
79
|
style: {
|
|
96
80
|
cursor: 'pointer'
|
|
@@ -99,29 +83,22 @@ export function treeSelect(opts) {
|
|
|
99
83
|
if (opts.stopClickEventPropagation) {
|
|
100
84
|
e.stopPropagation();
|
|
101
85
|
}
|
|
102
|
-
|
|
103
86
|
onToggleKey(rowKey);
|
|
104
87
|
}
|
|
105
88
|
};
|
|
106
89
|
}
|
|
107
90
|
});
|
|
108
|
-
|
|
109
91
|
var nextColumns = _sliceInstanceProperty(_context = pipeline.getColumns()).call(_context);
|
|
110
|
-
|
|
111
92
|
var checkboxPlacement = (_h = opts.checkboxPlacement) !== null && _h !== void 0 ? _h : 'start';
|
|
112
|
-
|
|
113
93
|
if (checkboxPlacement === 'start') {
|
|
114
94
|
nextColumns.unshift(checkboxColumn);
|
|
115
95
|
} else {
|
|
116
96
|
nextColumns.push(checkboxColumn);
|
|
117
97
|
}
|
|
118
|
-
|
|
119
98
|
pipeline.columns(nextColumns);
|
|
120
|
-
|
|
121
99
|
if (clickArea === 'row') {
|
|
122
100
|
pipeline.appendRowPropsGetter(function (row) {
|
|
123
101
|
var disabled = isDisabled(row);
|
|
124
|
-
|
|
125
102
|
if (!disabled) {
|
|
126
103
|
return {
|
|
127
104
|
style: {
|
|
@@ -131,14 +108,12 @@ export function treeSelect(opts) {
|
|
|
131
108
|
if (opts.stopClickEventPropagation) {
|
|
132
109
|
e.stopPropagation();
|
|
133
110
|
}
|
|
134
|
-
|
|
135
111
|
onToggleKey(row[primaryKey]);
|
|
136
112
|
}
|
|
137
113
|
};
|
|
138
114
|
}
|
|
139
115
|
});
|
|
140
116
|
}
|
|
141
|
-
|
|
142
117
|
if (opts.highlightRowWhenSelected) {
|
|
143
118
|
pipeline.appendRowPropsGetter(function (row) {
|
|
144
119
|
if (treeDataHelper.isChecked(row[primaryKey])) {
|
|
@@ -148,7 +123,6 @@ export function treeSelect(opts) {
|
|
|
148
123
|
}
|
|
149
124
|
});
|
|
150
125
|
}
|
|
151
|
-
|
|
152
126
|
return pipeline;
|
|
153
127
|
};
|
|
154
128
|
}
|