flotsam-autocomplete
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -1,2 +0,4 @@ | ||
const t="is-open";class e{constructor(t){this.eventName=t,this.callbacks=[]}registerCallback(t){this.callbacks.push(t)}unregisterCallback(t){const e=this.callbacks.indexOf(t);e>-1&&this.callbacks.splice(e,1)}fire(t){this.callbacks.slice(0).forEach(e=>{e(t)})}}class s{constructor(t){alert("dd"),this.events={},this.options=t,this.$input=t.el,this.data=!!t.data&&t.data,this.minChars=t.minChars?t.minChars:2,this.isOpen=!1,this.isListEmpty=!0,this.isFocused=!1,this.inputPreview=!0,this.onAjax=t.onAjax,this.init()}dispatch(t,e){const s=this.events[t];s&&s.fire(e)}on(t,s){let i=this.events[t];i||(i=new e(t),this.events[t]=i),i.registerCallback(s)}off(t,e){const s=this.events[t];s&&s.callbacks.indexOf(e)>-1&&(s.unregisterCallback(e),0===s.callbacks.length&&delete this.events[t])}setUp(){this.$input.setAttribute("autocomplete","off")}initModal(){this.$input.insertAdjacentHTML("afterend",'\n <div class="autocomplete-modal testing......">\n <div class="autocomplete-modal__inner">\n <ul class="autocomplete-modal__list" role="combobox">\n </ul>\n </div>\n </div>\n '),this.modal=document.querySelector(".autocomplete-modal"),this.list=this.modal.querySelector(".autocomplete-modal__list"),this.modal.style.pointerEvents="none",this.modal.style.visibility="hidden"}initInputCheck(){this.isDisabled||this.$input.addEventListener("input",this.onAjax?t=>{this.value=t.target.value,this.value.length>=this.minChars?(this.dispatch("loadingData",{input:this.$input,modal:this.modal,floatsam:this,options:this.options}),this.onAjax(this.value).then(t=>{this.data=t,this.dispatch("loadedData",{input:this.$input,modal:this.modal,floatsam:this,options:this.options}),this.update()})):this.closeModal()}:t=>{this.value=t.target.value,this.value.length>=this.minChars&&this.update()})}update(){this.data?(console.log(this.value),this.generateListItems(),!1===this.isOpen&&this.openModal()):this.closeModal()}preventSubmit(t){t.preventDefault()}openModal(){this.isDisabled||(document.addEventListener("submit",this.preventSubmit),console.log("adding keydown"),this.checkKey=this.checkKey.bind(this),document.addEventListener("keydown",this.checkKey,!0),this.modal.style.pointerEvents="auto",this.modal.style.visibility="visible",this.$input.classList.add(t),this.isOpen=!0,this.dispatch("openModal",{input:this.$input,modal:this.modal,floatsam:this,options:this.options}))}closeModal(){console.log("close list"),this.list.innerHTML="",this.currentSelected=null,this.isOpen&&(document.removeEventListener("submit",this.preventSubmit),console.log("removing keydown"),document.removeEventListener("keydown",this.checkKey,!0)),this.modal.style.pointerEvents="none",this.modal.style.visibility="hidden",this.$input.classList.remove(t),this.$input.focus(),this.isOpen=!1,this.dispatch("closeModal",{input:this.$input,modal:this.modal,floatsam:this,options:this.options})}checkKey(t){"38"==t.keyCode?this.selectPrev():"40"==t.keyCode?this.selectNext():"37"==t.keyCode||"39"==t.keyCode||("27"==t.keyCode||"9"==t.keyCode?(t.preventDefault(),this.closeModal()):"13"==t.keyCode&&(t.preventDefault(),this.closeModal(),this.$input.closest("form").submit()))}selectItem(){const t=[...this.list.querySelectorAll("li")];console.log(this.currentSelected),t.forEach((t,e)=>{e===this.currentSelected?(t.classList.add("selected-item"),this.inputPreview&&this.setInput(t.textContent),this.dispatch("selectKey",{selected:t.textContent,input:this.$input,modal:this.modal,floatsam:this,options:this.options})):t.classList.remove("selected-item")})}selectNext(){this.currentSelected=null===this.currentSelected?0:this.currentSelected+1,this.selectItem()}selectPrev(){this.currentSelected=this.currentSelected-1,this.selectItem()}generateListItems(){let t="";this.data?(this.data.filter(t=>{if(console.log(this.value),t.toLowerCase().includes(this.value.toLowerCase()))return t}).forEach(e=>{const s=new RegExp(this.value,"gi"),i=e.replace(s,t=>"<span style='background-color: yellow;'>"+t+"</span>");t+=`<li role="option">${i}</li>`}),this.list.innerHTML=t,[...this.list.querySelectorAll("li")].forEach(t=>{t.addEventListener("click",()=>{this.setInput(t.textContent),this.closeModal()})})):console.warn("no data!!!",this.value)}setInput(t){this.$input.value=t}triggerClose(){this.closeModal()}triggerDisable(){this.isDisabled=!0,this.closeModal(),this.dispatch("disabled",{input:this.$input,modal:this.modal,floatsam:this,options:this.options})}triggerEnable(){this.isDisabled=!1}minCharsExcceded(){return this.value.length>=this.minChars}init(){this._self=this,this.currentSelected=null,this.isDisabled=!1,this.setUp(),this.initModal(),this.initInputCheck(),alert("kyletest!!!"),this.dispatch("init",{input:this.$input,modal:this.modal,floatsam:this,options:this.options})}}export{s as default}; | ||
const t="is-open";class e{constructor(t){this.eventName=t,this.callbacks=[]}registerCallback(t){this.callbacks.push(t)}unregisterCallback(t){const e=this.callbacks.indexOf(t);e>-1&&this.callbacks.splice(e,1)}fire(t){this.callbacks.slice(0).forEach(e=>{e(t)})}}class s{constructor(t){this.events={},this.options=t,this.$input=t.el,this.data=!!t.data&&t.data,this.minChars=t.minChars?t.minChars:2,this.isOpen=!1,this.isListEmpty=!0,this.isFocused=!1,this.inputPreview=!0,this.onAjax=t.onAjax,this.init()}dispatch(t,e){const s=this.events[t];s&&s.fire(e)}on(t,s){let i=this.events[t];i||(i=new e(t),this.events[t]=i),i.registerCallback(s)}off(t,e){const s=this.events[t];s&&s.callbacks.indexOf(e)>-1&&(s.unregisterCallback(e),0===s.callbacks.length&&delete this.events[t])}setUp(){this.$input.setAttribute("autocomplete","off")}initModal(){this.$input.insertAdjacentHTML("afterend",'\n <div class="autocomplete-modal we active">\n <div class="autocomplete-modal__inner">\n <ul class="autocomplete-modal__list" role="combobox">\n </ul>\n </div>\n </div>\n '),this.modal=document.querySelector(".autocomplete-modal"),this.list=this.modal.querySelector(".autocomplete-modal__list"),this.modal.style.pointerEvents="none",this.modal.style.visibility="hidden"}initInputCheck(){this.isDisabled||this.$input.addEventListener("input",this.onAjax?t=>{this.value=t.target.value,this.value.length>=this.minChars?(this.dispatch("loadingData",{input:this.$input,modal:this.modal,floatsam:this,options:this.options}),this.onAjax(this.value).then(t=>{this.data=t,this.dispatch("loadedData",{input:this.$input,modal:this.modal,floatsam:this,options:this.options}),this.update()})):this.closeModal()}:t=>{this.value=t.target.value,this.value.length>=this.minChars&&this.update()})}update(){this.data?(console.log(this.value),this.generateListItems(),!1===this.isOpen&&this.openModal()):this.closeModal()}preventSubmit(t){t.preventDefault()}openModal(){this.isDisabled||(document.addEventListener("submit",this.preventSubmit),console.log("adding keydown"),this.checkKey=this.checkKey.bind(this),document.addEventListener("keydown",this.checkKey,!0),this.modal.style.pointerEvents="auto",this.modal.style.visibility="visible",this.$input.classList.add(t),this.isOpen=!0,this.dispatch("openModal",{input:this.$input,modal:this.modal,floatsam:this,options:this.options}))}closeModal(){console.log("close list"),this.list.innerHTML="",this.currentSelected=null,this.isOpen&&(document.removeEventListener("submit",this.preventSubmit),console.log("removing keydown"),document.removeEventListener("keydown",this.checkKey,!0)),this.modal.style.pointerEvents="none",this.modal.style.visibility="hidden",this.$input.classList.remove(t),this.$input.focus(),this.isOpen=!1,this.dispatch("closeModal",{input:this.$input,modal:this.modal,floatsam:this,options:this.options})}checkKey(t){"38"==t.keyCode?this.selectPrev():"40"==t.keyCode?this.selectNext():"37"==t.keyCode||"39"==t.keyCode||("27"==t.keyCode||"9"==t.keyCode?(t.preventDefault(),this.closeModal()):"13"==t.keyCode&&(t.preventDefault(),this.closeModal(),this.$input.closest("form").submit()))}selectItem(){const t=[...this.list.querySelectorAll("li")];console.log(this.currentSelected),t.forEach((t,e)=>{e===this.currentSelected?(t.classList.add("selected-item"),this.inputPreview&&this.setInput(t.textContent),this.dispatch("selectKey",{selected:t.textContent,input:this.$input,modal:this.modal,floatsam:this,options:this.options})):t.classList.remove("selected-item")})}selectNext(){this.currentSelected=null===this.currentSelected?0:this.currentSelected+1,this.selectItem()}selectPrev(){this.currentSelected=this.currentSelected-1,this.selectItem()}generateListItems(){let t="";this.data?(this.data.filter(t=>{if(console.log(this.value),t.toLowerCase().includes(this.value.toLowerCase()))return t}).forEach(e=>{const s=new RegExp(this.value,"gi"),i=e.replace(s,t=>"<span style='background-color: yellow;'>"+t+"</span>");t+=`<li role="option">${i}</li>`}),this.list.innerHTML=t,[...this.list.querySelectorAll("li")].forEach(t=>{t.addEventListener("click",()=>{this.setInput(t.textContent),this.closeModal()})})):console.warn("no data!!!",this.value)}setInput(t){this.$input.value=t}triggerClose(){this.closeModal()}triggerDisable(){this.isDisabled=!0,this.closeModal(),this.dispatch("disabled",{input:this.$input,modal:this.modal,floatsam:this,options:this.options})}triggerEnable(){this.isDisabled=!1}minCharsExcceded(){return this.value.length>=this.minChars}init(){this._self=this,this.currentSelected=null,this.isDisabled=!1,this.setUp(),this.initModal(),this.initInputCheck(),console.log("we are in dev mode"),this.dispatch("init",{input:this.$input,modal:this.modal,floatsam:this,options:this.options})}}export{s as default}; | ||
//# sourceMappingURL=flotsam.modern.js.map | ||
console.log('checnage here') |
@@ -1,2 +0,2 @@ | ||
var t="is-open",e=/*#__PURE__*/function(){function t(t){this.eventName=t,this.callbacks=[]}var e=t.prototype;return e.registerCallback=function(t){this.callbacks.push(t)},e.unregisterCallback=function(t){var e=this.callbacks.indexOf(t);e>-1&&this.callbacks.splice(e,1)},e.fire=function(t){this.callbacks.slice(0).forEach(function(e){e(t)})},t}(),i=/*#__PURE__*/function(){function i(t){alert("dd"),this.events={},this.options=t,this.$input=t.el,this.data=!!t.data&&t.data,this.minChars=t.minChars?t.minChars:2,this.isOpen=!1,this.isListEmpty=!0,this.isFocused=!1,this.inputPreview=!0,this.onAjax=t.onAjax,this.init()}var s=i.prototype;return s.dispatch=function(t,e){var i=this.events[t];i&&i.fire(e)},s.on=function(t,i){var s=this.events[t];s||(s=new e(t),this.events[t]=s),s.registerCallback(i)},s.off=function(t,e){var i=this.events[t];i&&i.callbacks.indexOf(e)>-1&&(i.unregisterCallback(e),0===i.callbacks.length&&delete this.events[t])},s.setUp=function(){this.$input.setAttribute("autocomplete","off")},s.initModal=function(){this.$input.insertAdjacentHTML("afterend",'\n <div class="autocomplete-modal testing......">\n <div class="autocomplete-modal__inner">\n <ul class="autocomplete-modal__list" role="combobox">\n </ul>\n </div>\n </div>\n '),this.modal=document.querySelector(".autocomplete-modal"),this.list=this.modal.querySelector(".autocomplete-modal__list"),this.modal.style.pointerEvents="none",this.modal.style.visibility="hidden"},s.initInputCheck=function(){var t=this;this.isDisabled||this.$input.addEventListener("input",this.onAjax?function(e){t.value=e.target.value,t.value.length>=t.minChars?(t.dispatch("loadingData",{input:t.$input,modal:t.modal,floatsam:t,options:t.options}),t.onAjax(t.value).then(function(e){t.data=e,t.dispatch("loadedData",{input:t.$input,modal:t.modal,floatsam:t,options:t.options}),t.update()})):t.closeModal()}:function(e){t.value=e.target.value,t.value.length>=t.minChars&&t.update()})},s.update=function(){this.data?(console.log(this.value),this.generateListItems(),!1===this.isOpen&&this.openModal()):this.closeModal()},s.preventSubmit=function(t){t.preventDefault()},s.openModal=function(){this.isDisabled||(document.addEventListener("submit",this.preventSubmit),console.log("adding keydown"),this.checkKey=this.checkKey.bind(this),document.addEventListener("keydown",this.checkKey,!0),this.modal.style.pointerEvents="auto",this.modal.style.visibility="visible",this.$input.classList.add(t),this.isOpen=!0,this.dispatch("openModal",{input:this.$input,modal:this.modal,floatsam:this,options:this.options}))},s.closeModal=function(){console.log("close list"),this.list.innerHTML="",this.currentSelected=null,this.isOpen&&(document.removeEventListener("submit",this.preventSubmit),console.log("removing keydown"),document.removeEventListener("keydown",this.checkKey,!0)),this.modal.style.pointerEvents="none",this.modal.style.visibility="hidden",this.$input.classList.remove(t),this.$input.focus(),this.isOpen=!1,this.dispatch("closeModal",{input:this.$input,modal:this.modal,floatsam:this,options:this.options})},s.checkKey=function(t){"38"==t.keyCode?this.selectPrev():"40"==t.keyCode?this.selectNext():"37"==t.keyCode||"39"==t.keyCode||("27"==t.keyCode||"9"==t.keyCode?(t.preventDefault(),this.closeModal()):"13"==t.keyCode&&(t.preventDefault(),this.closeModal(),this.$input.closest("form").submit()))},s.selectItem=function(){var t=this,e=[].concat(this.list.querySelectorAll("li"));console.log(this.currentSelected),e.forEach(function(e,i){i===t.currentSelected?(e.classList.add("selected-item"),t.inputPreview&&t.setInput(e.textContent),t.dispatch("selectKey",{selected:e.textContent,input:t.$input,modal:t.modal,floatsam:t,options:t.options})):e.classList.remove("selected-item")})},s.selectNext=function(){this.currentSelected=null===this.currentSelected?0:this.currentSelected+1,this.selectItem()},s.selectPrev=function(){this.currentSelected=this.currentSelected-1,this.selectItem()},s.generateListItems=function(){var t=this,e="";this.data?(this.data.filter(function(e){if(console.log(t.value),e.toLowerCase().includes(t.value.toLowerCase()))return e}).forEach(function(i){var s=new RegExp(t.value,"gi"),n=i.replace(s,function(t){return"<span style='background-color: yellow;'>"+t+"</span>"});e=e+'<li role="option">'+n+"</li>"}),this.list.innerHTML=e,[].concat(this.list.querySelectorAll("li")).forEach(function(e){e.addEventListener("click",function(){t.setInput(e.textContent),t.closeModal()})})):console.warn("no data!!!",this.value)},s.setInput=function(t){this.$input.value=t},s.triggerClose=function(){this.closeModal()},s.triggerDisable=function(){this.isDisabled=!0,this.closeModal(),this.dispatch("disabled",{input:this.$input,modal:this.modal,floatsam:this,options:this.options})},s.triggerEnable=function(){this.isDisabled=!1},s.minCharsExcceded=function(){return this.value.length>=this.minChars},s.init=function(){this._self=this,this.currentSelected=null,this.isDisabled=!1,this.setUp(),this.initModal(),this.initInputCheck(),alert("kyletest!!!"),this.dispatch("init",{input:this.$input,modal:this.modal,floatsam:this,options:this.options})},i}();export{i as default}; | ||
var t="is-open",e=/*#__PURE__*/function(){function t(t){this.eventName=t,this.callbacks=[]}var e=t.prototype;return e.registerCallback=function(t){this.callbacks.push(t)},e.unregisterCallback=function(t){var e=this.callbacks.indexOf(t);e>-1&&this.callbacks.splice(e,1)},e.fire=function(t){this.callbacks.slice(0).forEach(function(e){e(t)})},t}(),i=/*#__PURE__*/function(){function i(t){this.events={},this.options=t,this.$input=t.el,this.data=!!t.data&&t.data,this.minChars=t.minChars?t.minChars:2,this.isOpen=!1,this.isListEmpty=!0,this.isFocused=!1,this.inputPreview=!0,this.onAjax=t.onAjax,this.init()}var s=i.prototype;return s.dispatch=function(t,e){var i=this.events[t];i&&i.fire(e)},s.on=function(t,i){var s=this.events[t];s||(s=new e(t),this.events[t]=s),s.registerCallback(i)},s.off=function(t,e){var i=this.events[t];i&&i.callbacks.indexOf(e)>-1&&(i.unregisterCallback(e),0===i.callbacks.length&&delete this.events[t])},s.setUp=function(){this.$input.setAttribute("autocomplete","off")},s.initModal=function(){this.$input.insertAdjacentHTML("afterend",'\n <div class="autocomplete-modal we active">\n <div class="autocomplete-modal__inner">\n <ul class="autocomplete-modal__list" role="combobox">\n </ul>\n </div>\n </div>\n '),this.modal=document.querySelector(".autocomplete-modal"),this.list=this.modal.querySelector(".autocomplete-modal__list"),this.modal.style.pointerEvents="none",this.modal.style.visibility="hidden"},s.initInputCheck=function(){var t=this;this.isDisabled||this.$input.addEventListener("input",this.onAjax?function(e){t.value=e.target.value,t.value.length>=t.minChars?(t.dispatch("loadingData",{input:t.$input,modal:t.modal,floatsam:t,options:t.options}),t.onAjax(t.value).then(function(e){t.data=e,t.dispatch("loadedData",{input:t.$input,modal:t.modal,floatsam:t,options:t.options}),t.update()})):t.closeModal()}:function(e){t.value=e.target.value,t.value.length>=t.minChars&&t.update()})},s.update=function(){this.data?(console.log(this.value),this.generateListItems(),!1===this.isOpen&&this.openModal()):this.closeModal()},s.preventSubmit=function(t){t.preventDefault()},s.openModal=function(){this.isDisabled||(document.addEventListener("submit",this.preventSubmit),console.log("adding keydown"),this.checkKey=this.checkKey.bind(this),document.addEventListener("keydown",this.checkKey,!0),this.modal.style.pointerEvents="auto",this.modal.style.visibility="visible",this.$input.classList.add(t),this.isOpen=!0,this.dispatch("openModal",{input:this.$input,modal:this.modal,floatsam:this,options:this.options}))},s.closeModal=function(){console.log("close list"),this.list.innerHTML="",this.currentSelected=null,this.isOpen&&(document.removeEventListener("submit",this.preventSubmit),console.log("removing keydown"),document.removeEventListener("keydown",this.checkKey,!0)),this.modal.style.pointerEvents="none",this.modal.style.visibility="hidden",this.$input.classList.remove(t),this.$input.focus(),this.isOpen=!1,this.dispatch("closeModal",{input:this.$input,modal:this.modal,floatsam:this,options:this.options})},s.checkKey=function(t){"38"==t.keyCode?this.selectPrev():"40"==t.keyCode?this.selectNext():"37"==t.keyCode||"39"==t.keyCode||("27"==t.keyCode||"9"==t.keyCode?(t.preventDefault(),this.closeModal()):"13"==t.keyCode&&(t.preventDefault(),this.closeModal(),this.$input.closest("form").submit()))},s.selectItem=function(){var t=this,e=[].concat(this.list.querySelectorAll("li"));console.log(this.currentSelected),e.forEach(function(e,i){i===t.currentSelected?(e.classList.add("selected-item"),t.inputPreview&&t.setInput(e.textContent),t.dispatch("selectKey",{selected:e.textContent,input:t.$input,modal:t.modal,floatsam:t,options:t.options})):e.classList.remove("selected-item")})},s.selectNext=function(){this.currentSelected=null===this.currentSelected?0:this.currentSelected+1,this.selectItem()},s.selectPrev=function(){this.currentSelected=this.currentSelected-1,this.selectItem()},s.generateListItems=function(){var t=this,e="";this.data?(this.data.filter(function(e){if(console.log(t.value),e.toLowerCase().includes(t.value.toLowerCase()))return e}).forEach(function(i){var s=new RegExp(t.value,"gi"),n=i.replace(s,function(t){return"<span style='background-color: yellow;'>"+t+"</span>"});e=e+'<li role="option">'+n+"</li>"}),this.list.innerHTML=e,[].concat(this.list.querySelectorAll("li")).forEach(function(e){e.addEventListener("click",function(){t.setInput(e.textContent),t.closeModal()})})):console.warn("no data!!!",this.value)},s.setInput=function(t){this.$input.value=t},s.triggerClose=function(){this.closeModal()},s.triggerDisable=function(){this.isDisabled=!0,this.closeModal(),this.dispatch("disabled",{input:this.$input,modal:this.modal,floatsam:this,options:this.options})},s.triggerEnable=function(){this.isDisabled=!1},s.minCharsExcceded=function(){return this.value.length>=this.minChars},s.init=function(){this._self=this,this.currentSelected=null,this.isDisabled=!1,this.setUp(),this.initModal(),this.initInputCheck(),console.log("we are in dev mode"),this.dispatch("init",{input:this.$input,modal:this.modal,floatsam:this,options:this.options})},i}();export{i as default}; | ||
//# sourceMappingURL=flotsam.module.js.map |
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t||self).flotsamAutocomplete=e()}(this,function(){var t="is-open",e=/*#__PURE__*/function(){function t(t){this.eventName=t,this.callbacks=[]}var e=t.prototype;return e.registerCallback=function(t){this.callbacks.push(t)},e.unregisterCallback=function(t){var e=this.callbacks.indexOf(t);e>-1&&this.callbacks.splice(e,1)},e.fire=function(t){this.callbacks.slice(0).forEach(function(e){e(t)})},t}();/*#__PURE__*/ | ||
return function(){function i(t){alert("dd"),this.events={},this.options=t,this.$input=t.el,this.data=!!t.data&&t.data,this.minChars=t.minChars?t.minChars:2,this.isOpen=!1,this.isListEmpty=!0,this.isFocused=!1,this.inputPreview=!0,this.onAjax=t.onAjax,this.init()}var s=i.prototype;return s.dispatch=function(t,e){var i=this.events[t];i&&i.fire(e)},s.on=function(t,i){var s=this.events[t];s||(s=new e(t),this.events[t]=s),s.registerCallback(i)},s.off=function(t,e){var i=this.events[t];i&&i.callbacks.indexOf(e)>-1&&(i.unregisterCallback(e),0===i.callbacks.length&&delete this.events[t])},s.setUp=function(){this.$input.setAttribute("autocomplete","off")},s.initModal=function(){this.$input.insertAdjacentHTML("afterend",'\n <div class="autocomplete-modal testing......">\n <div class="autocomplete-modal__inner">\n <ul class="autocomplete-modal__list" role="combobox">\n </ul>\n </div>\n </div>\n '),this.modal=document.querySelector(".autocomplete-modal"),this.list=this.modal.querySelector(".autocomplete-modal__list"),this.modal.style.pointerEvents="none",this.modal.style.visibility="hidden"},s.initInputCheck=function(){var t=this;this.isDisabled||this.$input.addEventListener("input",this.onAjax?function(e){t.value=e.target.value,t.value.length>=t.minChars?(t.dispatch("loadingData",{input:t.$input,modal:t.modal,floatsam:t,options:t.options}),t.onAjax(t.value).then(function(e){t.data=e,t.dispatch("loadedData",{input:t.$input,modal:t.modal,floatsam:t,options:t.options}),t.update()})):t.closeModal()}:function(e){t.value=e.target.value,t.value.length>=t.minChars&&t.update()})},s.update=function(){this.data?(console.log(this.value),this.generateListItems(),!1===this.isOpen&&this.openModal()):this.closeModal()},s.preventSubmit=function(t){t.preventDefault()},s.openModal=function(){this.isDisabled||(document.addEventListener("submit",this.preventSubmit),console.log("adding keydown"),this.checkKey=this.checkKey.bind(this),document.addEventListener("keydown",this.checkKey,!0),this.modal.style.pointerEvents="auto",this.modal.style.visibility="visible",this.$input.classList.add(t),this.isOpen=!0,this.dispatch("openModal",{input:this.$input,modal:this.modal,floatsam:this,options:this.options}))},s.closeModal=function(){console.log("close list"),this.list.innerHTML="",this.currentSelected=null,this.isOpen&&(document.removeEventListener("submit",this.preventSubmit),console.log("removing keydown"),document.removeEventListener("keydown",this.checkKey,!0)),this.modal.style.pointerEvents="none",this.modal.style.visibility="hidden",this.$input.classList.remove(t),this.$input.focus(),this.isOpen=!1,this.dispatch("closeModal",{input:this.$input,modal:this.modal,floatsam:this,options:this.options})},s.checkKey=function(t){"38"==t.keyCode?this.selectPrev():"40"==t.keyCode?this.selectNext():"37"==t.keyCode||"39"==t.keyCode||("27"==t.keyCode||"9"==t.keyCode?(t.preventDefault(),this.closeModal()):"13"==t.keyCode&&(t.preventDefault(),this.closeModal(),this.$input.closest("form").submit()))},s.selectItem=function(){var t=this,e=[].concat(this.list.querySelectorAll("li"));console.log(this.currentSelected),e.forEach(function(e,i){i===t.currentSelected?(e.classList.add("selected-item"),t.inputPreview&&t.setInput(e.textContent),t.dispatch("selectKey",{selected:e.textContent,input:t.$input,modal:t.modal,floatsam:t,options:t.options})):e.classList.remove("selected-item")})},s.selectNext=function(){this.currentSelected=null===this.currentSelected?0:this.currentSelected+1,this.selectItem()},s.selectPrev=function(){this.currentSelected=this.currentSelected-1,this.selectItem()},s.generateListItems=function(){var t=this,e="";this.data?(this.data.filter(function(e){if(console.log(t.value),e.toLowerCase().includes(t.value.toLowerCase()))return e}).forEach(function(i){var s=new RegExp(t.value,"gi"),n=i.replace(s,function(t){return"<span style='background-color: yellow;'>"+t+"</span>"});e=e+'<li role="option">'+n+"</li>"}),this.list.innerHTML=e,[].concat(this.list.querySelectorAll("li")).forEach(function(e){e.addEventListener("click",function(){t.setInput(e.textContent),t.closeModal()})})):console.warn("no data!!!",this.value)},s.setInput=function(t){this.$input.value=t},s.triggerClose=function(){this.closeModal()},s.triggerDisable=function(){this.isDisabled=!0,this.closeModal(),this.dispatch("disabled",{input:this.$input,modal:this.modal,floatsam:this,options:this.options})},s.triggerEnable=function(){this.isDisabled=!1},s.minCharsExcceded=function(){return this.value.length>=this.minChars},s.init=function(){this._self=this,this.currentSelected=null,this.isDisabled=!1,this.setUp(),this.initModal(),this.initInputCheck(),alert("kyletest!!!"),this.dispatch("init",{input:this.$input,modal:this.modal,floatsam:this,options:this.options})},i}()}); | ||
return function(){function i(t){this.events={},this.options=t,this.$input=t.el,this.data=!!t.data&&t.data,this.minChars=t.minChars?t.minChars:2,this.isOpen=!1,this.isListEmpty=!0,this.isFocused=!1,this.inputPreview=!0,this.onAjax=t.onAjax,this.init()}var s=i.prototype;return s.dispatch=function(t,e){var i=this.events[t];i&&i.fire(e)},s.on=function(t,i){var s=this.events[t];s||(s=new e(t),this.events[t]=s),s.registerCallback(i)},s.off=function(t,e){var i=this.events[t];i&&i.callbacks.indexOf(e)>-1&&(i.unregisterCallback(e),0===i.callbacks.length&&delete this.events[t])},s.setUp=function(){this.$input.setAttribute("autocomplete","off")},s.initModal=function(){this.$input.insertAdjacentHTML("afterend",'\n <div class="autocomplete-modal we active">\n <div class="autocomplete-modal__inner">\n <ul class="autocomplete-modal__list" role="combobox">\n </ul>\n </div>\n </div>\n '),this.modal=document.querySelector(".autocomplete-modal"),this.list=this.modal.querySelector(".autocomplete-modal__list"),this.modal.style.pointerEvents="none",this.modal.style.visibility="hidden"},s.initInputCheck=function(){var t=this;this.isDisabled||this.$input.addEventListener("input",this.onAjax?function(e){t.value=e.target.value,t.value.length>=t.minChars?(t.dispatch("loadingData",{input:t.$input,modal:t.modal,floatsam:t,options:t.options}),t.onAjax(t.value).then(function(e){t.data=e,t.dispatch("loadedData",{input:t.$input,modal:t.modal,floatsam:t,options:t.options}),t.update()})):t.closeModal()}:function(e){t.value=e.target.value,t.value.length>=t.minChars&&t.update()})},s.update=function(){this.data?(console.log(this.value),this.generateListItems(),!1===this.isOpen&&this.openModal()):this.closeModal()},s.preventSubmit=function(t){t.preventDefault()},s.openModal=function(){this.isDisabled||(document.addEventListener("submit",this.preventSubmit),console.log("adding keydown"),this.checkKey=this.checkKey.bind(this),document.addEventListener("keydown",this.checkKey,!0),this.modal.style.pointerEvents="auto",this.modal.style.visibility="visible",this.$input.classList.add(t),this.isOpen=!0,this.dispatch("openModal",{input:this.$input,modal:this.modal,floatsam:this,options:this.options}))},s.closeModal=function(){console.log("close list"),this.list.innerHTML="",this.currentSelected=null,this.isOpen&&(document.removeEventListener("submit",this.preventSubmit),console.log("removing keydown"),document.removeEventListener("keydown",this.checkKey,!0)),this.modal.style.pointerEvents="none",this.modal.style.visibility="hidden",this.$input.classList.remove(t),this.$input.focus(),this.isOpen=!1,this.dispatch("closeModal",{input:this.$input,modal:this.modal,floatsam:this,options:this.options})},s.checkKey=function(t){"38"==t.keyCode?this.selectPrev():"40"==t.keyCode?this.selectNext():"37"==t.keyCode||"39"==t.keyCode||("27"==t.keyCode||"9"==t.keyCode?(t.preventDefault(),this.closeModal()):"13"==t.keyCode&&(t.preventDefault(),this.closeModal(),this.$input.closest("form").submit()))},s.selectItem=function(){var t=this,e=[].concat(this.list.querySelectorAll("li"));console.log(this.currentSelected),e.forEach(function(e,i){i===t.currentSelected?(e.classList.add("selected-item"),t.inputPreview&&t.setInput(e.textContent),t.dispatch("selectKey",{selected:e.textContent,input:t.$input,modal:t.modal,floatsam:t,options:t.options})):e.classList.remove("selected-item")})},s.selectNext=function(){this.currentSelected=null===this.currentSelected?0:this.currentSelected+1,this.selectItem()},s.selectPrev=function(){this.currentSelected=this.currentSelected-1,this.selectItem()},s.generateListItems=function(){var t=this,e="";this.data?(this.data.filter(function(e){if(console.log(t.value),e.toLowerCase().includes(t.value.toLowerCase()))return e}).forEach(function(i){var s=new RegExp(t.value,"gi"),n=i.replace(s,function(t){return"<span style='background-color: yellow;'>"+t+"</span>"});e=e+'<li role="option">'+n+"</li>"}),this.list.innerHTML=e,[].concat(this.list.querySelectorAll("li")).forEach(function(e){e.addEventListener("click",function(){t.setInput(e.textContent),t.closeModal()})})):console.warn("no data!!!",this.value)},s.setInput=function(t){this.$input.value=t},s.triggerClose=function(){this.closeModal()},s.triggerDisable=function(){this.isDisabled=!0,this.closeModal(),this.dispatch("disabled",{input:this.$input,modal:this.modal,floatsam:this,options:this.options})},s.triggerEnable=function(){this.isDisabled=!1},s.minCharsExcceded=function(){return this.value.length>=this.minChars},s.init=function(){this._self=this,this.currentSelected=null,this.isDisabled=!1,this.setUp(),this.initModal(),this.initInputCheck(),console.log("we are in dev mode"),this.dispatch("init",{input:this.$input,modal:this.modal,floatsam:this,options:this.options})},i}()}); | ||
//# sourceMappingURL=flotsam.umd.js.map | ||
console.log('checnage here') |
{ | ||
"name": "flotsam-autocomplete", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "no tears autocomplete", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -399,3 +399,3 @@ const modal = () => { | ||
alert('kyletest!!!') | ||
console.log('we are in dev mode') | ||
@@ -402,0 +402,0 @@ this.dispatch('init', { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
112358
440