import { Observable } from 'rxjs';
import { SdTableColumn } from '../../models/table-column.model';
import { TemplateRef } from '@angular/core';
import { SdSearch } from '@sd-angular/core/forms';
import { SdNestedKeyOf, SdOperator, SdOrder, SdPagingReq } from '@sd-angular/core/utilities';
export interface SdTableQuickFilter {
    code: string;
    columnFilter: Record<string, any>;
    externalFilter: Record<string, any>;
}
export interface TableFilterConfiguration {
    inlineExternal: Record<string, boolean>;
}
export interface TableFilterValue {
    columnOperator?: Record<string, SdOperator>;
    columnFilter?: Record<string, any>;
    externalFilter?: Record<string, any>;
    notReload?: boolean;
    filtered?: boolean;
}
export interface SdTableFilterRequest<T = any> {
    columnOperator: Record<string, SdOperator>;
    rawColumnFilter: Record<SdNestedKeyOf<T>, any>;
    rawExternalFilter: Record<string, any>;
    pageNumber: number;
    pageSize: number;
    orderBy?: string;
    orderDirection?: SdOrder['direction'];
    isExported?: boolean;
    visibledColumns?: SdTableColumn[];
}
export interface SdTableOptionFilter<T = any> {
    /** Key định danh nếu muốn lưu cache */
    key?: string;
    /** Có bật cache giá trị filter hay không */
    cacheable?: boolean;
    /** Vô hiệu toàn bộ filter */
    disabled?: boolean;
    /** Ẩn tất cả inline filter (chỉ còn external), nếu chọn auto thì sẽ ẩn khi total row <= 10, phù hợp cho các màn detail có ít dữ liệu */
    hideInlineFilter?: boolean | 'auto';
    /** Hàm xử lý khi đổi Operator của filter column */
    operatorChange?: (column?: SdTableColumn, operator?: SdOperator) => void;
    /** Danh sách external filter */
    externalFilters?: SdTableExternalFilter[];
    /** Số lượng cột external filter trên mỗi hàng (mặc định: 6) */
    externalFilterPerRow?: 4 | 6;
    /** Chế độ thủ công: phải nhấn nút áp dụng mới gửi filter */
    manualFilter?: boolean;
    /** Có thể thu gọn bộ lọc hay không */
    collapsable?: boolean;
    /** Ẩn toolbar (xóa bộ lọc, thiết lập) của external filter, khi có ít external filter user không cần chức năng này */
    hideExternalFilterToolbar?: boolean;
    /** Hàm xử lý khi trigger clear filter từ external filter */
    onClearFilter?: () => void;
}
export declare const SdConvertToPagingReq: (filterRequest: SdTableFilterRequest, args: {
    columns?: SdTableColumn[];
    externalFilters?: SdTableExternalFilter[];
    fieldMapping?: Record<string, string>;
    orders?: SdOrder[];
}) => SdPagingReq;
export declare type SdTableExternalFilter<TData = any> = TextFilter<TData> | DateFilter<TData> | DateTimeFilter<TData> | DateRangeFilter<TData> | NumberFilter<TData> | ValuesFilter<TData> | LazyValuesFilter<TData> | BooleanFilter<TData> | CustomFilter<TData>;
interface BaseFilter<TData = any> {
    field: string;
    title: string;
    defaultShowing?: boolean;
    required?: boolean;
    hidden?: boolean;
    defaultOperator?: SdOperator;
    data?: TData;
}
interface TextFilter<TData = any> extends BaseFilter<TData> {
    type: 'string';
    default?: string;
}
interface DateFilter<TData = any> extends BaseFilter<TData> {
    type: 'date';
    default?: Date | string;
    minDate?: string | number | Date;
    maxDate?: string | number | Date;
}
interface DateTimeFilter<TData = any> extends BaseFilter<TData> {
    type: 'datetime';
    default?: Date | string;
    minDate?: string | number | Date;
    maxDate?: string | number | Date;
}
interface DateRangeFilter<TData = any> extends BaseFilter<TData> {
    type: 'daterange';
    enableTime?: boolean;
    minDate?: string | number | Date;
    maxDate?: string | number | Date;
    default?: {
        from?: Date | string;
        to?: Date | string;
    };
}
interface NumberFilter<TData = any> extends BaseFilter<TData> {
    type: 'number';
    default?: number;
}
interface ValuesFilter<TData = any> extends BaseFilter<TData> {
    type: 'values';
    option: {
        valueField: string;
        displayField: string;
        items: any[] | (() => Promise<any[]>);
        selection?: 'AUTOCOMPLETE' | 'MULTIPLE' | 'MULTIPLEAUTOCOMPLETE';
    };
    default?: string | string[];
}
interface LazyValuesFilter<TData = any> extends BaseFilter<TData> {
    type: 'lazy-values';
    option: {
        valueField: string;
        displayField: string;
        items: SdSearch;
        selection?: 'MULTIPLE';
    };
    default?: string | string[];
}
interface BooleanFilter<TData = any> extends BaseFilter<TData> {
    type: 'boolean';
    option?: {
        displayOnTrue?: string;
        displayOnFalse?: string;
    };
    default?: boolean;
}
interface CustomFilter<TData = any> extends BaseFilter<TData> {
    type: 'custom';
    filterDef?: TemplateRef<any>;
    default?: any;
}
export interface TableFilterRegister {
    configuration: {
        get: () => TableFilterConfiguration;
        set: (configuration: Partial<TableFilterConfiguration>) => TableFilterConfiguration;
        remove: () => void;
        observer: Observable<TableFilterConfiguration>;
    };
    value: {
        get: () => TableFilterValue;
        set: (value: Partial<TableFilterValue>) => TableFilterValue;
        remove: () => void;
        observer: Observable<TableFilterValue>;
    };
}
export {};
