diff --git a/README.md b/README.md
index be1eb5b..ff8e6f8 100644
--- a/README.md
+++ b/README.md
@@ -30,6 +30,10 @@ autoComplete.js is a simple, pure vanilla Javascript library progressively desig
- Pure Vanilla Javascript
- Zero Dependencies
- Simple & Lightweight
+- Powerful Search Engine with two different modes
+- Diacritics Support
+- Debounce Support
+- Life Cycle Events
- Useful plugin API
- WAI-ARIA Compliant
- Highly Customizable
@@ -47,13 +51,13 @@ autoComplete.js is a simple, pure vanilla Javascript library progressively desig
`JS`
```html
-
+
```
`CSS`
```html
-
+
```
#### Package Manager
diff --git a/dist/autoComplete.js b/dist/autoComplete.js
index 8d151db..b2ac08a 100644
--- a/dist/autoComplete.js
+++ b/dist/autoComplete.js
@@ -229,11 +229,11 @@
var checkTrigger = function checkTrigger(query, condition, threshold) {
return condition ? condition(query) : query.length >= threshold;
};
- var mark = function mark(value, klass) {
+ var mark = function mark(value, cls) {
return create("mark", _objectSpread2({
innerHTML: value
- }, typeof klass === "string" && {
- "class": klass
+ }, typeof cls === "string" && {
+ "class": cls
})).outerHTML;
};
@@ -349,7 +349,6 @@
eventEmitter("results", ctx);
};
- var classes;
var Expand = "aria-expanded";
var Active = "aria-activedescendant";
var Selected = "aria-selected";
@@ -404,7 +403,10 @@
eventEmitter("close", ctx);
};
var goTo = function goTo(index, ctx) {
- var results = ctx.list.getElementsByTagName(ctx.resultItem.tag);
+ var list = ctx.list,
+ resultItem = ctx.resultItem;
+ var results = list.getElementsByTagName(resultItem.tag);
+ var cls = resultItem.selected ? resultItem.selected.split(" ") : false;
if (ctx.isOpen && results.length) {
var _results$index$classL;
var state = ctx.cursor;
@@ -414,12 +416,12 @@
if (state > -1) {
var _results$state$classL;
results[state].removeAttribute(Selected);
- if (classes) (_results$state$classL = results[state].classList).remove.apply(_results$state$classL, _toConsumableArray(classes));
+ if (cls) (_results$state$classL = results[state].classList).remove.apply(_results$state$classL, _toConsumableArray(cls));
}
results[index].setAttribute(Selected, true);
- if (classes) (_results$index$classL = results[index].classList).add.apply(_results$index$classL, _toConsumableArray(classes));
+ if (cls) (_results$index$classL = results[index].classList).add.apply(_results$index$classL, _toConsumableArray(cls));
ctx.input.setAttribute(Active, results[ctx.cursor].id);
- ctx.list.scrollTop = results[index].offsetTop - ctx.list.clientHeight + results[index].clientHeight + 5;
+ list.scrollTop = results[index].offsetTop - list.clientHeight + results[index].clientHeight + 5;
ctx.feedback.cursor = ctx.cursor;
feedback(ctx, index);
eventEmitter("navigate", ctx);
@@ -446,44 +448,35 @@
var items = Array.from(ctx.list.querySelectorAll(itemTag));
var item = event.target.closest(itemTag);
if (item && item.nodeName === itemTag) {
- event.preventDefault();
var index = items.indexOf(item);
select(ctx, event, index);
}
};
var navigate = function navigate(event, ctx) {
- var key = event.keyCode;
- var selected = ctx.resultItem.selected;
- if (selected) classes = selected.split(" ");
- switch (key) {
+ switch (event.keyCode) {
case 40:
case 38:
event.preventDefault();
- key === 40 ? next(ctx) : previous(ctx);
+ event.keyCode === 40 ? next(ctx) : previous(ctx);
break;
case 13:
- event.preventDefault();
- if (ctx.cursor >= 0) {
- select(ctx, event);
- }
+ if (!ctx.submit) event.preventDefault();
+ if (ctx.cursor >= 0) select(ctx, event);
break;
case 9:
if (ctx.resultsList.tabSelect && ctx.cursor >= 0) {
event.preventDefault();
select(ctx, event);
- } else {
- close(ctx);
}
break;
case 27:
- event.preventDefault();
ctx.input.value = "";
close(ctx);
break;
}
};
- function start (ctx) {
+ function start (ctx, q) {
var _this = this;
return new Promise(function ($return, $error) {
var input, query, trigger, threshold, resultsList, queryVal, condition;
@@ -492,7 +485,7 @@
trigger = ctx.trigger;
threshold = ctx.threshold;
resultsList = ctx.resultsList;
- queryVal = getQuery(input);
+ queryVal = q || getQuery(input);
queryVal = query ? query(queryVal) : queryVal;
condition = checkTrigger(queryVal, trigger, threshold);
if (condition) {
@@ -519,7 +512,7 @@
var eventsManager = function eventsManager(events, callback) {
for (var element in events) {
for (var event in events[element]) {
- callback(event, element);
+ callback(element, event);
}
}
};
@@ -557,17 +550,17 @@
}
}
};
- eventsManager(privateEvents, function (event, element) {
- if (!resultsList && element === "list") return;
+ eventsManager(privateEvents, function (element, event) {
+ if (!resultsList && event !== "input") return;
if (publicEvents[element][event]) return;
publicEvents[element][event] = privateEvents[element][event];
});
- eventsManager(publicEvents, function (event, element) {
+ eventsManager(publicEvents, function (element, event) {
ctx[element].addEventListener(event, publicEvents[element][event]);
});
};
var removeEvents = function removeEvents(ctx) {
- eventsManager(ctx.events, function (event, element) {
+ eventsManager(ctx.events, function (element, event) {
ctx[element].removeEventListener(event, ctx.events[element][event]);
});
};
@@ -628,8 +621,8 @@
prototype.init = function () {
init(this);
};
- prototype.start = function () {
- start(this);
+ prototype.start = function (query) {
+ start(this, query);
};
prototype.unInit = function () {
if (this.wrapper) {
diff --git a/dist/autoComplete.js.gz b/dist/autoComplete.js.gz
index b885ba1..3640c18 100644
Binary files a/dist/autoComplete.js.gz and b/dist/autoComplete.js.gz differ
diff --git a/dist/autoComplete.min.js b/dist/autoComplete.min.js
index ca6a951..cc5edec 100644
--- a/dist/autoComplete.min.js
+++ b/dist/autoComplete.min.js
@@ -1 +1 @@
-var e,t;e=this,t=function(){"use strict";function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function t(t){for(var n=1;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}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 s,a=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){u=!0,s=e},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw s}}}}(n.keys);try{for(f.s();!(l=f.n()).done;)c(l.value)}catch(e){f.e(e)}finally{f.f()}}else c()})),n.filter&&(u=n.filter(u));var c=u.slice(0,s.maxResults);t.feedback={query:e,matches:u,results:c},p("results",t)},v="aria-expanded",y="aria-activedescendant",b="aria-selected",g=function(e,n){e.feedback.selection=t({index:n},e.feedback.results[n])},w=function(e){e.isOpen||((e.wrapper||e.input).setAttribute(v,!0),e.list.removeAttribute("hidden"),e.isOpen=!0,p("open",e))},O=function(e){e.isOpen&&((e.wrapper||e.input).setAttribute(v,!1),e.input.setAttribute(y,""),e.list.setAttribute("hidden",""),e.isOpen=!1,p("close",e))},A=function(e,t){var n=t.list.getElementsByTagName(t.resultItem.tag);if(t.isOpen&&n.length){var r,o,s=t.cursor;e>=n.length&&(e=0),e<0&&(e=n.length-1),t.cursor=e,s>-1&&(n[s].removeAttribute(b),a&&(o=n[s].classList).remove.apply(o,i(a))),n[e].setAttribute(b,!0),a&&(r=n[e].classList).add.apply(r,i(a)),t.input.setAttribute(y,n[t.cursor].id),t.list.scrollTop=n[e].offsetTop-t.list.clientHeight+n[e].clientHeight+5,t.feedback.cursor=t.cursor,g(t,e),p("navigate",t)}},S=function(e){var t=e.cursor+1;A(t,e)},j=function(e){var t=e.cursor-1;A(t,e)},k=function(e,t,n){(n=n>=0?n:e.cursor)<0||(e.feedback.event=t,g(e,n),p("selection",e),O(e))};function L(e){var n=this;return new Promise((function(r,i){var o,s,a,u,l,f,p;return o=e.input,s=e.query,a=e.trigger,u=e.threshold,l=e.resultsList,f=(p=o)instanceof HTMLInputElement||p instanceof HTMLTextAreaElement?p.value:p.innerHTML,function(e,t,n){return t?t(e):e.length>=n}(f=s?s(f):f,a,u)?h(e).then((function(o){try{return e.feedback instanceof Error?r():(m(f,e),l&&function(e){var n=e.resultsList,r=e.list,i=e.resultItem,o=e.feedback;o.query;var s=o.matches,a=o.results;if(e.cursor=-1,r.innerHTML="",s.length||n.noResults){var u=document.createDocumentFragment();a.forEach((function(e,n){var r=c(i.tag,t({id:"".concat(i.id,"_").concat(n),role:"option",innerHTML:e.match,inside:u},i.class&&{class:i.class}));i.element&&i.element(r,e)})),r.append(u),n.element&&n.element(r,o),w(e)}else O(e)}(e),d.call(n))}catch(e){return i(e)}}),i):(O(e),d.call(n));function d(){return r()}}))}var T=function(e,t){for(var n in e)for(var r in e[n])t(r,n)},E=function(e){var n=e.events;e.trigger;var r=e.debounce,i=e.resultsList,o=function(e,t){var n;return function(){clearTimeout(n),n=setTimeout((function(){return e()}),t)}}((function(){return L(e)}),r),s=e.events=t({input:t({},n&&n.input)},i&&{list:n?t({},n.list):{}}),u={input:{input:function(){o()},keydown:function(t){!function(e,t){var n=e.keyCode,r=t.resultItem.selected;switch(r&&(a=r.split(" ")),n){case 40:case 38:e.preventDefault(),40===n?S(t):j(t);break;case 13:e.preventDefault(),t.cursor>=0&&k(t,e);break;case 9:t.resultsList.tabSelect&&t.cursor>=0?(e.preventDefault(),k(t,e)):O(t);break;case 27:e.preventDefault(),t.input.value="",O(t)}}(t,e)},blur:function(){O(e)}},list:{mousedown:function(e){e.preventDefault()},click:function(t){!function(e,t){var n=t.resultItem.tag.toUpperCase(),r=Array.from(t.list.querySelectorAll(n)),i=e.target.closest(n);if(i&&i.nodeName===n){e.preventDefault();var o=r.indexOf(i);k(t,e,o)}}(t,e)}}};T(u,(function(e,t){(i||"list"!==t)&&(s[t][e]||(s[t][e]=u[t][e]))})),T(s,(function(t,n){e[n].addEventListener(t,s[n][t])}))};function x(e){var n=this;return new Promise((function(r,i){var o,s,a,u,l,f;if(o=e.name,s=e.input,a=e.placeHolder,u=e.resultsList,l=e.data,f={role:"combobox","aria-owns":u.id,"aria-haspopup":!0,"aria-expanded":!1},c(s,t(t({"aria-controls":u.id,"aria-autocomplete":"both"},a&&{placeholder:a}),!e.wrapper&&t({},f))),e.wrapper&&(e.wrapper=c("div",t({around:s,class:o+"_wrapper"},f))),u&&(e.list=c(u.tag,t({dest:["string"==typeof u.destination?document.querySelector(u.destination):u.destination(),u.position],id:u.id,role:"listbox",hidden:"hidden"},u.class&&{class:u.class}))),l.cache)return h(e).then((function(e){try{return d.call(n)}catch(e){return i(e)}}),i);function d(){return E(e),p("init",e),r()}return d.call(n)}))}function I(e){var t=e.prototype;t.init=function(){x(this)},t.start=function(){L(this)},t.unInit=function(){if(this.wrapper){var e=this.wrapper.parentNode;e.insertBefore(this.input,this.wrapper),e.removeChild(this.wrapper)}var t;T((t=this).events,(function(e,n){t[n].removeEventListener(e,t.events[n][e])}))},t.open=function(){w(this)},t.close=function(){O(this)},t.goTo=function(e){A(e,this)},t.next=function(){S(this)},t.previous=function(){j(this)},t.select=function(e){k(this,null,e)},e.search=t.search=function(e,t,n){d(e,t,n)}}return function e(t){this.options=t,this.id=e.instances=(e.instances||0)+1,this.name="autoComplete",this.wrapper=1,this.threshold=1,this.debounce=0,this.resultsList={position:"afterend",tag:"ul",maxResults:5},this.resultItem={tag:"li"},function(e){var t=e.id,r=e.name,i=e.options,o=e.resultsList,s=e.resultItem;for(var a in i)if("object"===n(i[a]))for(var u in e[a]||(e[a]={}),i[a])e[a][u]=i[a][u];else e[a]=i[a];e.selector=e.selector||"#"+r,o.destination=o.destination||e.selector,o.id=o.id||r+"_list_"+t,s.id=s.id||r+"_result",e.input="string"==typeof e.selector?document.querySelector(e.selector):e.selector()}(this),I.call(this,e),x(this)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).autoComplete=t();
+var e,t;e=this,t=function(){"use strict";function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function t(t){for(var n=1;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}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 s,a=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){u=!0,s=e},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw s}}}}(n.keys);try{for(f.s();!(l=f.n()).done;)c(l.value)}catch(e){f.e(e)}finally{f.f()}}else c()})),n.filter&&(u=n.filter(u));var c=u.slice(0,s.maxResults);t.feedback={query:e,matches:u,results:c},f("results",t)},m="aria-expanded",v="aria-activedescendant",y="aria-selected",b=function(e,n){e.feedback.selection=t({index:n},e.feedback.results[n])},g=function(e){e.isOpen||((e.wrapper||e.input).setAttribute(m,!0),e.list.removeAttribute("hidden"),e.isOpen=!0,f("open",e))},w=function(e){e.isOpen&&((e.wrapper||e.input).setAttribute(m,!1),e.input.setAttribute(v,""),e.list.setAttribute("hidden",""),e.isOpen=!1,f("close",e))},O=function(e,t){var n=t.list,r=t.resultItem,o=n.getElementsByTagName(r.tag),s=!!r.selected&&r.selected.split(" ");if(t.isOpen&&o.length){var a,u,c=t.cursor;e>=o.length&&(e=0),e<0&&(e=o.length-1),t.cursor=e,c>-1&&(o[c].removeAttribute(y),s&&(u=o[c].classList).remove.apply(u,i(s))),o[e].setAttribute(y,!0),s&&(a=o[e].classList).add.apply(a,i(s)),t.input.setAttribute(v,o[t.cursor].id),n.scrollTop=o[e].offsetTop-n.clientHeight+o[e].clientHeight+5,t.feedback.cursor=t.cursor,b(t,e),f("navigate",t)}},A=function(e){var t=e.cursor+1;O(t,e)},S=function(e){var t=e.cursor-1;O(t,e)},k=function(e,t,n){(n=n>=0?n:e.cursor)<0||(e.feedback.event=t,b(e,n),f("selection",e),w(e))};function j(e,n){var r=this;return new Promise((function(i,o){var s,a,c,l,f,p,m;return s=e.input,a=e.query,c=e.trigger,l=e.threshold,f=e.resultsList,p=n||((m=s)instanceof HTMLInputElement||m instanceof HTMLTextAreaElement?m.value:m.innerHTML),function(e,t,n){return t?t(e):e.length>=n}(p=a?a(p):p,c,l)?d(e).then((function(n){try{return e.feedback instanceof Error?i():(h(p,e),f&&function(e){var n=e.resultsList,r=e.list,i=e.resultItem,o=e.feedback;o.query;var s=o.matches,a=o.results;if(e.cursor=-1,r.innerHTML="",s.length||n.noResults){var c=document.createDocumentFragment();a.forEach((function(e,n){var r=u(i.tag,t({id:"".concat(i.id,"_").concat(n),role:"option",innerHTML:e.match,inside:c},i.class&&{class:i.class}));i.element&&i.element(r,e)})),r.append(c),n.element&&n.element(r,o),g(e)}else w(e)}(e),v.call(r))}catch(e){return o(e)}}),o):(w(e),v.call(r));function v(){return i()}}))}var L=function(e,t){for(var n in e)for(var r in e[n])t(n,r)},T=function(e){var n=e.events;e.trigger;var r=e.debounce,i=e.resultsList,o=function(e,t){var n;return function(){clearTimeout(n),n=setTimeout((function(){return e()}),t)}}((function(){return j(e)}),r),s=e.events=t({input:t({},n&&n.input)},i&&{list:n?t({},n.list):{}}),a={input:{input:function(){o()},keydown:function(t){!function(e,t){switch(e.keyCode){case 40:case 38:e.preventDefault(),40===e.keyCode?A(t):S(t);break;case 13:t.submit||e.preventDefault(),t.cursor>=0&&k(t,e);break;case 9:t.resultsList.tabSelect&&t.cursor>=0&&(e.preventDefault(),k(t,e));break;case 27:t.input.value="",w(t)}}(t,e)},blur:function(){w(e)}},list:{mousedown:function(e){e.preventDefault()},click:function(t){!function(e,t){var n=t.resultItem.tag.toUpperCase(),r=Array.from(t.list.querySelectorAll(n)),i=e.target.closest(n);if(i&&i.nodeName===n){var o=r.indexOf(i);k(t,e,o)}}(t,e)}}};L(a,(function(e,t){(i||"input"===t)&&(s[e][t]||(s[e][t]=a[e][t]))})),L(s,(function(t,n){e[t].addEventListener(n,s[t][n])}))};function E(e){var n=this;return new Promise((function(r,i){var o,s,a,c,l,p;if(o=e.name,s=e.input,a=e.placeHolder,c=e.resultsList,l=e.data,p={role:"combobox","aria-owns":c.id,"aria-haspopup":!0,"aria-expanded":!1},u(s,t(t({"aria-controls":c.id,"aria-autocomplete":"both"},a&&{placeholder:a}),!e.wrapper&&t({},p))),e.wrapper&&(e.wrapper=u("div",t({around:s,class:o+"_wrapper"},p))),c&&(e.list=u(c.tag,t({dest:["string"==typeof c.destination?document.querySelector(c.destination):c.destination(),c.position],id:c.id,role:"listbox",hidden:"hidden"},c.class&&{class:c.class}))),l.cache)return d(e).then((function(e){try{return h.call(n)}catch(e){return i(e)}}),i);function h(){return T(e),f("init",e),r()}return h.call(n)}))}function x(e){var t=e.prototype;t.init=function(){E(this)},t.start=function(e){j(this,e)},t.unInit=function(){if(this.wrapper){var e=this.wrapper.parentNode;e.insertBefore(this.input,this.wrapper),e.removeChild(this.wrapper)}var t;L((t=this).events,(function(e,n){t[e].removeEventListener(n,t.events[e][n])}))},t.open=function(){g(this)},t.close=function(){w(this)},t.goTo=function(e){O(e,this)},t.next=function(){A(this)},t.previous=function(){S(this)},t.select=function(e){k(this,null,e)},e.search=t.search=function(e,t,n){p(e,t,n)}}return function e(t){this.options=t,this.id=e.instances=(e.instances||0)+1,this.name="autoComplete",this.wrapper=1,this.threshold=1,this.debounce=0,this.resultsList={position:"afterend",tag:"ul",maxResults:5},this.resultItem={tag:"li"},function(e){var t=e.id,r=e.name,i=e.options,o=e.resultsList,s=e.resultItem;for(var a in i)if("object"===n(i[a]))for(var u in e[a]||(e[a]={}),i[a])e[a][u]=i[a][u];else e[a]=i[a];e.selector=e.selector||"#"+r,o.destination=o.destination||e.selector,o.id=o.id||r+"_list_"+t,s.id=s.id||r+"_result",e.input="string"==typeof e.selector?document.querySelector(e.selector):e.selector()}(this),x.call(this,e),E(this)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).autoComplete=t();
diff --git a/dist/autoComplete.min.js.gz b/dist/autoComplete.min.js.gz
index 278cd34..0d94ffc 100644
Binary files a/dist/autoComplete.min.js.gz and b/dist/autoComplete.min.js.gz differ
diff --git a/docs/configuration.md b/docs/configuration.md
index 3ab0c90..8983d3c 100644
--- a/docs/configuration.md
+++ b/docs/configuration.md
@@ -10,7 +10,7 @@ API configuration options, methods and events
### name (optional)
-> Global instance name where all elements inherit their class & id names
+> Responsible for the global instance naming where all elements inherit their class & id names
- Type: `String`
- Default: `autoComplete`
@@ -26,9 +26,9 @@ name: "autoComplete",
### selector (optional)
-> Input field selector
+> Responsible for the input, textarea, or contentEditable element selection
-- Type: `String` of [selector](https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Selectors) | `Function`
+- Type: `String` of [selector](https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Selectors) | `Function` returns `Element`
- Default: `#autoComplete`
##### Example
@@ -54,7 +54,7 @@ selector: () => {
### wrapper (optional)
-> Wrapper div container
+> Responsible for rendering the `div` that wraps the `input` and the `list` element
- Type: `Boolean`
- Default: `true`
@@ -69,7 +69,7 @@ wrapper: false,
### data (required)
-> Data Source
+> Responsible for the data source selection
- Type: `Object`
@@ -154,7 +154,7 @@ data: {
### trigger (optional)
-> Event & Condition rules that trigger autoComplete.js engine to start
+> Responsible for Event & Condition rules that trigger autoComplete.js engine to start
- Type: `Function` returns `Boolean`
- Parameters: (`query`)
@@ -172,7 +172,7 @@ trigger: (query) => {
### query (optional)
-> Query interceptor
+> Responsible for Query interception & manipulation
- Type: `Function` returns `String`
- Parameters: (`input`)
@@ -190,7 +190,7 @@ query: (input) => {
### placeHolder (optional)
-> Input field placeholder value
+> Responsible for the input field placeholder value setting
- Type: `String`
- Default: `Blank/Empty`
@@ -205,7 +205,7 @@ placeHolder: "Search...",
### threshold (optional)
-> Minimum characters length for autoComplete.js engine to start
+> Responsible for setting threshold value of the minimum characters length where autoComplete.js engine starts
- Type: `Integer`
- Default: `1`
@@ -220,7 +220,7 @@ threshold: 2,
### debounce (optional)
-> Delay duration after done typing for autoComplete.js engine to start
+> Responsible for setting delay time duration that counts after typing is done for autoComplete.js engine to start
- Type: `Integer`
- Default: `0`
@@ -235,7 +235,7 @@ debounce: 300, // Milliseconds value
### searchEngine (optional)
-> Search engine Type/Mode
+> Responsible for setting the Search engine Type/Mode or custom engine
- Type: `String` | `Function`
- `String` lowerCase `"strict"` | `"loose"`
@@ -252,7 +252,7 @@ searchEngine: "strict",
### diacritics (optional)
-> Search engine diacritics handler
+> Responsible for turning on/off language diacritics supported search
- Type: `Boolean`
- Default: `false`
@@ -267,7 +267,7 @@ diacritics: true,
### resultsList (optional)
-> Rendered results list element interceptor and customizer
+> Responsible for the results list element rendering, interception, and customizing
- Type: `Object` | `Boolean` for disabling list rendering
@@ -331,7 +331,7 @@ resultsList: {
### resultItem (optional)
-> Rendered result item element customizer and interceptor
+> Responsible for the result item element rendering, interception, and customizing
- Type: `Object`
@@ -378,9 +378,24 @@ resultItem: {
***
+### submit (optional)
+
+> Responsible for the `Enter` button default behavior
+
+- Type: `Boolean`
+- Default: `false`
+
+##### Example:
+
+```js
+submit: true,
+```
+
+***
+
### events (optional)
-> Input field & Results list events additions or overriding
+> Responsible for the input field and results list events additions or overriding
- Type: `Object`
- input: `Object` of functions with the [event](https://developer.mozilla.org/en-US/docs/Web/Events) type name
@@ -432,21 +447,27 @@ autoCompleteJS.init();
***
-### start()
+### start(query)
-> Runs `start()` core function which is responsible for the following tasks in order:
+> Runs `start(query)` core function which is responsible for the following tasks in order:
-1. Getting the `input` query value
+1. Getting the `input` query value if NOT passed as an argument
2. Manipulating `query` value
3. Checking `trigger` condition validity to proceed
4. Fetching `data` from `src` or `store` if cached
5. Start matching results
6. Rendering `list` if enabled
+Arguments:
+- query: `String` (optional)
+
+Defaults:
+- query: `input` query value
+
##### Example:
```js
-autoCompleteJS.start();
+autoCompleteJS.start("tea");
```
***
@@ -455,10 +476,10 @@ autoCompleteJS.start();
> autoComplete.js powerful search engine
-Parameters:
+Arguments:
- query: `String`
- record: `String`
-- options: `Object`
+- options: `Object` (optional)
- mode: `String`
- `"strict"` search mode
- `"loose"` search mode
@@ -523,7 +544,7 @@ autoCompleteJS.previous();
> Navigates to a specific `resultItem` on the list by its `index` number
-Parameters:
+Arguments:
- index: `Number`
Defaults:
@@ -542,8 +563,8 @@ autoCompleteJS.gotTo(1);
> Selects a `resultItem` from the list by its `index` number
-Parameters:
-- index: `Number`
+Arguments:
+- index: `Number` (optional)
Defaults:
- index: current cursor position
@@ -570,7 +591,7 @@ autoCompleteJS.close();
### unInit()
-> Removes all the event listeners on the `_events` list
+> Removes all the event listeners on the `events` list
##### Example:
diff --git a/docs/demo/index.html b/docs/demo/index.html
index d5d5f7b..c6e74dc 100644
--- a/docs/demo/index.html
+++ b/docs/demo/index.html
@@ -72,7 +72,7 @@
+ href="https://cdn.jsdelivr.net/npm/@tarekraafat/autocomplete.js@10.2.0/dist/css/autoComplete.min.css">
@@ -150,7 +150,7 @@ mode
-
+