@kdcloudjs/table 1.2.0-canary.15 → 1.2.0-canary.16-hotfix
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.js +2051 -3489
- 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/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 +14 -67
- package/es/table/base/helpers/SpanManager.js +3 -9
- package/es/table/base/helpers/TableDOMUtils.js +4 -27
- 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 +14 -35
- package/es/table/base/loading.js +6 -8
- package/es/table/base/renderTemplates.js +26 -44
- package/es/table/base/styles.js +1 -10
- package/es/table/base/table.js +96 -179
- 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.d.ts +1 -0
- package/es/table/pipeline/features/columnDrag.js +236 -303
- 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 +51 -42
- 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 +65 -143
- package/es/table/pipeline/features/rowDetail.js +2 -41
- package/es/table/pipeline/features/rowDrag.js +36 -71
- 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 +31 -83
- package/es/table/pipeline/features/tips.js +0 -6
- package/es/table/pipeline/features/treeMode.js +9 -44
- package/es/table/pipeline/features/treeSelect.js +0 -26
- package/es/table/pipeline/features/utils/touchEventUtils.d.ts +15 -0
- package/es/table/pipeline/features/utils/touchEventUtils.js +65 -0
- 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 -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/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 +14 -77
- package/lib/table/base/helpers/SpanManager.js +3 -11
- package/lib/table/base/helpers/TableDOMUtils.js +2 -27
- 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 +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 +1 -22
- package/lib/table/base/table.js +96 -212
- 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.d.ts +1 -0
- package/lib/table/pipeline/features/columnDrag.js +236 -309
- 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 +51 -58
- 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 +65 -160
- package/lib/table/pipeline/features/rowDetail.js +2 -65
- package/lib/table/pipeline/features/rowDrag.js +36 -81
- 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 -103
- package/lib/table/pipeline/features/tips.js +0 -15
- package/lib/table/pipeline/features/treeMode.js +9 -65
- package/lib/table/pipeline/features/treeSelect.js +0 -34
- package/lib/table/pipeline/features/utils/touchEventUtils.d.ts +15 -0
- package/lib/table/pipeline/features/utils/touchEventUtils.js +76 -0
- 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 -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 -21
- 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/package.json +2 -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";
|
|
@@ -25,13 +20,12 @@ import cx from 'classnames';
|
|
|
25
20
|
import { internals } from '../../internals';
|
|
26
21
|
import { collectNodes, isLeafNode, layeredSort, mergeCellProps, smartCompare, console } 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,46 @@ export function sort() {
|
|
|
153
136
|
}));
|
|
154
137
|
var dataSource = pipeline.getDataSource();
|
|
155
138
|
var columns = pipeline.getColumns();
|
|
156
|
-
|
|
157
139
|
if (process.env.NODE_ENV !== 'production') {
|
|
158
140
|
if (!hasAnySortableColumns(columns)) {
|
|
159
141
|
console.warn('commonTransform.sort 缺少可排序的列,请通过 column.features.sortable 来指定哪些列可排序', columns);
|
|
160
142
|
}
|
|
161
143
|
}
|
|
162
|
-
|
|
163
144
|
pipeline.dataSource(processDataSource(dataSource));
|
|
164
145
|
pipeline.columns(processColumns(columns));
|
|
165
146
|
return pipeline;
|
|
166
|
-
|
|
167
147
|
function processDataSource(dataSource) {
|
|
168
148
|
var _context, _context2;
|
|
169
|
-
|
|
170
149
|
if (keepDataSource) {
|
|
171
150
|
return dataSource;
|
|
172
151
|
}
|
|
173
|
-
|
|
174
152
|
if (sortMap.size === 0) {
|
|
175
153
|
return dataSource;
|
|
176
154
|
}
|
|
177
|
-
|
|
178
155
|
var sortColumnsMap = new _Map(_mapInstanceProperty(_context = _filterInstanceProperty(_context2 = collectNodes(columns, 'leaf-only')).call(_context2, function (col) {
|
|
179
156
|
var _a, _b;
|
|
180
|
-
|
|
181
157
|
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
158
|
})).call(_context, function (col) {
|
|
183
159
|
return [col.code, col];
|
|
184
160
|
}));
|
|
185
161
|
return layeredSort(dataSource, function (x, y) {
|
|
186
162
|
var _iterator = _createForOfIteratorHelper(sorts),
|
|
187
|
-
|
|
188
|
-
|
|
163
|
+
_step;
|
|
189
164
|
try {
|
|
190
165
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
191
166
|
var _step$value = _step.value,
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
var column = sortColumnsMap.get(code);
|
|
195
|
-
|
|
167
|
+
code = _step$value.code,
|
|
168
|
+
order = _step$value.order;
|
|
169
|
+
var column = sortColumnsMap.get(code);
|
|
170
|
+
// 如果 code 对应的 column 不可排序,我们跳过该 code
|
|
196
171
|
if (column == null) {
|
|
197
172
|
continue;
|
|
198
173
|
}
|
|
199
|
-
|
|
200
174
|
var sortable = column.features.sortable;
|
|
201
175
|
var compareFn = typeof sortable === 'function' ? sortable : smartCompare;
|
|
202
176
|
var xValue = internals.safeGetValue(column, x, -1);
|
|
203
177
|
var yValue = internals.safeGetValue(column, y, -1);
|
|
204
178
|
var cmp = compareFn(xValue, yValue, x, y);
|
|
205
|
-
|
|
206
179
|
if (cmp !== 0) {
|
|
207
180
|
return cmp * (order === 'asc' ? 1 : -1);
|
|
208
181
|
}
|
|
@@ -212,16 +185,13 @@ export function sort() {
|
|
|
212
185
|
} finally {
|
|
213
186
|
_iterator.f();
|
|
214
187
|
}
|
|
215
|
-
|
|
216
188
|
return 0;
|
|
217
189
|
});
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
|
|
190
|
+
}
|
|
191
|
+
// 在「升序 - 降序 - 不排序」之间不断切换
|
|
221
192
|
function toggle(code) {
|
|
222
193
|
var sort = sortMap.get(code);
|
|
223
194
|
var currentSort;
|
|
224
|
-
|
|
225
195
|
if (sort == null) {
|
|
226
196
|
currentSort = {
|
|
227
197
|
code: code,
|
|
@@ -232,15 +202,12 @@ export function sort() {
|
|
|
232
202
|
var index = _findIndexInstanceProperty(sorts).call(sorts, function (s) {
|
|
233
203
|
return s.code === code;
|
|
234
204
|
});
|
|
235
|
-
|
|
236
205
|
var nextSorts = _sliceInstanceProperty(sorts).call(sorts, 0, index + 1);
|
|
237
|
-
|
|
238
206
|
var nextOrder = getNextOrder(sort.order);
|
|
239
207
|
currentSort = {
|
|
240
208
|
code: code,
|
|
241
209
|
order: nextOrder
|
|
242
210
|
};
|
|
243
|
-
|
|
244
211
|
if (nextOrder === 'none') {
|
|
245
212
|
nextSorts.pop();
|
|
246
213
|
} else {
|
|
@@ -248,41 +215,31 @@ export function sort() {
|
|
|
248
215
|
order: nextOrder
|
|
249
216
|
});
|
|
250
217
|
}
|
|
251
|
-
|
|
252
218
|
onChangeSorts(nextSorts, currentSort);
|
|
253
219
|
}
|
|
254
220
|
}
|
|
255
|
-
|
|
256
221
|
function processColumns(columns) {
|
|
257
222
|
return _mapInstanceProperty(columns).call(columns, dfs);
|
|
258
|
-
|
|
259
223
|
function dfs(col) {
|
|
260
224
|
var _a;
|
|
261
|
-
|
|
262
225
|
var result = _extends({}, col);
|
|
263
|
-
|
|
264
226
|
var sortable = col.code && (((_a = col.features) === null || _a === void 0 ? void 0 : _a.sortable) || sortMap.has(col.code));
|
|
265
227
|
var active = sortable && sortMap.has(col.code);
|
|
266
|
-
|
|
267
228
|
if (sortable) {
|
|
268
229
|
var sortIndex = -1;
|
|
269
230
|
var sortOrder = 'none';
|
|
270
|
-
|
|
271
231
|
if (active) {
|
|
272
232
|
var _sortMap$get = sortMap.get(col.code),
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
233
|
+
order = _sortMap$get.order,
|
|
234
|
+
index = _sortMap$get.index;
|
|
276
235
|
sortOrder = order;
|
|
277
236
|
sortIndex = index;
|
|
278
|
-
|
|
279
237
|
if (highlightColumnWhenActive) {
|
|
280
238
|
result.headerCellProps = mergeCellProps(col.headerCellProps, {
|
|
281
239
|
style: {
|
|
282
240
|
background: 'var(--header-highlight-bgcolor)'
|
|
283
241
|
}
|
|
284
242
|
});
|
|
285
|
-
|
|
286
243
|
result.getCellProps = function (value, row, rowIndex) {
|
|
287
244
|
var prevCellProps = internals.safeGetCellProps(col, row, rowIndex);
|
|
288
245
|
return mergeCellProps(prevCellProps, {
|
|
@@ -293,13 +250,11 @@ export function sort() {
|
|
|
293
250
|
};
|
|
294
251
|
}
|
|
295
252
|
}
|
|
296
|
-
|
|
297
253
|
var sortNode = /*#__PURE__*/React.createElement(SortHeaderCell, {
|
|
298
254
|
onToggle: function onToggle(e) {
|
|
299
255
|
if (stopClickEventPropagation) {
|
|
300
256
|
e.stopPropagation();
|
|
301
257
|
}
|
|
302
|
-
|
|
303
258
|
toggle(col.code);
|
|
304
259
|
},
|
|
305
260
|
sortOrder: sortOrder,
|
|
@@ -309,22 +264,19 @@ export function sort() {
|
|
|
309
264
|
}, internals.safeRenderHeader(_extends(_extends({}, col), {
|
|
310
265
|
title: col.title && col.title[0] ? col.title[0] : col.title
|
|
311
266
|
})));
|
|
312
|
-
|
|
313
267
|
var _sortNodeWithoutTitle = /*#__PURE__*/React.createElement(SortHeaderCell, {
|
|
314
268
|
onToggle: function onToggle(e) {
|
|
315
269
|
if (stopClickEventPropagation) {
|
|
316
270
|
e.stopPropagation();
|
|
317
271
|
}
|
|
318
|
-
|
|
319
272
|
toggle(col.code);
|
|
320
273
|
},
|
|
321
274
|
sortOrder: sortOrder,
|
|
322
275
|
column: col,
|
|
323
276
|
sortIndex: sortIndex,
|
|
324
277
|
sortOptions: sortOptions
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
|
|
278
|
+
});
|
|
279
|
+
// 开启标题行高自适应后,修改表头的渲染结构
|
|
328
280
|
if (col.renderHeader) {
|
|
329
281
|
result.title = col.renderHeader(result.title, _sortNodeWithoutTitle);
|
|
330
282
|
} else {
|
|
@@ -335,17 +287,13 @@ export function sort() {
|
|
|
335
287
|
}
|
|
336
288
|
}
|
|
337
289
|
}
|
|
338
|
-
|
|
339
290
|
if (!isLeafNode(col)) {
|
|
340
291
|
var _context3;
|
|
341
|
-
|
|
342
292
|
result.children = _mapInstanceProperty(_context3 = col.children).call(_context3, dfs);
|
|
343
293
|
}
|
|
344
|
-
|
|
345
294
|
return result;
|
|
346
295
|
}
|
|
347
296
|
}
|
|
348
|
-
|
|
349
297
|
function getNextOrder(order) {
|
|
350
298
|
var idx = orders.indexOf(order);
|
|
351
299
|
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,54 @@ 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
|
if (pipeline.isSameInputDataSource() && openKeys === pipeline.getFeatureOptions('lastOpenKeys')) {
|
|
75
63
|
return pipeline.getFeatureOptions('lastTreeMode');
|
|
76
64
|
}
|
|
77
|
-
|
|
78
65
|
pipeline.setFeatureOptions('lastOpenKeys', pipeline.getStateAtKey(stateKey));
|
|
79
66
|
var result = [];
|
|
80
67
|
dfs(input, 0);
|
|
81
|
-
|
|
82
68
|
function dfs(nodes, depth) {
|
|
83
69
|
if (nodes == null) {
|
|
84
70
|
return;
|
|
85
71
|
}
|
|
86
|
-
|
|
87
72
|
var _iterator = _createForOfIteratorHelper(nodes),
|
|
88
|
-
|
|
89
|
-
|
|
73
|
+
_step;
|
|
90
74
|
try {
|
|
91
75
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
92
76
|
var node = _step.value;
|
|
@@ -104,7 +88,6 @@ export function treeMode() {
|
|
|
104
88
|
rowKey: rowKey
|
|
105
89
|
};
|
|
106
90
|
result.push(_extends(_defineProperty({}, treeMetaKey, treeMeta), node));
|
|
107
|
-
|
|
108
91
|
if (!isLeaf && expanded) {
|
|
109
92
|
dfs(node.children, depth + 1);
|
|
110
93
|
}
|
|
@@ -115,39 +98,31 @@ export function treeMode() {
|
|
|
115
98
|
_iterator.f();
|
|
116
99
|
}
|
|
117
100
|
}
|
|
118
|
-
|
|
119
101
|
pipeline.setFeatureOptions('lastTreeMode', result);
|
|
120
102
|
return result;
|
|
121
103
|
}
|
|
122
|
-
|
|
123
104
|
function processColumns(columns) {
|
|
124
105
|
if (columns.length === 0) {
|
|
125
106
|
return columns;
|
|
126
107
|
}
|
|
127
|
-
|
|
128
108
|
var expandColIndex = _findIndexInstanceProperty(columns).call(columns, function (_ref) {
|
|
129
109
|
var code = _ref.code;
|
|
130
110
|
return code && opts.expandColCode === code;
|
|
131
111
|
});
|
|
132
|
-
|
|
133
112
|
expandColIndex = expandColIndex === -1 ? 0 : expandColIndex;
|
|
134
113
|
var expandCol = columns[expandColIndex];
|
|
135
|
-
|
|
136
114
|
var render = function render(value, record, recordIndex) {
|
|
137
115
|
var content = internals.safeRender(expandCol, record, recordIndex);
|
|
138
|
-
|
|
139
116
|
if (record[treeMetaKey] == null) {
|
|
140
117
|
// 没有 treeMeta 信息的话,就返回原先的渲染结果
|
|
141
118
|
return content;
|
|
142
119
|
}
|
|
143
|
-
|
|
144
120
|
var _record$treeMetaKey = record[treeMetaKey],
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
121
|
+
rowKey = _record$treeMetaKey.rowKey,
|
|
122
|
+
depth = _record$treeMetaKey.depth,
|
|
123
|
+
isLeaf = _record$treeMetaKey.isLeaf,
|
|
124
|
+
expanded = _record$treeMetaKey.expanded;
|
|
149
125
|
var indent = iconIndent + depth * indentSize;
|
|
150
|
-
|
|
151
126
|
if (isLeaf) {
|
|
152
127
|
return /*#__PURE__*/React.createElement(InlineFlexCell, {
|
|
153
128
|
className: cx('expansion-cell', Classes.leaf)
|
|
@@ -157,15 +132,12 @@ export function treeMode() {
|
|
|
157
132
|
}
|
|
158
133
|
}, content));
|
|
159
134
|
}
|
|
160
|
-
|
|
161
135
|
var onClick = function onClick(e) {
|
|
162
136
|
if (stopClickEventPropagation) {
|
|
163
137
|
e.stopPropagation();
|
|
164
138
|
}
|
|
165
|
-
|
|
166
139
|
toggle(rowKey);
|
|
167
140
|
};
|
|
168
|
-
|
|
169
141
|
var expandCls = expanded ? Classes.expanded : Classes.collapsed;
|
|
170
142
|
return /*#__PURE__*/React.createElement(ExpansionCell, {
|
|
171
143
|
className: cx('expansion-cell', expandCls),
|
|
@@ -192,29 +164,23 @@ export function treeMode() {
|
|
|
192
164
|
onClick: clickArea === 'icon' ? onClick : undefined
|
|
193
165
|
}), content);
|
|
194
166
|
};
|
|
195
|
-
|
|
196
167
|
var getCellProps = function getCellProps(value, record, rowIndex) {
|
|
197
168
|
var prevProps = internals.safeGetCellProps(expandCol, record, rowIndex);
|
|
198
|
-
|
|
199
169
|
if (record[treeMetaKey] == null) {
|
|
200
170
|
// 没有 treeMeta 信息的话,就返回原先的 cellProps
|
|
201
171
|
return prevProps;
|
|
202
172
|
}
|
|
203
|
-
|
|
204
173
|
var _record$treeMetaKey2 = record[treeMetaKey],
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
174
|
+
isLeaf = _record$treeMetaKey2.isLeaf,
|
|
175
|
+
rowKey = _record$treeMetaKey2.rowKey;
|
|
208
176
|
if (isLeaf) {
|
|
209
177
|
return prevProps;
|
|
210
178
|
}
|
|
211
|
-
|
|
212
179
|
return mergeCellProps(prevProps, {
|
|
213
180
|
onClick: function onClick(e) {
|
|
214
181
|
if (stopClickEventPropagation) {
|
|
215
182
|
e.stopPropagation();
|
|
216
183
|
}
|
|
217
|
-
|
|
218
184
|
toggle(rowKey);
|
|
219
185
|
},
|
|
220
186
|
style: {
|
|
@@ -222,7 +188,6 @@ export function treeMode() {
|
|
|
222
188
|
}
|
|
223
189
|
});
|
|
224
190
|
};
|
|
225
|
-
|
|
226
191
|
columns[expandColIndex] = _extends(_extends({}, expandCol), {
|
|
227
192
|
title: /*#__PURE__*/React.createElement("span", {
|
|
228
193
|
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
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare function getEventCoordinates(event: MouseEvent | TouchEvent): {
|
|
2
|
+
clientX: number;
|
|
3
|
+
clientY: number;
|
|
4
|
+
};
|
|
5
|
+
export declare function getEventTarget(event: MouseEvent | TouchEvent): EventTarget;
|
|
6
|
+
export declare function isTouchEvent(event: MouseEvent | TouchEvent): event is TouchEvent;
|
|
7
|
+
export declare function addPointerEventListeners(element: Element | Window | Document, handlers: {
|
|
8
|
+
onPointerMove: (e: MouseEvent | TouchEvent) => void;
|
|
9
|
+
onPointerUp: (e: MouseEvent | TouchEvent) => void;
|
|
10
|
+
}, isTouchStart: boolean): void;
|
|
11
|
+
export declare function removePointerEventListeners(element: Element | Window | Document, handlers: {
|
|
12
|
+
onPointerMove: (e: MouseEvent | TouchEvent) => void;
|
|
13
|
+
onPointerUp: (e: MouseEvent | TouchEvent) => void;
|
|
14
|
+
}, isTouchStart: boolean): void;
|
|
15
|
+
export declare function hasMovedEnough(startX: number, startY: number, endX: number, endY: number, threshold?: number): boolean;
|