import * as React from "react";
import { DropdownProps } from "../Dropdown";
import {FormControl, FormControlDefaultProps, FormControlProps} from "./FormControl";

export type MultiSelectProps = DropdownProps & {
    id?: string | number;
    isFilterable?: boolean;
    searchText?: string;
    noResultsText?: string;
    label?: string;
    value?: any;
    testAutomationId?: string;
    className?: string;
    block?: boolean;
    stretch?: boolean;
    listHeader?: any;
    listItemsLimit?: number;
    labelItemsLimit?: number;
    onChange?: (value: any) => void;
    showMoreCountTextTemplate?: string;
    toggleAriaLabel?: string;
    selectedValuesPrefix?: string;
    applyLabelPrefixForSingleMode?: boolean;
    applyLabelPrefixForMultiMode?: boolean;
    ariaLabelledById?: string;
} & FormControlProps & Partial<MultiSelectDefaultProps> & React.HTMLProps<MultiSelect>;

export type MultiSelectDefaultProps = {
    isFilterable: boolean;
    labelItemsLimit: number;
    testAutomationId: string;
    searchText: string;
    noResultsText: string;
    disabled: boolean;
    showMoreCountTextTemplate: string;
} & FormControlDefaultProps;

type MultiSelectState = {
    filterText: string;
    filterRegExp: RegExp | null;
    filterCallback: (label: string, value: any) => boolean;
    isOpen: boolean;
    isMoreShowed: boolean;
    hasFilterFocus: boolean;
};

declare namespace MultiSelectModule {
    class MultiSelectOption extends React.Component<any> {}
    class MultiSelectMasterOption extends React.Component<any> {}
    class MultiSelectOptionGroup extends React.Component<any> {}
    class MultiSelectField extends React.Component<any> {}
}

export class MultiSelect extends FormControl<MultiSelectProps> {
    static Option: typeof MultiSelectModule.MultiSelectOption;
    static MasterOption: typeof MultiSelectModule.MultiSelectMasterOption;
    static Group: typeof MultiSelectModule.MultiSelectOptionGroup;
    static MultiSelectField: typeof MultiSelectModule.MultiSelectField;

    filterByLimit(label: string, value: any): boolean;
    filterByLabelAndLimit(label, value): boolean;
    outputConverter(e: any): any;
    getValue(): null;
    onToggle(isOpen: boolean): void;
    onKeyDown(event: React.KeyboardEvent<any>): void;
    setTextFilter(text: string): void;
    showMore(event: React.MouseEvent<any>): void;
    renderShowMore(): React.ReactNode;
}