UNPKG

@antv/s2

Version:

effective spreadsheet render core lib

205 lines (204 loc) 8.81 kB
import type { DisplayObject, Image, Line, PointLike, Polygon, Rect, Text, TextStyleProps } from '@antv/g'; import { Group } from '@antv/g'; import { CellType, InteractionStateName } from '../common/constant'; import type { GuiIcon } from '../common/icons/gui-icon'; import { CellBorderPosition, CellClipBox, type CellTextWordWrapStyle, type Condition, type ConditionMappingResult, type Conditions, type ContentPositionParams, type FormatResult, type HeaderActionNameOptions, type IconPosition, type InternalFullyCellTheme, type InternalFullyTheme, type RenderTextShapeOptions, type ResizeArea, type ResizeInteractionOptions, type S2CellType, type SimpleData, type StateShapeLayer, type TextTheme } from '../common/interface'; import type { SimpleBBox } from '../engine'; import type { CustomText } from '../engine/CustomText'; import type { SpreadSheet } from '../sheet-type'; import { type GroupedIcons } from '../utils/cell/header-cell'; export declare abstract class BaseCell<T extends SimpleBBox> extends Group { protected meta: T; protected spreadsheet: SpreadSheet; protected theme: InternalFullyTheme; protected backgroundShape: Rect | Polygon | Image; protected textShape: CustomText; protected textShapes: CustomText[]; protected linkFieldShape: Line; protected get actualText(): string; protected originalText: SimpleData; protected conditions: Conditions; protected conditionIntervalShape: Rect | undefined; protected conditionIconShape: GuiIcon; protected conditionIconShapes: GuiIcon[]; protected groupedIcons: GroupedIcons; protected stateShapes: Map<StateShapeLayer, DisplayObject<any, any>>; /** * Return the type of the cell */ abstract get cellType(): CellType; /** * Determine how to render this cell area */ protected abstract initCell(): void; /** * Update cell's selected state */ abstract update(): void; protected abstract getBorderPositions(): CellBorderPosition[]; protected abstract getTextStyle(): TextTheme & CellTextWordWrapStyle; protected abstract getFormattedFieldValue(): FormatResult; abstract getMaxTextWidth(): number; protected abstract afterDrawText(): void; protected abstract getTextPosition(): PointLike; abstract getContentPosition(options?: ContentPositionParams): PointLike; protected abstract getIconPosition(): PointLike; protected abstract findFieldCondition<Con extends Condition>(conditions?: Con[]): Con | undefined; protected abstract mappingValue<Result>(condition: Condition<Result>): ConditionMappingResult<Result>; protected abstract getBackgroundColor(): { backgroundColor: string | undefined; backgroundColorOpacity: number | undefined; intelligentReverseTextColor: boolean; }; abstract getMetaField(): string; constructor(meta: T, spreadsheet: SpreadSheet, ...restOptions: unknown[]); /** * in case there are more params to be handled * @param options any type's rest params */ protected handleRestOptions(...options: unknown[]): void; protected getResizedTextMaxLines(): number | void; getMeta(): T; setMeta(viewMeta: T): void; getIconStyle(): import("../common/interface").DeepRequired<import("../common/interface").IconTheme>; isShallowRender(): boolean; getCellTextWordWrapStyle(cellType?: CellType): CellTextWordWrapStyle; /** * 获取实际渲染的文本 (含省略号) */ getActualText(): string; /** * 实际渲染的文本宽度, 如果是多行文本, 取最大的一行宽度 */ getActualTextWidth(): number; /** * 实际渲染的文本宽度, 如果是多行文本, 取每一行文本高度的总和 * @alias getMultiLineActualTextHeight */ getActualTextHeight(): number; /** * 获取实际渲染的多行文本 (含省略号) */ getMultiLineActualTexts(): string[]; /** * 实际渲染的多行文本宽度 (每一行文本宽度的总和) */ getMultiLineActualTextWidth(): number; /** * 实际渲染的多行文本高度 (每一行文本高度的总和) * @alias getActualTextHeight */ getMultiLineActualTextHeight(): number; /** * 获取原始的文本 (不含省略号) */ getOriginalText(): SimpleData; /** * 文本是否溢出 (有省略号) */ isTextOverflowing(): boolean; /** * 是否是多行文本 */ isMultiLineText(): boolean; /** * 获取文本包围盒 */ getTextLineBoundingRects(): import("@antv/g").Rectangle[]; /** * 获取文本行高 */ getTextLineHeight(): number; /** * 获取单元格空值占位符 */ getEmptyPlaceholder(): string | null | undefined; /** * 获取单元格展示的数值 */ getFieldValue(): SimpleData; protected shouldInit(): boolean; getStyle<K extends keyof InternalFullyTheme = CellType>(name?: K): InternalFullyTheme[K] | InternalFullyCellTheme; getLinkFieldShape(): Line; getBackgroundShape(): Image | Rect | Polygon; getStateShapes(): Map<StateShapeLayer, DisplayObject<any, any>>; protected getResizeAreaStyle(): ResizeArea; protected shouldDrawResizeAreaByType(type: keyof ResizeInteractionOptions, cell: S2CellType): number | boolean | "selected" | "all" | "current" | ((cell: S2CellType) => boolean) | ((resizeInfo: import("../common/interface").ResizeInfo) => boolean) | undefined; getBBoxByType(type?: CellClipBox): SimpleBBox; drawBorders(): void; /** * 绘制 hover 悬停,刷选的外框 */ protected drawInteractiveBorderShape(): void; /** * 交互使用的背景色 */ protected drawInteractiveBgShape(): void; protected drawBackgroundShape(): void; renderTextShape(style: TextStyleProps, options?: RenderTextShapeOptions): CustomText; updateTextPosition(position?: PointLike): void; drawTextOrCustomRenderer(): void; drawTextShape(): void; protected drawLinkFieldShape(showLinkFieldShape: boolean, linkFillColor: string): void; protected getLinkFieldStyle(): string; protected drawLinkField(meta: T): void; updateByState(stateName: `${InteractionStateName}`, cell: S2CellType): void; protected getInteractiveBorderShapeStyle<T>(borderSize: T & number): { x: number; y: number; width: number; height: number; }; hideInteractionShape(): void; clearUnselectedState(): void; getTextShape(): CustomText; getTextShapes(): CustomText[]; addTextShape(textShape: CustomText | Text): void; getConditionIconShape(): GuiIcon; getConditionIconShapes(): GuiIcon[]; addConditionIconShape(iconShape: GuiIcon): void; resetTextAndConditionIconShapes(): void; get cellConditions(): Conditions; drawConditionIconShapes(): void; getTextConditionMappingResult(): ConditionMappingResult<TextTheme>; getContainConditionMappingResultTextStyle(style: TextTheme | undefined): { fill: string; fontSize?: number | undefined; linkTextFill?: string | undefined; textAlign?: import("../common/interface").TextAlign | undefined; textBaseline?: import("../common/interface").TextBaseline | undefined; opacity?: string | number | undefined; fontFamily?: string | undefined; fontWeight?: number | "bold" | import("@antv/g-lite/types/css").CSSGlobalKeywords | "normal" | "bolder" | "lighter" | undefined; fontStyle?: import("@antv/g-lite/types/css").CSSGlobalKeywords | "normal" | "italic" | "oblique" | undefined; fontVariant?: string | undefined; lineHeight?: string | number | undefined; }; /** * 获取默认字体颜色:根据字段标记背景颜色,设置字体颜色 * @param textStyle * @private */ protected getDefaultTextFill(textFill: string): string; getBackgroundConditionFill(): { backgroundColor: string; backgroundColorOpacity: number; intelligentReverseTextColor: boolean; } | { intelligentReverseTextColor: boolean; backgroundColor?: undefined; backgroundColorOpacity?: undefined; }; getIconConditionResult(): HeaderActionNameOptions | undefined; protected getActionAndConditionIconWidth(position?: IconPosition): number; protected getCrossBackgroundColor(rowIndex: number): { backgroundColorOpacity: number; backgroundColor: string; }; getMaxLinesByCustomHeight(options: { targetCell?: S2CellType; displayHeight?: number; isCustomHeight?: boolean; }): number | undefined; getRenderer(): import("../common/interface").CustomRendererConfig | undefined; }