react-fuzzy
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -123,3 +123,3 @@ 'use strict'; | ||
selectedIndex: 0, | ||
value: '' | ||
value: props.inputProps.defaultValue || '' | ||
}; | ||
@@ -173,5 +173,12 @@ _this.handleChange = _this.handleChange.bind(_this); | ||
value: function handleChange(e) { | ||
e.persist(); | ||
if (this.props.inputProps.onChange) { | ||
this.props.inputProps.onChange(e); | ||
} | ||
var shouldDisplayAllListItems = this.props.shouldShowDropdownAtStart && !e.target.value; | ||
this.setState({ | ||
isOpen: true, | ||
results: shouldDisplayAllListItems ? this.props.list : this.fuse.search(e.target.value).slice(0, this.props.maxResults - 1), | ||
@@ -240,2 +247,4 @@ value: e.target.value | ||
className = _props2.className, | ||
inputProps = _props2.inputProps, | ||
isDropdown = _props2.isDropdown, | ||
list = _props2.list, | ||
@@ -264,3 +273,4 @@ placeholder = _props2.placeholder, | ||
if (shouldShowDropdownAtStart) { | ||
// Check shouldShowDropdownAtStart for backwards-compatibility. | ||
if (isDropdown || shouldShowDropdownAtStart) { | ||
_this2.setState({ | ||
@@ -276,3 +286,3 @@ isOpen: false | ||
{ style: (0, _extends3.default)({}, styles.searchBoxWrapper, this.props.inputWrapperStyle) }, | ||
_react2.default.createElement('input', { | ||
_react2.default.createElement('input', (0, _extends3.default)({}, inputProps, { | ||
autoFocus: autoFocus, | ||
@@ -284,3 +294,3 @@ onChange: this.handleChange, | ||
value: this.state.value, | ||
onFocus: function onFocus() { | ||
onFocus: function onFocus(e) { | ||
if (shouldShowDropdownAtStart) { | ||
@@ -292,4 +302,8 @@ _this2.setState({ | ||
} | ||
if (inputProps.onFocus) { | ||
inputProps.onFocus(e); | ||
} | ||
} | ||
}) | ||
})) | ||
), | ||
@@ -313,2 +327,4 @@ this.state.isOpen && this.state.results && this.state.results.length > 0 && _react2.default.createElement( | ||
include: _propTypes2.default.array, | ||
inputProps: _propTypes2.default.object, | ||
isDropdown: _propTypes2.default.bool, | ||
maxPatternLength: _propTypes2.default.number, | ||
@@ -342,2 +358,4 @@ onSelect: _propTypes2.default.func.isRequired, | ||
include: [], | ||
inputProps: {}, | ||
isDropdown: false, | ||
keyForDisplayName: 'title', | ||
@@ -344,0 +362,0 @@ location: 0, |
{ | ||
"name": "react-fuzzy", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "React Fuzzy Component", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -72,4 +72,6 @@ # react-fuzzy | ||
className|null|give a custom class name to the root element | ||
inputProps|{}|Props passed directly to the input element. i.e. `defaultValue`, `onChange`, etc. | ||
inputStyle|{}|Styles passed directly to the `input` element. | ||
inputWrapperStyle|{}|Styles passed directly to the `input` wrapper `div`. | ||
isDropdown|false|Hide the result list on blur. | ||
listItemStyle|{}|Styles passed to each item in the dropdown list. | ||
@@ -76,0 +78,0 @@ listWrapperStyle|{}|Styles passed directly to the dropdown wrapper. |
24660
450
101