Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tarekraafat/autocomplete.js

Package Overview
Dependencies
Maintainers
1
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tarekraafat/autocomplete.js - npm Package Compare versions

Comparing version 3.1.0 to 3.2.0

4

dist/js/autoComplete.js

@@ -41,6 +41,6 @@ (function (global, factory) {

resultsList = document.createElement("ul");
resultsList.setAttribute("id", select.resultsList);
if (renderResults.container) {
renderResults.container(resultsList);
select.resultsList = renderResults.container(resultsList) || select.resultsList;
}
resultsList.setAttribute("id", select.resultsList);
renderResults.destination.insertAdjacentElement(renderResults.position, resultsList);

@@ -47,0 +47,0 @@ };

@@ -1,1 +0,1 @@

var a,b;a=this,b=function(){"use strict";function s(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var a,c="data-result",t="autoComplete_results_list",u="autoComplete_result",n="autoComplete_highlighted",r=function(e){return"string"==typeof e?document.querySelector(e):e()},l=function(){return a.innerHTML=""},h=r,o=function(e){(a=document.createElement("ul")).setAttribute("id",t),e.container&&e.container(a),e.destination.insertAdjacentElement(e.position,a)},f=function(e){return"<span class=".concat(n,">").concat(e,"</span>")},d=function(s,o,r){s.forEach(function(e,t){var n=document.createElement("li"),i=s[t].source[o]||s[t].source;n.setAttribute(c,i),n.setAttribute("class",u),n.setAttribute("tabindex","1"),n.innerHTML=r?r(e,n):e.match||e,a.appendChild(n)})},p=function(e){var n=r(e),i=a.firstChild;document.onkeydown=function(e){var t=document.activeElement;switch(e.keyCode){case 38:t!==i&&t!==n?t.previousSibling.focus():t===i&&n.focus();break;case 40:t===n&&0<a.childNodes.length?i.focus():t!==a.lastChild&&t.nextSibling.focus()}}},v=l,m=function(n,i,s,o){a.querySelectorAll(".".concat(u)).forEach(function(t){["mousedown","keydown"].forEach(function(e){t.addEventListener(e,function(t){"mousedown"!==e&&13!==t.keyCode||(i({event:t,query:r(n).value,results:s.map(function(e){return e.source}),selection:s.find(function(e){return(e.source[o]||e.source)===t.target.closest(".".concat(u)).getAttribute(c)}).source}),l())})})})};return function(){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),this.selector=e.selector||"#autoComplete",this.data={src:function(){return"function"==typeof e.data.src?e.data.src():e.data.src},key:e.data.key},this.searchEngine="loose"===e.searchEngine?"loose":"strict",this.threshold=e.threshold||0,this.resultsList=o({container:e.resultsList.container,destination:e.resultsList.destination?e.resultsList.destination:h(this.selector),position:e.resultsList.position?e.resultsList.position:"afterend"}),this.placeHolder=e.placeHolder,this.maxResults=e.maxResults||5,this.resultItem=e.resultItem,this.highlight=e.highlight||!1,this.onSelection=e.onSelection,this.init()}var e,n,i;return e=t,(n=[{key:"search",value:function(e,t){var n=this.highlight,i=t.toLowerCase();if("loose"===this.searchEngine){e=e.replace(/ /g,"");for(var s=[],o=0,r=0;r<i.length;r++){var a=i[r];o<e.length&&a===e[o]&&(a=n?f(a):a,o++),s.push(a)}return o===e.length&&s.join("")}if(i.includes(e)&&n){var c=h(this.selector).value.toLowerCase();return i.replace(c,f(c))}}},{key:"listMatchedResults",value:function(e){var n=this,i=[],s=h(this.selector).value.toLowerCase();e.filter(function(e){var t=n.search(s,e[n.data.key]||e);t&&i.push({match:t,source:e})});var t=i.slice(0,this.maxResults);return d(t,this.data.key,this.resultItem),p(this.selector),t}},{key:"ignite",value:function(t){var n=this,i=this.selector,s=h(i),e=this.placeHolder,o=this.onSelection;e&&s.setAttribute("placeholder",e),s.onkeyup=function(){v();if(s.value.length>n.threshold&&s.value.replace(/ /g,"").length){var e=n.listMatchedResults(t);o&&m(i,o,e,n.data.key)}}}},{key:"init",value:function(){var t=this,e=this.data.src();e instanceof Promise?e.then(function(e){return t.ignite(e)}):this.ignite(e)}}])&&s(e.prototype,n),i&&s(e,i),t}()},"object"==typeof exports&&"undefined"!=typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):a.autoComplete=b();
var a,b;a=this,b=function(){"use strict";function i(t,e){for(var n=0;n<e.length;n++){var s=e[n];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var a,u="data-result",c={resultsList:"autoComplete_results_list",result:"autoComplete_result",highlight:"autoComplete_highlighted"},r=function(t){return"string"==typeof t?document.querySelector(t):t()},l=function(){return a.innerHTML=""},h=r,o=function(t){a=document.createElement("ul"),t.container&&(c.resultsList=t.container(a)||c.resultsList),a.setAttribute("id",c.resultsList),t.destination.insertAdjacentElement(t.position,a)},f=function(t){return"<span class=".concat(c.highlight,">").concat(t,"</span>")},d=function(i,o,r){i.forEach(function(t,e){var n=document.createElement("li"),s=i[e].source[o]||i[e].source;n.setAttribute(u,s),n.setAttribute("class",c.result),n.setAttribute("tabindex","1"),n.innerHTML=r?r(t,n):t.match||t,a.appendChild(n)})},p=function(t){var n=r(t),s=a.firstChild;document.onkeydown=function(t){var e=document.activeElement;switch(t.keyCode){case 38:e!==s&&e!==n?e.previousSibling.focus():e===s&&n.focus();break;case 40:e===n&&0<a.childNodes.length?s.focus():e!==a.lastChild&&e.nextSibling.focus()}}},g=l,v=function(n,s,i,o){a.querySelectorAll(".".concat(c.result)).forEach(function(e){["mousedown","keydown"].forEach(function(t){e.addEventListener(t,function(e){"mousedown"!==t&&13!==e.keyCode||(s({event:e,query:r(n).value,results:i.map(function(t){return t.source}),selection:i.find(function(t){return(t.source[o]||t.source)===e.target.closest(".".concat(c.result)).getAttribute(u)}).source}),l())})})})};return function(){function e(t){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),this.selector=t.selector||"#autoComplete",this.data={src:function(){return"function"==typeof t.data.src?t.data.src():t.data.src},key:t.data.key},this.searchEngine="loose"===t.searchEngine?"loose":"strict",this.threshold=t.threshold||0,this.resultsList=o({container:t.resultsList.container,destination:t.resultsList.destination?t.resultsList.destination:h(this.selector),position:t.resultsList.position?t.resultsList.position:"afterend"}),this.placeHolder=t.placeHolder,this.maxResults=t.maxResults||5,this.resultItem=t.resultItem,this.highlight=t.highlight||!1,this.onSelection=t.onSelection,this.init()}var t,n,s;return t=e,(n=[{key:"search",value:function(t,e){var n=this.highlight,s=e.toLowerCase();if("loose"===this.searchEngine){t=t.replace(/ /g,"");for(var i=[],o=0,r=0;r<s.length;r++){var a=s[r];o<t.length&&a===t[o]&&(a=n?f(a):a,o++),i.push(a)}return o===t.length&&i.join("")}if(s.includes(t)&&n){var u=h(this.selector).value.toLowerCase();return s.replace(u,f(u))}}},{key:"listMatchedResults",value:function(t){var n=this,s=[],i=h(this.selector).value.toLowerCase();t.filter(function(t){var e=n.search(i,t[n.data.key]||t);e&&s.push({match:e,source:t})});var e=s.slice(0,this.maxResults);return d(e,this.data.key,this.resultItem),p(this.selector),e}},{key:"ignite",value:function(e){var n=this,s=this.selector,i=h(s),t=this.placeHolder,o=this.onSelection;t&&i.setAttribute("placeholder",t),i.onkeyup=function(){g();if(i.value.length>n.threshold&&i.value.replace(/ /g,"").length){var t=n.listMatchedResults(e);o&&v(s,o,t,n.data.key)}}}},{key:"init",value:function(){var e=this,t=this.data.src();t instanceof Promise?t.then(function(t){return e.ignite(t)}):this.ignite(t)}}])&&i(t.prototype,n),s&&i(t,s),e}()},"object"==typeof exports&&"undefined"!=typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):a.autoComplete=b();

@@ -5,3 +5,3 @@ <a href="https://tarekraafat.github.io/autoComplete.js/demo/">

> Simple autocomplete pure vanilla Javascript library. <a href="https://tarekraafat.github.io/autoComplete.js/demo/" target="\_blank">Live Demo</a> **v3.1**
> Simple autocomplete pure vanilla Javascript library. <a href="https://tarekraafat.github.io/autoComplete.js/demo/" target="\_blank">Live Demo</a> **v3.2**

@@ -8,0 +8,0 @@ autoComplete.js is a simple pure vanilla Javascript library that's progressively designed for speed,<br>high versatility and seamless integration with wide range of projects & systems.

@@ -17,3 +17,3 @@ # Introduction

> Simple autocomplete pure vanilla Javascript library. <a href="https://tarekraafat.github.io/autoComplete.js/demo/" target="\_blank">:rocket: Live Demo</a> **v3.1**
> Simple autocomplete pure vanilla Javascript library. <a href="https://tarekraafat.github.io/autoComplete.js/demo/" target="\_blank">:rocket: Live Demo</a> **v3.2**

@@ -71,3 +71,3 @@ autoComplete.js is a simple pure vanilla Javascript library that's progressively designed for speed, high versatility and seamless integration with wide range of projects & systems, made for users and developers in mind.

```html
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/TarekRaafat/autoComplete.js@3.1.0/dist/css/autoComplete.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/TarekRaafat/autoComplete.js@3.2.0/dist/css/autoComplete.min.css">
```

@@ -78,3 +78,3 @@

```html
<script src="https://cdn.jsdelivr.net/gh/TarekRaafat/autoComplete.js@3.1.0/dist/js/autoComplete.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/TarekRaafat/autoComplete.js@3.2.0/dist/js/autoComplete.min.js"></script>
```

@@ -121,3 +121,3 @@

OR
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/TarekRaafat/autoComplete.js@3.1.0/dist/css/autoComplete.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/TarekRaafat/autoComplete.js@3.2.0/dist/css/autoComplete.min.css">
```

@@ -137,3 +137,3 @@

OR
<script src="https://cdn.jsdelivr.net/gh/TarekRaafat/autoComplete.js@3.1.0/dist/js/autoComplete.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/TarekRaafat/autoComplete.js@3.2.0/dist/js/autoComplete.min.js"></script>
<script src="./js/index.js"></script>

@@ -270,4 +270,4 @@ ```

- [x] API for Rendered result item customization
- [x] API for Rendered result list customization
- [ ] Added more use cases & examples to documentation
- [x] API for Rendered results list customization
- [ ] Add more use cases & examples to documentation

@@ -274,0 +274,0 @@ * * *

@@ -29,5 +29,9 @@ ## Versioning

- v3.1.0 :sparkles:
- v3.2.0 :sparkles:
- Added API for rendered results list `resultsList > container` function
- API Enhancements over rendered results list container `resultsList > container` function **(Thanks @albu77)**
- v3.1.0
- Added API for rendered results list container `resultsList > container` function **(Thanks @albu77)**
- API Enhancements

@@ -34,0 +38,0 @@

{
"name": "@tarekraafat/autocomplete.js",
"version": "3.1.0",
"version": "3.2.0",
"description": "Simple autocomplete pure vanilla Javascript library.",

@@ -5,0 +5,0 @@ "main": "dist/js/autoComplete.js",

@@ -22,3 +22,3 @@ # autoComplete.js :sparkles:

> Simple autocomplete pure vanilla Javascript library. <a href="https://tarekraafat.github.io/autoComplete.js/demo/" target="\_blank">:rocket: Live Demo</a> **v3.1**
> Simple autocomplete pure vanilla Javascript library. <a href="https://tarekraafat.github.io/autoComplete.js/demo/" target="\_blank">:rocket: Live Demo</a> **v3.2**

@@ -56,3 +56,3 @@ autoComplete.js is a simple pure vanilla Javascript library that's progressively designed for speed, high versatility and seamless integration with wide range of projects & systems, made for users and developers in mind.

```html
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/TarekRaafat/autoComplete.js@3.1.0/dist/css/autoComplete.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/TarekRaafat/autoComplete.js@3.2.0/dist/css/autoComplete.min.css">
```

@@ -63,3 +63,3 @@

```html
<script src="https://cdn.jsdelivr.net/gh/TarekRaafat/autoComplete.js@3.1.0/dist/js/autoComplete.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/TarekRaafat/autoComplete.js@3.2.0/dist/js/autoComplete.min.js"></script>
```

@@ -66,0 +66,0 @@

@@ -15,6 +15,6 @@ let resultsList;

resultsList = document.createElement("ul");
resultsList.setAttribute("id", select.resultsList);
if (renderResults.container) {
renderResults.container(resultsList);
select.resultsList = renderResults.container(resultsList) || select.resultsList;
}
resultsList.setAttribute("id", select.resultsList);
renderResults.destination.insertAdjacentElement(renderResults.position, resultsList);

@@ -21,0 +21,0 @@ };

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc