@fluid-topics/ft-search-bar 0.2.15 → 0.2.18
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.css.d.ts +1 -0
- package/build/ft-search-bar.css.js +34 -14
- package/build/ft-search-bar.d.ts +5 -1
- package/build/ft-search-bar.js +110 -51
- package/build/ft-search-bar.light.js +350 -281
- package/build/ft-search-bar.min.js +454 -385
- package/package.json +14 -14
- package/build/ft-search-bar.inline-styles.js +0 -2582
- package/build/inline-styles.d.ts +0 -2
- package/build/inline-styles.js +0 -4
|
@@ -7,6 +7,7 @@ export declare const FtSearchBarCssVariables: {
|
|
|
7
7
|
mobileOpenBottom: FtCssVariable;
|
|
8
8
|
mobileOpenLeft: FtCssVariable;
|
|
9
9
|
mobileOpenRight: FtCssVariable;
|
|
10
|
+
desktopFiltersHeight: FtCssVariable;
|
|
10
11
|
floatingZIndex: FtCssVariable;
|
|
11
12
|
colorSurface: FtCssVariable;
|
|
12
13
|
colorOnSurface: FtCssVariable;
|
|
@@ -6,6 +6,7 @@ import { FtSelectCssVariables } from "@fluid-topics/ft-select";
|
|
|
6
6
|
import { FtSnapScrollCssVariables } from "@fluid-topics/ft-snap-scroll";
|
|
7
7
|
import { FtChipCssVariables } from "@fluid-topics/ft-chip";
|
|
8
8
|
import { FtSkeletonCssVariables } from "@fluid-topics/ft-skeleton";
|
|
9
|
+
import { FtTooltipCssVariables } from "@fluid-topics/ft-tooltip";
|
|
9
10
|
export const FtSearchBarCssVariables = {
|
|
10
11
|
height: FtCssVariable.create("--ft-search-bar-height", "SIZE", "38px"),
|
|
11
12
|
borderRadius: FtCssVariable.extend("--ft-search-bar-border-radius", designSystemVariables.borderRadiusS),
|
|
@@ -14,7 +15,8 @@ export const FtSearchBarCssVariables = {
|
|
|
14
15
|
mobileOpenBottom: FtCssVariable.create("--ft-search-bar-mobile-open-bottom", "SIZE", "0"),
|
|
15
16
|
mobileOpenLeft: FtCssVariable.create("--ft-search-bar-mobile-open-left", "SIZE", "0"),
|
|
16
17
|
mobileOpenRight: FtCssVariable.create("--ft-search-bar-mobile-open-right", "SIZE", "0"),
|
|
17
|
-
|
|
18
|
+
desktopFiltersHeight: FtCssVariable.create("--ft-search-bar-desktop-filters-height", "SIZE", "350px"),
|
|
19
|
+
floatingZIndex: FtCssVariable.create("--ft-search-bar-floating-components-z-index", "NUMBER", "3"),
|
|
18
20
|
colorSurface: FtCssVariable.external(designSystemVariables.colorSurface, "Design system"),
|
|
19
21
|
colorOnSurface: FtCssVariable.external(designSystemVariables.colorOnSurface, "Design system"),
|
|
20
22
|
colorOnSurfaceMedium: FtCssVariable.external(designSystemVariables.colorOnSurfaceMedium, "Design system"),
|
|
@@ -50,9 +52,16 @@ export const searchBarCss = css `
|
|
|
50
52
|
right: ${FtSearchBarCssVariables.mobileOpenRight};
|
|
51
53
|
z-index: ${FtSearchBarCssVariables.floatingZIndex};
|
|
52
54
|
padding: 16px;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.ft-search-bar--mobile-menu-open:not(.ft-search-bar--forced-open) {
|
|
53
58
|
background: ${FtSearchBarCssVariables.colorSurface};
|
|
54
59
|
}
|
|
55
60
|
|
|
61
|
+
.ft-search-bar--mobile-menu-open.ft-search-bar--forced-open {
|
|
62
|
+
position: ${FtSearchBarCssVariables.mobileOpenPosition.get("static")};
|
|
63
|
+
}
|
|
64
|
+
|
|
56
65
|
.ft-search-bar {
|
|
57
66
|
position: relative;
|
|
58
67
|
display: flex;
|
|
@@ -106,12 +115,12 @@ export const searchBarCss = css `
|
|
|
106
115
|
flex-grow: 1;
|
|
107
116
|
border: none;
|
|
108
117
|
background-color: transparent;
|
|
118
|
+
color: ${FtSearchBarCssVariables.colorOnSurface};
|
|
109
119
|
outline: none;
|
|
110
120
|
}
|
|
111
121
|
|
|
112
|
-
.ft-search-bar--
|
|
113
|
-
|
|
114
|
-
min-width: 250px;
|
|
122
|
+
.ft-search-bar--input::placeholder {
|
|
123
|
+
color: ${FtSearchBarCssVariables.colorOnSurfaceMedium};
|
|
115
124
|
}
|
|
116
125
|
|
|
117
126
|
.ft-search-bar--actions {
|
|
@@ -121,7 +130,7 @@ export const searchBarCss = css `
|
|
|
121
130
|
align-items: center;
|
|
122
131
|
height: 100%;
|
|
123
132
|
|
|
124
|
-
|
|
133
|
+
${setVariable(FtTooltipCssVariables.zIndex, `calc(${FtSearchBarCssVariables.floatingZIndex} + 1)`)};
|
|
125
134
|
}
|
|
126
135
|
|
|
127
136
|
.ft-search-bar > ft-button,
|
|
@@ -179,23 +188,31 @@ export const searchBarCss = css `
|
|
|
179
188
|
`;
|
|
180
189
|
//language=css
|
|
181
190
|
export const facetsCss = css `
|
|
182
|
-
.ft-search-bar--
|
|
191
|
+
.ft-search-bar--desktop-menu .ft-search-bar--presets {
|
|
183
192
|
margin-right: auto;
|
|
184
193
|
}
|
|
185
194
|
|
|
186
|
-
.ft-search-bar--
|
|
195
|
+
.ft-search-bar--desktop-menu .ft-search-bar--presets {
|
|
187
196
|
min-width: 250px;
|
|
188
197
|
${setVariable(FtSelectCssVariables.optionsZIndex, "2")};
|
|
189
198
|
}
|
|
190
199
|
|
|
191
|
-
.ft-search-bar--
|
|
200
|
+
.ft-search-bar--desktop-menu {
|
|
201
|
+
display: flex;
|
|
192
202
|
flex-direction: column;
|
|
193
203
|
gap: 16px;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.ft-search-bar + .ft-search-bar--desktop-menu {
|
|
207
|
+
margin-top: 8px;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.ft-search-bar--floating-panel {
|
|
194
211
|
padding: 16px;
|
|
195
212
|
}
|
|
196
213
|
|
|
197
214
|
.ft-search-bar--floating-panel-open .ft-search-bar--floating-panel {
|
|
198
|
-
display:
|
|
215
|
+
display: block;
|
|
199
216
|
}
|
|
200
217
|
|
|
201
218
|
.ft-search-bar--desktop .ft-search-bar--facets-actions {
|
|
@@ -203,6 +220,9 @@ export const facetsCss = css `
|
|
|
203
220
|
align-items: center;
|
|
204
221
|
justify-content: flex-end;
|
|
205
222
|
gap: 8px;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.ft-search-bar--floating-panel .ft-search-bar--facets-actions {
|
|
206
226
|
padding: 0 10px;
|
|
207
227
|
}
|
|
208
228
|
|
|
@@ -224,13 +244,13 @@ export const facetsCss = css `
|
|
|
224
244
|
display: none;
|
|
225
245
|
}
|
|
226
246
|
|
|
227
|
-
.ft-search-bar--
|
|
247
|
+
.ft-search-bar--desktop-menu .ft-search-bar--filters-container {
|
|
228
248
|
display: block;
|
|
229
|
-
height:
|
|
249
|
+
height: ${FtSearchBarCssVariables.desktopFiltersHeight};
|
|
230
250
|
--ft-snap-scroll-gap: 16px;
|
|
231
251
|
}
|
|
232
252
|
|
|
233
|
-
.ft-search-bar--
|
|
253
|
+
.ft-search-bar--desktop-menu ft-filter {
|
|
234
254
|
display: flex;
|
|
235
255
|
flex-grow: 0;
|
|
236
256
|
max-height: 100%;
|
|
@@ -294,7 +314,7 @@ export const facetsCss = css `
|
|
|
294
314
|
padding-right: 0;
|
|
295
315
|
}
|
|
296
316
|
|
|
297
|
-
.ft-search-bar--
|
|
317
|
+
.ft-search-bar--desktop-menu .ft-search-bar--launch-search {
|
|
298
318
|
margin: 0;
|
|
299
319
|
}
|
|
300
320
|
`;
|
|
@@ -350,7 +370,7 @@ export const suggestionsCss = css `
|
|
|
350
370
|
.ft-search-bar--floating-panel,
|
|
351
371
|
.ft-search-bar--desktop .ft-search-bar--suggestions {
|
|
352
372
|
position: absolute;
|
|
353
|
-
z-index:
|
|
373
|
+
z-index: ${FtSearchBarCssVariables.floatingZIndex};
|
|
354
374
|
top: 100%;
|
|
355
375
|
left: -1px;
|
|
356
376
|
right: -1px;
|
package/build/ft-search-bar.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export interface FtSearchBarLabels extends ParametrizedLabels {
|
|
|
16
16
|
clearInputButton?: string;
|
|
17
17
|
clearFilterButton?: string;
|
|
18
18
|
displayMoreFilterValuesButton?: string;
|
|
19
|
+
noFilterValuesAvailable?: string;
|
|
19
20
|
searchButton?: string;
|
|
20
21
|
noSuggestions?: string;
|
|
21
22
|
contentLocaleSelector?: string;
|
|
@@ -28,7 +29,7 @@ export declare type DisplayMode = "auto" | "mobile" | "desktop";
|
|
|
28
29
|
export interface FtSearchBarProperties {
|
|
29
30
|
labels?: FtSearchBarLabels;
|
|
30
31
|
mode?: DisplayMode;
|
|
31
|
-
|
|
32
|
+
forceMenuOpen?: boolean;
|
|
32
33
|
baseUrl: string;
|
|
33
34
|
apiIntegrationIdentifier?: string;
|
|
34
35
|
contentLocale?: string;
|
|
@@ -52,6 +53,7 @@ export declare class FtSearchBar extends FtLitElement implements FtSearchBarProp
|
|
|
52
53
|
dense: boolean;
|
|
53
54
|
mode?: DisplayMode;
|
|
54
55
|
forceMobileMenuOpen: boolean;
|
|
56
|
+
forceMenuOpen: boolean;
|
|
55
57
|
baseUrl: string;
|
|
56
58
|
apiIntegrationIdentifier: string;
|
|
57
59
|
contentLocale?: string;
|
|
@@ -107,9 +109,11 @@ export declare class FtSearchBar extends FtLitElement implements FtSearchBarProp
|
|
|
107
109
|
private renderMobileFacets;
|
|
108
110
|
private contentLocalesAsFilterOptions;
|
|
109
111
|
private renderDesktopSearchBar;
|
|
112
|
+
private renderDesktopMenu;
|
|
110
113
|
private renderSearchBarLeftAction;
|
|
111
114
|
private renderDesktopSearchBarButtons;
|
|
112
115
|
private renderFacetsActions;
|
|
116
|
+
private renderDesktopClearFilters;
|
|
113
117
|
private renderDesktopFacets;
|
|
114
118
|
private renderSelectedFacets;
|
|
115
119
|
private renderSuggestions;
|
package/build/ft-search-bar.js
CHANGED
|
@@ -34,6 +34,7 @@ export const DEFAULT_LABELS = {
|
|
|
34
34
|
clearInputButton: "Clear",
|
|
35
35
|
clearFilterButton: "Clear",
|
|
36
36
|
displayMoreFilterValuesButton: "More",
|
|
37
|
+
noFilterValuesAvailable: "No values available",
|
|
37
38
|
searchButton: "Search",
|
|
38
39
|
noSuggestions: "No results found…",
|
|
39
40
|
clearFilters: "Clear filters",
|
|
@@ -57,12 +58,15 @@ export class SearchStateChangeEvent extends CustomEvent {
|
|
|
57
58
|
super("change", { detail: request });
|
|
58
59
|
}
|
|
59
60
|
}
|
|
61
|
+
const doNothing = () => {
|
|
62
|
+
};
|
|
60
63
|
export class FtSearchBar extends FtLitElement {
|
|
61
64
|
constructor() {
|
|
62
65
|
super(...arguments);
|
|
63
66
|
this.dense = false;
|
|
64
67
|
this.mode = "auto";
|
|
65
68
|
this.forceMobileMenuOpen = false;
|
|
69
|
+
this.forceMenuOpen = false;
|
|
66
70
|
this.baseUrl = "";
|
|
67
71
|
this.apiIntegrationIdentifier = "ft-search-bar";
|
|
68
72
|
this.availableContentLocales = [];
|
|
@@ -79,7 +83,7 @@ export class FtSearchBar extends FtLitElement {
|
|
|
79
83
|
this.mobileMenuOpen = false;
|
|
80
84
|
this.facets = [];
|
|
81
85
|
this.facetsInitialized = false;
|
|
82
|
-
this.knownFacetLabels =
|
|
86
|
+
this.knownFacetLabels = new Map();
|
|
83
87
|
this.query = "";
|
|
84
88
|
this.suggestions = [];
|
|
85
89
|
this.suggestionsLoaded = true;
|
|
@@ -101,7 +105,7 @@ export class FtSearchBar extends FtLitElement {
|
|
|
101
105
|
&& a.filters.every(fa => b.filters.some(fb => this.compareFilters(fa, fb)));
|
|
102
106
|
}
|
|
103
107
|
get isMobileMenuOpen() {
|
|
104
|
-
return this.forceMobileMenuOpen || this.mobileMenuOpen;
|
|
108
|
+
return this.isMobile && (this.forceMobileMenuOpen || this.forceMenuOpen || this.mobileMenuOpen);
|
|
105
109
|
}
|
|
106
110
|
get recentSearchesStorageKey() {
|
|
107
111
|
return this.baseUrl + ":ft:recent-search-queries";
|
|
@@ -119,7 +123,8 @@ export class FtSearchBar extends FtLitElement {
|
|
|
119
123
|
};
|
|
120
124
|
}
|
|
121
125
|
get facetsRequest() {
|
|
122
|
-
const fromFilters = this.searchFilters.filter(f => !this.displayedFilters.includes(f.key))
|
|
126
|
+
const fromFilters = this.searchFilters.filter(f => f.values.length > 0 && !this.displayedFilters.includes(f.key))
|
|
127
|
+
.map(f => ({ id: f.key }));
|
|
123
128
|
return [...this.displayedFilters.map(id => ({ id })), ...fromFilters];
|
|
124
129
|
}
|
|
125
130
|
get suggestRequest() {
|
|
@@ -177,8 +182,9 @@ export class FtSearchBar extends FtLitElement {
|
|
|
177
182
|
"ft-search-bar--dense": !this.isMobile && this.dense,
|
|
178
183
|
"ft-search-bar--mobile": this.isMobile,
|
|
179
184
|
"ft-search-bar--desktop": !this.isMobile,
|
|
180
|
-
"ft-search-bar--floating-panel-open": !this.isMobile && this.displayFacets,
|
|
185
|
+
"ft-search-bar--floating-panel-open": !this.isMobile && this.displayFacets && !this.forceMenuOpen,
|
|
181
186
|
"ft-search-bar--mobile-menu-open": this.isMobileMenuOpen,
|
|
187
|
+
"ft-search-bar--forced-open": this.forceMenuOpen || this.forceMobileMenuOpen,
|
|
182
188
|
};
|
|
183
189
|
return this.facetsInitialized && this.availableContentLocalesInitialized ? html `
|
|
184
190
|
<div class="${classMap(rootClasses)}" part="container" tabindex="-1">
|
|
@@ -220,8 +226,9 @@ export class FtSearchBar extends FtLitElement {
|
|
|
220
226
|
`;
|
|
221
227
|
}
|
|
222
228
|
renderMobileSearchBarButtons() {
|
|
223
|
-
|
|
224
|
-
|
|
229
|
+
const displayClearButton = this.query || (this.isMobileMenuOpen && !this.forceMobileMenuOpen);
|
|
230
|
+
return html `
|
|
231
|
+
${displayClearButton ? html `
|
|
225
232
|
<div class="ft-search-bar--actions"
|
|
226
233
|
part="search-bar-actions">
|
|
227
234
|
<ft-button class="ft-search-bar--clear-query"
|
|
@@ -229,16 +236,15 @@ export class FtSearchBar extends FtLitElement {
|
|
|
229
236
|
icon="close"
|
|
230
237
|
round
|
|
231
238
|
label="${this.labelResolver.resolve("clearInputButton")}"
|
|
239
|
+
tooltipPosition="left"
|
|
232
240
|
@click=${() => {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
241
|
+
this.setQuery("");
|
|
242
|
+
this.mobileMenuOpen = false;
|
|
243
|
+
this.displayFacets = false;
|
|
244
|
+
}}
|
|
237
245
|
></ft-button>
|
|
238
246
|
</div>
|
|
239
|
-
|
|
240
|
-
}
|
|
241
|
-
return html `
|
|
247
|
+
` : nothing}
|
|
242
248
|
<div class="ft-search-bar--actions"
|
|
243
249
|
part="search-bar-actions">
|
|
244
250
|
<ft-button class="ft-search-bar--launch-search"
|
|
@@ -246,7 +252,8 @@ export class FtSearchBar extends FtLitElement {
|
|
|
246
252
|
icon="search"
|
|
247
253
|
round
|
|
248
254
|
label="${this.labelResolver.resolve("searchButton")}"
|
|
249
|
-
|
|
255
|
+
tooltipPosition="left"
|
|
256
|
+
@click=${() => { var _a; return this.isMobileMenuOpen ? this.launchSearch() : (_a = this.input) === null || _a === void 0 ? void 0 : _a.focus(); }}
|
|
250
257
|
></ft-button>
|
|
251
258
|
</div>
|
|
252
259
|
`;
|
|
@@ -266,7 +273,8 @@ export class FtSearchBar extends FtLitElement {
|
|
|
266
273
|
</ft-typography>
|
|
267
274
|
</div>
|
|
268
275
|
<ft-filter
|
|
269
|
-
part="filters"
|
|
276
|
+
part="filters filter-ft-locale"
|
|
277
|
+
.exportpartsPrefixes=${["filter", "filter-ft-locale"]}
|
|
270
278
|
class="ft-search-bar--content-locale"
|
|
271
279
|
filterPlaceHolder="${this.labelResolver.resolve("filterInputPlaceHolder", this.labelResolver.resolve("contentLocaleSelector"))}"
|
|
272
280
|
.options=${(this.contentLocalesAsFilterOptions())}
|
|
@@ -276,7 +284,8 @@ export class FtSearchBar extends FtLitElement {
|
|
|
276
284
|
` : null}
|
|
277
285
|
${repeat(this.facets, facet => facet.key, facet => {
|
|
278
286
|
const filter = facetToFilter(facet);
|
|
279
|
-
|
|
287
|
+
const keyWithNoColumn = facet.key.replace(":", "-");
|
|
288
|
+
return facet.rootNodes.length > 0 ? html `
|
|
280
289
|
<ft-accordion-item data-facet-key="${facet.key}">
|
|
281
290
|
<div class="ft-search-bar--filter-label" slot="toggle">
|
|
282
291
|
<ft-typography variant="button">${facet.label}</ft-typography>
|
|
@@ -285,11 +294,13 @@ export class FtSearchBar extends FtLitElement {
|
|
|
285
294
|
</ft-typography>
|
|
286
295
|
</div>
|
|
287
296
|
<ft-filter
|
|
288
|
-
part="filters"
|
|
297
|
+
part="filters filter filter-${keyWithNoColumn}"
|
|
298
|
+
.exportpartsPrefixes=${["filter", "filter-" + keyWithNoColumn]}
|
|
289
299
|
id="${filter.id}"
|
|
290
300
|
filterPlaceHolder="${this.labelResolver.resolve("filterInputPlaceHolder", filter.label)}"
|
|
291
301
|
clearButtonLabel="${this.labelResolver.resolve("clearFilterButton")}"
|
|
292
302
|
moreValuesButtonLabel="${this.labelResolver.resolve("displayMoreFilterValuesButton")}"
|
|
303
|
+
noValuesLabel="${this.labelResolver.resolve("noFilterValuesAvailable")}"
|
|
293
304
|
?multivalued=${filter.multivalued}
|
|
294
305
|
raiseSelectedOptions
|
|
295
306
|
.options=${filter.options}
|
|
@@ -297,7 +308,7 @@ export class FtSearchBar extends FtLitElement {
|
|
|
297
308
|
@change=${(e) => this.setFilter(filter.id, e.detail)}
|
|
298
309
|
></ft-filter>
|
|
299
310
|
</ft-accordion-item>
|
|
300
|
-
|
|
311
|
+
` : nothing;
|
|
301
312
|
})}
|
|
302
313
|
</ft-accordion>
|
|
303
314
|
`;
|
|
@@ -327,25 +338,36 @@ export class FtSearchBar extends FtLitElement {
|
|
|
327
338
|
${this.renderSuggestions()}
|
|
328
339
|
</div>
|
|
329
340
|
${this.renderDesktopSearchBarButtons()}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
icon="search"
|
|
337
|
-
@click=${this.launchSearch}>
|
|
338
|
-
${this.labelResolver.resolve("searchButton")}
|
|
339
|
-
</ft-button>
|
|
340
|
-
</div>
|
|
341
|
-
</div>
|
|
341
|
+
${this.forceMenuOpen ? nothing : html `
|
|
342
|
+
<div class="ft-search-bar--floating-panel" @keyup=${this.onFloatingContainerKeyUp}
|
|
343
|
+
part="floating-panel"
|
|
344
|
+
tabindex="-1">
|
|
345
|
+
${this.renderDesktopMenu()}
|
|
346
|
+
</div>`}
|
|
342
347
|
</div>
|
|
343
|
-
${this.dense ? nothing : this.renderSelectedFacets()}
|
|
348
|
+
${this.dense || this.forceMenuOpen ? (this.forceMenuOpen ? this.renderDesktopMenu() : nothing) : this.renderSelectedFacets()}
|
|
344
349
|
`;
|
|
345
350
|
}
|
|
351
|
+
renderDesktopMenu() {
|
|
352
|
+
return this.hasFacets ? html `
|
|
353
|
+
<div class="ft-search-bar--desktop-menu">
|
|
354
|
+
${this.renderFacetsActions()}
|
|
355
|
+
${this.renderDesktopFacets()}
|
|
356
|
+
<div class="ft-search-bar--facets-actions">
|
|
357
|
+
${this.forceMenuOpen ? this.renderDesktopClearFilters() : nothing}
|
|
358
|
+
<ft-button class="ft-search-bar--launch-search"
|
|
359
|
+
part="launch-search-in-panel"
|
|
360
|
+
icon="search"
|
|
361
|
+
@click=${this.launchSearch}>
|
|
362
|
+
${this.labelResolver.resolve("searchButton")}
|
|
363
|
+
</ft-button>
|
|
364
|
+
</div>
|
|
365
|
+
</div>
|
|
366
|
+
` : nothing;
|
|
367
|
+
}
|
|
346
368
|
renderSearchBarLeftAction() {
|
|
347
369
|
if (this.hasFacets) {
|
|
348
|
-
return html `
|
|
370
|
+
return this.forceMenuOpen ? nothing : html `
|
|
349
371
|
<ft-button class="ft-search-bar--filters-opener ft-search-bar--left-action"
|
|
350
372
|
part="filters-opener"
|
|
351
373
|
trailingIcon
|
|
@@ -359,11 +381,12 @@ export class FtSearchBar extends FtLitElement {
|
|
|
359
381
|
</ft-button>
|
|
360
382
|
`;
|
|
361
383
|
}
|
|
362
|
-
if (this.hasLocaleSelector) {
|
|
384
|
+
else if (this.hasLocaleSelector) {
|
|
363
385
|
return html `
|
|
364
386
|
<ft-select outlined
|
|
365
387
|
class="ft-search-bar--content-locale ft-search-bar--left-action"
|
|
366
|
-
part="content-locale"
|
|
388
|
+
part="content-locale select-ft-locale"
|
|
389
|
+
.exportpartsPrefixes=${["content-locale", "select-ft-locale"]}
|
|
367
390
|
@change=${(e) => this.contentLocale = e.detail == null ? undefined : e.detail}>
|
|
368
391
|
${repeat(this.availableContentLocales, l => l.lang, l => html `
|
|
369
392
|
<ft-select-option .value=${l.lang}
|
|
@@ -419,16 +442,19 @@ export class FtSearchBar extends FtLitElement {
|
|
|
419
442
|
`)}
|
|
420
443
|
</ft-select>
|
|
421
444
|
` : nothing}
|
|
422
|
-
${this.searchFilters.length > 0 ? html `
|
|
423
|
-
<ft-button part="facets-actions"
|
|
424
|
-
@click=${this.clearFilters}>
|
|
425
|
-
${this.labelResolver.resolve("clearFilters")}
|
|
426
|
-
</ft-button>
|
|
427
|
-
` : nothing}
|
|
428
445
|
<slot name="facets-actions"></slot>
|
|
446
|
+
${this.forceMenuOpen && !this.isMobile ? nothing : this.renderDesktopClearFilters()}
|
|
429
447
|
</div>
|
|
430
448
|
`;
|
|
431
449
|
}
|
|
450
|
+
renderDesktopClearFilters() {
|
|
451
|
+
return this.searchFilters.length > 0 ? html `
|
|
452
|
+
<ft-button part="facets-actions"
|
|
453
|
+
@click=${this.clearFilters}>
|
|
454
|
+
${this.labelResolver.resolve("clearFilters")}
|
|
455
|
+
</ft-button>
|
|
456
|
+
` : nothing;
|
|
457
|
+
}
|
|
432
458
|
renderDesktopFacets() {
|
|
433
459
|
if (!this.hasFacets) {
|
|
434
460
|
return nothing;
|
|
@@ -436,10 +462,12 @@ export class FtSearchBar extends FtLitElement {
|
|
|
436
462
|
return html `
|
|
437
463
|
<ft-snap-scroll horizontal limitSize controls
|
|
438
464
|
class="ft-search-bar--filters-container"
|
|
439
|
-
part="filters-container"
|
|
465
|
+
part="filters-container"
|
|
466
|
+
exportpartsPrefix="filters-container">
|
|
440
467
|
${this.hasLocaleSelector ? html `
|
|
441
|
-
<ft-filter
|
|
442
|
-
|
|
468
|
+
<ft-filter class="ft-search-bar--content-locale"
|
|
469
|
+
part="filters filter-ft-locale"
|
|
470
|
+
.exportpartsPrefixes=${["filter", "filter-ft-locale"]}
|
|
443
471
|
label="${this.labelResolver.resolve("contentLocaleSelector")}"
|
|
444
472
|
filterPlaceHolder="${this.labelResolver.resolve("filterInputPlaceHolder", this.labelResolver.resolve("contentLocaleSelector"))}"
|
|
445
473
|
.options=${(this.contentLocalesAsFilterOptions())}
|
|
@@ -449,15 +477,18 @@ export class FtSearchBar extends FtLitElement {
|
|
|
449
477
|
${repeat(this.facets, facet => facet.key, facet => {
|
|
450
478
|
const filter = facetToFilter(facet);
|
|
451
479
|
const hierachical = filter.options.some(o => { var _a, _b; return ((_b = (_a = o.subOptions) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0; });
|
|
480
|
+
const keyWithNoColumn = facet.key.replace(":", "-");
|
|
452
481
|
return html `
|
|
453
482
|
<ft-filter
|
|
454
483
|
class="${hierachical ? "ft-search-bar--hierarchical-filter" : ""}"
|
|
455
|
-
part="filters"
|
|
484
|
+
part="filters filter filter-${keyWithNoColumn}"
|
|
485
|
+
.exportpartsPrefixes=${["filter", "filter-" + keyWithNoColumn]}
|
|
456
486
|
id="${filter.id}"
|
|
457
487
|
label="${filter.label}"
|
|
458
488
|
filterPlaceHolder="${this.labelResolver.resolve("filterInputPlaceHolder", filter.label)}"
|
|
459
489
|
clearButtonLabel="${this.labelResolver.resolve("clearFilterButton")}"
|
|
460
490
|
moreValuesButtonLabel="${this.labelResolver.resolve("displayMoreFilterValuesButton")}"
|
|
491
|
+
noValuesLabel="${this.labelResolver.resolve("noFilterValuesAvailable")}"
|
|
461
492
|
?multivalued=${filter.multivalued}
|
|
462
493
|
raiseSelectedOptions
|
|
463
494
|
.options=${filter.options}
|
|
@@ -476,7 +507,7 @@ export class FtSearchBar extends FtLitElement {
|
|
|
476
507
|
const useSnapScroll = (!this.isMobile && this.dense) || (this.isMobile && this.isMobileMenuOpen);
|
|
477
508
|
const filters = html `
|
|
478
509
|
${this.hasLocaleSelector && (this.hasFacets || this.isMobile) ? html `
|
|
479
|
-
<ft-chip part="selected-filters"
|
|
510
|
+
<ft-chip part="selected-filters selected-filter-ft-locale"
|
|
480
511
|
?dense=${this.dense && !this.isMobile}
|
|
481
512
|
?clickable=${this.isMobile}
|
|
482
513
|
@click=${() => this.openMobileFilters("ft:contentLocale")}>
|
|
@@ -487,9 +518,10 @@ export class FtSearchBar extends FtLitElement {
|
|
|
487
518
|
const values = getSelectedValues(facet);
|
|
488
519
|
return repeat(values, value => {
|
|
489
520
|
let label = facet.label + ": " + getBreadcrumbFromValue(value);
|
|
521
|
+
const keyWithNoColumn = facet.key.replace(":", "-");
|
|
490
522
|
const chip = html `
|
|
491
523
|
<ft-chip
|
|
492
|
-
part="selected-filters"
|
|
524
|
+
part="selected-filters selected-filter-${keyWithNoColumn}"
|
|
493
525
|
?dense=${this.dense && !this.isMobile}
|
|
494
526
|
?clickable=${this.isMobile}
|
|
495
527
|
?removable=${!this.isMobile}
|
|
@@ -509,7 +541,7 @@ export class FtSearchBar extends FtLitElement {
|
|
|
509
541
|
});
|
|
510
542
|
})}
|
|
511
543
|
${this.isMobile ? html `
|
|
512
|
-
<ft-chip part="selected-filters"
|
|
544
|
+
<ft-chip part="selected-filters mobile-filters-opener"
|
|
513
545
|
icon="add"
|
|
514
546
|
clickable
|
|
515
547
|
@click=${() => {
|
|
@@ -524,7 +556,8 @@ export class FtSearchBar extends FtLitElement {
|
|
|
524
556
|
? html `
|
|
525
557
|
<ft-snap-scroll horizontal controls hideScrollbar limitSize
|
|
526
558
|
class="ft-search-bar--selected-filters"
|
|
527
|
-
part="selected-filters-container"
|
|
559
|
+
part="selected-filters-container"
|
|
560
|
+
exportpartsPrefix="selected-filters-container">
|
|
528
561
|
${filters}
|
|
529
562
|
</ft-snap-scroll>
|
|
530
563
|
`
|
|
@@ -539,6 +572,7 @@ export class FtSearchBar extends FtLitElement {
|
|
|
539
572
|
const shouldDisplaySuggestions = this.query.length > 2 || filteredRecentSearches.length > 0;
|
|
540
573
|
return html `
|
|
541
574
|
<div class="ft-search-bar--suggestions ${shouldDisplaySuggestions ? "ft-search-bar--suggestions-not-empty" : ""}"
|
|
575
|
+
part="suggestions-container"
|
|
542
576
|
@keydown=${this.onSuggestKeyDown}>
|
|
543
577
|
${repeat(filteredRecentSearches.slice(0, 5), query => query, query => html `
|
|
544
578
|
<a href="${this.searchRequestSerializer({ ...this.request, query: query })}"
|
|
@@ -554,6 +588,7 @@ export class FtSearchBar extends FtLitElement {
|
|
|
554
588
|
part="remove-suggestion"
|
|
555
589
|
?dense=${!this.isMobile}
|
|
556
590
|
label="${this.labelResolver.resolve("removeRecentSearch")}"
|
|
591
|
+
tooltipPosition="left"
|
|
557
592
|
@click=${(e) => this.removeRecentSearch(e, query)}></ft-button>
|
|
558
593
|
</a>
|
|
559
594
|
`)}
|
|
@@ -640,6 +675,9 @@ export class FtSearchBar extends FtLitElement {
|
|
|
640
675
|
this.setFiltersFromPreset(currentPreset);
|
|
641
676
|
}
|
|
642
677
|
}
|
|
678
|
+
if (props.has("contentLocale") && this.contentLocale != null) {
|
|
679
|
+
this.knownFacetLabels = new Map();
|
|
680
|
+
}
|
|
643
681
|
if (["contentLocale", "searchFilters"].some(p => props.has(p))) {
|
|
644
682
|
this.selectedPreset = (_f = ((_e = this.presets) !== null && _e !== void 0 ? _e : []).find(p => this.compareRequests(p, this.request))) === null || _f === void 0 ? void 0 : _f.name;
|
|
645
683
|
}
|
|
@@ -694,9 +732,27 @@ export class FtSearchBar extends FtLitElement {
|
|
|
694
732
|
if (this.facetsRequest.length > 0) {
|
|
695
733
|
this.facetsLoaded = false;
|
|
696
734
|
this.updateFacetsDebouncer.run(async () => {
|
|
697
|
-
var _a
|
|
698
|
-
|
|
699
|
-
this.
|
|
735
|
+
var _a;
|
|
736
|
+
const retrievedFacets = new Map();
|
|
737
|
+
await ((_a = this.api) === null || _a === void 0 ? void 0 : _a.search({ ...this.request, query: "" }).then(r => r.facets.forEach(f => {
|
|
738
|
+
this.knownFacetLabels.set(f.key, f.label);
|
|
739
|
+
retrievedFacets.set(f.key, f);
|
|
740
|
+
})).catch(doNothing));
|
|
741
|
+
this.facets = [];
|
|
742
|
+
for (let r of this.facetsRequest) {
|
|
743
|
+
if (retrievedFacets.has(r.id)) {
|
|
744
|
+
this.facets.push(retrievedFacets.get(r.id));
|
|
745
|
+
}
|
|
746
|
+
else if (this.knownFacetLabels.has(r.id)) {
|
|
747
|
+
this.facets.push({
|
|
748
|
+
key: r.id,
|
|
749
|
+
label: this.knownFacetLabels.get(r.id),
|
|
750
|
+
rootNodes: [],
|
|
751
|
+
multiSelectionable: true,
|
|
752
|
+
hierarchical: false
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
}
|
|
700
756
|
this.facetsLoaded = true;
|
|
701
757
|
this.facetsInitialized = true;
|
|
702
758
|
});
|
|
@@ -887,6 +943,9 @@ __decorate([
|
|
|
887
943
|
__decorate([
|
|
888
944
|
property({ type: Boolean })
|
|
889
945
|
], FtSearchBar.prototype, "forceMobileMenuOpen", void 0);
|
|
946
|
+
__decorate([
|
|
947
|
+
property({ type: Boolean })
|
|
948
|
+
], FtSearchBar.prototype, "forceMenuOpen", void 0);
|
|
890
949
|
__decorate([
|
|
891
950
|
property()
|
|
892
951
|
], FtSearchBar.prototype, "baseUrl", void 0);
|