From 16557153b60fa2e7b91e9f7e0492f7047fef12db Mon Sep 17 00:00:00 2001 From: Grzegorz Tomicki Date: Sun, 24 Mar 2024 22:52:19 +0100 Subject: [PATCH 1/4] refactor: export function, create ariaAcri --- sources/js/script.js | 17 ++++---- sources/js/utils/function.js | 75 ++++++++++++++++++++---------------- 2 files changed, 52 insertions(+), 40 deletions(-) diff --git a/sources/js/script.js b/sources/js/script.js index 6a0098b..996cbce 100644 --- a/sources/js/script.js +++ b/sources/js/script.js @@ -14,6 +14,7 @@ import { setAriaActivedescendant, setAttributes, showBtnToClearData, + ariaActiveDescendantDefault, } from "./utils/function"; import keyCodes from "./utils/keyCodes"; @@ -134,6 +135,11 @@ export default class Autocomplete { _initial = () => { this._clearbutton(); + const ariaAcrivedescentDefault = ariaActiveDescendantDefault( + this._outputUl, + ); + setAttributes(this._root, ariaAcrivedescentDefault); + output( this._root, this._resultList, @@ -224,13 +230,9 @@ export default class Autocomplete { // remove class isActive classList(this._resultWrap, "remove", this._isActive); - const ariaAcrivedescentDefault = { - "aria-owns": `${this._id}-list`, - "aria-expanded": "false", - "aria-autocomplete": "list", - role: "combobox", - removeClass: "auto-expanded", - }; + const ariaAcrivedescentDefault = ariaActiveDescendantDefault( + this._outputUl, + ); const ariaAcrivedescent = this._preventScrollUp ? ariaAcrivedescentDefault @@ -769,6 +771,7 @@ export default class Autocomplete { /** * Rerender rows without remove root input and close elements + * @param {String} inputValue */ rerender = (inputValue) => { const text = inputValue?.trim() ? inputValue.trim() : this._root.value; diff --git a/sources/js/utils/function.js b/sources/js/utils/function.js index ed0f196..ae833d1 100644 --- a/sources/js/utils/function.js +++ b/sources/js/utils/function.js @@ -3,7 +3,7 @@ * @param {Object} value * @returns {Boolean} */ -const isObject = (value) => +export const isObject = (value) => value && typeof value === "object" && value.constructor === Object; /** @@ -13,7 +13,8 @@ const isObject = (value) => * @param {Object} value * @returns {Boolean} */ -const isPromise = (value) => Boolean(value && typeof value.then === "function"); +export const isPromise = (value) => + Boolean(value && typeof value.then === "function"); /** * Set attributes to element @@ -21,7 +22,7 @@ const isPromise = (value) => Boolean(value && typeof value.then === "function"); * @param {HTMLElement} el * @param {Object} object */ -const setAttributes = (el, object) => { +export const setAttributes = (el, object) => { for (let key in object) { if (key === "addClass") { classList(el, "add", object[key]); @@ -39,7 +40,7 @@ const setAttributes = (el, object) => { * @param {HTMLElement} element * @returns {HTMLELement} */ -const getFirstElement = (element) => +export const getFirstElement = (element) => (element.firstElementChild || element).textContent.trim(); /** @@ -47,7 +48,7 @@ const getFirstElement = (element) => * @param {HTMLElement} resultList * @param {HTMLElement} resultWrap */ -const scrollResultsToTop = (resultList, resultWrap) => { +export const scrollResultsToTop = (resultList, resultWrap) => { // if there is an overflow of ul element, after // opening we always move ul to the top of the results resultList.scrollTop = resultList.offsetTop - resultWrap.offsetHeight; @@ -58,7 +59,7 @@ const scrollResultsToTop = (resultList, resultWrap) => { * * @param {HTMLElement} itemsLi */ -const addAriaToAllLiElements = (itemsLi) => { +export const addAriaToAllLiElements = (itemsLi) => { // add role to all li elements for (let i = 0; i < itemsLi.length; i++) { setAttributes(itemsLi[i], { @@ -66,7 +67,8 @@ const addAriaToAllLiElements = (itemsLi) => { tabindex: "-1", "aria-selected": "false", "aria-setsize": itemsLi.length, - "aria-posinset": i, + // https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-posinset + "aria-posinset": i + 1, }); } }; @@ -77,7 +79,7 @@ const addAriaToAllLiElements = (itemsLi) => { * @param {HTMLElement} clearButton - button to clear data * @param {Function} destroy - destroy function */ -const showBtnToClearData = (clearButton = false, destroy) => { +export const showBtnToClearData = (clearButton = false, destroy) => { if (!clearButton) return; classList(clearButton, "remove", "hidden"); @@ -92,7 +94,7 @@ const showBtnToClearData = (clearButton = false, destroy) => { * @param {String} action - add/remove/contains * @param {String} className - class name */ -const classList = (element, action, className) => +export const classList = (element, action, className) => element.classList[action](className); /** @@ -101,7 +103,7 @@ const classList = (element, action, className) => * @param {HTMLElement} root - search input * @param {String} type */ -const setAriaActivedescendant = (root, type) => { +export const setAriaActivedescendant = (root, type) => { setAttributes(root, { "aria-activedescendant": type || "", }); @@ -114,7 +116,7 @@ const setAriaActivedescendant = (root, type) => { * @param {String} classGroup * @returns {Number} */ -const getClassGroupHeight = (outputUl, classGroup) => { +export const getClassGroupHeight = (outputUl, classGroup) => { // get height of ul without group class const allLiElements = document.querySelectorAll( `#${outputUl} > li:not(.${classGroup})`, @@ -134,7 +136,12 @@ const getClassGroupHeight = (outputUl, classGroup) => { * @param {String} classGroup * @param {HTMLElement} resultList */ -const followActiveElement = (target, outputUl, classGroup, resultList) => { +export const followActiveElement = ( + target, + outputUl, + classGroup, + resultList, +) => { const previusElement = resultList.previousSibling; const previusElementHeight = previusElement ? previusElement.offsetHeight : 0; @@ -165,7 +172,7 @@ const followActiveElement = (target, outputUl, classGroup, resultList) => { * @param {HTMLElement} resultWrap - wrapper ul element * @param {String} prefix - add prefix to all class auto */ -const output = (root, resultList, outputUl, resultWrap, prefix) => { +export const output = (root, resultList, outputUl, resultWrap, prefix) => { // set attribute to results-list setAttributes(resultList, { id: outputUl, @@ -191,7 +198,7 @@ const output = (root, resultList, outputUl, resultWrap, prefix) => { * @param {String} type - type of element * @returns {HTMLDivElement} */ -const createElement = (type) => document.createElement(type); +export const createElement = (type) => document.createElement(type); /** * Get element @@ -199,7 +206,7 @@ const createElement = (type) => document.createElement(type); * @param {String} element * @returns {HTMLElement} */ -const select = (element) => document.querySelector(element); +export const select = (element) => document.querySelector(element); /** * Event listeners @@ -208,31 +215,33 @@ const select = (element) => document.querySelector(element); * @param {String} action * @param {Function} callback */ -const onEvent = (element, action, callback) => { +export const onEvent = (element, action, callback) => { element.addEventListener(action, callback); }; /** * Remove event listeners + * + * @param {HTMLElement} element + * @param {String} action + * @param {Function} callback */ -const offEvent = (element, action, callback) => { +export const offEvent = (element, action, callback) => { element.removeEventListener(action, callback); }; -export { - addAriaToAllLiElements, - classList, - createElement, - followActiveElement, - getFirstElement, - isObject, - isPromise, - offEvent, - onEvent, - output, - scrollResultsToTop, - select, - setAriaActivedescendant, - setAttributes, - showBtnToClearData, +/** + * Add event listeners to all elements + * + * @param {HTMLElement} id + * + */ +export const ariaActiveDescendantDefault = (id) => { + return { + "aria-owns": id, + "aria-expanded": "false", + "aria-autocomplete": "list", + role: "combobox", + removeClass: "auto-expanded", + }; }; From 7bac9c26534bfa316b849c369df53fabfaedd962 Mon Sep 17 00:00:00 2001 From: Grzegorz Tomicki Date: Sun, 24 Mar 2024 22:57:38 +0100 Subject: [PATCH 2/4] docs: update version --- CHANGELOG.md | 6 ++++++ README.md | 10 +++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fdd024..6d7bbd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 2024-03-24 (2.0.1) +### Bug Fixes +- set default aria on initial input field +- aria-posinset start from 0, should be 1 + + ## 2024-03-20 (2.0.0) ## Added - removeResultsWhenInputIsEmpty - the parameter deletes the results. We use the `destroy()` method which removes the results from the DOM and returns everything to its original state. diff --git a/README.md b/README.md index e2fa5cb..0026cab 100644 --- a/README.md +++ b/README.md @@ -44,13 +44,13 @@ See the demo - [example](https://tomickigrzegorz.github.io/autocomplete/) #### CSS ```html - + ``` #### JavaScript ```html - + ``` ##### -- OR -- @@ -480,9 +480,9 @@ Configuration for IE: ### cdn -- https://cdn.jsdelivr.net/gh/tomickigrzegorz/autocomplete@2.0.0/dist/js/polyfill.js -- https://cdn.jsdelivr.net/gh/tomickigrzegorz/autocomplete@2.0.0/dist/js/autocomplete.ie.min.js -- https://cdn.jsdelivr.net/gh/tomickigrzegorz/autocomplete@2.0.0/dist/css/autocomplete.ie.min.css +- https://cdn.jsdelivr.net/gh/tomickigrzegorz/autocomplete@2.0.1/dist/js/polyfill.js +- https://cdn.jsdelivr.net/gh/tomickigrzegorz/autocomplete@2.0.1/dist/js/autocomplete.ie.min.js +- https://cdn.jsdelivr.net/gh/tomickigrzegorz/autocomplete@2.0.1/dist/css/autocomplete.ie.min.css ### cdn polyfill from npm From 16ace25c677746c08b2aed80688d72ab9e6b6946 Mon Sep 17 00:00:00 2001 From: Grzegorz Tomicki Date: Sun, 24 Mar 2024 22:57:52 +0100 Subject: [PATCH 3/4] chore: v2.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 526d6a0..6ddcaa5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tomickigrzegorz/autocomplete", - "version": "2.0.0", + "version": "2.0.1", "description": "Simple autocomplete component in vanilla JS", "author": "Grzegorz Tomicki", "main": "dist/js/autocomplete.js", From 0e6c834266153e42befef623ac3fa429cc9496d9 Mon Sep 17 00:00:00 2001 From: Grzegorz Tomicki Date: Sun, 24 Mar 2024 22:58:11 +0100 Subject: [PATCH 4/4] build: v2.0.1 --- dist/js/autocomplete.esm.js | 23 ++++++++++++++--------- dist/js/autocomplete.esm.js.map | 2 +- dist/js/autocomplete.esm.min.js | 4 ++-- dist/js/autocomplete.ie.min.js | 4 ++-- dist/js/autocomplete.js | 23 ++++++++++++++--------- dist/js/autocomplete.js.map | 2 +- dist/js/autocomplete.min.js | 4 ++-- dist/js/autocomplete.umd.js | 23 ++++++++++++++--------- dist/js/autocomplete.umd.js.map | 2 +- dist/js/autocomplete.umd.min.js | 4 ++-- dist/js/polyfill.js | 2 +- docs/ie.html | 6 +++--- docs/index.html | 12 ++++++------ docs/js/autocomplete.min.js | 4 ++-- docs/js/autocomplete.min.js.map | 2 +- 15 files changed, 66 insertions(+), 51 deletions(-) diff --git a/dist/js/autocomplete.esm.js b/dist/js/autocomplete.esm.js index e320023..25e2488 100644 --- a/dist/js/autocomplete.esm.js +++ b/dist/js/autocomplete.esm.js @@ -1,6 +1,6 @@ /*! * @name autocomplete -* @version 2.0.0 +* @version 2.0.1 * @author Grzegorz Tomicki * @link https://github.com/tomickigrzegorz/autocomplete * @license MIT @@ -29,7 +29,7 @@ const addAriaToAllLiElements = itemsLi => { tabindex: "-1", "aria-selected": "false", "aria-setsize": itemsLi.length, - "aria-posinset": i + "aria-posinset": i + 1 }); } }; @@ -89,6 +89,15 @@ const onEvent = (element, action, callback) => { const offEvent = (element, action, callback) => { element.removeEventListener(action, callback); }; +const ariaActiveDescendantDefault = id => { + return { + "aria-owns": id, + "aria-expanded": "false", + "aria-autocomplete": "list", + role: "combobox", + removeClass: "auto-expanded" + }; +}; const keyCodes = { ESC: 27, @@ -132,6 +141,8 @@ class Autocomplete { } = _ref; this._initial = () => { this._clearbutton(); + const ariaAcrivedescentDefault = ariaActiveDescendantDefault(this._outputUl); + setAttributes(this._root, ariaAcrivedescentDefault); output(this._root, this._resultList, this._outputUl, this._resultWrap, this._prefix); onEvent(this._root, "input", this._handleInput); this._showAll && onEvent(this._root, "click", this._handleInput); @@ -177,13 +188,7 @@ class Autocomplete { }; this._reset = () => { classList(this._resultWrap, "remove", this._isActive); - const ariaAcrivedescentDefault = { - "aria-owns": `${this._id}-list`, - "aria-expanded": "false", - "aria-autocomplete": "list", - role: "combobox", - removeClass: "auto-expanded" - }; + const ariaAcrivedescentDefault = ariaActiveDescendantDefault(this._outputUl); const ariaAcrivedescent = this._preventScrollUp ? ariaAcrivedescentDefault : { ...ariaAcrivedescentDefault, "aria-activedescendant": "" diff --git a/dist/js/autocomplete.esm.js.map b/dist/js/autocomplete.esm.js.map index fd5c104..eb44c0a 100644 --- a/dist/js/autocomplete.esm.js.map +++ b/dist/js/autocomplete.esm.js.map @@ -1 +1 @@ -{"version":3,"file":"autocomplete.esm.js","sources":["../../sources/js/utils/function.js","../../sources/js/utils/keyCodes.js","../../sources/js/script.js"],"sourcesContent":["/**\r\n * Check is a Object\r\n * @param {Object} value\r\n * @returns {Boolean}\r\n */\r\nconst isObject = (value) =>\r\n value && typeof value === \"object\" && value.constructor === Object;\r\n\r\n/**\r\n * Check if is a Promise\r\n * https://stackoverflow.com/a/53955664/10424385\r\n *\r\n * @param {Object} value\r\n * @returns {Boolean}\r\n */\r\nconst isPromise = (value) => Boolean(value && typeof value.then === \"function\");\r\n\r\n/**\r\n * Set attributes to element\r\n *\r\n * @param {HTMLElement} el\r\n * @param {Object} object\r\n */\r\nconst setAttributes = (el, object) => {\r\n for (let key in object) {\r\n if (key === \"addClass\") {\r\n classList(el, \"add\", object[key]);\r\n } else if (key === \"removeClass\") {\r\n classList(el, \"remove\", object[key]);\r\n } else {\r\n el.setAttribute(key, object[key]);\r\n }\r\n }\r\n};\r\n\r\n/**\r\n * Get first element from child\r\n *\r\n * @param {HTMLElement} element\r\n * @returns {HTMLELement}\r\n */\r\nconst getFirstElement = (element) =>\r\n (element.firstElementChild || element).textContent.trim();\r\n\r\n/**\r\n * Scroll to top result-list\r\n * @param {HTMLElement} resultList\r\n * @param {HTMLElement} resultWrap\r\n */\r\nconst scrollResultsToTop = (resultList, resultWrap) => {\r\n // if there is an overflow of ul element, after\r\n // opening we always move ul to the top of the results\r\n resultList.scrollTop = resultList.offsetTop - resultWrap.offsetHeight;\r\n};\r\n\r\n/**\r\n * Adding role, tabindex, aria and call handleMouse\r\n *\r\n * @param {HTMLElement} itemsLi\r\n */\r\nconst addAriaToAllLiElements = (itemsLi) => {\r\n // add role to all li elements\r\n for (let i = 0; i < itemsLi.length; i++) {\r\n setAttributes(itemsLi[i], {\r\n role: \"option\",\r\n tabindex: \"-1\",\r\n \"aria-selected\": \"false\",\r\n \"aria-setsize\": itemsLi.length,\r\n \"aria-posinset\": i,\r\n });\r\n }\r\n};\r\n\r\n/**\r\n * Show btn to clear data\r\n *\r\n * @param {HTMLElement} clearButton - button to clear data\r\n * @param {Function} destroy - destroy function\r\n */\r\nconst showBtnToClearData = (clearButton = false, destroy) => {\r\n if (!clearButton) return;\r\n\r\n classList(clearButton, \"remove\", \"hidden\");\r\n // add event to clear button\r\n onEvent(clearButton, \"click\", destroy);\r\n};\r\n\r\n/**\r\n * ClassList add/remove/contains\r\n *\r\n * @param {HTMLElement} element - html element\r\n * @param {String} action - add/remove/contains\r\n * @param {String} className - class name\r\n */\r\nconst classList = (element, action, className) =>\r\n element.classList[action](className);\r\n\r\n/**\r\n * Set aria-activedescendant\r\n *\r\n * @param {HTMLElement} root - search input\r\n * @param {String} type\r\n */\r\nconst setAriaActivedescendant = (root, type) => {\r\n setAttributes(root, {\r\n \"aria-activedescendant\": type || \"\",\r\n });\r\n};\r\n\r\n/**\r\n * Get height of ul without group class\r\n *\r\n * @param {String} outputUl\r\n * @param {String} classGroup\r\n * @returns {Number}\r\n */\r\nconst getClassGroupHeight = (outputUl, classGroup) => {\r\n // get height of ul without group class\r\n const allLiElements = document.querySelectorAll(\r\n `#${outputUl} > li:not(.${classGroup})`,\r\n );\r\n let height = 0;\r\n [].slice.call(allLiElements).map((el) => (height += el.offsetHeight));\r\n\r\n // return height\r\n return height;\r\n};\r\n\r\n/**\r\n * Scroll into view when press up/down arrows\r\n *\r\n * @param {HTMLElement} target\r\n * @param {HTMLElement} outputUl\r\n * @param {String} classGroup\r\n * @param {HTMLElement} resultList\r\n */\r\nconst followActiveElement = (target, outputUl, classGroup, resultList) => {\r\n const previusElement = resultList.previousSibling;\r\n\r\n const previusElementHeight = previusElement ? previusElement.offsetHeight : 0;\r\n\r\n if (target.getAttribute(\"aria-posinset\") == \"0\") {\r\n resultList.scrollTop =\r\n target.offsetTop - getClassGroupHeight(outputUl, classGroup);\r\n }\r\n\r\n if (target.offsetTop - previusElementHeight < resultList.scrollTop) {\r\n resultList.scrollTop = target.offsetTop - previusElementHeight;\r\n } else {\r\n const offsetBottom =\r\n target.offsetTop + target.offsetHeight - previusElementHeight;\r\n const scrollBottom = resultList.scrollTop + resultList.offsetHeight;\r\n if (offsetBottom > scrollBottom) {\r\n resultList.scrollTop = offsetBottom - resultList.offsetHeight;\r\n }\r\n }\r\n};\r\n\r\n/**\r\n * Create output-list and put after search input\r\n *\r\n * @param {HTMLElement} root - search input\r\n * @param {HTMLElement} resultList - output-list ul\r\n * @param {String} outputUl - id name of output-list\r\n * @param {HTMLElement} resultWrap - wrapper ul element\r\n * @param {String} prefix - add prefix to all class auto\r\n */\r\nconst output = (root, resultList, outputUl, resultWrap, prefix) => {\r\n // set attribute to results-list\r\n setAttributes(resultList, {\r\n id: outputUl,\r\n tabIndex: \"0\",\r\n role: \"listbox\",\r\n });\r\n\r\n // add class to wrap element\r\n setAttributes(resultWrap, {\r\n addClass: `${prefix}-results-wrapper`,\r\n });\r\n\r\n // insert the results into the wrap element\r\n resultWrap.insertAdjacentElement(\"beforeend\", resultList);\r\n\r\n // insert the wrap element after the search input\r\n root.parentNode.insertBefore(resultWrap, root.nextSibling);\r\n};\r\n\r\n/**\r\n * Create element\r\n *\r\n * @param {String} type - type of element\r\n * @returns {HTMLDivElement}\r\n */\r\nconst createElement = (type) => document.createElement(type);\r\n\r\n/**\r\n * Get element\r\n *\r\n * @param {String} element\r\n * @returns {HTMLElement}\r\n */\r\nconst select = (element) => document.querySelector(element);\r\n\r\n/**\r\n * Event listeners\r\n *\r\n * @param {HTMLElement} element\r\n * @param {String} action\r\n * @param {Function} callback\r\n */\r\nconst onEvent = (element, action, callback) => {\r\n element.addEventListener(action, callback);\r\n};\r\n\r\n/**\r\n * Remove event listeners\r\n */\r\nconst offEvent = (element, action, callback) => {\r\n element.removeEventListener(action, callback);\r\n};\r\n\r\nexport {\r\n addAriaToAllLiElements,\r\n classList,\r\n createElement,\r\n followActiveElement,\r\n getFirstElement,\r\n isObject,\r\n isPromise,\r\n offEvent,\r\n onEvent,\r\n output,\r\n scrollResultsToTop,\r\n select,\r\n setAriaActivedescendant,\r\n setAttributes,\r\n showBtnToClearData,\r\n};\r\n","/**\r\n * Key codes\r\n */\r\nconst keyCodes = {\r\n ESC: 27,\r\n ENTER: 13,\r\n UP: 38,\r\n DOWN: 40,\r\n TAB: 9,\r\n};\r\n\r\nexport default keyCodes;\r\n","import {\r\n addAriaToAllLiElements,\r\n classList,\r\n createElement,\r\n followActiveElement,\r\n getFirstElement,\r\n isObject,\r\n isPromise,\r\n offEvent,\r\n onEvent,\r\n output,\r\n scrollResultsToTop,\r\n select,\r\n setAriaActivedescendant,\r\n setAttributes,\r\n showBtnToClearData,\r\n} from \"./utils/function\";\r\n\r\nimport keyCodes from \"./utils/keyCodes\";\r\n\r\n/**\r\n * @class Autocomplete\r\n */\r\nexport default class Autocomplete {\r\n /**\r\n * Constructor\r\n *\r\n * @param {String} element\r\n * @param {Object} object\r\n */\r\n constructor(\r\n element,\r\n {\r\n delay = 500,\r\n clearButton = true,\r\n clearButtonOnInitial = false,\r\n howManyCharacters = 1,\r\n selectFirst = false,\r\n insertToInput = false,\r\n showAllValues = false,\r\n cache = false,\r\n disableCloseOnSelect = false,\r\n preventScrollUp = false,\r\n removeResultsWhenInputIsEmpty = false,\r\n regex = { expression: /[|\\\\{}()[\\]^$+*?]/g, replacement: \"\\\\$&\" },\r\n classGroup,\r\n classPreventClosing,\r\n classPrefix,\r\n ariaLabelClear,\r\n onSearch,\r\n onResults = () => {},\r\n onSubmit = () => {},\r\n onOpened = () => {},\r\n onReset = () => {},\r\n onRender = () => {},\r\n onClose = () => {},\r\n noResults = () => {},\r\n onSelectedItem = () => {},\r\n },\r\n ) {\r\n this._id = element;\r\n this._root = document.getElementById(element);\r\n this._onSearch = isPromise(onSearch)\r\n ? onSearch\r\n : ({ currentValue, element }) =>\r\n Promise.resolve(onSearch({ currentValue, element }));\r\n this._onResults = onResults;\r\n this._onRender = onRender;\r\n this._onSubmit = onSubmit;\r\n this._onSelected = onSelectedItem;\r\n this._onOpened = onOpened;\r\n this._onReset = onReset;\r\n this._noResults = noResults;\r\n this._onClose = onClose;\r\n\r\n this._delay = delay;\r\n this._characters = howManyCharacters;\r\n this._clearButton = clearButton;\r\n this._clearButtonOnInitial = clearButtonOnInitial;\r\n this._selectFirst = selectFirst;\r\n this._toInput = insertToInput;\r\n this._showAll = showAllValues;\r\n this._classGroup = classGroup;\r\n this._prevClosing = classPreventClosing;\r\n this._clearBtnAriLabel = ariaLabelClear\r\n ? ariaLabelClear\r\n : \"clear the search query\";\r\n this._prefix = classPrefix ? `${classPrefix}-auto` : \"auto\";\r\n this._disable = disableCloseOnSelect;\r\n this._preventScrollUp = preventScrollUp;\r\n this._removeResultsWhenInputIsEmpty = removeResultsWhenInputIsEmpty;\r\n\r\n // default config\r\n this._cache = cache;\r\n this._timeout = null;\r\n this._outputUl = `${this._prefix}-${this._id}-results`;\r\n this._cacheData = `data-cache-auto-${this._id}`;\r\n this._isLoading = `${this._prefix}-is-loading`;\r\n this._isActive = `${this._prefix}-is-active`;\r\n this._activeList = `${this._prefix}-selected`;\r\n this._selectedOption = `${this._prefix}-selected-option`;\r\n this._err = `${this._prefix}-error`;\r\n this._resultWrap = createElement(\"div\");\r\n this._resultList = createElement(\"ul\");\r\n this._clearBtn = createElement(\"button\");\r\n\r\n // ----------------------------------------\r\n // regex\r\n\r\n this._regex = regex;\r\n this._defaultExpression = {\r\n expression: /[|\\\\{}()[\\]^$+*?]/g,\r\n replacement: \"\\\\$&\",\r\n };\r\n\r\n // if regex is don't have replacement then set default\r\n if (!this._regex.replacement) {\r\n this._regex.replacement = this._defaultExpression.replacement;\r\n }\r\n\r\n // if regex is don't have expression then set default\r\n if (!this._regex.expression) {\r\n this._regex.expression = this._defaultExpression.expression;\r\n }\r\n\r\n // ----------------------------------------\r\n\r\n this._initial();\r\n }\r\n\r\n /**\r\n * Initial function\r\n */\r\n _initial = () => {\r\n this._clearbutton();\r\n\r\n output(\r\n this._root,\r\n this._resultList,\r\n this._outputUl,\r\n this._resultWrap,\r\n this._prefix,\r\n );\r\n\r\n // default aria\r\n onEvent(this._root, \"input\", this._handleInput);\r\n\r\n // show all values on click root input\r\n this._showAll && onEvent(this._root, \"click\", this._handleInput);\r\n\r\n // calback functions\r\n this._onRender({\r\n element: this._root,\r\n results: this._resultList,\r\n });\r\n\r\n // show clear button if\r\n if (this._clearButtonOnInitial) {\r\n showBtnToClearData(this._clearBtn, this.destroy);\r\n }\r\n };\r\n\r\n /**\r\n * Actions on input\r\n *\r\n * @param {String} type - set attribute depending on type\r\n * @param {String} target\r\n */\r\n _cacheAct = (type, target) => {\r\n if (!this._cache) return;\r\n\r\n if (type === \"update\") {\r\n this._root.setAttribute(this._cacheData, target.value);\r\n } else if (type === \"remove\") {\r\n this._root.removeAttribute(this._cacheData);\r\n } else {\r\n this._root.value = this._root.getAttribute(this._cacheData);\r\n }\r\n };\r\n\r\n /**\r\n * Handle input\r\n *\r\n * @param {Event} object\r\n */\r\n _handleInput = ({ target, type }) => {\r\n if (\r\n this._root.getAttribute(\"aria-expanded\") === \"true\" &&\r\n type === \"click\"\r\n ) {\r\n return;\r\n }\r\n\r\n // replace all special characters\r\n const regex = target.value.replace(\r\n this._regex.expression,\r\n this._regex.replacement,\r\n );\r\n\r\n // update data attribute cache\r\n this._cacheAct(\"update\", target);\r\n\r\n const delay = this._showAll ? 0 : this._delay;\r\n // clear timeout\r\n clearTimeout(this._timeout);\r\n this._timeout = setTimeout(() => {\r\n // removeResultsWhenInputIsEmpty\r\n // remove results when input is empty\r\n if (this._removeResultsWhenInputIsEmpty) {\r\n if (target.value.length === 0) {\r\n this.destroy();\r\n return;\r\n }\r\n }\r\n\r\n this._searchItem(regex.trim());\r\n }, delay);\r\n };\r\n\r\n /**\r\n * Default aria\r\n */\r\n _reset = () => {\r\n // remove class isActive\r\n classList(this._resultWrap, \"remove\", this._isActive);\r\n\r\n const ariaAcrivedescentDefault = {\r\n \"aria-owns\": `${this._id}-list`,\r\n \"aria-expanded\": \"false\",\r\n \"aria-autocomplete\": \"list\",\r\n role: \"combobox\",\r\n removeClass: \"auto-expanded\",\r\n };\r\n\r\n const ariaAcrivedescent = this._preventScrollUp\r\n ? ariaAcrivedescentDefault\r\n : { ...ariaAcrivedescentDefault, \"aria-activedescendant\": \"\" };\r\n\r\n // set attributes to root - input\r\n setAttributes(this._root, ariaAcrivedescent);\r\n\r\n if (!this._preventScrollUp) {\r\n // set default aria-selected, remove id and remove class 'auto-selected'\r\n this._removeAria(select(`.${this._activeList}`));\r\n\r\n // set index\r\n this._index = this._selectFirst ? 0 : -1;\r\n }\r\n\r\n // remove result when lengh = 0 and insertToInput is false\r\n // https://github.com/tomickigrzegorz/autocomplete/issues/136\r\n if ((this._matches?.length == 0 && !this._toInput) || this._showAll) {\r\n this._resultList.textContent = \"\";\r\n }\r\n\r\n // callback function\r\n this._onClose();\r\n };\r\n\r\n /**\r\n * The async function gets the text from the search\r\n * and returns the matching array\r\n *\r\n * @param {String} value\r\n */\r\n _searchItem = (value) => {\r\n this._value = value;\r\n\r\n // if searching show loading icon\r\n this._onLoading(true);\r\n\r\n // hide button clear\r\n showBtnToClearData(this._clearBtn, this.destroy);\r\n\r\n // if there is no value and clearButton is true\r\n if (value.length == 0 && this._clearButton) {\r\n classList(this._clearBtn, \"add\", \"hidden\");\r\n }\r\n\r\n // if declare characters more then value.len and showAll is false\r\n // remove class isActive\r\n if (this._characters > value.length && !this._showAll) {\r\n this._onLoading();\r\n return;\r\n }\r\n\r\n // callblack function onSearch\r\n this._onSearch({ currentValue: value, element: this._root })\r\n .then((result) => {\r\n const rootValueLength = this._root.value.length;\r\n const resultLength = result.length;\r\n // set no result\r\n this._matches = Array.isArray(result)\r\n ? result\r\n : JSON.parse(JSON.stringify(result));\r\n\r\n this._onLoading();\r\n this._error();\r\n\r\n // if use destroy() method\r\n if (resultLength == 0 && rootValueLength == 0) {\r\n classList(this._clearBtn, \"add\", \"hidden\");\r\n }\r\n\r\n if (resultLength == 0 && rootValueLength) {\r\n classList(this._root, \"remove\", \"auto-expanded\");\r\n this._reset();\r\n this._noResults({\r\n element: this._root,\r\n currentValue: value,\r\n template: this._results,\r\n });\r\n this._events();\r\n } else if (resultLength > 0 || isObject(result)) {\r\n this._index = this._selectFirst ? 0 : -1;\r\n this._results();\r\n this._events();\r\n }\r\n })\r\n .catch(() => {\r\n this._onLoading();\r\n this._reset();\r\n });\r\n };\r\n\r\n /**\r\n * Set or remove loading class\r\n *\r\n * @param {Boolean} type\r\n */\r\n _onLoading = (type) =>\r\n this._root.parentNode.classList[type ? \"add\" : \"remove\"](this._isLoading);\r\n\r\n /**\r\n * Set error class to the root element\r\n */\r\n _error = () => classList(this._root, \"remove\", this._err);\r\n\r\n /**\r\n * Events\r\n */\r\n _events = () => {\r\n // handle click on keydown [up, down, enter, tab, esc]\r\n onEvent(this._root, \"keydown\", this._handleKeys);\r\n\r\n onEvent(this._root, \"click\", this._handleShowItems);\r\n\r\n // close expanded items\r\n onEvent(document, \"click\", this._handleDocClick);\r\n\r\n // temporarily disabled mouseleave\r\n [\"mousemove\", \"click\"].map((eventType) => {\r\n onEvent(this._resultList, eventType, this._handleMouse);\r\n });\r\n };\r\n\r\n /**\r\n * Results\r\n *\r\n * @param {HTMLElement|String} template - html or string returned from the function,\r\n * look at the example - https://github.com/tomickigrzegorz/autocomplete/blob/master/docs/js/examples/no-results.js#L30\r\n */\r\n _results = (template) => {\r\n // set attribute to root\r\n setAttributes(this._root, {\r\n \"aria-expanded\": \"true\",\r\n addClass: `${this._prefix}-expanded`,\r\n });\r\n\r\n // clear result list\r\n this._resultList.textContent = \"\";\r\n\r\n // add all found records to otput ul\r\n const dataResults =\r\n this._matches.length === 0\r\n ? this._onResults({\r\n currentValue: this._value,\r\n matches: 0,\r\n template,\r\n })\r\n : this._onResults({\r\n currentValue: this._value,\r\n matches: this._matches,\r\n classGroup: this._classGroup,\r\n });\r\n\r\n // add data to ul\r\n this._resultList.insertAdjacentHTML(\"afterbegin\", dataResults);\r\n\r\n // add class isActive\r\n classList(this._resultWrap, \"add\", this._isActive);\r\n\r\n const checkIfClassGroupExist = this._classGroup\r\n ? `:not(.${this._classGroup})`\r\n : \"\";\r\n\r\n this._itemsLi = document.querySelectorAll(\r\n `#${this._outputUl} > li${checkIfClassGroupExist}`,\r\n );\r\n\r\n // adding role, tabindex and aria\r\n addAriaToAllLiElements(this._itemsLi);\r\n\r\n // action on open results\r\n this._onOpened({\r\n type: \"results\",\r\n element: this._root,\r\n results: this._resultList,\r\n });\r\n\r\n // select first element\r\n this._selectFirstElement();\r\n\r\n // move the view item to the first item\r\n // this.resultList.scrollTop = 0;\r\n // if (this._preventScrollUp) return;\r\n scrollResultsToTop(this._resultList, this._resultWrap);\r\n };\r\n\r\n /**\r\n * Hangle click on document\r\n *\r\n * @param {Event} object\r\n */\r\n _handleDocClick = ({ target }) => {\r\n let disableClose = null;\r\n\r\n // if 'target' is a ul and 'disableCloseOnSelect'\r\n // is a 'true' set 'disableClose' on true\r\n if (\r\n (target.closest(\"ul\") && this._disable) ||\r\n // when class classDisableClose\r\n // then do not not close results\r\n target.closest(`.${this._prevClosing}`)\r\n ) {\r\n disableClose = true;\r\n }\r\n\r\n if (target.id !== this._id && !disableClose) {\r\n this._reset();\r\n return;\r\n }\r\n };\r\n\r\n /**\r\n * Select first element\r\n */\r\n _selectFirstElement = () => {\r\n this._removeAria(select(`.${this._activeList}`));\r\n\r\n if (!this._selectFirst) {\r\n return;\r\n }\r\n\r\n const { firstElementChild } = this._resultList;\r\n\r\n const classSelectFirst =\r\n this._classGroup && this._matches.length > 0 && this._selectFirst\r\n ? firstElementChild.nextElementSibling\r\n : firstElementChild;\r\n\r\n // calback function onSelect when first element is true\r\n this._onSelected({\r\n index: this._index,\r\n element: this._root,\r\n object: this._matches[this._index],\r\n });\r\n\r\n // set attribute to first element\r\n setAttributes(classSelectFirst, {\r\n id: `${this._selectedOption}-0`,\r\n addClass: this._activeList,\r\n \"aria-selected\": \"true\",\r\n });\r\n\r\n // set aria active descendant\r\n setAriaActivedescendant(this._root, `${this._selectedOption}-0`);\r\n };\r\n\r\n /**\r\n * show items when items.length > 0 and is not empty\r\n */\r\n _handleShowItems = () => {\r\n // if resultWrap is not active and resultList is not empty\r\n if (\r\n this._resultList.textContent.length > 0 &&\r\n !classList(this._resultWrap, \"contains\", this._isActive)\r\n ) {\r\n // set attribute to root\r\n setAttributes(this._root, {\r\n \"aria-expanded\": \"true\",\r\n addClass: `${this._prefix}-expanded`,\r\n });\r\n\r\n // add isActive class to resultWrap\r\n classList(this._resultWrap, \"add\", this._isActive);\r\n\r\n // move the view item to the first item\r\n // this.resultList.scrollTop = 0;\r\n if (!this._preventScrollUp) {\r\n scrollResultsToTop(this._resultList, this._resultWrap);\r\n // select first element\r\n this._selectFirstElement();\r\n }\r\n\r\n // callback function\r\n this._onOpened({\r\n type: \"showItems\",\r\n element: this._root,\r\n results: this._resultList,\r\n });\r\n\r\n if (!this._cache) return;\r\n this._cacheAct(\"update\", this._root);\r\n }\r\n };\r\n\r\n /**\r\n * Adding text from the list when li is clicking\r\n * or adding aria-selected to li elements\r\n *\r\n * @param {Event} event\r\n */\r\n _handleMouse = (event) => {\r\n event.preventDefault();\r\n\r\n const { target, type } = event;\r\n const targetClosest = target.closest(\"li\");\r\n const targetClosestRole = targetClosest?.hasAttribute(\"role\");\r\n const activeClass = this._activeList;\r\n const activeClassElement = select(`.${activeClass}`);\r\n\r\n if (\r\n !targetClosest ||\r\n !targetClosestRole ||\r\n target.closest(`.${this._prevClosing}`)\r\n ) {\r\n return;\r\n }\r\n\r\n if (type === \"click\") {\r\n // click on li get element\r\n // get text from clicked li\r\n this._getTextFromLi(targetClosest);\r\n }\r\n\r\n if (\r\n type === \"mousemove\" &&\r\n !classList(targetClosest, \"contains\", activeClass)\r\n ) {\r\n this._removeAria(activeClassElement);\r\n\r\n // add aria to li\r\n this._setAria(targetClosest);\r\n this._index = this._indexLiSelected(targetClosest);\r\n\r\n this._onSelected({\r\n index: this._index,\r\n element: this._root,\r\n object: this._matches[this._index],\r\n });\r\n }\r\n };\r\n\r\n /**\r\n * Get text from li on enter or click\r\n *\r\n * @param {HTMLElement} element\r\n */\r\n _getTextFromLi = (element) => {\r\n if (!element || this._matches.length === 0) {\r\n // set default settings\r\n !this._disable && this._reset();\r\n\r\n return;\r\n }\r\n\r\n // show clearBtn when select element\r\n this._clearButton && classList(this._clearBtn, \"remove\", \"hidden\");\r\n\r\n // get first element from li and set it to root\r\n this._root.value = getFirstElement(element);\r\n\r\n // onSubmit passing text to function\r\n this._onSubmit({\r\n index: this._index,\r\n element: this._root,\r\n object: this._matches[this._index],\r\n results: this._resultList,\r\n });\r\n\r\n // set default settings\r\n if (!this._disable) {\r\n if (!this._preventScrollUp) {\r\n this._removeAria(element);\r\n }\r\n this._reset();\r\n }\r\n\r\n // remove cache\r\n this._cacheAct(\"remove\");\r\n };\r\n\r\n /**\r\n * Return which li element was selected\r\n * by hovering the mouse over\r\n *\r\n * @param {HTMLElement} target\r\n * @returns {Number}\r\n */\r\n _indexLiSelected = (target) =>\r\n // get index of li element\r\n Array.prototype.indexOf.call(this._itemsLi, target);\r\n\r\n /**\r\n * Navigating the elements li and enter\r\n *\r\n * @param {Event} event\r\n */\r\n _handleKeys = (event) => {\r\n const { keyCode } = event;\r\n\r\n const resultList = classList(this._resultWrap, \"contains\", this._isActive);\r\n\r\n const matchesLength = this._matches.length + 1;\r\n this._selectedLi = select(`.${this._activeList}`);\r\n\r\n // switch between keys\r\n switch (keyCode) {\r\n case keyCodes.UP:\r\n case keyCodes.DOWN:\r\n // Wrong cursor position in the input field #62\r\n // Prevents the cursor from moving to the beginning\r\n // of input as the cursor hovers over the results.\r\n event.preventDefault();\r\n\r\n if ((matchesLength <= 1 && this._selectFirst) || !resultList) {\r\n return;\r\n }\r\n\r\n // if keyCode is up\r\n if (keyCode === keyCodes.UP) {\r\n if (this._index < 0) {\r\n this._index = matchesLength - 1;\r\n }\r\n this._index -= 1;\r\n } else {\r\n this._index += 1;\r\n if (this._index >= matchesLength) {\r\n this._index = 0;\r\n }\r\n }\r\n\r\n // remove aria-selected\r\n this._removeAria(this._selectedLi);\r\n\r\n if (this._index >= 0 && this._index < matchesLength - 1) {\r\n const selectedElement = this._itemsLi[this._index];\r\n\r\n if (this._toInput && resultList) {\r\n this._root.value = getFirstElement(selectedElement);\r\n }\r\n\r\n // callback function\r\n this._onSelected({\r\n index: this._index,\r\n element: this._root,\r\n object: this._matches[this._index],\r\n });\r\n\r\n // set aria-selected\r\n this._setAria(selectedElement);\r\n } else {\r\n // catch action\r\n this._cacheAct();\r\n setAriaActivedescendant(this._root);\r\n\r\n this._onSelected({\r\n index: null,\r\n element: this._root,\r\n object: null,\r\n });\r\n }\r\n\r\n break;\r\n // keycode enter\r\n case keyCodes.ENTER:\r\n // https:github.com/tomickigrzegorz/autocomplete/issues/145\r\n event.preventDefault();\r\n\r\n this._getTextFromLi(this._selectedLi);\r\n break;\r\n\r\n // keycode escape and keycode tab\r\n case keyCodes.TAB:\r\n case keyCodes.ESC:\r\n event.stopPropagation();\r\n this._reset();\r\n\r\n break;\r\n default:\r\n break;\r\n }\r\n };\r\n\r\n /**\r\n * Set aria label on item li\r\n *\r\n * @param {HTMLElement} target\r\n */\r\n _setAria = (target) => {\r\n const selectedOption = `${this._selectedOption}-${this._indexLiSelected(\r\n target,\r\n )}`;\r\n\r\n // set aria to li\r\n setAttributes(target, {\r\n id: selectedOption,\r\n \"aria-selected\": \"true\",\r\n addClass: this._activeList,\r\n });\r\n\r\n setAriaActivedescendant(this._root, selectedOption);\r\n\r\n // scrollIntoView when press up/down arrows\r\n followActiveElement(\r\n target,\r\n this._outputUl,\r\n this._classGroup,\r\n this._resultList,\r\n );\r\n };\r\n\r\n /**\r\n * Remove aria label from item li\r\n *\r\n * @param {HTMLElement} element\r\n */\r\n _removeAria = (element) => {\r\n if (!element) return;\r\n\r\n // remove aria from li\r\n setAttributes(element, {\r\n id: \"\",\r\n removeClass: this._activeList,\r\n \"aria-selected\": \"false\",\r\n });\r\n };\r\n\r\n /**\r\n * Create clear button and\r\n * removing text from the input field\r\n */\r\n _clearbutton = () => {\r\n // stop when clear button is disabled\r\n if (!this._clearButton) return;\r\n\r\n // add aria to clear button\r\n setAttributes(this._clearBtn, {\r\n class: `${this._prefix}-clear hidden`,\r\n type: \"button\",\r\n title: this._clearBtnAriLabel,\r\n \"aria-label\": this._clearBtnAriLabel,\r\n });\r\n\r\n // insert clear button after input - root\r\n this._root.insertAdjacentElement(\"afterend\", this._clearBtn);\r\n };\r\n\r\n /**\r\n * Rerender rows without remove root input and close elements\r\n */\r\n rerender = (inputValue) => {\r\n const text = inputValue?.trim() ? inputValue.trim() : this._root.value;\r\n if (inputValue?.trim()) {\r\n this._root.value = inputValue.trim();\r\n this._cacheAct(\"update\", this._root);\r\n }\r\n const regexText = text.replace(\r\n this._regex.expression,\r\n this._regex.replacement,\r\n );\r\n this._searchItem(regexText.trim());\r\n };\r\n\r\n /**\r\n * Clicking on the clear button\r\n * publick destroy method\r\n */\r\n destroy = () => {\r\n // if clear button is true then add class hidden\r\n this._clearButton && classList(this._clearBtn, \"add\", \"hidden\");\r\n // clear value searchId\r\n this._root.value = \"\";\r\n // set focus\r\n this._root.focus();\r\n // remove li from ul\r\n this._resultList.textContent = \"\";\r\n // set default aria\r\n this._reset();\r\n // remove error if exist\r\n this._error();\r\n // callback function\r\n this._onReset(this._root);\r\n // remove animation on loading\r\n this._onLoading();\r\n\r\n // remove listener\r\n offEvent(this._root, \"keydown\", this._handleKeys);\r\n offEvent(this._root, \"click\", this._handleShowItems);\r\n // remove listener on click on document\r\n offEvent(document, \"click\", this._handleDocClick);\r\n };\r\n}\r\n"],"names":["isObject","value","constructor","Object","isPromise","Boolean","then","setAttributes","el","object","key","classList","setAttribute","getFirstElement","element","firstElementChild","textContent","trim","scrollResultsToTop","resultList","resultWrap","scrollTop","offsetTop","offsetHeight","addAriaToAllLiElements","itemsLi","i","length","role","tabindex","showBtnToClearData","clearButton","destroy","onEvent","action","className","setAriaActivedescendant","root","type","getClassGroupHeight","outputUl","classGroup","allLiElements","document","querySelectorAll","height","slice","call","map","followActiveElement","target","previusElement","previousSibling","previusElementHeight","getAttribute","offsetBottom","scrollBottom","output","prefix","id","tabIndex","addClass","insertAdjacentElement","parentNode","insertBefore","nextSibling","createElement","select","querySelector","callback","addEventListener","offEvent","removeEventListener","keyCodes","ESC","ENTER","UP","DOWN","TAB","Autocomplete","_ref","delay","clearButtonOnInitial","howManyCharacters","selectFirst","insertToInput","showAllValues","cache","disableCloseOnSelect","preventScrollUp","removeResultsWhenInputIsEmpty","regex","expression","replacement","classPreventClosing","classPrefix","ariaLabelClear","onSearch","onResults","onSubmit","onOpened","onReset","onRender","onClose","noResults","onSelectedItem","_initial","_clearbutton","_root","_resultList","_outputUl","_resultWrap","_prefix","_handleInput","_showAll","_onRender","results","_clearButtonOnInitial","_clearBtn","_cacheAct","_cache","_cacheData","removeAttribute","_ref2","replace","_regex","_delay","clearTimeout","_timeout","setTimeout","_removeResultsWhenInputIsEmpty","_searchItem","_reset","_isActive","ariaAcrivedescentDefault","_id","removeClass","ariaAcrivedescent","_preventScrollUp","_removeAria","_activeList","_index","_selectFirst","_matches","_toInput","_onClose","_value","_onLoading","_clearButton","_characters","_onSearch","currentValue","result","rootValueLength","resultLength","Array","isArray","JSON","parse","stringify","_error","_noResults","template","_results","_events","catch","_isLoading","_err","_handleKeys","_handleShowItems","_handleDocClick","eventType","_handleMouse","dataResults","_onResults","matches","_classGroup","insertAdjacentHTML","checkIfClassGroupExist","_itemsLi","_onOpened","_selectFirstElement","_ref3","disableClose","closest","_disable","_prevClosing","classSelectFirst","nextElementSibling","_onSelected","index","_selectedOption","event","preventDefault","targetClosest","targetClosestRole","hasAttribute","activeClass","activeClassElement","_getTextFromLi","_setAria","_indexLiSelected","_onSubmit","prototype","indexOf","keyCode","matchesLength","_selectedLi","selectedElement","stopPropagation","selectedOption","class","title","_clearBtnAriLabel","rerender","inputValue","text","regexText","focus","_onReset","getElementById","_ref4","Promise","resolve","_defaultExpression"],"mappings":";;;;;;;AAKA,MAAMA,QAAQ,GAAIC,KAAK,IACrBA,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,CAACC,WAAW,KAAKC,MAAM,CAAA;AASpE,MAAMC,SAAS,GAAIH,KAAK,IAAKI,OAAO,CAACJ,KAAK,IAAI,OAAOA,KAAK,CAACK,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,CAAC2C,WAAW,GAAG3C,aAAa,CAAC,IAAI,CAAC,CAAA;AACtC,IAAA,IAAI,CAACoD,SAAS,GAAGpD,aAAa,CAAC,QAAQ,CAAC,CAAA;IAKxC,IAAI,CAAC2D,MAAM,GAAGlC,MAAK,CAAA;IACnB,IAAI,CAACqI,kBAAkB,GAAG;AACxBpI,MAAAA,UAAU,EAAE,oBAAoB;AAChCC,MAAAA,WAAW,EAAE,MAAA;KACd,CAAA;AAGD,IAAA,IAAI,CAAC,IAAI,CAACgC,MAAM,CAAChC,WAAW,EAAE;MAC5B,IAAI,CAACgC,MAAM,CAAChC,WAAW,GAAG,IAAI,CAACmI,kBAAkB,CAACnI,WAAW,CAAA;AAC/D,KAAA;AAGA,IAAA,IAAI,CAAC,IAAI,CAACgC,MAAM,CAACjC,UAAU,EAAE;MAC3B,IAAI,CAACiC,MAAM,CAACjC,UAAU,GAAG,IAAI,CAACoI,kBAAkB,CAACpI,UAAU,CAAA;AAC7D,KAAA;IAIA,IAAI,CAACc,QAAQ,EAAE,CAAA;AACjB,GAAA;AA6qBF;;;;"} \ No newline at end of file +{"version":3,"file":"autocomplete.esm.js","sources":["../../sources/js/utils/function.js","../../sources/js/utils/keyCodes.js","../../sources/js/script.js"],"sourcesContent":["/**\r\n * Check is a Object\r\n * @param {Object} value\r\n * @returns {Boolean}\r\n */\r\nexport const isObject = (value) =>\r\n value && typeof value === \"object\" && value.constructor === Object;\r\n\r\n/**\r\n * Check if is a Promise\r\n * https://stackoverflow.com/a/53955664/10424385\r\n *\r\n * @param {Object} value\r\n * @returns {Boolean}\r\n */\r\nexport const isPromise = (value) =>\r\n Boolean(value && typeof value.then === \"function\");\r\n\r\n/**\r\n * Set attributes to element\r\n *\r\n * @param {HTMLElement} el\r\n * @param {Object} object\r\n */\r\nexport const setAttributes = (el, object) => {\r\n for (let key in object) {\r\n if (key === \"addClass\") {\r\n classList(el, \"add\", object[key]);\r\n } else if (key === \"removeClass\") {\r\n classList(el, \"remove\", object[key]);\r\n } else {\r\n el.setAttribute(key, object[key]);\r\n }\r\n }\r\n};\r\n\r\n/**\r\n * Get first element from child\r\n *\r\n * @param {HTMLElement} element\r\n * @returns {HTMLELement}\r\n */\r\nexport const getFirstElement = (element) =>\r\n (element.firstElementChild || element).textContent.trim();\r\n\r\n/**\r\n * Scroll to top result-list\r\n * @param {HTMLElement} resultList\r\n * @param {HTMLElement} resultWrap\r\n */\r\nexport const scrollResultsToTop = (resultList, resultWrap) => {\r\n // if there is an overflow of ul element, after\r\n // opening we always move ul to the top of the results\r\n resultList.scrollTop = resultList.offsetTop - resultWrap.offsetHeight;\r\n};\r\n\r\n/**\r\n * Adding role, tabindex, aria and call handleMouse\r\n *\r\n * @param {HTMLElement} itemsLi\r\n */\r\nexport const addAriaToAllLiElements = (itemsLi) => {\r\n // add role to all li elements\r\n for (let i = 0; i < itemsLi.length; i++) {\r\n setAttributes(itemsLi[i], {\r\n role: \"option\",\r\n tabindex: \"-1\",\r\n \"aria-selected\": \"false\",\r\n \"aria-setsize\": itemsLi.length,\r\n // https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-posinset\r\n \"aria-posinset\": i + 1,\r\n });\r\n }\r\n};\r\n\r\n/**\r\n * Show btn to clear data\r\n *\r\n * @param {HTMLElement} clearButton - button to clear data\r\n * @param {Function} destroy - destroy function\r\n */\r\nexport const showBtnToClearData = (clearButton = false, destroy) => {\r\n if (!clearButton) return;\r\n\r\n classList(clearButton, \"remove\", \"hidden\");\r\n // add event to clear button\r\n onEvent(clearButton, \"click\", destroy);\r\n};\r\n\r\n/**\r\n * ClassList add/remove/contains\r\n *\r\n * @param {HTMLElement} element - html element\r\n * @param {String} action - add/remove/contains\r\n * @param {String} className - class name\r\n */\r\nexport const classList = (element, action, className) =>\r\n element.classList[action](className);\r\n\r\n/**\r\n * Set aria-activedescendant\r\n *\r\n * @param {HTMLElement} root - search input\r\n * @param {String} type\r\n */\r\nexport const setAriaActivedescendant = (root, type) => {\r\n setAttributes(root, {\r\n \"aria-activedescendant\": type || \"\",\r\n });\r\n};\r\n\r\n/**\r\n * Get height of ul without group class\r\n *\r\n * @param {String} outputUl\r\n * @param {String} classGroup\r\n * @returns {Number}\r\n */\r\nexport const getClassGroupHeight = (outputUl, classGroup) => {\r\n // get height of ul without group class\r\n const allLiElements = document.querySelectorAll(\r\n `#${outputUl} > li:not(.${classGroup})`,\r\n );\r\n let height = 0;\r\n [].slice.call(allLiElements).map((el) => (height += el.offsetHeight));\r\n\r\n // return height\r\n return height;\r\n};\r\n\r\n/**\r\n * Scroll into view when press up/down arrows\r\n *\r\n * @param {HTMLElement} target\r\n * @param {HTMLElement} outputUl\r\n * @param {String} classGroup\r\n * @param {HTMLElement} resultList\r\n */\r\nexport const followActiveElement = (\r\n target,\r\n outputUl,\r\n classGroup,\r\n resultList,\r\n) => {\r\n const previusElement = resultList.previousSibling;\r\n\r\n const previusElementHeight = previusElement ? previusElement.offsetHeight : 0;\r\n\r\n if (target.getAttribute(\"aria-posinset\") == \"0\") {\r\n resultList.scrollTop =\r\n target.offsetTop - getClassGroupHeight(outputUl, classGroup);\r\n }\r\n\r\n if (target.offsetTop - previusElementHeight < resultList.scrollTop) {\r\n resultList.scrollTop = target.offsetTop - previusElementHeight;\r\n } else {\r\n const offsetBottom =\r\n target.offsetTop + target.offsetHeight - previusElementHeight;\r\n const scrollBottom = resultList.scrollTop + resultList.offsetHeight;\r\n if (offsetBottom > scrollBottom) {\r\n resultList.scrollTop = offsetBottom - resultList.offsetHeight;\r\n }\r\n }\r\n};\r\n\r\n/**\r\n * Create output-list and put after search input\r\n *\r\n * @param {HTMLElement} root - search input\r\n * @param {HTMLElement} resultList - output-list ul\r\n * @param {String} outputUl - id name of output-list\r\n * @param {HTMLElement} resultWrap - wrapper ul element\r\n * @param {String} prefix - add prefix to all class auto\r\n */\r\nexport const output = (root, resultList, outputUl, resultWrap, prefix) => {\r\n // set attribute to results-list\r\n setAttributes(resultList, {\r\n id: outputUl,\r\n tabIndex: \"0\",\r\n role: \"listbox\",\r\n });\r\n\r\n // add class to wrap element\r\n setAttributes(resultWrap, {\r\n addClass: `${prefix}-results-wrapper`,\r\n });\r\n\r\n // insert the results into the wrap element\r\n resultWrap.insertAdjacentElement(\"beforeend\", resultList);\r\n\r\n // insert the wrap element after the search input\r\n root.parentNode.insertBefore(resultWrap, root.nextSibling);\r\n};\r\n\r\n/**\r\n * Create element\r\n *\r\n * @param {String} type - type of element\r\n * @returns {HTMLDivElement}\r\n */\r\nexport const createElement = (type) => document.createElement(type);\r\n\r\n/**\r\n * Get element\r\n *\r\n * @param {String} element\r\n * @returns {HTMLElement}\r\n */\r\nexport const select = (element) => document.querySelector(element);\r\n\r\n/**\r\n * Event listeners\r\n *\r\n * @param {HTMLElement} element\r\n * @param {String} action\r\n * @param {Function} callback\r\n */\r\nexport const onEvent = (element, action, callback) => {\r\n element.addEventListener(action, callback);\r\n};\r\n\r\n/**\r\n * Remove event listeners\r\n *\r\n * @param {HTMLElement} element\r\n * @param {String} action\r\n * @param {Function} callback\r\n */\r\nexport const offEvent = (element, action, callback) => {\r\n element.removeEventListener(action, callback);\r\n};\r\n\r\n/**\r\n * Add event listeners to all elements\r\n *\r\n * @param {HTMLElement} id\r\n *\r\n */\r\nexport const ariaActiveDescendantDefault = (id) => {\r\n return {\r\n \"aria-owns\": id,\r\n \"aria-expanded\": \"false\",\r\n \"aria-autocomplete\": \"list\",\r\n role: \"combobox\",\r\n removeClass: \"auto-expanded\",\r\n };\r\n};\r\n","/**\r\n * Key codes\r\n */\r\nconst keyCodes = {\r\n ESC: 27,\r\n ENTER: 13,\r\n UP: 38,\r\n DOWN: 40,\r\n TAB: 9,\r\n};\r\n\r\nexport default keyCodes;\r\n","import {\r\n addAriaToAllLiElements,\r\n classList,\r\n createElement,\r\n followActiveElement,\r\n getFirstElement,\r\n isObject,\r\n isPromise,\r\n offEvent,\r\n onEvent,\r\n output,\r\n scrollResultsToTop,\r\n select,\r\n setAriaActivedescendant,\r\n setAttributes,\r\n showBtnToClearData,\r\n ariaActiveDescendantDefault,\r\n} from \"./utils/function\";\r\n\r\nimport keyCodes from \"./utils/keyCodes\";\r\n\r\n/**\r\n * @class Autocomplete\r\n */\r\nexport default class Autocomplete {\r\n /**\r\n * Constructor\r\n *\r\n * @param {String} element\r\n * @param {Object} object\r\n */\r\n constructor(\r\n element,\r\n {\r\n delay = 500,\r\n clearButton = true,\r\n clearButtonOnInitial = false,\r\n howManyCharacters = 1,\r\n selectFirst = false,\r\n insertToInput = false,\r\n showAllValues = false,\r\n cache = false,\r\n disableCloseOnSelect = false,\r\n preventScrollUp = false,\r\n removeResultsWhenInputIsEmpty = false,\r\n regex = { expression: /[|\\\\{}()[\\]^$+*?]/g, replacement: \"\\\\$&\" },\r\n classGroup,\r\n classPreventClosing,\r\n classPrefix,\r\n ariaLabelClear,\r\n onSearch,\r\n onResults = () => {},\r\n onSubmit = () => {},\r\n onOpened = () => {},\r\n onReset = () => {},\r\n onRender = () => {},\r\n onClose = () => {},\r\n noResults = () => {},\r\n onSelectedItem = () => {},\r\n },\r\n ) {\r\n this._id = element;\r\n this._root = document.getElementById(element);\r\n this._onSearch = isPromise(onSearch)\r\n ? onSearch\r\n : ({ currentValue, element }) =>\r\n Promise.resolve(onSearch({ currentValue, element }));\r\n this._onResults = onResults;\r\n this._onRender = onRender;\r\n this._onSubmit = onSubmit;\r\n this._onSelected = onSelectedItem;\r\n this._onOpened = onOpened;\r\n this._onReset = onReset;\r\n this._noResults = noResults;\r\n this._onClose = onClose;\r\n\r\n this._delay = delay;\r\n this._characters = howManyCharacters;\r\n this._clearButton = clearButton;\r\n this._clearButtonOnInitial = clearButtonOnInitial;\r\n this._selectFirst = selectFirst;\r\n this._toInput = insertToInput;\r\n this._showAll = showAllValues;\r\n this._classGroup = classGroup;\r\n this._prevClosing = classPreventClosing;\r\n this._clearBtnAriLabel = ariaLabelClear\r\n ? ariaLabelClear\r\n : \"clear the search query\";\r\n this._prefix = classPrefix ? `${classPrefix}-auto` : \"auto\";\r\n this._disable = disableCloseOnSelect;\r\n this._preventScrollUp = preventScrollUp;\r\n this._removeResultsWhenInputIsEmpty = removeResultsWhenInputIsEmpty;\r\n\r\n // default config\r\n this._cache = cache;\r\n this._timeout = null;\r\n this._outputUl = `${this._prefix}-${this._id}-results`;\r\n this._cacheData = `data-cache-auto-${this._id}`;\r\n this._isLoading = `${this._prefix}-is-loading`;\r\n this._isActive = `${this._prefix}-is-active`;\r\n this._activeList = `${this._prefix}-selected`;\r\n this._selectedOption = `${this._prefix}-selected-option`;\r\n this._err = `${this._prefix}-error`;\r\n this._resultWrap = createElement(\"div\");\r\n this._resultList = createElement(\"ul\");\r\n this._clearBtn = createElement(\"button\");\r\n\r\n // ----------------------------------------\r\n // regex\r\n\r\n this._regex = regex;\r\n this._defaultExpression = {\r\n expression: /[|\\\\{}()[\\]^$+*?]/g,\r\n replacement: \"\\\\$&\",\r\n };\r\n\r\n // if regex is don't have replacement then set default\r\n if (!this._regex.replacement) {\r\n this._regex.replacement = this._defaultExpression.replacement;\r\n }\r\n\r\n // if regex is don't have expression then set default\r\n if (!this._regex.expression) {\r\n this._regex.expression = this._defaultExpression.expression;\r\n }\r\n\r\n // ----------------------------------------\r\n\r\n this._initial();\r\n }\r\n\r\n /**\r\n * Initial function\r\n */\r\n _initial = () => {\r\n this._clearbutton();\r\n\r\n const ariaAcrivedescentDefault = ariaActiveDescendantDefault(\r\n this._outputUl,\r\n );\r\n setAttributes(this._root, ariaAcrivedescentDefault);\r\n\r\n output(\r\n this._root,\r\n this._resultList,\r\n this._outputUl,\r\n this._resultWrap,\r\n this._prefix,\r\n );\r\n\r\n // default aria\r\n onEvent(this._root, \"input\", this._handleInput);\r\n\r\n // show all values on click root input\r\n this._showAll && onEvent(this._root, \"click\", this._handleInput);\r\n\r\n // calback functions\r\n this._onRender({\r\n element: this._root,\r\n results: this._resultList,\r\n });\r\n\r\n // show clear button if\r\n if (this._clearButtonOnInitial) {\r\n showBtnToClearData(this._clearBtn, this.destroy);\r\n }\r\n };\r\n\r\n /**\r\n * Actions on input\r\n *\r\n * @param {String} type - set attribute depending on type\r\n * @param {String} target\r\n */\r\n _cacheAct = (type, target) => {\r\n if (!this._cache) return;\r\n\r\n if (type === \"update\") {\r\n this._root.setAttribute(this._cacheData, target.value);\r\n } else if (type === \"remove\") {\r\n this._root.removeAttribute(this._cacheData);\r\n } else {\r\n this._root.value = this._root.getAttribute(this._cacheData);\r\n }\r\n };\r\n\r\n /**\r\n * Handle input\r\n *\r\n * @param {Event} object\r\n */\r\n _handleInput = ({ target, type }) => {\r\n if (\r\n this._root.getAttribute(\"aria-expanded\") === \"true\" &&\r\n type === \"click\"\r\n ) {\r\n return;\r\n }\r\n\r\n // replace all special characters\r\n const regex = target.value.replace(\r\n this._regex.expression,\r\n this._regex.replacement,\r\n );\r\n\r\n // update data attribute cache\r\n this._cacheAct(\"update\", target);\r\n\r\n const delay = this._showAll ? 0 : this._delay;\r\n // clear timeout\r\n clearTimeout(this._timeout);\r\n this._timeout = setTimeout(() => {\r\n // removeResultsWhenInputIsEmpty\r\n // remove results when input is empty\r\n if (this._removeResultsWhenInputIsEmpty) {\r\n if (target.value.length === 0) {\r\n this.destroy();\r\n return;\r\n }\r\n }\r\n\r\n this._searchItem(regex.trim());\r\n }, delay);\r\n };\r\n\r\n /**\r\n * Default aria\r\n */\r\n _reset = () => {\r\n // remove class isActive\r\n classList(this._resultWrap, \"remove\", this._isActive);\r\n\r\n const ariaAcrivedescentDefault = ariaActiveDescendantDefault(\r\n this._outputUl,\r\n );\r\n\r\n const ariaAcrivedescent = this._preventScrollUp\r\n ? ariaAcrivedescentDefault\r\n : { ...ariaAcrivedescentDefault, \"aria-activedescendant\": \"\" };\r\n\r\n // set attributes to root - input\r\n setAttributes(this._root, ariaAcrivedescent);\r\n\r\n if (!this._preventScrollUp) {\r\n // set default aria-selected, remove id and remove class 'auto-selected'\r\n this._removeAria(select(`.${this._activeList}`));\r\n\r\n // set index\r\n this._index = this._selectFirst ? 0 : -1;\r\n }\r\n\r\n // remove result when lengh = 0 and insertToInput is false\r\n // https://github.com/tomickigrzegorz/autocomplete/issues/136\r\n if ((this._matches?.length == 0 && !this._toInput) || this._showAll) {\r\n this._resultList.textContent = \"\";\r\n }\r\n\r\n // callback function\r\n this._onClose();\r\n };\r\n\r\n /**\r\n * The async function gets the text from the search\r\n * and returns the matching array\r\n *\r\n * @param {String} value\r\n */\r\n _searchItem = (value) => {\r\n this._value = value;\r\n\r\n // if searching show loading icon\r\n this._onLoading(true);\r\n\r\n // hide button clear\r\n showBtnToClearData(this._clearBtn, this.destroy);\r\n\r\n // if there is no value and clearButton is true\r\n if (value.length == 0 && this._clearButton) {\r\n classList(this._clearBtn, \"add\", \"hidden\");\r\n }\r\n\r\n // if declare characters more then value.len and showAll is false\r\n // remove class isActive\r\n if (this._characters > value.length && !this._showAll) {\r\n this._onLoading();\r\n return;\r\n }\r\n\r\n // callblack function onSearch\r\n this._onSearch({ currentValue: value, element: this._root })\r\n .then((result) => {\r\n const rootValueLength = this._root.value.length;\r\n const resultLength = result.length;\r\n // set no result\r\n this._matches = Array.isArray(result)\r\n ? result\r\n : JSON.parse(JSON.stringify(result));\r\n\r\n this._onLoading();\r\n this._error();\r\n\r\n // if use destroy() method\r\n if (resultLength == 0 && rootValueLength == 0) {\r\n classList(this._clearBtn, \"add\", \"hidden\");\r\n }\r\n\r\n if (resultLength == 0 && rootValueLength) {\r\n classList(this._root, \"remove\", \"auto-expanded\");\r\n this._reset();\r\n this._noResults({\r\n element: this._root,\r\n currentValue: value,\r\n template: this._results,\r\n });\r\n this._events();\r\n } else if (resultLength > 0 || isObject(result)) {\r\n this._index = this._selectFirst ? 0 : -1;\r\n this._results();\r\n this._events();\r\n }\r\n })\r\n .catch(() => {\r\n this._onLoading();\r\n this._reset();\r\n });\r\n };\r\n\r\n /**\r\n * Set or remove loading class\r\n *\r\n * @param {Boolean} type\r\n */\r\n _onLoading = (type) =>\r\n this._root.parentNode.classList[type ? \"add\" : \"remove\"](this._isLoading);\r\n\r\n /**\r\n * Set error class to the root element\r\n */\r\n _error = () => classList(this._root, \"remove\", this._err);\r\n\r\n /**\r\n * Events\r\n */\r\n _events = () => {\r\n // handle click on keydown [up, down, enter, tab, esc]\r\n onEvent(this._root, \"keydown\", this._handleKeys);\r\n\r\n onEvent(this._root, \"click\", this._handleShowItems);\r\n\r\n // close expanded items\r\n onEvent(document, \"click\", this._handleDocClick);\r\n\r\n // temporarily disabled mouseleave\r\n [\"mousemove\", \"click\"].map((eventType) => {\r\n onEvent(this._resultList, eventType, this._handleMouse);\r\n });\r\n };\r\n\r\n /**\r\n * Results\r\n *\r\n * @param {HTMLElement|String} template - html or string returned from the function,\r\n * look at the example - https://github.com/tomickigrzegorz/autocomplete/blob/master/docs/js/examples/no-results.js#L30\r\n */\r\n _results = (template) => {\r\n // set attribute to root\r\n setAttributes(this._root, {\r\n \"aria-expanded\": \"true\",\r\n addClass: `${this._prefix}-expanded`,\r\n });\r\n\r\n // clear result list\r\n this._resultList.textContent = \"\";\r\n\r\n // add all found records to otput ul\r\n const dataResults =\r\n this._matches.length === 0\r\n ? this._onResults({\r\n currentValue: this._value,\r\n matches: 0,\r\n template,\r\n })\r\n : this._onResults({\r\n currentValue: this._value,\r\n matches: this._matches,\r\n classGroup: this._classGroup,\r\n });\r\n\r\n // add data to ul\r\n this._resultList.insertAdjacentHTML(\"afterbegin\", dataResults);\r\n\r\n // add class isActive\r\n classList(this._resultWrap, \"add\", this._isActive);\r\n\r\n const checkIfClassGroupExist = this._classGroup\r\n ? `:not(.${this._classGroup})`\r\n : \"\";\r\n\r\n this._itemsLi = document.querySelectorAll(\r\n `#${this._outputUl} > li${checkIfClassGroupExist}`,\r\n );\r\n\r\n // adding role, tabindex and aria\r\n addAriaToAllLiElements(this._itemsLi);\r\n\r\n // action on open results\r\n this._onOpened({\r\n type: \"results\",\r\n element: this._root,\r\n results: this._resultList,\r\n });\r\n\r\n // select first element\r\n this._selectFirstElement();\r\n\r\n // move the view item to the first item\r\n // this.resultList.scrollTop = 0;\r\n // if (this._preventScrollUp) return;\r\n scrollResultsToTop(this._resultList, this._resultWrap);\r\n };\r\n\r\n /**\r\n * Hangle click on document\r\n *\r\n * @param {Event} object\r\n */\r\n _handleDocClick = ({ target }) => {\r\n let disableClose = null;\r\n\r\n // if 'target' is a ul and 'disableCloseOnSelect'\r\n // is a 'true' set 'disableClose' on true\r\n if (\r\n (target.closest(\"ul\") && this._disable) ||\r\n // when class classDisableClose\r\n // then do not not close results\r\n target.closest(`.${this._prevClosing}`)\r\n ) {\r\n disableClose = true;\r\n }\r\n\r\n if (target.id !== this._id && !disableClose) {\r\n this._reset();\r\n return;\r\n }\r\n };\r\n\r\n /**\r\n * Select first element\r\n */\r\n _selectFirstElement = () => {\r\n this._removeAria(select(`.${this._activeList}`));\r\n\r\n if (!this._selectFirst) {\r\n return;\r\n }\r\n\r\n const { firstElementChild } = this._resultList;\r\n\r\n const classSelectFirst =\r\n this._classGroup && this._matches.length > 0 && this._selectFirst\r\n ? firstElementChild.nextElementSibling\r\n : firstElementChild;\r\n\r\n // calback function onSelect when first element is true\r\n this._onSelected({\r\n index: this._index,\r\n element: this._root,\r\n object: this._matches[this._index],\r\n });\r\n\r\n // set attribute to first element\r\n setAttributes(classSelectFirst, {\r\n id: `${this._selectedOption}-0`,\r\n addClass: this._activeList,\r\n \"aria-selected\": \"true\",\r\n });\r\n\r\n // set aria active descendant\r\n setAriaActivedescendant(this._root, `${this._selectedOption}-0`);\r\n };\r\n\r\n /**\r\n * show items when items.length > 0 and is not empty\r\n */\r\n _handleShowItems = () => {\r\n // if resultWrap is not active and resultList is not empty\r\n if (\r\n this._resultList.textContent.length > 0 &&\r\n !classList(this._resultWrap, \"contains\", this._isActive)\r\n ) {\r\n // set attribute to root\r\n setAttributes(this._root, {\r\n \"aria-expanded\": \"true\",\r\n addClass: `${this._prefix}-expanded`,\r\n });\r\n\r\n // add isActive class to resultWrap\r\n classList(this._resultWrap, \"add\", this._isActive);\r\n\r\n // move the view item to the first item\r\n // this.resultList.scrollTop = 0;\r\n if (!this._preventScrollUp) {\r\n scrollResultsToTop(this._resultList, this._resultWrap);\r\n // select first element\r\n this._selectFirstElement();\r\n }\r\n\r\n // callback function\r\n this._onOpened({\r\n type: \"showItems\",\r\n element: this._root,\r\n results: this._resultList,\r\n });\r\n\r\n if (!this._cache) return;\r\n this._cacheAct(\"update\", this._root);\r\n }\r\n };\r\n\r\n /**\r\n * Adding text from the list when li is clicking\r\n * or adding aria-selected to li elements\r\n *\r\n * @param {Event} event\r\n */\r\n _handleMouse = (event) => {\r\n event.preventDefault();\r\n\r\n const { target, type } = event;\r\n const targetClosest = target.closest(\"li\");\r\n const targetClosestRole = targetClosest?.hasAttribute(\"role\");\r\n const activeClass = this._activeList;\r\n const activeClassElement = select(`.${activeClass}`);\r\n\r\n if (\r\n !targetClosest ||\r\n !targetClosestRole ||\r\n target.closest(`.${this._prevClosing}`)\r\n ) {\r\n return;\r\n }\r\n\r\n if (type === \"click\") {\r\n // click on li get element\r\n // get text from clicked li\r\n this._getTextFromLi(targetClosest);\r\n }\r\n\r\n if (\r\n type === \"mousemove\" &&\r\n !classList(targetClosest, \"contains\", activeClass)\r\n ) {\r\n this._removeAria(activeClassElement);\r\n\r\n // add aria to li\r\n this._setAria(targetClosest);\r\n this._index = this._indexLiSelected(targetClosest);\r\n\r\n this._onSelected({\r\n index: this._index,\r\n element: this._root,\r\n object: this._matches[this._index],\r\n });\r\n }\r\n };\r\n\r\n /**\r\n * Get text from li on enter or click\r\n *\r\n * @param {HTMLElement} element\r\n */\r\n _getTextFromLi = (element) => {\r\n if (!element || this._matches.length === 0) {\r\n // set default settings\r\n !this._disable && this._reset();\r\n\r\n return;\r\n }\r\n\r\n // show clearBtn when select element\r\n this._clearButton && classList(this._clearBtn, \"remove\", \"hidden\");\r\n\r\n // get first element from li and set it to root\r\n this._root.value = getFirstElement(element);\r\n\r\n // onSubmit passing text to function\r\n this._onSubmit({\r\n index: this._index,\r\n element: this._root,\r\n object: this._matches[this._index],\r\n results: this._resultList,\r\n });\r\n\r\n // set default settings\r\n if (!this._disable) {\r\n if (!this._preventScrollUp) {\r\n this._removeAria(element);\r\n }\r\n this._reset();\r\n }\r\n\r\n // remove cache\r\n this._cacheAct(\"remove\");\r\n };\r\n\r\n /**\r\n * Return which li element was selected\r\n * by hovering the mouse over\r\n *\r\n * @param {HTMLElement} target\r\n * @returns {Number}\r\n */\r\n _indexLiSelected = (target) =>\r\n // get index of li element\r\n Array.prototype.indexOf.call(this._itemsLi, target);\r\n\r\n /**\r\n * Navigating the elements li and enter\r\n *\r\n * @param {Event} event\r\n */\r\n _handleKeys = (event) => {\r\n const { keyCode } = event;\r\n\r\n const resultList = classList(this._resultWrap, \"contains\", this._isActive);\r\n\r\n const matchesLength = this._matches.length + 1;\r\n this._selectedLi = select(`.${this._activeList}`);\r\n\r\n // switch between keys\r\n switch (keyCode) {\r\n case keyCodes.UP:\r\n case keyCodes.DOWN:\r\n // Wrong cursor position in the input field #62\r\n // Prevents the cursor from moving to the beginning\r\n // of input as the cursor hovers over the results.\r\n event.preventDefault();\r\n\r\n if ((matchesLength <= 1 && this._selectFirst) || !resultList) {\r\n return;\r\n }\r\n\r\n // if keyCode is up\r\n if (keyCode === keyCodes.UP) {\r\n if (this._index < 0) {\r\n this._index = matchesLength - 1;\r\n }\r\n this._index -= 1;\r\n } else {\r\n this._index += 1;\r\n if (this._index >= matchesLength) {\r\n this._index = 0;\r\n }\r\n }\r\n\r\n // remove aria-selected\r\n this._removeAria(this._selectedLi);\r\n\r\n if (this._index >= 0 && this._index < matchesLength - 1) {\r\n const selectedElement = this._itemsLi[this._index];\r\n\r\n if (this._toInput && resultList) {\r\n this._root.value = getFirstElement(selectedElement);\r\n }\r\n\r\n // callback function\r\n this._onSelected({\r\n index: this._index,\r\n element: this._root,\r\n object: this._matches[this._index],\r\n });\r\n\r\n // set aria-selected\r\n this._setAria(selectedElement);\r\n } else {\r\n // catch action\r\n this._cacheAct();\r\n setAriaActivedescendant(this._root);\r\n\r\n this._onSelected({\r\n index: null,\r\n element: this._root,\r\n object: null,\r\n });\r\n }\r\n\r\n break;\r\n // keycode enter\r\n case keyCodes.ENTER:\r\n // https:github.com/tomickigrzegorz/autocomplete/issues/145\r\n event.preventDefault();\r\n\r\n this._getTextFromLi(this._selectedLi);\r\n break;\r\n\r\n // keycode escape and keycode tab\r\n case keyCodes.TAB:\r\n case keyCodes.ESC:\r\n event.stopPropagation();\r\n this._reset();\r\n\r\n break;\r\n default:\r\n break;\r\n }\r\n };\r\n\r\n /**\r\n * Set aria label on item li\r\n *\r\n * @param {HTMLElement} target\r\n */\r\n _setAria = (target) => {\r\n const selectedOption = `${this._selectedOption}-${this._indexLiSelected(\r\n target,\r\n )}`;\r\n\r\n // set aria to li\r\n setAttributes(target, {\r\n id: selectedOption,\r\n \"aria-selected\": \"true\",\r\n addClass: this._activeList,\r\n });\r\n\r\n setAriaActivedescendant(this._root, selectedOption);\r\n\r\n // scrollIntoView when press up/down arrows\r\n followActiveElement(\r\n target,\r\n this._outputUl,\r\n this._classGroup,\r\n this._resultList,\r\n );\r\n };\r\n\r\n /**\r\n * Remove aria label from item li\r\n *\r\n * @param {HTMLElement} element\r\n */\r\n _removeAria = (element) => {\r\n if (!element) return;\r\n\r\n // remove aria from li\r\n setAttributes(element, {\r\n id: \"\",\r\n removeClass: this._activeList,\r\n \"aria-selected\": \"false\",\r\n });\r\n };\r\n\r\n /**\r\n * Create clear button and\r\n * removing text from the input field\r\n */\r\n _clearbutton = () => {\r\n // stop when clear button is disabled\r\n if (!this._clearButton) return;\r\n\r\n // add aria to clear button\r\n setAttributes(this._clearBtn, {\r\n class: `${this._prefix}-clear hidden`,\r\n type: \"button\",\r\n title: this._clearBtnAriLabel,\r\n \"aria-label\": this._clearBtnAriLabel,\r\n });\r\n\r\n // insert clear button after input - root\r\n this._root.insertAdjacentElement(\"afterend\", this._clearBtn);\r\n };\r\n\r\n /**\r\n * Rerender rows without remove root input and close elements\r\n * @param {String} inputValue\r\n */\r\n rerender = (inputValue) => {\r\n const text = inputValue?.trim() ? inputValue.trim() : this._root.value;\r\n if (inputValue?.trim()) {\r\n this._root.value = inputValue.trim();\r\n this._cacheAct(\"update\", this._root);\r\n }\r\n const regexText = text.replace(\r\n this._regex.expression,\r\n this._regex.replacement,\r\n );\r\n this._searchItem(regexText.trim());\r\n };\r\n\r\n /**\r\n * Clicking on the clear button\r\n * publick destroy method\r\n */\r\n destroy = () => {\r\n // if clear button is true then add class hidden\r\n this._clearButton && classList(this._clearBtn, \"add\", \"hidden\");\r\n // clear value searchId\r\n this._root.value = \"\";\r\n // set focus\r\n this._root.focus();\r\n // remove li from ul\r\n this._resultList.textContent = \"\";\r\n // set default aria\r\n this._reset();\r\n // remove error if exist\r\n this._error();\r\n // callback function\r\n this._onReset(this._root);\r\n // remove animation on loading\r\n this._onLoading();\r\n\r\n // remove listener\r\n offEvent(this._root, \"keydown\", this._handleKeys);\r\n offEvent(this._root, \"click\", this._handleShowItems);\r\n // remove listener on click on document\r\n offEvent(document, \"click\", this._handleDocClick);\r\n };\r\n}\r\n"],"names":["isObject","value","constructor","Object","isPromise","Boolean","then","setAttributes","el","object","key","classList","setAttribute","getFirstElement","element","firstElementChild","textContent","trim","scrollResultsToTop","resultList","resultWrap","scrollTop","offsetTop","offsetHeight","addAriaToAllLiElements","itemsLi","i","length","role","tabindex","showBtnToClearData","clearButton","destroy","onEvent","action","className","setAriaActivedescendant","root","type","getClassGroupHeight","outputUl","classGroup","allLiElements","document","querySelectorAll","height","slice","call","map","followActiveElement","target","previusElement","previousSibling","previusElementHeight","getAttribute","offsetBottom","scrollBottom","output","prefix","id","tabIndex","addClass","insertAdjacentElement","parentNode","insertBefore","nextSibling","createElement","select","querySelector","callback","addEventListener","offEvent","removeEventListener","ariaActiveDescendantDefault","removeClass","keyCodes","ESC","ENTER","UP","DOWN","TAB","Autocomplete","_ref","delay","clearButtonOnInitial","howManyCharacters","selectFirst","insertToInput","showAllValues","cache","disableCloseOnSelect","preventScrollUp","removeResultsWhenInputIsEmpty","regex","expression","replacement","classPreventClosing","classPrefix","ariaLabelClear","onSearch","onResults","onSubmit","onOpened","onReset","onRender","onClose","noResults","onSelectedItem","_initial","_clearbutton","ariaAcrivedescentDefault","_outputUl","_root","_resultList","_resultWrap","_prefix","_handleInput","_showAll","_onRender","results","_clearButtonOnInitial","_clearBtn","_cacheAct","_cache","_cacheData","removeAttribute","_ref2","replace","_regex","_delay","clearTimeout","_timeout","setTimeout","_removeResultsWhenInputIsEmpty","_searchItem","_reset","_isActive","ariaAcrivedescent","_preventScrollUp","_removeAria","_activeList","_index","_selectFirst","_matches","_toInput","_onClose","_value","_onLoading","_clearButton","_characters","_onSearch","currentValue","result","rootValueLength","resultLength","Array","isArray","JSON","parse","stringify","_error","_noResults","template","_results","_events","catch","_isLoading","_err","_handleKeys","_handleShowItems","_handleDocClick","eventType","_handleMouse","dataResults","_onResults","matches","_classGroup","insertAdjacentHTML","checkIfClassGroupExist","_itemsLi","_onOpened","_selectFirstElement","_ref3","disableClose","closest","_disable","_prevClosing","_id","classSelectFirst","nextElementSibling","_onSelected","index","_selectedOption","event","preventDefault","targetClosest","targetClosestRole","hasAttribute","activeClass","activeClassElement","_getTextFromLi","_setAria","_indexLiSelected","_onSubmit","prototype","indexOf","keyCode","matchesLength","_selectedLi","selectedElement","stopPropagation","selectedOption","class","title","_clearBtnAriLabel","rerender","inputValue","text","regexText","focus","_onReset","getElementById","_ref4","Promise","resolve","_defaultExpression"],"mappings":";;;;;;;AAKO,MAAMA,QAAQ,GAAIC,KAAK,IAC5BA,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,CAACC,WAAW,KAAKC,MAAM,CAAA;AAS7D,MAAMC,SAAS,GAAIH,KAAK,IAC7BI,OAAO,CAACJ,KAAK,IAAI,OAAOA,KAAK,CAACK,IAAI,KAAK,UAAU,CAAC,CAAA;AAQ7C,MAAMC,aAAa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CAACoD,IAAI,GAAI,GAAE,IAAI,CAACpD,OAAQ,CAAO,MAAA,CAAA,CAAA;AACnC,IAAA,IAAI,CAACD,WAAW,GAAGhD,aAAa,CAAC,KAAK,CAAC,CAAA;AACvC,IAAA,IAAI,CAAC+C,WAAW,GAAG/C,aAAa,CAAC,IAAI,CAAC,CAAA;AACtC,IAAA,IAAI,CAACuD,SAAS,GAAGvD,aAAa,CAAC,QAAQ,CAAC,CAAA;IAKxC,IAAI,CAAC8D,MAAM,GAAGnC,MAAK,CAAA;IACnB,IAAI,CAACoI,kBAAkB,GAAG;AACxBnI,MAAAA,UAAU,EAAE,oBAAoB;AAChCC,MAAAA,WAAW,EAAE,MAAA;KACd,CAAA;AAGD,IAAA,IAAI,CAAC,IAAI,CAACiC,MAAM,CAACjC,WAAW,EAAE;MAC5B,IAAI,CAACiC,MAAM,CAACjC,WAAW,GAAG,IAAI,CAACkI,kBAAkB,CAAClI,WAAW,CAAA;AAC/D,KAAA;AAGA,IAAA,IAAI,CAAC,IAAI,CAACiC,MAAM,CAAClC,UAAU,EAAE;MAC3B,IAAI,CAACkC,MAAM,CAAClC,UAAU,GAAG,IAAI,CAACmI,kBAAkB,CAACnI,UAAU,CAAA;AAC7D,KAAA;IAIA,IAAI,CAACc,QAAQ,EAAE,CAAA;AACjB,GAAA;AA+qBF;;;;"} \ No newline at end of file diff --git a/dist/js/autocomplete.esm.min.js b/dist/js/autocomplete.esm.min.js index bc0899d..b7820c5 100644 --- a/dist/js/autocomplete.esm.min.js +++ b/dist/js/autocomplete.esm.min.js @@ -1,8 +1,8 @@ /*! * @name autocomplete -* @version 2.0.0 +* @version 2.0.1 * @author Grzegorz Tomicki * @link https://github.com/tomickigrzegorz/autocomplete * @license MIT */ -const t=(t,s)=>{for(let i in s)"addClass"===i?e(t,"add",s[i]):"removeClass"===i?e(t,"remove",s[i]):t.setAttribute(i,s[i])},s=t=>(t.firstElementChild||t).textContent.trim(),i=(t,s)=>{t.scrollTop=t.offsetTop-s.offsetHeight},h=function(t,s){void 0===t&&(t=!1),t&&(e(t,"remove","hidden"),o(t,"click",s))},e=(t,s,i)=>t.classList[s](i),a=(s,i)=>{t(s,{"aria-activedescendant":i||""})},n=(t,s,i,h)=>{const e=h.previousSibling,a=e?e.offsetHeight:0;if("0"==t.getAttribute("aria-posinset")&&(h.scrollTop=t.offsetTop-((t,s)=>{const i=document.querySelectorAll(`#${t} > li:not(.${s})`);let h=0;return[].slice.call(i).map((t=>h+=t.offsetHeight)),h})(s,i)),t.offsetTop-ah.scrollTop+h.offsetHeight&&(h.scrollTop=s-h.offsetHeight)}},l=t=>document.createElement(t),r=t=>document.querySelector(t),o=(t,s,i)=>{t.addEventListener(s,i)},c=(t,s,i)=>{t.removeEventListener(s,i)},d=27,u=13,m=38,p=40,$=9;class v{constructor(v,b){let{delay:f=500,clearButton:x=!0,clearButtonOnInitial:y=!1,howManyCharacters:C=1,selectFirst:k=!1,insertToInput:g=!1,showAllValues:w=!1,cache:j=!1,disableCloseOnSelect:I=!1,preventScrollUp:S=!1,removeResultsWhenInputIsEmpty:V=!1,regex:O={expression:/[|\\{}()[\]^$+*?]/g,replacement:"\\$&"},classGroup:R,classPreventClosing:A,classPrefix:B,ariaLabelClear:P,onSearch:T,onResults:E=(()=>{}),onSubmit:G=(()=>{}),onOpened:J=(()=>{}),onReset:N=(()=>{}),onRender:q=(()=>{}),onClose:z=(()=>{}),noResults:F=(()=>{}),onSelectedItem:L=(()=>{})}=b;var M;this.t=()=>{var s,i,e,a,n;this.i(),s=this.h,i=this.l,e=this.o,a=this.u,n=this.m,t(i,{id:e,tabIndex:"0",role:"listbox"}),t(a,{addClass:`${n}-results-wrapper`}),a.insertAdjacentElement("beforeend",i),s.parentNode.insertBefore(a,s.nextSibling),o(this.h,"input",this.p),this.$&&o(this.h,"click",this.p),this.v({element:this.h,results:this.l}),this.C&&h(this.k,this.destroy)},this.j=(t,s)=>{this.I&&("update"===t?this.h.setAttribute(this.S,s.value):"remove"===t?this.h.removeAttribute(this.S):this.h.value=this.h.getAttribute(this.S))},this.p=t=>{let{target:s,type:i}=t;if("true"===this.h.getAttribute("aria-expanded")&&"click"===i)return;const h=s.value.replace(this.V.expression,this.V.replacement);this.j("update",s);const e=this.$?0:this.O;clearTimeout(this.R),this.R=setTimeout((()=>{this.A&&0===s.value.length?this.destroy():this.B(h.trim())}),e)},this.P=()=>{e(this.u,"remove",this.T);const s={"aria-owns":`${this.G}-list`,"aria-expanded":"false","aria-autocomplete":"list",role:"combobox",removeClass:"auto-expanded"},i=this.J?s:{...s,"aria-activedescendant":""};t(this.h,i),this.J||(this.N(r(`.${this.q}`)),this.F=this.L?0:-1),(0==this.M?.length&&!this.U||this.$)&&(this.l.textContent=""),this.W()},this.B=t=>{this.D=t,this.H(!0),h(this.k,this.destroy),0==t.length&&this.K&&e(this.k,"add","hidden"),this.X>t.length&&!this.$?this.H():this.Y({currentValue:t,element:this.h}).then((s=>{const i=this.h.value.length,h=s.length;this.M=Array.isArray(s)?s:JSON.parse(JSON.stringify(s)),this.H(),this.Z(),0==h&&0==i&&e(this.k,"add","hidden"),0==h&&i?(e(this.h,"remove","auto-expanded"),this.P(),this._({element:this.h,currentValue:t,template:this.tt}),this.st()):(h>0||(t=>t&&"object"==typeof t&&t.constructor===Object)(s))&&(this.F=this.L?0:-1,this.tt(),this.st())})).catch((()=>{this.H(),this.P()}))},this.H=t=>this.h.parentNode.classList[t?"add":"remove"](this.it),this.Z=()=>e(this.h,"remove",this.ht),this.st=()=>{o(this.h,"keydown",this.et),o(this.h,"click",this.nt),o(document,"click",this.lt),["mousemove","click"].map((t=>{o(this.l,t,this.rt)}))},this.tt=s=>{t(this.h,{"aria-expanded":"true",addClass:`${this.m}-expanded`}),this.l.textContent="";const h=0===this.M.length?this.ot({currentValue:this.D,matches:0,template:s}):this.ot({currentValue:this.D,matches:this.M,classGroup:this.ct});this.l.insertAdjacentHTML("afterbegin",h),e(this.u,"add",this.T);const a=this.ct?`:not(.${this.ct})`:"";this.dt=document.querySelectorAll(`#${this.o} > li${a}`),(s=>{for(let i=0;i{let{target:s}=t,i=null;(s.closest("ul")&&this.vt||s.closest(`.${this.bt}`))&&(i=!0),s.id===this.G||i||this.P()},this.$t=()=>{if(this.N(r(`.${this.q}`)),!this.L)return;const{firstElementChild:s}=this.l,i=this.ct&&this.M.length>0&&this.L?s.nextElementSibling:s;this.ft({index:this.F,element:this.h,object:this.M[this.F]}),t(i,{id:`${this.xt}-0`,addClass:this.q,"aria-selected":"true"}),a(this.h,`${this.xt}-0`)},this.nt=()=>{if(this.l.textContent.length>0&&!e(this.u,"contains",this.T)){if(t(this.h,{"aria-expanded":"true",addClass:`${this.m}-expanded`}),e(this.u,"add",this.T),this.J||(i(this.l,this.u),this.$t()),this.ut({type:"showItems",element:this.h,results:this.l}),!this.I)return;this.j("update",this.h)}},this.rt=t=>{t.preventDefault();const{target:s,type:i}=t,h=s.closest("li"),a=h?.hasAttribute("role"),n=this.q,l=r(`.${n}`);h&&a&&!s.closest(`.${this.bt}`)&&("click"===i&&this.yt(h),"mousemove"!==i||e(h,"contains",n)||(this.N(l),this.Ct(h),this.F=this.kt(h),this.ft({index:this.F,element:this.h,object:this.M[this.F]})))},this.yt=t=>{t&&0!==this.M.length?(this.K&&e(this.k,"remove","hidden"),this.h.value=s(t),this.gt({index:this.F,element:this.h,object:this.M[this.F],results:this.l}),this.vt||(this.J||this.N(t),this.P()),this.j("remove")):!this.vt&&this.P()},this.kt=t=>Array.prototype.indexOf.call(this.dt,t),this.et=t=>{const{keyCode:i}=t,h=e(this.u,"contains",this.T),n=this.M.length+1;switch(this.wt=r(`.${this.q}`),i){case m:case p:if(t.preventDefault(),n<=1&&this.L||!h)return;if(i===m?(this.F<0&&(this.F=n-1),this.F-=1):(this.F+=1,this.F>=n&&(this.F=0)),this.N(this.wt),this.F>=0&&this.F{const i=`${this.xt}-${this.kt(s)}`;t(s,{id:i,"aria-selected":"true",addClass:this.q}),a(this.h,i),n(s,this.o,this.ct,this.l)},this.N=s=>{s&&t(s,{id:"",removeClass:this.q,"aria-selected":"false"})},this.i=()=>{this.K&&(t(this.k,{class:`${this.m}-clear hidden`,type:"button",title:this.jt,"aria-label":this.jt}),this.h.insertAdjacentElement("afterend",this.k))},this.rerender=t=>{const s=t?.trim()?t.trim():this.h.value;t?.trim()&&(this.h.value=t.trim(),this.j("update",this.h));const i=s.replace(this.V.expression,this.V.replacement);this.B(i.trim())},this.destroy=()=>{this.K&&e(this.k,"add","hidden"),this.h.value="",this.h.focus(),this.l.textContent="",this.P(),this.Z(),this.It(this.h),this.H(),c(this.h,"keydown",this.et),c(this.h,"click",this.nt),c(document,"click",this.lt)},this.G=v,this.h=document.getElementById(v),this.Y=(M=T,Boolean(M&&"function"==typeof M.then)?T:t=>{let{currentValue:s,element:i}=t;return Promise.resolve(T({currentValue:s,element:i}))}),this.ot=E,this.v=q,this.gt=G,this.ft=L,this.ut=J,this.It=N,this._=F,this.W=z,this.O=f,this.X=C,this.K=x,this.C=y,this.L=k,this.U=g,this.$=w,this.ct=R,this.bt=A,this.jt=P||"clear the search query",this.m=B?`${B}-auto`:"auto",this.vt=I,this.J=S,this.A=V,this.I=j,this.R=null,this.o=`${this.m}-${this.G}-results`,this.S=`data-cache-auto-${this.G}`,this.it=`${this.m}-is-loading`,this.T=`${this.m}-is-active`,this.q=`${this.m}-selected`,this.xt=`${this.m}-selected-option`,this.ht=`${this.m}-error`,this.u=l("div"),this.l=l("ul"),this.k=l("button"),this.V=O,this.St={expression:/[|\\{}()[\]^$+*?]/g,replacement:"\\$&"},this.V.replacement||(this.V.replacement=this.St.replacement),this.V.expression||(this.V.expression=this.St.expression),this.t()}}export{v as default}; +const t=(t,s)=>{for(let i in s)"addClass"===i?e(t,"add",s[i]):"removeClass"===i?e(t,"remove",s[i]):t.setAttribute(i,s[i])},s=t=>(t.firstElementChild||t).textContent.trim(),i=(t,s)=>{t.scrollTop=t.offsetTop-s.offsetHeight},h=function(t,s){void 0===t&&(t=!1),t&&(e(t,"remove","hidden"),r(t,"click",s))},e=(t,s,i)=>t.classList[s](i),a=(s,i)=>{t(s,{"aria-activedescendant":i||""})},n=(t,s,i,h)=>{const e=h.previousSibling,a=e?e.offsetHeight:0;if("0"==t.getAttribute("aria-posinset")&&(h.scrollTop=t.offsetTop-((t,s)=>{const i=document.querySelectorAll(`#${t} > li:not(.${s})`);let h=0;return[].slice.call(i).map((t=>h+=t.offsetHeight)),h})(s,i)),t.offsetTop-ah.scrollTop+h.offsetHeight&&(h.scrollTop=s-h.offsetHeight)}},l=t=>document.createElement(t),o=t=>document.querySelector(t),r=(t,s,i)=>{t.addEventListener(s,i)},c=(t,s,i)=>{t.removeEventListener(s,i)},d=t=>({"aria-owns":t,"aria-expanded":"false","aria-autocomplete":"list",role:"combobox",removeClass:"auto-expanded"}),u=27,m=13,p=38,$=40,v=9;class b{constructor(b,f){let{delay:x=500,clearButton:y=!0,clearButtonOnInitial:C=!1,howManyCharacters:k=1,selectFirst:g=!1,insertToInput:w=!1,showAllValues:j=!1,cache:I=!1,disableCloseOnSelect:S=!1,preventScrollUp:V=!1,removeResultsWhenInputIsEmpty:O=!1,regex:R={expression:/[|\\{}()[\]^$+*?]/g,replacement:"\\$&"},classGroup:A,classPreventClosing:B,classPrefix:P,ariaLabelClear:T,onSearch:E,onResults:G=(()=>{}),onSubmit:J=(()=>{}),onOpened:N=(()=>{}),onReset:q=(()=>{}),onRender:z=(()=>{}),onClose:F=(()=>{}),noResults:L=(()=>{}),onSelectedItem:M=(()=>{})}=f;var U;this.t=()=>{this.i();const s=d(this.h);var i,e,a,n,l;t(this.l,s),i=this.l,e=this.o,a=this.h,n=this.u,l=this.m,t(e,{id:a,tabIndex:"0",role:"listbox"}),t(n,{addClass:`${l}-results-wrapper`}),n.insertAdjacentElement("beforeend",e),i.parentNode.insertBefore(n,i.nextSibling),r(this.l,"input",this.p),this.$&&r(this.l,"click",this.p),this.v({element:this.l,results:this.o}),this.C&&h(this.k,this.destroy)},this.j=(t,s)=>{this.I&&("update"===t?this.l.setAttribute(this.S,s.value):"remove"===t?this.l.removeAttribute(this.S):this.l.value=this.l.getAttribute(this.S))},this.p=t=>{let{target:s,type:i}=t;if("true"===this.l.getAttribute("aria-expanded")&&"click"===i)return;const h=s.value.replace(this.V.expression,this.V.replacement);this.j("update",s);const e=this.$?0:this.O;clearTimeout(this.R),this.R=setTimeout((()=>{this.A&&0===s.value.length?this.destroy():this.B(h.trim())}),e)},this.P=()=>{e(this.u,"remove",this.T);const s=d(this.h),i=this.G?s:{...s,"aria-activedescendant":""};t(this.l,i),this.G||(this.J(o(`.${this.N}`)),this.q=this.F?0:-1),(0==this.L?.length&&!this.M||this.$)&&(this.o.textContent=""),this.U()},this.B=t=>{this.W=t,this.D(!0),h(this.k,this.destroy),0==t.length&&this.H&&e(this.k,"add","hidden"),this.K>t.length&&!this.$?this.D():this.X({currentValue:t,element:this.l}).then((s=>{const i=this.l.value.length,h=s.length;this.L=Array.isArray(s)?s:JSON.parse(JSON.stringify(s)),this.D(),this.Y(),0==h&&0==i&&e(this.k,"add","hidden"),0==h&&i?(e(this.l,"remove","auto-expanded"),this.P(),this.Z({element:this.l,currentValue:t,template:this._}),this.tt()):(h>0||(t=>t&&"object"==typeof t&&t.constructor===Object)(s))&&(this.q=this.F?0:-1,this._(),this.tt())})).catch((()=>{this.D(),this.P()}))},this.D=t=>this.l.parentNode.classList[t?"add":"remove"](this.st),this.Y=()=>e(this.l,"remove",this.it),this.tt=()=>{r(this.l,"keydown",this.ht),r(this.l,"click",this.et),r(document,"click",this.nt),["mousemove","click"].map((t=>{r(this.o,t,this.lt)}))},this._=s=>{t(this.l,{"aria-expanded":"true",addClass:`${this.m}-expanded`}),this.o.textContent="";const h=0===this.L.length?this.ot({currentValue:this.W,matches:0,template:s}):this.ot({currentValue:this.W,matches:this.L,classGroup:this.rt});this.o.insertAdjacentHTML("afterbegin",h),e(this.u,"add",this.T);const a=this.rt?`:not(.${this.rt})`:"";this.ct=document.querySelectorAll(`#${this.h} > li${a}`),(s=>{for(let i=0;i{let{target:s}=t,i=null;(s.closest("ul")&&this.$t||s.closest(`.${this.vt}`))&&(i=!0),s.id===this.bt||i||this.P()},this.ut=()=>{if(this.J(o(`.${this.N}`)),!this.F)return;const{firstElementChild:s}=this.o,i=this.rt&&this.L.length>0&&this.F?s.nextElementSibling:s;this.ft({index:this.q,element:this.l,object:this.L[this.q]}),t(i,{id:`${this.xt}-0`,addClass:this.N,"aria-selected":"true"}),a(this.l,`${this.xt}-0`)},this.et=()=>{if(this.o.textContent.length>0&&!e(this.u,"contains",this.T)){if(t(this.l,{"aria-expanded":"true",addClass:`${this.m}-expanded`}),e(this.u,"add",this.T),this.G||(i(this.o,this.u),this.ut()),this.dt({type:"showItems",element:this.l,results:this.o}),!this.I)return;this.j("update",this.l)}},this.lt=t=>{t.preventDefault();const{target:s,type:i}=t,h=s.closest("li"),a=h?.hasAttribute("role"),n=this.N,l=o(`.${n}`);h&&a&&!s.closest(`.${this.vt}`)&&("click"===i&&this.yt(h),"mousemove"!==i||e(h,"contains",n)||(this.J(l),this.Ct(h),this.q=this.kt(h),this.ft({index:this.q,element:this.l,object:this.L[this.q]})))},this.yt=t=>{t&&0!==this.L.length?(this.H&&e(this.k,"remove","hidden"),this.l.value=s(t),this.gt({index:this.q,element:this.l,object:this.L[this.q],results:this.o}),this.$t||(this.G||this.J(t),this.P()),this.j("remove")):!this.$t&&this.P()},this.kt=t=>Array.prototype.indexOf.call(this.ct,t),this.ht=t=>{const{keyCode:i}=t,h=e(this.u,"contains",this.T),n=this.L.length+1;switch(this.wt=o(`.${this.N}`),i){case p:case $:if(t.preventDefault(),n<=1&&this.F||!h)return;if(i===p?(this.q<0&&(this.q=n-1),this.q-=1):(this.q+=1,this.q>=n&&(this.q=0)),this.J(this.wt),this.q>=0&&this.q{const i=`${this.xt}-${this.kt(s)}`;t(s,{id:i,"aria-selected":"true",addClass:this.N}),a(this.l,i),n(s,this.h,this.rt,this.o)},this.J=s=>{s&&t(s,{id:"",removeClass:this.N,"aria-selected":"false"})},this.i=()=>{this.H&&(t(this.k,{class:`${this.m}-clear hidden`,type:"button",title:this.jt,"aria-label":this.jt}),this.l.insertAdjacentElement("afterend",this.k))},this.rerender=t=>{const s=t?.trim()?t.trim():this.l.value;t?.trim()&&(this.l.value=t.trim(),this.j("update",this.l));const i=s.replace(this.V.expression,this.V.replacement);this.B(i.trim())},this.destroy=()=>{this.H&&e(this.k,"add","hidden"),this.l.value="",this.l.focus(),this.o.textContent="",this.P(),this.Y(),this.It(this.l),this.D(),c(this.l,"keydown",this.ht),c(this.l,"click",this.et),c(document,"click",this.nt)},this.bt=b,this.l=document.getElementById(b),this.X=(U=E,Boolean(U&&"function"==typeof U.then)?E:t=>{let{currentValue:s,element:i}=t;return Promise.resolve(E({currentValue:s,element:i}))}),this.ot=G,this.v=z,this.gt=J,this.ft=M,this.dt=N,this.It=q,this.Z=L,this.U=F,this.O=x,this.K=k,this.H=y,this.C=C,this.F=g,this.M=w,this.$=j,this.rt=A,this.vt=B,this.jt=T||"clear the search query",this.m=P?`${P}-auto`:"auto",this.$t=S,this.G=V,this.A=O,this.I=I,this.R=null,this.h=`${this.m}-${this.bt}-results`,this.S=`data-cache-auto-${this.bt}`,this.st=`${this.m}-is-loading`,this.T=`${this.m}-is-active`,this.N=`${this.m}-selected`,this.xt=`${this.m}-selected-option`,this.it=`${this.m}-error`,this.u=l("div"),this.o=l("ul"),this.k=l("button"),this.V=R,this.St={expression:/[|\\{}()[\]^$+*?]/g,replacement:"\\$&"},this.V.replacement||(this.V.replacement=this.St.replacement),this.V.expression||(this.V.expression=this.St.expression),this.t()}}export{b as default}; diff --git a/dist/js/autocomplete.ie.min.js b/dist/js/autocomplete.ie.min.js index a603dfd..8ff80f4 100644 --- a/dist/js/autocomplete.ie.min.js +++ b/dist/js/autocomplete.ie.min.js @@ -1,8 +1,8 @@ /*! * @name autocomplete -* @version 2.0.0 +* @version 2.0.1 * @author Grzegorz Tomicki * @link https://github.com/tomickigrzegorz/autocomplete * @license MIT */ -var Autocomplete=function(){"use strict";const t=(t,s)=>{for(let i in s)"addClass"===i?e(t,"add",s[i]):"removeClass"===i?e(t,"remove",s[i]):t.setAttribute(i,s[i])},s=t=>(t.firstElementChild||t).textContent.trim(),i=(t,s)=>{t.scrollTop=t.offsetTop-s.offsetHeight},h=function(t,s){void 0===t&&(t=!1),t&&(e(t,"remove","hidden"),o(t,"click",s))},e=(t,s,i)=>t.classList[s](i),a=(s,i)=>{t(s,{"aria-activedescendant":i||""})},n=(t,s,i,h)=>{const e=h.previousSibling,a=e?e.offsetHeight:0;if("0"==t.getAttribute("aria-posinset")&&(h.scrollTop=t.offsetTop-((t,s)=>{const i=document.querySelectorAll("#"+t+" > li:not(."+s+")");let h=0;return[].slice.call(i).map((t=>h+=t.offsetHeight)),h})(s,i)),t.offsetTop-ah.scrollTop+h.offsetHeight&&(h.scrollTop=s-h.offsetHeight)}},l=t=>document.createElement(t),r=t=>document.querySelector(t),o=(t,s,i)=>{t.addEventListener(s,i)},c=(t,s,i)=>{t.removeEventListener(s,i)},d=27,u=13,m=38,p=40,v=9;return class{constructor(b,f){let{delay:x=500,clearButton:y=!0,clearButtonOnInitial:C=!1,howManyCharacters:k=1,selectFirst:g=!1,insertToInput:w=!1,showAllValues:j=!1,cache:I=!1,disableCloseOnSelect:S=!1,preventScrollUp:V=!1,removeResultsWhenInputIsEmpty:O=!1,regex:R={expression:/[|\\{}()[\]^$+*?]/g,replacement:"\\$&"},classGroup:A,classPreventClosing:$,classPrefix:B,ariaLabelClear:P,onSearch:T,onResults:E=(()=>{}),onSubmit:G=(()=>{}),onOpened:J=(()=>{}),onReset:N=(()=>{}),onRender:q=(()=>{}),onClose:z=(()=>{}),noResults:F=(()=>{}),onSelectedItem:L=(()=>{})}=f;var M;this.t=()=>{var s,i,e,a,n;this.i(),s=this.h,i=this.l,e=this.o,a=this.u,n=this.m,t(i,{id:e,tabIndex:"0",role:"listbox"}),t(a,{addClass:n+"-results-wrapper"}),a.insertAdjacentElement("beforeend",i),s.parentNode.insertBefore(a,s.nextSibling),o(this.h,"input",this.p),this.v&&o(this.h,"click",this.p),this.C({element:this.h,results:this.l}),this.k&&h(this.j,this.destroy)},this.I=(t,s)=>{this.S&&("update"===t?this.h.setAttribute(this.V,s.value):"remove"===t?this.h.removeAttribute(this.V):this.h.value=this.h.getAttribute(this.V))},this.p=t=>{let{target:s,type:i}=t;if("true"===this.h.getAttribute("aria-expanded")&&"click"===i)return;const h=s.value.replace(this.O.expression,this.O.replacement);this.I("update",s);const e=this.v?0:this.R;clearTimeout(this.A),this.A=setTimeout((()=>{this.$&&0===s.value.length?this.destroy():this.B(h.trim())}),e)},this.P=()=>{var s;e(this.u,"remove",this.T);const i={"aria-owns":this.G+"-list","aria-expanded":"false","aria-autocomplete":"list",role:"combobox",removeClass:"auto-expanded"},h=this.J?i:{...i,"aria-activedescendant":""};t(this.h,h),this.J||(this.N(r("."+this.q)),this.F=this.L?0:-1),(0==(null==(s=this.M)?void 0:s.length)&&!this.U||this.v)&&(this.l.textContent=""),this.W()},this.B=t=>{this.D=t,this.H(!0),h(this.j,this.destroy),0==t.length&&this.K&&e(this.j,"add","hidden"),this.X>t.length&&!this.v?this.H():this.Y({currentValue:t,element:this.h}).then((s=>{const i=this.h.value.length,h=s.length;this.M=Array.isArray(s)?s:JSON.parse(JSON.stringify(s)),this.H(),this.Z(),0==h&&0==i&&e(this.j,"add","hidden"),0==h&&i?(e(this.h,"remove","auto-expanded"),this.P(),this._({element:this.h,currentValue:t,template:this.tt}),this.st()):(h>0||(t=>t&&"object"==typeof t&&t.constructor===Object)(s))&&(this.F=this.L?0:-1,this.tt(),this.st())})).catch((()=>{this.H(),this.P()}))},this.H=t=>this.h.parentNode.classList[t?"add":"remove"](this.it),this.Z=()=>e(this.h,"remove",this.ht),this.st=()=>{o(this.h,"keydown",this.et),o(this.h,"click",this.nt),o(document,"click",this.lt),["mousemove","click"].map((t=>{o(this.l,t,this.rt)}))},this.tt=s=>{t(this.h,{"aria-expanded":"true",addClass:this.m+"-expanded"}),this.l.textContent="";const h=0===this.M.length?this.ot({currentValue:this.D,matches:0,template:s}):this.ot({currentValue:this.D,matches:this.M,classGroup:this.ct});this.l.insertAdjacentHTML("afterbegin",h),e(this.u,"add",this.T);const a=this.ct?":not(."+this.ct+")":"";this.dt=document.querySelectorAll("#"+this.o+" > li"+a),(s=>{for(let i=0;i{let{target:s}=t,i=null;(s.closest("ul")&&this.bt||s.closest("."+this.ft))&&(i=!0),s.id===this.G||i||this.P()},this.vt=()=>{if(this.N(r("."+this.q)),!this.L)return;const{firstElementChild:s}=this.l,i=this.ct&&this.M.length>0&&this.L?s.nextElementSibling:s;this.xt({index:this.F,element:this.h,object:this.M[this.F]}),t(i,{id:this.yt+"-0",addClass:this.q,"aria-selected":"true"}),a(this.h,this.yt+"-0")},this.nt=()=>{if(this.l.textContent.length>0&&!e(this.u,"contains",this.T)){if(t(this.h,{"aria-expanded":"true",addClass:this.m+"-expanded"}),e(this.u,"add",this.T),this.J||(i(this.l,this.u),this.vt()),this.ut({type:"showItems",element:this.h,results:this.l}),!this.S)return;this.I("update",this.h)}},this.rt=t=>{t.preventDefault();const{target:s,type:i}=t,h=s.closest("li"),a=null==h?void 0:h.hasAttribute("role"),n=this.q,l=r("."+n);h&&a&&!s.closest("."+this.ft)&&("click"===i&&this.Ct(h),"mousemove"!==i||e(h,"contains",n)||(this.N(l),this.kt(h),this.F=this.gt(h),this.xt({index:this.F,element:this.h,object:this.M[this.F]})))},this.Ct=t=>{t&&0!==this.M.length?(this.K&&e(this.j,"remove","hidden"),this.h.value=s(t),this.wt({index:this.F,element:this.h,object:this.M[this.F],results:this.l}),this.bt||(this.J||this.N(t),this.P()),this.I("remove")):!this.bt&&this.P()},this.gt=t=>Array.prototype.indexOf.call(this.dt,t),this.et=t=>{const{keyCode:i}=t,h=e(this.u,"contains",this.T),n=this.M.length+1;switch(this.jt=r("."+this.q),i){case m:case p:if(t.preventDefault(),n<=1&&this.L||!h)return;if(i===m?(this.F<0&&(this.F=n-1),this.F-=1):(this.F+=1,this.F>=n&&(this.F=0)),this.N(this.jt),this.F>=0&&this.F{const i=this.yt+"-"+this.gt(s);t(s,{id:i,"aria-selected":"true",addClass:this.q}),a(this.h,i),n(s,this.o,this.ct,this.l)},this.N=s=>{s&&t(s,{id:"",removeClass:this.q,"aria-selected":"false"})},this.i=()=>{this.K&&(t(this.j,{class:this.m+"-clear hidden",type:"button",title:this.It,"aria-label":this.It}),this.h.insertAdjacentElement("afterend",this.j))},this.rerender=t=>{const s=null!=t&&t.trim()?t.trim():this.h.value;null!=t&&t.trim()&&(this.h.value=t.trim(),this.I("update",this.h));const i=s.replace(this.O.expression,this.O.replacement);this.B(i.trim())},this.destroy=()=>{this.K&&e(this.j,"add","hidden"),this.h.value="",this.h.focus(),this.l.textContent="",this.P(),this.Z(),this.St(this.h),this.H(),c(this.h,"keydown",this.et),c(this.h,"click",this.nt),c(document,"click",this.lt)},this.G=b,this.h=document.getElementById(b),this.Y=(M=T,Boolean(M&&"function"==typeof M.then)?T:t=>{let{currentValue:s,element:i}=t;return Promise.resolve(T({currentValue:s,element:i}))}),this.ot=E,this.C=q,this.wt=G,this.xt=L,this.ut=J,this.St=N,this._=F,this.W=z,this.R=x,this.X=k,this.K=y,this.k=C,this.L=g,this.U=w,this.v=j,this.ct=A,this.ft=$,this.It=P||"clear the search query",this.m=B?B+"-auto":"auto",this.bt=S,this.J=V,this.$=O,this.S=I,this.A=null,this.o=this.m+"-"+this.G+"-results",this.V="data-cache-auto-"+this.G,this.it=this.m+"-is-loading",this.T=this.m+"-is-active",this.q=this.m+"-selected",this.yt=this.m+"-selected-option",this.ht=this.m+"-error",this.u=l("div"),this.l=l("ul"),this.j=l("button"),this.O=R,this.Vt={expression:/[|\\{}()[\]^$+*?]/g,replacement:"\\$&"},this.O.replacement||(this.O.replacement=this.Vt.replacement),this.O.expression||(this.O.expression=this.Vt.expression),this.t()}}}(); +var Autocomplete=function(){"use strict";const t=(t,s)=>{for(let i in s)"addClass"===i?e(t,"add",s[i]):"removeClass"===i?e(t,"remove",s[i]):t.setAttribute(i,s[i])},s=t=>(t.firstElementChild||t).textContent.trim(),i=(t,s)=>{t.scrollTop=t.offsetTop-s.offsetHeight},h=function(t,s){void 0===t&&(t=!1),t&&(e(t,"remove","hidden"),r(t,"click",s))},e=(t,s,i)=>t.classList[s](i),a=(s,i)=>{t(s,{"aria-activedescendant":i||""})},n=(t,s,i,h)=>{const e=h.previousSibling,a=e?e.offsetHeight:0;if("0"==t.getAttribute("aria-posinset")&&(h.scrollTop=t.offsetTop-((t,s)=>{const i=document.querySelectorAll("#"+t+" > li:not(."+s+")");let h=0;return[].slice.call(i).map((t=>h+=t.offsetHeight)),h})(s,i)),t.offsetTop-ah.scrollTop+h.offsetHeight&&(h.scrollTop=s-h.offsetHeight)}},l=t=>document.createElement(t),o=t=>document.querySelector(t),r=(t,s,i)=>{t.addEventListener(s,i)},c=(t,s,i)=>{t.removeEventListener(s,i)},d=t=>({"aria-owns":t,"aria-expanded":"false","aria-autocomplete":"list",role:"combobox",removeClass:"auto-expanded"}),u=27,m=13,p=38,v=40,b=9;return class{constructor(f,x){let{delay:y=500,clearButton:C=!0,clearButtonOnInitial:k=!1,howManyCharacters:g=1,selectFirst:w=!1,insertToInput:j=!1,showAllValues:I=!1,cache:S=!1,disableCloseOnSelect:V=!1,preventScrollUp:O=!1,removeResultsWhenInputIsEmpty:R=!1,regex:A={expression:/[|\\{}()[\]^$+*?]/g,replacement:"\\$&"},classGroup:$,classPreventClosing:B,classPrefix:P,ariaLabelClear:T,onSearch:E,onResults:G=(()=>{}),onSubmit:J=(()=>{}),onOpened:N=(()=>{}),onReset:q=(()=>{}),onRender:z=(()=>{}),onClose:F=(()=>{}),noResults:L=(()=>{}),onSelectedItem:M=(()=>{})}=x;var U;this.t=()=>{this.i();const s=d(this.h);var i,e,a,n,l;t(this.l,s),i=this.l,e=this.o,a=this.h,n=this.u,l=this.m,t(e,{id:a,tabIndex:"0",role:"listbox"}),t(n,{addClass:l+"-results-wrapper"}),n.insertAdjacentElement("beforeend",e),i.parentNode.insertBefore(n,i.nextSibling),r(this.l,"input",this.p),this.v&&r(this.l,"click",this.p),this.C({element:this.l,results:this.o}),this.k&&h(this.j,this.destroy)},this.I=(t,s)=>{this.S&&("update"===t?this.l.setAttribute(this.V,s.value):"remove"===t?this.l.removeAttribute(this.V):this.l.value=this.l.getAttribute(this.V))},this.p=t=>{let{target:s,type:i}=t;if("true"===this.l.getAttribute("aria-expanded")&&"click"===i)return;const h=s.value.replace(this.O.expression,this.O.replacement);this.I("update",s);const e=this.v?0:this.R;clearTimeout(this.A),this.A=setTimeout((()=>{this.$&&0===s.value.length?this.destroy():this.B(h.trim())}),e)},this.P=()=>{var s;e(this.u,"remove",this.T);const i=d(this.h),h=this.G?i:{...i,"aria-activedescendant":""};t(this.l,h),this.G||(this.J(o("."+this.N)),this.q=this.F?0:-1),(0==(null==(s=this.L)?void 0:s.length)&&!this.M||this.v)&&(this.o.textContent=""),this.U()},this.B=t=>{this.W=t,this.D(!0),h(this.j,this.destroy),0==t.length&&this.H&&e(this.j,"add","hidden"),this.K>t.length&&!this.v?this.D():this.X({currentValue:t,element:this.l}).then((s=>{const i=this.l.value.length,h=s.length;this.L=Array.isArray(s)?s:JSON.parse(JSON.stringify(s)),this.D(),this.Y(),0==h&&0==i&&e(this.j,"add","hidden"),0==h&&i?(e(this.l,"remove","auto-expanded"),this.P(),this.Z({element:this.l,currentValue:t,template:this._}),this.tt()):(h>0||(t=>t&&"object"==typeof t&&t.constructor===Object)(s))&&(this.q=this.F?0:-1,this._(),this.tt())})).catch((()=>{this.D(),this.P()}))},this.D=t=>this.l.parentNode.classList[t?"add":"remove"](this.st),this.Y=()=>e(this.l,"remove",this.it),this.tt=()=>{r(this.l,"keydown",this.ht),r(this.l,"click",this.et),r(document,"click",this.nt),["mousemove","click"].map((t=>{r(this.o,t,this.lt)}))},this._=s=>{t(this.l,{"aria-expanded":"true",addClass:this.m+"-expanded"}),this.o.textContent="";const h=0===this.L.length?this.ot({currentValue:this.W,matches:0,template:s}):this.ot({currentValue:this.W,matches:this.L,classGroup:this.rt});this.o.insertAdjacentHTML("afterbegin",h),e(this.u,"add",this.T);const a=this.rt?":not(."+this.rt+")":"";this.ct=document.querySelectorAll("#"+this.h+" > li"+a),(s=>{for(let i=0;i{let{target:s}=t,i=null;(s.closest("ul")&&this.vt||s.closest("."+this.bt))&&(i=!0),s.id===this.ft||i||this.P()},this.ut=()=>{if(this.J(o("."+this.N)),!this.F)return;const{firstElementChild:s}=this.o,i=this.rt&&this.L.length>0&&this.F?s.nextElementSibling:s;this.xt({index:this.q,element:this.l,object:this.L[this.q]}),t(i,{id:this.yt+"-0",addClass:this.N,"aria-selected":"true"}),a(this.l,this.yt+"-0")},this.et=()=>{if(this.o.textContent.length>0&&!e(this.u,"contains",this.T)){if(t(this.l,{"aria-expanded":"true",addClass:this.m+"-expanded"}),e(this.u,"add",this.T),this.G||(i(this.o,this.u),this.ut()),this.dt({type:"showItems",element:this.l,results:this.o}),!this.S)return;this.I("update",this.l)}},this.lt=t=>{t.preventDefault();const{target:s,type:i}=t,h=s.closest("li"),a=null==h?void 0:h.hasAttribute("role"),n=this.N,l=o("."+n);h&&a&&!s.closest("."+this.bt)&&("click"===i&&this.Ct(h),"mousemove"!==i||e(h,"contains",n)||(this.J(l),this.kt(h),this.q=this.gt(h),this.xt({index:this.q,element:this.l,object:this.L[this.q]})))},this.Ct=t=>{t&&0!==this.L.length?(this.H&&e(this.j,"remove","hidden"),this.l.value=s(t),this.wt({index:this.q,element:this.l,object:this.L[this.q],results:this.o}),this.vt||(this.G||this.J(t),this.P()),this.I("remove")):!this.vt&&this.P()},this.gt=t=>Array.prototype.indexOf.call(this.ct,t),this.ht=t=>{const{keyCode:i}=t,h=e(this.u,"contains",this.T),n=this.L.length+1;switch(this.jt=o("."+this.N),i){case p:case v:if(t.preventDefault(),n<=1&&this.F||!h)return;if(i===p?(this.q<0&&(this.q=n-1),this.q-=1):(this.q+=1,this.q>=n&&(this.q=0)),this.J(this.jt),this.q>=0&&this.q{const i=this.yt+"-"+this.gt(s);t(s,{id:i,"aria-selected":"true",addClass:this.N}),a(this.l,i),n(s,this.h,this.rt,this.o)},this.J=s=>{s&&t(s,{id:"",removeClass:this.N,"aria-selected":"false"})},this.i=()=>{this.H&&(t(this.j,{class:this.m+"-clear hidden",type:"button",title:this.It,"aria-label":this.It}),this.l.insertAdjacentElement("afterend",this.j))},this.rerender=t=>{const s=null!=t&&t.trim()?t.trim():this.l.value;null!=t&&t.trim()&&(this.l.value=t.trim(),this.I("update",this.l));const i=s.replace(this.O.expression,this.O.replacement);this.B(i.trim())},this.destroy=()=>{this.H&&e(this.j,"add","hidden"),this.l.value="",this.l.focus(),this.o.textContent="",this.P(),this.Y(),this.St(this.l),this.D(),c(this.l,"keydown",this.ht),c(this.l,"click",this.et),c(document,"click",this.nt)},this.ft=f,this.l=document.getElementById(f),this.X=(U=E,Boolean(U&&"function"==typeof U.then)?E:t=>{let{currentValue:s,element:i}=t;return Promise.resolve(E({currentValue:s,element:i}))}),this.ot=G,this.C=z,this.wt=J,this.xt=M,this.dt=N,this.St=q,this.Z=L,this.U=F,this.R=y,this.K=g,this.H=C,this.k=k,this.F=w,this.M=j,this.v=I,this.rt=$,this.bt=B,this.It=T||"clear the search query",this.m=P?P+"-auto":"auto",this.vt=V,this.G=O,this.$=R,this.S=S,this.A=null,this.h=this.m+"-"+this.ft+"-results",this.V="data-cache-auto-"+this.ft,this.st=this.m+"-is-loading",this.T=this.m+"-is-active",this.N=this.m+"-selected",this.yt=this.m+"-selected-option",this.it=this.m+"-error",this.u=l("div"),this.o=l("ul"),this.j=l("button"),this.O=A,this.Vt={expression:/[|\\{}()[\]^$+*?]/g,replacement:"\\$&"},this.O.replacement||(this.O.replacement=this.Vt.replacement),this.O.expression||(this.O.expression=this.Vt.expression),this.t()}}}(); diff --git a/dist/js/autocomplete.js b/dist/js/autocomplete.js index 3f1ba32..c0ec216 100644 --- a/dist/js/autocomplete.js +++ b/dist/js/autocomplete.js @@ -1,6 +1,6 @@ /*! * @name autocomplete -* @version 2.0.0 +* @version 2.0.1 * @author Grzegorz Tomicki * @link https://github.com/tomickigrzegorz/autocomplete * @license MIT @@ -32,7 +32,7 @@ var Autocomplete = (function () { tabindex: "-1", "aria-selected": "false", "aria-setsize": itemsLi.length, - "aria-posinset": i + "aria-posinset": i + 1 }); } }; @@ -92,6 +92,15 @@ var Autocomplete = (function () { const offEvent = (element, action, callback) => { element.removeEventListener(action, callback); }; + const ariaActiveDescendantDefault = id => { + return { + "aria-owns": id, + "aria-expanded": "false", + "aria-autocomplete": "list", + role: "combobox", + removeClass: "auto-expanded" + }; + }; const keyCodes = { ESC: 27, @@ -135,6 +144,8 @@ var Autocomplete = (function () { } = _ref; this._initial = () => { this._clearbutton(); + const ariaAcrivedescentDefault = ariaActiveDescendantDefault(this._outputUl); + setAttributes(this._root, ariaAcrivedescentDefault); output(this._root, this._resultList, this._outputUl, this._resultWrap, this._prefix); onEvent(this._root, "input", this._handleInput); this._showAll && onEvent(this._root, "click", this._handleInput); @@ -180,13 +191,7 @@ var Autocomplete = (function () { }; this._reset = () => { classList(this._resultWrap, "remove", this._isActive); - const ariaAcrivedescentDefault = { - "aria-owns": `${this._id}-list`, - "aria-expanded": "false", - "aria-autocomplete": "list", - role: "combobox", - removeClass: "auto-expanded" - }; + const ariaAcrivedescentDefault = ariaActiveDescendantDefault(this._outputUl); const ariaAcrivedescent = this._preventScrollUp ? ariaAcrivedescentDefault : { ...ariaAcrivedescentDefault, "aria-activedescendant": "" diff --git a/dist/js/autocomplete.js.map b/dist/js/autocomplete.js.map index 6632ed3..5ea26c3 100644 --- a/dist/js/autocomplete.js.map +++ b/dist/js/autocomplete.js.map @@ -1 +1 @@ -{"version":3,"file":"autocomplete.js","sources":["../../sources/js/utils/function.js","../../sources/js/utils/keyCodes.js","../../sources/js/script.js"],"sourcesContent":["/**\r\n * Check is a Object\r\n * @param {Object} value\r\n * @returns {Boolean}\r\n */\r\nconst isObject = (value) =>\r\n value && typeof value === \"object\" && value.constructor === Object;\r\n\r\n/**\r\n * Check if is a Promise\r\n * https://stackoverflow.com/a/53955664/10424385\r\n *\r\n * @param {Object} value\r\n * @returns {Boolean}\r\n */\r\nconst isPromise = (value) => Boolean(value && typeof value.then === \"function\");\r\n\r\n/**\r\n * Set attributes to element\r\n *\r\n * @param {HTMLElement} el\r\n * @param {Object} object\r\n */\r\nconst setAttributes = (el, object) => {\r\n for (let key in object) {\r\n if (key === \"addClass\") {\r\n classList(el, \"add\", object[key]);\r\n } else if (key === \"removeClass\") {\r\n classList(el, \"remove\", object[key]);\r\n } else {\r\n el.setAttribute(key, object[key]);\r\n }\r\n }\r\n};\r\n\r\n/**\r\n * Get first element from child\r\n *\r\n * @param {HTMLElement} element\r\n * @returns {HTMLELement}\r\n */\r\nconst getFirstElement = (element) =>\r\n (element.firstElementChild || element).textContent.trim();\r\n\r\n/**\r\n * Scroll to top result-list\r\n * @param {HTMLElement} resultList\r\n * @param {HTMLElement} resultWrap\r\n */\r\nconst scrollResultsToTop = (resultList, resultWrap) => {\r\n // if there is an overflow of ul element, after\r\n // opening we always move ul to the top of the results\r\n resultList.scrollTop = resultList.offsetTop - resultWrap.offsetHeight;\r\n};\r\n\r\n/**\r\n * Adding role, tabindex, aria and call handleMouse\r\n *\r\n * @param {HTMLElement} itemsLi\r\n */\r\nconst addAriaToAllLiElements = (itemsLi) => {\r\n // add role to all li elements\r\n for (let i = 0; i < itemsLi.length; i++) {\r\n setAttributes(itemsLi[i], {\r\n role: \"option\",\r\n tabindex: \"-1\",\r\n \"aria-selected\": \"false\",\r\n \"aria-setsize\": itemsLi.length,\r\n \"aria-posinset\": i,\r\n });\r\n }\r\n};\r\n\r\n/**\r\n * Show btn to clear data\r\n *\r\n * @param {HTMLElement} clearButton - button to clear data\r\n * @param {Function} destroy - destroy function\r\n */\r\nconst showBtnToClearData = (clearButton = false, destroy) => {\r\n if (!clearButton) return;\r\n\r\n classList(clearButton, \"remove\", \"hidden\");\r\n // add event to clear button\r\n onEvent(clearButton, \"click\", destroy);\r\n};\r\n\r\n/**\r\n * ClassList add/remove/contains\r\n *\r\n * @param {HTMLElement} element - html element\r\n * @param {String} action - add/remove/contains\r\n * @param {String} className - class name\r\n */\r\nconst classList = (element, action, className) =>\r\n element.classList[action](className);\r\n\r\n/**\r\n * Set aria-activedescendant\r\n *\r\n * @param {HTMLElement} root - search input\r\n * @param {String} type\r\n */\r\nconst setAriaActivedescendant = (root, type) => {\r\n setAttributes(root, {\r\n \"aria-activedescendant\": type || \"\",\r\n });\r\n};\r\n\r\n/**\r\n * Get height of ul without group class\r\n *\r\n * @param {String} outputUl\r\n * @param {String} classGroup\r\n * @returns {Number}\r\n */\r\nconst getClassGroupHeight = (outputUl, classGroup) => {\r\n // get height of ul without group class\r\n const allLiElements = document.querySelectorAll(\r\n `#${outputUl} > li:not(.${classGroup})`,\r\n );\r\n let height = 0;\r\n [].slice.call(allLiElements).map((el) => (height += el.offsetHeight));\r\n\r\n // return height\r\n return height;\r\n};\r\n\r\n/**\r\n * Scroll into view when press up/down arrows\r\n *\r\n * @param {HTMLElement} target\r\n * @param {HTMLElement} outputUl\r\n * @param {String} classGroup\r\n * @param {HTMLElement} resultList\r\n */\r\nconst followActiveElement = (target, outputUl, classGroup, resultList) => {\r\n const previusElement = resultList.previousSibling;\r\n\r\n const previusElementHeight = previusElement ? previusElement.offsetHeight : 0;\r\n\r\n if (target.getAttribute(\"aria-posinset\") == \"0\") {\r\n resultList.scrollTop =\r\n target.offsetTop - getClassGroupHeight(outputUl, classGroup);\r\n }\r\n\r\n if (target.offsetTop - previusElementHeight < resultList.scrollTop) {\r\n resultList.scrollTop = target.offsetTop - previusElementHeight;\r\n } else {\r\n const offsetBottom =\r\n target.offsetTop + target.offsetHeight - previusElementHeight;\r\n const scrollBottom = resultList.scrollTop + resultList.offsetHeight;\r\n if (offsetBottom > scrollBottom) {\r\n resultList.scrollTop = offsetBottom - resultList.offsetHeight;\r\n }\r\n }\r\n};\r\n\r\n/**\r\n * Create output-list and put after search input\r\n *\r\n * @param {HTMLElement} root - search input\r\n * @param {HTMLElement} resultList - output-list ul\r\n * @param {String} outputUl - id name of output-list\r\n * @param {HTMLElement} resultWrap - wrapper ul element\r\n * @param {String} prefix - add prefix to all class auto\r\n */\r\nconst output = (root, resultList, outputUl, resultWrap, prefix) => {\r\n // set attribute to results-list\r\n setAttributes(resultList, {\r\n id: outputUl,\r\n tabIndex: \"0\",\r\n role: \"listbox\",\r\n });\r\n\r\n // add class to wrap element\r\n setAttributes(resultWrap, {\r\n addClass: `${prefix}-results-wrapper`,\r\n });\r\n\r\n // insert the results into the wrap element\r\n resultWrap.insertAdjacentElement(\"beforeend\", resultList);\r\n\r\n // insert the wrap element after the search input\r\n root.parentNode.insertBefore(resultWrap, root.nextSibling);\r\n};\r\n\r\n/**\r\n * Create element\r\n *\r\n * @param {String} type - type of element\r\n * @returns {HTMLDivElement}\r\n */\r\nconst createElement = (type) => document.createElement(type);\r\n\r\n/**\r\n * Get element\r\n *\r\n * @param {String} element\r\n * @returns {HTMLElement}\r\n */\r\nconst select = (element) => document.querySelector(element);\r\n\r\n/**\r\n * Event listeners\r\n *\r\n * @param {HTMLElement} element\r\n * @param {String} action\r\n * @param {Function} callback\r\n */\r\nconst onEvent = (element, action, callback) => {\r\n element.addEventListener(action, callback);\r\n};\r\n\r\n/**\r\n * Remove event listeners\r\n */\r\nconst offEvent = (element, action, callback) => {\r\n element.removeEventListener(action, callback);\r\n};\r\n\r\nexport {\r\n addAriaToAllLiElements,\r\n classList,\r\n createElement,\r\n followActiveElement,\r\n getFirstElement,\r\n isObject,\r\n isPromise,\r\n offEvent,\r\n onEvent,\r\n output,\r\n scrollResultsToTop,\r\n select,\r\n setAriaActivedescendant,\r\n setAttributes,\r\n showBtnToClearData,\r\n};\r\n","/**\r\n * Key codes\r\n */\r\nconst keyCodes = {\r\n ESC: 27,\r\n ENTER: 13,\r\n UP: 38,\r\n DOWN: 40,\r\n TAB: 9,\r\n};\r\n\r\nexport default keyCodes;\r\n","import {\r\n addAriaToAllLiElements,\r\n classList,\r\n createElement,\r\n followActiveElement,\r\n getFirstElement,\r\n isObject,\r\n isPromise,\r\n offEvent,\r\n onEvent,\r\n output,\r\n scrollResultsToTop,\r\n select,\r\n setAriaActivedescendant,\r\n setAttributes,\r\n showBtnToClearData,\r\n} from \"./utils/function\";\r\n\r\nimport keyCodes from \"./utils/keyCodes\";\r\n\r\n/**\r\n * @class Autocomplete\r\n */\r\nexport default class Autocomplete {\r\n /**\r\n * Constructor\r\n *\r\n * @param {String} element\r\n * @param {Object} object\r\n */\r\n constructor(\r\n element,\r\n {\r\n delay = 500,\r\n clearButton = true,\r\n clearButtonOnInitial = false,\r\n howManyCharacters = 1,\r\n selectFirst = false,\r\n insertToInput = false,\r\n showAllValues = false,\r\n cache = false,\r\n disableCloseOnSelect = false,\r\n preventScrollUp = false,\r\n removeResultsWhenInputIsEmpty = false,\r\n regex = { expression: /[|\\\\{}()[\\]^$+*?]/g, replacement: \"\\\\$&\" },\r\n classGroup,\r\n classPreventClosing,\r\n classPrefix,\r\n ariaLabelClear,\r\n onSearch,\r\n onResults = () => {},\r\n onSubmit = () => {},\r\n onOpened = () => {},\r\n onReset = () => {},\r\n onRender = () => {},\r\n onClose = () => {},\r\n noResults = () => {},\r\n onSelectedItem = () => {},\r\n },\r\n ) {\r\n this._id = element;\r\n this._root = document.getElementById(element);\r\n this._onSearch = isPromise(onSearch)\r\n ? onSearch\r\n : ({ currentValue, element }) =>\r\n Promise.resolve(onSearch({ currentValue, element }));\r\n this._onResults = onResults;\r\n this._onRender = onRender;\r\n this._onSubmit = onSubmit;\r\n this._onSelected = onSelectedItem;\r\n this._onOpened = onOpened;\r\n this._onReset = onReset;\r\n this._noResults = noResults;\r\n this._onClose = onClose;\r\n\r\n this._delay = delay;\r\n this._characters = howManyCharacters;\r\n this._clearButton = clearButton;\r\n this._clearButtonOnInitial = clearButtonOnInitial;\r\n this._selectFirst = selectFirst;\r\n this._toInput = insertToInput;\r\n this._showAll = showAllValues;\r\n this._classGroup = classGroup;\r\n this._prevClosing = classPreventClosing;\r\n this._clearBtnAriLabel = ariaLabelClear\r\n ? ariaLabelClear\r\n : \"clear the search query\";\r\n this._prefix = classPrefix ? `${classPrefix}-auto` : \"auto\";\r\n this._disable = disableCloseOnSelect;\r\n this._preventScrollUp = preventScrollUp;\r\n this._removeResultsWhenInputIsEmpty = removeResultsWhenInputIsEmpty;\r\n\r\n // default config\r\n this._cache = cache;\r\n this._timeout = null;\r\n this._outputUl = `${this._prefix}-${this._id}-results`;\r\n this._cacheData = `data-cache-auto-${this._id}`;\r\n this._isLoading = `${this._prefix}-is-loading`;\r\n this._isActive = `${this._prefix}-is-active`;\r\n this._activeList = `${this._prefix}-selected`;\r\n this._selectedOption = `${this._prefix}-selected-option`;\r\n this._err = `${this._prefix}-error`;\r\n this._resultWrap = createElement(\"div\");\r\n this._resultList = createElement(\"ul\");\r\n this._clearBtn = createElement(\"button\");\r\n\r\n // ----------------------------------------\r\n // regex\r\n\r\n this._regex = regex;\r\n this._defaultExpression = {\r\n expression: /[|\\\\{}()[\\]^$+*?]/g,\r\n replacement: \"\\\\$&\",\r\n };\r\n\r\n // if regex is don't have replacement then set default\r\n if (!this._regex.replacement) {\r\n this._regex.replacement = this._defaultExpression.replacement;\r\n }\r\n\r\n // if regex is don't have expression then set default\r\n if (!this._regex.expression) {\r\n this._regex.expression = this._defaultExpression.expression;\r\n }\r\n\r\n // ----------------------------------------\r\n\r\n this._initial();\r\n }\r\n\r\n /**\r\n * Initial function\r\n */\r\n _initial = () => {\r\n this._clearbutton();\r\n\r\n output(\r\n this._root,\r\n this._resultList,\r\n this._outputUl,\r\n this._resultWrap,\r\n this._prefix,\r\n );\r\n\r\n // default aria\r\n onEvent(this._root, \"input\", this._handleInput);\r\n\r\n // show all values on click root input\r\n this._showAll && onEvent(this._root, \"click\", this._handleInput);\r\n\r\n // calback functions\r\n this._onRender({\r\n element: this._root,\r\n results: this._resultList,\r\n });\r\n\r\n // show clear button if\r\n if (this._clearButtonOnInitial) {\r\n showBtnToClearData(this._clearBtn, this.destroy);\r\n }\r\n };\r\n\r\n /**\r\n * Actions on input\r\n *\r\n * @param {String} type - set attribute depending on type\r\n * @param {String} target\r\n */\r\n _cacheAct = (type, target) => {\r\n if (!this._cache) return;\r\n\r\n if (type === \"update\") {\r\n this._root.setAttribute(this._cacheData, target.value);\r\n } else if (type === \"remove\") {\r\n this._root.removeAttribute(this._cacheData);\r\n } else {\r\n this._root.value = this._root.getAttribute(this._cacheData);\r\n }\r\n };\r\n\r\n /**\r\n * Handle input\r\n *\r\n * @param {Event} object\r\n */\r\n _handleInput = ({ target, type }) => {\r\n if (\r\n this._root.getAttribute(\"aria-expanded\") === \"true\" &&\r\n type === \"click\"\r\n ) {\r\n return;\r\n }\r\n\r\n // replace all special characters\r\n const regex = target.value.replace(\r\n this._regex.expression,\r\n this._regex.replacement,\r\n );\r\n\r\n // update data attribute cache\r\n this._cacheAct(\"update\", target);\r\n\r\n const delay = this._showAll ? 0 : this._delay;\r\n // clear timeout\r\n clearTimeout(this._timeout);\r\n this._timeout = setTimeout(() => {\r\n // removeResultsWhenInputIsEmpty\r\n // remove results when input is empty\r\n if (this._removeResultsWhenInputIsEmpty) {\r\n if (target.value.length === 0) {\r\n this.destroy();\r\n return;\r\n }\r\n }\r\n\r\n this._searchItem(regex.trim());\r\n }, delay);\r\n };\r\n\r\n /**\r\n * Default aria\r\n */\r\n _reset = () => {\r\n // remove class isActive\r\n classList(this._resultWrap, \"remove\", this._isActive);\r\n\r\n const ariaAcrivedescentDefault = {\r\n \"aria-owns\": `${this._id}-list`,\r\n \"aria-expanded\": \"false\",\r\n \"aria-autocomplete\": \"list\",\r\n role: \"combobox\",\r\n removeClass: \"auto-expanded\",\r\n };\r\n\r\n const ariaAcrivedescent = this._preventScrollUp\r\n ? ariaAcrivedescentDefault\r\n : { ...ariaAcrivedescentDefault, \"aria-activedescendant\": \"\" };\r\n\r\n // set attributes to root - input\r\n setAttributes(this._root, ariaAcrivedescent);\r\n\r\n if (!this._preventScrollUp) {\r\n // set default aria-selected, remove id and remove class 'auto-selected'\r\n this._removeAria(select(`.${this._activeList}`));\r\n\r\n // set index\r\n this._index = this._selectFirst ? 0 : -1;\r\n }\r\n\r\n // remove result when lengh = 0 and insertToInput is false\r\n // https://github.com/tomickigrzegorz/autocomplete/issues/136\r\n if ((this._matches?.length == 0 && !this._toInput) || this._showAll) {\r\n this._resultList.textContent = \"\";\r\n }\r\n\r\n // callback function\r\n this._onClose();\r\n };\r\n\r\n /**\r\n * The async function gets the text from the search\r\n * and returns the matching array\r\n *\r\n * @param {String} value\r\n */\r\n _searchItem = (value) => {\r\n this._value = value;\r\n\r\n // if searching show loading icon\r\n this._onLoading(true);\r\n\r\n // hide button clear\r\n showBtnToClearData(this._clearBtn, this.destroy);\r\n\r\n // if there is no value and clearButton is true\r\n if (value.length == 0 && this._clearButton) {\r\n classList(this._clearBtn, \"add\", \"hidden\");\r\n }\r\n\r\n // if declare characters more then value.len and showAll is false\r\n // remove class isActive\r\n if (this._characters > value.length && !this._showAll) {\r\n this._onLoading();\r\n return;\r\n }\r\n\r\n // callblack function onSearch\r\n this._onSearch({ currentValue: value, element: this._root })\r\n .then((result) => {\r\n const rootValueLength = this._root.value.length;\r\n const resultLength = result.length;\r\n // set no result\r\n this._matches = Array.isArray(result)\r\n ? result\r\n : JSON.parse(JSON.stringify(result));\r\n\r\n this._onLoading();\r\n this._error();\r\n\r\n // if use destroy() method\r\n if (resultLength == 0 && rootValueLength == 0) {\r\n classList(this._clearBtn, \"add\", \"hidden\");\r\n }\r\n\r\n if (resultLength == 0 && rootValueLength) {\r\n classList(this._root, \"remove\", \"auto-expanded\");\r\n this._reset();\r\n this._noResults({\r\n element: this._root,\r\n currentValue: value,\r\n template: this._results,\r\n });\r\n this._events();\r\n } else if (resultLength > 0 || isObject(result)) {\r\n this._index = this._selectFirst ? 0 : -1;\r\n this._results();\r\n this._events();\r\n }\r\n })\r\n .catch(() => {\r\n this._onLoading();\r\n this._reset();\r\n });\r\n };\r\n\r\n /**\r\n * Set or remove loading class\r\n *\r\n * @param {Boolean} type\r\n */\r\n _onLoading = (type) =>\r\n this._root.parentNode.classList[type ? \"add\" : \"remove\"](this._isLoading);\r\n\r\n /**\r\n * Set error class to the root element\r\n */\r\n _error = () => classList(this._root, \"remove\", this._err);\r\n\r\n /**\r\n * Events\r\n */\r\n _events = () => {\r\n // handle click on keydown [up, down, enter, tab, esc]\r\n onEvent(this._root, \"keydown\", this._handleKeys);\r\n\r\n onEvent(this._root, \"click\", this._handleShowItems);\r\n\r\n // close expanded items\r\n onEvent(document, \"click\", this._handleDocClick);\r\n\r\n // temporarily disabled mouseleave\r\n [\"mousemove\", \"click\"].map((eventType) => {\r\n onEvent(this._resultList, eventType, this._handleMouse);\r\n });\r\n };\r\n\r\n /**\r\n * Results\r\n *\r\n * @param {HTMLElement|String} template - html or string returned from the function,\r\n * look at the example - https://github.com/tomickigrzegorz/autocomplete/blob/master/docs/js/examples/no-results.js#L30\r\n */\r\n _results = (template) => {\r\n // set attribute to root\r\n setAttributes(this._root, {\r\n \"aria-expanded\": \"true\",\r\n addClass: `${this._prefix}-expanded`,\r\n });\r\n\r\n // clear result list\r\n this._resultList.textContent = \"\";\r\n\r\n // add all found records to otput ul\r\n const dataResults =\r\n this._matches.length === 0\r\n ? this._onResults({\r\n currentValue: this._value,\r\n matches: 0,\r\n template,\r\n })\r\n : this._onResults({\r\n currentValue: this._value,\r\n matches: this._matches,\r\n classGroup: this._classGroup,\r\n });\r\n\r\n // add data to ul\r\n this._resultList.insertAdjacentHTML(\"afterbegin\", dataResults);\r\n\r\n // add class isActive\r\n classList(this._resultWrap, \"add\", this._isActive);\r\n\r\n const checkIfClassGroupExist = this._classGroup\r\n ? `:not(.${this._classGroup})`\r\n : \"\";\r\n\r\n this._itemsLi = document.querySelectorAll(\r\n `#${this._outputUl} > li${checkIfClassGroupExist}`,\r\n );\r\n\r\n // adding role, tabindex and aria\r\n addAriaToAllLiElements(this._itemsLi);\r\n\r\n // action on open results\r\n this._onOpened({\r\n type: \"results\",\r\n element: this._root,\r\n results: this._resultList,\r\n });\r\n\r\n // select first element\r\n this._selectFirstElement();\r\n\r\n // move the view item to the first item\r\n // this.resultList.scrollTop = 0;\r\n // if (this._preventScrollUp) return;\r\n scrollResultsToTop(this._resultList, this._resultWrap);\r\n };\r\n\r\n /**\r\n * Hangle click on document\r\n *\r\n * @param {Event} object\r\n */\r\n _handleDocClick = ({ target }) => {\r\n let disableClose = null;\r\n\r\n // if 'target' is a ul and 'disableCloseOnSelect'\r\n // is a 'true' set 'disableClose' on true\r\n if (\r\n (target.closest(\"ul\") && this._disable) ||\r\n // when class classDisableClose\r\n // then do not not close results\r\n target.closest(`.${this._prevClosing}`)\r\n ) {\r\n disableClose = true;\r\n }\r\n\r\n if (target.id !== this._id && !disableClose) {\r\n this._reset();\r\n return;\r\n }\r\n };\r\n\r\n /**\r\n * Select first element\r\n */\r\n _selectFirstElement = () => {\r\n this._removeAria(select(`.${this._activeList}`));\r\n\r\n if (!this._selectFirst) {\r\n return;\r\n }\r\n\r\n const { firstElementChild } = this._resultList;\r\n\r\n const classSelectFirst =\r\n this._classGroup && this._matches.length > 0 && this._selectFirst\r\n ? firstElementChild.nextElementSibling\r\n : firstElementChild;\r\n\r\n // calback function onSelect when first element is true\r\n this._onSelected({\r\n index: this._index,\r\n element: this._root,\r\n object: this._matches[this._index],\r\n });\r\n\r\n // set attribute to first element\r\n setAttributes(classSelectFirst, {\r\n id: `${this._selectedOption}-0`,\r\n addClass: this._activeList,\r\n \"aria-selected\": \"true\",\r\n });\r\n\r\n // set aria active descendant\r\n setAriaActivedescendant(this._root, `${this._selectedOption}-0`);\r\n };\r\n\r\n /**\r\n * show items when items.length > 0 and is not empty\r\n */\r\n _handleShowItems = () => {\r\n // if resultWrap is not active and resultList is not empty\r\n if (\r\n this._resultList.textContent.length > 0 &&\r\n !classList(this._resultWrap, \"contains\", this._isActive)\r\n ) {\r\n // set attribute to root\r\n setAttributes(this._root, {\r\n \"aria-expanded\": \"true\",\r\n addClass: `${this._prefix}-expanded`,\r\n });\r\n\r\n // add isActive class to resultWrap\r\n classList(this._resultWrap, \"add\", this._isActive);\r\n\r\n // move the view item to the first item\r\n // this.resultList.scrollTop = 0;\r\n if (!this._preventScrollUp) {\r\n scrollResultsToTop(this._resultList, this._resultWrap);\r\n // select first element\r\n this._selectFirstElement();\r\n }\r\n\r\n // callback function\r\n this._onOpened({\r\n type: \"showItems\",\r\n element: this._root,\r\n results: this._resultList,\r\n });\r\n\r\n if (!this._cache) return;\r\n this._cacheAct(\"update\", this._root);\r\n }\r\n };\r\n\r\n /**\r\n * Adding text from the list when li is clicking\r\n * or adding aria-selected to li elements\r\n *\r\n * @param {Event} event\r\n */\r\n _handleMouse = (event) => {\r\n event.preventDefault();\r\n\r\n const { target, type } = event;\r\n const targetClosest = target.closest(\"li\");\r\n const targetClosestRole = targetClosest?.hasAttribute(\"role\");\r\n const activeClass = this._activeList;\r\n const activeClassElement = select(`.${activeClass}`);\r\n\r\n if (\r\n !targetClosest ||\r\n !targetClosestRole ||\r\n target.closest(`.${this._prevClosing}`)\r\n ) {\r\n return;\r\n }\r\n\r\n if (type === \"click\") {\r\n // click on li get element\r\n // get text from clicked li\r\n this._getTextFromLi(targetClosest);\r\n }\r\n\r\n if (\r\n type === \"mousemove\" &&\r\n !classList(targetClosest, \"contains\", activeClass)\r\n ) {\r\n this._removeAria(activeClassElement);\r\n\r\n // add aria to li\r\n this._setAria(targetClosest);\r\n this._index = this._indexLiSelected(targetClosest);\r\n\r\n this._onSelected({\r\n index: this._index,\r\n element: this._root,\r\n object: this._matches[this._index],\r\n });\r\n }\r\n };\r\n\r\n /**\r\n * Get text from li on enter or click\r\n *\r\n * @param {HTMLElement} element\r\n */\r\n _getTextFromLi = (element) => {\r\n if (!element || this._matches.length === 0) {\r\n // set default settings\r\n !this._disable && this._reset();\r\n\r\n return;\r\n }\r\n\r\n // show clearBtn when select element\r\n this._clearButton && classList(this._clearBtn, \"remove\", \"hidden\");\r\n\r\n // get first element from li and set it to root\r\n this._root.value = getFirstElement(element);\r\n\r\n // onSubmit passing text to function\r\n this._onSubmit({\r\n index: this._index,\r\n element: this._root,\r\n object: this._matches[this._index],\r\n results: this._resultList,\r\n });\r\n\r\n // set default settings\r\n if (!this._disable) {\r\n if (!this._preventScrollUp) {\r\n this._removeAria(element);\r\n }\r\n this._reset();\r\n }\r\n\r\n // remove cache\r\n this._cacheAct(\"remove\");\r\n };\r\n\r\n /**\r\n * Return which li element was selected\r\n * by hovering the mouse over\r\n *\r\n * @param {HTMLElement} target\r\n * @returns {Number}\r\n */\r\n _indexLiSelected = (target) =>\r\n // get index of li element\r\n Array.prototype.indexOf.call(this._itemsLi, target);\r\n\r\n /**\r\n * Navigating the elements li and enter\r\n *\r\n * @param {Event} event\r\n */\r\n _handleKeys = (event) => {\r\n const { keyCode } = event;\r\n\r\n const resultList = classList(this._resultWrap, \"contains\", this._isActive);\r\n\r\n const matchesLength = this._matches.length + 1;\r\n this._selectedLi = select(`.${this._activeList}`);\r\n\r\n // switch between keys\r\n switch (keyCode) {\r\n case keyCodes.UP:\r\n case keyCodes.DOWN:\r\n // Wrong cursor position in the input field #62\r\n // Prevents the cursor from moving to the beginning\r\n // of input as the cursor hovers over the results.\r\n event.preventDefault();\r\n\r\n if ((matchesLength <= 1 && this._selectFirst) || !resultList) {\r\n return;\r\n }\r\n\r\n // if keyCode is up\r\n if (keyCode === keyCodes.UP) {\r\n if (this._index < 0) {\r\n this._index = matchesLength - 1;\r\n }\r\n this._index -= 1;\r\n } else {\r\n this._index += 1;\r\n if (this._index >= matchesLength) {\r\n this._index = 0;\r\n }\r\n }\r\n\r\n // remove aria-selected\r\n this._removeAria(this._selectedLi);\r\n\r\n if (this._index >= 0 && this._index < matchesLength - 1) {\r\n const selectedElement = this._itemsLi[this._index];\r\n\r\n if (this._toInput && resultList) {\r\n this._root.value = getFirstElement(selectedElement);\r\n }\r\n\r\n // callback function\r\n this._onSelected({\r\n index: this._index,\r\n element: this._root,\r\n object: this._matches[this._index],\r\n });\r\n\r\n // set aria-selected\r\n this._setAria(selectedElement);\r\n } else {\r\n // catch action\r\n this._cacheAct();\r\n setAriaActivedescendant(this._root);\r\n\r\n this._onSelected({\r\n index: null,\r\n element: this._root,\r\n object: null,\r\n });\r\n }\r\n\r\n break;\r\n // keycode enter\r\n case keyCodes.ENTER:\r\n // https:github.com/tomickigrzegorz/autocomplete/issues/145\r\n event.preventDefault();\r\n\r\n this._getTextFromLi(this._selectedLi);\r\n break;\r\n\r\n // keycode escape and keycode tab\r\n case keyCodes.TAB:\r\n case keyCodes.ESC:\r\n event.stopPropagation();\r\n this._reset();\r\n\r\n break;\r\n default:\r\n break;\r\n }\r\n };\r\n\r\n /**\r\n * Set aria label on item li\r\n *\r\n * @param {HTMLElement} target\r\n */\r\n _setAria = (target) => {\r\n const selectedOption = `${this._selectedOption}-${this._indexLiSelected(\r\n target,\r\n )}`;\r\n\r\n // set aria to li\r\n setAttributes(target, {\r\n id: selectedOption,\r\n \"aria-selected\": \"true\",\r\n addClass: this._activeList,\r\n });\r\n\r\n setAriaActivedescendant(this._root, selectedOption);\r\n\r\n // scrollIntoView when press up/down arrows\r\n followActiveElement(\r\n target,\r\n this._outputUl,\r\n this._classGroup,\r\n this._resultList,\r\n );\r\n };\r\n\r\n /**\r\n * Remove aria label from item li\r\n *\r\n * @param {HTMLElement} element\r\n */\r\n _removeAria = (element) => {\r\n if (!element) return;\r\n\r\n // remove aria from li\r\n setAttributes(element, {\r\n id: \"\",\r\n removeClass: this._activeList,\r\n \"aria-selected\": \"false\",\r\n });\r\n };\r\n\r\n /**\r\n * Create clear button and\r\n * removing text from the input field\r\n */\r\n _clearbutton = () => {\r\n // stop when clear button is disabled\r\n if (!this._clearButton) return;\r\n\r\n // add aria to clear button\r\n setAttributes(this._clearBtn, {\r\n class: `${this._prefix}-clear hidden`,\r\n type: \"button\",\r\n title: this._clearBtnAriLabel,\r\n \"aria-label\": this._clearBtnAriLabel,\r\n });\r\n\r\n // insert clear button after input - root\r\n this._root.insertAdjacentElement(\"afterend\", this._clearBtn);\r\n };\r\n\r\n /**\r\n * Rerender rows without remove root input and close elements\r\n */\r\n rerender = (inputValue) => {\r\n const text = inputValue?.trim() ? inputValue.trim() : this._root.value;\r\n if (inputValue?.trim()) {\r\n this._root.value = inputValue.trim();\r\n this._cacheAct(\"update\", this._root);\r\n }\r\n const regexText = text.replace(\r\n this._regex.expression,\r\n this._regex.replacement,\r\n );\r\n this._searchItem(regexText.trim());\r\n };\r\n\r\n /**\r\n * Clicking on the clear button\r\n * publick destroy method\r\n */\r\n destroy = () => {\r\n // if clear button is true then add class hidden\r\n this._clearButton && classList(this._clearBtn, \"add\", \"hidden\");\r\n // clear value searchId\r\n this._root.value = \"\";\r\n // set focus\r\n this._root.focus();\r\n // remove li from ul\r\n this._resultList.textContent = \"\";\r\n // set default aria\r\n this._reset();\r\n // remove error if exist\r\n this._error();\r\n // callback function\r\n this._onReset(this._root);\r\n // remove animation on loading\r\n this._onLoading();\r\n\r\n // remove listener\r\n offEvent(this._root, \"keydown\", this._handleKeys);\r\n offEvent(this._root, \"click\", this._handleShowItems);\r\n // remove listener on click on document\r\n offEvent(document, \"click\", this._handleDocClick);\r\n };\r\n}\r\n"],"names":["isObject","value","constructor","Object","isPromise","Boolean","then","setAttributes","el","object","key","classList","setAttribute","getFirstElement","element","firstElementChild","textContent","trim","scrollResultsToTop","resultList","resultWrap","scrollTop","offsetTop","offsetHeight","addAriaToAllLiElements","itemsLi","i","length","role","tabindex","showBtnToClearData","clearButton","destroy","onEvent","action","className","setAriaActivedescendant","root","type","getClassGroupHeight","outputUl","classGroup","allLiElements","document","querySelectorAll","height","slice","call","map","followActiveElement","target","previusElement","previousSibling","previusElementHeight","getAttribute","offsetBottom","scrollBottom","output","prefix","id","tabIndex","addClass","insertAdjacentElement","parentNode","insertBefore","nextSibling","createElement","select","querySelector","callback","addEventListener","offEvent","removeEventListener","keyCodes","ESC","ENTER","UP","DOWN","TAB","Autocomplete","_ref","delay","clearButtonOnInitial","howManyCharacters","selectFirst","insertToInput","showAllValues","cache","disableCloseOnSelect","preventScrollUp","removeResultsWhenInputIsEmpty","regex","expression","replacement","classPreventClosing","classPrefix","ariaLabelClear","onSearch","onResults","onSubmit","onOpened","onReset","onRender","onClose","noResults","onSelectedItem","_initial","_clearbutton","_root","_resultList","_outputUl","_resultWrap","_prefix","_handleInput","_showAll","_onRender","results","_clearButtonOnInitial","_clearBtn","_cacheAct","_cache","_cacheData","removeAttribute","_ref2","replace","_regex","_delay","clearTimeout","_timeout","setTimeout","_removeResultsWhenInputIsEmpty","_searchItem","_reset","_isActive","ariaAcrivedescentDefault","_id","removeClass","ariaAcrivedescent","_preventScrollUp","_removeAria","_activeList","_index","_selectFirst","_matches","_toInput","_onClose","_value","_onLoading","_clearButton","_characters","_onSearch","currentValue","result","rootValueLength","resultLength","Array","isArray","JSON","parse","stringify","_error","_noResults","template","_results","_events","catch","_isLoading","_err","_handleKeys","_handleShowItems","_handleDocClick","eventType","_handleMouse","dataResults","_onResults","matches","_classGroup","insertAdjacentHTML","checkIfClassGroupExist","_itemsLi","_onOpened","_selectFirstElement","_ref3","disableClose","closest","_disable","_prevClosing","classSelectFirst","nextElementSibling","_onSelected","index","_selectedOption","event","preventDefault","targetClosest","targetClosestRole","hasAttribute","activeClass","activeClassElement","_getTextFromLi","_setAria","_indexLiSelected","_onSubmit","prototype","indexOf","keyCode","matchesLength","_selectedLi","selectedElement","stopPropagation","selectedOption","class","title","_clearBtnAriLabel","rerender","inputValue","text","regexText","focus","_onReset","getElementById","_ref4","Promise","resolve","_defaultExpression"],"mappings":";;;;;;;;;;EAKA,MAAMA,QAAQ,GAAIC,KAAK,IACrBA,KAAK,IAAI,OAAOA,KAAK,KAAK,QAA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I,GAAE,IAAI,CAACvD,OAAQ,CAAO,MAAA,CAAA,CAAA;EACnC,IAAA,IAAI,CAACD,WAAW,GAAG7C,aAAa,CAAC,KAAK,CAAC,CAAA;EACvC,IAAA,IAAI,CAAC2C,WAAW,GAAG3C,aAAa,CAAC,IAAI,CAAC,CAAA;EACtC,IAAA,IAAI,CAACoD,SAAS,GAAGpD,aAAa,CAAC,QAAQ,CAAC,CAAA;MAKxC,IAAI,CAAC2D,MAAM,GAAGlC,MAAK,CAAA;MACnB,IAAI,CAACqI,kBAAkB,GAAG;EACxBpI,MAAAA,UAAU,EAAE,oBAAoB;EAChCC,MAAAA,WAAW,EAAE,MAAA;OACd,CAAA;EAGD,IAAA,IAAI,CAAC,IAAI,CAACgC,MAAM,CAAChC,WAAW,EAAE;QAC5B,IAAI,CAACgC,MAAM,CAAChC,WAAW,GAAG,IAAI,CAACmI,kBAAkB,CAACnI,WAAW,CAAA;EAC/D,KAAA;EAGA,IAAA,IAAI,CAAC,IAAI,CAACgC,MAAM,CAACjC,UAAU,EAAE;QAC3B,IAAI,CAACiC,MAAM,CAACjC,UAAU,GAAG,IAAI,CAACoI,kBAAkB,CAACpI,UAAU,CAAA;EAC7D,KAAA;MAIA,IAAI,CAACc,QAAQ,EAAE,CAAA;EACjB,GAAA;EA6qBF;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"autocomplete.js","sources":["../../sources/js/utils/function.js","../../sources/js/utils/keyCodes.js","../../sources/js/script.js"],"sourcesContent":["/**\r\n * Check is a Object\r\n * @param {Object} value\r\n * @returns {Boolean}\r\n */\r\nexport const isObject = (value) =>\r\n value && typeof value === \"object\" && value.constructor === Object;\r\n\r\n/**\r\n * Check if is a Promise\r\n * https://stackoverflow.com/a/53955664/10424385\r\n *\r\n * @param {Object} value\r\n * @returns {Boolean}\r\n */\r\nexport const isPromise = (value) =>\r\n Boolean(value && typeof value.then === \"function\");\r\n\r\n/**\r\n * Set attributes to element\r\n *\r\n * @param {HTMLElement} el\r\n * @param {Object} object\r\n */\r\nexport const setAttributes = (el, object) => {\r\n for (let key in object) {\r\n if (key === \"addClass\") {\r\n classList(el, \"add\", object[key]);\r\n } else if (key === \"removeClass\") {\r\n classList(el, \"remove\", object[key]);\r\n } else {\r\n el.setAttribute(key, object[key]);\r\n }\r\n }\r\n};\r\n\r\n/**\r\n * Get first element from child\r\n *\r\n * @param {HTMLElement} element\r\n * @returns {HTMLELement}\r\n */\r\nexport const getFirstElement = (element) =>\r\n (element.firstElementChild || element).textContent.trim();\r\n\r\n/**\r\n * Scroll to top result-list\r\n * @param {HTMLElement} resultList\r\n * @param {HTMLElement} resultWrap\r\n */\r\nexport const scrollResultsToTop = (resultList, resultWrap) => {\r\n // if there is an overflow of ul element, after\r\n // opening we always move ul to the top of the results\r\n resultList.scrollTop = resultList.offsetTop - resultWrap.offsetHeight;\r\n};\r\n\r\n/**\r\n * Adding role, tabindex, aria and call handleMouse\r\n *\r\n * @param {HTMLElement} itemsLi\r\n */\r\nexport const addAriaToAllLiElements = (itemsLi) => {\r\n // add role to all li elements\r\n for (let i = 0; i < itemsLi.length; i++) {\r\n setAttributes(itemsLi[i], {\r\n role: \"option\",\r\n tabindex: \"-1\",\r\n \"aria-selected\": \"false\",\r\n \"aria-setsize\": itemsLi.length,\r\n // https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-posinset\r\n \"aria-posinset\": i + 1,\r\n });\r\n }\r\n};\r\n\r\n/**\r\n * Show btn to clear data\r\n *\r\n * @param {HTMLElement} clearButton - button to clear data\r\n * @param {Function} destroy - destroy function\r\n */\r\nexport const showBtnToClearData = (clearButton = false, destroy) => {\r\n if (!clearButton) return;\r\n\r\n classList(clearButton, \"remove\", \"hidden\");\r\n // add event to clear button\r\n onEvent(clearButton, \"click\", destroy);\r\n};\r\n\r\n/**\r\n * ClassList add/remove/contains\r\n *\r\n * @param {HTMLElement} element - html element\r\n * @param {String} action - add/remove/contains\r\n * @param {String} className - class name\r\n */\r\nexport const classList = (element, action, className) =>\r\n element.classList[action](className);\r\n\r\n/**\r\n * Set aria-activedescendant\r\n *\r\n * @param {HTMLElement} root - search input\r\n * @param {String} type\r\n */\r\nexport const setAriaActivedescendant = (root, type) => {\r\n setAttributes(root, {\r\n \"aria-activedescendant\": type || \"\",\r\n });\r\n};\r\n\r\n/**\r\n * Get height of ul without group class\r\n *\r\n * @param {String} outputUl\r\n * @param {String} classGroup\r\n * @returns {Number}\r\n */\r\nexport const getClassGroupHeight = (outputUl, classGroup) => {\r\n // get height of ul without group class\r\n const allLiElements = document.querySelectorAll(\r\n `#${outputUl} > li:not(.${classGroup})`,\r\n );\r\n let height = 0;\r\n [].slice.call(allLiElements).map((el) => (height += el.offsetHeight));\r\n\r\n // return height\r\n return height;\r\n};\r\n\r\n/**\r\n * Scroll into view when press up/down arrows\r\n *\r\n * @param {HTMLElement} target\r\n * @param {HTMLElement} outputUl\r\n * @param {String} classGroup\r\n * @param {HTMLElement} resultList\r\n */\r\nexport const followActiveElement = (\r\n target,\r\n outputUl,\r\n classGroup,\r\n resultList,\r\n) => {\r\n const previusElement = resultList.previousSibling;\r\n\r\n const previusElementHeight = previusElement ? previusElement.offsetHeight : 0;\r\n\r\n if (target.getAttribute(\"aria-posinset\") == \"0\") {\r\n resultList.scrollTop =\r\n target.offsetTop - getClassGroupHeight(outputUl, classGroup);\r\n }\r\n\r\n if (target.offsetTop - previusElementHeight < resultList.scrollTop) {\r\n resultList.scrollTop = target.offsetTop - previusElementHeight;\r\n } else {\r\n const offsetBottom =\r\n target.offsetTop + target.offsetHeight - previusElementHeight;\r\n const scrollBottom = resultList.scrollTop + resultList.offsetHeight;\r\n if (offsetBottom > scrollBottom) {\r\n resultList.scrollTop = offsetBottom - resultList.offsetHeight;\r\n }\r\n }\r\n};\r\n\r\n/**\r\n * Create output-list and put after search input\r\n *\r\n * @param {HTMLElement} root - search input\r\n * @param {HTMLElement} resultList - output-list ul\r\n * @param {String} outputUl - id name of output-list\r\n * @param {HTMLElement} resultWrap - wrapper ul element\r\n * @param {String} prefix - add prefix to all class auto\r\n */\r\nexport const output = (root, resultList, outputUl, resultWrap, prefix) => {\r\n // set attribute to results-list\r\n setAttributes(resultList, {\r\n id: outputUl,\r\n tabIndex: \"0\",\r\n role: \"listbox\",\r\n });\r\n\r\n // add class to wrap element\r\n setAttributes(resultWrap, {\r\n addClass: `${prefix}-results-wrapper`,\r\n });\r\n\r\n // insert the results into the wrap element\r\n resultWrap.insertAdjacentElement(\"beforeend\", resultList);\r\n\r\n // insert the wrap element after the search input\r\n root.parentNode.insertBefore(resultWrap, root.nextSibling);\r\n};\r\n\r\n/**\r\n * Create element\r\n *\r\n * @param {String} type - type of element\r\n * @returns {HTMLDivElement}\r\n */\r\nexport const createElement = (type) => document.createElement(type);\r\n\r\n/**\r\n * Get element\r\n *\r\n * @param {String} element\r\n * @returns {HTMLElement}\r\n */\r\nexport const select = (element) => document.querySelector(element);\r\n\r\n/**\r\n * Event listeners\r\n *\r\n * @param {HTMLElement} element\r\n * @param {String} action\r\n * @param {Function} callback\r\n */\r\nexport const onEvent = (element, action, callback) => {\r\n element.addEventListener(action, callback);\r\n};\r\n\r\n/**\r\n * Remove event listeners\r\n *\r\n * @param {HTMLElement} element\r\n * @param {String} action\r\n * @param {Function} callback\r\n */\r\nexport const offEvent = (element, action, callback) => {\r\n element.removeEventListener(action, callback);\r\n};\r\n\r\n/**\r\n * Add event listeners to all elements\r\n *\r\n * @param {HTMLElement} id\r\n *\r\n */\r\nexport const ariaActiveDescendantDefault = (id) => {\r\n return {\r\n \"aria-owns\": id,\r\n \"aria-expanded\": \"false\",\r\n \"aria-autocomplete\": \"list\",\r\n role: \"combobox\",\r\n removeClass: \"auto-expanded\",\r\n };\r\n};\r\n","/**\r\n * Key codes\r\n */\r\nconst keyCodes = {\r\n ESC: 27,\r\n ENTER: 13,\r\n UP: 38,\r\n DOWN: 40,\r\n TAB: 9,\r\n};\r\n\r\nexport default keyCodes;\r\n","import {\r\n addAriaToAllLiElements,\r\n classList,\r\n createElement,\r\n followActiveElement,\r\n getFirstElement,\r\n isObject,\r\n isPromise,\r\n offEvent,\r\n onEvent,\r\n output,\r\n scrollResultsToTop,\r\n select,\r\n setAriaActivedescendant,\r\n setAttributes,\r\n showBtnToClearData,\r\n ariaActiveDescendantDefault,\r\n} from \"./utils/function\";\r\n\r\nimport keyCodes from \"./utils/keyCodes\";\r\n\r\n/**\r\n * @class Autocomplete\r\n */\r\nexport default class Autocomplete {\r\n /**\r\n * Constructor\r\n *\r\n * @param {String} element\r\n * @param {Object} object\r\n */\r\n constructor(\r\n element,\r\n {\r\n delay = 500,\r\n clearButton = true,\r\n clearButtonOnInitial = false,\r\n howManyCharacters = 1,\r\n selectFirst = false,\r\n insertToInput = false,\r\n showAllValues = false,\r\n cache = false,\r\n disableCloseOnSelect = false,\r\n preventScrollUp = false,\r\n removeResultsWhenInputIsEmpty = false,\r\n regex = { expression: /[|\\\\{}()[\\]^$+*?]/g, replacement: \"\\\\$&\" },\r\n classGroup,\r\n classPreventClosing,\r\n classPrefix,\r\n ariaLabelClear,\r\n onSearch,\r\n onResults = () => {},\r\n onSubmit = () => {},\r\n onOpened = () => {},\r\n onReset = () => {},\r\n onRender = () => {},\r\n onClose = () => {},\r\n noResults = () => {},\r\n onSelectedItem = () => {},\r\n },\r\n ) {\r\n this._id = element;\r\n this._root = document.getElementById(element);\r\n this._onSearch = isPromise(onSearch)\r\n ? onSearch\r\n : ({ currentValue, element }) =>\r\n Promise.resolve(onSearch({ currentValue, element }));\r\n this._onResults = onResults;\r\n this._onRender = onRender;\r\n this._onSubmit = onSubmit;\r\n this._onSelected = onSelectedItem;\r\n this._onOpened = onOpened;\r\n this._onReset = onReset;\r\n this._noResults = noResults;\r\n this._onClose = onClose;\r\n\r\n this._delay = delay;\r\n this._characters = howManyCharacters;\r\n this._clearButton = clearButton;\r\n this._clearButtonOnInitial = clearButtonOnInitial;\r\n this._selectFirst = selectFirst;\r\n this._toInput = insertToInput;\r\n this._showAll = showAllValues;\r\n this._classGroup = classGroup;\r\n this._prevClosing = classPreventClosing;\r\n this._clearBtnAriLabel = ariaLabelClear\r\n ? ariaLabelClear\r\n : \"clear the search query\";\r\n this._prefix = classPrefix ? `${classPrefix}-auto` : \"auto\";\r\n this._disable = disableCloseOnSelect;\r\n this._preventScrollUp = preventScrollUp;\r\n this._removeResultsWhenInputIsEmpty = removeResultsWhenInputIsEmpty;\r\n\r\n // default config\r\n this._cache = cache;\r\n this._timeout = null;\r\n this._outputUl = `${this._prefix}-${this._id}-results`;\r\n this._cacheData = `data-cache-auto-${this._id}`;\r\n this._isLoading = `${this._prefix}-is-loading`;\r\n this._isActive = `${this._prefix}-is-active`;\r\n this._activeList = `${this._prefix}-selected`;\r\n this._selectedOption = `${this._prefix}-selected-option`;\r\n this._err = `${this._prefix}-error`;\r\n this._resultWrap = createElement(\"div\");\r\n this._resultList = createElement(\"ul\");\r\n this._clearBtn = createElement(\"button\");\r\n\r\n // ----------------------------------------\r\n // regex\r\n\r\n this._regex = regex;\r\n this._defaultExpression = {\r\n expression: /[|\\\\{}()[\\]^$+*?]/g,\r\n replacement: \"\\\\$&\",\r\n };\r\n\r\n // if regex is don't have replacement then set default\r\n if (!this._regex.replacement) {\r\n this._regex.replacement = this._defaultExpression.replacement;\r\n }\r\n\r\n // if regex is don't have expression then set default\r\n if (!this._regex.expression) {\r\n this._regex.expression = this._defaultExpression.expression;\r\n }\r\n\r\n // ----------------------------------------\r\n\r\n this._initial();\r\n }\r\n\r\n /**\r\n * Initial function\r\n */\r\n _initial = () => {\r\n this._clearbutton();\r\n\r\n const ariaAcrivedescentDefault = ariaActiveDescendantDefault(\r\n this._outputUl,\r\n );\r\n setAttributes(this._root, ariaAcrivedescentDefault);\r\n\r\n output(\r\n this._root,\r\n this._resultList,\r\n this._outputUl,\r\n this._resultWrap,\r\n this._prefix,\r\n );\r\n\r\n // default aria\r\n onEvent(this._root, \"input\", this._handleInput);\r\n\r\n // show all values on click root input\r\n this._showAll && onEvent(this._root, \"click\", this._handleInput);\r\n\r\n // calback functions\r\n this._onRender({\r\n element: this._root,\r\n results: this._resultList,\r\n });\r\n\r\n // show clear button if\r\n if (this._clearButtonOnInitial) {\r\n showBtnToClearData(this._clearBtn, this.destroy);\r\n }\r\n };\r\n\r\n /**\r\n * Actions on input\r\n *\r\n * @param {String} type - set attribute depending on type\r\n * @param {String} target\r\n */\r\n _cacheAct = (type, target) => {\r\n if (!this._cache) return;\r\n\r\n if (type === \"update\") {\r\n this._root.setAttribute(this._cacheData, target.value);\r\n } else if (type === \"remove\") {\r\n this._root.removeAttribute(this._cacheData);\r\n } else {\r\n this._root.value = this._root.getAttribute(this._cacheData);\r\n }\r\n };\r\n\r\n /**\r\n * Handle input\r\n *\r\n * @param {Event} object\r\n */\r\n _handleInput = ({ target, type }) => {\r\n if (\r\n this._root.getAttribute(\"aria-expanded\") === \"true\" &&\r\n type === \"click\"\r\n ) {\r\n return;\r\n }\r\n\r\n // replace all special characters\r\n const regex = target.value.replace(\r\n this._regex.expression,\r\n this._regex.replacement,\r\n );\r\n\r\n // update data attribute cache\r\n this._cacheAct(\"update\", target);\r\n\r\n const delay = this._showAll ? 0 : this._delay;\r\n // clear timeout\r\n clearTimeout(this._timeout);\r\n this._timeout = setTimeout(() => {\r\n // removeResultsWhenInputIsEmpty\r\n // remove results when input is empty\r\n if (this._removeResultsWhenInputIsEmpty) {\r\n if (target.value.length === 0) {\r\n this.destroy();\r\n return;\r\n }\r\n }\r\n\r\n this._searchItem(regex.trim());\r\n }, delay);\r\n };\r\n\r\n /**\r\n * Default aria\r\n */\r\n _reset = () => {\r\n // remove class isActive\r\n classList(this._resultWrap, \"remove\", this._isActive);\r\n\r\n const ariaAcrivedescentDefault = ariaActiveDescendantDefault(\r\n this._outputUl,\r\n );\r\n\r\n const ariaAcrivedescent = this._preventScrollUp\r\n ? ariaAcrivedescentDefault\r\n : { ...ariaAcrivedescentDefault, \"aria-activedescendant\": \"\" };\r\n\r\n // set attributes to root - input\r\n setAttributes(this._root, ariaAcrivedescent);\r\n\r\n if (!this._preventScrollUp) {\r\n // set default aria-selected, remove id and remove class 'auto-selected'\r\n this._removeAria(select(`.${this._activeList}`));\r\n\r\n // set index\r\n this._index = this._selectFirst ? 0 : -1;\r\n }\r\n\r\n // remove result when lengh = 0 and insertToInput is false\r\n // https://github.com/tomickigrzegorz/autocomplete/issues/136\r\n if ((this._matches?.length == 0 && !this._toInput) || this._showAll) {\r\n this._resultList.textContent = \"\";\r\n }\r\n\r\n // callback function\r\n this._onClose();\r\n };\r\n\r\n /**\r\n * The async function gets the text from the search\r\n * and returns the matching array\r\n *\r\n * @param {String} value\r\n */\r\n _searchItem = (value) => {\r\n this._value = value;\r\n\r\n // if searching show loading icon\r\n this._onLoading(true);\r\n\r\n // hide button clear\r\n showBtnToClearData(this._clearBtn, this.destroy);\r\n\r\n // if there is no value and clearButton is true\r\n if (value.length == 0 && this._clearButton) {\r\n classList(this._clearBtn, \"add\", \"hidden\");\r\n }\r\n\r\n // if declare characters more then value.len and showAll is false\r\n // remove class isActive\r\n if (this._characters > value.length && !this._showAll) {\r\n this._onLoading();\r\n return;\r\n }\r\n\r\n // callblack function onSearch\r\n this._onSearch({ currentValue: value, element: this._root })\r\n .then((result) => {\r\n const rootValueLength = this._root.value.length;\r\n const resultLength = result.length;\r\n // set no result\r\n this._matches = Array.isArray(result)\r\n ? result\r\n : JSON.parse(JSON.stringify(result));\r\n\r\n this._onLoading();\r\n this._error();\r\n\r\n // if use destroy() method\r\n if (resultLength == 0 && rootValueLength == 0) {\r\n classList(this._clearBtn, \"add\", \"hidden\");\r\n }\r\n\r\n if (resultLength == 0 && rootValueLength) {\r\n classList(this._root, \"remove\", \"auto-expanded\");\r\n this._reset();\r\n this._noResults({\r\n element: this._root,\r\n currentValue: value,\r\n template: this._results,\r\n });\r\n this._events();\r\n } else if (resultLength > 0 || isObject(result)) {\r\n this._index = this._selectFirst ? 0 : -1;\r\n this._results();\r\n this._events();\r\n }\r\n })\r\n .catch(() => {\r\n this._onLoading();\r\n this._reset();\r\n });\r\n };\r\n\r\n /**\r\n * Set or remove loading class\r\n *\r\n * @param {Boolean} type\r\n */\r\n _onLoading = (type) =>\r\n this._root.parentNode.classList[type ? \"add\" : \"remove\"](this._isLoading);\r\n\r\n /**\r\n * Set error class to the root element\r\n */\r\n _error = () => classList(this._root, \"remove\", this._err);\r\n\r\n /**\r\n * Events\r\n */\r\n _events = () => {\r\n // handle click on keydown [up, down, enter, tab, esc]\r\n onEvent(this._root, \"keydown\", this._handleKeys);\r\n\r\n onEvent(this._root, \"click\", this._handleShowItems);\r\n\r\n // close expanded items\r\n onEvent(document, \"click\", this._handleDocClick);\r\n\r\n // temporarily disabled mouseleave\r\n [\"mousemove\", \"click\"].map((eventType) => {\r\n onEvent(this._resultList, eventType, this._handleMouse);\r\n });\r\n };\r\n\r\n /**\r\n * Results\r\n *\r\n * @param {HTMLElement|String} template - html or string returned from the function,\r\n * look at the example - https://github.com/tomickigrzegorz/autocomplete/blob/master/docs/js/examples/no-results.js#L30\r\n */\r\n _results = (template) => {\r\n // set attribute to root\r\n setAttributes(this._root, {\r\n \"aria-expanded\": \"true\",\r\n addClass: `${this._prefix}-expanded`,\r\n });\r\n\r\n // clear result list\r\n this._resultList.textContent = \"\";\r\n\r\n // add all found records to otput ul\r\n const dataResults =\r\n this._matches.length === 0\r\n ? this._onResults({\r\n currentValue: this._value,\r\n matches: 0,\r\n template,\r\n })\r\n : this._onResults({\r\n currentValue: this._value,\r\n matches: this._matches,\r\n classGroup: this._classGroup,\r\n });\r\n\r\n // add data to ul\r\n this._resultList.insertAdjacentHTML(\"afterbegin\", dataResults);\r\n\r\n // add class isActive\r\n classList(this._resultWrap, \"add\", this._isActive);\r\n\r\n const checkIfClassGroupExist = this._classGroup\r\n ? `:not(.${this._classGroup})`\r\n : \"\";\r\n\r\n this._itemsLi = document.querySelectorAll(\r\n `#${this._outputUl} > li${checkIfClassGroupExist}`,\r\n );\r\n\r\n // adding role, tabindex and aria\r\n addAriaToAllLiElements(this._itemsLi);\r\n\r\n // action on open results\r\n this._onOpened({\r\n type: \"results\",\r\n element: this._root,\r\n results: this._resultList,\r\n });\r\n\r\n // select first element\r\n this._selectFirstElement();\r\n\r\n // move the view item to the first item\r\n // this.resultList.scrollTop = 0;\r\n // if (this._preventScrollUp) return;\r\n scrollResultsToTop(this._resultList, this._resultWrap);\r\n };\r\n\r\n /**\r\n * Hangle click on document\r\n *\r\n * @param {Event} object\r\n */\r\n _handleDocClick = ({ target }) => {\r\n let disableClose = null;\r\n\r\n // if 'target' is a ul and 'disableCloseOnSelect'\r\n // is a 'true' set 'disableClose' on true\r\n if (\r\n (target.closest(\"ul\") && this._disable) ||\r\n // when class classDisableClose\r\n // then do not not close results\r\n target.closest(`.${this._prevClosing}`)\r\n ) {\r\n disableClose = true;\r\n }\r\n\r\n if (target.id !== this._id && !disableClose) {\r\n this._reset();\r\n return;\r\n }\r\n };\r\n\r\n /**\r\n * Select first element\r\n */\r\n _selectFirstElement = () => {\r\n this._removeAria(select(`.${this._activeList}`));\r\n\r\n if (!this._selectFirst) {\r\n return;\r\n }\r\n\r\n const { firstElementChild } = this._resultList;\r\n\r\n const classSelectFirst =\r\n this._classGroup && this._matches.length > 0 && this._selectFirst\r\n ? firstElementChild.nextElementSibling\r\n : firstElementChild;\r\n\r\n // calback function onSelect when first element is true\r\n this._onSelected({\r\n index: this._index,\r\n element: this._root,\r\n object: this._matches[this._index],\r\n });\r\n\r\n // set attribute to first element\r\n setAttributes(classSelectFirst, {\r\n id: `${this._selectedOption}-0`,\r\n addClass: this._activeList,\r\n \"aria-selected\": \"true\",\r\n });\r\n\r\n // set aria active descendant\r\n setAriaActivedescendant(this._root, `${this._selectedOption}-0`);\r\n };\r\n\r\n /**\r\n * show items when items.length > 0 and is not empty\r\n */\r\n _handleShowItems = () => {\r\n // if resultWrap is not active and resultList is not empty\r\n if (\r\n this._resultList.textContent.length > 0 &&\r\n !classList(this._resultWrap, \"contains\", this._isActive)\r\n ) {\r\n // set attribute to root\r\n setAttributes(this._root, {\r\n \"aria-expanded\": \"true\",\r\n addClass: `${this._prefix}-expanded`,\r\n });\r\n\r\n // add isActive class to resultWrap\r\n classList(this._resultWrap, \"add\", this._isActive);\r\n\r\n // move the view item to the first item\r\n // this.resultList.scrollTop = 0;\r\n if (!this._preventScrollUp) {\r\n scrollResultsToTop(this._resultList, this._resultWrap);\r\n // select first element\r\n this._selectFirstElement();\r\n }\r\n\r\n // callback function\r\n this._onOpened({\r\n type: \"showItems\",\r\n element: this._root,\r\n results: this._resultList,\r\n });\r\n\r\n if (!this._cache) return;\r\n this._cacheAct(\"update\", this._root);\r\n }\r\n };\r\n\r\n /**\r\n * Adding text from the list when li is clicking\r\n * or adding aria-selected to li elements\r\n *\r\n * @param {Event} event\r\n */\r\n _handleMouse = (event) => {\r\n event.preventDefault();\r\n\r\n const { target, type } = event;\r\n const targetClosest = target.closest(\"li\");\r\n const targetClosestRole = targetClosest?.hasAttribute(\"role\");\r\n const activeClass = this._activeList;\r\n const activeClassElement = select(`.${activeClass}`);\r\n\r\n if (\r\n !targetClosest ||\r\n !targetClosestRole ||\r\n target.closest(`.${this._prevClosing}`)\r\n ) {\r\n return;\r\n }\r\n\r\n if (type === \"click\") {\r\n // click on li get element\r\n // get text from clicked li\r\n this._getTextFromLi(targetClosest);\r\n }\r\n\r\n if (\r\n type === \"mousemove\" &&\r\n !classList(targetClosest, \"contains\", activeClass)\r\n ) {\r\n this._removeAria(activeClassElement);\r\n\r\n // add aria to li\r\n this._setAria(targetClosest);\r\n this._index = this._indexLiSelected(targetClosest);\r\n\r\n this._onSelected({\r\n index: this._index,\r\n element: this._root,\r\n object: this._matches[this._index],\r\n });\r\n }\r\n };\r\n\r\n /**\r\n * Get text from li on enter or click\r\n *\r\n * @param {HTMLElement} element\r\n */\r\n _getTextFromLi = (element) => {\r\n if (!element || this._matches.length === 0) {\r\n // set default settings\r\n !this._disable && this._reset();\r\n\r\n return;\r\n }\r\n\r\n // show clearBtn when select element\r\n this._clearButton && classList(this._clearBtn, \"remove\", \"hidden\");\r\n\r\n // get first element from li and set it to root\r\n this._root.value = getFirstElement(element);\r\n\r\n // onSubmit passing text to function\r\n this._onSubmit({\r\n index: this._index,\r\n element: this._root,\r\n object: this._matches[this._index],\r\n results: this._resultList,\r\n });\r\n\r\n // set default settings\r\n if (!this._disable) {\r\n if (!this._preventScrollUp) {\r\n this._removeAria(element);\r\n }\r\n this._reset();\r\n }\r\n\r\n // remove cache\r\n this._cacheAct(\"remove\");\r\n };\r\n\r\n /**\r\n * Return which li element was selected\r\n * by hovering the mouse over\r\n *\r\n * @param {HTMLElement} target\r\n * @returns {Number}\r\n */\r\n _indexLiSelected = (target) =>\r\n // get index of li element\r\n Array.prototype.indexOf.call(this._itemsLi, target);\r\n\r\n /**\r\n * Navigating the elements li and enter\r\n *\r\n * @param {Event} event\r\n */\r\n _handleKeys = (event) => {\r\n const { keyCode } = event;\r\n\r\n const resultList = classList(this._resultWrap, \"contains\", this._isActive);\r\n\r\n const matchesLength = this._matches.length + 1;\r\n this._selectedLi = select(`.${this._activeList}`);\r\n\r\n // switch between keys\r\n switch (keyCode) {\r\n case keyCodes.UP:\r\n case keyCodes.DOWN:\r\n // Wrong cursor position in the input field #62\r\n // Prevents the cursor from moving to the beginning\r\n // of input as the cursor hovers over the results.\r\n event.preventDefault();\r\n\r\n if ((matchesLength <= 1 && this._selectFirst) || !resultList) {\r\n return;\r\n }\r\n\r\n // if keyCode is up\r\n if (keyCode === keyCodes.UP) {\r\n if (this._index < 0) {\r\n this._index = matchesLength - 1;\r\n }\r\n this._index -= 1;\r\n } else {\r\n this._index += 1;\r\n if (this._index >= matchesLength) {\r\n this._index = 0;\r\n }\r\n }\r\n\r\n // remove aria-selected\r\n this._removeAria(this._selectedLi);\r\n\r\n if (this._index >= 0 && this._index < matchesLength - 1) {\r\n const selectedElement = this._itemsLi[this._index];\r\n\r\n if (this._toInput && resultList) {\r\n this._root.value = getFirstElement(selectedElement);\r\n }\r\n\r\n // callback function\r\n this._onSelected({\r\n index: this._index,\r\n element: this._root,\r\n object: this._matches[this._index],\r\n });\r\n\r\n // set aria-selected\r\n this._setAria(selectedElement);\r\n } else {\r\n // catch action\r\n this._cacheAct();\r\n setAriaActivedescendant(this._root);\r\n\r\n this._onSelected({\r\n index: null,\r\n element: this._root,\r\n object: null,\r\n });\r\n }\r\n\r\n break;\r\n // keycode enter\r\n case keyCodes.ENTER:\r\n // https:github.com/tomickigrzegorz/autocomplete/issues/145\r\n event.preventDefault();\r\n\r\n this._getTextFromLi(this._selectedLi);\r\n break;\r\n\r\n // keycode escape and keycode tab\r\n case keyCodes.TAB:\r\n case keyCodes.ESC:\r\n event.stopPropagation();\r\n this._reset();\r\n\r\n break;\r\n default:\r\n break;\r\n }\r\n };\r\n\r\n /**\r\n * Set aria label on item li\r\n *\r\n * @param {HTMLElement} target\r\n */\r\n _setAria = (target) => {\r\n const selectedOption = `${this._selectedOption}-${this._indexLiSelected(\r\n target,\r\n )}`;\r\n\r\n // set aria to li\r\n setAttributes(target, {\r\n id: selectedOption,\r\n \"aria-selected\": \"true\",\r\n addClass: this._activeList,\r\n });\r\n\r\n setAriaActivedescendant(this._root, selectedOption);\r\n\r\n // scrollIntoView when press up/down arrows\r\n followActiveElement(\r\n target,\r\n this._outputUl,\r\n this._classGroup,\r\n this._resultList,\r\n );\r\n };\r\n\r\n /**\r\n * Remove aria label from item li\r\n *\r\n * @param {HTMLElement} element\r\n */\r\n _removeAria = (element) => {\r\n if (!element) return;\r\n\r\n // remove aria from li\r\n setAttributes(element, {\r\n id: \"\",\r\n removeClass: this._activeList,\r\n \"aria-selected\": \"false\",\r\n });\r\n };\r\n\r\n /**\r\n * Create clear button and\r\n * removing text from the input field\r\n */\r\n _clearbutton = () => {\r\n // stop when clear button is disabled\r\n if (!this._clearButton) return;\r\n\r\n // add aria to clear button\r\n setAttributes(this._clearBtn, {\r\n class: `${this._prefix}-clear hidden`,\r\n type: \"button\",\r\n title: this._clearBtnAriLabel,\r\n \"aria-label\": this._clearBtnAriLabel,\r\n });\r\n\r\n // insert clear button after input - root\r\n this._root.insertAdjacentElement(\"afterend\", this._clearBtn);\r\n };\r\n\r\n /**\r\n * Rerender rows without remove root input and close elements\r\n * @param {String} inputValue\r\n */\r\n rerender = (inputValue) => {\r\n const text = inputValue?.trim() ? inputValue.trim() : this._root.value;\r\n if (inputValue?.trim()) {\r\n this._root.value = inputValue.trim();\r\n this._cacheAct(\"update\", this._root);\r\n }\r\n const regexText = text.replace(\r\n this._regex.expression,\r\n this._regex.replacement,\r\n );\r\n this._searchItem(regexText.trim());\r\n };\r\n\r\n /**\r\n * Clicking on the clear button\r\n * publick destroy method\r\n */\r\n destroy = () => {\r\n // if clear button is true then add class hidden\r\n this._clearButton && classList(this._clearBtn, \"add\", \"hidden\");\r\n // clear value searchId\r\n this._root.value = \"\";\r\n // set focus\r\n this._root.focus();\r\n // remove li from ul\r\n this._resultList.textContent = \"\";\r\n // set default aria\r\n this._reset();\r\n // remove error if exist\r\n this._error();\r\n // callback function\r\n this._onReset(this._root);\r\n // remove animation on loading\r\n this._onLoading();\r\n\r\n // remove listener\r\n offEvent(this._root, \"keydown\", this._handleKeys);\r\n offEvent(this._root, \"click\", this._handleShowItems);\r\n // remove listener on click on document\r\n offEvent(document, \"click\", this._handleDocClick);\r\n };\r\n}\r\n"],"names":["isObject","value","constructor","Object","isPromise","Boolean","then","setAttributes","el","object","key","classList","setAttribute","getFirstElement","element","firstElementChild","textContent","trim","scrollResultsToTop","resultList","resultWrap","scrollTop","offsetTop","offsetHeight","addAriaToAllLiElements","itemsLi","i","length","role","tabindex","showBtnToClearData","clearButton","destroy","onEvent","action","className","setAriaActivedescendant","root","type","getClassGroupHeight","outputUl","classGroup","allLiElements","document","querySelectorAll","height","slice","call","map","followActiveElement","target","previusElement","previousSibling","previusElementHeight","getAttribute","offsetBottom","scrollBottom","output","prefix","id","tabIndex","addClass","insertAdjacentElement","parentNode","insertBefore","nextSibling","createElement","select","querySelector","callback","addEventListener","offEvent","removeEventListener","ariaActiveDescendantDefault","removeClass","keyCodes","ESC","ENTER","UP","DOWN","TAB","Autocomplete","_ref","delay","clearButtonOnInitial","howManyCharacters","selectFirst","insertToInput","showAllValues","cache","disableCloseOnSelect","preventScrollUp","removeResultsWhenInputIsEmpty","regex","expression","replacement","classPreventClosing","classPrefix","ariaLabelClear","onSearch","onResults","onSubmit","onOpened","onReset","onRender","onClose","noResults","onSelectedItem","_initial","_clearbutton","ariaAcrivedescentDefault","_outputUl","_root","_resultList","_resultWrap","_prefix","_handleInput","_showAll","_onRender","results","_clearButtonOnInitial","_clearBtn","_cacheAct","_cache","_cacheData","removeAttribute","_ref2","replace","_regex","_delay","clearTimeout","_timeout","setTimeout","_removeResultsWhenInputIsEmpty","_searchItem","_reset","_isActive","ariaAcrivedescent","_preventScrollUp","_removeAria","_activeList","_index","_selectFirst","_matches","_toInput","_onClose","_value","_onLoading","_clearButton","_characters","_onSearch","currentValue","result","rootValueLength","resultLength","Array","isArray","JSON","parse","stringify","_error","_noResults","template","_results","_events","catch","_isLoading","_err","_handleKeys","_handleShowItems","_handleDocClick","eventType","_handleMouse","dataResults","_onResults","matches","_classGroup","insertAdjacentHTML","checkIfClassGroupExist","_itemsLi","_onOpened","_selectFirstElement","_ref3","disableClose","closest","_disable","_prevClosing","_id","classSelectFirst","nextElementSibling","_onSelected","index","_selectedOption","event","preventDefault","targetClosest","targetClosestRole","hasAttribute","activeClass","activeClassElement","_getTextFromLi","_setAria","_indexLiSelected","_onSubmit","prototype","indexOf","keyCode","matchesLength","_selectedLi","selectedElement","stopPropagation","selectedOption","class","title","_clearBtnAriLabel","rerender","inputValue","text","regexText","focus","_onReset","getElementById","_ref4","Promise","resolve","_defaultExpression"],"mappings":";;;;;;;;;;EAKO,MAAMA,QAAQ,GAAIC,KAAK,IAC5BA,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,CAACC,WAAW,KAAKC,MAAM,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AACzB,OAAQ,CAAU,SAAA,CAAA,CAAA;EAC7C,IAAA,IAAI,CAAC6E,eAAe,GAAI,GAAE,IAAI,CAAC7E,OAAQ,CAAiB,gBAAA,CAAA,CAAA;EACxD,IAAA,IAAI,CAACoD,IAAI,GAAI,GAAE,IAAI,CAACpD,OAAQ,CAAO,MAAA,CAAA,CAAA;EACnC,IAAA,IAAI,CAACD,WAAW,GAAGhD,aAAa,CAAC,KAAK,CAAC,CAAA;EACvC,IAAA,IAAI,CAAC+C,WAAW,GAAG/C,aAAa,CAAC,IAAI,CAAC,CAAA;EACtC,IAAA,IAAI,CAACuD,SAAS,GAAGvD,aAAa,CAAC,QAAQ,CAAC,CAAA;MAKxC,IAAI,CAAC8D,MAAM,GAAGnC,MAAK,CAAA;MACnB,IAAI,CAACoI,kBAAkB,GAAG;EACxBnI,MAAAA,UAAU,EAAE,oBAAoB;EAChCC,MAAAA,WAAW,EAAE,MAAA;OACd,CAAA;EAGD,IAAA,IAAI,CAAC,IAAI,CAACiC,MAAM,CAACjC,WAAW,EAAE;QAC5B,IAAI,CAACiC,MAAM,CAACjC,WAAW,GAAG,IAAI,CAACkI,kBAAkB,CAAClI,WAAW,CAAA;EAC/D,KAAA;EAGA,IAAA,IAAI,CAAC,IAAI,CAACiC,MAAM,CAAClC,UAAU,EAAE;QAC3B,IAAI,CAACkC,MAAM,CAAClC,UAAU,GAAG,IAAI,CAACmI,kBAAkB,CAACnI,UAAU,CAAA;EAC7D,KAAA;MAIA,IAAI,CAACc,QAAQ,EAAE,CAAA;EACjB,GAAA;EA+qBF;;;;;;;;"} \ No newline at end of file diff --git a/dist/js/autocomplete.min.js b/dist/js/autocomplete.min.js index acacb96..492bf6c 100644 --- a/dist/js/autocomplete.min.js +++ b/dist/js/autocomplete.min.js @@ -1,8 +1,8 @@ /*! * @name autocomplete -* @version 2.0.0 +* @version 2.0.1 * @author Grzegorz Tomicki * @link https://github.com/tomickigrzegorz/autocomplete * @license MIT */ -var Autocomplete=function(){"use strict";const t=(t,s)=>{for(let i in s)"addClass"===i?e(t,"add",s[i]):"removeClass"===i?e(t,"remove",s[i]):t.setAttribute(i,s[i])},s=t=>(t.firstElementChild||t).textContent.trim(),i=(t,s)=>{t.scrollTop=t.offsetTop-s.offsetHeight},h=function(t,s){void 0===t&&(t=!1),t&&(e(t,"remove","hidden"),o(t,"click",s))},e=(t,s,i)=>t.classList[s](i),a=(s,i)=>{t(s,{"aria-activedescendant":i||""})},n=(t,s,i,h)=>{const e=h.previousSibling,a=e?e.offsetHeight:0;if("0"==t.getAttribute("aria-posinset")&&(h.scrollTop=t.offsetTop-((t,s)=>{const i=document.querySelectorAll(`#${t} > li:not(.${s})`);let h=0;return[].slice.call(i).map((t=>h+=t.offsetHeight)),h})(s,i)),t.offsetTop-ah.scrollTop+h.offsetHeight&&(h.scrollTop=s-h.offsetHeight)}},l=t=>document.createElement(t),r=t=>document.querySelector(t),o=(t,s,i)=>{t.addEventListener(s,i)},c=(t,s,i)=>{t.removeEventListener(s,i)},d=27,u=13,m=38,p=40,$=9;return class{constructor(v,b){let{delay:f=500,clearButton:x=!0,clearButtonOnInitial:y=!1,howManyCharacters:C=1,selectFirst:k=!1,insertToInput:g=!1,showAllValues:w=!1,cache:j=!1,disableCloseOnSelect:I=!1,preventScrollUp:S=!1,removeResultsWhenInputIsEmpty:V=!1,regex:O={expression:/[|\\{}()[\]^$+*?]/g,replacement:"\\$&"},classGroup:R,classPreventClosing:A,classPrefix:B,ariaLabelClear:P,onSearch:T,onResults:E=(()=>{}),onSubmit:G=(()=>{}),onOpened:J=(()=>{}),onReset:N=(()=>{}),onRender:q=(()=>{}),onClose:z=(()=>{}),noResults:F=(()=>{}),onSelectedItem:L=(()=>{})}=b;var M;this.t=()=>{var s,i,e,a,n;this.i(),s=this.h,i=this.l,e=this.o,a=this.u,n=this.m,t(i,{id:e,tabIndex:"0",role:"listbox"}),t(a,{addClass:`${n}-results-wrapper`}),a.insertAdjacentElement("beforeend",i),s.parentNode.insertBefore(a,s.nextSibling),o(this.h,"input",this.p),this.$&&o(this.h,"click",this.p),this.v({element:this.h,results:this.l}),this.C&&h(this.k,this.destroy)},this.j=(t,s)=>{this.I&&("update"===t?this.h.setAttribute(this.S,s.value):"remove"===t?this.h.removeAttribute(this.S):this.h.value=this.h.getAttribute(this.S))},this.p=t=>{let{target:s,type:i}=t;if("true"===this.h.getAttribute("aria-expanded")&&"click"===i)return;const h=s.value.replace(this.V.expression,this.V.replacement);this.j("update",s);const e=this.$?0:this.O;clearTimeout(this.R),this.R=setTimeout((()=>{this.A&&0===s.value.length?this.destroy():this.B(h.trim())}),e)},this.P=()=>{e(this.u,"remove",this.T);const s={"aria-owns":`${this.G}-list`,"aria-expanded":"false","aria-autocomplete":"list",role:"combobox",removeClass:"auto-expanded"},i=this.J?s:{...s,"aria-activedescendant":""};t(this.h,i),this.J||(this.N(r(`.${this.q}`)),this.F=this.L?0:-1),(0==this.M?.length&&!this.U||this.$)&&(this.l.textContent=""),this.W()},this.B=t=>{this.D=t,this.H(!0),h(this.k,this.destroy),0==t.length&&this.K&&e(this.k,"add","hidden"),this.X>t.length&&!this.$?this.H():this.Y({currentValue:t,element:this.h}).then((s=>{const i=this.h.value.length,h=s.length;this.M=Array.isArray(s)?s:JSON.parse(JSON.stringify(s)),this.H(),this.Z(),0==h&&0==i&&e(this.k,"add","hidden"),0==h&&i?(e(this.h,"remove","auto-expanded"),this.P(),this._({element:this.h,currentValue:t,template:this.tt}),this.st()):(h>0||(t=>t&&"object"==typeof t&&t.constructor===Object)(s))&&(this.F=this.L?0:-1,this.tt(),this.st())})).catch((()=>{this.H(),this.P()}))},this.H=t=>this.h.parentNode.classList[t?"add":"remove"](this.it),this.Z=()=>e(this.h,"remove",this.ht),this.st=()=>{o(this.h,"keydown",this.et),o(this.h,"click",this.nt),o(document,"click",this.lt),["mousemove","click"].map((t=>{o(this.l,t,this.rt)}))},this.tt=s=>{t(this.h,{"aria-expanded":"true",addClass:`${this.m}-expanded`}),this.l.textContent="";const h=0===this.M.length?this.ot({currentValue:this.D,matches:0,template:s}):this.ot({currentValue:this.D,matches:this.M,classGroup:this.ct});this.l.insertAdjacentHTML("afterbegin",h),e(this.u,"add",this.T);const a=this.ct?`:not(.${this.ct})`:"";this.dt=document.querySelectorAll(`#${this.o} > li${a}`),(s=>{for(let i=0;i{let{target:s}=t,i=null;(s.closest("ul")&&this.vt||s.closest(`.${this.bt}`))&&(i=!0),s.id===this.G||i||this.P()},this.$t=()=>{if(this.N(r(`.${this.q}`)),!this.L)return;const{firstElementChild:s}=this.l,i=this.ct&&this.M.length>0&&this.L?s.nextElementSibling:s;this.ft({index:this.F,element:this.h,object:this.M[this.F]}),t(i,{id:`${this.xt}-0`,addClass:this.q,"aria-selected":"true"}),a(this.h,`${this.xt}-0`)},this.nt=()=>{if(this.l.textContent.length>0&&!e(this.u,"contains",this.T)){if(t(this.h,{"aria-expanded":"true",addClass:`${this.m}-expanded`}),e(this.u,"add",this.T),this.J||(i(this.l,this.u),this.$t()),this.ut({type:"showItems",element:this.h,results:this.l}),!this.I)return;this.j("update",this.h)}},this.rt=t=>{t.preventDefault();const{target:s,type:i}=t,h=s.closest("li"),a=h?.hasAttribute("role"),n=this.q,l=r(`.${n}`);h&&a&&!s.closest(`.${this.bt}`)&&("click"===i&&this.yt(h),"mousemove"!==i||e(h,"contains",n)||(this.N(l),this.Ct(h),this.F=this.kt(h),this.ft({index:this.F,element:this.h,object:this.M[this.F]})))},this.yt=t=>{t&&0!==this.M.length?(this.K&&e(this.k,"remove","hidden"),this.h.value=s(t),this.gt({index:this.F,element:this.h,object:this.M[this.F],results:this.l}),this.vt||(this.J||this.N(t),this.P()),this.j("remove")):!this.vt&&this.P()},this.kt=t=>Array.prototype.indexOf.call(this.dt,t),this.et=t=>{const{keyCode:i}=t,h=e(this.u,"contains",this.T),n=this.M.length+1;switch(this.wt=r(`.${this.q}`),i){case m:case p:if(t.preventDefault(),n<=1&&this.L||!h)return;if(i===m?(this.F<0&&(this.F=n-1),this.F-=1):(this.F+=1,this.F>=n&&(this.F=0)),this.N(this.wt),this.F>=0&&this.F{const i=`${this.xt}-${this.kt(s)}`;t(s,{id:i,"aria-selected":"true",addClass:this.q}),a(this.h,i),n(s,this.o,this.ct,this.l)},this.N=s=>{s&&t(s,{id:"",removeClass:this.q,"aria-selected":"false"})},this.i=()=>{this.K&&(t(this.k,{class:`${this.m}-clear hidden`,type:"button",title:this.jt,"aria-label":this.jt}),this.h.insertAdjacentElement("afterend",this.k))},this.rerender=t=>{const s=t?.trim()?t.trim():this.h.value;t?.trim()&&(this.h.value=t.trim(),this.j("update",this.h));const i=s.replace(this.V.expression,this.V.replacement);this.B(i.trim())},this.destroy=()=>{this.K&&e(this.k,"add","hidden"),this.h.value="",this.h.focus(),this.l.textContent="",this.P(),this.Z(),this.It(this.h),this.H(),c(this.h,"keydown",this.et),c(this.h,"click",this.nt),c(document,"click",this.lt)},this.G=v,this.h=document.getElementById(v),this.Y=(M=T,Boolean(M&&"function"==typeof M.then)?T:t=>{let{currentValue:s,element:i}=t;return Promise.resolve(T({currentValue:s,element:i}))}),this.ot=E,this.v=q,this.gt=G,this.ft=L,this.ut=J,this.It=N,this._=F,this.W=z,this.O=f,this.X=C,this.K=x,this.C=y,this.L=k,this.U=g,this.$=w,this.ct=R,this.bt=A,this.jt=P||"clear the search query",this.m=B?`${B}-auto`:"auto",this.vt=I,this.J=S,this.A=V,this.I=j,this.R=null,this.o=`${this.m}-${this.G}-results`,this.S=`data-cache-auto-${this.G}`,this.it=`${this.m}-is-loading`,this.T=`${this.m}-is-active`,this.q=`${this.m}-selected`,this.xt=`${this.m}-selected-option`,this.ht=`${this.m}-error`,this.u=l("div"),this.l=l("ul"),this.k=l("button"),this.V=O,this.St={expression:/[|\\{}()[\]^$+*?]/g,replacement:"\\$&"},this.V.replacement||(this.V.replacement=this.St.replacement),this.V.expression||(this.V.expression=this.St.expression),this.t()}}}(); +var Autocomplete=function(){"use strict";const t=(t,s)=>{for(let i in s)"addClass"===i?e(t,"add",s[i]):"removeClass"===i?e(t,"remove",s[i]):t.setAttribute(i,s[i])},s=t=>(t.firstElementChild||t).textContent.trim(),i=(t,s)=>{t.scrollTop=t.offsetTop-s.offsetHeight},h=function(t,s){void 0===t&&(t=!1),t&&(e(t,"remove","hidden"),o(t,"click",s))},e=(t,s,i)=>t.classList[s](i),a=(s,i)=>{t(s,{"aria-activedescendant":i||""})},n=(t,s,i,h)=>{const e=h.previousSibling,a=e?e.offsetHeight:0;if("0"==t.getAttribute("aria-posinset")&&(h.scrollTop=t.offsetTop-((t,s)=>{const i=document.querySelectorAll(`#${t} > li:not(.${s})`);let h=0;return[].slice.call(i).map((t=>h+=t.offsetHeight)),h})(s,i)),t.offsetTop-ah.scrollTop+h.offsetHeight&&(h.scrollTop=s-h.offsetHeight)}},l=t=>document.createElement(t),r=t=>document.querySelector(t),o=(t,s,i)=>{t.addEventListener(s,i)},c=(t,s,i)=>{t.removeEventListener(s,i)},d=t=>({"aria-owns":t,"aria-expanded":"false","aria-autocomplete":"list",role:"combobox",removeClass:"auto-expanded"}),u=27,m=13,p=38,$=40,v=9;return class{constructor(b,f){let{delay:x=500,clearButton:y=!0,clearButtonOnInitial:C=!1,howManyCharacters:k=1,selectFirst:g=!1,insertToInput:w=!1,showAllValues:j=!1,cache:I=!1,disableCloseOnSelect:S=!1,preventScrollUp:V=!1,removeResultsWhenInputIsEmpty:O=!1,regex:R={expression:/[|\\{}()[\]^$+*?]/g,replacement:"\\$&"},classGroup:A,classPreventClosing:B,classPrefix:P,ariaLabelClear:T,onSearch:E,onResults:G=(()=>{}),onSubmit:J=(()=>{}),onOpened:N=(()=>{}),onReset:q=(()=>{}),onRender:z=(()=>{}),onClose:F=(()=>{}),noResults:L=(()=>{}),onSelectedItem:M=(()=>{})}=f;var U;this.t=()=>{this.i();const s=d(this.h);var i,e,a,n,l;t(this.l,s),i=this.l,e=this.o,a=this.h,n=this.u,l=this.m,t(e,{id:a,tabIndex:"0",role:"listbox"}),t(n,{addClass:`${l}-results-wrapper`}),n.insertAdjacentElement("beforeend",e),i.parentNode.insertBefore(n,i.nextSibling),o(this.l,"input",this.p),this.$&&o(this.l,"click",this.p),this.v({element:this.l,results:this.o}),this.C&&h(this.k,this.destroy)},this.j=(t,s)=>{this.I&&("update"===t?this.l.setAttribute(this.S,s.value):"remove"===t?this.l.removeAttribute(this.S):this.l.value=this.l.getAttribute(this.S))},this.p=t=>{let{target:s,type:i}=t;if("true"===this.l.getAttribute("aria-expanded")&&"click"===i)return;const h=s.value.replace(this.V.expression,this.V.replacement);this.j("update",s);const e=this.$?0:this.O;clearTimeout(this.R),this.R=setTimeout((()=>{this.A&&0===s.value.length?this.destroy():this.B(h.trim())}),e)},this.P=()=>{e(this.u,"remove",this.T);const s=d(this.h),i=this.G?s:{...s,"aria-activedescendant":""};t(this.l,i),this.G||(this.J(r(`.${this.N}`)),this.q=this.F?0:-1),(0==this.L?.length&&!this.M||this.$)&&(this.o.textContent=""),this.U()},this.B=t=>{this.W=t,this.D(!0),h(this.k,this.destroy),0==t.length&&this.H&&e(this.k,"add","hidden"),this.K>t.length&&!this.$?this.D():this.X({currentValue:t,element:this.l}).then((s=>{const i=this.l.value.length,h=s.length;this.L=Array.isArray(s)?s:JSON.parse(JSON.stringify(s)),this.D(),this.Y(),0==h&&0==i&&e(this.k,"add","hidden"),0==h&&i?(e(this.l,"remove","auto-expanded"),this.P(),this.Z({element:this.l,currentValue:t,template:this._}),this.tt()):(h>0||(t=>t&&"object"==typeof t&&t.constructor===Object)(s))&&(this.q=this.F?0:-1,this._(),this.tt())})).catch((()=>{this.D(),this.P()}))},this.D=t=>this.l.parentNode.classList[t?"add":"remove"](this.st),this.Y=()=>e(this.l,"remove",this.it),this.tt=()=>{o(this.l,"keydown",this.ht),o(this.l,"click",this.et),o(document,"click",this.nt),["mousemove","click"].map((t=>{o(this.o,t,this.lt)}))},this._=s=>{t(this.l,{"aria-expanded":"true",addClass:`${this.m}-expanded`}),this.o.textContent="";const h=0===this.L.length?this.rt({currentValue:this.W,matches:0,template:s}):this.rt({currentValue:this.W,matches:this.L,classGroup:this.ot});this.o.insertAdjacentHTML("afterbegin",h),e(this.u,"add",this.T);const a=this.ot?`:not(.${this.ot})`:"";this.ct=document.querySelectorAll(`#${this.h} > li${a}`),(s=>{for(let i=0;i{let{target:s}=t,i=null;(s.closest("ul")&&this.$t||s.closest(`.${this.vt}`))&&(i=!0),s.id===this.bt||i||this.P()},this.ut=()=>{if(this.J(r(`.${this.N}`)),!this.F)return;const{firstElementChild:s}=this.o,i=this.ot&&this.L.length>0&&this.F?s.nextElementSibling:s;this.ft({index:this.q,element:this.l,object:this.L[this.q]}),t(i,{id:`${this.xt}-0`,addClass:this.N,"aria-selected":"true"}),a(this.l,`${this.xt}-0`)},this.et=()=>{if(this.o.textContent.length>0&&!e(this.u,"contains",this.T)){if(t(this.l,{"aria-expanded":"true",addClass:`${this.m}-expanded`}),e(this.u,"add",this.T),this.G||(i(this.o,this.u),this.ut()),this.dt({type:"showItems",element:this.l,results:this.o}),!this.I)return;this.j("update",this.l)}},this.lt=t=>{t.preventDefault();const{target:s,type:i}=t,h=s.closest("li"),a=h?.hasAttribute("role"),n=this.N,l=r(`.${n}`);h&&a&&!s.closest(`.${this.vt}`)&&("click"===i&&this.yt(h),"mousemove"!==i||e(h,"contains",n)||(this.J(l),this.Ct(h),this.q=this.kt(h),this.ft({index:this.q,element:this.l,object:this.L[this.q]})))},this.yt=t=>{t&&0!==this.L.length?(this.H&&e(this.k,"remove","hidden"),this.l.value=s(t),this.gt({index:this.q,element:this.l,object:this.L[this.q],results:this.o}),this.$t||(this.G||this.J(t),this.P()),this.j("remove")):!this.$t&&this.P()},this.kt=t=>Array.prototype.indexOf.call(this.ct,t),this.ht=t=>{const{keyCode:i}=t,h=e(this.u,"contains",this.T),n=this.L.length+1;switch(this.wt=r(`.${this.N}`),i){case p:case $:if(t.preventDefault(),n<=1&&this.F||!h)return;if(i===p?(this.q<0&&(this.q=n-1),this.q-=1):(this.q+=1,this.q>=n&&(this.q=0)),this.J(this.wt),this.q>=0&&this.q{const i=`${this.xt}-${this.kt(s)}`;t(s,{id:i,"aria-selected":"true",addClass:this.N}),a(this.l,i),n(s,this.h,this.ot,this.o)},this.J=s=>{s&&t(s,{id:"",removeClass:this.N,"aria-selected":"false"})},this.i=()=>{this.H&&(t(this.k,{class:`${this.m}-clear hidden`,type:"button",title:this.jt,"aria-label":this.jt}),this.l.insertAdjacentElement("afterend",this.k))},this.rerender=t=>{const s=t?.trim()?t.trim():this.l.value;t?.trim()&&(this.l.value=t.trim(),this.j("update",this.l));const i=s.replace(this.V.expression,this.V.replacement);this.B(i.trim())},this.destroy=()=>{this.H&&e(this.k,"add","hidden"),this.l.value="",this.l.focus(),this.o.textContent="",this.P(),this.Y(),this.It(this.l),this.D(),c(this.l,"keydown",this.ht),c(this.l,"click",this.et),c(document,"click",this.nt)},this.bt=b,this.l=document.getElementById(b),this.X=(U=E,Boolean(U&&"function"==typeof U.then)?E:t=>{let{currentValue:s,element:i}=t;return Promise.resolve(E({currentValue:s,element:i}))}),this.rt=G,this.v=z,this.gt=J,this.ft=M,this.dt=N,this.It=q,this.Z=L,this.U=F,this.O=x,this.K=k,this.H=y,this.C=C,this.F=g,this.M=w,this.$=j,this.ot=A,this.vt=B,this.jt=T||"clear the search query",this.m=P?`${P}-auto`:"auto",this.$t=S,this.G=V,this.A=O,this.I=I,this.R=null,this.h=`${this.m}-${this.bt}-results`,this.S=`data-cache-auto-${this.bt}`,this.st=`${this.m}-is-loading`,this.T=`${this.m}-is-active`,this.N=`${this.m}-selected`,this.xt=`${this.m}-selected-option`,this.it=`${this.m}-error`,this.u=l("div"),this.o=l("ul"),this.k=l("button"),this.V=R,this.St={expression:/[|\\{}()[\]^$+*?]/g,replacement:"\\$&"},this.V.replacement||(this.V.replacement=this.St.replacement),this.V.expression||(this.V.expression=this.St.expression),this.t()}}}(); diff --git a/dist/js/autocomplete.umd.js b/dist/js/autocomplete.umd.js index c90b60f..99bc492 100644 --- a/dist/js/autocomplete.umd.js +++ b/dist/js/autocomplete.umd.js @@ -1,6 +1,6 @@ /*! * @name autocomplete -* @version 2.0.0 +* @version 2.0.1 * @author Grzegorz Tomicki * @link https://github.com/tomickigrzegorz/autocomplete * @license MIT @@ -35,7 +35,7 @@ tabindex: "-1", "aria-selected": "false", "aria-setsize": itemsLi.length, - "aria-posinset": i + "aria-posinset": i + 1 }); } }; @@ -95,6 +95,15 @@ const offEvent = (element, action, callback) => { element.removeEventListener(action, callback); }; + const ariaActiveDescendantDefault = id => { + return { + "aria-owns": id, + "aria-expanded": "false", + "aria-autocomplete": "list", + role: "combobox", + removeClass: "auto-expanded" + }; + }; const keyCodes = { ESC: 27, @@ -138,6 +147,8 @@ } = _ref; this._initial = () => { this._clearbutton(); + const ariaAcrivedescentDefault = ariaActiveDescendantDefault(this._outputUl); + setAttributes(this._root, ariaAcrivedescentDefault); output(this._root, this._resultList, this._outputUl, this._resultWrap, this._prefix); onEvent(this._root, "input", this._handleInput); this._showAll && onEvent(this._root, "click", this._handleInput); @@ -183,13 +194,7 @@ }; this._reset = () => { classList(this._resultWrap, "remove", this._isActive); - const ariaAcrivedescentDefault = { - "aria-owns": `${this._id}-list`, - "aria-expanded": "false", - "aria-autocomplete": "list", - role: "combobox", - removeClass: "auto-expanded" - }; + const ariaAcrivedescentDefault = ariaActiveDescendantDefault(this._outputUl); const ariaAcrivedescent = this._preventScrollUp ? ariaAcrivedescentDefault : { ...ariaAcrivedescentDefault, "aria-activedescendant": "" diff --git a/dist/js/autocomplete.umd.js.map b/dist/js/autocomplete.umd.js.map index 444879b..f27dcc5 100644 --- a/dist/js/autocomplete.umd.js.map +++ b/dist/js/autocomplete.umd.js.map @@ -1 +1 @@ -{"version":3,"file":"autocomplete.umd.js","sources":["../../sources/js/utils/function.js","../../sources/js/utils/keyCodes.js","../../sources/js/script.js"],"sourcesContent":["/**\r\n * Check is a Object\r\n * @param {Object} value\r\n * @returns {Boolean}\r\n */\r\nconst isObject = (value) =>\r\n value && typeof value === \"object\" && value.constructor === Object;\r\n\r\n/**\r\n * Check if is a Promise\r\n * https://stackoverflow.com/a/53955664/10424385\r\n *\r\n * @param {Object} value\r\n * @returns {Boolean}\r\n */\r\nconst isPromise = (value) => Boolean(value && typeof value.then === \"function\");\r\n\r\n/**\r\n * Set attributes to element\r\n *\r\n * @param {HTMLElement} el\r\n * @param {Object} object\r\n */\r\nconst setAttributes = (el, object) => {\r\n for (let key in object) {\r\n if (key === \"addClass\") {\r\n classList(el, \"add\", object[key]);\r\n } else if (key === \"removeClass\") {\r\n classList(el, \"remove\", object[key]);\r\n } else {\r\n el.setAttribute(key, object[key]);\r\n }\r\n }\r\n};\r\n\r\n/**\r\n * Get first element from child\r\n *\r\n * @param {HTMLElement} element\r\n * @returns {HTMLELement}\r\n */\r\nconst getFirstElement = (element) =>\r\n (element.firstElementChild || element).textContent.trim();\r\n\r\n/**\r\n * Scroll to top result-list\r\n * @param {HTMLElement} resultList\r\n * @param {HTMLElement} resultWrap\r\n */\r\nconst scrollResultsToTop = (resultList, resultWrap) => {\r\n // if there is an overflow of ul element, after\r\n // opening we always move ul to the top of the results\r\n resultList.scrollTop = resultList.offsetTop - resultWrap.offsetHeight;\r\n};\r\n\r\n/**\r\n * Adding role, tabindex, aria and call handleMouse\r\n *\r\n * @param {HTMLElement} itemsLi\r\n */\r\nconst addAriaToAllLiElements = (itemsLi) => {\r\n // add role to all li elements\r\n for (let i = 0; i < itemsLi.length; i++) {\r\n setAttributes(itemsLi[i], {\r\n role: \"option\",\r\n tabindex: \"-1\",\r\n \"aria-selected\": \"false\",\r\n \"aria-setsize\": itemsLi.length,\r\n \"aria-posinset\": i,\r\n });\r\n }\r\n};\r\n\r\n/**\r\n * Show btn to clear data\r\n *\r\n * @param {HTMLElement} clearButton - button to clear data\r\n * @param {Function} destroy - destroy function\r\n */\r\nconst showBtnToClearData = (clearButton = false, destroy) => {\r\n if (!clearButton) return;\r\n\r\n classList(clearButton, \"remove\", \"hidden\");\r\n // add event to clear button\r\n onEvent(clearButton, \"click\", destroy);\r\n};\r\n\r\n/**\r\n * ClassList add/remove/contains\r\n *\r\n * @param {HTMLElement} element - html element\r\n * @param {String} action - add/remove/contains\r\n * @param {String} className - class name\r\n */\r\nconst classList = (element, action, className) =>\r\n element.classList[action](className);\r\n\r\n/**\r\n * Set aria-activedescendant\r\n *\r\n * @param {HTMLElement} root - search input\r\n * @param {String} type\r\n */\r\nconst setAriaActivedescendant = (root, type) => {\r\n setAttributes(root, {\r\n \"aria-activedescendant\": type || \"\",\r\n });\r\n};\r\n\r\n/**\r\n * Get height of ul without group class\r\n *\r\n * @param {String} outputUl\r\n * @param {String} classGroup\r\n * @returns {Number}\r\n */\r\nconst getClassGroupHeight = (outputUl, classGroup) => {\r\n // get height of ul without group class\r\n const allLiElements = document.querySelectorAll(\r\n `#${outputUl} > li:not(.${classGroup})`,\r\n );\r\n let height = 0;\r\n [].slice.call(allLiElements).map((el) => (height += el.offsetHeight));\r\n\r\n // return height\r\n return height;\r\n};\r\n\r\n/**\r\n * Scroll into view when press up/down arrows\r\n *\r\n * @param {HTMLElement} target\r\n * @param {HTMLElement} outputUl\r\n * @param {String} classGroup\r\n * @param {HTMLElement} resultList\r\n */\r\nconst followActiveElement = (target, outputUl, classGroup, resultList) => {\r\n const previusElement = resultList.previousSibling;\r\n\r\n const previusElementHeight = previusElement ? previusElement.offsetHeight : 0;\r\n\r\n if (target.getAttribute(\"aria-posinset\") == \"0\") {\r\n resultList.scrollTop =\r\n target.offsetTop - getClassGroupHeight(outputUl, classGroup);\r\n }\r\n\r\n if (target.offsetTop - previusElementHeight < resultList.scrollTop) {\r\n resultList.scrollTop = target.offsetTop - previusElementHeight;\r\n } else {\r\n const offsetBottom =\r\n target.offsetTop + target.offsetHeight - previusElementHeight;\r\n const scrollBottom = resultList.scrollTop + resultList.offsetHeight;\r\n if (offsetBottom > scrollBottom) {\r\n resultList.scrollTop = offsetBottom - resultList.offsetHeight;\r\n }\r\n }\r\n};\r\n\r\n/**\r\n * Create output-list and put after search input\r\n *\r\n * @param {HTMLElement} root - search input\r\n * @param {HTMLElement} resultList - output-list ul\r\n * @param {String} outputUl - id name of output-list\r\n * @param {HTMLElement} resultWrap - wrapper ul element\r\n * @param {String} prefix - add prefix to all class auto\r\n */\r\nconst output = (root, resultList, outputUl, resultWrap, prefix) => {\r\n // set attribute to results-list\r\n setAttributes(resultList, {\r\n id: outputUl,\r\n tabIndex: \"0\",\r\n role: \"listbox\",\r\n });\r\n\r\n // add class to wrap element\r\n setAttributes(resultWrap, {\r\n addClass: `${prefix}-results-wrapper`,\r\n });\r\n\r\n // insert the results into the wrap element\r\n resultWrap.insertAdjacentElement(\"beforeend\", resultList);\r\n\r\n // insert the wrap element after the search input\r\n root.parentNode.insertBefore(resultWrap, root.nextSibling);\r\n};\r\n\r\n/**\r\n * Create element\r\n *\r\n * @param {String} type - type of element\r\n * @returns {HTMLDivElement}\r\n */\r\nconst createElement = (type) => document.createElement(type);\r\n\r\n/**\r\n * Get element\r\n *\r\n * @param {String} element\r\n * @returns {HTMLElement}\r\n */\r\nconst select = (element) => document.querySelector(element);\r\n\r\n/**\r\n * Event listeners\r\n *\r\n * @param {HTMLElement} element\r\n * @param {String} action\r\n * @param {Function} callback\r\n */\r\nconst onEvent = (element, action, callback) => {\r\n element.addEventListener(action, callback);\r\n};\r\n\r\n/**\r\n * Remove event listeners\r\n */\r\nconst offEvent = (element, action, callback) => {\r\n element.removeEventListener(action, callback);\r\n};\r\n\r\nexport {\r\n addAriaToAllLiElements,\r\n classList,\r\n createElement,\r\n followActiveElement,\r\n getFirstElement,\r\n isObject,\r\n isPromise,\r\n offEvent,\r\n onEvent,\r\n output,\r\n scrollResultsToTop,\r\n select,\r\n setAriaActivedescendant,\r\n setAttributes,\r\n showBtnToClearData,\r\n};\r\n","/**\r\n * Key codes\r\n */\r\nconst keyCodes = {\r\n ESC: 27,\r\n ENTER: 13,\r\n UP: 38,\r\n DOWN: 40,\r\n TAB: 9,\r\n};\r\n\r\nexport default keyCodes;\r\n","import {\r\n addAriaToAllLiElements,\r\n classList,\r\n createElement,\r\n followActiveElement,\r\n getFirstElement,\r\n isObject,\r\n isPromise,\r\n offEvent,\r\n onEvent,\r\n output,\r\n scrollResultsToTop,\r\n select,\r\n setAriaActivedescendant,\r\n setAttributes,\r\n showBtnToClearData,\r\n} from \"./utils/function\";\r\n\r\nimport keyCodes from \"./utils/keyCodes\";\r\n\r\n/**\r\n * @class Autocomplete\r\n */\r\nexport default class Autocomplete {\r\n /**\r\n * Constructor\r\n *\r\n * @param {String} element\r\n * @param {Object} object\r\n */\r\n constructor(\r\n element,\r\n {\r\n delay = 500,\r\n clearButton = true,\r\n clearButtonOnInitial = false,\r\n howManyCharacters = 1,\r\n selectFirst = false,\r\n insertToInput = false,\r\n showAllValues = false,\r\n cache = false,\r\n disableCloseOnSelect = false,\r\n preventScrollUp = false,\r\n removeResultsWhenInputIsEmpty = false,\r\n regex = { expression: /[|\\\\{}()[\\]^$+*?]/g, replacement: \"\\\\$&\" },\r\n classGroup,\r\n classPreventClosing,\r\n classPrefix,\r\n ariaLabelClear,\r\n onSearch,\r\n onResults = () => {},\r\n onSubmit = () => {},\r\n onOpened = () => {},\r\n onReset = () => {},\r\n onRender = () => {},\r\n onClose = () => {},\r\n noResults = () => {},\r\n onSelectedItem = () => {},\r\n },\r\n ) {\r\n this._id = element;\r\n this._root = document.getElementById(element);\r\n this._onSearch = isPromise(onSearch)\r\n ? onSearch\r\n : ({ currentValue, element }) =>\r\n Promise.resolve(onSearch({ currentValue, element }));\r\n this._onResults = onResults;\r\n this._onRender = onRender;\r\n this._onSubmit = onSubmit;\r\n this._onSelected = onSelectedItem;\r\n this._onOpened = onOpened;\r\n this._onReset = onReset;\r\n this._noResults = noResults;\r\n this._onClose = onClose;\r\n\r\n this._delay = delay;\r\n this._characters = howManyCharacters;\r\n this._clearButton = clearButton;\r\n this._clearButtonOnInitial = clearButtonOnInitial;\r\n this._selectFirst = selectFirst;\r\n this._toInput = insertToInput;\r\n this._showAll = showAllValues;\r\n this._classGroup = classGroup;\r\n this._prevClosing = classPreventClosing;\r\n this._clearBtnAriLabel = ariaLabelClear\r\n ? ariaLabelClear\r\n : \"clear the search query\";\r\n this._prefix = classPrefix ? `${classPrefix}-auto` : \"auto\";\r\n this._disable = disableCloseOnSelect;\r\n this._preventScrollUp = preventScrollUp;\r\n this._removeResultsWhenInputIsEmpty = removeResultsWhenInputIsEmpty;\r\n\r\n // default config\r\n this._cache = cache;\r\n this._timeout = null;\r\n this._outputUl = `${this._prefix}-${this._id}-results`;\r\n this._cacheData = `data-cache-auto-${this._id}`;\r\n this._isLoading = `${this._prefix}-is-loading`;\r\n this._isActive = `${this._prefix}-is-active`;\r\n this._activeList = `${this._prefix}-selected`;\r\n this._selectedOption = `${this._prefix}-selected-option`;\r\n this._err = `${this._prefix}-error`;\r\n this._resultWrap = createElement(\"div\");\r\n this._resultList = createElement(\"ul\");\r\n this._clearBtn = createElement(\"button\");\r\n\r\n // ----------------------------------------\r\n // regex\r\n\r\n this._regex = regex;\r\n this._defaultExpression = {\r\n expression: /[|\\\\{}()[\\]^$+*?]/g,\r\n replacement: \"\\\\$&\",\r\n };\r\n\r\n // if regex is don't have replacement then set default\r\n if (!this._regex.replacement) {\r\n this._regex.replacement = this._defaultExpression.replacement;\r\n }\r\n\r\n // if regex is don't have expression then set default\r\n if (!this._regex.expression) {\r\n this._regex.expression = this._defaultExpression.expression;\r\n }\r\n\r\n // ----------------------------------------\r\n\r\n this._initial();\r\n }\r\n\r\n /**\r\n * Initial function\r\n */\r\n _initial = () => {\r\n this._clearbutton();\r\n\r\n output(\r\n this._root,\r\n this._resultList,\r\n this._outputUl,\r\n this._resultWrap,\r\n this._prefix,\r\n );\r\n\r\n // default aria\r\n onEvent(this._root, \"input\", this._handleInput);\r\n\r\n // show all values on click root input\r\n this._showAll && onEvent(this._root, \"click\", this._handleInput);\r\n\r\n // calback functions\r\n this._onRender({\r\n element: this._root,\r\n results: this._resultList,\r\n });\r\n\r\n // show clear button if\r\n if (this._clearButtonOnInitial) {\r\n showBtnToClearData(this._clearBtn, this.destroy);\r\n }\r\n };\r\n\r\n /**\r\n * Actions on input\r\n *\r\n * @param {String} type - set attribute depending on type\r\n * @param {String} target\r\n */\r\n _cacheAct = (type, target) => {\r\n if (!this._cache) return;\r\n\r\n if (type === \"update\") {\r\n this._root.setAttribute(this._cacheData, target.value);\r\n } else if (type === \"remove\") {\r\n this._root.removeAttribute(this._cacheData);\r\n } else {\r\n this._root.value = this._root.getAttribute(this._cacheData);\r\n }\r\n };\r\n\r\n /**\r\n * Handle input\r\n *\r\n * @param {Event} object\r\n */\r\n _handleInput = ({ target, type }) => {\r\n if (\r\n this._root.getAttribute(\"aria-expanded\") === \"true\" &&\r\n type === \"click\"\r\n ) {\r\n return;\r\n }\r\n\r\n // replace all special characters\r\n const regex = target.value.replace(\r\n this._regex.expression,\r\n this._regex.replacement,\r\n );\r\n\r\n // update data attribute cache\r\n this._cacheAct(\"update\", target);\r\n\r\n const delay = this._showAll ? 0 : this._delay;\r\n // clear timeout\r\n clearTimeout(this._timeout);\r\n this._timeout = setTimeout(() => {\r\n // removeResultsWhenInputIsEmpty\r\n // remove results when input is empty\r\n if (this._removeResultsWhenInputIsEmpty) {\r\n if (target.value.length === 0) {\r\n this.destroy();\r\n return;\r\n }\r\n }\r\n\r\n this._searchItem(regex.trim());\r\n }, delay);\r\n };\r\n\r\n /**\r\n * Default aria\r\n */\r\n _reset = () => {\r\n // remove class isActive\r\n classList(this._resultWrap, \"remove\", this._isActive);\r\n\r\n const ariaAcrivedescentDefault = {\r\n \"aria-owns\": `${this._id}-list`,\r\n \"aria-expanded\": \"false\",\r\n \"aria-autocomplete\": \"list\",\r\n role: \"combobox\",\r\n removeClass: \"auto-expanded\",\r\n };\r\n\r\n const ariaAcrivedescent = this._preventScrollUp\r\n ? ariaAcrivedescentDefault\r\n : { ...ariaAcrivedescentDefault, \"aria-activedescendant\": \"\" };\r\n\r\n // set attributes to root - input\r\n setAttributes(this._root, ariaAcrivedescent);\r\n\r\n if (!this._preventScrollUp) {\r\n // set default aria-selected, remove id and remove class 'auto-selected'\r\n this._removeAria(select(`.${this._activeList}`));\r\n\r\n // set index\r\n this._index = this._selectFirst ? 0 : -1;\r\n }\r\n\r\n // remove result when lengh = 0 and insertToInput is false\r\n // https://github.com/tomickigrzegorz/autocomplete/issues/136\r\n if ((this._matches?.length == 0 && !this._toInput) || this._showAll) {\r\n this._resultList.textContent = \"\";\r\n }\r\n\r\n // callback function\r\n this._onClose();\r\n };\r\n\r\n /**\r\n * The async function gets the text from the search\r\n * and returns the matching array\r\n *\r\n * @param {String} value\r\n */\r\n _searchItem = (value) => {\r\n this._value = value;\r\n\r\n // if searching show loading icon\r\n this._onLoading(true);\r\n\r\n // hide button clear\r\n showBtnToClearData(this._clearBtn, this.destroy);\r\n\r\n // if there is no value and clearButton is true\r\n if (value.length == 0 && this._clearButton) {\r\n classList(this._clearBtn, \"add\", \"hidden\");\r\n }\r\n\r\n // if declare characters more then value.len and showAll is false\r\n // remove class isActive\r\n if (this._characters > value.length && !this._showAll) {\r\n this._onLoading();\r\n return;\r\n }\r\n\r\n // callblack function onSearch\r\n this._onSearch({ currentValue: value, element: this._root })\r\n .then((result) => {\r\n const rootValueLength = this._root.value.length;\r\n const resultLength = result.length;\r\n // set no result\r\n this._matches = Array.isArray(result)\r\n ? result\r\n : JSON.parse(JSON.stringify(result));\r\n\r\n this._onLoading();\r\n this._error();\r\n\r\n // if use destroy() method\r\n if (resultLength == 0 && rootValueLength == 0) {\r\n classList(this._clearBtn, \"add\", \"hidden\");\r\n }\r\n\r\n if (resultLength == 0 && rootValueLength) {\r\n classList(this._root, \"remove\", \"auto-expanded\");\r\n this._reset();\r\n this._noResults({\r\n element: this._root,\r\n currentValue: value,\r\n template: this._results,\r\n });\r\n this._events();\r\n } else if (resultLength > 0 || isObject(result)) {\r\n this._index = this._selectFirst ? 0 : -1;\r\n this._results();\r\n this._events();\r\n }\r\n })\r\n .catch(() => {\r\n this._onLoading();\r\n this._reset();\r\n });\r\n };\r\n\r\n /**\r\n * Set or remove loading class\r\n *\r\n * @param {Boolean} type\r\n */\r\n _onLoading = (type) =>\r\n this._root.parentNode.classList[type ? \"add\" : \"remove\"](this._isLoading);\r\n\r\n /**\r\n * Set error class to the root element\r\n */\r\n _error = () => classList(this._root, \"remove\", this._err);\r\n\r\n /**\r\n * Events\r\n */\r\n _events = () => {\r\n // handle click on keydown [up, down, enter, tab, esc]\r\n onEvent(this._root, \"keydown\", this._handleKeys);\r\n\r\n onEvent(this._root, \"click\", this._handleShowItems);\r\n\r\n // close expanded items\r\n onEvent(document, \"click\", this._handleDocClick);\r\n\r\n // temporarily disabled mouseleave\r\n [\"mousemove\", \"click\"].map((eventType) => {\r\n onEvent(this._resultList, eventType, this._handleMouse);\r\n });\r\n };\r\n\r\n /**\r\n * Results\r\n *\r\n * @param {HTMLElement|String} template - html or string returned from the function,\r\n * look at the example - https://github.com/tomickigrzegorz/autocomplete/blob/master/docs/js/examples/no-results.js#L30\r\n */\r\n _results = (template) => {\r\n // set attribute to root\r\n setAttributes(this._root, {\r\n \"aria-expanded\": \"true\",\r\n addClass: `${this._prefix}-expanded`,\r\n });\r\n\r\n // clear result list\r\n this._resultList.textContent = \"\";\r\n\r\n // add all found records to otput ul\r\n const dataResults =\r\n this._matches.length === 0\r\n ? this._onResults({\r\n currentValue: this._value,\r\n matches: 0,\r\n template,\r\n })\r\n : this._onResults({\r\n currentValue: this._value,\r\n matches: this._matches,\r\n classGroup: this._classGroup,\r\n });\r\n\r\n // add data to ul\r\n this._resultList.insertAdjacentHTML(\"afterbegin\", dataResults);\r\n\r\n // add class isActive\r\n classList(this._resultWrap, \"add\", this._isActive);\r\n\r\n const checkIfClassGroupExist = this._classGroup\r\n ? `:not(.${this._classGroup})`\r\n : \"\";\r\n\r\n this._itemsLi = document.querySelectorAll(\r\n `#${this._outputUl} > li${checkIfClassGroupExist}`,\r\n );\r\n\r\n // adding role, tabindex and aria\r\n addAriaToAllLiElements(this._itemsLi);\r\n\r\n // action on open results\r\n this._onOpened({\r\n type: \"results\",\r\n element: this._root,\r\n results: this._resultList,\r\n });\r\n\r\n // select first element\r\n this._selectFirstElement();\r\n\r\n // move the view item to the first item\r\n // this.resultList.scrollTop = 0;\r\n // if (this._preventScrollUp) return;\r\n scrollResultsToTop(this._resultList, this._resultWrap);\r\n };\r\n\r\n /**\r\n * Hangle click on document\r\n *\r\n * @param {Event} object\r\n */\r\n _handleDocClick = ({ target }) => {\r\n let disableClose = null;\r\n\r\n // if 'target' is a ul and 'disableCloseOnSelect'\r\n // is a 'true' set 'disableClose' on true\r\n if (\r\n (target.closest(\"ul\") && this._disable) ||\r\n // when class classDisableClose\r\n // then do not not close results\r\n target.closest(`.${this._prevClosing}`)\r\n ) {\r\n disableClose = true;\r\n }\r\n\r\n if (target.id !== this._id && !disableClose) {\r\n this._reset();\r\n return;\r\n }\r\n };\r\n\r\n /**\r\n * Select first element\r\n */\r\n _selectFirstElement = () => {\r\n this._removeAria(select(`.${this._activeList}`));\r\n\r\n if (!this._selectFirst) {\r\n return;\r\n }\r\n\r\n const { firstElementChild } = this._resultList;\r\n\r\n const classSelectFirst =\r\n this._classGroup && this._matches.length > 0 && this._selectFirst\r\n ? firstElementChild.nextElementSibling\r\n : firstElementChild;\r\n\r\n // calback function onSelect when first element is true\r\n this._onSelected({\r\n index: this._index,\r\n element: this._root,\r\n object: this._matches[this._index],\r\n });\r\n\r\n // set attribute to first element\r\n setAttributes(classSelectFirst, {\r\n id: `${this._selectedOption}-0`,\r\n addClass: this._activeList,\r\n \"aria-selected\": \"true\",\r\n });\r\n\r\n // set aria active descendant\r\n setAriaActivedescendant(this._root, `${this._selectedOption}-0`);\r\n };\r\n\r\n /**\r\n * show items when items.length > 0 and is not empty\r\n */\r\n _handleShowItems = () => {\r\n // if resultWrap is not active and resultList is not empty\r\n if (\r\n this._resultList.textContent.length > 0 &&\r\n !classList(this._resultWrap, \"contains\", this._isActive)\r\n ) {\r\n // set attribute to root\r\n setAttributes(this._root, {\r\n \"aria-expanded\": \"true\",\r\n addClass: `${this._prefix}-expanded`,\r\n });\r\n\r\n // add isActive class to resultWrap\r\n classList(this._resultWrap, \"add\", this._isActive);\r\n\r\n // move the view item to the first item\r\n // this.resultList.scrollTop = 0;\r\n if (!this._preventScrollUp) {\r\n scrollResultsToTop(this._resultList, this._resultWrap);\r\n // select first element\r\n this._selectFirstElement();\r\n }\r\n\r\n // callback function\r\n this._onOpened({\r\n type: \"showItems\",\r\n element: this._root,\r\n results: this._resultList,\r\n });\r\n\r\n if (!this._cache) return;\r\n this._cacheAct(\"update\", this._root);\r\n }\r\n };\r\n\r\n /**\r\n * Adding text from the list when li is clicking\r\n * or adding aria-selected to li elements\r\n *\r\n * @param {Event} event\r\n */\r\n _handleMouse = (event) => {\r\n event.preventDefault();\r\n\r\n const { target, type } = event;\r\n const targetClosest = target.closest(\"li\");\r\n const targetClosestRole = targetClosest?.hasAttribute(\"role\");\r\n const activeClass = this._activeList;\r\n const activeClassElement = select(`.${activeClass}`);\r\n\r\n if (\r\n !targetClosest ||\r\n !targetClosestRole ||\r\n target.closest(`.${this._prevClosing}`)\r\n ) {\r\n return;\r\n }\r\n\r\n if (type === \"click\") {\r\n // click on li get element\r\n // get text from clicked li\r\n this._getTextFromLi(targetClosest);\r\n }\r\n\r\n if (\r\n type === \"mousemove\" &&\r\n !classList(targetClosest, \"contains\", activeClass)\r\n ) {\r\n this._removeAria(activeClassElement);\r\n\r\n // add aria to li\r\n this._setAria(targetClosest);\r\n this._index = this._indexLiSelected(targetClosest);\r\n\r\n this._onSelected({\r\n index: this._index,\r\n element: this._root,\r\n object: this._matches[this._index],\r\n });\r\n }\r\n };\r\n\r\n /**\r\n * Get text from li on enter or click\r\n *\r\n * @param {HTMLElement} element\r\n */\r\n _getTextFromLi = (element) => {\r\n if (!element || this._matches.length === 0) {\r\n // set default settings\r\n !this._disable && this._reset();\r\n\r\n return;\r\n }\r\n\r\n // show clearBtn when select element\r\n this._clearButton && classList(this._clearBtn, \"remove\", \"hidden\");\r\n\r\n // get first element from li and set it to root\r\n this._root.value = getFirstElement(element);\r\n\r\n // onSubmit passing text to function\r\n this._onSubmit({\r\n index: this._index,\r\n element: this._root,\r\n object: this._matches[this._index],\r\n results: this._resultList,\r\n });\r\n\r\n // set default settings\r\n if (!this._disable) {\r\n if (!this._preventScrollUp) {\r\n this._removeAria(element);\r\n }\r\n this._reset();\r\n }\r\n\r\n // remove cache\r\n this._cacheAct(\"remove\");\r\n };\r\n\r\n /**\r\n * Return which li element was selected\r\n * by hovering the mouse over\r\n *\r\n * @param {HTMLElement} target\r\n * @returns {Number}\r\n */\r\n _indexLiSelected = (target) =>\r\n // get index of li element\r\n Array.prototype.indexOf.call(this._itemsLi, target);\r\n\r\n /**\r\n * Navigating the elements li and enter\r\n *\r\n * @param {Event} event\r\n */\r\n _handleKeys = (event) => {\r\n const { keyCode } = event;\r\n\r\n const resultList = classList(this._resultWrap, \"contains\", this._isActive);\r\n\r\n const matchesLength = this._matches.length + 1;\r\n this._selectedLi = select(`.${this._activeList}`);\r\n\r\n // switch between keys\r\n switch (keyCode) {\r\n case keyCodes.UP:\r\n case keyCodes.DOWN:\r\n // Wrong cursor position in the input field #62\r\n // Prevents the cursor from moving to the beginning\r\n // of input as the cursor hovers over the results.\r\n event.preventDefault();\r\n\r\n if ((matchesLength <= 1 && this._selectFirst) || !resultList) {\r\n return;\r\n }\r\n\r\n // if keyCode is up\r\n if (keyCode === keyCodes.UP) {\r\n if (this._index < 0) {\r\n this._index = matchesLength - 1;\r\n }\r\n this._index -= 1;\r\n } else {\r\n this._index += 1;\r\n if (this._index >= matchesLength) {\r\n this._index = 0;\r\n }\r\n }\r\n\r\n // remove aria-selected\r\n this._removeAria(this._selectedLi);\r\n\r\n if (this._index >= 0 && this._index < matchesLength - 1) {\r\n const selectedElement = this._itemsLi[this._index];\r\n\r\n if (this._toInput && resultList) {\r\n this._root.value = getFirstElement(selectedElement);\r\n }\r\n\r\n // callback function\r\n this._onSelected({\r\n index: this._index,\r\n element: this._root,\r\n object: this._matches[this._index],\r\n });\r\n\r\n // set aria-selected\r\n this._setAria(selectedElement);\r\n } else {\r\n // catch action\r\n this._cacheAct();\r\n setAriaActivedescendant(this._root);\r\n\r\n this._onSelected({\r\n index: null,\r\n element: this._root,\r\n object: null,\r\n });\r\n }\r\n\r\n break;\r\n // keycode enter\r\n case keyCodes.ENTER:\r\n // https:github.com/tomickigrzegorz/autocomplete/issues/145\r\n event.preventDefault();\r\n\r\n this._getTextFromLi(this._selectedLi);\r\n break;\r\n\r\n // keycode escape and keycode tab\r\n case keyCodes.TAB:\r\n case keyCodes.ESC:\r\n event.stopPropagation();\r\n this._reset();\r\n\r\n break;\r\n default:\r\n break;\r\n }\r\n };\r\n\r\n /**\r\n * Set aria label on item li\r\n *\r\n * @param {HTMLElement} target\r\n */\r\n _setAria = (target) => {\r\n const selectedOption = `${this._selectedOption}-${this._indexLiSelected(\r\n target,\r\n )}`;\r\n\r\n // set aria to li\r\n setAttributes(target, {\r\n id: selectedOption,\r\n \"aria-selected\": \"true\",\r\n addClass: this._activeList,\r\n });\r\n\r\n setAriaActivedescendant(this._root, selectedOption);\r\n\r\n // scrollIntoView when press up/down arrows\r\n followActiveElement(\r\n target,\r\n this._outputUl,\r\n this._classGroup,\r\n this._resultList,\r\n );\r\n };\r\n\r\n /**\r\n * Remove aria label from item li\r\n *\r\n * @param {HTMLElement} element\r\n */\r\n _removeAria = (element) => {\r\n if (!element) return;\r\n\r\n // remove aria from li\r\n setAttributes(element, {\r\n id: \"\",\r\n removeClass: this._activeList,\r\n \"aria-selected\": \"false\",\r\n });\r\n };\r\n\r\n /**\r\n * Create clear button and\r\n * removing text from the input field\r\n */\r\n _clearbutton = () => {\r\n // stop when clear button is disabled\r\n if (!this._clearButton) return;\r\n\r\n // add aria to clear button\r\n setAttributes(this._clearBtn, {\r\n class: `${this._prefix}-clear hidden`,\r\n type: \"button\",\r\n title: this._clearBtnAriLabel,\r\n \"aria-label\": this._clearBtnAriLabel,\r\n });\r\n\r\n // insert clear button after input - root\r\n this._root.insertAdjacentElement(\"afterend\", this._clearBtn);\r\n };\r\n\r\n /**\r\n * Rerender rows without remove root input and close elements\r\n */\r\n rerender = (inputValue) => {\r\n const text = inputValue?.trim() ? inputValue.trim() : this._root.value;\r\n if (inputValue?.trim()) {\r\n this._root.value = inputValue.trim();\r\n this._cacheAct(\"update\", this._root);\r\n }\r\n const regexText = text.replace(\r\n this._regex.expression,\r\n this._regex.replacement,\r\n );\r\n this._searchItem(regexText.trim());\r\n };\r\n\r\n /**\r\n * Clicking on the clear button\r\n * publick destroy method\r\n */\r\n destroy = () => {\r\n // if clear button is true then add class hidden\r\n this._clearButton && classList(this._clearBtn, \"add\", \"hidden\");\r\n // clear value searchId\r\n this._root.value = \"\";\r\n // set focus\r\n this._root.focus();\r\n // remove li from ul\r\n this._resultList.textContent = \"\";\r\n // set default aria\r\n this._reset();\r\n // remove error if exist\r\n this._error();\r\n // callback function\r\n this._onReset(this._root);\r\n // remove animation on loading\r\n this._onLoading();\r\n\r\n // remove listener\r\n offEvent(this._root, \"keydown\", this._handleKeys);\r\n offEvent(this._root, \"click\", this._handleShowItems);\r\n // remove listener on click on document\r\n offEvent(document, \"click\", this._handleDocClick);\r\n };\r\n}\r\n"],"names":["isObject","value","constructor","Object","isPromise","Boolean","then","setAttributes","el","object","key","classList","setAttribute","getFirstElement","element","firstElementChild","textContent","trim","scrollResultsToTop","resultList","resultWrap","scrollTop","offsetTop","offsetHeight","addAriaToAllLiElements","itemsLi","i","length","role","tabindex","showBtnToClearData","clearButton","destroy","onEvent","action","className","setAriaActivedescendant","root","type","getClassGroupHeight","outputUl","classGroup","allLiElements","document","querySelectorAll","height","slice","call","map","followActiveElement","target","previusElement","previousSibling","previusElementHeight","getAttribute","offsetBottom","scrollBottom","output","prefix","id","tabIndex","addClass","insertAdjacentElement","parentNode","insertBefore","nextSibling","createElement","select","querySelector","callback","addEventListener","offEvent","removeEventListener","keyCodes","ESC","ENTER","UP","DOWN","TAB","Autocomplete","_ref","delay","clearButtonOnInitial","howManyCharacters","selectFirst","insertToInput","showAllValues","cache","disableCloseOnSelect","preventScrollUp","removeResultsWhenInputIsEmpty","regex","expression","replacement","classPreventClosing","classPrefix","ariaLabelClear","onSearch","onResults","onSubmit","onOpened","onReset","onRender","onClose","noResults","onSelectedItem","_initial","_clearbutton","_root","_resultList","_outputUl","_resultWrap","_prefix","_handleInput","_showAll","_onRender","results","_clearButtonOnInitial","_clearBtn","_cacheAct","_cache","_cacheData","removeAttribute","_ref2","replace","_regex","_delay","clearTimeout","_timeout","setTimeout","_removeResultsWhenInputIsEmpty","_searchItem","_reset","_isActive","ariaAcrivedescentDefault","_id","removeClass","ariaAcrivedescent","_preventScrollUp","_removeAria","_activeList","_index","_selectFirst","_matches","_toInput","_onClose","_value","_onLoading","_clearButton","_characters","_onSearch","currentValue","result","rootValueLength","resultLength","Array","isArray","JSON","parse","stringify","_error","_noResults","template","_results","_events","catch","_isLoading","_err","_handleKeys","_handleShowItems","_handleDocClick","eventType","_handleMouse","dataResults","_onResults","matches","_classGroup","insertAdjacentHTML","checkIfClassGroupExist","_itemsLi","_onOpened","_selectFirstElement","_ref3","disableClose","closest","_disable","_prevClosing","classSelectFirst","nextElementSibling","_onSelected","index","_selectedOption","event","preventDefault","targetClosest","targetClosestRole","hasAttribute","activeClass","activeClassElement","_getTextFromLi","_setAria","_indexLiSelected","_onSubmit","prototype","indexOf","keyCode","matchesLength","_selectedLi","selectedElement","stopPropagation","selectedOption","class","title","_clearBtnAriLabel","rerender","inputValue","text","regexText","focus","_onReset","getElementById","_ref4","Promise","resolve","_defaultExpression"],"mappings":";;;;;;;;;;;;;EAKA,MAAMA,QAAQ,GAAIC,KAAK,IACrBA,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,CAACC,WAAW,KAAKC,MAAM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CAAA,CAAA;EACnC,IAAA,IAAI,CAACD,WAAW,GAAG7C,aAAa,CAAC,KAAK,CAAC,CAAA;EACvC,IAAA,IAAI,CAAC2C,WAAW,GAAG3C,aAAa,CAAC,IAAI,CAAC,CAAA;EACtC,IAAA,IAAI,CAACoD,SAAS,GAAGpD,aAAa,CAAC,QAAQ,CAAC,CAAA;MAKxC,IAAI,CAAC2D,MAAM,GAAGlC,MAAK,CAAA;MACnB,IAAI,CAACqI,kBAAkB,GAAG;EACxBpI,MAAAA,UAAU,EAAE,oBAAoB;EAChCC,MAAAA,WAAW,EAAE,MAAA;OACd,CAAA;EAGD,IAAA,IAAI,CAAC,IAAI,CAACgC,MAAM,CAAChC,WAAW,EAAE;QAC5B,IAAI,CAACgC,MAAM,CAAChC,WAAW,GAAG,IAAI,CAACmI,kBAAkB,CAACnI,WAAW,CAAA;EAC/D,KAAA;EAGA,IAAA,IAAI,CAAC,IAAI,CAACgC,MAAM,CAACjC,UAAU,EAAE;QAC3B,IAAI,CAACiC,MAAM,CAACjC,UAAU,GAAG,IAAI,CAACoI,kBAAkB,CAACpI,UAAU,CAAA;EAC7D,KAAA;MAIA,IAAI,CAACc,QAAQ,EAAE,CAAA;EACjB,GAAA;EA6qBF;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"autocomplete.umd.js","sources":["../../sources/js/utils/function.js","../../sources/js/utils/keyCodes.js","../../sources/js/script.js"],"sourcesContent":["/**\r\n * Check is a Object\r\n * @param {Object} value\r\n * @returns {Boolean}\r\n */\r\nexport const isObject = (value) =>\r\n value && typeof value === \"object\" && value.constructor === Object;\r\n\r\n/**\r\n * Check if is a Promise\r\n * https://stackoverflow.com/a/53955664/10424385\r\n *\r\n * @param {Object} value\r\n * @returns {Boolean}\r\n */\r\nexport const isPromise = (value) =>\r\n Boolean(value && typeof value.then === \"function\");\r\n\r\n/**\r\n * Set attributes to element\r\n *\r\n * @param {HTMLElement} el\r\n * @param {Object} object\r\n */\r\nexport const setAttributes = (el, object) => {\r\n for (let key in object) {\r\n if (key === \"addClass\") {\r\n classList(el, \"add\", object[key]);\r\n } else if (key === \"removeClass\") {\r\n classList(el, \"remove\", object[key]);\r\n } else {\r\n el.setAttribute(key, object[key]);\r\n }\r\n }\r\n};\r\n\r\n/**\r\n * Get first element from child\r\n *\r\n * @param {HTMLElement} element\r\n * @returns {HTMLELement}\r\n */\r\nexport const getFirstElement = (element) =>\r\n (element.firstElementChild || element).textContent.trim();\r\n\r\n/**\r\n * Scroll to top result-list\r\n * @param {HTMLElement} resultList\r\n * @param {HTMLElement} resultWrap\r\n */\r\nexport const scrollResultsToTop = (resultList, resultWrap) => {\r\n // if there is an overflow of ul element, after\r\n // opening we always move ul to the top of the results\r\n resultList.scrollTop = resultList.offsetTop - resultWrap.offsetHeight;\r\n};\r\n\r\n/**\r\n * Adding role, tabindex, aria and call handleMouse\r\n *\r\n * @param {HTMLElement} itemsLi\r\n */\r\nexport const addAriaToAllLiElements = (itemsLi) => {\r\n // add role to all li elements\r\n for (let i = 0; i < itemsLi.length; i++) {\r\n setAttributes(itemsLi[i], {\r\n role: \"option\",\r\n tabindex: \"-1\",\r\n \"aria-selected\": \"false\",\r\n \"aria-setsize\": itemsLi.length,\r\n // https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-posinset\r\n \"aria-posinset\": i + 1,\r\n });\r\n }\r\n};\r\n\r\n/**\r\n * Show btn to clear data\r\n *\r\n * @param {HTMLElement} clearButton - button to clear data\r\n * @param {Function} destroy - destroy function\r\n */\r\nexport const showBtnToClearData = (clearButton = false, destroy) => {\r\n if (!clearButton) return;\r\n\r\n classList(clearButton, \"remove\", \"hidden\");\r\n // add event to clear button\r\n onEvent(clearButton, \"click\", destroy);\r\n};\r\n\r\n/**\r\n * ClassList add/remove/contains\r\n *\r\n * @param {HTMLElement} element - html element\r\n * @param {String} action - add/remove/contains\r\n * @param {String} className - class name\r\n */\r\nexport const classList = (element, action, className) =>\r\n element.classList[action](className);\r\n\r\n/**\r\n * Set aria-activedescendant\r\n *\r\n * @param {HTMLElement} root - search input\r\n * @param {String} type\r\n */\r\nexport const setAriaActivedescendant = (root, type) => {\r\n setAttributes(root, {\r\n \"aria-activedescendant\": type || \"\",\r\n });\r\n};\r\n\r\n/**\r\n * Get height of ul without group class\r\n *\r\n * @param {String} outputUl\r\n * @param {String} classGroup\r\n * @returns {Number}\r\n */\r\nexport const getClassGroupHeight = (outputUl, classGroup) => {\r\n // get height of ul without group class\r\n const allLiElements = document.querySelectorAll(\r\n `#${outputUl} > li:not(.${classGroup})`,\r\n );\r\n let height = 0;\r\n [].slice.call(allLiElements).map((el) => (height += el.offsetHeight));\r\n\r\n // return height\r\n return height;\r\n};\r\n\r\n/**\r\n * Scroll into view when press up/down arrows\r\n *\r\n * @param {HTMLElement} target\r\n * @param {HTMLElement} outputUl\r\n * @param {String} classGroup\r\n * @param {HTMLElement} resultList\r\n */\r\nexport const followActiveElement = (\r\n target,\r\n outputUl,\r\n classGroup,\r\n resultList,\r\n) => {\r\n const previusElement = resultList.previousSibling;\r\n\r\n const previusElementHeight = previusElement ? previusElement.offsetHeight : 0;\r\n\r\n if (target.getAttribute(\"aria-posinset\") == \"0\") {\r\n resultList.scrollTop =\r\n target.offsetTop - getClassGroupHeight(outputUl, classGroup);\r\n }\r\n\r\n if (target.offsetTop - previusElementHeight < resultList.scrollTop) {\r\n resultList.scrollTop = target.offsetTop - previusElementHeight;\r\n } else {\r\n const offsetBottom =\r\n target.offsetTop + target.offsetHeight - previusElementHeight;\r\n const scrollBottom = resultList.scrollTop + resultList.offsetHeight;\r\n if (offsetBottom > scrollBottom) {\r\n resultList.scrollTop = offsetBottom - resultList.offsetHeight;\r\n }\r\n }\r\n};\r\n\r\n/**\r\n * Create output-list and put after search input\r\n *\r\n * @param {HTMLElement} root - search input\r\n * @param {HTMLElement} resultList - output-list ul\r\n * @param {String} outputUl - id name of output-list\r\n * @param {HTMLElement} resultWrap - wrapper ul element\r\n * @param {String} prefix - add prefix to all class auto\r\n */\r\nexport const output = (root, resultList, outputUl, resultWrap, prefix) => {\r\n // set attribute to results-list\r\n setAttributes(resultList, {\r\n id: outputUl,\r\n tabIndex: \"0\",\r\n role: \"listbox\",\r\n });\r\n\r\n // add class to wrap element\r\n setAttributes(resultWrap, {\r\n addClass: `${prefix}-results-wrapper`,\r\n });\r\n\r\n // insert the results into the wrap element\r\n resultWrap.insertAdjacentElement(\"beforeend\", resultList);\r\n\r\n // insert the wrap element after the search input\r\n root.parentNode.insertBefore(resultWrap, root.nextSibling);\r\n};\r\n\r\n/**\r\n * Create element\r\n *\r\n * @param {String} type - type of element\r\n * @returns {HTMLDivElement}\r\n */\r\nexport const createElement = (type) => document.createElement(type);\r\n\r\n/**\r\n * Get element\r\n *\r\n * @param {String} element\r\n * @returns {HTMLElement}\r\n */\r\nexport const select = (element) => document.querySelector(element);\r\n\r\n/**\r\n * Event listeners\r\n *\r\n * @param {HTMLElement} element\r\n * @param {String} action\r\n * @param {Function} callback\r\n */\r\nexport const onEvent = (element, action, callback) => {\r\n element.addEventListener(action, callback);\r\n};\r\n\r\n/**\r\n * Remove event listeners\r\n *\r\n * @param {HTMLElement} element\r\n * @param {String} action\r\n * @param {Function} callback\r\n */\r\nexport const offEvent = (element, action, callback) => {\r\n element.removeEventListener(action, callback);\r\n};\r\n\r\n/**\r\n * Add event listeners to all elements\r\n *\r\n * @param {HTMLElement} id\r\n *\r\n */\r\nexport const ariaActiveDescendantDefault = (id) => {\r\n return {\r\n \"aria-owns\": id,\r\n \"aria-expanded\": \"false\",\r\n \"aria-autocomplete\": \"list\",\r\n role: \"combobox\",\r\n removeClass: \"auto-expanded\",\r\n };\r\n};\r\n","/**\r\n * Key codes\r\n */\r\nconst keyCodes = {\r\n ESC: 27,\r\n ENTER: 13,\r\n UP: 38,\r\n DOWN: 40,\r\n TAB: 9,\r\n};\r\n\r\nexport default keyCodes;\r\n","import {\r\n addAriaToAllLiElements,\r\n classList,\r\n createElement,\r\n followActiveElement,\r\n getFirstElement,\r\n isObject,\r\n isPromise,\r\n offEvent,\r\n onEvent,\r\n output,\r\n scrollResultsToTop,\r\n select,\r\n setAriaActivedescendant,\r\n setAttributes,\r\n showBtnToClearData,\r\n ariaActiveDescendantDefault,\r\n} from \"./utils/function\";\r\n\r\nimport keyCodes from \"./utils/keyCodes\";\r\n\r\n/**\r\n * @class Autocomplete\r\n */\r\nexport default class Autocomplete {\r\n /**\r\n * Constructor\r\n *\r\n * @param {String} element\r\n * @param {Object} object\r\n */\r\n constructor(\r\n element,\r\n {\r\n delay = 500,\r\n clearButton = true,\r\n clearButtonOnInitial = false,\r\n howManyCharacters = 1,\r\n selectFirst = false,\r\n insertToInput = false,\r\n showAllValues = false,\r\n cache = false,\r\n disableCloseOnSelect = false,\r\n preventScrollUp = false,\r\n removeResultsWhenInputIsEmpty = false,\r\n regex = { expression: /[|\\\\{}()[\\]^$+*?]/g, replacement: \"\\\\$&\" },\r\n classGroup,\r\n classPreventClosing,\r\n classPrefix,\r\n ariaLabelClear,\r\n onSearch,\r\n onResults = () => {},\r\n onSubmit = () => {},\r\n onOpened = () => {},\r\n onReset = () => {},\r\n onRender = () => {},\r\n onClose = () => {},\r\n noResults = () => {},\r\n onSelectedItem = () => {},\r\n },\r\n ) {\r\n this._id = element;\r\n this._root = document.getElementById(element);\r\n this._onSearch = isPromise(onSearch)\r\n ? onSearch\r\n : ({ currentValue, element }) =>\r\n Promise.resolve(onSearch({ currentValue, element }));\r\n this._onResults = onResults;\r\n this._onRender = onRender;\r\n this._onSubmit = onSubmit;\r\n this._onSelected = onSelectedItem;\r\n this._onOpened = onOpened;\r\n this._onReset = onReset;\r\n this._noResults = noResults;\r\n this._onClose = onClose;\r\n\r\n this._delay = delay;\r\n this._characters = howManyCharacters;\r\n this._clearButton = clearButton;\r\n this._clearButtonOnInitial = clearButtonOnInitial;\r\n this._selectFirst = selectFirst;\r\n this._toInput = insertToInput;\r\n this._showAll = showAllValues;\r\n this._classGroup = classGroup;\r\n this._prevClosing = classPreventClosing;\r\n this._clearBtnAriLabel = ariaLabelClear\r\n ? ariaLabelClear\r\n : \"clear the search query\";\r\n this._prefix = classPrefix ? `${classPrefix}-auto` : \"auto\";\r\n this._disable = disableCloseOnSelect;\r\n this._preventScrollUp = preventScrollUp;\r\n this._removeResultsWhenInputIsEmpty = removeResultsWhenInputIsEmpty;\r\n\r\n // default config\r\n this._cache = cache;\r\n this._timeout = null;\r\n this._outputUl = `${this._prefix}-${this._id}-results`;\r\n this._cacheData = `data-cache-auto-${this._id}`;\r\n this._isLoading = `${this._prefix}-is-loading`;\r\n this._isActive = `${this._prefix}-is-active`;\r\n this._activeList = `${this._prefix}-selected`;\r\n this._selectedOption = `${this._prefix}-selected-option`;\r\n this._err = `${this._prefix}-error`;\r\n this._resultWrap = createElement(\"div\");\r\n this._resultList = createElement(\"ul\");\r\n this._clearBtn = createElement(\"button\");\r\n\r\n // ----------------------------------------\r\n // regex\r\n\r\n this._regex = regex;\r\n this._defaultExpression = {\r\n expression: /[|\\\\{}()[\\]^$+*?]/g,\r\n replacement: \"\\\\$&\",\r\n };\r\n\r\n // if regex is don't have replacement then set default\r\n if (!this._regex.replacement) {\r\n this._regex.replacement = this._defaultExpression.replacement;\r\n }\r\n\r\n // if regex is don't have expression then set default\r\n if (!this._regex.expression) {\r\n this._regex.expression = this._defaultExpression.expression;\r\n }\r\n\r\n // ----------------------------------------\r\n\r\n this._initial();\r\n }\r\n\r\n /**\r\n * Initial function\r\n */\r\n _initial = () => {\r\n this._clearbutton();\r\n\r\n const ariaAcrivedescentDefault = ariaActiveDescendantDefault(\r\n this._outputUl,\r\n );\r\n setAttributes(this._root, ariaAcrivedescentDefault);\r\n\r\n output(\r\n this._root,\r\n this._resultList,\r\n this._outputUl,\r\n this._resultWrap,\r\n this._prefix,\r\n );\r\n\r\n // default aria\r\n onEvent(this._root, \"input\", this._handleInput);\r\n\r\n // show all values on click root input\r\n this._showAll && onEvent(this._root, \"click\", this._handleInput);\r\n\r\n // calback functions\r\n this._onRender({\r\n element: this._root,\r\n results: this._resultList,\r\n });\r\n\r\n // show clear button if\r\n if (this._clearButtonOnInitial) {\r\n showBtnToClearData(this._clearBtn, this.destroy);\r\n }\r\n };\r\n\r\n /**\r\n * Actions on input\r\n *\r\n * @param {String} type - set attribute depending on type\r\n * @param {String} target\r\n */\r\n _cacheAct = (type, target) => {\r\n if (!this._cache) return;\r\n\r\n if (type === \"update\") {\r\n this._root.setAttribute(this._cacheData, target.value);\r\n } else if (type === \"remove\") {\r\n this._root.removeAttribute(this._cacheData);\r\n } else {\r\n this._root.value = this._root.getAttribute(this._cacheData);\r\n }\r\n };\r\n\r\n /**\r\n * Handle input\r\n *\r\n * @param {Event} object\r\n */\r\n _handleInput = ({ target, type }) => {\r\n if (\r\n this._root.getAttribute(\"aria-expanded\") === \"true\" &&\r\n type === \"click\"\r\n ) {\r\n return;\r\n }\r\n\r\n // replace all special characters\r\n const regex = target.value.replace(\r\n this._regex.expression,\r\n this._regex.replacement,\r\n );\r\n\r\n // update data attribute cache\r\n this._cacheAct(\"update\", target);\r\n\r\n const delay = this._showAll ? 0 : this._delay;\r\n // clear timeout\r\n clearTimeout(this._timeout);\r\n this._timeout = setTimeout(() => {\r\n // removeResultsWhenInputIsEmpty\r\n // remove results when input is empty\r\n if (this._removeResultsWhenInputIsEmpty) {\r\n if (target.value.length === 0) {\r\n this.destroy();\r\n return;\r\n }\r\n }\r\n\r\n this._searchItem(regex.trim());\r\n }, delay);\r\n };\r\n\r\n /**\r\n * Default aria\r\n */\r\n _reset = () => {\r\n // remove class isActive\r\n classList(this._resultWrap, \"remove\", this._isActive);\r\n\r\n const ariaAcrivedescentDefault = ariaActiveDescendantDefault(\r\n this._outputUl,\r\n );\r\n\r\n const ariaAcrivedescent = this._preventScrollUp\r\n ? ariaAcrivedescentDefault\r\n : { ...ariaAcrivedescentDefault, \"aria-activedescendant\": \"\" };\r\n\r\n // set attributes to root - input\r\n setAttributes(this._root, ariaAcrivedescent);\r\n\r\n if (!this._preventScrollUp) {\r\n // set default aria-selected, remove id and remove class 'auto-selected'\r\n this._removeAria(select(`.${this._activeList}`));\r\n\r\n // set index\r\n this._index = this._selectFirst ? 0 : -1;\r\n }\r\n\r\n // remove result when lengh = 0 and insertToInput is false\r\n // https://github.com/tomickigrzegorz/autocomplete/issues/136\r\n if ((this._matches?.length == 0 && !this._toInput) || this._showAll) {\r\n this._resultList.textContent = \"\";\r\n }\r\n\r\n // callback function\r\n this._onClose();\r\n };\r\n\r\n /**\r\n * The async function gets the text from the search\r\n * and returns the matching array\r\n *\r\n * @param {String} value\r\n */\r\n _searchItem = (value) => {\r\n this._value = value;\r\n\r\n // if searching show loading icon\r\n this._onLoading(true);\r\n\r\n // hide button clear\r\n showBtnToClearData(this._clearBtn, this.destroy);\r\n\r\n // if there is no value and clearButton is true\r\n if (value.length == 0 && this._clearButton) {\r\n classList(this._clearBtn, \"add\", \"hidden\");\r\n }\r\n\r\n // if declare characters more then value.len and showAll is false\r\n // remove class isActive\r\n if (this._characters > value.length && !this._showAll) {\r\n this._onLoading();\r\n return;\r\n }\r\n\r\n // callblack function onSearch\r\n this._onSearch({ currentValue: value, element: this._root })\r\n .then((result) => {\r\n const rootValueLength = this._root.value.length;\r\n const resultLength = result.length;\r\n // set no result\r\n this._matches = Array.isArray(result)\r\n ? result\r\n : JSON.parse(JSON.stringify(result));\r\n\r\n this._onLoading();\r\n this._error();\r\n\r\n // if use destroy() method\r\n if (resultLength == 0 && rootValueLength == 0) {\r\n classList(this._clearBtn, \"add\", \"hidden\");\r\n }\r\n\r\n if (resultLength == 0 && rootValueLength) {\r\n classList(this._root, \"remove\", \"auto-expanded\");\r\n this._reset();\r\n this._noResults({\r\n element: this._root,\r\n currentValue: value,\r\n template: this._results,\r\n });\r\n this._events();\r\n } else if (resultLength > 0 || isObject(result)) {\r\n this._index = this._selectFirst ? 0 : -1;\r\n this._results();\r\n this._events();\r\n }\r\n })\r\n .catch(() => {\r\n this._onLoading();\r\n this._reset();\r\n });\r\n };\r\n\r\n /**\r\n * Set or remove loading class\r\n *\r\n * @param {Boolean} type\r\n */\r\n _onLoading = (type) =>\r\n this._root.parentNode.classList[type ? \"add\" : \"remove\"](this._isLoading);\r\n\r\n /**\r\n * Set error class to the root element\r\n */\r\n _error = () => classList(this._root, \"remove\", this._err);\r\n\r\n /**\r\n * Events\r\n */\r\n _events = () => {\r\n // handle click on keydown [up, down, enter, tab, esc]\r\n onEvent(this._root, \"keydown\", this._handleKeys);\r\n\r\n onEvent(this._root, \"click\", this._handleShowItems);\r\n\r\n // close expanded items\r\n onEvent(document, \"click\", this._handleDocClick);\r\n\r\n // temporarily disabled mouseleave\r\n [\"mousemove\", \"click\"].map((eventType) => {\r\n onEvent(this._resultList, eventType, this._handleMouse);\r\n });\r\n };\r\n\r\n /**\r\n * Results\r\n *\r\n * @param {HTMLElement|String} template - html or string returned from the function,\r\n * look at the example - https://github.com/tomickigrzegorz/autocomplete/blob/master/docs/js/examples/no-results.js#L30\r\n */\r\n _results = (template) => {\r\n // set attribute to root\r\n setAttributes(this._root, {\r\n \"aria-expanded\": \"true\",\r\n addClass: `${this._prefix}-expanded`,\r\n });\r\n\r\n // clear result list\r\n this._resultList.textContent = \"\";\r\n\r\n // add all found records to otput ul\r\n const dataResults =\r\n this._matches.length === 0\r\n ? this._onResults({\r\n currentValue: this._value,\r\n matches: 0,\r\n template,\r\n })\r\n : this._onResults({\r\n currentValue: this._value,\r\n matches: this._matches,\r\n classGroup: this._classGroup,\r\n });\r\n\r\n // add data to ul\r\n this._resultList.insertAdjacentHTML(\"afterbegin\", dataResults);\r\n\r\n // add class isActive\r\n classList(this._resultWrap, \"add\", this._isActive);\r\n\r\n const checkIfClassGroupExist = this._classGroup\r\n ? `:not(.${this._classGroup})`\r\n : \"\";\r\n\r\n this._itemsLi = document.querySelectorAll(\r\n `#${this._outputUl} > li${checkIfClassGroupExist}`,\r\n );\r\n\r\n // adding role, tabindex and aria\r\n addAriaToAllLiElements(this._itemsLi);\r\n\r\n // action on open results\r\n this._onOpened({\r\n type: \"results\",\r\n element: this._root,\r\n results: this._resultList,\r\n });\r\n\r\n // select first element\r\n this._selectFirstElement();\r\n\r\n // move the view item to the first item\r\n // this.resultList.scrollTop = 0;\r\n // if (this._preventScrollUp) return;\r\n scrollResultsToTop(this._resultList, this._resultWrap);\r\n };\r\n\r\n /**\r\n * Hangle click on document\r\n *\r\n * @param {Event} object\r\n */\r\n _handleDocClick = ({ target }) => {\r\n let disableClose = null;\r\n\r\n // if 'target' is a ul and 'disableCloseOnSelect'\r\n // is a 'true' set 'disableClose' on true\r\n if (\r\n (target.closest(\"ul\") && this._disable) ||\r\n // when class classDisableClose\r\n // then do not not close results\r\n target.closest(`.${this._prevClosing}`)\r\n ) {\r\n disableClose = true;\r\n }\r\n\r\n if (target.id !== this._id && !disableClose) {\r\n this._reset();\r\n return;\r\n }\r\n };\r\n\r\n /**\r\n * Select first element\r\n */\r\n _selectFirstElement = () => {\r\n this._removeAria(select(`.${this._activeList}`));\r\n\r\n if (!this._selectFirst) {\r\n return;\r\n }\r\n\r\n const { firstElementChild } = this._resultList;\r\n\r\n const classSelectFirst =\r\n this._classGroup && this._matches.length > 0 && this._selectFirst\r\n ? firstElementChild.nextElementSibling\r\n : firstElementChild;\r\n\r\n // calback function onSelect when first element is true\r\n this._onSelected({\r\n index: this._index,\r\n element: this._root,\r\n object: this._matches[this._index],\r\n });\r\n\r\n // set attribute to first element\r\n setAttributes(classSelectFirst, {\r\n id: `${this._selectedOption}-0`,\r\n addClass: this._activeList,\r\n \"aria-selected\": \"true\",\r\n });\r\n\r\n // set aria active descendant\r\n setAriaActivedescendant(this._root, `${this._selectedOption}-0`);\r\n };\r\n\r\n /**\r\n * show items when items.length > 0 and is not empty\r\n */\r\n _handleShowItems = () => {\r\n // if resultWrap is not active and resultList is not empty\r\n if (\r\n this._resultList.textContent.length > 0 &&\r\n !classList(this._resultWrap, \"contains\", this._isActive)\r\n ) {\r\n // set attribute to root\r\n setAttributes(this._root, {\r\n \"aria-expanded\": \"true\",\r\n addClass: `${this._prefix}-expanded`,\r\n });\r\n\r\n // add isActive class to resultWrap\r\n classList(this._resultWrap, \"add\", this._isActive);\r\n\r\n // move the view item to the first item\r\n // this.resultList.scrollTop = 0;\r\n if (!this._preventScrollUp) {\r\n scrollResultsToTop(this._resultList, this._resultWrap);\r\n // select first element\r\n this._selectFirstElement();\r\n }\r\n\r\n // callback function\r\n this._onOpened({\r\n type: \"showItems\",\r\n element: this._root,\r\n results: this._resultList,\r\n });\r\n\r\n if (!this._cache) return;\r\n this._cacheAct(\"update\", this._root);\r\n }\r\n };\r\n\r\n /**\r\n * Adding text from the list when li is clicking\r\n * or adding aria-selected to li elements\r\n *\r\n * @param {Event} event\r\n */\r\n _handleMouse = (event) => {\r\n event.preventDefault();\r\n\r\n const { target, type } = event;\r\n const targetClosest = target.closest(\"li\");\r\n const targetClosestRole = targetClosest?.hasAttribute(\"role\");\r\n const activeClass = this._activeList;\r\n const activeClassElement = select(`.${activeClass}`);\r\n\r\n if (\r\n !targetClosest ||\r\n !targetClosestRole ||\r\n target.closest(`.${this._prevClosing}`)\r\n ) {\r\n return;\r\n }\r\n\r\n if (type === \"click\") {\r\n // click on li get element\r\n // get text from clicked li\r\n this._getTextFromLi(targetClosest);\r\n }\r\n\r\n if (\r\n type === \"mousemove\" &&\r\n !classList(targetClosest, \"contains\", activeClass)\r\n ) {\r\n this._removeAria(activeClassElement);\r\n\r\n // add aria to li\r\n this._setAria(targetClosest);\r\n this._index = this._indexLiSelected(targetClosest);\r\n\r\n this._onSelected({\r\n index: this._index,\r\n element: this._root,\r\n object: this._matches[this._index],\r\n });\r\n }\r\n };\r\n\r\n /**\r\n * Get text from li on enter or click\r\n *\r\n * @param {HTMLElement} element\r\n */\r\n _getTextFromLi = (element) => {\r\n if (!element || this._matches.length === 0) {\r\n // set default settings\r\n !this._disable && this._reset();\r\n\r\n return;\r\n }\r\n\r\n // show clearBtn when select element\r\n this._clearButton && classList(this._clearBtn, \"remove\", \"hidden\");\r\n\r\n // get first element from li and set it to root\r\n this._root.value = getFirstElement(element);\r\n\r\n // onSubmit passing text to function\r\n this._onSubmit({\r\n index: this._index,\r\n element: this._root,\r\n object: this._matches[this._index],\r\n results: this._resultList,\r\n });\r\n\r\n // set default settings\r\n if (!this._disable) {\r\n if (!this._preventScrollUp) {\r\n this._removeAria(element);\r\n }\r\n this._reset();\r\n }\r\n\r\n // remove cache\r\n this._cacheAct(\"remove\");\r\n };\r\n\r\n /**\r\n * Return which li element was selected\r\n * by hovering the mouse over\r\n *\r\n * @param {HTMLElement} target\r\n * @returns {Number}\r\n */\r\n _indexLiSelected = (target) =>\r\n // get index of li element\r\n Array.prototype.indexOf.call(this._itemsLi, target);\r\n\r\n /**\r\n * Navigating the elements li and enter\r\n *\r\n * @param {Event} event\r\n */\r\n _handleKeys = (event) => {\r\n const { keyCode } = event;\r\n\r\n const resultList = classList(this._resultWrap, \"contains\", this._isActive);\r\n\r\n const matchesLength = this._matches.length + 1;\r\n this._selectedLi = select(`.${this._activeList}`);\r\n\r\n // switch between keys\r\n switch (keyCode) {\r\n case keyCodes.UP:\r\n case keyCodes.DOWN:\r\n // Wrong cursor position in the input field #62\r\n // Prevents the cursor from moving to the beginning\r\n // of input as the cursor hovers over the results.\r\n event.preventDefault();\r\n\r\n if ((matchesLength <= 1 && this._selectFirst) || !resultList) {\r\n return;\r\n }\r\n\r\n // if keyCode is up\r\n if (keyCode === keyCodes.UP) {\r\n if (this._index < 0) {\r\n this._index = matchesLength - 1;\r\n }\r\n this._index -= 1;\r\n } else {\r\n this._index += 1;\r\n if (this._index >= matchesLength) {\r\n this._index = 0;\r\n }\r\n }\r\n\r\n // remove aria-selected\r\n this._removeAria(this._selectedLi);\r\n\r\n if (this._index >= 0 && this._index < matchesLength - 1) {\r\n const selectedElement = this._itemsLi[this._index];\r\n\r\n if (this._toInput && resultList) {\r\n this._root.value = getFirstElement(selectedElement);\r\n }\r\n\r\n // callback function\r\n this._onSelected({\r\n index: this._index,\r\n element: this._root,\r\n object: this._matches[this._index],\r\n });\r\n\r\n // set aria-selected\r\n this._setAria(selectedElement);\r\n } else {\r\n // catch action\r\n this._cacheAct();\r\n setAriaActivedescendant(this._root);\r\n\r\n this._onSelected({\r\n index: null,\r\n element: this._root,\r\n object: null,\r\n });\r\n }\r\n\r\n break;\r\n // keycode enter\r\n case keyCodes.ENTER:\r\n // https:github.com/tomickigrzegorz/autocomplete/issues/145\r\n event.preventDefault();\r\n\r\n this._getTextFromLi(this._selectedLi);\r\n break;\r\n\r\n // keycode escape and keycode tab\r\n case keyCodes.TAB:\r\n case keyCodes.ESC:\r\n event.stopPropagation();\r\n this._reset();\r\n\r\n break;\r\n default:\r\n break;\r\n }\r\n };\r\n\r\n /**\r\n * Set aria label on item li\r\n *\r\n * @param {HTMLElement} target\r\n */\r\n _setAria = (target) => {\r\n const selectedOption = `${this._selectedOption}-${this._indexLiSelected(\r\n target,\r\n )}`;\r\n\r\n // set aria to li\r\n setAttributes(target, {\r\n id: selectedOption,\r\n \"aria-selected\": \"true\",\r\n addClass: this._activeList,\r\n });\r\n\r\n setAriaActivedescendant(this._root, selectedOption);\r\n\r\n // scrollIntoView when press up/down arrows\r\n followActiveElement(\r\n target,\r\n this._outputUl,\r\n this._classGroup,\r\n this._resultList,\r\n );\r\n };\r\n\r\n /**\r\n * Remove aria label from item li\r\n *\r\n * @param {HTMLElement} element\r\n */\r\n _removeAria = (element) => {\r\n if (!element) return;\r\n\r\n // remove aria from li\r\n setAttributes(element, {\r\n id: \"\",\r\n removeClass: this._activeList,\r\n \"aria-selected\": \"false\",\r\n });\r\n };\r\n\r\n /**\r\n * Create clear button and\r\n * removing text from the input field\r\n */\r\n _clearbutton = () => {\r\n // stop when clear button is disabled\r\n if (!this._clearButton) return;\r\n\r\n // add aria to clear button\r\n setAttributes(this._clearBtn, {\r\n class: `${this._prefix}-clear hidden`,\r\n type: \"button\",\r\n title: this._clearBtnAriLabel,\r\n \"aria-label\": this._clearBtnAriLabel,\r\n });\r\n\r\n // insert clear button after input - root\r\n this._root.insertAdjacentElement(\"afterend\", this._clearBtn);\r\n };\r\n\r\n /**\r\n * Rerender rows without remove root input and close elements\r\n * @param {String} inputValue\r\n */\r\n rerender = (inputValue) => {\r\n const text = inputValue?.trim() ? inputValue.trim() : this._root.value;\r\n if (inputValue?.trim()) {\r\n this._root.value = inputValue.trim();\r\n this._cacheAct(\"update\", this._root);\r\n }\r\n const regexText = text.replace(\r\n this._regex.expression,\r\n this._regex.replacement,\r\n );\r\n this._searchItem(regexText.trim());\r\n };\r\n\r\n /**\r\n * Clicking on the clear button\r\n * publick destroy method\r\n */\r\n destroy = () => {\r\n // if clear button is true then add class hidden\r\n this._clearButton && classList(this._clearBtn, \"add\", \"hidden\");\r\n // clear value searchId\r\n this._root.value = \"\";\r\n // set focus\r\n this._root.focus();\r\n // remove li from ul\r\n this._resultList.textContent = \"\";\r\n // set default aria\r\n this._reset();\r\n // remove error if exist\r\n this._error();\r\n // callback function\r\n this._onReset(this._root);\r\n // remove animation on loading\r\n this._onLoading();\r\n\r\n // remove listener\r\n offEvent(this._root, \"keydown\", this._handleKeys);\r\n offEvent(this._root, \"click\", this._handleShowItems);\r\n // remove listener on click on document\r\n offEvent(document, \"click\", this._handleDocClick);\r\n };\r\n}\r\n"],"names":["isObject","value","constructor","Object","isPromise","Boolean","then","setAttributes","el","object","key","classList","setAttribute","getFirstElement","element","firstElementChild","textContent","trim","scrollResultsToTop","resultList","resultWrap","scrollTop","offsetTop","offsetHeight","addAriaToAllLiElements","itemsLi","i","length","role","tabindex","showBtnToClearData","clearButton","destroy","onEvent","action","className","setAriaActivedescendant","root","type","getClassGroupHeight","outputUl","classGroup","allLiElements","document","querySelectorAll","height","slice","call","map","followActiveElement","target","previusElement","previousSibling","previusElementHeight","getAttribute","offsetBottom","scrollBottom","output","prefix","id","tabIndex","addClass","insertAdjacentElement","parentNode","insertBefore","nextSibling","createElement","select","querySelector","callback","addEventListener","offEvent","removeEventListener","ariaActiveDescendantDefault","removeClass","keyCodes","ESC","ENTER","UP","DOWN","TAB","Autocomplete","_ref","delay","clearButtonOnInitial","howManyCharacters","selectFirst","insertToInput","showAllValues","cache","disableCloseOnSelect","preventScrollUp","removeResultsWhenInputIsEmpty","regex","expression","replacement","classPreventClosing","classPrefix","ariaLabelClear","onSearch","onResults","onSubmit","onOpened","onReset","onRender","onClose","noResults","onSelectedItem","_initial","_clearbutton","ariaAcrivedescentDefault","_outputUl","_root","_resultList","_resultWrap","_prefix","_handleInput","_showAll","_onRender","results","_clearButtonOnInitial","_clearBtn","_cacheAct","_cache","_cacheData","removeAttribute","_ref2","replace","_regex","_delay","clearTimeout","_timeout","setTimeout","_removeResultsWhenInputIsEmpty","_searchItem","_reset","_isActive","ariaAcrivedescent","_preventScrollUp","_removeAria","_activeList","_index","_selectFirst","_matches","_toInput","_onClose","_value","_onLoading","_clearButton","_characters","_onSearch","currentValue","result","rootValueLength","resultLength","Array","isArray","JSON","parse","stringify","_error","_noResults","template","_results","_events","catch","_isLoading","_err","_handleKeys","_handleShowItems","_handleDocClick","eventType","_handleMouse","dataResults","_onResults","matches","_classGroup","insertAdjacentHTML","checkIfClassGroupExist","_itemsLi","_onOpened","_selectFirstElement","_ref3","disableClose","closest","_disable","_prevClosing","_id","classSelectFirst","nextElementSibling","_onSelected","index","_selectedOption","event","preventDefault","targetClosest","targetClosestRole","hasAttribute","activeClass","activeClassElement","_getTextFromLi","_setAria","_indexLiSelected","_onSubmit","prototype","indexOf","keyCode","matchesLength","_selectedLi","selectedElement","stopPropagation","selectedOption","class","title","_clearBtnAriLabel","rerender","inputValue","text","regexText","focus","_onReset","getElementById","_ref4","Promise","resolve","_defaultExpression"],"mappings":";;;;;;;;;;;;;EAKO,MAAMA,QAAQ,GAAIC,KAAK,IAC5BA,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,CAACC,WAAW,KAAKC,MAAM,CAAA;EAS7D,MAAMC,SAAS,GAAIH,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AA;EAC7C,IAAA,IAAI,CAAC6E,eAAe,GAAI,GAAE,IAAI,CAAC7E,OAAQ,CAAiB,gBAAA,CAAA,CAAA;EACxD,IAAA,IAAI,CAACoD,IAAI,GAAI,GAAE,IAAI,CAACpD,OAAQ,CAAO,MAAA,CAAA,CAAA;EACnC,IAAA,IAAI,CAACD,WAAW,GAAGhD,aAAa,CAAC,KAAK,CAAC,CAAA;EACvC,IAAA,IAAI,CAAC+C,WAAW,GAAG/C,aAAa,CAAC,IAAI,CAAC,CAAA;EACtC,IAAA,IAAI,CAACuD,SAAS,GAAGvD,aAAa,CAAC,QAAQ,CAAC,CAAA;MAKxC,IAAI,CAAC8D,MAAM,GAAGnC,MAAK,CAAA;MACnB,IAAI,CAACoI,kBAAkB,GAAG;EACxBnI,MAAAA,UAAU,EAAE,oBAAoB;EAChCC,MAAAA,WAAW,EAAE,MAAA;OACd,CAAA;EAGD,IAAA,IAAI,CAAC,IAAI,CAACiC,MAAM,CAACjC,WAAW,EAAE;QAC5B,IAAI,CAACiC,MAAM,CAACjC,WAAW,GAAG,IAAI,CAACkI,kBAAkB,CAAClI,WAAW,CAAA;EAC/D,KAAA;EAGA,IAAA,IAAI,CAAC,IAAI,CAACiC,MAAM,CAAClC,UAAU,EAAE;QAC3B,IAAI,CAACkC,MAAM,CAAClC,UAAU,GAAG,IAAI,CAACmI,kBAAkB,CAACnI,UAAU,CAAA;EAC7D,KAAA;MAIA,IAAI,CAACc,QAAQ,EAAE,CAAA;EACjB,GAAA;EA+qBF;;;;;;;;"} \ No newline at end of file diff --git a/dist/js/autocomplete.umd.min.js b/dist/js/autocomplete.umd.min.js index c1b7c7d..f298a6b 100644 --- a/dist/js/autocomplete.umd.min.js +++ b/dist/js/autocomplete.umd.min.js @@ -1,8 +1,8 @@ /*! * @name autocomplete -* @version 2.0.0 +* @version 2.0.1 * @author Grzegorz Tomicki * @link https://github.com/tomickigrzegorz/autocomplete * @license MIT */ -!function(t,s){"object"==typeof exports&&"undefined"!=typeof module?module.exports=s():"function"==typeof define&&define.amd?define(s):(t="undefined"!=typeof globalThis?globalThis:t||self).Autocomplete=s()}(this,(function(){"use strict";const t=(t,s)=>{for(let i in s)"addClass"===i?e(t,"add",s[i]):"removeClass"===i?e(t,"remove",s[i]):t.setAttribute(i,s[i])},s=t=>(t.firstElementChild||t).textContent.trim(),i=(t,s)=>{t.scrollTop=t.offsetTop-s.offsetHeight},h=function(t,s){void 0===t&&(t=!1),t&&(e(t,"remove","hidden"),r(t,"click",s))},e=(t,s,i)=>t.classList[s](i),n=(s,i)=>{t(s,{"aria-activedescendant":i||""})},a=(t,s,i,h)=>{const e=h.previousSibling,n=e?e.offsetHeight:0;if("0"==t.getAttribute("aria-posinset")&&(h.scrollTop=t.offsetTop-((t,s)=>{const i=document.querySelectorAll(`#${t} > li:not(.${s})`);let h=0;return[].slice.call(i).map((t=>h+=t.offsetHeight)),h})(s,i)),t.offsetTop-nh.scrollTop+h.offsetHeight&&(h.scrollTop=s-h.offsetHeight)}},o=t=>document.createElement(t),l=t=>document.querySelector(t),r=(t,s,i)=>{t.addEventListener(s,i)},c=(t,s,i)=>{t.removeEventListener(s,i)},d=27,u=13,m=38,p=40,f=9;return class{constructor($,b){let{delay:v=500,clearButton:x=!0,clearButtonOnInitial:y=!1,howManyCharacters:C=1,selectFirst:k=!1,insertToInput:g=!1,showAllValues:j=!1,cache:w=!1,disableCloseOnSelect:I=!1,preventScrollUp:S=!1,removeResultsWhenInputIsEmpty:V=!1,regex:O={expression:/[|\\{}()[\]^$+*?]/g,replacement:"\\$&"},classGroup:R,classPreventClosing:T,classPrefix:A,ariaLabelClear:B,onSearch:P,onResults:E=(()=>{}),onSubmit:G=(()=>{}),onOpened:J=(()=>{}),onReset:N=(()=>{}),onRender:q=(()=>{}),onClose:z=(()=>{}),noResults:F=(()=>{}),onSelectedItem:L=(()=>{})}=b;var M;this.t=()=>{var s,i,e,n,a;this.i(),s=this.h,i=this.o,e=this.l,n=this.u,a=this.m,t(i,{id:e,tabIndex:"0",role:"listbox"}),t(n,{addClass:`${a}-results-wrapper`}),n.insertAdjacentElement("beforeend",i),s.parentNode.insertBefore(n,s.nextSibling),r(this.h,"input",this.p),this.$&&r(this.h,"click",this.p),this.v({element:this.h,results:this.o}),this.C&&h(this.k,this.destroy)},this.j=(t,s)=>{this.I&&("update"===t?this.h.setAttribute(this.S,s.value):"remove"===t?this.h.removeAttribute(this.S):this.h.value=this.h.getAttribute(this.S))},this.p=t=>{let{target:s,type:i}=t;if("true"===this.h.getAttribute("aria-expanded")&&"click"===i)return;const h=s.value.replace(this.V.expression,this.V.replacement);this.j("update",s);const e=this.$?0:this.O;clearTimeout(this.R),this.R=setTimeout((()=>{this.T&&0===s.value.length?this.destroy():this.A(h.trim())}),e)},this.B=()=>{e(this.u,"remove",this.P);const s={"aria-owns":`${this.G}-list`,"aria-expanded":"false","aria-autocomplete":"list",role:"combobox",removeClass:"auto-expanded"},i=this.J?s:{...s,"aria-activedescendant":""};t(this.h,i),this.J||(this.N(l(`.${this.q}`)),this.F=this.L?0:-1),(0==this.M?.length&&!this.U||this.$)&&(this.o.textContent=""),this.W()},this.A=t=>{this.D=t,this.H(!0),h(this.k,this.destroy),0==t.length&&this.K&&e(this.k,"add","hidden"),this.X>t.length&&!this.$?this.H():this.Y({currentValue:t,element:this.h}).then((s=>{const i=this.h.value.length,h=s.length;this.M=Array.isArray(s)?s:JSON.parse(JSON.stringify(s)),this.H(),this.Z(),0==h&&0==i&&e(this.k,"add","hidden"),0==h&&i?(e(this.h,"remove","auto-expanded"),this.B(),this._({element:this.h,currentValue:t,template:this.tt}),this.st()):(h>0||(t=>t&&"object"==typeof t&&t.constructor===Object)(s))&&(this.F=this.L?0:-1,this.tt(),this.st())})).catch((()=>{this.H(),this.B()}))},this.H=t=>this.h.parentNode.classList[t?"add":"remove"](this.it),this.Z=()=>e(this.h,"remove",this.ht),this.st=()=>{r(this.h,"keydown",this.et),r(this.h,"click",this.nt),r(document,"click",this.ot),["mousemove","click"].map((t=>{r(this.o,t,this.lt)}))},this.tt=s=>{t(this.h,{"aria-expanded":"true",addClass:`${this.m}-expanded`}),this.o.textContent="";const h=0===this.M.length?this.rt({currentValue:this.D,matches:0,template:s}):this.rt({currentValue:this.D,matches:this.M,classGroup:this.ct});this.o.insertAdjacentHTML("afterbegin",h),e(this.u,"add",this.P);const n=this.ct?`:not(.${this.ct})`:"";this.dt=document.querySelectorAll(`#${this.l} > li${n}`),(s=>{for(let i=0;i{let{target:s}=t,i=null;(s.closest("ul")&&this.$t||s.closest(`.${this.bt}`))&&(i=!0),s.id===this.G||i||this.B()},this.ft=()=>{if(this.N(l(`.${this.q}`)),!this.L)return;const{firstElementChild:s}=this.o,i=this.ct&&this.M.length>0&&this.L?s.nextElementSibling:s;this.vt({index:this.F,element:this.h,object:this.M[this.F]}),t(i,{id:`${this.xt}-0`,addClass:this.q,"aria-selected":"true"}),n(this.h,`${this.xt}-0`)},this.nt=()=>{if(this.o.textContent.length>0&&!e(this.u,"contains",this.P)){if(t(this.h,{"aria-expanded":"true",addClass:`${this.m}-expanded`}),e(this.u,"add",this.P),this.J||(i(this.o,this.u),this.ft()),this.ut({type:"showItems",element:this.h,results:this.o}),!this.I)return;this.j("update",this.h)}},this.lt=t=>{t.preventDefault();const{target:s,type:i}=t,h=s.closest("li"),n=h?.hasAttribute("role"),a=this.q,o=l(`.${a}`);h&&n&&!s.closest(`.${this.bt}`)&&("click"===i&&this.yt(h),"mousemove"!==i||e(h,"contains",a)||(this.N(o),this.Ct(h),this.F=this.kt(h),this.vt({index:this.F,element:this.h,object:this.M[this.F]})))},this.yt=t=>{t&&0!==this.M.length?(this.K&&e(this.k,"remove","hidden"),this.h.value=s(t),this.gt({index:this.F,element:this.h,object:this.M[this.F],results:this.o}),this.$t||(this.J||this.N(t),this.B()),this.j("remove")):!this.$t&&this.B()},this.kt=t=>Array.prototype.indexOf.call(this.dt,t),this.et=t=>{const{keyCode:i}=t,h=e(this.u,"contains",this.P),a=this.M.length+1;switch(this.jt=l(`.${this.q}`),i){case m:case p:if(t.preventDefault(),a<=1&&this.L||!h)return;if(i===m?(this.F<0&&(this.F=a-1),this.F-=1):(this.F+=1,this.F>=a&&(this.F=0)),this.N(this.jt),this.F>=0&&this.F{const i=`${this.xt}-${this.kt(s)}`;t(s,{id:i,"aria-selected":"true",addClass:this.q}),n(this.h,i),a(s,this.l,this.ct,this.o)},this.N=s=>{s&&t(s,{id:"",removeClass:this.q,"aria-selected":"false"})},this.i=()=>{this.K&&(t(this.k,{class:`${this.m}-clear hidden`,type:"button",title:this.wt,"aria-label":this.wt}),this.h.insertAdjacentElement("afterend",this.k))},this.rerender=t=>{const s=t?.trim()?t.trim():this.h.value;t?.trim()&&(this.h.value=t.trim(),this.j("update",this.h));const i=s.replace(this.V.expression,this.V.replacement);this.A(i.trim())},this.destroy=()=>{this.K&&e(this.k,"add","hidden"),this.h.value="",this.h.focus(),this.o.textContent="",this.B(),this.Z(),this.It(this.h),this.H(),c(this.h,"keydown",this.et),c(this.h,"click",this.nt),c(document,"click",this.ot)},this.G=$,this.h=document.getElementById($),this.Y=(M=P,Boolean(M&&"function"==typeof M.then)?P:t=>{let{currentValue:s,element:i}=t;return Promise.resolve(P({currentValue:s,element:i}))}),this.rt=E,this.v=q,this.gt=G,this.vt=L,this.ut=J,this.It=N,this._=F,this.W=z,this.O=v,this.X=C,this.K=x,this.C=y,this.L=k,this.U=g,this.$=j,this.ct=R,this.bt=T,this.wt=B||"clear the search query",this.m=A?`${A}-auto`:"auto",this.$t=I,this.J=S,this.T=V,this.I=w,this.R=null,this.l=`${this.m}-${this.G}-results`,this.S=`data-cache-auto-${this.G}`,this.it=`${this.m}-is-loading`,this.P=`${this.m}-is-active`,this.q=`${this.m}-selected`,this.xt=`${this.m}-selected-option`,this.ht=`${this.m}-error`,this.u=o("div"),this.o=o("ul"),this.k=o("button"),this.V=O,this.St={expression:/[|\\{}()[\]^$+*?]/g,replacement:"\\$&"},this.V.replacement||(this.V.replacement=this.St.replacement),this.V.expression||(this.V.expression=this.St.expression),this.t()}}})); +!function(t,s){"object"==typeof exports&&"undefined"!=typeof module?module.exports=s():"function"==typeof define&&define.amd?define(s):(t="undefined"!=typeof globalThis?globalThis:t||self).Autocomplete=s()}(this,(function(){"use strict";const t=(t,s)=>{for(let i in s)"addClass"===i?e(t,"add",s[i]):"removeClass"===i?e(t,"remove",s[i]):t.setAttribute(i,s[i])},s=t=>(t.firstElementChild||t).textContent.trim(),i=(t,s)=>{t.scrollTop=t.offsetTop-s.offsetHeight},h=function(t,s){void 0===t&&(t=!1),t&&(e(t,"remove","hidden"),r(t,"click",s))},e=(t,s,i)=>t.classList[s](i),n=(s,i)=>{t(s,{"aria-activedescendant":i||""})},a=(t,s,i,h)=>{const e=h.previousSibling,n=e?e.offsetHeight:0;if("0"==t.getAttribute("aria-posinset")&&(h.scrollTop=t.offsetTop-((t,s)=>{const i=document.querySelectorAll(`#${t} > li:not(.${s})`);let h=0;return[].slice.call(i).map((t=>h+=t.offsetHeight)),h})(s,i)),t.offsetTop-nh.scrollTop+h.offsetHeight&&(h.scrollTop=s-h.offsetHeight)}},o=t=>document.createElement(t),l=t=>document.querySelector(t),r=(t,s,i)=>{t.addEventListener(s,i)},c=(t,s,i)=>{t.removeEventListener(s,i)},d=t=>({"aria-owns":t,"aria-expanded":"false","aria-autocomplete":"list",role:"combobox",removeClass:"auto-expanded"}),u=27,m=13,p=38,f=40,$=9;return class{constructor(b,v){let{delay:x=500,clearButton:y=!0,clearButtonOnInitial:C=!1,howManyCharacters:k=1,selectFirst:g=!1,insertToInput:j=!1,showAllValues:w=!1,cache:I=!1,disableCloseOnSelect:S=!1,preventScrollUp:V=!1,removeResultsWhenInputIsEmpty:O=!1,regex:R={expression:/[|\\{}()[\]^$+*?]/g,replacement:"\\$&"},classGroup:T,classPreventClosing:A,classPrefix:B,ariaLabelClear:P,onSearch:E,onResults:G=(()=>{}),onSubmit:J=(()=>{}),onOpened:N=(()=>{}),onReset:q=(()=>{}),onRender:z=(()=>{}),onClose:F=(()=>{}),noResults:L=(()=>{}),onSelectedItem:M=(()=>{})}=v;var U;this.t=()=>{this.i();const s=d(this.h);var i,e,n,a,o;t(this.o,s),i=this.o,e=this.l,n=this.h,a=this.u,o=this.m,t(e,{id:n,tabIndex:"0",role:"listbox"}),t(a,{addClass:`${o}-results-wrapper`}),a.insertAdjacentElement("beforeend",e),i.parentNode.insertBefore(a,i.nextSibling),r(this.o,"input",this.p),this.$&&r(this.o,"click",this.p),this.v({element:this.o,results:this.l}),this.C&&h(this.k,this.destroy)},this.j=(t,s)=>{this.I&&("update"===t?this.o.setAttribute(this.S,s.value):"remove"===t?this.o.removeAttribute(this.S):this.o.value=this.o.getAttribute(this.S))},this.p=t=>{let{target:s,type:i}=t;if("true"===this.o.getAttribute("aria-expanded")&&"click"===i)return;const h=s.value.replace(this.V.expression,this.V.replacement);this.j("update",s);const e=this.$?0:this.O;clearTimeout(this.R),this.R=setTimeout((()=>{this.T&&0===s.value.length?this.destroy():this.A(h.trim())}),e)},this.B=()=>{e(this.u,"remove",this.P);const s=d(this.h),i=this.G?s:{...s,"aria-activedescendant":""};t(this.o,i),this.G||(this.J(l(`.${this.N}`)),this.q=this.F?0:-1),(0==this.L?.length&&!this.M||this.$)&&(this.l.textContent=""),this.U()},this.A=t=>{this.W=t,this.D(!0),h(this.k,this.destroy),0==t.length&&this.H&&e(this.k,"add","hidden"),this.K>t.length&&!this.$?this.D():this.X({currentValue:t,element:this.o}).then((s=>{const i=this.o.value.length,h=s.length;this.L=Array.isArray(s)?s:JSON.parse(JSON.stringify(s)),this.D(),this.Y(),0==h&&0==i&&e(this.k,"add","hidden"),0==h&&i?(e(this.o,"remove","auto-expanded"),this.B(),this.Z({element:this.o,currentValue:t,template:this._}),this.tt()):(h>0||(t=>t&&"object"==typeof t&&t.constructor===Object)(s))&&(this.q=this.F?0:-1,this._(),this.tt())})).catch((()=>{this.D(),this.B()}))},this.D=t=>this.o.parentNode.classList[t?"add":"remove"](this.st),this.Y=()=>e(this.o,"remove",this.it),this.tt=()=>{r(this.o,"keydown",this.ht),r(this.o,"click",this.et),r(document,"click",this.nt),["mousemove","click"].map((t=>{r(this.l,t,this.ot)}))},this._=s=>{t(this.o,{"aria-expanded":"true",addClass:`${this.m}-expanded`}),this.l.textContent="";const h=0===this.L.length?this.lt({currentValue:this.W,matches:0,template:s}):this.lt({currentValue:this.W,matches:this.L,classGroup:this.rt});this.l.insertAdjacentHTML("afterbegin",h),e(this.u,"add",this.P);const n=this.rt?`:not(.${this.rt})`:"";this.ct=document.querySelectorAll(`#${this.h} > li${n}`),(s=>{for(let i=0;i{let{target:s}=t,i=null;(s.closest("ul")&&this.ft||s.closest(`.${this.$t}`))&&(i=!0),s.id===this.bt||i||this.B()},this.ut=()=>{if(this.J(l(`.${this.N}`)),!this.F)return;const{firstElementChild:s}=this.l,i=this.rt&&this.L.length>0&&this.F?s.nextElementSibling:s;this.vt({index:this.q,element:this.o,object:this.L[this.q]}),t(i,{id:`${this.xt}-0`,addClass:this.N,"aria-selected":"true"}),n(this.o,`${this.xt}-0`)},this.et=()=>{if(this.l.textContent.length>0&&!e(this.u,"contains",this.P)){if(t(this.o,{"aria-expanded":"true",addClass:`${this.m}-expanded`}),e(this.u,"add",this.P),this.G||(i(this.l,this.u),this.ut()),this.dt({type:"showItems",element:this.o,results:this.l}),!this.I)return;this.j("update",this.o)}},this.ot=t=>{t.preventDefault();const{target:s,type:i}=t,h=s.closest("li"),n=h?.hasAttribute("role"),a=this.N,o=l(`.${a}`);h&&n&&!s.closest(`.${this.$t}`)&&("click"===i&&this.yt(h),"mousemove"!==i||e(h,"contains",a)||(this.J(o),this.Ct(h),this.q=this.kt(h),this.vt({index:this.q,element:this.o,object:this.L[this.q]})))},this.yt=t=>{t&&0!==this.L.length?(this.H&&e(this.k,"remove","hidden"),this.o.value=s(t),this.gt({index:this.q,element:this.o,object:this.L[this.q],results:this.l}),this.ft||(this.G||this.J(t),this.B()),this.j("remove")):!this.ft&&this.B()},this.kt=t=>Array.prototype.indexOf.call(this.ct,t),this.ht=t=>{const{keyCode:i}=t,h=e(this.u,"contains",this.P),a=this.L.length+1;switch(this.jt=l(`.${this.N}`),i){case p:case f:if(t.preventDefault(),a<=1&&this.F||!h)return;if(i===p?(this.q<0&&(this.q=a-1),this.q-=1):(this.q+=1,this.q>=a&&(this.q=0)),this.J(this.jt),this.q>=0&&this.q{const i=`${this.xt}-${this.kt(s)}`;t(s,{id:i,"aria-selected":"true",addClass:this.N}),n(this.o,i),a(s,this.h,this.rt,this.l)},this.J=s=>{s&&t(s,{id:"",removeClass:this.N,"aria-selected":"false"})},this.i=()=>{this.H&&(t(this.k,{class:`${this.m}-clear hidden`,type:"button",title:this.wt,"aria-label":this.wt}),this.o.insertAdjacentElement("afterend",this.k))},this.rerender=t=>{const s=t?.trim()?t.trim():this.o.value;t?.trim()&&(this.o.value=t.trim(),this.j("update",this.o));const i=s.replace(this.V.expression,this.V.replacement);this.A(i.trim())},this.destroy=()=>{this.H&&e(this.k,"add","hidden"),this.o.value="",this.o.focus(),this.l.textContent="",this.B(),this.Y(),this.It(this.o),this.D(),c(this.o,"keydown",this.ht),c(this.o,"click",this.et),c(document,"click",this.nt)},this.bt=b,this.o=document.getElementById(b),this.X=(U=E,Boolean(U&&"function"==typeof U.then)?E:t=>{let{currentValue:s,element:i}=t;return Promise.resolve(E({currentValue:s,element:i}))}),this.lt=G,this.v=z,this.gt=J,this.vt=M,this.dt=N,this.It=q,this.Z=L,this.U=F,this.O=x,this.K=k,this.H=y,this.C=C,this.F=g,this.M=j,this.$=w,this.rt=T,this.$t=A,this.wt=P||"clear the search query",this.m=B?`${B}-auto`:"auto",this.ft=S,this.G=V,this.T=O,this.I=I,this.R=null,this.h=`${this.m}-${this.bt}-results`,this.S=`data-cache-auto-${this.bt}`,this.st=`${this.m}-is-loading`,this.P=`${this.m}-is-active`,this.N=`${this.m}-selected`,this.xt=`${this.m}-selected-option`,this.it=`${this.m}-error`,this.u=o("div"),this.l=o("ul"),this.k=o("button"),this.V=R,this.St={expression:/[|\\{}()[\]^$+*?]/g,replacement:"\\$&"},this.V.replacement||(this.V.replacement=this.St.replacement),this.V.expression||(this.V.expression=this.St.expression),this.t()}}})); diff --git a/dist/js/polyfill.js b/dist/js/polyfill.js index fdee35b..8db8cec 100644 --- a/dist/js/polyfill.js +++ b/dist/js/polyfill.js @@ -1,6 +1,6 @@ /*! * @name autocomplete -* @version 2.0.0 +* @version 2.0.1 * @author Grzegorz Tomicki * @link https://github.com/tomickigrzegorz/autocomplete * @license MIT diff --git a/docs/ie.html b/docs/ie.html index 04c9746..a4a61c0 100644 --- a/docs/ie.html +++ b/docs/ie.html @@ -54,13 +54,13 @@

-- local files --

-- cdn --

  • - https://cdn.jsdelivr.net/gh/tomik23/autocomplete@2.0.0/dist/js/polyfill.js + https://cdn.jsdelivr.net/gh/tomik23/autocomplete@2.0.1/dist/js/polyfill.js
  • - https://cdn.jsdelivr.net/gh/tomik23/autocomplete@2.0.0/dist/js/autocomplete.ie.min.js + https://cdn.jsdelivr.net/gh/tomik23/autocomplete@2.0.1/dist/js/autocomplete.ie.min.js
  • - https://cdn.jsdelivr.net/gh/tomik23/autocomplete@2.0.0/dist/css/autocomplete.ie.min.css + https://cdn.jsdelivr.net/gh/tomik23/autocomplete@2.0.1/dist/css/autocomplete.ie.min.css

-- cdn polyfill from npm --

diff --git a/docs/index.html b/docs/index.html index 2950ad7..220e923 100644 --- a/docs/index.html +++ b/docs/index.html @@ -38,7 +38,7 @@

- autocomplete v2.0.0 + autocomplete v2.0.1