@fluid-topics/ft-search-bar 1.2.19 → 1.2.21

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.
@@ -2887,7 +2887,6 @@ Also for action icons.`,s.colorGray200),contentGlobalSubtle:o.extend("--ft-conte
2887
2887
  <a href="${this.getRequestWithQuery(n)}"
2888
2888
  part="suggestions"
2889
2889
  class="ft-search-bar--suggestion ft-search-bar--recent-search"
2890
- @keyup=${i=>this.onSuggestKeyUp(i)}
2891
2890
  @click=${i=>this.onSuggestClick(i,n)}>
2892
2891
  <ft-ripple></ft-ripple>
2893
2892
  <ft-icon variant="material" value="history" part="suggestion-icon"></ft-icon>
@@ -2908,7 +2907,6 @@ Also for action icons.`,s.colorGray200),contentGlobalSubtle:o.extend("--ft-conte
2908
2907
  <a href="${this.getRequestWithQuery(n.value)}"
2909
2908
  part="suggestions"
2910
2909
  class="ft-search-bar--suggestion"
2911
- @keyup=${i=>this.onSuggestKeyUp(i)}
2912
2910
  @click=${i=>this.onSuggestClick(i,n.value)}>
2913
2911
  <ft-ripple></ft-ripple>
2914
2912
  ${this.getIcon(n)}
@@ -2917,7 +2915,7 @@ Also for action icons.`,s.colorGray200),contentGlobalSubtle:o.extend("--ft-conte
2917
2915
  </div>
2918
2916
  `)}
2919
2917
  </div>
2920
- `}getRequestWithQuery(e){return this.searchBar.searchRequestSerializer({...this.searchBar.request,paging:{page:1},query:e})}update(){return new Promise((e,r)=>{this.updateDebouncer.run(async()=>{this.searchBar.suggestions=this.searchBar.api&&this.searchBar.query.length>2?await this.searchBar.api.getSuggestions(this.searchBar.suggestRequest).then(n=>n.suggestions).catch(()=>[]):[],e()})})}onSuggestKeyDown(e){var r,n;switch(e.key){case"ArrowUp":(r=this.previousSuggestionElement())===null||r===void 0||r.focus(),e.preventDefault(),e.stopPropagation();break;case"ArrowDown":(n=this.nextSuggestionElement())===null||n===void 0||n.focus(),e.preventDefault(),e.stopPropagation();break}}nextSuggestionElement(){var e,r;let n=(e=this.getFocusedSuggestionElement())===null||e===void 0?void 0:e.parentElement,i=(r=n?.nextElementSibling)===null||r===void 0?void 0:r.querySelector("[part=suggestions]");return i??this.getFirstSuggestionElement()}previousSuggestionElement(){var e,r;let n=(e=this.getFocusedSuggestionElement())===null||e===void 0?void 0:e.parentElement,i=(r=n?.previousElementSibling)===null||r===void 0?void 0:r.querySelector("[part=suggestions]");return i??this.getLastSuggestionElement()}onSuggestKeyUp(e){(e.key==="Enter"||e.key===" ")&&e.target.click()}onSuggestClick(e,r){this.searchBar.setQuery(r),this.searchBar.onLaunchSearch()}removeRecentSearch(e,r){var n,i,a,l;e.preventDefault(),e.stopPropagation();let c=e.target.closest("[part='suggestion-container']"),p=(l=(i=(n=c?.previousElementSibling)===null||n===void 0?void 0:n.querySelector("[part='suggestions']"))!==null&&i!==void 0?i:(a=c?.nextElementSibling)===null||a===void 0?void 0:a.querySelector("[part='suggestions']"))!==null&&l!==void 0?l:this.searchBar.input;p?.focus(),this.searchBar.recentSearches=this.searchBar.recentSearches.filter(f=>f.toLowerCase()!==r.toLowerCase()),this.searchBar.saveRecentSearches()}getIcon(e){let r=e.type==="DOCUMENT"?Pe.file_format:Pe.fluid_topics,n;switch(e.type){case"MAP":n=e.editorialType==="BOOK"?wt.BOOK:wt.ARTICLE;break;case"DOCUMENT":n=ds(e.mimeType,e.filenameExtension);break;case"TOPIC":n=wt.TOPICS;break}return Ao.html`
2918
+ `}getRequestWithQuery(e){return this.searchBar.searchRequestSerializer({...this.searchBar.request,paging:{page:1},query:e})}update(){return new Promise((e,r)=>{this.updateDebouncer.run(async()=>{this.searchBar.suggestions=this.searchBar.api&&this.searchBar.query.length>2?await this.searchBar.api.getSuggestions(this.searchBar.suggestRequest).then(n=>n.suggestions).catch(()=>[]):[],e()})})}onSuggestKeyDown(e){var r,n;switch(e.key){case"ArrowUp":(r=this.previousSuggestionElement())===null||r===void 0||r.focus(),e.preventDefault(),e.stopPropagation();break;case"ArrowDown":(n=this.nextSuggestionElement())===null||n===void 0||n.focus(),e.preventDefault(),e.stopPropagation();break}}nextSuggestionElement(){var e,r;let n=(e=this.getFocusedSuggestionElement())===null||e===void 0?void 0:e.parentElement,i=(r=n?.nextElementSibling)===null||r===void 0?void 0:r.querySelector("[part=suggestions]");return i??this.getFirstSuggestionElement()}previousSuggestionElement(){var e,r;let n=(e=this.getFocusedSuggestionElement())===null||e===void 0?void 0:e.parentElement,i=(r=n?.previousElementSibling)===null||r===void 0?void 0:r.querySelector("[part=suggestions]");return i??this.getLastSuggestionElement()}onSuggestClick(e,r){this.searchBar.setQuery(r),this.searchBar.onLaunchSearch()}removeRecentSearch(e,r){var n,i,a,l;e.preventDefault(),e.stopPropagation();let c=e.target.closest("[part='suggestion-container']"),p=(l=(i=(n=c?.previousElementSibling)===null||n===void 0?void 0:n.querySelector("[part='suggestions']"))!==null&&i!==void 0?i:(a=c?.nextElementSibling)===null||a===void 0?void 0:a.querySelector("[part='suggestions']"))!==null&&l!==void 0?l:this.searchBar.input;p?.focus(),this.searchBar.recentSearches=this.searchBar.recentSearches.filter(f=>f.toLowerCase()!==r.toLowerCase()),this.searchBar.saveRecentSearches()}getIcon(e){let r=e.type==="DOCUMENT"?Pe.file_format:Pe.fluid_topics,n;switch(e.type){case"MAP":n=e.editorialType==="BOOK"?wt.BOOK:wt.ARTICLE;break;case"DOCUMENT":n=ds(e.mimeType,e.filenameExtension);break;case"TOPIC":n=wt.TOPICS;break}return Ao.html`
2921
2919
  <ft-icon .variant="${r}" .value="${n}" part="suggestion-icon"></ft-icon>
2922
2920
  `}getFocusedSuggestionElement(){return this.searchBar.querySelector(".ft-search-bar--suggestion:focus-within")}getLastSuggestionElement(){let e=this.searchBar.querySelectorAll(".ft-search-bar--suggestion");return e.length>0?e[e.length-1]:null}getFirstSuggestionElement(){return this.searchBar.querySelector(".ft-search-bar--suggestion")}focusFirstSuggestion(){var e;(e=this.getFirstSuggestionElement())===null||e===void 0||e.focus()}};kt.styles=[pn.wordWrap,Ao.css`
2923
2921
  .ft-search-bar--mobile .ft-search-bar--suggestions {