diff --git a/.babelrc b/.babelrc new file mode 100644 index 00000000..8fb47a89 --- /dev/null +++ b/.babelrc @@ -0,0 +1,9 @@ +{ + "ignore": ["node-modules/**", "src/index.umd.js"], + "presets": [ "es2015", "stage-0", "react"], + "env": { + "test": { + "plugins": ["istanbul"], + }, + } +} diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index f4253545..00000000 --- a/.eslintrc +++ /dev/null @@ -1,35 +0,0 @@ -{ - "parser": "babel-eslint", - "env": { - "browser": true, - "node": true - }, - "plugins": [ - "react" - ], - "rules": { - "curly": [2, "multi-line"], - "jsx-quotes": 1, - "no-shadow": 0, - "no-trailing-spaces": 0, - "no-underscore-dangle": 0, - "no-unused-expressions": 0, - "object-curly-spacing": [1, "always"], - "quotes": [2, "single", "avoid-escape"], - "react/jsx-boolean-value": 1, - "react/jsx-no-undef": 1, - "react/jsx-sort-prop-types": 1, - "react/jsx-uses-react": 1, - "react/jsx-uses-vars": 1, - "react/no-did-mount-set-state": 1, - "react/no-did-update-set-state": 1, - "react/no-unknown-property": 1, - "react/prop-types": 1, - "react/react-in-jsx-scope": 1, - "react/self-closing-comp": 1, - "react/sort-comp": 1, - "react/wrap-multilines": 1, - "semi": 2, - "strict": 0 - } -} diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 00000000..0dacb6aa --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,41 @@ +module.exports = { + parserOptions: { + ecmaVersion: 6, + sourceType: 'module', + ecmaFeatures: { + experimentalObjectRestSpread: true, + jsx: true, + }, + }, + env: { + browser: true, + es6: true, + node: true, + }, + plugins: ['react'], + rules: { + 'curly': [2, 'multi-line'], + 'jsx-quotes': 1, + 'no-shadow': 0, + 'no-trailing-spaces': 0, + 'no-underscore-dangle': 0, + 'no-unused-expressions': 0, + 'object-curly-spacing': [1, 'always'], + 'quotes': [2, 'single', 'avoid-escape'], + 'react/jsx-boolean-value': 1, + 'react/jsx-no-undef': 1, + 'react/jsx-uses-react': 1, + 'react/jsx-uses-vars': 1, + 'react/jsx-wrap-multilines': 1, + 'react/no-did-mount-set-state': 1, + 'react/no-did-update-set-state': 1, + 'react/no-unknown-property': 1, + 'react/prop-types': 1, + 'react/react-in-jsx-scope': 1, + 'react/self-closing-comp': 1, + 'react/sort-comp': 1, + 'react/sort-prop-types': 1, + 'semi': 2, + 'strict': 0, + }, +}; diff --git a/.gitignore b/.gitignore index d2dfea8f..582edcc8 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ pids # Coverage tools lib-cov coverage +.nyc_output # Dependency directory node_modules diff --git a/.nycrc b/.nycrc new file mode 100644 index 00000000..e6c59634 --- /dev/null +++ b/.nycrc @@ -0,0 +1,12 @@ +{ + "reporter": [ + "lcov", + "text-summary" + ], + "require": [ + "babel-register" + ], + "sourceMap": false, + "instrument": false, + "report-dir": "./coverage" +} diff --git a/.travis.yml b/.travis.yml index 8278823b..ac23f398 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,8 @@ sudo: false language: node_js node_js: - - "v4" + - "v4" script: - - npm run coveralls + - npm run lint + - npm run test + - npm run coveralls diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6afd856a..776eac1b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,9 +3,9 @@ Thanks for your interest in React-Select. All forms of contribution are welcome, from issue reports to PRs and documentation / write-ups. -* We use node.js v4 for development and testing. Due to incompatibilities with -JSDOM and older versions of node.js, you'll need to use node 4 to run the -tests. If you can't install node v4 as your "default" node installation, you +* We use node.js v4+ for development and testing. Due to incompatibilities with +JSDOM and older versions of node.js, you'll need to use node 4 and above to run the +tests. If you can't install node v4 or above as your "default" node installation, you could try using [nvm](https://github.com/creationix/nvm) to install multiple versions concurrently. * If you're upgrading your node.js 0.x environment, it's sometimes necessary diff --git a/HISTORY.md b/HISTORY.md index 67c687e5..deeba3b9 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,59 @@ # React-Select-Plus +## v1.0.0-rc.10 / 2017-09-13 + +* changed; `openAfterFocus` prop has been renamed to `openOnClick`, and now default to `true` +* fixed; React.PropTypes deprecation warning, thanks [Jeremy Liberman](https://github.com/MrLeebo) +* improved; scrolling behaviour when navigating the menu with the keyboard, thanks [boatkorachal](https://github.com/boatkorachal) +* fixed; error with the `Async` cache when you type `"hasOwnProperty"`, thanks [SuhushinAS](https://github.com/SuhushinAS) + +## v1.0.0-rc.9 / 2017-09-13 + +* fixed; clearable padding style, thanks [Minori Miyauchi](https://github.com/mmiyauchi) +* fixed; removed use of `Object.assign`, fixes IE compatibility +* added; new `closeOnSelect` prop (defaults to `true`) that controls whether the menu is closed when an option is selected, thanks to [Michael Elgar](https://github.com/melgar) for the original idea +* changed; by default, the menu for multi-selects now closes when an option is selected +* changed; `Async` component no longer always clears options when one is selected (although the menu is now closed by default). Use `closeOnSelect={false} onSelectResetsInput={false}` to leave the menu open. +* fixed; `Async` component always called `onChange` even when it wasn't provided +* fixed; input lag for the `Async` component when results are returned from cache +* fixed; required was not being updated without an onChange handler +* fixed; peer dependencies for `prop-types`, thanks [Michaël De Boey](https://github.com/MichaelDeBoey) +* fixed; internal optimisations, thanks [Kieran Boyle](https://github.com/dysfunc) +* added; `Value` component is now exported, thanks [Prof Gra](https://github.com/Grahack) +* fixed; callback fired after `Async` component unmounts, thanks [Andrew Russell](https://github.com/DeadHeadRussell) +* fixed; wrapping on Firefox in SCSS files, thanks [Michael Williamson](https://github.com/mwilliamson) + +## v1.0.0-rc.8 / 2017-09-12 + +* fixed; `onMenuScrollToBottom` does not work in chrome 58.0, thanks [Simon Hartcher](https://github.com/deevus) +* fixed; missing es6 module build for `js:next` entrypoint +* updated; `react-input-autosize@2.0.0` including several fixes for react-select (see [changes](https://github.com/JedWatson/react-input-autosize/blob/master/HISTORY.md)) + +## v1.0.0-rc.7 / 2017-09-11 + +* fixed; issue with `lib` build preventing use in ES2015 environments + +## v1.0.0-rc.6 / 2017-09-10 + +* fixed; changing `required` prop from `true` to `false` now works as expected, thanks [George Karagkiaouris](https://github.com/karaggeorge) +* added; new prop `onSelectResetsInput` controls whether the input value is cleared when options are selected, thanks [David Roeca](https://github.com/davidroeca) and [Alexander Nosov](https://github.com/nosovsh) +* fixed; tabindex parent bug fix for Edge, thanks [George Payne](https://github.com/George-A-Payne) +* fixed; update selectize link in README.md, thanks [kerumen](https://github.com/kerumen) +* added; standard issue template, thanks [agirton](https://github.com/agirton) +* added; new build process using rollup and webpack. Removed grunt. thanks [gwyneplaine](https://github.com/gwyneplaine) +* fixed; updated contributor docs with the correct node version reference [gwyneplaine](https://github.com/gwyneplaine) +* fixed; missing method binds in Option, thanks [agirton](https://github.com/agirton) +* fixed; converted components to use es6 classes, thanks [jochenberger](https://github.com/jochenberger) +* fixed; console.log example in usage docs, thanks [rohmanhm](https://github.com/rohmanhm) +* fixed; hide create option after closing menu, thanks [andreme](https://github.com/andreme) +* fixed; remove circular reference, thanks [agirton](https://github.com/agirton) +* fixed; readme typo, thanks [ieldanr](https:/github.com/ieldanr) +* fixed; add missing function binds in Option component, thanks [agirton](https://github.com/agirton) and [blacktemplar](https://github.com/blacktemplar) +* fixed; re-added fix to [#1580](https://github.com/JedWatson/react-select/issues/1580), thanks [agirton](https://github.com/agirton) +* fixed; avoid mutating user inputs when ignoring case/accents, thanks [not-an-aardvark](https://github.com/not-an-aardvark) +* fixed; issues synchronising options props in `Async`, thanks [cbergmiller](https://github.com/cbergmiller) +* fixed; backspace handling for non-multi select controls, thanks [Jeremy Liberman](https://github.com/MrLeebo) + ## v1.0.0-rc.5 / 2017-05-25 * fixed; Allow `falsey` values to be clearable, thanks [Simon Gaestel](https://github.com/sgaestel) diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md index b7451a6b..fb96d21b 100644 --- a/ISSUE_TEMPLATE.md +++ b/ISSUE_TEMPLATE.md @@ -1,9 +1,24 @@ ### Thanks for using react-select! -If you are reporting an error please include a test case that demonstrates the issue you're reporting! +Before creating an issue... + +# Are you asking a question? +Please don't file GitHub issues to ask questions. Use Stack Overflow with a [#react-select](http://stackoverflow.com/questions/tagged/react-select) tag + + +# Are you reporting a bug or runtime error? +Please include a test case that demonstrates the issue you're reporting! This is very helpful to maintainers in order to help us see the issue you're seeing. Here is a Plunker you can fork that has react-select loaded and supports JSX syntax: -https://plnkr.co/edit/HTmtER9AMNcPoWhXV707?p=preview +https://plnkr.co/edit/dHygFMWWqVwaRAfpEmbn?p=preview You may also find the [online Babel tool](https://babeljs.io/repl/) quite helpful if you wish to use ES6/ES7 syntax not yet supported by the browser you are using. + + +# Are you making a feature request? +Provide as much information as possible about your requested feature. Here are a few questions you may consider answering: + +* What's your use case? (Tell us about your application and what problem you're trying to solve.) +* What interface do you have in mind? (What new properties or methods do you think might be helpful?) +* Can you point to similar functionality with any existing libraries or components? (Working demos can be helpful.) diff --git a/LICENSE b/LICENSE index 58b127b3..4993fba5 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2016 HubSpot +Copyright (c) 2017 HubSpot Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 0d29bb38..316745fb 100644 --- a/README.md +++ b/README.md @@ -43,13 +43,15 @@ import Select from 'react-select-plus'; import 'react-select-plus/dist/react-select-plus.css'; ``` -You can also use the standalone build by including `react-select-plus.js` and `react-select-plus.css` in your page. (If you do this though you'll also need to include the dependencies.) For example: +You can also use the standalone UMD build by including `dist/react-select-plus.js` and `dist/react-select-plus.css` in your page. If you do this you'll also need to include the dependencies. For example: + ```html - - - - - + + + + + + ``` @@ -74,7 +76,7 @@ var options = [ ]; function logChange(val) { - console.log("Selected: " + val); + console.log("Selected: " + JSON.stringify(val)); } tag with this field name for html forms - noResultsText: stringOrNode, // placeholder displayed when there are no matching search results - onBlur: _propTypes2['default'].func, // onBlur handler: function (event) {} - onBlurResetsInput: _propTypes2['default'].bool, // whether input is cleared on blur - onChange: _propTypes2['default'].func, // onChange handler: function (newValue) {} - onClose: _propTypes2['default'].func, // fires when the menu is closed - onCloseResetsInput: _propTypes2['default'].bool, // whether input is cleared when menu is closed through the arrow - onFocus: _propTypes2['default'].func, // onFocus handler: function (event) {} - onInputChange: _propTypes2['default'].func, // onInputChange handler: function (inputValue) {} - onInputKeyDown: _propTypes2['default'].func, // input keyDown handler: function (event) {} - onMenuScrollToBottom: _propTypes2['default'].func, // fires when the menu is scrolled to the bottom; can be used to paginate options - onOpen: _propTypes2['default'].func, // fires when the menu is opened - onValueClick: _propTypes2['default'].func, // onClick handler for value labels: function (value, event) {} - openAfterFocus: _propTypes2['default'].bool, // boolean to enable opening dropdown when focused - openOnFocus: _propTypes2['default'].bool, // always open options menu on focus - optionClassName: _propTypes2['default'].string, // additional class(es) to apply to the