Skip to content

Commit

Permalink
Adding built files
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregoor committed Mar 22, 2015
1 parent f8fcac8 commit 3ebf518
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 8 deletions.
19 changes: 19 additions & 0 deletions dist/react-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ var Select = React.createClass({
matchPos: React.PropTypes.string, // (any|start) match the start or entire string when filtering
matchProp: React.PropTypes.string, // (any|label|value) which option property to filter on
inputProps: React.PropTypes.object, // custom attributes for the Input (in the Select-control) e.g: {'data-foo': 'bar'}
createable: React.PropTypes.bool, // whether a new option can be created by giving a name
createText: React.PropTypes.string, // text to be displayed after the new option

/*
* Allow user to make option label clickable. When this handler is defined we should
Expand Down Expand Up @@ -73,6 +75,8 @@ var Select = React.createClass({
matchPos: "any",
matchProp: "any",
inputProps: {},
createable: false,
createText: "(create new)",

onOptionLabelClick: undefined
};
Expand Down Expand Up @@ -393,6 +397,8 @@ var Select = React.createClass({
}, this._bindCloseMenuIfClickedOutside);
} else {
var filteredOptions = this.filterOptions(this.state.options);
filteredOptions = this.addCreateOption(filteredOptions, event.target.value);

this.setState({
isOpen: true,
inputValue: event.target.value,
Expand All @@ -414,6 +420,7 @@ var Select = React.createClass({
if (this._optionsCache[cacheKey] && (input === cacheKey || this._optionsCache[cacheKey].complete)) {
var options = this._optionsCache[cacheKey].options;
var filteredOptions = this.filterOptions(options);
filteredOptions = this.addCreateOption(filteredOptions, input);

this.setState(_.extend({
options: options,
Expand All @@ -434,6 +441,7 @@ var Select = React.createClass({
return;
}
var filteredOptions = this.filterOptions(data.options);
filteredOptions = this.addCreateOption(filteredOptions, input);

this.setState(_.extend({
options: data.options,
Expand Down Expand Up @@ -581,6 +589,17 @@ var Select = React.createClass({
}
},

addCreateOption: function addCreateOption(options, input) {
options = _.cloneDeep(options);
if (this.props.createable && input && !_.findWhere(options, { label: input })) {
options.push({
value: input,
label: input + " " + this.props.createText
});
}
return options;
},

render: function render() {
var selectClass = classes("Select", this.props.className, {
"is-multi": this.props.multi,
Expand Down
2 changes: 1 addition & 1 deletion dist/react-select.min.js

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions examples/dist/app.js

Large diffs are not rendered by default.

22 changes: 21 additions & 1 deletion examples/dist/bundle.js

Large diffs are not rendered by default.

Loading

0 comments on commit 3ebf518

Please sign in to comment.