import { TemplateRef } from '@angular/core';
import { SdBadge } from '@sd-angular/core/components/badge';
import { SdSearch } from '@sd-angular/core/forms';
import { SdColor, SdNestedKeyOf, SdOperator } from '@sd-angular/core/utilities';
export type SdTableColumn<T = any> = SdTableColumnText<T> | SdTableColumnNumber<T> | SdTableColumnBool<T> | SdTableColumnDate<T> | SdTableColumnValues<T> | SdTableColumnLazyValues<T> | SdTableColumnChildren<T>;
export type SdTableColumnTransformFunc<T = any> = (value: any, rowData: T, args?: {
    isExport?: boolean;
}) => string | Promise<string>;
interface SdTableColumnBase<T = any> {
    title: string;
    titleHtml?: string;
    description?: string;
    width?: string;
    minWidth?: string;
    maxWidth?: string;
    hidden?: boolean;
    invisible?: boolean;
    fixed?: boolean;
    align?: 'right';
    useBadge?: (value: any, rowData: T) => {
        type?: SdBadge['type'];
        color?: SdBadge['color'];
        icon?: SdBadge['icon'];
        title?: SdBadge['title'];
    };
    cellStyle?: (value: any, rowData: T) => Record<string, string>;
    htmlTemplate?: (value: any, rowData: T) => string;
    transform?: SdTableColumnTransformFunc<T>;
    tooltip?: (value: any, rowData: T) => string;
    click?: (value: any, rowData: T) => void;
    sortable?: boolean;
    filter?: {
        disabled?: boolean;
        default?: any;
        operator?: {
            default?: SdOperator;
            enable?: boolean;
            list?: SdOperator[];
        };
    };
    export?: {
        disabled?: boolean;
    };
    cellDef?: TemplateRef<any>;
    copiable?: boolean;
}
interface SdTableColumnText<T = any> extends SdTableColumnBase<T> {
    field: SdNestedKeyOf<T>;
    type: 'string';
    badge?: (value: any, rowData: T) => SdColor;
    badgeIcon?: (value: any, rowData: T) => string;
    badgeType?: SdBadge['type'];
}
interface SdTableColumnNumber<T = any> extends SdTableColumnBase<T> {
    field: SdNestedKeyOf<T>;
    type: 'number';
    badge?: (value: any, rowData: T) => SdColor;
    badgeIcon?: (value: any, rowData: T) => string;
    badgeType?: SdBadge['type'];
    filter?: SdTableColumnBase['filter'] & {
        type?: 'split-number';
    };
}
interface SdTableColumnBool<T = any> extends SdTableColumnBase<T> {
    field: SdNestedKeyOf<T>;
    type: 'boolean';
    option?: {
        displayOnTrue?: string;
        displayOnFalse?: string;
    };
}
interface SdTableColumnDate<T = any> extends SdTableColumnBase<T> {
    field: SdNestedKeyOf<T>;
    type: 'date' | 'datetime' | 'time';
    filter?: SdTableColumnBase['filter'] & {
        type?: 'daterange' | 'date' | 'split-date';
    };
}
export interface SdTableColumnValues<T = any> extends SdTableColumnBase<T> {
    field: SdNestedKeyOf<T>;
    type: 'values';
    badge?: (value: any, rowData: T) => SdColor;
    badgeIcon?: (value: any, rowData: T) => string;
    badgeType?: SdBadge['type'];
    option: {
        valueField: string;
        displayField: string;
        items: any[] | (() => Promise<any[]>);
        selection?: 'AUTOCOMPLETE' | 'MULTIPLE' | 'MULTIPLEAUTOCOMPLETE';
    };
}
export interface SdTableColumnLazyValues<T = any> extends SdTableColumnBase<T> {
    field: SdNestedKeyOf<T>;
    type: 'lazy-values';
    option: {
        valueField: string;
        displayField: string;
        items: SdSearch;
        views?: (values: string[]) => Promise<any[]>;
        mapValue?: (value: any, rowData?: T) => string | string[];
        selection?: 'MULTIPLE';
    };
}
export type SdTableColumnNormal<T = any> = Exclude<SdTableColumn<T>, SdTableColumnChildren<T>>;
export interface SdTableColumnChildren<T = any> extends SdTableColumnBase<T> {
    field: string;
    type: 'children';
    children: SdTableColumnNormal<T>[];
}
export {};
