/**
 * @file DraggableTreeNodeList component
 * @author liangxiaojun(liangxiaojun@derbysoft.com)
 */

import React, {Component} from 'react';
import PropTypes from 'prop-types';
import {Droppable} from 'react-beautiful-dnd';

import TreeNode from '../_TreeNode/TreeNode';

class DraggableTreeNodeList extends Component {

    constructor(props, ...restArgs) {
        super(props, ...restArgs);
    }

    render() {

        const {depth, path, data, collapsed} = this.props;

        return (
            <Droppable droppableId="droppable">
                {(provided, snapshot) => (
                    <div ref={provided.innerRef}
                         className={'draggable-tree-node-list' + (collapsed ? ' collapsed' : '')}>

                        {
                            data && data.length > 0 ?
                                (
                                    data.map((item, index) => {
                                        return (
                                            <TreeNode {...this.props}
                                                      key={index}
                                                      data={item}
                                                      index={index}
                                                      depth={depth + 1}
                                                      path={path ? [...path, {index, value: item}] : [{
                                                          index,
                                                          value: item
                                                      }]}/>
                                        );
                                    })
                                )
                                :
                                null
                        }

                        {provided.placeholder}

                    </div>
                )}
            </Droppable>
        );

    }
};

DraggableTreeNodeList.propTypes = {

    depth: PropTypes.number,
    path: PropTypes.array,

    data: PropTypes.array,

    collapsed: PropTypes.bool

};

DraggableTreeNodeList.defaultProps = {

    depth: -1,
    path: null,

    data: [],

    collapsed: false

};

export default DraggableTreeNodeList;
@@ -557,17 +557,16 @@
    %7B
-(
 provided
 , sn
@@ -565,19 +565,8 @@
 ided
-, snapshot)
  =%3E 
@@ -895,64 +895,9 @@
 ) =%3E
- %7B
 %0A
-                                        return (%0A    
     
@@ -958,20 +958,16 @@
 .props%7D%0A
-    
         
@@ -1066,28 +1066,24 @@
             
-    
 data=%7Bitem%7D%0A
@@ -1128,28 +1128,24 @@
             
-   
- 
 index=%7Bindex
@@ -1138,36 +1138,32 @@
   index=%7Bindex%7D%0A
-    
                 
@@ -1214,20 +1214,16 @@
 th + 1%7D%0A
-    
         
@@ -1372,23 +1372,15 @@
     
-    
 index,%0A
-    
     
@@ -1491,20 +1491,16 @@
         
-    
 %7D%5D%7D/%3E%0A  
@@ -1537,52 +1537,8 @@
     
-    );%0A                                    %7D
 )%0A  

update DraggableTreeNodeList