import type { Theme } from './theme'; /** horizontal align constants for cell style */ export type HorizontalAlign = '' | 'left' | 'center' | 'right'; /** vertical align constants for cell style */ export type VerticalAlign = '' | 'top' | 'bottom' | 'middle'; export type ThemeColorType = 'Background' | 'Text' | 'Background2' | 'Text2' | 'Accent' | 'Accent2' | 'Accent3' | 'Accent4' | 'Accent5' | 'Accent6'; export declare const ThemeColorIndex: (color: ThemeColor) => number; /** * font size for cell style. we generally prefer relative sizes * (percent or em) because they are relative to the default theme * size, which might be different on different platforms. */ export interface FontSize { unit: 'pt' | 'px' | 'em' | '%'; value: number; } export interface HTMLColor { text: string; /** @internal */ offset?: Color; } export interface ThemeColor { theme: number | ThemeColorType; tint?: number; /** @internal */ offset?: Color; } export interface NullColor { /** @internal */ offset?: Color; } export type Color = ThemeColor | HTMLColor | NullColor; export declare const IsHTMLColor: (color?: Color) => color is HTMLColor; export declare const IsThemeColor: (color?: Color) => color is ThemeColor; export declare const IsDefinedColor: (color?: Color) => color is (ThemeColor | HTMLColor); /** @internal */ export interface CompositeBorderEdge { width: number; color: Color; } /** @internal */ export interface CompositeBorder { top: CompositeBorderEdge; left: CompositeBorderEdge; right: CompositeBorderEdge; bottom: CompositeBorderEdge; } /** * style properties applied to a single cell, row, column, or sheet. * when rendering a cell, we composite all styles that might apply. */ export interface CellStyle { /** horizontal align defaults to left */ horizontal_align?: HorizontalAlign; /** vertical align defaults to bottom */ vertical_align?: VerticalAlign; /** representation for NaN */ nan?: string; /** number format, either a symbolic name like "General" or a format string */ number_format?: string; /** wrap text */ wrap?: boolean; /** * font size. we recommend using relative font sizes (either % or em) * which will be relative to the theme font size. */ font_size?: FontSize; /** font face. this can be a comma-delimited list, like CSS */ font_face?: string; /** flag */ bold?: boolean; /** flag */ italic?: boolean; /** flag */ underline?: boolean; /** flag */ strike?: boolean; /** border weight */ border_top?: number; /** border weight */ border_right?: number; /** border weight */ border_left?: number; /** border weight */ border_bottom?: number; /** text color */ text?: Color; /** background color */ fill?: Color; /** border color */ border_top_fill?: Color; /** border color */ border_left_fill?: Color; /** border color */ border_right_fill?: Color; /** border color */ border_bottom_fill?: Color; /** text indent */ indent?: number; /** * cell is locked for editing * * @privateRemarks * * this should properly be in cell, not style -- but we keep * it here so it can cascade like other styles. * */ locked?: boolean; } /** * @internal * * starting on data bars, but there might be other conditional * stuff we want to tack on to standard styles. * */ export type ExtendedCelLStyle = CellStyle & { databar?: { fill: Color; negative?: Color; hide_values?: boolean; value: number; zero: number; }; }; /** @internal */ export type PropertyKeys = keyof CellStyle; /** * (finally) removing the old namespace. we keep this object around for * some internal methods, but all the types have moved to the top-level * of this module and need to be imported separately. * * we could theoretically build a backcompat module that re-exports all * the types, but it's probably not necessary -- most updates will just * require a find-and-replace (plus adding some imports). * * @internal */ export declare const Style: { /** * note that there are no default colors; those should be set * in grid when style is applied. that way the default colors for * border, text and background colors will be theme-dependent and * can change. * * @internal */ DefaultProperties: CellStyle; /** * this is a utility function for callers that use borders, to * reduce testing and facilitate reusable methods * * @internal */ CompositeBorders: (style: CellStyle) => CompositeBorder; Serialize: (style: CellStyle) => string; /** * merge. returns a new object, does not update dest in place. * NOTE: if it does not update dest in place, then what would be * the use case for a non-delta merge? (...) * * @internal */ Merge: (dest: CellStyle, src: CellStyle, delta?: boolean) => CellStyle; /** @internal */ Composite: (list: CellStyle[]) => CellStyle; /** @internal */ Empty: (style: CellStyle) => boolean; /** @internal */ ParseFontSize: (text?: string, default_unit?: string) => CellStyle; /** * returns the font size of the properties argument as a ratio of the * base argument. this is intended to show the relative font size of * a spreadsheet cell; so anything with no value should be "1", and * everything else is relative to that. * * we prefer relative sizes (em, essentially) to fixed sizes because * we may have different base font sizes on different platforms (we do, * in fact, on windows because calibri is too small). * * using relative sizes helps ensure that it looks similar, if not * identical, on different platforms. * * @internal */ RelativeFontSize: (properties: CellStyle, base: CellStyle) => number; /** * @internal */ FontSize: (properties: CellStyle, prefer_points?: boolean) => string; /** * @internal * * generate a font size based on a base size (hopefully in actual units) * and a relative size (em, %, or possibly a static unit). also optionally * apply a scale. * */ CompositeFontSize: (base: FontSize, relative: FontSize, scale?: number, prefer_points?: boolean) => FontSize; /** * return a font string suitable for canvas. because our font sizes are * (probably) in ems, we need a base size to bounce off. */ CompositeFont: (base: FontSize, properties: CellStyle, scale: number, theme: Theme) => { font: string; variants: string | undefined; base: FontSize; size: FontSize | undefined; scale: number; stack_size: FontSize | undefined; font_size: FontSize | undefined; }; };