@fluid-topics/ft-search-input 1.0.7 → 1.0.9
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.
|
@@ -8,7 +8,7 @@ export declare class FtSearchInput extends FtSearchInput_base implements FtSearc
|
|
|
8
8
|
constructor();
|
|
9
9
|
private request?;
|
|
10
10
|
private liveQuery;
|
|
11
|
-
private suggestResults
|
|
11
|
+
private suggestResults?;
|
|
12
12
|
private forceCloseSuggestion;
|
|
13
13
|
private input;
|
|
14
14
|
private suggestion;
|
package/build/ft-search-input.js
CHANGED
|
@@ -19,14 +19,14 @@ class FtSearchInput extends withI18n(FtSearchComponent) {
|
|
|
19
19
|
constructor() {
|
|
20
20
|
super();
|
|
21
21
|
this.liveQuery = "";
|
|
22
|
-
this.suggestResults = [];
|
|
23
22
|
this.forceCloseSuggestion = false;
|
|
24
23
|
this.addI18nContext(searchInputContext);
|
|
25
24
|
}
|
|
26
25
|
render() {
|
|
26
|
+
var _a, _b;
|
|
27
27
|
let classes = {
|
|
28
28
|
"ft-search-input": true,
|
|
29
|
-
"ft-search-input--with-suggestions": this.suggestResults.length > 0,
|
|
29
|
+
"ft-search-input--with-suggestions": (_b = (_a = this.suggestResults) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0 > 0,
|
|
30
30
|
"ft-search-input--with-suggestions-closed": this.forceCloseSuggestion,
|
|
31
31
|
};
|
|
32
32
|
return html `
|
|
@@ -693,8 +693,8 @@ const it=Symbol.for(""),et=t=>{if((null==t?void 0:t.r)===it)return null==t?void
|
|
|
693
693
|
</div>
|
|
694
694
|
`}onSuggestKeyDown(t){var i,e,o,s,n,r;switch(t.key){case"ArrowUp":null===(o=null!==(e=null===(i=this.getFocusedSuggestionElement())||void 0===i?void 0:i.previousElementSibling)&&void 0!==e?e:this.getLastSuggestionElement())||void 0===o||o.focus(),t.preventDefault(),t.stopPropagation();break;case"ArrowDown":null===(r=null!==(n=null===(s=this.getFocusedSuggestionElement())||void 0===s?void 0:s.nextElementSibling)&&void 0!==n?n:this.getFirstSuggestionElement())||void 0===r||r.focus(),t.preventDefault(),t.stopPropagation()}}onSuggestKeyUp(t,i){"Enter"!==t.key&&" "!==t.key||this.onSuggestSelected(t,i)}onSuggestSelected(t,i){t.preventDefault(),this.dispatchEvent(new ze(i))}getIcon(t){const i="DOCUMENT"===t.type?Fi.file_format:Fi.fluid_topics;let o;switch(t.type){case"MAP":o="BOOK"===t.editorialType?Ui.BOOK:Ui.ARTICLE;break;case"DOCUMENT":o=function(t,i){var e,o,s,n;t=(null!=t?t:"").toLowerCase(),i=(null!=i?i:"").toLowerCase();const[r,a]=((null!==(e=Ai.get(t))&&void 0!==e?e:t)+"/").split("/");return null!==(n=null!==(s=null!==(o=Mi.get(a))&&void 0!==o?o:Mi.get(i))&&void 0!==s?s:Mi.get(r))&&void 0!==n?n:Ni.UNKNOWN}(t.mimeType,t.filenameExtension);break;case"TOPIC":o=Ui.TOPICS}return e.html`
|
|
695
695
|
<ft-icon .variant="${i}" .value="${o}" part="suggestion-icon"></ft-icon>
|
|
696
|
-
`}getFocusedSuggestionElement(){return this.shadowRoot.querySelector(".ft-search-input-suggestion--suggestion:focus-within")}getLastSuggestionElement(){let t=this.shadowRoot.querySelectorAll(".ft-search-input-suggestion--suggestion");return t.length>0?t[t.length-1]:null}getFirstSuggestionElement(){return this.shadowRoot.querySelector(".ft-search-input-suggestion--suggestion")}focusFirstSuggestion(){var t;null===(t=this.getFirstSuggestionElement())||void 0===t||t.focus()}};Oe.elementDefinitions={"ft-ripple":b,"ft-typography":ki,"ft-icon":Ri},Oe.styles=[i.wordWrap,Se],Ce([i.redux()],Oe.prototype,"suggestResults",void 0),Oe=Ce([o.customElement("ft-search-input-suggestion")],Oe);var Ee=function(t,i,e,o){for(var s,n=arguments.length,r=n<3?i:null===o?o=Object.getOwnPropertyDescriptor(i,e):o,a=t.length-1;a>=0;a--)(s=t[a])&&(r=(n<3?s(r):n>3?s(i,e,r):s(i,e))||r);return n>3&&r&&Object.defineProperty(i,e,r),r};class Ie extends(ve(fe)){constructor(){super(),this.liveQuery="",this.
|
|
697
|
-
<div class="${s.classMap(
|
|
696
|
+
`}getFocusedSuggestionElement(){return this.shadowRoot.querySelector(".ft-search-input-suggestion--suggestion:focus-within")}getLastSuggestionElement(){let t=this.shadowRoot.querySelectorAll(".ft-search-input-suggestion--suggestion");return t.length>0?t[t.length-1]:null}getFirstSuggestionElement(){return this.shadowRoot.querySelector(".ft-search-input-suggestion--suggestion")}focusFirstSuggestion(){var t;null===(t=this.getFirstSuggestionElement())||void 0===t||t.focus()}};Oe.elementDefinitions={"ft-ripple":b,"ft-typography":ki,"ft-icon":Ri},Oe.styles=[i.wordWrap,Se],Ce([i.redux()],Oe.prototype,"suggestResults",void 0),Oe=Ce([o.customElement("ft-search-input-suggestion")],Oe);var Ee=function(t,i,e,o){for(var s,n=arguments.length,r=n<3?i:null===o?o=Object.getOwnPropertyDescriptor(i,e):o,a=t.length-1;a>=0;a--)(s=t[a])&&(r=(n<3?s(r):n>3?s(i,e,r):s(i,e))||r);return n>3&&r&&Object.defineProperty(i,e,r),r};class Ie extends(ve(fe)){constructor(){super(),this.liveQuery="",this.forceCloseSuggestion=!1,this.addI18nContext(ke)}render(){var t,i;let o={"ft-search-input":!0,"ft-search-input--with-suggestions":null!==(i=null===(t=this.suggestResults)||void 0===t?void 0:t.length)&&void 0!==i&&i,"ft-search-input--with-suggestions-closed":this.forceCloseSuggestion};return e.html`
|
|
697
|
+
<div class="${s.classMap(o)}" @focusout=${()=>this.forceCloseSuggestion=!1}>
|
|
698
698
|
<div class="ft-search-input--input-container" part="input-container" tabindex="-1">
|
|
699
699
|
<div class="ft-search-input--input-outline" part="input-outline">
|
|
700
700
|
<input class="ft-search-input--input ft-typography--body2"
|