import type { CellStyle, EvaluateOptions, IArea, Color, Gradient, GradientStop, UnionValue } from '../../treb-base-types/src/index'; interface VertexPlaceholder { result: UnionValue; updated: boolean; } export interface CondifionalFormatExpressionOptions { style: CellStyle; expression: string; options?: EvaluateOptions; } /** * conditional format predicated on an expression. if the expression * evaluates to true, we apply the style. otherwise no. */ export interface ConditionalFormatExpression extends CondifionalFormatExpressionOptions { type: 'expression'; area: IArea; /** @internal */ internal?: { vertex?: VertexPlaceholder; }; } export interface ConditionalFormatGradientOptions { /** property defaults to fill */ property?: 'fill' | 'text'; /** defaults to RGB */ color_space?: 'HSL' | 'RGB'; /** gradient stops, required */ stops: Array<{ value: number; color: Color; }>; /** min and max are optional. if not provided, we use the min/max of the range of data. */ min?: number; /** min and max are optional. if not provided, we use the min/max of the range of data. */ max?: number; } /** * * @internal * * @privateRemarks * * this is marked internal temporarily while I figure out why our API * generator is not exporting the gradient stop type */ export declare const StandardGradientsList: { readonly 'red-green': { readonly color_space: "RGB"; readonly stops: GradientStop[]; }; readonly 'red-yellow-green': { readonly color_space: "RGB"; readonly stops: GradientStop[]; }; readonly 'green-red': { readonly color_space: "RGB"; readonly stops: GradientStop[]; }; readonly 'green-yellow-red': { readonly color_space: "RGB"; readonly stops: GradientStop[]; }; }; export type StandardGradient = 'red-green' | 'green-red' | 'red-yellow-green' | 'green-yellow-red'; export interface ConditionalFormatGradient extends ConditionalFormatGradientOptions { type: 'gradient'; area: IArea; /** @internal */ internal?: { gradient?: Gradient; vertex?: VertexPlaceholder; }; } export interface ConditionalFormatDataBarOptions { /** min and max are optional. if not provided, we use the min/max of the range of data. */ min?: number; /** min and max are optional. if not provided, we use the min/max of the range of data. */ max?: number; /** */ fill: Color; /** */ negative?: Color; /** */ hide_values?: boolean; } export interface ConditionalFormatDataBar extends ConditionalFormatDataBarOptions { type: 'data-bar'; area: IArea; /** @internal */ internal?: { vertex?: VertexPlaceholder; }; } export interface ConditionalFormatCellMatchOptions { style: CellStyle; expression: string; options?: EvaluateOptions; } export interface ConditionalFormatCellMatch extends ConditionalFormatCellMatchOptions { type: 'cell-match'; area: IArea; /** @internal */ internal?: { vertex?: VertexPlaceholder; }; } export interface ConditionalFormatCellMatchOptions { style: CellStyle; expression: string; between?: [number, number]; options?: EvaluateOptions; } export interface ConditionalFormatCellMatch extends ConditionalFormatCellMatchOptions { type: 'cell-match'; area: IArea; /** @internal */ internal?: { vertex?: VertexPlaceholder; }; } export interface ConditionalFormatDuplicateValuesOptions { style: CellStyle; /** true to highlight unique cells, false to highlight duplicates. defaults to false. */ unique?: boolean; } export interface ConditionalFormatDuplicateValues extends ConditionalFormatDuplicateValuesOptions { type: 'duplicate-values'; area: IArea; /** @internal */ internal?: { vertex?: VertexPlaceholder; }; } /** composite conditional format type */ export type ConditionalFormatType = ConditionalFormatDuplicateValues | ConditionalFormatExpression | ConditionalFormatCellMatch | ConditionalFormatGradient | ConditionalFormatDataBar; /** * union, plus we're adding a state used to track application. * that state is serialized if it's true. * we also add an internal field that will be type-specific, and not serialized. * * ...everybody has a vertex now, we could standardize it * * update: adding a priority field, optional * */ export type ConditionalFormat = { internal?: unknown; priority?: number; } & ConditionalFormatType; /** * the list of formats, in reverse order of precedence. as a starting * point we're using the naive approach, just applying everything in * order. that may change. */ export type ConditionalFormatList = ConditionalFormat[]; export {};