Version 2.8.11

This commit is contained in:
Josh Johnson 2017-07-31 16:18:36 +01:00
parent 21f67b4289
commit 16c114a6e3
7 changed files with 62 additions and 42 deletions

View file

@ -1,4 +1,4 @@
/*! choices.js v2.8.10 | (c) 2017 Josh Johnson | https://github.com/jshjohnson/Choices#readme */
/*! choices.js v2.8.11 | (c) 2017 Josh Johnson | https://github.com/jshjohnson/Choices#readme */
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
@ -118,6 +118,7 @@ return /******/ (function(modules) { // webpackBootstrap
silent: false,
items: [],
choices: [],
renderChoiceLimit: -1,
maxItemCount: -1,
addItems: true,
removeItems: true,
@ -411,7 +412,7 @@ return /******/ (function(modules) { // webpackBootstrap
if (groupChoices.length >= 1) {
var dropdownGroup = _this._getTemplate('choiceGroup', group);
groupFragment.appendChild(dropdownGroup);
_this.renderChoices(groupChoices, groupFragment);
_this.renderChoices(groupChoices, groupFragment, true);
}
});
@ -431,11 +432,16 @@ return /******/ (function(modules) { // webpackBootstrap
value: function renderChoices(choices, fragment) {
var _this2 = this;
var withinGroup = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
// Create a fragment to store our list items (so we don't have to update the DOM for each item)
var choicesFragment = fragment || document.createDocumentFragment();
var filter = this.isSearching ? _utils.sortByScore : this.config.sortFilter;
var renderSelectedChoices = this.config.renderSelectedChoices;
var _config = this.config,
renderSelectedChoices = _config.renderSelectedChoices,
searchResultLimit = _config.searchResultLimit,
renderChoiceLimit = _config.renderChoiceLimit;
var filter = this.isSearching ? _utils.sortByScore : this.config.sortFilter;
var appendChoice = function appendChoice(choice) {
var shouldRender = renderSelectedChoices === 'auto' ? _this2.isSelectOneElement || !choice.selected : true;
if (shouldRender) {
@ -444,24 +450,32 @@ return /******/ (function(modules) { // webpackBootstrap
}
};
// If sorting is enabled or the user is searching, filter choices
if (this.config.shouldSort || this.isSearching) {
choices.sort(filter);
}
var rendererableChoices = choices;
if (this.isSearching) {
for (var i = 0; i < this.config.searchResultLimit; i++) {
var choice = choices[i];
if (choice) {
appendChoice(choice);
}
}
} else {
choices.forEach(function (choice) {
return appendChoice(choice);
if (renderSelectedChoices === 'auto' && !this.isSelectOneElement) {
rendererableChoices = choices.filter(function (choice) {
return !choice.selected;
});
}
// If sorting is enabled or the user is searching, filter choices
if (this.config.shouldSort || this.isSearching) {
rendererableChoices.sort(filter);
}
var choiceLimit = rendererableChoices.length;
if (this.isSearching) {
choiceLimit = Math.min(searchResultLimit, rendererableChoices.length - 1);
} else if (renderChoiceLimit > 0 && !withinGroup) {
choiceLimit = Math.min(renderChoiceLimit, rendererableChoices.length - 1);
}
// Add each choice to dropdown within range
for (var i = 0; i < choiceLimit; i++) {
appendChoice(rendererableChoices[i]);
};
return choicesFragment;
}
@ -536,7 +550,7 @@ return /******/ (function(modules) { // webpackBootstrap
// Only render if our state has actually changed
if (this.currentState !== this.prevState) {
// Choices
if (this.currentState.choices !== this.prevState.choices || this.currentState.groups !== this.prevState.groups) {
if (this.currentState.choices !== this.prevState.choices || this.currentState.groups !== this.prevState.groups || this.currentState.items !== this.prevState.items) {
if (this.isSelectElement) {
// Get active groups/choices
var activeGroups = this.store.getGroupsFilteredByActive();
@ -1523,7 +1537,11 @@ return /******/ (function(modules) { // webpackBootstrap
this.highlightPosition = 0;
this.isSearching = true;
this.store.dispatch((0, _index3.filterChoices)(results));
return results.length;
}
return 0;
}
/**
@ -1549,14 +1567,16 @@ return /******/ (function(modules) { // webpackBootstrap
if (this.input === document.activeElement) {
// Check that we have a value to search and the input was an alphanumeric character
if (value && value.length >= this.config.searchFloor) {
var resultCount = 0;
// Check flag to filter search input
if (this.config.searchChoices) {
// Filter available choices
this._searchChoices(value);
resultCount = this._searchChoices(value);
}
// Trigger search event
(0, _utils.triggerEvent)(this.passedElement, 'search', {
value: value
value: value,
resultCount: resultCount
});
} else if (hasUnactiveChoices) {
// Otherwise reset choices to active
@ -4524,16 +4544,16 @@ return /******/ (function(modules) { // webpackBootstrap
/* 19 */
/***/ (function(module, exports) {
module.exports = function(module) {
if(!module.webpackPolyfill) {
module.deprecate = function() {};
module.paths = [];
// module.parent = undefined by default
module.children = [];
module.webpackPolyfill = 1;
}
return module;
}
module.exports = function(module) {
if(!module.webpackPolyfill) {
module.deprecate = function() {};
module.paths = [];
// module.parent = undefined by default
module.children = [];
module.webpackPolyfill = 1;
}
return module;
}
/***/ }),
@ -5993,4 +6013,4 @@ return /******/ (function(modules) { // webpackBootstrap
/******/ ])
});
;
//# sourceMappingURL=choices.js.map
//# sourceMappingURL=choices.js.map

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