@kdcloudjs/table 1.2.2-canary.5 → 1.2.2-canary.7

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.
@@ -111,7 +111,7 @@ var Z = {
111
111
  scrollItem: 30,
112
112
  loadingIndicator: 40
113
113
  };
114
- export var GlobalStyle = createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .", "{\n position: absolute;\n top:0;\n left:0;\n z-index: 9999;\n pointer-events:none;\n user-select: none;\n\n display:flex;\n opacity: 0.9;\n align-items:center;\n min-width:80px;\n padding: 0px 8px;\n border: 1px solid #d9d9d9;\n box-shadow: 0px 6px 16px 3px rgba(0,0,0,0.08);\n border-radius: 2px;\n background: #fff;\n\n .", "{\n font-size:12px;\n overflow:hidden;\n text-overflow: ellipsis;\n white-space:nowrap;\n }\n \n }\n\n .", "{\n position: absolute;\n top:0;\n left:0;\n z-index: 9998;\n pointer-events:none;\n user-select: none;\n height: 2px;\n background: var(--primary-color);\n }\n .", ":before{\n content: \" \";\n position: absolute;\n width: 8px;\n height: 8px;\n top:-4px;\n border: 2px solid var(--primary-color);\n border-radius: 50%;\n background:#fff;\n }\n"])), Classes.rowDragElement, Classes.rowDragElementLabel, Classes.rowDragLine, Classes.treeTableRowDragLine);
114
+ export var GlobalStyle = createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .", "{\n position: absolute;\n top:0;\n left:0;\n z-index: 9999;\n pointer-events:none;\n user-select: none;\n\n display:flex;\n opacity: 0.9;\n align-items:center;\n min-width:80px;\n padding: 0px 8px;\n border: 1px solid #d9d9d9;\n box-shadow: 0px 6px 16px 3px rgba(0,0,0,0.08);\n border-radius: 2px;\n background: #fff;\n max-height:48px;\n\n .", "{\n font-size:12px;\n overflow:hidden;\n text-overflow: ellipsis;\n white-space:nowrap;\n }\n \n }\n\n .", "{\n position: absolute;\n top:0;\n left:0;\n z-index: 9998;\n pointer-events:none;\n user-select: none;\n height: 2px;\n background: var(--primary-color);\n }\n .", ":before{\n content: \" \";\n position: absolute;\n width: 8px;\n height: 8px;\n top:-4px;\n border: 2px solid var(--primary-color);\n border-radius: 50%;\n background:#fff;\n }\n"])), Classes.rowDragElement, Classes.rowDragElementLabel, Classes.rowDragLine, Classes.treeTableRowDragLine);
115
115
  var outerBorderStyleMixin = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n border-top: 1px solid #cccccc;\n border-right: 1px solid #cccccc;\n border-bottom: 1px solid #cccccc;\n border-left: 1px solid #cccccc;\n\n td.", ",\n th.", " {\n border-left: none;\n }\n td.", ",\n th.", " {\n border-right: none;\n }\n\n thead tr.", " th,\n tbody tr.", " td {\n border-top: none;\n }\n &.has-footer tfoot tr.", " td {\n border-bottom: none;\n }\n &:not(.has-footer) tbody tr.", " td {\n border-bottom: none;\n }\n td.", ":not(.", "){\n border-left: var(---cell-border-vertical);\n }\n td.", ":not(.", "){\n border-right: var(---cell-border-vertical);\n }\n"])), Classes.first, Classes.first, Classes.last, Classes.last, Classes.first, Classes.first, Classes.last, Classes.last, Classes.rowSpan, Classes.first, Classes.rowSpan, Classes.last);
116
116
  export var defaultCSSVariables = {
117
117
  '--row-height': '48px',
@@ -79,7 +79,7 @@ export function rowDrag(opt) {
79
79
  direction = getDirection(cell, event.clientY, allowDragIntoRow);
80
80
  }
81
81
  }
82
- if (overIndex === -1 && dataSource.length > 0 && event.target === dropZoneTarget) {
82
+ if (overIndex === -1 && dataSource.length > 0 && dropZoneTarget.contains(event.target)) {
83
83
  overIndex = dataSource.length - 1;
84
84
  direction = 'bottom';
85
85
  }
@@ -185,7 +185,7 @@ export function rowDrag(opt) {
185
185
  timeoutId = setTimeout(function () {
186
186
  intervalId = setInterval(function () {
187
187
  tableBody.scrollTop += moveOffset;
188
- }, 100);
188
+ }, 50);
189
189
  }, 500);
190
190
  };
191
191
  var handleDragStart = function handleDragStart(mouseDownEvent) {
@@ -276,6 +276,9 @@ export function rowDrag(opt) {
276
276
  }
277
277
  };
278
278
  var handleDragStop = function handleDragStop(mouseUpEvent) {
279
+ if (!isValidDrag) {
280
+ return;
281
+ }
279
282
  removeElement(dragElement);
280
283
  removeElement(dragLine);
281
284
  artTable.classList.remove(cx(Classes.rowDragging));
@@ -283,10 +286,6 @@ export function rowDrag(opt) {
283
286
  clearTimeout(timeoutId);
284
287
  clearInterval(intervalId);
285
288
  clearTimeout(expandRowTimeoutId);
286
- while (expandRowCallBackList.length > 0) {
287
- var callback = expandRowCallBackList.pop();
288
- callback();
289
- }
290
289
  var rowDropZones = rowDragApi.getRowDropZone();
291
290
  rowDropZones.forEach(function (dropzone) {
292
291
  var container = dropzone.getContainer();
@@ -300,6 +299,10 @@ export function rowDrag(opt) {
300
299
  var dragEvent = createDropTargetEvent(dropTarget, mouseUpEvent, startDataItem, currentDropZone);
301
300
  dropTarget.onDragStop(dragEvent);
302
301
  }
302
+ while (expandRowCallBackList.length > 0) {
303
+ var callback = expandRowCallBackList.pop();
304
+ callback();
305
+ }
303
306
  };
304
307
  var mousemove$ = fromEvent(window, 'mousemove');
305
308
  var mouseup$ = fromEvent(window, 'mouseup');
@@ -430,6 +433,7 @@ function createDragLine(isTreeTable) {
430
433
  return dragLine;
431
434
  }
432
435
  function positionDragLine(_ref) {
436
+ var _context7;
433
437
  var lineElement = _ref.lineElement,
434
438
  dragZone = _ref.dragZone,
435
439
  event = _ref.event;
@@ -442,6 +446,9 @@ function positionDragLine(_ref) {
442
446
  var treeModeOptions = getTreeModeOptions();
443
447
  var rowDragOptions = getRowDragOptions() || {};
444
448
  var allowDragIntoRow = rowDragOptions.allowDragIntoRow;
449
+ var isTreeTable = !!treeModeOptions;
450
+ var bodyRect = tableContainer.getBoundingClientRect();
451
+ var offsetParentSize = getElementRectWithOffset(document.body);
445
452
  if (dataSource.length === 0) {
446
453
  tableContainer.classList.add(Classes.rowDragNoData);
447
454
  lineElement.style.display = 'none';
@@ -451,60 +458,57 @@ function positionDragLine(_ref) {
451
458
  }
452
459
  // 鼠标悬停所在的拖拽行信息
453
460
  var dragItem = getDragRowItem(event.target, tableContainer, dataSource);
454
- if (!dragItem) return;
461
+ if (!dragItem) {
462
+ if (dataSource.length > 0 && tableContainer.contains(event.target)) {
463
+ var _context5, _context6;
464
+ var _rowIndex = dataSource.length - 1;
465
+ var _row = dataSource[_rowIndex];
466
+ var _direction = 'bottom';
467
+ var _targetCell = isTreeTable ? tableContainer.querySelector(_concatInstanceProperty(_context5 = "tr[data-rowindex=\"".concat(_rowIndex, "\"] .")).call(_context5, Classes.tableExtendCell)) : tableContainer.querySelector(_concatInstanceProperty(_context6 = "tr[data-rowindex=\"".concat(_rowIndex, "\"] .")).call(_context6, Classes.rowDragCell));
468
+ if (!_targetCell) return;
469
+ var _getLinePosition = getLinePosition({
470
+ treeModeOptions: treeModeOptions,
471
+ cell: _targetCell,
472
+ row: _row,
473
+ direction: _direction,
474
+ offsetParentSize: offsetParentSize,
475
+ bodyRect: bodyRect
476
+ }),
477
+ _top = _getLinePosition.top,
478
+ _left = _getLinePosition.left,
479
+ _width = _getLinePosition.width;
480
+ lineElement.style.left = "".concat(_left, "px");
481
+ lineElement.style.top = "".concat(_top, "px");
482
+ lineElement.style.width = "".concat(_width, "px");
483
+ }
484
+ return;
485
+ }
455
486
  var cell = dragItem.cell,
456
487
  rowIndex = dragItem.rowIndex,
457
488
  row = dragItem.row;
458
- var bodyRect = tableContainer.getBoundingClientRect();
459
- var offsetParentSize = getElementRectWithOffset(document.body);
460
- var isTreeTable = !!treeModeOptions;
461
489
  var allowDragInto = isTreeTable && allowDragIntoRow;
462
490
  var direction = getDirection(cell, event.clientY, allowDragInto);
463
- if (isTreeTable) {
464
- var _context5;
465
- var iconWidth = treeModeOptions.iconWidth,
466
- iconIndent = treeModeOptions.iconIndent,
467
- iconGap = treeModeOptions.iconGap,
468
- indentSize = treeModeOptions.indentSize,
469
- treeMetaKey = treeModeOptions.treeMetaKey;
470
- var expandCell = tableContainer.querySelector(_concatInstanceProperty(_context5 = "tr[data-rowindex=\"".concat(rowIndex, "\"] .")).call(_context5, Classes.tableExtendCell));
471
- if (expandCell) {
472
- var _getElementSize2 = _getElementSize(expandCell),
473
- paddingLeft = _getElementSize2.paddingLeft;
474
- var expandCellRect = expandCell.getBoundingClientRect();
475
- var _row$treeMetaKey = row[treeMetaKey],
476
- rowKey = _row$treeMetaKey.rowKey,
477
- depth = _row$treeMetaKey.depth,
478
- isLeaf = _row$treeMetaKey.isLeaf,
479
- expanded = _row$treeMetaKey.expanded;
480
- var addWidth = isLeaf ? iconWidth + iconGap : 0;
481
- var indent = iconIndent + depth * indentSize + addWidth;
482
- var x = expandCellRect.x,
483
- _y = expandCellRect.y,
484
- _height = expandCellRect.height;
485
- var _top = direction === 'bottom' ? _y + _height - offsetParentSize.top : _y - offsetParentSize.top;
486
- var offsetX = Math.max(x + paddingLeft + indent - bodyRect.x, 0);
487
- var _left = bodyRect.x + offsetX - offsetParentSize.left;
488
- lineElement.style.left = "".concat(_left, "px");
489
- lineElement.style.top = "".concat(_top, "px");
490
- lineElement.style.width = "".concat(bodyRect.width - offsetX, "px");
491
- if (direction === 'into') {
492
- lineElement.style.display = 'none';
493
- } else {
494
- lineElement.style.display = 'block';
495
- }
496
- return;
497
- }
498
- }
499
- // 根据鼠标悬停位置所在单元格和显示位置计算拖拽线的位置
500
- var rect = cell.getBoundingClientRect();
501
- var y = rect.y,
502
- height = rect.height;
503
- var top = direction === 'bottom' ? y + height - offsetParentSize.top : y - offsetParentSize.top;
504
- var left = bodyRect.x - offsetParentSize.left;
491
+ var targetCell = isTreeTable ? tableContainer.querySelector(_concatInstanceProperty(_context7 = "tr[data-rowindex=\"".concat(rowIndex, "\"] .")).call(_context7, Classes.tableExtendCell)) : cell;
492
+ if (!targetCell) return;
493
+ var _getLinePosition2 = getLinePosition({
494
+ treeModeOptions: treeModeOptions,
495
+ cell: targetCell,
496
+ row: row,
497
+ direction: direction,
498
+ offsetParentSize: offsetParentSize,
499
+ bodyRect: bodyRect
500
+ }),
501
+ top = _getLinePosition2.top,
502
+ left = _getLinePosition2.left,
503
+ width = _getLinePosition2.width;
505
504
  lineElement.style.left = "".concat(left, "px");
506
505
  lineElement.style.top = "".concat(top, "px");
507
- lineElement.style.width = "".concat(bodyRect.width, "px");
506
+ lineElement.style.width = "".concat(width, "px");
507
+ if (direction === 'into') {
508
+ lineElement.style.display = 'none';
509
+ } else {
510
+ lineElement.style.display = 'block';
511
+ }
508
512
  }
509
513
  function showDragLine(lineElement) {
510
514
  lineElement.style.display = 'block';
@@ -537,11 +541,11 @@ function positionDragElemment(element, event) {
537
541
  }
538
542
  function getElementRectWithOffset(el) {
539
543
  var offsetElementRect = el.getBoundingClientRect();
540
- var _getElementSize3 = _getElementSize(el),
541
- borderTopWidth = _getElementSize3.borderTopWidth,
542
- borderLeftWidth = _getElementSize3.borderLeftWidth,
543
- borderRightWidth = _getElementSize3.borderRightWidth,
544
- borderBottomWidth = _getElementSize3.borderBottomWidth;
544
+ var _getElementSize2 = _getElementSize(el),
545
+ borderTopWidth = _getElementSize2.borderTopWidth,
546
+ borderLeftWidth = _getElementSize2.borderLeftWidth,
547
+ borderRightWidth = _getElementSize2.borderRightWidth,
548
+ borderBottomWidth = _getElementSize2.borderBottomWidth;
545
549
  return {
546
550
  top: offsetElementRect.top + (borderTopWidth || 0),
547
551
  left: offsetElementRect.left + (borderLeftWidth || 0),
@@ -667,4 +671,54 @@ function getDirection(cell, clientY) {
667
671
  direction = 'top';
668
672
  }
669
673
  return direction;
670
- }
674
+ }
675
+ var getLinePosition = function getLinePosition(_ref2) {
676
+ var treeModeOptions = _ref2.treeModeOptions,
677
+ cell = _ref2.cell,
678
+ row = _ref2.row,
679
+ direction = _ref2.direction,
680
+ offsetParentSize = _ref2.offsetParentSize,
681
+ bodyRect = _ref2.bodyRect;
682
+ var isTreeTable = !!treeModeOptions;
683
+ if (isTreeTable) {
684
+ var iconWidth = treeModeOptions.iconWidth,
685
+ iconIndent = treeModeOptions.iconIndent,
686
+ iconGap = treeModeOptions.iconGap,
687
+ indentSize = treeModeOptions.indentSize,
688
+ treeMetaKey = treeModeOptions.treeMetaKey;
689
+ var _getElementSize3 = _getElementSize(cell),
690
+ paddingLeft = _getElementSize3.paddingLeft;
691
+ var expandCellRect = cell.getBoundingClientRect();
692
+ var _row$treeMetaKey = row[treeMetaKey],
693
+ rowKey = _row$treeMetaKey.rowKey,
694
+ depth = _row$treeMetaKey.depth,
695
+ isLeaf = _row$treeMetaKey.isLeaf,
696
+ expanded = _row$treeMetaKey.expanded;
697
+ var addWidth = isLeaf ? iconWidth + iconGap : 0;
698
+ var indent = iconIndent + depth * indentSize + addWidth;
699
+ var x = expandCellRect.x,
700
+ _y = expandCellRect.y,
701
+ _height = expandCellRect.height;
702
+ var _top2 = direction === 'bottom' ? _y + _height - offsetParentSize.top : _y - offsetParentSize.top;
703
+ var offsetX = Math.max(x + paddingLeft + indent - bodyRect.x, 0);
704
+ var _left2 = bodyRect.x + offsetX - offsetParentSize.left;
705
+ var _width2 = bodyRect.width - offsetX;
706
+ return {
707
+ top: _top2,
708
+ left: _left2,
709
+ width: _width2
710
+ };
711
+ }
712
+ // 根据鼠标悬停位置所在单元格和显示位置计算拖拽线的位置
713
+ var rect = cell.getBoundingClientRect();
714
+ var y = rect.y,
715
+ height = rect.height;
716
+ var top = direction === 'bottom' ? y + height - offsetParentSize.top : y - offsetParentSize.top;
717
+ var left = bodyRect.x - offsetParentSize.left;
718
+ var width = bodyRect.width;
719
+ return {
720
+ top: top,
721
+ left: left,
722
+ width: width
723
+ };
724
+ };
@@ -123,7 +123,7 @@ var Z = {
123
123
  scrollItem: 30,
124
124
  loadingIndicator: 40
125
125
  };
126
- var GlobalStyle = exports.GlobalStyle = (0, _styledComponents.createGlobalStyle)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n .", "{\n position: absolute;\n top:0;\n left:0;\n z-index: 9999;\n pointer-events:none;\n user-select: none;\n\n display:flex;\n opacity: 0.9;\n align-items:center;\n min-width:80px;\n padding: 0px 8px;\n border: 1px solid #d9d9d9;\n box-shadow: 0px 6px 16px 3px rgba(0,0,0,0.08);\n border-radius: 2px;\n background: #fff;\n\n .", "{\n font-size:12px;\n overflow:hidden;\n text-overflow: ellipsis;\n white-space:nowrap;\n }\n \n }\n\n .", "{\n position: absolute;\n top:0;\n left:0;\n z-index: 9998;\n pointer-events:none;\n user-select: none;\n height: 2px;\n background: var(--primary-color);\n }\n .", ":before{\n content: \" \";\n position: absolute;\n width: 8px;\n height: 8px;\n top:-4px;\n border: 2px solid var(--primary-color);\n border-radius: 50%;\n background:#fff;\n }\n"])), Classes.rowDragElement, Classes.rowDragElementLabel, Classes.rowDragLine, Classes.treeTableRowDragLine);
126
+ var GlobalStyle = exports.GlobalStyle = (0, _styledComponents.createGlobalStyle)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n .", "{\n position: absolute;\n top:0;\n left:0;\n z-index: 9999;\n pointer-events:none;\n user-select: none;\n\n display:flex;\n opacity: 0.9;\n align-items:center;\n min-width:80px;\n padding: 0px 8px;\n border: 1px solid #d9d9d9;\n box-shadow: 0px 6px 16px 3px rgba(0,0,0,0.08);\n border-radius: 2px;\n background: #fff;\n max-height:48px;\n\n .", "{\n font-size:12px;\n overflow:hidden;\n text-overflow: ellipsis;\n white-space:nowrap;\n }\n \n }\n\n .", "{\n position: absolute;\n top:0;\n left:0;\n z-index: 9998;\n pointer-events:none;\n user-select: none;\n height: 2px;\n background: var(--primary-color);\n }\n .", ":before{\n content: \" \";\n position: absolute;\n width: 8px;\n height: 8px;\n top:-4px;\n border: 2px solid var(--primary-color);\n border-radius: 50%;\n background:#fff;\n }\n"])), Classes.rowDragElement, Classes.rowDragElementLabel, Classes.rowDragLine, Classes.treeTableRowDragLine);
127
127
  var outerBorderStyleMixin = (0, _styledComponents.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n border-top: 1px solid #cccccc;\n border-right: 1px solid #cccccc;\n border-bottom: 1px solid #cccccc;\n border-left: 1px solid #cccccc;\n\n td.", ",\n th.", " {\n border-left: none;\n }\n td.", ",\n th.", " {\n border-right: none;\n }\n\n thead tr.", " th,\n tbody tr.", " td {\n border-top: none;\n }\n &.has-footer tfoot tr.", " td {\n border-bottom: none;\n }\n &:not(.has-footer) tbody tr.", " td {\n border-bottom: none;\n }\n td.", ":not(.", "){\n border-left: var(---cell-border-vertical);\n }\n td.", ":not(.", "){\n border-right: var(---cell-border-vertical);\n }\n"])), Classes.first, Classes.first, Classes.last, Classes.last, Classes.first, Classes.first, Classes.last, Classes.last, Classes.rowSpan, Classes.first, Classes.rowSpan, Classes.last);
128
128
  var defaultCSSVariables = exports.defaultCSSVariables = {
129
129
  '--row-height': '48px',
@@ -90,7 +90,7 @@ function rowDrag(opt) {
90
90
  direction = getDirection(cell, event.clientY, allowDragIntoRow);
91
91
  }
92
92
  }
93
- if (overIndex === -1 && dataSource.length > 0 && event.target === dropZoneTarget) {
93
+ if (overIndex === -1 && dataSource.length > 0 && dropZoneTarget.contains(event.target)) {
94
94
  overIndex = dataSource.length - 1;
95
95
  direction = 'bottom';
96
96
  }
@@ -196,7 +196,7 @@ function rowDrag(opt) {
196
196
  timeoutId = setTimeout(function () {
197
197
  intervalId = setInterval(function () {
198
198
  tableBody.scrollTop += moveOffset;
199
- }, 100);
199
+ }, 50);
200
200
  }, 500);
201
201
  };
202
202
  var handleDragStart = function handleDragStart(mouseDownEvent) {
@@ -287,6 +287,9 @@ function rowDrag(opt) {
287
287
  }
288
288
  };
289
289
  var handleDragStop = function handleDragStop(mouseUpEvent) {
290
+ if (!isValidDrag) {
291
+ return;
292
+ }
290
293
  removeElement(dragElement);
291
294
  removeElement(dragLine);
292
295
  artTable.classList.remove((0, _classnames.default)(_styles.Classes.rowDragging));
@@ -294,10 +297,6 @@ function rowDrag(opt) {
294
297
  clearTimeout(timeoutId);
295
298
  clearInterval(intervalId);
296
299
  clearTimeout(expandRowTimeoutId);
297
- while (expandRowCallBackList.length > 0) {
298
- var callback = expandRowCallBackList.pop();
299
- callback();
300
- }
301
300
  var rowDropZones = rowDragApi.getRowDropZone();
302
301
  rowDropZones.forEach(function (dropzone) {
303
302
  var container = dropzone.getContainer();
@@ -311,6 +310,10 @@ function rowDrag(opt) {
311
310
  var dragEvent = createDropTargetEvent(dropTarget, mouseUpEvent, startDataItem, currentDropZone);
312
311
  dropTarget.onDragStop(dragEvent);
313
312
  }
313
+ while (expandRowCallBackList.length > 0) {
314
+ var callback = expandRowCallBackList.pop();
315
+ callback();
316
+ }
314
317
  };
315
318
  var mousemove$ = (0, _rxjs.fromEvent)(window, 'mousemove');
316
319
  var mouseup$ = (0, _rxjs.fromEvent)(window, 'mouseup');
@@ -441,6 +444,7 @@ function createDragLine(isTreeTable) {
441
444
  return dragLine;
442
445
  }
443
446
  function positionDragLine(_ref) {
447
+ var _context7;
444
448
  var lineElement = _ref.lineElement,
445
449
  dragZone = _ref.dragZone,
446
450
  event = _ref.event;
@@ -453,6 +457,9 @@ function positionDragLine(_ref) {
453
457
  var treeModeOptions = getTreeModeOptions();
454
458
  var rowDragOptions = getRowDragOptions() || {};
455
459
  var allowDragIntoRow = rowDragOptions.allowDragIntoRow;
460
+ var isTreeTable = !!treeModeOptions;
461
+ var bodyRect = tableContainer.getBoundingClientRect();
462
+ var offsetParentSize = getElementRectWithOffset(document.body);
456
463
  if (dataSource.length === 0) {
457
464
  tableContainer.classList.add(_styles.Classes.rowDragNoData);
458
465
  lineElement.style.display = 'none';
@@ -462,60 +469,57 @@ function positionDragLine(_ref) {
462
469
  }
463
470
  // 鼠标悬停所在的拖拽行信息
464
471
  var dragItem = getDragRowItem(event.target, tableContainer, dataSource);
465
- if (!dragItem) return;
472
+ if (!dragItem) {
473
+ if (dataSource.length > 0 && tableContainer.contains(event.target)) {
474
+ var _context5, _context6;
475
+ var _rowIndex = dataSource.length - 1;
476
+ var _row = dataSource[_rowIndex];
477
+ var _direction = 'bottom';
478
+ var _targetCell = isTreeTable ? tableContainer.querySelector((0, _concat.default)(_context5 = "tr[data-rowindex=\"".concat(_rowIndex, "\"] .")).call(_context5, _styles.Classes.tableExtendCell)) : tableContainer.querySelector((0, _concat.default)(_context6 = "tr[data-rowindex=\"".concat(_rowIndex, "\"] .")).call(_context6, _styles.Classes.rowDragCell));
479
+ if (!_targetCell) return;
480
+ var _getLinePosition = getLinePosition({
481
+ treeModeOptions: treeModeOptions,
482
+ cell: _targetCell,
483
+ row: _row,
484
+ direction: _direction,
485
+ offsetParentSize: offsetParentSize,
486
+ bodyRect: bodyRect
487
+ }),
488
+ _top = _getLinePosition.top,
489
+ _left = _getLinePosition.left,
490
+ _width = _getLinePosition.width;
491
+ lineElement.style.left = "".concat(_left, "px");
492
+ lineElement.style.top = "".concat(_top, "px");
493
+ lineElement.style.width = "".concat(_width, "px");
494
+ }
495
+ return;
496
+ }
466
497
  var cell = dragItem.cell,
467
498
  rowIndex = dragItem.rowIndex,
468
499
  row = dragItem.row;
469
- var bodyRect = tableContainer.getBoundingClientRect();
470
- var offsetParentSize = getElementRectWithOffset(document.body);
471
- var isTreeTable = !!treeModeOptions;
472
500
  var allowDragInto = isTreeTable && allowDragIntoRow;
473
501
  var direction = getDirection(cell, event.clientY, allowDragInto);
474
- if (isTreeTable) {
475
- var _context5;
476
- var iconWidth = treeModeOptions.iconWidth,
477
- iconIndent = treeModeOptions.iconIndent,
478
- iconGap = treeModeOptions.iconGap,
479
- indentSize = treeModeOptions.indentSize,
480
- treeMetaKey = treeModeOptions.treeMetaKey;
481
- var expandCell = tableContainer.querySelector((0, _concat.default)(_context5 = "tr[data-rowindex=\"".concat(rowIndex, "\"] .")).call(_context5, _styles.Classes.tableExtendCell));
482
- if (expandCell) {
483
- var _getElementSize2 = _getElementSize(expandCell),
484
- paddingLeft = _getElementSize2.paddingLeft;
485
- var expandCellRect = expandCell.getBoundingClientRect();
486
- var _row$treeMetaKey = row[treeMetaKey],
487
- rowKey = _row$treeMetaKey.rowKey,
488
- depth = _row$treeMetaKey.depth,
489
- isLeaf = _row$treeMetaKey.isLeaf,
490
- expanded = _row$treeMetaKey.expanded;
491
- var addWidth = isLeaf ? iconWidth + iconGap : 0;
492
- var indent = iconIndent + depth * indentSize + addWidth;
493
- var x = expandCellRect.x,
494
- _y = expandCellRect.y,
495
- _height = expandCellRect.height;
496
- var _top = direction === 'bottom' ? _y + _height - offsetParentSize.top : _y - offsetParentSize.top;
497
- var offsetX = Math.max(x + paddingLeft + indent - bodyRect.x, 0);
498
- var _left = bodyRect.x + offsetX - offsetParentSize.left;
499
- lineElement.style.left = "".concat(_left, "px");
500
- lineElement.style.top = "".concat(_top, "px");
501
- lineElement.style.width = "".concat(bodyRect.width - offsetX, "px");
502
- if (direction === 'into') {
503
- lineElement.style.display = 'none';
504
- } else {
505
- lineElement.style.display = 'block';
506
- }
507
- return;
508
- }
509
- }
510
- // 根据鼠标悬停位置所在单元格和显示位置计算拖拽线的位置
511
- var rect = cell.getBoundingClientRect();
512
- var y = rect.y,
513
- height = rect.height;
514
- var top = direction === 'bottom' ? y + height - offsetParentSize.top : y - offsetParentSize.top;
515
- var left = bodyRect.x - offsetParentSize.left;
502
+ var targetCell = isTreeTable ? tableContainer.querySelector((0, _concat.default)(_context7 = "tr[data-rowindex=\"".concat(rowIndex, "\"] .")).call(_context7, _styles.Classes.tableExtendCell)) : cell;
503
+ if (!targetCell) return;
504
+ var _getLinePosition2 = getLinePosition({
505
+ treeModeOptions: treeModeOptions,
506
+ cell: targetCell,
507
+ row: row,
508
+ direction: direction,
509
+ offsetParentSize: offsetParentSize,
510
+ bodyRect: bodyRect
511
+ }),
512
+ top = _getLinePosition2.top,
513
+ left = _getLinePosition2.left,
514
+ width = _getLinePosition2.width;
516
515
  lineElement.style.left = "".concat(left, "px");
517
516
  lineElement.style.top = "".concat(top, "px");
518
- lineElement.style.width = "".concat(bodyRect.width, "px");
517
+ lineElement.style.width = "".concat(width, "px");
518
+ if (direction === 'into') {
519
+ lineElement.style.display = 'none';
520
+ } else {
521
+ lineElement.style.display = 'block';
522
+ }
519
523
  }
520
524
  function showDragLine(lineElement) {
521
525
  lineElement.style.display = 'block';
@@ -548,11 +552,11 @@ function positionDragElemment(element, event) {
548
552
  }
549
553
  function getElementRectWithOffset(el) {
550
554
  var offsetElementRect = el.getBoundingClientRect();
551
- var _getElementSize3 = _getElementSize(el),
552
- borderTopWidth = _getElementSize3.borderTopWidth,
553
- borderLeftWidth = _getElementSize3.borderLeftWidth,
554
- borderRightWidth = _getElementSize3.borderRightWidth,
555
- borderBottomWidth = _getElementSize3.borderBottomWidth;
555
+ var _getElementSize2 = _getElementSize(el),
556
+ borderTopWidth = _getElementSize2.borderTopWidth,
557
+ borderLeftWidth = _getElementSize2.borderLeftWidth,
558
+ borderRightWidth = _getElementSize2.borderRightWidth,
559
+ borderBottomWidth = _getElementSize2.borderBottomWidth;
556
560
  return {
557
561
  top: offsetElementRect.top + (borderTopWidth || 0),
558
562
  left: offsetElementRect.left + (borderLeftWidth || 0),
@@ -678,4 +682,54 @@ function getDirection(cell, clientY) {
678
682
  direction = 'top';
679
683
  }
680
684
  return direction;
681
- }
685
+ }
686
+ var getLinePosition = function getLinePosition(_ref2) {
687
+ var treeModeOptions = _ref2.treeModeOptions,
688
+ cell = _ref2.cell,
689
+ row = _ref2.row,
690
+ direction = _ref2.direction,
691
+ offsetParentSize = _ref2.offsetParentSize,
692
+ bodyRect = _ref2.bodyRect;
693
+ var isTreeTable = !!treeModeOptions;
694
+ if (isTreeTable) {
695
+ var iconWidth = treeModeOptions.iconWidth,
696
+ iconIndent = treeModeOptions.iconIndent,
697
+ iconGap = treeModeOptions.iconGap,
698
+ indentSize = treeModeOptions.indentSize,
699
+ treeMetaKey = treeModeOptions.treeMetaKey;
700
+ var _getElementSize3 = _getElementSize(cell),
701
+ paddingLeft = _getElementSize3.paddingLeft;
702
+ var expandCellRect = cell.getBoundingClientRect();
703
+ var _row$treeMetaKey = row[treeMetaKey],
704
+ rowKey = _row$treeMetaKey.rowKey,
705
+ depth = _row$treeMetaKey.depth,
706
+ isLeaf = _row$treeMetaKey.isLeaf,
707
+ expanded = _row$treeMetaKey.expanded;
708
+ var addWidth = isLeaf ? iconWidth + iconGap : 0;
709
+ var indent = iconIndent + depth * indentSize + addWidth;
710
+ var x = expandCellRect.x,
711
+ _y = expandCellRect.y,
712
+ _height = expandCellRect.height;
713
+ var _top2 = direction === 'bottom' ? _y + _height - offsetParentSize.top : _y - offsetParentSize.top;
714
+ var offsetX = Math.max(x + paddingLeft + indent - bodyRect.x, 0);
715
+ var _left2 = bodyRect.x + offsetX - offsetParentSize.left;
716
+ var _width2 = bodyRect.width - offsetX;
717
+ return {
718
+ top: _top2,
719
+ left: _left2,
720
+ width: _width2
721
+ };
722
+ }
723
+ // 根据鼠标悬停位置所在单元格和显示位置计算拖拽线的位置
724
+ var rect = cell.getBoundingClientRect();
725
+ var y = rect.y,
726
+ height = rect.height;
727
+ var top = direction === 'bottom' ? y + height - offsetParentSize.top : y - offsetParentSize.top;
728
+ var left = bodyRect.x - offsetParentSize.left;
729
+ var width = bodyRect.width;
730
+ return {
731
+ top: top,
732
+ left: left,
733
+ width: width
734
+ };
735
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kdcloudjs/table",
3
- "version": "1.2.2-canary.5",
3
+ "version": "1.2.2-canary.7",
4
4
  "description": "金蝶 react table 组件",
5
5
  "title": "table",
6
6
  "keywords": [