Skip to content

Commit

Permalink
Merged latest createable from master and built
Browse files Browse the repository at this point in the history
  • Loading branch information
f0urfingeredfish committed Dec 21, 2016
1 parent 6d64f9f commit 8e3426a
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 27 deletions.
29 changes: 24 additions & 5 deletions dist/react-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,15 @@ var Creatable = _react2['default'].createClass({
// ({ label: string, labelKey: string, valueKey: string }): Object
newOptionCreator: _react2['default'].PropTypes.func,

// input change handler: function (inputValue) {}
onInputChange: _react2['default'].PropTypes.func,

// input keyDown handler: function (event) {}
onInputKeyDown: _react2['default'].PropTypes.func,

// new option click handler: function (option) {}
onNewOptionClick: _react2['default'].PropTypes.func,

// See Select.propTypes.options
options: _react2['default'].PropTypes.array,

Expand Down Expand Up @@ -353,6 +362,7 @@ var Creatable = _react2['default'].createClass({
var _props = this.props;
var isValidNewOption = _props.isValidNewOption;
var newOptionCreator = _props.newOptionCreator;
var onNewOptionClick = _props.onNewOptionClick;
var _props$options = _props.options;
var options = _props$options === undefined ? [] : _props$options;
var shouldKeyDownEventCreateNewOption = _props.shouldKeyDownEventCreateNewOption;
Expand All @@ -363,9 +373,13 @@ var Creatable = _react2['default'].createClass({

// Don't add the same option twice.
if (_isOptionUnique) {
options.unshift(option);

this.select.selectValue(option);
if (onNewOptionClick) {
onNewOptionClick(option);
} else {
this.inputValue = '';
options.unshift(option);
this.select.selectValue(option);
}
}
}
},
Expand Down Expand Up @@ -405,7 +419,6 @@ var Creatable = _react2['default'].createClass({

this._createPlaceholderOption = _newOptionCreator({
label: _prompt,
inputValue: this.inputValue,
labelKey: this.labelKey,
valueKey: this.valueKey
});
Expand Down Expand Up @@ -436,11 +449,17 @@ var Creatable = _react2['default'].createClass({
var menuRenderer = this.props.menuRenderer;

return menuRenderer(_extends({}, params, {
onSelect: this.onOptionSelect
onSelect: this.onOptionSelect,
selectValue: this.onOptionSelect
}));
},

onInputChange: function onInputChange(input) {
var onInputChange = this.props.onInputChange;

if (onInputChange) {
onInputChange(input);
}
// This value may be needed in between Select mounts (when this.select is null)
this.inputValue = input;
},
Expand Down
4 changes: 2 additions & 2 deletions dist/react-select.min.js

Large diffs are not rendered by default.

29 changes: 24 additions & 5 deletions examples/dist/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,15 @@ var Creatable = _react2['default'].createClass({
// ({ label: string, labelKey: string, valueKey: string }): Object
newOptionCreator: _react2['default'].PropTypes.func,

// input change handler: function (inputValue) {}
onInputChange: _react2['default'].PropTypes.func,

// input keyDown handler: function (event) {}
onInputKeyDown: _react2['default'].PropTypes.func,

// new option click handler: function (option) {}
onNewOptionClick: _react2['default'].PropTypes.func,

// See Select.propTypes.options
options: _react2['default'].PropTypes.array,

Expand Down Expand Up @@ -348,6 +357,7 @@ var Creatable = _react2['default'].createClass({
var _props = this.props;
var isValidNewOption = _props.isValidNewOption;
var newOptionCreator = _props.newOptionCreator;
var onNewOptionClick = _props.onNewOptionClick;
var _props$options = _props.options;
var options = _props$options === undefined ? [] : _props$options;
var shouldKeyDownEventCreateNewOption = _props.shouldKeyDownEventCreateNewOption;
Expand All @@ -358,9 +368,13 @@ var Creatable = _react2['default'].createClass({

// Don't add the same option twice.
if (_isOptionUnique) {
options.unshift(option);

this.select.selectValue(option);
if (onNewOptionClick) {
onNewOptionClick(option);
} else {
this.inputValue = '';
options.unshift(option);
this.select.selectValue(option);
}
}
}
},
Expand Down Expand Up @@ -400,7 +414,6 @@ var Creatable = _react2['default'].createClass({

this._createPlaceholderOption = _newOptionCreator({
label: _prompt,
inputValue: this.inputValue,
labelKey: this.labelKey,
valueKey: this.valueKey
});
Expand Down Expand Up @@ -431,11 +444,17 @@ var Creatable = _react2['default'].createClass({
var menuRenderer = this.props.menuRenderer;

return menuRenderer(_extends({}, params, {
onSelect: this.onOptionSelect
onSelect: this.onOptionSelect,
selectValue: this.onOptionSelect
}));
},

onInputChange: function onInputChange(input) {
var onInputChange = this.props.onInputChange;

if (onInputChange) {
onInputChange(input);
}
// This value may be needed in between Select mounts (when this.select is null)
this.inputValue = input;
},
Expand Down
29 changes: 24 additions & 5 deletions examples/dist/standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,15 @@ var Creatable = _react2['default'].createClass({
// ({ label: string, labelKey: string, valueKey: string }): Object
newOptionCreator: _react2['default'].PropTypes.func,

// input change handler: function (inputValue) {}
onInputChange: _react2['default'].PropTypes.func,

// input keyDown handler: function (event) {}
onInputKeyDown: _react2['default'].PropTypes.func,

// new option click handler: function (option) {}
onNewOptionClick: _react2['default'].PropTypes.func,

// See Select.propTypes.options
options: _react2['default'].PropTypes.array,

Expand Down Expand Up @@ -353,6 +362,7 @@ var Creatable = _react2['default'].createClass({
var _props = this.props;
var isValidNewOption = _props.isValidNewOption;
var newOptionCreator = _props.newOptionCreator;
var onNewOptionClick = _props.onNewOptionClick;
var _props$options = _props.options;
var options = _props$options === undefined ? [] : _props$options;
var shouldKeyDownEventCreateNewOption = _props.shouldKeyDownEventCreateNewOption;
Expand All @@ -363,9 +373,13 @@ var Creatable = _react2['default'].createClass({

// Don't add the same option twice.
if (_isOptionUnique) {
options.unshift(option);

this.select.selectValue(option);
if (onNewOptionClick) {
onNewOptionClick(option);
} else {
this.inputValue = '';
options.unshift(option);
this.select.selectValue(option);
}
}
}
},
Expand Down Expand Up @@ -405,7 +419,6 @@ var Creatable = _react2['default'].createClass({

this._createPlaceholderOption = _newOptionCreator({
label: _prompt,
inputValue: this.inputValue,
labelKey: this.labelKey,
valueKey: this.valueKey
});
Expand Down Expand Up @@ -436,11 +449,17 @@ var Creatable = _react2['default'].createClass({
var menuRenderer = this.props.menuRenderer;

return menuRenderer(_extends({}, params, {
onSelect: this.onOptionSelect
onSelect: this.onOptionSelect,
selectValue: this.onOptionSelect
}));
},

onInputChange: function onInputChange(input) {
var onInputChange = this.props.onInputChange;

if (onInputChange) {
onInputChange(input);
}
// This value may be needed in between Select mounts (when this.select is null)
this.inputValue = input;
},
Expand Down
29 changes: 24 additions & 5 deletions lib/Creatable.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ var Creatable = _react2['default'].createClass({
// ({ label: string, labelKey: string, valueKey: string }): Object
newOptionCreator: _react2['default'].PropTypes.func,

// input change handler: function (inputValue) {}
onInputChange: _react2['default'].PropTypes.func,

// input keyDown handler: function (event) {}
onInputKeyDown: _react2['default'].PropTypes.func,

// new option click handler: function (option) {}
onNewOptionClick: _react2['default'].PropTypes.func,

// See Select.propTypes.options
options: _react2['default'].PropTypes.array,

Expand Down Expand Up @@ -86,6 +95,7 @@ var Creatable = _react2['default'].createClass({
var _props = this.props;
var isValidNewOption = _props.isValidNewOption;
var newOptionCreator = _props.newOptionCreator;
var onNewOptionClick = _props.onNewOptionClick;
var _props$options = _props.options;
var options = _props$options === undefined ? [] : _props$options;
var shouldKeyDownEventCreateNewOption = _props.shouldKeyDownEventCreateNewOption;
Expand All @@ -96,9 +106,13 @@ var Creatable = _react2['default'].createClass({

// Don't add the same option twice.
if (_isOptionUnique) {
options.unshift(option);

this.select.selectValue(option);
if (onNewOptionClick) {
onNewOptionClick(option);
} else {
this.inputValue = '';
options.unshift(option);
this.select.selectValue(option);
}
}
}
},
Expand Down Expand Up @@ -138,7 +152,6 @@ var Creatable = _react2['default'].createClass({

this._createPlaceholderOption = _newOptionCreator({
label: _prompt,
inputValue: this.inputValue,
labelKey: this.labelKey,
valueKey: this.valueKey
});
Expand Down Expand Up @@ -169,11 +182,17 @@ var Creatable = _react2['default'].createClass({
var menuRenderer = this.props.menuRenderer;

return menuRenderer(_extends({}, params, {
onSelect: this.onOptionSelect
onSelect: this.onOptionSelect,
selectValue: this.onOptionSelect
}));
},

onInputChange: function onInputChange(input) {
var onInputChange = this.props.onInputChange;

if (onInputChange) {
onInputChange(input);
}
// This value may be needed in between Select mounts (when this.select is null)
this.inputValue = input;
},
Expand Down
28 changes: 23 additions & 5 deletions src/Creatable.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ const Creatable = React.createClass({
// ({ label: string, labelKey: string, valueKey: string }): Object
newOptionCreator: React.PropTypes.func,

// input change handler: function (inputValue) {}
onInputChange: React.PropTypes.func,

// input keyDown handler: function (event) {}
onInputKeyDown: React.PropTypes.func,

// new option click handler: function (option) {}
onNewOptionClick: React.PropTypes.func,

// See Select.propTypes.options
options: React.PropTypes.array,

Expand Down Expand Up @@ -67,6 +76,7 @@ const Creatable = React.createClass({
const {
isValidNewOption,
newOptionCreator,
onNewOptionClick,
options = [],
shouldKeyDownEventCreateNewOption
} = this.props;
Expand All @@ -77,10 +87,13 @@ const Creatable = React.createClass({

// Don't add the same option twice.
if (isOptionUnique) {
options.unshift(option);

this.select.selectValue(option);
if (onNewOptionClick) {
onNewOptionClick(option);
} else {
this.inputValue = '';
options.unshift(option);
this.select.selectValue(option);
}
}
}
},
Expand Down Expand Up @@ -116,7 +129,6 @@ const Creatable = React.createClass({

this._createPlaceholderOption = newOptionCreator({
label: prompt,
inputValue: this.inputValue,
labelKey: this.labelKey,
valueKey: this.valueKey
});
Expand Down Expand Up @@ -149,11 +161,17 @@ const Creatable = React.createClass({

return menuRenderer({
...params,
onSelect: this.onOptionSelect
onSelect: this.onOptionSelect,
selectValue: this.onOptionSelect
});
},

onInputChange (input) {
const { onInputChange } = this.props;

if (onInputChange) {
onInputChange(input);
}
// This value may be needed in between Select mounts (when this.select is null)
this.inputValue = input;
},
Expand Down

0 comments on commit 8e3426a

Please sign in to comment.