import { Column } from 'ag-grid-enterprise';
import { AdaptableColumnGroup, AdaptableColumnType, BaseContext, Layout } from '../types';
import { TypeHint } from '../AdaptableState/Common/Types';
/**
 * Options related to managing Columns in Adaptable.
 */
export interface ColumnOptions {
    /**
     * Provide an alternative Friendly Name for a Column
     * @defaultValue  undefined
     */
    columnFriendlyName?: (columnFriendlyNameContext: ColumnFriendlyNameContext) => string | undefined;
    /**
     * Provide a custom Header Name for a Table or Pivot Column
     */
    columnHeader?: (context: ColumnHeaderContext) => string;
    /**
     * Optional list of Column Types - used for Scope and creating Special Columns
     * @defaultValue Empty Array
     */
    columnTypes?: TypeHint<string, AdaptableColumnType>[] | ((context: ColumnTypesContext) => TypeHint<string, AdaptableColumnType>[]);
    /**
     * Log warning to console if AdapTable cannot find a column
     *
     * @defaultValue true
     * @gridInfoItem
     * @noCodeItem
     */
    showMissingColumnsWarning?: boolean;
    /**
     * Appends the name of the Column Group to a Column's Friendly Name
     *
     * @defaultValue false
     * @gridInfoItem
     * @noCodeItem
     */
    addColumnGroupToColumnFriendlyName?: boolean;
}
/**
 * Common properties for Column Header Context
 */
export interface BaseColumnHeaderContext extends BaseContext {
    /**
     * Default header name for Column
     */
    defaultHeaderName: string;
    /**
     * Name of Current Layout
     */
    currentLayoutName: string;
    /**
     * Type (table/pivot) of Current Layout
     */
    currentLayoutType: 'table' | 'pivot';
    /**
     * Current Layout
     */
    currentLayout: Layout;
}
/**
 * Context for Columns created automatically by AG Grid when Row Grouping
 */
export interface AutoGroupColumnHeaderContext extends BaseColumnHeaderContext {
    /**
     * Auto-generated Row Group Column (when RowGroupDisplayType is `single`)
     */
    columnType: 'autoGroupColumn';
    /**
     * Id of the Column
     */
    columnId: string;
    /**
     * Ids of all Row Grouped Columns
     */
    groupedColumnIds: string[];
}
/**
 * Context for Columns created when Row Grouping
 */
export interface RowGroupColumnHeaderContext extends BaseColumnHeaderContext {
    /**
     * A Row Grouped Column (created in both Table and Pivot Layout)
     */
    columnType: 'rowGroupColumn';
    /**
     * Id of the Column
     */
    columnId: string;
    /**
     * Id of Row Grouped Column
     */
    groupColumnId: string;
}
/**
 * Context for standard Table Layout Columns
 */
export interface TableColumnHeaderContext extends BaseColumnHeaderContext {
    /**
     *  Table Column (created in Table Layouts)
     */
    columnType: 'tableColumn';
    /**
     * Id of the Column
     */
    columnId: string;
    /**
     * Aggregation function of Column (optional)
     */
    aggregation?: string;
}
/**
 * Context for Column Group headers
 */
export interface TableColumnGroupHeaderContext extends BaseColumnHeaderContext {
    /**
     * Table Column Group (used when Column Grouping in Table Layouts)
     */
    columnType: 'tableColumnGroup';
    /**
     * Id of Column Group
     */
    groupId: string;
    /**
     * Ids of Column Group's children
     */
    childrenColumnIds: string[];
    /**
     * Expanded / Collapsed state of Column Group
     */
    state: 'expanded' | 'collapsed';
}
/**
 * Context for Pivot Column Groups
 */
export interface PivotColumnGroupHeaderContext extends BaseColumnHeaderContext {
    /**
     * Pivot Column Group (created for each distinct value in a PivotColumn)
     */
    columnType: 'pivotColumnGroup';
    /**
     * Id of generated Column Group
     */
    groupId: string;
    /**
     * Pivot Keys for Column Group
     */
    pivotKeys: string[];
    /**
     * Expanded / Collapsed state of Column Group
     */
    state: 'expanded' | 'collapsed';
}
/**
 * Context for Pivot Result Columns
 */
export interface PivotResultColumnHeaderContext extends BaseColumnHeaderContext {
    /**
     * Pivot Result Column (unique intersection of PivotAggregationColumn and PivotColumn)
     */
    columnType: 'pivotResultColumn';
    /**
     * Id of generated Column
     */
    columnId: string;
    /**
     * Current Pivot Keys
     */
    pivotKeys: string[];
    /**
     * Id of Pivot Aggregated Column
     */
    aggregatedColumnId: string;
    /**
     *  Aggregation function of Column
     */
    aggregation: string;
}
/**
 * Context for Pivot Grand Total Columns
 */
export interface PivotGrandTotalHeaderContext extends BaseColumnHeaderContext {
    /**
     * Pivot Grand Total Column
     */
    columnType: 'pivotGrandTotal';
    /**
     * Id of Pivot Aggregated Column
     */
    aggregatedColumnId: string;
    /**
     *  Aggregation function of Column
     */
    aggregation: string;
}
/**
 * Context for Pivot Total Columns
 */
export interface PivotColumnTotalHeaderContext extends BaseColumnHeaderContext {
    /**
     * Pivot Column Total
     */
    columnType: 'pivotColumnTotal';
    /**
     * Key (i.e. column value) of Pivot Column
     */
    pivotKey: string;
    /**
     * Id of Pivot Column
     */
    pivotColumnId: string;
    /**
     *  Aggregation function of Column
     */
    aggregation: string;
}
/**
 * Context for Pivot Aggregation Totals
 */
export interface PivotAggregationTotalHeaderContext extends BaseColumnHeaderContext {
    /**
     * Pivot Aggregation Total Column
     */
    columnType: 'pivotAggregationTotal';
    /**
     * Id of Aggregated Column
     */
    aggregatedColumnId: string;
    /**
     *  Aggregation function of Column
     */
    aggregation: string;
    /**
     * Id of Pivot Column
     */
    pivotColumnId: string;
    /**
     * Key (i.e. column value) of Pivot Column
     */
    pivotKey: string;
}
/**
 * Context provided to columnHeader function custom Headers to be provided for any type of AG Grid Column
 */
export type ColumnHeaderContext = TableColumnHeaderContext | TableColumnGroupHeaderContext | AutoGroupColumnHeaderContext | RowGroupColumnHeaderContext | PivotColumnGroupHeaderContext | PivotResultColumnHeaderContext | PivotGrandTotalHeaderContext | PivotColumnTotalHeaderContext | PivotAggregationTotalHeaderContext;
/**
 * Context used when setting a Column Friendly Name
 */
export interface ColumnFriendlyNameContext extends BaseContext {
    /**
     * Id of the Column
     */
    colId: string;
    /**
     * AG Grid Display Name
     */
    displayName: string;
    /**
     * AG Grid ColDef for the Column
     */
    agColumn: Column;
    /**
     * Column Group Information
     */
    columnGroup: AdaptableColumnGroup;
}
/**
 * Context used when retrieving Column Types
 */
export interface ColumnTypesContext extends BaseContext {
    /**
     * Current Column Types
     */
    types: string[];
}
