rc-menu
Advanced tools
Comparing version 3.0.1 to 3.1.0
@@ -41,3 +41,3 @@ /** @jsx React.DOM */ | ||
var leftMenu = ( | ||
<Menu multiple={true} onSelect={handleSelect} onDeselect={handleDeselect}> | ||
<Menu multiple={true} onSelect={handleSelect} onDeselect={handleDeselect} selectedKeys={['2']}> | ||
<SubMenu title={titleRight} key="1"> | ||
@@ -47,3 +47,3 @@ <MenuItem key="1-1">0-1</MenuItem> | ||
</SubMenu> | ||
<MenuItem key="2">1</MenuItem> | ||
<MenuItem key="2" disabled>1</MenuItem> | ||
<MenuItem key="3">outer</MenuItem> | ||
@@ -50,0 +50,0 @@ <SubMenu title={titleRight1} key="4"> |
# History | ||
---- | ||
## 3.1.0 / 2015-03-26 | ||
`improved` [#5](https://github.com/react-component/menu/issues/5) support selected and disabled for menuitem simultaneously | ||
## 3.0.0 / 2015-03-17 | ||
@@ -5,0 +9,0 @@ |
@@ -8,3 +8,2 @@ /** @jsx React.DOM */ | ||
var createChainedFunction = rcUtil.createChainedFunction; | ||
var assign = require("object-assign"); | ||
var KeyCode = rcUtil.KeyCode; | ||
@@ -150,2 +149,3 @@ var scrollIntoView = require('dom-scroll-into-view'); | ||
// not from submenu | ||
// top menu | ||
if (!props.sub) { | ||
@@ -164,12 +164,12 @@ if (!props.multiple) { | ||
var state = this.state; | ||
var selectedKeys = state.selectedKeys; | ||
// my child | ||
if (this.getChildrenComponents().indexOf(child) !== -1) { | ||
var selectedKeys; | ||
if (props.multiple) { | ||
selectedKeys.push(key); | ||
selectedKeys = state.selectedKeys.concat([key]); | ||
} else { | ||
state.selectedKeys = [key]; | ||
selectedKeys = [key]; | ||
} | ||
this.setState({ | ||
selectedKeys: state.selectedKeys | ||
selectedKeys: selectedKeys | ||
}); | ||
@@ -184,10 +184,11 @@ } | ||
var state = this.state; | ||
var selectedKeys = state.selectedKeys; | ||
// my children | ||
if (this.getChildrenComponents().indexOf(child) !== -1) { | ||
var selectedKeys = state.selectedKeys; | ||
var index = selectedKeys.indexOf(key); | ||
if (index !== -1) { | ||
selectedKeys = selectedKeys.concat([]); | ||
selectedKeys.splice(index, 1); | ||
this.setState({ | ||
selectedKeys: state.selectedKeys | ||
selectedKeys: selectedKeys | ||
}); | ||
@@ -206,5 +207,6 @@ } | ||
if (index !== -1) { | ||
selectedKeys = selectedKeys.concat([]); | ||
selectedKeys.splice(index, 1); | ||
this.setState({ | ||
selectedKeys: state.selectedKeys | ||
selectedKeys: selectedKeys | ||
}); | ||
@@ -218,12 +220,7 @@ } | ||
var props = this.props; | ||
var baseProps = { | ||
var childProps = child.props; | ||
return React.cloneElement(child, { | ||
rootPrefixCls: props.prefixCls, | ||
ref: createChainedFunction(child.ref, saveRef.bind(this, key)), | ||
eventKey: key | ||
}; | ||
var childProps = child.props; | ||
if (childProps.disabled) { | ||
return React.cloneElement(child, baseProps); | ||
} | ||
var newProps = { | ||
eventKey: key, | ||
onHover: this.handleItemHover, | ||
@@ -236,5 +233,3 @@ active: key === state.activeKey, | ||
onSelect: createChainedFunction(childProps.onSelect, this.handleSelect) | ||
}; | ||
assign(newProps, baseProps); | ||
return React.cloneElement(child, newProps); | ||
}); | ||
} | ||
@@ -241,0 +236,0 @@ |
@@ -17,16 +17,16 @@ /** @jsx React.DOM */ | ||
_getPrefixCls() { | ||
return this.props.rootPrefixCls + '-item'; | ||
} | ||
_getActiveClassName() { | ||
return this.props.activeClassName || this.props.rootPrefixCls + '-item-active'; | ||
return this._getPrefixCls() + '-active'; | ||
} | ||
_getSelectedClassName() { | ||
return this.props.activeClassName || this.props.rootPrefixCls + '-item-selected'; | ||
return this._getPrefixCls() + '-selected'; | ||
} | ||
_getPrefixCls() { | ||
return this.props.rootPrefixCls + '-item'; | ||
} | ||
_getDisabledClassName() { | ||
return this.props.disabledClassName || this.props.rootPrefixCls + '-item-disabled'; | ||
return this._getPrefixCls() + '-disabled'; | ||
} | ||
@@ -57,7 +57,7 @@ | ||
} else { | ||
props.onSelect(props.eventKey, this,e); | ||
props.onSelect(props.eventKey, this, e); | ||
} | ||
} else { | ||
if (!props.selected) { | ||
props.onSelect(props.eventKey, this,e); | ||
props.onSelect(props.eventKey, this, e); | ||
} | ||
@@ -64,0 +64,0 @@ } |
@@ -36,7 +36,7 @@ /** @jsx React.DOM */ | ||
_getActiveClassName() { | ||
return this.props.activeClassName || this.props.rootPrefixCls + '-submenu-active'; | ||
return this._getPrefixCls()+'-active'; | ||
}, | ||
_getDisabledClassName() { | ||
return this.props.disabledClassName || this.props.rootPrefixCls + '-submenu-disabled'; | ||
return this._getPrefixCls()+'-disabled'; | ||
}, | ||
@@ -126,2 +126,3 @@ | ||
handleSelect(childKey, child, e) { | ||
// propagate | ||
this.props.onSelect(childKey, child, e); | ||
@@ -131,2 +132,3 @@ }, | ||
handleDeselect(childKey, child, e) { | ||
// propagate | ||
this.props.onDeselect(childKey, child, e); | ||
@@ -133,0 +135,0 @@ }, |
{ | ||
"name": "rc-menu", | ||
"version": "3.0.1", | ||
"version": "3.1.0", | ||
"description": "menu ui component for react", | ||
@@ -28,3 +28,2 @@ "keywords": [ | ||
"react": "*", | ||
"object-assign": "^2.0.0", | ||
"rc-util": "2.x", | ||
@@ -63,3 +62,2 @@ "dom-scroll-into-view": "^1.0.1" | ||
"dom-scroll-into-view": "^1.0.1", | ||
"object-assign": "^2.0.0", | ||
"rc-util": "2.x" | ||
@@ -66,0 +64,0 @@ }, |
Sorry, the diff of this file is not supported yet
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
2
38518
940
- Removedobject-assign@^2.0.0
- Removedobject-assign@2.1.1(transitive)