UNPKG

6.25 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright Akveo. All Rights Reserved.
4 * Licensed under the MIT License. See License.txt in the project root for license information.
5 */
6import { AfterViewInit, ChangeDetectorRef, ComponentRef, ElementRef, OnDestroy, Renderer2 } from '@angular/core';
7import { ControlValueAccessor } from '@angular/forms';
8import { Subject } from 'rxjs';
9import { NbOverlayRef, NbScrollStrategy } from '../cdk/overlay/mapping';
10import { NbTriggerStrategy, NbTriggerStrategyBuilderService } from '../cdk/overlay/overlay-trigger';
11import { NbOverlayService } from '../cdk/overlay/overlay-service';
12import { NbAdjustableConnectedPositionStrategy, NbPositionBuilderService } from '../cdk/overlay/overlay-position';
13import { NbActiveDescendantKeyManager, NbActiveDescendantKeyManagerFactoryService } from '../cdk/a11y/descendant-key-manager';
14import { NbScrollStrategies } from '../cdk/adapter/block-scroll-strategy-adapter';
15import { NbOptionComponent } from '../option/option.component';
16import { NbAutocompleteComponent } from './autocomplete.component';
17import * as i0 from "@angular/core";
18/**
19 * The `NbAutocompleteDirective` provides a capability to expand input with
20 * `NbAutocompleteComponent` overlay containing options to select and fill input with.
21 *
22 * @stacked-example(Showcase, autocomplete/autocomplete-showcase.component)
23 *
24 * ### Installation
25 *
26 * Import `NbAutocompleteModule` to your feature module.
27 * ```ts
28 * @NgModule({
29 * imports: [
30 * // ...
31 * NbAutocompleteModule,
32 * ],
33 * })
34 * export class PageModule { }
35 * ```
36 * ### Usage
37 *
38 * You can bind control with form controls or ngModel.
39 *
40 * @stacked-example(Autocomplete form binding, autocomplete/autocomplete-form.component)
41 *
42 * Options in the autocomplete may be grouped using `nb-option-group` component.
43 *
44 * @stacked-example(Grouping, autocomplete/autocomplete-group.component)
45 *
46 * Autocomplete may change selected option value via provided function.
47 *
48 * @stacked-example(Custom display, autocomplete/autocomplete-custom-display.component)
49 *
50 * Also, autocomplete may make first option in option list active automatically.
51 *
52 * @stacked-example(Active first, autocomplete/autocomplete-active-first.component)
53 *
54 * */
55export declare class NbAutocompleteDirective<T> implements OnDestroy, AfterViewInit, ControlValueAccessor {
56 protected hostRef: ElementRef;
57 protected overlay: NbOverlayService;
58 protected cd: ChangeDetectorRef;
59 protected triggerStrategyBuilder: NbTriggerStrategyBuilderService;
60 protected positionBuilder: NbPositionBuilderService;
61 protected activeDescendantKeyManagerFactory: NbActiveDescendantKeyManagerFactoryService<NbOptionComponent<T>>;
62 protected renderer: Renderer2;
63 /**
64 * NbAutocompleteComponent instance passed via input.
65 * */
66 protected _autocomplete: NbAutocompleteComponent<T>;
67 /**
68 * Trigger strategy used by overlay.
69 * @docs-private
70 * */
71 protected triggerStrategy: NbTriggerStrategy;
72 protected positionStrategy: NbAdjustableConnectedPositionStrategy;
73 protected overlayRef: NbOverlayRef;
74 protected keyManager: NbActiveDescendantKeyManager<NbOptionComponent<T>>;
75 protected destroy$: Subject<void>;
76 protected _onChange: (value: T) => void;
77 protected _onTouched: () => void;
78 /**
79 * Determines is autocomplete overlay opened.
80 * */
81 get isOpen(): boolean;
82 /**
83 * Determines is autocomplete overlay closed.
84 * */
85 get isClosed(): boolean;
86 /**
87 * Provides autocomplete component.
88 * */
89 get autocomplete(): NbAutocompleteComponent<T>;
90 set autocomplete(autocomplete: NbAutocompleteComponent<T>);
91 /**
92 * Determines options overlay offset (in pixels).
93 **/
94 overlayOffset: number;
95 /**
96 * Determines options overlay scroll strategy.
97 **/
98 scrollStrategy: NbScrollStrategies;
99 customOverlayHost: ElementRef;
100 get top(): boolean;
101 get bottom(): boolean;
102 role: string;
103 ariaAutocomplete: string;
104 hasPopup: string;
105 get ariaExpanded(): string;
106 get ariaOwns(): string;
107 get ariaActiveDescendant(): string;
108 constructor(hostRef: ElementRef, overlay: NbOverlayService, cd: ChangeDetectorRef, triggerStrategyBuilder: NbTriggerStrategyBuilderService, positionBuilder: NbPositionBuilderService, activeDescendantKeyManagerFactory: NbActiveDescendantKeyManagerFactoryService<NbOptionComponent<T>>, renderer: Renderer2);
109 ngAfterViewInit(): void;
110 ngOnDestroy(): void;
111 handleInput(): void;
112 handleKeydown(): void;
113 handleBlur(): void;
114 show(): void;
115 hide(): void;
116 writeValue(value: T): void;
117 registerOnChange(fn: (value: any) => {}): void;
118 registerOnTouched(fn: any): void;
119 setDisabledState(disabled: boolean): void;
120 protected subscribeOnOptionClick(): void;
121 protected subscribeOnPositionChange(): void;
122 protected getActiveItem(): NbOptionComponent<T>;
123 protected setupAutocomplete(): void;
124 protected getDisplayValue(value: string): string;
125 protected getContainer(): ComponentRef<any>;
126 protected handleInputValueUpdate(value: T, focusInput?: boolean): void;
127 protected subscribeOnTriggers(): void;
128 protected createTriggerStrategy(): NbTriggerStrategy;
129 protected createKeyManager(): void;
130 protected setHostInputValue(value: any): void;
131 protected createPositionStrategy(): NbAdjustableConnectedPositionStrategy;
132 protected subscribeOnOverlayKeys(): void;
133 protected setActiveItem(): void;
134 protected attachToOverlay(): void;
135 protected createOverlay(): void;
136 protected initOverlay(): void;
137 protected checkOverlayVisibility(): void;
138 protected createScrollStrategy(): NbScrollStrategy;
139 protected shouldShow(): boolean;
140 static ɵfac: i0.ɵɵFactoryDeclaration<NbAutocompleteDirective<any>, never>;
141 static ɵdir: i0.ɵɵDirectiveDeclaration<NbAutocompleteDirective<any>, "input[nbAutocomplete]", never, { "autocomplete": { "alias": "nbAutocomplete"; "required": false; }; "overlayOffset": { "alias": "overlayOffset"; "required": false; }; "scrollStrategy": { "alias": "scrollStrategy"; "required": false; }; "customOverlayHost": { "alias": "customOverlayHost"; "required": false; }; }, {}, never, never, false, never>;
142}