@fluid-topics/ft-search-bar 0.1.13 → 0.1.16

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.
@@ -34,7 +34,6 @@ export const searchBarCss = css `
34
34
  flex-direction: column;
35
35
  gap: 8px;
36
36
  color: ${FtSearchBarCssVariables.colorOnSurface};
37
- background: ${FtSearchBarCssVariables.colorSurface};
38
37
  outline: none;
39
38
  }
40
39
 
@@ -50,6 +49,7 @@ export const searchBarCss = css `
50
49
  right: ${FtSearchBarCssVariables.mobileOpenRight};
51
50
  z-index: ${FtSearchBarCssVariables.floatingZIndex};
52
51
  padding: 16px;
52
+ background: ${FtSearchBarCssVariables.colorSurface};
53
53
  }
54
54
 
55
55
  .ft-search-bar {
@@ -1,10 +1,10 @@
1
1
  import { PropertyValues } from "lit";
2
2
  import { ElementDefinitionsMap, FtLitElement, ParametrizedLabels } from "@fluid-topics/ft-wc-utils";
3
- import { FluidTopicsApi, FtSearchFacetConf, FtSearchRequest, FtSuggestRequest } from "@fluid-topics/public-api";
3
+ import { FluidTopicsApi, FtSearchFacetConf, FtSearchPreset, FtSearchRequest, FtSuggestRequest } from "@fluid-topics/public-api";
4
4
  declare global {
5
5
  interface Window {
6
6
  fluidtopics?: {
7
- FluidTopicsApi: new (tenantBaseUrl: string, integrationIdentifier: string) => FluidTopicsApi;
7
+ FluidTopicsApi: new (tenantBaseUrl: string, integrationIdentifier: string, overrideIdentifierIfOnTenant?: boolean) => FluidTopicsApi;
8
8
  };
9
9
  }
10
10
  }
@@ -24,10 +24,6 @@ export interface FtSearchBarLabels extends ParametrizedLabels {
24
24
  back?: string;
25
25
  }
26
26
  export declare const DEFAULT_LABELS: FtSearchBarLabels;
27
- declare type RelevantFtSearchRequest = Pick<FtSearchRequest, "contentLocale" | "filters"> & Partial<FtSearchRequest>;
28
- export interface FtSearchPreset extends RelevantFtSearchRequest {
29
- name: string;
30
- }
31
27
  export interface FtSearchBarProperties {
32
28
  labels?: FtSearchBarLabels;
33
29
  baseUrl: string;
@@ -337,9 +337,9 @@ let FtSearchBar = class FtSearchBar extends FtLitElement {
337
337
  <ft-select outlined
338
338
  class="ft-search-bar--content-locale ft-search-bar--left-action"
339
339
  part="content-locale"
340
- @change=${(e) => this.contentLocale = e.detail}>
340
+ @change=${(e) => this.contentLocale = e.detail == null ? undefined : e.detail}>
341
341
  ${repeat(this.availableContentLocales, l => l.lang, l => html `
342
- <ft-select-option value="${l.lang}"
342
+ <ft-select-option .value=${l.lang}
343
343
  label="${l.label}"
344
344
  ?selected=${l.lang === this.contentLocale}>
345
345
  </ft-select-option>
@@ -646,7 +646,7 @@ let FtSearchBar = class FtSearchBar extends FtLitElement {
646
646
  }
647
647
  }
648
648
  setApi() {
649
- this.api = window.fluidtopics ? new window.fluidtopics.FluidTopicsApi(this.baseUrl, this.apiIntegrationIdentifier) : undefined;
649
+ this.api = window.fluidtopics ? new window.fluidtopics.FluidTopicsApi(this.baseUrl, this.apiIntegrationIdentifier, true) : undefined;
650
650
  }
651
651
  updateFacets() {
652
652
  if (this.facetsRequest.length > 0) {
@@ -1724,14 +1724,14 @@ const ui=e.css`.mdc-touch-target-wrapper{display:inline}.mdc-radio{padding:calc(
1724
1724
  padding: 0 12px 0 16px;
1725
1725
  color: ${mo.helperColor};
1726
1726
  }
1727
- `]}getTemplate(){var t,i,a,c,n;let s=!this.disabled&&this.optionsDisplayed&&this.hasOptions,l=this.disabled||!this.hasOptions;const d={"ft-select":!0,"ft-select--filled":!this.outlined,"ft-select--outlined":this.outlined,"ft-select--disabled":l,"ft-select--options-displayed":s,"ft-select--has-value":null!=(null===(t=this.selectedOption)||void 0===t?void 0:t.value),"ft-select--no-label":!this.label};return e.html`
1728
- <div class="${r.classMap(d)}" part="container">
1727
+ `]}getTemplate(){var t,i,a,c,n;let s=!this.disabled&&this.optionsDisplayed&&this.hasOptions,l=this.disabled||!this.hasOptions;const d=null!=(null===(t=this.selectedOption)||void 0===t?void 0:t.value)||(null!==(a=null===(i=this.selectedOption)||void 0===i?void 0:i.label)&&void 0!==a?a:"").length>0,p={"ft-select":!0,"ft-select--filled":!this.outlined,"ft-select--outlined":this.outlined,"ft-select--disabled":l,"ft-select--options-displayed":s,"ft-select--has-option-selected":d,"ft-select--no-label":!this.label};return e.html`
1728
+ <div class="${r.classMap(p)}" part="container">
1729
1729
  <div class="ft-select--main-panel" part="main-panel">
1730
1730
  <ft-input-label text="${this.label}"
1731
1731
  part="label"
1732
1732
  ?disabled=${l}
1733
1733
  ?outlined=${this.outlined}
1734
- ?raised=${null!=(null===(i=this.selectedOption)||void 0===i?void 0:i.value)||s}
1734
+ ?raised=${d||s}
1735
1735
  ></ft-input-label>
1736
1736
  <div class="ft-select--input-panel"
1737
1737
  part="selected-value"
@@ -1743,7 +1743,7 @@ const ui=e.css`.mdc-touch-target-wrapper{display:inline}.mdc-radio{padding:calc(
1743
1743
  aria-expanded="${s}">
1744
1744
  <ft-ripple ?disabled=${l} ?activated=${!this.outlined}></ft-ripple>
1745
1745
  <ft-typography variant="body1" class="ft-select--selected-option">
1746
- ${null!=(null===(a=this.selectedOption)||void 0===a?void 0:a.value)&&null!==(n=null===(c=this.selectedOption)||void 0===c?void 0:c.label)&&void 0!==n?n:""}
1746
+ ${null!==(n=null===(c=this.selectedOption)||void 0===c?void 0:c.label)&&void 0!==n?n:""}
1747
1747
  </ft-typography>
1748
1748
  <mwc-icon>${s?"expand_less":"expand_more"}</mwc-icon>
1749
1749
  </div>
@@ -1780,7 +1780,6 @@ const ui=e.css`.mdc-touch-target-wrapper{display:inline}.mdc-radio{padding:calc(
1780
1780
  flex-direction: column;
1781
1781
  gap: 8px;
1782
1782
  color: ${go.colorOnSurface};
1783
- background: ${go.colorSurface};
1784
1783
  outline: none;
1785
1784
  }
1786
1785
 
@@ -1796,6 +1795,7 @@ const ui=e.css`.mdc-touch-target-wrapper{display:inline}.mdc-radio{padding:calc(
1796
1795
  right: ${go.mobileOpenRight};
1797
1796
  z-index: ${go.floatingZIndex};
1798
1797
  padding: 16px;
1798
+ background: ${go.colorSurface};
1799
1799
  }
1800
1800
 
1801
1801
  .ft-search-bar {
@@ -2261,9 +2261,9 @@ const ui=e.css`.mdc-touch-target-wrapper{display:inline}.mdc-radio{padding:calc(
2261
2261
  <ft-select outlined
2262
2262
  class="ft-search-bar--content-locale ft-search-bar--left-action"
2263
2263
  part="content-locale"
2264
- @change=${t=>this.contentLocale=t.detail}>
2264
+ @change=${t=>this.contentLocale=null==t.detail?void 0:t.detail}>
2265
2265
  ${o.repeat(this.availableContentLocales,(t=>t.lang),(t=>e.html`
2266
- <ft-select-option value="${t.lang}"
2266
+ <ft-select-option .value=${t.lang}
2267
2267
  label="${t.label}"
2268
2268
  ?selected=${t.lang===this.contentLocale}>
2269
2269
  </ft-select-option>
@@ -2429,4 +2429,4 @@ const ui=e.css`.mdc-touch-target-wrapper{display:inline}.mdc-radio{padding:calc(
2429
2429
  <ft-icon variant="${i}" part="suggestion-icon">
2430
2430
  ${o}
2431
2431
  </ft-icon>
2432
- `}openMobileFilters(t){this.isMobile&&(this.mobileMenuOpen=!0,this.displayFacets=!0,this.scrollToFacet=t)}async firstUpdated(t){var e,i;super.firstUpdated(t),this.initApi(),this.availableContentLocales=null!==(i=await(null===(e=this.api)||void 0===e?void 0:e.getAvailableSearchLocales().then((t=>t.contentLocales)).catch((()=>[]))))&&void 0!==i?i:[]}update(t){var e,i,o;if(t.has("labels")&&(this.labelResolver=new a.ParametrizedLabelResolver(_o,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.recentSearches=JSON.parse(null!==(i=window.localStorage.getItem(this.recentSearchesStorageKey))&&void 0!==i?i:"[]")),t.has("selectedPreset")){const t=this.presets.find((t=>t.name===this.selectedPreset));t&&!this.compareRequests(this.request,t)&&this.setFiltersFromPreset(t)}["contentLocale","searchFilters"].some((e=>t.has(e)))&&(this.selectedPreset=null===(o=this.presets.find((t=>this.compareRequests(t,this.request))))||void 0===o?void 0:o.name),["baseUrl","apiIntegrationIdentifier"].some((e=>t.has(e)))&&this.setApi(),["uiLocale","contentLocale","searchFilters","displayedFilters","api"].some((e=>t.has(e)))&&this.updateFacets(),["query","uiLocale","contentLocale","searchFilters","displayedFilters","api"].some((e=>t.has(e)))&&this.updateSuggestions(),["query","uiLocale","contentLocale","searchFilters"].some((e=>t.has(e)))&&this.dispatchEvent(new zo(this.request))}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.setApi(),setTimeout((()=>this.initApi()),100))}setApi(){this.api=window.fluidtopics?new window.fluidtopics.FluidTopicsApi(this.baseUrl,this.apiIntegrationIdentifier):void 0}updateFacets(){this.facetsRequest.length>0?(this.facetsLoaded=!1,this.updateFacetsDebouncer.run((async()=>{var t,e;this.facets=null!==(e=await(null===(t=this.api)||void 0===t?void 0:t.search({...this.request,query:""}).then((t=>t.facets)).catch((()=>[]))))&&void 0!==e?e:[],this.facets.forEach((t=>this.knownFacetLabels[t.key]=t.label)),this.facetsLoaded=!0}))):this.facets=[]}updateSuggestions(){this.suggestionsLoaded=!1,this.suggestDebouncer.run((async()=>{this.suggestions=this.api&&this.query.length>2?await this.api.getSuggestions(this.suggestRequest).then((t=>t.suggestions)).catch((()=>[])):[],this.suggestionsLoaded=!0}))}onSearchBarKeyUp(t){const e=t.composedPath()[0];this.query=e.value,"Enter"===t.key&&this.launchSearch()}onSearchBarKeyDown(t){var e,i;switch(t.key){case"Escape":this.mobileMenuOpen=!1,null===(e=this.input)||void 0===e||e.blur();break;case"ArrowDown":t.stopPropagation(),t.preventDefault(),null===(i=this.firstSuggestion)||void 0===i||i.focus()}}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}onSuggestClick(t,e){t.ctrlKey||t.metaKey||this.onSuggestSelected(t,e)}onSuggestKeyUp(t,e){"Enter"!==t.key&&" "!==t.key||this.onSuggestSelected(t,e)}onSuggestSelected(t,e){t.preventDefault(),this.setQuery(e),this.launchSearch()}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 wo(this.request)),this.mobileMenuOpen=!1,this.displayFacets=!1,this.focus()}saveRecentSearches(){window.localStorage.setItem(this.recentSearchesStorageKey,JSON.stringify(this.recentSearches))}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}getLocaleLabel(t){var e;return null!==(e=this.availableContentLocales.filter((e=>{var i;return(null!==(i=e.lang)&&void 0!==i?i:"").toLowerCase()===(null!=t?t:"").toLowerCase()})).map((t=>t.label)).pop())&&void 0!==e?e:t}setFilter(t,e){let i=this.searchFilters.filter((e=>e.key!==t));this.facets.forEach((i=>{i.key===t&&Jt(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=>Jt(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}removeRecentSearch(t,e){var i,o,r,a;t.preventDefault(),t.stopPropagation();const c=null!==(a=null!==(o=null===(i=this.focusedSuggestion)||void 0===i?void 0:i.previousElementSibling)&&void 0!==o?o:null===(r=this.focusedSuggestion)||void 0===r?void 0:r.nextElementSibling)&&void 0!==a?a:this.input;null==c||c.focus(),this.recentSearches=this.recentSearches.filter((t=>t.toLowerCase()!==e.toLowerCase())),this.saveRecentSearches()}onSuggestKeyDown(t){var e,i,o,r,a,c;switch(t.key){case"ArrowUp":null===(o=null!==(i=null===(e=this.focusedSuggestion)||void 0===e?void 0:e.previousElementSibling)&&void 0!==i?i:this.lastSuggestion)||void 0===o||o.focus(),t.preventDefault(),t.stopPropagation();break;case"ArrowDown":null===(c=null!==(a=null===(r=this.focusedSuggestion)||void 0===r?void 0:r.nextElementSibling)&&void 0!==a?a:this.firstSuggestion)||void 0===c||c.focus(),t.preventDefault(),t.stopPropagation()}}},t.FtSearchBar.elementDefinitions={"ft-accordion":Qi,"ft-accordion-item":Ji,"ft-button":Qe,"ft-chip":so,"ft-filter":Ii,"ft-filter-option":wi,"ft-icon":qi,"ft-ripple":Fe,"ft-select":bo,"ft-select-option":uo,"ft-size-watcher":p,"ft-snap-scroll":$i,"ft-tooltip":He,"ft-typography":Xt,"mwc-icon":Re},$o([i.property({type:Boolean})],t.FtSearchBar.prototype,"dense",void 0),$o([i.property({type:String})],t.FtSearchBar.prototype,"baseUrl",void 0),$o([i.property({type:String})],t.FtSearchBar.prototype,"apiIntegrationIdentifier",void 0),$o([i.property({type:String})],t.FtSearchBar.prototype,"contentLocale",void 0),$o([i.state()],t.FtSearchBar.prototype,"availableContentLocales",void 0),$o([i.property({type:String})],t.FtSearchBar.prototype,"uiLocale",void 0),$o([a.jsonProperty({})],t.FtSearchBar.prototype,"labels",void 0),$o([a.jsonProperty([])],t.FtSearchBar.prototype,"displayedFilters",void 0),$o([a.jsonProperty([])],t.FtSearchBar.prototype,"presets",void 0),$o([i.property({type:String,reflect:!0})],t.FtSearchBar.prototype,"selectedPreset",void 0),$o([i.property()],t.FtSearchBar.prototype,"searchRequestSerializer",void 0),$o([i.state()],t.FtSearchBar.prototype,"searchFilters",void 0),$o([i.state()],t.FtSearchBar.prototype,"sizeCategory",void 0),$o([i.state()],t.FtSearchBar.prototype,"displayFacets",void 0),$o([i.state()],t.FtSearchBar.prototype,"mobileMenuOpen",void 0),$o([i.state()],t.FtSearchBar.prototype,"facets",void 0),$o([i.query(".ft-search-bar--container")],t.FtSearchBar.prototype,"container",void 0),$o([i.query(".ft-search-bar--filters-opener")],t.FtSearchBar.prototype,"filtersOpener",void 0),$o([i.query(".ft-search-bar--floating-panel")],t.FtSearchBar.prototype,"floatingContainer",void 0),$o([i.query("ft-snap-scroll.ft-search-bar--filters-container")],t.FtSearchBar.prototype,"scrollingFiltersContainer",void 0),$o([i.query(".ft-search-bar--input")],t.FtSearchBar.prototype,"input",void 0),$o([i.state()],t.FtSearchBar.prototype,"query",void 0),$o([i.state()],t.FtSearchBar.prototype,"suggestions",void 0),$o([i.state()],t.FtSearchBar.prototype,"suggestionsLoaded",void 0),$o([i.state()],t.FtSearchBar.prototype,"recentSearches",void 0),$o([i.state()],t.FtSearchBar.prototype,"scrollToFacet",void 0),$o([i.query(".ft-search-bar--suggestion:first-child")],t.FtSearchBar.prototype,"firstSuggestion",void 0),$o([i.query(".ft-search-bar--suggestion:focus-within")],t.FtSearchBar.prototype,"focusedSuggestion",void 0),$o([i.query(".ft-search-bar--suggestion:last-child")],t.FtSearchBar.prototype,"lastSuggestion",void 0),$o([i.state()],t.FtSearchBar.prototype,"api",void 0),t.FtSearchBar=$o([a.customElement("ft-search-bar")],t.FtSearchBar),t.DEFAULT_LABELS=_o,t.FtSearchBarCssVariables=go,t.LaunchSearchEvent=wo,t.SearchStateChangeEvent=zo,Object.defineProperty(t,"t",{value:!0})}({},ftGlobals.lit,ftGlobals.litDecorators,ftGlobals.litRepeat,ftGlobals.litClassMap,ftGlobals.wcUtils,ftGlobals.litStyleMap,ftGlobals.litUnsafeHTML);
2432
+ `}openMobileFilters(t){this.isMobile&&(this.mobileMenuOpen=!0,this.displayFacets=!0,this.scrollToFacet=t)}async firstUpdated(t){var e,i;super.firstUpdated(t),this.initApi(),this.availableContentLocales=null!==(i=await(null===(e=this.api)||void 0===e?void 0:e.getAvailableSearchLocales().then((t=>t.contentLocales)).catch((()=>[]))))&&void 0!==i?i:[]}update(t){var e,i,o;if(t.has("labels")&&(this.labelResolver=new a.ParametrizedLabelResolver(_o,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.recentSearches=JSON.parse(null!==(i=window.localStorage.getItem(this.recentSearchesStorageKey))&&void 0!==i?i:"[]")),t.has("selectedPreset")){const t=this.presets.find((t=>t.name===this.selectedPreset));t&&!this.compareRequests(this.request,t)&&this.setFiltersFromPreset(t)}["contentLocale","searchFilters"].some((e=>t.has(e)))&&(this.selectedPreset=null===(o=this.presets.find((t=>this.compareRequests(t,this.request))))||void 0===o?void 0:o.name),["baseUrl","apiIntegrationIdentifier"].some((e=>t.has(e)))&&this.setApi(),["uiLocale","contentLocale","searchFilters","displayedFilters","api"].some((e=>t.has(e)))&&this.updateFacets(),["query","uiLocale","contentLocale","searchFilters","displayedFilters","api"].some((e=>t.has(e)))&&this.updateSuggestions(),["query","uiLocale","contentLocale","searchFilters"].some((e=>t.has(e)))&&this.dispatchEvent(new zo(this.request))}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.setApi(),setTimeout((()=>this.initApi()),100))}setApi(){this.api=window.fluidtopics?new window.fluidtopics.FluidTopicsApi(this.baseUrl,this.apiIntegrationIdentifier,!0):void 0}updateFacets(){this.facetsRequest.length>0?(this.facetsLoaded=!1,this.updateFacetsDebouncer.run((async()=>{var t,e;this.facets=null!==(e=await(null===(t=this.api)||void 0===t?void 0:t.search({...this.request,query:""}).then((t=>t.facets)).catch((()=>[]))))&&void 0!==e?e:[],this.facets.forEach((t=>this.knownFacetLabels[t.key]=t.label)),this.facetsLoaded=!0}))):this.facets=[]}updateSuggestions(){this.suggestionsLoaded=!1,this.suggestDebouncer.run((async()=>{this.suggestions=this.api&&this.query.length>2?await this.api.getSuggestions(this.suggestRequest).then((t=>t.suggestions)).catch((()=>[])):[],this.suggestionsLoaded=!0}))}onSearchBarKeyUp(t){const e=t.composedPath()[0];this.query=e.value,"Enter"===t.key&&this.launchSearch()}onSearchBarKeyDown(t){var e,i;switch(t.key){case"Escape":this.mobileMenuOpen=!1,null===(e=this.input)||void 0===e||e.blur();break;case"ArrowDown":t.stopPropagation(),t.preventDefault(),null===(i=this.firstSuggestion)||void 0===i||i.focus()}}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}onSuggestClick(t,e){t.ctrlKey||t.metaKey||this.onSuggestSelected(t,e)}onSuggestKeyUp(t,e){"Enter"!==t.key&&" "!==t.key||this.onSuggestSelected(t,e)}onSuggestSelected(t,e){t.preventDefault(),this.setQuery(e),this.launchSearch()}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 wo(this.request)),this.mobileMenuOpen=!1,this.displayFacets=!1,this.focus()}saveRecentSearches(){window.localStorage.setItem(this.recentSearchesStorageKey,JSON.stringify(this.recentSearches))}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}getLocaleLabel(t){var e;return null!==(e=this.availableContentLocales.filter((e=>{var i;return(null!==(i=e.lang)&&void 0!==i?i:"").toLowerCase()===(null!=t?t:"").toLowerCase()})).map((t=>t.label)).pop())&&void 0!==e?e:t}setFilter(t,e){let i=this.searchFilters.filter((e=>e.key!==t));this.facets.forEach((i=>{i.key===t&&Jt(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=>Jt(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}removeRecentSearch(t,e){var i,o,r,a;t.preventDefault(),t.stopPropagation();const c=null!==(a=null!==(o=null===(i=this.focusedSuggestion)||void 0===i?void 0:i.previousElementSibling)&&void 0!==o?o:null===(r=this.focusedSuggestion)||void 0===r?void 0:r.nextElementSibling)&&void 0!==a?a:this.input;null==c||c.focus(),this.recentSearches=this.recentSearches.filter((t=>t.toLowerCase()!==e.toLowerCase())),this.saveRecentSearches()}onSuggestKeyDown(t){var e,i,o,r,a,c;switch(t.key){case"ArrowUp":null===(o=null!==(i=null===(e=this.focusedSuggestion)||void 0===e?void 0:e.previousElementSibling)&&void 0!==i?i:this.lastSuggestion)||void 0===o||o.focus(),t.preventDefault(),t.stopPropagation();break;case"ArrowDown":null===(c=null!==(a=null===(r=this.focusedSuggestion)||void 0===r?void 0:r.nextElementSibling)&&void 0!==a?a:this.firstSuggestion)||void 0===c||c.focus(),t.preventDefault(),t.stopPropagation()}}},t.FtSearchBar.elementDefinitions={"ft-accordion":Qi,"ft-accordion-item":Ji,"ft-button":Qe,"ft-chip":so,"ft-filter":Ii,"ft-filter-option":wi,"ft-icon":qi,"ft-ripple":Fe,"ft-select":bo,"ft-select-option":uo,"ft-size-watcher":p,"ft-snap-scroll":$i,"ft-tooltip":He,"ft-typography":Xt,"mwc-icon":Re},$o([i.property({type:Boolean})],t.FtSearchBar.prototype,"dense",void 0),$o([i.property({type:String})],t.FtSearchBar.prototype,"baseUrl",void 0),$o([i.property({type:String})],t.FtSearchBar.prototype,"apiIntegrationIdentifier",void 0),$o([i.property({type:String})],t.FtSearchBar.prototype,"contentLocale",void 0),$o([i.state()],t.FtSearchBar.prototype,"availableContentLocales",void 0),$o([i.property({type:String})],t.FtSearchBar.prototype,"uiLocale",void 0),$o([a.jsonProperty({})],t.FtSearchBar.prototype,"labels",void 0),$o([a.jsonProperty([])],t.FtSearchBar.prototype,"displayedFilters",void 0),$o([a.jsonProperty([])],t.FtSearchBar.prototype,"presets",void 0),$o([i.property({type:String,reflect:!0})],t.FtSearchBar.prototype,"selectedPreset",void 0),$o([i.property()],t.FtSearchBar.prototype,"searchRequestSerializer",void 0),$o([i.state()],t.FtSearchBar.prototype,"searchFilters",void 0),$o([i.state()],t.FtSearchBar.prototype,"sizeCategory",void 0),$o([i.state()],t.FtSearchBar.prototype,"displayFacets",void 0),$o([i.state()],t.FtSearchBar.prototype,"mobileMenuOpen",void 0),$o([i.state()],t.FtSearchBar.prototype,"facets",void 0),$o([i.query(".ft-search-bar--container")],t.FtSearchBar.prototype,"container",void 0),$o([i.query(".ft-search-bar--filters-opener")],t.FtSearchBar.prototype,"filtersOpener",void 0),$o([i.query(".ft-search-bar--floating-panel")],t.FtSearchBar.prototype,"floatingContainer",void 0),$o([i.query("ft-snap-scroll.ft-search-bar--filters-container")],t.FtSearchBar.prototype,"scrollingFiltersContainer",void 0),$o([i.query(".ft-search-bar--input")],t.FtSearchBar.prototype,"input",void 0),$o([i.state()],t.FtSearchBar.prototype,"query",void 0),$o([i.state()],t.FtSearchBar.prototype,"suggestions",void 0),$o([i.state()],t.FtSearchBar.prototype,"suggestionsLoaded",void 0),$o([i.state()],t.FtSearchBar.prototype,"recentSearches",void 0),$o([i.state()],t.FtSearchBar.prototype,"scrollToFacet",void 0),$o([i.query(".ft-search-bar--suggestion:first-child")],t.FtSearchBar.prototype,"firstSuggestion",void 0),$o([i.query(".ft-search-bar--suggestion:focus-within")],t.FtSearchBar.prototype,"focusedSuggestion",void 0),$o([i.query(".ft-search-bar--suggestion:last-child")],t.FtSearchBar.prototype,"lastSuggestion",void 0),$o([i.state()],t.FtSearchBar.prototype,"api",void 0),t.FtSearchBar=$o([a.customElement("ft-search-bar")],t.FtSearchBar),t.DEFAULT_LABELS=_o,t.FtSearchBarCssVariables=go,t.LaunchSearchEvent=wo,t.SearchStateChangeEvent=zo,Object.defineProperty(t,"t",{value:!0})}({},ftGlobals.lit,ftGlobals.litDecorators,ftGlobals.litRepeat,ftGlobals.litClassMap,ftGlobals.wcUtils,ftGlobals.litStyleMap,ftGlobals.litUnsafeHTML);
@@ -1839,14 +1839,14 @@ class Nr extends vt{constructor(t){if(super(t),this.it=M,t.type!==mt)throw Error
1839
1839
  padding: 0 12px 0 16px;
1840
1840
  color: ${bo.helperColor};
1841
1841
  }
1842
- `]}getTemplate(){var t,e,i,r,o;let n=!this.disabled&&this.optionsDisplayed&&this.hasOptions,a=this.disabled||!this.hasOptions;const c={"ft-select":!0,"ft-select--filled":!this.outlined,"ft-select--outlined":this.outlined,"ft-select--disabled":a,"ft-select--options-displayed":n,"ft-select--has-value":null!=(null===(t=this.selectedOption)||void 0===t?void 0:t.value),"ft-select--no-label":!this.label};return A`
1843
- <div class="${Ot(c)}" part="container">
1842
+ `]}getTemplate(){var t,e,i,r,o;let n=!this.disabled&&this.optionsDisplayed&&this.hasOptions,a=this.disabled||!this.hasOptions;const c=null!=(null===(t=this.selectedOption)||void 0===t?void 0:t.value)||(null!==(i=null===(e=this.selectedOption)||void 0===e?void 0:e.label)&&void 0!==i?i:"").length>0,s={"ft-select":!0,"ft-select--filled":!this.outlined,"ft-select--outlined":this.outlined,"ft-select--disabled":a,"ft-select--options-displayed":n,"ft-select--has-option-selected":c,"ft-select--no-label":!this.label};return A`
1843
+ <div class="${Ot(s)}" part="container">
1844
1844
  <div class="ft-select--main-panel" part="main-panel">
1845
1845
  <ft-input-label text="${this.label}"
1846
1846
  part="label"
1847
1847
  ?disabled=${a}
1848
1848
  ?outlined=${this.outlined}
1849
- ?raised=${null!=(null===(e=this.selectedOption)||void 0===e?void 0:e.value)||n}
1849
+ ?raised=${c||n}
1850
1850
  ></ft-input-label>
1851
1851
  <div class="ft-select--input-panel"
1852
1852
  part="selected-value"
@@ -1858,7 +1858,7 @@ class Nr extends vt{constructor(t){if(super(t),this.it=M,t.type!==mt)throw Error
1858
1858
  aria-expanded="${n}">
1859
1859
  <ft-ripple ?disabled=${a} ?activated=${!this.outlined}></ft-ripple>
1860
1860
  <ft-typography variant="body1" class="ft-select--selected-option">
1861
- ${null!=(null===(i=this.selectedOption)||void 0===i?void 0:i.value)&&null!==(o=null===(r=this.selectedOption)||void 0===r?void 0:r.label)&&void 0!==o?o:""}
1861
+ ${null!==(o=null===(r=this.selectedOption)||void 0===r?void 0:r.label)&&void 0!==o?o:""}
1862
1862
  </ft-typography>
1863
1863
  <mwc-icon>${n?"expand_less":"expand_more"}</mwc-icon>
1864
1864
  </div>
@@ -1895,7 +1895,6 @@ class Nr extends vt{constructor(t){if(super(t),this.it=M,t.type!==mt)throw Error
1895
1895
  flex-direction: column;
1896
1896
  gap: 8px;
1897
1897
  color: ${go.colorOnSurface};
1898
- background: ${go.colorSurface};
1899
1898
  outline: none;
1900
1899
  }
1901
1900
 
@@ -1911,6 +1910,7 @@ class Nr extends vt{constructor(t){if(super(t),this.it=M,t.type!==mt)throw Error
1911
1910
  right: ${go.mobileOpenRight};
1912
1911
  z-index: ${go.floatingZIndex};
1913
1912
  padding: 16px;
1913
+ background: ${go.colorSurface};
1914
1914
  }
1915
1915
 
1916
1916
  .ft-search-bar {
@@ -2376,9 +2376,9 @@ class Nr extends vt{constructor(t){if(super(t),this.it=M,t.type!==mt)throw Error
2376
2376
  <ft-select outlined
2377
2377
  class="ft-search-bar--content-locale ft-search-bar--left-action"
2378
2378
  part="content-locale"
2379
- @change=${t=>this.contentLocale=t.detail}>
2379
+ @change=${t=>this.contentLocale=null==t.detail?void 0:t.detail}>
2380
2380
  ${St(this.availableContentLocales,(t=>t.lang),(t=>A`
2381
- <ft-select-option value="${t.lang}"
2381
+ <ft-select-option .value=${t.lang}
2382
2382
  label="${t.label}"
2383
2383
  ?selected=${t.lang===this.contentLocale}>
2384
2384
  </ft-select-option>
@@ -2544,4 +2544,4 @@ class Nr extends vt{constructor(t){if(super(t),this.it=M,t.type!==mt)throw Error
2544
2544
  <ft-icon variant="${e}" part="suggestion-icon">
2545
2545
  ${i}
2546
2546
  </ft-icon>
2547
- `}openMobileFilters(t){this.isMobile&&(this.mobileMenuOpen=!0,this.displayFacets=!0,this.scrollToFacet=t)}async firstUpdated(t){var e,i;super.firstUpdated(t),this.initApi(),this.availableContentLocales=null!==(i=await(null===(e=this.api)||void 0===e?void 0:e.getAvailableSearchLocales().then((t=>t.contentLocales)).catch((()=>[]))))&&void 0!==i?i:[]}update(t){var e,i,r;if(t.has("labels")&&(this.labelResolver=new At(_o,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.recentSearches=JSON.parse(null!==(i=window.localStorage.getItem(this.recentSearchesStorageKey))&&void 0!==i?i:"[]")),t.has("selectedPreset")){const t=this.presets.find((t=>t.name===this.selectedPreset));t&&!this.compareRequests(this.request,t)&&this.setFiltersFromPreset(t)}["contentLocale","searchFilters"].some((e=>t.has(e)))&&(this.selectedPreset=null===(r=this.presets.find((t=>this.compareRequests(t,this.request))))||void 0===r?void 0:r.name),["baseUrl","apiIntegrationIdentifier"].some((e=>t.has(e)))&&this.setApi(),["uiLocale","contentLocale","searchFilters","displayedFilters","api"].some((e=>t.has(e)))&&this.updateFacets(),["query","uiLocale","contentLocale","searchFilters","displayedFilters","api"].some((e=>t.has(e)))&&this.updateSuggestions(),["query","uiLocale","contentLocale","searchFilters"].some((e=>t.has(e)))&&this.dispatchEvent(new Oo(this.request))}contentAvailableCallback(t){var e,i,r;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===(r=this.shadowRoot)||void 0===r?void 0:r.querySelector(`ft-accordion-item[data-facet-key="${this.scrollToFacet}"]`);t&&(t.active=!0),this.scrollToFacet=void 0}}initApi(){null==this.api&&(this.setApi(),setTimeout((()=>this.initApi()),100))}setApi(){this.api=window.fluidtopics?new window.fluidtopics.FluidTopicsApi(this.baseUrl,this.apiIntegrationIdentifier):void 0}updateFacets(){this.facetsRequest.length>0?(this.facetsLoaded=!1,this.updateFacetsDebouncer.run((async()=>{var t,e;this.facets=null!==(e=await(null===(t=this.api)||void 0===t?void 0:t.search({...this.request,query:""}).then((t=>t.facets)).catch((()=>[]))))&&void 0!==e?e:[],this.facets.forEach((t=>this.knownFacetLabels[t.key]=t.label)),this.facetsLoaded=!0}))):this.facets=[]}updateSuggestions(){this.suggestionsLoaded=!1,this.suggestDebouncer.run((async()=>{this.suggestions=this.api&&this.query.length>2?await this.api.getSuggestions(this.suggestRequest).then((t=>t.suggestions)).catch((()=>[])):[],this.suggestionsLoaded=!0}))}onSearchBarKeyUp(t){const e=t.composedPath()[0];this.query=e.value,"Enter"===t.key&&this.launchSearch()}onSearchBarKeyDown(t){var e,i;switch(t.key){case"Escape":this.mobileMenuOpen=!1,null===(e=this.input)||void 0===e||e.blur();break;case"ArrowDown":t.stopPropagation(),t.preventDefault(),null===(i=this.firstSuggestion)||void 0===i||i.focus()}}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}onSuggestClick(t,e){t.ctrlKey||t.metaKey||this.onSuggestSelected(t,e)}onSuggestKeyUp(t,e){"Enter"!==t.key&&" "!==t.key||this.onSuggestSelected(t,e)}onSuggestSelected(t,e){t.preventDefault(),this.setQuery(e),this.launchSearch()}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 So(this.request)),this.mobileMenuOpen=!1,this.displayFacets=!1,this.focus()}saveRecentSearches(){window.localStorage.setItem(this.recentSearchesStorageKey,JSON.stringify(this.recentSearches))}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}getLocaleLabel(t){var e;return null!==(e=this.availableContentLocales.filter((e=>{var i;return(null!==(i=e.lang)&&void 0!==i?i:"").toLowerCase()===(null!=t?t:"").toLowerCase()})).map((t=>t.label)).pop())&&void 0!==e?e:t}setFilter(t,e){let i=this.searchFilters.filter((e=>e.key!==t));this.facets.forEach((i=>{i.key===t&&Ge(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=>Ge(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}removeRecentSearch(t,e){var i,r,o,n;t.preventDefault(),t.stopPropagation();const a=null!==(n=null!==(r=null===(i=this.focusedSuggestion)||void 0===i?void 0:i.previousElementSibling)&&void 0!==r?r:null===(o=this.focusedSuggestion)||void 0===o?void 0:o.nextElementSibling)&&void 0!==n?n:this.input;null==a||a.focus(),this.recentSearches=this.recentSearches.filter((t=>t.toLowerCase()!==e.toLowerCase())),this.saveRecentSearches()}onSuggestKeyDown(t){var e,i,r,o,n,a;switch(t.key){case"ArrowUp":null===(r=null!==(i=null===(e=this.focusedSuggestion)||void 0===e?void 0:e.previousElementSibling)&&void 0!==i?i:this.lastSuggestion)||void 0===r||r.focus(),t.preventDefault(),t.stopPropagation();break;case"ArrowDown":null===(a=null!==(n=null===(o=this.focusedSuggestion)||void 0===o?void 0:o.nextElementSibling)&&void 0!==n?n:this.firstSuggestion)||void 0===a||a.focus(),t.preventDefault(),t.stopPropagation()}}},t.FtSearchBar.elementDefinitions={"ft-accordion":to,"ft-accordion-item":Yr,"ft-button":Yi,"ft-chip":lo,"ft-filter":Tr,"ft-filter-option":$r,"ft-icon":Kr,"ft-ripple":Fi,"ft-select":vo,"ft-select-option":mo,"ft-size-watcher":Ht,"ft-snap-scroll":kr,"ft-tooltip":Ui,"ft-typography":qe,"mwc-icon":Ni},$o([nt({type:Boolean})],t.FtSearchBar.prototype,"dense",void 0),$o([nt({type:String})],t.FtSearchBar.prototype,"baseUrl",void 0),$o([nt({type:String})],t.FtSearchBar.prototype,"apiIntegrationIdentifier",void 0),$o([nt({type:String})],t.FtSearchBar.prototype,"contentLocale",void 0),$o([at()],t.FtSearchBar.prototype,"availableContentLocales",void 0),$o([nt({type:String})],t.FtSearchBar.prototype,"uiLocale",void 0),$o([Et({})],t.FtSearchBar.prototype,"labels",void 0),$o([Et([])],t.FtSearchBar.prototype,"displayedFilters",void 0),$o([Et([])],t.FtSearchBar.prototype,"presets",void 0),$o([nt({type:String,reflect:!0})],t.FtSearchBar.prototype,"selectedPreset",void 0),$o([nt()],t.FtSearchBar.prototype,"searchRequestSerializer",void 0),$o([at()],t.FtSearchBar.prototype,"searchFilters",void 0),$o([at()],t.FtSearchBar.prototype,"sizeCategory",void 0),$o([at()],t.FtSearchBar.prototype,"displayFacets",void 0),$o([at()],t.FtSearchBar.prototype,"mobileMenuOpen",void 0),$o([at()],t.FtSearchBar.prototype,"facets",void 0),$o([lt(".ft-search-bar--container")],t.FtSearchBar.prototype,"container",void 0),$o([lt(".ft-search-bar--filters-opener")],t.FtSearchBar.prototype,"filtersOpener",void 0),$o([lt(".ft-search-bar--floating-panel")],t.FtSearchBar.prototype,"floatingContainer",void 0),$o([lt("ft-snap-scroll.ft-search-bar--filters-container")],t.FtSearchBar.prototype,"scrollingFiltersContainer",void 0),$o([lt(".ft-search-bar--input")],t.FtSearchBar.prototype,"input",void 0),$o([at()],t.FtSearchBar.prototype,"query",void 0),$o([at()],t.FtSearchBar.prototype,"suggestions",void 0),$o([at()],t.FtSearchBar.prototype,"suggestionsLoaded",void 0),$o([at()],t.FtSearchBar.prototype,"recentSearches",void 0),$o([at()],t.FtSearchBar.prototype,"scrollToFacet",void 0),$o([lt(".ft-search-bar--suggestion:first-child")],t.FtSearchBar.prototype,"firstSuggestion",void 0),$o([lt(".ft-search-bar--suggestion:focus-within")],t.FtSearchBar.prototype,"focusedSuggestion",void 0),$o([lt(".ft-search-bar--suggestion:last-child")],t.FtSearchBar.prototype,"lastSuggestion",void 0),$o([at()],t.FtSearchBar.prototype,"api",void 0),t.FtSearchBar=$o([Ct("ft-search-bar")],t.FtSearchBar),t.DEFAULT_LABELS=_o,t.FtSearchBarCssVariables=go,t.LaunchSearchEvent=So,t.SearchStateChangeEvent=Oo,Object.defineProperty(t,"t",{value:!0})}({});
2547
+ `}openMobileFilters(t){this.isMobile&&(this.mobileMenuOpen=!0,this.displayFacets=!0,this.scrollToFacet=t)}async firstUpdated(t){var e,i;super.firstUpdated(t),this.initApi(),this.availableContentLocales=null!==(i=await(null===(e=this.api)||void 0===e?void 0:e.getAvailableSearchLocales().then((t=>t.contentLocales)).catch((()=>[]))))&&void 0!==i?i:[]}update(t){var e,i,r;if(t.has("labels")&&(this.labelResolver=new At(_o,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.recentSearches=JSON.parse(null!==(i=window.localStorage.getItem(this.recentSearchesStorageKey))&&void 0!==i?i:"[]")),t.has("selectedPreset")){const t=this.presets.find((t=>t.name===this.selectedPreset));t&&!this.compareRequests(this.request,t)&&this.setFiltersFromPreset(t)}["contentLocale","searchFilters"].some((e=>t.has(e)))&&(this.selectedPreset=null===(r=this.presets.find((t=>this.compareRequests(t,this.request))))||void 0===r?void 0:r.name),["baseUrl","apiIntegrationIdentifier"].some((e=>t.has(e)))&&this.setApi(),["uiLocale","contentLocale","searchFilters","displayedFilters","api"].some((e=>t.has(e)))&&this.updateFacets(),["query","uiLocale","contentLocale","searchFilters","displayedFilters","api"].some((e=>t.has(e)))&&this.updateSuggestions(),["query","uiLocale","contentLocale","searchFilters"].some((e=>t.has(e)))&&this.dispatchEvent(new Oo(this.request))}contentAvailableCallback(t){var e,i,r;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===(r=this.shadowRoot)||void 0===r?void 0:r.querySelector(`ft-accordion-item[data-facet-key="${this.scrollToFacet}"]`);t&&(t.active=!0),this.scrollToFacet=void 0}}initApi(){null==this.api&&(this.setApi(),setTimeout((()=>this.initApi()),100))}setApi(){this.api=window.fluidtopics?new window.fluidtopics.FluidTopicsApi(this.baseUrl,this.apiIntegrationIdentifier,!0):void 0}updateFacets(){this.facetsRequest.length>0?(this.facetsLoaded=!1,this.updateFacetsDebouncer.run((async()=>{var t,e;this.facets=null!==(e=await(null===(t=this.api)||void 0===t?void 0:t.search({...this.request,query:""}).then((t=>t.facets)).catch((()=>[]))))&&void 0!==e?e:[],this.facets.forEach((t=>this.knownFacetLabels[t.key]=t.label)),this.facetsLoaded=!0}))):this.facets=[]}updateSuggestions(){this.suggestionsLoaded=!1,this.suggestDebouncer.run((async()=>{this.suggestions=this.api&&this.query.length>2?await this.api.getSuggestions(this.suggestRequest).then((t=>t.suggestions)).catch((()=>[])):[],this.suggestionsLoaded=!0}))}onSearchBarKeyUp(t){const e=t.composedPath()[0];this.query=e.value,"Enter"===t.key&&this.launchSearch()}onSearchBarKeyDown(t){var e,i;switch(t.key){case"Escape":this.mobileMenuOpen=!1,null===(e=this.input)||void 0===e||e.blur();break;case"ArrowDown":t.stopPropagation(),t.preventDefault(),null===(i=this.firstSuggestion)||void 0===i||i.focus()}}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}onSuggestClick(t,e){t.ctrlKey||t.metaKey||this.onSuggestSelected(t,e)}onSuggestKeyUp(t,e){"Enter"!==t.key&&" "!==t.key||this.onSuggestSelected(t,e)}onSuggestSelected(t,e){t.preventDefault(),this.setQuery(e),this.launchSearch()}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 So(this.request)),this.mobileMenuOpen=!1,this.displayFacets=!1,this.focus()}saveRecentSearches(){window.localStorage.setItem(this.recentSearchesStorageKey,JSON.stringify(this.recentSearches))}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}getLocaleLabel(t){var e;return null!==(e=this.availableContentLocales.filter((e=>{var i;return(null!==(i=e.lang)&&void 0!==i?i:"").toLowerCase()===(null!=t?t:"").toLowerCase()})).map((t=>t.label)).pop())&&void 0!==e?e:t}setFilter(t,e){let i=this.searchFilters.filter((e=>e.key!==t));this.facets.forEach((i=>{i.key===t&&Ge(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=>Ge(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}removeRecentSearch(t,e){var i,r,o,n;t.preventDefault(),t.stopPropagation();const a=null!==(n=null!==(r=null===(i=this.focusedSuggestion)||void 0===i?void 0:i.previousElementSibling)&&void 0!==r?r:null===(o=this.focusedSuggestion)||void 0===o?void 0:o.nextElementSibling)&&void 0!==n?n:this.input;null==a||a.focus(),this.recentSearches=this.recentSearches.filter((t=>t.toLowerCase()!==e.toLowerCase())),this.saveRecentSearches()}onSuggestKeyDown(t){var e,i,r,o,n,a;switch(t.key){case"ArrowUp":null===(r=null!==(i=null===(e=this.focusedSuggestion)||void 0===e?void 0:e.previousElementSibling)&&void 0!==i?i:this.lastSuggestion)||void 0===r||r.focus(),t.preventDefault(),t.stopPropagation();break;case"ArrowDown":null===(a=null!==(n=null===(o=this.focusedSuggestion)||void 0===o?void 0:o.nextElementSibling)&&void 0!==n?n:this.firstSuggestion)||void 0===a||a.focus(),t.preventDefault(),t.stopPropagation()}}},t.FtSearchBar.elementDefinitions={"ft-accordion":to,"ft-accordion-item":Yr,"ft-button":Yi,"ft-chip":lo,"ft-filter":Tr,"ft-filter-option":$r,"ft-icon":Kr,"ft-ripple":Fi,"ft-select":vo,"ft-select-option":mo,"ft-size-watcher":Ht,"ft-snap-scroll":kr,"ft-tooltip":Ui,"ft-typography":qe,"mwc-icon":Ni},$o([nt({type:Boolean})],t.FtSearchBar.prototype,"dense",void 0),$o([nt({type:String})],t.FtSearchBar.prototype,"baseUrl",void 0),$o([nt({type:String})],t.FtSearchBar.prototype,"apiIntegrationIdentifier",void 0),$o([nt({type:String})],t.FtSearchBar.prototype,"contentLocale",void 0),$o([at()],t.FtSearchBar.prototype,"availableContentLocales",void 0),$o([nt({type:String})],t.FtSearchBar.prototype,"uiLocale",void 0),$o([Et({})],t.FtSearchBar.prototype,"labels",void 0),$o([Et([])],t.FtSearchBar.prototype,"displayedFilters",void 0),$o([Et([])],t.FtSearchBar.prototype,"presets",void 0),$o([nt({type:String,reflect:!0})],t.FtSearchBar.prototype,"selectedPreset",void 0),$o([nt()],t.FtSearchBar.prototype,"searchRequestSerializer",void 0),$o([at()],t.FtSearchBar.prototype,"searchFilters",void 0),$o([at()],t.FtSearchBar.prototype,"sizeCategory",void 0),$o([at()],t.FtSearchBar.prototype,"displayFacets",void 0),$o([at()],t.FtSearchBar.prototype,"mobileMenuOpen",void 0),$o([at()],t.FtSearchBar.prototype,"facets",void 0),$o([lt(".ft-search-bar--container")],t.FtSearchBar.prototype,"container",void 0),$o([lt(".ft-search-bar--filters-opener")],t.FtSearchBar.prototype,"filtersOpener",void 0),$o([lt(".ft-search-bar--floating-panel")],t.FtSearchBar.prototype,"floatingContainer",void 0),$o([lt("ft-snap-scroll.ft-search-bar--filters-container")],t.FtSearchBar.prototype,"scrollingFiltersContainer",void 0),$o([lt(".ft-search-bar--input")],t.FtSearchBar.prototype,"input",void 0),$o([at()],t.FtSearchBar.prototype,"query",void 0),$o([at()],t.FtSearchBar.prototype,"suggestions",void 0),$o([at()],t.FtSearchBar.prototype,"suggestionsLoaded",void 0),$o([at()],t.FtSearchBar.prototype,"recentSearches",void 0),$o([at()],t.FtSearchBar.prototype,"scrollToFacet",void 0),$o([lt(".ft-search-bar--suggestion:first-child")],t.FtSearchBar.prototype,"firstSuggestion",void 0),$o([lt(".ft-search-bar--suggestion:focus-within")],t.FtSearchBar.prototype,"focusedSuggestion",void 0),$o([lt(".ft-search-bar--suggestion:last-child")],t.FtSearchBar.prototype,"lastSuggestion",void 0),$o([at()],t.FtSearchBar.prototype,"api",void 0),t.FtSearchBar=$o([Ct("ft-search-bar")],t.FtSearchBar),t.DEFAULT_LABELS=_o,t.FtSearchBarCssVariables=go,t.LaunchSearchEvent=So,t.SearchStateChangeEvent=Oo,Object.defineProperty(t,"t",{value:!0})}({});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-search-bar",
3
- "version": "0.1.13",
3
+ "version": "0.1.16",
4
4
  "description": "Search bar component using Fluid Topics public API",
5
5
  "keywords": [
6
6
  "Lit"
@@ -19,25 +19,25 @@
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.1.13",
23
- "@fluid-topics/ft-button": "^0.1.13",
24
- "@fluid-topics/ft-chip": "^0.1.13",
25
- "@fluid-topics/ft-filter": "^0.1.13",
26
- "@fluid-topics/ft-icon": "^0.1.13",
27
- "@fluid-topics/ft-select": "^0.1.13",
28
- "@fluid-topics/ft-size-watcher": "^0.1.13",
29
- "@fluid-topics/ft-snap-scroll": "^0.1.13",
30
- "@fluid-topics/ft-tooltip": "^0.1.13",
31
- "@fluid-topics/ft-typography": "^0.1.13",
32
- "@fluid-topics/ft-wc-utils": "^0.1.13",
22
+ "@fluid-topics/ft-accordion": "^0.1.16",
23
+ "@fluid-topics/ft-button": "^0.1.16",
24
+ "@fluid-topics/ft-chip": "^0.1.16",
25
+ "@fluid-topics/ft-filter": "^0.1.16",
26
+ "@fluid-topics/ft-icon": "^0.1.16",
27
+ "@fluid-topics/ft-select": "^0.1.16",
28
+ "@fluid-topics/ft-size-watcher": "^0.1.16",
29
+ "@fluid-topics/ft-snap-scroll": "^0.1.16",
30
+ "@fluid-topics/ft-tooltip": "^0.1.16",
31
+ "@fluid-topics/ft-typography": "^0.1.16",
32
+ "@fluid-topics/ft-wc-utils": "^0.1.16",
33
33
  "@material/mwc-icon": "^0.25.3",
34
34
  "lit": "2.1.3"
35
35
  },
36
36
  "devDependencies": {
37
- "@fluid-topics/public-api": "^1.0.14"
37
+ "@fluid-topics/public-api": "1.0.15"
38
38
  },
39
39
  "peerDependencies": {
40
- "@fluid-topics/public-api": "^1.0.14"
40
+ "@fluid-topics/public-api": "1.0.15"
41
41
  },
42
- "gitHead": "1d71ea532a92f97baca8f16cbc975e8fe79b471a"
42
+ "gitHead": "cd0a3cb28ec86c2c93fcaecf99cdd1c51e83c8c9"
43
43
  }