UNPKG

@antv/s2

Version:

effective spreadsheet render core lib

69 lines 2.92 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GridGroup = void 0; const tslib_1 = require("tslib"); const g_1 = require("@antv/g"); const lodash_1 = require("lodash"); const constant_1 = require("../common/constant"); const g_renders_1 = require("../utils/g-renders"); class GridGroup extends g_1.Group { constructor(cfg) { const { name, s2 } = cfg, rest = tslib_1.__rest(cfg, ["name", "s2"]); super({ name, style: rest, }); this.gridInfo = { cols: [], rows: [], }; this.updateGrid = (gridInfo, id = constant_1.KEY_GROUP_GRID_GROUP) => { var _a, _b; if (!this.gridGroup || !this.getElementById(id)) { this.gridGroup = this.appendChild(new g_1.Group({ id, style: { zIndex: constant_1.PANEL_GRID_GROUP_Z_INDEX, }, })); } else { this.gridGroup.removeChildren(); } const width = (_a = (0, lodash_1.last)(gridInfo.cols)) !== null && _a !== void 0 ? _a : 0; const height = (_b = (0, lodash_1.last)(gridInfo.rows)) !== null && _b !== void 0 ? _b : 0; const { theme } = this.s2; const style = theme.dataCell.cell; const verticalBorderWidth = style === null || style === void 0 ? void 0 : style.verticalBorderWidth; this.gridInfo = gridInfo; const halfVerticalBorderWidthBorderWidth = verticalBorderWidth / 2; this.gridInfo.cols.forEach((x) => { (0, g_renders_1.renderLine)(this.gridGroup, { x1: x - halfVerticalBorderWidthBorderWidth, x2: x - halfVerticalBorderWidthBorderWidth, y1: 0, y2: height, stroke: style.verticalBorderColor, strokeOpacity: style.verticalBorderColorOpacity, lineWidth: verticalBorderWidth, }); }); const horizontalBorderWidth = style === null || style === void 0 ? void 0 : style.horizontalBorderWidth; const halfHorizontalBorderWidth = horizontalBorderWidth / 2; this.gridInfo.rows.forEach((y) => { (0, g_renders_1.renderLine)(this.gridGroup, { x1: 0, x2: width, y1: y - halfHorizontalBorderWidth, y2: y - halfHorizontalBorderWidth, stroke: style.horizontalBorderColor, strokeOpacity: style.horizontalBorderColorOpacity, lineWidth: horizontalBorderWidth, }); }); }; this.s2 = s2; } } exports.GridGroup = GridGroup; //# sourceMappingURL=grid-group.js.map