Comparing version 0.20.6 to 0.21.0
396
lib/Tree.js
@@ -57,3 +57,3 @@ 'use strict'; | ||
_get(Object.getPrototypeOf(Tree.prototype), 'constructor', this).call(this, props); | ||
['handleKeyDown', 'handleCheck'].forEach(function (m) { | ||
['onKeyDown', 'onCheck'].forEach(function (m) { | ||
_this[m] = _this[m].bind(_this); | ||
@@ -83,80 +83,3 @@ }); | ||
} | ||
}, { | ||
key: 'getDefaultCheckedKeys', | ||
value: function getDefaultCheckedKeys(props) { | ||
var checkedKeys = props.defaultCheckedKeys; | ||
if ('checkedKeys' in props) { | ||
checkedKeys = props.checkedKeys || []; | ||
} | ||
return checkedKeys; | ||
} | ||
}, { | ||
key: 'getDefaultSelectedKeys', | ||
value: function getDefaultSelectedKeys(props) { | ||
var selectedKeys = props.multiple ? [].concat(_toConsumableArray(props.defaultSelectedKeys)) : [props.defaultSelectedKeys[0]]; | ||
if ('selectedKeys' in props) { | ||
selectedKeys = props.multiple ? [].concat(_toConsumableArray(props.selectedKeys)) : [props.selectedKeys[0]]; | ||
} | ||
return selectedKeys; | ||
} | ||
}, { | ||
key: 'getCheckKeys', | ||
value: function getCheckKeys() { | ||
var _this2 = this; | ||
var checkPartKeys = []; | ||
var checkedKeys = []; | ||
Object.keys(this.treeNodesStates).forEach(function (item) { | ||
var itemObj = _this2.treeNodesStates[item]; | ||
if (itemObj.checked) { | ||
checkedKeys.push(itemObj.key); | ||
} else if (itemObj.checkPart) { | ||
checkPartKeys.push(itemObj.key); | ||
} | ||
}); | ||
return { | ||
checkPartKeys: checkPartKeys, checkedKeys: checkedKeys | ||
}; | ||
} | ||
}, { | ||
key: 'getOpenTransitionName', | ||
value: function getOpenTransitionName() { | ||
var props = this.props; | ||
var transitionName = props.openTransitionName; | ||
var animationName = props.openAnimation; | ||
if (!transitionName && typeof animationName === 'string') { | ||
transitionName = props.prefixCls + '-open-' + animationName; | ||
} | ||
return transitionName; | ||
} | ||
}, { | ||
key: 'getDragNodes', | ||
value: function getDragNodes(treeNode) { | ||
var _this3 = this; | ||
var dragNodesKeys = []; | ||
Object.keys(this.treeNodesStates).forEach(function (item) { | ||
if (item.indexOf(treeNode.props.pos) === 0) { | ||
dragNodesKeys.push(_this3.treeNodesStates[item].key); | ||
} | ||
}); | ||
return dragNodesKeys; | ||
} | ||
}, { | ||
key: 'getExpandedKeys', | ||
value: function getExpandedKeys(treeNode, expand) { | ||
var key = treeNode.props.eventKey; | ||
var expandedKeys = this.state.expandedKeys; | ||
var expandedIndex = expandedKeys.indexOf(key); | ||
var exKeys = undefined; | ||
if (expandedIndex > -1 && !expand) { | ||
exKeys = [].concat(_toConsumableArray(expandedKeys)); | ||
exKeys.splice(expandedIndex, 1); | ||
return exKeys; | ||
} | ||
if (expand && expandedKeys.indexOf(key) === -1) { | ||
return expandedKeys.concat([key]); | ||
} | ||
} | ||
/* | ||
@@ -188,4 +111,4 @@ // ie8 | ||
}, { | ||
key: 'handleDragStart', | ||
value: function handleDragStart(e, treeNode) { | ||
key: 'onDragStart', | ||
value: function onDragStart(e, treeNode) { | ||
// console.log(this.refs.tree.parentNode, treeNode.refs.selectHandle); | ||
@@ -211,4 +134,4 @@ // this.createDragElement(treeNode); | ||
}, { | ||
key: 'handleDragEnterGap', | ||
value: function handleDragEnterGap(e, treeNode) { | ||
key: 'onDragEnterGap', | ||
value: function onDragEnterGap(e, treeNode) { | ||
// console.log(e.pageY, getOffset(treeNode.refs.selectHandle), treeNode.props.eventKey); | ||
@@ -234,5 +157,5 @@ var offsetTop = (0, _util.getOffset)(treeNode.refs.selectHandle).top; | ||
}, { | ||
key: 'handleDragEnter', | ||
value: function handleDragEnter(e, treeNode) { | ||
var enterGap = this.handleDragEnterGap(e, treeNode); | ||
key: 'onDragEnter', | ||
value: function onDragEnter(e, treeNode) { | ||
var enterGap = this.onDragEnterGap(e, treeNode); | ||
if (this.dragNode.props.eventKey === treeNode.props.eventKey && enterGap === 0) { | ||
@@ -262,4 +185,4 @@ this.setState({ | ||
}, { | ||
key: 'handleDragOver', | ||
value: function handleDragOver(e, treeNode) { | ||
key: 'onDragOver', | ||
value: function onDragOver(e, treeNode) { | ||
if (this.props.onTreeDragOver) { | ||
@@ -270,4 +193,4 @@ this.props.onTreeDragOver({ event: e, node: treeNode }); | ||
}, { | ||
key: 'handleDragLeave', | ||
value: function handleDragLeave(e, treeNode) { | ||
key: 'onDragLeave', | ||
value: function onDragLeave(e, treeNode) { | ||
if (this.props.onTreeDragLeave) { | ||
@@ -278,4 +201,4 @@ this.props.onTreeDragLeave({ event: e, node: treeNode }); | ||
}, { | ||
key: 'handleDrop', | ||
value: function handleDrop(e, treeNode) { | ||
key: 'onDrop', | ||
value: function onDrop(e, treeNode) { | ||
var key = treeNode.props.eventKey; | ||
@@ -305,23 +228,5 @@ if (this.dragNode.props.eventKey === key) { | ||
}, { | ||
key: 'loopAllChildren', | ||
value: function loopAllChildren(childs, callback) { | ||
var loop = function loop(children, level) { | ||
_react2['default'].Children.forEach(children, function (item, index) { | ||
var pos = level + '-' + index; | ||
var newChildren = item.props.children; | ||
if (newChildren) { | ||
if (!Array.isArray(newChildren)) { | ||
newChildren = [newChildren]; | ||
} | ||
loop(newChildren, pos); | ||
} | ||
callback(item, index, pos); | ||
}); | ||
}; | ||
loop(childs, 0); | ||
} | ||
}, { | ||
key: 'handleExpand', | ||
value: function handleExpand(treeNode) { | ||
var _this4 = this; | ||
key: 'onExpand', | ||
value: function onExpand(treeNode) { | ||
var _this2 = this; | ||
@@ -347,3 +252,3 @@ var thisProps = this.props; | ||
return thisProps.onDataLoaded(treeNode).then(function () { | ||
_this4.setState({ | ||
_this2.setState({ | ||
expandedKeys: expandedKeys | ||
@@ -364,72 +269,5 @@ }); | ||
}, { | ||
key: 'handleCheckState', | ||
value: function handleCheckState(obj, checkedArr, unCheckEvent) { | ||
var evt = false; | ||
if (typeof unCheckEvent === 'boolean') { | ||
evt = true; | ||
} | ||
// stripTail('x-xx-sss-xx') | ||
var stripTail = function stripTail(str) { | ||
var arr = str.match(/(.+)(-[^-]+)$/); | ||
var st = ''; | ||
if (arr && arr.length === 3) { | ||
st = arr[1]; | ||
} | ||
return st; | ||
}; | ||
checkedArr.forEach(function (_pos) { | ||
Object.keys(obj).forEach(function (i) { | ||
if (splitPos(i).length > splitPos(_pos).length && i.indexOf(_pos) === 0) { | ||
obj[i].checkPart = false; | ||
if (evt) { | ||
if (unCheckEvent) { | ||
obj[i].checked = false; | ||
} else { | ||
obj[i].checked = true; | ||
} | ||
} else { | ||
obj[i].checked = true; | ||
} | ||
} | ||
}); | ||
var loop = function loop(__pos) { | ||
var _posLen = splitPos(__pos).length; | ||
if (_posLen <= 2) { | ||
return; | ||
} | ||
var sibling = 0; | ||
var siblingChecked = 0; | ||
var parentPos = stripTail(__pos); | ||
Object.keys(obj).forEach(function (i) { | ||
if (splitPos(i).length === _posLen && i.indexOf(parentPos) === 0) { | ||
sibling++; | ||
if (obj[i].checked) { | ||
siblingChecked++; | ||
} else if (obj[i].checkPart) { | ||
siblingChecked += 0.5; | ||
} | ||
} | ||
}); | ||
var parent = obj[parentPos]; | ||
// sibling 不会等于0 | ||
// 全不选 - 全选 - 半选 | ||
if (siblingChecked === 0) { | ||
parent.checked = false; | ||
parent.checkPart = false; | ||
} else if (siblingChecked === sibling) { | ||
parent.checked = true; | ||
parent.checkPart = false; | ||
} else { | ||
parent.checkPart = true; | ||
parent.checked = false; | ||
} | ||
loop(parentPos); | ||
}; | ||
loop(_pos); | ||
}); | ||
} | ||
}, { | ||
key: 'handleCheck', | ||
value: function handleCheck(treeNode) { | ||
var _this5 = this; | ||
key: 'onCheck', | ||
value: function onCheck(treeNode) { | ||
var _this3 = this; | ||
@@ -443,3 +281,3 @@ var tnProps = treeNode.props; | ||
Object.keys(this.treeNodesStates).forEach(function (item) { | ||
var itemObj = _this5.treeNodesStates[item]; | ||
var itemObj = _this3.treeNodesStates[item]; | ||
if (itemObj.key === (treeNode.key || tnProps.eventKey)) { | ||
@@ -473,4 +311,4 @@ pos = item; | ||
}, { | ||
key: 'handleSelect', | ||
value: function handleSelect(treeNode) { | ||
key: 'onSelect', | ||
value: function onSelect(treeNode) { | ||
var props = this.props; | ||
@@ -509,4 +347,14 @@ var selectedKeys = [].concat(_toConsumableArray(this.state.selectedKeys)); | ||
}, { | ||
key: 'handleContextMenu', | ||
value: function handleContextMenu(e, treeNode) { | ||
key: 'onMouseEnter', | ||
value: function onMouseEnter(e, treeNode) { | ||
this.props.onMouseEnter({ event: e, node: treeNode }); | ||
} | ||
}, { | ||
key: 'onMouseLeave', | ||
value: function onMouseLeave(e, treeNode) { | ||
this.props.onMouseLeave({ event: e, node: treeNode }); | ||
} | ||
}, { | ||
key: 'onContextMenu', | ||
value: function onContextMenu(e, treeNode) { | ||
var selectedKeys = [].concat(_toConsumableArray(this.state.selectedKeys)); | ||
@@ -534,7 +382,169 @@ var eventKey = treeNode.props.eventKey; | ||
}, { | ||
key: 'handleKeyDown', | ||
value: function handleKeyDown(e) { | ||
key: 'onKeyDown', | ||
value: function onKeyDown(e) { | ||
e.preventDefault(); | ||
} | ||
}, { | ||
key: 'getDefaultCheckedKeys', | ||
value: function getDefaultCheckedKeys(props) { | ||
var checkedKeys = props.defaultCheckedKeys; | ||
if ('checkedKeys' in props) { | ||
checkedKeys = props.checkedKeys || []; | ||
} | ||
return checkedKeys; | ||
} | ||
}, { | ||
key: 'getDefaultSelectedKeys', | ||
value: function getDefaultSelectedKeys(props) { | ||
var selectedKeys = props.multiple ? [].concat(_toConsumableArray(props.defaultSelectedKeys)) : [props.defaultSelectedKeys[0]]; | ||
if ('selectedKeys' in props) { | ||
selectedKeys = props.multiple ? [].concat(_toConsumableArray(props.selectedKeys)) : [props.selectedKeys[0]]; | ||
} | ||
return selectedKeys; | ||
} | ||
}, { | ||
key: 'getCheckKeys', | ||
value: function getCheckKeys() { | ||
var _this4 = this; | ||
var checkPartKeys = []; | ||
var checkedKeys = []; | ||
Object.keys(this.treeNodesStates).forEach(function (item) { | ||
var itemObj = _this4.treeNodesStates[item]; | ||
if (itemObj.checked) { | ||
checkedKeys.push(itemObj.key); | ||
} else if (itemObj.checkPart) { | ||
checkPartKeys.push(itemObj.key); | ||
} | ||
}); | ||
return { | ||
checkPartKeys: checkPartKeys, checkedKeys: checkedKeys | ||
}; | ||
} | ||
}, { | ||
key: 'getOpenTransitionName', | ||
value: function getOpenTransitionName() { | ||
var props = this.props; | ||
var transitionName = props.openTransitionName; | ||
var animationName = props.openAnimation; | ||
if (!transitionName && typeof animationName === 'string') { | ||
transitionName = props.prefixCls + '-open-' + animationName; | ||
} | ||
return transitionName; | ||
} | ||
}, { | ||
key: 'getDragNodes', | ||
value: function getDragNodes(treeNode) { | ||
var _this5 = this; | ||
var dragNodesKeys = []; | ||
Object.keys(this.treeNodesStates).forEach(function (item) { | ||
if (item.indexOf(treeNode.props.pos) === 0) { | ||
dragNodesKeys.push(_this5.treeNodesStates[item].key); | ||
} | ||
}); | ||
return dragNodesKeys; | ||
} | ||
}, { | ||
key: 'getExpandedKeys', | ||
value: function getExpandedKeys(treeNode, expand) { | ||
var key = treeNode.props.eventKey; | ||
var expandedKeys = this.state.expandedKeys; | ||
var expandedIndex = expandedKeys.indexOf(key); | ||
var exKeys = undefined; | ||
if (expandedIndex > -1 && !expand) { | ||
exKeys = [].concat(_toConsumableArray(expandedKeys)); | ||
exKeys.splice(expandedIndex, 1); | ||
return exKeys; | ||
} | ||
if (expand && expandedKeys.indexOf(key) === -1) { | ||
return expandedKeys.concat([key]); | ||
} | ||
} | ||
}, { | ||
key: 'handleCheckState', | ||
value: function handleCheckState(obj, checkedArr, unCheckEvent) { | ||
var evt = false; | ||
if (typeof unCheckEvent === 'boolean') { | ||
evt = true; | ||
} | ||
// stripTail('x-xx-sss-xx') | ||
var stripTail = function stripTail(str) { | ||
var arr = str.match(/(.+)(-[^-]+)$/); | ||
var st = ''; | ||
if (arr && arr.length === 3) { | ||
st = arr[1]; | ||
} | ||
return st; | ||
}; | ||
checkedArr.forEach(function (_pos) { | ||
Object.keys(obj).forEach(function (i) { | ||
if (splitPos(i).length > splitPos(_pos).length && i.indexOf(_pos) === 0) { | ||
obj[i].checkPart = false; | ||
if (evt) { | ||
if (unCheckEvent) { | ||
obj[i].checked = false; | ||
} else { | ||
obj[i].checked = true; | ||
} | ||
} else { | ||
obj[i].checked = true; | ||
} | ||
} | ||
}); | ||
var loop = function loop(__pos) { | ||
var _posLen = splitPos(__pos).length; | ||
if (_posLen <= 2) { | ||
return; | ||
} | ||
var sibling = 0; | ||
var siblingChecked = 0; | ||
var parentPos = stripTail(__pos); | ||
Object.keys(obj).forEach(function (i) { | ||
if (splitPos(i).length === _posLen && i.indexOf(parentPos) === 0) { | ||
sibling++; | ||
if (obj[i].checked) { | ||
siblingChecked++; | ||
} else if (obj[i].checkPart) { | ||
siblingChecked += 0.5; | ||
} | ||
} | ||
}); | ||
var parent = obj[parentPos]; | ||
// sibling 不会等于0 | ||
// 全不选 - 全选 - 半选 | ||
if (siblingChecked === 0) { | ||
parent.checked = false; | ||
parent.checkPart = false; | ||
} else if (siblingChecked === sibling) { | ||
parent.checked = true; | ||
parent.checkPart = false; | ||
} else { | ||
parent.checkPart = true; | ||
parent.checked = false; | ||
} | ||
loop(parentPos); | ||
}; | ||
loop(_pos); | ||
}); | ||
} | ||
}, { | ||
key: 'loopAllChildren', | ||
value: function loopAllChildren(childs, callback) { | ||
var loop = function loop(children, level) { | ||
_react2['default'].Children.forEach(children, function (item, index) { | ||
var pos = level + '-' + index; | ||
var newChildren = item.props.children; | ||
if (newChildren) { | ||
if (!Array.isArray(newChildren)) { | ||
newChildren = [newChildren]; | ||
} | ||
loop(newChildren, pos); | ||
} | ||
callback(item, index, pos); | ||
}); | ||
}; | ||
loop(childs, 0); | ||
} | ||
}, { | ||
key: 'renderTreeNode', | ||
@@ -553,2 +563,4 @@ value: function renderTreeNode(child, index) { | ||
onDataLoaded: props.onDataLoaded, | ||
onMouseEnter: props.onMouseEnter, | ||
onMouseLeave: props.onMouseLeave, | ||
onRightClick: props.onRightClick, | ||
@@ -584,3 +596,3 @@ prefixCls: props.prefixCls, | ||
domProps.tabIndex = '0'; | ||
domProps.onKeyDown = this.handleKeyDown; | ||
domProps.onKeyDown = this.onKeyDown; | ||
} | ||
@@ -634,2 +646,4 @@ var checkedKeys = this.state.checkedKeys; | ||
onDataLoaded: _react2['default'].PropTypes.func, | ||
onMouseEnter: _react2['default'].PropTypes.func, | ||
onMouseLeave: _react2['default'].PropTypes.func, | ||
onRightClick: _react2['default'].PropTypes.func, | ||
@@ -636,0 +650,0 @@ onTreeDragStart: _react2['default'].PropTypes.func, |
@@ -55,3 +55,3 @@ 'use strict'; | ||
_get(Object.getPrototypeOf(TreeNode.prototype), 'constructor', this).call(this, props); | ||
['handleExpand', 'handleCheck', 'handleContextMenu', 'handleDragStart', 'handleDragEnter', 'handleDragOver', 'handleDragLeave', 'handleDrop'].forEach(function (m) { | ||
['onExpand', 'onCheck', 'onContextMenu', 'onMouseEnter', 'onMouseLeave', 'onDragStart', 'onDragEnter', 'onDragOver', 'onDragLeave', 'onDrop'].forEach(function (m) { | ||
_this[m] = _this[m].bind(_this); | ||
@@ -66,40 +66,32 @@ }); | ||
_createClass(TreeNode, [{ | ||
key: 'getPosition', | ||
value: function getPosition(pos) { | ||
var obj = { | ||
last: false, | ||
center: false | ||
}; | ||
var siblings = Object.keys(this.props.root.treeNodesStates).filter(function (item) { | ||
var len = pos.length; | ||
return len === item.length && pos.substring(0, len - 2) === item.substring(0, len - 2); | ||
}); | ||
var sLen = siblings.length; | ||
var posIndex = Number(pos.substr(-1, 1)); | ||
if (sLen === 1 || posIndex === sLen - 1) { | ||
obj.last = true; | ||
} else { | ||
obj.center = true; | ||
} | ||
return obj; | ||
key: 'onCheck', | ||
value: function onCheck() { | ||
this.props.root.onCheck(this); | ||
} | ||
}, { | ||
key: 'handleCheck', | ||
value: function handleCheck() { | ||
this.props.root.handleCheck(this); | ||
key: 'onSelect', | ||
value: function onSelect() { | ||
this.props.root.onSelect(this); | ||
} | ||
}, { | ||
key: 'handleSelect', | ||
value: function handleSelect() { | ||
this.props.root.handleSelect(this); | ||
key: 'onMouseEnter', | ||
value: function onMouseEnter(e) { | ||
e.preventDefault(); | ||
this.props.root.onMouseEnter(e, this); | ||
} | ||
}, { | ||
key: 'handleContextMenu', | ||
value: function handleContextMenu(e) { | ||
key: 'onMouseLeave', | ||
value: function onMouseLeave(e) { | ||
e.preventDefault(); | ||
this.props.root.handleContextMenu(e, this); | ||
this.props.root.onMouseLeave(e, this); | ||
} | ||
}, { | ||
key: 'handleDragStart', | ||
value: function handleDragStart(e) { | ||
key: 'onContextMenu', | ||
value: function onContextMenu(e) { | ||
e.preventDefault(); | ||
this.props.root.onContextMenu(e, this); | ||
} | ||
}, { | ||
key: 'onDragStart', | ||
value: function onDragStart(e) { | ||
// console.log('dragstart', this.props.eventKey, e); | ||
@@ -111,15 +103,15 @@ // e.preventDefault(); | ||
}); | ||
this.props.root.handleDragStart(e, this); | ||
this.props.root.onDragStart(e, this); | ||
} | ||
}, { | ||
key: 'handleDragEnter', | ||
value: function handleDragEnter(e) { | ||
key: 'onDragEnter', | ||
value: function onDragEnter(e) { | ||
// console.log('dragenter', this.props.eventKey, e); | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
this.props.root.handleDragEnter(e, this); | ||
this.props.root.onDragEnter(e, this); | ||
} | ||
}, { | ||
key: 'handleDragOver', | ||
value: function handleDragOver(e) { | ||
key: 'onDragOver', | ||
value: function onDragOver(e) { | ||
// console.log(this.props.eventKey, e); | ||
@@ -129,15 +121,15 @@ // todo disabled | ||
e.stopPropagation(); | ||
this.props.root.handleDragOver(e, this); | ||
this.props.root.onDragOver(e, this); | ||
return false; | ||
} | ||
}, { | ||
key: 'handleDragLeave', | ||
value: function handleDragLeave(e) { | ||
key: 'onDragLeave', | ||
value: function onDragLeave(e) { | ||
// console.log(this.props.eventKey, e); | ||
e.stopPropagation(); | ||
this.props.root.handleDragLeave(e, this); | ||
this.props.root.onDragLeave(e, this); | ||
} | ||
}, { | ||
key: 'handleDrop', | ||
value: function handleDrop(e) { | ||
key: 'onDrop', | ||
value: function onDrop(e) { | ||
e.stopPropagation(); | ||
@@ -147,10 +139,10 @@ this.setState({ | ||
}); | ||
this.props.root.handleDrop(e, this); | ||
this.props.root.onDrop(e, this); | ||
} | ||
}, { | ||
key: 'handleExpand', | ||
value: function handleExpand() { | ||
key: 'onExpand', | ||
value: function onExpand() { | ||
var _this2 = this; | ||
var callbackPromise = this.props.root.handleExpand(this); | ||
var callbackPromise = this.props.root.onExpand(this); | ||
if (callbackPromise && typeof callbackPromise === 'object') { | ||
@@ -175,7 +167,27 @@ (function () { | ||
}, { | ||
key: 'handleKeyDown', | ||
value: function handleKeyDown(e) { | ||
key: 'onKeyDown', | ||
value: function onKeyDown(e) { | ||
e.preventDefault(); | ||
} | ||
}, { | ||
key: 'getPosition', | ||
value: function getPosition(pos) { | ||
var obj = { | ||
last: false, | ||
center: false | ||
}; | ||
var siblings = Object.keys(this.props.root.treeNodesStates).filter(function (item) { | ||
var len = pos.length; | ||
return len === item.length && pos.substring(0, len - 2) === item.substring(0, len - 2); | ||
}); | ||
var sLen = siblings.length; | ||
var posIndex = Number(pos.substr(-1, 1)); | ||
if (sLen === 1 || posIndex === sLen - 1) { | ||
obj.last = true; | ||
} else { | ||
obj.center = true; | ||
} | ||
return obj; | ||
} | ||
}, { | ||
key: 'renderSwitcher', | ||
@@ -200,3 +212,3 @@ value: function renderSwitcher(props, expandedState) { | ||
} | ||
return _react2['default'].createElement('span', { className: (0, _classnames2['default'])(switcherCls), onClick: this.handleExpand }); | ||
return _react2['default'].createElement('span', { className: (0, _classnames2['default'])(switcherCls), onClick: this.onExpand }); | ||
} | ||
@@ -227,3 +239,3 @@ }, { | ||
'span', | ||
{ ref: 'checkbox', className: (0, _classnames2['default'])(checkboxCls), onClick: this.handleCheck }, | ||
{ ref: 'checkbox', className: (0, _classnames2['default'])(checkboxCls), onClick: this.onCheck }, | ||
customEle | ||
@@ -318,10 +330,16 @@ ); | ||
e.preventDefault(); | ||
_this3.handleSelect(); | ||
_this3.onSelect(); | ||
if (props.checkable) { | ||
_this3.handleCheck(); | ||
_this3.onCheck(); | ||
} | ||
}; | ||
if (props.onRightClick) { | ||
domProps.onContextMenu = _this3.handleContextMenu; | ||
domProps.onContextMenu = _this3.onContextMenu; | ||
} | ||
if (props.onMouseEnter) { | ||
domProps.onMouseEnter = _this3.onMouseEnter; | ||
} | ||
if (props.onMouseLeave) { | ||
domProps.onMouseLeave = _this3.onMouseLeave; | ||
} | ||
if (props.draggable) { | ||
@@ -334,3 +352,3 @@ if (ieOrEdge) { | ||
domProps['aria-grabbed'] = true; | ||
domProps.onDragStart = _this3.handleDragStart; | ||
domProps.onDragStart = _this3.onDragStart; | ||
} | ||
@@ -348,6 +366,6 @@ } | ||
if (props.draggable) { | ||
liProps.onDragEnter = this.handleDragEnter; | ||
liProps.onDragOver = this.handleDragOver; | ||
liProps.onDragLeave = this.handleDragLeave; | ||
liProps.onDrop = this.handleDrop; | ||
liProps.onDragEnter = this.onDragEnter; | ||
liProps.onDragOver = this.onDragOver; | ||
liProps.onDragLeave = this.onDragLeave; | ||
liProps.onDrop = this.onDrop; | ||
} | ||
@@ -354,0 +372,0 @@ |
@@ -38,2 +38,20 @@ 'use strict'; | ||
// // iscroll offset | ||
// offset = function (el) { | ||
// var left = -el.offsetLeft, | ||
// top = -el.offsetTop; | ||
// // jshint -W084 | ||
// while (el = el.offsetParent) { | ||
// left -= el.offsetLeft; | ||
// top -= el.offsetTop; | ||
// } | ||
// // jshint +W084 | ||
// return { | ||
// left: left, | ||
// top: top | ||
// }; | ||
// } | ||
function getOffset(ele) { | ||
@@ -40,0 +58,0 @@ var el = ele; |
{ | ||
"name": "rc-tree", | ||
"version": "0.20.6", | ||
"version": "0.21.0", | ||
"description": "tree ui component for react", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -76,2 +76,4 @@ # rc-tree | ||
|onRightClick | select current treeNode and show customized contextmenu | function({event,node}) | - | | ||
|onMouseEnter | call when mouse enter a treeNode | function({event,node}) | - | | ||
|onMouseLeave | call when mouse leave a treeNode | function({event,node}) | - | | ||
|draggable | whether can drag treeNode. (drag events are not supported in Internet Explorer 8 and earlier versions or Safari 5.1 and earlier versions.) | bool | false | | ||
@@ -78,0 +80,0 @@ |onTreeDragStart | it execs when fire the tree's dragstart event | function({event,node}) | - | |
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
56195
1432
119