import { EventEmitter, OnInit, OnChanges, SimpleChanges, AfterViewInit } from '@angular/core';
import { FormControl } from "@angular/forms";
import { TranslateService } from "@ngx-translate/core";
import { FormControlBase } from '../form-control-base';
import { Observable } from 'rxjs';
import { TextboxComponent } from '../textbox/textbox.component';
import { ValidationMessageService } from '../../core/validation-message.service';
import { FormGroupHelper } from '../../shared/form-group.helper';
import { MenuItem, MenuTemplateType, MenuHostElementClasses } from '../menu/menu.component';
import { PopupStatus } from '../../shared/directives/popup/popup-container.directive';
import { ScrollService } from '../../core/scroll.service';
/**
 * Position of the menu relative to the input
 */
export declare type ComboboxMenuPosition = "top_right" | "top_left" | "bottom_left" | "bottom_right";
/**
 * The type of add new implementation. Static displays a simple static button while dynamic updates
 * the label of the button with value of the textbox
 */
declare type AddNewType = "dynamic" | "static" | boolean;
/**
 * Select box (select, autocomplete, combobox)
 *
 * NOTE: Min/max length validation is implemented on the internal ec-textbox.
 * Values passed in via input properties (@see maxlength , @see minlength )
 * are used to create validators on the textbox.  When the validation on the
 * textbox fails, the validation error(s) get passed up to the {@see formModel }.
 * When setting up this component's {@see FormControl }, you do NOT need to set the
 * Validators.minLength or Validators.maxLength validators.
 *
 * Required is also passed via input property, but you SHOULD also set up the
 * Validators.required validator on this component's FormControl.
 *
 * @export
 */
export declare class ComboboxComponent extends FormControlBase implements OnInit, OnChanges, AfterViewInit {
    protected validationMessageService: ValidationMessageService;
    protected formGroupHelper: FormGroupHelper;
    protected translate: TranslateService;
    protected scrollService: ScrollService;
    /**
     * Close the popup menu on resize so the width and positioning can be recalculated
     * correctly. Cannot be placed on the popupDirective because of a bug where
     * HostListeners for global events don't fire
     * @see https://github.com/angular/angular/issues/14191
     */
    onResize(): void;
    /**
     * Show the add new button in the popup
     */
    addNew?: AddNewType;
    /**
     * The maximum number of characters allowed in the input.
     *
     * @memberof TextboxComponent
     */
    maxlength?: number;
    /**
     * Position of the menu relative to the text box
     * @default 'bottom_right'
     * @memberof ComboboxComponent
     */
    menuPosition?: ComboboxMenuPosition;
    /**
     * The minimum number of characters allowed in the input
     *
     * @memberof TextboxComponent
     */
    minlength?: number;
    /**
     * Items to show in combobox menu
     *
     * @memberof ComboboxComponent
     */
    options: Array<MenuItem>;
    /**
     * Display template for menu items
     *
     * @memberof ComboboxComponent
     */
    templateType: MenuTemplateType;
    /**
     * Position the menu as fixed, ideal when comboboxes are inside dialogs
     * Defaulting to true so all menus will be at least the width of the
     * textbox + button, but can grow wider if the inner elements need it
     */
    popupFixed: boolean;
    /**
     * The total number of records from the datasource
     */
    totalRecords?: number;
    /**
     * If set to true, we will upperCase the text box and apply the class on the add box
     */
    upperCase: boolean;
    /**The placeholder to show in the combobox. Leave empty to use default behavior determined
     * by whether Add New is enabled
     */
    placeholder: string;
    /** Observable to subscribe to when the combobox menu is opened for the first time */
    loadOnOpenObservable?: Observable<MenuItem[]> | undefined;
    /** Do not display the toggle button when true */
    hideToggleButton: boolean;
    /**
     * Always show the menu when the formModel has a value. Sets
     * hideToggleButton to true and menuStatus to visible as well.
     */
    alwaysOpen: boolean;
    /**
     * Additonal classes to apply to the ec-menu element
     */
    menuElementClasses: MenuHostElementClasses | string[];
    /**
     * Additional classes to apply to the .textbox-group element
     */
    textboxElementClasses: string[];
    /** Hide 'No matches' message when true */
    hideNoMatches: boolean;
    /**
     * Text to show when the menu is empty. "No matches" is the default.
     */
    noMatchesText: string;
    /**
     * Notify the parent that the add new button was clicked
     * @todo discuss if we need to send along the value or should
     * the parent get it from the formModel
     * (lwf 2017.07.13): I think we might as well send the value along and
     * leave it up to the parent to decide how to handle it.
     */
    addNewClick: EventEmitter<string>;
    /**
     * Notify parent when text typed into textbox
     */
    search: EventEmitter<string>;
    textbox: TextboxComponent;
    /**
     * Access to the menu's component via the  {@link PopupContainerDirective}
     */
    private popup?;
    /**
     * Reference the add-new button element
     */
    private addNewButton;
    /**
       * Filtered Items to show in combobox menu
       */
    filteredOptions: Array<MenuItem>;
    /**
     * Tracks if the menu is open or hidden
     */
    menuStatus: PopupStatus;
    /**
     * Placeholder to assign to textbox
     */
    effectivePlaceholder: string;
    /**
     * Reference to the currently-selected menu item
     */
    selectedItem: MenuItem | null;
    /**
     * FormControl for the textbox
     */
    textboxFormModel: FormControl;
    /**
     * Tracks whether the add new button is selected
     */
    addNewSelected: boolean;
    /**
     * Tracks whether the textboxFormModel value matches an item in the filteredOptions
     */
    foundMatch: boolean;
    /**
     * Index of the currently-selected options
     */
    private selectedItemIndex;
    /** Placeholder text for 'Choose or Add...' */
    private chooseOrAddPlaceholder;
    /** Placeholder text for 'Choose' */
    private choosePlaceholder;
    private hasDataBeenLoadedOnOpen;
    constructor(validationMessageService: ValidationMessageService, formGroupHelper: FormGroupHelper, translate: TranslateService, scrollService: ScrollService);
    /**
     * The angular onChanges lifecycle event
     * @see https://angular.io/guide/lifecycle-hooks
     */
    ngOnChanges(changes: SimpleChanges): void;
    /**
     * The angular onInit lifecycle hook
     * @see https://angular.io/guide/lifecycle-hooks
     */
    ngOnInit(): void;
    /**
     * The angular afterViewInit lifecycle hook
     * @see https://angular.io/guide/lifecycle-hooks
     */
    ngAfterViewInit(): void;
    /**
     * Set errors on the textboxFormModel, which will then set errors on the
     * formModel. Also mark the formModel as touched to display any errors.
     * @param errors key(s) of ValidationMessageService errors to display or remove
     * @memberof ComoboboxComponent
     */
    setErrors(errors: {
        [key: string]: boolean;
    }): void;
    /**
     * Unfilter options and update the selectedItem and selectedItemIndex
     * @memberof ComboboxComponent
     */
    resetOptions(options?: MenuItem[]): void;
    /**
     * Listen to the selected changed event from {@link MenuComponent} and update the form
     * model and close menu
     */
    selectedChanged(item: MenuItem): void;
    /**
     * Show and hide the popup menu
     *
     * @memberof ComboboxComponent
     */
    toggleMenu(event?: Event): void;
    onBlur(): void;
    /**
     * Control the menu with keyboard navigation
     *
     * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key#Example | KeyboardEvent.key}
     * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values | Key Values}
     *
     * @memberof ComboboxComponent
     */
    keyNavigate(event: KeyboardEvent): void;
    /**
     * Facilitates adding items to a combobox
     *
     * @param addFn Function from parent that should make an API request to add a new item to the combobox's options
     * @memberof ComboboxComponent
     */
    addNewItem(addFn: () => Promise<void>): Promise<void>;
    /**
     * Figure out whether they are adding new or have an item selected, and commit it to the form model
     */
    private commitSelection;
    /**
     * Send the current value of the textbox to the parent when the add new button is
     * clicked
     *
     * @param event Add new button click or enter key event
     * @memberof ComboboxComponent
     */
    onAddNew(event: Event): void;
    /**
     * Navigate the dropdown menu using up and down arrow keys
     *
     * @param event Up or down arrow keydown event
     * @memberof ComboboxComponent
     */
    private onArrowDownUp;
    /**

     * Filter array of options by label (contains)
     *
     * @param filterText The value of textbox that we will filter our options by
     *
     * @memberof ComboboxComponent
     */
    private filterOptionsArray;
    /**
     * Find a given item's index in the filtered items array.
     *
     * Returns -1 if not found
     * @param item The matching item to find in the
     * filterdOptions array. Will use the selectedItem if nothing is passed.
     * @memberof ComboboxComponent
     */
    private findSelectedItemIndex;
    /**
     * React to our formModel changing
     *
     * The formModel represents the currently selected ModelItem
     * When changed, set the value of the TextboxComponent and
     * find index of item in options list.
     *
     * @memberof ComboboxComponent
     */
    private formModelChanged;
    /**
     * Scroll the menu if the current selectedItemIndex is out of view
     *
     * @memberof ComboboxComponent
     */
    private scrollMenu;
    /**
     * Search/Filter based on textbox input
     * NOTE: so as not to receive a notification on every key event, we suggest you debounce your
     * subscription
     * @see {@link http://reactivex.io/rxjs/class/es6/Observable.js~Observable.html#instance-method-debounceTime | Observable.debounceTime}
     *
     * @memberof ComboboxComponent
     */
    private searchAndFilter;
    /**
     * Set {@link formModel }'s validation errors equal to the internal textbox's.
     *
     * When the internal textbox is invalid, need to set this control's
     * errors because we are using our own label, not TextboxControl's.
     * We use our own label so label text will wrap at the end of the button,
     * not at the end of the textbox.
     *
     * @memberof ComboboxComponent
     */
    private setFormModelValidationErrors;
    /**
     * Update the form model value with the selected item or reset form model value if item is null
     *
     * @memberof ComboboxComponent
     */
    private setFormModelValue;
    /**
     * Set validators on the {@see textboxFormModel }
     *
     * Validators are currently set based on the {@see maxlength },
     * {@see minlength }, and {@see required } inputs.  This works well
     * with {@see TextboxComponent }, which needs these inputs to apply
     * the proper attributes to its inputs.
     *
     * A future release of Angular will supposedly add these attributes
     * for you, which will eliminate the need for TextboxComponent to have
     * such inputs.  This component, however, will still need these inputs
     * as there is no current way to know which validators are applied to it
     * from its parent View Component.
     *
     *
     * @memberof ComboboxComponent
     */
    private setTextboxFormModelValidators;
    /**
     * Keep textbox's disabled status in-sync with combobox's
     *
     * {@link TextboxComponent} gets its disabled status from its {@link FormControl}
     *
     * @memberof ComboboxComponent
     */
    private synchronizeDisabledAttributes;
    /**
     * If the formModel value and textbox value do not match, reset the textbox and selectedItem to
     * the formModle value. If there is no formModel value, make sure we clear the textbox. Reset the
     * filteredOptions to the full list and update the selectedItemIndex
     *
     */
    private syncModelValues;
    /**
     * Search and filter the options list when the value of the textbox input changes. If addNew is
     * set also check for matches in our filteredOptions to conditionally show and hide the add new
     * button
     *
     * @see https://developer.mozilla.org/en-US/docs/Web/Events/input
     */
    textboxValueChanged(event: Event): void;
    private clearSelectedItem;
    /**Recompute what the placeholder should be based on whether the user provided one and the current state of the addNew input */
    private updatePlaceholderText;
    /**Find the option we want to be the default selection. If there is an exact match, use that
     * otherwise if there are items, return zero to indicate the first item. Otherwise return -1
     * to indicate no selection
     */
    private findDefaultSelectionIndex;
}
export {};
