diff --git a/dist/combobo.js b/dist/combobo.js index dd37cc3..5ffd18c 100644 --- a/dist/combobo.js +++ b/dist/combobo.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Combobo=e():t.Combobo=e()}("undefined"!=typeof self?self:this,function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:i})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e,n){"use strict";t.exports=s;var i=n(3),r=n(4),o=Array.prototype;function s(t){if(!(this instanceof s))return new s(t);var e,n=r(t.className).split(/\s+/);for(this._elem=t,this.length=0,e=0;e=0||o.push.call(this,t);return this._elem.className=this.toString(),this},s.prototype.remove=function(){var t,e,n;for(n=0;n=0},s.prototype.toggle=function(t,e){return t+="",!0===e?this.add(t):!1===e?this.remove(t):this[this.contains(t)?"remove":"add"](t)},s.prototype.toString=function(){return o.join.call(this," ")}},function(t,e,n){"use strict";t.exports=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8;var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";var i=n+"0123456789";var r=n.charAt(Math.floor(Math.random()*n.length));for(var o=1;o=2?"":t.config.selectionValue(t.selected)),t.config.selectOnly||t.input.select()}),this.toggleButton&&this.toggleButton.addEventListener("click",function(e){e.stopPropagation(),t.isOpen?t.closeList():t.openList()}),document.addEventListener("click",function(e){!(0,p.default)(e.target,[t.input,t.list],!0)&&t.isOpen&&t.closeList()})),this.optionEvents(),this.initKeys()}},{key:"getOptIndex",value:function(){return this.currentOption&&this.currentOpts.indexOf(this.currentOption)}},{key:"optionEvents",value:function(){var t=this;this.cachedOpts.forEach(function(e){t.optionsWithEventHandlers.has(e.id)||t.selected.includes(e)||(e.addEventListener("click",function(){t.goTo(t.currentOpts.indexOf(e)).select()}),e.addEventListener("mouseover",function(){var n=t.currentOption;n&&(0,o.default)(n).remove(t.config.activeClass),(0,o.default)(e).add(t.config.activeClass),t.isHovering=!0}),e.addEventListener("mouseout",function(){(0,o.default)(e).remove(t.config.activeClass),t.isHovering=!1}),t.optionsWithEventHandlers.add(e.id))})}},{key:"openList",value:function(){(0,o.default)(this.list).add(this.config.openClass),this.input.setAttribute("aria-expanded","true"),this.isOpen||this.announceCount(),this.isOpen=!0,this.emit("list:open");var t=(0,l.default)(this.list);if(!t.visible){var e="bottom"===t.position?0-(window.innerHeight-(this.input.clientHeight+this.list.clientHeight)):0;(0,c.default)({element:this.input,offset:e,bezier:[.19,1,.22,1],duration:100})}return this}},{key:"closeList",value:function(t,e){return(0,o.default)(this.list).remove(this.config.openClass),this.input.setAttribute("aria-expanded","false"),this.isOpen=!1,t&&this.input.focus(),!this.multiselect&&this.selected.length&&(this.input.value=this.config.selectionValue(this.selected)),e&&!this.config.selectOnly&&this.input.select(),this.emit("list:close"),this}},{key:"getSearchString",value:function(t){var e=this;return t?("number"==typeof this.searchTimeout&&window.clearTimeout(this.searchTimeout),this.searchTimeout=window.setTimeout(function(){e.searchString=""},this.config.selectSearchTimeout),this.searchString=this.searchString?this.searchString+t:t,this.searchString.toLowerCase()):this.searchString}},{key:"initKeys",value:function(){var t=this;if(!this.optionsWithKeyEventHandlers.has(this.input)){this.optionsWithKeyEventHandlers.add(this.input),h.default.down(this.input,[{keys:["up","down"],callback:function(e,n){if(t.isOpen)return-1===t.currentOpts.indexOf(t.currentOption)?t.goTo(0,!0):t.goTo("down"===n?"next":"prev",!0);var i=t.selected.length?t.currentOpts.indexOf(t.selected[t.selected.length-1]):0;t.goTo(i,!0).openList()},preventDefault:!0},{keys:["enter"],callback:function(){t.isOpen?t.select():t.openList()}},{keys:["escape"],callback:function(e){t.isOpen&&(e.stopPropagation(),t.closeList(!0,!0))}},{keys:["backspace"],callback:function(){t.selected.length>=2&&(t.input.value="")}}]),h.default.down(window,function(e){" "===e.key&&e.target===t.input&&(t.config.selectOnly&&(e.preventDefault(),e.stopPropagation()),t.isOpen||t.openList())}),h.default.down(this.input,function(e){var n=e.key,i=e.metaKey,r=e.ctrlKey,o=e.altKey;i||r||o||n&&[" ","tab","backspace"].includes(n.toLowerCase())&&t.isOpen&&(e.preventDefault(),e.stopPropagation(),t.select(),t.closeList())}),this.config.selectOnly&&(h.default.up(this.input,function(e){var n=e.key,i=e.altKey,r=e.ctrlKey,o=e.metaKey;if(new Array(26).fill(1).map(function(t,e){return String.fromCharCode("a".charCodeAt(0)+e)}).includes(n)&&" "!==n&&!i&&!r&&!o){e.preventDefault(),e.stopPropagation();var s=t.getSearchString(n);t.isOpen||t.openList();var u=t.searchIndex(s);u>-1&&t.goTo(u)}}),this.input.addEventListener("blur",function(){t.searchString="",t.selected.length&&(t.input.innerText=t.config.selectionValue(t.selected))}));var e=[9,13,27,16];h.default.up(this.input,function(n){if(t.autoFilter){var i=t.config.filter,r=t.cachedInputValue;e.indexOf(n.which)>-1||!i||"div"===t.input.tagName.toLowerCase()||(t.freshSelection?(t.clearFilters(),r&&r.trim()!==t.input.value.trim()&&(t.filter().openList(),t.freshSelection=!1)):t.filter().openList(),(0,g.default)(t.list,t.currentOpts,t.config.noResultsText))}})}}},{key:"searchIndex",value:function(t){var e=this.getOptIndex(),n=t.trim(),i=n[0],r=n===i.repeat(n.length)&&n.length>1,o=this.currentOpts.filter(function(t){return t.textContent.toLowerCase().startsWith(r?i:n)});if(0===o.length)return-1;if(1===o.length)return this.currentOpts.indexOf(o[0]);if(-1===e)return this.currentOpts.indexOf(o[0]);var s=o.indexOf(this.currentOption);return r&&o.length>1?this.currentOpts.indexOf(o[s+1]||o[0]):-1!==s&&s-1})||t||this.announceCount(),this}},{key:"announceCount",value:function(){var t=this.config.announcement&&this.config.announcement.count;return t&&this.liveRegion&&this.liveRegion.announce(t(this.currentOpts.length),500),this}},{key:"updateOpts",value:function(){var t=this,e=this.config.optionValue;return this.cachedOpts.forEach(function(n){n.style.display=-1===t.currentOpts.indexOf(n)?"none":"",n.innerHTML="string"==typeof e?(0,y.default)(n,"div"===t.input.tagName.toLowerCase()?t.getSearchString():t.input.value,e):e(n)}),this.updateGroups(),this}},{key:"updateGroups",value:function(){return this.groups.forEach(function(t){var e=t.options.filter(function(t){return""===t.style.display});t.element.style.display=e.length?"":"none"}),this}},{key:"select",value:function(){var t=this,e=this.currentOption;if(e){!this.config.multiselect&&this.selected.length&&(0,o.default)(this.selected[0]).remove(this.config.selectedClass);var n=this.selected.indexOf(e),i=n>-1;this.config.multiselect?i?this.selected.splice(n,1):this.selected.push(e):this.selected=this.config.allowEmpty&&i&&!this.config.selectOnly?[]:[e],this.cachedOpts.forEach(function(e){e.setAttribute("aria-selected",t.selected.indexOf(e)>-1?"true":"false")});var r=this.selected.length?this.config.selectionValue(this.selected):"";if(i?(e.classList.remove(this.config.selectedClass),this.emit("deselection",{text:r,option:e})):(e.classList.add(this.config.selectedClass),this.emit("selection",{text:r,option:e})),this.freshSelection=!0,this.config.selectOnly?(this.input.innerText=r,this.config.inputElm&&(this.config.inputElm.value=r)):this.input.value=r,this.cachedInputValue=r,this.filter(!0).clearFilters(),this.config.multiselect||(this.closeList(),this.config.selectOnly||this.input.select()),this.selectElm){var s=this.value(),u=!0,c=!1,a=void 0;try{for(var l,f=this.selectElm.options[Symbol.iterator]();!(u=(l=f.next()).done);u=!0){var h=l.value;this.config.multiselect?h.selected=-1!==s.indexOf(h.value):h.selected=h.value===s}}catch(t){c=!0,a=t}finally{try{!u&&f.return&&f.return()}finally{if(c)throw a}}}return this}}},{key:"reset",value:function(){var t=this;return this.clearFilters(),this.input.value="",this.updateOpts(),this.input.removeAttribute("aria-activedescendant"),this.input.removeAttribute("data-active-option"),this.currentOption=null,this.selected=[],this.cachedOpts.forEach(function(e){(0,o.default)(e).remove(t.config.selectedClass),(0,o.default)(e).remove(t.config.activeClass),e.setAttribute("aria-selected","false")}),this.searchString="",this}},{key:"goTo",value:function(t,e){var n=this;if("string"==typeof t){var i=this.getOptIndex();return this.goTo("next"===t?i+1:i-1,e)}var r=this.currentOpts[t],o=!1;if(!this.currentOpts[t])return 0===this.getOptIndex()&&(this.list.scrollTop=0),this;if(this.groups.length){var s=(0,v.default)(this.groups,r);o=s&&s!==this.currentGroup,this.currentGroup=s}return this.currentOption=r,this.pseudoFocus(o),this.currentOpts.forEach(function(t){t.classList.contains(n.config.activeClass)&&!(0,a.default)(n.list,t)&&(0,c.default)(t)}),this}},{key:"pseudoFocus",value:function(t){var e=this.currentOption,n=this.config.activeClass,i=this.input.getAttribute("data-active-option"),r=i&&document.getElementById(i);return r&&n&&(0,o.default)(r).remove(n),e&&(this.input.setAttribute("data-active-option",e.id),n&&(0,o.default)(e).add(n),this.liveRegion&&(0,O.default)(e,this.config,this.liveRegion.announce.bind(this.liveRegion),t,this.currentGroup&&this.currentGroup.element),this.input.setAttribute("aria-activedescendant",e.id),this.currentOption=e,this.emit("change")),this}},{key:"setOptions",value:function(t){return"object"===(void 0===t?"undefined":i(t))&&this.config.list.append(t),this.cachedOpts.push(t),-1===this.currentOpts.indexOf(t)&&this.currentOpts.push(t),this}},{key:"setCurrentOptions",value:function(){return this.currentOption=this.currentOpts[0],this}},{key:"updateSelectedOptions",value:function(){var t=this,e=document.getElementById(this.config.list.id),n=this.selected;for(this.emptyDropdownList();e.hasChildNodes();)e.removeChild(e.firstChild);return n.length>0&&n.forEach(function(e){t.setOptions(e)}),this}},{key:"emptyDropdownList",value:function(){return this.currentOpts=[],this.cachedOpts=[],this.optionsWithEventHandlers.clear(),this}},{key:"setNoResultFound",value:function(){(0,g.default)(this.list,this.currentOpts,this.config.noResultsText)}},{key:"value",value:function(){var t=[];return this.selected.forEach(function(e){e.hasAttribute("data-value")?t.push(e.dataset.value):t.push(e.innerText)}),this.config.multiselect?t:t&&t.length?t[0]:null}},{key:"transformSelectElement",value:function(t){var e=this,n=document.createElement("div");n.className=this.config.wrapClass,n.id=t.id+"-combobo",t.multiple&&n.classList.add("multiselect");var i=this.config.selectOnly?"div":"input",r=document.createElement(i);r.setAttribute("tabindex","0"),r.type="text",r.className=this.config.inputClass,r.id=t.id+"-input",n.appendChild(r);var o=document.createElement("span");o.setAttribute("aria-hidden","true"),o.className=this.config.toggleButtonClass,n.appendChild(o);var s=document.createElement("div");s.className=this.config.listClass,n.appendChild(s);var u=!1;return Array.from(t.children).forEach(function(t){if("optgroup"===t.tagName.toLowerCase()){u=!0;var n=document.createElement("div");n.className=e.config.optgroupClass,n.setAttribute("role","group");var i=(0,x.default)();n.setAttribute("aria-labelledby",i);var r=document.createElement("div");r.className=e.config.optgroupLabelClass,r.id=i,r.textContent=t.label,n.appendChild(r),Array.from(t.children).forEach(function(t){var i={text:t.textContent,value:t.value,selected:t.hasAttribute("selected"),disabled:t.hasAttribute("disabled")};n.appendChild(e.createOptionElement(i.text,i.value,i.selected,i.disabled))}),s.appendChild(n)}else{var o={text:t.textContent,value:t.value,selected:t.hasAttribute("selected"),disabled:t.hasAttribute("disabled")};s.appendChild(e.createOptionElement(o.text,o.value,o.selected,o.disabled))}}),u&&n.classList.add("has-groups"),{comboElement:n,input:r}}},{key:"createOptionElement",value:function(t,e,n,i){var r=document.createElement("div");return r.className=this.config.optionsClass,r.textContent=t,r.dataset.value=e,n&&r.classList.add(this.config.selectedClass),i&&r.classList.add("disabled"),r}},{key:"createOptgroupElement",value:function(t){var e=document.createElement("div");e.className=this.config.optgroupClass,e.setAttribute("role","group");var n=(0,x.default)();e.setAttribute("aria-labelledby",n);var i=document.createElement("div");return i.className=this.config.optgroupLabelClass,i.id=n,i.textContent=t,e.appendChild(i),e}}]),t}()},function(t,e){t.exports=function(t,e){if(t.indexOf)return t.indexOf(e);for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:100,n=0,i=void 0,l=void 0;if((0,u.isElement)(t))i=o.default.apply(void 0,a),l=r;else{if(!(0,u.isObject)(t))throw new TypeError("The first argument must be HTMLElement or Object.");if(!(0,u.isElement)(t.element))throw new TypeError("`element` must be HTMLElement.");n=(0,u.isNumeric)(t.offset)?t.offset:0,i=(0,u.isArray)(t.bezier)&&4===t.bezier.length?o.default.apply(void 0,function(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e=0},e.isFunction=function(t){return null!=t&&"[object Function]"===i(t)},e.isElement=function(t){return"object"===o(window.HTMLElement)?t instanceof window.HTMLElement:!!t&&"object"===(void 0===t?"undefined":o(t))&&null!==t&&1===t.nodeType&&"string"==typeof t.nodeName}},function(t,e,n){"use strict";function i(t,e){return window.getComputedStyle(t,null).getPropertyValue(e)}function r(t){if(1===t.nodeType)return o.test(function(t){return i(t,"overflow")+i(t,"overflow-y")}(t))&&t.scrollHeight>t.clientHeight}Object.defineProperty(e,"__esModule",{value:!0});var o=/(auto|scroll)/;e.default=function(t){for(var e=function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=e.parentNode;return null===i||"HTML"===i.nodeName?n:t(i,n.concat(i))}(t),n=document.body,i=0,o=e.length;i0?n=u:e=u}while(Math.abs(s)>l&&++c=.001?c(e,l,t,n):0===f?l:u(e,i,i+p,t,n)}if(!(0<=t&&t<=1&&0<=n&&n<=1))throw new Error("bezier x values must be in [0, 1] range");var a=d?new Float32Array(h):new Array(h);if(t!==e||n!==i)for(var l=0;l1)for(var n=1;no)&&!(r+n-ie,o=!i&&!r,s={visible:o};return o||(s.position=i?"top":"bottom"),s}},function(t,e,n){"use strict";var i,r=n(11),o=(i=r)&&i.__esModule?i:{default:i};t.exports={contains:function(t,e){return e.filter(function(e){return(0,o.default)(e).toLowerCase().indexOf(t.toLowerCase())>-1})},equals:function(t,e){return e.filter(function(e){return(0,o.default)(e).toLowerCase()===t.toLowerCase()})},"starts-with":function(t,e){return e.filter(function(e){return 0===(0,o.default)(e).toLowerCase().indexOf(t.toLowerCase())})}}},function(t,e,n){"use strict";t.exports=function(t){return t.getAttribute("data-value")||t.innerText}},function(t,e,n){"use strict";var i,r=n(13),o=(i=r)&&i.__esModule?i:{default:i};e.attach=function(t,e,n){if("function"==typeof n)return e.addEventListener(t,n);n&&n.length&&e.addEventListener(t,function(t){var e=o.default[t.which];n.forEach(function(n){n.keys.indexOf(e)>-1&&(n.preventDefault&&t.preventDefault(),n.callback(t,e))})})},e.up=function(t,n){return e.attach("keyup",t,n)},e.down=function(t,n){return e.attach("keydown",t,n)},e.press=function(t,n){return e.attach("keypress",t,n)}},function(t,e,n){"use strict";t.exports={8:"backspace",9:"tab",13:"enter",27:"escape",32:"space",37:"left",38:"up",39:"right",40:"down"}},function(t,e,n){"use strict";t.exports=function(t,e,n){if(e=e.length?e:[e],n&&e.indexOf(t)>-1)return!0;for(var i=t.parentNode;i&&"HTML"!==i.tagName;){if(e.indexOf(i)>-1)return!0;i=i.parentNode}return!1}},function(t,e,n){"use strict";var i,r=n(16),o=(i=r)&&i.__esModule?i:{default:i};t.exports=function(t,e,n){return n=n||document,"string"==typeof t?e?o.default.all(t,n):(0,o.default)(t,n):t}},function(t,e,n){"use strict";(t.exports=function(t,e){return(e=e||document).querySelector(t)}).all=function(t,e){return e=e||document,Array.prototype.slice.call(e.querySelectorAll(t))}},function(t,e,n){"use strict";t.exports=function(t,e){var n=t.filter(function(t){return t.options.indexOf(e)>-1});return n.length&&n[0]}},function(t,e,n){"use strict";var i,r=n(0),o=(i=r)&&i.__esModule?i:{default:i};t.exports=function(t,e,n){var i=t.querySelector(".combobo-no-results");!n||e.length||i?i&&e.length&&t.removeChild(i):(i=document.createElement("div"),(0,o.default)(i).add("combobo-no-results"),i.innerHTML=n,t.appendChild(i))}},function(t,e,n){"use strict";var i,r=n(1),o=(i=r)&&i.__esModule?i:{default:i};t.exports=function(t,e,n){e.id=e.id||(0,o.default)(),t.setAttribute("role","combobox"),e.setAttribute("role","listbox"),t.setAttribute("aria-controls",e.id),t.setAttribute("aria-autocomplete","list"),t.setAttribute("aria-expanded","false"),n.forEach(function(t){t.setAttribute("role","option"),t.id=t.id||(0,o.default)()})}},function(t,e,n){"use strict";t.exports=function(t,e,n){e=e||"";var i=t.innerText,r=i.toLowerCase().indexOf(e.toLowerCase()),o=e.length;return e&&r>=0?i.substring(0,r)+''+i.substr(r,o)+""+i.substring(r+o):i}},function(t,e,n){"use strict";var i,r=n(22),o=(i=r)&&i.__esModule?i:{default:i};var s={select:"select.combobo",input:".combobox",list:".listbox",toggleButton:".trigger",options:".option",groups:null,wrapClass:"combo-wrap",inputClass:"combobox",listClass:"listbox",toggleButtonClass:"trigger",toggleButtonIcon:null,optgroupClass:"optgroup",optgroupLabelClass:"optgroup-label",optionsClass:"option",openClass:"open",activeClass:"active",selectedClass:"selected",useLiveRegion:!0,allowEmpty:!0,multiselect:!1,noResultsText:null,selectionValue:function(t){return t.map(function(t){return t.innerText.trim()}).join(" - ")},optionValue:function(t){return t.innerHTML},announcement:{count:function(t){return t+" options available"},selected:"Selected."},filter:"contains",autoFilter:!0,selectOnly:!1,selectSearchTimeout:500};t.exports=function(t){var e={},n={};return t.announcement=t.announcement||{},(0,o.default)(n,s.announcement,t.announcement),(0,o.default)(e,s,t),e.announcement=n,e}},function(t,e,n){"use strict";var i=n(23);function r(t,e){for(var n in e)o(e,n)&&(t[n]=e[n])}function o(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.exports=function(t){i(t)||(t={});for(var e=arguments.length,n=1;n=0||o.push.call(this,t);return this._elem.className=this.toString(),this},s.prototype.remove=function(){var t,e,n;for(n=0;n=0},s.prototype.toggle=function(t,e){return t+="",!0===e?this.add(t):!1===e?this.remove(t):this[this.contains(t)?"remove":"add"](t)},s.prototype.toString=function(){return o.join.call(this," ")}},function(t,e,n){"use strict";t.exports=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8;var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";var i=n+"0123456789";var r=n.charAt(Math.floor(Math.random()*n.length));for(var o=1;o=2?"":t.config.selectionValue(t.selected)),t.config.selectOnly||t.input.select()}),this.toggleButton&&this.toggleButton.addEventListener("click",function(e){e.stopPropagation(),t.isOpen?t.closeList():t.openList()}),document.addEventListener("click",function(e){!(0,p.default)(e.target,[t.input,t.list],!0)&&t.isOpen&&t.closeList()})),this.optionEvents(),this.initKeys()}},{key:"getOptIndex",value:function(){return this.currentOption&&this.currentOpts.indexOf(this.currentOption)}},{key:"optionEvents",value:function(){var t=this;this.cachedOpts.forEach(function(e){t.optionsWithEventHandlers.has(e.id)||t.selected.includes(e)||(e.addEventListener("click",function(){t.goTo(t.currentOpts.indexOf(e)).select()}),e.addEventListener("mouseover",function(){var n=t.currentOption;n&&(0,o.default)(n).remove(t.config.activeClass),(0,o.default)(e).add(t.config.activeClass),t.isHovering=!0}),e.addEventListener("mouseout",function(){(0,o.default)(e).remove(t.config.activeClass),t.isHovering=!1}),t.optionsWithEventHandlers.add(e.id))})}},{key:"openList",value:function(){(0,o.default)(this.list).add(this.config.openClass),this.input.setAttribute("aria-expanded","true"),this.isOpen||this.announceCount(),this.isOpen=!0,this.emit("list:open");var t=(0,c.default)(this.list);if(!t.visible){var e="bottom"===t.position?0-(window.innerHeight-(this.input.clientHeight+this.list.clientHeight)):0;(0,a.default)({element:this.input,offset:e,bezier:[.19,1,.22,1],duration:100})}return this}},{key:"closeList",value:function(t,e){return(0,o.default)(this.list).remove(this.config.openClass),this.input.setAttribute("aria-expanded","false"),this.isOpen=!1,t&&this.input.focus(),!this.multiselect&&this.selected.length&&(this.input.value=this.config.selectionValue(this.selected)),e&&!this.config.selectOnly&&this.input.select(),this.emit("list:close"),this}},{key:"getSearchString",value:function(t){var e=this;return t?("number"==typeof this.searchTimeout&&window.clearTimeout(this.searchTimeout),this.searchTimeout=window.setTimeout(function(){e.searchString=""},this.config.selectSearchTimeout),this.searchString=this.searchString?this.searchString+t:t,this.searchString.toLowerCase()):this.searchString}},{key:"initKeys",value:function(){var t=this;if(!this.optionsWithKeyEventHandlers.has(this.input)){this.optionsWithKeyEventHandlers.add(this.input),h.default.down(this.input,[{keys:["up","down"],callback:function(e,n){if(t.isOpen)return-1===t.currentOpts.indexOf(t.currentOption)?t.goTo(0,!0):t.goTo("down"===n?"next":"prev",!0);var i=t.selected.length?t.currentOpts.indexOf(t.selected[t.selected.length-1]):0;t.goTo(i,!0).openList()},preventDefault:!0},{keys:["enter"],callback:function(){t.isOpen?t.select():t.openList()}},{keys:["escape"],callback:function(e){t.isOpen&&(e.stopPropagation(),t.closeList(!0,!0))}},{keys:["backspace"],callback:function(){t.selected.length>=2&&(t.input.value="")}}]),h.default.down(window,function(e){" "===e.key&&e.target===t.input&&(t.config.selectOnly&&(e.preventDefault(),e.stopPropagation()),t.isOpen||t.openList())}),h.default.down(this.input,function(e){var n=e.key,i=e.metaKey,r=e.ctrlKey,o=e.altKey;i||r||o||n&&[" ","tab","backspace"].includes(n.toLowerCase())&&t.isOpen&&(e.preventDefault(),e.stopPropagation(),t.select(),t.closeList())}),this.config.selectOnly&&(h.default.up(this.input,function(e){var n=e.key,i=e.altKey,r=e.ctrlKey,o=e.metaKey;if(new Array(26).fill(1).map(function(t,e){return String.fromCharCode("a".charCodeAt(0)+e)}).includes(n)&&" "!==n&&!i&&!r&&!o){e.preventDefault(),e.stopPropagation();var s=t.getSearchString(n);t.isOpen||t.openList();var u=t.searchIndex(s);u>-1&&t.goTo(u)}}),this.input.addEventListener("blur",function(){t.searchString="",t.selected.length&&(t.input.innerText=t.config.selectionValue(t.selected))}));var e=[9,13,27,16];h.default.up(this.input,function(n){if(t.autoFilter){var i=t.config.filter,r=t.cachedInputValue;e.indexOf(n.which)>-1||!i||"div"===t.input.tagName.toLowerCase()||(t.freshSelection?(t.clearFilters(),r&&r.trim()!==t.input.value.trim()&&(t.filter().openList(),t.freshSelection=!1)):t.filter().openList(),(0,g.default)(t.list,t.currentOpts,t.config.noResultsText))}})}}},{key:"searchIndex",value:function(t){var e=this.getOptIndex(),n=t.trim(),i=n[0],r=n===i.repeat(n.length)&&n.length>1,o=this.currentOpts.filter(function(t){return t.textContent.toLowerCase().startsWith(r?i:n)});if(0===o.length)return-1;if(1===o.length)return this.currentOpts.indexOf(o[0]);if(-1===e)return this.currentOpts.indexOf(o[0]);var s=o.indexOf(this.currentOption);return r&&o.length>1?this.currentOpts.indexOf(o[s+1]||o[0]):-1!==s&&s-1})||t||this.announceCount(),this}},{key:"announceCount",value:function(){var t=this.config.announcement&&this.config.announcement.count;return t&&this.liveRegion&&this.liveRegion.announce(t(this.currentOpts.length),500),this}},{key:"updateOpts",value:function(){var t=this,e=this.config.optionValue;return this.cachedOpts.forEach(function(n){n.style.display=-1===t.currentOpts.indexOf(n)?"none":"",n.innerHTML="string"==typeof e?(0,y.default)(n,"div"===t.input.tagName.toLowerCase()?t.getSearchString():t.input.value,e):e(n)}),this.updateGroups(),this}},{key:"updateGroups",value:function(){return this.groups.forEach(function(t){var e=t.options.filter(function(t){return""===t.style.display});t.element.style.display=e.length?"":"none"}),this}},{key:"select",value:function(){var t=this,e=this.currentOption;if(e){!this.config.multiselect&&this.selected.length&&(0,o.default)(this.selected[0]).remove(this.config.selectedClass);var n=this.selected.indexOf(e),i=n>-1;this.config.multiselect?i?this.selected.splice(n,1):this.selected.push(e):this.selected=this.config.allowEmpty&&i&&!this.config.selectOnly?[]:[e],this.cachedOpts.forEach(function(e){e.setAttribute("aria-selected",t.selected.indexOf(e)>-1?"true":"false")});var r=this.selected.length?this.config.selectionValue(this.selected):"";if(i?(e.classList.remove(this.config.selectedClass),this.emit("deselection",{text:r,option:e})):(e.classList.add(this.config.selectedClass),this.emit("selection",{text:r,option:e})),this.freshSelection=!0,this.config.selectOnly?(this.input.innerText=r,this.config.inputElm&&(this.config.inputElm.value=r)):this.input.value=r,this.cachedInputValue=r,this.filter(!0).clearFilters(),this.config.multiselect||(this.closeList(),this.config.selectOnly||this.input.select()),this.selectElm){var s=this.value(),u=!0,a=!1,l=void 0;try{for(var c,f=this.selectElm.options[Symbol.iterator]();!(u=(c=f.next()).done);u=!0){var h=c.value;this.config.multiselect?h.selected=-1!==s.indexOf(h.value):h.selected=h.value===s}}catch(t){a=!0,l=t}finally{try{!u&&f.return&&f.return()}finally{if(a)throw l}}}return this}}},{key:"reset",value:function(){var t=this;return this.clearFilters(),this.input.value="",this.updateOpts(),this.input.removeAttribute("aria-activedescendant"),this.input.removeAttribute("data-active-option"),this.currentOption=null,this.selected=[],this.cachedOpts.forEach(function(e){(0,o.default)(e).remove(t.config.selectedClass),(0,o.default)(e).remove(t.config.activeClass),e.setAttribute("aria-selected","false")}),this.searchString="",this}},{key:"goTo",value:function(t,e){var n=this;if("string"==typeof t){var i=this.getOptIndex();return this.goTo("next"===t?i+1:i-1,e)}var r=this.currentOpts[t],o=!1;if(!this.currentOpts[t])return 0===this.getOptIndex()&&(this.list.scrollTop=0),this;if(this.groups.length){var s=(0,v.default)(this.groups,r);o=s&&s!==this.currentGroup,this.currentGroup=s}return this.currentOption=r,this.pseudoFocus(o),this.currentOpts.forEach(function(t){t.classList.contains(n.config.activeClass)&&!(0,l.default)(n.list,t)&&(0,a.default)(t)}),this}},{key:"pseudoFocus",value:function(t){var e=this.currentOption,n=this.config.activeClass,i=this.input.getAttribute("data-active-option"),r=i&&document.getElementById(i);return r&&n&&(0,o.default)(r).remove(n),e&&(this.input.setAttribute("data-active-option",e.id),n&&(0,o.default)(e).add(n),this.liveRegion&&(0,O.default)(e,this.config,this.liveRegion.announce.bind(this.liveRegion),t,this.currentGroup&&this.currentGroup.element),this.input.setAttribute("aria-activedescendant",e.id),this.currentOption=e,this.emit("change")),this}},{key:"setOptions",value:function(t){return"object"===(void 0===t?"undefined":i(t))&&this.config.list.append(t),this.cachedOpts.push(t),-1===this.currentOpts.indexOf(t)&&this.currentOpts.push(t),this}},{key:"setCurrentOptions",value:function(){return this.currentOption=this.currentOpts[0],this}},{key:"updateSelectedOptions",value:function(){var t=this,e=document.getElementById(this.config.list.id),n=this.selected;for(this.emptyDropdownList();e.hasChildNodes();)e.removeChild(e.firstChild);return n.length>0&&n.forEach(function(e){t.setOptions(e)}),this}},{key:"emptyDropdownList",value:function(){return this.currentOpts=[],this.cachedOpts=[],this.optionsWithEventHandlers.clear(),this}},{key:"setNoResultFound",value:function(){(0,g.default)(this.list,this.currentOpts,this.config.noResultsText)}},{key:"value",value:function(){var t=[];return this.selected.forEach(function(e){e.hasAttribute("data-value")?t.push(e.dataset.value):t.push(e.innerText)}),this.config.multiselect?t:t&&t.length?t[0]:null}},{key:"transformSelectElement",value:function(t){var e=this,n=document.createElement("div");n.className=this.config.wrapClass,n.id=t.id+"-combobo",t.multiple&&n.classList.add("multiselect");var i=this.config.selectOnly?"div":"input",r=document.createElement(i);r.setAttribute("tabindex","0"),r.type="text",r.className=this.config.inputClass,r.id=t.id+"-input",n.appendChild(r),this.reassignLabel(t,r.id);var o=document.createElement("span");o.setAttribute("aria-hidden","true"),o.className=this.config.toggleButtonClass,n.appendChild(o);var s=document.createElement("div");s.className=this.config.listClass,n.appendChild(s);var u=!1;return Array.from(t.children).forEach(function(t){if("optgroup"===t.tagName.toLowerCase()){u=!0;var n=document.createElement("div");n.className=e.config.optgroupClass,n.setAttribute("role","group");var i=(0,x.default)();n.setAttribute("aria-labelledby",i);var r=document.createElement("div");r.className=e.config.optgroupLabelClass,r.id=i,r.textContent=t.label,n.appendChild(r),Array.from(t.children).forEach(function(t){var i={text:t.textContent,value:t.value,selected:t.hasAttribute("selected"),disabled:t.hasAttribute("disabled")};n.appendChild(e.createOptionElement(i.text,i.value,i.selected,i.disabled))}),s.appendChild(n)}else{var o={text:t.textContent,value:t.value,selected:t.hasAttribute("selected"),disabled:t.hasAttribute("disabled")};s.appendChild(e.createOptionElement(o.text,o.value,o.selected,o.disabled))}}),u&&n.classList.add("has-groups"),{comboElement:n,input:r}}},{key:"createOptionElement",value:function(t,e,n,i){var r=document.createElement("div");return r.className=this.config.optionsClass,r.textContent=t,r.dataset.value=e,n&&r.classList.add(this.config.selectedClass),i&&r.classList.add("disabled"),r}},{key:"createOptgroupElement",value:function(t){var e=document.createElement("div");e.className=this.config.optgroupClass,e.setAttribute("role","group");var n=(0,x.default)();e.setAttribute("aria-labelledby",n);var i=document.createElement("div");return i.className=this.config.optgroupLabelClass,i.id=n,i.textContent=t,e.appendChild(i),e}}]),t}()},function(t,e){t.exports=function(t,e){if(t.indexOf)return t.indexOf(e);for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:100,n=0,i=void 0,c=void 0;if((0,u.isElement)(t))i=o.default.apply(void 0,l),c=r;else{if(!(0,u.isObject)(t))throw new TypeError("The first argument must be HTMLElement or Object.");if(!(0,u.isElement)(t.element))throw new TypeError("`element` must be HTMLElement.");n=(0,u.isNumeric)(t.offset)?t.offset:0,i=(0,u.isArray)(t.bezier)&&4===t.bezier.length?o.default.apply(void 0,function(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e=0},e.isFunction=function(t){return null!=t&&"[object Function]"===i(t)},e.isElement=function(t){return"object"===o(window.HTMLElement)?t instanceof window.HTMLElement:!!t&&"object"===(void 0===t?"undefined":o(t))&&null!==t&&1===t.nodeType&&"string"==typeof t.nodeName}},function(t,e,n){"use strict";function i(t,e){return window.getComputedStyle(t,null).getPropertyValue(e)}function r(t){if(1===t.nodeType)return o.test(function(t){return i(t,"overflow")+i(t,"overflow-y")}(t))&&t.scrollHeight>t.clientHeight}Object.defineProperty(e,"__esModule",{value:!0});var o=/(auto|scroll)/;e.default=function(t){for(var e=function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=e.parentNode;return null===i||"HTML"===i.nodeName?n:t(i,n.concat(i))}(t),n=document.body,i=0,o=e.length;i0?n=u:e=u}while(Math.abs(s)>c&&++a=.001?a(e,c,t,n):0===f?c:u(e,i,i+p,t,n)}if(!(0<=t&&t<=1&&0<=n&&n<=1))throw new Error("bezier x values must be in [0, 1] range");var l=d?new Float32Array(h):new Array(h);if(t!==e||n!==i)for(var c=0;c1)for(var n=1;no)&&!(r+n-ie,o=!i&&!r,s={visible:o};return o||(s.position=i?"top":"bottom"),s}},function(t,e,n){"use strict";var i,r=n(11),o=(i=r)&&i.__esModule?i:{default:i};t.exports={contains:function(t,e){return e.filter(function(e){return(0,o.default)(e).toLowerCase().indexOf(t.toLowerCase())>-1})},equals:function(t,e){return e.filter(function(e){return(0,o.default)(e).toLowerCase()===t.toLowerCase()})},"starts-with":function(t,e){return e.filter(function(e){return 0===(0,o.default)(e).toLowerCase().indexOf(t.toLowerCase())})}}},function(t,e,n){"use strict";t.exports=function(t){return t.getAttribute("data-value")||t.innerText}},function(t,e,n){"use strict";var i,r=n(13),o=(i=r)&&i.__esModule?i:{default:i};e.attach=function(t,e,n){if("function"==typeof n)return e.addEventListener(t,n);n&&n.length&&e.addEventListener(t,function(t){var e=o.default[t.which];n.forEach(function(n){n.keys.indexOf(e)>-1&&(n.preventDefault&&t.preventDefault(),n.callback(t,e))})})},e.up=function(t,n){return e.attach("keyup",t,n)},e.down=function(t,n){return e.attach("keydown",t,n)},e.press=function(t,n){return e.attach("keypress",t,n)}},function(t,e,n){"use strict";t.exports={8:"backspace",9:"tab",13:"enter",27:"escape",32:"space",37:"left",38:"up",39:"right",40:"down"}},function(t,e,n){"use strict";t.exports=function(t,e,n){if(e=e.length?e:[e],n&&e.indexOf(t)>-1)return!0;for(var i=t.parentNode;i&&"HTML"!==i.tagName;){if(e.indexOf(i)>-1)return!0;i=i.parentNode}return!1}},function(t,e,n){"use strict";var i,r=n(16),o=(i=r)&&i.__esModule?i:{default:i};t.exports=function(t,e,n){return n=n||document,"string"==typeof t?e?o.default.all(t,n):(0,o.default)(t,n):t}},function(t,e,n){"use strict";(t.exports=function(t,e){return(e=e||document).querySelector(t)}).all=function(t,e){return e=e||document,Array.prototype.slice.call(e.querySelectorAll(t))}},function(t,e,n){"use strict";t.exports=function(t,e){var n=t.filter(function(t){return t.options.indexOf(e)>-1});return n.length&&n[0]}},function(t,e,n){"use strict";var i,r=n(0),o=(i=r)&&i.__esModule?i:{default:i};t.exports=function(t,e,n){var i=t.querySelector(".combobo-no-results");!n||e.length||i?i&&e.length&&t.removeChild(i):(i=document.createElement("div"),(0,o.default)(i).add("combobo-no-results"),i.innerHTML=n,t.appendChild(i))}},function(t,e,n){"use strict";var i,r=n(1),o=(i=r)&&i.__esModule?i:{default:i};t.exports=function(t,e,n){e.id=e.id||(0,o.default)(),t.setAttribute("role","combobox"),e.setAttribute("role","listbox"),t.setAttribute("aria-controls",e.id),t.setAttribute("aria-autocomplete","list"),t.setAttribute("aria-expanded","false"),n.forEach(function(t){t.setAttribute("role","option"),t.id=t.id||(0,o.default)()})}},function(t,e,n){"use strict";t.exports=function(t,e,n){e=e||"";var i=t.innerText,r=i.toLowerCase().indexOf(e.toLowerCase()),o=e.length;return e&&r>=0?i.substring(0,r)+''+i.substr(r,o)+""+i.substring(r+o):i}},function(t,e,n){"use strict";var i,r=n(22),o=(i=r)&&i.__esModule?i:{default:i};var s={select:"select.combobo",input:".combobox",list:".listbox",toggleButton:".trigger",options:".option",groups:null,wrapClass:"combo-wrap",inputClass:"combobox",listClass:"listbox",toggleButtonClass:"trigger",toggleButtonIcon:null,optgroupClass:"optgroup",optgroupLabelClass:"optgroup-label",optionsClass:"option",openClass:"open",activeClass:"active",selectedClass:"selected",useLiveRegion:!0,allowEmpty:!0,multiselect:!1,noResultsText:null,selectionValue:function(t){return t.map(function(t){return t.innerText.trim()}).join(" - ")},optionValue:function(t){return t.innerHTML},announcement:{count:function(t){return t+" options available"},selected:"Selected."},filter:"contains",autoFilter:!0,selectOnly:!1,selectSearchTimeout:500};t.exports=function(t){var e={},n={};return t.announcement=t.announcement||{},(0,o.default)(n,s.announcement,t.announcement),(0,o.default)(e,s,t),e.announcement=n,e}},function(t,e,n){"use strict";var i=n(23);function r(t,e){for(var n in e)o(e,n)&&(t[n]=e[n])}function o(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.exports=function(t){i(t)||(t={});for(var e=arguments.length,n=1;n