redux-form
Advanced tools
Comparing version 6.6.1 to 6.6.2
@@ -408,2 +408,59 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
}); | ||
it('should concatenate prefixes when nested', function () { | ||
var store = makeStore({ | ||
testForm: { | ||
values: { | ||
deep: { | ||
foo: { | ||
bar: '42' | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
var input = createSpy(function (props) { | ||
return React.createElement('input', props.input); | ||
}).andCallThrough(); | ||
var Form = function (_Component6) { | ||
_inherits(Form, _Component6); | ||
function Form() { | ||
_classCallCheck(this, Form); | ||
return _possibleConstructorReturn(this, (Form.__proto__ || Object.getPrototypeOf(Form)).apply(this, arguments)); | ||
} | ||
_createClass(Form, [{ | ||
key: 'render', | ||
value: function render() { | ||
return React.createElement( | ||
FormSection, | ||
{ name: 'deep' }, | ||
React.createElement( | ||
FormSection, | ||
{ name: 'foo' }, | ||
React.createElement(Field, { name: 'bar', component: input }) | ||
) | ||
); | ||
} | ||
}]); | ||
return Form; | ||
}(Component); | ||
var TestForm = reduxForm({ form: 'testForm' })(Form); | ||
TestUtils.renderIntoDocument(React.createElement( | ||
Provider, | ||
{ store: store }, | ||
React.createElement(TestForm, null) | ||
)); | ||
// input gets the correct name and value | ||
expect(input).toHaveBeenCalled(); | ||
expect(input.calls.length).toBe(1); | ||
expect(input.calls[0].arguments[0].input.value).toBe('42'); | ||
expect(input.calls[0].arguments[0].input.name).toBe('deep.foo.bar'); | ||
}); | ||
}); | ||
@@ -410,0 +467,0 @@ }; |
import expect from 'expect'; | ||
import * as expectedActionTypes from '../actionTypes'; | ||
import expectedPropTypes from '../propTypes'; | ||
import { actionTypes, arrayInsert, arrayMove, arrayPop, arrayPush, arrayRemove, arrayRemoveAll, arrayShift, arraySplice, arraySwap, arrayUnshift, autofill, blur, change, destroy, Field, Fields, FieldArray, Form, FormSection, focus, formValueSelector, getFormValues, getFormInitialValues, getFormSyncErrors, getFormAsyncErrors, getFormSyncWarnings, getFormSubmitErrors, initialize, isDirty, isInvalid, isPristine, isValid, isSubmitting, hasSubmitSucceeded, hasSubmitFailed, propTypes, reducer, reduxForm, registerField, reset, setSubmitFailed, setSubmitSucceeded, startAsyncValidation, startSubmit, stopAsyncValidation, stopSubmit, submit, SubmissionError, touch, unregisterField, untouch, values } from '../immutable'; | ||
import { actionTypes, arrayInsert, arrayMove, arrayPop, arrayPush, arrayRemove, arrayRemoveAll, arrayShift, arraySplice, arraySwap, arrayUnshift, autofill, blur, change, clearSubmitErrors, destroy, Field, Fields, FieldArray, Form, FormSection, focus, formValueSelector, getFormValues, getFormInitialValues, getFormSyncErrors, getFormAsyncErrors, getFormSyncWarnings, getFormSubmitErrors, initialize, isDirty, isInvalid, isPristine, isValid, isSubmitting, hasSubmitSucceeded, hasSubmitFailed, propTypes, reducer, reduxForm, registerField, reset, setSubmitFailed, setSubmitSucceeded, startAsyncValidation, startSubmit, stopAsyncValidation, stopSubmit, submit, SubmissionError, touch, unregisterField, untouch, values } from '../immutable'; | ||
@@ -49,2 +49,5 @@ describe('immutable', function () { | ||
}); | ||
it('should export clearSubmitErrors', function () { | ||
expect(clearSubmitErrors).toExist().toBeA('function'); | ||
}); | ||
it('should export destroy', function () { | ||
@@ -51,0 +54,0 @@ expect(destroy).toExist().toBeA('function'); |
import expect from 'expect'; | ||
import * as expectedActionTypes from '../actionTypes'; | ||
import expectedPropTypes from '../propTypes'; | ||
import { actionTypes, arrayInsert, arrayMove, arrayPop, arrayPush, arrayRemove, arrayRemoveAll, arrayShift, arraySplice, arraySwap, arrayUnshift, autofill, blur, change, destroy, Field, Fields, FieldArray, Form, FormSection, focus, formValueSelector, getFormNames, getFormValues, getFormInitialValues, getFormSyncErrors, getFormAsyncErrors, getFormSyncWarnings, getFormSubmitErrors, initialize, isDirty, isInvalid, isPristine, isValid, isSubmitting, hasSubmitSucceeded, hasSubmitFailed, propTypes, reducer, reduxForm, registerField, reset, setSubmitFailed, setSubmitSucceeded, startAsyncValidation, startSubmit, stopAsyncValidation, stopSubmit, submit, SubmissionError, touch, unregisterField, untouch, values } from '../index'; | ||
import { actionTypes, arrayInsert, arrayMove, arrayPop, arrayPush, arrayRemove, arrayRemoveAll, arrayShift, arraySplice, arraySwap, arrayUnshift, autofill, blur, change, clearSubmitErrors, destroy, Field, Fields, FieldArray, Form, FormSection, focus, formValueSelector, getFormNames, getFormValues, getFormInitialValues, getFormSyncErrors, getFormAsyncErrors, getFormSyncWarnings, getFormSubmitErrors, initialize, isDirty, isInvalid, isPristine, isValid, isSubmitting, hasSubmitSucceeded, hasSubmitFailed, propTypes, reducer, reduxForm, registerField, reset, setSubmitFailed, setSubmitSucceeded, startAsyncValidation, startSubmit, stopAsyncValidation, stopSubmit, submit, SubmissionError, touch, unregisterField, untouch, values } from '../index'; | ||
@@ -49,2 +49,5 @@ describe('index', function () { | ||
}); | ||
it('should export clearSubmitErrors', function () { | ||
expect(clearSubmitErrors).toExist().toBeA('function'); | ||
}); | ||
it('should export destroy', function () { | ||
@@ -51,0 +54,0 @@ expect(destroy).toExist().toBeA('function'); |
import { arrayRemove } from '../actions'; | ||
var describeArrayRemove = function describeArrayRemove(reducer, expect, _ref) { | ||
var fromJS = _ref.fromJS; | ||
var fromJS = _ref.fromJS, | ||
setIn = _ref.setIn; | ||
return function () { | ||
@@ -100,3 +101,3 @@ it('should remove from beginning', function () { | ||
it('should remove sync error from beginning', function () { | ||
var state = reducer(fromJS({ | ||
var state = reducer(setIn(fromJS({ | ||
foo: { | ||
@@ -112,11 +113,10 @@ values: { | ||
} | ||
}, | ||
syncErrors: { | ||
myField: { | ||
subField: ['error 0', 'error 1', 'error 2', 'error 3'] | ||
} | ||
} | ||
} | ||
}), 'foo.syncErrors', { | ||
myField: { | ||
subField: ['error 0', 'error 1', 'error 2', 'error 3'] | ||
} | ||
}), arrayRemove('foo', 'myField.subField', 0)); | ||
expect(state).toEqualMap({ | ||
expect(state).toEqualMap(setIn(fromJS({ | ||
foo: { | ||
@@ -132,14 +132,13 @@ values: { | ||
} | ||
}, | ||
syncErrors: { | ||
myField: { | ||
subField: ['error 1', 'error 2', 'error 3'] | ||
} | ||
} | ||
} | ||
}); | ||
}), 'foo.syncErrors', { | ||
myField: { | ||
subField: ['error 1', 'error 2', 'error 3'] | ||
} | ||
})); | ||
}); | ||
it('should remove sync error from end', function () { | ||
var state = reducer(fromJS({ | ||
var state = reducer(setIn(fromJS({ | ||
foo: { | ||
@@ -155,11 +154,10 @@ values: { | ||
} | ||
}, | ||
syncErrors: { | ||
myField: { | ||
subField: ['error 0', 'error 1', 'error 2', 'error 3'] | ||
} | ||
} | ||
} | ||
}), 'foo.syncErrors', { | ||
myField: { | ||
subField: ['error 0', 'error 1', 'error 2', 'error 3'] | ||
} | ||
}), arrayRemove('foo', 'myField.subField', 3)); | ||
expect(state).toEqualMap({ | ||
expect(state).toEqualMap(setIn(fromJS({ | ||
foo: { | ||
@@ -175,14 +173,13 @@ values: { | ||
} | ||
}, | ||
syncErrors: { | ||
myField: { | ||
subField: ['error 0', 'error 1', 'error 2'] | ||
} | ||
} | ||
} | ||
}); | ||
}), 'foo.syncErrors', { | ||
myField: { | ||
subField: ['error 0', 'error 1', 'error 2'] | ||
} | ||
})); | ||
}); | ||
it('should remove sync error from middle', function () { | ||
var state = reducer(fromJS({ | ||
var state = reducer(setIn(fromJS({ | ||
foo: { | ||
@@ -198,11 +195,10 @@ values: { | ||
} | ||
}, | ||
syncErrors: { | ||
myField: { | ||
subField: ['error 0', 'error 1', 'error 2', 'error 3'] | ||
} | ||
} | ||
} | ||
}), 'foo.syncErrors', { | ||
myField: { | ||
subField: ['error 0', 'error 1', 'error 2', 'error 3'] | ||
} | ||
}), arrayRemove('foo', 'myField.subField', 1)); | ||
expect(state).toEqualMap({ | ||
expect(state).toEqualMap(setIn(fromJS({ | ||
foo: { | ||
@@ -218,11 +214,11 @@ values: { | ||
} | ||
}, | ||
syncErrors: { | ||
myField: { | ||
subField: ['error 0', 'error 2', 'error 3'] | ||
} | ||
} | ||
} | ||
}); | ||
}), 'foo.syncErrors', { | ||
myField: { | ||
subField: ['error 0', 'error 2', 'error 3'] | ||
} | ||
})); | ||
}); | ||
it('should remove async error from beginning', function () { | ||
@@ -229,0 +225,0 @@ var state = reducer(fromJS({ |
@@ -83,3 +83,3 @@ import { updateSyncErrors } from '../actions'; | ||
it('should clear sync errors', function () { | ||
var state = reducer(fromJS({ | ||
var state = reducer(setIn(fromJS({ | ||
foo: { | ||
@@ -89,8 +89,7 @@ values: { | ||
myOtherField: 'otherValue' | ||
}, | ||
syncErrors: { | ||
myField: 'myField error', | ||
myOtherField: 'myOtherField error' | ||
} | ||
} | ||
}), 'foo.syncErrors', { | ||
myField: 'myField error', | ||
myOtherField: 'myOtherField error' | ||
}), updateSyncErrors('foo', {})); | ||
@@ -97,0 +96,0 @@ expect(state).toEqualMap({ |
@@ -18,2 +18,3 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
import { dataKey } from './util/eventConsts'; | ||
import plain from './structure/plain'; | ||
@@ -29,3 +30,3 @@ var propsToNotUpdateFor = ['_reduxForm']; | ||
var getSyncError = function getSyncError(syncErrors, name) { | ||
var error = getIn(syncErrors, name); | ||
var error = plain.getIn(syncErrors, name); | ||
// Because the error for this field might not be at a level in the error structure where | ||
@@ -32,0 +33,0 @@ // it can be set directly, it might need to be unwrapped from the _error property |
@@ -18,2 +18,3 @@ import _mapValues from 'lodash-es/mapValues'; | ||
import plain from './structure/plain'; | ||
@@ -32,3 +33,3 @@ var propsToNotUpdateFor = ['_reduxForm', 'value']; | ||
// one in Field. | ||
return getIn(syncErrors, name + '._error'); | ||
return plain.getIn(syncErrors, name + '._error'); | ||
}; | ||
@@ -35,0 +36,0 @@ |
@@ -29,6 +29,5 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
var getSyncError = function getSyncError(syncErrors, name) { | ||
var error = getIn(syncErrors, name); | ||
// Because the error for this field might not be at a level in the error structure where | ||
// it can be set directly, it might need to be unwrapped from the _error property | ||
return error && error._error ? error._error : error; | ||
return plain.getIn(syncErrors, name + '._error') || plain.getIn(syncErrors, name); | ||
}; | ||
@@ -35,0 +34,0 @@ |
@@ -16,3 +16,2 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
import createConnectedFieldArray from './ConnectedFieldArray'; | ||
import shallowCompare from './util/shallowCompare'; | ||
import prefixName from './util/prefixName'; | ||
@@ -59,7 +58,2 @@ | ||
_createClass(FieldArray, [{ | ||
key: 'shouldComponentUpdate', | ||
value: function shouldComponentUpdate(nextProps, nextState) { | ||
return shallowCompare(this, nextProps, nextState); | ||
} | ||
}, { | ||
key: 'componentWillMount', | ||
@@ -136,4 +130,4 @@ value: function componentWillMount() { | ||
props: PropTypes.object, | ||
validate: PropTypes.func, | ||
warn: PropTypes.func, | ||
validate: PropTypes.oneOfType([PropTypes.func, PropTypes.arrayOf(PropTypes.func)]), | ||
warn: PropTypes.oneOfType([PropTypes.func, PropTypes.arrayOf(PropTypes.func)]), | ||
withRef: PropTypes.bool | ||
@@ -140,0 +134,0 @@ }; |
@@ -20,2 +20,3 @@ import createAll from './createAll'; | ||
change = _createAll.change, | ||
clearSubmitErrors = _createAll.clearSubmitErrors, | ||
destroy = _createAll.destroy, | ||
@@ -61,2 +62,2 @@ Field = _createAll.Field, | ||
values = _createAll.values; | ||
export { actionTypes, arrayInsert, arrayMove, arrayPop, arrayPush, arrayRemove, arrayRemoveAll, arrayShift, arraySplice, arraySwap, arrayUnshift, autofill, blur, change, destroy, Field, Fields, FieldArray, Form, FormSection, focus, formValueSelector, getFormNames, getFormValues, getFormInitialValues, getFormSyncErrors, getFormAsyncErrors, getFormSyncWarnings, getFormSubmitErrors, initialize, isDirty, isInvalid, isPristine, isValid, isSubmitting, hasSubmitSucceeded, hasSubmitFailed, propTypes, reducer, reduxForm, registerField, reset, setSubmitFailed, setSubmitSucceeded, startAsyncValidation, startSubmit, stopAsyncValidation, stopSubmit, submit, SubmissionError, touch, unregisterField, untouch, values }; | ||
export { actionTypes, arrayInsert, arrayMove, arrayPop, arrayPush, arrayRemove, arrayRemoveAll, arrayShift, arraySplice, arraySwap, arrayUnshift, autofill, blur, change, clearSubmitErrors, destroy, Field, Fields, FieldArray, Form, FormSection, focus, formValueSelector, getFormNames, getFormValues, getFormInitialValues, getFormSyncErrors, getFormAsyncErrors, getFormSyncWarnings, getFormSubmitErrors, initialize, isDirty, isInvalid, isPristine, isValid, isSubmitting, hasSubmitSucceeded, hasSubmitFailed, propTypes, reducer, reduxForm, registerField, reset, setSubmitFailed, setSubmitSucceeded, startAsyncValidation, startSubmit, stopAsyncValidation, stopSubmit, submit, SubmissionError, touch, unregisterField, untouch, values }; |
@@ -20,2 +20,3 @@ import createAll from './createAll'; | ||
change = _createAll.change, | ||
clearSubmitErrors = _createAll.clearSubmitErrors, | ||
destroy = _createAll.destroy, | ||
@@ -61,2 +62,2 @@ Field = _createAll.Field, | ||
values = _createAll.values; | ||
export { actionTypes, arrayInsert, arrayMove, arrayPop, arrayPush, arrayRemove, arrayRemoveAll, arrayShift, arraySplice, arraySwap, arrayUnshift, autofill, blur, change, destroy, Field, Fields, FieldArray, Form, FormSection, focus, formValueSelector, getFormNames, getFormValues, getFormInitialValues, getFormSyncErrors, getFormAsyncErrors, getFormSyncWarnings, getFormSubmitErrors, initialize, isDirty, isInvalid, isPristine, isValid, isSubmitting, hasSubmitSucceeded, hasSubmitFailed, propTypes, reducer, reduxForm, registerField, reset, setSubmitFailed, setSubmitSucceeded, startAsyncValidation, startSubmit, stopAsyncValidation, stopSubmit, submit, SubmissionError, touch, unregisterField, untouch, values }; | ||
export { actionTypes, arrayInsert, arrayMove, arrayPop, arrayPush, arrayRemove, arrayRemoveAll, arrayShift, arraySplice, arraySwap, arrayUnshift, autofill, blur, change, clearSubmitErrors, destroy, Field, Fields, FieldArray, Form, FormSection, focus, formValueSelector, getFormNames, getFormValues, getFormInitialValues, getFormSyncErrors, getFormAsyncErrors, getFormSyncWarnings, getFormSubmitErrors, initialize, isDirty, isInvalid, isPristine, isValid, isSubmitting, hasSubmitSucceeded, hasSubmitFailed, propTypes, reducer, reduxForm, registerField, reset, setSubmitFailed, setSubmitSucceeded, startAsyncValidation, startSubmit, stopAsyncValidation, stopSubmit, submit, SubmissionError, touch, unregisterField, untouch, values }; |
@@ -7,2 +7,3 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
import createDeleteInWithCleanUp from './deleteInWithCleanUp'; | ||
import plain from './structure/plain'; | ||
@@ -27,2 +28,7 @@ var createReducer = function createReducer(structure) { | ||
}; | ||
var doPlainSplice = function doPlainSplice(state, key, field, index, removeNum, value, force) { | ||
var slice = getIn(state, key); | ||
var existing = plain.getIn(slice, field); | ||
return existing || force ? setIn(state, key, plain.setIn(slice, field, plain.splice(existing, index, removeNum, value))) : state; | ||
}; | ||
var rootKeys = ['values', 'fields', 'submitErrors', 'asyncErrors']; | ||
@@ -34,3 +40,4 @@ var arraySplice = function arraySplice(state, field, index, removeNum, value) { | ||
result = doSplice(result, 'fields', field, index, removeNum, nonValuesValue); | ||
result = doSplice(result, 'syncErrors', field, index, removeNum, undefined); | ||
result = doPlainSplice(result, 'syncErrors', field, index, removeNum, undefined); | ||
result = doPlainSplice(result, 'syncWarnings', field, index, removeNum, undefined); | ||
result = doSplice(result, 'submitErrors', field, index, removeNum, undefined); | ||
@@ -37,0 +44,0 @@ result = doSplice(result, 'asyncErrors', field, index, removeNum, undefined); |
@@ -13,2 +13,3 @@ import _toPath from 'lodash-es/toPath'; | ||
var structure = { | ||
allowsArrayErrors: false, | ||
empty: Map(), | ||
@@ -15,0 +16,0 @@ emptyList: emptyList, |
@@ -9,2 +9,3 @@ import splice from './splice'; | ||
var structure = { | ||
allowsArrayErrors: true, | ||
empty: {}, | ||
@@ -11,0 +12,0 @@ emptyList: [], |
@@ -454,2 +454,59 @@ 'use strict'; | ||
}); | ||
it('should concatenate prefixes when nested', function () { | ||
var store = makeStore({ | ||
testForm: { | ||
values: { | ||
deep: { | ||
foo: { | ||
bar: '42' | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
var input = (0, _expect.createSpy)(function (props) { | ||
return _react2.default.createElement('input', props.input); | ||
}).andCallThrough(); | ||
var Form = function (_Component6) { | ||
_inherits(Form, _Component6); | ||
function Form() { | ||
_classCallCheck(this, Form); | ||
return _possibleConstructorReturn(this, (Form.__proto__ || Object.getPrototypeOf(Form)).apply(this, arguments)); | ||
} | ||
_createClass(Form, [{ | ||
key: 'render', | ||
value: function render() { | ||
return _react2.default.createElement( | ||
_FormSection2.default, | ||
{ name: 'deep' }, | ||
_react2.default.createElement( | ||
_FormSection2.default, | ||
{ name: 'foo' }, | ||
_react2.default.createElement(Field, { name: 'bar', component: input }) | ||
) | ||
); | ||
} | ||
}]); | ||
return Form; | ||
}(_react.Component); | ||
var TestForm = reduxForm({ form: 'testForm' })(Form); | ||
_reactAddonsTestUtils2.default.renderIntoDocument(_react2.default.createElement( | ||
_reactRedux.Provider, | ||
{ store: store }, | ||
_react2.default.createElement(TestForm, null) | ||
)); | ||
// input gets the correct name and value | ||
expect(input).toHaveBeenCalled(); | ||
expect(input.calls.length).toBe(1); | ||
expect(input.calls[0].arguments[0].input.value).toBe('42'); | ||
expect(input.calls[0].arguments[0].input.name).toBe('deep.foo.bar'); | ||
}); | ||
}); | ||
@@ -456,0 +513,0 @@ }; |
@@ -64,2 +64,5 @@ 'use strict'; | ||
}); | ||
it('should export clearSubmitErrors', function () { | ||
(0, _expect2.default)(_immutable.clearSubmitErrors).toExist().toBeA('function'); | ||
}); | ||
it('should export destroy', function () { | ||
@@ -66,0 +69,0 @@ (0, _expect2.default)(_immutable.destroy).toExist().toBeA('function'); |
@@ -64,2 +64,5 @@ 'use strict'; | ||
}); | ||
it('should export clearSubmitErrors', function () { | ||
(0, _expect2.default)(_index.clearSubmitErrors).toExist().toBeA('function'); | ||
}); | ||
it('should export destroy', function () { | ||
@@ -66,0 +69,0 @@ (0, _expect2.default)(_index.destroy).toExist().toBeA('function'); |
@@ -10,3 +10,4 @@ 'use strict'; | ||
var describeArrayRemove = function describeArrayRemove(reducer, expect, _ref) { | ||
var fromJS = _ref.fromJS; | ||
var fromJS = _ref.fromJS, | ||
setIn = _ref.setIn; | ||
return function () { | ||
@@ -107,3 +108,3 @@ it('should remove from beginning', function () { | ||
it('should remove sync error from beginning', function () { | ||
var state = reducer(fromJS({ | ||
var state = reducer(setIn(fromJS({ | ||
foo: { | ||
@@ -119,11 +120,10 @@ values: { | ||
} | ||
}, | ||
syncErrors: { | ||
myField: { | ||
subField: ['error 0', 'error 1', 'error 2', 'error 3'] | ||
} | ||
} | ||
} | ||
}), 'foo.syncErrors', { | ||
myField: { | ||
subField: ['error 0', 'error 1', 'error 2', 'error 3'] | ||
} | ||
}), (0, _actions.arrayRemove)('foo', 'myField.subField', 0)); | ||
expect(state).toEqualMap({ | ||
expect(state).toEqualMap(setIn(fromJS({ | ||
foo: { | ||
@@ -139,14 +139,13 @@ values: { | ||
} | ||
}, | ||
syncErrors: { | ||
myField: { | ||
subField: ['error 1', 'error 2', 'error 3'] | ||
} | ||
} | ||
} | ||
}); | ||
}), 'foo.syncErrors', { | ||
myField: { | ||
subField: ['error 1', 'error 2', 'error 3'] | ||
} | ||
})); | ||
}); | ||
it('should remove sync error from end', function () { | ||
var state = reducer(fromJS({ | ||
var state = reducer(setIn(fromJS({ | ||
foo: { | ||
@@ -162,11 +161,10 @@ values: { | ||
} | ||
}, | ||
syncErrors: { | ||
myField: { | ||
subField: ['error 0', 'error 1', 'error 2', 'error 3'] | ||
} | ||
} | ||
} | ||
}), 'foo.syncErrors', { | ||
myField: { | ||
subField: ['error 0', 'error 1', 'error 2', 'error 3'] | ||
} | ||
}), (0, _actions.arrayRemove)('foo', 'myField.subField', 3)); | ||
expect(state).toEqualMap({ | ||
expect(state).toEqualMap(setIn(fromJS({ | ||
foo: { | ||
@@ -182,14 +180,13 @@ values: { | ||
} | ||
}, | ||
syncErrors: { | ||
myField: { | ||
subField: ['error 0', 'error 1', 'error 2'] | ||
} | ||
} | ||
} | ||
}); | ||
}), 'foo.syncErrors', { | ||
myField: { | ||
subField: ['error 0', 'error 1', 'error 2'] | ||
} | ||
})); | ||
}); | ||
it('should remove sync error from middle', function () { | ||
var state = reducer(fromJS({ | ||
var state = reducer(setIn(fromJS({ | ||
foo: { | ||
@@ -205,11 +202,10 @@ values: { | ||
} | ||
}, | ||
syncErrors: { | ||
myField: { | ||
subField: ['error 0', 'error 1', 'error 2', 'error 3'] | ||
} | ||
} | ||
} | ||
}), 'foo.syncErrors', { | ||
myField: { | ||
subField: ['error 0', 'error 1', 'error 2', 'error 3'] | ||
} | ||
}), (0, _actions.arrayRemove)('foo', 'myField.subField', 1)); | ||
expect(state).toEqualMap({ | ||
expect(state).toEqualMap(setIn(fromJS({ | ||
foo: { | ||
@@ -225,11 +221,11 @@ values: { | ||
} | ||
}, | ||
syncErrors: { | ||
myField: { | ||
subField: ['error 0', 'error 2', 'error 3'] | ||
} | ||
} | ||
} | ||
}); | ||
}), 'foo.syncErrors', { | ||
myField: { | ||
subField: ['error 0', 'error 2', 'error 3'] | ||
} | ||
})); | ||
}); | ||
it('should remove async error from beginning', function () { | ||
@@ -236,0 +232,0 @@ var state = reducer(fromJS({ |
@@ -89,3 +89,3 @@ 'use strict'; | ||
it('should clear sync errors', function () { | ||
var state = reducer(fromJS({ | ||
var state = reducer(setIn(fromJS({ | ||
foo: { | ||
@@ -95,8 +95,7 @@ values: { | ||
myOtherField: 'otherValue' | ||
}, | ||
syncErrors: { | ||
myField: 'myField error', | ||
myOtherField: 'myOtherField error' | ||
} | ||
} | ||
}), 'foo.syncErrors', { | ||
myField: 'myField error', | ||
myOtherField: 'myOtherField error' | ||
}), (0, _actions.updateSyncErrors)('foo', {})); | ||
@@ -103,0 +102,0 @@ expect(state).toEqualMap({ |
@@ -25,2 +25,6 @@ 'use strict'; | ||
var _plain = require('./structure/plain'); | ||
var _plain2 = _interopRequireDefault(_plain); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -45,3 +49,3 @@ | ||
var getSyncError = function getSyncError(syncErrors, name) { | ||
var error = getIn(syncErrors, name); | ||
var error = _plain2.default.getIn(syncErrors, name); | ||
// Because the error for this field might not be at a level in the error structure where | ||
@@ -48,0 +52,0 @@ // it can be set directly, it might need to be unwrapped from the _error property |
@@ -23,2 +23,6 @@ 'use strict'; | ||
var _plain = require('./structure/plain'); | ||
var _plain2 = _interopRequireDefault(_plain); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -46,3 +50,3 @@ | ||
// one in Field. | ||
return getIn(syncErrors, name + '._error'); | ||
return _plain2.default.getIn(syncErrors, name + '._error'); | ||
}; | ||
@@ -49,0 +53,0 @@ |
@@ -47,6 +47,5 @@ 'use strict'; | ||
var getSyncError = function getSyncError(syncErrors, name) { | ||
var error = getIn(syncErrors, name); | ||
// Because the error for this field might not be at a level in the error structure where | ||
// it can be set directly, it might need to be unwrapped from the _error property | ||
return error && error._error ? error._error : error; | ||
return _plain2.default.getIn(syncErrors, name + '._error') || _plain2.default.getIn(syncErrors, name); | ||
}; | ||
@@ -53,0 +52,0 @@ |
@@ -21,6 +21,2 @@ 'use strict'; | ||
var _shallowCompare = require('./util/shallowCompare'); | ||
var _shallowCompare2 = _interopRequireDefault(_shallowCompare); | ||
var _prefixName = require('./util/prefixName'); | ||
@@ -79,7 +75,2 @@ | ||
_createClass(FieldArray, [{ | ||
key: 'shouldComponentUpdate', | ||
value: function shouldComponentUpdate(nextProps, nextState) { | ||
return (0, _shallowCompare2.default)(this, nextProps, nextState); | ||
} | ||
}, { | ||
key: 'componentWillMount', | ||
@@ -156,4 +147,4 @@ value: function componentWillMount() { | ||
props: _react.PropTypes.object, | ||
validate: _react.PropTypes.func, | ||
warn: _react.PropTypes.func, | ||
validate: _react.PropTypes.oneOfType([_react.PropTypes.func, _react.PropTypes.arrayOf(_react.PropTypes.func)]), | ||
warn: _react.PropTypes.oneOfType([_react.PropTypes.func, _react.PropTypes.arrayOf(_react.PropTypes.func)]), | ||
withRef: _react.PropTypes.bool | ||
@@ -160,0 +151,0 @@ }; |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.values = exports.untouch = exports.unregisterField = exports.touch = exports.SubmissionError = exports.submit = exports.stopSubmit = exports.stopAsyncValidation = exports.startSubmit = exports.startAsyncValidation = exports.setSubmitSucceeded = exports.setSubmitFailed = exports.reset = exports.registerField = exports.reduxForm = exports.reducer = exports.propTypes = exports.hasSubmitFailed = exports.hasSubmitSucceeded = exports.isSubmitting = exports.isValid = exports.isPristine = exports.isInvalid = exports.isDirty = exports.initialize = exports.getFormSubmitErrors = exports.getFormSyncWarnings = exports.getFormAsyncErrors = exports.getFormSyncErrors = exports.getFormInitialValues = exports.getFormValues = exports.getFormNames = exports.formValueSelector = exports.focus = exports.FormSection = exports.Form = exports.FieldArray = exports.Fields = exports.Field = exports.destroy = exports.change = exports.blur = exports.autofill = exports.arrayUnshift = exports.arraySwap = exports.arraySplice = exports.arrayShift = exports.arrayRemoveAll = exports.arrayRemove = exports.arrayPush = exports.arrayPop = exports.arrayMove = exports.arrayInsert = exports.actionTypes = undefined; | ||
exports.values = exports.untouch = exports.unregisterField = exports.touch = exports.SubmissionError = exports.submit = exports.stopSubmit = exports.stopAsyncValidation = exports.startSubmit = exports.startAsyncValidation = exports.setSubmitSucceeded = exports.setSubmitFailed = exports.reset = exports.registerField = exports.reduxForm = exports.reducer = exports.propTypes = exports.hasSubmitFailed = exports.hasSubmitSucceeded = exports.isSubmitting = exports.isValid = exports.isPristine = exports.isInvalid = exports.isDirty = exports.initialize = exports.getFormSubmitErrors = exports.getFormSyncWarnings = exports.getFormAsyncErrors = exports.getFormSyncErrors = exports.getFormInitialValues = exports.getFormValues = exports.getFormNames = exports.formValueSelector = exports.focus = exports.FormSection = exports.Form = exports.FieldArray = exports.Fields = exports.Field = exports.destroy = exports.clearSubmitErrors = exports.change = exports.blur = exports.autofill = exports.arrayUnshift = exports.arraySwap = exports.arraySplice = exports.arrayShift = exports.arrayRemoveAll = exports.arrayRemove = exports.arrayPush = exports.arrayPop = exports.arrayMove = exports.arrayInsert = exports.actionTypes = undefined; | ||
@@ -35,2 +35,3 @@ var _createAll2 = require('./createAll'); | ||
change = _createAll.change, | ||
clearSubmitErrors = _createAll.clearSubmitErrors, | ||
destroy = _createAll.destroy, | ||
@@ -90,2 +91,3 @@ Field = _createAll.Field, | ||
exports.change = change; | ||
exports.clearSubmitErrors = clearSubmitErrors; | ||
exports.destroy = destroy; | ||
@@ -92,0 +94,0 @@ exports.Field = Field; |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.values = exports.untouch = exports.unregisterField = exports.touch = exports.SubmissionError = exports.submit = exports.stopSubmit = exports.stopAsyncValidation = exports.startSubmit = exports.startAsyncValidation = exports.setSubmitSucceeded = exports.setSubmitFailed = exports.reset = exports.registerField = exports.reduxForm = exports.reducer = exports.propTypes = exports.hasSubmitFailed = exports.hasSubmitSucceeded = exports.isSubmitting = exports.isValid = exports.isPristine = exports.isInvalid = exports.isDirty = exports.initialize = exports.getFormSubmitErrors = exports.getFormSyncWarnings = exports.getFormAsyncErrors = exports.getFormSyncErrors = exports.getFormInitialValues = exports.getFormValues = exports.getFormNames = exports.formValueSelector = exports.focus = exports.FormSection = exports.Form = exports.FieldArray = exports.Fields = exports.Field = exports.destroy = exports.change = exports.blur = exports.autofill = exports.arrayUnshift = exports.arraySwap = exports.arraySplice = exports.arrayShift = exports.arrayRemoveAll = exports.arrayRemove = exports.arrayPush = exports.arrayPop = exports.arrayMove = exports.arrayInsert = exports.actionTypes = undefined; | ||
exports.values = exports.untouch = exports.unregisterField = exports.touch = exports.SubmissionError = exports.submit = exports.stopSubmit = exports.stopAsyncValidation = exports.startSubmit = exports.startAsyncValidation = exports.setSubmitSucceeded = exports.setSubmitFailed = exports.reset = exports.registerField = exports.reduxForm = exports.reducer = exports.propTypes = exports.hasSubmitFailed = exports.hasSubmitSucceeded = exports.isSubmitting = exports.isValid = exports.isPristine = exports.isInvalid = exports.isDirty = exports.initialize = exports.getFormSubmitErrors = exports.getFormSyncWarnings = exports.getFormAsyncErrors = exports.getFormSyncErrors = exports.getFormInitialValues = exports.getFormValues = exports.getFormNames = exports.formValueSelector = exports.focus = exports.FormSection = exports.Form = exports.FieldArray = exports.Fields = exports.Field = exports.destroy = exports.clearSubmitErrors = exports.change = exports.blur = exports.autofill = exports.arrayUnshift = exports.arraySwap = exports.arraySplice = exports.arrayShift = exports.arrayRemoveAll = exports.arrayRemove = exports.arrayPush = exports.arrayPop = exports.arrayMove = exports.arrayInsert = exports.actionTypes = undefined; | ||
@@ -35,2 +35,3 @@ var _createAll2 = require('./createAll'); | ||
change = _createAll.change, | ||
clearSubmitErrors = _createAll.clearSubmitErrors, | ||
destroy = _createAll.destroy, | ||
@@ -90,2 +91,3 @@ Field = _createAll.Field, | ||
exports.change = change; | ||
exports.clearSubmitErrors = clearSubmitErrors; | ||
exports.destroy = destroy; | ||
@@ -92,0 +94,0 @@ exports.Field = Field; |
@@ -13,2 +13,6 @@ 'use strict'; | ||
var _plain = require('./structure/plain'); | ||
var _plain2 = _interopRequireDefault(_plain); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -38,2 +42,7 @@ | ||
}; | ||
var doPlainSplice = function doPlainSplice(state, key, field, index, removeNum, value, force) { | ||
var slice = getIn(state, key); | ||
var existing = _plain2.default.getIn(slice, field); | ||
return existing || force ? setIn(state, key, _plain2.default.setIn(slice, field, _plain2.default.splice(existing, index, removeNum, value))) : state; | ||
}; | ||
var rootKeys = ['values', 'fields', 'submitErrors', 'asyncErrors']; | ||
@@ -45,3 +54,4 @@ var arraySplice = function arraySplice(state, field, index, removeNum, value) { | ||
result = doSplice(result, 'fields', field, index, removeNum, nonValuesValue); | ||
result = doSplice(result, 'syncErrors', field, index, removeNum, undefined); | ||
result = doPlainSplice(result, 'syncErrors', field, index, removeNum, undefined); | ||
result = doPlainSplice(result, 'syncWarnings', field, index, removeNum, undefined); | ||
result = doSplice(result, 'submitErrors', field, index, removeNum, undefined); | ||
@@ -48,0 +58,0 @@ result = doSplice(result, 'asyncErrors', field, index, removeNum, undefined); |
@@ -38,2 +38,3 @@ 'use strict'; | ||
var structure = { | ||
allowsArrayErrors: false, | ||
empty: (0, _immutable.Map)(), | ||
@@ -40,0 +41,0 @@ emptyList: emptyList, |
@@ -34,2 +34,3 @@ 'use strict'; | ||
var structure = { | ||
allowsArrayErrors: true, | ||
empty: {}, | ||
@@ -36,0 +37,0 @@ emptyList: [], |
{ | ||
"name": "redux-form", | ||
"version": "6.6.1", | ||
"version": "6.6.2", | ||
"description": "A higher order component decorator for forms using Redux and React", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -25,8 +25,8 @@ # redux-form | ||
* [Getting Started](https://redux-form.com/6.6.1/docs/GettingStarted.md/) | ||
* [Examples](https://redux-form.com/6.6.1/examples/) | ||
* [API](https://redux-form.com/6.6.1/docs/api/) | ||
* [FAQ](https://redux-form.com/6.6.1/docs/faq/) | ||
* [Getting Started](https://redux-form.com/6.6.2/docs/GettingStarted.md/) | ||
* [Examples](https://redux-form.com/6.6.2/examples/) | ||
* [API](https://redux-form.com/6.6.2/docs/api/) | ||
* [FAQ](https://redux-form.com/6.6.2/docs/faq/) | ||
* [Release Notes](https://github.com/erikras/redux-form/releases) | ||
* [Older Documentation](https://redux-form.com/6.6.1/docs/DocumentationVersions.md/) | ||
* [Older Documentation](https://redux-form.com/6.6.2/docs/DocumentationVersions.md/) | ||
@@ -33,0 +33,0 @@ ## Videos |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2376180
60172