aria-autocomplete
Advanced tools
Comparing version 1.0.0-beta.2 to 1.0.0
@@ -1,10 +0,14 @@ | ||
parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({"kTsq":[function(require,module,exports) { | ||
Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(e){var t=this;do{if(t.matches(e))return t;t=t.parentElement||t.parentNode}while(null!==t&&1===t.nodeType);return null}); | ||
parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({"diFG":[function(require,module,exports) { | ||
"use strict";function e(e){return e>=48&&e<=57||e>=65&&e<=90||e>=96&&e<=111||e>=186&&e<=222||32===e||8===e||46===e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=e; | ||
},{}],"AEQi":[function(require,module,exports) { | ||
var define; | ||
var t;parcelRequire=function(e,n,i,r){var o,s="function"==typeof parcelRequire&&parcelRequire,a="function"==typeof require&&require;function u(t,i){if(!n[t]){if(!e[t]){var r="function"==typeof parcelRequire&&parcelRequire;if(!i&&r)return r(t,!0);if(s)return s(t,!0);if(a&&"string"==typeof t)return a(t);var o=new Error("Cannot find module '"+t+"'");throw o.code="MODULE_NOT_FOUND",o}h.resolve=function(n){return e[t][1][n]||n},h.cache={};var c=n[t]=new u.Module(t);e[t][0].call(c.exports,h,c,c.exports,this)}return n[t].exports;function h(t){return u(h.resolve(t))}}u.isParcelRequire=!0,u.Module=function(t){this.id=t,this.bundle=u,this.exports={}},u.modules=e,u.cache=n,u.parent=s,u.register=function(t,n){e[t]=[function(t,e){e.exports=n},{}]};for(var c=0;c<i.length;c++)try{u(i[c])}catch(e){o||(o=e)}if(i.length){var h=u(i[i.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=h:"function"==typeof t&&t.amd&&t(function(){return h})}if(parcelRequire=u,o)throw o;return u}({vL70:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(t){return t>=48&&t<=57||t>=65&&t<=90||t>=96&&t<=111||t>=186&&t<=222||32===t||8===t||46===t}},{}],Focm:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var i,r=function(t){return t&&t.__esModule?t:{default:t}}(t("is-printable-keycode"));function o(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function s(t,e){if(t)for(var n in e){var i="number"==typeof e[n]?e[n]+"px":e[n];t.style[n]=i+""}}var a=function(){function t(e,n){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),this.options=n,this.input=e,this.eventHandler,this.currentWidth,this.cache={},this.trigger(),this.eventHandler=this.trigger.bind(this),this.input.addEventListener("blur",this.eventHandler),this.input.addEventListener("input",this.eventHandler),this.input.addEventListener("keyup",this.eventHandler),this.input.addEventListener("keydown",this.eventHandler)}return function(t,e,n){e&&o(t.prototype,e),n&&o(t,n)}(t,[{key:"measureString",value:function(t){return t?this.cache&&"number"==typeof this.cache[t]?this.cache[t]:(i||(s(i=document.createElement("span"),{position:"absolute",top:-99999,left:-99999,width:"auto",padding:0,whiteSpace:"pre"}),document.body.appendChild(i)),i.textContent=t,function(t,e,n){if(t&&e){var i=getComputedStyle(t),r={};if(n&&n.length)for(var o=0,a=n.length;o<a;o+=1)r[n[o]]=i[n[o]];else r=i;s(e,r)}}(this.input,i,["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"]),i.offsetWidth||i.clientWidth):0}},{key:"trigger",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!t.metaKey&&!t.altKey){var e,n=this.input.value;if(t.type&&"keydown"===t.type.toLowerCase()){var i=t.keyCode,o=46===i,s=8===i;if(o||s){var a=function(t){var e={};if("selectionStart"in t)e.start=t.selectionStart,e.length=t.selectionEnd-e.start;else if(document.selection){t.focus();var n=document.selection.createRange(),i=n.text.length;n.moveStart("character",-t.value.length),e.start=n.text.length-i,e.length=i}return e}(this.input);a.length?n=n.substring(0,a.start)+n.substring(a.start+a.length):s&&a.start?n=n.substring(0,a.start-1)+n.substring(a.start+1):o&&void 0!==a.start&&(n=n.substring(0,a.start)+n.substring(a.start+1))}else if((0,r.default)(i)){var u=String.fromCharCode(i);n+=u=t.shiftKey?u.toUpperCase():u.toLowerCase()}}!n&&(e=this.input.getAttribute("placeholder"))&&(n=e);var c=this.measureString(n)+4;this.options&&this.options.cache&&this.cache&&(this.cache[n]=c);var h=this.options&&this.options.minWidth;"number"==typeof h&&c<h&&(c=h);var l=this.options&&this.options.maxWidth;"number"==typeof l&&c>l&&(c=l),c!==this.currentWidth&&(this.currentWidth=c,this.input.style.width="".concat(c,"px"))}}},{key:"destroy",value:function(){this.input.removeEventListener("blur",this.eventHandler),this.input.removeEventListener("input",this.eventHandler),this.input.removeEventListener("keyup",this.eventHandler),this.input.removeEventListener("keydown",this.eventHandler),this.input=this.cache=null}}]),t}();n.default=a},{"is-printable-keycode":"vL70"}]},{},["Focm"]); | ||
},{}],"MBeS":[function(require,module,exports) { | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.trimString=r,exports.hasClass=n,exports.addClass=a,exports.removeClass=o,exports.cleanString=u,exports.isPrintableKey=f,exports.mergeObjects=v,exports.dispatchEvent=p,exports.setElementState=g,exports.processSourceArray=h,exports.htmlToElement=m,exports.setCss=E,exports.transferStyles=b,exports.searchVarPropsFor=A,exports.removeDuplicatesAndLabel=y,exports.SELECTED_OPTION=exports.CLEANED_LABEL=void 0;var e="_ariaAutocompleteCleanedLabel";exports.CLEANED_LABEL=e;var t="_ariaAutocompleteSelectedOption";function r(e){return null==e?"":(e+"").trim()}function n(e,t){var n=e,a=r(n.getAttribute&&n.getAttribute("class"));return" ".concat(a," ").indexOf(" ".concat(t," "))>-1}function a(e,t){for(var n=r(e.getAttribute&&e.getAttribute("class")),a=" "+n+" ",o="",i=0,s=t.split(" "),l=s.length;i<l;i+=1)""!==s[i]&&-1===a.indexOf(" "+s[i]+" ")&&(o+=" "+s[i]);n!==(o=r(n+o))&&e.setAttribute("class",o)}function o(e,t){for(var n=r(e.getAttribute&&e.getAttribute("class")),a=" "+n+" ",o=0,i=t.split(" "),s=i.length;o<s;o+=1)a=a.replace(" "+i[o]+" "," ");n!==(a=r(a))&&e.setAttribute("class",a)}exports.SELECTED_OPTION=t;var i=/&/g,s=/\s\s+/g,l=/[\u2018\u2019',:\u2013-]/g,c=/[\-\[\]{}()*+?.,\\\^$|#\s]/g;function u(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e=r(e).toLowerCase().replace(l,"").replace(i,"and").replace(s," "),t&&(e=e.replace(c,"\\$&")),e}function f(e){return e>=48&&e<=57||e>=65&&e<=90||e>=96&&e<=111||e>=186&&e<=222||32===e||8===e||46===e}function v(){for(var e={},t=0,r=arguments.length;t<r;t+=1){var n=t<0||arguments.length<=t?void 0:arguments[t];for(var a in n)n.hasOwnProperty(a)&&void 0!==n[a]&&(e[a]=n[a])}return e}function p(e,t){if("createEvent"in document){var r=document.createEvent("HTMLEvents");r.initEvent(t,!0,!0),e.dispatchEvent(r)}else e.fireEvent("on"+t)}function g(e,t,r){t=!!t,e&&("INPUT"===e.nodeName&&"boolean"==typeof e.checked&&e.checked!==t&&(e.checked=t,p(e,"change")),"OPTION"===e.nodeName&&e.selected!==t&&(e.selected=t,r.elementChangeEventTimer&&clearTimeout(r.elementChangeEventTimer),r.elementChangeEventTimer=setTimeout(function(){p(e.closest("select"),"change")},1)))}function h(t){for(var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0,a=[],o=r.value,i=r.label,s=0,l=t.length;s<l;s+=1){var c={},f=t[s];if("string"==typeof f)c.value=c.label=f;else{var p=(c=v(f))[o]||c.value||c.label,g=c[i]||c.label||c.value;c.value=(p||"").toString(),c.label=(g||"").toString()}!1!==n&&(c[e]=u(c.label)),a.push(c)}return a}var d=document.createElement("div");function m(e){return d.innerHTML=r(e),d.firstChild}function E(e,t){if(e)for(var r in t){var n="number"==typeof t[r]?t[r]+"px":t[r];e.style[r]=n+""}}function b(e,t,r){if(e&&t){var n=getComputedStyle(e),a={};if(r&&r.length)for(var o=0,i=r.length;o<i;o+=1)a[r[o]]=n[r[o]];else a=n;E(t,a)}}var x=function t(r,n,a){if("string"==typeof r)return a!==e&&(r=u(r,!1)),-1!==r.search(n);if(Array.isArray(r))for(var o=0,i=r.length;o<i;o+=1)if(t(r[o],n))return!0;return!1};function A(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];for(var a in n&&(r=u(r,!0)),e)if(e.hasOwnProperty(a)){var o=!1;if("string"==typeof e[a]){for(var i=t.length;i--;)if(t[i]===a){o=!0;break}}else o=Array.isArray(e[a]);if(o&&x(e[a],r,a))return!0}return!1}function y(e){for(var t=[],n=0,a=e.length;n<a;n+=1)if("string"==typeof e[n]){for(var o=r(e[n]),i="label"!==o,s=t.length;i&&s--;)t[s]===o&&(i=!1);i&&t.push(o)}return t} | ||
},{}],"KnPF":[function(require,module,exports) { | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var t,e=require("./autocomplete-helpers");function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function r(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),t}var s=function(){function i(t){n(this,i),this.input=t,this.currentString,this.eventHandler,this.currentWidth,this.init()}return r(i,[{key:"trigger",value:function(){this.checkAndSet.call(this)}},{key:"getInputSelection",value:function(){var t={};if("selectionStart"in this.input)t.start=this.input.selectionStart,t.length=this.input.selectionEnd-t.start;else if(document.selection){this.input.focus();var e=document.selection.createRange(),n=e.text.length;e.moveStart("character",-this.input.value.length),t.start=e.text.length-n,t.length=n}return t}},{key:"measureString",value:function(n){return n?n===this.currentString?this.currentWidth:(t||(t=document.createElement("span"),(0,e.setCss)(t,{position:"absolute",top:-99999,left:-99999,width:"auto",padding:0,whiteSpace:"pre"}),document.body.appendChild(t)),t.textContent=n,this.currentString=n,(0,e.transferStyles)(this.input,t,["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"]),t.offsetWidth||t.clientWidth):(this.currentString=n,0)}},{key:"checkAndSet",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!t.metaKey&&!t.altKey){var n,i=this.input.value;if(t.type&&"keydown"===t.type.toLowerCase()){var r=t.keyCode,s=46===r,a=8===r;if(s||a){var u=this.getInputSelection();u.length?i=i.substring(0,u.start)+i.substring(u.start+u.length):a&&u.start?i=i.substring(0,u.start-1)+i.substring(u.start+1):s&&void 0!==u.start&&(i=i.substring(0,u.start)+i.substring(u.start+1))}else if((0,e.isPrintableKey)(r)){var h=String.fromCharCode(r);i+=h=t.shiftKey?h.toUpperCase():h.toLowerCase()}}!i&&(n=this.input.getAttribute("placeholder"))&&(i=n);var o=this.measureString(i)+4;o!==this.currentWidth&&(this.currentWidth=o,this.input.style.width="".concat(o,"px"))}}},{key:"destroy",value:function(){this.input.removeEventListener("blur",this.eventHandler),this.input.removeEventListener("input",this.eventHandler),this.input.removeEventListener("keyup",this.eventHandler),this.input.removeEventListener("keydown",this.eventHandler),this.input=null}},{key:"init",value:function(){this.checkAndSet(),this.eventHandler=this.checkAndSet.bind(this),this.input.addEventListener("blur",this.eventHandler),this.input.addEventListener("input",this.eventHandler),this.input.addEventListener("keyup",this.eventHandler),this.input.addEventListener("keydown",this.eventHandler)}}]),i}();exports.default=s; | ||
},{"./autocomplete-helpers":"MBeS"}],"c8cM":[function(require,module,exports) { | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0,require("./closest-polyfill");var e=i(require("./autogrow")),t=require("./autocomplete-helpers");function i(e){return e&&e.__esModule?e:{default:e}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var i=0;i<t.length;i++){var s=t[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}function l(e,t,i){return t&&n(e.prototype,t),i&&n(e,i),e}var r=0,o={name:"",source:"",sourceMapping:{},alsoSearchIn:[],delay:100,minLength:1,maxResults:9999,showAllControl:!1,confirmOnBlur:!0,multiple:!1,autoGrow:!1,maxItems:9999,multipleSeparator:",",deleteOnBackspace:!1,asyncQueryParam:"q",asyncMaxResultsParam:"limit",placeholder:"",noResultsText:"No results",cssNameSpace:"aria-autocomplete",listClassName:"",inputClassName:"",wrapperClassName:"",srDeleteText:"delete",srDeletedText:"deleted",srShowAllText:"Show all",srSelectedText:"selected",srListLabelText:"Search suggestions",srAssistiveText:"When results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures.",srResultsText:function(e){return"".concat(e," ").concat(1===e?"result":"results"," available.")},onSearch:void 0,onAsyncPrep:void 0,onAsyncSuccess:void 0,onResponse:void 0,onItemRender:void 0,onConfirm:void 0,onDelete:void 0,onReady:void 0,onClose:void 0,onOpen:void 0},a=function(){function i(e,t){if(s(this,i),e){if(e.ariaAutocomplete&&e.ariaAutocomplete.open)return{api:e.ariaAutocomplete};this.options,this.element,this.elementIsInput,this.elementIsSelect,this.list,this.input,this.wrapper,this.showAll,this.srAnnouncements,this.ids,this.xhr,this.term,this.async,this.source,this.menuOpen,this.multiple,this.selected,this.disabled,this.autoGrow,this.filtering,this.cssNameSpace,this.forceShowAll,this.filteredSource,this.currentListHtml,this.inputPollingValue,this.currentSelectedIndex,this.documentClick,this.documentClickBound,this.filterTimer,this.pollingTimer,this.announcementTimer,this.componentBlurTimer,this.elementChangeEventTimer,this.AutoGrowInput,this.init(e,t)}}return l(i,[{key:"triggerOptionCallback",value:function(e,t,i){if(i=void 0===i?this.api:i,"function"==typeof this.options[e])return this.options[e].apply(i,t)}},{key:"show",value:function(e){if(void 0!==e){var i="".concat(this.cssNameSpace,"--hide hide hidden");return(0,t.removeClass)(e,i),e.removeAttribute("hidden")}if(this.input.setAttribute("aria-expanded","true"),this.showAll){var s=(!!this.forceShowAll).toString();this.showAll.setAttribute("aria-expanded",s)}this.menuOpen||(this.show(this.list),this.menuOpen=!0,this.triggerOptionCallback("onOpen",[this.list]),this.documentClickBound||(this.documentClickBound=!0,document.addEventListener("click",this.documentClick)))}},{key:"hide",value:function(e){if(void 0!==e)return(0,t.addClass)(e,"".concat(this.cssNameSpace,"--hide hide hidden")),e.setAttribute("hidden","hidden");this.currentSelectedIndex=-1,this.input.setAttribute("aria-expanded","false"),this.showAll&&this.showAll.setAttribute("aria-expanded","false"),this.menuOpen&&(this.hide(this.list),this.menuOpen=!1,this.triggerOptionCallback("onClose",[this.list]))}},{key:"enable",value:function(){if(this.disabled){this.disabled=!1,this.input.disabled=!1;var e=this.cssNameSpace;(0,t.removeClass)(this.input,"".concat(e,"__input--disabled disabled")),(0,t.removeClass)(this.wrapper,"".concat(e,"__wrapper--disabled disabled")),this.showAll&&(this.showAll.setAttribute("tabindex","0"),(0,t.removeClass)(this.showAll,"".concat(e,"__show-all--disabled disabled")))}}},{key:"disable",value:function(){if(!this.disabled){this.disabled=!0,this.input.disabled=!0;var e=this.cssNameSpace;(0,t.addClass)(this.input,"".concat(e,"__input--disabled disabled")),(0,t.addClass)(this.wrapper,"".concat(e,"__wrapper--disabled disabled")),this.showAll&&(this.showAll.setAttribute("tabindex","-1"),(0,t.addClass)(this.showAll,"".concat(e,"__show-all--disabled disabled")))}}},{key:"triggerAutoGrow",value:function(){this.autoGrow&&this.AutoGrowInput&&this.AutoGrowInput.trigger()}},{key:"setInputValue",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.input.value=this.term=e,t&&(this.inputPollingValue=e)}},{key:"indexOfQueryIn",value:function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.input.value,s=arguments.length>2?arguments[2]:void 0;if(i=(0,t.trimString)(i).toLowerCase()){s=s||"label";for(var n=0,l=e.length;n<l;n+=1)if((0,t.trimString)(e[n][s]).toLowerCase()===i)return n}return-1}},{key:"announce",value:function(e,t){var i=this;if(e&&this.srAnnouncements){if(0===t)return this.srAnnouncements.textContent=e;t="number"==typeof t?t:400,this.announcementTimer&&clearTimeout(this.announcementTimer),this.announcementTimer=setTimeout(function(){i.srAnnouncements.textContent=e},t)}}},{key:"isSelectedElem",value:function(e){return this.multiple&&e[t.SELECTED_OPTION]&&(0,t.hasClass)(e,"".concat(this.cssNameSpace,"__selected"))}},{key:"getSelectedElems",value:function(){for(var e=this.wrapper.childNodes,t=[],i=0,s=e.length;i<s;i+=1)this.isSelectedElem(e[i])&&t.push(e[i]);return t}},{key:"removeEntryFromSelected",value:function(e){var i=this.selected.indexOf(e);if(-1===i)for(var s=0,n=this.selected.length;s<n;s+=1)if(this.selected[s].value===e.value){i=s;break}if(i>-1&&this.selected[i]){var l=(0,t.mergeObjects)(this.selected[i]),r=l.label;(0,t.setElementState)(l.element,!1,this),this.selected.splice(i,1),this.triggerOptionCallback("onDelete",[l]),this.buildMultiSelected(),this.announce("".concat(r," ").concat(this.options.srDeletedText),0)}}},{key:"buildMultiSelected",value:function(){if(this.multiple){this.multiple&&this.selected.length>=this.options.maxItems?this.disable():this.enable();var e=this.getSelectedElems();if(this.selected.length||e.length){for(var i=[],s=e.length;s--;){for(var n=e[s][t.SELECTED_OPTION],l=this.selected.length,r=!1;l--;){var o=this.selected[l];if(o===n||o.value===n.value){r=!0;break}}r?i.push(e[s]):this.wrapper.removeChild(e[s])}for(var a=this.options.srDeleteText,c=document.createDocumentFragment(),h="".concat(this.cssNameSpace,"__selected"),u=0,d=this.selected.length;u<d;u+=1){for(var p=this.selected[u],m=i.length,f=!1;m--;){var v=i[m][t.SELECTED_OPTION];if(v===p||v.value===p.value){f=!0;break}}if(!f){var g=p.label,S=(0,t.htmlToElement)('<span role="button" class="'.concat(h,'" ')+'tabindex="0" aria-label="'.concat(a," ").concat(g,'">')+"".concat(g,"</span>"));S[t.SELECTED_OPTION]=p,c.appendChild(S)}}c.childNodes&&c.childNodes.length&&this.wrapper.insertBefore(c,this.list);for(var y=[],b=this.getSelectedElems(),A=0,w=b.length;A<w;A+=1){var E="".concat(this.ids.OPTION_SELECTED,"-").concat(A);b[A].setAttribute("id",E),y.push(E)}if(y.push(this.ids.LIST),this.input.setAttribute("aria-owns",y.join(" ")),this.autoGrow&&this.options.placeholder){var T=this.selected.length?"":this.options.placeholder;this.input.setAttribute("placeholder",T)}}}}},{key:"setInputDescription",value:function(){var e=this.input.getAttribute("aria-describedby"),i=(0,t.trimString)(e||""),s=i.replace(this.ids.SR_ASSISTANCE,"");0===this.input.value.length&&(s=s+" "+this.ids.SR_ASSISTANCE),(s=(0,t.trimString)(s))?s!==i&&this.input.setAttribute("aria-describedby",s):e&&this.input.removeAttribute("aria-describedby")}},{key:"resetOptionAttributes",value:function(){for(var e=this.cssNameSpace,i=this.list.childNodes,s=i.length;s--;)(0,t.removeClass)(i[s],"".concat(e,"__option--focused focused focus")),i[s].setAttribute("aria-selected","false")}},{key:"setOptionFocus",value:function(e,i){this.resetOptionAttributes();var s=this.list.childNodes;if(i<0||!s||!s.length)return this.currentSelectedIndex=-1,void(e&&e.target!==this.input&&this.input.focus());if(i>=s.length)return this.currentSelectedIndex=s.length-1,void this.setOptionFocus(e,this.currentSelectedIndex);var n=s[i];if(n&&"string"==typeof n.getAttribute("tabindex")){this.currentSelectedIndex=i;var l="".concat(this.cssNameSpace,"__option--focused focused focus");return(0,t.addClass)(n,l),n.setAttribute("aria-selected","true"),void n.focus()}this.currentSelectedIndex=-1}},{key:"setSourceElementValues",value:function(){for(var e=[],i=0,s=this.selected.length;i<s;i+=1){var n=this.selected[i];e.push(n.value),(0,t.setElementState)(n.element,!0,this)}if(this.elementIsInput){var l=e.join(this.options.multipleSeparator);l!==this.element.value&&(this.element.value=l,(0,t.dispatchEvent)(this.element,"change"))}!this.selected.length&&this.elementIsSelect&&(this.element.value="")}},{key:"handleOptionSelect",value:function(e,i){var s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(!("number"!=typeof i||i<0||this.multiple&&this.selected.length>=this.options.maxItems)&&this.filteredSource.length&&this.filteredSource[i]){for(var n=(0,t.mergeObjects)(this.filteredSource[i]),l=this.selected.length,r=!1;l--;)if(this.selected[l].value===n.value){r=!0;break}this.setInputValue(this.multiple?"":n.label,!0),this.triggerAutoGrow(),r||this.multiple||(this.selected=[]),r||(this.selected.push(n),this.setSourceElementValues(),this.buildMultiSelected()),this.triggerOptionCallback("onConfirm",[n]),this.announce("".concat(n.label," ").concat(this.options.srSelectedText),0),this.disabled||!1===s||this.input.focus(),this.hide()}}},{key:"removeSelectedFromResults",value:function(e){if(!this.multiple||!this.selected.length)return e;var t=[];e:for(var i=0,s=e.length;i<s;i+=1){for(var n=this.selected,l=e[i],r=0,o=n.length;r<o;r+=1){if(l.label===n[r].label&&l.value===n[r].value)continue e}t.push(l)}return t}},{key:"setListOptions",value:function(e){var i=[],s=this.options.sourceMapping,n=this.removeSelectedFromResults(e),l=this.triggerOptionCallback("onResponse",n);this.filteredSource=l?(0,t.processSourceArray)(l,s):n;for(var r,o=this.ids.OPTION,a=this.cssNameSpace,c=this.filteredSource.length,h="function"==typeof this.options.onItemRender,u=this.forceShowAll?9999:this.options.maxResults,d=0;d<c&&d<u;d+=1){var p=this.filteredSource[d],m=h&&this.triggerOptionCallback("onItemRender",[p])||p.label;i.push('<li tabindex="-1" aria-selected="false" role="option" class="'.concat(a,'__option" ')+'id="'.concat(o,"--").concat(d,'" aria-posinset="').concat(d+1,'" ')+'aria-setsize="'.concat(c,'">').concat(m,"</li>"))}i.length?((0,t.addClass)(this.list,"".concat(a,"__list--has-results")),(0,t.removeClass)(this.list,"".concat(a,"__list--no-results"))):((0,t.removeClass)(this.list,"".concat(a,"__list--has-results")),(0,t.addClass)(this.list,"".concat(a,"__list--no-results")));var f=this.options.noResultsText;if(!i.length&&"string"==typeof f&&f.length){r=f;var v="".concat(a,"__option");i.push('<li class="'.concat(v," ").concat(v,'--no-results">').concat(f,"</li>"))}this.cancelFilterPrep(),r||(r=this.triggerOptionCallback("srResultsText",[c])),this.announce(r);var g=i.join("");if(this.currentListHtml!==g?(this.currentListHtml=g,this.list.innerHTML=g):this.resetOptionAttributes(),!i.length)return this.hide(),void(this.forceShowAll=!1);this.show(),this.forceShowAll=!1}},{key:"handleAsync",value:function(e){var i=this,s=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.xhr&&this.xhr.abort();var n=new XMLHttpRequest,l=encodeURIComponent,r=this.forceShowAll,o=r||s,a=s?null:this.api,c=this.multiple?this.selected.length:0,h=/\?/.test(this.source)?"&":"?",u=this.source+h+"".concat(l(this.options.asyncQueryParam),"=").concat(l(e),"&")+"".concat(l(this.options.asyncMaxResultsParam),"=")+"".concat(o?9999:c+this.options.maxResults);u=this.triggerOptionCallback("onAsyncPrep",[u],a)||u,n.open("GET",u),n.onload=function(){if(n.readyState===n.DONE&&200===n.status){i.forceShowAll=r;var l=i.triggerOptionCallback("onAsyncSuccess",[e,n],a),o=i.options.sourceMapping,c=l||n.responseText,h=(0,t.processSourceArray)(c,o,!1);s?(i.prepSelectedFromArray(h),i.setInputStartingStates(!1)):i.setListOptions(h)}},s||(this.xhr=n),n.send()}},{key:"filter",value:function(e){var i=this;if("string"==typeof e){var s=this.forceShowAll,n=this.triggerOptionCallback("onSearch",[e]);if(s||"string"!=typeof n||(e=n),this.term=this.inputPollingValue=e,this.async)return this.handleAsync(e),void(this.forceShowAll=!1);if("function"!=typeof this.source){e||(s=!0);var l=[];if(this.source&&this.source.length){var r=[t.CLEANED_LABEL];if(!s){e=(0,t.cleanString)(e,!0);var o=this.options.alsoSearchIn;Array.isArray(o)&&o.length&&(r=(0,t.removeDuplicatesAndLabel)(r.concat(o)))}for(var a=0,c=this.source.length;a<c;a+=1){var h=this.source[a];(s||(0,t.searchVarPropsFor)(h,r,e))&&l.push(h)}}this.setListOptions(l)}else this.source.call(this.api,this.term,function(e){var s=i.options.sourceMapping,n=(0,t.processSourceArray)(e,s);i.setListOptions(n)})}else this.cancelFilterPrep()}},{key:"cancelFilterPrep",value:function(){this.filterTimer&&clearTimeout(this.filterTimer);var e=this.cssNameSpace;(0,t.removeClass)(this.wrapper,"".concat(e,"__wrapper--loading loading")),(0,t.removeClass)(this.input,"".concat(e,"__input--loading loading")),this.filtering=!1}},{key:"filterPrep",value:function(e){var i=this,s=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],l=this.forceShowAll,r=l||n?0:this.options.delay;this.cancelFilterPrep(),this.filtering=!0,this.filterTimer=setTimeout(function(){var n=i.input.value;if((l||""===n||s&&!i.multiple&&i.selected.length&&(0,t.trimString)(i.selected[0].label)===(0,t.trimString)(n))&&(n=""),i.setInputDescription(),i.inputPollingValue=n,!l&&n.length<i.options.minLength)i.hide();else{var r;try{r=e&&"keydown"===e.type&&(e.altKey||e.ctrlKey||e.metaKey)}catch(e){}var o=""!==n&&n===i.term;if(!o||o&&!i.menuOpen&&!r){var a=i.cssNameSpace;(0,t.addClass)(i.wrapper,"".concat(a,"__wrapper--loading loading")),(0,t.addClass)(i.input,"".concat(a,"__input--loading loading")),i.currentSelectedIndex=-1,i.filter(n)}}},r)}},{key:"filterPrepShowAll",value:function(e){var t=this;this.disabled||(this.showAllPrepTimer&&clearTimeout(this.showAllPrepTimer),this.showAllPrepTimer=setTimeout(function(){t.componentBlurTimer&&clearTimeout(t.componentBlurTimer),e.preventDefault(),t.forceShowAll=!0,t.filterPrep(e,!1,!0)}))}},{key:"handleComponentBlur",value:function(e){var i=this,s=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.componentBlurTimer&&clearTimeout(this.componentBlurTimer);var n=s?0:100;this.componentBlurTimer=setTimeout(function(){var e=document.activeElement;if(s||!e||i.showAll&&i.showAll===e||e[t.SELECTED_OPTION]||!i.wrapper.contains(e)){i.xhr&&i.xhr.abort();var n=i.indexOfQueryIn.bind(i);if(!s&&i.options.confirmOnBlur&&i.menuOpen){var l=i.currentSelectedIndex;"number"==typeof l&&-1!==l||(l=n(i.filteredSource)),i.handleOptionSelect({},l,!1)}if(i.cancelFilterPrep(),i.hide(),!i.multiple&&-1===n(i.selected))(i.elementIsInput||i.elementIsSelect)&&""!==i.element.value&&(i.element.value="",(0,t.dispatchEvent)(i.element,"change")),i.selected.length&&i.removeEntryFromSelected(i.selected[0]),i.setInputValue("",!0);i.multiple&&i.setInputValue("",!0),i.triggerAutoGrow(),i.documentClickBound&&(i.documentClickBound=!1,document.removeEventListener("click",i.documentClick))}},n)}},{key:"handleEnterKey",value:function(e){if(this.isSelectedElem(e.target)){var i=e.target[t.SELECTED_OPTION];return this.removeEntryFromSelected(i)}this.disabled||(this.showAll&&e.target===this.showAll?this.filterPrepShowAll(e):(this.menuOpen&&(e.preventDefault(),this.currentSelectedIndex>-1&&this.handleOptionSelect(e,this.currentSelectedIndex)),e.target===this.input&&this.filterPrep(e,!1,!0)))}},{key:"handleDownArrowKey",value:function(e){if(e.preventDefault(),this.menuOpen||(this.forceShowAll=this.options.minLength<1,(this.forceShowAll||this.input.value.length>=this.options.minLength)&&this.filterPrep(e)),this.menuOpen&&!this.filtering){var t=this.currentSelectedIndex;"number"!=typeof t||t<0?this.setOptionFocus(e,0):this.setOptionFocus(e,t+1)}}},{key:"handleUpArrowKey",value:function(e){e.preventDefault(),!this.disabled&&this.menuOpen&&"number"==typeof this.currentSelectedIndex&&this.setOptionFocus(e,this.currentSelectedIndex-1)}},{key:"handleKeyDownDefault",value:function(e){var i=e.target===this.input;if(32===e.keyCode&&!i)return e.preventDefault(),this.handleEnterKey(e);if(!this.disabled){var s=this.selected&&this.selected.length;if(this.options.deleteOnBackspace&&""===this.input.value&&8===e.keyCode&&s&&i&&this.multiple)this.removeEntryFromSelected(this.selected[s-1]);else{var n=(0,t.isPrintableKey)(e.keyCode),l=!i&&n;l&&this.input.focus(),(l||i&&n)&&this.filterPrep(e)}}}},{key:"prepKeyDown",value:function(e){switch(e.keyCode){case 13:this.handleEnterKey(e);break;case 27:this.handleComponentBlur(e,!0);break;case 38:this.handleUpArrowKey(e);break;case 40:this.handleDownArrowKey(e);break;default:this.handleKeyDownDefault(e)}}},{key:"cancelPolling",value:function(){this.pollingTimer&&clearTimeout(this.pollingTimer)}},{key:"startPolling",value:function(){var e=this;this.filtering||this.input.value===this.inputPollingValue||this.filterPrep({}),this.pollingTimer=setTimeout(function(){e.startPolling()},200)}},{key:"bindEvents",value:function(){var i=this;this.wrapper.addEventListener("focusout",function(e){i.handleComponentBlur(e,!1)}),this.wrapper.addEventListener("focusin",function(e){i.list.contains(e.target)||(i.currentSelectedIndex=-1)}),this.wrapper.addEventListener("keydown",function(e){i.prepKeyDown(e)}),this.wrapper.addEventListener("click",function(e){if(e.target!==i.wrapper){if(i.isSelectedElem(e.target)){var s=e.target[t.SELECTED_OPTION];i.removeEntryFromSelected(s)}}else i.input.focus()});var s="".concat(this.cssNameSpace,"__wrapper--focused focused focus"),n="".concat(this.cssNameSpace,"__input--focused focused focus");this.input.addEventListener("blur",function(){(0,t.removeClass)(i.wrapper,s),(0,t.removeClass)(i.input,n),i.cancelPolling()}),this.input.addEventListener("input",function(e){i.filterPrep(e)}),this.input.addEventListener("click",function(e){!i.menuOpen&&i.input.value.length>=i.options.minLength&&i.filterPrep(e,!0)}),this.input.addEventListener("focusin",function(){(0,t.addClass)(i.wrapper,s),(0,t.addClass)(i.input,n),i.startPolling(),i.disabled||i.menuOpen||i.filterPrep(event,!0)}),this.showAll&&this.showAll.addEventListener("click",function(e){i.filterPrepShowAll(e)}),this.list.addEventListener("mouseenter",function(e){i.resetOptionAttributes()}),this.list.addEventListener("click",function(e){if(e.target!==i.list){var t=i.list.childNodes;if(t.length){var s=[].indexOf.call(t,e.target);i.handleOptionSelect(e,s)}}}),this.autoGrow&&(this.AutoGrowInput=new e.default(this.input))}},{key:"prepListSourceCheckboxes",value:function(){this.multiple=!0,this.source=[];for(var e=this.element.querySelectorAll('input[type="checkbox"]'),i=0,s=e.length;i<s;i+=1){var n=e[i];if(n.value){var l={element:n,value:n.value},r=n.closest("label");!r&&n.id&&(r=document.querySelector('[for="'+n.id+'"]')),r&&(l.label=r.textContent),l.label||(l.label=l.value),l[t.CLEANED_LABEL]=(0,t.cleanString)(l.label),this.source.push(l),n.checked&&this.selected.push(l)}}}},{key:"prepListSourceDdl",value:function(){this.multiple=this.element.multiple,this.source=[];for(var e=this.element.querySelectorAll("option"),i=0,s=e.length;i<s;i+=1){var n=e[i];if(n.value){var l={element:n,value:n.value,label:n.textContent};l[t.CLEANED_LABEL]=(0,t.cleanString)(l.label),this.source.push(l),n.selected&&this.selected.push(l)}}}},{key:"prepSelectedFromArray",value:function(e){var t=this.elementIsInput&&this.element.value;if(t&&e&&e.length)for(var i=this.options.multiple,s=this.options.multipleSeparator,n=i?t.split(s):[t],l=0,r=n.length;l<r;l+=1){var o=n[l],a=this.indexOfQueryIn;if(!(a(this.selected,o,"value")>-1)){var c=a(e,o,"value");c>-1&&this.selected.push(e[c])}}}},{key:"prepListSourceArray",value:function(){var e=this.options.sourceMapping;this.source=(0,t.processSourceArray)(this.source,e),this.prepSelectedFromArray(this.source)}},{key:"prepListSourceAsync",value:function(){this.async=!0,this.elementIsInput&&this.element.value&&this.handleAsync(this.element.value,!0)}},{key:"prepListSourceFunction",value:function(){var e=this;this.elementIsInput&&this.element.value&&this.source.call(void 0,this.element.value,function(i){e.prepSelectedFromArray((0,t.processSourceArray)(i,e.options.sourceMapping)),e.setInputStartingStates(!1)})}},{key:"prepListSource",value:function(){return"function"==typeof this.source?this.prepListSourceFunction():"string"==typeof this.source&&this.source.length?this.prepListSourceAsync():Array.isArray(this.source)&&this.source.length?this.prepListSourceArray():this.elementIsSelect?this.prepListSourceDdl():void(this.element.querySelector('input[type="checkbox"]')&&this.prepListSourceCheckboxes())}},{key:"setInputStartingStates",value:function(){if(!(arguments.length>0&&void 0!==arguments[0])||arguments[0]){if(this.ids.ELEMENT){var e=document.querySelector('[for="'+this.ids.ELEMENT+'"]');e&&(e.ariaAutocompleteOriginalFor=this.ids.ELEMENT,e.setAttribute("for",this.ids.INPUT))}var t=this.element.getAttribute("aria-describedby");t&&this.input.setAttribute("aria-describedby",t);var i=this.element.getAttribute("aria-labelledby");i&&this.input.setAttribute("aria-labelledby",i)}this.selected.length&&(this.multiple?this.buildMultiSelected():(this.setInputValue(this.selected[0].label||"",!0),this.triggerAutoGrow())),this.setInputDescription(),this.element.disabled&&this.disable()}},{key:"setHtml",value:function(){var e=this.options,t=this.cssNameSpace,i=e.wrapperClassName?" ".concat(e.wrapperClassName):"",s=['<div id="'.concat(this.ids.WRAPPER,'" class="').concat(t,"__wrapper").concat(i,'">')],n=e.name?" ".concat(e.name):"",l=e.inputClassName?" ".concat(e.inputClassName):"";s.push('<input type="text" autocomplete="off" aria-expanded="false" aria-autocomplete="list" '+'role="combobox" id="'.concat(this.ids.INPUT,'" placeholder="').concat(e.placeholder,'" ')+'aria-owns="'.concat(this.ids.LIST,'" aria-placeholder="').concat(e.placeholder,'" ')+'class="'.concat(t,"__input").concat(l,'"').concat(n," />")),e.showAllControl&&s.push('<span role="button" aria-label="'.concat(e.srShowAllText,'" class="').concat(t,'__show-all" ')+'tabindex="0" id="'.concat(this.ids.BUTTON,'" aria-expanded="false"></span>'));var r=e.srListLabelText,o=e.listClassName?" ".concat(e.listClassName):"",a=r?' aria-label="'.concat(r,'"'):"";s.push('<ul id="'.concat(this.ids.LIST,'" class="').concat(t,"__list").concat(o,'" role="listbox" ')+'hidden="hidden"'.concat(a,"></ul>")),s.push('<span class="sr-only '.concat(t,"__sr-only ").concat(t,'__sr-assistance" ')+'id="'.concat(this.ids.SR_ASSISTANCE,'">').concat(e.srAssistiveText,"</span>")),s.push('<span class="sr-only '.concat(t,"__sr-only ").concat(t,'__sr-announcements" ')+'id="'.concat(this.ids.SR_ANNOUNCEMENTS,'" aria-live="polite" aria-atomic="true"></span>')),s.push("</div>"),this.element.insertAdjacentHTML("afterend",s.join(""))}},{key:"generateApi",value:function(){var e=this;this.api={open:function(){return e.show.call(e)},close:function(){return e.hide.call(e)},filter:function(t){return e.filter.call(t)}};for(var t=["options","destroy","enable","disable","input","wrapper","list","selected"],i=function(i,s){e.api[t[i]]="function"==typeof e[t[i]]?function(){return e[t[i]].call(e)}:e[t[i]]},s=0,n=t.length;s<n;s+=1)i(s);this.element.ariaAutocomplete=this.api}},{key:"destroy",value:function(){var e=document.querySelector('[for="'+this.ids.INPUT+'"]');for(var t in e&&e.ariaAutocompleteOriginalFor&&(e.setAttribute("for",e.ariaAutocompleteOriginalFor),delete e.ariaAutocompleteOriginalFor),this.documentClickBound&&document.removeEventListener("click",this.documentClick),this.autoGrow&&this.AutoGrowInput&&this.AutoGrowInput.destroy(),this.element.parentNode.removeChild(this.wrapper),delete this.element.ariaAutocomplete,this.show(this.element),this)this.hasOwnProperty(t)&&(this[t]=null)}},{key:"init",value:function(e,i){r+=1,this.ids={},this.ids.ELEMENT=e.id,this.ids.PREFIX="".concat(e.id||"","aria-autocomplete-").concat(r),this.ids.LIST="".concat(this.ids.PREFIX,"-list"),this.ids.INPUT="".concat(this.ids.PREFIX,"-input"),this.ids.BUTTON="".concat(this.ids.PREFIX,"-button"),this.ids.OPTION="".concat(this.ids.PREFIX,"-option"),this.ids.WRAPPER="".concat(this.ids.PREFIX,"-wrapper"),this.ids.OPTION_SELECTED="".concat(this.ids.OPTION,"-selected"),this.ids.SR_ASSISTANCE="".concat(this.ids.PREFIX,"-sr-assistance"),this.ids.SR_ANNOUNCEMENTS="".concat(this.ids.PREFIX,"-sr-announcements"),this.selected=[],this.element=e,this.elementIsInput="INPUT"===e.nodeName,this.elementIsSelect="SELECT"===e.nodeName,this.options=(0,t.mergeObjects)(o,i),this.source=this.options.source,this.multiple=this.options.multiple,this.autoGrow=this.options.autoGrow,this.cssNameSpace=this.options.cssNameSpace,this.documentClick=this.handleComponentBlur.bind(this),this.setHtml(),this.list=document.getElementById(this.ids.LIST),this.input=document.getElementById(this.ids.INPUT),this.wrapper=document.getElementById(this.ids.WRAPPER),this.showAll=document.getElementById(this.ids.BUTTON),this.srAnnouncements=document.getElementById(this.ids.SR_ANNOUNCEMENTS),this.prepListSource();var s="";this.options.showAllControl&&(s+=" ".concat(this.cssNameSpace,"__wrapper--show-all")),this.autoGrow&&(s+=" ".concat(this.cssNameSpace,"__wrapper--autogrow")),this.multiple&&(s+=" ".concat(this.cssNameSpace,"__wrapper--multiple")),s&&(0,t.addClass)(this.wrapper,s),this.hide(this.list),this.hide(this.element),this.generateApi(),this.setInputStartingStates(),this.bindEvents(),this.triggerOptionCallback("onReady",[this.wrapper])}}]),i}();window.AriaAutocomplete=function(e,t){return new a(e,t).api};var c=function(e,t){return new a(e,t).api};exports.default=c; | ||
},{"./closest-polyfill":"kTsq","./autogrow":"KnPF","./autocomplete-helpers":"MBeS"}]},{},["c8cM"], null) | ||
//# sourceMappingURL=/aria-autocomplete.min.js.map | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.trimString=r,exports.hasClass=a,exports.addClass=o,exports.removeClass=i,exports.cleanString=v,exports.mergeObjects=f,exports.dispatchEvent=p,exports.setElementState=g,exports.processSourceArray=h,exports.searchVarPropsFor=E,exports.removeDuplicatesAndLabel=m,exports.SELECTED_OPTION_PROP=exports.CLEANED_LABEL_PROP=void 0;var e="_ariaAutocompleteCleanedLabel";exports.CLEANED_LABEL_PROP=e;var t="_ariaAutocompleteSelectedOption";function r(e){return null==e?"":(e+"").trim()}exports.SELECTED_OPTION_PROP=t;var n=function(e){return e.getAttribute&&e.getAttribute("class")||""};function a(e,t){return" ".concat(n(e)," ").indexOf(" ".concat(t," "))>-1}function o(e,t){for(var r=n(e),a=" ".concat(r," "),o="",i=0,l=t.split(" "),s=l.length;i<s;i+=1)""!==l[i]&&-1===a.indexOf(" ".concat(l[i]," "))&&(o+=" "+l[i]);r!==(o=(r+o).trim())&&e.setAttribute("class",o)}function i(e,t){for(var r=n(e),a=" ".concat(r," "),o=0,i=t.split(" "),l=i.length;o<l;o+=1)a=a.replace(" ".concat(i[o]," ")," ");r!==(a=a.trim())&&e.setAttribute("class",a)}var l=/&/g,s=/\s\s+/g,c=/[\u2018\u2019',:\u2013-]/g,u=/[\-\[\]{}()*+?.,\\\^$|#\s]/g;function v(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e=r(e).toLowerCase().replace(c,"").replace(l,"and").replace(s," "),t&&(e=e.replace(u,"\\$&")),e}function f(){for(var e={},t=0,r=arguments.length;t<r;t+=1){var n=t<0||arguments.length<=t?void 0:arguments[t];for(var a in n)n.hasOwnProperty(a)&&void 0!==n[a]&&(e[a]=n[a])}return e}function p(e,t){if("createEvent"in document){var r=document.createEvent("HTMLEvents");r.initEvent(t,!0,!0),e.dispatchEvent(r)}else e.fireEvent("on"+t)}function g(e,t,r){t=!!t,e&&("INPUT"===e.nodeName&&"boolean"==typeof e.checked&&e.checked!==t&&(e.checked=t,p(e,"change")),"OPTION"===e.nodeName&&e.selected!==t&&(e.selected=t,r.elementChangeEventTimer&&clearTimeout(r.elementChangeEventTimer),r.elementChangeEventTimer=setTimeout(function(){p(e.closest("select"),"change")},1)))}function h(t){for(var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0,a=[],o=r.value,i=r.label,l=0,s=t.length;l<s;l+=1){var c={},u=t[l];if("string"==typeof u)c.value=c.label=u;else{var p=(c=f(u))[o]||c.value||c.label,g=c[i]||c.label||c.value;c.value=(p||"").toString(),c.label=(g||"").toString()}!1!==n&&(c[e]=v(c.label)),a.push(c)}return a}var d=function t(r,n,a){if("string"==typeof r)return a!==e&&(r=v(r,!1)),-1!==r.search(n);if(Array.isArray(r))for(var o=0,i=r.length;o<i;o+=1)if(t(r[o],n))return!0;return!1};function E(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];for(var a in n&&(r=v(r,!0)),e)if(e.hasOwnProperty(a)){var o=!1;if("string"==typeof e[a]){for(var i=t.length;i--;)if(t[i]===a){o=!0;break}}else o=Array.isArray(e[a]);if(o&&d(e[a],r,a))return!0}return!1}function m(e){for(var t=[],n=0,a=e.length;n<a;n+=1)if("string"==typeof e[n]){for(var o=r(e[n]),i="label"!==o,l=t.length;i&&l--;)t[l]===o&&(i=!1);i&&t.push(o)}return t} | ||
},{}],"vPu2":[function(require,module,exports) { | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var e={name:"",source:"",sourceMapping:{},alsoSearchIn:[],delay:100,minLength:1,maxResults:9999,showAllControl:!1,confirmOnBlur:!0,multiple:!1,autoGrow:!1,maxItems:9999,multipleSeparator:",",deleteOnBackspace:!1,asyncQueryParam:"q",asyncMaxResultsParam:"limit",placeholder:"",noResultsText:"No results",cssNameSpace:"aria-autocomplete",listClassName:"",inputClassName:"",wrapperClassName:"",srDeleteText:"delete",srDeletedText:"deleted",srShowAllText:"Show all",srSelectedText:"selected",srListLabelText:"Search suggestions",srAssistiveText:"When results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures.",srResultsText:function(e){return"".concat(e," ").concat(1===e?"result":"results"," available.")},onSearch:void 0,onAsyncPrep:void 0,onAsyncSuccess:void 0,onResponse:void 0,onItemRender:void 0,onConfirm:void 0,onDelete:void 0,onReady:void 0,onClose:void 0,onOpen:void 0};exports.default=e; | ||
},{}],"GbHv":[function(require,module,exports) { | ||
"use strict";function e(e){var t=e.Element.prototype;"function"!=typeof t.matches&&(t.matches=t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||function(e){for(var t=(this.document||this.ownerDocument).querySelectorAll(e),o=0;t[o]&&t[o]!==this;)++o;return Boolean(t[o])}),"function"!=typeof t.closest&&(t.closest=function(e){for(var t=this;t&&1===t.nodeType;){if(t.matches(e))return t;t=t.parentNode}return null})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var t=e;exports.default=t; | ||
},{}],"c8cM":[function(require,module,exports) { | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var e=l(require("is-printable-keycode")),t=l(require("input-autowidth")),i=require("./autocomplete-helpers"),s=l(require("./default-options")),n=l(require("element-closest"));function l(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var i=0;i<t.length;i++){var s=t[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}function o(e,t,i){return t&&a(e.prototype,t),i&&a(e,i),e}(0,n.default)(window);var c=0,h=function(){function n(e,t){if(r(this,n),e){if(e.ariaAutocomplete&&e.ariaAutocomplete.open)return{api:e.ariaAutocomplete};this.list,this.input,this.wrapper,this.showAll,this.srAnnouncements,this.ids,this.xhr,this.term,this.source,this.menuOpen,this.multiple,this.selected,this.disabled,this.autoGrow,this.filtering,this.cssNameSpace,this.forceShowAll,this.filteredSource,this.currentListHtml,this.inputPollingValue,this.currentSelectedIndex,this.documentClick,this.documentClickBound,this.filterTimer,this.pollingTimer,this.announcementTimer,this.componentBlurTimer,this.elementChangeEventTimer,this.inputAutoWidth,this.init(e,t)}}return o(n,[{key:"triggerOptionCallback",value:function(e,t,i){if(i=void 0===i?this.api:i,"function"==typeof this.options[e])return this.options[e].apply(i,t)}},{key:"show",value:function(e){if(void 0!==e){var t="".concat(this.cssNameSpace,"--hide hide hidden");return(0,i.removeClass)(e,t),e.removeAttribute("hidden")}if(this.input.setAttribute("aria-expanded","true"),this.showAll){var s=(!!this.forceShowAll).toString();this.showAll.setAttribute("aria-expanded",s)}this.menuOpen||(this.show(this.list),this.menuOpen=!0,this.triggerOptionCallback("onOpen",[this.list]),this.documentClickBound||(this.documentClickBound=!0,document.addEventListener("click",this.documentClick)))}},{key:"hide",value:function(e){if(void 0!==e)return(0,i.addClass)(e,"".concat(this.cssNameSpace,"--hide hide hidden")),e.setAttribute("hidden","hidden");this.currentSelectedIndex=-1,this.input.setAttribute("aria-expanded","false"),this.showAll&&this.showAll.setAttribute("aria-expanded","false"),this.menuOpen&&(this.hide(this.list),this.menuOpen=!1,this.triggerOptionCallback("onClose",[this.list]))}},{key:"enable",value:function(){if(this.disabled){this.disabled=!1,this.input.disabled=!1;var e=this.cssNameSpace;(0,i.removeClass)(this.input,"".concat(e,"__input--disabled disabled")),(0,i.removeClass)(this.wrapper,"".concat(e,"__wrapper--disabled disabled")),this.showAll&&(this.showAll.setAttribute("tabindex","0"),(0,i.removeClass)(this.showAll,"".concat(e,"__show-all--disabled disabled")))}}},{key:"disable",value:function(){if(!this.disabled){this.disabled=!0,this.input.disabled=!0;var e=this.cssNameSpace;(0,i.addClass)(this.input,"".concat(e,"__input--disabled disabled")),(0,i.addClass)(this.wrapper,"".concat(e,"__wrapper--disabled disabled")),this.showAll&&(this.showAll.setAttribute("tabindex","-1"),(0,i.addClass)(this.showAll,"".concat(e,"__show-all--disabled disabled")))}}},{key:"setInputValue",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.input.value=this.term=e,t&&(this.inputPollingValue=e),this.autoGrow&&this.inputAutoWidth&&this.inputAutoWidth.trigger()}},{key:"indexOfQueryIn",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.input.value,s=arguments.length>2?arguments[2]:void 0;if(t=(0,i.trimString)(t).toLowerCase()){s=s||"label";for(var n=0,l=e.length;n<l;n+=1)if((0,i.trimString)(e[n][s]).toLowerCase()===t)return n}return-1}},{key:"announce",value:function(e,t){var i=this;if(e&&this.srAnnouncements){if(0===t)return this.srAnnouncements.textContent=e;t="number"==typeof t?t:400,this.announcementTimer&&clearTimeout(this.announcementTimer),this.announcementTimer=setTimeout(function(){i.srAnnouncements.textContent=e},t)}}},{key:"isSelectedElem",value:function(e){return this.multiple&&e[i.SELECTED_OPTION_PROP]&&(0,i.hasClass)(e,"".concat(this.cssNameSpace,"__selected"))}},{key:"getSelectedElems",value:function(){for(var e=this.wrapper.childNodes,t=[],i=0,s=e.length;i<s;i+=1)this.isSelectedElem(e[i])&&t.push(e[i]);return t}},{key:"removeEntryFromSelected",value:function(e){var t=this.selected.indexOf(e);if(-1===t)for(var s=0,n=this.selected.length;s<n;s+=1)if(this.selected[s].value===e.value){t=s;break}if(t>-1&&this.selected[t]){var l=(0,i.mergeObjects)(this.selected[t]),r=l.label;(0,i.setElementState)(l.element,!1,this),this.selected.splice(t,1),this.triggerOptionCallback("onDelete",[l]),this.setSourceElementValues(),this.buildMultiSelected(),this.announce("".concat(r," ").concat(this.options.srDeletedText),0)}}},{key:"buildMultiSelected",value:function(){if(this.multiple){this.multiple&&this.selected.length>=this.options.maxItems?this.disable():this.enable();var e=this.getSelectedElems();if(this.selected.length||e.length){for(var t=[],s=e.length;s--;){for(var n=e[s][i.SELECTED_OPTION_PROP],l=this.selected.length,r=!1;l--;){var a=this.selected[l];if(a===n||a.value===n.value){r=!0;break}}r?t.push(e[s]):this.wrapper.removeChild(e[s])}for(var o=this.options.srDeleteText,c=document.createDocumentFragment(),h="".concat(this.cssNameSpace,"__selected"),u=0,d=this.selected.length;u<d;u+=1){for(var p=this.selected[u],m=t.length,f=!1;m--;){var v=t[m][i.SELECTED_OPTION_PROP];if(v===p||v.value===p.value){f=!0;break}}if(!f){var g=p.label,S=document.createElement("span");S.setAttribute("tabindex","0"),S.setAttribute("role","button"),S.setAttribute("class",h),S.setAttribute("aria-label",o+" "+g),S[i.SELECTED_OPTION_PROP]=p,S.textContent=g,c.appendChild(S)}}c.childNodes&&c.childNodes.length&&this.wrapper.insertBefore(c,this.list);for(var b=[],y=this.getSelectedElems(),A=0,w=y.length;A<w;A+=1){var E="".concat(this.ids.OPTION_SELECTED,"-").concat(A);y[A].setAttribute("id",E),b.push(E)}if(b.push(this.ids.LIST),this.input.setAttribute("aria-owns",b.join(" ")),this.autoGrow&&this.options.placeholder){var O=this.selected.length?"":this.options.placeholder;this.input.setAttribute("placeholder",O)}}}}},{key:"setInputDescription",value:function(){var e=this.input.getAttribute("aria-describedby"),t=(0,i.trimString)(e||""),s=t.replace(this.ids.SR_ASSISTANCE,"");0===this.input.value.length&&(s=s+" "+this.ids.SR_ASSISTANCE),(s=(0,i.trimString)(s))?s!==t&&this.input.setAttribute("aria-describedby",s):e&&this.input.removeAttribute("aria-describedby")}},{key:"resetOptionAttributes",value:function(){for(var e=this.cssNameSpace,t=this.list.childNodes,s=t.length;s--;)(0,i.removeClass)(t[s],"".concat(e,"__option--focused focused focus")),t[s].setAttribute("aria-selected","false")}},{key:"setOptionFocus",value:function(e,t){this.resetOptionAttributes();var s=this.list.childNodes;if(t<0||!s||!s.length)return this.currentSelectedIndex=-1,void(e&&e.target!==this.input&&this.input.focus());if(t>=s.length)return this.currentSelectedIndex=s.length-1,void this.setOptionFocus(e,this.currentSelectedIndex);var n=s[t];if(n&&"string"==typeof n.getAttribute("tabindex")){this.currentSelectedIndex=t;var l="".concat(this.cssNameSpace,"__option--focused focused focus");return(0,i.addClass)(n,l),n.setAttribute("aria-selected","true"),void n.focus()}this.currentSelectedIndex=-1}},{key:"setSourceElementValues",value:function(){for(var e=[],t=0,s=this.selected.length;t<s;t+=1){var n=this.selected[t];e.push(n.value),(0,i.setElementState)(n.element,!0,this)}if(this.elementIsInput){var l=e.join(this.options.multipleSeparator);l!==this.element.value&&(this.element.value=l,(0,i.dispatchEvent)(this.element,"change"))}!this.selected.length&&this.elementIsSelect&&(this.element.value="")}},{key:"handleOptionSelect",value:function(e,t){var s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(!("number"!=typeof t||t<0||this.multiple&&this.selected.length>=this.options.maxItems)&&this.filteredSource.length&&this.filteredSource[t]){for(var n=(0,i.mergeObjects)(this.filteredSource[t]),l=this.selected.length,r=!1;l--;)if(this.selected[l].value===n.value){r=!0;break}this.setInputValue(this.multiple?"":n.label,!0),r||this.multiple||(this.selected=[]),r||(this.selected.push(n),this.setSourceElementValues(),this.buildMultiSelected()),this.triggerOptionCallback("onConfirm",[n]),this.announce("".concat(n.label," ").concat(this.options.srSelectedText),0),this.disabled||!1===s||this.input.focus(),this.hide()}}},{key:"removeSelectedFromResults",value:function(e){if(!this.multiple||!this.selected.length)return e;var t=[];e:for(var i=0,s=e.length;i<s;i+=1){for(var n=this.selected,l=e[i],r=0,a=n.length;r<a;r+=1){if(l.label===n[r].label&&l.value===n[r].value)continue e}t.push(l)}return t}},{key:"setListOptions",value:function(e){var t=[],s=this.options.sourceMapping,n=this.removeSelectedFromResults(e),l=this.triggerOptionCallback("onResponse",n);this.filteredSource=l?(0,i.processSourceArray)(l,s):n;for(var r,a=this.ids.OPTION,o=this.cssNameSpace,c=this.filteredSource.length,h="function"==typeof this.options.onItemRender,u=this.forceShowAll?9999:this.options.maxResults,d=0;d<c&&d<u;d+=1){var p=this.filteredSource[d],m=h&&this.triggerOptionCallback("onItemRender",[p])||p.label;t.push('<li tabindex="-1" aria-selected="false" role="option" class="'.concat(o,'__option" ')+'id="'.concat(a,"--").concat(d,'" aria-posinset="').concat(d+1,'" ')+'aria-setsize="'.concat(c,'">').concat(m,"</li>"))}t.length?((0,i.addClass)(this.list,"".concat(o,"__list--has-results")),(0,i.removeClass)(this.list,"".concat(o,"__list--no-results"))):((0,i.removeClass)(this.list,"".concat(o,"__list--has-results")),(0,i.addClass)(this.list,"".concat(o,"__list--no-results")));var f=this.options.noResultsText;if(!t.length&&"string"==typeof f&&f.length){r=f;var v="".concat(o,"__option");t.push('<li class="'.concat(v," ").concat(v,'--no-results">').concat(f,"</li>"))}this.cancelFilterPrep(),r||(r=this.triggerOptionCallback("srResultsText",[c])),this.announce(r);var g=t.join("");if(this.currentListHtml!==g?(this.currentListHtml=g,this.list.innerHTML=g):this.resetOptionAttributes(),!t.length)return this.hide(),void(this.forceShowAll=!1);this.show(),this.forceShowAll=!1}},{key:"handleAsync",value:function(e){var t=this,s=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.xhr&&this.xhr.abort();var n=new XMLHttpRequest,l=encodeURIComponent,r=this.forceShowAll,a=r||s,o=s?null:this.api,c=this.multiple?this.selected.length:0,h=/\?/.test(this.source)?"&":"?",u=this.source+h+"".concat(l(this.options.asyncQueryParam),"=").concat(l(e),"&")+"".concat(l(this.options.asyncMaxResultsParam),"=")+"".concat(a?9999:c+this.options.maxResults);u=this.triggerOptionCallback("onAsyncPrep",[u],o)||u,n.open("GET",u),n.onload=function(){if(n.readyState===n.DONE&&200===n.status){t.forceShowAll=r;var l=t.triggerOptionCallback("onAsyncSuccess",[e,n],o),a=t.options.sourceMapping,c=l||n.responseText,h=(0,i.processSourceArray)(c,a,!1);s?(t.prepSelectedFromArray(h),t.setInputStartingStates(!1)):t.setListOptions(h)}},s||(this.xhr=n),n.send()}},{key:"filter",value:function(e){var t=this;if("string"==typeof e){var s=this.forceShowAll,n=this.triggerOptionCallback("onSearch",[e]);if(s||"string"!=typeof n||(e=n),this.term=this.inputPollingValue=e,"string"==typeof this.source&&this.source.length)return this.handleAsync(e),void(this.forceShowAll=!1);if("function"!=typeof this.source){e||(s=!0);var l=[];if(this.source&&this.source.length){var r=[i.CLEANED_LABEL_PROP];if(!s){e=(0,i.cleanString)(e,!0);var a=this.options.alsoSearchIn;Array.isArray(a)&&a.length&&(r=(0,i.removeDuplicatesAndLabel)(r.concat(a)))}for(var o=0,c=this.source.length;o<c;o+=1){var h=this.source[o];(s||(0,i.searchVarPropsFor)(h,r,e))&&l.push(h)}}this.setListOptions(l)}else this.source.call(this.api,this.term,function(e){var s=t.options.sourceMapping,n=(0,i.processSourceArray)(e,s);t.setListOptions(n)})}else this.cancelFilterPrep()}},{key:"cancelFilterPrep",value:function(){this.filterTimer&&clearTimeout(this.filterTimer);var e=this.cssNameSpace;(0,i.removeClass)(this.wrapper,"".concat(e,"__wrapper--loading loading")),(0,i.removeClass)(this.input,"".concat(e,"__input--loading loading")),this.filtering=!1}},{key:"filterPrep",value:function(e){var t=this,s=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],l=this.forceShowAll,r=l||n?0:this.options.delay;this.cancelFilterPrep(),this.filtering=!0,this.filterTimer=setTimeout(function(){var n=t.input.value;if((l||""===n||s&&!t.multiple&&t.selected.length&&(0,i.trimString)(t.selected[0].label)===(0,i.trimString)(n))&&(n=""),t.setInputDescription(),t.inputPollingValue=n,!l&&n.length<t.options.minLength)t.hide();else{var r;try{r=e&&"keydown"===e.type&&(e.altKey||e.ctrlKey||e.metaKey)}catch(e){}var a=""!==n&&n===t.term;if(!a||a&&!t.menuOpen&&!r){var o=t.cssNameSpace;(0,i.addClass)(t.wrapper,"".concat(o,"__wrapper--loading loading")),(0,i.addClass)(t.input,"".concat(o,"__input--loading loading")),t.currentSelectedIndex=-1,t.filter(n)}}},r)}},{key:"filterPrepShowAll",value:function(e){var t=this;this.disabled||(this.showAllPrepTimer&&clearTimeout(this.showAllPrepTimer),this.showAllPrepTimer=setTimeout(function(){t.componentBlurTimer&&clearTimeout(t.componentBlurTimer),e.preventDefault(),t.forceShowAll=!0,t.filterPrep(e,!1,!0)}))}},{key:"handleComponentBlur",value:function(e){var t=this,s=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.componentBlurTimer&&clearTimeout(this.componentBlurTimer);var n=s?0:100;this.componentBlurTimer=setTimeout(function(){var e=document.activeElement;if(s||!e||t.showAll&&t.showAll===e||e[i.SELECTED_OPTION_PROP]||!t.wrapper.contains(e)){t.xhr&&t.xhr.abort();var n=t.indexOfQueryIn.bind(t);if(!s&&t.options.confirmOnBlur&&t.menuOpen){var l=t.currentSelectedIndex;"number"==typeof l&&-1!==l||(l=n(t.filteredSource)),t.handleOptionSelect({},l,!1)}if(t.cancelFilterPrep(),t.hide(),!t.multiple&&-1===n(t.selected))(t.elementIsInput||t.elementIsSelect)&&""!==t.element.value&&(t.element.value="",(0,i.dispatchEvent)(t.element,"change")),t.selected.length&&t.removeEntryFromSelected(t.selected[0]),t.setInputValue("",!0);t.multiple&&t.setInputValue("",!0),t.documentClickBound&&(t.documentClickBound=!1,document.removeEventListener("click",t.documentClick))}},n)}},{key:"handleEnterKey",value:function(e){if(this.isSelectedElem(e.target)){var t=e.target[i.SELECTED_OPTION_PROP];return this.removeEntryFromSelected(t)}this.disabled||(this.showAll&&e.target===this.showAll?this.filterPrepShowAll(e):(this.menuOpen&&(e.preventDefault(),this.currentSelectedIndex>-1&&this.handleOptionSelect(e,this.currentSelectedIndex)),e.target===this.input&&this.filterPrep(e,!1,!0)))}},{key:"handleDownArrowKey",value:function(e){if(e.preventDefault(),this.menuOpen||(this.forceShowAll=this.options.minLength<1,(this.forceShowAll||this.input.value.length>=this.options.minLength)&&this.filterPrep(e)),this.menuOpen&&!this.filtering){var t=this.currentSelectedIndex;"number"!=typeof t||t<0?this.setOptionFocus(e,0):this.setOptionFocus(e,t+1)}}},{key:"handleUpArrowKey",value:function(e){e.preventDefault(),!this.disabled&&this.menuOpen&&"number"==typeof this.currentSelectedIndex&&this.setOptionFocus(e,this.currentSelectedIndex-1)}},{key:"handleKeyDownDefault",value:function(t){var i=t.target===this.input;if(32===t.keyCode&&!i)return t.preventDefault(),this.handleEnterKey(t);if(!this.disabled){var s=this.selected&&this.selected.length;if(this.options.deleteOnBackspace&&""===this.input.value&&8===t.keyCode&&s&&i&&this.multiple)this.removeEntryFromSelected(this.selected[s-1]);else{var n=(0,e.default)(t.keyCode),l=!i&&n;l&&this.input.focus(),(l||i&&n)&&this.filterPrep(t)}}}},{key:"prepKeyDown",value:function(e){switch(e.keyCode){case 13:this.handleEnterKey(e);break;case 27:this.handleComponentBlur(e,!0);break;case 38:this.handleUpArrowKey(e);break;case 40:this.handleDownArrowKey(e);break;default:this.handleKeyDownDefault(e)}}},{key:"cancelPolling",value:function(){this.pollingTimer&&clearTimeout(this.pollingTimer)}},{key:"startPolling",value:function(){var e=this;this.filtering||this.input.value===this.inputPollingValue||this.filterPrep({}),this.pollingTimer=setTimeout(function(){e.startPolling()},200)}},{key:"bindEvents",value:function(){var e=this;this.wrapper.addEventListener("focusout",function(t){e.handleComponentBlur(t,!1)}),this.wrapper.addEventListener("focusin",function(t){e.list.contains(t.target)||(e.currentSelectedIndex=-1)}),this.wrapper.addEventListener("keydown",function(t){e.prepKeyDown(t)}),this.wrapper.addEventListener("click",function(t){if(t.target!==e.wrapper){if(e.isSelectedElem(t.target)){var s=t.target[i.SELECTED_OPTION_PROP];e.removeEntryFromSelected(s)}}else e.input.focus()});var s="".concat(this.cssNameSpace,"__wrapper--focused focused focus"),n="".concat(this.cssNameSpace,"__input--focused focused focus");this.input.addEventListener("blur",function(){(0,i.removeClass)(e.wrapper,s),(0,i.removeClass)(e.input,n),e.cancelPolling()}),this.input.addEventListener("input",function(t){e.filterPrep(t)}),this.input.addEventListener("click",function(t){!e.menuOpen&&e.input.value.length>=e.options.minLength&&e.filterPrep(t,!0)}),this.input.addEventListener("focusin",function(){(0,i.addClass)(e.wrapper,s),(0,i.addClass)(e.input,n),e.startPolling(),e.disabled||e.menuOpen||e.filterPrep(event,!0)}),this.showAll&&this.showAll.addEventListener("click",function(t){e.filterPrepShowAll(t)}),this.list.addEventListener("mouseenter",function(t){e.resetOptionAttributes()}),this.list.addEventListener("click",function(t){if(t.target!==e.list){var i=e.list.childNodes;if(i.length){var s=[].indexOf.call(i,t.target);e.handleOptionSelect(t,s)}}}),this.autoGrow&&(this.inputAutoWidth=new t.default(this.input))}},{key:"prepListSourceCheckboxes",value:function(){this.multiple=!0,this.source=[];for(var e=this.element.querySelectorAll('input[type="checkbox"]'),t=0,s=e.length;t<s;t+=1){var n=e[t];if(n.value){var l={element:n,value:n.value},r=n.closest("label");!r&&n.id&&(r=document.querySelector('[for="'+n.id+'"]')),r&&(l.label=r.textContent),l.label||(l.label=l.value),l[i.CLEANED_LABEL_PROP]=(0,i.cleanString)(l.label),this.source.push(l),n.checked&&this.selected.push(l)}}}},{key:"prepListSourceDdl",value:function(){this.multiple=this.element.multiple,this.source=[];for(var e=this.element.querySelectorAll("option"),t=0,s=e.length;t<s;t+=1){var n=e[t];if(n.value){var l={element:n,value:n.value,label:n.textContent};l[i.CLEANED_LABEL_PROP]=(0,i.cleanString)(l.label),this.source.push(l),n.selected&&this.selected.push(l)}}}},{key:"prepSelectedFromArray",value:function(e){var t=this.elementIsInput&&this.element.value;if(t&&e&&e.length)for(var i=this.options.multiple,s=this.options.multipleSeparator,n=i?t.split(s):[t],l=0,r=n.length;l<r;l+=1){var a=n[l],o=this.indexOfQueryIn;if(!(o(this.selected,a,"value")>-1)){var c=o(e,a,"value");c>-1&&this.selected.push(e[c])}}}},{key:"prepListSourceArray",value:function(){var e=this.options.sourceMapping;this.source=(0,i.processSourceArray)(this.source,e),this.prepSelectedFromArray(this.source)}},{key:"prepListSourceAsync",value:function(){this.elementIsInput&&this.element.value&&this.handleAsync(this.element.value,!0)}},{key:"prepListSourceFunction",value:function(){var e=this;this.elementIsInput&&this.element.value&&this.source.call(void 0,this.element.value,function(t){e.prepSelectedFromArray((0,i.processSourceArray)(t,e.options.sourceMapping)),e.setInputStartingStates(!1)})}},{key:"prepListSource",value:function(){return"function"==typeof this.source?this.prepListSourceFunction():"string"==typeof this.source&&this.source.length?this.prepListSourceAsync():Array.isArray(this.source)&&this.source.length?this.prepListSourceArray():this.elementIsSelect?this.prepListSourceDdl():void(this.element.querySelector('input[type="checkbox"]')&&this.prepListSourceCheckboxes())}},{key:"setInputStartingStates",value:function(){if(!(arguments.length>0&&void 0!==arguments[0])||arguments[0]){if(this.ids.ELEMENT){var e=document.querySelector('[for="'+this.ids.ELEMENT+'"]');e&&(e.ariaAutocompleteOriginalFor=this.ids.ELEMENT,e.setAttribute("for",this.ids.INPUT))}var t=this.element.getAttribute("aria-describedby");t&&this.input.setAttribute("aria-describedby",t);var i=this.element.getAttribute("aria-labelledby");i&&this.input.setAttribute("aria-labelledby",i)}this.selected.length&&(this.multiple?this.buildMultiSelected():this.setInputValue(this.selected[0].label||"",!0)),this.setInputDescription(),this.element.disabled&&this.disable()}},{key:"setHtml",value:function(){var e=this.options,t=this.cssNameSpace,i=e.wrapperClassName?" ".concat(e.wrapperClassName):"",s=['<div id="'.concat(this.ids.WRAPPER,'" class="').concat(t,"__wrapper").concat(i,'">')],n=e.name?" ".concat(e.name):"",l=e.inputClassName?" ".concat(e.inputClassName):"",r=e.placeholder?' placeholder="'.concat(e.placeholder,'" aria-placeholder="').concat(e.placeholder,'"'):"";s.push('<input type="text" autocomplete="off" aria-expanded="false" aria-autocomplete="list" '+'role="combobox" id="'.concat(this.ids.INPUT,'" aria-owns="').concat(this.ids.LIST,'" ')+'class="'.concat(t,"__input").concat(l,'"').concat(n).concat(r," />")),e.showAllControl&&s.push('<span role="button" aria-label="'.concat(e.srShowAllText,'" class="').concat(t,'__show-all" ')+'tabindex="0" id="'.concat(this.ids.BUTTON,'" aria-expanded="false"></span>'));var a=e.srListLabelText,o=e.listClassName?" ".concat(e.listClassName):"",c=a?' aria-label="'.concat(a,'"'):"";s.push('<ul id="'.concat(this.ids.LIST,'" class="').concat(t,"__list").concat(o,'" role="listbox" ')+'hidden="hidden"'.concat(c,"></ul>")),s.push('<span class="sr-only '.concat(t,"__sr-only ").concat(t,'__sr-assistance" ')+'id="'.concat(this.ids.SR_ASSISTANCE,'">').concat(e.srAssistiveText,"</span>")),s.push('<span class="sr-only '.concat(t,"__sr-only ").concat(t,'__sr-announcements" ')+'id="'.concat(this.ids.SR_ANNOUNCEMENTS,'" aria-live="polite" aria-atomic="true"></span>')),s.push("</div>"),this.element.insertAdjacentHTML("afterend",s.join(""))}},{key:"generateApi",value:function(){var e=this;this.api={open:function(){return e.show.call(e)},close:function(){return e.hide.call(e)},filter:function(t){return e.filter.call(t)}};for(var t=["options","destroy","enable","disable","input","wrapper","list","selected"],i=function(i,s){e.api[t[i]]="function"==typeof e[t[i]]?function(){return e[t[i]].call(e)}:e[t[i]]},s=0,n=t.length;s<n;s+=1)i(s);this.element.ariaAutocomplete=this.api}},{key:"destroy",value:function(){var e=document.querySelector('[for="'+this.ids.INPUT+'"]');for(var t in e&&e.ariaAutocompleteOriginalFor&&(e.setAttribute("for",e.ariaAutocompleteOriginalFor),delete e.ariaAutocompleteOriginalFor),this.documentClickBound&&document.removeEventListener("click",this.documentClick),this.autoGrow&&this.inputAutoWidth&&this.inputAutoWidth.destroy(),this.element.parentNode.removeChild(this.wrapper),delete this.element.ariaAutocomplete,this.show(this.element),this)this.hasOwnProperty(t)&&(this[t]=null)}},{key:"init",value:function(e,t){c+=1,this.ids={},this.ids.ELEMENT=e.id,this.ids.PREFIX="".concat(e.id||"","aria-autocomplete-").concat(c),this.ids.LIST="".concat(this.ids.PREFIX,"-list"),this.ids.INPUT="".concat(this.ids.PREFIX,"-input"),this.ids.BUTTON="".concat(this.ids.PREFIX,"-button"),this.ids.OPTION="".concat(this.ids.PREFIX,"-option"),this.ids.WRAPPER="".concat(this.ids.PREFIX,"-wrapper"),this.ids.OPTION_SELECTED="".concat(this.ids.OPTION,"-selected"),this.ids.SR_ASSISTANCE="".concat(this.ids.PREFIX,"-sr-assistance"),this.ids.SR_ANNOUNCEMENTS="".concat(this.ids.PREFIX,"-sr-announcements"),this.selected=[],this.element=e,this.elementIsInput="INPUT"===e.nodeName,this.elementIsSelect="SELECT"===e.nodeName,this.options=(0,i.mergeObjects)(s.default,t),this.source=this.options.source,this.multiple=this.options.multiple,this.autoGrow=this.options.autoGrow,this.cssNameSpace=this.options.cssNameSpace,this.documentClick=this.handleComponentBlur.bind(this),this.setHtml(),this.list=document.getElementById(this.ids.LIST),this.input=document.getElementById(this.ids.INPUT),this.wrapper=document.getElementById(this.ids.WRAPPER),this.showAll=document.getElementById(this.ids.BUTTON),this.srAnnouncements=document.getElementById(this.ids.SR_ANNOUNCEMENTS),this.prepListSource();var n="";this.options.showAllControl&&(n+=" ".concat(this.cssNameSpace,"__wrapper--show-all")),this.autoGrow&&(n+=" ".concat(this.cssNameSpace,"__wrapper--autogrow")),this.multiple&&(n+=" ".concat(this.cssNameSpace,"__wrapper--multiple")),n&&(0,i.addClass)(this.wrapper,n),this.hide(this.list),this.hide(this.element),this.generateApi(),this.setInputStartingStates(),this.bindEvents(),this.triggerOptionCallback("onReady",[this.wrapper])}}]),n}();window.AriaAutocomplete=function(e,t){return new h(e,t).api};var u=function(e,t){return new h(e,t).api};exports.default=u; | ||
},{"is-printable-keycode":"diFG","input-autowidth":"AEQi","./autocomplete-helpers":"MBeS","./default-options":"vPu2","element-closest":"GbHv"}]},{},["c8cM"], null) |
{ | ||
"name": "aria-autocomplete", | ||
"version": "1.0.0-beta.2", | ||
"description": "Accessible, extensible, dependency-free JavaScript autocomplete with multi-select", | ||
"main": "src/aria-autocomplete.js", | ||
"version": "1.0.0", | ||
"description": "Accessible, extensible, JavaScript autocomplete with multi-select", | ||
"main": "dist/aria-autocomplete.min.js", | ||
"style": "dist/aria-autocomplete.min.css", | ||
"browser": "dist/aria-autocomplete.min.js", | ||
"scripts": { | ||
"build": "parcel build src/aria-autocomplete.js --out-file aria-autocomplete.min.js --no-source-maps", | ||
"dev": "NODE_ENV=development parcel build src/aria-autocomplete.js --out-file aria-autocomplete.js --no-minify", | ||
"build": "parcel build src/aria-autocomplete.js --out-file aria-autocomplete.min.js", | ||
"css": "NODE_ENV=development parcel build src/aria-autocomplete.less --out-file aria-autocomplete.css --no-minify" | ||
"css": "NODE_ENV=development parcel build src/aria-autocomplete.less --out-file aria-autocomplete.min.css --no-source-maps" | ||
}, | ||
@@ -40,3 +42,8 @@ "repository": { | ||
"parcel-bundler": "^1.12.4" | ||
}, | ||
"dependencies": { | ||
"element-closest": "^3.0.2", | ||
"input-autowidth": "^1.0.2", | ||
"is-printable-keycode": "^1.0.1" | ||
} | ||
} |
@@ -6,3 +6,3 @@ # Aria Autocomplete | ||
Accessible, extensible, dependency-free autocomplete with multi-select. | ||
Accessible, extensible, plain JavaScript autocomplete with multi-select. | ||
@@ -29,3 +29,3 @@ I've used a lot of autocomplete plugins, but the combination of **accessibility**, **performance**, and **functionality** that I needed wasn't out there. So I've written this from the ground up for that purpose, building on the [brilliant accessibility of GOV.UK's accessible-autocomplete](https://accessibility.blog.gov.uk/2018/05/15/what-we-learned-from-getting-our-autocomplete-tested-for-accessibility/) - with more functionality, a smaller file size, and (in my testing) better performance. | ||
``` | ||
npm install --save aria-autocomplete | ||
npm install aria-autocomplete | ||
``` | ||
@@ -53,3 +53,3 @@ | ||
I would encourage you to style it yourself to match your own site or application's design. An example stylesheet is included in the repository however at [dist/aria-autocomplete.css](/mynamesleon/aria-autocomplete/blob/master/dist/aria-autocomplete.css) which you can copy into your project and import into the browser: | ||
I would encourage you to style it yourself to match your own site or application's design. An example stylesheet is included in the repository however at [dist/aria-autocomplete.min.css](/mynamesleon/aria-autocomplete/blob/master/dist/aria-autocomplete.css) which you can copy into your project and import into the browser: | ||
@@ -62,5 +62,5 @@ ```html | ||
I wrote this from the ground up partly because I needed an autocomplete with better performance than others I'd tried. I've optimised the JavaScript where I can, but it's the actual list _rendering_ that's a hit to performance. In my testing, modern browsers can render huge lists (1000+ items) just fine (on my laptop, averaging 40ms in Chrome, and under 20ms in Firefox). | ||
I wrote this from the ground up largely because I needed an autocomplete with better performance than others I'd tried. I've optimised the JavaScript where I can, but in some browsers the list _rendering_ will still be a hit to performance. In my testing, modern browsers can render huge lists (1000+ items) just fine (on my laptop, averaging 40ms in Chrome, and under 20ms in Firefox). | ||
As we all know however, Internet Explorer _sucks_. If you need to support IE11 (or earlier), I suggest either setting the `maxResults` option to 200 or less, or using a sensible combination for the `delay` and `minLength` options. Testing on my laptop, the list rendering in IE11 would take on average: 55ms for 250 items, 300ms for 650 items, and over 600ms for 1000 items. | ||
As we all know however, Internet Explorer _sucks_. If you need to support Internet Explorer, I suggest using a sensible combination for the `delay`, `maxResults`, and possibly `minLength` options, to prevent the browser from freezing as your users type, and to reduce the rendering impact. Testing on my laptop, the list rendering in IE11 would take on average: 55ms for 250 items, 300ms for 650 items, and over 600ms for 1000 items. | ||
@@ -67,0 +67,0 @@ ## API Documentation |
@@ -1,3 +0,3 @@ | ||
export const CLEANED_LABEL = '_ariaAutocompleteCleanedLabel'; | ||
export const SELECTED_OPTION = '_ariaAutocompleteSelectedOption'; | ||
export const CLEANED_LABEL_PROP = '_ariaAutocompleteCleanedLabel'; | ||
export const SELECTED_OPTION_PROP = '_ariaAutocompleteSelectedOption'; | ||
@@ -12,12 +12,12 @@ /** | ||
const getClass = elem => | ||
(elem.getAttribute && elem.getAttribute('class')) || ''; | ||
/** | ||
* @description check if element has class - support pre `classList` | ||
* @param {Element} element - element to check class on | ||
* @param {Element} elem | ||
* @param {String} className | ||
* @returns {Boolean} | ||
*/ | ||
export function hasClass(element, className) { | ||
const e = element; | ||
const cur = trimString(e.getAttribute && e.getAttribute('class')); | ||
return ` ${cur} `.indexOf(` ${className} `) > -1; | ||
export function hasClass(elem, className) { | ||
return ` ${getClass(elem)} `.indexOf(` ${className} `) > -1; | ||
} | ||
@@ -27,19 +27,17 @@ | ||
* @description add class(es) to element - support pre `classList` | ||
* @param {Element} element - element to add class(es) to | ||
* @param {Element} elem | ||
* @param {String} classes - space delimitted class(es) to add | ||
*/ | ||
export function addClass(element, classes) { | ||
const currentValue = trimString( | ||
element.getAttribute && element.getAttribute('class') | ||
); | ||
const current = ' ' + currentValue + ' '; | ||
export function addClass(elem, classes) { | ||
const curValue = getClass(elem); | ||
const cur = ` ${curValue} `; | ||
let finalValue = ''; | ||
for (let i = 0, cs = classes.split(' '), l = cs.length; i < l; i += 1) { | ||
if (cs[i] !== '' && current.indexOf(' ' + cs[i] + ' ') === -1) { | ||
if (cs[i] !== '' && cur.indexOf(` ${cs[i]} `) === -1) { | ||
finalValue += ' ' + cs[i]; | ||
} | ||
} | ||
if (currentValue !== (finalValue = trimString(currentValue + finalValue))) { | ||
element.setAttribute('class', finalValue); | ||
if (curValue !== (finalValue = (curValue + finalValue).trim())) { | ||
elem.setAttribute('class', finalValue); | ||
} | ||
@@ -50,16 +48,14 @@ } | ||
* @description remove class(es) from element - support pre `classList` | ||
* @param {Element} element - element to add class(es) to | ||
* @param {Element} elem | ||
* @param {String} classes - space delimitted class(es) to remove | ||
*/ | ||
export function removeClass(element, classes) { | ||
const currentValue = trimString( | ||
element.getAttribute && element.getAttribute('class') | ||
); | ||
let finalValue = ' ' + currentValue + ' '; | ||
export function removeClass(elem, classes) { | ||
const curValue = getClass(elem); | ||
let finalValue = ` ${curValue} `; | ||
for (let i = 0, cs = classes.split(' '), l = cs.length; i < l; i += 1) { | ||
finalValue = finalValue.replace(' ' + cs[i] + ' ', ' '); | ||
finalValue = finalValue.replace(` ${cs[i]} `, ' '); | ||
} | ||
if (currentValue !== (finalValue = trimString(finalValue))) { | ||
element.setAttribute('class', finalValue); | ||
if (curValue !== (finalValue = finalValue.trim())) { | ||
elem.setAttribute('class', finalValue); | ||
} | ||
@@ -93,19 +89,2 @@ } | ||
/** | ||
* @description check if keycode is for a printable/width-affecting character | ||
* @param {Number} keyCode | ||
* @returns {Boolean} | ||
*/ | ||
export function isPrintableKey(keyCode) { | ||
return ( | ||
(keyCode >= 48 && keyCode <= 57) || // 0-9 | ||
(keyCode >= 65 && keyCode <= 90) || // a-z | ||
(keyCode >= 96 && keyCode <= 111) || // numpad 0-9, numeric operators | ||
(keyCode >= 186 && keyCode <= 222) || // semicolon, equal, comma, dash, etc. | ||
keyCode === 32 || // space | ||
keyCode === 8 || // backspace | ||
keyCode === 46 // delete | ||
); | ||
} | ||
/** | ||
* @description merge objects together to generate a new one | ||
@@ -205,3 +184,3 @@ * @param {Object} args - objects to merge together | ||
if (setCleanedLabel !== false) { | ||
result[CLEANED_LABEL] = cleanString(result.label); | ||
result[CLEANED_LABEL_PROP] = cleanString(result.label); | ||
} | ||
@@ -213,53 +192,3 @@ toReturn.push(result); | ||
const DIV = document.createElement('div'); | ||
/** | ||
* @description convert HTML string into an element | ||
* @param {String} html | ||
* @returns {Element} | ||
*/ | ||
export function htmlToElement(html) { | ||
DIV.innerHTML = trimString(html); | ||
return DIV.firstChild; | ||
} | ||
/** | ||
* @description set styles on an element | ||
* @param {Element} element | ||
* @param {Object} s | ||
*/ | ||
export function setCss(element, s) { | ||
if (!element) { | ||
return; | ||
} | ||
for (let i in s) { | ||
const style = typeof s[i] === 'number' ? s[i] + 'px' : s[i]; | ||
element.style[i] = style + ''; // force to be a string | ||
} | ||
} | ||
/** | ||
* @description transfer styles from one Element to another | ||
* @param {Element} from | ||
* @param {Element} to | ||
* @param {Array=} properties | ||
*/ | ||
export function transferStyles(from, to, properties) { | ||
if (!from || !to) { | ||
return; | ||
} | ||
const fromStyles = getComputedStyle(from); | ||
let styles = {}; | ||
if (properties && properties.length) { | ||
for (let i = 0, l = properties.length; i < l; i += 1) { | ||
styles[properties[i]] = fromStyles[properties[i]]; | ||
} | ||
} else { | ||
styles = fromStyles; | ||
} | ||
setCss(to, styles); | ||
} | ||
/** | ||
* @description search String or Array for another string - partial match | ||
@@ -272,3 +201,3 @@ * @param {String|Array} prop | ||
if (typeof prop === 'string') { | ||
if (name !== CLEANED_LABEL) { | ||
if (name !== CLEANED_LABEL_PROP) { | ||
prop = cleanString(prop, false); | ||
@@ -330,3 +259,3 @@ } | ||
export function removeDuplicatesAndLabel(arr) { | ||
// remove `label` (we will be using CLEANED_LABEL) and duplicates from props array | ||
// remove `label` (we will be using CLEANED_LABEL_PROP) and duplicates from props array | ||
const result = []; | ||
@@ -333,0 +262,0 @@ for (let i = 0, l = arr.length; i < l; i += 1) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
282515
3
11
2071
1
+ Addedelement-closest@^3.0.2
+ Addedinput-autowidth@^1.0.2
+ Addedis-printable-keycode@^1.0.1
+ Addedelement-closest@3.0.2(transitive)
+ Addedinput-autowidth@1.0.3(transitive)
+ Addedis-printable-keycode@1.0.3(transitive)