Version 3.0.3

This commit is contained in:
Josh Johnson 2018-01-04 11:35:32 +00:00
parent 3169d8c3d7
commit 40cc462133
7 changed files with 154 additions and 152 deletions

View file

@ -1,4 +1,4 @@
/*! choices.js v3.0.2 | (c) 2018 Josh Johnson | https://github.com/jshjohnson/Choices#readme */
/*! choices.js v3.0.3 | (c) 2018 Josh Johnson | https://github.com/jshjohnson/Choices#readme */
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
@ -576,7 +576,9 @@ return /******/ (function(modules) { // webpackBootstrap
}, {
key: 'render',
value: function render() {
if (this.store.isLoading()) return;
if (this.store.isLoading()) {
return;
}
this.currentState = this.store.getState();
@ -5232,10 +5234,10 @@ return /******/ (function(modules) { // webpackBootstrap
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
/*
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(_toConsumableArray(state), [{
id: action.id,
@ -5479,10 +5481,10 @@ return /******/ (function(modules) { // webpackBootstrap
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
/**
* 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) {
@ -5490,10 +5492,10 @@ return /******/ (function(modules) { // webpackBootstrap
});
};
/**
* Generates a string of random chars
* @param {Number} length Length of the string to generate
* @return {String} String of random chars
/**
* 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 = '';
@ -5506,11 +5508,11 @@ return /******/ (function(modules) { // webpackBootstrap
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
/**
* 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);
@ -5520,58 +5522,58 @@ return /******/ (function(modules) { // webpackBootstrap
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}
/**
* 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}
/**
* 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}
/**
* 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}
/**
* 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
/**
* 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
/**
* Merge one object into another
* @param {Object} obj Object to merge into extended object
*/
var merge = function merge(obj) {
for (var prop in obj) {
@ -5600,9 +5602,9 @@ return /******/ (function(modules) { // webpackBootstrap
return extended;
};
/**
* CSS transition end event listener
* @return
/**
* CSS transition end event listener
* @return
*/
var whichTransitionEvent = exports.whichTransitionEvent = function whichTransitionEvent() {
var t,
@ -5622,9 +5624,9 @@ return /******/ (function(modules) { // webpackBootstrap
}
};
/**
* CSS animation end event listener
* @return
/**
* CSS animation end event listener
* @return
*/
var whichAnimationEvent = exports.whichAnimationEvent = function whichAnimationEvent() {
var t,
@ -5644,13 +5646,13 @@ return /******/ (function(modules) { // webpackBootstrap
}
};
/**
* 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
/**
* 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 = [];
@ -5750,22 +5752,22 @@ return /******/ (function(modules) { // webpackBootstrap
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
/**
* 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
/**
* 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;
@ -5781,12 +5783,12 @@ return /******/ (function(modules) { // webpackBootstrap
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
/**
* 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;
@ -5804,11 +5806,11 @@ return /******/ (function(modules) { // webpackBootstrap
};
};
/**
* 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
/**
* 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;
@ -5821,11 +5823,11 @@ return /******/ (function(modules) { // webpackBootstrap
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
/**
* 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;
@ -5835,12 +5837,12 @@ return /******/ (function(modules) { // webpackBootstrap
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
/**
* 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;
@ -5856,10 +5858,10 @@ return /******/ (function(modules) { // webpackBootstrap
return children[startPos + operatorDirection];
};
/**
* Get scroll position based on top/bottom position
* @private
* @return {String} Position of scroll
/**
* Get scroll position based on top/bottom position
* @private
* @return {String} Position of scroll
*/
var getScrollPosition = exports.getScrollPosition = function getScrollPosition(position) {
if (position === 'bottom') {
@ -5871,23 +5873,23 @@ return /******/ (function(modules) { // webpackBootstrap
}
};
/**
* Determine whether an element is within the viewport
* @param {HTMLElement} el Element to test
* @return {String} Position of scroll
* @return {Boolean}
/**
* 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) ? true : false;
};
/**
* 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}
/**
* 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;
@ -5907,10 +5909,10 @@ return /******/ (function(modules) { // webpackBootstrap
return isVisible;
};
/**
* Remove html tags from a string
* @param {String} Initial string/html
* @return {String} Sanitised string
/**
* 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");
@ -5918,11 +5920,11 @@ return /******/ (function(modules) { // webpackBootstrap
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
/**
* 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();
@ -5936,20 +5938,20 @@ return /******/ (function(modules) { // webpackBootstrap
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
/**
* 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
/**
* 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');
@ -5967,9 +5969,9 @@ return /******/ (function(modules) { // webpackBootstrap
};
}();
/**
* Sets the width of a passed input based on its value
* @return {Number} Width of input
/**
* 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;
@ -6010,13 +6012,13 @@ return /******/ (function(modules) { // webpackBootstrap
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
/**
* 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();
@ -6027,24 +6029,24 @@ return /******/ (function(modules) { // webpackBootstrap
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
/**
* 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;
};
/**
* Trigger 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
/**
* Trigger 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 triggerEvent = exports.triggerEvent = function triggerEvent(element, type) {
var customArgs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
{
"name": "choices.js",
"version": "3.0.2",
"version": "3.0.3",
"description": "A vanilla JS customisable text input/select box plugin",
"main": [
"./assets/scripts/dist/choices.js",

View file

@ -16,7 +16,7 @@
<meta name="theme-color" content="#ffffff">
<!-- Ignore these -->
<link rel="stylesheet" href="assets/styles/css/base.min.css?version=3.0.2">
<link rel="stylesheet" href="assets/styles/css/base.min.css?version=3.0.3">
<!-- End ignore these -->
<!-- Optional includes -->
@ -24,7 +24,7 @@
<!-- End optional includes -->
<!-- Choices includes -->
<link rel="stylesheet" href="assets/styles/css/choices.min.css?version=3.0.2">
<link rel="stylesheet" href="assets/styles/css/choices.min.css?version=3.0.3">
<script src="assets/scripts/dist/choices.min.js?version=2.8.8"></script>
<!-- End Choices includes -->

View file

@ -1,6 +1,6 @@
{
"name": "choices.js",
"version": "3.0.2",
"version": "3.0.3",
"description": "A vanilla JS customisable text input/select box plugin",
"main": "./assets/scripts/dist/choices.min.js",
"scripts": {

View file

@ -1,4 +1,4 @@
// Example usage: npm --newVersion=3.0.2 run version
// Example usage: npm --newVersion=3.0.3 run version
const fs = require('fs');
const path = require('path');