diff --git a/demo/demoDist.js b/demo/demoDist.js index 7ca40ff..35612b7 100644 --- a/demo/demoDist.js +++ b/demo/demoDist.js @@ -1801,30 +1801,10 @@ var api = { var data = el.options; var classes = this.classes; - var _iteratorNormalCompletion = true; - var _didIteratorError = false; - var _iteratorError = undefined; - - try { - for (var _iterator = data[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { - var _el = _step.value; - - if (_el.selected && !_utils2.default.hasClass(_el, classes.PLACEHOLDER)) { - opts.push(_el); - } - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally { - try { - if (!_iteratorNormalCompletion && _iterator.return) { - _iterator.return(); - } - } finally { - if (_didIteratorError) { - throw _iteratorError; - } + for (var i = 0; i < data.length; i++) { + var _el = data[i]; + if (_el.selected && !_utils2.default.hasClass(_el, classes.PLACEHOLDER)) { + opts.push(_el); } } @@ -2539,33 +2519,13 @@ var build = { var data = []; var selectOptions = []; - var _iteratorNormalCompletion = true; - var _didIteratorError = false; - var _iteratorError = undefined; - - try { - for (var _iterator = target.children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { - var optionEl = _step.value; - - selectOptions.push(optionEl); - data.push({ - text: optionEl.innerHTML, - value: optionEl.value - }); - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally { - try { - if (!_iteratorNormalCompletion && _iterator.return) { - _iterator.return(); - } - } finally { - if (_didIteratorError) { - throw _iteratorError; - } - } + for (var i = 0; i < target.children.length; i++) { + var optionEl = target.children[i]; + selectOptions.push(optionEl); + data.push({ + text: optionEl.innerHTML, + value: optionEl.value + }); } refs.selectOptions = selectOptions; @@ -2603,29 +2563,9 @@ var build = { popInSelectElements: function popInSelectElements(select) { _utils2.default.removeAllChildren(select); - var _iteratorNormalCompletion2 = true; - var _didIteratorError2 = false; - var _iteratorError2 = undefined; - - try { - for (var _iterator2 = this.originalChildren[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { - var el = _step2.value; - - select.appendChild(el); - } - } catch (err) { - _didIteratorError2 = true; - _iteratorError2 = err; - } finally { - try { - if (!_iteratorNormalCompletion2 && _iterator2.return) { - _iterator2.return(); - } - } finally { - if (_didIteratorError2) { - throw _iteratorError2; - } - } + for (var i = 0; i < this.originalChildren.length; i++) { + var el = this.originalChildren[i]; + select.appendChild(el); } }, @@ -2634,7 +2574,7 @@ var build = { * ## popOutSelectElements * * pops out all the options of a select box, clones them, then appends the - * clones. This gives us the ability to restore the original tag + * clones. This gives us the ability to res``tore the original tag * * @param {DOMElement} select select element * @@ -5607,6 +5547,6 @@ exports.default = utils; 'use strict'; /* globals module */ -module.exports = '1.3.0'; +module.exports = '1.3.1'; },{}]},{},[1]); diff --git a/dist/flounder.amd.js b/dist/flounder.amd.js index fedf081..1a6aaaa 100644 --- a/dist/flounder.amd.js +++ b/dist/flounder.amd.js @@ -1,12 +1,12 @@ /*! - * Flounder JavaScript Stylable Selectbox v1.3.0 + * Flounder JavaScript Stylable Selectbox v1.3.1 * https://github.com/sociomantic-tsunami/flounder * * Copyright 2015-2017 Sociomantic Labs and other contributors * Released under the MIT license * https://github.com/sociomantic-tsunami/flounder/license * - * Date: Wed Oct 11 2017 + * Date: Fri Nov 03 2017 * * "This, so far, is the best Flounder ever" */(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;oc){for(var t=0,n=o.length-u;t "+t+") {","args = new Array(arguments.length + 1);","for (var i = 0; i < arguments.length; i++) {","args[i] = arguments[i];","}","}","return new Promise(function (rs, rj) {","var cb = "+o+";","var res;","switch (argLength) {",n.concat(["extra"]).map(function(e,t){return"case "+t+":res = fn.call("+["self"].concat(n.slice(0,t)).concat("cb").join(",")+");break;"}).join(""),"default:","args[argLength] = cb;","res = fn.apply(self, args);","}","if (res &&",'(typeof res === "object" || typeof res === "function") &&','typeof res.then === "function"',") {rs(res);}","});","};"].join("");return Function(["Promise","fn"],i)(r,e)}var r=e("./core.js"),a=e("asap");t.exports=r,r.denodeify=function(e,t){return"number"==typeof t&&t!==1/0?s(e,t):i(e)};var o="function (err, res) {if (err) { rj(err); } else { rs(res); }}";r.nodeify=function(e){return function(){var t=Array.prototype.slice.call(arguments),n="function"==typeof t[t.length-1]?t.pop():null,s=this;try{return e.apply(this,arguments).nodeify(n,s)}catch(i){if(null===n||"undefined"==typeof n)return new r(function(e,t){t(i)});a(function(){n.call(s,i)})}}},r.prototype.nodeify=function(e,t){return"function"!=typeof e?this:void this.then(function(n){a(function(){e.call(t,null,n)})},function(n){a(function(){e.call(t,n)})})}},{"./core.js":5,asap:1}],11:[function(e,t,n){"use strict";var s=e("./core.js");t.exports=s,s.enableSynchronous=function(){s.prototype.isPending=function(){return 0==this.getState()},s.prototype.isFulfilled=function(){return 1==this.getState()},s.prototype.isRejected=function(){return 2==this.getState()},s.prototype.getValue=function(){if(3===this._65)return this._55.getValue();if(!this.isFulfilled())throw new Error("Cannot get a value of an unfulfilled promise.");return this._55},s.prototype.getReason=function(){if(3===this._65)return this._55.getReason();if(!this.isRejected())throw new Error("Cannot get a rejection reason of a non-rejected promise.");return this._55},s.prototype.getState=function(){return 3===this._65?this._55.getState():this._65===-1||this._65===-2?0:this._65}},s.disableSynchronous=function(){s.prototype.isPending=void 0,s.prototype.isFulfilled=void 0,s.prototype.isRejected=void 0,s.prototype.getValue=void 0,s.prototype.getReason=void 0,s.prototype.getState=void 0}},{"./core.js":5}],12:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){var n=[],s=!0,i=!1,r=void 0;try{for(var a,o=e[Symbol.iterator]();!(s=(a=o.next()).done)&&(n.push(a.value),!t||n.length!==t);s=!0);}catch(l){i=!0,r=l}finally{try{!s&&o["return"]&&o["return"]()}finally{if(i)throw r}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),r=e("./utils"),a=s(r),o=e("./defaults"),l={buildFromUrl:function(e,t){var n=this;return this.loadDataFromUrl(e,function(e){n.data=e,t&&t(n.data),n.rebuild(n.data)}),[]},clickByIndex:function(e,t){return this.setByIndex(e,t,!1)},clickByText:function(e,t){return this.setByText(e,t,!1)},clickByValue:function(e,t){return this.setByValue(e,t,!1)},destroy:function(){this.componentWillUnmount();var e=this.refs,t=this.classes,n=this.originalTarget,s=n.tagName;if("INPUT"===s||"SELECT"===s){var i=n.nextElementSibling;if("SELECT"===s){var r=n[0];r&&a["default"].hasClass(r,t.PLACEHOLDER)&&n.removeChild(r)}else i=e.flounder.parentNode;try{var o=this.classes;i.parentNode.removeChild(i),n.tabIndex=0,a["default"].removeClass(n,o.HIDDEN)}catch(l){throw" : this flounder may have already been removed"}}else try{var u=e.wrapper,c=u.parentNode;c.removeChild(u)}catch(l){throw" : this flounder may have already been removed"}e.flounder.flounder=n.flounder=this.target.flounder=null},deselectAll:function(e){if(this.removeSelectedClass(),this.removeSelectedValue(),this.multiple){var t=this.refs.multiTagWrapper;if(t){for(var n=t.children,s=0;s2&&void 0!==arguments[2])||arguments[2],s=this.refs;if("string"!=typeof e&&e.length){var f=this.setByIndex.bind(this);return e.map(function(e){return f(e,t,n)})}var i=this.data,r=i.length;e<0&&(r=i.length,e=r+e);var a=s.data[e];return a?(this.forceMultiple=t&&this.multiple,this.programmaticClick=n,a.click(),a):null},setByText:function h(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof e&&e.length){var h=this.setByText.bind(this);return e.map(function(e){return h(e,t,n)})}var s=[];return e=""+e,this.refs.data.forEach(function(t,n){var i=t.innerHTML;i===e&&s.push(n)}),this.setByIndex(s,t,n)},setByValue:function p(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof e&&e.length){var p=this.setByValue.bind(this);return e.map(function(e){return p(e,t,n)})}var s=this.refs.selectOptions.map(function(t,n){return""+t.value==""+e?n:null}).filter(function(e){return 0===e||!!e});return this.setByIndex(s,t,n)}};n["default"]=l},{"./defaults":15,"./utils":20}],13:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r=e("./defaults"),a=e("./utils"),o=s(a),l={addOptionDescription:function(e,t){var n=document.createElement("div");n.innerHTML=t,n.className=this.classes.DESCRIPTION,e.appendChild(n)},addSearch:function(e){if(this.search){var t=this.classes,n=o["default"].constructElement({tagname:"input",type:"text",className:t.SEARCH,tabIndex:-1});return e.appendChild(n),n}return!1},bindThis:function(){var e=this;["addHoverClass","catchBodyClick","checkClickTarget","checkFlounderKeypress","checkMultiTagKeydown","clearPlaceholder","clickSet","divertTarget","displayMultipleTags","firstTouchController","fuzzySearch","removeHoverClass","removeMultiTag","setKeypress","setSelectValue","toggleList","toggleListSearchClick"].forEach(function(t){e[t]=e[t].bind(e),e[t].isBound=!0})},buildArrow:function(e,t){if(e.disableArrow)return!1;var n=this.classes,s=t({className:n.ARROW}),i=t({className:n.ARROW_INNER});return s.appendChild(i),s},buildData:function(e,t,n,s){function r(t,n){t.index=n;var s=n===e.index?" "+v:"",i={className:T.OPTION+s,"data-index":n};for(var r in t)"text"!==r&&"description"!==r&&(i[r]=t[r]);var a=p(i);return a.innerHTML=C?t.text:g(t.text),t.description&&l.addOptionDescription(a,t.description,T.DESCRIPTION),a.className+=t.extraClass?" "+t.extraClass:"",a.setAttribute("role","option"),a}function a(t,n){var i=void 0;if(E){var r=E.children[n];i=r,r.setAttribute("value",r.value),r.disabled===!0&&d[n]&&m(d[n],T.DISABLED),m(r,T.OPTION_TAG)}else{var a=t.extraClass||"",o=T.OPTION_TAG+" "+a;i=p({tagname:"option",className:o.trim(),value:t.value});var l=g(t.text);i.innerHTML=l;var u=t.disabled;u&&i.setAttribute("disabled",u),s.appendChild(i)}return n===e.index&&(i.selected=!0),i.getAttribute("disabled")&&m(d[n],T.DISABLED),i}var l=this,u=0,c=0,d=[],f=[],h=[],p=o["default"].constructElement,v=this.selectedClass,g=o["default"].escapeHTML,m=o["default"].addClass,y=this.refs,E=y.select,C=this.allowHTML,T=this.classes;return t.forEach(function(e,s){if("object"!==("undefined"==typeof e?"undefined":i(e))&&(e=t[s]={text:e,value:e}),e.header){var l=p({tagname:"div",className:T.SECTION}),v=p({tagname:"div",className:T.HEADER});v.textContent=e.header,l.appendChild(v),n.appendChild(l);var g=e.data;g.forEach(function(e,t){"object"!==("undefined"==typeof e?"undefined":i(e))&&(e=g[t]={text:e,value:e}),d[u]=r(e,u),l.appendChild(d[u]),f[u]=a(e,u),u++}),0==g.length&&o["default"].addClass(l,T.HIDDEN),h[c]=l,c++}else d[u]=r(e,u),n.appendChild(d[u]),f[u]=a(e,u),u++}),[d,f,h]},buildDom:function(){var e=this.props,t=this.classes;this.refs={};var n=o["default"].constructElement,s=o["default"].constructElement({className:t.MAIN_WRAPPER}),i=t.MAIN,a=this.multipleTags?i+" "+t.MULTIPLE_TAG_FLOUNDER:i,l=n({className:a});l.setAttribute("aria-hidden",!0),l.tabIndex=0,s.appendChild(l);var u=this.initSelectBox(s);u.tabIndex=-1;var c=this.data;this.defaultObj=(0,r.setDefaultOption)(this,this.props,c);var d=this.defaultObj,f=t.SELECTED_DISPLAYED;d.value&&d.extraClass&&(f+=" "+d.extraClass);var h=n({className:f,"data-value":d.value,"data-index":d.index}),p=this.multipleTags?n({className:t.MULTI_TAG_LIST}):null,v=n({className:t.OPTIONS_WRAPPER+" "+t.HIDDEN}),g=n({className:t.LIST});g.setAttribute("role","listbox"),v.appendChild(g),this.multiple===!0&&(u.setAttribute("multiple",""),g.setAttribute("aria-multiselectable","true"));var m=this.buildArrow(e,n);[h,p,v,m].forEach(function(e){e&&l.appendChild(e)});var y=this.addSearch(this.multipleTags?p:l),E=this.buildData(d,c,g,u);c=E[0];var C=E[1],T=E[2];if(this.target.appendChild(s),this.refs={wrapper:s,flounder:l,selected:h,arrow:m,optionsListWrapper:v,search:y,multiTagWrapper:p,optionsList:g,select:u,data:c,sections:T,selectOptions:C},this.multipleTags){var L=this.getSelected();0===L.length?h.innerHTML=d.text:this.displayMultipleTags(L,p)}else h.innerHTML=d.text},buildMultiTag:function(e){var t=this.classes,n=e.innerHTML,s=document.createElement("SPAN");s.className=t.MULTIPLE_SELECT_TAG,s.setAttribute("aria-label","Close"),s.setAttribute("tabindex",0);var i=document.createElement("A");return i.className=t.MULTIPLE_TAG_CLOSE,i.setAttribute("data-index",e.index),s.appendChild(i),s.innerHTML+=n,s},initSelectBox:function(e){var t=this.target,n=this.refs,s=n.select,i=this.classes;if("SELECT"===t.tagName){if(o["default"].addClass(t,i.SELECT_TAG),o["default"].addClass(t,i.HIDDEN),s=t,this.props.keepChangesOnDestroy||this.popOutSelectElements(s),t.length>0&&!this.selectDataOverride){this.refs.select=s;var r=[],a=[],l=!0,u=!1,c=void 0;try{for(var d,f=t.children[Symbol.iterator]();!(l=(d=f.next()).done);l=!0){var h=d.value;a.push(h),r.push({text:h.innerHTML,value:h.value})}}catch(p){u=!0,c=p}finally{try{!l&&f["return"]&&f["return"]()}finally{if(u)throw c}}n.selectOptions=a,this.data=r}else this.selectDataOverride&&o["default"].removeAllChildren(t);this.target=t.parentNode,o["default"].addClass(t,i.HIDDEN)}else s=o["default"].constructElement({tagname:"SELECT",className:i.SELECT_TAG+" "+i.HIDDEN}),e.appendChild(s);return s},popInSelectElements:function(e){o["default"].removeAllChildren(e);var t=!0,n=!1,s=void 0;try{for(var i,r=this.originalChildren[Symbol.iterator]();!(t=(i=r.next()).done);t=!0){var a=i.value;e.appendChild(a)}}catch(l){n=!0,s=l}finally{try{!t&&r["return"]&&r["return"]()}finally{if(n)throw s}}},popOutSelectElements:function(e){var t=[];this.originalChildren=e.children;for(var n=this.originalChildren,s=0;s=0?e[s]:null;return i?(i.index=s,i):null}function i(){var i=e.sortData(o);!a.multipleTags&&!a.multiple||a.defaultIndex||a.defaultValue||(a.placeholder=a.placeholder||l.placeholder),a.defaultEmpty&&(a.placeholder="");var r=a.placeholder;if(r||""===r||0===i.length)return n(e,i);var c=void 0;if(u){var d=e.refs.selected.getAttribute("data-value");if(c=s(i,d))return c}return c=a.defaultIndex?t(i):null,c=!c&&a.defaultValue?s(i):c,c=c?c:t(i,0)}var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments[2],u=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return o=o||a.data||[],i()}};n.setDefaultOption=u.setDefaultOption;n["default"]=u},{"./classes":14,"./utils":20}],16:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var i=e("./utils"),r=s(i),a=e("./keycodes"),o=s(a),l={addFirstTouchListeners:function(){var e=this.refs;e.selected.addEventListener("click",this.firstTouchController),e.select.addEventListener("focus",this.firstTouchController),this.props.openOnHover&&e.wrapper.addEventListener("mouseenter",this.firstTouchController)},addHoverClass:function(e){r["default"].addClass(e.target,this.classes.HOVER)},addListeners:function(e){var t=this.isIos,n=t?"blur":"change";if(e.select.addEventListener(n,this.divertTarget),e.flounder.addEventListener("keydown",this.checkFlounderKeypress),this.props.openOnHover){var s=e.wrapper;s.addEventListener("mouseenter",this.toggleList),s.addEventListener("mouseleave",this.toggleList)}else e.selected.addEventListener("click",this.toggleList);this.addFirstTouchListeners(),this.addOptionsListeners(),this.search&&this.addSearchListeners()},addMultipleTags:function(e,t){var n=this;e.forEach(function(e){if(""!==e.value){var s=n.buildMultiTag(e);t.insertBefore(s,t.lastChild)}else e.selected=!1});for(var s=t.children,i=0;i1)for(var o=0;o=48&&t<=57||t>=65&&t<=90)&&n.search&&"INPUT"===e.target.tagName&&(n.selected.innerHTML="")},checkMultiTagKeydown:function(e){var t=this,n=e.keyCode,s=e.target,i=[o["default"].BACKSPACE,o["default"].LEFT,o["default"].RIGHT];i.indexOf(n)!==-1?(e.preventDefault(),e.stopPropagation(),n===o["default"].BACKSPACE?this.checkMultiTagKeydownRemove(s):this.checkMultiTagKeydownNavigate(n,s)):e.key.length<2&&setTimeout(function(){return t.refs.search.focus()},0)},checkMultiTagKeydownNavigate:function(e,t){if(e===o["default"].LEFT){var n=t.previousSibling;n&&n.focus()}else if(e===o["default"].RIGHT){var s=t.nextSibling;s&&setTimeout(function(){return s.focus()},0)}},checkMultiTagKeydownRemove:function(e){var t=e.previousSibling,n=e.nextSibling;e.firstChild.click(),t?setTimeout(function(){return t.focus()},0):n&&n.focus()},clearPlaceholder:function(){this.refs.selected.innerHTML=""},clickSet:function(e){e.preventDefault(),e.stopPropagation(),this.setSelectValue({},e),this.programmaticClick||this.toggleList(e,"close"),this.programmaticClick=!1},displayMultipleTags:function(e,t){for(var n=t.children,s=0;s0?this.addMultipleTags(e,t):this.addPlaceholder()},displaySelected:function(e,t){var n=[],s=-1,i=this.getSelected(),r=i.length,a=this.multipleTags;if(e.className=this.classes.SELECTED_DISPLAYED,a||1!==r)if(a||0!==r)a?(e.innerHTML="",this.displayMultipleTags(i,t.multiTagWrapper)):e.innerHTML=this.multipleMessage,s=i.map(function(e){return e.index}),n=i.map(function(e){return e.value});else{var o=this.defaultObj;s=o.index||-1,e.innerHTML=o.text,n=o.value}else{s=i[0].index,e.innerHTML=t.data[s].innerHTML, -n=i[0].value;var l=t.data[s].extraClass;e.className+=l?" "+l:""}e.setAttribute("data-value",n),e.setAttribute("data-index",s)},divertTarget:function(e){if(this.isIos){var t=this.refs.select,n=this.classes,s=t.querySelector("."+n.PLUG);s&&t.removeChild(s)}var i=e.target.selectedIndex,r={type:e.type,target:this.data[i]};this.multipleTags&&(e.preventDefault(),e.stopPropagation()),this.setSelectValue(r),this.multiple||this.toggleList(e,"close")},firstTouchController:function(e){var t=this.refs;if(this.onFirstTouch)try{this.onFirstTouch(e)}catch(e){console.warn('something may be wrong in "onFirstTouch"',e)}t.selected.removeEventListener("click",this.firstTouchController),t.select.removeEventListener("focus",this.firstTouchController),this.props.openOnHover&&t.wrapper.removeEventListener("mouseenter",this.firstTouchController)},hideEmptySection:function(e){for(var t=this.selectedClass,n=this.refs.sections,s=0;sa?o=0:o<0&&(o=a);var l=this.classes,u=r["default"].hasClass,c=i[o];s.selectedIndex=o,(u(c,l.HIDDEN)||u(c,l.SELECTED_HIDDEN)||u(c,l.SEARCH_HIDDEN)||u(c,l.DISABLED))&&this.setKeypress(e)},setSelectValue:function(e,t){var n=this.refs,s=void 0;if(t?this.setSelectValueClick(t):(s=e.keyCode,this.setSelectValueButton(e)),this.displaySelected(n.selected,n),!this.programmaticClick){var i=[9,16,17,18,20,91];if(t||"blur"===e.type||!s&&"change"===e.type||s&&i.indexOf(s)===-1)if(this.toggleList.justOpened&&!t)this.toggleList.justOpened=!1;else if(this.onChange)try{this.onChange(t,this.getSelectedValues())}catch(t){console.warn("something may be wrong in onChange",t)}this.programmaticClick=!1}},setSelectValueButton:function(){var e=this.refs,t=e.data,n=this.selectedClass,s=void 0;if(this.multipleTags)return!1;this.removeSelectedClass(t);var i=this.getSelected(),a=i[0];a&&(s=t[a.index],r["default"].addClass(s,n),r["default"].scrollTo(s,e.optionsListWrapper))},setSelectValueClick:function(e){var t=this.multiple,n=this.refs,s=this.selectedClass,i=e.target,a=i.getAttribute("data-index"),o=n.selectOptions[a];t&&(!t||this.multipleTags||e[this.multiSelect])||this.forceMultiple?(r["default"].toggleClass(i,s),o.selected=!o.selected):(this.deselectAll(),r["default"].addClass(i,s),o.selected=o.selected!==!0),this.forceMultiple=!1,this.hideEmptySection(i.parentNode);var l=n.selectOptions[0];""===l.value&&this.getSelected().length>1&&(r["default"].removeClass(n.data[0],s),n.selectOptions[0].selected=!1)},toggleClosed:function(e,t,n,s){var i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],a=this.classes;r["default"].addClass(n.optionsListWrapper,a.HIDDEN),r["default"].removeClass(s,a.OPEN);var o=document.querySelector("html");if(o.removeEventListener("click",this.catchBodyClick),o.removeEventListener("touchend",this.catchBodyClick),this.search?this.fuzzySearchReset():this.removeSelectKeyListener(),i||setTimeout(function(){return n.flounder.focus()},0),this.onClose&&this.ready)try{this.onClose(e,this.getSelectedValues())}catch(e){console.warn('something may be wrong in "onClose"',e)}},toggleList:function(e,t){var n=this.classes,s=this.refs,i=s.optionsListWrapper,a=s.wrapper,o=r["default"].hasClass(i,n.HIDDEN),l=e.type;"mouseleave"!==l&&"close"!==t&&o?("keydown"===l&&(this.toggleList.justOpened=!0),this.toggleOpen(e,i,s,a)):(this.toggleList.justOpened=!1,this.toggleClosed(e,i,s,a))},toggleListSearchClick:function(e){var t=this.classes;r["default"].hasClass(this.refs.wrapper,t.OPEN)||this.toggleList(e,"open")},toggleOpen:function(e,t,n){if(!this.isIos||this.search||this.multipleTags===!0){var s=this.classes;r["default"].removeClass(n.optionsListWrapper,s.HIDDEN),r["default"].addClass(n.wrapper,s.OPEN);var i=document.querySelector("html");i.addEventListener("click",this.catchBodyClick),i.addEventListener("touchend",this.catchBodyClick)}if(!this.multipleTags){var a=n.select.selectedIndex,o=n.data[a];r["default"].scrollTo(o,n.optionsListWrapper)}this.search?setTimeout(function(){return n.search.focus()},0):(this.addSelectKeyListener(),setTimeout(function(){return n.select.focus()},0));var l=n.data.length;if(this.props.placeholder&&l--,n.multiTagWrapper){var u=n.multiTagWrapper.children.length-1;u===l&&(this.removeNoResultsMessage(),this.addNoMoreOptionsMessage())}if(this.onOpen&&this.ready)try{this.onOpen(e,this.getSelectedValues())}catch(e){console.warn('something may be wrong in "onOpen"',e)}}};n["default"]=l},{"./keycodes":18,"./utils":20}],17:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}function i(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t1)console.warn("Flounder - More than one element found.\n Dropping all but the first.");else if(0===t.length)throw"Flounder - No target element found.";t=t[0]}return t.flounder&&t.flounder.destroy(),this.init(t,n)}console.warn("Flounder - No target element found.")}return o(e,[{key:"componentWillUnmount",value:function(){if(this.onComponentWillUnmount)try{this.onComponentWillUnmount()}catch(e){console.warn('something may be wrong in "onComponentWillUnmount"',e)}this.removeListeners(),this.originalChildren&&this.popInSelectElements(this.refs.select)}}]),o(e,[{key:"filterSearchResults",value:function(e){var t=e.target.value.trim();this.fuzzySearch.previousValue=t;var n=this.search.isThereAnythingRelatedTo(t)||[];if(""!==t){var s=this.refs.data,i=this.refs.sections,r=this.classes;s.forEach(function(e){c["default"].addClass(e,r.SEARCH_HIDDEN)}),i.forEach(function(e){c["default"].addClass(e,r.SEARCH_HIDDEN)}),n.forEach(function(e){c["default"].removeClass(s[e.i],r.SEARCH_HIDDEN),"number"==typeof e.d.s&&c["default"].removeClass(i[e.d.s],r.SEARCH_HIDDEN)}),this.refs.noMoreOptionsEl||(0===n.length?this.addNoResultsMessage():this.removeNoResultsMessage())}else this.fuzzySearchReset()}},{key:"fuzzySearch",value:function(e){if(this.fuzzySearch.previousValue=this.fuzzySearch.previousValue||"",this.onInputChange)try{this.onInputChange(e)}catch(e){console.warn('something may be wrong in "onInputChange"',e)}if(this.toggleList.justOpened)this.toggleList.justOpened=!1;else{e.preventDefault();var t=e.keyCode;if(t!==L["default"].UP&&t!==L["default"].DOWN&&t!==L["default"].ENTER&&t!==L["default"].ESCAPE)if(this.multipleTags&&t===L["default"].BACKSPACE&&""===this.fuzzySearch.previousValue){var n=this.refs.search.previousSibling;n&&setTimeout(function(){return n.focus()},0)}else this.filterSearchResults(e);else t!==L["default"].ESCAPE&&t!==L["default"].ENTER||(this.fuzzySearchReset(),this.toggleList(e,"close"),this.addPlaceholder())}}},{key:"fuzzySearchReset",value:function(){var e=this.refs,t=this.classes;e.sections.forEach(function(e){c["default"].removeClass(e,t.SEARCH_HIDDEN)}),e.data.forEach(function(e){c["default"].removeClass(e,t.SEARCH_HIDDEN)}),e.search.value="",this.removeNoResultsMessage()}},{key:"init",value:function(e,t){if(this.props=t,this.bindThis(),this.initializeOptions(),this.setTarget(e),this.search&&(this.search=new y["default"](this)),this.onInit)try{this.onInit()}catch(n){console.warn('something may be wrong in "onInit"',n)}this.buildDom();var s=c["default"].setPlatform(),i=s.isOsx,r=s.isIos,a=s.multiSelect;if(this.isOsx=i,this.isIos=r,this.multiSelect=a,this.onRender(),this.onComponentDidMount)try{this.onComponentDidMount()}catch(n){console.warn("something may be wrong in onComponentDidMount",n)}return this.ready=!0,this.originalTarget.flounder=this.target.flounder=this,this.refs.flounder.flounder=this}},{key:"initializeOptions",value:function(){var e=this.props=this.props||{};for(var t in l.defaultOptions)if("onChange"===t&&e.onSelect)this.onChange=e.onSelect,console.warn("Please use onChange. onSelect has been\n depricated and will be removed in 2.0.0"),this.onSelect=function(){console.warn("Please use onChange. onSelect has been\n depricated and will be removed in 2.0.0"),this.onChange.apply(this,arguments)};else if("classes"===t){this.classes={};var n=l.defaultOptions[t],s="object"===a(e[t])?e[t]:{};for(var r in n)this.classes[r]=s[r]?s[r]:n[r]}else"data"===t?this.data=e.data&&e.data.length?[].concat(i(e.data)):[].concat(i(l.defaultOptions.data)):this[t]=void 0!==e[t]?e[t]:l.defaultOptions[t];this.selectedClass=this.classes.SELECTED,e.defaultEmpty&&(this.placeholder=""),this.multipleTags&&(this.search=!0,this.multiple=!0,this.selectedClass+=" "+this.classes.SELECTED_HIDDEN)}},{key:"onRender",value:function(){var e=this.props,t=this.refs;if(this.isIos&&!this.multiple){var n=t.select,s=this.classes;c["default"].removeClass(n,s.HIDDEN),c["default"].addClass(n,s.HIDDEN_IOS)}this.addListeners(t,e)}},{key:"sortData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=this,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,r=0;return e.forEach(function(e){e.header?(t=n.sortData(e.data,t,s,r),r++):("object"!==("undefined"==typeof e?"undefined":a(e))?e={text:e,value:e,index:s}:e.index=s,void 0!==i&&(e.s=i),t.push(e),s++)}),t}}]),e}();S.find=function(e,t){return"string"==typeof e?e=document.querySelectorAll(e):1===e.nodeType&&(e=[e]),Array.prototype.slice.call(e,0).map(function(e){return new S(e,t)})},Object.defineProperty(S,"version",{get:function(){return C["default"]}}),Object.defineProperty(S.prototype,"version",{get:function(){return C["default"]}}),c["default"].extendClass(S,f["default"],p["default"],g["default"]),n["default"]=S},{"./api":12,"./build":13,"./defaults":15,"./events":16,"./keycodes":18,"./search":19,"./utils":20,"./version":21}],18:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var s={BACKSPACE:8,DOWN:40,ENTER:13,ESCAPE:27,LEFT:37,RIGHT:39,SPACE:32,TAB:9,UP:38,NON_CHARACTER_KEYS:[16,17,18,20,91,93]};n["default"]=s},{}],19:[function(e,t,n){"use strict";function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;nt?1:e=r.minimumScore}},{key:"isThereAnythingRelatedTo",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=void 0;if(e=e.length?e:""+e,!(e.length>=r.minimumValueLength))return!1;this.query=e.toLowerCase().split(" ");var n=this.flounder.data;return n=this.flounder.sortData(n),t=this.ratedRes=n.map(this.getResultWeights),t=t.filter(this.isItemAboveMinimum),t.sort(this.compareScoreCards),this.ratedRes=t}},{key:"startsWith",value:function(e,t,n){var s=t.length,i=e.length;if(i<=s){var r=t.toLowerCase().slice(0,i);if(r===e)return n}return 0}},{key:"scoreThis",value:function(e,t,n){var s=this,i=0;return e&&this.query.forEach(function(r){r=s.escapeRegExp(r);var a=0;"string"==typeof e?(r=new RegExp(r,"g"),a=(e.match(r)||[]).length):e[0]?e.forEach(function(e){a+=e.indexOf(r)!==-1?1:0}):a=e[r]||1e-6,a>0?i=t*a*10:n!==!0&&(i=-t)}),Math.floor(i)}}]),e}();n["default"]=a},{}],20:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var i=e("microbejs/src/modules/http"),r=s(i),a={addClass:function(e,t){if("string"!=typeof t&&t.length)return t.forEach(function(t){a.addClass(e,t)}),!0;var n=e.className,s=n.length,i=n.slice(s-t.length-1,s);a.hasClass(e,t)||n.slice(0,t.length+1)===t+" "||i===" "+t||(n+=" "+t),e.className=n.trim()},attachAttributes:function(e,t){if(!t)return null;for(var n in t)"data-"===n.slice(0,5)?e.setAttribute(n,t[n]):e[n]=t[n]},constructElement:function(e){var t=document.createElement(e.tagname||"div");return a.attachAttributes(t,e),t},debounce:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this,s=void 0,i=void 0,r=function(){return e.apply(n,s)};return function(){clearTimeout(i),s=arguments,i=setTimeout(r,t)}},extendClass:function(e){function t(t){for(var n in t)e[n]=t[n]}e=e.prototype;for(var n=arguments.length,s=Array(n>1?n-1:0),i=1;i/g,">").replace(/"/g,""")},getElWidth:function(e,t,n){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1500,i=window.getComputedStyle(e);if(0===e.offsetWidth&&this.checkWidthAgain!==!0){if(!t||!n)throw"Flounder getElWidth error: no callback given.";setTimeout(t.bind(n),s),this.checkWidthAgain=!0}else this.checkWidthAgain=!1;return e.offsetWidth+parseInt(i["margin-left"])+parseInt(i["margin-right"])},hasClass:function(e,t){var n=e.className,s=new RegExp("(^"+t+" )|( "+t+"$)|( "+t+" )|(^"+t+"$)");return!!n.match(s)},http:!1,iosVersion:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window;return!!/iPad|iPhone|iPod/.test(e.navigator.platform)&&(e.indexedDB?"8+":e.SpeechSynthesisUtterance?"7":e.webkitAudioContext?"6":"5-")},removeAllChildren:function(e){Array.prototype.slice.call(e.children,0).forEach(function(t){e.removeChild(t)})},removeClass:function(e,t){if("string"!=typeof t&&t.length)return t.forEach(function(t){a.removeClass(e,t)}),!0;var n=e.className,s=n.length,i=t.length;n===t?n="":n.slice(0,i+1)===t+" "?n=n.slice(i+1,s):n.slice(s-i-1,s)===" "+t?n=n.slice(0,s-i-1):n.indexOf(" "+t+" ")!==-1&&(n=n.replace(" "+t+" "," ")),e.className=n.trim()},scrollTo:function(e,t){if(e){var n=t||e.offsetParent;if(n.scrollHeight>n.offsetHeight){var s=e.offsetTop,i=e.offsetHeight,r=n.offsetHeight,a=n.scrollTop,o=a+n.offsetHeight-i;so&&(n.scrollTop=s-(r-i))}}return!1},setPlatform:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window,t=e.navigator.platform,n=t.indexOf("Mac")!==-1,s=a.iosVersion(e),i=n?"metaKey":"ctrlKey";return{isOsx:n,isIos:s,multiSelect:i}},toggleClass:function(e,t){a.hasClass(e,t)?a.removeClass(e,t):a.addClass(e,t)}};(0,r["default"])(a),n["default"]=a},{"microbejs/src/modules/http":3}],21:[function(e,t,n){"use strict";t.exports="1.3.0"},{}],22:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}var i=e("../core/flounder"),r=s(i);define("flounder",[],function(){return r["default"]})},{"../core/flounder":17}]},{},[22]); \ No newline at end of file +/*! Flounder v1.3.1 | (c) 2015-2017 Sociomantic Labs | https://github.com/sociomantic-tsunami/flounder/license */!function e(t,n,s){function i(a,o){if(!n[a]){if(!t[a]){var l="function"==typeof require&&require;if(!o&&l)return l(a,!0);if(r)return r(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var c=n[a]={exports:{}};t[a][0].call(c.exports,function(e){var n=t[a][1][e];return i(n?n:e)},c,c.exports,e,t,n,s)}return n[a].exports}for(var r="function"==typeof require&&require,a=0;ac){for(var t=0,n=o.length-u;t "+t+") {","args = new Array(arguments.length + 1);","for (var i = 0; i < arguments.length; i++) {","args[i] = arguments[i];","}","}","return new Promise(function (rs, rj) {","var cb = "+o+";","var res;","switch (argLength) {",n.concat(["extra"]).map(function(e,t){return"case "+t+":res = fn.call("+["self"].concat(n.slice(0,t)).concat("cb").join(",")+");break;"}).join(""),"default:","args[argLength] = cb;","res = fn.apply(self, args);","}","if (res &&",'(typeof res === "object" || typeof res === "function") &&','typeof res.then === "function"',") {rs(res);}","});","};"].join("");return Function(["Promise","fn"],i)(r,e)}var r=e("./core.js"),a=e("asap");t.exports=r,r.denodeify=function(e,t){return"number"==typeof t&&t!==1/0?s(e,t):i(e)};var o="function (err, res) {if (err) { rj(err); } else { rs(res); }}";r.nodeify=function(e){return function(){var t=Array.prototype.slice.call(arguments),n="function"==typeof t[t.length-1]?t.pop():null,s=this;try{return e.apply(this,arguments).nodeify(n,s)}catch(i){if(null===n||"undefined"==typeof n)return new r(function(e,t){t(i)});a(function(){n.call(s,i)})}}},r.prototype.nodeify=function(e,t){return"function"!=typeof e?this:void this.then(function(n){a(function(){e.call(t,null,n)})},function(n){a(function(){e.call(t,n)})})}},{"./core.js":5,asap:1}],11:[function(e,t,n){"use strict";var s=e("./core.js");t.exports=s,s.enableSynchronous=function(){s.prototype.isPending=function(){return 0==this.getState()},s.prototype.isFulfilled=function(){return 1==this.getState()},s.prototype.isRejected=function(){return 2==this.getState()},s.prototype.getValue=function(){if(3===this._65)return this._55.getValue();if(!this.isFulfilled())throw new Error("Cannot get a value of an unfulfilled promise.");return this._55},s.prototype.getReason=function(){if(3===this._65)return this._55.getReason();if(!this.isRejected())throw new Error("Cannot get a rejection reason of a non-rejected promise.");return this._55},s.prototype.getState=function(){return 3===this._65?this._55.getState():this._65===-1||this._65===-2?0:this._65}},s.disableSynchronous=function(){s.prototype.isPending=void 0,s.prototype.isFulfilled=void 0,s.prototype.isRejected=void 0,s.prototype.getValue=void 0,s.prototype.getReason=void 0,s.prototype.getState=void 0}},{"./core.js":5}],12:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){var n=[],s=!0,i=!1,r=void 0;try{for(var a,o=e[Symbol.iterator]();!(s=(a=o.next()).done)&&(n.push(a.value),!t||n.length!==t);s=!0);}catch(l){i=!0,r=l}finally{try{!s&&o["return"]&&o["return"]()}finally{if(i)throw r}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),r=e("./utils"),a=s(r),o=e("./defaults"),l={buildFromUrl:function(e,t){var n=this;return this.loadDataFromUrl(e,function(e){n.data=e,t&&t(n.data),n.rebuild(n.data)}),[]},clickByIndex:function(e,t){return this.setByIndex(e,t,!1)},clickByText:function(e,t){return this.setByText(e,t,!1)},clickByValue:function(e,t){return this.setByValue(e,t,!1)},destroy:function(){this.componentWillUnmount();var e=this.refs,t=this.classes,n=this.originalTarget,s=n.tagName;if("INPUT"===s||"SELECT"===s){var i=n.nextElementSibling;if("SELECT"===s){var r=n[0];r&&a["default"].hasClass(r,t.PLACEHOLDER)&&n.removeChild(r)}else i=e.flounder.parentNode;try{var o=this.classes;i.parentNode.removeChild(i),n.tabIndex=0,a["default"].removeClass(n,o.HIDDEN)}catch(l){throw" : this flounder may have already been removed"}}else try{var u=e.wrapper,c=u.parentNode;c.removeChild(u)}catch(l){throw" : this flounder may have already been removed"}e.flounder.flounder=n.flounder=this.target.flounder=null},deselectAll:function(e){if(this.removeSelectedClass(),this.removeSelectedValue(),this.multiple){var t=this.refs.multiTagWrapper;if(t){for(var n=t.children,s=0;s2&&void 0!==arguments[2])||arguments[2],s=this.refs;if("string"!=typeof e&&e.length){var h=this.setByIndex.bind(this);return e.map(function(e){return h(e,t,n)})}var i=this.data,r=i.length;e<0&&(r=i.length,e=r+e);var a=s.data[e];return a?(this.forceMultiple=t&&this.multiple,this.programmaticClick=n,a.click(),a):null},setByText:function f(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof e&&e.length){var f=this.setByText.bind(this);return e.map(function(e){return f(e,t,n)})}var s=[];return e=""+e,this.refs.data.forEach(function(t,n){var i=t.innerHTML;i===e&&s.push(n)}),this.setByIndex(s,t,n)},setByValue:function p(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof e&&e.length){var p=this.setByValue.bind(this);return e.map(function(e){return p(e,t,n)})}var s=this.refs.selectOptions.map(function(t,n){return""+t.value==""+e?n:null}).filter(function(e){return 0===e||!!e});return this.setByIndex(s,t,n)}};n["default"]=l},{"./defaults":15,"./utils":20}],13:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r=e("./defaults"),a=e("./utils"),o=s(a),l={addOptionDescription:function(e,t){var n=document.createElement("div");n.innerHTML=t,n.className=this.classes.DESCRIPTION,e.appendChild(n)},addSearch:function(e){if(this.search){var t=this.classes,n=o["default"].constructElement({tagname:"input",type:"text",className:t.SEARCH,tabIndex:-1});return e.appendChild(n),n}return!1},bindThis:function(){var e=this;["addHoverClass","catchBodyClick","checkClickTarget","checkFlounderKeypress","checkMultiTagKeydown","clearPlaceholder","clickSet","divertTarget","displayMultipleTags","firstTouchController","fuzzySearch","removeHoverClass","removeMultiTag","setKeypress","setSelectValue","toggleList","toggleListSearchClick"].forEach(function(t){e[t]=e[t].bind(e),e[t].isBound=!0})},buildArrow:function(e,t){if(e.disableArrow)return!1;var n=this.classes,s=t({className:n.ARROW}),i=t({className:n.ARROW_INNER});return s.appendChild(i),s},buildData:function(e,t,n,s){function r(t,n){t.index=n;var s=n===e.index?" "+v:"",i={className:T.OPTION+s,"data-index":n};for(var r in t)"text"!==r&&"description"!==r&&(i[r]=t[r]);var a=p(i);return a.innerHTML=C?t.text:g(t.text),t.description&&l.addOptionDescription(a,t.description,T.DESCRIPTION),a.className+=t.extraClass?" "+t.extraClass:"",a.setAttribute("role","option"),a}function a(t,n){var i=void 0;if(E){var r=E.children[n];i=r,r.setAttribute("value",r.value),r.disabled===!0&&d[n]&&m(d[n],T.DISABLED),m(r,T.OPTION_TAG)}else{var a=t.extraClass||"",o=T.OPTION_TAG+" "+a;i=p({tagname:"option",className:o.trim(),value:t.value});var l=g(t.text);i.innerHTML=l;var u=t.disabled;u&&i.setAttribute("disabled",u),s.appendChild(i)}return n===e.index&&(i.selected=!0),i.getAttribute("disabled")&&m(d[n],T.DISABLED),i}var l=this,u=0,c=0,d=[],h=[],f=[],p=o["default"].constructElement,v=this.selectedClass,g=o["default"].escapeHTML,m=o["default"].addClass,y=this.refs,E=y.select,C=this.allowHTML,T=this.classes;return t.forEach(function(e,s){if("object"!==("undefined"==typeof e?"undefined":i(e))&&(e=t[s]={text:e,value:e}),e.header){var l=p({tagname:"div",className:T.SECTION}),v=p({tagname:"div",className:T.HEADER});v.textContent=e.header,l.appendChild(v),n.appendChild(l);var g=e.data;g.forEach(function(e,t){"object"!==("undefined"==typeof e?"undefined":i(e))&&(e=g[t]={text:e,value:e}),d[u]=r(e,u),l.appendChild(d[u]),h[u]=a(e,u),u++}),0==g.length&&o["default"].addClass(l,T.HIDDEN),f[c]=l,c++}else d[u]=r(e,u),n.appendChild(d[u]),h[u]=a(e,u),u++}),[d,h,f]},buildDom:function(){var e=this.props,t=this.classes;this.refs={};var n=o["default"].constructElement,s=o["default"].constructElement({className:t.MAIN_WRAPPER}),i=t.MAIN,a=this.multipleTags?i+" "+t.MULTIPLE_TAG_FLOUNDER:i,l=n({className:a});l.setAttribute("aria-hidden",!0),l.tabIndex=0,s.appendChild(l);var u=this.initSelectBox(s);u.tabIndex=-1;var c=this.data;this.defaultObj=(0,r.setDefaultOption)(this,this.props,c);var d=this.defaultObj,h=t.SELECTED_DISPLAYED;d.value&&d.extraClass&&(h+=" "+d.extraClass);var f=n({className:h,"data-value":d.value,"data-index":d.index}),p=this.multipleTags?n({className:t.MULTI_TAG_LIST}):null,v=n({className:t.OPTIONS_WRAPPER+" "+t.HIDDEN}),g=n({className:t.LIST});g.setAttribute("role","listbox"),v.appendChild(g),this.multiple===!0&&(u.setAttribute("multiple",""),g.setAttribute("aria-multiselectable","true"));var m=this.buildArrow(e,n);[f,p,v,m].forEach(function(e){e&&l.appendChild(e)});var y=this.addSearch(this.multipleTags?p:l),E=this.buildData(d,c,g,u);c=E[0];var C=E[1],T=E[2];if(this.target.appendChild(s),this.refs={wrapper:s,flounder:l,selected:f,arrow:m,optionsListWrapper:v,search:y,multiTagWrapper:p,optionsList:g,select:u,data:c,sections:T,selectOptions:C},this.multipleTags){var L=this.getSelected();0===L.length?f.innerHTML=d.text:this.displayMultipleTags(L,p)}else f.innerHTML=d.text},buildMultiTag:function(e){var t=this.classes,n=e.innerHTML,s=document.createElement("SPAN");s.className=t.MULTIPLE_SELECT_TAG,s.setAttribute("aria-label","Close"),s.setAttribute("tabindex",0);var i=document.createElement("A");return i.className=t.MULTIPLE_TAG_CLOSE,i.setAttribute("data-index",e.index),s.appendChild(i),s.innerHTML+=n,s},initSelectBox:function(e){var t=this.target,n=this.refs,s=n.select,i=this.classes;if("SELECT"===t.tagName){if(o["default"].addClass(t,i.SELECT_TAG),o["default"].addClass(t,i.HIDDEN),s=t,this.props.keepChangesOnDestroy||this.popOutSelectElements(s),t.length>0&&!this.selectDataOverride){this.refs.select=s;for(var r=[],a=[],l=0;l=0?e[s]:null;return i?(i.index=s,i):null}function i(){var i=e.sortData(o);!a.multipleTags&&!a.multiple||a.defaultIndex||a.defaultValue||(a.placeholder=a.placeholder||l.placeholder),a.defaultEmpty&&(a.placeholder="");var r=a.placeholder;if(r||""===r||0===i.length)return n(e,i);var c=void 0;if(u){var d=e.refs.selected.getAttribute("data-value");if(c=s(i,d))return c}return c=a.defaultIndex?t(i):null,c=!c&&a.defaultValue?s(i):c,c=c?c:t(i,0)}var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments[2],u=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return o=o||a.data||[],i()}};n.setDefaultOption=u.setDefaultOption;n["default"]=u},{"./classes":14,"./utils":20}],16:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var i=e("./utils"),r=s(i),a=e("./keycodes"),o=s(a),l={addFirstTouchListeners:function(){var e=this.refs;e.selected.addEventListener("click",this.firstTouchController),e.select.addEventListener("focus",this.firstTouchController),this.props.openOnHover&&e.wrapper.addEventListener("mouseenter",this.firstTouchController)},addHoverClass:function(e){r["default"].addClass(e.target,this.classes.HOVER)},addListeners:function(e){var t=this.isIos,n=t?"blur":"change";if(e.select.addEventListener(n,this.divertTarget),e.flounder.addEventListener("keydown",this.checkFlounderKeypress),this.props.openOnHover){var s=e.wrapper;s.addEventListener("mouseenter",this.toggleList),s.addEventListener("mouseleave",this.toggleList)}else e.selected.addEventListener("click",this.toggleList);this.addFirstTouchListeners(),this.addOptionsListeners(),this.search&&this.addSearchListeners()},addMultipleTags:function(e,t){var n=this;e.forEach(function(e){if(""!==e.value){var s=n.buildMultiTag(e);t.insertBefore(s,t.lastChild)}else e.selected=!1});for(var s=t.children,i=0;i1)for(var o=0;o=48&&t<=57||t>=65&&t<=90)&&n.search&&"INPUT"===e.target.tagName&&(n.selected.innerHTML="")},checkMultiTagKeydown:function(e){var t=this,n=e.keyCode,s=e.target,i=[o["default"].BACKSPACE,o["default"].LEFT,o["default"].RIGHT];i.indexOf(n)!==-1?(e.preventDefault(),e.stopPropagation(),n===o["default"].BACKSPACE?this.checkMultiTagKeydownRemove(s):this.checkMultiTagKeydownNavigate(n,s)):e.key.length<2&&setTimeout(function(){return t.refs.search.focus()},0)},checkMultiTagKeydownNavigate:function(e,t){if(e===o["default"].LEFT){var n=t.previousSibling;n&&n.focus()}else if(e===o["default"].RIGHT){var s=t.nextSibling;s&&setTimeout(function(){return s.focus()},0)}},checkMultiTagKeydownRemove:function(e){var t=e.previousSibling,n=e.nextSibling;e.firstChild.click(),t?setTimeout(function(){return t.focus()},0):n&&n.focus()},clearPlaceholder:function(){this.refs.selected.innerHTML=""},clickSet:function(e){e.preventDefault(),e.stopPropagation(),this.setSelectValue({},e),this.programmaticClick||this.toggleList(e,"close"),this.programmaticClick=!1},displayMultipleTags:function(e,t){for(var n=t.children,s=0;s0?this.addMultipleTags(e,t):this.addPlaceholder()},displaySelected:function(e,t){var n=[],s=-1,i=this.getSelected(),r=i.length,a=this.multipleTags;if(e.className=this.classes.SELECTED_DISPLAYED,a||1!==r)if(a||0!==r)a?(e.innerHTML="",this.displayMultipleTags(i,t.multiTagWrapper)):e.innerHTML=this.multipleMessage,s=i.map(function(e){return e.index}),n=i.map(function(e){return e.value});else{var o=this.defaultObj;s=o.index||-1,e.innerHTML=o.text,n=o.value}else{s=i[0].index,e.innerHTML=t.data[s].innerHTML,n=i[0].value;var l=t.data[s].extraClass;e.className+=l?" "+l:""}e.setAttribute("data-value",n),e.setAttribute("data-index",s)},divertTarget:function(e){if(this.isIos){var t=this.refs.select,n=this.classes,s=t.querySelector("."+n.PLUG);s&&t.removeChild(s)}var i=e.target.selectedIndex,r={type:e.type,target:this.data[i]};this.multipleTags&&(e.preventDefault(),e.stopPropagation()),this.setSelectValue(r), +this.multiple||this.toggleList(e,"close")},firstTouchController:function(e){var t=this.refs;if(this.onFirstTouch)try{this.onFirstTouch(e)}catch(e){console.warn('something may be wrong in "onFirstTouch"',e)}t.selected.removeEventListener("click",this.firstTouchController),t.select.removeEventListener("focus",this.firstTouchController),this.props.openOnHover&&t.wrapper.removeEventListener("mouseenter",this.firstTouchController)},hideEmptySection:function(e){for(var t=this.selectedClass,n=this.refs.sections,s=0;sa?o=0:o<0&&(o=a);var l=this.classes,u=r["default"].hasClass,c=i[o];s.selectedIndex=o,(u(c,l.HIDDEN)||u(c,l.SELECTED_HIDDEN)||u(c,l.SEARCH_HIDDEN)||u(c,l.DISABLED))&&this.setKeypress(e)},setSelectValue:function(e,t){var n=this.refs,s=void 0;if(t?this.setSelectValueClick(t):(s=e.keyCode,this.setSelectValueButton(e)),this.displaySelected(n.selected,n),!this.programmaticClick){var i=[9,16,17,18,20,91];if(t||"blur"===e.type||!s&&"change"===e.type||s&&i.indexOf(s)===-1)if(this.toggleList.justOpened&&!t)this.toggleList.justOpened=!1;else if(this.onChange)try{this.onChange(t,this.getSelectedValues())}catch(t){console.warn("something may be wrong in onChange",t)}this.programmaticClick=!1}},setSelectValueButton:function(){var e=this.refs,t=e.data,n=this.selectedClass,s=void 0;if(this.multipleTags)return!1;this.removeSelectedClass(t);var i=this.getSelected(),a=i[0];a&&(s=t[a.index],r["default"].addClass(s,n),r["default"].scrollTo(s,e.optionsListWrapper))},setSelectValueClick:function(e){var t=this.multiple,n=this.refs,s=this.selectedClass,i=e.target,a=i.getAttribute("data-index"),o=n.selectOptions[a];t&&(!t||this.multipleTags||e[this.multiSelect])||this.forceMultiple?(r["default"].toggleClass(i,s),o.selected=!o.selected):(this.deselectAll(),r["default"].addClass(i,s),o.selected=o.selected!==!0),this.forceMultiple=!1,this.hideEmptySection(i.parentNode);var l=n.selectOptions[0];""===l.value&&this.getSelected().length>1&&(r["default"].removeClass(n.data[0],s),n.selectOptions[0].selected=!1)},toggleClosed:function(e,t,n,s){var i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],a=this.classes;r["default"].addClass(n.optionsListWrapper,a.HIDDEN),r["default"].removeClass(s,a.OPEN);var o=document.querySelector("html");if(o.removeEventListener("click",this.catchBodyClick),o.removeEventListener("touchend",this.catchBodyClick),this.search?this.fuzzySearchReset():this.removeSelectKeyListener(),i||setTimeout(function(){return n.flounder.focus()},0),this.onClose&&this.ready)try{this.onClose(e,this.getSelectedValues())}catch(e){console.warn('something may be wrong in "onClose"',e)}},toggleList:function(e,t){var n=this.classes,s=this.refs,i=s.optionsListWrapper,a=s.wrapper,o=r["default"].hasClass(i,n.HIDDEN),l=e.type;"mouseleave"!==l&&"close"!==t&&o?("keydown"===l&&(this.toggleList.justOpened=!0),this.toggleOpen(e,i,s,a)):(this.toggleList.justOpened=!1,this.toggleClosed(e,i,s,a))},toggleListSearchClick:function(e){var t=this.classes;r["default"].hasClass(this.refs.wrapper,t.OPEN)||this.toggleList(e,"open")},toggleOpen:function(e,t,n){if(!this.isIos||this.search||this.multipleTags===!0){var s=this.classes;r["default"].removeClass(n.optionsListWrapper,s.HIDDEN),r["default"].addClass(n.wrapper,s.OPEN);var i=document.querySelector("html");i.addEventListener("click",this.catchBodyClick),i.addEventListener("touchend",this.catchBodyClick)}if(!this.multipleTags){var a=n.select.selectedIndex,o=n.data[a];r["default"].scrollTo(o,n.optionsListWrapper)}this.search?setTimeout(function(){return n.search.focus()},0):(this.addSelectKeyListener(),setTimeout(function(){return n.select.focus()},0));var l=n.data.length;if(this.props.placeholder&&l--,n.multiTagWrapper){var u=n.multiTagWrapper.children.length-1;u===l&&(this.removeNoResultsMessage(),this.addNoMoreOptionsMessage())}if(this.onOpen&&this.ready)try{this.onOpen(e,this.getSelectedValues())}catch(e){console.warn('something may be wrong in "onOpen"',e)}}};n["default"]=l},{"./keycodes":18,"./utils":20}],17:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}function i(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t1)console.warn("Flounder - More than one element found.\n Dropping all but the first.");else if(0===t.length)throw"Flounder - No target element found.";t=t[0]}return t.flounder&&t.flounder.destroy(),this.init(t,n)}console.warn("Flounder - No target element found.")}return o(e,[{key:"componentWillUnmount",value:function(){if(this.onComponentWillUnmount)try{this.onComponentWillUnmount()}catch(e){console.warn('something may be wrong in "onComponentWillUnmount"',e)}this.removeListeners(),this.originalChildren&&this.popInSelectElements(this.refs.select)}}]),o(e,[{key:"filterSearchResults",value:function(e){var t=e.target.value.trim();this.fuzzySearch.previousValue=t;var n=this.search.isThereAnythingRelatedTo(t)||[];if(""!==t){var s=this.refs.data,i=this.refs.sections,r=this.classes;s.forEach(function(e){c["default"].addClass(e,r.SEARCH_HIDDEN)}),i.forEach(function(e){c["default"].addClass(e,r.SEARCH_HIDDEN)}),n.forEach(function(e){c["default"].removeClass(s[e.i],r.SEARCH_HIDDEN),"number"==typeof e.d.s&&c["default"].removeClass(i[e.d.s],r.SEARCH_HIDDEN)}),this.refs.noMoreOptionsEl||(0===n.length?this.addNoResultsMessage():this.removeNoResultsMessage())}else this.fuzzySearchReset()}},{key:"fuzzySearch",value:function(e){if(this.fuzzySearch.previousValue=this.fuzzySearch.previousValue||"",this.onInputChange)try{this.onInputChange(e)}catch(e){console.warn('something may be wrong in "onInputChange"',e)}if(this.toggleList.justOpened)this.toggleList.justOpened=!1;else{e.preventDefault();var t=e.keyCode;if(t!==L["default"].UP&&t!==L["default"].DOWN&&t!==L["default"].ENTER&&t!==L["default"].ESCAPE)if(this.multipleTags&&t===L["default"].BACKSPACE&&""===this.fuzzySearch.previousValue){var n=this.refs.search.previousSibling;n&&setTimeout(function(){return n.focus()},0)}else this.filterSearchResults(e);else t!==L["default"].ESCAPE&&t!==L["default"].ENTER||(this.fuzzySearchReset(),this.toggleList(e,"close"),this.addPlaceholder())}}},{key:"fuzzySearchReset",value:function(){var e=this.refs,t=this.classes;e.sections.forEach(function(e){c["default"].removeClass(e,t.SEARCH_HIDDEN)}),e.data.forEach(function(e){c["default"].removeClass(e,t.SEARCH_HIDDEN)}),e.search.value="",this.removeNoResultsMessage()}},{key:"init",value:function(e,t){if(this.props=t,this.bindThis(),this.initializeOptions(),this.setTarget(e),this.search&&(this.search=new y["default"](this)),this.onInit)try{this.onInit()}catch(n){console.warn('something may be wrong in "onInit"',n)}this.buildDom();var s=c["default"].setPlatform(),i=s.isOsx,r=s.isIos,a=s.multiSelect;if(this.isOsx=i,this.isIos=r,this.multiSelect=a,this.onRender(),this.onComponentDidMount)try{this.onComponentDidMount()}catch(n){console.warn("something may be wrong in onComponentDidMount",n)}return this.ready=!0,this.originalTarget.flounder=this.target.flounder=this,this.refs.flounder.flounder=this}},{key:"initializeOptions",value:function(){var e=this.props=this.props||{};for(var t in l.defaultOptions)if("onChange"===t&&e.onSelect)this.onChange=e.onSelect,console.warn("Please use onChange. onSelect has been\n depricated and will be removed in 2.0.0"),this.onSelect=function(){console.warn("Please use onChange. onSelect has been\n depricated and will be removed in 2.0.0"),this.onChange.apply(this,arguments)};else if("classes"===t){this.classes={};var n=l.defaultOptions[t],s="object"===a(e[t])?e[t]:{};for(var r in n)this.classes[r]=s[r]?s[r]:n[r]}else"data"===t?this.data=e.data&&e.data.length?[].concat(i(e.data)):[].concat(i(l.defaultOptions.data)):this[t]=void 0!==e[t]?e[t]:l.defaultOptions[t];this.selectedClass=this.classes.SELECTED,e.defaultEmpty&&(this.placeholder=""),this.multipleTags&&(this.search=!0,this.multiple=!0,this.selectedClass+=" "+this.classes.SELECTED_HIDDEN)}},{key:"onRender",value:function(){var e=this.props,t=this.refs;if(this.isIos&&!this.multiple){var n=t.select,s=this.classes;c["default"].removeClass(n,s.HIDDEN),c["default"].addClass(n,s.HIDDEN_IOS)}this.addListeners(t,e)}},{key:"sortData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=this,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,r=0;return e.forEach(function(e){e.header?(t=n.sortData(e.data,t,s,r),r++):("object"!==("undefined"==typeof e?"undefined":a(e))?e={text:e,value:e,index:s}:e.index=s,void 0!==i&&(e.s=i),t.push(e),s++)}),t}}]),e}();S.find=function(e,t){return"string"==typeof e?e=document.querySelectorAll(e):1===e.nodeType&&(e=[e]),Array.prototype.slice.call(e,0).map(function(e){return new S(e,t)})},Object.defineProperty(S,"version",{get:function(){return C["default"]}}),Object.defineProperty(S.prototype,"version",{get:function(){return C["default"]}}),c["default"].extendClass(S,h["default"],p["default"],g["default"]),n["default"]=S},{"./api":12,"./build":13,"./defaults":15,"./events":16,"./keycodes":18,"./search":19,"./utils":20,"./version":21}],18:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var s={BACKSPACE:8,DOWN:40,ENTER:13,ESCAPE:27,LEFT:37,RIGHT:39,SPACE:32,TAB:9,UP:38,NON_CHARACTER_KEYS:[16,17,18,20,91,93]};n["default"]=s},{}],19:[function(e,t,n){"use strict";function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;nt?1:e=r.minimumScore}},{key:"isThereAnythingRelatedTo",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=void 0;if(e=e.length?e:""+e,!(e.length>=r.minimumValueLength))return!1;this.query=e.toLowerCase().split(" ");var n=this.flounder.data;return n=this.flounder.sortData(n),t=this.ratedRes=n.map(this.getResultWeights),t=t.filter(this.isItemAboveMinimum),t.sort(this.compareScoreCards),this.ratedRes=t}},{key:"startsWith",value:function(e,t,n){var s=t.length,i=e.length;if(i<=s){var r=t.toLowerCase().slice(0,i);if(r===e)return n}return 0}},{key:"scoreThis",value:function(e,t,n){var s=this,i=0;return e&&this.query.forEach(function(r){r=s.escapeRegExp(r);var a=0;"string"==typeof e?(r=new RegExp(r,"g"),a=(e.match(r)||[]).length):e[0]?e.forEach(function(e){a+=e.indexOf(r)!==-1?1:0}):a=e[r]||1e-6,a>0?i=t*a*10:n!==!0&&(i=-t)}),Math.floor(i)}}]),e}();n["default"]=a},{}],20:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var i=e("microbejs/src/modules/http"),r=s(i),a={addClass:function(e,t){if("string"!=typeof t&&t.length)return t.forEach(function(t){a.addClass(e,t)}),!0;var n=e.className,s=n.length,i=n.slice(s-t.length-1,s);a.hasClass(e,t)||n.slice(0,t.length+1)===t+" "||i===" "+t||(n+=" "+t),e.className=n.trim()},attachAttributes:function(e,t){if(!t)return null;for(var n in t)"data-"===n.slice(0,5)?e.setAttribute(n,t[n]):e[n]=t[n]},constructElement:function(e){var t=document.createElement(e.tagname||"div");return a.attachAttributes(t,e),t},debounce:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this,s=void 0,i=void 0,r=function(){return e.apply(n,s)};return function(){clearTimeout(i),s=arguments,i=setTimeout(r,t)}},extendClass:function(e){function t(t){for(var n in t)e[n]=t[n]}e=e.prototype;for(var n=arguments.length,s=Array(n>1?n-1:0),i=1;i/g,">").replace(/"/g,""")},getElWidth:function(e,t,n){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1500,i=window.getComputedStyle(e);if(0===e.offsetWidth&&this.checkWidthAgain!==!0){if(!t||!n)throw"Flounder getElWidth error: no callback given.";setTimeout(t.bind(n),s),this.checkWidthAgain=!0}else this.checkWidthAgain=!1;return e.offsetWidth+parseInt(i["margin-left"])+parseInt(i["margin-right"])},hasClass:function(e,t){var n=e.className,s=new RegExp("(^"+t+" )|( "+t+"$)|( "+t+" )|(^"+t+"$)");return!!n.match(s)},http:!1,iosVersion:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window;return!!/iPad|iPhone|iPod/.test(e.navigator.platform)&&(e.indexedDB?"8+":e.SpeechSynthesisUtterance?"7":e.webkitAudioContext?"6":"5-")},removeAllChildren:function(e){Array.prototype.slice.call(e.children,0).forEach(function(t){e.removeChild(t)})},removeClass:function(e,t){if("string"!=typeof t&&t.length)return t.forEach(function(t){a.removeClass(e,t)}),!0;var n=e.className,s=n.length,i=t.length;n===t?n="":n.slice(0,i+1)===t+" "?n=n.slice(i+1,s):n.slice(s-i-1,s)===" "+t?n=n.slice(0,s-i-1):n.indexOf(" "+t+" ")!==-1&&(n=n.replace(" "+t+" "," ")),e.className=n.trim()},scrollTo:function(e,t){if(e){var n=t||e.offsetParent;if(n.scrollHeight>n.offsetHeight){var s=e.offsetTop,i=e.offsetHeight,r=n.offsetHeight,a=n.scrollTop,o=a+n.offsetHeight-i;so&&(n.scrollTop=s-(r-i))}}return!1},setPlatform:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window,t=e.navigator.platform,n=t.indexOf("Mac")!==-1,s=a.iosVersion(e),i=n?"metaKey":"ctrlKey";return{isOsx:n,isIos:s,multiSelect:i}},toggleClass:function(e,t){a.hasClass(e,t)?a.removeClass(e,t):a.addClass(e,t)}};(0,r["default"])(a),n["default"]=a},{"microbejs/src/modules/http":3}],21:[function(e,t,n){"use strict";t.exports="1.3.1"},{}],22:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}var i=e("../core/flounder"),r=s(i);define("flounder",[],function(){return r["default"]})},{"../core/flounder":17}]},{},[22]); \ No newline at end of file diff --git a/dist/flounder.jquery.js b/dist/flounder.jquery.js index 0653b75..cd1a4f3 100644 --- a/dist/flounder.jquery.js +++ b/dist/flounder.jquery.js @@ -1,12 +1,12 @@ /*! - * Flounder JavaScript Stylable Selectbox v1.3.0 + * Flounder JavaScript Stylable Selectbox v1.3.1 * https://github.com/sociomantic-tsunami/flounder * * Copyright 2015-2017 Sociomantic Labs and other contributors * Released under the MIT license * https://github.com/sociomantic-tsunami/flounder/license * - * Date: Wed Oct 11 2017 + * Date: Fri Nov 03 2017 * * "This, so far, is the best Flounder ever" */(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;oc){for(var t=0,n=o.length-u;t "+t+") {","args = new Array(arguments.length + 1);","for (var i = 0; i < arguments.length; i++) {","args[i] = arguments[i];","}","}","return new Promise(function (rs, rj) {","var cb = "+o+";","var res;","switch (argLength) {",n.concat(["extra"]).map(function(e,t){return"case "+t+":res = fn.call("+["self"].concat(n.slice(0,t)).concat("cb").join(",")+");break;"}).join(""),"default:","args[argLength] = cb;","res = fn.apply(self, args);","}","if (res &&",'(typeof res === "object" || typeof res === "function") &&','typeof res.then === "function"',") {rs(res);}","});","};"].join("");return Function(["Promise","fn"],r)(i,e)}var i=e("./core.js"),a=e("asap");t.exports=i,i.denodeify=function(e,t){return"number"==typeof t&&t!==1/0?s(e,t):r(e)};var o="function (err, res) {if (err) { rj(err); } else { rs(res); }}";i.nodeify=function(e){return function(){var t=Array.prototype.slice.call(arguments),n="function"==typeof t[t.length-1]?t.pop():null,s=this;try{return e.apply(this,arguments).nodeify(n,s)}catch(r){if(null===n||"undefined"==typeof n)return new i(function(e,t){t(r)});a(function(){n.call(s,r)})}}},i.prototype.nodeify=function(e,t){return"function"!=typeof e?this:void this.then(function(n){a(function(){e.call(t,null,n)})},function(n){a(function(){e.call(t,n)})})}},{"./core.js":5,asap:1}],11:[function(e,t,n){"use strict";var s=e("./core.js");t.exports=s,s.enableSynchronous=function(){s.prototype.isPending=function(){return 0==this.getState()},s.prototype.isFulfilled=function(){return 1==this.getState()},s.prototype.isRejected=function(){return 2==this.getState()},s.prototype.getValue=function(){if(3===this._65)return this._55.getValue();if(!this.isFulfilled())throw new Error("Cannot get a value of an unfulfilled promise.");return this._55},s.prototype.getReason=function(){if(3===this._65)return this._55.getReason();if(!this.isRejected())throw new Error("Cannot get a rejection reason of a non-rejected promise.");return this._55},s.prototype.getState=function(){return 3===this._65?this._55.getState():this._65===-1||this._65===-2?0:this._65}},s.disableSynchronous=function(){s.prototype.isPending=void 0,s.prototype.isFulfilled=void 0,s.prototype.isRejected=void 0,s.prototype.getValue=void 0,s.prototype.getReason=void 0,s.prototype.getState=void 0}},{"./core.js":5}],12:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var r=function(){function e(e,t){var n=[],s=!0,r=!1,i=void 0;try{for(var a,o=e[Symbol.iterator]();!(s=(a=o.next()).done)&&(n.push(a.value),!t||n.length!==t);s=!0);}catch(l){r=!0,i=l}finally{try{!s&&o["return"]&&o["return"]()}finally{if(r)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),i=e("./utils"),a=s(i),o=e("./defaults"),l={buildFromUrl:function(e,t){var n=this;return this.loadDataFromUrl(e,function(e){n.data=e,t&&t(n.data),n.rebuild(n.data)}),[]},clickByIndex:function(e,t){return this.setByIndex(e,t,!1)},clickByText:function(e,t){return this.setByText(e,t,!1)},clickByValue:function(e,t){return this.setByValue(e,t,!1)},destroy:function(){this.componentWillUnmount();var e=this.refs,t=this.classes,n=this.originalTarget,s=n.tagName;if("INPUT"===s||"SELECT"===s){var r=n.nextElementSibling;if("SELECT"===s){var i=n[0];i&&a["default"].hasClass(i,t.PLACEHOLDER)&&n.removeChild(i)}else r=e.flounder.parentNode;try{var o=this.classes;r.parentNode.removeChild(r),n.tabIndex=0,a["default"].removeClass(n,o.HIDDEN)}catch(l){throw" : this flounder may have already been removed"}}else try{var u=e.wrapper,c=u.parentNode;c.removeChild(u)}catch(l){throw" : this flounder may have already been removed"}e.flounder.flounder=n.flounder=this.target.flounder=null},deselectAll:function(e){if(this.removeSelectedClass(),this.removeSelectedValue(),this.multiple){var t=this.refs.multiTagWrapper;if(t){for(var n=t.children,s=0;s2&&void 0!==arguments[2])||arguments[2],s=this.refs;if("string"!=typeof e&&e.length){var f=this.setByIndex.bind(this);return e.map(function(e){return f(e,t,n)})}var r=this.data,i=r.length;e<0&&(i=r.length,e=i+e);var a=s.data[e];return a?(this.forceMultiple=t&&this.multiple,this.programmaticClick=n,a.click(),a):null},setByText:function h(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof e&&e.length){var h=this.setByText.bind(this);return e.map(function(e){return h(e,t,n)})}var s=[];return e=""+e,this.refs.data.forEach(function(t,n){var r=t.innerHTML;r===e&&s.push(n)}),this.setByIndex(s,t,n)},setByValue:function p(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof e&&e.length){var p=this.setByValue.bind(this);return e.map(function(e){return p(e,t,n)})}var s=this.refs.selectOptions.map(function(t,n){return""+t.value==""+e?n:null}).filter(function(e){return 0===e||!!e});return this.setByIndex(s,t,n)}};n["default"]=l},{"./defaults":15,"./utils":20}],13:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=e("./defaults"),a=e("./utils"),o=s(a),l={addOptionDescription:function(e,t){var n=document.createElement("div");n.innerHTML=t,n.className=this.classes.DESCRIPTION,e.appendChild(n)},addSearch:function(e){if(this.search){var t=this.classes,n=o["default"].constructElement({tagname:"input",type:"text",className:t.SEARCH,tabIndex:-1});return e.appendChild(n),n}return!1},bindThis:function(){var e=this;["addHoverClass","catchBodyClick","checkClickTarget","checkFlounderKeypress","checkMultiTagKeydown","clearPlaceholder","clickSet","divertTarget","displayMultipleTags","firstTouchController","fuzzySearch","removeHoverClass","removeMultiTag","setKeypress","setSelectValue","toggleList","toggleListSearchClick"].forEach(function(t){e[t]=e[t].bind(e),e[t].isBound=!0})},buildArrow:function(e,t){if(e.disableArrow)return!1;var n=this.classes,s=t({className:n.ARROW}),r=t({className:n.ARROW_INNER});return s.appendChild(r),s},buildData:function(e,t,n,s){function i(t,n){t.index=n;var s=n===e.index?" "+v:"",r={className:T.OPTION+s,"data-index":n};for(var i in t)"text"!==i&&"description"!==i&&(r[i]=t[i]);var a=p(r);return a.innerHTML=C?t.text:g(t.text),t.description&&l.addOptionDescription(a,t.description,T.DESCRIPTION),a.className+=t.extraClass?" "+t.extraClass:"",a.setAttribute("role","option"),a}function a(t,n){var r=void 0;if(E){var i=E.children[n];r=i,i.setAttribute("value",i.value),i.disabled===!0&&d[n]&&m(d[n],T.DISABLED),m(i,T.OPTION_TAG)}else{var a=t.extraClass||"",o=T.OPTION_TAG+" "+a;r=p({tagname:"option",className:o.trim(),value:t.value});var l=g(t.text);r.innerHTML=l;var u=t.disabled;u&&r.setAttribute("disabled",u),s.appendChild(r)}return n===e.index&&(r.selected=!0),r.getAttribute("disabled")&&m(d[n],T.DISABLED),r}var l=this,u=0,c=0,d=[],f=[],h=[],p=o["default"].constructElement,v=this.selectedClass,g=o["default"].escapeHTML,m=o["default"].addClass,y=this.refs,E=y.select,C=this.allowHTML,T=this.classes;return t.forEach(function(e,s){if("object"!==("undefined"==typeof e?"undefined":r(e))&&(e=t[s]={text:e,value:e}),e.header){var l=p({tagname:"div",className:T.SECTION}),v=p({tagname:"div",className:T.HEADER});v.textContent=e.header,l.appendChild(v),n.appendChild(l);var g=e.data;g.forEach(function(e,t){"object"!==("undefined"==typeof e?"undefined":r(e))&&(e=g[t]={text:e,value:e}),d[u]=i(e,u),l.appendChild(d[u]),f[u]=a(e,u),u++}),0==g.length&&o["default"].addClass(l,T.HIDDEN),h[c]=l,c++}else d[u]=i(e,u),n.appendChild(d[u]),f[u]=a(e,u),u++}),[d,f,h]},buildDom:function(){var e=this.props,t=this.classes;this.refs={};var n=o["default"].constructElement,s=o["default"].constructElement({className:t.MAIN_WRAPPER}),r=t.MAIN,a=this.multipleTags?r+" "+t.MULTIPLE_TAG_FLOUNDER:r,l=n({className:a});l.setAttribute("aria-hidden",!0),l.tabIndex=0,s.appendChild(l);var u=this.initSelectBox(s);u.tabIndex=-1;var c=this.data;this.defaultObj=(0,i.setDefaultOption)(this,this.props,c);var d=this.defaultObj,f=t.SELECTED_DISPLAYED;d.value&&d.extraClass&&(f+=" "+d.extraClass);var h=n({className:f,"data-value":d.value,"data-index":d.index}),p=this.multipleTags?n({className:t.MULTI_TAG_LIST}):null,v=n({className:t.OPTIONS_WRAPPER+" "+t.HIDDEN}),g=n({className:t.LIST});g.setAttribute("role","listbox"),v.appendChild(g),this.multiple===!0&&(u.setAttribute("multiple",""),g.setAttribute("aria-multiselectable","true"));var m=this.buildArrow(e,n);[h,p,v,m].forEach(function(e){e&&l.appendChild(e)});var y=this.addSearch(this.multipleTags?p:l),E=this.buildData(d,c,g,u);c=E[0];var C=E[1],T=E[2];if(this.target.appendChild(s),this.refs={wrapper:s,flounder:l,selected:h,arrow:m,optionsListWrapper:v,search:y,multiTagWrapper:p,optionsList:g,select:u,data:c,sections:T,selectOptions:C},this.multipleTags){var L=this.getSelected();0===L.length?h.innerHTML=d.text:this.displayMultipleTags(L,p)}else h.innerHTML=d.text},buildMultiTag:function(e){var t=this.classes,n=e.innerHTML,s=document.createElement("SPAN");s.className=t.MULTIPLE_SELECT_TAG,s.setAttribute("aria-label","Close"),s.setAttribute("tabindex",0);var r=document.createElement("A");return r.className=t.MULTIPLE_TAG_CLOSE,r.setAttribute("data-index",e.index),s.appendChild(r),s.innerHTML+=n,s},initSelectBox:function(e){var t=this.target,n=this.refs,s=n.select,r=this.classes;if("SELECT"===t.tagName){if(o["default"].addClass(t,r.SELECT_TAG),o["default"].addClass(t,r.HIDDEN),s=t,this.props.keepChangesOnDestroy||this.popOutSelectElements(s),t.length>0&&!this.selectDataOverride){this.refs.select=s;var i=[],a=[],l=!0,u=!1,c=void 0;try{for(var d,f=t.children[Symbol.iterator]();!(l=(d=f.next()).done);l=!0){var h=d.value;a.push(h),i.push({text:h.innerHTML,value:h.value})}}catch(p){u=!0,c=p}finally{try{!l&&f["return"]&&f["return"]()}finally{if(u)throw c}}n.selectOptions=a,this.data=i}else this.selectDataOverride&&o["default"].removeAllChildren(t);this.target=t.parentNode,o["default"].addClass(t,r.HIDDEN)}else s=o["default"].constructElement({tagname:"SELECT",className:r.SELECT_TAG+" "+r.HIDDEN}),e.appendChild(s);return s},popInSelectElements:function(e){o["default"].removeAllChildren(e);var t=!0,n=!1,s=void 0;try{for(var r,i=this.originalChildren[Symbol.iterator]();!(t=(r=i.next()).done);t=!0){var a=r.value;e.appendChild(a)}}catch(l){n=!0,s=l}finally{try{!t&&i["return"]&&i["return"]()}finally{if(n)throw s}}},popOutSelectElements:function(e){var t=[];this.originalChildren=e.children;for(var n=this.originalChildren,s=0;s=0?e[s]:null;return r?(r.index=s,r):null}function r(){var r=e.sortData(o);!a.multipleTags&&!a.multiple||a.defaultIndex||a.defaultValue||(a.placeholder=a.placeholder||l.placeholder),a.defaultEmpty&&(a.placeholder="");var i=a.placeholder;if(i||""===i||0===r.length)return n(e,r);var c=void 0;if(u){var d=e.refs.selected.getAttribute("data-value");if(c=s(r,d))return c}return c=a.defaultIndex?t(r):null,c=!c&&a.defaultValue?s(r):c,c=c?c:t(r,0)}var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments[2],u=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return o=o||a.data||[],r()}};n.setDefaultOption=u.setDefaultOption;n["default"]=u},{"./classes":14,"./utils":20}],16:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var r=e("./utils"),i=s(r),a=e("./keycodes"),o=s(a),l={addFirstTouchListeners:function(){var e=this.refs;e.selected.addEventListener("click",this.firstTouchController),e.select.addEventListener("focus",this.firstTouchController),this.props.openOnHover&&e.wrapper.addEventListener("mouseenter",this.firstTouchController)},addHoverClass:function(e){i["default"].addClass(e.target,this.classes.HOVER)},addListeners:function(e){var t=this.isIos,n=t?"blur":"change";if(e.select.addEventListener(n,this.divertTarget),e.flounder.addEventListener("keydown",this.checkFlounderKeypress),this.props.openOnHover){var s=e.wrapper;s.addEventListener("mouseenter",this.toggleList),s.addEventListener("mouseleave",this.toggleList)}else e.selected.addEventListener("click",this.toggleList);this.addFirstTouchListeners(),this.addOptionsListeners(),this.search&&this.addSearchListeners()},addMultipleTags:function(e,t){var n=this;e.forEach(function(e){if(""!==e.value){var s=n.buildMultiTag(e);t.insertBefore(s,t.lastChild)}else e.selected=!1});for(var s=t.children,r=0;r1)for(var o=0;o=48&&t<=57||t>=65&&t<=90)&&n.search&&"INPUT"===e.target.tagName&&(n.selected.innerHTML="")},checkMultiTagKeydown:function(e){var t=this,n=e.keyCode,s=e.target,r=[o["default"].BACKSPACE,o["default"].LEFT,o["default"].RIGHT];r.indexOf(n)!==-1?(e.preventDefault(),e.stopPropagation(),n===o["default"].BACKSPACE?this.checkMultiTagKeydownRemove(s):this.checkMultiTagKeydownNavigate(n,s)):e.key.length<2&&setTimeout(function(){return t.refs.search.focus()},0)},checkMultiTagKeydownNavigate:function(e,t){if(e===o["default"].LEFT){var n=t.previousSibling;n&&n.focus()}else if(e===o["default"].RIGHT){var s=t.nextSibling;s&&setTimeout(function(){return s.focus()},0)}},checkMultiTagKeydownRemove:function(e){var t=e.previousSibling,n=e.nextSibling;e.firstChild.click(),t?setTimeout(function(){return t.focus()},0):n&&n.focus()},clearPlaceholder:function(){this.refs.selected.innerHTML=""},clickSet:function(e){e.preventDefault(),e.stopPropagation(),this.setSelectValue({},e),this.programmaticClick||this.toggleList(e,"close"),this.programmaticClick=!1},displayMultipleTags:function(e,t){for(var n=t.children,s=0;s0?this.addMultipleTags(e,t):this.addPlaceholder()},displaySelected:function(e,t){var n=[],s=-1,r=this.getSelected(),i=r.length,a=this.multipleTags;if(e.className=this.classes.SELECTED_DISPLAYED,a||1!==i)if(a||0!==i)a?(e.innerHTML="",this.displayMultipleTags(r,t.multiTagWrapper)):e.innerHTML=this.multipleMessage,s=r.map(function(e){return e.index}),n=r.map(function(e){return e.value});else{var o=this.defaultObj;s=o.index||-1,e.innerHTML=o.text,n=o.value}else{s=r[0].index,e.innerHTML=t.data[s].innerHTML, -n=r[0].value;var l=t.data[s].extraClass;e.className+=l?" "+l:""}e.setAttribute("data-value",n),e.setAttribute("data-index",s)},divertTarget:function(e){if(this.isIos){var t=this.refs.select,n=this.classes,s=t.querySelector("."+n.PLUG);s&&t.removeChild(s)}var r=e.target.selectedIndex,i={type:e.type,target:this.data[r]};this.multipleTags&&(e.preventDefault(),e.stopPropagation()),this.setSelectValue(i),this.multiple||this.toggleList(e,"close")},firstTouchController:function(e){var t=this.refs;if(this.onFirstTouch)try{this.onFirstTouch(e)}catch(e){console.warn('something may be wrong in "onFirstTouch"',e)}t.selected.removeEventListener("click",this.firstTouchController),t.select.removeEventListener("focus",this.firstTouchController),this.props.openOnHover&&t.wrapper.removeEventListener("mouseenter",this.firstTouchController)},hideEmptySection:function(e){for(var t=this.selectedClass,n=this.refs.sections,s=0;sa?o=0:o<0&&(o=a);var l=this.classes,u=i["default"].hasClass,c=r[o];s.selectedIndex=o,(u(c,l.HIDDEN)||u(c,l.SELECTED_HIDDEN)||u(c,l.SEARCH_HIDDEN)||u(c,l.DISABLED))&&this.setKeypress(e)},setSelectValue:function(e,t){var n=this.refs,s=void 0;if(t?this.setSelectValueClick(t):(s=e.keyCode,this.setSelectValueButton(e)),this.displaySelected(n.selected,n),!this.programmaticClick){var r=[9,16,17,18,20,91];if(t||"blur"===e.type||!s&&"change"===e.type||s&&r.indexOf(s)===-1)if(this.toggleList.justOpened&&!t)this.toggleList.justOpened=!1;else if(this.onChange)try{this.onChange(t,this.getSelectedValues())}catch(t){console.warn("something may be wrong in onChange",t)}this.programmaticClick=!1}},setSelectValueButton:function(){var e=this.refs,t=e.data,n=this.selectedClass,s=void 0;if(this.multipleTags)return!1;this.removeSelectedClass(t);var r=this.getSelected(),a=r[0];a&&(s=t[a.index],i["default"].addClass(s,n),i["default"].scrollTo(s,e.optionsListWrapper))},setSelectValueClick:function(e){var t=this.multiple,n=this.refs,s=this.selectedClass,r=e.target,a=r.getAttribute("data-index"),o=n.selectOptions[a];t&&(!t||this.multipleTags||e[this.multiSelect])||this.forceMultiple?(i["default"].toggleClass(r,s),o.selected=!o.selected):(this.deselectAll(),i["default"].addClass(r,s),o.selected=o.selected!==!0),this.forceMultiple=!1,this.hideEmptySection(r.parentNode);var l=n.selectOptions[0];""===l.value&&this.getSelected().length>1&&(i["default"].removeClass(n.data[0],s),n.selectOptions[0].selected=!1)},toggleClosed:function(e,t,n,s){var r=arguments.length>4&&void 0!==arguments[4]&&arguments[4],a=this.classes;i["default"].addClass(n.optionsListWrapper,a.HIDDEN),i["default"].removeClass(s,a.OPEN);var o=document.querySelector("html");if(o.removeEventListener("click",this.catchBodyClick),o.removeEventListener("touchend",this.catchBodyClick),this.search?this.fuzzySearchReset():this.removeSelectKeyListener(),r||setTimeout(function(){return n.flounder.focus()},0),this.onClose&&this.ready)try{this.onClose(e,this.getSelectedValues())}catch(e){console.warn('something may be wrong in "onClose"',e)}},toggleList:function(e,t){var n=this.classes,s=this.refs,r=s.optionsListWrapper,a=s.wrapper,o=i["default"].hasClass(r,n.HIDDEN),l=e.type;"mouseleave"!==l&&"close"!==t&&o?("keydown"===l&&(this.toggleList.justOpened=!0),this.toggleOpen(e,r,s,a)):(this.toggleList.justOpened=!1,this.toggleClosed(e,r,s,a))},toggleListSearchClick:function(e){var t=this.classes;i["default"].hasClass(this.refs.wrapper,t.OPEN)||this.toggleList(e,"open")},toggleOpen:function(e,t,n){if(!this.isIos||this.search||this.multipleTags===!0){var s=this.classes;i["default"].removeClass(n.optionsListWrapper,s.HIDDEN),i["default"].addClass(n.wrapper,s.OPEN);var r=document.querySelector("html");r.addEventListener("click",this.catchBodyClick),r.addEventListener("touchend",this.catchBodyClick)}if(!this.multipleTags){var a=n.select.selectedIndex,o=n.data[a];i["default"].scrollTo(o,n.optionsListWrapper)}this.search?setTimeout(function(){return n.search.focus()},0):(this.addSelectKeyListener(),setTimeout(function(){return n.select.focus()},0));var l=n.data.length;if(this.props.placeholder&&l--,n.multiTagWrapper){var u=n.multiTagWrapper.children.length-1;u===l&&(this.removeNoResultsMessage(),this.addNoMoreOptionsMessage())}if(this.onOpen&&this.ready)try{this.onOpen(e,this.getSelectedValues())}catch(e){console.warn('something may be wrong in "onOpen"',e)}}};n["default"]=l},{"./keycodes":18,"./utils":20}],17:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}function r(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t1)console.warn("Flounder - More than one element found.\n Dropping all but the first.");else if(0===t.length)throw"Flounder - No target element found.";t=t[0]}return t.flounder&&t.flounder.destroy(),this.init(t,n)}console.warn("Flounder - No target element found.")}return o(e,[{key:"componentWillUnmount",value:function(){if(this.onComponentWillUnmount)try{this.onComponentWillUnmount()}catch(e){console.warn('something may be wrong in "onComponentWillUnmount"',e)}this.removeListeners(),this.originalChildren&&this.popInSelectElements(this.refs.select)}}]),o(e,[{key:"filterSearchResults",value:function(e){var t=e.target.value.trim();this.fuzzySearch.previousValue=t;var n=this.search.isThereAnythingRelatedTo(t)||[];if(""!==t){var s=this.refs.data,r=this.refs.sections,i=this.classes;s.forEach(function(e){c["default"].addClass(e,i.SEARCH_HIDDEN)}),r.forEach(function(e){c["default"].addClass(e,i.SEARCH_HIDDEN)}),n.forEach(function(e){c["default"].removeClass(s[e.i],i.SEARCH_HIDDEN),"number"==typeof e.d.s&&c["default"].removeClass(r[e.d.s],i.SEARCH_HIDDEN)}),this.refs.noMoreOptionsEl||(0===n.length?this.addNoResultsMessage():this.removeNoResultsMessage())}else this.fuzzySearchReset()}},{key:"fuzzySearch",value:function(e){if(this.fuzzySearch.previousValue=this.fuzzySearch.previousValue||"",this.onInputChange)try{this.onInputChange(e)}catch(e){console.warn('something may be wrong in "onInputChange"',e)}if(this.toggleList.justOpened)this.toggleList.justOpened=!1;else{e.preventDefault();var t=e.keyCode;if(t!==L["default"].UP&&t!==L["default"].DOWN&&t!==L["default"].ENTER&&t!==L["default"].ESCAPE)if(this.multipleTags&&t===L["default"].BACKSPACE&&""===this.fuzzySearch.previousValue){var n=this.refs.search.previousSibling;n&&setTimeout(function(){return n.focus()},0)}else this.filterSearchResults(e);else t!==L["default"].ESCAPE&&t!==L["default"].ENTER||(this.fuzzySearchReset(),this.toggleList(e,"close"),this.addPlaceholder())}}},{key:"fuzzySearchReset",value:function(){var e=this.refs,t=this.classes;e.sections.forEach(function(e){c["default"].removeClass(e,t.SEARCH_HIDDEN)}),e.data.forEach(function(e){c["default"].removeClass(e,t.SEARCH_HIDDEN)}),e.search.value="",this.removeNoResultsMessage()}},{key:"init",value:function(e,t){if(this.props=t,this.bindThis(),this.initializeOptions(),this.setTarget(e),this.search&&(this.search=new y["default"](this)),this.onInit)try{this.onInit()}catch(n){console.warn('something may be wrong in "onInit"',n)}this.buildDom();var s=c["default"].setPlatform(),r=s.isOsx,i=s.isIos,a=s.multiSelect;if(this.isOsx=r,this.isIos=i,this.multiSelect=a,this.onRender(),this.onComponentDidMount)try{this.onComponentDidMount()}catch(n){console.warn("something may be wrong in onComponentDidMount",n)}return this.ready=!0,this.originalTarget.flounder=this.target.flounder=this,this.refs.flounder.flounder=this}},{key:"initializeOptions",value:function(){var e=this.props=this.props||{};for(var t in l.defaultOptions)if("onChange"===t&&e.onSelect)this.onChange=e.onSelect,console.warn("Please use onChange. onSelect has been\n depricated and will be removed in 2.0.0"),this.onSelect=function(){console.warn("Please use onChange. onSelect has been\n depricated and will be removed in 2.0.0"),this.onChange.apply(this,arguments)};else if("classes"===t){this.classes={};var n=l.defaultOptions[t],s="object"===a(e[t])?e[t]:{};for(var i in n)this.classes[i]=s[i]?s[i]:n[i]}else"data"===t?this.data=e.data&&e.data.length?[].concat(r(e.data)):[].concat(r(l.defaultOptions.data)):this[t]=void 0!==e[t]?e[t]:l.defaultOptions[t];this.selectedClass=this.classes.SELECTED,e.defaultEmpty&&(this.placeholder=""),this.multipleTags&&(this.search=!0,this.multiple=!0,this.selectedClass+=" "+this.classes.SELECTED_HIDDEN)}},{key:"onRender",value:function(){var e=this.props,t=this.refs;if(this.isIos&&!this.multiple){var n=t.select,s=this.classes;c["default"].removeClass(n,s.HIDDEN),c["default"].addClass(n,s.HIDDEN_IOS)}this.addListeners(t,e)}},{key:"sortData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=this,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,i=0;return e.forEach(function(e){e.header?(t=n.sortData(e.data,t,s,i),i++):("object"!==("undefined"==typeof e?"undefined":a(e))?e={text:e,value:e,index:s}:e.index=s,void 0!==r&&(e.s=r),t.push(e),s++)}),t}}]),e}();S.find=function(e,t){return"string"==typeof e?e=document.querySelectorAll(e):1===e.nodeType&&(e=[e]),Array.prototype.slice.call(e,0).map(function(e){return new S(e,t)})},Object.defineProperty(S,"version",{get:function(){return C["default"]}}),Object.defineProperty(S.prototype,"version",{get:function(){return C["default"]}}),c["default"].extendClass(S,f["default"],p["default"],g["default"]),n["default"]=S},{"./api":12,"./build":13,"./defaults":15,"./events":16,"./keycodes":18,"./search":19,"./utils":20,"./version":21}],18:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var s={BACKSPACE:8,DOWN:40,ENTER:13,ESCAPE:27,LEFT:37,RIGHT:39,SPACE:32,TAB:9,UP:38,NON_CHARACTER_KEYS:[16,17,18,20,91,93]};n["default"]=s},{}],19:[function(e,t,n){"use strict";function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;nt?1:e=i.minimumScore}},{key:"isThereAnythingRelatedTo",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=void 0;if(e=e.length?e:""+e,!(e.length>=i.minimumValueLength))return!1;this.query=e.toLowerCase().split(" ");var n=this.flounder.data;return n=this.flounder.sortData(n),t=this.ratedRes=n.map(this.getResultWeights),t=t.filter(this.isItemAboveMinimum),t.sort(this.compareScoreCards),this.ratedRes=t}},{key:"startsWith",value:function(e,t,n){var s=t.length,r=e.length;if(r<=s){var i=t.toLowerCase().slice(0,r);if(i===e)return n}return 0}},{key:"scoreThis",value:function(e,t,n){var s=this,r=0;return e&&this.query.forEach(function(i){i=s.escapeRegExp(i);var a=0;"string"==typeof e?(i=new RegExp(i,"g"),a=(e.match(i)||[]).length):e[0]?e.forEach(function(e){a+=e.indexOf(i)!==-1?1:0}):a=e[i]||1e-6,a>0?r=t*a*10:n!==!0&&(r=-t)}),Math.floor(r)}}]),e}();n["default"]=a},{}],20:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var r=e("microbejs/src/modules/http"),i=s(r),a={addClass:function(e,t){if("string"!=typeof t&&t.length)return t.forEach(function(t){a.addClass(e,t)}),!0;var n=e.className,s=n.length,r=n.slice(s-t.length-1,s);a.hasClass(e,t)||n.slice(0,t.length+1)===t+" "||r===" "+t||(n+=" "+t),e.className=n.trim()},attachAttributes:function(e,t){if(!t)return null;for(var n in t)"data-"===n.slice(0,5)?e.setAttribute(n,t[n]):e[n]=t[n]},constructElement:function(e){var t=document.createElement(e.tagname||"div");return a.attachAttributes(t,e),t},debounce:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this,s=void 0,r=void 0,i=function(){return e.apply(n,s)};return function(){clearTimeout(r),s=arguments,r=setTimeout(i,t)}},extendClass:function(e){function t(t){for(var n in t)e[n]=t[n]}e=e.prototype;for(var n=arguments.length,s=Array(n>1?n-1:0),r=1;r/g,">").replace(/"/g,""")},getElWidth:function(e,t,n){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1500,r=window.getComputedStyle(e);if(0===e.offsetWidth&&this.checkWidthAgain!==!0){if(!t||!n)throw"Flounder getElWidth error: no callback given.";setTimeout(t.bind(n),s),this.checkWidthAgain=!0}else this.checkWidthAgain=!1;return e.offsetWidth+parseInt(r["margin-left"])+parseInt(r["margin-right"])},hasClass:function(e,t){var n=e.className,s=new RegExp("(^"+t+" )|( "+t+"$)|( "+t+" )|(^"+t+"$)");return!!n.match(s)},http:!1,iosVersion:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window;return!!/iPad|iPhone|iPod/.test(e.navigator.platform)&&(e.indexedDB?"8+":e.SpeechSynthesisUtterance?"7":e.webkitAudioContext?"6":"5-")},removeAllChildren:function(e){Array.prototype.slice.call(e.children,0).forEach(function(t){e.removeChild(t)})},removeClass:function(e,t){if("string"!=typeof t&&t.length)return t.forEach(function(t){a.removeClass(e,t)}),!0;var n=e.className,s=n.length,r=t.length;n===t?n="":n.slice(0,r+1)===t+" "?n=n.slice(r+1,s):n.slice(s-r-1,s)===" "+t?n=n.slice(0,s-r-1):n.indexOf(" "+t+" ")!==-1&&(n=n.replace(" "+t+" "," ")),e.className=n.trim()},scrollTo:function(e,t){if(e){var n=t||e.offsetParent;if(n.scrollHeight>n.offsetHeight){var s=e.offsetTop,r=e.offsetHeight,i=n.offsetHeight,a=n.scrollTop,o=a+n.offsetHeight-r;so&&(n.scrollTop=s-(i-r))}}return!1},setPlatform:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window,t=e.navigator.platform,n=t.indexOf("Mac")!==-1,s=a.iosVersion(e),r=n?"metaKey":"ctrlKey";return{isOsx:n,isIos:s,multiSelect:r}},toggleClass:function(e,t){a.hasClass(e,t)?a.removeClass(e,t):a.addClass(e,t)}};(0,i["default"])(a),n["default"]=a},{"microbejs/src/modules/http":3}],21:[function(e,t,n){"use strict";t.exports="1.3.0"},{}],22:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}var r=e("../core/flounder"),i=s(r);!function(e){e.fn.flounder=function(t){var n=i["default"].prototype.destroy;return this.each(function(s,r){var a=new i["default"](r,t),o=e(r);o.data("flounder",a),a.destroy=function(){o.data("flounder",!1),n.call(a)}}),this}}(jQuery)},{"../core/flounder":17}]},{},[22]); \ No newline at end of file +/*! Flounder v1.3.1 | (c) 2015-2017 Sociomantic Labs | https://github.com/sociomantic-tsunami/flounder/license */!function e(t,n,s){function i(a,o){if(!n[a]){if(!t[a]){var l="function"==typeof require&&require;if(!o&&l)return l(a,!0);if(r)return r(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var c=n[a]={exports:{}};t[a][0].call(c.exports,function(e){var n=t[a][1][e];return i(n?n:e)},c,c.exports,e,t,n,s)}return n[a].exports}for(var r="function"==typeof require&&require,a=0;ac){for(var t=0,n=o.length-u;t "+t+") {","args = new Array(arguments.length + 1);","for (var i = 0; i < arguments.length; i++) {","args[i] = arguments[i];","}","}","return new Promise(function (rs, rj) {","var cb = "+o+";","var res;","switch (argLength) {",n.concat(["extra"]).map(function(e,t){return"case "+t+":res = fn.call("+["self"].concat(n.slice(0,t)).concat("cb").join(",")+");break;"}).join(""),"default:","args[argLength] = cb;","res = fn.apply(self, args);","}","if (res &&",'(typeof res === "object" || typeof res === "function") &&','typeof res.then === "function"',") {rs(res);}","});","};"].join("");return Function(["Promise","fn"],i)(r,e)}var r=e("./core.js"),a=e("asap");t.exports=r,r.denodeify=function(e,t){return"number"==typeof t&&t!==1/0?s(e,t):i(e)};var o="function (err, res) {if (err) { rj(err); } else { rs(res); }}";r.nodeify=function(e){return function(){var t=Array.prototype.slice.call(arguments),n="function"==typeof t[t.length-1]?t.pop():null,s=this;try{return e.apply(this,arguments).nodeify(n,s)}catch(i){if(null===n||"undefined"==typeof n)return new r(function(e,t){t(i)});a(function(){n.call(s,i)})}}},r.prototype.nodeify=function(e,t){return"function"!=typeof e?this:void this.then(function(n){a(function(){e.call(t,null,n)})},function(n){a(function(){e.call(t,n)})})}},{"./core.js":5,asap:1}],11:[function(e,t,n){"use strict";var s=e("./core.js");t.exports=s,s.enableSynchronous=function(){s.prototype.isPending=function(){return 0==this.getState()},s.prototype.isFulfilled=function(){return 1==this.getState()},s.prototype.isRejected=function(){return 2==this.getState()},s.prototype.getValue=function(){if(3===this._65)return this._55.getValue();if(!this.isFulfilled())throw new Error("Cannot get a value of an unfulfilled promise.");return this._55},s.prototype.getReason=function(){if(3===this._65)return this._55.getReason();if(!this.isRejected())throw new Error("Cannot get a rejection reason of a non-rejected promise.");return this._55},s.prototype.getState=function(){return 3===this._65?this._55.getState():this._65===-1||this._65===-2?0:this._65}},s.disableSynchronous=function(){s.prototype.isPending=void 0,s.prototype.isFulfilled=void 0,s.prototype.isRejected=void 0,s.prototype.getValue=void 0,s.prototype.getReason=void 0,s.prototype.getState=void 0}},{"./core.js":5}],12:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){var n=[],s=!0,i=!1,r=void 0;try{for(var a,o=e[Symbol.iterator]();!(s=(a=o.next()).done)&&(n.push(a.value),!t||n.length!==t);s=!0);}catch(l){i=!0,r=l}finally{try{!s&&o["return"]&&o["return"]()}finally{if(i)throw r}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),r=e("./utils"),a=s(r),o=e("./defaults"),l={buildFromUrl:function(e,t){var n=this;return this.loadDataFromUrl(e,function(e){n.data=e,t&&t(n.data),n.rebuild(n.data)}),[]},clickByIndex:function(e,t){return this.setByIndex(e,t,!1)},clickByText:function(e,t){return this.setByText(e,t,!1)},clickByValue:function(e,t){return this.setByValue(e,t,!1)},destroy:function(){this.componentWillUnmount();var e=this.refs,t=this.classes,n=this.originalTarget,s=n.tagName;if("INPUT"===s||"SELECT"===s){var i=n.nextElementSibling;if("SELECT"===s){var r=n[0];r&&a["default"].hasClass(r,t.PLACEHOLDER)&&n.removeChild(r)}else i=e.flounder.parentNode;try{var o=this.classes;i.parentNode.removeChild(i),n.tabIndex=0,a["default"].removeClass(n,o.HIDDEN)}catch(l){throw" : this flounder may have already been removed"}}else try{var u=e.wrapper,c=u.parentNode;c.removeChild(u)}catch(l){throw" : this flounder may have already been removed"}e.flounder.flounder=n.flounder=this.target.flounder=null},deselectAll:function(e){if(this.removeSelectedClass(),this.removeSelectedValue(),this.multiple){var t=this.refs.multiTagWrapper;if(t){for(var n=t.children,s=0;s2&&void 0!==arguments[2])||arguments[2],s=this.refs;if("string"!=typeof e&&e.length){var h=this.setByIndex.bind(this);return e.map(function(e){return h(e,t,n)})}var i=this.data,r=i.length;e<0&&(r=i.length,e=r+e);var a=s.data[e];return a?(this.forceMultiple=t&&this.multiple,this.programmaticClick=n,a.click(),a):null},setByText:function f(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof e&&e.length){var f=this.setByText.bind(this);return e.map(function(e){return f(e,t,n)})}var s=[];return e=""+e,this.refs.data.forEach(function(t,n){var i=t.innerHTML;i===e&&s.push(n)}),this.setByIndex(s,t,n)},setByValue:function p(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof e&&e.length){var p=this.setByValue.bind(this);return e.map(function(e){return p(e,t,n)})}var s=this.refs.selectOptions.map(function(t,n){return""+t.value==""+e?n:null}).filter(function(e){return 0===e||!!e});return this.setByIndex(s,t,n)}};n["default"]=l},{"./defaults":15,"./utils":20}],13:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r=e("./defaults"),a=e("./utils"),o=s(a),l={addOptionDescription:function(e,t){var n=document.createElement("div");n.innerHTML=t,n.className=this.classes.DESCRIPTION,e.appendChild(n)},addSearch:function(e){if(this.search){var t=this.classes,n=o["default"].constructElement({tagname:"input",type:"text",className:t.SEARCH,tabIndex:-1});return e.appendChild(n),n}return!1},bindThis:function(){var e=this;["addHoverClass","catchBodyClick","checkClickTarget","checkFlounderKeypress","checkMultiTagKeydown","clearPlaceholder","clickSet","divertTarget","displayMultipleTags","firstTouchController","fuzzySearch","removeHoverClass","removeMultiTag","setKeypress","setSelectValue","toggleList","toggleListSearchClick"].forEach(function(t){e[t]=e[t].bind(e),e[t].isBound=!0})},buildArrow:function(e,t){if(e.disableArrow)return!1;var n=this.classes,s=t({className:n.ARROW}),i=t({className:n.ARROW_INNER});return s.appendChild(i),s},buildData:function(e,t,n,s){function r(t,n){t.index=n;var s=n===e.index?" "+v:"",i={className:T.OPTION+s,"data-index":n};for(var r in t)"text"!==r&&"description"!==r&&(i[r]=t[r]);var a=p(i);return a.innerHTML=C?t.text:g(t.text),t.description&&l.addOptionDescription(a,t.description,T.DESCRIPTION),a.className+=t.extraClass?" "+t.extraClass:"",a.setAttribute("role","option"),a}function a(t,n){var i=void 0;if(E){var r=E.children[n];i=r,r.setAttribute("value",r.value),r.disabled===!0&&d[n]&&m(d[n],T.DISABLED),m(r,T.OPTION_TAG)}else{var a=t.extraClass||"",o=T.OPTION_TAG+" "+a;i=p({tagname:"option",className:o.trim(),value:t.value});var l=g(t.text);i.innerHTML=l;var u=t.disabled;u&&i.setAttribute("disabled",u),s.appendChild(i)}return n===e.index&&(i.selected=!0),i.getAttribute("disabled")&&m(d[n],T.DISABLED),i}var l=this,u=0,c=0,d=[],h=[],f=[],p=o["default"].constructElement,v=this.selectedClass,g=o["default"].escapeHTML,m=o["default"].addClass,y=this.refs,E=y.select,C=this.allowHTML,T=this.classes;return t.forEach(function(e,s){if("object"!==("undefined"==typeof e?"undefined":i(e))&&(e=t[s]={text:e,value:e}),e.header){var l=p({tagname:"div",className:T.SECTION}),v=p({tagname:"div",className:T.HEADER});v.textContent=e.header,l.appendChild(v),n.appendChild(l);var g=e.data;g.forEach(function(e,t){"object"!==("undefined"==typeof e?"undefined":i(e))&&(e=g[t]={text:e,value:e}),d[u]=r(e,u),l.appendChild(d[u]),h[u]=a(e,u),u++}),0==g.length&&o["default"].addClass(l,T.HIDDEN),f[c]=l,c++}else d[u]=r(e,u),n.appendChild(d[u]),h[u]=a(e,u),u++}),[d,h,f]},buildDom:function(){var e=this.props,t=this.classes;this.refs={};var n=o["default"].constructElement,s=o["default"].constructElement({className:t.MAIN_WRAPPER}),i=t.MAIN,a=this.multipleTags?i+" "+t.MULTIPLE_TAG_FLOUNDER:i,l=n({className:a});l.setAttribute("aria-hidden",!0),l.tabIndex=0,s.appendChild(l);var u=this.initSelectBox(s);u.tabIndex=-1;var c=this.data;this.defaultObj=(0,r.setDefaultOption)(this,this.props,c);var d=this.defaultObj,h=t.SELECTED_DISPLAYED;d.value&&d.extraClass&&(h+=" "+d.extraClass);var f=n({className:h,"data-value":d.value,"data-index":d.index}),p=this.multipleTags?n({className:t.MULTI_TAG_LIST}):null,v=n({className:t.OPTIONS_WRAPPER+" "+t.HIDDEN}),g=n({className:t.LIST});g.setAttribute("role","listbox"),v.appendChild(g),this.multiple===!0&&(u.setAttribute("multiple",""),g.setAttribute("aria-multiselectable","true"));var m=this.buildArrow(e,n);[f,p,v,m].forEach(function(e){e&&l.appendChild(e)});var y=this.addSearch(this.multipleTags?p:l),E=this.buildData(d,c,g,u);c=E[0];var C=E[1],T=E[2];if(this.target.appendChild(s),this.refs={wrapper:s,flounder:l,selected:f,arrow:m,optionsListWrapper:v,search:y,multiTagWrapper:p,optionsList:g,select:u,data:c,sections:T,selectOptions:C},this.multipleTags){var L=this.getSelected();0===L.length?f.innerHTML=d.text:this.displayMultipleTags(L,p)}else f.innerHTML=d.text},buildMultiTag:function(e){var t=this.classes,n=e.innerHTML,s=document.createElement("SPAN");s.className=t.MULTIPLE_SELECT_TAG,s.setAttribute("aria-label","Close"),s.setAttribute("tabindex",0);var i=document.createElement("A");return i.className=t.MULTIPLE_TAG_CLOSE,i.setAttribute("data-index",e.index),s.appendChild(i),s.innerHTML+=n,s},initSelectBox:function(e){var t=this.target,n=this.refs,s=n.select,i=this.classes;if("SELECT"===t.tagName){if(o["default"].addClass(t,i.SELECT_TAG),o["default"].addClass(t,i.HIDDEN),s=t,this.props.keepChangesOnDestroy||this.popOutSelectElements(s),t.length>0&&!this.selectDataOverride){this.refs.select=s;for(var r=[],a=[],l=0;l=0?e[s]:null;return i?(i.index=s,i):null}function i(){var i=e.sortData(o);!a.multipleTags&&!a.multiple||a.defaultIndex||a.defaultValue||(a.placeholder=a.placeholder||l.placeholder),a.defaultEmpty&&(a.placeholder="");var r=a.placeholder;if(r||""===r||0===i.length)return n(e,i);var c=void 0;if(u){var d=e.refs.selected.getAttribute("data-value");if(c=s(i,d))return c}return c=a.defaultIndex?t(i):null,c=!c&&a.defaultValue?s(i):c,c=c?c:t(i,0)}var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments[2],u=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return o=o||a.data||[],i()}};n.setDefaultOption=u.setDefaultOption;n["default"]=u},{"./classes":14,"./utils":20}],16:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var i=e("./utils"),r=s(i),a=e("./keycodes"),o=s(a),l={addFirstTouchListeners:function(){var e=this.refs;e.selected.addEventListener("click",this.firstTouchController),e.select.addEventListener("focus",this.firstTouchController),this.props.openOnHover&&e.wrapper.addEventListener("mouseenter",this.firstTouchController)},addHoverClass:function(e){r["default"].addClass(e.target,this.classes.HOVER)},addListeners:function(e){var t=this.isIos,n=t?"blur":"change";if(e.select.addEventListener(n,this.divertTarget),e.flounder.addEventListener("keydown",this.checkFlounderKeypress),this.props.openOnHover){var s=e.wrapper;s.addEventListener("mouseenter",this.toggleList),s.addEventListener("mouseleave",this.toggleList)}else e.selected.addEventListener("click",this.toggleList);this.addFirstTouchListeners(),this.addOptionsListeners(),this.search&&this.addSearchListeners()},addMultipleTags:function(e,t){var n=this;e.forEach(function(e){if(""!==e.value){var s=n.buildMultiTag(e);t.insertBefore(s,t.lastChild)}else e.selected=!1});for(var s=t.children,i=0;i1)for(var o=0;o=48&&t<=57||t>=65&&t<=90)&&n.search&&"INPUT"===e.target.tagName&&(n.selected.innerHTML="")},checkMultiTagKeydown:function(e){var t=this,n=e.keyCode,s=e.target,i=[o["default"].BACKSPACE,o["default"].LEFT,o["default"].RIGHT];i.indexOf(n)!==-1?(e.preventDefault(),e.stopPropagation(),n===o["default"].BACKSPACE?this.checkMultiTagKeydownRemove(s):this.checkMultiTagKeydownNavigate(n,s)):e.key.length<2&&setTimeout(function(){return t.refs.search.focus()},0)},checkMultiTagKeydownNavigate:function(e,t){if(e===o["default"].LEFT){var n=t.previousSibling;n&&n.focus()}else if(e===o["default"].RIGHT){var s=t.nextSibling;s&&setTimeout(function(){return s.focus()},0)}},checkMultiTagKeydownRemove:function(e){var t=e.previousSibling,n=e.nextSibling;e.firstChild.click(),t?setTimeout(function(){return t.focus()},0):n&&n.focus()},clearPlaceholder:function(){this.refs.selected.innerHTML=""},clickSet:function(e){e.preventDefault(),e.stopPropagation(),this.setSelectValue({},e),this.programmaticClick||this.toggleList(e,"close"),this.programmaticClick=!1},displayMultipleTags:function(e,t){for(var n=t.children,s=0;s0?this.addMultipleTags(e,t):this.addPlaceholder()},displaySelected:function(e,t){var n=[],s=-1,i=this.getSelected(),r=i.length,a=this.multipleTags;if(e.className=this.classes.SELECTED_DISPLAYED,a||1!==r)if(a||0!==r)a?(e.innerHTML="",this.displayMultipleTags(i,t.multiTagWrapper)):e.innerHTML=this.multipleMessage,s=i.map(function(e){return e.index}),n=i.map(function(e){return e.value});else{var o=this.defaultObj;s=o.index||-1,e.innerHTML=o.text,n=o.value}else{s=i[0].index,e.innerHTML=t.data[s].innerHTML,n=i[0].value;var l=t.data[s].extraClass;e.className+=l?" "+l:""}e.setAttribute("data-value",n),e.setAttribute("data-index",s)},divertTarget:function(e){if(this.isIos){var t=this.refs.select,n=this.classes,s=t.querySelector("."+n.PLUG);s&&t.removeChild(s)}var i=e.target.selectedIndex,r={type:e.type,target:this.data[i]};this.multipleTags&&(e.preventDefault(),e.stopPropagation()),this.setSelectValue(r), +this.multiple||this.toggleList(e,"close")},firstTouchController:function(e){var t=this.refs;if(this.onFirstTouch)try{this.onFirstTouch(e)}catch(e){console.warn('something may be wrong in "onFirstTouch"',e)}t.selected.removeEventListener("click",this.firstTouchController),t.select.removeEventListener("focus",this.firstTouchController),this.props.openOnHover&&t.wrapper.removeEventListener("mouseenter",this.firstTouchController)},hideEmptySection:function(e){for(var t=this.selectedClass,n=this.refs.sections,s=0;sa?o=0:o<0&&(o=a);var l=this.classes,u=r["default"].hasClass,c=i[o];s.selectedIndex=o,(u(c,l.HIDDEN)||u(c,l.SELECTED_HIDDEN)||u(c,l.SEARCH_HIDDEN)||u(c,l.DISABLED))&&this.setKeypress(e)},setSelectValue:function(e,t){var n=this.refs,s=void 0;if(t?this.setSelectValueClick(t):(s=e.keyCode,this.setSelectValueButton(e)),this.displaySelected(n.selected,n),!this.programmaticClick){var i=[9,16,17,18,20,91];if(t||"blur"===e.type||!s&&"change"===e.type||s&&i.indexOf(s)===-1)if(this.toggleList.justOpened&&!t)this.toggleList.justOpened=!1;else if(this.onChange)try{this.onChange(t,this.getSelectedValues())}catch(t){console.warn("something may be wrong in onChange",t)}this.programmaticClick=!1}},setSelectValueButton:function(){var e=this.refs,t=e.data,n=this.selectedClass,s=void 0;if(this.multipleTags)return!1;this.removeSelectedClass(t);var i=this.getSelected(),a=i[0];a&&(s=t[a.index],r["default"].addClass(s,n),r["default"].scrollTo(s,e.optionsListWrapper))},setSelectValueClick:function(e){var t=this.multiple,n=this.refs,s=this.selectedClass,i=e.target,a=i.getAttribute("data-index"),o=n.selectOptions[a];t&&(!t||this.multipleTags||e[this.multiSelect])||this.forceMultiple?(r["default"].toggleClass(i,s),o.selected=!o.selected):(this.deselectAll(),r["default"].addClass(i,s),o.selected=o.selected!==!0),this.forceMultiple=!1,this.hideEmptySection(i.parentNode);var l=n.selectOptions[0];""===l.value&&this.getSelected().length>1&&(r["default"].removeClass(n.data[0],s),n.selectOptions[0].selected=!1)},toggleClosed:function(e,t,n,s){var i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],a=this.classes;r["default"].addClass(n.optionsListWrapper,a.HIDDEN),r["default"].removeClass(s,a.OPEN);var o=document.querySelector("html");if(o.removeEventListener("click",this.catchBodyClick),o.removeEventListener("touchend",this.catchBodyClick),this.search?this.fuzzySearchReset():this.removeSelectKeyListener(),i||setTimeout(function(){return n.flounder.focus()},0),this.onClose&&this.ready)try{this.onClose(e,this.getSelectedValues())}catch(e){console.warn('something may be wrong in "onClose"',e)}},toggleList:function(e,t){var n=this.classes,s=this.refs,i=s.optionsListWrapper,a=s.wrapper,o=r["default"].hasClass(i,n.HIDDEN),l=e.type;"mouseleave"!==l&&"close"!==t&&o?("keydown"===l&&(this.toggleList.justOpened=!0),this.toggleOpen(e,i,s,a)):(this.toggleList.justOpened=!1,this.toggleClosed(e,i,s,a))},toggleListSearchClick:function(e){var t=this.classes;r["default"].hasClass(this.refs.wrapper,t.OPEN)||this.toggleList(e,"open")},toggleOpen:function(e,t,n){if(!this.isIos||this.search||this.multipleTags===!0){var s=this.classes;r["default"].removeClass(n.optionsListWrapper,s.HIDDEN),r["default"].addClass(n.wrapper,s.OPEN);var i=document.querySelector("html");i.addEventListener("click",this.catchBodyClick),i.addEventListener("touchend",this.catchBodyClick)}if(!this.multipleTags){var a=n.select.selectedIndex,o=n.data[a];r["default"].scrollTo(o,n.optionsListWrapper)}this.search?setTimeout(function(){return n.search.focus()},0):(this.addSelectKeyListener(),setTimeout(function(){return n.select.focus()},0));var l=n.data.length;if(this.props.placeholder&&l--,n.multiTagWrapper){var u=n.multiTagWrapper.children.length-1;u===l&&(this.removeNoResultsMessage(),this.addNoMoreOptionsMessage())}if(this.onOpen&&this.ready)try{this.onOpen(e,this.getSelectedValues())}catch(e){console.warn('something may be wrong in "onOpen"',e)}}};n["default"]=l},{"./keycodes":18,"./utils":20}],17:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}function i(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t1)console.warn("Flounder - More than one element found.\n Dropping all but the first.");else if(0===t.length)throw"Flounder - No target element found.";t=t[0]}return t.flounder&&t.flounder.destroy(),this.init(t,n)}console.warn("Flounder - No target element found.")}return o(e,[{key:"componentWillUnmount",value:function(){if(this.onComponentWillUnmount)try{this.onComponentWillUnmount()}catch(e){console.warn('something may be wrong in "onComponentWillUnmount"',e)}this.removeListeners(),this.originalChildren&&this.popInSelectElements(this.refs.select)}}]),o(e,[{key:"filterSearchResults",value:function(e){var t=e.target.value.trim();this.fuzzySearch.previousValue=t;var n=this.search.isThereAnythingRelatedTo(t)||[];if(""!==t){var s=this.refs.data,i=this.refs.sections,r=this.classes;s.forEach(function(e){c["default"].addClass(e,r.SEARCH_HIDDEN)}),i.forEach(function(e){c["default"].addClass(e,r.SEARCH_HIDDEN)}),n.forEach(function(e){c["default"].removeClass(s[e.i],r.SEARCH_HIDDEN),"number"==typeof e.d.s&&c["default"].removeClass(i[e.d.s],r.SEARCH_HIDDEN)}),this.refs.noMoreOptionsEl||(0===n.length?this.addNoResultsMessage():this.removeNoResultsMessage())}else this.fuzzySearchReset()}},{key:"fuzzySearch",value:function(e){if(this.fuzzySearch.previousValue=this.fuzzySearch.previousValue||"",this.onInputChange)try{this.onInputChange(e)}catch(e){console.warn('something may be wrong in "onInputChange"',e)}if(this.toggleList.justOpened)this.toggleList.justOpened=!1;else{e.preventDefault();var t=e.keyCode;if(t!==L["default"].UP&&t!==L["default"].DOWN&&t!==L["default"].ENTER&&t!==L["default"].ESCAPE)if(this.multipleTags&&t===L["default"].BACKSPACE&&""===this.fuzzySearch.previousValue){var n=this.refs.search.previousSibling;n&&setTimeout(function(){return n.focus()},0)}else this.filterSearchResults(e);else t!==L["default"].ESCAPE&&t!==L["default"].ENTER||(this.fuzzySearchReset(),this.toggleList(e,"close"),this.addPlaceholder())}}},{key:"fuzzySearchReset",value:function(){var e=this.refs,t=this.classes;e.sections.forEach(function(e){c["default"].removeClass(e,t.SEARCH_HIDDEN)}),e.data.forEach(function(e){c["default"].removeClass(e,t.SEARCH_HIDDEN)}),e.search.value="",this.removeNoResultsMessage()}},{key:"init",value:function(e,t){if(this.props=t,this.bindThis(),this.initializeOptions(),this.setTarget(e),this.search&&(this.search=new y["default"](this)),this.onInit)try{this.onInit()}catch(n){console.warn('something may be wrong in "onInit"',n)}this.buildDom();var s=c["default"].setPlatform(),i=s.isOsx,r=s.isIos,a=s.multiSelect;if(this.isOsx=i,this.isIos=r,this.multiSelect=a,this.onRender(),this.onComponentDidMount)try{this.onComponentDidMount()}catch(n){console.warn("something may be wrong in onComponentDidMount",n)}return this.ready=!0,this.originalTarget.flounder=this.target.flounder=this,this.refs.flounder.flounder=this}},{key:"initializeOptions",value:function(){var e=this.props=this.props||{};for(var t in l.defaultOptions)if("onChange"===t&&e.onSelect)this.onChange=e.onSelect,console.warn("Please use onChange. onSelect has been\n depricated and will be removed in 2.0.0"),this.onSelect=function(){console.warn("Please use onChange. onSelect has been\n depricated and will be removed in 2.0.0"),this.onChange.apply(this,arguments)};else if("classes"===t){this.classes={};var n=l.defaultOptions[t],s="object"===a(e[t])?e[t]:{};for(var r in n)this.classes[r]=s[r]?s[r]:n[r]}else"data"===t?this.data=e.data&&e.data.length?[].concat(i(e.data)):[].concat(i(l.defaultOptions.data)):this[t]=void 0!==e[t]?e[t]:l.defaultOptions[t];this.selectedClass=this.classes.SELECTED,e.defaultEmpty&&(this.placeholder=""),this.multipleTags&&(this.search=!0,this.multiple=!0,this.selectedClass+=" "+this.classes.SELECTED_HIDDEN)}},{key:"onRender",value:function(){var e=this.props,t=this.refs;if(this.isIos&&!this.multiple){var n=t.select,s=this.classes;c["default"].removeClass(n,s.HIDDEN),c["default"].addClass(n,s.HIDDEN_IOS)}this.addListeners(t,e)}},{key:"sortData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=this,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,r=0;return e.forEach(function(e){e.header?(t=n.sortData(e.data,t,s,r),r++):("object"!==("undefined"==typeof e?"undefined":a(e))?e={text:e,value:e,index:s}:e.index=s,void 0!==i&&(e.s=i),t.push(e),s++)}),t}}]),e}();S.find=function(e,t){return"string"==typeof e?e=document.querySelectorAll(e):1===e.nodeType&&(e=[e]),Array.prototype.slice.call(e,0).map(function(e){return new S(e,t)})},Object.defineProperty(S,"version",{get:function(){return C["default"]}}),Object.defineProperty(S.prototype,"version",{get:function(){return C["default"]}}),c["default"].extendClass(S,h["default"],p["default"],g["default"]),n["default"]=S},{"./api":12,"./build":13,"./defaults":15,"./events":16,"./keycodes":18,"./search":19,"./utils":20,"./version":21}],18:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var s={BACKSPACE:8,DOWN:40,ENTER:13,ESCAPE:27,LEFT:37,RIGHT:39,SPACE:32,TAB:9,UP:38,NON_CHARACTER_KEYS:[16,17,18,20,91,93]};n["default"]=s},{}],19:[function(e,t,n){"use strict";function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;nt?1:e=r.minimumScore}},{key:"isThereAnythingRelatedTo",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=void 0;if(e=e.length?e:""+e,!(e.length>=r.minimumValueLength))return!1;this.query=e.toLowerCase().split(" ");var n=this.flounder.data;return n=this.flounder.sortData(n),t=this.ratedRes=n.map(this.getResultWeights),t=t.filter(this.isItemAboveMinimum),t.sort(this.compareScoreCards),this.ratedRes=t}},{key:"startsWith",value:function(e,t,n){var s=t.length,i=e.length;if(i<=s){var r=t.toLowerCase().slice(0,i);if(r===e)return n}return 0}},{key:"scoreThis",value:function(e,t,n){var s=this,i=0;return e&&this.query.forEach(function(r){r=s.escapeRegExp(r);var a=0;"string"==typeof e?(r=new RegExp(r,"g"),a=(e.match(r)||[]).length):e[0]?e.forEach(function(e){a+=e.indexOf(r)!==-1?1:0}):a=e[r]||1e-6,a>0?i=t*a*10:n!==!0&&(i=-t)}),Math.floor(i)}}]),e}();n["default"]=a},{}],20:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var i=e("microbejs/src/modules/http"),r=s(i),a={addClass:function(e,t){if("string"!=typeof t&&t.length)return t.forEach(function(t){a.addClass(e,t)}),!0;var n=e.className,s=n.length,i=n.slice(s-t.length-1,s);a.hasClass(e,t)||n.slice(0,t.length+1)===t+" "||i===" "+t||(n+=" "+t),e.className=n.trim()},attachAttributes:function(e,t){if(!t)return null;for(var n in t)"data-"===n.slice(0,5)?e.setAttribute(n,t[n]):e[n]=t[n]},constructElement:function(e){var t=document.createElement(e.tagname||"div");return a.attachAttributes(t,e),t},debounce:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this,s=void 0,i=void 0,r=function(){return e.apply(n,s)};return function(){clearTimeout(i),s=arguments,i=setTimeout(r,t)}},extendClass:function(e){function t(t){for(var n in t)e[n]=t[n]}e=e.prototype;for(var n=arguments.length,s=Array(n>1?n-1:0),i=1;i/g,">").replace(/"/g,""")},getElWidth:function(e,t,n){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1500,i=window.getComputedStyle(e);if(0===e.offsetWidth&&this.checkWidthAgain!==!0){if(!t||!n)throw"Flounder getElWidth error: no callback given.";setTimeout(t.bind(n),s),this.checkWidthAgain=!0}else this.checkWidthAgain=!1;return e.offsetWidth+parseInt(i["margin-left"])+parseInt(i["margin-right"])},hasClass:function(e,t){var n=e.className,s=new RegExp("(^"+t+" )|( "+t+"$)|( "+t+" )|(^"+t+"$)");return!!n.match(s)},http:!1,iosVersion:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window;return!!/iPad|iPhone|iPod/.test(e.navigator.platform)&&(e.indexedDB?"8+":e.SpeechSynthesisUtterance?"7":e.webkitAudioContext?"6":"5-")},removeAllChildren:function(e){Array.prototype.slice.call(e.children,0).forEach(function(t){e.removeChild(t)})},removeClass:function(e,t){if("string"!=typeof t&&t.length)return t.forEach(function(t){a.removeClass(e,t)}),!0;var n=e.className,s=n.length,i=t.length;n===t?n="":n.slice(0,i+1)===t+" "?n=n.slice(i+1,s):n.slice(s-i-1,s)===" "+t?n=n.slice(0,s-i-1):n.indexOf(" "+t+" ")!==-1&&(n=n.replace(" "+t+" "," ")),e.className=n.trim()},scrollTo:function(e,t){if(e){var n=t||e.offsetParent;if(n.scrollHeight>n.offsetHeight){var s=e.offsetTop,i=e.offsetHeight,r=n.offsetHeight,a=n.scrollTop,o=a+n.offsetHeight-i;so&&(n.scrollTop=s-(r-i))}}return!1},setPlatform:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window,t=e.navigator.platform,n=t.indexOf("Mac")!==-1,s=a.iosVersion(e),i=n?"metaKey":"ctrlKey";return{isOsx:n,isIos:s,multiSelect:i}},toggleClass:function(e,t){a.hasClass(e,t)?a.removeClass(e,t):a.addClass(e,t)}};(0,r["default"])(a),n["default"]=a},{"microbejs/src/modules/http":3}],21:[function(e,t,n){"use strict";t.exports="1.3.1"},{}],22:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}var i=e("../core/flounder"),r=s(i);!function(e){e.fn.flounder=function(t){var n=r["default"].prototype.destroy;return this.each(function(s,i){var a=new r["default"](i,t),o=e(i);o.data("flounder",a),a.destroy=function(){o.data("flounder",!1),n.call(a)}}),this}}(jQuery)},{"../core/flounder":17}]},{},[22]); \ No newline at end of file diff --git a/dist/flounder.js b/dist/flounder.js index 71c91a6..fb5036d 100644 --- a/dist/flounder.js +++ b/dist/flounder.js @@ -1,12 +1,12 @@ /*! - * Flounder JavaScript Stylable Selectbox v1.3.0 + * Flounder JavaScript Stylable Selectbox v1.3.1 * https://github.com/sociomantic-tsunami/flounder * * Copyright 2015-2017 Sociomantic Labs and other contributors * Released under the MIT license * https://github.com/sociomantic-tsunami/flounder/license * - * Date: Wed Oct 11 2017 + * Date: Fri Nov 03 2017 * * "This, so far, is the best Flounder ever" */(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;oc){for(var t=0,n=o.length-u;t "+t+") {","args = new Array(arguments.length + 1);","for (var i = 0; i < arguments.length; i++) {","args[i] = arguments[i];","}","}","return new Promise(function (rs, rj) {","var cb = "+o+";","var res;","switch (argLength) {",n.concat(["extra"]).map(function(e,t){return"case "+t+":res = fn.call("+["self"].concat(n.slice(0,t)).concat("cb").join(",")+");break;"}).join(""),"default:","args[argLength] = cb;","res = fn.apply(self, args);","}","if (res &&",'(typeof res === "object" || typeof res === "function") &&','typeof res.then === "function"',") {rs(res);}","});","};"].join("");return Function(["Promise","fn"],r)(i,e)}var i=e("./core.js"),a=e("asap");t.exports=i,i.denodeify=function(e,t){return"number"==typeof t&&t!==1/0?s(e,t):r(e)};var o="function (err, res) {if (err) { rj(err); } else { rs(res); }}";i.nodeify=function(e){return function(){var t=Array.prototype.slice.call(arguments),n="function"==typeof t[t.length-1]?t.pop():null,s=this;try{return e.apply(this,arguments).nodeify(n,s)}catch(r){if(null===n||"undefined"==typeof n)return new i(function(e,t){t(r)});a(function(){n.call(s,r)})}}},i.prototype.nodeify=function(e,t){return"function"!=typeof e?this:void this.then(function(n){a(function(){e.call(t,null,n)})},function(n){a(function(){e.call(t,n)})})}},{"./core.js":5,asap:1}],11:[function(e,t,n){"use strict";var s=e("./core.js");t.exports=s,s.enableSynchronous=function(){s.prototype.isPending=function(){return 0==this.getState()},s.prototype.isFulfilled=function(){return 1==this.getState()},s.prototype.isRejected=function(){return 2==this.getState()},s.prototype.getValue=function(){if(3===this._65)return this._55.getValue();if(!this.isFulfilled())throw new Error("Cannot get a value of an unfulfilled promise.");return this._55},s.prototype.getReason=function(){if(3===this._65)return this._55.getReason();if(!this.isRejected())throw new Error("Cannot get a rejection reason of a non-rejected promise.");return this._55},s.prototype.getState=function(){return 3===this._65?this._55.getState():this._65===-1||this._65===-2?0:this._65}},s.disableSynchronous=function(){s.prototype.isPending=void 0,s.prototype.isFulfilled=void 0,s.prototype.isRejected=void 0,s.prototype.getValue=void 0,s.prototype.getReason=void 0,s.prototype.getState=void 0}},{"./core.js":5}],12:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var r=function(){function e(e,t){var n=[],s=!0,r=!1,i=void 0;try{for(var a,o=e[Symbol.iterator]();!(s=(a=o.next()).done)&&(n.push(a.value),!t||n.length!==t);s=!0);}catch(l){r=!0,i=l}finally{try{!s&&o["return"]&&o["return"]()}finally{if(r)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),i=e("./utils"),a=s(i),o=e("./defaults"),l={buildFromUrl:function(e,t){var n=this;return this.loadDataFromUrl(e,function(e){n.data=e,t&&t(n.data),n.rebuild(n.data)}),[]},clickByIndex:function(e,t){return this.setByIndex(e,t,!1)},clickByText:function(e,t){return this.setByText(e,t,!1)},clickByValue:function(e,t){return this.setByValue(e,t,!1)},destroy:function(){this.componentWillUnmount();var e=this.refs,t=this.classes,n=this.originalTarget,s=n.tagName;if("INPUT"===s||"SELECT"===s){var r=n.nextElementSibling;if("SELECT"===s){var i=n[0];i&&a["default"].hasClass(i,t.PLACEHOLDER)&&n.removeChild(i)}else r=e.flounder.parentNode;try{var o=this.classes;r.parentNode.removeChild(r),n.tabIndex=0,a["default"].removeClass(n,o.HIDDEN)}catch(l){throw" : this flounder may have already been removed"}}else try{var u=e.wrapper,c=u.parentNode;c.removeChild(u)}catch(l){throw" : this flounder may have already been removed"}e.flounder.flounder=n.flounder=this.target.flounder=null},deselectAll:function(e){if(this.removeSelectedClass(),this.removeSelectedValue(),this.multiple){var t=this.refs.multiTagWrapper;if(t){for(var n=t.children,s=0;s2&&void 0!==arguments[2])||arguments[2],s=this.refs;if("string"!=typeof e&&e.length){var f=this.setByIndex.bind(this);return e.map(function(e){return f(e,t,n)})}var r=this.data,i=r.length;e<0&&(i=r.length,e=i+e);var a=s.data[e];return a?(this.forceMultiple=t&&this.multiple,this.programmaticClick=n,a.click(),a):null},setByText:function h(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof e&&e.length){var h=this.setByText.bind(this);return e.map(function(e){return h(e,t,n)})}var s=[];return e=""+e,this.refs.data.forEach(function(t,n){var r=t.innerHTML;r===e&&s.push(n)}),this.setByIndex(s,t,n)},setByValue:function p(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof e&&e.length){var p=this.setByValue.bind(this);return e.map(function(e){return p(e,t,n)})}var s=this.refs.selectOptions.map(function(t,n){return""+t.value==""+e?n:null}).filter(function(e){return 0===e||!!e});return this.setByIndex(s,t,n)}};n["default"]=l},{"./defaults":15,"./utils":20}],13:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=e("./defaults"),a=e("./utils"),o=s(a),l={addOptionDescription:function(e,t){var n=document.createElement("div");n.innerHTML=t,n.className=this.classes.DESCRIPTION,e.appendChild(n)},addSearch:function(e){if(this.search){var t=this.classes,n=o["default"].constructElement({tagname:"input",type:"text",className:t.SEARCH,tabIndex:-1});return e.appendChild(n),n}return!1},bindThis:function(){var e=this;["addHoverClass","catchBodyClick","checkClickTarget","checkFlounderKeypress","checkMultiTagKeydown","clearPlaceholder","clickSet","divertTarget","displayMultipleTags","firstTouchController","fuzzySearch","removeHoverClass","removeMultiTag","setKeypress","setSelectValue","toggleList","toggleListSearchClick"].forEach(function(t){e[t]=e[t].bind(e),e[t].isBound=!0})},buildArrow:function(e,t){if(e.disableArrow)return!1;var n=this.classes,s=t({className:n.ARROW}),r=t({className:n.ARROW_INNER});return s.appendChild(r),s},buildData:function(e,t,n,s){function i(t,n){t.index=n;var s=n===e.index?" "+v:"",r={className:T.OPTION+s,"data-index":n};for(var i in t)"text"!==i&&"description"!==i&&(r[i]=t[i]);var a=p(r);return a.innerHTML=C?t.text:g(t.text),t.description&&l.addOptionDescription(a,t.description,T.DESCRIPTION),a.className+=t.extraClass?" "+t.extraClass:"",a.setAttribute("role","option"),a}function a(t,n){var r=void 0;if(E){var i=E.children[n];r=i,i.setAttribute("value",i.value),i.disabled===!0&&d[n]&&m(d[n],T.DISABLED),m(i,T.OPTION_TAG)}else{var a=t.extraClass||"",o=T.OPTION_TAG+" "+a;r=p({tagname:"option",className:o.trim(),value:t.value});var l=g(t.text);r.innerHTML=l;var u=t.disabled;u&&r.setAttribute("disabled",u),s.appendChild(r)}return n===e.index&&(r.selected=!0),r.getAttribute("disabled")&&m(d[n],T.DISABLED),r}var l=this,u=0,c=0,d=[],f=[],h=[],p=o["default"].constructElement,v=this.selectedClass,g=o["default"].escapeHTML,m=o["default"].addClass,y=this.refs,E=y.select,C=this.allowHTML,T=this.classes;return t.forEach(function(e,s){if("object"!==("undefined"==typeof e?"undefined":r(e))&&(e=t[s]={text:e,value:e}),e.header){var l=p({tagname:"div",className:T.SECTION}),v=p({tagname:"div",className:T.HEADER});v.textContent=e.header,l.appendChild(v),n.appendChild(l);var g=e.data;g.forEach(function(e,t){"object"!==("undefined"==typeof e?"undefined":r(e))&&(e=g[t]={text:e,value:e}),d[u]=i(e,u),l.appendChild(d[u]),f[u]=a(e,u),u++}),0==g.length&&o["default"].addClass(l,T.HIDDEN),h[c]=l,c++}else d[u]=i(e,u),n.appendChild(d[u]),f[u]=a(e,u),u++}),[d,f,h]},buildDom:function(){var e=this.props,t=this.classes;this.refs={};var n=o["default"].constructElement,s=o["default"].constructElement({className:t.MAIN_WRAPPER}),r=t.MAIN,a=this.multipleTags?r+" "+t.MULTIPLE_TAG_FLOUNDER:r,l=n({className:a});l.setAttribute("aria-hidden",!0),l.tabIndex=0,s.appendChild(l);var u=this.initSelectBox(s);u.tabIndex=-1;var c=this.data;this.defaultObj=(0,i.setDefaultOption)(this,this.props,c);var d=this.defaultObj,f=t.SELECTED_DISPLAYED;d.value&&d.extraClass&&(f+=" "+d.extraClass);var h=n({className:f,"data-value":d.value,"data-index":d.index}),p=this.multipleTags?n({className:t.MULTI_TAG_LIST}):null,v=n({className:t.OPTIONS_WRAPPER+" "+t.HIDDEN}),g=n({className:t.LIST});g.setAttribute("role","listbox"),v.appendChild(g),this.multiple===!0&&(u.setAttribute("multiple",""),g.setAttribute("aria-multiselectable","true"));var m=this.buildArrow(e,n);[h,p,v,m].forEach(function(e){e&&l.appendChild(e)});var y=this.addSearch(this.multipleTags?p:l),E=this.buildData(d,c,g,u);c=E[0];var C=E[1],T=E[2];if(this.target.appendChild(s),this.refs={wrapper:s,flounder:l,selected:h,arrow:m,optionsListWrapper:v,search:y,multiTagWrapper:p,optionsList:g,select:u,data:c,sections:T,selectOptions:C},this.multipleTags){var L=this.getSelected();0===L.length?h.innerHTML=d.text:this.displayMultipleTags(L,p)}else h.innerHTML=d.text},buildMultiTag:function(e){var t=this.classes,n=e.innerHTML,s=document.createElement("SPAN");s.className=t.MULTIPLE_SELECT_TAG,s.setAttribute("aria-label","Close"),s.setAttribute("tabindex",0);var r=document.createElement("A");return r.className=t.MULTIPLE_TAG_CLOSE,r.setAttribute("data-index",e.index),s.appendChild(r),s.innerHTML+=n,s},initSelectBox:function(e){var t=this.target,n=this.refs,s=n.select,r=this.classes;if("SELECT"===t.tagName){if(o["default"].addClass(t,r.SELECT_TAG),o["default"].addClass(t,r.HIDDEN),s=t,this.props.keepChangesOnDestroy||this.popOutSelectElements(s),t.length>0&&!this.selectDataOverride){this.refs.select=s;var i=[],a=[],l=!0,u=!1,c=void 0;try{for(var d,f=t.children[Symbol.iterator]();!(l=(d=f.next()).done);l=!0){var h=d.value;a.push(h),i.push({text:h.innerHTML,value:h.value})}}catch(p){u=!0,c=p}finally{try{!l&&f["return"]&&f["return"]()}finally{if(u)throw c}}n.selectOptions=a,this.data=i}else this.selectDataOverride&&o["default"].removeAllChildren(t);this.target=t.parentNode,o["default"].addClass(t,r.HIDDEN)}else s=o["default"].constructElement({tagname:"SELECT",className:r.SELECT_TAG+" "+r.HIDDEN}),e.appendChild(s);return s},popInSelectElements:function(e){o["default"].removeAllChildren(e);var t=!0,n=!1,s=void 0;try{for(var r,i=this.originalChildren[Symbol.iterator]();!(t=(r=i.next()).done);t=!0){var a=r.value;e.appendChild(a)}}catch(l){n=!0,s=l}finally{try{!t&&i["return"]&&i["return"]()}finally{if(n)throw s}}},popOutSelectElements:function(e){var t=[];this.originalChildren=e.children;for(var n=this.originalChildren,s=0;s=0?e[s]:null;return r?(r.index=s,r):null}function r(){var r=e.sortData(o);!a.multipleTags&&!a.multiple||a.defaultIndex||a.defaultValue||(a.placeholder=a.placeholder||l.placeholder),a.defaultEmpty&&(a.placeholder="");var i=a.placeholder;if(i||""===i||0===r.length)return n(e,r);var c=void 0;if(u){var d=e.refs.selected.getAttribute("data-value");if(c=s(r,d))return c}return c=a.defaultIndex?t(r):null,c=!c&&a.defaultValue?s(r):c,c=c?c:t(r,0)}var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments[2],u=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return o=o||a.data||[],r()}};n.setDefaultOption=u.setDefaultOption;n["default"]=u},{"./classes":14,"./utils":20}],16:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var r=e("./utils"),i=s(r),a=e("./keycodes"),o=s(a),l={addFirstTouchListeners:function(){var e=this.refs;e.selected.addEventListener("click",this.firstTouchController),e.select.addEventListener("focus",this.firstTouchController),this.props.openOnHover&&e.wrapper.addEventListener("mouseenter",this.firstTouchController)},addHoverClass:function(e){i["default"].addClass(e.target,this.classes.HOVER)},addListeners:function(e){var t=this.isIos,n=t?"blur":"change";if(e.select.addEventListener(n,this.divertTarget),e.flounder.addEventListener("keydown",this.checkFlounderKeypress),this.props.openOnHover){var s=e.wrapper;s.addEventListener("mouseenter",this.toggleList),s.addEventListener("mouseleave",this.toggleList)}else e.selected.addEventListener("click",this.toggleList);this.addFirstTouchListeners(),this.addOptionsListeners(),this.search&&this.addSearchListeners()},addMultipleTags:function(e,t){var n=this;e.forEach(function(e){if(""!==e.value){var s=n.buildMultiTag(e);t.insertBefore(s,t.lastChild)}else e.selected=!1});for(var s=t.children,r=0;r1)for(var o=0;o=48&&t<=57||t>=65&&t<=90)&&n.search&&"INPUT"===e.target.tagName&&(n.selected.innerHTML="")},checkMultiTagKeydown:function(e){var t=this,n=e.keyCode,s=e.target,r=[o["default"].BACKSPACE,o["default"].LEFT,o["default"].RIGHT];r.indexOf(n)!==-1?(e.preventDefault(),e.stopPropagation(),n===o["default"].BACKSPACE?this.checkMultiTagKeydownRemove(s):this.checkMultiTagKeydownNavigate(n,s)):e.key.length<2&&setTimeout(function(){return t.refs.search.focus()},0)},checkMultiTagKeydownNavigate:function(e,t){if(e===o["default"].LEFT){var n=t.previousSibling;n&&n.focus()}else if(e===o["default"].RIGHT){var s=t.nextSibling;s&&setTimeout(function(){return s.focus()},0)}},checkMultiTagKeydownRemove:function(e){var t=e.previousSibling,n=e.nextSibling;e.firstChild.click(),t?setTimeout(function(){return t.focus()},0):n&&n.focus()},clearPlaceholder:function(){this.refs.selected.innerHTML=""},clickSet:function(e){e.preventDefault(),e.stopPropagation(),this.setSelectValue({},e),this.programmaticClick||this.toggleList(e,"close"),this.programmaticClick=!1},displayMultipleTags:function(e,t){for(var n=t.children,s=0;s0?this.addMultipleTags(e,t):this.addPlaceholder()},displaySelected:function(e,t){var n=[],s=-1,r=this.getSelected(),i=r.length,a=this.multipleTags;if(e.className=this.classes.SELECTED_DISPLAYED,a||1!==i)if(a||0!==i)a?(e.innerHTML="",this.displayMultipleTags(r,t.multiTagWrapper)):e.innerHTML=this.multipleMessage,s=r.map(function(e){return e.index}),n=r.map(function(e){return e.value});else{var o=this.defaultObj;s=o.index||-1,e.innerHTML=o.text,n=o.value}else{s=r[0].index,e.innerHTML=t.data[s].innerHTML, -n=r[0].value;var l=t.data[s].extraClass;e.className+=l?" "+l:""}e.setAttribute("data-value",n),e.setAttribute("data-index",s)},divertTarget:function(e){if(this.isIos){var t=this.refs.select,n=this.classes,s=t.querySelector("."+n.PLUG);s&&t.removeChild(s)}var r=e.target.selectedIndex,i={type:e.type,target:this.data[r]};this.multipleTags&&(e.preventDefault(),e.stopPropagation()),this.setSelectValue(i),this.multiple||this.toggleList(e,"close")},firstTouchController:function(e){var t=this.refs;if(this.onFirstTouch)try{this.onFirstTouch(e)}catch(e){console.warn('something may be wrong in "onFirstTouch"',e)}t.selected.removeEventListener("click",this.firstTouchController),t.select.removeEventListener("focus",this.firstTouchController),this.props.openOnHover&&t.wrapper.removeEventListener("mouseenter",this.firstTouchController)},hideEmptySection:function(e){for(var t=this.selectedClass,n=this.refs.sections,s=0;sa?o=0:o<0&&(o=a);var l=this.classes,u=i["default"].hasClass,c=r[o];s.selectedIndex=o,(u(c,l.HIDDEN)||u(c,l.SELECTED_HIDDEN)||u(c,l.SEARCH_HIDDEN)||u(c,l.DISABLED))&&this.setKeypress(e)},setSelectValue:function(e,t){var n=this.refs,s=void 0;if(t?this.setSelectValueClick(t):(s=e.keyCode,this.setSelectValueButton(e)),this.displaySelected(n.selected,n),!this.programmaticClick){var r=[9,16,17,18,20,91];if(t||"blur"===e.type||!s&&"change"===e.type||s&&r.indexOf(s)===-1)if(this.toggleList.justOpened&&!t)this.toggleList.justOpened=!1;else if(this.onChange)try{this.onChange(t,this.getSelectedValues())}catch(t){console.warn("something may be wrong in onChange",t)}this.programmaticClick=!1}},setSelectValueButton:function(){var e=this.refs,t=e.data,n=this.selectedClass,s=void 0;if(this.multipleTags)return!1;this.removeSelectedClass(t);var r=this.getSelected(),a=r[0];a&&(s=t[a.index],i["default"].addClass(s,n),i["default"].scrollTo(s,e.optionsListWrapper))},setSelectValueClick:function(e){var t=this.multiple,n=this.refs,s=this.selectedClass,r=e.target,a=r.getAttribute("data-index"),o=n.selectOptions[a];t&&(!t||this.multipleTags||e[this.multiSelect])||this.forceMultiple?(i["default"].toggleClass(r,s),o.selected=!o.selected):(this.deselectAll(),i["default"].addClass(r,s),o.selected=o.selected!==!0),this.forceMultiple=!1,this.hideEmptySection(r.parentNode);var l=n.selectOptions[0];""===l.value&&this.getSelected().length>1&&(i["default"].removeClass(n.data[0],s),n.selectOptions[0].selected=!1)},toggleClosed:function(e,t,n,s){var r=arguments.length>4&&void 0!==arguments[4]&&arguments[4],a=this.classes;i["default"].addClass(n.optionsListWrapper,a.HIDDEN),i["default"].removeClass(s,a.OPEN);var o=document.querySelector("html");if(o.removeEventListener("click",this.catchBodyClick),o.removeEventListener("touchend",this.catchBodyClick),this.search?this.fuzzySearchReset():this.removeSelectKeyListener(),r||setTimeout(function(){return n.flounder.focus()},0),this.onClose&&this.ready)try{this.onClose(e,this.getSelectedValues())}catch(e){console.warn('something may be wrong in "onClose"',e)}},toggleList:function(e,t){var n=this.classes,s=this.refs,r=s.optionsListWrapper,a=s.wrapper,o=i["default"].hasClass(r,n.HIDDEN),l=e.type;"mouseleave"!==l&&"close"!==t&&o?("keydown"===l&&(this.toggleList.justOpened=!0),this.toggleOpen(e,r,s,a)):(this.toggleList.justOpened=!1,this.toggleClosed(e,r,s,a))},toggleListSearchClick:function(e){var t=this.classes;i["default"].hasClass(this.refs.wrapper,t.OPEN)||this.toggleList(e,"open")},toggleOpen:function(e,t,n){if(!this.isIos||this.search||this.multipleTags===!0){var s=this.classes;i["default"].removeClass(n.optionsListWrapper,s.HIDDEN),i["default"].addClass(n.wrapper,s.OPEN);var r=document.querySelector("html");r.addEventListener("click",this.catchBodyClick),r.addEventListener("touchend",this.catchBodyClick)}if(!this.multipleTags){var a=n.select.selectedIndex,o=n.data[a];i["default"].scrollTo(o,n.optionsListWrapper)}this.search?setTimeout(function(){return n.search.focus()},0):(this.addSelectKeyListener(),setTimeout(function(){return n.select.focus()},0));var l=n.data.length;if(this.props.placeholder&&l--,n.multiTagWrapper){var u=n.multiTagWrapper.children.length-1;u===l&&(this.removeNoResultsMessage(),this.addNoMoreOptionsMessage())}if(this.onOpen&&this.ready)try{this.onOpen(e,this.getSelectedValues())}catch(e){console.warn('something may be wrong in "onOpen"',e)}}};n["default"]=l},{"./keycodes":18,"./utils":20}],17:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}function r(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t1)console.warn("Flounder - More than one element found.\n Dropping all but the first.");else if(0===t.length)throw"Flounder - No target element found.";t=t[0]}return t.flounder&&t.flounder.destroy(),this.init(t,n)}console.warn("Flounder - No target element found.")}return o(e,[{key:"componentWillUnmount",value:function(){if(this.onComponentWillUnmount)try{this.onComponentWillUnmount()}catch(e){console.warn('something may be wrong in "onComponentWillUnmount"',e)}this.removeListeners(),this.originalChildren&&this.popInSelectElements(this.refs.select)}}]),o(e,[{key:"filterSearchResults",value:function(e){var t=e.target.value.trim();this.fuzzySearch.previousValue=t;var n=this.search.isThereAnythingRelatedTo(t)||[];if(""!==t){var s=this.refs.data,r=this.refs.sections,i=this.classes;s.forEach(function(e){c["default"].addClass(e,i.SEARCH_HIDDEN)}),r.forEach(function(e){c["default"].addClass(e,i.SEARCH_HIDDEN)}),n.forEach(function(e){c["default"].removeClass(s[e.i],i.SEARCH_HIDDEN),"number"==typeof e.d.s&&c["default"].removeClass(r[e.d.s],i.SEARCH_HIDDEN)}),this.refs.noMoreOptionsEl||(0===n.length?this.addNoResultsMessage():this.removeNoResultsMessage())}else this.fuzzySearchReset()}},{key:"fuzzySearch",value:function(e){if(this.fuzzySearch.previousValue=this.fuzzySearch.previousValue||"",this.onInputChange)try{this.onInputChange(e)}catch(e){console.warn('something may be wrong in "onInputChange"',e)}if(this.toggleList.justOpened)this.toggleList.justOpened=!1;else{e.preventDefault();var t=e.keyCode;if(t!==L["default"].UP&&t!==L["default"].DOWN&&t!==L["default"].ENTER&&t!==L["default"].ESCAPE)if(this.multipleTags&&t===L["default"].BACKSPACE&&""===this.fuzzySearch.previousValue){var n=this.refs.search.previousSibling;n&&setTimeout(function(){return n.focus()},0)}else this.filterSearchResults(e);else t!==L["default"].ESCAPE&&t!==L["default"].ENTER||(this.fuzzySearchReset(),this.toggleList(e,"close"),this.addPlaceholder())}}},{key:"fuzzySearchReset",value:function(){var e=this.refs,t=this.classes;e.sections.forEach(function(e){c["default"].removeClass(e,t.SEARCH_HIDDEN)}),e.data.forEach(function(e){c["default"].removeClass(e,t.SEARCH_HIDDEN)}),e.search.value="",this.removeNoResultsMessage()}},{key:"init",value:function(e,t){if(this.props=t,this.bindThis(),this.initializeOptions(),this.setTarget(e),this.search&&(this.search=new y["default"](this)),this.onInit)try{this.onInit()}catch(n){console.warn('something may be wrong in "onInit"',n)}this.buildDom();var s=c["default"].setPlatform(),r=s.isOsx,i=s.isIos,a=s.multiSelect;if(this.isOsx=r,this.isIos=i,this.multiSelect=a,this.onRender(),this.onComponentDidMount)try{this.onComponentDidMount()}catch(n){console.warn("something may be wrong in onComponentDidMount",n)}return this.ready=!0,this.originalTarget.flounder=this.target.flounder=this,this.refs.flounder.flounder=this}},{key:"initializeOptions",value:function(){var e=this.props=this.props||{};for(var t in l.defaultOptions)if("onChange"===t&&e.onSelect)this.onChange=e.onSelect,console.warn("Please use onChange. onSelect has been\n depricated and will be removed in 2.0.0"),this.onSelect=function(){console.warn("Please use onChange. onSelect has been\n depricated and will be removed in 2.0.0"),this.onChange.apply(this,arguments)};else if("classes"===t){this.classes={};var n=l.defaultOptions[t],s="object"===a(e[t])?e[t]:{};for(var i in n)this.classes[i]=s[i]?s[i]:n[i]}else"data"===t?this.data=e.data&&e.data.length?[].concat(r(e.data)):[].concat(r(l.defaultOptions.data)):this[t]=void 0!==e[t]?e[t]:l.defaultOptions[t];this.selectedClass=this.classes.SELECTED,e.defaultEmpty&&(this.placeholder=""),this.multipleTags&&(this.search=!0,this.multiple=!0,this.selectedClass+=" "+this.classes.SELECTED_HIDDEN)}},{key:"onRender",value:function(){var e=this.props,t=this.refs;if(this.isIos&&!this.multiple){var n=t.select,s=this.classes;c["default"].removeClass(n,s.HIDDEN),c["default"].addClass(n,s.HIDDEN_IOS)}this.addListeners(t,e)}},{key:"sortData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=this,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,i=0;return e.forEach(function(e){e.header?(t=n.sortData(e.data,t,s,i),i++):("object"!==("undefined"==typeof e?"undefined":a(e))?e={text:e,value:e,index:s}:e.index=s,void 0!==r&&(e.s=r),t.push(e),s++)}),t}}]),e}();S.find=function(e,t){return"string"==typeof e?e=document.querySelectorAll(e):1===e.nodeType&&(e=[e]),Array.prototype.slice.call(e,0).map(function(e){return new S(e,t)})},Object.defineProperty(S,"version",{get:function(){return C["default"]}}),Object.defineProperty(S.prototype,"version",{get:function(){return C["default"]}}),c["default"].extendClass(S,f["default"],p["default"],g["default"]),n["default"]=S},{"./api":12,"./build":13,"./defaults":15,"./events":16,"./keycodes":18,"./search":19,"./utils":20,"./version":21}],18:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var s={BACKSPACE:8,DOWN:40,ENTER:13,ESCAPE:27,LEFT:37,RIGHT:39,SPACE:32,TAB:9,UP:38,NON_CHARACTER_KEYS:[16,17,18,20,91,93]};n["default"]=s},{}],19:[function(e,t,n){"use strict";function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;nt?1:e=i.minimumScore}},{key:"isThereAnythingRelatedTo",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=void 0;if(e=e.length?e:""+e,!(e.length>=i.minimumValueLength))return!1;this.query=e.toLowerCase().split(" ");var n=this.flounder.data;return n=this.flounder.sortData(n),t=this.ratedRes=n.map(this.getResultWeights),t=t.filter(this.isItemAboveMinimum),t.sort(this.compareScoreCards),this.ratedRes=t}},{key:"startsWith",value:function(e,t,n){var s=t.length,r=e.length;if(r<=s){var i=t.toLowerCase().slice(0,r);if(i===e)return n}return 0}},{key:"scoreThis",value:function(e,t,n){var s=this,r=0;return e&&this.query.forEach(function(i){i=s.escapeRegExp(i);var a=0;"string"==typeof e?(i=new RegExp(i,"g"),a=(e.match(i)||[]).length):e[0]?e.forEach(function(e){a+=e.indexOf(i)!==-1?1:0}):a=e[i]||1e-6,a>0?r=t*a*10:n!==!0&&(r=-t)}),Math.floor(r)}}]),e}();n["default"]=a},{}],20:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var r=e("microbejs/src/modules/http"),i=s(r),a={addClass:function(e,t){if("string"!=typeof t&&t.length)return t.forEach(function(t){a.addClass(e,t)}),!0;var n=e.className,s=n.length,r=n.slice(s-t.length-1,s);a.hasClass(e,t)||n.slice(0,t.length+1)===t+" "||r===" "+t||(n+=" "+t),e.className=n.trim()},attachAttributes:function(e,t){if(!t)return null;for(var n in t)"data-"===n.slice(0,5)?e.setAttribute(n,t[n]):e[n]=t[n]},constructElement:function(e){var t=document.createElement(e.tagname||"div");return a.attachAttributes(t,e),t},debounce:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this,s=void 0,r=void 0,i=function(){return e.apply(n,s)};return function(){clearTimeout(r),s=arguments,r=setTimeout(i,t)}},extendClass:function(e){function t(t){for(var n in t)e[n]=t[n]}e=e.prototype;for(var n=arguments.length,s=Array(n>1?n-1:0),r=1;r/g,">").replace(/"/g,""")},getElWidth:function(e,t,n){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1500,r=window.getComputedStyle(e);if(0===e.offsetWidth&&this.checkWidthAgain!==!0){if(!t||!n)throw"Flounder getElWidth error: no callback given.";setTimeout(t.bind(n),s),this.checkWidthAgain=!0}else this.checkWidthAgain=!1;return e.offsetWidth+parseInt(r["margin-left"])+parseInt(r["margin-right"])},hasClass:function(e,t){var n=e.className,s=new RegExp("(^"+t+" )|( "+t+"$)|( "+t+" )|(^"+t+"$)");return!!n.match(s)},http:!1,iosVersion:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window;return!!/iPad|iPhone|iPod/.test(e.navigator.platform)&&(e.indexedDB?"8+":e.SpeechSynthesisUtterance?"7":e.webkitAudioContext?"6":"5-")},removeAllChildren:function(e){Array.prototype.slice.call(e.children,0).forEach(function(t){e.removeChild(t)})},removeClass:function(e,t){if("string"!=typeof t&&t.length)return t.forEach(function(t){a.removeClass(e,t)}),!0;var n=e.className,s=n.length,r=t.length;n===t?n="":n.slice(0,r+1)===t+" "?n=n.slice(r+1,s):n.slice(s-r-1,s)===" "+t?n=n.slice(0,s-r-1):n.indexOf(" "+t+" ")!==-1&&(n=n.replace(" "+t+" "," ")),e.className=n.trim()},scrollTo:function(e,t){if(e){var n=t||e.offsetParent;if(n.scrollHeight>n.offsetHeight){var s=e.offsetTop,r=e.offsetHeight,i=n.offsetHeight,a=n.scrollTop,o=a+n.offsetHeight-r;so&&(n.scrollTop=s-(i-r))}}return!1},setPlatform:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window,t=e.navigator.platform,n=t.indexOf("Mac")!==-1,s=a.iosVersion(e),r=n?"metaKey":"ctrlKey";return{isOsx:n,isIos:s,multiSelect:r}},toggleClass:function(e,t){a.hasClass(e,t)?a.removeClass(e,t):a.addClass(e,t)}};(0,i["default"])(a),n["default"]=a},{"microbejs/src/modules/http":3}],21:[function(e,t,n){"use strict";t.exports="1.3.0"},{}],22:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}var r=e("../core/flounder"),i=s(r);!function(e){e.core.flounder=function(e){var t=i["default"].prototype.destroy;return this.each(function(n){var s=new i["default"](n,e);n.data=n.data||{},n.data.flounder=n.data.flounder||{},n.data.flounder.flounder=s,s.destroy=function(){n.data.flounder.flounder=!1,t.call(s)}}),this}}(µ)},{"../core/flounder":17}]},{},[22]); \ No newline at end of file +/*! Flounder v1.3.1 | (c) 2015-2017 Sociomantic Labs | https://github.com/sociomantic-tsunami/flounder/license */!function e(t,n,s){function i(a,o){if(!n[a]){if(!t[a]){var l="function"==typeof require&&require;if(!o&&l)return l(a,!0);if(r)return r(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var c=n[a]={exports:{}};t[a][0].call(c.exports,function(e){var n=t[a][1][e];return i(n?n:e)},c,c.exports,e,t,n,s)}return n[a].exports}for(var r="function"==typeof require&&require,a=0;ac){for(var t=0,n=o.length-u;t "+t+") {","args = new Array(arguments.length + 1);","for (var i = 0; i < arguments.length; i++) {","args[i] = arguments[i];","}","}","return new Promise(function (rs, rj) {","var cb = "+o+";","var res;","switch (argLength) {",n.concat(["extra"]).map(function(e,t){return"case "+t+":res = fn.call("+["self"].concat(n.slice(0,t)).concat("cb").join(",")+");break;"}).join(""),"default:","args[argLength] = cb;","res = fn.apply(self, args);","}","if (res &&",'(typeof res === "object" || typeof res === "function") &&','typeof res.then === "function"',") {rs(res);}","});","};"].join("");return Function(["Promise","fn"],i)(r,e)}var r=e("./core.js"),a=e("asap");t.exports=r,r.denodeify=function(e,t){return"number"==typeof t&&t!==1/0?s(e,t):i(e)};var o="function (err, res) {if (err) { rj(err); } else { rs(res); }}";r.nodeify=function(e){return function(){var t=Array.prototype.slice.call(arguments),n="function"==typeof t[t.length-1]?t.pop():null,s=this;try{return e.apply(this,arguments).nodeify(n,s)}catch(i){if(null===n||"undefined"==typeof n)return new r(function(e,t){t(i)});a(function(){n.call(s,i)})}}},r.prototype.nodeify=function(e,t){return"function"!=typeof e?this:void this.then(function(n){a(function(){e.call(t,null,n)})},function(n){a(function(){e.call(t,n)})})}},{"./core.js":5,asap:1}],11:[function(e,t,n){"use strict";var s=e("./core.js");t.exports=s,s.enableSynchronous=function(){s.prototype.isPending=function(){return 0==this.getState()},s.prototype.isFulfilled=function(){return 1==this.getState()},s.prototype.isRejected=function(){return 2==this.getState()},s.prototype.getValue=function(){if(3===this._65)return this._55.getValue();if(!this.isFulfilled())throw new Error("Cannot get a value of an unfulfilled promise.");return this._55},s.prototype.getReason=function(){if(3===this._65)return this._55.getReason();if(!this.isRejected())throw new Error("Cannot get a rejection reason of a non-rejected promise.");return this._55},s.prototype.getState=function(){return 3===this._65?this._55.getState():this._65===-1||this._65===-2?0:this._65}},s.disableSynchronous=function(){s.prototype.isPending=void 0,s.prototype.isFulfilled=void 0,s.prototype.isRejected=void 0,s.prototype.getValue=void 0,s.prototype.getReason=void 0,s.prototype.getState=void 0}},{"./core.js":5}],12:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){var n=[],s=!0,i=!1,r=void 0;try{for(var a,o=e[Symbol.iterator]();!(s=(a=o.next()).done)&&(n.push(a.value),!t||n.length!==t);s=!0);}catch(l){i=!0,r=l}finally{try{!s&&o["return"]&&o["return"]()}finally{if(i)throw r}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),r=e("./utils"),a=s(r),o=e("./defaults"),l={buildFromUrl:function(e,t){var n=this;return this.loadDataFromUrl(e,function(e){n.data=e,t&&t(n.data),n.rebuild(n.data)}),[]},clickByIndex:function(e,t){return this.setByIndex(e,t,!1)},clickByText:function(e,t){return this.setByText(e,t,!1)},clickByValue:function(e,t){return this.setByValue(e,t,!1)},destroy:function(){this.componentWillUnmount();var e=this.refs,t=this.classes,n=this.originalTarget,s=n.tagName;if("INPUT"===s||"SELECT"===s){var i=n.nextElementSibling;if("SELECT"===s){var r=n[0];r&&a["default"].hasClass(r,t.PLACEHOLDER)&&n.removeChild(r)}else i=e.flounder.parentNode;try{var o=this.classes;i.parentNode.removeChild(i),n.tabIndex=0,a["default"].removeClass(n,o.HIDDEN)}catch(l){throw" : this flounder may have already been removed"}}else try{var u=e.wrapper,c=u.parentNode;c.removeChild(u)}catch(l){throw" : this flounder may have already been removed"}e.flounder.flounder=n.flounder=this.target.flounder=null},deselectAll:function(e){if(this.removeSelectedClass(),this.removeSelectedValue(),this.multiple){var t=this.refs.multiTagWrapper;if(t){for(var n=t.children,s=0;s2&&void 0!==arguments[2])||arguments[2],s=this.refs;if("string"!=typeof e&&e.length){var f=this.setByIndex.bind(this);return e.map(function(e){return f(e,t,n)})}var i=this.data,r=i.length;e<0&&(r=i.length,e=r+e);var a=s.data[e];return a?(this.forceMultiple=t&&this.multiple,this.programmaticClick=n,a.click(),a):null},setByText:function h(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof e&&e.length){var h=this.setByText.bind(this);return e.map(function(e){return h(e,t,n)})}var s=[];return e=""+e,this.refs.data.forEach(function(t,n){var i=t.innerHTML;i===e&&s.push(n)}),this.setByIndex(s,t,n)},setByValue:function p(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof e&&e.length){var p=this.setByValue.bind(this);return e.map(function(e){return p(e,t,n)})}var s=this.refs.selectOptions.map(function(t,n){return""+t.value==""+e?n:null}).filter(function(e){return 0===e||!!e});return this.setByIndex(s,t,n)}};n["default"]=l},{"./defaults":15,"./utils":20}],13:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r=e("./defaults"),a=e("./utils"),o=s(a),l={addOptionDescription:function(e,t){var n=document.createElement("div");n.innerHTML=t,n.className=this.classes.DESCRIPTION,e.appendChild(n)},addSearch:function(e){if(this.search){var t=this.classes,n=o["default"].constructElement({tagname:"input",type:"text",className:t.SEARCH,tabIndex:-1});return e.appendChild(n),n}return!1},bindThis:function(){var e=this;["addHoverClass","catchBodyClick","checkClickTarget","checkFlounderKeypress","checkMultiTagKeydown","clearPlaceholder","clickSet","divertTarget","displayMultipleTags","firstTouchController","fuzzySearch","removeHoverClass","removeMultiTag","setKeypress","setSelectValue","toggleList","toggleListSearchClick"].forEach(function(t){e[t]=e[t].bind(e),e[t].isBound=!0})},buildArrow:function(e,t){if(e.disableArrow)return!1;var n=this.classes,s=t({className:n.ARROW}),i=t({className:n.ARROW_INNER});return s.appendChild(i),s},buildData:function(e,t,n,s){function r(t,n){t.index=n;var s=n===e.index?" "+v:"",i={className:T.OPTION+s,"data-index":n};for(var r in t)"text"!==r&&"description"!==r&&(i[r]=t[r]);var a=p(i);return a.innerHTML=C?t.text:g(t.text),t.description&&l.addOptionDescription(a,t.description,T.DESCRIPTION),a.className+=t.extraClass?" "+t.extraClass:"",a.setAttribute("role","option"),a}function a(t,n){var i=void 0;if(E){var r=E.children[n];i=r,r.setAttribute("value",r.value),r.disabled===!0&&d[n]&&m(d[n],T.DISABLED),m(r,T.OPTION_TAG)}else{var a=t.extraClass||"",o=T.OPTION_TAG+" "+a;i=p({tagname:"option",className:o.trim(),value:t.value});var l=g(t.text);i.innerHTML=l;var u=t.disabled;u&&i.setAttribute("disabled",u),s.appendChild(i)}return n===e.index&&(i.selected=!0),i.getAttribute("disabled")&&m(d[n],T.DISABLED),i}var l=this,u=0,c=0,d=[],f=[],h=[],p=o["default"].constructElement,v=this.selectedClass,g=o["default"].escapeHTML,m=o["default"].addClass,y=this.refs,E=y.select,C=this.allowHTML,T=this.classes;return t.forEach(function(e,s){if("object"!==("undefined"==typeof e?"undefined":i(e))&&(e=t[s]={text:e,value:e}),e.header){var l=p({tagname:"div",className:T.SECTION}),v=p({tagname:"div",className:T.HEADER});v.textContent=e.header,l.appendChild(v),n.appendChild(l);var g=e.data;g.forEach(function(e,t){"object"!==("undefined"==typeof e?"undefined":i(e))&&(e=g[t]={text:e,value:e}),d[u]=r(e,u),l.appendChild(d[u]),f[u]=a(e,u),u++}),0==g.length&&o["default"].addClass(l,T.HIDDEN),h[c]=l,c++}else d[u]=r(e,u),n.appendChild(d[u]),f[u]=a(e,u),u++}),[d,f,h]},buildDom:function(){var e=this.props,t=this.classes;this.refs={};var n=o["default"].constructElement,s=o["default"].constructElement({className:t.MAIN_WRAPPER}),i=t.MAIN,a=this.multipleTags?i+" "+t.MULTIPLE_TAG_FLOUNDER:i,l=n({className:a});l.setAttribute("aria-hidden",!0),l.tabIndex=0,s.appendChild(l);var u=this.initSelectBox(s);u.tabIndex=-1;var c=this.data;this.defaultObj=(0,r.setDefaultOption)(this,this.props,c);var d=this.defaultObj,f=t.SELECTED_DISPLAYED;d.value&&d.extraClass&&(f+=" "+d.extraClass);var h=n({className:f,"data-value":d.value,"data-index":d.index}),p=this.multipleTags?n({className:t.MULTI_TAG_LIST}):null,v=n({className:t.OPTIONS_WRAPPER+" "+t.HIDDEN}),g=n({className:t.LIST});g.setAttribute("role","listbox"),v.appendChild(g),this.multiple===!0&&(u.setAttribute("multiple",""),g.setAttribute("aria-multiselectable","true"));var m=this.buildArrow(e,n);[h,p,v,m].forEach(function(e){e&&l.appendChild(e)});var y=this.addSearch(this.multipleTags?p:l),E=this.buildData(d,c,g,u);c=E[0];var C=E[1],T=E[2];if(this.target.appendChild(s),this.refs={wrapper:s,flounder:l,selected:h,arrow:m,optionsListWrapper:v,search:y,multiTagWrapper:p,optionsList:g,select:u,data:c,sections:T,selectOptions:C},this.multipleTags){var L=this.getSelected();0===L.length?h.innerHTML=d.text:this.displayMultipleTags(L,p)}else h.innerHTML=d.text},buildMultiTag:function(e){var t=this.classes,n=e.innerHTML,s=document.createElement("SPAN");s.className=t.MULTIPLE_SELECT_TAG,s.setAttribute("aria-label","Close"),s.setAttribute("tabindex",0);var i=document.createElement("A");return i.className=t.MULTIPLE_TAG_CLOSE,i.setAttribute("data-index",e.index),s.appendChild(i),s.innerHTML+=n,s},initSelectBox:function(e){var t=this.target,n=this.refs,s=n.select,i=this.classes;if("SELECT"===t.tagName){if(o["default"].addClass(t,i.SELECT_TAG),o["default"].addClass(t,i.HIDDEN),s=t,this.props.keepChangesOnDestroy||this.popOutSelectElements(s),t.length>0&&!this.selectDataOverride){this.refs.select=s;for(var r=[],a=[],l=0;l=0?e[s]:null;return i?(i.index=s,i):null}function i(){var i=e.sortData(o);!a.multipleTags&&!a.multiple||a.defaultIndex||a.defaultValue||(a.placeholder=a.placeholder||l.placeholder),a.defaultEmpty&&(a.placeholder="");var r=a.placeholder;if(r||""===r||0===i.length)return n(e,i);var c=void 0;if(u){var d=e.refs.selected.getAttribute("data-value");if(c=s(i,d))return c}return c=a.defaultIndex?t(i):null,c=!c&&a.defaultValue?s(i):c,c=c?c:t(i,0)}var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments[2],u=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return o=o||a.data||[],i()}};n.setDefaultOption=u.setDefaultOption;n["default"]=u},{"./classes":14,"./utils":20}],16:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var i=e("./utils"),r=s(i),a=e("./keycodes"),o=s(a),l={addFirstTouchListeners:function(){var e=this.refs;e.selected.addEventListener("click",this.firstTouchController),e.select.addEventListener("focus",this.firstTouchController),this.props.openOnHover&&e.wrapper.addEventListener("mouseenter",this.firstTouchController)},addHoverClass:function(e){r["default"].addClass(e.target,this.classes.HOVER)},addListeners:function(e){var t=this.isIos,n=t?"blur":"change";if(e.select.addEventListener(n,this.divertTarget),e.flounder.addEventListener("keydown",this.checkFlounderKeypress),this.props.openOnHover){var s=e.wrapper;s.addEventListener("mouseenter",this.toggleList),s.addEventListener("mouseleave",this.toggleList)}else e.selected.addEventListener("click",this.toggleList);this.addFirstTouchListeners(),this.addOptionsListeners(),this.search&&this.addSearchListeners()},addMultipleTags:function(e,t){var n=this;e.forEach(function(e){if(""!==e.value){var s=n.buildMultiTag(e);t.insertBefore(s,t.lastChild)}else e.selected=!1});for(var s=t.children,i=0;i1)for(var o=0;o=48&&t<=57||t>=65&&t<=90)&&n.search&&"INPUT"===e.target.tagName&&(n.selected.innerHTML="")},checkMultiTagKeydown:function(e){var t=this,n=e.keyCode,s=e.target,i=[o["default"].BACKSPACE,o["default"].LEFT,o["default"].RIGHT];i.indexOf(n)!==-1?(e.preventDefault(),e.stopPropagation(),n===o["default"].BACKSPACE?this.checkMultiTagKeydownRemove(s):this.checkMultiTagKeydownNavigate(n,s)):e.key.length<2&&setTimeout(function(){return t.refs.search.focus()},0)},checkMultiTagKeydownNavigate:function(e,t){if(e===o["default"].LEFT){var n=t.previousSibling;n&&n.focus()}else if(e===o["default"].RIGHT){var s=t.nextSibling;s&&setTimeout(function(){return s.focus()},0)}},checkMultiTagKeydownRemove:function(e){var t=e.previousSibling,n=e.nextSibling;e.firstChild.click(),t?setTimeout(function(){return t.focus()},0):n&&n.focus()},clearPlaceholder:function(){this.refs.selected.innerHTML=""},clickSet:function(e){e.preventDefault(),e.stopPropagation(),this.setSelectValue({},e),this.programmaticClick||this.toggleList(e,"close"),this.programmaticClick=!1},displayMultipleTags:function(e,t){for(var n=t.children,s=0;s0?this.addMultipleTags(e,t):this.addPlaceholder()},displaySelected:function(e,t){var n=[],s=-1,i=this.getSelected(),r=i.length,a=this.multipleTags;if(e.className=this.classes.SELECTED_DISPLAYED,a||1!==r)if(a||0!==r)a?(e.innerHTML="",this.displayMultipleTags(i,t.multiTagWrapper)):e.innerHTML=this.multipleMessage,s=i.map(function(e){return e.index}),n=i.map(function(e){return e.value});else{var o=this.defaultObj;s=o.index||-1,e.innerHTML=o.text,n=o.value}else{s=i[0].index,e.innerHTML=t.data[s].innerHTML,n=i[0].value;var l=t.data[s].extraClass;e.className+=l?" "+l:""}e.setAttribute("data-value",n),e.setAttribute("data-index",s)},divertTarget:function(e){if(this.isIos){var t=this.refs.select,n=this.classes,s=t.querySelector("."+n.PLUG);s&&t.removeChild(s)}var i=e.target.selectedIndex,r={type:e.type,target:this.data[i]};this.multipleTags&&(e.preventDefault(),e.stopPropagation()),this.setSelectValue(r), +this.multiple||this.toggleList(e,"close")},firstTouchController:function(e){var t=this.refs;if(this.onFirstTouch)try{this.onFirstTouch(e)}catch(e){console.warn('something may be wrong in "onFirstTouch"',e)}t.selected.removeEventListener("click",this.firstTouchController),t.select.removeEventListener("focus",this.firstTouchController),this.props.openOnHover&&t.wrapper.removeEventListener("mouseenter",this.firstTouchController)},hideEmptySection:function(e){for(var t=this.selectedClass,n=this.refs.sections,s=0;sa?o=0:o<0&&(o=a);var l=this.classes,u=r["default"].hasClass,c=i[o];s.selectedIndex=o,(u(c,l.HIDDEN)||u(c,l.SELECTED_HIDDEN)||u(c,l.SEARCH_HIDDEN)||u(c,l.DISABLED))&&this.setKeypress(e)},setSelectValue:function(e,t){var n=this.refs,s=void 0;if(t?this.setSelectValueClick(t):(s=e.keyCode,this.setSelectValueButton(e)),this.displaySelected(n.selected,n),!this.programmaticClick){var i=[9,16,17,18,20,91];if(t||"blur"===e.type||!s&&"change"===e.type||s&&i.indexOf(s)===-1)if(this.toggleList.justOpened&&!t)this.toggleList.justOpened=!1;else if(this.onChange)try{this.onChange(t,this.getSelectedValues())}catch(t){console.warn("something may be wrong in onChange",t)}this.programmaticClick=!1}},setSelectValueButton:function(){var e=this.refs,t=e.data,n=this.selectedClass,s=void 0;if(this.multipleTags)return!1;this.removeSelectedClass(t);var i=this.getSelected(),a=i[0];a&&(s=t[a.index],r["default"].addClass(s,n),r["default"].scrollTo(s,e.optionsListWrapper))},setSelectValueClick:function(e){var t=this.multiple,n=this.refs,s=this.selectedClass,i=e.target,a=i.getAttribute("data-index"),o=n.selectOptions[a];t&&(!t||this.multipleTags||e[this.multiSelect])||this.forceMultiple?(r["default"].toggleClass(i,s),o.selected=!o.selected):(this.deselectAll(),r["default"].addClass(i,s),o.selected=o.selected!==!0),this.forceMultiple=!1,this.hideEmptySection(i.parentNode);var l=n.selectOptions[0];""===l.value&&this.getSelected().length>1&&(r["default"].removeClass(n.data[0],s),n.selectOptions[0].selected=!1)},toggleClosed:function(e,t,n,s){var i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],a=this.classes;r["default"].addClass(n.optionsListWrapper,a.HIDDEN),r["default"].removeClass(s,a.OPEN);var o=document.querySelector("html");if(o.removeEventListener("click",this.catchBodyClick),o.removeEventListener("touchend",this.catchBodyClick),this.search?this.fuzzySearchReset():this.removeSelectKeyListener(),i||setTimeout(function(){return n.flounder.focus()},0),this.onClose&&this.ready)try{this.onClose(e,this.getSelectedValues())}catch(e){console.warn('something may be wrong in "onClose"',e)}},toggleList:function(e,t){var n=this.classes,s=this.refs,i=s.optionsListWrapper,a=s.wrapper,o=r["default"].hasClass(i,n.HIDDEN),l=e.type;"mouseleave"!==l&&"close"!==t&&o?("keydown"===l&&(this.toggleList.justOpened=!0),this.toggleOpen(e,i,s,a)):(this.toggleList.justOpened=!1,this.toggleClosed(e,i,s,a))},toggleListSearchClick:function(e){var t=this.classes;r["default"].hasClass(this.refs.wrapper,t.OPEN)||this.toggleList(e,"open")},toggleOpen:function(e,t,n){if(!this.isIos||this.search||this.multipleTags===!0){var s=this.classes;r["default"].removeClass(n.optionsListWrapper,s.HIDDEN),r["default"].addClass(n.wrapper,s.OPEN);var i=document.querySelector("html");i.addEventListener("click",this.catchBodyClick),i.addEventListener("touchend",this.catchBodyClick)}if(!this.multipleTags){var a=n.select.selectedIndex,o=n.data[a];r["default"].scrollTo(o,n.optionsListWrapper)}this.search?setTimeout(function(){return n.search.focus()},0):(this.addSelectKeyListener(),setTimeout(function(){return n.select.focus()},0));var l=n.data.length;if(this.props.placeholder&&l--,n.multiTagWrapper){var u=n.multiTagWrapper.children.length-1;u===l&&(this.removeNoResultsMessage(),this.addNoMoreOptionsMessage())}if(this.onOpen&&this.ready)try{this.onOpen(e,this.getSelectedValues())}catch(e){console.warn('something may be wrong in "onOpen"',e)}}};n["default"]=l},{"./keycodes":18,"./utils":20}],17:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}function i(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t1)console.warn("Flounder - More than one element found.\n Dropping all but the first.");else if(0===t.length)throw"Flounder - No target element found.";t=t[0]}return t.flounder&&t.flounder.destroy(),this.init(t,n)}console.warn("Flounder - No target element found.")}return o(e,[{key:"componentWillUnmount",value:function(){if(this.onComponentWillUnmount)try{this.onComponentWillUnmount()}catch(e){console.warn('something may be wrong in "onComponentWillUnmount"',e)}this.removeListeners(),this.originalChildren&&this.popInSelectElements(this.refs.select)}}]),o(e,[{key:"filterSearchResults",value:function(e){var t=e.target.value.trim();this.fuzzySearch.previousValue=t;var n=this.search.isThereAnythingRelatedTo(t)||[];if(""!==t){var s=this.refs.data,i=this.refs.sections,r=this.classes;s.forEach(function(e){c["default"].addClass(e,r.SEARCH_HIDDEN)}),i.forEach(function(e){c["default"].addClass(e,r.SEARCH_HIDDEN)}),n.forEach(function(e){c["default"].removeClass(s[e.i],r.SEARCH_HIDDEN),"number"==typeof e.d.s&&c["default"].removeClass(i[e.d.s],r.SEARCH_HIDDEN)}),this.refs.noMoreOptionsEl||(0===n.length?this.addNoResultsMessage():this.removeNoResultsMessage())}else this.fuzzySearchReset()}},{key:"fuzzySearch",value:function(e){if(this.fuzzySearch.previousValue=this.fuzzySearch.previousValue||"",this.onInputChange)try{this.onInputChange(e)}catch(e){console.warn('something may be wrong in "onInputChange"',e)}if(this.toggleList.justOpened)this.toggleList.justOpened=!1;else{e.preventDefault();var t=e.keyCode;if(t!==L["default"].UP&&t!==L["default"].DOWN&&t!==L["default"].ENTER&&t!==L["default"].ESCAPE)if(this.multipleTags&&t===L["default"].BACKSPACE&&""===this.fuzzySearch.previousValue){var n=this.refs.search.previousSibling;n&&setTimeout(function(){return n.focus()},0)}else this.filterSearchResults(e);else t!==L["default"].ESCAPE&&t!==L["default"].ENTER||(this.fuzzySearchReset(),this.toggleList(e,"close"),this.addPlaceholder())}}},{key:"fuzzySearchReset",value:function(){var e=this.refs,t=this.classes;e.sections.forEach(function(e){c["default"].removeClass(e,t.SEARCH_HIDDEN)}),e.data.forEach(function(e){c["default"].removeClass(e,t.SEARCH_HIDDEN)}),e.search.value="",this.removeNoResultsMessage()}},{key:"init",value:function(e,t){if(this.props=t,this.bindThis(),this.initializeOptions(),this.setTarget(e),this.search&&(this.search=new y["default"](this)),this.onInit)try{this.onInit()}catch(n){console.warn('something may be wrong in "onInit"',n)}this.buildDom();var s=c["default"].setPlatform(),i=s.isOsx,r=s.isIos,a=s.multiSelect;if(this.isOsx=i,this.isIos=r,this.multiSelect=a,this.onRender(),this.onComponentDidMount)try{this.onComponentDidMount()}catch(n){console.warn("something may be wrong in onComponentDidMount",n)}return this.ready=!0,this.originalTarget.flounder=this.target.flounder=this,this.refs.flounder.flounder=this}},{key:"initializeOptions",value:function(){var e=this.props=this.props||{};for(var t in l.defaultOptions)if("onChange"===t&&e.onSelect)this.onChange=e.onSelect,console.warn("Please use onChange. onSelect has been\n depricated and will be removed in 2.0.0"),this.onSelect=function(){console.warn("Please use onChange. onSelect has been\n depricated and will be removed in 2.0.0"),this.onChange.apply(this,arguments)};else if("classes"===t){this.classes={};var n=l.defaultOptions[t],s="object"===a(e[t])?e[t]:{};for(var r in n)this.classes[r]=s[r]?s[r]:n[r]}else"data"===t?this.data=e.data&&e.data.length?[].concat(i(e.data)):[].concat(i(l.defaultOptions.data)):this[t]=void 0!==e[t]?e[t]:l.defaultOptions[t];this.selectedClass=this.classes.SELECTED,e.defaultEmpty&&(this.placeholder=""),this.multipleTags&&(this.search=!0,this.multiple=!0,this.selectedClass+=" "+this.classes.SELECTED_HIDDEN)}},{key:"onRender",value:function(){var e=this.props,t=this.refs;if(this.isIos&&!this.multiple){var n=t.select,s=this.classes;c["default"].removeClass(n,s.HIDDEN),c["default"].addClass(n,s.HIDDEN_IOS)}this.addListeners(t,e)}},{key:"sortData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=this,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,r=0;return e.forEach(function(e){e.header?(t=n.sortData(e.data,t,s,r),r++):("object"!==("undefined"==typeof e?"undefined":a(e))?e={text:e,value:e,index:s}:e.index=s,void 0!==i&&(e.s=i),t.push(e),s++)}),t}}]),e}();S.find=function(e,t){return"string"==typeof e?e=document.querySelectorAll(e):1===e.nodeType&&(e=[e]),Array.prototype.slice.call(e,0).map(function(e){return new S(e,t)})},Object.defineProperty(S,"version",{get:function(){return C["default"]}}),Object.defineProperty(S.prototype,"version",{get:function(){return C["default"]}}),c["default"].extendClass(S,f["default"],p["default"],g["default"]),n["default"]=S},{"./api":12,"./build":13,"./defaults":15,"./events":16,"./keycodes":18,"./search":19,"./utils":20,"./version":21}],18:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var s={BACKSPACE:8,DOWN:40,ENTER:13,ESCAPE:27,LEFT:37,RIGHT:39,SPACE:32,TAB:9,UP:38,NON_CHARACTER_KEYS:[16,17,18,20,91,93]};n["default"]=s},{}],19:[function(e,t,n){"use strict";function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;nt?1:e=r.minimumScore}},{key:"isThereAnythingRelatedTo",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=void 0;if(e=e.length?e:""+e,!(e.length>=r.minimumValueLength))return!1;this.query=e.toLowerCase().split(" ");var n=this.flounder.data;return n=this.flounder.sortData(n),t=this.ratedRes=n.map(this.getResultWeights),t=t.filter(this.isItemAboveMinimum),t.sort(this.compareScoreCards),this.ratedRes=t}},{key:"startsWith",value:function(e,t,n){var s=t.length,i=e.length;if(i<=s){var r=t.toLowerCase().slice(0,i);if(r===e)return n}return 0}},{key:"scoreThis",value:function(e,t,n){var s=this,i=0;return e&&this.query.forEach(function(r){r=s.escapeRegExp(r);var a=0;"string"==typeof e?(r=new RegExp(r,"g"),a=(e.match(r)||[]).length):e[0]?e.forEach(function(e){a+=e.indexOf(r)!==-1?1:0}):a=e[r]||1e-6,a>0?i=t*a*10:n!==!0&&(i=-t)}),Math.floor(i)}}]),e}();n["default"]=a},{}],20:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var i=e("microbejs/src/modules/http"),r=s(i),a={addClass:function(e,t){if("string"!=typeof t&&t.length)return t.forEach(function(t){a.addClass(e,t)}),!0;var n=e.className,s=n.length,i=n.slice(s-t.length-1,s);a.hasClass(e,t)||n.slice(0,t.length+1)===t+" "||i===" "+t||(n+=" "+t),e.className=n.trim()},attachAttributes:function(e,t){if(!t)return null;for(var n in t)"data-"===n.slice(0,5)?e.setAttribute(n,t[n]):e[n]=t[n]},constructElement:function(e){var t=document.createElement(e.tagname||"div");return a.attachAttributes(t,e),t},debounce:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this,s=void 0,i=void 0,r=function(){return e.apply(n,s)};return function(){clearTimeout(i),s=arguments,i=setTimeout(r,t)}},extendClass:function(e){function t(t){for(var n in t)e[n]=t[n]}e=e.prototype;for(var n=arguments.length,s=Array(n>1?n-1:0),i=1;i/g,">").replace(/"/g,""")},getElWidth:function(e,t,n){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1500,i=window.getComputedStyle(e);if(0===e.offsetWidth&&this.checkWidthAgain!==!0){if(!t||!n)throw"Flounder getElWidth error: no callback given.";setTimeout(t.bind(n),s),this.checkWidthAgain=!0}else this.checkWidthAgain=!1;return e.offsetWidth+parseInt(i["margin-left"])+parseInt(i["margin-right"])},hasClass:function(e,t){var n=e.className,s=new RegExp("(^"+t+" )|( "+t+"$)|( "+t+" )|(^"+t+"$)");return!!n.match(s)},http:!1,iosVersion:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window;return!!/iPad|iPhone|iPod/.test(e.navigator.platform)&&(e.indexedDB?"8+":e.SpeechSynthesisUtterance?"7":e.webkitAudioContext?"6":"5-")},removeAllChildren:function(e){Array.prototype.slice.call(e.children,0).forEach(function(t){e.removeChild(t)})},removeClass:function(e,t){if("string"!=typeof t&&t.length)return t.forEach(function(t){a.removeClass(e,t)}),!0;var n=e.className,s=n.length,i=t.length;n===t?n="":n.slice(0,i+1)===t+" "?n=n.slice(i+1,s):n.slice(s-i-1,s)===" "+t?n=n.slice(0,s-i-1):n.indexOf(" "+t+" ")!==-1&&(n=n.replace(" "+t+" "," ")),e.className=n.trim()},scrollTo:function(e,t){if(e){var n=t||e.offsetParent;if(n.scrollHeight>n.offsetHeight){var s=e.offsetTop,i=e.offsetHeight,r=n.offsetHeight,a=n.scrollTop,o=a+n.offsetHeight-i;so&&(n.scrollTop=s-(r-i))}}return!1},setPlatform:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window,t=e.navigator.platform,n=t.indexOf("Mac")!==-1,s=a.iosVersion(e),i=n?"metaKey":"ctrlKey";return{isOsx:n,isIos:s,multiSelect:i}},toggleClass:function(e,t){a.hasClass(e,t)?a.removeClass(e,t):a.addClass(e,t)}};(0,r["default"])(a),n["default"]=a},{"microbejs/src/modules/http":3}],21:[function(e,t,n){"use strict";t.exports="1.3.1"},{}],22:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}var i=e("../core/flounder"),r=s(i);!function(e){e.core.flounder=function(e){var t=r["default"].prototype.destroy;return this.each(function(n){var s=new r["default"](n,e);n.data=n.data||{},n.data.flounder=n.data.flounder||{},n.data.flounder.flounder=s,s.destroy=function(){n.data.flounder.flounder=!1,t.call(s)}}),this}}(µ)},{"../core/flounder":17}]},{},[22]); \ No newline at end of file diff --git a/dist/flounder.min.js b/dist/flounder.min.js index 922d9ea..222dec3 100644 --- a/dist/flounder.min.js +++ b/dist/flounder.min.js @@ -1,2 +1,2 @@ -/*! Flounder v1.3.0 | (c) 2015-2017 Sociomantic Labs | https://github.com/sociomantic-tsunami/flounder/license */!function e(t,n,s){function i(a,o){if(!n[a]){if(!t[a]){var l="function"==typeof require&&require;if(!o&&l)return l(a,!0);if(r)return r(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var c=n[a]={exports:{}};t[a][0].call(c.exports,function(e){var n=t[a][1][e];return i(n?n:e)},c,c.exports,e,t,n,s)}return n[a].exports}for(var r="function"==typeof require&&require,a=0;ac){for(var t=0,n=o.length-u;t "+t+") {","args = new Array(arguments.length + 1);","for (var i = 0; i < arguments.length; i++) {","args[i] = arguments[i];","}","}","return new Promise(function (rs, rj) {","var cb = "+o+";","var res;","switch (argLength) {",n.concat(["extra"]).map(function(e,t){return"case "+t+":res = fn.call("+["self"].concat(n.slice(0,t)).concat("cb").join(",")+");break;"}).join(""),"default:","args[argLength] = cb;","res = fn.apply(self, args);","}","if (res &&",'(typeof res === "object" || typeof res === "function") &&','typeof res.then === "function"',") {rs(res);}","});","};"].join("");return Function(["Promise","fn"],i)(r,e)}var r=e("./core.js"),a=e("asap");t.exports=r,r.denodeify=function(e,t){return"number"==typeof t&&t!==1/0?s(e,t):i(e)};var o="function (err, res) {if (err) { rj(err); } else { rs(res); }}";r.nodeify=function(e){return function(){var t=Array.prototype.slice.call(arguments),n="function"==typeof t[t.length-1]?t.pop():null,s=this;try{return e.apply(this,arguments).nodeify(n,s)}catch(i){if(null===n||"undefined"==typeof n)return new r(function(e,t){t(i)});a(function(){n.call(s,i)})}}},r.prototype.nodeify=function(e,t){return"function"!=typeof e?this:void this.then(function(n){a(function(){e.call(t,null,n)})},function(n){a(function(){e.call(t,n)})})}},{"./core.js":5,asap:1}],11:[function(e,t,n){"use strict";var s=e("./core.js");t.exports=s,s.enableSynchronous=function(){s.prototype.isPending=function(){return 0==this.getState()},s.prototype.isFulfilled=function(){return 1==this.getState()},s.prototype.isRejected=function(){return 2==this.getState()},s.prototype.getValue=function(){if(3===this._65)return this._55.getValue();if(!this.isFulfilled())throw new Error("Cannot get a value of an unfulfilled promise.");return this._55},s.prototype.getReason=function(){if(3===this._65)return this._55.getReason();if(!this.isRejected())throw new Error("Cannot get a rejection reason of a non-rejected promise.");return this._55},s.prototype.getState=function(){return 3===this._65?this._55.getState():this._65===-1||this._65===-2?0:this._65}},s.disableSynchronous=function(){s.prototype.isPending=void 0,s.prototype.isFulfilled=void 0,s.prototype.isRejected=void 0,s.prototype.getValue=void 0,s.prototype.getReason=void 0,s.prototype.getState=void 0}},{"./core.js":5}],12:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){var n=[],s=!0,i=!1,r=void 0;try{for(var a,o=e[Symbol.iterator]();!(s=(a=o.next()).done)&&(n.push(a.value),!t||n.length!==t);s=!0);}catch(l){i=!0,r=l}finally{try{!s&&o["return"]&&o["return"]()}finally{if(i)throw r}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),r=e("./utils"),a=s(r),o=e("./defaults"),l={buildFromUrl:function(e,t){var n=this;return this.loadDataFromUrl(e,function(e){n.data=e,t&&t(n.data),n.rebuild(n.data)}),[]},clickByIndex:function(e,t){return this.setByIndex(e,t,!1)},clickByText:function(e,t){return this.setByText(e,t,!1)},clickByValue:function(e,t){return this.setByValue(e,t,!1)},destroy:function(){this.componentWillUnmount();var e=this.refs,t=this.classes,n=this.originalTarget,s=n.tagName;if("INPUT"===s||"SELECT"===s){var i=n.nextElementSibling;if("SELECT"===s){var r=n[0];r&&a["default"].hasClass(r,t.PLACEHOLDER)&&n.removeChild(r)}else i=e.flounder.parentNode;try{var o=this.classes;i.parentNode.removeChild(i),n.tabIndex=0,a["default"].removeClass(n,o.HIDDEN)}catch(l){throw" : this flounder may have already been removed"}}else try{var u=e.wrapper,c=u.parentNode;c.removeChild(u)}catch(l){throw" : this flounder may have already been removed"}e.flounder.flounder=n.flounder=this.target.flounder=null},deselectAll:function(e){if(this.removeSelectedClass(),this.removeSelectedValue(),this.multiple){var t=this.refs.multiTagWrapper;if(t){for(var n=t.children,s=0;s2&&void 0!==arguments[2])||arguments[2],s=this.refs;if("string"!=typeof e&&e.length){var h=this.setByIndex.bind(this);return e.map(function(e){return h(e,t,n)})}var i=this.data,r=i.length;e<0&&(r=i.length,e=r+e);var a=s.data[e];return a?(this.forceMultiple=t&&this.multiple,this.programmaticClick=n,a.click(),a):null},setByText:function f(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof e&&e.length){var f=this.setByText.bind(this);return e.map(function(e){return f(e,t,n)})}var s=[];return e=""+e,this.refs.data.forEach(function(t,n){var i=t.innerHTML;i===e&&s.push(n)}),this.setByIndex(s,t,n)},setByValue:function p(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof e&&e.length){var p=this.setByValue.bind(this);return e.map(function(e){return p(e,t,n)})}var s=this.refs.selectOptions.map(function(t,n){return""+t.value==""+e?n:null}).filter(function(e){return 0===e||!!e});return this.setByIndex(s,t,n)}};n["default"]=l},{"./defaults":15,"./utils":20}],13:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r=e("./defaults"),a=e("./utils"),o=s(a),l={addOptionDescription:function(e,t){var n=document.createElement("div");n.innerHTML=t,n.className=this.classes.DESCRIPTION,e.appendChild(n)},addSearch:function(e){if(this.search){var t=this.classes,n=o["default"].constructElement({tagname:"input",type:"text",className:t.SEARCH,tabIndex:-1});return e.appendChild(n),n}return!1},bindThis:function(){var e=this;["addHoverClass","catchBodyClick","checkClickTarget","checkFlounderKeypress","checkMultiTagKeydown","clearPlaceholder","clickSet","divertTarget","displayMultipleTags","firstTouchController","fuzzySearch","removeHoverClass","removeMultiTag","setKeypress","setSelectValue","toggleList","toggleListSearchClick"].forEach(function(t){e[t]=e[t].bind(e),e[t].isBound=!0})},buildArrow:function(e,t){if(e.disableArrow)return!1;var n=this.classes,s=t({className:n.ARROW}),i=t({className:n.ARROW_INNER});return s.appendChild(i),s},buildData:function(e,t,n,s){function r(t,n){t.index=n;var s=n===e.index?" "+v:"",i={className:T.OPTION+s,"data-index":n};for(var r in t)"text"!==r&&"description"!==r&&(i[r]=t[r]);var a=p(i);return a.innerHTML=C?t.text:g(t.text),t.description&&l.addOptionDescription(a,t.description,T.DESCRIPTION),a.className+=t.extraClass?" "+t.extraClass:"",a.setAttribute("role","option"),a}function a(t,n){var i=void 0;if(E){var r=E.children[n];i=r,r.setAttribute("value",r.value),r.disabled===!0&&d[n]&&m(d[n],T.DISABLED),m(r,T.OPTION_TAG)}else{var a=t.extraClass||"",o=T.OPTION_TAG+" "+a;i=p({tagname:"option",className:o.trim(),value:t.value});var l=g(t.text);i.innerHTML=l;var u=t.disabled;u&&i.setAttribute("disabled",u),s.appendChild(i)}return n===e.index&&(i.selected=!0),i.getAttribute("disabled")&&m(d[n],T.DISABLED),i}var l=this,u=0,c=0,d=[],h=[],f=[],p=o["default"].constructElement,v=this.selectedClass,g=o["default"].escapeHTML,m=o["default"].addClass,y=this.refs,E=y.select,C=this.allowHTML,T=this.classes;return t.forEach(function(e,s){if("object"!==("undefined"==typeof e?"undefined":i(e))&&(e=t[s]={text:e,value:e}),e.header){var l=p({tagname:"div",className:T.SECTION}),v=p({tagname:"div",className:T.HEADER});v.textContent=e.header,l.appendChild(v),n.appendChild(l);var g=e.data;g.forEach(function(e,t){"object"!==("undefined"==typeof e?"undefined":i(e))&&(e=g[t]={text:e,value:e}),d[u]=r(e,u),l.appendChild(d[u]),h[u]=a(e,u),u++}),0==g.length&&o["default"].addClass(l,T.HIDDEN),f[c]=l,c++}else d[u]=r(e,u),n.appendChild(d[u]),h[u]=a(e,u),u++}),[d,h,f]},buildDom:function(){var e=this.props,t=this.classes;this.refs={};var n=o["default"].constructElement,s=o["default"].constructElement({className:t.MAIN_WRAPPER}),i=t.MAIN,a=this.multipleTags?i+" "+t.MULTIPLE_TAG_FLOUNDER:i,l=n({className:a});l.setAttribute("aria-hidden",!0),l.tabIndex=0,s.appendChild(l);var u=this.initSelectBox(s);u.tabIndex=-1;var c=this.data;this.defaultObj=(0,r.setDefaultOption)(this,this.props,c);var d=this.defaultObj,h=t.SELECTED_DISPLAYED;d.value&&d.extraClass&&(h+=" "+d.extraClass);var f=n({className:h,"data-value":d.value,"data-index":d.index}),p=this.multipleTags?n({className:t.MULTI_TAG_LIST}):null,v=n({className:t.OPTIONS_WRAPPER+" "+t.HIDDEN}),g=n({className:t.LIST});g.setAttribute("role","listbox"),v.appendChild(g),this.multiple===!0&&(u.setAttribute("multiple",""),g.setAttribute("aria-multiselectable","true"));var m=this.buildArrow(e,n);[f,p,v,m].forEach(function(e){e&&l.appendChild(e)});var y=this.addSearch(this.multipleTags?p:l),E=this.buildData(d,c,g,u);c=E[0];var C=E[1],T=E[2];if(this.target.appendChild(s),this.refs={wrapper:s,flounder:l,selected:f,arrow:m,optionsListWrapper:v,search:y,multiTagWrapper:p,optionsList:g,select:u,data:c,sections:T,selectOptions:C},this.multipleTags){var L=this.getSelected();0===L.length?f.innerHTML=d.text:this.displayMultipleTags(L,p)}else f.innerHTML=d.text},buildMultiTag:function(e){var t=this.classes,n=e.innerHTML,s=document.createElement("SPAN");s.className=t.MULTIPLE_SELECT_TAG,s.setAttribute("aria-label","Close"),s.setAttribute("tabindex",0);var i=document.createElement("A");return i.className=t.MULTIPLE_TAG_CLOSE,i.setAttribute("data-index",e.index),s.appendChild(i),s.innerHTML+=n,s},initSelectBox:function(e){var t=this.target,n=this.refs,s=n.select,i=this.classes;if("SELECT"===t.tagName){if(o["default"].addClass(t,i.SELECT_TAG),o["default"].addClass(t,i.HIDDEN),s=t,this.props.keepChangesOnDestroy||this.popOutSelectElements(s),t.length>0&&!this.selectDataOverride){this.refs.select=s;var r=[],a=[],l=!0,u=!1,c=void 0;try{for(var d,h=t.children[Symbol.iterator]();!(l=(d=h.next()).done);l=!0){var f=d.value;a.push(f),r.push({text:f.innerHTML,value:f.value})}}catch(p){u=!0,c=p}finally{try{!l&&h["return"]&&h["return"]()}finally{if(u)throw c}}n.selectOptions=a,this.data=r}else this.selectDataOverride&&o["default"].removeAllChildren(t);this.target=t.parentNode,o["default"].addClass(t,i.HIDDEN)}else s=o["default"].constructElement({tagname:"SELECT",className:i.SELECT_TAG+" "+i.HIDDEN}),e.appendChild(s);return s},popInSelectElements:function(e){o["default"].removeAllChildren(e);var t=!0,n=!1,s=void 0;try{for(var i,r=this.originalChildren[Symbol.iterator]();!(t=(i=r.next()).done);t=!0){var a=i.value;e.appendChild(a)}}catch(l){n=!0,s=l}finally{try{!t&&r["return"]&&r["return"]()}finally{if(n)throw s}}},popOutSelectElements:function(e){var t=[];this.originalChildren=e.children;for(var n=this.originalChildren,s=0;s=0?e[s]:null;return i?(i.index=s,i):null}function i(){var i=e.sortData(o);!a.multipleTags&&!a.multiple||a.defaultIndex||a.defaultValue||(a.placeholder=a.placeholder||l.placeholder),a.defaultEmpty&&(a.placeholder="");var r=a.placeholder;if(r||""===r||0===i.length)return n(e,i);var c=void 0;if(u){var d=e.refs.selected.getAttribute("data-value");if(c=s(i,d))return c}return c=a.defaultIndex?t(i):null,c=!c&&a.defaultValue?s(i):c,c=c?c:t(i,0)}var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments[2],u=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return o=o||a.data||[],i()}};n.setDefaultOption=u.setDefaultOption;n["default"]=u},{"./classes":14,"./utils":20}],16:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var i=e("./utils"),r=s(i),a=e("./keycodes"),o=s(a),l={addFirstTouchListeners:function(){var e=this.refs;e.selected.addEventListener("click",this.firstTouchController),e.select.addEventListener("focus",this.firstTouchController),this.props.openOnHover&&e.wrapper.addEventListener("mouseenter",this.firstTouchController)},addHoverClass:function(e){r["default"].addClass(e.target,this.classes.HOVER)},addListeners:function(e){var t=this.isIos,n=t?"blur":"change";if(e.select.addEventListener(n,this.divertTarget),e.flounder.addEventListener("keydown",this.checkFlounderKeypress),this.props.openOnHover){var s=e.wrapper;s.addEventListener("mouseenter",this.toggleList),s.addEventListener("mouseleave",this.toggleList)}else e.selected.addEventListener("click",this.toggleList);this.addFirstTouchListeners(),this.addOptionsListeners(),this.search&&this.addSearchListeners()},addMultipleTags:function(e,t){var n=this;e.forEach(function(e){if(""!==e.value){var s=n.buildMultiTag(e);t.insertBefore(s,t.lastChild)}else e.selected=!1});for(var s=t.children,i=0;i1)for(var o=0;o=48&&t<=57||t>=65&&t<=90)&&n.search&&"INPUT"===e.target.tagName&&(n.selected.innerHTML="")},checkMultiTagKeydown:function(e){var t=this,n=e.keyCode,s=e.target,i=[o["default"].BACKSPACE,o["default"].LEFT,o["default"].RIGHT];i.indexOf(n)!==-1?(e.preventDefault(),e.stopPropagation(),n===o["default"].BACKSPACE?this.checkMultiTagKeydownRemove(s):this.checkMultiTagKeydownNavigate(n,s)):e.key.length<2&&setTimeout(function(){return t.refs.search.focus()},0)},checkMultiTagKeydownNavigate:function(e,t){if(e===o["default"].LEFT){var n=t.previousSibling;n&&n.focus()}else if(e===o["default"].RIGHT){var s=t.nextSibling;s&&setTimeout(function(){return s.focus()},0)}},checkMultiTagKeydownRemove:function(e){var t=e.previousSibling,n=e.nextSibling;e.firstChild.click(),t?setTimeout(function(){return t.focus()},0):n&&n.focus()},clearPlaceholder:function(){this.refs.selected.innerHTML=""},clickSet:function(e){e.preventDefault(),e.stopPropagation(),this.setSelectValue({},e),this.programmaticClick||this.toggleList(e,"close"),this.programmaticClick=!1},displayMultipleTags:function(e,t){for(var n=t.children,s=0;s0?this.addMultipleTags(e,t):this.addPlaceholder()},displaySelected:function(e,t){var n=[],s=-1,i=this.getSelected(),r=i.length,a=this.multipleTags;if(e.className=this.classes.SELECTED_DISPLAYED,a||1!==r)if(a||0!==r)a?(e.innerHTML="",this.displayMultipleTags(i,t.multiTagWrapper)):e.innerHTML=this.multipleMessage,s=i.map(function(e){return e.index}),n=i.map(function(e){return e.value});else{var o=this.defaultObj;s=o.index||-1,e.innerHTML=o.text,n=o.value}else{s=i[0].index,e.innerHTML=t.data[s].innerHTML, -n=i[0].value;var l=t.data[s].extraClass;e.className+=l?" "+l:""}e.setAttribute("data-value",n),e.setAttribute("data-index",s)},divertTarget:function(e){if(this.isIos){var t=this.refs.select,n=this.classes,s=t.querySelector("."+n.PLUG);s&&t.removeChild(s)}var i=e.target.selectedIndex,r={type:e.type,target:this.data[i]};this.multipleTags&&(e.preventDefault(),e.stopPropagation()),this.setSelectValue(r),this.multiple||this.toggleList(e,"close")},firstTouchController:function(e){var t=this.refs;if(this.onFirstTouch)try{this.onFirstTouch(e)}catch(e){console.warn('something may be wrong in "onFirstTouch"',e)}t.selected.removeEventListener("click",this.firstTouchController),t.select.removeEventListener("focus",this.firstTouchController),this.props.openOnHover&&t.wrapper.removeEventListener("mouseenter",this.firstTouchController)},hideEmptySection:function(e){for(var t=this.selectedClass,n=this.refs.sections,s=0;sa?o=0:o<0&&(o=a);var l=this.classes,u=r["default"].hasClass,c=i[o];s.selectedIndex=o,(u(c,l.HIDDEN)||u(c,l.SELECTED_HIDDEN)||u(c,l.SEARCH_HIDDEN)||u(c,l.DISABLED))&&this.setKeypress(e)},setSelectValue:function(e,t){var n=this.refs,s=void 0;if(t?this.setSelectValueClick(t):(s=e.keyCode,this.setSelectValueButton(e)),this.displaySelected(n.selected,n),!this.programmaticClick){var i=[9,16,17,18,20,91];if(t||"blur"===e.type||!s&&"change"===e.type||s&&i.indexOf(s)===-1)if(this.toggleList.justOpened&&!t)this.toggleList.justOpened=!1;else if(this.onChange)try{this.onChange(t,this.getSelectedValues())}catch(t){console.warn("something may be wrong in onChange",t)}this.programmaticClick=!1}},setSelectValueButton:function(){var e=this.refs,t=e.data,n=this.selectedClass,s=void 0;if(this.multipleTags)return!1;this.removeSelectedClass(t);var i=this.getSelected(),a=i[0];a&&(s=t[a.index],r["default"].addClass(s,n),r["default"].scrollTo(s,e.optionsListWrapper))},setSelectValueClick:function(e){var t=this.multiple,n=this.refs,s=this.selectedClass,i=e.target,a=i.getAttribute("data-index"),o=n.selectOptions[a];t&&(!t||this.multipleTags||e[this.multiSelect])||this.forceMultiple?(r["default"].toggleClass(i,s),o.selected=!o.selected):(this.deselectAll(),r["default"].addClass(i,s),o.selected=o.selected!==!0),this.forceMultiple=!1,this.hideEmptySection(i.parentNode);var l=n.selectOptions[0];""===l.value&&this.getSelected().length>1&&(r["default"].removeClass(n.data[0],s),n.selectOptions[0].selected=!1)},toggleClosed:function(e,t,n,s){var i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],a=this.classes;r["default"].addClass(n.optionsListWrapper,a.HIDDEN),r["default"].removeClass(s,a.OPEN);var o=document.querySelector("html");if(o.removeEventListener("click",this.catchBodyClick),o.removeEventListener("touchend",this.catchBodyClick),this.search?this.fuzzySearchReset():this.removeSelectKeyListener(),i||setTimeout(function(){return n.flounder.focus()},0),this.onClose&&this.ready)try{this.onClose(e,this.getSelectedValues())}catch(e){console.warn('something may be wrong in "onClose"',e)}},toggleList:function(e,t){var n=this.classes,s=this.refs,i=s.optionsListWrapper,a=s.wrapper,o=r["default"].hasClass(i,n.HIDDEN),l=e.type;"mouseleave"!==l&&"close"!==t&&o?("keydown"===l&&(this.toggleList.justOpened=!0),this.toggleOpen(e,i,s,a)):(this.toggleList.justOpened=!1,this.toggleClosed(e,i,s,a))},toggleListSearchClick:function(e){var t=this.classes;r["default"].hasClass(this.refs.wrapper,t.OPEN)||this.toggleList(e,"open")},toggleOpen:function(e,t,n){if(!this.isIos||this.search||this.multipleTags===!0){var s=this.classes;r["default"].removeClass(n.optionsListWrapper,s.HIDDEN),r["default"].addClass(n.wrapper,s.OPEN);var i=document.querySelector("html");i.addEventListener("click",this.catchBodyClick),i.addEventListener("touchend",this.catchBodyClick)}if(!this.multipleTags){var a=n.select.selectedIndex,o=n.data[a];r["default"].scrollTo(o,n.optionsListWrapper)}this.search?setTimeout(function(){return n.search.focus()},0):(this.addSelectKeyListener(),setTimeout(function(){return n.select.focus()},0));var l=n.data.length;if(this.props.placeholder&&l--,n.multiTagWrapper){var u=n.multiTagWrapper.children.length-1;u===l&&(this.removeNoResultsMessage(),this.addNoMoreOptionsMessage())}if(this.onOpen&&this.ready)try{this.onOpen(e,this.getSelectedValues())}catch(e){console.warn('something may be wrong in "onOpen"',e)}}};n["default"]=l},{"./keycodes":18,"./utils":20}],17:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}function i(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t1)console.warn("Flounder - More than one element found.\n Dropping all but the first.");else if(0===t.length)throw"Flounder - No target element found.";t=t[0]}return t.flounder&&t.flounder.destroy(),this.init(t,n)}console.warn("Flounder - No target element found.")}return o(e,[{key:"componentWillUnmount",value:function(){if(this.onComponentWillUnmount)try{this.onComponentWillUnmount()}catch(e){console.warn('something may be wrong in "onComponentWillUnmount"',e)}this.removeListeners(),this.originalChildren&&this.popInSelectElements(this.refs.select)}}]),o(e,[{key:"filterSearchResults",value:function(e){var t=e.target.value.trim();this.fuzzySearch.previousValue=t;var n=this.search.isThereAnythingRelatedTo(t)||[];if(""!==t){var s=this.refs.data,i=this.refs.sections,r=this.classes;s.forEach(function(e){c["default"].addClass(e,r.SEARCH_HIDDEN)}),i.forEach(function(e){c["default"].addClass(e,r.SEARCH_HIDDEN)}),n.forEach(function(e){c["default"].removeClass(s[e.i],r.SEARCH_HIDDEN),"number"==typeof e.d.s&&c["default"].removeClass(i[e.d.s],r.SEARCH_HIDDEN)}),this.refs.noMoreOptionsEl||(0===n.length?this.addNoResultsMessage():this.removeNoResultsMessage())}else this.fuzzySearchReset()}},{key:"fuzzySearch",value:function(e){if(this.fuzzySearch.previousValue=this.fuzzySearch.previousValue||"",this.onInputChange)try{this.onInputChange(e)}catch(e){console.warn('something may be wrong in "onInputChange"',e)}if(this.toggleList.justOpened)this.toggleList.justOpened=!1;else{e.preventDefault();var t=e.keyCode;if(t!==L["default"].UP&&t!==L["default"].DOWN&&t!==L["default"].ENTER&&t!==L["default"].ESCAPE)if(this.multipleTags&&t===L["default"].BACKSPACE&&""===this.fuzzySearch.previousValue){var n=this.refs.search.previousSibling;n&&setTimeout(function(){return n.focus()},0)}else this.filterSearchResults(e);else t!==L["default"].ESCAPE&&t!==L["default"].ENTER||(this.fuzzySearchReset(),this.toggleList(e,"close"),this.addPlaceholder())}}},{key:"fuzzySearchReset",value:function(){var e=this.refs,t=this.classes;e.sections.forEach(function(e){c["default"].removeClass(e,t.SEARCH_HIDDEN)}),e.data.forEach(function(e){c["default"].removeClass(e,t.SEARCH_HIDDEN)}),e.search.value="",this.removeNoResultsMessage()}},{key:"init",value:function(e,t){if(this.props=t,this.bindThis(),this.initializeOptions(),this.setTarget(e),this.search&&(this.search=new y["default"](this)),this.onInit)try{this.onInit()}catch(n){console.warn('something may be wrong in "onInit"',n)}this.buildDom();var s=c["default"].setPlatform(),i=s.isOsx,r=s.isIos,a=s.multiSelect;if(this.isOsx=i,this.isIos=r,this.multiSelect=a,this.onRender(),this.onComponentDidMount)try{this.onComponentDidMount()}catch(n){console.warn("something may be wrong in onComponentDidMount",n)}return this.ready=!0,this.originalTarget.flounder=this.target.flounder=this,this.refs.flounder.flounder=this}},{key:"initializeOptions",value:function(){var e=this.props=this.props||{};for(var t in l.defaultOptions)if("onChange"===t&&e.onSelect)this.onChange=e.onSelect,console.warn("Please use onChange. onSelect has been\n depricated and will be removed in 2.0.0"),this.onSelect=function(){console.warn("Please use onChange. onSelect has been\n depricated and will be removed in 2.0.0"),this.onChange.apply(this,arguments)};else if("classes"===t){this.classes={};var n=l.defaultOptions[t],s="object"===a(e[t])?e[t]:{};for(var r in n)this.classes[r]=s[r]?s[r]:n[r]}else"data"===t?this.data=e.data&&e.data.length?[].concat(i(e.data)):[].concat(i(l.defaultOptions.data)):this[t]=void 0!==e[t]?e[t]:l.defaultOptions[t];this.selectedClass=this.classes.SELECTED,e.defaultEmpty&&(this.placeholder=""),this.multipleTags&&(this.search=!0,this.multiple=!0,this.selectedClass+=" "+this.classes.SELECTED_HIDDEN)}},{key:"onRender",value:function(){var e=this.props,t=this.refs;if(this.isIos&&!this.multiple){var n=t.select,s=this.classes;c["default"].removeClass(n,s.HIDDEN),c["default"].addClass(n,s.HIDDEN_IOS)}this.addListeners(t,e)}},{key:"sortData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=this,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,r=0;return e.forEach(function(e){e.header?(t=n.sortData(e.data,t,s,r),r++):("object"!==("undefined"==typeof e?"undefined":a(e))?e={text:e,value:e,index:s}:e.index=s,void 0!==i&&(e.s=i),t.push(e),s++)}),t}}]),e}();S.find=function(e,t){return"string"==typeof e?e=document.querySelectorAll(e):1===e.nodeType&&(e=[e]),Array.prototype.slice.call(e,0).map(function(e){return new S(e,t)})},Object.defineProperty(S,"version",{get:function(){return C["default"]}}),Object.defineProperty(S.prototype,"version",{get:function(){return C["default"]}}),c["default"].extendClass(S,h["default"],p["default"],g["default"]),n["default"]=S},{"./api":12,"./build":13,"./defaults":15,"./events":16,"./keycodes":18,"./search":19,"./utils":20,"./version":21}],18:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var s={BACKSPACE:8,DOWN:40,ENTER:13,ESCAPE:27,LEFT:37,RIGHT:39,SPACE:32,TAB:9,UP:38,NON_CHARACTER_KEYS:[16,17,18,20,91,93]};n["default"]=s},{}],19:[function(e,t,n){"use strict";function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;nt?1:e=r.minimumScore}},{key:"isThereAnythingRelatedTo",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=void 0;if(e=e.length?e:""+e,!(e.length>=r.minimumValueLength))return!1;this.query=e.toLowerCase().split(" ");var n=this.flounder.data;return n=this.flounder.sortData(n),t=this.ratedRes=n.map(this.getResultWeights),t=t.filter(this.isItemAboveMinimum),t.sort(this.compareScoreCards),this.ratedRes=t}},{key:"startsWith",value:function(e,t,n){var s=t.length,i=e.length;if(i<=s){var r=t.toLowerCase().slice(0,i);if(r===e)return n}return 0}},{key:"scoreThis",value:function(e,t,n){var s=this,i=0;return e&&this.query.forEach(function(r){r=s.escapeRegExp(r);var a=0;"string"==typeof e?(r=new RegExp(r,"g"),a=(e.match(r)||[]).length):e[0]?e.forEach(function(e){a+=e.indexOf(r)!==-1?1:0}):a=e[r]||1e-6,a>0?i=t*a*10:n!==!0&&(i=-t)}),Math.floor(i)}}]),e}();n["default"]=a},{}],20:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var i=e("microbejs/src/modules/http"),r=s(i),a={addClass:function(e,t){if("string"!=typeof t&&t.length)return t.forEach(function(t){a.addClass(e,t)}),!0;var n=e.className,s=n.length,i=n.slice(s-t.length-1,s);a.hasClass(e,t)||n.slice(0,t.length+1)===t+" "||i===" "+t||(n+=" "+t),e.className=n.trim()},attachAttributes:function(e,t){if(!t)return null;for(var n in t)"data-"===n.slice(0,5)?e.setAttribute(n,t[n]):e[n]=t[n]},constructElement:function(e){var t=document.createElement(e.tagname||"div");return a.attachAttributes(t,e),t},debounce:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this,s=void 0,i=void 0,r=function(){return e.apply(n,s)};return function(){clearTimeout(i),s=arguments,i=setTimeout(r,t)}},extendClass:function(e){function t(t){for(var n in t)e[n]=t[n]}e=e.prototype;for(var n=arguments.length,s=Array(n>1?n-1:0),i=1;i/g,">").replace(/"/g,""")},getElWidth:function(e,t,n){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1500,i=window.getComputedStyle(e);if(0===e.offsetWidth&&this.checkWidthAgain!==!0){if(!t||!n)throw"Flounder getElWidth error: no callback given.";setTimeout(t.bind(n),s),this.checkWidthAgain=!0}else this.checkWidthAgain=!1;return e.offsetWidth+parseInt(i["margin-left"])+parseInt(i["margin-right"])},hasClass:function(e,t){var n=e.className,s=new RegExp("(^"+t+" )|( "+t+"$)|( "+t+" )|(^"+t+"$)");return!!n.match(s)},http:!1,iosVersion:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window;return!!/iPad|iPhone|iPod/.test(e.navigator.platform)&&(e.indexedDB?"8+":e.SpeechSynthesisUtterance?"7":e.webkitAudioContext?"6":"5-")},removeAllChildren:function(e){Array.prototype.slice.call(e.children,0).forEach(function(t){e.removeChild(t)})},removeClass:function(e,t){if("string"!=typeof t&&t.length)return t.forEach(function(t){a.removeClass(e,t)}),!0;var n=e.className,s=n.length,i=t.length;n===t?n="":n.slice(0,i+1)===t+" "?n=n.slice(i+1,s):n.slice(s-i-1,s)===" "+t?n=n.slice(0,s-i-1):n.indexOf(" "+t+" ")!==-1&&(n=n.replace(" "+t+" "," ")),e.className=n.trim()},scrollTo:function(e,t){if(e){var n=t||e.offsetParent;if(n.scrollHeight>n.offsetHeight){var s=e.offsetTop,i=e.offsetHeight,r=n.offsetHeight,a=n.scrollTop,o=a+n.offsetHeight-i;so&&(n.scrollTop=s-(r-i))}}return!1},setPlatform:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window,t=e.navigator.platform,n=t.indexOf("Mac")!==-1,s=a.iosVersion(e),i=n?"metaKey":"ctrlKey";return{isOsx:n,isIos:s,multiSelect:i}},toggleClass:function(e,t){a.hasClass(e,t)?a.removeClass(e,t):a.addClass(e,t)}};(0,r["default"])(a),n["default"]=a},{"microbejs/src/modules/http":3}],21:[function(e,t,n){"use strict";t.exports="1.3.0"},{}]},{},[17]); \ No newline at end of file +/*! Flounder v1.3.1 | (c) 2015-2017 Sociomantic Labs | https://github.com/sociomantic-tsunami/flounder/license */!function e(t,n,s){function i(a,o){if(!n[a]){if(!t[a]){var l="function"==typeof require&&require;if(!o&&l)return l(a,!0);if(r)return r(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var c=n[a]={exports:{}};t[a][0].call(c.exports,function(e){var n=t[a][1][e];return i(n?n:e)},c,c.exports,e,t,n,s)}return n[a].exports}for(var r="function"==typeof require&&require,a=0;ac){for(var t=0,n=o.length-u;t "+t+") {","args = new Array(arguments.length + 1);","for (var i = 0; i < arguments.length; i++) {","args[i] = arguments[i];","}","}","return new Promise(function (rs, rj) {","var cb = "+o+";","var res;","switch (argLength) {",n.concat(["extra"]).map(function(e,t){return"case "+t+":res = fn.call("+["self"].concat(n.slice(0,t)).concat("cb").join(",")+");break;"}).join(""),"default:","args[argLength] = cb;","res = fn.apply(self, args);","}","if (res &&",'(typeof res === "object" || typeof res === "function") &&','typeof res.then === "function"',") {rs(res);}","});","};"].join("");return Function(["Promise","fn"],i)(r,e)}var r=e("./core.js"),a=e("asap");t.exports=r,r.denodeify=function(e,t){return"number"==typeof t&&t!==1/0?s(e,t):i(e)};var o="function (err, res) {if (err) { rj(err); } else { rs(res); }}";r.nodeify=function(e){return function(){var t=Array.prototype.slice.call(arguments),n="function"==typeof t[t.length-1]?t.pop():null,s=this;try{return e.apply(this,arguments).nodeify(n,s)}catch(i){if(null===n||"undefined"==typeof n)return new r(function(e,t){t(i)});a(function(){n.call(s,i)})}}},r.prototype.nodeify=function(e,t){return"function"!=typeof e?this:void this.then(function(n){a(function(){e.call(t,null,n)})},function(n){a(function(){e.call(t,n)})})}},{"./core.js":5,asap:1}],11:[function(e,t,n){"use strict";var s=e("./core.js");t.exports=s,s.enableSynchronous=function(){s.prototype.isPending=function(){return 0==this.getState()},s.prototype.isFulfilled=function(){return 1==this.getState()},s.prototype.isRejected=function(){return 2==this.getState()},s.prototype.getValue=function(){if(3===this._65)return this._55.getValue();if(!this.isFulfilled())throw new Error("Cannot get a value of an unfulfilled promise.");return this._55},s.prototype.getReason=function(){if(3===this._65)return this._55.getReason();if(!this.isRejected())throw new Error("Cannot get a rejection reason of a non-rejected promise.");return this._55},s.prototype.getState=function(){return 3===this._65?this._55.getState():this._65===-1||this._65===-2?0:this._65}},s.disableSynchronous=function(){s.prototype.isPending=void 0,s.prototype.isFulfilled=void 0,s.prototype.isRejected=void 0,s.prototype.getValue=void 0,s.prototype.getReason=void 0,s.prototype.getState=void 0}},{"./core.js":5}],12:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){var n=[],s=!0,i=!1,r=void 0;try{for(var a,o=e[Symbol.iterator]();!(s=(a=o.next()).done)&&(n.push(a.value),!t||n.length!==t);s=!0);}catch(l){i=!0,r=l}finally{try{!s&&o["return"]&&o["return"]()}finally{if(i)throw r}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),r=e("./utils"),a=s(r),o=e("./defaults"),l={buildFromUrl:function(e,t){var n=this;return this.loadDataFromUrl(e,function(e){n.data=e,t&&t(n.data),n.rebuild(n.data)}),[]},clickByIndex:function(e,t){return this.setByIndex(e,t,!1)},clickByText:function(e,t){return this.setByText(e,t,!1)},clickByValue:function(e,t){return this.setByValue(e,t,!1)},destroy:function(){this.componentWillUnmount();var e=this.refs,t=this.classes,n=this.originalTarget,s=n.tagName;if("INPUT"===s||"SELECT"===s){var i=n.nextElementSibling;if("SELECT"===s){var r=n[0];r&&a["default"].hasClass(r,t.PLACEHOLDER)&&n.removeChild(r)}else i=e.flounder.parentNode;try{var o=this.classes;i.parentNode.removeChild(i),n.tabIndex=0,a["default"].removeClass(n,o.HIDDEN)}catch(l){throw" : this flounder may have already been removed"}}else try{var u=e.wrapper,c=u.parentNode;c.removeChild(u)}catch(l){throw" : this flounder may have already been removed"}e.flounder.flounder=n.flounder=this.target.flounder=null},deselectAll:function(e){if(this.removeSelectedClass(),this.removeSelectedValue(),this.multiple){var t=this.refs.multiTagWrapper;if(t){for(var n=t.children,s=0;s2&&void 0!==arguments[2])||arguments[2],s=this.refs;if("string"!=typeof e&&e.length){var h=this.setByIndex.bind(this);return e.map(function(e){return h(e,t,n)})}var i=this.data,r=i.length;e<0&&(r=i.length,e=r+e);var a=s.data[e];return a?(this.forceMultiple=t&&this.multiple,this.programmaticClick=n,a.click(),a):null},setByText:function f(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof e&&e.length){var f=this.setByText.bind(this);return e.map(function(e){return f(e,t,n)})}var s=[];return e=""+e,this.refs.data.forEach(function(t,n){var i=t.innerHTML;i===e&&s.push(n)}),this.setByIndex(s,t,n)},setByValue:function p(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof e&&e.length){var p=this.setByValue.bind(this);return e.map(function(e){return p(e,t,n)})}var s=this.refs.selectOptions.map(function(t,n){return""+t.value==""+e?n:null}).filter(function(e){return 0===e||!!e});return this.setByIndex(s,t,n)}};n["default"]=l},{"./defaults":15,"./utils":20}],13:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r=e("./defaults"),a=e("./utils"),o=s(a),l={addOptionDescription:function(e,t){var n=document.createElement("div");n.innerHTML=t,n.className=this.classes.DESCRIPTION,e.appendChild(n)},addSearch:function(e){if(this.search){var t=this.classes,n=o["default"].constructElement({tagname:"input",type:"text",className:t.SEARCH,tabIndex:-1});return e.appendChild(n),n}return!1},bindThis:function(){var e=this;["addHoverClass","catchBodyClick","checkClickTarget","checkFlounderKeypress","checkMultiTagKeydown","clearPlaceholder","clickSet","divertTarget","displayMultipleTags","firstTouchController","fuzzySearch","removeHoverClass","removeMultiTag","setKeypress","setSelectValue","toggleList","toggleListSearchClick"].forEach(function(t){e[t]=e[t].bind(e),e[t].isBound=!0})},buildArrow:function(e,t){if(e.disableArrow)return!1;var n=this.classes,s=t({className:n.ARROW}),i=t({className:n.ARROW_INNER});return s.appendChild(i),s},buildData:function(e,t,n,s){function r(t,n){t.index=n;var s=n===e.index?" "+v:"",i={className:T.OPTION+s,"data-index":n};for(var r in t)"text"!==r&&"description"!==r&&(i[r]=t[r]);var a=p(i);return a.innerHTML=C?t.text:g(t.text),t.description&&l.addOptionDescription(a,t.description,T.DESCRIPTION),a.className+=t.extraClass?" "+t.extraClass:"",a.setAttribute("role","option"),a}function a(t,n){var i=void 0;if(E){var r=E.children[n];i=r,r.setAttribute("value",r.value),r.disabled===!0&&d[n]&&m(d[n],T.DISABLED),m(r,T.OPTION_TAG)}else{var a=t.extraClass||"",o=T.OPTION_TAG+" "+a;i=p({tagname:"option",className:o.trim(),value:t.value});var l=g(t.text);i.innerHTML=l;var u=t.disabled;u&&i.setAttribute("disabled",u),s.appendChild(i)}return n===e.index&&(i.selected=!0),i.getAttribute("disabled")&&m(d[n],T.DISABLED),i}var l=this,u=0,c=0,d=[],h=[],f=[],p=o["default"].constructElement,v=this.selectedClass,g=o["default"].escapeHTML,m=o["default"].addClass,y=this.refs,E=y.select,C=this.allowHTML,T=this.classes;return t.forEach(function(e,s){if("object"!==("undefined"==typeof e?"undefined":i(e))&&(e=t[s]={text:e,value:e}),e.header){var l=p({tagname:"div",className:T.SECTION}),v=p({tagname:"div",className:T.HEADER});v.textContent=e.header,l.appendChild(v),n.appendChild(l);var g=e.data;g.forEach(function(e,t){"object"!==("undefined"==typeof e?"undefined":i(e))&&(e=g[t]={text:e,value:e}),d[u]=r(e,u),l.appendChild(d[u]),h[u]=a(e,u),u++}),0==g.length&&o["default"].addClass(l,T.HIDDEN),f[c]=l,c++}else d[u]=r(e,u),n.appendChild(d[u]),h[u]=a(e,u),u++}),[d,h,f]},buildDom:function(){var e=this.props,t=this.classes;this.refs={};var n=o["default"].constructElement,s=o["default"].constructElement({className:t.MAIN_WRAPPER}),i=t.MAIN,a=this.multipleTags?i+" "+t.MULTIPLE_TAG_FLOUNDER:i,l=n({className:a});l.setAttribute("aria-hidden",!0),l.tabIndex=0,s.appendChild(l);var u=this.initSelectBox(s);u.tabIndex=-1;var c=this.data;this.defaultObj=(0,r.setDefaultOption)(this,this.props,c);var d=this.defaultObj,h=t.SELECTED_DISPLAYED;d.value&&d.extraClass&&(h+=" "+d.extraClass);var f=n({className:h,"data-value":d.value,"data-index":d.index}),p=this.multipleTags?n({className:t.MULTI_TAG_LIST}):null,v=n({className:t.OPTIONS_WRAPPER+" "+t.HIDDEN}),g=n({className:t.LIST});g.setAttribute("role","listbox"),v.appendChild(g),this.multiple===!0&&(u.setAttribute("multiple",""),g.setAttribute("aria-multiselectable","true"));var m=this.buildArrow(e,n);[f,p,v,m].forEach(function(e){e&&l.appendChild(e)});var y=this.addSearch(this.multipleTags?p:l),E=this.buildData(d,c,g,u);c=E[0];var C=E[1],T=E[2];if(this.target.appendChild(s),this.refs={wrapper:s,flounder:l,selected:f,arrow:m,optionsListWrapper:v,search:y,multiTagWrapper:p,optionsList:g,select:u,data:c,sections:T,selectOptions:C},this.multipleTags){var L=this.getSelected();0===L.length?f.innerHTML=d.text:this.displayMultipleTags(L,p)}else f.innerHTML=d.text},buildMultiTag:function(e){var t=this.classes,n=e.innerHTML,s=document.createElement("SPAN");s.className=t.MULTIPLE_SELECT_TAG,s.setAttribute("aria-label","Close"),s.setAttribute("tabindex",0);var i=document.createElement("A");return i.className=t.MULTIPLE_TAG_CLOSE,i.setAttribute("data-index",e.index),s.appendChild(i),s.innerHTML+=n,s},initSelectBox:function(e){var t=this.target,n=this.refs,s=n.select,i=this.classes;if("SELECT"===t.tagName){if(o["default"].addClass(t,i.SELECT_TAG),o["default"].addClass(t,i.HIDDEN),s=t,this.props.keepChangesOnDestroy||this.popOutSelectElements(s),t.length>0&&!this.selectDataOverride){this.refs.select=s;for(var r=[],a=[],l=0;l=0?e[s]:null;return i?(i.index=s,i):null}function i(){var i=e.sortData(o);!a.multipleTags&&!a.multiple||a.defaultIndex||a.defaultValue||(a.placeholder=a.placeholder||l.placeholder),a.defaultEmpty&&(a.placeholder="");var r=a.placeholder;if(r||""===r||0===i.length)return n(e,i);var c=void 0;if(u){var d=e.refs.selected.getAttribute("data-value");if(c=s(i,d))return c}return c=a.defaultIndex?t(i):null,c=!c&&a.defaultValue?s(i):c,c=c?c:t(i,0)}var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments[2],u=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return o=o||a.data||[],i()}};n.setDefaultOption=u.setDefaultOption;n["default"]=u},{"./classes":14,"./utils":20}],16:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var i=e("./utils"),r=s(i),a=e("./keycodes"),o=s(a),l={addFirstTouchListeners:function(){var e=this.refs;e.selected.addEventListener("click",this.firstTouchController),e.select.addEventListener("focus",this.firstTouchController),this.props.openOnHover&&e.wrapper.addEventListener("mouseenter",this.firstTouchController)},addHoverClass:function(e){r["default"].addClass(e.target,this.classes.HOVER)},addListeners:function(e){var t=this.isIos,n=t?"blur":"change";if(e.select.addEventListener(n,this.divertTarget),e.flounder.addEventListener("keydown",this.checkFlounderKeypress),this.props.openOnHover){var s=e.wrapper;s.addEventListener("mouseenter",this.toggleList),s.addEventListener("mouseleave",this.toggleList)}else e.selected.addEventListener("click",this.toggleList);this.addFirstTouchListeners(),this.addOptionsListeners(),this.search&&this.addSearchListeners()},addMultipleTags:function(e,t){var n=this;e.forEach(function(e){if(""!==e.value){var s=n.buildMultiTag(e);t.insertBefore(s,t.lastChild)}else e.selected=!1});for(var s=t.children,i=0;i1)for(var o=0;o=48&&t<=57||t>=65&&t<=90)&&n.search&&"INPUT"===e.target.tagName&&(n.selected.innerHTML="")},checkMultiTagKeydown:function(e){var t=this,n=e.keyCode,s=e.target,i=[o["default"].BACKSPACE,o["default"].LEFT,o["default"].RIGHT];i.indexOf(n)!==-1?(e.preventDefault(),e.stopPropagation(),n===o["default"].BACKSPACE?this.checkMultiTagKeydownRemove(s):this.checkMultiTagKeydownNavigate(n,s)):e.key.length<2&&setTimeout(function(){return t.refs.search.focus()},0)},checkMultiTagKeydownNavigate:function(e,t){if(e===o["default"].LEFT){var n=t.previousSibling;n&&n.focus()}else if(e===o["default"].RIGHT){var s=t.nextSibling;s&&setTimeout(function(){return s.focus()},0)}},checkMultiTagKeydownRemove:function(e){var t=e.previousSibling,n=e.nextSibling;e.firstChild.click(),t?setTimeout(function(){return t.focus()},0):n&&n.focus()},clearPlaceholder:function(){this.refs.selected.innerHTML=""},clickSet:function(e){e.preventDefault(),e.stopPropagation(),this.setSelectValue({},e),this.programmaticClick||this.toggleList(e,"close"),this.programmaticClick=!1},displayMultipleTags:function(e,t){for(var n=t.children,s=0;s0?this.addMultipleTags(e,t):this.addPlaceholder()},displaySelected:function(e,t){var n=[],s=-1,i=this.getSelected(),r=i.length,a=this.multipleTags;if(e.className=this.classes.SELECTED_DISPLAYED,a||1!==r)if(a||0!==r)a?(e.innerHTML="",this.displayMultipleTags(i,t.multiTagWrapper)):e.innerHTML=this.multipleMessage,s=i.map(function(e){return e.index}),n=i.map(function(e){return e.value});else{var o=this.defaultObj;s=o.index||-1,e.innerHTML=o.text,n=o.value}else{s=i[0].index,e.innerHTML=t.data[s].innerHTML,n=i[0].value;var l=t.data[s].extraClass;e.className+=l?" "+l:""}e.setAttribute("data-value",n),e.setAttribute("data-index",s)},divertTarget:function(e){if(this.isIos){var t=this.refs.select,n=this.classes,s=t.querySelector("."+n.PLUG);s&&t.removeChild(s)}var i=e.target.selectedIndex,r={type:e.type,target:this.data[i]};this.multipleTags&&(e.preventDefault(),e.stopPropagation()),this.setSelectValue(r), +this.multiple||this.toggleList(e,"close")},firstTouchController:function(e){var t=this.refs;if(this.onFirstTouch)try{this.onFirstTouch(e)}catch(e){console.warn('something may be wrong in "onFirstTouch"',e)}t.selected.removeEventListener("click",this.firstTouchController),t.select.removeEventListener("focus",this.firstTouchController),this.props.openOnHover&&t.wrapper.removeEventListener("mouseenter",this.firstTouchController)},hideEmptySection:function(e){for(var t=this.selectedClass,n=this.refs.sections,s=0;sa?o=0:o<0&&(o=a);var l=this.classes,u=r["default"].hasClass,c=i[o];s.selectedIndex=o,(u(c,l.HIDDEN)||u(c,l.SELECTED_HIDDEN)||u(c,l.SEARCH_HIDDEN)||u(c,l.DISABLED))&&this.setKeypress(e)},setSelectValue:function(e,t){var n=this.refs,s=void 0;if(t?this.setSelectValueClick(t):(s=e.keyCode,this.setSelectValueButton(e)),this.displaySelected(n.selected,n),!this.programmaticClick){var i=[9,16,17,18,20,91];if(t||"blur"===e.type||!s&&"change"===e.type||s&&i.indexOf(s)===-1)if(this.toggleList.justOpened&&!t)this.toggleList.justOpened=!1;else if(this.onChange)try{this.onChange(t,this.getSelectedValues())}catch(t){console.warn("something may be wrong in onChange",t)}this.programmaticClick=!1}},setSelectValueButton:function(){var e=this.refs,t=e.data,n=this.selectedClass,s=void 0;if(this.multipleTags)return!1;this.removeSelectedClass(t);var i=this.getSelected(),a=i[0];a&&(s=t[a.index],r["default"].addClass(s,n),r["default"].scrollTo(s,e.optionsListWrapper))},setSelectValueClick:function(e){var t=this.multiple,n=this.refs,s=this.selectedClass,i=e.target,a=i.getAttribute("data-index"),o=n.selectOptions[a];t&&(!t||this.multipleTags||e[this.multiSelect])||this.forceMultiple?(r["default"].toggleClass(i,s),o.selected=!o.selected):(this.deselectAll(),r["default"].addClass(i,s),o.selected=o.selected!==!0),this.forceMultiple=!1,this.hideEmptySection(i.parentNode);var l=n.selectOptions[0];""===l.value&&this.getSelected().length>1&&(r["default"].removeClass(n.data[0],s),n.selectOptions[0].selected=!1)},toggleClosed:function(e,t,n,s){var i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],a=this.classes;r["default"].addClass(n.optionsListWrapper,a.HIDDEN),r["default"].removeClass(s,a.OPEN);var o=document.querySelector("html");if(o.removeEventListener("click",this.catchBodyClick),o.removeEventListener("touchend",this.catchBodyClick),this.search?this.fuzzySearchReset():this.removeSelectKeyListener(),i||setTimeout(function(){return n.flounder.focus()},0),this.onClose&&this.ready)try{this.onClose(e,this.getSelectedValues())}catch(e){console.warn('something may be wrong in "onClose"',e)}},toggleList:function(e,t){var n=this.classes,s=this.refs,i=s.optionsListWrapper,a=s.wrapper,o=r["default"].hasClass(i,n.HIDDEN),l=e.type;"mouseleave"!==l&&"close"!==t&&o?("keydown"===l&&(this.toggleList.justOpened=!0),this.toggleOpen(e,i,s,a)):(this.toggleList.justOpened=!1,this.toggleClosed(e,i,s,a))},toggleListSearchClick:function(e){var t=this.classes;r["default"].hasClass(this.refs.wrapper,t.OPEN)||this.toggleList(e,"open")},toggleOpen:function(e,t,n){if(!this.isIos||this.search||this.multipleTags===!0){var s=this.classes;r["default"].removeClass(n.optionsListWrapper,s.HIDDEN),r["default"].addClass(n.wrapper,s.OPEN);var i=document.querySelector("html");i.addEventListener("click",this.catchBodyClick),i.addEventListener("touchend",this.catchBodyClick)}if(!this.multipleTags){var a=n.select.selectedIndex,o=n.data[a];r["default"].scrollTo(o,n.optionsListWrapper)}this.search?setTimeout(function(){return n.search.focus()},0):(this.addSelectKeyListener(),setTimeout(function(){return n.select.focus()},0));var l=n.data.length;if(this.props.placeholder&&l--,n.multiTagWrapper){var u=n.multiTagWrapper.children.length-1;u===l&&(this.removeNoResultsMessage(),this.addNoMoreOptionsMessage())}if(this.onOpen&&this.ready)try{this.onOpen(e,this.getSelectedValues())}catch(e){console.warn('something may be wrong in "onOpen"',e)}}};n["default"]=l},{"./keycodes":18,"./utils":20}],17:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}function i(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t1)console.warn("Flounder - More than one element found.\n Dropping all but the first.");else if(0===t.length)throw"Flounder - No target element found.";t=t[0]}return t.flounder&&t.flounder.destroy(),this.init(t,n)}console.warn("Flounder - No target element found.")}return o(e,[{key:"componentWillUnmount",value:function(){if(this.onComponentWillUnmount)try{this.onComponentWillUnmount()}catch(e){console.warn('something may be wrong in "onComponentWillUnmount"',e)}this.removeListeners(),this.originalChildren&&this.popInSelectElements(this.refs.select)}}]),o(e,[{key:"filterSearchResults",value:function(e){var t=e.target.value.trim();this.fuzzySearch.previousValue=t;var n=this.search.isThereAnythingRelatedTo(t)||[];if(""!==t){var s=this.refs.data,i=this.refs.sections,r=this.classes;s.forEach(function(e){c["default"].addClass(e,r.SEARCH_HIDDEN)}),i.forEach(function(e){c["default"].addClass(e,r.SEARCH_HIDDEN)}),n.forEach(function(e){c["default"].removeClass(s[e.i],r.SEARCH_HIDDEN),"number"==typeof e.d.s&&c["default"].removeClass(i[e.d.s],r.SEARCH_HIDDEN)}),this.refs.noMoreOptionsEl||(0===n.length?this.addNoResultsMessage():this.removeNoResultsMessage())}else this.fuzzySearchReset()}},{key:"fuzzySearch",value:function(e){if(this.fuzzySearch.previousValue=this.fuzzySearch.previousValue||"",this.onInputChange)try{this.onInputChange(e)}catch(e){console.warn('something may be wrong in "onInputChange"',e)}if(this.toggleList.justOpened)this.toggleList.justOpened=!1;else{e.preventDefault();var t=e.keyCode;if(t!==L["default"].UP&&t!==L["default"].DOWN&&t!==L["default"].ENTER&&t!==L["default"].ESCAPE)if(this.multipleTags&&t===L["default"].BACKSPACE&&""===this.fuzzySearch.previousValue){var n=this.refs.search.previousSibling;n&&setTimeout(function(){return n.focus()},0)}else this.filterSearchResults(e);else t!==L["default"].ESCAPE&&t!==L["default"].ENTER||(this.fuzzySearchReset(),this.toggleList(e,"close"),this.addPlaceholder())}}},{key:"fuzzySearchReset",value:function(){var e=this.refs,t=this.classes;e.sections.forEach(function(e){c["default"].removeClass(e,t.SEARCH_HIDDEN)}),e.data.forEach(function(e){c["default"].removeClass(e,t.SEARCH_HIDDEN)}),e.search.value="",this.removeNoResultsMessage()}},{key:"init",value:function(e,t){if(this.props=t,this.bindThis(),this.initializeOptions(),this.setTarget(e),this.search&&(this.search=new y["default"](this)),this.onInit)try{this.onInit()}catch(n){console.warn('something may be wrong in "onInit"',n)}this.buildDom();var s=c["default"].setPlatform(),i=s.isOsx,r=s.isIos,a=s.multiSelect;if(this.isOsx=i,this.isIos=r,this.multiSelect=a,this.onRender(),this.onComponentDidMount)try{this.onComponentDidMount()}catch(n){console.warn("something may be wrong in onComponentDidMount",n)}return this.ready=!0,this.originalTarget.flounder=this.target.flounder=this,this.refs.flounder.flounder=this}},{key:"initializeOptions",value:function(){var e=this.props=this.props||{};for(var t in l.defaultOptions)if("onChange"===t&&e.onSelect)this.onChange=e.onSelect,console.warn("Please use onChange. onSelect has been\n depricated and will be removed in 2.0.0"),this.onSelect=function(){console.warn("Please use onChange. onSelect has been\n depricated and will be removed in 2.0.0"),this.onChange.apply(this,arguments)};else if("classes"===t){this.classes={};var n=l.defaultOptions[t],s="object"===a(e[t])?e[t]:{};for(var r in n)this.classes[r]=s[r]?s[r]:n[r]}else"data"===t?this.data=e.data&&e.data.length?[].concat(i(e.data)):[].concat(i(l.defaultOptions.data)):this[t]=void 0!==e[t]?e[t]:l.defaultOptions[t];this.selectedClass=this.classes.SELECTED,e.defaultEmpty&&(this.placeholder=""),this.multipleTags&&(this.search=!0,this.multiple=!0,this.selectedClass+=" "+this.classes.SELECTED_HIDDEN)}},{key:"onRender",value:function(){var e=this.props,t=this.refs;if(this.isIos&&!this.multiple){var n=t.select,s=this.classes;c["default"].removeClass(n,s.HIDDEN),c["default"].addClass(n,s.HIDDEN_IOS)}this.addListeners(t,e)}},{key:"sortData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=this,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,r=0;return e.forEach(function(e){e.header?(t=n.sortData(e.data,t,s,r),r++):("object"!==("undefined"==typeof e?"undefined":a(e))?e={text:e,value:e,index:s}:e.index=s,void 0!==i&&(e.s=i),t.push(e),s++)}),t}}]),e}();S.find=function(e,t){return"string"==typeof e?e=document.querySelectorAll(e):1===e.nodeType&&(e=[e]),Array.prototype.slice.call(e,0).map(function(e){return new S(e,t)})},Object.defineProperty(S,"version",{get:function(){return C["default"]}}),Object.defineProperty(S.prototype,"version",{get:function(){return C["default"]}}),c["default"].extendClass(S,h["default"],p["default"],g["default"]),n["default"]=S},{"./api":12,"./build":13,"./defaults":15,"./events":16,"./keycodes":18,"./search":19,"./utils":20,"./version":21}],18:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var s={BACKSPACE:8,DOWN:40,ENTER:13,ESCAPE:27,LEFT:37,RIGHT:39,SPACE:32,TAB:9,UP:38,NON_CHARACTER_KEYS:[16,17,18,20,91,93]};n["default"]=s},{}],19:[function(e,t,n){"use strict";function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;nt?1:e=r.minimumScore}},{key:"isThereAnythingRelatedTo",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=void 0;if(e=e.length?e:""+e,!(e.length>=r.minimumValueLength))return!1;this.query=e.toLowerCase().split(" ");var n=this.flounder.data;return n=this.flounder.sortData(n),t=this.ratedRes=n.map(this.getResultWeights),t=t.filter(this.isItemAboveMinimum),t.sort(this.compareScoreCards),this.ratedRes=t}},{key:"startsWith",value:function(e,t,n){var s=t.length,i=e.length;if(i<=s){var r=t.toLowerCase().slice(0,i);if(r===e)return n}return 0}},{key:"scoreThis",value:function(e,t,n){var s=this,i=0;return e&&this.query.forEach(function(r){r=s.escapeRegExp(r);var a=0;"string"==typeof e?(r=new RegExp(r,"g"),a=(e.match(r)||[]).length):e[0]?e.forEach(function(e){a+=e.indexOf(r)!==-1?1:0}):a=e[r]||1e-6,a>0?i=t*a*10:n!==!0&&(i=-t)}),Math.floor(i)}}]),e}();n["default"]=a},{}],20:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var i=e("microbejs/src/modules/http"),r=s(i),a={addClass:function(e,t){if("string"!=typeof t&&t.length)return t.forEach(function(t){a.addClass(e,t)}),!0;var n=e.className,s=n.length,i=n.slice(s-t.length-1,s);a.hasClass(e,t)||n.slice(0,t.length+1)===t+" "||i===" "+t||(n+=" "+t),e.className=n.trim()},attachAttributes:function(e,t){if(!t)return null;for(var n in t)"data-"===n.slice(0,5)?e.setAttribute(n,t[n]):e[n]=t[n]},constructElement:function(e){var t=document.createElement(e.tagname||"div");return a.attachAttributes(t,e),t},debounce:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this,s=void 0,i=void 0,r=function(){return e.apply(n,s)};return function(){clearTimeout(i),s=arguments,i=setTimeout(r,t)}},extendClass:function(e){function t(t){for(var n in t)e[n]=t[n]}e=e.prototype;for(var n=arguments.length,s=Array(n>1?n-1:0),i=1;i/g,">").replace(/"/g,""")},getElWidth:function(e,t,n){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1500,i=window.getComputedStyle(e);if(0===e.offsetWidth&&this.checkWidthAgain!==!0){if(!t||!n)throw"Flounder getElWidth error: no callback given.";setTimeout(t.bind(n),s),this.checkWidthAgain=!0}else this.checkWidthAgain=!1;return e.offsetWidth+parseInt(i["margin-left"])+parseInt(i["margin-right"])},hasClass:function(e,t){var n=e.className,s=new RegExp("(^"+t+" )|( "+t+"$)|( "+t+" )|(^"+t+"$)");return!!n.match(s)},http:!1,iosVersion:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window;return!!/iPad|iPhone|iPod/.test(e.navigator.platform)&&(e.indexedDB?"8+":e.SpeechSynthesisUtterance?"7":e.webkitAudioContext?"6":"5-")},removeAllChildren:function(e){Array.prototype.slice.call(e.children,0).forEach(function(t){e.removeChild(t)})},removeClass:function(e,t){if("string"!=typeof t&&t.length)return t.forEach(function(t){a.removeClass(e,t)}),!0;var n=e.className,s=n.length,i=t.length;n===t?n="":n.slice(0,i+1)===t+" "?n=n.slice(i+1,s):n.slice(s-i-1,s)===" "+t?n=n.slice(0,s-i-1):n.indexOf(" "+t+" ")!==-1&&(n=n.replace(" "+t+" "," ")),e.className=n.trim()},scrollTo:function(e,t){if(e){var n=t||e.offsetParent;if(n.scrollHeight>n.offsetHeight){var s=e.offsetTop,i=e.offsetHeight,r=n.offsetHeight,a=n.scrollTop,o=a+n.offsetHeight-i;so&&(n.scrollTop=s-(r-i))}}return!1},setPlatform:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window,t=e.navigator.platform,n=t.indexOf("Mac")!==-1,s=a.iosVersion(e),i=n?"metaKey":"ctrlKey";return{isOsx:n,isIos:s,multiSelect:i}},toggleClass:function(e,t){a.hasClass(e,t)?a.removeClass(e,t):a.addClass(e,t)}};(0,r["default"])(a),n["default"]=a},{"microbejs/src/modules/http":3}],21:[function(e,t,n){"use strict";t.exports="1.3.1"},{}]},{},[17]); \ No newline at end of file