0.0.21 • Published 5 years ago

react-power-tree v0.0.21

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

react-power-tree

npm version stage PRs Welcome

Installation

npm install react-power-tree

Current version requires react and material-ui as dependencies. Please check peerDependencies in package.json.

Usage

import PowerTree from 'react-power-tree';

Developers can choose to provide static data to render tree view or recursively add child nodes in dynamic way.

Online Examples

Static tree view

<PowerTree
    data={data}
    options={options} // optional
    onNodeSelect={(nodeData) => {
        console.log(nodeData);
    }}
/>

Attributes of node

KeyTypeRequiredDetail
namestringYThe name of child nodes with same parent node must be different from each other
childrenarrayNArray of child node data
defaultExpandedbooleanNDefault value is false
iconreact componentNDefault value is directory or file icon

Options

contextMenu

Popup when right clicking node. If null or empty, right click won't show the menu

FieldTypeRequiredDetails
itemsarrayYmenu items. keys: icon, label
onSelectfuncYonSelect(label, nodeData) => {}

Dynamic tree view

<PowerTree
    data={initData}
    options={options}
    onNodeSelect={(nodeData) => {
        console.log(nodeData)
    }}
    onNodeExpand={(nodeData, operations) => {
        const {addChildren} = operations;
        const childNodes = [...data];
        addChildren(childNodes);
    }}
/>
0.0.21

5 years ago

0.0.20

5 years ago

0.0.19

5 years ago

0.0.18

5 years ago

0.0.17

5 years ago

0.0.16

5 years ago

0.0.14

5 years ago

0.0.13

5 years ago

0.0.12

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago