UNPKG

@sheetxl/models

Version:

Models - A Headless javascript spreadsheet library.

191 lines 8.91 kB
import { Size, Rectangle, RemoveListener, Bounds, CellCoords, CellRangeCoords } from "@sheetxl/common"; import { SerializableProperties } from "../primitives"; import { AdjustedColor, SchemeColorLookup, IndexedColorLookup } from "../color"; import { ExtendedTextMetrics } from "../font/FontUtils"; import { IDocTheme } from "../theme"; import { INoneFill, IGradientFill, ISolidFill, IPatternFill, SolidFillValues, GradientFillValues, PatternFillValues, NoneFillValues, FillType, GradientStop, GradientType, SheetPatternType } from "./IFill"; import { CellBorderValues, ICellBorder } from "./ICellBorder"; import { ICellAlignment } from "./ICellAlignment"; import { ICellProtection } from "./ICellProtection"; import { IFont } from "./IFont"; import { ICellStyle, CellStyleValues, NamedCellStyleUpdate, INamedCellStyleUpdater, CellStyleUpdate, SerializableCellStyleValues, ICellStyleUpdater, ISharedCellStyle, INamedCellStyle } from "./ICellStyle"; import { ITableStyle, SerializableTableStyleValues } from "./ITableStyle"; import { ISheetStyleListener, IStylesPersistScope, SheetStyleJSON, ISheetStyle } from "./ISheetStyle"; declare class StyleValueDecorator<V> { protected _overrides: Partial<V>; protected _delegate: V; protected _isEmpty: boolean; constructor(overrides: Partial<V>, delegate: V); protected _value(field: string): any; isEmpty(): boolean; toJSON(): SerializableProperties<V>; } declare class NoneFill extends StyleValueDecorator<NoneFillValues> implements INoneFill { get fillType(): FillType.None; asCSS(_darkMode?: boolean): React.CSSProperties; toJSON(): SerializableProperties<SolidFillValues>; } declare class SolidFill extends StyleValueDecorator<SolidFillValues> implements ISolidFill { get fillType(): FillType.Solid; get color(): AdjustedColor; asCSS(darkMode?: boolean): React.CSSProperties; toJSON(): SerializableProperties<SolidFillValues>; } declare class GradientFill extends StyleValueDecorator<GradientFillValues> implements IGradientFill { get fillType(): FillType.Gradient; get stops(): GradientStop[]; get gradientType(): GradientType; get angle(): number; get fillTo(): Rectangle; asCSS(darkMode?: boolean, bounds?: Bounds): React.CSSProperties; toJSON(): SerializableProperties<GradientFillValues>; } declare class PatternFill extends StyleValueDecorator<PatternFillValues> implements IPatternFill { get fillType(): FillType.Pattern; get background(): AdjustedColor; get foreground(): AdjustedColor; get patternType(): SheetPatternType; asCSS(darkMode?: boolean): React.CSSProperties; toJSON(): SerializableProperties<PatternFillValues>; } declare class DecoratingCellStyle implements ICellStyle { protected _overrides: Partial<ICellStyle>; protected _delegate: Partial<ICellStyle>; protected _bestFitSize: Partial<Size>; protected _insets: Rectangle; protected _hasEmptyStyling: boolean; constructor(overrides: Partial<ICellStyle>, delegate: Partial<ICellStyle>); toJSON(): SerializableCellStyleValues; hasEmptyStyling(): boolean; get isCellStyle(): true; /** * storybook is giving runtime exception. with readonly abstract. */ get namedStyleRef(): INamedCellStyle; measureText(text: string, size?: number, family?: string): ExtendedTextMetrics; /** * Returns the best fit size assuming no content. * By default this only returns a height */ bestFitSize(): Partial<Size> | null; insets(): Rectangle; isNamed(): boolean; get namedStyle(): string; protected _value(field: string): any; get font(): IFont; get fill(): SolidFill | GradientFill | NoneFill | PatternFill; get alignment(): ICellAlignment; get border(): ICellBorder; get protection(): ICellProtection; get numberFormat(): string; get quotePrefix(): boolean; } declare class SharedCellStyle extends DecoratingCellStyle implements ISharedCellStyle { private _namedStyleRef; private _stateAsString; constructor(overrides: Partial<ICellStyle>, delegate: INamedCellStyle, stateAsString: string); get namedStyle(): string; get isSharedCellStyle(): true; get namedStyleRef(): INamedCellStyle; get stateAsString(): string; isNamed(): boolean; } interface SharedCellStyleState { stateAsString: string; state: Partial<CellStyleValues>; style: SharedCellStyle; refCount: number; } /** * Base implementation of @see {@link ISheetStyle} * * TODO - defaultFontSize move to theme? * */ declare class SheetStyle implements ISheetStyle { private _listeners; private _docTheme; private _defaultFontSize; private _schemeLookup; private _indexedColorLookup; private _builtInsCellStyleMap; private _customCellStyleMap; private _builtInsTableStyleMap; private _customTableStyleMap; private _indexedColors; private _mruColors; private _statesByString; private _statesByStyle; private _statesByRef; private _normalStyle; private _context; private _defaultTableStyle; private _emptyState; private _emptyStyle; private _persistCache; private _registry; constructor(docTheme?: IDocTheme, indexedColors?: string[], defaultFontSize?: number); private _initializeNamedCellStyles; private _initializeTableStyles; private _initializeBuiltIns; getNormalStyle(): INamedCellStyle; /** * Will fire a change event * @param docTheme */ setTheme(docTheme: IDocTheme): void; getTheme(): IDocTheme; setDefaultFontSize(fontSize: number): void; getDefaultFontSize(): number; getSharedStyle(adjustment: CellStyleUpdate | ICellStyleUpdater, original: ICellStyle, ref: any): ICellStyle; private _addSharedStateRef; private _getSharedStyleInternal; addSharedStyleRef(style: ICellStyle, ref: any): ICellStyle; _releaseSharedState(state: SharedCellStyleState): void; _releaseSharedStyles(ref: any): void; beginPersist(): IStylesPersistScope; getNamedCellStyle(name: string): INamedCellStyle; getBuiltInCellStyle(key: string | number): INamedCellStyle; getCustomCellStyles(): INamedCellStyle[]; setCustomCellStyle(name: string, style: NamedCellStyleUpdate | INamedCellStyleUpdater | ICellStyle, mergeIfExists?: boolean): INamedCellStyle; protected _setCustomCellStyleInternal(name: string, adjustment: NamedCellStyleUpdate | INamedCellStyleUpdater | ICellStyle, mergeIfExists?: boolean, _i?: number | null): INamedCellStyle; protected _createTableStyle(name: string, tableStyleValues: SerializableTableStyleValues, _original: ITableStyle): ITableStyle; protected _setCustomTableStyleInternal(name: string, tableStyleValues: SerializableTableStyleValues): ITableStyle; removeCustomCellStyle(style: INamedCellStyle | string): boolean; hideOrRemoveNamedCellStyle(style: INamedCellStyle | string): boolean; getTableStyle(name: string): ITableStyle | null; getBuiltInTableStyle(key: string): ITableStyle; getCustomTableStyles(): ITableStyle[]; setDefaultTableStyle(styleName: string): boolean; getDefaultTableStyle(): ITableStyle; removeCustomTableStyle(styleName: string): boolean; setCustomTableStyle(name: string, tableStyleValues: SerializableTableStyleValues): ITableStyle; private notifyTableStylesChange; private notifyNamedStylesChange; private notifyThemeChange; private notifyDefaultFontChange; normalizeBorder(original: SerializableProperties<CellBorderValues>, coords: CellCoords, range: CellRangeCoords): SerializableProperties<CellBorderValues>; createTemporaryStyle(adjustment: CellStyleUpdate | ICellStyleUpdater, original: ICellStyle): ICellStyle; validateStyleName(name: string, checkDuplicates?: boolean): void; normalize(values: SerializableCellStyleValues): Partial<CellStyleValues>; schemeLookup(): SchemeColorLookup; indexedColorLookup(): IndexedColorLookup; /** * Parses the color using the Theme being used by this style * @param str */ resolveColor(str: string): AdjustedColor; recentColors(): readonly AdjustedColor[]; addRecentColor(color: AdjustedColor): readonly AdjustedColor[]; clearRecentColors(): void; getIndexedColors(): readonly AdjustedColor[]; setCustomIndexedColors(colors: readonly AdjustedColor[]): void; getCustomIndexedColors(): readonly AdjustedColor[]; addListener(listener: ISheetStyleListener): RemoveListener; protected _toJSONInternal(jsonSheetStyleShared: SerializableCellStyleValues[]): SheetStyleJSON; protected _getStyleFromJSON(json: SerializableCellStyleValues, ref: any): ICellStyle; protected _fromJSONIndexedColors(indexedColors: string[]): AdjustedColor[]; protected _fromJSONInternal(json: SheetStyleJSON): void; } export { SheetStyle }; //# sourceMappingURL=SheetStyle.d.ts.map