import { ChangeDetectorRef, ElementRef, OnDestroy } from '@angular/core'; import { Observable } from 'rxjs'; import { KitFocusListenerService } from '../kit-focus-listener/kit-focus-listener.service'; import { KitPlatformService } from '../kit-platform/kit-platform.service'; import { KitSelectFilter, KitSelectInputView, KitSelectItem, KitSelectItemView, KitSelectOptions, KitSelectSearchFn } from './meta'; /** * Service for handling state of extended selector. * Should be provided on a component. * * * ### Example * * * collection:ext-select - [demo](https://ngx-kit.com/collection/module/ui-ext-select) */ export declare class KitSelectService implements OnDestroy { private elRef; private platform; private cdr; private focusListener; /** * Is control disabled. */ disabled: boolean; /** * @input */ private readonly _items; /** * @input */ private _searchFn?; /** * @input */ private readonly _filter; /** * @input */ private readonly _options; /** * @input */ private _multiple?; private readonly searchItems; private selectRef; private readonly _inputView; private readonly _itemsView; private readonly _focused; private readonly _itemsDisplay; private readonly _model; private readonly userInputs; private readonly _input; private readonly selections; private readonly removals; private readonly _loading; private readonly _active; private readonly mouseDowns; private readonly keyDowns; private destroy; /** * ValueAccessor changes. */ private _vaChanges; private _vaTouches; private _viewChanges; constructor(elRef: ElementRef, platform: KitPlatformService, cdr: ChangeDetectorRef, focusListener: KitFocusListenerService); ngOnDestroy(): void; /** * Is options should be displayed. */ itemsDisplay: boolean; /** * Observable with `itemsDisplay`. */ readonly itemsDisplayChanges: Observable; /** * List of options to display. */ readonly options: KitSelectOptions; /** * Observable with `options`. */ readonly optionsChanges: Observable; /** * Observable that emits when view should be updated. */ readonly viewChanges: Observable; /** * Set list of items to pick. */ items: KitSelectItem[]; /** * Emits when items array changed by item selection. */ readonly itemsChanges: Observable[]>; /** * Search function will be used instead of filter. The function should return list of items to pick. * * After pick, in addition to `ngModel` update, picked item will be merged into `[items]` array, updated array will be emitted via * `(itemsChange)` output. So you can use two-way binding here: `<... [(items)]="selectItems">`. * * Fits to async search or autocomplete. * * Enables autocomplete mode. */ searchFn: KitSelectSearchFn | undefined; /** * True if items received from `searchFn` instead of `items`. */ readonly isAutocomplete: boolean; /** * Set current value of the control. */ model: M | M[] | undefined; /** * Observable with `model`. */ readonly modelChanges: Observable; /** * View displayed in input section. * * @deprecated Use `.inputViews` instead. * * @todo Remove in the next major release. */ readonly inputView: KitSelectInputView | KitSelectInputView[] | undefined; /** * View displayed in input section. * Always returns an array. For non-multiple select use the first item: `inputViews[0]`. */ readonly inputViews: KitSelectInputView[]; /** * Observable with `inputView`. */ readonly inputViewChanges: Observable[] | undefined>; /** * Prepared view of items list. */ readonly itemsView: KitSelectItemView[]; /** * Observable with `itemsView`. */ readonly itemsViewChanges: Observable[]>; /** * Set filter to search through the current list of `[items]`. */ filter: KitSelectFilter | undefined; /** * Observable with `filter`. */ readonly filterChanges: Observable>; /** * Set value entered by user. */ input: string; /** * Observable with `input`. */ readonly inputChanges: Observable; /** * Indicate that select should has input for filtering or search. */ readonly searchable: KitSelectSearchFn | "includes" | "startsWith" | "endsWith" | import("./meta").KitSelectFilterFn | undefined; /** * Is request pending now. */ readonly loading: boolean; /** * Observable with `loading`. */ readonly loadingChanges: Observable; /** * Is select works in multiple mode. */ /** * Enables multiple select. */ multiple: boolean | undefined; /** * Check model is clearable. */ readonly isClearable: boolean | M | M[] | undefined; /** * Highlighted item's model. */ /** * Set current active option. */ active: M | undefined; /** * Observable with `active`. */ readonly activeChanges: Observable; /** * Is control focused now. */ readonly focused: boolean; /** * Observable with `focused`. */ readonly focusedChanges: Observable; /** * Register `ElementRef` of select element. */ registerSelectRef(selectRem: ElementRef): void; /** * Additional configuration. * If some values are not defined, will be used default value. */ overrideOptions(options: Partial): void; /** * Update options. * If some values are not defined, will be used current value. */ updateOptions(options: Partial): void; /** * Register value accessor hook. */ registerOnChange(fn: any): void; /** * Register value accessor hook. */ registerOnTouched(fn: any): void; /** * Call when input changes by user. */ userInput(input: string): void; /** * Call when user click on component. */ mousedown(event?: any): void; /** * Call when user focus component. */ focus(): void; /** * Call when user leave the component. */ blur(): void; /** * Call when user pick an item. */ select(model: M | undefined): void; /** * Remove item from model. * Needed for multiple mode. * * Call without param to reset model to undefined (or empty array if multiple). */ remove(model?: M): void; /** * Value accessor hook. */ writeValue(model: M | M[]): void; /** * Move active cursor. */ moveActive(modifier: number): void; /** * Initialize automatic change detection run. */ initChangeDetection(): void; private handleItemsDisplay; private handleItemsDisplayInSelectMode; private handleItemsDisplayInAutocompleteMode; private handleInput; /** * Search handlers (in autocomplete mode). */ private handleSearch; private processSearch; /** * Handle keyboard. */ private handleKeyboard; private error; private handleItemsView; private updateItemsView; private handleModel; /** * Merge items from search to the main items array. */ private mergeSearchItem; private handleActive; private handleInputView; private updateInputView; private getItemInputView; private handleSelect; private handleRemoval; private handleChangeDetection; private handleFocus; }