choices.js
Advanced tools
Comparing version 4.1.4 to 5.0.0
{ | ||
"name": "choices.js", | ||
"version": "4.1.4", | ||
"version": "5.0.0", | ||
"description": "A vanilla JS customisable text input/select box plugin", | ||
@@ -12,12 +12,11 @@ "main": "./public/assets/scripts/choices.min.js", | ||
"coverage": "nyc npm run test:unit", | ||
"bundlesize": "bundlesize", | ||
"cypress:run": "$(npm bin)/cypress run", | ||
"cypress:open": "$(npm bin)/cypress open", | ||
"test:unit": "mocha --require ./config/jsdom.js --compilers js:babel-core/register \"./src/**/**/**/**/*.test.js\" --exit", | ||
"test": "run-p test:unit test:e2e", | ||
"test:unit": "mocha --require ./config/jsdom.js --require @babel/register $(find src -name '*.test.js') --exit", | ||
"test:unit:watch": "npm run test:unit -- --watch --inspect=5556", | ||
"test:e2e": "run-p --race start cypress:run", | ||
"test": "run-p test:unit test:e2e", | ||
"js:watch": "NODE_ENV=development node server.js", | ||
"js:build:minimised": "webpack --env.minimize --config webpack.config.prod.js", | ||
"js:build:unminimised": "webpack --config webpack.config.prod.js", | ||
"js:build": "run-p js:build:minimised js:build:unminimised", | ||
"js:build": "webpack --config webpack.config.prod.js", | ||
"css:watch": "nodemon -e scss -x \"npm run css:build\"", | ||
@@ -31,3 +30,3 @@ "css:build": "run-p css:sass css:prefix css:min", | ||
"postversion": "npm run js:build && npm run bump-cache", | ||
"prepush": "run-p lint test:unit" | ||
"prepush": "run-p lint test:unit && npm run bundlesize" | ||
}, | ||
@@ -59,44 +58,49 @@ "repository": { | ||
"devDependencies": { | ||
"@babel/core": "^7.2.2", | ||
"@babel/plugin-proposal-class-properties": "^7.3.0", | ||
"@babel/plugin-transform-modules-commonjs": "^7.2.0", | ||
"@babel/plugin-transform-spread": "^7.2.2", | ||
"@babel/preset-env": "^7.3.1", | ||
"@babel/register": "^7.0.0", | ||
"autoprefixer": "^6.3.3", | ||
"babel-core": "^6.26.0", | ||
"babel-eslint": "^7.2.3", | ||
"babel-loader": "^7.1.2", | ||
"babel-preset-env": "^1.6.1", | ||
"babel-preset-stage-2": "^6.24.1", | ||
"chai": "^4.1.0", | ||
"babel-eslint": "^9.0.0", | ||
"babel-loader": "^8.0.5", | ||
"bundlesize": "^0.17.1", | ||
"chai": "^4.2.0", | ||
"csso": "^1.8.2", | ||
"cypress": "^3.1.4", | ||
"cypress": "^3.1.5", | ||
"eslint": "^3.19.0", | ||
"eslint-config-airbnb": "^15.1.0", | ||
"eslint-config-prettier": "^2.9.0", | ||
"eslint-loader": "^1.5.0", | ||
"eslint-plugin-cypress": "^2.0.1", | ||
"eslint-plugin-import": "^2.7.0", | ||
"eslint-config-prettier": "^2.10.0", | ||
"eslint-loader": "^2.1.2", | ||
"eslint-plugin-cypress": "^2.2.0", | ||
"eslint-plugin-import": "^2.16.0", | ||
"eslint-plugin-jsx-a11y": "^5.1.1", | ||
"eslint-plugin-prettier": "^2.6.0", | ||
"eslint-plugin-react": "^7.2.1", | ||
"express": "^4.16.3", | ||
"eslint-plugin-prettier": "^2.7.0", | ||
"eslint-plugin-react": "^7.12.4", | ||
"express": "^4.16.4", | ||
"husky": "^0.14.3", | ||
"jsdom": "^11.5.1", | ||
"mocha": "^3.4.2", | ||
"node-sass": "^4.9.3", | ||
"nodemon": "^1.9.1", | ||
"npm-run-all": "^4.1.3", | ||
"nyc": "^11.0.3", | ||
"opn": "^5.1.0", | ||
"jsdom": "^11.12.0", | ||
"mocha": "^5.2.0", | ||
"node-sass": "^4.11.0", | ||
"nodemon": "^1.18.10", | ||
"npm-run-all": "^4.1.5", | ||
"nyc": "^11.9.0", | ||
"opn": "^5.4.0", | ||
"postcss-cli": "^2.5.1", | ||
"prettier": "^1.13.0", | ||
"prettier": "^1.16.4", | ||
"sinon": "^2.4.0", | ||
"webpack": "^3.8.1", | ||
"webpack-dev-middleware": "^2.0.0", | ||
"webpack-hot-middleware": "^2.22.2", | ||
"unminified-webpack-plugin": "^2.0.0", | ||
"webpack": "^4.29.3", | ||
"webpack-cli": "^3.2.3", | ||
"webpack-dev-middleware": "^3.5.2", | ||
"webpack-hot-middleware": "^2.24.3", | ||
"whatwg-fetch": "^1.0.0", | ||
"wrapper-webpack-plugin": "^0.1.7" | ||
"wrapper-webpack-plugin": "^2.1.0" | ||
}, | ||
"dependencies": { | ||
"classnames": "^2.2.5", | ||
"core-js": "^2.5.6", | ||
"classnames": "^2.2.6", | ||
"custom-event-polyfill": "^0.3.0", | ||
"deepmerge": "^2.2.1", | ||
"fuse.js": "^3.1.0", | ||
"fuse.js": "^3.4.1", | ||
"redux": "^3.3.1" | ||
@@ -121,3 +125,9 @@ }, | ||
] | ||
} | ||
}, | ||
"bundlesize": [ | ||
{ | ||
"path": "public/assets/scripts/choices.min.js", | ||
"maxSize": "25 kB" | ||
} | ||
] | ||
} |
# Choices.js ![Build Status](https://travis-ci.org/jshjohnson/Choices.svg?branch=master) [![](https://data.jsdelivr.com/v1/package/npm/choices.js/badge?style=rounded)](https://www.jsdelivr.com/package/npm/choices.js) [![npm](https://img.shields.io/npm/v/choices.js.svg)](https://www.npmjs.com/package/choices.js) [![codebeat badge](https://codebeat.co/badges/55120150-5866-42d8-8010-6aaaff5d3fa1)](https://codebeat.co/projects/github-com-jshjohnson-choices-master) | ||
A vanilla, lightweight (~20kb gzipped 🎉), configurable select box/text input plugin. Similar to Select2 and Selectize but without the jQuery dependency. | ||
A vanilla, lightweight (~22kb gzipped 🎉), configurable select box/text input plugin. Similar to Select2 and Selectize but without the jQuery dependency. | ||
@@ -922,2 +922,4 @@ [Demo](https://joshuajohnson.co.uk/Choices/) | ||
* Array.prototype.some | ||
* Array.prototype.includes | ||
* Array.from | ||
* Array.prototype.reduce | ||
@@ -924,0 +926,0 @@ * Array.prototype.indexOf |
@@ -25,2 +25,3 @@ import Fuse from 'fuse.js'; | ||
import { clearAll, resetTo } from './actions/misc'; | ||
import { setIsLoading } from './actions/general'; | ||
import { | ||
@@ -447,3 +448,5 @@ isScrolledIntoView, | ||
this._setLoading(true); | ||
choices.forEach(addGroupsAndChoices); | ||
this._setLoading(false); | ||
@@ -488,2 +491,6 @@ return this; | ||
_render() { | ||
if (this._store.isLoading()) { | ||
return; | ||
} | ||
this._currentState = this._store.state; | ||
@@ -881,3 +888,7 @@ | ||
_handleLoadingState(isLoading = true) { | ||
_setLoading(isLoading) { | ||
this._store.dispatch(setIsLoading(isLoading)); | ||
} | ||
_handleLoadingState(setLoading = true) { | ||
let placeholderItem = this.itemList.getChild( | ||
@@ -887,3 +898,3 @@ `.${this.config.classNames.placeholder}`, | ||
if (isLoading) { | ||
if (setLoading) { | ||
this.disable(); | ||
@@ -1007,2 +1018,3 @@ this.containerOuter.addLoadingState(); | ||
this._handleLoadingState(false); | ||
this._setLoading(true); | ||
// Add each result as a choice | ||
@@ -1029,2 +1041,4 @@ parsedResults.forEach(result => { | ||
this._setLoading(false); | ||
if (this._isSelectOneElement) { | ||
@@ -1878,2 +1892,3 @@ this._selectPlaceholderChoice(); | ||
this._isSearching = false; | ||
this._setLoading(true); | ||
@@ -1968,2 +1983,4 @@ if (passedGroups && passedGroups.length) { | ||
} | ||
this._setLoading(false); | ||
} | ||
@@ -1970,0 +1987,0 @@ |
@@ -1,4 +0,1 @@ | ||
import 'core-js/fn/array/find'; | ||
import 'core-js/fn/array/from'; | ||
import 'core-js/fn/array/includes'; | ||
import 'custom-event-polyfill'; |
@@ -5,2 +5,3 @@ import { combineReducers } from 'redux'; | ||
import choices from './choices'; | ||
import general from './general'; | ||
import { cloneObject } from '../lib/utils'; | ||
@@ -12,2 +13,3 @@ | ||
choices, | ||
general, | ||
}); | ||
@@ -14,0 +16,0 @@ |
@@ -36,2 +36,5 @@ import { createStore } from 'redux'; | ||
choices: [], | ||
general: { | ||
loading: false, | ||
}, | ||
}); | ||
@@ -38,0 +41,0 @@ }); |
@@ -8,3 +8,4 @@ import { createStore } from 'redux'; | ||
rootReducer, | ||
window.devToolsExtension ? window.devToolsExtension() : undefined, | ||
window.__REDUX_DEVTOOLS_EXTENSION__ && | ||
window.__REDUX_DEVTOOLS_EXTENSION__(), | ||
); | ||
@@ -134,2 +135,10 @@ } | ||
/** | ||
* Get loading state from store | ||
* @return {Boolean} Loading State | ||
*/ | ||
isLoading() { | ||
return this.state.general.loading; | ||
} | ||
/** | ||
* Get single choice by it's ID | ||
@@ -136,0 +145,0 @@ * @return {Object} Found choice |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
5
63
957
675161
41
15400
- Removedcore-js@^2.5.6
- Removedcore-js@2.6.12(transitive)
Updatedclassnames@^2.2.6
Updatedfuse.js@^3.4.1