@@ -2,24 +2,42 @@ import React from 'react';
2
2
import ReactDOM from 'react-dom' ;
3
3
import Sortable from 'sortablejs' ;
4
4
5
- const store = {
5
+ const store = {
6
6
nextSibling : null ,
7
7
activeComponent : null
8
8
} ;
9
9
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
+
10
26
export default class extends React . Component {
11
27
static propTypes = {
28
+ options : React . PropTypes . object ,
12
29
onChange : React . PropTypes . func ,
13
30
tag : React . PropTypes . string
14
31
} ;
15
32
static defaultProps = {
33
+ options : { } ,
16
34
tag : 'div'
17
35
} ;
18
36
19
37
sortable = null ;
20
38
21
39
componentDidMount ( ) {
22
- const { children , className , ... options } = this . props ;
40
+ const options = extend ( { } , this . props . options ) ;
23
41
24
42
[
25
43
'onStart' ,
@@ -45,7 +63,9 @@ export default class extends React.Component {
45
63
evt . from . insertBefore ( evt . item , store . nextSibling ) ;
46
64
47
65
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' ) ) {
49
69
// Remove the node with the same data-reactid
50
70
evt . item . parentNode . removeChild ( evt . item ) ;
51
71
}
0 commit comments