@huntsman-cancer-institute/input 15.0.2 → 16.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.
Files changed (45) hide show
  1. package/date/date-date-range.component.d.ts +1 -1
  2. package/date/date-date.component.d.ts +1 -1
  3. package/dropdown/dropdown-select-result.component.d.ts +1 -1
  4. package/dropdown/dropdown-select.component.d.ts +1 -1
  5. package/dropdown/dropdown.component.d.ts +1 -1
  6. package/{esm2020 → esm2022}/date/date-base.mjs +4 -4
  7. package/{esm2020 → esm2022}/date/date-date-range.component.mjs +6 -6
  8. package/{esm2020 → esm2022}/date/date-date.component.mjs +6 -6
  9. package/esm2022/date/date-validator.mjs +40 -0
  10. package/{esm2020 → esm2022}/date/date.module.mjs +23 -23
  11. package/{esm2020 → esm2022}/dropdown/dropdown-select-result.component.mjs +6 -6
  12. package/{esm2020 → esm2022}/dropdown/dropdown-select.component.mjs +6 -6
  13. package/{esm2020 → esm2022}/dropdown/dropdown.component.mjs +6 -6
  14. package/{esm2020 → esm2022}/dropdown/dropdown.module.mjs +17 -17
  15. package/{esm2020 → esm2022}/dropdown/dropdown.service.mjs +4 -4
  16. package/esm2022/dropdown/messages.mjs +10 -0
  17. package/{esm2020 → esm2022}/dropdown/template-dropdown.directive.mjs +4 -4
  18. package/{esm2020 → esm2022}/inline/inline.component.mjs +12 -12
  19. package/{esm2020 → esm2022}/inline/inline.module.mjs +7 -7
  20. package/{esm2020 → esm2022}/search/search.component.mjs +6 -6
  21. package/{esm2020 → esm2022}/search/search.module.mjs +9 -9
  22. package/{esm2020 → esm2022}/select/custom-combobox.component.mjs +10 -10
  23. package/{esm2020 → esm2022}/select/custom-multi-combobox.component.mjs +10 -10
  24. package/{esm2020 → esm2022}/select/md-multi-select.component.mjs +12 -12
  25. package/{esm2020 → esm2022}/select/md-select.component.mjs +12 -12
  26. package/{esm2020 → esm2022}/select/native-select.component.mjs +12 -12
  27. package/{esm2020 → esm2022}/select/select.module.mjs +33 -33
  28. package/{fesm2020 → fesm2022}/huntsman-cancer-institute-input.mjs +191 -191
  29. package/{fesm2020 → fesm2022}/huntsman-cancer-institute-input.mjs.map +1 -1
  30. package/inline/inline.component.d.ts +1 -1
  31. package/package.json +13 -17
  32. package/search/search.component.d.ts +1 -1
  33. package/select/custom-combobox.component.d.ts +1 -1
  34. package/select/custom-multi-combobox.component.d.ts +1 -1
  35. package/select/md-multi-select.component.d.ts +1 -1
  36. package/select/md-select.component.d.ts +1 -1
  37. package/select/native-select.component.d.ts +1 -1
  38. package/esm2020/date/date-validator.mjs +0 -40
  39. package/esm2020/dropdown/messages.mjs +0 -10
  40. package/fesm2015/huntsman-cancer-institute-input.mjs +0 -3697
  41. package/fesm2015/huntsman-cancer-institute-input.mjs.map +0 -1
  42. /package/{esm2020 → esm2022}/dropdown/dropdown-index.mjs +0 -0
  43. /package/{esm2020 → esm2022}/dropdown/select-item.mjs +0 -0
  44. /package/{esm2020 → esm2022}/huntsman-cancer-institute-input.mjs +0 -0
  45. /package/{esm2020 → esm2022}/index.mjs +0 -0
@@ -1,3697 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { EventEmitter, Component, Input, Output, forwardRef, ViewChild, Directive, Host, isDevMode, Injectable, Inject, NgModule, SimpleChange, TemplateRef, ContentChild, HostListener, HostBinding, ViewEncapsulation } from '@angular/core';
3
- import * as i2 from '@angular/forms';
4
- import { NG_VALUE_ACCESSOR, UntypedFormControl, FormsModule, ReactiveFormsModule, NgModel, NgControl } from '@angular/forms';
5
- import { of, timer, Subscription, combineLatest } from 'rxjs';
6
- import { debounceTime, distinctUntilChanged, tap, filter, switchMap, map, mergeMap } from 'rxjs/operators';
7
- import * as i1 from '@angular/common';
8
- import { CommonModule, DatePipe } from '@angular/common';
9
- import * as i3 from '@ng-bootstrap/ng-bootstrap';
10
- import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
11
- import * as i2$1 from '@angular/common/http';
12
- import { HttpHeaders } from '@angular/common/http';
13
- import * as i1$1 from '@huntsman-cancer-institute/dictionary-service';
14
- import { DICTIONARY_ENDPOINT, DictionaryServiceModule } from '@huntsman-cancer-institute/dictionary-service';
15
- import * as moment from 'moment';
16
- import { MatLegacyTabsModule } from '@angular/material/legacy-tabs';
17
- import { MatDatepickerModule } from '@angular/material/datepicker';
18
- import * as i3$1 from '@angular/material/legacy-form-field';
19
- import { MatLegacyFormFieldModule } from '@angular/material/legacy-form-field';
20
- import { MatNativeDateModule } from '@angular/material/core';
21
- import * as i7 from '@angular/material/legacy-input';
22
- import { MatLegacyInputModule } from '@angular/material/legacy-input';
23
- import * as i6 from '@angular/material/legacy-select';
24
- import { MatLegacySelectModule } from '@angular/material/legacy-select';
25
- import * as i6$2 from '@angular/material/legacy-autocomplete';
26
- import { MatLegacyAutocompleteTrigger, MatLegacyAutocompleteModule } from '@angular/material/legacy-autocomplete';
27
- import * as i8 from '@angular/material/legacy-tooltip';
28
- import { MatLegacyTooltipModule } from '@angular/material/legacy-tooltip';
29
- import { MatIconModule } from '@angular/material/icon';
30
- import * as i5 from '@angular/cdk/scrolling';
31
- import { ScrollingModule } from '@angular/cdk/scrolling';
32
- import * as i6$1 from '@angular/material/legacy-core';
33
- import * as i9 from '@angular/material/legacy-progress-spinner';
34
- import { MatLegacyProgressSpinnerModule } from '@angular/material/legacy-progress-spinner';
35
-
36
- /**
37
- * @description: A model of common data for dropdown components.
38
- * @since 5.0.0
39
- */
40
- const KEY_CODE = Object.freeze({
41
- DOWN_ARROW: 40,
42
- UP_ARROW: 38,
43
- ENTER: 13,
44
- TAB: 9,
45
- DELETE: 8
46
- });
47
-
48
- /**
49
- * A model of common messages for dropdown components.
50
- *
51
- * @since 5.0.0
52
- */
53
- class Messages {
54
- }
55
- Messages.PARTIAL_COUNT_VAR = "%PARTIAL_COUNT%";
56
- Messages.TOTAL_COUNT_VAR = "%TOTAL_COUNT%";
57
-
58
- class DropdownSelectResultComponent {
59
- constructor() {
60
- this.itemSelectedEvent = new EventEmitter();
61
- this.activeIndex = 0;
62
- this.usingKeys = false;
63
- }
64
- ngOnInit() { }
65
- onSelected(item) {
66
- this.itemSelectedEvent.emit(item);
67
- }
68
- onMouseOver(index) {
69
- if (!this.usingKeys) {
70
- this.activeIndex = index;
71
- }
72
- }
73
- onHovering(event) {
74
- this.usingKeys = false;
75
- }
76
- isSelected(currentItem) {
77
- let result = false;
78
- this.selectedItems.forEach(item => {
79
- if (item.id === currentItem.id) {
80
- result = true;
81
- }
82
- });
83
- return result;
84
- }
85
- activeNext() {
86
- if (this.activeIndex >= this.items.length - 1) {
87
- this.activeIndex = this.items.length - 1;
88
- }
89
- else {
90
- this.activeIndex++;
91
- }
92
- this.scrollToElement();
93
- this.usingKeys = true;
94
- }
95
- activePrevious() {
96
- if (this.activeIndex - 1 < 0) {
97
- this.activeIndex = 0;
98
- }
99
- else {
100
- this.activeIndex--;
101
- }
102
- this.scrollToElement();
103
- this.usingKeys = true;
104
- }
105
- scrollToElement() {
106
- const element = document.getElementById("item-" + this.activeIndex);
107
- const container = document.getElementById("resultsContainer");
108
- if (element) {
109
- container.scrollTop = element.offsetTop;
110
- }
111
- }
112
- selectCurrentItem() {
113
- if (this.items[this.activeIndex]) {
114
- this.onSelected(this.items[this.activeIndex]);
115
- this.activeIndex = 0;
116
- }
117
- }
118
- }
119
- DropdownSelectResultComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DropdownSelectResultComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
120
- DropdownSelectResultComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: DropdownSelectResultComponent, selector: "hci-dropdown-select-result", inputs: { items: "items", searchFocused: "searchFocused", selectedItems: "selectedItems", templateRef: "templateRef" }, outputs: { itemSelectedEvent: "itemSelectedEvent" }, ngImport: i0, template: `
121
- <div class="select-results-container" *ngIf="items !== undefined && items.length > 0" id="resultsContainer">
122
- <div *ngFor="let item of items; let i = index;"
123
- class="select-result" id="item-{{i}}"
124
- (mousedown)="onSelected(item)" [class.selected]="isSelected(item)"
125
- [class.active]="i === activeIndex"
126
- (mouseover)="onMouseOver(i)"
127
- (mouseenter)="onHovering($event)">
128
- <ng-container [ngTemplateOutlet]="templateRef"
129
- [ngTemplateOutletContext]="{$item: item, $entity: item.entity, $id: item.id, $index: i}"></ng-container>
130
- <ng-container *ngIf="!templateRef">{{item.text}}</ng-container>
131
- </div>
132
- </div>
133
- `, isInline: true, dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
134
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DropdownSelectResultComponent, decorators: [{
135
- type: Component,
136
- args: [{
137
- selector: "hci-dropdown-select-result",
138
- template: `
139
- <div class="select-results-container" *ngIf="items !== undefined && items.length > 0" id="resultsContainer">
140
- <div *ngFor="let item of items; let i = index;"
141
- class="select-result" id="item-{{i}}"
142
- (mousedown)="onSelected(item)" [class.selected]="isSelected(item)"
143
- [class.active]="i === activeIndex"
144
- (mouseover)="onMouseOver(i)"
145
- (mouseenter)="onHovering($event)">
146
- <ng-container [ngTemplateOutlet]="templateRef"
147
- [ngTemplateOutletContext]="{$item: item, $entity: item.entity, $id: item.id, $index: i}"></ng-container>
148
- <ng-container *ngIf="!templateRef">{{item.text}}</ng-container>
149
- </div>
150
- </div>
151
- `
152
- }]
153
- }], propDecorators: { items: [{
154
- type: Input
155
- }], searchFocused: [{
156
- type: Input
157
- }], selectedItems: [{
158
- type: Input
159
- }], templateRef: [{
160
- type: Input
161
- }], itemSelectedEvent: [{
162
- type: Output
163
- }] } });
164
-
165
- const VALUE_ACCESSOR = {
166
- provide: NG_VALUE_ACCESSOR,
167
- useExisting: forwardRef(() => DropdownSelectComponent),
168
- multi: true
169
- };
170
- const noop = () => { };
171
- class DropdownSelectComponent {
172
- constructor() {
173
- this.MORE_RESULTS_MSG = "Showing " + Messages.PARTIAL_COUNT_VAR + " of " + Messages.TOTAL_COUNT_VAR + " results.";
174
- this.NO_RESULTS_MSG = "No results found";
175
- this.messages = {
176
- moreResultsMsg: this.MORE_RESULTS_MSG,
177
- noResultsMsg: this.NO_RESULTS_MSG
178
- };
179
- this.referenceMode = "id";
180
- this.placeholder = "";
181
- this.disabled = false;
182
- this.multiple = false;
183
- this.clientMode = false;
184
- this.deleteIcon = "fas fa-times-circle";
185
- this.inputState = 2; // selectIcon controller: 0->with selectIcon 2->without selectIcon
186
- this.searchDelay = 100;
187
- this.select = new EventEmitter();
188
- this.remove = new EventEmitter();
189
- this.onTouchedCallback = noop;
190
- this.onChangeCallback = noop;
191
- this.term = new UntypedFormControl();
192
- this.searchFocused = false;
193
- this.resultsVisible = false;
194
- this.selectedItems = [];
195
- this.placeholderSelected = "";
196
- }
197
- ngAfterViewInit() {
198
- this.subscribeToChangesAndLoadDataFromObservable();
199
- }
200
- onItemSelected(item) {
201
- if (this.multiple) {
202
- this.selectedItems.push(item);
203
- const index = this.listedData.indexOf(item, 0);
204
- if (index > -1) {
205
- this.listedData.splice(index, 1);
206
- }
207
- }
208
- else {
209
- this.selectedItems.length = 0;
210
- this.selectedItems.push(item);
211
- }
212
- this.onChangeCallback(this.buildValue());
213
- this.term.patchValue("", { emitEvent: false });
214
- setTimeout(() => this.focusInput(), 1);
215
- this.resultsVisible = false;
216
- this.select.emit(item);
217
- if (!this.multiple) {
218
- this.placeholderSelected = item.text;
219
- }
220
- }
221
- focusInput() {
222
- if (!this.disabled) {
223
- this.termInput.nativeElement.focus();
224
- this.resultsVisible = false;
225
- }
226
- this.searchFocused = !this.disabled;
227
- }
228
- writeValue(selectedValues) {
229
- if (selectedValues) {
230
- if (this.referenceMode === "id") {
231
- this.populateItemsFromIds(selectedValues);
232
- }
233
- else {
234
- this.populateItemsFromEntities(selectedValues);
235
- }
236
- }
237
- else {
238
- this.placeholderSelected = "";
239
- this.selectedItems = [];
240
- }
241
- }
242
- getCountMessage() {
243
- let msg = this.messages && this.messages.moreResultsMsg ? this.messages.moreResultsMsg : this.MORE_RESULTS_MSG;
244
- msg = msg.replace(Messages.PARTIAL_COUNT_VAR, String(this.listedData.length));
245
- msg = msg.replace(Messages.TOTAL_COUNT_VAR, String(this.resultsCount - this.selectedItems.length));
246
- return msg;
247
- }
248
- setDisabledState(isDisabled) {
249
- this.disabled = isDisabled;
250
- }
251
- registerOnChange(fn) {
252
- this.onChangeCallback = fn;
253
- }
254
- registerOnTouched(fn) {
255
- this.onTouchedCallback = fn;
256
- }
257
- removeItem(item) {
258
- const index = this.selectedItems.indexOf(item, 0);
259
- if (index > -1) {
260
- this.selectedItems.splice(index, 1);
261
- }
262
- this.onChangeCallback(this.buildValue());
263
- this.remove.emit(item);
264
- if (!this.multiple) {
265
- this.placeholderSelected = "";
266
- }
267
- }
268
- getPlaceholder() {
269
- return this.selectedItems.length > 0 ? this.placeholderSelected : this.placeholder;
270
- }
271
- getInputWidth() {
272
- const searchEmpty = this.selectedItems.length === 0 && (this.term.value === null || this.term.value.length === 0);
273
- const length = this.term.value === null ? 0 : this.term.value.length;
274
- if (!this.multiple) {
275
- return "100%";
276
- }
277
- else {
278
- return searchEmpty ? "100%" : (1 + length * .6) + "em";
279
- }
280
- }
281
- isHideable() {
282
- return !this.multiple && this.placeholderSelected !== "";
283
- }
284
- onFocus() {
285
- this.searchFocused = true;
286
- }
287
- onBlur() {
288
- this.term.patchValue("", { emitEvent: false });
289
- this.searchFocused = false;
290
- this.resultsVisible = false;
291
- this.onTouchedCallback();
292
- }
293
- onKeyUp(ev) {
294
- if (this.results) {
295
- if (ev.keyCode === KEY_CODE.DOWN_ARROW) {
296
- this.results.activeNext();
297
- }
298
- else if (ev.keyCode === KEY_CODE.UP_ARROW) {
299
- this.results.activePrevious();
300
- }
301
- else if (ev.keyCode === KEY_CODE.ENTER) {
302
- this.results.selectCurrentItem();
303
- }
304
- }
305
- else {
306
- if (this.inputState === 0) {
307
- if (ev.keyCode === KEY_CODE.ENTER || ev.keyCode === KEY_CODE.DOWN_ARROW) {
308
- this.showResults();
309
- }
310
- }
311
- }
312
- }
313
- onKeyDown(ev) {
314
- if (this.results) {
315
- if (ev.keyCode === KEY_CODE.TAB) {
316
- this.results.selectCurrentItem();
317
- }
318
- }
319
- if (ev.keyCode === KEY_CODE.DELETE) {
320
- if ((!this.term.value || this.term.value.length === 0) && this.selectedItems.length > 0) {
321
- this.removeItem(this.selectedItems[this.selectedItems.length - 1]);
322
- }
323
- }
324
- }
325
- onKeyPress(ev) {
326
- if (ev.keyCode === KEY_CODE.ENTER) {
327
- ev.preventDefault();
328
- }
329
- }
330
- showResults() {
331
- if (!this.disabled) {
332
- this.termInput.nativeElement.focus();
333
- this.subscribeToResults(of(""));
334
- }
335
- this.searchFocused = !this.disabled;
336
- }
337
- focus() {
338
- this.termInput.nativeElement.focus();
339
- }
340
- subscribeToChangesAndLoadDataFromObservable() {
341
- const observable = this.term.valueChanges.pipe(debounceTime(this.searchDelay), distinctUntilChanged());
342
- this.subscribeToResults(observable);
343
- }
344
- subscribeToResults(observable) {
345
- observable.pipe(tap(() => this.resultsVisible = false), filter((term) => term.length >= this.inputState), switchMap(term => this.loadDataFromObservable(term)), map(items => items.filter(item => !(this.multiple && this.alreadySelected(item)))), tap(() => this.resultsVisible = this.searchFocused)).subscribe((items) => this.listedData = items);
346
- }
347
- loadDataFromObservable(term) {
348
- return this.clientMode ? this.fetchAndfilterLocalData(term) : this.fetchData(term);
349
- }
350
- alreadySelected(item) {
351
- let result = false;
352
- this.selectedItems.forEach(selectedItem => {
353
- if (selectedItem.id === item.id) {
354
- result = true;
355
- }
356
- });
357
- return result;
358
- }
359
- fetchAndfilterLocalData(term) {
360
- if (!this.modifiedData) {
361
- return this.fetchData("").pipe(mergeMap((items) => {
362
- this.modifiedData = items;
363
- return this.filterLocalData(term);
364
- }));
365
- }
366
- else {
367
- return this.filterLocalData(term);
368
- }
369
- }
370
- fetchData(term) {
371
- return this
372
- .dataProvider(term, this.buildValue())
373
- .pipe(map((items) => this.adaptItems(items)));
374
- }
375
- filterLocalData(term) {
376
- return of(this.modifiedData.filter((item) => this.containsText(item, term)));
377
- }
378
- containsText(item, term) {
379
- return item.text.toUpperCase().indexOf(term.toUpperCase()) !== -1;
380
- }
381
- adaptItems(items) {
382
- const convertedItems = [];
383
- items.map((item) => this.selectItemAdapter(item))
384
- .forEach((selectItem) => convertedItems.push(selectItem));
385
- return convertedItems;
386
- }
387
- buildValue() {
388
- return "id" === this.referenceMode ? this.getSelectedIds() : this.getEntities();
389
- }
390
- getSelectedIds() {
391
- if (this.multiple) {
392
- const ids = [];
393
- this.selectedItems.forEach(item => ids.push(item.id));
394
- return ids;
395
- }
396
- else {
397
- return this.selectedItems.length === 0 ? null : this.selectedItems[0].id;
398
- }
399
- }
400
- getEntities() {
401
- if (this.multiple) {
402
- const entities = [];
403
- this.selectedItems.forEach(item => {
404
- entities.push(item.entity);
405
- });
406
- return entities;
407
- }
408
- else {
409
- return this.selectedItems.length === 0 ? null : this.selectedItems[0].entity;
410
- }
411
- }
412
- populateItemsFromEntities(selectedValues) {
413
- if (this.multiple) {
414
- this.handleMultipleWithEntities(selectedValues);
415
- }
416
- else {
417
- const selectItem = this.selectItemAdapter(selectedValues);
418
- this.selectedItems = [selectItem];
419
- this.placeholderSelected = selectItem.text;
420
- }
421
- }
422
- handleMultipleWithEntities(selectedValues) {
423
- this.selectedItems = [];
424
- selectedValues.forEach((entity) => {
425
- const item = this.selectItemAdapter(entity);
426
- const ids = this.getSelectedIds();
427
- if (ids.indexOf(item.id) === -1) {
428
- this.selectedItems.push(item);
429
- }
430
- });
431
- }
432
- populateItemsFromIds(selectedValues) {
433
- if (this.multiple) {
434
- this.handleMultipleWithIds(selectedValues);
435
- }
436
- else {
437
- this.handleSingleWithId(selectedValues);
438
- }
439
- }
440
- handleMultipleWithIds(selectedValues) {
441
- if (selectedValues !== undefined && this.selectedProvider !== undefined) {
442
- const uniqueIds = [];
443
- selectedValues.forEach((id) => {
444
- if (uniqueIds.indexOf(id) === -1) {
445
- uniqueIds.push(id);
446
- }
447
- });
448
- this.selectedProvider(uniqueIds).subscribe((items) => {
449
- this.selectedItems = items.map(this.selectItemAdapter);
450
- });
451
- }
452
- }
453
- handleSingleWithId(id) {
454
- if (id !== undefined && this.selectedProvider !== undefined) {
455
- this.selectedProvider([id]).subscribe((items) => {
456
- items.forEach((item) => {
457
- const selectItem = this.selectItemAdapter(item);
458
- this.selectedItems = [selectItem];
459
- this.placeholderSelected = selectItem.text;
460
- });
461
- });
462
- }
463
- }
464
- }
465
- DropdownSelectComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DropdownSelectComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
466
- DropdownSelectComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: DropdownSelectComponent, selector: "hci-dropdown-select", inputs: { messages: "messages", dataProvider: "dataProvider", selectedProvider: "selectedProvider", selectItemAdapter: "selectItemAdapter", referenceMode: "referenceMode", placeholder: "placeholder", disabled: "disabled", multiple: "multiple", clientMode: "clientMode", deleteIcon: "deleteIcon", inputState: "inputState", resultsCount: "resultsCount", searchDelay: "searchDelay" }, outputs: { select: "select", remove: "remove" }, host: { classAttribute: "flex-grow-1" }, providers: [VALUE_ACCESSOR], viewQueries: [{ propertyName: "results", first: true, predicate: ["results"], descendants: true }, { propertyName: "termInput", first: true, predicate: ["termInput"], descendants: true }], ngImport: i0, template: `
467
- <div class="select-container">
468
- <ul class="form-control"
469
- [class.simple-selection]="!multiple"
470
- [class.multiple-selection]="multiple"
471
- [class.search-focused]="searchFocused"
472
- [class.readonly]="disabled">
473
-
474
- <ng-container *ngIf="!searchFocused || multiple">
475
- <li *ngFor="let item of selectedItems" class="select-selected label label-info" [class.label]="multiple"
476
- [class.label-info]="multiple">
477
- <span class="selected-item-text">{{item.text}}</span>
478
- <a class="select-selection-remove" (click)="removeItem(item)" *ngIf="!disabled">
479
- <i [class]="deleteIcon" [class.text-info]="!multiple"></i>
480
- </a>
481
- </li>
482
- </ng-container>
483
-
484
- <li class="select-input">
485
- <input #termInput type="text"
486
- [placeholder]="getPlaceholder()"
487
- [formControl]="term"
488
- [class.hideable]="isHideable()"
489
- [style.width]="getInputWidth()"
490
- (focus)="onFocus()"
491
- (blur)="onBlur()"
492
- (keyup)="onKeyUp($event)"
493
- (keydown)="onKeyDown($event)"
494
- (keypress)="onKeyPress($event)"
495
- (click)="showResults()" *ngIf="!disabled" />
496
- </li>
497
- </ul>
498
- <span class="icon-drop-menu" *ngIf="inputState===0" (click)="showResults()">
499
- <span class="after"></span>
500
- </span>
501
- <div class="results-container" *ngIf="resultsVisible">
502
- <span class="results-msg" *ngIf="listedData && (listedData.length + selectedItems.length) < resultsCount">
503
- {{getCountMessage()}}
504
- </span>
505
- <span class="results-msg no-results-msg" *ngIf="searchFocused && listedData && listedData.length === 0">
506
- {{messages && messages.noResultsMsg ? messages.noResultsMsg : NO_RESULTS_MSG}}
507
- </span>
508
- <hci-dropdown-select-result #results
509
- [selectedItems]="selectedItems"
510
- [items]="listedData"
511
- (itemSelectedEvent)="onItemSelected($event)"
512
- [templateRef]="templateRef"
513
- [searchFocused]="searchFocused"></hci-dropdown-select-result>
514
- </div>
515
- </div>
516
- `, isInline: true, dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: DropdownSelectResultComponent, selector: "hci-dropdown-select-result", inputs: ["items", "searchFocused", "selectedItems", "templateRef"], outputs: ["itemSelectedEvent"] }] });
517
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DropdownSelectComponent, decorators: [{
518
- type: Component,
519
- args: [{
520
- selector: "hci-dropdown-select",
521
- template: `
522
- <div class="select-container">
523
- <ul class="form-control"
524
- [class.simple-selection]="!multiple"
525
- [class.multiple-selection]="multiple"
526
- [class.search-focused]="searchFocused"
527
- [class.readonly]="disabled">
528
-
529
- <ng-container *ngIf="!searchFocused || multiple">
530
- <li *ngFor="let item of selectedItems" class="select-selected label label-info" [class.label]="multiple"
531
- [class.label-info]="multiple">
532
- <span class="selected-item-text">{{item.text}}</span>
533
- <a class="select-selection-remove" (click)="removeItem(item)" *ngIf="!disabled">
534
- <i [class]="deleteIcon" [class.text-info]="!multiple"></i>
535
- </a>
536
- </li>
537
- </ng-container>
538
-
539
- <li class="select-input">
540
- <input #termInput type="text"
541
- [placeholder]="getPlaceholder()"
542
- [formControl]="term"
543
- [class.hideable]="isHideable()"
544
- [style.width]="getInputWidth()"
545
- (focus)="onFocus()"
546
- (blur)="onBlur()"
547
- (keyup)="onKeyUp($event)"
548
- (keydown)="onKeyDown($event)"
549
- (keypress)="onKeyPress($event)"
550
- (click)="showResults()" *ngIf="!disabled" />
551
- </li>
552
- </ul>
553
- <span class="icon-drop-menu" *ngIf="inputState===0" (click)="showResults()">
554
- <span class="after"></span>
555
- </span>
556
- <div class="results-container" *ngIf="resultsVisible">
557
- <span class="results-msg" *ngIf="listedData && (listedData.length + selectedItems.length) < resultsCount">
558
- {{getCountMessage()}}
559
- </span>
560
- <span class="results-msg no-results-msg" *ngIf="searchFocused && listedData && listedData.length === 0">
561
- {{messages && messages.noResultsMsg ? messages.noResultsMsg : NO_RESULTS_MSG}}
562
- </span>
563
- <hci-dropdown-select-result #results
564
- [selectedItems]="selectedItems"
565
- [items]="listedData"
566
- (itemSelectedEvent)="onItemSelected($event)"
567
- [templateRef]="templateRef"
568
- [searchFocused]="searchFocused"></hci-dropdown-select-result>
569
- </div>
570
- </div>
571
- `,
572
- providers: [VALUE_ACCESSOR],
573
- host: { class: "flex-grow-1" }
574
- }]
575
- }], propDecorators: { messages: [{
576
- type: Input
577
- }], dataProvider: [{
578
- type: Input
579
- }], selectedProvider: [{
580
- type: Input
581
- }], selectItemAdapter: [{
582
- type: Input
583
- }], referenceMode: [{
584
- type: Input
585
- }], placeholder: [{
586
- type: Input
587
- }], disabled: [{
588
- type: Input
589
- }], multiple: [{
590
- type: Input
591
- }], clientMode: [{
592
- type: Input
593
- }], deleteIcon: [{
594
- type: Input
595
- }], inputState: [{
596
- type: Input
597
- }], resultsCount: [{
598
- type: Input
599
- }], searchDelay: [{
600
- type: Input
601
- }], select: [{
602
- type: Output
603
- }], remove: [{
604
- type: Output
605
- }], results: [{
606
- type: ViewChild,
607
- args: ["results", { static: false }]
608
- }], termInput: [{
609
- type: ViewChild,
610
- args: ["termInput", { static: false }]
611
- }] } });
612
-
613
- /**
614
- * A customized template for Dropdown list items.
615
- */
616
- class TemplateDropdownDirective {
617
- constructor(templateRef, host) {
618
- this.templateRef = templateRef;
619
- if (host instanceof DropdownSelectComponent) {
620
- host.templateRef = templateRef;
621
- }
622
- }
623
- }
624
- TemplateDropdownDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TemplateDropdownDirective, deps: [{ token: i0.TemplateRef }, { token: DropdownSelectComponent, host: true }], target: i0.ɵɵFactoryTarget.Directive });
625
- TemplateDropdownDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.10", type: TemplateDropdownDirective, selector: "[appTemplateDropdown]", ngImport: i0 });
626
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TemplateDropdownDirective, decorators: [{
627
- type: Directive,
628
- args: [{
629
- selector: "[appTemplateDropdown]"
630
- }]
631
- }], ctorParameters: function () {
632
- return [{ type: i0.TemplateRef }, { type: DropdownSelectComponent, decorators: [{
633
- type: Host
634
- }] }];
635
- } });
636
-
637
- const DROPDOWN_TYPE = Object.freeze({
638
- INPUT_SINGLE: 0,
639
- INPUT_MULTI: 1,
640
- SELECT_SINGLE: 2,
641
- SELECT_MULTI: 3,
642
- SELECT_SINGLE_CUSTOM: 4,
643
- SELECT_MULTI_CUSTOM: 5
644
- });
645
- class DropdownService {
646
- constructor(http, dictionaryEndpoint) {
647
- this.http = http;
648
- this.dictionaryEndpoint = dictionaryEndpoint;
649
- this.listField = [];
650
- this.DICTIONARY_ENDPOINT = "";
651
- this.headers = new HttpHeaders().set("Content-Type", "application/json");
652
- this.options = { headers: this.headers };
653
- this.sortFunction = (dropdownObj1, dropdownObj2) => {
654
- if (dropdownObj1[this.listField[0]] < dropdownObj2[this.listField[0]]) {
655
- return -1;
656
- }
657
- else if (dropdownObj1[this.listField[0]] > dropdownObj2[this.listField[0]]) {
658
- return 1;
659
- }
660
- else {
661
- return 0;
662
- }
663
- };
664
- }
665
- /**
666
- * Get a list of data from the given object or url to set to the dropdown list.
667
- * @param {string} urlStr
668
- * @param {Object[]} dataObject
669
- * @param {string} displayField
670
- * @returns {any[]}
671
- */
672
- setData(urlStr, dataObject, displayField) {
673
- let listFieldSet = [];
674
- let dataListSet = [];
675
- if (dataObject) {
676
- // Set data from the passed object.
677
- if (isDevMode) {
678
- console.debug("DropdownService.setData. dataObject=:", dataObject);
679
- }
680
- if (dataObject) {
681
- if (listFieldSet.length === 0 || listFieldSet[0] === "") {
682
- dataObject.forEach(item => dataListSet.push(item));
683
- listFieldSet.push(displayField);
684
- this.listField.push(displayField);
685
- }
686
- }
687
- }
688
- else if (urlStr && urlStr.length > 0) {
689
- // Set data from a passed url.
690
- if (isDevMode) {
691
- console.debug("DropdownService.setData. urlStr=:", urlStr);
692
- }
693
- this.getDataList(urlStr).subscribe((data) => {
694
- if (data) {
695
- if (listFieldSet.length === 0 || listFieldSet[0] === "") {
696
- data.forEach(item => dataListSet.push(item));
697
- listFieldSet.push(displayField);
698
- this.listField.push(displayField);
699
- console.debug(data);
700
- console.debug(this.listField);
701
- }
702
- }
703
- });
704
- }
705
- else {
706
- throw new Error("Neither optionData or dataUrl were defined.");
707
- }
708
- return dataListSet;
709
- }
710
- listData(pattern, dataSet, maxResults) {
711
- return of(dataSet
712
- .filter((dropdownObj) => dropdownObj[this.listField[0]].toUpperCase().indexOf(pattern.toUpperCase()) !== -1)
713
- .sort(this.sortFunction));
714
- }
715
- /**
716
- * Get the max list data
717
- * @param {string} pattern
718
- * @param {number} maxResults
719
- * @param {any[]} dataSet
720
- * @returns {Observable<{count: number; results: Object[]}>}
721
- */
722
- listDataMax(pattern, maxResults, dataSet) {
723
- const filteredList = dataSet
724
- .filter((dropdownObj) => dropdownObj[this.listField[0]].toUpperCase().indexOf(pattern.toUpperCase()) !== -1)
725
- .sort(this.sortFunction);
726
- return timer(3000)
727
- .pipe(map((t) => {
728
- return {
729
- count: filteredList.length,
730
- results: maxResults && maxResults < filteredList.length ? filteredList.splice(0, maxResults) : filteredList
731
- };
732
- }));
733
- }
734
- /**
735
- * Push the selected items to a list to show in the input text area.
736
- * @param {any[]} ids
737
- * @param {any[]} dataSet
738
- * @returns {Observable<Object[]>}
739
- */
740
- getItems(ids, dataSet) {
741
- const selectedItems = [];
742
- ids.forEach((id) => {
743
- dataSet
744
- .filter((item) => item.id === id)
745
- .map((item) => selectedItems.push(item));
746
- });
747
- return of(selectedItems);
748
- }
749
- // Get data from the given url to set in the dropdown list.
750
- getDataList(urlStr) {
751
- return this.http.get(this.dictionaryEndpoint + urlStr);
752
- }
753
- }
754
- DropdownService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DropdownService, deps: [{ token: i2$1.HttpClient }, { token: DICTIONARY_ENDPOINT }], target: i0.ɵɵFactoryTarget.Injectable });
755
- DropdownService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DropdownService });
756
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DropdownService, decorators: [{
757
- type: Injectable
758
- }], ctorParameters: function () {
759
- return [{ type: i2$1.HttpClient }, { type: undefined, decorators: [{
760
- type: Inject,
761
- args: [DICTIONARY_ENDPOINT]
762
- }] }];
763
- } });
764
-
765
- class DropdownComponent {
766
- constructor(dropdownService, formBuilder) {
767
- this.dropdownService = dropdownService;
768
- this.formBuilder = formBuilder;
769
- this.modifiedData = [];
770
- this.isDisabled = false;
771
- this.inputSingleDataChange = new EventEmitter();
772
- this.inputMultiDataChange = new EventEmitter();
773
- }
774
- ngOnInit() {
775
- this.dropdownForm = this.formBuilder.group({
776
- option: new UntypedFormControl(""),
777
- dropdownSingleTypeAhead: new UntypedFormControl(""),
778
- dropdownMultipleTypeAhead: new UntypedFormControl(""),
779
- dropdownSingle: new UntypedFormControl(""),
780
- dropdownMultiple: new UntypedFormControl(""),
781
- habilitado: true
782
- });
783
- this.initDropdownForm();
784
- this.initDropdownItem();
785
- this.dropdownForm.valueChanges.subscribe(() => { });
786
- }
787
- onSelect(item) {
788
- if (this.dropdownType === 0 || this.dropdownType === 2 || this.dropdownType === 4) {
789
- this.modifiedData.length = 0;
790
- this.modifiedData.push(item.entity);
791
- this.inputSingleData = this.modifiedData[0];
792
- this.inputSingleDataChange.emit(this.inputSingleData);
793
- }
794
- else if (this.dropdownType === 1 || this.dropdownType === 3) {
795
- this.modifiedData.push(item.entity);
796
- this.inputMultiData = this.modifiedData;
797
- this.inputMultiDataChange.emit(this.inputMultiData);
798
- }
799
- }
800
- onRemove(item) {
801
- if (this.modifiedData.length > 0) {
802
- const index = this.modifiedData.indexOf(item.entity, 0);
803
- if (index > -1) {
804
- this.modifiedData.splice(index, 1);
805
- }
806
- }
807
- if (this.inputSingleData) {
808
- this.inputSingleData = "";
809
- this.inputSingleDataChange.emit(this.inputSingleData);
810
- }
811
- if (this.inputMultiData) {
812
- this.inputMultiData = this.modifiedData;
813
- this.inputMultiDataChange.emit(this.inputMultiData);
814
- }
815
- }
816
- reset() {
817
- this.dropdownForm.reset();
818
- }
819
- send(formJson) { }
820
- initDropdownItem() {
821
- let dataSet = [];
822
- // Set dropdown data list from a given array or a json file
823
- if (this.optionData && this.optionData.length > 0) {
824
- // Get dropdown list data from an object
825
- if (isDevMode()) {
826
- console.debug("optionData=", this.optionData);
827
- }
828
- dataSet = this.dropdownService.setData(undefined, this.optionData, this.displayField);
829
- }
830
- else if (this.dataUrl && this.dataUrl !== "") {
831
- // Get dropdown list data from an url with json file
832
- if (isDevMode()) {
833
- console.debug("dataUrl=", this.dataUrl);
834
- }
835
- dataSet = this.dropdownService.setData(this.dataUrl, undefined, this.displayField);
836
- }
837
- else {
838
- console.error("Neither optionData or dataUrl were defined.");
839
- if (isDevMode()) {
840
- console.debug("dataUrl=", this.dataUrl);
841
- console.debug("optionData=", this.optionData);
842
- }
843
- }
844
- // Filter and sort data
845
- this.listItems = (term) => this.dropdownService.listData(term, dataSet);
846
- this.listItemsMax = (term, ids) => {
847
- const selectedCount = ids ? ids.length : 0;
848
- return this.dropdownService.listDataMax(term, 3 + selectedCount, dataSet)
849
- .pipe(tap(response => this.count = response.count), map((response) => response.results));
850
- };
851
- // Get items and set them to the dropdown entiry
852
- this.getItems = (ids) => this.dropdownService.getItems(ids, dataSet);
853
- this.entityToSelectItem = (entity) => {
854
- return {
855
- id: entity[this.displayId],
856
- text: entity[this.displayField],
857
- entity: entity
858
- };
859
- };
860
- }
861
- initDropdownForm() {
862
- this.modifiedData.length = 0;
863
- if (this.dropdownType === 0 && this.inputSingleData) {
864
- this.dropdownForm.controls["dropdownSingleTypeAhead"].setValue(this.inputSingleData);
865
- this.modifiedData.push(this.inputSingleData);
866
- }
867
- if (this.dropdownType === 1 && this.inputMultiData) {
868
- this.dropdownForm.controls["dropdownMultipleTypeAhead"].setValue(this.inputMultiData);
869
- this.modifiedData = this.inputMultiData;
870
- }
871
- if (this.dropdownType === 2 && this.inputSingleData) {
872
- this.dropdownForm.controls["dropdownSingle"].setValue(this.inputSingleData);
873
- this.modifiedData.push(this.inputSingleData);
874
- }
875
- if (this.dropdownType === 3 && this.inputMultiData) {
876
- this.dropdownForm.controls["dropdownMultiple"].setValue(this.inputMultiData);
877
- this.modifiedData = this.inputMultiData;
878
- }
879
- if (this.dropdownType === 4 && this.inputSingleData) {
880
- this.dropdownForm.controls["dropdownSingle"].setValue(this.inputSingleData);
881
- this.modifiedData.push(this.inputSingleData);
882
- }
883
- }
884
- }
885
- DropdownComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DropdownComponent, deps: [{ token: DropdownService }, { token: i2.UntypedFormBuilder }], target: i0.ɵɵFactoryTarget.Component });
886
- DropdownComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: DropdownComponent, selector: "hci-dropdown", inputs: { inputSingleData: "inputSingleData", inputMultiData: "inputMultiData", modifiedData: "modifiedData", optionData: "optionData", displayField: "displayField", displayId: "displayId", dataUrl: "dataUrl", dropdownType: "dropdownType", placeholder: "placeholder", isDisabled: "isDisabled" }, outputs: { inputSingleDataChange: "inputSingleDataChange", inputMultiDataChange: "inputMultiDataChange" }, providers: [DropdownService], viewQueries: [{ propertyName: "dropdownSingle", first: true, predicate: ["dropdownSingle"], descendants: true }], ngImport: i0, template: `
887
- <form novalidate [formGroup]="dropdownForm">
888
- <div class="form-group">
889
- <hci-dropdown-select #dropdownSingle *ngIf="dropdownType === 0"
890
- [placeholder]="placeholder"
891
- formControlName="dropdownSingleTypeAhead"
892
- [multiple]="false"
893
- [dataProvider]="listItems"
894
- [selectItemAdapter]="entityToSelectItem"
895
- referenceMode="entity"
896
- (select)="onSelect($event)"
897
- (remove)="onRemove($event)"
898
- [disabled]="isDisabled"
899
- [selectedProvider]="getItems"
900
- [clientMode]="true"></hci-dropdown-select>
901
- <hci-dropdown-select *ngIf="dropdownType === 1"
902
- [placeholder]="placeholder"
903
- formControlName="dropdownMultipleTypeAhead"
904
- [dataProvider]="listItems"
905
- [selectItemAdapter]="entityToSelectItem"
906
- [clientMode]="true"
907
- referenceMode="entity"
908
- [multiple]="true"
909
- (select)="onSelect($event)"
910
- (remove)="onRemove($event)"
911
- [disabled]="isDisabled"
912
- [selectedProvider]="getItems"
913
- [clientMode]="true"></hci-dropdown-select>
914
- <hci-dropdown-select *ngIf="dropdownType === 2"
915
- [placeholder]="placeholder"
916
- formControlName="dropdownSingle"
917
- [dataProvider]="listItems"
918
- [selectItemAdapter]="entityToSelectItem"
919
- [inputState]="0"
920
- referenceMode="entity"
921
- [multiple]="false"
922
- (select)="onSelect($event)"
923
- (remove)="onRemove($event)"
924
- [disabled]="isDisabled"
925
- [selectedProvider]="getItems"
926
- [clientMode]="true"></hci-dropdown-select>
927
- <hci-dropdown-select *ngIf="dropdownType === 3"
928
- [placeholder]="placeholder"
929
- formControlName="dropdownMultiple"
930
- [dataProvider]="listItems"
931
- [selectItemAdapter]="entityToSelectItem"
932
- [inputState]="0"
933
- referenceMode="entity"
934
- [multiple]="true"
935
- (select)="onSelect($event)"
936
- (remove)="onRemove($event)"
937
- [selectedProvider]="getItems"
938
- [disabled]="isDisabled"
939
- [clientMode]="true"></hci-dropdown-select>
940
- <hci-dropdown-select *ngIf="dropdownType === 4"
941
- [placeholder]="placeholder"
942
- formControlName="dropdownSingle"
943
- [dataProvider]="listItems"
944
- [selectItemAdapter]="entityToSelectItem"
945
- [inputState]="0"
946
- referenceMode="entity"
947
- (select)="onSelect($event)"
948
- (remove)="onRemove($event)"
949
- [selectedProvider]="getItems"
950
- [disabled]="isDisabled"
951
- [clientMode]="true">
952
- <div *appTemplateDropdown="let item = $entity; let i = $index">
953
- <span>[{{item.id}}]</span> {{item[displayField]}}
954
- </div>
955
- </hci-dropdown-select>
956
- </div>
957
- </form>
958
- `, isInline: true, dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i2.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: TemplateDropdownDirective, selector: "[appTemplateDropdown]" }, { kind: "component", type: DropdownSelectComponent, selector: "hci-dropdown-select", inputs: ["messages", "dataProvider", "selectedProvider", "selectItemAdapter", "referenceMode", "placeholder", "disabled", "multiple", "clientMode", "deleteIcon", "inputState", "resultsCount", "searchDelay"], outputs: ["select", "remove"] }] });
959
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DropdownComponent, decorators: [{
960
- type: Component,
961
- args: [{
962
- selector: "hci-dropdown",
963
- template: `
964
- <form novalidate [formGroup]="dropdownForm">
965
- <div class="form-group">
966
- <hci-dropdown-select #dropdownSingle *ngIf="dropdownType === 0"
967
- [placeholder]="placeholder"
968
- formControlName="dropdownSingleTypeAhead"
969
- [multiple]="false"
970
- [dataProvider]="listItems"
971
- [selectItemAdapter]="entityToSelectItem"
972
- referenceMode="entity"
973
- (select)="onSelect($event)"
974
- (remove)="onRemove($event)"
975
- [disabled]="isDisabled"
976
- [selectedProvider]="getItems"
977
- [clientMode]="true"></hci-dropdown-select>
978
- <hci-dropdown-select *ngIf="dropdownType === 1"
979
- [placeholder]="placeholder"
980
- formControlName="dropdownMultipleTypeAhead"
981
- [dataProvider]="listItems"
982
- [selectItemAdapter]="entityToSelectItem"
983
- [clientMode]="true"
984
- referenceMode="entity"
985
- [multiple]="true"
986
- (select)="onSelect($event)"
987
- (remove)="onRemove($event)"
988
- [disabled]="isDisabled"
989
- [selectedProvider]="getItems"
990
- [clientMode]="true"></hci-dropdown-select>
991
- <hci-dropdown-select *ngIf="dropdownType === 2"
992
- [placeholder]="placeholder"
993
- formControlName="dropdownSingle"
994
- [dataProvider]="listItems"
995
- [selectItemAdapter]="entityToSelectItem"
996
- [inputState]="0"
997
- referenceMode="entity"
998
- [multiple]="false"
999
- (select)="onSelect($event)"
1000
- (remove)="onRemove($event)"
1001
- [disabled]="isDisabled"
1002
- [selectedProvider]="getItems"
1003
- [clientMode]="true"></hci-dropdown-select>
1004
- <hci-dropdown-select *ngIf="dropdownType === 3"
1005
- [placeholder]="placeholder"
1006
- formControlName="dropdownMultiple"
1007
- [dataProvider]="listItems"
1008
- [selectItemAdapter]="entityToSelectItem"
1009
- [inputState]="0"
1010
- referenceMode="entity"
1011
- [multiple]="true"
1012
- (select)="onSelect($event)"
1013
- (remove)="onRemove($event)"
1014
- [selectedProvider]="getItems"
1015
- [disabled]="isDisabled"
1016
- [clientMode]="true"></hci-dropdown-select>
1017
- <hci-dropdown-select *ngIf="dropdownType === 4"
1018
- [placeholder]="placeholder"
1019
- formControlName="dropdownSingle"
1020
- [dataProvider]="listItems"
1021
- [selectItemAdapter]="entityToSelectItem"
1022
- [inputState]="0"
1023
- referenceMode="entity"
1024
- (select)="onSelect($event)"
1025
- (remove)="onRemove($event)"
1026
- [selectedProvider]="getItems"
1027
- [disabled]="isDisabled"
1028
- [clientMode]="true">
1029
- <div *appTemplateDropdown="let item = $entity; let i = $index">
1030
- <span>[{{item.id}}]</span> {{item[displayField]}}
1031
- </div>
1032
- </hci-dropdown-select>
1033
- </div>
1034
- </form>
1035
- `,
1036
- providers: [DropdownService]
1037
- }]
1038
- }], ctorParameters: function () { return [{ type: DropdownService }, { type: i2.UntypedFormBuilder }]; }, propDecorators: { inputSingleData: [{
1039
- type: Input
1040
- }], inputMultiData: [{
1041
- type: Input
1042
- }], modifiedData: [{
1043
- type: Input
1044
- }], optionData: [{
1045
- type: Input
1046
- }], displayField: [{
1047
- type: Input
1048
- }], displayId: [{
1049
- type: Input
1050
- }], dataUrl: [{
1051
- type: Input
1052
- }], dropdownType: [{
1053
- type: Input
1054
- }], placeholder: [{
1055
- type: Input
1056
- }], isDisabled: [{
1057
- type: Input
1058
- }], inputSingleDataChange: [{
1059
- type: Output
1060
- }], inputMultiDataChange: [{
1061
- type: Output
1062
- }], dropdownSingle: [{
1063
- type: ViewChild,
1064
- args: ["dropdownSingle", { static: false }]
1065
- }] } });
1066
-
1067
- class DropdownModule {
1068
- }
1069
- DropdownModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DropdownModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1070
- DropdownModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.10", ngImport: i0, type: DropdownModule, declarations: [TemplateDropdownDirective,
1071
- DropdownSelectComponent,
1072
- DropdownComponent,
1073
- DropdownSelectResultComponent], imports: [CommonModule,
1074
- FormsModule,
1075
- ReactiveFormsModule,
1076
- NgbModule], exports: [TemplateDropdownDirective,
1077
- DropdownSelectComponent,
1078
- DropdownComponent,
1079
- DropdownSelectResultComponent] });
1080
- DropdownModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DropdownModule, imports: [CommonModule,
1081
- FormsModule,
1082
- ReactiveFormsModule,
1083
- NgbModule] });
1084
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DropdownModule, decorators: [{
1085
- type: NgModule,
1086
- args: [{
1087
- imports: [
1088
- CommonModule,
1089
- FormsModule,
1090
- ReactiveFormsModule,
1091
- NgbModule
1092
- ],
1093
- declarations: [
1094
- TemplateDropdownDirective,
1095
- DropdownSelectComponent,
1096
- DropdownComponent,
1097
- DropdownSelectResultComponent
1098
- ],
1099
- exports: [
1100
- TemplateDropdownDirective,
1101
- DropdownSelectComponent,
1102
- DropdownComponent,
1103
- DropdownSelectResultComponent
1104
- ]
1105
- }]
1106
- }] });
1107
-
1108
- class DateValidator {
1109
- static dateFormatValidator(ac) {
1110
- if (ac && ac.value && !moment(ac.value, "M/D/YYYY", true).isValid()) {
1111
- return { "dateFormatValidator": true };
1112
- }
1113
- return null;
1114
- }
1115
- static dateRangeValidator(ac) {
1116
- if (ac && ac.value && DateValidator.minValue && DateValidator.maxValue && moment(ac.value, "M/D/YYYY", true).isValid()) {
1117
- let dateValue = moment(ac.value);
1118
- let minDate = moment(DateValidator.convertNgbStructToDate(DateValidator.minValue));
1119
- let maxDate = moment(DateValidator.convertNgbStructToDate(DateValidator.maxValue));
1120
- if (dateValue.isBefore(minDate, "day") || dateValue.isAfter(maxDate, "day")) {
1121
- return { "dateRangeValidator": true };
1122
- }
1123
- }
1124
- return null;
1125
- }
1126
- static convertNgbStructToDate(struct) {
1127
- return { year: struct.year, month: struct.month - 1, day: struct.day };
1128
- }
1129
- static inRange(ac) {
1130
- if (ac && ac.value && DateValidator.minValue && DateValidator.maxValue && moment(ac.value, "M/D/YYYY", true).isValid()) {
1131
- let dateValue = moment(ac.value);
1132
- let minDate = moment(DateValidator.convertNgbStructToDate(DateValidator.minValue));
1133
- let maxDate = moment(DateValidator.convertNgbStructToDate(DateValidator.maxValue));
1134
- if (dateValue.isBefore(minDate, "day") || dateValue.isAfter(maxDate, "day")) {
1135
- return false;
1136
- }
1137
- else {
1138
- return true;
1139
- }
1140
- }
1141
- return false;
1142
- }
1143
- }
1144
- DateValidator.minValue = undefined;
1145
- DateValidator.maxValue = undefined;
1146
-
1147
- /**
1148
- * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary
1149
- *
1150
- * Extending class works like in Java except that decorators are only scanned in the child class. In this case,
1151
- * we want variables like inputData to be available to all inline components that extend this class; however, we want
1152
- * this variable to be an @Input.
1153
- * What we can do here is define "inputData: Object" here and in the extending class, define "@Input inputData: Object".
1154
- *
1155
- * The two way binding to the component is inputData. To allow non-saving modification to this data, we copy
1156
- * it to modifiedData. The wrapped component such as input/select/... then use modifiedData as their ngModel.
1157
- * When we cancel out of editing, modifiedData is ignored and replaced with inputData. When editing is saved, inputData
1158
- * is replaced with modifiedData.
1159
- *
1160
- * @since 1.0.0
1161
- */
1162
- class DateBase {
1163
- constructor(elementRef) {
1164
- this.state = 0;
1165
- this._el = elementRef.nativeElement;
1166
- }
1167
- /**
1168
- * Listen to clicks on the document. If the state is in edit mode and there is a click outside the element,
1169
- * then save it.
1170
- *
1171
- * @param event
1172
- */
1173
- handleOutsideEvent(event) {
1174
- if (this.state !== 1) {
1175
- return;
1176
- }
1177
- let targetCmpt = null;
1178
- try {
1179
- // Catch exception if target is not an element
1180
- targetCmpt = event.target;
1181
- }
1182
- catch (e) {
1183
- this.save();
1184
- return;
1185
- }
1186
- let inside = false;
1187
- do {
1188
- if (targetCmpt === this._el) {
1189
- inside = true;
1190
- break;
1191
- }
1192
- targetCmpt = targetCmpt.parentElement;
1193
- } while (targetCmpt);
1194
- if (!inside) {
1195
- this.save();
1196
- }
1197
- }
1198
- /**
1199
- * Updates the modifiedData (working data) to the bound data.
1200
- */
1201
- updateInternalDataFromModel() {
1202
- this.modifiedData = this.inputData;
1203
- }
1204
- /**
1205
- * Updates the bound data with the working data.
1206
- */
1207
- updateModelFromInternalData() {
1208
- this.inputData = this.modifiedData;
1209
- }
1210
- /**
1211
- * When user chooses to edit, change state to show edit dialog.
1212
- */
1213
- startEdit() {
1214
- this.modifiedData = this.inputData;
1215
- this.state = 1;
1216
- }
1217
- /**
1218
- * Generic actions to change state based on key input. Escape will cancel out of the edit
1219
- * without saving, enter will save and exit.
1220
- *
1221
- * @param event
1222
- */
1223
- onKeyDown(event) {
1224
- if (event.key === "escape") {
1225
- this.cancel();
1226
- }
1227
- else if (event.key === "enter") {
1228
- this.save();
1229
- }
1230
- }
1231
- /**
1232
- *
1233
- * @param newValue
1234
- */
1235
- onChange(newValue) {
1236
- this.modifiedData = newValue;
1237
- }
1238
- /**
1239
- * Replace the bound data with the working data and exit editing mode.
1240
- */
1241
- save() {
1242
- this.updateModelFromInternalData();
1243
- this.state = 0;
1244
- }
1245
- /**
1246
- * Don't update the bound data and exit the editing mode.
1247
- */
1248
- cancel() {
1249
- this.updateInternalDataFromModel();
1250
- this.state = 0;
1251
- }
1252
- }
1253
- DateBase.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DateBase, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Injectable });
1254
- DateBase.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DateBase });
1255
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DateBase, decorators: [{
1256
- type: Injectable
1257
- }], ctorParameters: function () { return [{ type: i0.ElementRef }]; } });
1258
-
1259
- /**
1260
- * TODO: Confirm timezone behavior.
1261
- *
1262
- * @since 4.0.0
1263
- */
1264
- class DateComponent extends DateBase {
1265
- constructor(elementRef, formBuilder, datePipe, changeDetectorRef) {
1266
- super(elementRef);
1267
- this.formBuilder = formBuilder;
1268
- this.datePipe = datePipe;
1269
- this.changeDetectorRef = changeDetectorRef;
1270
- // Binded data from the parent component.
1271
- this.dateFormat = "shortDate";
1272
- this.inputDataChange = new EventEmitter();
1273
- // only validate if user is typing
1274
- this.validate = false;
1275
- this.focused = false;
1276
- }
1277
- /**
1278
- *
1279
- */
1280
- ngOnInit() {
1281
- this.dateForm = this.formBuilder.group({
1282
- dateInput: new UntypedFormControl("", [DateValidator.dateFormatValidator, DateValidator.dateRangeValidator])
1283
- });
1284
- this.onChanges();
1285
- this.updateInternalDataFromModel();
1286
- // set the minDate to 20 years in the past by default
1287
- let today = new Date();
1288
- if (!this.minDate) {
1289
- this.minDate = { year: today.getFullYear() - 20, month: today.getMonth() + 1, day: today.getDate() };
1290
- }
1291
- // set max date to today by default
1292
- if (!this.maxDate) {
1293
- this.maxDate = { year: today.getFullYear(), month: today.getMonth() + 1, day: today.getDate() };
1294
- }
1295
- }
1296
- ngAfterViewInit() {
1297
- // Fill the input with the bound data set in the parent component.
1298
- if (this.inputData) {
1299
- let formattedDate = this.datePipe.transform(this.inputData, this.dateFormat);
1300
- this.dateForm.controls["dateInput"].setValue(formattedDate);
1301
- }
1302
- this.changeDetectorRef.detectChanges();
1303
- }
1304
- onChanges() { }
1305
- ngDoCheck() {
1306
- // this is the only way I found to have the focus on the startDate day when the user opens
1307
- // the popup. We only want to focus once otherwise user can not click anywhere else in the popup
1308
- if (this.dp && !this.focused) {
1309
- this.dp.focus();
1310
- this.focused = true;
1311
- }
1312
- // mark picker for focusing next time it is open
1313
- if (this.state === 0) {
1314
- this.focused = false;
1315
- }
1316
- }
1317
- updateInternalDataFromModel() {
1318
- if (this.inputData) {
1319
- this.modifiedData = new Date(this.inputData);
1320
- let md = new Date(this.inputData);
1321
- this.startDate = { year: md.getFullYear(), month: md.getMonth() + 1, day: md.getDate() };
1322
- }
1323
- else {
1324
- let today = new Date();
1325
- this.startDate = { year: today.getFullYear(), month: today.getMonth() + 1, day: today.getDate() };
1326
- }
1327
- }
1328
- /**
1329
- * Updates the bound data with the working data.
1330
- */
1331
- updateModelFromInternalData() {
1332
- if (this.modifiedData) {
1333
- let dsDate = this.ngbDateToString(this.modifiedData);
1334
- if (dsDate) {
1335
- this.inputData = dsDate;
1336
- }
1337
- else {
1338
- this.inputData = this.modifiedData;
1339
- }
1340
- const formattedModifiedDate = this.datePipe.transform(this.inputData, this.dateFormat);
1341
- this.dateForm.controls["dateInput"].setValue(formattedModifiedDate, { emitEvent: false });
1342
- }
1343
- this.inputDataChange.emit(this.inputData);
1344
- this.updateInternalDataFromModel();
1345
- }
1346
- clear() {
1347
- this.modifiedData = null;
1348
- this.inputData = null;
1349
- this.dateForm.controls["dateInput"].setValue("");
1350
- this.validate = false;
1351
- let today = new Date();
1352
- this.startDate = { year: today.getFullYear(), month: today.getMonth() + 1, day: today.getDate() };
1353
- this.state = 0;
1354
- this.dateForm.controls["dateInput"].setValue("");
1355
- this.inputDataChange.emit(this.inputData);
1356
- }
1357
- onKeyUpInput(event) {
1358
- // Check for when the input is deleted before being saved
1359
- if (event.key === "Delete" || event.key === "Backspace") {
1360
- if (this.dateForm.controls["dataInput"].value.length === 0) {
1361
- this.clear();
1362
- }
1363
- }
1364
- // update range so that the date range validator can run accurately
1365
- DateValidator.minValue = this.minDate;
1366
- DateValidator.maxValue = this.maxDate;
1367
- // Get the updated dateForm value
1368
- let eventTarget = event.target;
1369
- let inputValue = eventTarget.value;
1370
- this.dateForm.controls["dateInput"].patchValue(inputValue);
1371
- // if we have a good date and is within the range update the picker
1372
- if (DateValidator.inRange(this.dateForm.controls["dateInput"])) {
1373
- this.validate = false;
1374
- this.inputData = this.datePipe.transform(this.dateForm.controls["dateInput"].value, this.dateFormat);
1375
- this.updateInternalDataFromModel();
1376
- this.dateForm.controls["dateInput"].setValue(this.inputData);
1377
- this.inputDataChange.emit(this.inputData);
1378
- }
1379
- else {
1380
- this.validate = true;
1381
- }
1382
- // // only validate if user is typing
1383
- // if (!this.validate) {
1384
- // this.validate = true;
1385
- // this.dateForm.controls["dateInput"].setValue("");
1386
- //
1387
- // // clear the date picker
1388
- // this.modifiedData = null;
1389
- // this.inputData = null;
1390
- // let today: Date = new Date();
1391
- // this.startDate = {year: today.getFullYear(), month: today.getMonth() + 1, day: today.getDate()};
1392
- // this.state = 0;
1393
- // this.inputDataChange.emit(this.inputData);
1394
- // }
1395
- }
1396
- /**
1397
- * NgbDateStruct stores day, month and year. Convert this to ISO8601.
1398
- *
1399
- * @param date
1400
- * @returns {any}
1401
- */
1402
- ngbDateToString(date) {
1403
- if (date === undefined || date === null) {
1404
- return null;
1405
- }
1406
- else if (date.year === undefined || date.month === undefined || date.day === undefined) {
1407
- return null;
1408
- }
1409
- return date.year + "-" + ((date.month < 10) ? "0" : "") + date.month + "-" + ((date.day < 10) ? "0" : "") + date.day + "T12:00-06:00";
1410
- }
1411
- }
1412
- DateComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DateComponent, deps: [{ token: i0.ElementRef }, { token: i2.UntypedFormBuilder }, { token: i1.DatePipe }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
1413
- DateComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: DateComponent, selector: "hci-date", inputs: { dateFormat: "dateFormat", minDate: "minDate", maxDate: "maxDate", label: "label", inputData: "inputData", modifiedData: "modifiedData" }, outputs: { inputDataChange: "inputDataChange" }, host: { listeners: { "document:click": "handleOutsideEvent($event)" } }, providers: [DatePipe, DateValidator], viewQueries: [{ propertyName: "dp", first: true, predicate: ["dp"], descendants: true }], usesInheritance: true, ngImport: i0, template: `
1414
- <div class="form-group">
1415
- <div class="input-group d-flex">
1416
- <form [formGroup]="dateForm" class="flex-grow-1">
1417
- <div class="date-wrapper">
1418
- <div class="input-group-append">
1419
- <input type="text" (keyup)="onKeyUpInput($event)"
1420
- (ngModelChange)="onChange($event)" class="form-control"
1421
- formControlName="dateInput" placeholder="{{label}}"
1422
- aria-label="date" aria-describedby="basic-addon2" />
1423
- <span class="input-group-text" id="basic-addon2" (click)="clear()">
1424
- <i class="fas fa-times"></i>
1425
- </span>
1426
- <button class="btn btn-outline-secondary" type="button" (click)="startEdit();">
1427
- <i class="fas fa-calendar-alt"></i>
1428
- </button>
1429
- </div>
1430
- <div *ngIf="validate && dateForm.get('dateInput').hasError('dateFormatValidator')"
1431
- class="invalid-date">Enter date as M/D/YYYY or MM/DD/YYYY</div>
1432
- <div *ngIf="validate && dateForm.get('dateInput').hasError('dateRangeValidator')"
1433
- class="invalid-date">Invalid Date Range</div>
1434
- </div>
1435
- </form>
1436
- <!--
1437
- We will replace the nbg date picker with material date picker
1438
- -->
1439
- <!-- <form [formGroup]="dateForm" class="flex-grow-1">-->
1440
- <!-- <div class="date-wrapper">-->
1441
- <!-- <div class="input-group-append">-->
1442
- <!-- <mat-form-field appearance="outline" [style.padding-top.em]="0.5"-->
1443
- <!-- [style.padding-bottom.em]="0.5">-->
1444
- <!-- <input matInput (keypress)="onKeyPressInput($event)"-->
1445
- <!-- [min]="minDate" [max]="maxDate" [matDatepicker]="datePicker"-->
1446
- <!-- formControlName="dateInput" placeholder="{{label}}" aria-label="date"-->
1447
- <!-- aria-describedby="basic-addon2">-->
1448
- <!-- <mat-datepicker-toggle matSuffix [for]="datePicker"></mat-datepicker-toggle>-->
1449
- <!-- <mat-datepicker #datePicker></mat-datepicker>-->
1450
- <!-- <mat-error *ngIf="validate && dateForm.get('dateInput').hasError('dateFormatValidator')"-->
1451
- <!-- class="invalid-date">-->
1452
- <!-- Enter date as M/D/YYYY or MM/DD/YYYY-->
1453
- <!-- </mat-error>-->
1454
- <!-- <mat-error *ngIf="validate && dateForm.get('dateInput').hasError('dateRangeValidator')"-->
1455
- <!-- class="invalid-date">-->
1456
- <!-- Invalid Date Range-->
1457
- <!-- </mat-error>-->
1458
- <!-- </mat-form-field>-->
1459
- <!-- </div>-->
1460
- <!-- </div>-->
1461
- <!-- </form>-->
1462
- </div>
1463
- </div>
1464
- <div *ngIf="state === 1" class="inline-editing">
1465
- <ngb-datepicker [ngModel]="modifiedData" #dp [startDate]="startDate" [minDate]="minDate"
1466
- [maxDate]="maxDate" (keydown)="onKeyDown($event)"
1467
- (ngModelChange)="onChange($event)" (select)="save()"></ngb-datepicker>
1468
- <div class="inline-hover-save-options">
1469
- <!-- <a class="btn ii-so-btn save" (click)="save()"><i class="fas fa-check"></i></a>-->
1470
- <!-- <a class="btn ii-so-btn cancel" (click)="cancel()"><i class="fas fa-times"></i></a>-->
1471
- </div>
1472
- </div>
1473
-
1474
- `, isInline: true, styles: [""], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i2.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: i3.NgbDatepicker, selector: "ngb-datepicker", inputs: ["dayTemplate", "dayTemplateData", "displayMonths", "firstDayOfWeek", "footerTemplate", "markDisabled", "maxDate", "minDate", "navigation", "outsideDays", "showWeekNumbers", "startDate", "weekdays"], outputs: ["navigate", "dateSelect"], exportAs: ["ngbDatepicker"] }] });
1475
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DateComponent, decorators: [{
1476
- type: Component,
1477
- args: [{ selector: "hci-date", providers: [DatePipe, DateValidator], template: `
1478
- <div class="form-group">
1479
- <div class="input-group d-flex">
1480
- <form [formGroup]="dateForm" class="flex-grow-1">
1481
- <div class="date-wrapper">
1482
- <div class="input-group-append">
1483
- <input type="text" (keyup)="onKeyUpInput($event)"
1484
- (ngModelChange)="onChange($event)" class="form-control"
1485
- formControlName="dateInput" placeholder="{{label}}"
1486
- aria-label="date" aria-describedby="basic-addon2" />
1487
- <span class="input-group-text" id="basic-addon2" (click)="clear()">
1488
- <i class="fas fa-times"></i>
1489
- </span>
1490
- <button class="btn btn-outline-secondary" type="button" (click)="startEdit();">
1491
- <i class="fas fa-calendar-alt"></i>
1492
- </button>
1493
- </div>
1494
- <div *ngIf="validate && dateForm.get('dateInput').hasError('dateFormatValidator')"
1495
- class="invalid-date">Enter date as M/D/YYYY or MM/DD/YYYY</div>
1496
- <div *ngIf="validate && dateForm.get('dateInput').hasError('dateRangeValidator')"
1497
- class="invalid-date">Invalid Date Range</div>
1498
- </div>
1499
- </form>
1500
- <!--
1501
- We will replace the nbg date picker with material date picker
1502
- -->
1503
- <!-- <form [formGroup]="dateForm" class="flex-grow-1">-->
1504
- <!-- <div class="date-wrapper">-->
1505
- <!-- <div class="input-group-append">-->
1506
- <!-- <mat-form-field appearance="outline" [style.padding-top.em]="0.5"-->
1507
- <!-- [style.padding-bottom.em]="0.5">-->
1508
- <!-- <input matInput (keypress)="onKeyPressInput($event)"-->
1509
- <!-- [min]="minDate" [max]="maxDate" [matDatepicker]="datePicker"-->
1510
- <!-- formControlName="dateInput" placeholder="{{label}}" aria-label="date"-->
1511
- <!-- aria-describedby="basic-addon2">-->
1512
- <!-- <mat-datepicker-toggle matSuffix [for]="datePicker"></mat-datepicker-toggle>-->
1513
- <!-- <mat-datepicker #datePicker></mat-datepicker>-->
1514
- <!-- <mat-error *ngIf="validate && dateForm.get('dateInput').hasError('dateFormatValidator')"-->
1515
- <!-- class="invalid-date">-->
1516
- <!-- Enter date as M/D/YYYY or MM/DD/YYYY-->
1517
- <!-- </mat-error>-->
1518
- <!-- <mat-error *ngIf="validate && dateForm.get('dateInput').hasError('dateRangeValidator')"-->
1519
- <!-- class="invalid-date">-->
1520
- <!-- Invalid Date Range-->
1521
- <!-- </mat-error>-->
1522
- <!-- </mat-form-field>-->
1523
- <!-- </div>-->
1524
- <!-- </div>-->
1525
- <!-- </form>-->
1526
- </div>
1527
- </div>
1528
- <div *ngIf="state === 1" class="inline-editing">
1529
- <ngb-datepicker [ngModel]="modifiedData" #dp [startDate]="startDate" [minDate]="minDate"
1530
- [maxDate]="maxDate" (keydown)="onKeyDown($event)"
1531
- (ngModelChange)="onChange($event)" (select)="save()"></ngb-datepicker>
1532
- <div class="inline-hover-save-options">
1533
- <!-- <a class="btn ii-so-btn save" (click)="save()"><i class="fas fa-check"></i></a>-->
1534
- <!-- <a class="btn ii-so-btn cancel" (click)="cancel()"><i class="fas fa-times"></i></a>-->
1535
- </div>
1536
- </div>
1537
-
1538
- `, host: {
1539
- "(document:click)": "handleOutsideEvent($event)"
1540
- } }]
1541
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i2.UntypedFormBuilder }, { type: i1.DatePipe }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { dp: [{
1542
- type: ViewChild,
1543
- args: ["dp", { static: false }]
1544
- }], dateFormat: [{
1545
- type: Input
1546
- }], minDate: [{
1547
- type: Input
1548
- }], maxDate: [{
1549
- type: Input
1550
- }], label: [{
1551
- type: Input
1552
- }], inputData: [{
1553
- type: Input
1554
- }], modifiedData: [{
1555
- type: Input
1556
- }], inputDataChange: [{
1557
- type: Output
1558
- }] } });
1559
-
1560
- /**
1561
- * TODO: Confirm timezone behavior.
1562
- *
1563
- * @since 4.0.0
1564
- */
1565
- class DateRangeComponent {
1566
- constructor() {
1567
- // Binded data from the parent component.
1568
- this.dateFormat = "shortDate";
1569
- this.inputDataChange = new EventEmitter();
1570
- }
1571
- ngOnInit() {
1572
- this.setRange();
1573
- }
1574
- /**
1575
- *
1576
- */
1577
- ngAfterViewInit() {
1578
- // if there is no start date but there is an end date, make the start date go to the end date
1579
- if (!this.inputStartData && this.inputEndData) {
1580
- let dt = new Date(this.inputEndData);
1581
- this.sp.startDate = { year: dt.getFullYear(), month: dt.getMonth() + 1, day: dt.getDate() };
1582
- }
1583
- }
1584
- onClickSubmitStartDate(startData) {
1585
- this.setRange();
1586
- // if there is no start date but there is an end date, make the start date go to the end date
1587
- if (!startData && this.inputEndData) {
1588
- let dt = new Date(this.inputEndData);
1589
- this.sp.startDate = { year: dt.getFullYear(), month: dt.getMonth() + 1, day: dt.getDate() };
1590
- }
1591
- this.inputDataChange.emit([this.inputStartData, this.inputEndData]);
1592
- }
1593
- onClickSubmitEndDate(endData) {
1594
- this.setRange();
1595
- this.inputDataChange.emit([this.inputStartData, this.inputEndData]);
1596
- }
1597
- setRange() {
1598
- // set the minDate to 20 years in the past by default
1599
- let today = new Date();
1600
- if (!this.minStartDate) {
1601
- this.minStartDate = { year: today.getFullYear() - 20, month: today.getMonth() + 1, day: today.getDate() };
1602
- }
1603
- this.minEndDate = this.minStartDate;
1604
- // set the maxDate to today by default
1605
- this.maxStartDate = { year: today.getFullYear(), month: today.getMonth() + 1, day: today.getDate() };
1606
- this.maxEndDate = this.maxStartDate;
1607
- if (this.inputEndData) {
1608
- let endDate = new Date(this.inputEndData);
1609
- this.maxStartDate = { year: endDate.getFullYear(), month: endDate.getMonth() + 1, day: endDate.getDate() };
1610
- }
1611
- if (this.inputStartData) {
1612
- let startDate = new Date(this.inputStartData);
1613
- this.minEndDate = { year: startDate.getFullYear(), month: startDate.getMonth() + 1, day: startDate.getDate() };
1614
- }
1615
- }
1616
- }
1617
- DateRangeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DateRangeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1618
- DateRangeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: DateRangeComponent, selector: "hci-date-range", inputs: { dateFormat: "dateFormat", inputStartData: "inputStartData", inputEndData: "inputEndData", startLabel: "startLabel", endLabel: "endLabel", minStartDate: "minStartDate" }, outputs: { inputDataChange: "inputDataChange" }, viewQueries: [{ propertyName: "sp", first: true, predicate: ["startdate"], descendants: true, static: true }, { propertyName: "ep", first: true, predicate: ["enddate"], descendants: true, static: true }], ngImport: i0, template: `
1619
- <div class="d-flex flex-wrap date-range">
1620
- <hci-date #startdate
1621
- class="date"
1622
- [label]="startLabel"
1623
- [(inputData)]="inputStartData"
1624
- (inputDataChange)="onClickSubmitStartDate($event)"
1625
- [dateFormat]="dateFormat"
1626
- [minDate]="minStartDate"
1627
- [maxDate]="maxStartDate">
1628
- </hci-date>
1629
- <hci-date #enddate
1630
- class="date"
1631
- [label]="endLabel"
1632
- [(inputData)]="inputEndData"
1633
- (inputDataChange)="onClickSubmitEndDate($event)"
1634
- [dateFormat]="dateFormat"
1635
- [minDate]="minEndDate"
1636
- [maxDate]="maxEndDate">
1637
- </hci-date>
1638
- </div>
1639
- `, isInline: true, dependencies: [{ kind: "component", type: DateComponent, selector: "hci-date", inputs: ["dateFormat", "minDate", "maxDate", "label", "inputData", "modifiedData"], outputs: ["inputDataChange"] }] });
1640
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DateRangeComponent, decorators: [{
1641
- type: Component,
1642
- args: [{
1643
- selector: "hci-date-range",
1644
- template: `
1645
- <div class="d-flex flex-wrap date-range">
1646
- <hci-date #startdate
1647
- class="date"
1648
- [label]="startLabel"
1649
- [(inputData)]="inputStartData"
1650
- (inputDataChange)="onClickSubmitStartDate($event)"
1651
- [dateFormat]="dateFormat"
1652
- [minDate]="minStartDate"
1653
- [maxDate]="maxStartDate">
1654
- </hci-date>
1655
- <hci-date #enddate
1656
- class="date"
1657
- [label]="endLabel"
1658
- [(inputData)]="inputEndData"
1659
- (inputDataChange)="onClickSubmitEndDate($event)"
1660
- [dateFormat]="dateFormat"
1661
- [minDate]="minEndDate"
1662
- [maxDate]="maxEndDate">
1663
- </hci-date>
1664
- </div>
1665
- `
1666
- }]
1667
- }], propDecorators: { sp: [{
1668
- type: ViewChild,
1669
- args: ["startdate", { static: true }]
1670
- }], ep: [{
1671
- type: ViewChild,
1672
- args: ["enddate", { static: true }]
1673
- }], dateFormat: [{
1674
- type: Input
1675
- }], inputStartData: [{
1676
- type: Input
1677
- }], inputEndData: [{
1678
- type: Input
1679
- }], startLabel: [{
1680
- type: Input
1681
- }], endLabel: [{
1682
- type: Input
1683
- }], inputDataChange: [{
1684
- type: Output
1685
- }], minStartDate: [{
1686
- type: Input
1687
- }] } });
1688
-
1689
- class DateModule {
1690
- }
1691
- DateModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DateModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1692
- DateModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.10", ngImport: i0, type: DateModule, declarations: [DateComponent,
1693
- DateRangeComponent], imports: [CommonModule,
1694
- FormsModule,
1695
- ReactiveFormsModule,
1696
- NgbModule,
1697
- MatLegacyTabsModule,
1698
- MatLegacyFormFieldModule,
1699
- MatDatepickerModule,
1700
- MatNativeDateModule,
1701
- MatLegacyInputModule], exports: [DateComponent,
1702
- DateRangeComponent] });
1703
- DateModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DateModule, imports: [CommonModule,
1704
- FormsModule,
1705
- ReactiveFormsModule,
1706
- NgbModule,
1707
- MatLegacyTabsModule,
1708
- MatLegacyFormFieldModule,
1709
- MatDatepickerModule,
1710
- MatNativeDateModule,
1711
- MatLegacyInputModule] });
1712
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DateModule, decorators: [{
1713
- type: NgModule,
1714
- args: [{
1715
- imports: [
1716
- CommonModule,
1717
- FormsModule,
1718
- ReactiveFormsModule,
1719
- NgbModule,
1720
- MatLegacyTabsModule,
1721
- MatLegacyFormFieldModule,
1722
- MatDatepickerModule,
1723
- MatNativeDateModule,
1724
- MatLegacyInputModule
1725
- ],
1726
- declarations: [
1727
- DateComponent,
1728
- DateRangeComponent
1729
- ],
1730
- exports: [
1731
- DateComponent,
1732
- DateRangeComponent
1733
- ]
1734
- }]
1735
- }] });
1736
-
1737
- /**
1738
- * This component is designed to take any input as ng-content and wrap it such that it renders as a string. When hovering
1739
- * over, a border and edit icon is shown. Upon clicking, it enters edit mode and the passed in input is rendered. The
1740
- * bound ngModel is wrapped in an intermediary. This component binds a separate internal value to the wrapped component.
1741
- * This allows the user to cancel out and not update the ngModel bound to this component.
1742
- */
1743
- class InlineComponent {
1744
- constructor() {
1745
- this.noValueMessage = "Click to Add";
1746
- // View state
1747
- this.editMode = false;
1748
- }
1749
- /**
1750
- * Called when the model updates and we need to up the view.
1751
- *
1752
- * @param value
1753
- */
1754
- writeValue(value) {
1755
- if (isDevMode()) {
1756
- console.debug("InlineComponent: writeValue");
1757
- console.debug("InlineComponent: " + value);
1758
- }
1759
- // Update the internal values.
1760
- this.value = value;
1761
- this.modifiedValue = this.value;
1762
- if (this.ngModelRef !== undefined) {
1763
- if (isDevMode()) {
1764
- console.debug("InlineComponent: update ngModelRef: " + this.modifiedValue);
1765
- }
1766
- // Update the model, then tell the directive that it has been updated.
1767
- this.ngModelRef.model = this.modifiedValue;
1768
- this.ngModelRef.ngOnChanges({
1769
- model: new SimpleChange(undefined, this.modifiedValue, false)
1770
- });
1771
- }
1772
- }
1773
- /**
1774
- * Register the function that is called when the value changes in the value.
1775
- *
1776
- * @param {(value: any) => void} fn
1777
- */
1778
- registerOnChange(fn) {
1779
- if (isDevMode()) {
1780
- console.debug("InlineComponent: registerOnChange");
1781
- console.debug(fn);
1782
- }
1783
- this.onChange = () => {
1784
- if (isDevMode()) {
1785
- console.debug("InlineComponent: onChange Function" + this.value);
1786
- }
1787
- fn(this.value);
1788
- };
1789
- }
1790
- /**
1791
- * Register the function called to update the model on blur.
1792
- *
1793
- * @param {() => void} fn
1794
- */
1795
- registerOnTouched(fn) {
1796
- if (isDevMode()) {
1797
- console.debug("InlineComponent: registerOnTouched");
1798
- console.debug(fn);
1799
- }
1800
- this.onTouched = fn;
1801
- }
1802
- /**
1803
- * Set the editMode. If true then tell the passed in input to bind the current modified value.
1804
- *
1805
- * @param {boolean} editMode
1806
- */
1807
- setEditMode(event, editMode) {
1808
- event.stopPropagation();
1809
- this.editMode = editMode;
1810
- if (this.editMode) {
1811
- this.onTouched();
1812
- this.ngModelRef.model = this.modifiedValue;
1813
- this.ngModelRef.ngOnChanges({
1814
- model: new SimpleChange(undefined, this.modifiedValue, false)
1815
- });
1816
- }
1817
- }
1818
- /**
1819
- * Cancel edit mode which resets the modified value.
1820
- */
1821
- cancel() {
1822
- this.editMode = false;
1823
- this.modifiedValue = this.value;
1824
- }
1825
- /**
1826
- * Update the value with the modified value and call the onChange function so two way binding is updated with this component.
1827
- */
1828
- save() {
1829
- if (isDevMode()) {
1830
- console.debug("InlineComponent: save modifiedValue: " + this.modifiedValue + ", value: " + this.value);
1831
- }
1832
- this.value = this.modifiedValue;
1833
- this.onChange(this.value);
1834
- this.editMode = false;
1835
- }
1836
- /**
1837
- * The component to wrap must be named with #input and have a ngModel directive. When the content is set here, we
1838
- * read the ngModel and set the model as well as listen to changes.
1839
- *
1840
- * @param {NgModel} ngModel
1841
- */
1842
- set contentChild(ngModel) {
1843
- if (isDevMode()) {
1844
- console.debug("InlineComponent: set contentChild: " + this.modifiedValue);
1845
- console.debug(ngModel);
1846
- }
1847
- this.ngModelRef = ngModel;
1848
- if (this.ngModelRef) {
1849
- this.ngModelRef.model = this.modifiedValue;
1850
- this.ngModelRef.ngOnChanges({
1851
- model: new SimpleChange(undefined, this.modifiedValue, false)
1852
- });
1853
- this.ngModelRef.update.subscribe((value) => {
1854
- if (isDevMode()) {
1855
- console.debug("InlineComponent: cmpt model change: " + value);
1856
- }
1857
- this.modifiedValue = value;
1858
- });
1859
- }
1860
- }
1861
- /**
1862
- * If the click target is outside the inline input then cancel it.
1863
- *
1864
- * @param {MouseEvent} event
1865
- */
1866
- documentClick(event) {
1867
- if (this.editMode) {
1868
- if (isDevMode()) {
1869
- console.debug("InlineComponent: documentClick");
1870
- }
1871
- let e = event.target.closest("hci-inline-input");
1872
- if (!e) {
1873
- this.save();
1874
- }
1875
- }
1876
- }
1877
- }
1878
- InlineComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: InlineComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1879
- InlineComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: InlineComponent, selector: "hci-inline-input", inputs: { noValueMessage: "noValueMessage" }, host: { listeners: { "document:click": "documentClick($event)" } }, providers: [
1880
- {
1881
- provide: NG_VALUE_ACCESSOR,
1882
- useExisting: forwardRef(() => InlineComponent),
1883
- multi: true
1884
- }
1885
- ], queries: [{ propertyName: "renderTemplate", first: true, predicate: ["renderTemplate"], descendants: true, read: TemplateRef, static: true }, { propertyName: "contentChild", first: true, predicate: ["input"], descendants: true, read: NgModel }], ngImport: i0, template: `
1886
- <div *ngIf="!editMode; else editTemplate"
1887
- (click)="setEditMode($event, true)"
1888
- class="edit-false pl-1">
1889
- <ng-container *ngIf="renderTemplate; else defaultRenderTemplate">
1890
- <ng-container *ngTemplateOutlet="renderTemplate; context: {value: value}"></ng-container>
1891
- </ng-container>
1892
- <ng-template #defaultRenderTemplate>
1893
- <ng-container *ngIf="value">
1894
- {{value}}
1895
- </ng-container>
1896
- <ng-container *ngIf="!value">
1897
- {{noValueMessage}}
1898
- </ng-container>
1899
- </ng-template>
1900
- <button class="btn btn-primary ml-auto">
1901
- <i class="fas fa-pencil"></i>
1902
- </button>
1903
- </div>
1904
-
1905
- <ng-template #editTemplate>
1906
- <div class="edit-true">
1907
- <div class="input-container">
1908
- <ng-content></ng-content>
1909
- </div>
1910
- <div class="d-flex">
1911
- <button class="btn btn-green" (click)="save()">
1912
- <i class="fas fa-check"></i>
1913
- </button>
1914
- <button class="btn btn-red d-flex" (click)="cancel()">
1915
- <i class="fas fa-times ml-auto mr-auto"></i>
1916
- </button>
1917
- </div>
1918
- </div>
1919
- </ng-template>
1920
- `, isInline: true, dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
1921
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: InlineComponent, decorators: [{
1922
- type: Component,
1923
- args: [{
1924
- selector: "hci-inline-input",
1925
- template: `
1926
- <div *ngIf="!editMode; else editTemplate"
1927
- (click)="setEditMode($event, true)"
1928
- class="edit-false pl-1">
1929
- <ng-container *ngIf="renderTemplate; else defaultRenderTemplate">
1930
- <ng-container *ngTemplateOutlet="renderTemplate; context: {value: value}"></ng-container>
1931
- </ng-container>
1932
- <ng-template #defaultRenderTemplate>
1933
- <ng-container *ngIf="value">
1934
- {{value}}
1935
- </ng-container>
1936
- <ng-container *ngIf="!value">
1937
- {{noValueMessage}}
1938
- </ng-container>
1939
- </ng-template>
1940
- <button class="btn btn-primary ml-auto">
1941
- <i class="fas fa-pencil"></i>
1942
- </button>
1943
- </div>
1944
-
1945
- <ng-template #editTemplate>
1946
- <div class="edit-true">
1947
- <div class="input-container">
1948
- <ng-content></ng-content>
1949
- </div>
1950
- <div class="d-flex">
1951
- <button class="btn btn-green" (click)="save()">
1952
- <i class="fas fa-check"></i>
1953
- </button>
1954
- <button class="btn btn-red d-flex" (click)="cancel()">
1955
- <i class="fas fa-times ml-auto mr-auto"></i>
1956
- </button>
1957
- </div>
1958
- </div>
1959
- </ng-template>
1960
- `,
1961
- providers: [
1962
- {
1963
- provide: NG_VALUE_ACCESSOR,
1964
- useExisting: forwardRef(() => InlineComponent),
1965
- multi: true
1966
- }
1967
- ]
1968
- }]
1969
- }], propDecorators: { renderTemplate: [{
1970
- type: ContentChild,
1971
- args: ["renderTemplate", { read: TemplateRef, static: true }]
1972
- }], noValueMessage: [{
1973
- type: Input
1974
- }], contentChild: [{
1975
- type: ContentChild,
1976
- args: ["input", { read: NgModel, static: false }]
1977
- }], documentClick: [{
1978
- type: HostListener,
1979
- args: ["document:click", ["$event"]]
1980
- }] } });
1981
-
1982
- class InlineModule {
1983
- }
1984
- InlineModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: InlineModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1985
- InlineModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.10", ngImport: i0, type: InlineModule, declarations: [InlineComponent], imports: [CommonModule,
1986
- FormsModule], exports: [InlineComponent] });
1987
- InlineModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: InlineModule, imports: [CommonModule,
1988
- FormsModule] });
1989
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: InlineModule, decorators: [{
1990
- type: NgModule,
1991
- args: [{
1992
- imports: [
1993
- CommonModule,
1994
- FormsModule
1995
- ],
1996
- declarations: [
1997
- InlineComponent
1998
- ],
1999
- exports: [
2000
- InlineComponent
2001
- ]
2002
- }]
2003
- }] });
2004
-
2005
- class MdSelectComponent {
2006
- constructor(dictionaryService, http) {
2007
- this.dictionaryService = dictionaryService;
2008
- this.http = http;
2009
- this.classList = "";
2010
- this.required = false;
2011
- this.idKey = "id";
2012
- this.displayKey = "display";
2013
- this.onChangeCallback = () => { };
2014
- this.onTouchedCallback = () => { };
2015
- }
2016
- ngOnInit() {
2017
- if (this.url && this.url.indexOf("/") === -1) {
2018
- this.dictionaryService.getDictionaryDropdownEntries(this.url).subscribe((entries) => {
2019
- this.entries = entries;
2020
- });
2021
- }
2022
- else if (this.url) {
2023
- this.http.get(this.url).subscribe((entries) => {
2024
- this.entries = entries;
2025
- });
2026
- }
2027
- if (this.classList.length > 0) {
2028
- this.classList += " material-input";
2029
- }
2030
- else {
2031
- this.classList = "material-input";
2032
- }
2033
- }
2034
- get value() {
2035
- return this._value;
2036
- }
2037
- set value(newValue) {
2038
- this._value = newValue;
2039
- this.onChangeCallback(newValue);
2040
- }
2041
- onBlur() {
2042
- this.onTouchedCallback();
2043
- }
2044
- writeValue(value) {
2045
- if (value !== this.value) {
2046
- this.value = value;
2047
- }
2048
- }
2049
- registerOnChange(callback) {
2050
- this.onChangeCallback = callback;
2051
- }
2052
- registerOnTouched(callback) {
2053
- this.onTouchedCallback = callback;
2054
- }
2055
- }
2056
- MdSelectComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MdSelectComponent, deps: [{ token: i1$1.DictionaryService }, { token: i2$1.HttpClient }], target: i0.ɵɵFactoryTarget.Component });
2057
- MdSelectComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: MdSelectComponent, selector: "hci-md-select", inputs: { classList: ["class", "classList"], name: "name", label: "label", url: "url", className: "className", entries: "entries", required: "required", idKey: "idKey", displayKey: "displayKey" }, host: { properties: { "class": "this.classList" } }, providers: [
2058
- {
2059
- provide: NG_VALUE_ACCESSOR,
2060
- useExisting: forwardRef(() => MdSelectComponent),
2061
- multi: true
2062
- }
2063
- ], ngImport: i0, template: `
2064
- <mat-form-field>
2065
- <mat-label>{{label}}</mat-label>
2066
- <mat-select [(value)]="value" [required]="required">
2067
- <mat-option *ngIf="!required" [value]="undefined"></mat-option>
2068
- <mat-option *ngFor="let row of entries" [value]="row[idKey]">{{ row[displayKey] }}</mat-option>
2069
- </mat-select>
2070
- </mat-form-field>
2071
- `, isInline: true, dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i3$1.MatLegacyFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i3$1.MatLegacyLabel, selector: "mat-label" }, { kind: "component", type: i6.MatLegacySelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { kind: "component", type: i6$1.MatLegacyOption, selector: "mat-option", exportAs: ["matOption"] }] });
2072
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MdSelectComponent, decorators: [{
2073
- type: Component,
2074
- args: [{
2075
- selector: "hci-md-select",
2076
- template: `
2077
- <mat-form-field>
2078
- <mat-label>{{label}}</mat-label>
2079
- <mat-select [(value)]="value" [required]="required">
2080
- <mat-option *ngIf="!required" [value]="undefined"></mat-option>
2081
- <mat-option *ngFor="let row of entries" [value]="row[idKey]">{{ row[displayKey] }}</mat-option>
2082
- </mat-select>
2083
- </mat-form-field>
2084
- `,
2085
- providers: [
2086
- {
2087
- provide: NG_VALUE_ACCESSOR,
2088
- useExisting: forwardRef(() => MdSelectComponent),
2089
- multi: true
2090
- }
2091
- ]
2092
- }]
2093
- }], ctorParameters: function () { return [{ type: i1$1.DictionaryService }, { type: i2$1.HttpClient }]; }, propDecorators: { classList: [{
2094
- type: HostBinding,
2095
- args: ["class"]
2096
- }, {
2097
- type: Input,
2098
- args: ["class"]
2099
- }], name: [{
2100
- type: Input
2101
- }], label: [{
2102
- type: Input
2103
- }], url: [{
2104
- type: Input
2105
- }], className: [{
2106
- type: Input
2107
- }], entries: [{
2108
- type: Input
2109
- }], required: [{
2110
- type: Input
2111
- }], idKey: [{
2112
- type: Input
2113
- }], displayKey: [{
2114
- type: Input
2115
- }] } });
2116
-
2117
- class NativeSelectComponent {
2118
- get filter() {
2119
- return this._filter;
2120
- }
2121
- set filter(f) {
2122
- this._filter = f;
2123
- if (this.filterKey != null && this.filter != null && this.unfilteredEntries != null) {
2124
- this.entries = this.unfilteredEntries;
2125
- var newlist = this.entries.filter(entry => entry[this.filterKey] == this.filter);
2126
- this.entries = newlist;
2127
- if (this.sortKey != null) {
2128
- if (this.sortNumeric) {
2129
- this.entries.sort((a, b) => {
2130
- return a[this.sortKey] - b[this.sortKey];
2131
- });
2132
- }
2133
- else {
2134
- this.entries.sort((a, b) => {
2135
- return a[this.sortKey].localeCompare(b[this.sortKey]);
2136
- });
2137
- }
2138
- }
2139
- }
2140
- }
2141
- constructor(dictionaryService, http, cdr) {
2142
- this.dictionaryService = dictionaryService;
2143
- this.http = http;
2144
- this.cdr = cdr;
2145
- this.classList = "";
2146
- this.required = false;
2147
- this.idKey = "id";
2148
- this.displayKey = "display";
2149
- this.disabled = false;
2150
- this.sortKey = null;
2151
- this.sortNumeric = false;
2152
- this.filterKey = null;
2153
- this._filter = null;
2154
- }
2155
- ngOnInit() {
2156
- if (this.url && this.url.indexOf("/") === -1) {
2157
- this.dictionaryService.getDictionaryDropdownEntries(this.url).subscribe((entries) => {
2158
- this.entries = entries;
2159
- if (this.filterKey != null && this.filter != null) {
2160
- this.unfilteredEntries = this.entries;
2161
- var newlist = this.entries.filter(entry => entry[this.filterKey] == this.filter);
2162
- this.entries = newlist;
2163
- }
2164
- if (this.sortKey != null) {
2165
- if (this.sortNumeric) {
2166
- this.entries.sort((a, b) => {
2167
- return a[this.sortKey] - b[this.sortKey];
2168
- });
2169
- }
2170
- else {
2171
- this.entries.sort((a, b) => {
2172
- return a[this.sortKey].localeCompare(b[this.sortKey]);
2173
- });
2174
- }
2175
- }
2176
- });
2177
- }
2178
- else if (this.url) {
2179
- this.http.get(this.url).subscribe((entries) => {
2180
- this.entries = entries;
2181
- if (this.filterKey != null && this.filter != null) {
2182
- this.unfilteredEntries = this.entries;
2183
- var newlist = this.entries.filter(entry => entry[this.filterKey] == this.filter);
2184
- this.entries = newlist;
2185
- }
2186
- if (this.sortKey != null) {
2187
- if (this.sortNumeric) {
2188
- this.entries.sort((a, b) => {
2189
- return a[this.sortKey] - b[this.sortKey];
2190
- });
2191
- }
2192
- else {
2193
- this.entries.sort((a, b) => {
2194
- return a[this.sortKey].localeCompare(b[this.sortKey]);
2195
- });
2196
- }
2197
- }
2198
- });
2199
- }
2200
- else {
2201
- if (this.filterKey != null && this.filter != null) {
2202
- this.unfilteredEntries = this.entries;
2203
- var newlist = this.entries.filter(entry => entry[this.filterKey] == this.filter);
2204
- this.entries = newlist;
2205
- }
2206
- if (this.sortKey != null) {
2207
- if (this.sortNumeric) {
2208
- this.entries.sort((a, b) => {
2209
- return a[this.sortKey] - b[this.sortKey];
2210
- });
2211
- }
2212
- else {
2213
- this.entries.sort((a, b) => {
2214
- return a[this.sortKey].localeCompare(b[this.sortKey]);
2215
- });
2216
- }
2217
- }
2218
- }
2219
- if (this.classList.length > 0) {
2220
- this.classList += " native-input"; //?
2221
- }
2222
- else {
2223
- this.classList = "native-input";
2224
- }
2225
- }
2226
- setHeight(h) {
2227
- this.height = h;
2228
- // avoid ExpressionChangedAfterItHasBeenCheckedError
2229
- this.cdr.detectChanges();
2230
- }
2231
- writeValue(value) {
2232
- if (value !== undefined) {
2233
- this.value = value;
2234
- }
2235
- }
2236
- registerOnChange(fn) {
2237
- this.onChange = () => {
2238
- fn(this.value);
2239
- };
2240
- }
2241
- registerOnTouched(fn) { }
2242
- }
2243
- NativeSelectComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: NativeSelectComponent, deps: [{ token: i1$1.DictionaryService }, { token: i2$1.HttpClient }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
2244
- NativeSelectComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: NativeSelectComponent, selector: "hci-native-select", inputs: { classList: ["class", "classList"], name: "name", label: "label", url: "url", entries: "entries", required: "required", idKey: "idKey", displayKey: "displayKey", disabled: "disabled", sortKey: "sortKey", sortNumeric: "sortNumeric", filterKey: "filterKey", filter: "filter" }, host: { properties: { "class": "this.classList" } }, providers: [
2245
- {
2246
- provide: NG_VALUE_ACCESSOR,
2247
- useExisting: forwardRef(() => NativeSelectComponent),
2248
- multi: true
2249
- }
2250
- ], ngImport: i0, template: `
2251
- <div *ngIf="label" class="label">
2252
- {{label}}{{(required) ? " *" : ""}}
2253
- </div>
2254
- <select [(ngModel)]="value"
2255
- [style.height.px]="height"
2256
- (change)="onChange()"
2257
- [disabled]="disabled"
2258
- class="form-control flex-grow-1"
2259
- style="min-width: 4rem;">
2260
- <ng-container *ngIf="!required">
2261
- <option [ngValue]="undefined">
2262
- </option>
2263
- </ng-container>
2264
- <option *ngFor="let row of entries"
2265
- [ngValue]="row[idKey]">
2266
- {{ row[displayKey] }}
2267
- </option>
2268
- </select>
2269
- `, isInline: true, dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i2.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i2.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] });
2270
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: NativeSelectComponent, decorators: [{
2271
- type: Component,
2272
- args: [{
2273
- selector: "hci-native-select",
2274
- template: `
2275
- <div *ngIf="label" class="label">
2276
- {{label}}{{(required) ? " *" : ""}}
2277
- </div>
2278
- <select [(ngModel)]="value"
2279
- [style.height.px]="height"
2280
- (change)="onChange()"
2281
- [disabled]="disabled"
2282
- class="form-control flex-grow-1"
2283
- style="min-width: 4rem;">
2284
- <ng-container *ngIf="!required">
2285
- <option [ngValue]="undefined">
2286
- </option>
2287
- </ng-container>
2288
- <option *ngFor="let row of entries"
2289
- [ngValue]="row[idKey]">
2290
- {{ row[displayKey] }}
2291
- </option>
2292
- </select>
2293
- `,
2294
- providers: [
2295
- {
2296
- provide: NG_VALUE_ACCESSOR,
2297
- useExisting: forwardRef(() => NativeSelectComponent),
2298
- multi: true
2299
- }
2300
- ]
2301
- }]
2302
- }], ctorParameters: function () { return [{ type: i1$1.DictionaryService }, { type: i2$1.HttpClient }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { classList: [{
2303
- type: HostBinding,
2304
- args: ["class"]
2305
- }, {
2306
- type: Input,
2307
- args: ["class"]
2308
- }], name: [{
2309
- type: Input
2310
- }], label: [{
2311
- type: Input
2312
- }], url: [{
2313
- type: Input
2314
- }], entries: [{
2315
- type: Input
2316
- }], required: [{
2317
- type: Input
2318
- }], idKey: [{
2319
- type: Input
2320
- }], displayKey: [{
2321
- type: Input
2322
- }], disabled: [{
2323
- type: Input
2324
- }], sortKey: [{
2325
- type: Input
2326
- }], sortNumeric: [{
2327
- type: Input
2328
- }], filterKey: [{
2329
- type: Input
2330
- }], filter: [{
2331
- type: Input
2332
- }] } });
2333
-
2334
- class MdMultiSelectComponent {
2335
- constructor(dictionaryService, http) {
2336
- this.dictionaryService = dictionaryService;
2337
- this.http = http;
2338
- this.classList = "";
2339
- this.required = false;
2340
- this.idKey = "id";
2341
- this.displayKey = "display";
2342
- this.options = new UntypedFormControl();
2343
- this.onChangeCallback = () => { };
2344
- this.onTouchedCallback = () => { };
2345
- }
2346
- ngOnInit() {
2347
- if (this.url && this.url.indexOf("/") === -1) {
2348
- this.dictionaryService.getDictionaryDropdownEntries(this.url).subscribe((entries) => {
2349
- this.entries = entries;
2350
- });
2351
- }
2352
- else if (this.url) {
2353
- this.http.get(this.url).subscribe((entries) => {
2354
- this.entries = entries;
2355
- });
2356
- }
2357
- if (this.classList.length > 0) {
2358
- this.classList += " material-input";
2359
- }
2360
- else {
2361
- this.classList = "material-input";
2362
- }
2363
- }
2364
- getOptionDisplay(value) {
2365
- for (let entry of this.entries) {
2366
- if (entry[this.idKey] === value) {
2367
- return entry[this.displayKey];
2368
- }
2369
- }
2370
- return undefined;
2371
- }
2372
- remove(value) {
2373
- console.debug(this.options);
2374
- let newValue = [];
2375
- for (let option of this.options.value) {
2376
- if (option !== value) {
2377
- newValue.push(option);
2378
- }
2379
- }
2380
- this.writeValue(newValue);
2381
- }
2382
- get value() {
2383
- return this._value;
2384
- }
2385
- set value(newValue) {
2386
- this._value = newValue;
2387
- this.options.setValue(newValue);
2388
- this.onChangeCallback(newValue);
2389
- }
2390
- onBlur() {
2391
- this.onTouchedCallback();
2392
- }
2393
- writeValue(value) {
2394
- if (value !== this.value) {
2395
- this.value = value;
2396
- this.options.setValue(value);
2397
- }
2398
- }
2399
- registerOnChange(callback) {
2400
- this.onChangeCallback = callback;
2401
- }
2402
- registerOnTouched(callback) {
2403
- this.onTouchedCallback = callback;
2404
- }
2405
- }
2406
- MdMultiSelectComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MdMultiSelectComponent, deps: [{ token: i1$1.DictionaryService }, { token: i2$1.HttpClient }], target: i0.ɵɵFactoryTarget.Component });
2407
- MdMultiSelectComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: MdMultiSelectComponent, selector: "hci-md-multi-select", inputs: { classList: ["class", "classList"], name: "name", label: "label", url: "url", entries: "entries", required: "required", idKey: "idKey", displayKey: "displayKey" }, host: { properties: { "class": "this.classList" } }, providers: [
2408
- {
2409
- provide: NG_VALUE_ACCESSOR,
2410
- useExisting: forwardRef(() => MdMultiSelectComponent),
2411
- multi: true
2412
- }
2413
- ], ngImport: i0, template: `
2414
- <mat-form-field class="flex-grow-1">
2415
- <mat-label>{{label}}</mat-label>
2416
- <mat-select [(value)]="value" [formControl]="options" [required]="required" multiple>
2417
- <mat-select-trigger class="d-flex flex-wrap">
2418
- <div *ngFor="let option of options.value" class="chip">
2419
- {{getOptionDisplay(option)}}
2420
- <div (click)="$event.stopPropagation(); remove(option)" class="chip-remove">
2421
- <i class="fa fa-times-circle fa-xs"></i>
2422
- </div>
2423
- </div>
2424
- </mat-select-trigger>
2425
- <mat-option *ngFor="let row of entries" [value]="row[idKey]">{{ row[displayKey] }}</mat-option>
2426
- </mat-select>
2427
- </mat-form-field>
2428
- `, isInline: true, dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: i3$1.MatLegacyFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i3$1.MatLegacyLabel, selector: "mat-label" }, { kind: "component", type: i6.MatLegacySelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { kind: "directive", type: i6.MatLegacySelectTrigger, selector: "mat-select-trigger" }, { kind: "component", type: i6$1.MatLegacyOption, selector: "mat-option", exportAs: ["matOption"] }] });
2429
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MdMultiSelectComponent, decorators: [{
2430
- type: Component,
2431
- args: [{
2432
- selector: "hci-md-multi-select",
2433
- template: `
2434
- <mat-form-field class="flex-grow-1">
2435
- <mat-label>{{label}}</mat-label>
2436
- <mat-select [(value)]="value" [formControl]="options" [required]="required" multiple>
2437
- <mat-select-trigger class="d-flex flex-wrap">
2438
- <div *ngFor="let option of options.value" class="chip">
2439
- {{getOptionDisplay(option)}}
2440
- <div (click)="$event.stopPropagation(); remove(option)" class="chip-remove">
2441
- <i class="fa fa-times-circle fa-xs"></i>
2442
- </div>
2443
- </div>
2444
- </mat-select-trigger>
2445
- <mat-option *ngFor="let row of entries" [value]="row[idKey]">{{ row[displayKey] }}</mat-option>
2446
- </mat-select>
2447
- </mat-form-field>
2448
- `,
2449
- providers: [
2450
- {
2451
- provide: NG_VALUE_ACCESSOR,
2452
- useExisting: forwardRef(() => MdMultiSelectComponent),
2453
- multi: true
2454
- }
2455
- ]
2456
- }]
2457
- }], ctorParameters: function () { return [{ type: i1$1.DictionaryService }, { type: i2$1.HttpClient }]; }, propDecorators: { classList: [{
2458
- type: HostBinding,
2459
- args: ["class"]
2460
- }, {
2461
- type: Input,
2462
- args: ["class"]
2463
- }], name: [{
2464
- type: Input
2465
- }], label: [{
2466
- type: Input
2467
- }], url: [{
2468
- type: Input
2469
- }], entries: [{
2470
- type: Input
2471
- }], required: [{
2472
- type: Input
2473
- }], idKey: [{
2474
- type: Input
2475
- }], displayKey: [{
2476
- type: Input
2477
- }] } });
2478
-
2479
- class CustomComboBoxComponent {
2480
- set customFieldClasses(value) {
2481
- this._customFieldClasses = value ? value : "";
2482
- }
2483
- get customFieldClasses() {
2484
- return !!this._customFieldClasses ? this._customFieldClasses : "mat-form-field-should-float";
2485
- }
2486
- set customOptionClasses(value) {
2487
- this._customOptionClasses = value ? value : "";
2488
- }
2489
- get customOptionClasses() {
2490
- return !!this._customOptionClasses ? this._customOptionClasses : "";
2491
- }
2492
- constructor(cdr, injector) {
2493
- this.cdr = cdr;
2494
- this.injector = injector;
2495
- this.optionSizePx = 25;
2496
- this.numOptionsToShow = 10;
2497
- this.maxOptionsToShow = 10;
2498
- this.customViewportClass = "";
2499
- this.placeholder = "";
2500
- // Removes the placeholder after a selection is made
2501
- this.temporaryPlaceholder = false;
2502
- this.tooltip = "";
2503
- this.allowNone = true;
2504
- this.selectTextOnOpen = true;
2505
- // tell mat-dialog to pass initial focus to the inner input
2506
- this._cdkFocusInitial = null;
2507
- this.cdkFocusInitial = undefined;
2508
- // on tab, skip the host element and focus the input
2509
- this._tabindex = null;
2510
- this.tabindex = 0;
2511
- this.forceShowNone = false;
2512
- this.options = [];
2513
- this.allowLoader = false;
2514
- this.isOpen = false;
2515
- this.loadedOptions = [];
2516
- this.forceEmitObject = false;
2517
- this.appearance = "";
2518
- // Set to empty to not show errors
2519
- this.defineErrors = { required: "This is a required field" };
2520
- this._showLoader = false;
2521
- this._customFieldClasses = "";
2522
- this._customOptionClasses = "";
2523
- this.outerControl = new UntypedFormControl();
2524
- this.innerControl = new UntypedFormControl(null);
2525
- this.ignoreInnerControlChanges = false;
2526
- this.subs = new Subscription();
2527
- this.noNgControl = false;
2528
- this.viewportVisibleRange = {
2529
- start: 0,
2530
- end: this.numOptionsToShow - 1
2531
- };
2532
- this.clickInProgress = false;
2533
- this.optionSelected = new EventEmitter();
2534
- this.optionChanged = new EventEmitter();
2535
- this.optionsLoaded = new EventEmitter();
2536
- this.onChangeFn = () => { };
2537
- this.onTouchedFn = () => { };
2538
- this.displayFn = (opt) => {
2539
- return opt ? (this.displayField ? opt[this.displayField] : opt) : undefined;
2540
- };
2541
- }
2542
- ngOnInit() {
2543
- this._showLoader = this.allowLoader && (!this.options || this.options.length === 0);
2544
- }
2545
- ngAfterViewInit() {
2546
- let ngControl = this.injector.get(NgControl, null);
2547
- if (ngControl && ngControl.control) {
2548
- this.outerControl = ngControl.control;
2549
- this.innerControl.setValidators(this.outerControl.validator);
2550
- this.innerControl.setAsyncValidators(this.outerControl.asyncValidator);
2551
- this.innerControl.updateValueAndValidity();
2552
- this.cdr.detectChanges();
2553
- }
2554
- else {
2555
- this.noNgControl = true;
2556
- }
2557
- this.subs.add(this.innerControl.valueChanges.pipe(debounceTime(300)).subscribe((_value) => {
2558
- if (this.isOpen && !this.ignoreInnerControlChanges) {
2559
- this.filterOptions();
2560
- }
2561
- else {
2562
- this.ignoreInnerControlChanges = false;
2563
- }
2564
- }));
2565
- // work around for validators not always propagating
2566
- this.subs.add(this.outerControl.statusChanges.subscribe((_event) => {
2567
- this.innerControl.setValidators(this.outerControl.validator);
2568
- this.innerControl.setAsyncValidators(this.outerControl.asyncValidator);
2569
- this.innerControl.updateValueAndValidity();
2570
- this.innerControl.setErrors(this.outerControl.errors);
2571
- if (this.outerControl.touched) {
2572
- this.innerControl.markAsTouched();
2573
- }
2574
- }));
2575
- // this object is used to control the active state when keying up and down
2576
- this.keyManager = this.autoCompleteTrigger.autocomplete._keyManager;
2577
- this.keyManager.withWrap(false);
2578
- this.subs.add(combineLatest([
2579
- this.viewport.renderedRangeStream,
2580
- this.viewport.scrolledIndexChange
2581
- ]).subscribe(([renderedRange, scrolledIndex]) => {
2582
- // Instead of loading the whole item list at once, the virtual scroll viewport buffers
2583
- // a range of entries, only a portion of which are within the visible fold
2584
- this.viewportRenderRange = renderedRange;
2585
- // we have to figure out the visible range ourselves
2586
- let len = Math.min(this.loadedOptions.length + (this.allowNone ? 1 : 0), this.numOptionsToShow - 1);
2587
- this.viewportVisibleRange = {
2588
- start: scrolledIndex,
2589
- end: scrolledIndex + len
2590
- };
2591
- }));
2592
- }
2593
- ngOnChanges(changes) {
2594
- if (changes.options) {
2595
- let optionsChange = changes.options;
2596
- if (!optionsChange.currentValue || optionsChange.currentValue.length < 1) {
2597
- this.options = [];
2598
- if (this.innerControl.value != null) {
2599
- //Reset the innerControl value of the dropdown list to an empty array in case of no results are present to be displayed.
2600
- //This flushes out the stale value from the list if there are no results to be displayed.
2601
- this.innerControl.setValue([]);
2602
- }
2603
- }
2604
- let currentOpts = optionsChange.currentValue;
2605
- if (currentOpts && "length" in currentOpts && currentOpts !== optionsChange.previousValue) {
2606
- this._showLoader = false;
2607
- this.optionsLoaded.emit();
2608
- // If number of options is less than our max, reduce size of overlay
2609
- this.numOptionsToShow = Math.min(currentOpts.length + (this.allowNone ? 1 : 0), this.maxOptionsToShow);
2610
- }
2611
- else {
2612
- this._showLoader = true;
2613
- }
2614
- }
2615
- setTimeout(() => {
2616
- // The autocomplete will automatically pop open once it has options filtered into it,
2617
- // but we don't want it to on initial page load or when tabbing though
2618
- if (this.isOpen) {
2619
- this.filterOptions();
2620
- }
2621
- else {
2622
- this.loadOnlyCurrentValue(this.outerControl.value);
2623
- }
2624
- });
2625
- }
2626
- writeValue(obj) {
2627
- this.loadOnlyCurrentValue(obj);
2628
- }
2629
- registerOnChange(fn) {
2630
- this.onChangeFn = fn;
2631
- }
2632
- registerOnTouched(fn) {
2633
- this.onTouchedFn = fn;
2634
- }
2635
- setDisabledState(isDisabled) {
2636
- if (isDisabled) {
2637
- this.innerControl.disable();
2638
- }
2639
- else {
2640
- this.innerControl.enable();
2641
- }
2642
- }
2643
- getError() {
2644
- for (const error in this.outerControl.errors) {
2645
- if (this.defineErrors && error in this.defineErrors) {
2646
- return this.defineErrors[error];
2647
- }
2648
- }
2649
- }
2650
- loadOnlyCurrentValue(cntrlVal) {
2651
- if (!this.options || this.options.length < 1) {
2652
- return;
2653
- }
2654
- let newValue = null;
2655
- if (cntrlVal !== null && cntrlVal !== undefined) {
2656
- let currentlySelected = this.options.find((opt) => {
2657
- let optValue = this.valueField ? opt[this.valueField] : opt;
2658
- if (this.forceEmitObject) {
2659
- let outerValue = cntrlVal ? (this.valueField ? cntrlVal[this.valueField] : cntrlVal) : null;
2660
- if (optValue === outerValue) {
2661
- return true;
2662
- }
2663
- }
2664
- else {
2665
- return optValue === cntrlVal;
2666
- }
2667
- });
2668
- if (currentlySelected) {
2669
- newValue = currentlySelected;
2670
- }
2671
- }
2672
- // prefer to check id if it has one vs straight against it's object identity
2673
- if (this.innerControl.value && newValue != null && this.valueField) {
2674
- if (this.innerControl.value[this.valueField] !== newValue[this.valueField]) {
2675
- this.ignoreInnerControlChanges = true;
2676
- this.innerControl.setValue(newValue);
2677
- this.optionSelected.emit(newValue[this.valueField]);
2678
- }
2679
- }
2680
- else if (this.innerControl.value !== newValue) {
2681
- this.ignoreInnerControlChanges = true;
2682
- this.innerControl.setValue(newValue);
2683
- let nv = newValue ? ((this.valueField && !this.forceEmitObject) ? newValue[this.valueField] : newValue) : null;
2684
- this.optionSelected.emit(nv);
2685
- }
2686
- }
2687
- filterOptions(showAll = false) {
2688
- this.forceShowNone = showAll;
2689
- this.isOpen = true;
2690
- if (!this.options || this.options.length < 1) {
2691
- return;
2692
- }
2693
- if (showAll || !this.innerControl.value) {
2694
- this.loadedOptions = [...this.options];
2695
- }
2696
- else {
2697
- let searchValue = "";
2698
- if (typeof this.innerControl.value === "string") {
2699
- searchValue = this.innerControl.value.toLowerCase();
2700
- }
2701
- else if (this.displayField) {
2702
- searchValue = this.innerControl.value[this.displayField].toLowerCase();
2703
- }
2704
- this.loadedOptions = this.options.filter((opt) => {
2705
- let optDisplay = (this.displayField ? opt[this.displayField] : opt).toLowerCase();
2706
- return optDisplay.includes(searchValue);
2707
- });
2708
- this.forceShowNone = this.loadedOptions.length === 0;
2709
- }
2710
- this.selectedIndex = this.getOptIndex(this.outerControl.value);
2711
- }
2712
- showLoader() {
2713
- return this.allowLoader && this._showLoader;
2714
- }
2715
- open() {
2716
- if (this.innerControl.disabled) {
2717
- return;
2718
- }
2719
- // The autocomplete will only open when options are loaded
2720
- this.filterOptions(true);
2721
- this.autoCompleteTrigger.openPanel();
2722
- }
2723
- close() {
2724
- this.autoCompleteTrigger.closePanel();
2725
- }
2726
- onOpened() {
2727
- this.forceShowNone = true;
2728
- if (this.isOpen) {
2729
- return;
2730
- }
2731
- this.isOpen = true;
2732
- if (this.selectTextOnOpen) {
2733
- this.inputElement.nativeElement.select(); // Highlights text
2734
- }
2735
- if (this.selectedIndex > 0) {
2736
- // make the selected option also the active option
2737
- this.activeValue = this.getOptVal(this.loadedOptions[this.selectedIndex]);
2738
- setTimeout(() => {
2739
- this.scrollToSelectedOption();
2740
- });
2741
- }
2742
- }
2743
- onClosed() {
2744
- if (!this.isOpen) {
2745
- return;
2746
- }
2747
- this.isOpen = false;
2748
- if (!this.innerControl.value && this.outerControl.value) {
2749
- this.selectOption(null);
2750
- }
2751
- this.loadOnlyCurrentValue(this.outerControl.value);
2752
- // reset the options so the autocomplete won't automatically open on the next tab through
2753
- this.loadedOptions = [];
2754
- }
2755
- startClick() {
2756
- // clicking on certain parts of the mat-field will "flicker" the focus, triggering
2757
- // error validation early. This tracks those internal clicks so they can be ignored
2758
- this.clickInProgress = true;
2759
- }
2760
- endClick() {
2761
- this.clickInProgress = false;
2762
- }
2763
- onClick(event) {
2764
- event.stopPropagation();
2765
- if (!this.isOpen) {
2766
- this.open();
2767
- }
2768
- }
2769
- toggleOpen(event) {
2770
- event.stopPropagation();
2771
- if (this.isOpen) {
2772
- this.close();
2773
- }
2774
- else {
2775
- this.open();
2776
- }
2777
- }
2778
- onKey(event) {
2779
- if (event.key === "Tab" || event.key === "Enter") {
2780
- return;
2781
- }
2782
- else {
2783
- if (!this.isOpen) {
2784
- this.open();
2785
- }
2786
- // There is a bug where the cdk a11y KeyManager implementation is not compatible with
2787
- // the MatAutocompleteTrigger, which causes the Drop-down not scroll with keyboard
2788
- // on long option lists.
2789
- //
2790
- // https://github.com/angular/components/issues/16598
2791
- //
2792
- // This work around takes control of the keyboard and manually scrolls and activates
2793
- // the options
2794
- //
2795
- // References:
2796
- // https://github.com/angular/components/blob/master/src/material/autocomplete/autocomplete-trigger.ts
2797
- // https://github.com/angular/components/blob/master/src/cdk/a11y/key-manager/list-key-manager.ts
2798
- // https://github.com/angular/components/blob/master/src/cdk/a11y/key-manager/activedescendant-key-manager.ts
2799
- if (event.key === "ArrowUp" || event.key === "ArrowDown") {
2800
- event.stopPropagation();
2801
- this.initActiveItem();
2802
- this.shiftActiveItem(event.key);
2803
- this.checkActiveBoundaries();
2804
- }
2805
- }
2806
- }
2807
- // before our keypress binding even triggers, angular has already moved the active selection
2808
- // unsyncing it with our display. this code re-initializes the active option
2809
- initActiveItem() {
2810
- if (this.activeValue === undefined || this.activeValue === null) {
2811
- this.keyManager.setFirstItemActive();
2812
- }
2813
- else {
2814
- let activeIndex = this.getActiveIndex();
2815
- // this does the conversion from an index within all options down to a position within the
2816
- // displayed range, which is all the keymanager is aware of
2817
- let position = activeIndex - this.viewportRenderRange.start;
2818
- this.keyManager.setActiveItem(position);
2819
- }
2820
- }
2821
- shiftActiveItem(key) {
2822
- if (key === "ArrowUp") {
2823
- this.keyManager.setPreviousItemActive();
2824
- }
2825
- else if (key === "ArrowDown") {
2826
- this.keyManager.setNextItemActive();
2827
- }
2828
- if (this.keyManager.activeItem) {
2829
- this.activeValue = this.getOptVal(this.keyManager.activeItem.value);
2830
- }
2831
- }
2832
- // check if the active option index is within the displayed viewport window
2833
- // if not, scroll it into view
2834
- checkActiveBoundaries() {
2835
- let activeIndex = this.getActiveIndex();
2836
- if (activeIndex < this.viewportVisibleRange.start) {
2837
- setTimeout(() => {
2838
- this.viewport.scrollToOffset(activeIndex * this.optionSizePx);
2839
- });
2840
- }
2841
- else if (activeIndex > this.viewportVisibleRange.end) {
2842
- setTimeout(() => {
2843
- this.viewport.scrollToOffset((activeIndex - (this.numOptionsToShow - 1)) * this.optionSizePx);
2844
- });
2845
- }
2846
- }
2847
- getActiveIndex() {
2848
- let activeIndex = 0;
2849
- if (this.activeValue !== undefined && this.activeValue !== null) {
2850
- // if we added a none option the returned index would be off by one
2851
- let valIndex = this.getOptIndex(this.activeValue) + (this.allowNone && (this.forceShowNone || !this.innerControl.value) ? 1 : 0);
2852
- // the index should be within the range of our entire buffer, or just allow it to reset
2853
- if (valIndex >= this.viewportRenderRange.start
2854
- && (!this.viewportRenderRange.end || valIndex <= this.viewportRenderRange.end)) {
2855
- activeIndex = valIndex;
2856
- }
2857
- }
2858
- return activeIndex;
2859
- }
2860
- onFocus() {
2861
- if (!this.isOpen) {
2862
- // Highlights text
2863
- if (this.selectTextOnOpen) {
2864
- this.inputElement.nativeElement.select();
2865
- }
2866
- }
2867
- }
2868
- onFocusOut() {
2869
- // mark control touched and trigger error validation
2870
- if (!this.clickInProgress) {
2871
- this.close();
2872
- this.onTouchedFn();
2873
- }
2874
- }
2875
- selectOption(opt) {
2876
- let newVal = this.getOptVal(opt, this.forceEmitObject);
2877
- if (this.noNgControl) {
2878
- this.outerControl.setValue(newVal);
2879
- }
2880
- this.onChangeFn(newVal);
2881
- this.optionSelected.emit(newVal);
2882
- this.optionChanged.emit(newVal);
2883
- }
2884
- scrollToSelectedOption() {
2885
- // scroll to the currently selected option when we open the dropdown
2886
- if (this.selectedIndex > 0) {
2887
- let offsetIndex = this.selectedIndex + (this.allowNone ? 1 : 0); // adjust for None entry
2888
- offsetIndex -= (this.numOptionsToShow / 2) - 1; // calculate middle of viewport
2889
- this.viewport.scrollToOffset(offsetIndex * this.optionSizePx);
2890
- }
2891
- }
2892
- getOptVal(opt, forceObject = false) {
2893
- if (this.valueField && !forceObject) {
2894
- if (opt !== null && opt !== undefined && typeof opt === "object" && this.valueField in opt) {
2895
- return opt[this.valueField];
2896
- }
2897
- else {
2898
- return undefined;
2899
- }
2900
- }
2901
- return opt;
2902
- }
2903
- getOptIndex(optValue) {
2904
- // find the index for the currently selected option
2905
- if (optValue !== null && optValue !== undefined) {
2906
- return this.loadedOptions.findIndex((option) => {
2907
- return this.getOptVal(option) === optValue;
2908
- });
2909
- }
2910
- return undefined;
2911
- }
2912
- ngOnDestroy() {
2913
- this.subs.unsubscribe();
2914
- }
2915
- }
2916
- CustomComboBoxComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CustomComboBoxComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Component });
2917
- CustomComboBoxComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: CustomComboBoxComponent, selector: "hci-combobox", inputs: { maxOptionsToShow: "maxOptionsToShow", customViewportClass: "customViewportClass", customFieldClasses: "customFieldClasses", customOptionClasses: "customOptionClasses", label: "label", placeholder: "placeholder", temporaryPlaceholder: "temporaryPlaceholder", tooltip: "tooltip", allowNone: "allowNone", selectTextOnOpen: "selectTextOnOpen", cdkFocusInitial: "cdkFocusInitial", tabindex: "tabindex", options: "options", allowLoader: "allowLoader", valueField: "valueField", forceEmitObject: "forceEmitObject", displayField: "displayField", appearance: "appearance", floatLabel: "floatLabel", defineErrors: "defineErrors" }, outputs: { optionSelected: "optionSelected", optionChanged: "optionChanged", optionsLoaded: "optionsLoaded" }, host: { properties: { "attr.cdkFocusInitial": "this._cdkFocusInitial", "attr.tabindex": "this._tabindex" }, classAttribute: "hci-combobox-container" }, providers: [{
2918
- provide: NG_VALUE_ACCESSOR,
2919
- useExisting: forwardRef(() => CustomComboBoxComponent),
2920
- multi: true,
2921
- }], viewQueries: [{ propertyName: "viewport", first: true, predicate: ["viewport"], descendants: true, static: true }, { propertyName: "inputElement", first: true, predicate: ["input"], descendants: true, static: true }, { propertyName: "autoCompleteTrigger", first: true, predicate: ["input"], descendants: true, read: MatLegacyAutocompleteTrigger }], usesOnChanges: true, ngImport: i0, template: `
2922
- <mat-form-field (click)="onClick($event)"
2923
- (mousedown)="startClick()"
2924
- (mouseup)="endClick()"
2925
- [appearance]="appearance"
2926
- [floatLabel]="floatLabel"
2927
- [matTooltip]="this.tooltip"
2928
- [ngClass]="customFieldClasses"
2929
- >
2930
- <mat-label *ngIf="label !== undefined">{{ label }}</mat-label>
2931
- <mat-label *ngIf="label === undefined">
2932
- {{ temporaryPlaceholder ? (innerControl.value ? '' : placeholder) : placeholder }}
2933
- </mat-label>
2934
- <input #input
2935
- matInput
2936
- name="customComboBoxFilter"
2937
- [placeholder]="temporaryPlaceholder ? (innerControl.value ? '' : placeholder) : placeholder"
2938
- [matAutocomplete]="auto"
2939
- autocomplete="off"
2940
- [formControl]="innerControl"
2941
- [attr.cdkFocusInitial]="cdkFocusInitial === undefined ? null : cdkFocusInitial"
2942
- [tabindex]="tabindex"
2943
- (keydown)="onKey($event)"
2944
- (focus)="onFocus()"
2945
- (focusout)="onFocusOut()"
2946
- >
2947
- <div matSuffix
2948
- class="hci-combobox-arrow-wrapper"
2949
- (click) = "toggleOpen($event)"
2950
- (mousedown)="startClick()"
2951
- (mouseup)="endClick()"
2952
- >
2953
- <div class="hci-combobox-arrow"></div>
2954
- </div>
2955
- <mat-spinner matSuffix *ngIf="showLoader()" [diameter]="30" style="float: right; margin-left: 8px"></mat-spinner>
2956
- <mat-autocomplete #auto="matAutocomplete"
2957
- autoActiveFirstOption
2958
- (optionSelected)="this.selectOption($event.option.value)"
2959
- (opened)="this.onOpened()"
2960
- (closed)="this.onClosed()"
2961
- [displayWith]="this.displayFn">
2962
- <cdk-virtual-scroll-viewport #viewport
2963
- [style.display]="isOpen ? null : 'none'"
2964
- class="hci-combobox-viewport"
2965
- [ngClass]= "customViewportClass"
2966
- [itemSize]="optionSizePx"
2967
- [style.height.px]="numOptionsToShow * optionSizePx"
2968
- [minBufferPx]="numOptionsToShow * optionSizePx * 2"
2969
- [maxBufferPx]="numOptionsToShow * optionSizePx * 3"
2970
- (mousedown)="startClick()"
2971
- (mouseup)="endClick()"
2972
- >
2973
- <mat-option *ngIf="allowNone && isOpen && (this.forceShowNone || !this.innerControl.value)"
2974
- [ngClass]="customOptionClasses"
2975
- [style.height.px]="optionSizePx"
2976
- >
2977
- None
2978
- </mat-option>
2979
- <mat-option *cdkVirtualFor="let opt of this.loadedOptions"
2980
- [value]="opt"
2981
- [ngClass]="customOptionClasses"
2982
- [class.hci-combobox-selected]="(valueField ? opt[valueField] : opt) === outerControl.value"
2983
- [class.mat-selected]="(valueField ? opt[valueField] : opt) === outerControl.value"
2984
- [style.height.px]="optionSizePx"
2985
- >
2986
- {{ displayField ? opt[displayField] : opt }}
2987
- </mat-option>
2988
- </cdk-virtual-scroll-viewport>
2989
- </mat-autocomplete>
2990
- <mat-error>
2991
- {{ getError() }}
2992
- </mat-error>
2993
- <ng-content></ng-content>
2994
- </mat-form-field>
2995
- `, isInline: true, styles: [".hci-combobox-container{display:inline-block}.hci-combobox-arrow{width:0;height:0;border-left:5px solid transparent;border-right:5px solid transparent;border-top:5px solid;margin:0 4px;color:#0000008a}.hci-combobox-arrow-wrapper{display:table-cell;vertical-align:middle}.hci-combobox-viewport mat-option{display:flex;align-items:center;padding:0 .2rem}.hci-combobox-viewport mat-option .mat-option-text{white-space:nowrap}.hci-combobox-viewport .hci-combobox-selected{background-color:#ddd}.hci-combobox-viewport .mat-active{background-color:#f3f3f3}.hci-combobox-viewport{overflow-anchor:none}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i3$1.MatLegacyError, selector: "mat-error", inputs: ["id"] }, { kind: "component", type: i3$1.MatLegacyFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i3$1.MatLegacyLabel, selector: "mat-label" }, { kind: "directive", type: i3$1.MatLegacySuffix, selector: "[matSuffix]" }, { kind: "component", type: i6$1.MatLegacyOption, selector: "mat-option", exportAs: ["matOption"] }, { kind: "directive", type: i5.CdkFixedSizeVirtualScroll, selector: "cdk-virtual-scroll-viewport[itemSize]", inputs: ["itemSize", "minBufferPx", "maxBufferPx"] }, { kind: "directive", type: i5.CdkVirtualForOf, selector: "[cdkVirtualFor][cdkVirtualForOf]", inputs: ["cdkVirtualForOf", "cdkVirtualForTrackBy", "cdkVirtualForTemplate", "cdkVirtualForTemplateCacheSize"] }, { kind: "component", type: i5.CdkVirtualScrollViewport, selector: "cdk-virtual-scroll-viewport", inputs: ["orientation", "appendOnly"], outputs: ["scrolledIndexChange"] }, { kind: "component", type: i6$2.MatLegacyAutocomplete, selector: "mat-autocomplete", inputs: ["disableRipple"], exportAs: ["matAutocomplete"] }, { kind: "directive", type: i6$2.MatLegacyAutocompleteTrigger, selector: "input[matAutocomplete], textarea[matAutocomplete]", exportAs: ["matAutocompleteTrigger"] }, { kind: "directive", type: i7.MatLegacyInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", exportAs: ["matInput"] }, { kind: "directive", type: i8.MatLegacyTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }, { kind: "component", type: i9.MatLegacyProgressSpinner, selector: "mat-progress-spinner, mat-spinner", inputs: ["color", "diameter", "strokeWidth", "mode", "value"], exportAs: ["matProgressSpinner"] }], encapsulation: i0.ViewEncapsulation.None });
2996
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CustomComboBoxComponent, decorators: [{
2997
- type: Component,
2998
- args: [{ selector: "hci-combobox", template: `
2999
- <mat-form-field (click)="onClick($event)"
3000
- (mousedown)="startClick()"
3001
- (mouseup)="endClick()"
3002
- [appearance]="appearance"
3003
- [floatLabel]="floatLabel"
3004
- [matTooltip]="this.tooltip"
3005
- [ngClass]="customFieldClasses"
3006
- >
3007
- <mat-label *ngIf="label !== undefined">{{ label }}</mat-label>
3008
- <mat-label *ngIf="label === undefined">
3009
- {{ temporaryPlaceholder ? (innerControl.value ? '' : placeholder) : placeholder }}
3010
- </mat-label>
3011
- <input #input
3012
- matInput
3013
- name="customComboBoxFilter"
3014
- [placeholder]="temporaryPlaceholder ? (innerControl.value ? '' : placeholder) : placeholder"
3015
- [matAutocomplete]="auto"
3016
- autocomplete="off"
3017
- [formControl]="innerControl"
3018
- [attr.cdkFocusInitial]="cdkFocusInitial === undefined ? null : cdkFocusInitial"
3019
- [tabindex]="tabindex"
3020
- (keydown)="onKey($event)"
3021
- (focus)="onFocus()"
3022
- (focusout)="onFocusOut()"
3023
- >
3024
- <div matSuffix
3025
- class="hci-combobox-arrow-wrapper"
3026
- (click) = "toggleOpen($event)"
3027
- (mousedown)="startClick()"
3028
- (mouseup)="endClick()"
3029
- >
3030
- <div class="hci-combobox-arrow"></div>
3031
- </div>
3032
- <mat-spinner matSuffix *ngIf="showLoader()" [diameter]="30" style="float: right; margin-left: 8px"></mat-spinner>
3033
- <mat-autocomplete #auto="matAutocomplete"
3034
- autoActiveFirstOption
3035
- (optionSelected)="this.selectOption($event.option.value)"
3036
- (opened)="this.onOpened()"
3037
- (closed)="this.onClosed()"
3038
- [displayWith]="this.displayFn">
3039
- <cdk-virtual-scroll-viewport #viewport
3040
- [style.display]="isOpen ? null : 'none'"
3041
- class="hci-combobox-viewport"
3042
- [ngClass]= "customViewportClass"
3043
- [itemSize]="optionSizePx"
3044
- [style.height.px]="numOptionsToShow * optionSizePx"
3045
- [minBufferPx]="numOptionsToShow * optionSizePx * 2"
3046
- [maxBufferPx]="numOptionsToShow * optionSizePx * 3"
3047
- (mousedown)="startClick()"
3048
- (mouseup)="endClick()"
3049
- >
3050
- <mat-option *ngIf="allowNone && isOpen && (this.forceShowNone || !this.innerControl.value)"
3051
- [ngClass]="customOptionClasses"
3052
- [style.height.px]="optionSizePx"
3053
- >
3054
- None
3055
- </mat-option>
3056
- <mat-option *cdkVirtualFor="let opt of this.loadedOptions"
3057
- [value]="opt"
3058
- [ngClass]="customOptionClasses"
3059
- [class.hci-combobox-selected]="(valueField ? opt[valueField] : opt) === outerControl.value"
3060
- [class.mat-selected]="(valueField ? opt[valueField] : opt) === outerControl.value"
3061
- [style.height.px]="optionSizePx"
3062
- >
3063
- {{ displayField ? opt[displayField] : opt }}
3064
- </mat-option>
3065
- </cdk-virtual-scroll-viewport>
3066
- </mat-autocomplete>
3067
- <mat-error>
3068
- {{ getError() }}
3069
- </mat-error>
3070
- <ng-content></ng-content>
3071
- </mat-form-field>
3072
- `, providers: [{
3073
- provide: NG_VALUE_ACCESSOR,
3074
- useExisting: forwardRef(() => CustomComboBoxComponent),
3075
- multi: true,
3076
- }], host: {
3077
- class: "hci-combobox-container"
3078
- }, encapsulation: ViewEncapsulation.None, styles: [".hci-combobox-container{display:inline-block}.hci-combobox-arrow{width:0;height:0;border-left:5px solid transparent;border-right:5px solid transparent;border-top:5px solid;margin:0 4px;color:#0000008a}.hci-combobox-arrow-wrapper{display:table-cell;vertical-align:middle}.hci-combobox-viewport mat-option{display:flex;align-items:center;padding:0 .2rem}.hci-combobox-viewport mat-option .mat-option-text{white-space:nowrap}.hci-combobox-viewport .hci-combobox-selected{background-color:#ddd}.hci-combobox-viewport .mat-active{background-color:#f3f3f3}.hci-combobox-viewport{overflow-anchor:none}\n"] }]
3079
- }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i0.Injector }]; }, propDecorators: { maxOptionsToShow: [{
3080
- type: Input
3081
- }], customViewportClass: [{
3082
- type: Input
3083
- }], customFieldClasses: [{
3084
- type: Input
3085
- }], customOptionClasses: [{
3086
- type: Input
3087
- }], label: [{
3088
- type: Input
3089
- }], placeholder: [{
3090
- type: Input
3091
- }], temporaryPlaceholder: [{
3092
- type: Input
3093
- }], tooltip: [{
3094
- type: Input
3095
- }], allowNone: [{
3096
- type: Input
3097
- }], selectTextOnOpen: [{
3098
- type: Input
3099
- }], _cdkFocusInitial: [{
3100
- type: HostBinding,
3101
- args: ["attr.cdkFocusInitial"]
3102
- }], cdkFocusInitial: [{
3103
- type: Input
3104
- }], _tabindex: [{
3105
- type: HostBinding,
3106
- args: ["attr.tabindex"]
3107
- }], tabindex: [{
3108
- type: Input
3109
- }], options: [{
3110
- type: Input
3111
- }], allowLoader: [{
3112
- type: Input
3113
- }], valueField: [{
3114
- type: Input
3115
- }], forceEmitObject: [{
3116
- type: Input
3117
- }], displayField: [{
3118
- type: Input
3119
- }], appearance: [{
3120
- type: Input
3121
- }], floatLabel: [{
3122
- type: Input
3123
- }], defineErrors: [{
3124
- type: Input
3125
- }], optionSelected: [{
3126
- type: Output
3127
- }], optionChanged: [{
3128
- type: Output
3129
- }], optionsLoaded: [{
3130
- type: Output
3131
- }], viewport: [{
3132
- type: ViewChild,
3133
- args: ["viewport", { static: true }]
3134
- }], inputElement: [{
3135
- type: ViewChild,
3136
- args: ["input", { static: true }]
3137
- }], autoCompleteTrigger: [{
3138
- type: ViewChild,
3139
- args: ["input", { read: MatLegacyAutocompleteTrigger, static: false }]
3140
- }] } });
3141
-
3142
- class CustomMultiComboBoxComponent {
3143
- constructor(injector) {
3144
- this.injector = injector;
3145
- this.placeholder = "";
3146
- this.temporaryPlaceholder = false;
3147
- this.tooltip = "";
3148
- this.options = [];
3149
- this.includeLoadingOption = true;
3150
- this.loadedOptions = [];
3151
- this.isSelectOpen = false;
3152
- this.forceEmitObject = false;
3153
- this.appearance = "";
3154
- this.outerControl = new UntypedFormControl([]);
3155
- this.innerControl = new UntypedFormControl("");
3156
- this.ignoreInnerControlChanges = false;
3157
- this.noNgControl = false;
3158
- this.selectedListItems = [];
3159
- this.selectionChanged = new EventEmitter();
3160
- this.onChangeFn = () => { };
3161
- this.onTouchedFn = () => { };
3162
- }
3163
- ngAfterViewInit() {
3164
- let ngControl = this.injector.get(NgControl, null);
3165
- if (ngControl && ngControl.control) {
3166
- this.outerControl = ngControl.control;
3167
- setTimeout(() => {
3168
- this.loadOnlyCurrentValue();
3169
- });
3170
- }
3171
- else {
3172
- this.noNgControl = true;
3173
- }
3174
- this.innerControlSubscription = this.innerControl.valueChanges.pipe(debounceTime(300)).subscribe(() => {
3175
- if (!this.ignoreInnerControlChanges) {
3176
- this.filterOptions();
3177
- }
3178
- else {
3179
- this.ignoreInnerControlChanges = false;
3180
- }
3181
- });
3182
- }
3183
- ngOnChanges(changes) {
3184
- if (changes.options) {
3185
- let optionsChange = changes.options;
3186
- if (!optionsChange.currentValue) {
3187
- this.options = [];
3188
- }
3189
- }
3190
- this.loadOnlyCurrentValue();
3191
- }
3192
- writeValue(obj) {
3193
- this.loadOnlyCurrentValue();
3194
- }
3195
- registerOnChange(fn) {
3196
- this.onChangeFn = fn;
3197
- }
3198
- registerOnTouched(fn) {
3199
- this.onTouchedFn = fn;
3200
- }
3201
- setDisabledState(isDisabled) {
3202
- if (isDisabled) {
3203
- this.innerControl.disable();
3204
- this.selectElement.disabled = true;
3205
- }
3206
- else {
3207
- this.innerControl.enable();
3208
- this.selectElement.disabled = false;
3209
- }
3210
- }
3211
- onInputFocus() {
3212
- this.selectElement.open();
3213
- }
3214
- loadOnlyCurrentValue() {
3215
- this.loadedOptions = [];
3216
- if (this.outerControl.value && this.outerControl.value.length) {
3217
- for (let opt of this.options) {
3218
- if (this.isOptInOuterValue(opt)) {
3219
- this.loadedOptions.push(opt);
3220
- }
3221
- }
3222
- }
3223
- this.selectedListItems = this.loadedOptions;
3224
- let currentValueLabel = "";
3225
- for (let opt of this.loadedOptions) {
3226
- if (currentValueLabel) {
3227
- currentValueLabel += ", ";
3228
- }
3229
- currentValueLabel += this.displayField ? opt[this.displayField] : opt;
3230
- }
3231
- this.ignoreInnerControlChanges = true;
3232
- this.innerControl.setValue(currentValueLabel);
3233
- }
3234
- filterOptions(showAll = false) {
3235
- if (showAll || !this.innerControl.value) {
3236
- this.loadedOptions = this.options;
3237
- }
3238
- else {
3239
- let searchValue = this.innerControl.value.toLowerCase();
3240
- this.loadedOptions = this.options.filter((opt) => {
3241
- let optDisplay = (this.displayField ? opt[this.displayField] : opt).toLowerCase();
3242
- return optDisplay.includes(searchValue) || this.isOptInOuterValue(opt);
3243
- });
3244
- }
3245
- }
3246
- isOptInOuterValue(opt) {
3247
- let optValue = this.valueField ? opt[this.valueField] : opt;
3248
- if (this.forceEmitObject) {
3249
- for (let outerValOpt of this.outerControl.value) {
3250
- let outerOptValue = this.valueField ? outerValOpt[this.valueField] : outerValOpt;
3251
- if (optValue === outerOptValue) {
3252
- return true;
3253
- }
3254
- }
3255
- }
3256
- else {
3257
- return this.outerControl.value.includes(optValue);
3258
- }
3259
- }
3260
- onOpenedChange(opened) {
3261
- this.isSelectOpen = opened;
3262
- if (opened) {
3263
- this.onTouchedFn();
3264
- this.inputElement.nativeElement.focus();
3265
- this.ignoreInnerControlChanges = true;
3266
- this.innerControl.setValue("");
3267
- setTimeout(() => {
3268
- this.filterOptions(true);
3269
- this.includeLoadingOption = false;
3270
- });
3271
- }
3272
- else {
3273
- setTimeout(() => {
3274
- this.loadOnlyCurrentValue();
3275
- this.includeLoadingOption = true;
3276
- });
3277
- }
3278
- }
3279
- selectOptions(options) {
3280
- let newVal = [];
3281
- for (let opt of options) {
3282
- if (opt) {
3283
- newVal.push((this.valueField && !this.forceEmitObject) ? opt[this.valueField] : opt);
3284
- }
3285
- }
3286
- if (this.noNgControl) {
3287
- this.outerControl.setValue(newVal);
3288
- }
3289
- this.onChangeFn(newVal);
3290
- this.selectionChanged.emit(newVal);
3291
- if (this.isSelectOpen) {
3292
- this.inputElement.nativeElement.focus();
3293
- }
3294
- }
3295
- compareByID(itemOne, itemTwo) {
3296
- if (!itemOne) {
3297
- return false;
3298
- }
3299
- else if (!itemTwo) {
3300
- return false;
3301
- }
3302
- else {
3303
- if (this.valueField) {
3304
- return itemOne[this.valueField] && itemTwo[this.valueField] && itemOne[this.valueField] === itemTwo[this.valueField];
3305
- }
3306
- else {
3307
- return itemOne === itemTwo;
3308
- }
3309
- }
3310
- }
3311
- ngOnDestroy() {
3312
- if (this.innerControlSubscription) {
3313
- this.innerControlSubscription.unsubscribe();
3314
- }
3315
- }
3316
- }
3317
- CustomMultiComboBoxComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CustomMultiComboBoxComponent, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Component });
3318
- CustomMultiComboBoxComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: CustomMultiComboBoxComponent, selector: "hci-multi-combobox", inputs: { label: "label", placeholder: "placeholder", temporaryPlaceholder: "temporaryPlaceholder", tooltip: "tooltip", options: "options", valueField: "valueField", forceEmitObject: "forceEmitObject", displayField: "displayField", appearance: "appearance", initialFocus: "initialFocus", floatLabel: "floatLabel" }, outputs: { selectionChanged: "selectionChanged" }, providers: [{
3319
- provide: NG_VALUE_ACCESSOR,
3320
- useExisting: CustomMultiComboBoxComponent,
3321
- multi: true,
3322
- }], viewQueries: [{ propertyName: "inputElement", first: true, predicate: ["input"], descendants: true }, { propertyName: "selectElement", first: true, predicate: ["select"], descendants: true }], usesOnChanges: true, ngImport: i0, template: `
3323
- <div class="combobox-multi-container d-flex font-sm">
3324
- <mat-form-field [appearance]="appearance" [matTooltip]="this.tooltip" [floatLabel]="floatLabel">
3325
- <mat-label *ngIf="label !== undefined">{{ label }}</mat-label>
3326
- <mat-label *ngIf="label === undefined">
3327
- {{ temporaryPlaceholder ? (outerControl.value && outerControl.value.length ? '' : placeholder) : placeholder }}
3328
- </mat-label>
3329
- <input #input matInput name="customMultiComboBoxFilter" class="ellipsis"
3330
- (focus)="this.onInputFocus()"
3331
- autocomplete="off"
3332
- [placeholder]="temporaryPlaceholder ? (outerControl.value && outerControl.value.length ? '' : placeholder) : placeholder"
3333
- [formControl]="this.innerControl"
3334
- [attr.cdkFocusInitial]="initialFocus === undefined ? null : initialFocus">
3335
- <div matSuffix class="hci-combobox-arrow-wrapper">
3336
- <mat-select
3337
- #select [multiple]="true"
3338
- (selectionChange)="this.selectOptions($event.value)"
3339
- (openedChange)="this.onOpenedChange($event)"
3340
- [(ngModel)]="selectedListItems"
3341
- [compareWith]="compareByID">
3342
- <mat-option *ngFor="let opt of this.loadedOptions" [value]="opt">
3343
- {{this.displayField ? opt[this.displayField] : opt}}
3344
- </mat-option>
3345
- <mat-option *ngIf="this.includeLoadingOption">Loading...</mat-option>
3346
- <mat-option *ngIf="!this.includeLoadingOption && !this.options.length">None</mat-option>
3347
- </mat-select>
3348
- </div>
3349
- </mat-form-field>
3350
- </div>
3351
- `, isInline: true, styles: [""], dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: i3$1.MatLegacyFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i3$1.MatLegacyLabel, selector: "mat-label" }, { kind: "directive", type: i3$1.MatLegacySuffix, selector: "[matSuffix]" }, { kind: "component", type: i6.MatLegacySelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { kind: "component", type: i6$1.MatLegacyOption, selector: "mat-option", exportAs: ["matOption"] }, { kind: "directive", type: i7.MatLegacyInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", exportAs: ["matInput"] }, { kind: "directive", type: i8.MatLegacyTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }] });
3352
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CustomMultiComboBoxComponent, decorators: [{
3353
- type: Component,
3354
- args: [{ selector: "hci-multi-combobox", template: `
3355
- <div class="combobox-multi-container d-flex font-sm">
3356
- <mat-form-field [appearance]="appearance" [matTooltip]="this.tooltip" [floatLabel]="floatLabel">
3357
- <mat-label *ngIf="label !== undefined">{{ label }}</mat-label>
3358
- <mat-label *ngIf="label === undefined">
3359
- {{ temporaryPlaceholder ? (outerControl.value && outerControl.value.length ? '' : placeholder) : placeholder }}
3360
- </mat-label>
3361
- <input #input matInput name="customMultiComboBoxFilter" class="ellipsis"
3362
- (focus)="this.onInputFocus()"
3363
- autocomplete="off"
3364
- [placeholder]="temporaryPlaceholder ? (outerControl.value && outerControl.value.length ? '' : placeholder) : placeholder"
3365
- [formControl]="this.innerControl"
3366
- [attr.cdkFocusInitial]="initialFocus === undefined ? null : initialFocus">
3367
- <div matSuffix class="hci-combobox-arrow-wrapper">
3368
- <mat-select
3369
- #select [multiple]="true"
3370
- (selectionChange)="this.selectOptions($event.value)"
3371
- (openedChange)="this.onOpenedChange($event)"
3372
- [(ngModel)]="selectedListItems"
3373
- [compareWith]="compareByID">
3374
- <mat-option *ngFor="let opt of this.loadedOptions" [value]="opt">
3375
- {{this.displayField ? opt[this.displayField] : opt}}
3376
- </mat-option>
3377
- <mat-option *ngIf="this.includeLoadingOption">Loading...</mat-option>
3378
- <mat-option *ngIf="!this.includeLoadingOption && !this.options.length">None</mat-option>
3379
- </mat-select>
3380
- </div>
3381
- </mat-form-field>
3382
- </div>
3383
- `, providers: [{
3384
- provide: NG_VALUE_ACCESSOR,
3385
- useExisting: CustomMultiComboBoxComponent,
3386
- multi: true,
3387
- }] }]
3388
- }], ctorParameters: function () { return [{ type: i0.Injector }]; }, propDecorators: { inputElement: [{
3389
- type: ViewChild,
3390
- args: ["input", { static: false }]
3391
- }], selectElement: [{
3392
- type: ViewChild,
3393
- args: ["select", { static: false }]
3394
- }], label: [{
3395
- type: Input
3396
- }], placeholder: [{
3397
- type: Input
3398
- }], temporaryPlaceholder: [{
3399
- type: Input
3400
- }], tooltip: [{
3401
- type: Input
3402
- }], options: [{
3403
- type: Input
3404
- }], valueField: [{
3405
- type: Input
3406
- }], forceEmitObject: [{
3407
- type: Input
3408
- }], displayField: [{
3409
- type: Input
3410
- }], appearance: [{
3411
- type: Input
3412
- }], initialFocus: [{
3413
- type: Input
3414
- }], floatLabel: [{
3415
- type: Input
3416
- }], selectionChanged: [{
3417
- type: Output
3418
- }] } });
3419
-
3420
- class SelectModule {
3421
- }
3422
- SelectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: SelectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
3423
- SelectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.10", ngImport: i0, type: SelectModule, declarations: [MdSelectComponent,
3424
- MdMultiSelectComponent,
3425
- NativeSelectComponent,
3426
- CustomComboBoxComponent,
3427
- CustomMultiComboBoxComponent], imports: [CommonModule,
3428
- FormsModule,
3429
- ReactiveFormsModule,
3430
- MatLegacySelectModule,
3431
- ScrollingModule,
3432
- MatLegacyAutocompleteModule,
3433
- MatLegacyInputModule,
3434
- MatLegacyTooltipModule,
3435
- MatIconModule,
3436
- MatLegacyProgressSpinnerModule,
3437
- DictionaryServiceModule], exports: [MdSelectComponent,
3438
- MdMultiSelectComponent,
3439
- NativeSelectComponent,
3440
- CustomComboBoxComponent,
3441
- CustomMultiComboBoxComponent] });
3442
- SelectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: SelectModule, imports: [CommonModule,
3443
- FormsModule,
3444
- ReactiveFormsModule,
3445
- MatLegacySelectModule,
3446
- ScrollingModule,
3447
- MatLegacyAutocompleteModule,
3448
- MatLegacyInputModule,
3449
- MatLegacyTooltipModule,
3450
- MatIconModule,
3451
- MatLegacyProgressSpinnerModule,
3452
- DictionaryServiceModule] });
3453
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: SelectModule, decorators: [{
3454
- type: NgModule,
3455
- args: [{
3456
- imports: [
3457
- CommonModule,
3458
- FormsModule,
3459
- ReactiveFormsModule,
3460
- MatLegacySelectModule,
3461
- ScrollingModule,
3462
- MatLegacyAutocompleteModule,
3463
- MatLegacyInputModule,
3464
- MatLegacyTooltipModule,
3465
- MatIconModule,
3466
- MatLegacyProgressSpinnerModule,
3467
- DictionaryServiceModule
3468
- ],
3469
- declarations: [
3470
- MdSelectComponent,
3471
- MdMultiSelectComponent,
3472
- NativeSelectComponent,
3473
- CustomComboBoxComponent,
3474
- CustomMultiComboBoxComponent
3475
- ],
3476
- exports: [
3477
- MdSelectComponent,
3478
- MdMultiSelectComponent,
3479
- NativeSelectComponent,
3480
- CustomComboBoxComponent,
3481
- CustomMultiComboBoxComponent
3482
- ]
3483
- }]
3484
- }] });
3485
-
3486
- /**
3487
- * I'm just screwing around with some ideas here, beware of actually using any of this code.
3488
- */
3489
- class SearchComponent {
3490
- constructor(changeDetectorRef) {
3491
- this.changeDetectorRef = changeDetectorRef;
3492
- this.CHILD_NODE = "children";
3493
- this.dataFiltered = new EventEmitter();
3494
- }
3495
- ngAfterViewInit() {
3496
- if (isDevMode()) {
3497
- console.debug("SearchComponent.ngAfterViewInit");
3498
- }
3499
- setTimeout(() => {
3500
- if (this.anyComponent && this.data && this.input) {
3501
- let changes = {};
3502
- changes[this.input] = new SimpleChange([], this.data, false);
3503
- this.anyComponent.ngOnChanges(changes);
3504
- }
3505
- });
3506
- }
3507
- ngOnChanges(changes) {
3508
- if (isDevMode()) {
3509
- console.debug("SearchComponent.ngOnChanges");
3510
- }
3511
- if (changes.data && this.isArray === undefined) {
3512
- for (let item of this.data) {
3513
- if (item[this.CHILD_NODE]) {
3514
- this.isArray = false;
3515
- return;
3516
- }
3517
- }
3518
- }
3519
- }
3520
- /**
3521
- * A tree or a grid? Who knows.
3522
- *
3523
- * @param {KeyboardEvent} event
3524
- */
3525
- doSearch(searchBox) {
3526
- if (isDevMode()) {
3527
- console.debug("doSearch");
3528
- }
3529
- this.search = searchBox;
3530
- let filteredData = null;
3531
- if (this.isArray) {
3532
- console.debug("array option");
3533
- filteredData = this.filterArray(this.data);
3534
- }
3535
- else if (this.isIncludeChildren) {
3536
- console.debug("child option");
3537
- filteredData = this.filterTreeIncludeChildren(JSON.parse(JSON.stringify(this.data)));
3538
- }
3539
- else {
3540
- console.debug("not child option");
3541
- filteredData = this.filterTree(JSON.parse(JSON.stringify(this.data)));
3542
- }
3543
- // This is what triggers the @Output
3544
- this.dataFiltered.emit(filteredData);
3545
- if (this.anyComponent) {
3546
- let changes = {};
3547
- changes[this.input] = new SimpleChange(this.anyComponent[this.input], filteredData, false);
3548
- this.anyComponent.ngOnChanges(changes);
3549
- }
3550
- this.changeDetectorRef.detectChanges();
3551
- }
3552
- filterArray(data) {
3553
- if (isDevMode()) {
3554
- console.debug("filterArray");
3555
- }
3556
- return data.filter((o) => {
3557
- return (o["name"].indexOf(this.search) >= 0);
3558
- });
3559
- }
3560
- /**
3561
- * Recursive tree search. It will include parent nodes if a leaf node matches the search string.
3562
- *
3563
- * @param {any[]} data
3564
- * @returns {any[]}
3565
- */
3566
- filterTree(data) {
3567
- if (isDevMode()) {
3568
- console.debug("filterTreeOrigional");
3569
- }
3570
- let filteredData = [];
3571
- for (let child of data) {
3572
- let pushed = false;
3573
- if (child["children"]) {
3574
- child["children"] = this.filterTree(child["children"]);
3575
- if (child["children"].length > 0) {
3576
- pushed = true;
3577
- filteredData.push(child);
3578
- }
3579
- }
3580
- if (!pushed && child["name"].indexOf(this.search) >= 0) {
3581
- filteredData.push(child);
3582
- }
3583
- }
3584
- return filteredData;
3585
- }
3586
- /**
3587
- * Recursive tree search. It will include children nodes if a parent node matches the search string.
3588
- *
3589
- * @param {any[]} data
3590
- * @returns {any[]}
3591
- */
3592
- filterTreeIncludeChildren(data) {
3593
- if (isDevMode()) {
3594
- console.debug("filterTreeIncludeChildren");
3595
- }
3596
- let filteredData = [];
3597
- for (let child of data) {
3598
- if (child["name"].indexOf(this.search) >= 0) {
3599
- filteredData.push(child);
3600
- }
3601
- else {
3602
- let pushed = false;
3603
- if (child["children"]) {
3604
- child["children"] = this.filterTreeIncludeChildren(child["children"]);
3605
- if (child["children"].length > 0) {
3606
- pushed = true;
3607
- filteredData.push(child);
3608
- }
3609
- }
3610
- if (!pushed && child["name"].indexOf(this.search) >= 0) {
3611
- filteredData.push(child);
3612
- }
3613
- }
3614
- }
3615
- return filteredData;
3616
- }
3617
- }
3618
- SearchComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: SearchComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
3619
- SearchComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: SearchComponent, selector: "hci-search", inputs: { isArray: "isArray", isIncludeChildren: "isIncludeChildren", anyComponent: "anyComponent", input: "input", data: "data" }, outputs: { dataFiltered: "dataFiltered" }, usesOnChanges: true, ngImport: i0, template: `
3620
- <div class="input-group ">
3621
- <input #searchBox type="text"
3622
- (keyup.enter)="doSearch(searchBox.value)"
3623
- class="form-control"
3624
- placeholder="Search for..."
3625
- aria-label="Search for text">
3626
- <div class="input-group-append">
3627
- <button class="btn btn-outline-secondary" type="button" (click)="doSearch(searchBox.value)">
3628
- <i class="fas fa-search"></i>
3629
- </button>
3630
- </div>
3631
- </div>
3632
- `, isInline: true });
3633
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: SearchComponent, decorators: [{
3634
- type: Component,
3635
- args: [{
3636
- selector: "hci-search",
3637
- template: `
3638
- <div class="input-group ">
3639
- <input #searchBox type="text"
3640
- (keyup.enter)="doSearch(searchBox.value)"
3641
- class="form-control"
3642
- placeholder="Search for..."
3643
- aria-label="Search for text">
3644
- <div class="input-group-append">
3645
- <button class="btn btn-outline-secondary" type="button" (click)="doSearch(searchBox.value)">
3646
- <i class="fas fa-search"></i>
3647
- </button>
3648
- </div>
3649
- </div>
3650
- `
3651
- }]
3652
- }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; }, propDecorators: { isArray: [{
3653
- type: Input
3654
- }], isIncludeChildren: [{
3655
- type: Input
3656
- }], anyComponent: [{
3657
- type: Input
3658
- }], input: [{
3659
- type: Input
3660
- }], data: [{
3661
- type: Input
3662
- }], dataFiltered: [{
3663
- type: Output
3664
- }] } });
3665
-
3666
- class SearchModule {
3667
- }
3668
- SearchModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: SearchModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
3669
- SearchModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.10", ngImport: i0, type: SearchModule, declarations: [SearchComponent], imports: [CommonModule,
3670
- FormsModule,
3671
- NgbModule], exports: [SearchComponent] });
3672
- SearchModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: SearchModule, imports: [CommonModule,
3673
- FormsModule,
3674
- NgbModule] });
3675
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: SearchModule, decorators: [{
3676
- type: NgModule,
3677
- args: [{
3678
- imports: [
3679
- CommonModule,
3680
- FormsModule,
3681
- NgbModule
3682
- ],
3683
- declarations: [
3684
- SearchComponent
3685
- ],
3686
- exports: [
3687
- SearchComponent
3688
- ]
3689
- }]
3690
- }] });
3691
-
3692
- /**
3693
- * Generated bundle index. Do not edit.
3694
- */
3695
-
3696
- export { CustomComboBoxComponent, CustomMultiComboBoxComponent, DROPDOWN_TYPE, DateComponent, DateModule, DateRangeComponent, DropdownComponent, DropdownModule, DropdownSelectComponent, DropdownSelectResultComponent, InlineComponent, InlineModule, MdMultiSelectComponent, MdSelectComponent, NativeSelectComponent, SearchComponent, SearchModule, SelectModule, TemplateDropdownDirective };
3697
- //# sourceMappingURL=huntsman-cancer-institute-input.mjs.map