@kdcloudjs/table 1.2.1-canary.6 → 1.2.1-canary.6-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/CHANGELOG.md +0 -0
- package/dist/@kdcloudjs/table.css +1 -1
- package/dist/@kdcloudjs/table.js +4847 -6022
- package/dist/@kdcloudjs/table.js.map +1 -1
- package/dist/@kdcloudjs/table.min.css +1 -1
- package/dist/@kdcloudjs/table.min.js +16 -24
- package/dist/@kdcloudjs/table.min.js.map +1 -1
- 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 +84 -147
- 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/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/header.js +30 -81
- 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 +2 -3
- 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.js +0 -9
- package/es/table/base/table.js +110 -199
- package/es/table/base/utils.js +17 -57
- package/es/table/common-views.js +0 -7
- package/es/table/interfaces.d.ts +2 -0
- package/es/table/internals.d.ts +2 -1
- 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 -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/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 +6 -43
- package/es/table/pipeline/features/rowDrag.js +39 -78
- package/es/table/pipeline/features/rowGrouping.js +10 -42
- package/es/table/pipeline/features/singleSelect.js +0 -24
- package/es/table/pipeline/features/sort.js +37 -90
- package/es/table/pipeline/features/tips.js +4 -10
- package/es/table/pipeline/features/treeMode.js +14 -49
- package/es/table/pipeline/features/treeSelect.js +2 -28
- package/es/table/pipeline/pipeline.js +12 -53
- 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-table/interfaces.d.ts +1 -1
- 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/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.d.ts +1 -0
- package/es/table/transforms/sort.js +42 -96
- package/es/table/transforms/tips.js +5 -10
- package/es/table/transforms/treeMode.js +39 -80
- 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 +8 -13
- 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 +88 -176
- package/lib/config-provider/ConfigContext.js +2 -6
- package/lib/config-provider/compDefaultProps.js +1 -3
- package/lib/config-provider/configProvider.js +5 -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 +2 -11
- package/lib/locale/locale.js +15 -71
- package/lib/locale/zh-CN.js +1 -2
- package/lib/table/base/calculations.js +25 -86
- package/lib/table/base/colgroup.js +0 -5
- package/lib/table/base/empty.js +7 -20
- package/lib/table/base/header.js +30 -91
- 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 +2 -7
- package/lib/table/base/helpers/__test__/rowHeightManager.test.js +0 -1
- package/lib/table/base/helpers/getRichVisibleRectsStream.js +14 -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 +44 -76
- package/lib/table/base/styles.js +8 -37
- package/lib/table/base/table.js +121 -243
- package/lib/table/base/utils.js +26 -109
- package/lib/table/common-views.js +4 -24
- package/lib/table/index.js +0 -13
- package/lib/table/interfaces.d.ts +2 -0
- package/lib/table/internals.d.ts +2 -1
- package/lib/table/internals.js +2 -17
- 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 +17 -63
- package/lib/table/pipeline/features/contextMenu.js +23 -121
- package/lib/table/pipeline/features/filter/DefaultFilterContent.js +16 -52
- package/lib/table/pipeline/features/filter/DefaultFilterIcon.js +1 -4
- package/lib/table/pipeline/features/filter/Filter.js +29 -77
- package/lib/table/pipeline/features/filter/FilterPanel.js +13 -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 +6 -67
- package/lib/table/pipeline/features/rowDrag.js +41 -93
- package/lib/table/pipeline/features/rowGrouping.js +10 -62
- package/lib/table/pipeline/features/singleSelect.js +0 -34
- package/lib/table/pipeline/features/sort.js +37 -110
- package/lib/table/pipeline/features/tips.js +4 -19
- package/lib/table/pipeline/features/treeMode.js +15 -72
- package/lib/table/pipeline/features/treeSelect.js +2 -36
- package/lib/table/pipeline/index.js +1 -10
- package/lib/table/pipeline/pipeline.js +13 -64
- 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-table/interfaces.d.ts +1 -1
- 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/transforms/autoRowSpan.js +1 -21
- package/lib/table/transforms/autoWidth.js +14 -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 +19 -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.d.ts +1 -0
- package/lib/table/transforms/sort.js +43 -122
- package/lib/table/transforms/tips.js +5 -20
- package/lib/table/transforms/treeMode.js +40 -109
- 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 +8 -18
- 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 +3 -2
|
@@ -2,13 +2,11 @@ import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
|
2
2
|
import { traverseColumn } from '../utils';
|
|
3
3
|
import { warnTransformsDeprecated } from './warnTransformsDeprecated';
|
|
4
4
|
/** @deprecated transform 用法已经过时,请使用 pipeline 来对表格进行拓展 */
|
|
5
|
-
|
|
6
5
|
export function makeOrderFieldTransform() {
|
|
7
6
|
var startOrder = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
8
7
|
warnTransformsDeprecated('makeOrderFieldTransform');
|
|
9
8
|
return traverseColumn(function (column) {
|
|
10
9
|
var _a, _b;
|
|
11
|
-
|
|
12
10
|
if (((_a = column.features) === null || _a === void 0 ? void 0 : _a.order) || ((_b = column.features) === null || _b === void 0 ? void 0 : _b.orderField)) {
|
|
13
11
|
return _extends(_extends({}, column), {
|
|
14
12
|
getValue: function getValue(record, index) {
|
|
@@ -16,7 +14,6 @@ export function makeOrderFieldTransform() {
|
|
|
16
14
|
}
|
|
17
15
|
});
|
|
18
16
|
}
|
|
19
|
-
|
|
20
17
|
return column;
|
|
21
18
|
});
|
|
22
19
|
}
|
|
@@ -4,15 +4,10 @@ import _getIteratorMethod from "@babel/runtime-corejs3/core-js/get-iterator-meth
|
|
|
4
4
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
|
|
5
5
|
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
6
6
|
import _taggedTemplateLiteral from "@babel/runtime-corejs3/helpers/taggedTemplateLiteral";
|
|
7
|
-
|
|
8
7
|
var _templateObject;
|
|
9
|
-
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
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
|
-
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
|
-
|
|
8
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof _Symbol && _getIteratorMethod(r) || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
9
|
+
function _unsupportedIterableToArray(r, a) { if (r) { var _context4; if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = _sliceInstanceProperty(_context4 = {}.toString.call(r)).call(_context4, 8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? _Array$from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
10
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
16
11
|
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
|
17
12
|
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
18
13
|
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
@@ -20,32 +15,25 @@ import _Map from "@babel/runtime-corejs3/core-js-stable/map";
|
|
|
20
15
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
21
16
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
22
17
|
import _findIndexInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find-index";
|
|
23
|
-
|
|
24
18
|
var __rest = this && this.__rest || function (s, e) {
|
|
25
19
|
var t = {};
|
|
26
|
-
|
|
27
|
-
for (var p in s) {
|
|
28
|
-
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
29
|
-
}
|
|
30
|
-
|
|
20
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
31
21
|
if (s != null && typeof _Object$getOwnPropertySymbols === "function") for (var i = 0, p = _Object$getOwnPropertySymbols(s); i < p.length; i++) {
|
|
32
22
|
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
33
23
|
}
|
|
34
24
|
return t;
|
|
35
25
|
};
|
|
36
|
-
|
|
37
26
|
import React, { useState } from 'react';
|
|
38
27
|
import styled from 'styled-components';
|
|
39
28
|
import { internals } from '../internals';
|
|
40
29
|
import { collectNodes, isLeafNode, layeredSort, mergeCellProps, smartCompare } from '../utils';
|
|
41
30
|
import { warnTransformsDeprecated } from './warnTransformsDeprecated';
|
|
42
|
-
|
|
43
31
|
function SortIcon(_ref) {
|
|
44
32
|
var _ref$size = _ref.size,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
33
|
+
size = _ref$size === void 0 ? 32 : _ref$size,
|
|
34
|
+
style = _ref.style,
|
|
35
|
+
className = _ref.className,
|
|
36
|
+
order = _ref.order;
|
|
49
37
|
return /*#__PURE__*/React.createElement("svg", {
|
|
50
38
|
style: style,
|
|
51
39
|
className: className,
|
|
@@ -65,14 +53,13 @@ function SortIcon(_ref) {
|
|
|
65
53
|
d: "M24 24L16 32 8 24z "
|
|
66
54
|
}));
|
|
67
55
|
}
|
|
68
|
-
|
|
69
56
|
function DefaultSortHeaderCell(_ref2) {
|
|
70
57
|
var children = _ref2.children,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
58
|
+
column = _ref2.column,
|
|
59
|
+
onToggle = _ref2.onToggle,
|
|
60
|
+
sortOrder = _ref2.sortOrder,
|
|
61
|
+
sortIndex = _ref2.sortIndex,
|
|
62
|
+
sortOptions = _ref2.sortOptions;
|
|
76
63
|
// 通过 justify-content 来与 col.align 保持对齐方向一致
|
|
77
64
|
var justifyContent = column.align === 'right' ? 'flex-end' : column.align === 'center' ? 'center' : 'flex-start';
|
|
78
65
|
return /*#__PURE__*/React.createElement(TableHeaderCell, {
|
|
@@ -88,7 +75,7 @@ function DefaultSortHeaderCell(_ref2) {
|
|
|
88
75
|
},
|
|
89
76
|
size: 16,
|
|
90
77
|
order: sortOrder
|
|
91
|
-
}), sortOptions.mode === 'multiple' && sortIndex != -1 && /*#__PURE__*/React.createElement("div", {
|
|
78
|
+
}), sortOptions.mode === 'multiple' && sortIndex != -1 && (/*#__PURE__*/React.createElement("div", {
|
|
92
79
|
style: {
|
|
93
80
|
userSelect: 'none',
|
|
94
81
|
marginLeft: 2,
|
|
@@ -97,39 +84,33 @@ function DefaultSortHeaderCell(_ref2) {
|
|
|
97
84
|
fontSize: 10,
|
|
98
85
|
fontFamily: 'monospace'
|
|
99
86
|
}
|
|
100
|
-
}, sortIndex + 1));
|
|
87
|
+
}, sortIndex + 1)));
|
|
101
88
|
}
|
|
102
|
-
|
|
103
89
|
function hasAnySortableColumns(cols) {
|
|
104
90
|
return cols.some(function (col) {
|
|
105
91
|
var _a;
|
|
106
|
-
|
|
107
92
|
return Boolean((_a = col.features) === null || _a === void 0 ? void 0 : _a.sortable) || !isLeafNode(col) && hasAnySortableColumns(col.children);
|
|
108
93
|
});
|
|
109
94
|
}
|
|
110
|
-
|
|
111
95
|
var TableHeaderCell = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n cursor: pointer;\n display: flex;\n align-items: center;\n"])));
|
|
112
96
|
/** @deprecated transform 用法已经过时,请使用 pipeline 来对表格进行拓展 */
|
|
113
|
-
|
|
114
97
|
export function makeSortTransform(_ref3) {
|
|
115
98
|
var inputSorts = _ref3.sorts,
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
99
|
+
inputOnChangeSorts = _ref3.onChangeSorts,
|
|
100
|
+
_ref3$orders = _ref3.orders,
|
|
101
|
+
orders = _ref3$orders === void 0 ? ['desc', 'asc', 'none'] : _ref3$orders,
|
|
102
|
+
_ref3$mode = _ref3.mode,
|
|
103
|
+
mode = _ref3$mode === void 0 ? 'multiple' : _ref3$mode,
|
|
104
|
+
_ref3$SortHeaderCell = _ref3.SortHeaderCell,
|
|
105
|
+
SortHeaderCell = _ref3$SortHeaderCell === void 0 ? DefaultSortHeaderCell : _ref3$SortHeaderCell,
|
|
106
|
+
keepDataSource = _ref3.keepDataSource,
|
|
107
|
+
highlightColumnWhenActive = _ref3.highlightColumnWhenActive,
|
|
108
|
+
stopClickEventPropagation = _ref3.stopClickEventPropagation;
|
|
126
109
|
warnTransformsDeprecated('makeSortTransform');
|
|
127
|
-
|
|
128
110
|
var filteredInputSorts = _filterInstanceProperty(inputSorts).call(inputSorts, function (s) {
|
|
129
111
|
return s.order !== 'none';
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
|
|
112
|
+
});
|
|
113
|
+
// 单字段排序的情况下 sorts 中只有第一个排序字段才会生效
|
|
133
114
|
var sorts = mode === 'multiple' ? filteredInputSorts : _sliceInstanceProperty(filteredInputSorts).call(filteredInputSorts, 0, 1);
|
|
134
115
|
var onChangeSorts = mode === 'multiple' ? inputOnChangeSorts : function (nextSorts) {
|
|
135
116
|
// 单字段排序的情况下,nextSorts 中只有最后一个排序字段才会生效
|
|
@@ -152,54 +133,45 @@ export function makeSortTransform(_ref3) {
|
|
|
152
133
|
}));
|
|
153
134
|
return function (_ref4) {
|
|
154
135
|
var dataSource = _ref4.dataSource,
|
|
155
|
-
|
|
156
|
-
|
|
136
|
+
columns = _ref4.columns;
|
|
157
137
|
if (process.env.NODE_ENV !== 'production') {
|
|
158
138
|
if (!hasAnySortableColumns(columns)) {
|
|
159
139
|
console.warn('[ali-react-table] commonTransform.sort 缺少可排序的列,请通过 column.features.sortable 来指定哪些列可排序', columns);
|
|
160
140
|
}
|
|
161
141
|
}
|
|
162
|
-
|
|
163
142
|
return {
|
|
164
143
|
columns: processColumns(columns),
|
|
165
144
|
dataSource: processDataSource(dataSource)
|
|
166
145
|
};
|
|
167
|
-
|
|
168
146
|
function processDataSource(dataSource) {
|
|
169
147
|
var _context, _context2;
|
|
170
|
-
|
|
171
148
|
if (keepDataSource) {
|
|
172
149
|
return dataSource;
|
|
173
150
|
}
|
|
174
|
-
|
|
175
151
|
var sortColumnsMap = new _Map(_mapInstanceProperty(_context = _filterInstanceProperty(_context2 = collectNodes(columns, 'leaf-only')).call(_context2, function (col) {
|
|
176
152
|
var _a;
|
|
177
|
-
|
|
178
153
|
return ((_a = col.features) === null || _a === void 0 ? void 0 : _a.sortable) != null;
|
|
179
154
|
})).call(_context, function (col) {
|
|
180
155
|
return [col.code, col];
|
|
181
156
|
}));
|
|
182
157
|
return layeredSort(dataSource, function (x, y) {
|
|
183
158
|
var _iterator = _createForOfIteratorHelper(sorts),
|
|
184
|
-
|
|
185
|
-
|
|
159
|
+
_step;
|
|
186
160
|
try {
|
|
187
161
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
188
162
|
var _step$value = _step.value,
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
var column = sortColumnsMap.get(code);
|
|
192
|
-
|
|
163
|
+
code = _step$value.code,
|
|
164
|
+
order = _step$value.order;
|
|
165
|
+
var column = sortColumnsMap.get(code);
|
|
166
|
+
// 如果 code 对应的 column 不可排序,我们跳过该 code
|
|
193
167
|
if (column == null) {
|
|
194
168
|
continue;
|
|
195
169
|
}
|
|
196
|
-
|
|
197
170
|
var sortable = column.features.sortable;
|
|
198
171
|
var compareFn = typeof sortable === 'function' ? sortable : smartCompare;
|
|
199
172
|
var xValue = internals.safeGetValue(column, x, -1);
|
|
200
173
|
var yValue = internals.safeGetValue(column, y, -1);
|
|
201
174
|
var cmp = compareFn(xValue, yValue);
|
|
202
|
-
|
|
203
175
|
if (cmp !== 0) {
|
|
204
176
|
return cmp * (order === 'asc' ? 1 : -1);
|
|
205
177
|
}
|
|
@@ -209,15 +181,12 @@ export function makeSortTransform(_ref3) {
|
|
|
209
181
|
} finally {
|
|
210
182
|
_iterator.f();
|
|
211
183
|
}
|
|
212
|
-
|
|
213
184
|
return 0;
|
|
214
185
|
});
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
|
|
186
|
+
}
|
|
187
|
+
// 在「升序 - 降序 - 不排序」之间不断切换
|
|
218
188
|
function toggle(code) {
|
|
219
189
|
var sort = sortMap.get(code);
|
|
220
|
-
|
|
221
190
|
if (sort == null) {
|
|
222
191
|
onChangeSorts(_concatInstanceProperty(sorts).call(sorts, [{
|
|
223
192
|
code: code,
|
|
@@ -227,11 +196,8 @@ export function makeSortTransform(_ref3) {
|
|
|
227
196
|
var index = _findIndexInstanceProperty(sorts).call(sorts, function (s) {
|
|
228
197
|
return s.code === code;
|
|
229
198
|
});
|
|
230
|
-
|
|
231
199
|
var nextSorts = _sliceInstanceProperty(sorts).call(sorts, 0, index + 1);
|
|
232
|
-
|
|
233
200
|
var nextOrder = getNextOrder(sort.order);
|
|
234
|
-
|
|
235
201
|
if (nextOrder === 'none') {
|
|
236
202
|
nextSorts.pop();
|
|
237
203
|
} else {
|
|
@@ -239,41 +205,31 @@ export function makeSortTransform(_ref3) {
|
|
|
239
205
|
order: nextOrder
|
|
240
206
|
});
|
|
241
207
|
}
|
|
242
|
-
|
|
243
208
|
onChangeSorts(nextSorts);
|
|
244
209
|
}
|
|
245
210
|
}
|
|
246
|
-
|
|
247
211
|
function processColumns(columns) {
|
|
248
212
|
return _mapInstanceProperty(columns).call(columns, dfs);
|
|
249
|
-
|
|
250
213
|
function dfs(col) {
|
|
251
214
|
var _a;
|
|
252
|
-
|
|
253
215
|
var result = _extends({}, col);
|
|
254
|
-
|
|
255
216
|
var sortable = col.code && (((_a = col.features) === null || _a === void 0 ? void 0 : _a.sortable) || sortMap.has(col.code));
|
|
256
217
|
var active = sortable && sortMap.has(col.code);
|
|
257
|
-
|
|
258
218
|
if (sortable) {
|
|
259
219
|
var sortIndex = -1;
|
|
260
220
|
var sortOrder = 'none';
|
|
261
|
-
|
|
262
221
|
if (active) {
|
|
263
222
|
var _sortMap$get = sortMap.get(col.code),
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
223
|
+
order = _sortMap$get.order,
|
|
224
|
+
index = _sortMap$get.index;
|
|
267
225
|
sortOrder = order;
|
|
268
226
|
sortIndex = index;
|
|
269
|
-
|
|
270
227
|
if (highlightColumnWhenActive) {
|
|
271
228
|
result.headerCellProps = mergeCellProps(col.headerCellProps, {
|
|
272
229
|
style: {
|
|
273
230
|
background: 'var(--header-highlight-bgcolor)'
|
|
274
231
|
}
|
|
275
232
|
});
|
|
276
|
-
|
|
277
233
|
result.getCellProps = function (value, row, rowIndex) {
|
|
278
234
|
var prevCellProps = internals.safeGetCellProps(col, row, rowIndex);
|
|
279
235
|
return mergeCellProps(prevCellProps, {
|
|
@@ -284,13 +240,11 @@ export function makeSortTransform(_ref3) {
|
|
|
284
240
|
};
|
|
285
241
|
}
|
|
286
242
|
}
|
|
287
|
-
|
|
288
243
|
result.title = /*#__PURE__*/React.createElement(SortHeaderCell, {
|
|
289
244
|
onToggle: function onToggle(e) {
|
|
290
245
|
if (stopClickEventPropagation) {
|
|
291
246
|
e.stopPropagation();
|
|
292
247
|
}
|
|
293
|
-
|
|
294
248
|
toggle(col.code);
|
|
295
249
|
},
|
|
296
250
|
sortOrder: sortOrder,
|
|
@@ -299,37 +253,29 @@ export function makeSortTransform(_ref3) {
|
|
|
299
253
|
sortOptions: sortOptions
|
|
300
254
|
}, internals.safeRenderHeader(col));
|
|
301
255
|
}
|
|
302
|
-
|
|
303
256
|
if (!isLeafNode(col)) {
|
|
304
257
|
var _context3;
|
|
305
|
-
|
|
306
258
|
result.children = _mapInstanceProperty(_context3 = col.children).call(_context3, dfs);
|
|
307
259
|
}
|
|
308
|
-
|
|
309
260
|
return result;
|
|
310
261
|
}
|
|
311
262
|
}
|
|
312
263
|
};
|
|
313
|
-
|
|
314
264
|
function getNextOrder(order) {
|
|
315
265
|
var idx = orders.indexOf(order);
|
|
316
266
|
return orders[idx === orders.length - 1 ? 0 : idx + 1];
|
|
317
267
|
}
|
|
318
268
|
}
|
|
319
269
|
/** @deprecated transform 用法已经过时,请使用 pipeline 来对表格进行拓展 */
|
|
320
|
-
|
|
321
270
|
export function useSortTransform() {
|
|
322
271
|
var _a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
323
|
-
|
|
324
272
|
var _a$defaultSorts = _a.defaultSorts,
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
273
|
+
defaultSorts = _a$defaultSorts === void 0 ? [] : _a$defaultSorts,
|
|
274
|
+
others = __rest(_a, ["defaultSorts"]);
|
|
328
275
|
var _useState = useState(defaultSorts),
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
276
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
277
|
+
sorts = _useState2[0],
|
|
278
|
+
onChangeSorts = _useState2[1];
|
|
333
279
|
return makeSortTransform(_extends({
|
|
334
280
|
sorts: sorts,
|
|
335
281
|
onChangeSorts: onChangeSorts
|
|
@@ -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';
|
|
@@ -11,25 +9,22 @@ import { traverseColumn } from '../utils';
|
|
|
11
9
|
import { warnTransformsDeprecated } from './warnTransformsDeprecated';
|
|
12
10
|
var HeaderCellWithTips = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n\n .tip-icon-wrapper {\n margin-left: 2px;\n }\n\n .tip-icon {\n display: flex;\n fill: currentColor;\n }\n"])));
|
|
13
11
|
/** @deprecated transform 用法已经过时,请使用 pipeline 来对表格进行拓展 */
|
|
14
|
-
|
|
15
12
|
export function makeTipsTransform(_ref) {
|
|
16
13
|
var Balloon = _ref.Balloon,
|
|
17
|
-
|
|
14
|
+
Tooltip = _ref.Tooltip;
|
|
18
15
|
warnTransformsDeprecated('makeTipsTransform');
|
|
19
16
|
return traverseColumn(function (col) {
|
|
20
17
|
var _a;
|
|
21
|
-
|
|
22
18
|
if (!((_a = col.features) === null || _a === void 0 ? void 0 : _a.tips)) {
|
|
23
19
|
return col;
|
|
24
20
|
}
|
|
25
|
-
|
|
26
21
|
var justifyContent = col.align === 'right' ? 'flex-end' : col.align === 'center' ? 'center' : 'flex-start';
|
|
27
22
|
return _extends(_extends({}, col), {
|
|
28
|
-
title: /*#__PURE__*/React.createElement(HeaderCellWithTips, {
|
|
23
|
+
title: (/*#__PURE__*/React.createElement(HeaderCellWithTips, {
|
|
29
24
|
style: {
|
|
30
25
|
justifyContent: justifyContent
|
|
31
26
|
}
|
|
32
|
-
}, internals.safeRenderHeader(col), Balloon ?
|
|
27
|
+
}, internals.safeRenderHeader(col), Balloon ? (
|
|
33
28
|
/*#__PURE__*/
|
|
34
29
|
// fusion/hippo
|
|
35
30
|
React.createElement(Balloon, {
|
|
@@ -39,7 +34,7 @@ export function makeTipsTransform(_ref) {
|
|
|
39
34
|
}, /*#__PURE__*/React.createElement(icons.Info, {
|
|
40
35
|
className: "tip-icon"
|
|
41
36
|
}))
|
|
42
|
-
}, col.features.tips) :
|
|
37
|
+
}, col.features.tips)) : (
|
|
43
38
|
/*#__PURE__*/
|
|
44
39
|
// antd
|
|
45
40
|
React.createElement(Tooltip, {
|
|
@@ -48,7 +43,7 @@ export function makeTipsTransform(_ref) {
|
|
|
48
43
|
className: "tip-icon-wrapper"
|
|
49
44
|
}, /*#__PURE__*/React.createElement(icons.Info, {
|
|
50
45
|
className: "tip-icon"
|
|
51
|
-
}))))
|
|
46
|
+
}))))))
|
|
52
47
|
});
|
|
53
48
|
});
|
|
54
49
|
}
|