Comparing version 1.2.3-beta to 1.3.0-beta
# History | ||
--- | ||
## 1.3.0 / 2016-04-15 | ||
- make `autoExpandParent` also work in controlled mode.(Before just work in uncontrolled mode) | ||
- change `onExpand` params | ||
- old: function(node, expanded, expandedKeys) | ||
- new: function(expandedKeys, {expanded: bool, node}) | ||
## 1.2.1 / 2016-04-08 | ||
@@ -5,0 +11,0 @@ - remove `halfCheckedKeys` api, and change `checkedKeys` to an object on setting `checkStrictly`. |
@@ -195,24 +195,18 @@ 'use strict'; | ||
var expand = !treeNode.props.expanded; | ||
var expanded = !treeNode.props.expanded; | ||
var controlled = ('expandedKeys' in this.props); | ||
var expandedKeys = [].concat(_toConsumableArray(this.state.expandedKeys)); | ||
var index = expandedKeys.indexOf(treeNode.props.eventKey); | ||
if (expanded && index === -1) { | ||
expandedKeys.push(treeNode.props.eventKey); | ||
} else if (!expanded && index > -1) { | ||
expandedKeys.splice(index, 1); | ||
} | ||
if (!controlled) { | ||
if (expand) { | ||
if (index === -1) { | ||
expandedKeys.push(treeNode.props.eventKey); | ||
} | ||
} else { | ||
expandedKeys.splice(index, 1); | ||
} | ||
this.setState({ expandedKeys: expandedKeys }); | ||
// remember the return object, such as expandedKeys, must clone!! | ||
// so you can avoid outer code change it. | ||
this.props.onExpand(treeNode, expand, [].concat(_toConsumableArray(expandedKeys))); | ||
} else { | ||
this.props.onExpand(treeNode, !expand, [].concat(_toConsumableArray(expandedKeys))); | ||
} | ||
this.props.onExpand(expandedKeys, { node: treeNode, expanded: expanded }); | ||
// after data loaded, need set new expandedKeys | ||
if (expand && this.props.loadData) { | ||
if (expanded && this.props.loadData) { | ||
return this.props.loadData(treeNode).then(function () { | ||
@@ -370,8 +364,8 @@ if (!controlled) { | ||
key: 'getFilterExpandedKeys', | ||
value: function getFilterExpandedKeys(props) { | ||
var defaultExpandedKeys = props.defaultExpandedKeys; | ||
value: function getFilterExpandedKeys(props, expandKeyProp, expandAll) { | ||
var keys = props[expandKeyProp]; | ||
var expandedPositionArr = []; | ||
if (props.autoExpandParent) { | ||
(0, _util.loopAllChildren)(props.children, function (item, index, pos, newKey) { | ||
if (defaultExpandedKeys.indexOf(newKey) > -1) { | ||
if (keys.indexOf(newKey) > -1) { | ||
expandedPositionArr.push(pos); | ||
@@ -383,3 +377,3 @@ } | ||
(0, _util.loopAllChildren)(props.children, function (item, index, pos, newKey) { | ||
if (props.defaultExpandAll) { | ||
if (expandAll) { | ||
filterExpandedKeys.push(newKey); | ||
@@ -394,3 +388,3 @@ } else if (props.autoExpandParent) { | ||
}); | ||
return filterExpandedKeys.length ? filterExpandedKeys : defaultExpandedKeys; | ||
return filterExpandedKeys.length ? filterExpandedKeys : keys; | ||
} | ||
@@ -400,5 +394,5 @@ }, { | ||
value: function getDefaultExpandedKeys(props, willReceiveProps) { | ||
var expandedKeys = willReceiveProps ? undefined : this.getFilterExpandedKeys(props); | ||
var expandedKeys = willReceiveProps ? undefined : this.getFilterExpandedKeys(props, 'defaultExpandedKeys', props.defaultExpandAll); | ||
if ('expandedKeys' in props) { | ||
expandedKeys = props.expandedKeys || []; | ||
expandedKeys = (props.autoExpandParent ? this.getFilterExpandedKeys(props, 'expandedKeys', false) : props.expandedKeys) || []; | ||
} | ||
@@ -405,0 +399,0 @@ return expandedKeys; |
{ | ||
"name": "rc-tree", | ||
"version": "1.2.3-beta", | ||
"version": "1.3.0-beta", | ||
"description": "tree ui component for react", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -76,3 +76,3 @@ # rc-tree | ||
|selectedKeys | Controlled selected treeNodes(After setting, defaultSelectedKeys will not work) | String[] | [] | | ||
|onExpand | fire on treeNode expand or not | function(node, expanded, expandedKeys) | - | | ||
|onExpand | fire on treeNode expand or not | function(expandedKeys, {expanded: bool, node}) | - | | ||
|onCheck | click the treeNode/checkbox to fire | function(checkedKeys, e:{checked: bool, checkedNodes, node, event}) | - | | ||
@@ -79,0 +79,0 @@ |onSelect | click the treeNode to fire | function(selectedKeys, e:{selected: bool, selectedNodes, node, event}) | - | |
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
62626
1470