PageSourceSearch

https://www.grimaud-provence.com/app/dist/grimaud/addons/woody-add…earch-engine-input-component.1be834f194.mjs

js grimaud-provence.com collected 2026-09-26 04:48:05 UTC 5,935 bytes, 1 lines download raw bytes

1import a from"woody_library_woody_component";class h extends a{#w={input_selector:".search-input",submit_selector:'[data-search-action="submit"]',launch_ai_selector:'[data-search-action="launch-ai"]',clear_selector:'[data-search-action="clear"]',animate_suggestions_limit:8,animate_typing_speed:60,animate_erasing_speed:40,animate_pause_duration:2e3,animate_between_duration:500};#t;#o;#r;#l;#e;#i=!1;#s;#u=[];#c=!1;#a=null;#h=null;#d=0;#p=!1;#n=0;constructor(){super()}async init(e){if(super.init(e),this.config=Object.assign(this.#w,this.config),document.addEventListener("click",t=>{this.contains(t.target)||this.#i&&this.#e.close()}),this.#t=this.querySelector(this.config.input_selector),!this.#t)throw new Error("SearchEngineInputComponent - init - input is missed");if(this.#t.addEventListener("keyup",t=>{t.key==="Enter"?(this.#i&&this.#e.close(),this.submit(this.#t.value)):t.key==="Escape"?this.escape():t.key==="ArrowUp"?(this.#i&&this.#e.open(),this.#i&&this.#e.selectUp()):t.key==="ArrowDown"?(this.#i&&this.#e.open(),this.#i&&this.#e.selectDown()):(this.#i&&this.#e.open(),this.#i&&this.#e.update(this.#t.value))}),this.#t.addEventListener("input",t=>{this.#t.value&&this.#t.value!=""?(this.classList.add("has-search-input-value"),this.#p&&this.#f()):(this.classList.remove("has-search-input-value"),this.#p&&this.#g())}),this.#t.addEventListener("click",t=>{this.#i&&this.#e.open()}),this.#t.addEventListener("focus",t=>{this.#i&&this.#e.open()}),this.#o=this.querySelector(this.config.submit_selector),this.#o?(this.#o.addEventListener("click",t=>{t.preventDefault(),this.submit(this.#t.value)}),this.#o.addEventListener("keyup",t=>{(t.key==="Enter"||t.key===" ")&&this.submit(this.#t.value)})):console.warn("SearchEngineInputComponent - init - no submit button found"),this.#r=this.querySelector(this.config.launch_ai_selector),this.#r&&(this.#r.addEventListener("click",t=>{t.preventDefault(),this.launch_ai(this.#t.value)}),this.#r.addEventListener("keyup",t=>{(t.key==="Enter"||t.key===" ")&&this.launch_ai(this.#t.value)})),this.#l=this.querySelector(this.config.clear_selector),this.#l?(this.#l.addEventListener("click",t=>{t.preventDefault(),this.clear()}),this.#l.addEventListener("keyup",t=>{(t.key==="Enter"||t.key===" ")&&this.clear()}
1)):console.warn("SearchEngineInputComponent - init - no clear button found"),this.#e=this.querySelector("woody-search-engine-input-dropdown"),!this.#e)throw new Error("SearchEngineInputComponent - init - dropdown component is missed");await customElements.whenDefined(this.#e.tagName.toLowerCase()),this.onCmpDropdownDefined(),this.hasAttribute("data-animate-suggestions")&&(this.#v(),this.#_())}#_(){const e=this.closest("woody-search-engine");e&&(e.addEventListener("search-hide",()=>{this.#f()}),e.addEventListener("search-show",()=>{this.#y()}))}onCmpDropdownDefined(){this.#i=!0,this.#e.addEventListener("submit",e=>{this.#i&&this.#e.close(),this.setInputValue(e.detail.value),this.submit(this.#t.value)}),this.#e.addEventListener("select",e=>{this.setInputValue(e.detail.value)}),document.activeElement===this.#t&&this.#e.open()}setInputValue(e){this.#t.value=e,this.#t.dispatchEvent(new Event("input"))}focus(){this.#t.focus()}submit(e){this.#i&&this.#e.close(),this.dispatchEvent(new CustomEvent("submit",{detail:{value:e}})),window.dataLayer.push({event:"view_search_results",search_term:e})}escape(){this.#e.isOpened()?this.#i&&this.#e.close():this.dispatchEvent(new Event("escape"))}launch_ai(e){if(!window.globals.django?.app_url){console.warn("SearchEngineInputComponent - launch_ai - window.globals.django.app_url is missed");return}let[t,i=""]=window.globals.django.app_url.split("?");const s=new URLSearchParams(i);s.set("question",e);const n=`${t}?${s.toString()}`;window.open(n,"_blank","noopener,noreferrer")}clear(){this.#t.value&&this.#t.value!=""?(this.setInputValue(""),this.#t.focus(),this.#i&&this.#e.update(this.#t.value)):this.#i&&this.#e.close()}async#v(){if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return;this.#s=document.createElement("span"),this.#s.className="search-input-animated-placeholder",this.#s.setAttribute("aria-hidden","true");const e=this.#t.closest(".input-group");if(e){e.appendChild(this.#s);try{const{fetchPopularSearches:t}=await import("woody_addon_search_data_controller"),i=await t();i&&i.length>0&&(this.#u=this.#E([...i]).slice(0,this.config.animate_suggestions_limit),this.#p=!0,e.classList.add("has-animated-placeholder"),(!this.#t.value||this.#t.value==="")&&this.#g())}catch(t){console.warn("SearchEngineInputComponent - animated placeholder - failed to fetch suggestions",t)}}}#E(e){for(let t=e.length-1;t>0;t--){const i=Math.floor(Math.random()*(t+1));[e[t],e[i]]=[e[i],e[t]]}return e}#g(){this.#c||(this.#c=!0,this.#s&&(this.#s.style.display=""),this.#b())}#y(){this.#f(),!(!this.#p||!this.#u.length)&&(this.#d=0,this.#s&&(this.#s.textContent="",this.#s.style.display=""),(!this.#t.value||this.#t.value==="")&&this.#g())}#f(){this.#c=!1,this.#n+=1,this.#a&&(clearTimeout(this.#a),this.#a=null),this.#h&&(this.#h(),this.#h=null),this.#s&&(this.#s.textContent="",this.#s.style.display="none")}async#b(){const e=this.#n;for(;this.#c&&e===this.#n;){const t=this.#u[this.#d];for(let i=0;i<=t.length;i++){if(e!==this.#n)return;this.#s.textContent=t.substring(0,i),await this.#m(this.config.animate_typing_speed,e)}if(e!==this.#n||(await this.#m(this.config.animate_pause_duration,e),e!==this.#n))return;for(let i=t.length;i>=0;i--){if(e!==this.#n)return;this.#s.textContent=t.substring(0,i),await this.#m(this.config.animate_erasing_speed,e)}if(e!==this.#n||(await this.#m(this.config.animate_between_duration,e),e!==this.#n))return;this.#d=(this.#d+1)%this.#u.length}}#m(e,t){return new Promise(i=>{if(t!==void 0&&t!==this.#n){i();return}this.#h=i,this.#a=setTimeout(()=>{this.#a=null,this.#h=null,i()},e)})}disconnectedCallback(){this.#f(),super.disconnectedCallback?.()}}export{h as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.