@fluid-topics/ft-search-bar 0.3.46 → 0.3.48
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.
|
@@ -188,12 +188,12 @@ export const searchBarCss = css `
|
|
|
188
188
|
`;
|
|
189
189
|
//language=css
|
|
190
190
|
export const facetsCss = css `
|
|
191
|
-
.ft-search-bar--
|
|
192
|
-
|
|
191
|
+
.ft-search-bar--presets {
|
|
192
|
+
min-width: 200px;
|
|
193
193
|
}
|
|
194
194
|
|
|
195
195
|
.ft-search-bar--desktop-menu .ft-search-bar--presets {
|
|
196
|
-
|
|
196
|
+
margin-right: auto;
|
|
197
197
|
${setVariable(FtSelectCssVariables.optionsZIndex, "2")};
|
|
198
198
|
}
|
|
199
199
|
|
package/build/ft-search-bar.d.ts
CHANGED
|
@@ -85,13 +85,13 @@ export declare class FtSearchBar extends FtLitElement implements FtSearchBarProp
|
|
|
85
85
|
protected update(props: PropertyValues): void;
|
|
86
86
|
private stateChangeEventDebouncer;
|
|
87
87
|
private dispatchStateChangeEvent;
|
|
88
|
-
private
|
|
88
|
+
private updateLocalesDebouncer;
|
|
89
89
|
private initSearchData;
|
|
90
|
-
protected contentAvailableCallback(props: PropertyValues): void;
|
|
91
|
-
private initApi;
|
|
92
90
|
private facetsLoaded;
|
|
93
91
|
private updateFacetsDebouncer;
|
|
94
92
|
private updateFacets;
|
|
93
|
+
protected contentAvailableCallback(props: PropertyValues): void;
|
|
94
|
+
private initApi;
|
|
95
95
|
private retrieveFacetsFromSearch;
|
|
96
96
|
private onFloatingContainerKeyUp;
|
|
97
97
|
setQuery(query: string): void;
|
package/build/ft-search-bar.js
CHANGED
|
@@ -93,7 +93,7 @@ export class FtSearchBar extends FtLitElement {
|
|
|
93
93
|
this.desktopSearchBarManager = new DesktopSearchBarManager(this);
|
|
94
94
|
this.mobileSearchBarManager = new MobileSearchBarManager(this, this.selectedFacetsManager, this.suggestManager);
|
|
95
95
|
this.stateChangeEventDebouncer = new Debouncer(10);
|
|
96
|
-
this.
|
|
96
|
+
this.updateLocalesDebouncer = new Debouncer(10);
|
|
97
97
|
this.facetsLoaded = false;
|
|
98
98
|
this.updateFacetsDebouncer = new Debouncer(500);
|
|
99
99
|
this.closeFloatingContainer = (e) => {
|
|
@@ -428,18 +428,35 @@ export class FtSearchBar extends FtLitElement {
|
|
|
428
428
|
this.availableContentLocalesInitialized = false;
|
|
429
429
|
this.facetsLoaded = false;
|
|
430
430
|
this.facetsInitialized = false;
|
|
431
|
-
this.
|
|
431
|
+
this.updateLocalesDebouncer.run(() => {
|
|
432
432
|
var _a;
|
|
433
433
|
(_a = this.api) === null || _a === void 0 ? void 0 : _a.getAvailableSearchLocales().then(result => result.contentLocales).catch(() => []).then(result => {
|
|
434
434
|
this.availableContentLocales = result;
|
|
435
435
|
this.availableContentLocalesInitialized = true;
|
|
436
436
|
});
|
|
437
|
+
});
|
|
438
|
+
this.updateFacetsDebouncer.run(() => {
|
|
437
439
|
this.retrieveFacetsFromSearch()
|
|
438
440
|
.then(() => {
|
|
439
441
|
this.facetsLoaded = true;
|
|
440
442
|
this.facetsInitialized = true;
|
|
441
443
|
});
|
|
442
|
-
});
|
|
444
|
+
}, this.facetsInitialized ? 500 : 10);
|
|
445
|
+
}
|
|
446
|
+
updateFacets() {
|
|
447
|
+
if (this.api) {
|
|
448
|
+
if (this.facetsRequest.length > 0) {
|
|
449
|
+
this.facetsLoaded = false;
|
|
450
|
+
this.updateFacetsDebouncer.run(async () => {
|
|
451
|
+
await this.retrieveFacetsFromSearch();
|
|
452
|
+
this.facetsLoaded = true;
|
|
453
|
+
this.facetsInitialized = true;
|
|
454
|
+
}, this.facetsInitialized ? 500 : 10);
|
|
455
|
+
}
|
|
456
|
+
else {
|
|
457
|
+
this.facets = [];
|
|
458
|
+
}
|
|
459
|
+
}
|
|
443
460
|
}
|
|
444
461
|
contentAvailableCallback(props) {
|
|
445
462
|
var _a, _b, _c;
|
|
@@ -462,20 +479,6 @@ export class FtSearchBar extends FtLitElement {
|
|
|
462
479
|
setTimeout(() => this.initApi(), 10);
|
|
463
480
|
}
|
|
464
481
|
}
|
|
465
|
-
updateFacets() {
|
|
466
|
-
if (this.api && this.facetsInitialized) {
|
|
467
|
-
if (this.facetsRequest.length > 0) {
|
|
468
|
-
this.facetsLoaded = false;
|
|
469
|
-
this.updateFacetsDebouncer.run(async () => {
|
|
470
|
-
await this.retrieveFacetsFromSearch();
|
|
471
|
-
this.facetsLoaded = true;
|
|
472
|
-
});
|
|
473
|
-
}
|
|
474
|
-
else {
|
|
475
|
-
this.facets = [];
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
482
|
async retrieveFacetsFromSearch() {
|
|
480
483
|
var _a;
|
|
481
484
|
const retrievedFacets = new Map();
|
|
@@ -1166,7 +1166,7 @@ const q=Symbol.for(""),W=t=>{if((null==t?void 0:t.r)===q)return null==t?void 0:t
|
|
|
1166
1166
|
slot {
|
|
1167
1167
|
display: none;
|
|
1168
1168
|
}
|
|
1169
|
-
`];var wi=function(t,e,i,o){for(var s,r=arguments.length,n=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o,l=t.length-1;l>=0;l--)(s=t[l])&&(n=(r<3?s(n):r>3?s(e,i,n):s(e,i))||n);return r>3&&n&&Object.defineProperty(e,i,n),n};class ki extends CustomEvent{constructor(t){super("change",{detail:t})}}class Si extends e.FtLitElement{constructor(){super(...arguments),this.id="",this.label="",this.filterPlaceHolder="Filter {0}",this.clearButtonLabel="Clear",this.moreValuesButtonLabel="More",this.noValuesLabel="No values available",this.options=[],this.multivalued=!1,this.disabled=!1,this.raiseSelectedOptions=!1,this.displayedValuesLimit=0,this.hideClearButton=!1,this.withScroll=!1,this.filter="",this.displayedLevels=[],this.scrollResizeObserver=new ResizeObserver((()=>this.updateScroll())),this.levelsScrollDebouncer=new e.Debouncer(300),this.changeDebouncer=new e.Debouncer(10)}get flatOptions(){return ee(this.options,(t=>{var e;return null!==(e=t.subOptions)&&void 0!==e?e:[]}))}render(){var t,e;const o=this.flatOptions.some((t=>t.selected)),s=this.withScroll||this.filter||null!==(e=null===(t=this.lastLevel)||void 0===t?void 0:t.hasHiddenValues)&&void 0!==e&&e,r=this.filterPlaceHolder.replace("{0}",this.label);return i.html`
|
|
1169
|
+
`];var wi=function(t,e,i,o){for(var s,r=arguments.length,n=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o,l=t.length-1;l>=0;l--)(s=t[l])&&(n=(r<3?s(n):r>3?s(e,i,n):s(e,i))||n);return r>3&&n&&Object.defineProperty(e,i,n),n};class ki extends CustomEvent{constructor(t){super("change",{detail:t})}}class Si extends e.FtLitElement{constructor(){super(...arguments),this.id="",this.label="",this.filterPlaceHolder="Filter {0}",this.clearButtonLabel="Clear",this.moreValuesButtonLabel="More",this.noValuesLabel="No values available",this.options=[],this.multivalued=!1,this.disabled=!1,this.raiseSelectedOptions=!1,this.displayedValuesLimit=0,this.hideClearButton=!1,this.withScroll=!1,this.filter="",this.displayedLevels=[],this.scrollResizeObserver=new ResizeObserver((()=>this.updateScroll())),this.levelsScrollDebouncer=new e.Debouncer(300),this.changeDebouncer=new e.Debouncer(10)}get flatOptions(){return ee(this.options,(t=>{var e;return null!==(e=t.subOptions)&&void 0!==e?e:[]}))}get selectedValues(){return this.flatOptions.filter((t=>t.selected)).map((t=>t.value))}render(){var t,e;const o=this.flatOptions.some((t=>t.selected)),s=this.withScroll||this.filter||null!==(e=null===(t=this.lastLevel)||void 0===t?void 0:t.hasHiddenValues)&&void 0!==e&&e,r=this.filterPlaceHolder.replace("{0}",this.label);return i.html`
|
|
1170
1170
|
<div class="ft-filter--container ${this.disabled?"ft-filter--disabled":""}"
|
|
1171
1171
|
part="container">
|
|
1172
1172
|
${this.label||o?i.html`
|
|
@@ -1236,7 +1236,7 @@ const q=Symbol.for(""),W=t=>{if((null==t?void 0:t.r)===q)return null==t?void 0:t
|
|
|
1236
1236
|
.exportpartsPrefixes=${["values","available-values"]}
|
|
1237
1237
|
noValuesLabel="${this.noValuesLabel}"
|
|
1238
1238
|
></ft-filter-level>
|
|
1239
|
-
`}goBack(t){this.slideOut=t.detail.value}onDisplayLevel(t){this.displayedLevels.push(t.detail.value),this.slideIn=t.detail.value}clear(){if(this.flatOptions.forEach((t=>t.selected=!1)),this.displayedLevels.length>0){let t=this.displayedLevels[this.displayedLevels.length-1];this.displayedLevels=[t],this.slideOut=t}this.optionsChanged()}onChange(t){var e;t.stopPropagation();const i=this.flatOptions.find((e=>e.value===t.detail.value));i.selected=!i.selected;const o=t=>{var e;t!==i&&(t.selected=!1),null===(e=t.subOptions)||void 0===e||e.forEach(o)};this.multivalued?null===(e=i.subOptions)||void 0===e||e.forEach(o):this.options.forEach(o),this.optionsChanged()}optionsChanged(){this.changeDebouncer.run((()=>{var t;
|
|
1239
|
+
`}goBack(t){this.slideOut=t.detail.value}onDisplayLevel(t){this.displayedLevels.push(t.detail.value),this.slideIn=t.detail.value}clear(){if(this.flatOptions.forEach((t=>t.selected=!1)),this.displayedLevels.length>0){let t=this.displayedLevels[this.displayedLevels.length-1];this.displayedLevels=[t],this.slideOut=t}this.optionsChanged()}onChange(t){var e;t.stopPropagation();const i=this.flatOptions.find((e=>e.value===t.detail.value));i.selected=!i.selected;const o=t=>{var e;t!==i&&(t.selected=!1),null===(e=t.subOptions)||void 0===e||e.forEach(o)};this.multivalued?null===(e=i.subOptions)||void 0===e||e.forEach(o):this.options.forEach(o),this.optionsChanged()}optionsChanged(){this.changeDebouncer.run((()=>{var t;this.dispatchEvent(new ki(this.selectedValues)),this.requestUpdate(),null===(t=this.levels)||void 0===t||t.forEach((t=>t.requestUpdate()))}))}updateOptionsFromSlot(t){t.stopPropagation(),this.options=this.slotElement.assignedElements().map((t=>t)),this.optionsChanged()}onFilterChange(){var t,e;this.filter=null!==(e=null===(t=this.filterInput)||void 0===t?void 0:t.value)&&void 0!==e?e:""}updateScroll(){this.valuesContainer&&(this.withScroll=this.valuesContainer.scrollHeight>this.valuesContainer.clientHeight)}}Si.elementDefinitions={"ft-button":Te,"ft-filter-level":ai,"ft-snap-scroll":di,"ft-typography":te},Si.styles=$i,wi([o.property({type:String})],Si.prototype,"id",void 0),wi([o.property({type:String})],Si.prototype,"label",void 0),wi([o.property({type:String})],Si.prototype,"filterPlaceHolder",void 0),wi([o.property({type:String})],Si.prototype,"clearButtonLabel",void 0),wi([o.property({type:String})],Si.prototype,"moreValuesButtonLabel",void 0),wi([o.property({type:String})],Si.prototype,"noValuesLabel",void 0),wi([e.jsonProperty([])],Si.prototype,"options",void 0),wi([o.property({type:Boolean})],Si.prototype,"multivalued",void 0),wi([o.property({type:Boolean})],Si.prototype,"disabled",void 0),wi([o.property({type:Boolean})],Si.prototype,"raiseSelectedOptions",void 0),wi([o.property({type:Number})],Si.prototype,"displayedValuesLimit",void 0),wi([o.property({type:Boolean})],Si.prototype,"hideClearButton",void 0),wi([o.query(".ft-filter--slot")],Si.prototype,"slotElement",void 0),wi([o.query(".ft-filter--container")],Si.prototype,"container",void 0),wi([o.query(".ft-filter--values")],Si.prototype,"valuesContainer",void 0),wi([o.query(".ft-filter--levels")],Si.prototype,"levelsContainer",void 0),wi([o.query(".ft-filter--levels ft-filter-level:last-child")],Si.prototype,"lastLevel",void 0),wi([o.query(".ft-filter--filter input")],Si.prototype,"filterInput",void 0),wi([o.queryAll(".ft-filter--levels ft-filter-level")],Si.prototype,"levels",void 0),wi([o.state()],Si.prototype,"withScroll",void 0),wi([o.state()],Si.prototype,"filter",void 0),wi([o.state()],Si.prototype,"slideIn",void 0),wi([o.state()],Si.prototype,"slideOut",void 0);var zi=function(t,e,i,o){for(var s,r=arguments.length,n=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o,l=t.length-1;l>=0;l--)(s=t[l])&&(n=(r<3?s(n):r>3?s(e,i,n):s(e,i))||n);return r>3&&n&&Object.defineProperty(e,i,n),n};class Oi extends e.FtLitElement{constructor(){super(...arguments),this.label="",this.value=null,this.selected=!1,this.subOptions=[]}render(){return i.html`
|
|
1240
1240
|
<slot class="ft-filter-option--slot" @slotchange=${this.updateSubOptionsFromSlot}></slot>
|
|
1241
1241
|
`}updateSubOptionsFromSlot(t){t.stopPropagation(),this.subOptions=this.slotElement.assignedElements().map((t=>t))}updated(t){super.updated(t),this.dispatchEvent(new CustomEvent("option-change",{detail:this,bubbles:!0}))}}Oi.elementDefinitions={},zi([o.property({type:String})],Oi.prototype,"label",void 0),zi([o.property({type:Object,converter:t=>t})],Oi.prototype,"value",void 0),zi([o.property({type:Boolean,reflect:!0})],Oi.prototype,"selected",void 0),zi([o.property({type:Object})],Oi.prototype,"subOptions",void 0),zi([e.jsonProperty({})],Oi.prototype,"renderOption",void 0),zi([o.query(".ft-filter-option--slot")],Oi.prototype,"slotElement",void 0),e.customElement("ft-filter")(Si),e.customElement("ft-filter-option")(Oi);const Bi=i.css`
|
|
1242
1242
|
.ft-accordion {
|
|
@@ -1971,12 +1971,12 @@ const q=Symbol.for(""),W=t=>{if((null==t?void 0:t.r)===q)return null==t?void 0:t
|
|
|
1971
1971
|
}
|
|
1972
1972
|
|
|
1973
1973
|
`,ro=i.css`
|
|
1974
|
-
.ft-search-bar--
|
|
1975
|
-
|
|
1974
|
+
.ft-search-bar--presets {
|
|
1975
|
+
min-width: 200px;
|
|
1976
1976
|
}
|
|
1977
1977
|
|
|
1978
1978
|
.ft-search-bar--desktop-menu .ft-search-bar--presets {
|
|
1979
|
-
|
|
1979
|
+
margin-right: auto;
|
|
1980
1980
|
${e.setVariable(Xi.optionsZIndex,"2")};
|
|
1981
1981
|
}
|
|
1982
1982
|
|
|
@@ -2440,7 +2440,7 @@ const q=Symbol.for(""),W=t=>{if((null==t?void 0:t.r)===q)return null==t?void 0:t
|
|
|
2440
2440
|
</div>
|
|
2441
2441
|
`}onSearchBarKeyDown(t){var e;switch(t.key){case"Escape":this.searchBar.mobileMenuOpen=!1,null===(e=this.searchBar.input)||void 0===e||e.blur();break;case"ArrowDown":t.stopPropagation(),t.preventDefault(),this.suggestManager.focusFirstSuggestion()}}onSearchBarKeyUp(t){const e=t.composedPath()[0];this.searchBar.query=e.value,"Enter"===t.key&&this.searchBar.launchSearch()}}ho.styles=i.css`
|
|
2442
2442
|
|
|
2443
|
-
`;var po=function(t,e,i,o){for(var s,r=arguments.length,n=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o,l=t.length-1;l>=0;l--)(s=t[l])&&(n=(r<3?s(n):r>3?s(e,i,n):s(e,i))||n);return r>3&&n&&Object.defineProperty(e,i,n),n};null==window.fluidtopics&&console.warn("Fluid Topics public API was not found. You can find it here: https://www.npmjs.com/package/@fluid-topics/public-api");const fo={filtersButton:"Filters",inputPlaceHolder:"Search",filterInputPlaceHolder:"Filter {0}",clearInputButton:"Clear",clearFilterButton:"Clear",displayMoreFilterValuesButton:"More",noFilterValuesAvailable:"No values available",searchButton:"Search",clearFilters:"Clear filters",contentLocaleSelector:"Lang",presetsSelector:"Quick filters",removeRecentSearch:"Remove",back:"Back"};class uo extends CustomEvent{constructor(t){super("launch-search",{detail:t,bubbles:!0,composed:!0})}}class bo extends CustomEvent{constructor(t){super("change",{detail:t})}}const vo=()=>{};class go extends e.FtLitElement{constructor(){super(...arguments),this.dense=!1,this.mode="auto",this.forceMobileMenuOpen=!1,this.forceMenuOpen=!1,this.baseUrl="",this.apiIntegrationIdentifier="ft-search-bar",this.availableContentLocales=[],this.availableContentLocalesInitialized=!1,this.labels={},this.labelResolver=new e.ParametrizedLabelResolver(fo,{}),this.displayedFilters=[],this.presets=[],this.priors=[],this.searchRequestSerializer=t=>function(t,e){var i;const o=new URLSearchParams({"content-lang":null!==(i=e.contentLocale)&&void 0!==i?i:"all",query:e.query});if(e.filters.length>0){const t=e.filters.map((t=>{const e=t.values.map((t=>t.replace(/_/g,"\\\\\\\\_").replace(/~/g,"\\\\~").replace(/\*/g,"\\*"))).map((t=>encodeURIComponent(function(t){return`"${t}"`}(t)))).join("_");return`${t.key}~${e}`})).join("*");o.append("filters",t)}return new URL(`${t}/search/all?${o.toString()}`).href}(this.baseUrl,t),this.searchFilters=[],this.sizeCategory=l.M,this.displayFacets=!1,this.mobileMenuOpen=!1,this.facets=[],this.facetsInitialized=!1,this.knownFacetLabels=new Map,this.query="",this.suggestions=[],this.recentSearches=[],this.suggestManager=new lo(this),this.selectedFacetsManager=new ao(this),this.desktopSearchBarManager=new ho(this),this.mobileSearchBarManager=new co(this,this.selectedFacetsManager,this.suggestManager),this.stateChangeEventDebouncer=new e.Debouncer(10),this.
|
|
2443
|
+
`;var po=function(t,e,i,o){for(var s,r=arguments.length,n=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o,l=t.length-1;l>=0;l--)(s=t[l])&&(n=(r<3?s(n):r>3?s(e,i,n):s(e,i))||n);return r>3&&n&&Object.defineProperty(e,i,n),n};null==window.fluidtopics&&console.warn("Fluid Topics public API was not found. You can find it here: https://www.npmjs.com/package/@fluid-topics/public-api");const fo={filtersButton:"Filters",inputPlaceHolder:"Search",filterInputPlaceHolder:"Filter {0}",clearInputButton:"Clear",clearFilterButton:"Clear",displayMoreFilterValuesButton:"More",noFilterValuesAvailable:"No values available",searchButton:"Search",clearFilters:"Clear filters",contentLocaleSelector:"Lang",presetsSelector:"Quick filters",removeRecentSearch:"Remove",back:"Back"};class uo extends CustomEvent{constructor(t){super("launch-search",{detail:t,bubbles:!0,composed:!0})}}class bo extends CustomEvent{constructor(t){super("change",{detail:t})}}const vo=()=>{};class go extends e.FtLitElement{constructor(){super(...arguments),this.dense=!1,this.mode="auto",this.forceMobileMenuOpen=!1,this.forceMenuOpen=!1,this.baseUrl="",this.apiIntegrationIdentifier="ft-search-bar",this.availableContentLocales=[],this.availableContentLocalesInitialized=!1,this.labels={},this.labelResolver=new e.ParametrizedLabelResolver(fo,{}),this.displayedFilters=[],this.presets=[],this.priors=[],this.searchRequestSerializer=t=>function(t,e){var i;const o=new URLSearchParams({"content-lang":null!==(i=e.contentLocale)&&void 0!==i?i:"all",query:e.query});if(e.filters.length>0){const t=e.filters.map((t=>{const e=t.values.map((t=>t.replace(/_/g,"\\\\\\\\_").replace(/~/g,"\\\\~").replace(/\*/g,"\\*"))).map((t=>encodeURIComponent(function(t){return`"${t}"`}(t)))).join("_");return`${t.key}~${e}`})).join("*");o.append("filters",t)}return new URL(`${t}/search/all?${o.toString()}`).href}(this.baseUrl,t),this.searchFilters=[],this.sizeCategory=l.M,this.displayFacets=!1,this.mobileMenuOpen=!1,this.facets=[],this.facetsInitialized=!1,this.knownFacetLabels=new Map,this.query="",this.suggestions=[],this.recentSearches=[],this.suggestManager=new lo(this),this.selectedFacetsManager=new ao(this),this.desktopSearchBarManager=new ho(this),this.mobileSearchBarManager=new co(this,this.selectedFacetsManager,this.suggestManager),this.stateChangeEventDebouncer=new e.Debouncer(10),this.updateLocalesDebouncer=new e.Debouncer(10),this.facetsLoaded=!1,this.updateFacetsDebouncer=new e.Debouncer(500),this.closeFloatingContainer=t=>{this.isMobile()||(this.displayFacets=this.displayFacets&&t.composedPath().some((t=>t===this.floatingContainer)))},this.compareFilters=(t,e)=>t.key===e.key&&t.negative==e.negative&&t.values.length===e.values.length&&t.values.every((t=>e.values.includes(t))),this.compareRequests=(t,e)=>(null==t.contentLocale||null==e.contentLocale||t.contentLocale===e.contentLocale)&&t.filters.length===e.filters.length&&t.filters.every((t=>e.filters.some((e=>this.compareFilters(t,e)))))}isMobileMenuOpen(){return this.isMobile()&&(this.forceMobileMenuOpen||this.forceMenuOpen||this.mobileMenuOpen)}get request(){return{uiLocale:this.uiLocale,contentLocale:this.contentLocale,query:this.query,facets:this.facetsRequest,priors:this.hasPriors?this.priors:void 0,filters:this.searchFilters,paging:{perPage:0,page:1},sort:[]}}get facetsRequest(){const t=this.searchFilters.filter((t=>t.values.length>0&&!this.displayedFilters.includes(t.key))).map((t=>({id:t.key})));return[...this.displayedFilters.map((t=>({id:t}))),...t]}get suggestRequest(){return{contentLocale:this.contentLocale,input:this.query,filters:this.searchFilters,sort:[]}}isMobile(){switch(this.mode){case"mobile":return!0;case"desktop":return!1;default:return this.sizeCategory===l.S}}hasFacets(){return this.facetsRequest.length>0}get hasPresets(){return null!=this.presets&&this.presets.length>0}get hasPriors(){return null!=this.priors&&this.priors.length>0}hasLocaleSelector(){return this.availableContentLocales.length>1}focus(){var t;null===(t=this.container)||void 0===t||t.focus()}focusInput(){this.input?this.input.focus():setTimeout((()=>this.focusInput()),50)}clear(){this.query="",this.searchFilters=[],this.input&&(this.input.value=""),this.mobileMenuOpen=!1,this.displayFacets=!1}render(){return i.html`
|
|
2444
2444
|
<ft-size-watcher @change=${this.updateSize}></ft-size-watcher>
|
|
2445
2445
|
${this.renderSearchBar()}
|
|
2446
2446
|
`}renderSearchBar(){return this.facetsInitialized&&this.availableContentLocalesInitialized?this.isMobile()?this.mobileSearchBarManager.render():this.desktopSearchBarManager.render():i.html`
|
|
@@ -2573,7 +2573,7 @@ const q=Symbol.for(""),W=t=>{if((null==t?void 0:t.r)===q)return null==t?void 0:t
|
|
|
2573
2573
|
></ft-filter>
|
|
2574
2574
|
`}))}
|
|
2575
2575
|
</ft-snap-scroll>
|
|
2576
|
-
`:i.nothing}async firstUpdated(t){super.firstUpdated(t),this.initApi(),window.addEventListener("storage",(t=>{t.key===this.recentSearchesStorageKey&&this.initRecentSearches()}))}update(t){var i,o,s,r,n;if(t.has("labels")&&(this.labelResolver=new e.ParametrizedLabelResolver(fo,this.labels)),t.has("sizeCategory")&&(this.mobileMenuOpen=!1,this.displayFacets=this.displayFacets&&!this.isMobile()),super.update(t),(t.has("availableContentLocales")||t.has("contentLocale"))&&this.availableContentLocales.length>0){const e=t=>this.availableContentLocales.some((e=>e.lang===t));e(this.contentLocale)||(this.contentLocale=t.has("contentLocale")&&e(t.get("contentLocale"))?t.get("contentLocale"):null===(i=this.availableContentLocales[0])||void 0===i?void 0:i.lang)}if(t.has("baseUrl")&&this.baseUrl&&(this.baseUrl.endsWith("/")&&(this.baseUrl=this.baseUrl.replace(/\/$/,"")),this.initRecentSearches()),t.has("presets")&&(null!==(o=this.presets)&&void 0!==o?o:[]).forEach((t=>t.filters.forEach((t=>t.values=t.values.map((t=>ie(t))))))),t.has("presets")||t.has("selectedPreset")){const t=(null!==(s=this.presets)&&void 0!==s?s:[]).find((t=>t.name===this.selectedPreset));t&&!this.compareRequests(this.request,t)&&this.setFiltersFromPreset(t)}t.has("contentLocale")&&null!=this.contentLocale&&(this.knownFacetLabels=new Map),["contentLocale","searchFilters"].some((e=>t.has(e)))&&(this.selectedPreset=null===(n=(null!==(r=this.presets)&&void 0!==r?r:[]).find((t=>this.compareRequests(t,this.request))))||void 0===n?void 0:n.name),["baseUrl","apiIntegrationIdentifier"].some((e=>t.has(e)))&&(this.api=void 0,this.initApi()),t.has("api")&&this.api&&this.initSearchData(),["uiLocale","contentLocale","searchFilters","displayedFilters"].some((e=>t.has(e)))&&this.updateFacets(),["query","uiLocale","contentLocale","searchFilters","displayedFilters","api"].some((e=>t.has(e)))&&this.suggestManager.update(),["query","uiLocale","contentLocale","searchFilters"].some((e=>t.has(e)))&&this.dispatchStateChangeEvent()}dispatchStateChangeEvent(){this.stateChangeEventDebouncer.run((()=>this.dispatchEvent(new bo(this.request))))}initSearchData(){this.availableContentLocalesInitialized=!1,this.facetsLoaded=!1,this.facetsInitialized=!1,this.
|
|
2576
|
+
`:i.nothing}async firstUpdated(t){super.firstUpdated(t),this.initApi(),window.addEventListener("storage",(t=>{t.key===this.recentSearchesStorageKey&&this.initRecentSearches()}))}update(t){var i,o,s,r,n;if(t.has("labels")&&(this.labelResolver=new e.ParametrizedLabelResolver(fo,this.labels)),t.has("sizeCategory")&&(this.mobileMenuOpen=!1,this.displayFacets=this.displayFacets&&!this.isMobile()),super.update(t),(t.has("availableContentLocales")||t.has("contentLocale"))&&this.availableContentLocales.length>0){const e=t=>this.availableContentLocales.some((e=>e.lang===t));e(this.contentLocale)||(this.contentLocale=t.has("contentLocale")&&e(t.get("contentLocale"))?t.get("contentLocale"):null===(i=this.availableContentLocales[0])||void 0===i?void 0:i.lang)}if(t.has("baseUrl")&&this.baseUrl&&(this.baseUrl.endsWith("/")&&(this.baseUrl=this.baseUrl.replace(/\/$/,"")),this.initRecentSearches()),t.has("presets")&&(null!==(o=this.presets)&&void 0!==o?o:[]).forEach((t=>t.filters.forEach((t=>t.values=t.values.map((t=>ie(t))))))),t.has("presets")||t.has("selectedPreset")){const t=(null!==(s=this.presets)&&void 0!==s?s:[]).find((t=>t.name===this.selectedPreset));t&&!this.compareRequests(this.request,t)&&this.setFiltersFromPreset(t)}t.has("contentLocale")&&null!=this.contentLocale&&(this.knownFacetLabels=new Map),["contentLocale","searchFilters"].some((e=>t.has(e)))&&(this.selectedPreset=null===(n=(null!==(r=this.presets)&&void 0!==r?r:[]).find((t=>this.compareRequests(t,this.request))))||void 0===n?void 0:n.name),["baseUrl","apiIntegrationIdentifier"].some((e=>t.has(e)))&&(this.api=void 0,this.initApi()),t.has("api")&&this.api&&this.initSearchData(),["uiLocale","contentLocale","searchFilters","displayedFilters"].some((e=>t.has(e)))&&this.updateFacets(),["query","uiLocale","contentLocale","searchFilters","displayedFilters","api"].some((e=>t.has(e)))&&this.suggestManager.update(),["query","uiLocale","contentLocale","searchFilters"].some((e=>t.has(e)))&&this.dispatchStateChangeEvent()}dispatchStateChangeEvent(){this.stateChangeEventDebouncer.run((()=>this.dispatchEvent(new bo(this.request))))}initSearchData(){this.availableContentLocalesInitialized=!1,this.facetsLoaded=!1,this.facetsInitialized=!1,this.updateLocalesDebouncer.run((()=>{var t;null===(t=this.api)||void 0===t||t.getAvailableSearchLocales().then((t=>t.contentLocales)).catch((()=>[])).then((t=>{this.availableContentLocales=t,this.availableContentLocalesInitialized=!0}))})),this.updateFacetsDebouncer.run((()=>{this.retrieveFacetsFromSearch().then((()=>{this.facetsLoaded=!0,this.facetsInitialized=!0}))}),this.facetsInitialized?500:10)}updateFacets(){this.api&&(this.facetsRequest.length>0?(this.facetsLoaded=!1,this.updateFacetsDebouncer.run((async()=>{await this.retrieveFacetsFromSearch(),this.facetsLoaded=!0,this.facetsInitialized=!0}),this.facetsInitialized?500:10)):this.facets=[])}contentAvailableCallback(t){var e,i,o;if(super.contentAvailableCallback(t),t.has("displayFacets")&&this.displayFacets&&(null===(e=this.floatingContainer)||void 0===e||e.focus()),null!=this.scrollToFacet&&this.facetsLoaded){null===(i=this.scrollingFiltersContainer)||void 0===i||i.scrollIndexIntoView(this.facets.findIndex((t=>t.key===this.scrollToFacet)));const t=null===(o=this.shadowRoot)||void 0===o?void 0:o.querySelector(`ft-accordion-item[data-facet-key="${this.scrollToFacet}"]`);t&&(t.active=!0),this.scrollToFacet=void 0}}initApi(){null==this.api&&(this.api=window.fluidtopics?new window.fluidtopics.FluidTopicsApi(this.baseUrl,this.apiIntegrationIdentifier,!0):void 0,setTimeout((()=>this.initApi()),10))}async retrieveFacetsFromSearch(){var t;const e=new Map;await(null===(t=this.api)||void 0===t?void 0:t.search({...this.request,query:""}).then((t=>t.facets.forEach((t=>{this.knownFacetLabels.set(t.key,t.label),e.set(t.key,t)})))).catch(vo)),this.facets=[];for(let t of this.facetsRequest)e.has(t.id)?this.facets.push(e.get(t.id)):this.knownFacetLabels.has(t.id)&&this.facets.push({key:t.id,label:this.knownFacetLabels.get(t.id),rootNodes:[],multiSelectionable:!0,hierarchical:!1})}onFloatingContainerKeyUp(t){var e;"Escape"===t.key&&(this.displayFacets=!1,null===(e=this.filtersOpener)||void 0===e||e.focus())}setQuery(t){this.input&&(this.input.value=t),this.query=t}launchSearch(){if(this.query){let t=this.recentSearches.filter((t=>t.toLowerCase()!==this.query.toLowerCase())).filter(((t,e)=>e<20));this.recentSearches=[this.query,...t],this.saveRecentSearches()}this.dispatchEvent(new uo(this.request)),this.mobileMenuOpen=!1,this.displayFacets=!1,this.focus()}get recentSearchesStorageKey(){return this.baseUrl+":ft:recent-search-queries"}initRecentSearches(){var t;this.recentSearches=JSON.parse(null!==(t=window.localStorage.getItem(this.recentSearchesStorageKey))&&void 0!==t?t:"[]")}saveRecentSearches(){const t=JSON.stringify(this.recentSearches);window.localStorage.setItem(this.recentSearchesStorageKey,t),window.dispatchEvent(new StorageEvent("storage",{key:this.recentSearchesStorageKey,newValue:t,storageArea:window.localStorage,url:window.location.href}))}connectedCallback(){super.connectedCallback(),document.addEventListener("focusin",this.closeFloatingContainer),document.addEventListener("click",this.closeFloatingContainer)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("focusin",this.closeFloatingContainer),document.addEventListener("click",this.closeFloatingContainer)}updateSize(t){this.sizeCategory=t.detail.category}setFilter(t,e){let i=this.searchFilters.filter((e=>e.key!==t));this.facets.forEach((i=>{i.key===t&&ee(i.rootNodes,(t=>t.childNodes)).forEach((t=>t.selected=e.includes(t.value)))})),e.length&&i.push({key:t,negative:!1,values:e}),this.searchFilters=i,this.scrollToFacet=t}setFiltersFromPreset(t){null!=t&&(null!=t.contentLocale&&(this.contentLocale=t.contentLocale),this.searchFilters=t.filters)}clearFilters(){this.facets.forEach((t=>ee(t.rootNodes,(t=>t.childNodes)).forEach((t=>t.selected=!1)))),this.searchFilters=[];const t=this.facets[0];this.scrollToFacet=null==t?void 0:t.key}querySelector(t){return this.shadowRoot.querySelector(t)}querySelectorAll(t){return this.shadowRoot.querySelectorAll(t)}renderDesktopFloatingMenu(){return this.forceMenuOpen?i.nothing:i.html`
|
|
2577
2577
|
<div class="ft-search-bar--floating-panel"
|
|
2578
2578
|
@keyup=${this.onFloatingContainerKeyUp}
|
|
2579
2579
|
part="floating-panel"
|
|
@@ -1298,7 +1298,7 @@ class Si extends Rt{constructor(t){if(super(t),this.it=Q,t.type!==Nt)throw Error
|
|
|
1298
1298
|
slot {
|
|
1299
1299
|
display: none;
|
|
1300
1300
|
}
|
|
1301
|
-
`];var Co=function(t,e,i,o){for(var s,r=arguments.length,n=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o,l=t.length-1;l>=0;l--)(s=t[l])&&(n=(r<3?s(n):r>3?s(e,i,n):s(e,i))||n);return r>3&&n&&Object.defineProperty(e,i,n),n};class Eo extends CustomEvent{constructor(t){super("change",{detail:t})}}class zo extends wt{constructor(){super(...arguments),this.id="",this.label="",this.filterPlaceHolder="Filter {0}",this.clearButtonLabel="Clear",this.moreValuesButtonLabel="More",this.noValuesLabel="No values available",this.options=[],this.multivalued=!1,this.disabled=!1,this.raiseSelectedOptions=!1,this.displayedValuesLimit=0,this.hideClearButton=!1,this.withScroll=!1,this.filter="",this.displayedLevels=[],this.scrollResizeObserver=new ResizeObserver((()=>this.updateScroll())),this.levelsScrollDebouncer=new e(300),this.changeDebouncer=new e(10)}get flatOptions(){return ei(this.options,(t=>{var e;return null!==(e=t.subOptions)&&void 0!==e?e:[]}))}render(){var t,e;const i=this.flatOptions.some((t=>t.selected)),o=this.withScroll||this.filter||null!==(e=null===(t=this.lastLevel)||void 0===t?void 0:t.hasHiddenValues)&&void 0!==e&&e,s=this.filterPlaceHolder.replace("{0}",this.label);return X`
|
|
1301
|
+
`];var Co=function(t,e,i,o){for(var s,r=arguments.length,n=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o,l=t.length-1;l>=0;l--)(s=t[l])&&(n=(r<3?s(n):r>3?s(e,i,n):s(e,i))||n);return r>3&&n&&Object.defineProperty(e,i,n),n};class Eo extends CustomEvent{constructor(t){super("change",{detail:t})}}class zo extends wt{constructor(){super(...arguments),this.id="",this.label="",this.filterPlaceHolder="Filter {0}",this.clearButtonLabel="Clear",this.moreValuesButtonLabel="More",this.noValuesLabel="No values available",this.options=[],this.multivalued=!1,this.disabled=!1,this.raiseSelectedOptions=!1,this.displayedValuesLimit=0,this.hideClearButton=!1,this.withScroll=!1,this.filter="",this.displayedLevels=[],this.scrollResizeObserver=new ResizeObserver((()=>this.updateScroll())),this.levelsScrollDebouncer=new e(300),this.changeDebouncer=new e(10)}get flatOptions(){return ei(this.options,(t=>{var e;return null!==(e=t.subOptions)&&void 0!==e?e:[]}))}get selectedValues(){return this.flatOptions.filter((t=>t.selected)).map((t=>t.value))}render(){var t,e;const i=this.flatOptions.some((t=>t.selected)),o=this.withScroll||this.filter||null!==(e=null===(t=this.lastLevel)||void 0===t?void 0:t.hasHiddenValues)&&void 0!==e&&e,s=this.filterPlaceHolder.replace("{0}",this.label);return X`
|
|
1302
1302
|
<div class="ft-filter--container ${this.disabled?"ft-filter--disabled":""}"
|
|
1303
1303
|
part="container">
|
|
1304
1304
|
${this.label||i?X`
|
|
@@ -1368,7 +1368,7 @@ class Si extends Rt{constructor(t){if(super(t),this.it=Q,t.type!==Nt)throw Error
|
|
|
1368
1368
|
.exportpartsPrefixes=${["values","available-values"]}
|
|
1369
1369
|
noValuesLabel="${this.noValuesLabel}"
|
|
1370
1370
|
></ft-filter-level>
|
|
1371
|
-
`}goBack(t){this.slideOut=t.detail.value}onDisplayLevel(t){this.displayedLevels.push(t.detail.value),this.slideIn=t.detail.value}clear(){if(this.flatOptions.forEach((t=>t.selected=!1)),this.displayedLevels.length>0){let t=this.displayedLevels[this.displayedLevels.length-1];this.displayedLevels=[t],this.slideOut=t}this.optionsChanged()}onChange(t){var e;t.stopPropagation();const i=this.flatOptions.find((e=>e.value===t.detail.value));i.selected=!i.selected;const o=t=>{var e;t!==i&&(t.selected=!1),null===(e=t.subOptions)||void 0===e||e.forEach(o)};this.multivalued?null===(e=i.subOptions)||void 0===e||e.forEach(o):this.options.forEach(o),this.optionsChanged()}optionsChanged(){this.changeDebouncer.run((()=>{var t;
|
|
1371
|
+
`}goBack(t){this.slideOut=t.detail.value}onDisplayLevel(t){this.displayedLevels.push(t.detail.value),this.slideIn=t.detail.value}clear(){if(this.flatOptions.forEach((t=>t.selected=!1)),this.displayedLevels.length>0){let t=this.displayedLevels[this.displayedLevels.length-1];this.displayedLevels=[t],this.slideOut=t}this.optionsChanged()}onChange(t){var e;t.stopPropagation();const i=this.flatOptions.find((e=>e.value===t.detail.value));i.selected=!i.selected;const o=t=>{var e;t!==i&&(t.selected=!1),null===(e=t.subOptions)||void 0===e||e.forEach(o)};this.multivalued?null===(e=i.subOptions)||void 0===e||e.forEach(o):this.options.forEach(o),this.optionsChanged()}optionsChanged(){this.changeDebouncer.run((()=>{var t;this.dispatchEvent(new Eo(this.selectedValues)),this.requestUpdate(),null===(t=this.levels)||void 0===t||t.forEach((t=>t.requestUpdate()))}))}updateOptionsFromSlot(t){t.stopPropagation(),this.options=this.slotElement.assignedElements().map((t=>t)),this.optionsChanged()}onFilterChange(){var t,e;this.filter=null!==(e=null===(t=this.filterInput)||void 0===t?void 0:t.value)&&void 0!==e?e:""}updateScroll(){this.valuesContainer&&(this.withScroll=this.valuesContainer.scrollHeight>this.valuesContainer.clientHeight)}}zo.elementDefinitions={"ft-button":_i,"ft-filter-level":po,"ft-snap-scroll":go,"ft-typography":ti},zo.styles=Oo,Co([o({type:String})],zo.prototype,"id",void 0),Co([o({type:String})],zo.prototype,"label",void 0),Co([o({type:String})],zo.prototype,"filterPlaceHolder",void 0),Co([o({type:String})],zo.prototype,"clearButtonLabel",void 0),Co([o({type:String})],zo.prototype,"moreValuesButtonLabel",void 0),Co([o({type:String})],zo.prototype,"noValuesLabel",void 0),Co([p([])],zo.prototype,"options",void 0),Co([o({type:Boolean})],zo.prototype,"multivalued",void 0),Co([o({type:Boolean})],zo.prototype,"disabled",void 0),Co([o({type:Boolean})],zo.prototype,"raiseSelectedOptions",void 0),Co([o({type:Number})],zo.prototype,"displayedValuesLimit",void 0),Co([o({type:Boolean})],zo.prototype,"hideClearButton",void 0),Co([n(".ft-filter--slot")],zo.prototype,"slotElement",void 0),Co([n(".ft-filter--container")],zo.prototype,"container",void 0),Co([n(".ft-filter--values")],zo.prototype,"valuesContainer",void 0),Co([n(".ft-filter--levels")],zo.prototype,"levelsContainer",void 0),Co([n(".ft-filter--levels ft-filter-level:last-child")],zo.prototype,"lastLevel",void 0),Co([n(".ft-filter--filter input")],zo.prototype,"filterInput",void 0),Co([function(t){return r({descriptor:e=>({get(){var e,i;return null!==(i=null===(e=this.renderRoot)||void 0===e?void 0:e.querySelectorAll(t))&&void 0!==i?i:[]},enumerable:!0,configurable:!0})})}(".ft-filter--levels ft-filter-level")],zo.prototype,"levels",void 0),Co([s()],zo.prototype,"withScroll",void 0),Co([s()],zo.prototype,"filter",void 0),Co([s()],zo.prototype,"slideIn",void 0),Co([s()],zo.prototype,"slideOut",void 0);var Bo=function(t,e,i,o){for(var s,r=arguments.length,n=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o,l=t.length-1;l>=0;l--)(s=t[l])&&(n=(r<3?s(n):r>3?s(e,i,n):s(e,i))||n);return r>3&&n&&Object.defineProperty(e,i,n),n};class Mo extends wt{constructor(){super(...arguments),this.label="",this.value=null,this.selected=!1,this.subOptions=[]}render(){return X`
|
|
1372
1372
|
<slot class="ft-filter-option--slot" @slotchange=${this.updateSubOptionsFromSlot}></slot>
|
|
1373
1373
|
`}updateSubOptionsFromSlot(t){t.stopPropagation(),this.subOptions=this.slotElement.assignedElements().map((t=>t))}updated(t){super.updated(t),this.dispatchEvent(new CustomEvent("option-change",{detail:this,bubbles:!0}))}}Mo.elementDefinitions={},Bo([o({type:String})],Mo.prototype,"label",void 0),Bo([o({type:Object,converter:t=>t})],Mo.prototype,"value",void 0),Bo([o({type:Boolean,reflect:!0})],Mo.prototype,"selected",void 0),Bo([o({type:Object})],Mo.prototype,"subOptions",void 0),Bo([p({})],Mo.prototype,"renderOption",void 0),Bo([n(".ft-filter-option--slot")],Mo.prototype,"slotElement",void 0),h("ft-filter")(zo),h("ft-filter-option")(Mo);const No=y`
|
|
1374
1374
|
.ft-accordion {
|
|
@@ -2103,12 +2103,12 @@ class Si extends Rt{constructor(t){if(super(t),this.it=Q,t.type!==Nt)throw Error
|
|
|
2103
2103
|
}
|
|
2104
2104
|
|
|
2105
2105
|
`,cs=y`
|
|
2106
|
-
.ft-search-bar--
|
|
2107
|
-
|
|
2106
|
+
.ft-search-bar--presets {
|
|
2107
|
+
min-width: 200px;
|
|
2108
2108
|
}
|
|
2109
2109
|
|
|
2110
2110
|
.ft-search-bar--desktop-menu .ft-search-bar--presets {
|
|
2111
|
-
|
|
2111
|
+
margin-right: auto;
|
|
2112
2112
|
${yt(ts.optionsZIndex,"2")};
|
|
2113
2113
|
}
|
|
2114
2114
|
|
|
@@ -2572,7 +2572,7 @@ class Si extends Rt{constructor(t){if(super(t),this.it=Q,t.type!==Nt)throw Error
|
|
|
2572
2572
|
</div>
|
|
2573
2573
|
`}onSearchBarKeyDown(t){var e;switch(t.key){case"Escape":this.searchBar.mobileMenuOpen=!1,null===(e=this.searchBar.input)||void 0===e||e.blur();break;case"ArrowDown":t.stopPropagation(),t.preventDefault(),this.suggestManager.focusFirstSuggestion()}}onSearchBarKeyUp(t){const e=t.composedPath()[0];this.searchBar.query=e.value,"Enter"===t.key&&this.searchBar.launchSearch()}}us.styles=y`
|
|
2574
2574
|
|
|
2575
|
-
`;var bs=function(t,e,i,o){for(var s,r=arguments.length,n=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o,l=t.length-1;l>=0;l--)(s=t[l])&&(n=(r<3?s(n):r>3?s(e,i,n):s(e,i))||n);return r>3&&n&&Object.defineProperty(e,i,n),n};null==window.fluidtopics&&console.warn("Fluid Topics public API was not found. You can find it here: https://www.npmjs.com/package/@fluid-topics/public-api");const vs={filtersButton:"Filters",inputPlaceHolder:"Search",filterInputPlaceHolder:"Filter {0}",clearInputButton:"Clear",clearFilterButton:"Clear",displayMoreFilterValuesButton:"More",noFilterValuesAvailable:"No values available",searchButton:"Search",clearFilters:"Clear filters",contentLocaleSelector:"Lang",presetsSelector:"Quick filters",removeRecentSearch:"Remove",back:"Back"};class gs extends CustomEvent{constructor(t){super("launch-search",{detail:t,bubbles:!0,composed:!0})}}class xs extends CustomEvent{constructor(t){super("change",{detail:t})}}const ys=()=>{};class ms extends wt{constructor(){super(...arguments),this.dense=!1,this.mode="auto",this.forceMobileMenuOpen=!1,this.forceMenuOpen=!1,this.baseUrl="",this.apiIntegrationIdentifier="ft-search-bar",this.availableContentLocales=[],this.availableContentLocalesInitialized=!1,this.labels={},this.labelResolver=new Ot(vs,{}),this.displayedFilters=[],this.presets=[],this.priors=[],this.searchRequestSerializer=t=>function(t,e){var i;const o=new URLSearchParams({"content-lang":null!==(i=e.contentLocale)&&void 0!==i?i:"all",query:e.query});if(e.filters.length>0){const t=e.filters.map((t=>{const e=t.values.map((t=>t.replace(/_/g,"\\\\\\\\_").replace(/~/g,"\\\\~").replace(/\*/g,"\\*"))).map((t=>encodeURIComponent(function(t){return`"${t}"`}(t)))).join("_");return`${t.key}~${e}`})).join("*");o.append("filters",t)}return new URL(`${t}/search/all?${o.toString()}`).href}(this.baseUrl,t),this.searchFilters=[],this.sizeCategory=_t.M,this.displayFacets=!1,this.mobileMenuOpen=!1,this.facets=[],this.facetsInitialized=!1,this.knownFacetLabels=new Map,this.query="",this.suggestions=[],this.recentSearches=[],this.suggestManager=new ps(this),this.selectedFacetsManager=new ds(this),this.desktopSearchBarManager=new us(this),this.mobileSearchBarManager=new fs(this,this.selectedFacetsManager,this.suggestManager),this.stateChangeEventDebouncer=new e(10),this.
|
|
2575
|
+
`;var bs=function(t,e,i,o){for(var s,r=arguments.length,n=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o,l=t.length-1;l>=0;l--)(s=t[l])&&(n=(r<3?s(n):r>3?s(e,i,n):s(e,i))||n);return r>3&&n&&Object.defineProperty(e,i,n),n};null==window.fluidtopics&&console.warn("Fluid Topics public API was not found. You can find it here: https://www.npmjs.com/package/@fluid-topics/public-api");const vs={filtersButton:"Filters",inputPlaceHolder:"Search",filterInputPlaceHolder:"Filter {0}",clearInputButton:"Clear",clearFilterButton:"Clear",displayMoreFilterValuesButton:"More",noFilterValuesAvailable:"No values available",searchButton:"Search",clearFilters:"Clear filters",contentLocaleSelector:"Lang",presetsSelector:"Quick filters",removeRecentSearch:"Remove",back:"Back"};class gs extends CustomEvent{constructor(t){super("launch-search",{detail:t,bubbles:!0,composed:!0})}}class xs extends CustomEvent{constructor(t){super("change",{detail:t})}}const ys=()=>{};class ms extends wt{constructor(){super(...arguments),this.dense=!1,this.mode="auto",this.forceMobileMenuOpen=!1,this.forceMenuOpen=!1,this.baseUrl="",this.apiIntegrationIdentifier="ft-search-bar",this.availableContentLocales=[],this.availableContentLocalesInitialized=!1,this.labels={},this.labelResolver=new Ot(vs,{}),this.displayedFilters=[],this.presets=[],this.priors=[],this.searchRequestSerializer=t=>function(t,e){var i;const o=new URLSearchParams({"content-lang":null!==(i=e.contentLocale)&&void 0!==i?i:"all",query:e.query});if(e.filters.length>0){const t=e.filters.map((t=>{const e=t.values.map((t=>t.replace(/_/g,"\\\\\\\\_").replace(/~/g,"\\\\~").replace(/\*/g,"\\*"))).map((t=>encodeURIComponent(function(t){return`"${t}"`}(t)))).join("_");return`${t.key}~${e}`})).join("*");o.append("filters",t)}return new URL(`${t}/search/all?${o.toString()}`).href}(this.baseUrl,t),this.searchFilters=[],this.sizeCategory=_t.M,this.displayFacets=!1,this.mobileMenuOpen=!1,this.facets=[],this.facetsInitialized=!1,this.knownFacetLabels=new Map,this.query="",this.suggestions=[],this.recentSearches=[],this.suggestManager=new ps(this),this.selectedFacetsManager=new ds(this),this.desktopSearchBarManager=new us(this),this.mobileSearchBarManager=new fs(this,this.selectedFacetsManager,this.suggestManager),this.stateChangeEventDebouncer=new e(10),this.updateLocalesDebouncer=new e(10),this.facetsLoaded=!1,this.updateFacetsDebouncer=new e(500),this.closeFloatingContainer=t=>{this.isMobile()||(this.displayFacets=this.displayFacets&&t.composedPath().some((t=>t===this.floatingContainer)))},this.compareFilters=(t,e)=>t.key===e.key&&t.negative==e.negative&&t.values.length===e.values.length&&t.values.every((t=>e.values.includes(t))),this.compareRequests=(t,e)=>(null==t.contentLocale||null==e.contentLocale||t.contentLocale===e.contentLocale)&&t.filters.length===e.filters.length&&t.filters.every((t=>e.filters.some((e=>this.compareFilters(t,e)))))}isMobileMenuOpen(){return this.isMobile()&&(this.forceMobileMenuOpen||this.forceMenuOpen||this.mobileMenuOpen)}get request(){return{uiLocale:this.uiLocale,contentLocale:this.contentLocale,query:this.query,facets:this.facetsRequest,priors:this.hasPriors?this.priors:void 0,filters:this.searchFilters,paging:{perPage:0,page:1},sort:[]}}get facetsRequest(){const t=this.searchFilters.filter((t=>t.values.length>0&&!this.displayedFilters.includes(t.key))).map((t=>({id:t.key})));return[...this.displayedFilters.map((t=>({id:t}))),...t]}get suggestRequest(){return{contentLocale:this.contentLocale,input:this.query,filters:this.searchFilters,sort:[]}}isMobile(){switch(this.mode){case"mobile":return!0;case"desktop":return!1;default:return this.sizeCategory===_t.S}}hasFacets(){return this.facetsRequest.length>0}get hasPresets(){return null!=this.presets&&this.presets.length>0}get hasPriors(){return null!=this.priors&&this.priors.length>0}hasLocaleSelector(){return this.availableContentLocales.length>1}focus(){var t;null===(t=this.container)||void 0===t||t.focus()}focusInput(){this.input?this.input.focus():setTimeout((()=>this.focusInput()),50)}clear(){this.query="",this.searchFilters=[],this.input&&(this.input.value=""),this.mobileMenuOpen=!1,this.displayFacets=!1}render(){return X`
|
|
2576
2576
|
<ft-size-watcher @change=${this.updateSize}></ft-size-watcher>
|
|
2577
2577
|
${this.renderSearchBar()}
|
|
2578
2578
|
`}renderSearchBar(){return this.facetsInitialized&&this.availableContentLocalesInitialized?this.isMobile()?this.mobileSearchBarManager.render():this.desktopSearchBarManager.render():X`
|
|
@@ -2705,7 +2705,7 @@ class Si extends Rt{constructor(t){if(super(t),this.it=Q,t.type!==Nt)throw Error
|
|
|
2705
2705
|
></ft-filter>
|
|
2706
2706
|
`}))}
|
|
2707
2707
|
</ft-snap-scroll>
|
|
2708
|
-
`:Q}async firstUpdated(t){super.firstUpdated(t),this.initApi(),window.addEventListener("storage",(t=>{t.key===this.recentSearchesStorageKey&&this.initRecentSearches()}))}update(t){var e,i,o,s,r;if(t.has("labels")&&(this.labelResolver=new Ot(vs,this.labels)),t.has("sizeCategory")&&(this.mobileMenuOpen=!1,this.displayFacets=this.displayFacets&&!this.isMobile()),super.update(t),(t.has("availableContentLocales")||t.has("contentLocale"))&&this.availableContentLocales.length>0){const i=t=>this.availableContentLocales.some((e=>e.lang===t));i(this.contentLocale)||(this.contentLocale=t.has("contentLocale")&&i(t.get("contentLocale"))?t.get("contentLocale"):null===(e=this.availableContentLocales[0])||void 0===e?void 0:e.lang)}if(t.has("baseUrl")&&this.baseUrl&&(this.baseUrl.endsWith("/")&&(this.baseUrl=this.baseUrl.replace(/\/$/,"")),this.initRecentSearches()),t.has("presets")&&(null!==(i=this.presets)&&void 0!==i?i:[]).forEach((t=>t.filters.forEach((t=>t.values=t.values.map((t=>ii(t))))))),t.has("presets")||t.has("selectedPreset")){const t=(null!==(o=this.presets)&&void 0!==o?o:[]).find((t=>t.name===this.selectedPreset));t&&!this.compareRequests(this.request,t)&&this.setFiltersFromPreset(t)}t.has("contentLocale")&&null!=this.contentLocale&&(this.knownFacetLabels=new Map),["contentLocale","searchFilters"].some((e=>t.has(e)))&&(this.selectedPreset=null===(r=(null!==(s=this.presets)&&void 0!==s?s:[]).find((t=>this.compareRequests(t,this.request))))||void 0===r?void 0:r.name),["baseUrl","apiIntegrationIdentifier"].some((e=>t.has(e)))&&(this.api=void 0,this.initApi()),t.has("api")&&this.api&&this.initSearchData(),["uiLocale","contentLocale","searchFilters","displayedFilters"].some((e=>t.has(e)))&&this.updateFacets(),["query","uiLocale","contentLocale","searchFilters","displayedFilters","api"].some((e=>t.has(e)))&&this.suggestManager.update(),["query","uiLocale","contentLocale","searchFilters"].some((e=>t.has(e)))&&this.dispatchStateChangeEvent()}dispatchStateChangeEvent(){this.stateChangeEventDebouncer.run((()=>this.dispatchEvent(new xs(this.request))))}initSearchData(){this.availableContentLocalesInitialized=!1,this.facetsLoaded=!1,this.facetsInitialized=!1,this.
|
|
2708
|
+
`:Q}async firstUpdated(t){super.firstUpdated(t),this.initApi(),window.addEventListener("storage",(t=>{t.key===this.recentSearchesStorageKey&&this.initRecentSearches()}))}update(t){var e,i,o,s,r;if(t.has("labels")&&(this.labelResolver=new Ot(vs,this.labels)),t.has("sizeCategory")&&(this.mobileMenuOpen=!1,this.displayFacets=this.displayFacets&&!this.isMobile()),super.update(t),(t.has("availableContentLocales")||t.has("contentLocale"))&&this.availableContentLocales.length>0){const i=t=>this.availableContentLocales.some((e=>e.lang===t));i(this.contentLocale)||(this.contentLocale=t.has("contentLocale")&&i(t.get("contentLocale"))?t.get("contentLocale"):null===(e=this.availableContentLocales[0])||void 0===e?void 0:e.lang)}if(t.has("baseUrl")&&this.baseUrl&&(this.baseUrl.endsWith("/")&&(this.baseUrl=this.baseUrl.replace(/\/$/,"")),this.initRecentSearches()),t.has("presets")&&(null!==(i=this.presets)&&void 0!==i?i:[]).forEach((t=>t.filters.forEach((t=>t.values=t.values.map((t=>ii(t))))))),t.has("presets")||t.has("selectedPreset")){const t=(null!==(o=this.presets)&&void 0!==o?o:[]).find((t=>t.name===this.selectedPreset));t&&!this.compareRequests(this.request,t)&&this.setFiltersFromPreset(t)}t.has("contentLocale")&&null!=this.contentLocale&&(this.knownFacetLabels=new Map),["contentLocale","searchFilters"].some((e=>t.has(e)))&&(this.selectedPreset=null===(r=(null!==(s=this.presets)&&void 0!==s?s:[]).find((t=>this.compareRequests(t,this.request))))||void 0===r?void 0:r.name),["baseUrl","apiIntegrationIdentifier"].some((e=>t.has(e)))&&(this.api=void 0,this.initApi()),t.has("api")&&this.api&&this.initSearchData(),["uiLocale","contentLocale","searchFilters","displayedFilters"].some((e=>t.has(e)))&&this.updateFacets(),["query","uiLocale","contentLocale","searchFilters","displayedFilters","api"].some((e=>t.has(e)))&&this.suggestManager.update(),["query","uiLocale","contentLocale","searchFilters"].some((e=>t.has(e)))&&this.dispatchStateChangeEvent()}dispatchStateChangeEvent(){this.stateChangeEventDebouncer.run((()=>this.dispatchEvent(new xs(this.request))))}initSearchData(){this.availableContentLocalesInitialized=!1,this.facetsLoaded=!1,this.facetsInitialized=!1,this.updateLocalesDebouncer.run((()=>{var t;null===(t=this.api)||void 0===t||t.getAvailableSearchLocales().then((t=>t.contentLocales)).catch((()=>[])).then((t=>{this.availableContentLocales=t,this.availableContentLocalesInitialized=!0}))})),this.updateFacetsDebouncer.run((()=>{this.retrieveFacetsFromSearch().then((()=>{this.facetsLoaded=!0,this.facetsInitialized=!0}))}),this.facetsInitialized?500:10)}updateFacets(){this.api&&(this.facetsRequest.length>0?(this.facetsLoaded=!1,this.updateFacetsDebouncer.run((async()=>{await this.retrieveFacetsFromSearch(),this.facetsLoaded=!0,this.facetsInitialized=!0}),this.facetsInitialized?500:10)):this.facets=[])}contentAvailableCallback(t){var e,i,o;if(super.contentAvailableCallback(t),t.has("displayFacets")&&this.displayFacets&&(null===(e=this.floatingContainer)||void 0===e||e.focus()),null!=this.scrollToFacet&&this.facetsLoaded){null===(i=this.scrollingFiltersContainer)||void 0===i||i.scrollIndexIntoView(this.facets.findIndex((t=>t.key===this.scrollToFacet)));const t=null===(o=this.shadowRoot)||void 0===o?void 0:o.querySelector(`ft-accordion-item[data-facet-key="${this.scrollToFacet}"]`);t&&(t.active=!0),this.scrollToFacet=void 0}}initApi(){null==this.api&&(this.api=window.fluidtopics?new window.fluidtopics.FluidTopicsApi(this.baseUrl,this.apiIntegrationIdentifier,!0):void 0,setTimeout((()=>this.initApi()),10))}async retrieveFacetsFromSearch(){var t;const e=new Map;await(null===(t=this.api)||void 0===t?void 0:t.search({...this.request,query:""}).then((t=>t.facets.forEach((t=>{this.knownFacetLabels.set(t.key,t.label),e.set(t.key,t)})))).catch(ys)),this.facets=[];for(let t of this.facetsRequest)e.has(t.id)?this.facets.push(e.get(t.id)):this.knownFacetLabels.has(t.id)&&this.facets.push({key:t.id,label:this.knownFacetLabels.get(t.id),rootNodes:[],multiSelectionable:!0,hierarchical:!1})}onFloatingContainerKeyUp(t){var e;"Escape"===t.key&&(this.displayFacets=!1,null===(e=this.filtersOpener)||void 0===e||e.focus())}setQuery(t){this.input&&(this.input.value=t),this.query=t}launchSearch(){if(this.query){let t=this.recentSearches.filter((t=>t.toLowerCase()!==this.query.toLowerCase())).filter(((t,e)=>e<20));this.recentSearches=[this.query,...t],this.saveRecentSearches()}this.dispatchEvent(new gs(this.request)),this.mobileMenuOpen=!1,this.displayFacets=!1,this.focus()}get recentSearchesStorageKey(){return this.baseUrl+":ft:recent-search-queries"}initRecentSearches(){var t;this.recentSearches=JSON.parse(null!==(t=window.localStorage.getItem(this.recentSearchesStorageKey))&&void 0!==t?t:"[]")}saveRecentSearches(){const t=JSON.stringify(this.recentSearches);window.localStorage.setItem(this.recentSearchesStorageKey,t),window.dispatchEvent(new StorageEvent("storage",{key:this.recentSearchesStorageKey,newValue:t,storageArea:window.localStorage,url:window.location.href}))}connectedCallback(){super.connectedCallback(),document.addEventListener("focusin",this.closeFloatingContainer),document.addEventListener("click",this.closeFloatingContainer)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("focusin",this.closeFloatingContainer),document.addEventListener("click",this.closeFloatingContainer)}updateSize(t){this.sizeCategory=t.detail.category}setFilter(t,e){let i=this.searchFilters.filter((e=>e.key!==t));this.facets.forEach((i=>{i.key===t&&ei(i.rootNodes,(t=>t.childNodes)).forEach((t=>t.selected=e.includes(t.value)))})),e.length&&i.push({key:t,negative:!1,values:e}),this.searchFilters=i,this.scrollToFacet=t}setFiltersFromPreset(t){null!=t&&(null!=t.contentLocale&&(this.contentLocale=t.contentLocale),this.searchFilters=t.filters)}clearFilters(){this.facets.forEach((t=>ei(t.rootNodes,(t=>t.childNodes)).forEach((t=>t.selected=!1)))),this.searchFilters=[];const t=this.facets[0];this.scrollToFacet=null==t?void 0:t.key}querySelector(t){return this.shadowRoot.querySelector(t)}querySelectorAll(t){return this.shadowRoot.querySelectorAll(t)}renderDesktopFloatingMenu(){return this.forceMenuOpen?Q:X`
|
|
2709
2709
|
<div class="ft-search-bar--floating-panel"
|
|
2710
2710
|
@keyup=${this.onFloatingContainerKeyUp}
|
|
2711
2711
|
part="floating-panel"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-topics/ft-search-bar",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.48",
|
|
4
4
|
"description": "Search bar component using Fluid Topics public API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Lit"
|
|
@@ -19,18 +19,18 @@
|
|
|
19
19
|
"url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@fluid-topics/ft-accordion": "0.3.
|
|
23
|
-
"@fluid-topics/ft-button": "0.3.
|
|
24
|
-
"@fluid-topics/ft-chip": "0.3.
|
|
25
|
-
"@fluid-topics/ft-filter": "0.3.
|
|
26
|
-
"@fluid-topics/ft-icon": "0.3.
|
|
27
|
-
"@fluid-topics/ft-select": "0.3.
|
|
28
|
-
"@fluid-topics/ft-size-watcher": "0.3.
|
|
29
|
-
"@fluid-topics/ft-skeleton": "0.3.
|
|
30
|
-
"@fluid-topics/ft-snap-scroll": "0.3.
|
|
31
|
-
"@fluid-topics/ft-tooltip": "0.3.
|
|
32
|
-
"@fluid-topics/ft-typography": "0.3.
|
|
33
|
-
"@fluid-topics/ft-wc-utils": "0.3.
|
|
22
|
+
"@fluid-topics/ft-accordion": "0.3.48",
|
|
23
|
+
"@fluid-topics/ft-button": "0.3.48",
|
|
24
|
+
"@fluid-topics/ft-chip": "0.3.48",
|
|
25
|
+
"@fluid-topics/ft-filter": "0.3.48",
|
|
26
|
+
"@fluid-topics/ft-icon": "0.3.48",
|
|
27
|
+
"@fluid-topics/ft-select": "0.3.48",
|
|
28
|
+
"@fluid-topics/ft-size-watcher": "0.3.48",
|
|
29
|
+
"@fluid-topics/ft-skeleton": "0.3.48",
|
|
30
|
+
"@fluid-topics/ft-snap-scroll": "0.3.48",
|
|
31
|
+
"@fluid-topics/ft-tooltip": "0.3.48",
|
|
32
|
+
"@fluid-topics/ft-typography": "0.3.48",
|
|
33
|
+
"@fluid-topics/ft-wc-utils": "0.3.48",
|
|
34
34
|
"lit": "2.2.8"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"@fluid-topics/public-api": "1.0.28"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "d3c000ead2ed2e15f291d09b303ad8aaa7f1ce98"
|
|
43
43
|
}
|