@kdcloudjs/table 1.2.0-canary.1 → 1.2.0-canary.11
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 +528 -51
- package/dist/@kdcloudjs/table.js.map +1 -1
- package/dist/@kdcloudjs/table.min.css +1 -1
- package/dist/@kdcloudjs/table.min.js +8 -8
- package/dist/@kdcloudjs/table.min.js.map +1 -1
- package/es/locale/locale.d.ts +8 -4
- package/es/locale/zh-CN.d.ts +8 -4
- package/es/locale/zh-CN.js +10 -4
- package/es/table/base/helpers/TableDOMUtils.js +17 -14
- package/es/table/base/styles.d.ts +10 -0
- package/es/table/base/styles.js +12 -2
- package/es/table/base/table.js +38 -7
- package/es/table/common-views.js +3 -1
- package/es/table/interfaces.d.ts +5 -0
- package/es/table/pipeline/features/autoFill.js +10 -4
- package/es/table/pipeline/features/columnDrag.js +6 -1
- package/es/table/pipeline/features/columnFilter.js +17 -5
- package/es/table/pipeline/features/columnResizeWidth.js +3 -1
- package/es/table/pipeline/features/filter/DefaultFilterContent.d.ts +1 -1
- package/es/table/pipeline/features/filter/DefaultFilterContent.js +11 -5
- package/es/table/pipeline/features/filter/Filter.d.ts +4 -1
- package/es/table/pipeline/features/filter/Filter.js +4 -2
- package/es/table/pipeline/features/index.d.ts +1 -0
- package/es/table/pipeline/features/index.js +2 -1
- package/es/table/pipeline/features/multiSelect.js +31 -12
- package/es/table/pipeline/features/rowDrag.d.ts +30 -0
- package/es/table/pipeline/features/rowDrag.js +327 -0
- package/es/table/pipeline/features/sort.js +22 -3
- package/lib/locale/locale.d.ts +8 -4
- package/lib/locale/zh-CN.d.ts +8 -4
- package/lib/locale/zh-CN.js +10 -4
- package/lib/table/base/helpers/TableDOMUtils.js +17 -14
- package/lib/table/base/styles.d.ts +10 -0
- package/lib/table/base/styles.js +12 -2
- package/lib/table/base/table.js +38 -7
- package/lib/table/common-views.js +3 -1
- package/lib/table/interfaces.d.ts +5 -0
- package/lib/table/pipeline/features/autoFill.js +10 -4
- package/lib/table/pipeline/features/columnDrag.js +6 -1
- package/lib/table/pipeline/features/columnFilter.js +18 -6
- package/lib/table/pipeline/features/columnResizeWidth.js +3 -1
- package/lib/table/pipeline/features/filter/DefaultFilterContent.d.ts +1 -1
- package/lib/table/pipeline/features/filter/DefaultFilterContent.js +11 -5
- package/lib/table/pipeline/features/filter/Filter.d.ts +4 -1
- package/lib/table/pipeline/features/filter/Filter.js +4 -2
- package/lib/table/pipeline/features/index.d.ts +1 -0
- package/lib/table/pipeline/features/index.js +9 -1
- package/lib/table/pipeline/features/multiSelect.js +33 -12
- package/lib/table/pipeline/features/rowDrag.d.ts +30 -0
- package/lib/table/pipeline/features/rowDrag.js +349 -0
- package/lib/table/pipeline/features/sort.js +22 -3
- package/package.json +1 -1
|
@@ -6,6 +6,9 @@ import React from 'react';
|
|
|
6
6
|
import { internals } from '../../internals';
|
|
7
7
|
import { always, arrayUtils } from '../../utils/others';
|
|
8
8
|
import { collectNodes, mergeCellProps } from '../../utils';
|
|
9
|
+
var fullRowsSetKey = 'fullRowsSetKey';
|
|
10
|
+
var allEnableKeys = 'allEnableKeys';
|
|
11
|
+
var selectValueSetKey = 'selectValueSetKey';
|
|
9
12
|
export function multiSelect() {
|
|
10
13
|
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
11
14
|
return function multiSelectStep(pipeline) {
|
|
@@ -36,10 +39,9 @@ export function multiSelect() {
|
|
|
36
39
|
action: action
|
|
37
40
|
});
|
|
38
41
|
};
|
|
39
|
-
|
|
40
|
-
var dataSource = pipeline.getDataSource();
|
|
41
42
|
/** dataSource 中包含的所有 keys */
|
|
42
43
|
|
|
44
|
+
|
|
43
45
|
var fullKeySet = new _Set();
|
|
44
46
|
/** 所有有效的 keys(disable 状态为 false) */
|
|
45
47
|
|
|
@@ -48,7 +50,7 @@ export function multiSelect() {
|
|
|
48
50
|
var isAllChecked = set.size !== 0; // 当前不存在选中则默认为false
|
|
49
51
|
|
|
50
52
|
var isAnyChecked = false;
|
|
51
|
-
var flatDataSource = collectNodes(
|
|
53
|
+
var flatDataSource = collectNodes(pipeline.getDataSource());
|
|
52
54
|
flatDataSource.forEach(function (row, rowIndex) {
|
|
53
55
|
var rowKey = internals.safeGetRowKey(primaryKey, row, rowIndex);
|
|
54
56
|
fullKeySet.add(rowKey); // 在 allKeys 中排除被禁用的 key
|
|
@@ -76,6 +78,8 @@ export function multiSelect() {
|
|
|
76
78
|
checked: isAllChecked,
|
|
77
79
|
indeterminate: !isAllChecked && isAnyChecked,
|
|
78
80
|
onChange: function onChange(_) {
|
|
81
|
+
var allKeys = pipeline.getFeatureOptions(allEnableKeys);
|
|
82
|
+
|
|
79
83
|
if (isAllChecked) {
|
|
80
84
|
_onChange(arrayUtils.diff(value, allKeys), '', allKeys, 'uncheck-all');
|
|
81
85
|
} else {
|
|
@@ -96,9 +100,11 @@ export function multiSelect() {
|
|
|
96
100
|
var rowKey = internals.safeGetRowKey(primaryKey, row, rowIndex);
|
|
97
101
|
var checkboxCellProps = {};
|
|
98
102
|
var preCellProps = (_b = (_a = opts.checkboxColumn) === null || _a === void 0 ? void 0 : _a.getCellProps) === null || _b === void 0 ? void 0 : _b.call(_a, value, row, rowIndex);
|
|
103
|
+
var fullRowsSet = pipeline.getFeatureOptions(fullRowsSetKey) || new _Set();
|
|
104
|
+
var selectValueSet = pipeline.getFeatureOptions(selectValueSetKey) || new _Set();
|
|
99
105
|
|
|
100
|
-
if (
|
|
101
|
-
var prevChecked =
|
|
106
|
+
if (fullRowsSet.has(rowKey) && clickArea === 'cell') {
|
|
107
|
+
var prevChecked = selectValueSet.has(rowKey);
|
|
102
108
|
var disabled = isDisabled(row, rowIndex);
|
|
103
109
|
checkboxCellProps = {
|
|
104
110
|
style: {
|
|
@@ -122,7 +128,8 @@ export function multiSelect() {
|
|
|
122
128
|
}
|
|
123
129
|
|
|
124
130
|
var key = internals.safeGetRowKey(primaryKey, row, rowIndex);
|
|
125
|
-
var
|
|
131
|
+
var selectValueSet = pipeline.getFeatureOptions(selectValueSetKey) || new _Set();
|
|
132
|
+
var checked = selectValueSet.has(key);
|
|
126
133
|
return /*#__PURE__*/React.createElement(Checkbox, {
|
|
127
134
|
checked: checked,
|
|
128
135
|
disabled: isDisabled(row, rowIndex),
|
|
@@ -161,8 +168,9 @@ export function multiSelect() {
|
|
|
161
168
|
|
|
162
169
|
pipeline.appendRowPropsGetter(function (row, rowIndex) {
|
|
163
170
|
var rowKey = internals.safeGetRowKey(primaryKey, row, rowIndex);
|
|
171
|
+
var fullRowsSet = pipeline.getFeatureOptions(fullRowsSetKey) || new _Set();
|
|
164
172
|
|
|
165
|
-
if (!
|
|
173
|
+
if (!fullRowsSet.has(rowKey)) {
|
|
166
174
|
// rowKey 不在 fullKeySet 中说明这一行是在 multiSelect 之后才生成的,multiSelect 不对之后生成的行进行处理
|
|
167
175
|
return;
|
|
168
176
|
}
|
|
@@ -170,7 +178,8 @@ export function multiSelect() {
|
|
|
170
178
|
var style = {};
|
|
171
179
|
var className;
|
|
172
180
|
var onClick;
|
|
173
|
-
var
|
|
181
|
+
var selectValueSet = pipeline.getFeatureOptions(selectValueSetKey) || new _Set();
|
|
182
|
+
var checked = selectValueSet.has(rowKey);
|
|
174
183
|
|
|
175
184
|
if (opts.highlightRowWhenSelected && checked) {
|
|
176
185
|
className = 'highlight';
|
|
@@ -197,22 +206,32 @@ export function multiSelect() {
|
|
|
197
206
|
style: style,
|
|
198
207
|
onClick: onClick
|
|
199
208
|
};
|
|
200
|
-
});
|
|
209
|
+
}); // 只保留一份到pipeline, 避免行数据过多时内容被握住
|
|
210
|
+
|
|
211
|
+
pipeline.setFeatureOptions(fullRowsSetKey, fullKeySet);
|
|
212
|
+
pipeline.setFeatureOptions(allEnableKeys, allKeys);
|
|
213
|
+
pipeline.setFeatureOptions(selectValueSetKey, set);
|
|
214
|
+
fullKeySet = null;
|
|
215
|
+
allKeys = null;
|
|
216
|
+
set = null;
|
|
201
217
|
return pipeline;
|
|
202
218
|
|
|
203
219
|
function onCheckboxChange(prevChecked, key, batch) {
|
|
204
220
|
var batchKeys = [key];
|
|
205
221
|
|
|
206
222
|
if (batch && lastKey) {
|
|
207
|
-
var
|
|
208
|
-
|
|
223
|
+
var _allKeys = pipeline.getFeatureOptions(allEnableKeys);
|
|
224
|
+
|
|
225
|
+
var lastIdx = _allKeys.indexOf(lastKey);
|
|
226
|
+
|
|
227
|
+
var cntIdx = _allKeys.indexOf(key);
|
|
209
228
|
|
|
210
229
|
var _ref = lastIdx < cntIdx ? [lastIdx, cntIdx] : [cntIdx, lastIdx],
|
|
211
230
|
_ref2 = _slicedToArray(_ref, 2),
|
|
212
231
|
start = _ref2[0],
|
|
213
232
|
end = _ref2[1];
|
|
214
233
|
|
|
215
|
-
batchKeys = _sliceInstanceProperty(
|
|
234
|
+
batchKeys = _sliceInstanceProperty(_allKeys).call(_allKeys, start, end + 1);
|
|
216
235
|
}
|
|
217
236
|
|
|
218
237
|
if (prevChecked) {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { TablePipeline } from '../pipeline';
|
|
2
|
+
import { ArtColumn } from '../../interfaces';
|
|
3
|
+
interface RowDragEvent {
|
|
4
|
+
startRowIndex: number;
|
|
5
|
+
startRow: any;
|
|
6
|
+
endRowIndex: number;
|
|
7
|
+
endRow: any;
|
|
8
|
+
isFinished: boolean;
|
|
9
|
+
dragPosition: string;
|
|
10
|
+
}
|
|
11
|
+
export interface RowDragFeatureOptions {
|
|
12
|
+
/** 拖拽开始事件 */
|
|
13
|
+
onDragStart?: (event: RowDragEvent) => void;
|
|
14
|
+
/** 拖拽移动事件 */
|
|
15
|
+
onDragMove?: (event: RowDragEvent) => void;
|
|
16
|
+
/** 拖拽结束事件 */
|
|
17
|
+
onDragEnd?: (event: RowDragEvent) => void;
|
|
18
|
+
/** 判断一行是否要禁用拖拽 */
|
|
19
|
+
isDisabled?: (row: any, rowIndex: number) => boolean;
|
|
20
|
+
/** 拖拽列定义 */
|
|
21
|
+
rowDragColumn?: ArtColumn;
|
|
22
|
+
/** 行高 */
|
|
23
|
+
rowHeight?: number;
|
|
24
|
+
/** 拖拽过程中是否禁止滚动条滚动 */
|
|
25
|
+
suppressScrollMove?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare const ROW_DRAG_COLUMN_CODE = "$_row_drag_column_&";
|
|
28
|
+
export declare const rowDragKey = "rowDragKey";
|
|
29
|
+
export declare function rowDrag(opt: RowDragFeatureOptions): (pipeline: TablePipeline) => TablePipeline;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
2
|
+
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
3
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { fromEvent } from 'rxjs';
|
|
6
|
+
import { map, takeUntil } from 'rxjs/operators';
|
|
7
|
+
import cx from 'classnames';
|
|
8
|
+
import { Classes } from '../../base/styles';
|
|
9
|
+
export var ROW_DRAG_COLUMN_CODE = '$_row_drag_column_&';
|
|
10
|
+
export var rowDragKey = 'rowDragKey';
|
|
11
|
+
var SCROLL_OFFSET = 30;
|
|
12
|
+
var defaultRowDragColumn = {
|
|
13
|
+
name: '拖拽列',
|
|
14
|
+
code: ROW_DRAG_COLUMN_CODE,
|
|
15
|
+
lock: true,
|
|
16
|
+
title: '',
|
|
17
|
+
width: 40,
|
|
18
|
+
align: 'center',
|
|
19
|
+
getCellProps: function getCellProps(value, row, rowIndex) {
|
|
20
|
+
return {
|
|
21
|
+
className: cx(Classes.rowDragCell)
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
render: function render(value, row, rowIndex) {
|
|
25
|
+
return /*#__PURE__*/React.createElement("svg", {
|
|
26
|
+
viewBox: '0 0 1024 1024',
|
|
27
|
+
version: '1.1',
|
|
28
|
+
xmlns: 'http://www.w3.org/1999/xlink',
|
|
29
|
+
"data-icon": 'drag',
|
|
30
|
+
width: '16',
|
|
31
|
+
height: '16'
|
|
32
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
33
|
+
d: 'M298.688 192a64 64 0 1 0 128 0 64 64 0 0 0-128 0z m298.624 0a64 64 0 1 0 128 0 64 64 0 0 0-128 0zM298.688 512a64 64 0 1 0 128 0 64 64 0 0 0-128 0z m298.624 0a64 64 0 1 0 128 0 64 64 0 0 0-128 0z m-298.624 320a64 64 0 1 0 128 0 64 64 0 0 0-128 0z m298.624 0a64 64 0 1 0 128 0 64 64 0 0 0-128 0z',
|
|
34
|
+
"p-id": '4278'
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
export function rowDrag(opt) {
|
|
39
|
+
return function rowDragStep(pipeline) {
|
|
40
|
+
var _context;
|
|
41
|
+
|
|
42
|
+
var tableBody = pipeline.ref.current.domHelper && pipeline.ref.current.domHelper.tableBody;
|
|
43
|
+
var artTable = pipeline.ref.current.domHelper && pipeline.ref.current.domHelper.artTable;
|
|
44
|
+
if (!tableBody) return pipeline;
|
|
45
|
+
var dataSource = pipeline.getDataSource();
|
|
46
|
+
var rowHeight = (opt === null || opt === void 0 ? void 0 : opt.rowHeight) || 48;
|
|
47
|
+
|
|
48
|
+
var handleDragStrat = function handleDragStrat(event) {
|
|
49
|
+
var _a; // 开始拖拽
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
artTable.classList.add(cx(Classes.rowDragging));
|
|
53
|
+
(_a = opt === null || opt === void 0 ? void 0 : opt.onDragStart) === null || _a === void 0 ? void 0 : _a.call(opt, event);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
var handleDragMove = function handleDragMove(event) {
|
|
57
|
+
var _a;
|
|
58
|
+
|
|
59
|
+
(_a = opt === null || opt === void 0 ? void 0 : opt.onDragMove) === null || _a === void 0 ? void 0 : _a.call(opt, event);
|
|
60
|
+
pipeline.setStateAtKey(rowDragKey, event);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
var handleDragEnd = function handleDragEnd(event, isOutOfRange) {
|
|
64
|
+
var _a;
|
|
65
|
+
|
|
66
|
+
artTable.classList.remove(cx(Classes.rowDragging));
|
|
67
|
+
pipeline.setStateAtKey(rowDragKey, event); // 超出拖拽范围不触发dragend事件
|
|
68
|
+
|
|
69
|
+
if (!isOutOfRange) {
|
|
70
|
+
(_a = opt === null || opt === void 0 ? void 0 : opt.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(opt, event);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
var getDragEvent = function getDragEvent(startRowInfo, endRowInfo, _ref) {
|
|
75
|
+
var isFinished = _ref.isFinished,
|
|
76
|
+
_ref$dragPosition = _ref.dragPosition,
|
|
77
|
+
dragPosition = _ref$dragPosition === void 0 ? 'bottom' : _ref$dragPosition;
|
|
78
|
+
return {
|
|
79
|
+
startRowIndex: startRowInfo.rowIndex,
|
|
80
|
+
startRow: startRowInfo.row,
|
|
81
|
+
endRowIndex: endRowInfo.rowIndex,
|
|
82
|
+
endRow: endRowInfo.row,
|
|
83
|
+
dragPosition: dragPosition,
|
|
84
|
+
isFinished: isFinished
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
var updateScrollPosition = function updateScrollPosition(mouseMoveEvent) {
|
|
89
|
+
if (opt === null || opt === void 0 ? void 0 : opt.suppressScrollMove) return;
|
|
90
|
+
var clientY = mouseMoveEvent.clientY;
|
|
91
|
+
var tableBodyClientRect = tableBody.getBoundingClientRect();
|
|
92
|
+
var top = tableBodyClientRect.top,
|
|
93
|
+
height = tableBodyClientRect.height;
|
|
94
|
+
|
|
95
|
+
if (clientY + SCROLL_OFFSET >= top + height) {
|
|
96
|
+
pipeline.ref.current.domHelper.tableBody.scrollTop += SCROLL_OFFSET;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (clientY + SCROLL_OFFSET <= top) {
|
|
100
|
+
pipeline.ref.current.domHelper.tableBody.scrollTop -= SCROLL_OFFSET;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
var onMouseDown = function onMouseDown(mouseDownEvent) {
|
|
105
|
+
var _a;
|
|
106
|
+
|
|
107
|
+
var startRowInfo = getTargetRowInfo(mouseDownEvent.target, tableBody, dataSource);
|
|
108
|
+
var endRowInfo = startRowInfo;
|
|
109
|
+
if (!startRowInfo || startRowInfo.code !== rowDragColumn.code) return;
|
|
110
|
+
if ((_a = opt === null || opt === void 0 ? void 0 : opt.isDisabled) === null || _a === void 0 ? void 0 : _a.call(opt, startRowInfo.row, startRowInfo.rowIndex)) return; // 默认拖拽插入的位置是向下
|
|
111
|
+
|
|
112
|
+
var dragPosition = 'bottom';
|
|
113
|
+
var isOutOfRange = false;
|
|
114
|
+
var dragStartEvent = getDragEvent(startRowInfo, endRowInfo, {
|
|
115
|
+
isFinished: false,
|
|
116
|
+
dragPosition: 'bottom'
|
|
117
|
+
});
|
|
118
|
+
handleDragStrat(dragStartEvent);
|
|
119
|
+
var tableWidth = tableBody.clientWidth;
|
|
120
|
+
var startRowRects = startRowInfo.cell.getBoundingClientRect(); // 光标位置距离初始拖拽行的偏移量
|
|
121
|
+
|
|
122
|
+
var startOffset = mouseDownEvent.clientY - startRowRects.y;
|
|
123
|
+
var dragElement = createDragElement(startRowRects, tableWidth, rowHeight); // 可拖拽的范围
|
|
124
|
+
|
|
125
|
+
var dragRange = getDragRange(tableBody, {
|
|
126
|
+
startOffset: startOffset,
|
|
127
|
+
rowHeight: startRowRects.height
|
|
128
|
+
});
|
|
129
|
+
var mousemove$ = fromEvent(window, 'mousemove');
|
|
130
|
+
var mouseup$ = fromEvent(window, 'mouseup');
|
|
131
|
+
var rowDrag$ = mousemove$.pipe(map(function (mouseMoveEvent) {
|
|
132
|
+
var clientX = mouseMoveEvent.clientX,
|
|
133
|
+
clientY = mouseMoveEvent.clientY;
|
|
134
|
+
var tagretRow = getTargetRowInfo(mouseMoveEvent.target, tableBody, dataSource);
|
|
135
|
+
|
|
136
|
+
if (tagretRow) {
|
|
137
|
+
endRowInfo = tagretRow;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
var targetRowRects = endRowInfo.cell.getBoundingClientRect(); // 判断拖拽插入的位置,拖拽框上边框位于目标行之上则向上插入,否则向下插入
|
|
141
|
+
|
|
142
|
+
var isMoveToTop = clientY - startOffset < targetRowRects.y;
|
|
143
|
+
dragPosition = isMoveToTop ? 'top' : 'bottom';
|
|
144
|
+
isOutOfRange = isOutOfDragRange({
|
|
145
|
+
x: clientX,
|
|
146
|
+
y: clientY
|
|
147
|
+
}, dragRange);
|
|
148
|
+
updateScrollPosition(mouseMoveEvent); // 拖拽到底时让滚动条可以滚动
|
|
149
|
+
|
|
150
|
+
updateDragElementPosition(dragElement, dragRange, {
|
|
151
|
+
x: clientX,
|
|
152
|
+
y: clientY,
|
|
153
|
+
startOffset: startOffset
|
|
154
|
+
});
|
|
155
|
+
updateCurSorStyle(isOutOfRange);
|
|
156
|
+
return {
|
|
157
|
+
startRowInfo: startRowInfo,
|
|
158
|
+
endRowInfo: endRowInfo,
|
|
159
|
+
dragPosition: dragPosition
|
|
160
|
+
};
|
|
161
|
+
}), takeUntil(mouseup$));
|
|
162
|
+
rowDrag$.subscribe({
|
|
163
|
+
next: function next(_ref2) {
|
|
164
|
+
var startRowInfo = _ref2.startRowInfo,
|
|
165
|
+
endRowInfo = _ref2.endRowInfo,
|
|
166
|
+
dragPosition = _ref2.dragPosition;
|
|
167
|
+
var dragMoveEvent = getDragEvent(startRowInfo, endRowInfo, {
|
|
168
|
+
isFinished: false,
|
|
169
|
+
dragPosition: dragPosition
|
|
170
|
+
});
|
|
171
|
+
handleDragMove(dragMoveEvent);
|
|
172
|
+
},
|
|
173
|
+
complete: function complete() {
|
|
174
|
+
var dragEndEvent = getDragEvent(startRowInfo, endRowInfo, {
|
|
175
|
+
isFinished: true,
|
|
176
|
+
dragPosition: dragPosition
|
|
177
|
+
});
|
|
178
|
+
handleDragEnd(dragEndEvent, isOutOfRange);
|
|
179
|
+
removeDragElement(dragElement);
|
|
180
|
+
removeCurSorStyle();
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
var rowDragColumn = (opt === null || opt === void 0 ? void 0 : opt.rowDragColumn) || defaultRowDragColumn;
|
|
186
|
+
pipeline.setFeatureOptions('rowDragColumnKey', rowDragColumn.code);
|
|
187
|
+
|
|
188
|
+
var nextColumns = _sliceInstanceProperty(_context = pipeline.getColumns()).call(_context);
|
|
189
|
+
|
|
190
|
+
nextColumns.unshift(rowDragColumn);
|
|
191
|
+
pipeline.columns(nextColumns);
|
|
192
|
+
pipeline.addTableProps({
|
|
193
|
+
onMouseDown: onMouseDown
|
|
194
|
+
});
|
|
195
|
+
pipeline.appendRowPropsGetter(function (row, rowIndex) {
|
|
196
|
+
var _cx;
|
|
197
|
+
|
|
198
|
+
var rowDragEvent = pipeline.getStateAtKey(rowDragKey) || {};
|
|
199
|
+
var startRowIndex = rowDragEvent.startRowIndex,
|
|
200
|
+
endRowIndex = rowDragEvent.endRowIndex,
|
|
201
|
+
isFinished = rowDragEvent.isFinished,
|
|
202
|
+
dragPosition = rowDragEvent.dragPosition;
|
|
203
|
+
var isFooterCell = row[pipeline.getFeatureOptions('footerRowMetaKey')];
|
|
204
|
+
if (isFooterCell || isFinished || rowIndex !== startRowIndex && rowIndex !== endRowIndex) return;
|
|
205
|
+
var className = cx((_cx = {}, _defineProperty(_cx, Classes.rowDragStart, rowIndex === startRowIndex), _defineProperty(_cx, Classes.rowDragEnd, rowIndex === endRowIndex), _defineProperty(_cx, Classes.rowDragEndToTop, rowIndex === endRowIndex && dragPosition === 'top'), _defineProperty(_cx, Classes.rowDragEndToBottom, rowIndex === endRowIndex && dragPosition === 'bottom'), _cx));
|
|
206
|
+
return {
|
|
207
|
+
className: className
|
|
208
|
+
};
|
|
209
|
+
});
|
|
210
|
+
return pipeline;
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function getTargetRowInfo(target, tableBody, record) {
|
|
215
|
+
while (target && tableBody.contains(target)) {
|
|
216
|
+
if (target.getAttribute('data-role') === 'table-cell') {
|
|
217
|
+
var code = target.getAttribute('data-code');
|
|
218
|
+
var rowIndex = parseInt(target.getAttribute('data-rowindex'));
|
|
219
|
+
var row = record[rowIndex];
|
|
220
|
+
var isFooterCell = isEleInFooter(target);
|
|
221
|
+
if (!row || isFooterCell) return null;
|
|
222
|
+
return {
|
|
223
|
+
rowIndex: rowIndex,
|
|
224
|
+
row: row,
|
|
225
|
+
code: code,
|
|
226
|
+
cell: target
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
target = target.parentElement;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function isEleInFooter(target) {
|
|
237
|
+
while (target && !target.classList.contains(Classes.artTable)) {
|
|
238
|
+
if (target.classList.contains(Classes.tableFooter)) {
|
|
239
|
+
return true;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
target = target.parentElement;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function createDragElement(rects, tableWidth, rowHeight) {
|
|
249
|
+
var _context2, _context3, _context4;
|
|
250
|
+
|
|
251
|
+
var x = rects.x,
|
|
252
|
+
y = rects.y;
|
|
253
|
+
var dragMoveElement = document.createElement('div');
|
|
254
|
+
dragMoveElement.className = cx(Classes.rowDragElement);
|
|
255
|
+
dragMoveElement.style.cssText = _concatInstanceProperty(_context2 = _concatInstanceProperty(_context3 = _concatInstanceProperty(_context4 = "position:fixed;z-index:9999;left:".concat(x, "px;top:")).call(_context4, y, "px;pointer-events:none;width:")).call(_context3, tableWidth, "px;height:")).call(_context2, rowHeight, "px;background:var(--primary-color);opacity: 0.1;");
|
|
256
|
+
document.body.appendChild(dragMoveElement);
|
|
257
|
+
return dragMoveElement;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function updateDragElementPosition(element, dragRange, _ref3) {
|
|
261
|
+
var x = _ref3.x,
|
|
262
|
+
y = _ref3.y,
|
|
263
|
+
startOffset = _ref3.startOffset;
|
|
264
|
+
var validPosition = getValidPosition({
|
|
265
|
+
x: x,
|
|
266
|
+
y: y
|
|
267
|
+
}, dragRange);
|
|
268
|
+
element.style.top = validPosition.y - startOffset + 'px';
|
|
269
|
+
return element;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function removeDragElement(element) {
|
|
273
|
+
document.body.removeChild(element);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
function updateCurSorStyle(isOutOfRange) {
|
|
277
|
+
if (isOutOfRange) {
|
|
278
|
+
document.body.style.cursor = 'no-drop';
|
|
279
|
+
} else {
|
|
280
|
+
document.body.style.cursor = 'move';
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function removeCurSorStyle() {
|
|
285
|
+
document.body.style.cursor = 'default';
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function getDragRange(tableBody, _ref4) {
|
|
289
|
+
var startOffset = _ref4.startOffset,
|
|
290
|
+
rowHeight = _ref4.rowHeight;
|
|
291
|
+
var tableBodyClientRect = tableBody.getBoundingClientRect();
|
|
292
|
+
var height = tableBodyClientRect.height,
|
|
293
|
+
width = tableBodyClientRect.width,
|
|
294
|
+
x = tableBodyClientRect.x,
|
|
295
|
+
y = tableBodyClientRect.y;
|
|
296
|
+
return {
|
|
297
|
+
minX: x,
|
|
298
|
+
maxX: x + width,
|
|
299
|
+
minY: y - rowHeight + startOffset,
|
|
300
|
+
maxY: y + height + startOffset
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function getValidPosition(position, dragRange) {
|
|
305
|
+
var x = position.x,
|
|
306
|
+
y = position.y;
|
|
307
|
+
var minX = dragRange.minX,
|
|
308
|
+
maxX = dragRange.maxX,
|
|
309
|
+
minY = dragRange.minY,
|
|
310
|
+
maxY = dragRange.maxY;
|
|
311
|
+
var newX = x < minX ? minX : x > maxX ? maxX : x;
|
|
312
|
+
var newY = y < minY ? minY : y > maxY ? maxY : y;
|
|
313
|
+
return {
|
|
314
|
+
x: newX,
|
|
315
|
+
y: newY
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function isOutOfDragRange(position, dragRange) {
|
|
320
|
+
var x = position.x,
|
|
321
|
+
y = position.y;
|
|
322
|
+
var minX = dragRange.minX,
|
|
323
|
+
maxX = dragRange.maxX,
|
|
324
|
+
minY = dragRange.minY,
|
|
325
|
+
maxY = dragRange.maxY;
|
|
326
|
+
return x > maxX || x < minX || y > maxY || y < minY;
|
|
327
|
+
}
|
|
@@ -310,10 +310,29 @@ export function sort() {
|
|
|
310
310
|
title: col.title && col.title[0] ? col.title[0] : col.title
|
|
311
311
|
})));
|
|
312
312
|
|
|
313
|
-
|
|
314
|
-
|
|
313
|
+
var _sortNodeWithoutTitle = /*#__PURE__*/React.createElement(SortHeaderCell, {
|
|
314
|
+
onToggle: function onToggle(e) {
|
|
315
|
+
if (stopClickEventPropagation) {
|
|
316
|
+
e.stopPropagation();
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
toggle(col.code);
|
|
320
|
+
},
|
|
321
|
+
sortOrder: sortOrder,
|
|
322
|
+
column: col,
|
|
323
|
+
sortIndex: sortIndex,
|
|
324
|
+
sortOptions: sortOptions
|
|
325
|
+
}); // 开启标题行高自适应后,修改表头的渲染结构
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
if (col.renderHeader) {
|
|
329
|
+
result.title = col.renderHeader(result.title, _sortNodeWithoutTitle);
|
|
315
330
|
} else {
|
|
316
|
-
result.title
|
|
331
|
+
if (result.title && result.title[0]) {
|
|
332
|
+
result.title[0] = sortNode;
|
|
333
|
+
} else {
|
|
334
|
+
result.title = sortNode;
|
|
335
|
+
}
|
|
317
336
|
}
|
|
318
337
|
}
|
|
319
338
|
|
package/lib/locale/locale.d.ts
CHANGED
|
@@ -26,10 +26,14 @@ declare class LocaleCache {
|
|
|
26
26
|
*/
|
|
27
27
|
setLocalesData(locale: string, localeData?: LocaleDataType): {
|
|
28
28
|
locale: string;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
contain: string;
|
|
30
|
+
notContain: string;
|
|
31
|
+
equal: string;
|
|
32
|
+
notEqual: string;
|
|
33
|
+
isNull: string;
|
|
34
|
+
notIsNull: string;
|
|
35
|
+
resetFilter: string;
|
|
36
|
+
confirmFilter: string;
|
|
33
37
|
};
|
|
34
38
|
/**
|
|
35
39
|
* 获取当前语言包数据
|
package/lib/locale/zh-CN.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
declare const locale: {
|
|
2
2
|
locale: string;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
contain: string;
|
|
4
|
+
notContain: string;
|
|
5
|
+
equal: string;
|
|
6
|
+
notEqual: string;
|
|
7
|
+
isNull: string;
|
|
8
|
+
notIsNull: string;
|
|
9
|
+
resetFilter: string;
|
|
10
|
+
confirmFilter: string;
|
|
7
11
|
};
|
|
8
12
|
export default locale;
|
package/lib/locale/zh-CN.js
CHANGED
|
@@ -6,10 +6,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var locale = {
|
|
8
8
|
locale: 'zh-CN',
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
// Text Filter
|
|
10
|
+
contain: '包含',
|
|
11
|
+
notContain: '不包含',
|
|
12
|
+
equal: '等于',
|
|
13
|
+
notEqual: '不等于',
|
|
14
|
+
isNull: '为空',
|
|
15
|
+
notIsNull: '不为空',
|
|
16
|
+
// filter button
|
|
17
|
+
resetFilter: '重置',
|
|
18
|
+
confirmFilter: '确定'
|
|
13
19
|
};
|
|
14
20
|
var _default = locale;
|
|
15
21
|
exports.default = _default;
|
|
@@ -59,7 +59,8 @@ var _styles = require("../styles");
|
|
|
59
59
|
var TableDOMHelper = /*#__PURE__*/function () {
|
|
60
60
|
function TableDOMHelper(artTableWrapper) {
|
|
61
61
|
var _this = this,
|
|
62
|
-
_context2
|
|
62
|
+
_context2,
|
|
63
|
+
_context3;
|
|
63
64
|
|
|
64
65
|
(0, _classCallCheck2.default)(this, TableDOMHelper);
|
|
65
66
|
|
|
@@ -105,7 +106,7 @@ var TableDOMHelper = /*#__PURE__*/function () {
|
|
|
105
106
|
this.tableElement = this.artTable.querySelector(".".concat(_styles.Classes.tableBody, " table"));
|
|
106
107
|
this.tableFooter = this.artTable.querySelector(".".concat(_styles.Classes.tableFooter));
|
|
107
108
|
this.tableFooterMain = this.artTable.querySelector(".".concat(_styles.Classes.tableFooterMain));
|
|
108
|
-
var stickyScrollSelector = (0, _concat.default)(_context2 = ".".concat(_styles.Classes.artTable, " + .")).call(_context2, _styles.Classes.stickyScroll);
|
|
109
|
+
var stickyScrollSelector = (0, _concat.default)(_context2 = (0, _concat.default)(_context3 = ".".concat(_styles.Classes.artTable, " + .")).call(_context3, _styles.Classes.horizontalStickyScrollContainer, " .")).call(_context2, _styles.Classes.stickyScroll);
|
|
109
110
|
this.stickyScroll = artTableWrapper.querySelector(stickyScrollSelector);
|
|
110
111
|
this.stickyScrollItem = this.stickyScroll.querySelector(".".concat(_styles.Classes.stickyScrollItem));
|
|
111
112
|
}
|
|
@@ -118,33 +119,35 @@ var TableDOMHelper = /*#__PURE__*/function () {
|
|
|
118
119
|
}, {
|
|
119
120
|
key: "getTableRows",
|
|
120
121
|
value: function getTableRows() {
|
|
121
|
-
var
|
|
122
|
+
var _context4;
|
|
122
123
|
|
|
123
|
-
var tbody = this.artTable.querySelector((0, _concat.default)(
|
|
124
|
+
var tbody = this.artTable.querySelector((0, _concat.default)(_context4 = ".".concat(_styles.Classes.tableBody, " .")).call(_context4, _styles.Classes.virtual, " table tbody"));
|
|
124
125
|
return tbody.childNodes;
|
|
125
126
|
}
|
|
126
127
|
}, {
|
|
127
128
|
key: "getTableBodyHtmlTable",
|
|
128
129
|
value: function getTableBodyHtmlTable() {
|
|
129
|
-
var
|
|
130
|
+
var _context5;
|
|
130
131
|
|
|
131
|
-
return this.artTable.querySelector((0, _concat.default)(
|
|
132
|
+
return this.artTable.querySelector((0, _concat.default)(_context5 = ".".concat(_styles.Classes.tableBody, " .")).call(_context5, _styles.Classes.virtual, " table"));
|
|
132
133
|
}
|
|
133
134
|
}, {
|
|
134
135
|
key: "getLeftLockShadow",
|
|
135
136
|
value: function getLeftLockShadow() {
|
|
136
|
-
var
|
|
137
|
+
var _context6;
|
|
137
138
|
|
|
138
|
-
var selector = (0, _concat.default)(
|
|
139
|
-
|
|
139
|
+
var selector = (0, _concat.default)(_context6 = ".".concat(_styles.Classes.lockShadowMask, " .")).call(_context6, _styles.Classes.leftLockShadow);
|
|
140
|
+
var allLeftLockShadow = this.artTable.querySelectorAll(selector);
|
|
141
|
+
return allLeftLockShadow[allLeftLockShadow.length - 1]; // 当table-body、table-footer嵌套多层表格时,需要查找最后一个,否则会查找到嵌套表格的
|
|
140
142
|
}
|
|
141
143
|
}, {
|
|
142
144
|
key: "getRightLockShadow",
|
|
143
145
|
value: function getRightLockShadow() {
|
|
144
|
-
var
|
|
146
|
+
var _context7;
|
|
145
147
|
|
|
146
|
-
var selector = (0, _concat.default)(
|
|
147
|
-
|
|
148
|
+
var selector = (0, _concat.default)(_context7 = ".".concat(_styles.Classes.lockShadowMask, " .")).call(_context7, _styles.Classes.rightLockShadow);
|
|
149
|
+
var allRightLockShadow = this.artTable.querySelectorAll(selector);
|
|
150
|
+
return allRightLockShadow[allRightLockShadow.length - 1]; // 当table-body、table-footer嵌套多层表格时,需要查找最后一个,否则会查找到嵌套表格的
|
|
148
151
|
}
|
|
149
152
|
}, {
|
|
150
153
|
key: "getLoadingIndicator",
|
|
@@ -154,10 +157,10 @@ var TableDOMHelper = /*#__PURE__*/function () {
|
|
|
154
157
|
}, {
|
|
155
158
|
key: "getRowTop",
|
|
156
159
|
value: function getRowTop(rowIndex) {
|
|
157
|
-
var
|
|
160
|
+
var _context8, _context9;
|
|
158
161
|
|
|
159
162
|
if (rowIndex === 0) return 0;
|
|
160
|
-
var selector = (0, _concat.default)(
|
|
163
|
+
var selector = (0, _concat.default)(_context8 = (0, _concat.default)(_context9 = ".".concat(_styles.Classes.tableBody, " .")).call(_context9, _styles.Classes.tableRow, "[data-rowindex=\"")).call(_context8, rowIndex, "\"]");
|
|
161
164
|
var row = this.artTable.querySelector(selector);
|
|
162
165
|
var rowOffsetTop = row && row.offsetTop || 0;
|
|
163
166
|
var tableOffsetTop = this.tableElement.offsetTop || 0;
|
|
@@ -25,6 +25,9 @@ export declare const Classes: {
|
|
|
25
25
|
readonly stickyScrollItem: string;
|
|
26
26
|
readonly horizontalScrollContainer: string;
|
|
27
27
|
readonly verticalScrollPlaceholder: string;
|
|
28
|
+
readonly horizontalStickyScrollContainer: string;
|
|
29
|
+
readonly horizontalScrollLeftSpacer: string;
|
|
30
|
+
readonly horizontalScrollRightSpacer: string;
|
|
28
31
|
readonly lockShadowMask: string;
|
|
29
32
|
readonly lockShadow: string;
|
|
30
33
|
readonly leftLockShadow: string;
|
|
@@ -67,6 +70,13 @@ export declare const Classes: {
|
|
|
67
70
|
readonly popup: string;
|
|
68
71
|
readonly popupHeader: string;
|
|
69
72
|
readonly popupBody: string;
|
|
73
|
+
readonly rowDragging: string;
|
|
74
|
+
readonly rowDragStart: string;
|
|
75
|
+
readonly rowDragEnd: string;
|
|
76
|
+
readonly rowDragEndToTop: string;
|
|
77
|
+
readonly rowDragEndToBottom: string;
|
|
78
|
+
readonly rowDragElement: string;
|
|
79
|
+
readonly rowDragCell: string;
|
|
70
80
|
};
|
|
71
81
|
export declare const MenuClasses: {
|
|
72
82
|
menu: string;
|