@bridgeline-digital/hawksearch-handlebars-ui 6.3.1 → 6.3.2

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.
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * name: @bridgeline-digital/hawksearch-handlebars-ui
3
3
  *
4
- * version: v6.3.1
4
+ * version: v6.3.2
5
5
  *
6
6
  * description: The HawkSearch Handlebars UI package allows you to add a highly-customizable search results page to your website powered by HawkSearch.
7
7
  *
@@ -8733,6 +8733,10 @@ class SearchFieldComponent extends BaseComponent {
8733
8733
  var _a;
8734
8734
  return ((_a = HawkSearch.config.autocomplete) == null ? void 0 : _a.recommendationsEnabled) ?? false;
8735
8735
  }
8736
+ get searchDebounceValue() {
8737
+ var _a;
8738
+ return ((_a = this.configuration) == null ? void 0 : _a.searchDebounceValue) ?? 250;
8739
+ }
8736
8740
  get disableAutofill() {
8737
8741
  var _a, _b;
8738
8742
  return ((_b = (_a = HawkSearch.config.components) == null ? void 0 : _a["search-field"]) == null ? void 0 : _b.disableAutofill) ?? false;
@@ -8815,7 +8819,7 @@ class SearchFieldComponent extends BaseComponent {
8815
8819
  if (Array.isArray(this.placeholder)) {
8816
8820
  this.animatePlaceholder();
8817
8821
  }
8818
- e.addEventListener("keyup", debounce(onKeyUp, 250));
8822
+ e.addEventListener("keyup", debounce(onKeyUp, this.searchDebounceValue));
8819
8823
  });
8820
8824
  this.rootElement.querySelectorAll("hawksearch-autocomplete").forEach((e) => {
8821
8825
  e.addEventListener("hawksearch:close-autocomplete", (event) => {
@@ -9977,7 +9981,7 @@ class VisualSearchFieldComponent extends BaseComponent {
9977
9981
  this.bindFromEvent = true;
9978
9982
  this.previousValue = "";
9979
9983
  this.maxSize = 4 * 1024 * 1024;
9980
- this.allowedExtensions = ["jpg", "jpeg", "png", "webp"];
9984
+ this.allowedExtensions = ["jpg", "jpeg", "png", "webp", "avif"];
9981
9985
  }
9982
9986
  handleFiles(files) {
9983
9987
  var _a;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * name: @bridgeline-digital/hawksearch-handlebars-ui
3
3
  *
4
- * version: v6.3.1
4
+ * version: v6.3.2
5
5
  *
6
6
  * description: The HawkSearch Handlebars UI package allows you to add a highly-customizable search results page to your website powered by HawkSearch.
7
7
  *
@@ -722,7 +722,7 @@ Expecting `+C.join(", ")+", got '"+(this.terminals_[b]||b)+"'":T="Parse error on
722
722
  </div>`;class oc extends U{constructor(){super(...arguments),this.componentName="query-suggestions",this.defaultHtml=sc,this.bindFromEvent=!0}registerHelpers(){var e,t,r,a;super.registerHelpers();const i=((t=(e=this.configuration)==null?void 0:e.strings)==null?void 0:t.orDelimeter)??"or",s=((a=(r=this.configuration)==null?void 0:r.strings)==null?void 0:a.prompt)??"Did you mean to search for ${suggestions}?";this.handlebars.registerHelper("query-suggestions",function(d){function u(_){return`<a hawksearch-query="${encodeURIComponent(_)}" class="query-suggestions__link">${_}</a>`}const g=", ",y=`, ${i} `;let h="";d.length<=2?h=d.map(u).join(` ${i} `):h=d.slice(0,d.length-1).map(u).join(g)+y+u(d[d.length-1]);const v=s.replace("${suggestions}",h);return new HawkSearch.handlebars.SafeString(v)})}renderContent(){var e;return!!this.data&&!!this.data.display&&!!((e=this.data.querySuggestions)!=null&&e.length)}getContentModel(){return{querySuggestions:this.data.querySuggestions??[]}}onRender(){super.onRender(),this.rootElement.querySelectorAll("[hawksearch-query]").forEach(e=>{e.addEventListener("click",t=>{t.preventDefault();const a=t.currentTarget.getAttribute("hawksearch-query");a&&HawkSearch.services.search.query(a)})})}}const lc=`<div class="search-field">
723
723
  <input type="text" hawksearch-input value="{{query}}" placeholder="{{strings.placeholder}}" />
724
724
  <hawksearch-autocomplete></hawksearch-autocomplete>
725
- </div>`;class cc extends U{constructor(){super(...arguments),this.componentName="search-field",this.defaultHtml=lc,this.bindFromEvent=!0,this.previousValue="",this.placeholderIdx=0,this.intervalId=setTimeout(()=>{}),this.charIdx=0}get autocompleteMinCharacterCount(){var e;return((e=HawkSearch.config.autocomplete)==null?void 0:e.minCharacterCount)??1}get recommendationsEnabled(){var e;return((e=HawkSearch.config.autocomplete)==null?void 0:e.recommendationsEnabled)??!1}get disableAutofill(){var e,t;return((t=(e=HawkSearch.config.components)==null?void 0:e["search-field"])==null?void 0:t.disableAutofill)??!1}get placeholder(){var e,t;return((t=(e=this.configuration)==null?void 0:e.strings)==null?void 0:t.placeholder)??"Enter keywords"}connectedCallback(){super.connectedCallback(),this.clickEventHandler=e=>{!!e.target.closest("hawksearch-search-field")||this.toggleAutocomplete(!1)},this.rootElement.ownerDocument.addEventListener("click",this.clickEventHandler)}disconnectedCallback(){super.disconnectedCallback(),this.rootElement.ownerDocument.removeEventListener("click",this.connectedCallback)}getContentModel(){var e;return{query:(e=this.data)==null?void 0:e.query,strings:{placeholder:this.placeholder}}}onRender(){super.onRender();const e=["Enter","NumpadEnter"];Array.isArray(this.placeholder)&&this.placeholder.length>1&&clearInterval(this.intervalId),this.rootElement.querySelectorAll("[hawksearch-input]").forEach(t=>{if(this.disableAutofill){const a=t;a.value=""}t.addEventListener("focus",a=>{const s=t.value.trim();s&&this.previousAutocompleteResponse?HawkSearch.services.autocomplete.bindComponent(this.previousAutocompleteResponse):s||this.displayDefaultAutocomplete()}),t.addEventListener("keyup",a=>{if(!e.includes(a.code))return;const s=a.currentTarget.value.trim();s||(clearInterval(this.intervalId),this.animatePlaceholder()),this.toggleAutocomplete(!1),HawkSearch.services.search.query(s)});const r=async a=>{const s=t.value.trim();e.includes(a.code)||s===this.previousValue||(this.previousValue=s,this.toggleAutocomplete(!!s),s&&s.length>this.autocompleteMinCharacterCount?this.previousAutocompleteResponse=await HawkSearch.services.autocomplete.query(s):this.displayDefaultAutocomplete())};Array.isArray(this.placeholder)&&this.animatePlaceholder(),t.addEventListener("keyup",oe(r,250))}),this.rootElement.querySelectorAll("hawksearch-autocomplete").forEach(t=>{t.addEventListener("hawksearch:close-autocomplete",r=>{this.toggleAutocomplete(!1)})})}toggleAutocomplete(e){this.rootElement.querySelectorAll("hawksearch-autocomplete").forEach(t=>{const r=t;r.style.display=e?"block":"none"})}async displayDefaultAutocomplete(){if(!(!this.recommendationsEnabled||this.defaultAutocompleteResponse===!1)){if(this.defaultAutocompleteResponse===void 0){const e=await HawkSearch.services.autocomplete.query();this.defaultAutocompleteResponse=e||!1}this.defaultAutocompleteResponse&&HawkSearch.services.autocomplete.bindComponent(this.defaultAutocompleteResponse)}}animatePlaceholder(){this.intervalId=setInterval(this.onTick.bind(this),50)}setPlaceholder(){const t=this.placeholder[this.placeholderIdx].substring(0,this.charIdx+1);this.rootElement.querySelectorAll("[hawksearch-input]").forEach(r=>{r.setAttribute("placeholder",t)})}onTick(){const e=this.placeholder[this.placeholderIdx];this.charIdx===e.length&&setTimeout(this.goReverse.bind(this),1e3),this.setPlaceholder(),this.charIdx++}goReverse(){clearInterval(this.intervalId),this.intervalId=setInterval(this.onTickReverse.bind(this,()=>{this.charIdx=0,this.placeholderIdx++,this.placeholderIdx===this.placeholder.length&&(this.placeholderIdx=0)}),100)}onTickReverse(e){this.charIdx===0?(e.bind(this)(),clearInterval(this.intervalId),this.animatePlaceholder()):(this.setPlaceholder(),this.charIdx--)}}const dc=`<div class="search-field">
725
+ </div>`;class cc extends U{constructor(){super(...arguments),this.componentName="search-field",this.defaultHtml=lc,this.bindFromEvent=!0,this.previousValue="",this.placeholderIdx=0,this.intervalId=setTimeout(()=>{}),this.charIdx=0}get autocompleteMinCharacterCount(){var e;return((e=HawkSearch.config.autocomplete)==null?void 0:e.minCharacterCount)??1}get recommendationsEnabled(){var e;return((e=HawkSearch.config.autocomplete)==null?void 0:e.recommendationsEnabled)??!1}get searchDebounceValue(){var e;return((e=this.configuration)==null?void 0:e.searchDebounceValue)??250}get disableAutofill(){var e,t;return((t=(e=HawkSearch.config.components)==null?void 0:e["search-field"])==null?void 0:t.disableAutofill)??!1}get placeholder(){var e,t;return((t=(e=this.configuration)==null?void 0:e.strings)==null?void 0:t.placeholder)??"Enter keywords"}connectedCallback(){super.connectedCallback(),this.clickEventHandler=e=>{!!e.target.closest("hawksearch-search-field")||this.toggleAutocomplete(!1)},this.rootElement.ownerDocument.addEventListener("click",this.clickEventHandler)}disconnectedCallback(){super.disconnectedCallback(),this.rootElement.ownerDocument.removeEventListener("click",this.connectedCallback)}getContentModel(){var e;return{query:(e=this.data)==null?void 0:e.query,strings:{placeholder:this.placeholder}}}onRender(){super.onRender();const e=["Enter","NumpadEnter"];Array.isArray(this.placeholder)&&this.placeholder.length>1&&clearInterval(this.intervalId),this.rootElement.querySelectorAll("[hawksearch-input]").forEach(t=>{if(this.disableAutofill){const a=t;a.value=""}t.addEventListener("focus",a=>{const s=t.value.trim();s&&this.previousAutocompleteResponse?HawkSearch.services.autocomplete.bindComponent(this.previousAutocompleteResponse):s||this.displayDefaultAutocomplete()}),t.addEventListener("keyup",a=>{if(!e.includes(a.code))return;const s=a.currentTarget.value.trim();s||(clearInterval(this.intervalId),this.animatePlaceholder()),this.toggleAutocomplete(!1),HawkSearch.services.search.query(s)});const r=async a=>{const s=t.value.trim();e.includes(a.code)||s===this.previousValue||(this.previousValue=s,this.toggleAutocomplete(!!s),s&&s.length>this.autocompleteMinCharacterCount?this.previousAutocompleteResponse=await HawkSearch.services.autocomplete.query(s):this.displayDefaultAutocomplete())};Array.isArray(this.placeholder)&&this.animatePlaceholder(),t.addEventListener("keyup",oe(r,this.searchDebounceValue))}),this.rootElement.querySelectorAll("hawksearch-autocomplete").forEach(t=>{t.addEventListener("hawksearch:close-autocomplete",r=>{this.toggleAutocomplete(!1)})})}toggleAutocomplete(e){this.rootElement.querySelectorAll("hawksearch-autocomplete").forEach(t=>{const r=t;r.style.display=e?"block":"none"})}async displayDefaultAutocomplete(){if(!(!this.recommendationsEnabled||this.defaultAutocompleteResponse===!1)){if(this.defaultAutocompleteResponse===void 0){const e=await HawkSearch.services.autocomplete.query();this.defaultAutocompleteResponse=e||!1}this.defaultAutocompleteResponse&&HawkSearch.services.autocomplete.bindComponent(this.defaultAutocompleteResponse)}}animatePlaceholder(){this.intervalId=setInterval(this.onTick.bind(this),50)}setPlaceholder(){const t=this.placeholder[this.placeholderIdx].substring(0,this.charIdx+1);this.rootElement.querySelectorAll("[hawksearch-input]").forEach(r=>{r.setAttribute("placeholder",t)})}onTick(){const e=this.placeholder[this.placeholderIdx];this.charIdx===e.length&&setTimeout(this.goReverse.bind(this),1e3),this.setPlaceholder(),this.charIdx++}goReverse(){clearInterval(this.intervalId),this.intervalId=setInterval(this.onTickReverse.bind(this,()=>{this.charIdx=0,this.placeholderIdx++,this.placeholderIdx===this.placeholder.length&&(this.placeholderIdx=0)}),100)}onTickReverse(e){this.charIdx===0?(e.bind(this)(),clearInterval(this.intervalId),this.animatePlaceholder()):(this.setPlaceholder(),this.charIdx--)}}const dc=`<div class="search-field">
726
726
  <input type="text" hawksearch-input hawksearch-concept-search value="{{query}}" placeholder="{{strings.placeholder}}" />
727
727
  </div>`;class uc extends U{constructor(){super(...arguments),this.componentName="conceptsearch-field",this.defaultHtml=dc,this.bindFromEvent=!0,this.previousValue="",this.placeholderIdx=0,this.intervalId=setTimeout(()=>{}),this.charIdx=0}get searchOnKeyPress(){var e;return((e=this.configuration)==null?void 0:e.searchOnKeyPress)??!1}get searchMinCharacterCount(){var e;return((e=this.configuration)==null?void 0:e.searchMinCharacterCount)??10}get searchDebounceValue(){var e;return((e=this.configuration)==null?void 0:e.searchDebounceValue)??350}get placeholder(){var e,t;return((t=(e=this.configuration)==null?void 0:e.strings)==null?void 0:t.placeholder)??"Enter Keyword"}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback(),this.rootElement.ownerDocument.removeEventListener("click",this.connectedCallback)}getContentModel(){var e;return{query:(e=this.data)==null?void 0:e.query,strings:{placeholder:this.placeholder}}}onRender(){super.onRender();const e=["Enter","NumpadEnter"];Array.isArray(this.placeholder)&&this.placeholder.length>1&&clearInterval(this.intervalId),this.rootElement.querySelectorAll("[hawksearch-input]").forEach(t=>{t.addEventListener("keyup",a=>{if(!e.includes(a.code))return;const s=a.currentTarget.value.trim();s||(clearInterval(this.intervalId),this.animatePlaceholder()),this.handleSearchRequest(s)});const r=a=>{const s=t.value.trim();!this.searchOnKeyPress||s===this.previousValue||s&&s.length>this.searchMinCharacterCount&&this.handleSearchRequest(s)};Array.isArray(this.placeholder)&&this.animatePlaceholder(),t.addEventListener("keyup",oe(r,this.searchDebounceValue))})}handleSearchRequest(e){this.previousValue=e,HawkSearch.services.search.query({queryString:e,requestType:"ConceptSearch"})}animatePlaceholder(){this.intervalId=setInterval(this.onTick.bind(this),50)}setPlaceholder(){const t=this.placeholder[this.placeholderIdx].substring(0,this.charIdx+1);this.rootElement.querySelectorAll("[hawksearch-input]").forEach(r=>{r.setAttribute("placeholder",t)})}onTick(){const e=this.placeholder[this.placeholderIdx];this.charIdx===e.length&&setTimeout(this.goReverse.bind(this),1e3),this.setPlaceholder(),this.charIdx++}goReverse(){clearInterval(this.intervalId),this.intervalId=setInterval(this.onTickReverse.bind(this,()=>{this.charIdx=0,this.placeholderIdx++,this.placeholderIdx===this.placeholder.length&&(this.placeholderIdx=0)}),100)}onTickReverse(e){this.charIdx===0?(e.bind(this)(),clearInterval(this.intervalId),this.animatePlaceholder()):(this.setPlaceholder(),this.charIdx--)}}const hc=`<div class="conversationalsearch">
728
728
  <div class="conversationalsearch__body">
@@ -961,7 +961,7 @@ Expecting `+C.join(", ")+", got '"+(this.terminals_[b]||b)+"'":T="Parse error on
961
961
  </p>
962
962
  <p class="visualsearch-field__drop-area__drop-msg">{{strings.dropImageMessage}}</p>
963
963
  </div>
964
- </div>`;class Dc extends U{constructor(){super(...arguments),this.componentName="visualsearch-field",this.defaultHtml=Tc,this.bindFromEvent=!0,this.previousValue="",this.maxSize=4*1024*1024,this.allowedExtensions=["jpg","jpeg","png","webp"]}handleFiles(e){var t;const r=e[0],a=(t=r.name.split(".").pop())==null?void 0:t.toLowerCase();if(!this.isValidFile(r,a))return;const i=new FileReader;i.onload=s=>{var d;const u=new Image;u.src=i.result,this.rootElement.querySelectorAll("[hawksearch-visualsearch-display]").forEach(y=>{y.lastChild&&y.removeChild(y.lastChild),y.appendChild(u)});const g=(d=s.target)==null?void 0:d.result;g&&(this.previousValue=g,HawkSearch.services.search.query({queryString:g,requestType:"ImageData"}))},i.onerror=s=>{this.triggerUploadFailed("file_read_unsuccessful",{error:s})},i.readAsDataURL(r)}connectedCallback(){super.connectedCallback(),this.clickEventHandler=e=>{e.target.closest("hawksearch-visualsearch-droparea")},this.rootElement.ownerDocument.addEventListener("click",this.clickEventHandler)}disconnectedCallback(){super.disconnectedCallback(),this.rootElement.ownerDocument.removeEventListener("click",this.connectedCallback)}getContentModel(){var e,t,r,a,i,s,d,u,g;return{query:(e=this.data)==null?void 0:e.query,strings:{dragImageMessage:((r=(t=this.configuration)==null?void 0:t.strings)==null?void 0:r.dragImageMessage)??"Drag an image here or ",uploadImageMessage:((i=(a=this.configuration)==null?void 0:a.strings)==null?void 0:i.uploadImageMessage)??"upload an image",dropImageMessage:((d=(s=this.configuration)==null?void 0:s.strings)==null?void 0:d.dropImageMessage)??"Drop an image here",errorMessage:((g=(u=this.configuration)==null?void 0:u.strings)==null?void 0:g.errorMessage)??"Drop an image here"}}}onRender(){super.onRender(),this.rootElement.querySelectorAll("[hawksearch-visualsearch-fileinput]").forEach(e=>{e.addEventListener("change",t=>{t.preventDefault(),t.stopPropagation();const a=t.currentTarget.files;this.handleFiles(a)})}),this.rootElement.querySelectorAll("[hawksearch-visualsearch-droparea]").forEach(e=>{e.addEventListener("drop",t=>{t.preventDefault(),t.stopPropagation();const a=t.dataTransfer.files;this.handleFiles(a),e.classList.remove("dragging-state")}),e.addEventListener("dragover",t=>{t.preventDefault()}),e.addEventListener("dragenter",t=>{t.preventDefault(),t.stopPropagation(),e.classList.add("dragging-state")}),e.addEventListener("dragleave",t=>{t.preventDefault(),t.stopPropagation(),e.classList.remove("dragging-state")})})}isValidFile(e,t){return e.type.startsWith("image/")?e.size>this.maxSize?(this.triggerUploadFailed("file_too_large",{size:`${Math.round(e.size/1024/1024)}MB`}),!1):this.allowedExtensions.includes(t)?!0:(this.triggerUploadFailed("file_extension_unsupported",{extension:t}),!1):(this.triggerUploadFailed("file_type_unsupported",{type:e.type}),!1)}triggerUploadFailed(e,t){this.triggerEvent("hawksearch:visualsearch-upload-failed",{reason:e,...t})}}const Lc=`{{#if (arrayHasObjectsWithValue items "color")}}
964
+ </div>`;class Dc extends U{constructor(){super(...arguments),this.componentName="visualsearch-field",this.defaultHtml=Tc,this.bindFromEvent=!0,this.previousValue="",this.maxSize=4*1024*1024,this.allowedExtensions=["jpg","jpeg","png","webp","avif"]}handleFiles(e){var t;const r=e[0],a=(t=r.name.split(".").pop())==null?void 0:t.toLowerCase();if(!this.isValidFile(r,a))return;const i=new FileReader;i.onload=s=>{var d;const u=new Image;u.src=i.result,this.rootElement.querySelectorAll("[hawksearch-visualsearch-display]").forEach(y=>{y.lastChild&&y.removeChild(y.lastChild),y.appendChild(u)});const g=(d=s.target)==null?void 0:d.result;g&&(this.previousValue=g,HawkSearch.services.search.query({queryString:g,requestType:"ImageData"}))},i.onerror=s=>{this.triggerUploadFailed("file_read_unsuccessful",{error:s})},i.readAsDataURL(r)}connectedCallback(){super.connectedCallback(),this.clickEventHandler=e=>{e.target.closest("hawksearch-visualsearch-droparea")},this.rootElement.ownerDocument.addEventListener("click",this.clickEventHandler)}disconnectedCallback(){super.disconnectedCallback(),this.rootElement.ownerDocument.removeEventListener("click",this.connectedCallback)}getContentModel(){var e,t,r,a,i,s,d,u,g;return{query:(e=this.data)==null?void 0:e.query,strings:{dragImageMessage:((r=(t=this.configuration)==null?void 0:t.strings)==null?void 0:r.dragImageMessage)??"Drag an image here or ",uploadImageMessage:((i=(a=this.configuration)==null?void 0:a.strings)==null?void 0:i.uploadImageMessage)??"upload an image",dropImageMessage:((d=(s=this.configuration)==null?void 0:s.strings)==null?void 0:d.dropImageMessage)??"Drop an image here",errorMessage:((g=(u=this.configuration)==null?void 0:u.strings)==null?void 0:g.errorMessage)??"Drop an image here"}}}onRender(){super.onRender(),this.rootElement.querySelectorAll("[hawksearch-visualsearch-fileinput]").forEach(e=>{e.addEventListener("change",t=>{t.preventDefault(),t.stopPropagation();const a=t.currentTarget.files;this.handleFiles(a)})}),this.rootElement.querySelectorAll("[hawksearch-visualsearch-droparea]").forEach(e=>{e.addEventListener("drop",t=>{t.preventDefault(),t.stopPropagation();const a=t.dataTransfer.files;this.handleFiles(a),e.classList.remove("dragging-state")}),e.addEventListener("dragover",t=>{t.preventDefault()}),e.addEventListener("dragenter",t=>{t.preventDefault(),t.stopPropagation(),e.classList.add("dragging-state")}),e.addEventListener("dragleave",t=>{t.preventDefault(),t.stopPropagation(),e.classList.remove("dragging-state")})})}isValidFile(e,t){return e.type.startsWith("image/")?e.size>this.maxSize?(this.triggerUploadFailed("file_too_large",{size:`${Math.round(e.size/1024/1024)}MB`}),!1):this.allowedExtensions.includes(t)?!0:(this.triggerUploadFailed("file_extension_unsupported",{extension:t}),!1):(this.triggerUploadFailed("file_type_unsupported",{type:e.type}),!1)}triggerUploadFailed(e,t){this.triggerEvent("hawksearch:visualsearch-upload-failed",{reason:e,...t})}}const Lc=`{{#if (arrayHasObjectsWithValue items "color")}}
965
965
  <div class="variant-selector-list">
966
966
  {{#each (arrayFilterObjects items "color")}}
967
967
  <div