@visactor/vtable
Version:
canvas table width high performance
708 lines (665 loc) • 120 kB
JavaScript
import * as columnStyleContents from "../body-helper/style";
import { importStyle } from "./style";
import * as style from "../tools/style";
import { InteractionState, Placement } from "../ts-types";
import { event, style as utilStyle } from "../tools/helper";
import { TABLE_EVENT_TYPE } from "./TABLE_EVENT_TYPE";
import { EventHandler } from "../event/EventHandler";
import { EventTarget } from "../event/EventTarget";
import { NumberMap } from "../tools/NumberMap";
import { Rect } from "../tools/Rect";
import { throttle2 } from "../tools/util";
import themes from "../themes";
import { Env } from "../tools/env";
import { Scenegraph } from "../scenegraph/scenegraph";
import { StateManager } from "../state/state";
import { EventManager } from "../event/event";
import { BodyHelper } from "../body-helper/body-helper";
import { HeaderHelper } from "../header-helper/header-helper";
import { AABBBounds, isNumber, isBoolean, isValid, cloneDeep } from "@visactor/vutils";
import { measureTextBounds, textMeasure } from "../scenegraph/utils/text-measure";
import { getProp } from "../scenegraph/utils/get-prop";
import { IconCache } from "../plugins/icons";
import { _applyColWidthLimits, _getScrollableVisibleRect, _setDataSource, _toPxWidth, checkHasColumnAutoWidth, createRootElement, getStyleTheme, updateRootElementPadding } from "./tableHelper";
import { FocusInput } from "./FouseInput";
import { defaultPixelRatio } from "../tools/pixel-ratio";
import { clearChartRenderQueue, setBatchRenderChartCount } from "../scenegraph/graphic/contributions/chart-render-helper";
import { NumberRangeMap } from "../layout/row-height-map";
import { RowSeriesNumberHelper } from "./row-series-number-helper";
import { hideCellSelectBorder, restoreCellSelectBorder } from "../scenegraph/select/update-select-border";
import { ReactCustomLayout } from "../components/react/react-custom-layout";
import { hasAutoImageColumn } from "../layout/layout-helper";
import { Factory } from "./factory";
import { getCellAt, getCellAtRelativePosition, getColAt, getRowAt, getTargetColAt, getTargetColAtConsiderRightFrozen, getTargetRowAt, getTargetRowAtConsiderBottomFrozen } from "./utils/get-cell-position";
import { getCellStyle } from "./style-helper";
import { createReactContainer } from "../scenegraph/layout/frozen-react";
import { setIconColor } from "../icons";
import { TableAnimationManager } from "./animation";
import { checkCellInSelect } from "../state/common/check-in-select";
import { isCellDisableSelect } from "../state/select/is-cell-select-highlight";
import { getCustomMergeCellFunc } from "./utils/get-custom-merge-cell-func";
import { vglobal } from "./../vrender";
const {toBoxArray: toBoxArray} = utilStyle, {isTouchEvent: isTouchEvent} = event, rangeReg = /^\$(\d+)\$(\d+)$/;
importStyle();
export class BaseTable extends EventTarget {
static get EVENT_TYPE() {
return TABLE_EVENT_TYPE;
}
constructor(container, options = {}) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
if (super(), this.showFrozenIcon = !0, this.version = "1.17.5", this.id = `VTable${Date.now()}`,
this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200),
!container && "node" !== options.mode && !options.canvas) throw new Error("vtable's container is undefined");
!1 === (null === (_a = options.customConfig) || void 0 === _a ? void 0 : _a.imageAnonymous) && (vglobal.isImageAnonymous = !1);
const {frozenColCount: frozenColCount = 0, unfreezeAllOnExceedsMaxWidth: unfreezeAllOnExceedsMaxWidth, frozenRowCount: frozenRowCount, defaultRowHeight: defaultRowHeight = 40, defaultHeaderRowHeight: defaultHeaderRowHeight, defaultColWidth: defaultColWidth = 80, defaultHeaderColWidth: defaultHeaderColWidth, widthMode: widthMode = "standard", heightMode: heightMode = "standard", autoFillWidth: autoFillWidth = !1, autoFillHeight: autoFillHeight = !1, widthAdaptiveMode: widthAdaptiveMode = "only-body", heightAdaptiveMode: heightAdaptiveMode = "only-body", keyboardOptions: keyboardOptions, eventOptions: eventOptions, rowSeriesNumber: rowSeriesNumber, columnResizeMode: columnResizeMode, rowResizeMode: rowResizeMode = "none", resize: resize, dragHeaderMode: dragHeaderMode, dragOrder: dragOrder, 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, limitMinHeight: limitMinHeight, clearDOM: clearDOM = !0} = options;
this.container = container, this.options = options, this._widthMode = widthMode,
this._heightMode = heightMode, this._widthAdaptiveMode = widthAdaptiveMode, this._heightAdaptiveMode = heightAdaptiveMode,
this._autoFillWidth = autoFillWidth, this._autoFillHeight = autoFillHeight, this.customRender = customRender,
this.padding = {
top: 0,
right: 0,
left: 0,
bottom: 0
}, padding && ("number" == typeof padding ? (this.padding.top = padding, this.padding.left = padding,
this.padding.bottom = padding, this.padding.right = padding) : (padding.top && (this.padding.top = padding.top),
padding.bottom && (this.padding.bottom = padding.bottom), padding.left && (this.padding.left = padding.left),
padding.right && (this.padding.right = padding.right))), (isValid(canvasHeight) || isValid(canvasWidth)) && (this.canvasSizeSeted = !0),
this.tableNoFrameWidth = 0, this.tableNoFrameHeight = 0, this.canvasWidth = isNumber(canvasWidth) ? canvasWidth : void 0,
this.canvasHeight = isNumber(canvasHeight) ? canvasHeight : void 0, this.columnWidthComputeMode = null !== (_b = options.columnWidthComputeMode) && void 0 !== _b ? _b : "normal";
const internalProps = this.internalProps = {};
void 0 !== showFrozenIcon && (this.showFrozenIcon = showFrozenIcon), "number" == typeof allowFrozenColCount && allowFrozenColCount <= 0 && (this.showFrozenIcon = !1),
this.options.canvas ? ("node" !== Env.mode && (internalProps.element = this.options.canvas.parentElement,
internalProps.element.style.position = "relative"), internalProps.focusControl = new FocusInput(this, internalProps.element),
internalProps.canvas = this.options.canvas, internalProps.context = internalProps.canvas.getContext("2d")) : "node" !== Env.mode && (internalProps.element = createRootElement(this.padding),
internalProps.focusControl = new FocusInput(this, internalProps.element), internalProps.canvas = document.createElement("canvas"),
internalProps.element.appendChild(internalProps.canvas), internalProps.context = internalProps.canvas.getContext("2d"),
(null === (_c = options.customConfig) || void 0 === _c ? void 0 : _c.createReactContainer) && createReactContainer(this)),
internalProps.handler = new EventHandler, isNumber(this.options.resizeTime) && (internalProps.handler.resizeTime = this.options.resizeTime),
internalProps.pixelRatio = pixelRatio, internalProps.frozenColCount = frozenColCount,
internalProps.frozenRowCount = frozenRowCount, internalProps.unfreezeAllOnExceedsMaxWidth = null == unfreezeAllOnExceedsMaxWidth || unfreezeAllOnExceedsMaxWidth,
internalProps.defaultRowHeight = defaultRowHeight, internalProps.defaultHeaderRowHeight = null != defaultHeaderRowHeight ? defaultHeaderRowHeight : defaultRowHeight,
internalProps.defaultColWidth = defaultColWidth, internalProps.defaultHeaderColWidth = null != defaultHeaderColWidth ? defaultHeaderColWidth : defaultColWidth,
internalProps.keyboardOptions = keyboardOptions, internalProps.eventOptions = eventOptions,
internalProps.rowSeriesNumber = rowSeriesNumber, internalProps.columnResizeMode = null !== (_d = null == resize ? void 0 : resize.columnResizeMode) && void 0 !== _d ? _d : columnResizeMode,
internalProps.rowResizeMode = null !== (_e = null == resize ? void 0 : resize.rowResizeMode) && void 0 !== _e ? _e : rowResizeMode,
internalProps.dragHeaderMode = null !== (_g = null !== (_f = null == dragOrder ? void 0 : dragOrder.dragHeaderMode) && void 0 !== _f ? _f : dragHeaderMode) && void 0 !== _g ? _g : "none",
internalProps.renderChartAsync = renderChartAsync, setBatchRenderChartCount(renderChartAsyncBatchCount),
internalProps.overscrollBehavior = null != overscrollBehavior ? overscrollBehavior : "auto",
internalProps._rowHeightsMap = new NumberRangeMap(this), internalProps._rowRangeHeightsMap = new Map,
internalProps._colRangeWidthsMap = new Map, internalProps._widthResizedColMap = new Set,
internalProps._heightResizedRowMap = new Set, this.colWidthsMap = new NumberMap,
this.colContentWidthsMap = new NumberMap, this.colWidthsLimit = {};
const that = this;
if (internalProps.calcWidthContext = {
_: internalProps,
get full() {
var _a;
return "node" === Env.mode ? that.canvasWidth / (null != pixelRatio ? pixelRatio : 1) : this._.canvas.width / (null !== (_a = this._.context.pixelRatio) && void 0 !== _a ? _a : window.devicePixelRatio);
}
}, internalProps.cellTextOverflows = {}, internalProps.focusedTable = !1, internalProps.theme = themes.of(null !== (_h = options.theme) && void 0 !== _h ? _h : themes.DEFAULT),
internalProps.theme.isPivot = this.isPivotTable(), setIconColor(internalProps.theme.functionalIconsStyle),
container ? (clearDOM && (container.innerHTML = ""), container.appendChild(internalProps.element),
this._updateSize()) : this._updateSize(), internalProps.bodyHelper = new BodyHelper(this),
internalProps.headerHelper = new HeaderHelper(this), internalProps.rowSeriesNumberHelper = new RowSeriesNumberHelper(this),
internalProps.autoWrapText = options.autoWrapText, internalProps.enableLineBreak = options.enableLineBreak,
internalProps.allowFrozenColCount = null !== (_j = options.allowFrozenColCount) && void 0 !== _j ? _j : 0,
internalProps.limitMaxAutoWidth = null !== (_k = options.limitMaxAutoWidth) && void 0 !== _k ? _k : 450,
internalProps.limitMinWidth = null != limitMinWidth ? "number" == typeof limitMinWidth ? limitMinWidth : limitMinWidth ? 10 : 0 : 10,
internalProps.limitMinHeight = null != limitMinHeight ? "number" == typeof limitMinHeight ? limitMinHeight : limitMinHeight ? 10 : 0 : 10,
this.scenegraph = new Scenegraph(this), this.stateManager = new StateManager(this),
this.eventManager = new EventManager(this), this.animationManager = new TableAnimationManager(this),
options.legends) {
internalProps.legends = [];
const createLegend = Factory.getFunction("createLegend");
if (Array.isArray(options.legends)) {
for (let i = 0; i < options.legends.length; i++) internalProps.legends.push(createLegend(options.legends[i], this));
this.scenegraph.tableGroup.setAttributes({
x: this.tableX,
y: this.tableY
});
} else internalProps.legends.push(createLegend(options.legends, this)), this.scenegraph.tableGroup.setAttributes({
x: this.tableX,
y: this.tableY
});
}
if (internalProps.tooltip = Object.assign({
parentElement: this.getElement(),
renderMode: "html",
isShowOverflowTextTooltip: !1,
confine: !0,
position: Placement.bottom
}, options.tooltip), "html" === internalProps.tooltip.renderMode) {
const TooltipHandler = Factory.getComponent("tooltipHandler");
TooltipHandler && (internalProps.tooltipHandler = new TooltipHandler(this, internalProps.tooltip.confine));
}
if (internalProps.menu = Object.assign({
renderMode: "html"
}, options.menu), Array.isArray(null === (_l = options.menu) || void 0 === _l ? void 0 : _l.dropDownMenuHighlight) && this.setDropDownMenuHighlight(null === (_m = options.menu) || void 0 === _m ? void 0 : _m.dropDownMenuHighlight),
(Array.isArray(null === (_o = options.menu) || void 0 === _o ? void 0 : _o.defaultHeaderMenuItems) || "function" == typeof (null === (_p = options.menu) || void 0 === _p ? void 0 : _p.defaultHeaderMenuItems)) && (this.globalDropDownMenu = options.menu.defaultHeaderMenuItems),
"html" === internalProps.menu.renderMode) {
const MenuHandler = Factory.getComponent("menuHandler");
internalProps.menuHandler = new MenuHandler(this);
}
this.headerStyleCache = new Map, this.bodyStyleCache = new Map, this.bodyMergeTitleCache = new Map,
this.bodyBottomStyleCache = new Map, internalProps.stick = {
changedCells: new Map
}, internalProps.customMergeCell = getCustomMergeCellFunc(options.customMergeCell);
const CustomCellStylePlugin = Factory.getComponent("customCellStylePlugin");
CustomCellStylePlugin && (this.customCellStylePlugin = new CustomCellStylePlugin(this, null !== (_q = options.customCellStyle) && void 0 !== _q ? _q : [], null !== (_r = options.customCellStyleArrangement) && void 0 !== _r ? _r : [])),
this._adjustCanvasSizeByOption();
}
_adjustCanvasSizeByOption() {
"auto" !== this.options.canvasHeight && "auto" !== this.options.canvasWidth || setTimeout((() => {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
let canvasWidth, canvasHeight;
if ("auto" === this.options.canvasHeight) {
let borderWidth = 0;
if (null === (_a = this.theme.frameStyle) || void 0 === _a ? void 0 : _a.innerBorder) {
borderWidth += null !== (_d = toBoxArray(null !== (_c = null === (_b = this.internalProps.theme.frameStyle) || void 0 === _b ? void 0 : _b.shadowBlur) && void 0 !== _c ? _c : [ 0 ])[1]) && void 0 !== _d ? _d : 0;
} else if (this.theme.frameStyle) {
const lineWidths = toBoxArray(null !== (_f = null === (_e = this.internalProps.theme.frameStyle) || void 0 === _e ? void 0 : _e.borderLineWidth) && void 0 !== _f ? _f : [ null ]), shadowWidths = toBoxArray(null !== (_h = null === (_g = this.internalProps.theme.frameStyle) || void 0 === _g ? void 0 : _g.shadowBlur) && void 0 !== _h ? _h : [ 0 ]);
borderWidth += (null !== (_j = lineWidths[0]) && void 0 !== _j ? _j : 0) + (null !== (_k = shadowWidths[0]) && void 0 !== _k ? _k : 0) + ((null !== (_l = lineWidths[2]) && void 0 !== _l ? _l : 0) + (null !== (_m = shadowWidths[2]) && void 0 !== _m ? _m : 0));
}
canvasHeight = Math.min(this.options.maxCanvasHeight ? this.options.maxCanvasHeight - borderWidth : 2e4, this.getAllRowsHeight()) + borderWidth;
} else canvasHeight = this.canvasHeight;
if ("auto" === this.options.canvasWidth) {
let borderWidth = 0;
if (null === (_o = this.theme.frameStyle) || void 0 === _o ? void 0 : _o.innerBorder) {
borderWidth += null !== (_r = toBoxArray(null !== (_q = null === (_p = this.internalProps.theme.frameStyle) || void 0 === _p ? void 0 : _p.shadowBlur) && void 0 !== _q ? _q : [ 0 ])[2]) && void 0 !== _r ? _r : 0;
} else if (this.theme.frameStyle) {
const lineWidths = toBoxArray(null !== (_t = null === (_s = this.internalProps.theme.frameStyle) || void 0 === _s ? void 0 : _s.borderLineWidth) && void 0 !== _t ? _t : [ null ]), shadowWidths = toBoxArray(null !== (_v = null === (_u = this.internalProps.theme.frameStyle) || void 0 === _u ? void 0 : _u.shadowBlur) && void 0 !== _v ? _v : [ 0 ]);
borderWidth += (null !== (_w = lineWidths[1]) && void 0 !== _w ? _w : 0) + (null !== (_x = shadowWidths[1]) && void 0 !== _x ? _x : 0) + ((null !== (_y = lineWidths[3]) && void 0 !== _y ? _y : 0) + (null !== (_z = shadowWidths[3]) && void 0 !== _z ? _z : 0));
}
canvasWidth = Math.min(this.options.maxCanvasWidth ? this.options.maxCanvasWidth - borderWidth : 2e4, this.getAllColsWidth()) + borderWidth;
} else canvasWidth = this.canvasWidth;
this.setCanvasSize(canvasWidth, canvasHeight);
}), 0);
}
getContainer() {
return this.container;
}
getElement() {
return this.internalProps.element;
}
get canvas() {
return this.internalProps.canvas;
}
setCanvasSize(canvasWidth, canvasHeight) {
this.canvasWidth = canvasWidth, this.canvasHeight = canvasHeight, this.options.canvasHeight = canvasHeight,
this.options.canvasWidth = canvasWidth, this.resize();
}
resize() {
var _a;
this._updateSize(), null === (_a = this.internalProps.legends) || void 0 === _a || _a.forEach((legend => {
null == legend || legend.resize();
})), this.internalProps.title && this.internalProps.title.resize(), this.internalProps.emptyTip && this.internalProps.emptyTip.resize(),
this.scenegraph.resize();
}
get rowCount() {
return this.internalProps.rowCount;
}
set rowCount(rowCount) {
this.internalProps.rowCount = rowCount;
}
get colCount() {
var _a;
return null !== (_a = this.internalProps.colCount) && void 0 !== _a ? _a : 0;
}
set colCount(colCount) {
this.internalProps.colCount = colCount;
}
get frozenColCount() {
var _a, _b, _c, _d, _e;
return null !== (_e = null !== (_c = null === (_b = null === (_a = this.internalProps) || void 0 === _a ? void 0 : _a.layoutMap) || void 0 === _b ? void 0 : _b.frozenColCount) && void 0 !== _c ? _c : null === (_d = this.internalProps) || void 0 === _d ? void 0 : _d.frozenColCount) && void 0 !== _e ? _e : 0;
}
set frozenColCount(frozenColCount) {
frozenColCount >= this.colCount && (frozenColCount = 0), this.internalProps.frozenColCount = frozenColCount,
this.options.frozenColCount = frozenColCount;
const maxFrozenWidth = this._getMaxFrozenWidth();
if (this.getColsWidth(0, frozenColCount - 1) > maxFrozenWidth) if (this.internalProps.unfreezeAllOnExceedsMaxWidth) this.internalProps.frozenColCount = 0; else {
const computedFrozenColCount = this._getComputedFrozenColCount(frozenColCount);
this.internalProps.frozenColCount = computedFrozenColCount;
}
this.stateManager.setFrozenCol(this.internalProps.frozenColCount);
}
setFrozenColCount(frozenColCount) {
frozenColCount >= this.colCount && (frozenColCount = 0), this.internalProps.frozenColCount = frozenColCount,
this.options.frozenColCount = frozenColCount;
const maxFrozenWidth = this._getMaxFrozenWidth();
if (this.getColsWidth(0, frozenColCount - 1) > maxFrozenWidth) if (this.internalProps.unfreezeAllOnExceedsMaxWidth) this.internalProps.frozenColCount = 0; else {
const computedFrozenColCount = this._getComputedFrozenColCount(frozenColCount);
this.internalProps.frozenColCount = computedFrozenColCount;
}
this.stateManager.setFrozenCol(this.internalProps.frozenColCount);
}
_setFrozenColCount(frozenColCount) {
frozenColCount >= this.colCount && (frozenColCount = 0), this.internalProps.frozenColCount = frozenColCount;
}
_resetFrozenColCount() {
this.options.frozenColCount && (this.tableNoFrameWidth - this.getColsWidth(0, this.options.frozenColCount - 1) <= 120 ? this._setFrozenColCount(0) : this.frozenColCount !== this.options.frozenColCount && this._setFrozenColCount(this.options.frozenColCount));
}
get frozenRowCount() {
var _a, _b, _c, _d, _e;
return null !== (_e = null !== (_c = null === (_b = null === (_a = this.internalProps) || void 0 === _a ? void 0 : _a.layoutMap) || void 0 === _b ? void 0 : _b.frozenRowCount) && void 0 !== _c ? _c : null === (_d = this.internalProps) || void 0 === _d ? void 0 : _d.frozenRowCount) && void 0 !== _e ? _e : 0;
}
set frozenRowCount(frozenRowCount) {
this.internalProps.frozenRowCount = frozenRowCount, this.stateManager.setFrozenRow(this.internalProps.frozenRowCount);
}
get rightFrozenColCount() {
var _a, _b, _c, _d, _e;
return null !== (_e = null !== (_c = null === (_b = null === (_a = this.internalProps) || void 0 === _a ? void 0 : _a.layoutMap) || void 0 === _b ? void 0 : _b.rightFrozenColCount) && void 0 !== _c ? _c : null === (_d = this.internalProps) || void 0 === _d ? void 0 : _d.rightFrozenColCount) && void 0 !== _e ? _e : 0;
}
set rightFrozenColCount(rightFrozenColCount) {
this.scenegraph.dealWidthRightFrozen(rightFrozenColCount);
}
get bottomFrozenRowCount() {
var _a, _b, _c, _d, _e;
return null !== (_e = null !== (_c = null === (_b = null === (_a = this.internalProps) || void 0 === _a ? void 0 : _a.layoutMap) || void 0 === _b ? void 0 : _b.bottomFrozenRowCount) && void 0 !== _c ? _c : null === (_d = this.internalProps) || void 0 === _d ? void 0 : _d.bottomFrozenRowCount) && void 0 !== _e ? _e : 0;
}
set bottomFrozenRowCount(bottomFrozenRowCount) {
this.scenegraph.dealWidthBottomFrozen(bottomFrozenRowCount);
}
get defaultRowHeight() {
return isNumber(this.internalProps.defaultRowHeight) ? this.internalProps.defaultRowHeight : 40;
}
set defaultRowHeight(defaultRowHeight) {
this.internalProps.defaultRowHeight = defaultRowHeight, this.options.defaultRowHeight = defaultRowHeight;
}
get defaultHeaderRowHeight() {
return this.internalProps.defaultHeaderRowHeight;
}
set defaultHeaderRowHeight(defaultHeaderRowHeight) {
this.internalProps.defaultHeaderRowHeight = defaultHeaderRowHeight, this.options.defaultHeaderRowHeight = defaultHeaderRowHeight;
}
get defaultColWidth() {
return this.internalProps.defaultColWidth;
}
set defaultColWidth(defaultColWidth) {
this.internalProps.defaultColWidth = defaultColWidth, this.options.defaultColWidth = defaultColWidth;
}
get defaultHeaderColWidth() {
return this.internalProps.defaultHeaderColWidth;
}
set defaultHeaderColWidth(defaultHeaderColWidth) {
this.internalProps.defaultHeaderColWidth = defaultHeaderColWidth, this.options.defaultHeaderColWidth = defaultHeaderColWidth;
}
get colWidthsMap() {
return this.internalProps._colWidthsMap;
}
set colWidthsMap(colWidthsMap) {
this.internalProps._colWidthsMap = colWidthsMap;
}
get colContentWidthsMap() {
return this.internalProps._colContentWidthsMap;
}
set colContentWidthsMap(colContentWidthsMap) {
this.internalProps._colContentWidthsMap = colContentWidthsMap;
}
get _colRangeWidthsMap() {
return this.internalProps._colRangeWidthsMap;
}
set _colRangeWidthsMap(_colRangeWidthsMap) {
this.internalProps._colRangeWidthsMap = _colRangeWidthsMap;
}
get _rowRangeHeightsMap() {
return this.internalProps._rowRangeHeightsMap;
}
set _rowRangeHeightsMap(_rowRangeHeightsMap) {
this.internalProps._rowRangeHeightsMap = _rowRangeHeightsMap;
}
get rowHeightsMap() {
return this.internalProps._rowHeightsMap;
}
set rowHeightsMap(rowHeightsMap) {
this.internalProps._rowHeightsMap = rowHeightsMap;
}
get colWidthsLimit() {
return this.internalProps._colWidthsLimit;
}
set colWidthsLimit(colWidthsLimit) {
this.internalProps._colWidthsLimit = colWidthsLimit;
}
get keyboardOptions() {
var _a;
return null !== (_a = this.internalProps.keyboardOptions) && void 0 !== _a ? _a : null;
}
set keyboardOptions(keyboardOptions) {
this.internalProps.keyboardOptions = null != keyboardOptions ? keyboardOptions : void 0;
}
get eventOptions() {
var _a;
return null !== (_a = this.internalProps.eventOptions) && void 0 !== _a ? _a : null;
}
set eventOptions(eventOptions) {
this.internalProps.eventOptions = null != eventOptions ? eventOptions : void 0;
}
get widthMode() {
return this._widthMode;
}
set widthMode(widthMode) {
widthMode !== this._widthMode && (this._widthMode = widthMode, this.options.widthMode = widthMode);
}
get heightMode() {
return this._heightMode;
}
set heightMode(heightMode) {
heightMode !== this._heightMode && (this._heightMode = heightMode, this.options.heightMode = heightMode);
}
get autoFillWidth() {
return this._autoFillWidth;
}
set autoFillWidth(autoFillWidth) {
autoFillWidth !== this._autoFillWidth && (this._autoFillWidth = autoFillWidth);
}
get autoFillHeight() {
return this._autoFillHeight;
}
set autoFillHeight(autoFillHeight) {
autoFillHeight !== this._autoFillHeight && (this._autoFillHeight = autoFillHeight);
}
get widthAdaptiveMode() {
return this._widthAdaptiveMode;
}
set widthAdaptiveMode(widthAdaptiveMode) {
widthAdaptiveMode !== this._widthAdaptiveMode && (this._widthAdaptiveMode = widthAdaptiveMode);
}
get heightAdaptiveMode() {
return this._heightAdaptiveMode;
}
set heightAdaptiveMode(heightAdaptiveMode) {
heightAdaptiveMode !== this._heightAdaptiveMode && (this._heightAdaptiveMode = heightAdaptiveMode);
}
_colWidthDefineToPxWidth(width) {
return "auto" === width ? 0 : _toPxWidth(this, width);
}
_getMaxFrozenWidth() {
var _a;
const maxFrozenWidth = null !== (_a = this.options.maxFrozenWidth) && void 0 !== _a ? _a : "80%";
return _toPxWidth(this, maxFrozenWidth);
}
_getComputedFrozenColCount(frozenColCount) {
const maxFrozenWidth = this._getMaxFrozenWidth();
let computedfrozenColCount = frozenColCount;
for (;this.getColsWidth(0, computedfrozenColCount - 1) > maxFrozenWidth && (computedfrozenColCount--,
!(computedfrozenColCount <= 0)); ) ;
return computedfrozenColCount;
}
_getColWidthLimits(col) {
const limit = this.colWidthsLimit[col];
if (!limit) return null;
const result = {};
return limit.min && (result.min = _toPxWidth(this, limit.min), result.minDef = limit.min),
limit.max && (result.max = _toPxWidth(this, limit.max), result.maxDef = limit.max),
result;
}
_adjustColWidth(col, orgWidth) {
const limits = this._getColWidthLimits(col);
return Math.max(_applyColWidthLimits(limits, orgWidth), 0);
}
get pixelRatio() {
return this.internalProps.pixelRatio;
}
setPixelRatio(pixelRatio) {
var _a;
if (pixelRatio !== (null === (_a = this.internalProps) || void 0 === _a ? void 0 : _a.pixelRatio)) {
this.internalProps.pixelRatio = pixelRatio;
const canvasWidth = this.canvasWidth;
this.internalProps.calcWidthContext = {
_: this.internalProps,
get full() {
var _a;
return "node" === Env.mode ? canvasWidth / (null != pixelRatio ? pixelRatio : 1) : this._.canvas.width / (null !== (_a = this._.context.pixelRatio) && void 0 !== _a ? _a : window.devicePixelRatio);
}
}, this.scenegraph.setPixelRatio(pixelRatio);
}
}
_updateSize() {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5;
const {padding: padding} = this;
let widthP = 0, heightP = 0;
if (this.tableX = 0, this.tableY = 0, this.options.canvas && this.options.viewBox) widthP = this.options.viewBox.x2 - this.options.viewBox.x1,
heightP = this.options.viewBox.y2 - this.options.viewBox.y1, (null === (_a = null == this ? void 0 : this.scenegraph) || void 0 === _a ? void 0 : _a.stage) && (this.options.viewBox ? this.scenegraph.stage.setViewBox(this.options.viewBox, !1) : this.scenegraph.stage.resize(widthP, heightP)); else if ("browser" === Env.mode) {
const element = this.getElement();
let widthWithoutPadding = 0, heightWithoutPadding = 0;
const isDefWidth = isValid(this.canvasWidth), isDefHeight = isValid(this.canvasHeight);
this.canvasSizeSeted && (isDefWidth && (widthWithoutPadding = this.canvasWidth),
isDefHeight && (heightWithoutPadding = this.canvasHeight));
if ((!isDefWidth || !isDefHeight) && element.parentElement) {
const computedStyle = element.parentElement.style || window.getComputedStyle(element.parentElement);
isDefWidth || (widthWithoutPadding = element.parentElement.offsetWidth - (parseInt(computedStyle.paddingLeft, 10) || 0) - (parseInt(computedStyle.paddingRight, 10) || 0)),
isDefHeight || (heightWithoutPadding = element.parentElement.offsetHeight - parseInt(computedStyle.paddingTop || "0px", 10) - parseInt(computedStyle.paddingBottom || "0px", 20)),
widthWithoutPadding = (null != widthWithoutPadding ? widthWithoutPadding : 1) - (this.options.tableSizeAntiJitter ? 1 : 0),
heightWithoutPadding = (null != heightWithoutPadding ? heightWithoutPadding : 1) - (this.options.tableSizeAntiJitter ? 1 : 0);
}
element.style.width = widthWithoutPadding && widthWithoutPadding - padding.left - padding.right + "px" || "0px",
element.style.height = heightWithoutPadding && heightWithoutPadding - padding.top - padding.bottom + "px" || "0px";
const {canvas: canvas} = this.internalProps;
widthP = (null !== (_c = null === (_b = canvas.parentElement) || void 0 === _b ? void 0 : _b.offsetWidth) && void 0 !== _c ? _c : 1) - (this.options.tableSizeAntiJitter ? 1 : 0),
heightP = (null !== (_e = null === (_d = canvas.parentElement) || void 0 === _d ? void 0 : _d.offsetHeight) && void 0 !== _e ? _e : 1) - (this.options.tableSizeAntiJitter ? 1 : 0),
(null === (_f = null == this ? void 0 : this.scenegraph) || void 0 === _f ? void 0 : _f.stage) ? (null === (_g = this.options) || void 0 === _g ? void 0 : _g.viewBox) && !(null === (_h = this.options) || void 0 === _h ? void 0 : _h.canvas) && this.scenegraph.stage.resize(widthP, heightP) : (canvas.style.width = "",
canvas.style.height = "", canvas.width = widthP, canvas.height = heightP, canvas.style.width = `${widthP}px`,
canvas.style.height = `${heightP}px`), (null === (_j = this.options) || void 0 === _j ? void 0 : _j.viewBox) && (widthP = this.options.viewBox.x2 - this.options.viewBox.x1,
heightP = this.options.viewBox.y2 - this.options.viewBox.y1), (null === (_k = null == this ? void 0 : this.scenegraph) || void 0 === _k ? void 0 : _k.stage) && (this.options.viewBox ? this.scenegraph.stage.setViewBox(this.options.viewBox, !1) : this.scenegraph.stage.resize(widthP, heightP));
} else "node" === Env.mode && (widthP = this.canvasWidth - 1, heightP = this.canvasHeight - 1);
const width = Math.floor(widthP - style.getVerticalScrollBarSize(this.getTheme().scrollStyle)), height = Math.floor(heightP - style.getHorizontalScrollBarSize(this.getTheme().scrollStyle));
if (null === (_l = this.internalProps.theme) || void 0 === _l ? void 0 : _l.frameStyle) {
const lineWidths = toBoxArray(null !== (_o = null === (_m = this.internalProps.theme.frameStyle) || void 0 === _m ? void 0 : _m.borderLineWidth) && void 0 !== _o ? _o : [ null ]), shadowWidths = toBoxArray(null !== (_q = null === (_p = this.internalProps.theme.frameStyle) || void 0 === _p ? void 0 : _p.shadowBlur) && void 0 !== _q ? _q : [ 0 ]);
(null === (_r = this.theme.frameStyle) || void 0 === _r ? void 0 : _r.innerBorder) ? (this.tableX = 0,
this.tableY = 0, this.tableNoFrameWidth = width - (null !== (_s = shadowWidths[1]) && void 0 !== _s ? _s : 0),
this.tableNoFrameHeight = height - (null !== (_t = shadowWidths[2]) && void 0 !== _t ? _t : 0)) : (this.tableX = (null !== (_u = lineWidths[3]) && void 0 !== _u ? _u : 0) + (null !== (_v = shadowWidths[3]) && void 0 !== _v ? _v : 0),
this.tableY = (null !== (_w = lineWidths[0]) && void 0 !== _w ? _w : 0) + (null !== (_x = shadowWidths[0]) && void 0 !== _x ? _x : 0),
this.tableNoFrameWidth = width - ((null !== (_y = lineWidths[1]) && void 0 !== _y ? _y : 0) + (null !== (_z = shadowWidths[1]) && void 0 !== _z ? _z : 0)) - ((null !== (_0 = lineWidths[3]) && void 0 !== _0 ? _0 : 0) + (null !== (_1 = shadowWidths[3]) && void 0 !== _1 ? _1 : 0)),
this.tableNoFrameHeight = height - ((null !== (_2 = lineWidths[0]) && void 0 !== _2 ? _2 : 0) + (null !== (_3 = shadowWidths[0]) && void 0 !== _3 ? _3 : 0)) - ((null !== (_4 = lineWidths[2]) && void 0 !== _4 ? _4 : 0) + (null !== (_5 = shadowWidths[2]) && void 0 !== _5 ? _5 : 0)));
}
}
updateViewBox(newViewBox) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
const oldWidth = (null !== (_c = null === (_b = null === (_a = this.options) || void 0 === _a ? void 0 : _a.viewBox) || void 0 === _b ? void 0 : _b.x2) && void 0 !== _c ? _c : 0) - (null !== (_f = null === (_e = null === (_d = this.options) || void 0 === _d ? void 0 : _d.viewBox) || void 0 === _e ? void 0 : _e.x1) && void 0 !== _f ? _f : 0), oldHeight = (null !== (_j = null === (_h = null === (_g = this.options) || void 0 === _g ? void 0 : _g.viewBox) || void 0 === _h ? void 0 : _h.y2) && void 0 !== _j ? _j : 0) - (null !== (_m = null === (_l = null === (_k = this.options) || void 0 === _k ? void 0 : _k.viewBox) || void 0 === _l ? void 0 : _l.y1) && void 0 !== _m ? _m : 0), newWidth = newViewBox.x2 - newViewBox.x1, newHeight = newViewBox.y2 - newViewBox.y1;
this.options.viewBox = newViewBox, oldWidth !== newWidth || oldHeight !== newHeight ? this.resize() : this.scenegraph.stage.setViewBox(this.options.viewBox, !0);
}
setViewBoxTransform(a, b, c, d, e, f) {
this.internalProps.modifiedViewBoxTransform = !0, this.scenegraph.stage.window.setViewBoxTransform(a, b, c, d, e, f);
}
get rowHierarchyType() {
return this.dataSource.rowHierarchyType;
}
getColsWidth(startCol, endCol) {
var _a;
if (startCol > endCol) return 0;
startCol = Math.max(startCol, 0), endCol = Math.min(endCol, (null !== (_a = this.colCount) && void 0 !== _a ? _a : 1 / 0) - 1);
const cachedColWidth = this._colRangeWidthsMap.get(`$${startCol}$${endCol}`);
if (null != cachedColWidth) return cachedColWidth;
const cachedLowerColWidth = this._colRangeWidthsMap.get(`$${startCol}$${endCol - 1}`);
if (null != cachedLowerColWidth) {
const addWidth = cachedLowerColWidth + this.getColWidth(endCol);
return startCol >= 0 && endCol >= 0 && !Number.isNaN(addWidth) && this._colRangeWidthsMap.set(`$${startCol}$${endCol}`, Math.round(addWidth)),
Math.round(addWidth);
}
let w = 0;
for (let col = startCol; col <= endCol; col++) w += this.getColWidth(col);
return startCol >= 0 && endCol >= 0 && this._colRangeWidthsMap.set(`$${startCol}$${endCol}`, Math.round(w)),
Math.round(w);
}
getRowHeight(row) {
var _a;
if (isValid(this.rowHeightsMap.get(row))) {
if (null === (_a = this.options.customConfig) || void 0 === _a ? void 0 : _a._disableColumnAndRowSizeRound) {
const height = this.rowHeightsMap.get(row);
let heightRange;
return heightRange = row < this.frozenRowCount ? this.rowHeightsMap.getSumInRange(0, row) : row >= this.rowCount - this.bottomFrozenRowCount ? this.rowHeightsMap.getSumInRange(row, this.rowCount - 1) : this.rowHeightsMap.getSumInRange(this.frozenRowCount, row),
heightRange = Number(heightRange.toFixed(2)), Number.isInteger(heightRange) ? Math.ceil(height) : Math.floor(height);
}
return this.rowHeightsMap.get(row);
}
const defaultHeight = this.getDefaultRowHeight(row);
return isNumber(defaultHeight) ? defaultHeight : this.defaultRowHeight;
}
getDefaultColumnWidth(col) {
var _a, _b;
return this.isRowHeader(col, 0) || this.isCornerHeader(col, 0) ? Array.isArray(this.defaultHeaderColWidth) ? null !== (_a = this.defaultHeaderColWidth[col]) && void 0 !== _a ? _a : this.defaultColWidth : this.defaultHeaderColWidth : this.isRightFrozenColumn(col, this.columnHeaderLevelCount) && this.isPivotTable() ? Array.isArray(this.defaultHeaderColWidth) ? null !== (_b = this.defaultHeaderColWidth[this.rowHeaderLevelCount - this.rightFrozenColCount]) && void 0 !== _b ? _b : this.defaultColWidth : this.defaultHeaderColWidth : this.defaultColWidth;
}
getDefaultRowHeight(row) {
var _a, _b;
return this.isColumnHeader(0, row) || this.isCornerHeader(0, row) || this.isSeriesNumberInHeader(0, row) ? Array.isArray(this.defaultHeaderRowHeight) ? null !== (_a = this.defaultHeaderRowHeight[row]) && void 0 !== _a ? _a : this.internalProps.defaultRowHeight : this.defaultHeaderRowHeight : this.isBottomFrozenRow(row) ? Array.isArray(this.defaultHeaderRowHeight) ? null !== (_b = this.defaultHeaderRowHeight[this.columnHeaderLevelCount > 0 ? this.columnHeaderLevelCount - this.bottomFrozenRowCount : 0]) && void 0 !== _b ? _b : this.internalProps.defaultRowHeight : this.defaultHeaderRowHeight : this.internalProps.defaultRowHeight;
}
_setRowHeight(row, height, clearCache) {
var _a;
this.rowHeightsMap.put(row, (null === (_a = this.options.customConfig) || void 0 === _a ? void 0 : _a._disableColumnAndRowSizeRound) ? height : Math.round(height)),
clearCache && this._clearRowRangeHeightsMap(row);
}
setRowHeight(row, height) {
this.scenegraph.setRowHeight(row, height), this.scenegraph.updateChartSizeForResizeRowHeight(row),
this.internalProps._heightResizedRowMap.add(row);
}
getRowsHeight(startRow, endRow) {
var _a, _b;
if (startRow > endRow || 0 === this.rowCount) return 0;
startRow = Math.max(startRow, 0), endRow = Math.min(endRow, (null !== (_a = this.rowCount) && void 0 !== _a ? _a : 1 / 0) - 1);
let h = 0;
const isDefaultRowHeightIsAuto = "auto" === this.options.defaultRowHeight;
if ("standard" !== this.heightMode || this.options.customComputeRowHeight || this.autoFillHeight || !this.internalProps.layoutMap || this.hasAutoImageColumn() || isDefaultRowHeightIsAuto || 0 !== this.internalProps._heightResizedRowMap.size) {
if (null === (_b = this.options.customConfig) || void 0 === _b ? void 0 : _b._disableColumnAndRowSizeRound) {
const tempH = this.rowHeightsMap.getSumInRange(startRow, endRow);
let heightRange;
return heightRange = endRow < this.frozenRowCount ? this.rowHeightsMap.getSumInRange(0, endRow) : endRow >= this.rowCount - this.bottomFrozenRowCount ? this.rowHeightsMap.getSumInRange(endRow, this.rowCount - 1) : this.rowHeightsMap.getSumInRange(this.frozenRowCount, endRow),
heightRange = Number(heightRange.toFixed(2)), Number.isInteger(heightRange) ? Math.ceil(tempH) : Math.floor(tempH);
}
h = this.rowHeightsMap.getSumInRange(startRow, endRow);
} else {
for (let i = startRow; i < Math.min(endRow + 1, this.columnHeaderLevelCount); i++) h += this.getRowHeight(i);
endRow >= this.columnHeaderLevelCount && (h += this.defaultRowHeight * (Math.min(endRow, this.rowCount - this.bottomFrozenRowCount - 1) - Math.max(this.columnHeaderLevelCount, startRow) + 1));
for (let i = this.rowCount - this.bottomFrozenRowCount; i < endRow + 1; i++) h += this.getRowHeight(i);
}
return Math.round(h);
}
getColWidthDefined(col) {
var _a;
const {layoutMap: layoutMap} = this.internalProps;
if ("autoWidth" === this.widthMode) return "auto";
const {width: width} = null !== (_a = null == layoutMap ? void 0 : layoutMap.getColumnWidthDefined(col)) && void 0 !== _a ? _a : {};
return "number" == typeof width && width <= 0 ? 0 : width || this.getDefaultColumnWidth(col);
}
getColWidthDefinedNumber(col) {
const width = this.getColWidthDefined(col);
return this._adjustColWidth(col, this._colWidthDefineToPxWidth(width));
}
isAutoRowHeight(row) {
return "autoHeight" === this.heightMode || (!!this.options.customComputeRowHeight || (row >= 0 && row < this.columnHeaderLevelCount ? "auto" === this.getDefaultRowHeight(row) : "auto" === this.internalProps.defaultRowHeight));
}
getColWidth(col) {
var _a;
const width = null !== (_a = this.colWidthsMap.get(col)) && void 0 !== _a ? _a : this.getDefaultColumnWidth(col);
return "adaptive" === this.widthMode && "number" == typeof width || this.transpose && "number" == typeof width ? this._colWidthDefineToPxWidth(width) : this._adjustColWidth(col, this._colWidthDefineToPxWidth(width));
}
_setColWidth(col, width, clearCache, skipCheckFrozen) {
this.colWidthsMap.put(col, "number" == typeof width ? Math.round(width) : width),
clearCache && this._clearColRangeWidthsMap(col), skipCheckFrozen || this.stateManager.checkFrozen();
}
setColWidth(col, width) {
this.scenegraph.setColWidth(col, width), this.scenegraph.updateChartSizeForResizeColWidth(col),
this.internalProps._widthResizedColMap.add(col);
}
_clearColRangeWidthsMap(col) {
if ("number" != typeof col) this._colRangeWidthsMap.clear(); else {
const keys = this._colRangeWidthsMap.keys();
for (const key of keys) {
const reg = rangeReg.exec(key);
if (reg) {
const start = Number(reg[1]), end = Number(reg[2]);
col >= start && col <= end && this._colRangeWidthsMap.delete(key);
}
}
}
}
_clearRowRangeHeightsMap(row) {
this.rowHeightsMap.clearRange();
}
_getColContentWidth(col) {
return Number(this.colContentWidthsMap.get(col));
}
_setColContentWidth(col, width) {
this.colContentWidthsMap.put(col, width);
}
getAllRowsHeight() {
if (this.internalProps.rowCount <= 0) return 0;
return this.getRowsHeight(0, this.internalProps.rowCount - 1);
}
getAllColsWidth() {
if (this.internalProps.colCount <= 0) return 0;
return this.getColsWidth(0, this.internalProps.colCount - 1);
}
getMaxColWidth(col) {
var _a;
const obj = this.colWidthsLimit[col];
let max = null !== (_a = obj && obj.max) && void 0 !== _a ? _a : 1 / 0;
return "string" == typeof max && (max = _toPxWidth(this, max)), max;
}
setMaxColWidth(col, maxwidth) {
(this.colWidthsLimit[col] || (this.colWidthsLimit[col] = {})).max = maxwidth;
}
getMinColWidth(col) {
var _a;
const obj = this.colWidthsLimit[col];
let min = null !== (_a = obj && obj.min) && void 0 !== _a ? _a : 0;
return "string" == typeof min && (min = _toPxWidth(this, min)), min;
}
setMinColWidth(col, minwidth) {
(this.colWidthsLimit[col] || (this.colWidthsLimit[col] = {})).min = minwidth;
}
getCellRect(col, row) {
var _a, _b;
const isFrozenCell = this.isFrozenCell(col, row);
let absoluteLeft;
const width = this.getColWidth(col);
let absoluteTop;
absoluteLeft = isFrozenCell && isFrozenCell.col && this.isRightFrozenColumn(col, row) ? this.getAllColsWidth() <= this.tableNoFrameWidth ? this.getColsWidth(0, col - 1) || 0 : this.tableNoFrameWidth - (null !== (_a = this.getColsWidth(col, this.colCount - 1)) && void 0 !== _a ? _a : 0) : this.getColsWidth(0, col - 1) || 0;
const height = this.getRowHeight(row);
return absoluteTop = isFrozenCell && isFrozenCell.row && this.isBottomFrozenRow(col, row) ? this.getAllRowsHeight() <= this.tableNoFrameHeight ? this.getRowsHeight(0, row - 1) : this.tableNoFrameHeight - (null !== (_b = this.getRowsHeight(row, this.rowCount - 1)) && void 0 !== _b ? _b : 0) : this.getRowsHeight(0, row - 1),
new Rect(Math.round(absoluteLeft), Math.round(absoluteTop), Math.round(width), Math.round(height));
}
getMergeCellRect(col, row) {
const cellRange = this.getCellRange(col, row), absoluteLeft = this.getColsWidth(0, cellRange.start.col - 1) || 0, width = this.getColsWidth(cellRange.start.col, cellRange.end.col), absoluteTop = this.getRowsHeight(0, cellRange.start.row - 1) || 0, height = this.getRowsHeight(cellRange.start.row, cellRange.end.row);
return new Rect(Math.round(absoluteLeft), Math.round(absoluteTop), Math.round(width), Math.round(height));
}
getCellRelativeRect(col, row) {
const isFrozenCell = this.isFrozenCell(col, row);
let relativeX = !0, relativeY = !0;
(null == isFrozenCell ? void 0 : isFrozenCell.col) && (null == isFrozenCell ? void 0 : isFrozenCell.row) ? (relativeX = !1,
relativeY = !1) : (null == isFrozenCell ? void 0 : isFrozenCell.col) ? relativeX = !1 : (null == isFrozenCell ? void 0 : isFrozenCell.row) && (relativeY = !1);
const cellRect = this.getCellRect(col, row);
return this._toRelativeRect(cellRect, relativeX, relativeY);
}
getCellRangeRelativeRect(range) {
if (range.start) {
const isFrozenCell = this.isFrozenCell(range.start.col, range.start.row);
let relativeX = !0, relativeY = !0;
return (null == isFrozenCell ? void 0 : isFrozenCell.col) && (null == isFrozenCell ? void 0 : isFrozenCell.row) ? (relativeX = !1,
relativeY = !1) : (null == isFrozenCell ? void 0 : isFrozenCell.col) ? relativeX = !1 : (null == isFrozenCell ? void 0 : isFrozenCell.row) && (relativeY = !1),
this._toRelativeRect(this.getCellsRect(range.start.col, range.start.row, range.end.col, range.end.row), relativeX, relativeY);
}
const cellRange = this.getCellRange(range.col, range.row), isFrozenCell = this.isFrozenCell(range.col, range.row);
let relativeX = !0, relativeY = !0;
return (null == isFrozenCell ? void 0 : isFrozenCell.col) && (null == isFrozenCell ? void 0 : isFrozenCell.row) ? (relativeX = !1,
relativeY = !1) : (null == isFrozenCell ? void 0 : isFrozenCell.col) ? relativeX = !1 : (null == isFrozenCell ? void 0 : isFrozenCell.row) && (relativeY = !1),
this._toRelativeRect(this.getCellsRect(cellRange.start.col, cellRange.start.row, cellRange.end.col, cellRange.end.row), relativeX, relativeY);
}
getVisibleCellRangeRelativeRect(range) {
let cellRange;
return cellRange = range.start ? range : this.getCellRange(range.col, range.row),
this._getVisiableRect(this.getCellRangeRelativeRect(range), cellRange);
}
_getVisiableRect(relativeRectObj, cellRange) {
const targetLeft = cellRange.start.col >= this.frozenColCount ? Math.max(relativeRectObj.left, this.frozenColCount >= 1 ? this.getColsWidth(0, this.frozenColCount - 1) : 0) : relativeRectObj.left, targetRight = Math.min(relativeRectObj.right, this.tableNoFrameWidth), rect = relativeRectObj.copy();
rect.left = targetLeft, rect.right = targetRight;
const targetTop = cellRange.start.row >= this.frozenRowCount ? Math.max(relativeRectObj.top, this.frozenRowCount >= 1 ? this.getRowsHeight(0, this.frozenRowCount - 1) : 0) : relativeRectObj.top, targetBottom = Math.min(relativeRectObj.bottom, this.tableNoFrameHeight);
return rect.top = targetTop, rect.bottom = targetBottom, rect;
}
getCellsRect(startCol, startRow, endCol, endRow) {
var _a, _b, _c, _d, _e, _f;
let absoluteLeft = this.getColsWidth(0, startCol - 1) || 0, width = this.getColsWidth(startCol, endCol);
const scrollLeft = this.scrollLeft;
this.isLeftFrozenColumn(startCol) && this.isRightFrozenColumn(endCol) ? width = this.tableNoFrameWidth - (null !== (_a = this.getColsWidth(startCol + 1, this.colCount - 1)) && void 0 !== _a ? _a : 0) - absoluteLeft : this.isLeftFrozenColumn(startCol) && !this.isLeftFrozenColumn(endCol) ? width = Math.max(width - scrollLeft, this.getColsWidth(startCol, this.frozenColCount - 1)) : !this.isRightFrozenColumn(startCol) && this.isRightFrozenColumn(endCol) ? (absoluteLeft = Math.min(absoluteLeft - scrollLeft, this.tableNoFrameWidth - this.getRightFrozenColsWidth()),
width = this.tableNoFrameWidth - (null !== (_b = this.getColsWidth(startCol + 1, this.colCount - 1)) && void 0 !== _b ? _b : 0) - absoluteLeft) : this.isRightFrozenColumn(startCol) && (absoluteLeft = this.tableNoFrameWidth - (null !== (_c = this.getColsWidth(startCol, this.colCount - 1)) && void 0 !== _c ? _c : 0));
let absoluteTop = this.getRowsHeight(0, startRow - 1), height = this.getRowsHeight(startRow, endRow);
const scrollTop = this.scrollTop;
return this.isTopFrozenRow(startRow) && this.isBottomFrozenRow(endRow) ? hei