@fluid-topics/ft-search-bar 1.2.60 → 1.2.62
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/build/ft-search-bar.d.ts +8 -5
- package/build/ft-search-bar.js +40 -16
- package/build/ft-search-bar.light.js +478 -429
- package/build/ft-search-bar.min.js +286 -237
- package/build/ft-search-bar.properties.d.ts +2 -0
- package/build/ft-search-bar.styles.d.ts +1 -0
- package/build/ft-search-bar.styles.js +8 -0
- package/build/managers/DesktopSearchBarManager.d.ts +2 -0
- package/build/managers/DesktopSearchBarManager.js +57 -5
- package/build/managers/MobileSearchBarManager.js +40 -2
- package/build/managers/SuggestManager.d.ts +16 -6
- package/build/managers/SuggestManager.js +116 -57
- package/package.json +16 -16
package/build/ft-search-bar.d.ts
CHANGED
|
@@ -59,6 +59,9 @@ export declare class FtSearchBar extends FtLitElement implements FtSearchBarProp
|
|
|
59
59
|
scrollToFacet?: string;
|
|
60
60
|
api?: FluidTopicsApi;
|
|
61
61
|
reactToFocus: boolean;
|
|
62
|
+
displaySuggestListbox: boolean;
|
|
63
|
+
selectedSuggestOptionId?: string;
|
|
64
|
+
selectedSuggestRemoveRecent?: boolean;
|
|
62
65
|
suggestManager: SuggestManager;
|
|
63
66
|
selectedFacetsManager: FacetsChipsManager;
|
|
64
67
|
desktopSearchBarManager: DesktopSearchBarManager;
|
|
@@ -75,10 +78,11 @@ export declare class FtSearchBar extends FtLitElement implements FtSearchBarProp
|
|
|
75
78
|
focusInput(react?: boolean): Promise<void>;
|
|
76
79
|
clear(): void;
|
|
77
80
|
protected render(): import("lit-html").TemplateResult<1>;
|
|
81
|
+
private renderLiveText;
|
|
78
82
|
protected renderSearchBar(): import("lit-html").TemplateResult<1>;
|
|
79
83
|
renderMobileFacets(): import("lit-html").TemplateResult<1>;
|
|
80
84
|
private getContentLocaleRadioGroup;
|
|
81
|
-
renderDesktopMenu(): import("lit-html").TemplateResult<1
|
|
85
|
+
renderDesktopMenu(): typeof nothing | import("lit-html").TemplateResult<1>;
|
|
82
86
|
renderFacetsActions(): import("lit-html").TemplateResult<1>;
|
|
83
87
|
private renderDesktopClearFilters;
|
|
84
88
|
private renderDesktopFacets;
|
|
@@ -101,6 +105,7 @@ export declare class FtSearchBar extends FtLitElement implements FtSearchBarProp
|
|
|
101
105
|
private initRecentSearches;
|
|
102
106
|
saveRecentSearches(): void;
|
|
103
107
|
private closeFloatingContainer;
|
|
108
|
+
private closeSuggestListbox;
|
|
104
109
|
connectedCallback(): Promise<void>;
|
|
105
110
|
disconnectedCallback(): void;
|
|
106
111
|
private updateSize;
|
|
@@ -115,8 +120,6 @@ export declare class FtSearchBar extends FtLitElement implements FtSearchBarProp
|
|
|
115
120
|
private clearFilters;
|
|
116
121
|
querySelector(selectors: string): HTMLElement | null;
|
|
117
122
|
querySelectorAll(selectors: string): NodeListOf<HTMLElement>;
|
|
118
|
-
renderDesktopFloatingMenu(): import("lit-html").TemplateResult<1
|
|
119
|
-
|
|
120
|
-
private enableFocusReactionOnAnyUserInteraction;
|
|
121
|
-
private enableFocusReaction;
|
|
123
|
+
renderDesktopFloatingMenu(): typeof nothing | import("lit-html").TemplateResult<1>;
|
|
124
|
+
get ariaActiveDescendent(): string | undefined;
|
|
122
125
|
}
|
package/build/ft-search-bar.js
CHANGED
|
@@ -83,6 +83,8 @@ class FtSearchBar extends FtLitElement {
|
|
|
83
83
|
this.suggestions = [];
|
|
84
84
|
this.recentSearches = [];
|
|
85
85
|
this.reactToFocus = true;
|
|
86
|
+
this.displaySuggestListbox = false;
|
|
87
|
+
this.selectedSuggestRemoveRecent = false;
|
|
86
88
|
this.suggestManager = new SuggestManager(this);
|
|
87
89
|
this.selectedFacetsManager = new FacetsChipsManager(this);
|
|
88
90
|
this.desktopSearchBarManager = new DesktopSearchBarManager(this);
|
|
@@ -115,6 +117,14 @@ class FtSearchBar extends FtLitElement {
|
|
|
115
117
|
this.displayFacets = this.displayFacets && e.composedPath().some(element => element === this.floatingContainer);
|
|
116
118
|
}
|
|
117
119
|
};
|
|
120
|
+
this.closeSuggestListbox = (e) => {
|
|
121
|
+
const path = e.composedPath();
|
|
122
|
+
const inside = path.some(n => n === this || n === this.shadowRoot);
|
|
123
|
+
if (!inside) {
|
|
124
|
+
this.displaySuggestListbox = false;
|
|
125
|
+
this.selectedSuggestOptionId = undefined;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
118
128
|
this.compareUnknownFilters = (a, b) => {
|
|
119
129
|
if (a.valueFilter && b.valueFilter) {
|
|
120
130
|
return this.compareValueFilters(a.valueFilter, b.valueFilter);
|
|
@@ -138,7 +148,6 @@ class FtSearchBar extends FtLitElement {
|
|
|
138
148
|
this.compareRequests = (a, b) => (a.contentLocale == null || b.contentLocale == null || a.contentLocale === b.contentLocale)
|
|
139
149
|
&& a.metadataFilters.length === b.metadataFilters.length
|
|
140
150
|
&& a.metadataFilters.every(fa => b.metadataFilters.some(fb => this.compareFilters(fa, fb)));
|
|
141
|
-
this.enableFocusReactionCallback = () => this.enableFocusReaction();
|
|
142
151
|
}
|
|
143
152
|
isMobileMenuOpen() {
|
|
144
153
|
return this.isMobile() && (this.forceMobileMenuOpen || this.forceMenuOpen || this.mobileMenuOpen);
|
|
@@ -198,9 +207,7 @@ class FtSearchBar extends FtLitElement {
|
|
|
198
207
|
this.reactToFocus = react;
|
|
199
208
|
await waitFor(() => this.input, 50);
|
|
200
209
|
this.input.focus();
|
|
201
|
-
|
|
202
|
-
this.enableFocusReactionOnAnyUserInteraction();
|
|
203
|
-
}
|
|
210
|
+
this.reactToFocus = true;
|
|
204
211
|
}
|
|
205
212
|
clear() {
|
|
206
213
|
this.query = "";
|
|
@@ -214,9 +221,20 @@ class FtSearchBar extends FtLitElement {
|
|
|
214
221
|
render() {
|
|
215
222
|
return html `
|
|
216
223
|
<ft-size-watcher @change=${this.updateSize}></ft-size-watcher>
|
|
224
|
+
<div class="ft-search-bar--aria-live" aria-live="polite" aria-atomic="true">
|
|
225
|
+
${this.renderLiveText()}
|
|
226
|
+
</div>
|
|
217
227
|
${this.renderSearchBar()}
|
|
218
228
|
`;
|
|
219
229
|
}
|
|
230
|
+
renderLiveText() {
|
|
231
|
+
if (this.suggestManager.shouldDisplaySuggestions) {
|
|
232
|
+
return this.labelResolver.resolve("ariaLiveSuggestions", this.suggestManager.recentSearchesMatchingQuery.length, this.suggestions.length);
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
return "";
|
|
236
|
+
}
|
|
237
|
+
}
|
|
220
238
|
renderSearchBar() {
|
|
221
239
|
if (this.facetsInitialized && this.availableContentLocalesInitialized) {
|
|
222
240
|
return this.isMobile() ? this.mobileSearchBarManager.render() : this.desktopSearchBarManager.render();
|
|
@@ -574,6 +592,7 @@ class FtSearchBar extends FtLitElement {
|
|
|
574
592
|
}
|
|
575
593
|
async connectedCallback() {
|
|
576
594
|
super.connectedCallback();
|
|
595
|
+
document.addEventListener("pointerdown", this.closeSuggestListbox);
|
|
577
596
|
document.addEventListener("focusin", this.closeFloatingContainer);
|
|
578
597
|
document.addEventListener("click", this.closeFloatingContainer);
|
|
579
598
|
if (this.focusOnDisplay && !isTouchScreen) {
|
|
@@ -584,8 +603,9 @@ class FtSearchBar extends FtLitElement {
|
|
|
584
603
|
}
|
|
585
604
|
disconnectedCallback() {
|
|
586
605
|
super.disconnectedCallback();
|
|
606
|
+
document.removeEventListener("pointerdown", this.closeSuggestListbox);
|
|
587
607
|
document.removeEventListener("focusin", this.closeFloatingContainer);
|
|
588
|
-
document.
|
|
608
|
+
document.removeEventListener("click", this.closeFloatingContainer);
|
|
589
609
|
ftAppInfoStore.removeEventListener("authentication-change", this.initSearchData);
|
|
590
610
|
}
|
|
591
611
|
updateSize(e) {
|
|
@@ -640,16 +660,14 @@ class FtSearchBar extends FtLitElement {
|
|
|
640
660
|
${this.renderDesktopMenu()}
|
|
641
661
|
</div>`;
|
|
642
662
|
}
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
this.removeEventListener("click", this.enableFocusReactionCallback);
|
|
652
|
-
this.removeEventListener("keyup", this.enableFocusReactionCallback);
|
|
663
|
+
get ariaActiveDescendent() {
|
|
664
|
+
if (!this.selectedSuggestOptionId) {
|
|
665
|
+
return undefined;
|
|
666
|
+
}
|
|
667
|
+
if (this.selectedSuggestRemoveRecent) {
|
|
668
|
+
return "remove-" + this.selectedSuggestOptionId;
|
|
669
|
+
}
|
|
670
|
+
return this.selectedSuggestOptionId;
|
|
653
671
|
}
|
|
654
672
|
}
|
|
655
673
|
FtSearchBar.elementDefinitions = {
|
|
@@ -783,7 +801,13 @@ __decorate([
|
|
|
783
801
|
], FtSearchBar.prototype, "api", void 0);
|
|
784
802
|
__decorate([
|
|
785
803
|
state()
|
|
786
|
-
], FtSearchBar.prototype, "
|
|
804
|
+
], FtSearchBar.prototype, "displaySuggestListbox", void 0);
|
|
805
|
+
__decorate([
|
|
806
|
+
state()
|
|
807
|
+
], FtSearchBar.prototype, "selectedSuggestOptionId", void 0);
|
|
808
|
+
__decorate([
|
|
809
|
+
state()
|
|
810
|
+
], FtSearchBar.prototype, "selectedSuggestRemoveRecent", void 0);
|
|
787
811
|
__decorate([
|
|
788
812
|
state()
|
|
789
813
|
], FtSearchBar.prototype, "facetsLoaded", void 0);
|