@sourceloop/search-client 4.3.2 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -16
- package/esm2020/lib/lib-configuration.mjs +63 -0
- package/esm2020/lib/search/search.component.mjs +315 -0
- package/esm2020/lib/search-lib.module.mjs +50 -0
- package/{esm2015/lib/types.js → esm2020/lib/types.mjs} +0 -0
- package/{esm2015/public-api.js → esm2020/public-api.mjs} +0 -0
- package/{esm2015/sourceloop-search-client.js → esm2020/sourceloop-search-client.mjs} +0 -0
- package/fesm2015/sourceloop-search-client.mjs +449 -0
- package/fesm2015/sourceloop-search-client.mjs.map +1 -0
- package/fesm2020/sourceloop-search-client.mjs +443 -0
- package/fesm2020/sourceloop-search-client.mjs.map +1 -0
- package/lib/search/search.component.d.ts +3 -0
- package/lib/search-lib.module.d.ts +13 -0
- package/package.json +33 -21
- package/sourceloop-search-client.d.ts +1 -0
- package/bundles/sourceloop-search-client.umd.js +0 -428
- package/bundles/sourceloop-search-client.umd.js.map +0 -1
- package/esm2015/lib/lib-configuration.js +0 -66
- package/esm2015/lib/lib-configuration.ngsummary.json +0 -1
- package/esm2015/lib/search/search.component.js +0 -297
- package/esm2015/lib/search/search.component.ngfactory.js +0 -129
- package/esm2015/lib/search/search.component.ngsummary.json +0 -1
- package/esm2015/lib/search/search.component.scss.shim.ngstyle.js +0 -9
- package/esm2015/lib/search-lib.module.js +0 -29
- package/esm2015/lib/search-lib.module.ngfactory.js +0 -32
- package/esm2015/lib/search-lib.module.ngsummary.json +0 -1
- package/esm2015/lib/types.ngsummary.json +0 -1
- package/esm2015/public-api.ngsummary.json +0 -1
- package/esm2015/sourceloop-search-client.ngsummary.json +0 -1
- package/fesm2015/sourceloop-search-client.js +0 -408
- package/fesm2015/sourceloop-search-client.js.map +0 -1
- package/lib/search/search.component.ngfactory.d.ts +0 -1
- package/lib/search/search.component.scss.shim.ngstyle.d.ts +0 -1
- package/lib/search-lib.module.ngfactory.d.ts +0 -3
- package/sourceloop-search-client.metadata.json +0 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
2
|
+
import { HttpClientModule } from '@angular/common/http';
|
|
3
|
+
import { NgModule } from '@angular/core';
|
|
4
|
+
import { FlexLayoutModule } from '@angular/flex-layout';
|
|
5
|
+
import { FormsModule } from '@angular/forms';
|
|
6
|
+
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
7
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
8
|
+
import { MatInputModule } from '@angular/material/input';
|
|
9
|
+
import { MatSelectModule } from '@angular/material/select';
|
|
10
|
+
import { SearchComponent } from './search/search.component';
|
|
11
|
+
import * as i0 from "@angular/core";
|
|
12
|
+
export class SearchLibModule {
|
|
13
|
+
}
|
|
14
|
+
SearchLibModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: SearchLibModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
15
|
+
SearchLibModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: SearchLibModule, declarations: [SearchComponent], imports: [CommonModule,
|
|
16
|
+
FormsModule,
|
|
17
|
+
HttpClientModule,
|
|
18
|
+
MatSelectModule,
|
|
19
|
+
MatFormFieldModule,
|
|
20
|
+
MatIconModule,
|
|
21
|
+
MatInputModule,
|
|
22
|
+
FlexLayoutModule], exports: [SearchComponent] });
|
|
23
|
+
SearchLibModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: SearchLibModule, imports: [[
|
|
24
|
+
CommonModule,
|
|
25
|
+
FormsModule,
|
|
26
|
+
HttpClientModule,
|
|
27
|
+
MatSelectModule,
|
|
28
|
+
MatFormFieldModule,
|
|
29
|
+
MatIconModule,
|
|
30
|
+
MatInputModule,
|
|
31
|
+
FlexLayoutModule,
|
|
32
|
+
]] });
|
|
33
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: SearchLibModule, decorators: [{
|
|
34
|
+
type: NgModule,
|
|
35
|
+
args: [{
|
|
36
|
+
declarations: [SearchComponent],
|
|
37
|
+
imports: [
|
|
38
|
+
CommonModule,
|
|
39
|
+
FormsModule,
|
|
40
|
+
HttpClientModule,
|
|
41
|
+
MatSelectModule,
|
|
42
|
+
MatFormFieldModule,
|
|
43
|
+
MatIconModule,
|
|
44
|
+
MatInputModule,
|
|
45
|
+
FlexLayoutModule,
|
|
46
|
+
],
|
|
47
|
+
exports: [SearchComponent],
|
|
48
|
+
}]
|
|
49
|
+
}] });
|
|
50
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VhcmNoLWxpYi5tb2R1bGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvbGliL3NlYXJjaC1saWIubW9kdWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBQyxZQUFZLEVBQUMsTUFBTSxpQkFBaUIsQ0FBQztBQUM3QyxPQUFPLEVBQUMsZ0JBQWdCLEVBQUMsTUFBTSxzQkFBc0IsQ0FBQztBQUN0RCxPQUFPLEVBQUMsUUFBUSxFQUFDLE1BQU0sZUFBZSxDQUFDO0FBQ3ZDLE9BQU8sRUFBQyxnQkFBZ0IsRUFBQyxNQUFNLHNCQUFzQixDQUFDO0FBQ3RELE9BQU8sRUFBQyxXQUFXLEVBQUMsTUFBTSxnQkFBZ0IsQ0FBQztBQUMzQyxPQUFPLEVBQUMsa0JBQWtCLEVBQUMsTUFBTSw4QkFBOEIsQ0FBQztBQUNoRSxPQUFPLEVBQUMsYUFBYSxFQUFDLE1BQU0sd0JBQXdCLENBQUM7QUFDckQsT0FBTyxFQUFDLGNBQWMsRUFBQyxNQUFNLHlCQUF5QixDQUFDO0FBQ3ZELE9BQU8sRUFBQyxlQUFlLEVBQUMsTUFBTSwwQkFBMEIsQ0FBQztBQUV6RCxPQUFPLEVBQUMsZUFBZSxFQUFDLE1BQU0sMkJBQTJCLENBQUM7O0FBZ0IxRCxNQUFNLE9BQU8sZUFBZTs7NkdBQWYsZUFBZTs4R0FBZixlQUFlLGlCQWJYLGVBQWUsYUFFNUIsWUFBWTtRQUNaLFdBQVc7UUFDWCxnQkFBZ0I7UUFDaEIsZUFBZTtRQUNmLGtCQUFrQjtRQUNsQixhQUFhO1FBQ2IsY0FBYztRQUNkLGdCQUFnQixhQUVSLGVBQWU7OEdBRWQsZUFBZSxZQVpqQjtZQUNQLFlBQVk7WUFDWixXQUFXO1lBQ1gsZ0JBQWdCO1lBQ2hCLGVBQWU7WUFDZixrQkFBa0I7WUFDbEIsYUFBYTtZQUNiLGNBQWM7WUFDZCxnQkFBZ0I7U0FDakI7NEZBR1UsZUFBZTtrQkFkM0IsUUFBUTttQkFBQztvQkFDUixZQUFZLEVBQUUsQ0FBQyxlQUFlLENBQUM7b0JBQy9CLE9BQU8sRUFBRTt3QkFDUCxZQUFZO3dCQUNaLFdBQVc7d0JBQ1gsZ0JBQWdCO3dCQUNoQixlQUFlO3dCQUNmLGtCQUFrQjt3QkFDbEIsYUFBYTt3QkFDYixjQUFjO3dCQUNkLGdCQUFnQjtxQkFDakI7b0JBQ0QsT0FBTyxFQUFFLENBQUMsZUFBZSxDQUFDO2lCQUMzQiIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7Q29tbW9uTW9kdWxlfSBmcm9tICdAYW5ndWxhci9jb21tb24nO1xuaW1wb3J0IHtIdHRwQ2xpZW50TW9kdWxlfSBmcm9tICdAYW5ndWxhci9jb21tb24vaHR0cCc7XG5pbXBvcnQge05nTW9kdWxlfSBmcm9tICdAYW5ndWxhci9jb3JlJztcbmltcG9ydCB7RmxleExheW91dE1vZHVsZX0gZnJvbSAnQGFuZ3VsYXIvZmxleC1sYXlvdXQnO1xuaW1wb3J0IHtGb3Jtc01vZHVsZX0gZnJvbSAnQGFuZ3VsYXIvZm9ybXMnO1xuaW1wb3J0IHtNYXRGb3JtRmllbGRNb2R1bGV9IGZyb20gJ0Bhbmd1bGFyL21hdGVyaWFsL2Zvcm0tZmllbGQnO1xuaW1wb3J0IHtNYXRJY29uTW9kdWxlfSBmcm9tICdAYW5ndWxhci9tYXRlcmlhbC9pY29uJztcbmltcG9ydCB7TWF0SW5wdXRNb2R1bGV9IGZyb20gJ0Bhbmd1bGFyL21hdGVyaWFsL2lucHV0JztcbmltcG9ydCB7TWF0U2VsZWN0TW9kdWxlfSBmcm9tICdAYW5ndWxhci9tYXRlcmlhbC9zZWxlY3QnO1xuXG5pbXBvcnQge1NlYXJjaENvbXBvbmVudH0gZnJvbSAnLi9zZWFyY2gvc2VhcmNoLmNvbXBvbmVudCc7XG5cbkBOZ01vZHVsZSh7XG4gIGRlY2xhcmF0aW9uczogW1NlYXJjaENvbXBvbmVudF0sXG4gIGltcG9ydHM6IFtcbiAgICBDb21tb25Nb2R1bGUsXG4gICAgRm9ybXNNb2R1bGUsXG4gICAgSHR0cENsaWVudE1vZHVsZSxcbiAgICBNYXRTZWxlY3RNb2R1bGUsXG4gICAgTWF0Rm9ybUZpZWxkTW9kdWxlLFxuICAgIE1hdEljb25Nb2R1bGUsXG4gICAgTWF0SW5wdXRNb2R1bGUsXG4gICAgRmxleExheW91dE1vZHVsZSxcbiAgXSxcbiAgZXhwb3J0czogW1NlYXJjaENvbXBvbmVudF0sXG59KVxuZXhwb3J0IGNsYXNzIFNlYXJjaExpYk1vZHVsZSB7fVxuIl19
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
import * as i8 from '@angular/common';
|
|
2
|
+
import { isPlatformBrowser, CommonModule } from '@angular/common';
|
|
3
|
+
import { HttpClientModule } from '@angular/common/http';
|
|
4
|
+
import * as i0 from '@angular/core';
|
|
5
|
+
import { InjectionToken, EventEmitter, PLATFORM_ID, Component, Inject, Input, Output, ViewChild, NgModule } from '@angular/core';
|
|
6
|
+
import { FlexLayoutModule } from '@angular/flex-layout';
|
|
7
|
+
import * as i7 from '@angular/forms';
|
|
8
|
+
import { NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
|
|
9
|
+
import * as i1 from '@angular/material/form-field';
|
|
10
|
+
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
11
|
+
import * as i2 from '@angular/material/icon';
|
|
12
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
13
|
+
import * as i6 from '@angular/material/input';
|
|
14
|
+
import { MatInputModule } from '@angular/material/input';
|
|
15
|
+
import * as i3 from '@angular/material/select';
|
|
16
|
+
import { MatSelectModule } from '@angular/material/select';
|
|
17
|
+
import { Subject } from 'rxjs';
|
|
18
|
+
import { tap, debounceTime } from 'rxjs/operators';
|
|
19
|
+
import * as i4 from '@angular/material/core';
|
|
20
|
+
import * as i5 from '@angular/flex-layout/flex';
|
|
21
|
+
|
|
22
|
+
// cant use T extends IReturnType here
|
|
23
|
+
const SEARCH_SERVICE_TOKEN = new InjectionToken('Search_Service_Token');
|
|
24
|
+
// IRequestParameters default values
|
|
25
|
+
const DEFAULT_LIMIT = 20;
|
|
26
|
+
const DEFAULT_LIMIT_TYPE = false;
|
|
27
|
+
const DEFAULT_ORDER = [];
|
|
28
|
+
const DEBOUNCE_TIME = 1000;
|
|
29
|
+
const DEFAULT_OFFSET = 0;
|
|
30
|
+
const DEFAULT_SAVE_IN_RECENTS = true;
|
|
31
|
+
|
|
32
|
+
const ALL_LABEL = 'All';
|
|
33
|
+
class SearchComponent {
|
|
34
|
+
constructor(searchService,
|
|
35
|
+
// tslint:disable-next-line:ban-types
|
|
36
|
+
platformId, cdr) {
|
|
37
|
+
this.searchService = searchService;
|
|
38
|
+
this.platformId = platformId;
|
|
39
|
+
this.cdr = cdr;
|
|
40
|
+
this.searchBoxInput = '';
|
|
41
|
+
this.suggestionsDisplay = false;
|
|
42
|
+
this.categoryDisplay = false;
|
|
43
|
+
this.searching = false;
|
|
44
|
+
this.suggestions = [];
|
|
45
|
+
this.recentSearches = [];
|
|
46
|
+
this.category = ALL_LABEL;
|
|
47
|
+
this.searchRequest$ = new Subject();
|
|
48
|
+
// emitted when user clicks one of the suggested results (including recent search sugestions)
|
|
49
|
+
this.clicked = new EventEmitter();
|
|
50
|
+
this.searched = new EventEmitter();
|
|
51
|
+
this.disabled = false;
|
|
52
|
+
}
|
|
53
|
+
get config() {
|
|
54
|
+
return this._config;
|
|
55
|
+
}
|
|
56
|
+
set config(value) {
|
|
57
|
+
this._config = value;
|
|
58
|
+
if (value && value.models) {
|
|
59
|
+
value.models.unshift({
|
|
60
|
+
name: ALL_LABEL,
|
|
61
|
+
displayName: ALL_LABEL,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
else if (value && !value.models) {
|
|
65
|
+
value.models = [
|
|
66
|
+
{
|
|
67
|
+
name: ALL_LABEL,
|
|
68
|
+
displayName: ALL_LABEL,
|
|
69
|
+
},
|
|
70
|
+
];
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
// do nothing
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
ngOnInit() {
|
|
77
|
+
this.searchRequest$
|
|
78
|
+
.pipe(tap(v => (this.suggestions = [])), debounceTime(DEBOUNCE_TIME))
|
|
79
|
+
.subscribe((value) => {
|
|
80
|
+
this.searched.emit({
|
|
81
|
+
event: value.event,
|
|
82
|
+
keyword: value.input,
|
|
83
|
+
category: this.category,
|
|
84
|
+
});
|
|
85
|
+
this.getSuggestions(value);
|
|
86
|
+
this.cdr.markForCheck();
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
// ControlValueAccessor Implementation
|
|
90
|
+
writeValue(value) {
|
|
91
|
+
this.searchBoxInput = value;
|
|
92
|
+
}
|
|
93
|
+
// When the value in the UI is changed, this method will invoke a callback function
|
|
94
|
+
registerOnChange(fn) {
|
|
95
|
+
this.onChange = fn;
|
|
96
|
+
}
|
|
97
|
+
registerOnTouched(fn) {
|
|
98
|
+
this.onTouched = fn;
|
|
99
|
+
}
|
|
100
|
+
setDisabledState(isDisabled) {
|
|
101
|
+
this.disabled = isDisabled;
|
|
102
|
+
}
|
|
103
|
+
getSuggestions(eventValue) {
|
|
104
|
+
var _a, _b, _c, _d, _e;
|
|
105
|
+
eventValue.input = eventValue.input.trim();
|
|
106
|
+
if (!eventValue.input.length) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const order = (_a = this.config.order) !== null && _a !== void 0 ? _a : DEFAULT_ORDER;
|
|
110
|
+
let orderString = '';
|
|
111
|
+
order.forEach(preference => (orderString = `${orderString}${preference} `));
|
|
112
|
+
let saveInRecents = (_b = this.config.saveInRecents) !== null && _b !== void 0 ? _b : DEFAULT_SAVE_IN_RECENTS;
|
|
113
|
+
if (this.config.saveInRecents && this.config.saveInRecentsOnlyOnEnter) {
|
|
114
|
+
if (!eventValue.event ||
|
|
115
|
+
(eventValue.event instanceof KeyboardEvent &&
|
|
116
|
+
eventValue.event.key === 'Enter')) {
|
|
117
|
+
saveInRecents = true; // save in recents only on enter or change in category
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
// do not save in recent search on typing
|
|
121
|
+
saveInRecents = false;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/* need to put default value here and not in contructor
|
|
125
|
+
because sonar was giving code smell with definite assertion as all these parameters are optional */
|
|
126
|
+
const requestParameters = {
|
|
127
|
+
match: eventValue.input,
|
|
128
|
+
sources: this._categoryToSourceName(this.category),
|
|
129
|
+
limit: (_c = this.config.limit) !== null && _c !== void 0 ? _c : DEFAULT_LIMIT,
|
|
130
|
+
limitByType: (_d = this.config.limitByType) !== null && _d !== void 0 ? _d : DEFAULT_LIMIT_TYPE,
|
|
131
|
+
order: orderString,
|
|
132
|
+
offset: (_e = this.config.offset) !== null && _e !== void 0 ? _e : DEFAULT_OFFSET,
|
|
133
|
+
};
|
|
134
|
+
this.searching = true;
|
|
135
|
+
this.cdr.markForCheck();
|
|
136
|
+
this.searchService
|
|
137
|
+
.searchApiRequest(requestParameters, saveInRecents)
|
|
138
|
+
.subscribe((value) => {
|
|
139
|
+
this.suggestions = value;
|
|
140
|
+
this.searching = false;
|
|
141
|
+
this.cdr.markForCheck();
|
|
142
|
+
}, (_error) => {
|
|
143
|
+
this.suggestions = [];
|
|
144
|
+
this.searching = false;
|
|
145
|
+
this.cdr.markForCheck();
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
getRecentSearches() {
|
|
149
|
+
if (!this.config.hideRecentSearch &&
|
|
150
|
+
this.searchService.recentSearchApiRequest) {
|
|
151
|
+
this.searchService.recentSearchApiRequest().subscribe((value) => {
|
|
152
|
+
this.recentSearches = value;
|
|
153
|
+
this.cdr.markForCheck();
|
|
154
|
+
}, (_error) => {
|
|
155
|
+
this.recentSearches = [];
|
|
156
|
+
this.cdr.markForCheck();
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
// event can be KeyBoardEvent or Event of type 'change' fired on change in value of drop down for category
|
|
161
|
+
hitSearchApi(event) {
|
|
162
|
+
// this will happen only in case user searches something and then erases it, we need to update recent search
|
|
163
|
+
if (!this.searchBoxInput) {
|
|
164
|
+
this.suggestions = [];
|
|
165
|
+
this.getRecentSearches();
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
// no debounce time needed in case of searchOnlyOnEnter
|
|
169
|
+
if (this.config.searchOnlyOnEnter) {
|
|
170
|
+
if (!event || (event instanceof KeyboardEvent && event.key === 'Enter')) {
|
|
171
|
+
this.getSuggestions({ input: this.searchBoxInput, event });
|
|
172
|
+
}
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
// no debounce time needed in case of change in category
|
|
176
|
+
if (!event) {
|
|
177
|
+
this.getSuggestions({ input: this.searchBoxInput, event });
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
this.searchRequest$.next({
|
|
181
|
+
input: this.searchBoxInput,
|
|
182
|
+
event,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
populateValue(suggestion, event) {
|
|
186
|
+
const value = suggestion[this.config.displayPropertyName]; // converted to string to assign value to searchBoxInput
|
|
187
|
+
this.searchBoxInput = value;
|
|
188
|
+
this.suggestionsDisplay = false;
|
|
189
|
+
// ngModelChange doesn't detect change in value when populated from outside, hence calling manually
|
|
190
|
+
this.onChange(this.searchBoxInput);
|
|
191
|
+
// need to do this to show more search options for selected suggestion - just in case user reopens search input
|
|
192
|
+
this.getSuggestions({ input: this.searchBoxInput, event });
|
|
193
|
+
this.clicked.emit({ item: suggestion, event });
|
|
194
|
+
}
|
|
195
|
+
populateValueRecentSearch(recentSearch, event) {
|
|
196
|
+
event.stopPropagation();
|
|
197
|
+
event.preventDefault();
|
|
198
|
+
const value = recentSearch['match'];
|
|
199
|
+
this.searchBoxInput = value;
|
|
200
|
+
this.suggestionsDisplay = false;
|
|
201
|
+
this.onChange(this.searchBoxInput);
|
|
202
|
+
// need to do this to show more search options for selected suggestion - just in case user reopens search input
|
|
203
|
+
this.getSuggestions({ input: this.searchBoxInput, event });
|
|
204
|
+
this.focusInput();
|
|
205
|
+
this.showSuggestions();
|
|
206
|
+
}
|
|
207
|
+
fetchModelImageUrlFromSuggestion(suggestion) {
|
|
208
|
+
const modelName = suggestion['source'];
|
|
209
|
+
let url;
|
|
210
|
+
this.config.models.forEach(model => {
|
|
211
|
+
if (model.name === modelName && model.imageUrl) {
|
|
212
|
+
url = model.imageUrl;
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
return url;
|
|
216
|
+
}
|
|
217
|
+
boldString(str, substr) {
|
|
218
|
+
const strRegExp = new RegExp(`(${substr})`, 'gi');
|
|
219
|
+
const stringToMakeBold = str;
|
|
220
|
+
return stringToMakeBold.replace(strRegExp, `<b>$1</b>`);
|
|
221
|
+
}
|
|
222
|
+
hideSuggestions() {
|
|
223
|
+
this.suggestionsDisplay = false;
|
|
224
|
+
this.onTouched();
|
|
225
|
+
}
|
|
226
|
+
showSuggestions() {
|
|
227
|
+
this.suggestionsDisplay = true;
|
|
228
|
+
this.getRecentSearches();
|
|
229
|
+
}
|
|
230
|
+
focusInput() {
|
|
231
|
+
if (isPlatformBrowser(this.platformId)) {
|
|
232
|
+
this.searchInputElement.nativeElement.focus();
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
setCategory(category) {
|
|
236
|
+
this.category = category;
|
|
237
|
+
this.categoryDisplay = false;
|
|
238
|
+
if (this.searchBoxInput) {
|
|
239
|
+
this.hitSearchApi();
|
|
240
|
+
this.focusInput();
|
|
241
|
+
this.showSuggestions();
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
showCategory() {
|
|
245
|
+
this.categoryDisplay = !this.categoryDisplay;
|
|
246
|
+
}
|
|
247
|
+
hideCategory() {
|
|
248
|
+
this.categoryDisplay = false;
|
|
249
|
+
}
|
|
250
|
+
resetInput() {
|
|
251
|
+
this.searchBoxInput = '';
|
|
252
|
+
this.suggestions = [];
|
|
253
|
+
this.suggestionsDisplay = true;
|
|
254
|
+
this.focusInput();
|
|
255
|
+
// ngModelChange doesn't detect change in value when populated from outside, hence calling manually
|
|
256
|
+
this.onChange(this.searchBoxInput);
|
|
257
|
+
this.getRecentSearches();
|
|
258
|
+
}
|
|
259
|
+
ngOnDestroy() {
|
|
260
|
+
this.searchRequest$.unsubscribe();
|
|
261
|
+
}
|
|
262
|
+
_categoryToSourceName(category) {
|
|
263
|
+
if (category === ALL_LABEL) {
|
|
264
|
+
return [];
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
return [category];
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
getModelFromModelName(name) {
|
|
271
|
+
return this.config.models.find(item => item.name === name);
|
|
272
|
+
}
|
|
273
|
+
getModelsWithSuggestions() {
|
|
274
|
+
const modelsWithSuggestions = [];
|
|
275
|
+
const sources = [];
|
|
276
|
+
this.suggestions.forEach(suggestion => {
|
|
277
|
+
if (sources.indexOf(suggestion['source']) >= 0) {
|
|
278
|
+
modelsWithSuggestions.every(modelWithSuggestions => {
|
|
279
|
+
if (modelWithSuggestions.model.name === suggestion['source']) {
|
|
280
|
+
modelWithSuggestions.items.push(suggestion);
|
|
281
|
+
return false;
|
|
282
|
+
}
|
|
283
|
+
return true;
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
const model = this.getModelFromModelName(suggestion['source']);
|
|
288
|
+
modelsWithSuggestions.push({ model, items: [suggestion] });
|
|
289
|
+
sources.push(suggestion['source']);
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
return modelsWithSuggestions;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
SearchComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: SearchComponent, deps: [{ token: SEARCH_SERVICE_TOKEN }, { token: PLATFORM_ID }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
296
|
+
SearchComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: SearchComponent, selector: "sourceloop-search", inputs: { config: "config", titleTemplate: "titleTemplate", subtitleTemplate: "subtitleTemplate" }, outputs: { clicked: "clicked", searched: "searched" }, providers: [
|
|
297
|
+
{
|
|
298
|
+
provide: NG_VALUE_ACCESSOR,
|
|
299
|
+
useExisting: SearchComponent,
|
|
300
|
+
multi: true,
|
|
301
|
+
},
|
|
302
|
+
], viewQueries: [{ propertyName: "searchInputElement", first: true, predicate: ["searchInput"], descendants: true }], ngImport: i0, template: "<div fxLayout fxLayoutAlign=\"start center\" class=\"toolbar-search\">\n <mat-form-field appearance=\"outline\" class=\"toolbar-search-input\">\n <input\n matInput\n autocomplete=\"off\"\n type=\"text\"\n [placeholder]=\"\n config.placeholderFunction\n ? config.placeholderFunction(searchInput.value, category)\n : config.placeholder || 'Search'\n \"\n #searchInput\n name=\"searchInput\"\n (focus)=\"showSuggestions()\"\n (blur)=\"hideSuggestions()\"\n [(ngModel)]=\"searchBoxInput\"\n (keyup)=\"hitSearchApi($event)\"\n placeholder=\"Search\"\n (ngModelChange)=\"onChange(this.searchBoxInput)\"\n [disabled]=\"disabled\"\n />\n <mat-icon matPrefix [className]=\"config.searchIconClass\"></mat-icon>\n <mat-icon\n *ngIf=\"searchBoxInput\"\n matSuffix\n [className]=\"config.crossIconClass\"\n (click)=\"resetInput()\"\n ></mat-icon>\n </mat-form-field>\n\n <mat-form-field appearance=\"outline\" class=\"toolbar-search-select\">\n <mat-icon matSuffix [className]=\"config.dropDownButtonIconClass\"></mat-icon>\n <mat-select\n [value]=\"category\"\n (selectionChange)=\"setCategory($event.value)\"\n panelClass=\"search-select\"\n >\n <mat-option [value]=\"model.name\" *ngFor=\"let model of config.models\">\n {{ model.displayName }}\n </mat-option>\n </mat-select>\n </mat-form-field>\n</div>\n\n<div class=\"search-container\">\n <div\n *ngIf=\"suggestionsDisplay && (recentSearches.length || suggestions.length)\"\n class=\"search-popup\"\n >\n <ng-container *ngIf=\"searchBoxInput\">\n <span *ngIf=\"suggestions.length === 0\" class=\"search-message\">\n <ng-container *ngIf=\"searching\"> searching... </ng-container>\n <ng-container *ngIf=\"!searching\">\n {{ config.noResultMessage }}\n </ng-container>\n </span>\n <ng-container *ngIf=\"config.categorizeResults && suggestions.length\">\n <div\n class=\"search-result\"\n *ngFor=\"let modelWithSuggestions of getModelsWithSuggestions()\"\n >\n <h3 class=\"suggestions-heading\">\n <img\n *ngIf=\"modelWithSuggestions.model.imageUrl\"\n [src]=\"modelWithSuggestions.model.imageUrl\"\n [alt]=\"modelWithSuggestions.model.displayName\"\n />\n {{ modelWithSuggestions.model.displayName }} ({{\n modelWithSuggestions.items.length\n }})\n </h3>\n <ul>\n <li\n *ngFor=\"let suggestion of modelWithSuggestions.items\"\n (mousedown)=\"populateValue(suggestion, $event)\"\n class=\"suggestions\"\n >\n <ng-container *ngIf=\"subtitleTemplate\">\n <ng-container\n *ngTemplateOutlet=\"\n subtitleTemplate;\n context: {$implicit: suggestion}\n \"\n >\n </ng-container>\n </ng-container>\n <p\n *ngIf=\"!titleTemplate\"\n [innerHTML]=\"\n boldString(\n suggestion[config.displayPropertyName],\n searchBoxInput\n )\n \"\n style=\"display: inline\"\n ></p>\n <ng-container *ngIf=\"titleTemplate\">\n <ng-container\n *ngTemplateOutlet=\"\n titleTemplate;\n context: {$implicit: suggestion}\n \"\n >\n </ng-container>\n </ng-container>\n </li>\n </ul>\n </div>\n </ng-container>\n <ng-container *ngIf=\"!config.categorizeResults\">\n <div class=\"search-result\">\n <ul>\n <li\n *ngFor=\"let suggestion of suggestions\"\n (mousedown)=\"populateValue(suggestion, $event)\"\n >\n <!--Need to call fetchModelImageUrlFromSuggestion as each suggestion can come from different model-->\n <img\n *ngIf=\"\n !titleTemplate && fetchModelImageUrlFromSuggestion(suggestion)\n \"\n class=\"suggestions-categorize-false\"\n [src]=\"fetchModelImageUrlFromSuggestion(suggestion)\"\n style=\"margin-right: 5px\"\n alt=\"Img\"\n />\n <ng-container *ngIf=\"subtitleTemplate\">\n <ng-container\n *ngTemplateOutlet=\"\n subtitleTemplate;\n context: {$implicit: suggestion}\n \"\n >\n </ng-container>\n </ng-container>\n <p\n *ngIf=\"!titleTemplate\"\n [innerHTML]=\"\n boldString(\n suggestion[config.displayPropertyName],\n searchBoxInput\n )\n \"\n style=\"display: inline\"\n ></p>\n <ng-container *ngIf=\"titleTemplate\">\n <ng-container\n *ngTemplateOutlet=\"\n titleTemplate;\n context: {$implicit: suggestion}\n \"\n >\n </ng-container>\n </ng-container>\n </li>\n </ul>\n </div>\n </ng-container>\n </ng-container>\n\n <ng-container *ngIf=\"!config.hideRecentSearch && recentSearches.length > 0\">\n <div class=\"recent-searches\">\n <h3 class=\"suggestions-heading\">Recent Searches</h3>\n <ul>\n <li\n *ngFor=\"let recentSearch of recentSearches\"\n class=\"suggestions\"\n (mousedown)=\"populateValueRecentSearch(recentSearch, $event)\"\n >\n <mat-icon\n matPrefix\n [className]=\"config.recentSearchIconClass\"\n ></mat-icon>\n\n <span> {{ recentSearch.match }}</span>\n </li>\n </ul>\n </div>\n </ng-container>\n </div>\n</div>\n", styles: [":host ::ng-deep .mat-form-field-wrapper{padding:0}:host ::ng-deep .mat-form-field-wrapper .mat-form-field-prefix{margin-right:12px}.toolbar-search-input{width:86%}.toolbar-search-input ::ng-deep input{margin:0}.toolbar-search-input ::ng-deep .mat-form-field-flex .mat-form-field-outline:first-child .mat-form-field-outline-start{border-color:transparent}.toolbar-search-input ::ng-deep .mat-form-field-flex .mat-form-field-outline:first-child .mat-form-field-outline-end{border:none;border-radius:0}.icomoon.Search,.icomoon.close{height:1rem;width:1rem;font-size:1rem;color:#33333380;padding-bottom:4px}.icomoon.close{cursor:pointer}.toolbar-search-select{width:14%}.toolbar-search-select ::ng-deep .mat-select-arrow{opacity:0}.toolbar-search-select ::ng-deep .mat-select-arrow-wrapper{display:inline-block;width:1px}.toolbar-search-select ::ng-deep .mat-select-value-text{font-size:9px}.toolbar-search-select ::ng-deep .mat-form-field-suffix .mat-icon{width:12px;font-size:14px}.toolbar-search-select ::ng-deep .mat-form-field-flex .mat-form-field-outline:first-child .mat-form-field-outline-start{border-color:transparent;border-radius:0}.toolbar-search-select ::ng-deep .mat-form-field-flex .mat-form-field-outline:first-child .mat-form-field-outline-end{border:none}.toolbar-search-select ::ng-deep .mat-form-field-flex .mat-form-field-infix{-webkit-padding-before:.7em!important}.toolbar-search{width:515px;background-color:#f7f7f7;border-radius:0 0 4px 4px}.toolbar-search ::ng-deep .mat-form-field-appearance-outline .mat-form-field-flex{height:39px;align-items:center!important}.toolbar-search ::ng-deep .mat-form-field-appearance-outline .mat-form-field-wrapper{margin:0}.toolbar-search ::ng-deep .mat-form-field-infix{height:auto!important}.search-container{position:relative;width:515px}.search-container .search-popup{padding:0 15px 15px;margin:0;max-height:80vh;overflow-x:hidden;overflow-y:auto;position:absolute;top:100%;left:0px;right:0px;z-index:9999;background-color:#fff;box-shadow:0 5px 4px #0003;border-radius:0 0 4px 4px}.search-container .search-popup hr{border:0;border-top:1px solid #ebebeb;margin:0;position:sticky;top:0;padding:0 0 15px;z-index:1}.search-container .search-popup .search-message{display:inline-block;width:100%;text-align:center;font-size:16px;padding-top:12px}.search-container .search-popup .search-item-info{color:#91263b;text-align:center;font-size:12px;margin-bottom:15px;padding-top:12px}.search-container .search-popup ul{padding:0;margin:0}.search-container .search-popup ul li{list-style:none;font-size:1rem;font-weight:400;line-height:1.5;color:#333}.search-container .search-popup ul li.suggestions{font-size:15px;line-height:36px;padding:0 15px 0 44px;align-items:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer}.search-container .search-popup ul li.suggestions:hover{background-color:#fee8e8}.search-container .search-popup ul li.suggestions svg{margin-right:5px}.search-container .search-popup ul li.suggestions-categorize-false:hover{background-color:#fee8e8}.search-container .search-popup .search-result{padding:10px 0 0;margin:0 -15px}.search-container .search-popup .search-result.no-categorize-result ul{width:100%;padding:0;margin:0 0 10px}.search-container .search-popup .search-result.no-categorize-result ul li{font-size:15px;line-height:36px;padding:0 15px 0 31px;display:flex;align-items:center;cursor:pointer}.search-container .search-popup .search-result.no-categorize-result ul li:hover{background-color:#fee8e8}.search-container .search-popup .search-result.no-categorize-result ul li img{width:18px;margin-right:9px}.search-container .search-popup .suggestions-heading{color:#9c9c9c;font-size:14px;font-weight:400;margin:0 0 10px 17px;display:flex;align-items:center;position:relative}.search-container .search-popup .suggestions-heading .show-more{position:absolute;right:20px;color:#d1d1d1;font-size:12px;cursor:pointer;text-decoration:none}.search-container .search-popup .suggestions-heading .show-more :hover{text-decoration:underline}.search-container .search-popup .suggestions-heading img{width:18px;margin-right:9px}.search-container .search-popup .recent-searches{padding:10px 0 0;margin:0 -15px}.search-container .search-popup .recent-searches ul{display:inline-block;width:100%}.search-container .search-popup .recent-searches ul li.suggestions{display:flex}.search-container .search-popup .recent-searches ul li.suggestions span{width:100%;overflow:hidden;text-overflow:ellipsis}.search-container .search-popup .recent-searches .suggestions{display:flex}.search-container .search-popup .recent-searches .suggestions-heading{margin-left:30px}.search-container .search-popup .recent-searches li.suggestions{padding-left:31px}::ng-deep .search-select.mat-select-panel{margin-top:30px;margin-left:10px}::ng-deep .search-select .mat-option-text{display:contents!important}::ng-deep .toolbar-search .mat-form-field-infix{font-size:14px}::ng-deep .toolbar-search input{line-height:14px}::ng-deep .toolbar-search .mat-form-field-outline:first-child .mat-form-field-outline-start,::ng-deep .toolbar-search .mat-form-field-outline:first-child .mat-form-field-outline-end{background-color:#f1f3f4}::ng-deep .toolbar-search:hover .toolbar-search-input.mat-form-field:not(.mat-form-field-disabled) .mat-form-field-outline .mat-form-field-outline-start{border-width:1px!important;border-color:#a53159!important}::ng-deep .toolbar-search:hover .toolbar-search-input.mat-form-field:not(.mat-form-field-disabled) .mat-form-field-outline .mat-form-field-outline-end{border:1px solid #a53159!important;border-left-style:none!important;border-right-style:none!important;border-top-right-radius:0!important;border-bottom-right-radius:0!important}::ng-deep .toolbar-search:hover .toolbar-search-select.mat-form-field:not(.mat-form-field-disabled) .mat-form-field-outline .mat-form-field-outline-start{border-radius:0;border-color:transparent!important;background-color:#a53159!important}::ng-deep .toolbar-search:hover .toolbar-search-select.mat-form-field:not(.mat-form-field-disabled) .mat-form-field-outline .mat-form-field-outline-end{border-width:1px!important;border-color:#a53159!important;background-color:#a53159!important}::ng-deep .toolbar-search:hover .toolbar-search-select.mat-form-field:not(.mat-form-field-disabled) .mat-select{color:#fff!important}::ng-deep .toolbar-search:hover .toolbar-search-select.mat-form-field:not(.mat-form-field-disabled) .icomoon.arrow_down{color:#fff}::ng-deep .toolbar-search:focus-within .toolbar-search-input.mat-form-field:not(.mat-form-field-disabled) .mat-form-field-outline .mat-form-field-outline-start{border-width:2px!important;border-color:#90003b!important}::ng-deep .toolbar-search:focus-within .toolbar-search-input.mat-form-field:not(.mat-form-field-disabled) .mat-form-field-outline .mat-form-field-outline-end{border:2px solid #90003b!important;border-left-style:none!important;border-right-style:none!important;border-top-right-radius:0!important;border-bottom-right-radius:0!important}::ng-deep .toolbar-search:focus-within .toolbar-search-select.mat-form-field:not(.mat-form-field-disabled) .mat-form-field-outline .mat-form-field-outline-start{border-radius:0;border-color:transparent!important;background-color:#90003b!important}::ng-deep .toolbar-search:focus-within .toolbar-search-select.mat-form-field:not(.mat-form-field-disabled) .mat-form-field-outline .mat-form-field-outline-end{border-width:2px!important;border-color:#90003b!important;background-color:#90003b!important}::ng-deep .toolbar-search:focus-within .toolbar-search-select.mat-form-field:not(.mat-form-field-disabled) .mat-select{color:#fff!important}::ng-deep .toolbar-search:focus-within .toolbar-search-select.mat-form-field:not(.mat-form-field-disabled) .icomoon.arrow_down{color:#fff}::ng-deep .toolbar-search .mat-select-arrow{opacity:0}\n"], components: [{ type: i1.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: i2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { type: i3.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { type: i4.MatOption, selector: "mat-option", exportAs: ["matOption"] }], directives: [{ type: i5.DefaultLayoutDirective, selector: " [fxLayout], [fxLayout.xs], [fxLayout.sm], [fxLayout.md], [fxLayout.lg], [fxLayout.xl], [fxLayout.lt-sm], [fxLayout.lt-md], [fxLayout.lt-lg], [fxLayout.lt-xl], [fxLayout.gt-xs], [fxLayout.gt-sm], [fxLayout.gt-md], [fxLayout.gt-lg]", inputs: ["fxLayout", "fxLayout.xs", "fxLayout.sm", "fxLayout.md", "fxLayout.lg", "fxLayout.xl", "fxLayout.lt-sm", "fxLayout.lt-md", "fxLayout.lt-lg", "fxLayout.lt-xl", "fxLayout.gt-xs", "fxLayout.gt-sm", "fxLayout.gt-md", "fxLayout.gt-lg"] }, { type: i5.DefaultLayoutAlignDirective, selector: " [fxLayoutAlign], [fxLayoutAlign.xs], [fxLayoutAlign.sm], [fxLayoutAlign.md], [fxLayoutAlign.lg], [fxLayoutAlign.xl], [fxLayoutAlign.lt-sm], [fxLayoutAlign.lt-md], [fxLayoutAlign.lt-lg], [fxLayoutAlign.lt-xl], [fxLayoutAlign.gt-xs], [fxLayoutAlign.gt-sm], [fxLayoutAlign.gt-md], [fxLayoutAlign.gt-lg]", inputs: ["fxLayoutAlign", "fxLayoutAlign.xs", "fxLayoutAlign.sm", "fxLayoutAlign.md", "fxLayoutAlign.lg", "fxLayoutAlign.xl", "fxLayoutAlign.lt-sm", "fxLayoutAlign.lt-md", "fxLayoutAlign.lt-lg", "fxLayoutAlign.lt-xl", "fxLayoutAlign.gt-xs", "fxLayoutAlign.gt-sm", "fxLayoutAlign.gt-md", "fxLayoutAlign.gt-lg"] }, { type: i6.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { type: i7.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i7.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i7.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i1.MatPrefix, selector: "[matPrefix]" }, { type: i8.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1.MatSuffix, selector: "[matSuffix]" }, { type: i8.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i8.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }] });
|
|
303
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: SearchComponent, decorators: [{
|
|
304
|
+
type: Component,
|
|
305
|
+
args: [{ selector: 'sourceloop-search', providers: [
|
|
306
|
+
{
|
|
307
|
+
provide: NG_VALUE_ACCESSOR,
|
|
308
|
+
useExisting: SearchComponent,
|
|
309
|
+
multi: true,
|
|
310
|
+
},
|
|
311
|
+
], template: "<div fxLayout fxLayoutAlign=\"start center\" class=\"toolbar-search\">\n <mat-form-field appearance=\"outline\" class=\"toolbar-search-input\">\n <input\n matInput\n autocomplete=\"off\"\n type=\"text\"\n [placeholder]=\"\n config.placeholderFunction\n ? config.placeholderFunction(searchInput.value, category)\n : config.placeholder || 'Search'\n \"\n #searchInput\n name=\"searchInput\"\n (focus)=\"showSuggestions()\"\n (blur)=\"hideSuggestions()\"\n [(ngModel)]=\"searchBoxInput\"\n (keyup)=\"hitSearchApi($event)\"\n placeholder=\"Search\"\n (ngModelChange)=\"onChange(this.searchBoxInput)\"\n [disabled]=\"disabled\"\n />\n <mat-icon matPrefix [className]=\"config.searchIconClass\"></mat-icon>\n <mat-icon\n *ngIf=\"searchBoxInput\"\n matSuffix\n [className]=\"config.crossIconClass\"\n (click)=\"resetInput()\"\n ></mat-icon>\n </mat-form-field>\n\n <mat-form-field appearance=\"outline\" class=\"toolbar-search-select\">\n <mat-icon matSuffix [className]=\"config.dropDownButtonIconClass\"></mat-icon>\n <mat-select\n [value]=\"category\"\n (selectionChange)=\"setCategory($event.value)\"\n panelClass=\"search-select\"\n >\n <mat-option [value]=\"model.name\" *ngFor=\"let model of config.models\">\n {{ model.displayName }}\n </mat-option>\n </mat-select>\n </mat-form-field>\n</div>\n\n<div class=\"search-container\">\n <div\n *ngIf=\"suggestionsDisplay && (recentSearches.length || suggestions.length)\"\n class=\"search-popup\"\n >\n <ng-container *ngIf=\"searchBoxInput\">\n <span *ngIf=\"suggestions.length === 0\" class=\"search-message\">\n <ng-container *ngIf=\"searching\"> searching... </ng-container>\n <ng-container *ngIf=\"!searching\">\n {{ config.noResultMessage }}\n </ng-container>\n </span>\n <ng-container *ngIf=\"config.categorizeResults && suggestions.length\">\n <div\n class=\"search-result\"\n *ngFor=\"let modelWithSuggestions of getModelsWithSuggestions()\"\n >\n <h3 class=\"suggestions-heading\">\n <img\n *ngIf=\"modelWithSuggestions.model.imageUrl\"\n [src]=\"modelWithSuggestions.model.imageUrl\"\n [alt]=\"modelWithSuggestions.model.displayName\"\n />\n {{ modelWithSuggestions.model.displayName }} ({{\n modelWithSuggestions.items.length\n }})\n </h3>\n <ul>\n <li\n *ngFor=\"let suggestion of modelWithSuggestions.items\"\n (mousedown)=\"populateValue(suggestion, $event)\"\n class=\"suggestions\"\n >\n <ng-container *ngIf=\"subtitleTemplate\">\n <ng-container\n *ngTemplateOutlet=\"\n subtitleTemplate;\n context: {$implicit: suggestion}\n \"\n >\n </ng-container>\n </ng-container>\n <p\n *ngIf=\"!titleTemplate\"\n [innerHTML]=\"\n boldString(\n suggestion[config.displayPropertyName],\n searchBoxInput\n )\n \"\n style=\"display: inline\"\n ></p>\n <ng-container *ngIf=\"titleTemplate\">\n <ng-container\n *ngTemplateOutlet=\"\n titleTemplate;\n context: {$implicit: suggestion}\n \"\n >\n </ng-container>\n </ng-container>\n </li>\n </ul>\n </div>\n </ng-container>\n <ng-container *ngIf=\"!config.categorizeResults\">\n <div class=\"search-result\">\n <ul>\n <li\n *ngFor=\"let suggestion of suggestions\"\n (mousedown)=\"populateValue(suggestion, $event)\"\n >\n <!--Need to call fetchModelImageUrlFromSuggestion as each suggestion can come from different model-->\n <img\n *ngIf=\"\n !titleTemplate && fetchModelImageUrlFromSuggestion(suggestion)\n \"\n class=\"suggestions-categorize-false\"\n [src]=\"fetchModelImageUrlFromSuggestion(suggestion)\"\n style=\"margin-right: 5px\"\n alt=\"Img\"\n />\n <ng-container *ngIf=\"subtitleTemplate\">\n <ng-container\n *ngTemplateOutlet=\"\n subtitleTemplate;\n context: {$implicit: suggestion}\n \"\n >\n </ng-container>\n </ng-container>\n <p\n *ngIf=\"!titleTemplate\"\n [innerHTML]=\"\n boldString(\n suggestion[config.displayPropertyName],\n searchBoxInput\n )\n \"\n style=\"display: inline\"\n ></p>\n <ng-container *ngIf=\"titleTemplate\">\n <ng-container\n *ngTemplateOutlet=\"\n titleTemplate;\n context: {$implicit: suggestion}\n \"\n >\n </ng-container>\n </ng-container>\n </li>\n </ul>\n </div>\n </ng-container>\n </ng-container>\n\n <ng-container *ngIf=\"!config.hideRecentSearch && recentSearches.length > 0\">\n <div class=\"recent-searches\">\n <h3 class=\"suggestions-heading\">Recent Searches</h3>\n <ul>\n <li\n *ngFor=\"let recentSearch of recentSearches\"\n class=\"suggestions\"\n (mousedown)=\"populateValueRecentSearch(recentSearch, $event)\"\n >\n <mat-icon\n matPrefix\n [className]=\"config.recentSearchIconClass\"\n ></mat-icon>\n\n <span> {{ recentSearch.match }}</span>\n </li>\n </ul>\n </div>\n </ng-container>\n </div>\n</div>\n", styles: [":host ::ng-deep .mat-form-field-wrapper{padding:0}:host ::ng-deep .mat-form-field-wrapper .mat-form-field-prefix{margin-right:12px}.toolbar-search-input{width:86%}.toolbar-search-input ::ng-deep input{margin:0}.toolbar-search-input ::ng-deep .mat-form-field-flex .mat-form-field-outline:first-child .mat-form-field-outline-start{border-color:transparent}.toolbar-search-input ::ng-deep .mat-form-field-flex .mat-form-field-outline:first-child .mat-form-field-outline-end{border:none;border-radius:0}.icomoon.Search,.icomoon.close{height:1rem;width:1rem;font-size:1rem;color:#33333380;padding-bottom:4px}.icomoon.close{cursor:pointer}.toolbar-search-select{width:14%}.toolbar-search-select ::ng-deep .mat-select-arrow{opacity:0}.toolbar-search-select ::ng-deep .mat-select-arrow-wrapper{display:inline-block;width:1px}.toolbar-search-select ::ng-deep .mat-select-value-text{font-size:9px}.toolbar-search-select ::ng-deep .mat-form-field-suffix .mat-icon{width:12px;font-size:14px}.toolbar-search-select ::ng-deep .mat-form-field-flex .mat-form-field-outline:first-child .mat-form-field-outline-start{border-color:transparent;border-radius:0}.toolbar-search-select ::ng-deep .mat-form-field-flex .mat-form-field-outline:first-child .mat-form-field-outline-end{border:none}.toolbar-search-select ::ng-deep .mat-form-field-flex .mat-form-field-infix{-webkit-padding-before:.7em!important}.toolbar-search{width:515px;background-color:#f7f7f7;border-radius:0 0 4px 4px}.toolbar-search ::ng-deep .mat-form-field-appearance-outline .mat-form-field-flex{height:39px;align-items:center!important}.toolbar-search ::ng-deep .mat-form-field-appearance-outline .mat-form-field-wrapper{margin:0}.toolbar-search ::ng-deep .mat-form-field-infix{height:auto!important}.search-container{position:relative;width:515px}.search-container .search-popup{padding:0 15px 15px;margin:0;max-height:80vh;overflow-x:hidden;overflow-y:auto;position:absolute;top:100%;left:0px;right:0px;z-index:9999;background-color:#fff;box-shadow:0 5px 4px #0003;border-radius:0 0 4px 4px}.search-container .search-popup hr{border:0;border-top:1px solid #ebebeb;margin:0;position:sticky;top:0;padding:0 0 15px;z-index:1}.search-container .search-popup .search-message{display:inline-block;width:100%;text-align:center;font-size:16px;padding-top:12px}.search-container .search-popup .search-item-info{color:#91263b;text-align:center;font-size:12px;margin-bottom:15px;padding-top:12px}.search-container .search-popup ul{padding:0;margin:0}.search-container .search-popup ul li{list-style:none;font-size:1rem;font-weight:400;line-height:1.5;color:#333}.search-container .search-popup ul li.suggestions{font-size:15px;line-height:36px;padding:0 15px 0 44px;align-items:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer}.search-container .search-popup ul li.suggestions:hover{background-color:#fee8e8}.search-container .search-popup ul li.suggestions svg{margin-right:5px}.search-container .search-popup ul li.suggestions-categorize-false:hover{background-color:#fee8e8}.search-container .search-popup .search-result{padding:10px 0 0;margin:0 -15px}.search-container .search-popup .search-result.no-categorize-result ul{width:100%;padding:0;margin:0 0 10px}.search-container .search-popup .search-result.no-categorize-result ul li{font-size:15px;line-height:36px;padding:0 15px 0 31px;display:flex;align-items:center;cursor:pointer}.search-container .search-popup .search-result.no-categorize-result ul li:hover{background-color:#fee8e8}.search-container .search-popup .search-result.no-categorize-result ul li img{width:18px;margin-right:9px}.search-container .search-popup .suggestions-heading{color:#9c9c9c;font-size:14px;font-weight:400;margin:0 0 10px 17px;display:flex;align-items:center;position:relative}.search-container .search-popup .suggestions-heading .show-more{position:absolute;right:20px;color:#d1d1d1;font-size:12px;cursor:pointer;text-decoration:none}.search-container .search-popup .suggestions-heading .show-more :hover{text-decoration:underline}.search-container .search-popup .suggestions-heading img{width:18px;margin-right:9px}.search-container .search-popup .recent-searches{padding:10px 0 0;margin:0 -15px}.search-container .search-popup .recent-searches ul{display:inline-block;width:100%}.search-container .search-popup .recent-searches ul li.suggestions{display:flex}.search-container .search-popup .recent-searches ul li.suggestions span{width:100%;overflow:hidden;text-overflow:ellipsis}.search-container .search-popup .recent-searches .suggestions{display:flex}.search-container .search-popup .recent-searches .suggestions-heading{margin-left:30px}.search-container .search-popup .recent-searches li.suggestions{padding-left:31px}::ng-deep .search-select.mat-select-panel{margin-top:30px;margin-left:10px}::ng-deep .search-select .mat-option-text{display:contents!important}::ng-deep .toolbar-search .mat-form-field-infix{font-size:14px}::ng-deep .toolbar-search input{line-height:14px}::ng-deep .toolbar-search .mat-form-field-outline:first-child .mat-form-field-outline-start,::ng-deep .toolbar-search .mat-form-field-outline:first-child .mat-form-field-outline-end{background-color:#f1f3f4}::ng-deep .toolbar-search:hover .toolbar-search-input.mat-form-field:not(.mat-form-field-disabled) .mat-form-field-outline .mat-form-field-outline-start{border-width:1px!important;border-color:#a53159!important}::ng-deep .toolbar-search:hover .toolbar-search-input.mat-form-field:not(.mat-form-field-disabled) .mat-form-field-outline .mat-form-field-outline-end{border:1px solid #a53159!important;border-left-style:none!important;border-right-style:none!important;border-top-right-radius:0!important;border-bottom-right-radius:0!important}::ng-deep .toolbar-search:hover .toolbar-search-select.mat-form-field:not(.mat-form-field-disabled) .mat-form-field-outline .mat-form-field-outline-start{border-radius:0;border-color:transparent!important;background-color:#a53159!important}::ng-deep .toolbar-search:hover .toolbar-search-select.mat-form-field:not(.mat-form-field-disabled) .mat-form-field-outline .mat-form-field-outline-end{border-width:1px!important;border-color:#a53159!important;background-color:#a53159!important}::ng-deep .toolbar-search:hover .toolbar-search-select.mat-form-field:not(.mat-form-field-disabled) .mat-select{color:#fff!important}::ng-deep .toolbar-search:hover .toolbar-search-select.mat-form-field:not(.mat-form-field-disabled) .icomoon.arrow_down{color:#fff}::ng-deep .toolbar-search:focus-within .toolbar-search-input.mat-form-field:not(.mat-form-field-disabled) .mat-form-field-outline .mat-form-field-outline-start{border-width:2px!important;border-color:#90003b!important}::ng-deep .toolbar-search:focus-within .toolbar-search-input.mat-form-field:not(.mat-form-field-disabled) .mat-form-field-outline .mat-form-field-outline-end{border:2px solid #90003b!important;border-left-style:none!important;border-right-style:none!important;border-top-right-radius:0!important;border-bottom-right-radius:0!important}::ng-deep .toolbar-search:focus-within .toolbar-search-select.mat-form-field:not(.mat-form-field-disabled) .mat-form-field-outline .mat-form-field-outline-start{border-radius:0;border-color:transparent!important;background-color:#90003b!important}::ng-deep .toolbar-search:focus-within .toolbar-search-select.mat-form-field:not(.mat-form-field-disabled) .mat-form-field-outline .mat-form-field-outline-end{border-width:2px!important;border-color:#90003b!important;background-color:#90003b!important}::ng-deep .toolbar-search:focus-within .toolbar-search-select.mat-form-field:not(.mat-form-field-disabled) .mat-select{color:#fff!important}::ng-deep .toolbar-search:focus-within .toolbar-search-select.mat-form-field:not(.mat-form-field-disabled) .icomoon.arrow_down{color:#fff}::ng-deep .toolbar-search .mat-select-arrow{opacity:0}\n"] }]
|
|
312
|
+
}], ctorParameters: function () {
|
|
313
|
+
return [{ type: undefined, decorators: [{
|
|
314
|
+
type: Inject,
|
|
315
|
+
args: [SEARCH_SERVICE_TOKEN]
|
|
316
|
+
}] }, { type: Object, decorators: [{
|
|
317
|
+
type: Inject,
|
|
318
|
+
args: [PLATFORM_ID]
|
|
319
|
+
}] }, { type: i0.ChangeDetectorRef }];
|
|
320
|
+
}, propDecorators: { config: [{
|
|
321
|
+
type: Input
|
|
322
|
+
}], titleTemplate: [{
|
|
323
|
+
type: Input
|
|
324
|
+
}], subtitleTemplate: [{
|
|
325
|
+
type: Input
|
|
326
|
+
}], clicked: [{
|
|
327
|
+
type: Output
|
|
328
|
+
}], searched: [{
|
|
329
|
+
type: Output
|
|
330
|
+
}], searchInputElement: [{
|
|
331
|
+
type: ViewChild,
|
|
332
|
+
args: ['searchInput']
|
|
333
|
+
}] } });
|
|
334
|
+
|
|
335
|
+
class SearchLibModule {
|
|
336
|
+
}
|
|
337
|
+
SearchLibModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: SearchLibModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
338
|
+
SearchLibModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: SearchLibModule, declarations: [SearchComponent], imports: [CommonModule,
|
|
339
|
+
FormsModule,
|
|
340
|
+
HttpClientModule,
|
|
341
|
+
MatSelectModule,
|
|
342
|
+
MatFormFieldModule,
|
|
343
|
+
MatIconModule,
|
|
344
|
+
MatInputModule,
|
|
345
|
+
FlexLayoutModule], exports: [SearchComponent] });
|
|
346
|
+
SearchLibModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: SearchLibModule, imports: [[
|
|
347
|
+
CommonModule,
|
|
348
|
+
FormsModule,
|
|
349
|
+
HttpClientModule,
|
|
350
|
+
MatSelectModule,
|
|
351
|
+
MatFormFieldModule,
|
|
352
|
+
MatIconModule,
|
|
353
|
+
MatInputModule,
|
|
354
|
+
FlexLayoutModule,
|
|
355
|
+
]] });
|
|
356
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: SearchLibModule, decorators: [{
|
|
357
|
+
type: NgModule,
|
|
358
|
+
args: [{
|
|
359
|
+
declarations: [SearchComponent],
|
|
360
|
+
imports: [
|
|
361
|
+
CommonModule,
|
|
362
|
+
FormsModule,
|
|
363
|
+
HttpClientModule,
|
|
364
|
+
MatSelectModule,
|
|
365
|
+
MatFormFieldModule,
|
|
366
|
+
MatIconModule,
|
|
367
|
+
MatInputModule,
|
|
368
|
+
FlexLayoutModule,
|
|
369
|
+
],
|
|
370
|
+
exports: [SearchComponent],
|
|
371
|
+
}]
|
|
372
|
+
}] });
|
|
373
|
+
|
|
374
|
+
class Configuration {
|
|
375
|
+
constructor(d) {
|
|
376
|
+
checkForError(d);
|
|
377
|
+
this.displayPropertyName = d.displayPropertyName;
|
|
378
|
+
this.models = d.models;
|
|
379
|
+
/* IRequestParameters - will be given default values before call is made in case undefined/null,
|
|
380
|
+
otherwise there ! is used on which sonar gives code smell */
|
|
381
|
+
this.limit = d.limit;
|
|
382
|
+
this.limitByType = d.limitByType;
|
|
383
|
+
this.order = d.order;
|
|
384
|
+
this.offset = d.offset;
|
|
385
|
+
this.saveInRecents = d.saveInRecents;
|
|
386
|
+
const displayTexts = setDisplayText(d);
|
|
387
|
+
this.noResultMessage = displayTexts.noResultMessage;
|
|
388
|
+
this.placeholder = displayTexts.placeholder;
|
|
389
|
+
this.placeholderFunction = displayTexts.placeholderFunction;
|
|
390
|
+
const searchConfig = setSearchConfig(d);
|
|
391
|
+
this.categorizeResults = searchConfig.categorizeResults;
|
|
392
|
+
this.hideRecentSearch = searchConfig.hideRecentSearch;
|
|
393
|
+
this.hideCategorizeButton = searchConfig.hideCategorizeButton;
|
|
394
|
+
this.saveInRecentsOnlyOnEnter = searchConfig.saveInRecentsOnlyOnEnter;
|
|
395
|
+
this.searchOnlyOnEnter = searchConfig.searchOnlyOnEnter;
|
|
396
|
+
const classes = setIconClasses(d);
|
|
397
|
+
this.searchIconClass = classes.searchIconClass;
|
|
398
|
+
this.crossIconClass = classes.crossIconClass;
|
|
399
|
+
this.dropDownButtonIconClass = classes.dropDownButtonIconClass;
|
|
400
|
+
this.recentSearchIconClass = classes.recentSearchIconClass;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
function checkForError(d) {
|
|
404
|
+
if (d.categorizeResults === false &&
|
|
405
|
+
(d.hideCategorizeButton === false || d.hideCategorizeButton === undefined)) {
|
|
406
|
+
throw new Error('You must provide hideCategorizeButton:true as categorizeResults is false');
|
|
407
|
+
}
|
|
408
|
+
if (d.saveInRecents === false && d.saveInRecentsOnlyOnEnter === true) {
|
|
409
|
+
throw new Error('You must provide saveInRecents:true for saveInRecentsOnlyOnEnter:true');
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
function setDisplayText(d) {
|
|
413
|
+
var _a, _b;
|
|
414
|
+
return {
|
|
415
|
+
placeholder: (_a = d.placeholder) !== null && _a !== void 0 ? _a : 'Search',
|
|
416
|
+
noResultMessage: (_b = d.noResultMessage) !== null && _b !== void 0 ? _b : 'No result found',
|
|
417
|
+
placeholderFunction: d.placeholderFunction,
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
function setSearchConfig(d) {
|
|
421
|
+
var _a, _b, _c, _d, _e;
|
|
422
|
+
return {
|
|
423
|
+
categorizeResults: (_a = d.categorizeResults) !== null && _a !== void 0 ? _a : true,
|
|
424
|
+
hideRecentSearch: (_b = d.hideRecentSearch) !== null && _b !== void 0 ? _b : false,
|
|
425
|
+
hideCategorizeButton: (_c = d.hideCategorizeButton) !== null && _c !== void 0 ? _c : false,
|
|
426
|
+
saveInRecentsOnlyOnEnter: (_d = d.saveInRecentsOnlyOnEnter) !== null && _d !== void 0 ? _d : false,
|
|
427
|
+
searchOnlyOnEnter: (_e = d.searchOnlyOnEnter) !== null && _e !== void 0 ? _e : false,
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
function setIconClasses(d) {
|
|
431
|
+
var _a, _b, _c, _d;
|
|
432
|
+
return {
|
|
433
|
+
searchIconClass: (_a = d.searchIconClass) !== null && _a !== void 0 ? _a : 'icomoon Search',
|
|
434
|
+
crossIconClass: (_b = d.crossIconClass) !== null && _b !== void 0 ? _b : 'icomoon close',
|
|
435
|
+
dropDownButtonIconClass: (_c = d.dropDownButtonIconClass) !== null && _c !== void 0 ? _c : 'icomoon arrow_down',
|
|
436
|
+
recentSearchIconClass: (_d = d.recentSearchIconClass) !== null && _d !== void 0 ? _d : 'icomoon Search',
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/*
|
|
441
|
+
* Public API Surface of my-lib
|
|
442
|
+
*/
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Generated bundle index. Do not edit.
|
|
446
|
+
*/
|
|
447
|
+
|
|
448
|
+
export { Configuration, DEBOUNCE_TIME, DEFAULT_LIMIT, DEFAULT_LIMIT_TYPE, DEFAULT_OFFSET, DEFAULT_ORDER, DEFAULT_SAVE_IN_RECENTS, SEARCH_SERVICE_TOKEN, SearchComponent, SearchLibModule };
|
|
449
|
+
//# sourceMappingURL=sourceloop-search-client.mjs.map
|