diff --git a/CHANGELOG.md b/CHANGELOG.md index 44656cf7..f2f1cbb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,16 @@ 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.1](https://github.com/formsy/formsy-react/compare/v2.3.0...v2.3.1) + +- add throttledValidateForm in detachFromForm [`#713`](https://github.com/formsy/formsy-react/pull/713) +- feat: add test for unmounting multiple inputs, closes #712 [`#712`](https://github.com/formsy/formsy-react/issues/712) +- bump action versions [`7dc2c11`](https://github.com/formsy/formsy-react/commit/7dc2c11b0e34d0c80e3ac2ccdcde15658fc06288) + #### [v2.3.0](https://github.com/formsy/formsy-react/compare/v2.2.8...v2.3.0) +> 8 November 2022 + - 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) diff --git a/dist/Formsy.d.ts b/dist/Formsy.d.ts index f7ce2610..d27930b9 100644 --- a/dist/Formsy.d.ts +++ b/dist/Formsy.d.ts @@ -54,7 +54,7 @@ export declare class Formsy extends React.Component { validationErrors: PropTypes.Requireable; }; static defaultProps: Partial; - private readonly throttledValidateForm; + private readonly debouncedValidateForm; constructor(props: FormsyProps); componentDidMount: () => void; componentDidUpdate: (prevProps: FormsyProps) => void; diff --git a/dist/formsy-react.cjs.development.js b/dist/formsy-react.cjs.development.js index e563c066..e47bfe0a 100644 --- a/dist/formsy-react.cjs.development.js +++ b/dist/formsy-react.cjs.development.js @@ -158,18 +158,17 @@ function runRules(value, currentValues, validations, validationRules) { }); return results; } -function throttle(callback, interval) { - var enableCall = true; +function debounce(callback, timeout) { + var _this = this; + var timer; 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; - }, interval); + clearTimeout(timer); + timer = setTimeout(function () { + callback.apply(_this, args); + }, timeout); }; } @@ -720,17 +719,15 @@ var Formsy = /*#__PURE__*/function (_React$Component) { if (canChange) { onChange(_this.getModel(), _this.isChanged()); } - // Will be triggered immediately & every one frame rate - _this.throttledValidateForm(); + _this.debouncedValidateForm(); }; // 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(); + _this.inputs = _this.inputs.filter(function (input) { + return input !== component; + }); + _this.debouncedValidateForm(); }; // Checks if the values have changed from their initial value _this.isChanged = function () { @@ -811,7 +808,7 @@ var Formsy = /*#__PURE__*/function (_React$Component) { // 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 + // run when the last input has set its state var onValidationComplete = function onValidationComplete() { var allIsValid = _this.inputs.every(function (component) { return component.state.isValid; @@ -822,20 +819,17 @@ var Formsy = /*#__PURE__*/function (_React$Component) { canChange: true }); }; - // 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 - // change event. New inputs might be added later - if (!_this.inputs.length) { - _this.setState({ - canChange: true - }, onValidationComplete); + if (_this.inputs.length === 0) { + onValidationComplete(); + } else { + // 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 isLastInput = index === _this.inputs.length - 1; + var callback = isLastInput ? onValidationComplete : null; + component.setState(validationState, callback); + }); } }; _this.state = { @@ -853,7 +847,7 @@ var Formsy = /*#__PURE__*/function (_React$Component) { }; _this.inputs = []; _this.emptyArray = []; - _this.throttledValidateForm = throttle(_this.validateForm, ONE_RENDER_FRAME); + _this.debouncedValidateForm = debounce(_this.validateForm, ONE_RENDER_FRAME); return _this; } var _proto = Formsy.prototype; diff --git a/dist/formsy-react.cjs.development.js.map b/dist/formsy-react.cjs.development.js.map index 39cfd193..50e40fa8 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 }) 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,QAAQ;AAClC;SAEgBU,OAAO,CAACV,KAAc;EACpC,OAAOA,KAAK,YAAYW,MAAM;AAChC;SAEgBC,kBAAkB,CAACZ,KAAa;EAC9C,OAAOA,KAAK,KAAK,EAAE;AACrB;SAEg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Q,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 +{"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 debounce(callback, timeout: number) {\n let timer;\n return (...args) => {\n clearTimeout(timer);\n timer = setTimeout(() => {\n callback.apply(this, args);\n }, timeout);\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 { debounce, 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 debouncedValidateForm: () => 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.debouncedValidateForm = debounce(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 this.debouncedValidateForm();\n };\n\n // Method put on each input component to unregister\n // itself from the form\n public detachFromForm = (component: InputComponent) => {\n this.inputs = this.inputs.filter((input) => input !== component);\n\n this.debouncedValidateForm();\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 input 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 if (this.inputs.length === 0) {\n onValidationComplete();\n } else {\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 isLastInput = index === this.inputs.length - 1;\n const callback = isLastInput ? onValidationComplete : null;\n component.setState(validationState, callback);\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","debounce","callback","timeout","timer","args","clearTimeout","setTimeout","apply","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","debouncedValidateForm","input","getPristineValues","onSubmit","onValidSubmit","onInvalidSubmit","preventDefaultSubmit","updateInputsWithError","invalidate","entries","find","stringify","validationState","onValidationComplete","isLastInput","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;AACr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/D,SAAS,CAACK,IAAI;EACxBsE,OAAO,EAAE3E,SAAS,CAAC1B,IAAI;EACvB+I,WAAW,eAAErH,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;EACzBmI,eAAe,EAAEzG,SAAS,CAAC1B,IAAI;EAC/B2G,OAAO,EAAEjF,SAAS,CAAC1B,IAAI;EACvBiI,QAAQ,EAAEvG,SAAS,CAAC1B,IAAI;EACxBkG,OAAO,EAAExE,SAAS,CAAC1B,IAAI;EACvBkI,aAAa,EAAExG,SAAS,CAAC1B,IAAI;EAC7BoI,oBAAoB,EAAE1G,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;EACrB8F,eAAe,EAAE9F,IAAU;EAC3BsE,OAAO,EAAEtE,IAAU;EACnB4F,QAAQ,EAAE5F,IAAU;EACpB6D,OAAO,EAAE7D,IAAU;EACnB6F,aAAa,EAAE7F,IAAU;EACzB+F,oBAAoB,EAAE,IAAI;EAC1BrC,2BAA2B,EAAE,KAAK;EAClCd,gBAAgB,EAAE,EAAE;EACpB8D,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 3337d394..d4577157 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?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))}))}}; +"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+))?$/,R=/^(?:[-+]?(?:0|[1-9]\d*))$/,j=/^[-+]?(?:\d*[.])?\d+$/,x=/^[\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,I)},isDefaultRequiredValue:function(t,e){return F(e)},isEmail:function(t,e){return S(0,e,O)},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,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,j)},isSpecialWords:function(t,e){return S(0,e,x)},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 ?")},T=r.createContext({attachToForm:M,detachFromForm:M,isFormDisabled:!0,isValidValue:M,validate:M,runValidation:M}),A=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;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.debouncedValidateForm()},r.detachFromForm=function(t){r.inputs=r.inputs.filter((function(e){return e!==t})),r.debouncedValidateForm()},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})};0===r.inputs.length?t():r.inputs.forEach((function(e,n){var i=r.runValidation(e);e.setState(i,n===r.inputs.length-1?t:null)}))},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.debouncedValidateForm=function(t,e){var n,r=this;return function(){for(var e=arguments.length,i=new Array(e),o=0;o=0||(i[n]=t[n]);return i}(t,k);return r.createElement(T.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=A(t)||{},n.requiredValidations=!0===e?{isDefaultRequiredValue:e}:A(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(T.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 14219f08..3b548c95 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 }) 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","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","_this","prevInputNames","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","_inheritsLoose","render","children","formElement","nonFormsyProps","createElement","FormsyContext","Provider","resetInternal","submit","Component","WrappedComponent","WithFormsyWrapper","messages","getErrorMessages","showRequired","pristineValue","setValidations","_proto","componentDidMount","shouldComponentUpdate","nextProps","nextState","some","k","isPropsChanged","isStateChanged","componentDidUpdate","componentWillUnmount","propsForElement","errorMessage","getErrorMessage","errorMessages","hasValue","isFormSubmitted","showError","getValue","ref","displayName","default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aAAchC,KAAKiC,kBACnBC,cAAelC,KAAKgB,mBACpBmB,SAAUnC,KAAKmC,WACf/I,eAAgB4G,KAAK5G,iBACrBgJ,gBAAiBpC,KAAKoC,kBACtB9F,WAAY0D,KAAK1D,aACjB3B,WAAYqF,KAAKrF,aACjB8B,QAASuD,KAAKvD,UACdpD,aAAc2G,KAAK3G,aACnBwE,WAAYmC,KAAKnC,WACjBsD,eAAgBnB,KAAKmB,eACrBxD,SAAUqC,KAAKrC,SACf0E,UAAWrC,KAAKqC,YAChBpB,aAAcjB,KAAKiB,eACnB5M,MAAO2L,KAAKsC,aAOd,OAJIhI,IACFyH,EAAgBQ,IAAMjI,GAGjBtB,EAAMuH,cAAcM,EAAkBkB,OA/LvC/I,EAAM4H,WAoMhB,OA7LgBE,0BAfMtF,EAeiCqF,GAdtC2B,aAAehH,EAAUf,OAASsB,EAAeP,GAAaA,EAAY,kBAgB3EsF,YAAiBzG,EAEjByG,eAAoB,CAChCxG,SAAU,KACVM,UAAU,EACV8B,gBAAiB,GACjBf,iBAAkB,GAClBzF,YAAa,KACb7B,MAAQwM,EAAmD4B,cAmLxD,SAACvH,GAAK,OACXlC,EAAMuH,cAAcC,EAAckC,SAAU,MAAO,SAACxG,GAClD,OAAOlD,EAAMuH,cAAcO,OAAwB5F,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 debounce(callback, timeout: number) {\n let timer;\n return (...args) => {\n clearTimeout(timer);\n timer = setTimeout(() => {\n callback.apply(this, args);\n }, timeout);\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 { debounce, 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 debouncedValidateForm: () => 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.debouncedValidateForm = debounce(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 this.debouncedValidateForm();\n };\n\n // Method put on each input component to unregister\n // itself from the form\n public detachFromForm = (component: InputComponent) => {\n this.inputs = this.inputs.filter((input) => input !== component);\n\n this.debouncedValidateForm();\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 input 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 if (this.inputs.length === 0) {\n onValidationComplete();\n } else {\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 isLastInput = index === this.inputs.length - 1;\n const callback = isLastInput ? onValidationComplete : null;\n component.setState(validationState, callback);\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","_this","prevInputNames","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","debouncedValidateForm","input","getPristineValues","onSubmit","onValidSubmit","onInvalidSubmit","preventDefaultSubmit","updateInputsWithError","invalidate","entries","find","stringify","validationState","onValidationComplete","isSubmitting","callback","timeout","timer","clearTimeout","setTimeout","apply","debounce","_inheritsLoose","render","this","children","formElement","nonFormsyProps","createElement","FormsyContext","Provider","resetInternal","submit","Component","WrappedComponent","WithFormsyWrapper","messages","getErrorMessages","showRequired","pristineValue","setValidations","_proto","componentDidMount","shouldComponentUpdate","nextProps","nextState","some","k","isPropsChanged","isStateChanged","componentDidUpdate","componentWillUnmount","propsForElement","errorMessage","getErrorMessage","errorMessages","hasValue","isFormSubmitted","showError","getValue","ref","displayName","defaultValue","Consumer"],"mappings":"2vBAIgBA,EAAQC,GACtB,OAAOC,MAAMF,QAAQC,YAGPE,EAASF,GACvB,OAAOG,gBAAcH,YAOPI,EAAOJ,GACrB,OAAOA,aAAiBK,cAGVC,EAAWN,GACzB,OAAiB,OAAVA,GAAmC,mBAAVA,WAGlBO,EAASP,GACvB,MAAwB,iBAAVA,WAOAQ,EAAQR,GACtB,OAAOA,aAAiBS,gBAGVC,EAAmBV,GACjC,MAAiB,KAAVA,WAGOW,EAAuBX,GACrC,OAAOA,MAAAA,WAGOY,EAAiBZ,GAC/B,YAAiBa,IAAVb,WAGOc,cAIAC,EAAgCf,GAE9C,OAAIE,EAASF,QAAoBA,GAC7BD,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EAAY,kBAgB3EwF,YAAiBzG,EAEjByG,eAAoB,CAChCxG,SAAU,KACVM,UAAU,EACV4B,gBAAiB,GACjBf,iBAAkB,GAClBvF,YAAa,KACb7B,MAAQwM,EAAmD4B,cAmLxD,SAACvH,GAAK,OACXlC,EAAMuH,cAAcC,EAAckC,SAAU,MAAO,SAAC1G,GAClD,OAAOhD,EAAMuH,cAAcO,OAAwB5F,EAAUc"} \ No newline at end of file diff --git a/dist/formsy-react.esm.js b/dist/formsy-react.esm.js index ee5ab773..a7627934 100644 --- a/dist/formsy-react.esm.js +++ b/dist/formsy-react.esm.js @@ -152,18 +152,17 @@ function runRules(value, currentValues, validations, validationRules) { }); return results; } -function throttle(callback, interval) { - var enableCall = true; +function debounce(callback, timeout) { + var _this = this; + var timer; 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; - }, interval); + clearTimeout(timer); + timer = setTimeout(function () { + callback.apply(_this, args); + }, timeout); }; } @@ -714,17 +713,15 @@ var Formsy = /*#__PURE__*/function (_React$Component) { if (canChange) { onChange(_this.getModel(), _this.isChanged()); } - // Will be triggered immediately & every one frame rate - _this.throttledValidateForm(); + _this.debouncedValidateForm(); }; // 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(); + _this.inputs = _this.inputs.filter(function (input) { + return input !== component; + }); + _this.debouncedValidateForm(); }; // Checks if the values have changed from their initial value _this.isChanged = function () { @@ -805,7 +802,7 @@ var Formsy = /*#__PURE__*/function (_React$Component) { // 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 + // run when the last input has set its state var onValidationComplete = function onValidationComplete() { var allIsValid = _this.inputs.every(function (component) { return component.state.isValid; @@ -816,20 +813,17 @@ var Formsy = /*#__PURE__*/function (_React$Component) { canChange: true }); }; - // 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 - // change event. New inputs might be added later - if (!_this.inputs.length) { - _this.setState({ - canChange: true - }, onValidationComplete); + if (_this.inputs.length === 0) { + onValidationComplete(); + } else { + // 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 isLastInput = index === _this.inputs.length - 1; + var callback = isLastInput ? onValidationComplete : null; + component.setState(validationState, callback); + }); } }; _this.state = { @@ -847,7 +841,7 @@ var Formsy = /*#__PURE__*/function (_React$Component) { }; _this.inputs = []; _this.emptyArray = []; - _this.throttledValidateForm = throttle(_this.validateForm, ONE_RENDER_FRAME); + _this.debouncedValidateForm = debounce(_this.validateForm, ONE_RENDER_FRAME); return _this; } var _proto = Formsy.prototype; diff --git a/dist/formsy-react.esm.js.map b/dist/formsy-react.esm.js.map index b0efe0fd..080ec94e 100644 --- a/dist/formsy-react.esm.js.map +++ b/dist/formsy-react.esm.js.map @@ -1 +1 @@ -{"version":3,"file":"formsy-react.esm.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,C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B8F,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 +{"version":3,"file":"formsy-react.esm.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 debounce(callback, timeout: number) {\n let timer;\n return (...args) => {\n clearTimeout(timer);\n timer = setTimeout(() => {\n callback.apply(this, args);\n }, timeout);\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 { debounce, 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 debouncedValidateForm: () => 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.debouncedValidateForm = debounce(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 this.debouncedValidateForm();\n };\n\n // Method put on each input component to unregister\n // itself from the form\n public detachFromForm = (component: InputComponent) => {\n this.inputs = this.inputs.filter((input) => input !== component);\n\n this.debouncedValidateForm();\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 input 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 if (this.inputs.length === 0) {\n onValidationComplete();\n } else {\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 isLastInput = index === this.inputs.length - 1;\n const callback = isLastInput ? onValidationComplete : null;\n component.setState(validationState, callback);\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","debounce","callback","timeout","timer","args","clearTimeout","setTimeout","apply","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","debouncedValidateForm","input","getPristineValues","onSubmit","onValidSubmit","onInvalidSubmit","preventDefaultSubmit","updateInputsWithError","invalidate","entries","find","stringify","validationState","onValidationComplete","isLastInput","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,aAAa,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,QAAQ;AAClC;SAEgBU,OAAO,CAACV,KAAc;EACpC,OAAOA,KAAK,YAAYW,MAAM;AAChC;SAEgBC,kBAAkB,CAACZ,KAAa;EAC9C,OAAOA,KAAK,KAAK,EAAE;AACrB;SAEgBa,sBAAsB,CAACb,KAAc;EACnD,OAAOA,KAAK,KAAK,IAAI,IAAIA,KAAK,KAAKc,SAAS;AAC9C;SAEgBC,gBAAgB,CAACf,KAAc;EAC7C,OAAOA,KAAK,KAAKc,SAAS;AAC5B;SAEgBE,IAAI;;AAClB;SAGcC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B;AAEasD,mBAAY,GAAyB;EACjDG,QAAQ,EAAE,KAAK;EACfY,OAAO,EAAE,IAAI;EACbsB,QAAQ,EAAEtF,IAAU;EACpB8D,SAAS,EAAE9D,IAAU;EACrB8F,eAAe,EAAE9F,IAAU;EAC3BsE,OAAO,EAAEtE,IAAU;EACnB4F,QAAQ,EAAE5F,IAAU;EACpB6D,OAAO,EAAE7D,IAAU;EACnB6F,aAAa,EAAE7F,IAAU;EACzB+F,oBAAoB,EAAE,IAAI;EAC1BrC,2BAA2B,EAAE,KAAK;EAClCd,gBAAgB,EAAE,EAAE;EACpB8D,WAAW,EAAE;CACd;;;;;"} \ No newline at end of file diff --git a/dist/utils.d.ts b/dist/utils.d.ts index 87527a2a..58ddd2a2 100644 --- a/dist/utils.d.ts +++ b/dist/utils.d.ts @@ -19,5 +19,5 @@ interface RulesResult { success: string[]; } export declare function runRules(value: V, currentValues: Values, validations: Validations, validationRules: Validations): RulesResult; -export declare function throttle(callback: any, interval: any): (...args: any[]) => void; +export declare function debounce(callback: any, timeout: number): (...args: any[]) => void; export {}; diff --git a/package.json b/package.json index a60429e7..9693223d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "formsy-react", - "version": "2.3.0", + "version": "2.3.1", "description": "A form input builder and validator for React", "keywords": [ "form",