UNPKG

@adaptabletools/adaptable

Version:

Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements

195 lines (194 loc) 5.48 kB
import { BaseState } from './BaseState'; import { SuspendableObject } from './Common/SuspendableObject'; import { AdaptableCustomIcon, AdaptableSystemIcon, AdaptablePredicate, AdaptableStyle, AdaptableBooleanQuery } from '../types'; import { TypeHint } from './Common/Types'; import { RowScope } from './Common/RowScope'; import { AgSparklineOptions } from 'ag-charts-types'; /** * Adaptable State Section for Styled Column Module */ export interface StyledColumnState extends BaseState { /** * Collection of Special Column Styles */ StyledColumns?: StyledColumn[]; } /** * Object used in Special Column Style function */ export interface StyledColumn extends SuspendableObject { /** * Column being styled */ ColumnId: string; /** * Styles a numeric column with a Gradient */ GradientStyle?: GradientStyle; /** * Styles a numeric column so each cell displays a 'Bar' */ PercentBarStyle?: PercentBarStyle; /** * Displays a Sparkline Chart in an array column */ SparklineStyle?: SparklineStyle; /** * Displays cell values in Column as a Badge */ BadgeStyle?: BadgeStyle; } /** * Style used to display Percent Bars in Special Column Style */ export interface PercentBarStyle extends NumericStyledColumn { /** * Whether Cell shows Cell Value, Percent Value, both or none */ CellText?: CellTextOptions; /** * Position of text in Cell relative to Percent Bar, "Above", "Below" or "Merged" * @defaultValue Below */ CellTextPosition?: 'Above' | 'Below' | 'Merged'; /** * Whether Tooltip shows Cell Value, Percent Value, both or none */ ToolTipText?: CellTextOptions; /** * Background colour for 'Percent Bar'; leave unset if none required * @defaultValue undefined */ BackColor?: string; } /** * Base type for Numeric Styled Columns (i.e. Gradient and Percent Bar) */ export interface NumericStyledColumn { /** * Ranges (e.g. to create traffic light effect) */ CellRanges?: CellColorRange[]; /** * Compares Cell values to another Column */ ColumnComparison?: ColumnComparison; /** * Used with Ranges; can be Number (any number or Col-Min/Col-Max) or 'Percentage' (values 0-100) * @defaultValue Number */ RangeValueType?: RangeValueType; } /** * Used to display Gradient Styles in Special Column Style */ export interface GradientStyle extends NumericStyledColumn { } /** * Defines which Colours to show in Gradient and Percent Bar Styles */ export interface CellColorRange { /** * Start number of Range */ Min: number | 'Col-Min'; /** * End number of Range */ Max: number | 'Col-Max'; /** * Cell colour to use for values that fall inside Range */ Color: string; /** * Reverses the Gradient so the lower the cell value the darker the colour */ ReverseGradient?: boolean; } /** * Enables a Percent Bar or Gradient Style to use another column in its calculations */ export interface ColumnComparison { /** * Start value - either numeric value or Column name */ MinValue: number | string; /** * End value - either numeric value or Column name */ MaxValue: number | string; /** * Colour to use for the Comparison */ Color: string; } /** * Array of CellTextOption available in Special Column Styles */ export type CellTextOptions = CellTextOption[]; /** * Text optionally to show in a Special Column Style special style: 'CellValue' or 'PercentageValue' */ export type CellTextOption = 'CellValue' | 'PercentageValue'; /** * Whether the Range is Number or Percent based */ export type RangeValueType = 'Number' | 'Percentage'; /** * Style to show for a Sparkline Column */ export type SparklineStyle = { /** * AG Grid Sparkline Options */ options?: AgSparklineOptions; }; /** * Predicates available when creating a Badge Style Rule */ export type SystemBadgeStylePredicateId = 'In' | 'NotIn' | 'Blanks' | 'NonBlanks' | 'Equals' | 'NotEquals' | 'GreaterThan' | 'LessThan' | 'Positive' | 'Negative' | 'Zero' | 'Between' | 'NotBetween' | 'Is' | 'IsNot' | 'Contains' | 'NotContains' | 'StartsWith' | 'EndsWith' | 'Regex'; /** * System Predicate Ids available for Badge Style */ export type SystemBadgeStylePredicateIds = SystemBadgeStylePredicateId[]; /** * System Predicate definition for Badge Style */ export interface BadgeStylePredicate extends AdaptablePredicate { PredicateId: TypeHint<string, SystemBadgeStylePredicateId>; } /** * Defines a Badge Style */ export interface BadgeStyleDefinition { /** * Optional Rule for deciding whether Badge is displayed */ Predicate?: BadgeStylePredicate; Expression?: AdaptableBooleanQuery; /** * Style for the Badge */ Style?: AdaptableStyle; /** * Icon to display in Badge */ Icon?: AdaptableSystemIcon | AdaptableCustomIcon; /** * Position of Icon in the Badge - 'Start' or 'End' */ IconPosition?: 'Start' | 'End'; } /** * Collection of Badge Style Definitions to display in a Badge Styled Column */ export interface BadgeStyle { /** * Collection of Badge Style Definitions */ Badges?: BadgeStyleDefinition[]; /** * Which types of Rows should contain a Badge (data, grouped, summary) */ RowScope?: RowScope; }