@sourceloop/search-client 1.2.1 → 4.3.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.
Files changed (29) hide show
  1. package/assets/icomoon/fonts/icomoon.ttf +0 -0
  2. package/assets/icomoon/style.css +32 -0
  3. package/bundles/sourceloop-search-client.umd.js +96 -39
  4. package/bundles/sourceloop-search-client.umd.js.map +1 -1
  5. package/esm2015/lib/lib-configuration.js +53 -16
  6. package/esm2015/lib/lib-configuration.ngsummary.json +1 -0
  7. package/esm2015/lib/search/search.component.js +45 -25
  8. package/esm2015/lib/search/search.component.ngfactory.js +129 -0
  9. package/esm2015/lib/search/search.component.ngsummary.json +1 -0
  10. package/esm2015/lib/search/search.component.scss.shim.ngstyle.js +9 -0
  11. package/esm2015/lib/search-lib.module.js +1 -1
  12. package/esm2015/lib/search-lib.module.ngfactory.js +32 -0
  13. package/esm2015/lib/search-lib.module.ngsummary.json +1 -0
  14. package/esm2015/lib/types.js +1 -1
  15. package/esm2015/lib/types.ngsummary.json +1 -0
  16. package/esm2015/public-api.js +1 -1
  17. package/esm2015/public-api.ngsummary.json +1 -0
  18. package/esm2015/sourceloop-search-client.js +1 -1
  19. package/esm2015/sourceloop-search-client.ngsummary.json +1 -0
  20. package/fesm2015/sourceloop-search-client.js +96 -39
  21. package/fesm2015/sourceloop-search-client.js.map +1 -1
  22. package/lib/lib-configuration.d.ts +6 -0
  23. package/lib/search/search.component.d.ts +10 -6
  24. package/lib/search/search.component.ngfactory.d.ts +1 -0
  25. package/lib/search/search.component.scss.shim.ngstyle.d.ts +1 -0
  26. package/lib/search-lib.module.ngfactory.d.ts +3 -0
  27. package/lib/types.d.ts +1 -1
  28. package/package.json +12 -6
  29. package/sourceloop-search-client.metadata.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import { isPlatformBrowser, CommonModule } from '@angular/common';
2
2
  import { HttpClientModule } from '@angular/common/http';
3
- import { InjectionToken, EventEmitter, Component, Inject, PLATFORM_ID, Input, Output, ViewChild, NgModule } from '@angular/core';
3
+ import { InjectionToken, EventEmitter, Component, Inject, PLATFORM_ID, ChangeDetectorRef, Input, Output, ViewChild, NgModule } from '@angular/core';
4
4
  import { FlexLayoutModule } from '@angular/flex-layout';
5
5
  import { NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
6
6
  import { MatFormFieldModule } from '@angular/material/form-field';
@@ -24,15 +24,15 @@ const ALL_LABEL = 'All';
24
24
  class SearchComponent {
25
25
  constructor(searchService,
26
26
  // tslint:disable-next-line:ban-types
27
- platformId) {
27
+ platformId, cdr) {
28
28
  this.searchService = searchService;
29
29
  this.platformId = platformId;
30
+ this.cdr = cdr;
30
31
  this.searchBoxInput = '';
31
32
  this.suggestionsDisplay = false;
32
33
  this.categoryDisplay = false;
33
34
  this.searching = false;
34
35
  this.suggestions = [];
35
- this.relevantSuggestions = [];
36
36
  this.recentSearches = [];
37
37
  this.category = ALL_LABEL;
38
38
  this.searchRequest$ = new Subject();
@@ -61,7 +61,7 @@ class SearchComponent {
61
61
  ];
62
62
  }
63
63
  else {
64
- //do nothing
64
+ // do nothing
65
65
  }
66
66
  }
67
67
  ngOnInit() {
@@ -74,6 +74,7 @@ class SearchComponent {
74
74
  category: this.category,
75
75
  });
76
76
  this.getSuggestions(value);
77
+ this.cdr.markForCheck();
77
78
  });
78
79
  }
79
80
  // ControlValueAccessor Implementation
@@ -92,6 +93,10 @@ class SearchComponent {
92
93
  }
93
94
  getSuggestions(eventValue) {
94
95
  var _a, _b, _c, _d, _e;
96
+ eventValue.input = eventValue.input.trim();
97
+ if (!eventValue.input.length) {
98
+ return;
99
+ }
95
100
  const order = (_a = this.config.order) !== null && _a !== void 0 ? _a : DEFAULT_ORDER;
96
101
  let orderString = '';
97
102
  order.forEach(preference => (orderString = `${orderString}${preference} `));
@@ -118,14 +123,17 @@ class SearchComponent {
118
123
  offset: (_e = this.config.offset) !== null && _e !== void 0 ? _e : DEFAULT_OFFSET,
119
124
  };
120
125
  this.searching = true;
126
+ this.cdr.markForCheck();
121
127
  this.searchService
122
128
  .searchApiRequest(requestParameters, saveInRecents)
123
129
  .subscribe((value) => {
124
130
  this.suggestions = value;
125
131
  this.searching = false;
132
+ this.cdr.markForCheck();
126
133
  }, (_error) => {
127
134
  this.suggestions = [];
128
135
  this.searching = false;
136
+ this.cdr.markForCheck();
129
137
  });
130
138
  }
131
139
  getRecentSearches() {
@@ -133,8 +141,10 @@ class SearchComponent {
133
141
  this.searchService.recentSearchApiRequest) {
134
142
  this.searchService.recentSearchApiRequest().subscribe((value) => {
135
143
  this.recentSearches = value;
144
+ this.cdr.markForCheck();
136
145
  }, (_error) => {
137
146
  this.recentSearches = [];
147
+ this.cdr.markForCheck();
138
148
  });
139
149
  }
140
150
  }
@@ -188,29 +198,13 @@ class SearchComponent {
188
198
  fetchModelImageUrlFromSuggestion(suggestion) {
189
199
  const modelName = suggestion['source'];
190
200
  let url;
191
- this.config.models.forEach((model, i) => {
201
+ this.config.models.forEach(model => {
192
202
  if (model.name === modelName && model.imageUrl) {
193
203
  url = model.imageUrl;
194
204
  }
195
205
  });
196
206
  return url;
197
207
  }
198
- // also returns true if there are any suggestions related to the model
199
- getSuggestionsFromModelName(modelName) {
200
- this.relevantSuggestions = [];
201
- this.suggestions.forEach(suggestion => {
202
- const sourceModelName = suggestion['source'];
203
- if (sourceModelName === modelName) {
204
- this.relevantSuggestions.push(suggestion);
205
- }
206
- });
207
- if (this.relevantSuggestions.length) {
208
- return true;
209
- }
210
- else {
211
- return false;
212
- }
213
- }
214
208
  boldString(str, substr) {
215
209
  const strRegExp = new RegExp(`(${substr})`, 'gi');
216
210
  const stringToMakeBold = str;
@@ -246,6 +240,7 @@ class SearchComponent {
246
240
  }
247
241
  resetInput() {
248
242
  this.searchBoxInput = '';
243
+ this.suggestions = [];
249
244
  this.suggestionsDisplay = true;
250
245
  this.focusInput();
251
246
  // ngModelChange doesn't detect change in value when populated from outside, hence calling manually
@@ -263,11 +258,35 @@ class SearchComponent {
263
258
  return [category];
264
259
  }
265
260
  }
261
+ getModelFromModelName(name) {
262
+ return this.config.models.find(item => item.name === name);
263
+ }
264
+ getModelsWithSuggestions() {
265
+ const modelsWithSuggestions = [];
266
+ const sources = [];
267
+ this.suggestions.forEach(suggestion => {
268
+ if (sources.indexOf(suggestion['source']) >= 0) {
269
+ modelsWithSuggestions.every(modelWithSuggestions => {
270
+ if (modelWithSuggestions.model.name === suggestion['source']) {
271
+ modelWithSuggestions.items.push(suggestion);
272
+ return false;
273
+ }
274
+ return true;
275
+ });
276
+ }
277
+ else {
278
+ const model = this.getModelFromModelName(suggestion['source']);
279
+ modelsWithSuggestions.push({ model, items: [suggestion] });
280
+ sources.push(suggestion['source']);
281
+ }
282
+ });
283
+ return modelsWithSuggestions;
284
+ }
266
285
  }
267
286
  SearchComponent.decorators = [
268
287
  { type: Component, args: [{
269
288
  selector: 'sourceloop-search',
270
- 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]=\"config.placeholder || 'Search'\"\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 class=\"icomoon Search\"></mat-icon>\n <mat-icon\n *ngIf=\"searchBoxInput\"\n matSuffix\n class=\"icomoon close\"\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 class=\"icomoon arrow_down\"></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 *ngIf=\"suggestionsDisplay\" class=\"search-popup\">\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\">\n <div class=\"search-result\" *ngFor=\"let model of config.models\">\n <h3\n *ngIf=\"getSuggestionsFromModelName(model.name)\"\n class=\"suggestions-heading\"\n >\n <img\n *ngIf=\"model.imageUrl\"\n [src]=\"model.imageUrl\"\n [alt]=\"model.displayName\"\n />\n {{ model.displayName }} ({{ relevantSuggestions?.length }})\n </h3>\n <ul>\n <li\n *ngFor=\"let suggestion of relevantSuggestions\"\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 <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M2 6.5C2 8.981 4.0185 11 6.5 11C8.981 11 11 8.981 11 6.5C11 4.0185 8.981 2 6.5 2C4.0185 2 2 4.0185 2 6.5ZM1 6.5C1 3.4625 3.4625 1 6.5 1C9.5375 1 12 3.4625 12 6.5C12 9.5375 9.5375 12 6.5 12C3.4625 12 1 9.5375 1 6.5ZM10.7236 11.4306C10.9771 11.2131 11.2131 10.9771 11.4306 10.7236L15.0001 14.2926L14.2931 15.0001L10.7236 11.4306Z\"\n fill=\"#9C9C9C\"\n />\n </svg>\n <span>{{ recentSearch.match }}</span>\n </li>\n </ul>\n </div>\n </ng-container>\n </div>\n</div>\n",
289
+ 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>&nbsp;{{ recentSearch.match }}</span>\n </li>\n </ul>\n </div>\n </ng-container>\n </div>\n</div>\n",
271
290
  providers: [
272
291
  {
273
292
  provide: NG_VALUE_ACCESSOR,
@@ -275,12 +294,13 @@ SearchComponent.decorators = [
275
294
  multi: true,
276
295
  },
277
296
  ],
278
- 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:360px}.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}.icomoon.arrow_down{margin-bottom:4px}.toolbar-search-select{width:30%}.toolbar-search-select ::ng-deep .mat-select-arrow{opacity:0}.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:-webkit-sticky;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:normal;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"]
297
+ 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:calc(100% - 86%)}.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:-webkit-sticky;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:normal;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"]
279
298
  },] }
280
299
  ];
281
300
  SearchComponent.ctorParameters = () => [
282
301
  { type: undefined, decorators: [{ type: Inject, args: [SEARCH_SERVICE_TOKEN,] }] },
283
- { type: Object, decorators: [{ type: Inject, args: [PLATFORM_ID,] }] }
302
+ { type: Object, decorators: [{ type: Inject, args: [PLATFORM_ID,] }] },
303
+ { type: ChangeDetectorRef }
284
304
  ];
285
305
  SearchComponent.propDecorators = {
286
306
  config: [{ type: Input }],
@@ -312,17 +332,9 @@ SearchLibModule.decorators = [
312
332
 
313
333
  class Configuration {
314
334
  constructor(d) {
315
- var _a, _b, _c, _d, _e, _f, _g;
316
- if (d.categorizeResults === false &&
317
- (d.hideCategorizeButton === false || d.hideCategorizeButton === undefined)) {
318
- throw new Error('You must provide hideCategorizeButton:true as categorizeResults is false');
319
- }
320
- if (d.saveInRecents === false && d.saveInRecentsOnlyOnEnter === true) {
321
- throw new Error('You must provide saveInRecents:true for saveInRecentsOnlyOnEnter:true');
322
- }
335
+ checkForError(d);
323
336
  this.displayPropertyName = d.displayPropertyName;
324
337
  this.models = d.models;
325
- this.placeholder = (_a = d.placeholder) !== null && _a !== void 0 ? _a : 'Search';
326
338
  /* IRequestParameters - will be given default values before call is made in case undefined/null,
327
339
  otherwise there ! is used on which sonar gives code smell */
328
340
  this.limit = d.limit;
@@ -330,14 +342,59 @@ class Configuration {
330
342
  this.order = d.order;
331
343
  this.offset = d.offset;
332
344
  this.saveInRecents = d.saveInRecents;
333
- this.categorizeResults = (_b = d.categorizeResults) !== null && _b !== void 0 ? _b : true;
334
- this.hideRecentSearch = (_c = d.hideRecentSearch) !== null && _c !== void 0 ? _c : false;
335
- this.hideCategorizeButton = (_d = d.hideCategorizeButton) !== null && _d !== void 0 ? _d : false;
336
- this.saveInRecentsOnlyOnEnter = (_e = d.saveInRecentsOnlyOnEnter) !== null && _e !== void 0 ? _e : false;
337
- this.searchOnlyOnEnter = (_f = d.searchOnlyOnEnter) !== null && _f !== void 0 ? _f : false;
338
- this.noResultMessage = (_g = d.noResultMessage) !== null && _g !== void 0 ? _g : 'No result found';
345
+ const displayTexts = setDisplayText(d);
346
+ this.noResultMessage = displayTexts.noResultMessage;
347
+ this.placeholder = displayTexts.placeholder;
348
+ this.placeholderFunction = displayTexts.placeholderFunction;
349
+ const searchConfig = setSearchConfig(d);
350
+ this.categorizeResults = searchConfig.categorizeResults;
351
+ this.hideRecentSearch = searchConfig.hideRecentSearch;
352
+ this.hideCategorizeButton = searchConfig.hideCategorizeButton;
353
+ this.saveInRecentsOnlyOnEnter = searchConfig.saveInRecentsOnlyOnEnter;
354
+ this.searchOnlyOnEnter = searchConfig.searchOnlyOnEnter;
355
+ const classes = setIconClasses(d);
356
+ this.searchIconClass = classes.searchIconClass;
357
+ this.crossIconClass = classes.crossIconClass;
358
+ this.dropDownButtonIconClass = classes.dropDownButtonIconClass;
359
+ this.recentSearchIconClass = classes.recentSearchIconClass;
339
360
  }
340
361
  }
362
+ function checkForError(d) {
363
+ if (d.categorizeResults === false &&
364
+ (d.hideCategorizeButton === false || d.hideCategorizeButton === undefined)) {
365
+ throw new Error('You must provide hideCategorizeButton:true as categorizeResults is false');
366
+ }
367
+ if (d.saveInRecents === false && d.saveInRecentsOnlyOnEnter === true) {
368
+ throw new Error('You must provide saveInRecents:true for saveInRecentsOnlyOnEnter:true');
369
+ }
370
+ }
371
+ function setDisplayText(d) {
372
+ var _a, _b;
373
+ return {
374
+ placeholder: (_a = d.placeholder) !== null && _a !== void 0 ? _a : 'Search',
375
+ noResultMessage: (_b = d.noResultMessage) !== null && _b !== void 0 ? _b : 'No result found',
376
+ placeholderFunction: d.placeholderFunction,
377
+ };
378
+ }
379
+ function setSearchConfig(d) {
380
+ var _a, _b, _c, _d, _e;
381
+ return {
382
+ categorizeResults: (_a = d.categorizeResults) !== null && _a !== void 0 ? _a : true,
383
+ hideRecentSearch: (_b = d.hideRecentSearch) !== null && _b !== void 0 ? _b : false,
384
+ hideCategorizeButton: (_c = d.hideCategorizeButton) !== null && _c !== void 0 ? _c : false,
385
+ saveInRecentsOnlyOnEnter: (_d = d.saveInRecentsOnlyOnEnter) !== null && _d !== void 0 ? _d : false,
386
+ searchOnlyOnEnter: (_e = d.searchOnlyOnEnter) !== null && _e !== void 0 ? _e : false,
387
+ };
388
+ }
389
+ function setIconClasses(d) {
390
+ var _a, _b, _c, _d;
391
+ return {
392
+ searchIconClass: (_a = d.searchIconClass) !== null && _a !== void 0 ? _a : 'icomoon Search',
393
+ crossIconClass: (_b = d.crossIconClass) !== null && _b !== void 0 ? _b : 'icomoon close',
394
+ dropDownButtonIconClass: (_c = d.dropDownButtonIconClass) !== null && _c !== void 0 ? _c : 'icomoon arrow_down',
395
+ recentSearchIconClass: (_d = d.recentSearchIconClass) !== null && _d !== void 0 ? _d : 'icomoon Search',
396
+ };
397
+ }
341
398
 
342
399
  /*
343
400
  * Public API Surface of my-lib
@@ -1 +1 @@
1
- {"version":3,"file":"sourceloop-search-client.js","sources":["../../projects/search-lib/src/lib/types.ts","../../projects/search-lib/src/lib/search/search.component.ts","../../projects/search-lib/src/lib/search-lib.module.ts","../../projects/search-lib/src/lib/lib-configuration.ts","../../projects/search-lib/src/public-api.ts","../../projects/search-lib/src/sourceloop-search-client.ts"],"sourcesContent":["import {InjectionToken} from '@angular/core';\nimport {Observable} from 'rxjs';\n\nexport interface ISearchQuery {\n match: string;\n limit: number | null;\n order: string | null;\n limitByType: boolean | null;\n offset: number | null;\n sources: string[] | null;\n}\nexport interface IModel {\n name: string;\n displayName: string;\n imageUrl?: string;\n icon?: string;\n}\nexport interface IReturnType {\n rank: number;\n source: string;\n}\nexport interface IDefaultReturnType extends IReturnType {\n name: string;\n description: string;\n}\n\nexport interface ISearchService<T extends IReturnType> {\n searchApiRequest(\n requestParameters: ISearchQuery,\n saveInRecents: boolean,\n ): Observable<T[]>;\n recentSearchApiRequest?(): Observable<ISearchQuery[]>;\n}\n\n// cant use T extends IReturnType here\nexport const SEARCH_SERVICE_TOKEN: InjectionToken<ISearchService<IReturnType>> =\n new InjectionToken<ISearchService<IReturnType>>('Search_Service_Token');\n\nexport type RecentSearchEvent = {\n event?: Event;\n keyword: string;\n category: string;\n};\n\nexport type ItemClickedEvent<T> = {\n event: MouseEvent;\n item: T;\n};\n\nexport type TypeEvent = {\n event?: Event;\n input: string;\n};\n// IRequestParameters default values\nexport const DEFAULT_LIMIT = 20;\nexport const DEFAULT_LIMIT_TYPE = false;\nexport const DEFAULT_ORDER = [];\nexport const DEBOUNCE_TIME = 1000;\nexport const DEFAULT_OFFSET = 0;\nexport const DEFAULT_SAVE_IN_RECENTS = true;\n","import {\n Component,\n ElementRef,\n EventEmitter,\n Inject,\n Input,\n OnDestroy,\n OnInit,\n Output,\n PLATFORM_ID,\n TemplateRef,\n ViewChild,\n} from '@angular/core';\nimport {Configuration} from '../lib-configuration';\nimport {Subject} from 'rxjs';\nimport {debounceTime, tap} from 'rxjs/operators';\nimport {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';\nimport {\n ISearchService,\n ISearchQuery,\n SEARCH_SERVICE_TOKEN,\n DEBOUNCE_TIME,\n DEFAULT_LIMIT,\n DEFAULT_LIMIT_TYPE,\n DEFAULT_OFFSET,\n DEFAULT_SAVE_IN_RECENTS,\n DEFAULT_ORDER,\n IReturnType,\n RecentSearchEvent,\n TypeEvent,\n ItemClickedEvent,\n} from '../types';\nimport {isPlatformBrowser} from '@angular/common';\n\nconst ALL_LABEL = 'All';\n@Component({\n selector: 'sourceloop-search',\n templateUrl: './search.component.html',\n styleUrls: ['./search.component.scss'],\n providers: [\n {\n provide: NG_VALUE_ACCESSOR,\n useExisting: SearchComponent,\n multi: true,\n },\n ],\n})\nexport class SearchComponent<T extends IReturnType>\n implements OnInit, OnDestroy, ControlValueAccessor\n{\n searchBoxInput = '';\n suggestionsDisplay = false;\n categoryDisplay = false;\n searching = false;\n suggestions: T[] = [];\n relevantSuggestions: T[] = [];\n recentSearches: ISearchQuery[] = [];\n category: string = ALL_LABEL;\n searchRequest$ = new Subject<{input: string; event: Event}>();\n\n private _config!: Configuration<T>;\n public get config(): Configuration<T> {\n return this._config;\n }\n @Input()\n public set config(value: Configuration<T>) {\n this._config = value;\n\n if (value && value.models) {\n value.models.unshift({\n name: ALL_LABEL,\n displayName: ALL_LABEL,\n });\n } else if (value && !value.models) {\n value.models = [\n {\n name: ALL_LABEL,\n displayName: ALL_LABEL,\n },\n ];\n } else {\n //do nothing\n }\n }\n\n @Input() titleTemplate?: TemplateRef<any>;\n @Input() subtitleTemplate?: TemplateRef<any>;\n // emitted when user clicks one of the suggested results (including recent search sugestions)\n @Output() clicked = new EventEmitter<ItemClickedEvent<T>>();\n @Output() searched = new EventEmitter<RecentSearchEvent>();\n /* emitted when user makes search request (including recent search requests & requests made on change in category from dropdown)\n In case of recent search Array of recent Search request result is emitted */\n\n onChange!: (value: string | undefined) => void;\n onTouched!: () => void;\n disabled = false;\n\n @ViewChild('searchInput') public searchInputElement!: ElementRef;\n\n constructor(\n @Inject(SEARCH_SERVICE_TOKEN)\n private readonly searchService: ISearchService<T>,\n // tslint:disable-next-line:ban-types\n @Inject(PLATFORM_ID) private readonly platformId: Object,\n ) {}\n\n ngOnInit(): void {\n this.searchRequest$\n .pipe(\n tap(v => (this.suggestions = [])),\n debounceTime(DEBOUNCE_TIME),\n )\n .subscribe((value: TypeEvent) => {\n this.searched.emit({\n event: value.event,\n keyword: value.input,\n category: this.category,\n });\n this.getSuggestions(value);\n });\n }\n\n // ControlValueAccessor Implementation\n writeValue(value: string): void {\n this.searchBoxInput = value;\n }\n // When the value in the UI is changed, this method will invoke a callback function\n registerOnChange(fn: (value: string | undefined) => void): void {\n this.onChange = fn;\n }\n registerOnTouched(fn: () => void): void {\n this.onTouched = fn;\n }\n setDisabledState?(isDisabled: boolean): void {\n this.disabled = isDisabled;\n }\n\n getSuggestions(eventValue: TypeEvent) {\n const order = this.config.order ?? DEFAULT_ORDER;\n let orderString = '';\n order.forEach(preference => (orderString = `${orderString}${preference} `));\n\n let saveInRecents = this.config.saveInRecents ?? DEFAULT_SAVE_IN_RECENTS;\n if (this.config.saveInRecents && this.config.saveInRecentsOnlyOnEnter) {\n if (\n !eventValue.event ||\n (eventValue.event instanceof KeyboardEvent &&\n eventValue.event.key === 'Enter')\n ) {\n saveInRecents = true; // save in recents only on enter or change in category\n } else {\n // do not save in recent search on typing\n saveInRecents = false;\n }\n }\n /* need to put default value here and not in contructor\n because sonar was giving code smell with definite assertion as all these parameters are optional */\n const requestParameters: ISearchQuery = {\n match: eventValue.input,\n sources: this._categoryToSourceName(this.category),\n limit: this.config.limit ?? DEFAULT_LIMIT,\n limitByType: this.config.limitByType ?? DEFAULT_LIMIT_TYPE,\n order: orderString,\n offset: this.config.offset ?? DEFAULT_OFFSET,\n };\n\n this.searching = true;\n this.searchService\n .searchApiRequest(requestParameters, saveInRecents)\n .subscribe(\n (value: T[]) => {\n this.suggestions = value;\n this.searching = false;\n },\n (_error: Error) => {\n this.suggestions = [];\n this.searching = false;\n },\n );\n }\n getRecentSearches() {\n if (\n !this.config.hideRecentSearch &&\n this.searchService.recentSearchApiRequest\n ) {\n this.searchService.recentSearchApiRequest().subscribe(\n (value: ISearchQuery[]) => {\n this.recentSearches = value;\n },\n (_error: Error) => {\n this.recentSearches = [];\n },\n );\n }\n }\n\n // event can be KeyBoardEvent or Event of type 'change' fired on change in value of drop down for category\n hitSearchApi(event?: Event) {\n // this will happen only in case user searches something and then erases it, we need to update recent search\n if (!this.searchBoxInput) {\n this.suggestions = [];\n this.getRecentSearches();\n return;\n }\n\n // no debounce time needed in case of searchOnlyOnEnter\n if (this.config.searchOnlyOnEnter) {\n if (!event || (event instanceof KeyboardEvent && event.key === 'Enter')) {\n this.getSuggestions({input: this.searchBoxInput, event});\n }\n return;\n }\n\n // no debounce time needed in case of change in category\n if (!event) {\n this.getSuggestions({input: this.searchBoxInput, event});\n return;\n }\n\n this.searchRequest$.next({\n input: this.searchBoxInput,\n event,\n });\n }\n\n populateValue(suggestion: T, event: MouseEvent) {\n const value = suggestion[\n this.config.displayPropertyName\n ] as unknown as string; // converted to string to assign value to searchBoxInput\n this.searchBoxInput = value;\n this.suggestionsDisplay = false;\n // ngModelChange doesn't detect change in value when populated from outside, hence calling manually\n this.onChange(this.searchBoxInput);\n // need to do this to show more search options for selected suggestion - just in case user reopens search input\n this.getSuggestions({input: this.searchBoxInput, event});\n this.clicked.emit({item: suggestion, event});\n }\n populateValueRecentSearch(recentSearch: ISearchQuery, event: MouseEvent) {\n event.stopPropagation();\n event.preventDefault();\n const value = recentSearch['match'];\n this.searchBoxInput = value;\n this.suggestionsDisplay = false;\n this.onChange(this.searchBoxInput);\n // need to do this to show more search options for selected suggestion - just in case user reopens search input\n this.getSuggestions({input: this.searchBoxInput, event});\n this.focusInput();\n this.showSuggestions();\n }\n\n fetchModelImageUrlFromSuggestion(suggestion: T) {\n const modelName = suggestion[\n 'source' as unknown as keyof T\n ] as unknown as string;\n let url: string | undefined;\n this.config.models.forEach((model, i) => {\n if (model.name === modelName && model.imageUrl) {\n url = model.imageUrl;\n }\n });\n return url;\n }\n\n // also returns true if there are any suggestions related to the model\n getSuggestionsFromModelName(modelName: string) {\n this.relevantSuggestions = [];\n this.suggestions.forEach(suggestion => {\n const sourceModelName = suggestion[\n 'source' as keyof T\n ] as unknown as string;\n if (sourceModelName === modelName) {\n this.relevantSuggestions.push(suggestion);\n }\n });\n if (this.relevantSuggestions.length) {\n return true;\n } else {\n return false;\n }\n }\n\n boldString(str: T[keyof T] | string, substr: string) {\n const strRegExp = new RegExp(`(${substr})`, 'gi');\n const stringToMakeBold: string = str as unknown as string;\n return stringToMakeBold.replace(strRegExp, `<b>$1</b>`);\n }\n\n hideSuggestions() {\n this.suggestionsDisplay = false;\n this.onTouched();\n }\n\n showSuggestions() {\n this.suggestionsDisplay = true;\n this.getRecentSearches();\n }\n\n focusInput() {\n if (isPlatformBrowser(this.platformId)) {\n this.searchInputElement.nativeElement.focus();\n }\n }\n\n setCategory(category: string) {\n this.category = category;\n this.categoryDisplay = false;\n if (this.searchBoxInput) {\n this.hitSearchApi();\n this.focusInput();\n this.showSuggestions();\n }\n }\n\n showCategory() {\n this.categoryDisplay = !this.categoryDisplay;\n }\n\n hideCategory() {\n this.categoryDisplay = false;\n }\n\n resetInput() {\n this.searchBoxInput = '';\n this.suggestionsDisplay = true;\n this.focusInput();\n // ngModelChange doesn't detect change in value when populated from outside, hence calling manually\n this.onChange(this.searchBoxInput);\n this.getRecentSearches();\n }\n ngOnDestroy() {\n this.searchRequest$.unsubscribe();\n }\n\n _categoryToSourceName(category: string) {\n if (category === ALL_LABEL) {\n return [];\n } else {\n return [category];\n }\n }\n}\n","import {CommonModule} from '@angular/common';\nimport {HttpClientModule} from '@angular/common/http';\nimport {NgModule} from '@angular/core';\nimport {FlexLayoutModule} from '@angular/flex-layout';\nimport {FormsModule} from '@angular/forms';\nimport {MatFormFieldModule} from '@angular/material/form-field';\nimport {MatIconModule} from '@angular/material/icon';\nimport {MatInputModule} from '@angular/material/input';\nimport {MatSelectModule} from '@angular/material/select';\n\nimport {SearchComponent} from './search/search.component';\n\n@NgModule({\n declarations: [SearchComponent],\n imports: [\n CommonModule,\n FormsModule,\n HttpClientModule,\n MatSelectModule,\n MatFormFieldModule,\n MatIconModule,\n MatInputModule,\n FlexLayoutModule,\n ],\n exports: [SearchComponent],\n})\nexport class SearchLibModule {}\n","import {IDefaultReturnType, IModel} from './types';\nexport class Configuration<T = IDefaultReturnType> {\n /** property to be displayed in the results */\n displayPropertyName: keyof T;\n /** list of model configuration to be render and categorize search results */\n models: IModel[];\n /** max number of results (based on limitByType option) */\n limit?: number;\n /** apply limit on individual models, or on overall results */\n limitByType?: boolean;\n /** apply a particular ordering on results */\n order?: string[];\n /** offset for results in case limit is used */\n offset?: number;\n /** save the search query in recent history */\n saveInRecents?: boolean;\n /** a placeholder to display in the search box */\n placeholder?: string;\n /** categorize results on the basis of models provided */\n categorizeResults?: boolean;\n /** hides the recent search list */\n hideRecentSearch?: boolean;\n /** hide the category selection button */\n hideCategorizeButton?: boolean;\n /** save value in recent search only on enter or change in category, if false, also saved on typing */\n saveInRecentsOnlyOnEnter?: boolean;\n /** search only on enter key or when category is changed */\n searchOnlyOnEnter?: boolean;\n noResultMessage?: string;\n\n constructor(d: Configuration<T>) {\n if (\n d.categorizeResults === false &&\n (d.hideCategorizeButton === false || d.hideCategorizeButton === undefined)\n ) {\n throw new Error(\n 'You must provide hideCategorizeButton:true as categorizeResults is false',\n );\n }\n if (d.saveInRecents === false && d.saveInRecentsOnlyOnEnter === true) {\n throw new Error(\n 'You must provide saveInRecents:true for saveInRecentsOnlyOnEnter:true',\n );\n }\n this.displayPropertyName = d.displayPropertyName;\n this.models = d.models;\n\n this.placeholder = d.placeholder ?? 'Search';\n /* IRequestParameters - will be given default values before call is made in case undefined/null,\n otherwise there ! is used on which sonar gives code smell */\n this.limit = d.limit;\n this.limitByType = d.limitByType;\n this.order = d.order;\n this.offset = d.offset;\n this.saveInRecents = d.saveInRecents;\n\n this.categorizeResults = d.categorizeResults ?? true;\n this.hideRecentSearch = d.hideRecentSearch ?? false;\n this.hideCategorizeButton = d.hideCategorizeButton ?? false;\n this.saveInRecentsOnlyOnEnter = d.saveInRecentsOnlyOnEnter ?? false;\n this.searchOnlyOnEnter = d.searchOnlyOnEnter ?? false;\n this.noResultMessage = d.noResultMessage ?? 'No result found';\n }\n}\n","/*\n * Public API Surface of my-lib\n */\n\nexport * from './lib/search-lib.module';\nexport * from './lib/search/search.component';\nexport * from './lib/lib-configuration';\nexport * from './lib/types';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;;AAkCA;MACa,oBAAoB,GAC/B,IAAI,cAAc,CAA8B,sBAAsB,EAAE;AAiB1E;MACa,aAAa,GAAG,GAAG;MACnB,kBAAkB,GAAG,MAAM;MAC3B,aAAa,GAAG,GAAG;MACnB,aAAa,GAAG,KAAK;MACrB,cAAc,GAAG,EAAE;MACnB,uBAAuB,GAAG;;ACzBvC,MAAM,SAAS,GAAG,KAAK,CAAC;MAaX,eAAe;IAoD1B,YAEmB,aAAgC;;IAEX,UAAkB;QAFvC,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AAM,CAAC;QACvB,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC,aAAa,CAAC;QAErC,IAAI,CAAC,iBAAiB,GAAG,MAAA,CAAC,CAAC,iBAAiB,mCAAI,IAAI,CAAC;QACrD,IAAI,CAAC,gBAAgB,GAAG,MAAA,CAAC,CAAC,gBAAgB,mCAAI,KAAK,CAAC;QACpD,IAAI,CAAC,oBAAoB,GAAG,MAAA,CAAC,CAAC,oBAAoB,mCAAI,KAAK,CAAC;QAC5D,IAAI,CAAC,wBAAwB,GAAG,MAAA,CAAC,CAAC,wBAAwB,mCAAI,KAAK,CAAC;QACpE,IAAI,CAAC,iBAAiB,GAAG,MAAA,CAAC,CAAC,iBAAiB,mCAAI,KAAK,CAAC;QACtD,IAAI,CAAC,eAAe,GAAG,MAAA,CAAC,CAAC,eAAe,mCAAI,iBAAiB,CAAC;KAC/D;;;AC9DH;;;;ACAA;;;;;;"}
1
+ {"version":3,"file":"sourceloop-search-client.js","sources":["../../src/lib/types.ts","../../src/lib/search/search.component.ts","../../src/lib/search-lib.module.ts","../../src/lib/lib-configuration.ts","../../src/public-api.ts","../../src/sourceloop-search-client.ts"],"sourcesContent":["import {InjectionToken} from '@angular/core';\nimport {Observable} from 'rxjs';\n\nexport interface ISearchQuery {\n match: string;\n limit: number | null;\n order: string | null;\n limitByType: boolean | null;\n offset: number | null;\n sources: string[] | null;\n}\nexport interface IModel {\n name: string;\n displayName: string;\n imageUrl?: string;\n icon?: string;\n}\nexport interface IReturnType {\n rank: number;\n source: string;\n}\nexport interface IDefaultReturnType extends IReturnType {\n name: string;\n description: string;\n}\n\nexport interface ISearchService<T extends IReturnType> {\n searchApiRequest(\n requestParameters: ISearchQuery,\n saveInRecents: boolean,\n ): Observable<T[]>;\n recentSearchApiRequest?(): Observable<ISearchQuery[]>;\n}\n\n// cant use T extends IReturnType here\nexport const SEARCH_SERVICE_TOKEN: InjectionToken<ISearchService<IReturnType>> =\n new InjectionToken<ISearchService<IReturnType>>('Search_Service_Token');\n\nexport type RecentSearchEvent = {\n event?: Event;\n keyword: string;\n category: string;\n};\n\nexport type ItemClickedEvent<T> = {\n event: MouseEvent;\n item: T;\n};\n\nexport type TypeEvent = {\n event?: Event;\n input: string;\n};\n// IRequestParameters default values\nexport const DEFAULT_LIMIT = 20;\nexport const DEFAULT_LIMIT_TYPE = false;\nexport const DEFAULT_ORDER = [];\nexport const DEBOUNCE_TIME = 1000;\nexport const DEFAULT_OFFSET = 0;\nexport const DEFAULT_SAVE_IN_RECENTS = true;\n","import {\n ChangeDetectorRef,\n Component,\n ElementRef,\n EventEmitter,\n Inject,\n Input,\n OnDestroy,\n OnInit,\n Output,\n PLATFORM_ID,\n TemplateRef,\n ViewChild,\n} from '@angular/core';\nimport {Configuration} from '../lib-configuration';\nimport {Subject} from 'rxjs';\nimport {debounceTime, tap} from 'rxjs/operators';\nimport {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';\nimport {\n ISearchService,\n ISearchQuery,\n SEARCH_SERVICE_TOKEN,\n DEBOUNCE_TIME,\n DEFAULT_LIMIT,\n DEFAULT_LIMIT_TYPE,\n DEFAULT_OFFSET,\n DEFAULT_SAVE_IN_RECENTS,\n DEFAULT_ORDER,\n IReturnType,\n RecentSearchEvent,\n TypeEvent,\n ItemClickedEvent,\n IModel,\n} from '../types';\nimport {isPlatformBrowser} from '@angular/common';\n\nconst ALL_LABEL = 'All';\n@Component({\n selector: 'sourceloop-search',\n templateUrl: './search.component.html',\n styleUrls: ['./search.component.scss'],\n providers: [\n {\n provide: NG_VALUE_ACCESSOR,\n useExisting: SearchComponent,\n multi: true,\n },\n ],\n})\nexport class SearchComponent<T extends IReturnType>\n implements OnInit, OnDestroy, ControlValueAccessor\n{\n searchBoxInput = '';\n suggestionsDisplay = false;\n categoryDisplay = false;\n searching = false;\n suggestions: T[] = [];\n recentSearches: ISearchQuery[] = [];\n category: string = ALL_LABEL;\n searchRequest$ = new Subject<{input: string; event: Event}>();\n\n private _config!: Configuration<T>;\n public get config(): Configuration<T> {\n return this._config;\n }\n @Input()\n public set config(value: Configuration<T>) {\n this._config = value;\n\n if (value && value.models) {\n value.models.unshift({\n name: ALL_LABEL,\n displayName: ALL_LABEL,\n });\n } else if (value && !value.models) {\n value.models = [\n {\n name: ALL_LABEL,\n displayName: ALL_LABEL,\n },\n ];\n } else {\n // do nothing\n }\n }\n\n @Input() titleTemplate?: TemplateRef<any>;\n @Input() subtitleTemplate?: TemplateRef<any>;\n // emitted when user clicks one of the suggested results (including recent search sugestions)\n @Output() clicked = new EventEmitter<ItemClickedEvent<T>>();\n @Output() searched = new EventEmitter<RecentSearchEvent>();\n /* emitted when user makes search request (including recent search requests & requests made on change in category from dropdown)\n In case of recent search Array of recent Search request result is emitted */\n\n onChange!: (value: string | undefined) => void;\n onTouched!: () => void;\n disabled = false;\n\n @ViewChild('searchInput') public searchInputElement!: ElementRef;\n\n constructor(\n @Inject(SEARCH_SERVICE_TOKEN)\n private readonly searchService: ISearchService<T>,\n // tslint:disable-next-line:ban-types\n @Inject(PLATFORM_ID) private readonly platformId: Object,\n private readonly cdr: ChangeDetectorRef,\n ) {}\n\n ngOnInit(): void {\n this.searchRequest$\n .pipe(\n tap(v => (this.suggestions = [])),\n debounceTime(DEBOUNCE_TIME),\n )\n .subscribe((value: TypeEvent) => {\n this.searched.emit({\n event: value.event,\n keyword: value.input,\n category: this.category,\n });\n this.getSuggestions(value);\n this.cdr.markForCheck();\n });\n }\n\n // ControlValueAccessor Implementation\n writeValue(value: string): void {\n this.searchBoxInput = value;\n }\n // When the value in the UI is changed, this method will invoke a callback function\n registerOnChange(fn: (value: string | undefined) => void): void {\n this.onChange = fn;\n }\n registerOnTouched(fn: () => void): void {\n this.onTouched = fn;\n }\n setDisabledState?(isDisabled: boolean): void {\n this.disabled = isDisabled;\n }\n\n getSuggestions(eventValue: TypeEvent) {\n eventValue.input = eventValue.input.trim();\n if (!eventValue.input.length) {\n return;\n }\n const order = this.config.order ?? DEFAULT_ORDER;\n let orderString = '';\n order.forEach(preference => (orderString = `${orderString}${preference} `));\n\n let saveInRecents = this.config.saveInRecents ?? DEFAULT_SAVE_IN_RECENTS;\n if (this.config.saveInRecents && this.config.saveInRecentsOnlyOnEnter) {\n if (\n !eventValue.event ||\n (eventValue.event instanceof KeyboardEvent &&\n eventValue.event.key === 'Enter')\n ) {\n saveInRecents = true; // save in recents only on enter or change in category\n } else {\n // do not save in recent search on typing\n saveInRecents = false;\n }\n }\n /* need to put default value here and not in contructor\n because sonar was giving code smell with definite assertion as all these parameters are optional */\n const requestParameters: ISearchQuery = {\n match: eventValue.input,\n sources: this._categoryToSourceName(this.category),\n limit: this.config.limit ?? DEFAULT_LIMIT,\n limitByType: this.config.limitByType ?? DEFAULT_LIMIT_TYPE,\n order: orderString,\n offset: this.config.offset ?? DEFAULT_OFFSET,\n };\n\n this.searching = true;\n this.cdr.markForCheck();\n this.searchService\n .searchApiRequest(requestParameters, saveInRecents)\n .subscribe(\n (value: T[]) => {\n this.suggestions = value;\n this.searching = false;\n this.cdr.markForCheck();\n },\n (_error: Error) => {\n this.suggestions = [];\n this.searching = false;\n this.cdr.markForCheck();\n },\n );\n }\n getRecentSearches() {\n if (\n !this.config.hideRecentSearch &&\n this.searchService.recentSearchApiRequest\n ) {\n this.searchService.recentSearchApiRequest().subscribe(\n (value: ISearchQuery[]) => {\n this.recentSearches = value;\n this.cdr.markForCheck();\n },\n (_error: Error) => {\n this.recentSearches = [];\n this.cdr.markForCheck();\n },\n );\n }\n }\n\n // event can be KeyBoardEvent or Event of type 'change' fired on change in value of drop down for category\n hitSearchApi(event?: Event) {\n // this will happen only in case user searches something and then erases it, we need to update recent search\n if (!this.searchBoxInput) {\n this.suggestions = [];\n this.getRecentSearches();\n return;\n }\n\n // no debounce time needed in case of searchOnlyOnEnter\n if (this.config.searchOnlyOnEnter) {\n if (!event || (event instanceof KeyboardEvent && event.key === 'Enter')) {\n this.getSuggestions({input: this.searchBoxInput, event});\n }\n return;\n }\n\n // no debounce time needed in case of change in category\n if (!event) {\n this.getSuggestions({input: this.searchBoxInput, event});\n return;\n }\n\n this.searchRequest$.next({\n input: this.searchBoxInput,\n event,\n });\n }\n\n populateValue(suggestion: T, event: MouseEvent) {\n const value = suggestion[\n this.config.displayPropertyName\n ] as unknown as string; // converted to string to assign value to searchBoxInput\n this.searchBoxInput = value;\n this.suggestionsDisplay = false;\n // ngModelChange doesn't detect change in value when populated from outside, hence calling manually\n this.onChange(this.searchBoxInput);\n // need to do this to show more search options for selected suggestion - just in case user reopens search input\n this.getSuggestions({input: this.searchBoxInput, event});\n this.clicked.emit({item: suggestion, event});\n }\n populateValueRecentSearch(recentSearch: ISearchQuery, event: MouseEvent) {\n event.stopPropagation();\n event.preventDefault();\n const value = recentSearch['match'];\n this.searchBoxInput = value;\n this.suggestionsDisplay = false;\n this.onChange(this.searchBoxInput);\n // need to do this to show more search options for selected suggestion - just in case user reopens search input\n this.getSuggestions({input: this.searchBoxInput, event});\n this.focusInput();\n this.showSuggestions();\n }\n\n fetchModelImageUrlFromSuggestion(suggestion: T) {\n const modelName = suggestion[\n 'source' as unknown as keyof T\n ] as unknown as string;\n let url: string | undefined;\n this.config.models.forEach(model => {\n if (model.name === modelName && model.imageUrl) {\n url = model.imageUrl;\n }\n });\n return url;\n }\n\n boldString(str: T[keyof T] | string, substr: string) {\n const strRegExp = new RegExp(`(${substr})`, 'gi');\n const stringToMakeBold: string = str as unknown as string;\n return stringToMakeBold.replace(strRegExp, `<b>$1</b>`);\n }\n\n hideSuggestions() {\n this.suggestionsDisplay = false;\n this.onTouched();\n }\n\n showSuggestions() {\n this.suggestionsDisplay = true;\n this.getRecentSearches();\n }\n\n focusInput() {\n if (isPlatformBrowser(this.platformId)) {\n this.searchInputElement.nativeElement.focus();\n }\n }\n\n setCategory(category: string) {\n this.category = category;\n this.categoryDisplay = false;\n if (this.searchBoxInput) {\n this.hitSearchApi();\n this.focusInput();\n this.showSuggestions();\n }\n }\n\n showCategory() {\n this.categoryDisplay = !this.categoryDisplay;\n }\n\n hideCategory() {\n this.categoryDisplay = false;\n }\n\n resetInput() {\n this.searchBoxInput = '';\n this.suggestions = [];\n this.suggestionsDisplay = true;\n this.focusInput();\n // ngModelChange doesn't detect change in value when populated from outside, hence calling manually\n this.onChange(this.searchBoxInput);\n this.getRecentSearches();\n }\n ngOnDestroy() {\n this.searchRequest$.unsubscribe();\n }\n\n _categoryToSourceName(category: string) {\n if (category === ALL_LABEL) {\n return [];\n } else {\n return [category];\n }\n }\n getModelFromModelName(name: string) {\n return this.config.models.find(item => item.name === name) as IModel;\n }\n getModelsWithSuggestions() {\n const modelsWithSuggestions: {model: IModel; items: T[]}[] = [];\n const sources: string[] = [];\n this.suggestions.forEach(suggestion => {\n if (sources.indexOf(suggestion['source']) >= 0) {\n modelsWithSuggestions.every(modelWithSuggestions => {\n if (modelWithSuggestions.model.name === suggestion['source']) {\n modelWithSuggestions.items.push(suggestion);\n return false;\n }\n return true;\n });\n } else {\n const model = this.getModelFromModelName(suggestion['source']);\n modelsWithSuggestions.push({model, items: [suggestion]});\n sources.push(suggestion['source']);\n }\n });\n return modelsWithSuggestions;\n }\n}\n","import {CommonModule} from '@angular/common';\nimport {HttpClientModule} from '@angular/common/http';\nimport {NgModule} from '@angular/core';\nimport {FlexLayoutModule} from '@angular/flex-layout';\nimport {FormsModule} from '@angular/forms';\nimport {MatFormFieldModule} from '@angular/material/form-field';\nimport {MatIconModule} from '@angular/material/icon';\nimport {MatInputModule} from '@angular/material/input';\nimport {MatSelectModule} from '@angular/material/select';\n\nimport {SearchComponent} from './search/search.component';\n\n@NgModule({\n declarations: [SearchComponent],\n imports: [\n CommonModule,\n FormsModule,\n HttpClientModule,\n MatSelectModule,\n MatFormFieldModule,\n MatIconModule,\n MatInputModule,\n FlexLayoutModule,\n ],\n exports: [SearchComponent],\n})\nexport class SearchLibModule {}\n","import {IDefaultReturnType, IModel} from './types';\nexport class Configuration<T = IDefaultReturnType> {\n /** property to be displayed in the results */\n displayPropertyName: keyof T;\n /** list of model configuration to be render and categorize search results */\n models: IModel[];\n /** max number of results (based on limitByType option) */\n limit?: number;\n /** apply limit on individual models, or on overall results */\n limitByType?: boolean;\n /** apply a particular ordering on results */\n order?: string[];\n /** offset for results in case limit is used */\n offset?: number;\n /** save the search query in recent history */\n saveInRecents?: boolean;\n /** a placeholder to display in the search box */\n placeholder?: string;\n /** a function to generate placeholder, overrides the placeholder property */\n placeholderFunction?: (input: string, category: string) => string;\n /** categorize results on the basis of models provided */\n categorizeResults?: boolean;\n /** hides the recent search list */\n hideRecentSearch?: boolean;\n /** hide the category selection button */\n hideCategorizeButton?: boolean;\n /** save value in recent search only on enter or change in category, if false, also saved on typing */\n saveInRecentsOnlyOnEnter?: boolean;\n /** search only on enter key or when category is changed */\n searchOnlyOnEnter?: boolean;\n noResultMessage?: string;\n searchIconClass?: string;\n crossIconClass?: string;\n dropDownButtonIconClass?: string;\n recentSearchIconClass?: string;\n\n constructor(d: Configuration<T>) {\n checkForError(d);\n this.displayPropertyName = d.displayPropertyName;\n this.models = d.models;\n\n /* IRequestParameters - will be given default values before call is made in case undefined/null,\n otherwise there ! is used on which sonar gives code smell */\n this.limit = d.limit;\n this.limitByType = d.limitByType;\n this.order = d.order;\n this.offset = d.offset;\n this.saveInRecents = d.saveInRecents;\n\n const displayTexts = setDisplayText(d);\n this.noResultMessage = displayTexts.noResultMessage;\n this.placeholder = displayTexts.placeholder;\n this.placeholderFunction = displayTexts.placeholderFunction;\n\n const searchConfig = setSearchConfig(d);\n this.categorizeResults = searchConfig.categorizeResults;\n this.hideRecentSearch = searchConfig.hideRecentSearch;\n this.hideCategorizeButton = searchConfig.hideCategorizeButton;\n this.saveInRecentsOnlyOnEnter = searchConfig.saveInRecentsOnlyOnEnter;\n this.searchOnlyOnEnter = searchConfig.searchOnlyOnEnter;\n\n const classes = setIconClasses(d);\n this.searchIconClass = classes.searchIconClass;\n this.crossIconClass = classes.crossIconClass;\n this.dropDownButtonIconClass = classes.dropDownButtonIconClass;\n this.recentSearchIconClass = classes.recentSearchIconClass;\n }\n}\nfunction checkForError<T>(d: Configuration<T>) {\n if (\n d.categorizeResults === false &&\n (d.hideCategorizeButton === false || d.hideCategorizeButton === undefined)\n ) {\n throw new Error(\n 'You must provide hideCategorizeButton:true as categorizeResults is false',\n );\n }\n if (d.saveInRecents === false && d.saveInRecentsOnlyOnEnter === true) {\n throw new Error(\n 'You must provide saveInRecents:true for saveInRecentsOnlyOnEnter:true',\n );\n }\n}\nfunction setDisplayText<T>(d: Configuration<T>) {\n return {\n placeholder: d.placeholder ?? 'Search',\n noResultMessage: d.noResultMessage ?? 'No result found',\n placeholderFunction: d.placeholderFunction,\n };\n}\nfunction setSearchConfig<T>(d: Configuration<T>) {\n return {\n categorizeResults: d.categorizeResults ?? true,\n hideRecentSearch: d.hideRecentSearch ?? false,\n hideCategorizeButton: d.hideCategorizeButton ?? false,\n saveInRecentsOnlyOnEnter: d.saveInRecentsOnlyOnEnter ?? false,\n searchOnlyOnEnter: d.searchOnlyOnEnter ?? false,\n };\n}\nfunction setIconClasses<T>(d: Configuration<T>) {\n return {\n searchIconClass: d.searchIconClass ?? 'icomoon Search',\n crossIconClass: d.crossIconClass ?? 'icomoon close',\n dropDownButtonIconClass: d.dropDownButtonIconClass ?? 'icomoon arrow_down',\n recentSearchIconClass: d.recentSearchIconClass ?? 'icomoon Search',\n };\n}\n","/*\n * Public API Surface of my-lib\n */\n\nexport * from './lib/search-lib.module';\nexport * from './lib/search/search.component';\nexport * from './lib/lib-configuration';\nexport * from './lib/types';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;;AAkCA;MACa,oBAAoB,GAC/B,IAAI,cAAc,CAA8B,sBAAsB,EAAE;AAiB1E;MACa,aAAa,GAAG,GAAG;MACnB,kBAAkB,GAAG,MAAM;MAC3B,aAAa,GAAG,GAAG;MACnB,aAAa,GAAG,KAAK;MACrB,cAAc,GAAG,EAAE;MACnB,uBA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;QAC7C,oBAAoB,EAAE,MAAA,CAAC,CAAC,oBAAoB,mCAAI,KAAK;QACrD,wBAAwB,EAAE,MAAA,CAAC,CAAC,wBAAwB,mCAAI,KAAK;QAC7D,iBAAiB,EAAE,MAAA,CAAC,CAAC,iBAAiB,mCAAI,KAAK;KAChD,CAAC;AACJ,CAAC;AACD,SAAS,cAAc,CAAI,CAAmB;;IAC5C,OAAO;QACL,eAAe,EAAE,MAAA,CAAC,CAAC,eAAe,mCAAI,gBAAgB;QACtD,cAAc,EAAE,MAAA,CAAC,CAAC,cAAc,mCAAI,eAAe;QACnD,uBAAuB,EAAE,MAAA,CAAC,CAAC,uBAAuB,mCAAI,oBAAoB;QAC1E,qBAAqB,EAAE,MAAA,CAAC,CAAC,qBAAqB,mCAAI,gBAAgB;KACnE,CAAC;AACJ;;AC1GA;;;;ACAA;;;;;;"}
@@ -16,6 +16,8 @@ export declare class Configuration<T = IDefaultReturnType> {
16
16
  saveInRecents?: boolean;
17
17
  /** a placeholder to display in the search box */
18
18
  placeholder?: string;
19
+ /** a function to generate placeholder, overrides the placeholder property */
20
+ placeholderFunction?: (input: string, category: string) => string;
19
21
  /** categorize results on the basis of models provided */
20
22
  categorizeResults?: boolean;
21
23
  /** hides the recent search list */
@@ -27,5 +29,9 @@ export declare class Configuration<T = IDefaultReturnType> {
27
29
  /** search only on enter key or when category is changed */
28
30
  searchOnlyOnEnter?: boolean;
29
31
  noResultMessage?: string;
32
+ searchIconClass?: string;
33
+ crossIconClass?: string;
34
+ dropDownButtonIconClass?: string;
35
+ recentSearchIconClass?: string;
30
36
  constructor(d: Configuration<T>);
31
37
  }
@@ -1,17 +1,17 @@
1
- import { ElementRef, EventEmitter, OnDestroy, OnInit, TemplateRef } from '@angular/core';
1
+ import { ChangeDetectorRef, ElementRef, EventEmitter, OnDestroy, OnInit, TemplateRef } from '@angular/core';
2
2
  import { Configuration } from '../lib-configuration';
3
3
  import { Subject } from 'rxjs';
4
4
  import { ControlValueAccessor } from '@angular/forms';
5
- import { ISearchService, ISearchQuery, IReturnType, RecentSearchEvent, TypeEvent, ItemClickedEvent } from '../types';
5
+ import { ISearchService, ISearchQuery, IReturnType, RecentSearchEvent, TypeEvent, ItemClickedEvent, IModel } from '../types';
6
6
  export declare class SearchComponent<T extends IReturnType> implements OnInit, OnDestroy, ControlValueAccessor {
7
7
  private readonly searchService;
8
8
  private readonly platformId;
9
+ private readonly cdr;
9
10
  searchBoxInput: string;
10
11
  suggestionsDisplay: boolean;
11
12
  categoryDisplay: boolean;
12
13
  searching: boolean;
13
14
  suggestions: T[];
14
- relevantSuggestions: T[];
15
15
  recentSearches: ISearchQuery[];
16
16
  category: string;
17
17
  searchRequest$: Subject<{
@@ -29,7 +29,7 @@ export declare class SearchComponent<T extends IReturnType> implements OnInit, O
29
29
  onTouched: () => void;
30
30
  disabled: boolean;
31
31
  searchInputElement: ElementRef;
32
- constructor(searchService: ISearchService<T>, platformId: Object);
32
+ constructor(searchService: ISearchService<T>, platformId: Object, cdr: ChangeDetectorRef);
33
33
  ngOnInit(): void;
34
34
  writeValue(value: string): void;
35
35
  registerOnChange(fn: (value: string | undefined) => void): void;
@@ -40,8 +40,7 @@ export declare class SearchComponent<T extends IReturnType> implements OnInit, O
40
40
  hitSearchApi(event?: Event): void;
41
41
  populateValue(suggestion: T, event: MouseEvent): void;
42
42
  populateValueRecentSearch(recentSearch: ISearchQuery, event: MouseEvent): void;
43
- fetchModelImageUrlFromSuggestion(suggestion: T): string;
44
- getSuggestionsFromModelName(modelName: string): boolean;
43
+ fetchModelImageUrlFromSuggestion(suggestion: T): string | undefined;
45
44
  boldString(str: T[keyof T] | string, substr: string): string;
46
45
  hideSuggestions(): void;
47
46
  showSuggestions(): void;
@@ -52,4 +51,9 @@ export declare class SearchComponent<T extends IReturnType> implements OnInit, O
52
51
  resetInput(): void;
53
52
  ngOnDestroy(): void;
54
53
  _categoryToSourceName(category: string): string[];
54
+ getModelFromModelName(name: string): IModel;
55
+ getModelsWithSuggestions(): {
56
+ model: IModel;
57
+ items: T[];
58
+ }[];
55
59
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import * as i0 from '@angular/core';
2
+ import * as i1 from './search-lib.module';
3
+ export declare const SearchLibModuleNgFactory: i0.NgModuleFactory<i1.SearchLibModule>;
package/lib/types.d.ts CHANGED
@@ -42,7 +42,7 @@ export declare type TypeEvent = {
42
42
  };
43
43
  export declare const DEFAULT_LIMIT = 20;
44
44
  export declare const DEFAULT_LIMIT_TYPE = false;
45
- export declare const DEFAULT_ORDER: any[];
45
+ export declare const DEFAULT_ORDER: never[];
46
46
  export declare const DEBOUNCE_TIME = 1000;
47
47
  export declare const DEFAULT_OFFSET = 0;
48
48
  export declare const DEFAULT_SAVE_IN_RECENTS = true;
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@sourceloop/search-client",
3
- "version": "1.2.1",
3
+ "version": "4.3.0",
4
4
  "description": "A global search component for search microservice",
5
5
  "peerDependencies": {
6
6
  "@angular/animations": "~12.1.5",
7
- "@angular/common": "^12.1.5",
7
+ "@angular/cdk": ">=10.2.0 <13.0.0",
8
+ "@angular/common": "~12.1.5",
8
9
  "@angular/compiler": "~12.1.5",
9
- "@angular/core": "^12.1.5",
10
- "@angular/cdk": "^10.2.0",
11
- "@angular/flex-layout": "^10.0.0-beta.32",
12
- "@angular/material": "^10.2.0",
10
+ "@angular/core": "~12.1.5",
11
+ "@angular/flex-layout": "10.0.0-beta.32 - 12.0.0-beta.35",
13
12
  "@angular/forms": "~12.1.5",
13
+ "@angular/material": ">=10.2.0 <13.0.0",
14
14
  "@angular/platform-browser": "~12.1.5",
15
15
  "@angular/platform-browser-dynamic": "~12.1.5",
16
16
  "@angular/router": "~12.1.5",
@@ -28,6 +28,12 @@
28
28
  "author": "Sourcefuse",
29
29
  "license": "MIT",
30
30
  "private": false,
31
+ "publishConfig": {
32
+ "registry": "https://registry.npmjs.org/",
33
+ "access": "public",
34
+ "directory": "dist"
35
+ },
36
+ "gitHead": "b527ac2f790fe074cc7020daabf8e73486e32ac9",
31
37
  "main": "bundles/sourceloop-search-client.umd.js",
32
38
  "module": "fesm2015/sourceloop-search-client.js",
33
39
  "es2015": "fesm2015/sourceloop-search-client.js",