Socket
Book a DemoInstallSign in
Socket

react-nestedlist

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-nestedlist

Editable nested lists for React.

0.0.3
latest
Source
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

react-nestedlist

build npm license

Livedemo

For a livedemo click here.

Usage

npm install --save react-nestedlist
import {flatMap} from 'react-nestedlist/dist/utils/nestedListUtils';
import NestedList, {NestedListItem} from 'react-nestedlist';
import Immutable from 'immutable';

class App extends React.Component {
  constructor() {
    super();
    this.state = {
      tree: Immutable.fromJS([
        {
          _id: 'startpage',
          label: 'Startpage',
          children: []
        },
        {
          _id: 'page-1',
          label: 'Page 1',
          children: [
            {
              _id: 'page-1a',
              label: 'Page 1a',
              children: []
            },
            {
              _id: 'page-1b',
              label: 'Page 1b',
              children: []
            }
          ]
        },
        {
          _id: 'page-2',
          label: 'Page 2',
          children: []
        }
      ])
    }
  }

  validate(tree) {
    if (tree.first().get('label') !== 'Startpage') return 'Startpage must be first';

    return true;
  }

  render() {
    return (
      <NestedList data={this.state.tree} onDataChange={tree => this.setState({tree})} validate={this.validate}>
        {(items, draggedId) => (
          <div className="list">
            {flatMap(items, item => (
              <NestedListItem key={item.get('_id')} item={item}>
                <div
                  style={{paddingLeft: (item.get('__level') - 1) * 20 + 10}}
                  className={'list-item' + (draggedId === item.get('_id') ? ' list-item-preview' : '')}>
                  {item.get('label')}
                </div>
              </NestedListItem>
            ))}
          </div>
        )}
      </NestedList>
    );
  }
}

Development

# prepare
npm install

# run development server at http://localhost:8082
npm start

# run tests (per default in PhantomJS without coverage report)
npm test
npm test -- --coverage
npm test -- --browser chrome
npm test -- --browser firefox

# build dist bundle
npm run dist

FAQs

Package last updated on 12 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.