@@ -2,24 +2,42 @@ import React from 'react';
22import ReactDOM from 'react-dom' ;
33import Sortable from 'sortablejs' ;
44
5- const store = {
5+ const store = {
66 nextSibling : null ,
77 activeComponent : null
88} ;
99
10+ const extend = ( target , ...sources ) => {
11+ target = target || { } ;
12+ for ( let index = 0 ; index < sources . length ; index ++ ) {
13+ let obj = sources [ index ] ;
14+ if ( ! obj ) {
15+ continue ;
16+ }
17+ for ( let key in obj ) {
18+ if ( obj . hasOwnProperty ( key ) ) {
19+ target [ key ] = obj [ key ] ;
20+ }
21+ }
22+ }
23+ return target ;
24+ } ;
25+
1026export default class extends React . Component {
1127 static propTypes = {
28+ options : React . PropTypes . object ,
1229 onChange : React . PropTypes . func ,
1330 tag : React . PropTypes . string
1431 } ;
1532 static defaultProps = {
33+ options : { } ,
1634 tag : 'div'
1735 } ;
1836
1937 sortable = null ;
2038
2139 componentDidMount ( ) {
22- const { children , className , ... options } = this . props ;
40+ const options = extend ( { } , this . props . options ) ;
2341
2442 [
2543 'onStart' ,
@@ -45,7 +63,9 @@ export default class extends React.Component {
4563 evt . from . insertBefore ( evt . item , store . nextSibling ) ;
4664
4765 if ( remote !== this ) {
48- if ( ( typeof remote . props . group === 'object' ) && ( remote . props . group . pull === 'clone' ) ) {
66+ const remoteOptions = remote . props . options || { } ;
67+
68+ if ( ( typeof remoteOptions . group === 'object' ) && ( remoteOptions . group . pull === 'clone' ) ) {
4969 // Remove the node with the same data-reactid
5070 evt . item . parentNode . removeChild ( evt . item ) ;
5171 }
0 commit comments