1 line
64 KiB
JavaScript
1 line
64 KiB
JavaScript
|
|
"use strict";(self.webpackChunkwebpack=self.webpackChunkwebpack||[]).push([[161],{27265:function(e,t,s){s.r(t),s.d(t,{initialize:function(){return Ft}}),s(78959);var r=s(35286),a=s(97465),n=s(38526),i=s(43197),o=s.n(i),l=s(45034),c=s.n(l),p=s(98027),h=s.n(p),u=s(84880);class d extends r.wA{constructor(...e){super(...e),o()(this,"handleOverlayOptionsUpdate",(e=>{this.props.updateOverlayOptions(e,(()=>this.props.showResults()))}))}componentDidMount(){(0,u.vJ)(this.handleOverlayOptionsUpdate),(0,u.Em)(this.props.toggleResults)}render(){return null}}class m extends r.wA{constructor(){super(...arguments),o()(this,"handleCompositionStart",(()=>this.setState({isComposing:!0}))),o()(this,"handleCompositionEnd",(()=>this.setState({isComposing:!1}))),o()(this,"handleFilterInputClick",(e=>{e.preventDefault(),e.currentTarget.dataset.filterType&&("taxonomy"===e.currentTarget.dataset.filterType?this.props.setFilter(e.currentTarget.dataset.taxonomy,e.currentTarget.dataset.val):this.props.setFilter(e.currentTarget.dataset.filterType,e.currentTarget.dataset.val)),this.props.setSearchQuery(""),this.props.showResults()})),o()(this,"handleHistoryNavigation",(()=>{this.props.initializeQueryValues({isHistoryNavigation:!0})})),o()(this,"handleInput",c()((e=>{var t,s;null!==(t=e.inputType)&&void 0!==t&&t.includes("format")||""===e.target.value||this.state.isComposing||"submit"!==this.props.overlayOptions.overlayTrigger&&(this.props.setSearchQuery(e.target.value),"immediate"===this.props.overlayOptions.overlayTrigger&&this.props.showResults(),"results"===this.props.overlayOptions.overlayTrigger&&(null===(s=this.props.response)||void 0===s?void 0:s.results)&&this.props.showResults())}),200)),o()(this,"handleKeyup",(e=>{"Enter"===e.key&&(this.props.setSearchQuery(e.target.value),this.props.showResults())})),o()(this,"handleOverlayTriggerClick",(e=>{e.stopImmediatePropagation(),this.props.setSearchQuery(""),this.props.showResults()})),o()(this,"handleSubmit",(e=>{if(e.preventDefault(),this.handleInput.flush(),!this.props.isVisible){var t;const s=null===(t=e.target.querySelector(this.props.themeOptions.searchInputSelector))||void 0===t?void 0:t.value;"string"==typeof s&&this.props.setSearchQuery(s),this.props.showResults()}})),o()(this,"fixBodyScroll",(()=>{var e;this.props.isVisible?(this.preventBodyScroll(),null===(e=window)||void 0===e||e.scrollTo(0,0)):this.props.isVisible||this.restoreBodyScroll()})),this.state={isComposing:!1,bodyScrollTop:0,previousStyle:null,previousBodyStyleAttribute:""},this.props.initializeQueryValues()}componentDidMount(){this.disableUnnecessaryFormAndInputAttributes(),this.addEventListeners()}componentWillUnmount(){this.removeEventListeners(),this.restoreBodyScroll()}componentDidUpdate(e){this.props.isVisible!==e.isVisible&&this.fixBodyScroll()}disableUnnecessaryFormAndInputAttributes(){document.querySelectorAll(this.props.themeOptions.searchInputSelector).forEach((e=>{e.removeAttribute("required"),e.removeAttribute("autocomplete"),e.form.removeAttribute("autocomplete")}))}addEventListeners(){window.addEventListener("popstate",this.handleHistoryNavigation),document.querySelectorAll(this.props.themeOptions.searchInputSelector).forEach((e=>{e.form.addEventListener("submit",this.handleSubmit),e.addEventListener("keyup",this.handleKeyup),e.addEventListener("input",this.handleInput),e.addEventListener("compositionstart",this.handleCompositionStart),e.addEventListener("compositionend",this.handleCompositionEnd)})),document.querySelectorAll(this.props.themeOptions.overlayTriggerSelector).forEach((e=>{e.addEventListener("click",this.handleOverlayTriggerClick,!0)})),document.querySelectorAll(this.props.themeOptions.filterInputSelector).forEach((e=>{e.addEventListener("click",this.handleFilterInputClick)}))}removeEventListeners(){window.removeEventListener("popstate",this.handleHistoryNavigation),document.querySelectorAll(this.props.themeOptions.searchInputSelector).forEach((e=>{e.form.removeEventListener("submit",this.handleSubmit),e.removeEventListener("keyup",this.handleKeyup),e.removeEventListener("input",this.handleInput),e
|