UNPKG

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