@kdcloudjs/table 1.2.0-canary.16 → 1.2.0-canary.17-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/LICENSE +568 -568
- package/README.md +111 -111
- package/dist/@kdcloudjs/table.css +1 -1
- package/dist/@kdcloudjs/table.js +4596 -5714
- package/dist/@kdcloudjs/table.js.map +1 -1
- package/dist/@kdcloudjs/table.min.css +1 -1
- package/dist/@kdcloudjs/table.min.js +18 -16
- package/dist/@kdcloudjs/table.min.js.map +1 -1
- package/dist/kd-ui-complete.less +777 -777
- package/es/_utils/arrayUtil.js +0 -3
- package/es/_utils/devwarning.js +0 -1
- package/es/_utils/formatUtil.js +36 -101
- package/es/_utils/hooks.js +21 -45
- package/es/_utils/index.js +0 -2
- package/es/_utils/numberUtil.js +32 -55
- package/es/_utils/omit.js +0 -2
- package/es/_utils/type.js +0 -2
- package/es/_utils/usePopper.js +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 +9 -48
- package/es/style/color/colors.less +1 -1
- package/es/style/core/index.less +1 -1
- package/es/style/core/motion/other.less +27 -27
- package/es/style/core/motion/slide.less +53 -53
- package/es/style/core/motion.less +1 -1
- package/es/style/core/reset.less +185 -185
- package/es/style/index.less +1 -1
- package/es/style/mixins/index.less +18 -18
- package/es/style/mixins/overlay.less +21 -21
- package/es/style/mixins/reset.less +12 -12
- package/es/style/themes/default.less +445 -445
- package/es/table/base/calculations.js +25 -75
- package/es/table/base/colgroup.js +0 -1
- package/es/table/base/empty.js +6 -6
- package/es/table/base/header.js +19 -74
- package/es/table/base/helpers/SpanManager.js +4 -11
- package/es/table/base/helpers/TableDOMUtils.js +7 -30
- 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 +17 -39
- package/es/table/base/loading.js +8 -10
- package/es/table/base/renderTemplates.js +41 -59
- 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/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 +18 -91
- 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 +26 -50
- 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 +74 -154
- package/es/table/pipeline/features/rowDetail.js +4 -43
- package/es/table/pipeline/features/rowDrag.js +64 -80
- package/es/table/pipeline/features/rowGrouping.js +4 -37
- package/es/table/pipeline/features/singleSelect.js +0 -24
- package/es/table/pipeline/features/sort.js +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-tree-table/buildCrossTreeTable.js +22 -57
- package/es/table/pivot/cross-tree-table/cross-tree-table.js +35 -61
- package/es/table/pivot/pivot-utils/buildDrillTree.js +10 -23
- package/es/table/pivot/pivot-utils/builders.js +34 -74
- package/es/table/pivot/pivot-utils/convert-utils.js +16 -42
- package/es/table/pivot/pivot-utils/simpleEncode.js +0 -1
- package/es/table/style/index.less +1 -1
- package/es/table/transforms/autoRowSpan.js +1 -15
- package/es/table/transforms/autoWidth.js +13 -35
- package/es/table/transforms/buildTree.js +1 -2
- package/es/table/transforms/columnHover.js +9 -15
- package/es/table/transforms/columnRangeHover.js +12 -19
- package/es/table/transforms/columnResize.js +18 -42
- package/es/table/transforms/flatten.js +0 -3
- package/es/table/transforms/orderField.js +0 -3
- package/es/table/transforms/sort.js +42 -96
- package/es/table/transforms/tips.js +5 -10
- package/es/table/transforms/treeMode.js +36 -77
- package/es/table/transforms/visible.js +0 -2
- package/es/table/use/useResizeObserver.js +1 -4
- package/es/table/utils/applyTransforms.js +0 -1
- package/es/table/utils/buildTree.js +7 -22
- package/es/table/utils/collectNodes.js +4 -13
- package/es/table/utils/console.js +0 -14
- package/es/table/utils/copyToClipboard.js +0 -4
- package/es/table/utils/element.js +14 -41
- package/es/table/utils/exportTableAsExcel.js +7 -43
- package/es/table/utils/getTreeDepth.js +4 -12
- package/es/table/utils/groupBy.js +4 -13
- package/es/table/utils/layeredFilter.js +0 -4
- package/es/table/utils/layeredSort.js +0 -5
- package/es/table/utils/makeRecursiveMapper.js +4 -15
- package/es/table/utils/mergeCellProps.js +6 -14
- package/es/table/utils/others.js +6 -19
- package/es/table/utils/proto.js +2 -30
- package/es/table/utils/smartCompare.js +4 -12
- package/es/table/utils/traverseColumn.js +5 -18
- package/es/table/utils/tree-data-helpers/StrictTreeDataHelper.js +5 -27
- package/es/table/utils/tree-data-helpers/TreeDataHelper.js +19 -74
- 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 +79 -166
- package/lib/config-provider/ConfigContext.js +2 -6
- package/lib/config-provider/compDefaultProps.js +1 -3
- package/lib/config-provider/configProvider.js +6 -22
- package/lib/config-provider/defaultConfig.js +1 -7
- package/lib/config-provider/index.js +1 -8
- package/lib/index.js +2 -8
- package/lib/locale/index.js +3 -11
- package/lib/locale/locale.js +13 -69
- package/lib/locale/zh-CN.js +1 -2
- package/lib/style/color/colors.less +1 -1
- package/lib/style/components.less +1 -1
- package/lib/style/core/index.less +1 -1
- package/lib/style/core/motion/other.less +27 -27
- package/lib/style/core/motion/slide.less +53 -53
- package/lib/style/core/motion.less +1 -1
- package/lib/style/core/reset.less +185 -185
- package/lib/style/index.less +1 -1
- package/lib/style/mixins/index.less +18 -18
- package/lib/style/mixins/overlay.less +21 -21
- package/lib/style/mixins/reset.less +12 -12
- package/lib/style/themes/default.less +445 -445
- package/lib/table/base/calculations.js +25 -86
- package/lib/table/base/colgroup.js +0 -5
- package/lib/table/base/empty.js +8 -20
- package/lib/table/base/header.js +19 -84
- package/lib/table/base/helpers/SpanManager.js +6 -16
- package/lib/table/base/helpers/TableDOMUtils.js +7 -33
- package/lib/table/base/helpers/__test__/SpanManager.test.js +2 -4
- package/lib/table/base/helpers/__test__/TableDOMUtils.test.js +0 -5
- package/lib/table/base/helpers/__test__/rowHeightManager.test.js +0 -1
- package/lib/table/base/helpers/getRichVisibleRectsStream.js +13 -64
- 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 -75
- package/lib/table/base/styles.js +9 -37
- package/lib/table/base/table.js +122 -243
- package/lib/table/base/utils.js +27 -109
- package/lib/table/common-views.js +4 -24
- package/lib/table/index.js +0 -13
- package/lib/table/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 +18 -63
- package/lib/table/pipeline/features/contextMenu.js +20 -117
- package/lib/table/pipeline/features/filter/DefaultFilterContent.js +17 -52
- package/lib/table/pipeline/features/filter/DefaultFilterIcon.js +1 -4
- package/lib/table/pipeline/features/filter/Filter.js +29 -76
- package/lib/table/pipeline/features/filter/FilterPanel.js +14 -44
- package/lib/table/pipeline/features/filter/index.js +0 -5
- package/lib/table/pipeline/features/filter/util.js +2 -10
- package/lib/table/pipeline/features/footerDataSource.js +1 -12
- package/lib/table/pipeline/features/index.js +0 -23
- package/lib/table/pipeline/features/mergeCellHover.js +0 -5
- package/lib/table/pipeline/features/multiSelect.js +15 -71
- package/lib/table/pipeline/features/rangeSelection.js +76 -175
- package/lib/table/pipeline/features/rowDetail.js +4 -67
- package/lib/table/pipeline/features/rowDrag.js +66 -94
- package/lib/table/pipeline/features/rowGrouping.js +4 -57
- package/lib/table/pipeline/features/singleSelect.js +0 -34
- package/lib/table/pipeline/features/sort.js +37 -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 +2 -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-tree-table/buildCrossTreeTable.js +22 -70
- package/lib/table/pivot/cross-tree-table/cross-tree-table.js +36 -73
- package/lib/table/pivot/cross-tree-table/index.js +0 -3
- package/lib/table/pivot/pivot-utils/buildDrillTree.js +10 -29
- package/lib/table/pivot/pivot-utils/builders.js +34 -85
- package/lib/table/pivot/pivot-utils/convert-utils.js +16 -60
- package/lib/table/pivot/pivot-utils/index.js +0 -7
- package/lib/table/pivot/pivot-utils/simpleEncode.js +0 -2
- package/lib/table/style/css.js +0 -1
- package/lib/table/style/index.js +0 -1
- package/lib/table/style/index.less +1 -1
- package/lib/table/transforms/autoRowSpan.js +1 -21
- package/lib/table/transforms/autoWidth.js +15 -58
- package/lib/table/transforms/buildTree.js +1 -4
- package/lib/table/transforms/columnHover.js +9 -22
- package/lib/table/transforms/columnRangeHover.js +12 -27
- package/lib/table/transforms/columnResize.js +20 -63
- package/lib/table/transforms/flatten.js +0 -5
- package/lib/table/transforms/index.js +0 -12
- package/lib/table/transforms/orderField.js +0 -7
- package/lib/table/transforms/sort.js +44 -122
- package/lib/table/transforms/tips.js +5 -20
- package/lib/table/transforms/treeMode.js +38 -106
- package/lib/table/transforms/visible.js +0 -7
- package/lib/table/transforms/warnTransformsDeprecated.js +0 -4
- package/lib/table/use/useResizeObserver.js +2 -10
- package/lib/table/utils/applyTransforms.js +0 -2
- package/lib/table/utils/browserType.js +2 -3
- package/lib/table/utils/buildTree.js +7 -33
- package/lib/table/utils/collectNodes.js +4 -18
- package/lib/table/utils/console.js +2 -19
- package/lib/table/utils/copyToClipboard.js +1 -8
- package/lib/table/utils/element.js +14 -46
- package/lib/table/utils/exportTableAsExcel.js +7 -52
- package/lib/table/utils/getTreeDepth.js +4 -17
- package/lib/table/utils/groupBy.js +4 -17
- package/lib/table/utils/index.js +0 -21
- 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 +7 -38
- package/lib/table/utils/tree-data-helpers/TreeDataHelper.js +21 -90
- package/package.json +219 -218
|
@@ -15,15 +15,12 @@ import { internals } from '../../internals';
|
|
|
15
15
|
import { collectNodes, isLeafNode, mergeCellProps } from '../../utils';
|
|
16
16
|
import { flatMap } from '../../utils/others';
|
|
17
17
|
import { Classes } from '../../base';
|
|
18
|
-
|
|
19
18
|
var groupingMetaSymbol = _Symbol('row-grouping-meta');
|
|
20
|
-
|
|
21
19
|
function attachGroupingMeta(row) {
|
|
22
20
|
return _extends(_defineProperty({}, groupingMetaSymbol, {
|
|
23
21
|
expandable: !isLeafNode(row)
|
|
24
22
|
}), row);
|
|
25
23
|
}
|
|
26
|
-
|
|
27
24
|
function getGroupingMeta(row) {
|
|
28
25
|
if (row[groupingMetaSymbol] == null) {
|
|
29
26
|
return {
|
|
@@ -31,13 +28,11 @@ function getGroupingMeta(row) {
|
|
|
31
28
|
expandable: false
|
|
32
29
|
};
|
|
33
30
|
}
|
|
34
|
-
|
|
35
31
|
return {
|
|
36
32
|
isGroupHeader: true,
|
|
37
33
|
expandable: row[groupingMetaSymbol].expandable
|
|
38
34
|
};
|
|
39
35
|
}
|
|
40
|
-
|
|
41
36
|
function rowGroupingRowPropsGetter(row) {
|
|
42
37
|
if (getGroupingMeta(row).isGroupHeader) {
|
|
43
38
|
return {
|
|
@@ -45,74 +40,56 @@ function rowGroupingRowPropsGetter(row) {
|
|
|
45
40
|
};
|
|
46
41
|
}
|
|
47
42
|
}
|
|
48
|
-
|
|
49
43
|
export function rowGrouping() {
|
|
50
44
|
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
51
45
|
return function (pipeline) {
|
|
52
46
|
var _context;
|
|
53
|
-
|
|
54
47
|
var _a, _b, _c;
|
|
55
|
-
|
|
56
48
|
var stateKey = 'rowGrouping';
|
|
57
49
|
var indents = pipeline.ctx.indents;
|
|
58
50
|
var textOffset = indents.iconIndent + indents.iconWidth + indents.iconGap;
|
|
59
51
|
var primaryKey = pipeline.ensurePrimaryKey('rowGrouping');
|
|
60
|
-
|
|
61
52
|
if (typeof primaryKey !== 'string') {
|
|
62
53
|
throw new Error('rowGrouping 仅支持字符串作为 primaryKey');
|
|
63
54
|
}
|
|
64
|
-
|
|
65
55
|
var openKeys = (_c = (_b = (_a = opts.openKeys) !== null && _a !== void 0 ? _a : pipeline.getStateAtKey(stateKey)) !== null && _b !== void 0 ? _b : opts.defaultOpenAll ? _mapInstanceProperty(_context = pipeline.getDataSource()).call(_context, function (row) {
|
|
66
56
|
return row[primaryKey];
|
|
67
57
|
}) : opts.defaultOpenKeys) !== null && _c !== void 0 ? _c : [];
|
|
68
58
|
var openKeySet = new _Set(openKeys);
|
|
69
|
-
|
|
70
59
|
var onChangeOpenKeys = function onChangeOpenKeys(nextKeys, key, action) {
|
|
71
60
|
var _a;
|
|
72
|
-
|
|
73
61
|
(_a = opts.onChangeOpenKeys) === null || _a === void 0 ? void 0 : _a.call(opts, nextKeys, key, action);
|
|
74
62
|
pipeline.setStateAtKey(stateKey, nextKeys, {
|
|
75
63
|
key: key,
|
|
76
64
|
action: action
|
|
77
65
|
});
|
|
78
66
|
};
|
|
79
|
-
|
|
80
67
|
return pipeline.mapDataSource(processDataSource).mapColumns(processColumns).appendRowPropsGetter(rowGroupingRowPropsGetter);
|
|
81
|
-
|
|
82
68
|
function processDataSource(input) {
|
|
83
69
|
return flatMap(input, function (row) {
|
|
84
70
|
var result = [attachGroupingMeta(row)];
|
|
85
71
|
var expanded = openKeySet.has(row[primaryKey]);
|
|
86
|
-
|
|
87
72
|
if (expanded) {
|
|
88
73
|
if (Array.isArray(row.children)) {
|
|
89
74
|
result = _concatInstanceProperty(result).call(result, row.children);
|
|
90
75
|
}
|
|
91
76
|
}
|
|
92
|
-
|
|
93
77
|
return result;
|
|
94
78
|
});
|
|
95
79
|
}
|
|
96
|
-
|
|
97
80
|
function processColumns(columns) {
|
|
98
81
|
var _context3;
|
|
99
|
-
|
|
100
82
|
if (columns.length === 0) {
|
|
101
83
|
return columns;
|
|
102
84
|
}
|
|
103
|
-
|
|
104
85
|
var columnFlatCount = collectNodes(columns, 'leaf-only').length;
|
|
105
|
-
|
|
106
86
|
var _columns = _toArray(columns),
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
87
|
+
firstCol = _columns[0],
|
|
88
|
+
others = _sliceInstanceProperty(_columns).call(_columns, 1);
|
|
110
89
|
var render = function render(value, row, rowIndex) {
|
|
111
90
|
var _a, _b;
|
|
112
|
-
|
|
113
91
|
var content = internals.safeRender(firstCol, row, rowIndex);
|
|
114
92
|
var meta = getGroupingMeta(row);
|
|
115
|
-
|
|
116
93
|
if (!meta.isGroupHeader || !meta.expandable) {
|
|
117
94
|
var marginLeft = textOffset + (meta.isGroupHeader ? 0 : indents.indentSize);
|
|
118
95
|
return /*#__PURE__*/React.createElement(InlineFlexCell, {
|
|
@@ -121,7 +98,6 @@ export function rowGrouping() {
|
|
|
121
98
|
}
|
|
122
99
|
}, meta.isGroupHeader ? (_a = row.groupTitle) !== null && _a !== void 0 ? _a : content : content);
|
|
123
100
|
}
|
|
124
|
-
|
|
125
101
|
var expanded = openKeySet.has(row[primaryKey]);
|
|
126
102
|
var expandCls = expanded ? Classes.expanded : Classes.collapsed;
|
|
127
103
|
return /*#__PURE__*/React.createElement(ExpansionCell, {
|
|
@@ -134,39 +110,31 @@ export function rowGrouping() {
|
|
|
134
110
|
}
|
|
135
111
|
}), (_b = row.groupTitle) !== null && _b !== void 0 ? _b : content);
|
|
136
112
|
};
|
|
137
|
-
|
|
138
113
|
var getCellProps = function getCellProps(value, row, rowIndex) {
|
|
139
114
|
var _a;
|
|
140
|
-
|
|
141
115
|
var meta = getGroupingMeta(row);
|
|
142
|
-
|
|
143
116
|
if (!meta.isGroupHeader) {
|
|
144
117
|
return;
|
|
145
118
|
}
|
|
146
|
-
|
|
147
119
|
var expandable = meta.expandable;
|
|
148
120
|
var rowKey = row[primaryKey];
|
|
149
121
|
var expanded = openKeySet.has(rowKey);
|
|
150
122
|
var onClick;
|
|
151
|
-
|
|
152
123
|
if (expandable) {
|
|
153
124
|
onClick = function onClick(e) {
|
|
154
125
|
if (opts.stopClickEventPropagation) {
|
|
155
126
|
e.stopPropagation();
|
|
156
127
|
}
|
|
157
|
-
|
|
158
128
|
if (expanded) {
|
|
159
129
|
onChangeOpenKeys(_filterInstanceProperty(openKeys).call(openKeys, function (key) {
|
|
160
130
|
return key !== rowKey;
|
|
161
131
|
}), rowKey, 'collapse');
|
|
162
132
|
} else {
|
|
163
133
|
var _context2;
|
|
164
|
-
|
|
165
134
|
onChangeOpenKeys(_concatInstanceProperty(_context2 = []).call(_context2, _toConsumableArray(openKeys), [rowKey]), rowKey, 'expand');
|
|
166
135
|
}
|
|
167
136
|
};
|
|
168
137
|
}
|
|
169
|
-
|
|
170
138
|
var prevProps = (_a = firstCol.getCellProps) === null || _a === void 0 ? void 0 : _a.call(firstCol, value, row, rowIndex);
|
|
171
139
|
return mergeCellProps(prevProps, {
|
|
172
140
|
onClick: onClick,
|
|
@@ -175,14 +143,13 @@ export function rowGrouping() {
|
|
|
175
143
|
}
|
|
176
144
|
});
|
|
177
145
|
};
|
|
178
|
-
|
|
179
146
|
return _concatInstanceProperty(_context3 = [_extends(_extends({}, firstCol), {
|
|
180
|
-
title: /*#__PURE__*/React.createElement("div", {
|
|
147
|
+
title: ( /*#__PURE__*/React.createElement("div", {
|
|
181
148
|
style: {
|
|
182
149
|
display: 'inline-block',
|
|
183
150
|
marginLeft: textOffset
|
|
184
151
|
}
|
|
185
|
-
}, internals.safeRenderHeader(firstCol)),
|
|
152
|
+
}, internals.safeRenderHeader(firstCol))),
|
|
186
153
|
render: render,
|
|
187
154
|
getCellProps: getCellProps,
|
|
188
155
|
getSpanRect: function getSpanRect(value, row, rowIndex) {
|
|
@@ -9,28 +9,21 @@ export function singleSelect() {
|
|
|
9
9
|
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
10
10
|
return function singleSelectStep(pipeline) {
|
|
11
11
|
var _context;
|
|
12
|
-
|
|
13
12
|
var _a, _b, _c, _d, _e, _f;
|
|
14
|
-
|
|
15
13
|
var Radio = pipeline.ctx.components.Radio;
|
|
16
|
-
|
|
17
14
|
if (Radio == null) {
|
|
18
15
|
throw new Error('使用 singleSelect 之前需要通过 pipeline context 设置 components.Radio');
|
|
19
16
|
}
|
|
20
|
-
|
|
21
17
|
var stateKey = 'singleSelect';
|
|
22
18
|
var clickArea = (_a = opts.clickArea) !== null && _a !== void 0 ? _a : 'radio';
|
|
23
19
|
var isDisabled = (_b = opts.isDisabled) !== null && _b !== void 0 ? _b : always(false);
|
|
24
20
|
var primaryKey = pipeline.ensurePrimaryKey('singleSelect');
|
|
25
21
|
var value = (_d = (_c = opts.value) !== null && _c !== void 0 ? _c : pipeline.getStateAtKey(stateKey)) !== null && _d !== void 0 ? _d : opts.defaultValue;
|
|
26
|
-
|
|
27
22
|
var onChange = function onChange(rowKey) {
|
|
28
23
|
var _a;
|
|
29
|
-
|
|
30
24
|
(_a = opts.onChange) === null || _a === void 0 ? void 0 : _a.call(opts, rowKey);
|
|
31
25
|
pipeline.setStateAtKey(stateKey, rowKey);
|
|
32
26
|
};
|
|
33
|
-
|
|
34
27
|
var radioColumn = _extends(_extends({
|
|
35
28
|
name: '',
|
|
36
29
|
width: 50,
|
|
@@ -38,9 +31,7 @@ export function singleSelect() {
|
|
|
38
31
|
}, opts.radioColumn), {
|
|
39
32
|
getCellProps: function getCellProps(value, row, rowIndex) {
|
|
40
33
|
var _a, _b;
|
|
41
|
-
|
|
42
34
|
var preCellProps = (_b = (_a = opts.radioColumn) === null || _a === void 0 ? void 0 : _a.getCellProps) === null || _b === void 0 ? void 0 : _b.call(_a, value, row, rowIndex);
|
|
43
|
-
|
|
44
35
|
if (clickArea === 'cell') {
|
|
45
36
|
var rowKey = internals.safeGetRowKey(primaryKey, row, rowIndex);
|
|
46
37
|
var disabled = isDisabled(row, rowIndex);
|
|
@@ -52,74 +43,59 @@ export function singleSelect() {
|
|
|
52
43
|
if (opts.stopClickEventPropagation) {
|
|
53
44
|
e.stopPropagation();
|
|
54
45
|
}
|
|
55
|
-
|
|
56
46
|
onChange(rowKey);
|
|
57
47
|
}
|
|
58
48
|
});
|
|
59
49
|
}
|
|
60
|
-
|
|
61
50
|
return preCellProps;
|
|
62
51
|
},
|
|
63
52
|
render: function render(_, row, rowIndex) {
|
|
64
53
|
if (row[pipeline.getFeatureOptions('footerRowMetaKey')]) {
|
|
65
54
|
return null;
|
|
66
55
|
}
|
|
67
|
-
|
|
68
56
|
var rowKey = internals.safeGetRowKey(primaryKey, row, rowIndex);
|
|
69
57
|
return /*#__PURE__*/React.createElement(Radio, {
|
|
70
58
|
checked: value === rowKey,
|
|
71
59
|
disabled: isDisabled(row, rowIndex),
|
|
72
60
|
onChange: clickArea === 'radio' ? function (arg1, arg2) {
|
|
73
61
|
var _a;
|
|
74
|
-
|
|
75
62
|
var nativeEvent = (_a = arg2 === null || arg2 === void 0 ? void 0 : arg2.nativeEvent) !== null && _a !== void 0 ? _a : arg1 === null || arg1 === void 0 ? void 0 : arg1.nativeEvent;
|
|
76
|
-
|
|
77
63
|
if (nativeEvent && opts.stopClickEventPropagation) {
|
|
78
64
|
nativeEvent.stopPropagation();
|
|
79
65
|
}
|
|
80
|
-
|
|
81
66
|
onChange(rowKey);
|
|
82
67
|
} : undefined
|
|
83
68
|
});
|
|
84
69
|
},
|
|
85
70
|
features: _extends(_extends({}, (_e = opts.radioColumn) === null || _e === void 0 ? void 0 : _e.features), _defineProperty({}, SINGLE_SELECT_MARK_PROPNAME, true))
|
|
86
71
|
});
|
|
87
|
-
|
|
88
72
|
var nextColumns = _sliceInstanceProperty(_context = pipeline.getColumns()).call(_context);
|
|
89
|
-
|
|
90
73
|
var radioPlacement = (_f = opts.radioPlacement) !== null && _f !== void 0 ? _f : 'start';
|
|
91
|
-
|
|
92
74
|
if (radioPlacement === 'start') {
|
|
93
75
|
nextColumns.unshift(radioColumn);
|
|
94
76
|
} else {
|
|
95
77
|
nextColumns.push(radioColumn);
|
|
96
78
|
}
|
|
97
|
-
|
|
98
79
|
pipeline.columns(nextColumns);
|
|
99
80
|
pipeline.appendRowPropsGetter(function (row, rowIndex) {
|
|
100
81
|
var rowKey = internals.safeGetRowKey(primaryKey, row, rowIndex);
|
|
101
82
|
var style = {};
|
|
102
83
|
var className;
|
|
103
84
|
var onClick;
|
|
104
|
-
|
|
105
85
|
if (opts.highlightRowWhenSelected) {
|
|
106
86
|
if (value === rowKey) {
|
|
107
87
|
className = 'highlight';
|
|
108
88
|
}
|
|
109
89
|
}
|
|
110
|
-
|
|
111
90
|
if (clickArea === 'row' && !isDisabled(row, rowIndex)) {
|
|
112
91
|
style.cursor = 'pointer';
|
|
113
|
-
|
|
114
92
|
onClick = function onClick(e) {
|
|
115
93
|
if (opts.stopClickEventPropagation) {
|
|
116
94
|
e.stopPropagation();
|
|
117
95
|
}
|
|
118
|
-
|
|
119
96
|
onChange(rowKey);
|
|
120
97
|
};
|
|
121
98
|
}
|
|
122
|
-
|
|
123
99
|
return {
|
|
124
100
|
className: className,
|
|
125
101
|
style: style,
|
|
@@ -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
|
-
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 _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,13 @@ function SortIcon(_ref) {
|
|
|
52
46
|
d: "M24 24L16 32 8 24z "
|
|
53
47
|
}));
|
|
54
48
|
}
|
|
55
|
-
|
|
56
49
|
function DefaultSortHeaderCell(_ref2) {
|
|
57
|
-
var _cx;
|
|
58
|
-
|
|
59
50
|
var children = _ref2.children,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
51
|
+
column = _ref2.column,
|
|
52
|
+
onToggle = _ref2.onToggle,
|
|
53
|
+
sortOrder = _ref2.sortOrder,
|
|
54
|
+
sortIndex = _ref2.sortIndex,
|
|
55
|
+
sortOptions = _ref2.sortOptions;
|
|
65
56
|
// 通过 justify-content 来与 col.align 保持对齐方向一致
|
|
66
57
|
var justifyContent = column.align === 'right' ? 'flex-end' : column.align === 'center' ? 'center' : 'flex-start';
|
|
67
58
|
return /*#__PURE__*/React.createElement(TableHeaderCell, {
|
|
@@ -75,10 +66,10 @@ function DefaultSortHeaderCell(_ref2) {
|
|
|
75
66
|
marginLeft: 2,
|
|
76
67
|
flexShrink: 0
|
|
77
68
|
},
|
|
78
|
-
className: cx((
|
|
69
|
+
className: cx(_defineProperty(_defineProperty({}, Classes.tableSortIcon, true), "active", sortOrder === 'desc' || sortOrder === 'asc')),
|
|
79
70
|
size: 16,
|
|
80
71
|
order: sortOrder
|
|
81
|
-
}), sortOptions.mode === 'multiple' && sortIndex !== -1 && /*#__PURE__*/React.createElement("div", {
|
|
72
|
+
}), sortOptions.mode === 'multiple' && sortIndex !== -1 && ( /*#__PURE__*/React.createElement("div", {
|
|
82
73
|
style: {
|
|
83
74
|
userSelect: 'none',
|
|
84
75
|
marginLeft: 2,
|
|
@@ -87,50 +78,41 @@ function DefaultSortHeaderCell(_ref2) {
|
|
|
87
78
|
fontSize: 10,
|
|
88
79
|
fontFamily: 'monospace'
|
|
89
80
|
}
|
|
90
|
-
}, sortIndex + 1));
|
|
81
|
+
}, sortIndex + 1)));
|
|
91
82
|
}
|
|
92
|
-
|
|
93
83
|
function hasAnySortableColumns(cols) {
|
|
94
84
|
return cols.some(function (col) {
|
|
95
85
|
var _a;
|
|
96
|
-
|
|
97
86
|
return Boolean((_a = col.features) === null || _a === void 0 ? void 0 : _a.sortable) || !isLeafNode(col) && hasAnySortableColumns(col.children);
|
|
98
87
|
});
|
|
99
88
|
}
|
|
100
|
-
|
|
101
89
|
var TableHeaderCell = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n cursor: pointer;\n display: flex;\n align-items: center;\n // flex: auto;\n"])));
|
|
102
90
|
var stateKey = 'sort';
|
|
103
91
|
export function sort() {
|
|
104
92
|
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
105
93
|
return function sortStep(pipeline) {
|
|
106
94
|
var _a, _b, _c;
|
|
107
|
-
|
|
108
95
|
var _opts$orders = opts.orders,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
96
|
+
orders = _opts$orders === void 0 ? ['desc', 'asc', 'none'] : _opts$orders,
|
|
97
|
+
_opts$mode = opts.mode,
|
|
98
|
+
mode = _opts$mode === void 0 ? 'multiple' : _opts$mode,
|
|
99
|
+
_opts$SortHeaderCell = opts.SortHeaderCell,
|
|
100
|
+
SortHeaderCell = _opts$SortHeaderCell === void 0 ? DefaultSortHeaderCell : _opts$SortHeaderCell,
|
|
101
|
+
keepDataSource = opts.keepDataSource,
|
|
102
|
+
highlightColumnWhenActive = opts.highlightColumnWhenActive,
|
|
103
|
+
stopClickEventPropagation = opts.stopClickEventPropagation,
|
|
104
|
+
sortIconHoverShow = opts.sortIconHoverShow;
|
|
118
105
|
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
106
|
var activeSorts = _filterInstanceProperty(inputSorts).call(inputSorts, function (s) {
|
|
121
107
|
return s.order !== 'none';
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
|
|
108
|
+
});
|
|
109
|
+
// 单字段排序的情况下 sorts 中只有第一个排序字段才会生效
|
|
125
110
|
var sorts = mode === 'multiple' ? activeSorts : _sliceInstanceProperty(activeSorts).call(activeSorts, 0, 1);
|
|
126
|
-
|
|
127
111
|
var onChangeSortsInMultipleMode = function onChangeSortsInMultipleMode(nextSorts, currentSort) {
|
|
128
112
|
var _a;
|
|
129
|
-
|
|
130
113
|
(_a = opts.onChangeSorts) === null || _a === void 0 ? void 0 : _a.call(opts, nextSorts, currentSort);
|
|
131
114
|
pipeline.setStateAtKey(stateKey, nextSorts);
|
|
132
115
|
};
|
|
133
|
-
|
|
134
116
|
var onChangeSorts = mode === 'multiple' ? onChangeSortsInMultipleMode : function (nextSorts, currentSort) {
|
|
135
117
|
// 单字段排序的情况下,nextSorts 中只有最后一个排序字段才会生效
|
|
136
118
|
var len = nextSorts.length;
|
|
@@ -153,56 +135,46 @@ export function sort() {
|
|
|
153
135
|
}));
|
|
154
136
|
var dataSource = pipeline.getDataSource();
|
|
155
137
|
var columns = pipeline.getColumns();
|
|
156
|
-
|
|
157
138
|
if (process.env.NODE_ENV !== 'production') {
|
|
158
139
|
if (!hasAnySortableColumns(columns)) {
|
|
159
140
|
console.warn('commonTransform.sort 缺少可排序的列,请通过 column.features.sortable 来指定哪些列可排序', columns);
|
|
160
141
|
}
|
|
161
142
|
}
|
|
162
|
-
|
|
163
143
|
pipeline.dataSource(processDataSource(dataSource));
|
|
164
144
|
pipeline.columns(processColumns(columns));
|
|
165
145
|
return pipeline;
|
|
166
|
-
|
|
167
146
|
function processDataSource(dataSource) {
|
|
168
147
|
var _context, _context2;
|
|
169
|
-
|
|
170
148
|
if (keepDataSource) {
|
|
171
149
|
return dataSource;
|
|
172
150
|
}
|
|
173
|
-
|
|
174
151
|
if (sortMap.size === 0) {
|
|
175
152
|
return dataSource;
|
|
176
153
|
}
|
|
177
|
-
|
|
178
154
|
var sortColumnsMap = new _Map(_mapInstanceProperty(_context = _filterInstanceProperty(_context2 = collectNodes(columns, 'leaf-only')).call(_context2, function (col) {
|
|
179
155
|
var _a, _b;
|
|
180
|
-
|
|
181
156
|
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
157
|
})).call(_context, function (col) {
|
|
183
158
|
return [col.code, col];
|
|
184
159
|
}));
|
|
185
160
|
return layeredSort(dataSource, function (x, y) {
|
|
186
161
|
var _iterator = _createForOfIteratorHelper(sorts),
|
|
187
|
-
|
|
188
|
-
|
|
162
|
+
_step;
|
|
189
163
|
try {
|
|
190
164
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
191
165
|
var _step$value = _step.value,
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
var column = sortColumnsMap.get(code);
|
|
195
|
-
|
|
166
|
+
code = _step$value.code,
|
|
167
|
+
order = _step$value.order;
|
|
168
|
+
var column = sortColumnsMap.get(code);
|
|
169
|
+
// 如果 code 对应的 column 不可排序,我们跳过该 code
|
|
196
170
|
if (column == null) {
|
|
197
171
|
continue;
|
|
198
172
|
}
|
|
199
|
-
|
|
200
173
|
var sortable = column.features.sortable;
|
|
201
174
|
var compareFn = typeof sortable === 'function' ? sortable : smartCompare;
|
|
202
175
|
var xValue = internals.safeGetValue(column, x, -1);
|
|
203
176
|
var yValue = internals.safeGetValue(column, y, -1);
|
|
204
177
|
var cmp = compareFn(xValue, yValue, x, y);
|
|
205
|
-
|
|
206
178
|
if (cmp !== 0) {
|
|
207
179
|
return cmp * (order === 'asc' ? 1 : -1);
|
|
208
180
|
}
|
|
@@ -212,16 +184,13 @@ export function sort() {
|
|
|
212
184
|
} finally {
|
|
213
185
|
_iterator.f();
|
|
214
186
|
}
|
|
215
|
-
|
|
216
187
|
return 0;
|
|
217
188
|
});
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
|
|
189
|
+
}
|
|
190
|
+
// 在「升序 - 降序 - 不排序」之间不断切换
|
|
221
191
|
function toggle(code) {
|
|
222
192
|
var sort = sortMap.get(code);
|
|
223
193
|
var currentSort;
|
|
224
|
-
|
|
225
194
|
if (sort == null) {
|
|
226
195
|
currentSort = {
|
|
227
196
|
code: code,
|
|
@@ -232,15 +201,12 @@ export function sort() {
|
|
|
232
201
|
var index = _findIndexInstanceProperty(sorts).call(sorts, function (s) {
|
|
233
202
|
return s.code === code;
|
|
234
203
|
});
|
|
235
|
-
|
|
236
204
|
var nextSorts = _sliceInstanceProperty(sorts).call(sorts, 0, index + 1);
|
|
237
|
-
|
|
238
205
|
var nextOrder = getNextOrder(sort.order);
|
|
239
206
|
currentSort = {
|
|
240
207
|
code: code,
|
|
241
208
|
order: nextOrder
|
|
242
209
|
};
|
|
243
|
-
|
|
244
210
|
if (nextOrder === 'none') {
|
|
245
211
|
nextSorts.pop();
|
|
246
212
|
} else {
|
|
@@ -248,41 +214,31 @@ export function sort() {
|
|
|
248
214
|
order: nextOrder
|
|
249
215
|
});
|
|
250
216
|
}
|
|
251
|
-
|
|
252
217
|
onChangeSorts(nextSorts, currentSort);
|
|
253
218
|
}
|
|
254
219
|
}
|
|
255
|
-
|
|
256
220
|
function processColumns(columns) {
|
|
257
221
|
return _mapInstanceProperty(columns).call(columns, dfs);
|
|
258
|
-
|
|
259
222
|
function dfs(col) {
|
|
260
223
|
var _a;
|
|
261
|
-
|
|
262
224
|
var result = _extends({}, col);
|
|
263
|
-
|
|
264
225
|
var sortable = col.code && (((_a = col.features) === null || _a === void 0 ? void 0 : _a.sortable) || sortMap.has(col.code));
|
|
265
226
|
var active = sortable && sortMap.has(col.code);
|
|
266
|
-
|
|
267
227
|
if (sortable) {
|
|
268
228
|
var sortIndex = -1;
|
|
269
229
|
var sortOrder = 'none';
|
|
270
|
-
|
|
271
230
|
if (active) {
|
|
272
231
|
var _sortMap$get = sortMap.get(col.code),
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
232
|
+
order = _sortMap$get.order,
|
|
233
|
+
index = _sortMap$get.index;
|
|
276
234
|
sortOrder = order;
|
|
277
235
|
sortIndex = index;
|
|
278
|
-
|
|
279
236
|
if (highlightColumnWhenActive) {
|
|
280
237
|
result.headerCellProps = mergeCellProps(col.headerCellProps, {
|
|
281
238
|
style: {
|
|
282
239
|
background: 'var(--header-highlight-bgcolor)'
|
|
283
240
|
}
|
|
284
241
|
});
|
|
285
|
-
|
|
286
242
|
result.getCellProps = function (value, row, rowIndex) {
|
|
287
243
|
var prevCellProps = internals.safeGetCellProps(col, row, rowIndex);
|
|
288
244
|
return mergeCellProps(prevCellProps, {
|
|
@@ -293,13 +249,11 @@ export function sort() {
|
|
|
293
249
|
};
|
|
294
250
|
}
|
|
295
251
|
}
|
|
296
|
-
|
|
297
252
|
var sortNode = /*#__PURE__*/React.createElement(SortHeaderCell, {
|
|
298
253
|
onToggle: function onToggle(e) {
|
|
299
254
|
if (stopClickEventPropagation) {
|
|
300
255
|
e.stopPropagation();
|
|
301
256
|
}
|
|
302
|
-
|
|
303
257
|
toggle(col.code);
|
|
304
258
|
},
|
|
305
259
|
sortOrder: sortOrder,
|
|
@@ -309,22 +263,19 @@ export function sort() {
|
|
|
309
263
|
}, internals.safeRenderHeader(_extends(_extends({}, col), {
|
|
310
264
|
title: col.title && col.title[0] ? col.title[0] : col.title
|
|
311
265
|
})));
|
|
312
|
-
|
|
313
266
|
var _sortNodeWithoutTitle = /*#__PURE__*/React.createElement(SortHeaderCell, {
|
|
314
267
|
onToggle: function onToggle(e) {
|
|
315
268
|
if (stopClickEventPropagation) {
|
|
316
269
|
e.stopPropagation();
|
|
317
270
|
}
|
|
318
|
-
|
|
319
271
|
toggle(col.code);
|
|
320
272
|
},
|
|
321
273
|
sortOrder: sortOrder,
|
|
322
274
|
column: col,
|
|
323
275
|
sortIndex: sortIndex,
|
|
324
276
|
sortOptions: sortOptions
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
|
|
277
|
+
});
|
|
278
|
+
// 开启标题行高自适应后,修改表头的渲染结构
|
|
328
279
|
if (col.renderHeader) {
|
|
329
280
|
result.title = col.renderHeader(result.title, _sortNodeWithoutTitle);
|
|
330
281
|
} else {
|
|
@@ -335,17 +286,13 @@ export function sort() {
|
|
|
335
286
|
}
|
|
336
287
|
}
|
|
337
288
|
}
|
|
338
|
-
|
|
339
289
|
if (!isLeafNode(col)) {
|
|
340
290
|
var _context3;
|
|
341
|
-
|
|
342
291
|
result.children = _mapInstanceProperty(_context3 = col.children).call(_context3, dfs);
|
|
343
292
|
}
|
|
344
|
-
|
|
345
293
|
return result;
|
|
346
294
|
}
|
|
347
295
|
}
|
|
348
|
-
|
|
349
296
|
function getNextOrder(order) {
|
|
350
297
|
var idx = orders.indexOf(order);
|
|
351
298
|
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,25 +11,21 @@ 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
|
-
title: /*#__PURE__*/React.createElement(HeaderCellWithTips, {
|
|
24
|
+
title: ( /*#__PURE__*/React.createElement(HeaderCellWithTips, {
|
|
31
25
|
style: {
|
|
32
26
|
justifyContent: justifyContent
|
|
33
27
|
}
|
|
34
|
-
}, internals.safeRenderHeader(col), Balloon ?
|
|
28
|
+
}, internals.safeRenderHeader(col), Balloon ? (
|
|
35
29
|
/*#__PURE__*/
|
|
36
30
|
// fusion/hippo
|
|
37
31
|
React.createElement(Balloon, {
|
|
@@ -41,7 +35,7 @@ export function tips() {
|
|
|
41
35
|
}, /*#__PURE__*/React.createElement(icons.Info, {
|
|
42
36
|
className: "tip-icon"
|
|
43
37
|
}))
|
|
44
|
-
}, col.features.tips) :
|
|
38
|
+
}, col.features.tips)) : (
|
|
45
39
|
/*#__PURE__*/
|
|
46
40
|
// antd
|
|
47
41
|
React.createElement(Tooltip, {
|
|
@@ -50,7 +44,7 @@ export function tips() {
|
|
|
50
44
|
className: "tip-icon-wrapper"
|
|
51
45
|
}, /*#__PURE__*/React.createElement(icons.Info, {
|
|
52
46
|
className: "tip-icon"
|
|
53
|
-
}))))
|
|
47
|
+
}))))))
|
|
54
48
|
});
|
|
55
49
|
}));
|
|
56
50
|
};
|