diff --git a/.vscode/settings.json b/.vscode/settings.json
index 897800ae..755bf1a2 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -4,6 +4,7 @@
"Tarek",
"activedescendant",
"afterend",
+ "ascendingly",
"autocapitalize",
"autocorrect",
"combobox",
diff --git a/dist/js/autoComplete.js b/dist/js/autoComplete.js
index 24eb4c88..5a34db5d 100644
--- a/dist/js/autoComplete.js
+++ b/dist/js/autoComplete.js
@@ -160,7 +160,6 @@
var createList = (function (config) {
var list = document.createElement(config.resultsList.element);
list.setAttribute("id", config.resultsList.idName);
- list.setAttribute("aria-label", config.name);
list.setAttribute("class", config.resultsList.className);
list.setAttribute("role", "listbox");
list.setAttribute("tabindex", "-1");
@@ -188,9 +187,9 @@
}));
});
- var closeList = function closeList(config) {
+ var closeList = function closeList(config, element) {
var list = document.getElementById(config.resultsList.idName);
- if (list) {
+ if (list && element !== config.inputField) {
list.remove();
config.inputField.removeAttribute("aria-activedescendant");
config.inputField.setAttribute("aria-expanded", false);
@@ -228,14 +227,18 @@
_loop(index);
}
} else {
- config.noResults(list, data.query);
+ if (!config.resultsList.noResults) {
+ list.remove();
+ } else {
+ config.resultsList.noResults(list, data.query);
+ }
}
};
var keyboardEvent = "keydown";
var navigate = function navigate(config, dataFeedback) {
var currentFocus = -1;
- var update = function update(event, list, state, config) {
+ var update = function update(event, list, state) {
event.preventDefault();
if (state) {
currentFocus++;
@@ -253,7 +256,7 @@
var removeActive = function removeActive(list) {
for (var index = 0; index < list.length; index++) {
list[index].removeAttribute("aria-selected");
- if (config.selection.className) list[index].classList.remove(config.selection.className);
+ if (config.resultItem.selected.className) list[index].classList.remove(config.resultItem.selected.className);
}
};
var addActive = function addActive(list) {
@@ -262,7 +265,7 @@
if (currentFocus >= list.length) currentFocus = 0;
if (currentFocus < 0) currentFocus = list.length - 1;
list[currentFocus].setAttribute("aria-selected", "true");
- if (config.selection.className) list[currentFocus].classList.add(config.selection.className);
+ if (config.resultItem.selected.className) list[currentFocus].classList.add(config.resultItem.selected.className);
};
var navigation = function navigation(event) {
var list = document.getElementById(config.resultsList.idName);
@@ -270,19 +273,25 @@
config.inputField.removeEventListener(keyboardEvent, navigate);
} else {
list = list.getElementsByTagName(config.resultItem.element);
- if (event.keyCode === 27) {
- config.inputField.value = "";
- closeList(config);
- } else if (event.keyCode === 40 || event.keyCode === 9) {
- update(event, list, true, config);
- } else if (event.keyCode === 38 || event.keyCode === 9) {
- update(event, list, false, config);
- } else if (event.keyCode === 13) {
- event.preventDefault();
- if (currentFocus > -1) {
- list[currentFocus].click();
+ switch (event.keyCode) {
+ case 27:
+ config.inputField.value = "";
closeList(config);
- }
+ break;
+ case 9:
+ case 40:
+ update(event, list, true);
+ break;
+ case 38:
+ update(event, list, false);
+ break;
+ case 13:
+ event.preventDefault();
+ if (currentFocus > -1) {
+ list[currentFocus].click();
+ closeList(config);
+ }
+ break;
}
}
};
@@ -301,7 +310,7 @@
for (var number = 0; number < recordLowerCase.length; number++) {
var recordChar = record[number];
if (searchPosition < query.length && recordLowerCase[number] === query[searchPosition]) {
- recordChar = config.highlight.render ? "").concat(recordChar, "") : recordChar;
+ recordChar = config.resultItem.highlight.render ? "").concat(recordChar, "") : recordChar;
searchPosition++;
}
match.push(recordChar);
@@ -313,7 +322,7 @@
if (recordLowerCase.includes(query)) {
var pattern = new RegExp(query.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&"), "i");
query = pattern.exec(record);
- var _match = config.highlight.render ? record.replace(query, "").concat(query, "")) : record;
+ var _match = config.resultItem.highlight.render ? record.replace(query, "").concat(query, "")) : record;
return _match;
}
}
@@ -372,8 +381,7 @@
for (var index = 0; index < config.data.store.length; index++) {
_loop(index);
}
- var list = config.sort ? resList.sort(config.sort) : resList;
- return list;
+ return resList;
};
var debouncer = (function (callback, delay) {
@@ -391,10 +399,9 @@
var autoComplete = function () {
function autoComplete(config) {
_classCallCheck(this, autoComplete);
- var _config$name = config.name,
- name = _config$name === void 0 ? "Search" : _config$name,
- _config$selector = config.selector,
+ var _config$selector = config.selector,
selector = _config$selector === void 0 ? "#autoComplete" : _config$selector,
+ placeHolder = config.placeHolder,
_config$observer = config.observer,
observer = _config$observer === void 0 ? false : _config$observer,
_config$data = config.data,
@@ -411,14 +418,15 @@
event = _config$trigger$event === void 0 ? ["input"] : _config$trigger$event,
_config$trigger$condi = _config$trigger.condition,
condition = _config$trigger$condi === void 0 ? false : _config$trigger$condi,
- _config$searchEngine = config.searchEngine,
- searchEngine = _config$searchEngine === void 0 ? "strict" : _config$searchEngine,
- _config$diacritics = config.diacritics,
- diacritics = _config$diacritics === void 0 ? false : _config$diacritics,
_config$threshold = config.threshold,
threshold = _config$threshold === void 0 ? 1 : _config$threshold,
_config$debounce = config.debounce,
debounce = _config$debounce === void 0 ? 0 : _config$debounce,
+ _config$diacritics = config.diacritics,
+ diacritics = _config$diacritics === void 0 ? false : _config$diacritics,
+ _config$searchEngine = config.searchEngine,
+ searchEngine = _config$searchEngine === void 0 ? "strict" : _config$searchEngine,
+ feedback = config.feedback,
_config$resultsList = config.resultsList;
_config$resultsList = _config$resultsList === void 0 ? {} : _config$resultsList;
var _config$resultsList$r = _config$resultsList.render,
@@ -434,39 +442,34 @@
resultsListId = _config$resultsList$i === void 0 ? "autoComplete_list" : _config$resultsList$i,
_config$resultsList$c2 = _config$resultsList.className,
resultsListClass = _config$resultsList$c2 === void 0 ? "autoComplete_list" : _config$resultsList$c2,
+ _config$resultsList$m = _config$resultsList.maxResults,
+ maxResults = _config$resultsList$m === void 0 ? 5 : _config$resultsList$m,
_config$resultsList$n = _config$resultsList.navigation,
navigation = _config$resultsList$n === void 0 ? false : _config$resultsList$n,
- _config$sort = config.sort,
- sort = _config$sort === void 0 ? false : _config$sort,
- placeHolder = config.placeHolder,
- _config$maxResults = config.maxResults,
- maxResults = _config$maxResults === void 0 ? 5 : _config$maxResults,
+ noResults = _config$resultsList.noResults,
_config$resultItem = config.resultItem;
_config$resultItem = _config$resultItem === void 0 ? {} : _config$resultItem;
var _config$resultItem$co = _config$resultItem.content,
content = _config$resultItem$co === void 0 ? false : _config$resultItem$co,
_config$resultItem$el = _config$resultItem.element,
resultItemElement = _config$resultItem$el === void 0 ? "li" : _config$resultItem$el,
- _config$resultItem$id = _config$resultItem.idName,
- resultItemId = _config$resultItem$id === void 0 ? "autoComplete_result" : _config$resultItem$id,
+ resultItemId = _config$resultItem.idName,
_config$resultItem$cl = _config$resultItem.className,
resultItemClass = _config$resultItem$cl === void 0 ? "autoComplete_result" : _config$resultItem$cl,
- noResults = config.noResults,
- _config$selection = config.selection;
- _config$selection = _config$selection === void 0 ? {} : _config$selection;
- var _config$selection$cla = _config$selection.className,
- selectionClass = _config$selection$cla === void 0 ? "autoComplete_selected" : _config$selection$cla,
- _config$highlight = config.highlight;
- _config$highlight = _config$highlight === void 0 ? {} : _config$highlight;
- var _config$highlight$ren = _config$highlight.render,
- highlightRender = _config$highlight$ren === void 0 ? false : _config$highlight$ren,
- _config$highlight$cla = _config$highlight.className,
- highlightClass = _config$highlight$cla === void 0 ? "autoComplete_highlighted" : _config$highlight$cla,
- feedback = config.feedback,
+ _config$resultItem$hi = _config$resultItem.highlight;
+ _config$resultItem$hi = _config$resultItem$hi === void 0 ? {} : _config$resultItem$hi;
+ var _config$resultItem$hi2 = _config$resultItem$hi.render,
+ highlightRender = _config$resultItem$hi2 === void 0 ? false : _config$resultItem$hi2,
+ _config$resultItem$hi3 = _config$resultItem$hi.className,
+ highlightClass = _config$resultItem$hi3 === void 0 ? "autoComplete_highlighted" : _config$resultItem$hi3,
+ _config$resultItem$se = _config$resultItem.selected;
+ _config$resultItem$se = _config$resultItem$se === void 0 ? {} : _config$resultItem$se;
+ var _config$resultItem$se2 = _config$resultItem$se.className,
+ selectedClass = _config$resultItem$se2 === void 0 ? "autoComplete_selected" : _config$resultItem$se2,
onSelection = config.onSelection;
- this.name = name;
this.selector = selector;
this.observer = observer;
+ this.placeHolder = placeHolder;
this.data = {
src: src,
key: key,
@@ -479,10 +482,11 @@
event: event,
condition: condition
};
- this.searchEngine = searchEngine;
- this.diacritics = diacritics;
this.threshold = threshold;
this.debounce = debounce;
+ this.diacritics = diacritics;
+ this.searchEngine = searchEngine;
+ this.feedback = feedback;
this.resultsList = {
render: resultsListRender,
container: container,
@@ -491,26 +495,23 @@
element: resultsListElement,
idName: resultsListId,
className: resultsListClass,
- navigation: navigation
+ maxResults: maxResults,
+ navigation: navigation,
+ noResults: noResults
};
- this.sort = sort;
- this.placeHolder = placeHolder;
- this.maxResults = maxResults;
this.resultItem = {
content: content,
element: resultItemElement,
idName: resultItemId,
- className: resultItemClass
- };
- this.noResults = noResults;
- this.selection = {
- className: selectionClass
- };
- this.highlight = {
- render: highlightRender,
- className: highlightClass
+ className: resultItemClass,
+ highlight: {
+ render: highlightRender,
+ className: highlightClass
+ },
+ selected: {
+ className: selectedClass
+ }
};
- this.feedback = feedback;
this.onSelection = onSelection;
this.inputField = typeof this.selector === "string" ? document.querySelector(this.selector) : this.selector();
this.observer ? this.preInit() : this.init();
@@ -524,7 +525,7 @@
input: input,
query: query,
matches: results,
- results: results.slice(0, this.maxResults)
+ results: results.slice(0, this.resultsList.maxResults)
};
eventEmitter(this.inputField, dataFeedback, "results");
if (!this.resultsList.render) return this.feedback(dataFeedback);
@@ -532,7 +533,7 @@
navigate(this, dataFeedback);
eventEmitter(this.inputField, dataFeedback, "open");
document.addEventListener("click", function (event) {
- return closeList(_this);
+ return closeList(_this, event.target);
});
}
}, {
diff --git a/dist/js/autoComplete.js.gz b/dist/js/autoComplete.js.gz
index 2ab799ba..1cf412c2 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 ba64dce3..93c322fa 100644
--- a/dist/js/autoComplete.min.js
+++ b/dist/js/autoComplete.min.js
@@ -1 +1 @@
-var e,t;e=this,t=function(){"use strict";function e(e,t){for(var n=0;n
-
-
-autoComplete.js
-
-> Simple autocomplete pure vanilla Javascript library. :rocket: Live Demo **v9.0**
-
-autoComplete.js is a simple pure vanilla Javascript library that's progressively designed for speed, high versatility and seamless integration with a wide range of projects & systems, made for users and developers in mind.
-
-## Features
-
-- Pure Vanilla Javascript
-- Zero Dependencies
-- Simple & Easy to use
-- Extremely Lightweight
-- Blazing Fast
-- Versatile
-- Hackable & highly customizable
-
-[![autoComplete.js Code Example](./img/autoComplete.init.png "autoComplete.js Code Example")](https://codepen.io/tarekraafat/pen/rQopdW?editors=0010)
-
-## 1. Get Started
-
-### Clone:
-
-- Clone autoComplete.js to your local machine
-
-```shell
-git clone https://github.com/TarekRaafat/autoComplete.js.git
-```
-
-### Setup:
-
-1. Install Dependencies
-
-```shell
-npm i
-```
-
-2. For Development
-
-```shell
-npm run dev
-```
-
-3. Build Production Package
-
-```shell
-npm run build
-```
-
-### Installation:
-
-- CDN
-
-`CSS`
-
-```html
-
-```
-
-`JS`
-
-```html
-
-```
-
-- CDN
-
-`CSS`
-
-```html
-
-```
-
-`JS`
-
-```html
-
-```
-
-- CDN
-
-`CSS`
-
-```html
-
-```
-
-`JS`
-
-```html
-
-```
-
-- HTML Local load
-
-```html
-
-```
-
-- HTML Local load - ES6 module `(Use with Import)`
-
-```html
-
-```
-
-- Import module ES6
-
-```js
-import autoComplete from "./autoComplete";
-```
-
-- install `(Node Package Manager)`
-
-```shell
-npm i @tarekraafat/autocomplete.js
-```
-
-- install `(Javascript Package Manager)`
-
-```shell
-yarn add @tarekraafat/autocomplete.js
-```
-
-- Node.js
-
-```js
-const autoComplete = require("@tarekraafat/autocomplete.js/dist/js/autoComplete");
-```
-
-### How to use:
-
-> HTML file
-
-1. Place the `CSS` stylesheet inside the `HEAD` tag
-
-```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`
-
-```html
-
-```
-
-3. Place autoComplete `JS` file & the custom `JS` file at the bottom `BODY` tag
-
-```html
-
-
-OR
-
-
-```
-
-> Custom JS file
-
-4. Create new instance of autoComplete engine and configure it `NOT all API configurations are required`
-
-```js
-new autoComplete({
- data: { // Data src [Array, Function, Async] | (REQUIRED)
- src: async () => {
- // API key token
- const token = "this_is_the_API_token_number";
- // User search query
- const query = document.querySelector("#autoComplete").value;
- // Fetch External Data Source
- const source = await fetch(`https://www.food2fork.com/api/search?key=${token}&q=${query}`);
- // Format data into JSON
- const data = await source.json();
- // Return Fetched data
- return data.recipes;
- },
- key: ["title"],
- cache: false
- },
- query: { // Query Interceptor | (Optional)
- manipulate: (query) => {
- return query.replace("pizza", "burger");
- }
- },
- sort: (a, b) => { // Sort rendered results ascendingly | (Optional)
- if (a.match < b.match) return -1;
- if (a.match > b.match) return 1;
- return 0;
- },
- placeHolder: "Food & Drinks...", // Place Holder text | (Optional)
- selector: "#autoComplete", // Input field selector | (Optional)
- observer: true, // Input field observer | (Optional)
- threshold: 3, // Min. Chars length to start Engine | (Optional)
- debounce: 300, // Post duration for engine to start | (Optional)
- searchEngine: "strict", // Search Engine type/mode | (Optional)
- resultsList: { // Rendered results list object | (Optional)
- container: source => {
- source.setAttribute("id", "food_list");
- },
- destination: "#autoComplete",
- position: "afterend",
- element: "ul"
- },
- maxResults: 5, // Max. number of rendered results | (Optional)
- highlight: {
- render: true, // Highlight matching results | (Optional)
- }
- resultItem: { // Rendered result item | (Optional)
- content: (data, source) => {
- source.innerHTML = data.match;
- },
- element: "li"
- },
- noResults: (dataFeedback, generateList) => {
- // Generate autoComplete List
- generateList(autoCompleteJS, dataFeedback, dataFeedback.results);
- // No Results List Item
- const result = document.createElement("li");
- result.setAttribute("class", "no_result");
- result.setAttribute("tabindex", "1");
- result.innerHTML = `Found No Results for "${dataFeedback.query}"`;
- document.querySelector(`#${autoCompleteJS.resultsList.idName}`).appendChild(result);
- },
- onSelection: feedback => { // Action script onSelection event | (Optional)
- console.log(feedback.selection.value.image_url);
- }
-});
-```
-
-### API Configuration:
-
-
-
-| Keys | Description | Values | Default |
-| -------------- | ------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `data` | Data Source, Data Key, Data Caching & Data Results | `Object` with 4 methods
**1- src**:
- `Array` of `Strings` / `Objects`
**OR**
- `Function` ( ) => `Array` of `Strings` / `Objects`
**2- key**:
- `Array` of `Strings`
**Required** if `src` is `Object`, for search to point to desired `keys`
**3- Cache**:
- `true` for static data `src`
- `false` for dynamic data `src` "API" with queries
**4- Results**:
- `Function` (resultsList) => `Array` of `Strings` / `Objects` | Data `src` |
-| `trigger` | Engine event & condition trigger | `Object` with 2 methods
**1- event**:
- `Array` of event name `Strings`
**2- condition**:
- `Boolean`
**OR**
- `Function` (even, query) => `Boolean` | 1- event: `["input"]`
2- condition:
`Function` => (query.length > this.threshold && query !== " ")` |
-| `query` | Query Interceptor | `Object` with 1 method
1- manipulate: `Function` (inputValue) => `String` | `Raw` Input Value |
-| `sort` | Sort rendered results | **-** `Function` (firstResult, secondResult) => { ... } | `false` **(Random Results)** |
-| `placeHolder` | Place Holder text | **-** `String` | Blank / Empty |
-| `selector` | Input field selector | **-** `String` `id`/`class`
**OR**
**-** `Function` ( ) => `document.querySelector("")` | `"#autoComplete"` |
-| `observer` | Input field observer | **-** `Boolean` | `false` |
-| `threshold` | Minimum characters length before engine starts rendering results | **-** `Number` | `1` |
-| `debounce` | Minimum duration after typing idle state for engine to kick in | **-** `Number`
In milliseconds value | `0` |
-| `searchEngine` | Search Engine Type/Mode | **-** `"strict"` lowerCase string
**OR**
**-** `"loose"` lowerCase string
**OR**
**-** customEngine `Function` (query, record) => `each match individually` | `"strict"` |
-| `diacritics` | Search Engine Diacritics handler | **-** `Boolean` | `false` |
-| `resultsList` | Rendered results list destination, position, element & navigation | `Object` with 8 methods
1- render: `Boolean`
2- container:
`Function` (source) => { ... }
3- destination:
**-** `String` `(id/class/tag)` value
**OR**
**-** `Function` ( ) => `document.querySelector("")`
4- position:
`"beforebegin"`, `"afterbegin"`, `"beforeend"`, `"afterend"` lowerCase string
5- element:
- `String` tag `(ul/span/div/etc..)` value
6- idName: `String`
7- className: `String`
8- navigation: `Function` (event, input, resListElement, onSelection, resListData) => { ... } | 1- render: `true`
2- container: (source) => { ... }
3- destination: `"#autoComplete"`
4- position: `"afterend"`
5- element: `"ul"`
6- idName: `"autoComplete_list"`
7- className: `"autoComplete_list"`
8- navigation: `default` |
-| `resultItem` | Rendered result Item content & element | `Object` with 4 methods
1- content:
**-** `Function` (data, source) => { ... }
**-** `data.match` has to be used for **Highlighted** result
2- element:
- `String` tag `(li/span/div/etc..)`
3- idName: `String`
4- className: `String` | 1- content: `(data, source)` => { ... }
2- element: `"li"`
3- idName: `"autoComplete_result"`
4- className: `"autoComplete_result"` |
-| `noResults` | Action script on noResults found | **-** `Function` (list, query) => { ... } | No Action |
-| `selection` | Format selected result item | `Object` with 1 method
1- className: `String` | 1- className: `autoComplete_selected` |
-| `highlight` | Highlight matching results | `Object` with 2 methods
1- render: `Boolean`
2- className: `String` | 1- render: `false`
2- className: `autoComplete_highlighted` |
-| `maxResults` | Maximum number of displayed results | **-** `Number` (Integer) | `5` |
-| `feedback` | Action script on dataFeedback event | **-** `Function` (data) => { ... } | No Action |
-| `onSelection` | Action script onSelection event | **-** `Function` (feedback) => { ... } | No Action |
-
-1. That's it, you're ready to go!
-
-* * *
-
-### Life Cycle Events:
-
-1. `init`: Fires after "autoComplete.js" engine is initialized
-2. `fetch`: Fires after fetching data is complete
-3. `input`: Fires on every user input
-4. `results`: Fires after search is done and matching results are ready
-5. `open`: Fires after opening the results list
-6. `navigate`: Fires on every "resultsList" navigation interaction
-7. `close`: Fires on "resultsList" close
-8. `unInit`: Fires after "autoComplete.js" engine is un-initialized
-
-* * *
-
-## 2. Examples
-
-- Live working [Demo]
-
-
-- Try it on [](https://codepen.io/tarekraafat/pen/rQopdW?editors=0010)
-
-[demo]: https://tarekraafat.github.io/autoComplete.js/demo/
-
-- Download [Demo] files locally from `/dist` folder
-
-* * *
-
-## 3. Third-Party Plugins
-
-- [Contao autoComplete.js Bundle](https://github.com/heimrichhannot/contao-autocompletejs-bundle) by [@heimrichhannot](https://github.com/heimrichhannot)
-
-* * *
-
-## 4. Support
-
-For general questions about autoComplete.js, tweet at [@TarekRaafat].
-
-For technical questions, you should post a question on [Stack Overflow] and tag
-it with [autoComplete.js][so tag].
-
-
-
-[stack overflow]: https://stackoverflow.com/
-
-[@tarekraafat]: https://twitter.com/TarekRaafat
-
-[so tag]: https://stackoverflow.com/questions/tagged/autoComplete.js
-
-* * *
-
-## 5. Browsers Support
-
-| [](http://godban.github.io/browsers-support-badges/)IE / Edge | [](http://godban.github.io/browsers-support-badges/)Firefox | [](http://godban.github.io/browsers-support-badges/)Chrome | [](http://godban.github.io/browsers-support-badges/)Safari | [](http://godban.github.io/browsers-support-badges/)iOS Safari | [](http://godban.github.io/browsers-support-badges/)Samsung | [](http://godban.github.io/browsers-support-badges/)Opera | [](http://godban.github.io/browsers-support-badges/)Opera Mini | [](http://godban.github.io/browsers-support-badges/)Electron |
-| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| Edge | last version | last version | last version | last version | last version | last version | last version | last version |
-
-* * *
-
-## 6. What's New in v9.0?
-
-Check out Releases Information :sparkles:
-
-* * *
-
-## 7. Roadmap
-
-### Functionality:
-
-- [x] Add support for different types of data source
- - [x] Function
- - [x] JSON
- - [x] Array of Object
- - [x] External data source via Promises & Async/Await function
-- [x] Multi-keyword Search
-- [x] Different types/modes of Search Logic
-- [x] Choose different results render destination & position
-- [x] Sort rendered results
-- [x] Results list Keyboard `ARROW` or `TAB` Navigation
-- [x] Enhance error Handling (Ongoing)
-- [x] Number of matching results
-- [x] Fetching dynamically External API data source
-- [x] Multiple searchable `keys` for data `src`
-- [x] Event emitter on input field events
-- [x] Handling large data sets
-- [x] Event emitter fires on cleared empty input field state
-- [x] `Query` Interception & Manipulation
-- [x] Improve `Promise` usage for external data source handling
-- [x] Add support for `Diacritics`
-- [x] Input field Observer
-- [ ] Automatic deep search over all keys in multiple nested object data source
-
-### Usability:
-
-- [x] Avail Gzip files options
-- [x] Comprehensive data feedback on user selection
-- [x] Dynamic input field selector
-- [x] Minimum characters length before results start getting rendered for more focused results
-- [x] No matches found response & text
-- [x] API for Rendered result item customization
-- [x] API for Rendered results list customization
-- [x] Capability for multiple instances
-- [x] Render `results` in default case
-- [x] Render `resultsList` & `resultItem` in different/custom elements
-- [x] HTML elements `ContentEditable` Input Support
-- [x] Serve results without rendering list through `resultsList.render` API
-- [x] Custom Search Engine Capability
-- [x] `ShadowDom` Support
-- [x] API support for `customNavigation`
-- [x] API support for `customEventTriggers` & `customTriggerConditions`
-- [x] Better `resultsList` navigation [Without loosing cursor]
-- [x] Add event emitters for navigation
-- [x] Life Cycle Events
-- [ ] Add more use examples & cases of the library to the documentation
-- [ ] Better code compression / optimization for the library to squeeze it back under `[5kb]`
-
-### Plugins:
-
-- [ ] Recent / Most Searches
-- [ ] Inline Suggestions
-- [ ] Input Tags
-- [ ] Virtual Scrolling
-- [ ] Results List Category Separator
-- [ ] `IndexedDB` for large data sets handling & offline usage
-- [ ] Themes / Styles & Interactions
-
-### Styles:
-
-- [x] autoComplete.js default style
-- [x] Neutral style [01]
-- [x] Light style [02]
-
-### Reported Issues:
-
-- [ ] Duplicated results when using multiple data source `keys`
-
-* * *
-
-## 8. Contribution
-
-> Contributions are always more than welcome!
-
-If you have any ideas, just [open an issue](https://github.com/TarekRaafat/autoComplete.js/issues) and tell me what you think.
-
-- Please fork the repository and make changes as you'd like.
- Pull requests are warmly welcome.
-
-> If you'd like to contribute:
-
-1. Fork it (
high versatility and seamless integration with a wide range of projects & systems.
-
-
-
-
-
-
-
-
-
-
-
-[GitHub](https://github.com/TarekRaafat/autoComplete.js)
-[Get Started](#introduction)
-
-![color](#fff)
diff --git a/docs/_sidebar.md b/docs/_sidebar.md
new file mode 100644
index 00000000..6128a73f
--- /dev/null
+++ b/docs/_sidebar.md
@@ -0,0 +1,17 @@
+- [ Introduction](/ "autoComplete.js - Vanilla Javascript library")
+- [mode
-
+
diff --git a/docs/demo/js/index.js b/docs/demo/js/index.js index 29d39859..7f4e5892 100644 --- a/docs/demo/js/index.js +++ b/docs/demo/js/index.js @@ -1,6 +1,5 @@ // The autoComplete.js Engine instance creator const autoCompleteJS = new autoComplete({ - name: "food & drinks", data: { src: async function () { // Loading placeholder text @@ -31,7 +30,16 @@ const autoCompleteJS = new autoComplete({ highlight: { render: true, }, - maxResults: 5, + resultsList: { + noResults: (list, query) => { + // No Results List Message + const message = document.createElement("li"); + message.setAttribute("class", "no_result"); + message.setAttribute("tabindex", "1"); + message.innerHTML = `Found No Results for "${query}"`; + list.appendChild(message); + }, + }, resultItem: { content: (data, element) => { // Modify Results Item Style @@ -46,16 +54,6 @@ const autoCompleteJS = new autoComplete({ `; }, }, - noResults: (dataFeedback, generateList) => { - // Generate autoComplete List - generateList(autoCompleteJS, dataFeedback, dataFeedback.results); - // No Results List Item - const result = document.createElement("li"); - result.setAttribute("class", "no_result"); - result.setAttribute("tabindex", "1"); - result.innerHTML = `Found No Results for "${dataFeedback.query}"`; - document.querySelector(`#${autoCompleteJS.resultsList.idName}`).appendChild(result); - }, onSelection: (feedback) => { document.querySelector("#autoComplete").blur(); // Prepare User's Selected Value diff --git a/docs/getting-started.md b/docs/getting-started.md new file mode 100644 index 00000000..802008f3 --- /dev/null +++ b/docs/getting-started.md @@ -0,0 +1,9 @@ +# Getting Started + +This quick start is intended for beginner to advanced developers + +## Quick Start + +*** + +It's very easy to get started with `autoComplete.js`. All that's required is the script included in your page along with a single `` filed tag to render the chart. \ No newline at end of file diff --git a/docs/index.html b/docs/index.html index 20888e4c..7586d29e 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1,75 +1,205 @@ -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -