UNPKG

@antv/s2

Version:

effective spreadsheet render core lib

55 lines 2.59 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TableColCell = void 0; const lodash_1 = require("lodash"); const col_cell_1 = require("../cell/col-cell"); const constant_1 = require("../common/constant"); const header_cell_1 = require("../utils/cell/header-cell"); const g_renders_1 = require("../utils/g-renders"); const sort_action_1 = require("../utils/sort-action"); class TableColCell extends col_cell_1.ColCell { handleRestOptions(...[headerConfig]) { this.headerConfig = Object.assign({}, headerConfig); const { field } = this.meta; const sortParams = this.spreadsheet.dataCfg.sortParams; const sortParam = (0, lodash_1.find)(sortParams, (item) => (item === null || item === void 0 ? void 0 : item.sortFieldId) === field); const type = (0, sort_action_1.getSortTypeIcon)(sortParam, true); this.headerConfig.sortParam = Object.assign(Object.assign(Object.assign({}, this.headerConfig.sortParam), (sortParam || {})), { type }); } getFormattedFieldValue() { return (0, header_cell_1.formattedFieldValue)(this.meta, this.spreadsheet.dataSet.getFieldName(this.meta.field)); } isSortCell() { return true; } showSortIcon() { const { extra } = this.meta; const { options } = this.spreadsheet; const { showDefaultHeaderActionIcon } = options; if (!(extra === null || extra === void 0 ? void 0 : extra.isCustomNode)) { return showDefaultHeaderActionIcon; } // 自定义列头时, 只在叶子节点展示 return showDefaultHeaderActionIcon && this.meta.isLeaf; } getTextStyle() { var _a; const textOverflowStyle = this.getCellTextWordWrapStyle(); const style = (_a = this.getStyle()) === null || _a === void 0 ? void 0 : _a.bolderText; return Object.assign(Object.assign({}, textOverflowStyle), style); } getHorizontalResizeAreaName() { return `${constant_1.HORIZONTAL_RESIZE_AREA_KEY_PRE}${this.meta.id}`; } drawBackgroundShape() { const { backgroundColor, backgroundColorOpacity } = this.getStyle().cell || {}; this.backgroundShape = (0, g_renders_1.renderRect)(this, Object.assign(Object.assign({}, this.getBBoxByType()), { fill: backgroundColor, fillOpacity: backgroundColorOpacity })); } drawTextOrCustomRenderer() { // 明细表列头仅允许文本 this.drawTextShape(); this.afterDrawText(); } } exports.TableColCell = TableColCell; //# sourceMappingURL=table-col-cell.js.map