@fluid-topics/ft-search-bar 0.1.8 → 0.1.11
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/converters.d.ts +1 -0
- package/build/converters.js +5 -0
- package/build/ft-search-bar.css.js +13 -5
- package/build/ft-search-bar.js +28 -13
- package/build/ft-search-bar.light.js +66 -36
- package/build/ft-search-bar.min.js +137 -107
- package/package.json +13 -13
package/build/converters.d.ts
CHANGED
|
@@ -7,4 +7,5 @@ export declare function getLabelFromValue(value: string): string | undefined;
|
|
|
7
7
|
export declare function getBreadcrumbFromValue(value: string): string;
|
|
8
8
|
export declare function selectedValues(facet: FtFilterProperties): Array<string>;
|
|
9
9
|
export declare function facetToFilter(facet: FtSearchFacet): FtFilterProperties;
|
|
10
|
+
export declare function getSelectedValues(facet: FtSearchFacet): Array<string>;
|
|
10
11
|
//# sourceMappingURL=converters.d.ts.map
|
package/build/converters.js
CHANGED
|
@@ -54,4 +54,9 @@ export function facetToFilter(facet) {
|
|
|
54
54
|
options: facet.rootNodes.map(n => facetEntryToOption(n, false))
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
+
export function getSelectedValues(facet) {
|
|
58
|
+
return flatDeep(facet.rootNodes, n => n.selected ? [] : n.childNodes)
|
|
59
|
+
.filter(n => n.selected)
|
|
60
|
+
.map(n => n.value);
|
|
61
|
+
}
|
|
57
62
|
//# sourceMappingURL=converters.js.map
|
|
@@ -38,6 +38,10 @@ export const searchBarCss = css `
|
|
|
38
38
|
outline: none;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
.ft-search-bar--container > * {
|
|
42
|
+
flex-shrink: 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
41
45
|
.ft-search-bar--mobile-menu-open {
|
|
42
46
|
position: ${FtSearchBarCssVariables.mobileOpenPosition};
|
|
43
47
|
top: ${FtSearchBarCssVariables.mobileOpenTop};
|
|
@@ -49,7 +53,6 @@ export const searchBarCss = css `
|
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
.ft-search-bar {
|
|
52
|
-
flex-shrink: 0;
|
|
53
56
|
position: relative;
|
|
54
57
|
display: flex;
|
|
55
58
|
flex-direction: row;
|
|
@@ -116,14 +119,14 @@ export const searchBarCss = css `
|
|
|
116
119
|
}
|
|
117
120
|
|
|
118
121
|
.ft-search-bar--left-action::part(button) {
|
|
119
|
-
height
|
|
122
|
+
height: 100%;
|
|
120
123
|
}
|
|
121
124
|
|
|
122
125
|
.ft-search-bar--floating-panel-open .ft-search-bar--left-action {
|
|
123
126
|
${setVariable(FtButtonCssVariables.borderRadius, css `calc(${FtSearchBarCssVariables.borderRadius} - 1px) 0 0 0`)};
|
|
124
127
|
}
|
|
125
128
|
|
|
126
|
-
.ft-search-bar--launch-search,
|
|
129
|
+
.ft-search-bar .ft-search-bar--launch-search,
|
|
127
130
|
.ft-search-bar--clear-query {
|
|
128
131
|
margin: 0 4px;
|
|
129
132
|
}
|
|
@@ -169,11 +172,13 @@ export const facetsCss = css `
|
|
|
169
172
|
}
|
|
170
173
|
|
|
171
174
|
.ft-search-bar--floating-panel {
|
|
175
|
+
flex-direction: column;
|
|
176
|
+
gap: 16px;
|
|
172
177
|
padding: 16px;
|
|
173
178
|
}
|
|
174
179
|
|
|
175
180
|
.ft-search-bar--floating-panel-open .ft-search-bar--floating-panel {
|
|
176
|
-
display:
|
|
181
|
+
display: flex;
|
|
177
182
|
}
|
|
178
183
|
|
|
179
184
|
.ft-search-bar--desktop .ft-search-bar--facets-actions {
|
|
@@ -182,7 +187,6 @@ export const facetsCss = css `
|
|
|
182
187
|
justify-content: flex-end;
|
|
183
188
|
gap: 8px;
|
|
184
189
|
padding: 0 10px;
|
|
185
|
-
margin-bottom: 16px;
|
|
186
190
|
}
|
|
187
191
|
|
|
188
192
|
.ft-search-bar--mobile .ft-search-bar--facets-actions {
|
|
@@ -272,6 +276,10 @@ export const facetsCss = css `
|
|
|
272
276
|
padding-left: 0;
|
|
273
277
|
padding-right: 0;
|
|
274
278
|
}
|
|
279
|
+
|
|
280
|
+
.ft-search-bar--floating-panel .ft-search-bar--launch-search {
|
|
281
|
+
margin: 0;
|
|
282
|
+
}
|
|
275
283
|
`;
|
|
276
284
|
//language=css
|
|
277
285
|
export const selectedFiltersCss = css `
|
package/build/ft-search-bar.js
CHANGED
|
@@ -11,7 +11,7 @@ import { classMap } from "lit/directives/class-map.js";
|
|
|
11
11
|
import { customElement, Debouncer, FtLitElement, jsonProperty, ParametrizedLabelResolver } from "@fluid-topics/ft-wc-utils";
|
|
12
12
|
import { FtSizeCategory, FtSizeWatcher } from "@fluid-topics/ft-size-watcher";
|
|
13
13
|
import { FtTypography, FtTypographyBody2 } from "@fluid-topics/ft-typography";
|
|
14
|
-
import { facetToFilter, getBreadcrumbFromValue, getLabelFromValue, selectedValues, serializeRequest } from "./converters";
|
|
14
|
+
import { facetToFilter, getBreadcrumbFromValue, getLabelFromValue, getSelectedValues, selectedValues, serializeRequest } from "./converters";
|
|
15
15
|
import { FtFilter, FtFilterOption } from "@fluid-topics/ft-filter";
|
|
16
16
|
import { FtIcon, FtIcons, FtIconVariants, resolveFileFormatIcon, } from "@fluid-topics/ft-icon";
|
|
17
17
|
import { FtAccordion, FtAccordionItem } from "@fluid-topics/ft-accordion";
|
|
@@ -188,6 +188,14 @@ let FtSearchBar = class FtSearchBar extends FtLitElement {
|
|
|
188
188
|
</div>
|
|
189
189
|
${this.displayFacets ? this.renderFacetsActions() : this.renderSelectedFacets()}
|
|
190
190
|
${this.displayFacets ? this.renderMobileFacets() : this.renderSuggestions()}
|
|
191
|
+
${this.mobileMenuOpen || this.displayFacets ? html `
|
|
192
|
+
<ft-button class="ft-search-bar--launch-search"
|
|
193
|
+
part="search-bar-actions"
|
|
194
|
+
icon="search"
|
|
195
|
+
@click=${this.launchSearch}>
|
|
196
|
+
${this.labelResolver.resolve("searchButton")}
|
|
197
|
+
</ft-button>
|
|
198
|
+
` : nothing}
|
|
191
199
|
`;
|
|
192
200
|
}
|
|
193
201
|
renderMobileSearchBarButtons() {
|
|
@@ -259,7 +267,7 @@ let FtSearchBar = class FtSearchBar extends FtLitElement {
|
|
|
259
267
|
raiseSelectedOptions
|
|
260
268
|
.options=${filter.options}
|
|
261
269
|
.displayedValuesLimit=${10}
|
|
262
|
-
@change=${(e) => this.setFilter(filter.id,
|
|
270
|
+
@change=${(e) => this.setFilter(filter.id, e.detail)}
|
|
263
271
|
></ft-filter>
|
|
264
272
|
</ft-accordion-item>
|
|
265
273
|
`;
|
|
@@ -295,7 +303,14 @@ let FtSearchBar = class FtSearchBar extends FtLitElement {
|
|
|
295
303
|
<div class="ft-search-bar--floating-panel" @keyup=${this.onFloatingContainerKeyUp} tabindex="-1">
|
|
296
304
|
${this.renderFacetsActions()}
|
|
297
305
|
${this.renderDesktopFacets()}
|
|
298
|
-
|
|
306
|
+
<div class="ft-search-bar--facets-actions">
|
|
307
|
+
<ft-button class="ft-search-bar--launch-search"
|
|
308
|
+
part="search-bar-actions"
|
|
309
|
+
icon="search"
|
|
310
|
+
@click=${this.launchSearch}>
|
|
311
|
+
${this.labelResolver.resolve("searchButton")}
|
|
312
|
+
</ft-button>
|
|
313
|
+
</div>
|
|
299
314
|
</div>
|
|
300
315
|
</div>
|
|
301
316
|
${this.dense ? nothing : this.renderSelectedFacets()}
|
|
@@ -416,7 +431,7 @@ let FtSearchBar = class FtSearchBar extends FtLitElement {
|
|
|
416
431
|
raiseSelectedOptions
|
|
417
432
|
.options=${filter.options}
|
|
418
433
|
.displayedValuesLimit=${10}
|
|
419
|
-
@change=${(e) => this.setFilter(filter.id,
|
|
434
|
+
@change=${(e) => this.setFilter(filter.id, e.detail)}
|
|
420
435
|
></ft-filter>
|
|
421
436
|
`;
|
|
422
437
|
})}
|
|
@@ -424,7 +439,7 @@ let FtSearchBar = class FtSearchBar extends FtLitElement {
|
|
|
424
439
|
`;
|
|
425
440
|
}
|
|
426
441
|
renderSelectedFacets() {
|
|
427
|
-
if (!this.hasLocaleSelector && this.
|
|
442
|
+
if (!this.hasLocaleSelector && !this.hasFacets) {
|
|
428
443
|
return null;
|
|
429
444
|
}
|
|
430
445
|
const useSnapScroll = (!this.isMobile && this.dense) || (this.isMobile && this.mobileMenuOpen);
|
|
@@ -437,9 +452,10 @@ let FtSearchBar = class FtSearchBar extends FtLitElement {
|
|
|
437
452
|
${(this.getLocaleLabel(this.contentLocale))}
|
|
438
453
|
</ft-chip>
|
|
439
454
|
` : null}
|
|
440
|
-
${repeat(this.
|
|
441
|
-
|
|
442
|
-
|
|
455
|
+
${repeat(this.facets, facet => facet.key, facet => {
|
|
456
|
+
const values = getSelectedValues(facet);
|
|
457
|
+
return repeat(values, value => {
|
|
458
|
+
let label = facet.label + ": " + getBreadcrumbFromValue(value);
|
|
443
459
|
const chip = html `
|
|
444
460
|
<ft-chip
|
|
445
461
|
part="selected-filters"
|
|
@@ -449,8 +465,8 @@ let FtSearchBar = class FtSearchBar extends FtLitElement {
|
|
|
449
465
|
icon=${this.isMobile ? nothing : "close"}
|
|
450
466
|
label="${label}"
|
|
451
467
|
title=${useSnapScroll ? label : nothing}
|
|
452
|
-
@click=${() => this.openMobileFilters(
|
|
453
|
-
@icon-click=${() => this.setFilter(
|
|
468
|
+
@click=${() => this.openMobileFilters(facet.key)}
|
|
469
|
+
@icon-click=${() => this.setFilter(facet.key, values.filter(v => v !== value))}>
|
|
454
470
|
${getLabelFromValue(value)}
|
|
455
471
|
</ft-chip>
|
|
456
472
|
`;
|
|
@@ -737,7 +753,7 @@ let FtSearchBar = class FtSearchBar extends FtLitElement {
|
|
|
737
753
|
.map(l => l.label)
|
|
738
754
|
.pop()) !== null && _a !== void 0 ? _a : locale;
|
|
739
755
|
}
|
|
740
|
-
setFilter(key,
|
|
756
|
+
setFilter(key, selectedValues) {
|
|
741
757
|
let newFilters = this.searchFilters.filter(f => f.key !== key);
|
|
742
758
|
this.facets.forEach(facet => {
|
|
743
759
|
if (facet.key === key) {
|
|
@@ -747,7 +763,6 @@ let FtSearchBar = class FtSearchBar extends FtLitElement {
|
|
|
747
763
|
if (selectedValues.length) {
|
|
748
764
|
newFilters.push({
|
|
749
765
|
key: key,
|
|
750
|
-
label: label,
|
|
751
766
|
negative: false,
|
|
752
767
|
values: selectedValues
|
|
753
768
|
});
|
|
@@ -760,7 +775,7 @@ let FtSearchBar = class FtSearchBar extends FtLitElement {
|
|
|
760
775
|
if (request.contentLocale != null) {
|
|
761
776
|
this.contentLocale = request.contentLocale;
|
|
762
777
|
}
|
|
763
|
-
this.searchFilters = request.filters
|
|
778
|
+
this.searchFilters = request.filters;
|
|
764
779
|
}
|
|
765
780
|
}
|
|
766
781
|
clearFilters() {
|