@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(): {
@@ -74,7 +74,7 @@ export class BaseTable extends EventTarget {
74
74
  }
75
75
  constructor(container, options = {}) {
76
76
  var _a, _b, _c, _d, _e, _f, _g;
77
- if (super(), this.showFrozenIcon = !0, this.showSort = !0, this.version = "0.18.3",
77
+ if (super(), this.showFrozenIcon = !0, this.showSort = !0, this.version = "0.18.4",
78
78
  this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {},
79
79
  this.throttleInvalidate = throttle2(this.render.bind(this), 200), !container && "node" !== options.mode) throw new Error("vtable's container is undefined");
80
80
  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 = defaultPixelRatio, renderChartAsync: renderChartAsync, renderChartAsyncBatchCount: renderChartAsyncBatchCount, mode: mode, modeParams: modeParams, canvasWidth: canvasWidth, canvasHeight: canvasHeight, overscrollBehavior: overscrollBehavior, limitMinWidth: limitMinWidth} = options;
@@ -479,7 +479,7 @@ export class BaseTable extends EventTarget {
479
479
  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,
480
480
  absoluteLeft += this.scrollLeft) : absoluteLeft = this.getColsWidth(0, col - 1) || 0;
481
481
  const height = this.getRowHeight(row);
482
- 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),
482
+ 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),
483
483
  absoluteTop += this.scrollTop) : absoluteTop = this.getRowsHeight(0, row - 1), new Rect(Math.round(absoluteLeft), Math.round(absoluteTop), Math.round(width), Math.round(height));
484
484
  }
485
485
  getMergeCellRect(col, row) {
@@ -487,12 +487,26 @@ export class BaseTable extends EventTarget {
487
487
  return new Rect(Math.round(absoluteLeft), Math.round(absoluteTop), Math.round(width), Math.round(height));
488
488
  }
489
489
  getCellRelativeRect(col, row) {
490
- return this._toRelativeRect(this.getCellRect(col, row));
490
+ const isFrozenCell = this.isFrozenCell(col, row);
491
+ let relativeX = !0, relativeY = !0;
492
+ (null == isFrozenCell ? void 0 : isFrozenCell.col) && (null == isFrozenCell ? void 0 : isFrozenCell.row) ? (relativeX = !1,
493
+ relativeY = !1) : (null == isFrozenCell ? void 0 : isFrozenCell.col) ? relativeX = !1 : (null == isFrozenCell ? void 0 : isFrozenCell.row) && (relativeY = !1);
494
+ const cellRect = this.getCellRect(col, row);
495
+ return this._toRelativeRect(cellRect, relativeX, relativeY);
491
496
  }
492
497
  getCellRangeRelativeRect(range) {
493
- if (range.start) return this._toRelativeRect(this.getCellsRect(range.start.col, range.start.row, range.end.col, range.end.row));
494
- const cellRange = this.getCellRange(range.col, range.row);
495
- return this._toRelativeRect(this.getCellsRect(cellRange.start.col, cellRange.start.row, cellRange.end.col, cellRange.end.row));
498
+ if (range.start) {
499
+ const isFrozenCell = this.isFrozenCell(range.start.col, range.start.row);
500
+ let relativeX = !0, relativeY = !0;
501
+ return (null == isFrozenCell ? void 0 : isFrozenCell.col) && (null == isFrozenCell ? void 0 : isFrozenCell.row) ? (relativeX = !1,
502
+ relativeY = !1) : (null == isFrozenCell ? void 0 : isFrozenCell.col) ? relativeX = !1 : (null == isFrozenCell ? void 0 : isFrozenCell.row) && (relativeY = !1),
503
+ this._toRelativeRect(this.getCellsRect(range.start.col, range.start.row, range.end.col, range.end.row), relativeX, relativeY);
504
+ }
505
+ const cellRange = this.getCellRange(range.col, range.row), isFrozenCell = this.isFrozenCell(range.col, range.row);
506
+ let relativeX = !0, relativeY = !0;
507
+ return (null == isFrozenCell ? void 0 : isFrozenCell.col) && (null == isFrozenCell ? void 0 : isFrozenCell.row) ? (relativeX = !1,
508
+ relativeY = !1) : (null == isFrozenCell ? void 0 : isFrozenCell.col) ? relativeX = !1 : (null == isFrozenCell ? void 0 : isFrozenCell.row) && (relativeY = !1),
509
+ this._toRelativeRect(this.getCellsRect(cellRange.start.col, cellRange.start.row, cellRange.end.col, cellRange.end.row), relativeX, relativeY);
496
510
  }
497
511
  getVisibleCellRangeRelativeRect(range) {
498
512
  let cellRange;
@@ -607,9 +621,9 @@ export class BaseTable extends EventTarget {
607
621
  }), 0);
608
622
  }));
609
623
  }
610
- _toRelativeRect(absoluteRect) {
624
+ _toRelativeRect(absoluteRect, relativeX = !0, relativeY = !0) {
611
625
  const rect = absoluteRect.copy(), visibleRect = this.getVisibleRect();
612
- return rect.offsetLeft(this.tableX - visibleRect.left), rect.offsetTop(this.tableY - visibleRect.top),
626
+ return rect.offsetLeft(this.tableX - (relativeX ? visibleRect.left : 0)), rect.offsetTop(this.tableY - (relativeY ? visibleRect.top : 0)),
613
627
  rect;
614
628
  }
615
629
  getVisibleRect() {