@@ -13,34 +13,15 @@ import flatten from 'flat';
13
13
import actionTypes from '../action-types' ;
14
14
import { isValid } from '../utils' ;
15
15
16
- const propInverses = {
17
- blur : 'focus' ,
18
- dirty : 'pristine' ,
19
- untouched : 'touched' ,
20
- } ;
21
-
22
- function deprecateProp ( prop , result ) {
23
- console . warn ( `The .${ prop } prop will be deprecated as of v1.0.`
24
- + `Please use the the inverse of .${ propInverses [ prop ] } instead.` ) ;
25
-
26
- return result ;
27
- }
28
-
29
16
const initialFieldState = {
30
- get blur ( ) {
31
- return deprecateProp ( 'blur' , true ) ;
32
- } ,
33
- get dirty ( ) {
34
- return deprecateProp ( 'dirty' , false ) ;
35
- } ,
17
+ blur : true , // will be deprecated
18
+ dirty : false , // will be deprecated
36
19
focus : false ,
37
20
pending : false ,
38
21
pristine : true ,
39
22
submitted : false ,
40
23
touched : false ,
41
- get untouched ( ) {
42
- return deprecateProp ( 'untouched' , true ) ;
43
- } ,
24
+ untouched : true , // will be deprecated
44
25
valid : true ,
45
26
validating : false ,
46
27
viewValue : null ,
@@ -164,40 +145,30 @@ function _createFormReducer(model, initialState) {
164
145
165
146
case actionTypes . FOCUS :
166
147
return setField ( state , localPath , {
167
- get blur ( ) {
168
- return deprecateProp ( 'blur' , false ) ;
169
- } ,
148
+ blur : false , // will be deprecated
170
149
focus : true ,
171
150
} ) ;
172
151
173
152
case actionTypes . CHANGE : {
174
153
const setDirtyState = icepick . merge ( state , {
175
- get dirty ( ) {
176
- return deprecateProp ( 'dirty' , true ) ;
177
- } ,
154
+ dirty : true , // will be deprecated
178
155
pristine : false ,
179
156
} ) ;
180
157
181
158
return removeDiff ( setField ( setDirtyState , localPath , {
182
- get dirty ( ) {
183
- return deprecateProp ( 'dirty' , true ) ;
184
- } ,
159
+ dirty : true , // will be deprecated
185
160
pristine : false ,
186
161
} ) , action . value , localPath ) ;
187
162
}
188
163
189
164
case actionTypes . SET_DIRTY : {
190
165
const setDirtyState = icepick . merge ( state , {
191
- get dirty ( ) {
192
- return deprecateProp ( 'dirty' , true ) ;
193
- } ,
166
+ dirty : true , // will be deprecated
194
167
pristine : false ,
195
168
} ) ;
196
169
197
170
return setField ( setDirtyState , localPath , {
198
- get dirty ( ) {
199
- return deprecateProp ( 'dirty' , true ) ;
200
- } ,
171
+ dirty : true , // will be deprecated
201
172
pristine : false ,
202
173
} ) ;
203
174
}
@@ -208,19 +179,13 @@ function _createFormReducer(model, initialState) {
208
179
focus : false ,
209
180
touched : true ,
210
181
retouched : state . submitted || state . submitFailed ,
211
- get blur ( ) {
212
- return deprecateProp ( 'blur' , true ) ;
213
- } ,
214
- get untouched ( ) {
215
- return deprecateProp ( 'untouched' , false ) ;
216
- } ,
182
+ blur : true , // will be deprecated
183
+ untouched : false , // will be deprecated
217
184
} ) ;
218
185
219
186
return icepick . merge ( fieldState , {
220
187
touched : true ,
221
- get untouched ( ) {
222
- return deprecateProp ( 'untouched' , false ) ;
223
- } ,
188
+ untouched : false , // will be deprecated
224
189
} ) ;
225
190
}
226
191
@@ -360,37 +325,29 @@ function _createFormReducer(model, initialState) {
360
325
setPristineState = icepick . merge ( state , {
361
326
fields : mapValues ( state . fields , field => ( {
362
327
...field ,
363
- get dirty ( ) {
364
- return deprecateProp ( 'dirty' , false ) ;
365
- } ,
328
+ dirty : false , // will be deprecated
366
329
pristine : true ,
367
330
} ) ) ,
368
331
} ) ;
369
332
} else {
370
333
setPristineState = setField ( state , localPath , {
371
- get dirty ( ) {
372
- return deprecateProp ( 'dirty' , false ) ;
373
- } ,
334
+ dirty : false , // will be deprecated
374
335
pristine : true ,
375
336
} ) ;
376
337
377
338
formIsPristine = every ( mapValues ( setPristineState . fields , field => field . pristine ) ) ;
378
339
}
379
340
380
341
return icepick . merge ( setPristineState , {
381
- get dirty ( ) {
382
- return deprecateProp ( 'dirty' , ! formIsPristine ) ;
383
- } ,
342
+ dirty : ! formIsPristine , // will be deprecated
384
343
pristine : formIsPristine ,
385
344
} ) ;
386
345
}
387
346
388
347
case actionTypes . SET_UNTOUCHED :
389
348
return setField ( state , localPath , {
390
349
touched : false ,
391
- get untouched ( ) {
392
- return deprecateProp ( 'untouched' , true ) ;
393
- } ,
350
+ untouched : true , // will be deprecated
394
351
} ) ;
395
352
396
353
case actionTypes . SET_SUBMITTED :
@@ -399,9 +356,7 @@ function _createFormReducer(model, initialState) {
399
356
submitted : ! ! action . submitted ,
400
357
submitFailed : false ,
401
358
touched : true ,
402
- get untouched ( ) {
403
- return deprecateProp ( 'untouched' , false ) ;
404
- } ,
359
+ untouched : false , // will be deprecated
405
360
} ) ;
406
361
407
362
case actionTypes . SET_SUBMIT_FAILED :
@@ -410,9 +365,7 @@ function _createFormReducer(model, initialState) {
410
365
submitted : false ,
411
366
submitFailed : true ,
412
367
touched : true ,
413
- get untouched ( ) {
414
- return deprecateProp ( 'untouched' , false ) ;
415
- } ,
368
+ untouched : false , // will be deprecated
416
369
} ) ;
417
370
418
371
case actionTypes . SET_INITIAL :
0 commit comments