55[ ![ dependencies Status] ( https://david-dm.org/hckhanh/react-tree-es6/status.svg )] ( https://david-dm.org/hckhanh/react-tree-es6 )
66[ ![ CII Best Practices] ( https://bestpractices.coreinfrastructure.org/projects/288/badge )] ( https://bestpractices.coreinfrastructure.org/projects/288 )
77
8- The wrapper of jsTree (jstree.com) for React
8+ If you want to find a ** tree view ** component for [ React ] ( https://facebook.github.io/react/ ) , this module is what you need.
99
1010## Getting Started
1111
12- If you want to find a ** tree view** component for React, this module is what you need.
13- ** It supports ES6 and backward compatible with ES5.**
12+ ** It ONLY supports ES6 and above.** Read < https://hckhanh.github.io/react-tree-es6 > for more details.
1413
1514## Installation
1615
@@ -20,102 +19,6 @@ npm install --save react-tree-es6
2019
2120## Usage
2221
23- import/require ` ReactTree ` in your source code:
24-
25- ``` js
26- import ReactTree from ' react-tree-es6' ;
27- ```
28-
29- and add this component into your ` render() ` function:
30-
31- ``` js
32- render () {
33- return (< ReactTree core= {CORE } onChanged= {this .handleOnChanged } / > );
34- }
35- ```
36-
37- ** Go to [ example] ( example ) folder to get more details.**
38-
39- ### core
40-
41- ` core ` is the jsTree object contains basic data and configurations of the tree.
42- This is an example of ` core ` object:
43-
44- ``` js
45- {
46- data: [ // data can be an array or object.
47- ' Simple root node' ,
48- {
49- text: ' Root node 2' ,
50- state: {
51- opened: true ,
52- selected: true
53- },
54- children: [
55- {
56- text: ' Child 1'
57- },
58- ' Child 2'
59- ]
60- }
61- ]
62- }
63- ```
64-
65- As you know, a tree has one or many nodes, here is the full structure of a node:
66-
67- ``` js
68- // Alternative format of the node (id & parent are required)
69- {
70- id: ' string' // required
71- parent: ' string' // required
72- text: ' string' // node text
73- icon: ' string' // string for custom
74- state: {
75- opened: boolean // is the node open
76- disabled: boolean // is the node disabled
77- selected: boolean // is the node selected
78- },
79- li_attr: { } // attributes for the generated LI node
80- a_attr: { } // attributes for the generated A node
81- }
82- ```
83-
84- You can define a ` core ` object and then put it to ` core ` property:
85-
86- ``` js
87- const CORE = {
88- data: [
89- ' Simple root node' ,
90- {
91- text: ' Root node 2' ,
92- state: {
93- opened: true ,
94- selected: true
95- },
96- children: [
97- {
98- text: ' Child 1'
99- },
100- ' Child 2'
101- ]
102- }
103- ]
104- };
105-
106- class ExampleApp extends React .Component {
107- render () {
108- return (< ReactTree core= {CORE } / > );
109- }
110- }
111- ```
112-
113- ** To make sure you can find what you need, go to [ jsTree API] ( https://www.jstree.com/api ) for more details.**
114-
115- ### onChanged
116-
117- This is an event to handle when a node is clicked:
118-
11922``` js
12023const CORE = {
12124 data: [
@@ -162,39 +65,6 @@ class ExampleApp extends React.Component {
16265}
16366```
16467
165- ### Themes
166-
167- If user want to apply css for ** ReactTree** , consider to include these files to your web app:
168-
169- * node_modules/jstree/dist/themes/** default** /style.min.css
170- * node_modules/jstree/dist/themes/** default-dark** /style.min.css
171-
172- with additional options in ` core ` object, for instance with ** default-dark** theme:
173-
174- ``` js
175- const CORE = {
176- data: [
177- ' Simple root node' ,
178- {
179- text: ' Root node 2' ,
180- state: {
181- opened: true ,
182- selected: true
183- },
184- children: [
185- {
186- text: ' Child 1'
187- },
188- ' Child 2'
189- ]
190- }
191- ],
192- themes: {
193- name: ' default-dark'
194- }
195- };
196- ```
197-
19868## License
19969
200- MIT ( < http://www.opensource.org/licenses/mit-license.php > )
70+ MIT
0 commit comments