mirror of
https://github.com/Choices-js/Choices.git
synced 2024-06-08 00:42:15 +02:00
Use babel env config
This commit is contained in:
parent
18456153ff
commit
b3108835bb
2
.babelrc
2
.babelrc
|
@ -1,3 +1,3 @@
|
||||||
{
|
{
|
||||||
"presets": ["es2015", "stage-2"]
|
"presets": ["env", "stage-2"]
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
"babel-core": "^6.26.0",
|
"babel-core": "^6.26.0",
|
||||||
"babel-eslint": "^7.2.3",
|
"babel-eslint": "^7.2.3",
|
||||||
"babel-loader": "^7.1.2",
|
"babel-loader": "^7.1.2",
|
||||||
"babel-preset-es2015": "^6.6.0",
|
"babel-preset-env": "^1.6.1",
|
||||||
"babel-preset-stage-2": "^6.24.1",
|
"babel-preset-stage-2": "^6.24.1",
|
||||||
"chai": "^4.1.0",
|
"chai": "^4.1.0",
|
||||||
"concurrently": "^3.1.0",
|
"concurrently": "^3.1.0",
|
||||||
|
|
486
src/scripts/dist/choices.js
vendored
486
src/scripts/dist/choices.js
vendored
|
@ -518,14 +518,12 @@ var isScrolledIntoView = exports.isScrolledIntoView = function isScrolledIntoVie
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove html tags from a string
|
* Escape html in the string
|
||||||
* @param {String} Initial string/html
|
* @param {String} html Initial string/html
|
||||||
* @return {String} Sanitised string
|
* @return {String} Sanitised string
|
||||||
*/
|
*/
|
||||||
var stripHTML = exports.stripHTML = function stripHTML(html) {
|
var stripHTML = exports.stripHTML = function stripHTML(html) {
|
||||||
var el = document.createElement('DIV');
|
return html.replace(/&/g, '&').replace(/>/g, '&rt;').replace(/</g, '<').replace(/"/g, '"');
|
||||||
el.innerHTML = html;
|
|
||||||
return el.textContent || el.innerText || '';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -581,12 +579,12 @@ var strToEl = exports.strToEl = function () {
|
||||||
* Sets the width of a passed input based on its value
|
* Sets the width of a passed input based on its value
|
||||||
* @return {Number} Width of input
|
* @return {Number} Width of input
|
||||||
*/
|
*/
|
||||||
var getWidthOfInput = exports.getWidthOfInput = function getWidthOfInput(input) {
|
var calcWidthOfInput = exports.calcWidthOfInput = function calcWidthOfInput(input) {
|
||||||
var value = input.value || input.placeholder;
|
var value = input.value || input.placeholder;
|
||||||
var width = input.offsetWidth;
|
var width = input.offsetWidth;
|
||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
var testEl = strToEl('<span>' + value + '</span>');
|
var testEl = strToEl('<span>' + stripHTML(value) + '</span>');
|
||||||
testEl.style.position = 'absolute';
|
testEl.style.position = 'absolute';
|
||||||
testEl.style.padding = '0';
|
testEl.style.padding = '0';
|
||||||
testEl.style.top = '-9999px';
|
testEl.style.top = '-9999px';
|
||||||
|
@ -710,6 +708,10 @@ var reduceToValues = exports.reduceToValues = function reduceToValues(items) {
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
|
exports.SCROLLING_SPEED = exports.KEY_CODES = exports.ACTION_TYPES = exports.EVENTS = exports.DEFAULT_CONFIG = exports.DEFAULT_CLASSNAMES = undefined;
|
||||||
|
|
||||||
|
var _utils = __webpack_require__(0);
|
||||||
|
|
||||||
var DEFAULT_CLASSNAMES = exports.DEFAULT_CLASSNAMES = {
|
var DEFAULT_CLASSNAMES = exports.DEFAULT_CLASSNAMES = {
|
||||||
containerOuter: 'choices',
|
containerOuter: 'choices',
|
||||||
containerInner: 'choices__inner',
|
containerInner: 'choices__inner',
|
||||||
|
@ -774,7 +776,7 @@ var DEFAULT_CONFIG = exports.DEFAULT_CONFIG = {
|
||||||
itemSelectText: 'Press to select',
|
itemSelectText: 'Press to select',
|
||||||
uniqueItemText: 'Only unique values can be added.',
|
uniqueItemText: 'Only unique values can be added.',
|
||||||
addItemText: function addItemText(value) {
|
addItemText: function addItemText(value) {
|
||||||
return 'Press Enter to add <b>"' + value + '"</b>';
|
return 'Press Enter to add <b>"' + (0, _utils.stripHTML)(value) + '"</b>';
|
||||||
},
|
},
|
||||||
maxItemText: function maxItemText(maxItemCount) {
|
maxItemText: function maxItemText(maxItemCount) {
|
||||||
return 'Only ' + maxItemCount + ' values can be added.';
|
return 'Only ' + maxItemCount + ' values can be added.';
|
||||||
|
@ -1693,16 +1695,6 @@ var WrappedElement = function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
_createClass(WrappedElement, [{
|
_createClass(WrappedElement, [{
|
||||||
key: 'getElement',
|
|
||||||
value: function getElement() {
|
|
||||||
return this.element;
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
key: 'getValue',
|
|
||||||
value: function getValue() {
|
|
||||||
return this.element.value;
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
key: 'conceal',
|
key: 'conceal',
|
||||||
value: function conceal() {
|
value: function conceal() {
|
||||||
// Hide passed input
|
// Hide passed input
|
||||||
|
@ -1762,6 +1754,11 @@ var WrappedElement = function () {
|
||||||
value: function triggerEvent(eventType, data) {
|
value: function triggerEvent(eventType, data) {
|
||||||
(0, _utils.dispatchEvent)(this.element, eventType, data);
|
(0, _utils.dispatchEvent)(this.element, eventType, data);
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
key: 'value',
|
||||||
|
get: function get() {
|
||||||
|
return this.element.value;
|
||||||
|
}
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
return WrappedElement;
|
return WrappedElement;
|
||||||
|
@ -2045,8 +2042,8 @@ var Choices = function () {
|
||||||
this.presetItems = this.config.items;
|
this.presetItems = this.config.items;
|
||||||
|
|
||||||
// Then add any values passed from attribute
|
// Then add any values passed from attribute
|
||||||
if (this.passedElement.getValue()) {
|
if (this.passedElement.value) {
|
||||||
this.presetItems = this.presetItems.concat(this.passedElement.getValue().split(this.config.delimiter));
|
this.presetItems = this.presetItems.concat(this.passedElement.value.split(this.config.delimiter));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set unique base Id
|
// Set unique base Id
|
||||||
|
@ -2114,8 +2111,10 @@ var Choices = function () {
|
||||||
|
|
||||||
// Set initialise flag
|
// Set initialise flag
|
||||||
this.initialised = true;
|
this.initialised = true;
|
||||||
// Create required elements
|
// Create required templates
|
||||||
this._createTemplates();
|
this._createTemplates();
|
||||||
|
// Create required elements
|
||||||
|
this._createElements();
|
||||||
// Generate input markup
|
// Generate input markup
|
||||||
this._createStructure();
|
this._createStructure();
|
||||||
// Subscribe store to render method
|
// Subscribe store to render method
|
||||||
|
@ -2151,7 +2150,7 @@ var Choices = function () {
|
||||||
this.containerOuter.unwrap(this.passedElement.element);
|
this.containerOuter.unwrap(this.passedElement.element);
|
||||||
|
|
||||||
if (this.isSelectElement) {
|
if (this.isSelectElement) {
|
||||||
this.passedElement.setOptions(this.presetChoices);
|
this.passedElement.options = this.presetChoices;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear data store
|
// Clear data store
|
||||||
|
@ -2357,10 +2356,10 @@ var Choices = function () {
|
||||||
|
|
||||||
if (this.isTextElement) {
|
if (this.isTextElement) {
|
||||||
// Update the value of the hidden input
|
// Update the value of the hidden input
|
||||||
this.passedElement.setValue(items);
|
this.passedElement.value = items;
|
||||||
} else {
|
} else {
|
||||||
// Update the options of the hidden input
|
// Update the options of the hidden input
|
||||||
this.passedElement.setOptions(items);
|
this.passedElement.options = items;
|
||||||
}
|
}
|
||||||
|
|
||||||
var addItemToFragment = function addItemToFragment(item) {
|
var addItemToFragment = function addItemToFragment(item) {
|
||||||
|
@ -2387,7 +2386,7 @@ var Choices = function () {
|
||||||
}, {
|
}, {
|
||||||
key: 'render',
|
key: 'render',
|
||||||
value: function render() {
|
value: function render() {
|
||||||
this.currentState = this.store.getState();
|
this.currentState = this.store.state;
|
||||||
var stateChanged = this.currentState.choices !== this.prevState.choices || this.currentState.groups !== this.prevState.groups || this.currentState.items !== this.prevState.items;
|
var stateChanged = this.currentState.choices !== this.prevState.choices || this.currentState.groups !== this.prevState.groups || this.currentState.items !== this.prevState.items;
|
||||||
|
|
||||||
if (!stateChanged) {
|
if (!stateChanged) {
|
||||||
|
@ -2398,8 +2397,8 @@ var Choices = function () {
|
||||||
|
|
||||||
if (this.isSelectElement) {
|
if (this.isSelectElement) {
|
||||||
// Get active groups/choices
|
// Get active groups/choices
|
||||||
var activeGroups = this.store.getGroupsFilteredByActive();
|
var activeGroups = this.store.activeGroups;
|
||||||
var activeChoices = this.store.getChoicesFilteredByActive();
|
var activeChoices = this.store.activeChoices;
|
||||||
|
|
||||||
var choiceListFragment = document.createDocumentFragment();
|
var choiceListFragment = document.createDocumentFragment();
|
||||||
|
|
||||||
|
@ -2427,8 +2426,8 @@ var Choices = function () {
|
||||||
|
|
||||||
// If we have choices to show
|
// If we have choices to show
|
||||||
if (choiceListFragment.childNodes && choiceListFragment.childNodes.length > 0) {
|
if (choiceListFragment.childNodes && choiceListFragment.childNodes.length > 0) {
|
||||||
var activeItems = this.store.getItemsFilteredByActive();
|
var activeItems = this.store.activeItems;
|
||||||
var canAddItem = this._canAddItem(activeItems, this.input.getValue());
|
var canAddItem = this._canAddItem(activeItems, this.input.value);
|
||||||
|
|
||||||
// ...and we can select them
|
// ...and we can select them
|
||||||
if (canAddItem.response) {
|
if (canAddItem.response) {
|
||||||
|
@ -2461,7 +2460,7 @@ var Choices = function () {
|
||||||
/* Items */
|
/* Items */
|
||||||
if (this.currentState.items !== this.prevState.items) {
|
if (this.currentState.items !== this.prevState.items) {
|
||||||
// Get active items (items that can be selected)
|
// Get active items (items that can be selected)
|
||||||
var _activeItems = this.store.getItemsFilteredByActive() || [];
|
var _activeItems = this.store.activeItems || [];
|
||||||
// Clear list
|
// Clear list
|
||||||
this.itemList.clear();
|
this.itemList.clear();
|
||||||
|
|
||||||
|
@ -2567,7 +2566,7 @@ var Choices = function () {
|
||||||
value: function highlightAll() {
|
value: function highlightAll() {
|
||||||
var _this4 = this;
|
var _this4 = this;
|
||||||
|
|
||||||
var items = this.store.getItems();
|
var items = this.store.items;
|
||||||
items.forEach(function (item) {
|
items.forEach(function (item) {
|
||||||
return _this4.highlightItem(item);
|
return _this4.highlightItem(item);
|
||||||
});
|
});
|
||||||
|
@ -2585,7 +2584,7 @@ var Choices = function () {
|
||||||
value: function unhighlightAll() {
|
value: function unhighlightAll() {
|
||||||
var _this5 = this;
|
var _this5 = this;
|
||||||
|
|
||||||
var items = this.store.getItems();
|
var items = this.store.items;
|
||||||
items.forEach(function (item) {
|
items.forEach(function (item) {
|
||||||
return _this5.unhighlightItem(item);
|
return _this5.unhighlightItem(item);
|
||||||
});
|
});
|
||||||
|
@ -2608,7 +2607,7 @@ var Choices = function () {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
var items = this.store.getItemsFilteredByActive();
|
var items = this.store.activeItems;
|
||||||
|
|
||||||
items.forEach(function (item) {
|
items.forEach(function (item) {
|
||||||
if (item.value === value) {
|
if (item.value === value) {
|
||||||
|
@ -2632,7 +2631,7 @@ var Choices = function () {
|
||||||
value: function removeActiveItems(excludedId) {
|
value: function removeActiveItems(excludedId) {
|
||||||
var _this7 = this;
|
var _this7 = this;
|
||||||
|
|
||||||
var items = this.store.getItemsFilteredByActive();
|
var items = this.store.activeItems;
|
||||||
|
|
||||||
items.forEach(function (item) {
|
items.forEach(function (item) {
|
||||||
if (excludedId !== item.id) {
|
if (excludedId !== item.id) {
|
||||||
|
@ -2657,7 +2656,7 @@ var Choices = function () {
|
||||||
|
|
||||||
var runEvent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
var runEvent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
||||||
|
|
||||||
var items = this.store.getItemsFilteredByHighlighted();
|
var items = this.store.highlightedActiveItems;
|
||||||
|
|
||||||
items.forEach(function (item) {
|
items.forEach(function (item) {
|
||||||
_this8._removeItem(item);
|
_this8._removeItem(item);
|
||||||
|
@ -2685,7 +2684,7 @@ var Choices = function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.dropdown.show();
|
this.dropdown.show();
|
||||||
this.containerOuter.open(this.dropdown.getVerticalPos());
|
this.containerOuter.open(this.dropdown.distanceFromTopWindow());
|
||||||
|
|
||||||
if (focusInput && this.canSearch) {
|
if (focusInput && this.canSearch) {
|
||||||
this.input.focus();
|
this.input.focus();
|
||||||
|
@ -2753,7 +2752,7 @@ var Choices = function () {
|
||||||
value: function getValue() {
|
value: function getValue() {
|
||||||
var valueOnly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
var valueOnly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
||||||
|
|
||||||
var items = this.store.getItemsFilteredByActive();
|
var items = this.store.activeItems;
|
||||||
|
|
||||||
var values = items.reduce(function (selectedItems, item) {
|
var values = items.reduce(function (selectedItems, item) {
|
||||||
var itemValue = valueOnly ? item.value : item;
|
var itemValue = valueOnly ? item.value : item;
|
||||||
|
@ -2935,7 +2934,7 @@ var Choices = function () {
|
||||||
}, {
|
}, {
|
||||||
key: '_triggerChange',
|
key: '_triggerChange',
|
||||||
value: function _triggerChange(value) {
|
value: function _triggerChange(value) {
|
||||||
if (!value) {
|
if (value === undefined || value === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2951,7 +2950,7 @@ var Choices = function () {
|
||||||
}, {
|
}, {
|
||||||
key: '_selectPlaceholderChoice',
|
key: '_selectPlaceholderChoice',
|
||||||
value: function _selectPlaceholderChoice() {
|
value: function _selectPlaceholderChoice() {
|
||||||
var placeholderChoice = this.store.getPlaceholderChoice();
|
var placeholderChoice = this.store.placeholderChoice;
|
||||||
|
|
||||||
if (placeholderChoice) {
|
if (placeholderChoice) {
|
||||||
this._addItem(placeholderChoice.value, placeholderChoice.label, placeholderChoice.id, placeholderChoice.groupId, null, placeholderChoice.placeholder);
|
this._addItem(placeholderChoice.value, placeholderChoice.label, placeholderChoice.id, placeholderChoice.groupId, null, placeholderChoice.placeholder);
|
||||||
|
@ -3093,7 +3092,7 @@ var Choices = function () {
|
||||||
// If editing the last item is allowed and there are not other selected items,
|
// If editing the last item is allowed and there are not other selected items,
|
||||||
// we can edit the item value. Otherwise if we can remove items, remove all selected items
|
// we can edit the item value. Otherwise if we can remove items, remove all selected items
|
||||||
if (this.config.editItems && !hasHighlightedItems && lastItem) {
|
if (this.config.editItems && !hasHighlightedItems && lastItem) {
|
||||||
this.input.setValue(lastItem.value);
|
this.input.value = lastItem.value;
|
||||||
this.input.setWidth();
|
this.input.setWidth();
|
||||||
this._removeItem(lastItem);
|
this._removeItem(lastItem);
|
||||||
this._triggerChange(lastItem.value);
|
this._triggerChange(lastItem.value);
|
||||||
|
@ -3129,7 +3128,7 @@ var Choices = function () {
|
||||||
placeholderItem.innerHTML = this.config.loadingText;
|
placeholderItem.innerHTML = this.config.loadingText;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.input.setPlaceholder(this.config.loadingText);
|
this.input.placeholder = this.config.loadingText;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.containerOuter.removeLoadingState();
|
this.containerOuter.removeLoadingState();
|
||||||
|
@ -3137,7 +3136,7 @@ var Choices = function () {
|
||||||
if (this.isSelectOneElement) {
|
if (this.isSelectOneElement) {
|
||||||
placeholderItem.innerHTML = this.placeholder || '';
|
placeholderItem.innerHTML = this.placeholder || '';
|
||||||
} else {
|
} else {
|
||||||
this.input.setPlaceholder(this.placeholder || '');
|
this.input.placeholder = this.placeholder || '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3252,7 +3251,7 @@ var Choices = function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If new value matches the desired length and is not the same as the current value with a space
|
// If new value matches the desired length and is not the same as the current value with a space
|
||||||
var haystack = this.store.getSearchableChoices();
|
var haystack = this.store.searchableChoices;
|
||||||
var needle = newValue;
|
var needle = newValue;
|
||||||
var keys = (0, _utils.isType)('Array', this.config.searchFields) ? this.config.searchFields : [this.config.searchFields];
|
var keys = (0, _utils.isType)('Array', this.config.searchFields) ? this.config.searchFields : [this.config.searchFields];
|
||||||
var options = Object.assign(this.config.fuseOptions, { keys: keys });
|
var options = Object.assign(this.config.fuseOptions, { keys: keys });
|
||||||
|
@ -3281,7 +3280,7 @@ var Choices = function () {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var choices = this.store.getChoices();
|
var choices = this.store.choices;
|
||||||
var hasUnactiveChoices = choices.some(function (option) {
|
var hasUnactiveChoices = choices.some(function (option) {
|
||||||
return !option.active;
|
return !option.active;
|
||||||
});
|
});
|
||||||
|
@ -3374,7 +3373,7 @@ var Choices = function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
var target = e.target;
|
var target = e.target;
|
||||||
var activeItems = this.store.getItemsFilteredByActive();
|
var activeItems = this.store.activeItems;
|
||||||
var hasFocusedInput = this.input.isFocussed;
|
var hasFocusedInput = this.input.isFocussed;
|
||||||
var hasActiveDropdown = this.dropdown.isActive;
|
var hasActiveDropdown = this.dropdown.isActive;
|
||||||
var hasItems = this.itemList.hasChildren;
|
var hasItems = this.itemList.hasChildren;
|
||||||
|
@ -3401,7 +3400,7 @@ var Choices = function () {
|
||||||
// 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) {
|
||||||
_this15.canSearch = false;
|
_this15.canSearch = false;
|
||||||
if (_this15.config.removeItems && !_this15.input.getValue() && _this15.input.element === document.activeElement) {
|
if (_this15.config.removeItems && !_this15.input.value && _this15.input.element === document.activeElement) {
|
||||||
// Highlight items
|
// Highlight items
|
||||||
_this15.highlightAll();
|
_this15.highlightAll();
|
||||||
}
|
}
|
||||||
|
@ -3411,7 +3410,7 @@ var Choices = function () {
|
||||||
var onEnterKey = function onEnterKey() {
|
var onEnterKey = function onEnterKey() {
|
||||||
// If enter key is pressed and the input has a value
|
// If enter key is pressed and the input has a value
|
||||||
if (_this15.isTextElement && target.value) {
|
if (_this15.isTextElement && target.value) {
|
||||||
var value = _this15.input.getValue();
|
var value = _this15.input.value;
|
||||||
var canAddItem = _this15._canAddItem(activeItems, value);
|
var canAddItem = _this15._canAddItem(activeItems, value);
|
||||||
|
|
||||||
// All is good, add
|
// All is good, add
|
||||||
|
@ -3527,8 +3526,8 @@ var Choices = function () {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var value = this.input.getValue();
|
var value = this.input.value;
|
||||||
var activeItems = this.store.getItemsFilteredByActive();
|
var activeItems = this.store.activeItems;
|
||||||
var canAddItem = this._canAddItem(activeItems, value);
|
var canAddItem = this._canAddItem(activeItems, value);
|
||||||
|
|
||||||
// We are typing into a text input and have a value, we want to show a dropdown
|
// We are typing into a text input and have a value, we want to show a dropdown
|
||||||
|
@ -3560,7 +3559,7 @@ var Choices = function () {
|
||||||
this.store.dispatch((0, _choices.activateChoices)(true));
|
this.store.dispatch((0, _choices.activateChoices)(true));
|
||||||
}
|
}
|
||||||
} else if (this.canSearch && canAddItem.response) {
|
} else if (this.canSearch && canAddItem.response) {
|
||||||
this._handleSearch(this.input.getValue());
|
this._handleSearch(this.input.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Re-establish canSearch value from changes in _onKeyDown
|
// Re-establish canSearch value from changes in _onKeyDown
|
||||||
|
@ -3630,7 +3629,7 @@ var Choices = function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.containerOuter.element.contains(target) && target !== this.input.element) {
|
if (this.containerOuter.element.contains(target) && target !== this.input.element) {
|
||||||
var activeItems = this.store.getItemsFilteredByActive();
|
var activeItems = this.store.activeItems;
|
||||||
var hasShiftKey = e.shiftKey;
|
var hasShiftKey = e.shiftKey;
|
||||||
|
|
||||||
var buttonTarget = (0, _utils.findAncestorByAttrName)(target, 'data-button');
|
var buttonTarget = (0, _utils.findAncestorByAttrName)(target, 'data-button');
|
||||||
|
@ -3680,7 +3679,7 @@ var Choices = function () {
|
||||||
value: function _onClick(e) {
|
value: function _onClick(e) {
|
||||||
var target = e.target;
|
var target = e.target;
|
||||||
var hasActiveDropdown = this.dropdown.isActive;
|
var hasActiveDropdown = this.dropdown.isActive;
|
||||||
var activeItems = this.store.getItemsFilteredByActive();
|
var activeItems = this.store.activeItems;
|
||||||
|
|
||||||
// If target is something that concerns us
|
// If target is something that concerns us
|
||||||
if (this.containerOuter.element.contains(target)) {
|
if (this.containerOuter.element.contains(target)) {
|
||||||
|
@ -3775,7 +3774,7 @@ var Choices = function () {
|
||||||
var target = e.target;
|
var target = e.target;
|
||||||
// If target is something that concerns us
|
// If target is something that concerns us
|
||||||
if (this.containerOuter.element.contains(target) && !this.isScrollingOnIe) {
|
if (this.containerOuter.element.contains(target) && !this.isScrollingOnIe) {
|
||||||
var activeItems = this.store.getItemsFilteredByActive();
|
var activeItems = this.store.activeItems;
|
||||||
var hasHighlightedItems = activeItems.some(function (item) {
|
var hasHighlightedItems = activeItems.some(function (item) {
|
||||||
return item.highlighted;
|
return item.highlighted;
|
||||||
});
|
});
|
||||||
|
@ -3967,7 +3966,7 @@ var Choices = function () {
|
||||||
var passedValue = (0, _utils.isType)('String', value) ? value.trim() : value;
|
var passedValue = (0, _utils.isType)('String', value) ? value.trim() : value;
|
||||||
var passedKeyCode = keyCode;
|
var passedKeyCode = keyCode;
|
||||||
var passedCustomProperties = customProperties;
|
var passedCustomProperties = customProperties;
|
||||||
var items = this.store.getItems();
|
var items = this.store.items;
|
||||||
var passedLabel = label || passedValue;
|
var passedLabel = label || passedValue;
|
||||||
var passedOptionId = parseInt(choiceId, 10) || -1;
|
var passedOptionId = parseInt(choiceId, 10) || -1;
|
||||||
|
|
||||||
|
@ -4086,7 +4085,7 @@ var Choices = function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate unique id
|
// Generate unique id
|
||||||
var choices = this.store.getChoices();
|
var choices = this.store.choices;
|
||||||
var choiceLabel = label || value;
|
var choiceLabel = label || value;
|
||||||
var choiceId = choices ? choices.length + 1 : 1;
|
var choiceId = choices ? choices.length + 1 : 1;
|
||||||
var choiceElementId = this.baseId + '-' + this.idNames.itemChoice + '-' + choiceId;
|
var choiceElementId = this.baseId + '-' + this.idNames.itemChoice + '-' + choiceId;
|
||||||
|
@ -4192,14 +4191,12 @@ var Choices = function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create DOM structure around passed select element
|
* Create DOM elements using templates
|
||||||
* @return
|
|
||||||
* @private
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}, {
|
}, {
|
||||||
key: '_createStructure',
|
key: '_createElements',
|
||||||
value: function _createStructure() {
|
value: function _createElements() {
|
||||||
var direction = this.passedElement.element.getAttribute('dir') || 'ltr';
|
var direction = this.passedElement.element.getAttribute('dir') || 'ltr';
|
||||||
var containerOuter = this._getTemplate('containerOuter', direction, this.isSelectElement, this.isSelectOneElement, this.config.searchEnabled, this.passedElement.element.type);
|
var containerOuter = this._getTemplate('containerOuter', direction, this.isSelectElement, this.isSelectOneElement, this.config.searchEnabled, this.passedElement.element.type);
|
||||||
var containerInner = this._getTemplate('containerInner');
|
var containerInner = this._getTemplate('containerInner');
|
||||||
|
@ -4214,18 +4211,28 @@ var Choices = function () {
|
||||||
this.choiceList = new _list2.default(this, choiceList, this.config.classNames);
|
this.choiceList = new _list2.default(this, choiceList, this.config.classNames);
|
||||||
this.itemList = new _list2.default(this, itemList, this.config.classNames);
|
this.itemList = new _list2.default(this, itemList, this.config.classNames);
|
||||||
this.dropdown = new _dropdown2.default(this, dropdown, this.config.classNames);
|
this.dropdown = new _dropdown2.default(this, dropdown, this.config.classNames);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create DOM structure around passed select element
|
||||||
|
* @return
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
}, {
|
||||||
|
key: '_createStructure',
|
||||||
|
value: function _createStructure() {
|
||||||
|
// Hide original element
|
||||||
this.passedElement.conceal();
|
this.passedElement.conceal();
|
||||||
|
|
||||||
// Wrap input in container preserving DOM ordering
|
// Wrap input in container preserving DOM ordering
|
||||||
this.containerInner.wrap(this.passedElement.element);
|
this.containerInner.wrap(this.passedElement.element);
|
||||||
// Wrapper inner container with outer container
|
// Wrapper inner container with outer container
|
||||||
this.containerOuter.wrap(this.containerInner.element);
|
this.containerOuter.wrap(this.containerInner.element);
|
||||||
|
|
||||||
if (this.isSelectOneElement) {
|
if (this.isSelectOneElement) {
|
||||||
this.input.setPlaceholder(this.config.searchPlaceholderValue || '');
|
this.input.placeholder = this.config.searchPlaceholderValue || '';
|
||||||
} else if (this.placeholder) {
|
} else if (this.placeholder) {
|
||||||
this.input.setPlaceholder(this.placeholder);
|
this.input.placeholder = this.placeholder;
|
||||||
this.input.setWidth(true);
|
this.input.setWidth(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4235,16 +4242,16 @@ var Choices = function () {
|
||||||
|
|
||||||
this.containerOuter.element.appendChild(this.containerInner.element);
|
this.containerOuter.element.appendChild(this.containerInner.element);
|
||||||
this.containerOuter.element.appendChild(this.dropdown.element);
|
this.containerOuter.element.appendChild(this.dropdown.element);
|
||||||
this.containerInner.element.appendChild(itemList);
|
this.containerInner.element.appendChild(this.itemList.element);
|
||||||
|
|
||||||
if (!this.isTextElement) {
|
if (!this.isTextElement) {
|
||||||
dropdown.appendChild(choiceList);
|
this.dropdown.element.appendChild(this.choiceList.element);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.isSelectOneElement) {
|
if (!this.isSelectOneElement) {
|
||||||
this.containerInner.element.appendChild(this.input.element);
|
this.containerInner.element.appendChild(this.input.element);
|
||||||
} else if (this.canSearch) {
|
} else if (this.canSearch) {
|
||||||
dropdown.insertBefore(input, dropdown.firstChild);
|
this.dropdown.element.insertBefore(this.input.element, this.dropdown.element.firstChild);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isSelectElement) {
|
if (this.isSelectElement) {
|
||||||
|
@ -4258,14 +4265,14 @@ var Choices = function () {
|
||||||
value: function _addPredefinedChoices() {
|
value: function _addPredefinedChoices() {
|
||||||
var _this21 = this;
|
var _this21 = this;
|
||||||
|
|
||||||
var passedGroups = this.passedElement.getOptionGroups();
|
var passedGroups = this.passedElement.optionGroups;
|
||||||
|
|
||||||
this.highlightPosition = 0;
|
this.highlightPosition = 0;
|
||||||
this.isSearching = false;
|
this.isSearching = false;
|
||||||
|
|
||||||
if (passedGroups && passedGroups.length) {
|
if (passedGroups && passedGroups.length) {
|
||||||
// If we have a placeholder option
|
// If we have a placeholder option
|
||||||
var placeholderChoice = this.passedElement.getPlaceholderOption();
|
var placeholderChoice = this.passedElement.placeholderOption;
|
||||||
if (placeholderChoice && placeholderChoice.parentNode.tagName === 'SELECT') {
|
if (placeholderChoice && placeholderChoice.parentNode.tagName === 'SELECT') {
|
||||||
this._addChoice(placeholderChoice.value, placeholderChoice.innerHTML, placeholderChoice.selected, placeholderChoice.disabled, undefined, undefined,
|
this._addChoice(placeholderChoice.value, placeholderChoice.innerHTML, placeholderChoice.selected, placeholderChoice.disabled, undefined, undefined,
|
||||||
/* placeholder */true);
|
/* placeholder */true);
|
||||||
|
@ -4275,7 +4282,7 @@ var Choices = function () {
|
||||||
_this21._addGroup(group, group.id || null);
|
_this21._addGroup(group, group.id || null);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var passedOptions = this.passedElement.getOptions();
|
var passedOptions = this.passedElement.options;
|
||||||
var filter = this.config.sortFn;
|
var filter = this.config.sortFn;
|
||||||
var allChoices = this.presetChoices;
|
var allChoices = this.presetChoices;
|
||||||
|
|
||||||
|
@ -4382,7 +4389,7 @@ var Choices = function () {
|
||||||
value: function _findAndSelectChoiceByValue(val) {
|
value: function _findAndSelectChoiceByValue(val) {
|
||||||
var _this24 = this;
|
var _this24 = this;
|
||||||
|
|
||||||
var choices = this.store.getChoices();
|
var choices = this.store.choices;
|
||||||
// Check 'value' property exists and the choice isn't already selected
|
// Check 'value' property exists and the choice isn't already selected
|
||||||
var foundChoice = choices.find(function (choice) {
|
var foundChoice = choices.find(function (choice) {
|
||||||
return _this24.config.itemComparer(choice.value, val);
|
return _this24.config.itemComparer(choice.value, val);
|
||||||
|
@ -5469,8 +5476,40 @@ var Store = function () {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}, {
|
}, {
|
||||||
key: 'getState',
|
key: 'getChoiceById',
|
||||||
value: function getState() {
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get single choice by it's ID
|
||||||
|
* @return {Object} Found choice
|
||||||
|
*/
|
||||||
|
value: function getChoiceById(id) {
|
||||||
|
if (id) {
|
||||||
|
var choices = this.activeChoices;
|
||||||
|
var foundChoice = choices.find(function (choice) {
|
||||||
|
return choice.id === parseInt(id, 10);
|
||||||
|
});
|
||||||
|
return foundChoice;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get group by group id
|
||||||
|
* @param {Number} id Group ID
|
||||||
|
* @return {Object} Group data
|
||||||
|
*/
|
||||||
|
|
||||||
|
}, {
|
||||||
|
key: 'getGroupById',
|
||||||
|
value: function getGroupById(id) {
|
||||||
|
return this.groups.find(function (group) {
|
||||||
|
return group.id === parseInt(id, 10);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: 'state',
|
||||||
|
get: function get() {
|
||||||
return this.store.getState();
|
return this.store.getState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5480,10 +5519,9 @@ var Store = function () {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}, {
|
}, {
|
||||||
key: 'getItems',
|
key: 'items',
|
||||||
value: function getItems() {
|
get: function get() {
|
||||||
var state = this.store.getState();
|
return this.state.items;
|
||||||
return state.items;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5492,14 +5530,11 @@ var Store = function () {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}, {
|
}, {
|
||||||
key: 'getItemsFilteredByActive',
|
key: 'activeItems',
|
||||||
value: function getItemsFilteredByActive() {
|
get: function get() {
|
||||||
var items = this.getItems();
|
return this.items.filter(function (item) {
|
||||||
var values = items.filter(function (item) {
|
|
||||||
return item.active === true;
|
return item.active === true;
|
||||||
});
|
});
|
||||||
|
|
||||||
return values;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5508,14 +5543,11 @@ var Store = function () {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}, {
|
}, {
|
||||||
key: 'getItemsFilteredByHighlighted',
|
key: 'highlightedActiveItems',
|
||||||
value: function getItemsFilteredByHighlighted() {
|
get: function get() {
|
||||||
var items = this.getItems();
|
return this.items.filter(function (item) {
|
||||||
var values = items.filter(function (item) {
|
|
||||||
return item.active && item.highlighted;
|
return item.active && item.highlighted;
|
||||||
});
|
});
|
||||||
|
|
||||||
return values;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5524,10 +5556,9 @@ var Store = function () {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}, {
|
}, {
|
||||||
key: 'getChoices',
|
key: 'choices',
|
||||||
value: function getChoices() {
|
get: function get() {
|
||||||
var state = this.store.getState();
|
return this.state.choices;
|
||||||
return state.choices;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5536,9 +5567,9 @@ var Store = function () {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}, {
|
}, {
|
||||||
key: 'getChoicesFilteredByActive',
|
key: 'activeChoices',
|
||||||
value: function getChoicesFilteredByActive() {
|
get: function get() {
|
||||||
var choices = this.getChoices();
|
var choices = this.choices;
|
||||||
var values = choices.filter(function (choice) {
|
var values = choices.filter(function (choice) {
|
||||||
return choice.active === true;
|
return choice.active === true;
|
||||||
});
|
});
|
||||||
|
@ -5552,14 +5583,11 @@ var Store = function () {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}, {
|
}, {
|
||||||
key: 'getChoicesFilteredBySelectable',
|
key: 'selectableChoices',
|
||||||
value: function getChoicesFilteredBySelectable() {
|
get: function get() {
|
||||||
var choices = this.getChoices();
|
return this.choices.filter(function (choice) {
|
||||||
var values = choices.filter(function (choice) {
|
|
||||||
return choice.disabled !== true;
|
return choice.disabled !== true;
|
||||||
});
|
});
|
||||||
|
|
||||||
return values;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5568,46 +5596,24 @@ var Store = function () {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}, {
|
}, {
|
||||||
key: 'getSearchableChoices',
|
key: 'searchableChoices',
|
||||||
value: function getSearchableChoices() {
|
get: function get() {
|
||||||
var filtered = this.getChoicesFilteredBySelectable();
|
return this.selectableChoices.filter(function (choice) {
|
||||||
return filtered.filter(function (choice) {
|
|
||||||
return choice.placeholder !== true;
|
return choice.placeholder !== true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get single choice by it's ID
|
|
||||||
* @return {Object} Found choice
|
|
||||||
*/
|
|
||||||
|
|
||||||
}, {
|
|
||||||
key: 'getChoiceById',
|
|
||||||
value: function getChoiceById(id) {
|
|
||||||
if (id) {
|
|
||||||
var choices = this.getChoicesFilteredByActive();
|
|
||||||
var foundChoice = choices.find(function (choice) {
|
|
||||||
return choice.id === parseInt(id, 10);
|
|
||||||
});
|
|
||||||
return foundChoice;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get placeholder choice from store
|
* Get placeholder choice from store
|
||||||
* @return {Object} Found placeholder
|
* @return {Object} Found placeholder
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}, {
|
}, {
|
||||||
key: 'getPlaceholderChoice',
|
key: 'placeholderChoice',
|
||||||
value: function getPlaceholderChoice() {
|
get: function get() {
|
||||||
var choices = this.getChoices();
|
return [].concat(_toConsumableArray(this.choices)).reverse().find(function (choice) {
|
||||||
var placeholderChoice = [].concat(_toConsumableArray(choices)).reverse().find(function (choice) {
|
|
||||||
return choice.placeholder === true;
|
return choice.placeholder === true;
|
||||||
});
|
});
|
||||||
|
|
||||||
return placeholderChoice;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5616,10 +5622,9 @@ var Store = function () {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}, {
|
}, {
|
||||||
key: 'getGroups',
|
key: 'groups',
|
||||||
value: function getGroups() {
|
get: function get() {
|
||||||
var state = this.store.getState();
|
return this.state.groups;
|
||||||
return state.groups;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5628,37 +5633,18 @@ var Store = function () {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}, {
|
}, {
|
||||||
key: 'getGroupsFilteredByActive',
|
key: 'activeGroups',
|
||||||
value: function getGroupsFilteredByActive() {
|
get: function get() {
|
||||||
var groups = this.getGroups();
|
var groups = this.groups;
|
||||||
var choices = this.getChoices();
|
var choices = this.choices;
|
||||||
|
|
||||||
var values = groups.filter(function (group) {
|
return groups.filter(function (group) {
|
||||||
var isActive = group.active === true && group.disabled === false;
|
var isActive = group.active === true && group.disabled === false;
|
||||||
var hasActiveOptions = choices.some(function (choice) {
|
var hasActiveOptions = choices.some(function (choice) {
|
||||||
return choice.active === true && choice.disabled === false;
|
return choice.active === true && choice.disabled === false;
|
||||||
});
|
});
|
||||||
return isActive && hasActiveOptions;
|
return isActive && hasActiveOptions;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return values;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get group by group id
|
|
||||||
* @param {Number} id Group ID
|
|
||||||
* @return {Object} Group data
|
|
||||||
*/
|
|
||||||
|
|
||||||
}, {
|
|
||||||
key: 'getGroupById',
|
|
||||||
value: function getGroupById(id) {
|
|
||||||
var groups = this.getGroups();
|
|
||||||
var foundGroup = groups.find(function (group) {
|
|
||||||
return group.id === parseInt(id, 10);
|
|
||||||
});
|
|
||||||
|
|
||||||
return foundGroup;
|
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
@ -6100,21 +6086,16 @@ var Dropdown = function () {
|
||||||
this.isActive = false;
|
this.isActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine how far the top of our element is from
|
||||||
|
* the top of the window
|
||||||
|
* @return {Number} Vertical position
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
_createClass(Dropdown, [{
|
_createClass(Dropdown, [{
|
||||||
key: 'getElement',
|
key: 'distanceFromTopWindow',
|
||||||
value: function getElement() {
|
value: function distanceFromTopWindow() {
|
||||||
return this.element;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine how far the top of our element is from
|
|
||||||
* the top of the window
|
|
||||||
* @return {Number} Vertical position
|
|
||||||
*/
|
|
||||||
|
|
||||||
}, {
|
|
||||||
key: 'getVerticalPos',
|
|
||||||
value: function getVerticalPos() {
|
|
||||||
this.dimensions = this.element.getBoundingClientRect();
|
this.dimensions = this.element.getBoundingClientRect();
|
||||||
this.position = Math.ceil(this.dimensions.top + window.pageYOffset + this.element.offsetHeight);
|
this.position = Math.ceil(this.dimensions.top + window.pageYOffset + this.element.offsetHeight);
|
||||||
return this.position;
|
return this.position;
|
||||||
|
@ -6201,17 +6182,12 @@ var Container = function () {
|
||||||
this.onBlur = this.onBlur.bind(this);
|
this.onBlur = this.onBlur.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add event listeners
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
_createClass(Container, [{
|
_createClass(Container, [{
|
||||||
key: 'getElement',
|
|
||||||
value: function getElement() {
|
|
||||||
return this.element;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add event listeners
|
|
||||||
*/
|
|
||||||
|
|
||||||
}, {
|
|
||||||
key: 'addEventListeners',
|
key: 'addEventListeners',
|
||||||
value: function addEventListeners() {
|
value: function addEventListeners() {
|
||||||
this.element.addEventListener('focus', this.onFocus);
|
this.element.addEventListener('focus', this.onFocus);
|
||||||
|
@ -6450,11 +6426,6 @@ var Input = function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
_createClass(Input, [{
|
_createClass(Input, [{
|
||||||
key: 'getElement',
|
|
||||||
value: function getElement() {
|
|
||||||
return this.element;
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
key: 'addEventListeners',
|
key: 'addEventListeners',
|
||||||
value: function addEventListeners() {
|
value: function addEventListeners() {
|
||||||
this.element.addEventListener('input', this.onInput);
|
this.element.addEventListener('input', this.onInput);
|
||||||
|
@ -6582,32 +6553,17 @@ var Input = function () {
|
||||||
// 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.parentInstance.placeholder.length / 1.25 || enforceWidth) {
|
if (this.element.value && this.element.value.length >= this.parentInstance.placeholder.length / 1.25 || enforceWidth) {
|
||||||
this.element.style.width = this.getWidth();
|
this.element.style.width = this.calcWidth();
|
||||||
}
|
}
|
||||||
} 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.getWidth();
|
this.element.style.width = this.calcWidth();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
key: 'getWidth',
|
key: 'calcWidth',
|
||||||
value: function getWidth() {
|
value: function calcWidth() {
|
||||||
return (0, _utils.getWidthOfInput)(this.element);
|
return (0, _utils.calcWidthOfInput)(this.element);
|
||||||
}
|
|
||||||
}, {
|
|
||||||
key: 'setPlaceholder',
|
|
||||||
value: function setPlaceholder(placeholder) {
|
|
||||||
this.element.placeholder = placeholder;
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
key: 'setValue',
|
|
||||||
value: function setValue(value) {
|
|
||||||
this.element.value = value;
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
key: 'getValue',
|
|
||||||
value: function getValue() {
|
|
||||||
return this.element.value;
|
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
key: 'setActiveDescendant',
|
key: 'setActiveDescendant',
|
||||||
|
@ -6619,6 +6575,19 @@ var Input = function () {
|
||||||
value: function removeActiveDescendant() {
|
value: function removeActiveDescendant() {
|
||||||
this.element.removeAttribute('aria-activedescendant');
|
this.element.removeAttribute('aria-activedescendant');
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
key: 'placeholder',
|
||||||
|
set: function set(placeholder) {
|
||||||
|
this.element.placeholder = placeholder;
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: 'value',
|
||||||
|
set: function set(value) {
|
||||||
|
this.element.value = value;
|
||||||
|
},
|
||||||
|
get: function get() {
|
||||||
|
return this.element.value;
|
||||||
|
}
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
return Input;
|
return Input;
|
||||||
|
@ -6653,17 +6622,12 @@ var List = function () {
|
||||||
this.hasChildren = !!this.element.children;
|
this.hasChildren = !!this.element.children;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear List contents
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
_createClass(List, [{
|
_createClass(List, [{
|
||||||
key: 'getElement',
|
|
||||||
value: function getElement() {
|
|
||||||
return this.element;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clear List contents
|
|
||||||
*/
|
|
||||||
|
|
||||||
}, {
|
|
||||||
key: 'clear',
|
key: 'clear',
|
||||||
value: function clear() {
|
value: function clear() {
|
||||||
this.element.innerHTML = '';
|
this.element.innerHTML = '';
|
||||||
|
@ -6751,39 +6715,20 @@ var WrappedInput = function (_WrappedElement) {
|
||||||
}
|
}
|
||||||
|
|
||||||
_createClass(WrappedInput, [{
|
_createClass(WrappedInput, [{
|
||||||
key: 'getElement',
|
key: 'value',
|
||||||
value: function getElement() {
|
set: function set(items) {
|
||||||
_get(WrappedInput.prototype.__proto__ || Object.getPrototypeOf(WrappedInput.prototype), 'getElement', this).call(this);
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
key: 'conceal',
|
|
||||||
value: function conceal() {
|
|
||||||
_get(WrappedInput.prototype.__proto__ || Object.getPrototypeOf(WrappedInput.prototype), 'conceal', this).call(this);
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
key: 'reveal',
|
|
||||||
value: function reveal() {
|
|
||||||
_get(WrappedInput.prototype.__proto__ || Object.getPrototypeOf(WrappedInput.prototype), 'reveal', this).call(this);
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
key: 'enable',
|
|
||||||
value: function enable() {
|
|
||||||
_get(WrappedInput.prototype.__proto__ || Object.getPrototypeOf(WrappedInput.prototype), 'enable', this).call(this);
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
key: 'disable',
|
|
||||||
value: function disable() {
|
|
||||||
_get(WrappedInput.prototype.__proto__ || Object.getPrototypeOf(WrappedInput.prototype), 'disable', this).call(this);
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
key: 'setValue',
|
|
||||||
value: function setValue(items) {
|
|
||||||
var itemsFiltered = (0, _utils.reduceToValues)(items);
|
var itemsFiltered = (0, _utils.reduceToValues)(items);
|
||||||
var itemsFilteredString = itemsFiltered.join(this.parentInstance.config.delimiter);
|
var itemsFilteredString = itemsFiltered.join(this.parentInstance.config.delimiter);
|
||||||
|
|
||||||
this.element.setAttribute('value', itemsFilteredString);
|
this.element.setAttribute('value', itemsFilteredString);
|
||||||
this.element.value = itemsFilteredString;
|
this.element.value = itemsFilteredString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @todo figure out why we need this? Perhaps a babel issue
|
||||||
|
,
|
||||||
|
get: function get() {
|
||||||
|
return _get(WrappedInput.prototype.__proto__ || Object.getPrototypeOf(WrappedInput.prototype), 'value', this);
|
||||||
|
}
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
return WrappedInput;
|
return WrappedInput;
|
||||||
|
@ -6804,8 +6749,6 @@ 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 _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
|
||||||
|
|
||||||
var _wrappedElement = __webpack_require__(4);
|
var _wrappedElement = __webpack_require__(4);
|
||||||
|
|
||||||
var _wrappedElement2 = _interopRequireDefault(_wrappedElement);
|
var _wrappedElement2 = _interopRequireDefault(_wrappedElement);
|
||||||
|
@ -6837,48 +6780,27 @@ var WrappedSelect = function (_WrappedElement) {
|
||||||
}
|
}
|
||||||
|
|
||||||
_createClass(WrappedSelect, [{
|
_createClass(WrappedSelect, [{
|
||||||
key: 'getElement',
|
key: 'appendDocFragment',
|
||||||
value: function getElement() {
|
value: function appendDocFragment(fragment) {
|
||||||
_get(WrappedSelect.prototype.__proto__ || Object.getPrototypeOf(WrappedSelect.prototype), 'getElement', this).call(this);
|
this.element.innerHTML = '';
|
||||||
|
this.element.appendChild(fragment);
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
key: 'conceal',
|
key: 'placeholderOption',
|
||||||
value: function conceal() {
|
get: function get() {
|
||||||
_get(WrappedSelect.prototype.__proto__ || Object.getPrototypeOf(WrappedSelect.prototype), 'conceal', this).call(this);
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
key: 'reveal',
|
|
||||||
value: function reveal() {
|
|
||||||
_get(WrappedSelect.prototype.__proto__ || Object.getPrototypeOf(WrappedSelect.prototype), 'reveal', this).call(this);
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
key: 'enable',
|
|
||||||
value: function enable() {
|
|
||||||
_get(WrappedSelect.prototype.__proto__ || Object.getPrototypeOf(WrappedSelect.prototype), 'enable', this).call(this);
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
key: 'disable',
|
|
||||||
value: function disable() {
|
|
||||||
_get(WrappedSelect.prototype.__proto__ || Object.getPrototypeOf(WrappedSelect.prototype), 'disable', this).call(this);
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
key: 'getPlaceholderOption',
|
|
||||||
value: function getPlaceholderOption() {
|
|
||||||
return this.element.querySelector('option[placeholder]');
|
return this.element.querySelector('option[placeholder]');
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
key: 'getOptions',
|
key: 'optionGroups',
|
||||||
value: function getOptions() {
|
get: function get() {
|
||||||
return Array.from(this.element.options);
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
key: 'getOptionGroups',
|
|
||||||
value: function getOptionGroups() {
|
|
||||||
return Array.from(this.element.getElementsByTagName('OPTGROUP'));
|
return Array.from(this.element.getElementsByTagName('OPTGROUP'));
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
key: 'setOptions',
|
key: 'options',
|
||||||
value: function setOptions(options) {
|
get: function get() {
|
||||||
|
return Array.from(this.element.options);
|
||||||
|
},
|
||||||
|
set: function set(options) {
|
||||||
var fragment = document.createDocumentFragment();
|
var fragment = document.createDocumentFragment();
|
||||||
var addOptionToFragment = function addOptionToFragment(data) {
|
var addOptionToFragment = function addOptionToFragment(data) {
|
||||||
// Create a standard select option
|
// Create a standard select option
|
||||||
|
@ -6894,12 +6816,6 @@ var WrappedSelect = function (_WrappedElement) {
|
||||||
|
|
||||||
this.appendDocFragment(fragment);
|
this.appendDocFragment(fragment);
|
||||||
}
|
}
|
||||||
}, {
|
|
||||||
key: 'appendDocFragment',
|
|
||||||
value: function appendDocFragment(fragment) {
|
|
||||||
this.element.innerHTML = '';
|
|
||||||
this.element.appendChild(fragment);
|
|
||||||
}
|
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
return WrappedSelect;
|
return WrappedSelect;
|
||||||
|
|
2
src/scripts/dist/choices.js.map
vendored
2
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
|
@ -17,6 +17,7 @@ export default class WrappedInput extends WrappedElement {
|
||||||
this.element.value = itemsFilteredString;
|
this.element.value = itemsFilteredString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @todo figure out why we need this? Perhaps a babel issue
|
||||||
get value() {
|
get value() {
|
||||||
return super.value;
|
return super.value;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue