@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
|
@@ -6,55 +6,46 @@ import { makeRecursiveMapper, mergeCellProps, collectNodes, isLeafNode, isSelect
|
|
|
6
6
|
import { FILL_COLUMN_CODE } from './autoFill';
|
|
7
7
|
var stateKey = 'columnDrag';
|
|
8
8
|
var SCROLL_SIZE = 30;
|
|
9
|
-
|
|
10
9
|
function disableSelect(event) {
|
|
11
10
|
event.preventDefault();
|
|
12
11
|
}
|
|
13
|
-
|
|
14
12
|
function sortColumns(columns, sort) {
|
|
15
13
|
var res = new Array(columns.length);
|
|
16
|
-
|
|
17
14
|
var lastColumns = _toConsumableArray(columns);
|
|
18
|
-
|
|
19
15
|
while (columns.length) {
|
|
20
16
|
var cloumn = columns.pop();
|
|
21
17
|
res[sort[cloumn.code]] = cloumn;
|
|
22
18
|
}
|
|
23
|
-
|
|
24
19
|
if (_filterInstanceProperty(res).call(res, Boolean).length !== lastColumns.length) {
|
|
25
20
|
return lastColumns;
|
|
26
21
|
}
|
|
27
|
-
|
|
28
22
|
return res;
|
|
29
23
|
}
|
|
30
|
-
|
|
31
24
|
function stopClickPropagation(e) {
|
|
32
25
|
e.stopPropagation();
|
|
33
26
|
}
|
|
34
|
-
|
|
35
27
|
export function columnDrag() {
|
|
36
28
|
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
37
29
|
return function (pipeline) {
|
|
38
30
|
var _pipeline$getStateAtK = pipeline.getStateAtKey(stateKey, {}),
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
cloumnsTranslateData = _pipeline$getStateAtK.cloumnsTranslateData;
|
|
41
32
|
var columns = pipeline.getColumns();
|
|
42
|
-
var tableBody = pipeline.ref.current.domHelper && pipeline.ref.current.domHelper.tableBody;
|
|
33
|
+
var tableBody = pipeline.ref.current.domHelper && pipeline.ref.current.domHelper.tableBody;
|
|
34
|
+
// if (cloumnsSortData) {
|
|
43
35
|
// columns = sortColumns(columns, cloumnsSortData)
|
|
44
36
|
// }
|
|
45
|
-
|
|
46
37
|
pipeline.columns(_filterInstanceProperty(columns).call(columns, function (column) {
|
|
47
38
|
return column;
|
|
48
39
|
}));
|
|
49
40
|
return pipeline.mapColumns(makeRecursiveMapper(function (col, recursiveFlatMapInfo) {
|
|
50
41
|
var path = recursiveFlatMapInfo.path,
|
|
51
|
-
|
|
42
|
+
isLeaf = recursiveFlatMapInfo.isLeaf;
|
|
52
43
|
var style = cloumnsTranslateData ? {
|
|
53
44
|
transition: '.3s',
|
|
54
45
|
transform: "translate3d(".concat(cloumnsTranslateData[col.code], "px, 0px, 0px)")
|
|
55
46
|
} : {};
|
|
56
|
-
var prevGetCellProps = col.getCellProps;
|
|
57
|
-
|
|
47
|
+
var prevGetCellProps = col.getCellProps;
|
|
48
|
+
// !col.code: 选择列 col.lock: 固定列 不允许拖拽
|
|
58
49
|
if (col.lock || !col.code) return col;
|
|
59
50
|
return _extends(_extends({}, col), {
|
|
60
51
|
getCellProps: function getCellProps(value, record, rowIndex) {
|
|
@@ -68,8 +59,8 @@ export function columnDrag() {
|
|
|
68
59
|
if (e.button !== 0 || !e.currentTarget.contains(e.target)) {
|
|
69
60
|
return;
|
|
70
61
|
}
|
|
71
|
-
|
|
72
|
-
|
|
62
|
+
window.addEventListener('selectstart', disableSelect);
|
|
63
|
+
// const cx = e.clientX
|
|
73
64
|
// const width = col.width
|
|
74
65
|
// const a = startIndex
|
|
75
66
|
// const b = endIndex
|
|
@@ -77,13 +68,10 @@ export function columnDrag() {
|
|
|
77
68
|
// let newColumn = [...columns]
|
|
78
69
|
// let newStartIndex = startIndex
|
|
79
70
|
// let endIdx = endIndex
|
|
80
|
-
|
|
81
71
|
var columnMoved = false;
|
|
82
72
|
var columns = pipeline.getColumns();
|
|
83
|
-
|
|
84
73
|
var _pipeline$getStateAtK2 = pipeline.getStateAtKey(stateKey, {}),
|
|
85
|
-
|
|
86
|
-
|
|
74
|
+
cloumnsTranslateData = _pipeline$getStateAtK2.cloumnsTranslateData;
|
|
87
75
|
var cloumnsSortData = {};
|
|
88
76
|
columns.forEach(function (item, index) {
|
|
89
77
|
cloumnsSortData[item.code] = index;
|
|
@@ -97,21 +85,17 @@ export function columnDrag() {
|
|
|
97
85
|
var allColumns = collectNodes(columns);
|
|
98
86
|
var tableBodyClientRect = tableBody.getBoundingClientRect();
|
|
99
87
|
var startScrollLeft = pipeline.ref.current.domHelper.virtual.scrollLeft;
|
|
100
|
-
|
|
101
88
|
var updateScrollPosition = function updateScrollPosition(client) {
|
|
102
89
|
var clientX = client.clientX;
|
|
103
90
|
var left = tableBodyClientRect.left,
|
|
104
|
-
|
|
105
|
-
|
|
91
|
+
width = tableBodyClientRect.width;
|
|
106
92
|
if (clientX + SCROLL_SIZE >= left + width) {
|
|
107
93
|
pipeline.ref.current.domHelper.virtual.scrollLeft += SCROLL_SIZE;
|
|
108
94
|
}
|
|
109
|
-
|
|
110
95
|
if (clientX - SCROLL_SIZE <= left) {
|
|
111
96
|
pipeline.ref.current.domHelper.virtual.scrollLeft -= SCROLL_SIZE;
|
|
112
97
|
}
|
|
113
98
|
};
|
|
114
|
-
|
|
115
99
|
function handleMouseMove(e) {
|
|
116
100
|
var client = {
|
|
117
101
|
clientX: e.clientX,
|
|
@@ -119,17 +103,15 @@ export function columnDrag() {
|
|
|
119
103
|
};
|
|
120
104
|
var scrollDistance = pipeline.ref.current.domHelper.virtual.scrollLeft - startScrollLeft;
|
|
121
105
|
var leftPosition = startX - scrollDistance; // 表头最左边起点
|
|
122
|
-
|
|
123
106
|
updateScrollPosition(client);
|
|
124
|
-
|
|
125
107
|
if (e.clientX - leftPosition < 20) {
|
|
126
108
|
return;
|
|
127
109
|
} else {
|
|
128
110
|
e.stopPropagation();
|
|
129
111
|
}
|
|
130
|
-
|
|
131
112
|
document.body.style.userSelect = 'none';
|
|
132
|
-
currentTarget.style.cursor = 'move';
|
|
113
|
+
currentTarget.style.cursor = 'move';
|
|
114
|
+
// 循环计算每一个的位置
|
|
133
115
|
// if (startIndex !== replaceIndex) {
|
|
134
116
|
// const optionColumn = columns[startIndex]
|
|
135
117
|
// const move = startIndex > replaceIndex ? 1 : -1
|
|
@@ -152,21 +134,18 @@ export function columnDrag() {
|
|
|
152
134
|
// index++
|
|
153
135
|
// }
|
|
154
136
|
// 重置位置信息
|
|
155
|
-
|
|
156
137
|
cloumnsTranslateData = {};
|
|
157
138
|
allColumns.forEach(function (item) {
|
|
158
139
|
cloumnsTranslateData[item.code] = 0;
|
|
159
|
-
});
|
|
160
|
-
|
|
140
|
+
});
|
|
141
|
+
// 计算平移位置
|
|
161
142
|
var replaceIndex = 0;
|
|
162
143
|
var totalWitdth = getColumnWidth(columns[replaceIndex]);
|
|
163
|
-
|
|
164
144
|
while (totalWitdth < e.clientX - leftPosition && replaceIndex < columns.length - 1) {
|
|
165
145
|
replaceIndex++;
|
|
166
146
|
totalWitdth += getColumnWidth(columns[replaceIndex]);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
|
|
147
|
+
}
|
|
148
|
+
// 需要取最新startIndex, 不能直接用makeRecursiveMapper提供的startIndex(因为map时还没添加选择列、充满列等后面use添加的列)
|
|
170
149
|
var startIndex;
|
|
171
150
|
columns.forEach(function (column, index) {
|
|
172
151
|
if (column.code === col.code) {
|
|
@@ -175,63 +154,53 @@ export function columnDrag() {
|
|
|
175
154
|
});
|
|
176
155
|
var optionColumn = columns[startIndex];
|
|
177
156
|
var index = replaceIndex;
|
|
178
|
-
|
|
179
157
|
if (startIndex > replaceIndex) {
|
|
180
158
|
// 左移
|
|
181
159
|
while (index < startIndex) {
|
|
182
160
|
var _columns$index = columns[index],
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
161
|
+
code = _columns$index.code,
|
|
162
|
+
lock = _columns$index.lock,
|
|
163
|
+
width = _columns$index.width,
|
|
164
|
+
children = _columns$index.children;
|
|
188
165
|
if (enableMove({
|
|
189
166
|
code: code,
|
|
190
167
|
lock: lock
|
|
191
168
|
})) {
|
|
192
169
|
cloumnsTranslateData[code] += optionColumn.width;
|
|
193
|
-
|
|
194
170
|
if (isLeafNode(columns[index])) {
|
|
195
171
|
cloumnsTranslateData[optionColumn.code] -= width;
|
|
196
172
|
} else {
|
|
197
173
|
cloumnsTranslateData[optionColumn.code] -= getColumnWidth(columns[index]);
|
|
198
174
|
moveAllChildren(children, cloumnsTranslateData, optionColumn.width);
|
|
199
175
|
}
|
|
200
|
-
|
|
201
176
|
columnMoved = true;
|
|
202
177
|
}
|
|
203
|
-
|
|
204
178
|
index++;
|
|
205
179
|
}
|
|
206
180
|
} else if (startIndex < replaceIndex) {
|
|
207
181
|
// 右移
|
|
208
182
|
while (startIndex < index) {
|
|
209
183
|
var _columns$index2 = columns[index],
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
184
|
+
_code = _columns$index2.code,
|
|
185
|
+
_lock = _columns$index2.lock,
|
|
186
|
+
_width = _columns$index2.width,
|
|
187
|
+
_children = _columns$index2.children;
|
|
215
188
|
if (enableMove({
|
|
216
189
|
code: _code,
|
|
217
190
|
lock: _lock
|
|
218
191
|
})) {
|
|
219
192
|
cloumnsTranslateData[_code] -= optionColumn.width;
|
|
220
|
-
|
|
221
193
|
if (isLeafNode(columns[index])) {
|
|
222
194
|
cloumnsTranslateData[optionColumn.code] += _width;
|
|
223
195
|
} else {
|
|
224
196
|
cloumnsTranslateData[optionColumn.code] += getColumnWidth(columns[index]);
|
|
225
197
|
moveAllChildren(_children, cloumnsTranslateData, optionColumn.width, true);
|
|
226
198
|
}
|
|
227
|
-
|
|
228
199
|
columnMoved = true;
|
|
229
200
|
}
|
|
230
|
-
|
|
231
201
|
index--;
|
|
232
202
|
}
|
|
233
203
|
}
|
|
234
|
-
|
|
235
204
|
window.requestAnimationFrame(function () {
|
|
236
205
|
pipeline.setStateAtKey(stateKey, {
|
|
237
206
|
cloumnsTranslateData: cloumnsTranslateData
|
|
@@ -239,29 +208,24 @@ export function columnDrag() {
|
|
|
239
208
|
moveData = [startIndex, replaceIndex];
|
|
240
209
|
});
|
|
241
210
|
}
|
|
242
|
-
|
|
243
211
|
function handleMouseUp(e) {
|
|
244
212
|
document.body.removeEventListener('mousemove', handleMouseMove);
|
|
245
213
|
document.body.removeEventListener('mouseup', handleMouseUp);
|
|
246
214
|
window.removeEventListener('selectstart', disableSelect);
|
|
247
|
-
|
|
248
215
|
if (_isMoveWhenClicking(mouseDownClientX, mouseDownClientY, e.clientX, e.clientY)) {
|
|
249
216
|
e.stopPropagation(); // 存在移动就阻止冒泡
|
|
250
|
-
|
|
251
217
|
currentTarget.addEventListener('click', stopClickPropagation); // 阻止列头点击事件,防止拖动后触发列头过滤事件
|
|
252
218
|
}
|
|
253
|
-
|
|
254
219
|
window.requestAnimationFrame(function () {
|
|
255
220
|
// 取消阻止列头点击事件
|
|
256
221
|
currentTarget.removeEventListener('click', stopClickPropagation);
|
|
257
222
|
currentTarget = null;
|
|
258
|
-
|
|
259
223
|
var _moveData = moveData,
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
224
|
+
_moveData2 = _slicedToArray(_moveData, 2),
|
|
225
|
+
startIndex = _moveData2[0],
|
|
226
|
+
replaceIndex = _moveData2[1];
|
|
227
|
+
var optionColumn = columns[startIndex];
|
|
228
|
+
// const move = startIndex > replaceIndex ? 1 : -1
|
|
265
229
|
// let index = Math.min(startIndex, replaceIndex)
|
|
266
230
|
// while (index < Math.max(startIndex, replaceIndex) && index > 0) {
|
|
267
231
|
// const code = columns[index].code
|
|
@@ -269,16 +233,13 @@ export function columnDrag() {
|
|
|
269
233
|
// cloumnsSortData[code] += move
|
|
270
234
|
// index += move
|
|
271
235
|
// }
|
|
272
|
-
|
|
273
236
|
var index = replaceIndex;
|
|
274
|
-
|
|
275
237
|
if (startIndex > replaceIndex) {
|
|
276
238
|
// 左移
|
|
277
239
|
while (index < startIndex) {
|
|
278
240
|
var _columns$index3 = columns[index],
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
241
|
+
code = _columns$index3.code,
|
|
242
|
+
lock = _columns$index3.lock;
|
|
282
243
|
if (enableMove({
|
|
283
244
|
code: code,
|
|
284
245
|
lock: lock
|
|
@@ -287,16 +248,14 @@ export function columnDrag() {
|
|
|
287
248
|
cloumnsSortData[optionColumn.code] -= 1;
|
|
288
249
|
columnMoved = true;
|
|
289
250
|
}
|
|
290
|
-
|
|
291
251
|
index++;
|
|
292
252
|
}
|
|
293
253
|
} else if (startIndex < replaceIndex) {
|
|
294
254
|
// 右移
|
|
295
255
|
while (index > startIndex) {
|
|
296
256
|
var _columns$index4 = columns[index],
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
257
|
+
_code2 = _columns$index4.code,
|
|
258
|
+
_lock2 = _columns$index4.lock;
|
|
300
259
|
if (enableMove({
|
|
301
260
|
code: _code2,
|
|
302
261
|
lock: _lock2
|
|
@@ -305,29 +264,23 @@ export function columnDrag() {
|
|
|
305
264
|
cloumnsSortData[optionColumn.code] += 1;
|
|
306
265
|
columnMoved = true;
|
|
307
266
|
}
|
|
308
|
-
|
|
309
267
|
index--;
|
|
310
268
|
}
|
|
311
269
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
270
|
+
var onColumnDragStopped = opts.onColumnDragStopped;
|
|
271
|
+
// 拖拽结束返回列顺序
|
|
315
272
|
if (onColumnDragStopped) {
|
|
316
273
|
var _context;
|
|
317
|
-
|
|
318
274
|
var isRowDragColumn = function isRowDragColumn(code) {
|
|
319
275
|
var rowDragColumnKey = pipeline.getFeatureOptions('rowDragColumnKey');
|
|
320
276
|
return code === rowDragColumnKey;
|
|
321
277
|
};
|
|
322
|
-
|
|
323
278
|
var newColumns = _filterInstanceProperty(_context = sortColumns(columns, cloumnsSortData)).call(_context, function (column) {
|
|
324
279
|
return column.code !== FILL_COLUMN_CODE && !isRowDragColumn(column.code) && !isSelectColumn(column);
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
|
|
280
|
+
});
|
|
281
|
+
// TODO drag需要在resize之后use,否则这里返回的列对应的宽度不是拖拽后的
|
|
328
282
|
onColumnDragStopped(columnMoved, newColumns);
|
|
329
283
|
}
|
|
330
|
-
|
|
331
284
|
pipeline.setStateAtKey(stateKey, {
|
|
332
285
|
cloumnsTranslateData: null
|
|
333
286
|
});
|
|
@@ -336,7 +289,6 @@ export function columnDrag() {
|
|
|
336
289
|
currentTarget.style.opacity = '';
|
|
337
290
|
currentTarget.style.cursor = '';
|
|
338
291
|
}
|
|
339
|
-
|
|
340
292
|
document.body.addEventListener('mousemove', handleMouseMove);
|
|
341
293
|
document.body.addEventListener('mouseup', handleMouseUp);
|
|
342
294
|
},
|
|
@@ -346,45 +298,37 @@ export function columnDrag() {
|
|
|
346
298
|
}));
|
|
347
299
|
};
|
|
348
300
|
}
|
|
349
|
-
|
|
350
301
|
function enableMove(_ref) {
|
|
351
302
|
var lock = _ref.lock,
|
|
352
|
-
|
|
303
|
+
code = _ref.code;
|
|
353
304
|
return code && code !== FILL_COLUMN_CODE && !lock;
|
|
354
305
|
}
|
|
355
|
-
|
|
356
306
|
function getColumnWidth(col) {
|
|
357
307
|
if (col.children) {
|
|
358
308
|
return col.children.reduce(function (acc, col) {
|
|
359
309
|
return acc + getColumnWidth(col);
|
|
360
310
|
}, 0);
|
|
361
311
|
}
|
|
362
|
-
|
|
363
312
|
return col.width;
|
|
364
313
|
}
|
|
365
|
-
|
|
366
314
|
function moveAllChildren(cols, cloumnsTranslateData, width, isMinus) {
|
|
367
315
|
cols.forEach(function (col) {
|
|
368
316
|
var _a;
|
|
369
|
-
|
|
370
317
|
var code = col.code,
|
|
371
|
-
|
|
318
|
+
children = col.children;
|
|
372
319
|
var movedWidth = (_a = cloumnsTranslateData[code]) !== null && _a !== void 0 ? _a : 0;
|
|
373
320
|
cloumnsTranslateData[code] = movedWidth + (isMinus ? -width : width);
|
|
374
|
-
|
|
375
321
|
if (!isLeafNode(col)) {
|
|
376
322
|
moveAllChildren(children, cloumnsTranslateData, width);
|
|
377
323
|
}
|
|
378
324
|
});
|
|
379
325
|
}
|
|
380
|
-
|
|
381
326
|
function _isMoveWhenClicking(mouseDownClientX, mouseDownClientY, mouseUpClientX, mouseUpClientY) {
|
|
382
327
|
var xDiff = mouseUpClientX - mouseDownClientX;
|
|
383
|
-
var yDiff = mouseUpClientY - mouseDownClientY;
|
|
384
|
-
|
|
328
|
+
var yDiff = mouseUpClientY - mouseDownClientY;
|
|
329
|
+
// 鼠标点按和松开的偏移量大于5px,认为存在移动
|
|
385
330
|
if (Math.sqrt(xDiff * xDiff + yDiff * yDiff) > 5) {
|
|
386
331
|
return true;
|
|
387
332
|
}
|
|
388
|
-
|
|
389
333
|
return false;
|
|
390
334
|
}
|
|
@@ -19,63 +19,49 @@ export function filter() {
|
|
|
19
19
|
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
20
20
|
return function step(pipeline) {
|
|
21
21
|
var _a, _b;
|
|
22
|
-
|
|
23
22
|
var dataSource = pipeline.getDataSource();
|
|
24
23
|
var columns = pipeline.getColumns();
|
|
25
24
|
var filters = opts.filters,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
defaultFilters = opts.defaultFilters,
|
|
26
|
+
onChangeFilters = opts.onChangeFilters,
|
|
27
|
+
keepDataSource = opts.keepDataSource,
|
|
28
|
+
mode = opts.mode,
|
|
29
|
+
filterIcon = opts.filterIcon,
|
|
30
|
+
stopClickEventPropagation = opts.stopClickEventPropagation,
|
|
31
|
+
stopESCKeyDownEventPropagation = opts.stopESCKeyDownEventPropagation,
|
|
32
|
+
hideFilterPopupHeader = opts.hideFilterPopupHeader,
|
|
33
|
+
getPopupParent = opts.getPopupParent;
|
|
35
34
|
var inputFilters = (_b = (_a = filters !== null && filters !== void 0 ? filters : pipeline.getStateAtKey(stateKey)) !== null && _a !== void 0 ? _a : defaultFilters) !== null && _b !== void 0 ? _b : [];
|
|
36
35
|
inputFilters = mode === 'single' ? _sliceInstanceProperty(inputFilters).call(inputFilters, 0, 1) : inputFilters;
|
|
37
36
|
var inputFiltersMap = new _Map(_mapInstanceProperty(inputFilters).call(inputFilters, function (filterItem) {
|
|
38
37
|
return [filterItem.code, _extends({}, filterItem)];
|
|
39
38
|
}));
|
|
40
39
|
var localeText = pipeline.ctx.localeText;
|
|
41
|
-
|
|
42
40
|
function processColumns(columns) {
|
|
43
41
|
return _mapInstanceProperty(columns).call(columns, dfs);
|
|
44
|
-
|
|
45
42
|
function dfs(col) {
|
|
46
43
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
47
|
-
|
|
48
44
|
var result = _extends({}, col);
|
|
49
|
-
|
|
50
45
|
var filterable = col.code && ((_a = col.features) === null || _a === void 0 ? void 0 : _a.filterable);
|
|
51
46
|
var filterActive = filterable && ((_c = (_b = inputFiltersMap === null || inputFiltersMap === void 0 ? void 0 : inputFiltersMap.get(col.code)) === null || _b === void 0 ? void 0 : _filterInstanceProperty(_b)) === null || _c === void 0 ? void 0 : _c.length) > 0;
|
|
52
|
-
|
|
53
47
|
if (filterable) {
|
|
54
|
-
var _cx;
|
|
55
|
-
|
|
56
48
|
var handleFilterChanged = function handleFilterChanged(filterItem) {
|
|
57
49
|
var nextFiltersMap = new _Map(inputFiltersMap);
|
|
58
|
-
|
|
59
50
|
var currentFilter = _extends({
|
|
60
51
|
code: col.code
|
|
61
52
|
}, filterItem);
|
|
62
|
-
|
|
63
53
|
if (filterItem == null) {
|
|
64
54
|
nextFiltersMap.delete(col.code);
|
|
65
55
|
} else {
|
|
66
56
|
if (mode === 'single') {
|
|
67
57
|
nextFiltersMap.clear();
|
|
68
58
|
}
|
|
69
|
-
|
|
70
59
|
nextFiltersMap.set(col.code, currentFilter);
|
|
71
60
|
}
|
|
72
|
-
|
|
73
61
|
var nextFilters = _Array$from(_valuesInstanceProperty(nextFiltersMap).call(nextFiltersMap));
|
|
74
|
-
|
|
75
62
|
onChangeFilters === null || onChangeFilters === void 0 ? void 0 : onChangeFilters(nextFilters, currentFilter);
|
|
76
63
|
pipeline.setStateAtKey(stateKey, nextFilters);
|
|
77
64
|
};
|
|
78
|
-
|
|
79
65
|
var setFilter = function setFilter(filter, filterCondition) {
|
|
80
66
|
handleFilterChanged(!filter ? undefined : {
|
|
81
67
|
code: col.code,
|
|
@@ -83,10 +69,8 @@ export function filter() {
|
|
|
83
69
|
filterCondition: filterCondition
|
|
84
70
|
});
|
|
85
71
|
};
|
|
86
|
-
|
|
87
72
|
var filterPanel = (_d = col.features) === null || _d === void 0 ? void 0 : _d.filterPanel;
|
|
88
73
|
var colFilterIcon = (_f = (_e = col.features) === null || _e === void 0 ? void 0 : _e.filterIcon) !== null && _f !== void 0 ? _f : filterIcon;
|
|
89
|
-
|
|
90
74
|
var _Filter = /*#__PURE__*/React.createElement(Filter, {
|
|
91
75
|
key: "".concat(col.code, "_filter"),
|
|
92
76
|
FilterPanelContent: filterPanel,
|
|
@@ -95,54 +79,44 @@ export function filter() {
|
|
|
95
79
|
setFilterModel: handleFilterChanged,
|
|
96
80
|
setFilter: setFilter,
|
|
97
81
|
isFilterActive: filterActive,
|
|
98
|
-
className: cx((
|
|
82
|
+
className: cx(_defineProperty(_defineProperty({}, Classes.tableFilterTrigger, true), "active", filterActive)),
|
|
99
83
|
stopClickEventPropagation: stopClickEventPropagation,
|
|
100
84
|
stopESCKeyDownEventPropagation: stopESCKeyDownEventPropagation,
|
|
101
85
|
hideFilterPopupHeader: hideFilterPopupHeader,
|
|
102
86
|
getPopupParent: getPopupParent,
|
|
103
87
|
localeText: localeText
|
|
104
88
|
});
|
|
105
|
-
|
|
106
89
|
if (col.renderHeader) {
|
|
107
90
|
result.title = col.renderHeader(result.title, _Filter);
|
|
108
91
|
} else {
|
|
109
92
|
var _context, _context2;
|
|
110
|
-
|
|
111
93
|
result.title = _concatInstanceProperty(_context = []).call(_context, _toConsumableArray(_concatInstanceProperty(_context2 = []).call(_context2, (_g = result.title) !== null && _g !== void 0 ? _g : [internals.safeRenderHeader(_extends({}, col))])), [_Filter]);
|
|
112
|
-
}
|
|
94
|
+
}
|
|
95
|
+
// result.headerCellProps = mergeCellProps(col.headerCellProps, {
|
|
113
96
|
// style: {
|
|
114
97
|
// paddingRight: '18px'
|
|
115
98
|
// }
|
|
116
99
|
// })
|
|
117
|
-
|
|
118
100
|
}
|
|
119
|
-
|
|
120
101
|
if (!isLeafNode(col)) {
|
|
121
102
|
var _context3;
|
|
122
|
-
|
|
123
103
|
result.children = _mapInstanceProperty(_context3 = col.children).call(_context3, dfs);
|
|
124
104
|
}
|
|
125
|
-
|
|
126
105
|
return result;
|
|
127
106
|
}
|
|
128
107
|
}
|
|
129
|
-
|
|
130
108
|
function processDataSource(dataSource) {
|
|
131
109
|
var _context4, _context5;
|
|
132
|
-
|
|
133
110
|
var filtersKeys = [];
|
|
134
111
|
inputFiltersMap.forEach(function (value, key) {
|
|
135
112
|
filtersKeys.push(key);
|
|
136
113
|
});
|
|
137
|
-
|
|
138
114
|
if (keepDataSource || filtersKeys.length <= 0) {
|
|
139
115
|
return dataSource;
|
|
140
116
|
}
|
|
141
|
-
|
|
142
117
|
var columns = pipeline.getColumns();
|
|
143
118
|
var columnsMap = new _Map(_mapInstanceProperty(_context4 = _filterInstanceProperty(_context5 = collectNodes(columns, 'leaf-only')).call(_context5, function (col) {
|
|
144
119
|
var _a, _b;
|
|
145
|
-
|
|
146
120
|
return ((_a = col.features) === null || _a === void 0 ? void 0 : _a.filterable) !== false && ((_b = col.features) === null || _b === void 0 ? void 0 : _b.filterable) != null;
|
|
147
121
|
})).call(_context4, function (col) {
|
|
148
122
|
return [col.code, col];
|
|
@@ -150,15 +124,12 @@ export function filter() {
|
|
|
150
124
|
var defaultFilterOptionsMap = new _Map(_mapInstanceProperty(DEFAULT_FILTER_OPTIONS).call(DEFAULT_FILTER_OPTIONS, function (item) {
|
|
151
125
|
return [item.key, _extends({}, item)];
|
|
152
126
|
}));
|
|
153
|
-
|
|
154
127
|
function isMatchedFilterCondition(record) {
|
|
155
128
|
return filtersKeys.every(function (key) {
|
|
156
129
|
var _a, _b;
|
|
157
|
-
|
|
158
130
|
var filterItem = inputFiltersMap.get(key);
|
|
159
131
|
var filterable = (_b = (_a = columnsMap.get(key)) === null || _a === void 0 ? void 0 : _a.features) === null || _b === void 0 ? void 0 : _b.filterable;
|
|
160
132
|
var comparisonFn;
|
|
161
|
-
|
|
162
133
|
if (typeof filterable === 'function') {
|
|
163
134
|
comparisonFn = filterable;
|
|
164
135
|
} else if (defaultFilterOptionsMap.get(filterItem.filterCondition)) {
|
|
@@ -167,40 +138,30 @@ export function filter() {
|
|
|
167
138
|
console.warn("\u5217[".concat(key, "]\u672A\u914D\u7F6E\u7B5B\u9009\u51FD\u6570\uFF0C\u8BF7\u8BBE\u7F6E column.features.filterable \u6765\u4F5C\u4E3A\u8BE5\u5217\u7684\u7B5B\u9009\u51FD\u6570, \u76EE\u524D\u4F7F\u7528\u9ED8\u8BA4\u5305\u542B\u7B5B\u9009\u51FD\u6570"));
|
|
168
139
|
comparisonFn = _filterInstanceProperty(defaultFilterOptionsMap.get('contain'));
|
|
169
140
|
}
|
|
170
|
-
|
|
171
141
|
return comparisonFn(_filterInstanceProperty(filterItem), filterItem)(internals.safeGetValue(columnsMap.get(key), record, -1), record);
|
|
172
142
|
});
|
|
173
143
|
}
|
|
174
|
-
|
|
175
144
|
return layeredFilter(dataSource, isMatchedFilterCondition);
|
|
176
145
|
}
|
|
177
|
-
|
|
178
146
|
pipeline.dataSource(processDataSource(dataSource));
|
|
179
147
|
pipeline.columns(processColumns(columns));
|
|
180
148
|
return pipeline;
|
|
181
149
|
};
|
|
182
150
|
}
|
|
183
|
-
|
|
184
151
|
function layeredFilter(array, matchFn) {
|
|
185
152
|
return dfs(array);
|
|
186
|
-
|
|
187
153
|
function dfs(rows) {
|
|
188
154
|
var _context6;
|
|
189
|
-
|
|
190
155
|
var parentMatched = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
191
156
|
return _filterInstanceProperty(_context6 = _mapInstanceProperty(rows).call(rows, function (row) {
|
|
192
157
|
var currentMatched = matchFn(row);
|
|
193
|
-
|
|
194
158
|
if (isLeafNode(row)) {
|
|
195
159
|
return (parentMatched || currentMatched) && _extends({}, row);
|
|
196
160
|
}
|
|
197
|
-
|
|
198
161
|
var children = row.children;
|
|
199
|
-
|
|
200
162
|
var rowAfterFilterChildren = _extends(_extends({}, row), {
|
|
201
163
|
children: dfs(children, parentMatched || currentMatched)
|
|
202
164
|
});
|
|
203
|
-
|
|
204
165
|
var matchedByChildren = !isLeafNode(rowAfterFilterChildren);
|
|
205
166
|
return (parentMatched || currentMatched || matchedByChildren) && rowAfterFilterChildren;
|
|
206
167
|
})).call(_context6, Boolean);
|
|
@@ -5,29 +5,23 @@ export function columnHover() {
|
|
|
5
5
|
var stateKey = 'columnHover';
|
|
6
6
|
return function (pipeline) {
|
|
7
7
|
var _a, _b, _c, _d;
|
|
8
|
-
|
|
9
8
|
var hoverColor = (_a = opts.hoverColor) !== null && _a !== void 0 ? _a : 'var(--hover-bgcolor)';
|
|
10
9
|
var hoverColIndex = (_d = (_c = (_b = opts.hoverColIndex) !== null && _b !== void 0 ? _b : pipeline.getStateAtKey(stateKey)) !== null && _c !== void 0 ? _c : opts.defaultHoverColIndex) !== null && _d !== void 0 ? _d : -1;
|
|
11
|
-
|
|
12
10
|
var onChangeHoverColIndex = function onChangeHoverColIndex(nextColIndex) {
|
|
13
11
|
var _a;
|
|
14
|
-
|
|
15
12
|
pipeline.setStateAtKey(stateKey, nextColIndex);
|
|
16
13
|
(_a = opts.onChangeHoverColIndex) === null || _a === void 0 ? void 0 : _a.call(opts, nextColIndex);
|
|
17
14
|
};
|
|
18
|
-
|
|
19
15
|
return pipeline.mapColumns(makeRecursiveMapper(function (col, _ref) {
|
|
20
16
|
var startIndex = _ref.startIndex,
|
|
21
|
-
|
|
17
|
+
endIndex = _ref.endIndex;
|
|
22
18
|
var range = {
|
|
23
19
|
start: startIndex,
|
|
24
20
|
end: endIndex
|
|
25
21
|
};
|
|
26
|
-
|
|
27
22
|
if (!isLeafNode(col)) {
|
|
28
23
|
return col;
|
|
29
24
|
}
|
|
30
|
-
|
|
31
25
|
var colIndexMatched = range.start <= hoverColIndex && hoverColIndex < range.end;
|
|
32
26
|
var prevGetCellProps = col.getCellProps;
|
|
33
27
|
return _extends(_extends({}, col), {
|
|
@@ -9,32 +9,26 @@ export function columnRangeHover() {
|
|
|
9
9
|
var stateKey = 'columnHover';
|
|
10
10
|
return function columnRangeHoverStep(pipeline) {
|
|
11
11
|
var _a, _b, _c, _d, _e;
|
|
12
|
-
|
|
13
12
|
var hoverRange = (_c = (_b = (_a = opts.hoverRange) !== null && _a !== void 0 ? _a : pipeline.getStateAtKey(stateKey)) !== null && _b !== void 0 ? _b : opts.defaultHoverRange) !== null && _c !== void 0 ? _c : EMPTY_RANGE;
|
|
14
13
|
var hoverColor = (_d = opts.hoverColor) !== null && _d !== void 0 ? _d : 'var(--hover-bgcolor)';
|
|
15
14
|
var headerHoverColor = (_e = opts.headerHoverColor) !== null && _e !== void 0 ? _e : 'var(--header-hover-bgcolor)';
|
|
16
|
-
|
|
17
15
|
var onChangeHoverRange = function onChangeHoverRange(nextColIndexRange) {
|
|
18
16
|
var _a;
|
|
19
|
-
|
|
20
17
|
pipeline.setStateAtKey(stateKey, nextColIndexRange);
|
|
21
18
|
(_a = opts.onChangeHoverRange) === null || _a === void 0 ? void 0 : _a.call(opts, nextColIndexRange);
|
|
22
19
|
};
|
|
23
|
-
|
|
24
20
|
return pipeline.mapColumns(makeRecursiveMapper(function (col, _ref) {
|
|
25
21
|
var startIndex = _ref.startIndex,
|
|
26
|
-
|
|
22
|
+
endIndex = _ref.endIndex;
|
|
27
23
|
var colRange = {
|
|
28
24
|
start: startIndex,
|
|
29
25
|
end: endIndex
|
|
30
26
|
};
|
|
31
27
|
var match = colRange.end > hoverRange.start && hoverRange.end > colRange.start;
|
|
32
|
-
|
|
33
28
|
if (!isLeafNode(col)) {
|
|
34
29
|
if (headerHoverColor == null) {
|
|
35
30
|
return col;
|
|
36
31
|
}
|
|
37
|
-
|
|
38
32
|
return _extends(_extends({}, col), {
|
|
39
33
|
headerCellProps: mergeCellProps(col.headerCellProps, {
|
|
40
34
|
onMouseEnter: function onMouseEnter() {
|
|
@@ -49,7 +43,6 @@ export function columnRangeHover() {
|
|
|
49
43
|
})
|
|
50
44
|
});
|
|
51
45
|
}
|
|
52
|
-
|
|
53
46
|
var prevGetCellProps = col.getCellProps;
|
|
54
47
|
return _extends(_extends({}, col), {
|
|
55
48
|
headerCellProps: mergeCellProps(col.headerCellProps, {
|