@@ -4,7 +4,6 @@ import uniq from 'lodash/uniq';
4
4
import React from 'react' ;
5
5
import ReactDOM from 'react-dom' ;
6
6
import Sortable from '../../src' ;
7
- import store from './store' ;
8
7
9
8
class App extends React . Component {
10
9
state = {
@@ -16,6 +15,8 @@ class App extends React.Component {
16
15
cloneControlledTarget : [ ]
17
16
} ;
18
17
18
+ simpleList = null ;
19
+
19
20
addMoreItems ( ) {
20
21
const items = [
21
22
'Apple' ,
@@ -58,11 +59,28 @@ class App extends React.Component {
58
59
< div >
59
60
< div className = "container-fluid" style = { { marginTop : 50 } } >
60
61
< div className = "title" > Simple List</ div >
62
+ < div className = "form-group" >
63
+ < button
64
+ type = "button"
65
+ className = "btn btn-default"
66
+ onClick = { ( e ) => {
67
+ const order = this . simpleList . toArray ( ) ;
68
+ this . simpleList . sort ( order . reverse ( ) ) ;
69
+ } }
70
+ >
71
+ Reverse Order
72
+ </ button >
73
+ </ div >
61
74
< div className = "row" >
62
75
< div className = "col-sm-12" >
63
76
< Sortable
64
- tag = "ul"
65
77
className = "block-list"
78
+ ref = { c => {
79
+ if ( c ) {
80
+ this . simpleList = c . sortable ;
81
+ }
82
+ } }
83
+ tag = "ul"
66
84
>
67
85
{ simpleList }
68
86
</ Sortable >
@@ -83,13 +101,15 @@ class App extends React.Component {
83
101
< div className = "row" >
84
102
< div className = "col-sm-6" >
85
103
< Sortable
86
- ref = "group-left"
87
- className = "block-list"
88
- group = { {
89
- name : 'shared' ,
90
- pull : true ,
91
- put : true
104
+ options = { {
105
+ group : {
106
+ name : 'shared' ,
107
+ pull : true ,
108
+ put : true
109
+ }
92
110
} }
111
+ className = "block-list"
112
+ ref = "group-left"
93
113
onChange = { ( items ) => {
94
114
this . setState ( { groupLeft : items } ) ;
95
115
} }
@@ -99,16 +119,18 @@ class App extends React.Component {
99
119
</ div >
100
120
< div className = "col-sm-6" >
101
121
< Sortable
102
- ref = "group-right"
103
- className = "block-list"
104
- group = { {
105
- name : 'shared' ,
106
- pull : true ,
107
- put : true
122
+ options = { {
123
+ group : {
124
+ name : 'shared' ,
125
+ pull : true ,
126
+ put : true
127
+ }
108
128
} }
129
+ className = "block-list"
109
130
onChange = { ( items ) => {
110
131
this . setState ( { groupRight : items } ) ;
111
132
} }
133
+ ref = "group-right"
112
134
>
113
135
{ groupRight }
114
136
</ Sortable >
@@ -117,33 +139,35 @@ class App extends React.Component {
117
139
</ div >
118
140
< div className = "container-fluid" >
119
141
< div className = "title" style = { { marginTop : 50 } } > Uncontrolled Component</ div >
120
- < h4 > Clone items from left to right with duplicate DOM elements.</ h4 >
142
+ < h4 > Clone items from left to right. DOM elements are duplicated .</ h4 >
121
143
< div className = "row" >
122
144
< div className = "col-sm-6" >
123
145
< Sortable
124
- ref = "group-left"
125
- tag = "ul"
126
- className = "block-list"
127
- sort = { false }
128
- group = { {
129
- name : 'shared' ,
130
- pull : 'clone' ,
131
- put : false
146
+ options = { {
147
+ sort : false ,
148
+ group : {
149
+ name : 'clone1' ,
150
+ pull : 'clone' ,
151
+ put : false
152
+ }
132
153
} }
154
+ className = "block-list"
155
+ tag = "ul"
133
156
>
134
157
{ cloneUncontrolled }
135
158
</ Sortable >
136
159
</ div >
137
160
< div className = "col-sm-6" >
138
161
< Sortable
139
- ref = "group-right"
140
- tag = "ul"
141
- className = "block-list"
142
- group = { {
143
- name : 'shared' ,
144
- pull : false ,
145
- put : true
162
+ options = { {
163
+ group : {
164
+ name : 'clone1' ,
165
+ pull : false ,
166
+ put : true
167
+ }
146
168
} }
169
+ className = "block-list"
170
+ tag = "ul"
147
171
>
148
172
</ Sortable >
149
173
</ div >
@@ -155,36 +179,38 @@ class App extends React.Component {
155
179
< div className = "row" >
156
180
< div className = "col-sm-6" >
157
181
< Sortable
158
- ref = "group-left"
159
- tag = "ul"
160
- className = "block-list"
161
- sort = { false }
162
- group = { {
163
- name : 'shared' ,
164
- pull : 'clone' ,
165
- put : false
182
+ options = { {
183
+ sort : false ,
184
+ group : {
185
+ name : 'clone2' ,
186
+ pull : 'clone' ,
187
+ put : false
188
+ }
166
189
} }
190
+ className = "block-list"
167
191
onChange = { ( items ) => {
168
192
this . setState ( { cloneControlledSource : items } ) ;
169
193
} }
194
+ tag = "ul"
170
195
>
171
196
{ cloneControlledSource }
172
197
</ Sortable >
173
198
</ div >
174
199
< div className = "col-sm-6" >
175
200
< Sortable
176
- ref = "group-right"
177
- tag = "ul"
178
- className = "block-list"
179
- group = { {
180
- name : 'shared' ,
181
- pull : false ,
182
- put : true
201
+ options = { {
202
+ group : {
203
+ name : 'clone2' ,
204
+ pull : false ,
205
+ put : true
206
+ }
183
207
} }
208
+ className = "block-list"
184
209
onChange = { ( items ) => {
185
210
items = uniq ( items ) ; // Remove duplicate items
186
211
this . setState ( { cloneControlledTarget : items } ) ;
187
212
} }
213
+ tag = "ul"
188
214
>
189
215
{ cloneControlledTarget }
190
216
</ Sortable >
0 commit comments