UNPKG

11.3 kBTypeScriptView Raw
1import { ChangeDetectorRef, ElementRef, EventEmitter, OnDestroy, OnInit, Renderer2, TemplateRef, ViewContainerRef } from '@angular/core';
2import { NgControl } from '@angular/forms';
3import { ComponentLoaderFactory } from 'ngx-bootstrap/component-loader';
4import { Observable } from 'rxjs';
5import { TypeaheadOptionItemContext, TypeaheadOptionListContext } from './models';
6import { TypeaheadContainerComponent } from './typeahead-container.component';
7import { TypeaheadMatch } from './typeahead-match.class';
8import { TypeaheadOrder } from './typeahead-order.class';
9import { TypeaheadConfig } from './typeahead.config';
10import * as i0 from "@angular/core";
11type TypeaheadOption = string | Record<string | number, any>;
12type TypeaheadOptionArr = TypeaheadOption[] | Observable<TypeaheadOption>;
13export declare class TypeaheadDirective implements OnInit, OnDestroy {
14 private changeDetection;
15 private element;
16 private ngControl;
17 private renderer;
18 /** options source, can be Array of strings, objects or
19 * an Observable for external matching process
20 */
21 typeahead?: TypeaheadOptionArr;
22 /** minimal no of characters that needs to be entered before
23 * typeahead kicks-in. When set to 0, typeahead shows on focus with full
24 * list of options (limited as normal by typeaheadOptionsLimit)
25 */
26 typeaheadMinLength: number;
27 /** sets use adaptive position */
28 adaptivePosition: boolean;
29 /** turn on/off animation */
30 isAnimated: boolean;
31 /** minimal wait time after last character typed before typeahead kicks-in */
32 typeaheadWaitMs: number;
33 /** maximum length of options items list. The default value is 20 */
34 typeaheadOptionsLimit?: number;
35 /** when options source is an array of objects, the name of field
36 * that contains the options value, we use array item as option in case
37 * of this field is missing. Supports nested properties and methods.
38 */
39 typeaheadOptionField?: string;
40 /** when options source is an array of objects, the name of field that
41 * contains the group value, matches are grouped by this field when set.
42 */
43 typeaheadGroupField?: string;
44 /** Used to specify a custom order of matches. When options source is an array of objects
45 * a field for sorting has to be set up. In case of options source is an array of string,
46 * a field for sorting is absent. The ordering direction could be changed to ascending or descending.
47 */
48 typeaheadOrderBy?: TypeaheadOrder;
49 /** should be used only in case of typeahead attribute is Observable of array.
50 * If true - loading of options will be async, otherwise - sync.
51 * true make sense if options array is large.
52 */
53 typeaheadAsync?: boolean;
54 /** match latin symbols.
55 * If true the word súper would match super and vice versa.
56 */
57 typeaheadLatinize: boolean;
58 /** Can be use to search words by inserting a single white space between each characters
59 * for example 'C a l i f o r n i a' will match 'California'.
60 */
61 typeaheadSingleWords: boolean;
62 /** should be used only in case typeaheadSingleWords attribute is true.
63 * Sets the word delimiter to break words. Defaults to space.
64 */
65 typeaheadWordDelimiters: string;
66 /** Can be used to conduct a search of multiple items and have suggestion not for the
67 * whole value of the input but for the value that comes after a delimiter provided via
68 * typeaheadMultipleSearchDelimiters attribute. This option can only be used together with
69 * typeaheadSingleWords option if typeaheadWordDelimiters and typeaheadPhraseDelimiters
70 * are different from typeaheadMultipleSearchDelimiters to avoid conflict in determining
71 * when to delimit multiple searches and when a single word.
72 */
73 typeaheadMultipleSearch?: boolean;
74 /** should be used only in case typeaheadMultipleSearch attribute is true.
75 * Sets the multiple search delimiter to know when to start a new search. Defaults to comma.
76 * If space needs to be used, then explicitly set typeaheadWordDelimiters to something else than space
77 * because space is used by default OR set typeaheadSingleWords attribute to false if you don't need
78 * to use it together with multiple search.
79 */
80 typeaheadMultipleSearchDelimiters: string;
81 /** should be used only in case typeaheadSingleWords attribute is true.
82 * Sets the word delimiter to match exact phrase.
83 * Defaults to simple and double quotes.
84 */
85 typeaheadPhraseDelimiters: string;
86 /** used to specify a custom item template.
87 * Template variables exposed are called item and index;
88 */
89 typeaheadItemTemplate?: TemplateRef<TypeaheadOptionItemContext>;
90 /** used to specify a custom options list template.
91 * Template variables: matches, itemTemplate, query
92 */
93 optionsListTemplate?: TemplateRef<TypeaheadOptionListContext>;
94 /** specifies if typeahead is scrollable */
95 typeaheadScrollable: boolean;
96 /** specifies number of options to show in scroll view */
97 typeaheadOptionsInScrollableView: number;
98 /** used to hide result on blur */
99 typeaheadHideResultsOnBlur?: boolean;
100 /** fired when an options list was opened and the user clicked Tab
101 * If a value equal true, it will be chosen first or active item in the list
102 * If value equal false, it will be chosen an active item in the list or nothing
103 */
104 typeaheadSelectFirstItem: boolean;
105 /** makes active first item in a list */
106 typeaheadIsFirstItemActive: boolean;
107 /** fired when 'busy' state of this component was changed,
108 * fired on async mode only, returns boolean
109 */
110 typeaheadLoading: EventEmitter<boolean>;
111 /** fired on every key event and returns true
112 * in case of matches are not detected
113 */
114 typeaheadNoResults: EventEmitter<boolean>;
115 /** fired when option was selected, return object with data of this option. */
116 typeaheadOnSelect: EventEmitter<TypeaheadMatch<any>>;
117 /** fired when option was previewed, return object with data of this option. */
118 typeaheadOnPreview: EventEmitter<TypeaheadMatch<any>>;
119 /** fired when blur event occurs. returns the active item */
120 typeaheadOnBlur: EventEmitter<TypeaheadMatch<any> | undefined>;
121 /**
122 * A selector specifying the element the typeahead should be appended to.
123 */
124 container?: string;
125 /** This attribute indicates that the dropdown should be opened upwards */
126 dropup: boolean;
127 /** if false restrict model values to the ones selected from the popup only will be provided */
128 /** if false the first match automatically will not be focused as you type */
129 /** format the ng-model result after selection */
130 /** if true automatically select an item when there is one option that exactly matches the user input */
131 /** if true select the currently highlighted match on blur */
132 /** if false don't focus the input element the typeahead directive is associated with on selection */
133 activeDescendant?: string;
134 isOpen: boolean;
135 list: string;
136 _container?: TypeaheadContainerComponent;
137 isActiveItemChanged: boolean;
138 isFocused: boolean;
139 cancelRequestOnFocusLost: boolean;
140 selectItemOnBlur: boolean;
141 protected keyUpEventEmitter: EventEmitter<string>;
142 protected placement: string;
143 protected _matches: TypeaheadMatch[];
144 private _typeahead;
145 private _subscriptions;
146 private _allEnteredValue?;
147 private _outsideClickListener;
148 constructor(cis: ComponentLoaderFactory, config: TypeaheadConfig, changeDetection: ChangeDetectorRef, element: ElementRef, ngControl: NgControl, renderer: Renderer2, viewContainerRef: ViewContainerRef);
149 get matches(): TypeaheadMatch[];
150 ngOnInit(): void;
151 onInput(e: any): void;
152 onChange(event: KeyboardEvent): void;
153 onFocus(): void;
154 onBlur(): void;
155 onKeydown(event: KeyboardEvent): void;
156 changeModel(match?: TypeaheadMatch): void;
157 show(): void;
158 hide(): void;
159 onOutsideClick(): void;
160 ngOnDestroy(): void;
161 protected asyncActions(): void;
162 protected syncActions(): void;
163 protected normalizeOption(option: TypeaheadOption): string;
164 protected tokenizeQuery(currentQuery: string | string[]): string | string[];
165 protected normalizeQuery(value: string): string | string[];
166 protected testMatch(match: string, test: string[] | string): boolean;
167 protected finalizeAsyncCall(matches?: TypeaheadOption | TypeaheadOption[]): void;
168 protected prepareMatches(options: TypeaheadOption | TypeaheadOption[]): void;
169 protected orderMatches(options: TypeaheadOption[]): TypeaheadOption[];
170 protected hasMatches(): boolean;
171 protected checkDelimitersConflict(): void;
172 protected haveCommonCharacters(str1: string, str2: string): boolean;
173 static ɵfac: i0.ɵɵFactoryDeclaration<TypeaheadDirective, never>;
174 static ɵdir: i0.ɵɵDirectiveDeclaration<TypeaheadDirective, "[typeahead]", ["bs-typeahead"], { "typeahead": { "alias": "typeahead"; "required": false; }; "typeaheadMinLength": { "alias": "typeaheadMinLength"; "required": false; }; "adaptivePosition": { "alias": "adaptivePosition"; "required": false; }; "isAnimated": { "alias": "isAnimated"; "required": false; }; "typeaheadWaitMs": { "alias": "typeaheadWaitMs"; "required": false; }; "typeaheadOptionsLimit": { "alias": "typeaheadOptionsLimit"; "required": false; }; "typeaheadOptionField": { "alias": "typeaheadOptionField"; "required": false; }; "typeaheadGroupField": { "alias": "typeaheadGroupField"; "required": false; }; "typeaheadOrderBy": { "alias": "typeaheadOrderBy"; "required": false; }; "typeaheadAsync": { "alias": "typeaheadAsync"; "required": false; }; "typeaheadLatinize": { "alias": "typeaheadLatinize"; "required": false; }; "typeaheadSingleWords": { "alias": "typeaheadSingleWords"; "required": false; }; "typeaheadWordDelimiters": { "alias": "typeaheadWordDelimiters"; "required": false; }; "typeaheadMultipleSearch": { "alias": "typeaheadMultipleSearch"; "required": false; }; "typeaheadMultipleSearchDelimiters": { "alias": "typeaheadMultipleSearchDelimiters"; "required": false; }; "typeaheadPhraseDelimiters": { "alias": "typeaheadPhraseDelimiters"; "required": false; }; "typeaheadItemTemplate": { "alias": "typeaheadItemTemplate"; "required": false; }; "optionsListTemplate": { "alias": "optionsListTemplate"; "required": false; }; "typeaheadScrollable": { "alias": "typeaheadScrollable"; "required": false; }; "typeaheadOptionsInScrollableView": { "alias": "typeaheadOptionsInScrollableView"; "required": false; }; "typeaheadHideResultsOnBlur": { "alias": "typeaheadHideResultsOnBlur"; "required": false; }; "typeaheadSelectFirstItem": { "alias": "typeaheadSelectFirstItem"; "required": false; }; "typeaheadIsFirstItemActive": { "alias": "typeaheadIsFirstItemActive"; "required": false; }; "container": { "alias": "container"; "required": false; }; "dropup": { "alias": "dropup"; "required": false; }; }, { "typeaheadLoading": "typeaheadLoading"; "typeaheadNoResults": "typeaheadNoResults"; "typeaheadOnSelect": "typeaheadOnSelect"; "typeaheadOnPreview": "typeaheadOnPreview"; "typeaheadOnBlur": "typeaheadOnBlur"; }, never, never, false, never>;
175}
176export {};