@kdcloudjs/table 1.2.0-canary.1 → 1.2.0-canary.10

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.
Files changed (51) hide show
  1. package/dist/@kdcloudjs/table.css +1 -1
  2. package/dist/@kdcloudjs/table.js +517 -49
  3. package/dist/@kdcloudjs/table.js.map +1 -1
  4. package/dist/@kdcloudjs/table.min.css +1 -1
  5. package/dist/@kdcloudjs/table.min.js +8 -8
  6. package/dist/@kdcloudjs/table.min.js.map +1 -1
  7. package/es/locale/locale.d.ts +8 -4
  8. package/es/locale/zh-CN.d.ts +8 -4
  9. package/es/locale/zh-CN.js +10 -4
  10. package/es/table/base/helpers/TableDOMUtils.js +17 -14
  11. package/es/table/base/styles.d.ts +10 -0
  12. package/es/table/base/styles.js +12 -2
  13. package/es/table/base/table.js +38 -7
  14. package/es/table/common-views.js +3 -1
  15. package/es/table/interfaces.d.ts +5 -0
  16. package/es/table/pipeline/features/autoFill.js +7 -3
  17. package/es/table/pipeline/features/columnFilter.js +17 -5
  18. package/es/table/pipeline/features/columnResizeWidth.js +3 -1
  19. package/es/table/pipeline/features/filter/DefaultFilterContent.d.ts +1 -1
  20. package/es/table/pipeline/features/filter/DefaultFilterContent.js +11 -5
  21. package/es/table/pipeline/features/filter/Filter.d.ts +4 -1
  22. package/es/table/pipeline/features/filter/Filter.js +4 -2
  23. package/es/table/pipeline/features/index.d.ts +1 -0
  24. package/es/table/pipeline/features/index.js +2 -1
  25. package/es/table/pipeline/features/multiSelect.js +31 -12
  26. package/es/table/pipeline/features/rowDrag.d.ts +28 -0
  27. package/es/table/pipeline/features/rowDrag.js +325 -0
  28. package/es/table/pipeline/features/sort.js +22 -3
  29. package/lib/locale/locale.d.ts +8 -4
  30. package/lib/locale/zh-CN.d.ts +8 -4
  31. package/lib/locale/zh-CN.js +10 -4
  32. package/lib/table/base/helpers/TableDOMUtils.js +17 -14
  33. package/lib/table/base/styles.d.ts +10 -0
  34. package/lib/table/base/styles.js +12 -2
  35. package/lib/table/base/table.js +38 -7
  36. package/lib/table/common-views.js +3 -1
  37. package/lib/table/interfaces.d.ts +5 -0
  38. package/lib/table/pipeline/features/autoFill.js +7 -3
  39. package/lib/table/pipeline/features/columnFilter.js +18 -6
  40. package/lib/table/pipeline/features/columnResizeWidth.js +3 -1
  41. package/lib/table/pipeline/features/filter/DefaultFilterContent.d.ts +1 -1
  42. package/lib/table/pipeline/features/filter/DefaultFilterContent.js +11 -5
  43. package/lib/table/pipeline/features/filter/Filter.d.ts +4 -1
  44. package/lib/table/pipeline/features/filter/Filter.js +4 -2
  45. package/lib/table/pipeline/features/index.d.ts +1 -0
  46. package/lib/table/pipeline/features/index.js +9 -1
  47. package/lib/table/pipeline/features/multiSelect.js +33 -12
  48. package/lib/table/pipeline/features/rowDrag.d.ts +28 -0
  49. package/lib/table/pipeline/features/rowDrag.js +347 -0
  50. package/lib/table/pipeline/features/sort.js +22 -3
  51. 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(dataSource);
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 (fullKeySet.has(rowKey) && clickArea === 'cell') {
101
- var prevChecked = set.has(rowKey);
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 checked = set.has(key);
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 (!fullKeySet.has(rowKey)) {
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 checked = set.has(rowKey);
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 lastIdx = allKeys.indexOf(lastKey);
208
- var cntIdx = allKeys.indexOf(key);
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(allKeys).call(allKeys, start, end + 1);
234
+ batchKeys = _sliceInstanceProperty(_allKeys).call(_allKeys, start, end + 1);
216
235
  }
217
236
 
218
237
  if (prevChecked) {
@@ -0,0 +1,28 @@
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
+ export declare const ROW_DRAG_COLUMN_CODE = "$_row_drag_column_&";
26
+ export declare const rowDragKey = "rowDragKey";
27
+ export declare function rowDrag(opt: RowDragFeatureOptions): (pipeline: TablePipeline) => TablePipeline;
28
+ export {};
@@ -0,0 +1,325 @@
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
+ var clientY = mouseMoveEvent.clientY;
90
+ var tableBodyClientRect = tableBody.getBoundingClientRect();
91
+ var top = tableBodyClientRect.top,
92
+ height = tableBodyClientRect.height;
93
+
94
+ if (clientY + SCROLL_OFFSET >= top + height) {
95
+ pipeline.ref.current.domHelper.tableBody.scrollTop += SCROLL_OFFSET;
96
+ }
97
+
98
+ if (clientY + SCROLL_OFFSET <= top) {
99
+ pipeline.ref.current.domHelper.tableBody.scrollTop -= SCROLL_OFFSET;
100
+ }
101
+ };
102
+
103
+ var onMouseDown = function onMouseDown(mouseDownEvent) {
104
+ var _a;
105
+
106
+ var startRowInfo = getTargetRowInfo(mouseDownEvent.target, tableBody, dataSource);
107
+ var endRowInfo = startRowInfo;
108
+ if (!startRowInfo || startRowInfo.code !== rowDragColumn.code) return;
109
+ 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; // 默认拖拽插入的位置是向下
110
+
111
+ var dragPosition = 'bottom';
112
+ var isOutOfRange = false;
113
+ var dragStartEvent = getDragEvent(startRowInfo, endRowInfo, {
114
+ isFinished: false,
115
+ dragPosition: 'bottom'
116
+ });
117
+ handleDragStrat(dragStartEvent);
118
+ var tableWidth = tableBody.clientWidth;
119
+ var startRowRects = startRowInfo.cell.getBoundingClientRect(); // 光标位置距离初始拖拽行的偏移量
120
+
121
+ var startOffset = mouseDownEvent.clientY - startRowRects.y;
122
+ var dragElement = createDragElement(startRowRects, tableWidth, rowHeight); // 可拖拽的范围
123
+
124
+ var dragRange = getDragRange(tableBody, {
125
+ startOffset: startOffset,
126
+ rowHeight: startRowRects.height
127
+ });
128
+ var mousemove$ = fromEvent(window, 'mousemove');
129
+ var mouseup$ = fromEvent(window, 'mouseup');
130
+ var rowDrag$ = mousemove$.pipe(map(function (mouseMoveEvent) {
131
+ var clientX = mouseMoveEvent.clientX,
132
+ clientY = mouseMoveEvent.clientY;
133
+ var tagretRow = getTargetRowInfo(mouseMoveEvent.target, tableBody, dataSource);
134
+
135
+ if (tagretRow) {
136
+ endRowInfo = tagretRow;
137
+ }
138
+
139
+ var targetRowRects = endRowInfo.cell.getBoundingClientRect(); // 判断拖拽插入的位置,拖拽框上边框位于目标行之上则向上插入,否则向下插入
140
+
141
+ var isMoveToTop = clientY - startOffset < targetRowRects.y;
142
+ dragPosition = isMoveToTop ? 'top' : 'bottom';
143
+ isOutOfRange = isOutOfDragRange({
144
+ x: clientX,
145
+ y: clientY
146
+ }, dragRange);
147
+ updateScrollPosition(mouseMoveEvent); // 拖拽到底时让滚动条可以滚动
148
+
149
+ updateDragElementPosition(dragElement, dragRange, {
150
+ x: clientX,
151
+ y: clientY,
152
+ startOffset: startOffset
153
+ });
154
+ updateCurSorStyle(isOutOfRange);
155
+ return {
156
+ startRowInfo: startRowInfo,
157
+ endRowInfo: endRowInfo,
158
+ dragPosition: dragPosition
159
+ };
160
+ }), takeUntil(mouseup$));
161
+ rowDrag$.subscribe({
162
+ next: function next(_ref2) {
163
+ var startRowInfo = _ref2.startRowInfo,
164
+ endRowInfo = _ref2.endRowInfo,
165
+ dragPosition = _ref2.dragPosition;
166
+ var dragMoveEvent = getDragEvent(startRowInfo, endRowInfo, {
167
+ isFinished: false,
168
+ dragPosition: dragPosition
169
+ });
170
+ handleDragMove(dragMoveEvent);
171
+ },
172
+ complete: function complete() {
173
+ var dragEndEvent = getDragEvent(startRowInfo, endRowInfo, {
174
+ isFinished: true,
175
+ dragPosition: dragPosition
176
+ });
177
+ handleDragEnd(dragEndEvent, isOutOfRange);
178
+ removeDragElement(dragElement);
179
+ removeCurSorStyle();
180
+ }
181
+ });
182
+ };
183
+
184
+ var rowDragColumn = (opt === null || opt === void 0 ? void 0 : opt.rowDragColumn) || defaultRowDragColumn;
185
+
186
+ var nextColumns = _sliceInstanceProperty(_context = pipeline.getColumns()).call(_context);
187
+
188
+ nextColumns.unshift(rowDragColumn);
189
+ pipeline.columns(nextColumns);
190
+ pipeline.addTableProps({
191
+ onMouseDown: onMouseDown
192
+ });
193
+ pipeline.appendRowPropsGetter(function (row, rowIndex) {
194
+ var _cx;
195
+
196
+ var rowDragEvent = pipeline.getStateAtKey(rowDragKey) || {};
197
+ var startRowIndex = rowDragEvent.startRowIndex,
198
+ endRowIndex = rowDragEvent.endRowIndex,
199
+ isFinished = rowDragEvent.isFinished,
200
+ dragPosition = rowDragEvent.dragPosition;
201
+ var isFooterCell = row[pipeline.getFeatureOptions('footerRowMetaKey')];
202
+ if (isFooterCell || isFinished || rowIndex !== startRowIndex && rowIndex !== endRowIndex) return;
203
+ 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));
204
+ return {
205
+ className: className
206
+ };
207
+ });
208
+ return pipeline;
209
+ };
210
+ }
211
+
212
+ function getTargetRowInfo(target, tableBody, record) {
213
+ while (target && tableBody.contains(target)) {
214
+ if (target.getAttribute('data-role') === 'table-cell') {
215
+ var code = target.getAttribute('data-code');
216
+ var rowIndex = parseInt(target.getAttribute('data-rowindex'));
217
+ var row = record[rowIndex];
218
+ var isFooterCell = isEleInFooter(target);
219
+ if (!row || isFooterCell) return null;
220
+ return {
221
+ rowIndex: rowIndex,
222
+ row: row,
223
+ code: code,
224
+ cell: target
225
+ };
226
+ }
227
+
228
+ target = target.parentElement;
229
+ }
230
+
231
+ return null;
232
+ }
233
+
234
+ function isEleInFooter(target) {
235
+ while (target && !target.classList.contains(Classes.artTable)) {
236
+ if (target.classList.contains(Classes.tableFooter)) {
237
+ return true;
238
+ }
239
+
240
+ target = target.parentElement;
241
+ }
242
+
243
+ return false;
244
+ }
245
+
246
+ function createDragElement(rects, tableWidth, rowHeight) {
247
+ var _context2, _context3, _context4;
248
+
249
+ var x = rects.x,
250
+ y = rects.y;
251
+ var dragMoveElement = document.createElement('div');
252
+ dragMoveElement.className = cx(Classes.rowDragElement);
253
+ 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;");
254
+ document.body.appendChild(dragMoveElement);
255
+ return dragMoveElement;
256
+ }
257
+
258
+ function updateDragElementPosition(element, dragRange, _ref3) {
259
+ var x = _ref3.x,
260
+ y = _ref3.y,
261
+ startOffset = _ref3.startOffset;
262
+ var validPosition = getValidPosition({
263
+ x: x,
264
+ y: y
265
+ }, dragRange);
266
+ element.style.top = validPosition.y - startOffset + 'px';
267
+ return element;
268
+ }
269
+
270
+ function removeDragElement(element) {
271
+ document.body.removeChild(element);
272
+ }
273
+
274
+ function updateCurSorStyle(isOutOfRange) {
275
+ if (isOutOfRange) {
276
+ document.body.style.cursor = 'no-drop';
277
+ } else {
278
+ document.body.style.cursor = 'move';
279
+ }
280
+ }
281
+
282
+ function removeCurSorStyle() {
283
+ document.body.style.cursor = 'default';
284
+ }
285
+
286
+ function getDragRange(tableBody, _ref4) {
287
+ var startOffset = _ref4.startOffset,
288
+ rowHeight = _ref4.rowHeight;
289
+ var tableBodyClientRect = tableBody.getBoundingClientRect();
290
+ var height = tableBodyClientRect.height,
291
+ width = tableBodyClientRect.width,
292
+ x = tableBodyClientRect.x,
293
+ y = tableBodyClientRect.y;
294
+ return {
295
+ minX: x,
296
+ maxX: x + width,
297
+ minY: y - rowHeight + startOffset,
298
+ maxY: y + height + startOffset
299
+ };
300
+ }
301
+
302
+ function getValidPosition(position, dragRange) {
303
+ var x = position.x,
304
+ y = position.y;
305
+ var minX = dragRange.minX,
306
+ maxX = dragRange.maxX,
307
+ minY = dragRange.minY,
308
+ maxY = dragRange.maxY;
309
+ var newX = x < minX ? minX : x > maxX ? maxX : x;
310
+ var newY = y < minY ? minY : y > maxY ? maxY : y;
311
+ return {
312
+ x: newX,
313
+ y: newY
314
+ };
315
+ }
316
+
317
+ function isOutOfDragRange(position, dragRange) {
318
+ var x = position.x,
319
+ y = position.y;
320
+ var minX = dragRange.minX,
321
+ maxX = dragRange.maxX,
322
+ minY = dragRange.minY,
323
+ maxY = dragRange.maxY;
324
+ return x > maxX || x < minX || y > maxY || y < minY;
325
+ }
@@ -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
- if (result.title && result.title[0]) {
314
- result.title[0] = sortNode;
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 = sortNode;
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
 
@@ -26,10 +26,14 @@ declare class LocaleCache {
26
26
  */
27
27
  setLocalesData(locale: string, localeData?: LocaleDataType): {
28
28
  locale: string;
29
- 'global.selectholder': string;
30
- 'global.placeholder': string;
31
- 'global.cancel': string;
32
- 'global.confirm': string;
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
  * 获取当前语言包数据
@@ -1,8 +1,12 @@
1
1
  declare const locale: {
2
2
  locale: string;
3
- 'global.selectholder': string;
4
- 'global.placeholder': string;
5
- 'global.cancel': string;
6
- 'global.confirm': string;
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;
@@ -6,10 +6,16 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var locale = {
8
8
  locale: 'zh-CN',
9
- 'global.selectholder': '请选择',
10
- 'global.placeholder': '请输入...',
11
- 'global.cancel': '取消',
12
- 'global.confirm': '确定'
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 _context3;
122
+ var _context4;
122
123
 
123
- var tbody = this.artTable.querySelector((0, _concat.default)(_context3 = ".".concat(_styles.Classes.tableBody, " .")).call(_context3, _styles.Classes.virtual, " table tbody"));
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 _context4;
130
+ var _context5;
130
131
 
131
- return this.artTable.querySelector((0, _concat.default)(_context4 = ".".concat(_styles.Classes.tableBody, " .")).call(_context4, _styles.Classes.virtual, " table"));
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 _context5;
137
+ var _context6;
137
138
 
138
- var selector = (0, _concat.default)(_context5 = ".".concat(_styles.Classes.lockShadowMask, " .")).call(_context5, _styles.Classes.leftLockShadow);
139
- return this.artTable.querySelector(selector);
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 _context6;
146
+ var _context7;
145
147
 
146
- var selector = (0, _concat.default)(_context6 = ".".concat(_styles.Classes.lockShadowMask, " .")).call(_context6, _styles.Classes.rightLockShadow);
147
- return this.artTable.querySelector(selector);
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 _context7, _context8;
160
+ var _context8, _context9;
158
161
 
159
162
  if (rowIndex === 0) return 0;
160
- var selector = (0, _concat.default)(_context7 = (0, _concat.default)(_context8 = ".".concat(_styles.Classes.tableBody, " .")).call(_context8, _styles.Classes.tableRow, "[data-rowindex=\"")).call(_context7, rowIndex, "\"]");
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;