1.0.17-rc.2 • Published 5 years ago

@beisen-phoenix/rc-tree v1.0.17-rc.2

Weekly downloads
-
License
ISC
Repository
gitlab
Last release
5 years ago

rc-tree


API

Tree props

namedescriptiontypedefault
autoExpandParent自动展开指定的父节点boolfalse
checkable节点前添加 Checkbox 复选框bool/React Nodefalse
checkedKeys受控选中的树节点(设置后,默认选中的键将不起作用)。注意:父节点和子节点是关联的,如果父节点的键存在,则检查所有子节点,反之亦然。当设置checkable和checkstricle时,它应该是一个包含checked数组和半checked数组的对象。String[]/{checked:Array,halfChecked:Array}[]
checkStrictlycheckable状态下节点选择完全受控(父子节点选中状态不再关联)boolfalse
className根dom节点的附加css类String''
defaultCheckedKeys默认选中复选框的树节点String[][]
defaultExpandedKeys默认展开指定的树节点String[]-
defaultExpandAll默认展开所有树节点boolfalse
defaultExpandParent默认展开父节点booltrue
defaultSelectedKeys默认选中的树节点String[][]
disabled是否禁用树boolfalse
draggable设置节点可拖拽(IE>8)boolfalse
expandedKeys(受控)展开指定的树节点String[]-
filterTreeNode按需筛选树节点(高亮),返回truefunction(node)-
icon自定义图标。可接收组件,props 为当前节点 propselement/Function(props)-
loadedKeys受控)已经加载的节点,需要配合 loadData 使用string[]-
loadData异步加载数据,返回值应该是一个promisefunction(node)-
multiple支持点选多个节点(节点本身)boolfalse
prefixCls样式前缀String'rc-loadDatatree'
selectable是否可以被选中booltrue
selectedKeys受控选定树节点(设置后,默认选定的键将不起作用)String[][]
showIcon是否显示图标booltrue
singleLine设置是否整行选中boolfalse
treeDataTreeNodes数据数组,如果设置了它,则不需要构造子TreeNode。(值在整个数组中应该是唯一的),***h目前仅对treeData方式的使用,做了整行选择样式支持扩展,其他使用保持原组件方式***array<{key,title,children, disabled, selectable}>-
onCheck单击TreeNode/复选框触发function(checkedKeys, e:{checked: bool, checkedNodes, node, event, nativeEvent})-
onExpand展开/收起节点时触发function(expandedKeys, {expanded: bool, node, nativeEvent})-
onDragEnddragend 触发时调用function({event,node})-
onDragEnterdragenter 触发时调用function({event,node,expandedKeys})-
onDragLeavedragleave 触发时调用function({event,node})-
onDragOverdragover 触发时调用(一直)function({event,node})-
onDragStartdragstart 触发时调用function({event,node})-
onDropdrop 触发时调用function({event, node, dragNode, dragNodesKeys})-
onLoad节点加载完毕时触发-
onMouseEnter当鼠标进入TreeNode时调用function({event,node})-
onMouseLeave当鼠标离开TreeNode时调用function({event,node})-
onRightClick响应右键点击function({event,node})-
onSelect节点选中时触发function(selectedKeys, e:{selected: bool, selectedNodes, node, event, nativeEvent})-
switcherIcon指定节点切换图标ReactNode / (props: TreeNodeAttribute) => ReactNode-

TreeNode props

note: if you have a lot of TreeNode, like more than 1000,
make the parent node is collapsed by default, will obvious effect, very fast.
Because the children hide TreeNode will not insert into dom.

namedescriptiontypedefault
className节点附加的样式String''
style设置节点的style样式Object''
disabled是否禁用Treenodeboolfalse
disableCheckbox是否禁用Treenode'复选框boolfalse
title树/子树的标题String/element'---'
key节点标识,全局唯一。它与树属性(默认)expandedkeys/(默认)checkedkeys/(默认)selectedkeys一起使用。StringtreeNode's position
isLeaf是否为叶节点boolfalse
icon自定义图标。可接收组件,props 为当前节点 propselement/Function(props)-
switcherIcon指定节点切换图标ReactNode / (props: TreeNodeAttribute) => ReactNode-

note

The number of treeNodes can be very large, but when enable checkable, it will spend more computing time, so we cached some calculations(e.g. this.treeNodesStates), to avoid double computing. But, this bring some restrictions, when you async load treeNodes, you should render tree like this {this.state.treeData.length ? <Tree ...>{this.state.treeData.map(t => <TreeNode ... />)}</Tree> : 'loading tree'}

Development

npm install
npm start

Test Case

http://localhost:8018/tests/runner.html?coverage

Coverage

http://localhost:8018/node_modules/rc-server/node_modules/node-jscover/lib/front-end/jscoverage.html?w=http://localhost:8018/tests/runner.html?coverage

License

rc-tree is released under the MIT license.

other tree view

1.0.17-rc.2

5 years ago

1.0.17-rc.1

5 years ago

1.0.17

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago