import { default as React } from 'react';
import { CustomEditorProps } from './CustomEditorProps';
/**
 * Editor types supported for editable cells
 */
export type EditableCellEditor = 'text' | 'date' | 'dateRange' | 'custom';
/**
 * Date range value type (compatible with react-day-picker's DateRange)
 */
export type DateRangeValue = {
    from?: Date;
    to?: Date;
};
/**
 * Value types for each editor type
 */
export type CellEditValueMap = {
    text: string;
    date: Date;
    dateRange: DateRangeValue;
};
/**
 * Union of all possible cell edit values.
 *
 * For built-in editors this is `string | Date | DateRangeValue`. The `'custom'`
 * editor may produce any value type: supply `TCustom` to make those values
 * type-safe end-to-end (e.g. in `cellEdit.onSave` and `renderEditor`). When
 * `TCustom` is left as the default (`never`), the type collapses to the
 * built-in union and existing call sites are unaffected.
 *
 * @template TCustom - The value type produced by a `'custom'` editor.
 */
export type CellEditValue<TCustom = never> = string | Date | DateRangeValue | TCustom;
/**
 * Configuration for editable cell editor.
 *
 * This is a discriminated union on `type`:
 * - Built-in editors (`'text' | 'date' | 'dateRange'`) accept an optional
 *   `dateFormat` and must not provide `renderEditor`.
 * - The `'custom'` editor requires `renderEditor` and must not provide
 *   `dateFormat`.
 *
 * @template TRecord - The type of the full row record (used by `renderEditor`).
 * @template TCustom - The value type produced by a `'custom'` editor.
 */
export type EditableConfig<TRecord = unknown, TCustom = unknown> = {
    /**
     * The type of built-in editor to use.
     * @default 'text'
     */
    type: 'text' | 'date' | 'dateRange';
    /**
     * Date format string (for 'date' and 'dateRange' types)
     * @default 'dd.MM.yyyy'
     */
    dateFormat?: string;
    /** Not allowed for built-in editor types. */
    renderEditor?: never;
} | {
    /** Marks this column as using a consumer-provided custom editor. */
    type: 'custom';
    /** Not applicable to the custom editor. */
    dateFormat?: never;
    /**
     * Render function for the `'custom'` editor type.
     *
     * Receives the standardized {@link CustomEditorProps} contract (draft
     * value + lifecycle handlers) and returns the editor UI. Required when
     * `type` is `'custom'`.
     */
    renderEditor: (props: CustomEditorProps<TCustom, TRecord>) => React.ReactNode;
};
/**
 * Value type for column editable property
 * Can be:
 * - boolean: true enables text editing, false disables
 * - EditableConfig: object with editor configuration
 * - function: returns boolean or EditableConfig based on record/rowIndex
 */
export type EditableValue<T, TCustom = unknown> = boolean | EditableConfig<T, TCustom> | ((record: T, rowIndex: number) => boolean | EditableConfig<T, TCustom>);
export default EditableConfig;
