Editable nested lists for React.
npm install react-nestedlist


For a livedemo click here.
``bash`
npm install --save react-nestedlist
`jsx
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 (
{(items, draggedId) => (
{flatMap(items, item => (
style={{paddingLeft: (item.get('__level') - 1) * 20 + 10}}
className={'list-item' + (draggedId === item.get('_id') ? ' list-item-preview' : '')}>
{item.get('label')}
))}
Development
`bash
prepare
npm installrun development server at http://localhost:8082
npm startrun tests (per default in PhantomJS without coverage report)
npm test
npm test -- --coverage
npm test -- --browser chrome
npm test -- --browser firefoxbuild dist bundle
npm run dist
``