/
easydropdown.js
2 lines (2 loc) · 37.2 KB
/
easydropdown.js
1
2
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.easydropdown=t():e.easydropdown=t()}(window,function(){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:o})},n.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=70)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(52);function r(e,t,n,o){var r=e(o,n),i=r.maxVisibleItemsOverride>-1?r.maxVisibleItemsOverride:n.behavior.maxVisibleItems,a=o.item.length>i,u=o.sumItemsHeight(i);t.open(u,r.type,a)}t.dispatchOpen=r;var i=r.bind(null,o.default);t.default=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(18),r=n(4);t.ArrayStrategy=r.default,t.default=o.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return e.reduce(function(e,t){if("string"==typeof t)e.push(t);else{var n=t[0],o=t[1];n&&e.push(o)}return e},[]).join(" ")}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=function(e,t){var n=t.actions,o=t.timers;window.clearTimeout(o.keyingTimeoutId),n.keying(),o.keyingTimeoutId=window.setTimeout(function(){return n.resetKeying()},100),e.disabled=!0,setTimeout(function(){e.disabled=!1,e.focus()})}},function(e,t,n){"use strict";var o;Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.PUSH="PUSH",e.REPLACE="REPLACE"}(o||(o={})),t.default=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=function(){return function(){this.label="",this.value="",this.isDisabled=!1}}();t.default=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(){this.label="",this.options=[],this.isDisabled=!1}return Object.defineProperty(e.prototype,"totalOptions",{get:function(){return this.options.length},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasLabel",{get:function(){return""!==this.label},enumerable:!0,configurable:!0}),e}();t.default=o},function(e,t,n){"use strict";var o;Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.AT_TOP="AT_TOP",e.SCROLLED="SCROLLED",e.AT_BOTTOM="AT_BOTTOM"}(o||(o={})),t.default=o},function(e,t,n){"use strict";var o;Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.CLOSED="CLOSED",e.OPEN_ABOVE="OPEN_ABOVE",e.OPEN_BELOW="OPEN_BELOW"}(o||(o={})),t.default=o},function(e,t,n){"use strict";var o;Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.NONE="NONE",e.FULL="FULL",e.REPLACE="REPLACE",e.INNER="INNER",e.OUTER="OUTER"}(o=t.DomChangeType||(t.DomChangeType={})),t.default=o},function(e,t,n){"use strict";var o;Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.ADD="ADD",e.EDIT="EDIT",e.REMOVE="REMOVE"}(o||(o={})),t.default=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){var n=t.state,o=t.actions,r=t.dom;n.isOpen&&(o.close(),r.select.blur())}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UP=38,t.DOWN=40,t.SPACE=32,t.ENTER=13,t.ESC=27},function(e,t,n){"use strict";var o;Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.NONE="NONE",e.TOP="TOP",e.BOTTOM="BOTTOM"}(o||(o={})),t.default=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OPTION='[data-ref~="option"]'},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,n){void 0===n&&(n=!1);var o=e.parentNode;if(n&&e.matches(t))return e;for(;o&&o!==document.body;){if(o.matches&&o.matches(t))return o;if(!o.parentNode)return null;o=o.parentNode}return null}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(62),r=n(61),i=n(60),a=function(){return function(){this.callbacks=new r.default,this.classNames=new i.default,this.behavior=new o.default,Object.seal(this)}}();t.default=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MERGE_ERROR=function(e,t){return void 0===t&&(t=""),'Unknown property "'+e+'"'+(t?'. Did you mean "'+t+'"?':"")},t.TYPE_ERROR_TARGET=function(e){return'[Helpful Merge] Target "'+e+'" must be a valid object'},t.TYPE_ERROR_SOURCE=function(e){return'[Helpful Merge] Source "'+e+'" must be a valid object'},t.INVALID_ARRAY_STRATEGY=function(e){return'[Helpful Merge] Invalid array strategy "'+e+'"'}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(65),r=n(4),i=n(64),a=n(63),u=n(17);function s(e,t,n){void 0===n&&(n=null);var i,l=[];if(i=n instanceof o.default?n:new o.default,"boolean"==typeof n&&!0===n)i.deep=!0;else if(n&&i!==n&&"object"==typeof n&&(s(i,n),[r.default.PUSH,r.default.REPLACE].indexOf(i.arrayStrategy)<0))throw RangeError(u.INVALID_ARRAY_STRATEGY(i.arrayStrategy));if(!e||"object"!=typeof e)throw new TypeError(u.TYPE_ERROR_TARGET(e));if(!t||"object"!=typeof t)throw new TypeError(u.TYPE_ERROR_SOURCE(t));if(Array.isArray(t)){if(i.arrayStrategy===r.default.PUSH)return e.push.apply(e,t),e;for(var d=0;d<t.length;d++)l.push(d.toString())}else l=Object.getOwnPropertyNames(t);for(var c=0,f=l;c<f.length;c++){var p=f[c],h=Object.getOwnPropertyDescriptor(t,p);if(("function"!=typeof h.get||h.set||i.includeReadOnly)&&(h.enumerable||i.includeNonEmurable))if(!i.deep||"object"!=typeof t[p]||null===t[p]||Array.isArray(t[p])&&i.useReferenceIfArray||!e[p]&&i.useReferenceIfTargetUnset)try{e[p]=t[p]}catch(t){a.default(t,e,p,i.errorMessage)}else{if(!Object.prototype.hasOwnProperty.call(e,p)||null===e[p])try{e[p]=Array.isArray(t[p])?[]:{}}catch(t){a.default(t,e,p,i.errorMessage)}s(e[p],t[p],i)}}return e}Object.keys(i.default.prototype).forEach(function(e){return s[e]=function(e){return function(){for(var t,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return(t=new i.default)[e].apply(t,n)}}(e)}),t.default=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=[]},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=function(){return function(e){this.open=e.open.bind(e),this.close=e.close.bind(e),this.refresh=e.refresh.bind(e),this.destroy=e.destroy.bind(e),Object.defineProperties(this,{value:{get:function(){return e.value},set:function(t){return e.value=t}}})}}();t.default=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(){}return e.prototype.clear=function(){var e=this;Object.keys(this).forEach(function(t){return window.clearInterval(e[t])})},e}();t.default=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),r=n(16),i=n(8),a=n(7),u=n(6),s=n(5),l=function(){function e(e,t){void 0===e&&(e=null),void 0===t&&(t=new r.default),this.groups=[],this.focusedIndex=-1,this.selectedIndex=-1,this.maxVisibleItemsOverride=-1,this.maxBodyHeight=-1,this.name="",this.placeholder="",this.scrollStatus=a.default.AT_TOP,this.bodyStatus=i.default.CLOSED,this.isDisabled=!1,this.isRequired=!1,this.isInvalid=!1,this.isFocused=!1,this.isUseNativeMode=!1,this.isScrollable=!1,this.isSearching=!1,this.isKeying=!1,this.config=t,e&&(o.default(this,e),this.groups=this.groups.map(function(e){var t=o.default(new u.default,e);return t.options=t.options.map(function(e){return o.default(new s.default,e)}),t}))}return Object.defineProperty(e.prototype,"totalGroups",{get:function(){return this.groups.length},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"lastGroup",{get:function(){return this.groups[this.groups.length-1]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"totalOptions",{get:function(){return this.groups.reduce(function(e,t){return e+t.totalOptions},0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"selectedOption",{get:function(){return this.getOptionFromIndex(this.selectedIndex)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"focusedOption",{get:function(){return this.getOptionFromIndex(this.focusedIndex)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this.selectedOption?this.selectedOption.value:""},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"humanReadableValue",{get:function(){return!this.hasValue&&this.hasPlaceholder||this.config.behavior.showPlaceholderWhenOpen&&this.hasPlaceholder&&this.isOpen?this.placeholder:this.label},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"label",{get:function(){return this.selectedOption?this.selectedOption.label:""},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasPlaceholder",{get:function(){return""!==this.placeholder},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isPlaceholderShown",{get:function(){return this.hasPlaceholder&&!this.hasValue},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasValue",{get:function(){return""!==this.value},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isGrouped",{get:function(){return Boolean(this.groups.find(function(e){return e.hasLabel}))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isOpen",{get:function(){return this.bodyStatus!==i.default.CLOSED},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isClosed",{get:function(){return this.bodyStatus===i.default.CLOSED},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isOpenAbove",{get:function(){return this.bodyStatus===i.default.OPEN_ABOVE},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isOpenBelow",{get:function(){return this.bodyStatus===i.default.OPEN_BELOW},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isAtTop",{get:function(){return this.scrollStatus===a.default.AT_TOP},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isAtBottom",{get:function(){return this.scrollStatus===a.default.AT_BOTTOM},enumerable:!0,configurable:!0}),e.prototype.getOptionFromIndex=function(e){for(var t=0,n=0,o=this.groups;n<o.length;n++){var r=o[n];if(e<0)break;if(e<=Math.max(0,t+r.totalOptions-1))return r.options[e-t];t+=r.totalOptions}return null},e.prototype.getOptionIndexFromValue=function(e){for(var t=-1,n=0,o=this.groups;n<o.length;n++)for(var r=0,i=o[n].options;r<i.length;r++){if(t++,i[r].value===e)return t}return-1},e}();t.default=l},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){var t=/(ipad|iphone|ipod)/gi.test(e),n=/android/gi.test(e),o=/opera mini/gi.test(e),r=/windows phone/gi.test(e);return!!(t||n||o||r)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),r=n(23),i=n(6),a=n(5),u=n(22),s=function(){function e(){}return e.mapFromSelect=function(t,n){var o=new u.default(null,n),i=!1;o.name=t.name,o.isDisabled=t.disabled,o.isRequired=t.required,o.isUseNativeMode=n.behavior.useNativeUiOnMobile&&r.default(window.navigator.userAgent);for(var a=0,s=void 0;s=t.children[a];a++)if(0!==a||null===s.getAttribute("data-placeholder"))if(s instanceof HTMLOptionElement)!1===i&&(o.groups.push(e.mapGroup()),i=!0),o.lastGroup.options.push(e.mapOption(s)),s.selected&&(o.selectedIndex=o.totalOptions-1);else{if(!(s instanceof HTMLOptGroupElement))throw new TypeError('[EasyDropDown] Invalid child tag "'+s.tagName+'" found in provided `<select>` element');i=!0,o.groups.push(e.mapGroup(s));for(var l=0,d=void 0;d=s.children[l];l++)o.lastGroup.options.push(e.mapOption(d,s)),d.selected&&(o.selectedIndex=o.totalOptions-1);i=!1}else o.placeholder=s.textContent,s.value="";return Object.seal(o)},e.mapGroup=function(e){return void 0===e&&(e=null),o.default(new i.default,{label:e?e.label:"",isDisabled:!!e&&e.disabled})},e.mapOption=function(e,t){if(void 0===t&&(t=null),!(e instanceof HTMLOptionElement))throw new TypeError("[EasyDropDown] Invalid markup structure");var n=null!==t&&t.disabled;return o.default(new a.default,{label:e.textContent,value:e.value,isDisabled:e.disabled||n})},e}();t.default=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(13),r=n(8),i=n(7);t.default=function(e){return{focus:function(){e.isFocused=!0},blur:function(){e.isFocused=!1},invalidate:function(){e.isInvalid=!0},validate:function(){e.isInvalid=!1},topOut:function(){e.scrollStatus=i.default.AT_TOP},bottomOut:function(){e.scrollStatus=i.default.AT_BOTTOM},scroll:function(){e.scrollStatus=i.default.SCROLLED},makeScrollable:function(){e.isScrollable=!0},makeUnscrollable:function(){e.isScrollable=!1},open:function(t,n,i){if(!e.isDisabled){switch(this.closeOthers(),n){case o.default.NONE:case o.default.TOP:e.bodyStatus=r.default.OPEN_BELOW;break;case o.default.BOTTOM:e.bodyStatus=r.default.OPEN_ABOVE}e.isScrollable=i,e.maxBodyHeight=t,this.scrollToView(e,!0)}},close:function(){e.bodyStatus=r.default.CLOSED,e.focusedIndex=-1},selectOption:function(t){var n=e.getOptionFromIndex(t);t>-1&&(!n||n.isDisabled)||(e.selectedIndex=t,e.isInvalid&&this.validate(),e.isSearching?this.scrollToView(e):this.close())},focusOption:function(t,n){void 0===n&&(n=!1);var o=Math.abs(t-e.focusedIndex)>1;e.focusedIndex=t,n&&this.scrollToView(e,o)},search:function(){e.isSearching=!0},resetSearch:function(){e.isSearching=!1},keying:function(){e.isKeying=!0},resetKeying:function(){e.isKeying=!1},useNative:function(){e.isUseNativeMode=!0}}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),r=n(25),i=function(){function e(){}return e.proxyActions=function(t,n,i){var a=e.createStateProxy(t,i),u=r.default(a);return o.default(u,n),u},e.createStateProxy=function(t,n){return Object.seal(e.getPropertyDescriptorsFromValue(t,n).reduce(function(e,t){var n=t.key,o=t.get,r=t.set;return Object.defineProperty(e,n,{enumerable:!0,get:o,set:r})},{}))},e.getPropertyDescriptorsFromValue=function(t,n){var o=Object.getPrototypeOf(t);return Object.keys(t).concat(Object.keys(o)).reduce(function(r,i){var a="function"==typeof(Object.getOwnPropertyDescriptor(t,i)||Object.getOwnPropertyDescriptor(o,i)).get;return r.push({get:e.readPropertyValue.bind(null,t,i),set:a?void 0:e.updatePropertyValue.bind(null,t,i,n),key:i}),r},[])},e.readPropertyValue=function(e,t){return e[t]},e.updatePropertyValue=function(e,t,n,o){e[t]!==o&&(e[t]=o,n(e,t))},e}();t.default=i},function(e,t,n){"use strict";function o(e,t,n,o,r){var i;return t<e?t-r:(i=t+n-(e+o))>0?e+i+r:e}Object.defineProperty(t,"__esModule",{value:!0}),t.getScrollTop=o,t.default=function(e,t,n,r){void 0===r&&(r=!1);var i=Math.max(0,n.focusedIndex>-1?n.focusedIndex:n.selectedIndex),a=e.option[i];if(a){var u=r?n.maxBodyHeight/2-a.offsetHeight/2:0,s=o(e.itemsList.scrollTop,a.offsetTop,a.offsetHeight,n.maxBodyHeight,u);s!==e.itemsList.scrollTop&&(e.itemsList.scrollTop=s)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){for(var n=0,o=t;n<o.length;n++){var r=o[n];r!==e&&r.actions.close()}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=300;t.default=function(e,t,n){var r=e.outerHTML;return window.setInterval(function(){var o=e.outerHTML;o===r||t.isKeying||n(),r=o},o)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=100;t.default=function(e,t,n){var r=e.value;return window.setInterval(function(){if(e.value!==r){var o=t.getOptionIndexFromValue(e.value);n.selectOption(o),n.focusOption(o,!0)}r=e.value},o)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(10),r=n(9);function i(e,t){var n=window.requestAnimationFrame;t.forEach(function(t){n&&["class","style"].indexOf(t.name)>-1?n(function(){return a(e,t)}):a(e,t)})}function a(e,t){switch(t.type){case o.default.ADD:case o.default.EDIT:e.setAttribute(t.name,t.value);break;case o.default.REMOVE:e.removeAttribute(t.name)}}t.default=function e(t,n){switch(n.type){case r.default.NONE:return t;case r.default.REPLACE:return t.parentElement.replaceChild(n.newNode,t),n.newNode;case r.default.INNER:return t instanceof Text?t.textContent=n.newTextContent:n.childCommands.length>0?n.childCommands.forEach(function(n,o){return e(t.childNodes[o],n)}):t.innerHTML=n.newInnerHtml,t;case r.default.OUTER:return i(t,n.attributeChanges),t;case r.default.FULL:return n.childCommands.length>0?n.childCommands.forEach(function(n,o){return e(t.childNodes[o],n)}):t.innerHTML=n.newInnerHtml,i(t,n.attributeChanges),t}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=function(){return function(){this.newNode=null,this.newInnerHtml="",this.newTextContent="",this.attributeChanges=[],this.childCommands=[],this.index=null}}();t.default=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),r=n(10),i=n(9),a=n(32);function u(e,t){for(var n=Math.max(e.attributes.length,t.attributes.length),o={},a=[],u=0;u<n;u++){var s=e.attributes[u],l=t.attributes[u];s&&void 0===o[s.name]&&(o[s.name]=[]),l&&void 0===o[l.name]&&(o[l.name]=[]),s&&(o[s.name][0]=s.value),l&&(o[l.name][1]=l.value)}var d=Object.keys(o);d.length>1&&d.sort();u=0;for(var c=void 0;c=d[u];u++){var f=o[c],p={type:null,name:c,value:null};f[0]!==f[1]&&(void 0===f[0]?(p.type=r.default.ADD,p.value=f[1]):void 0===f[1]?(p.type=r.default.REMOVE,p.value=""):(p.type=r.default.EDIT,p.value=f[1]),a.push(p))}return{type:i.default.OUTER,attributeChanges:a}}t.default=function e(t,n){var r=-1,s=new a.default;if(t instanceof HTMLSelectElement)return s.type=i.default.NONE,s;if(t instanceof Text&&n instanceof Text)t.textContent===n.textContent?s.type=i.default.NONE:(s.type=i.default.INNER,s.newTextContent=n.textContent);else if(t instanceof HTMLElement&&n instanceof HTMLElement)if(t.tagName!==n.tagName)s.type=i.default.REPLACE,s.newNode=n;else if(t.outerHTML===n.outerHTML)s.type=i.default.NONE;else if(t.innerHTML===n.innerHTML)o.default(s,u(t,n));else if(o.default(s,u(t,n)),s.attributeChanges.length>0?s.type=i.default.FULL:s.type=i.default.INNER,(r=t.childNodes.length)>0&&r===n.childNodes.length)for(var l=0,d=void 0;d=t.childNodes[l];l++)s.childCommands.push(e(d,n.childNodes[l]));else s.newInnerHtml=n.innerHTML;else s.type=i.default.REPLACE,s.newNode=n;return s}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(){this.select=null,this.root=null,this.head=null,this.value=null,this.body=null,this.arrow=null,this.itemsList=null,this.item=[],this.group=[],this.option=[]}return e.prototype.sumItemsHeight=function(e){void 0===e&&(e=1/0);for(var t=0,n=0,o=void 0;(o=this.item[n])&&n!==e;n++)t+=o.offsetHeight;return t},e}();t.default=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){var t=document.createElement("div");return t.innerHTML=e,t.firstElementChild}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=function(e,t){return'\n <div\n class="'+t.value+'"\n data-ref="value"\n '+(e.isPlaceholderShown?'aria-placeholder="'+e.humanReadableValue+'"':"")+"\n >\n "+e.humanReadableValue+"\n </div>\n "}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=function(e,t){return'<div class="'+t.arrow+'" role="presentation"></div>'}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(37),r=n(36);t.default=function(e,t){return'\n <div class="'+t.head+'" data-ref="head">\n '+r.default(e,t)+"\n "+o.default(e,t)+'\n <select class="'+t.select+'" data-ref="select"></select>\n </div>\n'}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(2);t.default=function(e,t,n){var r=t.selectedOption===e;return'\n <div\n class="'+o.default([n.option,[r,n.optionSelected],[e===t.focusedOption,n.optionFocused],[e.isDisabled,n.optionDisabled]])+'"\n data-ref="option item"\n role="option"\n title="'+e.label+'"\n '+(r?'aria-selected="true"':"")+"\n "+(e.isDisabled?'aria-disabled="true"':"")+"\n >\n "+e.label+"\n </div>\n "}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(2),r=n(39);t.default=function(e,t,n){return'\n <div class="'+o.default([n.group,[e.isDisabled,n.groupDisabled],[e.hasLabel,n.groupHasLabel]])+'" data-ref="group" role="group">\n '+(e.hasLabel?'<div class="'+n.groupLabel+'" data-ref="item">'+e.label+"</div>":"")+"\n "+e.options.map(function(e){return r.default(e,t,n)}).join("")+"\n </div>\n "}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(2),r=n(40);t.default=function(e,t){var n=o.default([t.body,[e.isAtTop,t.bodyAtTop],[e.isAtBottom,t.bodyAtBottom],[e.isScrollable,t.bodyScrollable]]),i=e.isOpen?'style="max-height: '+e.maxBodyHeight+'px;"':"";return'\n <div\n class="'+n+'"\n data-ref="body"\n role="listbox"\n '+(e.isOpen?"":"aria-hidden")+'\n >\n <div class="'+t.itemsList+'"\n data-ref="itemsList"\n '+i+">\n "+e.groups.map(function(n){return r.default(n,e,t)}).join("")+"\n </div>\n <div class="+t.gradientTop+' role="presentation"></div>\n <div class='+t.gradientBottom+' role="presentation"></div>\n </div>\n '}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(2),r=n(41),i=n(38);t.default=function(e,t){return'\n <div\n class="'+o.default([t.root,[e.isDisabled,t.rootDisabled],[e.isInvalid,t.rootInvalid],[e.isOpen,t.rootOpen],[e.isFocused,t.rootFocused],[e.hasValue,t.rootHasValue],[e.isOpenAbove,t.rootOpenAbove],[e.isOpenBelow,t.rootOpenBelow],[e.isUseNativeMode,t.rootNative]])+'"\n role="widget combobox"\n aria-haspopup="listbox"\n '+(e.isOpen?'aria-expanded="true"':"")+"\n "+(e.isRequired?'aria-required="true"':"")+"\n "+(e.isDisabled?'aria-disabled="true"':"")+"\n "+(e.isInvalid?'aria-invalid="true"':"")+"\n >\n "+i.default(e,t)+"\n "+(e.isUseNativeMode?"":r.default(e,t))+"\n </div>\n "}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(42),r=n(35),i=n(34),a=n(33),u=n(31),s=function(){function e(e){this.dom=new i.default,this.classNames=e}return e.prototype.render=function(t,n){var a=o.default(t,this.classNames),u=r.default(a);return this.dom=new i.default,this.dom.root=u,this.dom.option.length=this.dom.group.length=0,e.queryDomRefs(this.dom),this.injectSelect(n),this.dom},e.prototype.update=function(e,t){var n=o.default(e,this.classNames),i=r.default(n),s=a.default(this.dom.root,i);u.default(this.dom.root,s),"selectedIndex"===t&&this.syncSelectWithValue(e.value)},e.prototype.destroy=function(){this.dom.select.classList.remove(this.classNames.select);try{this.dom.root.parentElement.replaceChild(this.dom.select,this.dom.root)}catch(e){}},e.prototype.injectSelect=function(e){var t=e.parentElement,n=this.dom.select;if(!t)throw new Error("[EasyDropDown] The provided `<select>` element must exist within a document");t.replaceChild(this.dom.root,e),n.parentElement.replaceChild(e,n),e.className=this.classNames.select,e.setAttribute("aria-hidden","true"),this.dom.select=e},e.prototype.syncSelectWithValue=function(e){if(this.dom.select.value!==e){var t=new CustomEvent("change",{bubbles:!0});this.dom.select.value=e,this.dom.select.dispatchEvent(t)}},e.queryDomRefs=function(e,t){return void 0===t&&(t=Object.keys(e)),t.reduce(function(e,t){var n='[data-ref~="'+t+'"]',o=e.root.querySelectorAll(n);if(o.length<1||"root"===t)return e;var r=o[0],i=e[t];return null===i?e[t]=r:Array.isArray(i)&&Array.prototype.push.apply(i,o),e},e)},e}();t.default=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(12),r=1200;t.default=function(e,t,n){var i=e.keyCode,a=t.actions,u=t.timers,s=t.state;void 0===n&&(n=r),s.isUseNativeMode||[o.UP,o.DOWN].includes(i)||(window.clearTimeout(u.searchTimeoutId),a.search(),u.searchTimeoutId=window.setTimeout(function(){return a.resetSearch()},n))}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(0),r=n(3);t.default=function(e,t){var n=e.metaKey,i=e.target,a=t.state,u=t.config,s=t.dom,l=t.actions,d=a.focusedIndex>-1?a.focusedIndex:a.selectedIndex,c=0,f=1;e.preventDefault(),r.default(i,t),n&&(f=Math.round(Math.max(a.totalOptions/2,u.behavior.maxVisibleItems)));do{d-=f,f=1,d<0&&(d=u.behavior.loop?a.totalOptions-1:0),l.focusOption(d,!0),c++}while(a.focusedOption&&a.focusedOption.isDisabled&&c<a.totalOptions);a.isClosed&&o.default(l,u,s)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(0),r=n(3);t.default=function(e,t){var n=e.metaKey,i=e.target,a=t.state,u=t.dom,s=t.actions,l=t.config,d=a.focusedIndex>-1?a.focusedIndex:a.selectedIndex,c=0,f=1;e.preventDefault(),r.default(i,t),n&&(f=Math.round(Math.max(a.totalOptions/2,l.behavior.maxVisibleItems)));do{d+=f,f=1,d>=a.totalOptions&&(d=l.behavior.loop?0:a.totalOptions-1),s.focusOption(d,!0),c++}while(a.focusedOption&&a.focusedOption.isDisabled&&c<=a.totalOptions);a.isClosed&&o.default(s,l,u)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(0),r=n(3),i=n(12),a=n(46),u=n(45);t.default=function(e,t){var n=e.keyCode,s=e.target,l=t.state,d=t.actions,c=t.dom,f=t.config;if(!l.isUseNativeMode&&!l.isDisabled)switch(n){case i.DOWN:a.default(e,t);break;case i.UP:u.default(e,t);break;case i.SPACE:if(l.isSearching)return void e.stopPropagation();case i.ENTER:e.stopPropagation(),e.preventDefault(),r.default(s,t),l.isOpen?d.selectOption(l.focusedIndex):o.default(d,f,c);break;case i.ESC:d.close()}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){var n=t.actions;t.config,t.dom,n.invalidate()}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(0);t.default=function(e,t){var n=t.actions,r=t.config,i=t.dom,a=t.state;n.focus(),r.behavior.openOnFocus&&!a.isUseNativeMode&&o.default(n,r,i)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){var n=t.actions;t.state.isKeying||n.blur()}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){t.state;var n=t.actions,o=t.dom;e.stopPropagation();var r=o.itemsList,i=r.offsetHeight,a=r.scrollHeight,u=r.scrollTop;0===u?n.topOut():u===a-i?n.bottomOut():n.scroll()}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(13),r=10;function i(e,t,n,r){var i=o.default.NONE,a=-1;if(e<=n&&t<=n){var u=Math.max(t,e);i=e<t?o.default.TOP:o.default.BOTTOM,a=Math.floor(u/r)}else e<=n?i=o.default.TOP:t<=n&&(i=o.default.BOTTOM);return{type:i,maxVisibleItemsOverride:a}}t.mapCollisionData=i,t.default=function(e,t){var n=e.head.getBoundingClientRect(),a=window.innerHeight,u=n.top-r,s=a-n.bottom-r;if(e.option.length<1)return{type:o.default.NONE,maxVisibleItemsOverride:-1};var l=Math.min(t.behavior.maxVisibleItems,e.item.length);return i(u,s,e.sumItemsHeight(l),e.sumItemsHeight(1))}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(0);t.default=function(e,t){var n=t.state,r=t.actions,i=t.dom,a=t.config;n.isUseNativeMode||(e.stopPropagation(),n.isClosed?(o.default(r,a,i),i.select.focus()):r.close())}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(15),r=n(14);t.default=function(e,t){var n=t.state,i=t.actions,a=t.dom;e.stopPropagation();var u=o.default(e.target,r.OPTION,!0);if(u&&!n.isKeying){var s=Array.prototype.indexOf.call(a.option,u);i.focusOption(s)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(15),r=n(14);t.default=function(e,t){t.state;var n=t.actions,i=t.dom;e.stopPropagation();var a=o.default(e.target,r.OPTION,!0);if(a){var u=Array.prototype.indexOf.call(i.option,a);n.selectOption(u)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(55),r=n(54),i=n(53),a=n(51),u=n(50),s=n(49),l=n(48),d=n(47),c=n(44),f=n(11),p=n(11);t.default=function(e){return[{target:e.head,type:"click",handler:i.default},{target:e.body,type:"click",handler:o.default},{target:e.body,type:"mouseover",handler:r.default},{target:e.itemsList,type:"scroll",handler:a.default},{target:e.select,type:"keydown",handler:d.default},{target:e.select,type:"invalid",handler:l.default},{target:e.select,type:"keypress",handler:c.default},{target:e.select,type:"focus",handler:s.default},{target:e.select,type:"blur",handler:u.default},{target:document.documentElement,type:"click",handler:f.default},{target:window,type:"resize",handler:p.default,throttle:100}]}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),r=function(){function e(e){this.type="",this.target=null,this.debounce=0,this.throttle=0,this.handler=null,this.boundHandler=null,this.passive=!1,o.default(this,e),Object.seal(this)}return e.prototype.unbind=function(){this.target&&this.target.removeEventListener(this.type,this.boundHandler)},e}();t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){var n=null,o=-1/0;return function(){for(var r=this,i=[],a=0;a<arguments.length;a++)i[a]=arguments[a];var u=Date.now(),s=function(){n=null,e.apply(r,i),o=u},l=u-o;l>=t?s():(clearTimeout(n),n=setTimeout(s,t-l))}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(58),r=n(57),i=n(56);function a(e,t){var n=new r.default(t);if(!n.target)return n;var i=function(t){return n.handler(t,e)};return n.throttle>0?n.boundHandler=o.default(i,n.throttle):n.boundHandler=i,n.target.addEventListener(n.type,n.boundHandler),n}t.bindEvent=a,t.default=function(e){return i.default(e.dom).map(a.bind(null,e))}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=function(){return function(){this.root="edd-root",this.rootOpen="edd-root-open",this.rootOpenAbove="edd-root-open-above",this.rootOpenBelow="edd-root-open-below",this.rootDisabled="edd-root-disabled",this.rootInvalid="edd-root-invalid",this.rootFocused="edd-root-focused",this.rootHasValue="edd-root-has-value",this.rootNative="edd-native",this.gradientTop="edd-gradient-top",this.gradientBottom="edd-gradient-bottom",this.head="edd-head",this.value="edd-value",this.arrow="edd-arrow",this.select="edd-select",this.body="edd-body",this.bodyScrollable="edd-body-scrollable",this.bodyAtTop="edd-body-at-top",this.bodyAtBottom="edd-body-at-bottom",this.itemsList="edd-items-list",this.group="edd-group",this.groupDisabled="edd-group-disabled",this.groupHasLabel="edd-group-has-label",this.groupLabel="edd-group-label",this.option="edd-option",this.optionDisabled="edd-option-disabled",this.optionFocused="edd-option-focused",this.optionSelected="edd-option-selected",Object.seal(this)}}();t.default=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=function(){return function(){this.onOpen=null,this.onClose=null,this.onSelect=null,Object.seal(this)}}();t.default=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=function(){return function(){this.showPlaceholderWhenOpen=!1,this.openOnFocus=!1,this.closeOnSelect=!1,this.useNativeUiOnMobile=!0,this.loop=!1,this.clampMaxVisibleItems=!0,this.liveUpdates=!1,this.maxVisibleItems=15,Object.seal(this)}}();t.default=o},function(e,t,n){"use strict";function o(e,t){for(var n=e.length>t.length?e:t,o=n===e?t:e,r=0,i=0,a=0,u=-1;r<n.length;r++){for(;0===a&&n[r]!==o[i]&&i<o.length;)i++;if(n[r]===o[i]){if(u!==r-1&&(a=0),u=r,i++,++a===o.length)break}else{if(a>1)break;a=i=0}}u=-1;for(var s=0,l=0,d=0,c=n.length-1,f=o.length-1;s<n.length-r;s++){for(;0===d&&n[c-s]!==o[f-l]&&l<o.length;)l++;if(n[c-s]===o[f-l])u!==s-1&&(d=0),u=s,d++,l++;else{if(d>1)break;d=l=0}}return Math.min(o.length,a+d)}Object.defineProperty(t,"__esModule",{value:!0}),t.getTotalMatching=o,t.default=function(e,t,n,r){if(Object.hasOwnProperty.call(t,n)||!Object.isSealed(t)||Object.isExtensible(t)||!(e instanceof TypeError))throw e;var i=function(e,t,n,r){var i=o(r.toLowerCase(),e),a=Math.abs(r.length-t.length);return i>n.totalMatching||i===n.totalMatching&&a<n.delta?{key:r,delta:a,totalMatching:i}:n}.bind(null,n,n.toLowerCase()),a={key:"",delta:1/0,totalMatching:0},u=Object.keys(t).reduce(i,a),s=u&&u.totalMatching>1?u.key:"";throw new TypeError(r(n,s))}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(18),r=function(){function e(){this.target=null,this.sources=[],this.config={}}return e.prototype.to=function(e){return this.target=e,this},e.prototype.from=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this.sources=e,this},e.prototype.with=function(e){return this.config=e,this},e.prototype.exec=function(){var e=this;return this.sources.reduce(function(t,n){return o.default(t,n,e.config)},this.target||{})},e}();t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(4),r=n(17),i=function(){return function(){this.deep=!1,this.useReferenceIfTargetUnset=!1,this.useReferenceIfArray=!1,this.includeReadOnly=!1,this.includeNonEmurable=!1,this.arrayStrategy=o.default.REPLACE,this.errorMessage=r.MERGE_ERROR,Object.seal(this)}}();t.default=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),r=n(16),i=n(59),a=n(43),u=n(0),s=n(30),l=n(29),d=n(28),c=n(27),f=n(26),p=n(24),h=n(19),v=n(21),b=function(){function e(e,t){this.config=o.default(new r.default,t,!0),this.state=p.default.mapFromSelect(e,this.config),this.renderer=new a.default(this.config.classNames),this.dom=this.renderer.render(this.state,e),this.timers=new v.default,this.actions=f.default.proxyActions(this.state,{closeOthers:d.default.bind(null,this,h.default),scrollToView:c.default.bind(null,this.dom,this.timers)},this.handleStateUpdate.bind(this)),this.eventBindings=i.default({actions:this.actions,config:this.config,dom:this.dom,state:this.state,timers:this.timers}),this.timers.pollChangeIntervalId=s.default(this.dom.select,this.state,this.actions),this.config.behavior.liveUpdates&&(this.timers.pollMutationIntervalId=l.default(this.dom.select,this.state,this.refresh.bind(this)))}return Object.defineProperty(e.prototype,"selectElement",{get:function(){return this.dom.select},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this.state.value},set:function(e){if("string"!=typeof e)throw new TypeError("[EasyDropDown] Provided value not a valid string");this.dom.select.value=e},enumerable:!0,configurable:!0}),e.prototype.open=function(){u.default(this.actions,this.config,this.dom)},e.prototype.close=function(){this.actions.close()},e.prototype.refresh=function(){this.state=o.default(this.state,p.default.mapFromSelect(this.dom.select,this.config)),this.renderer.update(this.state),this.dom.group.length=this.dom.option.length=this.dom.item.length=0,a.default.queryDomRefs(this.dom,["group","option","item"])},e.prototype.destroy=function(){this.timers.clear(),this.eventBindings.forEach(function(e){return e.unbind()}),this.renderer.destroy();var e=h.default.indexOf(this);h.default.splice(e,1)},e.prototype.handleStateUpdate=function(e,t){var n,o=this.config.callbacks;switch(this.renderer.update(e,t),t){case"bodyStatus":"function"==typeof(n=e.isOpen?o.onOpen:o.onClose)&&n();break;case"selectedIndex":"function"==typeof(n=o.onSelect)&&n(e.value)}},e}();t.default=b},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(19),r=n(66),i=n(20);function a(e,t){void 0===t&&(t={});var n=e;if("string"==typeof e&&(n=document.querySelector(e)),!(n instanceof HTMLSelectElement))throw new TypeError("[EasyDropDown] Invalid select element provided");if(n.multiple)throw new Error("[EasyDropDown] EasyDropDown does not support the `multiple` attribute on select elements.");for(var a=0,u=o.default;a<u.length;a++){var s=u[a];if(s.selectElement===n)return new i.default(s)}var l=new r.default(n,t);return o.default.push(l),new i.default(l)}var u,s=((u=a).all=function(e){void 0===e&&(e={});var t=document.querySelectorAll("select");Array.prototype.forEach.call(t,function(t){return a(t,e)})},u.destroy=function(){o.default.slice().forEach(function(e){return e.destroy()})},u);t.default=s},function(e,t){Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector)},function(e,t){try{var n=new window.CustomEvent("test");if(n.preventDefault(),!0!==n.defaultPrevented)throw new Error("Could not prevent default")}catch(e){var o=function(e,t){var n,o;return t=t||{bubbles:!1,cancelable:!1,detail:void 0},(n=document.createEvent("CustomEvent")).initCustomEvent(e,t.bubbles,t.cancelable,t.detail),o=n.preventDefault,n.preventDefault=function(){o.call(this);try{Object.defineProperty(this,"defaultPrevented",{get:function(){return!0}})}catch(e){this.defaultPrevented=!0}},n};o.prototype=window.Event.prototype,window.CustomEvent=o}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),n(69),n(68);var o=n(67);e.exports=o.default}])});
//# sourceMappingURL=easydropdown.js.map