UNPKG

@antv/s2

Version:

effective spreadsheet render core lib

117 lines 5.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TableDataCell = void 0; const data_cell_1 = require("../cell/data-cell"); const constant_1 = require("../common/constant"); const engine_1 = require("../engine"); const utils_1 = require("../facet/utils"); const resize_1 = require("../utils/interaction/resize"); class TableDataCell extends data_cell_1.DataCell { getLinkFieldStyle() { return this.theme.rowCell.text.linkTextFill; } getTextStyle() { // 此逻辑不能放到seriesNumberCell中,否则在单元格复用场景下会导致文本样式错误 if (this.meta.valueField === constant_1.SERIES_NUMBER_FIELD) { const textOverflowStyle = this.getCellTextWordWrapStyle(constant_1.CellType.SERIES_NUMBER_CELL); const style = this.theme.rowCell.seriesText; return Object.assign(Object.assign({}, textOverflowStyle), style); } return super.getTextStyle(); } shouldDrawResizeArea() { // 每一行直绘制一条贯穿式 resize 热区 const id = `${this.meta.rowIndex}`; const resizeArea = (0, resize_1.getOrCreateResizeAreaGroupById)(this.spreadsheet, constant_1.KEY_GROUP_ROW_RESIZE_AREA); return !(resizeArea === null || resizeArea === void 0 ? void 0 : resizeArea.getElementById(id)); } drawResizeArea() { if (!this.shouldDrawResizeArea()) { return; } const resizeArea = (0, resize_1.getOrCreateResizeAreaGroupById)(this.spreadsheet, constant_1.KEY_GROUP_ROW_RESIZE_AREA); if (!resizeArea) { return; } const { rowIndex } = this.getMeta(); const cellRange = this.spreadsheet.facet.getCellRange(); const { rowCount, trailingRowCount } = this.spreadsheet.facet.getFrozenOptions(); const isFrozenHead = (0, utils_1.isFrozenRow)(rowIndex, cellRange.start, rowCount); const isFrozenTrailing = (0, utils_1.isFrozenTrailingRow)(rowIndex, cellRange.end, trailingRowCount); const isFrozen = isFrozenHead || isFrozenTrailing; const { y, height } = this.getBBoxByType(); const { x: panelBBoxX, y: panelBBoxY, viewportWidth, viewportHeight, } = this.spreadsheet.facet.panelBBox; const { scrollY } = this.spreadsheet.facet.getScrollOffset(); const paginationSy = this.spreadsheet.facet.getPaginationScrollY(); const frozenGroupAreas = this.spreadsheet.facet .frozenGroupAreas; const frozenRowGroup = frozenGroupAreas[constant_1.FrozenGroupArea.Row]; const frozenTrailingRowGroup = frozenGroupAreas[constant_1.FrozenGroupArea.TrailingRow]; const resizeStyle = this.getResizeAreaStyle(); const width = panelBBoxX + viewportWidth; const resizeClipAreaBBox = { x: 0, y: isFrozen ? 0 : frozenRowGroup.height, width, height: isFrozen ? Number.POSITIVE_INFINITY : viewportHeight - frozenRowGroup.height - frozenTrailingRowGroup.height, }; const resizeAreaBBox = { x: 0, y: y + height - resizeStyle.size, width, height: resizeStyle.size, }; if (!(0, resize_1.shouldAddResizeArea)(resizeAreaBBox, resizeClipAreaBBox, { scrollX: 0, scrollY: isFrozen ? 0 : paginationSy + scrollY, })) { return; } let offsetY = panelBBoxY; if (isFrozenHead) { offsetY += y - frozenRowGroup.y; } else if (isFrozenTrailing) { offsetY += viewportHeight - frozenTrailingRowGroup.height + y - frozenTrailingRowGroup.y; } else { offsetY += y - paginationSy - scrollY; } const attrs = (0, resize_1.getResizeAreaAttrs)({ theme: resizeStyle, type: constant_1.ResizeDirectionType.Vertical, effect: constant_1.ResizeAreaEffect.Cell, offsetX: 0, offsetY, width, height, meta: this.meta, cell: this, }); resizeArea.appendChild(new engine_1.CustomRect({ style: Object.assign(Object.assign({}, attrs.style), { x: 0, y: offsetY + height - resizeStyle.size, width }), }, attrs.appendInfo)); } isDisableHover(cellMeta) { return (cellMeta === null || cellMeta === void 0 ? void 0 : cellMeta.type) === constant_1.CellType.COL_CELL; } getResizedTextMaxLines() { var _a, _b, _c, _d, _e; const { facet, options } = this.spreadsheet; const { rowCell } = options.style; const { id, rowId, rowIndex } = this.meta; return ((_d = (_b = (_a = rowCell === null || rowCell === void 0 ? void 0 : rowCell.maxLinesByField) === null || _a === void 0 ? void 0 : _a[id]) !== null && _b !== void 0 ? _b : (_c = rowCell === null || rowCell === void 0 ? void 0 : rowCell.maxLinesByField) === null || _c === void 0 ? void 0 : _c[rowId]) !== null && _d !== void 0 ? _d : this.getMaxLinesByCustomHeight({ isCustomHeight: (_e = facet === null || facet === void 0 ? void 0 : facet.customRowHeightStatusMap) === null || _e === void 0 ? void 0 : _e[rowIndex], })); } } exports.TableDataCell = TableDataCell; //# sourceMappingURL=table-data-cell.js.map