diff --git a/CHANGELOG.md b/CHANGELOG.md index f0b363d1..f9ad7b9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +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.2.3](https://github.com/formsy/formsy-react/compare/v2.2.1...v2.2.3) + +> 21 January 2021 + +- Add "formElement" props to allow any element to be render as a form [`#599`](https://github.com/formsy/formsy-react/pull/599) +- Add react 17 as valid peerDependencies [`#600`](https://github.com/formsy/formsy-react/pull/600) +- chore(deps): Bump ini from 1.3.5 to 1.3.7 [`#590`](https://github.com/formsy/formsy-react/pull/590) +- chore(deps): Bump node-fetch from 2.6.0 to 2.6.1 [`#564`](https://github.com/formsy/formsy-react/pull/564) +- Clarify and update API and sibling packages in README [`46df770`](https://github.com/formsy/formsy-react/commit/46df77024a6c6a6ed25f669426b11b8e18a106a7) + #### [v2.2.1](https://github.com/formsy/formsy-react/compare/v2.2.0...v2.2.1) > 27 August 2020 diff --git a/dist/formsy-react.cjs.development.js b/dist/formsy-react.cjs.development.js index f428a700..e0931ac5 100644 --- a/dist/formsy-react.cjs.development.js +++ b/dist/formsy-react.cjs.development.js @@ -4,12 +4,9 @@ Object.defineProperty(exports, '__esModule', { value: true }); function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } -var isPlainObject = _interopDefault(require('lodash.isplainobject')); +var lodash = require('lodash'); var PropTypes = _interopDefault(require('prop-types')); var React = _interopDefault(require('react')); -var get = _interopDefault(require('lodash.get')); -var has = _interopDefault(require('lodash.has')); -var set = _interopDefault(require('lodash.set')); function _extends() { _extends = Object.assign || function (target) { @@ -62,7 +59,7 @@ function isArray(value) { return Array.isArray(value); } function isObject(value) { - return isPlainObject(value); + return lodash.isPlainObject(value); } function isTypeUndefined(value) { return typeof value === 'undefined'; @@ -733,7 +730,7 @@ var Formsy = /*#__PURE__*/function (_React$Component) { var returnModel = {}; Object.keys(model).forEach(function (key) { - set(returnModel, key, model[key]); + lodash.set(returnModel, key, model[key]); }); return returnModel; }; @@ -760,8 +757,8 @@ var Formsy = /*#__PURE__*/function (_React$Component) { _this.inputs.forEach(function (component) { var name = component.props.name; - if (data && has(data, name)) { - component.setValue(get(data, name)); + if (data && lodash.has(data, name)) { + component.setValue(lodash.get(data, name)); } else { component.resetValue(); } @@ -918,17 +915,12 @@ var Formsy = /*#__PURE__*/function (_React$Component) { }; // Set the value of components - _this.updateInputsWithValue = function (values, validate) { - Object.entries(values).forEach(function (_ref2) { - var name = _ref2[0], - value = _ref2[1]; - - var input = _this.inputs.find(function (component) { - return component.props.name === name; - }); + _this.updateInputsWithValue = function (data, validate) { + _this.inputs.forEach(function (component) { + var name = component.props.name; - if (input) { - input.setValue(value, validate); + if (data && lodash.has(data, name)) { + component.setValue(lodash.get(data, name), validate); } }); }; // Use the binded values and the actual input value to diff --git a/dist/formsy-react.cjs.development.js.map b/dist/formsy-react.cjs.development.js.map index 05563897..3cbc34bc 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.isplainobject';\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: /^(([^<>()[\\]\\\\.,;:\\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 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 extends React.Component & FormsyContextInterface, WrapperState>\n implements WrapperInstanceMethods {\n public validations?: Validations;\n\n public requiredValidations?: Validations;\n\n public static displayName = `Formsy(${getDisplayName(WrappedComponent)})`;\n\n public static propTypes: any = propTypes;\n\n public static defaultProps: any = {\n innerRef: null,\n required: false,\n validationError: '',\n validationErrors: {},\n validations: null,\n value: (WrappedComponent as ComponentWithStaticAttributes).defaultValue,\n };\n\n public constructor(props) {\n super(props);\n const { runValidation, validations, required, value } = props;\n\n this.state = { value } as any;\n\n this.setValidations(validations, required);\n\n this.state = {\n formSubmitted: false,\n isPristine: true,\n pristineValue: props.value,\n value: props.value,\n ...runValidation(this, props.value),\n };\n }\n\n public componentDidMount() {\n const { name, attachToForm } = this.props;\n\n if (!name) {\n throw new Error('Form Input requires a name property when used');\n }\n\n attachToForm(this);\n }\n\n public shouldComponentUpdate(nextProps, nextState) {\n const { props, state } = this;\n const isChanged = (a: object, b: object): boolean => Object.keys(a).some((k) => a[k] !== b[k]);\n const isPropsChanged = isChanged(props, nextProps);\n const isStateChanged = isChanged(state, nextState);\n\n return isPropsChanged || isStateChanged;\n }\n\n public componentDidUpdate(prevProps) {\n const { value, validations, required, validate } = this.props;\n\n // If the value passed has changed, set it. If value is not passed it will\n // internally update, and this will never run\n if (!utils.isSame(value, prevProps.value)) {\n this.setValue(value);\n }\n\n // If validations or required is changed, run a new validation\n if (!utils.isSame(validations, prevProps.validations) || !utils.isSame(required, prevProps.required)) {\n this.setValidations(validations, required);\n validate(this);\n }\n }\n\n // Detach it when component unmounts\n public componentWillUnmount() {\n const { detachFromForm } = this.props;\n detachFromForm(this);\n }\n\n public getErrorMessage = (): ValidationError | null => {\n const messages = this.getErrorMessages();\n return messages.length ? messages[0] : null;\n };\n\n public getErrorMessages = (): ValidationError[] => {\n const { validationError } = this.state;\n\n if (!this.isValid() || this.showRequired()) {\n return validationError || [];\n }\n return [];\n };\n\n // eslint-disable-next-line react/destructuring-assignment\n public getValue = (): V => this.state.value;\n\n public setValidations = (validations: Validations, required: RequiredValidation): void => {\n // Add validations to the store itself as the props object can not be modified\n this.validations = convertValidationsToObject(validations) || {};\n this.requiredValidations =\n required === true ? { isDefaultRequiredValue: required } : convertValidationsToObject(required);\n };\n\n // By default, we validate after the value has been set.\n // A user can override this and pass a second parameter of `false` to skip validation.\n public setValue = (value: V, validate = true): void => {\n const { validate: validateForm } = this.props;\n\n if (!validate) {\n this.setState({ value });\n } else {\n this.setState(\n {\n value,\n isPristine: false,\n },\n () => {\n validateForm(this);\n },\n );\n }\n };\n\n // eslint-disable-next-line react/destructuring-assignment\n public hasValue = () => {\n const { value } = this.state;\n return isDefaultRequiredValue(value);\n };\n\n // eslint-disable-next-line react/destructuring-assignment\n public isFormDisabled = (): boolean => this.props.isFormDisabled;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isFormSubmitted = (): boolean => this.state.formSubmitted;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isPristine = (): boolean => this.state.isPristine;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isRequired = (): boolean => !!this.props.required;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isValid = (): boolean => this.state.isValid;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isValidValue = (value: V) => this.props.isValidValue(this, value);\n\n public resetValue = () => {\n const { pristineValue } = this.state;\n const { validate } = this.props;\n\n this.setState(\n {\n value: pristineValue,\n isPristine: true,\n },\n () => {\n validate(this);\n },\n );\n };\n\n public showError = (): boolean => !this.showRequired() && !this.isValid();\n\n // eslint-disable-next-line react/destructuring-assignment\n public showRequired = (): boolean => this.state.isRequired;\n\n public render() {\n const { innerRef } = this.props;\n const propsForElement: T & PassDownProps = {\n ...this.props,\n errorMessage: this.getErrorMessage(),\n errorMessages: this.getErrorMessages(),\n hasValue: this.hasValue(),\n isFormDisabled: this.isFormDisabled(),\n isFormSubmitted: this.isFormSubmitted(),\n isPristine: this.isPristine(),\n isRequired: this.isRequired(),\n isValid: this.isValid(),\n isValidValue: this.isValidValue,\n resetValue: this.resetValue,\n setValidations: this.setValidations,\n setValue: this.setValue,\n showError: this.showError(),\n showRequired: this.showRequired(),\n value: this.getValue(),\n };\n\n if (innerRef) {\n propsForElement.ref = innerRef;\n }\n\n return React.createElement(WrappedComponent, propsForElement);\n }\n }\n\n // eslint-disable-next-line react/display-name\n return (props) =>\n React.createElement(FormsyContext.Consumer, null, (contextValue) => {\n return React.createElement(WithFormsyWrapper, { ...props, ...contextValue });\n });\n}\n","/* eslint-disable react/no-unused-state, react/default-props-match-prop-types */\nimport get from 'lodash.get';\nimport has from 'lodash.has';\nimport set from 'lodash.set';\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 = (values, validate) => {\n Object.entries(values).forEach(([name, value]) => {\n const input = this.inputs.find((component) => component.props.name === name);\n\n if (input) {\n input.setValue(value, validate);\n }\n });\n };\n\n // Use the binded values and the actual input value to\n // validate the input and set its state. Then check the\n // state of the form itself\n public validate = (component: InputComponent) => {\n const { onChange } = this.props;\n const { canChange } = this.state;\n\n // Trigger onChange\n if (canChange) {\n onChange(this.getModel(), this.isChanged());\n }\n\n const validationState = this.runValidation(component);\n // Run through the validations, split them up and call\n // the validator IF there is a value or it is required\n component.setState(validationState, this.validateForm);\n };\n\n // Validate the form by going through all child input components\n // and check their state\n public validateForm = () => {\n // We need a callback as we are validating all inputs again. This will\n // run when the last component has set its state\n const onValidationComplete = () => {\n const allIsValid = this.inputs.every((component) => component.state.isValid);\n\n this.setFormValidState(allIsValid);\n\n // Tell the form that it can start to trigger change events\n this.setState({\n canChange: true,\n });\n };\n\n // Run validation again in case affected by other inputs. The\n // last component validated will run the onValidationComplete callback\n this.inputs.forEach((component, index) => {\n const validationState = this.runValidation(component);\n const isFinalInput = index === this.inputs.length - 1;\n const callback = isFinalInput ? onValidationComplete : null;\n component.setState(validationState, callback);\n });\n\n // If there are no inputs, set state where form is ready to trigger\n // change event. New inputs might be added later\n if (!this.inputs.length) {\n this.setState(\n {\n canChange: true,\n },\n onValidationComplete,\n );\n }\n };\n\n public render() {\n const {\n /* eslint-disable @typescript-eslint/no-unused-vars */\n children,\n mapping,\n onChange,\n onInvalid,\n onInvalidSubmit,\n onReset,\n onSubmit,\n onValid,\n onValidSubmit,\n preventDefaultSubmit,\n preventExternalInvalidation,\n validationErrors,\n disabled,\n formElement,\n ...nonFormsyProps\n } = this.props;\n const { contextValue } = this.state;\n\n return React.createElement(\n FormsyContext.Provider,\n {\n value: contextValue,\n },\n React.createElement(\n formElement,\n {\n onReset: this.resetInternal,\n onSubmit: this.submit,\n ...nonFormsyProps,\n disabled,\n },\n children,\n ),\n );\n }\n}\n"],"names":["isArray","value","Array","isObject","isPlainObject","isTypeUndefined","isDate","Date","isFunction","isString","isNumber","isRegex","RegExp","isValueStringEmpty","isValueNullOrUndefined","undefined","isValueUndefined","noop","protectAgainstParamReassignment","isSame","a","b","length","every","item","index","toString","Object","keys","key","runRules","currentValues","validations","validationRules","results","errors","failed","success","forEach","validationName","validationsVal","validationRulesVal","addToResults","validation","push","Error","throttle","callback","interval","enableCall","args","apply","setTimeout","isExisty","isEmpty","isDefaultRequiredValue","matchRegexp","_values","regexp","test","REGEX_PATTERNS","ALPHA","ALPHANUMERIC","EMAIL","FLOAT","INT","NUMERIC","SPECIAL_WORDS","URL","WORDS","equals","eql","equalsField","values","field","isAlpha","isAlphanumeric","isEmail","isEmptyString","isFalse","isFloat","isInt","isLength","isNumeric","isSpecialWords","isTrue","isUndefined","isUrl","isWords","maxLength","minLength","addValidationRule","name","func","noFormsyErrorMessage","throwNoFormsyProvider","defaultValue","attachToForm","detachFromForm","isFormDisabled","isValidValue","validate","runValidation","React","createContext","convertValidationsToObject","split","reduce","validationsAccumulator","validateMethod","shift","map","arg","JSON","parse","e","validationsAccumulatorCopy","propTypes","innerRef","PropTypes","string","isRequired","required","oneOfType","bool","object","any","getDisplayName","component","displayName","utils","withFormsy","WrappedComponent","WithFormsyWrapper","props","messages","getErrorMessages","validationError","state","isValid","showRequired","requiredValidations","validateForm","setState","isPristine","formSubmitted","pristineValue","setValidations","componentDidMount","shouldComponentUpdate","nextProps","nextState","isChanged","some","k","isPropsChanged","isStateChanged","componentDidUpdate","prevProps","setValue","componentWillUnmount","render","propsForElement","errorMessage","getErrorMessage","errorMessages","hasValue","isFormSubmitted","resetValue","showError","getValue","ref","createElement","Component","validationErrors","FormsyContext","Consumer","contextValue","ONE_RENDER_FRAME","Formsy","prevInputNames","inputs","disabled","setInputValidationErrors","newInputNames","valueAccumulator","getCurrentValues","mapModel","preventExternalInvalidation","setFormValidState","allIsValid","onValid","onInvalid","model","mapping","returnModel","set","setFormPristine","resetModel","event","onReset","preventDefault","reset","data","has","get","componentValidationErrors","validationResults","requiredResults","emptyArray","error","filter","x","pos","arr","indexOf","onChange","canChange","getModel","throttledValidateForm","componentPos","slice","concat","getPristineValues","onSubmit","onValidSubmit","onInvalidSubmit","preventDefaultSubmit","updateInputsWithError","invalidate","entries","find","input","stringify","validationState","onValidationComplete","isFinalInput","isSubmitting","children","formElement","nonFormsyProps","Provider","resetInternal","submit"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAIgBA,QAAQC;AACtB,SAAOC,KAAK,CAACF,OAAN,CAAcC,KAAd,CAAP;AACD;SAEeE,SAASF;AACvB,SAAOG,aAAa,CAACH,KAAD,CAApB;AACD;SAEeI,gBAAgBJ;A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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: /^(([^<>()[\\]\\\\.,;:\\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 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 public validations?: Validations;\n\n public requiredValidations?: Validations;\n\n public static displayName = `Formsy(${getDisplayName(WrappedComponent)})`;\n\n public static propTypes: any = propTypes;\n\n public static defaultProps: any = {\n innerRef: null,\n required: false,\n validationError: '',\n validationErrors: {},\n validations: null,\n value: (WrappedComponent as ComponentWithStaticAttributes).defaultValue,\n };\n\n public constructor(props) {\n super(props);\n const { runValidation, validations, required, value } = props;\n\n this.state = { value } as any;\n\n this.setValidations(validations, required);\n\n this.state = {\n formSubmitted: false,\n isPristine: true,\n pristineValue: props.value,\n value: props.value,\n ...runValidation(this, props.value),\n };\n }\n\n public componentDidMount() {\n const { name, attachToForm } = this.props;\n\n if (!name) {\n throw new Error('Form Input requires a name property when used');\n }\n\n attachToForm(this);\n }\n\n public shouldComponentUpdate(nextProps, nextState) {\n const { props, state } = this;\n const isChanged = (a: object, b: object): boolean => Object.keys(a).some((k) => a[k] !== b[k]);\n const isPropsChanged = isChanged(props, nextProps);\n const isStateChanged = isChanged(state, nextState);\n\n return isPropsChanged || isStateChanged;\n }\n\n public componentDidUpdate(prevProps) {\n const { value, validations, required, validate } = this.props;\n\n // If the value passed has changed, set it. If value is not passed it will\n // internally update, and this will never run\n if (!utils.isSame(value, prevProps.value)) {\n this.setValue(value);\n }\n\n // If validations or required is changed, run a new validation\n if (!utils.isSame(validations, prevProps.validations) || !utils.isSame(required, prevProps.required)) {\n this.setValidations(validations, required);\n validate(this);\n }\n }\n\n // Detach it when component unmounts\n public componentWillUnmount() {\n const { detachFromForm } = this.props;\n detachFromForm(this);\n }\n\n public getErrorMessage = (): ValidationError | null => {\n const messages = this.getErrorMessages();\n return messages.length ? messages[0] : null;\n };\n\n public getErrorMessages = (): ValidationError[] => {\n const { validationError } = this.state;\n\n if (!this.isValid() || this.showRequired()) {\n return validationError || [];\n }\n return [];\n };\n\n // eslint-disable-next-line react/destructuring-assignment\n public getValue = (): V => this.state.value;\n\n public setValidations = (validations: Validations, required: RequiredValidation): void => {\n // Add validations to the store itself as the props object can not be modified\n this.validations = convertValidationsToObject(validations) || {};\n this.requiredValidations =\n required === true ? { isDefaultRequiredValue: required } : convertValidationsToObject(required);\n };\n\n // By default, we validate after the value has been set.\n // A user can override this and pass a second parameter of `false` to skip validation.\n public setValue = (value: V, validate = true): void => {\n const { validate: validateForm } = this.props;\n\n if (!validate) {\n this.setState({ value });\n } else {\n this.setState(\n {\n value,\n isPristine: false,\n },\n () => {\n validateForm(this);\n },\n );\n }\n };\n\n // eslint-disable-next-line react/destructuring-assignment\n public hasValue = () => {\n const { value } = this.state;\n return isDefaultRequiredValue(value);\n };\n\n // eslint-disable-next-line react/destructuring-assignment\n public isFormDisabled = (): boolean => this.props.isFormDisabled;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isFormSubmitted = (): boolean => this.state.formSubmitted;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isPristine = (): boolean => this.state.isPristine;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isRequired = (): boolean => !!this.props.required;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isValid = (): boolean => this.state.isValid;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isValidValue = (value: V) => this.props.isValidValue(this, value);\n\n public resetValue = () => {\n const { pristineValue } = this.state;\n const { validate } = this.props;\n\n this.setState(\n {\n value: pristineValue,\n isPristine: true,\n },\n () => {\n validate(this);\n },\n );\n };\n\n public showError = (): boolean => !this.showRequired() && !this.isValid();\n\n // eslint-disable-next-line react/destructuring-assignment\n public showRequired = (): boolean => this.state.isRequired;\n\n public render() {\n const { innerRef } = this.props;\n const propsForElement: T & PassDownProps = {\n ...this.props,\n errorMessage: this.getErrorMessage(),\n errorMessages: this.getErrorMessages(),\n hasValue: this.hasValue(),\n isFormDisabled: this.isFormDisabled(),\n isFormSubmitted: this.isFormSubmitted(),\n isPristine: this.isPristine(),\n isRequired: this.isRequired(),\n isValid: this.isValid(),\n isValidValue: this.isValidValue,\n resetValue: this.resetValue,\n setValidations: this.setValidations,\n setValue: this.setValue,\n showError: this.showError(),\n showRequired: this.showRequired(),\n value: this.getValue(),\n };\n\n if (innerRef) {\n propsForElement.ref = innerRef;\n }\n\n return React.createElement(WrappedComponent, propsForElement);\n }\n }\n\n // eslint-disable-next-line react/display-name\n return (props) =>\n React.createElement(FormsyContext.Consumer, null, (contextValue) => {\n return React.createElement(WithFormsyWrapper, { ...props, ...contextValue });\n });\n}\n","/* eslint-disable react/no-unused-state, react/default-props-match-prop-types */\nimport { get, has, set } from 'lodash';\nimport PropTypes from 'prop-types';\nimport React from 'react';\nimport FormsyContext from './FormsyContext';\nimport {\n FormsyContextInterface,\n IModel,\n InputComponent,\n IResetModel,\n IUpdateInputsWithError,\n IUpdateInputsWithValue,\n ValidationError,\n} from './interfaces';\nimport { throttle, isObject, isString } from './utils';\nimport * as utils from './utils';\nimport validationRules from './validationRules';\nimport { PassDownProps } from './withFormsy';\n\ntype FormHTMLAttributesCleaned = Omit, 'onChange' | 'onSubmit'>;\n\ntype OnSubmitCallback = (\n model: IModel,\n resetModel: IResetModel,\n updateInputsWithError: IUpdateInputsWithError,\n event: React.SyntheticEvent>,\n) => void;\n\ntype FormElementType =\n | string\n | React.ComponentType<{\n onReset?: (e: React.SyntheticEvent) => void;\n onSubmit?: (e: React.SyntheticEvent) => void;\n disabled?: boolean;\n children?: React.ReactChildren;\n }>;\n\nexport interface FormsyProps extends FormHTMLAttributesCleaned {\n disabled: boolean;\n mapping: null | ((model: IModel) => IModel);\n onChange: (model: IModel, isChanged: boolean) => void;\n onInvalid: () => void;\n onReset?: () => void;\n onSubmit?: OnSubmitCallback;\n onValidSubmit?: OnSubmitCallback;\n onInvalidSubmit: OnSubmitCallback;\n onValid: () => void;\n preventDefaultSubmit?: boolean;\n preventExternalInvalidation?: boolean;\n validationErrors?: null | object;\n formElement?: FormElementType;\n}\n\nexport interface FormsyState {\n canChange: boolean;\n contextValue: FormsyContextInterface;\n formSubmitted?: boolean;\n isPristine?: boolean;\n isSubmitting: boolean;\n isValid: boolean;\n}\n\nconst ONE_RENDER_FRAME = 66;\n\nexport class Formsy extends React.Component {\n public inputs: InstanceType>[];\n\n public emptyArray: any[];\n\n public prevInputNames: any[] | null = null;\n\n public static displayName = 'Formsy';\n\n public static propTypes = {\n disabled: PropTypes.bool,\n mapping: PropTypes.func,\n formElement: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.func]),\n onChange: PropTypes.func,\n onInvalid: PropTypes.func,\n onInvalidSubmit: PropTypes.func,\n onReset: PropTypes.func,\n onSubmit: PropTypes.func,\n onValid: PropTypes.func,\n onValidSubmit: PropTypes.func,\n preventDefaultSubmit: PropTypes.bool,\n preventExternalInvalidation: PropTypes.bool,\n validationErrors: PropTypes.object, // eslint-disable-line\n };\n\n public static defaultProps: Partial = {\n disabled: false,\n mapping: null,\n onChange: utils.noop,\n onInvalid: utils.noop,\n onInvalidSubmit: utils.noop,\n onReset: utils.noop,\n onSubmit: utils.noop,\n onValid: utils.noop,\n onValidSubmit: utils.noop,\n preventDefaultSubmit: true,\n preventExternalInvalidation: false,\n validationErrors: {},\n formElement: 'form',\n };\n\n private readonly throttledValidateForm: () => void;\n\n public constructor(props: FormsyProps) {\n super(props);\n this.state = {\n canChange: false,\n isSubmitting: false,\n isValid: true,\n contextValue: {\n attachToForm: this.attachToForm,\n detachFromForm: this.detachFromForm,\n isFormDisabled: props.disabled,\n isValidValue: this.isValidValue,\n validate: this.validate,\n runValidation: this.runValidation,\n },\n };\n this.inputs = [];\n this.emptyArray = [];\n this.throttledValidateForm = throttle(this.validateForm, ONE_RENDER_FRAME);\n }\n\n public componentDidMount = () => {\n this.prevInputNames = this.inputs.map((component) => component.props.name);\n this.validateForm();\n };\n\n public componentDidUpdate = (prevProps: FormsyProps) => {\n const { validationErrors, disabled } = this.props;\n\n if (validationErrors && isObject(validationErrors) && Object.keys(validationErrors).length > 0) {\n this.setInputValidationErrors(validationErrors);\n }\n\n const newInputNames = this.inputs.map((component) => component.props.name);\n if (this.prevInputNames && !utils.isSame(this.prevInputNames, newInputNames)) {\n this.prevInputNames = newInputNames;\n this.validateForm();\n }\n\n // Keep the disabled value in state/context the same as from props\n if (disabled !== prevProps.disabled) {\n // eslint-disable-next-line\n this.setState((state) => ({\n ...state,\n contextValue: {\n ...state.contextValue,\n isFormDisabled: disabled,\n },\n }));\n }\n };\n\n public getCurrentValues = () =>\n this.inputs.reduce((valueAccumulator, component) => {\n const {\n props: { name },\n state: { value },\n } = component;\n // eslint-disable-next-line no-param-reassign\n valueAccumulator[name] = utils.protectAgainstParamReassignment(value);\n return valueAccumulator;\n }, {});\n\n public getModel = () => {\n const currentValues = this.getCurrentValues();\n return this.mapModel(currentValues);\n };\n\n public getPristineValues = () =>\n this.inputs.reduce((valueAccumulator, component) => {\n const {\n props: { name, value },\n } = component;\n // eslint-disable-next-line no-param-reassign\n valueAccumulator[name] = utils.protectAgainstParamReassignment(value);\n return valueAccumulator;\n }, {});\n\n public setFormPristine = (isPristine: boolean) => {\n this.setState({\n formSubmitted: !isPristine,\n });\n\n // Iterate through each component and set it as pristine\n // or \"dirty\".\n this.inputs.forEach((component) => {\n component.setState({\n formSubmitted: !isPristine,\n isPristine,\n });\n });\n };\n\n public setInputValidationErrors = (errors) => {\n const { preventExternalInvalidation } = this.props;\n const { isValid } = this.state;\n\n this.inputs.forEach((component) => {\n const { name } = component.props;\n component.setState({\n isValid: !(name in errors),\n validationError: isString(errors[name]) ? [errors[name]] : errors[name],\n });\n });\n if (!preventExternalInvalidation && isValid) {\n this.setFormValidState(false);\n }\n };\n\n public setFormValidState = (allIsValid: boolean) => {\n const { onValid, onInvalid } = this.props;\n\n this.setState({\n isValid: allIsValid,\n });\n\n if (allIsValid) {\n onValid();\n } else {\n onInvalid();\n }\n };\n\n public isValidValue = (component, value) => this.runValidation(component, value).isValid;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isFormDisabled = () => this.props.disabled;\n\n public mapModel = (model: IModel): IModel => {\n const { mapping } = this.props;\n\n if (mapping) {\n return mapping(model);\n }\n\n const returnModel = {};\n Object.keys(model).forEach((key) => {\n set(returnModel, key, model[key]);\n });\n return returnModel;\n };\n\n public reset = (model?: IModel) => {\n this.setFormPristine(true);\n this.resetModel(model);\n };\n\n private resetInternal = (event) => {\n const { onReset } = this.props;\n\n event.preventDefault();\n this.reset();\n if (onReset) {\n onReset();\n }\n };\n\n // Reset each key in the model to the original / initial / specified value\n private resetModel: IResetModel = (data) => {\n this.inputs.forEach((component) => {\n const { name } = component.props;\n if (data && has(data, name)) {\n component.setValue(get(data, name));\n } else {\n component.resetValue();\n }\n });\n this.validateForm();\n };\n\n // Checks validation on current value or a passed value\n public runValidation = (\n component: InputComponent,\n value = component.state.value,\n ): { isRequired: boolean; isValid: boolean; validationError: ValidationError[] } => {\n const { validationErrors } = this.props;\n const { validationError, validationErrors: componentValidationErrors, name } = component.props;\n const currentValues = this.getCurrentValues();\n const validationResults = utils.runRules(value, currentValues, component.validations, validationRules);\n const requiredResults = utils.runRules(value, currentValues, component.requiredValidations, validationRules);\n const isRequired = Object.keys(component.requiredValidations).length ? !!requiredResults.success.length : false;\n const isValid = !validationResults.failed.length && !(validationErrors && validationErrors[component.props.name]);\n\n return {\n isRequired,\n isValid: isRequired ? false : isValid,\n validationError: (() => {\n if (isValid && !isRequired) {\n return this.emptyArray;\n }\n\n if (validationResults.errors.length) {\n return validationResults.errors;\n }\n\n if (validationErrors && validationErrors[name]) {\n return isString(validationErrors[name]) ? [validationErrors[name]] : validationErrors[name];\n }\n\n if (isRequired) {\n const error = componentValidationErrors[requiredResults.success[0]] || validationError;\n return error ? [error] : null;\n }\n\n if (validationResults.failed.length) {\n return validationResults.failed\n .map((failed) => (componentValidationErrors[failed] ? componentValidationErrors[failed] : validationError))\n .filter((x, pos, arr) => arr.indexOf(x) === pos); // remove duplicates\n }\n\n // This line is not reachable\n // istanbul ignore next\n return undefined;\n })(),\n };\n };\n\n // Method put on each input component to register\n // itself to the form\n public attachToForm = (component) => {\n if (this.inputs.indexOf(component) === -1) {\n this.inputs.push(component);\n }\n\n const { onChange } = this.props;\n const { canChange } = this.state;\n\n // Trigger onChange\n if (canChange) {\n onChange(this.getModel(), this.isChanged());\n }\n\n // Will be triggered immediately & every one frame rate\n this.throttledValidateForm();\n };\n\n // Method put on each input component to unregister\n // itself from the form\n public detachFromForm = (component: InputComponent) => {\n const componentPos = this.inputs.indexOf(component);\n\n if (componentPos !== -1) {\n this.inputs = this.inputs.slice(0, componentPos).concat(this.inputs.slice(componentPos + 1));\n }\n\n this.validateForm();\n };\n\n // Checks if the values have changed from their initial value\n public isChanged = () => !utils.isSame(this.getPristineValues(), this.getCurrentValues());\n\n // Update model, submit to url prop and send the model\n public submit = (event?: React.SyntheticEvent) => {\n const { onSubmit, onValidSubmit, onInvalidSubmit, preventDefaultSubmit } = this.props;\n const { isValid } = this.state;\n\n if (preventDefaultSubmit && event && event.preventDefault) {\n event.preventDefault();\n }\n\n // Trigger form as not pristine.\n // If any inputs have not been touched yet this will make them dirty\n // so validation becomes visible (if based on isPristine)\n this.setFormPristine(false);\n const model = this.getModel();\n onSubmit(model, this.resetModel, this.updateInputsWithError, event);\n\n if (isValid) {\n onValidSubmit(model, this.resetModel, this.updateInputsWithError, event);\n } else {\n onInvalidSubmit(model, this.resetModel, this.updateInputsWithError, event);\n }\n };\n\n // Go through errors from server and grab the components\n // stored in the inputs map. Change their state to invalid\n // and set the serverError message\n public updateInputsWithError: IUpdateInputsWithError = (errors, invalidate) => {\n const { preventExternalInvalidation } = this.props;\n const { isValid } = this.state;\n\n Object.entries(errors).forEach(([name, error]) => {\n const component = this.inputs.find((input) => input.props.name === name);\n if (!component) {\n throw new Error(\n `You are trying to update an input that does not exist. Verify errors object with input names. ${JSON.stringify(\n errors,\n )}`,\n );\n }\n component.setState({\n isValid: preventExternalInvalidation,\n validationError: utils.isString(error) ? [error] : error,\n });\n });\n\n if (invalidate && isValid) {\n this.setFormValidState(false);\n }\n };\n\n // Set the value of components\n public updateInputsWithValue: IUpdateInputsWithValue = (data, validate) => {\n this.inputs.forEach((component) => {\n const { name } = component.props;\n if (data && has(data, name)) {\n component.setValue(get(data, name), validate);\n }\n });\n };\n\n // Use the binded values and the actual input value to\n // validate the input and set its state. Then check the\n // state of the form itself\n public validate = (component: InputComponent) => {\n const { onChange } = this.props;\n const { canChange } = this.state;\n\n // Trigger onChange\n if (canChange) {\n onChange(this.getModel(), this.isChanged());\n }\n\n const validationState = this.runValidation(component);\n // Run through the validations, split them up and call\n // the validator IF there is a value or it is required\n component.setState(validationState, this.validateForm);\n };\n\n // Validate the form by going through all child input components\n // and check their state\n public validateForm = () => {\n // We need a callback as we are validating all inputs again. This will\n // run when the last component has set its state\n const onValidationComplete = () => {\n const allIsValid = this.inputs.every((component) => component.state.isValid);\n\n this.setFormValidState(allIsValid);\n\n // Tell the form that it can start to trigger change events\n this.setState({\n canChange: true,\n });\n };\n\n // Run validation again in case affected by other inputs. The\n // last component validated will run the onValidationComplete callback\n this.inputs.forEach((component, index) => {\n const validationState = this.runValidation(component);\n const isFinalInput = index === this.inputs.length - 1;\n const callback = isFinalInput ? onValidationComplete : null;\n component.setState(validationState, callback);\n });\n\n // If there are no inputs, set state where form is ready to trigger\n // change event. New inputs might be added later\n if (!this.inputs.length) {\n this.setState(\n {\n canChange: true,\n },\n onValidationComplete,\n );\n }\n };\n\n public render() {\n const {\n /* eslint-disable @typescript-eslint/no-unused-vars */\n children,\n mapping,\n onChange,\n onInvalid,\n onInvalidSubmit,\n onReset,\n onSubmit,\n onValid,\n onValidSubmit,\n preventDefaultSubmit,\n preventExternalInvalidation,\n validationErrors,\n disabled,\n formElement,\n ...nonFormsyProps\n } = this.props;\n const { contextValue } = this.state;\n\n return React.createElement(\n FormsyContext.Provider,\n {\n value: contextValue,\n },\n React.createElement(\n formElement,\n {\n onReset: this.resetInternal,\n onSubmit: this.submit,\n ...nonFormsyProps,\n disabled,\n },\n children,\n ),\n );\n }\n}\n"],"names":["isArray","value","Array","isObject","isPlainObject","isTypeUndefined","isDate","Date","isFunction","isString","isNumber","isRegex","RegExp","isValueStringEmpty","isValueNullOrUndefined","undefined","isValueUndefined","noop","protectAgainstParamReassignment","isSame","a","b","length","every","item","index","toString","Object","keys","key","runRules","currentValues","validations","validationRules","results","errors","failed","success","forEach","validationName","validationsVal","validationRulesVal","addToResults","validation","push","Error","throttle","callback","interval","enableCall","args","apply","setTimeout","isExisty","isEmpty","isDefaultRequiredValue","matchRegexp","_values","regexp","test","REGEX_PATTERNS","ALPHA","ALPHANUMERIC","EMAIL","FLOAT","INT","NUMERIC","SPECIAL_WORDS","URL","WORDS","equals","eql","equalsField","values","field","isAlpha","isAlphanumeric","isEmail","isEmptyString","isFalse","isFloat","isInt","isLength","isNumeric","isSpecialWords","isTrue","isUndefined","isUrl","isWords","maxLength","minLength","addValidationRule","name","func","noFormsyErrorMessage","throwNoFormsyProvider","defaultValue","attachToForm","detachFromForm","isFormDisabled","isValidValue","validate","runValidation","React","createContext","convertValidationsToObject","split","reduce","validationsAccumulator","validateMethod","shift","map","arg","JSON","parse","e","validationsAccumulatorCopy","propTypes","innerRef","PropTypes","string","isRequired","required","oneOfType","bool","object","any","getDisplayName","component","displayName","utils","withFormsy","WrappedComponent","WithFormsyWrapper","props","messages","getErrorMessages","validationError","state","isValid","showRequired","requiredValidations","validateForm","setState","isPristine","formSubmitted","pristineValue","setValidations","componentDidMount","shouldComponentUpdate","nextProps","nextState","isChanged","some","k","isPropsChanged","isStateChanged","componentDidUpdate","prevProps","setValue","componentWillUnmount","render","propsForElement","errorMessage","getErrorMessage","errorMessages","hasValue","isFormSubmitted","resetValue","showError","getValue","ref","createElement","Component","validationErrors","FormsyContext","Consumer","contextValue","ONE_RENDER_FRAME","Formsy","prevInputNames","inputs","disabled","setInputValidationErrors","newInputNames","valueAccumulator","getCurrentValues","mapModel","preventExternalInvalidation","setFormValidState","allIsValid","onValid","onInvalid","model","mapping","returnModel","set","setFormPristine","resetModel","event","onReset","preventDefault","reset","data","has","get","componentValidationErrors","validationResults","requiredResults","emptyArray","error","filter","x","pos","arr","indexOf","onChange","canChange","getModel","throttledValidateForm","componentPos","slice","concat","getPristineValues","onSubmit","onValidSubmit","onInvalidSubmit","preventDefaultSubmit","updateInputsWithError","invalidate","entries","find","input","stringify","validationState","onValidationComplete","isFinalInput","isSubmitting","children","formElement","nonFormsyProps","Provider","resetInternal","submit"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAIgBA,QAAQC;AACtB,SAAOC,KAAK,CAACF,OAAN,CAAcC,KAAd,CAAP;AACD;SAEeE,SAASF;AACvB,SAAOG,oBAAa,CAACH,KAAD,CAApB;AACD;SAEeI,gBAAgBJ;AAC9B,SAAO,OAAOA,KAAP,KAAiB,WAAxB;AACD;SAEeK,OAAOL;AACrB,SAAOA,KAAK,YAAYM,IAAxB;AACD;SAEeC,WAAWP;AACzB,SAAOA,KAAK,KAAK,IAAV,IAAkB,OAAOA,KAAP,KAAiB,UAA1C;AACD;SAEeQ,SAASR;AACvB,SAAO,OAAOA,KAAP,KAAiB,QAAxB;AACD;SAEeS,SAAST;AACvB,SAAO,OAAOA,KAAP,KAAiB,QAAxB;AACD;SAEeU,QAAQV;AACtB,SAAOA,KAAK,YAAYW,MAAxB;AACD;SAEeC,mBAAmBZ;AACjC,SAAOA,KAAK,KAAK,EAAjB;AACD;SAEea,uBAAuBb;AACrC,SAAOA,KAAK,KAAK,IAAV,IAAkBA,KAAK,KAAKc,SAAnC;AACD;SAEeC,iBAAiBf;AAC/B,SAAOA,KAAK,KAAKc,SAAjB;AACD;SAEeE;AAEf;SAEeC,gCAAgCjB;AAC9C;AACA,MAAIE,QAAQ,CAACF,KAAD,CAAZ,EAAqB,oBAAYA,KAAZ;AACrB,MAAID,OAAO,CAACC,KAAD,CAAX,EAAoB,iBAAWA,KAAX;AACpB,SAAOA,KAAP;AACD;SAEekB,OAAOC,GAAYC;AACjC,MAAI,OAA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D,IAJsC;AAKjDgG,EAAAA,eAAe,EAAEhG,IALgC;AAMjDsE,EAAAA,OAAO,EAAEtE,IANwC;AAOjD8F,EAAAA,QAAQ,EAAE9F,IAPuC;AAQjD6D,EAAAA,OAAO,EAAE7D,IARwC;AASjD+F,EAAAA,aAAa,EAAE/F,IATkC;AAUjDiG,EAAAA,oBAAoB,EAAE,IAV2B;AAWjDvC,EAAAA,2BAA2B,EAAE,KAXoB;AAYjDd,EAAAA,gBAAgB,EAAE,EAZ+B;AAajDiE,EAAAA,WAAW,EAAE;AAboC,CAArC;;;;;;;;"} \ No newline at end of file diff --git a/dist/formsy-react.cjs.production.min.js b/dist/formsy-react.cjs.production.min.js index 4271db48..81660763 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=t(require("lodash.isplainobject")),n=t(require("prop-types")),r=t(require("react")),i=t(require("lodash.get")),o=t(require("lodash.has")),a=t(require("lodash.set"));function u(){return(u=Object.assign||function(t){for(var e=1;e()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/i,O=/^(?:[-+]?(?:\d+))?(?:\.\d*)?(?:[eE][+-]?(?:\d+))?$/,j=/^(?:[-+]?(?:0|[1-9]\d*))$/,D=/^[-+]?(?:\d*[.])?\d+$/,M=/^[\sA-ZÀ-ÖØ-öø-ÿ]+$/i,P=/^(?:\w+:)?\/\/([^\s.]+\.\S{2}|localhost[:?\d]*)\S*$/i,A=/^[A-Z\s]+$/i,T={equals:function(t,e,n){return!S(e)||q(e)||e===n},equalsField:function(t,e,n){return e===t[n]},isAlpha:function(t,e){return I(0,e,x)},isAlphanumeric:function(t,e){return I(0,e,R)},isDefaultRequiredValue:function(t,e){return w(e)},isEmail:function(t,e){return I(0,e,C)},isEmptyString:function(t,e){return q(e)},isExisty:function(t,e){return S(e)},isFalse:function(t,e){return!1===e},isFloat:function(t,e){return I(0,e,O)},isInt:function(t,e){return I(0,e,j)},isLength:function(t,e,n){return!S(e)||q(e)||e.length===n},isNumeric:function(t,e){return function(t){return"number"==typeof t}(e)||I(0,e,D)},isSpecialWords:function(t,e){return I(0,e,M)},isTrue:function(t,e){return!0===e},isUndefined:function(t,e){return g(e)},isUrl:function(t,e){return I(0,e,P)},isWords:function(t,e){return I(0,e,A)},matchRegexp:I,maxLength:function(t,e,n){return!S(e)||e.length<=n},minLength:function(t,e,n){return!S(e)||q(e)||e.length>=n}},N=function(){throw new Error("Could not find Formsy Context Provider. Did you use withFormsy outside ?")},k=r.createContext({attachToForm:N,detachFromForm:N,isFormDisabled:!0,isValidValue:N,validate:N,runValidation:N}),$=function(t){return m(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 i=u({},t);return i[r]=!n.length||n[0],i}),{}):t||{}},W={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},U=function(t){function e(e){var n,r,s;return(n=t.call(this,e)||this).prevInputNames=null,n.componentDidMount=function(){n.prevInputNames=n.inputs.map((function(t){return t.props.name})),n.validateForm()},n.componentDidUpdate=function(t){var e=n.props,r=e.validationErrors,i=e.disabled;r&&c(r)&&Object.keys(r).length>0&&n.setInputValidationErrors(r);var o=n.inputs.map((function(t){return t.props.name}));n.prevInputNames&&!E(n.prevInputNames,o)&&(n.prevInputNames=o,n.validateForm()),i!==t.disabled&&n.setState((function(t){return u({},t,{contextValue:u({},t.contextValue,{isFormDisabled:i})})}))},n.getCurrentValues=function(){return n.inputs.reduce((function(t,e){return t[e.props.name]=y(e.state.value),t}),{})},n.getModel=function(){var t=n.getCurrentValues();return n.mapModel(t)},n.getPristineValues=function(){return n.inputs.reduce((function(t,e){var n=e.props;return t[n.name]=y(n.value),t}),{})},n.setFormPristine=function(t){n.setState({formSubmitted:!t}),n.inputs.forEach((function(e){e.setState({formSubmitted:!t,isPristine:t})}))},n.setInputValidationErrors=function(t){var e=n.props.preventExternalInvalidation,r=n.state.isValid;n.inputs.forEach((function(e){var n=e.props.name;e.setState({isValid:!(n in t),validationError:m(t[n])?[t[n]]:t[n]})})),!e&&r&&n.setFormValidState(!1)},n.setFormValidState=function(t){var e=n.props,r=e.onValid,i=e.onInvalid;n.setState({isValid:t}),t?r():i()},n.isValidValue=function(t,e){return n.runValidation(t,e).isValid},n.isFormDisabled=function(){return n.props.disabled},n.mapModel=function(t){var e=n.props.mapping;if(e)return e(t);var r={};return Object.keys(t).forEach((function(e){a(r,e,t[e])})),r},n.reset=function(t){n.setFormPristine(!0),n.resetModel(t)},n.resetInternal=function(t){var e=n.props.onReset;t.preventDefault(),n.reset(),e&&e()},n.resetModel=function(t){n.inputs.forEach((function(e){var n=e.props.name;t&&o(t,n)?e.setValue(i(t,n)):e.resetValue()})),n.validateForm()},n.runValidation=function(t,e){void 0===e&&(e=t.state.value);var r=n.props.validationErrors,i=t.props,o=i.validationError,a=i.validationErrors,u=i.name,s=n.getCurrentValues(),l=F(e,s,t.validations,T),d=F(e,s,t.requiredValidations,T),c=!!Object.keys(t.requiredValidations).length&&!!d.success.length,f=!(l.failed.length||r&&r[t.props.name]);return{isRequired:c,isValid:!c&&f,validationError:function(){if(f&&!c)return n.emptyArray;if(l.errors.length)return l.errors;if(r&&r[u])return m(r[u])?[r[u]]:r[u];if(c){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}()}},n.attachToForm=function(t){-1===n.inputs.indexOf(t)&&n.inputs.push(t),n.state.canChange&&(0,n.props.onChange)(n.getModel(),n.isChanged()),n.throttledValidateForm()},n.detachFromForm=function(t){var e=n.inputs.indexOf(t);-1!==e&&(n.inputs=n.inputs.slice(0,e).concat(n.inputs.slice(e+1))),n.validateForm()},n.isChanged=function(){return!E(n.getPristineValues(),n.getCurrentValues())},n.submit=function(t){var e=n.props,r=e.onSubmit,i=e.onValidSubmit,o=e.onInvalidSubmit,a=n.state.isValid;e.preventDefaultSubmit&&t&&t.preventDefault&&t.preventDefault(),n.setFormPristine(!1);var u=n.getModel();r(u,n.resetModel,n.updateInputsWithError,t),a?i(u,n.resetModel,n.updateInputsWithError,t):o(u,n.resetModel,n.updateInputsWithError,t)},n.updateInputsWithError=function(t,e){var r=n.props.preventExternalInvalidation,i=n.state.isValid;Object.entries(t).forEach((function(e){var i=e[0],o=e[1],a=n.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:r,validationError:m(o)?[o]:o})})),e&&i&&n.setFormValidState(!1)},n.updateInputsWithValue=function(t,e){Object.entries(t).forEach((function(t){var r=t[0],i=t[1],o=n.inputs.find((function(t){return t.props.name===r}));o&&o.setValue(i,e)}))},n.validate=function(t){n.state.canChange&&(0,n.props.onChange)(n.getModel(),n.isChanged());var e=n.runValidation(t);t.setState(e,n.validateForm)},n.validateForm=function(){var t=function(){var t=n.inputs.every((function(t){return t.state.isValid}));n.setFormValidState(t),n.setState({canChange:!0})};n.inputs.forEach((function(e,r){var i=n.runValidation(e);e.setState(i,r===n.inputs.length-1?t:null)})),n.inputs.length||n.setState({canChange:!0},t)},n.state={canChange:!1,isSubmitting:!1,isValid:!0,contextValue:{attachToForm:n.attachToForm,detachFromForm:n.detachFromForm,isFormDisabled:e.disabled,isValidValue:n.isValidValue,validate:n.validate,runValidation:n.runValidation}},n.inputs=[],n.emptyArray=[],n.throttledValidateForm=(r=n.validateForm,s=!0,function(){if(s){s=!1;for(var t=arguments.length,e=new Array(t),n=0;n=0||(i[n]=t[n]);return i}(t,["children","mapping","onChange","onInvalid","onInvalidSubmit","onReset","onSubmit","onValid","onValidSubmit","preventDefaultSubmit","preventExternalInvalidation","validationErrors","disabled","formElement"]);return r.createElement(k.Provider,{value:this.state.contextValue},r.createElement(i,u({onReset:this.resetInternal,onSubmit:this.submit},o,{disabled:n}),e))},e}(r.Component);U.displayName="Formsy",U.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},U.defaultProps={disabled:!1,mapping:null,onChange:b,onInvalid:b,onInvalidSubmit:b,onReset:b,onSubmit:b,onValid:b,onValidSubmit:b,preventDefaultSubmit:!0,preventExternalInvalidation:!1,validationErrors:{},formElement:"form"},exports.addValidationRule=function(t,e){T[t]=e},exports.default=U,exports.propTypes=W,exports.validationRules=T,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)||{},n.requiredValidations=!0===e?{isDefaultRequiredValue:e}:$(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(l(n))})):n.setState({value:t})},n.hasValue=function(){return w(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(l(n),t)},n.resetValue=function(){var t=n.props.validate;n.setState({value:n.state.pristineValue,isPristine:!0},(function(){t(l(n))}))},n.showError=function(){return!n.showRequired()&&!n.isValid()},n.showRequired=function(){return n.state.isRequired};var r=t.runValidation,i=t.validations,o=t.required;return n.state={value:t.value},n.setValidations(i,o),n.state=u({formSubmitted:!1,isPristine:!0,pristineValue:t.value,value:t.value},r(l(n),t.value)),n}s(n,e);var i=n.prototype;return i.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)},i.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},i.componentDidUpdate=function(t){var e=this.props,n=e.value,r=e.validations,i=e.required,o=e.validate;E(n,t.value)||this.setValue(n),E(r,t.validations)&&E(i,t.required)||(this.setValidations(r,i),o(this))},i.componentWillUnmount=function(){(0,this.props.detachFromForm)(this)},i.render=function(){var e=this.props.innerRef,n=u({},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||(m(e)?e:"Component"))+")",n.propTypes=W,n.defaultProps={innerRef:null,required:!1,validationError:"",validationErrors:{},validations:null,value:t.defaultValue},function(t){return r.createElement(k.Consumer,null,(function(e){return r.createElement(n,u({},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||function(t){for(var e=1;e()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/i,x=/^(?:[-+]?(?:\d+))?(?:\.\d*)?(?:[eE][+-]?(?:\d+))?$/,R=/^(?:[-+]?(?:0|[1-9]\d*))$/,C=/^[-+]?(?:\d*[.])?\d+$/,O=/^[\sA-ZÀ-ÖØ-öø-ÿ]+$/i,D=/^(?:\w+:)?\/\/([^\s.]+\.\S{2}|localhost[:?\d]*)\S*$/i,j=/^[A-Z\s]+$/i,M={equals:function(t,e,n){return!y(e)||E(e)||e===n},equalsField:function(t,e,n){return e===t[n]},isAlpha:function(t,e){return S(0,e,w)},isAlphanumeric:function(t,e){return S(0,e,I)},isDefaultRequiredValue:function(t,e){return F(e)},isEmail:function(t,e){return S(0,e,q)},isEmptyString:function(t,e){return E(e)},isExisty:function(t,e){return y(e)},isFalse:function(t,e){return!1===e},isFloat:function(t,e){return S(0,e,x)},isInt:function(t,e){return S(0,e,R)},isLength:function(t,e,n){return!y(e)||E(e)||e.length===n},isNumeric:function(t,e){return function(t){return"number"==typeof t}(e)||S(0,e,C)},isSpecialWords:function(t,e){return S(0,e,O)},isTrue:function(t,e){return!0===e},isUndefined:function(t,e){return v(e)},isUrl:function(t,e){return S(0,e,D)},isWords:function(t,e){return S(0,e,j)},matchRegexp:S,maxLength:function(t,e,n){return!y(e)||e.length<=n},minLength:function(t,e,n){return!y(e)||E(e)||e.length>=n}},P=function(){throw new Error("Could not find Formsy Context Provider. Did you use withFormsy outside ?")},A=r.createContext({attachToForm:P,detachFromForm:P,isFormDisabled:!0,isValidValue:P,validate:P,runValidation:P}),T=function(t){return c(t)?t.split(/,(?![^{[]*[}\]])/g).reduce((function(t,e){var n=e.split(":"),r=n.shift();if((n=n.map((function(t){try{return JSON.parse(t)}catch(e){return t}}))).length>1)throw new Error("Formsy does not support multiple args on string validations. Use object format of validations instead.");var a=i({},t);return a[r]=!n.length||n[0],a}),{}):t||{}},N={innerRef:n.func,name:n.string.isRequired,required:n.oneOfType([n.bool,n.object,n.string]),validations:n.oneOfType([n.object,n.string]),value:n.any},k=function(t){function n(n){var r,a,o;return(r=t.call(this,n)||this).prevInputNames=null,r.componentDidMount=function(){r.prevInputNames=r.inputs.map((function(t){return t.props.name})),r.validateForm()},r.componentDidUpdate=function(t){var e=r.props,n=e.validationErrors,a=e.disabled;n&&s(n)&&Object.keys(n).length>0&&r.setInputValidationErrors(n);var o=r.inputs.map((function(t){return t.props.name}));r.prevInputNames&&!g(r.prevInputNames,o)&&(r.prevInputNames=o,r.validateForm()),a!==t.disabled&&r.setState((function(t){return i({},t,{contextValue:i({},t.contextValue,{isFormDisabled:a})})}))},r.getCurrentValues=function(){return r.inputs.reduce((function(t,e){return t[e.props.name]=V(e.state.value),t}),{})},r.getModel=function(){var t=r.getCurrentValues();return r.mapModel(t)},r.getPristineValues=function(){return r.inputs.reduce((function(t,e){var n=e.props;return t[n.name]=V(n.value),t}),{})},r.setFormPristine=function(t){r.setState({formSubmitted:!t}),r.inputs.forEach((function(e){e.setState({formSubmitted:!t,isPristine:t})}))},r.setInputValidationErrors=function(t){var e=r.props.preventExternalInvalidation,n=r.state.isValid;r.inputs.forEach((function(e){var n=e.props.name;e.setState({isValid:!(n in t),validationError:c(t[n])?[t[n]]:t[n]})})),!e&&n&&r.setFormValidState(!1)},r.setFormValidState=function(t){var e=r.props,n=e.onValid,i=e.onInvalid;r.setState({isValid:t}),t?n():i()},r.isValidValue=function(t,e){return r.runValidation(t,e).isValid},r.isFormDisabled=function(){return r.props.disabled},r.mapModel=function(t){var n=r.props.mapping;if(n)return n(t);var i={};return Object.keys(t).forEach((function(n){e.set(i,n,t[n])})),i},r.reset=function(t){r.setFormPristine(!0),r.resetModel(t)},r.resetInternal=function(t){var e=r.props.onReset;t.preventDefault(),r.reset(),e&&e()},r.resetModel=function(t){r.inputs.forEach((function(n){var r=n.props.name;t&&e.has(t,r)?n.setValue(e.get(t,r)):n.resetValue()})),r.validateForm()},r.runValidation=function(t,e){void 0===e&&(e=t.state.value);var n=r.props.validationErrors,i=t.props,a=i.validationError,o=i.validationErrors,u=i.name,s=r.getCurrentValues(),l=b(e,s,t.validations,M),d=b(e,s,t.requiredValidations,M),f=!!Object.keys(t.requiredValidations).length&&!!d.success.length,p=!(l.failed.length||n&&n[t.props.name]);return{isRequired:f,isValid:!f&&p,validationError:function(){if(p&&!f)return r.emptyArray;if(l.errors.length)return l.errors;if(n&&n[u])return c(n[u])?[n[u]]:n[u];if(f){var t=o[d.success[0]]||a;return t?[t]:null}return l.failed.length?l.failed.map((function(t){return o[t]?o[t]:a})).filter((function(t,e,n){return n.indexOf(t)===e})):void 0}()}},r.attachToForm=function(t){-1===r.inputs.indexOf(t)&&r.inputs.push(t),r.state.canChange&&(0,r.props.onChange)(r.getModel(),r.isChanged()),r.throttledValidateForm()},r.detachFromForm=function(t){var e=r.inputs.indexOf(t);-1!==e&&(r.inputs=r.inputs.slice(0,e).concat(r.inputs.slice(e+1))),r.validateForm()},r.isChanged=function(){return!g(r.getPristineValues(),r.getCurrentValues())},r.submit=function(t){var e=r.props,n=e.onSubmit,i=e.onValidSubmit,a=e.onInvalidSubmit,o=r.state.isValid;e.preventDefaultSubmit&&t&&t.preventDefault&&t.preventDefault(),r.setFormPristine(!1);var u=r.getModel();n(u,r.resetModel,r.updateInputsWithError,t),o?i(u,r.resetModel,r.updateInputsWithError,t):a(u,r.resetModel,r.updateInputsWithError,t)},r.updateInputsWithError=function(t,e){var n=r.props.preventExternalInvalidation,i=r.state.isValid;Object.entries(t).forEach((function(e){var i=e[0],a=e[1],o=r.inputs.find((function(t){return t.props.name===i}));if(!o)throw new Error("You are trying to update an input that does not exist. Verify errors object with input names. "+JSON.stringify(t));o.setState({isValid:n,validationError:c(a)?[a]:a})})),e&&i&&r.setFormValidState(!1)},r.updateInputsWithValue=function(t,n){r.inputs.forEach((function(r){var i=r.props.name;t&&e.has(t,i)&&r.setValue(e.get(t,i),n)}))},r.validate=function(t){r.state.canChange&&(0,r.props.onChange)(r.getModel(),r.isChanged());var e=r.runValidation(t);t.setState(e,r.validateForm)},r.validateForm=function(){var t=function(){var t=r.inputs.every((function(t){return t.state.isValid}));r.setFormValidState(t),r.setState({canChange:!0})};r.inputs.forEach((function(e,n){var i=r.runValidation(e);e.setState(i,n===r.inputs.length-1?t:null)})),r.inputs.length||r.setState({canChange:!0},t)},r.state={canChange:!1,isSubmitting:!1,isValid:!0,contextValue:{attachToForm:r.attachToForm,detachFromForm:r.detachFromForm,isFormDisabled:n.disabled,isValidValue:r.isValidValue,validate:r.validate,runValidation:r.runValidation}},r.inputs=[],r.emptyArray=[],r.throttledValidateForm=(a=r.validateForm,o=!0,function(){if(o){o=!1;for(var t=arguments.length,e=new Array(t),n=0;n=0||(i[n]=t[n]);return i}(t,["children","mapping","onChange","onInvalid","onInvalidSubmit","onReset","onSubmit","onValid","onValidSubmit","preventDefaultSubmit","preventExternalInvalidation","validationErrors","disabled","formElement"]);return r.createElement(A.Provider,{value:this.state.contextValue},r.createElement(a,i({onReset:this.resetInternal,onSubmit:this.submit},o,{disabled:n}),e))},n}(r.Component);k.displayName="Formsy",k.propTypes={disabled:n.bool,mapping:n.func,formElement:n.oneOfType([n.string,n.object,n.func]),onChange:n.func,onInvalid:n.func,onInvalidSubmit:n.func,onReset:n.func,onSubmit:n.func,onValid:n.func,onValidSubmit:n.func,preventDefaultSubmit:n.bool,preventExternalInvalidation:n.bool,validationErrors:n.object},k.defaultProps={disabled:!1,mapping:null,onChange:h,onInvalid:h,onInvalidSubmit:h,onReset:h,onSubmit:h,onValid:h,onValidSubmit:h,preventDefaultSubmit:!0,preventExternalInvalidation:!1,validationErrors:{},formElement:"form"},exports.addValidationRule=function(t,e){M[t]=e},exports.default=k,exports.propTypes=N,exports.validationRules=M,exports.withFormsy=function(t){var e,n=function(e){function n(t){var n;(n=e.call(this,t)||this).getErrorMessage=function(){var t=n.getErrorMessages();return t.length?t[0]:null},n.getErrorMessages=function(){var t=n.state.validationError;return(!n.isValid()||n.showRequired())&&t||[]},n.getValue=function(){return n.state.value},n.setValidations=function(t,e){n.validations=T(t)||{},n.requiredValidations=!0===e?{isDefaultRequiredValue:e}:T(e)},n.setValue=function(t,e){void 0===e&&(e=!0);var r=n.props.validate;e?n.setState({value:t,isPristine:!1},(function(){r(o(n))})):n.setState({value:t})},n.hasValue=function(){return F(n.state.value)},n.isFormDisabled=function(){return n.props.isFormDisabled},n.isFormSubmitted=function(){return n.state.formSubmitted},n.isPristine=function(){return n.state.isPristine},n.isRequired=function(){return!!n.props.required},n.isValid=function(){return n.state.isValid},n.isValidValue=function(t){return n.props.isValidValue(o(n),t)},n.resetValue=function(){var t=n.props.validate;n.setState({value:n.state.pristineValue,isPristine:!0},(function(){t(o(n))}))},n.showError=function(){return!n.showRequired()&&!n.isValid()},n.showRequired=function(){return n.state.isRequired};var r=t.runValidation,a=t.validations,u=t.required;return n.state={value:t.value},n.setValidations(a,u),n.state=i({formSubmitted:!1,isPristine:!0,pristineValue:t.value,value:t.value},r(o(n),t.value)),n}a(n,e);var u=n.prototype;return u.componentDidMount=function(){var t=this.props,e=t.attachToForm;if(!t.name)throw new Error("Form Input requires a name property when used");e(this)},u.shouldComponentUpdate=function(t,e){var n=this.state,r=function(t,e){return Object.keys(t).some((function(n){return t[n]!==e[n]}))},i=r(this.props,t),a=r(n,e);return i||a},u.componentDidUpdate=function(t){var e=this.props,n=e.value,r=e.validations,i=e.required,a=e.validate;g(n,t.value)||this.setValue(n),g(r,t.validations)&&g(i,t.required)||(this.setValidations(r,i),a(this))},u.componentWillUnmount=function(){(0,this.props.detachFromForm)(this)},u.render=function(){var e=this.props.innerRef,n=i({},this.props,{errorMessage:this.getErrorMessage(),errorMessages:this.getErrorMessages(),hasValue:this.hasValue(),isFormDisabled:this.isFormDisabled(),isFormSubmitted:this.isFormSubmitted(),isPristine:this.isPristine(),isRequired:this.isRequired(),isValid:this.isValid(),isValidValue:this.isValidValue,resetValue:this.resetValue,setValidations:this.setValidations,setValue:this.setValue,showError:this.showError(),showRequired:this.showRequired(),value:this.getValue()});return e&&(n.ref=e),r.createElement(t,n)},n}(r.Component);return n.displayName="Formsy("+((e=t).displayName||e.name||(c(e)?e:"Component"))+")",n.propTypes=N,n.defaultProps={innerRef:null,required:!1,validationError:"",validationErrors:{},validations:null,value:t.defaultValue},function(t){return r.createElement(A.Consumer,null,(function(e){return r.createElement(n,i({},t,e))}))}}; //# 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 b92279f8..3ac6ceef 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.isplainobject';\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: /^(([^<>()[\\]\\\\.,;:\\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 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 extends React.Component & FormsyContextInterface, WrapperState>\n implements WrapperInstanceMethods {\n public validations?: Validations;\n\n public requiredValidations?: Validations;\n\n public static displayName = `Formsy(${getDisplayName(WrappedComponent)})`;\n\n public static propTypes: any = propTypes;\n\n public static defaultProps: any = {\n innerRef: null,\n required: false,\n validationError: '',\n validationErrors: {},\n validations: null,\n value: (WrappedComponent as ComponentWithStaticAttributes).defaultValue,\n };\n\n public constructor(props) {\n super(props);\n const { runValidation, validations, required, value } = props;\n\n this.state = { value } as any;\n\n this.setValidations(validations, required);\n\n this.state = {\n formSubmitted: false,\n isPristine: true,\n pristineValue: props.value,\n value: props.value,\n ...runValidation(this, props.value),\n };\n }\n\n public componentDidMount() {\n const { name, attachToForm } = this.props;\n\n if (!name) {\n throw new Error('Form Input requires a name property when used');\n }\n\n attachToForm(this);\n }\n\n public shouldComponentUpdate(nextProps, nextState) {\n const { props, state } = this;\n const isChanged = (a: object, b: object): boolean => Object.keys(a).some((k) => a[k] !== b[k]);\n const isPropsChanged = isChanged(props, nextProps);\n const isStateChanged = isChanged(state, nextState);\n\n return isPropsChanged || isStateChanged;\n }\n\n public componentDidUpdate(prevProps) {\n const { value, validations, required, validate } = this.props;\n\n // If the value passed has changed, set it. If value is not passed it will\n // internally update, and this will never run\n if (!utils.isSame(value, prevProps.value)) {\n this.setValue(value);\n }\n\n // If validations or required is changed, run a new validation\n if (!utils.isSame(validations, prevProps.validations) || !utils.isSame(required, prevProps.required)) {\n this.setValidations(validations, required);\n validate(this);\n }\n }\n\n // Detach it when component unmounts\n public componentWillUnmount() {\n const { detachFromForm } = this.props;\n detachFromForm(this);\n }\n\n public getErrorMessage = (): ValidationError | null => {\n const messages = this.getErrorMessages();\n return messages.length ? messages[0] : null;\n };\n\n public getErrorMessages = (): ValidationError[] => {\n const { validationError } = this.state;\n\n if (!this.isValid() || this.showRequired()) {\n return validationError || [];\n }\n return [];\n };\n\n // eslint-disable-next-line react/destructuring-assignment\n public getValue = (): V => this.state.value;\n\n public setValidations = (validations: Validations, required: RequiredValidation): void => {\n // Add validations to the store itself as the props object can not be modified\n this.validations = convertValidationsToObject(validations) || {};\n this.requiredValidations =\n required === true ? { isDefaultRequiredValue: required } : convertValidationsToObject(required);\n };\n\n // By default, we validate after the value has been set.\n // A user can override this and pass a second parameter of `false` to skip validation.\n public setValue = (value: V, validate = true): void => {\n const { validate: validateForm } = this.props;\n\n if (!validate) {\n this.setState({ value });\n } else {\n this.setState(\n {\n value,\n isPristine: false,\n },\n () => {\n validateForm(this);\n },\n );\n }\n };\n\n // eslint-disable-next-line react/destructuring-assignment\n public hasValue = () => {\n const { value } = this.state;\n return isDefaultRequiredValue(value);\n };\n\n // eslint-disable-next-line react/destructuring-assignment\n public isFormDisabled = (): boolean => this.props.isFormDisabled;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isFormSubmitted = (): boolean => this.state.formSubmitted;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isPristine = (): boolean => this.state.isPristine;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isRequired = (): boolean => !!this.props.required;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isValid = (): boolean => this.state.isValid;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isValidValue = (value: V) => this.props.isValidValue(this, value);\n\n public resetValue = () => {\n const { pristineValue } = this.state;\n const { validate } = this.props;\n\n this.setState(\n {\n value: pristineValue,\n isPristine: true,\n },\n () => {\n validate(this);\n },\n );\n };\n\n public showError = (): boolean => !this.showRequired() && !this.isValid();\n\n // eslint-disable-next-line react/destructuring-assignment\n public showRequired = (): boolean => this.state.isRequired;\n\n public render() {\n const { innerRef } = this.props;\n const propsForElement: T & PassDownProps = {\n ...this.props,\n errorMessage: this.getErrorMessage(),\n errorMessages: this.getErrorMessages(),\n hasValue: this.hasValue(),\n isFormDisabled: this.isFormDisabled(),\n isFormSubmitted: this.isFormSubmitted(),\n isPristine: this.isPristine(),\n isRequired: this.isRequired(),\n isValid: this.isValid(),\n isValidValue: this.isValidValue,\n resetValue: this.resetValue,\n setValidations: this.setValidations,\n setValue: this.setValue,\n showError: this.showError(),\n showRequired: this.showRequired(),\n value: this.getValue(),\n };\n\n if (innerRef) {\n propsForElement.ref = innerRef;\n }\n\n return React.createElement(WrappedComponent, propsForElement);\n }\n }\n\n // eslint-disable-next-line react/display-name\n return (props) =>\n React.createElement(FormsyContext.Consumer, null, (contextValue) => {\n return React.createElement(WithFormsyWrapper, { ...props, ...contextValue });\n });\n}\n","/* eslint-disable react/no-unused-state, react/default-props-match-prop-types */\nimport get from 'lodash.get';\nimport has from 'lodash.has';\nimport set from 'lodash.set';\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 = (values, validate) => {\n Object.entries(values).forEach(([name, value]) => {\n const input = this.inputs.find((component) => component.props.name === name);\n\n if (input) {\n input.setValue(value, validate);\n }\n });\n };\n\n // Use the binded values and the actual input value to\n // validate the input and set its state. Then check the\n // state of the form itself\n public validate = (component: InputComponent) => {\n const { onChange } = this.props;\n const { canChange } = this.state;\n\n // Trigger onChange\n if (canChange) {\n onChange(this.getModel(), this.isChanged());\n }\n\n const validationState = this.runValidation(component);\n // Run through the validations, split them up and call\n // the validator IF there is a value or it is required\n component.setState(validationState, this.validateForm);\n };\n\n // Validate the form by going through all child input components\n // and check their state\n public validateForm = () => {\n // We need a callback as we are validating all inputs again. This will\n // run when the last component has set its state\n const onValidationComplete = () => {\n const allIsValid = this.inputs.every((component) => component.state.isValid);\n\n this.setFormValidState(allIsValid);\n\n // Tell the form that it can start to trigger change events\n this.setState({\n canChange: true,\n });\n };\n\n // Run validation again in case affected by other inputs. The\n // last component validated will run the onValidationComplete callback\n this.inputs.forEach((component, index) => {\n const validationState = this.runValidation(component);\n const isFinalInput = index === this.inputs.length - 1;\n const callback = isFinalInput ? onValidationComplete : null;\n component.setState(validationState, callback);\n });\n\n // If there are no inputs, set state where form is ready to trigger\n // change event. New inputs might be added later\n if (!this.inputs.length) {\n this.setState(\n {\n canChange: true,\n },\n onValidationComplete,\n );\n }\n };\n\n public render() {\n const {\n /* eslint-disable @typescript-eslint/no-unused-vars */\n children,\n mapping,\n onChange,\n onInvalid,\n onInvalidSubmit,\n onReset,\n onSubmit,\n onValid,\n onValidSubmit,\n preventDefaultSubmit,\n preventExternalInvalidation,\n validationErrors,\n disabled,\n formElement,\n ...nonFormsyProps\n } = this.props;\n const { contextValue } = this.state;\n\n return React.createElement(\n FormsyContext.Provider,\n {\n value: contextValue,\n },\n React.createElement(\n formElement,\n {\n onReset: this.resetInternal,\n onSubmit: this.submit,\n ...nonFormsyProps,\n disabled,\n },\n children,\n ),\n );\n }\n}\n"],"names":["isArray","value","Array","isObject","isPlainObject","isDate","Date","isFunction","isString","isRegex","RegExp","isValueStringEmpty","isValueNullOrUndefined","isValueUndefined","undefined","noop","protectAgainstParamReassignment","isSame","a","b","length","every","item","index","toString","Object","keys","key","runRules","currentValues","validations","validationRules","results","errors","failed","success","forEach","validationName","validationsVal","validationRulesVal","addToResults","validation","push","Error","isExisty","isEmpty","isTypeUndefined","isDefaultRequiredValue","matchRegexp","_values","regexp","test","REGEX_PATTERNS","equals","eql","equalsField","values","field","isAlpha","isAlphanumeric","isEmail","isEmptyString","isFalse","isFloat","isInt","isLength","isNumeric","isNumber","isSpecialWords","isTrue","isUndefined","isUrl","isWords","maxLength","minLength","throwNoFormsyProvider","React","createContext","attachToForm","detachFromForm","isFormDisabled","isValidValue","validate","runValidation","convertValidationsToObject","split","reduce","validationsAccumulator","args","validateMethod","shift","map","arg","JSON","parse","e","validationsAccumulatorCopy","propTypes","innerRef","PropTypes","func","name","string","isRequired","required","oneOfType","bool","object","any","Formsy","props","callback","enableCall","prevInputNames","_this","inputs","component","validateForm","prevProps","validationErrors","disabled","setInputValidationErrors","newInputNames","utils","setState","state","contextValue","valueAccumulator","getCurrentValues","mapModel","isPristine","formSubmitted","preventExternalInvalidation","isValid","validationError","setFormValidState","allIsValid","onValid","onInvalid","model","mapping","returnModel","set","setFormPristine","resetModel","event","onReset","preventDefault","reset","data","has","setValue","get","resetValue","componentValidationErrors","validationResults","requiredResults","requiredValidations","emptyArray","error","filter","x","pos","arr","indexOf","canChange","onChange","getModel","isChanged","throttledValidateForm","componentPos","slice","concat","getPristineValues","onSubmit","onValidSubmit","onInvalidSubmit","preventDefaultSubmit","updateInputsWithError","invalidate","entries","find","input","stringify","validationState","onValidationComplete","isSubmitting","apply","this","setTimeout","render","children","formElement","nonFormsyProps","createElement","FormsyContext","Provider","resetInternal","submit","Component","WrappedComponent","WithFormsyWrapper","messages","getErrorMessages","showRequired","pristineValue","setValidations","componentDidMount","shouldComponentUpdate","nextProps","nextState","some","k","isPropsChanged","isStateChanged","componentDidUpdate","componentWillUnmount","propsForElement","errorMessage","getErrorMessage","errorMessages","hasValue","isFormSubmitted","showError","getValue","ref","displayName","defaultValue","Consumer"],"mappings":"uuBAIgBA,EAAQC,UACfC,MAAMF,QAAQC,YAGPE,EAASF,UAChBG,EAAcH,YAOPI,EAAOJ,UACdA,aAAiBK,cAGVC,EAAWN,UACR,OAAVA,GAAmC,mBAAVA,WAGlBO,EAASP,SACC,iBAAVA,WAOAQ,EAAQR,UACfA,aAAiBS,gBAGVC,EAAmBV,SAChB,KAAVA,WAGOW,EAAuBX,UAC9BA,MAAAA,WAGOY,EAAiBZ,eACda,IAAVb,WAGOc,cAIAC,EAAgCf,UAE1CE,EAASF,QAAoBA,GAC7BD,EAAQC,aAAmBA,GACxBA,WAGOgB,EAAOC,EAAYC,iBACtBD,UAAaC,IAIpBnB,EAAQkB,IAAMlB,EAAQmB,GACpBD,EAAEE,SAAWD,EAAEC,QAIZF,EAAEG,OAAM,SAACC,EAAMC,UAAUN,EAAOK,EAAMH,EAAEI,OAG7ChB,E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,IAAAA,YAAa0E,IAAAA,SAAUtB,IAAAA,SAIjCyC,EAAa1H,EAAOqH,EAAUrH,aAC5BsJ,SAAStJ,GAIX0H,EAAa7F,EAAawF,EAAUxF,cAAiB6F,EAAanB,EAAUc,EAAUd,iBACpFsG,eAAehL,EAAa0E,GACjCtB,EAAS0G,UAKN4B,qBAAA,YAELzI,EAD2B6G,KAAK9E,MAAxB/B,gBACO6G,SA2FVE,OAAA,eACG5F,EAAa0F,KAAK9E,MAAlBZ,SACFuH,OACD7B,KAAK9E,OACR4G,aAAc9B,KAAK+B,kBACnBC,cAAehC,KAAKe,mBACpBkB,SAAUjC,KAAKiC,WACf7I,eAAgB4G,KAAK5G,iBACrB8I,gBAAiBlC,KAAKkC,kBACtB5F,WAAY0D,KAAK1D,aACjB3B,WAAYqF,KAAKrF,aACjB8B,QAASuD,KAAKvD,UACdpD,aAAc2G,KAAK3G,aACnBwE,WAAYmC,KAAKnC,WACjBqD,eAAgBlB,KAAKkB,eACrBvD,SAAUqC,KAAKrC,SACfwE,UAAWnC,KAAKmC,YAChBnB,aAAchB,KAAKgB,eACnB3M,MAAO2L,KAAKoC,oBAGV9H,IACFuH,EAAgBQ,IAAM/H,GAGjBtB,EAAMsH,cAAcM,EAAkBiB,OA9LjB7I,EAAM2H,kBAMtBE,0BAbMrF,EAaiCoF,GAZtC0B,aAAe9G,EAAUf,OAASsB,EAAeP,GAAaA,EAAY,kBAc3EqF,YAAiBxG,EAEjBwG,eAAoB,CAChCvG,SAAU,KACVM,UAAU,EACV8B,gBAAiB,GACjBf,iBAAkB,GAClBzF,YAAa,KACb7B,MAAQuM,EAAmD2B,cAmLxD,SAACrH,UACNlC,EAAMsH,cAAcC,EAAciC,SAAU,MAAM,SAACtG,UAC1ClD,EAAMsH,cAAcO,OAAwB3F,EAAUgB"} \ No newline at end of file +{"version":3,"file":"formsy-react.cjs.production.min.js","sources":["../src/utils.ts","../src/validationRules.ts","../src/FormsyContext.ts","../src/withFormsy.ts","../src/Formsy.ts"],"sourcesContent":["import { isPlainObject } from 'lodash';\n\nimport { ValidationError, Validations, Values } from './interfaces';\n\nexport function isArray(value: unknown): value is unknown[] {\n return Array.isArray(value);\n}\n\nexport function isObject(value: unknown): value is object {\n return isPlainObject(value);\n}\n\nexport function isTypeUndefined(value: unknown): value is undefined {\n return typeof value === 'undefined';\n}\n\nexport function isDate(value: unknown): value is Date {\n return value instanceof Date;\n}\n\nexport function isFunction(value: unknown): value is Function {\n return value !== null && typeof value === 'function';\n}\n\nexport function isString(value: unknown): value is string {\n return typeof value === 'string';\n}\n\nexport function isNumber(value: unknown): value is number {\n return typeof value === 'number';\n}\n\nexport function isRegex(value: unknown): value is RegExp {\n return value instanceof RegExp;\n}\n\nexport function isValueStringEmpty(value: string): boolean {\n return value === '';\n}\n\nexport function isValueNullOrUndefined(value: unknown): boolean {\n return value === null || value === undefined;\n}\n\nexport function isValueUndefined(value: unknown): boolean {\n return value === undefined;\n}\n\nexport function noop() {\n // do nothing.\n}\n\nexport function protectAgainstParamReassignment(value: unknown) {\n // Clone objects to avoid accidental param reassignment\n if (isObject(value)) return { ...value };\n if (isArray(value)) return [...value];\n return value;\n}\n\nexport function isSame(a: unknown, b: unknown) {\n if (typeof a !== typeof b) {\n return false;\n }\n\n if (isArray(a) && isArray(b)) {\n if (a.length !== b.length) {\n return false;\n }\n\n return a.every((item, index) => isSame(item, b[index]));\n }\n\n if (isFunction(a) && isFunction(b)) {\n return a.toString() === b.toString();\n }\n\n if (isDate(a) && isDate(b)) {\n return a.toString() === b.toString();\n }\n\n if (isObject(a) && isObject(b)) {\n if (Object.keys(a).length !== Object.keys(b).length) {\n return false;\n }\n\n return Object.keys(a).every((key) => isSame(a[key], b[key]));\n }\n\n if (isRegex(a) && isRegex(b)) {\n return a.toString() === b.toString();\n }\n\n return a === b;\n}\n\ninterface RulesResult {\n errors: ValidationError[];\n failed: string[];\n success: string[];\n}\n\nexport function runRules(\n value: V,\n currentValues: Values,\n validations: Validations,\n validationRules: Validations,\n) {\n const results: RulesResult = {\n errors: [],\n failed: [],\n success: [],\n };\n\n Object.keys(validations).forEach((validationName) => {\n const validationsVal = validations[validationName];\n const validationRulesVal = validationRules[validationName];\n const addToResults = (validation) => {\n if (isString(validation)) {\n results.errors.push(validation);\n results.failed.push(validationName);\n } else if (!validation) {\n results.failed.push(validationName);\n } else {\n results.success.push(validationName);\n }\n };\n\n if (validationRulesVal && isFunction(validationsVal)) {\n throw new Error(`Formsy does not allow you to override default validations: ${validationName}`);\n }\n\n if (!validationRulesVal && !isFunction(validationsVal)) {\n throw new Error(`Formsy does not have the validation rule: ${validationName}`);\n }\n\n if (isFunction(validationsVal)) {\n return addToResults(validationsVal(currentValues, value));\n }\n\n return addToResults(validationRulesVal(currentValues, value, validationsVal));\n });\n\n return results;\n}\n\nexport function throttle(callback, interval) {\n let enableCall = true;\n\n return function (...args) {\n if (!enableCall) return;\n\n enableCall = false;\n callback.apply(this, args);\n setTimeout(() => (enableCall = true), interval);\n };\n}\n","import { ValidationFunction, Values } from './interfaces';\nimport {\n isNumber,\n isString,\n isTypeUndefined,\n isValueNullOrUndefined,\n isValueStringEmpty,\n isValueUndefined,\n} from './utils';\n\nexport function isExisty(value: V) {\n return !isValueNullOrUndefined(value);\n}\n\nexport function isEmpty(value: V) {\n if (isString(value)) {\n return isValueStringEmpty(value);\n }\n if (isTypeUndefined(value)) {\n return false;\n }\n return isValueUndefined(value);\n}\n\nexport function isDefaultRequiredValue(value: unknown) {\n return isString(value) ? isValueStringEmpty(value) : isValueNullOrUndefined(value);\n}\n\nexport function matchRegexp(_values: Values, value: V, regexp: RegExp) {\n return !isExisty(value) || isEmpty(value) || regexp.test(`${value}`);\n}\n\ninterface Validations {\n [key: string]: ValidationFunction;\n}\n\nconst REGEX_PATTERNS = {\n ALPHA: /^[A-Z]+$/i,\n ALPHANUMERIC: /^[0-9A-Z]+$/i,\n EMAIL: /^(([^<>()[\\]\\\\.,;:\\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 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 public validations?: Validations;\n\n public requiredValidations?: Validations;\n\n public static displayName = `Formsy(${getDisplayName(WrappedComponent)})`;\n\n public static propTypes: any = propTypes;\n\n public static defaultProps: any = {\n innerRef: null,\n required: false,\n validationError: '',\n validationErrors: {},\n validations: null,\n value: (WrappedComponent as ComponentWithStaticAttributes).defaultValue,\n };\n\n public constructor(props) {\n super(props);\n const { runValidation, validations, required, value } = props;\n\n this.state = { value } as any;\n\n this.setValidations(validations, required);\n\n this.state = {\n formSubmitted: false,\n isPristine: true,\n pristineValue: props.value,\n value: props.value,\n ...runValidation(this, props.value),\n };\n }\n\n public componentDidMount() {\n const { name, attachToForm } = this.props;\n\n if (!name) {\n throw new Error('Form Input requires a name property when used');\n }\n\n attachToForm(this);\n }\n\n public shouldComponentUpdate(nextProps, nextState) {\n const { props, state } = this;\n const isChanged = (a: object, b: object): boolean => Object.keys(a).some((k) => a[k] !== b[k]);\n const isPropsChanged = isChanged(props, nextProps);\n const isStateChanged = isChanged(state, nextState);\n\n return isPropsChanged || isStateChanged;\n }\n\n public componentDidUpdate(prevProps) {\n const { value, validations, required, validate } = this.props;\n\n // If the value passed has changed, set it. If value is not passed it will\n // internally update, and this will never run\n if (!utils.isSame(value, prevProps.value)) {\n this.setValue(value);\n }\n\n // If validations or required is changed, run a new validation\n if (!utils.isSame(validations, prevProps.validations) || !utils.isSame(required, prevProps.required)) {\n this.setValidations(validations, required);\n validate(this);\n }\n }\n\n // Detach it when component unmounts\n public componentWillUnmount() {\n const { detachFromForm } = this.props;\n detachFromForm(this);\n }\n\n public getErrorMessage = (): ValidationError | null => {\n const messages = this.getErrorMessages();\n return messages.length ? messages[0] : null;\n };\n\n public getErrorMessages = (): ValidationError[] => {\n const { validationError } = this.state;\n\n if (!this.isValid() || this.showRequired()) {\n return validationError || [];\n }\n return [];\n };\n\n // eslint-disable-next-line react/destructuring-assignment\n public getValue = (): V => this.state.value;\n\n public setValidations = (validations: Validations, required: RequiredValidation): void => {\n // Add validations to the store itself as the props object can not be modified\n this.validations = convertValidationsToObject(validations) || {};\n this.requiredValidations =\n required === true ? { isDefaultRequiredValue: required } : convertValidationsToObject(required);\n };\n\n // By default, we validate after the value has been set.\n // A user can override this and pass a second parameter of `false` to skip validation.\n public setValue = (value: V, validate = true): void => {\n const { validate: validateForm } = this.props;\n\n if (!validate) {\n this.setState({ value });\n } else {\n this.setState(\n {\n value,\n isPristine: false,\n },\n () => {\n validateForm(this);\n },\n );\n }\n };\n\n // eslint-disable-next-line react/destructuring-assignment\n public hasValue = () => {\n const { value } = this.state;\n return isDefaultRequiredValue(value);\n };\n\n // eslint-disable-next-line react/destructuring-assignment\n public isFormDisabled = (): boolean => this.props.isFormDisabled;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isFormSubmitted = (): boolean => this.state.formSubmitted;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isPristine = (): boolean => this.state.isPristine;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isRequired = (): boolean => !!this.props.required;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isValid = (): boolean => this.state.isValid;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isValidValue = (value: V) => this.props.isValidValue(this, value);\n\n public resetValue = () => {\n const { pristineValue } = this.state;\n const { validate } = this.props;\n\n this.setState(\n {\n value: pristineValue,\n isPristine: true,\n },\n () => {\n validate(this);\n },\n );\n };\n\n public showError = (): boolean => !this.showRequired() && !this.isValid();\n\n // eslint-disable-next-line react/destructuring-assignment\n public showRequired = (): boolean => this.state.isRequired;\n\n public render() {\n const { innerRef } = this.props;\n const propsForElement: T & PassDownProps = {\n ...this.props,\n errorMessage: this.getErrorMessage(),\n errorMessages: this.getErrorMessages(),\n hasValue: this.hasValue(),\n isFormDisabled: this.isFormDisabled(),\n isFormSubmitted: this.isFormSubmitted(),\n isPristine: this.isPristine(),\n isRequired: this.isRequired(),\n isValid: this.isValid(),\n isValidValue: this.isValidValue,\n resetValue: this.resetValue,\n setValidations: this.setValidations,\n setValue: this.setValue,\n showError: this.showError(),\n showRequired: this.showRequired(),\n value: this.getValue(),\n };\n\n if (innerRef) {\n propsForElement.ref = innerRef;\n }\n\n return React.createElement(WrappedComponent, propsForElement);\n }\n }\n\n // eslint-disable-next-line react/display-name\n return (props) =>\n React.createElement(FormsyContext.Consumer, null, (contextValue) => {\n return React.createElement(WithFormsyWrapper, { ...props, ...contextValue });\n });\n}\n","/* eslint-disable react/no-unused-state, react/default-props-match-prop-types */\nimport { get, has, set } from 'lodash';\nimport PropTypes from 'prop-types';\nimport React from 'react';\nimport FormsyContext from './FormsyContext';\nimport {\n FormsyContextInterface,\n IModel,\n InputComponent,\n IResetModel,\n IUpdateInputsWithError,\n IUpdateInputsWithValue,\n ValidationError,\n} from './interfaces';\nimport { throttle, isObject, isString } from './utils';\nimport * as utils from './utils';\nimport validationRules from './validationRules';\nimport { PassDownProps } from './withFormsy';\n\ntype FormHTMLAttributesCleaned = Omit, 'onChange' | 'onSubmit'>;\n\ntype OnSubmitCallback = (\n model: IModel,\n resetModel: IResetModel,\n updateInputsWithError: IUpdateInputsWithError,\n event: React.SyntheticEvent>,\n) => void;\n\ntype FormElementType =\n | string\n | React.ComponentType<{\n onReset?: (e: React.SyntheticEvent) => void;\n onSubmit?: (e: React.SyntheticEvent) => void;\n disabled?: boolean;\n children?: React.ReactChildren;\n }>;\n\nexport interface FormsyProps extends FormHTMLAttributesCleaned {\n disabled: boolean;\n mapping: null | ((model: IModel) => IModel);\n onChange: (model: IModel, isChanged: boolean) => void;\n onInvalid: () => void;\n onReset?: () => void;\n onSubmit?: OnSubmitCallback;\n onValidSubmit?: OnSubmitCallback;\n onInvalidSubmit: OnSubmitCallback;\n onValid: () => void;\n preventDefaultSubmit?: boolean;\n preventExternalInvalidation?: boolean;\n validationErrors?: null | object;\n formElement?: FormElementType;\n}\n\nexport interface FormsyState {\n canChange: boolean;\n contextValue: FormsyContextInterface;\n formSubmitted?: boolean;\n isPristine?: boolean;\n isSubmitting: boolean;\n isValid: boolean;\n}\n\nconst ONE_RENDER_FRAME = 66;\n\nexport class Formsy extends React.Component {\n public inputs: InstanceType>[];\n\n public emptyArray: any[];\n\n public prevInputNames: any[] | null = null;\n\n public static displayName = 'Formsy';\n\n public static propTypes = {\n disabled: PropTypes.bool,\n mapping: PropTypes.func,\n formElement: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.func]),\n onChange: PropTypes.func,\n onInvalid: PropTypes.func,\n onInvalidSubmit: PropTypes.func,\n onReset: PropTypes.func,\n onSubmit: PropTypes.func,\n onValid: PropTypes.func,\n onValidSubmit: PropTypes.func,\n preventDefaultSubmit: PropTypes.bool,\n preventExternalInvalidation: PropTypes.bool,\n validationErrors: PropTypes.object, // eslint-disable-line\n };\n\n public static defaultProps: Partial = {\n disabled: false,\n mapping: null,\n onChange: utils.noop,\n onInvalid: utils.noop,\n onInvalidSubmit: utils.noop,\n onReset: utils.noop,\n onSubmit: utils.noop,\n onValid: utils.noop,\n onValidSubmit: utils.noop,\n preventDefaultSubmit: true,\n preventExternalInvalidation: false,\n validationErrors: {},\n formElement: 'form',\n };\n\n private readonly throttledValidateForm: () => void;\n\n public constructor(props: FormsyProps) {\n super(props);\n this.state = {\n canChange: false,\n isSubmitting: false,\n isValid: true,\n contextValue: {\n attachToForm: this.attachToForm,\n detachFromForm: this.detachFromForm,\n isFormDisabled: props.disabled,\n isValidValue: this.isValidValue,\n validate: this.validate,\n runValidation: this.runValidation,\n },\n };\n this.inputs = [];\n this.emptyArray = [];\n this.throttledValidateForm = throttle(this.validateForm, ONE_RENDER_FRAME);\n }\n\n public componentDidMount = () => {\n this.prevInputNames = this.inputs.map((component) => component.props.name);\n this.validateForm();\n };\n\n public componentDidUpdate = (prevProps: FormsyProps) => {\n const { validationErrors, disabled } = this.props;\n\n if (validationErrors && isObject(validationErrors) && Object.keys(validationErrors).length > 0) {\n this.setInputValidationErrors(validationErrors);\n }\n\n const newInputNames = this.inputs.map((component) => component.props.name);\n if (this.prevInputNames && !utils.isSame(this.prevInputNames, newInputNames)) {\n this.prevInputNames = newInputNames;\n this.validateForm();\n }\n\n // Keep the disabled value in state/context the same as from props\n if (disabled !== prevProps.disabled) {\n // eslint-disable-next-line\n this.setState((state) => ({\n ...state,\n contextValue: {\n ...state.contextValue,\n isFormDisabled: disabled,\n },\n }));\n }\n };\n\n public getCurrentValues = () =>\n this.inputs.reduce((valueAccumulator, component) => {\n const {\n props: { name },\n state: { value },\n } = component;\n // eslint-disable-next-line no-param-reassign\n valueAccumulator[name] = utils.protectAgainstParamReassignment(value);\n return valueAccumulator;\n }, {});\n\n public getModel = () => {\n const currentValues = this.getCurrentValues();\n return this.mapModel(currentValues);\n };\n\n public getPristineValues = () =>\n this.inputs.reduce((valueAccumulator, component) => {\n const {\n props: { name, value },\n } = component;\n // eslint-disable-next-line no-param-reassign\n valueAccumulator[name] = utils.protectAgainstParamReassignment(value);\n return valueAccumulator;\n }, {});\n\n public setFormPristine = (isPristine: boolean) => {\n this.setState({\n formSubmitted: !isPristine,\n });\n\n // Iterate through each component and set it as pristine\n // or \"dirty\".\n this.inputs.forEach((component) => {\n component.setState({\n formSubmitted: !isPristine,\n isPristine,\n });\n });\n };\n\n public setInputValidationErrors = (errors) => {\n const { preventExternalInvalidation } = this.props;\n const { isValid } = this.state;\n\n this.inputs.forEach((component) => {\n const { name } = component.props;\n component.setState({\n isValid: !(name in errors),\n validationError: isString(errors[name]) ? [errors[name]] : errors[name],\n });\n });\n if (!preventExternalInvalidation && isValid) {\n this.setFormValidState(false);\n }\n };\n\n public setFormValidState = (allIsValid: boolean) => {\n const { onValid, onInvalid } = this.props;\n\n this.setState({\n isValid: allIsValid,\n });\n\n if (allIsValid) {\n onValid();\n } else {\n onInvalid();\n }\n };\n\n public isValidValue = (component, value) => this.runValidation(component, value).isValid;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isFormDisabled = () => this.props.disabled;\n\n public mapModel = (model: IModel): IModel => {\n const { mapping } = this.props;\n\n if (mapping) {\n return mapping(model);\n }\n\n const returnModel = {};\n Object.keys(model).forEach((key) => {\n set(returnModel, key, model[key]);\n });\n return returnModel;\n };\n\n public reset = (model?: IModel) => {\n this.setFormPristine(true);\n this.resetModel(model);\n };\n\n private resetInternal = (event) => {\n const { onReset } = this.props;\n\n event.preventDefault();\n this.reset();\n if (onReset) {\n onReset();\n }\n };\n\n // Reset each key in the model to the original / initial / specified value\n private resetModel: IResetModel = (data) => {\n this.inputs.forEach((component) => {\n const { name } = component.props;\n if (data && has(data, name)) {\n component.setValue(get(data, name));\n } else {\n component.resetValue();\n }\n });\n this.validateForm();\n };\n\n // Checks validation on current value or a passed value\n public runValidation = (\n component: InputComponent,\n value = component.state.value,\n ): { isRequired: boolean; isValid: boolean; validationError: ValidationError[] } => {\n const { validationErrors } = this.props;\n const { validationError, validationErrors: componentValidationErrors, name } = component.props;\n const currentValues = this.getCurrentValues();\n const validationResults = utils.runRules(value, currentValues, component.validations, validationRules);\n const requiredResults = utils.runRules(value, currentValues, component.requiredValidations, validationRules);\n const isRequired = Object.keys(component.requiredValidations).length ? !!requiredResults.success.length : false;\n const isValid = !validationResults.failed.length && !(validationErrors && validationErrors[component.props.name]);\n\n return {\n isRequired,\n isValid: isRequired ? false : isValid,\n validationError: (() => {\n if (isValid && !isRequired) {\n return this.emptyArray;\n }\n\n if (validationResults.errors.length) {\n return validationResults.errors;\n }\n\n if (validationErrors && validationErrors[name]) {\n return isString(validationErrors[name]) ? [validationErrors[name]] : validationErrors[name];\n }\n\n if (isRequired) {\n const error = componentValidationErrors[requiredResults.success[0]] || validationError;\n return error ? [error] : null;\n }\n\n if (validationResults.failed.length) {\n return validationResults.failed\n .map((failed) => (componentValidationErrors[failed] ? componentValidationErrors[failed] : validationError))\n .filter((x, pos, arr) => arr.indexOf(x) === pos); // remove duplicates\n }\n\n // This line is not reachable\n // istanbul ignore next\n return undefined;\n })(),\n };\n };\n\n // Method put on each input component to register\n // itself to the form\n public attachToForm = (component) => {\n if (this.inputs.indexOf(component) === -1) {\n this.inputs.push(component);\n }\n\n const { onChange } = this.props;\n const { canChange } = this.state;\n\n // Trigger onChange\n if (canChange) {\n onChange(this.getModel(), this.isChanged());\n }\n\n // Will be triggered immediately & every one frame rate\n this.throttledValidateForm();\n };\n\n // Method put on each input component to unregister\n // itself from the form\n public detachFromForm = (component: InputComponent) => {\n const componentPos = this.inputs.indexOf(component);\n\n if (componentPos !== -1) {\n this.inputs = this.inputs.slice(0, componentPos).concat(this.inputs.slice(componentPos + 1));\n }\n\n this.validateForm();\n };\n\n // Checks if the values have changed from their initial value\n public isChanged = () => !utils.isSame(this.getPristineValues(), this.getCurrentValues());\n\n // Update model, submit to url prop and send the model\n public submit = (event?: React.SyntheticEvent) => {\n const { onSubmit, onValidSubmit, onInvalidSubmit, preventDefaultSubmit } = this.props;\n const { isValid } = this.state;\n\n if (preventDefaultSubmit && event && event.preventDefault) {\n event.preventDefault();\n }\n\n // Trigger form as not pristine.\n // If any inputs have not been touched yet this will make them dirty\n // so validation becomes visible (if based on isPristine)\n this.setFormPristine(false);\n const model = this.getModel();\n onSubmit(model, this.resetModel, this.updateInputsWithError, event);\n\n if (isValid) {\n onValidSubmit(model, this.resetModel, this.updateInputsWithError, event);\n } else {\n onInvalidSubmit(model, this.resetModel, this.updateInputsWithError, event);\n }\n };\n\n // Go through errors from server and grab the components\n // stored in the inputs map. Change their state to invalid\n // and set the serverError message\n public updateInputsWithError: IUpdateInputsWithError = (errors, invalidate) => {\n const { preventExternalInvalidation } = this.props;\n const { isValid } = this.state;\n\n Object.entries(errors).forEach(([name, error]) => {\n const component = this.inputs.find((input) => input.props.name === name);\n if (!component) {\n throw new Error(\n `You are trying to update an input that does not exist. Verify errors object with input names. ${JSON.stringify(\n errors,\n )}`,\n );\n }\n component.setState({\n isValid: preventExternalInvalidation,\n validationError: utils.isString(error) ? [error] : error,\n });\n });\n\n if (invalidate && isValid) {\n this.setFormValidState(false);\n }\n };\n\n // Set the value of components\n public updateInputsWithValue: IUpdateInputsWithValue = (data, validate) => {\n this.inputs.forEach((component) => {\n const { name } = component.props;\n if (data && has(data, name)) {\n component.setValue(get(data, name), validate);\n }\n });\n };\n\n // Use the binded values and the actual input value to\n // validate the input and set its state. Then check the\n // state of the form itself\n public validate = (component: InputComponent) => {\n const { onChange } = this.props;\n const { canChange } = this.state;\n\n // Trigger onChange\n if (canChange) {\n onChange(this.getModel(), this.isChanged());\n }\n\n const validationState = this.runValidation(component);\n // Run through the validations, split them up and call\n // the validator IF there is a value or it is required\n component.setState(validationState, this.validateForm);\n };\n\n // Validate the form by going through all child input components\n // and check their state\n public validateForm = () => {\n // We need a callback as we are validating all inputs again. This will\n // run when the last component has set its state\n const onValidationComplete = () => {\n const allIsValid = this.inputs.every((component) => component.state.isValid);\n\n this.setFormValidState(allIsValid);\n\n // Tell the form that it can start to trigger change events\n this.setState({\n canChange: true,\n });\n };\n\n // Run validation again in case affected by other inputs. The\n // last component validated will run the onValidationComplete callback\n this.inputs.forEach((component, index) => {\n const validationState = this.runValidation(component);\n const isFinalInput = index === this.inputs.length - 1;\n const callback = isFinalInput ? onValidationComplete : null;\n component.setState(validationState, callback);\n });\n\n // If there are no inputs, set state where form is ready to trigger\n // change event. New inputs might be added later\n if (!this.inputs.length) {\n this.setState(\n {\n canChange: true,\n },\n onValidationComplete,\n );\n }\n };\n\n public render() {\n const {\n /* eslint-disable @typescript-eslint/no-unused-vars */\n children,\n mapping,\n onChange,\n onInvalid,\n onInvalidSubmit,\n onReset,\n onSubmit,\n onValid,\n onValidSubmit,\n preventDefaultSubmit,\n preventExternalInvalidation,\n validationErrors,\n disabled,\n formElement,\n ...nonFormsyProps\n } = this.props;\n const { contextValue } = this.state;\n\n return React.createElement(\n FormsyContext.Provider,\n {\n value: contextValue,\n },\n React.createElement(\n formElement,\n {\n onReset: this.resetInternal,\n onSubmit: this.submit,\n ...nonFormsyProps,\n disabled,\n },\n children,\n ),\n );\n }\n}\n"],"names":["isArray","value","Array","isObject","isPlainObject","isDate","Date","isFunction","isString","isRegex","RegExp","isValueStringEmpty","isValueNullOrUndefined","isValueUndefined","undefined","noop","protectAgainstParamReassignment","isSame","a","b","length","every","item","index","toString","Object","keys","key","runRules","currentValues","validations","validationRules","results","errors","failed","success","forEach","validationName","validationsVal","validationRulesVal","addToResults","validation","push","Error","isExisty","isEmpty","isTypeUndefined","isDefaultRequiredValue","matchRegexp","_values","regexp","test","REGEX_PATTERNS","equals","eql","equalsField","values","field","isAlpha","isAlphanumeric","isEmail","isEmptyString","isFalse","isFloat","isInt","isLength","isNumeric","isNumber","isSpecialWords","isTrue","isUndefined","isUrl","isWords","maxLength","minLength","throwNoFormsyProvider","React","createContext","attachToForm","detachFromForm","isFormDisabled","isValidValue","validate","runValidation","convertValidationsToObject","split","reduce","validationsAccumulator","args","validateMethod","shift","map","arg","JSON","parse","e","validationsAccumulatorCopy","propTypes","innerRef","PropTypes","func","name","string","isRequired","required","oneOfType","bool","object","any","Formsy","props","callback","enableCall","prevInputNames","_this","inputs","component","validateForm","prevProps","validationErrors","disabled","setInputValidationErrors","newInputNames","utils","setState","state","contextValue","valueAccumulator","getCurrentValues","mapModel","isPristine","formSubmitted","preventExternalInvalidation","isValid","validationError","setFormValidState","allIsValid","onValid","onInvalid","model","mapping","returnModel","set","setFormPristine","resetModel","event","onReset","preventDefault","reset","data","has","setValue","get","resetValue","componentValidationErrors","validationResults","requiredResults","requiredValidations","emptyArray","error","filter","x","pos","arr","indexOf","canChange","onChange","getModel","isChanged","throttledValidateForm","componentPos","slice","concat","getPristineValues","onSubmit","onValidSubmit","onInvalidSubmit","preventDefaultSubmit","updateInputsWithError","invalidate","entries","find","input","stringify","validationState","onValidationComplete","isSubmitting","apply","this","setTimeout","render","children","formElement","nonFormsyProps","createElement","FormsyContext","Provider","resetInternal","submit","Component","WrappedComponent","WithFormsyWrapper","messages","getErrorMessages","showRequired","pristineValue","setValidations","componentDidMount","shouldComponentUpdate","nextProps","nextState","some","k","isPropsChanged","isStateChanged","componentDidUpdate","componentWillUnmount","propsForElement","errorMessage","getErrorMessage","errorMessages","hasValue","isFormSubmitted","showError","get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KoC,oBAGV9H,IACFuH,EAAgBQ,IAAM/H,GAGjBtB,EAAMsH,cAAcM,EAAkBiB,OA9LvC7I,EAAM2H,kBAMAE,0BAdMrF,EAciCoF,GAbtC0B,aAAe9G,EAAUf,OAASsB,EAAeP,GAAaA,EAAY,kBAe3EqF,YAAiBxG,EAEjBwG,eAAoB,CAChCvG,SAAU,KACVM,UAAU,EACV8B,gBAAiB,GACjBf,iBAAkB,GAClBzF,YAAa,KACb7B,MAAQuM,EAAmD2B,cAmLxD,SAACrH,UACNlC,EAAMsH,cAAcC,EAAciC,SAAU,MAAM,SAACtG,UAC1ClD,EAAMsH,cAAcO,OAAwB3F,EAAUgB"} \ No newline at end of file diff --git a/dist/formsy-react.esm.js b/dist/formsy-react.esm.js index 2a0944a2..cdc83a5f 100644 --- a/dist/formsy-react.esm.js +++ b/dist/formsy-react.esm.js @@ -1,9 +1,6 @@ -import isPlainObject from 'lodash.isplainobject'; +import { isPlainObject, set, has, get } from 'lodash-es'; import PropTypes from 'prop-types'; import React from 'react'; -import get from 'lodash.get'; -import has from 'lodash.has'; -import set from 'lodash.set'; function _extends() { _extends = Object.assign || function (target) { @@ -912,17 +909,12 @@ var Formsy = /*#__PURE__*/function (_React$Component) { }; // Set the value of components - _this.updateInputsWithValue = function (values, validate) { - Object.entries(values).forEach(function (_ref2) { - var name = _ref2[0], - value = _ref2[1]; - - var input = _this.inputs.find(function (component) { - return component.props.name === name; - }); + _this.updateInputsWithValue = function (data, validate) { + _this.inputs.forEach(function (component) { + var name = component.props.name; - if (input) { - input.setValue(value, validate); + if (data && has(data, name)) { + component.setValue(get(data, name), validate); } }); }; // Use the binded values and the actual input value to diff --git a/dist/formsy-react.esm.js.map b/dist/formsy-react.esm.js.map index 057670f4..a83005a9 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.isplainobject';\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: /^(([^<>()[\\]\\\\.,;:\\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 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 extends React.Component & FormsyContextInterface, WrapperState>\n implements WrapperInstanceMethods {\n public validations?: Validations;\n\n public requiredValidations?: Validations;\n\n public static displayName = `Formsy(${getDisplayName(WrappedComponent)})`;\n\n public static propTypes: any = propTypes;\n\n public static defaultProps: any = {\n innerRef: null,\n required: false,\n validationError: '',\n validationErrors: {},\n validations: null,\n value: (WrappedComponent as ComponentWithStaticAttributes).defaultValue,\n };\n\n public constructor(props) {\n super(props);\n const { runValidation, validations, required, value } = props;\n\n this.state = { value } as any;\n\n this.setValidations(validations, required);\n\n this.state = {\n formSubmitted: false,\n isPristine: true,\n pristineValue: props.value,\n value: props.value,\n ...runValidation(this, props.value),\n };\n }\n\n public componentDidMount() {\n const { name, attachToForm } = this.props;\n\n if (!name) {\n throw new Error('Form Input requires a name property when used');\n }\n\n attachToForm(this);\n }\n\n public shouldComponentUpdate(nextProps, nextState) {\n const { props, state } = this;\n const isChanged = (a: object, b: object): boolean => Object.keys(a).some((k) => a[k] !== b[k]);\n const isPropsChanged = isChanged(props, nextProps);\n const isStateChanged = isChanged(state, nextState);\n\n return isPropsChanged || isStateChanged;\n }\n\n public componentDidUpdate(prevProps) {\n const { value, validations, required, validate } = this.props;\n\n // If the value passed has changed, set it. If value is not passed it will\n // internally update, and this will never run\n if (!utils.isSame(value, prevProps.value)) {\n this.setValue(value);\n }\n\n // If validations or required is changed, run a new validation\n if (!utils.isSame(validations, prevProps.validations) || !utils.isSame(required, prevProps.required)) {\n this.setValidations(validations, required);\n validate(this);\n }\n }\n\n // Detach it when component unmounts\n public componentWillUnmount() {\n const { detachFromForm } = this.props;\n detachFromForm(this);\n }\n\n public getErrorMessage = (): ValidationError | null => {\n const messages = this.getErrorMessages();\n return messages.length ? messages[0] : null;\n };\n\n public getErrorMessages = (): ValidationError[] => {\n const { validationError } = this.state;\n\n if (!this.isValid() || this.showRequired()) {\n return validationError || [];\n }\n return [];\n };\n\n // eslint-disable-next-line react/destructuring-assignment\n public getValue = (): V => this.state.value;\n\n public setValidations = (validations: Validations, required: RequiredValidation): void => {\n // Add validations to the store itself as the props object can not be modified\n this.validations = convertValidationsToObject(validations) || {};\n this.requiredValidations =\n required === true ? { isDefaultRequiredValue: required } : convertValidationsToObject(required);\n };\n\n // By default, we validate after the value has been set.\n // A user can override this and pass a second parameter of `false` to skip validation.\n public setValue = (value: V, validate = true): void => {\n const { validate: validateForm } = this.props;\n\n if (!validate) {\n this.setState({ value });\n } else {\n this.setState(\n {\n value,\n isPristine: false,\n },\n () => {\n validateForm(this);\n },\n );\n }\n };\n\n // eslint-disable-next-line react/destructuring-assignment\n public hasValue = () => {\n const { value } = this.state;\n return isDefaultRequiredValue(value);\n };\n\n // eslint-disable-next-line react/destructuring-assignment\n public isFormDisabled = (): boolean => this.props.isFormDisabled;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isFormSubmitted = (): boolean => this.state.formSubmitted;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isPristine = (): boolean => this.state.isPristine;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isRequired = (): boolean => !!this.props.required;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isValid = (): boolean => this.state.isValid;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isValidValue = (value: V) => this.props.isValidValue(this, value);\n\n public resetValue = () => {\n const { pristineValue } = this.state;\n const { validate } = this.props;\n\n this.setState(\n {\n value: pristineValue,\n isPristine: true,\n },\n () => {\n validate(this);\n },\n );\n };\n\n public showError = (): boolean => !this.showRequired() && !this.isValid();\n\n // eslint-disable-next-line react/destructuring-assignment\n public showRequired = (): boolean => this.state.isRequired;\n\n public render() {\n const { innerRef } = this.props;\n const propsForElement: T & PassDownProps = {\n ...this.props,\n errorMessage: this.getErrorMessage(),\n errorMessages: this.getErrorMessages(),\n hasValue: this.hasValue(),\n isFormDisabled: this.isFormDisabled(),\n isFormSubmitted: this.isFormSubmitted(),\n isPristine: this.isPristine(),\n isRequired: this.isRequired(),\n isValid: this.isValid(),\n isValidValue: this.isValidValue,\n resetValue: this.resetValue,\n setValidations: this.setValidations,\n setValue: this.setValue,\n showError: this.showError(),\n showRequired: this.showRequired(),\n value: this.getValue(),\n };\n\n if (innerRef) {\n propsForElement.ref = innerRef;\n }\n\n return React.createElement(WrappedComponent, propsForElement);\n }\n }\n\n // eslint-disable-next-line react/display-name\n return (props) =>\n React.createElement(FormsyContext.Consumer, null, (contextValue) => {\n return React.createElement(WithFormsyWrapper, { ...props, ...contextValue });\n });\n}\n","/* eslint-disable react/no-unused-state, react/default-props-match-prop-types */\nimport get from 'lodash.get';\nimport has from 'lodash.has';\nimport set from 'lodash.set';\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 = (values, validate) => {\n Object.entries(values).forEach(([name, value]) => {\n const input = this.inputs.find((component) => component.props.name === name);\n\n if (input) {\n input.setValue(value, validate);\n }\n });\n };\n\n // Use the binded values and the actual input value to\n // validate the input and set its state. Then check the\n // state of the form itself\n public validate = (component: InputComponent) => {\n const { onChange } = this.props;\n const { canChange } = this.state;\n\n // Trigger onChange\n if (canChange) {\n onChange(this.getModel(), this.isChanged());\n }\n\n const validationState = this.runValidation(component);\n // Run through the validations, split them up and call\n // the validator IF there is a value or it is required\n component.setState(validationState, this.validateForm);\n };\n\n // Validate the form by going through all child input components\n // and check their state\n public validateForm = () => {\n // We need a callback as we are validating all inputs again. This will\n // run when the last component has set its state\n const onValidationComplete = () => {\n const allIsValid = this.inputs.every((component) => component.state.isValid);\n\n this.setFormValidState(allIsValid);\n\n // Tell the form that it can start to trigger change events\n this.setState({\n canChange: true,\n });\n };\n\n // Run validation again in case affected by other inputs. The\n // last component validated will run the onValidationComplete callback\n this.inputs.forEach((component, index) => {\n const validationState = this.runValidation(component);\n const isFinalInput = index === this.inputs.length - 1;\n const callback = isFinalInput ? onValidationComplete : null;\n component.setState(validationState, callback);\n });\n\n // If there are no inputs, set state where form is ready to trigger\n // change event. New inputs might be added later\n if (!this.inputs.length) {\n this.setState(\n {\n canChange: true,\n },\n onValidationComplete,\n );\n }\n };\n\n public render() {\n const {\n /* eslint-disable @typescript-eslint/no-unused-vars */\n children,\n mapping,\n onChange,\n onInvalid,\n onInvalidSubmit,\n onReset,\n onSubmit,\n onValid,\n onValidSubmit,\n preventDefaultSubmit,\n preventExternalInvalidation,\n validationErrors,\n disabled,\n formElement,\n ...nonFormsyProps\n } = this.props;\n const { contextValue } = this.state;\n\n return React.createElement(\n FormsyContext.Provider,\n {\n value: contextValue,\n },\n React.createElement(\n formElement,\n {\n onReset: this.resetInternal,\n onSubmit: this.submit,\n ...nonFormsyProps,\n disabled,\n },\n children,\n ),\n );\n }\n}\n"],"names":["isArray","value","Array","isObject","isPlainObject","isTypeUndefined","isDate","Date","isFunction","isString","isNumber","isRegex","RegExp","isValueStringEmpty","isValueNullOrUndefined","undefined","isValueUndefined","noop","protectAgainstParamReassignment","isSame","a","b","length","every","item","index","toString","Object","keys","key","runRules","currentValues","validations","validationRules","results","errors","failed","success","forEach","validationName","validationsVal","validationRulesVal","addToResults","validation","push","Error","throttle","callback","interval","enableCall","args","apply","setTimeout","isExisty","isEmpty","isDefaultRequiredValue","matchRegexp","_values","regexp","test","REGEX_PATTERNS","ALPHA","ALPHANUMERIC","EMAIL","FLOAT","INT","NUMERIC","SPECIAL_WORDS","URL","WORDS","equals","eql","equalsField","values","field","isAlpha","isAlphanumeric","isEmail","isEmptyString","isFalse","isFloat","isInt","isLength","isNumeric","isSpecialWords","isTrue","isUndefined","isUrl","isWords","maxLength","minLength","addValidationRule","name","func","noFormsyErrorMessage","throwNoFormsyProvider","defaultValue","attachToForm","detachFromForm","isFormDisabled","isValidValue","validate","runValidation","React","createContext","convertValidationsToObject","split","reduce","validationsAccumulator","validateMethod","shift","map","arg","JSON","parse","e","validationsAccumulatorCopy","propTypes","innerRef","PropTypes","string","isRequired","required","oneOfType","bool","object","any","getDisplayName","component","displayName","utils","withFormsy","WrappedComponent","WithFormsyWrapper","props","messages","getErrorMessages","validationError","state","isValid","showRequired","requiredValidations","validateForm","setState","isPristine","formSubmitted","pristineValue","setValidations","componentDidMount","shouldComponentUpdate","nextProps","nextState","isChanged","some","k","isPropsChanged","isStateChanged","componentDidUpdate","prevProps","setValue","componentWillUnmount","render","propsForElement","errorMessage","getErrorMessage","errorMessages","hasValue","isFormSubmitted","resetValue","showError","getValue","ref","createElement","Component","validationErrors","FormsyContext","Consumer","contextValue","ONE_RENDER_FRAME","Formsy","prevInputNames","inputs","disabled","setInputValidationErrors","newInputNames","valueAccumulator","getCurrentValues","mapModel","preventExternalInvalidation","setFormValidState","allIsValid","onValid","onInvalid","model","mapping","returnModel","set","setFormPristine","resetModel","event","onReset","preventDefault","reset","data","has","get","componentValidationErrors","validationResults","requiredResults","emptyArray","error","filter","x","pos","arr","indexOf","onChange","canChange","getModel","throttledValidateForm","componentPos","slice","concat","getPristineValues","onSubmit","onValidSubmit","onInvalidSubmit","preventDefaultSubmit","updateInputsWithError","invalidate","entries","find","input","stringify","validationState","onValidationComplete","isFinalInput","isSubmitting","children","formElement","nonFormsyProps","Provider","resetInternal","submit"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAIgBA,QAAQC;AACtB,SAAOC,KAAK,CAACF,OAAN,CAAcC,KAAd,CAAP;AACD;SAEeE,SAASF;AACvB,SAAOG,aAAa,CAACH,KAAD,CAApB;AACD;SAEeI,gBAAgBJ;AAC9B,SAAO,OAAOA,KAAP,KAAiB,WAAxB;AACD;SAEeK,OAAOL;AACrB,SAAOA,KAAK,YAAYM,IAAxB;AACD;SAEeC,WAAWP;AACzB,SAAOA,KAAK,KAAK,IAAV,IAAkB,OAAOA,KAAP,KAAiB,UAA1C;AACD;SAEeQ,SAASR;AACvB,SAAO,OAAOA,KAAP,KAAiB,QAAxB;AACD;SAEeS,SAAST;AACvB,SAAO,OAAOA,KAAP,KAAiB,QAAxB;AACD;SAEeU,QAAQV;AACtB,SAAOA,KAAK,YAAYW,MAAxB;AACD;SAEeC,mBAAmBZ;AACjC,SAAOA,KAAK,KAAK,EAAjB;AACD;SAEea,uBAAuBb;AACrC,SAAOA,KAAK,KAAK,IAAV,IAAkBA,KAAK,KAAKc,SAAnC;AACD;SAEeC,iBAAiBf;AAC/B,SAAOA,KAAK,KAAKc,SAAjB;AACD;SAEeE;AAEf;SAEeC,gCAAgCjB;AAC9C;AACA,MAAIE,QAAQ,CAACF,KAAD,CAAZ,EAAqB,oBAAYA,KAAZ;AACrB,MAAID,OAAO,CAACC,KAAD,CAAX,EAAoB,iBAAWA,KAAX;AACpB,SAAOA,KAAP;AACD;SAEekB,OAAOC,GAAYC;AACjC,MAAI,OAAOD,CAAP,KAAa,OAAOC,CAAxB,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AAQ,EAAEtF,IAHuC;AAIjD8D,EAAAA,SAAS,EAAE9D,IAJsC;AAKjDgG,EAAAA,eAAe,EAAEhG,IALgC;AAMjDsE,EAAAA,OAAO,EAAEtE,IANwC;AAOjD8F,EAAAA,QAAQ,EAAE9F,IAPuC;AAQjD6D,EAAAA,OAAO,EAAE7D,IARwC;AASjD+F,EAAAA,aAAa,EAAE/F,IATkC;AAUjDiG,EAAAA,oBAAoB,EAAE,IAV2B;AAWjDvC,EAAAA,2BAA2B,EAAE,KAXoB;AAYjDd,EAAAA,gBAAgB,EAAE,EAZ+B;AAajDiE,EAAAA,WAAW,EAAE;AAboC,CAArC;;;;;"} \ No newline at end of file +{"version":3,"file":"formsy-react.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: /^(([^<>()[\\]\\\\.,;:\\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 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 public validations?: Validations;\n\n public requiredValidations?: Validations;\n\n public static displayName = `Formsy(${getDisplayName(WrappedComponent)})`;\n\n public static propTypes: any = propTypes;\n\n public static defaultProps: any = {\n innerRef: null,\n required: false,\n validationError: '',\n validationErrors: {},\n validations: null,\n value: (WrappedComponent as ComponentWithStaticAttributes).defaultValue,\n };\n\n public constructor(props) {\n super(props);\n const { runValidation, validations, required, value } = props;\n\n this.state = { value } as any;\n\n this.setValidations(validations, required);\n\n this.state = {\n formSubmitted: false,\n isPristine: true,\n pristineValue: props.value,\n value: props.value,\n ...runValidation(this, props.value),\n };\n }\n\n public componentDidMount() {\n const { name, attachToForm } = this.props;\n\n if (!name) {\n throw new Error('Form Input requires a name property when used');\n }\n\n attachToForm(this);\n }\n\n public shouldComponentUpdate(nextProps, nextState) {\n const { props, state } = this;\n const isChanged = (a: object, b: object): boolean => Object.keys(a).some((k) => a[k] !== b[k]);\n const isPropsChanged = isChanged(props, nextProps);\n const isStateChanged = isChanged(state, nextState);\n\n return isPropsChanged || isStateChanged;\n }\n\n public componentDidUpdate(prevProps) {\n const { value, validations, required, validate } = this.props;\n\n // If the value passed has changed, set it. If value is not passed it will\n // internally update, and this will never run\n if (!utils.isSame(value, prevProps.value)) {\n this.setValue(value);\n }\n\n // If validations or required is changed, run a new validation\n if (!utils.isSame(validations, prevProps.validations) || !utils.isSame(required, prevProps.required)) {\n this.setValidations(validations, required);\n validate(this);\n }\n }\n\n // Detach it when component unmounts\n public componentWillUnmount() {\n const { detachFromForm } = this.props;\n detachFromForm(this);\n }\n\n public getErrorMessage = (): ValidationError | null => {\n const messages = this.getErrorMessages();\n return messages.length ? messages[0] : null;\n };\n\n public getErrorMessages = (): ValidationError[] => {\n const { validationError } = this.state;\n\n if (!this.isValid() || this.showRequired()) {\n return validationError || [];\n }\n return [];\n };\n\n // eslint-disable-next-line react/destructuring-assignment\n public getValue = (): V => this.state.value;\n\n public setValidations = (validations: Validations, required: RequiredValidation): void => {\n // Add validations to the store itself as the props object can not be modified\n this.validations = convertValidationsToObject(validations) || {};\n this.requiredValidations =\n required === true ? { isDefaultRequiredValue: required } : convertValidationsToObject(required);\n };\n\n // By default, we validate after the value has been set.\n // A user can override this and pass a second parameter of `false` to skip validation.\n public setValue = (value: V, validate = true): void => {\n const { validate: validateForm } = this.props;\n\n if (!validate) {\n this.setState({ value });\n } else {\n this.setState(\n {\n value,\n isPristine: false,\n },\n () => {\n validateForm(this);\n },\n );\n }\n };\n\n // eslint-disable-next-line react/destructuring-assignment\n public hasValue = () => {\n const { value } = this.state;\n return isDefaultRequiredValue(value);\n };\n\n // eslint-disable-next-line react/destructuring-assignment\n public isFormDisabled = (): boolean => this.props.isFormDisabled;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isFormSubmitted = (): boolean => this.state.formSubmitted;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isPristine = (): boolean => this.state.isPristine;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isRequired = (): boolean => !!this.props.required;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isValid = (): boolean => this.state.isValid;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isValidValue = (value: V) => this.props.isValidValue(this, value);\n\n public resetValue = () => {\n const { pristineValue } = this.state;\n const { validate } = this.props;\n\n this.setState(\n {\n value: pristineValue,\n isPristine: true,\n },\n () => {\n validate(this);\n },\n );\n };\n\n public showError = (): boolean => !this.showRequired() && !this.isValid();\n\n // eslint-disable-next-line react/destructuring-assignment\n public showRequired = (): boolean => this.state.isRequired;\n\n public render() {\n const { innerRef } = this.props;\n const propsForElement: T & PassDownProps = {\n ...this.props,\n errorMessage: this.getErrorMessage(),\n errorMessages: this.getErrorMessages(),\n hasValue: this.hasValue(),\n isFormDisabled: this.isFormDisabled(),\n isFormSubmitted: this.isFormSubmitted(),\n isPristine: this.isPristine(),\n isRequired: this.isRequired(),\n isValid: this.isValid(),\n isValidValue: this.isValidValue,\n resetValue: this.resetValue,\n setValidations: this.setValidations,\n setValue: this.setValue,\n showError: this.showError(),\n showRequired: this.showRequired(),\n value: this.getValue(),\n };\n\n if (innerRef) {\n propsForElement.ref = innerRef;\n }\n\n return React.createElement(WrappedComponent, propsForElement);\n }\n }\n\n // eslint-disable-next-line react/display-name\n return (props) =>\n React.createElement(FormsyContext.Consumer, null, (contextValue) => {\n return React.createElement(WithFormsyWrapper, { ...props, ...contextValue });\n });\n}\n","/* eslint-disable react/no-unused-state, react/default-props-match-prop-types */\nimport { get, has, set } from 'lodash';\nimport PropTypes from 'prop-types';\nimport React from 'react';\nimport FormsyContext from './FormsyContext';\nimport {\n FormsyContextInterface,\n IModel,\n InputComponent,\n IResetModel,\n IUpdateInputsWithError,\n IUpdateInputsWithValue,\n ValidationError,\n} from './interfaces';\nimport { throttle, isObject, isString } from './utils';\nimport * as utils from './utils';\nimport validationRules from './validationRules';\nimport { PassDownProps } from './withFormsy';\n\ntype FormHTMLAttributesCleaned = Omit, 'onChange' | 'onSubmit'>;\n\ntype OnSubmitCallback = (\n model: IModel,\n resetModel: IResetModel,\n updateInputsWithError: IUpdateInputsWithError,\n event: React.SyntheticEvent>,\n) => void;\n\ntype FormElementType =\n | string\n | React.ComponentType<{\n onReset?: (e: React.SyntheticEvent) => void;\n onSubmit?: (e: React.SyntheticEvent) => void;\n disabled?: boolean;\n children?: React.ReactChildren;\n }>;\n\nexport interface FormsyProps extends FormHTMLAttributesCleaned {\n disabled: boolean;\n mapping: null | ((model: IModel) => IModel);\n onChange: (model: IModel, isChanged: boolean) => void;\n onInvalid: () => void;\n onReset?: () => void;\n onSubmit?: OnSubmitCallback;\n onValidSubmit?: OnSubmitCallback;\n onInvalidSubmit: OnSubmitCallback;\n onValid: () => void;\n preventDefaultSubmit?: boolean;\n preventExternalInvalidation?: boolean;\n validationErrors?: null | object;\n formElement?: FormElementType;\n}\n\nexport interface FormsyState {\n canChange: boolean;\n contextValue: FormsyContextInterface;\n formSubmitted?: boolean;\n isPristine?: boolean;\n isSubmitting: boolean;\n isValid: boolean;\n}\n\nconst ONE_RENDER_FRAME = 66;\n\nexport class Formsy extends React.Component {\n public inputs: InstanceType>[];\n\n public emptyArray: any[];\n\n public prevInputNames: any[] | null = null;\n\n public static displayName = 'Formsy';\n\n public static propTypes = {\n disabled: PropTypes.bool,\n mapping: PropTypes.func,\n formElement: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.func]),\n onChange: PropTypes.func,\n onInvalid: PropTypes.func,\n onInvalidSubmit: PropTypes.func,\n onReset: PropTypes.func,\n onSubmit: PropTypes.func,\n onValid: PropTypes.func,\n onValidSubmit: PropTypes.func,\n preventDefaultSubmit: PropTypes.bool,\n preventExternalInvalidation: PropTypes.bool,\n validationErrors: PropTypes.object, // eslint-disable-line\n };\n\n public static defaultProps: Partial = {\n disabled: false,\n mapping: null,\n onChange: utils.noop,\n onInvalid: utils.noop,\n onInvalidSubmit: utils.noop,\n onReset: utils.noop,\n onSubmit: utils.noop,\n onValid: utils.noop,\n onValidSubmit: utils.noop,\n preventDefaultSubmit: true,\n preventExternalInvalidation: false,\n validationErrors: {},\n formElement: 'form',\n };\n\n private readonly throttledValidateForm: () => void;\n\n public constructor(props: FormsyProps) {\n super(props);\n this.state = {\n canChange: false,\n isSubmitting: false,\n isValid: true,\n contextValue: {\n attachToForm: this.attachToForm,\n detachFromForm: this.detachFromForm,\n isFormDisabled: props.disabled,\n isValidValue: this.isValidValue,\n validate: this.validate,\n runValidation: this.runValidation,\n },\n };\n this.inputs = [];\n this.emptyArray = [];\n this.throttledValidateForm = throttle(this.validateForm, ONE_RENDER_FRAME);\n }\n\n public componentDidMount = () => {\n this.prevInputNames = this.inputs.map((component) => component.props.name);\n this.validateForm();\n };\n\n public componentDidUpdate = (prevProps: FormsyProps) => {\n const { validationErrors, disabled } = this.props;\n\n if (validationErrors && isObject(validationErrors) && Object.keys(validationErrors).length > 0) {\n this.setInputValidationErrors(validationErrors);\n }\n\n const newInputNames = this.inputs.map((component) => component.props.name);\n if (this.prevInputNames && !utils.isSame(this.prevInputNames, newInputNames)) {\n this.prevInputNames = newInputNames;\n this.validateForm();\n }\n\n // Keep the disabled value in state/context the same as from props\n if (disabled !== prevProps.disabled) {\n // eslint-disable-next-line\n this.setState((state) => ({\n ...state,\n contextValue: {\n ...state.contextValue,\n isFormDisabled: disabled,\n },\n }));\n }\n };\n\n public getCurrentValues = () =>\n this.inputs.reduce((valueAccumulator, component) => {\n const {\n props: { name },\n state: { value },\n } = component;\n // eslint-disable-next-line no-param-reassign\n valueAccumulator[name] = utils.protectAgainstParamReassignment(value);\n return valueAccumulator;\n }, {});\n\n public getModel = () => {\n const currentValues = this.getCurrentValues();\n return this.mapModel(currentValues);\n };\n\n public getPristineValues = () =>\n this.inputs.reduce((valueAccumulator, component) => {\n const {\n props: { name, value },\n } = component;\n // eslint-disable-next-line no-param-reassign\n valueAccumulator[name] = utils.protectAgainstParamReassignment(value);\n return valueAccumulator;\n }, {});\n\n public setFormPristine = (isPristine: boolean) => {\n this.setState({\n formSubmitted: !isPristine,\n });\n\n // Iterate through each component and set it as pristine\n // or \"dirty\".\n this.inputs.forEach((component) => {\n component.setState({\n formSubmitted: !isPristine,\n isPristine,\n });\n });\n };\n\n public setInputValidationErrors = (errors) => {\n const { preventExternalInvalidation } = this.props;\n const { isValid } = this.state;\n\n this.inputs.forEach((component) => {\n const { name } = component.props;\n component.setState({\n isValid: !(name in errors),\n validationError: isString(errors[name]) ? [errors[name]] : errors[name],\n });\n });\n if (!preventExternalInvalidation && isValid) {\n this.setFormValidState(false);\n }\n };\n\n public setFormValidState = (allIsValid: boolean) => {\n const { onValid, onInvalid } = this.props;\n\n this.setState({\n isValid: allIsValid,\n });\n\n if (allIsValid) {\n onValid();\n } else {\n onInvalid();\n }\n };\n\n public isValidValue = (component, value) => this.runValidation(component, value).isValid;\n\n // eslint-disable-next-line react/destructuring-assignment\n public isFormDisabled = () => this.props.disabled;\n\n public mapModel = (model: IModel): IModel => {\n const { mapping } = this.props;\n\n if (mapping) {\n return mapping(model);\n }\n\n const returnModel = {};\n Object.keys(model).forEach((key) => {\n set(returnModel, key, model[key]);\n });\n return returnModel;\n };\n\n public reset = (model?: IModel) => {\n this.setFormPristine(true);\n this.resetModel(model);\n };\n\n private resetInternal = (event) => {\n const { onReset } = this.props;\n\n event.preventDefault();\n this.reset();\n if (onReset) {\n onReset();\n }\n };\n\n // Reset each key in the model to the original / initial / specified value\n private resetModel: IResetModel = (data) => {\n this.inputs.forEach((component) => {\n const { name } = component.props;\n if (data && has(data, name)) {\n component.setValue(get(data, name));\n } else {\n component.resetValue();\n }\n });\n this.validateForm();\n };\n\n // Checks validation on current value or a passed value\n public runValidation = (\n component: InputComponent,\n value = component.state.value,\n ): { isRequired: boolean; isValid: boolean; validationError: ValidationError[] } => {\n const { validationErrors } = this.props;\n const { validationError, validationErrors: componentValidationErrors, name } = component.props;\n const currentValues = this.getCurrentValues();\n const validationResults = utils.runRules(value, currentValues, component.validations, validationRules);\n const requiredResults = utils.runRules(value, currentValues, component.requiredValidations, validationRules);\n const isRequired = Object.keys(component.requiredValidations).length ? !!requiredResults.success.length : false;\n const isValid = !validationResults.failed.length && !(validationErrors && validationErrors[component.props.name]);\n\n return {\n isRequired,\n isValid: isRequired ? false : isValid,\n validationError: (() => {\n if (isValid && !isRequired) {\n return this.emptyArray;\n }\n\n if (validationResults.errors.length) {\n return validationResults.errors;\n }\n\n if (validationErrors && validationErrors[name]) {\n return isString(validationErrors[name]) ? [validationErrors[name]] : validationErrors[name];\n }\n\n if (isRequired) {\n const error = componentValidationErrors[requiredResults.success[0]] || validationError;\n return error ? [error] : null;\n }\n\n if (validationResults.failed.length) {\n return validationResults.failed\n .map((failed) => (componentValidationErrors[failed] ? componentValidationErrors[failed] : validationError))\n .filter((x, pos, arr) => arr.indexOf(x) === pos); // remove duplicates\n }\n\n // This line is not reachable\n // istanbul ignore next\n return undefined;\n })(),\n };\n };\n\n // Method put on each input component to register\n // itself to the form\n public attachToForm = (component) => {\n if (this.inputs.indexOf(component) === -1) {\n this.inputs.push(component);\n }\n\n const { onChange } = this.props;\n const { canChange } = this.state;\n\n // Trigger onChange\n if (canChange) {\n onChange(this.getModel(), this.isChanged());\n }\n\n // Will be triggered immediately & every one frame rate\n this.throttledValidateForm();\n };\n\n // Method put on each input component to unregister\n // itself from the form\n public detachFromForm = (component: InputComponent) => {\n const componentPos = this.inputs.indexOf(component);\n\n if (componentPos !== -1) {\n this.inputs = this.inputs.slice(0, componentPos).concat(this.inputs.slice(componentPos + 1));\n }\n\n this.validateForm();\n };\n\n // Checks if the values have changed from their initial value\n public isChanged = () => !utils.isSame(this.getPristineValues(), this.getCurrentValues());\n\n // Update model, submit to url prop and send the model\n public submit = (event?: React.SyntheticEvent) => {\n const { onSubmit, onValidSubmit, onInvalidSubmit, preventDefaultSubmit } = this.props;\n const { isValid } = this.state;\n\n if (preventDefaultSubmit && event && event.preventDefault) {\n event.preventDefault();\n }\n\n // Trigger form as not pristine.\n // If any inputs have not been touched yet this will make them dirty\n // so validation becomes visible (if based on isPristine)\n this.setFormPristine(false);\n const model = this.getModel();\n onSubmit(model, this.resetModel, this.updateInputsWithError, event);\n\n if (isValid) {\n onValidSubmit(model, this.resetModel, this.updateInputsWithError, event);\n } else {\n onInvalidSubmit(model, this.resetModel, this.updateInputsWithError, event);\n }\n };\n\n // Go through errors from server and grab the components\n // stored in the inputs map. Change their state to invalid\n // and set the serverError message\n public updateInputsWithError: IUpdateInputsWithError = (errors, invalidate) => {\n const { preventExternalInvalidation } = this.props;\n const { isValid } = this.state;\n\n Object.entries(errors).forEach(([name, error]) => {\n const component = this.inputs.find((input) => input.props.name === name);\n if (!component) {\n throw new Error(\n `You are trying to update an input that does not exist. Verify errors object with input names. ${JSON.stringify(\n errors,\n )}`,\n );\n }\n component.setState({\n isValid: preventExternalInvalidation,\n validationError: utils.isString(error) ? [error] : error,\n });\n });\n\n if (invalidate && isValid) {\n this.setFormValidState(false);\n }\n };\n\n // Set the value of components\n public updateInputsWithValue: IUpdateInputsWithValue = (data, validate) => {\n this.inputs.forEach((component) => {\n const { name } = component.props;\n if (data && has(data, name)) {\n component.setValue(get(data, name), validate);\n }\n });\n };\n\n // Use the binded values and the actual input value to\n // validate the input and set its state. Then check the\n // state of the form itself\n public validate = (component: InputComponent) => {\n const { onChange } = this.props;\n const { canChange } = this.state;\n\n // Trigger onChange\n if (canChange) {\n onChange(this.getModel(), this.isChanged());\n }\n\n const validationState = this.runValidation(component);\n // Run through the validations, split them up and call\n // the validator IF there is a value or it is required\n component.setState(validationState, this.validateForm);\n };\n\n // Validate the form by going through all child input components\n // and check their state\n public validateForm = () => {\n // We need a callback as we are validating all inputs again. This will\n // run when the last component has set its state\n const onValidationComplete = () => {\n const allIsValid = this.inputs.every((component) => component.state.isValid);\n\n this.setFormValidState(allIsValid);\n\n // Tell the form that it can start to trigger change events\n this.setState({\n canChange: true,\n });\n };\n\n // Run validation again in case affected by other inputs. The\n // last component validated will run the onValidationComplete callback\n this.inputs.forEach((component, index) => {\n const validationState = this.runValidation(component);\n const isFinalInput = index === this.inputs.length - 1;\n const callback = isFinalInput ? onValidationComplete : null;\n component.setState(validationState, callback);\n });\n\n // If there are no inputs, set state where form is ready to trigger\n // change event. New inputs might be added later\n if (!this.inputs.length) {\n this.setState(\n {\n canChange: true,\n },\n onValidationComplete,\n );\n }\n };\n\n public render() {\n const {\n /* eslint-disable @typescript-eslint/no-unused-vars */\n children,\n mapping,\n onChange,\n onInvalid,\n onInvalidSubmit,\n onReset,\n onSubmit,\n onValid,\n onValidSubmit,\n preventDefaultSubmit,\n preventExternalInvalidation,\n validationErrors,\n disabled,\n formElement,\n ...nonFormsyProps\n } = this.props;\n const { contextValue } = this.state;\n\n return React.createElement(\n FormsyContext.Provider,\n {\n value: contextValue,\n },\n React.createElement(\n formElement,\n {\n onReset: this.resetInternal,\n onSubmit: this.submit,\n ...nonFormsyProps,\n disabled,\n },\n children,\n ),\n );\n }\n}\n"],"names":["isArray","value","Array","isObject","isPlainObject","isTypeUndefined","isDate","Date","isFunction","isString","isNumber","isRegex","RegExp","isValueStringEmpty","isValueNullOrUndefined","undefined","isValueUndefined","noop","protectAgainstParamReassignment","isSame","a","b","length","every","item","index","toString","Object","keys","key","runRules","currentValues","validations","validationRules","results","errors","failed","success","forEach","validationName","validationsVal","validationRulesVal","addToResults","validation","push","Error","throttle","callback","interval","enableCall","args","apply","setTimeout","isExisty","isEmpty","isDefaultRequiredValue","matchRegexp","_values","regexp","test","REGEX_PATTERNS","ALPHA","ALPHANUMERIC","EMAIL","FLOAT","INT","NUMERIC","SPECIAL_WORDS","URL","WORDS","equals","eql","equalsField","values","field","isAlpha","isAlphanumeric","isEmail","isEmptyString","isFalse","isFloat","isInt","isLength","isNumeric","isSpecialWords","isTrue","isUndefined","isUrl","isWords","maxLength","minLength","addValidationRule","name","func","noFormsyErrorMessage","throwNoFormsyProvider","defaultValue","attachToForm","detachFromForm","isFormDisabled","isValidValue","validate","runValidation","React","createContext","convertValidationsToObject","split","reduce","validationsAccumulator","validateMethod","shift","map","arg","JSON","parse","e","validationsAccumulatorCopy","propTypes","innerRef","PropTypes","string","isRequired","required","oneOfType","bool","object","any","getDisplayName","component","displayName","utils","withFormsy","WrappedComponent","WithFormsyWrapper","props","messages","getErrorMessages","validationError","state","isValid","showRequired","requiredValidations","validateForm","setState","isPristine","formSubmitted","pristineValue","setValidations","componentDidMount","shouldComponentUpdate","nextProps","nextState","isChanged","some","k","isPropsChanged","isStateChanged","componentDidUpdate","prevProps","setValue","componentWillUnmount","render","propsForElement","errorMessage","getErrorMessage","errorMessages","hasValue","isFormSubmitted","resetValue","showError","getValue","ref","createElement","Component","validationErrors","FormsyContext","Consumer","contextValue","ONE_RENDER_FRAME","Formsy","prevInputNames","inputs","disabled","setInputValidationErrors","newInputNames","valueAccumulator","getCurrentValues","mapModel","preventExternalInvalidation","setFormValidState","allIsValid","onValid","onInvalid","model","mapping","returnModel","set","setFormPristine","resetModel","event","onReset","preventDefault","reset","data","has","get","componentValidationErrors","validationResults","requiredResults","emptyArray","error","filter","x","pos","arr","indexOf","onChange","canChange","getModel","throttledValidateForm","componentPos","slice","concat","getPristineValues","onSubmit","onValidSubmit","onInvalidSubmit","preventDefaultSubmit","updateInputsWithError","invalidate","entries","find","input","stringify","validationState","onValidationComplete","isFinalInput","isSubmitting","children","formElement","nonFormsyProps","Provider","resetInternal","submit"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAIgBA,QAAQC;AACtB,SAAOC,KAAK,CAACF,OAAN,CAAcC,KAAd,CAAP;AACD;SAEeE,SAASF;AACvB,SAAOG,aAAa,CAACH,KAAD,CAApB;AACD;SAEeI,gBAAgBJ;AAC9B,SAAO,OAAOA,KAAP,KAAiB,WAAxB;AACD;SAEeK,OAAOL;AACrB,SAAOA,KAAK,YAAYM,IAAxB;AACD;SAEeC,WAAWP;AACzB,SAAOA,KAAK,KAAK,IAAV,IAAkB,OAAOA,KAAP,KAAiB,UAA1C;AACD;SAEeQ,SAASR;AACvB,SAAO,OAAOA,KAAP,KAAiB,QAAxB;AACD;SAEeS,SAAST;AACvB,SAAO,OAAOA,KAAP,KAAiB,QAAxB;AACD;SAEeU,QAAQV;AACtB,SAAOA,KAAK,YAAYW,M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ASxBkG,EAAAA,OAAO,EAAExE,SAAS,CAAC1B,IATK;AAUxBoI,EAAAA,aAAa,EAAE1G,SAAS,CAAC1B,IAVD;AAWxBsI,EAAAA,oBAAoB,EAAE5G,SAAS,CAACK,IAXR;AAYxBgE,EAAAA,2BAA2B,EAAErE,SAAS,CAACK,IAZf;AAaxBkD,EAAAA,gBAAgB,EAAEvD,SAAS,CAACM;AAbJ,CAAZ;AAgBAsD,mBAAA,GAAqC;AACjDG,EAAAA,QAAQ,EAAE,KADuC;AAEjDY,EAAAA,OAAO,EAAE,IAFwC;AAGjDsB,EAAAA,QAAQ,EAAEtF,IAHuC;AAIjD8D,EAAAA,SAAS,EAAE9D,IAJsC;AAKjDgG,EAAAA,eAAe,EAAEhG,IALgC;AAMjDsE,EAAAA,OAAO,EAAEtE,IANwC;AAOjD8F,EAAAA,QAAQ,EAAE9F,IAPuC;AAQjD6D,EAAAA,OAAO,EAAE7D,IARwC;AASjD+F,EAAAA,aAAa,EAAE/F,IATkC;AAUjDiG,EAAAA,oBAAoB,EAAE,IAV2B;AAWjDvC,EAAAA,2BAA2B,EAAE,KAXoB;AAYjDd,EAAAA,gBAAgB,EAAE,EAZ+B;AAajDiE,EAAAA,WAAW,EAAE;AAboC,CAArC;;;;;"} \ No newline at end of file diff --git a/package.json b/package.json index 93103117..69704da3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "formsy-react", - "version": "2.2.3", + "version": "2.2.4", "description": "A form input builder and validator for React", "keywords": [ "form",