Skip to content

Commit

Permalink
Updating build
Browse files Browse the repository at this point in the history
  • Loading branch information
JedWatson committed Apr 2, 2016
1 parent 1005f0f commit b2a0da1
Show file tree
Hide file tree
Showing 11 changed files with 19,417 additions and 15,807 deletions.
1 change: 1 addition & 0 deletions dist/react-select.css
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
vertical-align: middle;
}
.Select-input > input {
width: 100%;
background: none transparent;
border: 0 none;
box-shadow: none;
Expand Down
165 changes: 114 additions & 51 deletions dist/react-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ var Select = _react2['default'].createClass({
allowCreate: _react2['default'].PropTypes.bool, // whether to allow creation of new entries
autoBlur: _react2['default'].PropTypes.bool,
autofocus: _react2['default'].PropTypes.bool, // autofocus the component on mount
autosize: _react2['default'].PropTypes.bool, // whether to enable autosizing or not
backspaceRemoves: _react2['default'].PropTypes.bool, // whether backspace removes an item if there is no text input
className: _react2['default'].PropTypes.string, // className for the outer element
clearAllText: stringOrNode, // title for the "clear" control when multi: true
Expand All @@ -355,11 +356,13 @@ var Select = _react2['default'].createClass({
ignoreCase: _react2['default'].PropTypes.bool, // whether to perform case-insensitive filtering
inputProps: _react2['default'].PropTypes.object, // custom attributes for the Input
isLoading: _react2['default'].PropTypes.bool, // whether the Select is loading externally or not (such as options being loaded)
joinValues: _react2['default'].PropTypes.bool, // joins multiple values into a single form field with the delimiter (legacy mode)
labelKey: _react2['default'].PropTypes.string, // path of the label value in option objects
matchPos: _react2['default'].PropTypes.string, // (any|start) match the start or entire string when filtering
matchProp: _react2['default'].PropTypes.string, // (any|label|value) which option property to filter on
menuBuffer: _react2['default'].PropTypes.number, // optional buffer (in px) between the bottom of the viewport and the bottom of the menu
menuContainerStyle: _react2['default'].PropTypes.object, // optional style to apply to the menu container
menuRenderer: _react2['default'].PropTypes.func, // renders a custom menu with options
menuStyle: _react2['default'].PropTypes.object, // optional style to apply to the menu
multi: _react2['default'].PropTypes.bool, // multi-value input
name: _react2['default'].PropTypes.string, // generates a hidden <input /> tag with this field name for html forms
Expand All @@ -374,6 +377,8 @@ var Select = _react2['default'].createClass({
onMenuScrollToBottom: _react2['default'].PropTypes.func, // fires when the menu is scrolled to the bottom; can be used to paginate options
onOpen: _react2['default'].PropTypes.func, // fires when the menu is opened
onValueClick: _react2['default'].PropTypes.func, // onClick handler for value labels: function (value, event) {}
openAfterFocus: _react2['default'].PropTypes.bool, // boolean to enable opening dropdown when focused
optionClassName: _react2['default'].PropTypes.string, // additional class(es) to apply to the <Option /> elements
optionComponent: _react2['default'].PropTypes.func, // option component to render in dropdown
optionRenderer: _react2['default'].PropTypes.func, // optionRenderer: function (option) {}
options: _react2['default'].PropTypes.array, // array of options
Expand All @@ -396,6 +401,7 @@ var Select = _react2['default'].createClass({
getDefaultProps: function getDefaultProps() {
return {
addLabelText: 'Add "{label}"?',
autosize: true,
allowCreate: false,
backspaceRemoves: true,
clearable: true,
Expand All @@ -409,13 +415,15 @@ var Select = _react2['default'].createClass({
ignoreCase: true,
inputProps: {},
isLoading: false,
joinValues: false,
labelKey: 'label',
matchPos: 'any',
matchProp: 'any',
menuBuffer: 0,
multi: false,
noResultsText: 'No results found',
onBlurResetsInput: true,
openAfterFocus: false,
optionComponent: _Option2['default'],
placeholder: 'Select...',
required: false,
Expand Down Expand Up @@ -444,6 +452,14 @@ var Select = _react2['default'].createClass({
}
},

componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
if (this.props.value !== nextProps.value && nextProps.required) {
this.setState({
required: this.handleRequired(nextProps.value, nextProps.multi)
});
}
},

componentWillUpdate: function componentWillUpdate(nextProps, nextState) {
if (nextState.isOpen !== this.state.isOpen) {
var handler = nextState.isOpen ? nextProps.onOpen : nextProps.onClose;
Expand Down Expand Up @@ -489,6 +505,12 @@ var Select = _react2['default'].createClass({
focus: function focus() {
if (!this.refs.input) return;
this.refs.input.focus();

if (this.props.openAfterFocus) {
this.setState({
isOpen: true
});
}
},

blurInput: function blurInput() {
Expand Down Expand Up @@ -930,17 +952,32 @@ var Select = _react2['default'].createClass({
ref: 'input',
style: { border: 0, width: 1, display: 'inline-block' } }));
}
return _react2['default'].createElement(_reactInputAutosize2['default'], _extends({}, this.props.inputProps, {
className: className,
tabIndex: this.props.tabIndex,
onBlur: this.handleInputBlur,
onChange: this.handleInputChange,
onFocus: this.handleInputFocus,
minWidth: '5',
ref: 'input',
required: this.state.required,
value: this.state.inputValue
}));
if (this.props.autosize) {
return _react2['default'].createElement(_reactInputAutosize2['default'], _extends({}, this.props.inputProps, {
className: className,
tabIndex: this.props.tabIndex,
onBlur: this.handleInputBlur,
onChange: this.handleInputChange,
onFocus: this.handleInputFocus,
minWidth: '5',
ref: 'input',
required: this.state.required,
value: this.state.inputValue
}));
}
return _react2['default'].createElement(
'div',
{ className: className },
_react2['default'].createElement('input', _extends({}, this.props.inputProps, {
tabIndex: this.props.tabIndex,
onBlur: this.handleInputBlur,
onChange: this.handleInputChange,
onFocus: this.handleInputFocus,
ref: 'input',
required: this.state.required,
value: this.state.inputValue
}))
);
},

renderClear: function renderClear() {
Expand Down Expand Up @@ -1007,42 +1044,53 @@ var Select = _react2['default'].createClass({
var _this4 = this;

if (options && options.length) {
var _ret = (function () {
var Option = _this4.props.optionComponent;
var renderLabel = _this4.props.optionRenderer || _this4.getOptionLabel;

return {
v: options.map(function (option, i) {
var isSelected = valueArray && valueArray.indexOf(option) > -1;
var isFocused = option === focusedOption;
var optionRef = isFocused ? 'focused' : null;
var optionClass = (0, _classnames2['default'])({
'Select-option': true,
'is-selected': isSelected,
'is-focused': isFocused,
'is-disabled': option.disabled
});

return _react2['default'].createElement(
Option,
{
className: optionClass,
isDisabled: option.disabled,
isFocused: isFocused,
key: 'option-' + i + '-' + option[_this4.props.valueKey],
onSelect: _this4.selectValue,
onFocus: _this4.focusOption,
option: option,
isSelected: isSelected,
ref: optionRef
},
renderLabel(option)
);
})
};
})();

if (typeof _ret === 'object') return _ret.v;
if (this.props.menuRenderer) {
return this.props.menuRenderer({
focusedOption: focusedOption,
focusOption: this.focusOption,
labelKey: this.props.labelKey,
options: options,
selectValue: this.selectValue,
valueArray: valueArray
});
} else {
var _ret = (function () {
var Option = _this4.props.optionComponent;
var renderLabel = _this4.props.optionRenderer || _this4.getOptionLabel;

return {
v: options.map(function (option, i) {
var isSelected = valueArray && valueArray.indexOf(option) > -1;
var isFocused = option === focusedOption;
var optionRef = isFocused ? 'focused' : null;
var optionClass = (0, _classnames2['default'])(_this4.props.optionClassName, {
'Select-option': true,
'is-selected': isSelected,
'is-focused': isFocused,
'is-disabled': option.disabled
});

return _react2['default'].createElement(
Option,
{
className: optionClass,
isDisabled: option.disabled,
isFocused: isFocused,
key: 'option-' + i + '-' + option[_this4.props.valueKey],
onSelect: _this4.selectValue,
onFocus: _this4.focusOption,
option: option,
isSelected: isSelected,
ref: optionRef
},
renderLabel(option)
);
})
};
})();

if (typeof _ret === 'object') return _ret.v;
}
} else if (this.props.noResultsText) {
return _react2['default'].createElement(
'div',
Expand All @@ -1058,10 +1106,25 @@ var Select = _react2['default'].createClass({
var _this5 = this;

if (!this.props.name) return;
var value = valueArray.map(function (i) {
return stringifyValue(i[_this5.props.valueKey]);
}).join(this.props.delimiter);
return _react2['default'].createElement('input', { type: 'hidden', ref: 'value', name: this.props.name, value: value, disabled: this.props.disabled });
if (this.props.joinValues) {
var value = valueArray.map(function (i) {
return stringifyValue(i[_this5.props.valueKey]);
}).join(this.props.delimiter);
return _react2['default'].createElement('input', {
type: 'hidden',
ref: 'value',
name: this.props.name,
value: value,
disabled: this.props.disabled });
}
return valueArray.map(function (item, index) {
return _react2['default'].createElement('input', { key: 'hidden.' + index,
type: 'hidden',
ref: 'value' + index,
name: _this5.props.name,
value: stringifyValue(item[_this5.props.valueKey]),
disabled: _this5.props.disabled });
});
},

getFocusableOption: function getFocusableOption(selectedOption) {
Expand Down
Loading

0 comments on commit b2a0da1

Please sign in to comment.