UNPKG

@antv/s2

Version:

effective spreadsheet render core lib

61 lines 3.45 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getOccupiedWidthForTableCol = exports.getExtraPaddingForExpandIcon = exports.getTableColIconsWidth = void 0; const lodash_1 = require("lodash"); const constant_1 = require("../../common/constant"); const header_cell_1 = require("./header-cell"); const getTableColIconsWidth = (s2, meta, cellType, iconStyle) => { var _a, _b; const iconSize = iconStyle === null || iconStyle === void 0 ? void 0 : iconStyle.size; const iconMargin = iconStyle === null || iconStyle === void 0 ? void 0 : iconStyle.margin; let iconCount = 0; if (s2.options.showDefaultHeaderActionIcon) { iconCount = 1; } else { iconCount = (_b = (_a = (0, header_cell_1.getActionIconConfig)(s2.options.headerActionIcons, meta, cellType)) === null || _a === void 0 ? void 0 : _a.icons.length) !== null && _b !== void 0 ? _b : 0; } return (iconCount * (iconSize + iconMargin.left) + (iconCount > 0 ? iconMargin.right : 0)); }; exports.getTableColIconsWidth = getTableColIconsWidth; const getExtraPaddingForExpandIcon = (s2, field, style) => { var _a, _b, _c, _d; const iconMarginLeft = ((_b = (_a = style.icon) === null || _a === void 0 ? void 0 : _a.margin) === null || _b === void 0 ? void 0 : _b.left) || 0; const iconMarginRight = ((_d = (_c = style.icon) === null || _c === void 0 ? void 0 : _c.margin) === null || _d === void 0 ? void 0 : _d.right) || 0; const hiddenColumnsDetail = s2.store.get('hiddenColumnsDetail', []); let hasPrevSiblingCell = false; let hasNextSiblingCell = false; hiddenColumnsDetail.forEach((column) => { var _a, _b, _c, _d; if (((_b = (_a = column === null || column === void 0 ? void 0 : column.displaySiblingNode) === null || _a === void 0 ? void 0 : _a.prev) === null || _b === void 0 ? void 0 : _b.field) === field) { hasPrevSiblingCell = true; } if (((_d = (_c = column === null || column === void 0 ? void 0 : column.displaySiblingNode) === null || _c === void 0 ? void 0 : _c.next) === null || _d === void 0 ? void 0 : _d.field) === field) { hasNextSiblingCell = true; } }); const iconSize = (0, lodash_1.get)(style, 'icon.size'); // 图标本身宽度 + 主题配置的 icon margin return { left: hasNextSiblingCell ? iconSize + iconMarginRight : 0, right: hasPrevSiblingCell ? iconSize + iconMarginLeft : 0, }; }; exports.getExtraPaddingForExpandIcon = getExtraPaddingForExpandIcon; const getOccupiedWidthForTableCol = (s2, meta, style) => { var _a, _b; const padding = (0, lodash_1.get)(style, 'cell.padding'); const horizontalBorderWidth = (_b = (_a = style === null || style === void 0 ? void 0 : style.cell) === null || _a === void 0 ? void 0 : _a.horizontalBorderWidth) !== null && _b !== void 0 ? _b : 1; const expandIconPadding = (0, exports.getExtraPaddingForExpandIcon)(s2, meta.field, style); const iconsWidth = (0, exports.getTableColIconsWidth)(s2, meta, constant_1.CellType.COL_CELL, style === null || style === void 0 ? void 0 : style.icon); return (padding.left + padding.right + iconsWidth + expandIconPadding.left + expandIconPadding.right + horizontalBorderWidth); }; exports.getOccupiedWidthForTableCol = getOccupiedWidthForTableCol; //# sourceMappingURL=table-col-cell.js.map