diff --git a/demo/demoDist.js b/demo/demoDist.js index 7e8a875..7ca40ff 100644 --- a/demo/demoDist.js +++ b/demo/demoDist.js @@ -48,7 +48,8 @@ var buildData = function buildData() { res.push({ text: dataObj.text, value: dataObj.id, - description: dataObj.id + ' could be described as "' + dataObj.text + '"' + description: dataObj.id + ' could be described as "' + dataObj.text + '"', + extraClass: dataObj.cssClass }); }); @@ -1394,8 +1395,6 @@ var _defaults = require('./defaults'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -var nativeSlice = Array.prototype.slice; - var api = { /** @@ -1538,8 +1537,6 @@ var api = { * @return {Void} void */ deselectAll: function deselectAll(silent) { - var _this2 = this; - this.removeSelectedClass(); this.removeSelectedValue(); @@ -1547,10 +1544,12 @@ var api = { var multiTagWrapper = this.refs.multiTagWrapper; if (multiTagWrapper) { - var tags = nativeSlice.call(multiTagWrapper.children, 0, -1); + var children = multiTagWrapper.children; - tags.forEach(function (el, count) { - var lastEl = count === tags.length - 1; + for (var i = 0; i < children.length - 1; i++) { + var el = children[i]; + + var lastEl = i === children.length - 1; if (!silent && lastEl) { el = el.children; @@ -1558,10 +1557,10 @@ var api = { el.click(); } else { - el.removeEventListener('click', _this2.removeMultiTag); + el.removeEventListener('click', this.removeMultiTag); el.remove(); } - }); + } this.addPlaceholder(); } @@ -1585,14 +1584,12 @@ var api = { var selected = refs.selected; if (bool) { - refs.flounder.removeEventListener('keydown', this.checkFlounderKeypress); - refs.selected.removeEventListener('click', this.toggleList); - _utils2.default.addClass(selected, classes.DISABLED); + flounder.removeEventListener('keydown', this.checkFlounderKeypress); + selected.removeEventListener('click', this.toggleList); _utils2.default.addClass(flounder, classes.DISABLED); } else { - refs.flounder.addEventListener('keydown', this.checkFlounderKeypress); - refs.selected.addEventListener('click', this.toggleList); - _utils2.default.removeClass(selected, classes.DISABLED); + flounder.addEventListener('keydown', this.checkFlounderKeypress); + selected.addEventListener('click', this.toggleList); _utils2.default.removeClass(flounder, classes.DISABLED); } }, @@ -1768,7 +1765,7 @@ var api = { * @return {Object} option and div tage */ getData: function getData(index) { - var _this3 = this; + var _this2 = this; var refs = this.refs; @@ -1779,11 +1776,11 @@ var api = { }; } else if (index && index.length && typeof index !== 'string') { return index.map(function (i) { - return _this3.getData(i); + return _this2.getData(i); }); } else if (!index) { return refs.selectOptions.map(function (el, i) { - return _this3.getData(i); + return _this2.getData(i); }); } @@ -1804,11 +1801,32 @@ var api = { var data = el.options; var classes = this.classes; - nativeSlice.call(data).forEach(function (el) { - if (el.selected && !_utils2.default.hasClass(el, classes.PLACEHOLDER)) { - opts.push(el); + 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; + } + } + } return opts; }, @@ -1839,23 +1857,23 @@ var api = { * @return {Void} void */ loadDataFromUrl: function loadDataFromUrl(url, callback) { - var _this4 = this; + var _this3 = this; var classes = this.classes; _utils2.default.http.get(url).then(function (data) { if (data) { - _this4.data = JSON.parse(data); + _this3.data = JSON.parse(data); if (callback) { - callback(_this4.data); + callback(_this3.data); } } else { console.warn('no data recieved'); } }).catch(function (e) { console.warn('something happened: ', e); - _this4.rebuild([{ + _this3.rebuild([{ text: '', value: '', index: 0, @@ -2064,8 +2082,6 @@ var _utils2 = _interopRequireDefault(_utils); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -var nativeSlice = Array.prototype.slice; - var build = { /** @@ -2386,8 +2402,13 @@ var build = { this.defaultObj = (0, _defaults.setDefaultOption)(this, this.props, data); var defaultValue = this.defaultObj; + var selectedClassName = classes.SELECTED_DISPLAYED; + if (defaultValue.value && defaultValue.extraClass) { + selectedClassName += ' ' + defaultValue.extraClass; + } + var selected = constructElement({ - className: classes.SELECTED_DISPLAYED, + className: selectedClassName, 'data-value': defaultValue.value, 'data-index': defaultValue.index }); @@ -2518,13 +2539,34 @@ var build = { var data = []; var selectOptions = []; - nativeSlice.call(target.children, 0).forEach(function (optionEl) { - selectOptions.push(optionEl); - data.push({ - text: optionEl.innerHTML, - value: optionEl.value - }); - }); + 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; + } + } + } refs.selectOptions = selectOptions; @@ -2561,9 +2603,30 @@ var build = { popInSelectElements: function popInSelectElements(select) { _utils2.default.removeAllChildren(select); - this.originalChildren.forEach(function (_el) { - select.appendChild(_el); - }); + 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; + } + } + } }, @@ -2580,13 +2643,15 @@ var build = { popOutSelectElements: function popOutSelectElements(select) { var res = []; - this.originalChildren = nativeSlice.call(select.children, 0); + this.originalChildren = select.children; var children = this.originalChildren; - children.forEach(function (_el, i) { - res[i] = _el.cloneNode(true); - select.removeChild(_el); - }); + for (var i = 0; i < children.length; i++) { + var el = children[i]; + + res[i] = el.cloneNode(true); + select.removeChild(el); + } res.forEach(function (_el) { select.appendChild(_el); @@ -2660,7 +2725,6 @@ var classes = { ARROW_INNER: 'flounder__arrow--inner', DESCRIPTION: 'flounder__option--description', DISABLED: 'flounder__disabled', - DISABLED_OPTION: 'flounder__disabled--option', HEADER: 'flounder__header', HIDDEN: 'flounder--hidden', HIDDEN_IOS: 'flounder--hidden--ios', @@ -2724,14 +2788,14 @@ var defaultOptions = exports.defaultOptions = { multipleMessage: '(Multiple Items Selected)', noMoreOptionsMessage: 'No more options to add.', noMoreResultsMessage: 'No matches found', - onChange: function onChange(e, selectedValues) {}, // eslint-disable-line - onClose: function onClose(e, selectedValues) {}, // eslint-disable-line - onComponentDidMount: function onComponentDidMount() {}, // eslint-disable-line - onComponentWillUnmount: function onComponentWillUnmount() {}, // eslint-disable-line - onFirstTouch: function onFirstTouch(e) {}, // eslint-disable-line - onInit: function onInit() {}, // eslint-disable-line - onInputChange: function onInputChange(e) {}, // eslint-disable-line - onOpen: function onOpen(e, selectedValues) {}, // eslint-disable-line + onChange: null, // function( e, selectedValues ){} + onClose: null, // function( e, selectedValues ){} + onComponentDidMount: null, // function(){} + onComponentWillUnmount: null, // function(){} + onFirstTouch: null, // function( e ){} + onInit: null, // function(){} + onInputChange: null, // function( e ){} + onOpen: null, // function( e, selectedValues ){} openOnHover: false, placeholder: 'Please choose an option', search: false, @@ -2931,8 +2995,6 @@ var _keycodes2 = _interopRequireDefault(_keycodes); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /* globals console, document, setTimeout, window */ -var nativeSlice = Array.prototype.slice; - var events = { /** @@ -3022,14 +3084,15 @@ var events = { } }); - var tags = nativeSlice.call(multiTagWrapper.children, 0, -1); + var children = multiTagWrapper.children; - tags.forEach(function (tag) { + for (var i = 0; i < children.length - 1; i++) { + var tag = children[i]; var closeBtn = tag.firstChild; - closeBtn.addEventListener('click', _this.removeMultiTag); - tag.addEventListener('keydown', _this.checkMultiTagKeydown); - }); + closeBtn.addEventListener('click', this.removeMultiTag); + tag.addEventListener('keydown', this.checkMultiTagKeydown); + } }, @@ -3151,13 +3214,15 @@ var events = { var search = this.refs.search; var multiTagWrapper = this.refs.multiTagWrapper; + this.debouncedFuzzySearch = _utils2.default.debounce(this.fuzzySearch, 200); + if (multiTagWrapper) { multiTagWrapper.addEventListener('click', this.toggleListSearchClick); } search.addEventListener('click', this.toggleListSearchClick); search.addEventListener('focus', this.toggleListSearchClick); - search.addEventListener('keyup', this.fuzzySearch); + search.addEventListener('keyup', this.debouncedFuzzySearch); search.addEventListener('focus', this.clearPlaceholder); }, @@ -3292,10 +3357,12 @@ var events = { }, 200); } - try { - this.onChange(e, this.getSelectedValues()); - } catch (e) { - console.warn('something may be wrong in "onChange"', e); + if (this.onChange) { + try { + this.onChange(e, this.getSelectedValues()); + } catch (e) { + console.warn('something may be wrong in "onChange"', e); + } } } } @@ -3353,47 +3420,35 @@ var events = { /** * ## checkMultiTagKeydown * - * when a tag is selected, this decided how to handle it by either - * passing the event on, or handling tag removal + * when a tag is selected, this decides how to handle it by either passing + * the event on, or handling tag removal * * @param {Object} e event object * * @return {Void} void */ checkMultiTagKeydown: function checkMultiTagKeydown(e) { - var keyCode = e.keyCode; - var self = this; - var refs = this.refs; - var tags = nativeSlice.call(refs.multiTagWrapper.children, 0, -1); - var target = e.target; - var index = tags.indexOf(target); + var _this3 = this; - /** - * ## focusSearch - * - * focus' on the search input - * - * @return {Void} void - */ - function focusSearch() { - setTimeout(function () { - return refs.search.focus(); - }, 0); - self.clearPlaceholder(); - self.toggleListSearchClick(e); - } + var keyCode = e.keyCode, + target = e.target; + + + var catchKeys = [_keycodes2.default.BACKSPACE, _keycodes2.default.LEFT, _keycodes2.default.RIGHT]; - if (keyCode === _keycodes2.default.LEFT || keyCode === _keycodes2.default.RIGHT || keyCode === _keycodes2.default.BACKSPACE) { + if (catchKeys.indexOf(keyCode) !== -1) { e.preventDefault(); e.stopPropagation(); if (keyCode === _keycodes2.default.BACKSPACE) { - self.checkMultiTagKeydownRemove(target, focusSearch, index); + this.checkMultiTagKeydownRemove(target); } else { - self.checkMultiTagKeydownNavigate(focusSearch, keyCode, index); + this.checkMultiTagKeydownNavigate(keyCode, target); } } else if (e.key.length < 2) { - focusSearch(); + setTimeout(function () { + return _this3.refs.search.focus(); + }, 0); } }, @@ -3401,28 +3456,29 @@ var events = { /** * ## checkMultiTagKeydownNavigate * - * after left or right is hit while a multitag is focused, this focus' on + * after left or right is hit while a multitag is focused, this focuses on * the next tag in that direction or the the search field * - * @param {Function} focusSearch function to focus on the search field - * @param {Number} keyCode keyclode from te keypress event - * @param {Number} index index of currently focused tag + * @param {Number} keyCode keycode from the keypress event + * @param {DOMElement} target focused multitag * * @return {Void} void */ - checkMultiTagKeydownNavigate: function checkMultiTagKeydownNavigate(focusSearch, keyCode, index) { - var tags = nativeSlice.call(this.refs.multiTagWrapper.children, 0, -1); + checkMultiTagKeydownNavigate: function checkMultiTagKeydownNavigate(keyCode, target) { + if (keyCode === _keycodes2.default.LEFT) { + var prev = target.previousSibling; - var adjustment = keyCode - 38; - var newIndex = index + adjustment; - var length = tags.length - 1; + if (prev) { + prev.focus(); + } + } else if (keyCode === _keycodes2.default.RIGHT) { + var next = target.nextSibling; - if (newIndex > length) { - focusSearch(); - } else if (newIndex >= 0) { - setTimeout(function () { - return tags[newIndex].focus(); - }, 0); + if (next) { + setTimeout(function () { + return next.focus(); + }, 0); + } } }, @@ -3430,28 +3486,25 @@ var events = { /** * ## checkMultiTagKeydownRemove * - * after a backspece while a multitag is focused, this removes the tag and - * focus' on the next + * after a backspace while a multitag is focused, this removes the tag and + * focuses on the next * * @param {DOMElement} target focused multitag - * @param {Function} focusSearch function to focus on the search field - * @param {Number} index index of currently focused tag * * @return {Void} void */ - checkMultiTagKeydownRemove: function checkMultiTagKeydownRemove(target, focusSearch, index) { - var tags = nativeSlice.call(this.refs.multiTagWrapper.children, 0, -1); - - var siblings = tags.length - 1; + checkMultiTagKeydownRemove: function checkMultiTagKeydownRemove(target) { + var prev = target.previousSibling; + var next = target.nextSibling; target.firstChild.click(); - if (siblings > 0) { + if (prev) { setTimeout(function () { - return tags[index === 0 ? 0 : index - 1].focus(); + return prev.focus(); }, 0); - } else { - focusSearch(); + } else if (next) { + next.focus(); } }, @@ -3506,18 +3559,17 @@ var events = { * @return {Void} void */ displayMultipleTags: function displayMultipleTags(selectedOptions, multiTagWrapper) { - var _this3 = this; - - var tags = nativeSlice.call(multiTagWrapper.children, 0, -1); + var children = multiTagWrapper.children; - tags.forEach(function (tag) { + for (var i = 0; i < children.length - 1; i++) { + var tag = children[i]; var closeBtn = tag.firstChild; - closeBtn.removeEventListener('click', _this3.removeMultiTag); - tag.removeEventListener('keydown', _this3.checkMultiTagKeydown); + closeBtn.removeEventListener('click', this.removeMultiTag); + tag.removeEventListener('keydown', this.checkMultiTagKeydown); multiTagWrapper.removeChild(tag); - }); + } if (selectedOptions.length > 0) { this.addMultipleTags(selectedOptions, multiTagWrapper); @@ -3637,10 +3689,12 @@ var events = { firstTouchController: function firstTouchController(e) { var refs = this.refs; - try { - this.onFirstTouch(e); - } catch (e) { - console.warn('something may be wrong in "onFirstTouch"', e); + if (this.onFirstTouch) { + try { + this.onFirstTouch(e); + } catch (e) { + console.warn('something may be wrong in "onFirstTouch"', e); + } } refs.selected.removeEventListener('click', this.firstTouchController); @@ -3790,10 +3844,12 @@ var events = { selected.setAttribute('data-value', value); selected.setAttribute('data-index', index); - try { - this.onChange(e, this.getSelectedValues()); - } catch (e) { - console.warn('something may be wrong in "onChange"', e); + if (this.onChange) { + try { + this.onChange(e, this.getSelectedValues()); + } catch (e) { + console.warn('something may be wrong in "onChange"', e); + } } }, @@ -3864,7 +3920,7 @@ var events = { var search = this.refs.search; search.removeEventListener('click', this.toggleListSearchClick); search.removeEventListener('focus', this.toggleListSearchClick); - search.removeEventListener('keyup', this.fuzzySearch); + search.removeEventListener('keyup', this.debouncedFuzzySearch); search.removeEventListener('focus', this.clearPlaceholder); }, @@ -4052,7 +4108,7 @@ var events = { if (e || obj.type === 'blur' || !keyCode && obj.type === 'change' || keyCode && nonKeys.indexOf(keyCode) === -1) { if (this.toggleList.justOpened && !e) { this.toggleList.justOpened = false; - } else { + } else if (this.onChange) { try { this.onChange(e, this.getSelectedValues()); } catch (e) { @@ -4093,7 +4149,7 @@ var events = { _utils2.default.addClass(selectedOption, selectedClass); - _utils2.default.scrollTo(selectedOption); + _utils2.default.scrollTo(selectedOption, refs.optionsListWrapper); } }, @@ -4176,7 +4232,7 @@ var events = { }, 0); } - if (this.ready) { + if (this.onClose && this.ready) { try { this.onClose(e, this.getSelectedValues()); } catch (e) { @@ -4265,7 +4321,7 @@ var events = { var index = refs.select.selectedIndex; var selectedDiv = refs.data[index]; - _utils2.default.scrollTo(selectedDiv); + _utils2.default.scrollTo(selectedDiv, refs.optionsListWrapper); } if (this.search) { @@ -4286,15 +4342,15 @@ var events = { } if (refs.multiTagWrapper) { - var tags = nativeSlice.call(refs.multiTagWrapper.children, 0, -1); + var numTags = refs.multiTagWrapper.children.length - 1; - if (tags.length === optionCount) { + if (numTags === optionCount) { this.removeNoResultsMessage(); this.addNoMoreOptionsMessage(); } } - if (this.ready) { + if (this.onOpen && this.ready) { try { this.onOpen(e, this.getSelectedValues()); } catch (e) { @@ -4355,14 +4411,11 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -var nativeSlice = Array.prototype.slice; - /** * main flounder class * * @return {Object} Flounder instance */ - var Flounder = function () { _createClass(Flounder, [{ key: 'componentWillUnmount', @@ -4375,10 +4428,12 @@ var Flounder = function () { * @return {Void} void */ value: function componentWillUnmount() { - try { - this.onComponentWillUnmount(); - } catch (e) { - console.warn('something may be wrong in\n "onComponentWillUnmount"', e); + if (this.onComponentWillUnmount) { + try { + this.onComponentWillUnmount(); + } catch (e) { + console.warn('something may be wrong in "onComponentWillUnmount"', e); + } } this.removeListeners(); @@ -4498,10 +4553,12 @@ var Flounder = function () { value: function fuzzySearch(e) { this.fuzzySearch.previousValue = this.fuzzySearch.previousValue || ''; - try { - this.onInputChange(e); - } catch (e) { - console.warn('something may be wrong in "onInputChange"', e); + if (this.onInputChange) { + try { + this.onInputChange(e); + } catch (e) { + console.warn('something may be wrong in "onInputChange"', e); + } } if (!this.toggleList.justOpened) { @@ -4511,7 +4568,7 @@ var Flounder = function () { if (keyCode !== _keycodes2.default.UP && keyCode !== _keycodes2.default.DOWN && keyCode !== _keycodes2.default.ENTER && keyCode !== _keycodes2.default.ESCAPE) { if (this.multipleTags && keyCode === _keycodes2.default.BACKSPACE && this.fuzzySearch.previousValue === '') { - var lastTag = nativeSlice.call(this.refs.multiTagWrapper.children, 0, -1).pop(); + var lastTag = this.refs.search.previousSibling; if (lastTag) { setTimeout(function () { @@ -4582,10 +4639,12 @@ var Flounder = function () { this.search = new _search2.default(this); } - try { - this.onInit(); - } catch (e) { - console.warn('something may be wrong in "onInit"', e); + if (this.onInit) { + try { + this.onInit(); + } catch (e) { + console.warn('something may be wrong in "onInit"', e); + } } this.buildDom(); @@ -4600,10 +4659,12 @@ var Flounder = function () { this.multiSelect = multiSelect; this.onRender(); - try { - this.onComponentDidMount(); - } catch (e) { - console.warn('something may be wrong in onComponentDidMount', e); + if (this.onComponentDidMount) { + try { + this.onComponentDidMount(); + } catch (e) { + console.warn('something may be wrong in onComponentDidMount', e); + } } this.ready = true; @@ -5238,6 +5299,36 @@ var utils = { }, + /** + * ## debounce + * + * debounces a function using the specified delay + * + * @param {Function} func function to be debounced + * @param {Number} wait debounce delay + * @param {Object} context context for debounced funtion execution + * + * @return {Void} void + */ + debounce: function debounce(func, wait) { + var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this; + + var args = void 0; + var timeout = void 0; + + var debounced = function debounced() { + return func.apply(context, args); + }; + + return function () { + clearTimeout(timeout); + + args = arguments; + timeout = setTimeout(debounced, wait); + }; + }, + + /** * ## extendClass * @@ -5434,26 +5525,32 @@ var utils = { * * checks if an option is visible and, if it is not, scrolls it into view * - * @param {DOMElement} element element to check + * @param {DOMElement} element element to check + * @param {DOMElement} [scrollParent] parent element to scroll * * @return {Void} void */ - scrollTo: function scrollTo(element) { + scrollTo: function scrollTo(element, scrollParent) { if (element) { - var parent = element.parentNode.parentNode; - var elHeight = element.offsetHeight; - var min = parent.scrollTop; - var max = parent.scrollTop + parent.offsetHeight - elHeight; - var pos = element.offsetTop; - - if (pos < min) { - parent.scrollTop = pos - elHeight * 0.5; - } else if (pos > max) { - parent.scrollTop = pos - parent.offsetHeight + elHeight * 1.5; + var scrollElement = scrollParent || element.offsetParent; + + if (scrollElement.scrollHeight > scrollElement.offsetHeight) { + var pos = element.offsetTop; + var elHeight = element.offsetHeight; + var contHeight = scrollElement.offsetHeight; + + var min = scrollElement.scrollTop; + var max = min + scrollElement.offsetHeight - elHeight; + + if (pos < min) { + scrollElement.scrollTop = pos; + } else if (pos > max) { + scrollElement.scrollTop = pos - (contHeight - elHeight); + } } - } else { - return false; } + + return false; }, @@ -5499,7 +5596,7 @@ var utils = { utils.addClass(_el, _class); } } -}; /* globals document, window, setTimeout*/ +}; /* globals clearTimeout, document, setTimeout, window */ (0, _http2.default)(utils); @@ -5510,6 +5607,6 @@ exports.default = utils; 'use strict'; /* globals module */ -module.exports = '1.2.3'; +module.exports = '1.3.0'; },{}]},{},[1]); diff --git a/dist/flounder-structure.css b/dist/flounder-structure.css index 7b11269..bfdfa26 100644 --- a/dist/flounder-structure.css +++ b/dist/flounder-structure.css @@ -3,7 +3,6 @@ { display: inline-block; text-align: left; - user-select: none; width: 18rem; } @@ -250,19 +249,15 @@ input:active ~ .flounder__arrow--wrapper } -.flounder--hidden, -.flounder--search--hidden +.flounder--hidden { left: -999999px; position: absolute; } - -.flounder__disabled, -.flounder__disabled--option +.flounder--search--hidden { - cursor: auto; - pointer-events: none; + display: none; } @@ -270,6 +265,8 @@ input:active ~ .flounder__arrow--wrapper { border-color: #cccccc; color: #cccccc; + cursor: auto; + pointer-events: none; } @@ -320,6 +317,7 @@ div:focus > .flounder__multiple__tag__close margin-right: 4px; padding: 4px 5px; position: relative; + user-select: none; z-index: 2; } diff --git a/dist/flounder.amd.js b/dist/flounder.amd.js index 6b14992..fedf081 100644 --- a/dist/flounder.amd.js +++ b/dist/flounder.amd.js @@ -1,12 +1,12 @@ /*! - * Flounder JavaScript Stylable Selectbox v1.2.3 + * Flounder JavaScript Stylable Selectbox v1.3.0 * 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 Sep 13 2017 + * Date: Wed Oct 11 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;o length) { - focusSearch(); - } else if (newIndex >= 0) { - setTimeout(function () { - return tags[newIndex].focus(); - }, 0); + if (next) { + setTimeout(function () { + return next.focus(); + }, 0); + } } }, @@ -3133,28 +3188,25 @@ var events = { /** * ## checkMultiTagKeydownRemove * - * after a backspece while a multitag is focused, this removes the tag and - * focus' on the next + * after a backspace while a multitag is focused, this removes the tag and + * focuses on the next * * @param {DOMElement} target focused multitag - * @param {Function} focusSearch function to focus on the search field - * @param {Number} index index of currently focused tag * * @return {Void} void */ - checkMultiTagKeydownRemove: function checkMultiTagKeydownRemove(target, focusSearch, index) { - var tags = nativeSlice.call(this.refs.multiTagWrapper.children, 0, -1); - - var siblings = tags.length - 1; + checkMultiTagKeydownRemove: function checkMultiTagKeydownRemove(target) { + var prev = target.previousSibling; + var next = target.nextSibling; target.firstChild.click(); - if (siblings > 0) { + if (prev) { setTimeout(function () { - return tags[index === 0 ? 0 : index - 1].focus(); + return prev.focus(); }, 0); - } else { - focusSearch(); + } else if (next) { + next.focus(); } }, @@ -3209,18 +3261,17 @@ var events = { * @return {Void} void */ displayMultipleTags: function displayMultipleTags(selectedOptions, multiTagWrapper) { - var _this3 = this; - - var tags = nativeSlice.call(multiTagWrapper.children, 0, -1); + var children = multiTagWrapper.children; - tags.forEach(function (tag) { + for (var i = 0; i < children.length - 1; i++) { + var tag = children[i]; var closeBtn = tag.firstChild; - closeBtn.removeEventListener('click', _this3.removeMultiTag); - tag.removeEventListener('keydown', _this3.checkMultiTagKeydown); + closeBtn.removeEventListener('click', this.removeMultiTag); + tag.removeEventListener('keydown', this.checkMultiTagKeydown); multiTagWrapper.removeChild(tag); - }); + } if (selectedOptions.length > 0) { this.addMultipleTags(selectedOptions, multiTagWrapper); @@ -3340,10 +3391,12 @@ var events = { firstTouchController: function firstTouchController(e) { var refs = this.refs; - try { - this.onFirstTouch(e); - } catch (e) { - console.warn('something may be wrong in "onFirstTouch"', e); + if (this.onFirstTouch) { + try { + this.onFirstTouch(e); + } catch (e) { + console.warn('something may be wrong in "onFirstTouch"', e); + } } refs.selected.removeEventListener('click', this.firstTouchController); @@ -3493,10 +3546,12 @@ var events = { selected.setAttribute('data-value', value); selected.setAttribute('data-index', index); - try { - this.onChange(e, this.getSelectedValues()); - } catch (e) { - console.warn('something may be wrong in "onChange"', e); + if (this.onChange) { + try { + this.onChange(e, this.getSelectedValues()); + } catch (e) { + console.warn('something may be wrong in "onChange"', e); + } } }, @@ -3567,7 +3622,7 @@ var events = { var search = this.refs.search; search.removeEventListener('click', this.toggleListSearchClick); search.removeEventListener('focus', this.toggleListSearchClick); - search.removeEventListener('keyup', this.fuzzySearch); + search.removeEventListener('keyup', this.debouncedFuzzySearch); search.removeEventListener('focus', this.clearPlaceholder); }, @@ -3755,7 +3810,7 @@ var events = { if (e || obj.type === 'blur' || !keyCode && obj.type === 'change' || keyCode && nonKeys.indexOf(keyCode) === -1) { if (this.toggleList.justOpened && !e) { this.toggleList.justOpened = false; - } else { + } else if (this.onChange) { try { this.onChange(e, this.getSelectedValues()); } catch (e) { @@ -3796,7 +3851,7 @@ var events = { _utils2.default.addClass(selectedOption, selectedClass); - _utils2.default.scrollTo(selectedOption); + _utils2.default.scrollTo(selectedOption, refs.optionsListWrapper); } }, @@ -3879,7 +3934,7 @@ var events = { }, 0); } - if (this.ready) { + if (this.onClose && this.ready) { try { this.onClose(e, this.getSelectedValues()); } catch (e) { @@ -3968,7 +4023,7 @@ var events = { var index = refs.select.selectedIndex; var selectedDiv = refs.data[index]; - _utils2.default.scrollTo(selectedDiv); + _utils2.default.scrollTo(selectedDiv, refs.optionsListWrapper); } if (this.search) { @@ -3989,15 +4044,15 @@ var events = { } if (refs.multiTagWrapper) { - var tags = nativeSlice.call(refs.multiTagWrapper.children, 0, -1); + var numTags = refs.multiTagWrapper.children.length - 1; - if (tags.length === optionCount) { + if (numTags === optionCount) { this.removeNoResultsMessage(); this.addNoMoreOptionsMessage(); } } - if (this.ready) { + if (this.onOpen && this.ready) { try { this.onOpen(e, this.getSelectedValues()); } catch (e) { @@ -4058,14 +4113,11 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -var nativeSlice = Array.prototype.slice; - /** * main flounder class * * @return {Object} Flounder instance */ - var Flounder = function () { _createClass(Flounder, [{ key: 'componentWillUnmount', @@ -4078,10 +4130,12 @@ var Flounder = function () { * @return {Void} void */ value: function componentWillUnmount() { - try { - this.onComponentWillUnmount(); - } catch (e) { - console.warn('something may be wrong in\n "onComponentWillUnmount"', e); + if (this.onComponentWillUnmount) { + try { + this.onComponentWillUnmount(); + } catch (e) { + console.warn('something may be wrong in "onComponentWillUnmount"', e); + } } this.removeListeners(); @@ -4201,10 +4255,12 @@ var Flounder = function () { value: function fuzzySearch(e) { this.fuzzySearch.previousValue = this.fuzzySearch.previousValue || ''; - try { - this.onInputChange(e); - } catch (e) { - console.warn('something may be wrong in "onInputChange"', e); + if (this.onInputChange) { + try { + this.onInputChange(e); + } catch (e) { + console.warn('something may be wrong in "onInputChange"', e); + } } if (!this.toggleList.justOpened) { @@ -4214,7 +4270,7 @@ var Flounder = function () { if (keyCode !== _keycodes2.default.UP && keyCode !== _keycodes2.default.DOWN && keyCode !== _keycodes2.default.ENTER && keyCode !== _keycodes2.default.ESCAPE) { if (this.multipleTags && keyCode === _keycodes2.default.BACKSPACE && this.fuzzySearch.previousValue === '') { - var lastTag = nativeSlice.call(this.refs.multiTagWrapper.children, 0, -1).pop(); + var lastTag = this.refs.search.previousSibling; if (lastTag) { setTimeout(function () { @@ -4285,10 +4341,12 @@ var Flounder = function () { this.search = new _search2.default(this); } - try { - this.onInit(); - } catch (e) { - console.warn('something may be wrong in "onInit"', e); + if (this.onInit) { + try { + this.onInit(); + } catch (e) { + console.warn('something may be wrong in "onInit"', e); + } } this.buildDom(); @@ -4303,10 +4361,12 @@ var Flounder = function () { this.multiSelect = multiSelect; this.onRender(); - try { - this.onComponentDidMount(); - } catch (e) { - console.warn('something may be wrong in onComponentDidMount', e); + if (this.onComponentDidMount) { + try { + this.onComponentDidMount(); + } catch (e) { + console.warn('something may be wrong in onComponentDidMount', e); + } } this.ready = true; @@ -4941,6 +5001,36 @@ var utils = { }, + /** + * ## debounce + * + * debounces a function using the specified delay + * + * @param {Function} func function to be debounced + * @param {Number} wait debounce delay + * @param {Object} context context for debounced funtion execution + * + * @return {Void} void + */ + debounce: function debounce(func, wait) { + var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this; + + var args = void 0; + var timeout = void 0; + + var debounced = function debounced() { + return func.apply(context, args); + }; + + return function () { + clearTimeout(timeout); + + args = arguments; + timeout = setTimeout(debounced, wait); + }; + }, + + /** * ## extendClass * @@ -5137,26 +5227,32 @@ var utils = { * * checks if an option is visible and, if it is not, scrolls it into view * - * @param {DOMElement} element element to check + * @param {DOMElement} element element to check + * @param {DOMElement} [scrollParent] parent element to scroll * * @return {Void} void */ - scrollTo: function scrollTo(element) { + scrollTo: function scrollTo(element, scrollParent) { if (element) { - var parent = element.parentNode.parentNode; - var elHeight = element.offsetHeight; - var min = parent.scrollTop; - var max = parent.scrollTop + parent.offsetHeight - elHeight; - var pos = element.offsetTop; - - if (pos < min) { - parent.scrollTop = pos - elHeight * 0.5; - } else if (pos > max) { - parent.scrollTop = pos - parent.offsetHeight + elHeight * 1.5; + var scrollElement = scrollParent || element.offsetParent; + + if (scrollElement.scrollHeight > scrollElement.offsetHeight) { + var pos = element.offsetTop; + var elHeight = element.offsetHeight; + var contHeight = scrollElement.offsetHeight; + + var min = scrollElement.scrollTop; + var max = min + scrollElement.offsetHeight - elHeight; + + if (pos < min) { + scrollElement.scrollTop = pos; + } else if (pos > max) { + scrollElement.scrollTop = pos - (contHeight - elHeight); + } } - } else { - return false; } + + return false; }, @@ -5202,7 +5298,7 @@ var utils = { utils.addClass(_el, _class); } } -}; /* globals document, window, setTimeout*/ +}; /* globals clearTimeout, document, setTimeout, window */ (0, _http2.default)(utils); @@ -5213,7 +5309,7 @@ exports.default = utils; 'use strict'; /* globals module */ -module.exports = '1.2.3'; +module.exports = '1.3.0'; },{}],22:[function(require,module,exports){ 'use strict'; diff --git a/dist/flounder.amd.min.js b/dist/flounder.amd.min.js index 1084111..2f5523c 100644 --- a/dist/flounder.amd.min.js +++ b/dist/flounder.amd.min.js @@ -1,2 +1,2 @@ -/*! Flounder v1.2.3 | (c) 2015-2017 Sociomantic Labs | https://github.com/sociomantic-tsunami/flounder/license */!function e(t,n,s){function r(a,o){if(!n[a]){if(!t[a]){var l="function"==typeof require&&require;if(!o&&l)return l(a,!0);if(i)return i(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 r(n?n:e)},c,c.exports,e,t,n,s)}return n[a].exports}for(var i="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"],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=Array.prototype.slice,u={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){var t=this;if(this.removeSelectedClass(),this.removeSelectedValue(),this.multiple){var n=this.refs.multiTagWrapper;if(n){var s=l.call(n.children,0,-1);s.forEach(function(n,r){var i=r===s.length-1;!e&&i?(n=n.children,n=n[0],n.click()):(n.removeEventListener("click",t.removeMultiTag),n.remove())}),this.addPlaceholder()}}},disable:function(e){var t=this.refs,n=this.classes,s=t.flounder,r=t.selected;e?(t.flounder.removeEventListener("keydown",this.checkFlounderKeypress),t.selected.removeEventListener("click",this.toggleList),a["default"].addClass(r,n.DISABLED),a["default"].addClass(s,n.DISABLED)):(t.flounder.addEventListener("keydown",this.checkFlounderKeypress),t.selected.addEventListener("click",this.toggleList),a["default"].removeClass(r,n.DISABLED),a["default"].removeClass(s,n.DISABLED))},disableByIndex:function c(e,t){var n=this.refs;if("string"!=typeof e&&e.length){var c=this.disableByIndex.bind(this);return e.map(function(e){return c(e,t)})}var s=n.data,r=s.length;e<0&&(r=s.length,e=r+e);var i=s[e];if(i){var o=n.selectOptions[e],l=this.classes;return t?(o.disabled=!1,a["default"].removeClass(i,l.DISABLED)):(o.disabled=!0,a["default"].addClass(i,l.DISABLED)),[i,o]}console.warn("Flounder - No element to disable.")},disableByText:function d(e,t){if("string"!=typeof e&&e.length){var d=this.disableByText.bind(this),n=e.map(function(e){return d(e,t)});return 1===n.length?n[0]:n}var s=[];return this.refs.data.forEach(function(t,n){var r=t.innerHTML;r===e&&s.push(n)}),s=1===s.length?s[0]:s,this.disableByIndex(s,t)},disableByValue:function f(e,t){if("string"!=typeof e&&e.length){var f=this.disableByValue.bind(this),n=e.map(function(e){return f(e,t)});return 1===n.length?n[0]:n}var s=this.refs.selectOptions.map(function(t,n){return""+t.value==""+e?n:null}).filter(function(e){return!!e||0===e});return s=1===s.length?s[0]:s,this.disableByIndex(s,t)},enableByIndex:function(e){return this.disableByIndex(e,!0)},enableByText:function(e){return this.disableByText(e,!0)},enableByValue:function(e){this.disableByValue(e,!0)},getData:function(e){var t=this,n=this.refs;return"number"==typeof e?{option:n.selectOptions[e],div:n.data[e]}:e&&e.length&&"string"!=typeof e?e.map(function(e){return t.getData(e)}):e?void console.warn("Flounder - Illegal parameter type."):n.selectOptions.map(function(e,n){return t.getData(n)})},getSelected:function(){var e=this.refs.select,t=[],n=e.options,s=this.classes;return l.call(n).forEach(function(e){e.selected&&!a["default"].hasClass(e,s.PLACEHOLDER)&&t.push(e)}),t},getSelectedValues:function(){return this.getSelected().map(function(e){return e.value})},loadDataFromUrl:function(e,t){var n=this,s=this.classes;return a["default"].http.get(e).then(function(e){e?(n.data=JSON.parse(e),t&&t(n.data)):console.warn("no data recieved")})["catch"](function(e){console.warn("something happened: ",e),n.rebuild([{text:"",value:"",index:0,extraClass:s.LOADING_FAILED}])}),[{text:"",value:"",index:0,extraClass:s.LOADING}]},rebuild:function(e,t){if(t||!t&&("string"==typeof e||e&&"number"!=typeof e.length))return this.reconfigure(e,t);e=this.data=e||this.data,t=this.props;var n=this.refs,s=n.select;this.deselectAll(),this.removeOptionsListeners(),n.select.innerHTML="",n.select=!1,this.defaultObj=(0,o.setDefaultOption)(this,t,e,!0),n.optionsList.innerHTML="";var i=this.buildData(this.defaultObj,this.data,n.optionsList,s),a=r(i,3);return n.data=a[0],n.selectOptions=a[1],n.sections=a[2],n.select=s,this.addOptionsListeners(),this.data=e,this.displaySelected(n.selected,n),this},setByIndex:function h(e,t){var n=!(arguments.length>2&&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 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 p(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof e&&e.length){var p=this.setByText.bind(this);return e.map(function(e){return p(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 v(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof e&&e.length){var v=this.setByValue.bind(this);return e.map(function(e){return v(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"]=u},{"./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=Array.prototype.slice,u={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=n({className:t.SELECTED_DISPLAYED,"data-value":d.value,"data-index":d.index}),h=this.multipleTags?n({className:t.MULTI_TAG_LIST}):null,p=n({className:t.OPTIONS_WRAPPER+" "+t.HIDDEN}),v=n({className:t.LIST});v.setAttribute("role","listbox"),p.appendChild(v),this.multiple===!0&&(u.setAttribute("multiple",""),v.setAttribute("aria-multiselectable","true"));var g=this.buildArrow(e,n);[f,h,p,g].forEach(function(e){e&&l.appendChild(e)});var m=this.addSearch(this.multipleTags?h:l),y=this.buildData(d,c,v,u);c=y[0];var E=y[1],C=y[2];if(this.target.appendChild(s),this.refs={wrapper:s,flounder:l,selected:f,arrow:g,optionsListWrapper:p,search:m,multiTagWrapper:h,optionsList:v,select:u,data:c,sections:C,selectOptions:E},this.multipleTags){var T=this.getSelected();0===T.length?f.innerHTML=d.text:this.displayMultipleTags(T,h)}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 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.call(t.children,0).forEach(function(e){a.push(e),i.push({text:e.innerHTML,value:e.value})}),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),this.originalChildren.forEach(function(t){e.appendChild(t)})},popOutSelectElements:function(e){var t=[];this.originalChildren=l.call(e.children,0);var n=this.originalChildren;n.forEach(function(n,s){t[s]=n.cloneNode(!0),e.removeChild(n)}),t.forEach(function(t){e.appendChild(t)})},reconfigure:function(e,t){return e&&"string"!=typeof e&&"number"==typeof e.length?(t=t=t||this.props,t.data=e):t||"object"!==("undefined"==typeof e?"undefined":r(e))?(t=t||{},t.data=t.data||this.data):(t=e,t.data=t.data||this.data),this.constructor(this.originalTarget,t)},setTarget:function(e){if(e=1===e.nodeType?e:document.querySelector(e),this.originalTarget=e,e.flounder=this,"INPUT"===e.tagName){var t=this.classes;o["default"].addClass(e,t.HIDDEN),e.setAttribute("aria-hidden",!0),e.tabIndex=-1,e=e.parentNode}this.target=e}};n["default"]=u},{"./defaults":15,"./utils":20}],14:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var s={ARROW:"flounder__arrow--wrapper",ARROW_INNER:"flounder__arrow--inner",DESCRIPTION:"flounder__option--description",DISABLED:"flounder__disabled",DISABLED_OPTION:"flounder__disabled--option",HEADER:"flounder__header",HIDDEN:"flounder--hidden",HIDDEN_IOS:"flounder--hidden--ios",HOVER:"flounder__hover",LIST:"flounder__list",LOADING:"flounder__loading",LOADING_FAILED:"flounder__loading--failed",MAIN:"flounder",MAIN_WRAPPER:"flounder--wrapper flounder__input--select",MULTIPLE_TAG_FLOUNDER:"flounder--multiple",MULTI_TAG_LIST:"flounder__multi--tag--list",MULTIPLE_SELECT_TAG:"flounder__multiple--select--tag",MULTIPLE_TAG_CLOSE:"flounder__multiple__tag__close",NO_RESULTS:"flounder__no-results",OPEN:"open",OPTION:"flounder__option",OPTION_TAG:"flounder--option--tag",OPTIONS_WRAPPER:"flounder__list--wrapper",PLACEHOLDER:"flounder__placeholder",PLUG:"flounder__ios--plug",SECTION:"flounder__section",SELECTED:"flounder__option--selected",SELECTED_HIDDEN:"flounder__option--selected--hidden",SELECTED_DISPLAYED:"flounder__option--selected--displayed",SEARCH:"flounder__input--search",SEARCH_HIDDEN:"flounder--search--hidden",SELECT_TAG:"flounder--select--tag"};n["default"]=s},{}],15:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0}),n.setDefaultOption=n.defaultOptions=void 0;var r=e("./utils"),i=s(r),a=e("./classes"),o=s(a),l=n.defaultOptions={allowHTML:!1,classes:o["default"],data:[],defaultEmpty:!1,defaultIndex:!1,defaultValue:!1,disableArrow:!1,keepChangesOnDestroy:!1,multiple:!1,multipleTags:!1,multipleMessage:"(Multiple Items Selected)",noMoreOptionsMessage:"No more options to add.",noMoreResultsMessage:"No matches found",onChange:function(e,t){},onClose:function(e,t){},onComponentDidMount:function(){},onComponentWillUnmount:function(){},onFirstTouch:function(e){},onInit:function(){},onInputChange:function(e){},onOpen:function(e,t){},openOnHover:!1,placeholder:"Please choose an option",search:!1,selectDataOverride:!1},u={defaultOptions:l,setDefaultOption:function(e){function t(e,t){var n=t||0===t?t:a.defaultIndex,s=e[n];return s?(s.index=n,s):null}function n(e){var t=e.refs,n=e.classes,s=t.select,r=a.placeholder,u={text:r||""===r?r:l.placeholder,value:"",index:0,extraClass:n.HIDDEN+" "+n.PLACEHOLDER};if(s){var c=e.allowHTML?u.text:i["default"].escapeHTML(u.text),d=i["default"].constructElement({tagname:"option",className:n.OPTION_TAG,value:u.value});d.innerHTML=c,s.insertBefore(d,s[0]),e.refs.selectOptions.unshift(d)}return o.unshift(u),u}function s(e,t){var n=t||""+a.defaultValue,s=void 0;e.forEach(function(e,t){var r=""+e.value;r===n&&(s=t)});var r=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=Array.prototype.slice,u={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});var s=l.call(t.children,0,-1);s.forEach(function(e){var t=e.firstChild;t.addEventListener("click",n.removeMultiTag),e.addEventListener("keydown",n.checkMultiTagKeydown)})},addOptionsListeners:function(){var e=this;this.refs.data.forEach(function(t){"DIV"===t.tagName&&(t.addEventListener("mouseenter",e.addHoverClass),t.addEventListener("mouseleave",e.removeHoverClass),t.addEventListener("click",e.clickSet))})},addNoMoreOptionsMessage:function(){var e=this.classes,t={className:e.OPTION+" "+e.NO_RESULTS},n=this.refs.noMoreOptionsEl||i["default"].constructElement(t);n.innerHTML=this.noMoreOptionsMessage,this.refs.optionsList.appendChild(n),this.refs.noMoreOptionsEl=n},addNoResultsMessage:function(){var e=this.classes,t={className:e.OPTION+" "+e.NO_RESULTS},n=this.refs.noResultsEl||i["default"].constructElement(t);n.innerHTML=this.noMoreResultsMessage,this.refs.optionsList.appendChild(n),this.refs.noResultsEl=n},addPlaceholder:function(){var e=this.getSelectedValues(),t=e[0],n=this.getSelected(),s=n.length?n[0].innerHTML:"",r=e.length,i=this.refs.selected;switch(r){case 0:this.setByIndex(0);break;case 1:i.innerHTML=s;break;default:i.innerHTML=this.multipleMessage}this.multipleTags&&(0===r&&this.setByIndex(0),t&&""!==t?i.innerHTML="":i.innerHTML=this.placeholder)},addSearchListeners:function(){var e=this.refs.search,t=this.refs.multiTagWrapper;t&&t.addEventListener("click",this.toggleListSearchClick),e.addEventListener("click",this.toggleListSearchClick),e.addEventListener("focus",this.toggleListSearchClick),e.addEventListener("keyup",this.fuzzySearch),e.addEventListener("focus",this.clearPlaceholder)},addSelectKeyListener:function(){var e=this.refs.select;if(e.addEventListener("keyup",this.setSelectValue),e.addEventListener("keydown",this.setKeypress),this.isIos){var t=this.classes,n=e.children[0],s=document.createElement("OPTION");s.disabled=!0,s.setAttribute("disabled",!0),s.className=t.PLUG,e.insertBefore(s,n)}},catchBodyClick:function(e){this.checkClickTarget(e)||(this.toggleList(e),this.addPlaceholder())},checkClickTarget:function(e,t){return t=t||e.target,t!==document&&(t===this.refs.flounder||(t=t.parentNode,!!t&&this.checkClickTarget(e,t)))},checkEnterOnSearch:function(e,t){var n=e.target.value;if(n&&""!==n){var s=[],r=this.getSelected(),i=this.search.isThereAnythingRelatedTo(n);i.forEach(function(e){var n=e.i;e=t.selectOptions[n],r.indexOf(e)===-1&&s.push(e)});var a=-1;if(1===s.length)a=0;else if(s.length>1)for(var o=0;o=48&&t<=57||t>=65&&t<=90)&&n.search&&"INPUT"===e.target.tagName&&(n.selected.innerHTML="")},checkMultiTagKeydown:function(e){function t(){setTimeout(function(){return r.search.focus()},0),s.clearPlaceholder(),s.toggleListSearchClick(e)}var n=e.keyCode,s=this,r=this.refs,i=l.call(r.multiTagWrapper.children,0,-1),a=e.target,u=i.indexOf(a);n===o["default"].LEFT||n===o["default"].RIGHT||n===o["default"].BACKSPACE?(e.preventDefault(),e.stopPropagation(),n===o["default"].BACKSPACE?s.checkMultiTagKeydownRemove(a,t,u):s.checkMultiTagKeydownNavigate(t,n,u)):e.key.length<2&&t()},checkMultiTagKeydownNavigate:function(e,t,n){var s=l.call(this.refs.multiTagWrapper.children,0,-1),r=t-38,i=n+r,a=s.length-1;i>a?e():i>=0&&setTimeout(function(){return s[i].focus()},0)},checkMultiTagKeydownRemove:function(e,t,n){var s=l.call(this.refs.multiTagWrapper.children,0,-1),r=s.length-1;e.firstChild.click(),r>0?setTimeout(function(){return s[0===n?0:n-1].focus()},0):t()},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){var n=this,s=l.call(t.children,0,-1);s.forEach(function(e){var s=e.firstChild;s.removeEventListener("click",n.removeMultiTag),e.removeEventListener("keydown",n.checkMultiTagKeydown),t.removeChild(e)}),e.length>0?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;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 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))},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.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)}this.search?setTimeout(function(){return n.search.focus()},0):(this.addSelectKeyListener(),setTimeout(function(){return n.select.focus()},0));var u=n.data.length;if(this.props.placeholder&&u--,n.multiTagWrapper){var c=l.call(n.multiTagWrapper.children,0,-1);c.length===u&&(this.removeNoResultsMessage(),this.addNoMoreOptionsMessage())}if(this.ready)try{this.onOpen(e,this.getSelectedValues())}catch(e){console.warn('something may be wrong in "onOpen"',e)}}};n["default"]=u},{"./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(){try{this.onComponentWillUnmount()}catch(e){console.warn('something may be wrong in\n "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){this.fuzzySearch.previousValue=this.fuzzySearch.previousValue||"";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=S.call(this.refs.multiTagWrapper.children,0,-1).pop();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){this.props=t,this.bindThis(),this.initializeOptions(),this.setTarget(e),this.search&&(this.search=new y["default"](this));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;this.isOsx=r,this.isIos=i,this.multiSelect=a,this.onRender();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}();b.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 b(e,t)})},Object.defineProperty(b,"version",{get:function(){return C["default"]}}),Object.defineProperty(b.prototype,"version",{get:function(){return C["default"]}}),c["default"].extendClass(b,f["default"],p["default"],g["default"]),n["default"]=b},{"./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},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){if(!e)return!1;var t=e.parentNode.parentNode,n=e.offsetHeight,s=t.scrollTop,r=t.scrollTop+t.offsetHeight-n,i=e.offsetTop;ir&&(t.scrollTop=i-t.offsetHeight+1.5*n)},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.2.3"},{}],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);define("flounder",[],function(){return i["default"]})},{"../core/flounder":17}]},{},[22]); \ No newline at end of file +/*! 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 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 diff --git a/dist/flounder.jquery.js b/dist/flounder.jquery.js index 10a70d8..0653b75 100644 --- a/dist/flounder.jquery.js +++ b/dist/flounder.jquery.js @@ -1,12 +1,12 @@ /*! - * Flounder JavaScript Stylable Selectbox v1.2.3 + * Flounder JavaScript Stylable Selectbox v1.3.0 * 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 Sep 13 2017 + * Date: Wed Oct 11 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;o length) { - focusSearch(); - } else if (newIndex >= 0) { - setTimeout(function () { - return tags[newIndex].focus(); - }, 0); + if (next) { + setTimeout(function () { + return next.focus(); + }, 0); + } } }, @@ -3133,28 +3188,25 @@ var events = { /** * ## checkMultiTagKeydownRemove * - * after a backspece while a multitag is focused, this removes the tag and - * focus' on the next + * after a backspace while a multitag is focused, this removes the tag and + * focuses on the next * * @param {DOMElement} target focused multitag - * @param {Function} focusSearch function to focus on the search field - * @param {Number} index index of currently focused tag * * @return {Void} void */ - checkMultiTagKeydownRemove: function checkMultiTagKeydownRemove(target, focusSearch, index) { - var tags = nativeSlice.call(this.refs.multiTagWrapper.children, 0, -1); - - var siblings = tags.length - 1; + checkMultiTagKeydownRemove: function checkMultiTagKeydownRemove(target) { + var prev = target.previousSibling; + var next = target.nextSibling; target.firstChild.click(); - if (siblings > 0) { + if (prev) { setTimeout(function () { - return tags[index === 0 ? 0 : index - 1].focus(); + return prev.focus(); }, 0); - } else { - focusSearch(); + } else if (next) { + next.focus(); } }, @@ -3209,18 +3261,17 @@ var events = { * @return {Void} void */ displayMultipleTags: function displayMultipleTags(selectedOptions, multiTagWrapper) { - var _this3 = this; - - var tags = nativeSlice.call(multiTagWrapper.children, 0, -1); + var children = multiTagWrapper.children; - tags.forEach(function (tag) { + for (var i = 0; i < children.length - 1; i++) { + var tag = children[i]; var closeBtn = tag.firstChild; - closeBtn.removeEventListener('click', _this3.removeMultiTag); - tag.removeEventListener('keydown', _this3.checkMultiTagKeydown); + closeBtn.removeEventListener('click', this.removeMultiTag); + tag.removeEventListener('keydown', this.checkMultiTagKeydown); multiTagWrapper.removeChild(tag); - }); + } if (selectedOptions.length > 0) { this.addMultipleTags(selectedOptions, multiTagWrapper); @@ -3340,10 +3391,12 @@ var events = { firstTouchController: function firstTouchController(e) { var refs = this.refs; - try { - this.onFirstTouch(e); - } catch (e) { - console.warn('something may be wrong in "onFirstTouch"', e); + if (this.onFirstTouch) { + try { + this.onFirstTouch(e); + } catch (e) { + console.warn('something may be wrong in "onFirstTouch"', e); + } } refs.selected.removeEventListener('click', this.firstTouchController); @@ -3493,10 +3546,12 @@ var events = { selected.setAttribute('data-value', value); selected.setAttribute('data-index', index); - try { - this.onChange(e, this.getSelectedValues()); - } catch (e) { - console.warn('something may be wrong in "onChange"', e); + if (this.onChange) { + try { + this.onChange(e, this.getSelectedValues()); + } catch (e) { + console.warn('something may be wrong in "onChange"', e); + } } }, @@ -3567,7 +3622,7 @@ var events = { var search = this.refs.search; search.removeEventListener('click', this.toggleListSearchClick); search.removeEventListener('focus', this.toggleListSearchClick); - search.removeEventListener('keyup', this.fuzzySearch); + search.removeEventListener('keyup', this.debouncedFuzzySearch); search.removeEventListener('focus', this.clearPlaceholder); }, @@ -3755,7 +3810,7 @@ var events = { if (e || obj.type === 'blur' || !keyCode && obj.type === 'change' || keyCode && nonKeys.indexOf(keyCode) === -1) { if (this.toggleList.justOpened && !e) { this.toggleList.justOpened = false; - } else { + } else if (this.onChange) { try { this.onChange(e, this.getSelectedValues()); } catch (e) { @@ -3796,7 +3851,7 @@ var events = { _utils2.default.addClass(selectedOption, selectedClass); - _utils2.default.scrollTo(selectedOption); + _utils2.default.scrollTo(selectedOption, refs.optionsListWrapper); } }, @@ -3879,7 +3934,7 @@ var events = { }, 0); } - if (this.ready) { + if (this.onClose && this.ready) { try { this.onClose(e, this.getSelectedValues()); } catch (e) { @@ -3968,7 +4023,7 @@ var events = { var index = refs.select.selectedIndex; var selectedDiv = refs.data[index]; - _utils2.default.scrollTo(selectedDiv); + _utils2.default.scrollTo(selectedDiv, refs.optionsListWrapper); } if (this.search) { @@ -3989,15 +4044,15 @@ var events = { } if (refs.multiTagWrapper) { - var tags = nativeSlice.call(refs.multiTagWrapper.children, 0, -1); + var numTags = refs.multiTagWrapper.children.length - 1; - if (tags.length === optionCount) { + if (numTags === optionCount) { this.removeNoResultsMessage(); this.addNoMoreOptionsMessage(); } } - if (this.ready) { + if (this.onOpen && this.ready) { try { this.onOpen(e, this.getSelectedValues()); } catch (e) { @@ -4058,14 +4113,11 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -var nativeSlice = Array.prototype.slice; - /** * main flounder class * * @return {Object} Flounder instance */ - var Flounder = function () { _createClass(Flounder, [{ key: 'componentWillUnmount', @@ -4078,10 +4130,12 @@ var Flounder = function () { * @return {Void} void */ value: function componentWillUnmount() { - try { - this.onComponentWillUnmount(); - } catch (e) { - console.warn('something may be wrong in\n "onComponentWillUnmount"', e); + if (this.onComponentWillUnmount) { + try { + this.onComponentWillUnmount(); + } catch (e) { + console.warn('something may be wrong in "onComponentWillUnmount"', e); + } } this.removeListeners(); @@ -4201,10 +4255,12 @@ var Flounder = function () { value: function fuzzySearch(e) { this.fuzzySearch.previousValue = this.fuzzySearch.previousValue || ''; - try { - this.onInputChange(e); - } catch (e) { - console.warn('something may be wrong in "onInputChange"', e); + if (this.onInputChange) { + try { + this.onInputChange(e); + } catch (e) { + console.warn('something may be wrong in "onInputChange"', e); + } } if (!this.toggleList.justOpened) { @@ -4214,7 +4270,7 @@ var Flounder = function () { if (keyCode !== _keycodes2.default.UP && keyCode !== _keycodes2.default.DOWN && keyCode !== _keycodes2.default.ENTER && keyCode !== _keycodes2.default.ESCAPE) { if (this.multipleTags && keyCode === _keycodes2.default.BACKSPACE && this.fuzzySearch.previousValue === '') { - var lastTag = nativeSlice.call(this.refs.multiTagWrapper.children, 0, -1).pop(); + var lastTag = this.refs.search.previousSibling; if (lastTag) { setTimeout(function () { @@ -4285,10 +4341,12 @@ var Flounder = function () { this.search = new _search2.default(this); } - try { - this.onInit(); - } catch (e) { - console.warn('something may be wrong in "onInit"', e); + if (this.onInit) { + try { + this.onInit(); + } catch (e) { + console.warn('something may be wrong in "onInit"', e); + } } this.buildDom(); @@ -4303,10 +4361,12 @@ var Flounder = function () { this.multiSelect = multiSelect; this.onRender(); - try { - this.onComponentDidMount(); - } catch (e) { - console.warn('something may be wrong in onComponentDidMount', e); + if (this.onComponentDidMount) { + try { + this.onComponentDidMount(); + } catch (e) { + console.warn('something may be wrong in onComponentDidMount', e); + } } this.ready = true; @@ -4941,6 +5001,36 @@ var utils = { }, + /** + * ## debounce + * + * debounces a function using the specified delay + * + * @param {Function} func function to be debounced + * @param {Number} wait debounce delay + * @param {Object} context context for debounced funtion execution + * + * @return {Void} void + */ + debounce: function debounce(func, wait) { + var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this; + + var args = void 0; + var timeout = void 0; + + var debounced = function debounced() { + return func.apply(context, args); + }; + + return function () { + clearTimeout(timeout); + + args = arguments; + timeout = setTimeout(debounced, wait); + }; + }, + + /** * ## extendClass * @@ -5137,26 +5227,32 @@ var utils = { * * checks if an option is visible and, if it is not, scrolls it into view * - * @param {DOMElement} element element to check + * @param {DOMElement} element element to check + * @param {DOMElement} [scrollParent] parent element to scroll * * @return {Void} void */ - scrollTo: function scrollTo(element) { + scrollTo: function scrollTo(element, scrollParent) { if (element) { - var parent = element.parentNode.parentNode; - var elHeight = element.offsetHeight; - var min = parent.scrollTop; - var max = parent.scrollTop + parent.offsetHeight - elHeight; - var pos = element.offsetTop; - - if (pos < min) { - parent.scrollTop = pos - elHeight * 0.5; - } else if (pos > max) { - parent.scrollTop = pos - parent.offsetHeight + elHeight * 1.5; + var scrollElement = scrollParent || element.offsetParent; + + if (scrollElement.scrollHeight > scrollElement.offsetHeight) { + var pos = element.offsetTop; + var elHeight = element.offsetHeight; + var contHeight = scrollElement.offsetHeight; + + var min = scrollElement.scrollTop; + var max = min + scrollElement.offsetHeight - elHeight; + + if (pos < min) { + scrollElement.scrollTop = pos; + } else if (pos > max) { + scrollElement.scrollTop = pos - (contHeight - elHeight); + } } - } else { - return false; } + + return false; }, @@ -5202,7 +5298,7 @@ var utils = { utils.addClass(_el, _class); } } -}; /* globals document, window, setTimeout*/ +}; /* globals clearTimeout, document, setTimeout, window */ (0, _http2.default)(utils); @@ -5213,7 +5309,7 @@ exports.default = utils; 'use strict'; /* globals module */ -module.exports = '1.2.3'; +module.exports = '1.3.0'; },{}],22:[function(require,module,exports){ 'use strict'; diff --git a/dist/flounder.jquery.min.js b/dist/flounder.jquery.min.js index 17b7459..60b23d6 100644 --- a/dist/flounder.jquery.min.js +++ b/dist/flounder.jquery.min.js @@ -1,2 +1,2 @@ -/*! Flounder v1.2.3 | (c) 2015-2017 Sociomantic Labs | https://github.com/sociomantic-tsunami/flounder/license */!function e(t,n,s){function r(a,o){if(!n[a]){if(!t[a]){var l="function"==typeof require&&require;if(!o&&l)return l(a,!0);if(i)return i(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 r(n?n:e)},c,c.exports,e,t,n,s)}return n[a].exports}for(var i="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"],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=Array.prototype.slice,u={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){var t=this;if(this.removeSelectedClass(),this.removeSelectedValue(),this.multiple){var n=this.refs.multiTagWrapper;if(n){var s=l.call(n.children,0,-1);s.forEach(function(n,r){var i=r===s.length-1;!e&&i?(n=n.children,n=n[0],n.click()):(n.removeEventListener("click",t.removeMultiTag),n.remove())}),this.addPlaceholder()}}},disable:function(e){var t=this.refs,n=this.classes,s=t.flounder,r=t.selected;e?(t.flounder.removeEventListener("keydown",this.checkFlounderKeypress),t.selected.removeEventListener("click",this.toggleList),a["default"].addClass(r,n.DISABLED),a["default"].addClass(s,n.DISABLED)):(t.flounder.addEventListener("keydown",this.checkFlounderKeypress),t.selected.addEventListener("click",this.toggleList),a["default"].removeClass(r,n.DISABLED),a["default"].removeClass(s,n.DISABLED))},disableByIndex:function c(e,t){var n=this.refs;if("string"!=typeof e&&e.length){var c=this.disableByIndex.bind(this);return e.map(function(e){return c(e,t)})}var s=n.data,r=s.length;e<0&&(r=s.length,e=r+e);var i=s[e];if(i){var o=n.selectOptions[e],l=this.classes;return t?(o.disabled=!1,a["default"].removeClass(i,l.DISABLED)):(o.disabled=!0,a["default"].addClass(i,l.DISABLED)),[i,o]}console.warn("Flounder - No element to disable.")},disableByText:function d(e,t){if("string"!=typeof e&&e.length){var d=this.disableByText.bind(this),n=e.map(function(e){return d(e,t)});return 1===n.length?n[0]:n}var s=[];return this.refs.data.forEach(function(t,n){var r=t.innerHTML;r===e&&s.push(n)}),s=1===s.length?s[0]:s,this.disableByIndex(s,t)},disableByValue:function f(e,t){if("string"!=typeof e&&e.length){var f=this.disableByValue.bind(this),n=e.map(function(e){return f(e,t)});return 1===n.length?n[0]:n}var s=this.refs.selectOptions.map(function(t,n){return""+t.value==""+e?n:null}).filter(function(e){return!!e||0===e});return s=1===s.length?s[0]:s,this.disableByIndex(s,t)},enableByIndex:function(e){return this.disableByIndex(e,!0)},enableByText:function(e){return this.disableByText(e,!0)},enableByValue:function(e){this.disableByValue(e,!0)},getData:function(e){var t=this,n=this.refs;return"number"==typeof e?{option:n.selectOptions[e],div:n.data[e]}:e&&e.length&&"string"!=typeof e?e.map(function(e){return t.getData(e)}):e?void console.warn("Flounder - Illegal parameter type."):n.selectOptions.map(function(e,n){return t.getData(n)})},getSelected:function(){var e=this.refs.select,t=[],n=e.options,s=this.classes;return l.call(n).forEach(function(e){e.selected&&!a["default"].hasClass(e,s.PLACEHOLDER)&&t.push(e)}),t},getSelectedValues:function(){return this.getSelected().map(function(e){return e.value})},loadDataFromUrl:function(e,t){var n=this,s=this.classes;return a["default"].http.get(e).then(function(e){e?(n.data=JSON.parse(e),t&&t(n.data)):console.warn("no data recieved")})["catch"](function(e){console.warn("something happened: ",e),n.rebuild([{text:"",value:"",index:0,extraClass:s.LOADING_FAILED}])}),[{text:"",value:"",index:0,extraClass:s.LOADING}]},rebuild:function(e,t){if(t||!t&&("string"==typeof e||e&&"number"!=typeof e.length))return this.reconfigure(e,t);e=this.data=e||this.data,t=this.props;var n=this.refs,s=n.select;this.deselectAll(),this.removeOptionsListeners(),n.select.innerHTML="",n.select=!1,this.defaultObj=(0,o.setDefaultOption)(this,t,e,!0),n.optionsList.innerHTML="";var i=this.buildData(this.defaultObj,this.data,n.optionsList,s),a=r(i,3);return n.data=a[0],n.selectOptions=a[1],n.sections=a[2],n.select=s,this.addOptionsListeners(),this.data=e,this.displaySelected(n.selected,n),this},setByIndex:function h(e,t){var n=!(arguments.length>2&&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 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 p(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof e&&e.length){var p=this.setByText.bind(this);return e.map(function(e){return p(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 v(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof e&&e.length){var v=this.setByValue.bind(this);return e.map(function(e){return v(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"]=u},{"./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=Array.prototype.slice,u={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=n({className:t.SELECTED_DISPLAYED,"data-value":d.value,"data-index":d.index}),h=this.multipleTags?n({className:t.MULTI_TAG_LIST}):null,p=n({className:t.OPTIONS_WRAPPER+" "+t.HIDDEN}),v=n({className:t.LIST});v.setAttribute("role","listbox"),p.appendChild(v),this.multiple===!0&&(u.setAttribute("multiple",""),v.setAttribute("aria-multiselectable","true"));var g=this.buildArrow(e,n);[f,h,p,g].forEach(function(e){e&&l.appendChild(e)});var m=this.addSearch(this.multipleTags?h:l),y=this.buildData(d,c,v,u);c=y[0];var E=y[1],C=y[2];if(this.target.appendChild(s),this.refs={wrapper:s,flounder:l,selected:f,arrow:g,optionsListWrapper:p,search:m,multiTagWrapper:h,optionsList:v,select:u,data:c,sections:C,selectOptions:E},this.multipleTags){var T=this.getSelected();0===T.length?f.innerHTML=d.text:this.displayMultipleTags(T,h)}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 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.call(t.children,0).forEach(function(e){a.push(e),i.push({text:e.innerHTML,value:e.value})}),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),this.originalChildren.forEach(function(t){e.appendChild(t)})},popOutSelectElements:function(e){var t=[];this.originalChildren=l.call(e.children,0);var n=this.originalChildren;n.forEach(function(n,s){t[s]=n.cloneNode(!0),e.removeChild(n)}),t.forEach(function(t){e.appendChild(t)})},reconfigure:function(e,t){return e&&"string"!=typeof e&&"number"==typeof e.length?(t=t=t||this.props,t.data=e):t||"object"!==("undefined"==typeof e?"undefined":r(e))?(t=t||{},t.data=t.data||this.data):(t=e,t.data=t.data||this.data),this.constructor(this.originalTarget,t)},setTarget:function(e){if(e=1===e.nodeType?e:document.querySelector(e),this.originalTarget=e,e.flounder=this,"INPUT"===e.tagName){var t=this.classes;o["default"].addClass(e,t.HIDDEN),e.setAttribute("aria-hidden",!0),e.tabIndex=-1,e=e.parentNode}this.target=e}};n["default"]=u},{"./defaults":15,"./utils":20}],14:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var s={ARROW:"flounder__arrow--wrapper",ARROW_INNER:"flounder__arrow--inner",DESCRIPTION:"flounder__option--description",DISABLED:"flounder__disabled",DISABLED_OPTION:"flounder__disabled--option",HEADER:"flounder__header",HIDDEN:"flounder--hidden",HIDDEN_IOS:"flounder--hidden--ios",HOVER:"flounder__hover",LIST:"flounder__list",LOADING:"flounder__loading",LOADING_FAILED:"flounder__loading--failed",MAIN:"flounder",MAIN_WRAPPER:"flounder--wrapper flounder__input--select",MULTIPLE_TAG_FLOUNDER:"flounder--multiple",MULTI_TAG_LIST:"flounder__multi--tag--list",MULTIPLE_SELECT_TAG:"flounder__multiple--select--tag",MULTIPLE_TAG_CLOSE:"flounder__multiple__tag__close",NO_RESULTS:"flounder__no-results",OPEN:"open",OPTION:"flounder__option",OPTION_TAG:"flounder--option--tag",OPTIONS_WRAPPER:"flounder__list--wrapper",PLACEHOLDER:"flounder__placeholder",PLUG:"flounder__ios--plug",SECTION:"flounder__section",SELECTED:"flounder__option--selected",SELECTED_HIDDEN:"flounder__option--selected--hidden",SELECTED_DISPLAYED:"flounder__option--selected--displayed",SEARCH:"flounder__input--search",SEARCH_HIDDEN:"flounder--search--hidden",SELECT_TAG:"flounder--select--tag"};n["default"]=s},{}],15:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0}),n.setDefaultOption=n.defaultOptions=void 0;var r=e("./utils"),i=s(r),a=e("./classes"),o=s(a),l=n.defaultOptions={allowHTML:!1,classes:o["default"],data:[],defaultEmpty:!1,defaultIndex:!1,defaultValue:!1,disableArrow:!1,keepChangesOnDestroy:!1,multiple:!1,multipleTags:!1,multipleMessage:"(Multiple Items Selected)",noMoreOptionsMessage:"No more options to add.",noMoreResultsMessage:"No matches found",onChange:function(e,t){},onClose:function(e,t){},onComponentDidMount:function(){},onComponentWillUnmount:function(){},onFirstTouch:function(e){},onInit:function(){},onInputChange:function(e){},onOpen:function(e,t){},openOnHover:!1,placeholder:"Please choose an option",search:!1,selectDataOverride:!1},u={defaultOptions:l,setDefaultOption:function(e){function t(e,t){var n=t||0===t?t:a.defaultIndex,s=e[n];return s?(s.index=n,s):null}function n(e){var t=e.refs,n=e.classes,s=t.select,r=a.placeholder,u={text:r||""===r?r:l.placeholder,value:"",index:0,extraClass:n.HIDDEN+" "+n.PLACEHOLDER};if(s){var c=e.allowHTML?u.text:i["default"].escapeHTML(u.text),d=i["default"].constructElement({tagname:"option",className:n.OPTION_TAG,value:u.value});d.innerHTML=c,s.insertBefore(d,s[0]),e.refs.selectOptions.unshift(d)}return o.unshift(u),u}function s(e,t){var n=t||""+a.defaultValue,s=void 0;e.forEach(function(e,t){var r=""+e.value;r===n&&(s=t)});var r=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=Array.prototype.slice,u={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});var s=l.call(t.children,0,-1);s.forEach(function(e){var t=e.firstChild;t.addEventListener("click",n.removeMultiTag),e.addEventListener("keydown",n.checkMultiTagKeydown)})},addOptionsListeners:function(){var e=this;this.refs.data.forEach(function(t){"DIV"===t.tagName&&(t.addEventListener("mouseenter",e.addHoverClass),t.addEventListener("mouseleave",e.removeHoverClass),t.addEventListener("click",e.clickSet))})},addNoMoreOptionsMessage:function(){var e=this.classes,t={className:e.OPTION+" "+e.NO_RESULTS},n=this.refs.noMoreOptionsEl||i["default"].constructElement(t);n.innerHTML=this.noMoreOptionsMessage,this.refs.optionsList.appendChild(n),this.refs.noMoreOptionsEl=n},addNoResultsMessage:function(){var e=this.classes,t={className:e.OPTION+" "+e.NO_RESULTS},n=this.refs.noResultsEl||i["default"].constructElement(t);n.innerHTML=this.noMoreResultsMessage,this.refs.optionsList.appendChild(n),this.refs.noResultsEl=n},addPlaceholder:function(){var e=this.getSelectedValues(),t=e[0],n=this.getSelected(),s=n.length?n[0].innerHTML:"",r=e.length,i=this.refs.selected;switch(r){case 0:this.setByIndex(0);break;case 1:i.innerHTML=s;break;default:i.innerHTML=this.multipleMessage}this.multipleTags&&(0===r&&this.setByIndex(0),t&&""!==t?i.innerHTML="":i.innerHTML=this.placeholder)},addSearchListeners:function(){var e=this.refs.search,t=this.refs.multiTagWrapper;t&&t.addEventListener("click",this.toggleListSearchClick),e.addEventListener("click",this.toggleListSearchClick),e.addEventListener("focus",this.toggleListSearchClick),e.addEventListener("keyup",this.fuzzySearch),e.addEventListener("focus",this.clearPlaceholder)},addSelectKeyListener:function(){var e=this.refs.select;if(e.addEventListener("keyup",this.setSelectValue),e.addEventListener("keydown",this.setKeypress),this.isIos){var t=this.classes,n=e.children[0],s=document.createElement("OPTION");s.disabled=!0,s.setAttribute("disabled",!0),s.className=t.PLUG,e.insertBefore(s,n)}},catchBodyClick:function(e){this.checkClickTarget(e)||(this.toggleList(e),this.addPlaceholder())},checkClickTarget:function(e,t){return t=t||e.target,t!==document&&(t===this.refs.flounder||(t=t.parentNode,!!t&&this.checkClickTarget(e,t)))},checkEnterOnSearch:function(e,t){var n=e.target.value;if(n&&""!==n){var s=[],r=this.getSelected(),i=this.search.isThereAnythingRelatedTo(n);i.forEach(function(e){var n=e.i;e=t.selectOptions[n],r.indexOf(e)===-1&&s.push(e)});var a=-1;if(1===s.length)a=0;else if(s.length>1)for(var o=0;o=48&&t<=57||t>=65&&t<=90)&&n.search&&"INPUT"===e.target.tagName&&(n.selected.innerHTML="")},checkMultiTagKeydown:function(e){function t(){setTimeout(function(){return r.search.focus()},0),s.clearPlaceholder(),s.toggleListSearchClick(e)}var n=e.keyCode,s=this,r=this.refs,i=l.call(r.multiTagWrapper.children,0,-1),a=e.target,u=i.indexOf(a);n===o["default"].LEFT||n===o["default"].RIGHT||n===o["default"].BACKSPACE?(e.preventDefault(),e.stopPropagation(),n===o["default"].BACKSPACE?s.checkMultiTagKeydownRemove(a,t,u):s.checkMultiTagKeydownNavigate(t,n,u)):e.key.length<2&&t()},checkMultiTagKeydownNavigate:function(e,t,n){var s=l.call(this.refs.multiTagWrapper.children,0,-1),r=t-38,i=n+r,a=s.length-1;i>a?e():i>=0&&setTimeout(function(){return s[i].focus()},0)},checkMultiTagKeydownRemove:function(e,t,n){var s=l.call(this.refs.multiTagWrapper.children,0,-1),r=s.length-1;e.firstChild.click(),r>0?setTimeout(function(){return s[0===n?0:n-1].focus()},0):t()},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){var n=this,s=l.call(t.children,0,-1);s.forEach(function(e){var s=e.firstChild;s.removeEventListener("click",n.removeMultiTag),e.removeEventListener("keydown",n.checkMultiTagKeydown),t.removeChild(e)}),e.length>0?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;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 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))},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.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)}this.search?setTimeout(function(){return n.search.focus()},0):(this.addSelectKeyListener(),setTimeout(function(){return n.select.focus()},0));var u=n.data.length;if(this.props.placeholder&&u--,n.multiTagWrapper){var c=l.call(n.multiTagWrapper.children,0,-1);c.length===u&&(this.removeNoResultsMessage(),this.addNoMoreOptionsMessage())}if(this.ready)try{this.onOpen(e,this.getSelectedValues())}catch(e){console.warn('something may be wrong in "onOpen"',e)}}};n["default"]=u},{"./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(){try{this.onComponentWillUnmount()}catch(e){console.warn('something may be wrong in\n "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){this.fuzzySearch.previousValue=this.fuzzySearch.previousValue||"";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=S.call(this.refs.multiTagWrapper.children,0,-1).pop();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){this.props=t,this.bindThis(),this.initializeOptions(),this.setTarget(e),this.search&&(this.search=new y["default"](this));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;this.isOsx=r,this.isIos=i,this.multiSelect=a,this.onRender();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}();b.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 b(e,t)})},Object.defineProperty(b,"version",{get:function(){return C["default"]}}),Object.defineProperty(b.prototype,"version",{get:function(){return C["default"]}}),c["default"].extendClass(b,f["default"],p["default"],g["default"]),n["default"]=b},{"./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},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){if(!e)return!1;var t=e.parentNode.parentNode,n=e.offsetHeight,s=t.scrollTop,r=t.scrollTop+t.offsetHeight-n,i=e.offsetTop;ir&&(t.scrollTop=i-t.offsetHeight+1.5*n)},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.2.3"},{}],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.0 | (c) 2015-2017 Sociomantic Labs | https://github.com/sociomantic-tsunami/flounder/license */!function e(t,n,s){function r(a,o){if(!n[a]){if(!t[a]){var l="function"==typeof require&&require;if(!o&&l)return l(a,!0);if(i)return i(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 r(n?n:e)},c,c.exports,e,t,n,s)}return n[a].exports}for(var i="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"],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 diff --git a/dist/flounder.js b/dist/flounder.js index 1bec0a3..71c91a6 100644 --- a/dist/flounder.js +++ b/dist/flounder.js @@ -1,12 +1,12 @@ /*! - * Flounder JavaScript Stylable Selectbox v1.2.3 + * Flounder JavaScript Stylable Selectbox v1.3.0 * 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 Sep 13 2017 + * Date: Wed Oct 11 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;o length) { - focusSearch(); - } else if (newIndex >= 0) { - setTimeout(function () { - return tags[newIndex].focus(); - }, 0); + if (next) { + setTimeout(function () { + return next.focus(); + }, 0); + } } }, @@ -3133,28 +3188,25 @@ var events = { /** * ## checkMultiTagKeydownRemove * - * after a backspece while a multitag is focused, this removes the tag and - * focus' on the next + * after a backspace while a multitag is focused, this removes the tag and + * focuses on the next * * @param {DOMElement} target focused multitag - * @param {Function} focusSearch function to focus on the search field - * @param {Number} index index of currently focused tag * * @return {Void} void */ - checkMultiTagKeydownRemove: function checkMultiTagKeydownRemove(target, focusSearch, index) { - var tags = nativeSlice.call(this.refs.multiTagWrapper.children, 0, -1); - - var siblings = tags.length - 1; + checkMultiTagKeydownRemove: function checkMultiTagKeydownRemove(target) { + var prev = target.previousSibling; + var next = target.nextSibling; target.firstChild.click(); - if (siblings > 0) { + if (prev) { setTimeout(function () { - return tags[index === 0 ? 0 : index - 1].focus(); + return prev.focus(); }, 0); - } else { - focusSearch(); + } else if (next) { + next.focus(); } }, @@ -3209,18 +3261,17 @@ var events = { * @return {Void} void */ displayMultipleTags: function displayMultipleTags(selectedOptions, multiTagWrapper) { - var _this3 = this; - - var tags = nativeSlice.call(multiTagWrapper.children, 0, -1); + var children = multiTagWrapper.children; - tags.forEach(function (tag) { + for (var i = 0; i < children.length - 1; i++) { + var tag = children[i]; var closeBtn = tag.firstChild; - closeBtn.removeEventListener('click', _this3.removeMultiTag); - tag.removeEventListener('keydown', _this3.checkMultiTagKeydown); + closeBtn.removeEventListener('click', this.removeMultiTag); + tag.removeEventListener('keydown', this.checkMultiTagKeydown); multiTagWrapper.removeChild(tag); - }); + } if (selectedOptions.length > 0) { this.addMultipleTags(selectedOptions, multiTagWrapper); @@ -3340,10 +3391,12 @@ var events = { firstTouchController: function firstTouchController(e) { var refs = this.refs; - try { - this.onFirstTouch(e); - } catch (e) { - console.warn('something may be wrong in "onFirstTouch"', e); + if (this.onFirstTouch) { + try { + this.onFirstTouch(e); + } catch (e) { + console.warn('something may be wrong in "onFirstTouch"', e); + } } refs.selected.removeEventListener('click', this.firstTouchController); @@ -3493,10 +3546,12 @@ var events = { selected.setAttribute('data-value', value); selected.setAttribute('data-index', index); - try { - this.onChange(e, this.getSelectedValues()); - } catch (e) { - console.warn('something may be wrong in "onChange"', e); + if (this.onChange) { + try { + this.onChange(e, this.getSelectedValues()); + } catch (e) { + console.warn('something may be wrong in "onChange"', e); + } } }, @@ -3567,7 +3622,7 @@ var events = { var search = this.refs.search; search.removeEventListener('click', this.toggleListSearchClick); search.removeEventListener('focus', this.toggleListSearchClick); - search.removeEventListener('keyup', this.fuzzySearch); + search.removeEventListener('keyup', this.debouncedFuzzySearch); search.removeEventListener('focus', this.clearPlaceholder); }, @@ -3755,7 +3810,7 @@ var events = { if (e || obj.type === 'blur' || !keyCode && obj.type === 'change' || keyCode && nonKeys.indexOf(keyCode) === -1) { if (this.toggleList.justOpened && !e) { this.toggleList.justOpened = false; - } else { + } else if (this.onChange) { try { this.onChange(e, this.getSelectedValues()); } catch (e) { @@ -3796,7 +3851,7 @@ var events = { _utils2.default.addClass(selectedOption, selectedClass); - _utils2.default.scrollTo(selectedOption); + _utils2.default.scrollTo(selectedOption, refs.optionsListWrapper); } }, @@ -3879,7 +3934,7 @@ var events = { }, 0); } - if (this.ready) { + if (this.onClose && this.ready) { try { this.onClose(e, this.getSelectedValues()); } catch (e) { @@ -3968,7 +4023,7 @@ var events = { var index = refs.select.selectedIndex; var selectedDiv = refs.data[index]; - _utils2.default.scrollTo(selectedDiv); + _utils2.default.scrollTo(selectedDiv, refs.optionsListWrapper); } if (this.search) { @@ -3989,15 +4044,15 @@ var events = { } if (refs.multiTagWrapper) { - var tags = nativeSlice.call(refs.multiTagWrapper.children, 0, -1); + var numTags = refs.multiTagWrapper.children.length - 1; - if (tags.length === optionCount) { + if (numTags === optionCount) { this.removeNoResultsMessage(); this.addNoMoreOptionsMessage(); } } - if (this.ready) { + if (this.onOpen && this.ready) { try { this.onOpen(e, this.getSelectedValues()); } catch (e) { @@ -4058,14 +4113,11 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -var nativeSlice = Array.prototype.slice; - /** * main flounder class * * @return {Object} Flounder instance */ - var Flounder = function () { _createClass(Flounder, [{ key: 'componentWillUnmount', @@ -4078,10 +4130,12 @@ var Flounder = function () { * @return {Void} void */ value: function componentWillUnmount() { - try { - this.onComponentWillUnmount(); - } catch (e) { - console.warn('something may be wrong in\n "onComponentWillUnmount"', e); + if (this.onComponentWillUnmount) { + try { + this.onComponentWillUnmount(); + } catch (e) { + console.warn('something may be wrong in "onComponentWillUnmount"', e); + } } this.removeListeners(); @@ -4201,10 +4255,12 @@ var Flounder = function () { value: function fuzzySearch(e) { this.fuzzySearch.previousValue = this.fuzzySearch.previousValue || ''; - try { - this.onInputChange(e); - } catch (e) { - console.warn('something may be wrong in "onInputChange"', e); + if (this.onInputChange) { + try { + this.onInputChange(e); + } catch (e) { + console.warn('something may be wrong in "onInputChange"', e); + } } if (!this.toggleList.justOpened) { @@ -4214,7 +4270,7 @@ var Flounder = function () { if (keyCode !== _keycodes2.default.UP && keyCode !== _keycodes2.default.DOWN && keyCode !== _keycodes2.default.ENTER && keyCode !== _keycodes2.default.ESCAPE) { if (this.multipleTags && keyCode === _keycodes2.default.BACKSPACE && this.fuzzySearch.previousValue === '') { - var lastTag = nativeSlice.call(this.refs.multiTagWrapper.children, 0, -1).pop(); + var lastTag = this.refs.search.previousSibling; if (lastTag) { setTimeout(function () { @@ -4285,10 +4341,12 @@ var Flounder = function () { this.search = new _search2.default(this); } - try { - this.onInit(); - } catch (e) { - console.warn('something may be wrong in "onInit"', e); + if (this.onInit) { + try { + this.onInit(); + } catch (e) { + console.warn('something may be wrong in "onInit"', e); + } } this.buildDom(); @@ -4303,10 +4361,12 @@ var Flounder = function () { this.multiSelect = multiSelect; this.onRender(); - try { - this.onComponentDidMount(); - } catch (e) { - console.warn('something may be wrong in onComponentDidMount', e); + if (this.onComponentDidMount) { + try { + this.onComponentDidMount(); + } catch (e) { + console.warn('something may be wrong in onComponentDidMount', e); + } } this.ready = true; @@ -4941,6 +5001,36 @@ var utils = { }, + /** + * ## debounce + * + * debounces a function using the specified delay + * + * @param {Function} func function to be debounced + * @param {Number} wait debounce delay + * @param {Object} context context for debounced funtion execution + * + * @return {Void} void + */ + debounce: function debounce(func, wait) { + var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this; + + var args = void 0; + var timeout = void 0; + + var debounced = function debounced() { + return func.apply(context, args); + }; + + return function () { + clearTimeout(timeout); + + args = arguments; + timeout = setTimeout(debounced, wait); + }; + }, + + /** * ## extendClass * @@ -5137,26 +5227,32 @@ var utils = { * * checks if an option is visible and, if it is not, scrolls it into view * - * @param {DOMElement} element element to check + * @param {DOMElement} element element to check + * @param {DOMElement} [scrollParent] parent element to scroll * * @return {Void} void */ - scrollTo: function scrollTo(element) { + scrollTo: function scrollTo(element, scrollParent) { if (element) { - var parent = element.parentNode.parentNode; - var elHeight = element.offsetHeight; - var min = parent.scrollTop; - var max = parent.scrollTop + parent.offsetHeight - elHeight; - var pos = element.offsetTop; - - if (pos < min) { - parent.scrollTop = pos - elHeight * 0.5; - } else if (pos > max) { - parent.scrollTop = pos - parent.offsetHeight + elHeight * 1.5; + var scrollElement = scrollParent || element.offsetParent; + + if (scrollElement.scrollHeight > scrollElement.offsetHeight) { + var pos = element.offsetTop; + var elHeight = element.offsetHeight; + var contHeight = scrollElement.offsetHeight; + + var min = scrollElement.scrollTop; + var max = min + scrollElement.offsetHeight - elHeight; + + if (pos < min) { + scrollElement.scrollTop = pos; + } else if (pos > max) { + scrollElement.scrollTop = pos - (contHeight - elHeight); + } } - } else { - return false; } + + return false; }, @@ -5202,7 +5298,7 @@ var utils = { utils.addClass(_el, _class); } } -}; /* globals document, window, setTimeout*/ +}; /* globals clearTimeout, document, setTimeout, window */ (0, _http2.default)(utils); @@ -5213,6 +5309,6 @@ exports.default = utils; 'use strict'; /* globals module */ -module.exports = '1.2.3'; +module.exports = '1.3.0'; },{}]},{},[17]); diff --git a/dist/flounder.microbe.js b/dist/flounder.microbe.js index 2f9d008..d64f074 100644 --- a/dist/flounder.microbe.js +++ b/dist/flounder.microbe.js @@ -1,12 +1,12 @@ /*! - * Flounder JavaScript Stylable Selectbox v1.2.3 + * Flounder JavaScript Stylable Selectbox v1.3.0 * 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 Sep 13 2017 + * Date: Wed Oct 11 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;o length) { - focusSearch(); - } else if (newIndex >= 0) { - setTimeout(function () { - return tags[newIndex].focus(); - }, 0); + if (next) { + setTimeout(function () { + return next.focus(); + }, 0); + } } }, @@ -3133,28 +3188,25 @@ var events = { /** * ## checkMultiTagKeydownRemove * - * after a backspece while a multitag is focused, this removes the tag and - * focus' on the next + * after a backspace while a multitag is focused, this removes the tag and + * focuses on the next * * @param {DOMElement} target focused multitag - * @param {Function} focusSearch function to focus on the search field - * @param {Number} index index of currently focused tag * * @return {Void} void */ - checkMultiTagKeydownRemove: function checkMultiTagKeydownRemove(target, focusSearch, index) { - var tags = nativeSlice.call(this.refs.multiTagWrapper.children, 0, -1); - - var siblings = tags.length - 1; + checkMultiTagKeydownRemove: function checkMultiTagKeydownRemove(target) { + var prev = target.previousSibling; + var next = target.nextSibling; target.firstChild.click(); - if (siblings > 0) { + if (prev) { setTimeout(function () { - return tags[index === 0 ? 0 : index - 1].focus(); + return prev.focus(); }, 0); - } else { - focusSearch(); + } else if (next) { + next.focus(); } }, @@ -3209,18 +3261,17 @@ var events = { * @return {Void} void */ displayMultipleTags: function displayMultipleTags(selectedOptions, multiTagWrapper) { - var _this3 = this; - - var tags = nativeSlice.call(multiTagWrapper.children, 0, -1); + var children = multiTagWrapper.children; - tags.forEach(function (tag) { + for (var i = 0; i < children.length - 1; i++) { + var tag = children[i]; var closeBtn = tag.firstChild; - closeBtn.removeEventListener('click', _this3.removeMultiTag); - tag.removeEventListener('keydown', _this3.checkMultiTagKeydown); + closeBtn.removeEventListener('click', this.removeMultiTag); + tag.removeEventListener('keydown', this.checkMultiTagKeydown); multiTagWrapper.removeChild(tag); - }); + } if (selectedOptions.length > 0) { this.addMultipleTags(selectedOptions, multiTagWrapper); @@ -3340,10 +3391,12 @@ var events = { firstTouchController: function firstTouchController(e) { var refs = this.refs; - try { - this.onFirstTouch(e); - } catch (e) { - console.warn('something may be wrong in "onFirstTouch"', e); + if (this.onFirstTouch) { + try { + this.onFirstTouch(e); + } catch (e) { + console.warn('something may be wrong in "onFirstTouch"', e); + } } refs.selected.removeEventListener('click', this.firstTouchController); @@ -3493,10 +3546,12 @@ var events = { selected.setAttribute('data-value', value); selected.setAttribute('data-index', index); - try { - this.onChange(e, this.getSelectedValues()); - } catch (e) { - console.warn('something may be wrong in "onChange"', e); + if (this.onChange) { + try { + this.onChange(e, this.getSelectedValues()); + } catch (e) { + console.warn('something may be wrong in "onChange"', e); + } } }, @@ -3567,7 +3622,7 @@ var events = { var search = this.refs.search; search.removeEventListener('click', this.toggleListSearchClick); search.removeEventListener('focus', this.toggleListSearchClick); - search.removeEventListener('keyup', this.fuzzySearch); + search.removeEventListener('keyup', this.debouncedFuzzySearch); search.removeEventListener('focus', this.clearPlaceholder); }, @@ -3755,7 +3810,7 @@ var events = { if (e || obj.type === 'blur' || !keyCode && obj.type === 'change' || keyCode && nonKeys.indexOf(keyCode) === -1) { if (this.toggleList.justOpened && !e) { this.toggleList.justOpened = false; - } else { + } else if (this.onChange) { try { this.onChange(e, this.getSelectedValues()); } catch (e) { @@ -3796,7 +3851,7 @@ var events = { _utils2.default.addClass(selectedOption, selectedClass); - _utils2.default.scrollTo(selectedOption); + _utils2.default.scrollTo(selectedOption, refs.optionsListWrapper); } }, @@ -3879,7 +3934,7 @@ var events = { }, 0); } - if (this.ready) { + if (this.onClose && this.ready) { try { this.onClose(e, this.getSelectedValues()); } catch (e) { @@ -3968,7 +4023,7 @@ var events = { var index = refs.select.selectedIndex; var selectedDiv = refs.data[index]; - _utils2.default.scrollTo(selectedDiv); + _utils2.default.scrollTo(selectedDiv, refs.optionsListWrapper); } if (this.search) { @@ -3989,15 +4044,15 @@ var events = { } if (refs.multiTagWrapper) { - var tags = nativeSlice.call(refs.multiTagWrapper.children, 0, -1); + var numTags = refs.multiTagWrapper.children.length - 1; - if (tags.length === optionCount) { + if (numTags === optionCount) { this.removeNoResultsMessage(); this.addNoMoreOptionsMessage(); } } - if (this.ready) { + if (this.onOpen && this.ready) { try { this.onOpen(e, this.getSelectedValues()); } catch (e) { @@ -4058,14 +4113,11 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -var nativeSlice = Array.prototype.slice; - /** * main flounder class * * @return {Object} Flounder instance */ - var Flounder = function () { _createClass(Flounder, [{ key: 'componentWillUnmount', @@ -4078,10 +4130,12 @@ var Flounder = function () { * @return {Void} void */ value: function componentWillUnmount() { - try { - this.onComponentWillUnmount(); - } catch (e) { - console.warn('something may be wrong in\n "onComponentWillUnmount"', e); + if (this.onComponentWillUnmount) { + try { + this.onComponentWillUnmount(); + } catch (e) { + console.warn('something may be wrong in "onComponentWillUnmount"', e); + } } this.removeListeners(); @@ -4201,10 +4255,12 @@ var Flounder = function () { value: function fuzzySearch(e) { this.fuzzySearch.previousValue = this.fuzzySearch.previousValue || ''; - try { - this.onInputChange(e); - } catch (e) { - console.warn('something may be wrong in "onInputChange"', e); + if (this.onInputChange) { + try { + this.onInputChange(e); + } catch (e) { + console.warn('something may be wrong in "onInputChange"', e); + } } if (!this.toggleList.justOpened) { @@ -4214,7 +4270,7 @@ var Flounder = function () { if (keyCode !== _keycodes2.default.UP && keyCode !== _keycodes2.default.DOWN && keyCode !== _keycodes2.default.ENTER && keyCode !== _keycodes2.default.ESCAPE) { if (this.multipleTags && keyCode === _keycodes2.default.BACKSPACE && this.fuzzySearch.previousValue === '') { - var lastTag = nativeSlice.call(this.refs.multiTagWrapper.children, 0, -1).pop(); + var lastTag = this.refs.search.previousSibling; if (lastTag) { setTimeout(function () { @@ -4285,10 +4341,12 @@ var Flounder = function () { this.search = new _search2.default(this); } - try { - this.onInit(); - } catch (e) { - console.warn('something may be wrong in "onInit"', e); + if (this.onInit) { + try { + this.onInit(); + } catch (e) { + console.warn('something may be wrong in "onInit"', e); + } } this.buildDom(); @@ -4303,10 +4361,12 @@ var Flounder = function () { this.multiSelect = multiSelect; this.onRender(); - try { - this.onComponentDidMount(); - } catch (e) { - console.warn('something may be wrong in onComponentDidMount', e); + if (this.onComponentDidMount) { + try { + this.onComponentDidMount(); + } catch (e) { + console.warn('something may be wrong in onComponentDidMount', e); + } } this.ready = true; @@ -4941,6 +5001,36 @@ var utils = { }, + /** + * ## debounce + * + * debounces a function using the specified delay + * + * @param {Function} func function to be debounced + * @param {Number} wait debounce delay + * @param {Object} context context for debounced funtion execution + * + * @return {Void} void + */ + debounce: function debounce(func, wait) { + var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this; + + var args = void 0; + var timeout = void 0; + + var debounced = function debounced() { + return func.apply(context, args); + }; + + return function () { + clearTimeout(timeout); + + args = arguments; + timeout = setTimeout(debounced, wait); + }; + }, + + /** * ## extendClass * @@ -5137,26 +5227,32 @@ var utils = { * * checks if an option is visible and, if it is not, scrolls it into view * - * @param {DOMElement} element element to check + * @param {DOMElement} element element to check + * @param {DOMElement} [scrollParent] parent element to scroll * * @return {Void} void */ - scrollTo: function scrollTo(element) { + scrollTo: function scrollTo(element, scrollParent) { if (element) { - var parent = element.parentNode.parentNode; - var elHeight = element.offsetHeight; - var min = parent.scrollTop; - var max = parent.scrollTop + parent.offsetHeight - elHeight; - var pos = element.offsetTop; - - if (pos < min) { - parent.scrollTop = pos - elHeight * 0.5; - } else if (pos > max) { - parent.scrollTop = pos - parent.offsetHeight + elHeight * 1.5; + var scrollElement = scrollParent || element.offsetParent; + + if (scrollElement.scrollHeight > scrollElement.offsetHeight) { + var pos = element.offsetTop; + var elHeight = element.offsetHeight; + var contHeight = scrollElement.offsetHeight; + + var min = scrollElement.scrollTop; + var max = min + scrollElement.offsetHeight - elHeight; + + if (pos < min) { + scrollElement.scrollTop = pos; + } else if (pos > max) { + scrollElement.scrollTop = pos - (contHeight - elHeight); + } } - } else { - return false; } + + return false; }, @@ -5202,7 +5298,7 @@ var utils = { utils.addClass(_el, _class); } } -}; /* globals document, window, setTimeout*/ +}; /* globals clearTimeout, document, setTimeout, window */ (0, _http2.default)(utils); @@ -5213,7 +5309,7 @@ exports.default = utils; 'use strict'; /* globals module */ -module.exports = '1.2.3'; +module.exports = '1.3.0'; },{}],22:[function(require,module,exports){ 'use strict'; diff --git a/dist/flounder.microbe.min.js b/dist/flounder.microbe.min.js index 6e8005e..aa9a551 100644 --- a/dist/flounder.microbe.min.js +++ b/dist/flounder.microbe.min.js @@ -1,2 +1,2 @@ -/*! Flounder v1.2.3 | (c) 2015-2017 Sociomantic Labs | https://github.com/sociomantic-tsunami/flounder/license */!function e(t,n,s){function r(a,o){if(!n[a]){if(!t[a]){var l="function"==typeof require&&require;if(!o&&l)return l(a,!0);if(i)return i(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 r(n?n:e)},c,c.exports,e,t,n,s)}return n[a].exports}for(var i="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"],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=Array.prototype.slice,u={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){var t=this;if(this.removeSelectedClass(),this.removeSelectedValue(),this.multiple){var n=this.refs.multiTagWrapper;if(n){var s=l.call(n.children,0,-1);s.forEach(function(n,r){var i=r===s.length-1;!e&&i?(n=n.children,n=n[0],n.click()):(n.removeEventListener("click",t.removeMultiTag),n.remove())}),this.addPlaceholder()}}},disable:function(e){var t=this.refs,n=this.classes,s=t.flounder,r=t.selected;e?(t.flounder.removeEventListener("keydown",this.checkFlounderKeypress),t.selected.removeEventListener("click",this.toggleList),a["default"].addClass(r,n.DISABLED),a["default"].addClass(s,n.DISABLED)):(t.flounder.addEventListener("keydown",this.checkFlounderKeypress),t.selected.addEventListener("click",this.toggleList),a["default"].removeClass(r,n.DISABLED),a["default"].removeClass(s,n.DISABLED))},disableByIndex:function c(e,t){var n=this.refs;if("string"!=typeof e&&e.length){var c=this.disableByIndex.bind(this);return e.map(function(e){return c(e,t)})}var s=n.data,r=s.length;e<0&&(r=s.length,e=r+e);var i=s[e];if(i){var o=n.selectOptions[e],l=this.classes;return t?(o.disabled=!1,a["default"].removeClass(i,l.DISABLED)):(o.disabled=!0,a["default"].addClass(i,l.DISABLED)),[i,o]}console.warn("Flounder - No element to disable.")},disableByText:function d(e,t){if("string"!=typeof e&&e.length){var d=this.disableByText.bind(this),n=e.map(function(e){return d(e,t)});return 1===n.length?n[0]:n}var s=[];return this.refs.data.forEach(function(t,n){var r=t.innerHTML;r===e&&s.push(n)}),s=1===s.length?s[0]:s,this.disableByIndex(s,t)},disableByValue:function f(e,t){if("string"!=typeof e&&e.length){var f=this.disableByValue.bind(this),n=e.map(function(e){return f(e,t)});return 1===n.length?n[0]:n}var s=this.refs.selectOptions.map(function(t,n){return""+t.value==""+e?n:null}).filter(function(e){return!!e||0===e});return s=1===s.length?s[0]:s,this.disableByIndex(s,t)},enableByIndex:function(e){return this.disableByIndex(e,!0)},enableByText:function(e){return this.disableByText(e,!0)},enableByValue:function(e){this.disableByValue(e,!0)},getData:function(e){var t=this,n=this.refs;return"number"==typeof e?{option:n.selectOptions[e],div:n.data[e]}:e&&e.length&&"string"!=typeof e?e.map(function(e){return t.getData(e)}):e?void console.warn("Flounder - Illegal parameter type."):n.selectOptions.map(function(e,n){return t.getData(n)})},getSelected:function(){var e=this.refs.select,t=[],n=e.options,s=this.classes;return l.call(n).forEach(function(e){e.selected&&!a["default"].hasClass(e,s.PLACEHOLDER)&&t.push(e)}),t},getSelectedValues:function(){return this.getSelected().map(function(e){return e.value})},loadDataFromUrl:function(e,t){var n=this,s=this.classes;return a["default"].http.get(e).then(function(e){e?(n.data=JSON.parse(e),t&&t(n.data)):console.warn("no data recieved")})["catch"](function(e){console.warn("something happened: ",e),n.rebuild([{text:"",value:"",index:0,extraClass:s.LOADING_FAILED}])}),[{text:"",value:"",index:0,extraClass:s.LOADING}]},rebuild:function(e,t){if(t||!t&&("string"==typeof e||e&&"number"!=typeof e.length))return this.reconfigure(e,t);e=this.data=e||this.data,t=this.props;var n=this.refs,s=n.select;this.deselectAll(),this.removeOptionsListeners(),n.select.innerHTML="",n.select=!1,this.defaultObj=(0,o.setDefaultOption)(this,t,e,!0),n.optionsList.innerHTML="";var i=this.buildData(this.defaultObj,this.data,n.optionsList,s),a=r(i,3);return n.data=a[0],n.selectOptions=a[1],n.sections=a[2],n.select=s,this.addOptionsListeners(),this.data=e,this.displaySelected(n.selected,n),this},setByIndex:function h(e,t){var n=!(arguments.length>2&&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 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 p(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof e&&e.length){var p=this.setByText.bind(this);return e.map(function(e){return p(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 v(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof e&&e.length){var v=this.setByValue.bind(this);return e.map(function(e){return v(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"]=u},{"./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=Array.prototype.slice,u={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=n({className:t.SELECTED_DISPLAYED,"data-value":d.value,"data-index":d.index}),h=this.multipleTags?n({className:t.MULTI_TAG_LIST}):null,p=n({className:t.OPTIONS_WRAPPER+" "+t.HIDDEN}),v=n({className:t.LIST});v.setAttribute("role","listbox"),p.appendChild(v),this.multiple===!0&&(u.setAttribute("multiple",""),v.setAttribute("aria-multiselectable","true"));var g=this.buildArrow(e,n);[f,h,p,g].forEach(function(e){e&&l.appendChild(e)});var m=this.addSearch(this.multipleTags?h:l),y=this.buildData(d,c,v,u);c=y[0];var E=y[1],C=y[2];if(this.target.appendChild(s),this.refs={wrapper:s,flounder:l,selected:f,arrow:g,optionsListWrapper:p,search:m,multiTagWrapper:h,optionsList:v,select:u,data:c,sections:C,selectOptions:E},this.multipleTags){var T=this.getSelected();0===T.length?f.innerHTML=d.text:this.displayMultipleTags(T,h)}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 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.call(t.children,0).forEach(function(e){a.push(e),i.push({text:e.innerHTML,value:e.value})}),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),this.originalChildren.forEach(function(t){e.appendChild(t)})},popOutSelectElements:function(e){var t=[];this.originalChildren=l.call(e.children,0);var n=this.originalChildren;n.forEach(function(n,s){t[s]=n.cloneNode(!0),e.removeChild(n)}),t.forEach(function(t){e.appendChild(t)})},reconfigure:function(e,t){return e&&"string"!=typeof e&&"number"==typeof e.length?(t=t=t||this.props,t.data=e):t||"object"!==("undefined"==typeof e?"undefined":r(e))?(t=t||{},t.data=t.data||this.data):(t=e,t.data=t.data||this.data),this.constructor(this.originalTarget,t)},setTarget:function(e){if(e=1===e.nodeType?e:document.querySelector(e),this.originalTarget=e,e.flounder=this,"INPUT"===e.tagName){var t=this.classes;o["default"].addClass(e,t.HIDDEN),e.setAttribute("aria-hidden",!0),e.tabIndex=-1,e=e.parentNode}this.target=e}};n["default"]=u},{"./defaults":15,"./utils":20}],14:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var s={ARROW:"flounder__arrow--wrapper",ARROW_INNER:"flounder__arrow--inner",DESCRIPTION:"flounder__option--description",DISABLED:"flounder__disabled",DISABLED_OPTION:"flounder__disabled--option",HEADER:"flounder__header",HIDDEN:"flounder--hidden",HIDDEN_IOS:"flounder--hidden--ios",HOVER:"flounder__hover",LIST:"flounder__list",LOADING:"flounder__loading",LOADING_FAILED:"flounder__loading--failed",MAIN:"flounder",MAIN_WRAPPER:"flounder--wrapper flounder__input--select",MULTIPLE_TAG_FLOUNDER:"flounder--multiple",MULTI_TAG_LIST:"flounder__multi--tag--list",MULTIPLE_SELECT_TAG:"flounder__multiple--select--tag",MULTIPLE_TAG_CLOSE:"flounder__multiple__tag__close",NO_RESULTS:"flounder__no-results",OPEN:"open",OPTION:"flounder__option",OPTION_TAG:"flounder--option--tag",OPTIONS_WRAPPER:"flounder__list--wrapper",PLACEHOLDER:"flounder__placeholder",PLUG:"flounder__ios--plug",SECTION:"flounder__section",SELECTED:"flounder__option--selected",SELECTED_HIDDEN:"flounder__option--selected--hidden",SELECTED_DISPLAYED:"flounder__option--selected--displayed",SEARCH:"flounder__input--search",SEARCH_HIDDEN:"flounder--search--hidden",SELECT_TAG:"flounder--select--tag"};n["default"]=s},{}],15:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0}),n.setDefaultOption=n.defaultOptions=void 0;var r=e("./utils"),i=s(r),a=e("./classes"),o=s(a),l=n.defaultOptions={allowHTML:!1,classes:o["default"],data:[],defaultEmpty:!1,defaultIndex:!1,defaultValue:!1,disableArrow:!1,keepChangesOnDestroy:!1,multiple:!1,multipleTags:!1,multipleMessage:"(Multiple Items Selected)",noMoreOptionsMessage:"No more options to add.",noMoreResultsMessage:"No matches found",onChange:function(e,t){},onClose:function(e,t){},onComponentDidMount:function(){},onComponentWillUnmount:function(){},onFirstTouch:function(e){},onInit:function(){},onInputChange:function(e){},onOpen:function(e,t){},openOnHover:!1,placeholder:"Please choose an option",search:!1,selectDataOverride:!1},u={defaultOptions:l,setDefaultOption:function(e){function t(e,t){var n=t||0===t?t:a.defaultIndex,s=e[n];return s?(s.index=n,s):null}function n(e){var t=e.refs,n=e.classes,s=t.select,r=a.placeholder,u={text:r||""===r?r:l.placeholder,value:"",index:0,extraClass:n.HIDDEN+" "+n.PLACEHOLDER};if(s){var c=e.allowHTML?u.text:i["default"].escapeHTML(u.text),d=i["default"].constructElement({tagname:"option",className:n.OPTION_TAG,value:u.value});d.innerHTML=c,s.insertBefore(d,s[0]),e.refs.selectOptions.unshift(d)}return o.unshift(u),u}function s(e,t){var n=t||""+a.defaultValue,s=void 0;e.forEach(function(e,t){var r=""+e.value;r===n&&(s=t)});var r=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=Array.prototype.slice,u={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});var s=l.call(t.children,0,-1);s.forEach(function(e){var t=e.firstChild;t.addEventListener("click",n.removeMultiTag),e.addEventListener("keydown",n.checkMultiTagKeydown)})},addOptionsListeners:function(){var e=this;this.refs.data.forEach(function(t){"DIV"===t.tagName&&(t.addEventListener("mouseenter",e.addHoverClass),t.addEventListener("mouseleave",e.removeHoverClass),t.addEventListener("click",e.clickSet))})},addNoMoreOptionsMessage:function(){var e=this.classes,t={className:e.OPTION+" "+e.NO_RESULTS},n=this.refs.noMoreOptionsEl||i["default"].constructElement(t);n.innerHTML=this.noMoreOptionsMessage,this.refs.optionsList.appendChild(n),this.refs.noMoreOptionsEl=n},addNoResultsMessage:function(){var e=this.classes,t={className:e.OPTION+" "+e.NO_RESULTS},n=this.refs.noResultsEl||i["default"].constructElement(t);n.innerHTML=this.noMoreResultsMessage,this.refs.optionsList.appendChild(n),this.refs.noResultsEl=n},addPlaceholder:function(){var e=this.getSelectedValues(),t=e[0],n=this.getSelected(),s=n.length?n[0].innerHTML:"",r=e.length,i=this.refs.selected;switch(r){case 0:this.setByIndex(0);break;case 1:i.innerHTML=s;break;default:i.innerHTML=this.multipleMessage}this.multipleTags&&(0===r&&this.setByIndex(0),t&&""!==t?i.innerHTML="":i.innerHTML=this.placeholder)},addSearchListeners:function(){var e=this.refs.search,t=this.refs.multiTagWrapper;t&&t.addEventListener("click",this.toggleListSearchClick),e.addEventListener("click",this.toggleListSearchClick),e.addEventListener("focus",this.toggleListSearchClick),e.addEventListener("keyup",this.fuzzySearch),e.addEventListener("focus",this.clearPlaceholder)},addSelectKeyListener:function(){var e=this.refs.select;if(e.addEventListener("keyup",this.setSelectValue),e.addEventListener("keydown",this.setKeypress),this.isIos){var t=this.classes,n=e.children[0],s=document.createElement("OPTION");s.disabled=!0,s.setAttribute("disabled",!0),s.className=t.PLUG,e.insertBefore(s,n)}},catchBodyClick:function(e){this.checkClickTarget(e)||(this.toggleList(e),this.addPlaceholder())},checkClickTarget:function(e,t){return t=t||e.target,t!==document&&(t===this.refs.flounder||(t=t.parentNode,!!t&&this.checkClickTarget(e,t)))},checkEnterOnSearch:function(e,t){var n=e.target.value;if(n&&""!==n){var s=[],r=this.getSelected(),i=this.search.isThereAnythingRelatedTo(n);i.forEach(function(e){var n=e.i;e=t.selectOptions[n],r.indexOf(e)===-1&&s.push(e)});var a=-1;if(1===s.length)a=0;else if(s.length>1)for(var o=0;o=48&&t<=57||t>=65&&t<=90)&&n.search&&"INPUT"===e.target.tagName&&(n.selected.innerHTML="")},checkMultiTagKeydown:function(e){function t(){setTimeout(function(){return r.search.focus()},0),s.clearPlaceholder(),s.toggleListSearchClick(e)}var n=e.keyCode,s=this,r=this.refs,i=l.call(r.multiTagWrapper.children,0,-1),a=e.target,u=i.indexOf(a);n===o["default"].LEFT||n===o["default"].RIGHT||n===o["default"].BACKSPACE?(e.preventDefault(),e.stopPropagation(),n===o["default"].BACKSPACE?s.checkMultiTagKeydownRemove(a,t,u):s.checkMultiTagKeydownNavigate(t,n,u)):e.key.length<2&&t()},checkMultiTagKeydownNavigate:function(e,t,n){var s=l.call(this.refs.multiTagWrapper.children,0,-1),r=t-38,i=n+r,a=s.length-1;i>a?e():i>=0&&setTimeout(function(){return s[i].focus()},0)},checkMultiTagKeydownRemove:function(e,t,n){var s=l.call(this.refs.multiTagWrapper.children,0,-1),r=s.length-1;e.firstChild.click(),r>0?setTimeout(function(){return s[0===n?0:n-1].focus()},0):t()},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){var n=this,s=l.call(t.children,0,-1);s.forEach(function(e){var s=e.firstChild;s.removeEventListener("click",n.removeMultiTag),e.removeEventListener("keydown",n.checkMultiTagKeydown),t.removeChild(e)}),e.length>0?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;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 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))},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.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)}this.search?setTimeout(function(){return n.search.focus()},0):(this.addSelectKeyListener(),setTimeout(function(){return n.select.focus()},0));var u=n.data.length;if(this.props.placeholder&&u--,n.multiTagWrapper){var c=l.call(n.multiTagWrapper.children,0,-1);c.length===u&&(this.removeNoResultsMessage(),this.addNoMoreOptionsMessage())}if(this.ready)try{this.onOpen(e,this.getSelectedValues())}catch(e){console.warn('something may be wrong in "onOpen"',e)}}};n["default"]=u},{"./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(){try{this.onComponentWillUnmount()}catch(e){console.warn('something may be wrong in\n "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){this.fuzzySearch.previousValue=this.fuzzySearch.previousValue||"";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=S.call(this.refs.multiTagWrapper.children,0,-1).pop();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){this.props=t,this.bindThis(),this.initializeOptions(),this.setTarget(e),this.search&&(this.search=new y["default"](this));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;this.isOsx=r,this.isIos=i,this.multiSelect=a,this.onRender();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}();b.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 b(e,t)})},Object.defineProperty(b,"version",{get:function(){return C["default"]}}),Object.defineProperty(b.prototype,"version",{get:function(){return C["default"]}}),c["default"].extendClass(b,f["default"],p["default"],g["default"]),n["default"]=b},{"./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},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){if(!e)return!1;var t=e.parentNode.parentNode,n=e.offsetHeight,s=t.scrollTop,r=t.scrollTop+t.offsetHeight-n,i=e.offsetTop;ir&&(t.scrollTop=i-t.offsetHeight+1.5*n)},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.2.3"},{}],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.0 | (c) 2015-2017 Sociomantic Labs | https://github.com/sociomantic-tsunami/flounder/license */!function e(t,n,s){function r(a,o){if(!n[a]){if(!t[a]){var l="function"==typeof require&&require;if(!o&&l)return l(a,!0);if(i)return i(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 r(n?n:e)},c,c.exports,e,t,n,s)}return n[a].exports}for(var i="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"],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 diff --git a/dist/flounder.min.js b/dist/flounder.min.js index 3145c9a..922d9ea 100644 --- a/dist/flounder.min.js +++ b/dist/flounder.min.js @@ -1,2 +1,2 @@ -/*! Flounder v1.2.3 | (c) 2015-2017 Sociomantic Labs | https://github.com/sociomantic-tsunami/flounder/license */!function e(t,n,s){function r(a,o){if(!n[a]){if(!t[a]){var l="function"==typeof require&&require;if(!o&&l)return l(a,!0);if(i)return i(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 r(n?n:e)},c,c.exports,e,t,n,s)}return n[a].exports}for(var i="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"],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=Array.prototype.slice,u={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){var t=this;if(this.removeSelectedClass(),this.removeSelectedValue(),this.multiple){var n=this.refs.multiTagWrapper;if(n){var s=l.call(n.children,0,-1);s.forEach(function(n,r){var i=r===s.length-1;!e&&i?(n=n.children,n=n[0],n.click()):(n.removeEventListener("click",t.removeMultiTag),n.remove())}),this.addPlaceholder()}}},disable:function(e){var t=this.refs,n=this.classes,s=t.flounder,r=t.selected;e?(t.flounder.removeEventListener("keydown",this.checkFlounderKeypress),t.selected.removeEventListener("click",this.toggleList),a["default"].addClass(r,n.DISABLED),a["default"].addClass(s,n.DISABLED)):(t.flounder.addEventListener("keydown",this.checkFlounderKeypress),t.selected.addEventListener("click",this.toggleList),a["default"].removeClass(r,n.DISABLED),a["default"].removeClass(s,n.DISABLED))},disableByIndex:function c(e,t){var n=this.refs;if("string"!=typeof e&&e.length){var c=this.disableByIndex.bind(this);return e.map(function(e){return c(e,t)})}var s=n.data,r=s.length;e<0&&(r=s.length,e=r+e);var i=s[e];if(i){var o=n.selectOptions[e],l=this.classes;return t?(o.disabled=!1,a["default"].removeClass(i,l.DISABLED)):(o.disabled=!0,a["default"].addClass(i,l.DISABLED)),[i,o]}console.warn("Flounder - No element to disable.")},disableByText:function d(e,t){if("string"!=typeof e&&e.length){var d=this.disableByText.bind(this),n=e.map(function(e){return d(e,t)});return 1===n.length?n[0]:n}var s=[];return this.refs.data.forEach(function(t,n){var r=t.innerHTML;r===e&&s.push(n)}),s=1===s.length?s[0]:s,this.disableByIndex(s,t)},disableByValue:function f(e,t){if("string"!=typeof e&&e.length){var f=this.disableByValue.bind(this),n=e.map(function(e){return f(e,t)});return 1===n.length?n[0]:n}var s=this.refs.selectOptions.map(function(t,n){return""+t.value==""+e?n:null}).filter(function(e){return!!e||0===e});return s=1===s.length?s[0]:s,this.disableByIndex(s,t)},enableByIndex:function(e){return this.disableByIndex(e,!0)},enableByText:function(e){return this.disableByText(e,!0)},enableByValue:function(e){this.disableByValue(e,!0)},getData:function(e){var t=this,n=this.refs;return"number"==typeof e?{option:n.selectOptions[e],div:n.data[e]}:e&&e.length&&"string"!=typeof e?e.map(function(e){return t.getData(e)}):e?void console.warn("Flounder - Illegal parameter type."):n.selectOptions.map(function(e,n){return t.getData(n)})},getSelected:function(){var e=this.refs.select,t=[],n=e.options,s=this.classes;return l.call(n).forEach(function(e){e.selected&&!a["default"].hasClass(e,s.PLACEHOLDER)&&t.push(e)}),t},getSelectedValues:function(){return this.getSelected().map(function(e){return e.value})},loadDataFromUrl:function(e,t){var n=this,s=this.classes;return a["default"].http.get(e).then(function(e){e?(n.data=JSON.parse(e),t&&t(n.data)):console.warn("no data recieved")})["catch"](function(e){console.warn("something happened: ",e),n.rebuild([{text:"",value:"",index:0,extraClass:s.LOADING_FAILED}])}),[{text:"",value:"",index:0,extraClass:s.LOADING}]},rebuild:function(e,t){if(t||!t&&("string"==typeof e||e&&"number"!=typeof e.length))return this.reconfigure(e,t);e=this.data=e||this.data,t=this.props;var n=this.refs,s=n.select;this.deselectAll(),this.removeOptionsListeners(),n.select.innerHTML="",n.select=!1,this.defaultObj=(0,o.setDefaultOption)(this,t,e,!0),n.optionsList.innerHTML="";var i=this.buildData(this.defaultObj,this.data,n.optionsList,s),a=r(i,3);return n.data=a[0],n.selectOptions=a[1],n.sections=a[2],n.select=s,this.addOptionsListeners(),this.data=e,this.displaySelected(n.selected,n),this},setByIndex:function h(e,t){var n=!(arguments.length>2&&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 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 p(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof e&&e.length){var p=this.setByText.bind(this);return e.map(function(e){return p(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 v(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof e&&e.length){var v=this.setByValue.bind(this);return e.map(function(e){return v(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"]=u},{"./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=Array.prototype.slice,u={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=n({className:t.SELECTED_DISPLAYED,"data-value":d.value,"data-index":d.index}),h=this.multipleTags?n({className:t.MULTI_TAG_LIST}):null,p=n({className:t.OPTIONS_WRAPPER+" "+t.HIDDEN}),v=n({className:t.LIST});v.setAttribute("role","listbox"),p.appendChild(v),this.multiple===!0&&(u.setAttribute("multiple",""),v.setAttribute("aria-multiselectable","true"));var g=this.buildArrow(e,n);[f,h,p,g].forEach(function(e){e&&l.appendChild(e)});var m=this.addSearch(this.multipleTags?h:l),y=this.buildData(d,c,v,u);c=y[0];var E=y[1],C=y[2];if(this.target.appendChild(s),this.refs={wrapper:s,flounder:l,selected:f,arrow:g,optionsListWrapper:p,search:m,multiTagWrapper:h,optionsList:v,select:u,data:c,sections:C,selectOptions:E},this.multipleTags){var T=this.getSelected();0===T.length?f.innerHTML=d.text:this.displayMultipleTags(T,h)}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 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.call(t.children,0).forEach(function(e){a.push(e),i.push({text:e.innerHTML,value:e.value})}),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),this.originalChildren.forEach(function(t){e.appendChild(t)})},popOutSelectElements:function(e){var t=[];this.originalChildren=l.call(e.children,0);var n=this.originalChildren;n.forEach(function(n,s){t[s]=n.cloneNode(!0),e.removeChild(n)}),t.forEach(function(t){e.appendChild(t)})},reconfigure:function(e,t){return e&&"string"!=typeof e&&"number"==typeof e.length?(t=t=t||this.props,t.data=e):t||"object"!==("undefined"==typeof e?"undefined":r(e))?(t=t||{},t.data=t.data||this.data):(t=e,t.data=t.data||this.data),this.constructor(this.originalTarget,t)},setTarget:function(e){if(e=1===e.nodeType?e:document.querySelector(e),this.originalTarget=e,e.flounder=this,"INPUT"===e.tagName){var t=this.classes;o["default"].addClass(e,t.HIDDEN),e.setAttribute("aria-hidden",!0),e.tabIndex=-1,e=e.parentNode}this.target=e}};n["default"]=u},{"./defaults":15,"./utils":20}],14:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var s={ARROW:"flounder__arrow--wrapper",ARROW_INNER:"flounder__arrow--inner",DESCRIPTION:"flounder__option--description",DISABLED:"flounder__disabled",DISABLED_OPTION:"flounder__disabled--option",HEADER:"flounder__header",HIDDEN:"flounder--hidden",HIDDEN_IOS:"flounder--hidden--ios",HOVER:"flounder__hover",LIST:"flounder__list",LOADING:"flounder__loading",LOADING_FAILED:"flounder__loading--failed",MAIN:"flounder",MAIN_WRAPPER:"flounder--wrapper flounder__input--select",MULTIPLE_TAG_FLOUNDER:"flounder--multiple",MULTI_TAG_LIST:"flounder__multi--tag--list",MULTIPLE_SELECT_TAG:"flounder__multiple--select--tag",MULTIPLE_TAG_CLOSE:"flounder__multiple__tag__close",NO_RESULTS:"flounder__no-results",OPEN:"open",OPTION:"flounder__option",OPTION_TAG:"flounder--option--tag",OPTIONS_WRAPPER:"flounder__list--wrapper",PLACEHOLDER:"flounder__placeholder",PLUG:"flounder__ios--plug",SECTION:"flounder__section",SELECTED:"flounder__option--selected",SELECTED_HIDDEN:"flounder__option--selected--hidden",SELECTED_DISPLAYED:"flounder__option--selected--displayed",SEARCH:"flounder__input--search",SEARCH_HIDDEN:"flounder--search--hidden",SELECT_TAG:"flounder--select--tag"};n["default"]=s},{}],15:[function(e,t,n){"use strict";function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0}),n.setDefaultOption=n.defaultOptions=void 0;var r=e("./utils"),i=s(r),a=e("./classes"),o=s(a),l=n.defaultOptions={allowHTML:!1,classes:o["default"],data:[],defaultEmpty:!1,defaultIndex:!1,defaultValue:!1,disableArrow:!1,keepChangesOnDestroy:!1,multiple:!1,multipleTags:!1,multipleMessage:"(Multiple Items Selected)",noMoreOptionsMessage:"No more options to add.",noMoreResultsMessage:"No matches found",onChange:function(e,t){},onClose:function(e,t){},onComponentDidMount:function(){},onComponentWillUnmount:function(){},onFirstTouch:function(e){},onInit:function(){},onInputChange:function(e){},onOpen:function(e,t){},openOnHover:!1,placeholder:"Please choose an option",search:!1,selectDataOverride:!1},u={defaultOptions:l,setDefaultOption:function(e){function t(e,t){var n=t||0===t?t:a.defaultIndex,s=e[n];return s?(s.index=n,s):null}function n(e){var t=e.refs,n=e.classes,s=t.select,r=a.placeholder,u={text:r||""===r?r:l.placeholder,value:"",index:0,extraClass:n.HIDDEN+" "+n.PLACEHOLDER};if(s){var c=e.allowHTML?u.text:i["default"].escapeHTML(u.text),d=i["default"].constructElement({tagname:"option",className:n.OPTION_TAG,value:u.value});d.innerHTML=c,s.insertBefore(d,s[0]),e.refs.selectOptions.unshift(d)}return o.unshift(u),u}function s(e,t){var n=t||""+a.defaultValue,s=void 0;e.forEach(function(e,t){var r=""+e.value;r===n&&(s=t)});var r=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=Array.prototype.slice,u={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});var s=l.call(t.children,0,-1);s.forEach(function(e){var t=e.firstChild;t.addEventListener("click",n.removeMultiTag),e.addEventListener("keydown",n.checkMultiTagKeydown)})},addOptionsListeners:function(){var e=this;this.refs.data.forEach(function(t){"DIV"===t.tagName&&(t.addEventListener("mouseenter",e.addHoverClass),t.addEventListener("mouseleave",e.removeHoverClass),t.addEventListener("click",e.clickSet))})},addNoMoreOptionsMessage:function(){var e=this.classes,t={className:e.OPTION+" "+e.NO_RESULTS},n=this.refs.noMoreOptionsEl||i["default"].constructElement(t);n.innerHTML=this.noMoreOptionsMessage,this.refs.optionsList.appendChild(n),this.refs.noMoreOptionsEl=n},addNoResultsMessage:function(){var e=this.classes,t={className:e.OPTION+" "+e.NO_RESULTS},n=this.refs.noResultsEl||i["default"].constructElement(t);n.innerHTML=this.noMoreResultsMessage,this.refs.optionsList.appendChild(n),this.refs.noResultsEl=n},addPlaceholder:function(){var e=this.getSelectedValues(),t=e[0],n=this.getSelected(),s=n.length?n[0].innerHTML:"",r=e.length,i=this.refs.selected;switch(r){case 0:this.setByIndex(0);break;case 1:i.innerHTML=s;break;default:i.innerHTML=this.multipleMessage}this.multipleTags&&(0===r&&this.setByIndex(0),t&&""!==t?i.innerHTML="":i.innerHTML=this.placeholder)},addSearchListeners:function(){var e=this.refs.search,t=this.refs.multiTagWrapper;t&&t.addEventListener("click",this.toggleListSearchClick),e.addEventListener("click",this.toggleListSearchClick),e.addEventListener("focus",this.toggleListSearchClick),e.addEventListener("keyup",this.fuzzySearch),e.addEventListener("focus",this.clearPlaceholder)},addSelectKeyListener:function(){var e=this.refs.select;if(e.addEventListener("keyup",this.setSelectValue),e.addEventListener("keydown",this.setKeypress),this.isIos){var t=this.classes,n=e.children[0],s=document.createElement("OPTION");s.disabled=!0,s.setAttribute("disabled",!0),s.className=t.PLUG,e.insertBefore(s,n)}},catchBodyClick:function(e){this.checkClickTarget(e)||(this.toggleList(e),this.addPlaceholder())},checkClickTarget:function(e,t){return t=t||e.target,t!==document&&(t===this.refs.flounder||(t=t.parentNode,!!t&&this.checkClickTarget(e,t)))},checkEnterOnSearch:function(e,t){var n=e.target.value;if(n&&""!==n){var s=[],r=this.getSelected(),i=this.search.isThereAnythingRelatedTo(n);i.forEach(function(e){var n=e.i;e=t.selectOptions[n],r.indexOf(e)===-1&&s.push(e)});var a=-1;if(1===s.length)a=0;else if(s.length>1)for(var o=0;o=48&&t<=57||t>=65&&t<=90)&&n.search&&"INPUT"===e.target.tagName&&(n.selected.innerHTML="")},checkMultiTagKeydown:function(e){function t(){setTimeout(function(){return r.search.focus()},0),s.clearPlaceholder(),s.toggleListSearchClick(e)}var n=e.keyCode,s=this,r=this.refs,i=l.call(r.multiTagWrapper.children,0,-1),a=e.target,u=i.indexOf(a);n===o["default"].LEFT||n===o["default"].RIGHT||n===o["default"].BACKSPACE?(e.preventDefault(),e.stopPropagation(),n===o["default"].BACKSPACE?s.checkMultiTagKeydownRemove(a,t,u):s.checkMultiTagKeydownNavigate(t,n,u)):e.key.length<2&&t()},checkMultiTagKeydownNavigate:function(e,t,n){var s=l.call(this.refs.multiTagWrapper.children,0,-1),r=t-38,i=n+r,a=s.length-1;i>a?e():i>=0&&setTimeout(function(){return s[i].focus()},0)},checkMultiTagKeydownRemove:function(e,t,n){var s=l.call(this.refs.multiTagWrapper.children,0,-1),r=s.length-1;e.firstChild.click(),r>0?setTimeout(function(){return s[0===n?0:n-1].focus()},0):t()},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){var n=this,s=l.call(t.children,0,-1);s.forEach(function(e){var s=e.firstChild;s.removeEventListener("click",n.removeMultiTag),e.removeEventListener("keydown",n.checkMultiTagKeydown),t.removeChild(e)}),e.length>0?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;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 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))},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.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)}this.search?setTimeout(function(){return n.search.focus()},0):(this.addSelectKeyListener(),setTimeout(function(){return n.select.focus()},0));var u=n.data.length;if(this.props.placeholder&&u--,n.multiTagWrapper){var c=l.call(n.multiTagWrapper.children,0,-1);c.length===u&&(this.removeNoResultsMessage(),this.addNoMoreOptionsMessage())}if(this.ready)try{this.onOpen(e,this.getSelectedValues())}catch(e){console.warn('something may be wrong in "onOpen"',e)}}};n["default"]=u},{"./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(){try{this.onComponentWillUnmount()}catch(e){console.warn('something may be wrong in\n "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){this.fuzzySearch.previousValue=this.fuzzySearch.previousValue||"";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=S.call(this.refs.multiTagWrapper.children,0,-1).pop();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){this.props=t,this.bindThis(),this.initializeOptions(),this.setTarget(e),this.search&&(this.search=new y["default"](this));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;this.isOsx=r,this.isIos=i,this.multiSelect=a,this.onRender();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}();b.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 b(e,t)})},Object.defineProperty(b,"version",{get:function(){return C["default"]}}),Object.defineProperty(b.prototype,"version",{get:function(){return C["default"]}}),c["default"].extendClass(b,f["default"],p["default"],g["default"]),n["default"]=b},{"./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},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){if(!e)return!1;var t=e.parentNode.parentNode,n=e.offsetHeight,s=t.scrollTop,r=t.scrollTop+t.offsetHeight-n,i=e.offsetTop;ir&&(t.scrollTop=i-t.offsetHeight+1.5*n)},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.2.3"},{}]},{},[17]); \ No newline at end of file +/*! 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