Version 3.0.0

This commit is contained in:
Josh Johnson 2017-08-03 12:28:01 +01:00
parent bab75d6af1
commit bfa7b1d97f
7 changed files with 194 additions and 102 deletions

View file

@ -1,4 +1,4 @@
/*! choices.js v2.8.12 | (c) 2017 Josh Johnson | https://github.com/jshjohnson/Choices#readme */
/*! choices.js v3.0.0 | (c) 2017 Josh Johnson | https://github.com/jshjohnson/Choices#readme */
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
@ -140,6 +140,7 @@ return /******/ (function(modules) { // webpackBootstrap
sortFilter: _utils.sortByAlpha,
placeholder: true,
placeholderValue: null,
searchPlaceholderValue: null,
prependValue: null,
appendValue: null,
renderSelectedChoices: 'auto',
@ -213,13 +214,6 @@ return /******/ (function(modules) { // webpackBootstrap
// Retrieve triggering element (i.e. element with 'data-choice' trigger)
this.element = element;
this.passedElement = (0, _utils.isType)('String', element) ? document.querySelector(element) : element;
this.isTextElement = this.passedElement.type === 'text';
this.isSelectOneElement = this.passedElement.type === 'select-one';
this.isSelectMultipleElement = this.passedElement.type === 'select-multiple';
this.isSelectElement = this.isSelectOneElement || this.isSelectMultipleElement;
this.isValidElementType = this.isTextElement || this.isSelectElement;
this.isIe11 = !!(navigator.userAgent.match(/Trident/) && navigator.userAgent.match(/rv[ :]11/));
this.isScrollingOnIe = false;
if (!this.passedElement) {
if (!this.config.silent) {
@ -228,6 +222,14 @@ return /******/ (function(modules) { // webpackBootstrap
return;
}
this.isTextElement = this.passedElement.type === 'text';
this.isSelectOneElement = this.passedElement.type === 'select-one';
this.isSelectMultipleElement = this.passedElement.type === 'select-multiple';
this.isSelectElement = this.isSelectOneElement || this.isSelectMultipleElement;
this.isValidElementType = this.isTextElement || this.isSelectElement;
this.isIe11 = !!(navigator.userAgent.match(/Trident/) && navigator.userAgent.match(/rv[ :]11/));
this.isScrollingOnIe = false;
if (this.config.shouldSortItems === true && this.isSelectOneElement) {
if (!this.config.silent) {
console.warn('shouldSortElements: Type of passed element is \'select-one\', falling back to false.');
@ -237,6 +239,11 @@ return /******/ (function(modules) { // webpackBootstrap
this.highlightPosition = 0;
this.canSearch = this.config.searchEnabled;
this.placeholder = false;
if (!this.isSelectOneElement) {
this.placeholder = this.config.placeholder ? this.config.placeholderValue || this.passedElement.getAttribute('placeholder') : false;
}
// Assign preset choices from passed object
this.presetChoices = this.config.choices;
@ -460,22 +467,42 @@ return /******/ (function(modules) { // webpackBootstrap
});
}
// Split array into placeholders and "normal" choices
var _rendererableChoices$ = rendererableChoices.reduce(function (acc, choice) {
if (choice.placeholder) {
acc.placeholderChoices.push(choice);
} else {
acc.normalChoices.push(choice);
}
return acc;
}, { placeholderChoices: [], normalChoices: [] }),
placeholderChoices = _rendererableChoices$.placeholderChoices,
normalChoices = _rendererableChoices$.normalChoices;
// If sorting is enabled or the user is searching, filter choices
if (this.config.shouldSort || this.isSearching) {
rendererableChoices.sort(filter);
normalChoices.sort(filter);
}
var choiceLimit = rendererableChoices.length;
// Prepend placeholeder
var sortedChoices = [].concat(_toConsumableArray(placeholderChoices), _toConsumableArray(normalChoices));
if (this.isSearching) {
choiceLimit = Math.min(searchResultLimit, rendererableChoices.length - 1);
choiceLimit = searchResultLimit;
} else if (renderChoiceLimit > 0 && !withinGroup) {
choiceLimit = Math.min(renderChoiceLimit, rendererableChoices.length - 1);
choiceLimit = renderChoiceLimit;
}
// Add each choice to dropdown within range
for (var i = 0; i < choiceLimit; i++) {
appendChoice(rendererableChoices[i]);
if (sortedChoices[i]) {
appendChoice(sortedChoices[i]);
}
};
return choicesFragment;
@ -611,15 +638,17 @@ return /******/ (function(modules) { // webpackBootstrap
// Items
if (this.currentState.items !== this.prevState.items) {
// Get active items (items that can be selected)
var _activeItems = this.store.getItemsFilteredByActive();
if (_activeItems) {
// Clear list
this.itemList.innerHTML = '';
if (_activeItems && _activeItems) {
// Create a fragment to store our list items
// (so we don't have to update the DOM for each item)
var itemListFragment = this.renderItems(_activeItems);
// Clear list
this.itemList.innerHTML = '';
// If we have items to add
if (itemListFragment.childNodes) {
// Update list
@ -987,9 +1016,9 @@ return /******/ (function(modules) { // webpackBootstrap
// If we are dealing with a select input, we need to create an option first
// that is then selected. For text inputs we can just add items normally.
if (!_this10.isTextElement) {
_this10._addChoice(item.value, item.label, true, false, -1, item.customProperties, null);
_this10._addChoice(item.value, item.label, true, false, -1, item.customProperties, item.placeholder);
} else {
_this10._addItem(item.value, item.label, item.id, undefined, item.customProperties, null);
_this10._addItem(item.value, item.label, item.id, undefined, item.customProperties, item.placeholder);
}
} else if (itemType === 'String') {
if (!_this10.isTextElement) {
@ -1037,7 +1066,7 @@ return /******/ (function(modules) { // webpackBootstrap
if (foundChoice) {
if (!foundChoice.selected) {
_this11._addItem(foundChoice.value, foundChoice.label, foundChoice.id, foundChoice.groupId, foundChoice.customProperties, foundChoice.keyCode);
_this11._addItem(foundChoice.value, foundChoice.label, foundChoice.id, foundChoice.groupId, foundChoice.customProperties, foundChoice.placeholder, foundChoice.keyCode);
} else if (!_this11.config.silent) {
console.warn('Attempting to select choice already selected');
}
@ -1082,7 +1111,7 @@ return /******/ (function(modules) { // webpackBootstrap
if (result.choices) {
_this12._addGroup(result, result.id || null, value, label);
} else {
_this12._addChoice(result[value], result[label], result.selected, result.disabled, undefined, result['customProperties'], null);
_this12._addChoice(result[value], result[label], result.selected, result.disabled, undefined, result.customProperties, result.placeholder);
}
});
}
@ -1135,16 +1164,18 @@ return /******/ (function(modules) { // webpackBootstrap
}, {
key: 'enable',
value: function enable() {
this.passedElement.disabled = false;
var isDisabled = this.containerOuter.classList.contains(this.config.classNames.disabledState);
if (this.initialised && isDisabled) {
this._addEventListeners();
this.passedElement.removeAttribute('disabled');
this.input.removeAttribute('disabled');
this.containerOuter.classList.remove(this.config.classNames.disabledState);
this.containerOuter.removeAttribute('aria-disabled');
if (this.isSelectOneElement) {
this.containerOuter.setAttribute('tabindex', '0');
if (this.initialised) {
this.passedElement.disabled = false;
var isDisabled = this.containerOuter.classList.contains(this.config.classNames.disabledState);
if (isDisabled) {
this._addEventListeners();
this.passedElement.removeAttribute('disabled');
this.input.removeAttribute('disabled');
this.containerOuter.classList.remove(this.config.classNames.disabledState);
this.containerOuter.removeAttribute('aria-disabled');
if (this.isSelectOneElement) {
this.containerOuter.setAttribute('tabindex', '0');
}
}
}
return this;
@ -1159,16 +1190,18 @@ return /******/ (function(modules) { // webpackBootstrap
}, {
key: 'disable',
value: function disable() {
this.passedElement.disabled = true;
var isEnabled = !this.containerOuter.classList.contains(this.config.classNames.disabledState);
if (this.initialised && isEnabled) {
this._removeEventListeners();
this.passedElement.setAttribute('disabled', '');
this.input.setAttribute('disabled', '');
this.containerOuter.classList.add(this.config.classNames.disabledState);
this.containerOuter.setAttribute('aria-disabled', 'true');
if (this.isSelectOneElement) {
this.containerOuter.setAttribute('tabindex', '-1');
if (this.initialised) {
this.passedElement.disabled = true;
var isEnabled = !this.containerOuter.classList.contains(this.config.classNames.disabledState);
if (isEnabled) {
this._removeEventListeners();
this.passedElement.setAttribute('disabled', '');
this.input.setAttribute('disabled', '');
this.containerOuter.classList.add(this.config.classNames.disabledState);
this.containerOuter.setAttribute('aria-disabled', 'true');
if (this.isSelectOneElement) {
this.containerOuter.setAttribute('tabindex', '-1');
}
}
}
return this;
@ -1251,15 +1284,26 @@ return /******/ (function(modules) { // webpackBootstrap
this._triggerChange(itemToRemove.value);
if (this.isSelectOneElement) {
var placeholder = this.config.placeholder ? this.config.placeholderValue || this.passedElement.getAttribute('placeholder') : false;
if (placeholder) {
var placeholderItem = this._getTemplate('placeholder', placeholder);
this.itemList.appendChild(placeholderItem);
}
this._selectPlaceholderChoice();
}
}
}
/**
* Select placeholder choice
*/
}, {
key: '_selectPlaceholderChoice',
value: function _selectPlaceholderChoice() {
var placeholderChoice = this.store.getPlaceholderChoice();
if (placeholderChoice) {
this._addItem(placeholderChoice.value, placeholderChoice.label, placeholderChoice.id, placeholderChoice.groupId, null, placeholderChoice.placeholder);
this._triggerChange(placeholderChoice.value);
}
}
/**
* Process click of an item
* @param {Array} activeItems The currently active items
@ -1336,7 +1380,7 @@ return /******/ (function(modules) { // webpackBootstrap
var canAddItem = this._canAddItem(activeItems, choice.value);
if (canAddItem.response) {
this._addItem(choice.value, choice.label, choice.id, choice.groupId, choice.customProperties, choice.keyCode);
this._addItem(choice.value, choice.label, choice.id, choice.groupId, choice.customProperties, choice.placeholder, choice.keyCode);
this._triggerChange(choice.value);
}
}
@ -1464,12 +1508,11 @@ return /******/ (function(modules) { // webpackBootstrap
} else {
// Remove loading states/text
this.containerOuter.classList.remove(this.config.classNames.loadingState);
var placeholder = this.config.placeholder ? this.config.placeholderValue || this.passedElement.getAttribute('placeholder') : false;
if (this.isSelectOneElement) {
placeholderItem.innerHTML = placeholder || '';
placeholderItem.innerHTML = this.placeholder || '';
} else {
this.input.placeholder = placeholder || '';
this.input.placeholder = this.placeholder || '';
}
}
}
@ -1501,9 +1544,13 @@ return /******/ (function(modules) { // webpackBootstrap
var groupId = result.id || null;
_this15._addGroup(result, groupId, value, label);
} else {
_this15._addChoice(result[value], result[label], result.selected, result.disabled, undefined, result['customProperties'], null);
_this15._addChoice(result[value], result[label], result.selected, result.disabled, undefined, result.customProperties, result.placeholder);
}
});
if (_this15.isSelectOneElement) {
_this15._selectPlaceholderChoice();
}
} else {
// No results, remove loading state
_this15._handleLoadingState(false);
@ -1528,7 +1575,7 @@ return /******/ (function(modules) { // webpackBootstrap
// If new value matches the desired length and is not the same as the current value with a space
if (newValue.length >= 1 && newValue !== currentValue + ' ') {
var haystack = this.store.getChoicesFilteredBySelectable();
var haystack = this.store.getSearchableChoices();
var needle = newValue;
var keys = (0, _utils.isType)('Array', this.config.searchFields) ? this.config.searchFields : [this.config.searchFields];
var options = Object.assign(this.config.fuseOptions, { keys: keys });
@ -1653,11 +1700,10 @@ return /******/ (function(modules) { // webpackBootstrap
}, {
key: '_setInputWidth',
value: function _setInputWidth() {
if (this.config.placeholderValue || this.passedElement.getAttribute('placeholder') && this.config.placeholder) {
if (this.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.
var placeholder = this.config.placeholder ? this.config.placeholderValue || this.passedElement.getAttribute('placeholder') : false;
if (this.input.value && this.input.value.length >= placeholder.length / 1.25) {
if (this.input.value && this.input.value.length >= this.placeholder.length / 1.25) {
this.input.style.width = (0, _utils.getWidthOfInput)(this.input);
}
} else {
@ -2348,7 +2394,8 @@ return /******/ (function(modules) { // webpackBootstrap
var choiceId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : -1;
var groupId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : -1;
var customProperties = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
var keyCode = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
var placeholder = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
var keyCode = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
var passedValue = (0, _utils.isType)('String', value) ? value.trim() : value;
var passedKeyCode = keyCode;
@ -2372,7 +2419,7 @@ return /******/ (function(modules) { // webpackBootstrap
passedValue += this.config.appendValue.toString();
}
this.store.dispatch((0, _index3.addItem)(passedValue, passedLabel, id, passedOptionId, groupId, customProperties, passedKeyCode));
this.store.dispatch((0, _index3.addItem)(passedValue, passedLabel, id, passedOptionId, groupId, customProperties, placeholder, passedKeyCode));
if (this.isSelectOneElement) {
this.removeActiveItems(id);
@ -2460,7 +2507,8 @@ return /******/ (function(modules) { // webpackBootstrap
var isDisabled = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
var groupId = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : -1;
var customProperties = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
var keyCode = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
var placeholder = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
var keyCode = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
if (typeof value === 'undefined' || value === null) {
return;
@ -2472,10 +2520,10 @@ return /******/ (function(modules) { // webpackBootstrap
var choiceId = choices ? choices.length + 1 : 1;
var choiceElementId = this.baseId + '-' + this.idNames.itemChoice + '-' + choiceId;
this.store.dispatch((0, _index3.addChoice)(value, choiceLabel, choiceId, groupId, isDisabled, choiceElementId, customProperties, keyCode));
this.store.dispatch((0, _index3.addChoice)(value, choiceLabel, choiceId, groupId, isDisabled, choiceElementId, customProperties, placeholder, keyCode));
if (isSelected) {
this._addItem(value, choiceLabel, choiceId, undefined, customProperties, keyCode);
this._addItem(value, choiceLabel, choiceId, undefined, customProperties, placeholder, keyCode);
}
}
@ -2518,9 +2566,7 @@ return /******/ (function(modules) { // webpackBootstrap
groupChoices.forEach(function (option) {
var isOptDisabled = option.disabled || option.parentNode && option.parentNode.disabled;
var label = (0, _utils.isType)('Object', option) ? option[labelKey] : option.innerHTML;
_this21._addChoice(option[valueKey], label, option.selected, isOptDisabled, groupId, option.customProperties);
_this21._addChoice(option[valueKey], (0, _utils.isType)('Object', option) ? option[labelKey] : option.innerHTML, option.selected, isOptDisabled, groupId, option.customProperties, option.placeholder);
});
} else {
this.store.dispatch((0, _index3.addGroup)(group.label, group.id, false, group.disabled));
@ -2582,12 +2628,12 @@ return /******/ (function(modules) { // webpackBootstrap
item: function item(data) {
var _classNames2;
var localClasses = (0, _classnames2.default)(globalClasses.item, (_classNames2 = {}, _defineProperty(_classNames2, globalClasses.highlightedState, data.highlighted), _defineProperty(_classNames2, globalClasses.itemSelectable, !data.highlighted), _classNames2));
var localClasses = (0, _classnames2.default)(globalClasses.item, (_classNames2 = {}, _defineProperty(_classNames2, globalClasses.highlightedState, data.highlighted), _defineProperty(_classNames2, globalClasses.itemSelectable, !data.highlighted), _defineProperty(_classNames2, globalClasses.placeholder, data.placeholder), _classNames2));
if (_this22.config.removeItemButton) {
var _classNames3;
localClasses = (0, _classnames2.default)(globalClasses.item, (_classNames3 = {}, _defineProperty(_classNames3, globalClasses.highlightedState, data.highlighted), _defineProperty(_classNames3, globalClasses.itemSelectable, !data.disabled), _classNames3));
localClasses = (0, _classnames2.default)(globalClasses.item, (_classNames3 = {}, _defineProperty(_classNames3, globalClasses.highlightedState, data.highlighted), _defineProperty(_classNames3, globalClasses.itemSelectable, !data.disabled), _defineProperty(_classNames3, globalClasses.placeholder, data.placeholder), _classNames3));
return (0, _utils.strToEl)('\n <div\n class="' + localClasses + '"\n data-item\n data-id="' + data.id + '"\n data-value="' + data.value + '"\n data-deletable\n ' + (data.active ? 'aria-selected="true"' : '') + '\n ' + (data.disabled ? 'aria-disabled="true"' : '') + '\n >\n ' + data.label + '<!--\n --><button\n type="button"\n class="' + globalClasses.button + '"\n data-button\n aria-label="Remove item: \'' + data.value + '\'"\n >\n Remove item\n </button>\n </div>\n ');
}
@ -2605,7 +2651,7 @@ return /******/ (function(modules) { // webpackBootstrap
choice: function choice(data) {
var _classNames5;
var localClasses = (0, _classnames2.default)(globalClasses.item, globalClasses.itemChoice, (_classNames5 = {}, _defineProperty(_classNames5, globalClasses.itemDisabled, data.disabled), _defineProperty(_classNames5, globalClasses.itemSelectable, !data.disabled), _classNames5));
var localClasses = (0, _classnames2.default)(globalClasses.item, globalClasses.itemChoice, (_classNames5 = {}, _defineProperty(_classNames5, globalClasses.itemDisabled, data.disabled), _defineProperty(_classNames5, globalClasses.itemSelectable, !data.disabled), _defineProperty(_classNames5, globalClasses.placeholder, data.placeholder), _classNames5));
return (0, _utils.strToEl)('\n <div\n class="' + localClasses + '"\n data-select-text="' + _this22.config.itemSelectText + '"\n data-choice\n data-id="' + data.id + '"\n data-value="' + data.value + '"\n ' + (data.disabled ? 'data-choice-disabled aria-disabled="true"' : 'data-choice-selectable') + '\n id="' + data.elementId + '"\n ' + (data.groupId > 0 ? 'role="treeitem"' : 'role="option"') + '\n >\n ' + data.label + '\n </div>\n ');
},
@ -2657,7 +2703,6 @@ return /******/ (function(modules) { // webpackBootstrap
var choiceList = this._getTemplate('choiceList');
var input = this._getTemplate('input');
var dropdown = this._getTemplate('dropdown');
var placeholder = this.config.placeholder ? this.config.placeholderValue || this.passedElement.getAttribute('placeholder') : false;
this.containerOuter = containerOuter;
this.containerInner = containerInner;
@ -2689,12 +2734,11 @@ return /******/ (function(modules) { // webpackBootstrap
// Wrapper inner container with outer container
(0, _utils.wrap)(containerInner, containerOuter);
// If placeholder has been enabled and we have a value
if (placeholder) {
input.placeholder = placeholder;
if (!this.isSelectOneElement) {
input.style.width = (0, _utils.getWidthOfInput)(input);
}
if (this.isSelectOneElement) {
input.placeholder = this.config.searchPlaceholderValue || '';
} else if (this.placeholder) {
input.placeholder = this.placeholder;
input.style.width = (0, _utils.getWidthOfInput)(input);
}
if (!this.config.addItems) {
@ -2736,7 +2780,8 @@ return /******/ (function(modules) { // webpackBootstrap
value: o.value,
label: o.innerHTML,
selected: o.selected,
disabled: o.disabled || o.parentNode.disabled
disabled: o.disabled || o.parentNode.disabled,
placeholder: o.hasAttribute('placeholder')
});
});
@ -2754,16 +2799,13 @@ return /******/ (function(modules) { // webpackBootstrap
allChoices.forEach(function (choice, index) {
// Pre-select first choice if it's a single select
if (_this23.isSelectOneElement) {
if (hasSelectedChoice || !hasSelectedChoice && index > 0) {
// If there is a selected choice already or the choice is not
// the first in the array, add each choice normally
_this23._addChoice(choice.value, choice.label, choice.selected, choice.disabled, undefined, choice.customProperties);
} else {
// Otherwise pre-select the first choice in the array
_this23._addChoice(choice.value, choice.label, true, false, undefined, choice.customProperties);
}
// If there is a selected choice already or the choice is not
// the first in the array, add each choice normally
// Otherwise pre-select the first choice in the array
var shouldPreselect = hasSelectedChoice || !hasSelectedChoice && index > 0;
_this23._addChoice(choice.value, choice.label, shouldPreselect ? choice.selected : true, shouldPreselect ? choice.disabled : false, undefined, choice.customProperties, choice.placeholder);
} else {
_this23._addChoice(choice.value, choice.label, choice.selected, choice.disabled, undefined, choice.customProperties);
_this23._addChoice(choice.value, choice.label, choice.selected, choice.disabled, undefined, choice.customProperties, choice.placeholder);
}
});
}
@ -2775,7 +2817,7 @@ return /******/ (function(modules) { // webpackBootstrap
if (!item.value) {
return;
}
_this23._addItem(item.value, item.label, item.id, undefined, item.customProperties);
_this23._addItem(item.value, item.label, item.id, undefined, item.customProperties, item.placeholder);
} else if (itemType === 'String') {
_this23._addItem(item);
}
@ -3694,6 +3736,8 @@ return /******/ (function(modules) { // webpackBootstrap
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: 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); } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Store = function () {
@ -3808,7 +3852,7 @@ return /******/ (function(modules) { // webpackBootstrap
var choices = this.getChoices();
var values = choices.filter(function (choice) {
return choice.active === true;
}, []);
});
return values;
}
@ -3824,11 +3868,25 @@ return /******/ (function(modules) { // webpackBootstrap
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
@ -3897,6 +3955,22 @@ return /******/ (function(modules) { // webpackBootstrap
return foundGroup;
}
/**
* Get placeholder choice from store
* @return {Object} Found placeholder
*/
}, {
key: 'getPlaceholderChoice',
value: function getPlaceholderChoice() {
var choices = this.getChoices();
var placeholderChoice = [].concat(_toConsumableArray(choices)).reverse().find(function (choice) {
return choice.placeholder === true;
});
return placeholderChoice;
}
}]);
return Store;
@ -5013,6 +5087,7 @@ return /******/ (function(modules) { // webpackBootstrap
active: true,
highlighted: false,
customProperties: action.customProperties,
placeholder: action.placeholder || false,
keyCode: null
}]);
@ -5130,6 +5205,7 @@ return /******/ (function(modules) { // webpackBootstrap
active: true,
score: 9999,
customProperties: action.customProperties,
placeholder: action.placeholder || false,
keyCode: null
}]);
}
@ -5227,7 +5303,7 @@ return /******/ (function(modules) { // webpackBootstrap
Object.defineProperty(exports, "__esModule", {
value: true
});
var addItem = exports.addItem = function addItem(value, label, id, choiceId, groupId, customProperties, keyCode) {
var addItem = exports.addItem = function addItem(value, label, id, choiceId, groupId, customProperties, placeholder, keyCode) {
return {
type: 'ADD_ITEM',
value: value,
@ -5236,6 +5312,7 @@ return /******/ (function(modules) { // webpackBootstrap
choiceId: choiceId,
groupId: groupId,
customProperties: customProperties,
placeholder: placeholder,
keyCode: keyCode
};
};
@ -5256,7 +5333,7 @@ return /******/ (function(modules) { // webpackBootstrap
};
};
var addChoice = exports.addChoice = function addChoice(value, label, id, groupId, disabled, elementId, customProperties, keyCode) {
var addChoice = exports.addChoice = function addChoice(value, label, id, groupId, disabled, elementId, customProperties, placeholder, keyCode) {
return {
type: 'ADD_CHOICE',
value: value,
@ -5266,6 +5343,7 @@ return /******/ (function(modules) { // webpackBootstrap
disabled: disabled,
elementId: elementId,
customProperties: customProperties,
placeholder: placeholder,
keyCode: keyCode
};
};
@ -5448,13 +5526,13 @@ return /******/ (function(modules) { // webpackBootstrap
*/
var whichTransitionEvent = exports.whichTransitionEvent = function whichTransitionEvent() {
var t,
el = document.createElement("fakeelement");
el = document.createElement('fakeelement');
var transitions = {
"transition": "transitionend",
"OTransition": "oTransitionEnd",
"MozTransition": "transitionend",
"WebkitTransition": "webkitTransitionEnd"
'transition': 'transitionend',
'OTransition': 'oTransitionEnd',
'MozTransition': 'transitionend',
'WebkitTransition': 'webkitTransitionEnd'
};
for (t in transitions) {
@ -5826,6 +5904,20 @@ return /******/ (function(modules) { // webpackBootstrap
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) {

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": "2.8.12",
"version": "3.0.0",
"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=2.8.12">
<link rel="stylesheet" href="assets/styles/css/base.min.css?version=3.0.0">
<!-- 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=2.8.12">
<link rel="stylesheet" href="assets/styles/css/choices.min.css?version=3.0.0">
<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": "2.8.12",
"version": "3.0.0",
"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=2.8.12 run version
// Example usage: npm --newVersion=3.0.0 run version
const fs = require('fs');
const path = require('path');