rsuite-check-tree
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -87,7 +87,32 @@ 'use strict'; | ||
_this.selectActiveItem = function (event) { | ||
var onChange = _this.props.onChange; | ||
var _this$getActiveItem = _this.getActiveItem(), | ||
nodeData = _this$getActiveItem.nodeData, | ||
layer = _this$getActiveItem.layer; | ||
onChange && onChange(nodeData, +layer, event); | ||
}; | ||
_this.toggleTreeNodeClass = function (nodeData) { | ||
var ele = (0, _reactDom.findDOMNode)(_this); | ||
var loop = function loop(nodes) { | ||
nodes.forEach(function (node) { | ||
(0, _domLib.toggleClass)(ele.querySelector('[data-value="' + node.value + '"]'), 'view'); | ||
if (node.children) { | ||
loop(node.children); | ||
} | ||
}); | ||
}; | ||
if (nodeData.children) { | ||
loop(nodeData.children); | ||
} | ||
}; | ||
_this.handleTreeToggle = function (nodeData, layer, event) { | ||
var _this$props = _this.props, | ||
onExpand = _this$props.onExpand, | ||
loadData = _this$props.loadData; | ||
var onExpand = _this.props.onExpand; | ||
_this.toggleTreeNodeClass(nodeData); | ||
(0, _domLib.toggleClass)((0, _reactDom.findDOMNode)(_this.refs['children_' + nodeData.value]), 'open'); | ||
@@ -109,17 +134,2 @@ nodeData.expand = (0, _domLib.hasClass)((0, _reactDom.findDOMNode)(_this.refs['children_' + nodeData.value]), 'open'); | ||
_this.selectActiveItem = function (event) { | ||
var _this$props2 = _this.props, | ||
onChange = _this$props2.onChange, | ||
data = _this$props2.data; | ||
var activeItem = document.activeElement; | ||
var _activeItem$dataset = activeItem.dataset, | ||
value = _activeItem$dataset.value, | ||
layer = _activeItem$dataset.layer; | ||
var nodeData = _this.getActiveElementOption(data, value); | ||
onChange && onChange(nodeData, +layer, event); | ||
}; | ||
_this.handleKeyDown = function (event) { | ||
@@ -198,3 +208,3 @@ switch (event.keyCode) { | ||
} | ||
return Array.from(node.querySelectorAll('[tabIndex="-1"]')).filter(function (item) { | ||
return Array.from(node.querySelectorAll('[tabIndex="-1"].tree-node.view')).filter(function (item) { | ||
return !~item.className.indexOf('disabled'); | ||
@@ -210,5 +220,18 @@ }); | ||
} | ||
}, { | ||
key: 'getActiveItem', | ||
value: function getActiveItem() { | ||
var data = this.props.data; | ||
// 展开,收起节点 | ||
var activeItem = document.activeElement; | ||
var _activeItem$dataset = activeItem.dataset, | ||
value = _activeItem$dataset.value, | ||
layer = _activeItem$dataset.layer; | ||
var nodeData = this.getActiveElementOption(data, value); | ||
return { | ||
nodeData: nodeData, | ||
layer: layer | ||
}; | ||
} | ||
}, { | ||
@@ -242,6 +265,8 @@ key: 'focusNextMenuItem', | ||
} | ||
var prevIndex = activeIndex === 0 ? items.length - 1 : activeIndex - 1; | ||
items[prevIndex].focus(); | ||
} | ||
// 展开,收起节点 | ||
}, { | ||
@@ -288,3 +313,4 @@ key: 'renderNode', | ||
parent: parent, | ||
checkState: checkState | ||
checkState: checkState, | ||
defaultExpandAll: defaultExpandAll | ||
}; | ||
@@ -295,3 +321,2 @@ | ||
var refKey = 'children_' + itemData.value; | ||
var node = _react2.default.createElement(Node, _extends({ key: index }, props)); | ||
@@ -298,0 +323,0 @@ if (_hasChildren) { |
@@ -118,3 +118,4 @@ 'use strict'; | ||
checkState = _props.checkState, | ||
renderTreeNode = _props.renderTreeNode; | ||
renderTreeNode = _props.renderTreeNode, | ||
defaultExpandAll = _props.defaultExpandAll; | ||
@@ -125,5 +126,7 @@ | ||
'half-checked': checkState === 'halfChecked', | ||
view: defaultExpandAll, | ||
checked: checkState === 'checked', | ||
disabled: disabled, | ||
active: active | ||
}); | ||
@@ -130,0 +133,0 @@ |
{ | ||
"name": "rsuite-check-tree", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "A react check tree component", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -1,2 +0,3 @@ | ||
# rsuite-tree [![npm][npm-badge]][npm] | ||
[![Travis](https://img.shields.io/travis/rsuite/rsuite-check-tree.svg)](https://travis-ci.org/rsuite/rsuite-check-tree) [![npm](https://img.shields.io/npm/v/rsuite-notification.svg)](https://www.npmjs.com/package/rsuite-check-tree) | ||
# rsuite-tree | ||
@@ -18,3 +19,3 @@ check 树形控件 | ||
import CheckTree from 'rsuite-tree'; | ||
import CheckTree from 'rsuite-check-tree'; | ||
<CheckTree | ||
@@ -34,5 +35,1 @@ defaultExpandAll | ||
[npm-badge]: https://badge.fury.io/js/rsuite-check-tree.svg | ||
[npm]: http://badge.fury.io/js/rsuite-check-tree |
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
41962
827
34