@kdcloudjs/table 1.2.0-canary.6 → 1.2.0-canary.6-hotfix.2
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 +1877 -3363
- 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/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 +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/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 +22 -72
- package/es/table/base/colgroup.js +0 -1
- package/es/table/base/empty.js +4 -4
- package/es/table/base/header.d.ts +2 -1
- package/es/table/base/header.js +17 -68
- package/es/table/base/helpers/SpanManager.js +3 -9
- package/es/table/base/helpers/TableDOMUtils.js +3 -26
- 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 +11 -44
- package/es/table/base/helpers/rowHeightManager.js +0 -28
- package/es/table/base/html-table.js +15 -36
- package/es/table/base/loading.js +6 -8
- package/es/table/base/renderTemplates.js +50 -54
- package/es/table/base/styles.js +1 -10
- package/es/table/base/table.js +116 -189
- 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 -38
- 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 -95
- package/es/table/pipeline/features/columnFilter.js +11 -44
- 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/rowGrouping.js +2 -35
- package/es/table/pipeline/features/singleSelect.js +0 -24
- package/es/table/pipeline/features/sort.js +29 -79
- package/es/table/pipeline/features/tips.js +0 -6
- package/es/table/pipeline/features/treeMode.js +9 -43
- package/es/table/pipeline/features/treeSelect.js +0 -26
- package/es/table/pipeline/pipeline.js +9 -49
- 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/style/index.less +1 -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 -88
- 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/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/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/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 +22 -83
- package/lib/table/base/colgroup.js +0 -5
- package/lib/table/base/empty.js +4 -16
- package/lib/table/base/header.d.ts +2 -1
- package/lib/table/base/header.js +17 -78
- package/lib/table/base/helpers/SpanManager.js +3 -11
- package/lib/table/base/helpers/TableDOMUtils.js +1 -26
- 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 +11 -62
- package/lib/table/base/helpers/rowHeightManager.js +0 -33
- package/lib/table/base/html-table.js +15 -46
- package/lib/table/base/index.js +0 -2
- package/lib/table/base/loading.js +6 -12
- package/lib/table/base/renderTemplates.js +51 -68
- package/lib/table/base/styles.js +1 -22
- package/lib/table/base/table.js +116 -222
- 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 -45
- 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 -101
- package/lib/table/pipeline/features/columnFilter.js +11 -58
- 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 -22
- package/lib/table/pipeline/features/mergeCellHover.js +0 -5
- package/lib/table/pipeline/features/multiSelect.js +15 -70
- package/lib/table/pipeline/features/rangeSelection.js +63 -159
- package/lib/table/pipeline/features/rowDetail.js +2 -65
- package/lib/table/pipeline/features/rowGrouping.js +2 -55
- package/lib/table/pipeline/features/singleSelect.js +0 -33
- package/lib/table/pipeline/features/sort.js +29 -99
- package/lib/table/pipeline/features/tips.js +0 -15
- package/lib/table/pipeline/features/treeMode.js +9 -64
- package/lib/table/pipeline/features/treeSelect.js +0 -34
- package/lib/table/pipeline/index.js +0 -8
- package/lib/table/pipeline/pipeline.js +9 -58
- 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/style/index.less +1 -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 -112
- 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/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 -20
- 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/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/package.json +219 -218
|
@@ -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,61 +23,50 @@ 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 : [];
|
|
35
30
|
var openKeySet = new _Set(openKeys);
|
|
36
|
-
|
|
37
31
|
var onChangeOpenKeys = function onChangeOpenKeys(nextKeys, key, action) {
|
|
38
32
|
var _a;
|
|
39
|
-
|
|
40
33
|
(_a = opts.onChangeOpenKeys) === null || _a === void 0 ? void 0 : _a.call(opts, nextKeys, key, action);
|
|
41
34
|
pipeline.setStateAtKey(stateKey, nextKeys, {
|
|
42
35
|
key: key,
|
|
43
36
|
action: action
|
|
44
37
|
});
|
|
45
38
|
};
|
|
46
|
-
|
|
47
39
|
var toggle = function toggle(rowKey) {
|
|
48
40
|
var expanded = openKeySet.has(rowKey);
|
|
49
|
-
|
|
50
41
|
if (expanded) {
|
|
51
42
|
onChangeOpenKeys(_filterInstanceProperty(openKeys).call(openKeys, function (key) {
|
|
52
43
|
return key !== rowKey;
|
|
53
44
|
}), rowKey, 'collapse');
|
|
54
45
|
} else {
|
|
55
46
|
var _context;
|
|
56
|
-
|
|
57
47
|
onChangeOpenKeys(_concatInstanceProperty(_context = []).call(_context, _toConsumableArray(openKeys), [rowKey]), rowKey, 'expand');
|
|
58
48
|
}
|
|
59
49
|
};
|
|
60
|
-
|
|
61
50
|
var isLeafNode = (_d = opts.isLeafNode) !== null && _d !== void 0 ? _d : standardIsLeafNode;
|
|
62
51
|
var clickArea = (_e = opts.clickArea) !== null && _e !== void 0 ? _e : 'cell';
|
|
63
52
|
var treeMetaKey = (_f = opts.treeMetaKey) !== null && _f !== void 0 ? _f : treeMetaSymbol;
|
|
64
|
-
var stopClickEventPropagation = Boolean(opts.stopClickEventPropagation);
|
|
65
|
-
|
|
53
|
+
var stopClickEventPropagation = Boolean(opts.stopClickEventPropagation);
|
|
54
|
+
// indents
|
|
66
55
|
var iconWidth = ctx.indents.iconWidth;
|
|
67
56
|
var iconIndent = (_g = opts.iconIndent) !== null && _g !== void 0 ? _g : ctx.indents.iconIndent;
|
|
68
57
|
var iconGap = (_h = opts.iconGap) !== null && _h !== void 0 ? _h : ctx.indents.iconGap;
|
|
69
58
|
var indentSize = (_j = opts.indentSize) !== null && _j !== void 0 ? _j : ctx.indents.indentSize;
|
|
70
59
|
var Icon = opts.icon;
|
|
71
60
|
return pipeline.mapDataSource(processDataSource).mapColumns(processColumns);
|
|
72
|
-
|
|
73
61
|
function processDataSource(input) {
|
|
74
62
|
var result = [];
|
|
75
63
|
dfs(input, 0);
|
|
76
|
-
|
|
77
64
|
function dfs(nodes, depth) {
|
|
78
65
|
if (nodes == null) {
|
|
79
66
|
return;
|
|
80
67
|
}
|
|
81
|
-
|
|
82
68
|
var _iterator = _createForOfIteratorHelper(nodes),
|
|
83
|
-
|
|
84
|
-
|
|
69
|
+
_step;
|
|
85
70
|
try {
|
|
86
71
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
87
72
|
var node = _step.value;
|
|
@@ -99,7 +84,6 @@ export function treeMode() {
|
|
|
99
84
|
rowKey: rowKey
|
|
100
85
|
};
|
|
101
86
|
result.push(_extends(_defineProperty({}, treeMetaKey, treeMeta), node));
|
|
102
|
-
|
|
103
87
|
if (!isLeaf && expanded) {
|
|
104
88
|
dfs(node.children, depth + 1);
|
|
105
89
|
}
|
|
@@ -110,38 +94,30 @@ export function treeMode() {
|
|
|
110
94
|
_iterator.f();
|
|
111
95
|
}
|
|
112
96
|
}
|
|
113
|
-
|
|
114
97
|
return result;
|
|
115
98
|
}
|
|
116
|
-
|
|
117
99
|
function processColumns(columns) {
|
|
118
100
|
if (columns.length === 0) {
|
|
119
101
|
return columns;
|
|
120
102
|
}
|
|
121
|
-
|
|
122
103
|
var expandColIndex = _findIndexInstanceProperty(columns).call(columns, function (_ref) {
|
|
123
104
|
var code = _ref.code;
|
|
124
105
|
return code && opts.expandColCode === code;
|
|
125
106
|
});
|
|
126
|
-
|
|
127
107
|
expandColIndex = expandColIndex === -1 ? 0 : expandColIndex;
|
|
128
108
|
var expandCol = columns[expandColIndex];
|
|
129
|
-
|
|
130
109
|
var render = function render(value, record, recordIndex) {
|
|
131
110
|
var content = internals.safeRender(expandCol, record, recordIndex);
|
|
132
|
-
|
|
133
111
|
if (record[treeMetaKey] == null) {
|
|
134
112
|
// 没有 treeMeta 信息的话,就返回原先的渲染结果
|
|
135
113
|
return content;
|
|
136
114
|
}
|
|
137
|
-
|
|
138
115
|
var _record$treeMetaKey = record[treeMetaKey],
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
116
|
+
rowKey = _record$treeMetaKey.rowKey,
|
|
117
|
+
depth = _record$treeMetaKey.depth,
|
|
118
|
+
isLeaf = _record$treeMetaKey.isLeaf,
|
|
119
|
+
expanded = _record$treeMetaKey.expanded;
|
|
143
120
|
var indent = iconIndent + depth * indentSize;
|
|
144
|
-
|
|
145
121
|
if (isLeaf) {
|
|
146
122
|
return /*#__PURE__*/React.createElement(InlineFlexCell, {
|
|
147
123
|
className: cx('expansion-cell', Classes.leaf)
|
|
@@ -151,15 +127,12 @@ export function treeMode() {
|
|
|
151
127
|
}
|
|
152
128
|
}, content));
|
|
153
129
|
}
|
|
154
|
-
|
|
155
130
|
var onClick = function onClick(e) {
|
|
156
131
|
if (stopClickEventPropagation) {
|
|
157
132
|
e.stopPropagation();
|
|
158
133
|
}
|
|
159
|
-
|
|
160
134
|
toggle(rowKey);
|
|
161
135
|
};
|
|
162
|
-
|
|
163
136
|
var expandCls = expanded ? Classes.expanded : Classes.collapsed;
|
|
164
137
|
return /*#__PURE__*/React.createElement(ExpansionCell, {
|
|
165
138
|
className: cx('expansion-cell', expandCls),
|
|
@@ -186,29 +159,23 @@ export function treeMode() {
|
|
|
186
159
|
onClick: clickArea === 'icon' ? onClick : undefined
|
|
187
160
|
}), content);
|
|
188
161
|
};
|
|
189
|
-
|
|
190
162
|
var getCellProps = function getCellProps(value, record, rowIndex) {
|
|
191
163
|
var prevProps = internals.safeGetCellProps(expandCol, record, rowIndex);
|
|
192
|
-
|
|
193
164
|
if (record[treeMetaKey] == null) {
|
|
194
165
|
// 没有 treeMeta 信息的话,就返回原先的 cellProps
|
|
195
166
|
return prevProps;
|
|
196
167
|
}
|
|
197
|
-
|
|
198
168
|
var _record$treeMetaKey2 = record[treeMetaKey],
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
169
|
+
isLeaf = _record$treeMetaKey2.isLeaf,
|
|
170
|
+
rowKey = _record$treeMetaKey2.rowKey;
|
|
202
171
|
if (isLeaf) {
|
|
203
172
|
return prevProps;
|
|
204
173
|
}
|
|
205
|
-
|
|
206
174
|
return mergeCellProps(prevProps, {
|
|
207
175
|
onClick: function onClick(e) {
|
|
208
176
|
if (stopClickEventPropagation) {
|
|
209
177
|
e.stopPropagation();
|
|
210
178
|
}
|
|
211
|
-
|
|
212
179
|
toggle(rowKey);
|
|
213
180
|
},
|
|
214
181
|
style: {
|
|
@@ -216,7 +183,6 @@ export function treeMode() {
|
|
|
216
183
|
}
|
|
217
184
|
});
|
|
218
185
|
};
|
|
219
|
-
|
|
220
186
|
columns[expandColIndex] = _extends(_extends({}, expandCol), {
|
|
221
187
|
title: /*#__PURE__*/React.createElement("span", {
|
|
222
188
|
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
|
}
|
|
@@ -21,16 +21,13 @@ import { autoFillTableWidth, tableWidthKey } from './features/autoFill';
|
|
|
21
21
|
*
|
|
22
22
|
* 4. snapshots,调用 pipeline.snapshot(name) 可以记录当前的状态,后续可以通过 name 来读取保存的状态
|
|
23
23
|
* */
|
|
24
|
-
|
|
25
24
|
export var TablePipeline = /*#__PURE__*/function () {
|
|
26
25
|
function TablePipeline(_ref) {
|
|
27
26
|
var state = _ref.state,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
setState = _ref.setState,
|
|
28
|
+
ctx = _ref.ctx,
|
|
29
|
+
ref = _ref.ref;
|
|
32
30
|
_classCallCheck(this, TablePipeline);
|
|
33
|
-
|
|
34
31
|
this._snapshots = {};
|
|
35
32
|
this._rowPropsGetters = [];
|
|
36
33
|
this._tableProps = {};
|
|
@@ -41,25 +38,21 @@ export var TablePipeline = /*#__PURE__*/function () {
|
|
|
41
38
|
this.state = state;
|
|
42
39
|
this.setState = setState;
|
|
43
40
|
this.ref = ref;
|
|
44
|
-
|
|
45
41
|
_extends(this.ctx, ctx);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
}
|
|
43
|
+
// Generate a pseudo-GUID by concatenating random hexadecimal.
|
|
49
44
|
_createClass(TablePipeline, [{
|
|
50
45
|
key: "guid",
|
|
51
46
|
value: function guid() {
|
|
52
47
|
function S4() {
|
|
53
48
|
return ((1 + Math.random()) * 0x10000 | 0).toString(16).substring(1);
|
|
54
49
|
}
|
|
55
|
-
|
|
56
50
|
return S4() + S4() + '-' + S4() + '-' + S4() + '-' + S4() + '-' + S4() + S4() + S4();
|
|
57
51
|
}
|
|
58
52
|
}, {
|
|
59
53
|
key: "appendRowPropsGetter",
|
|
60
54
|
value: function appendRowPropsGetter(getter) {
|
|
61
55
|
this._rowPropsGetters.push(getter);
|
|
62
|
-
|
|
63
56
|
return this;
|
|
64
57
|
}
|
|
65
58
|
}, {
|
|
@@ -94,11 +87,9 @@ export var TablePipeline = /*#__PURE__*/function () {
|
|
|
94
87
|
key: "getStateAtKey",
|
|
95
88
|
value: function getStateAtKey(stateKey, defaultValue) {
|
|
96
89
|
var _a;
|
|
97
|
-
|
|
98
90
|
return (_a = this.state[stateKey]) !== null && _a !== void 0 ? _a : defaultValue;
|
|
99
91
|
}
|
|
100
92
|
/** 将 stateKey 对应的状态设置为 partialState */
|
|
101
|
-
|
|
102
93
|
}, {
|
|
103
94
|
key: "setStateAtKey",
|
|
104
95
|
value: function setStateAtKey(stateKey, partialState, extraInfo) {
|
|
@@ -107,28 +98,23 @@ export var TablePipeline = /*#__PURE__*/function () {
|
|
|
107
98
|
}, stateKey, partialState, extraInfo);
|
|
108
99
|
}
|
|
109
100
|
/** 确保 primaryKey 已被设置,并返回 primaryKey */
|
|
110
|
-
|
|
111
101
|
}, {
|
|
112
102
|
key: "ensurePrimaryKey",
|
|
113
103
|
value: function ensurePrimaryKey(hint) {
|
|
114
104
|
if (this.ctx.primaryKey == null) {
|
|
115
105
|
throw new Error(hint ? "\u4F7F\u7528 ".concat(hint, " \u4E4B\u524D\u5FC5\u987B\u5148\u8BBE\u7F6E primaryKey") : '必须先设置 primaryKey');
|
|
116
106
|
}
|
|
117
|
-
|
|
118
107
|
return this.ctx.primaryKey;
|
|
119
108
|
}
|
|
120
109
|
/** 设置流水线的输入数据 */
|
|
121
|
-
|
|
122
110
|
}, {
|
|
123
111
|
key: "input",
|
|
124
112
|
value: function input(_input) {
|
|
125
113
|
var _context,
|
|
126
|
-
|
|
127
|
-
|
|
114
|
+
_this = this;
|
|
128
115
|
if (this._dataSource != null || this._columns != null) {
|
|
129
116
|
throw new Error('input 不能调用两次');
|
|
130
117
|
}
|
|
131
|
-
|
|
132
118
|
this._dataSource = _input.dataSource;
|
|
133
119
|
this._columns = _mapInstanceProperty(_context = _input.columns).call(_context, function (col) {
|
|
134
120
|
return _extends(_extends({}, col), {
|
|
@@ -139,7 +125,6 @@ export var TablePipeline = /*#__PURE__*/function () {
|
|
|
139
125
|
return this;
|
|
140
126
|
}
|
|
141
127
|
/** 设置 dataSource */
|
|
142
|
-
|
|
143
128
|
}, {
|
|
144
129
|
key: "dataSource",
|
|
145
130
|
value: function dataSource(rows) {
|
|
@@ -147,7 +132,6 @@ export var TablePipeline = /*#__PURE__*/function () {
|
|
|
147
132
|
return this;
|
|
148
133
|
}
|
|
149
134
|
/** 设置 columns */
|
|
150
|
-
|
|
151
135
|
}, {
|
|
152
136
|
key: "columns",
|
|
153
137
|
value: function columns(cols) {
|
|
@@ -155,7 +139,6 @@ export var TablePipeline = /*#__PURE__*/function () {
|
|
|
155
139
|
return this;
|
|
156
140
|
}
|
|
157
141
|
/** 设置主键 */
|
|
158
|
-
|
|
159
142
|
}, {
|
|
160
143
|
key: "primaryKey",
|
|
161
144
|
value: function primaryKey(key) {
|
|
@@ -163,7 +146,6 @@ export var TablePipeline = /*#__PURE__*/function () {
|
|
|
163
146
|
return this;
|
|
164
147
|
}
|
|
165
148
|
/** 设置页脚数据 */
|
|
166
|
-
|
|
167
149
|
}, {
|
|
168
150
|
key: "footerDataSource",
|
|
169
151
|
value: function footerDataSource(rows) {
|
|
@@ -171,12 +153,10 @@ export var TablePipeline = /*#__PURE__*/function () {
|
|
|
171
153
|
return this;
|
|
172
154
|
}
|
|
173
155
|
/** 保存快照 */
|
|
174
|
-
|
|
175
156
|
}, {
|
|
176
157
|
key: "snapshot",
|
|
177
158
|
value: function snapshot(name) {
|
|
178
159
|
var _context2;
|
|
179
|
-
|
|
180
160
|
this._snapshots[name] = {
|
|
181
161
|
dataSource: this._dataSource,
|
|
182
162
|
columns: this._columns,
|
|
@@ -186,7 +166,6 @@ export var TablePipeline = /*#__PURE__*/function () {
|
|
|
186
166
|
}
|
|
187
167
|
/** @deprecated
|
|
188
168
|
* 应用一个 kd-table Table transform */
|
|
189
|
-
|
|
190
169
|
}, {
|
|
191
170
|
key: "useTransform",
|
|
192
171
|
value: function useTransform(transform) {
|
|
@@ -197,63 +176,52 @@ export var TablePipeline = /*#__PURE__*/function () {
|
|
|
197
176
|
return this.dataSource(next.dataSource).columns(next.columns);
|
|
198
177
|
}
|
|
199
178
|
/** 使用 pipeline 功能拓展 */
|
|
200
|
-
|
|
201
179
|
}, {
|
|
202
180
|
key: "use",
|
|
203
181
|
value: function use(step) {
|
|
204
182
|
return step(this);
|
|
205
183
|
}
|
|
206
184
|
/** 转换 dataSource */
|
|
207
|
-
|
|
208
185
|
}, {
|
|
209
186
|
key: "mapDataSource",
|
|
210
187
|
value: function mapDataSource(mapper) {
|
|
211
188
|
return this.dataSource(mapper(this.getDataSource()));
|
|
212
189
|
}
|
|
213
190
|
/** 转换 columns */
|
|
214
|
-
|
|
215
191
|
}, {
|
|
216
192
|
key: "mapColumns",
|
|
217
193
|
value: function mapColumns(mapper) {
|
|
218
194
|
return this.columns(mapper(this.getColumns()));
|
|
219
195
|
}
|
|
220
196
|
/** 获取featureOptions 内容 */
|
|
221
|
-
|
|
222
197
|
}, {
|
|
223
198
|
key: "getFeatureOptions",
|
|
224
199
|
value: function getFeatureOptions(optionKey) {
|
|
225
200
|
var _a;
|
|
226
|
-
|
|
227
201
|
return (_a = this.ref.current.featureOptions) === null || _a === void 0 ? void 0 : _a[optionKey];
|
|
228
202
|
}
|
|
229
203
|
/** 设置pipelineOptions 内容 */
|
|
230
|
-
|
|
231
204
|
}, {
|
|
232
205
|
key: "setFeatureOptions",
|
|
233
206
|
value: function setFeatureOptions(optionKey, value) {
|
|
234
207
|
this.ref.current.featureOptions[optionKey] = value;
|
|
235
208
|
}
|
|
236
209
|
/** 获取 BaseTable 的 props,结果中包含 dataSource/columns/primaryKey/getRowProps 四个字段 */
|
|
237
|
-
|
|
238
210
|
}, {
|
|
239
211
|
key: "getProps",
|
|
240
212
|
value: function getProps() {
|
|
241
213
|
var _this2 = this;
|
|
242
|
-
|
|
243
214
|
this.use(autoFillTableWidth());
|
|
244
215
|
var result = {
|
|
245
216
|
dataSource: this._dataSource,
|
|
246
217
|
columns: this._columns
|
|
247
218
|
};
|
|
248
|
-
|
|
249
219
|
if (this.ctx.primaryKey) {
|
|
250
220
|
result.primaryKey = this.ctx.primaryKey;
|
|
251
221
|
}
|
|
252
|
-
|
|
253
222
|
if (this._footerDataSource) {
|
|
254
223
|
result.footerDataSource = this._footerDataSource;
|
|
255
224
|
}
|
|
256
|
-
|
|
257
225
|
if (this._rowPropsGetters.length > 0) {
|
|
258
226
|
result.getRowProps = function (row, rowIndex) {
|
|
259
227
|
return _this2._rowPropsGetters.reduce(function (res, get) {
|
|
@@ -261,31 +229,24 @@ export var TablePipeline = /*#__PURE__*/function () {
|
|
|
261
229
|
}, {});
|
|
262
230
|
};
|
|
263
231
|
}
|
|
264
|
-
|
|
265
232
|
result.getTableProps = function () {
|
|
266
233
|
return _this2._tableProps;
|
|
267
234
|
};
|
|
268
|
-
|
|
269
235
|
result.setTableWidth = function (tableWidth) {
|
|
270
236
|
var preTableWidth = _this2.getStateAtKey(tableWidthKey);
|
|
271
|
-
|
|
272
237
|
if (preTableWidth !== tableWidth) {
|
|
273
238
|
tableWidth && _this2.setStateAtKey(tableWidthKey, tableWidth);
|
|
274
239
|
}
|
|
275
240
|
};
|
|
276
|
-
|
|
277
241
|
result.setTableDomHelper = function (domHelper) {
|
|
278
242
|
_this2.ref.current.domHelper = domHelper;
|
|
279
243
|
};
|
|
280
|
-
|
|
281
244
|
result.setRowHeightManager = function (rowHeightManager) {
|
|
282
245
|
_this2.ref.current.rowHeightManager = rowHeightManager;
|
|
283
246
|
};
|
|
284
|
-
|
|
285
247
|
return result;
|
|
286
248
|
}
|
|
287
249
|
}]);
|
|
288
|
-
|
|
289
250
|
return TablePipeline;
|
|
290
251
|
}();
|
|
291
252
|
TablePipeline.defaultIndents = {
|
|
@@ -296,10 +257,9 @@ TablePipeline.defaultIndents = {
|
|
|
296
257
|
};
|
|
297
258
|
export function useTablePipeline(ctx) {
|
|
298
259
|
var _useState = useState({}),
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
260
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
261
|
+
state = _useState2[0],
|
|
262
|
+
setState = _useState2[1];
|
|
303
263
|
var ref = useRef({
|
|
304
264
|
featureOptions: {}
|
|
305
265
|
});
|