UNPKG

@c8y/ngx-components

Version:

Angular modules for Cumulocity IoT applications

68 lines 2.62 kB
import { QueryList } from '@angular/core'; import { Observable } from 'rxjs'; import { ListItemComponent } from '../list-group'; import { BsDropdownDirective } from 'ngx-bootstrap/dropdown'; import * as i0 from "@angular/core"; /** * This service provides keyboard navigation for dropdowns. * * It allows to navigate over the items in the dropdown using the keyboard * or search for them. For this to correctly work, the service needs to provided * as component provider in the component. Additionally the `ListItemComponent` * needs to be used in the dropdown items. Also each item needs to have a * span[data-search-label] element to search for the item. */ export declare class SelectKeyboardService { private readonly KEYCODE_UP; private readonly KEYCODE_DOWN; private readonly KEYCODE_TAB; private readonly KEYCODE_ENTER; private readonly KEYCODE_ESC; private readonly KEYCODE_SPACE; private destroyed$; /** * Conifguration options for the keyboard service. */ options: { /** * If true, the input will be cleared when the user selects an item. */ emptyInput: boolean; /** * Search on key event. */ keyboardSearch: boolean; /** * Space key event is used to select. */ spaceSelect: boolean; }; /** * Registers the keyboard event listener for the dropdown. * * @param input The input element to search for items. * @param list A QueryList of all the [ListItemComponent] on which can be searched * @param dropdown The dropdown itself as [BsDropdownDirective]. * @returns A Observable<number> where number is the index of the selected [ListItemComponent] */ register$(input: HTMLInputElement, list: QueryList<ListItemComponent>, dropdown: BsDropdownDirective): Observable<number>; ngOnDestroy(): void; /** * Unregister the keyboard event listner. */ unregister(): void; /** * Returns true if the keyboard event is fired by a selection event (Enter, Down, Tab, Up, Space) * @returns true if the event is a selection event. */ isSelectionEvent(event: KeyboardEvent): boolean; private handleKeyboard; private handleInputBoxSearch; private handleArrowKeySelection; private handleCancel; private selectNextItemOnKeyboardMove; private highlightItem; static ɵfac: i0.ɵɵFactoryDeclaration<SelectKeyboardService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<SelectKeyboardService>; } //# sourceMappingURL=select-keyboard.service.d.ts.map