diff --git a/README.md b/README.md index 61a4898b..3847eb07 100644 --- a/README.md +++ b/README.md @@ -54,13 +54,13 @@ git clone https://github.com/TarekRaafat/autoComplete.js.git `CSS` ```html - + ``` `JS` ```html - + ``` - npm install `(Node Package Manager)` diff --git a/dist/js/autoComplete.js b/dist/js/autoComplete.js index 80600b1c..dbcfcef2 100644 --- a/dist/js/autoComplete.js +++ b/dist/js/autoComplete.js @@ -173,7 +173,7 @@ var createItem = (function (item, index, config) { var result = document.createElement(config.resultItem.element); - result.setAttribute("id", "".concat(config.resultItem.className, "_").concat(index)); + result.setAttribute("id", "".concat(config.resultItem.idName, "_").concat(index)); result.setAttribute("class", config.resultItem.className); result.setAttribute("role", "option"); result.innerHTML = item.match; diff --git a/dist/js/autoComplete.js.gz b/dist/js/autoComplete.js.gz index ce8979d4..70fd2849 100644 Binary files a/dist/js/autoComplete.js.gz and b/dist/js/autoComplete.js.gz differ diff --git a/dist/js/autoComplete.min.js b/dist/js/autoComplete.min.js index 5da09589..4b645c50 100644 --- a/dist/js/autoComplete.min.js +++ b/dist/js/autoComplete.min.js @@ -1 +1 @@ -var a,b;a=this,b=function(){"use strict";function e(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,i=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:t}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,o=!0,s=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,r=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw r}}}}function u(e,t){for(var n=document.getElementsByClassName(e.resultsList.className),i=0;i=e.length&&(o=0),o<0&&(o=e.length-1),e[o].setAttribute("aria-selected","true"),e[o].classList.add("autoComplete_selected")},a=n.resultsList.navigation||function(e){var t=document.getElementById(n.resultsList.idName);if(!t)return n.inputField.removeEventListener("keydown",a);t=t.getElementsByTagName(n.resultItem.element),27===e.keyCode?(n.inputField.value="",u(n)):40===e.keyCode||9===e.keyCode?i(e,t,!0,n):38===e.keyCode||9===e.keyCode?i(e,t,!1,n):13===e.keyCode&&(e.preventDefault(),-1'.concat(a,""):a,o++),r.push(a)}if(o===e.length)return r.join("")}else if(i.includes(e))return e=new RegExp("".concat(e),"i").exec(t),n.highlight?t.replace(e,''.concat(e,"")):t}(s,t,o))&&e?a.push({key:e,index:n,match:t,value:i}):t&&!e&&a.push({index:n,match:t,value:i}))}var i=o.data.store[n];if(o.data.key){var t,r=l(o.data.key);try{for(r.s();!(t=r.n()).done;)e(t.value)}catch(e){r.e(e)}finally{r.f()}}else e()},t=0;t=r.threshold&&o.replace(/ /g,"").length)?a.dataStore().then(function(e){try{return u(a),a.start(n,i),s.call(a)}catch(e){return t(e)}},t):(u(a),s.call(a));function s(){return e()}})}},{key:"init",value:function(){var e,n,i,r,t=this;this.inputField="string"==typeof this.selector?document.querySelector(this.selector):this.selector(),(e=this).inputField.setAttribute("type","text"),e.inputField.setAttribute("role","combobox"),e.inputField.setAttribute("aria-haspopup",!0),e.inputField.setAttribute("aria-expanded",!1),e.inputField.setAttribute("aria-controls",e.resultsList.idName),e.inputField.setAttribute("aria-autocomplete","both"),this.placeHolder&&this.inputField.setAttribute("placeholder",this.placeHolder),this.hook=(n=function(){t.compose()},i=this.debounce,function(){var e=this,t=arguments;clearTimeout(r),r=setTimeout(function(){return n.apply(e,t)},i)}),this.trigger.event.forEach(function(e){t.inputField.removeEventListener(e,t.hook),t.inputField.addEventListener(e,t.hook)}),d(this.inputField,null,"init")}},{key:"preInit",value:function(){var o=this,s=document;new MutationObserver(function(e,t){var n,i=s.querySelector(o.selector),r=l(e);try{for(r.s();!(n=r.n()).done;){n.value;i&&(t.disconnect(),d(i,null,"connect"),o.init())}}catch(e){r.e(e)}finally{r.f()}}).observe(s,{childList:!0,subtree:!0})}},{key:"unInit",value:function(){this.inputField.removeEventListener("input",this.hook),d(this.inputField,null,"unInit")}}])&&e(n.prototype,i),h&&e(n,h),T},"object"==typeof exports&&"undefined"!=typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):(a="undefined"!=typeof globalThis?globalThis:a||self).autoComplete=b(); +var a,b;a=this,b=function(){"use strict";function e(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,i=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:t}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,o=!0,s=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,r=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw r}}}}function u(e,t){for(var n=document.getElementsByClassName(e.resultsList.className),i=0;i=e.length&&(o=0),o<0&&(o=e.length-1),e[o].setAttribute("aria-selected","true"),e[o].classList.add("autoComplete_selected")},a=n.resultsList.navigation||function(e){var t=document.getElementById(n.resultsList.idName);if(!t)return n.inputField.removeEventListener("keydown",a);t=t.getElementsByTagName(n.resultItem.element),27===e.keyCode?(n.inputField.value="",u(n)):40===e.keyCode||9===e.keyCode?i(e,t,!0,n):38===e.keyCode||9===e.keyCode?i(e,t,!1,n):13===e.keyCode&&(e.preventDefault(),-1'.concat(a,""):a,o++),r.push(a)}if(o===e.length)return r.join("")}else if(i.includes(e))return e=new RegExp("".concat(e),"i").exec(t),n.highlight?t.replace(e,''.concat(e,"")):t}(s,t,o))&&e?a.push({key:e,index:n,match:t,value:i}):t&&!e&&a.push({index:n,match:t,value:i}))}var i=o.data.store[n];if(o.data.key){var t,r=l(o.data.key);try{for(r.s();!(t=r.n()).done;)e(t.value)}catch(e){r.e(e)}finally{r.f()}}else e()},t=0;t=r.threshold&&o.replace(/ /g,"").length)?a.dataStore().then(function(e){try{return u(a),a.start(n,i),s.call(a)}catch(e){return t(e)}},t):(u(a),s.call(a));function s(){return e()}})}},{key:"init",value:function(){var e,n,i,r,t=this;this.inputField="string"==typeof this.selector?document.querySelector(this.selector):this.selector(),(e=this).inputField.setAttribute("type","text"),e.inputField.setAttribute("role","combobox"),e.inputField.setAttribute("aria-haspopup",!0),e.inputField.setAttribute("aria-expanded",!1),e.inputField.setAttribute("aria-controls",e.resultsList.idName),e.inputField.setAttribute("aria-autocomplete","both"),this.placeHolder&&this.inputField.setAttribute("placeholder",this.placeHolder),this.hook=(n=function(){t.compose()},i=this.debounce,function(){var e=this,t=arguments;clearTimeout(r),r=setTimeout(function(){return n.apply(e,t)},i)}),this.trigger.event.forEach(function(e){t.inputField.removeEventListener(e,t.hook),t.inputField.addEventListener(e,t.hook)}),d(this.inputField,null,"init")}},{key:"preInit",value:function(){var o=this,s=document;new MutationObserver(function(e,t){var n,i=s.querySelector(o.selector),r=l(e);try{for(r.s();!(n=r.n()).done;){n.value;i&&(t.disconnect(),d(i,null,"connect"),o.init())}}catch(e){r.e(e)}finally{r.f()}}).observe(s,{childList:!0,subtree:!0})}},{key:"unInit",value:function(){this.inputField.removeEventListener("input",this.hook),d(this.inputField,null,"unInit")}}])&&e(n.prototype,i),h&&e(n,h),T},"object"==typeof exports&&"undefined"!=typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):(a="undefined"!=typeof globalThis?globalThis:a||self).autoComplete=b(); diff --git a/dist/js/autoComplete.min.js.gz b/dist/js/autoComplete.min.js.gz index 6ad196a3..8842fe6c 100644 Binary files a/dist/js/autoComplete.min.js.gz and b/dist/js/autoComplete.min.js.gz differ diff --git a/docs/README.md b/docs/README.md index b04b6aac..481cd9fa 100644 --- a/docs/README.md +++ b/docs/README.md @@ -69,13 +69,13 @@ npm run build `CSS` ```html - + ``` `JS` ```html - + ``` - cdnjs Logo CDN @@ -83,27 +83,27 @@ npm run build `CSS` ```html - + ``` `JS` ```html - + ``` -- unpkg Logo CDN +- unpkg Logo CDN `CSS` ```html - + ``` `JS` ```html - + ``` - HTML Logo HTML Local load @@ -151,7 +151,7 @@ const autoComplete = require("@tarekraafat/autocomplete.js/dist/js/autoComplete" ```html OR - + ``` 2. Assign the default `id` value `"autoComplete"` to the desired input field or use any custom `id/class` and configure the API selector accordingly in `Step 4` @@ -166,7 +166,7 @@ OR OR - + ``` diff --git a/docs/demo/index.html b/docs/demo/index.html index 7d520d61..dcd58170 100644 --- a/docs/demo/index.html +++ b/docs/demo/index.html @@ -72,7 +72,7 @@ + href="https://cdn.jsdelivr.net/npm/@tarekraafat/autocomplete.js@8.2.3/dist/css/autoComplete.min.css"> @@ -151,7 +151,7 @@

mode

- + diff --git a/docs/releases.md b/docs/releases.md index 0733fec3..4069d4ad 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -26,7 +26,10 @@ Release flags: ## Release Notes -- v8.2.2 ✨ +- v8.2.3 ✨ + - 🔧 Fix: `resultItem` ID `setAttribute` to be `idName` instead of `className` (Thanks 👍 @marsimeau) #173 + +- v8.2.2 - 🔧 Fix: `diacritics` composite characters do not match (Thanks 👍 @ikemo3 @Michin0suke @bravik) #169 #171 - v8.2.1 diff --git a/package.json b/package.json index 56fd7737..d9a94f37 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tarekraafat/autocomplete.js", - "version": "8.2.2", + "version": "8.2.3", "description": "Simple autocomplete pure vanilla Javascript library.", "keywords": [ "simple",