Skip to content

Commit 8ff4596

Browse files
authored
Merge pull request JedWatson#1658 from agirton/migrate-to-external-pkgs
Migrate to prop-types and create-react-class packages
2 parents a0e5855 + 03b3da2 commit 8ff4596

18 files changed

+197
-164
lines changed

examples/src/components/BooleanSelect.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import React from 'react';
2+
import createClass from 'create-react-class';
3+
import PropTypes from 'prop-types';
24
import Select from 'react-select';
35

4-
var ValuesAsBooleansField = React.createClass({
6+
var ValuesAsBooleansField = createClass({
57
displayName: 'ValuesAsBooleansField',
68
propTypes: {
7-
label: React.PropTypes.string
9+
label: PropTypes.string
810
},
911
getInitialState () {
1012
return {

examples/src/components/Contributors.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import React from 'react';
2+
import createClass from 'create-react-class';
3+
import PropTypes from 'prop-types';
24
import Select from 'react-select';
35

46
const CONTRIBUTORS = require('../data/contributors');
57
const MAX_CONTRIBUTORS = 6;
68
const ASYNC_DELAY = 500;
79

8-
const Contributors = React.createClass({
10+
const Contributors = createClass({
911
displayName: 'Contributors',
1012
propTypes: {
11-
label: React.PropTypes.string,
13+
label: PropTypes.string,
1214
},
1315
getInitialState () {
1416
return {

examples/src/components/Creatable.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import React from 'react';
2+
import createClass from 'create-react-class';
3+
import PropTypes from 'prop-types';
24
import Select from 'react-select';
35

4-
var CreatableDemo = React.createClass({
6+
var CreatableDemo = createClass({
57
displayName: 'CreatableDemo',
68
propTypes: {
7-
hint: React.PropTypes.string,
8-
label: React.PropTypes.string
9+
hint: PropTypes.string,
10+
label: PropTypes.string
911
},
1012
getInitialState () {
1113
return {

examples/src/components/CustomComponents.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
import React from 'react';
2+
import createClass from 'create-react-class';
3+
import PropTypes from 'prop-types';
24
import Select from 'react-select';
35
import Gravatar from 'react-gravatar';
46

57
const USERS = require('../data/users');
68
const GRAVATAR_SIZE = 15;
79

8-
const GravatarOption = React.createClass({
10+
const GravatarOption = createClass({
911
propTypes: {
10-
children: React.PropTypes.node,
11-
className: React.PropTypes.string,
12-
isDisabled: React.PropTypes.bool,
13-
isFocused: React.PropTypes.bool,
14-
isSelected: React.PropTypes.bool,
15-
onFocus: React.PropTypes.func,
16-
onSelect: React.PropTypes.func,
17-
option: React.PropTypes.object.isRequired,
12+
children: PropTypes.node,
13+
className: PropTypes.string,
14+
isDisabled: PropTypes.bool,
15+
isFocused: PropTypes.bool,
16+
isSelected: PropTypes.bool,
17+
onFocus: PropTypes.func,
18+
onSelect: PropTypes.func,
19+
option: PropTypes.object.isRequired,
1820
},
1921
handleMouseDown (event) {
2022
event.preventDefault();
@@ -50,11 +52,11 @@ const GravatarOption = React.createClass({
5052
}
5153
});
5254

53-
const GravatarValue = React.createClass({
55+
const GravatarValue = createClass({
5456
propTypes: {
55-
children: React.PropTypes.node,
56-
placeholder: React.PropTypes.string,
57-
value: React.PropTypes.object
57+
children: PropTypes.node,
58+
placeholder: PropTypes.string,
59+
value: PropTypes.object
5860
},
5961
render () {
6062
var gravatarStyle = {
@@ -76,10 +78,10 @@ const GravatarValue = React.createClass({
7678
}
7779
});
7880

79-
const UsersField = React.createClass({
81+
const UsersField = createClass({
8082
propTypes: {
81-
hint: React.PropTypes.string,
82-
label: React.PropTypes.string,
83+
hint: PropTypes.string,
84+
label: PropTypes.string,
8385
},
8486
getInitialState () {
8587
return {};

examples/src/components/CustomRender.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import React from 'react';
2+
import createClass from 'create-react-class';
3+
import PropTypes from 'prop-types';
24
import Select from 'react-select';
35
import Highlighter from 'react-highlight-words';
46

5-
var DisabledUpsellOptions = React.createClass({
7+
var DisabledUpsellOptions = createClass({
68
displayName: 'DisabledUpsellOptions',
79
propTypes: {
8-
label: React.PropTypes.string,
10+
label: PropTypes.string,
911
},
1012
getInitialState () {
1113
return {};

examples/src/components/GithubUsers.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import React from 'react';
2+
import createClass from 'create-react-class';
3+
import PropTypes from 'prop-types';
24
import Select from 'react-select';
35
import fetch from 'isomorphic-fetch';
46

57

6-
const GithubUsers = React.createClass({
8+
const GithubUsers = createClass({
79
displayName: 'GithubUsers',
810
propTypes: {
9-
label: React.PropTypes.string,
11+
label: PropTypes.string,
1012
},
1113
getInitialState () {
1214
return {

examples/src/components/Multiselect.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import React from 'react';
2+
import createClass from 'create-react-class';
3+
import PropTypes from 'prop-types';
24
import Select from 'react-select';
35

46
const FLAVOURS = [
@@ -14,10 +16,10 @@ const WHY_WOULD_YOU = [
1416
{ label: 'Chocolate (are you crazy?)', value: 'chocolate', disabled: true },
1517
].concat(FLAVOURS.slice(1));
1618

17-
var MultiSelectField = React.createClass({
19+
var MultiSelectField = createClass({
1820
displayName: 'MultiSelectField',
1921
propTypes: {
20-
label: React.PropTypes.string,
22+
label: PropTypes.string,
2123
},
2224
getInitialState () {
2325
return {

examples/src/components/NumericSelect.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import React from 'react';
2+
import createClass from 'create-react-class';
3+
import PropTypes from 'prop-types';
24
import Select from 'react-select';
35

4-
var ValuesAsNumbersField = React.createClass({
6+
var ValuesAsNumbersField = createClass({
57
displayName: 'ValuesAsNumbersField',
68
propTypes: {
7-
label: React.PropTypes.string
9+
label: PropTypes.string
810
},
911
getInitialState () {
1012
return {

examples/src/components/States.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import React from 'react';
2+
import createClass from 'create-react-class';
3+
import PropTypes from 'prop-types';
24
import Select from 'react-select';
35

46
const STATES = require('../data/states');
57

6-
var StatesField = React.createClass({
8+
var StatesField = createClass({
79
displayName: 'StatesField',
810
propTypes: {
9-
label: React.PropTypes.string,
10-
searchable: React.PropTypes.bool,
11+
label: PropTypes.string,
12+
searchable: PropTypes.bool,
1113
},
1214
getDefaultProps () {
1315
return {

examples/src/components/Virtualized.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import React from 'react';
2+
import createClass from 'create-react-class';
23
import VirtualizedSelect from 'react-virtualized-select';
34

45
const DATA = require('../data/cities');
56

6-
var CitiesField = React.createClass({
7+
var CitiesField = createClass({
78
displayName: 'CitiesField',
89
getInitialState () {
910
return {};

gulpfile.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ var taskConfig = {
99
'classnames',
1010
'react-input-autosize',
1111
'react',
12-
'react-dom'
12+
'react-dom',
13+
'create-react-class',
14+
'prop-types'
1315
],
1416
less: {
1517
path: 'less',

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
"url": "https://github.com/JedWatson/react-select.git"
1212
},
1313
"dependencies": {
14+
"create-react-class": "^15.5.2",
1415
"classnames": "^2.2.4",
15-
"react-input-autosize": "^1.1.0"
16+
"react-input-autosize": "^1.1.3",
17+
"prop-types": "^15.5.8"
1618
},
1719
"devDependencies": {
1820
"babel": "^5.8.23",

src/Async.js

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,36 @@
1-
import React, { Component, PropTypes } from 'react';
1+
import React, { Component } from 'react';
2+
import PropTypes from 'prop-types';
23
import Select from './Select';
34
import stripDiacritics from './utils/stripDiacritics';
45

56
const propTypes = {
6-
autoload: React.PropTypes.bool.isRequired, // automatically call the `loadOptions` prop on-mount; defaults to true
7-
cache: React.PropTypes.any, // object to use to cache results; set to null/false to disable caching
8-
children: React.PropTypes.func.isRequired, // Child function responsible for creating the inner Select component; (props: Object): PropTypes.element
9-
ignoreAccents: React.PropTypes.bool, // strip diacritics when filtering; defaults to true
10-
ignoreCase: React.PropTypes.bool, // perform case-insensitive filtering; defaults to true
11-
loadingPlaceholder: React.PropTypes.oneOfType([ // replaces the placeholder while options are loading
12-
React.PropTypes.string,
13-
React.PropTypes.node
7+
autoload: PropTypes.bool.isRequired, // automatically call the `loadOptions` prop on-mount; defaults to true
8+
cache: PropTypes.any, // object to use to cache results; set to null/false to disable caching
9+
children: PropTypes.func.isRequired, // Child function responsible for creating the inner Select component; (props: Object): PropTypes.element
10+
ignoreAccents: PropTypes.bool, // strip diacritics when filtering; defaults to true
11+
ignoreCase: PropTypes.bool, // perform case-insensitive filtering; defaults to true
12+
loadingPlaceholder: PropTypes.oneOfType([ // replaces the placeholder while options are loading
13+
PropTypes.string,
14+
PropTypes.node
1415
]),
15-
loadOptions: React.PropTypes.func.isRequired, // callback to load options asynchronously; (inputValue: string, callback: Function): ?Promise
16-
multi: React.PropTypes.bool, // multi-value input
16+
loadOptions: PropTypes.func.isRequired, // callback to load options asynchronously; (inputValue: string, callback: Function): ?Promise
17+
multi: PropTypes.bool, // multi-value input
1718
options: PropTypes.array.isRequired, // array of options
18-
placeholder: React.PropTypes.oneOfType([ // field placeholder, displayed when there's no value (shared with Select)
19-
React.PropTypes.string,
20-
React.PropTypes.node
19+
placeholder: PropTypes.oneOfType([ // field placeholder, displayed when there's no value (shared with Select)
20+
PropTypes.string,
21+
PropTypes.node
2122
]),
22-
noResultsText: React.PropTypes.oneOfType([ // field noResultsText, displayed when no options come back from the server
23-
React.PropTypes.string,
24-
React.PropTypes.node
23+
noResultsText: PropTypes.oneOfType([ // field noResultsText, displayed when no options come back from the server
24+
PropTypes.string,
25+
PropTypes.node
2526
]),
26-
onChange: React.PropTypes.func, // onChange handler: function (newValue) {}
27-
searchPromptText: React.PropTypes.oneOfType([ // label to prompt for search input
28-
React.PropTypes.string,
29-
React.PropTypes.node
27+
onChange: PropTypes.func, // onChange handler: function (newValue) {}
28+
searchPromptText: PropTypes.oneOfType([ // label to prompt for search input
29+
PropTypes.string,
30+
PropTypes.node
3031
]),
31-
onInputChange: React.PropTypes.func, // optional for keeping track of what is being typed
32-
value: React.PropTypes.any, // initial field value
32+
onInputChange: PropTypes.func, // optional for keeping track of what is being typed
33+
value: PropTypes.any, // initial field value
3334
};
3435

3536
const defaultCache = {};
@@ -214,4 +215,4 @@ function defaultChildren (props) {
214215
return (
215216
<Select {...props} />
216217
);
217-
};
218+
}

src/AsyncCreatable.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react';
2+
import createClass from 'create-react-class';
23
import Select from './Select';
34

45
function reduce(obj, props = {}){
@@ -10,7 +11,7 @@ function reduce(obj, props = {}){
1011
}, props);
1112
}
1213

13-
const AsyncCreatable = React.createClass({
14+
const AsyncCreatable = createClass({
1415
displayName: 'AsyncCreatableSelect',
1516

1617
focus () {

src/Creatable.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,56 @@
11
import React from 'react';
2+
import createClass from 'create-react-class';
3+
import PropTypes from 'prop-types';
24
import Select from './Select';
35
import defaultFilterOptions from './utils/defaultFilterOptions';
46
import defaultMenuRenderer from './utils/defaultMenuRenderer';
57

6-
const Creatable = React.createClass({
8+
const Creatable = createClass({
79
displayName: 'CreatableSelect',
810

911
propTypes: {
1012
// Child function responsible for creating the inner Select component
1113
// This component can be used to compose HOCs (eg Creatable and Async)
1214
// (props: Object): PropTypes.element
13-
children: React.PropTypes.func,
15+
children: PropTypes.func,
1416

1517
// See Select.propTypes.filterOptions
16-
filterOptions: React.PropTypes.any,
18+
filterOptions: PropTypes.any,
1719

1820
// Searches for any matching option within the set of options.
1921
// This function prevents duplicate options from being created.
2022
// ({ option: Object, options: Array, labelKey: string, valueKey: string }): boolean
21-
isOptionUnique: React.PropTypes.func,
23+
isOptionUnique: PropTypes.func,
2224

2325
// Determines if the current input text represents a valid option.
2426
// ({ label: string }): boolean
25-
isValidNewOption: React.PropTypes.func,
27+
isValidNewOption: PropTypes.func,
2628

2729
// See Select.propTypes.menuRenderer
28-
menuRenderer: React.PropTypes.any,
30+
menuRenderer: PropTypes.any,
2931

3032
// Factory to create new option.
3133
// ({ label: string, labelKey: string, valueKey: string }): Object
32-
newOptionCreator: React.PropTypes.func,
34+
newOptionCreator: PropTypes.func,
3335

3436
// input change handler: function (inputValue) {}
35-
onInputChange: React.PropTypes.func,
37+
onInputChange: PropTypes.func,
3638

3739
// input keyDown handler: function (event) {}
38-
onInputKeyDown: React.PropTypes.func,
40+
onInputKeyDown: PropTypes.func,
3941

4042
// new option click handler: function (option) {}
41-
onNewOptionClick: React.PropTypes.func,
43+
onNewOptionClick: PropTypes.func,
4244

4345
// See Select.propTypes.options
44-
options: React.PropTypes.array,
46+
options: PropTypes.array,
4547

4648
// Creates prompt/placeholder option text.
4749
// (filterText: string): string
48-
promptTextCreator: React.PropTypes.func,
50+
promptTextCreator: PropTypes.func,
4951

5052
// Decides if a keyDown event (eg its `keyCode`) should result in the creation of a new option.
51-
shouldKeyDownEventCreateNewOption: React.PropTypes.func,
53+
shouldKeyDownEventCreateNewOption: PropTypes.func,
5254
},
5355

5456
// Default prop methods

0 commit comments

Comments
 (0)