0.1.1 • Published 7 years ago

retree v0.1.1

Weekly downloads
6
License
ISC
Repository
github
Last release
7 years ago

retree npm version

A minimal, extensible and customizable tree view UI component for react.

enter image description here

Demo

Installation

npm install --save retree

Usage

import React, { Component } from 'react';
import ReTree from 'retree';
import {prepareData, getChecked} from 'retree';
import '../node_modules/retree/tree-view.css';

class App extends Component {
  state = {
    data: prepareData(
    {
      label:'Pets', id:0, 
      children:[
                { label:'Cats', id:4,
                  children:[
                            {label:'Bubbles', id:5}, 
                            {label:'Riddles', id:6}
                            ]
                },
                { label:'Dogs', id:1, 
                  children:[
                            {label:'Scooby', id:2},
                            {label:'Snowy', id:3}
                            ]
                },
              ]
   }
  )
 }

  onChangeTree = (newData) => this.setState({data:newData});
  
  render() {
    return (      
      <div>
        <ReTree data={this.state.data} onChange={this.onChangeTree} ></ReTree>
        <h5>Checked Items are...</h5>
        <ol>{ Array.from(getChecked(this.state.data, new Set()))
              .map((i,k) => <li key={k}> {i.label} </li>)
            }
        </ol>
      </div>      
    );
  }
}

export default App;

Development

Build: npm install && npm run build

Demo: npm install && npm start

License

ISC.

0.1.1

7 years ago

0.1.0

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago

0.0.0

7 years ago