import type { ComponentType } from 'react';
import type { RichTextStyleVariables } from '@wix/patterns-fields';
import type { TableColumn } from '../../model/tableColumn';
import type { CellViewProps, CellEditProps } from '../../components/EditableTable/types';
export interface RichTextCellTypeConfig {
    textStyle?: RichTextStyleVariables;
}
export interface Cell {
    rowKey: string;
    columnId: string;
}
export interface CellBorder {
    top: boolean;
    bottom: boolean;
    left: boolean;
    right: boolean;
}
export type ValidationRule = {
    type: 'required';
    message: string;
} | {
    type: 'min' | 'max';
    value: number;
    message: string;
} | {
    type: 'minLength' | 'maxLength';
    value: number;
    message: string;
} | {
    type: 'pattern';
    value: RegExp;
    message: string;
} | {
    type: 'custom';
    validate: (value: unknown) => boolean;
    message: string;
} | {
    type: 'specificValues';
    values: {
        id: string;
        value: string;
    }[];
    message: string;
};
export interface ValidationResult {
    valid: boolean;
    errors?: string[];
}
export interface CellType {
    type: keyof CellTypeConfigMap;
    /** Render cell in view mode (read-only display) */
    ViewComponent: ComponentType<CellViewProps<any>>;
    /** Render cell in edit mode (inline editor). Optional — omit for view-only cells. */
    EditComponent?: ComponentType<CellEditProps<any>>;
    /** Serialize value to clipboard string */
    serialize?: (value: any) => string;
    /** Deserialize clipboard string to value */
    deserialize?: (raw: string) => any;
    /** Validate a cell value. Return null if valid, or error message string. */
    validate?: (value: any, rules?: ValidationRule[]) => string | null;
    /** Can this cell type be edited? (default: true) */
    editable?: boolean;
    /** Can this cell type be cleared with Delete key? (default: true) */
    clearable?: boolean;
    /** Toggle value on single click (e.g., boolean checkbox). Skips focus→edit flow. */
    toggleValue?: (value: any) => any;
    /** Enter edit mode on single click (e.g., image cell with no value). */
    editOnClick?: (value: any) => boolean;
    /** Show the EditComponent when the cell is focused, without entering edit mode.
     *  Keyboard navigation remains active. Similar to toggleValue but without toggling. */
    showEditWhenFocused?: boolean;
    /** Called on type-to-edit. Return object with cleared value and/or prevent flag.
     *  CMS-web pattern: text clears to '', number clears only for digits, date blocks non-digits.
     *  Return undefined to block the key. Return {} to enter edit mode without changing the value. */
    onTypeToEdit?: (params: {
        key: string;
        validation?: ValidationRule[];
    }) => {
        value?: any;
    } | undefined;
    /** Optional hook to normalize the committed value (e.g. auto-prepend https://).
     *  Called before commitEdit() from EditableCell (blur/Enter) and useKeyboardNavigation (Tab).
     *  The value is written back to editingValue via runInAction before committing. */
    normalizeOnCommit?: (value: any) => any;
}
export interface CellTypeConfigMap {
    text: never;
    number: never;
    boolean: never;
    url: never;
    email: never;
    date: never;
    object: never;
    image: never;
    richContent: never;
    video: never;
    richText: RichTextCellTypeConfig;
    mediaGallery: never;
    custom: Omit<CellType, 'type'>;
}
interface EditableColumnBase<T> extends Omit<TableColumn<T>, 'render'> {
    id: string;
    /** Column type — maps to a CellType in the registry */
    cellType: keyof CellTypeConfigMap;
    /** Extract the cell value from the row data */
    getValue: (item: T) => any;
    /** Return updated item with new cell value (immutable) */
    setValue?: (item: T, value: any) => T;
    /** Column-level validation rules */
    validation?: ValidationRule[];
    /** Is this column editable? (default: true if setValue exists) */
    editable?: boolean | ((item: T) => boolean);
    /** True if this column represents the schema's primary field. Drives header-action disable rules (e.g. blocks Delete, blocks Make Primary). */
    isPrimary?: boolean;
    /** True if this column represents a system field. Drives header-action disable rules (e.g. blocks Edit, Delete, Duplicate). */
    isSystem?: boolean;
}
export type EditableColumn<T, C extends keyof CellTypeConfigMap = keyof CellTypeConfigMap> = C extends C ? EditableColumnBase<T> & {
    cellType: C;
    typeConfig?: CellTypeConfigMap[C] extends never ? never : CellTypeConfigMap[C];
} : never;
export {};
//# sourceMappingURL=types.d.ts.map