rsuite-check-tree
Advanced tools
Comparing version 0.2.2-beta.2 to 0.2.2-beta.3
@@ -399,5 +399,24 @@ 'use strict'; | ||
}, { | ||
key: 'flattenNodes', | ||
key: 'setCheckState', | ||
value: function setCheckState(nodes) { | ||
var _this4 = this; | ||
var cascade = this.props.cascade; | ||
nodes.forEach(function (node) { | ||
var checkState = _this4.getNodeCheckState(node, cascade); | ||
var isChecked = false; | ||
if (checkState === _constants.CHECK_STATE.UNCHECK || checkState === _constants.CHECK_STATE.HALFCHECK) { | ||
isChecked = false; | ||
} | ||
if (checkState === _constants.CHECK_STATE.CHECK) { | ||
isChecked = true; | ||
} | ||
_this4.toggleNode('check', node, isChecked); | ||
if (Array.isArray(node.children) && node.children.length > 0) { | ||
_this4.setCheckState(node.children); | ||
} | ||
}); | ||
} | ||
/** | ||
@@ -408,4 +427,7 @@ * 拍平数组,将tree 转换为一维数组 | ||
*/ | ||
}, { | ||
key: 'flattenNodes', | ||
value: function flattenNodes(nodes) { | ||
var _this4 = this; | ||
var _this5 = this; | ||
@@ -425,8 +447,8 @@ var ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; | ||
node.refKey = refKey; | ||
_this4.nodes[refKey] = { | ||
_this5.nodes[refKey] = { | ||
label: node[labelKey], | ||
value: node[valueKey], | ||
expand: _this4.getExpandState(node) | ||
expand: _this5.getExpandState(node) | ||
}; | ||
_this4.flattenNodes(node[childrenKey], refKey); | ||
_this5.flattenNodes(node[childrenKey], refKey); | ||
}); | ||
@@ -437,3 +459,3 @@ } | ||
value: function unserializeLists(lists) { | ||
var _this5 = this; | ||
var _this6 = this; | ||
@@ -445,6 +467,6 @@ var valueKey = this.props.valueKey; | ||
Object.keys(lists).forEach(function (listKey) { | ||
_this5.nodes[refKey][listKey] = false; | ||
_this6.nodes[refKey][listKey] = false; | ||
lists[listKey].forEach(function (value) { | ||
if ((0, _isEqual2.default)(_this5.nodes[refKey][valueKey], value)) { | ||
_this5.nodes[refKey][listKey] = true; | ||
if ((0, _isEqual2.default)(_this6.nodes[refKey][valueKey], value)) { | ||
_this6.nodes[refKey][listKey] = true; | ||
} | ||
@@ -458,3 +480,3 @@ }); | ||
value: function serializeList(key) { | ||
var _this6 = this; | ||
var _this7 = this; | ||
@@ -466,4 +488,4 @@ var valueKey = this.props.valueKey; | ||
Object.keys(this.nodes).forEach(function (refKey) { | ||
if (_this6.nodes[refKey][key]) { | ||
list.push(_this6.nodes[refKey][valueKey]); | ||
if (_this7.nodes[refKey][key]) { | ||
list.push(_this7.nodes[refKey][valueKey]); | ||
} | ||
@@ -476,7 +498,7 @@ }); | ||
value: function isEveryChildChecked(node) { | ||
var _this7 = this; | ||
var _this8 = this; | ||
return node.children.every(function (child) { | ||
if (child.children) { | ||
return _this7.isEveryChildChecked(child); | ||
return _this8.isEveryChildChecked(child); | ||
} | ||
@@ -490,7 +512,7 @@ | ||
value: function isSomeChildChecked(node) { | ||
var _this8 = this; | ||
var _this9 = this; | ||
return node.children.some(function (child) { | ||
if (child.children) { | ||
return _this8.isSomeChildChecked(child); | ||
return _this9.isSomeChildChecked(child); | ||
} | ||
@@ -504,3 +526,3 @@ | ||
value: function toggleChecked(node, isChecked, cascade) { | ||
var _this9 = this; | ||
var _this10 = this; | ||
@@ -514,3 +536,3 @@ var childrenKey = this.props.childrenKey; | ||
node.children.forEach(function (child) { | ||
_this9.toggleChecked(child, isChecked, cascade); | ||
_this10.toggleChecked(child, isChecked, cascade); | ||
}); | ||
@@ -530,24 +552,2 @@ } | ||
}, { | ||
key: 'setCheckState', | ||
value: function setCheckState(nodes) { | ||
var _this10 = this; | ||
var cascade = this.props.cascade; | ||
nodes.forEach(function (node) { | ||
var checkState = _this10.getNodeCheckState(node, cascade); | ||
var isChecked = false; | ||
if (checkState === _constants.CHECK_STATE.UNCHECK || checkState === _constants.CHECK_STATE.HALFCHECK) { | ||
isChecked = false; | ||
} | ||
if (checkState === _constants.CHECK_STATE.CHECK) { | ||
isChecked = true; | ||
} | ||
_this10.toggleNode('check', node, isChecked); | ||
if (Array.isArray(node.children) && node.children.length > 0) { | ||
_this10.setCheckState(node.children); | ||
} | ||
}); | ||
} | ||
}, { | ||
key: 'focusNextItem', | ||
@@ -613,10 +613,2 @@ value: function focusNextItem() { | ||
var checkState = this.getNodeCheckState(node, cascade); | ||
var isChecked = false; | ||
if (checkState === _constants.CHECK_STATE.UNCHECK || checkState === _constants.CHECK_STATE.HALFCHECK) { | ||
isChecked = false; | ||
} | ||
if (checkState === _constants.CHECK_STATE.CHECK) { | ||
isChecked = true; | ||
} | ||
// this.toggleNode('check', node, isChecked); | ||
var children = node[childrenKey]; | ||
@@ -710,3 +702,7 @@ var disabled = this.getDisabledState(node); | ||
}, | ||
nodes | ||
_react2.default.createElement( | ||
'div', | ||
{ className: 'tree-nodes' }, | ||
nodes | ||
) | ||
); | ||
@@ -713,0 +709,0 @@ } |
{ | ||
"name": "rsuite-check-tree", | ||
"version": "0.2.2-beta.2", | ||
"version": "0.2.2-beta.3", | ||
"description": "A react check tree component", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
39851
810