@kdcloudjs/table 1.2.2-canary.13 → 1.2.2-canary.14

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.
@@ -4,6 +4,7 @@ import _toConsumableArray from "@babel/runtime-corejs3/helpers/toConsumableArray
4
4
  import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
5
5
  import { makeRecursiveMapper, mergeCellProps, collectNodes, isLeafNode, isSelectColumn } from '../../utils';
6
6
  import { FILL_COLUMN_CODE } from './autoFill';
7
+ import { getEventCoordinates, hasMovedEnough, addPointerEventListeners, removePointerEventListeners } from './utils/touchEventUtils';
7
8
  var stateKey = 'columnDrag';
8
9
  var SCROLL_SIZE = 30;
9
10
  function disableSelect(event) {
@@ -61,251 +62,237 @@ export function columnDrag() {
61
62
  style: style
62
63
  });
63
64
  },
64
- headerCellProps: mergeCellProps(col.headerCellProps, {
65
- onMouseDown: !isLeaf || path.length > 1 ? undefined : function (e) {
65
+ headerCellProps: mergeCellProps(col.headerCellProps, _extends(_extends({}, isLeaf && path.length === 1 ? {
66
+ onMouseDown: function onMouseDown(e) {
66
67
  if (e.button !== 0 || !e.currentTarget.contains(e.target)) {
67
68
  return;
68
69
  }
69
- window.addEventListener('selectstart', disableSelect);
70
- // const cx = e.clientX
71
- // const width = col.width
72
- // const a = startIndex
73
- // const b = endIndex
74
- // const newColumnDragData = [...columnDragData]
75
- // let newColumn = [...columns]
76
- // let newStartIndex = startIndex
77
- // let endIdx = endIndex
78
- var columnMoved = false;
79
- var columns = pipeline.getColumns();
80
- var _pipeline$getStateAtK2 = pipeline.getStateAtKey(stateKey, {}),
81
- cloumnsTranslateData = _pipeline$getStateAtK2.cloumnsTranslateData;
82
- var cloumnsSortData = {};
83
- columns.forEach(function (item, index) {
84
- cloumnsSortData[item.code] = index;
85
- });
86
- var currentTarget = e.currentTarget;
87
- var rect = e.currentTarget.parentElement.getClientRects()[0];
88
- var startX = direction === 'rtl' ? rect.right : rect.left;
89
- var mouseDownClientX = e.clientX;
90
- var mouseDownClientY = e.clientY;
91
- var moveData = [];
92
- var allColumns = collectNodes(columns);
93
- var tableBodyClientRect = tableBody.getBoundingClientRect();
94
- var startScrollLeft = pipeline.ref.current.domHelper.virtual.scrollLeft;
95
- var updateScrollPosition = function updateScrollPosition(client) {
96
- var clientX = client.clientX;
97
- var left = tableBodyClientRect.left,
98
- width = tableBodyClientRect.width;
99
- if (clientX + SCROLL_SIZE >= left + width) {
100
- pipeline.ref.current.domHelper.virtual.scrollLeft += SCROLL_SIZE;
101
- }
102
- if (clientX - SCROLL_SIZE <= left) {
103
- pipeline.ref.current.domHelper.virtual.scrollLeft -= SCROLL_SIZE;
104
- }
105
- };
106
- function handleMouseMove(e) {
107
- var client = {
108
- clientX: e.clientX,
109
- clientY: e.clientY
110
- };
111
- var scrollDistance = pipeline.ref.current.domHelper.virtual.scrollLeft - startScrollLeft;
112
- var startPosition = startX - scrollDistance; // 表头最左边起点
113
- var offsetDistance = direction === 'rtl' ? startPosition - e.clientX : e.clientX - startPosition;
114
- updateScrollPosition(client);
115
- if (offsetDistance < 20) {
116
- return;
117
- } else {
118
- e.stopPropagation();
119
- }
120
- document.body.style.userSelect = 'none';
121
- currentTarget.style.cursor = 'move';
122
- // 循环计算每一个的位置
123
- // if (startIndex !== replaceIndex) {
124
- // const optionColumn = columns[startIndex]
125
- // const move = startIndex > replaceIndex ? 1 : -1
126
- // let index = Math.min(startIndex, replaceIndex)
127
- // while (index < Math.max(startIndex, replaceIndex)) {
128
- // const code = columns[index].code
129
- // cloumnsTranslateData[code] += move * optionColumn.width
130
- // cloumnsTranslateData[optionColumn.code] -= move * optionColumn.width
131
- // index += move
132
- // }
133
- // }
134
- // const opColumn = columns[startIndex]
135
- // let index = Math.min(startIndex, replaceIndex)
136
- // while (index <= Math.max(startIndex, replaceIndex)) {
137
- // const code = columns[index].code
138
- // if (index !== startIndex && index !== replaceIndex) {
139
- // cloumnsTranslateData[code] += opColumn.width * (index > startIndex ? -1 : 1)
140
- // cloumnsTranslateData[opColumn.code] += columns[index].width * (index < startIndex ? -1 : 1)
141
- // }
142
- // index++
143
- // }
144
- // 重置位置信息
145
- cloumnsTranslateData = {};
146
- allColumns.forEach(function (item) {
147
- cloumnsTranslateData[item.code] = 0;
148
- });
149
- // 计算平移位置
150
- var replaceIndex = 0;
151
- var totalWitdth = getColumnWidth(columns[replaceIndex]);
152
- while (totalWitdth < offsetDistance && replaceIndex < columns.length - 1) {
153
- replaceIndex++;
154
- totalWitdth += getColumnWidth(columns[replaceIndex]);
155
- }
156
- // 需要取最新startIndex, 不能直接用makeRecursiveMapper提供的startIndex(因为map时还没添加选择列、充满列等后面use添加的列)
157
- var startIndex;
158
- columns.forEach(function (column, index) {
159
- if (column.code === col.code) {
160
- startIndex = index;
161
- }
162
- });
163
- var optionColumn = columns[startIndex];
164
- var index = replaceIndex;
165
- if (startIndex > replaceIndex) {
166
- // 左移
167
- while (index < startIndex) {
168
- var _columns$index = columns[index],
169
- code = _columns$index.code,
170
- lock = _columns$index.lock,
171
- width = _columns$index.width,
172
- children = _columns$index.children;
173
- if (enableMove({
174
- code: code,
175
- lock: lock
176
- })) {
177
- cloumnsTranslateData[code] += _adjustTranslation(optionColumn.width);
178
- if (isLeafNode(columns[index])) {
179
- cloumnsTranslateData[optionColumn.code] -= _adjustTranslation(width);
180
- } else {
181
- cloumnsTranslateData[optionColumn.code] -= _adjustTranslation(getColumnWidth(columns[index]));
182
- moveAllChildren(children, cloumnsTranslateData, _adjustTranslation(optionColumn.width));
183
- }
184
- columnMoved = true;
185
- }
186
- index++;
187
- }
188
- } else if (startIndex < replaceIndex) {
189
- // 右移
190
- while (startIndex < index) {
191
- var _columns$index2 = columns[index],
192
- _code = _columns$index2.code,
193
- _lock = _columns$index2.lock,
194
- _width = _columns$index2.width,
195
- _children = _columns$index2.children;
196
- if (enableMove({
197
- code: _code,
198
- lock: _lock
199
- })) {
200
- cloumnsTranslateData[_code] -= _adjustTranslation(optionColumn.width);
201
- if (isLeafNode(columns[index])) {
202
- cloumnsTranslateData[optionColumn.code] += _adjustTranslation(_width);
203
- } else {
204
- cloumnsTranslateData[optionColumn.code] += _adjustTranslation(getColumnWidth(columns[index]));
205
- moveAllChildren(_children, cloumnsTranslateData, _adjustTranslation(optionColumn.width), true);
206
- }
207
- columnMoved = true;
208
- }
209
- index--;
70
+ handlePointerDown(e.nativeEvent, false, e.currentTarget);
71
+ },
72
+ onTouchStart: function onTouchStart(e) {
73
+ // 阻止触摸事件的默认行为
74
+ if (e.cancelable) {
75
+ e.preventDefault();
76
+ }
77
+ handlePointerDown(e.nativeEvent, true, e.currentTarget);
78
+ }
79
+ } : {}), {
80
+ style: style
81
+ }))
82
+ });
83
+ // 统一的拖拽处理函数
84
+ function handlePointerDown(startEvent, isTouch, currentTarget) {
85
+ var _a;
86
+ window.addEventListener('selectstart', disableSelect);
87
+ var columnMoved = false;
88
+ var columns = pipeline.getColumns();
89
+ var _pipeline$getStateAtK2 = pipeline.getStateAtKey(stateKey, {}),
90
+ cloumnsTranslateData = _pipeline$getStateAtK2.cloumnsTranslateData;
91
+ var cloumnsSortData = {};
92
+ columns.forEach(function (item, index) {
93
+ cloumnsSortData[item.code] = index;
94
+ });
95
+ var rect = (_a = currentTarget.parentElement) === null || _a === void 0 ? void 0 : _a.getClientRects()[0];
96
+ if (!rect) return;
97
+ var startX = direction === 'rtl' ? rect.right : rect.left;
98
+ var startCoordinates = getEventCoordinates(startEvent);
99
+ var mouseDownClientX = startCoordinates.clientX;
100
+ var mouseDownClientY = startCoordinates.clientY;
101
+ var moveData = [];
102
+ var allColumns = collectNodes(columns);
103
+ var tableBodyClientRect = tableBody.getBoundingClientRect();
104
+ var startScrollLeft = pipeline.ref.current.domHelper.virtual.scrollLeft;
105
+ var updateScrollPosition = function updateScrollPosition(client) {
106
+ var clientX = client.clientX;
107
+ var left = tableBodyClientRect.left,
108
+ width = tableBodyClientRect.width;
109
+ if (clientX + SCROLL_SIZE >= left + width) {
110
+ pipeline.ref.current.domHelper.virtual.scrollLeft += SCROLL_SIZE;
111
+ }
112
+ if (clientX - SCROLL_SIZE <= left) {
113
+ pipeline.ref.current.domHelper.virtual.scrollLeft -= SCROLL_SIZE;
114
+ }
115
+ };
116
+ function handlePointerMove(e) {
117
+ // 触摸事件需要阻止默认行为,防止页面滚动
118
+ if (isTouch && e.cancelable) {
119
+ e.preventDefault();
120
+ }
121
+ var coordinates = getEventCoordinates(e);
122
+ var client = {
123
+ clientX: coordinates.clientX,
124
+ clientY: coordinates.clientY
125
+ };
126
+ var scrollDistance = pipeline.ref.current.domHelper.virtual.scrollLeft - startScrollLeft;
127
+ var startPosition = startX - scrollDistance; // 表头最左边起点
128
+ var offsetDistance = direction === 'rtl' ? startPosition - coordinates.clientX : coordinates.clientX - startPosition;
129
+ updateScrollPosition(client);
130
+ if (offsetDistance < 20) {
131
+ return;
132
+ } else {
133
+ e.stopPropagation();
134
+ }
135
+ document.body.style.userSelect = 'none';
136
+ currentTarget.style.cursor = 'move';
137
+ // 重置位置信息
138
+ cloumnsTranslateData = {};
139
+ allColumns.forEach(function (item) {
140
+ cloumnsTranslateData[item.code] = 0;
141
+ });
142
+ // 计算平移位置
143
+ var replaceIndex = 0;
144
+ var totalWitdth = getColumnWidth(columns[replaceIndex]);
145
+ while (totalWitdth < offsetDistance && replaceIndex < columns.length - 1) {
146
+ replaceIndex++;
147
+ totalWitdth += getColumnWidth(columns[replaceIndex]);
148
+ }
149
+ // 需要取最新startIndex, 不能直接用makeRecursiveMapper提供的startIndex(因为map时还没添加选择列、充满列等后面use添加的列)
150
+ var startIndex;
151
+ columns.forEach(function (column, index) {
152
+ if (column.code === col.code) {
153
+ startIndex = index;
154
+ }
155
+ });
156
+ var optionColumn = columns[startIndex];
157
+ var index = replaceIndex;
158
+ if (startIndex > replaceIndex) {
159
+ // 左移
160
+ while (index < startIndex) {
161
+ var _columns$index = columns[index],
162
+ code = _columns$index.code,
163
+ lock = _columns$index.lock,
164
+ width = _columns$index.width,
165
+ children = _columns$index.children;
166
+ if (enableMove({
167
+ code: code,
168
+ lock: lock
169
+ })) {
170
+ cloumnsTranslateData[code] += _adjustTranslation(optionColumn.width);
171
+ if (isLeafNode(columns[index])) {
172
+ cloumnsTranslateData[optionColumn.code] -= _adjustTranslation(width);
173
+ } else {
174
+ cloumnsTranslateData[optionColumn.code] -= _adjustTranslation(getColumnWidth(columns[index]));
175
+ moveAllChildren(children, cloumnsTranslateData, _adjustTranslation(optionColumn.width));
210
176
  }
177
+ columnMoved = true;
211
178
  }
212
- window.requestAnimationFrame(function () {
213
- pipeline.setStateAtKey(stateKey, {
214
- cloumnsTranslateData: cloumnsTranslateData
215
- });
216
- moveData = [startIndex, replaceIndex];
217
- });
179
+ index++;
218
180
  }
219
- function handleMouseUp(e) {
220
- document.body.removeEventListener('mousemove', handleMouseMove);
221
- document.body.removeEventListener('mouseup', handleMouseUp);
222
- window.removeEventListener('selectstart', disableSelect);
223
- if (_isMoveWhenClicking(mouseDownClientX, mouseDownClientY, e.clientX, e.clientY)) {
224
- e.stopPropagation(); // 存在移动就阻止冒泡
225
- currentTarget.addEventListener('click', stopClickPropagation); // 阻止列头点击事件,防止拖动后触发列头过滤事件
181
+ } else if (startIndex < replaceIndex) {
182
+ // 右移
183
+ while (startIndex < index) {
184
+ var _columns$index2 = columns[index],
185
+ _code = _columns$index2.code,
186
+ _lock = _columns$index2.lock,
187
+ _width = _columns$index2.width,
188
+ _children = _columns$index2.children;
189
+ if (enableMove({
190
+ code: _code,
191
+ lock: _lock
192
+ })) {
193
+ cloumnsTranslateData[_code] -= _adjustTranslation(optionColumn.width);
194
+ if (isLeafNode(columns[index])) {
195
+ cloumnsTranslateData[optionColumn.code] += _adjustTranslation(_width);
196
+ } else {
197
+ cloumnsTranslateData[optionColumn.code] += _adjustTranslation(getColumnWidth(columns[index]));
198
+ moveAllChildren(_children, cloumnsTranslateData, _adjustTranslation(optionColumn.width), true);
199
+ }
200
+ columnMoved = true;
226
201
  }
202
+ index--;
203
+ }
204
+ }
205
+ window.requestAnimationFrame(function () {
206
+ pipeline.setStateAtKey(stateKey, {
207
+ cloumnsTranslateData: cloumnsTranslateData
208
+ });
209
+ moveData = [startIndex, replaceIndex];
210
+ });
211
+ }
212
+ function handlePointerUp(e) {
213
+ removePointerEventListeners(document.body, {
214
+ onPointerMove: handlePointerMove,
215
+ onPointerUp: handlePointerUp
216
+ }, isTouch);
217
+ window.removeEventListener('selectstart', disableSelect);
218
+ var endCoordinates = getEventCoordinates(e);
219
+ if (hasMovedEnough(mouseDownClientX, mouseDownClientY, endCoordinates.clientX, endCoordinates.clientY)) {
220
+ e.stopPropagation(); // 存在移动就阻止冒泡
221
+ currentTarget.addEventListener('click', stopClickPropagation); // 阻止列头点击事件,防止拖动后触发列头过滤事件
222
+ }
227
223
 
228
- window.requestAnimationFrame(function () {
229
- // 取消阻止列头点击事件
230
- currentTarget.removeEventListener('click', stopClickPropagation);
231
- currentTarget = null;
232
- var _moveData = moveData,
233
- _moveData2 = _slicedToArray(_moveData, 2),
234
- startIndex = _moveData2[0],
235
- replaceIndex = _moveData2[1];
236
- var optionColumn = columns[startIndex];
237
- // const move = startIndex > replaceIndex ? 1 : -1
238
- // let index = Math.min(startIndex, replaceIndex)
239
- // while (index < Math.max(startIndex, replaceIndex) && index > 0) {
240
- // const code = columns[index].code
241
- // cloumnsSortData[optionColumn.code] -= move
242
- // cloumnsSortData[code] += move
243
- // index += move
244
- // }
245
- var index = replaceIndex;
246
- if (startIndex > replaceIndex) {
247
- // 左移
248
- while (index < startIndex) {
249
- var _columns$index3 = columns[index],
250
- code = _columns$index3.code,
251
- lock = _columns$index3.lock;
252
- if (enableMove({
253
- code: code,
254
- lock: lock
255
- })) {
256
- cloumnsSortData[code] += 1;
257
- cloumnsSortData[optionColumn.code] -= 1;
258
- columnMoved = true;
259
- }
260
- index++;
261
- }
262
- } else if (startIndex < replaceIndex) {
263
- // 右移
264
- while (index > startIndex) {
265
- var _columns$index4 = columns[index],
266
- _code2 = _columns$index4.code,
267
- _lock2 = _columns$index4.lock;
268
- if (enableMove({
269
- code: _code2,
270
- lock: _lock2
271
- })) {
272
- cloumnsSortData[_code2] -= 1;
273
- cloumnsSortData[optionColumn.code] += 1;
274
- columnMoved = true;
275
- }
276
- index--;
277
- }
224
+ window.requestAnimationFrame(function () {
225
+ // 取消阻止列头点击事件
226
+ currentTarget.removeEventListener('click', stopClickPropagation);
227
+ currentTarget = null;
228
+ var _moveData = moveData,
229
+ _moveData2 = _slicedToArray(_moveData, 2),
230
+ startIndex = _moveData2[0],
231
+ replaceIndex = _moveData2[1];
232
+ var optionColumn = columns[startIndex];
233
+ var index = replaceIndex;
234
+ if (startIndex > replaceIndex) {
235
+ // 左移
236
+ while (index < startIndex) {
237
+ var _columns$index3 = columns[index],
238
+ code = _columns$index3.code,
239
+ lock = _columns$index3.lock;
240
+ if (enableMove({
241
+ code: code,
242
+ lock: lock
243
+ })) {
244
+ cloumnsSortData[code] += 1;
245
+ cloumnsSortData[optionColumn.code] -= 1;
246
+ columnMoved = true;
278
247
  }
279
- var onColumnDragStopped = opts.onColumnDragStopped;
280
- // 拖拽结束返回列顺序
281
- if (onColumnDragStopped) {
282
- var _context;
283
- var isRowDragColumn = function isRowDragColumn(code) {
284
- var rowDragColumnKey = pipeline.getFeatureOptions('rowDragColumnKey');
285
- return code === rowDragColumnKey;
286
- };
287
- var newColumns = _filterInstanceProperty(_context = sortColumns(columns, cloumnsSortData)).call(_context, function (column) {
288
- return column.code !== FILL_COLUMN_CODE && !isRowDragColumn(column.code) && !isSelectColumn(column);
289
- });
290
- // TODO drag需要在resize之后use,否则这里返回的列对应的宽度不是拖拽后的
291
- onColumnDragStopped(columnMoved, newColumns);
248
+ index++;
249
+ }
250
+ } else if (startIndex < replaceIndex) {
251
+ // 右移
252
+ while (index > startIndex) {
253
+ var _columns$index4 = columns[index],
254
+ _code2 = _columns$index4.code,
255
+ _lock2 = _columns$index4.lock;
256
+ if (enableMove({
257
+ code: _code2,
258
+ lock: _lock2
259
+ })) {
260
+ cloumnsSortData[_code2] -= 1;
261
+ cloumnsSortData[optionColumn.code] += 1;
262
+ columnMoved = true;
292
263
  }
293
- pipeline.setStateAtKey(stateKey, {
294
- cloumnsTranslateData: null
295
- });
264
+ index--;
265
+ }
266
+ }
267
+ var onColumnDragStopped = opts.onColumnDragStopped;
268
+ // 拖拽结束返回列顺序
269
+ if (onColumnDragStopped) {
270
+ var _context;
271
+ var isRowDragColumn = function isRowDragColumn(code) {
272
+ var rowDragColumnKey = pipeline.getFeatureOptions('rowDragColumnKey');
273
+ return code === rowDragColumnKey;
274
+ };
275
+ var newColumns = _filterInstanceProperty(_context = sortColumns(columns, cloumnsSortData)).call(_context, function (column) {
276
+ return column.code !== FILL_COLUMN_CODE && !isRowDragColumn(column.code) && !isSelectColumn(column);
296
277
  });
297
- document.body.style.userSelect = '';
298
- currentTarget.style.opacity = '';
299
- currentTarget.style.cursor = '';
278
+ // TODO drag需要在resize之后use,否则这里返回的列对应的宽度不是拖拽后的
279
+ onColumnDragStopped(columnMoved, newColumns);
300
280
  }
301
- var onColumnDragStart = opts.onColumnDragStart;
302
- onColumnDragStart && onColumnDragStart(col);
303
- document.body.addEventListener('mousemove', handleMouseMove);
304
- document.body.addEventListener('mouseup', handleMouseUp);
305
- },
306
- style: style
307
- })
308
- });
281
+ pipeline.setStateAtKey(stateKey, {
282
+ cloumnsTranslateData: null
283
+ });
284
+ });
285
+ document.body.style.userSelect = '';
286
+ currentTarget.style.opacity = '';
287
+ currentTarget.style.cursor = '';
288
+ }
289
+ var onColumnDragStart = opts.onColumnDragStart;
290
+ onColumnDragStart && onColumnDragStart(col);
291
+ addPointerEventListeners(document.body, {
292
+ onPointerMove: handlePointerMove,
293
+ onPointerUp: handlePointerUp
294
+ }, isTouch);
295
+ }
309
296
  }));
310
297
  };
311
298
  }
@@ -333,13 +320,4 @@ function moveAllChildren(cols, cloumnsTranslateData, width, isMinus) {
333
320
  moveAllChildren(children, cloumnsTranslateData, width);
334
321
  }
335
322
  });
336
- }
337
- function _isMoveWhenClicking(mouseDownClientX, mouseDownClientY, mouseUpClientX, mouseUpClientY) {
338
- var xDiff = mouseUpClientX - mouseDownClientX;
339
- var yDiff = mouseUpClientY - mouseDownClientY;
340
- // 鼠标点按和松开的偏移量大于5px,认为存在移动
341
- if (Math.sqrt(xDiff * xDiff + yDiff * yDiff) > 5) {
342
- return true;
343
- }
344
- return false;
345
323
  }
@@ -12,6 +12,7 @@ import { mergeCellProps, collectNodes, makeRecursiveMapper, isGroupColumn } from
12
12
  import { internals } from '../../internals';
13
13
  import { Classes } from '../../base/styles';
14
14
  import { swapRTLDirection } from '../../base/utils';
15
+ import { getEventCoordinates } from './utils/touchEventUtils';
15
16
  var TableHeaderCellResize = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: absolute;\n top: 0;\n ", ": -5px;\n height: 100%;\n width: 10px;\n cursor: ew-resize;\n display: flex;\n flex-direction: column;\n align-items: center;\n z-index:1;\n\n &:after {\n content: \"\";\n position: absolute;\n display: block;\n ", ": calc(50% - 1px);\n width: 1px;\n height: calc(100% - 14px);\n top: 7px;\n }\n"])), function (props) {
16
17
  return swapRTLDirection(props.direction, 'right');
17
18
  }, function (props) {
@@ -65,10 +66,12 @@ export function columnResize() {
65
66
  var _a;
66
67
  (_a = opts.doubleClickCallback) === null || _a === void 0 ? void 0 : _a.call(opts, e, col);
67
68
  };
68
- var handleMouseDown = function handleMouseDown(e, col) {
69
+ // 通用的拖拽处理逻辑
70
+ var handleResize = function handleResize(startEvent, col, eventType) {
69
71
  window.addEventListener('selectstart', disableSelect);
70
72
  var changedColumnSize = {};
71
- var startX = e.clientX;
73
+ var startCoordinates = getEventCoordinates(startEvent);
74
+ var startX = startCoordinates.clientX;
72
75
  var children = col.children,
73
76
  code = col.code,
74
77
  _col$features = col.features,
@@ -79,9 +82,22 @@ export function columnResize() {
79
82
  var realMaxSize = typeof maxWidth === 'number' ? maxWidth : maxSize;
80
83
  var columnSize = pipeline.getFeatureOptions(COLUMN_SIZE_KEY);
81
84
  var recordColumnSize = columnSize;
82
- e.stopPropagation();
83
- var nextSize$ = fromEvent(window, 'mousemove').pipe(op.takeUntil(fromEvent(window, 'mouseup')), op.map(function (e) {
84
- var movingX = e.clientX;
85
+ // 根据事件类型选择不同的事件监听器
86
+ var moveEventName = eventType === 'mouse' ? 'mousemove' : 'touchmove';
87
+ var endEventName = eventType === 'mouse' ? 'mouseup' : 'touchend';
88
+ var moveEventOptions = eventType === 'touch' ? {
89
+ passive: false
90
+ } : undefined;
91
+ var endEventOptions = eventType === 'touch' ? {
92
+ passive: false
93
+ } : undefined;
94
+ var nextSize$ = fromEvent(window, moveEventName, moveEventOptions).pipe(op.takeUntil(fromEvent(window, endEventName, endEventOptions)), op.map(function (e) {
95
+ // 触摸事件需要阻止默认行为,防止页面滚动
96
+ if (eventType === 'touch' && e.cancelable) {
97
+ e.preventDefault();
98
+ }
99
+ var coordinates = getEventCoordinates(e);
100
+ var movingX = coordinates.clientX;
85
101
  var nextColumnSize = _extends({}, columnSize);
86
102
  var deltaSum = pipeline.ctx.direction === 'rtl' ? startX - movingX : movingX - startX;
87
103
  var deltaRemaining = deltaSum;
@@ -139,6 +155,19 @@ export function columnResize() {
139
155
  }
140
156
  });
141
157
  };
158
+ var handleMouseDown = function handleMouseDown(e, col) {
159
+ e.stopPropagation();
160
+ handleResize(e.nativeEvent, col, 'mouse');
161
+ };
162
+ // 触摸事件处理函数
163
+ var handleTouchStart = function handleTouchStart(e, col) {
164
+ // 阻止触摸事件的默认行为
165
+ if (e.cancelable) {
166
+ e.preventDefault();
167
+ }
168
+ e.stopPropagation();
169
+ handleResize(e.nativeEvent, col, 'touch');
170
+ };
142
171
  var isGroup = isGroupColumn(pipeline.getColumns());
143
172
  return pipeline.mapColumns(makeRecursiveMapper(function (col) {
144
173
  var _a;
@@ -156,6 +185,9 @@ export function columnResize() {
156
185
  },
157
186
  onMouseDown: function onMouseDown(e) {
158
187
  return handleMouseDown(e, col);
188
+ },
189
+ onTouchStart: function onTouchStart(e) {
190
+ return handleTouchStart(e, col);
159
191
  }
160
192
  }) : /*#__PURE__*/React.createElement(TableHeaderCellResize, {
161
193
  direction: pipeline.ctx.direction,
@@ -165,6 +197,9 @@ export function columnResize() {
165
197
  },
166
198
  onMouseDown: function onMouseDown(e) {
167
199
  return handleMouseDown(e, col);
200
+ },
201
+ onTouchStart: function onTouchStart(e) {
202
+ return handleTouchStart(e, col);
168
203
  }
169
204
  }))),
170
205
  headerCellProps: mergeCellProps(col.headerCellProps, {