UNPKG

11.9 kBTypeScriptView Raw
1import { OnChanges, OnDestroy, OnInit, AfterViewInit, ChangeDetectorRef, EventEmitter, TemplateRef, ElementRef, SimpleChanges, QueryList, InjectionToken } from '@angular/core';
2import { ControlValueAccessor } from '@angular/forms';
3import { Subject } from 'rxjs';
4import { ConsoleService } from './console.service';
5import { ItemsList } from './items-list';
6import { NgOption, DropdownPosition } from './ng-select.types';
7import { NgDropdownPanelComponent } from './ng-dropdown-panel.component';
8import { NgOptionComponent } from './ng-option.component';
9import { SelectionModelFactory } from './selection-model';
10import { NgSelectConfig } from './config.service';
11import * as i0 from "@angular/core";
12export declare const SELECTION_MODEL_FACTORY: InjectionToken<SelectionModelFactory>;
13export type AddTagFn = (term: string) => any | Promise<any>;
14export type CompareWithFn = (a: any, b: any) => boolean;
15export type GroupValueFn = (key: string | any, children: any[]) => string | any;
16export declare class NgSelectComponent implements OnDestroy, OnChanges, OnInit, AfterViewInit, ControlValueAccessor {
17 classes: string;
18 private autoFocus;
19 config: NgSelectConfig;
20 private _cd;
21 private _console;
22 bindLabel: string;
23 bindValue: string;
24 markFirst: boolean;
25 placeholder: string;
26 notFoundText: string;
27 typeToSearchText: string;
28 preventToggleOnRightClick: boolean;
29 addTagText: string;
30 loadingText: string;
31 clearAllText: string;
32 appearance: string;
33 dropdownPosition: DropdownPosition;
34 appendTo: string;
35 loading: boolean;
36 closeOnSelect: boolean;
37 hideSelected: boolean;
38 selectOnTab: boolean;
39 openOnEnter: boolean;
40 maxSelectedItems: number;
41 groupBy: string | ((value: any) => any);
42 groupValue: GroupValueFn;
43 bufferAmount: number;
44 virtualScroll: boolean;
45 selectableGroup: boolean;
46 selectableGroupAsModel: boolean;
47 searchFn: any;
48 trackByFn: any;
49 clearOnBackspace: boolean;
50 labelForId: any;
51 inputAttrs: {
52 [key: string]: string;
53 };
54 tabIndex: number;
55 readonly: boolean;
56 searchWhileComposing: boolean;
57 minTermLength: number;
58 editableSearchTerm: boolean;
59 keyDownFn: (_: KeyboardEvent) => boolean;
60 ngClass: any;
61 typeahead: Subject<string>;
62 multiple: boolean;
63 addTag: boolean | AddTagFn;
64 searchable: boolean;
65 clearable: boolean;
66 isOpen?: boolean;
67 get items(): readonly any[] | null | undefined;
68 set items(value: readonly any[] | null | undefined);
69 get compareWith(): CompareWithFn;
70 set compareWith(fn: CompareWithFn);
71 get clearSearchOnAdd(): boolean;
72 set clearSearchOnAdd(value: boolean);
73 get deselectOnClick(): boolean;
74 set deselectOnClick(value: boolean);
75 blurEvent: EventEmitter<any>;
76 focusEvent: EventEmitter<any>;
77 changeEvent: EventEmitter<any>;
78 openEvent: EventEmitter<any>;
79 closeEvent: EventEmitter<any>;
80 searchEvent: EventEmitter<{
81 term: string;
82 items: any[];
83 }>;
84 clearEvent: EventEmitter<any>;
85 addEvent: EventEmitter<any>;
86 removeEvent: EventEmitter<any>;
87 scroll: EventEmitter<{
88 start: number;
89 end: number;
90 }>;
91 scrollToEnd: EventEmitter<any>;
92 optionTemplate: TemplateRef<any>;
93 optgroupTemplate: TemplateRef<any>;
94 labelTemplate: TemplateRef<any>;
95 multiLabelTemplate: TemplateRef<any>;
96 headerTemplate: TemplateRef<any>;
97 footerTemplate: TemplateRef<any>;
98 notFoundTemplate: TemplateRef<any>;
99 placeholderTemplate: TemplateRef<any>;
100 typeToSearchTemplate: TemplateRef<any>;
101 loadingTextTemplate: TemplateRef<any>;
102 tagTemplate: TemplateRef<any>;
103 loadingSpinnerTemplate: TemplateRef<any>;
104 dropdownPanel: NgDropdownPanelComponent;
105 searchInput: ElementRef<HTMLInputElement>;
106 clearButton: ElementRef<HTMLSpanElement>;
107 ngOptions: QueryList<NgOptionComponent>;
108 useDefaultClass: boolean;
109 get disabled(): boolean;
110 get filtered(): boolean;
111 get single(): boolean;
112 itemsList: ItemsList;
113 viewPortItems: NgOption[];
114 searchTerm: string;
115 dropdownId: string;
116 element: HTMLElement;
117 focused: boolean;
118 escapeHTML: boolean;
119 private _items;
120 private _itemsAreUsed;
121 private _defaultLabel;
122 private _primitive;
123 private _manualOpen;
124 private _disabled;
125 private _pressedKeys;
126 private _compareWith;
127 private _clearSearchOnAdd;
128 private _deselectOnClick;
129 private _isComposing;
130 private get _editableSearchTerm();
131 private readonly _destroy$;
132 private readonly _keyPress$;
133 private _onChange;
134 private _onTouched;
135 clearItem: (item: any) => void;
136 constructor(classes: string, autoFocus: any, config: NgSelectConfig, newSelectionModel: SelectionModelFactory | undefined, _elementRef: ElementRef<HTMLElement>, _cd: ChangeDetectorRef, _console: ConsoleService);
137 get selectedItems(): NgOption[];
138 get selectedValues(): any[];
139 get hasValue(): boolean;
140 get currentPanelPosition(): DropdownPosition;
141 ngOnInit(): void;
142 ngOnChanges(changes: SimpleChanges): void;
143 ngAfterViewInit(): void;
144 ngOnDestroy(): void;
145 handleKeyDown($event: KeyboardEvent): void;
146 handleKeyCode($event: KeyboardEvent): void;
147 handleKeyCodeInput($event: KeyboardEvent): void;
148 handleKeyCodeClear($event: KeyboardEvent): void;
149 handleMousedown($event: MouseEvent): boolean;
150 handleArrowClick(): void;
151 handleClearClick(): void;
152 clearModel(): void;
153 writeValue(value: any | any[]): void;
154 registerOnChange(fn: any): void;
155 registerOnTouched(fn: any): void;
156 setDisabledState(state: boolean): void;
157 toggle(): void;
158 open(): void;
159 close(): void;
160 toggleItem(item: NgOption): void;
161 select(item: NgOption): void;
162 focus(): void;
163 blur(): void;
164 unselect(item: NgOption): void;
165 selectTag(): void;
166 showClear(): boolean;
167 focusOnClear(): void;
168 trackByOption: (_: number, item: NgOption) => any;
169 get showAddTag(): boolean;
170 showNoItemsFound(): boolean;
171 showTypeToSearch(): boolean;
172 onCompositionStart(): void;
173 onCompositionEnd(term: string): void;
174 filter(term: string): void;
175 onInputFocus($event: any): void;
176 onInputBlur($event: any): void;
177 onItemHover(item: NgOption): void;
178 detectChanges(): void;
179 private _setSearchTermFromItems;
180 private _setItems;
181 private _setItemsFromNgOptions;
182 private _isValidWriteValue;
183 private _handleWriteValue;
184 private _handleKeyPresses;
185 private _setInputAttributes;
186 private _updateNgModel;
187 private _clearSearch;
188 private _changeSearch;
189 private _scrollToMarked;
190 private _scrollToTag;
191 private _onSelectionChanged;
192 private _handleTab;
193 private _handleEnter;
194 private _handleSpace;
195 private _handleArrowDown;
196 private _handleArrowUp;
197 private _nextItemIsTag;
198 private _handleBackspace;
199 private get _isTypeahead();
200 private get _validTerm();
201 private _mergeGlobalConfig;
202 static ɵfac: i0.ɵɵFactoryDeclaration<NgSelectComponent, [{ attribute: "class"; }, { attribute: "autofocus"; }, null, { optional: true; }, null, null, null]>;
203 static ɵcmp: i0.ɵɵComponentDeclaration<NgSelectComponent, "ng-select", never, { "bindLabel": { "alias": "bindLabel"; "required": false; }; "bindValue": { "alias": "bindValue"; "required": false; }; "markFirst": { "alias": "markFirst"; "required": false; }; "placeholder": { "alias": "placeholder"; "required": false; }; "notFoundText": { "alias": "notFoundText"; "required": false; }; "typeToSearchText": { "alias": "typeToSearchText"; "required": false; }; "preventToggleOnRightClick": { "alias": "preventToggleOnRightClick"; "required": false; }; "addTagText": { "alias": "addTagText"; "required": false; }; "loadingText": { "alias": "loadingText"; "required": false; }; "clearAllText": { "alias": "clearAllText"; "required": false; }; "appearance": { "alias": "appearance"; "required": false; }; "dropdownPosition": { "alias": "dropdownPosition"; "required": false; }; "appendTo": { "alias": "appendTo"; "required": false; }; "loading": { "alias": "loading"; "required": false; }; "closeOnSelect": { "alias": "closeOnSelect"; "required": false; }; "hideSelected": { "alias": "hideSelected"; "required": false; }; "selectOnTab": { "alias": "selectOnTab"; "required": false; }; "openOnEnter": { "alias": "openOnEnter"; "required": false; }; "maxSelectedItems": { "alias": "maxSelectedItems"; "required": false; }; "groupBy": { "alias": "groupBy"; "required": false; }; "groupValue": { "alias": "groupValue"; "required": false; }; "bufferAmount": { "alias": "bufferAmount"; "required": false; }; "virtualScroll": { "alias": "virtualScroll"; "required": false; }; "selectableGroup": { "alias": "selectableGroup"; "required": false; }; "selectableGroupAsModel": { "alias": "selectableGroupAsModel"; "required": false; }; "searchFn": { "alias": "searchFn"; "required": false; }; "trackByFn": { "alias": "trackByFn"; "required": false; }; "clearOnBackspace": { "alias": "clearOnBackspace"; "required": false; }; "labelForId": { "alias": "labelForId"; "required": false; }; "inputAttrs": { "alias": "inputAttrs"; "required": false; }; "tabIndex": { "alias": "tabIndex"; "required": false; }; "readonly": { "alias": "readonly"; "required": false; }; "searchWhileComposing": { "alias": "searchWhileComposing"; "required": false; }; "minTermLength": { "alias": "minTermLength"; "required": false; }; "editableSearchTerm": { "alias": "editableSearchTerm"; "required": false; }; "keyDownFn": { "alias": "keyDownFn"; "required": false; }; "ngClass": { "alias": "ngClass"; "required": false; }; "typeahead": { "alias": "typeahead"; "required": false; }; "multiple": { "alias": "multiple"; "required": false; }; "addTag": { "alias": "addTag"; "required": false; }; "searchable": { "alias": "searchable"; "required": false; }; "clearable": { "alias": "clearable"; "required": false; }; "isOpen": { "alias": "isOpen"; "required": false; }; "items": { "alias": "items"; "required": false; }; "compareWith": { "alias": "compareWith"; "required": false; }; "clearSearchOnAdd": { "alias": "clearSearchOnAdd"; "required": false; }; "deselectOnClick": { "alias": "deselectOnClick"; "required": false; }; }, { "blurEvent": "blur"; "focusEvent": "focus"; "changeEvent": "change"; "openEvent": "open"; "closeEvent": "close"; "searchEvent": "search"; "clearEvent": "clear"; "addEvent": "add"; "removeEvent": "remove"; "scroll": "scroll"; "scrollToEnd": "scrollToEnd"; }, ["optionTemplate", "optgroupTemplate", "labelTemplate", "multiLabelTemplate", "headerTemplate", "footerTemplate", "notFoundTemplate", "placeholderTemplate", "typeToSearchTemplate", "loadingTextTemplate", "tagTemplate", "loadingSpinnerTemplate", "ngOptions"], never, true, never>;
204 static ngAcceptInputType_markFirst: unknown;
205 static ngAcceptInputType_loading: unknown;
206 static ngAcceptInputType_closeOnSelect: unknown;
207 static ngAcceptInputType_hideSelected: unknown;
208 static ngAcceptInputType_selectOnTab: unknown;
209 static ngAcceptInputType_openOnEnter: unknown;
210 static ngAcceptInputType_maxSelectedItems: unknown;
211 static ngAcceptInputType_bufferAmount: unknown;
212 static ngAcceptInputType_virtualScroll: unknown;
213 static ngAcceptInputType_selectableGroup: unknown;
214 static ngAcceptInputType_selectableGroupAsModel: unknown;
215 static ngAcceptInputType_clearOnBackspace: unknown;
216 static ngAcceptInputType_tabIndex: unknown;
217 static ngAcceptInputType_readonly: unknown;
218 static ngAcceptInputType_searchWhileComposing: unknown;
219 static ngAcceptInputType_minTermLength: unknown;
220 static ngAcceptInputType_editableSearchTerm: unknown;
221 static ngAcceptInputType_multiple: unknown;
222 static ngAcceptInputType_searchable: unknown;
223 static ngAcceptInputType_clearable: unknown;
224}