import { IRowNode } from '@ag-grid-community/core';
import { ActionColumnContext, ActionRowSubmittedInfo, AdaptableButton, AdaptableColumn, BaseContext, FormContext } from '../types';
/**
 * Options relating to Action Rows, Action Row Buttons and Action Row Forms
 */
export interface ActionRowOptions<TData = any> {
    /**
     * Action Row Buttons to display
     * @defaultValue undefined
     */
    actionRowButtons?: ((context: ActionRowButtonsContext) => ActionRowButtonType[]) | ActionRowButtonType[];
    /**
     * Additional options for managing Action Row Buttons
     * @defaultValue undefined
     */
    actionRowButtonOptions?: ActionRowButtonOptions<TData>;
    /**
     * Options for managing the Form which some Action Row buttons opens
     * @defaultValue undefined
     */
    actionRowFormOptions?: ActionRowFormOptions<TData>;
    /**
     * Whether AdapTable will automatically update AG Grid data model with created/edited/deleted rows
     * @defaultValue true
     */
    autoHandle?: boolean;
    /**
     * Prevents direct editing in Grid cells even for editable columns
     * @defaultValue false
     */
    disableInlineEditing?: boolean;
    /**
     * Function called when auto-handling 'create' or 'clone' Action Row Button; returned row value should be a valid pk value
     * @defaultValue undefined
     */
    setPrimaryKeyValue?: (context: SetPrimaryKeyValueContext<TData>) => any;
}
/**
 * Context for the setPrimaryKeyValue function
 */
export interface SetPrimaryKeyValueContext<TData = any> extends BaseContext {
    /**
     * Data in the row being created or cloned
     */
    rowData: TData;
}
/**
 * Options for managing the Buttons in Action Rows
 */
export interface ActionRowButtonOptions<TData = any> {
    /**
     * Optional configuration that merges with built-in action row button and overrides default configuration
     * @defaultValue undefined
     */
    customConfiguration?: (context: ActionRowButtonConfigurationContext) => Partial<AdaptableButton<ActionColumnContext<TData>>> | undefined;
    /**
     * Action Row Buttons position: 'pinnedLeft' or 'pinnedRight
     * @defaultValue 'pinnedLeft'
     */
    position?: 'pinnedLeft' | 'pinnedRight';
}
/**
 * Options for Form displayed when Action Row Button is clicked
 */
export interface ActionRowFormOptions<TData = any> {
    /**
     * Custom form title provider
     * @defaultValue 'Create New Row'/'Edit Row'
     */
    formTitle?: string | ((context: ActionRowParamContext<TData>) => string);
    /**
     * Custom form description provider
     * @defaultValue undefined
     */
    formDescription?: string | ((context: ActionRowParamContext<TData>) => string);
    /**
     * Custom form field label provider
     * @defaultValue undefined
     */
    formFieldLabel?: (context: ActionRowParamFieldContext<TData>) => string;
    /**
     * Custom form buttons; if provided, need to handle form submission explicitly
     */
    formButtons?: AdaptableButton<ActionRowFormContext<TData>>[];
    /**
     * Event fired when an Action Row Form is submitted via a standard button provided by AdapTable; this is not invoked when custom form buttons are provided
     *
     * @param actionRowSubmittedInfo the form submitted info
     * @defaultValue undefined
     */
    onFormSubmit?: (actionRowSubmittedInfo: ActionRowSubmittedInfo<TData>) => void;
    /**
     * Whether a Column is included in System Reports and available in UI for selection
     * @defaultValue true
     */
    showColumninActionRowForm?: (actionRowFormColumnContext: ActionRowFormColumnContext) => boolean;
}
/**
 * Context passed into a Row Form - can be `CreateActionRowContext` or `EditActionRowContext`
 */
export type ActionRowFormContext<TData = any> = CreateActionRowFormContext<TData> | EditActionRowFormContext<TData>;
/**
 * Context used in a Create Row Form
 */
export interface CreateActionRowFormContext<TData = any> extends FormContext {
    /**
     * Type of the Context
     */
    type: Extract<ActionRowType, 'rowCreated'>;
    /**
     * The RowNode being cloned
     */
    clonedRowNode?: IRowNode<TData>;
}
/**
 * Context used in an Edit Row Form
 */
export interface EditActionRowFormContext<TData = any> extends FormContext {
    /**
     * Type of the Context
     */
    type: Extract<ActionRowType, 'rowEdited'>;
    /**
     * The RowNode being edited
     */
    rowNode: IRowNode<TData>;
}
/**
 * Context used for overriding Title and Description of Action Row Form
 */
export interface ActionRowParamContext<TData = any> extends BaseContext {
    type: Extract<ActionRowType, 'rowEdited' | 'rowCreated'>;
    rowNode?: IRowNode<TData>;
}
/**
 * Context used for overriding Field elements in Action Row Form
 */
export interface ActionRowParamFieldContext<TData = any> extends ActionRowParamContext {
    column: AdaptableColumn<TData>;
}
/**
 * Type of Action Row Button: 'create' | 'clone' | 'edit' | 'delete'
 */
export type ActionRowButtonType = 'create' | 'clone' | 'edit' | 'delete';
/**
 * Context used when adding custom configuration for Action Row Buttons
 */
export interface ActionRowButtonConfigurationContext extends BaseContext {
    /**
     * Type of Action Row Button: 'create', 'clone', 'edit' or 'delete'
     */
    actionRowButtonType: ActionRowButtonType;
}
/**
 * Context passed to Action Row Buttons
 */
export interface ActionRowButtonsContext extends BaseContext {
}
/**
 * Context used for setting whether a Column is exportable
 */
export interface ActionRowFormColumnContext extends BaseContext {
    /**
     * Column to be exported
     */
    adaptableColumn: AdaptableColumn;
    /**
     * Type of Action Row
     */
    actionRowType: ActionRowType;
}
/**
 * Type of Action Row - Created, Edited or Deleted
 */
export type ActionRowType = 'rowCreated' | 'rowEdited' | 'rowDeleted';
