@adaptabletools/adaptable
Version:
Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements
154 lines (153 loc) • 5.72 kB
TypeScript
import { BaseState } from './BaseState';
import { ColumnScope } from './Common/ColumnScope';
import { AdaptableColumnPredicate } from './Common/AdaptablePredicate';
import { TypeHint } from './Common/Types';
import { AdaptableMessageType } from './Common/AdaptableMessageType';
import { AdaptableForm } from './Common/AdaptableForm';
import { AdaptableButton } from './Common/AdaptableButton';
import { SuspendableObject } from './Common/SuspendableObject';
import { AdaptableStyle } from './Common/AdaptableStyle';
import { XOR } from '../Utilities/Extensions/TypeExtensions';
import { AdaptableAggregatedBooleanQuery, AdaptableBooleanQuery, AdaptableObservableQuery } from './Common/AdaptableQuery';
import { ButtonStyle } from './Common/ButtonStyle';
import { AlertFormContext, BaseContext, NotificationsOptions } from '../types';
/**
* Adaptable State section for Alert Module
*/
export interface AlertState extends BaseState {
/**
* Alert Definitions - will trigger Alerts when rule is met
*/
AlertDefinitions?: AlertDefinition[];
}
/**
* The Alert Definition object used in the Alert function
*/
export interface AlertDefinition extends SuspendableObject {
/**
* Where Alert can be triggered: one, some or all columns or DataTypes
*/
Scope: ColumnScope;
/**
* When Alert should be triggered
*/
Rule: AlertRule;
/**
* Type of Alert: 'Info', 'Success', 'Warning', 'Error'; influences Alert colour, icon and logging
*/
MessageType: AdaptableMessageType;
/**
* Title of displayed Alert Message
*/
MessageHeader?: string;
/**
* Title of displayed Alert Message; if null, AdapTable creates dynamically using Rule & Scope
*/
MessageText?: string;
/**
* Series of properties which set what happens when Alert is triggered
*/
AlertProperties?: AlertProperties;
/**
* Form to display in Alert with buttons and inputs
*/
AlertForm?: string | AlertButtonForm;
}
/**
* Form triggered by an Alert which contains only Buttons
*/
export type AlertButtonForm = Omit<AdaptableForm<AlertFormContext>, 'title' | 'buttons' | 'description'> & {
Buttons?: AlertButton<AlertFormContext>[];
};
/**
* Predicate used when creating a Predicate-based Rule for an Alert
*/
export interface AlertDefinitionPredicate extends AdaptableColumnPredicate {
PredicateId: TypeHint<string, SystemAlertPredicateId>;
}
/**
* The Alert Rule defined by either an AdaptablePredicate or an AdaptableQuery
*/
export type AlertRule = XOR<{
Predicates: AlertDefinitionPredicate[];
}, AdaptableAlertQuery>;
/**
* Alert Query which may be either a Boolean, Observable or AggregatedBoolean Expression
*/
export type AdaptableAlertQuery = XOR<AdaptableBooleanQuery, XOR<AdaptableObservableQuery, AdaptableAggregatedBooleanQuery>>;
/**
* Commands available in an Alert
*/
export type AdaptableAlertCommand = 'highlight-cell' | 'highlight-row' | 'jump-to-cell' | 'jump-to-row' | 'jump-to-column' | 'suspend' | 'undo';
/**
* Defines a button that appears in an Alert Form
*/
export interface AlertButton<AlertFormContext> extends Omit<AdaptableButton<BaseContext>, 'onClick' | 'label' | 'buttonStyle' | 'hidden' | 'disabled' | 'tooltip'> {
/**
* Predefined Command(s) to trigger when button is clicked; implemented in `commandHandlers` property of Alert Options
*/
Command?: AdaptableAlertCommand | AdaptableAlertCommand[] | string | string[] | ((context: AlertFormContext) => void);
/**
* Label to show in the Button
*/
Label: string;
/**
* Style for the Button
*/
ButtonStyle?: ButtonStyle;
/**
* ToolTip to display
*/
Tooltip?: string;
}
/**
*
* Additional properties that specify how a particular Alert will ALWAYS behave
*/
export interface AlertProperties {
/**
* Displays a notification when Alert is triggered
*/
DisplayNotification?: boolean;
/**
* Notifiction duration(defaults to `NotificationOptions.duration`)
*/
NotificationDuration?: NotificationsOptions['duration'];
/**
* Colours updated Row using `MessageType` of triggering Alert Definition
*/
HighlightCell?: boolean | AdaptableStyle;
/**
* Colours updated Row using `MessageType` of triggering Alert Definition
*/
HighlightRow?: boolean | AdaptableStyle;
/**
* Grid will 'jump' to the changed cell which triggered the Alert
*/
JumpToCell?: boolean;
/**
* Grid will 'jump' to the newly added row which triggered the Alert
*/
JumpToRow?: boolean;
/**
* Shows Alert text in the div specificed in `alertContainer` property of Container Options
*/
ShowInDiv?: boolean;
/**
* Logs the Alert message to the console
*/
LogToConsole?: boolean;
/**
* Automatically prevent any cell edit which triggered the Alert (i.e. validation)
* @defaultValue false
*/
PreventEdit?: boolean;
}
/**
* Array containing all System Alert Predicates
*/
export type SystemAlertPredicateIds = SystemAlertPredicateId[];
/**
* List of System Predicates available for Alerts
*/
export type SystemAlertPredicateId = 'Blanks' | 'NonBlanks' | 'Equals' | 'NotEquals' | 'GreaterThan' | 'LessThan' | 'Positive' | 'Negative' | 'Zero' | 'Between' | 'NotBetween' | 'Is' | 'IsNot' | 'Contains' | 'NotContains' | 'StartsWith' | 'EndsWith' | 'Regex' | 'Today' | 'Yesterday' | 'Tomorrow' | 'ThisWeek' | 'ThisMonth' | 'ThisQuarter' | 'ThisYear' | 'InPast' | 'InFuture' | 'Before' | 'After' | 'On' | 'NotOn' | 'NextWorkDay' | 'LastWorkDay' | 'WorkDay' | 'Holiday' | 'True' | 'False' | 'PercentChange' | 'In' | 'NotIn' | 'AnyChange';