@adaptabletools/adaptable
Version:
Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements
136 lines (135 loc) • 3.72 kB
TypeScript
import { IRowNode } from 'ag-grid-enterprise';
import { AdaptableIcon, ColumnFilter } from '../../types';
import { AdaptableColumn, AdaptableColumnDataType } from './AdaptableColumn';
import { ColumnScope } from './ColumnScope';
import { BaseContext } from './BaseContext';
/**
* Predicate object used by AdapTableQL - essentially a boolean function
*/
export interface AdaptablePredicate<PREDICATE_TYPE = string> {
/**
* Id of Predicate (e.g. `Equals`, `GreaterThan`)
*/
PredicateId: PREDICATE_TYPE;
/**
* Optional Inputs that might be needed for evaluation
*/
Inputs?: any[];
}
/**
* Restricts a Predicate to a given Column
*/
export interface AdaptableColumnPredicate extends AdaptablePredicate {
/**
* Id of Column which will be evaluated by the Predicate
*/
ColumnId?: string;
}
/**
* Defines a Predicate - include where it can run and what it does
*/
export interface AdaptablePredicateDef<PREDICATE_TYPE = string> {
/**
* Predicate Id
*/
id: PREDICATE_TYPE;
/**
* Name of the Predicate
*/
label: string;
/**
* Columns (or DataTypes) where Predicate is active
*/
columnScope: ColumnScope;
/**
* Modules where Predicate can run
*/
moduleScope: PredicateModuleScope[];
/**
* Inputs the Predicate can take
*/
inputs?: PredicateDefInput[];
/**
* Actual boolean function invoked when evaluating the Predicate
*/
handler: (params: PredicateDefHandlerContext) => boolean;
/**
* String representation of the Predicate
*/
toString?: (params: PredicateDefToStringParams) => string;
/**
* Icon to show (primarily used in Filter dropdown)
*/
icon?: AdaptableIcon | {
text: string;
};
/**
* Keyboard shortcuts to initiate predicate - used in Quick Filter bar
*/
shortcuts?: string[];
}
/**
* Defines an Input to a Predicate
*/
export interface PredicateDefInput {
type: 'number' | 'text' | 'date' | 'boolean';
label?: string;
defaultValue?: any;
}
/**
* Object passed into an Adaptable Predicate Definition
*/
export interface PredicateDefHandlerContext extends BaseContext {
/**
* Raw value in cell being evaluated
*/
value: any;
/**
* Previous value in cell (e.g. if evaluating an edit)
*/
oldValue: any;
/**
* Display value in cell being evaluated
*/
displayValue: any;
/**
* AG Grid Row node which contains the cell
*/
node: IRowNode;
/**
* AdapTable Column which contains the cell
*/
column: AdaptableColumn;
/**
* Any (optional) inputs required to perform evaluation
*/
inputs?: any[];
predicatesOperator?: ColumnFilter['PredicatesOperator'];
}
/**
* Inputs required for a Predicate
*/
export interface PredicateDefToStringParams {
inputs: any[];
}
/**
* Defines which Modules use the Predicate
*/
export type PredicateModuleScope = 'columnFilter' | 'alert' | 'flashingcell' | 'formatColumn' | 'badgeStyle';
/**
* Array of Predicate Defs which are shipped by AdapTable
*/
export declare const SystemPredicateDefs: AdaptablePredicateDef[];
export declare const SystemFilterPredicateIds: string[];
export declare const SystemAlertPredicateIds: string[];
export declare const SystemFormatColumnPredicateIds: string[];
export declare const SystemFlashingCellPredicateIds: string[];
export declare const SystemBadgeStylePredicateIds: string[];
/**
* Column Filter Definition for a specific Column
*/
export interface ColumnFilterDef {
dataType: AdaptableColumnDataType;
predicates: AdaptablePredicateDef[];
columnFilter: ColumnFilter;
}