@visactor/vtable 0.18.3 → 0.18.4

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.
@@ -174,7 +174,7 @@ export declare abstract class BaseTable extends EventTarget implements BaseTable
174
174
  _makeVisibleCell(col: number, row: number): void;
175
175
  render(): void;
176
176
  renderAsync(): Promise<void>;
177
- _toRelativeRect(absoluteRect: Rect): Rect;
177
+ _toRelativeRect(absoluteRect: Rect, relativeX?: boolean, relativeY?: boolean): Rect;
178
178
  getVisibleRect(): Rect;
179
179
  get visibleRowCount(): number;
180
180
  getBodyVisibleCellRange(): {
@@ -45,7 +45,7 @@ class BaseTable extends EventTarget_1.EventTarget {
45
45
  }
46
46
  constructor(container, options = {}) {
47
47
  var _a, _b, _c, _d, _e, _f, _g;
48
- if (super(), this.showFrozenIcon = !0, this.showSort = !0, this.version = "0.18.3",
48
+ if (super(), this.showFrozenIcon = !0, this.showSort = !0, this.version = "0.18.4",
49
49
  this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {},
50
50
  this.throttleInvalidate = (0, util_1.throttle2)(this.render.bind(this), 200), !container && "node" !== options.mode) throw new Error("vtable's container is undefined");
51
51
  const {frozenColCount: frozenColCount = 0, defaultRowHeight: defaultRowHeight = 40, defaultHeaderRowHeight: defaultHeaderRowHeight, defaultColWidth: defaultColWidth = 80, defaultHeaderColWidth: defaultHeaderColWidth, widthMode: widthMode = "standard", heightMode: heightMode = "standard", autoFillWidth: autoFillWidth = !1, autoFillHeight: autoFillHeight = !1, keyboardOptions: keyboardOptions, eventOptions: eventOptions, columnResizeMode: columnResizeMode, dragHeaderMode: dragHeaderMode, showFrozenIcon: showFrozenIcon, allowFrozenColCount: allowFrozenColCount, padding: padding, hover: hover, menu: menu, select: click, customRender: customRender, pixelRatio: pixelRatio = pixel_ratio_1.defaultPixelRatio, renderChartAsync: renderChartAsync, renderChartAsyncBatchCount: renderChartAsyncBatchCount, mode: mode, modeParams: modeParams, canvasWidth: canvasWidth, canvasHeight: canvasHeight, overscrollBehavior: overscrollBehavior, limitMinWidth: limitMinWidth} = options;
@@ -456,7 +456,7 @@ class BaseTable extends EventTarget_1.EventTarget {
456
456
  isFrozenCell && isFrozenCell.col ? this.isRightFrozenColumn(col, row) ? absoluteLeft = this.tableNoFrameWidth - (null !== (_a = this.getColsWidth(col, this.colCount - 1)) && void 0 !== _a ? _a : 0) : (absoluteLeft = this.getColsWidth(0, col - 1) || 0,
457
457
  absoluteLeft += this.scrollLeft) : absoluteLeft = this.getColsWidth(0, col - 1) || 0;
458
458
  const height = this.getRowHeight(row);
459
- return isFrozenCell && isFrozenCell.row ? this.isBottomFrozenRow(col, row) ? absoluteLeft = this.tableNoFrameHeight - (null !== (_b = this.getRowsHeight(row, this.rowCount - 1)) && void 0 !== _b ? _b : 0) : (absoluteTop = this.getRowsHeight(0, row - 1),
459
+ return isFrozenCell && isFrozenCell.row ? this.isBottomFrozenRow(col, row) ? absoluteTop = this.tableNoFrameHeight - (null !== (_b = this.getRowsHeight(row, this.rowCount - 1)) && void 0 !== _b ? _b : 0) : (absoluteTop = this.getRowsHeight(0, row - 1),
460
460
  absoluteTop += this.scrollTop) : absoluteTop = this.getRowsHeight(0, row - 1), new Rect_1.Rect(Math.round(absoluteLeft), Math.round(absoluteTop), Math.round(width), Math.round(height));
461
461
  }
462
462
  getMergeCellRect(col, row) {
@@ -464,12 +464,26 @@ class BaseTable extends EventTarget_1.EventTarget {
464
464
  return new Rect_1.Rect(Math.round(absoluteLeft), Math.round(absoluteTop), Math.round(width), Math.round(height));
465
465
  }
466
466
  getCellRelativeRect(col, row) {
467
- return this._toRelativeRect(this.getCellRect(col, row));
467
+ const isFrozenCell = this.isFrozenCell(col, row);
468
+ let relativeX = !0, relativeY = !0;
469
+ (null == isFrozenCell ? void 0 : isFrozenCell.col) && (null == isFrozenCell ? void 0 : isFrozenCell.row) ? (relativeX = !1,
470
+ relativeY = !1) : (null == isFrozenCell ? void 0 : isFrozenCell.col) ? relativeX = !1 : (null == isFrozenCell ? void 0 : isFrozenCell.row) && (relativeY = !1);
471
+ const cellRect = this.getCellRect(col, row);
472
+ return this._toRelativeRect(cellRect, relativeX, relativeY);
468
473
  }
469
474
  getCellRangeRelativeRect(range) {
470
- if (range.start) return this._toRelativeRect(this.getCellsRect(range.start.col, range.start.row, range.end.col, range.end.row));
471
- const cellRange = this.getCellRange(range.col, range.row);
472
- return this._toRelativeRect(this.getCellsRect(cellRange.start.col, cellRange.start.row, cellRange.end.col, cellRange.end.row));
475
+ if (range.start) {
476
+ const isFrozenCell = this.isFrozenCell(range.start.col, range.start.row);
477
+ let relativeX = !0, relativeY = !0;
478
+ return (null == isFrozenCell ? void 0 : isFrozenCell.col) && (null == isFrozenCell ? void 0 : isFrozenCell.row) ? (relativeX = !1,
479
+ relativeY = !1) : (null == isFrozenCell ? void 0 : isFrozenCell.col) ? relativeX = !1 : (null == isFrozenCell ? void 0 : isFrozenCell.row) && (relativeY = !1),
480
+ this._toRelativeRect(this.getCellsRect(range.start.col, range.start.row, range.end.col, range.end.row), relativeX, relativeY);
481
+ }
482
+ const cellRange = this.getCellRange(range.col, range.row), isFrozenCell = this.isFrozenCell(range.col, range.row);
483
+ let relativeX = !0, relativeY = !0;
484
+ return (null == isFrozenCell ? void 0 : isFrozenCell.col) && (null == isFrozenCell ? void 0 : isFrozenCell.row) ? (relativeX = !1,
485
+ relativeY = !1) : (null == isFrozenCell ? void 0 : isFrozenCell.col) ? relativeX = !1 : (null == isFrozenCell ? void 0 : isFrozenCell.row) && (relativeY = !1),
486
+ this._toRelativeRect(this.getCellsRect(cellRange.start.col, cellRange.start.row, cellRange.end.col, cellRange.end.row), relativeX, relativeY);
473
487
  }
474
488
  getVisibleCellRangeRelativeRect(range) {
475
489
  let cellRange;
@@ -584,9 +598,9 @@ class BaseTable extends EventTarget_1.EventTarget {
584
598
  }), 0);
585
599
  }));
586
600
  }
587
- _toRelativeRect(absoluteRect) {
601
+ _toRelativeRect(absoluteRect, relativeX = !0, relativeY = !0) {
588
602
  const rect = absoluteRect.copy(), visibleRect = this.getVisibleRect();
589
- return rect.offsetLeft(this.tableX - visibleRect.left), rect.offsetTop(this.tableY - visibleRect.top),
603
+ return rect.offsetLeft(this.tableX - (relativeX ? visibleRect.left : 0)), rect.offsetTop(this.tableY - (relativeY ? visibleRect.top : 0)),
590
604
  rect;
591
605
  }
592
606
  getVisibleRect() {