From e8d8f8662ec78457a4b35d039818e62a7eab18bf Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Wed, 15 Nov 2017 06:51:53 +0000 Subject: [PATCH] Export properly --- server.js | 10 +- src/scripts/dist/choices.js | 4795 ++++++++++++++++--------------- src/scripts/dist/choices.js.map | 2 +- src/scripts/dist/choices.min.js | 2 +- src/scripts/src/choices.js | 5 +- webpack.config.prod.js | 51 +- 6 files changed, 2581 insertions(+), 2284 deletions(-) diff --git a/server.js b/server.js index a125696..f1e937d 100644 --- a/server.js +++ b/server.js @@ -1,13 +1,13 @@ -let webpack = require('webpack'); -let WebpackDevServer = require('webpack-dev-server'); -let config = require('./webpack.config.dev'); -let opn = require('opn'); +const webpack = require('webpack'); +const WebpackDevServer = require('webpack-dev-server'); +const config = require('./webpack.config.dev'); +const opn = require('opn'); new WebpackDevServer(webpack(config), { publicPath: config.output.publicPath, historyApiFallback: true, quiet: true, // lets WebpackDashboard do its thing -}).listen(3001, 'localhost', (err, result) => { +}).listen(3001, 'localhost', (err) => { if (err) console.log(err); opn('http://localhost:3001'); console.log('Listening at localhost:3001'); diff --git a/src/scripts/dist/choices.js b/src/scripts/dist/choices.js index 6d41e04..95d870c 100644 --- a/src/scripts/dist/choices.js +++ b/src/scripts/dist/choices.js @@ -1,11 +1,15 @@ /*! choices.js v3.0.2 | (c) 2017 Josh Johnson | https://github.com/jshjohnson/Choices#readme */ (function webpackUniversalModuleDefinition(root, factory) { + //CommonJS2 if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); + //AMD else if(typeof define === 'function' && define.amd) define([], factory); + //CommonJS else if(typeof exports === 'object') exports["Choices"] = factory(); + //Window else root["Choices"] = factory(); })(this, function() { @@ -71,43 +75,735 @@ return /******/ (function(modules) { // webpackBootstrap /******/ __webpack_require__.p = "/src/scripts/dist/"; /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 1); +/******/ return __webpack_require__(__webpack_require__.s = 5); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { -var g; +"use strict"; -// This works in non-strict mode -g = (function() { - return this; -})(); -try { - // This works if eval is allowed (see CSP) - g = g || Function("return this")() || (1,eval)("this"); -} catch(e) { - // This works if the window reference is available - if(typeof window === "object") - g = window; -} +Object.defineProperty(exports, "__esModule", { + value: true +}); -// g can still be undefined, but nothing to do about it... -// We return undefined, instead of nothing here, so it's -// easier to handle this case. if(!global) { ...} +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; -module.exports = g; +/* eslint-disable */ +/** + * Capitalises the first letter of each word in a string + * @param {String} str String to capitalise + * @return {String} Capitalised string + */ +var capitalise = exports.capitalise = function capitalise(str) { + return str.replace(/\w\S*/g, function (txt) { + return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); + }); +}; + +/** + * Generates a string of random chars + * @param {Number} length Length of the string to generate + * @return {String} String of random chars + */ +var generateChars = exports.generateChars = function generateChars(length) { + var chars = ''; + + for (var i = 0; i < length; i++) { + var randomChar = getRandomNumber(0, 36); + chars += randomChar.toString(36); + } + + return chars; +}; + +/** + * Generates a unique id based on an element + * @param {HTMLElement} element Element to generate the id from + * @param {String} Prefix for the Id + * @return {String} Unique Id + */ +var generateId = exports.generateId = function generateId(element, prefix) { + var id = element.id || element.name && element.name + '-' + generateChars(2) || generateChars(4); + id = id.replace(/(:|\.|\[|\]|,)/g, ''); + id = prefix + id; + + return id; +}; + +/** + * Tests the type of an object + * @param {String} type Type to test object against + * @param {Object} obj Object to be tested + * @return {Boolean} + */ +var getType = exports.getType = function getType(obj) { + return Object.prototype.toString.call(obj).slice(8, -1); +}; + +/** + * Tests the type of an object + * @param {String} type Type to test object against + * @param {Object} obj Object to be tested + * @return {Boolean} + */ +var isType = exports.isType = function isType(type, obj) { + var clas = getType(obj); + return obj !== undefined && obj !== null && clas === type; +}; + +/** + * Tests to see if a passed object is a node + * @param {Object} obj Object to be tested + * @return {Boolean} + */ +var isNode = exports.isNode = function isNode(o) { + return (typeof Node === 'undefined' ? 'undefined' : _typeof(Node)) === 'object' ? o instanceof Node : o && (typeof o === 'undefined' ? 'undefined' : _typeof(o)) === 'object' && typeof o.nodeType === 'number' && typeof o.nodeName === 'string'; +}; + +/** + * Tests to see if a passed object is an element + * @param {Object} obj Object to be tested + * @return {Boolean} + */ +var isElement = exports.isElement = function isElement(o) { + return (typeof HTMLElement === 'undefined' ? 'undefined' : _typeof(HTMLElement)) === 'object' ? o instanceof HTMLElement : // DOM2 + o && (typeof o === 'undefined' ? 'undefined' : _typeof(o)) === 'object' && o !== null && o.nodeType === 1 && typeof o.nodeName === 'string'; +}; + +/** + * Merges unspecified amount of objects into new object + * @private + * @return {Object} Merged object of arguments + */ +var extend = exports.extend = function extend() { + var extended = {}; + var length = arguments.length; + + /** + * Merge one object into another + * @param {Object} obj Object to merge into extended object + */ + var merge = function merge(obj) { + for (var prop in obj) { + if (Object.prototype.hasOwnProperty.call(obj, prop)) { + // If deep merge and property is an object, merge properties + if (isType('Object', obj[prop])) { + extended[prop] = extend(true, extended[prop], obj[prop]); + } else { + extended[prop] = obj[prop]; + } + } + } + }; + + // Loop through each passed argument + for (var i = 0; i < length; i++) { + // store argument at position i + var obj = arguments[i]; + + // If we are in fact dealing with an object, merge it. + if (isType('Object', obj)) { + merge(obj); + } + } + + return extended; +}; + +/** + * CSS transition end event listener + * @return + */ +var whichTransitionEvent = exports.whichTransitionEvent = function whichTransitionEvent() { + var t = void 0, + el = document.createElement('fakeelement'); + + var transitions = { + transition: 'transitionend', + OTransition: 'oTransitionEnd', + MozTransition: 'transitionend', + WebkitTransition: 'webkitTransitionEnd' + }; + + for (t in transitions) { + if (el.style[t] !== undefined) { + return transitions[t]; + } + } +}; + +/** + * CSS animation end event listener + * @return + */ +var whichAnimationEvent = exports.whichAnimationEvent = function whichAnimationEvent() { + var t = void 0, + el = document.createElement('fakeelement'); + + var animations = { + animation: 'animationend', + OAnimation: 'oAnimationEnd', + MozAnimation: 'animationend', + WebkitAnimation: 'webkitAnimationEnd' + }; + + for (t in animations) { + if (el.style[t] !== undefined) { + return animations[t]; + } + } +}; + +/** + * Get the ancestors of each element in the current set of matched elements, + * up to but not including the element matched by the selector + * @param {NodeElement} elem Element to begin search from + * @param {NodeElement} parent Parent to find + * @param {String} selector Class to find + * @return {Array} Array of parent elements + */ +var getParentsUntil = exports.getParentsUntil = function getParentsUntil(elem, parent, selector) { + var parents = []; + // Get matches + for (; elem && elem !== document; elem = elem.parentNode) { + // Check if parent has been reached + if (parent) { + var parentType = parent.charAt(0); + + // If parent is a class + if (parentType === '.') { + if (elem.classList.contains(parent.substr(1))) { + break; + } + } + + // If parent is an ID + if (parentType === '#') { + if (elem.id === parent.substr(1)) { + break; + } + } + + // If parent is a data attribute + if (parentType === '[') { + if (elem.hasAttribute(parent.substr(1, parent.length - 1))) { + break; + } + } + + // If parent is a tag + if (elem.tagName.toLowerCase() === parent) { + break; + } + } + if (selector) { + var selectorType = selector.charAt(0); + + // If selector is a class + if (selectorType === '.') { + if (elem.classList.contains(selector.substr(1))) { + parents.push(elem); + } + } + + // If selector is an ID + if (selectorType === '#') { + if (elem.id === selector.substr(1)) { + parents.push(elem); + } + } + + // If selector is a data attribute + if (selectorType === '[') { + if (elem.hasAttribute(selector.substr(1, selector.length - 1))) { + parents.push(elem); + } + } + + // If selector is a tag + if (elem.tagName.toLowerCase() === selector) { + parents.push(elem); + } + } else { + parents.push(elem); + } + } + + // Return parents if any exist + if (parents.length === 0) { + return null; + } + return parents; +}; + +var wrap = exports.wrap = function wrap(element, wrapper) { + wrapper = wrapper || document.createElement('div'); + if (element.nextSibling) { + element.parentNode.insertBefore(wrapper, element.nextSibling); + } else { + element.parentNode.appendChild(wrapper); + } + return wrapper.appendChild(element); +}; + +var getSiblings = exports.getSiblings = function getSiblings(elem) { + var siblings = []; + var sibling = elem.parentNode.firstChild; + for (; sibling; sibling = sibling.nextSibling) { + if (sibling.nodeType === 1 && sibling !== elem) { + siblings.push(sibling); + } + } + return siblings; +}; + +/** + * Find ancestor in DOM tree + * @param {NodeElement} el Element to start search from + * @param {[type]} cls Class of parent + * @return {NodeElement} Found parent element + */ +var findAncestor = exports.findAncestor = function findAncestor(el, cls) { + while ((el = el.parentElement) && !el.classList.contains(cls)) {} + return el; +}; + +/** + * Find ancestor in DOM tree by attribute name + * @param {NodeElement} el Element to start search from + * @param {string} attr Attribute name of parent + * @return {?NodeElement} Found parent element or null + */ +var findAncestorByAttrName = exports.findAncestorByAttrName = function findAncestorByAttrName(el, attr) { + var target = el; + + while (target) { + if (target.hasAttribute(attr)) { + return target; + } + + target = target.parentElement; + } + + return null; +}; + +/** + * Debounce an event handler. + * @param {Function} func Function to run after wait + * @param {Number} wait The delay before the function is executed + * @param {Boolean} immediate If passed, trigger the function on the leading edge, instead of the trailing. + * @return {Function} A function will be called after it stops being called for a given delay + */ +var debounce = exports.debounce = function debounce(func, wait, immediate) { + var timeout = void 0; + return function () { + var context = this, + args = arguments; + var later = function later() { + timeout = null; + if (!immediate) func.apply(context, args); + }; + var callNow = immediate && !timeout; + clearTimeout(timeout); + timeout = setTimeout(later, wait); + if (callNow) func.apply(context, args); + }; +}; + +/** + * Get an element's distance from the top of the page + * @private + * @param {NodeElement} el Element to test for + * @return {Number} Elements Distance from top of page + */ +var getElemDistance = exports.getElemDistance = function getElemDistance(el) { + var location = 0; + if (el.offsetParent) { + do { + location += el.offsetTop; + el = el.offsetParent; + } while (el); + } + return location >= 0 ? location : 0; +}; + +/** + * Determine element height multiplied by any offsets + * @private + * @param {HTMLElement} el Element to test for + * @return {Number} Height of element + */ +var getElementOffset = exports.getElementOffset = function getElementOffset(el, offset) { + var elOffset = offset; + if (elOffset > 1) elOffset = 1; + if (elOffset > 0) elOffset = 0; + + return Math.max(el.offsetHeight * elOffset); +}; + +/** + * Get the next or previous element from a given start point + * @param {HTMLElement} startEl Element to start position from + * @param {String} className The class we will look through + * @param {Number} direction Positive next element, negative previous element + * @return {[HTMLElement} Found element + */ +var getAdjacentEl = exports.getAdjacentEl = function getAdjacentEl(startEl, className) { + var direction = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; + + if (!startEl || !className) return; + + var parent = startEl.parentNode.parentNode; + var children = Array.from(parent.querySelectorAll(className)); + + var startPos = children.indexOf(startEl); + var operatorDirection = direction > 0 ? 1 : -1; + + return children[startPos + operatorDirection]; +}; + +/** + * Get scroll position based on top/bottom position + * @private + * @return {String} Position of scroll + */ +var getScrollPosition = exports.getScrollPosition = function getScrollPosition(position) { + if (position === 'bottom') { + // Scroll position from the bottom of the viewport + return Math.max((window.scrollY || window.pageYOffset) + (window.innerHeight || document.documentElement.clientHeight)); + } + // Scroll position from the top of the viewport + return window.scrollY || window.pageYOffset; +}; + +/** + * Determine whether an element is within the viewport + * @param {HTMLElement} el Element to test + * @return {String} Position of scroll + * @return {Boolean} + */ +var isInView = exports.isInView = function isInView(el, position, offset) { + // If the user has scrolled further than the distance from the element to the top of its parent + return this.getScrollPosition(position) > this.getElemDistance(el) + this.getElementOffset(el, offset); +}; + +/** + * Determine whether an element is within + * @param {HTMLElement} el Element to test + * @param {HTMLElement} parent Scrolling parent + * @param {Number} direction Whether element is visible from above or below + * @return {Boolean} + */ +var isScrolledIntoView = exports.isScrolledIntoView = function isScrolledIntoView(el, parent) { + var direction = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; + + if (!el) return; + + var isVisible = void 0; + + if (direction > 0) { + // In view from bottom + isVisible = parent.scrollTop + parent.offsetHeight >= el.offsetTop + el.offsetHeight; + } else { + // In view from top + isVisible = el.offsetTop >= parent.scrollTop; + } + + return isVisible; +}; + +/** + * Remove html tags from a string + * @param {String} Initial string/html + * @return {String} Sanitised string + */ +var stripHTML = exports.stripHTML = function stripHTML(html) { + var el = document.createElement('DIV'); + el.innerHTML = html; + return el.textContent || el.innerText || ''; +}; + +/** + * Adds animation to an element and removes it upon animation completion + * @param {Element} el Element to add animation to + * @param {String} animation Animation class to add to element + * @return + */ +var addAnimation = exports.addAnimation = function addAnimation(el, animation) { + var animationEvent = whichAnimationEvent(); + + var removeAnimation = function removeAnimation() { + el.classList.remove(animation); + el.removeEventListener(animationEvent, removeAnimation, false); + }; + + el.classList.add(animation); + el.addEventListener(animationEvent, removeAnimation, false); +}; + +/** + * Get a random number between a range + * @param {Number} min Minimum range + * @param {Number} max Maximum range + * @return {Number} Random number + */ +var getRandomNumber = exports.getRandomNumber = function getRandomNumber(min, max) { + return Math.floor(Math.random() * (max - min) + min); +}; + +/** + * Turn a string into a node + * @param {String} String to convert + * @return {HTMLElement} Converted node element + */ +var strToEl = exports.strToEl = function () { + var tmpEl = document.createElement('div'); + return function (str) { + var cleanedInput = str.trim(); + var r = void 0; + tmpEl.innerHTML = cleanedInput; + r = tmpEl.children[0]; + + while (tmpEl.firstChild) { + tmpEl.removeChild(tmpEl.firstChild); + } + + return r; + }; +}(); + +/** + * Sets the width of a passed input based on its value + * @return {Number} Width of input + */ +var getWidthOfInput = exports.getWidthOfInput = function getWidthOfInput(input) { + var value = input.value || input.placeholder; + var width = input.offsetWidth; + + if (value) { + var testEl = strToEl('' + value + ''); + testEl.style.position = 'absolute'; + testEl.style.padding = '0'; + testEl.style.top = '-9999px'; + testEl.style.left = '-9999px'; + testEl.style.width = 'auto'; + testEl.style.whiteSpace = 'pre'; + + if (document.body.contains(input) && window.getComputedStyle) { + var inputStyle = window.getComputedStyle(input); + + if (inputStyle) { + testEl.style.fontSize = inputStyle.fontSize; + testEl.style.fontFamily = inputStyle.fontFamily; + testEl.style.fontWeight = inputStyle.fontWeight; + testEl.style.fontStyle = inputStyle.fontStyle; + testEl.style.letterSpacing = inputStyle.letterSpacing; + testEl.style.textTransform = inputStyle.textTransform; + testEl.style.padding = inputStyle.padding; + } + } + + document.body.appendChild(testEl); + + if (value && testEl.offsetWidth !== input.offsetWidth) { + width = testEl.offsetWidth + 4; + } + + document.body.removeChild(testEl); + } + + return width + 'px'; +}; + +/** + * Sorting function for current and previous string + * @param {String} a Current value + * @param {String} b Next value + * @return {Number} -1 for after previous, + * 1 for before, + * 0 for same location + */ +var sortByAlpha = exports.sortByAlpha = function sortByAlpha(a, b) { + var labelA = (a.label || a.value).toLowerCase(); + var labelB = (b.label || b.value).toLowerCase(); + + if (labelA < labelB) return -1; + if (labelA > labelB) return 1; + return 0; +}; + +/** + * Sort by numeric score + * @param {Object} a Current value + * @param {Object} b Next value + * @return {Number} -1 for after previous, + * 1 for before, + * 0 for same location + */ +var sortByScore = exports.sortByScore = function sortByScore(a, b) { + return a.score - b.score; +}; + +/** + * Dispatch native event + * @param {NodeElement} element Element to trigger event on + * @param {String} type Type of event to trigger + * @param {Object} customArgs Data to pass with event + * @return {Object} Triggered event + */ +var dispatchEvent = exports.dispatchEvent = function dispatchEvent(element, type) { + var customArgs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; + + var event = new CustomEvent(type, { + detail: customArgs, + bubbles: true, + cancelable: true + }); + + return element.dispatchEvent(event); +}; + +/** + * Tests value against a regular expression + * @param {string} value Value to test + * @return {Boolean} Whether test passed/failed + * @private + */ +var regexFilter = exports.regexFilter = function regexFilter(value, regex) { + if (!value || !regex) { + return false; + } + + var expression = new RegExp(regex.source, 'i'); + return expression.test(value); +}; /***/ }), /* 1 */ /***/ (function(module, exports, __webpack_require__) { -module.exports = __webpack_require__(2); +"use strict"; +Object.defineProperty(exports, "__esModule", { + value: true +}); +var DEFAULT_CLASSNAMES = exports.DEFAULT_CLASSNAMES = { + containerOuter: 'choices', + containerInner: 'choices__inner', + input: 'choices__input', + inputCloned: 'choices__input--cloned', + list: 'choices__list', + listItems: 'choices__list--multiple', + listSingle: 'choices__list--single', + listDropdown: 'choices__list--dropdown', + item: 'choices__item', + itemSelectable: 'choices__item--selectable', + itemDisabled: 'choices__item--disabled', + itemChoice: 'choices__item--choice', + placeholder: 'choices__placeholder', + group: 'choices__group', + groupHeading: 'choices__heading', + button: 'choices__button', + activeState: 'is-active', + focusState: 'is-focused', + openState: 'is-open', + disabledState: 'is-disabled', + highlightedState: 'is-highlighted', + hiddenState: 'is-hidden', + flippedState: 'is-flipped', + loadingState: 'is-loading', + noResults: 'has-no-results', + noChoices: 'has-no-choices' +}; + +var DEFAULT_CONFIG = exports.DEFAULT_CONFIG = { + silent: false, + renderChoiceLimit: -1, + maxItemCount: -1, + addItems: true, + removeItems: true, + removeItemButton: false, + editItems: false, + duplicateItems: true, + delimiter: ',', + paste: true, + searchEnabled: true, + searchChoices: true, + searchFloor: 1, + searchResultLimit: 4, + searchFields: ['label', 'value'], + position: 'auto', + resetScrollPosition: true, + regexFilter: null, + shouldSort: true, + shouldSortItems: false, + placeholder: true, + placeholderValue: null, + searchPlaceholderValue: null, + prependValue: null, + appendValue: null, + renderSelectedChoices: 'auto', + loadingText: 'Loading...', + noResultsText: 'No results found', + noChoicesText: 'No choices to choose from', + itemSelectText: 'Press to select', + addItemText: function addItemText(value) { + return 'Press Enter to add "' + value + '"'; + }, + maxItemText: function maxItemText(maxItemCount) { + return 'Only ' + maxItemCount + ' values can be added.'; + }, + uniqueItemText: 'Only unique values can be added.', + fuseOptions: { + includeScore: true + }, + callbackOnInit: null, + callbackOnCreateTemplates: null +}; + +var EVENTS = exports.EVENTS = { + showDropdown: 'showDropdown', + hideDropdown: 'hideDropdown', + change: 'change', + choice: 'choice', + search: 'search', + addItem: 'addItem', + removeItem: 'removeItem', + highlightItem: 'highlightItem' +}; + +var ACTION_TYPES = exports.ACTION_TYPES = { + ADD_CHOICE: 'ADD_CHOICE', + FILTER_CHOICES: 'FILTER_CHOICES', + ACTIVATE_CHOICES: 'ACTIVATE_CHOICES', + CLEAR_CHOICES: 'CLEAR_CHOICES', + ADD_GROUP: 'ADD_GROUP', + ADD_ITEM: 'ADD_ITEM', + REMOVE_ITEM: 'REMOVE_ITEM', + HIGHLIGHT_ITEM: 'HIGHLIGHT_ITEM', + CLEAR_ALL: 'CLEAR_ALL' +}; + +var KEY_CODES = exports.KEY_CODES = { + BACK_KEY: 46, + DELETE_KEY: 8, + ENTER_KEY: 13, + A_KEY: 65, + ESC_KEY: 27, + UP_KEY: 38, + DOWN_KEY: 40, + PAGE_UP_KEY: 33, + PAGE_DOWN_KEY: 34 +}; + +var SCROLLING_SPEED = exports.SCROLLING_SPEED = 4; + /***/ }), /* 2 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { @@ -115,12 +811,8 @@ module.exports = __webpack_require__(2); "use strict"; Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); -// EXTERNAL MODULE: ./node_modules/fuse.js/dist/fuse.js -var dist_fuse = __webpack_require__(3); -var fuse_default = /*#__PURE__*/__webpack_require__.n(dist_fuse); - // EXTERNAL MODULE: ./node_modules/redux/node_modules/lodash-es/_freeGlobal.js -var _freeGlobal = __webpack_require__(4); +var _freeGlobal = __webpack_require__(9); // CONCATENATED MODULE: ./node_modules/redux/node_modules/lodash-es/_root.js @@ -137,9 +829,9 @@ var root = _freeGlobal["a" /* default */] || freeSelf || Function('return this') /** Built-in value references. */ -var _Symbol_Symbol = _root.Symbol; +var Symbol = _root.Symbol; -/* harmony default export */ var _Symbol = (_Symbol_Symbol); +/* harmony default export */ var _Symbol = (Symbol); // CONCATENATED MODULE: ./node_modules/redux/node_modules/lodash-es/_getRawTag.js @@ -364,7 +1056,7 @@ function isPlainObject(value) { /* harmony default export */ var lodash_es_isPlainObject = (isPlainObject); // EXTERNAL MODULE: ./node_modules/redux/node_modules/symbol-observable/index.js -var symbol_observable = __webpack_require__(5); +var symbol_observable = __webpack_require__(10); var symbol_observable_default = /*#__PURE__*/__webpack_require__.n(symbol_observable); // CONCATENATED MODULE: ./node_modules/redux/es/createStore.js @@ -900,6 +1592,11 @@ function applyMiddleware() { }; } // CONCATENATED MODULE: ./node_modules/redux/es/index.js +/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "createStore", function() { return createStore_createStore; }); +/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "combineReducers", function() { return combineReducers; }); +/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "bindActionCreators", function() { return bindActionCreators; }); +/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "applyMiddleware", function() { return applyMiddleware; }); +/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "compose", function() { return compose; }); @@ -918,1691 +1615,54 @@ if (false) { } -// CONCATENATED MODULE: ./src/scripts/src/reducers/items.js -function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } -var defaultState = []; +/***/ }), +/* 3 */ +/***/ (function(module, exports) { -function items_items() { - var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultState; - var action = arguments[1]; +var g; - switch (action.type) { - case 'ADD_ITEM': - { - // Add object to items array - var newState = [].concat(_toConsumableArray(state), [{ - id: action.id, - choiceId: action.choiceId, - groupId: action.groupId, - value: action.value, - label: action.label, - active: true, - highlighted: false, - customProperties: action.customProperties, - placeholder: action.placeholder || false, - keyCode: null - }]); +// This works in non-strict mode +g = (function() { + return this; +})(); - return newState.map(function (obj) { - var item = obj; - if (item.highlighted) { - item.highlighted = false; - } - return item; - }); - } - - case 'REMOVE_ITEM': - { - // Set item to inactive - return state.map(function (obj) { - var item = obj; - if (item.id === action.id) { - item.active = false; - } - return item; - }); - } - - case 'HIGHLIGHT_ITEM': - { - return state.map(function (obj) { - var item = obj; - if (item.id === action.id) { - item.highlighted = action.highlighted; - } - return item; - }); - } - - default: - { - return state; - } - } +try { + // This works if eval is allowed (see CSP) + g = g || Function("return this")() || (1,eval)("this"); +} catch(e) { + // This works if the window reference is available + if(typeof window === "object") + g = window; } -// CONCATENATED MODULE: ./src/scripts/src/reducers/groups.js -function groups__toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } -var groups_defaultState = []; +// g can still be undefined, but nothing to do about it... +// We return undefined, instead of nothing here, so it's +// easier to handle this case. if(!global) { ...} -function groups() { - var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : groups_defaultState; - var action = arguments[1]; - - switch (action.type) { - case 'ADD_GROUP': - { - return [].concat(groups__toConsumableArray(state), [{ - id: action.id, - value: action.value, - active: action.active, - disabled: action.disabled - }]); - } - - case 'CLEAR_CHOICES': - { - return []; - } - - default: - { - return state; - } - } -} -// CONCATENATED MODULE: ./src/scripts/src/reducers/choices.js -function choices__toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } - -var choices_defaultState = []; - -function choices_choices() { - var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : choices_defaultState; - var action = arguments[1]; - - switch (action.type) { - case 'ADD_CHOICE': - { - /* - A disabled choice appears in the choice dropdown but cannot be selected - A selected choice has been added to the passed input's value (added as an item) - An active choice appears within the choice dropdown - */ - return [].concat(choices__toConsumableArray(state), [{ - id: action.id, - elementId: action.elementId, - groupId: action.groupId, - value: action.value, - label: action.label || action.value, - disabled: action.disabled || false, - selected: false, - active: true, - score: 9999, - customProperties: action.customProperties, - placeholder: action.placeholder || false, - keyCode: null - }]); - } - - case 'ADD_ITEM': - { - // If all choices need to be activated - if (action.activateOptions) { - return state.map(function (obj) { - var choice = obj; - choice.active = action.active; - return choice; - }); - } - - // When an item is added and it has an associated choice, - // we want to disable it so it can't be chosen again - if (action.choiceId > -1) { - return state.map(function (obj) { - var choice = obj; - if (choice.id === parseInt(action.choiceId, 10)) { - choice.selected = true; - } - return choice; - }); - } - - return state; - } - - case 'REMOVE_ITEM': - { - // When an item is removed and it has an associated choice, - // we want to re-enable it so it can be chosen again - if (action.choiceId > -1) { - return state.map(function (obj) { - var choice = obj; - if (choice.id === parseInt(action.choiceId, 10)) { - choice.selected = false; - } - return choice; - }); - } - - return state; - } - - case 'FILTER_CHOICES': - { - return state.map(function (obj) { - var choice = obj; - // Set active state based on whether choice is - // within filtered results - choice.active = action.results.some(function (_ref) { - var item = _ref.item, - score = _ref.score; - - if (item.id === choice.id) { - choice.score = score; - return true; - } - return false; - }); - - return choice; - }); - } - - case 'ACTIVATE_CHOICES': - { - return state.map(function (obj) { - var choice = obj; - choice.active = action.active; - return choice; - }); - } - - case 'CLEAR_CHOICES': - { - return choices_defaultState; - } - - default: - { - return state; - } - } -} -// CONCATENATED MODULE: ./src/scripts/src/reducers/index.js +module.exports = g; +/***/ }), +/* 4 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; - -var appReducer = combineReducers({ - items: items_items, - groups: groups, - choices: choices_choices +Object.defineProperty(exports, "__esModule", { + value: true }); -var rootReducer = function rootReducer(passedState, action) { - var state = passedState; - // If we are clearing all items, groups and options we reassign - // state and then pass that state to our proper reducer. This isn't - // mutating our actual state - // See: http://stackoverflow.com/a/35641992 - if (action.type === 'CLEAR_ALL') { - state = undefined; - } - - return appReducer(state, action); -}; - -/* harmony default export */ var src_reducers = (rootReducer); -// CONCATENATED MODULE: ./src/scripts/src/store/store.js var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -function store__toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } +var _utils = __webpack_require__(0); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - - -var store_Store = function () { - function Store() { - _classCallCheck(this, Store); - - this.store = createStore_createStore(src_reducers, window.devToolsExtension ? window.devToolsExtension() : undefined); - } - - /** - * Subscribe store to function call (wrapped Redux method) - * @param {Function} onChange Function to trigger when state changes - * @return - */ - - - _createClass(Store, [{ - key: 'subscribe', - value: function subscribe(onChange) { - this.store.subscribe(onChange); - } - - /** - * Dispatch event to store (wrapped Redux method) - * @param {Function} action Action function to trigger - * @return - */ - - }, { - key: 'dispatch', - value: function dispatch(action) { - this.store.dispatch(action); - } - - /** - * Get store object (wrapping Redux method) - * @return {Object} State - */ - - }, { - key: 'getState', - value: function getState() { - return this.store.getState(); - } - - /** - * Get items from store - * @return {Array} Item objects - */ - - }, { - key: 'getItems', - value: function getItems() { - var state = this.store.getState(); - return state.items; - } - - /** - * Get active items from store - * @return {Array} Item objects - */ - - }, { - key: 'getItemsFilteredByActive', - value: function getItemsFilteredByActive() { - var items = this.getItems(); - var values = items.filter(function (item) { - return item.active === true; - }, []); - - return values; - } - - /** - * Get items from store reduced to just their values - * @return {Array} Item objects - */ - - }, { - key: 'getItemsReducedToValues', - value: function getItemsReducedToValues() { - var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getItems(); - - var values = items.reduce(function (prev, current) { - prev.push(current.value); - return prev; - }, []); - - return values; - } - - /** - * Get choices from store - * @return {Array} Option objects - */ - - }, { - key: 'getChoices', - value: function getChoices() { - var state = this.store.getState(); - return state.choices; - } - - /** - * Get active choices from store - * @return {Array} Option objects - */ - - }, { - key: 'getChoicesFilteredByActive', - value: function getChoicesFilteredByActive() { - var choices = this.getChoices(); - var values = choices.filter(function (choice) { - return choice.active === true; - }); - - return values; - } - - /** - * Get selectable choices from store - * @return {Array} Option objects - */ - - }, { - key: 'getChoicesFilteredBySelectable', - value: function getChoicesFilteredBySelectable() { - var choices = this.getChoices(); - var values = choices.filter(function (choice) { - return choice.disabled !== true; - }); - - return values; - } - - /** - * Get choices that can be searched (excluding placeholders) - * @return {Array} Option objects - */ - - }, { - key: 'getSearchableChoices', - value: function getSearchableChoices() { - var filtered = this.getChoicesFilteredBySelectable(); - return filtered.filter(function (choice) { - return choice.placeholder !== true; - }); - } - - /** - * Get single choice by it's ID - * @return {Object} Found choice - */ - - }, { - key: 'getChoiceById', - value: function getChoiceById(id) { - if (id) { - var choices = this.getChoicesFilteredByActive(); - var foundChoice = choices.find(function (choice) { - return choice.id === parseInt(id, 10); - }); - return foundChoice; - } - return false; - } - - /** - * Get placeholder choice from store - * @return {Object} Found placeholder - */ - - }, { - key: 'getPlaceholderChoice', - value: function getPlaceholderChoice() { - var choices = this.getChoices(); - var placeholderChoice = [].concat(store__toConsumableArray(choices)).reverse().find(function (choice) { - return choice.placeholder === true; - }); - - return placeholderChoice; - } - - /** - * Get groups from store - * @return {Array} Group objects - */ - - }, { - key: 'getGroups', - value: function getGroups() { - var state = this.store.getState(); - return state.groups; - } - - /** - * Get active groups from store - * @return {Array} Group objects - */ - - }, { - key: 'getGroupsFilteredByActive', - value: function getGroupsFilteredByActive() { - var groups = this.getGroups(); - var choices = this.getChoices(); - - var values = groups.filter(function (group) { - var isActive = group.active === true && group.disabled === false; - var hasActiveOptions = choices.some(function (choice) { - return choice.active === true && choice.disabled === false; - }); - return isActive && hasActiveOptions; - }, []); - - return values; - } - - /** - * Get group by group id - * @param {Number} id Group ID - * @return {Object} Group data - */ - - }, { - key: 'getGroupById', - value: function getGroupById(id) { - var groups = this.getGroups(); - var foundGroup = groups.find(function (group) { - return group.id === parseInt(id, 10); - }); - - return foundGroup; - } - }]); - - return Store; -}(); - -/* harmony default export */ var store_store = (store_Store); -// CONCATENATED MODULE: ./src/scripts/src/components/dropdown.js -var dropdown__createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -function dropdown__classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -var Dropdown = function () { - function Dropdown(instance, element, classNames) { - dropdown__classCallCheck(this, Dropdown); - - this.parentInstance = instance; - this.element = element; - this.classNames = classNames; - this.dimensions = null; - this.position = null; - this.isActive = false; - } - - dropdown__createClass(Dropdown, [{ - key: 'getElement', - value: function getElement() { - return this.element; - } - - /** - * Determine how far the top of our element is from - * the top of the window - * @return {Number} Vertical position - */ - - }, { - key: 'getVerticalPos', - value: function getVerticalPos() { - this.dimensions = this.element.getBoundingClientRect(); - this.position = Math.ceil(this.dimensions.top + window.pageYOffset + this.element.offsetHeight); - return this.position; - } - - /** - * Find element that matches passed selector - * @return {HTMLElement} - */ - - }, { - key: 'getChild', - value: function getChild(selector) { - return this.element.querySelector(selector); - } - - /** - * Show dropdown to user by adding active state class - * @return {Object} Class instance - * @public - */ - - }, { - key: 'show', - value: function show() { - this.element.classList.add(this.classNames.activeState); - this.element.setAttribute('aria-expanded', 'true'); - this.isActive = true; - return this.parentInstance; - } - - /** - * Hide dropdown from user - * @return {Object} Class instance - * @public - */ - - }, { - key: 'hide', - value: function hide() { - this.element.classList.remove(this.classNames.activeState); - this.element.setAttribute('aria-expanded', 'false'); - this.isActive = false; - return this.parentInstance; - } - }]); - - return Dropdown; -}(); - -/* harmony default export */ var components_dropdown = (Dropdown); -// CONCATENATED MODULE: ./src/scripts/src/components/container.js -var container__createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -function container__classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -var Container = function () { - function Container(instance, element, classNames) { - container__classCallCheck(this, Container); - - this.parentInstance = instance; - this.element = element; - this.classNames = classNames; - this.config = instance.config; - this.isOpen = false; - this.isFlipped = false; - this.isFocussed = false; - this.isDisabled = false; - this.isLoading = false; - this.onFocus = this.onFocus.bind(this); - this.onBlur = this.onBlur.bind(this); - } - - container__createClass(Container, [{ - key: 'getElement', - value: function getElement() { - return this.element; - } - - /** - * Add event listeners - */ - - }, { - key: 'addEventListeners', - value: function addEventListeners() { - this.element.addEventListener('focus', this.onFocus); - this.element.addEventListener('blur', this.onBlur); - } - - /** - * Remove event listeners - */ - - /** */ - - }, { - key: 'removeEventListeners', - value: function removeEventListeners() { - this.element.removeEventListener('focus', this.onFocus); - this.element.removeEventListener('blur', this.onBlur); - } - - /** - * Set focussed state - */ - - }, { - key: 'onFocus', - value: function onFocus() { - this.isFocussed = true; - } - - /** - * Remove blurred state - */ - - }, { - key: 'onBlur', - value: function onBlur() { - this.isFocussed = false; - } - - /** - * Determine whether container should be flipped - * based on passed dropdown position - * @param {Number} dropdownPos - * @returns - */ - - }, { - key: 'shouldFlip', - value: function shouldFlip(dropdownPos) { - if (dropdownPos === undefined) { - return false; - } - - var body = document.body; - var html = document.documentElement; - var winHeight = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight); - - // If flip is enabled and the dropdown bottom position is - // greater than the window height flip the dropdown. - var shouldFlip = false; - if (this.config.position === 'auto') { - shouldFlip = dropdownPos >= winHeight; - } else if (this.config.position === 'top') { - shouldFlip = true; - } - - return shouldFlip; - } - - /** - * Set active descendant attribute - * @param {Number} activeDescendant ID of active descendant - */ - - }, { - key: 'setActiveDescendant', - value: function setActiveDescendant(activeDescendantID) { - this.element.setAttribute('aria-activedescendant', activeDescendantID); - } - - /** - * Remove active descendant attribute - */ - - }, { - key: 'removeActiveDescendant', - value: function removeActiveDescendant() { - this.element.removeAttribute('aria-activedescendant'); - } - }, { - key: 'open', - value: function open(dropdownPos) { - this.element.classList.add(this.classNames.openState); - this.element.setAttribute('aria-expanded', 'true'); - this.isOpen = true; - - if (this.shouldFlip(dropdownPos)) { - this.element.classList.add(this.classNames.flippedState); - this.isFlipped = true; - } - } - }, { - key: 'close', - value: function close() { - this.element.classList.remove(this.classNames.openState); - this.element.setAttribute('aria-expanded', 'false'); - this.removeActiveDescendant(); - this.isOpen = false; - - // A dropdown flips if it does not have space within the page - if (this.isFlipped) { - this.element.classList.remove(this.classNames.flippedState); - this.isFlipped = false; - } - } - }, { - key: 'focus', - value: function focus() { - if (!this.isFocussed) { - this.element.focus(); - } - } - }, { - key: 'addFocusState', - value: function addFocusState() { - this.element.classList.add(this.classNames.focusState); - } - }, { - key: 'removeFocusState', - value: function removeFocusState() { - this.element.classList.remove(this.classNames.focusState); - } - - /** - * Remove disabled state - */ - - }, { - key: 'enable', - value: function enable() { - this.element.classList.remove(this.config.classNames.disabledState); - this.element.removeAttribute('aria-disabled'); - if (this.parentInstance.isSelectOneElement) { - this.element.setAttribute('tabindex', '0'); - } - this.isDisabled = false; - } - - /** - * Set disabled state - */ - - }, { - key: 'disable', - value: function disable() { - this.element.classList.add(this.config.classNames.disabledState); - this.element.setAttribute('aria-disabled', 'true'); - if (this.parentInstance.isSelectOneElement) { - this.element.setAttribute('tabindex', '-1'); - } - this.isDisabled = true; - } - }, { - key: 'revert', - value: function revert(originalElement) { - // Move passed element back to original position - this.element.parentNode.insertBefore(originalElement, this.element); - // Remove container - this.element.parentNode.removeChild(this.element); - } - - /** - * Add loading state to element - */ - - }, { - key: 'addLoadingState', - value: function addLoadingState() { - this.element.classList.add(this.classNames.loadingState); - this.element.setAttribute('aria-busy', 'true'); - this.isLoading = true; - } - - /** - * Remove loading state from element - */ - - }, { - key: 'removeLoadingState', - value: function removeLoadingState() { - this.element.classList.remove(this.classNames.loadingState); - this.element.removeAttribute('aria-busy'); - this.isLoading = false; - } - }]); - - return Container; -}(); - -/* harmony default export */ var container = (Container); -// CONCATENATED MODULE: ./src/scripts/src/lib/utils.js -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - -/* eslint-disable */ - -/** - * Capitalises the first letter of each word in a string - * @param {String} str String to capitalise - * @return {String} Capitalised string - */ -var capitalise = function capitalise(str) { - return str.replace(/\w\S*/g, function (txt) { - return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); - }); -}; - -/** - * Generates a string of random chars - * @param {Number} length Length of the string to generate - * @return {String} String of random chars - */ -var generateChars = function generateChars(length) { - var chars = ''; - - for (var i = 0; i < length; i++) { - var randomChar = getRandomNumber(0, 36); - chars += randomChar.toString(36); - } - - return chars; -}; - -/** - * Generates a unique id based on an element - * @param {HTMLElement} element Element to generate the id from - * @param {String} Prefix for the Id - * @return {String} Unique Id - */ -var generateId = function generateId(element, prefix) { - var id = element.id || element.name && element.name + '-' + generateChars(2) || generateChars(4); - id = id.replace(/(:|\.|\[|\]|,)/g, ''); - id = prefix + id; - - return id; -}; - -/** - * Tests the type of an object - * @param {String} type Type to test object against - * @param {Object} obj Object to be tested - * @return {Boolean} - */ -var getType = function getType(obj) { - return Object.prototype.toString.call(obj).slice(8, -1); -}; - -/** - * Tests the type of an object - * @param {String} type Type to test object against - * @param {Object} obj Object to be tested - * @return {Boolean} - */ -var isType = function isType(type, obj) { - var clas = getType(obj); - return obj !== undefined && obj !== null && clas === type; -}; - -/** - * Tests to see if a passed object is a node - * @param {Object} obj Object to be tested - * @return {Boolean} - */ -var isNode = function isNode(o) { - return (typeof Node === 'undefined' ? 'undefined' : _typeof(Node)) === 'object' ? o instanceof Node : o && (typeof o === 'undefined' ? 'undefined' : _typeof(o)) === 'object' && typeof o.nodeType === 'number' && typeof o.nodeName === 'string'; -}; - -/** - * Tests to see if a passed object is an element - * @param {Object} obj Object to be tested - * @return {Boolean} - */ -var isElement = function isElement(o) { - return (typeof HTMLElement === 'undefined' ? 'undefined' : _typeof(HTMLElement)) === 'object' ? o instanceof HTMLElement : // DOM2 - o && (typeof o === 'undefined' ? 'undefined' : _typeof(o)) === 'object' && o !== null && o.nodeType === 1 && typeof o.nodeName === 'string'; -}; - -/** - * Merges unspecified amount of objects into new object - * @private - * @return {Object} Merged object of arguments - */ -var extend = function extend() { - var extended = {}; - var length = arguments.length; - - /** - * Merge one object into another - * @param {Object} obj Object to merge into extended object - */ - var merge = function merge(obj) { - for (var prop in obj) { - if (Object.prototype.hasOwnProperty.call(obj, prop)) { - // If deep merge and property is an object, merge properties - if (isType('Object', obj[prop])) { - extended[prop] = extend(true, extended[prop], obj[prop]); - } else { - extended[prop] = obj[prop]; - } - } - } - }; - - // Loop through each passed argument - for (var i = 0; i < length; i++) { - // store argument at position i - var obj = arguments[i]; - - // If we are in fact dealing with an object, merge it. - if (isType('Object', obj)) { - merge(obj); - } - } - - return extended; -}; - -/** - * CSS transition end event listener - * @return - */ -var whichTransitionEvent = function whichTransitionEvent() { - var t = void 0, - el = document.createElement('fakeelement'); - - var transitions = { - transition: 'transitionend', - OTransition: 'oTransitionEnd', - MozTransition: 'transitionend', - WebkitTransition: 'webkitTransitionEnd' - }; - - for (t in transitions) { - if (el.style[t] !== undefined) { - return transitions[t]; - } - } -}; - -/** - * CSS animation end event listener - * @return - */ -var whichAnimationEvent = function whichAnimationEvent() { - var t = void 0, - el = document.createElement('fakeelement'); - - var animations = { - animation: 'animationend', - OAnimation: 'oAnimationEnd', - MozAnimation: 'animationend', - WebkitAnimation: 'webkitAnimationEnd' - }; - - for (t in animations) { - if (el.style[t] !== undefined) { - return animations[t]; - } - } -}; - -/** - * Get the ancestors of each element in the current set of matched elements, - * up to but not including the element matched by the selector - * @param {NodeElement} elem Element to begin search from - * @param {NodeElement} parent Parent to find - * @param {String} selector Class to find - * @return {Array} Array of parent elements - */ -var getParentsUntil = function getParentsUntil(elem, parent, selector) { - var parents = []; - // Get matches - for (; elem && elem !== document; elem = elem.parentNode) { - // Check if parent has been reached - if (parent) { - var parentType = parent.charAt(0); - - // If parent is a class - if (parentType === '.') { - if (elem.classList.contains(parent.substr(1))) { - break; - } - } - - // If parent is an ID - if (parentType === '#') { - if (elem.id === parent.substr(1)) { - break; - } - } - - // If parent is a data attribute - if (parentType === '[') { - if (elem.hasAttribute(parent.substr(1, parent.length - 1))) { - break; - } - } - - // If parent is a tag - if (elem.tagName.toLowerCase() === parent) { - break; - } - } - if (selector) { - var selectorType = selector.charAt(0); - - // If selector is a class - if (selectorType === '.') { - if (elem.classList.contains(selector.substr(1))) { - parents.push(elem); - } - } - - // If selector is an ID - if (selectorType === '#') { - if (elem.id === selector.substr(1)) { - parents.push(elem); - } - } - - // If selector is a data attribute - if (selectorType === '[') { - if (elem.hasAttribute(selector.substr(1, selector.length - 1))) { - parents.push(elem); - } - } - - // If selector is a tag - if (elem.tagName.toLowerCase() === selector) { - parents.push(elem); - } - } else { - parents.push(elem); - } - } - - // Return parents if any exist - if (parents.length === 0) { - return null; - } - return parents; -}; - -var wrap = function wrap(element, wrapper) { - wrapper = wrapper || document.createElement('div'); - if (element.nextSibling) { - element.parentNode.insertBefore(wrapper, element.nextSibling); - } else { - element.parentNode.appendChild(wrapper); - } - return wrapper.appendChild(element); -}; - -var getSiblings = function getSiblings(elem) { - var siblings = []; - var sibling = elem.parentNode.firstChild; - for (; sibling; sibling = sibling.nextSibling) { - if (sibling.nodeType === 1 && sibling !== elem) { - siblings.push(sibling); - } - } - return siblings; -}; - -/** - * Find ancestor in DOM tree - * @param {NodeElement} el Element to start search from - * @param {[type]} cls Class of parent - * @return {NodeElement} Found parent element - */ -var findAncestor = function findAncestor(el, cls) { - while ((el = el.parentElement) && !el.classList.contains(cls)) {} - return el; -}; - -/** - * Find ancestor in DOM tree by attribute name - * @param {NodeElement} el Element to start search from - * @param {string} attr Attribute name of parent - * @return {?NodeElement} Found parent element or null - */ -var findAncestorByAttrName = function findAncestorByAttrName(el, attr) { - var target = el; - - while (target) { - if (target.hasAttribute(attr)) { - return target; - } - - target = target.parentElement; - } - - return null; -}; - -/** - * Debounce an event handler. - * @param {Function} func Function to run after wait - * @param {Number} wait The delay before the function is executed - * @param {Boolean} immediate If passed, trigger the function on the leading edge, instead of the trailing. - * @return {Function} A function will be called after it stops being called for a given delay - */ -var debounce = function debounce(func, wait, immediate) { - var timeout = void 0; - return function () { - var context = this, - args = arguments; - var later = function later() { - timeout = null; - if (!immediate) func.apply(context, args); - }; - var callNow = immediate && !timeout; - clearTimeout(timeout); - timeout = setTimeout(later, wait); - if (callNow) func.apply(context, args); - }; -}; - -/** - * Get an element's distance from the top of the page - * @private - * @param {NodeElement} el Element to test for - * @return {Number} Elements Distance from top of page - */ -var getElemDistance = function getElemDistance(el) { - var location = 0; - if (el.offsetParent) { - do { - location += el.offsetTop; - el = el.offsetParent; - } while (el); - } - return location >= 0 ? location : 0; -}; - -/** - * Determine element height multiplied by any offsets - * @private - * @param {HTMLElement} el Element to test for - * @return {Number} Height of element - */ -var getElementOffset = function getElementOffset(el, offset) { - var elOffset = offset; - if (elOffset > 1) elOffset = 1; - if (elOffset > 0) elOffset = 0; - - return Math.max(el.offsetHeight * elOffset); -}; - -/** - * Get the next or previous element from a given start point - * @param {HTMLElement} startEl Element to start position from - * @param {String} className The class we will look through - * @param {Number} direction Positive next element, negative previous element - * @return {[HTMLElement} Found element - */ -var getAdjacentEl = function getAdjacentEl(startEl, className) { - var direction = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; - - if (!startEl || !className) return; - - var parent = startEl.parentNode.parentNode; - var children = Array.from(parent.querySelectorAll(className)); - - var startPos = children.indexOf(startEl); - var operatorDirection = direction > 0 ? 1 : -1; - - return children[startPos + operatorDirection]; -}; - -/** - * Get scroll position based on top/bottom position - * @private - * @return {String} Position of scroll - */ -var getScrollPosition = function getScrollPosition(position) { - if (position === 'bottom') { - // Scroll position from the bottom of the viewport - return Math.max((window.scrollY || window.pageYOffset) + (window.innerHeight || document.documentElement.clientHeight)); - } - // Scroll position from the top of the viewport - return window.scrollY || window.pageYOffset; -}; - -/** - * Determine whether an element is within the viewport - * @param {HTMLElement} el Element to test - * @return {String} Position of scroll - * @return {Boolean} - */ -var isInView = function isInView(el, position, offset) { - // If the user has scrolled further than the distance from the element to the top of its parent - return this.getScrollPosition(position) > this.getElemDistance(el) + this.getElementOffset(el, offset); -}; - -/** - * Determine whether an element is within - * @param {HTMLElement} el Element to test - * @param {HTMLElement} parent Scrolling parent - * @param {Number} direction Whether element is visible from above or below - * @return {Boolean} - */ -var isScrolledIntoView = function isScrolledIntoView(el, parent) { - var direction = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; - - if (!el) return; - - var isVisible = void 0; - - if (direction > 0) { - // In view from bottom - isVisible = parent.scrollTop + parent.offsetHeight >= el.offsetTop + el.offsetHeight; - } else { - // In view from top - isVisible = el.offsetTop >= parent.scrollTop; - } - - return isVisible; -}; - -/** - * Remove html tags from a string - * @param {String} Initial string/html - * @return {String} Sanitised string - */ -var stripHTML = function stripHTML(html) { - var el = document.createElement('DIV'); - el.innerHTML = html; - return el.textContent || el.innerText || ''; -}; - -/** - * Adds animation to an element and removes it upon animation completion - * @param {Element} el Element to add animation to - * @param {String} animation Animation class to add to element - * @return - */ -var addAnimation = function addAnimation(el, animation) { - var animationEvent = whichAnimationEvent(); - - var removeAnimation = function removeAnimation() { - el.classList.remove(animation); - el.removeEventListener(animationEvent, removeAnimation, false); - }; - - el.classList.add(animation); - el.addEventListener(animationEvent, removeAnimation, false); -}; - -/** - * Get a random number between a range - * @param {Number} min Minimum range - * @param {Number} max Maximum range - * @return {Number} Random number - */ -var getRandomNumber = function getRandomNumber(min, max) { - return Math.floor(Math.random() * (max - min) + min); -}; - -/** - * Turn a string into a node - * @param {String} String to convert - * @return {HTMLElement} Converted node element - */ -var strToEl = function () { - var tmpEl = document.createElement('div'); - return function (str) { - var cleanedInput = str.trim(); - var r = void 0; - tmpEl.innerHTML = cleanedInput; - r = tmpEl.children[0]; - - while (tmpEl.firstChild) { - tmpEl.removeChild(tmpEl.firstChild); - } - - return r; - }; -}(); - -/** - * Sets the width of a passed input based on its value - * @return {Number} Width of input - */ -var getWidthOfInput = function getWidthOfInput(input) { - var value = input.value || input.placeholder; - var width = input.offsetWidth; - - if (value) { - var testEl = strToEl('' + value + ''); - testEl.style.position = 'absolute'; - testEl.style.padding = '0'; - testEl.style.top = '-9999px'; - testEl.style.left = '-9999px'; - testEl.style.width = 'auto'; - testEl.style.whiteSpace = 'pre'; - - if (document.body.contains(input) && window.getComputedStyle) { - var inputStyle = window.getComputedStyle(input); - - if (inputStyle) { - testEl.style.fontSize = inputStyle.fontSize; - testEl.style.fontFamily = inputStyle.fontFamily; - testEl.style.fontWeight = inputStyle.fontWeight; - testEl.style.fontStyle = inputStyle.fontStyle; - testEl.style.letterSpacing = inputStyle.letterSpacing; - testEl.style.textTransform = inputStyle.textTransform; - testEl.style.padding = inputStyle.padding; - } - } - - document.body.appendChild(testEl); - - if (value && testEl.offsetWidth !== input.offsetWidth) { - width = testEl.offsetWidth + 4; - } - - document.body.removeChild(testEl); - } - - return width + 'px'; -}; - -/** - * Sorting function for current and previous string - * @param {String} a Current value - * @param {String} b Next value - * @return {Number} -1 for after previous, - * 1 for before, - * 0 for same location - */ -var sortByAlpha = function sortByAlpha(a, b) { - var labelA = (a.label || a.value).toLowerCase(); - var labelB = (b.label || b.value).toLowerCase(); - - if (labelA < labelB) return -1; - if (labelA > labelB) return 1; - return 0; -}; - -/** - * Sort by numeric score - * @param {Object} a Current value - * @param {Object} b Next value - * @return {Number} -1 for after previous, - * 1 for before, - * 0 for same location - */ -var sortByScore = function sortByScore(a, b) { - return a.score - b.score; -}; - -/** - * Dispatch native event - * @param {NodeElement} element Element to trigger event on - * @param {String} type Type of event to trigger - * @param {Object} customArgs Data to pass with event - * @return {Object} Triggered event - */ -var dispatchEvent = function dispatchEvent(element, type) { - var customArgs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; - - var event = new CustomEvent(type, { - detail: customArgs, - bubbles: true, - cancelable: true - }); - - return element.dispatchEvent(event); -}; - -/** - * Tests value against a regular expression - * @param {string} value Value to test - * @return {Boolean} Whether test passed/failed - * @private - */ -var regexFilter = function regexFilter(value, regex) { - if (!value || !regex) { - return false; - } - - var expression = new RegExp(regex.source, 'i'); - return expression.test(value); -}; -// CONCATENATED MODULE: ./src/scripts/src/components/input.js -var input__createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -function input__classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - - -var input_Input = function () { - function Input(instance, element, classNames) { - input__classCallCheck(this, Input); - - this.parentInstance = instance; - this.element = element; - this.classNames = classNames; - this.isFocussed = this.element === document.activeElement; - this.isDisabled = false; - - // Bind event listeners - this.onPaste = this.onPaste.bind(this); - this.onInput = this.onInput.bind(this); - this.onFocus = this.onFocus.bind(this); - this.onBlur = this.onBlur.bind(this); - } - - input__createClass(Input, [{ - key: 'getElement', - value: function getElement() { - return this.element; - } - }, { - key: 'addEventListeners', - value: function addEventListeners() { - this.element.addEventListener('input', this.onInput); - this.element.addEventListener('paste', this.onPaste); - this.element.addEventListener('focus', this.onFocus); - this.element.addEventListener('blur', this.onBlur); - } - }, { - key: 'removeEventListeners', - value: function removeEventListeners() { - this.element.removeEventListener('input', this.onInput); - this.element.removeEventListener('paste', this.onPaste); - this.element.removeEventListener('focus', this.onFocus); - this.element.removeEventListener('blur', this.onBlur); - } - - /** - * Input event - * @return - * @private - */ - - }, { - key: 'onInput', - value: function onInput() { - if (!this.parentInstance.isSelectOneElement) { - this.setWidth(); - } - } - - /** - * Paste event - * @param {Object} e Event - * @return - * @private - */ - - }, { - key: 'onPaste', - value: function onPaste(e) { - // Disable pasting into the input if option has been set - if (e.target === this.element && !this.parentInstance.config.paste) { - e.preventDefault(); - } - } - - /** - * Set focussed state - */ - - }, { - key: 'onFocus', - value: function onFocus() { - this.isFocussed = true; - } - - /** - * Remove focussed state - */ - - }, { - key: 'onBlur', - value: function onBlur() { - this.isFocussed = false; - } - }, { - key: 'activate', - value: function activate(focusInput) { - // Optionally focus the input if we have a search input - if (focusInput && this.parentInstance.canSearch && document.activeElement !== this.element) { - this.element.focus(); - } - } - }, { - key: 'deactivate', - value: function deactivate(blurInput) { - this.removeActiveDescendant(); - // Optionally blur the input if we have a search input - if (blurInput && this.parentInstance.canSearch && document.activeElement === this.element) { - this.element.blur(); - } - } - }, { - key: 'enable', - value: function enable() { - this.element.removeAttribute('disabled'); - this.isDisabled = false; - } - }, { - key: 'disable', - value: function disable() { - this.element.setAttribute('disabled', ''); - this.isDisabled = true; - } - }, { - key: 'focus', - value: function focus() { - if (!this.isFocussed) { - this.element.focus(); - } - } - - /** - * Set value of input to blank - * @return {Object} Class instance - * @public - */ - - }, { - key: 'clear', - value: function clear() { - var setWidth = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; - - if (this.element.value) { - this.element.value = ''; - } - - if (setWidth) { - this.setWidth(); - } - - return this.parentInstance; - } - - /** - * Set the correct input width based on placeholder - * value or input value - * @return - */ - - }, { - key: 'setWidth', - value: function setWidth(enforceWidth) { - if (this.parentInstance.placeholder) { - // If there is a placeholder, we only want to set the width of the input when it is a greater - // length than 75% of the placeholder. This stops the input jumping around. - if (this.element.value && this.element.value.length >= this.parentInstance.placeholder.length / 1.25 || enforceWidth) { - this.element.style.width = this.getWidth(); - } - } else { - // If there is no placeholder, resize input to contents - this.element.style.width = this.getWidth(); - } - } - }, { - key: 'getWidth', - value: function getWidth() { - return getWidthOfInput(this.element); - } - }, { - key: 'setPlaceholder', - value: function setPlaceholder(placeholder) { - this.element.placeholder = placeholder; - } - }, { - key: 'setValue', - value: function setValue(value) { - this.element.value = value; - } - }, { - key: 'getValue', - value: function getValue() { - return this.element.value; - } - }, { - key: 'setActiveDescendant', - value: function setActiveDescendant(activeDescendantID) { - this.element.setAttribute('aria-activedescendant', activeDescendantID); - } - }, { - key: 'removeActiveDescendant', - value: function removeActiveDescendant() { - this.element.removeAttribute('aria-activedescendant'); - } - }]); - - return Input; -}(); - -/* harmony default export */ var components_input = (input_Input); -// CONCATENATED MODULE: ./src/scripts/src/components/list.js -var list__createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -function list__classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -var List = function () { - function List(instance, element, classNames) { - list__classCallCheck(this, List); - - this.parentInstance = instance; - this.element = element; - this.classNames = classNames; - this.scrollPos = this.element.scrollTop; - this.height = this.element.offsetHeight; - this.hasChildren = !!this.element.children; - } - - list__createClass(List, [{ - key: 'getElement', - value: function getElement() { - return this.element; - } - - /** - * Clear List contents - */ - - }, { - key: 'clear', - value: function clear() { - this.element.innerHTML = ''; - } - - /** - * Scroll to passed position on Y axis - */ - - }, { - key: 'scrollTo', - value: function scrollTo() { - var scrollPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; - - this.element.scrollTop = scrollPos; - } - /** - * Append node to element - */ - - }, { - key: 'append', - value: function append(node) { - this.element.appendChild(node); - } - - /** - * Find element that matches passed selector - * @return {HTMLElement} - */ - - }, { - key: 'getChild', - value: function getChild(selector) { - return this.element.querySelector(selector); - } - }]); - - return List; -}(); - -/* harmony default export */ var list = (List); -// CONCATENATED MODULE: ./src/scripts/src/components/wrapped-element.js -var wrapped_element__createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -function wrapped_element__classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - - -var wrapped_element_WrappedElement = function () { +var WrappedElement = function () { function WrappedElement(instance, element, classNames) { - wrapped_element__classCallCheck(this, WrappedElement); + _classCallCheck(this, WrappedElement); this.parentInstance = instance; this.element = element; @@ -2610,7 +1670,7 @@ var wrapped_element_WrappedElement = function () { this.isDisabled = false; } - wrapped_element__createClass(WrappedElement, [{ + _createClass(WrappedElement, [{ key: 'getElement', value: function getElement() { return this.element; @@ -2679,503 +1739,102 @@ var wrapped_element_WrappedElement = function () { }, { key: 'triggerEvent', value: function triggerEvent(eventType, data) { - dispatchEvent(this.element, eventType, data); + (0, _utils.dispatchEvent)(this.element, eventType, data); } }]); return WrappedElement; }(); -/* harmony default export */ var wrapped_element = (wrapped_element_WrappedElement); -// CONCATENATED MODULE: ./src/scripts/src/components/wrapped-input.js -var wrapped_input__createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +exports.default = WrappedElement; -var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; +/***/ }), +/* 5 */ +/***/ (function(module, exports, __webpack_require__) { -function wrapped_input__classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } +module.exports = __webpack_require__(6); +/***/ }), +/* 6 */ +/***/ (function(module, exports, __webpack_require__) { -var WrappedInput = function (_WrappedElement) { - _inherits(WrappedInput, _WrappedElement); - - function WrappedInput(instance, element, classNames) { - wrapped_input__classCallCheck(this, WrappedInput); - - var _this = _possibleConstructorReturn(this, (WrappedInput.__proto__ || Object.getPrototypeOf(WrappedInput)).call(this, instance, element, classNames)); - - _this.parentInstance = instance; - _this.element = element; - _this.classNames = classNames; - return _this; - } - - wrapped_input__createClass(WrappedInput, [{ - key: 'getElement', - value: function getElement() { - _get(WrappedInput.prototype.__proto__ || Object.getPrototypeOf(WrappedInput.prototype), 'getElement', this).call(this); - } - }, { - key: 'conceal', - value: function conceal() { - _get(WrappedInput.prototype.__proto__ || Object.getPrototypeOf(WrappedInput.prototype), 'conceal', this).call(this); - } - }, { - key: 'reveal', - value: function reveal() { - _get(WrappedInput.prototype.__proto__ || Object.getPrototypeOf(WrappedInput.prototype), 'reveal', this).call(this); - } - }, { - key: 'enable', - value: function enable() { - _get(WrappedInput.prototype.__proto__ || Object.getPrototypeOf(WrappedInput.prototype), 'enable', this).call(this); - } - }, { - key: 'disable', - value: function disable() { - _get(WrappedInput.prototype.__proto__ || Object.getPrototypeOf(WrappedInput.prototype), 'enable', this).call(this); - } - }, { - key: 'setValue', - value: function setValue(value) { - this.element.setAttribute('value', value); - this.element.value = value; - } - }]); - - return WrappedInput; -}(wrapped_element); - -/* harmony default export */ var wrapped_input = (WrappedInput); -// CONCATENATED MODULE: ./src/scripts/src/components/wrapped-select.js -var wrapped_select__createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var wrapped_select__get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; - -function wrapped_select__classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function wrapped_select__possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function wrapped_select__inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } +"use strict"; +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; -var WrappedSelect = function (_WrappedElement) { - wrapped_select__inherits(WrappedSelect, _WrappedElement); +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - function WrappedSelect(instance, element, classNames) { - wrapped_select__classCallCheck(this, WrappedSelect); +var _fuse = __webpack_require__(7); - var _this = wrapped_select__possibleConstructorReturn(this, (WrappedSelect.__proto__ || Object.getPrototypeOf(WrappedSelect)).call(this, instance, element, classNames)); +var _fuse2 = _interopRequireDefault(_fuse); - _this.parentInstance = instance; - _this.element = element; - _this.classNames = classNames; - return _this; - } +var _store = __webpack_require__(8); - wrapped_select__createClass(WrappedSelect, [{ - key: 'getElement', - value: function getElement() { - wrapped_select__get(WrappedSelect.prototype.__proto__ || Object.getPrototypeOf(WrappedSelect.prototype), 'getElement', this).call(this); - } - }, { - key: 'conceal', - value: function conceal() { - wrapped_select__get(WrappedSelect.prototype.__proto__ || Object.getPrototypeOf(WrappedSelect.prototype), 'conceal', this).call(this); - } - }, { - key: 'reveal', - value: function reveal() { - wrapped_select__get(WrappedSelect.prototype.__proto__ || Object.getPrototypeOf(WrappedSelect.prototype), 'reveal', this).call(this); - } - }, { - key: 'enable', - value: function enable() { - wrapped_select__get(WrappedSelect.prototype.__proto__ || Object.getPrototypeOf(WrappedSelect.prototype), 'enable', this).call(this); - } - }, { - key: 'disable', - value: function disable() { - wrapped_select__get(WrappedSelect.prototype.__proto__ || Object.getPrototypeOf(WrappedSelect.prototype), 'enable', this).call(this); - } - }, { - key: 'setOptions', - value: function setOptions(options) { - this.element.innerHTML = ''; - this.element.appendChild(options); - } - }, { - key: 'getPlaceholderOption', - value: function getPlaceholderOption() { - return this.element.querySelector('option[placeholder]'); - } - }, { - key: 'getOptions', - value: function getOptions() { - return Array.from(this.element.options); - } - }, { - key: 'getOptionGroups', - value: function getOptionGroups() { - return Array.from(this.element.getElementsByTagName('OPTGROUP')); - } - }]); +var _store2 = _interopRequireDefault(_store); - return WrappedSelect; -}(wrapped_element); +var _dropdown = __webpack_require__(18); -/* harmony default export */ var wrapped_select = (WrappedSelect); -// CONCATENATED MODULE: ./src/scripts/src/constants.js +var _dropdown2 = _interopRequireDefault(_dropdown); -var DEFAULT_CLASSNAMES = { - containerOuter: 'choices', - containerInner: 'choices__inner', - input: 'choices__input', - inputCloned: 'choices__input--cloned', - list: 'choices__list', - listItems: 'choices__list--multiple', - listSingle: 'choices__list--single', - listDropdown: 'choices__list--dropdown', - item: 'choices__item', - itemSelectable: 'choices__item--selectable', - itemDisabled: 'choices__item--disabled', - itemChoice: 'choices__item--choice', - placeholder: 'choices__placeholder', - group: 'choices__group', - groupHeading: 'choices__heading', - button: 'choices__button', - activeState: 'is-active', - focusState: 'is-focused', - openState: 'is-open', - disabledState: 'is-disabled', - highlightedState: 'is-highlighted', - hiddenState: 'is-hidden', - flippedState: 'is-flipped', - loadingState: 'is-loading', - noResults: 'has-no-results', - noChoices: 'has-no-choices' -}; +var _container = __webpack_require__(19); -var DEFAULT_CONFIG = { - silent: false, - renderChoiceLimit: -1, - maxItemCount: -1, - addItems: true, - removeItems: true, - removeItemButton: false, - editItems: false, - duplicateItems: true, - delimiter: ',', - paste: true, - searchEnabled: true, - searchChoices: true, - searchFloor: 1, - searchResultLimit: 4, - searchFields: ['label', 'value'], - position: 'auto', - resetScrollPosition: true, - regexFilter: null, - shouldSort: true, - shouldSortItems: false, - placeholder: true, - placeholderValue: null, - searchPlaceholderValue: null, - prependValue: null, - appendValue: null, - renderSelectedChoices: 'auto', - loadingText: 'Loading...', - noResultsText: 'No results found', - noChoicesText: 'No choices to choose from', - itemSelectText: 'Press to select', - addItemText: function addItemText(value) { - return 'Press Enter to add "' + value + '"'; - }, - maxItemText: function maxItemText(maxItemCount) { - return 'Only ' + maxItemCount + ' values can be added.'; - }, - uniqueItemText: 'Only unique values can be added.', - fuseOptions: { - includeScore: true - }, - callbackOnInit: null, - callbackOnCreateTemplates: null -}; +var _container2 = _interopRequireDefault(_container); -var EVENTS = { - showDropdown: 'showDropdown', - hideDropdown: 'hideDropdown', - change: 'change', - choice: 'choice', - search: 'search', - addItem: 'addItem', - removeItem: 'removeItem', - highlightItem: 'highlightItem' -}; +var _input = __webpack_require__(20); -var ACTION_TYPES = { - ADD_CHOICE: 'ADD_CHOICE', - FILTER_CHOICES: 'FILTER_CHOICES', - ACTIVATE_CHOICES: 'ACTIVATE_CHOICES', - CLEAR_CHOICES: 'CLEAR_CHOICES', - ADD_GROUP: 'ADD_GROUP', - ADD_ITEM: 'ADD_ITEM', - REMOVE_ITEM: 'REMOVE_ITEM', - HIGHLIGHT_ITEM: 'HIGHLIGHT_ITEM', - CLEAR_ALL: 'CLEAR_ALL' -}; +var _input2 = _interopRequireDefault(_input); -var KEY_CODES = { - BACK_KEY: 46, - DELETE_KEY: 8, - ENTER_KEY: 13, - A_KEY: 65, - ESC_KEY: 27, - UP_KEY: 38, - DOWN_KEY: 40, - PAGE_UP_KEY: 33, - PAGE_DOWN_KEY: 34 -}; +var _list = __webpack_require__(21); -var SCROLLING_SPEED = 4; -// EXTERNAL MODULE: ./node_modules/classnames/index.js -var classnames = __webpack_require__(9); -var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames); +var _list2 = _interopRequireDefault(_list); + +var _wrappedInput = __webpack_require__(22); + +var _wrappedInput2 = _interopRequireDefault(_wrappedInput); + +var _wrappedSelect = __webpack_require__(23); + +var _wrappedSelect2 = _interopRequireDefault(_wrappedSelect); + +var _constants = __webpack_require__(1); + +var _templates = __webpack_require__(24); + +var _choices = __webpack_require__(26); + +var _items = __webpack_require__(27); + +var _groups = __webpack_require__(28); + +var _misc = __webpack_require__(29); + +var _utils = __webpack_require__(0); + +__webpack_require__(30); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -// CONCATENATED MODULE: ./src/scripts/src/templates.js function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } - - -var TEMPLATES = { - containerOuter: function containerOuter(globalClasses, direction, isSelectElement, isSelectOneElement, searchEnabled, passedElementType) { - var tabIndex = isSelectOneElement ? 'tabindex="0"' : ''; - var role = isSelectElement ? 'role="listbox"' : ''; - var ariaAutoComplete = ''; - - if (isSelectElement && searchEnabled) { - role = 'role="combobox"'; - ariaAutoComplete = 'aria-autocomplete="list"'; - } - - return strToEl('\n