@@ -37,6 +37,7 @@ const store: Store = { dragging: null };
37
37
export class ReactSortable < T extends ItemInterface > extends Component <
38
38
ReactSortableProps < T >
39
39
> {
40
+ /* eslint-disable-next-line */
40
41
static defaultProps : Partial < ReactSortableProps < any > > = {
41
42
clone : ( item ) => item ,
42
43
} ;
@@ -56,7 +57,7 @@ export class ReactSortable<T extends ItemInterface> extends Component<
56
57
57
58
props . setList ( newList , this . sortable , store ) ;
58
59
invariant (
59
- //@ts -ignore
60
+ //@ts -expect-error: Doesn't exist. Will deprecate soon.
60
61
! props . plugins ,
61
62
`
62
63
Plugins prop is no longer supported.
@@ -65,13 +66,13 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
65
66
`
66
67
) ;
67
68
}
68
- componentDidMount ( ) {
69
+ componentDidMount ( ) : void {
69
70
if ( this . ref . current === null ) return ;
70
71
const newOptions = this . makeOptions ( ) ;
71
72
Sortable . create ( this . ref . current , newOptions ) ;
72
73
}
73
74
74
- render ( ) {
75
+ render ( ) : JSX . Element {
75
76
const { tag, style, className, id } = this . props ;
76
77
const classicProps = { style, className, id } ;
77
78
@@ -94,17 +95,20 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
94
95
dataIdAttr,
95
96
selectedClass = "sortable-selected" ,
96
97
chosenClass = "sortable-chosen" ,
98
+ /* eslint-disable */
97
99
dragClass = "sortable-drag" ,
98
100
fallbackClass = "sortable-falback" ,
99
101
ghostClass = "sortable-ghost" ,
100
102
swapClass = "sortable-swap-highlight" ,
103
+ /* eslint-enable */
101
104
filter = "sortable-filter" ,
102
105
list,
103
106
} = this . props ;
104
107
105
108
// if no children, don't do anything.
106
109
if ( ! children || children == null ) return null ;
107
110
const dataid = dataIdAttr || "data-id" ;
111
+ /* eslint-disable-next-line */
108
112
return Children . map ( children as ReactElement < any > [ ] , ( child , index ) => {
109
113
const item = list [ index ] ;
110
114
const { className : prevClassName } = child . props ;
@@ -137,7 +141,7 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
137
141
if ( el === null ) return null ;
138
142
const key = Object . keys ( el ) . find ( ( k ) => k . includes ( "Sortable" ) ) ;
139
143
if ( ! key ) return null ;
140
- //@ts -ignore - I know what I'm doing .
144
+ //@ts -expect-error: fix me .
141
145
return el [ key ] as Sortable ;
142
146
}
143
147
@@ -186,36 +190,39 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
186
190
}
187
191
188
192
/** Prepares a method that will be used in the sortable options to call an `on[Handler]` prop & an `on[Handler]` ReactSortable method. */
189
- prepareOnHandlerPropAndDOM ( evtName : HandledMethodNames ) {
190
- return ( evt : SortableEvent ) => {
193
+ prepareOnHandlerPropAndDOM (
194
+ evtName : HandledMethodNames
195
+ ) : ( evt : SortableEvent ) => void {
196
+ return ( evt ) => {
191
197
// call the component prop
192
198
this . callOnHandlerProp ( evt , evtName ) ;
193
199
// calls state change
194
- //@ts -ignore - until @types multidrag item is in
200
+ //@ts -expect-error: until @types multidrag item is in
195
201
this [ evtName ] ( evt ) ;
196
202
} ;
197
203
}
198
204
199
205
/** Prepares a method that will be used in the sortable options to call an `on[Handler]` prop */
200
206
prepareOnHandlerProp (
201
207
evtName : Exclude < AllMethodsExceptMove , HandledMethodNames >
202
- ) {
203
- return ( evt : SortableEvent ) => {
208
+ ) : ( evt : SortableEvent ) => void {
209
+ return ( evt ) => {
204
210
// call the component prop
205
211
this . callOnHandlerProp ( evt , evtName ) ;
206
212
} ;
207
213
}
208
214
209
215
/** Calls the `props.on[Handler]` function */
210
- callOnHandlerProp ( evt : SortableEvent , evtName : AllMethodsExceptMove ) {
216
+ callOnHandlerProp ( evt : SortableEvent , evtName : AllMethodsExceptMove ) : void {
211
217
const propEvent = this . props [ evtName ] ;
212
218
if ( propEvent ) propEvent ( evt , this . sortable , store ) ;
213
219
}
214
220
215
221
// SORTABLE DOM HANDLING
216
222
217
- onAdd ( evt : MultiDragEvent ) {
223
+ onAdd ( evt : MultiDragEvent ) : void {
218
224
const { list, setList, clone } = this . props ;
225
+ /* eslint-disable-next-line */
219
226
const otherList = [ ...store . dragging ! . props . list ] ;
220
227
const customs = createCustoms ( evt , otherList ) ;
221
228
removeNodes ( customs ) ;
@@ -226,7 +233,7 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
226
233
setList ( newList , this . sortable , store ) ;
227
234
}
228
235
229
- onRemove ( evt : MultiDragEvent ) {
236
+ onRemove ( evt : MultiDragEvent ) : void {
230
237
const { list, setList } = this . props ;
231
238
const mode = getMode ( evt ) ;
232
239
const customs = createCustoms ( evt , list ) ;
@@ -248,7 +255,7 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
248
255
} ) ) ;
249
256
break ;
250
257
case "normal" :
251
- customClones = customs . map ( ( item , index ) => ( {
258
+ customClones = customs . map ( ( item ) => ( {
252
259
...item ,
253
260
element : evt . clone ,
254
261
} ) ) ;
@@ -266,6 +273,7 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
266
273
// replace selected items with cloned items
267
274
customs . forEach ( ( curr ) => {
268
275
const index = curr . oldIndex ;
276
+ /* eslint-disable-next-line */
269
277
const newItem = this . props . clone ! ( curr . item , evt ) ;
270
278
newList . splice ( index , 1 , newItem ) ;
271
279
} ) ;
@@ -276,7 +284,7 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
276
284
setList ( newList , this . sortable , store ) ;
277
285
}
278
286
279
- onUpdate ( evt : MultiDragEvent ) {
287
+ onUpdate ( evt : MultiDragEvent ) : void {
280
288
const { list, setList } = this . props ;
281
289
const customs = createCustoms ( evt , list ) ;
282
290
removeNodes ( customs ) ;
@@ -285,15 +293,15 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
285
293
return setList ( newList , this . sortable , store ) ;
286
294
}
287
295
288
- onStart ( evt : SortableEvent ) {
296
+ onStart ( ) : void {
289
297
store . dragging = this ;
290
298
}
291
299
292
- onEnd ( evt : SortableEvent ) {
300
+ onEnd ( ) : void {
293
301
store . dragging = null ;
294
302
}
295
303
296
- onChoose ( evt : SortableEvent ) {
304
+ onChoose ( evt : SortableEvent ) : void {
297
305
const { list, setList } = this . props ;
298
306
const newList = list . map ( ( item , index ) => {
299
307
if ( index === evt . oldIndex ) {
@@ -307,7 +315,7 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
307
315
setList ( newList , this . sortable , store ) ;
308
316
}
309
317
310
- onUnchoose ( evt : SortableEvent ) {
318
+ onUnchoose ( evt : SortableEvent ) : void {
311
319
const { list, setList } = this . props ;
312
320
const newList = list . map ( ( item , index ) => {
313
321
if ( index === evt . oldIndex ) {
@@ -321,12 +329,12 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
321
329
setList ( newList , this . sortable , store ) ;
322
330
}
323
331
324
- onSpill ( evt : SortableEvent ) {
332
+ onSpill ( evt : SortableEvent ) : void {
325
333
const { removeOnSpill, revertOnSpill } = this . props ;
326
334
if ( removeOnSpill && ! revertOnSpill ) removeNode ( evt . item ) ;
327
335
}
328
336
329
- onSelect ( evt : MultiDragEvent ) {
337
+ onSelect ( evt : MultiDragEvent ) : void {
330
338
const { list, setList } = this . props ;
331
339
const newList = list . map ( ( item ) => ( { ...item , selected : false } ) ) ;
332
340
evt . newIndicies . forEach ( ( curr ) => {
@@ -343,7 +351,7 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
343
351
setList ( newList , this . sortable , store ) ;
344
352
}
345
353
346
- onDeselect ( evt : MultiDragEvent ) {
354
+ onDeselect ( evt : MultiDragEvent ) : void {
347
355
const { list, setList } = this . props ;
348
356
const newList = list . map ( ( item ) => ( { ...item , selected : false } ) ) ;
349
357
evt . newIndicies . forEach ( ( curr ) => {
0 commit comments