From 57f77738a0267e48c199a823e121d60f640f9f96 Mon Sep 17 00:00:00 2001
From: Felix Mosheev <9304194+felixmosh@users.noreply.github.com>
Date: Tue, 8 Nov 2022 23:30:08 +0200
Subject: [PATCH] v2.3.0
---
CHANGELOG.md | 6 +
dist/formsy-react.cjs.development.js | 378 ++++++--------------
dist/formsy-react.cjs.development.js.map | 2 +-
dist/formsy-react.cjs.production.min.js | 2 +-
dist/formsy-react.cjs.production.min.js.map | 2 +-
dist/formsy-react.esm.js | 378 ++++++--------------
dist/formsy-react.esm.js.map | 2 +-
package.json | 2 +-
8 files changed, 243 insertions(+), 529 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 14aa0dcf..44656cf7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,8 +4,14 @@ All notable changes to this project will be documented in this file. Dates are d
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
+#### [v2.3.0](https://github.com/formsy/formsy-react/compare/v2.2.8...v2.3.0)
+
+- Add support for React 18 [`#692`](https://github.com/formsy/formsy-react/pull/692)
+
#### [v2.2.8](https://github.com/formsy/formsy-react/compare/v2.2.7...v2.2.8)
+> 8 November 2022
+
- Migrate to react testing lib instead of enzyme [`#679`](https://github.com/formsy/formsy-react/pull/679)
- Bump deps [`7056b3e`](https://github.com/formsy/formsy-react/commit/7056b3eca1bc8df759f05f88a75f5ff681dc2596)
- refactor: Move rules tests to rules folder [`33d2f88`](https://github.com/formsy/formsy-react/commit/33d2f8888b211672bfa762a2e804d651683903a6)
diff --git a/dist/formsy-react.cjs.development.js b/dist/formsy-react.cjs.development.js
index e0931ac5..e563c066 100644
--- a/dist/formsy-react.cjs.development.js
+++ b/dist/formsy-react.cjs.development.js
@@ -9,49 +9,47 @@ var PropTypes = _interopDefault(require('prop-types'));
var React = _interopDefault(require('react'));
function _extends() {
- _extends = Object.assign || function (target) {
+ _extends = Object.assign ? Object.assign.bind() : 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;
};
-
return _extends.apply(this, arguments);
}
-
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
- subClass.__proto__ = superClass;
+ _setPrototypeOf(subClass, superClass);
+}
+function _setPrototypeOf(o, p) {
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
+ o.__proto__ = p;
+ return o;
+ };
+ return _setPrototypeOf(o, p);
}
-
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
-
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
-
return target;
}
-
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
-
return self;
}
@@ -88,7 +86,8 @@ function isValueNullOrUndefined(value) {
function isValueUndefined(value) {
return value === undefined;
}
-function noop() {// do nothing.
+function noop() {
+ // do nothing.
}
function protectAgainstParamReassignment(value) {
// Clone objects to avoid accidental param reassignment
@@ -100,39 +99,31 @@ function isSame(a, b) {
if (typeof a !== typeof b) {
return false;
}
-
if (isArray(a) && isArray(b)) {
if (a.length !== b.length) {
return false;
}
-
return a.every(function (item, index) {
return isSame(item, b[index]);
});
}
-
if (isFunction(a) && isFunction(b)) {
return a.toString() === b.toString();
}
-
if (isDate(a) && isDate(b)) {
return a.toString() === b.toString();
}
-
if (isObject(a) && isObject(b)) {
if (Object.keys(a).length !== Object.keys(b).length) {
return false;
}
-
return Object.keys(a).every(function (key) {
return isSame(a[key], b[key]);
});
}
-
if (isRegex(a) && isRegex(b)) {
return a.toString() === b.toString();
}
-
return a === b;
}
function runRules(value, currentValues, validations, validationRules) {
@@ -144,7 +135,6 @@ function runRules(value, currentValues, validations, validationRules) {
Object.keys(validations).forEach(function (validationName) {
var validationsVal = validations[validationName];
var validationRulesVal = validationRules[validationName];
-
var addToResults = function addToResults(validation) {
if (isString(validation)) {
results.errors.push(validation);
@@ -155,19 +145,15 @@ function runRules(value, currentValues, validations, validationRules) {
results.success.push(validationName);
}
};
-
if (validationRulesVal && isFunction(validationsVal)) {
throw new Error("Formsy does not allow you to override default validations: " + validationName);
}
-
if (!validationRulesVal && !isFunction(validationsVal)) {
throw new Error("Formsy does not have the validation rule: " + validationName);
}
-
if (isFunction(validationsVal)) {
return addToResults(validationsVal(currentValues, value));
}
-
return addToResults(validationRulesVal(currentValues, value, validationsVal));
});
return results;
@@ -177,11 +163,9 @@ function throttle(callback, interval) {
return function () {
if (!enableCall) return;
enableCall = false;
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
-
callback.apply(this, args);
setTimeout(function () {
return enableCall = true;
@@ -196,14 +180,11 @@ function isEmpty(value) {
if (isString(value)) {
return isValueStringEmpty(value);
}
-
if (isTypeUndefined(value)) {
return false;
}
-
return isValueUndefined(value);
}
-
function _isDefaultRequiredValue(value) {
return isString(value) ? isValueStringEmpty(value) : isValueNullOrUndefined(value);
}
@@ -289,12 +270,10 @@ var addValidationRule = function addValidationRule(name, func) {
};
var noFormsyErrorMessage = 'Could not find Formsy Context Provider. Did you use withFormsy outside ?';
-
var throwNoFormsyProvider = function throwNoFormsyProvider() {
// istanbul ignore next
throw new Error(noFormsyErrorMessage);
};
-
var defaultValue = {
attachToForm: throwNoFormsyProvider,
detachFromForm: throwNoFormsyProvider,
@@ -306,7 +285,6 @@ var defaultValue = {
var FormsyContext = /*#__PURE__*/React.createContext(defaultValue);
/* eslint-disable react/default-props-match-prop-types */
-
var convertValidationsToObject = function convertValidationsToObject(validations) {
if (isString(validations)) {
return validations.split(/,(?![^{[]*[}\]])/g).reduce(function (validationsAccumulator, validation) {
@@ -322,19 +300,15 @@ var convertValidationsToObject = function convertValidationsToObject(validations
if (args.length > 1) {
throw new Error('Formsy does not support multiple args on string validations. Use object format of validations instead.');
- } // Avoid parameter reassignment
-
-
+ }
+ // Avoid parameter reassignment
var validationsAccumulatorCopy = _extends({}, validationsAccumulator);
-
validationsAccumulatorCopy[validateMethod] = args.length ? args[0] : true;
return validationsAccumulatorCopy;
}, {});
}
-
return validations || {};
};
-
var propTypes = {
innerRef: PropTypes.func,
name: PropTypes.string.isRequired,
@@ -342,58 +316,44 @@ var propTypes = {
validations: /*#__PURE__*/PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
value: PropTypes.any
};
-
function getDisplayName(component) {
return component.displayName || component.name || (isString(component) ? component : 'Component');
}
-
function withFormsy(WrappedComponent) {
var WithFormsyWrapper = /*#__PURE__*/function (_React$Component) {
_inheritsLoose(WithFormsyWrapper, _React$Component);
-
function WithFormsyWrapper(props) {
var _this;
-
_this = _React$Component.call(this, props) || this;
-
_this.getErrorMessage = function () {
var messages = _this.getErrorMessages();
-
return messages.length ? messages[0] : null;
};
-
_this.getErrorMessages = function () {
var validationError = _this.state.validationError;
-
if (!_this.isValid() || _this.showRequired()) {
return validationError || [];
}
-
return [];
- }; // eslint-disable-next-line react/destructuring-assignment
-
-
+ };
+ // eslint-disable-next-line react/destructuring-assignment
_this.getValue = function () {
return _this.state.value;
};
-
_this.setValidations = function (validations, required) {
// Add validations to the store itself as the props object can not be modified
_this.validations = convertValidationsToObject(validations) || {};
_this.requiredValidations = required === true ? {
isDefaultRequiredValue: required
} : convertValidationsToObject(required);
- }; // By default, we validate after the value has been set.
+ };
+ // By default, we validate after the value has been set.
// A user can override this and pass a second parameter of `false` to skip validation.
-
-
_this.setValue = function (value, validate) {
if (validate === void 0) {
validate = true;
}
-
var validateForm = _this.props.validate;
-
if (!validate) {
_this.setState({
value: value
@@ -406,48 +366,39 @@ function withFormsy(WrappedComponent) {
validateForm(_assertThisInitialized(_this));
});
}
- }; // eslint-disable-next-line react/destructuring-assignment
-
-
+ };
+ // eslint-disable-next-line react/destructuring-assignment
_this.hasValue = function () {
var value = _this.state.value;
return _isDefaultRequiredValue(value);
- }; // eslint-disable-next-line react/destructuring-assignment
-
-
+ };
+ // eslint-disable-next-line react/destructuring-assignment
_this.isFormDisabled = function () {
return _this.props.isFormDisabled;
- }; // eslint-disable-next-line react/destructuring-assignment
-
-
+ };
+ // eslint-disable-next-line react/destructuring-assignment
_this.isFormSubmitted = function () {
return _this.state.formSubmitted;
- }; // eslint-disable-next-line react/destructuring-assignment
-
-
+ };
+ // eslint-disable-next-line react/destructuring-assignment
_this.isPristine = function () {
return _this.state.isPristine;
- }; // eslint-disable-next-line react/destructuring-assignment
-
-
+ };
+ // eslint-disable-next-line react/destructuring-assignment
_this.isRequired = function () {
return !!_this.props.required;
- }; // eslint-disable-next-line react/destructuring-assignment
-
-
+ };
+ // eslint-disable-next-line react/destructuring-assignment
_this.isValid = function () {
return _this.state.isValid;
- }; // eslint-disable-next-line react/destructuring-assignment
-
-
+ };
+ // eslint-disable-next-line react/destructuring-assignment
_this.isValidValue = function (value) {
return _this.props.isValidValue(_assertThisInitialized(_this), value);
};
-
_this.resetValue = function () {
var pristineValue = _this.state.pristineValue;
var validate = _this.props.validate;
-
_this.setState({
value: pristineValue,
isPristine: true
@@ -455,26 +406,21 @@ function withFormsy(WrappedComponent) {
validate(_assertThisInitialized(_this));
});
};
-
_this.showError = function () {
return !_this.showRequired() && !_this.isValid();
- }; // eslint-disable-next-line react/destructuring-assignment
-
-
+ };
+ // eslint-disable-next-line react/destructuring-assignment
_this.showRequired = function () {
return _this.state.isRequired;
};
-
var runValidation = props.runValidation,
- validations = props.validations,
- required = props.required,
- value = props.value;
+ validations = props.validations,
+ required = props.required,
+ value = props.value;
_this.state = {
value: value
};
-
_this.setValidations(validations, required);
-
_this.state = _extends({
formSubmitted: false,
isPristine: true,
@@ -483,64 +429,53 @@ function withFormsy(WrappedComponent) {
}, runValidation(_assertThisInitialized(_this), props.value));
return _this;
}
-
var _proto = WithFormsyWrapper.prototype;
-
_proto.componentDidMount = function componentDidMount() {
var _this$props = this.props,
- name = _this$props.name,
- attachToForm = _this$props.attachToForm;
-
+ name = _this$props.name,
+ attachToForm = _this$props.attachToForm;
if (!name) {
throw new Error('Form Input requires a name property when used');
}
-
attachToForm(this);
};
-
_proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) {
var props = this.props,
- state = this.state;
-
+ state = this.state;
var isChanged = function isChanged(a, b) {
return Object.keys(a).some(function (k) {
return a[k] !== b[k];
});
};
-
var isPropsChanged = isChanged(props, nextProps);
var isStateChanged = isChanged(state, nextState);
return isPropsChanged || isStateChanged;
};
-
_proto.componentDidUpdate = function componentDidUpdate(prevProps) {
var _this$props2 = this.props,
- value = _this$props2.value,
- validations = _this$props2.validations,
- required = _this$props2.required,
- validate = _this$props2.validate; // If the value passed has changed, set it. If value is not passed it will
+ value = _this$props2.value,
+ validations = _this$props2.validations,
+ required = _this$props2.required,
+ validate = _this$props2.validate;
+ // If the value passed has changed, set it. If value is not passed it will
// internally update, and this will never run
-
if (!isSame(value, prevProps.value)) {
this.setValue(value);
- } // If validations or required is changed, run a new validation
-
-
+ }
+ // If validations or required is changed, run a new validation
if (!isSame(validations, prevProps.validations) || !isSame(required, prevProps.required)) {
this.setValidations(validations, required);
validate(this);
}
- } // Detach it when component unmounts
+ }
+ // Detach it when component unmounts
;
-
_proto.componentWillUnmount = function componentWillUnmount() {
var detachFromForm = this.props.detachFromForm;
detachFromForm(this);
};
-
_proto.render = function render() {
var innerRef = this.props.innerRef;
-
var propsForElement = _extends({}, this.props, {
errorMessage: this.getErrorMessage(),
errorMessages: this.getErrorMessages(),
@@ -558,17 +493,13 @@ function withFormsy(WrappedComponent) {
showRequired: this.showRequired(),
value: this.getValue()
});
-
if (innerRef) {
propsForElement.ref = innerRef;
}
-
return React.createElement(WrappedComponent, propsForElement);
};
-
return WithFormsyWrapper;
}(React.Component);
-
WithFormsyWrapper.displayName = "Formsy(" + getDisplayName(WrappedComponent) + ")";
WithFormsyWrapper.propTypes = propTypes;
WithFormsyWrapper.defaultProps = {
@@ -578,8 +509,8 @@ function withFormsy(WrappedComponent) {
validationErrors: {},
validations: null,
value: WrappedComponent.defaultValue
- }; // eslint-disable-next-line react/display-name
-
+ };
+ // eslint-disable-next-line react/display-name
return function (props) {
return React.createElement(FormsyContext.Consumer, null, function (contextValue) {
return React.createElement(WithFormsyWrapper, _extends({}, props, contextValue));
@@ -587,44 +518,35 @@ function withFormsy(WrappedComponent) {
};
}
+var _excluded = ["children", "mapping", "onChange", "onInvalid", "onInvalidSubmit", "onReset", "onSubmit", "onValid", "onValidSubmit", "preventDefaultSubmit", "preventExternalInvalidation", "validationErrors", "disabled", "formElement"];
var ONE_RENDER_FRAME = 66;
var Formsy = /*#__PURE__*/function (_React$Component) {
_inheritsLoose(Formsy, _React$Component);
-
function Formsy(props) {
var _this;
-
_this = _React$Component.call(this, props) || this;
_this.prevInputNames = null;
-
_this.componentDidMount = function () {
_this.prevInputNames = _this.inputs.map(function (component) {
return component.props.name;
});
-
_this.validateForm();
};
-
_this.componentDidUpdate = function (prevProps) {
var _this$props = _this.props,
- validationErrors = _this$props.validationErrors,
- disabled = _this$props.disabled;
-
+ validationErrors = _this$props.validationErrors,
+ disabled = _this$props.disabled;
if (validationErrors && isObject(validationErrors) && Object.keys(validationErrors).length > 0) {
_this.setInputValidationErrors(validationErrors);
}
-
var newInputNames = _this.inputs.map(function (component) {
return component.props.name;
});
-
if (_this.prevInputNames && !isSame(_this.prevInputNames, newInputNames)) {
_this.prevInputNames = newInputNames;
-
_this.validateForm();
- } // Keep the disabled value in state/context the same as from props
-
-
+ }
+ // Keep the disabled value in state/context the same as from props
if (disabled !== prevProps.disabled) {
// eslint-disable-next-line
_this.setState(function (state) {
@@ -636,41 +558,35 @@ var Formsy = /*#__PURE__*/function (_React$Component) {
});
}
};
-
_this.getCurrentValues = function () {
return _this.inputs.reduce(function (valueAccumulator, component) {
var name = component.props.name,
- value = component.state.value; // eslint-disable-next-line no-param-reassign
-
+ value = component.state.value;
+ // eslint-disable-next-line no-param-reassign
valueAccumulator[name] = protectAgainstParamReassignment(value);
return valueAccumulator;
}, {});
};
-
_this.getModel = function () {
var currentValues = _this.getCurrentValues();
-
return _this.mapModel(currentValues);
};
-
_this.getPristineValues = function () {
return _this.inputs.reduce(function (valueAccumulator, component) {
var _component$props = component.props,
- name = _component$props.name,
- value = _component$props.value; // eslint-disable-next-line no-param-reassign
-
+ name = _component$props.name,
+ value = _component$props.value;
+ // eslint-disable-next-line no-param-reassign
valueAccumulator[name] = protectAgainstParamReassignment(value);
return valueAccumulator;
}, {});
};
-
_this.setFormPristine = function (isPristine) {
_this.setState({
formSubmitted: !isPristine
- }); // Iterate through each component and set it as pristine
+ });
+ // Iterate through each component and set it as pristine
// or "dirty".
-
-
_this.inputs.forEach(function (component) {
component.setState({
formSubmitted: !isPristine,
@@ -678,11 +594,9 @@ var Formsy = /*#__PURE__*/function (_React$Component) {
});
});
};
-
_this.setInputValidationErrors = function (errors) {
var preventExternalInvalidation = _this.props.preventExternalInvalidation;
var isValid = _this.state.isValid;
-
_this.inputs.forEach(function (component) {
var name = component.props.name;
component.setState({
@@ -690,97 +604,76 @@ var Formsy = /*#__PURE__*/function (_React$Component) {
validationError: isString(errors[name]) ? [errors[name]] : errors[name]
});
});
-
if (!preventExternalInvalidation && isValid) {
_this.setFormValidState(false);
}
};
-
_this.setFormValidState = function (allIsValid) {
var _this$props2 = _this.props,
- onValid = _this$props2.onValid,
- onInvalid = _this$props2.onInvalid;
-
+ onValid = _this$props2.onValid,
+ onInvalid = _this$props2.onInvalid;
_this.setState({
isValid: allIsValid
});
-
if (allIsValid) {
onValid();
} else {
onInvalid();
}
};
-
_this.isValidValue = function (component, value) {
return _this.runValidation(component, value).isValid;
- }; // eslint-disable-next-line react/destructuring-assignment
-
-
+ };
+ // eslint-disable-next-line react/destructuring-assignment
_this.isFormDisabled = function () {
return _this.props.disabled;
};
-
_this.mapModel = function (model) {
var mapping = _this.props.mapping;
-
if (mapping) {
return mapping(model);
}
-
var returnModel = {};
Object.keys(model).forEach(function (key) {
lodash.set(returnModel, key, model[key]);
});
return returnModel;
};
-
_this.reset = function (model) {
_this.setFormPristine(true);
-
_this.resetModel(model);
};
-
_this.resetInternal = function (event) {
var onReset = _this.props.onReset;
event.preventDefault();
-
_this.reset();
-
if (onReset) {
onReset();
}
- }; // Reset each key in the model to the original / initial / specified value
-
-
+ };
+ // Reset each key in the model to the original / initial / specified value
_this.resetModel = function (data) {
_this.inputs.forEach(function (component) {
var name = component.props.name;
-
if (data && lodash.has(data, name)) {
component.setValue(lodash.get(data, name));
} else {
component.resetValue();
}
});
-
_this.validateForm();
- }; // Checks validation on current value or a passed value
-
-
+ };
+ // Checks validation on current value or a passed value
_this.runValidation = function (component, value) {
if (value === void 0) {
value = component.state.value;
}
-
var validationErrors = _this.props.validationErrors;
var _component$props2 = component.props,
- validationError = _component$props2.validationError,
- componentValidationErrors = _component$props2.validationErrors,
- name = _component$props2.name;
-
+ validationError = _component$props2.validationError,
+ componentValidationErrors = _component$props2.validationErrors,
+ name = _component$props2.name;
var currentValues = _this.getCurrentValues();
-
var validationResults = runRules(value, currentValues, component.validations, validations);
var requiredResults = runRules(value, currentValues, component.requiredValidations, validations);
var isRequired = Object.keys(component.requiredValidations).length ? !!requiredResults.success.length : false;
@@ -792,159 +685,130 @@ var Formsy = /*#__PURE__*/function (_React$Component) {
if (isValid && !isRequired) {
return _this.emptyArray;
}
-
if (validationResults.errors.length) {
return validationResults.errors;
}
-
if (validationErrors && validationErrors[name]) {
return isString(validationErrors[name]) ? [validationErrors[name]] : validationErrors[name];
}
-
if (isRequired) {
var error = componentValidationErrors[requiredResults.success[0]] || validationError;
return error ? [error] : null;
}
-
if (validationResults.failed.length) {
return validationResults.failed.map(function (failed) {
return componentValidationErrors[failed] ? componentValidationErrors[failed] : validationError;
}).filter(function (x, pos, arr) {
return arr.indexOf(x) === pos;
}); // remove duplicates
- } // This line is not reachable
+ }
+ // This line is not reachable
// istanbul ignore next
-
-
return undefined;
}()
};
- }; // Method put on each input component to register
+ };
+ // Method put on each input component to register
// itself to the form
-
-
_this.attachToForm = function (component) {
if (_this.inputs.indexOf(component) === -1) {
_this.inputs.push(component);
}
-
var onChange = _this.props.onChange;
- var canChange = _this.state.canChange; // Trigger onChange
-
+ var canChange = _this.state.canChange;
+ // Trigger onChange
if (canChange) {
onChange(_this.getModel(), _this.isChanged());
- } // Will be triggered immediately & every one frame rate
-
-
+ }
+ // Will be triggered immediately & every one frame rate
_this.throttledValidateForm();
- }; // Method put on each input component to unregister
+ };
+ // Method put on each input component to unregister
// itself from the form
-
-
_this.detachFromForm = function (component) {
var componentPos = _this.inputs.indexOf(component);
-
if (componentPos !== -1) {
_this.inputs = _this.inputs.slice(0, componentPos).concat(_this.inputs.slice(componentPos + 1));
}
-
_this.validateForm();
- }; // Checks if the values have changed from their initial value
-
-
+ };
+ // Checks if the values have changed from their initial value
_this.isChanged = function () {
return !isSame(_this.getPristineValues(), _this.getCurrentValues());
- }; // Update model, submit to url prop and send the model
-
-
+ };
+ // Update model, submit to url prop and send the model
_this.submit = function (event) {
var _this$props3 = _this.props,
- onSubmit = _this$props3.onSubmit,
- onValidSubmit = _this$props3.onValidSubmit,
- onInvalidSubmit = _this$props3.onInvalidSubmit,
- preventDefaultSubmit = _this$props3.preventDefaultSubmit;
+ onSubmit = _this$props3.onSubmit,
+ onValidSubmit = _this$props3.onValidSubmit,
+ onInvalidSubmit = _this$props3.onInvalidSubmit,
+ preventDefaultSubmit = _this$props3.preventDefaultSubmit;
var isValid = _this.state.isValid;
-
if (preventDefaultSubmit && event && event.preventDefault) {
event.preventDefault();
- } // Trigger form as not pristine.
+ }
+ // Trigger form as not pristine.
// If any inputs have not been touched yet this will make them dirty
// so validation becomes visible (if based on isPristine)
-
-
_this.setFormPristine(false);
-
var model = _this.getModel();
-
onSubmit(model, _this.resetModel, _this.updateInputsWithError, event);
-
if (isValid) {
onValidSubmit(model, _this.resetModel, _this.updateInputsWithError, event);
} else {
onInvalidSubmit(model, _this.resetModel, _this.updateInputsWithError, event);
}
- }; // Go through errors from server and grab the components
+ };
+ // Go through errors from server and grab the components
// stored in the inputs map. Change their state to invalid
// and set the serverError message
-
-
_this.updateInputsWithError = function (errors, invalidate) {
var preventExternalInvalidation = _this.props.preventExternalInvalidation;
var isValid = _this.state.isValid;
Object.entries(errors).forEach(function (_ref) {
var name = _ref[0],
- error = _ref[1];
-
+ error = _ref[1];
var component = _this.inputs.find(function (input) {
return input.props.name === name;
});
-
if (!component) {
throw new Error("You are trying to update an input that does not exist. Verify errors object with input names. " + JSON.stringify(errors));
}
-
component.setState({
isValid: preventExternalInvalidation,
validationError: isString(error) ? [error] : error
});
});
-
if (invalidate && isValid) {
_this.setFormValidState(false);
}
- }; // Set the value of components
-
-
+ };
+ // Set the value of components
_this.updateInputsWithValue = function (data, validate) {
_this.inputs.forEach(function (component) {
var name = component.props.name;
-
if (data && lodash.has(data, name)) {
component.setValue(lodash.get(data, name), validate);
}
});
- }; // Use the binded values and the actual input value to
+ };
+ // Use the binded values and the actual input value to
// validate the input and set its state. Then check the
// state of the form itself
-
-
_this.validate = function (component) {
var onChange = _this.props.onChange;
- var canChange = _this.state.canChange; // Trigger onChange
-
+ var canChange = _this.state.canChange;
+ // Trigger onChange
if (canChange) {
onChange(_this.getModel(), _this.isChanged());
}
-
- var validationState = _this.runValidation(component); // Run through the validations, split them up and call
+ var validationState = _this.runValidation(component);
+ // Run through the validations, split them up and call
// the validator IF there is a value or it is required
-
-
component.setState(validationState, _this.validateForm);
- }; // Validate the form by going through all child input components
+ };
+ // Validate the form by going through all child input components
// and check their state
-
-
_this.validateForm = function () {
// We need a callback as we are validating all inputs again. This will
// run when the last component has set its state
@@ -952,34 +816,28 @@ var Formsy = /*#__PURE__*/function (_React$Component) {
var allIsValid = _this.inputs.every(function (component) {
return component.state.isValid;
});
-
- _this.setFormValidState(allIsValid); // Tell the form that it can start to trigger change events
-
-
+ _this.setFormValidState(allIsValid);
+ // Tell the form that it can start to trigger change events
_this.setState({
canChange: true
});
- }; // Run validation again in case affected by other inputs. The
+ };
+ // Run validation again in case affected by other inputs. The
// last component validated will run the onValidationComplete callback
-
-
_this.inputs.forEach(function (component, index) {
var validationState = _this.runValidation(component);
-
var isFinalInput = index === _this.inputs.length - 1;
var callback = isFinalInput ? onValidationComplete : null;
component.setState(validationState, callback);
- }); // If there are no inputs, set state where form is ready to trigger
+ });
+ // If there are no inputs, set state where form is ready to trigger
// change event. New inputs might be added later
-
-
if (!_this.inputs.length) {
_this.setState({
canChange: true
}, onValidationComplete);
}
};
-
_this.state = {
canChange: false,
isSubmitting: false,
@@ -998,16 +856,13 @@ var Formsy = /*#__PURE__*/function (_React$Component) {
_this.throttledValidateForm = throttle(_this.validateForm, ONE_RENDER_FRAME);
return _this;
}
-
var _proto = Formsy.prototype;
-
_proto.render = function render() {
var _this$props4 = this.props,
- children = _this$props4.children,
- disabled = _this$props4.disabled,
- formElement = _this$props4.formElement,
- nonFormsyProps = _objectWithoutPropertiesLoose(_this$props4, ["children", "mapping", "onChange", "onInvalid", "onInvalidSubmit", "onReset", "onSubmit", "onValid", "onValidSubmit", "preventDefaultSubmit", "preventExternalInvalidation", "validationErrors", "disabled", "formElement"]);
-
+ children = _this$props4.children,
+ disabled = _this$props4.disabled,
+ formElement = _this$props4.formElement,
+ nonFormsyProps = _objectWithoutPropertiesLoose(_this$props4, _excluded);
var contextValue = this.state.contextValue;
return React.createElement(FormsyContext.Provider, {
value: contextValue
@@ -1018,7 +873,6 @@ var Formsy = /*#__PURE__*/function (_React$Component) {
disabled: disabled
}), children));
};
-
return Formsy;
}(React.Component);
Formsy.displayName = 'Formsy';
diff --git a/dist/formsy-react.cjs.development.js.map b/dist/formsy-react.cjs.development.js.map
index 20948b2b..39cfd193 100644
--- a/dist/formsy-react.cjs.development.js.map
+++ b/dist/formsy-react.cjs.development.js.map
@@ -1 +1 @@
-{"version":3,"file":"formsy-react.cjs.development.js","sources":["../src/utils.ts","../src/validationRules.ts","../src/FormsyContext.ts","../src/withFormsy.ts","../src/Formsy.ts"],"sourcesContent":["import { isPlainObject } from 'lodash';\n\nimport { ValidationError, Validations, Values } from './interfaces';\n\nexport function isArray(value: unknown): value is unknown[] {\n return Array.isArray(value);\n}\n\nexport function isObject(value: unknown): value is object {\n return isPlainObject(value);\n}\n\nexport function isTypeUndefined(value: unknown): value is undefined {\n return typeof value === 'undefined';\n}\n\nexport function isDate(value: unknown): value is Date {\n return value instanceof Date;\n}\n\nexport function isFunction(value: unknown): value is Function {\n return value !== null && typeof value === 'function';\n}\n\nexport function isString(value: unknown): value is string {\n return typeof value === 'string';\n}\n\nexport function isNumber(value: unknown): value is number {\n return typeof value === 'number';\n}\n\nexport function isRegex(value: unknown): value is RegExp {\n return value instanceof RegExp;\n}\n\nexport function isValueStringEmpty(value: string): boolean {\n return value === '';\n}\n\nexport function isValueNullOrUndefined(value: unknown): boolean {\n return value === null || value === undefined;\n}\n\nexport function isValueUndefined(value: unknown): boolean {\n return value === undefined;\n}\n\nexport function noop() {\n // do nothing.\n}\n\nexport function protectAgainstParamReassignment(value: unknown) {\n // Clone objects to avoid accidental param reassignment\n if (isObject(value)) return { ...value };\n if (isArray(value)) return [...value];\n return value;\n}\n\nexport function isSame(a: unknown, b: unknown) {\n if (typeof a !== typeof b) {\n return false;\n }\n\n if (isArray(a) && isArray(b)) {\n if (a.length !== b.length) {\n return false;\n }\n\n return a.every((item, index) => isSame(item, b[index]));\n }\n\n if (isFunction(a) && isFunction(b)) {\n return a.toString() === b.toString();\n }\n\n if (isDate(a) && isDate(b)) {\n return a.toString() === b.toString();\n }\n\n if (isObject(a) && isObject(b)) {\n if (Object.keys(a).length !== Object.keys(b).length) {\n return false;\n }\n\n return Object.keys(a).every((key) => isSame(a[key], b[key]));\n }\n\n if (isRegex(a) && isRegex(b)) {\n return a.toString() === b.toString();\n }\n\n return a === b;\n}\n\ninterface RulesResult {\n errors: ValidationError[];\n failed: string[];\n success: string[];\n}\n\nexport function runRules(\n value: V,\n currentValues: Values,\n validations: Validations,\n validationRules: Validations,\n) {\n const results: RulesResult = {\n errors: [],\n failed: [],\n success: [],\n };\n\n Object.keys(validations).forEach((validationName) => {\n const validationsVal = validations[validationName];\n const validationRulesVal = validationRules[validationName];\n const addToResults = (validation) => {\n if (isString(validation)) {\n results.errors.push(validation);\n results.failed.push(validationName);\n } else if (!validation) {\n results.failed.push(validationName);\n } else {\n results.success.push(validationName);\n }\n };\n\n if (validationRulesVal && isFunction(validationsVal)) {\n throw new Error(`Formsy does not allow you to override default validations: ${validationName}`);\n }\n\n if (!validationRulesVal && !isFunction(validationsVal)) {\n throw new Error(`Formsy does not have the validation rule: ${validationName}`);\n }\n\n if (isFunction(validationsVal)) {\n return addToResults(validationsVal(currentValues, value));\n }\n\n return addToResults(validationRulesVal(currentValues, value, validationsVal));\n });\n\n return results;\n}\n\nexport function throttle(callback, interval) {\n let enableCall = true;\n\n return function (...args) {\n if (!enableCall) return;\n\n enableCall = false;\n callback.apply(this, args);\n setTimeout(() => (enableCall = true), interval);\n };\n}\n","import { ValidationFunction, Values } from './interfaces';\nimport {\n isNumber,\n isString,\n isTypeUndefined,\n isValueNullOrUndefined,\n isValueStringEmpty,\n isValueUndefined,\n} from './utils';\n\nexport function isExisty(value: V) {\n return !isValueNullOrUndefined(value);\n}\n\nexport function isEmpty(value: V) {\n if (isString(value)) {\n return isValueStringEmpty(value);\n }\n if (isTypeUndefined(value)) {\n return false;\n }\n return isValueUndefined(value);\n}\n\nexport function isDefaultRequiredValue(value: unknown) {\n return isString(value) ? isValueStringEmpty(value) : isValueNullOrUndefined(value);\n}\n\nexport function matchRegexp(_values: Values, value: V, regexp: RegExp) {\n return !isExisty(value) || isEmpty(value) || regexp.test(`${value}`);\n}\n\ninterface Validations {\n [key: string]: ValidationFunction;\n}\n\nconst REGEX_PATTERNS = {\n ALPHA: /^[A-Z]+$/i,\n ALPHANUMERIC: /^[0-9A-Z]+$/i,\n EMAIL:\n /^(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/i, // from http://emailregex.com/\n FLOAT: /^(?:[-+]?(?:\\d+))?(?:\\.\\d*)?(?:[eE][+-]?(?:\\d+))?$/,\n INT: /^(?:[-+]?(?:0|[1-9]\\d*))$/,\n NUMERIC: /^[-+]?(?:\\d*[.])?\\d+$/,\n SPECIAL_WORDS: /^[\\sA-ZÀ-ÖØ-öø-ÿ]+$/i,\n URL: /^(?:\\w+:)?\\/\\/([^\\s.]+\\.\\S{2}|localhost[:?\\d]*)\\S*$/i,\n WORDS: /^[A-Z\\s]+$/i,\n};\n\nconst validations: Validations = {\n equals: (_values, value: V, eql: V) => !isExisty(value) || isEmpty(value) || value === eql,\n equalsField: (values, value: V, field: string) => value === values[field],\n isAlpha: (values, value: V) => matchRegexp(values, value, REGEX_PATTERNS.ALPHA),\n isAlphanumeric: (values, value: V) => matchRegexp(values, value, REGEX_PATTERNS.ALPHANUMERIC),\n isDefaultRequiredValue: (_values, value: V) => isDefaultRequiredValue(value),\n isEmail: (values, value: string) => matchRegexp(values, value, REGEX_PATTERNS.EMAIL),\n isEmptyString: (_values, value: string) => isEmpty(value),\n isExisty: (_values, value: V) => isExisty(value),\n isFalse: (_values, value: boolean | string) => value === false,\n isFloat: (values, value: V) => matchRegexp(values, value, REGEX_PATTERNS.FLOAT),\n isInt: (values, value: V) => matchRegexp(values, value, REGEX_PATTERNS.INT),\n isLength: (_values, value: string, length: number) => !isExisty(value) || isEmpty(value) || value.length === length,\n isNumeric: (values, value: V) => isNumber(value) || matchRegexp(values, value, REGEX_PATTERNS.NUMERIC),\n isSpecialWords: (values, value: V) => matchRegexp(values, value, REGEX_PATTERNS.SPECIAL_WORDS),\n isTrue: (_values, value: boolean | string) => value === true,\n isUndefined: (_values, value: V) => isValueUndefined(value),\n isUrl: (values, value: V) => matchRegexp(values, value, REGEX_PATTERNS.URL),\n isWords: (values, value: V) => matchRegexp(values, value, REGEX_PATTERNS.WORDS),\n matchRegexp,\n maxLength: (_values, value: string, length: number) => !isExisty(value) || value.length <= length,\n minLength: (_values, value: string, length: number) => !isExisty(value) || isEmpty(value) || value.length >= length,\n};\n\nexport const addValidationRule = (name: string, func: ValidationFunction) => {\n validations[name] = func;\n};\n\nexport default validations;\n","import React from 'react';\nimport { FormsyContextInterface } from './interfaces';\n\nconst noFormsyErrorMessage = 'Could not find Formsy Context Provider. Did you use withFormsy outside ?';\n\nconst throwNoFormsyProvider = () => {\n // istanbul ignore next\n throw new Error(noFormsyErrorMessage);\n};\n\nconst defaultValue = {\n attachToForm: throwNoFormsyProvider,\n detachFromForm: throwNoFormsyProvider,\n isFormDisabled: true,\n isValidValue: throwNoFormsyProvider,\n validate: throwNoFormsyProvider,\n runValidation: throwNoFormsyProvider,\n};\n\nexport default React.createContext(defaultValue);\n","import PropTypes from 'prop-types';\nimport React from 'react';\nimport FormsyContext from './FormsyContext';\nimport {\n ComponentWithStaticAttributes,\n FormsyContextInterface,\n RequiredValidation,\n ValidationError,\n Validations,\n WrappedComponentClass,\n} from './interfaces';\n\nimport * as utils from './utils';\nimport { isString } from './utils';\nimport { isDefaultRequiredValue } from './validationRules';\n\n/* eslint-disable react/default-props-match-prop-types */\n\nconst convertValidationsToObject = (validations: false | Validations): Validations => {\n if (isString(validations)) {\n return validations.split(/,(?![^{[]*[}\\]])/g).reduce((validationsAccumulator, validation) => {\n let args: string[] = validation.split(':');\n const validateMethod: string = args.shift();\n\n args = args.map((arg) => {\n try {\n return JSON.parse(arg);\n } catch (e) {\n return arg; // It is a string if it can not parse it\n }\n });\n\n if (args.length > 1) {\n throw new Error(\n 'Formsy does not support multiple args on string validations. Use object format of validations instead.',\n );\n }\n\n // Avoid parameter reassignment\n const validationsAccumulatorCopy: Validations = { ...validationsAccumulator };\n validationsAccumulatorCopy[validateMethod] = args.length ? args[0] : true;\n return validationsAccumulatorCopy;\n }, {});\n }\n\n return validations || {};\n};\n\nexport const propTypes = {\n innerRef: PropTypes.func,\n name: PropTypes.string.isRequired,\n required: PropTypes.oneOfType([PropTypes.bool, PropTypes.object, PropTypes.string]),\n validations: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),\n value: PropTypes.any, // eslint-disable-line react/forbid-prop-types\n};\n\nexport interface WrapperProps {\n innerRef?: (ref: React.Ref) => void;\n name: string;\n required?: RequiredValidation;\n validationError?: ValidationError;\n validationErrors?: { [key: string]: ValidationError };\n validations?: Validations;\n value?: V;\n}\n\nexport interface WrapperState {\n [key: string]: unknown;\n\n formSubmitted: boolean;\n isPristine: boolean;\n isRequired: boolean;\n isValid: boolean;\n pristineValue: V;\n validationError: ValidationError[];\n value: V;\n}\n\nexport interface InjectedProps {\n errorMessage: ValidationError;\n errorMessages: ValidationError[];\n hasValue: boolean;\n isFormDisabled: boolean;\n isFormSubmitted: boolean;\n isPristine: boolean;\n isRequired: boolean;\n isValid: boolean;\n isValidValue: (value: V) => boolean;\n ref?: React.Ref;\n resetValue: () => void;\n setValidations: (validations: Validations, required: RequiredValidation) => void;\n setValue: (value: V, validate?: boolean) => void;\n showError: boolean;\n showRequired: boolean;\n}\n\nexport interface WrapperInstanceMethods {\n getErrorMessage: () => null | ValidationError;\n getErrorMessages: () => ValidationError[];\n getValue: () => V;\n isFormDisabled: () => boolean;\n isFormSubmitted: () => boolean;\n isValid: () => boolean;\n isValidValue: (value: V) => boolean;\n setValue: (value: V, validate?: boolean) => void;\n}\n\nexport type PassDownProps = WrapperProps & InjectedProps;\n\nfunction getDisplayName(component: WrappedComponentClass) {\n return component.displayName || component.name || (utils.isString(component) ? component : 'Component');\n}\n\nexport default function withFormsy(\n WrappedComponent: React.ComponentType>,\n): React.ComponentType, keyof InjectedProps>> {\n class WithFormsyWrapper\n extends React.Component & FormsyContextInterface, WrapperState>\n implements WrapperInstanceMethods\n {\n public validations?: Validations;\n\n public requiredValidations?: Validations;\n\n public static displayName = `Formsy(${getDisplayName(WrappedComponent)})`;\n\n public static propTypes: any = propTypes;\n\n public static defaultProps: any = {\n innerRef: null,\n required: false,\n validationError: '',\n validationErrors: {},\n validations: null,\n value: (WrappedComponent as ComponentWithStaticAttributes).defaultValue,\n };\n\n public constructor(props) {\n super(props);\n const { runValidation, validations, required, value } = props;\n\n this.state = { value } as any;\n\n this.setValidations(validations, required);\n\n this.state = {\n formSubmitted: false,\n isPristine: true,\n pristineValue: props.value,\n value: props.value,\n ...runValidation(this, props.value),\n };\n }\n\n public componentDidMount() {\n const { name, attachToForm } = this.props;\n\n if (!name) {\n throw new Error('Form Input requires a name property when used');\n }\n\n attachToForm(this);\n }\n\n public shouldComponentUpdate(nextProps, nextState) {\n const { props, state } = this;\n const isChanged = (a: object, b: object): boolean => Object.keys(a).some((k) => a[k] !== b[k]);\n const isPropsChanged = isChanged(props, nextProps);\n const isStateChanged = isChanged(state, nextState);\n\n return isPropsChanged || isStateChanged;\n }\n\n public componentDidUpdate(prevProps) {\n const { value, validations, required, validate } = this.props;\n\n // If the value passed has changed, set it. If value is not passed it will\n // internally update, and this will never run\n if (!utils.isSame(value, prevProps.value)) {\n this.setValue(value);\n }\n\n // If validations or required is changed, run a new validation\n if (!utils.isSame(validations, prevProps.validations) || !utils.isSame(required, prevProps.required)) {\n this.setValidations(validations, required);\n validate(this);\n }\n }\n\n // Detach it when component unmounts\n public componentWillUnmount() {\n const { detachFromForm } = this.props;\n detachFromForm(this);\n }\n\n public getErrorMessage = (): ValidationError | null => {\n const messages = this.getErrorMessages();\n return messages.length ? messages[0] : null;\n };\n\n public getErrorMessages = (): ValidationError[] => {\n const { validationError } = this.state;\n\n if (!this.isValid() || this.showRequired()) {\n return validationError || [];\n }\n return [];\n };\n\n // eslint-disable-next-line react/destructuring-assignment\n public getValue = (): V => this.state.value;\n\n public setValidations = (validations: Validations, required: RequiredValidation): void => {\n // Add validations to the store itself as the props object can not be modified\n this.validations = convertValidationsToObject(validations) || {};\n this.requiredValidations =\n required === true ? { isDefaultRequiredValue: required } : convertValidationsToObject(required);\n };\n\n // By default, we validate after the value has been set.\n // A user can override this and pass a second parameter of `false` to skip validation.\n public setValue = (value: V, validate = true): void => {\n const { validate: validateForm } = this.props;\n\n if (!validate) {\n this.setState({ value });\n } else {\n this.setState(\n {\n value,\n isPristine: false,\n },\n () => {\n validateForm(this);\n },\n );\n }\n };\n\n // eslint-disable-next-line react/destructuring-assignment\n public hasValue = () => {\n const { value } = this.state;\n return isDefaultRequiredValue(value);\n };\n\n // eslint-disable-next-line react/destructuring-assignment\n public isFormDisabled = (): boolean => this.props.isFormDisabled;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isFormSubmitted = (): boolean => this.state.formSubmitted;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isPristine = (): boolean => this.state.isPristine;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isRequired = (): boolean => !!this.props.required;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isValid = (): boolean => this.state.isValid;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isValidValue = (value: V) => this.props.isValidValue(this, value);\n\n public resetValue = () => {\n const { pristineValue } = this.state;\n const { validate } = this.props;\n\n this.setState(\n {\n value: pristineValue,\n isPristine: true,\n },\n () => {\n validate(this);\n },\n );\n };\n\n public showError = (): boolean => !this.showRequired() && !this.isValid();\n\n // eslint-disable-next-line react/destructuring-assignment\n public showRequired = (): boolean => this.state.isRequired;\n\n public render() {\n const { innerRef } = this.props;\n const propsForElement: T & PassDownProps = {\n ...this.props,\n errorMessage: this.getErrorMessage(),\n errorMessages: this.getErrorMessages(),\n hasValue: this.hasValue(),\n isFormDisabled: this.isFormDisabled(),\n isFormSubmitted: this.isFormSubmitted(),\n isPristine: this.isPristine(),\n isRequired: this.isRequired(),\n isValid: this.isValid(),\n isValidValue: this.isValidValue,\n resetValue: this.resetValue,\n setValidations: this.setValidations,\n setValue: this.setValue,\n showError: this.showError(),\n showRequired: this.showRequired(),\n value: this.getValue(),\n };\n\n if (innerRef) {\n propsForElement.ref = innerRef;\n }\n\n return React.createElement(WrappedComponent, propsForElement);\n }\n }\n\n // eslint-disable-next-line react/display-name\n return (props) =>\n React.createElement(FormsyContext.Consumer, null, (contextValue) => {\n return React.createElement(WithFormsyWrapper, { ...props, ...contextValue });\n });\n}\n","/* eslint-disable react/no-unused-state, react/default-props-match-prop-types */\nimport { get, has, set } from 'lodash';\nimport PropTypes from 'prop-types';\nimport React from 'react';\nimport FormsyContext from './FormsyContext';\nimport {\n FormsyContextInterface,\n IModel,\n InputComponent,\n IResetModel,\n IUpdateInputsWithError,\n IUpdateInputsWithValue,\n ValidationError,\n} from './interfaces';\nimport { throttle, isObject, isString } from './utils';\nimport * as utils from './utils';\nimport validationRules from './validationRules';\nimport { PassDownProps } from './withFormsy';\n\ntype FormHTMLAttributesCleaned = Omit, 'onChange' | 'onSubmit'>;\n\ntype OnSubmitCallback = (\n model: IModel,\n resetModel: IResetModel,\n updateInputsWithError: IUpdateInputsWithError,\n event: React.SyntheticEvent,\n) => void;\n\ntype FormElementType =\n | string\n | React.ComponentType<{\n onReset?: (e: React.SyntheticEvent) => void;\n onSubmit?: (e: React.SyntheticEvent) => void;\n disabled?: boolean;\n children?: React.ReactChildren;\n }>;\n\nexport interface FormsyProps extends FormHTMLAttributesCleaned {\n disabled: boolean;\n mapping: null | ((model: IModel) => IModel);\n onChange: (model: IModel, isChanged: boolean) => void;\n onInvalid: () => void;\n onReset?: () => void;\n onSubmit?: OnSubmitCallback;\n onValidSubmit?: OnSubmitCallback;\n onInvalidSubmit: OnSubmitCallback;\n onValid: () => void;\n preventDefaultSubmit?: boolean;\n preventExternalInvalidation?: boolean;\n validationErrors?: null | object;\n formElement?: FormElementType;\n}\n\nexport interface FormsyState {\n canChange: boolean;\n contextValue: FormsyContextInterface;\n formSubmitted?: boolean;\n isPristine?: boolean;\n isSubmitting: boolean;\n isValid: boolean;\n}\n\nconst ONE_RENDER_FRAME = 66;\n\nexport class Formsy extends React.Component {\n public inputs: InstanceType>[];\n\n public emptyArray: any[];\n\n public prevInputNames: any[] | null = null;\n\n public static displayName = 'Formsy';\n\n public static propTypes = {\n disabled: PropTypes.bool,\n mapping: PropTypes.func,\n formElement: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.func]),\n onChange: PropTypes.func,\n onInvalid: PropTypes.func,\n onInvalidSubmit: PropTypes.func,\n onReset: PropTypes.func,\n onSubmit: PropTypes.func,\n onValid: PropTypes.func,\n onValidSubmit: PropTypes.func,\n preventDefaultSubmit: PropTypes.bool,\n preventExternalInvalidation: PropTypes.bool,\n validationErrors: PropTypes.object, // eslint-disable-line\n };\n\n public static defaultProps: Partial = {\n disabled: false,\n mapping: null,\n onChange: utils.noop,\n onInvalid: utils.noop,\n onInvalidSubmit: utils.noop,\n onReset: utils.noop,\n onSubmit: utils.noop,\n onValid: utils.noop,\n onValidSubmit: utils.noop,\n preventDefaultSubmit: true,\n preventExternalInvalidation: false,\n validationErrors: {},\n formElement: 'form',\n };\n\n private readonly throttledValidateForm: () => void;\n\n public constructor(props: FormsyProps) {\n super(props);\n this.state = {\n canChange: false,\n isSubmitting: false,\n isValid: true,\n contextValue: {\n attachToForm: this.attachToForm,\n detachFromForm: this.detachFromForm,\n isFormDisabled: props.disabled,\n isValidValue: this.isValidValue,\n validate: this.validate,\n runValidation: this.runValidation,\n },\n };\n this.inputs = [];\n this.emptyArray = [];\n this.throttledValidateForm = throttle(this.validateForm, ONE_RENDER_FRAME);\n }\n\n public componentDidMount = () => {\n this.prevInputNames = this.inputs.map((component) => component.props.name);\n this.validateForm();\n };\n\n public componentDidUpdate = (prevProps: FormsyProps) => {\n const { validationErrors, disabled } = this.props;\n\n if (validationErrors && isObject(validationErrors) && Object.keys(validationErrors).length > 0) {\n this.setInputValidationErrors(validationErrors);\n }\n\n const newInputNames = this.inputs.map((component) => component.props.name);\n if (this.prevInputNames && !utils.isSame(this.prevInputNames, newInputNames)) {\n this.prevInputNames = newInputNames;\n this.validateForm();\n }\n\n // Keep the disabled value in state/context the same as from props\n if (disabled !== prevProps.disabled) {\n // eslint-disable-next-line\n this.setState((state) => ({\n ...state,\n contextValue: {\n ...state.contextValue,\n isFormDisabled: disabled,\n },\n }));\n }\n };\n\n public getCurrentValues = () =>\n this.inputs.reduce((valueAccumulator, component) => {\n const {\n props: { name },\n state: { value },\n } = component;\n // eslint-disable-next-line no-param-reassign\n valueAccumulator[name] = utils.protectAgainstParamReassignment(value);\n return valueAccumulator;\n }, {});\n\n public getModel = () => {\n const currentValues = this.getCurrentValues();\n return this.mapModel(currentValues);\n };\n\n public getPristineValues = () =>\n this.inputs.reduce((valueAccumulator, component) => {\n const {\n props: { name, value },\n } = component;\n // eslint-disable-next-line no-param-reassign\n valueAccumulator[name] = utils.protectAgainstParamReassignment(value);\n return valueAccumulator;\n }, {});\n\n public setFormPristine = (isPristine: boolean) => {\n this.setState({\n formSubmitted: !isPristine,\n });\n\n // Iterate through each component and set it as pristine\n // or \"dirty\".\n this.inputs.forEach((component) => {\n component.setState({\n formSubmitted: !isPristine,\n isPristine,\n });\n });\n };\n\n public setInputValidationErrors = (errors) => {\n const { preventExternalInvalidation } = this.props;\n const { isValid } = this.state;\n\n this.inputs.forEach((component) => {\n const { name } = component.props;\n component.setState({\n isValid: !(name in errors),\n validationError: isString(errors[name]) ? [errors[name]] : errors[name],\n });\n });\n if (!preventExternalInvalidation && isValid) {\n this.setFormValidState(false);\n }\n };\n\n public setFormValidState = (allIsValid: boolean) => {\n const { onValid, onInvalid } = this.props;\n\n this.setState({\n isValid: allIsValid,\n });\n\n if (allIsValid) {\n onValid();\n } else {\n onInvalid();\n }\n };\n\n public isValidValue = (component, value) => this.runValidation(component, value).isValid;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isFormDisabled = () => this.props.disabled;\n\n public mapModel = (model: IModel): IModel => {\n const { mapping } = this.props;\n\n if (mapping) {\n return mapping(model);\n }\n\n const returnModel = {};\n Object.keys(model).forEach((key) => {\n set(returnModel, key, model[key]);\n });\n return returnModel;\n };\n\n public reset = (model?: IModel) => {\n this.setFormPristine(true);\n this.resetModel(model);\n };\n\n private resetInternal = (event) => {\n const { onReset } = this.props;\n\n event.preventDefault();\n this.reset();\n if (onReset) {\n onReset();\n }\n };\n\n // Reset each key in the model to the original / initial / specified value\n private resetModel: IResetModel = (data) => {\n this.inputs.forEach((component) => {\n const { name } = component.props;\n if (data && has(data, name)) {\n component.setValue(get(data, name));\n } else {\n component.resetValue();\n }\n });\n this.validateForm();\n };\n\n // Checks validation on current value or a passed value\n public runValidation = (\n component: InputComponent,\n value = component.state.value,\n ): { isRequired: boolean; isValid: boolean; validationError: ValidationError[] } => {\n const { validationErrors } = this.props;\n const { validationError, validationErrors: componentValidationErrors, name } = component.props;\n const currentValues = this.getCurrentValues();\n const validationResults = utils.runRules(value, currentValues, component.validations, validationRules);\n const requiredResults = utils.runRules(value, currentValues, component.requiredValidations, validationRules);\n const isRequired = Object.keys(component.requiredValidations).length ? !!requiredResults.success.length : false;\n const isValid = !validationResults.failed.length && !(validationErrors && validationErrors[component.props.name]);\n\n return {\n isRequired,\n isValid: isRequired ? false : isValid,\n validationError: (() => {\n if (isValid && !isRequired) {\n return this.emptyArray;\n }\n\n if (validationResults.errors.length) {\n return validationResults.errors;\n }\n\n if (validationErrors && validationErrors[name]) {\n return isString(validationErrors[name]) ? [validationErrors[name]] : validationErrors[name];\n }\n\n if (isRequired) {\n const error = componentValidationErrors[requiredResults.success[0]] || validationError;\n return error ? [error] : null;\n }\n\n if (validationResults.failed.length) {\n return validationResults.failed\n .map((failed) => (componentValidationErrors[failed] ? componentValidationErrors[failed] : validationError))\n .filter((x, pos, arr) => arr.indexOf(x) === pos); // remove duplicates\n }\n\n // This line is not reachable\n // istanbul ignore next\n return undefined;\n })(),\n };\n };\n\n // Method put on each input component to register\n // itself to the form\n public attachToForm = (component) => {\n if (this.inputs.indexOf(component) === -1) {\n this.inputs.push(component);\n }\n\n const { onChange } = this.props;\n const { canChange } = this.state;\n\n // Trigger onChange\n if (canChange) {\n onChange(this.getModel(), this.isChanged());\n }\n\n // Will be triggered immediately & every one frame rate\n this.throttledValidateForm();\n };\n\n // Method put on each input component to unregister\n // itself from the form\n public detachFromForm = (component: InputComponent) => {\n const componentPos = this.inputs.indexOf(component);\n\n if (componentPos !== -1) {\n this.inputs = this.inputs.slice(0, componentPos).concat(this.inputs.slice(componentPos + 1));\n }\n\n this.validateForm();\n };\n\n // Checks if the values have changed from their initial value\n public isChanged = () => !utils.isSame(this.getPristineValues(), this.getCurrentValues());\n\n // Update model, submit to url prop and send the model\n public submit = (event?: React.SyntheticEvent) => {\n const { onSubmit, onValidSubmit, onInvalidSubmit, preventDefaultSubmit } = this.props;\n const { isValid } = this.state;\n\n if (preventDefaultSubmit && event && event.preventDefault) {\n event.preventDefault();\n }\n\n // Trigger form as not pristine.\n // If any inputs have not been touched yet this will make them dirty\n // so validation becomes visible (if based on isPristine)\n this.setFormPristine(false);\n const model = this.getModel();\n onSubmit(model, this.resetModel, this.updateInputsWithError, event);\n\n if (isValid) {\n onValidSubmit(model, this.resetModel, this.updateInputsWithError, event);\n } else {\n onInvalidSubmit(model, this.resetModel, this.updateInputsWithError, event);\n }\n };\n\n // Go through errors from server and grab the components\n // stored in the inputs map. Change their state to invalid\n // and set the serverError message\n public updateInputsWithError: IUpdateInputsWithError = (errors, invalidate) => {\n const { preventExternalInvalidation } = this.props;\n const { isValid } = this.state;\n\n Object.entries(errors).forEach(([name, error]) => {\n const component = this.inputs.find((input) => input.props.name === name);\n if (!component) {\n throw new Error(\n `You are trying to update an input that does not exist. Verify errors object with input names. ${JSON.stringify(\n errors,\n )}`,\n );\n }\n component.setState({\n isValid: preventExternalInvalidation,\n validationError: utils.isString(error) ? [error] : error,\n });\n });\n\n if (invalidate && isValid) {\n this.setFormValidState(false);\n }\n };\n\n // Set the value of components\n public updateInputsWithValue: IUpdateInputsWithValue = (data, validate) => {\n this.inputs.forEach((component) => {\n const { name } = component.props;\n if (data && has(data, name)) {\n component.setValue(get(data, name), validate);\n }\n });\n };\n\n // Use the binded values and the actual input value to\n // validate the input and set its state. Then check the\n // state of the form itself\n public validate = (component: InputComponent) => {\n const { onChange } = this.props;\n const { canChange } = this.state;\n\n // Trigger onChange\n if (canChange) {\n onChange(this.getModel(), this.isChanged());\n }\n\n const validationState = this.runValidation(component);\n // Run through the validations, split them up and call\n // the validator IF there is a value or it is required\n component.setState(validationState, this.validateForm);\n };\n\n // Validate the form by going through all child input components\n // and check their state\n public validateForm = () => {\n // We need a callback as we are validating all inputs again. This will\n // run when the last component has set its state\n const onValidationComplete = () => {\n const allIsValid = this.inputs.every((component) => component.state.isValid);\n\n this.setFormValidState(allIsValid);\n\n // Tell the form that it can start to trigger change events\n this.setState({\n canChange: true,\n });\n };\n\n // Run validation again in case affected by other inputs. The\n // last component validated will run the onValidationComplete callback\n this.inputs.forEach((component, index) => {\n const validationState = this.runValidation(component);\n const isFinalInput = index === this.inputs.length - 1;\n const callback = isFinalInput ? onValidationComplete : null;\n component.setState(validationState, callback);\n });\n\n // If there are no inputs, set state where form is ready to trigger\n // change event. New inputs might be added later\n if (!this.inputs.length) {\n this.setState(\n {\n canChange: true,\n },\n onValidationComplete,\n );\n }\n };\n\n public render() {\n const {\n /* eslint-disable @typescript-eslint/no-unused-vars */\n children,\n mapping,\n onChange,\n onInvalid,\n onInvalidSubmit,\n onReset,\n onSubmit,\n onValid,\n onValidSubmit,\n preventDefaultSubmit,\n preventExternalInvalidation,\n validationErrors,\n disabled,\n formElement,\n ...nonFormsyProps\n } = this.props;\n const { contextValue } = this.state;\n\n return React.createElement(\n FormsyContext.Provider,\n {\n value: contextValue,\n },\n React.createElement(\n formElement,\n {\n onReset: this.resetInternal,\n onSubmit: this.submit,\n ...nonFormsyProps,\n disabled,\n },\n children,\n ),\n );\n }\n}\n"],"names":["isArray","value","Array","isObject","isPlainObject","isTypeUndefined","isDate","Date","isFunction","isString","isNumber","isRegex","RegExp","isValueStringEmpty","isValueNullOrUndefined","undefined","isValueUndefined","noop","protectAgainstParamReassignment","isSame","a","b","length","every","item","index","toString","Object","keys","key","runRules","currentValues","validations","validationRules","results","errors","failed","success","forEach","validationName","validationsVal","validationRulesVal","addToResults","validation","push","Error","throttle","callback","interval","enableCall","args","apply","setTimeout","isExisty","isEmpty","isDefaultRequiredValue","matchRegexp","_values","regexp","test","REGEX_PATTERNS","ALPHA","ALPHANUMERIC","EMAIL","FLOAT","INT","NUMERIC","SPECIAL_WORDS","URL","WORDS","equals","eql","equalsField","values","field","isAlpha","isAlphanumeric","isEmail","isEmptyString","isFalse","isFloat","isInt","isLength","isNumeric","isSpecialWords","isTrue","isUndefined","isUrl","isWords","maxLength","minLength","addValidationRule","name","func","noFormsyErrorMessage","throwNoFormsyProvider","defaultValue","attachToForm","detachFromForm","isFormDisabled","isValidValue","validate","runValidation","React","createContext","convertValidationsToObject","split","reduce","validationsAccumulator","validateMethod","shift","map","arg","JSON","parse","e","validationsAccumulatorCopy","propTypes","innerRef","PropTypes","string","isRequired","required","oneOfType","bool","object","any","getDisplayName","component","displayName","utils","withFormsy","WrappedComponent","WithFormsyWrapper","props","messages","getErrorMessages","validationError","state","isValid","showRequired","requiredValidations","validateForm","setState","isPristine","formSubmitted","pristineValue","setValidations","componentDidMount","shouldComponentUpdate","nextProps","nextState","isChanged","some","k","isPropsChanged","isStateChanged","componentDidUpdate","prevProps","setValue","componentWillUnmount","render","propsForElement","errorMessage","getErrorMessage","errorMessages","hasValue","isFormSubmitted","resetValue","showError","getValue","ref","createElement","Component","validationErrors","FormsyContext","Consumer","contextValue","ONE_RENDER_FRAME","Formsy","prevInputNames","inputs","disabled","setInputValidationErrors","newInputNames","valueAccumulator","getCurrentValues","mapModel","preventExternalInvalidation","setFormValidState","allIsValid","onValid","onInvalid","model","mapping","returnModel","set","setFormPristine","resetModel","event","onReset","preventDefault","reset","data","has","get","componentValidationErrors","validationResults","requiredResults","emptyArray","error","filter","x","pos","arr","indexOf","onChange","canChange","getModel","throttledValidateForm","componentPos","slice","concat","getPristineValues","onSubmit","onValidSubmit","onInvalidSubmit","preventDefaultSubmit","updateInputsWithError","invalidate","entries","find","input","stringify","validationState","onValidationComplete","isFinalInput","isSubmitting","children","formElement","nonFormsyProps","Provider","resetInternal","submit"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAIgBA,QAAQC;AACtB,SAAOC,KAAK,CAACF,OAAN,CAAcC,KAAd,CAAP;AACD;SAEeE,SAASF;AACvB,SAAOG,oBAAa,CAACH,KAAD,CAApB;AACD;SAEeI,gBAAgBJ;AAC9B,SAAO,OAAOA,KAAP,KAAiB,WAAxB;AACD;SAEeK,OAAOL;AACrB,SAAOA,KAAK,YAAYM,IAAxB;AACD;SAEeC,WAAWP;AACzB,SAAOA,KAAK,KAAK,IAAV,IAAkB,OAAOA,KAAP,KAAiB,UAA1C;AACD;SAEeQ,SAASR;AACvB,SAAO,OAAOA,KAAP,KAAiB,QAAxB;AACD;SAEeS,SAAST;AACvB,SAAO,OAAOA,KAAP,KAAiB,QAAxB;AACD;SAEeU,QAAQV;AACtB,SAAOA,KAAK,YAAYW,MAAxB;AACD;SAEeC,mBAAmBZ;AACjC,SAAOA,KAAK,KAAK,EAAjB;AACD;SAEea,uBAAuBb;AACrC,SAAOA,KAAK,KAAK,IAAV,IAAkBA,KAAK,KAAKc,SAAnC;AACD;SAEeC,iBAAiBf;AAC/B,SAAOA,KAAK,KAAKc,SAAjB;AACD;SAEeE;AAEf;SAEeC,gCAAgCjB;AAC9C;AACA,MAAIE,QAAQ,CAACF,KAAD,CAAZ,EAAqB,oBAAYA,KAAZ;AACrB,MAAID,OAAO,CAACC,KAAD,CAAX,EAAoB,iBAAWA,KAAX;AACpB,SAAOA,KAAP;AACD;SAEekB,OAAOC,GAAYC;AACjC,MAAI,OAAOD,CAAP,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AAKjDgG,EAAAA,eAAe,EAAEhG,IALgC;AAMjDsE,EAAAA,OAAO,EAAEtE,IANwC;AAOjD8F,EAAAA,QAAQ,EAAE9F,IAPuC;AAQjD6D,EAAAA,OAAO,EAAE7D,IARwC;AASjD+F,EAAAA,aAAa,EAAE/F,IATkC;AAUjDiG,EAAAA,oBAAoB,EAAE,IAV2B;AAWjDvC,EAAAA,2BAA2B,EAAE,KAXoB;AAYjDd,EAAAA,gBAAgB,EAAE,EAZ+B;AAajDiE,EAAAA,WAAW,EAAE;AAboC,CAArC;;;;;;;;"}
\ No newline at end of file
+{"version":3,"file":"formsy-react.cjs.development.js","sources":["../src/utils.ts","../src/validationRules.ts","../src/FormsyContext.ts","../src/withFormsy.ts","../src/Formsy.ts"],"sourcesContent":["import { isPlainObject } from 'lodash';\n\nimport { ValidationError, Validations, Values } from './interfaces';\n\nexport function isArray(value: unknown): value is unknown[] {\n return Array.isArray(value);\n}\n\nexport function isObject(value: unknown): value is object {\n return isPlainObject(value);\n}\n\nexport function isTypeUndefined(value: unknown): value is undefined {\n return typeof value === 'undefined';\n}\n\nexport function isDate(value: unknown): value is Date {\n return value instanceof Date;\n}\n\nexport function isFunction(value: unknown): value is Function {\n return value !== null && typeof value === 'function';\n}\n\nexport function isString(value: unknown): value is string {\n return typeof value === 'string';\n}\n\nexport function isNumber(value: unknown): value is number {\n return typeof value === 'number';\n}\n\nexport function isRegex(value: unknown): value is RegExp {\n return value instanceof RegExp;\n}\n\nexport function isValueStringEmpty(value: string): boolean {\n return value === '';\n}\n\nexport function isValueNullOrUndefined(value: unknown): boolean {\n return value === null || value === undefined;\n}\n\nexport function isValueUndefined(value: unknown): boolean {\n return value === undefined;\n}\n\nexport function noop() {\n // do nothing.\n}\n\nexport function protectAgainstParamReassignment(value: unknown) {\n // Clone objects to avoid accidental param reassignment\n if (isObject(value)) return { ...value };\n if (isArray(value)) return [...value];\n return value;\n}\n\nexport function isSame(a: unknown, b: unknown) {\n if (typeof a !== typeof b) {\n return false;\n }\n\n if (isArray(a) && isArray(b)) {\n if (a.length !== b.length) {\n return false;\n }\n\n return a.every((item, index) => isSame(item, b[index]));\n }\n\n if (isFunction(a) && isFunction(b)) {\n return a.toString() === b.toString();\n }\n\n if (isDate(a) && isDate(b)) {\n return a.toString() === b.toString();\n }\n\n if (isObject(a) && isObject(b)) {\n if (Object.keys(a).length !== Object.keys(b).length) {\n return false;\n }\n\n return Object.keys(a).every((key) => isSame(a[key], b[key]));\n }\n\n if (isRegex(a) && isRegex(b)) {\n return a.toString() === b.toString();\n }\n\n return a === b;\n}\n\ninterface RulesResult {\n errors: ValidationError[];\n failed: string[];\n success: string[];\n}\n\nexport function runRules(\n value: V,\n currentValues: Values,\n validations: Validations,\n validationRules: Validations,\n) {\n const results: RulesResult = {\n errors: [],\n failed: [],\n success: [],\n };\n\n Object.keys(validations).forEach((validationName) => {\n const validationsVal = validations[validationName];\n const validationRulesVal = validationRules[validationName];\n const addToResults = (validation) => {\n if (isString(validation)) {\n results.errors.push(validation);\n results.failed.push(validationName);\n } else if (!validation) {\n results.failed.push(validationName);\n } else {\n results.success.push(validationName);\n }\n };\n\n if (validationRulesVal && isFunction(validationsVal)) {\n throw new Error(`Formsy does not allow you to override default validations: ${validationName}`);\n }\n\n if (!validationRulesVal && !isFunction(validationsVal)) {\n throw new Error(`Formsy does not have the validation rule: ${validationName}`);\n }\n\n if (isFunction(validationsVal)) {\n return addToResults(validationsVal(currentValues, value));\n }\n\n return addToResults(validationRulesVal(currentValues, value, validationsVal));\n });\n\n return results;\n}\n\nexport function throttle(callback, interval) {\n let enableCall = true;\n\n return function (...args) {\n if (!enableCall) return;\n\n enableCall = false;\n callback.apply(this, args);\n setTimeout(() => (enableCall = true), interval);\n };\n}\n","import { ValidationFunction, Values } from './interfaces';\nimport {\n isNumber,\n isString,\n isTypeUndefined,\n isValueNullOrUndefined,\n isValueStringEmpty,\n isValueUndefined,\n} from './utils';\n\nexport function isExisty(value: V) {\n return !isValueNullOrUndefined(value);\n}\n\nexport function isEmpty(value: V) {\n if (isString(value)) {\n return isValueStringEmpty(value);\n }\n if (isTypeUndefined(value)) {\n return false;\n }\n return isValueUndefined(value);\n}\n\nexport function isDefaultRequiredValue(value: unknown) {\n return isString(value) ? isValueStringEmpty(value) : isValueNullOrUndefined(value);\n}\n\nexport function matchRegexp(_values: Values, value: V, regexp: RegExp) {\n return !isExisty(value) || isEmpty(value) || regexp.test(`${value}`);\n}\n\ninterface Validations {\n [key: string]: ValidationFunction;\n}\n\nconst REGEX_PATTERNS = {\n ALPHA: /^[A-Z]+$/i,\n ALPHANUMERIC: /^[0-9A-Z]+$/i,\n EMAIL:\n /^(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/i, // from http://emailregex.com/\n FLOAT: /^(?:[-+]?(?:\\d+))?(?:\\.\\d*)?(?:[eE][+-]?(?:\\d+))?$/,\n INT: /^(?:[-+]?(?:0|[1-9]\\d*))$/,\n NUMERIC: /^[-+]?(?:\\d*[.])?\\d+$/,\n SPECIAL_WORDS: /^[\\sA-ZÀ-ÖØ-öø-ÿ]+$/i,\n URL: /^(?:\\w+:)?\\/\\/([^\\s.]+\\.\\S{2}|localhost[:?\\d]*)\\S*$/i,\n WORDS: /^[A-Z\\s]+$/i,\n};\n\nconst validations: Validations = {\n equals: (_values, value: V, eql: V) => !isExisty(value) || isEmpty(value) || value === eql,\n equalsField: (values, value: V, field: string) => value === values[field],\n isAlpha: (values, value: V) => matchRegexp(values, value, REGEX_PATTERNS.ALPHA),\n isAlphanumeric: (values, value: V) => matchRegexp(values, value, REGEX_PATTERNS.ALPHANUMERIC),\n isDefaultRequiredValue: (_values, value: V) => isDefaultRequiredValue(value),\n isEmail: (values, value: string) => matchRegexp(values, value, REGEX_PATTERNS.EMAIL),\n isEmptyString: (_values, value: string) => isEmpty(value),\n isExisty: (_values, value: V) => isExisty(value),\n isFalse: (_values, value: boolean | string) => value === false,\n isFloat: (values, value: V) => matchRegexp(values, value, REGEX_PATTERNS.FLOAT),\n isInt: (values, value: V) => matchRegexp(values, value, REGEX_PATTERNS.INT),\n isLength: (_values, value: string, length: number) => !isExisty(value) || isEmpty(value) || value.length === length,\n isNumeric: (values, value: V) => isNumber(value) || matchRegexp(values, value, REGEX_PATTERNS.NUMERIC),\n isSpecialWords: (values, value: V) => matchRegexp(values, value, REGEX_PATTERNS.SPECIAL_WORDS),\n isTrue: (_values, value: boolean | string) => value === true,\n isUndefined: (_values, value: V) => isValueUndefined(value),\n isUrl: (values, value: V) => matchRegexp(values, value, REGEX_PATTERNS.URL),\n isWords: (values, value: V) => matchRegexp(values, value, REGEX_PATTERNS.WORDS),\n matchRegexp,\n maxLength: (_values, value: string, length: number) => !isExisty(value) || value.length <= length,\n minLength: (_values, value: string, length: number) => !isExisty(value) || isEmpty(value) || value.length >= length,\n};\n\nexport const addValidationRule = (name: string, func: ValidationFunction) => {\n validations[name] = func;\n};\n\nexport default validations;\n","import React from 'react';\nimport { FormsyContextInterface } from './interfaces';\n\nconst noFormsyErrorMessage = 'Could not find Formsy Context Provider. Did you use withFormsy outside ?';\n\nconst throwNoFormsyProvider = () => {\n // istanbul ignore next\n throw new Error(noFormsyErrorMessage);\n};\n\nconst defaultValue = {\n attachToForm: throwNoFormsyProvider,\n detachFromForm: throwNoFormsyProvider,\n isFormDisabled: true,\n isValidValue: throwNoFormsyProvider,\n validate: throwNoFormsyProvider,\n runValidation: throwNoFormsyProvider,\n};\n\nexport default React.createContext(defaultValue);\n","import PropTypes from 'prop-types';\nimport React from 'react';\nimport FormsyContext from './FormsyContext';\nimport {\n ComponentWithStaticAttributes,\n FormsyContextInterface,\n RequiredValidation,\n ValidationError,\n Validations,\n WrappedComponentClass,\n} from './interfaces';\n\nimport * as utils from './utils';\nimport { isString } from './utils';\nimport { isDefaultRequiredValue } from './validationRules';\n\n/* eslint-disable react/default-props-match-prop-types */\n\nconst convertValidationsToObject = (validations: false | Validations): Validations => {\n if (isString(validations)) {\n return validations.split(/,(?![^{[]*[}\\]])/g).reduce((validationsAccumulator, validation) => {\n let args: string[] = validation.split(':');\n const validateMethod: string = args.shift();\n\n args = args.map((arg) => {\n try {\n return JSON.parse(arg);\n } catch (e) {\n return arg; // It is a string if it can not parse it\n }\n });\n\n if (args.length > 1) {\n throw new Error(\n 'Formsy does not support multiple args on string validations. Use object format of validations instead.',\n );\n }\n\n // Avoid parameter reassignment\n const validationsAccumulatorCopy: Validations = { ...validationsAccumulator };\n validationsAccumulatorCopy[validateMethod] = args.length ? args[0] : true;\n return validationsAccumulatorCopy;\n }, {});\n }\n\n return validations || {};\n};\n\nexport const propTypes = {\n innerRef: PropTypes.func,\n name: PropTypes.string.isRequired,\n required: PropTypes.oneOfType([PropTypes.bool, PropTypes.object, PropTypes.string]),\n validations: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),\n value: PropTypes.any, // eslint-disable-line react/forbid-prop-types\n};\n\nexport interface WrapperProps {\n innerRef?: (ref: React.Ref) => void;\n name: string;\n required?: RequiredValidation;\n validationError?: ValidationError;\n validationErrors?: { [key: string]: ValidationError };\n validations?: Validations;\n value?: V;\n}\n\nexport interface WrapperState {\n [key: string]: unknown;\n\n formSubmitted: boolean;\n isPristine: boolean;\n isRequired: boolean;\n isValid: boolean;\n pristineValue: V;\n validationError: ValidationError[];\n value: V;\n}\n\nexport interface InjectedProps {\n errorMessage: ValidationError;\n errorMessages: ValidationError[];\n hasValue: boolean;\n isFormDisabled: boolean;\n isFormSubmitted: boolean;\n isPristine: boolean;\n isRequired: boolean;\n isValid: boolean;\n isValidValue: (value: V) => boolean;\n ref?: React.Ref;\n resetValue: () => void;\n setValidations: (validations: Validations, required: RequiredValidation) => void;\n setValue: (value: V, validate?: boolean) => void;\n showError: boolean;\n showRequired: boolean;\n}\n\nexport interface WrapperInstanceMethods {\n getErrorMessage: () => null | ValidationError;\n getErrorMessages: () => ValidationError[];\n getValue: () => V;\n isFormDisabled: () => boolean;\n isFormSubmitted: () => boolean;\n isValid: () => boolean;\n isValidValue: (value: V) => boolean;\n setValue: (value: V, validate?: boolean) => void;\n}\n\nexport type PassDownProps = WrapperProps & InjectedProps;\n\nfunction getDisplayName(component: WrappedComponentClass) {\n return component.displayName || component.name || (utils.isString(component) ? component : 'Component');\n}\n\nexport default function withFormsy(\n WrappedComponent: React.ComponentType>,\n): React.ComponentType, keyof InjectedProps>> {\n class WithFormsyWrapper\n extends React.Component & FormsyContextInterface, WrapperState>\n implements WrapperInstanceMethods\n {\n public validations?: Validations;\n\n public requiredValidations?: Validations;\n\n public static displayName = `Formsy(${getDisplayName(WrappedComponent)})`;\n\n public static propTypes: any = propTypes;\n\n public static defaultProps: any = {\n innerRef: null,\n required: false,\n validationError: '',\n validationErrors: {},\n validations: null,\n value: (WrappedComponent as ComponentWithStaticAttributes).defaultValue,\n };\n\n public constructor(props) {\n super(props);\n const { runValidation, validations, required, value } = props;\n\n this.state = { value } as any;\n\n this.setValidations(validations, required);\n\n this.state = {\n formSubmitted: false,\n isPristine: true,\n pristineValue: props.value,\n value: props.value,\n ...runValidation(this, props.value),\n };\n }\n\n public componentDidMount() {\n const { name, attachToForm } = this.props;\n\n if (!name) {\n throw new Error('Form Input requires a name property when used');\n }\n\n attachToForm(this);\n }\n\n public shouldComponentUpdate(nextProps, nextState) {\n const { props, state } = this;\n const isChanged = (a: object, b: object): boolean => Object.keys(a).some((k) => a[k] !== b[k]);\n const isPropsChanged = isChanged(props, nextProps);\n const isStateChanged = isChanged(state, nextState);\n\n return isPropsChanged || isStateChanged;\n }\n\n public componentDidUpdate(prevProps) {\n const { value, validations, required, validate } = this.props;\n\n // If the value passed has changed, set it. If value is not passed it will\n // internally update, and this will never run\n if (!utils.isSame(value, prevProps.value)) {\n this.setValue(value);\n }\n\n // If validations or required is changed, run a new validation\n if (!utils.isSame(validations, prevProps.validations) || !utils.isSame(required, prevProps.required)) {\n this.setValidations(validations, required);\n validate(this);\n }\n }\n\n // Detach it when component unmounts\n public componentWillUnmount() {\n const { detachFromForm } = this.props;\n detachFromForm(this);\n }\n\n public getErrorMessage = (): ValidationError | null => {\n const messages = this.getErrorMessages();\n return messages.length ? messages[0] : null;\n };\n\n public getErrorMessages = (): ValidationError[] => {\n const { validationError } = this.state;\n\n if (!this.isValid() || this.showRequired()) {\n return validationError || [];\n }\n return [];\n };\n\n // eslint-disable-next-line react/destructuring-assignment\n public getValue = (): V => this.state.value;\n\n public setValidations = (validations: Validations, required: RequiredValidation): void => {\n // Add validations to the store itself as the props object can not be modified\n this.validations = convertValidationsToObject(validations) || {};\n this.requiredValidations =\n required === true ? { isDefaultRequiredValue: required } : convertValidationsToObject(required);\n };\n\n // By default, we validate after the value has been set.\n // A user can override this and pass a second parameter of `false` to skip validation.\n public setValue = (value: V, validate = true): void => {\n const { validate: validateForm } = this.props;\n\n if (!validate) {\n this.setState({ value });\n } else {\n this.setState(\n {\n value,\n isPristine: false,\n },\n () => {\n validateForm(this);\n },\n );\n }\n };\n\n // eslint-disable-next-line react/destructuring-assignment\n public hasValue = () => {\n const { value } = this.state;\n return isDefaultRequiredValue(value);\n };\n\n // eslint-disable-next-line react/destructuring-assignment\n public isFormDisabled = (): boolean => this.props.isFormDisabled;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isFormSubmitted = (): boolean => this.state.formSubmitted;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isPristine = (): boolean => this.state.isPristine;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isRequired = (): boolean => !!this.props.required;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isValid = (): boolean => this.state.isValid;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isValidValue = (value: V) => this.props.isValidValue(this, value);\n\n public resetValue = () => {\n const { pristineValue } = this.state;\n const { validate } = this.props;\n\n this.setState(\n {\n value: pristineValue,\n isPristine: true,\n },\n () => {\n validate(this);\n },\n );\n };\n\n public showError = (): boolean => !this.showRequired() && !this.isValid();\n\n // eslint-disable-next-line react/destructuring-assignment\n public showRequired = (): boolean => this.state.isRequired;\n\n public render() {\n const { innerRef } = this.props;\n const propsForElement: T & PassDownProps = {\n ...this.props,\n errorMessage: this.getErrorMessage(),\n errorMessages: this.getErrorMessages(),\n hasValue: this.hasValue(),\n isFormDisabled: this.isFormDisabled(),\n isFormSubmitted: this.isFormSubmitted(),\n isPristine: this.isPristine(),\n isRequired: this.isRequired(),\n isValid: this.isValid(),\n isValidValue: this.isValidValue,\n resetValue: this.resetValue,\n setValidations: this.setValidations,\n setValue: this.setValue,\n showError: this.showError(),\n showRequired: this.showRequired(),\n value: this.getValue(),\n };\n\n if (innerRef) {\n propsForElement.ref = innerRef;\n }\n\n return React.createElement(WrappedComponent, propsForElement);\n }\n }\n\n // eslint-disable-next-line react/display-name\n return (props) =>\n React.createElement(FormsyContext.Consumer, null, ((contextValue) => {\n return React.createElement(WithFormsyWrapper, { ...props, ...contextValue });\n }) as any);\n}\n","/* eslint-disable react/no-unused-state, react/default-props-match-prop-types */\nimport { get, has, set } from 'lodash';\nimport PropTypes from 'prop-types';\nimport React from 'react';\nimport FormsyContext from './FormsyContext';\nimport {\n FormsyContextInterface,\n IModel,\n InputComponent,\n IResetModel,\n IUpdateInputsWithError,\n IUpdateInputsWithValue,\n ValidationError,\n} from './interfaces';\nimport { throttle, isObject, isString } from './utils';\nimport * as utils from './utils';\nimport validationRules from './validationRules';\nimport { PassDownProps } from './withFormsy';\n\ntype FormHTMLAttributesCleaned = Omit, 'onChange' | 'onSubmit'>;\n\ntype OnSubmitCallback = (\n model: IModel,\n resetModel: IResetModel,\n updateInputsWithError: IUpdateInputsWithError,\n event: React.SyntheticEvent,\n) => void;\n\ntype FormElementType =\n | string\n | React.ComponentType<{\n onReset?: (e: React.SyntheticEvent) => void;\n onSubmit?: (e: React.SyntheticEvent) => void;\n disabled?: boolean;\n children?: React.ReactChildren;\n }>;\n\nexport interface FormsyProps extends FormHTMLAttributesCleaned {\n disabled: boolean;\n mapping: null | ((model: IModel) => IModel);\n onChange: (model: IModel, isChanged: boolean) => void;\n onInvalid: () => void;\n onReset?: () => void;\n onSubmit?: OnSubmitCallback;\n onValidSubmit?: OnSubmitCallback;\n onInvalidSubmit: OnSubmitCallback;\n onValid: () => void;\n preventDefaultSubmit?: boolean;\n preventExternalInvalidation?: boolean;\n validationErrors?: null | object;\n formElement?: FormElementType;\n}\n\nexport interface FormsyState {\n canChange: boolean;\n contextValue: FormsyContextInterface;\n formSubmitted?: boolean;\n isPristine?: boolean;\n isSubmitting: boolean;\n isValid: boolean;\n}\n\nconst ONE_RENDER_FRAME = 66;\n\nexport class Formsy extends React.Component {\n public inputs: InstanceType>[];\n\n public emptyArray: any[];\n\n public prevInputNames: any[] | null = null;\n\n public static displayName = 'Formsy';\n\n public static propTypes = {\n disabled: PropTypes.bool,\n mapping: PropTypes.func,\n formElement: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.func]),\n onChange: PropTypes.func,\n onInvalid: PropTypes.func,\n onInvalidSubmit: PropTypes.func,\n onReset: PropTypes.func,\n onSubmit: PropTypes.func,\n onValid: PropTypes.func,\n onValidSubmit: PropTypes.func,\n preventDefaultSubmit: PropTypes.bool,\n preventExternalInvalidation: PropTypes.bool,\n validationErrors: PropTypes.object, // eslint-disable-line\n };\n\n public static defaultProps: Partial = {\n disabled: false,\n mapping: null,\n onChange: utils.noop,\n onInvalid: utils.noop,\n onInvalidSubmit: utils.noop,\n onReset: utils.noop,\n onSubmit: utils.noop,\n onValid: utils.noop,\n onValidSubmit: utils.noop,\n preventDefaultSubmit: true,\n preventExternalInvalidation: false,\n validationErrors: {},\n formElement: 'form',\n };\n\n private readonly throttledValidateForm: () => void;\n\n public constructor(props: FormsyProps) {\n super(props);\n this.state = {\n canChange: false,\n isSubmitting: false,\n isValid: true,\n contextValue: {\n attachToForm: this.attachToForm,\n detachFromForm: this.detachFromForm,\n isFormDisabled: props.disabled,\n isValidValue: this.isValidValue,\n validate: this.validate,\n runValidation: this.runValidation,\n },\n };\n this.inputs = [];\n this.emptyArray = [];\n this.throttledValidateForm = throttle(this.validateForm, ONE_RENDER_FRAME);\n }\n\n public componentDidMount = () => {\n this.prevInputNames = this.inputs.map((component) => component.props.name);\n this.validateForm();\n };\n\n public componentDidUpdate = (prevProps: FormsyProps) => {\n const { validationErrors, disabled } = this.props;\n\n if (validationErrors && isObject(validationErrors) && Object.keys(validationErrors).length > 0) {\n this.setInputValidationErrors(validationErrors);\n }\n\n const newInputNames = this.inputs.map((component) => component.props.name);\n if (this.prevInputNames && !utils.isSame(this.prevInputNames, newInputNames)) {\n this.prevInputNames = newInputNames;\n this.validateForm();\n }\n\n // Keep the disabled value in state/context the same as from props\n if (disabled !== prevProps.disabled) {\n // eslint-disable-next-line\n this.setState((state) => ({\n ...state,\n contextValue: {\n ...state.contextValue,\n isFormDisabled: disabled,\n },\n }));\n }\n };\n\n public getCurrentValues = () =>\n this.inputs.reduce((valueAccumulator, component) => {\n const {\n props: { name },\n state: { value },\n } = component;\n // eslint-disable-next-line no-param-reassign\n valueAccumulator[name] = utils.protectAgainstParamReassignment(value);\n return valueAccumulator;\n }, {});\n\n public getModel = () => {\n const currentValues = this.getCurrentValues();\n return this.mapModel(currentValues);\n };\n\n public getPristineValues = () =>\n this.inputs.reduce((valueAccumulator, component) => {\n const {\n props: { name, value },\n } = component;\n // eslint-disable-next-line no-param-reassign\n valueAccumulator[name] = utils.protectAgainstParamReassignment(value);\n return valueAccumulator;\n }, {});\n\n public setFormPristine = (isPristine: boolean) => {\n this.setState({\n formSubmitted: !isPristine,\n });\n\n // Iterate through each component and set it as pristine\n // or \"dirty\".\n this.inputs.forEach((component) => {\n component.setState({\n formSubmitted: !isPristine,\n isPristine,\n });\n });\n };\n\n public setInputValidationErrors = (errors) => {\n const { preventExternalInvalidation } = this.props;\n const { isValid } = this.state;\n\n this.inputs.forEach((component) => {\n const { name } = component.props;\n component.setState({\n isValid: !(name in errors),\n validationError: isString(errors[name]) ? [errors[name]] : errors[name],\n });\n });\n if (!preventExternalInvalidation && isValid) {\n this.setFormValidState(false);\n }\n };\n\n public setFormValidState = (allIsValid: boolean) => {\n const { onValid, onInvalid } = this.props;\n\n this.setState({\n isValid: allIsValid,\n });\n\n if (allIsValid) {\n onValid();\n } else {\n onInvalid();\n }\n };\n\n public isValidValue = (component, value) => this.runValidation(component, value).isValid;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isFormDisabled = () => this.props.disabled;\n\n public mapModel = (model: IModel): IModel => {\n const { mapping } = this.props;\n\n if (mapping) {\n return mapping(model);\n }\n\n const returnModel = {};\n Object.keys(model).forEach((key) => {\n set(returnModel, key, model[key]);\n });\n return returnModel;\n };\n\n public reset = (model?: IModel) => {\n this.setFormPristine(true);\n this.resetModel(model);\n };\n\n private resetInternal = (event) => {\n const { onReset } = this.props;\n\n event.preventDefault();\n this.reset();\n if (onReset) {\n onReset();\n }\n };\n\n // Reset each key in the model to the original / initial / specified value\n private resetModel: IResetModel = (data) => {\n this.inputs.forEach((component) => {\n const { name } = component.props;\n if (data && has(data, name)) {\n component.setValue(get(data, name));\n } else {\n component.resetValue();\n }\n });\n this.validateForm();\n };\n\n // Checks validation on current value or a passed value\n public runValidation = (\n component: InputComponent,\n value = component.state.value,\n ): { isRequired: boolean; isValid: boolean; validationError: ValidationError[] } => {\n const { validationErrors } = this.props;\n const { validationError, validationErrors: componentValidationErrors, name } = component.props;\n const currentValues = this.getCurrentValues();\n const validationResults = utils.runRules(value, currentValues, component.validations, validationRules);\n const requiredResults = utils.runRules(value, currentValues, component.requiredValidations, validationRules);\n const isRequired = Object.keys(component.requiredValidations).length ? !!requiredResults.success.length : false;\n const isValid = !validationResults.failed.length && !(validationErrors && validationErrors[component.props.name]);\n\n return {\n isRequired,\n isValid: isRequired ? false : isValid,\n validationError: (() => {\n if (isValid && !isRequired) {\n return this.emptyArray;\n }\n\n if (validationResults.errors.length) {\n return validationResults.errors;\n }\n\n if (validationErrors && validationErrors[name]) {\n return isString(validationErrors[name]) ? [validationErrors[name]] : validationErrors[name];\n }\n\n if (isRequired) {\n const error = componentValidationErrors[requiredResults.success[0]] || validationError;\n return error ? [error] : null;\n }\n\n if (validationResults.failed.length) {\n return validationResults.failed\n .map((failed) => (componentValidationErrors[failed] ? componentValidationErrors[failed] : validationError))\n .filter((x, pos, arr) => arr.indexOf(x) === pos); // remove duplicates\n }\n\n // This line is not reachable\n // istanbul ignore next\n return undefined;\n })(),\n };\n };\n\n // Method put on each input component to register\n // itself to the form\n public attachToForm = (component) => {\n if (this.inputs.indexOf(component) === -1) {\n this.inputs.push(component);\n }\n\n const { onChange } = this.props;\n const { canChange } = this.state;\n\n // Trigger onChange\n if (canChange) {\n onChange(this.getModel(), this.isChanged());\n }\n\n // Will be triggered immediately & every one frame rate\n this.throttledValidateForm();\n };\n\n // Method put on each input component to unregister\n // itself from the form\n public detachFromForm = (component: InputComponent) => {\n const componentPos = this.inputs.indexOf(component);\n\n if (componentPos !== -1) {\n this.inputs = this.inputs.slice(0, componentPos).concat(this.inputs.slice(componentPos + 1));\n }\n\n this.validateForm();\n };\n\n // Checks if the values have changed from their initial value\n public isChanged = () => !utils.isSame(this.getPristineValues(), this.getCurrentValues());\n\n // Update model, submit to url prop and send the model\n public submit = (event?: React.SyntheticEvent) => {\n const { onSubmit, onValidSubmit, onInvalidSubmit, preventDefaultSubmit } = this.props;\n const { isValid } = this.state;\n\n if (preventDefaultSubmit && event && event.preventDefault) {\n event.preventDefault();\n }\n\n // Trigger form as not pristine.\n // If any inputs have not been touched yet this will make them dirty\n // so validation becomes visible (if based on isPristine)\n this.setFormPristine(false);\n const model = this.getModel();\n onSubmit(model, this.resetModel, this.updateInputsWithError, event);\n\n if (isValid) {\n onValidSubmit(model, this.resetModel, this.updateInputsWithError, event);\n } else {\n onInvalidSubmit(model, this.resetModel, this.updateInputsWithError, event);\n }\n };\n\n // Go through errors from server and grab the components\n // stored in the inputs map. Change their state to invalid\n // and set the serverError message\n public updateInputsWithError: IUpdateInputsWithError = (errors, invalidate) => {\n const { preventExternalInvalidation } = this.props;\n const { isValid } = this.state;\n\n Object.entries(errors).forEach(([name, error]) => {\n const component = this.inputs.find((input) => input.props.name === name);\n if (!component) {\n throw new Error(\n `You are trying to update an input that does not exist. Verify errors object with input names. ${JSON.stringify(\n errors,\n )}`,\n );\n }\n component.setState({\n isValid: preventExternalInvalidation,\n validationError: utils.isString(error) ? [error] : error,\n });\n });\n\n if (invalidate && isValid) {\n this.setFormValidState(false);\n }\n };\n\n // Set the value of components\n public updateInputsWithValue: IUpdateInputsWithValue = (data, validate) => {\n this.inputs.forEach((component) => {\n const { name } = component.props;\n if (data && has(data, name)) {\n component.setValue(get(data, name), validate);\n }\n });\n };\n\n // Use the binded values and the actual input value to\n // validate the input and set its state. Then check the\n // state of the form itself\n public validate = (component: InputComponent) => {\n const { onChange } = this.props;\n const { canChange } = this.state;\n\n // Trigger onChange\n if (canChange) {\n onChange(this.getModel(), this.isChanged());\n }\n\n const validationState = this.runValidation(component);\n // Run through the validations, split them up and call\n // the validator IF there is a value or it is required\n component.setState(validationState, this.validateForm);\n };\n\n // Validate the form by going through all child input components\n // and check their state\n public validateForm = () => {\n // We need a callback as we are validating all inputs again. This will\n // run when the last component has set its state\n const onValidationComplete = () => {\n const allIsValid = this.inputs.every((component) => component.state.isValid);\n\n this.setFormValidState(allIsValid);\n\n // Tell the form that it can start to trigger change events\n this.setState({\n canChange: true,\n });\n };\n\n // Run validation again in case affected by other inputs. The\n // last component validated will run the onValidationComplete callback\n this.inputs.forEach((component, index) => {\n const validationState = this.runValidation(component);\n const isFinalInput = index === this.inputs.length - 1;\n const callback = isFinalInput ? onValidationComplete : null;\n component.setState(validationState, callback);\n });\n\n // If there are no inputs, set state where form is ready to trigger\n // change event. New inputs might be added later\n if (!this.inputs.length) {\n this.setState(\n {\n canChange: true,\n },\n onValidationComplete,\n );\n }\n };\n\n public render() {\n const {\n /* eslint-disable @typescript-eslint/no-unused-vars */\n children,\n mapping,\n onChange,\n onInvalid,\n onInvalidSubmit,\n onReset,\n onSubmit,\n onValid,\n onValidSubmit,\n preventDefaultSubmit,\n preventExternalInvalidation,\n validationErrors,\n disabled,\n formElement,\n ...nonFormsyProps\n } = this.props;\n const { contextValue } = this.state;\n\n return React.createElement(\n FormsyContext.Provider,\n {\n value: contextValue,\n },\n React.createElement(\n formElement,\n {\n onReset: this.resetInternal,\n onSubmit: this.submit,\n ...nonFormsyProps,\n disabled,\n },\n children,\n ),\n );\n }\n}\n"],"names":["isArray","value","Array","isObject","isPlainObject","isTypeUndefined","isDate","Date","isFunction","isString","isNumber","isRegex","RegExp","isValueStringEmpty","isValueNullOrUndefined","undefined","isValueUndefined","noop","protectAgainstParamReassignment","isSame","a","b","length","every","item","index","toString","Object","keys","key","runRules","currentValues","validations","validationRules","results","errors","failed","success","forEach","validationName","validationsVal","validationRulesVal","addToResults","validation","push","Error","throttle","callback","interval","enableCall","args","apply","setTimeout","isExisty","isEmpty","isDefaultRequiredValue","matchRegexp","_values","regexp","test","REGEX_PATTERNS","ALPHA","ALPHANUMERIC","EMAIL","FLOAT","INT","NUMERIC","SPECIAL_WORDS","URL","WORDS","equals","eql","equalsField","values","field","isAlpha","isAlphanumeric","isEmail","isEmptyString","isFalse","isFloat","isInt","isLength","isNumeric","isSpecialWords","isTrue","isUndefined","isUrl","isWords","maxLength","minLength","addValidationRule","name","func","noFormsyErrorMessage","throwNoFormsyProvider","defaultValue","attachToForm","detachFromForm","isFormDisabled","isValidValue","validate","runValidation","React","createContext","convertValidationsToObject","split","reduce","validationsAccumulator","validateMethod","shift","map","arg","JSON","parse","e","validationsAccumulatorCopy","propTypes","innerRef","PropTypes","string","isRequired","required","oneOfType","bool","object","any","getDisplayName","component","displayName","utils","withFormsy","WrappedComponent","WithFormsyWrapper","props","messages","getErrorMessages","validationError","state","isValid","showRequired","requiredValidations","validateForm","setState","isPristine","formSubmitted","pristineValue","setValidations","componentDidMount","shouldComponentUpdate","nextProps","nextState","isChanged","some","k","isPropsChanged","isStateChanged","componentDidUpdate","prevProps","setValue","componentWillUnmount","render","propsForElement","errorMessage","getErrorMessage","errorMessages","hasValue","isFormSubmitted","resetValue","showError","getValue","ref","createElement","Component","validationErrors","FormsyContext","Consumer","contextValue","ONE_RENDER_FRAME","Formsy","prevInputNames","inputs","disabled","setInputValidationErrors","newInputNames","valueAccumulator","getCurrentValues","mapModel","preventExternalInvalidation","setFormValidState","allIsValid","onValid","onInvalid","model","mapping","returnModel","set","setFormPristine","resetModel","event","onReset","preventDefault","reset","data","has","get","componentValidationErrors","validationResults","requiredResults","emptyArray","error","filter","x","pos","arr","indexOf","onChange","canChange","getModel","throttledValidateForm","componentPos","slice","concat","getPristineValues","onSubmit","onValidSubmit","onInvalidSubmit","preventDefaultSubmit","updateInputsWithError","invalidate","entries","find","input","stringify","validationState","onValidationComplete","isFinalInput","isSubmitting","children","formElement","nonFormsyProps","Provider","resetInternal","submit"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAIgBA,OAAO,CAACC,KAAc;EACpC,OAAOC,KAAK,CAACF,OAAO,CAACC,KAAK,CAAC;AAC7B;SAEgBE,QAAQ,CAACF,KAAc;EACrC,OAAOG,oBAAa,CAACH,KAAK,CAAC;AAC7B;SAEgBI,eAAe,CAACJ,KAAc;EAC5C,OAAO,OAAOA,KAAK,KAAK,WAAW;AACrC;SAEgBK,MAAM,CAACL,KAAc;EACnC,OAAOA,KAAK,YAAYM,IAAI;AAC9B;SAEgBC,UAAU,CAACP,KAAc;EACvC,OAAOA,KAAK,KAAK,IAAI,IAAI,OAAOA,KAAK,KAAK,UAAU;AACtD;SAEgBQ,QAAQ,CAACR,KAAc;EACrC,OAAO,OAAOA,KAAK,KAAK,QAAQ;AAClC;SAEgBS,QAAQ,CAACT,KAAc;EACrC,OAAO,OAAOA,KAAK,KAAK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AAI;EACvBkJ,WAAW,eAAExH,SAAS,CAACI,SAAS,CAAC,CAACJ,SAAS,CAACC,MAAM,EAAED,SAAS,CAACM,MAAM,EAAEN,SAAS,CAAC1B,IAAI,CAAC,CAAC;EACtF2H,QAAQ,EAAEjG,SAAS,CAAC1B,IAAI;EACxBmG,SAAS,EAAEzE,SAAS,CAAC1B,IAAI;EACzBqI,eAAe,EAAE3G,SAAS,CAAC1B,IAAI;EAC/B2G,OAAO,EAAEjF,SAAS,CAAC1B,IAAI;EACvBmI,QAAQ,EAAEzG,SAAS,CAAC1B,IAAI;EACxBkG,OAAO,EAAExE,SAAS,CAAC1B,IAAI;EACvBoI,aAAa,EAAE1G,SAAS,CAAC1B,IAAI;EAC7BsI,oBAAoB,EAAE5G,SAAS,CAACK,IAAI;EACpCgE,2BAA2B,EAAErE,SAAS,CAACK,IAAI;EAC3CkD,gBAAgB,EAAEvD,SAAS,CAACM;CAC7B;AAEasD,mBAAY,GAAyB;EACjDG,QAAQ,EAAE,KAAK;EACfY,OAAO,EAAE,IAAI;EACbsB,QAAQ,EAAEtF,IAAU;EACpB8D,SAAS,EAAE9D,IAAU;EACrBgG,eAAe,EAAEhG,IAAU;EAC3BsE,OAAO,EAAEtE,IAAU;EACnB8F,QAAQ,EAAE9F,IAAU;EACpB6D,OAAO,EAAE7D,IAAU;EACnB+F,aAAa,EAAE/F,IAAU;EACzBiG,oBAAoB,EAAE,IAAI;EAC1BvC,2BAA2B,EAAE,KAAK;EAClCd,gBAAgB,EAAE,EAAE;EACpBiE,WAAW,EAAE;CACd;;;;;;;;"}
\ No newline at end of file
diff --git a/dist/formsy-react.cjs.production.min.js b/dist/formsy-react.cjs.production.min.js
index 81660763..3337d394 100644
--- a/dist/formsy-react.cjs.production.min.js
+++ b/dist/formsy-react.cjs.production.min.js
@@ -1,2 +1,2 @@
-"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=require("lodash"),n=t(require("prop-types")),r=t(require("react"));function i(){return(i=Object.assign||function(t){for(var e=1;e()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/i,x=/^(?:[-+]?(?:\d+))?(?:\.\d*)?(?:[eE][+-]?(?:\d+))?$/,R=/^(?:[-+]?(?:0|[1-9]\d*))$/,C=/^[-+]?(?:\d*[.])?\d+$/,O=/^[\sA-ZÀ-ÖØ-öø-ÿ]+$/i,D=/^(?:\w+:)?\/\/([^\s.]+\.\S{2}|localhost[:?\d]*)\S*$/i,j=/^[A-Z\s]+$/i,M={equals:function(t,e,n){return!y(e)||E(e)||e===n},equalsField:function(t,e,n){return e===t[n]},isAlpha:function(t,e){return S(0,e,w)},isAlphanumeric:function(t,e){return S(0,e,I)},isDefaultRequiredValue:function(t,e){return F(e)},isEmail:function(t,e){return S(0,e,q)},isEmptyString:function(t,e){return E(e)},isExisty:function(t,e){return y(e)},isFalse:function(t,e){return!1===e},isFloat:function(t,e){return S(0,e,x)},isInt:function(t,e){return S(0,e,R)},isLength:function(t,e,n){return!y(e)||E(e)||e.length===n},isNumeric:function(t,e){return function(t){return"number"==typeof t}(e)||S(0,e,C)},isSpecialWords:function(t,e){return S(0,e,O)},isTrue:function(t,e){return!0===e},isUndefined:function(t,e){return v(e)},isUrl:function(t,e){return S(0,e,D)},isWords:function(t,e){return S(0,e,j)},matchRegexp:S,maxLength:function(t,e,n){return!y(e)||e.length<=n},minLength:function(t,e,n){return!y(e)||E(e)||e.length>=n}},P=function(){throw new Error("Could not find Formsy Context Provider. Did you use withFormsy outside ?")},A=r.createContext({attachToForm:P,detachFromForm:P,isFormDisabled:!0,isValidValue:P,validate:P,runValidation:P}),T=function(t){return c(t)?t.split(/,(?![^{[]*[}\]])/g).reduce((function(t,e){var n=e.split(":"),r=n.shift();if((n=n.map((function(t){try{return JSON.parse(t)}catch(e){return t}}))).length>1)throw new Error("Formsy does not support multiple args on string validations. Use object format of validations instead.");var a=i({},t);return a[r]=!n.length||n[0],a}),{}):t||{}},N={innerRef:n.func,name:n.string.isRequired,required:n.oneOfType([n.bool,n.object,n.string]),validations:n.oneOfType([n.object,n.string]),value:n.any},k=function(t){function n(n){var r,a,o;return(r=t.call(this,n)||this).prevInputNames=null,r.componentDidMount=function(){r.prevInputNames=r.inputs.map((function(t){return t.props.name})),r.validateForm()},r.componentDidUpdate=function(t){var e=r.props,n=e.validationErrors,a=e.disabled;n&&s(n)&&Object.keys(n).length>0&&r.setInputValidationErrors(n);var o=r.inputs.map((function(t){return t.props.name}));r.prevInputNames&&!g(r.prevInputNames,o)&&(r.prevInputNames=o,r.validateForm()),a!==t.disabled&&r.setState((function(t){return i({},t,{contextValue:i({},t.contextValue,{isFormDisabled:a})})}))},r.getCurrentValues=function(){return r.inputs.reduce((function(t,e){return t[e.props.name]=V(e.state.value),t}),{})},r.getModel=function(){var t=r.getCurrentValues();return r.mapModel(t)},r.getPristineValues=function(){return r.inputs.reduce((function(t,e){var n=e.props;return t[n.name]=V(n.value),t}),{})},r.setFormPristine=function(t){r.setState({formSubmitted:!t}),r.inputs.forEach((function(e){e.setState({formSubmitted:!t,isPristine:t})}))},r.setInputValidationErrors=function(t){var e=r.props.preventExternalInvalidation,n=r.state.isValid;r.inputs.forEach((function(e){var n=e.props.name;e.setState({isValid:!(n in t),validationError:c(t[n])?[t[n]]:t[n]})})),!e&&n&&r.setFormValidState(!1)},r.setFormValidState=function(t){var e=r.props,n=e.onValid,i=e.onInvalid;r.setState({isValid:t}),t?n():i()},r.isValidValue=function(t,e){return r.runValidation(t,e).isValid},r.isFormDisabled=function(){return r.props.disabled},r.mapModel=function(t){var n=r.props.mapping;if(n)return n(t);var i={};return Object.keys(t).forEach((function(n){e.set(i,n,t[n])})),i},r.reset=function(t){r.setFormPristine(!0),r.resetModel(t)},r.resetInternal=function(t){var e=r.props.onReset;t.preventDefault(),r.reset(),e&&e()},r.resetModel=function(t){r.inputs.forEach((function(n){var r=n.props.name;t&&e.has(t,r)?n.setValue(e.get(t,r)):n.resetValue()})),r.validateForm()},r.runValidation=function(t,e){void 0===e&&(e=t.state.value);var n=r.props.validationErrors,i=t.props,a=i.validationError,o=i.validationErrors,u=i.name,s=r.getCurrentValues(),l=b(e,s,t.validations,M),d=b(e,s,t.requiredValidations,M),f=!!Object.keys(t.requiredValidations).length&&!!d.success.length,p=!(l.failed.length||n&&n[t.props.name]);return{isRequired:f,isValid:!f&&p,validationError:function(){if(p&&!f)return r.emptyArray;if(l.errors.length)return l.errors;if(n&&n[u])return c(n[u])?[n[u]]:n[u];if(f){var t=o[d.success[0]]||a;return t?[t]:null}return l.failed.length?l.failed.map((function(t){return o[t]?o[t]:a})).filter((function(t,e,n){return n.indexOf(t)===e})):void 0}()}},r.attachToForm=function(t){-1===r.inputs.indexOf(t)&&r.inputs.push(t),r.state.canChange&&(0,r.props.onChange)(r.getModel(),r.isChanged()),r.throttledValidateForm()},r.detachFromForm=function(t){var e=r.inputs.indexOf(t);-1!==e&&(r.inputs=r.inputs.slice(0,e).concat(r.inputs.slice(e+1))),r.validateForm()},r.isChanged=function(){return!g(r.getPristineValues(),r.getCurrentValues())},r.submit=function(t){var e=r.props,n=e.onSubmit,i=e.onValidSubmit,a=e.onInvalidSubmit,o=r.state.isValid;e.preventDefaultSubmit&&t&&t.preventDefault&&t.preventDefault(),r.setFormPristine(!1);var u=r.getModel();n(u,r.resetModel,r.updateInputsWithError,t),o?i(u,r.resetModel,r.updateInputsWithError,t):a(u,r.resetModel,r.updateInputsWithError,t)},r.updateInputsWithError=function(t,e){var n=r.props.preventExternalInvalidation,i=r.state.isValid;Object.entries(t).forEach((function(e){var i=e[0],a=e[1],o=r.inputs.find((function(t){return t.props.name===i}));if(!o)throw new Error("You are trying to update an input that does not exist. Verify errors object with input names. "+JSON.stringify(t));o.setState({isValid:n,validationError:c(a)?[a]:a})})),e&&i&&r.setFormValidState(!1)},r.updateInputsWithValue=function(t,n){r.inputs.forEach((function(r){var i=r.props.name;t&&e.has(t,i)&&r.setValue(e.get(t,i),n)}))},r.validate=function(t){r.state.canChange&&(0,r.props.onChange)(r.getModel(),r.isChanged());var e=r.runValidation(t);t.setState(e,r.validateForm)},r.validateForm=function(){var t=function(){var t=r.inputs.every((function(t){return t.state.isValid}));r.setFormValidState(t),r.setState({canChange:!0})};r.inputs.forEach((function(e,n){var i=r.runValidation(e);e.setState(i,n===r.inputs.length-1?t:null)})),r.inputs.length||r.setState({canChange:!0},t)},r.state={canChange:!1,isSubmitting:!1,isValid:!0,contextValue:{attachToForm:r.attachToForm,detachFromForm:r.detachFromForm,isFormDisabled:n.disabled,isValidValue:r.isValidValue,validate:r.validate,runValidation:r.runValidation}},r.inputs=[],r.emptyArray=[],r.throttledValidateForm=(a=r.validateForm,o=!0,function(){if(o){o=!1;for(var t=arguments.length,e=new Array(t),n=0;n=0||(i[n]=t[n]);return i}(t,["children","mapping","onChange","onInvalid","onInvalidSubmit","onReset","onSubmit","onValid","onValidSubmit","preventDefaultSubmit","preventExternalInvalidation","validationErrors","disabled","formElement"]);return r.createElement(A.Provider,{value:this.state.contextValue},r.createElement(a,i({onReset:this.resetInternal,onSubmit:this.submit},o,{disabled:n}),e))},n}(r.Component);k.displayName="Formsy",k.propTypes={disabled:n.bool,mapping:n.func,formElement:n.oneOfType([n.string,n.object,n.func]),onChange:n.func,onInvalid:n.func,onInvalidSubmit:n.func,onReset:n.func,onSubmit:n.func,onValid:n.func,onValidSubmit:n.func,preventDefaultSubmit:n.bool,preventExternalInvalidation:n.bool,validationErrors:n.object},k.defaultProps={disabled:!1,mapping:null,onChange:h,onInvalid:h,onInvalidSubmit:h,onReset:h,onSubmit:h,onValid:h,onValidSubmit:h,preventDefaultSubmit:!0,preventExternalInvalidation:!1,validationErrors:{},formElement:"form"},exports.addValidationRule=function(t,e){M[t]=e},exports.default=k,exports.propTypes=N,exports.validationRules=M,exports.withFormsy=function(t){var e,n=function(e){function n(t){var n;(n=e.call(this,t)||this).getErrorMessage=function(){var t=n.getErrorMessages();return t.length?t[0]:null},n.getErrorMessages=function(){var t=n.state.validationError;return(!n.isValid()||n.showRequired())&&t||[]},n.getValue=function(){return n.state.value},n.setValidations=function(t,e){n.validations=T(t)||{},n.requiredValidations=!0===e?{isDefaultRequiredValue:e}:T(e)},n.setValue=function(t,e){void 0===e&&(e=!0);var r=n.props.validate;e?n.setState({value:t,isPristine:!1},(function(){r(o(n))})):n.setState({value:t})},n.hasValue=function(){return F(n.state.value)},n.isFormDisabled=function(){return n.props.isFormDisabled},n.isFormSubmitted=function(){return n.state.formSubmitted},n.isPristine=function(){return n.state.isPristine},n.isRequired=function(){return!!n.props.required},n.isValid=function(){return n.state.isValid},n.isValidValue=function(t){return n.props.isValidValue(o(n),t)},n.resetValue=function(){var t=n.props.validate;n.setState({value:n.state.pristineValue,isPristine:!0},(function(){t(o(n))}))},n.showError=function(){return!n.showRequired()&&!n.isValid()},n.showRequired=function(){return n.state.isRequired};var r=t.runValidation,a=t.validations,u=t.required;return n.state={value:t.value},n.setValidations(a,u),n.state=i({formSubmitted:!1,isPristine:!0,pristineValue:t.value,value:t.value},r(o(n),t.value)),n}a(n,e);var u=n.prototype;return u.componentDidMount=function(){var t=this.props,e=t.attachToForm;if(!t.name)throw new Error("Form Input requires a name property when used");e(this)},u.shouldComponentUpdate=function(t,e){var n=this.state,r=function(t,e){return Object.keys(t).some((function(n){return t[n]!==e[n]}))},i=r(this.props,t),a=r(n,e);return i||a},u.componentDidUpdate=function(t){var e=this.props,n=e.value,r=e.validations,i=e.required,a=e.validate;g(n,t.value)||this.setValue(n),g(r,t.validations)&&g(i,t.required)||(this.setValidations(r,i),a(this))},u.componentWillUnmount=function(){(0,this.props.detachFromForm)(this)},u.render=function(){var e=this.props.innerRef,n=i({},this.props,{errorMessage:this.getErrorMessage(),errorMessages:this.getErrorMessages(),hasValue:this.hasValue(),isFormDisabled:this.isFormDisabled(),isFormSubmitted:this.isFormSubmitted(),isPristine:this.isPristine(),isRequired:this.isRequired(),isValid:this.isValid(),isValidValue:this.isValidValue,resetValue:this.resetValue,setValidations:this.setValidations,setValue:this.setValue,showError:this.showError(),showRequired:this.showRequired(),value:this.getValue()});return e&&(n.ref=e),r.createElement(t,n)},n}(r.Component);return n.displayName="Formsy("+((e=t).displayName||e.name||(c(e)?e:"Component"))+")",n.propTypes=N,n.defaultProps={innerRef:null,required:!1,validationError:"",validationErrors:{},validations:null,value:t.defaultValue},function(t){return r.createElement(A.Consumer,null,(function(e){return r.createElement(n,i({},t,e))}))}};
+"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=require("lodash"),n=t(require("prop-types")),r=t(require("react"));function i(){return(i=Object.assign?Object.assign.bind():function(t){for(var e=1;e()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/i,q=/^(?:[-+]?(?:\d+))?(?:\.\d*)?(?:[eE][+-]?(?:\d+))?$/,x=/^(?:[-+]?(?:0|[1-9]\d*))$/,R=/^[-+]?(?:\d*[.])?\d+$/,j=/^[\sA-ZÀ-ÖØ-öø-ÿ]+$/i,C=/^(?:\w+:)?\/\/([^\s.]+\.\S{2}|localhost[:?\d]*)\S*$/i,D=/^[A-Z\s]+$/i,P={equals:function(t,e,n){return!y(e)||E(e)||e===n},equalsField:function(t,e,n){return e===t[n]},isAlpha:function(t,e){return S(0,e,w)},isAlphanumeric:function(t,e){return S(0,e,O)},isDefaultRequiredValue:function(t,e){return F(e)},isEmail:function(t,e){return S(0,e,I)},isEmptyString:function(t,e){return E(e)},isExisty:function(t,e){return y(e)},isFalse:function(t,e){return!1===e},isFloat:function(t,e){return S(0,e,q)},isInt:function(t,e){return S(0,e,x)},isLength:function(t,e,n){return!y(e)||E(e)||e.length===n},isNumeric:function(t,e){return function(t){return"number"==typeof t}(e)||S(0,e,R)},isSpecialWords:function(t,e){return S(0,e,j)},isTrue:function(t,e){return!0===e},isUndefined:function(t,e){return v(e)},isUrl:function(t,e){return S(0,e,C)},isWords:function(t,e){return S(0,e,D)},matchRegexp:S,maxLength:function(t,e,n){return!y(e)||e.length<=n},minLength:function(t,e,n){return!y(e)||E(e)||e.length>=n}},M=function(){throw new Error("Could not find Formsy Context Provider. Did you use withFormsy outside ?")},A=r.createContext({attachToForm:M,detachFromForm:M,isFormDisabled:!0,isValidValue:M,validate:M,runValidation:M}),T=function(t){return c(t)?t.split(/,(?![^{[]*[}\]])/g).reduce((function(t,e){var n=e.split(":"),r=n.shift();if((n=n.map((function(t){try{return JSON.parse(t)}catch(e){return t}}))).length>1)throw new Error("Formsy does not support multiple args on string validations. Use object format of validations instead.");var o=i({},t);return o[r]=!n.length||n[0],o}),{}):t||{}},N={innerRef:n.func,name:n.string.isRequired,required:n.oneOfType([n.bool,n.object,n.string]),validations:n.oneOfType([n.object,n.string]),value:n.any},k=["children","mapping","onChange","onInvalid","onInvalidSubmit","onReset","onSubmit","onValid","onValidSubmit","preventDefaultSubmit","preventExternalInvalidation","validationErrors","disabled","formElement"],$=function(t){function n(n){var r,o,a;return(r=t.call(this,n)||this).prevInputNames=null,r.componentDidMount=function(){r.prevInputNames=r.inputs.map((function(t){return t.props.name})),r.validateForm()},r.componentDidUpdate=function(t){var e=r.props,n=e.validationErrors,o=e.disabled;n&&s(n)&&Object.keys(n).length>0&&r.setInputValidationErrors(n);var a=r.inputs.map((function(t){return t.props.name}));r.prevInputNames&&!g(r.prevInputNames,a)&&(r.prevInputNames=a,r.validateForm()),o!==t.disabled&&r.setState((function(t){return i({},t,{contextValue:i({},t.contextValue,{isFormDisabled:o})})}))},r.getCurrentValues=function(){return r.inputs.reduce((function(t,e){return t[e.props.name]=V(e.state.value),t}),{})},r.getModel=function(){var t=r.getCurrentValues();return r.mapModel(t)},r.getPristineValues=function(){return r.inputs.reduce((function(t,e){var n=e.props;return t[n.name]=V(n.value),t}),{})},r.setFormPristine=function(t){r.setState({formSubmitted:!t}),r.inputs.forEach((function(e){e.setState({formSubmitted:!t,isPristine:t})}))},r.setInputValidationErrors=function(t){var e=r.props.preventExternalInvalidation,n=r.state.isValid;r.inputs.forEach((function(e){var n=e.props.name;e.setState({isValid:!(n in t),validationError:c(t[n])?[t[n]]:t[n]})})),!e&&n&&r.setFormValidState(!1)},r.setFormValidState=function(t){var e=r.props,n=e.onValid,i=e.onInvalid;r.setState({isValid:t}),t?n():i()},r.isValidValue=function(t,e){return r.runValidation(t,e).isValid},r.isFormDisabled=function(){return r.props.disabled},r.mapModel=function(t){var n=r.props.mapping;if(n)return n(t);var i={};return Object.keys(t).forEach((function(n){e.set(i,n,t[n])})),i},r.reset=function(t){r.setFormPristine(!0),r.resetModel(t)},r.resetInternal=function(t){var e=r.props.onReset;t.preventDefault(),r.reset(),e&&e()},r.resetModel=function(t){r.inputs.forEach((function(n){var r=n.props.name;t&&e.has(t,r)?n.setValue(e.get(t,r)):n.resetValue()})),r.validateForm()},r.runValidation=function(t,e){void 0===e&&(e=t.state.value);var n=r.props.validationErrors,i=t.props,o=i.validationError,a=i.validationErrors,u=i.name,s=r.getCurrentValues(),l=b(e,s,t.validations,P),d=b(e,s,t.requiredValidations,P),f=!!Object.keys(t.requiredValidations).length&&!!d.success.length,p=!(l.failed.length||n&&n[t.props.name]);return{isRequired:f,isValid:!f&&p,validationError:function(){if(p&&!f)return r.emptyArray;if(l.errors.length)return l.errors;if(n&&n[u])return c(n[u])?[n[u]]:n[u];if(f){var t=a[d.success[0]]||o;return t?[t]:null}return l.failed.length?l.failed.map((function(t){return a[t]?a[t]:o})).filter((function(t,e,n){return n.indexOf(t)===e})):void 0}()}},r.attachToForm=function(t){-1===r.inputs.indexOf(t)&&r.inputs.push(t),r.state.canChange&&(0,r.props.onChange)(r.getModel(),r.isChanged()),r.throttledValidateForm()},r.detachFromForm=function(t){var e=r.inputs.indexOf(t);-1!==e&&(r.inputs=r.inputs.slice(0,e).concat(r.inputs.slice(e+1))),r.validateForm()},r.isChanged=function(){return!g(r.getPristineValues(),r.getCurrentValues())},r.submit=function(t){var e=r.props,n=e.onSubmit,i=e.onValidSubmit,o=e.onInvalidSubmit,a=r.state.isValid;e.preventDefaultSubmit&&t&&t.preventDefault&&t.preventDefault(),r.setFormPristine(!1);var u=r.getModel();n(u,r.resetModel,r.updateInputsWithError,t),a?i(u,r.resetModel,r.updateInputsWithError,t):o(u,r.resetModel,r.updateInputsWithError,t)},r.updateInputsWithError=function(t,e){var n=r.props.preventExternalInvalidation,i=r.state.isValid;Object.entries(t).forEach((function(e){var i=e[0],o=e[1],a=r.inputs.find((function(t){return t.props.name===i}));if(!a)throw new Error("You are trying to update an input that does not exist. Verify errors object with input names. "+JSON.stringify(t));a.setState({isValid:n,validationError:c(o)?[o]:o})})),e&&i&&r.setFormValidState(!1)},r.updateInputsWithValue=function(t,n){r.inputs.forEach((function(r){var i=r.props.name;t&&e.has(t,i)&&r.setValue(e.get(t,i),n)}))},r.validate=function(t){r.state.canChange&&(0,r.props.onChange)(r.getModel(),r.isChanged());var e=r.runValidation(t);t.setState(e,r.validateForm)},r.validateForm=function(){var t=function(){var t=r.inputs.every((function(t){return t.state.isValid}));r.setFormValidState(t),r.setState({canChange:!0})};r.inputs.forEach((function(e,n){var i=r.runValidation(e);e.setState(i,n===r.inputs.length-1?t:null)})),r.inputs.length||r.setState({canChange:!0},t)},r.state={canChange:!1,isSubmitting:!1,isValid:!0,contextValue:{attachToForm:r.attachToForm,detachFromForm:r.detachFromForm,isFormDisabled:n.disabled,isValidValue:r.isValidValue,validate:r.validate,runValidation:r.runValidation}},r.inputs=[],r.emptyArray=[],r.throttledValidateForm=(o=r.validateForm,a=!0,function(){if(a){a=!1;for(var t=arguments.length,e=new Array(t),n=0;n=0||(i[n]=t[n]);return i}(t,k);return r.createElement(A.Provider,{value:this.state.contextValue},r.createElement(o,i({onReset:this.resetInternal,onSubmit:this.submit},a,{disabled:n}),e))},n}(r.Component);$.displayName="Formsy",$.propTypes={disabled:n.bool,mapping:n.func,formElement:n.oneOfType([n.string,n.object,n.func]),onChange:n.func,onInvalid:n.func,onInvalidSubmit:n.func,onReset:n.func,onSubmit:n.func,onValid:n.func,onValidSubmit:n.func,preventDefaultSubmit:n.bool,preventExternalInvalidation:n.bool,validationErrors:n.object},$.defaultProps={disabled:!1,mapping:null,onChange:h,onInvalid:h,onInvalidSubmit:h,onReset:h,onSubmit:h,onValid:h,onValidSubmit:h,preventDefaultSubmit:!0,preventExternalInvalidation:!1,validationErrors:{},formElement:"form"},exports.addValidationRule=function(t,e){P[t]=e},exports.default=$,exports.propTypes=N,exports.validationRules=P,exports.withFormsy=function(t){var e,n=function(e){function n(t){var n;(n=e.call(this,t)||this).getErrorMessage=function(){var t=n.getErrorMessages();return t.length?t[0]:null},n.getErrorMessages=function(){var t=n.state.validationError;return(!n.isValid()||n.showRequired())&&t||[]},n.getValue=function(){return n.state.value},n.setValidations=function(t,e){n.validations=T(t)||{},n.requiredValidations=!0===e?{isDefaultRequiredValue:e}:T(e)},n.setValue=function(t,e){void 0===e&&(e=!0);var r=n.props.validate;e?n.setState({value:t,isPristine:!1},(function(){r(a(n))})):n.setState({value:t})},n.hasValue=function(){return F(n.state.value)},n.isFormDisabled=function(){return n.props.isFormDisabled},n.isFormSubmitted=function(){return n.state.formSubmitted},n.isPristine=function(){return n.state.isPristine},n.isRequired=function(){return!!n.props.required},n.isValid=function(){return n.state.isValid},n.isValidValue=function(t){return n.props.isValidValue(a(n),t)},n.resetValue=function(){var t=n.props.validate;n.setState({value:n.state.pristineValue,isPristine:!0},(function(){t(a(n))}))},n.showError=function(){return!n.showRequired()&&!n.isValid()},n.showRequired=function(){return n.state.isRequired};var r=t.runValidation,o=t.validations,u=t.required;return n.state={value:t.value},n.setValidations(o,u),n.state=i({formSubmitted:!1,isPristine:!0,pristineValue:t.value,value:t.value},r(a(n),t.value)),n}o(n,e);var u=n.prototype;return u.componentDidMount=function(){var t=this.props,e=t.attachToForm;if(!t.name)throw new Error("Form Input requires a name property when used");e(this)},u.shouldComponentUpdate=function(t,e){var n=this.state,r=function(t,e){return Object.keys(t).some((function(n){return t[n]!==e[n]}))},i=r(this.props,t),o=r(n,e);return i||o},u.componentDidUpdate=function(t){var e=this.props,n=e.value,r=e.validations,i=e.required,o=e.validate;g(n,t.value)||this.setValue(n),g(r,t.validations)&&g(i,t.required)||(this.setValidations(r,i),o(this))},u.componentWillUnmount=function(){(0,this.props.detachFromForm)(this)},u.render=function(){var e=this.props.innerRef,n=i({},this.props,{errorMessage:this.getErrorMessage(),errorMessages:this.getErrorMessages(),hasValue:this.hasValue(),isFormDisabled:this.isFormDisabled(),isFormSubmitted:this.isFormSubmitted(),isPristine:this.isPristine(),isRequired:this.isRequired(),isValid:this.isValid(),isValidValue:this.isValidValue,resetValue:this.resetValue,setValidations:this.setValidations,setValue:this.setValue,showError:this.showError(),showRequired:this.showRequired(),value:this.getValue()});return e&&(n.ref=e),r.createElement(t,n)},n}(r.Component);return n.displayName="Formsy("+((e=t).displayName||e.name||(c(e)?e:"Component"))+")",n.propTypes=N,n.defaultProps={innerRef:null,required:!1,validationError:"",validationErrors:{},validations:null,value:t.defaultValue},function(t){return r.createElement(A.Consumer,null,(function(e){return r.createElement(n,i({},t,e))}))}};
//# sourceMappingURL=formsy-react.cjs.production.min.js.map
diff --git a/dist/formsy-react.cjs.production.min.js.map b/dist/formsy-react.cjs.production.min.js.map
index b0998014..14219f08 100644
--- a/dist/formsy-react.cjs.production.min.js.map
+++ b/dist/formsy-react.cjs.production.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"formsy-react.cjs.production.min.js","sources":["../src/utils.ts","../src/validationRules.ts","../src/FormsyContext.ts","../src/withFormsy.ts","../src/Formsy.ts"],"sourcesContent":["import { isPlainObject } from 'lodash';\n\nimport { ValidationError, Validations, Values } from './interfaces';\n\nexport function isArray(value: unknown): value is unknown[] {\n return Array.isArray(value);\n}\n\nexport function isObject(value: unknown): value is object {\n return isPlainObject(value);\n}\n\nexport function isTypeUndefined(value: unknown): value is undefined {\n return typeof value === 'undefined';\n}\n\nexport function isDate(value: unknown): value is Date {\n return value instanceof Date;\n}\n\nexport function isFunction(value: unknown): value is Function {\n return value !== null && typeof value === 'function';\n}\n\nexport function isString(value: unknown): value is string {\n return typeof value === 'string';\n}\n\nexport function isNumber(value: unknown): value is number {\n return typeof value === 'number';\n}\n\nexport function isRegex(value: unknown): value is RegExp {\n return value instanceof RegExp;\n}\n\nexport function isValueStringEmpty(value: string): boolean {\n return value === '';\n}\n\nexport function isValueNullOrUndefined(value: unknown): boolean {\n return value === null || value === undefined;\n}\n\nexport function isValueUndefined(value: unknown): boolean {\n return value === undefined;\n}\n\nexport function noop() {\n // do nothing.\n}\n\nexport function protectAgainstParamReassignment(value: unknown) {\n // Clone objects to avoid accidental param reassignment\n if (isObject(value)) return { ...value };\n if (isArray(value)) return [...value];\n return value;\n}\n\nexport function isSame(a: unknown, b: unknown) {\n if (typeof a !== typeof b) {\n return false;\n }\n\n if (isArray(a) && isArray(b)) {\n if (a.length !== b.length) {\n return false;\n }\n\n return a.every((item, index) => isSame(item, b[index]));\n }\n\n if (isFunction(a) && isFunction(b)) {\n return a.toString() === b.toString();\n }\n\n if (isDate(a) && isDate(b)) {\n return a.toString() === b.toString();\n }\n\n if (isObject(a) && isObject(b)) {\n if (Object.keys(a).length !== Object.keys(b).length) {\n return false;\n }\n\n return Object.keys(a).every((key) => isSame(a[key], b[key]));\n }\n\n if (isRegex(a) && isRegex(b)) {\n return a.toString() === b.toString();\n }\n\n return a === b;\n}\n\ninterface RulesResult {\n errors: ValidationError[];\n failed: string[];\n success: string[];\n}\n\nexport function runRules(\n value: V,\n currentValues: Values,\n validations: Validations,\n validationRules: Validations,\n) {\n const results: RulesResult = {\n errors: [],\n failed: [],\n success: [],\n };\n\n Object.keys(validations).forEach((validationName) => {\n const validationsVal = validations[validationName];\n const validationRulesVal = validationRules[validationName];\n const addToResults = (validation) => {\n if (isString(validation)) {\n results.errors.push(validation);\n results.failed.push(validationName);\n } else if (!validation) {\n results.failed.push(validationName);\n } else {\n results.success.push(validationName);\n }\n };\n\n if (validationRulesVal && isFunction(validationsVal)) {\n throw new Error(`Formsy does not allow you to override default validations: ${validationName}`);\n }\n\n if (!validationRulesVal && !isFunction(validationsVal)) {\n throw new Error(`Formsy does not have the validation rule: ${validationName}`);\n }\n\n if (isFunction(validationsVal)) {\n return addToResults(validationsVal(currentValues, value));\n }\n\n return addToResults(validationRulesVal(currentValues, value, validationsVal));\n });\n\n return results;\n}\n\nexport function throttle(callback, interval) {\n let enableCall = true;\n\n return function (...args) {\n if (!enableCall) return;\n\n enableCall = false;\n callback.apply(this, args);\n setTimeout(() => (enableCall = true), interval);\n };\n}\n","import { ValidationFunction, Values } from './interfaces';\nimport {\n isNumber,\n isString,\n isTypeUndefined,\n isValueNullOrUndefined,\n isValueStringEmpty,\n isValueUndefined,\n} from './utils';\n\nexport function isExisty(value: V) {\n return !isValueNullOrUndefined(value);\n}\n\nexport function isEmpty(value: V) {\n if (isString(value)) {\n return isValueStringEmpty(value);\n }\n if (isTypeUndefined(value)) {\n return false;\n }\n return isValueUndefined(value);\n}\n\nexport function isDefaultRequiredValue(value: unknown) {\n return isString(value) ? isValueStringEmpty(value) : isValueNullOrUndefined(value);\n}\n\nexport function matchRegexp(_values: Values, value: V, regexp: RegExp) {\n return !isExisty(value) || isEmpty(value) || regexp.test(`${value}`);\n}\n\ninterface Validations {\n [key: string]: ValidationFunction;\n}\n\nconst REGEX_PATTERNS = {\n ALPHA: /^[A-Z]+$/i,\n ALPHANUMERIC: /^[0-9A-Z]+$/i,\n EMAIL:\n /^(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/i, // from http://emailregex.com/\n FLOAT: /^(?:[-+]?(?:\\d+))?(?:\\.\\d*)?(?:[eE][+-]?(?:\\d+))?$/,\n INT: /^(?:[-+]?(?:0|[1-9]\\d*))$/,\n NUMERIC: /^[-+]?(?:\\d*[.])?\\d+$/,\n SPECIAL_WORDS: /^[\\sA-ZÀ-ÖØ-öø-ÿ]+$/i,\n URL: /^(?:\\w+:)?\\/\\/([^\\s.]+\\.\\S{2}|localhost[:?\\d]*)\\S*$/i,\n WORDS: /^[A-Z\\s]+$/i,\n};\n\nconst validations: Validations = {\n equals: (_values, value: V, eql: V) => !isExisty(value) || isEmpty(value) || value === eql,\n equalsField: (values, value: V, field: string) => value === values[field],\n isAlpha: (values, value: V) => matchRegexp(values, value, REGEX_PATTERNS.ALPHA),\n isAlphanumeric: (values, value: V) => matchRegexp(values, value, REGEX_PATTERNS.ALPHANUMERIC),\n isDefaultRequiredValue: (_values, value: V) => isDefaultRequiredValue(value),\n isEmail: (values, value: string) => matchRegexp(values, value, REGEX_PATTERNS.EMAIL),\n isEmptyString: (_values, value: string) => isEmpty(value),\n isExisty: (_values, value: V) => isExisty(value),\n isFalse: (_values, value: boolean | string) => value === false,\n isFloat: (values, value: V) => matchRegexp(values, value, REGEX_PATTERNS.FLOAT),\n isInt: (values, value: V) => matchRegexp(values, value, REGEX_PATTERNS.INT),\n isLength: (_values, value: string, length: number) => !isExisty(value) || isEmpty(value) || value.length === length,\n isNumeric: (values, value: V) => isNumber(value) || matchRegexp(values, value, REGEX_PATTERNS.NUMERIC),\n isSpecialWords: (values, value: V) => matchRegexp(values, value, REGEX_PATTERNS.SPECIAL_WORDS),\n isTrue: (_values, value: boolean | string) => value === true,\n isUndefined: (_values, value: V) => isValueUndefined(value),\n isUrl: (values, value: V) => matchRegexp(values, value, REGEX_PATTERNS.URL),\n isWords: (values, value: V) => matchRegexp(values, value, REGEX_PATTERNS.WORDS),\n matchRegexp,\n maxLength: (_values, value: string, length: number) => !isExisty(value) || value.length <= length,\n minLength: (_values, value: string, length: number) => !isExisty(value) || isEmpty(value) || value.length >= length,\n};\n\nexport const addValidationRule = (name: string, func: ValidationFunction) => {\n validations[name] = func;\n};\n\nexport default validations;\n","import React from 'react';\nimport { FormsyContextInterface } from './interfaces';\n\nconst noFormsyErrorMessage = 'Could not find Formsy Context Provider. Did you use withFormsy outside ?';\n\nconst throwNoFormsyProvider = () => {\n // istanbul ignore next\n throw new Error(noFormsyErrorMessage);\n};\n\nconst defaultValue = {\n attachToForm: throwNoFormsyProvider,\n detachFromForm: throwNoFormsyProvider,\n isFormDisabled: true,\n isValidValue: throwNoFormsyProvider,\n validate: throwNoFormsyProvider,\n runValidation: throwNoFormsyProvider,\n};\n\nexport default React.createContext(defaultValue);\n","import PropTypes from 'prop-types';\nimport React from 'react';\nimport FormsyContext from './FormsyContext';\nimport {\n ComponentWithStaticAttributes,\n FormsyContextInterface,\n RequiredValidation,\n ValidationError,\n Validations,\n WrappedComponentClass,\n} from './interfaces';\n\nimport * as utils from './utils';\nimport { isString } from './utils';\nimport { isDefaultRequiredValue } from './validationRules';\n\n/* eslint-disable react/default-props-match-prop-types */\n\nconst convertValidationsToObject = (validations: false | Validations): Validations => {\n if (isString(validations)) {\n return validations.split(/,(?![^{[]*[}\\]])/g).reduce((validationsAccumulator, validation) => {\n let args: string[] = validation.split(':');\n const validateMethod: string = args.shift();\n\n args = args.map((arg) => {\n try {\n return JSON.parse(arg);\n } catch (e) {\n return arg; // It is a string if it can not parse it\n }\n });\n\n if (args.length > 1) {\n throw new Error(\n 'Formsy does not support multiple args on string validations. Use object format of validations instead.',\n );\n }\n\n // Avoid parameter reassignment\n const validationsAccumulatorCopy: Validations = { ...validationsAccumulator };\n validationsAccumulatorCopy[validateMethod] = args.length ? args[0] : true;\n return validationsAccumulatorCopy;\n }, {});\n }\n\n return validations || {};\n};\n\nexport const propTypes = {\n innerRef: PropTypes.func,\n name: PropTypes.string.isRequired,\n required: PropTypes.oneOfType([PropTypes.bool, PropTypes.object, PropTypes.string]),\n validations: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),\n value: PropTypes.any, // eslint-disable-line react/forbid-prop-types\n};\n\nexport interface WrapperProps {\n innerRef?: (ref: React.Ref) => void;\n name: string;\n required?: RequiredValidation;\n validationError?: ValidationError;\n validationErrors?: { [key: string]: ValidationError };\n validations?: Validations;\n value?: V;\n}\n\nexport interface WrapperState {\n [key: string]: unknown;\n\n formSubmitted: boolean;\n isPristine: boolean;\n isRequired: boolean;\n isValid: boolean;\n pristineValue: V;\n validationError: ValidationError[];\n value: V;\n}\n\nexport interface InjectedProps {\n errorMessage: ValidationError;\n errorMessages: ValidationError[];\n hasValue: boolean;\n isFormDisabled: boolean;\n isFormSubmitted: boolean;\n isPristine: boolean;\n isRequired: boolean;\n isValid: boolean;\n isValidValue: (value: V) => boolean;\n ref?: React.Ref;\n resetValue: () => void;\n setValidations: (validations: Validations, required: RequiredValidation) => void;\n setValue: (value: V, validate?: boolean) => void;\n showError: boolean;\n showRequired: boolean;\n}\n\nexport interface WrapperInstanceMethods {\n getErrorMessage: () => null | ValidationError;\n getErrorMessages: () => ValidationError[];\n getValue: () => V;\n isFormDisabled: () => boolean;\n isFormSubmitted: () => boolean;\n isValid: () => boolean;\n isValidValue: (value: V) => boolean;\n setValue: (value: V, validate?: boolean) => void;\n}\n\nexport type PassDownProps = WrapperProps & InjectedProps;\n\nfunction getDisplayName(component: WrappedComponentClass) {\n return component.displayName || component.name || (utils.isString(component) ? component : 'Component');\n}\n\nexport default function withFormsy(\n WrappedComponent: React.ComponentType>,\n): React.ComponentType, keyof InjectedProps>> {\n class WithFormsyWrapper\n extends React.Component & FormsyContextInterface, WrapperState>\n implements WrapperInstanceMethods\n {\n public validations?: Validations;\n\n public requiredValidations?: Validations;\n\n public static displayName = `Formsy(${getDisplayName(WrappedComponent)})`;\n\n public static propTypes: any = propTypes;\n\n public static defaultProps: any = {\n innerRef: null,\n required: false,\n validationError: '',\n validationErrors: {},\n validations: null,\n value: (WrappedComponent as ComponentWithStaticAttributes).defaultValue,\n };\n\n public constructor(props) {\n super(props);\n const { runValidation, validations, required, value } = props;\n\n this.state = { value } as any;\n\n this.setValidations(validations, required);\n\n this.state = {\n formSubmitted: false,\n isPristine: true,\n pristineValue: props.value,\n value: props.value,\n ...runValidation(this, props.value),\n };\n }\n\n public componentDidMount() {\n const { name, attachToForm } = this.props;\n\n if (!name) {\n throw new Error('Form Input requires a name property when used');\n }\n\n attachToForm(this);\n }\n\n public shouldComponentUpdate(nextProps, nextState) {\n const { props, state } = this;\n const isChanged = (a: object, b: object): boolean => Object.keys(a).some((k) => a[k] !== b[k]);\n const isPropsChanged = isChanged(props, nextProps);\n const isStateChanged = isChanged(state, nextState);\n\n return isPropsChanged || isStateChanged;\n }\n\n public componentDidUpdate(prevProps) {\n const { value, validations, required, validate } = this.props;\n\n // If the value passed has changed, set it. If value is not passed it will\n // internally update, and this will never run\n if (!utils.isSame(value, prevProps.value)) {\n this.setValue(value);\n }\n\n // If validations or required is changed, run a new validation\n if (!utils.isSame(validations, prevProps.validations) || !utils.isSame(required, prevProps.required)) {\n this.setValidations(validations, required);\n validate(this);\n }\n }\n\n // Detach it when component unmounts\n public componentWillUnmount() {\n const { detachFromForm } = this.props;\n detachFromForm(this);\n }\n\n public getErrorMessage = (): ValidationError | null => {\n const messages = this.getErrorMessages();\n return messages.length ? messages[0] : null;\n };\n\n public getErrorMessages = (): ValidationError[] => {\n const { validationError } = this.state;\n\n if (!this.isValid() || this.showRequired()) {\n return validationError || [];\n }\n return [];\n };\n\n // eslint-disable-next-line react/destructuring-assignment\n public getValue = (): V => this.state.value;\n\n public setValidations = (validations: Validations, required: RequiredValidation): void => {\n // Add validations to the store itself as the props object can not be modified\n this.validations = convertValidationsToObject(validations) || {};\n this.requiredValidations =\n required === true ? { isDefaultRequiredValue: required } : convertValidationsToObject(required);\n };\n\n // By default, we validate after the value has been set.\n // A user can override this and pass a second parameter of `false` to skip validation.\n public setValue = (value: V, validate = true): void => {\n const { validate: validateForm } = this.props;\n\n if (!validate) {\n this.setState({ value });\n } else {\n this.setState(\n {\n value,\n isPristine: false,\n },\n () => {\n validateForm(this);\n },\n );\n }\n };\n\n // eslint-disable-next-line react/destructuring-assignment\n public hasValue = () => {\n const { value } = this.state;\n return isDefaultRequiredValue(value);\n };\n\n // eslint-disable-next-line react/destructuring-assignment\n public isFormDisabled = (): boolean => this.props.isFormDisabled;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isFormSubmitted = (): boolean => this.state.formSubmitted;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isPristine = (): boolean => this.state.isPristine;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isRequired = (): boolean => !!this.props.required;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isValid = (): boolean => this.state.isValid;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isValidValue = (value: V) => this.props.isValidValue(this, value);\n\n public resetValue = () => {\n const { pristineValue } = this.state;\n const { validate } = this.props;\n\n this.setState(\n {\n value: pristineValue,\n isPristine: true,\n },\n () => {\n validate(this);\n },\n );\n };\n\n public showError = (): boolean => !this.showRequired() && !this.isValid();\n\n // eslint-disable-next-line react/destructuring-assignment\n public showRequired = (): boolean => this.state.isRequired;\n\n public render() {\n const { innerRef } = this.props;\n const propsForElement: T & PassDownProps = {\n ...this.props,\n errorMessage: this.getErrorMessage(),\n errorMessages: this.getErrorMessages(),\n hasValue: this.hasValue(),\n isFormDisabled: this.isFormDisabled(),\n isFormSubmitted: this.isFormSubmitted(),\n isPristine: this.isPristine(),\n isRequired: this.isRequired(),\n isValid: this.isValid(),\n isValidValue: this.isValidValue,\n resetValue: this.resetValue,\n setValidations: this.setValidations,\n setValue: this.setValue,\n showError: this.showError(),\n showRequired: this.showRequired(),\n value: this.getValue(),\n };\n\n if (innerRef) {\n propsForElement.ref = innerRef;\n }\n\n return React.createElement(WrappedComponent, propsForElement);\n }\n }\n\n // eslint-disable-next-line react/display-name\n return (props) =>\n React.createElement(FormsyContext.Consumer, null, (contextValue) => {\n return React.createElement(WithFormsyWrapper, { ...props, ...contextValue });\n });\n}\n","/* eslint-disable react/no-unused-state, react/default-props-match-prop-types */\nimport { get, has, set } from 'lodash';\nimport PropTypes from 'prop-types';\nimport React from 'react';\nimport FormsyContext from './FormsyContext';\nimport {\n FormsyContextInterface,\n IModel,\n InputComponent,\n IResetModel,\n IUpdateInputsWithError,\n IUpdateInputsWithValue,\n ValidationError,\n} from './interfaces';\nimport { throttle, isObject, isString } from './utils';\nimport * as utils from './utils';\nimport validationRules from './validationRules';\nimport { PassDownProps } from './withFormsy';\n\ntype FormHTMLAttributesCleaned = Omit, 'onChange' | 'onSubmit'>;\n\ntype OnSubmitCallback = (\n model: IModel,\n resetModel: IResetModel,\n updateInputsWithError: IUpdateInputsWithError,\n event: React.SyntheticEvent,\n) => void;\n\ntype FormElementType =\n | string\n | React.ComponentType<{\n onReset?: (e: React.SyntheticEvent) => void;\n onSubmit?: (e: React.SyntheticEvent) => void;\n disabled?: boolean;\n children?: React.ReactChildren;\n }>;\n\nexport interface FormsyProps extends FormHTMLAttributesCleaned {\n disabled: boolean;\n mapping: null | ((model: IModel) => IModel);\n onChange: (model: IModel, isChanged: boolean) => void;\n onInvalid: () => void;\n onReset?: () => void;\n onSubmit?: OnSubmitCallback;\n onValidSubmit?: OnSubmitCallback;\n onInvalidSubmit: OnSubmitCallback;\n onValid: () => void;\n preventDefaultSubmit?: boolean;\n preventExternalInvalidation?: boolean;\n validationErrors?: null | object;\n formElement?: FormElementType;\n}\n\nexport interface FormsyState {\n canChange: boolean;\n contextValue: FormsyContextInterface;\n formSubmitted?: boolean;\n isPristine?: boolean;\n isSubmitting: boolean;\n isValid: boolean;\n}\n\nconst ONE_RENDER_FRAME = 66;\n\nexport class Formsy extends React.Component {\n public inputs: InstanceType>[];\n\n public emptyArray: any[];\n\n public prevInputNames: any[] | null = null;\n\n public static displayName = 'Formsy';\n\n public static propTypes = {\n disabled: PropTypes.bool,\n mapping: PropTypes.func,\n formElement: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.func]),\n onChange: PropTypes.func,\n onInvalid: PropTypes.func,\n onInvalidSubmit: PropTypes.func,\n onReset: PropTypes.func,\n onSubmit: PropTypes.func,\n onValid: PropTypes.func,\n onValidSubmit: PropTypes.func,\n preventDefaultSubmit: PropTypes.bool,\n preventExternalInvalidation: PropTypes.bool,\n validationErrors: PropTypes.object, // eslint-disable-line\n };\n\n public static defaultProps: Partial = {\n disabled: false,\n mapping: null,\n onChange: utils.noop,\n onInvalid: utils.noop,\n onInvalidSubmit: utils.noop,\n onReset: utils.noop,\n onSubmit: utils.noop,\n onValid: utils.noop,\n onValidSubmit: utils.noop,\n preventDefaultSubmit: true,\n preventExternalInvalidation: false,\n validationErrors: {},\n formElement: 'form',\n };\n\n private readonly throttledValidateForm: () => void;\n\n public constructor(props: FormsyProps) {\n super(props);\n this.state = {\n canChange: false,\n isSubmitting: false,\n isValid: true,\n contextValue: {\n attachToForm: this.attachToForm,\n detachFromForm: this.detachFromForm,\n isFormDisabled: props.disabled,\n isValidValue: this.isValidValue,\n validate: this.validate,\n runValidation: this.runValidation,\n },\n };\n this.inputs = [];\n this.emptyArray = [];\n this.throttledValidateForm = throttle(this.validateForm, ONE_RENDER_FRAME);\n }\n\n public componentDidMount = () => {\n this.prevInputNames = this.inputs.map((component) => component.props.name);\n this.validateForm();\n };\n\n public componentDidUpdate = (prevProps: FormsyProps) => {\n const { validationErrors, disabled } = this.props;\n\n if (validationErrors && isObject(validationErrors) && Object.keys(validationErrors).length > 0) {\n this.setInputValidationErrors(validationErrors);\n }\n\n const newInputNames = this.inputs.map((component) => component.props.name);\n if (this.prevInputNames && !utils.isSame(this.prevInputNames, newInputNames)) {\n this.prevInputNames = newInputNames;\n this.validateForm();\n }\n\n // Keep the disabled value in state/context the same as from props\n if (disabled !== prevProps.disabled) {\n // eslint-disable-next-line\n this.setState((state) => ({\n ...state,\n contextValue: {\n ...state.contextValue,\n isFormDisabled: disabled,\n },\n }));\n }\n };\n\n public getCurrentValues = () =>\n this.inputs.reduce((valueAccumulator, component) => {\n const {\n props: { name },\n state: { value },\n } = component;\n // eslint-disable-next-line no-param-reassign\n valueAccumulator[name] = utils.protectAgainstParamReassignment(value);\n return valueAccumulator;\n }, {});\n\n public getModel = () => {\n const currentValues = this.getCurrentValues();\n return this.mapModel(currentValues);\n };\n\n public getPristineValues = () =>\n this.inputs.reduce((valueAccumulator, component) => {\n const {\n props: { name, value },\n } = component;\n // eslint-disable-next-line no-param-reassign\n valueAccumulator[name] = utils.protectAgainstParamReassignment(value);\n return valueAccumulator;\n }, {});\n\n public setFormPristine = (isPristine: boolean) => {\n this.setState({\n formSubmitted: !isPristine,\n });\n\n // Iterate through each component and set it as pristine\n // or \"dirty\".\n this.inputs.forEach((component) => {\n component.setState({\n formSubmitted: !isPristine,\n isPristine,\n });\n });\n };\n\n public setInputValidationErrors = (errors) => {\n const { preventExternalInvalidation } = this.props;\n const { isValid } = this.state;\n\n this.inputs.forEach((component) => {\n const { name } = component.props;\n component.setState({\n isValid: !(name in errors),\n validationError: isString(errors[name]) ? [errors[name]] : errors[name],\n });\n });\n if (!preventExternalInvalidation && isValid) {\n this.setFormValidState(false);\n }\n };\n\n public setFormValidState = (allIsValid: boolean) => {\n const { onValid, onInvalid } = this.props;\n\n this.setState({\n isValid: allIsValid,\n });\n\n if (allIsValid) {\n onValid();\n } else {\n onInvalid();\n }\n };\n\n public isValidValue = (component, value) => this.runValidation(component, value).isValid;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isFormDisabled = () => this.props.disabled;\n\n public mapModel = (model: IModel): IModel => {\n const { mapping } = this.props;\n\n if (mapping) {\n return mapping(model);\n }\n\n const returnModel = {};\n Object.keys(model).forEach((key) => {\n set(returnModel, key, model[key]);\n });\n return returnModel;\n };\n\n public reset = (model?: IModel) => {\n this.setFormPristine(true);\n this.resetModel(model);\n };\n\n private resetInternal = (event) => {\n const { onReset } = this.props;\n\n event.preventDefault();\n this.reset();\n if (onReset) {\n onReset();\n }\n };\n\n // Reset each key in the model to the original / initial / specified value\n private resetModel: IResetModel = (data) => {\n this.inputs.forEach((component) => {\n const { name } = component.props;\n if (data && has(data, name)) {\n component.setValue(get(data, name));\n } else {\n component.resetValue();\n }\n });\n this.validateForm();\n };\n\n // Checks validation on current value or a passed value\n public runValidation = (\n component: InputComponent,\n value = component.state.value,\n ): { isRequired: boolean; isValid: boolean; validationError: ValidationError[] } => {\n const { validationErrors } = this.props;\n const { validationError, validationErrors: componentValidationErrors, name } = component.props;\n const currentValues = this.getCurrentValues();\n const validationResults = utils.runRules(value, currentValues, component.validations, validationRules);\n const requiredResults = utils.runRules(value, currentValues, component.requiredValidations, validationRules);\n const isRequired = Object.keys(component.requiredValidations).length ? !!requiredResults.success.length : false;\n const isValid = !validationResults.failed.length && !(validationErrors && validationErrors[component.props.name]);\n\n return {\n isRequired,\n isValid: isRequired ? false : isValid,\n validationError: (() => {\n if (isValid && !isRequired) {\n return this.emptyArray;\n }\n\n if (validationResults.errors.length) {\n return validationResults.errors;\n }\n\n if (validationErrors && validationErrors[name]) {\n return isString(validationErrors[name]) ? [validationErrors[name]] : validationErrors[name];\n }\n\n if (isRequired) {\n const error = componentValidationErrors[requiredResults.success[0]] || validationError;\n return error ? [error] : null;\n }\n\n if (validationResults.failed.length) {\n return validationResults.failed\n .map((failed) => (componentValidationErrors[failed] ? componentValidationErrors[failed] : validationError))\n .filter((x, pos, arr) => arr.indexOf(x) === pos); // remove duplicates\n }\n\n // This line is not reachable\n // istanbul ignore next\n return undefined;\n })(),\n };\n };\n\n // Method put on each input component to register\n // itself to the form\n public attachToForm = (component) => {\n if (this.inputs.indexOf(component) === -1) {\n this.inputs.push(component);\n }\n\n const { onChange } = this.props;\n const { canChange } = this.state;\n\n // Trigger onChange\n if (canChange) {\n onChange(this.getModel(), this.isChanged());\n }\n\n // Will be triggered immediately & every one frame rate\n this.throttledValidateForm();\n };\n\n // Method put on each input component to unregister\n // itself from the form\n public detachFromForm = (component: InputComponent) => {\n const componentPos = this.inputs.indexOf(component);\n\n if (componentPos !== -1) {\n this.inputs = this.inputs.slice(0, componentPos).concat(this.inputs.slice(componentPos + 1));\n }\n\n this.validateForm();\n };\n\n // Checks if the values have changed from their initial value\n public isChanged = () => !utils.isSame(this.getPristineValues(), this.getCurrentValues());\n\n // Update model, submit to url prop and send the model\n public submit = (event?: React.SyntheticEvent) => {\n const { onSubmit, onValidSubmit, onInvalidSubmit, preventDefaultSubmit } = this.props;\n const { isValid } = this.state;\n\n if (preventDefaultSubmit && event && event.preventDefault) {\n event.preventDefault();\n }\n\n // Trigger form as not pristine.\n // If any inputs have not been touched yet this will make them dirty\n // so validation becomes visible (if based on isPristine)\n this.setFormPristine(false);\n const model = this.getModel();\n onSubmit(model, this.resetModel, this.updateInputsWithError, event);\n\n if (isValid) {\n onValidSubmit(model, this.resetModel, this.updateInputsWithError, event);\n } else {\n onInvalidSubmit(model, this.resetModel, this.updateInputsWithError, event);\n }\n };\n\n // Go through errors from server and grab the components\n // stored in the inputs map. Change their state to invalid\n // and set the serverError message\n public updateInputsWithError: IUpdateInputsWithError = (errors, invalidate) => {\n const { preventExternalInvalidation } = this.props;\n const { isValid } = this.state;\n\n Object.entries(errors).forEach(([name, error]) => {\n const component = this.inputs.find((input) => input.props.name === name);\n if (!component) {\n throw new Error(\n `You are trying to update an input that does not exist. Verify errors object with input names. ${JSON.stringify(\n errors,\n )}`,\n );\n }\n component.setState({\n isValid: preventExternalInvalidation,\n validationError: utils.isString(error) ? [error] : error,\n });\n });\n\n if (invalidate && isValid) {\n this.setFormValidState(false);\n }\n };\n\n // Set the value of components\n public updateInputsWithValue: IUpdateInputsWithValue = (data, validate) => {\n this.inputs.forEach((component) => {\n const { name } = component.props;\n if (data && has(data, name)) {\n component.setValue(get(data, name), validate);\n }\n });\n };\n\n // Use the binded values and the actual input value to\n // validate the input and set its state. Then check the\n // state of the form itself\n public validate = (component: InputComponent) => {\n const { onChange } = this.props;\n const { canChange } = this.state;\n\n // Trigger onChange\n if (canChange) {\n onChange(this.getModel(), this.isChanged());\n }\n\n const validationState = this.runValidation(component);\n // Run through the validations, split them up and call\n // the validator IF there is a value or it is required\n component.setState(validationState, this.validateForm);\n };\n\n // Validate the form by going through all child input components\n // and check their state\n public validateForm = () => {\n // We need a callback as we are validating all inputs again. This will\n // run when the last component has set its state\n const onValidationComplete = () => {\n const allIsValid = this.inputs.every((component) => component.state.isValid);\n\n this.setFormValidState(allIsValid);\n\n // Tell the form that it can start to trigger change events\n this.setState({\n canChange: true,\n });\n };\n\n // Run validation again in case affected by other inputs. The\n // last component validated will run the onValidationComplete callback\n this.inputs.forEach((component, index) => {\n const validationState = this.runValidation(component);\n const isFinalInput = index === this.inputs.length - 1;\n const callback = isFinalInput ? onValidationComplete : null;\n component.setState(validationState, callback);\n });\n\n // If there are no inputs, set state where form is ready to trigger\n // change event. New inputs might be added later\n if (!this.inputs.length) {\n this.setState(\n {\n canChange: true,\n },\n onValidationComplete,\n );\n }\n };\n\n public render() {\n const {\n /* eslint-disable @typescript-eslint/no-unused-vars */\n children,\n mapping,\n onChange,\n onInvalid,\n onInvalidSubmit,\n onReset,\n onSubmit,\n onValid,\n onValidSubmit,\n preventDefaultSubmit,\n preventExternalInvalidation,\n validationErrors,\n disabled,\n formElement,\n ...nonFormsyProps\n } = this.props;\n const { contextValue } = this.state;\n\n return React.createElement(\n FormsyContext.Provider,\n {\n value: contextValue,\n },\n React.createElement(\n formElement,\n {\n onReset: this.resetInternal,\n onSubmit: this.submit,\n ...nonFormsyProps,\n disabled,\n },\n children,\n ),\n );\n }\n}\n"],"names":["isArray","value","Array","isObject","isPlainObject","isDate","Date","isFunction","isString","isRegex","RegExp","isValueStringEmpty","isValueNullOrUndefined","isValueUndefined","undefined","noop","protectAgainstParamReassignment","isSame","a","b","length","every","item","index","toString","Object","keys","key","runRules","currentValues","validations","validationRules","results","errors","failed","success","forEach","validationName","validationsVal","validationRulesVal","addToResults","validation","push","Error","isExisty","isEmpty","isTypeUndefined","isDefaultRequiredValue","matchRegexp","_values","regexp","test","REGEX_PATTERNS","equals","eql","equalsField","values","field","isAlpha","isAlphanumeric","isEmail","isEmptyString","isFalse","isFloat","isInt","isLength","isNumeric","isNumber","isSpecialWords","isTrue","isUndefined","isUrl","isWords","maxLength","minLength","throwNoFormsyProvider","React","createContext","attachToForm","detachFromForm","isFormDisabled","isValidValue","validate","runValidation","convertValidationsToObject","split","reduce","validationsAccumulator","args","validateMethod","shift","map","arg","JSON","parse","e","validationsAccumulatorCopy","propTypes","innerRef","PropTypes","func","name","string","isRequired","required","oneOfType","bool","object","any","Formsy","props","callback","enableCall","prevInputNames","_this","inputs","component","validateForm","prevProps","validationErrors","disabled","setInputValidationErrors","newInputNames","utils","setState","state","contextValue","valueAccumulator","getCurrentValues","mapModel","isPristine","formSubmitted","preventExternalInvalidation","isValid","validationError","setFormValidState","allIsValid","onValid","onInvalid","model","mapping","returnModel","set","setFormPristine","resetModel","event","onReset","preventDefault","reset","data","has","setValue","get","resetValue","componentValidationErrors","validationResults","requiredResults","requiredValidations","emptyArray","error","filter","x","pos","arr","indexOf","canChange","onChange","getModel","isChanged","throttledValidateForm","componentPos","slice","concat","getPristineValues","onSubmit","onValidSubmit","onInvalidSubmit","preventDefaultSubmit","updateInputsWithError","invalidate","entries","find","input","stringify","validationState","onValidationComplete","isSubmitting","apply","this","setTimeout","render","children","formElement","nonFormsyProps","createElement","FormsyContext","Provider","resetInternal","submit","Component","WrappedComponent","WithFormsyWrapper","messages","getErrorMessages","showRequired","pristineValue","setValidations","componentDidMount","shouldComponentUpdate","nextProps","nextState","some","k","isPropsChanged","isStateChanged","componentDidUpdate","componentWillUnmount","propsForElement","errorMessage","getErrorMessage","errorMessages","hasValue","isFormSubmitted","showError","getValue","ref","displayName","defaultValue","Consumer"],"mappings":"qoBAIg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AGjBtB,EAAMsH,cAAcM,EAAkBiB,OA/LvC7I,EAAM2H,kBAOAE,0BAfMrF,EAeiCoF,GAdtC0B,aAAe9G,EAAUf,OAASsB,EAAeP,GAAaA,EAAY,kBAgB3EqF,YAAiBxG,EAEjBwG,eAAoB,CAChCvG,SAAU,KACVM,UAAU,EACV8B,gBAAiB,GACjBf,iBAAkB,GAClBzF,YAAa,KACb7B,MAAQuM,EAAmD2B,cAmLxD,SAACrH,UACNlC,EAAMsH,cAAcC,EAAciC,SAAU,MAAM,SAACtG,UAC1ClD,EAAMsH,cAAcO,OAAwB3F,EAAUgB"}
\ No newline at end of file
+{"version":3,"file":"formsy-react.cjs.production.min.js","sources":["../src/utils.ts","../src/validationRules.ts","../src/FormsyContext.ts","../src/withFormsy.ts","../src/Formsy.ts"],"sourcesContent":["import { isPlainObject } from 'lodash';\n\nimport { ValidationError, Validations, Values } from './interfaces';\n\nexport function isArray(value: unknown): value is unknown[] {\n return Array.isArray(value);\n}\n\nexport function isObject(value: unknown): value is object {\n return isPlainObject(value);\n}\n\nexport function isTypeUndefined(value: unknown): value is undefined {\n return typeof value === 'undefined';\n}\n\nexport function isDate(value: unknown): value is Date {\n return value instanceof Date;\n}\n\nexport function isFunction(value: unknown): value is Function {\n return value !== null && typeof value === 'function';\n}\n\nexport function isString(value: unknown): value is string {\n return typeof value === 'string';\n}\n\nexport function isNumber(value: unknown): value is number {\n return typeof value === 'number';\n}\n\nexport function isRegex(value: unknown): value is RegExp {\n return value instanceof RegExp;\n}\n\nexport function isValueStringEmpty(value: string): boolean {\n return value === '';\n}\n\nexport function isValueNullOrUndefined(value: unknown): boolean {\n return value === null || value === undefined;\n}\n\nexport function isValueUndefined(value: unknown): boolean {\n return value === undefined;\n}\n\nexport function noop() {\n // do nothing.\n}\n\nexport function protectAgainstParamReassignment(value: unknown) {\n // Clone objects to avoid accidental param reassignment\n if (isObject(value)) return { ...value };\n if (isArray(value)) return [...value];\n return value;\n}\n\nexport function isSame(a: unknown, b: unknown) {\n if (typeof a !== typeof b) {\n return false;\n }\n\n if (isArray(a) && isArray(b)) {\n if (a.length !== b.length) {\n return false;\n }\n\n return a.every((item, index) => isSame(item, b[index]));\n }\n\n if (isFunction(a) && isFunction(b)) {\n return a.toString() === b.toString();\n }\n\n if (isDate(a) && isDate(b)) {\n return a.toString() === b.toString();\n }\n\n if (isObject(a) && isObject(b)) {\n if (Object.keys(a).length !== Object.keys(b).length) {\n return false;\n }\n\n return Object.keys(a).every((key) => isSame(a[key], b[key]));\n }\n\n if (isRegex(a) && isRegex(b)) {\n return a.toString() === b.toString();\n }\n\n return a === b;\n}\n\ninterface RulesResult {\n errors: ValidationError[];\n failed: string[];\n success: string[];\n}\n\nexport function runRules(\n value: V,\n currentValues: Values,\n validations: Validations,\n validationRules: Validations,\n) {\n const results: RulesResult = {\n errors: [],\n failed: [],\n success: [],\n };\n\n Object.keys(validations).forEach((validationName) => {\n const validationsVal = validations[validationName];\n const validationRulesVal = validationRules[validationName];\n const addToResults = (validation) => {\n if (isString(validation)) {\n results.errors.push(validation);\n results.failed.push(validationName);\n } else if (!validation) {\n results.failed.push(validationName);\n } else {\n results.success.push(validationName);\n }\n };\n\n if (validationRulesVal && isFunction(validationsVal)) {\n throw new Error(`Formsy does not allow you to override default validations: ${validationName}`);\n }\n\n if (!validationRulesVal && !isFunction(validationsVal)) {\n throw new Error(`Formsy does not have the validation rule: ${validationName}`);\n }\n\n if (isFunction(validationsVal)) {\n return addToResults(validationsVal(currentValues, value));\n }\n\n return addToResults(validationRulesVal(currentValues, value, validationsVal));\n });\n\n return results;\n}\n\nexport function throttle(callback, interval) {\n let enableCall = true;\n\n return function (...args) {\n if (!enableCall) return;\n\n enableCall = false;\n callback.apply(this, args);\n setTimeout(() => (enableCall = true), interval);\n };\n}\n","import { ValidationFunction, Values } from './interfaces';\nimport {\n isNumber,\n isString,\n isTypeUndefined,\n isValueNullOrUndefined,\n isValueStringEmpty,\n isValueUndefined,\n} from './utils';\n\nexport function isExisty(value: V) {\n return !isValueNullOrUndefined(value);\n}\n\nexport function isEmpty(value: V) {\n if (isString(value)) {\n return isValueStringEmpty(value);\n }\n if (isTypeUndefined(value)) {\n return false;\n }\n return isValueUndefined(value);\n}\n\nexport function isDefaultRequiredValue(value: unknown) {\n return isString(value) ? isValueStringEmpty(value) : isValueNullOrUndefined(value);\n}\n\nexport function matchRegexp(_values: Values, value: V, regexp: RegExp) {\n return !isExisty(value) || isEmpty(value) || regexp.test(`${value}`);\n}\n\ninterface Validations {\n [key: string]: ValidationFunction;\n}\n\nconst REGEX_PATTERNS = {\n ALPHA: /^[A-Z]+$/i,\n ALPHANUMERIC: /^[0-9A-Z]+$/i,\n EMAIL:\n /^(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/i, // from http://emailregex.com/\n FLOAT: /^(?:[-+]?(?:\\d+))?(?:\\.\\d*)?(?:[eE][+-]?(?:\\d+))?$/,\n INT: /^(?:[-+]?(?:0|[1-9]\\d*))$/,\n NUMERIC: /^[-+]?(?:\\d*[.])?\\d+$/,\n SPECIAL_WORDS: /^[\\sA-ZÀ-ÖØ-öø-ÿ]+$/i,\n URL: /^(?:\\w+:)?\\/\\/([^\\s.]+\\.\\S{2}|localhost[:?\\d]*)\\S*$/i,\n WORDS: /^[A-Z\\s]+$/i,\n};\n\nconst validations: Validations = {\n equals: (_values, value: V, eql: V) => !isExisty(value) || isEmpty(value) || value === eql,\n equalsField: (values, value: V, field: string) => value === values[field],\n isAlpha: (values, value: V) => matchRegexp(values, value, REGEX_PATTERNS.ALPHA),\n isAlphanumeric: (values, value: V) => matchRegexp(values, value, REGEX_PATTERNS.ALPHANUMERIC),\n isDefaultRequiredValue: (_values, value: V) => isDefaultRequiredValue(value),\n isEmail: (values, value: string) => matchRegexp(values, value, REGEX_PATTERNS.EMAIL),\n isEmptyString: (_values, value: string) => isEmpty(value),\n isExisty: (_values, value: V) => isExisty(value),\n isFalse: (_values, value: boolean | string) => value === false,\n isFloat: (values, value: V) => matchRegexp(values, value, REGEX_PATTERNS.FLOAT),\n isInt: (values, value: V) => matchRegexp(values, value, REGEX_PATTERNS.INT),\n isLength: (_values, value: string, length: number) => !isExisty(value) || isEmpty(value) || value.length === length,\n isNumeric: (values, value: V) => isNumber(value) || matchRegexp(values, value, REGEX_PATTERNS.NUMERIC),\n isSpecialWords: (values, value: V) => matchRegexp(values, value, REGEX_PATTERNS.SPECIAL_WORDS),\n isTrue: (_values, value: boolean | string) => value === true,\n isUndefined: (_values, value: V) => isValueUndefined(value),\n isUrl: (values, value: V) => matchRegexp(values, value, REGEX_PATTERNS.URL),\n isWords: (values, value: V) => matchRegexp(values, value, REGEX_PATTERNS.WORDS),\n matchRegexp,\n maxLength: (_values, value: string, length: number) => !isExisty(value) || value.length <= length,\n minLength: (_values, value: string, length: number) => !isExisty(value) || isEmpty(value) || value.length >= length,\n};\n\nexport const addValidationRule = (name: string, func: ValidationFunction) => {\n validations[name] = func;\n};\n\nexport default validations;\n","import React from 'react';\nimport { FormsyContextInterface } from './interfaces';\n\nconst noFormsyErrorMessage = 'Could not find Formsy Context Provider. Did you use withFormsy outside ?';\n\nconst throwNoFormsyProvider = () => {\n // istanbul ignore next\n throw new Error(noFormsyErrorMessage);\n};\n\nconst defaultValue = {\n attachToForm: throwNoFormsyProvider,\n detachFromForm: throwNoFormsyProvider,\n isFormDisabled: true,\n isValidValue: throwNoFormsyProvider,\n validate: throwNoFormsyProvider,\n runValidation: throwNoFormsyProvider,\n};\n\nexport default React.createContext(defaultValue);\n","import PropTypes from 'prop-types';\nimport React from 'react';\nimport FormsyContext from './FormsyContext';\nimport {\n ComponentWithStaticAttributes,\n FormsyContextInterface,\n RequiredValidation,\n ValidationError,\n Validations,\n WrappedComponentClass,\n} from './interfaces';\n\nimport * as utils from './utils';\nimport { isString } from './utils';\nimport { isDefaultRequiredValue } from './validationRules';\n\n/* eslint-disable react/default-props-match-prop-types */\n\nconst convertValidationsToObject = (validations: false | Validations): Validations => {\n if (isString(validations)) {\n return validations.split(/,(?![^{[]*[}\\]])/g).reduce((validationsAccumulator, validation) => {\n let args: string[] = validation.split(':');\n const validateMethod: string = args.shift();\n\n args = args.map((arg) => {\n try {\n return JSON.parse(arg);\n } catch (e) {\n return arg; // It is a string if it can not parse it\n }\n });\n\n if (args.length > 1) {\n throw new Error(\n 'Formsy does not support multiple args on string validations. Use object format of validations instead.',\n );\n }\n\n // Avoid parameter reassignment\n const validationsAccumulatorCopy: Validations = { ...validationsAccumulator };\n validationsAccumulatorCopy[validateMethod] = args.length ? args[0] : true;\n return validationsAccumulatorCopy;\n }, {});\n }\n\n return validations || {};\n};\n\nexport const propTypes = {\n innerRef: PropTypes.func,\n name: PropTypes.string.isRequired,\n required: PropTypes.oneOfType([PropTypes.bool, PropTypes.object, PropTypes.string]),\n validations: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),\n value: PropTypes.any, // eslint-disable-line react/forbid-prop-types\n};\n\nexport interface WrapperProps {\n innerRef?: (ref: React.Ref) => void;\n name: string;\n required?: RequiredValidation;\n validationError?: ValidationError;\n validationErrors?: { [key: string]: ValidationError };\n validations?: Validations;\n value?: V;\n}\n\nexport interface WrapperState {\n [key: string]: unknown;\n\n formSubmitted: boolean;\n isPristine: boolean;\n isRequired: boolean;\n isValid: boolean;\n pristineValue: V;\n validationError: ValidationError[];\n value: V;\n}\n\nexport interface InjectedProps {\n errorMessage: ValidationError;\n errorMessages: ValidationError[];\n hasValue: boolean;\n isFormDisabled: boolean;\n isFormSubmitted: boolean;\n isPristine: boolean;\n isRequired: boolean;\n isValid: boolean;\n isValidValue: (value: V) => boolean;\n ref?: React.Ref;\n resetValue: () => void;\n setValidations: (validations: Validations, required: RequiredValidation) => void;\n setValue: (value: V, validate?: boolean) => void;\n showError: boolean;\n showRequired: boolean;\n}\n\nexport interface WrapperInstanceMethods {\n getErrorMessage: () => null | ValidationError;\n getErrorMessages: () => ValidationError[];\n getValue: () => V;\n isFormDisabled: () => boolean;\n isFormSubmitted: () => boolean;\n isValid: () => boolean;\n isValidValue: (value: V) => boolean;\n setValue: (value: V, validate?: boolean) => void;\n}\n\nexport type PassDownProps = WrapperProps & InjectedProps;\n\nfunction getDisplayName(component: WrappedComponentClass) {\n return component.displayName || component.name || (utils.isString(component) ? component : 'Component');\n}\n\nexport default function withFormsy(\n WrappedComponent: React.ComponentType>,\n): React.ComponentType, keyof InjectedProps>> {\n class WithFormsyWrapper\n extends React.Component