UNPKG

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