UNPKG

@antv/s2

Version:

effective spreadsheet render core lib

53 lines (52 loc) 2.19 kB
import type { LineStyleProps } from '@antv/g'; import { CellBorderPosition, CellClipBox, type CellTheme, type IconTheme, type TextAlign, type TextBaseline } from '../../common/interface'; import type { SimpleBBox } from '../../engine'; import { type GroupedIcons } from './header-cell'; /** * text 和 icon 之间布局关系: * y轴: text 和 icon 高度上居中对齐 * x轴: * 1. text 和 icon 同为 left 或者 right 时,icon bbox 只需要简单放置在 left 或者 right 即可 * 2. 其他的情况,需要根据实际 text width 确定 icon bbox 开始位置 */ export declare const getVerticalTextPosition: (bbox: SimpleBBox, textBaseline: TextBaseline) => number; export declare const getVerticalIconPosition: (iconSize: number, textY: number, textFontSize: number, textBaseline: TextBaseline) => number; export declare const getHorizontalTextIconPosition: (options: { bbox: SimpleBBox; textWidth: number; textAlign: TextAlign; groupedIcons: GroupedIcons; iconStyle: IconTheme; isCustomRenderer?: boolean; }) => { textX: number; leftIconX: number; rightIconX: number; }; /** * 类似 background-clip 属性: https://developer.mozilla.org/en-US/docs/Web/CSS/background-clip * 分为三种类型: * borderBox: 整个 cell 的范围 * paddingBox: cell 去除 border 的范围 * contentBox: cell 去除 (border + padding) 的范围 * ------------------------------- * |b| padding | * |o| |---------------------| | * |r| | | | * |d| | | | * |e| |---------------------| | * |r| padding | * ------------------------------- * -------border-bottom----------- * ------------------------------- */ export declare const getCellBoxByType: (bbox: SimpleBBox, borderPositions: CellBorderPosition[], cellStyle: CellTheme, boxType: CellClipBox) => SimpleBBox; export declare const getBorderPositionAndStyle: (position: CellBorderPosition, bbox: SimpleBBox, style: CellTheme) => { position: { x1: number; x2: number; y1: number; y2: number; }; style: Partial<LineStyleProps>; };