rc-tree-select
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -39,2 +39,6 @@ 'use strict'; | ||
var _TreeNode2 = require('./TreeNode'); | ||
var _TreeNode3 = _interopRequireDefault(_TreeNode2); | ||
function noop() {} | ||
@@ -82,2 +86,3 @@ | ||
treeNodeFilterProp: _react.PropTypes.string, | ||
treeData: _react.PropTypes.array, | ||
loadData: _react.PropTypes.func | ||
@@ -367,3 +372,3 @@ }, | ||
} else { | ||
label = this.getLabelByValue(props.children, value); | ||
label = this.getLabelByValue(this.renderTreeData() || props.children, value); | ||
} | ||
@@ -586,3 +591,27 @@ return label; | ||
}, | ||
renderTreeData: function renderTreeData() { | ||
var loop = function loop(data) { | ||
var level = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1]; | ||
return data.map(function (item, index) { | ||
var pos = level + '-' + index; | ||
var props = { | ||
title: item.label, | ||
value: item.value, | ||
key: item.key || item.value || pos | ||
}; | ||
if (item.children) { | ||
return _react2['default'].createElement( | ||
_TreeNode3['default'], | ||
props, | ||
loop(item.children, pos) | ||
); | ||
} | ||
return _react2['default'].createElement(_TreeNode3['default'], _extends({}, props, { isLeaf: item.isLeaf })); | ||
}); | ||
}; | ||
if (this.props.treeData) { | ||
return loop(this.props.treeData); | ||
} | ||
}, | ||
render: function render() { | ||
@@ -616,2 +645,3 @@ var _rootCls; | ||
treeNodes: props.children, | ||
treeData: this.renderTreeData(props.treeData), | ||
multiple: multiple, | ||
@@ -618,0 +648,0 @@ disabled: disabled, |
@@ -200,3 +200,3 @@ 'use strict'; | ||
renderTree: function renderTree(treeProps) { | ||
renderTree: function renderTree(treeNodes, newTreeNodes, multiple) { | ||
var props = this.props; | ||
@@ -223,3 +223,3 @@ | ||
var trProps = { | ||
multiple: treeProps.multiple, | ||
multiple: multiple, | ||
prefixCls: props.prefixCls + '-tree', | ||
@@ -234,3 +234,3 @@ showIcon: props.treeIcon, | ||
var keys = []; | ||
(0, _util.loopAllChildren)(props.treeNodes, function (child) { | ||
(0, _util.loopAllChildren)(treeNodes, function (child) { | ||
if (vals.indexOf((0, _util.getValuePropValue)(child)) > -1) { | ||
@@ -258,3 +258,3 @@ keys.push(child.key); | ||
_extends({ ref: this.savePopupElement }, trProps), | ||
loop(treeProps.treeNodes) | ||
loop(newTreeNodes) | ||
); | ||
@@ -275,3 +275,3 @@ }, | ||
); | ||
var treeNodes = this.renderFilterOptionsFromChildren(props.treeNodes); | ||
var treeNodes = this.renderFilterOptionsFromChildren(props.treeData || props.treeNodes); | ||
var notFoundContent = undefined; | ||
@@ -294,3 +294,3 @@ if (!treeNodes.length) { | ||
search, | ||
notFoundContent ? notFoundContent : this.renderTree({ treeNodes: treeNodes, multiple: multiple }) | ||
notFoundContent ? notFoundContent : this.renderTree(props.treeData || props.treeNodes, treeNodes, multiple) | ||
); | ||
@@ -297,0 +297,0 @@ |
{ | ||
"name": "rc-tree-select", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "tree-select ui component for react", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -108,5 +108,7 @@ # rc-tree-select | ||
|treeNodeLabelProp | which prop value of treeNode will render as content of select | String | 'value' | | ||
|treeData | treeNodes Array, if set and you need not to construct children TreeNode. (if value is not unique of the whole array, you must provide `key` as unique id) | array<{value, label, children}> | [] | | ||
|loadData | load data asynchronously | function(node) | - | | ||
### TreeNode props | ||
> note: if set `treeData`, you can omit TreeNode setting below. | ||
@@ -116,3 +118,3 @@ | name | description | type | default | | ||
|disabled | disable treeNode | bool | false | | ||
|key | the unique key of treeNode, you must setting | String | - | | ||
|key | the unique key of treeNode, you must set it | String | - | | ||
|value | default as treeNodeFilterProp | String | '' | | ||
@@ -119,0 +121,0 @@ |title | tree/subTree's title | String | '---' | |
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
86051
2514
133