import { AdaptableMessageType, BaseContext, AdaptableColumnContext } from '../../types';
import { CellDataChangedInfo } from '../AdaptableState/Common/CellDataChangedInfo';
import { MathOperation } from '../AdaptableState/Common/Enums';
import { GridCell } from '../AdaptableState/Selection/GridCell';
/**
 * Options related to Editing in AdapTable - includes Server Validation, Smart Edit Operations and Cell Editabiility
 */
export interface EditOptions<TData = any> {
    /**
     * Function to validate AdapTable data edits remotely
     */
    validateOnServer?: (serverValidationContext: ServerValidationContext<TData>) => Promise<ServerValidationResult>;
    /**
     * Whether to display message after Server Validation runs
     *
     * @defaultValue true
     * @gridInfoItem
     */
    displayServerValidationMessages?: boolean;
    /**
     * Function which checks if a given Grid Cell is editable
     */
    isCellEditable?: (cellEditableContext: CellEditableContext<TData>) => boolean;
    /**
     * Custom Operations to use in Smart Edit
     */
    smartEditCustomOperations?: SmartEditCustomOperation<TData>[];
    /**
     * Columns that will display a Select dropdown when editing
     */
    showSelectCellEditor?: (currentColumContext: AdaptableColumnContext<TData>) => boolean;
    /**
     * List of Column values to display when Editing (i.e. in Edit Lookups, Bulk Update)
     */
    customEditColumnValues?: (context: CustomEditColumnValuesContext<TData>) => CustomEditColumnValueInfo[] | Promise<CustomEditColumnValueInfo[]>;
}
/**
 * Context used when getting Distinct Column Values for Editing
 */
export interface CustomEditColumnValuesContext<TData = any> extends AdaptableColumnContext<TData> {
    /**
     * Current distinct values in Column
     */
    defaultValues: Required<CustomEditColumnValueInfo>[];
    /**
     * Search text in Edit - used when fetching values from server
     */
    currentSearchValue: string;
    /**
     * Currently edited Grid Cell
     */
    gridCell: GridCell;
}
/**
 * Information about items in the Edit Controls
 */
export interface EditColumnValueInfo {
    value: any;
    label?: string;
}
/**
 * Information about items in the custom Edit Controls
 */
export interface CustomEditColumnValueInfo {
    value: any;
    label?: string;
}
/**
 * Used for Server Validation ie. after an edit in AG Grid which must be checked on Server
 */
export interface ServerValidationResult {
    /**
     * Header to diplay with validation
     * @defaultValue 'Server Validation Message',
     */
    validationHeader?: string;
    /**
     * Message to diplay with validation
     */
    validationMessage?: string;
    /**
     * Cell Value to use for after Server Validation
     */
    newCellValue?: any;
    /**
     * Type of Message to Display
     * @defaultValue Info
     *
     */
    messageType?: AdaptableMessageType;
}
/**
 * Custom Operation used in Smart Edit Module
 */
export type SmartEditCustomOperation<TData = any> = {
    /**
     * Name of the Custom Operation (as appears in AdapTable UI)
     */
    name: string;
    /**
     * Custom Operation function - returns a number
     */
    operation: (context: SmartEditOperationContext<TData>) => number;
};
/**
 * Operation used by Smart Edit - either System or Custom
 */
export type SmartEditOperation = SmartEditCustomOperation | MathOperation;
/**
 * Context used in Custom Smart Edit Operations
 */
export interface SmartEditOperationContext<TData = any> extends BaseContext {
    /**
     * Smart Edit value
     */
    smartEditValue: number;
    /**
     * Current selected grid cell - contains column, row and cell value information
     */
    currentCell: GridCell<TData>;
}
/**
 * Context used when validating data edits on Server
 */
export interface ServerValidationContext<TData = any> extends BaseContext {
    /**
     * Details of Cell Edit
     */
    cellDataChangedInfo: CellDataChangedInfo<TData>;
}
/**
 * Context used when checking Cell editability
 */
export interface CellEditableContext<TData = any> extends BaseContext {
    /**
     * Cell being edited
     */
    gridCell: GridCell<TData>;
    /**
     * Default editability according to the AG Grid Column Definition (`ColDef.editable`)
     */
    defaultColDefEditableValue: boolean;
}
