Comparing version 4.3.1 to 4.3.2
@@ -38,3 +38,6 @@ 'use strict'; | ||
onDeselect: _react2['default'].PropTypes.func, | ||
onDestroy: _react2['default'].PropTypes.func | ||
onDestroy: _react2['default'].PropTypes.func, | ||
level: _react2['default'].PropTypes.number, | ||
eventKey: _react2['default'].PropTypes.string, | ||
selectable: _react2['default'].PropTypes.bool | ||
}, | ||
@@ -46,2 +49,3 @@ | ||
closeSubMenuOnMouseLeave: true, | ||
selectable: true, | ||
onOpenChange: _util.noop, | ||
@@ -128,18 +132,20 @@ onClick: _util.noop, | ||
var props = this.props; | ||
// root menu | ||
var selectedKeys = this.state.selectedKeys; | ||
var selectedKey = selectInfo.key; | ||
if (props.multiple) { | ||
selectedKeys = selectedKeys.concat([selectedKey]); | ||
} else { | ||
selectedKeys = [selectedKey]; | ||
} | ||
if (!('selectedKeys' in props)) { | ||
this.setState({ | ||
if (props.selectable) { | ||
// root menu | ||
var selectedKeys = this.state.selectedKeys; | ||
var selectedKey = selectInfo.key; | ||
if (props.multiple) { | ||
selectedKeys = selectedKeys.concat([selectedKey]); | ||
} else { | ||
selectedKeys = [selectedKey]; | ||
} | ||
if (!('selectedKeys' in props)) { | ||
this.setState({ | ||
selectedKeys: selectedKeys | ||
}); | ||
} | ||
props.onSelect((0, _objectAssign2['default'])({}, selectInfo, { | ||
selectedKeys: selectedKeys | ||
}); | ||
})); | ||
} | ||
props.onSelect((0, _objectAssign2['default'])({}, selectInfo, { | ||
selectedKeys: selectedKeys | ||
})); | ||
}, | ||
@@ -200,20 +206,22 @@ | ||
var props = this.props; | ||
var selectedKeys = this.state.selectedKeys.concat(); | ||
var selectedKey = selectInfo.key; | ||
var index = selectedKeys.indexOf(selectedKey); | ||
if (index !== -1) { | ||
selectedKeys.splice(index, 1); | ||
} | ||
if (!('selectedKeys' in props)) { | ||
this.setState({ | ||
if (props.selectable) { | ||
var selectedKeys = this.state.selectedKeys.concat(); | ||
var selectedKey = selectInfo.key; | ||
var index = selectedKeys.indexOf(selectedKey); | ||
if (index !== -1) { | ||
selectedKeys.splice(index, 1); | ||
} | ||
if (!('selectedKeys' in props)) { | ||
this.setState({ | ||
selectedKeys: selectedKeys | ||
}); | ||
} | ||
props.onDeselect((0, _objectAssign2['default'])({}, selectInfo, { | ||
selectedKeys: selectedKeys | ||
}); | ||
})); | ||
} | ||
props.onDeselect((0, _objectAssign2['default'])({}, selectInfo, { | ||
selectedKeys: selectedKeys | ||
})); | ||
}, | ||
renderMenuItem: function renderMenuItem(c, i) { | ||
var key = (0, _util.getKeyFromChildrenIndex)(c, i); | ||
var key = (0, _util.getKeyFromChildrenIndex)(c, this.props.eventKey, i); | ||
var state = this.state; | ||
@@ -220,0 +228,0 @@ var extraProps = { |
@@ -32,6 +32,7 @@ 'use strict'; | ||
var children = props.children; | ||
var eventKey = props.eventKey; | ||
if (activeKey) { | ||
var found = undefined; | ||
_react2['default'].Children.forEach(children, function (c, i) { | ||
if (!c.props.disabled && activeKey === (0, _util.getKeyFromChildrenIndex)(c, i)) { | ||
if (!c.props.disabled && activeKey === (0, _util.getKeyFromChildrenIndex)(c, eventKey, i)) { | ||
found = true; | ||
@@ -48,3 +49,3 @@ } | ||
if (!activeKey && !c.props.disabled) { | ||
activeKey = (0, _util.getKeyFromChildrenIndex)(c, i); | ||
activeKey = (0, _util.getKeyFromChildrenIndex)(c, eventKey, i); | ||
} | ||
@@ -183,3 +184,3 @@ }); | ||
var props = this.props; | ||
var key = (0, _util.getKeyFromChildrenIndex)(child, i); | ||
var key = (0, _util.getKeyFromChildrenIndex)(child, props.eventKey, i); | ||
var childProps = child.props; | ||
@@ -186,0 +187,0 @@ var newChildProps = (0, _objectAssign2['default'])({ |
@@ -213,2 +213,3 @@ 'use strict'; | ||
selectedKeys: props.selectedKeys, | ||
eventKey: props.eventKey + '-menu-', | ||
openKeys: props.openKeys, | ||
@@ -215,0 +216,0 @@ onOpenChange: this.onOpenChange, |
@@ -63,4 +63,4 @@ 'use strict'; | ||
renderMenuItem: function renderMenuItem(c, i) { | ||
var key = (0, _util.getKeyFromChildrenIndex)(c, i); | ||
var props = this.props; | ||
var key = (0, _util.getKeyFromChildrenIndex)(c, props.eventKey, i); | ||
var extraProps = { | ||
@@ -67,0 +67,0 @@ openKeys: props.openKeys, |
@@ -10,6 +10,7 @@ 'use strict'; | ||
getKeyFromChildrenIndex: function getKeyFromChildrenIndex(child, index) { | ||
return child.key || 'rcMenuItem_' + now + '_' + index; | ||
getKeyFromChildrenIndex: function getKeyFromChildrenIndex(child, menuEventKey, index) { | ||
var prefix = menuEventKey || ''; | ||
return child.key || prefix + 'item_' + now + '_' + index; | ||
} | ||
}; | ||
module.exports = exports['default']; |
{ | ||
"name": "rc-menu", | ||
"version": "4.3.1", | ||
"version": "4.3.2", | ||
"description": "menu ui component for react", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
56471
1273