/** Core */ import { CoreComponent } from "cmf.core/src/core"; /** Angular2 */ import * as ng from "@angular/core"; import { DropdownElement, DropdownState, ComparisonMode } from "./dropdownStructure"; import { DropdownService } from "./dropdownService"; export { DropdownElement, DropdownState, DropdownHighlight, DropdownPositions, DropdownMultiSelection, DropdownClearMultiSelection, ComparisonMode } from "./dropdownStructure"; export declare class DropdownTitle { } export declare const CLOSE_LISTENER_EVENTS: string[]; /** * Number of items needed for the search bar to show up */ export declare const MIN_NUMBER_OF_ITEMS_FOR_SEARCH: number; /** * @whatItDoes * This component serves as a container for templates of items served in a dropDown menu. * It performs simple tasks, such as: * 1. Display the dropDown header; * 2. Open/close the dropDown list; * 3. Show items in list. * * @howToUse * This component is not supposed to handle complex tasks besides show and handle click events. * Each list item receives an object with "item" property, that contains the current item data that is being displayed. * * ### Inputs * `any[]` : **items** - An array of items to the displayed. Each array item will be injected in the template provided ; * `boolean` : **customHeader** - True if given header should be used as full header or false if default header with title should be used ; * `boolean` : **search** - If set to true, a search box will appear for the user to filter the items in the dropdown. Defaults to false ; * `string` : **searchPath** - Path to apply to the item on doing search string comparison. If not defined it will attempt to search by the item itself as if * items was a string[] ; * `boolean` : **multiSelection** - Allows multiple selection of dropdown elements. defaults to false ; * `string[]` : **multiSelectItems** - Items to be pre-selected when the user opens the dropdown or already selected when immediateSelection is true ; * `string[]` : **disabledItems** - Items that cannot be selected ; * `string[]` : **notSelectableItems** - Items that won't have a check box even when multi selection is enabled and won't be interactable in any way; * `boolean` : **disabled** - If set to true will disable the dropdown title and disable opening the dropdown. default is false ; * `any` : **template** - Custom template reference for list item ; * `boolean` : **immediateSelection** - If set to true and multiSelection is true, dropdown will not allow pre selection, Ok and Cancel button will disappear * dropdown will not allow pre selection, Ok and Cancel button will disappear and any selection made will be effective as soon as user selects a value . * `boolean´ : **comboboxAlike** - If set true, the dropdown will have a behaviour like a Combobox * `boolean´ : **customItemContent** - Content item projection; * `boolean´ : **calculateDropdownLeft** - Calculate dropdown left position; * `boolean´ : **mobileFilterDropdown** - If we want to enable the filter dropdown mobile version. * ´function´ : **compareFunctionForSelection** - Compare function to be used for item selection * `ComparisonMode` : **comparisonMode** - Comparison mode used for selection, by default is strict Strict meaning * that === will be used, otherwhise relaxed meaning that %string% is used, * in the next major default will be changed to . * `any` : **itemSelected** - Sets the currently selected value on the dropdown. * `boolean` : **showSelectedItemsPlaceholder** - Places a placeholder after the title dropdown indicating the selected items. Defaults to false. * * ### Outputs * `DropdownElement | DropdownElement[]` : **onItemSelect** - Dispatch an event when an item is selected ; * Event includes the index and the item itself. Emits and array when multiSelection is set ; * `any` : **onOpen** - Dispatch an event when the dropdown is opened. Event includes the dropdown instance (this component) ; * `any` : **onClose** - Dispatch an event when the dropdown is closed. Event includes the dropdown instance (this component) . * * ### Example * To use the component, assume this HTML Template as an example: * * ```HTML * * * My title * * * * {{item}} * * * ``` * */ export declare class Dropdown extends CoreComponent implements ng.DoCheck, ng.OnDestroy, ng.OnChanges, ng.AfterContentInit, ng.AfterViewInit { private _iterableDiffers; private _elementRef; private _ngZone; private _renderer; private _parentElementRef; private _dropdownService; items: any[]; /** * Event emitter for changes */ onItemSelect: ng.EventEmitter | DropdownElement[]>; /** * Event emitter for dropdown open */ onOpen: ng.EventEmitter; /** * Event emitter for dropdown close. */ onClose: ng.EventEmitter; /** * Public state for this dropdown */ state: DropdownState; /** * If set to true, a search box will appear for the user to filter the items in the dropdown. Defaults to false */ search: boolean; /** * Path to apply to the item on doing search string comparison */ searchPath: string; /** * Allows multiple selection of dropdown elements */ multiSelection: boolean; /** * If set to true, will disable the dropdown title */ disabled: boolean; /** * Items to be pre-selected when the user opens the dropdown */ multiSelectItems: string[]; /** * Items that will be disabled in the dropdown */ disabledItems: string[]; /** * Items in the dropdown that won't have a checkbox - event when multi selection is enabled */ notSelectableItems: string[]; /** * Use custom header (full replace the header for the ones given) * Default to false. */ _customHeader: boolean; /** * Comparison mode used for selection, by default is Strict meaning that === will be used otherwise if Relaxed %string% is used */ comparisonMode: ComparisonMode; _itemTemplate: ng.TemplateRef; /** * Item template received by input. Overrides _itemTemplate if defined. */ _itemTemplateInput: ng.TemplateRef; /** * * if set to true and multiSelection is true, dropdown will not allow pre selection, Ok and Cancel button will disappear and any * selection made will be effective as soon as user selects a value * Default to false */ immediateSelection: boolean; /** * Compare function that will be used for item selection */ compareFunctionForSelection: (targetItem: string, compareObj: any) => boolean; imediateSelection: boolean; /** * If set true the dropdown behaivour is similiar to a Combobox */ comboboxAlike: boolean; /** * If a placeholder indicating the selected items is to be automatically shown after the title dropdown */ showSelectedItemsPlaceholder: boolean; /** * Holds the unique item when there's only one element selected */ _placeholderText: string; _renderedItems: DropdownElement[]; /** * Number of selected and confirmed items in multi-selection */ _selectedCount: number; /** * Items rendered after search is applied */ _filteredItems: DropdownElement[]; /** * Stores the top position of the dropDown to optimize calculation */ _dropDownTop: number; /** * Stores the left position of the dropDown to optimize calculation */ _dropDownLeft: number; /** * Stores a unique id to identify the connection between the dropdown component and the dropdown element */ _uniqueId: string; /** * Toggle element */ _toggleElement: ng.ElementRef; /** * DropdownElement highlighted with arrows up or down */ _highlightedDropdown: DropdownElement; /** * DropdownElement value highlighted */ _highlightedItem: string; /** * Custom item content */ customItemContent: boolean; /** * Calculate dropdownLeft */ calculateDropdownLeft: boolean; /** * Mobile filter dropdown */ mobileFilterDropdown: boolean; /** * Stores the Item Selected */ itemSelected: any; /** * Stores the Index of the Item Selected */ itemSelectedIndex: number; private _dropdownMenu; private _searchBox; /** * Stores the dropDown element attached to body to destroy later */ private _dropdownElementAppendedToMain; /** * Iterable differ */ private _iterableDiffer; /** * OnClick/toggle body event listener. * This is used to handle the event when the dropdown is open. */ private _closeHandler; /** * Open handler */ private _openHandler; /** * Constructor * @param _iterableDiffers * @param _elementRef * @param _ngZone * @param _renderer * @param _parentElementRef * @param _dropdownService */ constructor(_iterableDiffers: ng.IterableDiffers, _elementRef: ng.ElementRef, _ngZone: ng.NgZone, _renderer: ng.Renderer, _parentElementRef: ng.ElementRef, _dropdownService: DropdownService); private setupOpenHandler; /** * Changes the header placeholder text to be rendered in the dom * @param selectedItems The items selected */ private evaluatePlaceholderText; /** * gets called to check the changes in the directives in addition to the default algorithm. */ ngDoCheck(): void; /** * Remove event listeners */ ngOnDestroy(): void; /** * Update multi select items if changed * @param changes */ ngOnChanges(changes: any): void; /** * After component content is initiated set the time span picker on body */ ngAfterContentInit(): void; /** * Angular Lifecycle hook that is called after a component's view has been fully initialized */ ngAfterViewInit(): void; /** * Handle a click on the list item. * Dispatch an event to the parent with the selected item. * @param item */ _onItemSelect(item: DropdownElement): void; /** * For open and close dropdown * @param event */ toggle: (event?: Event) => void; /** * Calculate dropdown width * @param isToggle */ calculateSize(isToggle?: boolean): void; /** * Apply search according to value filtering the items * @param value */ filterByValue(value: string): void; /** * Confirm multi selection, close the dropdown and emit the event */ confirmMultiSelection(): void; /** * Clears the items selected * @param forceClear if set to true clears also the preselected items otherwise keeps the previous configuration */ clearMultiSelection(forceClear?: boolean): void; /** * Highlight a dropdown element and move dropdown to show item if hidden * @param itemValue */ highlightItem(itemValue: string): void; } export declare class DropdownModule { }