Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

redux-form

Package Overview
Dependencies
Maintainers
1
Versions
236
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-form - npm Package Compare versions

Comparing version 6.1.0 to 6.1.1

es/selectors/__tests__/getFormSyncErrors.spec.js

2

es/__tests__/Field.spec.js

@@ -62,3 +62,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; };

var testProps = function testProps(state) {
var config = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

@@ -65,0 +65,0 @@ var store = makeStore({ testForm: state });

@@ -62,3 +62,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; };

var testProps = function testProps(state) {
var config = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

@@ -65,0 +65,0 @@ var store = makeStore({ testForm: state });

@@ -92,7 +92,9 @@ import _noop from 'lodash-es/noop';

var setSubmitSucceeded = createSpy();
var asyncValidate = createSpy().andReturn(Promise.reject());
var asyncValidate = createSpy().andReturn(Promise.resolve(values));
var props = { dispatch: dispatch, startSubmit: startSubmit, stopSubmit: stopSubmit, touch: touch, setSubmitFailed: setSubmitFailed, setSubmitSucceeded: setSubmitSucceeded, values: values };
return handleSubmit(submit, props, true, asyncValidate, ['foo', 'baz']).catch(function (result) {
expect(result).toBe(undefined);
return handleSubmit(submit, props, true, asyncValidate, ['foo', 'baz']).then(function () {
throw new Error('Expected to fail');
}).catch(function (result) {
expect(result).toBe(values);
expect(asyncValidate).toHaveBeenCalled().toHaveBeenCalledWith();

@@ -118,6 +120,8 @@ expect(submit).toNotHaveBeenCalled();

var setSubmitSucceeded = createSpy();
var asyncValidate = createSpy().andReturn(Promise.reject(values));
var asyncValidate = createSpy().andReturn(Promise.resolve(values));
var props = { dispatch: dispatch, onSubmitFail: onSubmitFail, startSubmit: startSubmit, stopSubmit: stopSubmit, touch: touch, setSubmitFailed: setSubmitFailed, setSubmitSucceeded: setSubmitSucceeded, values: values };
return handleSubmit(submit, props, true, asyncValidate, ['foo', 'baz']).catch(function (result) {
return handleSubmit(submit, props, true, asyncValidate, ['foo', 'baz']).then(function () {
throw new Error('Expected to fail');
}).catch(function (result) {
expect(result).toBe(values);

@@ -150,3 +154,5 @@ expect(asyncValidate).toHaveBeenCalled().toHaveBeenCalledWith();

return handleSubmit(submit, props, true, asyncValidate, ['foo', 'baz']).catch(function (result) {
return handleSubmit(submit, props, true, asyncValidate, ['foo', 'baz']).then(function () {
throw new Error('Expected to fail');
}).catch(function (result) {
expect(result).toBe(asyncErrors);

@@ -153,0 +159,0 @@ expect(asyncValidate).toHaveBeenCalled().toHaveBeenCalledWith();

@@ -24,4 +24,3 @@ import { updateSyncErrors } from '../actions';

myOtherField: 'otherValue'
},
syncValidateFailed: true
}
}

@@ -51,3 +50,3 @@ }), 'foo.syncErrors', {

},
syncValidateFailed: true,
syncError: true,
error: 'form wide error'

@@ -77,4 +76,3 @@ }

myOtherField: 'otherValue'
},
syncValidateFailed: true
}
}

@@ -94,3 +92,2 @@ }), 'foo.syncErrors', {

},
syncValidateFailed: true,
syncErrors: {

@@ -97,0 +94,0 @@ myField: 'myField error',

@@ -28,3 +28,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; };

var testProps = function testProps(state) {
var config = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

@@ -31,0 +31,0 @@ var store = makeStore({ testForm: state });

@@ -157,3 +157,3 @@ import { ARRAY_INSERT, ARRAY_MOVE, ARRAY_POP, ARRAY_PUSH, ARRAY_REMOVE, ARRAY_REMOVE_ALL, ARRAY_SHIFT, ARRAY_SPLICE, ARRAY_SWAP, ARRAY_UNSHIFT, AUTOFILL, BLUR, CHANGE, DESTROY, FOCUS, INITIALIZE, REGISTER_FIELD, RESET, SET_SUBMIT_FAILED, SET_SUBMIT_SUCCEEDED, START_ASYNC_VALIDATION, START_SUBMIT, STOP_ASYNC_VALIDATION, STOP_SUBMIT, TOUCH, UNREGISTER_FIELD, UNTOUCH, UPDATE_SYNC_ERRORS, UPDATE_SYNC_WARNINGS } from './actionTypes';

export var updateSyncErrors = function updateSyncErrors(form) {
var syncErrors = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var syncErrors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var error = arguments[2];

@@ -164,5 +164,5 @@ return { type: UPDATE_SYNC_ERRORS, meta: { form: form }, payload: { syncErrors: syncErrors, error: error } };

export var updateSyncWarnings = function updateSyncWarnings(form) {
var syncWarnings = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var syncWarnings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var warning = arguments[2];
return { type: UPDATE_SYNC_WARNINGS, meta: { form: form }, payload: { syncWarnings: syncWarnings, warning: warning } };
};

@@ -11,2 +11,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 createGetFormValues from './selectors/getFormValues';
import createGetFormSyncErrors from './selectors/getFormSyncErrors';
import createIsDirty from './selectors/isDirty';

@@ -31,2 +32,3 @@ import createIsInvalid from './selectors/isInvalid';

getFormValues: createGetFormValues(structure),
getFormSyncErrors: createGetFormSyncErrors(structure),
isDirty: createIsDirty(structure),

@@ -33,0 +35,0 @@ isInvalid: createIsInvalid(structure),

@@ -64,3 +64,3 @@ import _noop from 'lodash-es/noop';

var asyncValidate = arguments.length <= 3 || arguments[3] === undefined ? _noop : arguments[3];
var asyncValidate = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _noop;

@@ -67,0 +67,0 @@ var error = syncError || asyncError || submitError;

@@ -113,3 +113,3 @@ import _noop from 'lodash-es/noop';

}
}, true)).toBe(3.1415);
}, true)).toBe('3.1415');
expect(getValue({

@@ -122,3 +122,3 @@ preventDefault: _noop,

}
}, true)).toBe(2.71828);
}, true)).toBe('2.71828');
expect(getValue({

@@ -131,3 +131,3 @@ preventDefault: _noop,

}
}, false)).toBe(3);
}, false)).toBe('3');
expect(getValue({

@@ -140,3 +140,3 @@ preventDefault: _noop,

}
}, false)).toBe(3.1415);
}, false)).toBe('3.1415');

@@ -143,0 +143,0 @@ expect(getValue({

@@ -5,3 +5,3 @@ import getValue from './getValue';

var createOnBlur = function createOnBlur(blur) {
var _ref = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

@@ -8,0 +8,0 @@ var after = _ref.after;

@@ -5,3 +5,3 @@ import getValue from './getValue';

var createOnChange = function createOnChange(change) {
var _ref = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

@@ -8,0 +8,0 @@ var parse = _ref.parse;

@@ -40,5 +40,2 @@ import isEvent from './isEvent';

}
if (value !== '' && (type === 'number' || type === 'range')) {
return parseFloat(value);
}
return value;

@@ -45,0 +42,0 @@ }

@@ -7,5 +7,5 @@ import invariant from 'invariant';

return function (form) {
var getFormState = arguments.length <= 1 || arguments[1] === undefined ? function (state) {
var getFormState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (state) {
return getIn(state, 'form');
} : arguments[1];
};

@@ -12,0 +12,0 @@ invariant(form, 'Form value must be specified');

@@ -0,1 +1,3 @@

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }

@@ -22,3 +24,3 @@

// XXX: Always submitting when persistentSubmitErrors is enabled ignores sync errors.
// XXX: Always submitting when persistentSubmitErrors is enabled ignores sync errors.
// It would be better to check whether the form as any other errors except submit errors.

@@ -29,26 +31,9 @@ // This would either require changing the meaning of `valid` (maybe breaking change),

if (valid || persistentSubmitErrors) {
var doSubmit = function doSubmit() {
var result = void 0;
try {
result = submit(values, dispatch, props);
} catch (submitError) {
var error = submitError instanceof SubmissionError ? submitError.errors : undefined;
setSubmitFailed.apply(undefined, _toConsumableArray(fields));
if (onSubmitFail) {
onSubmitFail(error, dispatch);
}
return error;
}
if (isPromise(result)) {
startSubmit();
return result.then(function (submitResult) {
stopSubmit();
setSubmitSucceeded();
if (onSubmitSuccess) {
onSubmitSuccess(submitResult, dispatch);
}
return submitResult;
}, function (submitError) {
var _ret = function () {
var doSubmit = function doSubmit() {
var result = void 0;
try {
result = submit(values, dispatch, props);
} catch (submitError) {
var error = submitError instanceof SubmissionError ? submitError.errors : undefined;
stopSubmit(error);
setSubmitFailed.apply(undefined, _toConsumableArray(fields));

@@ -59,24 +44,54 @@ if (onSubmitFail) {

return error;
});
}
if (isPromise(result)) {
startSubmit();
return result.then(function (submitResult) {
stopSubmit();
setSubmitSucceeded();
if (onSubmitSuccess) {
onSubmitSuccess(submitResult, dispatch);
}
return submitResult;
}, function (submitError) {
var error = submitError instanceof SubmissionError ? submitError.errors : undefined;
stopSubmit(error);
setSubmitFailed.apply(undefined, _toConsumableArray(fields));
if (onSubmitFail) {
onSubmitFail(error, dispatch);
}
return error;
});
} else {
setSubmitSucceeded();
if (onSubmitSuccess) {
onSubmitSuccess(result, dispatch);
}
}
return result;
};
var asyncValidateResult = asyncValidate && asyncValidate();
if (asyncValidateResult) {
return {
v: asyncValidateResult.then(function (asyncErrors) {
if (asyncErrors) {
throw asyncErrors;
}
return doSubmit();
}).catch(function (asyncErrors) {
setSubmitFailed.apply(undefined, _toConsumableArray(fields));
if (onSubmitFail) {
onSubmitFail(asyncErrors, dispatch);
}
return Promise.reject(asyncErrors);
})
};
} else {
setSubmitSucceeded();
if (onSubmitSuccess) {
onSubmitSuccess(result, dispatch);
}
return {
v: doSubmit()
};
}
return result;
};
}();
var asyncValidateResult = asyncValidate && asyncValidate();
if (asyncValidateResult) {
return asyncValidateResult.then(doSubmit, function (asyncErrors) {
setSubmitFailed.apply(undefined, _toConsumableArray(fields));
if (onSubmitFail) {
onSubmitFail(asyncErrors, dispatch);
}
return Promise.reject(asyncErrors);
});
} else {
return doSubmit();
}
if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v;
} else {

@@ -83,0 +98,0 @@ setSubmitFailed.apply(undefined, _toConsumableArray(fields));

@@ -174,3 +174,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; }

result = deleteInWithCleanUp(result, 'fields.' + field + '.autofilled');
result = deleteInWithCleanUp(result, 'syncValidateFailed');
result = deleteInWithCleanUp(result, 'syncError');
if (touch) {

@@ -381,11 +381,8 @@ result = setIn(result, 'fields.' + field + '.touched', true);

var result = state;
if (error || Object.keys(syncErrors).length) {
result = setIn(result, 'syncValidateFailed', true);
} else {
result = deleteIn(result, 'syncValidateFailed');
}
if (error) {
result = setIn(result, 'error', error);
result = setIn(result, 'syncError', true);
} else {
result = deleteIn(result, 'error');
result = deleteIn(result, 'syncError');
}

@@ -418,3 +415,3 @@ if (Object.keys(syncErrors).length) {

var reducer = function reducer() {
var state = arguments.length <= 0 || arguments[0] === undefined ? empty : arguments[0];
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : empty;
var action = arguments[1];

@@ -428,4 +425,4 @@

return function () {
var state = arguments.length <= 0 || arguments[0] === undefined ? empty : arguments[0];
var action = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : empty;
var action = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

@@ -454,4 +451,4 @@ var form = action && action.meta && action.meta.form;

return decorate(function () {
var state = arguments.length <= 0 || arguments[0] === undefined ? empty : arguments[0];
var action = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : empty;
var action = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return Object.keys(reducers).reduce(function (accumulator, key) {

@@ -458,0 +455,0 @@ var previousState = getIn(accumulator, key);

@@ -7,3 +7,3 @@ import _mapValues from 'lodash-es/mapValues';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

@@ -10,0 +10,0 @@ 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; }

@@ -96,3 +96,3 @@ import createIsInvalid from '../isInvalid';

it('should return true when there is a syncValidateFailed', function () {
it('should return true when there is a syncError', function () {
expect(isInvalid('foo')(fromJS({

@@ -106,3 +106,3 @@ form: {

error: 'Bad Data',
syncValidateFailed: true,
syncError: true,
registeredFields: [{ name: 'dog', type: 'Field' }, { name: 'cat', type: 'Field' }]

@@ -109,0 +109,0 @@ }

@@ -96,3 +96,3 @@ import createIsValid from '../isValid';

it('should return false when there is a syncValidateFailed', function () {
it('should return false when there is a syncError', function () {
expect(isValid('foo')(fromJS({

@@ -106,3 +106,3 @@ form: {

error: 'Bad data',
syncValidateFailed: true,
syncError: true,
registeredFields: [{ name: 'dog', type: 'Field' }, { name: 'cat', type: 'Field' }]

@@ -109,0 +109,0 @@ }

var createGetFormValues = function createGetFormValues(_ref) {
var getIn = _ref.getIn;
return function (form) {
var getFormState = arguments.length <= 1 || arguments[1] === undefined ? function (state) {
var getFormState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (state) {
return getIn(state, 'form');
} : arguments[1];
};
return function (state) {

@@ -8,0 +8,0 @@ return getIn(getFormState(state), form + '.values');

@@ -6,5 +6,5 @@ var createIsPristine = function createIsPristine(_ref) {

return function (form) {
var getFormState = arguments.length <= 1 || arguments[1] === undefined ? function (state) {
var getFormState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (state) {
return getIn(state, 'form');
} : arguments[1];
};
return function (state) {

@@ -11,0 +11,0 @@ var formState = getFormState(state);

@@ -8,9 +8,9 @@ import createHasError from '../hasError';

return function (form) {
var getFormState = arguments.length <= 1 || arguments[1] === undefined ? function (state) {
var getFormState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (state) {
return getIn(state, 'form');
} : arguments[1];
};
return function (state) {
var formState = getFormState(state);
var syncValidateFailed = getIn(formState, form + '.syncValidateFailed');
if (syncValidateFailed) {
var syncError = getIn(formState, form + '.syncError');
if (syncError) {
return false;

@@ -17,0 +17,0 @@ }

@@ -99,3 +99,3 @@ 'use strict';

var testProps = function testProps(state) {
var config = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

@@ -102,0 +102,0 @@ var store = makeStore({ testForm: state });

@@ -99,3 +99,3 @@ 'use strict';

var testProps = function testProps(state) {
var config = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

@@ -102,0 +102,0 @@ var store = makeStore({ testForm: state });

@@ -106,7 +106,9 @@ 'use strict';

var setSubmitSucceeded = (0, _expect.createSpy)();
var asyncValidate = (0, _expect.createSpy)().andReturn(Promise.reject());
var asyncValidate = (0, _expect.createSpy)().andReturn(Promise.resolve(values));
var props = { dispatch: dispatch, startSubmit: startSubmit, stopSubmit: stopSubmit, touch: touch, setSubmitFailed: setSubmitFailed, setSubmitSucceeded: setSubmitSucceeded, values: values };
return (0, _handleSubmit2.default)(submit, props, true, asyncValidate, ['foo', 'baz']).catch(function (result) {
(0, _expect2.default)(result).toBe(undefined);
return (0, _handleSubmit2.default)(submit, props, true, asyncValidate, ['foo', 'baz']).then(function () {
throw new Error('Expected to fail');
}).catch(function (result) {
(0, _expect2.default)(result).toBe(values);
(0, _expect2.default)(asyncValidate).toHaveBeenCalled().toHaveBeenCalledWith();

@@ -132,6 +134,8 @@ (0, _expect2.default)(submit).toNotHaveBeenCalled();

var setSubmitSucceeded = (0, _expect.createSpy)();
var asyncValidate = (0, _expect.createSpy)().andReturn(Promise.reject(values));
var asyncValidate = (0, _expect.createSpy)().andReturn(Promise.resolve(values));
var props = { dispatch: dispatch, onSubmitFail: onSubmitFail, startSubmit: startSubmit, stopSubmit: stopSubmit, touch: touch, setSubmitFailed: setSubmitFailed, setSubmitSucceeded: setSubmitSucceeded, values: values };
return (0, _handleSubmit2.default)(submit, props, true, asyncValidate, ['foo', 'baz']).catch(function (result) {
return (0, _handleSubmit2.default)(submit, props, true, asyncValidate, ['foo', 'baz']).then(function () {
throw new Error('Expected to fail');
}).catch(function (result) {
(0, _expect2.default)(result).toBe(values);

@@ -164,3 +168,5 @@ (0, _expect2.default)(asyncValidate).toHaveBeenCalled().toHaveBeenCalledWith();

return (0, _handleSubmit2.default)(submit, props, true, asyncValidate, ['foo', 'baz']).catch(function (result) {
return (0, _handleSubmit2.default)(submit, props, true, asyncValidate, ['foo', 'baz']).then(function () {
throw new Error('Expected to fail');
}).catch(function (result) {
(0, _expect2.default)(result).toBe(asyncErrors);

@@ -167,0 +173,0 @@ (0, _expect2.default)(asyncValidate).toHaveBeenCalled().toHaveBeenCalledWith();

@@ -30,4 +30,3 @@ 'use strict';

myOtherField: 'otherValue'
},
syncValidateFailed: true
}
}

@@ -57,3 +56,3 @@ }), 'foo.syncErrors', {

},
syncValidateFailed: true,
syncError: true,
error: 'form wide error'

@@ -83,4 +82,3 @@ }

myOtherField: 'otherValue'
},
syncValidateFailed: true
}
}

@@ -100,3 +98,2 @@ }), 'foo.syncErrors', {

},
syncValidateFailed: true,
syncErrors: {

@@ -103,0 +100,0 @@ myField: 'myField error',

@@ -62,3 +62,3 @@ 'use strict';

var testProps = function testProps(state) {
var config = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

@@ -65,0 +65,0 @@ var store = makeStore({ testForm: state });

@@ -164,3 +164,3 @@ 'use strict';

var updateSyncErrors = exports.updateSyncErrors = function updateSyncErrors(form) {
var syncErrors = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var syncErrors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var error = arguments[2];

@@ -171,5 +171,5 @@ return { type: _actionTypes.UPDATE_SYNC_ERRORS, meta: { form: form }, payload: { syncErrors: syncErrors, error: error } };

var updateSyncWarnings = exports.updateSyncWarnings = function updateSyncWarnings(form) {
var syncWarnings = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var syncWarnings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var warning = arguments[2];
return { type: _actionTypes.UPDATE_SYNC_WARNINGS, meta: { form: form }, payload: { syncWarnings: syncWarnings, warning: warning } };
};

@@ -41,2 +41,6 @@ 'use strict';

var _getFormSyncErrors = require('./selectors/getFormSyncErrors');
var _getFormSyncErrors2 = _interopRequireDefault(_getFormSyncErrors);
var _isDirty = require('./selectors/isDirty');

@@ -88,2 +92,3 @@

getFormValues: (0, _getFormValues2.default)(structure),
getFormSyncErrors: (0, _getFormSyncErrors2.default)(structure),
isDirty: (0, _isDirty2.default)(structure),

@@ -90,0 +95,0 @@ isInvalid: (0, _isInvalid2.default)(structure),

@@ -87,3 +87,3 @@ 'use strict';

var asyncValidate = arguments.length <= 3 || arguments[3] === undefined ? _noop3.default : arguments[3];
var asyncValidate = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _noop3.default;

@@ -90,0 +90,0 @@ var error = syncError || asyncError || submitError;

@@ -124,3 +124,3 @@ 'use strict';

}
}, true)).toBe(3.1415);
}, true)).toBe('3.1415');
(0, _expect2.default)((0, _getValue2.default)({

@@ -133,3 +133,3 @@ preventDefault: _noop3.default,

}
}, true)).toBe(2.71828);
}, true)).toBe('2.71828');
(0, _expect2.default)((0, _getValue2.default)({

@@ -142,3 +142,3 @@ preventDefault: _noop3.default,

}
}, false)).toBe(3);
}, false)).toBe('3');
(0, _expect2.default)((0, _getValue2.default)({

@@ -151,3 +151,3 @@ preventDefault: _noop3.default,

}
}, false)).toBe(3.1415);
}, false)).toBe('3.1415');

@@ -154,0 +154,0 @@ (0, _expect2.default)((0, _getValue2.default)({

@@ -18,3 +18,3 @@ 'use strict';

var createOnBlur = function createOnBlur(blur) {
var _ref = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

@@ -21,0 +21,0 @@ var after = _ref.after;

@@ -18,3 +18,3 @@ 'use strict';

var createOnChange = function createOnChange(change) {
var _ref = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

@@ -21,0 +21,0 @@ var parse = _ref.parse;

@@ -50,5 +50,2 @@ 'use strict';

}
if (value !== '' && (type === 'number' || type === 'range')) {
return parseFloat(value);
}
return value;

@@ -55,0 +52,0 @@ }

@@ -20,5 +20,5 @@ 'use strict';

return function (form) {
var getFormState = arguments.length <= 1 || arguments[1] === undefined ? function (state) {
var getFormState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (state) {
return getIn(state, 'form');
} : arguments[1];
};

@@ -25,0 +25,0 @@ (0, _invariant2.default)(form, 'Form value must be specified');

@@ -7,2 +7,4 @@ 'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _isPromise = require('is-promise');

@@ -36,3 +38,3 @@

// XXX: Always submitting when persistentSubmitErrors is enabled ignores sync errors.
// XXX: Always submitting when persistentSubmitErrors is enabled ignores sync errors.
// It would be better to check whether the form as any other errors except submit errors.

@@ -43,26 +45,9 @@ // This would either require changing the meaning of `valid` (maybe breaking change),

if (valid || persistentSubmitErrors) {
var doSubmit = function doSubmit() {
var result = void 0;
try {
result = submit(values, dispatch, props);
} catch (submitError) {
var error = submitError instanceof _SubmissionError2.default ? submitError.errors : undefined;
setSubmitFailed.apply(undefined, _toConsumableArray(fields));
if (onSubmitFail) {
onSubmitFail(error, dispatch);
}
return error;
}
if ((0, _isPromise2.default)(result)) {
startSubmit();
return result.then(function (submitResult) {
stopSubmit();
setSubmitSucceeded();
if (onSubmitSuccess) {
onSubmitSuccess(submitResult, dispatch);
}
return submitResult;
}, function (submitError) {
var _ret = function () {
var doSubmit = function doSubmit() {
var result = void 0;
try {
result = submit(values, dispatch, props);
} catch (submitError) {
var error = submitError instanceof _SubmissionError2.default ? submitError.errors : undefined;
stopSubmit(error);
setSubmitFailed.apply(undefined, _toConsumableArray(fields));

@@ -73,24 +58,54 @@ if (onSubmitFail) {

return error;
});
}
if ((0, _isPromise2.default)(result)) {
startSubmit();
return result.then(function (submitResult) {
stopSubmit();
setSubmitSucceeded();
if (onSubmitSuccess) {
onSubmitSuccess(submitResult, dispatch);
}
return submitResult;
}, function (submitError) {
var error = submitError instanceof _SubmissionError2.default ? submitError.errors : undefined;
stopSubmit(error);
setSubmitFailed.apply(undefined, _toConsumableArray(fields));
if (onSubmitFail) {
onSubmitFail(error, dispatch);
}
return error;
});
} else {
setSubmitSucceeded();
if (onSubmitSuccess) {
onSubmitSuccess(result, dispatch);
}
}
return result;
};
var asyncValidateResult = asyncValidate && asyncValidate();
if (asyncValidateResult) {
return {
v: asyncValidateResult.then(function (asyncErrors) {
if (asyncErrors) {
throw asyncErrors;
}
return doSubmit();
}).catch(function (asyncErrors) {
setSubmitFailed.apply(undefined, _toConsumableArray(fields));
if (onSubmitFail) {
onSubmitFail(asyncErrors, dispatch);
}
return Promise.reject(asyncErrors);
})
};
} else {
setSubmitSucceeded();
if (onSubmitSuccess) {
onSubmitSuccess(result, dispatch);
}
return {
v: doSubmit()
};
}
return result;
};
}();
var asyncValidateResult = asyncValidate && asyncValidate();
if (asyncValidateResult) {
return asyncValidateResult.then(doSubmit, function (asyncErrors) {
setSubmitFailed.apply(undefined, _toConsumableArray(fields));
if (onSubmitFail) {
onSubmitFail(asyncErrors, dispatch);
}
return Promise.reject(asyncErrors);
});
} else {
return doSubmit();
}
if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v;
} else {

@@ -97,0 +112,0 @@ setSubmitFailed.apply(undefined, _toConsumableArray(fields));

@@ -186,3 +186,3 @@ 'use strict';

result = deleteInWithCleanUp(result, 'fields.' + field + '.autofilled');
result = deleteInWithCleanUp(result, 'syncValidateFailed');
result = deleteInWithCleanUp(result, 'syncError');
if (touch) {

@@ -393,11 +393,8 @@ result = setIn(result, 'fields.' + field + '.touched', true);

var result = state;
if (error || Object.keys(syncErrors).length) {
result = setIn(result, 'syncValidateFailed', true);
} else {
result = deleteIn(result, 'syncValidateFailed');
}
if (error) {
result = setIn(result, 'error', error);
result = setIn(result, 'syncError', true);
} else {
result = deleteIn(result, 'error');
result = deleteIn(result, 'syncError');
}

@@ -430,3 +427,3 @@ if (Object.keys(syncErrors).length) {

var reducer = function reducer() {
var state = arguments.length <= 0 || arguments[0] === undefined ? empty : arguments[0];
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : empty;
var action = arguments[1];

@@ -440,4 +437,4 @@

return function () {
var state = arguments.length <= 0 || arguments[0] === undefined ? empty : arguments[0];
var action = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : empty;
var action = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

@@ -466,4 +463,4 @@ var form = action && action.meta && action.meta.form;

return decorate(function () {
var state = arguments.length <= 0 || arguments[0] === undefined ? empty : arguments[0];
var action = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : empty;
var action = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return Object.keys(reducers).reduce(function (accumulator, key) {

@@ -470,0 +467,0 @@ var previousState = getIn(accumulator, key);

@@ -15,3 +15,3 @@ 'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

@@ -18,0 +18,0 @@ var _react = require('react');

@@ -117,3 +117,3 @@ 'use strict';

it('should return true when there is a syncValidateFailed', function () {
it('should return true when there is a syncError', function () {
expect(isInvalid('foo')(fromJS({

@@ -127,3 +127,3 @@ form: {

error: 'Bad Data',
syncValidateFailed: true,
syncError: true,
registeredFields: [{ name: 'dog', type: 'Field' }, { name: 'cat', type: 'Field' }]

@@ -130,0 +130,0 @@ }

@@ -117,3 +117,3 @@ 'use strict';

it('should return false when there is a syncValidateFailed', function () {
it('should return false when there is a syncError', function () {
expect(isValid('foo')(fromJS({

@@ -127,3 +127,3 @@ form: {

error: 'Bad data',
syncValidateFailed: true,
syncError: true,
registeredFields: [{ name: 'dog', type: 'Field' }, { name: 'cat', type: 'Field' }]

@@ -130,0 +130,0 @@ }

@@ -9,5 +9,5 @@ 'use strict';

return function (form) {
var getFormState = arguments.length <= 1 || arguments[1] === undefined ? function (state) {
var getFormState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (state) {
return getIn(state, 'form');
} : arguments[1];
};
return function (state) {

@@ -14,0 +14,0 @@ return getIn(getFormState(state), form + '.values');

@@ -11,5 +11,5 @@ 'use strict';

return function (form) {
var getFormState = arguments.length <= 1 || arguments[1] === undefined ? function (state) {
var getFormState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (state) {
return getIn(state, 'form');
} : arguments[1];
};
return function (state) {

@@ -16,0 +16,0 @@ var formState = getFormState(state);

@@ -18,9 +18,9 @@ 'use strict';

return function (form) {
var getFormState = arguments.length <= 1 || arguments[1] === undefined ? function (state) {
var getFormState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (state) {
return getIn(state, 'form');
} : arguments[1];
};
return function (state) {
var formState = getFormState(state);
var syncValidateFailed = getIn(formState, form + '.syncValidateFailed');
if (syncValidateFailed) {
var syncError = getIn(formState, form + '.syncError');
if (syncError) {
return false;

@@ -27,0 +27,0 @@ }

{
"name": "redux-form",
"version": "6.1.0",
"version": "6.1.1",
"description": "A higher order component decorator for forms using Redux and React",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -23,8 +23,8 @@ # redux-form

* [Getting Started](https://redux-form.com/6.1.0/docs/GettingStarted.md/)
* [Examples](https://redux-form.com/6.1.0/examples/)
* [API](https://redux-form.com/6.1.0/docs/api/)
* [FAQ](https://redux-form.com/6.1.0/docs/faq/)
* [Getting Started](https://redux-form.com/6.1.1/docs/GettingStarted.md/)
* [Examples](https://redux-form.com/6.1.1/examples/)
* [API](https://redux-form.com/6.1.1/docs/api/)
* [FAQ](https://redux-form.com/6.1.1/docs/faq/)
* [Release Notes](https://github.com/erikras/redux-form/releases)
* [Older Documentation](https://redux-form.com/6.1.0/docs/DocumentationVersions.md/)
* [Older Documentation](https://redux-form.com/6.1.1/docs/DocumentationVersions.md/)

@@ -31,0 +31,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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc