UNPKG

@visactor/vtable

Version:

canvas table width high performance

755 lines (711 loc) 81.3 kB
import { createStage, container, vglobal, registerForVrender } from "./../vrender"; import { InternalIconName } from "../ts-types"; import { getCellMergeInfo } from "./utils/get-cell-merge"; import { updateColWidth } from "./layout/update-width"; import { TableComponent } from "./component/table-component"; import { updateRowHeight } from "./layout/update-height"; import { updateImageCellContentWhileResize } from "./group-creater/cell-type/image-cell"; import { getQuadProps } from "./utils/padding"; import { createFrameBorder, updateCornerRadius, updateFrameBorder, updateFrameBorderSize } from "./style/frame-border"; import splitModule from "./graphic/contributions"; import { getProp } from "./utils/get-prop"; import { dealWithIcon } from "./utils/text-icon-layout"; import { SceneProxy } from "./group-creater/progress/proxy"; import { computeColWidth, computeColsWidth, getAdaptiveWidth } from "./layout/compute-col-width"; import { moveHeaderPosition } from "./layout/move-cell"; import { updateCell } from "./group-creater/cell-helper"; import { updateAllSelectComponent, updateCellSelectBorder } from "./select/update-select-border"; import { createCellSelectBorder } from "./select/create-select-border"; import { moveSelectingRangeComponentsToSelectedRangeComponents } from "./select/move-select-border"; import { deleteAllSelectBorder, deleteAllSelectingBorder, deleteLastSelectedRangeComponents, removeFillHandleFromSelectComponents } from "./select/delete-select-border"; import { updateRow } from "./layout/update-row"; import { handleTextStick } from "./stick-text"; import { computeRowHeight, computeRowsHeight } from "./layout/compute-row-height"; import { emptyGroup } from "./utils/empty-group"; import { dealBottomFrozen, dealFrozen, dealRightFrozen, resetFrozen, resetRowFrozen } from "./layout/frozen"; import { clearCellChartCacheImage, updateChartSizeForResizeColWidth, updateChartSizeForResizeRowHeight, updateChartState } from "./refresh-node/update-chart"; import { initSceneGraph } from "./group-creater/init-scenegraph"; import { updateContainerChildrenX, updateContainerChildrenY } from "./utils/update-container"; import { setPoptipTheme } from "./../vrender"; import textMeasureModule from "./utils/text-measure"; import { getIconByXY, hideClickIcon, hideHoverIcon, resetResidentHoverIcon, residentHoverIcon, setIconHoverStyle, setIconNormalStyle, showClickIcon, showHoverIcon, updateFrozenIcon, updateHierarchyIcon, updateSortIcon } from "./icon/icon-update"; import { Env } from "../tools/env"; import { createCornerCell } from "./style/corner-cell"; import { updateCol } from "./layout/update-col"; import { deduplication } from "../tools/util"; import { dealWithAnimationAppear } from "./animation/appear"; import { updateReactContainer } from "./layout/frozen-react"; import * as registerIcons from "../icons"; import { temporarilyUpdateSelectRectStyle } from "./select/update-select-style"; import { TABLE_EVENT_TYPE } from "../core/TABLE_EVENT_TYPE"; import { getCellEventArgsSet } from "../event/util"; import { clearAndReleaseBrushingChartInstance, getBrushingChartInstance, getBrushingChartInstanceCellPos } from "./graphic/active-cell-chart-list"; registerForVrender(), container.load(splitModule), container.load(textMeasureModule); export class Scenegraph { constructor(table) { let width, height; this._needUpdateContainer = !1, this.table = table, this.hasFrozen = !1, this.clear = !0, this.mergeMap = new Map, this.brushingChartInstance = void 0, this.brushingChartInstanceCellPos = { col: -1, row: -1 }, this.chartInstanceListColumnByColumnDirection = {}, this.chartInstanceListRowByRowDirection = {}, this.delayRunDimensionHoverTimerForColumnDirection = [], this.delayRunDimensionHoverTimerForRowDirection = [], this.delayRunDimensionHoverTimerForViewRange = [], this.disabledTooltipToAllChartInstances = !1, setPoptipTheme(this.table.theme.textPopTipStyle), "node" === Env.mode ? (vglobal.setEnv("node", table.options.modeParams), width = table.canvasWidth, height = table.canvasHeight) : table.options.canvas && table.options.viewBox ? (vglobal.setEnv("browser"), width = table.options.viewBox.x2 - table.options.viewBox.x1, height = table.options.viewBox.y2 - table.options.viewBox.y1) : (vglobal.setEnv("browser"), width = table.canvas.width, height = table.canvas.height), this.stage = createStage(Object.assign({ canvas: table.canvas, width: width, height: height, disableDirtyBounds: !1, background: table.theme.underlayBackgroundColor, dpr: table.internalProps.pixelRatio, enableLayout: !0, beforeRender: stage => { this.table.options.beforeRender && this.table.options.beforeRender(stage), this.table.animationManager.ticker.start(); }, afterRender: stage => { this.table.options.afterRender && this.table.options.afterRender(stage), this.table.fireListeners("after_render", null); }, canvasControled: !table.options.canvas, viewBox: table.options.viewBox }, table.options.renderOption)), this.stage.defaultLayer.setTheme({ group: { boundsPadding: 0, strokeBoundsBuffer: 0, lineJoin: "round" }, text: { ignoreBuf: !0 } }), this.initSceneGraph(), this.stage.defaultLayer.add(this.tableGroup), this.stage.table = this.table, this.createComponent(); } get width() { var _a, _b; return null !== (_b = null === (_a = this.tableGroup.attribute) || void 0 === _a ? void 0 : _a.width) && void 0 !== _b ? _b : 0; } get height() { var _a, _b; return null !== (_b = null === (_a = this.tableGroup.attribute) || void 0 === _a ? void 0 : _a.height) && void 0 !== _b ? _b : 0; } get x() { var _a, _b; return null !== (_b = null === (_a = this.tableGroup.attribute) || void 0 === _a ? void 0 : _a.x) && void 0 !== _b ? _b : 0; } get y() { var _a, _b; return null !== (_b = null === (_a = this.tableGroup.attribute) || void 0 === _a ? void 0 : _a.y) && void 0 !== _b ? _b : 0; } get bodyRowStart() { var _a; return null !== (_a = this.proxy.rowStart) && void 0 !== _a ? _a : 0; } get bodyRowEnd() { var _a; return null !== (_a = this.proxy.rowEnd) && void 0 !== _a ? _a : this.table.rowCount - 1; } get bodyColStart() { var _a; return null !== (_a = this.proxy.colStart) && void 0 !== _a ? _a : 0; } get bodyColEnd() { var _a; return null !== (_a = this.proxy.colEnd) && void 0 !== _a ? _a : this.table.colCount - 1; } initSceneGraph() { this.isPivot = this.table.isPivotTable(), initSceneGraph(this); } canvasShowMenu() { this.stage.addEventListener("rightdown", (e => { const eventArgsSet = getCellEventArgsSet(e); eventArgsSet.eventArgs || (this.table.stateManager.triggerContextMenu(-1, -1, eventArgsSet.abstractPos.x, eventArgsSet.abstractPos.y), this.table.fireListeners(TABLE_EVENT_TYPE.CONTEXTMENU_CANVAS, { event: e, x: eventArgsSet.abstractPos.x, y: eventArgsSet.abstractPos.y, col: -1, row: -1, target: void 0 })); })); } clearCells() { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v; this.table.animationManager.clear(), (this.table.isPivotChart() || this.table._hasCustomRenderOrLayout()) && this.stage.pluginService.findPluginsByName("poptipForText").forEach((plugin => { plugin.deactivate(this.stage.pluginService); })), this.clear = !0, this.hasFrozen = !1, this.mergeMap.clear(), this.colHeaderGroup.clear(), delete this.colHeaderGroup.border, this.rowHeaderGroup.clear(), delete this.rowHeaderGroup.border, this.cornerHeaderGroup.clear(), delete this.cornerHeaderGroup.border, this.bodyGroup.clear(), delete this.bodyGroup.border, this.bottomFrozenGroup.clear(), delete this.bottomFrozenGroup.border, this.rightFrozenGroup.clear(), delete this.rightFrozenGroup.border, this.rightTopCornerGroup.clear(), delete this.rightTopCornerGroup.border, this.rightBottomCornerGroup.clear(), delete this.rightBottomCornerGroup.border, this.leftBottomCornerGroup.clear(), delete this.leftBottomCornerGroup.border, null === (_a = this.bodySelectGroup) || void 0 === _a || _a.clear(), null === (_b = this.rowHeaderSelectGroup) || void 0 === _b || _b.clear(), null === (_c = this.bottomFrozenSelectGroup) || void 0 === _c || _c.clear(), null === (_d = this.colHeaderSelectGroup) || void 0 === _d || _d.clear(), null === (_e = this.rightFrozenSelectGroup) || void 0 === _e || _e.clear(), null === (_f = this.rightTopCornerSelectGroup) || void 0 === _f || _f.clear(), null === (_g = this.leftBottomCornerSelectGroup) || void 0 === _g || _g.clear(), null === (_h = this.rightBottomCornerSelectGroup) || void 0 === _h || _h.clear(), null === (_j = this.cornerHeaderSelectGroup) || void 0 === _j || _j.clear(), this.colHeaderGroup.setAttributes({ x: 0, y: 0, width: 0, height: 0 }), this.rowHeaderGroup.setAttributes({ x: 0, y: 0, width: 0, height: 0 }), this.cornerHeaderGroup.setAttributes({ x: 0, y: 0, width: 0, height: 0 }), this.bodyGroup.setAttributes({ x: 0, y: 0, width: 0, height: 0 }), this.rightFrozenGroup.setAttributes({ x: 0, y: 0, width: 0, height: 0 }), this.bottomFrozenGroup.setAttributes({ x: 0, y: 0, width: 0, height: 0 }), this.rightTopCornerGroup.setAttributes({ x: 0, y: 0, width: 0, height: 0, visible: !1 }), this.leftBottomCornerGroup.setAttributes({ x: 0, y: 0, width: 0, height: 0, visible: !1 }), this.rightBottomCornerGroup.setAttributes({ x: 0, y: 0, width: 0, height: 0, visible: !1 }), null === (_k = this.bodySelectGroup) || void 0 === _k || _k.setAttributes({ x: 0, y: 0, width: 0, height: 0 }), null === (_l = this.rowHeaderSelectGroup) || void 0 === _l || _l.setAttributes({ x: 0, y: 0, width: 0, height: 0 }), null === (_m = this.bottomFrozenSelectGroup) || void 0 === _m || _m.setAttributes({ x: 0, y: 0, width: 0, height: 0, visible: !1 }), null === (_o = this.colHeaderSelectGroup) || void 0 === _o || _o.setAttributes({ x: 0, y: 0, width: 0, height: 0 }), null === (_p = this.rightFrozenSelectGroup) || void 0 === _p || _p.setAttributes({ x: 0, y: 0, width: 0, height: 0, visible: !1 }), null === (_q = this.rightTopCornerSelectGroup) || void 0 === _q || _q.setAttributes({ x: 0, y: 0, width: 0, height: 0, visible: !1 }), null === (_r = this.leftBottomCornerSelectGroup) || void 0 === _r || _r.setAttributes({ x: 0, y: 0, width: 0, height: 0, visible: !1 }), null === (_s = this.rightBottomCornerSelectGroup) || void 0 === _s || _s.setAttributes({ x: 0, y: 0, width: 0, height: 0, visible: !1 }), null === (_t = this.cornerHeaderSelectGroup) || void 0 === _t || _t.setAttributes({ x: 0, y: 0, width: 0, height: 0 }), this.tableGroup.setAttributes({ x: this.table.tableX, y: this.table.tableY, width: 0, height: 0 }), this.tableGroup.border && (this.tableGroup.parent.removeChild(this.tableGroup.border), delete this.tableGroup.border), null === (_u = this.proxy) || void 0 === _u || _u.release(), null === (_v = this.table.reactCustomLayout) || void 0 === _v || _v.clearCache(); } updateStageBackground() { this.stage.background = this.table.theme.underlayBackgroundColor, this.stage.renderNextFrame(); } createComponent() { this.component = new TableComponent(this.table), this.component.addToGroup(this.componentGroup), this.selectedRangeComponents = new Map, this.selectingRangeComponents = new Map, this.customSelectedRangeComponents = new Map; } updateComponent() { this.component.updateStyle(); } createSceneGraph(skipRowHeightClear = !1) { skipRowHeightClear || (this.table.rowHeightsMap.clear(), this.table.internalProps.layoutMap.clearCellRangeMap()), (this.table.isPivotChart() || this.table._hasCustomRenderOrLayout()) && this.stage.pluginService.autoEnablePlugins.getContributions().forEach((p => { "poptipForText" === p.name && this.stage.pluginService.register(p); })), this.clear = !1, this.frozenColCount = this.table.frozenColCount, this.frozenRowCount = this.table.frozenRowCount, this.proxy = new SceneProxy(this.table), createFrameBorder(this.tableGroup, this.table.theme.frameStyle, this.tableGroup.role, void 0, !0), this.table.isPivotChart() && (createCornerCell(this.rightTopCornerGroup, this.table.theme.cornerRightTopCellStyle || this.table.theme.cornerHeaderStyle || {}), createCornerCell(this.leftBottomCornerGroup, this.table.theme.cornerLeftBottomCellStyle || this.table.theme.cornerHeaderStyle || {}), createCornerCell(this.rightBottomCornerGroup, this.table.theme.cornerRightBottomCellStyle || this.table.theme.cornerHeaderStyle || {})), this.proxy.createGroupForFirstScreen(this.cornerHeaderGroup, this.colHeaderGroup, this.rowHeaderGroup, this.rightFrozenGroup, this.bottomFrozenGroup, this.bodyGroup, 0, 0), this.afterScenegraphCreated(); } renderSceneGraph() { this.stage.render(); } getCell(col, row, getShadow) { var _a, _b, _c, _d, _e, _f; let cell; if (cell = this.table.rightFrozenColCount > 0 && col >= this.table.colCount - this.table.rightFrozenColCount && row < this.table.frozenRowCount ? null === (_a = this.rightTopCornerGroup.getColGroup(col)) || void 0 === _a ? void 0 : _a.getRowGroup(row) : this.table.bottomFrozenRowCount > 0 && row >= this.table.rowCount - this.table.bottomFrozenRowCount && col < this.table.frozenColCount ? null === (_b = this.leftBottomCornerGroup.getColGroup(col)) || void 0 === _b ? void 0 : _b.getRowGroup(row) : this.table.rightFrozenColCount > 0 && this.table.bottomFrozenRowCount > 0 && col >= this.table.colCount - this.table.rightFrozenColCount && row >= this.table.rowCount - this.table.bottomFrozenRowCount ? null === (_c = this.rightBottomCornerGroup.getColGroup(col)) || void 0 === _c ? void 0 : _c.getRowGroup(row) : this.table.rightFrozenColCount > 0 && col > this.table.colCount - 1 - this.table.rightFrozenColCount ? null === (_d = this.rightFrozenGroup.getColGroup(col)) || void 0 === _d ? void 0 : _d.getRowGroup(row) : this.table.bottomFrozenRowCount > 0 && row > this.table.rowCount - 1 - this.table.bottomFrozenRowCount ? null === (_e = this.bottomFrozenGroup.getColGroup(col)) || void 0 === _e ? void 0 : _e.getRowGroup(row) : null === (_f = this.getColGroup(col, row < this.frozenRowCount)) || void 0 === _f ? void 0 : _f.getRowGroup(row), cell && "shadow-cell" === cell.role && !getShadow) { const range = this.table.getCellRange(col, row); range.start.col === col && range.start.row === row || (cell = this.getCell(range.start.col, range.start.row)); } return cell || emptyGroup; } highPerformanceGetCell(col, row, getShadow) { return this.proxy.highPerformanceGetCell(col, row, getShadow); } getColGroup(col, isCornerOrColHeader = !1) { let element; return element = col < this.frozenColCount && isCornerOrColHeader ? this.cornerHeaderGroup.getColGroup(col) : col < this.frozenColCount ? this.rowHeaderGroup.getColGroup(col) : isCornerOrColHeader && this.table.rightFrozenColCount > 0 && col > this.table.colCount - 1 - this.table.rightFrozenColCount ? this.rightTopCornerGroup.getColGroup(col) : !isCornerOrColHeader && this.table.rightFrozenColCount > 0 && col > this.table.colCount - 1 - this.table.rightFrozenColCount ? this.rightFrozenGroup.getColGroup(col) : isCornerOrColHeader ? this.colHeaderGroup.getColGroup(col) : this.bodyGroup.getColGroup(col), element || void 0; } getColGroupInBottom(col, isCornerOrColHeader = !1) { var _a; if (isCornerOrColHeader) { const element = null !== (_a = this.getColGroupInLeftBottomCorner(col)) && void 0 !== _a ? _a : this.getColGroupInRightBottomCorner(col); if (element) return element; } if (this.table.bottomFrozenRowCount > 0) return this.bottomFrozenGroup.getColGroup(col); } getColGroupInLeftBottomCorner(col) { if (this.table.bottomFrozenRowCount > 0) return this.leftBottomCornerGroup.getColGroup(col); } getColGroupInRightTopCorner(col) { if (this.table.rightFrozenColCount > 0) return this.rightTopCornerGroup.getColGroup(col); } getColGroupInRightBottomCorner(col) { if (this.table.rightFrozenColCount > 0 && this.table.bottomFrozenRowCount > 0) return this.rightBottomCornerGroup.getColGroup(col); } getCellSize(col, row) { const cell = this.getCell(col, row), mergeInfo = getCellMergeInfo(this.table, col, row); let width = cell.attribute.width, height = cell.attribute.height; return mergeInfo && (width /= mergeInfo.end.col - mergeInfo.start.col + 1, height /= mergeInfo.end.row - mergeInfo.start.row + 1), { width: width, height: height }; } updateNextFrame() { this.updateContainerSync(), this.resetAllSelectComponent(), this.stage.renderNextFrame(); } resetAllSelectComponent() { var _a, _b, _c, _d; ((null === (_b = null === (_a = this.table.stateManager.select) || void 0 === _a ? void 0 : _a.ranges) || void 0 === _b ? void 0 : _b.length) > 0 || (null === (_d = null === (_c = this.table.stateManager.select) || void 0 === _c ? void 0 : _c.customSelectRanges) || void 0 === _d ? void 0 : _d.length) > 0) && updateAllSelectComponent(this); } hideHoverIcon(col, row) { hideHoverIcon(col, row, this); } showHoverIcon(col, row) { showHoverIcon(col, row, this); } hideClickIcon(col, row) { hideClickIcon(col, row, this); } showClickIcon(col, row) { showClickIcon(col, row, this); } getIcon(col, row, x, y) { return getIconByXY(col, row, x, y, this); } setIconHoverStyle(icon, col, row, cellGroup) { setIconHoverStyle(icon, col, row, cellGroup, this); } updateSortIcon(options) { const {col: col, row: row, iconMark: iconMark, order: order, oldSortCol: oldSortCol, oldSortRow: oldSortRow, oldIconMark: oldIconMark} = options; updateSortIcon({ col: col, row: row, iconMark: iconMark, order: order, oldSortCol: oldSortCol, oldSortRow: oldSortRow, oldIconMark: oldIconMark, scene: this }); } updateFrozenIcon(col, oldFrozenCol) { updateFrozenIcon(this); } updateHierarchyIcon(col, row) { updateHierarchyIcon(col, row, this); } setIconNormalStyle(icon, col, row) { setIconNormalStyle(icon, col, row, this); } residentHoverIcon(col, row) { residentHoverIcon(col, row, this); } resetResidentHoverIcon(col, row) { resetResidentHoverIcon(col, row, this); } deactivateChart(col, row, forceRelease = !1) { var _a, _b, _c, _d, _e, _f; if (forceRelease) { const brushingChartInstanceCellPos = getBrushingChartInstanceCellPos(this), brushingChartInstance = getBrushingChartInstance(this); brushingChartInstanceCellPos && brushingChartInstance && (clearAndReleaseBrushingChartInstance(this), clearCellChartCacheImage(brushingChartInstanceCellPos.col, brushingChartInstanceCellPos.row, this)); } if (-1 === col || -1 === row) return; const cellGroup = this.getCell(col, row); if (null === (_a = null == cellGroup ? void 0 : cellGroup.firstChild) || void 0 === _a ? void 0 : _a.deactivate) { if (forceRelease) return void (null === (_c = null === (_b = null == cellGroup ? void 0 : cellGroup.firstChild) || void 0 === _b ? void 0 : _b.deactivate) || void 0 === _c || _c.call(_b, this.table, { forceRelease: !0, releaseChartInstance: !0, releaseColumnChartInstance: !0, releaseRowChartInstance: !0, releaseAllChartInstance: !0 })); const chartType = (null == cellGroup ? void 0 : cellGroup.firstChild).attribute.spec.type; null === (_e = null === (_d = null == cellGroup ? void 0 : cellGroup.firstChild) || void 0 === _d ? void 0 : _d.deactivate) || void 0 === _e || _e.call(_d, this.table, (null === (_f = this.table.options.chartDimensionLinkage) || void 0 === _f ? void 0 : _f.showTooltip) ? { releaseChartInstance: "pie" !== chartType && ("scatter" === chartType ? col !== this.table.stateManager.hover.cellPos.col && row !== this.table.stateManager.hover.cellPos.row || this.table.stateManager.hover.cellPos.row < this.table.frozenRowCount || this.table.stateManager.hover.cellPos.row > this.table.rowCount - 1 - this.table.bottomFrozenRowCount || this.table.stateManager.hover.cellPos.col < this.table.frozenColCount || this.table.stateManager.hover.cellPos.col > this.table.colCount - 1 - this.table.rightFrozenColCount : this.table.options.indicatorsAsCol ? row !== this.table.stateManager.hover.cellPos.row || this.table.stateManager.hover.cellPos.col < this.table.frozenColCount || this.table.stateManager.hover.cellPos.col > this.table.colCount - 1 - this.table.rightFrozenColCount : col !== this.table.stateManager.hover.cellPos.col || this.table.stateManager.hover.cellPos.row < this.table.frozenRowCount || this.table.stateManager.hover.cellPos.row > this.table.rowCount - 1 - this.table.bottomFrozenRowCount), releaseColumnChartInstance: "pie" !== chartType && (col !== this.table.stateManager.hover.cellPos.col || this.table.stateManager.hover.cellPos.row < this.table.frozenRowCount || this.table.stateManager.hover.cellPos.row > this.table.rowCount - 1 - this.table.bottomFrozenRowCount), releaseRowChartInstance: "pie" !== chartType && (row !== this.table.stateManager.hover.cellPos.row || this.table.stateManager.hover.cellPos.col < this.table.frozenColCount || this.table.stateManager.hover.cellPos.col > this.table.colCount - 1 - this.table.rightFrozenColCount) } : void 0); } } activateChart(col, row) { var _a, _b, _c; if (-1 === col || -1 === row) return; const cellGroup = this.getCell(col, row); return null === (_b = null === (_a = null == cellGroup ? void 0 : cellGroup.firstChild) || void 0 === _a ? void 0 : _a.activate) || void 0 === _b || _b.call(_a, this.table), null === (_c = null == cellGroup ? void 0 : cellGroup.firstChild) || void 0 === _c ? void 0 : _c.activeChartInstance; } removeInteractionBorder(col, row) { const cellGroup = this.getCell(col, row); cellGroup.setAttribute("highlightStroke", void 0), cellGroup.setAttribute("highlightStrokeArrayWidth", void 0), cellGroup.setAttribute("highlightStrokeArrayColor", void 0); } createCellSelectBorder(start_Col, start_Row, end_Col, end_Row, selectRangeType, selectId, strokes) { createCellSelectBorder(this, start_Col, start_Row, end_Col, end_Row, selectRangeType, selectId, strokes); } moveSelectingRangeComponentsToSelectedRangeComponents() { moveSelectingRangeComponentsToSelectedRangeComponents(this); } deleteLastSelectedRangeComponents() { deleteLastSelectedRangeComponents(this); } deleteAllSelectBorder() { deleteAllSelectBorder(this), deleteAllSelectingBorder(this); } updateCellSelectBorder(selectRange, extendSelectRange = !0) { updateCellSelectBorder(this, selectRange, extendSelectRange); } removeFillHandleFromSelectComponents() { removeFillHandleFromSelectComponents(this); } recreateAllSelectRangeComponents() { deleteAllSelectBorder(this), this.table.stateManager.select.ranges.forEach((cellRange => { updateCellSelectBorder(this, cellRange), moveSelectingRangeComponentsToSelectedRangeComponents(this); })); } updateColWidth(col, detaX, skipUpdateContainer, skipTableWidthMap) { updateColWidth(this, col, Math.round(detaX), skipTableWidthMap), skipUpdateContainer || this.updateContainer({ async: !0 }); } updateChartSizeForResizeColWidth(col) { updateChartSizeForResizeColWidth(this, col); } updateChartSizeForResizeRowHeight(row) { updateChartSizeForResizeRowHeight(this, row); } updateChartState(datum, selectedDataMode) { var _a, _b, _c; if (this.table.isPivotChart()) { if (null == datum || 0 === (null == datum ? void 0 : datum.length) || 0 === Object.keys(datum).length) { const brushingChartInstance = getBrushingChartInstance(this); brushingChartInstance && (null === (_a = brushingChartInstance.getChart()) || void 0 === _a || _a.getComponentsByKey("brush")[0].clearBrushStateAndMask()), null === (_c = null === (_b = this.table.options.chartDimensionLinkage) || void 0 === _b ? void 0 : _b.clearChartState) || void 0 === _c || _c.call(_b); } updateChartState(this, datum, selectedDataMode); } } updateCheckboxCellState(col, row, checked) { var _a, _b; if (this.table.transpose) null === (_a = this.bodyGroup.children) || void 0 === _a || _a.forEach((columnGroup => { var _a; null === (_a = columnGroup.getChildAt(row)) || void 0 === _a || _a.getChildren().forEach((node => { "checkbox" === node.name && ("indeterminate" === checked ? (node.setAttribute("indeterminate", !0), node.setAttribute("checked", void 0)) : (node.setAttribute("indeterminate", void 0), node.setAttribute("checked", checked))), "checkbox-content" === node.name && ("indeterminate" === checked ? (node._checkboxGroup.getChildByName("checkbox").setAttribute("indeterminate", !0), node._checkboxGroup.getChildByName("checkbox").setAttribute("checked", void 0)) : (node._checkboxGroup.getChildByName("checkbox").setAttribute("indeterminate", void 0), node._checkboxGroup.getChildByName("checkbox").setAttribute("checked", checked))); })); })); else { const columnGroup = this.getColGroup(col); null === (_b = null == columnGroup ? void 0 : columnGroup.children) || void 0 === _b || _b.forEach((cellNode => { cellNode.getChildren().find((node => { "checkbox" === node.name && ("indeterminate" === checked ? (node.setAttribute("indeterminate", !0), node.setAttribute("checked", void 0)) : (node.setAttribute("indeterminate", void 0), node.setAttribute("checked", checked))), "checkbox-content" === node.name && ("indeterminate" === checked ? (node._checkboxGroup.getChildByName("checkbox").setAttribute("indeterminate", !0), node._checkboxGroup.getChildByName("checkbox").setAttribute("checked", void 0)) : (node._checkboxGroup.getChildByName("checkbox").setAttribute("indeterminate", void 0), node._checkboxGroup.getChildByName("checkbox").setAttribute("checked", checked))); })); })); } } updateHeaderCheckboxCellState(col, row, checked) { var _a, _b; if (this.table.transpose) null === (_a = this.rowHeaderGroup.children) || void 0 === _a || _a.forEach((columnGroup => { columnGroup.getChildAt(row).getChildren().forEach((node => { "checkbox" === node.name && ("indeterminate" === checked ? (node.setAttribute("indeterminate", !0), node.setAttribute("checked", void 0)) : (node.setAttribute("indeterminate", void 0), node.setAttribute("checked", checked))), "checkbox-content" === node.name && ("indeterminate" === checked ? (node._checkboxGroup.getChildByName("checkbox").setAttribute("indeterminate", !0), node._checkboxGroup.getChildByName("checkbox").setAttribute("checked", void 0)) : (node._checkboxGroup.getChildByName("checkbox").setAttribute("indeterminate", void 0), node._checkboxGroup.getChildByName("checkbox").setAttribute("checked", checked))); })); })); else { null === (_b = this.getColGroup(col, !0).children) || void 0 === _b || _b.forEach((cellNode => { cellNode.getChildren().find((node => { "checkbox" === node.name && ("indeterminate" === checked ? (node.setAttribute("indeterminate", !0), node.setAttribute("checked", void 0)) : (node.setAttribute("indeterminate", void 0), node.setAttribute("checked", checked))), "checkbox-content" === node.name && ("indeterminate" === checked ? (node._checkboxGroup.getChildByName("checkbox").setAttribute("indeterminate", !0), node._checkboxGroup.getChildByName("checkbox").setAttribute("checked", void 0)) : (node._checkboxGroup.getChildByName("checkbox").setAttribute("indeterminate", void 0), node._checkboxGroup.getChildByName("checkbox").setAttribute("checked", checked))); })); })); } } updateAutoColWidth(col) { this.table.internalProps._widthResizedColMap.delete(col); const oldWidth = this.table.getColWidth(col), newWidth = computeColWidth(col, 0, this.table.rowCount - 1, this.table, !0); newWidth !== oldWidth && this.updateColWidth(col, newWidth - oldWidth); } recalculateColWidths() { const table = this.table; "adaptive" === table.widthMode || table.autoFillWidth || table.internalProps.transpose ? computeColsWidth(this.table, 0, this.table.colCount - 1, !0) : (table._clearColRangeWidthsMap(), table.frozenColCount > 0 && computeColsWidth(this.table, 0, table.frozenColCount - 1, !0), table.rightFrozenColCount > 0 && computeColsWidth(this.table, table.rightFrozenColCount, table.colCount - 1, !0), computeColsWidth(table, this.proxy.colStart, this.proxy.colEnd, !0)); } recalculateRowHeights() { const table = this.table; table.internalProps.useOneRowHeightFillAll = !1, "adaptive" === table.heightMode || table.autoFillHeight ? computeRowsHeight(this.table, 0, this.table.rowCount - 1, !0, !0) : (table.frozenRowCount > 0 && computeRowsHeight(this.table, 0, table.frozenRowCount - 1, !0, !0), table.bottomFrozenRowCount > 0 && computeRowsHeight(this.table, table.bottomFrozenRowCount, table.rowCount - 1, !0, !0), computeRowsHeight(table, this.proxy.rowStart, this.proxy.rowEnd, !0, !0)); } resize() { var _a, _b; this.proxy.resize(), ("adaptive" === this.table.widthMode || this.table.autoFillWidth) && (0 === this.table.internalProps._widthResizedColMap.size ? this.recalculateColWidths() : this.dealWidthMode()), "adaptive" === this.table.heightMode ? 0 === this.table.internalProps._heightResizedRowMap.size ? this.recalculateRowHeights() : this.dealHeightMode() : this.table.autoFillHeight && this.dealHeightMode(), this.resetFrozen(), this.updateTableSize(), this.updateBorderSizeAndPosition(), this.component.updateScrollBar(), ("adaptive" === this.table.widthMode || "adaptive" === this.table.heightMode || this.table.autoFillWidth || this.table.autoFillHeight || (null === (_a = this.table.containerFit) || void 0 === _a ? void 0 : _a.width) || (null === (_b = this.table.containerFit) || void 0 === _b ? void 0 : _b.height)) && this.updateChartSizeForResizeColWidth(-1), this.proxy.progress(), this.updateNextFrame(); } updateTableSize() { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q; const contentWidth = Math.max(this.colHeaderGroup.attribute.width, this.bodyGroup.attribute.width, this.bottomFrozenGroup.attribute.width, 0) + Math.max(this.cornerHeaderGroup.attribute.width, this.rowHeaderGroup.attribute.width, this.leftBottomCornerGroup.attribute.width, 0) + Math.max(this.rightTopCornerGroup.attribute.width, this.rightFrozenGroup.attribute.width, this.rightBottomCornerGroup.attribute.width, 0), contentHeight = Math.max(this.colHeaderGroup.attribute.height, this.cornerHeaderGroup.attribute.height, this.rightTopCornerGroup.attribute.height, 0) + Math.max(this.rowHeaderGroup.attribute.height, this.bodyGroup.attribute.height, this.rightFrozenGroup.attribute.height, 0) + Math.max(this.leftBottomCornerGroup.attribute.height, this.bottomFrozenGroup.attribute.height, this.rightBottomCornerGroup.attribute.height, 0); let tableWidth = contentWidth, tableHeight = contentHeight; if (tableWidth = (null === (_a = this.table.containerFit) || void 0 === _a ? void 0 : _a.width) ? this.table.tableNoFrameWidth : Math.min(this.table.tableNoFrameWidth, contentWidth), tableHeight = (null === (_b = this.table.containerFit) || void 0 === _b ? void 0 : _b.height) ? this.table.tableNoFrameHeight : Math.min(this.table.tableNoFrameHeight, contentHeight), this.tableGroup.setAttributes({ x: this.table.tableX, y: this.table.tableY, width: tableWidth, height: tableHeight }), this.tableGroup.border) { const rectAttributes = null === (_c = this.tableGroup.border) || void 0 === _c ? void 0 : _c.attribute; let borderTop, borderRight, borderBottom, borderLeft; (null == rectAttributes ? void 0 : rectAttributes.strokeArrayWidth) ? (borderTop = rectAttributes.strokeArrayWidth ? rectAttributes.strokeArrayWidth[0] : null !== (_d = rectAttributes.lineWidth) && void 0 !== _d ? _d : 0, borderRight = rectAttributes.strokeArrayWidth ? rectAttributes.strokeArrayWidth[1] : null !== (_e = rectAttributes.lineWidth) && void 0 !== _e ? _e : 0, borderBottom = rectAttributes.strokeArrayWidth ? rectAttributes.strokeArrayWidth[2] : null !== (_f = rectAttributes.lineWidth) && void 0 !== _f ? _f : 0, borderLeft = rectAttributes.strokeArrayWidth ? rectAttributes.strokeArrayWidth[3] : null !== (_g = rectAttributes.lineWidth) && void 0 !== _g ? _g : 0) : (borderTop = null !== (_h = null == rectAttributes ? void 0 : rectAttributes.lineWidth) && void 0 !== _h ? _h : 0, borderRight = null !== (_j = null == rectAttributes ? void 0 : rectAttributes.lineWidth) && void 0 !== _j ? _j : 0, borderBottom = null !== (_k = null == rectAttributes ? void 0 : rectAttributes.lineWidth) && void 0 !== _k ? _k : 0, borderLeft = null !== (_l = null == rectAttributes ? void 0 : rectAttributes.lineWidth) && void 0 !== _l ? _l : 0), "rect" === this.tableGroup.border.type ? (null === (_m = this.table.theme.frameStyle) || void 0 === _m ? void 0 : _m.innerBorder) ? this.tableGroup.border.setAttributes({ x: this.table.tableX + borderLeft / 2, y: this.table.tableY + borderTop / 2, width: this.tableGroup.attribute.width - borderLeft / 2 - borderRight / 2, height: this.tableGroup.attribute.height - borderTop / 2 - borderBottom / 2 }) : this.tableGroup.border.setAttributes({ x: this.table.tableX - borderLeft / 2, y: this.table.tableY - borderTop / 2, width: this.tableGroup.attribute.width + borderLeft / 2 + borderRight / 2, height: this.tableGroup.attribute.height + borderTop / 2 + borderBottom / 2 }) : "group" === this.tableGroup.border.type && ((null === (_o = this.table.theme.frameStyle) || void 0 === _o ? void 0 : _o.innerBorder) ? (this.tableGroup.border.setAttributes({ x: this.table.tableX + borderLeft / 2, y: this.table.tableY + borderTop / 2, width: this.tableGroup.attribute.width - borderLeft / 2 - borderRight / 2, height: this.tableGroup.attribute.height - borderTop / 2 - borderBottom / 2 }), null === (_p = this.tableGroup.border.firstChild) || void 0 === _p || _p.setAttributes({ x: 0, y: 0, width: this.tableGroup.attribute.width - borderLeft / 2 - borderRight / 2, height: this.tableGroup.attribute.height - borderTop / 2 - borderBottom / 2 })) : (this.tableGroup.border.setAttributes({ x: this.table.tableX - borderLeft / 2, y: this.table.tableY - borderTop / 2, width: this.tableGroup.attribute.width + borderLeft / 2 + borderRight / 2, height: this.tableGroup.attribute.height + borderTop / 2 + borderBottom / 2 }), null === (_q = this.tableGroup.border.firstChild) || void 0 === _q || _q.setAttributes({ x: borderLeft / 2, y: borderTop / 2, width: this.tableGroup.attribute.width, height: this.tableGroup.attribute.height }))); } this.table.bottomFrozenRowCount > 0 && (this.bottomFrozenGroup.setAttribute("y", this.tableGroup.attribute.height - this.table.getBottomFrozenRowsHeight()), this.leftBottomCornerGroup.setAttributes({ visible: !0, y: this.tableGroup.attribute.height - this.table.getBottomFrozenRowsHeight(), height: this.table.getBottomFrozenRowsHeight(), width: this.table.getFrozenColsWidth() }), this.rightBottomCornerGroup.setAttributes({ visible: !0, y: this.tableGroup.attribute.height - this.table.getBottomFrozenRowsHeight(), height: this.table.getBottomFrozenRowsHeight() })), this.table.rightFrozenColCount > 0 && (this.rightFrozenGroup.setAttribute("x", this.tableGroup.attribute.width - this.table.getRightFrozenColsWidth()), this.rightTopCornerGroup.setAttributes({ visible: !0, x: this.tableGroup.attribute.width - this.table.getRightFrozenColsWidth(), width: this.table.getRightFrozenColsWidth(), height: this.table.getFrozenRowsHeight() }), this.rightBottomCornerGroup.setAttributes({ visible: !0, x: this.tableGroup.attribute.width - this.table.getRightFrozenColsWidth(), width: this.table.getRightFrozenColsWidth() })), this.updateDomContainer(); } updateRowHeight(row, detaY, skipTableHeightMap) { detaY = Math.round(detaY), updateRowHeight(this, row, detaY, skipTableHeightMap), this.updateContainerHeight(row, detaY); } updateRowsHeight(rows, detaYs, skipTableHeightMap) { for (let i = 0; i < rows.length; i++) { const row = rows[i]; if (row >= this.proxy.rowStart && row <= this.proxy.rowEnd) { const detaY = detaYs[i]; updateRowHeight(this, row, Math.round(detaY), skipTableHeightMap), this._updateContainerHeight(row, detaY); } } this.updateTableSize(), this.component.updateScrollBar(), this.updateNextFrame(); } updateContainerWidth(col, detaX) { col < this.frozenColCount ? (this.rowHeaderGroup.setDeltaWidth(detaX), this.cornerHeaderGroup.setDeltaWidth(detaX), this.colHeaderGroup.setDeltaX(detaX), this.bodyGroup.setDeltaX(detaX)) : (this.colHeaderGroup.setDeltaWidth(detaX), this.bodyGroup.setDeltaWidth(detaX)), this.updateTableSize(), this.component.updateScrollBar(), this.updateNextFrame(); } _updateContainerHeight(row, detaY) { row < this.table.frozenRowCount ? (this.colHeaderGroup.setDeltaHeight(detaY), this.cornerHeaderGroup.setDeltaHeight(detaY), this.rowHeaderGroup.setDeltaY(detaY), this.bodyGroup.setDeltaY(detaY), this.table.rightFrozenColCount && this.rightFrozenGroup.setDeltaY(detaY)) : row >= this.table.rowCount - this.table.bottomFrozenRowCount ? (this.leftBottomCornerGroup.setDeltaHeight(detaY), this.bottomFrozenGroup.setDeltaHeight(detaY), this.table.rightFrozenColCount && this.rightBottomCornerGroup.setDeltaHeight(detaY)) : (this.rowHeaderGroup.setDeltaHeight(detaY), this.bodyGroup.setDeltaHeight(detaY), this.table.rightFrozenColCount && this.rightFrozenGroup.setDeltaHeight(detaY)); } updateContainerHeight(row, detaY) { this._updateContainerHeight(row, detaY), this.updateTableSize(), this.component.updateScrollBar(), this.updateNextFrame(); } setColWidth(col, width) { const oldWidth = this.table.getColWidth(col); oldWidth !== width && (this.updateColWidth(col, width - oldWidth), this.table._clearColRangeWidthsMap(col)); } setRowHeight(row, height) { const oldHeight = this.table.getRowHeight(row); oldHeight !== height && ((row >= this.proxy.rowStart && row <= this.proxy.rowEnd || row >= this.table.rowCount - this.table.bottomFrozenRowCount && row <= this.table.rowCount - 1 || row < this.table.frozenRowCount) && this.updateRowHeight(row, height - oldHeight), this.table._clearRowRangeHeightsMap(row)); } setX(x, isEnd = !1) { this.table.scenegraph.proxy.setX(-x, isEnd); } setY(y, isEnd = !1) { this.table.scenegraph.proxy.setY(-y, isEnd); } setBodyAndRowHeaderY(y) { var _a, _b; const firstBodyColGroup = this.bodyGroup.firstChild, firstRowHeaderColGroup = this.rowHeaderGroup.firstChild, firstBodyCell = null !== (_a = null == firstBodyColGroup ? void 0 : firstBodyColGroup.firstChild) && void 0 !== _a ? _a : null == firstRowHeaderColGroup ? void 0 : firstRowHeaderColGroup.firstChild; let lastBodyCell = null !== (_b = null == firstBodyColGroup ? void 0 : firstBodyColGroup.lastChild) && void 0 !== _b ? _b : null == firstRowHeaderColGroup ? void 0 : firstRowHeaderColGroup.lastChild; lastBodyCell && "group" !== lastBodyCell.type && (lastBodyCell = lastBodyCell._prev), 0 === y && firstBodyCell && firstBodyCell.row === this.table.frozenRowCount && firstBodyCell.attribute.y + y < 0 ? y = -firstBodyCell.attribute.y : lastBodyCell && this.table.tableNoFrameHeight < this.table.getAllRowsHeight() && lastBodyCell.row === this.table.rowCount - this.table.bottomFrozenRowCount - 1 && lastBodyCell.attribute.y + this.table.getRowHeight(lastBodyCell.row) + y < this.table.tableNoFrameHeight - this.table.getFrozenRowsHeight() - this.table.getBottomFrozenRowsHeight() && (y = this.table.tableNoFrameHeight - this.table.getFrozenRowsHeight() - this.table.getBottomFrozenRowsHeight() - lastBodyCell.attribute.y - this.table.getRowHeight(lastBodyCell.row)), this.colHeaderGroup.attribute.height + y !== this.bodyGroup.attribute.y && (this.bodyGroup.setAttribute("y", this.colHeaderGroup.attribute.height + y), this.rowHeaderGroup.setAttribute("y", this.cornerHeaderGroup.attribute.height + y), this.bodySelectGroup.setAttribute("y", this.bodyGroup.attribute.y), this.rowHeaderSelectGroup.setAttribute("y", this.rowHeaderGroup.attribute.y), this.colHeaderSelectGroup.setAttribute("y", this.colHeaderGroup.attribute.y), this.cornerHeaderSelectGroup.setAttribute("y", this.cornerHeaderGroup.attribute.y), this.table.rightFrozenColCount > 0 && (this.rightFrozenGroup.setAttribute("y", this.rightTopCornerGroup.attribute.height + y), this.rightFrozenSelectGroup.setAttribute("y", this.rightFrozenGroup.attribute.y), this.rightTopCornerSelectGroup.setAttribute("y", this.rightTopCornerGroup.attribute.y)), this.table.bottomFrozenRowCount > 0 && (this.bottomFrozenSelectGroup.setAttribute("y", this.bottomFrozenGroup.attribute.y), this.leftBottomCornerSelectGroup.setAttribute("y", this.leftBottomCornerGroup.attribute.y)), this.table.rightFrozenColCount > 0 && this.table.bottomFrozenRowCount > 0 && this.rightBottomCornerSelectGroup.setAttribute("y", this.rightBottomCornerGroup.attribute.y), this.updateNextFrame()); } setBodyAndColHeaderX(x) { const firstBodyCol = this.bodyGroup.firstChild; let lastBodyCol = this.bodyGroup.lastChild; lastBodyCol && "group" !== lastBodyCol.type && (lastBodyCol = lastBodyCol._prev), 0 === x && firstBodyCol && firstBodyCol.col === this.table.frozenColCount && firstBodyCol.attribute.x + x < 0 ? x = -firstBodyCol.attribute.x : lastBodyCol && this.table.tableNoFrameWidth < this.table.getAllColsWidth() && lastBodyCol.col === this.table.colCount - this.table.rightFrozenColCount - 1 && lastBodyCol.attribute.x + lastBodyCol.attribute.width + x < this.table.tableNoFrameWidth - this.table.getFrozenColsWidth() - this.table.getRightFrozenColsWidth() && (x = this.table.tableNoFrameWidth - this.table.getFrozenColsWidth() - this.table.getRightFrozenColsWidth() - lastBodyCol.attribute.x - lastBodyCol.attribute.width), this.table.getFrozenColsWidth() + x !== this.bodyGroup.attribute.x && (this.bodyGroup.setAttribute("x", this.table.getFrozenColsWidth() + x), this.colHeaderGroup.setAttribute("x", this.table.getFrozenColsWidth() + x), this.bodySelectGroup.setAttribute("x", this.bodyGroup.attribute.x), this.colHeaderSelectGroup.setAttribute("x", this.colHeaderGroup.attribute.x), this.rowHeaderSelectGroup.setAttribute("x", this.rowHeaderGroup.attribute.x), this.cornerHeaderSelectGroup.setAttribute("x", this.cornerHeaderGroup.attribute.x), this.table.bottomFrozenRowCount > 0 && (this.bottomFrozenGroup.setAttribute("x", this.table.getFrozenColsWidth() + x), this.bottomFrozenSelectGroup.setAttribute("x", this.bottomFrozenGroup.attribute.x), this.leftBottomCornerSelectGroup.setAttribute("x", this.leftBottomCornerGroup.attribute.x)), this.table.rightFrozenColCount > 0 && (this.rightFrozenSelectGroup.setAttribute("x", this.rightFrozenGroup.attribute.x), this.rightTopCornerSelectGroup.setAttribute("x", this.rightTopCornerGroup.attribute.x)), this.table.rightFrozenColCount > 0 && this.table.bottomFrozenRowCount > 0 && this.rightBottomCornerSelectGroup.setAttribute("x", this.rightBottomCornerGroup.attribute.x), this.updateNextFrame()); } afterScenegraphCreated() { var _a, _b; this.isPivot || this.table.transpose ? this.table.options.frozenColCount ? this.component.setFrozenColumnShadow(this.table.frozenColCount - 1) : this.table.options.rightFrozenColCount ? this.component.setRightFrozenColumnShadow(this.table.colCount - this.table.rightFrozenColCount) : this.component.setFrozenColumnShadow(-1) : (this.component.setFrozenColumnShadow(this.table.frozenColCount - 1), this.component.setRightFrozenColumnShadow(this.table.colCount - this.table.rightFrozenColCount)), this.table.stateManager.checkFrozen(), this.updateContainer(), this.createFrameBorder(), this.updateBorderSizeAndPosition(), this.component.updateScrollBar(), handleTextStick(this.table), this.table.options.animationAppear && dealWithAnimationAppear(this.table), !1 === (null === (_a = this.table.options.menu) || void 0 === _a ? void 0 : _a.contextMenuWorkOnlyCell) && this.canvasShowMenu(), (null === (_b = this.table.stateManager.select.ranges) || void 0 === _b ? void 0 : _b.length) && this.recreateAllSelectRangeComponents(), this.updateNextFrame(); } dealWidthMode() { const table = this.table; if ("adaptive" === table.widthMode) { table._clearColRangeWidthsMap(); const canvasWidth = table.tableNoFrameWidth; let actualHeaderWidth = 0, startCol = 0, endCol = table.colCount; if ("only-body" === table.widthAdaptiveMode) { for (let col = 0; col < table.colCount; col++) if (col < table.rowHeaderLevelCount || table.isPivotChart() && col >= table.colCount - table.rightFrozenColCount) { actualHeaderWidth += table.getColWidth(col); } startCol = table.rowHeaderLevelCount, endCol = table.isPivotChart() ? table.colCount - table.rightFrozenColCount : table.colCount; } getAdaptiveWidth(canvasWidth - actualHeaderWidth, startCol, endCol, !1, [], table, !0); } else if (table.autoFillWidth) {