@sheetxl/models
Version:
Models - A Headless javascript spreadsheet library.
183 lines • 6.07 kB
TypeScript
import { CellCoords } from "@sheetxl/common";
import { SerializableProperties } from "../primitives";
import { GridSurfaceStyle } from "@sheetxl/grid";
import { ITableModel } from "../table";
import { SerializableCellStyleValues, ICellStyle, CellStyleValues } from "./ICellStyle";
import { ISheetStyle } from "./ISheetStyle";
import { ICellBorder } from "./ICellBorder";
import { IFont } from "./IFont";
import { ISolidFill, IGradientFill, IPatternFill, INoneFill } from "./IFill";
export declare enum TableStyleElement {
WholeTable = "wholeTable",
FirstColumnStripe = "firstColumnStripe",
SecondColumnStripe = "secondColumnStripe",
FirstRowStripe = "firstRowStripe",
SecondRowStripe = "secondRowStripe",
LastColumn = "lastColumn",
FirstColumn = "firstColumn",
HeaderRow = "headerRow",
TotalRow = "totalRow",
FirstHeaderCell = "firstHeaderCell",
LastHeaderCell = "lastHeaderCell",
FirstTotalCell = "firstTotalCell",
LastTotalCell = "lastTotalCell"
}
export declare const DEFAULT_TABLE_STYLE_NAME: string;
/** @hidden */
export declare const DEFAULT_PIVOT_STYLE_NAME: string;
export interface SizeCellStyleValues extends CellStyleValues {
/**
* Only applied with type is
* * firstRowStripe
* * secondRowStripe
* * firstColumnStripe
* * secondColumnStripe
*
* @defaultValue 1?
*/
size?: number;
}
/**
* A table style is a collection of cell styles that are applied to a table.
* These are applied in a specific order and merged to create a single cell style.
*
* The order is:
* Whole Table
* * First Column Stripe
* * Second Column Stripe
* * First Row Stripe
* * Second Row Stripe
* * Last Column
* * First Column
* * Header Row
* * Total Row
* * First Header Cell
* * Last Header Cell
* * First Total Cell
* * Last Total Cell
*/
export interface TableStyleValues {
/**
* The name of the table style. This is the name that is shown in the UI.
*/
name?: string;
/**
* true if this table style should be shown as an available table style.
* @remarks
* table and pivot can not both be true. If both false then hidden
* @defaultValue true
*/
table?: boolean;
/**
* 'True' if this table style should be shown as an available pivot table style.
* @remarks
* table and pivot can not both be true. If both false then hidden
* @defaultValue false
*/
pivot?: boolean;
/**
* Properties for the whole table.
*/
wholeTable?: CellStyleValues;
/**
* Properties for the first set of alternating columns.
*/
firstColumnStripe?: SizeCellStyleValues;
/**
* Properties for the second set of alternating columns.
*/
secondColumnStripe?: SizeCellStyleValues;
/**
* Properties for the first set of alternating rows.
*/
firstRowStripe?: SizeCellStyleValues;
/**
* Properties for the second set of alternating rows.
*/
secondRowStripe?: SizeCellStyleValues;
lastColumn?: CellStyleValues;
firstColumn?: CellStyleValues;
headerRow?: CellStyleValues;
totalRow?: CellStyleValues;
firstHeaderCell?: CellStyleValues;
lastHeaderCell?: CellStyleValues;
fFirstTotalCell?: CellStyleValues;
lastTotalCell?: CellStyleValues;
}
export type SerializableTableStyleValues = SerializableProperties<TableStyleValues>;
export interface ISizeCellStyleValues extends Readonly<ICellStyle> {
size?: number;
}
export interface ITableStyle extends Readonly<TableStyleValues> {
/**
* Returns an ICellStyle for the given for the given cell coords.
* @remarks
* The coords are absolute
*/
getCellStyleAt: (table: ITableModel, coords: CellCoords, override?: ICellStyle) => ICellStyle;
readonly isBuiltIn: boolean;
toJSON(): SerializableTableStyleValues;
readonly isTableStyle: true;
}
export interface PivotTableStyleValues {
name?: string;
wholeTable?: CellStyleValues;
pageFieldLabels?: CellStyleValues;
pageFieldValues?: CellStyleValues;
firstColumnStripe?: SizeCellStyleValues;
secondColumnStripe?: SizeCellStyleValues;
firstRowStripe?: SizeCellStyleValues;
secondRowStripe?: SizeCellStyleValues;
firstColumn?: CellStyleValues;
headerRow?: CellStyleValues;
firstHeaderCell?: CellStyleValues;
subtotalColumn1?: CellStyleValues;
subtotalColumn2?: CellStyleValues;
subtotalColumn3?: CellStyleValues;
blankRow?: CellStyleValues;
subtotalRow1?: CellStyleValues;
subtotalRow2?: CellStyleValues;
subtotalRow3?: CellStyleValues;
columnSubheading1?: CellStyleValues;
columnSubheading2?: CellStyleValues;
columnSubheading3?: CellStyleValues;
rowSubheading1?: CellStyleValues;
rowSubheading2?: CellStyleValues;
rowSubheading3?: CellStyleValues;
grandTotalColumn?: CellStyleValues;
grandTotalRow?: CellStyleValues;
}
/**
* Extends cell styles but doesn't have all properties. Do we need to extend
* and return null (or a default value for these or omit or subclass a narrow class?)
* Omit
* - font.family
* - font.size
* - font.subscript, font.superscript
* - numberFormat: string;
* - alignment
* - protection
*/
export interface ITableElementStyle extends Readonly<CellStyleValues> {
font: IFont;
fill: ISolidFill | IGradientFill | IPatternFill | INoneFill;
border: ICellBorder;
toJSON(): SerializableCellStyleValues;
/**
* This is used to determine if the style has rendering
* artifacts even if there is no content. (For example borders or background)
*/
hasEmptyStyling(): boolean;
readonly isTableElementStyle: true;
}
export interface TableStylesJSON {
defaultTableStyle?: string;
defaultPivotStyle?: string;
styles?: Record<string, SerializableTableStyleValues>;
}
export interface SelectedTableContext {
readonly table: () => ITableModel;
readonly sheetStyle: () => ISheetStyle;
readonly bodyStyle: () => GridSurfaceStyle;
}
//# sourceMappingURL=ITableStyle.d.ts.map