@skyux/lookup 5.2.2 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/documentation.json +409 -23
- package/esm2015/index.js +32 -0
- package/esm2015/index.js.map +1 -0
- package/esm2015/lib/modules/autocomplete/autocomplete-adapter.service.js +62 -0
- package/esm2015/lib/modules/autocomplete/autocomplete-adapter.service.js.map +1 -0
- package/esm2015/lib/modules/autocomplete/autocomplete-default-search-function.js +39 -0
- package/esm2015/lib/modules/autocomplete/autocomplete-default-search-function.js.map +1 -0
- package/esm2015/lib/modules/autocomplete/autocomplete-input.directive.js +220 -0
- package/esm2015/lib/modules/autocomplete/autocomplete-input.directive.js.map +1 -0
- package/esm2015/lib/modules/autocomplete/autocomplete-search-async-disabled.pipe.js +19 -0
- package/esm2015/lib/modules/autocomplete/autocomplete-search-async-disabled.pipe.js.map +1 -0
- package/esm2015/lib/modules/autocomplete/autocomplete.component.js +732 -0
- package/esm2015/lib/modules/autocomplete/autocomplete.component.js.map +1 -0
- package/esm2015/lib/modules/autocomplete/autocomplete.module.js +65 -0
- package/esm2015/lib/modules/autocomplete/autocomplete.module.js.map +1 -0
- package/esm2015/lib/modules/autocomplete/types/autocomplete-default-search-function-options.js +2 -0
- package/esm2015/lib/modules/autocomplete/types/autocomplete-default-search-function-options.js.map +1 -0
- package/esm2015/lib/modules/autocomplete/types/autocomplete-input-text-change.js +2 -0
- package/esm2015/lib/modules/autocomplete/types/autocomplete-input-text-change.js.map +1 -0
- package/esm2015/lib/modules/autocomplete/types/autocomplete-message-type.js +15 -0
- package/esm2015/lib/modules/autocomplete/types/autocomplete-message-type.js.map +1 -0
- package/esm2015/lib/modules/autocomplete/types/autocomplete-message.js +2 -0
- package/esm2015/lib/modules/autocomplete/types/autocomplete-message.js.map +1 -0
- package/esm2015/lib/modules/autocomplete/types/autocomplete-search-async-args.js +2 -0
- package/esm2015/lib/modules/autocomplete/types/autocomplete-search-async-args.js.map +1 -0
- package/esm2015/lib/modules/autocomplete/types/autocomplete-search-async-function.js +2 -0
- package/esm2015/lib/modules/autocomplete/types/autocomplete-search-async-function.js.map +1 -0
- package/esm2015/lib/modules/autocomplete/types/autocomplete-search-async-result-display-type.js +2 -0
- package/esm2015/lib/modules/autocomplete/types/autocomplete-search-async-result-display-type.js.map +1 -0
- package/esm2015/lib/modules/autocomplete/types/autocomplete-search-async-result.js +2 -0
- package/esm2015/lib/modules/autocomplete/types/autocomplete-search-async-result.js.map +1 -0
- package/esm2015/lib/modules/autocomplete/types/autocomplete-search-function-filter.js +2 -0
- package/esm2015/lib/modules/autocomplete/types/autocomplete-search-function-filter.js.map +1 -0
- package/esm2015/lib/modules/autocomplete/types/autocomplete-search-function-response.js +2 -0
- package/esm2015/lib/modules/autocomplete/types/autocomplete-search-function-response.js.map +1 -0
- package/esm2015/lib/modules/autocomplete/types/autocomplete-search-function.js +2 -0
- package/esm2015/lib/modules/autocomplete/types/autocomplete-search-function.js.map +1 -0
- package/esm2015/lib/modules/autocomplete/types/autocomplete-selection-change.js +2 -0
- package/esm2015/lib/modules/autocomplete/types/autocomplete-selection-change.js.map +1 -0
- package/esm2015/lib/modules/autocomplete/types/autocomplete-show-more-args.js +2 -0
- package/esm2015/lib/modules/autocomplete/types/autocomplete-show-more-args.js.map +1 -0
- package/esm2015/{modules → lib/modules}/country-field/country-field.component.js +5 -2
- package/esm2015/lib/modules/country-field/country-field.component.js.map +1 -0
- package/esm2015/lib/modules/country-field/country-field.module.js +49 -0
- package/esm2015/lib/modules/country-field/country-field.module.js.map +1 -0
- package/esm2015/lib/modules/country-field/types/country.js +2 -0
- package/esm2015/lib/modules/country-field/types/country.js.map +1 -0
- package/esm2015/lib/modules/lookup/lookup-adapter.service.js +21 -0
- package/esm2015/lib/modules/lookup/lookup-adapter.service.js.map +1 -0
- package/esm2015/lib/modules/lookup/lookup-autocomplete-adapter.js +72 -0
- package/esm2015/lib/modules/lookup/lookup-autocomplete-adapter.js.map +1 -0
- package/esm2015/lib/modules/lookup/lookup-item-selected.pipe.js +16 -0
- package/esm2015/lib/modules/lookup/lookup-item-selected.pipe.js.map +1 -0
- package/esm2015/lib/modules/lookup/lookup-show-more-async-modal.component.js +186 -0
- package/esm2015/lib/modules/lookup/lookup-show-more-async-modal.component.js.map +1 -0
- package/esm2015/lib/modules/lookup/lookup-show-more-modal.component.js +258 -0
- package/esm2015/lib/modules/lookup/lookup-show-more-modal.component.js.map +1 -0
- package/esm2015/lib/modules/lookup/lookup.component.js +608 -0
- package/esm2015/lib/modules/lookup/lookup.component.js.map +1 -0
- package/esm2015/lib/modules/lookup/lookup.module.js +94 -0
- package/esm2015/lib/modules/lookup/lookup.module.js.map +1 -0
- package/esm2015/lib/modules/lookup/types/lookup-add-click-callback-args.js +2 -0
- package/esm2015/lib/modules/lookup/types/lookup-add-click-callback-args.js.map +1 -0
- package/esm2015/lib/modules/lookup/types/lookup-add-click-event-args.js +2 -0
- package/esm2015/lib/modules/lookup/types/lookup-add-click-event-args.js.map +1 -0
- package/esm2015/lib/modules/lookup/types/lookup-select-mode-type.js +2 -0
- package/esm2015/lib/modules/lookup/types/lookup-select-mode-type.js.map +1 -0
- package/esm2015/lib/modules/lookup/types/lookup-select-mode.js +16 -0
- package/esm2015/lib/modules/lookup/types/lookup-select-mode.js.map +1 -0
- package/esm2015/lib/modules/lookup/types/lookup-show-more-config.js +2 -0
- package/esm2015/lib/modules/lookup/types/lookup-show-more-config.js.map +1 -0
- package/esm2015/lib/modules/lookup/types/lookup-show-more-custom-picker-context.js +7 -0
- package/esm2015/lib/modules/lookup/types/lookup-show-more-custom-picker-context.js.map +1 -0
- package/esm2015/lib/modules/lookup/types/lookup-show-more-custom-picker.js +2 -0
- package/esm2015/lib/modules/lookup/types/lookup-show-more-custom-picker.js.map +1 -0
- package/esm2015/lib/modules/lookup/types/lookup-show-more-native-picker-async-context.js +7 -0
- package/esm2015/lib/modules/lookup/types/lookup-show-more-native-picker-async-context.js.map +1 -0
- package/esm2015/lib/modules/lookup/types/lookup-show-more-native-picker-config.js +2 -0
- package/esm2015/lib/modules/lookup/types/lookup-show-more-native-picker-config.js.map +1 -0
- package/esm2015/lib/modules/lookup/types/lookup-show-more-native-picker-context.js +7 -0
- package/esm2015/lib/modules/lookup/types/lookup-show-more-native-picker-context.js.map +1 -0
- package/esm2015/lib/modules/search/search-adapter.service.js +45 -0
- package/esm2015/lib/modules/search/search-adapter.service.js.map +1 -0
- package/esm2015/lib/modules/search/search.component.js +260 -0
- package/esm2015/lib/modules/search/search.component.js.map +1 -0
- package/esm2015/lib/modules/search/search.module.js +46 -0
- package/esm2015/lib/modules/search/search.module.js.map +1 -0
- package/esm2015/lib/modules/shared/sky-lookup-resources.module.js +72 -0
- package/esm2015/lib/modules/shared/sky-lookup-resources.module.js.map +1 -0
- package/esm2015/lib/modules/shared/sky-lookup-string-utils.js +8 -0
- package/esm2015/lib/modules/shared/sky-lookup-string-utils.js.map +1 -0
- package/esm2015/lib/polyfills.js +30 -0
- package/esm2015/lib/polyfills.js.map +1 -0
- package/esm2015/skyux-lookup.js +2 -2
- package/esm2015/skyux-lookup.js.map +1 -0
- package/esm2015/testing/country-field/country-field-fixture.js +1 -1
- package/esm2015/testing/country-field/country-field-fixture.js.map +1 -0
- package/esm2015/testing/country-field/country-field-testing.module.js +1 -1
- package/esm2015/testing/country-field/country-field-testing.module.js.map +1 -0
- package/esm2015/testing/public-api.js +1 -1
- package/esm2015/testing/public-api.js.map +1 -0
- package/esm2015/testing/search/search-fixture.js +1 -1
- package/esm2015/testing/search/search-fixture.js.map +1 -0
- package/esm2015/testing/search/search-testing.module.js +1 -1
- package/esm2015/testing/search/search-testing.module.js.map +1 -0
- package/esm2015/testing/skyux-lookup-testing.js +1 -1
- package/esm2015/testing/skyux-lookup-testing.js.map +1 -0
- package/fesm2015/skyux-lookup-testing.js.map +1 -1
- package/fesm2015/skyux-lookup.js +2 -2
- package/fesm2015/skyux-lookup.js.map +1 -1
- package/index.d.ts +27 -0
- package/{modules → lib/modules}/autocomplete/autocomplete-adapter.service.d.ts +0 -0
- package/{modules → lib/modules}/autocomplete/autocomplete-default-search-function.d.ts +0 -0
- package/{modules → lib/modules}/autocomplete/autocomplete-input.directive.d.ts +0 -0
- package/{modules → lib/modules}/autocomplete/autocomplete-search-async-disabled.pipe.d.ts +0 -0
- package/{modules → lib/modules}/autocomplete/autocomplete.component.d.ts +0 -0
- package/{modules → lib/modules}/autocomplete/autocomplete.module.d.ts +0 -0
- package/{modules → lib/modules}/autocomplete/types/autocomplete-default-search-function-options.d.ts +0 -0
- package/{modules → lib/modules}/autocomplete/types/autocomplete-input-text-change.d.ts +0 -0
- package/{modules → lib/modules}/autocomplete/types/autocomplete-message-type.d.ts +0 -0
- package/{modules → lib/modules}/autocomplete/types/autocomplete-message.d.ts +0 -0
- package/{modules → lib/modules}/autocomplete/types/autocomplete-search-async-args.d.ts +0 -0
- package/{modules → lib/modules}/autocomplete/types/autocomplete-search-async-function.d.ts +0 -0
- package/{modules → lib/modules}/autocomplete/types/autocomplete-search-async-result-display-type.d.ts +0 -0
- package/{modules → lib/modules}/autocomplete/types/autocomplete-search-async-result.d.ts +0 -0
- package/{modules → lib/modules}/autocomplete/types/autocomplete-search-function-filter.d.ts +0 -0
- package/{modules → lib/modules}/autocomplete/types/autocomplete-search-function-response.d.ts +0 -0
- package/{modules → lib/modules}/autocomplete/types/autocomplete-search-function.d.ts +0 -0
- package/{modules → lib/modules}/autocomplete/types/autocomplete-selection-change.d.ts +0 -0
- package/{modules → lib/modules}/autocomplete/types/autocomplete-show-more-args.d.ts +0 -0
- package/{modules → lib/modules}/country-field/country-field.component.d.ts +0 -0
- package/{modules → lib/modules}/country-field/country-field.module.d.ts +0 -0
- package/{modules → lib/modules}/country-field/types/country.d.ts +0 -0
- package/{modules → lib/modules}/lookup/lookup-adapter.service.d.ts +0 -0
- package/{modules → lib/modules}/lookup/lookup-autocomplete-adapter.d.ts +0 -0
- package/{modules → lib/modules}/lookup/lookup-item-selected.pipe.d.ts +0 -0
- package/{modules → lib/modules}/lookup/lookup-show-more-async-modal.component.d.ts +0 -0
- package/{modules → lib/modules}/lookup/lookup-show-more-modal.component.d.ts +0 -0
- package/{modules → lib/modules}/lookup/lookup.component.d.ts +0 -0
- package/{modules → lib/modules}/lookup/lookup.module.d.ts +0 -0
- package/{modules → lib/modules}/lookup/types/lookup-add-click-callback-args.d.ts +0 -0
- package/{modules → lib/modules}/lookup/types/lookup-add-click-event-args.d.ts +0 -0
- package/{modules → lib/modules}/lookup/types/lookup-select-mode-type.d.ts +0 -0
- package/{modules → lib/modules}/lookup/types/lookup-select-mode.d.ts +0 -0
- package/{modules → lib/modules}/lookup/types/lookup-show-more-config.d.ts +0 -0
- package/{modules → lib/modules}/lookup/types/lookup-show-more-custom-picker-context.d.ts +0 -0
- package/{modules → lib/modules}/lookup/types/lookup-show-more-custom-picker.d.ts +0 -0
- package/{modules → lib/modules}/lookup/types/lookup-show-more-native-picker-async-context.d.ts +0 -0
- package/{modules → lib/modules}/lookup/types/lookup-show-more-native-picker-config.d.ts +0 -0
- package/{modules → lib/modules}/lookup/types/lookup-show-more-native-picker-context.d.ts +0 -0
- package/{modules → lib/modules}/search/search-adapter.service.d.ts +0 -0
- package/{modules → lib/modules}/search/search.component.d.ts +0 -0
- package/{modules → lib/modules}/search/search.module.d.ts +0 -0
- package/{modules → lib/modules}/shared/sky-lookup-resources.module.d.ts +0 -0
- package/{modules → lib/modules}/shared/sky-lookup-string-utils.d.ts +0 -0
- package/{polyfills.d.ts → lib/polyfills.d.ts} +0 -0
- package/package.json +23 -9
- package/skyux-lookup.d.ts +1 -1
- package/LICENSE +0 -21
- package/esm2015/modules/autocomplete/autocomplete-adapter.service.js +0 -61
- package/esm2015/modules/autocomplete/autocomplete-default-search-function.js +0 -39
- package/esm2015/modules/autocomplete/autocomplete-input.directive.js +0 -220
- package/esm2015/modules/autocomplete/autocomplete-search-async-disabled.pipe.js +0 -19
- package/esm2015/modules/autocomplete/autocomplete.component.js +0 -731
- package/esm2015/modules/autocomplete/autocomplete.module.js +0 -65
- package/esm2015/modules/autocomplete/types/autocomplete-default-search-function-options.js +0 -2
- package/esm2015/modules/autocomplete/types/autocomplete-input-text-change.js +0 -2
- package/esm2015/modules/autocomplete/types/autocomplete-message-type.js +0 -15
- package/esm2015/modules/autocomplete/types/autocomplete-message.js +0 -2
- package/esm2015/modules/autocomplete/types/autocomplete-search-async-args.js +0 -2
- package/esm2015/modules/autocomplete/types/autocomplete-search-async-function.js +0 -2
- package/esm2015/modules/autocomplete/types/autocomplete-search-async-result-display-type.js +0 -2
- package/esm2015/modules/autocomplete/types/autocomplete-search-async-result.js +0 -2
- package/esm2015/modules/autocomplete/types/autocomplete-search-function-filter.js +0 -2
- package/esm2015/modules/autocomplete/types/autocomplete-search-function-response.js +0 -2
- package/esm2015/modules/autocomplete/types/autocomplete-search-function.js +0 -2
- package/esm2015/modules/autocomplete/types/autocomplete-selection-change.js +0 -2
- package/esm2015/modules/autocomplete/types/autocomplete-show-more-args.js +0 -2
- package/esm2015/modules/country-field/country-field.module.js +0 -49
- package/esm2015/modules/country-field/types/country.js +0 -2
- package/esm2015/modules/lookup/lookup-adapter.service.js +0 -21
- package/esm2015/modules/lookup/lookup-autocomplete-adapter.js +0 -72
- package/esm2015/modules/lookup/lookup-item-selected.pipe.js +0 -16
- package/esm2015/modules/lookup/lookup-show-more-async-modal.component.js +0 -184
- package/esm2015/modules/lookup/lookup-show-more-modal.component.js +0 -256
- package/esm2015/modules/lookup/lookup.component.js +0 -602
- package/esm2015/modules/lookup/lookup.module.js +0 -94
- package/esm2015/modules/lookup/types/lookup-add-click-callback-args.js +0 -2
- package/esm2015/modules/lookup/types/lookup-add-click-event-args.js +0 -2
- package/esm2015/modules/lookup/types/lookup-select-mode-type.js +0 -2
- package/esm2015/modules/lookup/types/lookup-select-mode.js +0 -16
- package/esm2015/modules/lookup/types/lookup-show-more-config.js +0 -2
- package/esm2015/modules/lookup/types/lookup-show-more-custom-picker-context.js +0 -7
- package/esm2015/modules/lookup/types/lookup-show-more-custom-picker.js +0 -2
- package/esm2015/modules/lookup/types/lookup-show-more-native-picker-async-context.js +0 -7
- package/esm2015/modules/lookup/types/lookup-show-more-native-picker-config.js +0 -2
- package/esm2015/modules/lookup/types/lookup-show-more-native-picker-context.js +0 -7
- package/esm2015/modules/search/search-adapter.service.js +0 -45
- package/esm2015/modules/search/search.component.js +0 -260
- package/esm2015/modules/search/search.module.js +0 -46
- package/esm2015/modules/shared/sky-lookup-resources.module.js +0 -72
- package/esm2015/modules/shared/sky-lookup-string-utils.js +0 -8
- package/esm2015/polyfills.js +0 -30
- package/esm2015/public-api.js +0 -32
- package/public-api.d.ts +0 -27
|
@@ -0,0 +1,732 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChild, ElementRef, EventEmitter, Input, Optional, Output, TemplateRef, ViewChild, } from '@angular/core';
|
|
2
|
+
import { SkyAffixAutoFitContext, SkyAffixService, SkyOverlayService, } from '@skyux/core';
|
|
3
|
+
import { SkyInputBoxHostService } from '@skyux/forms';
|
|
4
|
+
import { from, fromEvent as observableFromEvent, of, Subject, } from 'rxjs';
|
|
5
|
+
import { debounceTime, map, switchMap, take, takeUntil } from 'rxjs/operators';
|
|
6
|
+
import { SkyAutocompleteMessageType } from './types/autocomplete-message-type';
|
|
7
|
+
import { SkyAutocompleteAdapterService } from './autocomplete-adapter.service';
|
|
8
|
+
import { skyAutocompleteDefaultSearchFunction } from './autocomplete-default-search-function';
|
|
9
|
+
import { SkyAutocompleteInputDirective } from './autocomplete-input.directive';
|
|
10
|
+
import { normalizeDiacritics } from '../shared/sky-lookup-string-utils';
|
|
11
|
+
import * as i0 from "@angular/core";
|
|
12
|
+
import * as i1 from "@skyux/core";
|
|
13
|
+
import * as i2 from "./autocomplete-adapter.service";
|
|
14
|
+
import * as i3 from "@skyux/forms";
|
|
15
|
+
import * as i4 from "@skyux/indicators";
|
|
16
|
+
import * as i5 from "@skyux/theme";
|
|
17
|
+
import * as i6 from "@angular/common";
|
|
18
|
+
import * as i7 from "@skyux/i18n";
|
|
19
|
+
import * as i8 from "./autocomplete-search-async-disabled.pipe";
|
|
20
|
+
let uniqueId = 0;
|
|
21
|
+
export class SkyAutocompleteComponent {
|
|
22
|
+
constructor(changeDetector, elementRef, affixService, adapterService, overlayService, inputBoxHostSvc) {
|
|
23
|
+
this.changeDetector = changeDetector;
|
|
24
|
+
this.elementRef = elementRef;
|
|
25
|
+
this.affixService = affixService;
|
|
26
|
+
this.adapterService = adapterService;
|
|
27
|
+
this.overlayService = overlayService;
|
|
28
|
+
this.inputBoxHostSvc = inputBoxHostSvc;
|
|
29
|
+
/**
|
|
30
|
+
* @internal
|
|
31
|
+
* Indicates whether to display a button in the dropdown that opens a picker where users can view all options.
|
|
32
|
+
*/
|
|
33
|
+
this.enableShowMore = false;
|
|
34
|
+
/**
|
|
35
|
+
* @internal
|
|
36
|
+
* Indicates whether to display a button that lets users add options to the data source.
|
|
37
|
+
*/
|
|
38
|
+
this.showAddButton = false;
|
|
39
|
+
/**
|
|
40
|
+
* @internal
|
|
41
|
+
* Allows async search to be disabled even when a listener is specified for
|
|
42
|
+
* the `searchAsync` output.
|
|
43
|
+
*/
|
|
44
|
+
this.searchAsyncDisabled = false;
|
|
45
|
+
/**
|
|
46
|
+
* @internal
|
|
47
|
+
* Fires when users select the button to add options to the data source.
|
|
48
|
+
*/
|
|
49
|
+
this.addClick = new EventEmitter();
|
|
50
|
+
/**
|
|
51
|
+
* @internal
|
|
52
|
+
* Fires when users select the button to view all options.
|
|
53
|
+
*/
|
|
54
|
+
this.showMoreClick = new EventEmitter();
|
|
55
|
+
this.searchAsync = new EventEmitter();
|
|
56
|
+
this.isOpen = false;
|
|
57
|
+
this.isSearchingAsync = false;
|
|
58
|
+
/**
|
|
59
|
+
* Index that indicates which descendant of the overlay currently has focus.
|
|
60
|
+
*/
|
|
61
|
+
this.activeElementIndex = -1;
|
|
62
|
+
this.inputDirectiveUnsubscribe = new Subject();
|
|
63
|
+
this.ngUnsubscribe = new Subject();
|
|
64
|
+
/**
|
|
65
|
+
* Elements within the autocomplete dropdown that are focusable.
|
|
66
|
+
* These are typically the search results and action buttons, but could also be
|
|
67
|
+
* elements provided in the consumer's own template.
|
|
68
|
+
*/
|
|
69
|
+
this.overlayFocusableElements = [];
|
|
70
|
+
this._selectionChange = new EventEmitter();
|
|
71
|
+
const id = ++uniqueId;
|
|
72
|
+
this.resultsListId = `sky-autocomplete-list-${id}`;
|
|
73
|
+
this.resultsWrapperId = `sky-autocomplete-wrapper-${id}`;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Specifies a static data source for the autocomplete component to search
|
|
77
|
+
* when users enter text. For a dynamic data source such as an array that
|
|
78
|
+
* changes due to server calls, use the `search` property instead.
|
|
79
|
+
*/
|
|
80
|
+
set data(value) {
|
|
81
|
+
this._data = value;
|
|
82
|
+
}
|
|
83
|
+
get data() {
|
|
84
|
+
return this._data || [];
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Specifies how many milliseconds to wait before searching while users
|
|
88
|
+
* enter text in the autocomplete field.
|
|
89
|
+
* @default 0
|
|
90
|
+
*/
|
|
91
|
+
set debounceTime(value) {
|
|
92
|
+
this._debounceTime = value;
|
|
93
|
+
}
|
|
94
|
+
get debounceTime() {
|
|
95
|
+
return this._debounceTime || 0;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Specifies an object property to display in the text input after users
|
|
99
|
+
* select an item in the dropdown list.
|
|
100
|
+
* @default "name"
|
|
101
|
+
*/
|
|
102
|
+
set descriptorProperty(value) {
|
|
103
|
+
this._descriptorProperty = value;
|
|
104
|
+
}
|
|
105
|
+
get descriptorProperty() {
|
|
106
|
+
return this._descriptorProperty || 'name';
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Specifies an observable of `SkyAutocompleteMessage` that can close the dropdown.
|
|
110
|
+
* @internal
|
|
111
|
+
*/
|
|
112
|
+
set messageStream(value) {
|
|
113
|
+
this._messageStream = value;
|
|
114
|
+
this.initMessageStream();
|
|
115
|
+
}
|
|
116
|
+
get messageStream() {
|
|
117
|
+
return this._messageStream;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Specifies the object properties to search.
|
|
121
|
+
* @default ["name"]
|
|
122
|
+
*/
|
|
123
|
+
set propertiesToSearch(value) {
|
|
124
|
+
this._propertiesToSearch = value;
|
|
125
|
+
}
|
|
126
|
+
get propertiesToSearch() {
|
|
127
|
+
return this._propertiesToSearch || ['name'];
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Specifies a function to dynamically manage the data source when users
|
|
131
|
+
* change the text in the autocomplete field. The search function must return
|
|
132
|
+
* an array or a promise of an array. The `search` property is particularly
|
|
133
|
+
* useful when the data source does not live in the source code.
|
|
134
|
+
*/
|
|
135
|
+
set search(value) {
|
|
136
|
+
this._search = value;
|
|
137
|
+
}
|
|
138
|
+
get search() {
|
|
139
|
+
return (this._search ||
|
|
140
|
+
skyAutocompleteDefaultSearchFunction({
|
|
141
|
+
propertiesToSearch: this.propertiesToSearch,
|
|
142
|
+
searchFilters: this.searchFilters,
|
|
143
|
+
}));
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Specifies a template to format each search result in the dropdown list.
|
|
147
|
+
* The autocomplete component injects search result values into the template
|
|
148
|
+
* as `item` variables that reference all of the object properties of the search results.
|
|
149
|
+
*/
|
|
150
|
+
set searchResultTemplate(value) {
|
|
151
|
+
this._searchResultTemplate = value;
|
|
152
|
+
}
|
|
153
|
+
get searchResultTemplate() {
|
|
154
|
+
return this._searchResultTemplate || this.defaultSearchResultTemplate;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Specifies the minimum number of characters that users must enter before
|
|
158
|
+
* the autocomplete component searches the data source and displays search
|
|
159
|
+
* results in the dropdown list.
|
|
160
|
+
* @default 1
|
|
161
|
+
*/
|
|
162
|
+
set searchTextMinimumCharacters(value) {
|
|
163
|
+
this._searchTextMinimumCharacters = value;
|
|
164
|
+
}
|
|
165
|
+
get searchTextMinimumCharacters() {
|
|
166
|
+
return this._searchTextMinimumCharacters > 0
|
|
167
|
+
? this._searchTextMinimumCharacters
|
|
168
|
+
: 1;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Specifies the maximum number of search results to display in the dropdown list.
|
|
172
|
+
* By default, the component displays all matching results.
|
|
173
|
+
*/
|
|
174
|
+
set searchResultsLimit(value) {
|
|
175
|
+
this._searchResultsLimit = value;
|
|
176
|
+
}
|
|
177
|
+
get searchResultsLimit() {
|
|
178
|
+
if (this._searchResultsLimit) {
|
|
179
|
+
return this._searchResultsLimit;
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
return this.enableShowMore ? 5 : this._searchResultsLimit;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Fires when users select items in the dropdown list.
|
|
187
|
+
*/
|
|
188
|
+
get selectionChange() {
|
|
189
|
+
return this._selectionChange;
|
|
190
|
+
}
|
|
191
|
+
//#endregion
|
|
192
|
+
//#region template_properties
|
|
193
|
+
get searchResults() {
|
|
194
|
+
return this._searchResults || [];
|
|
195
|
+
}
|
|
196
|
+
get highlightText() {
|
|
197
|
+
return this._highlightText || [];
|
|
198
|
+
}
|
|
199
|
+
get showActionsArea() {
|
|
200
|
+
return this.showAddButton || this.enableShowMore;
|
|
201
|
+
}
|
|
202
|
+
set inputDirective(directive) {
|
|
203
|
+
if (this._inputDirective !== directive) {
|
|
204
|
+
if (!directive) {
|
|
205
|
+
throw Error([
|
|
206
|
+
'The SkyAutocompleteComponent requires a ContentChild input or',
|
|
207
|
+
'textarea bound with the SkyAutocomplete directive. For example:',
|
|
208
|
+
'`<input type="text" skyAutocomplete>`.',
|
|
209
|
+
].join(' '));
|
|
210
|
+
}
|
|
211
|
+
// Unsubscribe from old subscriptions on any previous input directive
|
|
212
|
+
this.inputDirectiveUnsubscribe.next();
|
|
213
|
+
this._inputDirective = directive;
|
|
214
|
+
this._inputDirective.displayWith = this.descriptorProperty;
|
|
215
|
+
this._inputDirective.textChanges
|
|
216
|
+
.pipe(takeUntil(this.inputDirectiveUnsubscribe), debounceTime(this.debounceTime), switchMap((change) => {
|
|
217
|
+
this.isSearchingAsync = true;
|
|
218
|
+
return of(change);
|
|
219
|
+
}))
|
|
220
|
+
.subscribe((change) => {
|
|
221
|
+
this.searchTextChanged(change.value);
|
|
222
|
+
});
|
|
223
|
+
this._inputDirective.blur
|
|
224
|
+
.pipe(takeUntil(this.inputDirectiveUnsubscribe))
|
|
225
|
+
.subscribe(() => {
|
|
226
|
+
this.inputDirective.onTouched();
|
|
227
|
+
});
|
|
228
|
+
this._inputDirective.focus
|
|
229
|
+
.pipe(takeUntil(this.inputDirectiveUnsubscribe))
|
|
230
|
+
.subscribe(() => {
|
|
231
|
+
if (this.showActionsArea) {
|
|
232
|
+
this.openDropdown();
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
get inputDirective() {
|
|
238
|
+
return this._inputDirective;
|
|
239
|
+
}
|
|
240
|
+
set resultsRef(value) {
|
|
241
|
+
if (value) {
|
|
242
|
+
this._resultsRef = value;
|
|
243
|
+
this.destroyAffixer();
|
|
244
|
+
this.createAffixer();
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
get resultsRef() {
|
|
248
|
+
return this._resultsRef;
|
|
249
|
+
}
|
|
250
|
+
ngAfterContentInit() {
|
|
251
|
+
if (!this.inputDirective) {
|
|
252
|
+
throw Error([
|
|
253
|
+
'The SkyAutocompleteComponent requires a ContentChild input or',
|
|
254
|
+
'textarea bound with the SkyAutocomplete directive. For example:',
|
|
255
|
+
'`<input type="text" skyAutocomplete>`.',
|
|
256
|
+
].join(' '));
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
ngAfterViewInit() {
|
|
260
|
+
this.addInputEventListeners();
|
|
261
|
+
}
|
|
262
|
+
ngOnDestroy() {
|
|
263
|
+
this.cancelCurrentSearch();
|
|
264
|
+
this.inputDirectiveUnsubscribe.next();
|
|
265
|
+
this.inputDirectiveUnsubscribe.complete();
|
|
266
|
+
this.ngUnsubscribe.next();
|
|
267
|
+
this.ngUnsubscribe.complete();
|
|
268
|
+
this.destroyAffixer();
|
|
269
|
+
this.destroyOverlay();
|
|
270
|
+
}
|
|
271
|
+
addButtonClicked() {
|
|
272
|
+
this.addClick.emit();
|
|
273
|
+
this.inputDirective.restoreInputTextValueToPreviousState();
|
|
274
|
+
this.closeDropdown();
|
|
275
|
+
}
|
|
276
|
+
handleKeydown(event) {
|
|
277
|
+
/* Sanity check */
|
|
278
|
+
/* istanbul ignore else */
|
|
279
|
+
if (event.key) {
|
|
280
|
+
const key = event.key.toLowerCase();
|
|
281
|
+
const activeElement = this.getActiveElement();
|
|
282
|
+
const activeElementId = activeElement === null || activeElement === void 0 ? void 0 : activeElement.id;
|
|
283
|
+
const targetIsSearchResult = this.searchResults.find((r) => r.elementId === activeElementId);
|
|
284
|
+
/* tslint:disable-next-line:switch-default */
|
|
285
|
+
switch (key) {
|
|
286
|
+
case 'enter':
|
|
287
|
+
if (targetIsSearchResult) {
|
|
288
|
+
this.selectSearchResultById(activeElementId);
|
|
289
|
+
if (!this.showActionsArea) {
|
|
290
|
+
this.closeDropdown();
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
this.resetSearch();
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
if (activeElement) {
|
|
298
|
+
activeElement.click();
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
event.preventDefault();
|
|
302
|
+
event.stopPropagation();
|
|
303
|
+
break;
|
|
304
|
+
case 'tab':
|
|
305
|
+
if (targetIsSearchResult) {
|
|
306
|
+
this.selectSearchResultById(activeElementId);
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
this.inputDirective.restoreInputTextValueToPreviousState();
|
|
310
|
+
}
|
|
311
|
+
this.closeDropdown();
|
|
312
|
+
break;
|
|
313
|
+
case 'escape':
|
|
314
|
+
this.closeDropdown();
|
|
315
|
+
break;
|
|
316
|
+
case 'arrowdown':
|
|
317
|
+
case 'down':
|
|
318
|
+
this.removeFocusedClass();
|
|
319
|
+
if (this.activeElementIndex ===
|
|
320
|
+
this.overlayFocusableElements.length - 1 ||
|
|
321
|
+
this.activeElementIndex === -1) {
|
|
322
|
+
this.activeElementIndex = 0;
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
this.activeElementIndex = this.activeElementIndex + 1;
|
|
326
|
+
}
|
|
327
|
+
this.addFocusedClass();
|
|
328
|
+
this.changeDetector.markForCheck();
|
|
329
|
+
event.preventDefault();
|
|
330
|
+
event.stopPropagation();
|
|
331
|
+
break;
|
|
332
|
+
case 'arrowup':
|
|
333
|
+
case 'up':
|
|
334
|
+
this.removeFocusedClass();
|
|
335
|
+
if (this.activeElementIndex <= 0) {
|
|
336
|
+
this.activeElementIndex = this.overlayFocusableElements.length - 1;
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
this.activeElementIndex = this.activeElementIndex - 1;
|
|
340
|
+
}
|
|
341
|
+
this.addFocusedClass();
|
|
342
|
+
this.changeDetector.markForCheck();
|
|
343
|
+
event.preventDefault();
|
|
344
|
+
event.stopPropagation();
|
|
345
|
+
break;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
moreButtonClicked() {
|
|
350
|
+
this.showMoreClick.emit({ inputValue: this.searchText });
|
|
351
|
+
this.inputDirective.restoreInputTextValueToPreviousState();
|
|
352
|
+
this.closeDropdown();
|
|
353
|
+
}
|
|
354
|
+
onResultMouseDown(id, event) {
|
|
355
|
+
this.selectSearchResultById(id);
|
|
356
|
+
if (!this.showActionsArea) {
|
|
357
|
+
this.closeDropdown();
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
this.resetSearch();
|
|
361
|
+
}
|
|
362
|
+
event.preventDefault();
|
|
363
|
+
event.stopPropagation();
|
|
364
|
+
}
|
|
365
|
+
onResultMouseMove(id) {
|
|
366
|
+
if (id !== this.activeElementIndex) {
|
|
367
|
+
this.removeFocusedClass();
|
|
368
|
+
this.activeElementIndex = id;
|
|
369
|
+
this.addFocusedClass();
|
|
370
|
+
this.changeDetector.markForCheck();
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
isElementFocused(ref) {
|
|
374
|
+
return ref === this.overlayFocusableElements[this.activeElementIndex];
|
|
375
|
+
}
|
|
376
|
+
searchTextChanged(searchText) {
|
|
377
|
+
const isEmpty = !searchText || !searchText.trim() || searchText.match(/^\s+$/);
|
|
378
|
+
if (isEmpty) {
|
|
379
|
+
// Emit selectionChange if value has been cleared.
|
|
380
|
+
if (this.inputDirective.value) {
|
|
381
|
+
this.inputDirective.value = undefined;
|
|
382
|
+
this.selectionChange.emit({
|
|
383
|
+
selectedItem: undefined,
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
if (!this.showActionsArea) {
|
|
387
|
+
this.closeDropdown();
|
|
388
|
+
}
|
|
389
|
+
else {
|
|
390
|
+
this.resetSearch();
|
|
391
|
+
}
|
|
392
|
+
this.isSearchingAsync = false;
|
|
393
|
+
this.changeDetector.markForCheck();
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
const isLongEnough = searchText.length >= this.searchTextMinimumCharacters;
|
|
397
|
+
const isDifferent = searchText !== this.searchText;
|
|
398
|
+
this.searchText = searchText.trim();
|
|
399
|
+
if (isLongEnough && isDifferent) {
|
|
400
|
+
this.cancelCurrentSearch();
|
|
401
|
+
this.currentSearchSub = this.performSearch()
|
|
402
|
+
.pipe(take(1))
|
|
403
|
+
.subscribe((result) => {
|
|
404
|
+
const items = result.items;
|
|
405
|
+
this.isSearchingAsync = false;
|
|
406
|
+
this._searchResults = items.map((r, i) => {
|
|
407
|
+
const result = {
|
|
408
|
+
elementId: `${this.resultsListId}-item-${i}`,
|
|
409
|
+
data: r,
|
|
410
|
+
};
|
|
411
|
+
return result;
|
|
412
|
+
});
|
|
413
|
+
this.searchResultsCount = result.totalCount;
|
|
414
|
+
this._highlightText = this.getHighlightText(this.searchText);
|
|
415
|
+
this.removeFocusedClass();
|
|
416
|
+
this.removeActiveDescendant();
|
|
417
|
+
if (this.searchResults.length > 0) {
|
|
418
|
+
this.activeElementIndex = 0;
|
|
419
|
+
}
|
|
420
|
+
else {
|
|
421
|
+
this.activeElementIndex = -1;
|
|
422
|
+
}
|
|
423
|
+
this.changeDetector.markForCheck();
|
|
424
|
+
if (this.isOpen) {
|
|
425
|
+
// Let the results populate in the DOM before recalculating placement.
|
|
426
|
+
setTimeout(() => {
|
|
427
|
+
this.affixer.reaffix();
|
|
428
|
+
this.changeDetector.detectChanges();
|
|
429
|
+
this.initOverlayFocusableElements();
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
else {
|
|
433
|
+
this.openDropdown();
|
|
434
|
+
this.changeDetector.markForCheck();
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
else {
|
|
439
|
+
this.isSearchingAsync = false;
|
|
440
|
+
this.changeDetector.markForCheck();
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
performSearch() {
|
|
444
|
+
if (!this.searchAsyncDisabled && this.searchAsync.observers.length > 0) {
|
|
445
|
+
const searchAsyncArgs = {
|
|
446
|
+
displayType: 'popover',
|
|
447
|
+
offset: 0,
|
|
448
|
+
searchText: this.searchText,
|
|
449
|
+
};
|
|
450
|
+
this.searchAsync.emit(searchAsyncArgs);
|
|
451
|
+
return searchAsyncArgs.result;
|
|
452
|
+
}
|
|
453
|
+
const result = this.search(this.searchText, this.data);
|
|
454
|
+
if (result instanceof Array) {
|
|
455
|
+
return of({
|
|
456
|
+
items: result,
|
|
457
|
+
totalCount: result.length,
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
return from(result).pipe(map((items) => {
|
|
461
|
+
return {
|
|
462
|
+
items,
|
|
463
|
+
totalCount: items.length,
|
|
464
|
+
};
|
|
465
|
+
}));
|
|
466
|
+
}
|
|
467
|
+
cancelCurrentSearch() {
|
|
468
|
+
if (this.currentSearchSub) {
|
|
469
|
+
this.currentSearchSub.unsubscribe();
|
|
470
|
+
this.currentSearchSub = undefined;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Returns the text to highlight based on exact matches, case-insensitive matches, and matches for corresponding diacritical characters (a will match à).
|
|
475
|
+
*/
|
|
476
|
+
getHighlightText(searchText) {
|
|
477
|
+
const normalizedSearchText = normalizeDiacritics(this.searchText).toLocaleUpperCase();
|
|
478
|
+
let matchesToHighlight = [];
|
|
479
|
+
for (let i = 0, n = this._searchResults.length; i < n; i++) {
|
|
480
|
+
const value = this._searchResults[i].data[this.descriptorProperty]
|
|
481
|
+
.toString()
|
|
482
|
+
.toLocaleUpperCase();
|
|
483
|
+
const normalizedDataValue = normalizeDiacritics(value);
|
|
484
|
+
let offset = 0;
|
|
485
|
+
let index;
|
|
486
|
+
while ((index = normalizedDataValue.indexOf(normalizedSearchText, offset)) > -1) {
|
|
487
|
+
const matchedString = value.slice(index, index + searchText.length);
|
|
488
|
+
offset = index + searchText.length;
|
|
489
|
+
matchesToHighlight = matchesToHighlight.concat(matchedString);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
// Remove any duplicates from the array.
|
|
493
|
+
return [...new Set(matchesToHighlight)];
|
|
494
|
+
}
|
|
495
|
+
selectSearchResultById(id) {
|
|
496
|
+
const result = this.searchResults.find((r) => r.elementId === id).data;
|
|
497
|
+
/* Sanity check */
|
|
498
|
+
/* istanbul ignore else */
|
|
499
|
+
if (result) {
|
|
500
|
+
this.searchText = result[this.descriptorProperty];
|
|
501
|
+
this.inputDirective.value = result;
|
|
502
|
+
this.selectionChange.emit({
|
|
503
|
+
selectedItem: result,
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
openDropdown() {
|
|
508
|
+
if (!this.overlay) {
|
|
509
|
+
const overlay = this.overlayService.create({
|
|
510
|
+
enableClose: false,
|
|
511
|
+
enablePointerEvents: true,
|
|
512
|
+
wrapperClass: this.wrapperClass,
|
|
513
|
+
});
|
|
514
|
+
overlay.attachTemplate(this.resultsTemplateRef);
|
|
515
|
+
this.overlay = overlay;
|
|
516
|
+
this.isOpen = true;
|
|
517
|
+
this.changeDetector.markForCheck();
|
|
518
|
+
this.initOverlayFocusableElements();
|
|
519
|
+
overlay.backdropClick
|
|
520
|
+
.pipe(takeUntil(this.ngUnsubscribe))
|
|
521
|
+
.subscribe(() => {
|
|
522
|
+
/* Sanity check as you should not be able to active the directive from the backdrop */
|
|
523
|
+
/* istanbul ignore else */
|
|
524
|
+
if (document.activeElement !== this.inputDirective.inputElement) {
|
|
525
|
+
this.inputDirective.restoreInputTextValueToPreviousState();
|
|
526
|
+
this.closeDropdown();
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
closeDropdown() {
|
|
532
|
+
this.resetSearch();
|
|
533
|
+
this.isOpen = false;
|
|
534
|
+
this.destroyOverlay();
|
|
535
|
+
this.removeActiveDescendant();
|
|
536
|
+
this.changeDetector.markForCheck();
|
|
537
|
+
}
|
|
538
|
+
setActiveDescendant() {
|
|
539
|
+
const activeElement = this.overlayFocusableElements[this.activeElementIndex];
|
|
540
|
+
/* Sanity check */
|
|
541
|
+
/* istanbul ignore else */
|
|
542
|
+
if (activeElement) {
|
|
543
|
+
this.inputDirective.setActiveDescendant(activeElement.id);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
removeActiveDescendant() {
|
|
547
|
+
/* tslint:disable-next-line:no-null-keyword */
|
|
548
|
+
this.inputDirective.setActiveDescendant(null);
|
|
549
|
+
}
|
|
550
|
+
resetSearch() {
|
|
551
|
+
this._searchResults = [];
|
|
552
|
+
this.searchText = '';
|
|
553
|
+
this._highlightText = [];
|
|
554
|
+
this.activeElementIndex = -1;
|
|
555
|
+
this.searchResultsCount = undefined;
|
|
556
|
+
this.removeActiveDescendant();
|
|
557
|
+
this.initOverlayFocusableElements();
|
|
558
|
+
this.changeDetector.markForCheck();
|
|
559
|
+
}
|
|
560
|
+
addInputEventListeners() {
|
|
561
|
+
const element = this.elementRef.nativeElement;
|
|
562
|
+
observableFromEvent(element, 'keydown')
|
|
563
|
+
.pipe(takeUntil(this.ngUnsubscribe))
|
|
564
|
+
.subscribe((event) => {
|
|
565
|
+
this.handleKeydown(event);
|
|
566
|
+
});
|
|
567
|
+
observableFromEvent(window, 'resize')
|
|
568
|
+
.pipe(takeUntil(this.ngUnsubscribe))
|
|
569
|
+
.subscribe(() => {
|
|
570
|
+
/* istanbul ignore else */
|
|
571
|
+
if (this.isOpen) {
|
|
572
|
+
this.adapterService.setDropdownWidth(this.elementRef, this.resultsRef, !!this.inputBoxHostSvc);
|
|
573
|
+
}
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
destroyOverlay() {
|
|
577
|
+
if (this.overlay) {
|
|
578
|
+
this.overlayService.close(this.overlay);
|
|
579
|
+
this.overlay = undefined;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
createAffixer() {
|
|
583
|
+
/* Sanity check */
|
|
584
|
+
/* istanbul ignore else */
|
|
585
|
+
if (!this.affixer) {
|
|
586
|
+
const affixer = this.affixService.createAffixer(this.resultsRef);
|
|
587
|
+
this.adapterService.setDropdownWidth(this.elementRef, this.resultsRef, !!this.inputBoxHostSvc);
|
|
588
|
+
affixer.affixTo(this.elementRef.nativeElement, {
|
|
589
|
+
autoFitContext: SkyAffixAutoFitContext.Viewport,
|
|
590
|
+
enableAutoFit: true,
|
|
591
|
+
isSticky: true,
|
|
592
|
+
placement: 'below',
|
|
593
|
+
horizontalAlignment: 'left',
|
|
594
|
+
});
|
|
595
|
+
this.affixer = affixer;
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
destroyAffixer() {
|
|
599
|
+
if (this.affixer) {
|
|
600
|
+
this.affixer.destroy();
|
|
601
|
+
this.affixer = undefined;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
initMessageStream() {
|
|
605
|
+
/* istanbul ignore if */
|
|
606
|
+
if (this.messageStreamSub) {
|
|
607
|
+
this.messageStreamSub.unsubscribe();
|
|
608
|
+
}
|
|
609
|
+
if (this.messageStream) {
|
|
610
|
+
this.messageStreamSub = this.messageStream
|
|
611
|
+
.pipe(takeUntil(this.ngUnsubscribe))
|
|
612
|
+
.subscribe((message) => {
|
|
613
|
+
/* tslint:disable-next-line:switch-default */
|
|
614
|
+
switch (message.type) {
|
|
615
|
+
case SkyAutocompleteMessageType.CloseDropdown:
|
|
616
|
+
this.closeDropdown();
|
|
617
|
+
break;
|
|
618
|
+
case SkyAutocompleteMessageType.RepositionDropdown:
|
|
619
|
+
// Settimeout waits for changes in DOM (e.g., tokens being removed)
|
|
620
|
+
setTimeout(() => {
|
|
621
|
+
/* istanbul ignore else */
|
|
622
|
+
if (this.affixer) {
|
|
623
|
+
this.affixer.reaffix();
|
|
624
|
+
}
|
|
625
|
+
});
|
|
626
|
+
break;
|
|
627
|
+
}
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
initOverlayFocusableElements() {
|
|
632
|
+
// Wait for dropdown elements to render.
|
|
633
|
+
setTimeout(() => {
|
|
634
|
+
if (this.overlay) {
|
|
635
|
+
this.overlayFocusableElements =
|
|
636
|
+
this.adapterService.getOverlayFocusableElements(this.overlay);
|
|
637
|
+
this.overlayFocusableElements.forEach((el) => {
|
|
638
|
+
this.adapterService.setTabIndex(el, -1);
|
|
639
|
+
});
|
|
640
|
+
this.addFocusedClass();
|
|
641
|
+
}
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
getActiveElement() {
|
|
645
|
+
return this.overlayFocusableElements[this.activeElementIndex];
|
|
646
|
+
}
|
|
647
|
+
removeFocusedClass() {
|
|
648
|
+
if (this.activeElementIndex > -1) {
|
|
649
|
+
this.adapterService.removeCSSClass(this.overlayFocusableElements[this.activeElementIndex], 'sky-autocomplete-descendant-focus');
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
addFocusedClass() {
|
|
653
|
+
if (this.activeElementIndex > -1) {
|
|
654
|
+
this.adapterService.addCSSClass(this.overlayFocusableElements[this.activeElementIndex], 'sky-autocomplete-descendant-focus');
|
|
655
|
+
this.setActiveDescendant();
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
SkyAutocompleteComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyAutocompleteComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: i1.SkyAffixService }, { token: i2.SkyAutocompleteAdapterService }, { token: i1.SkyOverlayService }, { token: i3.SkyInputBoxHostService, optional: true }], target: i0.ɵɵFactoryTarget.Component });
|
|
660
|
+
SkyAutocompleteComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: SkyAutocompleteComponent, selector: "sky-autocomplete", inputs: { ariaLabelledBy: "ariaLabelledBy", data: "data", debounceTime: "debounceTime", descriptorProperty: "descriptorProperty", enableShowMore: "enableShowMore", messageStream: "messageStream", wrapperClass: "wrapperClass", propertiesToSearch: "propertiesToSearch", search: "search", searchResultTemplate: "searchResultTemplate", searchTextMinimumCharacters: "searchTextMinimumCharacters", searchFilters: "searchFilters", searchResultsLimit: "searchResultsLimit", showAddButton: "showAddButton", noResultsFoundText: "noResultsFoundText", searchAsyncDisabled: "searchAsyncDisabled" }, outputs: { addClick: "addClick", showMoreClick: "showMoreClick", selectionChange: "selectionChange", searchAsync: "searchAsync" }, providers: [SkyAutocompleteAdapterService], queries: [{ propertyName: "inputDirective", first: true, predicate: SkyAutocompleteInputDirective, descendants: true }], viewQueries: [{ propertyName: "defaultSearchResultTemplate", first: true, predicate: ["defaultSearchResultTemplate"], descendants: true, read: TemplateRef }, { propertyName: "resultsTemplateRef", first: true, predicate: ["resultsTemplateRef"], descendants: true, read: TemplateRef }, { propertyName: "resultsRef", first: true, predicate: ["resultsRef"], descendants: true, read: ElementRef }], ngImport: i0, template: "<div\n aria-autocomplete=\"list\"\n aria-haspopup=\"listbox\"\n class=\"sky-autocomplete\"\n role=\"combobox\"\n [attr.aria-expanded]=\"isOpen && searchText\"\n [attr.aria-labelledby]=\"ariaLabelledBy\"\n [attr.aria-owns]=\"isOpen ? resultsListId : null\"\n [attr.id]=\"resultsWrapperId\"\n>\n <ng-content></ng-content>\n</div>\n\n<ng-template #resultsTemplateRef>\n <div\n class=\"sky-autocomplete-results-container\"\n [skyThemeClass]=\"{\n 'sky-shadow': 'default',\n 'sky-elevation-4': 'modern'\n }\"\n (keydown)=\"handleKeydown($event)\"\n #resultsRef\n >\n <div\n *ngIf=\"isSearchingAsync; else resultControlsTemplateRef\"\n class=\"sky-autocomplete-results-waiting\"\n >\n <sky-wait [isWaiting]=\"true\"></sky-wait>\n </div>\n </div>\n</ng-template>\n\n<ng-template #resultControlsTemplateRef>\n <div\n *ngIf=\"searchText && (!showActionsArea || searchResults.length > 0)\"\n class=\"sky-autocomplete-results\"\n role=\"listbox\"\n [attr.aria-labelledby]=\"ariaLabelledBy\"\n [attr.id]=\"resultsListId\"\n >\n <ng-container *ngFor=\"let result of searchResults; let i = index\">\n <div\n *ngIf=\"!searchResultsLimit || i < searchResultsLimit\"\n class=\"sky-autocomplete-result\"\n role=\"option\"\n tabindex=\"0\"\n [attr.aria-selected]=\"isElementFocused(searchResultEl)\"\n [attr.id]=\"result.elementId\"\n [skyHighlight]=\"highlightText\"\n (mousedown)=\"onResultMouseDown(result.elementId, $event)\"\n (mousemove)=\"onResultMouseMove(i)\"\n #searchResultEl\n >\n <ng-container\n *ngTemplateOutlet=\"\n searchResultTemplate;\n context: { item: result.data }\n \"\n >\n </ng-container>\n </div>\n </ng-container>\n <div\n *ngIf=\"searchResults.length === 0\"\n class=\"sky-deemphasized sky-padding-squish-default\"\n >\n {{\n noResultsFoundText ||\n ('skyux_autocomplete_no_results' | skyLibResources)\n }}\n </div>\n </div>\n <div *ngIf=\"showActionsArea\" class=\"sky-autocomplete-actions\">\n <button\n *ngIf=\"enableShowMore && (!searchText || searchResults.length > 0)\"\n class=\"\n sky-autocomplete-action\n sky-autocomplete-action-more\n sky-btn\n sky-btn-link\n \"\n type=\"button\"\n (click)=\"moreButtonClicked()\"\n >\n <ng-container\n *ngIf=\"\n !(\n searchAsync\n | skyAutocompleteSearchAsyncDisabled: searchAsyncDisabled\n ) &&\n searchResults.length === 0 &&\n !searchText\n \"\n >\n {{ 'skyux_autocomplete_show_all' | skyLibResources }}\n </ng-container>\n <ng-container\n *ngIf=\"\n (searchAsync\n | skyAutocompleteSearchAsyncDisabled: searchAsyncDisabled) &&\n !searchText\n \"\n >\n {{\n 'skyux_autocomplete_show_all_count'\n | skyLibResources: (data.length | skyNumeric: { truncate: false })\n }}\n </ng-container>\n <ng-container *ngIf=\"searchText\">\n {{\n 'skyux_autocomplete_show_matches_count'\n | skyLibResources\n : (searchResultsCount === undefined\n ? data.length\n : (searchResultsCount | skyNumeric: { truncate: false }))\n }}\n </ng-container>\n </button>\n <div\n *ngIf=\"searchText && searchResults.length === 0\"\n class=\"sky-font-deemphasized sky-autocomplete-actions-no-results\"\n >\n {{\n noResultsFoundText ||\n ('skyux_autocomplete_no_results' | skyLibResources)\n }}\n </div>\n <button\n *ngIf=\"showAddButton\"\n class=\"\n sky-autocomplete-action sky-autocomplete-action-add sky-btn sky-btn-link\n \"\n tabindex=\"0\"\n type=\"button\"\n [class.focused]=\"isElementFocused(addButtonEl)\"\n (click)=\"addButtonClicked()\"\n #addButtonEl\n >\n <sky-icon *skyThemeIf=\"'modern'\" icon=\"add\" iconType=\"skyux\"></sky-icon>\n <sky-icon *skyThemeIf=\"'default'\" icon=\"plus-circle\"></sky-icon>\n {{ 'skyux_autocomplete_add' | skyLibResources }}\n </button>\n </div>\n</ng-template>\n\n<ng-template let-item=\"item\" #defaultSearchResultTemplate>\n {{ item[descriptorProperty] }}\n</ng-template>\n", styles: [".sky-autocomplete-results-container{position:fixed;background-color:#fff}.sky-autocomplete-results-waiting{height:70px}.sky-autocomplete-results{display:flex;flex-direction:column;padding:4px;overflow-y:auto;overflow-x:hidden;min-height:35px;max-height:calc(50vh - 50px)}.sky-autocomplete-result{color:#212327;margin-bottom:4px;padding:3px 20px;cursor:pointer}.sky-autocomplete-result:last-child{margin-bottom:0}.sky-autocomplete-actions{border-top:1px solid #cdcfd2}.sky-autocomplete-actions .sky-autocomplete-action{border:none}.sky-autocomplete-actions .sky-autocomplete-actions-no-results{display:inline-block;padding:7px 13px}.sky-autocomplete-action-add{float:right}.sky-autocomplete-action-add sky-icon{padding-right:5px}.sky-autocomplete-descendant-focus:not(.sky-autocomplete-action){background-color:#eeeeef}.sky-autocomplete-descendant-focus.sky-autocomplete-action{outline:thin dotted;outline:-webkit-focus-ring-color auto 5px}::ng-deep .sky-theme-modern .sky-autocomplete-results-container{border-radius:6px}::ng-deep .sky-theme-modern .sky-autocomplete-results{padding:10px 0}::ng-deep .sky-theme-modern .sky-autocomplete-result{margin-bottom:0;padding:10px 0 10px 15px}::ng-deep .sky-theme-modern .sky-autocomplete-descendant-focus:not(.sky-autocomplete-action){background-color:inherit}::ng-deep .sky-theme-modern .sky-autocomplete-descendant-focus{border:none;box-shadow:inset 0 0 0 2px #1870b8,0 1px 8px #0000004d}\n"], components: [{ type: i4.λ14, selector: "sky-wait", inputs: ["ariaLabel", "isWaiting", "isFullPage", "isNonBlocking"] }, { type: i4.λ4, selector: "sky-icon", inputs: ["icon", "iconType", "size", "fixedWidth", "variant"] }], directives: [{ type: i5.λ2, selector: "[skyThemeClass]", inputs: ["class", "skyThemeClass"] }, { type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i6.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i4.λ11, selector: "[skyHighlight]", inputs: ["skyHighlight"] }, { type: i6.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i5.λ3, selector: "[skyThemeIf]", inputs: ["skyThemeIf"] }], pipes: { "skyLibResources": i7.SkyLibResourcesPipe, "skyAutocompleteSearchAsyncDisabled": i8.SkyAutcompleteSearchAsyncDisabledPipe, "skyNumeric": i1.SkyNumericPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
661
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyAutocompleteComponent, decorators: [{
|
|
662
|
+
type: Component,
|
|
663
|
+
args: [{
|
|
664
|
+
selector: 'sky-autocomplete',
|
|
665
|
+
templateUrl: './autocomplete.component.html',
|
|
666
|
+
styleUrls: ['./autocomplete.component.scss'],
|
|
667
|
+
providers: [SkyAutocompleteAdapterService],
|
|
668
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
669
|
+
}]
|
|
670
|
+
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: i1.SkyAffixService }, { type: i2.SkyAutocompleteAdapterService }, { type: i1.SkyOverlayService }, { type: i3.SkyInputBoxHostService, decorators: [{
|
|
671
|
+
type: Optional
|
|
672
|
+
}] }]; }, propDecorators: { ariaLabelledBy: [{
|
|
673
|
+
type: Input
|
|
674
|
+
}], data: [{
|
|
675
|
+
type: Input
|
|
676
|
+
}], debounceTime: [{
|
|
677
|
+
type: Input
|
|
678
|
+
}], descriptorProperty: [{
|
|
679
|
+
type: Input
|
|
680
|
+
}], enableShowMore: [{
|
|
681
|
+
type: Input
|
|
682
|
+
}], messageStream: [{
|
|
683
|
+
type: Input
|
|
684
|
+
}], wrapperClass: [{
|
|
685
|
+
type: Input
|
|
686
|
+
}], propertiesToSearch: [{
|
|
687
|
+
type: Input
|
|
688
|
+
}], search: [{
|
|
689
|
+
type: Input
|
|
690
|
+
}], searchResultTemplate: [{
|
|
691
|
+
type: Input
|
|
692
|
+
}], searchTextMinimumCharacters: [{
|
|
693
|
+
type: Input
|
|
694
|
+
}], searchFilters: [{
|
|
695
|
+
type: Input
|
|
696
|
+
}], searchResultsLimit: [{
|
|
697
|
+
type: Input
|
|
698
|
+
}], showAddButton: [{
|
|
699
|
+
type: Input
|
|
700
|
+
}], noResultsFoundText: [{
|
|
701
|
+
type: Input
|
|
702
|
+
}], searchAsyncDisabled: [{
|
|
703
|
+
type: Input
|
|
704
|
+
}], addClick: [{
|
|
705
|
+
type: Output
|
|
706
|
+
}], showMoreClick: [{
|
|
707
|
+
type: Output
|
|
708
|
+
}], selectionChange: [{
|
|
709
|
+
type: Output
|
|
710
|
+
}], searchAsync: [{
|
|
711
|
+
type: Output
|
|
712
|
+
}], defaultSearchResultTemplate: [{
|
|
713
|
+
type: ViewChild,
|
|
714
|
+
args: ['defaultSearchResultTemplate', {
|
|
715
|
+
read: TemplateRef,
|
|
716
|
+
static: false,
|
|
717
|
+
}]
|
|
718
|
+
}], inputDirective: [{
|
|
719
|
+
type: ContentChild,
|
|
720
|
+
args: [SkyAutocompleteInputDirective]
|
|
721
|
+
}], resultsTemplateRef: [{
|
|
722
|
+
type: ViewChild,
|
|
723
|
+
args: ['resultsTemplateRef', {
|
|
724
|
+
read: TemplateRef,
|
|
725
|
+
}]
|
|
726
|
+
}], resultsRef: [{
|
|
727
|
+
type: ViewChild,
|
|
728
|
+
args: ['resultsRef', {
|
|
729
|
+
read: ElementRef,
|
|
730
|
+
}]
|
|
731
|
+
}] } });
|
|
732
|
+
//# sourceMappingURL=autocomplete.component.js.map
|