Comparing version 0.25.2 to 0.25.3
@@ -113,13 +113,10 @@ 'use strict'; | ||
if (pageY > offsetTop + offsetHeight - gapHeight) { | ||
// console.log('enter gap'); | ||
this.dropPos = 1; | ||
this.dropPosition = 1; | ||
return 1; | ||
} | ||
if (pageY < offsetTop + gapHeight) { | ||
// console.log('ee'); | ||
this.dropPos = -1; | ||
this.dropPosition = -1; | ||
return -1; | ||
} | ||
// console.log('xx'); | ||
this.dropPos = 0; | ||
this.dropPosition = 0; | ||
return 0; | ||
@@ -137,3 +134,2 @@ } | ||
} | ||
// console.log('en...', this.dropPos); | ||
var st = { | ||
@@ -183,5 +179,5 @@ dragOverNodeKey: treeNode.props.eventKey | ||
dragNodesKeys: [].concat(_toConsumableArray(this.dragNodesKeys)), | ||
dropPos: this.dropPos + Number(posArr[posArr.length - 1]) | ||
dropPosition: this.dropPosition + Number(posArr[posArr.length - 1]) | ||
}; | ||
if (this.dropPos !== 0) { | ||
if (this.dropPosition !== 0) { | ||
res.dropToGap = true; | ||
@@ -345,7 +341,7 @@ } | ||
var defaultExpandedKeys = props.defaultExpandedKeys; | ||
var expandedPosArr = []; | ||
var expandedPositionArr = []; | ||
if (props.autoExpandParent) { | ||
(0, _util.loopAllChildren)(props.children, function (item, index, pos, newKey) { | ||
if (defaultExpandedKeys.indexOf(newKey) > -1) { | ||
expandedPosArr.push(pos); | ||
expandedPositionArr.push(pos); | ||
} | ||
@@ -359,4 +355,4 @@ }); | ||
} else if (props.autoExpandParent) { | ||
expandedPosArr.forEach(function (p) { | ||
if ((pos.split('-').length < p.split('-').length && p.indexOf(pos) === 0 || pos === p) && filterExpandedKeys.indexOf(newKey) === -1) { | ||
expandedPositionArr.forEach(function (p) { | ||
if ((p.split('-').length > pos.split('-').length && (0, _util.isInclude)(pos.split('-'), p.split('-')) || pos === p) && filterExpandedKeys.indexOf(newKey) === -1) { | ||
filterExpandedKeys.push(newKey); | ||
@@ -427,4 +423,6 @@ } | ||
var dragNodesKeys = []; | ||
var tPArr = treeNode.props.pos.split('-'); | ||
(0, _util.loopAllChildren)(this.props.children, function (item, index, pos, newKey) { | ||
if (pos.indexOf(treeNode.props.pos) === 0) { | ||
var pArr = pos.split('-'); | ||
if (treeNode.props.pos === pos || tPArr.length < pArr.length && (0, _util.isInclude)(tPArr, pArr)) { | ||
dragNodesKeys.push(newKey); | ||
@@ -483,5 +481,5 @@ } | ||
draggable: props.draggable, | ||
dragOver: state.dragOverNodeKey === key && this.dropPos === 0, | ||
dragOverGapTop: state.dragOverNodeKey === key && this.dropPos === -1, | ||
dragOverGapBottom: state.dragOverNodeKey === key && this.dropPos === 1, | ||
dragOver: state.dragOverNodeKey === key && this.dropPosition === 0, | ||
dragOverGapTop: state.dragOverNodeKey === key && this.dropPosition === -1, | ||
dragOverGapBottom: state.dragOverNodeKey === key && this.dropPosition === 1, | ||
expanded: state.expandedKeys.indexOf(key) !== -1, | ||
@@ -496,3 +494,3 @@ selected: state.selectedKeys.indexOf(key) !== -1, | ||
if (this.treeNodesStates[pos]) { | ||
(0, _objectAssign2['default'])(cloneProps, this.treeNodesStates[pos].siblingPos); | ||
(0, _objectAssign2['default'])(cloneProps, this.treeNodesStates[pos].siblingPosition); | ||
} | ||
@@ -499,0 +497,0 @@ return _react2['default'].cloneElement(child, cloneProps); |
@@ -9,3 +9,4 @@ 'use strict'; | ||
exports.loopAllChildren = loopAllChildren; | ||
exports.filterMinPos = filterMinPos; | ||
exports.filterMinPosition = filterMinPosition; | ||
exports.isInclude = isInclude; | ||
exports.getTreeNodesStates = getTreeNodesStates; | ||
@@ -90,11 +91,11 @@ | ||
function getSiblingPos(index, len, siblingPos) { | ||
function getSiblingPosition(index, len, siblingPosition) { | ||
if (len === 1) { | ||
siblingPos.first = true; | ||
siblingPos.last = true; | ||
siblingPosition.first = true; | ||
siblingPosition.last = true; | ||
} else { | ||
siblingPos.first = index === 0; | ||
siblingPos.last = index === len - 1; | ||
siblingPosition.first = index === 0; | ||
siblingPosition.last = index === len - 1; | ||
} | ||
return siblingPos; | ||
return siblingPosition; | ||
} | ||
@@ -110,3 +111,3 @@ | ||
} | ||
callback(item, index, pos, item.key || pos, getSiblingPos(index, len, {})); | ||
callback(item, index, pos, item.key || pos, getSiblingPosition(index, len, {})); | ||
}); | ||
@@ -117,3 +118,3 @@ }; | ||
function filterMinPos(arr) { | ||
function filterMinPosition(arr) { | ||
var a = []; | ||
@@ -131,5 +132,13 @@ arr.forEach(function (item) { | ||
// console.log(filterMinPos(['0-0','0-1', '0-10', '0-0-1', '0-1-1', '0-10-0'])); | ||
// console.log(filterMinPosition(['0-0','0-1', '0-10', '0-0-1', '0-1-1', '0-10-0'])); | ||
function handleCheckState(obj, checkedPosArr, checkIt) { | ||
function isInclude(smallArray, bigArray) { | ||
return smallArray.every(function (ii, i) { | ||
return ii === bigArray[i]; | ||
}); | ||
} | ||
// console.log(isInclude(['0', '1'], ['0', '10', '1'])); | ||
function handleCheckState(obj, checkedPositionArr, checkIt) { | ||
var stripTail = function stripTail(str) { | ||
@@ -143,10 +152,12 @@ var arr = str.match(/(.+)(-[^-]+)$/); | ||
}; | ||
// stripTail('x-xx-sss-xx') | ||
var splitPos = function splitPos(pos) { | ||
// console.log(stripTail('0-101-000')); | ||
var splitPosition = function splitPosition(pos) { | ||
return pos.split('-'); | ||
}; | ||
checkedPosArr.forEach(function (_pos) { | ||
checkedPositionArr.forEach(function (_pos) { | ||
// 设置子节点,全选或全不选 | ||
var _posArr = splitPosition(_pos); | ||
Object.keys(obj).forEach(function (i) { | ||
if (splitPos(i).length > splitPos(_pos).length && i.indexOf(_pos) === 0) { | ||
var iArr = splitPosition(i); | ||
if (iArr.length > _posArr.length && isInclude(_posArr, iArr)) { | ||
obj[i].checkPart = false; | ||
@@ -158,3 +169,3 @@ obj[i].checked = checkIt; | ||
var loop = function loop(__pos) { | ||
var _posLen = splitPos(__pos).length; | ||
var _posLen = splitPosition(__pos).length; | ||
if (_posLen <= 2) { | ||
@@ -166,5 +177,6 @@ // e.g. '0-0', '0-1' | ||
var siblingChecked = 0; | ||
var parentPos = stripTail(__pos); | ||
var parentPosition = stripTail(__pos); | ||
Object.keys(obj).forEach(function (i) { | ||
if (splitPos(i).length === _posLen && i.indexOf(parentPos) === 0) { | ||
var iArr = splitPosition(i); | ||
if (iArr.length === _posLen && isInclude(splitPosition(parentPosition), iArr)) { | ||
sibling++; | ||
@@ -178,3 +190,3 @@ if (obj[i].checked) { | ||
}); | ||
var parent = obj[parentPos]; | ||
var parent = obj[parentPosition]; | ||
// sibling 不会等于0 | ||
@@ -192,3 +204,3 @@ // 全不选 - 全选 - 半选 | ||
} | ||
loop(parentPos); | ||
loop(parentPosition); | ||
}; | ||
@@ -220,9 +232,9 @@ loop(_pos); | ||
function getTreeNodesStates(children, checkedKeys, checkIt, unCheckKey) { | ||
var checkedPos = []; | ||
var checkedPosition = []; | ||
var treeNodesStates = {}; | ||
loopAllChildren(children, function (item, index, pos, newKey, siblingPos) { | ||
loopAllChildren(children, function (item, index, pos, newKey, siblingPosition) { | ||
var checked = false; | ||
if (checkedKeys.indexOf(newKey) !== -1) { | ||
checked = true; | ||
checkedPos.push(pos); | ||
checkedPosition.push(pos); | ||
} | ||
@@ -234,7 +246,7 @@ treeNodesStates[pos] = { | ||
checkPart: false, | ||
siblingPos: siblingPos | ||
siblingPosition: siblingPosition | ||
}; | ||
}); | ||
// debugger | ||
handleCheckState(treeNodesStates, filterMinPos(checkedPos.sort()), true); | ||
handleCheckState(treeNodesStates, filterMinPosition(checkedPosition.sort()), true); | ||
@@ -241,0 +253,0 @@ if (!checkIt && unCheckKey) { |
{ | ||
"name": "rc-tree", | ||
"version": "0.25.2", | ||
"version": "0.25.3", | ||
"description": "tree 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
61626
1537