rc-select
Advanced tools
Comparing version 3.3.5 to 3.4.0
# History | ||
---- | ||
## 3.4.0 / 2015-06-15 | ||
`new` support showSearch/animation/transitionName/disabled props | ||
## 3.1.0 / 2015-03-23 | ||
`new` [#2](https://github.com/react-component/select/pull/2) support tags config |
@@ -20,2 +20,3 @@ 'use strict'; | ||
var MenuItem = Menu.Item; | ||
var anim = require('css-animation'); | ||
@@ -150,2 +151,3 @@ function isMultipleOrTags(props) { | ||
var refs = this.refs; | ||
this.setState({ | ||
@@ -155,5 +157,7 @@ open: open | ||
if (open || isMultipleOrTags(_this2.props) || _this2.props.combobox) { | ||
_this2.refs.input.getDOMNode().focus(); | ||
} else { | ||
_this2.refs.selection.getDOMNode().focus(); | ||
if (refs.input) { | ||
React.findDOMNode(refs.input).focus(); | ||
} | ||
} else if (refs.selection) { | ||
React.findDOMNode(refs.selection).focus(); | ||
} | ||
@@ -180,3 +184,5 @@ }); | ||
value: function handleClick() { | ||
this.setOpenState(!this.state.open); | ||
if (!this.props.disabled) { | ||
this.setOpenState(!this.state.open); | ||
} | ||
} | ||
@@ -189,3 +195,5 @@ }, { | ||
var keyCode = e.keyCode; | ||
if (keyCode === KeyCode.ENTER || e.keyCode === KeyCode.DOWN) { | ||
if (this.state.open && !this.refs.input) { | ||
this.handleInputKeyDown(e); | ||
} else if (keyCode === KeyCode.ENTER || e.keyCode === KeyCode.DOWN) { | ||
this.handleClick(e); | ||
@@ -302,2 +310,5 @@ e.preventDefault(); | ||
value: function handleClearSelection(e) { | ||
if (this.props.disabled) { | ||
return; | ||
} | ||
e.stopPropagation(); | ||
@@ -412,2 +423,5 @@ if (this.state.inputValue || this.state.value.length) { | ||
} | ||
if (this.props.disabled) { | ||
rootCls[prefixCls + '-disabled'] = true; | ||
} | ||
return React.createElement( | ||
@@ -417,3 +431,4 @@ 'span', | ||
style: props.style, | ||
className: joinClasses(props.className, classSet(rootCls)), dir: 'ltr', | ||
className: joinClasses(props.className, classSet(rootCls)), | ||
dir: 'ltr', | ||
onFocus: this.handleFocus, | ||
@@ -435,2 +450,31 @@ onBlur: this.handleBlur }, | ||
}, { | ||
key: 'animateDropdown', | ||
value: function animateDropdown(prevProps, prevState) { | ||
var props = this.props; | ||
var state = this.state; | ||
var transitionName = props.transitionName; | ||
if (!transitionName && props.animation) { | ||
transitionName = '' + props.prefixCls + '-dropdown-' + props.animation; | ||
} | ||
if (transitionName && this.refs.dropdown) { | ||
var domNode = React.findDOMNode(this.refs.dropdown); | ||
if (state.open && !prevState.open) { | ||
anim(domNode, '' + transitionName + '-enter'); | ||
} else if (!state.open && prevState.open) { | ||
anim(domNode, '' + transitionName + '-leave'); | ||
} | ||
} | ||
} | ||
}, { | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate(prevProps, prevState) { | ||
prevState = prevState || {}; | ||
this.animateDropdown(prevProps, prevState); | ||
} | ||
}, { | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
this.componentDidUpdate(); | ||
} | ||
}, { | ||
key: 'render', | ||
@@ -447,2 +491,3 @@ value: function render() { | ||
value: state.inputValue, | ||
disabled: props.disabled, | ||
className: prefixCls + '-search__field', | ||
@@ -456,6 +501,9 @@ role: 'textbox' }); | ||
// single and not combobox, input is inside dropdown | ||
dropDown = React.createElement( | ||
this.cachedDropDown = dropDown = React.createElement( | ||
'span', | ||
{ key: 'dropdown', className: joinClasses(prefixCls + '-dropdown', prefixCls + '-dropdown--below'), tabIndex: '-1' }, | ||
multiple || props.combobox ? null : React.createElement( | ||
{ key: 'dropdown', | ||
ref: 'dropdown', | ||
className: joinClasses(prefixCls + '-dropdown', prefixCls + '-dropdown--below'), | ||
tabIndex: '-1' }, | ||
multiple || props.combobox || !props.showSearch ? null : React.createElement( | ||
'span', | ||
@@ -467,2 +515,4 @@ { className: joinClasses(prefixCls + '-search', prefixCls + '-search--dropdown') }, | ||
); | ||
} else { | ||
dropDown = this.cachedDropDown; | ||
} | ||
@@ -504,3 +554,6 @@ | ||
multiple: React.PropTypes.bool, | ||
showSearch: React.PropTypes.bool, | ||
tags: React.PropTypes.bool, | ||
transitionName: React.PropTypes.string, | ||
animation: React.PropTypes.string, | ||
onChange: React.PropTypes.func, | ||
@@ -514,2 +567,3 @@ onSelect: React.PropTypes.func, | ||
filterOption: true, | ||
showSearch: true, | ||
allowClear: false, | ||
@@ -516,0 +570,0 @@ onChange: noop, |
{ | ||
"name": "rc-select", | ||
"version": "3.3.5", | ||
"version": "3.4.0", | ||
"description": "select ui component for react", | ||
@@ -42,2 +42,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"css-animation": "~1.0.3", | ||
"expect.js": "~0.3.1", | ||
@@ -44,0 +45,0 @@ "jsonp": "^0.2.0", |
@@ -87,2 +87,26 @@ # rc-select | ||
<tr> | ||
<td>showSearch</td> | ||
<td>Boolean</td> | ||
<td>true</td> | ||
<td>whether show search input in single mode</td> | ||
</tr> | ||
<tr> | ||
<td>disabled</td> | ||
<td>Boolean</td> | ||
<td>false</td> | ||
<td>whether disabled select</td> | ||
</tr> | ||
<tr> | ||
<td>animation</td> | ||
<td>String</td> | ||
<td></td> | ||
<td>dropdown animation name. only support slide-up now</td> | ||
</tr> | ||
<tr> | ||
<td>transitionName</td> | ||
<td>String</td> | ||
<td></td> | ||
<td>dropdown css animation name</td> | ||
</tr> | ||
<tr> | ||
<td>value</td> | ||
@@ -89,0 +113,0 @@ <td>String | Array<String></td> |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34131
872
224
8