mirror of
https://github.com/Choices-js/Choices.git
synced 2024-05-11 18:16:35 +02:00
Merge into latest
This commit is contained in:
parent
fe6208f427
commit
bfb6571ce9
|
@ -82,23 +82,6 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||||
/* 0 */
|
/* 0 */
|
||||||
/***/ (function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
var store = __webpack_require__(26)('wks');
|
|
||||||
var uid = __webpack_require__(14);
|
|
||||||
var Symbol = __webpack_require__(2).Symbol;
|
|
||||||
var USE_SYMBOL = typeof Symbol == 'function';
|
|
||||||
|
|
||||||
var $exports = module.exports = function (name) {
|
|
||||||
return store[name] || (store[name] =
|
|
||||||
USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));
|
|
||||||
};
|
|
||||||
|
|
||||||
$exports.store = store;
|
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
/* 1 */
|
|
||||||
/***/ (function(module, exports, __webpack_require__) {
|
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
||||||
|
@ -110,6 +93,16 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
||||||
|
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a string of random chars
|
* Generates a string of random chars
|
||||||
* @param {Number} length Length of the string to generate
|
* @param {Number} length Length of the string to generate
|
||||||
|
@ -167,8 +160,8 @@ var isType = exports.isType = function isType(type, obj) {
|
||||||
* @return {Boolean}
|
* @return {Boolean}
|
||||||
*/
|
*/
|
||||||
var isElement = exports.isElement = function isElement(o) {
|
var isElement = exports.isElement = function isElement(o) {
|
||||||
return (typeof HTMLElement === 'undefined' ? 'undefined' : _typeof(HTMLElement)) === 'object' ? o instanceof HTMLElement : // DOM2
|
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';
|
: o && (typeof o === 'undefined' ? 'undefined' : _typeof(o)) === 'object' && o !== null && o.nodeType === 1 && typeof o.nodeName === 'string';
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -299,7 +292,7 @@ var isScrolledIntoView = exports.isScrolledIntoView = function isScrolledIntoVie
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Escape html in the string
|
* Escapes html in the string
|
||||||
* @param {String} html Initial string/html
|
* @param {String} html Initial string/html
|
||||||
* @return {String} Sanitised string
|
* @return {String} Sanitised string
|
||||||
*/
|
*/
|
||||||
|
@ -307,16 +300,6 @@ var stripHTML = exports.stripHTML = function stripHTML(html) {
|
||||||
return html.replace(/&/g, '&').replace(/>/g, '&rt;').replace(/</g, '<').replace(/"/g, '"');
|
return html.replace(/&/g, '&').replace(/>/g, '&rt;').replace(/</g, '<').replace(/"/g, '"');
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
* Turn a string into a node
|
||||||
* @param {String} String to convert
|
* @param {String} String to convert
|
||||||
|
@ -339,10 +322,10 @@ var strToEl = exports.strToEl = function () {
|
||||||
}();
|
}();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the width of a passed input based on its value
|
* Determines the width of a passed input based on its value and passes
|
||||||
* @return {Number} Width of input
|
* it to the supplied callback function.
|
||||||
*/
|
*/
|
||||||
var calcWidthOfInput = exports.calcWidthOfInput = function calcWidthOfInput(input) {
|
var calcWidthOfInput = exports.calcWidthOfInput = function calcWidthOfInput(input, callback) {
|
||||||
var value = input.value || input.placeholder;
|
var value = input.value || input.placeholder;
|
||||||
var width = input.offsetWidth;
|
var width = input.offsetWidth;
|
||||||
|
|
||||||
|
@ -371,14 +354,18 @@ var calcWidthOfInput = exports.calcWidthOfInput = function calcWidthOfInput(inpu
|
||||||
|
|
||||||
document.body.appendChild(testEl);
|
document.body.appendChild(testEl);
|
||||||
|
|
||||||
if (value && testEl.offsetWidth !== input.offsetWidth) {
|
requestAnimationFrame(function () {
|
||||||
width = testEl.offsetWidth + 4;
|
if (value && testEl.offsetWidth !== input.offsetWidth) {
|
||||||
}
|
width = testEl.offsetWidth + 4;
|
||||||
|
}
|
||||||
|
|
||||||
document.body.removeChild(testEl);
|
document.body.removeChild(testEl);
|
||||||
|
|
||||||
|
callback.call(undefined, width + 'px');
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
callback.call(undefined, width + 'px');
|
||||||
}
|
}
|
||||||
|
|
||||||
return width + 'px';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -490,6 +477,33 @@ var existsInArray = exports.existsInArray = function existsInArray(array, value)
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deep clone an object
|
||||||
|
* @param {Object} obj Object to clone
|
||||||
|
* @return {Object} Clone of the object
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
var cloneObject = exports.cloneObject = function cloneObject(obj) {
|
||||||
|
return JSON.parse(JSON.stringify(obj));
|
||||||
|
};
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
/* 1 */
|
||||||
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
|
var store = __webpack_require__(26)('wks');
|
||||||
|
var uid = __webpack_require__(14);
|
||||||
|
var Symbol = __webpack_require__(2).Symbol;
|
||||||
|
var USE_SYMBOL = typeof Symbol == 'function';
|
||||||
|
|
||||||
|
var $exports = module.exports = function (name) {
|
||||||
|
return store[name] || (store[name] =
|
||||||
|
USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));
|
||||||
|
};
|
||||||
|
|
||||||
|
$exports.store = store;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
/* 2 */
|
/* 2 */
|
||||||
/***/ (function(module, exports) {
|
/***/ (function(module, exports) {
|
||||||
|
@ -522,7 +536,7 @@ Object.defineProperty(exports, "__esModule", {
|
||||||
});
|
});
|
||||||
exports.SCROLLING_SPEED = exports.KEY_CODES = exports.ACTION_TYPES = exports.EVENTS = exports.DEFAULT_CONFIG = exports.DEFAULT_CLASSNAMES = undefined;
|
exports.SCROLLING_SPEED = exports.KEY_CODES = exports.ACTION_TYPES = exports.EVENTS = exports.DEFAULT_CONFIG = exports.DEFAULT_CLASSNAMES = undefined;
|
||||||
|
|
||||||
var _utils = __webpack_require__(1);
|
var _utils = __webpack_require__(0);
|
||||||
|
|
||||||
var DEFAULT_CLASSNAMES = exports.DEFAULT_CLASSNAMES = {
|
var DEFAULT_CLASSNAMES = exports.DEFAULT_CLASSNAMES = {
|
||||||
containerOuter: 'choices',
|
containerOuter: 'choices',
|
||||||
|
@ -996,7 +1010,7 @@ module.exports = (
|
||||||
|
|
||||||
var def = __webpack_require__(6).f;
|
var def = __webpack_require__(6).f;
|
||||||
var has = __webpack_require__(9);
|
var has = __webpack_require__(9);
|
||||||
var TAG = __webpack_require__(0)('toStringTag');
|
var TAG = __webpack_require__(1)('toStringTag');
|
||||||
|
|
||||||
module.exports = function (it, tag, stat) {
|
module.exports = function (it, tag, stat) {
|
||||||
if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag });
|
if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag });
|
||||||
|
@ -1865,7 +1879,7 @@ Object.defineProperty(exports, "__esModule", {
|
||||||
|
|
||||||
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; }; }();
|
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; }; }();
|
||||||
|
|
||||||
var _utils = __webpack_require__(1);
|
var _utils = __webpack_require__(0);
|
||||||
|
|
||||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
|
@ -1973,7 +1987,7 @@ var _classnames = __webpack_require__(79);
|
||||||
|
|
||||||
var _classnames2 = _interopRequireDefault(_classnames);
|
var _classnames2 = _interopRequireDefault(_classnames);
|
||||||
|
|
||||||
var _utils = __webpack_require__(1);
|
var _utils = __webpack_require__(0);
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
@ -2110,7 +2124,7 @@ var _groups = __webpack_require__(82);
|
||||||
|
|
||||||
var _misc = __webpack_require__(83);
|
var _misc = __webpack_require__(83);
|
||||||
|
|
||||||
var _utils = __webpack_require__(1);
|
var _utils = __webpack_require__(0);
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
@ -2178,6 +2192,7 @@ var Choices = function () {
|
||||||
|
|
||||||
this._store = new _store3.default(this.render);
|
this._store = new _store3.default(this.render);
|
||||||
this.initialised = false;
|
this.initialised = false;
|
||||||
|
this._initialState = {};
|
||||||
this._currentState = {};
|
this._currentState = {};
|
||||||
this._prevState = {};
|
this._prevState = {};
|
||||||
this._currentValue = '';
|
this._currentValue = '';
|
||||||
|
@ -2207,6 +2222,7 @@ var Choices = function () {
|
||||||
this._onTouchEnd = this._onTouchEnd.bind(this);
|
this._onTouchEnd = this._onTouchEnd.bind(this);
|
||||||
this._onMouseDown = this._onMouseDown.bind(this);
|
this._onMouseDown = this._onMouseDown.bind(this);
|
||||||
this._onMouseOver = this._onMouseOver.bind(this);
|
this._onMouseOver = this._onMouseOver.bind(this);
|
||||||
|
this._onFormReset = this._onFormReset.bind(this);
|
||||||
|
|
||||||
// If element has already been initialised with Choices, fail silently
|
// If element has already been initialised with Choices, fail silently
|
||||||
if (this.passedElement.element.getAttribute('data-choice') === 'active') {
|
if (this.passedElement.element.getAttribute('data-choice') === 'active') {
|
||||||
|
@ -2236,6 +2252,9 @@ var Choices = function () {
|
||||||
this._createElements();
|
this._createElements();
|
||||||
// Generate input markup
|
// Generate input markup
|
||||||
this._createStructure();
|
this._createStructure();
|
||||||
|
// Set initial state (We need to clone the state because some reducers
|
||||||
|
// modify the inner objects properties in the state) 🤢
|
||||||
|
this._initialState = (0, _utils.cloneObject)(this._store.state);
|
||||||
// Subscribe store to render method
|
// Subscribe store to render method
|
||||||
this._store.subscribe(this.render);
|
this._store.subscribe(this.render);
|
||||||
// Render any items
|
// Render any items
|
||||||
|
@ -3075,6 +3094,10 @@ var Choices = function () {
|
||||||
this.input.element.addEventListener('focus', this._onFocus);
|
this.input.element.addEventListener('focus', this._onFocus);
|
||||||
this.input.element.addEventListener('blur', this._onBlur);
|
this.input.element.addEventListener('blur', this._onBlur);
|
||||||
|
|
||||||
|
if (this.input.element.form) {
|
||||||
|
this.input.element.form.addEventListener('reset', this._onFormReset);
|
||||||
|
}
|
||||||
|
|
||||||
this.input.addEventListeners();
|
this.input.addEventListeners();
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
|
@ -3095,6 +3118,11 @@ var Choices = function () {
|
||||||
|
|
||||||
this.input.element.removeEventListener('focus', this._onFocus);
|
this.input.element.removeEventListener('focus', this._onFocus);
|
||||||
this.input.element.removeEventListener('blur', this._onBlur);
|
this.input.element.removeEventListener('blur', this._onBlur);
|
||||||
|
|
||||||
|
if (this.input.element.form) {
|
||||||
|
this.input.element.form.removeEventListener('reset', this._onFormReset);
|
||||||
|
}
|
||||||
|
|
||||||
this.input.removeEventListeners();
|
this.input.removeEventListeners();
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
|
@ -3134,8 +3162,6 @@ var Choices = function () {
|
||||||
this.showDropdown(true);
|
this.showDropdown(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.config.searchEnabled = this.config.searchEnabled;
|
|
||||||
|
|
||||||
var onAKey = function onAKey() {
|
var onAKey = function onAKey() {
|
||||||
// If CTRL + A or CMD + A have been pressed and there are items to select
|
// If CTRL + A or CMD + A have been pressed and there are items to select
|
||||||
if (ctrlDownKey && hasItems) {
|
if (ctrlDownKey && hasItems) {
|
||||||
|
@ -3289,7 +3315,6 @@ var Choices = function () {
|
||||||
|
|
||||||
// If user has removed value...
|
// If user has removed value...
|
||||||
if ((keyCode === backKey || keyCode === deleteKey) && !target.value) {
|
if ((keyCode === backKey || keyCode === deleteKey) && !target.value) {
|
||||||
// ...and it is a multiple select input, activate choices (if searching)
|
|
||||||
if (!this._isTextElement && this._isSearching) {
|
if (!this._isTextElement && this._isSearching) {
|
||||||
this._isSearching = false;
|
this._isSearching = false;
|
||||||
this._store.dispatch((0, _choices.activateChoices)(true));
|
this._store.dispatch((0, _choices.activateChoices)(true));
|
||||||
|
@ -3316,7 +3341,10 @@ var Choices = function () {
|
||||||
// If a user tapped within our container...
|
// If a user tapped within our container...
|
||||||
if (this._wasTap === true && this.containerOuter.element.contains(target)) {
|
if (this._wasTap === true && this.containerOuter.element.contains(target)) {
|
||||||
// ...and we aren't dealing with a single select box, show dropdown/focus input
|
// ...and we aren't dealing with a single select box, show dropdown/focus input
|
||||||
if ((target === this.containerOuter.element || target === this.containerInner.element) && !this._isSelectOneElement) {
|
|
||||||
|
var containerWasTarget = target === this.containerOuter.element || target === this.containerInner.element;
|
||||||
|
|
||||||
|
if (containerWasTarget && !this._isSelectOneElement) {
|
||||||
if (this._isTextElement) {
|
if (this._isTextElement) {
|
||||||
// If text element, we only want to focus the input
|
// If text element, we only want to focus the input
|
||||||
this.input.focus();
|
this.input.focus();
|
||||||
|
@ -3391,8 +3419,7 @@ var Choices = function () {
|
||||||
this.showDropdown(true);
|
this.showDropdown(true);
|
||||||
} else {
|
} else {
|
||||||
this.showDropdown();
|
this.showDropdown();
|
||||||
// code smell
|
this.containerOuter.focus(); // code smell 🤢
|
||||||
this.containerOuter.focus();
|
|
||||||
}
|
}
|
||||||
} else if (this._isSelectOneElement && target !== this.input.element && !this.dropdown.element.contains(target)) {
|
} else if (this._isSelectOneElement && target !== this.input.element && !this.dropdown.element.contains(target)) {
|
||||||
this.hideDropdown(true);
|
this.hideDropdown(true);
|
||||||
|
@ -3430,7 +3457,6 @@ var Choices = function () {
|
||||||
'select-one': function selectOne() {
|
'select-one': function selectOne() {
|
||||||
_this18.containerOuter.addFocusState();
|
_this18.containerOuter.addFocusState();
|
||||||
if (target === _this18.input.element) {
|
if (target === _this18.input.element) {
|
||||||
// Show dropdown if it isn't already showing
|
|
||||||
_this18.showDropdown();
|
_this18.showDropdown();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -3462,9 +3488,7 @@ var Choices = function () {
|
||||||
var blurActions = {
|
var blurActions = {
|
||||||
text: function text() {
|
text: function text() {
|
||||||
if (target === _this19.input.element) {
|
if (target === _this19.input.element) {
|
||||||
// Remove the focus state
|
|
||||||
_this19.containerOuter.removeFocusState();
|
_this19.containerOuter.removeFocusState();
|
||||||
// De-select any highlighted items
|
|
||||||
if (hasHighlightedItems) {
|
if (hasHighlightedItems) {
|
||||||
_this19.unhighlightAll();
|
_this19.unhighlightAll();
|
||||||
}
|
}
|
||||||
|
@ -3479,10 +3503,8 @@ var Choices = function () {
|
||||||
},
|
},
|
||||||
'select-multiple': function selectMultiple() {
|
'select-multiple': function selectMultiple() {
|
||||||
if (target === _this19.input.element) {
|
if (target === _this19.input.element) {
|
||||||
// Remove the focus state
|
|
||||||
_this19.containerOuter.removeFocusState();
|
_this19.containerOuter.removeFocusState();
|
||||||
_this19.hideDropdown();
|
_this19.hideDropdown();
|
||||||
// De-select any highlighted items
|
|
||||||
if (hasHighlightedItems) {
|
if (hasHighlightedItems) {
|
||||||
_this19.unhighlightAll();
|
_this19.unhighlightAll();
|
||||||
}
|
}
|
||||||
|
@ -3499,6 +3521,11 @@ var Choices = function () {
|
||||||
this.input.element.focus();
|
this.input.element.focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
key: '_onFormReset',
|
||||||
|
value: function _onFormReset() {
|
||||||
|
this._store.dispatch((0, _misc.resetTo)(this._initialState));
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
key: '_highlightChoice',
|
key: '_highlightChoice',
|
||||||
value: function _highlightChoice() {
|
value: function _highlightChoice() {
|
||||||
|
@ -3975,18 +4002,20 @@ var Choices = function () {
|
||||||
}, {
|
}, {
|
||||||
key: '_renderChoices',
|
key: '_renderChoices',
|
||||||
value: function _renderChoices() {
|
value: function _renderChoices() {
|
||||||
|
var _this26 = this;
|
||||||
|
|
||||||
var _store = this._store,
|
var _store = this._store,
|
||||||
activeGroups = _store.activeGroups,
|
activeGroups = _store.activeGroups,
|
||||||
activeChoices = _store.activeChoices;
|
activeChoices = _store.activeChoices;
|
||||||
|
|
||||||
var choiceListFragment = document.createDocumentFragment();
|
var choiceListFragment = document.createDocumentFragment();
|
||||||
|
|
||||||
// Clear choices
|
|
||||||
this.choiceList.clear();
|
this.choiceList.clear();
|
||||||
|
|
||||||
// Scroll back to top of choices list
|
|
||||||
if (this.config.resetScrollPosition) {
|
if (this.config.resetScrollPosition) {
|
||||||
this.choiceList.scrollToTop();
|
requestAnimationFrame(function () {
|
||||||
|
return _this26.choiceList.scrollToTop();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have grouped options
|
// If we have grouped options
|
||||||
|
@ -4075,7 +4104,6 @@ var Choices = function () {
|
||||||
}();
|
}();
|
||||||
|
|
||||||
Choices.userDefaults = {};
|
Choices.userDefaults = {};
|
||||||
|
|
||||||
// We cannot export default here due to Webpack: https://github.com/webpack/webpack/issues/3929
|
// We cannot export default here due to Webpack: https://github.com/webpack/webpack/issues/3929
|
||||||
module.exports = Choices;
|
module.exports = Choices;
|
||||||
|
|
||||||
|
@ -5161,7 +5189,7 @@ var Iterators = __webpack_require__(15);
|
||||||
var $iterCreate = __webpack_require__(45);
|
var $iterCreate = __webpack_require__(45);
|
||||||
var setToStringTag = __webpack_require__(28);
|
var setToStringTag = __webpack_require__(28);
|
||||||
var getPrototypeOf = __webpack_require__(54);
|
var getPrototypeOf = __webpack_require__(54);
|
||||||
var ITERATOR = __webpack_require__(0)('iterator');
|
var ITERATOR = __webpack_require__(1)('iterator');
|
||||||
var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next`
|
var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next`
|
||||||
var FF_ITERATOR = '@@iterator';
|
var FF_ITERATOR = '@@iterator';
|
||||||
var KEYS = 'keys';
|
var KEYS = 'keys';
|
||||||
|
@ -5272,7 +5300,7 @@ var setToStringTag = __webpack_require__(28);
|
||||||
var IteratorPrototype = {};
|
var IteratorPrototype = {};
|
||||||
|
|
||||||
// 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
|
// 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
|
||||||
__webpack_require__(5)(IteratorPrototype, __webpack_require__(0)('iterator'), function () { return this; });
|
__webpack_require__(5)(IteratorPrototype, __webpack_require__(1)('iterator'), function () { return this; });
|
||||||
|
|
||||||
module.exports = function (Constructor, NAME, next) {
|
module.exports = function (Constructor, NAME, next) {
|
||||||
Constructor.prototype = create(IteratorPrototype, { next: descriptor(1, next) });
|
Constructor.prototype = create(IteratorPrototype, { next: descriptor(1, next) });
|
||||||
|
@ -5531,7 +5559,7 @@ module.exports = function (iterator, fn, value, entries) {
|
||||||
|
|
||||||
// check on default Array iterator
|
// check on default Array iterator
|
||||||
var Iterators = __webpack_require__(15);
|
var Iterators = __webpack_require__(15);
|
||||||
var ITERATOR = __webpack_require__(0)('iterator');
|
var ITERATOR = __webpack_require__(1)('iterator');
|
||||||
var ArrayProto = Array.prototype;
|
var ArrayProto = Array.prototype;
|
||||||
|
|
||||||
module.exports = function (it) {
|
module.exports = function (it) {
|
||||||
|
@ -5559,7 +5587,7 @@ module.exports = function (object, index, value) {
|
||||||
/***/ (function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
var classof = __webpack_require__(60);
|
var classof = __webpack_require__(60);
|
||||||
var ITERATOR = __webpack_require__(0)('iterator');
|
var ITERATOR = __webpack_require__(1)('iterator');
|
||||||
var Iterators = __webpack_require__(15);
|
var Iterators = __webpack_require__(15);
|
||||||
module.exports = __webpack_require__(3).getIteratorMethod = function (it) {
|
module.exports = __webpack_require__(3).getIteratorMethod = function (it) {
|
||||||
if (it != undefined) return it[ITERATOR]
|
if (it != undefined) return it[ITERATOR]
|
||||||
|
@ -5574,7 +5602,7 @@ module.exports = __webpack_require__(3).getIteratorMethod = function (it) {
|
||||||
|
|
||||||
// getting tag from 19.1.3.6 Object.prototype.toString()
|
// getting tag from 19.1.3.6 Object.prototype.toString()
|
||||||
var cof = __webpack_require__(24);
|
var cof = __webpack_require__(24);
|
||||||
var TAG = __webpack_require__(0)('toStringTag');
|
var TAG = __webpack_require__(1)('toStringTag');
|
||||||
// ES3 wrong here
|
// ES3 wrong here
|
||||||
var ARG = cof(function () { return arguments; }()) == 'Arguments';
|
var ARG = cof(function () { return arguments; }()) == 'Arguments';
|
||||||
|
|
||||||
|
@ -5601,7 +5629,7 @@ module.exports = function (it) {
|
||||||
/* 61 */
|
/* 61 */
|
||||||
/***/ (function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
var ITERATOR = __webpack_require__(0)('iterator');
|
var ITERATOR = __webpack_require__(1)('iterator');
|
||||||
var SAFE_CLOSING = false;
|
var SAFE_CLOSING = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -6035,6 +6063,8 @@ var _choices = __webpack_require__(71);
|
||||||
|
|
||||||
var _choices2 = _interopRequireDefault(_choices);
|
var _choices2 = _interopRequireDefault(_choices);
|
||||||
|
|
||||||
|
var _utils = __webpack_require__(0);
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
var appReducer = (0, _redux.combineReducers)({
|
var appReducer = (0, _redux.combineReducers)({
|
||||||
|
@ -6051,6 +6081,8 @@ var rootReducer = function rootReducer(passedState, action) {
|
||||||
// See: http://stackoverflow.com/a/35641992
|
// See: http://stackoverflow.com/a/35641992
|
||||||
if (action.type === 'CLEAR_ALL') {
|
if (action.type === 'CLEAR_ALL') {
|
||||||
state = undefined;
|
state = undefined;
|
||||||
|
} else if (action.type === 'RESET_TO') {
|
||||||
|
return (0, _utils.cloneObject)(action.state);
|
||||||
}
|
}
|
||||||
|
|
||||||
return appReducer(state, action);
|
return appReducer(state, action);
|
||||||
|
@ -6452,7 +6484,7 @@ Object.defineProperty(exports, "__esModule", {
|
||||||
|
|
||||||
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; }; }();
|
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; }; }();
|
||||||
|
|
||||||
var _utils = __webpack_require__(1);
|
var _utils = __webpack_require__(0);
|
||||||
|
|
||||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
|
@ -6700,7 +6732,7 @@ Object.defineProperty(exports, "__esModule", {
|
||||||
|
|
||||||
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; }; }();
|
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; }; }();
|
||||||
|
|
||||||
var _utils = __webpack_require__(1);
|
var _utils = __webpack_require__(0);
|
||||||
|
|
||||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
|
@ -6734,6 +6766,10 @@ var Input = function () {
|
||||||
this.element.addEventListener('paste', this._onPaste);
|
this.element.addEventListener('paste', this._onPaste);
|
||||||
this.element.addEventListener('focus', this._onFocus);
|
this.element.addEventListener('focus', this._onFocus);
|
||||||
this.element.addEventListener('blur', this._onBlur);
|
this.element.addEventListener('blur', this._onBlur);
|
||||||
|
|
||||||
|
if (this.element.form) {
|
||||||
|
this.element.form.addEventListener('reset', this._onFormReset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
key: 'removeEventListeners',
|
key: 'removeEventListeners',
|
||||||
|
@ -6742,6 +6778,10 @@ var Input = function () {
|
||||||
this.element.removeEventListener('paste', this._onPaste);
|
this.element.removeEventListener('paste', this._onPaste);
|
||||||
this.element.removeEventListener('focus', this._onFocus);
|
this.element.removeEventListener('focus', this._onFocus);
|
||||||
this.element.removeEventListener('blur', this._onBlur);
|
this.element.removeEventListener('blur', this._onBlur);
|
||||||
|
|
||||||
|
if (this.element.form) {
|
||||||
|
this.element.form.removeEventListener('reset', this._onFormReset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
key: 'enable',
|
key: 'enable',
|
||||||
|
@ -6801,21 +6841,27 @@ var Input = function () {
|
||||||
}, {
|
}, {
|
||||||
key: 'setWidth',
|
key: 'setWidth',
|
||||||
value: function setWidth(enforceWidth) {
|
value: function setWidth(enforceWidth) {
|
||||||
|
var _this = this;
|
||||||
|
|
||||||
if (this._placeholderValue) {
|
if (this._placeholderValue) {
|
||||||
// If there is a placeholder, we only want to set the width of the input when it is a greater
|
// 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.
|
// length than 75% of the placeholder. This stops the input jumping around.
|
||||||
if (this.element.value && this.element.value.length >= this._placeholderValue.length / 1.25 || enforceWidth) {
|
if (this.element.value && this.element.value.length >= this._placeholderValue.length / 1.25 || enforceWidth) {
|
||||||
this.element.style.width = this.calcWidth();
|
this.calcWidth(function (width) {
|
||||||
|
_this.element.style.width = width;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// If there is no placeholder, resize input to contents
|
// If there is no placeholder, resize input to contents
|
||||||
this.element.style.width = this.calcWidth();
|
this.calcWidth(function (width) {
|
||||||
|
_this.element.style.width = width;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
key: 'calcWidth',
|
key: 'calcWidth',
|
||||||
value: function calcWidth() {
|
value: function calcWidth(callback) {
|
||||||
return (0, _utils.calcWidthOfInput)(this.element);
|
return (0, _utils.calcWidthOfInput)(this.element, callback);
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
key: 'setActiveDescendant',
|
key: 'setActiveDescendant',
|
||||||
|
@ -6827,13 +6873,6 @@ var Input = function () {
|
||||||
value: function removeActiveDescendant() {
|
value: function removeActiveDescendant() {
|
||||||
this.element.removeAttribute('aria-activedescendant');
|
this.element.removeAttribute('aria-activedescendant');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Input event
|
|
||||||
* @return
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
|
|
||||||
}, {
|
}, {
|
||||||
key: '_onInput',
|
key: '_onInput',
|
||||||
value: function _onInput() {
|
value: function _onInput() {
|
||||||
|
@ -6841,20 +6880,14 @@ var Input = function () {
|
||||||
this.setWidth();
|
this.setWidth();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Paste event
|
|
||||||
* @param {Object} e Event
|
|
||||||
* @return
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
|
|
||||||
}, {
|
}, {
|
||||||
key: '_onPaste',
|
key: '_onPaste',
|
||||||
value: function _onPaste(e) {
|
value: function _onPaste(event) {
|
||||||
|
var target = event.target;
|
||||||
// Disable pasting into the input if option has been set
|
// Disable pasting into the input if option has been set
|
||||||
if (e.target === this.element && this.preventPaste) {
|
|
||||||
e.preventDefault();
|
if (target === this.element && this.preventPaste) {
|
||||||
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
|
@ -6875,10 +6908,10 @@ var Input = function () {
|
||||||
}, {
|
}, {
|
||||||
key: 'value',
|
key: 'value',
|
||||||
set: function set(value) {
|
set: function set(value) {
|
||||||
this.element.value = value;
|
this.element.value = '' + value;
|
||||||
},
|
},
|
||||||
get: function get() {
|
get: function get() {
|
||||||
return this.element.value;
|
return (0, _utils.stripHTML)(this.element.value);
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
@ -6999,7 +7032,7 @@ var List = function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (continueAnimation) {
|
if (continueAnimation) {
|
||||||
requestAnimationFrame(function (time) {
|
requestAnimationFrame(function () {
|
||||||
_this2._animateScroll(time, endpoint, direction);
|
_this2._animateScroll(time, endpoint, direction);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -7030,7 +7063,7 @@ var _wrappedElement = __webpack_require__(32);
|
||||||
|
|
||||||
var _wrappedElement2 = _interopRequireDefault(_wrappedElement);
|
var _wrappedElement2 = _interopRequireDefault(_wrappedElement);
|
||||||
|
|
||||||
var _utils = __webpack_require__(1);
|
var _utils = __webpack_require__(0);
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
@ -7347,13 +7380,19 @@ var addGroup = exports.addGroup = function addGroup(value, id, active, disabled)
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
/* eslint-disable import/prefer-default-export */
|
|
||||||
var clearAll = exports.clearAll = function clearAll() {
|
var clearAll = exports.clearAll = function clearAll() {
|
||||||
return {
|
return {
|
||||||
type: 'CLEAR_ALL'
|
type: 'CLEAR_ALL'
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var resetTo = exports.resetTo = function resetTo(state) {
|
||||||
|
return {
|
||||||
|
type: 'RESET_TO',
|
||||||
|
state: state
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
/***/ })
|
/***/ })
|
||||||
/******/ ]);
|
/******/ ]);
|
||||||
});
|
});
|
||||||
|
|
File diff suppressed because one or more lines are too long
2
public/assets/scripts/choices.min.js
vendored
2
public/assets/scripts/choices.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -278,6 +278,31 @@
|
||||||
<option value="Liverpool Street">Liverpool Street</option>
|
<option value="Liverpool Street">Liverpool Street</option>
|
||||||
<option value="Kings Cross St. Pancras">Kings Cross St. Pancras</option>
|
<option value="Kings Cross St. Pancras">Kings Cross St. Pancras</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<h2>Form interaction</h2>
|
||||||
|
<p>Change the values and press reset (The select must be in a form element)</p>
|
||||||
|
<form>
|
||||||
|
<label for="reset-simple">Change me!</label>
|
||||||
|
<select class="form-control" name="reset-simple" id="reset-simple" placeholder="Choose an option">
|
||||||
|
<option value="Option 1">Option 1</option>
|
||||||
|
<option value="Option 2" selected>Option 2</option>
|
||||||
|
<option value="Option 3">Option 3</option>
|
||||||
|
<option value="Option 4">Option 4</option>
|
||||||
|
<option value="Option 5">Option 5</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<label for="reset-multiple">And me!</label>
|
||||||
|
<select class="form-control" data-trigger name="reset-multiple" id="reset-multiple" placeholder="This is a placeholder"
|
||||||
|
multiple>
|
||||||
|
<option value="Dropdown item 1" selected>Dropdown item 1</option>
|
||||||
|
<option value="Dropdown item 2">Dropdown item 2</option>
|
||||||
|
<option value="Dropdown item 3">Dropdown item 3</option>
|
||||||
|
<option value="Dropdown item 4" disabled>Dropdown item 4</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<button type="reset">Reset</button>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
|
@ -524,6 +549,11 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var resetSimple = new Choices(document.getElementById('reset-simple'));
|
||||||
|
|
||||||
|
var resetMultiple = new Choices('#reset-multiple', {
|
||||||
|
removeItemButton: true,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
/* eslint-disable import/prefer-default-export */
|
|
||||||
export const clearAll = () => ({
|
export const clearAll = () => ({
|
||||||
type: 'CLEAR_ALL',
|
type: 'CLEAR_ALL',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const resetTo = state => ({
|
||||||
|
type: 'RESET_TO',
|
||||||
|
state,
|
||||||
|
});
|
||||||
|
|
|
@ -25,7 +25,7 @@ import {
|
||||||
} from './actions/choices';
|
} from './actions/choices';
|
||||||
import { addItem, removeItem, highlightItem } from './actions/items';
|
import { addItem, removeItem, highlightItem } from './actions/items';
|
||||||
import { addGroup } from './actions/groups';
|
import { addGroup } from './actions/groups';
|
||||||
import { clearAll } from './actions/misc';
|
import { clearAll, resetTo } from './actions/misc';
|
||||||
import {
|
import {
|
||||||
isScrolledIntoView,
|
isScrolledIntoView,
|
||||||
getAdjacentEl,
|
getAdjacentEl,
|
||||||
|
@ -41,6 +41,7 @@ import {
|
||||||
fetchFromObject,
|
fetchFromObject,
|
||||||
isIE11,
|
isIE11,
|
||||||
existsInArray,
|
existsInArray,
|
||||||
|
cloneObject,
|
||||||
} from './lib/utils';
|
} from './lib/utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -105,6 +106,7 @@ class Choices {
|
||||||
|
|
||||||
this._store = new Store(this.render);
|
this._store = new Store(this.render);
|
||||||
this.initialised = false;
|
this.initialised = false;
|
||||||
|
this._initialState = {};
|
||||||
this._currentState = {};
|
this._currentState = {};
|
||||||
this._prevState = {};
|
this._prevState = {};
|
||||||
this._currentValue = '';
|
this._currentValue = '';
|
||||||
|
@ -136,6 +138,7 @@ class Choices {
|
||||||
this._onTouchEnd = this._onTouchEnd.bind(this);
|
this._onTouchEnd = this._onTouchEnd.bind(this);
|
||||||
this._onMouseDown = this._onMouseDown.bind(this);
|
this._onMouseDown = this._onMouseDown.bind(this);
|
||||||
this._onMouseOver = this._onMouseOver.bind(this);
|
this._onMouseOver = this._onMouseOver.bind(this);
|
||||||
|
this._onFormReset = this._onFormReset.bind(this);
|
||||||
|
|
||||||
// If element has already been initialised with Choices, fail silently
|
// If element has already been initialised with Choices, fail silently
|
||||||
if (this.passedElement.element.getAttribute('data-choice') === 'active') {
|
if (this.passedElement.element.getAttribute('data-choice') === 'active') {
|
||||||
|
@ -163,6 +166,9 @@ class Choices {
|
||||||
this._createElements();
|
this._createElements();
|
||||||
// Generate input markup
|
// Generate input markup
|
||||||
this._createStructure();
|
this._createStructure();
|
||||||
|
// Set initial state (We need to clone the state because some reducers
|
||||||
|
// modify the inner objects properties in the state) 🤢
|
||||||
|
this._initialState = cloneObject(this._store.state);
|
||||||
// Subscribe store to render method
|
// Subscribe store to render method
|
||||||
this._store.subscribe(this.render);
|
this._store.subscribe(this.render);
|
||||||
// Render any items
|
// Render any items
|
||||||
|
@ -948,6 +954,10 @@ class Choices {
|
||||||
this.input.element.addEventListener('focus', this._onFocus);
|
this.input.element.addEventListener('focus', this._onFocus);
|
||||||
this.input.element.addEventListener('blur', this._onBlur);
|
this.input.element.addEventListener('blur', this._onBlur);
|
||||||
|
|
||||||
|
if (this.input.element.form) {
|
||||||
|
this.input.element.form.addEventListener('reset', this._onFormReset);
|
||||||
|
}
|
||||||
|
|
||||||
this.input.addEventListeners();
|
this.input.addEventListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -967,6 +977,11 @@ class Choices {
|
||||||
|
|
||||||
this.input.element.removeEventListener('focus', this._onFocus);
|
this.input.element.removeEventListener('focus', this._onFocus);
|
||||||
this.input.element.removeEventListener('blur', this._onBlur);
|
this.input.element.removeEventListener('blur', this._onBlur);
|
||||||
|
|
||||||
|
if (this.input.element.form) {
|
||||||
|
this.input.element.form.removeEventListener('reset', this._onFormReset);
|
||||||
|
}
|
||||||
|
|
||||||
this.input.removeEventListeners();
|
this.input.removeEventListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1384,6 +1399,10 @@ class Choices {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_onFormReset() {
|
||||||
|
this._store.dispatch(resetTo(this._initialState));
|
||||||
|
}
|
||||||
|
|
||||||
_highlightChoice(el = null) {
|
_highlightChoice(el = null) {
|
||||||
const choices = Array.from(
|
const choices = Array.from(
|
||||||
this.dropdown.element.querySelectorAll('[data-choice-selectable]'),
|
this.dropdown.element.querySelectorAll('[data-choice-selectable]'),
|
||||||
|
|
|
@ -33,6 +33,10 @@ export default class Input {
|
||||||
this.element.addEventListener('paste', this._onPaste);
|
this.element.addEventListener('paste', this._onPaste);
|
||||||
this.element.addEventListener('focus', this._onFocus);
|
this.element.addEventListener('focus', this._onFocus);
|
||||||
this.element.addEventListener('blur', this._onBlur);
|
this.element.addEventListener('blur', this._onBlur);
|
||||||
|
|
||||||
|
if (this.element.form) {
|
||||||
|
this.element.form.addEventListener('reset', this._onFormReset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
removeEventListeners() {
|
removeEventListeners() {
|
||||||
|
@ -40,6 +44,10 @@ export default class Input {
|
||||||
this.element.removeEventListener('paste', this._onPaste);
|
this.element.removeEventListener('paste', this._onPaste);
|
||||||
this.element.removeEventListener('focus', this._onFocus);
|
this.element.removeEventListener('focus', this._onFocus);
|
||||||
this.element.removeEventListener('blur', this._onBlur);
|
this.element.removeEventListener('blur', this._onBlur);
|
||||||
|
|
||||||
|
if (this.element.form) {
|
||||||
|
this.element.form.removeEventListener('reset', this._onFormReset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enable() {
|
enable() {
|
||||||
|
@ -124,10 +132,12 @@ export default class Input {
|
||||||
this.setWidth();
|
this.setWidth();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_onPaste(e) {
|
|
||||||
|
_onPaste(event) {
|
||||||
|
const { target } = event;
|
||||||
// Disable pasting into the input if option has been set
|
// Disable pasting into the input if option has been set
|
||||||
if (e.target === this.element && this.preventPaste) {
|
if (target === this.element && this.preventPaste) {
|
||||||
e.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ export default class List {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (continueAnimation) {
|
if (continueAnimation) {
|
||||||
requestAnimationFrame(time => {
|
requestAnimationFrame(() => {
|
||||||
this._animateScroll(time, endpoint, direction);
|
this._animateScroll(time, endpoint, direction);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
1
src/scripts/dist/choices.js.map
vendored
1
src/scripts/dist/choices.js.map
vendored
File diff suppressed because one or more lines are too long
2
src/scripts/dist/choices.min.js
vendored
2
src/scripts/dist/choices.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -1,3 +1,15 @@
|
||||||
|
/* eslint-disable */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a random number between a range
|
||||||
|
* @param {Number} min Minimum range
|
||||||
|
* @param {Number} max Maximum range
|
||||||
|
* @return {Number} Random number
|
||||||
|
*/
|
||||||
|
export const getRandomNumber = function(min, max) {
|
||||||
|
return Math.floor(Math.random() * (max - min) + min);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a string of random chars
|
* Generates a string of random chars
|
||||||
* @param {Number} length Length of the string to generate
|
* @param {Number} length Length of the string to generate
|
||||||
|
@ -202,16 +214,6 @@ export const stripHTML = html =>
|
||||||
.replace(/</g, '<')
|
.replace(/</g, '<')
|
||||||
.replace(/"/g, '"');
|
.replace(/"/g, '"');
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a random number between a range
|
|
||||||
* @param {Number} min Minimum range
|
|
||||||
* @param {Number} max Maximum range
|
|
||||||
* @return {Number} Random number
|
|
||||||
*/
|
|
||||||
export const getRandomNumber = function(min, max) {
|
|
||||||
return Math.floor(Math.random() * (max - min) + min);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turn a string into a node
|
* Turn a string into a node
|
||||||
* @param {String} String to convert
|
* @param {String} String to convert
|
||||||
|
@ -378,19 +380,25 @@ export const fetchFromObject = (object, properties) => {
|
||||||
return object[properties];
|
return object[properties];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const isIE11 = () => {
|
export const isIE11 = () =>
|
||||||
return !!(
|
!!(
|
||||||
navigator.userAgent.match(/Trident/) &&
|
navigator.userAgent.match(/Trident/) &&
|
||||||
navigator.userAgent.match(/rv[ :]11/)
|
navigator.userAgent.match(/rv[ :]11/)
|
||||||
);
|
);
|
||||||
};
|
|
||||||
|
|
||||||
export const existsInArray = (array, value) => {
|
export const existsInArray = (array, value) =>
|
||||||
return array.some(item => {
|
array.some(item => {
|
||||||
if (isType('String', value)) {
|
if (isType('String', value)) {
|
||||||
return item.value === value.trim();
|
return item.value === value.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
return item.value === value;
|
return item.value === value;
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
/**
|
||||||
|
* Deep clone an object
|
||||||
|
* @param {Object} obj Object to clone
|
||||||
|
* @return {Object} Clone of the object
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
export const cloneObject = obj => JSON.parse(JSON.stringify(obj));
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { combineReducers } from 'redux';
|
||||||
import items from './items';
|
import items from './items';
|
||||||
import groups from './groups';
|
import groups from './groups';
|
||||||
import choices from './choices';
|
import choices from './choices';
|
||||||
|
import { cloneObject } from '../lib/utils';
|
||||||
|
|
||||||
const appReducer = combineReducers({
|
const appReducer = combineReducers({
|
||||||
items,
|
items,
|
||||||
|
@ -17,6 +18,8 @@ const rootReducer = (passedState, action) => {
|
||||||
// See: http://stackoverflow.com/a/35641992
|
// See: http://stackoverflow.com/a/35641992
|
||||||
if (action.type === 'CLEAR_ALL') {
|
if (action.type === 'CLEAR_ALL') {
|
||||||
state = undefined;
|
state = undefined;
|
||||||
|
} else if (action.type === 'RESET_TO') {
|
||||||
|
return cloneObject(action.state);
|
||||||
}
|
}
|
||||||
|
|
||||||
return appReducer(state, action);
|
return appReducer(state, action);
|
||||||
|
|
Loading…
Reference in a new issue