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

formik

Package Overview
Dependencies
Maintainers
1
Versions
212
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

formik - npm Package Compare versions

Comparing version 1.3.2 to 2.0.0-canary.5a8e912

dist/FormikContext.d.ts

7

dist/connect.d.ts
import * as React from 'react';
import { FormikContext } from './types';
export declare const FormikProvider: React.ComponentClass<import("create-react-context").ProviderProps<FormikContext<any>>, any>, FormikConsumer: React.ComponentClass<import("create-react-context").ConsumerProps<FormikContext<any>>, any>;
import { FormikCtx } from './types';
export declare function connect<OuterProps, Values = {}>(Comp: React.ComponentType<OuterProps & {
formik: FormikContext<Values>;
formik: FormikCtx<Values>;
}>): React.ComponentClass<OuterProps, any> & {
WrappedComponent: React.ComponentClass<OuterProps & {
formik: FormikContext<Values>;
formik: FormikCtx<Values>;
}, any>;
};
import * as React from 'react';
import { FormikContext } from './types';
import { FormikCtx } from './types';
export interface ErrorMessageProps {

@@ -12,6 +12,6 @@ name: string;

WrappedComponent: React.ComponentClass<ErrorMessageProps & {
formik: FormikContext<ErrorMessageProps & {
formik: FormikContext<any>;
formik: FormikCtx<ErrorMessageProps & {
formik: FormikCtx<any>;
}>;
}, any>;
};

@@ -23,4 +23,14 @@ import * as React from 'react';

export declare type FieldAttributes<T> = GenericFieldHTMLAttributes & FieldConfig & T;
export declare const Field: React.ComponentClass<any, any> & {
WrappedComponent: React.ComponentClass<any, any>;
};
export declare function useField(name: string, type?: string): [{
value: any;
name: string;
onChange: (e: React.ChangeEvent<any>) => void;
onBlur: (e: any) => void;
}, {
value: any;
error?: string | undefined;
touch: boolean;
initialValue?: any;
}];
export declare function Field({ validate, name, render, children, component, ...props }: FieldAttributes<any>): any;
export declare const FastField: typeof Field;
import * as React from 'react';
import { FormikContext, SharedRenderProps, FormikProps } from './types';
import { FormikCtx, SharedRenderProps, FormikProps } from './types';
export declare type FieldArrayRenderProps = ArrayHelpers & {

@@ -38,4 +38,4 @@ form: FormikProps<any>;

} & SharedRenderProps<FieldArrayRenderProps> & {
formik: FormikContext<any>;
formik: FormikCtx<any>;
}, any>;
};
import * as React from 'react';
export declare type FormikFormProps = Pick<React.FormHTMLAttributes<HTMLFormElement>, Exclude<keyof React.FormHTMLAttributes<HTMLFormElement>, 'onReset' | 'onSubmit'>>;
export declare const Form: React.ComponentClass<Pick<React.FormHTMLAttributes<HTMLFormElement>, "color" | "hidden" | "dir" | "slot" | "style" | "title" | "children" | "name" | "className" | "autoComplete" | "placeholder" | "onChange" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "draggable" | "id" | "lang" | "spellCheck" | "tabIndex" | "inputMode" | "is" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChangeCapture" | "onInput" | "onInputCapture" | "onResetCapture" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "acceptCharset" | "action" | "encType" | "method" | "noValidate" | "target">, any> & {
WrappedComponent: React.ComponentClass<Pick<React.FormHTMLAttributes<HTMLFormElement>, "color" | "hidden" | "dir" | "slot" | "style" | "title" | "children" | "name" | "className" | "autoComplete" | "placeholder" | "onChange" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "draggable" | "id" | "lang" | "spellCheck" | "tabIndex" | "inputMode" | "is" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChangeCapture" | "onInput" | "onInputCapture" | "onResetCapture" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "acceptCharset" | "action" | "encType" | "method" | "noValidate" | "target"> & {
formik: import("./types").FormikContext<{}>;
}, any>;
};
export declare function Form(props: FormikFormProps): JSX.Element;
export declare namespace Form {
var displayName: string;
}

@@ -8,19 +8,10 @@ 'use strict';

var tslib_1 = require('tslib');
var React = require('react');
var hoistNonReactStatics = _interopDefault(require('hoist-non-react-statics'));
var createContext = _interopDefault(require('create-react-context'));
var cloneDeep = _interopDefault(require('lodash.clonedeep'));
var toPath = _interopDefault(require('lodash.topath'));
var React = require('react');
var isEqual = _interopDefault(require('react-fast-compare'));
var deepmerge = _interopDefault(require('deepmerge'));
var warning = _interopDefault(require('warning'));
var deepmerge = _interopDefault(require('deepmerge'));
var hoistNonReactStatics = _interopDefault(require('hoist-non-react-statics'));
var _a;
var FormikProvider = (_a = createContext({}), _a.Provider), FormikConsumer = _a.Consumer;
function connect(Comp) {
var C = function (props) { return (React.createElement(FormikConsumer, null, function (formik) { return React.createElement(Comp, tslib_1.__assign({}, props, { formik: formik })); })); };
C.WrappedComponent = Comp;
return hoistNonReactStatics(C, Comp);
}
function getIn(obj, key, def, p) {

@@ -100,3 +91,3 @@ if (p === void 0) { p = 0; }

};
var isNaN = function (obj) { return obj !== obj; };
var isNaN$1 = function (obj) { return obj !== obj; };
var isEmptyChildren = function (children) {

@@ -121,222 +112,201 @@ return React.Children.count(children) === 0;

var Formik = (function (_super) {
tslib_1.__extends(Formik, _super);
function Formik(props) {
var _this = _super.call(this, props) || this;
_this.hcCache = {};
_this.hbCache = {};
_this.registerField = function (name, Comp) {
_this.fields[name] = Comp;
var PrivateFormikContext = React.createContext({});
var FormikProvider = PrivateFormikContext.Provider;
var FormikConsumer = PrivateFormikContext.Consumer;
function useFormikContext() {
return React.useContext(PrivateFormikContext);
}
function formikReducer(state, msg) {
switch (msg.type) {
case 'SET_VALUES':
return tslib_1.__assign({}, state, { values: msg.payload });
case 'SET_TOUCHED':
return tslib_1.__assign({}, state, { touched: msg.payload });
case 'SET_ERRORS':
return tslib_1.__assign({}, state, { errors: msg.payload });
case 'SET_STATUS':
return tslib_1.__assign({}, state, { status: msg.payload });
case 'SET_ISVALIDATING':
return tslib_1.__assign({}, state, { isValidating: msg.payload });
case 'SET_ISSUBMITTING':
return tslib_1.__assign({}, state, { isSubmitting: msg.payload });
case 'SET_FIELD_VALUE':
return tslib_1.__assign({}, state, { values: setIn(state.values, msg.payload.field, msg.payload.value) });
case 'SET_FIELD_TOUCHED':
return tslib_1.__assign({}, state, { touched: setIn(state.touched, msg.payload.field, msg.payload.value) });
case 'SET_FIELD_ERROR':
return tslib_1.__assign({}, state, { errors: setIn(state.errors, msg.payload.field, msg.payload.value) });
case 'RESET_FORM':
case 'SET_FORMIK_STATE':
return tslib_1.__assign({}, state, msg.payload);
case 'SUBMIT_ATTEMPT':
return tslib_1.__assign({}, state, { touched: setNestedObjectValues(state.values, true), isSubmitting: true, isValidating: true, submitCount: state.submitCount + 1 });
case 'SUBMIT_FAILURE':
return tslib_1.__assign({}, state, { isSubmitting: false });
default:
return state;
}
}
function useFormik(_a) {
var _b = _a.validateOnChange, validateOnChange = _b === void 0 ? true : _b, _c = _a.validateOnBlur, validateOnBlur = _c === void 0 ? true : _c, _d = _a.isInitialValid, isInitialValid = _d === void 0 ? false : _d, rest = tslib_1.__rest(_a, ["validateOnChange", "validateOnBlur", "isInitialValid"]);
var props = tslib_1.__assign({ validateOnChange: validateOnChange, validateOnBlur: validateOnBlur, isInitialValid: isInitialValid }, rest);
var initialValues = React.useRef(props.initialValues);
var didMount = React.useRef(false);
var fields = React.useRef({});
React.useEffect(function () {
initialValues.current = props.initialValues;
}, [props.initialValues]);
var _e = React.useReducer(formikReducer, {
values: props.initialValues,
errors: {},
touched: {},
isSubmitting: false,
isValidating: false,
submitCount: 0,
}), state = _e[0], dispatch = _e[1];
React.useEffect(function () {
if (!!didMount.current && !!validateOnChange && !state.isSubmitting) {
validateForm(state.values);
}
}, [state.values, validateOnChange, state.isSubmitting]);
React.useEffect(function () {
if (!!didMount.current && !!validateOnBlur && !state.isSubmitting) {
validateForm(state.values);
}
}, [state.touched, validateOnBlur, state.isSubmitting]);
React.useEffect(function () {
didMount.current = true;
return function unMount() {
didMount.current = false;
};
_this.unregisterField = function (name) {
delete _this.fields[name];
};
_this.setErrors = function (errors) {
_this.setState({ errors: errors });
};
_this.setTouched = function (touched) {
_this.setState({ touched: touched }, function () {
if (_this.props.validateOnBlur) {
_this.runValidations(_this.state.values);
}
});
};
_this.setValues = function (values) {
_this.setState({ values: values }, function () {
if (_this.props.validateOnChange) {
_this.runValidations(values);
}
});
};
_this.setStatus = function (status) {
_this.setState({ status: status });
};
_this.setError = function (error) {
{
console.warn("Warning: Formik's setError(error) is deprecated and may be removed in future releases. Please use Formik's setStatus(status) instead. It works identically. For more info see https://github.com/jaredpalmer/formik#setstatus-status-any--void");
}
_this.setState({ error: error });
};
_this.setSubmitting = function (isSubmitting) {
if (_this.didMount) {
_this.setState({ isSubmitting: isSubmitting });
}
};
_this.validateField = function (field) {
_this.setState({ isValidating: true });
_this.runSingleFieldLevelValidation(field, getIn(_this.state.values, field)).then(function (error) {
if (_this.didMount) {
_this.setState({
errors: setIn(_this.state.errors, field, error),
isValidating: false,
});
}
});
};
_this.runSingleFieldLevelValidation = function (field, value) {
return new Promise(function (resolve) {
return resolve(_this.fields[field].props.validate(value));
}).then(function (x) { return x; }, function (e) { return e; });
};
_this.runValidationSchema = function (values) {
return new Promise(function (resolve) {
var validationSchema = _this.props.validationSchema;
var schema = isFunction(validationSchema)
? validationSchema()
: validationSchema;
validateYupSchema(values, schema).then(function () {
resolve({});
}, function (err) {
resolve(yupToFormErrors(err));
});
});
};
_this.runValidations = function (values) {
if (values === void 0) { values = _this.state.values; }
_this.setState({ isValidating: true });
return Promise.all([
_this.runFieldLevelValidations(values),
_this.props.validationSchema ? _this.runValidationSchema(values) : {},
_this.props.validate ? _this.runValidateHandler(values) : {},
]).then(function (_a) {
var fieldErrors = _a[0], schemaErrors = _a[1], handlerErrors = _a[2];
var combinedErrors = deepmerge.all([fieldErrors, schemaErrors, handlerErrors], { arrayMerge: arrayMerge });
if (_this.didMount) {
_this.setState({ isValidating: false, errors: combinedErrors });
}
return combinedErrors;
});
};
_this.handleChange = function (eventOrPath) {
var executeChange = function (eventOrTextValue, maybePath) {
var field = maybePath;
var val = eventOrTextValue;
var parsed;
if (!isString(eventOrTextValue)) {
if (eventOrTextValue.persist) {
eventOrTextValue.persist();
}
var _a = eventOrTextValue.target, type = _a.type, name_1 = _a.name, id = _a.id, value = _a.value, checked = _a.checked, outerHTML = _a.outerHTML;
field = maybePath ? maybePath : name_1 ? name_1 : id;
if (!field && "development" !== 'production') {
warnAboutMissingIdentifier({
htmlContent: outerHTML,
documentationAnchorLink: 'handlechange-e-reactchangeeventany--void',
handlerName: 'handleChange',
});
}
val = /number|range/.test(type)
? ((parsed = parseFloat(value)), isNaN(parsed) ? '' : parsed)
: /checkbox/.test(type) ? checked : value;
}
if (field) {
_this.setState(function (prevState) { return (tslib_1.__assign({}, prevState, { values: setIn(prevState.values, field, val) })); }, function () {
if (_this.props.validateOnChange) {
_this.runValidations(setIn(_this.state.values, field, val));
}
});
}
}, []);
var imperativeMethods = {
resetForm: resetForm,
submitForm: submitForm,
validateForm: validateForm,
validateField: validateField,
setErrors: setErrors,
setFieldError: setFieldError,
setFieldTouched: setFieldTouched,
setFieldValue: setFieldValue,
setStatus: setStatus,
setSubmitting: setSubmitting,
setTouched: setTouched,
setValues: setValues,
setFormikState: setFormikState,
};
function registerField(name, _a) {
var validate = _a.validate;
if (fields.current !== null) {
fields.current[name] = {
validate: validate,
};
if (isString(eventOrPath)) {
return isFunction(_this.hcCache[eventOrPath])
? _this.hcCache[eventOrPath]
: (_this.hcCache[eventOrPath] = function (event) {
return executeChange(event, eventOrPath);
});
}
}
function unregisterField(name) {
if (fields.current !== null) {
delete fields.current[name];
}
}
function handleBlur(eventOrString) {
if (isString(eventOrString)) {
return function (event) { return executeBlur(event, eventOrString); };
}
else {
executeBlur(eventOrString);
}
function executeBlur(e, path) {
if (e.persist) {
e.persist();
}
else {
executeChange(eventOrPath);
}
};
_this.setFieldValue = function (field, value, shouldValidate) {
if (shouldValidate === void 0) { shouldValidate = true; }
if (_this.didMount) {
_this.setState(function (prevState) { return (tslib_1.__assign({}, prevState, { values: setIn(prevState.values, field, value) })); }, function () {
if (_this.props.validateOnChange && shouldValidate) {
_this.runValidations(_this.state.values);
}
var _a = e.target, name = _a.name, id = _a.id, outerHTML = _a.outerHTML;
var field = path ? path : name ? name : id;
if (!field && "development" !== 'production') {
warnAboutMissingIdentifier({
htmlContent: outerHTML,
documentationAnchorLink: 'handleblur-e-any--void',
handlerName: 'handleBlur',
});
}
};
_this.handleSubmit = function (e) {
if (e && e.preventDefault) {
e.preventDefault();
}
if (typeof document !== 'undefined') {
var activeElement = getActiveElement();
if (activeElement !== null &&
activeElement instanceof HTMLButtonElement) {
warning(!!(activeElement.attributes &&
activeElement.attributes.getNamedItem('type')), 'You submitted a Formik form using a button with an unspecified `type` attribute. Most browsers default button elements to `type="submit"`. If this is not a submit button, please add `type="button"`.');
}
}
_this.submitForm();
};
_this.submitForm = function () {
_this.setState(function (prevState) { return ({
touched: setNestedObjectValues(prevState.values, true),
isSubmitting: true,
submitCount: prevState.submitCount + 1,
}); });
return _this.runValidations().then(function (combinedErrors) {
var isValid = Object.keys(combinedErrors).length === 0;
if (isValid) {
_this.executeSubmit();
}
else if (_this.didMount) {
_this.setState({ isSubmitting: false });
}
dispatch({
type: 'SET_FIELD_TOUCHED',
payload: { field: field, value: true },
});
};
_this.executeSubmit = function () {
_this.props.onSubmit(_this.state.values, _this.getFormikActions());
};
_this.handleBlur = function (eventOrString) {
var executeBlur = function (e, path) {
if (e.persist) {
e.persist();
}
}
function handleChange(eventOrPath) {
if (isString(eventOrPath)) {
return function (event) { return executeChange(event, eventOrPath); };
}
else {
executeChange(eventOrPath);
}
function executeChange(eventOrTextValue, maybePath) {
var field = maybePath;
var val = eventOrTextValue;
var parsed;
if (!isString(eventOrTextValue)) {
if (eventOrTextValue.persist) {
eventOrTextValue.persist();
}
var _a = e.target, name = _a.name, id = _a.id, outerHTML = _a.outerHTML;
var field = path ? path : name ? name : id;
var _a = eventOrTextValue.target, type = _a.type, name_1 = _a.name, id = _a.id, value = _a.value, checked = _a.checked, outerHTML = _a.outerHTML;
field = maybePath ? maybePath : name_1 ? name_1 : id;
if (!field && "development" !== 'production') {
warnAboutMissingIdentifier({
htmlContent: outerHTML,
documentationAnchorLink: 'handleblur-e-any--void',
handlerName: 'handleBlur',
documentationAnchorLink: 'handlechange-e-reactchangeeventany--void',
handlerName: 'handleChange',
});
}
_this.setState(function (prevState) { return ({
touched: setIn(prevState.touched, field, true),
}); });
if (_this.props.validateOnBlur) {
_this.runValidations(_this.state.values);
}
};
if (isString(eventOrString)) {
return isFunction(_this.hbCache[eventOrString])
? _this.hbCache[eventOrString]
: (_this.hbCache[eventOrString] = function (event) {
return executeBlur(event, eventOrString);
});
val = /number|range/.test(type)
? ((parsed = parseFloat(value)), isNaN(parsed) ? '' : parsed)
: /checkbox/.test(type) ? checked : value;
}
if (field) {
dispatch({ type: 'SET_FIELD_VALUE', payload: { field: field, value: val } });
}
}
}
function handleReset() {
if (props.onReset) {
var maybePromisedOnReset = props.onReset(state.values, imperativeMethods);
if (isPromise(maybePromisedOnReset)) {
maybePromisedOnReset.then(resetForm);
}
else {
executeBlur(eventOrString);
resetForm();
}
};
_this.setFieldTouched = function (field, touched, shouldValidate) {
if (touched === void 0) { touched = true; }
if (shouldValidate === void 0) { shouldValidate = true; }
_this.setState(function (prevState) { return (tslib_1.__assign({}, prevState, { touched: setIn(prevState.touched, field, touched) })); }, function () {
if (_this.props.validateOnBlur && shouldValidate) {
_this.runValidations(_this.state.values);
}
});
};
_this.setFieldError = function (field, message) {
_this.setState(function (prevState) { return (tslib_1.__assign({}, prevState, { errors: setIn(prevState.errors, field, message) })); });
};
_this.resetForm = function (nextValues) {
var values = nextValues ? nextValues : _this.props.initialValues;
_this.initialValues = values;
_this.setState({
}
else {
resetForm();
}
}
function handleSubmit(e) {
if (e && e.preventDefault) {
e.preventDefault();
}
if (typeof document !== 'undefined') {
var activeElement = getActiveElement();
if (activeElement !== null &&
activeElement instanceof HTMLButtonElement) {
warning(!!(activeElement.attributes &&
activeElement.attributes.getNamedItem('type')), 'You submitted a Formik form using a button with an unspecified `type` attribute. Most browsers default button elements to `type="submit"`. If this is not a submit button, please add `type="button"`.');
}
}
submitForm();
}
function executeSubmit() {
props.onSubmit(state.values, imperativeMethods);
}
function resetForm(nextValues) {
var values = nextValues
? nextValues
: initialValues.current !== null
? initialValues.current
: props.initialValues;
initialValues.current = values;
dispatch({
type: 'RESET_FORM',
payload: {
isSubmitting: false,

@@ -346,102 +316,99 @@ isValidating: false,

touched: {},
error: undefined,
status: undefined,
values: values,
submitCount: 0,
});
};
_this.handleReset = function () {
if (_this.props.onReset) {
var maybePromisedOnReset = _this.props.onReset(_this.state.values, _this.getFormikActions());
if (isPromise(maybePromisedOnReset)) {
maybePromisedOnReset.then(_this.resetForm);
}
else {
_this.resetForm();
}
},
});
}
function setTouched(touched) {
dispatch({ type: 'SET_TOUCHED', payload: touched });
}
function setErrors(errors) {
dispatch({ type: 'SET_ERRORS', payload: errors });
}
function setValues(values) {
dispatch({ type: 'SET_VALUES', payload: values });
}
function setFieldError(field, value) {
dispatch({
type: 'SET_FIELD_ERROR',
payload: { field: field, value: value },
});
}
function setFieldValue(field, value) {
dispatch({
type: 'SET_FIELD_VALUE',
payload: {
field: field,
value: value,
},
});
}
function setFieldTouched(field, touched) {
if (touched === void 0) { touched = true; }
dispatch({
type: 'SET_FIELD_TOUCHED',
payload: {
field: field,
value: touched,
},
});
}
function validateField(name) {
if (fields.current !== null &&
fields.current[name] &&
fields.current[name].validate &&
isFunction(fields.current[name].validate)) {
var value = getIn(state.values, name);
var maybePromise = fields.current[name].validate(value);
if (isPromise(maybePromise)) {
dispatch({ type: 'SET_ISVALIDATING', payload: true });
return maybePromise
.then(function (x) { return x; }, function (e) { return e; })
.then(function (error) {
dispatch({
type: 'SET_FIELD_ERROR',
payload: { field: name, value: error },
});
dispatch({ type: 'SET_ISVALIDATING', payload: false });
});
}
else {
_this.resetForm();
dispatch({
type: 'SET_FIELD_ERROR',
payload: {
field: name,
value: maybePromise,
},
});
return Promise.resolve(maybePromise);
}
};
_this.setFormikState = function (s, callback) {
return _this.setState(s, callback);
};
_this.getFormikActions = function () {
return {
resetForm: _this.resetForm,
submitForm: _this.submitForm,
validateForm: _this.runValidations,
validateField: _this.validateField,
setError: _this.setError,
setErrors: _this.setErrors,
setFieldError: _this.setFieldError,
setFieldTouched: _this.setFieldTouched,
setFieldValue: _this.setFieldValue,
setStatus: _this.setStatus,
setSubmitting: _this.setSubmitting,
setTouched: _this.setTouched,
setValues: _this.setValues,
setFormikState: _this.setFormikState,
};
};
_this.getFormikComputedProps = function () {
var isInitialValid = _this.props.isInitialValid;
var dirty = !isEqual(_this.initialValues, _this.state.values);
return {
dirty: dirty,
isValid: dirty
? _this.state.errors && Object.keys(_this.state.errors).length === 0
: isInitialValid !== false && isFunction(isInitialValid)
? isInitialValid(_this.props)
: isInitialValid,
initialValues: _this.initialValues,
};
};
_this.getFormikBag = function () {
return tslib_1.__assign({}, _this.state, _this.getFormikActions(), _this.getFormikComputedProps(), { registerField: _this.registerField, unregisterField: _this.unregisterField, handleBlur: _this.handleBlur, handleChange: _this.handleChange, handleReset: _this.handleReset, handleSubmit: _this.handleSubmit, validateOnChange: _this.props.validateOnChange, validateOnBlur: _this.props.validateOnBlur });
};
_this.getFormikContext = function () {
return tslib_1.__assign({}, _this.getFormikBag(), { validationSchema: _this.props.validationSchema, validate: _this.props.validate, initialValues: _this.initialValues });
};
_this.state = {
values: props.initialValues || {},
errors: {},
touched: {},
isSubmitting: false,
isValidating: false,
submitCount: 0,
};
_this.didMount = false;
_this.fields = {};
_this.initialValues = props.initialValues || {};
warning(!(props.component && props.render), 'You should not use <Formik component> and <Formik render> in the same <Formik> component; <Formik render> will be ignored');
warning(!(props.component && props.children && !isEmptyChildren(props.children)), 'You should not use <Formik component> and <Formik children> in the same <Formik> component; <Formik children> will be ignored');
warning(!(props.render && props.children && !isEmptyChildren(props.children)), 'You should not use <Formik render> and <Formik children> in the same <Formik> component; <Formik children> will be ignored');
return _this;
}
else {
return Promise.resolve();
}
}
Formik.prototype.componentDidMount = function () {
this.didMount = true;
};
Formik.prototype.componentWillUnmount = function () {
this.didMount = false;
};
Formik.prototype.componentDidUpdate = function (prevProps) {
if (this.props.enableReinitialize &&
!isEqual(prevProps.initialValues, this.props.initialValues)) {
this.initialValues = this.props.initialValues;
this.resetForm(this.props.initialValues);
function runSingleFieldLevelValidationAsPromise(name, value) {
return new Promise(function (resolve) {
if (fields.current !== null &&
fields.current[name] &&
fields.current[name].validate &&
isFunction(fields.current[name].validate)) {
resolve(fields.current[name].validate(value));
}
}).then(function (x) { return x; }, function (e) { return e; });
}
function runFieldLevelValidations(values) {
if (fields.current === null) {
return Promise.resolve({});
}
};
Formik.prototype.runFieldLevelValidations = function (values) {
var _this = this;
var fieldKeysWithValidation = Object.keys(this.fields).filter(function (f) {
return _this.fields &&
_this.fields[f] &&
_this.fields[f].props.validate &&
isFunction(_this.fields[f].props.validate);
var fieldKeysWithValidation = Object.keys(fields.current).filter(function (f) {
return fields.current !== null &&
fields.current[f] &&
fields.current[f].validate &&
isFunction(fields.current[f].validate);
});
var fieldValidations = fieldKeysWithValidation.length > 0
? fieldKeysWithValidation.map(function (f) {
return _this.runSingleFieldLevelValidation(f, getIn(values, f));
return runSingleFieldLevelValidationAsPromise(f, getIn(values, f));
})

@@ -460,7 +427,6 @@ : [Promise.resolve('DO_NOT_DELETE_YOU_WILL_BE_FIRED')];

});
};
Formik.prototype.runValidateHandler = function (values) {
var _this = this;
}
function runValidateHandler(values, field) {
return new Promise(function (resolve) {
var maybePromisedErrors = _this.props.validate(values);
var maybePromisedErrors = props.validate(values, field);
if (maybePromisedErrors === undefined) {

@@ -480,30 +446,131 @@ resolve({});

});
};
Formik.prototype.render = function () {
var _a = this.props, component = _a.component, render = _a.render, children = _a.children;
var props = this.getFormikBag();
var ctx = this.getFormikContext();
return (React.createElement(FormikProvider, { value: ctx }, component
? React.createElement(component, props)
: render
? render(props)
: children
? isFunction(children)
? children(props)
: !isEmptyChildren(children)
? React.Children.only(children)
: null
: null));
};
Formik.defaultProps = {
validateOnChange: true,
validateOnBlur: true,
isInitialValid: false,
enableReinitialize: false,
};
return Formik;
}(React.Component));
}
function runValidationSchema(values, field) {
return new Promise(function (resolve) {
var validationSchema = props.validationSchema;
var schema = isFunction(validationSchema)
? validationSchema(field)
: validationSchema;
var promise = field && schema.validateAt
? schema.validateAt(field, values)
: validateYupSchema(values, schema);
promise.then(function () {
resolve({});
}, function (err) {
resolve(yupToFormErrors(err));
});
});
}
function validateForm(values, field) {
if (values === void 0) { values = state.values; }
dispatch({ type: 'SET_ISVALIDATING', payload: true });
return Promise.all([
runFieldLevelValidations(values),
props.validationSchema ? runValidationSchema(values, field) : {},
props.validate ? runValidateHandler(values, field) : {},
]).then(function (_a) {
var fieldErrors = _a[0], schemaErrors = _a[1], handlerErrors = _a[2];
var combinedErrors = deepmerge.all([fieldErrors, schemaErrors, handlerErrors], { arrayMerge: arrayMerge });
if (didMount.current) {
dispatch({ type: 'SET_ISVALIDATING', payload: false });
dispatch({ type: 'SET_ERRORS', payload: combinedErrors });
}
return combinedErrors;
});
}
function setFormikState(stateOrCb) {
if (isFunction(stateOrCb)) {
dispatch({ type: 'SET_FORMIK_STATE', payload: stateOrCb(state) });
}
else {
dispatch({ type: 'SET_FORMIK_STATE', payload: stateOrCb });
}
}
function setStatus(status) {
dispatch({ type: 'SET_STATUS', payload: status });
}
function setSubmitting(isSubmitting) {
dispatch({ type: 'SET_ISSUBMITTING', payload: isSubmitting });
}
function submitForm() {
dispatch({ type: 'SUBMIT_ATTEMPT' });
return validateForm().then(function (combinedErrors) {
var isActuallyValid = Object.keys(combinedErrors).length === 0;
if (isActuallyValid) {
executeSubmit();
}
else if (didMount.current) {
dispatch({ type: 'SUBMIT_FAILURE' });
}
});
}
function getFieldProps(name, type) {
var field = {
name: name,
value: type && (type === 'radio' || type === 'checkbox')
? undefined
: getIn(state.values, name),
onChange: handleChange,
onBlur: handleBlur,
};
return [field, getFieldMeta(name)];
}
function getFieldMeta(name) {
return {
value: getIn(state.values, name),
error: getIn(state.errors, name),
touch: getIn(state.touched, name),
initialValue: getIn(initialValues.current, name),
};
}
var dirty = React.useMemo(function () { return !isEqual(initialValues.current, state.values); }, [initialValues.current, state.values]);
var isValid = React.useMemo(function () {
return dirty
? state.errors && Object.keys(state.errors).length === 0
: isInitialValid !== false && isFunction(isInitialValid)
? isInitialValid(props)
: isInitialValid;
}, [state.errors, dirty, isInitialValid]);
var ctx = tslib_1.__assign({}, state, { initialValues: initialValues.current || props.initialValues, handleBlur: handleBlur,
handleChange: handleChange,
handleReset: handleReset,
handleSubmit: handleSubmit,
resetForm: resetForm,
setErrors: setErrors,
setFormikState: setFormikState,
setFieldTouched: setFieldTouched,
setFieldValue: setFieldValue,
setFieldError: setFieldError,
setStatus: setStatus,
setSubmitting: setSubmitting,
setTouched: setTouched,
setValues: setValues,
submitForm: submitForm,
validateForm: validateForm,
validateField: validateField,
isValid: isValid,
dirty: dirty,
unregisterField: unregisterField,
registerField: registerField,
getFieldProps: getFieldProps });
return ctx;
}
function Formik(props) {
var formikbag = useFormik(props);
var component = props.component, children = props.children, render = props.render;
return (React.createElement(FormikProvider, { value: formikbag }, component
? React.createElement(component, formikbag)
: render
? render(formikbag)
: children
? isFunction(children)
? children(formikbag)
: !isEmptyChildren(children)
? React.Children.only(children)
: null
: null));
}
function warnAboutMissingIdentifier(_a) {
var htmlContent = _a.htmlContent, documentationAnchorLink = _a.documentationAnchorLink, handlerName = _a.handlerName;
console.error("Warning: Formik called `" + handlerName + "`, but you forgot to pass an `id` or `name` attribute to your input:\n\n " + htmlContent + "\n\n Formik cannot determine which value to update. For more info see https://github.com/jaredpalmer/formik#" + documentationAnchorLink + "\n ");
console.error("Warning: Formik called `" + handlerName + "`, but you forgot to pass an `id` or `name` attribute to your input:\n " + htmlContent + "\n Formik cannot determine which value to update. For more info see https://github.com/jaredpalmer/formik#" + documentationAnchorLink + "\n ");
}

@@ -558,59 +625,37 @@ function yupToFormErrors(yupError) {

var FieldInner = (function (_super) {
tslib_1.__extends(FieldInner, _super);
function FieldInner(props) {
var _this = _super.call(this, props) || this;
var render = props.render, children = props.children, component = props.component;
warning(!(component && render), 'You should not use <Field component> and <Field render> in the same <Field> component; <Field component> will be ignored');
warning(!(component && children && isFunction(children)), 'You should not use <Field component> and <Field children> as a function in the same <Field> component; <Field component> will be ignored.');
warning(!(render && children && !isEmptyChildren(children)), 'You should not use <Field render> and <Field children> in the same <Field> component; <Field children> will be ignored');
return _this;
function useField(name, type) {
var formik = useFormikContext();
return formik.getFieldProps(name, type);
}
function Field(_a) {
var validate = _a.validate, name = _a.name, render = _a.render, children = _a.children, _b = _a.component, component = _b === void 0 ? 'input' : _b, props = tslib_1.__rest(_a, ["validate", "name", "render", "children", "component"]);
var _c = useFormikContext(), _validate = _c.validate, _validationSchema = _c.validationSchema, formik = tslib_1.__rest(_c, ["validate", "validationSchema"]);
React.useEffect(function () {
formik.registerField(props.name, {
validate: props.validate,
});
return function () {
formik.unregisterField(props.name);
};
}, [props.name, props.validate]);
var field = formik.getFieldProps(name, props.type)[0];
var bag = { field: field, form: formik };
if (render) {
return render(bag);
}
FieldInner.prototype.componentDidMount = function () {
this.props.formik.registerField(this.props.name, this);
};
FieldInner.prototype.componentDidUpdate = function (prevProps) {
if (this.props.name !== prevProps.name) {
this.props.formik.unregisterField(prevProps.name);
this.props.formik.registerField(this.props.name, this);
}
if (this.props.validate !== prevProps.validate) {
this.props.formik.registerField(this.props.name, this);
}
};
FieldInner.prototype.componentWillUnmount = function () {
this.props.formik.unregisterField(this.props.name);
};
FieldInner.prototype.render = function () {
var _a = this.props, validate = _a.validate, name = _a.name, render = _a.render, children = _a.children, _b = _a.component, component = _b === void 0 ? 'input' : _b, formik = _a.formik, props = tslib_1.__rest(_a, ["validate", "name", "render", "children", "component", "formik"]);
var _validate = formik.validate, _validationSchema = formik.validationSchema, restOfFormik = tslib_1.__rest(formik, ["validate", "validationSchema"]);
var field = {
value: props.type === 'radio' || props.type === 'checkbox'
? props.value
: getIn(formik.values, name),
name: name,
onChange: formik.handleChange,
onBlur: formik.handleBlur,
};
var bag = { field: field, form: restOfFormik };
if (render) {
return render(bag);
}
if (isFunction(children)) {
return children(bag);
}
if (typeof component === 'string') {
var innerRef = props.innerRef, rest = tslib_1.__rest(props, ["innerRef"]);
return React.createElement(component, tslib_1.__assign({ ref: innerRef }, field, rest, { children: children }));
}
return React.createElement(component, tslib_1.__assign({}, bag, props, { children: children }));
};
return FieldInner;
}(React.Component));
var Field = connect(FieldInner);
if (isFunction(children)) {
return children(bag);
}
if (typeof component === 'string') {
var innerRef = props.innerRef, rest = tslib_1.__rest(props, ["innerRef"]);
return React.createElement(component, tslib_1.__assign({ ref: innerRef }, field, rest, { children: children }));
}
return React.createElement(component, tslib_1.__assign({}, bag, props, { children: children }));
}
var FastField = Field;
var Form = connect(function (_a) {
var _b = _a.formik, handleReset = _b.handleReset, handleSubmit = _b.handleSubmit, props = tslib_1.__rest(_a, ["formik"]);
return (React.createElement("form", tslib_1.__assign({ onReset: handleReset, onSubmit: handleSubmit }, props)));
});
function Form(props) {
var _a = useFormikContext(), handleReset = _a.handleReset, handleSubmit = _a.handleSubmit;
return React.createElement("form", tslib_1.__assign({ onSubmit: handleSubmit, onReset: handleReset }, props));
}
Form.displayName = 'Form';

@@ -665,2 +710,8 @@

function connect(Comp) {
var C = function (props) { return (React.createElement(FormikConsumer, null, function (formik) { return React.createElement(Comp, tslib_1.__assign({}, props, { formik: formik })); })); };
C.WrappedComponent = Comp;
return hoistNonReactStatics(C, Comp);
}
var move = function (array, from, to) {

@@ -695,3 +746,3 @@ var copy = (array || []).slice();

_this.updateArrayField = function (fn, alterTouched, alterErrors) {
var _a = _this.props, name = _a.name, validateOnChange = _a.validateOnChange, _b = _a.formik, setFormikState = _b.setFormikState, validateForm = _b.validateForm, values = _b.values, touched = _b.touched, errors = _b.errors;
var _a = _this.props, name = _a.name, _b = _a.formik, setFormikState = _b.setFormikState, values = _b.values, touched = _b.touched, errors = _b.errors;
setFormikState(function (prevState) { return (tslib_1.__assign({}, prevState, { values: setIn(prevState.values, name, fn(getIn(values, name))), errors: alterErrors

@@ -701,7 +752,3 @@ ? setIn(prevState.errors, name, fn(getIn(errors, name)))

? setIn(prevState.touched, name, fn(getIn(touched, name)))
: prevState.touched })); }, function () {
if (validateOnChange) {
validateForm();
}
});
: prevState.touched })); });
};

@@ -736,4 +783,5 @@ _this.push = function (value) {

var arr = array ? [value].concat(array) : [value];
if (length < 0)
if (length < 0) {
length = arr.length;
}
return arr;

@@ -813,73 +861,2 @@ }, true, true);

var FastFieldInner = (function (_super) {
tslib_1.__extends(FastFieldInner, _super);
function FastFieldInner(props) {
var _this = _super.call(this, props) || this;
var render = props.render, children = props.children, component = props.component;
warning(!(component && render), 'You should not use <FastField component> and <FastField render> in the same <FastField> component; <FastField component> will be ignored');
warning(!(component && children && isFunction(children)), 'You should not use <FastField component> and <FastField children> as a function in the same <FastField> component; <FastField component> will be ignored.');
warning(!(render && children && !isEmptyChildren(children)), 'You should not use <FastField render> and <FastField children> in the same <FastField> component; <FastField children> will be ignored');
return _this;
}
FastFieldInner.prototype.shouldComponentUpdate = function (props) {
if (this.props.shouldUpdate) {
return this.props.shouldUpdate(props, this.props);
}
else if (getIn(this.props.formik.values, this.props.name) !==
getIn(props.formik.values, this.props.name) ||
getIn(this.props.formik.errors, this.props.name) !==
getIn(props.formik.errors, this.props.name) ||
getIn(this.props.formik.touched, this.props.name) !==
getIn(props.formik.touched, this.props.name) ||
Object.keys(this.props).length !== Object.keys(props).length ||
this.props.formik.isSubmitting !== props.formik.isSubmitting) {
return true;
}
else {
return false;
}
};
FastFieldInner.prototype.componentDidMount = function () {
this.props.formik.registerField(this.props.name, this);
};
FastFieldInner.prototype.componentDidUpdate = function (prevProps) {
if (this.props.name !== prevProps.name) {
this.props.formik.unregisterField(prevProps.name);
this.props.formik.registerField(this.props.name, this);
}
if (this.props.validate !== prevProps.validate) {
this.props.formik.registerField(this.props.name, this);
}
};
FastFieldInner.prototype.componentWillUnmount = function () {
this.props.formik.unregisterField(this.props.name);
};
FastFieldInner.prototype.render = function () {
var _a = this.props, validate = _a.validate, name = _a.name, render = _a.render, children = _a.children, _b = _a.component, component = _b === void 0 ? 'input' : _b, formik = _a.formik, props = tslib_1.__rest(_a, ["validate", "name", "render", "children", "component", "formik"]);
var _validate = formik.validate, _validationSchema = formik.validationSchema, restOfFormik = tslib_1.__rest(formik, ["validate", "validationSchema"]);
var field = {
value: props.type === 'radio' || props.type === 'checkbox'
? props.value
: getIn(formik.values, name),
name: name,
onChange: formik.handleChange,
onBlur: formik.handleBlur,
};
var bag = { field: field, form: restOfFormik };
if (render) {
return render(bag);
}
if (isFunction(children)) {
return children(bag);
}
if (typeof component === 'string') {
var innerRef = props.innerRef, rest = tslib_1.__rest(props, ["innerRef"]);
return React.createElement(component, tslib_1.__assign({ ref: innerRef }, field, rest, { children: children }));
}
return React.createElement(component, tslib_1.__assign({}, bag, props, { children: children }));
};
return FastFieldInner;
}(React.Component));
var FastField = connect(FastFieldInner);
var ErrorMessageImpl = (function (_super) {

@@ -920,6 +897,9 @@ tslib_1.__extends(ErrorMessageImpl, _super);

exports.useFormik = useFormik;
exports.Formik = Formik;
exports.yupToFormErrors = yupToFormErrors;
exports.validateYupSchema = validateYupSchema;
exports.useField = useField;
exports.Field = Field;
exports.FastField = FastField;
exports.Form = Form;

@@ -939,11 +919,11 @@ exports.withFormik = withFormik;

exports.isString = isString;
exports.isNaN = isNaN;
exports.isNaN = isNaN$1;
exports.isEmptyChildren = isEmptyChildren;
exports.isPromise = isPromise;
exports.getActiveElement = getActiveElement;
exports.FastField = FastField;
exports.connect = connect;
exports.ErrorMessage = ErrorMessage;
exports.FormikProvider = FormikProvider;
exports.FormikConsumer = FormikConsumer;
exports.connect = connect;
exports.ErrorMessage = ErrorMessage;
exports.useFormikContext = useFormikContext;
//# sourceMappingURL=formik.cjs.development.js.map

@@ -8,19 +8,10 @@ 'use strict';

var tslib_1 = require('tslib');
var React = require('react');
var hoistNonReactStatics = _interopDefault(require('hoist-non-react-statics'));
var createContext = _interopDefault(require('create-react-context'));
var cloneDeep = _interopDefault(require('lodash.clonedeep'));
var toPath = _interopDefault(require('lodash.topath'));
var React = require('react');
var isEqual = _interopDefault(require('react-fast-compare'));
var warning = _interopDefault(require('warning'));
var deepmerge = _interopDefault(require('deepmerge'));
require('warning');
var hoistNonReactStatics = _interopDefault(require('hoist-non-react-statics'));
var _a;
var FormikProvider = (_a = createContext({}), _a.Provider), FormikConsumer = _a.Consumer;
function connect(Comp) {
var C = function (props) { return (React.createElement(FormikConsumer, null, function (formik) { return React.createElement(Comp, tslib_1.__assign({}, props, { formik: formik })); })); };
C.WrappedComponent = Comp;
return hoistNonReactStatics(C, Comp);
}
function getIn(obj, key, def, p) {

@@ -100,3 +91,3 @@ if (p === void 0) { p = 0; }

};
var isNaN = function (obj) { return obj !== obj; };
var isNaN$1 = function (obj) { return obj !== obj; };
var isEmptyChildren = function (children) {

@@ -121,211 +112,193 @@ return React.Children.count(children) === 0;

var Formik = (function (_super) {
tslib_1.__extends(Formik, _super);
function Formik(props) {
var _this = _super.call(this, props) || this;
_this.hcCache = {};
_this.hbCache = {};
_this.registerField = function (name, Comp) {
_this.fields[name] = Comp;
var PrivateFormikContext = React.createContext({});
var FormikProvider = PrivateFormikContext.Provider;
var FormikConsumer = PrivateFormikContext.Consumer;
function useFormikContext() {
return React.useContext(PrivateFormikContext);
}
function formikReducer(state, msg) {
switch (msg.type) {
case 'SET_VALUES':
return tslib_1.__assign({}, state, { values: msg.payload });
case 'SET_TOUCHED':
return tslib_1.__assign({}, state, { touched: msg.payload });
case 'SET_ERRORS':
return tslib_1.__assign({}, state, { errors: msg.payload });
case 'SET_STATUS':
return tslib_1.__assign({}, state, { status: msg.payload });
case 'SET_ISVALIDATING':
return tslib_1.__assign({}, state, { isValidating: msg.payload });
case 'SET_ISSUBMITTING':
return tslib_1.__assign({}, state, { isSubmitting: msg.payload });
case 'SET_FIELD_VALUE':
return tslib_1.__assign({}, state, { values: setIn(state.values, msg.payload.field, msg.payload.value) });
case 'SET_FIELD_TOUCHED':
return tslib_1.__assign({}, state, { touched: setIn(state.touched, msg.payload.field, msg.payload.value) });
case 'SET_FIELD_ERROR':
return tslib_1.__assign({}, state, { errors: setIn(state.errors, msg.payload.field, msg.payload.value) });
case 'RESET_FORM':
case 'SET_FORMIK_STATE':
return tslib_1.__assign({}, state, msg.payload);
case 'SUBMIT_ATTEMPT':
return tslib_1.__assign({}, state, { touched: setNestedObjectValues(state.values, true), isSubmitting: true, isValidating: true, submitCount: state.submitCount + 1 });
case 'SUBMIT_FAILURE':
return tslib_1.__assign({}, state, { isSubmitting: false });
default:
return state;
}
}
function useFormik(_a) {
var _b = _a.validateOnChange, validateOnChange = _b === void 0 ? true : _b, _c = _a.validateOnBlur, validateOnBlur = _c === void 0 ? true : _c, _d = _a.isInitialValid, isInitialValid = _d === void 0 ? false : _d, rest = tslib_1.__rest(_a, ["validateOnChange", "validateOnBlur", "isInitialValid"]);
var props = tslib_1.__assign({ validateOnChange: validateOnChange, validateOnBlur: validateOnBlur, isInitialValid: isInitialValid }, rest);
var initialValues = React.useRef(props.initialValues);
var didMount = React.useRef(false);
var fields = React.useRef({});
React.useEffect(function () {
initialValues.current = props.initialValues;
}, [props.initialValues]);
var _e = React.useReducer(formikReducer, {
values: props.initialValues,
errors: {},
touched: {},
isSubmitting: false,
isValidating: false,
submitCount: 0,
}), state = _e[0], dispatch = _e[1];
React.useEffect(function () {
if (!!didMount.current && !!validateOnChange && !state.isSubmitting) {
validateForm(state.values);
}
}, [state.values, validateOnChange, state.isSubmitting]);
React.useEffect(function () {
if (!!didMount.current && !!validateOnBlur && !state.isSubmitting) {
validateForm(state.values);
}
}, [state.touched, validateOnBlur, state.isSubmitting]);
React.useEffect(function () {
didMount.current = true;
return function unMount() {
didMount.current = false;
};
_this.unregisterField = function (name) {
delete _this.fields[name];
};
_this.setErrors = function (errors) {
_this.setState({ errors: errors });
};
_this.setTouched = function (touched) {
_this.setState({ touched: touched }, function () {
if (_this.props.validateOnBlur) {
_this.runValidations(_this.state.values);
}
});
};
_this.setValues = function (values) {
_this.setState({ values: values }, function () {
if (_this.props.validateOnChange) {
_this.runValidations(values);
}
});
};
_this.setStatus = function (status) {
_this.setState({ status: status });
};
_this.setError = function (error) {
_this.setState({ error: error });
};
_this.setSubmitting = function (isSubmitting) {
if (_this.didMount) {
_this.setState({ isSubmitting: isSubmitting });
}
};
_this.validateField = function (field) {
_this.setState({ isValidating: true });
_this.runSingleFieldLevelValidation(field, getIn(_this.state.values, field)).then(function (error) {
if (_this.didMount) {
_this.setState({
errors: setIn(_this.state.errors, field, error),
isValidating: false,
});
}
});
};
_this.runSingleFieldLevelValidation = function (field, value) {
return new Promise(function (resolve) {
return resolve(_this.fields[field].props.validate(value));
}).then(function (x) { return x; }, function (e) { return e; });
};
_this.runValidationSchema = function (values) {
return new Promise(function (resolve) {
var validationSchema = _this.props.validationSchema;
var schema = isFunction(validationSchema)
? validationSchema()
: validationSchema;
validateYupSchema(values, schema).then(function () {
resolve({});
}, function (err) {
resolve(yupToFormErrors(err));
});
});
};
_this.runValidations = function (values) {
if (values === void 0) { values = _this.state.values; }
_this.setState({ isValidating: true });
return Promise.all([
_this.runFieldLevelValidations(values),
_this.props.validationSchema ? _this.runValidationSchema(values) : {},
_this.props.validate ? _this.runValidateHandler(values) : {},
]).then(function (_a) {
var fieldErrors = _a[0], schemaErrors = _a[1], handlerErrors = _a[2];
var combinedErrors = deepmerge.all([fieldErrors, schemaErrors, handlerErrors], { arrayMerge: arrayMerge });
if (_this.didMount) {
_this.setState({ isValidating: false, errors: combinedErrors });
}
return combinedErrors;
});
};
_this.handleChange = function (eventOrPath) {
var executeChange = function (eventOrTextValue, maybePath) {
var field = maybePath;
var val = eventOrTextValue;
var parsed;
if (!isString(eventOrTextValue)) {
if (eventOrTextValue.persist) {
eventOrTextValue.persist();
}
var _a = eventOrTextValue.target, type = _a.type, name_1 = _a.name, id = _a.id, value = _a.value, checked = _a.checked, outerHTML = _a.outerHTML;
field = maybePath ? maybePath : name_1 ? name_1 : id;
if (!field && "production" !== 'production') {
warnAboutMissingIdentifier({
htmlContent: outerHTML,
documentationAnchorLink: 'handlechange-e-reactchangeeventany--void',
handlerName: 'handleChange',
});
}
val = /number|range/.test(type)
? ((parsed = parseFloat(value)), isNaN(parsed) ? '' : parsed)
: /checkbox/.test(type) ? checked : value;
}
if (field) {
_this.setState(function (prevState) { return (tslib_1.__assign({}, prevState, { values: setIn(prevState.values, field, val) })); }, function () {
if (_this.props.validateOnChange) {
_this.runValidations(setIn(_this.state.values, field, val));
}
});
}
}, []);
var imperativeMethods = {
resetForm: resetForm,
submitForm: submitForm,
validateForm: validateForm,
validateField: validateField,
setErrors: setErrors,
setFieldError: setFieldError,
setFieldTouched: setFieldTouched,
setFieldValue: setFieldValue,
setStatus: setStatus,
setSubmitting: setSubmitting,
setTouched: setTouched,
setValues: setValues,
setFormikState: setFormikState,
};
function registerField(name, _a) {
var validate = _a.validate;
if (fields.current !== null) {
fields.current[name] = {
validate: validate,
};
if (isString(eventOrPath)) {
return isFunction(_this.hcCache[eventOrPath])
? _this.hcCache[eventOrPath]
: (_this.hcCache[eventOrPath] = function (event) {
return executeChange(event, eventOrPath);
});
}
}
function unregisterField(name) {
if (fields.current !== null) {
delete fields.current[name];
}
}
function handleBlur(eventOrString) {
if (isString(eventOrString)) {
return function (event) { return executeBlur(event, eventOrString); };
}
else {
executeBlur(eventOrString);
}
function executeBlur(e, path) {
if (e.persist) {
e.persist();
}
else {
executeChange(eventOrPath);
}
};
_this.setFieldValue = function (field, value, shouldValidate) {
if (shouldValidate === void 0) { shouldValidate = true; }
if (_this.didMount) {
_this.setState(function (prevState) { return (tslib_1.__assign({}, prevState, { values: setIn(prevState.values, field, value) })); }, function () {
if (_this.props.validateOnChange && shouldValidate) {
_this.runValidations(_this.state.values);
}
var _a = e.target, name = _a.name, id = _a.id, outerHTML = _a.outerHTML;
var field = path ? path : name ? name : id;
if (!field && "production" !== 'production') {
warnAboutMissingIdentifier({
htmlContent: outerHTML,
documentationAnchorLink: 'handleblur-e-any--void',
handlerName: 'handleBlur',
});
}
};
_this.handleSubmit = function (e) {
if (e && e.preventDefault) {
e.preventDefault();
}
_this.submitForm();
};
_this.submitForm = function () {
_this.setState(function (prevState) { return ({
touched: setNestedObjectValues(prevState.values, true),
isSubmitting: true,
submitCount: prevState.submitCount + 1,
}); });
return _this.runValidations().then(function (combinedErrors) {
var isValid = Object.keys(combinedErrors).length === 0;
if (isValid) {
_this.executeSubmit();
}
else if (_this.didMount) {
_this.setState({ isSubmitting: false });
}
dispatch({
type: 'SET_FIELD_TOUCHED',
payload: { field: field, value: true },
});
};
_this.executeSubmit = function () {
_this.props.onSubmit(_this.state.values, _this.getFormikActions());
};
_this.handleBlur = function (eventOrString) {
var executeBlur = function (e, path) {
if (e.persist) {
e.persist();
}
}
function handleChange(eventOrPath) {
if (isString(eventOrPath)) {
return function (event) { return executeChange(event, eventOrPath); };
}
else {
executeChange(eventOrPath);
}
function executeChange(eventOrTextValue, maybePath) {
var field = maybePath;
var val = eventOrTextValue;
var parsed;
if (!isString(eventOrTextValue)) {
if (eventOrTextValue.persist) {
eventOrTextValue.persist();
}
var _a = e.target, name = _a.name, id = _a.id, outerHTML = _a.outerHTML;
var field = path ? path : name ? name : id;
var _a = eventOrTextValue.target, type = _a.type, name_1 = _a.name, id = _a.id, value = _a.value, checked = _a.checked, outerHTML = _a.outerHTML;
field = maybePath ? maybePath : name_1 ? name_1 : id;
if (!field && "production" !== 'production') {
warnAboutMissingIdentifier({
htmlContent: outerHTML,
documentationAnchorLink: 'handleblur-e-any--void',
handlerName: 'handleBlur',
documentationAnchorLink: 'handlechange-e-reactchangeeventany--void',
handlerName: 'handleChange',
});
}
_this.setState(function (prevState) { return ({
touched: setIn(prevState.touched, field, true),
}); });
if (_this.props.validateOnBlur) {
_this.runValidations(_this.state.values);
}
};
if (isString(eventOrString)) {
return isFunction(_this.hbCache[eventOrString])
? _this.hbCache[eventOrString]
: (_this.hbCache[eventOrString] = function (event) {
return executeBlur(event, eventOrString);
});
val = /number|range/.test(type)
? ((parsed = parseFloat(value)), isNaN(parsed) ? '' : parsed)
: /checkbox/.test(type) ? checked : value;
}
if (field) {
dispatch({ type: 'SET_FIELD_VALUE', payload: { field: field, value: val } });
}
}
}
function handleReset() {
if (props.onReset) {
var maybePromisedOnReset = props.onReset(state.values, imperativeMethods);
if (isPromise(maybePromisedOnReset)) {
maybePromisedOnReset.then(resetForm);
}
else {
executeBlur(eventOrString);
resetForm();
}
};
_this.setFieldTouched = function (field, touched, shouldValidate) {
if (touched === void 0) { touched = true; }
if (shouldValidate === void 0) { shouldValidate = true; }
_this.setState(function (prevState) { return (tslib_1.__assign({}, prevState, { touched: setIn(prevState.touched, field, touched) })); }, function () {
if (_this.props.validateOnBlur && shouldValidate) {
_this.runValidations(_this.state.values);
}
});
};
_this.setFieldError = function (field, message) {
_this.setState(function (prevState) { return (tslib_1.__assign({}, prevState, { errors: setIn(prevState.errors, field, message) })); });
};
_this.resetForm = function (nextValues) {
var values = nextValues ? nextValues : _this.props.initialValues;
_this.initialValues = values;
_this.setState({
}
else {
resetForm();
}
}
function handleSubmit(e) {
if (e && e.preventDefault) {
e.preventDefault();
}
submitForm();
}
function executeSubmit() {
props.onSubmit(state.values, imperativeMethods);
}
function resetForm(nextValues) {
var values = nextValues
? nextValues
: initialValues.current !== null
? initialValues.current
: props.initialValues;
initialValues.current = values;
dispatch({
type: 'RESET_FORM',
payload: {
isSubmitting: false,

@@ -335,102 +308,99 @@ isValidating: false,

touched: {},
error: undefined,
status: undefined,
values: values,
submitCount: 0,
});
};
_this.handleReset = function () {
if (_this.props.onReset) {
var maybePromisedOnReset = _this.props.onReset(_this.state.values, _this.getFormikActions());
if (isPromise(maybePromisedOnReset)) {
maybePromisedOnReset.then(_this.resetForm);
}
else {
_this.resetForm();
}
},
});
}
function setTouched(touched) {
dispatch({ type: 'SET_TOUCHED', payload: touched });
}
function setErrors(errors) {
dispatch({ type: 'SET_ERRORS', payload: errors });
}
function setValues(values) {
dispatch({ type: 'SET_VALUES', payload: values });
}
function setFieldError(field, value) {
dispatch({
type: 'SET_FIELD_ERROR',
payload: { field: field, value: value },
});
}
function setFieldValue(field, value) {
dispatch({
type: 'SET_FIELD_VALUE',
payload: {
field: field,
value: value,
},
});
}
function setFieldTouched(field, touched) {
if (touched === void 0) { touched = true; }
dispatch({
type: 'SET_FIELD_TOUCHED',
payload: {
field: field,
value: touched,
},
});
}
function validateField(name) {
if (fields.current !== null &&
fields.current[name] &&
fields.current[name].validate &&
isFunction(fields.current[name].validate)) {
var value = getIn(state.values, name);
var maybePromise = fields.current[name].validate(value);
if (isPromise(maybePromise)) {
dispatch({ type: 'SET_ISVALIDATING', payload: true });
return maybePromise
.then(function (x) { return x; }, function (e) { return e; })
.then(function (error) {
dispatch({
type: 'SET_FIELD_ERROR',
payload: { field: name, value: error },
});
dispatch({ type: 'SET_ISVALIDATING', payload: false });
});
}
else {
_this.resetForm();
dispatch({
type: 'SET_FIELD_ERROR',
payload: {
field: name,
value: maybePromise,
},
});
return Promise.resolve(maybePromise);
}
};
_this.setFormikState = function (s, callback) {
return _this.setState(s, callback);
};
_this.getFormikActions = function () {
return {
resetForm: _this.resetForm,
submitForm: _this.submitForm,
validateForm: _this.runValidations,
validateField: _this.validateField,
setError: _this.setError,
setErrors: _this.setErrors,
setFieldError: _this.setFieldError,
setFieldTouched: _this.setFieldTouched,
setFieldValue: _this.setFieldValue,
setStatus: _this.setStatus,
setSubmitting: _this.setSubmitting,
setTouched: _this.setTouched,
setValues: _this.setValues,
setFormikState: _this.setFormikState,
};
};
_this.getFormikComputedProps = function () {
var isInitialValid = _this.props.isInitialValid;
var dirty = !isEqual(_this.initialValues, _this.state.values);
return {
dirty: dirty,
isValid: dirty
? _this.state.errors && Object.keys(_this.state.errors).length === 0
: isInitialValid !== false && isFunction(isInitialValid)
? isInitialValid(_this.props)
: isInitialValid,
initialValues: _this.initialValues,
};
};
_this.getFormikBag = function () {
return tslib_1.__assign({}, _this.state, _this.getFormikActions(), _this.getFormikComputedProps(), { registerField: _this.registerField, unregisterField: _this.unregisterField, handleBlur: _this.handleBlur, handleChange: _this.handleChange, handleReset: _this.handleReset, handleSubmit: _this.handleSubmit, validateOnChange: _this.props.validateOnChange, validateOnBlur: _this.props.validateOnBlur });
};
_this.getFormikContext = function () {
return tslib_1.__assign({}, _this.getFormikBag(), { validationSchema: _this.props.validationSchema, validate: _this.props.validate, initialValues: _this.initialValues });
};
_this.state = {
values: props.initialValues || {},
errors: {},
touched: {},
isSubmitting: false,
isValidating: false,
submitCount: 0,
};
_this.didMount = false;
_this.fields = {};
_this.initialValues = props.initialValues || {};
warning(!(props.component && props.render), 'You should not use <Formik component> and <Formik render> in the same <Formik> component; <Formik render> will be ignored');
warning(!(props.component && props.children && !isEmptyChildren(props.children)), 'You should not use <Formik component> and <Formik children> in the same <Formik> component; <Formik children> will be ignored');
warning(!(props.render && props.children && !isEmptyChildren(props.children)), 'You should not use <Formik render> and <Formik children> in the same <Formik> component; <Formik children> will be ignored');
return _this;
}
else {
return Promise.resolve();
}
}
Formik.prototype.componentDidMount = function () {
this.didMount = true;
};
Formik.prototype.componentWillUnmount = function () {
this.didMount = false;
};
Formik.prototype.componentDidUpdate = function (prevProps) {
if (this.props.enableReinitialize &&
!isEqual(prevProps.initialValues, this.props.initialValues)) {
this.initialValues = this.props.initialValues;
this.resetForm(this.props.initialValues);
function runSingleFieldLevelValidationAsPromise(name, value) {
return new Promise(function (resolve) {
if (fields.current !== null &&
fields.current[name] &&
fields.current[name].validate &&
isFunction(fields.current[name].validate)) {
resolve(fields.current[name].validate(value));
}
}).then(function (x) { return x; }, function (e) { return e; });
}
function runFieldLevelValidations(values) {
if (fields.current === null) {
return Promise.resolve({});
}
};
Formik.prototype.runFieldLevelValidations = function (values) {
var _this = this;
var fieldKeysWithValidation = Object.keys(this.fields).filter(function (f) {
return _this.fields &&
_this.fields[f] &&
_this.fields[f].props.validate &&
isFunction(_this.fields[f].props.validate);
var fieldKeysWithValidation = Object.keys(fields.current).filter(function (f) {
return fields.current !== null &&
fields.current[f] &&
fields.current[f].validate &&
isFunction(fields.current[f].validate);
});
var fieldValidations = fieldKeysWithValidation.length > 0
? fieldKeysWithValidation.map(function (f) {
return _this.runSingleFieldLevelValidation(f, getIn(values, f));
return runSingleFieldLevelValidationAsPromise(f, getIn(values, f));
})

@@ -449,7 +419,6 @@ : [Promise.resolve('DO_NOT_DELETE_YOU_WILL_BE_FIRED')];

});
};
Formik.prototype.runValidateHandler = function (values) {
var _this = this;
}
function runValidateHandler(values, field) {
return new Promise(function (resolve) {
var maybePromisedErrors = _this.props.validate(values);
var maybePromisedErrors = props.validate(values, field);
if (maybePromisedErrors === undefined) {

@@ -469,30 +438,131 @@ resolve({});

});
};
Formik.prototype.render = function () {
var _a = this.props, component = _a.component, render = _a.render, children = _a.children;
var props = this.getFormikBag();
var ctx = this.getFormikContext();
return (React.createElement(FormikProvider, { value: ctx }, component
? React.createElement(component, props)
: render
? render(props)
: children
? isFunction(children)
? children(props)
: !isEmptyChildren(children)
? React.Children.only(children)
: null
: null));
};
Formik.defaultProps = {
validateOnChange: true,
validateOnBlur: true,
isInitialValid: false,
enableReinitialize: false,
};
return Formik;
}(React.Component));
}
function runValidationSchema(values, field) {
return new Promise(function (resolve) {
var validationSchema = props.validationSchema;
var schema = isFunction(validationSchema)
? validationSchema(field)
: validationSchema;
var promise = field && schema.validateAt
? schema.validateAt(field, values)
: validateYupSchema(values, schema);
promise.then(function () {
resolve({});
}, function (err) {
resolve(yupToFormErrors(err));
});
});
}
function validateForm(values, field) {
if (values === void 0) { values = state.values; }
dispatch({ type: 'SET_ISVALIDATING', payload: true });
return Promise.all([
runFieldLevelValidations(values),
props.validationSchema ? runValidationSchema(values, field) : {},
props.validate ? runValidateHandler(values, field) : {},
]).then(function (_a) {
var fieldErrors = _a[0], schemaErrors = _a[1], handlerErrors = _a[2];
var combinedErrors = deepmerge.all([fieldErrors, schemaErrors, handlerErrors], { arrayMerge: arrayMerge });
if (didMount.current) {
dispatch({ type: 'SET_ISVALIDATING', payload: false });
dispatch({ type: 'SET_ERRORS', payload: combinedErrors });
}
return combinedErrors;
});
}
function setFormikState(stateOrCb) {
if (isFunction(stateOrCb)) {
dispatch({ type: 'SET_FORMIK_STATE', payload: stateOrCb(state) });
}
else {
dispatch({ type: 'SET_FORMIK_STATE', payload: stateOrCb });
}
}
function setStatus(status) {
dispatch({ type: 'SET_STATUS', payload: status });
}
function setSubmitting(isSubmitting) {
dispatch({ type: 'SET_ISSUBMITTING', payload: isSubmitting });
}
function submitForm() {
dispatch({ type: 'SUBMIT_ATTEMPT' });
return validateForm().then(function (combinedErrors) {
var isActuallyValid = Object.keys(combinedErrors).length === 0;
if (isActuallyValid) {
executeSubmit();
}
else if (didMount.current) {
dispatch({ type: 'SUBMIT_FAILURE' });
}
});
}
function getFieldProps(name, type) {
var field = {
name: name,
value: type && (type === 'radio' || type === 'checkbox')
? undefined
: getIn(state.values, name),
onChange: handleChange,
onBlur: handleBlur,
};
return [field, getFieldMeta(name)];
}
function getFieldMeta(name) {
return {
value: getIn(state.values, name),
error: getIn(state.errors, name),
touch: getIn(state.touched, name),
initialValue: getIn(initialValues.current, name),
};
}
var dirty = React.useMemo(function () { return !isEqual(initialValues.current, state.values); }, [initialValues.current, state.values]);
var isValid = React.useMemo(function () {
return dirty
? state.errors && Object.keys(state.errors).length === 0
: isInitialValid !== false && isFunction(isInitialValid)
? isInitialValid(props)
: isInitialValid;
}, [state.errors, dirty, isInitialValid]);
var ctx = tslib_1.__assign({}, state, { initialValues: initialValues.current || props.initialValues, handleBlur: handleBlur,
handleChange: handleChange,
handleReset: handleReset,
handleSubmit: handleSubmit,
resetForm: resetForm,
setErrors: setErrors,
setFormikState: setFormikState,
setFieldTouched: setFieldTouched,
setFieldValue: setFieldValue,
setFieldError: setFieldError,
setStatus: setStatus,
setSubmitting: setSubmitting,
setTouched: setTouched,
setValues: setValues,
submitForm: submitForm,
validateForm: validateForm,
validateField: validateField,
isValid: isValid,
dirty: dirty,
unregisterField: unregisterField,
registerField: registerField,
getFieldProps: getFieldProps });
return ctx;
}
function Formik(props) {
var formikbag = useFormik(props);
var component = props.component, children = props.children, render = props.render;
return (React.createElement(FormikProvider, { value: formikbag }, component
? React.createElement(component, formikbag)
: render
? render(formikbag)
: children
? isFunction(children)
? children(formikbag)
: !isEmptyChildren(children)
? React.Children.only(children)
: null
: null));
}
function warnAboutMissingIdentifier(_a) {
var htmlContent = _a.htmlContent, documentationAnchorLink = _a.documentationAnchorLink, handlerName = _a.handlerName;
console.error("Warning: Formik called `" + handlerName + "`, but you forgot to pass an `id` or `name` attribute to your input:\n\n " + htmlContent + "\n\n Formik cannot determine which value to update. For more info see https://github.com/jaredpalmer/formik#" + documentationAnchorLink + "\n ");
console.error("Warning: Formik called `" + handlerName + "`, but you forgot to pass an `id` or `name` attribute to your input:\n " + htmlContent + "\n Formik cannot determine which value to update. For more info see https://github.com/jaredpalmer/formik#" + documentationAnchorLink + "\n ");
}

@@ -547,59 +617,37 @@ function yupToFormErrors(yupError) {

var FieldInner = (function (_super) {
tslib_1.__extends(FieldInner, _super);
function FieldInner(props) {
var _this = _super.call(this, props) || this;
var render = props.render, children = props.children, component = props.component;
warning(!(component && render), 'You should not use <Field component> and <Field render> in the same <Field> component; <Field component> will be ignored');
warning(!(component && children && isFunction(children)), 'You should not use <Field component> and <Field children> as a function in the same <Field> component; <Field component> will be ignored.');
warning(!(render && children && !isEmptyChildren(children)), 'You should not use <Field render> and <Field children> in the same <Field> component; <Field children> will be ignored');
return _this;
function useField(name, type) {
var formik = useFormikContext();
return formik.getFieldProps(name, type);
}
function Field(_a) {
var validate = _a.validate, name = _a.name, render = _a.render, children = _a.children, _b = _a.component, component = _b === void 0 ? 'input' : _b, props = tslib_1.__rest(_a, ["validate", "name", "render", "children", "component"]);
var _c = useFormikContext(), _validate = _c.validate, _validationSchema = _c.validationSchema, formik = tslib_1.__rest(_c, ["validate", "validationSchema"]);
React.useEffect(function () {
formik.registerField(props.name, {
validate: props.validate,
});
return function () {
formik.unregisterField(props.name);
};
}, [props.name, props.validate]);
var field = formik.getFieldProps(name, props.type)[0];
var bag = { field: field, form: formik };
if (render) {
return render(bag);
}
FieldInner.prototype.componentDidMount = function () {
this.props.formik.registerField(this.props.name, this);
};
FieldInner.prototype.componentDidUpdate = function (prevProps) {
if (this.props.name !== prevProps.name) {
this.props.formik.unregisterField(prevProps.name);
this.props.formik.registerField(this.props.name, this);
}
if (this.props.validate !== prevProps.validate) {
this.props.formik.registerField(this.props.name, this);
}
};
FieldInner.prototype.componentWillUnmount = function () {
this.props.formik.unregisterField(this.props.name);
};
FieldInner.prototype.render = function () {
var _a = this.props, validate = _a.validate, name = _a.name, render = _a.render, children = _a.children, _b = _a.component, component = _b === void 0 ? 'input' : _b, formik = _a.formik, props = tslib_1.__rest(_a, ["validate", "name", "render", "children", "component", "formik"]);
var _validate = formik.validate, _validationSchema = formik.validationSchema, restOfFormik = tslib_1.__rest(formik, ["validate", "validationSchema"]);
var field = {
value: props.type === 'radio' || props.type === 'checkbox'
? props.value
: getIn(formik.values, name),
name: name,
onChange: formik.handleChange,
onBlur: formik.handleBlur,
};
var bag = { field: field, form: restOfFormik };
if (render) {
return render(bag);
}
if (isFunction(children)) {
return children(bag);
}
if (typeof component === 'string') {
var innerRef = props.innerRef, rest = tslib_1.__rest(props, ["innerRef"]);
return React.createElement(component, tslib_1.__assign({ ref: innerRef }, field, rest, { children: children }));
}
return React.createElement(component, tslib_1.__assign({}, bag, props, { children: children }));
};
return FieldInner;
}(React.Component));
var Field = connect(FieldInner);
if (isFunction(children)) {
return children(bag);
}
if (typeof component === 'string') {
var innerRef = props.innerRef, rest = tslib_1.__rest(props, ["innerRef"]);
return React.createElement(component, tslib_1.__assign({ ref: innerRef }, field, rest, { children: children }));
}
return React.createElement(component, tslib_1.__assign({}, bag, props, { children: children }));
}
var FastField = Field;
var Form = connect(function (_a) {
var _b = _a.formik, handleReset = _b.handleReset, handleSubmit = _b.handleSubmit, props = tslib_1.__rest(_a, ["formik"]);
return (React.createElement("form", tslib_1.__assign({ onReset: handleReset, onSubmit: handleSubmit }, props)));
});
function Form(props) {
var _a = useFormikContext(), handleReset = _a.handleReset, handleSubmit = _a.handleSubmit;
return React.createElement("form", tslib_1.__assign({ onSubmit: handleSubmit, onReset: handleReset }, props));
}
Form.displayName = 'Form';

@@ -654,2 +702,8 @@

function connect(Comp) {
var C = function (props) { return (React.createElement(FormikConsumer, null, function (formik) { return React.createElement(Comp, tslib_1.__assign({}, props, { formik: formik })); })); };
C.WrappedComponent = Comp;
return hoistNonReactStatics(C, Comp);
}
var move = function (array, from, to) {

@@ -684,3 +738,3 @@ var copy = (array || []).slice();

_this.updateArrayField = function (fn, alterTouched, alterErrors) {
var _a = _this.props, name = _a.name, validateOnChange = _a.validateOnChange, _b = _a.formik, setFormikState = _b.setFormikState, validateForm = _b.validateForm, values = _b.values, touched = _b.touched, errors = _b.errors;
var _a = _this.props, name = _a.name, _b = _a.formik, setFormikState = _b.setFormikState, values = _b.values, touched = _b.touched, errors = _b.errors;
setFormikState(function (prevState) { return (tslib_1.__assign({}, prevState, { values: setIn(prevState.values, name, fn(getIn(values, name))), errors: alterErrors

@@ -690,7 +744,3 @@ ? setIn(prevState.errors, name, fn(getIn(errors, name)))

? setIn(prevState.touched, name, fn(getIn(touched, name)))
: prevState.touched })); }, function () {
if (validateOnChange) {
validateForm();
}
});
: prevState.touched })); });
};

@@ -725,4 +775,5 @@ _this.push = function (value) {

var arr = array ? [value].concat(array) : [value];
if (length < 0)
if (length < 0) {
length = arr.length;
}
return arr;

@@ -802,73 +853,2 @@ }, true, true);

var FastFieldInner = (function (_super) {
tslib_1.__extends(FastFieldInner, _super);
function FastFieldInner(props) {
var _this = _super.call(this, props) || this;
var render = props.render, children = props.children, component = props.component;
warning(!(component && render), 'You should not use <FastField component> and <FastField render> in the same <FastField> component; <FastField component> will be ignored');
warning(!(component && children && isFunction(children)), 'You should not use <FastField component> and <FastField children> as a function in the same <FastField> component; <FastField component> will be ignored.');
warning(!(render && children && !isEmptyChildren(children)), 'You should not use <FastField render> and <FastField children> in the same <FastField> component; <FastField children> will be ignored');
return _this;
}
FastFieldInner.prototype.shouldComponentUpdate = function (props) {
if (this.props.shouldUpdate) {
return this.props.shouldUpdate(props, this.props);
}
else if (getIn(this.props.formik.values, this.props.name) !==
getIn(props.formik.values, this.props.name) ||
getIn(this.props.formik.errors, this.props.name) !==
getIn(props.formik.errors, this.props.name) ||
getIn(this.props.formik.touched, this.props.name) !==
getIn(props.formik.touched, this.props.name) ||
Object.keys(this.props).length !== Object.keys(props).length ||
this.props.formik.isSubmitting !== props.formik.isSubmitting) {
return true;
}
else {
return false;
}
};
FastFieldInner.prototype.componentDidMount = function () {
this.props.formik.registerField(this.props.name, this);
};
FastFieldInner.prototype.componentDidUpdate = function (prevProps) {
if (this.props.name !== prevProps.name) {
this.props.formik.unregisterField(prevProps.name);
this.props.formik.registerField(this.props.name, this);
}
if (this.props.validate !== prevProps.validate) {
this.props.formik.registerField(this.props.name, this);
}
};
FastFieldInner.prototype.componentWillUnmount = function () {
this.props.formik.unregisterField(this.props.name);
};
FastFieldInner.prototype.render = function () {
var _a = this.props, validate = _a.validate, name = _a.name, render = _a.render, children = _a.children, _b = _a.component, component = _b === void 0 ? 'input' : _b, formik = _a.formik, props = tslib_1.__rest(_a, ["validate", "name", "render", "children", "component", "formik"]);
var _validate = formik.validate, _validationSchema = formik.validationSchema, restOfFormik = tslib_1.__rest(formik, ["validate", "validationSchema"]);
var field = {
value: props.type === 'radio' || props.type === 'checkbox'
? props.value
: getIn(formik.values, name),
name: name,
onChange: formik.handleChange,
onBlur: formik.handleBlur,
};
var bag = { field: field, form: restOfFormik };
if (render) {
return render(bag);
}
if (isFunction(children)) {
return children(bag);
}
if (typeof component === 'string') {
var innerRef = props.innerRef, rest = tslib_1.__rest(props, ["innerRef"]);
return React.createElement(component, tslib_1.__assign({ ref: innerRef }, field, rest, { children: children }));
}
return React.createElement(component, tslib_1.__assign({}, bag, props, { children: children }));
};
return FastFieldInner;
}(React.Component));
var FastField = connect(FastFieldInner);
var ErrorMessageImpl = (function (_super) {

@@ -909,6 +889,9 @@ tslib_1.__extends(ErrorMessageImpl, _super);

exports.useFormik = useFormik;
exports.Formik = Formik;
exports.yupToFormErrors = yupToFormErrors;
exports.validateYupSchema = validateYupSchema;
exports.useField = useField;
exports.Field = Field;
exports.FastField = FastField;
exports.Form = Form;

@@ -928,11 +911,11 @@ exports.withFormik = withFormik;

exports.isString = isString;
exports.isNaN = isNaN;
exports.isNaN = isNaN$1;
exports.isEmptyChildren = isEmptyChildren;
exports.isPromise = isPromise;
exports.getActiveElement = getActiveElement;
exports.FastField = FastField;
exports.connect = connect;
exports.ErrorMessage = ErrorMessage;
exports.FormikProvider = FormikProvider;
exports.FormikConsumer = FormikConsumer;
exports.connect = connect;
exports.ErrorMessage = ErrorMessage;
exports.useFormikContext = useFormikContext;
//# sourceMappingURL=formik.cjs.production.js.map
import * as React from 'react';
import { FormikActions, FormikConfig, FormikErrors, FormikState, FormikTouched, FormikValues, FormikContext } from './types';
export declare class Formik<Values = object, ExtraProps = {}> extends React.Component<FormikConfig<Values> & ExtraProps, FormikState<Values>> {
static defaultProps: {
validateOnChange: boolean;
validateOnBlur: boolean;
isInitialValid: boolean;
enableReinitialize: boolean;
};
import { FormikConfig, FormikErrors, FormikState, FormikTouched, FormikValues } from './types';
export declare function useFormik<Values = object>({ validateOnChange, validateOnBlur, isInitialValid, ...rest }: FormikConfig<Values>): {
initialValues: Values;
didMount: boolean;
hcCache: {
[key: string]: (e: string | React.ChangeEvent<any>) => void;
};
hbCache: {
[key: string]: (e: any) => void;
};
fields: {
[field: string]: React.Component<any>;
};
constructor(props: FormikConfig<Values> & ExtraProps);
registerField: (name: string, Comp: React.Component<any, {}, any>) => void;
unregisterField: (name: string) => void;
componentDidMount(): void;
componentWillUnmount(): void;
componentDidUpdate(prevProps: Readonly<FormikConfig<Values> & ExtraProps>): void;
handleBlur: (eventOrString: any) => void | ((e: any) => void);
handleChange: (eventOrPath: string | React.ChangeEvent<any>) => void | ((eventOrTextValue: string | React.ChangeEvent<any>) => void);
handleReset: () => void;
handleSubmit: (e: React.FormEvent<HTMLFormElement> | undefined) => void;
resetForm: (nextValues?: Values | undefined) => void;
setErrors: (errors: FormikErrors<Values>) => void;
setFormikState: (stateOrCb: FormikState<Values> | ((state: FormikState<Values>) => FormikState<Values>)) => void;
setFieldTouched: (field: string, touched?: boolean) => void;
setFieldValue: (field: string, value: any) => void;
setFieldError: (field: string, value: string | undefined) => void;
setStatus: (status: any) => void;
setSubmitting: (isSubmitting: boolean) => void;
setTouched: (touched: FormikTouched<Values>) => void;
setValues: (values: Values) => void;
setStatus: (status?: any) => void;
setError: (error: any) => void;
setSubmitting: (isSubmitting: boolean) => void;
validateField: (field: string) => void;
runSingleFieldLevelValidation: (field: string, value: string | void) => Promise<string>;
runFieldLevelValidations(values: FormikValues): Promise<FormikErrors<Values>>;
runValidateHandler(values: FormikValues): Promise<FormikErrors<Values>>;
runValidationSchema: (values: FormikValues) => Promise<{}>;
runValidations: (values?: FormikValues) => Promise<FormikErrors<Values>>;
handleChange: (eventOrPath: string | React.ChangeEvent<any>) => void | ((eventOrTextValue: string | React.ChangeEvent<any>) => void);
setFieldValue: (field: string, value: any, shouldValidate?: boolean) => void;
handleSubmit: (e: React.FormEvent<HTMLFormElement> | undefined) => void;
submitForm: () => Promise<void>;
executeSubmit: () => void;
handleBlur: (eventOrString: any) => void | ((e: any) => void);
setFieldTouched: (field: string, touched?: boolean, shouldValidate?: boolean) => void;
setFieldError: (field: string, message: string | undefined) => void;
resetForm: (nextValues?: Values | undefined) => void;
handleReset: () => void;
setFormikState: (s: any, callback?: (() => void) | undefined) => void;
getFormikActions: () => FormikActions<Values>;
getFormikComputedProps: () => {
dirty: boolean;
isValid: boolean;
initialValues: Values;
};
getFormikBag: () => {
registerField: (name: string, Comp: React.Component<any, {}, any>) => void;
unregisterField: (name: string) => void;
handleBlur: (eventOrString: any) => void | ((e: any) => void);
handleChange: (eventOrPath: string | React.ChangeEvent<any>) => void | ((eventOrTextValue: string | React.ChangeEvent<any>) => void);
handleReset: () => void;
handleSubmit: (e: React.FormEvent<HTMLFormElement> | undefined) => void;
validateOnChange: (FormikConfig<Values> & ExtraProps)["validateOnChange"] | undefined;
validateOnBlur: (FormikConfig<Values> & ExtraProps)["validateOnBlur"] | undefined;
dirty: boolean;
isValid: boolean;
initialValues: Values;
setStatus(status?: any): void;
setError(e: any): void;
setErrors(errors: FormikErrors<Values>): void;
setSubmitting(isSubmitting: boolean): void;
setTouched(touched: FormikTouched<Values>): void;
setValues(values: Values): void;
setFieldValue(field: keyof Values & string, value: any, shouldValidate?: boolean | undefined): void;
setFieldValue(field: string, value: any): void;
setFieldError(field: keyof Values & string, message: string): void;
setFieldError(field: string, message: string): void;
setFieldTouched(field: keyof Values & string, isTouched?: boolean | undefined, shouldValidate?: boolean | undefined): void;
setFieldTouched(field: string, isTouched?: boolean | undefined): void;
validateForm(values?: any): Promise<FormikErrors<Values>>;
validateField(field: string): void;
resetForm(nextValues?: any): void;
submitForm(): void;
setFormikState<K extends "error" | "values" | "errors" | "touched" | "isValidating" | "isSubmitting" | "status" | "submitCount">(f: (prevState: Readonly<FormikState<Values>>, props: any) => Pick<FormikState<Values>, K>, callback?: (() => any) | undefined): void;
setFormikState<K extends "error" | "values" | "errors" | "touched" | "isValidating" | "isSubmitting" | "status" | "submitCount">(state: Pick<FormikState<Values>, K>, callback?: (() => any) | undefined): void;
values: Values;
error?: any;
errors: FormikErrors<Values>;
touched: FormikTouched<Values>;
isValidating: boolean;
isSubmitting: boolean;
status?: any;
submitCount: number;
};
getFormikContext: () => FormikContext<any>;
render(): JSX.Element;
}
validateForm: (values?: Values, field?: string | undefined) => Promise<FormikErrors<Values>>;
validateField: (name: string) => Promise<void> | Promise<string | undefined>;
isValid: boolean;
dirty: boolean;
unregisterField: (name: string) => void;
registerField: (name: string, { validate }: any) => void;
getFieldProps: (name: string, type: string) => [{
value: any;
name: string;
onChange: (e: React.ChangeEvent<any>) => void;
onBlur: (e: any) => void;
}, {
value: any;
error?: string | undefined;
touch: boolean;
initialValue?: any;
}];
values: Values;
error?: any;
errors: FormikErrors<Values>;
touched: FormikTouched<Values>;
isValidating: boolean;
isSubmitting: boolean;
status?: any;
submitCount: number;
};
export declare function Formik<Values = object, ExtraProps = {}>(props: FormikConfig<Values> & ExtraProps): JSX.Element;
export declare function yupToFormErrors<Values>(yupError: any): FormikErrors<Values>;
export declare function validateYupSchema<T extends FormikValues>(values: T, schema: any, sync?: boolean, context?: any): Promise<Partial<T>>;

@@ -1,29 +0,10 @@

import { __extends, __assign, __rest } from 'tslib';
import { createElement, Children, Component } from 'react';
import hoistNonReactStatics from 'hoist-non-react-statics';
import createContext from 'create-react-context';
import { __rest, __assign, __extends } from 'tslib';
import cloneDeep from 'lodash.clonedeep';
import toPath from 'lodash.topath';
import { useEffect, createElement, Component, Children, createContext, useContext, useRef, useReducer, useMemo } from 'react';
import isEqual from 'react-fast-compare';
import deepmerge from 'deepmerge';
import warning from 'warning';
import deepmerge from 'deepmerge';
import hoistNonReactStatics from 'hoist-non-react-statics';
var _a;
var FormikProvider = (_a =
/*#__PURE__*/
createContext({}), _a.Provider),
FormikConsumer = _a.Consumer;
function connect(Comp) {
var C = function (props) {
return createElement(FormikConsumer, null, function (formik) {
return createElement(Comp, __assign({}, props, {
formik: formik
}));
});
};
C.WrappedComponent = Comp;
return hoistNonReactStatics(C, Comp);
}
function getIn(obj, key, def, p) {

@@ -118,3 +99,3 @@ if (p === void 0) {

};
var isNaN = function (obj) {
var isNaN$1 = function (obj) {
return obj !== obj;

@@ -142,260 +123,226 @@ };

var Formik =
var PrivateFormikContext =
/*#__PURE__*/
function (_super) {
__extends(Formik, _super);
createContext({});
var FormikProvider = PrivateFormikContext.Provider;
var FormikConsumer = PrivateFormikContext.Consumer;
function useFormikContext() {
return useContext(PrivateFormikContext);
}
function Formik(props) {
var _this = _super.call(this, props) || this;
_this.hcCache = {};
_this.hbCache = {};
_this.registerField = function (name, Comp) {
_this.fields[name] = Comp;
};
_this.unregisterField = function (name) {
delete _this.fields[name];
};
_this.setErrors = function (errors) {
_this.setState({
errors: errors
function formikReducer(state, msg) {
switch (msg.type) {
case 'SET_VALUES':
return __assign({}, state, {
values: msg.payload
});
};
_this.setTouched = function (touched) {
_this.setState({
touched: touched
}, function () {
if (_this.props.validateOnBlur) {
_this.runValidations(_this.state.values);
}
case 'SET_TOUCHED':
return __assign({}, state, {
touched: msg.payload
});
};
_this.setValues = function (values) {
_this.setState({
values: values
}, function () {
if (_this.props.validateOnChange) {
_this.runValidations(values);
}
case 'SET_ERRORS':
return __assign({}, state, {
errors: msg.payload
});
};
_this.setStatus = function (status) {
_this.setState({
status: status
case 'SET_STATUS':
return __assign({}, state, {
status: msg.payload
});
};
_this.setError = function (error) {
if (process.env.NODE_ENV !== 'production') {
console.warn("Warning: Formik's setError(error) is deprecated and may be removed in future releases. Please use Formik's setStatus(status) instead. It works identically. For more info see https://github.com/jaredpalmer/formik#setstatus-status-any--void");
}
_this.setState({
error: error
case 'SET_ISVALIDATING':
return __assign({}, state, {
isValidating: msg.payload
});
};
_this.setSubmitting = function (isSubmitting) {
if (_this.didMount) {
_this.setState({
isSubmitting: isSubmitting
});
}
};
_this.validateField = function (field) {
_this.setState({
isValidating: true
case 'SET_ISSUBMITTING':
return __assign({}, state, {
isSubmitting: msg.payload
});
_this.runSingleFieldLevelValidation(field, getIn(_this.state.values, field)).then(function (error) {
if (_this.didMount) {
_this.setState({
errors: setIn(_this.state.errors, field, error),
isValidating: false
});
}
case 'SET_FIELD_VALUE':
return __assign({}, state, {
values: setIn(state.values, msg.payload.field, msg.payload.value)
});
};
_this.runSingleFieldLevelValidation = function (field, value) {
return new Promise(function (resolve) {
return resolve(_this.fields[field].props.validate(value));
}).then(function (x) {
return x;
}, function (e) {
return e;
case 'SET_FIELD_TOUCHED':
return __assign({}, state, {
touched: setIn(state.touched, msg.payload.field, msg.payload.value)
});
};
_this.runValidationSchema = function (values) {
return new Promise(function (resolve) {
var validationSchema = _this.props.validationSchema;
var schema = isFunction(validationSchema) ? validationSchema() : validationSchema;
validateYupSchema(values, schema).then(function () {
resolve({});
}, function (err) {
resolve(yupToFormErrors(err));
});
case 'SET_FIELD_ERROR':
return __assign({}, state, {
errors: setIn(state.errors, msg.payload.field, msg.payload.value)
});
};
_this.runValidations = function (values) {
if (values === void 0) {
values = _this.state.values;
}
case 'RESET_FORM':
case 'SET_FORMIK_STATE':
return __assign({}, state, msg.payload);
_this.setState({
isValidating: true
case 'SUBMIT_ATTEMPT':
return __assign({}, state, {
touched: setNestedObjectValues(state.values, true),
isSubmitting: true,
isValidating: true,
submitCount: state.submitCount + 1
});
return Promise.all([_this.runFieldLevelValidations(values), _this.props.validationSchema ? _this.runValidationSchema(values) : {}, _this.props.validate ? _this.runValidateHandler(values) : {}]).then(function (_a) {
var fieldErrors = _a[0],
schemaErrors = _a[1],
handlerErrors = _a[2];
var combinedErrors = deepmerge.all([fieldErrors, schemaErrors, handlerErrors], {
arrayMerge: arrayMerge
});
case 'SUBMIT_FAILURE':
return __assign({}, state, {
isSubmitting: false
});
if (_this.didMount) {
_this.setState({
isValidating: false,
errors: combinedErrors
});
}
default:
return state;
}
}
return combinedErrors;
});
};
function useFormik(_a) {
var _b = _a.validateOnChange,
validateOnChange = _b === void 0 ? true : _b,
_c = _a.validateOnBlur,
validateOnBlur = _c === void 0 ? true : _c,
_d = _a.isInitialValid,
isInitialValid = _d === void 0 ? false : _d,
rest = __rest(_a, ["validateOnChange", "validateOnBlur", "isInitialValid"]);
_this.handleChange = function (eventOrPath) {
var executeChange = function (eventOrTextValue, maybePath) {
var field = maybePath;
var val = eventOrTextValue;
var parsed;
var props = __assign({
validateOnChange: validateOnChange,
validateOnBlur: validateOnBlur,
isInitialValid: isInitialValid
}, rest);
if (!isString(eventOrTextValue)) {
if (eventOrTextValue.persist) {
eventOrTextValue.persist();
}
var initialValues = useRef(props.initialValues);
var didMount = useRef(false);
var fields = useRef({});
useEffect(function () {
initialValues.current = props.initialValues;
}, [props.initialValues]);
var _a = eventOrTextValue.target,
type = _a.type,
name_1 = _a.name,
id = _a.id,
value = _a.value,
checked = _a.checked,
outerHTML = _a.outerHTML;
field = maybePath ? maybePath : name_1 ? name_1 : id;
var _e = useReducer(formikReducer, {
values: props.initialValues,
errors: {},
touched: {},
isSubmitting: false,
isValidating: false,
submitCount: 0
}),
state = _e[0],
dispatch = _e[1];
if (!field && process.env.NODE_ENV !== 'production') {
warnAboutMissingIdentifier({
htmlContent: outerHTML,
documentationAnchorLink: 'handlechange-e-reactchangeeventany--void',
handlerName: 'handleChange'
});
}
useEffect(function () {
if (!!didMount.current && !!validateOnChange && !state.isSubmitting) {
validateForm(state.values);
}
}, [state.values, validateOnChange, state.isSubmitting]);
useEffect(function () {
if (!!didMount.current && !!validateOnBlur && !state.isSubmitting) {
validateForm(state.values);
}
}, [state.touched, validateOnBlur, state.isSubmitting]);
useEffect(function () {
didMount.current = true;
return function unMount() {
didMount.current = false;
};
}, []);
var imperativeMethods = {
resetForm: resetForm,
submitForm: submitForm,
validateForm: validateForm,
validateField: validateField,
setErrors: setErrors,
setFieldError: setFieldError,
setFieldTouched: setFieldTouched,
setFieldValue: setFieldValue,
setStatus: setStatus,
setSubmitting: setSubmitting,
setTouched: setTouched,
setValues: setValues,
setFormikState: setFormikState
};
val = /number|range/.test(type) ? (parsed = parseFloat(value), isNaN(parsed) ? '' : parsed) : /checkbox/.test(type) ? checked : value;
}
function registerField(name, _a) {
var validate = _a.validate;
if (field) {
_this.setState(function (prevState) {
return __assign({}, prevState, {
values: setIn(prevState.values, field, val)
});
}, function () {
if (_this.props.validateOnChange) {
_this.runValidations(setIn(_this.state.values, field, val));
}
});
}
if (fields.current !== null) {
fields.current[name] = {
validate: validate
};
}
}
if (isString(eventOrPath)) {
return isFunction(_this.hcCache[eventOrPath]) ? _this.hcCache[eventOrPath] : _this.hcCache[eventOrPath] = function (event) {
return executeChange(event, eventOrPath);
};
} else {
executeChange(eventOrPath);
}
};
function unregisterField(name) {
if (fields.current !== null) {
delete fields.current[name];
}
}
_this.setFieldValue = function (field, value, shouldValidate) {
if (shouldValidate === void 0) {
shouldValidate = true;
function handleBlur(eventOrString) {
if (isString(eventOrString)) {
return function (event) {
return executeBlur(event, eventOrString);
};
} else {
executeBlur(eventOrString);
}
function executeBlur(e, path) {
if (e.persist) {
e.persist();
}
if (_this.didMount) {
_this.setState(function (prevState) {
return __assign({}, prevState, {
values: setIn(prevState.values, field, value)
});
}, function () {
if (_this.props.validateOnChange && shouldValidate) {
_this.runValidations(_this.state.values);
}
var _a = e.target,
name = _a.name,
id = _a.id,
outerHTML = _a.outerHTML;
var field = path ? path : name ? name : id;
if (!field && process.env.NODE_ENV !== 'production') {
warnAboutMissingIdentifier({
htmlContent: outerHTML,
documentationAnchorLink: 'handleblur-e-any--void',
handlerName: 'handleBlur'
});
}
};
_this.handleSubmit = function (e) {
if (e && e.preventDefault) {
e.preventDefault();
}
if (process.env.NODE_ENV !== 'production' && typeof document !== 'undefined') {
var activeElement = getActiveElement();
if (activeElement !== null && activeElement instanceof HTMLButtonElement) {
warning(!!(activeElement.attributes && activeElement.attributes.getNamedItem('type')), 'You submitted a Formik form using a button with an unspecified `type` attribute. Most browsers default button elements to `type="submit"`. If this is not a submit button, please add `type="button"`.');
dispatch({
type: 'SET_FIELD_TOUCHED',
payload: {
field: field,
value: true
}
}
_this.submitForm();
};
_this.submitForm = function () {
_this.setState(function (prevState) {
return {
touched: setNestedObjectValues(prevState.values, true),
isSubmitting: true,
submitCount: prevState.submitCount + 1
};
});
}
}
return _this.runValidations().then(function (combinedErrors) {
var isValid = Object.keys(combinedErrors).length === 0;
function handleChange(eventOrPath) {
if (isString(eventOrPath)) {
return function (event) {
return executeChange(event, eventOrPath);
};
} else {
executeChange(eventOrPath);
}
if (isValid) {
_this.executeSubmit();
} else if (_this.didMount) {
_this.setState({
isSubmitting: false
});
}
});
};
function executeChange(eventOrTextValue, maybePath) {
var field = maybePath;
var val = eventOrTextValue;
var parsed;
_this.executeSubmit = function () {
_this.props.onSubmit(_this.state.values, _this.getFormikActions());
};
_this.handleBlur = function (eventOrString) {
var executeBlur = function (e, path) {
if (e.persist) {
e.persist();
if (!isString(eventOrTextValue)) {
if (eventOrTextValue.persist) {
eventOrTextValue.persist();
}
var _a = e.target,
name = _a.name,
var _a = eventOrTextValue.target,
type = _a.type,
name_1 = _a.name,
id = _a.id,
value = _a.value,
checked = _a.checked,
outerHTML = _a.outerHTML;
var field = path ? path : name ? name : id;
field = maybePath ? maybePath : name_1 ? name_1 : id;

@@ -405,60 +352,62 @@ if (!field && process.env.NODE_ENV !== 'production') {

htmlContent: outerHTML,
documentationAnchorLink: 'handleblur-e-any--void',
handlerName: 'handleBlur'
documentationAnchorLink: 'handlechange-e-reactchangeeventany--void',
handlerName: 'handleChange'
});
}
_this.setState(function (prevState) {
return {
touched: setIn(prevState.touched, field, true)
};
val = /number|range/.test(type) ? (parsed = parseFloat(value), isNaN(parsed) ? '' : parsed) : /checkbox/.test(type) ? checked : value;
}
if (field) {
dispatch({
type: 'SET_FIELD_VALUE',
payload: {
field: field,
value: val
}
});
}
}
}
if (_this.props.validateOnBlur) {
_this.runValidations(_this.state.values);
}
};
function handleReset() {
if (props.onReset) {
var maybePromisedOnReset = props.onReset(state.values, imperativeMethods);
if (isString(eventOrString)) {
return isFunction(_this.hbCache[eventOrString]) ? _this.hbCache[eventOrString] : _this.hbCache[eventOrString] = function (event) {
return executeBlur(event, eventOrString);
};
if (isPromise(maybePromisedOnReset)) {
maybePromisedOnReset.then(resetForm);
} else {
executeBlur(eventOrString);
resetForm();
}
};
} else {
resetForm();
}
}
_this.setFieldTouched = function (field, touched, shouldValidate) {
if (touched === void 0) {
touched = true;
}
function handleSubmit(e) {
if (e && e.preventDefault) {
e.preventDefault();
}
if (shouldValidate === void 0) {
shouldValidate = true;
if (process.env.NODE_ENV !== 'production' && typeof document !== 'undefined') {
var activeElement = getActiveElement();
if (activeElement !== null && activeElement instanceof HTMLButtonElement) {
warning(!!(activeElement.attributes && activeElement.attributes.getNamedItem('type')), 'You submitted a Formik form using a button with an unspecified `type` attribute. Most browsers default button elements to `type="submit"`. If this is not a submit button, please add `type="button"`.');
}
}
_this.setState(function (prevState) {
return __assign({}, prevState, {
touched: setIn(prevState.touched, field, touched)
});
}, function () {
if (_this.props.validateOnBlur && shouldValidate) {
_this.runValidations(_this.state.values);
}
});
};
submitForm();
}
_this.setFieldError = function (field, message) {
_this.setState(function (prevState) {
return __assign({}, prevState, {
errors: setIn(prevState.errors, field, message)
});
});
};
function executeSubmit() {
props.onSubmit(state.values, imperativeMethods);
}
_this.resetForm = function (nextValues) {
var values = nextValues ? nextValues : _this.props.initialValues;
_this.initialValues = values;
_this.setState({
function resetForm(nextValues) {
var values = nextValues ? nextValues : initialValues.current !== null ? initialValues.current : props.initialValues;
initialValues.current = values;
dispatch({
type: 'RESET_FORM',
payload: {
isSubmitting: false,

@@ -468,117 +417,128 @@ isValidating: false,

touched: {},
error: undefined,
status: undefined,
values: values,
submitCount: 0
});
};
}
});
}
_this.handleReset = function () {
if (_this.props.onReset) {
var maybePromisedOnReset = _this.props.onReset(_this.state.values, _this.getFormikActions());
function setTouched(touched) {
dispatch({
type: 'SET_TOUCHED',
payload: touched
});
}
if (isPromise(maybePromisedOnReset)) {
maybePromisedOnReset.then(_this.resetForm);
} else {
_this.resetForm();
}
} else {
_this.resetForm();
function setErrors(errors) {
dispatch({
type: 'SET_ERRORS',
payload: errors
});
}
function setValues(values) {
dispatch({
type: 'SET_VALUES',
payload: values
});
}
function setFieldError(field, value) {
dispatch({
type: 'SET_FIELD_ERROR',
payload: {
field: field,
value: value
}
};
});
}
_this.setFormikState = function (s, callback) {
return _this.setState(s, callback);
};
function setFieldValue(field, value) {
dispatch({
type: 'SET_FIELD_VALUE',
payload: {
field: field,
value: value
}
});
}
_this.getFormikActions = function () {
return {
resetForm: _this.resetForm,
submitForm: _this.submitForm,
validateForm: _this.runValidations,
validateField: _this.validateField,
setError: _this.setError,
setErrors: _this.setErrors,
setFieldError: _this.setFieldError,
setFieldTouched: _this.setFieldTouched,
setFieldValue: _this.setFieldValue,
setStatus: _this.setStatus,
setSubmitting: _this.setSubmitting,
setTouched: _this.setTouched,
setValues: _this.setValues,
setFormikState: _this.setFormikState
};
};
function setFieldTouched(field, touched) {
if (touched === void 0) {
touched = true;
}
_this.getFormikComputedProps = function () {
var isInitialValid = _this.props.isInitialValid;
var dirty = !isEqual(_this.initialValues, _this.state.values);
return {
dirty: dirty,
isValid: dirty ? _this.state.errors && Object.keys(_this.state.errors).length === 0 : isInitialValid !== false && isFunction(isInitialValid) ? isInitialValid(_this.props) : isInitialValid,
initialValues: _this.initialValues
};
};
dispatch({
type: 'SET_FIELD_TOUCHED',
payload: {
field: field,
value: touched
}
});
}
_this.getFormikBag = function () {
return __assign({}, _this.state, _this.getFormikActions(), _this.getFormikComputedProps(), {
registerField: _this.registerField,
unregisterField: _this.unregisterField,
handleBlur: _this.handleBlur,
handleChange: _this.handleChange,
handleReset: _this.handleReset,
handleSubmit: _this.handleSubmit,
validateOnChange: _this.props.validateOnChange,
validateOnBlur: _this.props.validateOnBlur
});
};
function validateField(name) {
if (fields.current !== null && fields.current[name] && fields.current[name].validate && isFunction(fields.current[name].validate)) {
var value = getIn(state.values, name);
var maybePromise = fields.current[name].validate(value);
_this.getFormikContext = function () {
return __assign({}, _this.getFormikBag(), {
validationSchema: _this.props.validationSchema,
validate: _this.props.validate,
initialValues: _this.initialValues
});
};
if (isPromise(maybePromise)) {
dispatch({
type: 'SET_ISVALIDATING',
payload: true
});
return maybePromise.then(function (x) {
return x;
}, function (e) {
return e;
}).then(function (error) {
dispatch({
type: 'SET_FIELD_ERROR',
payload: {
field: name,
value: error
}
});
dispatch({
type: 'SET_ISVALIDATING',
payload: false
});
});
} else {
dispatch({
type: 'SET_FIELD_ERROR',
payload: {
field: name,
value: maybePromise
}
});
return Promise.resolve(maybePromise);
}
} else {
return Promise.resolve();
}
}
_this.state = {
values: props.initialValues || {},
errors: {},
touched: {},
isSubmitting: false,
isValidating: false,
submitCount: 0
};
_this.didMount = false;
_this.fields = {};
_this.initialValues = props.initialValues || {};
warning(!(props.component && props.render), 'You should not use <Formik component> and <Formik render> in the same <Formik> component; <Formik render> will be ignored');
warning(!(props.component && props.children && !isEmptyChildren(props.children)), 'You should not use <Formik component> and <Formik children> in the same <Formik> component; <Formik children> will be ignored');
warning(!(props.render && props.children && !isEmptyChildren(props.children)), 'You should not use <Formik render> and <Formik children> in the same <Formik> component; <Formik children> will be ignored');
return _this;
function runSingleFieldLevelValidationAsPromise(name, value) {
return new Promise(function (resolve) {
if (fields.current !== null && fields.current[name] && fields.current[name].validate && isFunction(fields.current[name].validate)) {
resolve(fields.current[name].validate(value));
}
}).then(function (x) {
return x;
}, function (e) {
return e;
});
}
Formik.prototype.componentDidMount = function () {
this.didMount = true;
};
Formik.prototype.componentWillUnmount = function () {
this.didMount = false;
};
Formik.prototype.componentDidUpdate = function (prevProps) {
if (this.props.enableReinitialize && !isEqual(prevProps.initialValues, this.props.initialValues)) {
this.initialValues = this.props.initialValues;
this.resetForm(this.props.initialValues);
function runFieldLevelValidations(values) {
if (fields.current === null) {
return Promise.resolve({});
}
};
Formik.prototype.runFieldLevelValidations = function (values) {
var _this = this;
var fieldKeysWithValidation = Object.keys(this.fields).filter(function (f) {
return _this.fields && _this.fields[f] && _this.fields[f].props.validate && isFunction(_this.fields[f].props.validate);
var fieldKeysWithValidation = Object.keys(fields.current).filter(function (f) {
return fields.current !== null && fields.current[f] && fields.current[f].validate && isFunction(fields.current[f].validate);
});
var fieldValidations = fieldKeysWithValidation.length > 0 ? fieldKeysWithValidation.map(function (f) {
return _this.runSingleFieldLevelValidation(f, getIn(values, f));
return runSingleFieldLevelValidationAsPromise(f, getIn(values, f));
}) : [Promise.resolve('DO_NOT_DELETE_YOU_WILL_BE_FIRED')];

@@ -598,9 +558,7 @@ return Promise.all(fieldValidations).then(function (fieldErrorsList) {

});
};
}
Formik.prototype.runValidateHandler = function (values) {
var _this = this;
function runValidateHandler(values, field) {
return new Promise(function (resolve) {
var maybePromisedErrors = _this.props.validate(values);
var maybePromisedErrors = props.validate(values, field);

@@ -619,25 +577,158 @@ if (maybePromisedErrors === undefined) {

});
};
}
Formik.prototype.render = function () {
var _a = this.props,
component = _a.component,
render = _a.render,
children = _a.children;
var props = this.getFormikBag();
var ctx = this.getFormikContext();
return createElement(FormikProvider, {
value: ctx
}, component ? createElement(component, props) : render ? render(props) : children ? isFunction(children) ? children(props) : !isEmptyChildren(children) ? Children.only(children) : null : null);
};
function runValidationSchema(values, field) {
return new Promise(function (resolve) {
var validationSchema = props.validationSchema;
var schema = isFunction(validationSchema) ? validationSchema(field) : validationSchema;
var promise = field && schema.validateAt ? schema.validateAt(field, values) : validateYupSchema(values, schema);
promise.then(function () {
resolve({});
}, function (err) {
resolve(yupToFormErrors(err));
});
});
}
Formik.defaultProps = {
validateOnChange: true,
validateOnBlur: true,
isInitialValid: false,
enableReinitialize: false
};
return Formik;
}(Component);
function validateForm(values, field) {
if (values === void 0) {
values = state.values;
}
dispatch({
type: 'SET_ISVALIDATING',
payload: true
});
return Promise.all([runFieldLevelValidations(values), props.validationSchema ? runValidationSchema(values, field) : {}, props.validate ? runValidateHandler(values, field) : {}]).then(function (_a) {
var fieldErrors = _a[0],
schemaErrors = _a[1],
handlerErrors = _a[2];
var combinedErrors = deepmerge.all([fieldErrors, schemaErrors, handlerErrors], {
arrayMerge: arrayMerge
});
if (didMount.current) {
dispatch({
type: 'SET_ISVALIDATING',
payload: false
});
dispatch({
type: 'SET_ERRORS',
payload: combinedErrors
});
}
return combinedErrors;
});
}
function setFormikState(stateOrCb) {
if (isFunction(stateOrCb)) {
dispatch({
type: 'SET_FORMIK_STATE',
payload: stateOrCb(state)
});
} else {
dispatch({
type: 'SET_FORMIK_STATE',
payload: stateOrCb
});
}
}
function setStatus(status) {
dispatch({
type: 'SET_STATUS',
payload: status
});
}
function setSubmitting(isSubmitting) {
dispatch({
type: 'SET_ISSUBMITTING',
payload: isSubmitting
});
}
function submitForm() {
dispatch({
type: 'SUBMIT_ATTEMPT'
});
return validateForm().then(function (combinedErrors) {
var isActuallyValid = Object.keys(combinedErrors).length === 0;
if (isActuallyValid) {
executeSubmit();
} else if (didMount.current) {
dispatch({
type: 'SUBMIT_FAILURE'
});
}
});
}
function getFieldProps(name, type) {
var field = {
name: name,
value: type && (type === 'radio' || type === 'checkbox') ? undefined : getIn(state.values, name),
onChange: handleChange,
onBlur: handleBlur
};
return [field, getFieldMeta(name)];
}
function getFieldMeta(name) {
return {
value: getIn(state.values, name),
error: getIn(state.errors, name),
touch: getIn(state.touched, name),
initialValue: getIn(initialValues.current, name)
};
}
var dirty = useMemo(function () {
return !isEqual(initialValues.current, state.values);
}, [initialValues.current, state.values]);
var isValid = useMemo(function () {
return dirty ? state.errors && Object.keys(state.errors).length === 0 : isInitialValid !== false && isFunction(isInitialValid) ? isInitialValid(props) : isInitialValid;
}, [state.errors, dirty, isInitialValid]);
var ctx = __assign({}, state, {
initialValues: initialValues.current || props.initialValues,
handleBlur: handleBlur,
handleChange: handleChange,
handleReset: handleReset,
handleSubmit: handleSubmit,
resetForm: resetForm,
setErrors: setErrors,
setFormikState: setFormikState,
setFieldTouched: setFieldTouched,
setFieldValue: setFieldValue,
setFieldError: setFieldError,
setStatus: setStatus,
setSubmitting: setSubmitting,
setTouched: setTouched,
setValues: setValues,
submitForm: submitForm,
validateForm: validateForm,
validateField: validateField,
isValid: isValid,
dirty: dirty,
unregisterField: unregisterField,
registerField: registerField,
getFieldProps: getFieldProps
});
return ctx;
}
function Formik(props) {
var formikbag = useFormik(props);
var component = props.component,
children = props.children,
render = props.render;
return createElement(FormikProvider, {
value: formikbag
}, component ? createElement(component, formikbag) : render ? render(formikbag) : children ? isFunction(children) ? children(formikbag) : !isEmptyChildren(children) ? Children.only(children) : null : null);
}
function warnAboutMissingIdentifier(_a) {

@@ -647,3 +738,3 @@ var htmlContent = _a.htmlContent,

handlerName = _a.handlerName;
console.error("Warning: Formik called `" + handlerName + "`, but you forgot to pass an `id` or `name` attribute to your input:\n\n " + htmlContent + "\n\n Formik cannot determine which value to update. For more info see https://github.com/jaredpalmer/formik#" + documentationAnchorLink + "\n ");
console.error("Warning: Formik called `" + handlerName + "`, but you forgot to pass an `id` or `name` attribute to your input:\n " + htmlContent + "\n Formik cannot determine which value to update. For more info see https://github.com/jaredpalmer/formik#" + documentationAnchorLink + "\n ");
}

@@ -708,108 +799,69 @@

var FieldInner =
/*#__PURE__*/
function (_super) {
__extends(FieldInner, _super);
function useField(name, type) {
var formik = useFormikContext();
return formik.getFieldProps(name, type);
}
function Field(_a) {
var validate = _a.validate,
name = _a.name,
render = _a.render,
children = _a.children,
_b = _a.component,
component = _b === void 0 ? 'input' : _b,
props = __rest(_a, ["validate", "name", "render", "children", "component"]);
function FieldInner(props) {
var _this = _super.call(this, props) || this;
var _c = useFormikContext(),
_validate = _c.validate,
_validationSchema = _c.validationSchema,
formik = __rest(_c, ["validate", "validationSchema"]);
var render = props.render,
children = props.children,
component = props.component;
warning(!(component && render), 'You should not use <Field component> and <Field render> in the same <Field> component; <Field component> will be ignored');
warning(!(component && children && isFunction(children)), 'You should not use <Field component> and <Field children> as a function in the same <Field> component; <Field component> will be ignored.');
warning(!(render && children && !isEmptyChildren(children)), 'You should not use <Field render> and <Field children> in the same <Field> component; <Field children> will be ignored');
return _this;
}
FieldInner.prototype.componentDidMount = function () {
this.props.formik.registerField(this.props.name, this);
useEffect(function () {
formik.registerField(props.name, {
validate: props.validate
});
return function () {
formik.unregisterField(props.name);
};
}, [props.name, props.validate]);
var field = formik.getFieldProps(name, props.type)[0];
var bag = {
field: field,
form: formik
};
FieldInner.prototype.componentDidUpdate = function (prevProps) {
if (this.props.name !== prevProps.name) {
this.props.formik.unregisterField(prevProps.name);
this.props.formik.registerField(this.props.name, this);
}
if (render) {
return render(bag);
}
if (this.props.validate !== prevProps.validate) {
this.props.formik.registerField(this.props.name, this);
}
};
if (isFunction(children)) {
return children(bag);
}
FieldInner.prototype.componentWillUnmount = function () {
this.props.formik.unregisterField(this.props.name);
};
if (typeof component === 'string') {
var innerRef = props.innerRef,
rest = __rest(props, ["innerRef"]);
FieldInner.prototype.render = function () {
var _a = this.props,
validate = _a.validate,
name = _a.name,
render = _a.render,
children = _a.children,
_b = _a.component,
component = _b === void 0 ? 'input' : _b,
formik = _a.formik,
props = __rest(_a, ["validate", "name", "render", "children", "component", "formik"]);
var _validate = formik.validate,
_validationSchema = formik.validationSchema,
restOfFormik = __rest(formik, ["validate", "validationSchema"]);
var field = {
value: props.type === 'radio' || props.type === 'checkbox' ? props.value : getIn(formik.values, name),
name: name,
onChange: formik.handleChange,
onBlur: formik.handleBlur
};
var bag = {
field: field,
form: restOfFormik
};
if (render) {
return render(bag);
}
if (isFunction(children)) {
return children(bag);
}
if (typeof component === 'string') {
var innerRef = props.innerRef,
rest = __rest(props, ["innerRef"]);
return createElement(component, __assign({
ref: innerRef
}, field, rest, {
children: children
}));
}
return createElement(component, __assign({}, bag, props, {
return createElement(component, __assign({
ref: innerRef
}, field, rest, {
children: children
}));
};
}
return FieldInner;
}(Component);
return createElement(component, __assign({}, bag, props, {
children: children
}));
}
var FastField = Field;
var Field =
/*#__PURE__*/
connect(FieldInner);
function Form(props) {
var _a = useFormikContext(),
handleReset = _a.handleReset,
handleSubmit = _a.handleSubmit;
var Form =
/*#__PURE__*/
connect(function (_a) {
var _b = _a.formik,
handleReset = _b.handleReset,
handleSubmit = _b.handleSubmit,
props = __rest(_a, ["formik"]);
return createElement("form", __assign({
onReset: handleReset,
onSubmit: handleSubmit
onSubmit: handleSubmit,
onReset: handleReset
}, props));
});
}
Form.displayName = 'Form';

@@ -884,2 +936,15 @@

function connect(Comp) {
var C = function (props) {
return createElement(FormikConsumer, null, function (formik) {
return createElement(Comp, __assign({}, props, {
formik: formik
}));
});
};
C.WrappedComponent = Comp;
return hoistNonReactStatics(C, Comp);
}
var move = function (array, from, to) {

@@ -921,6 +986,4 @@ var copy = (array || []).slice();

name = _a.name,
validateOnChange = _a.validateOnChange,
_b = _a.formik,
setFormikState = _b.setFormikState,
validateForm = _b.validateForm,
values = _b.values,

@@ -935,6 +998,2 @@ touched = _b.touched,

});
}, function () {
if (validateOnChange) {
validateForm();
}
});

@@ -1008,3 +1067,7 @@ };

var arr = array ? [value].concat(array) : [value];
if (length < 0) length = arr.length;
if (length < 0) {
length = arr.length;
}
return arr;

@@ -1119,105 +1182,2 @@ }, true, true);

var FastFieldInner =
/*#__PURE__*/
function (_super) {
__extends(FastFieldInner, _super);
function FastFieldInner(props) {
var _this = _super.call(this, props) || this;
var render = props.render,
children = props.children,
component = props.component;
warning(!(component && render), 'You should not use <FastField component> and <FastField render> in the same <FastField> component; <FastField component> will be ignored');
warning(!(component && children && isFunction(children)), 'You should not use <FastField component> and <FastField children> as a function in the same <FastField> component; <FastField component> will be ignored.');
warning(!(render && children && !isEmptyChildren(children)), 'You should not use <FastField render> and <FastField children> in the same <FastField> component; <FastField children> will be ignored');
return _this;
}
FastFieldInner.prototype.shouldComponentUpdate = function (props) {
if (this.props.shouldUpdate) {
return this.props.shouldUpdate(props, this.props);
} else if (getIn(this.props.formik.values, this.props.name) !== getIn(props.formik.values, this.props.name) || getIn(this.props.formik.errors, this.props.name) !== getIn(props.formik.errors, this.props.name) || getIn(this.props.formik.touched, this.props.name) !== getIn(props.formik.touched, this.props.name) || Object.keys(this.props).length !== Object.keys(props).length || this.props.formik.isSubmitting !== props.formik.isSubmitting) {
return true;
} else {
return false;
}
};
FastFieldInner.prototype.componentDidMount = function () {
this.props.formik.registerField(this.props.name, this);
};
FastFieldInner.prototype.componentDidUpdate = function (prevProps) {
if (this.props.name !== prevProps.name) {
this.props.formik.unregisterField(prevProps.name);
this.props.formik.registerField(this.props.name, this);
}
if (this.props.validate !== prevProps.validate) {
this.props.formik.registerField(this.props.name, this);
}
};
FastFieldInner.prototype.componentWillUnmount = function () {
this.props.formik.unregisterField(this.props.name);
};
FastFieldInner.prototype.render = function () {
var _a = this.props,
validate = _a.validate,
name = _a.name,
render = _a.render,
children = _a.children,
_b = _a.component,
component = _b === void 0 ? 'input' : _b,
formik = _a.formik,
props = __rest(_a, ["validate", "name", "render", "children", "component", "formik"]);
var _validate = formik.validate,
_validationSchema = formik.validationSchema,
restOfFormik = __rest(formik, ["validate", "validationSchema"]);
var field = {
value: props.type === 'radio' || props.type === 'checkbox' ? props.value : getIn(formik.values, name),
name: name,
onChange: formik.handleChange,
onBlur: formik.handleBlur
};
var bag = {
field: field,
form: restOfFormik
};
if (render) {
return render(bag);
}
if (isFunction(children)) {
return children(bag);
}
if (typeof component === 'string') {
var innerRef = props.innerRef,
rest = __rest(props, ["innerRef"]);
return createElement(component, __assign({
ref: innerRef
}, field, rest, {
children: children
}));
}
return createElement(component, __assign({}, bag, props, {
children: children
}));
};
return FastFieldInner;
}(Component);
var FastField =
/*#__PURE__*/
connect(FastFieldInner);
var ErrorMessageImpl =

@@ -1261,3 +1221,3 @@ /*#__PURE__*/

export { Formik, yupToFormErrors, validateYupSchema, Field, Form, withFormik, move, swap, insert, replace, FieldArray, getIn, setIn, setNestedObjectValues, isFunction, isObject, isInteger, isString, isNaN, isEmptyChildren, isPromise, getActiveElement, FastField, FormikProvider, FormikConsumer, connect, ErrorMessage };
export { useFormik, Formik, yupToFormErrors, validateYupSchema, useField, Field, FastField, Form, withFormik, move, swap, insert, replace, FieldArray, getIn, setIn, setNestedObjectValues, isFunction, isObject, isInteger, isString, isNaN$1 as isNaN, isEmptyChildren, isPromise, getActiveElement, connect, ErrorMessage, FormikProvider, FormikConsumer, useFormikContext };
//# sourceMappingURL=formik.esm.js.map

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t(e.Formik={},e.React)}(this,function(e,d){"use strict";var h="default"in d?d.default:d,n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function a(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var v=function(){return(v=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function y(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&(r[n[o]]=e[n[o]])}return r}var m=Array.isArray,g=Object.keys,b=Object.prototype.hasOwnProperty;var r=function(e,t){try{return function e(t,r){if(t===r)return!0;var n,o,i,a=m(t),u=m(r);if(a&&u){if((o=t.length)!=r.length)return!1;for(n=0;n<o;n++)if(!e(t[n],r[n]))return!1;return!0}if(a!=u)return!1;var s=t instanceof Date,c=r instanceof Date;if(s!=c)return!1;if(s&&c)return t.getTime()==r.getTime();var l=t instanceof RegExp,f=r instanceof RegExp;if(l!=f)return!1;if(l&&f)return t.toString()==r.toString();if(t instanceof Object&&r instanceof Object){var p=g(t);if((o=p.length)!==g(r).length)return!1;for(n=0;n<o;n++)if(!b.call(r,p[n]))return!1;for(n=0;n<o;n++)if(!("_owner"===(i=p[n])&&t.$$typeof&&t._store||e(t[i],r[i])))return!1;return!0}return!1}(e,t)}catch(e){if(e.message&&e.message.match(/stack|recursion/i))return console.warn("Warning: react-fast-compare does not handle circular references.",e.name,e.message),!1;throw e}},t=function(){};"production"!==process.env.NODE_ENV&&(t=function(e,t,r){var n=arguments.length;r=new Array(2<n?n-2:0);for(var o=2;o<n;o++)r[o-2]=arguments[o];if(void 0===t)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");if(t.length<10||/^[s\W]*$/.test(t))throw new Error("The warning format should be able to uniquely identify this warning. Please, use a more descriptive format than: "+t);if(!e){var i=0,a="Warning: "+t.replace(/%s/g,function(){return r[i++]});"undefined"!=typeof console&&console.error(a);try{throw new Error(a)}catch(e){}}});var u=t,s=function(e){return!(!(n=e)||"object"!=typeof n||(t=e,"[object RegExp]"===(r=Object.prototype.toString.call(t))||"[object Date]"===r||t.$$typeof===o));var t,r,n};var o="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function c(e,t){return!1!==t.clone&&t.isMergeableObject(e)?f(Array.isArray(e)?[]:{},e,t):e}function l(e,t,r){return e.concat(t).map(function(e){return c(e,r)})}function f(e,t,r){(r=r||{}).arrayMerge=r.arrayMerge||l,r.isMergeableObject=r.isMergeableObject||s;var n,o,i,a,u=Array.isArray(t);return u===Array.isArray(e)?u?r.arrayMerge(e,t,r):(o=t,a={},(i=r).isMergeableObject(n=e)&&Object.keys(n).forEach(function(e){a[e]=c(n[e],i)}),Object.keys(o).forEach(function(e){a[e]=i.isMergeableObject(o[e])&&n[e]?f(n[e],o[e],i):c(o[e],i)}),a):c(t,r)}f.all=function(e,r){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(e,t){return f(e,t,r)},{})};var p=f,_={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},O={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},j=Object.defineProperty,F=Object.getOwnPropertyNames,w=Object.getOwnPropertySymbols,S=Object.getOwnPropertyDescriptor,k=Object.getPrototypeOf,E=k&&k(Object);var P=function e(t,r,n){if("string"==typeof r)return t;if(E){var o=k(r);o&&o!==E&&e(t,o,n)}var i=F(r);w&&(i=i.concat(w(r)));for(var a=0;a<i.length;++a){var u=i[a];if(!(_[u]||O[u]||n&&n[u])){var s=S(r,u);try{j(t,u,s)}catch(e){}}}return t},Ke="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function i(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function x(e,t){return e(t={exports:{}},t.exports),t.exports}function A(e){return function(){return e}}var C=function(){};C.thatReturns=A,C.thatReturnsFalse=A(!1),C.thatReturnsTrue=A(!0),C.thatReturnsNull=A(null),C.thatReturnsThis=function(){return this},C.thatReturnsArgument=function(e){return e};var V=C,T=function(e){};"production"!==process.env.NODE_ENV&&(T=function(e){if(void 0===e)throw new Error("invariant requires an error message argument")});var R=function(e,t,r,n,o,i,a,u){if(T(t),!e){var s;if(void 0===t)s=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[r,n,o,i,a,u],l=0;(s=new Error(t.replace(/%s/g,function(){return c[l++]}))).name="Invariant Violation"}throw s.framesToPop=1,s}},N=V;if("production"!==process.env.NODE_ENV){N=function(e,t){if(void 0===t)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");if(0!==t.indexOf("Failed Composite propType: ")&&!e){for(var r=arguments.length,n=Array(2<r?r-2:0),o=2;o<r;o++)n[o-2]=arguments[o];(function(e){for(var t=arguments.length,r=Array(1<t?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];var o=0,i="Warning: "+e.replace(/%s/g,function(){return r[o++]});"undefined"!=typeof console&&console.error(i);try{throw new Error(i)}catch(e){}}).apply(void 0,[t].concat(n))}}}var M=N,I=Object.getOwnPropertySymbols,D=Object.prototype.hasOwnProperty,B=Object.prototype.propertyIsEnumerable;var U=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(e){n[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var r,n,o=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),i=1;i<arguments.length;i++){for(var a in r=Object(arguments[i]))D.call(r,a)&&(o[a]=r[a]);if(I){n=I(r);for(var u=0;u<n.length;u++)B.call(r,n[u])&&(o[n[u]]=r[n[u]])}}return o},$="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";if("production"!==process.env.NODE_ENV)var W=R,Y=M,L=$,q={};var z=function(e,t,r,n,o){if("production"!==process.env.NODE_ENV)for(var i in e)if(e.hasOwnProperty(i)){var a;try{W("function"==typeof e[i],"%s: %s type `%s` is invalid; it must be a function, usually from the `prop-types` package, but received `%s`.",n||"React class",r,i,typeof e[i]),a=e[i](t,i,n,r,null,L)}catch(e){a=e}if(Y(!a||a instanceof Error,"%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",n||"React class",r,i,typeof a),a instanceof Error&&!(a.message in q)){q[a.message]=!0;var u=o?o():"";Y(!1,"Failed %s type: %s%s",r,a.message,null!=u?u:"")}}},H=function(u,f){var i="function"==typeof Symbol&&Symbol.iterator,a="@@iterator";var p="<<anonymous>>",e={array:t("array"),bool:t("boolean"),func:t("function"),number:t("number"),object:t("object"),string:t("string"),symbol:t("symbol"),any:r(V.thatReturnsNull),arrayOf:function(c){return r(function(e,t,r,n,o){if("function"!=typeof c)return new d("Property `"+o+"` of component `"+r+"` has invalid PropType notation inside arrayOf.");var i=e[t];if(!Array.isArray(i)){var a=h(i);return new d("Invalid "+n+" `"+o+"` of type `"+a+"` supplied to `"+r+"`, expected an array.")}for(var u=0;u<i.length;u++){var s=c(i,u,r,n,o+"["+u+"]",$);if(s instanceof Error)return s}return null})},element:r(function(e,t,r,n,o){var i=e[t];if(u(i))return null;var a=h(i);return new d("Invalid "+n+" `"+o+"` of type `"+a+"` supplied to `"+r+"`, expected a single ReactElement.")}),instanceOf:function(s){return r(function(e,t,r,n,o){if(e[t]instanceof s)return null;var i=s.name||p,a=(u=e[t],u.constructor&&u.constructor.name?u.constructor.name:p);var u;return new d("Invalid "+n+" `"+o+"` of type `"+a+"` supplied to `"+r+"`, expected instance of `"+i+"`.")})},node:r(function(e,t,r,n,o){return s(e[t])?null:new d("Invalid "+n+" `"+o+"` supplied to `"+r+"`, expected a ReactNode.")}),objectOf:function(c){return r(function(e,t,r,n,o){if("function"!=typeof c)return new d("Property `"+o+"` of component `"+r+"` has invalid PropType notation inside objectOf.");var i=e[t],a=h(i);if("object"!==a)return new d("Invalid "+n+" `"+o+"` of type `"+a+"` supplied to `"+r+"`, expected an object.");for(var u in i)if(i.hasOwnProperty(u)){var s=c(i,u,r,n,o+"."+u,$);if(s instanceof Error)return s}return null})},oneOf:function(s){if(!Array.isArray(s))return"production"!==process.env.NODE_ENV&&M(!1,"Invalid argument supplied to oneOf, expected an instance of array."),V.thatReturnsNull;return r(function(e,t,r,n,o){for(var i=e[t],a=0;a<s.length;a++)if(c(i,s[a]))return null;var u=JSON.stringify(s);return new d("Invalid "+n+" `"+o+"` of value `"+i+"` supplied to `"+r+"`, expected one of "+u+".")})},oneOfType:function(u){if(!Array.isArray(u))return"production"!==process.env.NODE_ENV&&M(!1,"Invalid argument supplied to oneOfType, expected an instance of array."),V.thatReturnsNull;for(var e=0;e<u.length;e++){var t=u[e];if("function"!=typeof t)return M(!1,"Invalid argument supplied to oneOfType. Expected an array of check functions, but received %s at index %s.",n(t),e),V.thatReturnsNull}return r(function(e,t,r,n,o){for(var i=0;i<u.length;i++){var a=u[i];if(null==a(e,t,r,n,o,$))return null}return new d("Invalid "+n+" `"+o+"` supplied to `"+r+"`.")})},shape:function(l){return r(function(e,t,r,n,o){var i=e[t],a=h(i);if("object"!==a)return new d("Invalid "+n+" `"+o+"` of type `"+a+"` supplied to `"+r+"`, expected `object`.");for(var u in l){var s=l[u];if(s){var c=s(i,u,r,n,o+"."+u,$);if(c)return c}}return null})},exact:function(f){return r(function(e,t,r,n,o){var i=e[t],a=h(i);if("object"!==a)return new d("Invalid "+n+" `"+o+"` of type `"+a+"` supplied to `"+r+"`, expected `object`.");var u=U({},e[t],f);for(var s in u){var c=f[s];if(!c)return new d("Invalid "+n+" `"+o+"` key `"+s+"` supplied to `"+r+"`.\nBad object: "+JSON.stringify(e[t],null," ")+"\nValid keys: "+JSON.stringify(Object.keys(f),null," "));var l=c(i,s,r,n,o+"."+s,$);if(l)return l}return null})}};function c(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function d(e){this.message=e,this.stack=""}function r(s){if("production"!==process.env.NODE_ENV)var c={},l=0;function e(e,t,r,n,o,i,a){if(n=n||p,i=i||r,a!==$)if(f)R(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");else if("production"!==process.env.NODE_ENV&&"undefined"!=typeof console){var u=n+":"+r;!c[u]&&l<3&&(M(!1,"You are manually calling a React.PropTypes validation function for the `%s` prop on `%s`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details.",i,n),c[u]=!0,l++)}return null==t[r]?e?new d(null===t[r]?"The "+o+" `"+i+"` is marked as required in `"+n+"`, but its value is `null`.":"The "+o+" `"+i+"` is marked as required in `"+n+"`, but its value is `undefined`."):null:s(t,r,n,o,i)}var t=e.bind(null,!1);return t.isRequired=e.bind(null,!0),t}function t(u){return r(function(e,t,r,n,o,i){var a=e[t];return h(a)===u?null:new d("Invalid "+n+" `"+o+"` of type `"+l(a)+"` supplied to `"+r+"`, expected `"+u+"`.")})}function s(e){switch(typeof e){case"number":case"string":case"undefined":return!0;case"boolean":return!e;case"object":if(Array.isArray(e))return e.every(s);if(null===e||u(e))return!0;var t=function(e){var t=e&&(i&&e[i]||e[a]);if("function"==typeof t)return t}(e);if(!t)return!1;var r,n=t.call(e);if(t!==e.entries){for(;!(r=n.next()).done;)if(!s(r.value))return!1}else for(;!(r=n.next()).done;){var o=r.value;if(o&&!s(o[1]))return!1}return!0;default:return!1}}function h(e){var t,r=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":(t=e,"symbol"===r||"Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol?"symbol":r)}function l(e){if(null==e)return""+e;var t=h(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function n(e){var t=l(e);switch(t){case"array":case"object":return"an "+t;case"boolean":case"date":case"regexp":return"a "+t;default:return t}}return d.prototype=Error.prototype,e.checkPropTypes=z,e.PropTypes=e},J=x(function(e){if("production"!==process.env.NODE_ENV){var t="function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103;e.exports=H(function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},!0)}else e.exports=function(){function e(e,t,r,n,o,i){i!==$&&R(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function t(){return e}var r={array:e.isRequired=e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return r.checkPropTypes=V,r.PropTypes=r}()}),G="__global_unique_id__",K=function(){return Ke[G]=(Ke[G]||0)+1},Q=x(function(e,t){t.__esModule=!0;r(h);var u=r(J),s=r(K),c=r(M);function r(e){return e&&e.__esModule?e:{default:e}}function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function p(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var d=1073741823;t.default=function(e,a){var t,r,n="__create-react-context-"+(0,s.default)()+"__",o=function(u){function s(){var e,t,r,n;l(this,s);for(var o=arguments.length,i=Array(o),a=0;a<o;a++)i[a]=arguments[a];return(e=t=f(this,u.call.apply(u,[this].concat(i)))).emitter=(r=t.props.value,n=[],{on:function(e){n.push(e)},off:function(t){n=n.filter(function(e){return e!==t})},get:function(){return r},set:function(e,t){r=e,n.forEach(function(e){return e(r,t)})}}),f(t,e)}return p(s,u),s.prototype.getChildContext=function(){var e;return(e={})[n]=this.emitter,e},s.prototype.componentWillReceiveProps=function(e){if(this.props.value!==e.value){var t=this.props.value,r=e.value,n=void 0;((o=t)===(i=r)?0!==o||1/o==1/i:o!=o&&i!=i)?n=0:(n="function"==typeof a?a(t,r):d,"production"!==process.env.NODE_ENV&&(0,c.default)((n&d)===n,"calculateChangedBits: Expected the return value to be a 31-bit integer. Instead received: %s",n),0!=(n|=0)&&this.emitter.set(e.value,n))}var o,i},s.prototype.render=function(){return this.props.children},s}(h.Component);o.childContextTypes=((t={})[n]=u.default.object.isRequired,t);var i=function(i){function a(){var e,r;l(this,a);for(var t=arguments.length,n=Array(t),o=0;o<t;o++)n[o]=arguments[o];return(e=r=f(this,i.call.apply(i,[this].concat(n)))).state={value:r.getValue()},r.onUpdate=function(e,t){0!=((0|r.observedBits)&t)&&r.setState({value:r.getValue()})},f(r,e)}return p(a,i),a.prototype.componentWillReceiveProps=function(e){var t=e.observedBits;this.observedBits=null==t?d:t},a.prototype.componentDidMount=function(){this.context[n]&&this.context[n].on(this.onUpdate);var e=this.props.observedBits;this.observedBits=null==e?d:e},a.prototype.componentWillUnmount=function(){this.context[n]&&this.context[n].off(this.onUpdate)},a.prototype.getValue=function(){return this.context[n]?this.context[n].get():e},a.prototype.render=function(){return e=this.props.children,(Array.isArray(e)?e[0]:e)(this.state.value);var e},a}(h.Component);return i.contextTypes=((r={})[n]=u.default.object,r),{Provider:o,Consumer:i}},e.exports=t.default});i(Q);var X,Z=(X=i(x(function(e,t){t.__esModule=!0;var r=o(h),n=o(Q);function o(e){return e&&e.__esModule?e:{default:e}}t.default=r.default.createContext||n.default,e.exports=t.default}))({})).Provider,ee=X.Consumer;function te(r){var e=function(t){return d.createElement(ee,null,function(e){return d.createElement(r,v({},t,{formik:e}))})};return e.WrappedComponent=r,P(e,r)}var re=x(function(e,t){var n="__lodash_hash_undefined__",r=9007199254740991,j="[object Arguments]",F="[object Boolean]",w="[object Date]",S="[object Function]",k="[object GeneratorFunction]",E="[object Map]",P="[object Number]",x="[object Object]",o="[object Promise]",A="[object RegExp]",C="[object Set]",V="[object String]",T="[object Symbol]",i="[object WeakMap]",R="[object ArrayBuffer]",N="[object DataView]",M="[object Float32Array]",I="[object Float64Array]",D="[object Int8Array]",B="[object Int16Array]",U="[object Int32Array]",$="[object Uint8Array]",W="[object Uint8ClampedArray]",Y="[object Uint16Array]",L="[object Uint32Array]",q=/\w*$/,a=/^\[object .+?Constructor\]$/,u=/^(?:0|[1-9]\d*)$/,z={};z[j]=z["[object Array]"]=z[R]=z[N]=z[F]=z[w]=z[M]=z[I]=z[D]=z[B]=z[U]=z[E]=z[P]=z[x]=z[A]=z[C]=z[V]=z[T]=z[$]=z[W]=z[Y]=z[L]=!0,z["[object Error]"]=z[S]=z[i]=!1;var s="object"==typeof Ke&&Ke&&Ke.Object===Object&&Ke,c="object"==typeof self&&self&&self.Object===Object&&self,l=s||c||Function("return this")(),f=t&&!t.nodeType&&t,p=f&&e&&!e.nodeType&&e,d=p&&p.exports===f;function H(e,t){return e.set(t[0],t[1]),e}function J(e,t){return e.add(t),e}function G(e,t,r,n){var o=-1,i=e?e.length:0;for(n&&i&&(r=e[++o]);++o<i;)r=t(r,e[o],o,e);return r}function K(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}function Q(e){var r=-1,n=Array(e.size);return e.forEach(function(e,t){n[++r]=[t,e]}),n}function h(t,r){return function(e){return t(r(e))}}function X(e){var t=-1,r=Array(e.size);return e.forEach(function(e){r[++t]=e}),r}var v,y=Array.prototype,m=Function.prototype,g=Object.prototype,b=l["__core-js_shared__"],_=(v=/[^.]+$/.exec(b&&b.keys&&b.keys.IE_PROTO||""))?"Symbol(src)_1."+v:"",O=m.toString,Z=g.hasOwnProperty,ee=g.toString,te=RegExp("^"+O.call(Z).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),re=d?l.Buffer:void 0,ne=l.Symbol,oe=l.Uint8Array,ie=h(Object.getPrototypeOf,Object),ae=Object.create,ue=g.propertyIsEnumerable,se=y.splice,ce=Object.getOwnPropertySymbols,le=re?re.isBuffer:void 0,fe=h(Object.keys,Object),pe=Ie(l,"DataView"),de=Ie(l,"Map"),he=Ie(l,"Promise"),ve=Ie(l,"Set"),ye=Ie(l,"WeakMap"),me=Ie(Object,"create"),ge=We(pe),be=We(de),_e=We(he),Oe=We(ve),je=We(ye),Fe=ne?ne.prototype:void 0,we=Fe?Fe.valueOf:void 0;function Se(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function ke(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Ee(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Pe(e){this.__data__=new ke(e)}function xe(e,t){var r,n,o,i=Le(e)||(o=n=r=e)&&"object"==typeof o&&qe(n)&&Z.call(r,"callee")&&(!ue.call(r,"callee")||ee.call(r)==j)?function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}(e.length,String):[],a=i.length,u=!!a;for(var s in e)!t&&!Z.call(e,s)||u&&("length"==s||Ue(s,a))||i.push(s);return i}function Ae(e,t,r){var n=e[t];Z.call(e,t)&&Ye(n,r)&&(void 0!==r||t in e)||(e[t]=r)}function Ce(e,t){for(var r=e.length;r--;)if(Ye(e[r][0],t))return r;return-1}function Ve(r,n,o,i,e,t,a){var u;if(i&&(u=t?i(r,e,t,a):i(r)),void 0!==u)return u;if(!Je(r))return r;var s,c,l,f,p,d,h=Le(r);if(h){if(u=function(e){var t=e.length,r=e.constructor(t);t&&"string"==typeof e[0]&&Z.call(e,"index")&&(r.index=e.index,r.input=e.input);return r}(r),!n)return function(e,t){var r=-1,n=e.length;t||(t=Array(n));for(;++r<n;)t[r]=e[r];return t}(r,u)}else{var v=Be(r),y=v==S||v==k;if(ze(r))return function(e,t){if(t)return e.slice();var r=new e.constructor(e.length);return e.copy(r),r}(r,n);if(v==x||v==j||y&&!t){if(K(r))return t?r:{};if(u="function"!=typeof(p=y?{}:r).constructor||$e(p)?{}:Je(d=ie(p))?ae(d):{},!n)return f=s=r,c=(l=u)&&Ne(f,Ge(f),l),Ne(s,De(s),c)}else{if(!z[v])return t?r:{};u=function(e,t,r,n){var o=e.constructor;switch(t){case R:return Re(e);case F:case w:return new o(+e);case N:return h=e,v=n?Re(h.buffer):h.buffer,new h.constructor(v,h.byteOffset,h.byteLength);case M:case I:case D:case B:case U:case $:case W:case Y:case L:return p=e,d=n?Re(p.buffer):p.buffer,new p.constructor(d,p.byteOffset,p.length);case E:return l=e,f=r,G(n?f(Q(l),!0):Q(l),H,new l.constructor);case P:case V:return new o(e);case A:return(c=new(s=e).constructor(s.source,q.exec(s))).lastIndex=s.lastIndex,c;case C:return a=e,u=r,G(n?u(X(a),!0):X(a),J,new a.constructor);case T:return i=e,we?Object(we.call(i)):{}}var i;var a,u;var s,c;var l,f;var p,d;var h,v}(r,v,Ve,n)}}a||(a=new Pe);var m,g,b,_=a.get(r);if(_)return _;if(a.set(r,u),!h)var O=o?(g=De,b=Ge(m=r),Le(m)?b:function(e,t){for(var r=-1,n=t.length,o=e.length;++r<n;)e[o+r]=t[r];return e}(b,g(m))):Ge(r);return function(e,t){for(var r=-1,n=e?e.length:0;++r<n&&!1!==t(e[r],r,e););}(O||r,function(e,t){O&&(e=r[t=e]),Ae(u,t,Ve(e,n,o,i,t,r,a))}),u}function Te(e){return!(!Je(e)||(t=e,_&&_ in t))&&(He(e)||K(e)?te:a).test(We(e));var t}function Re(e){var t=new e.constructor(e.byteLength);return new oe(t).set(new oe(e)),t}function Ne(e,t,r,n){r||(r={});for(var o=-1,i=t.length;++o<i;){var a=t[o],u=n?n(r[a],e[a],a,r,e):void 0;Ae(r,a,void 0===u?e[a]:u)}return r}function Me(e,t){var r,n,o=e.__data__;return("string"==(n=typeof(r=t))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof t?"string":"hash"]:o.map}function Ie(e,t){var r,n,o=(n=t,null==(r=e)?void 0:r[n]);return Te(o)?o:void 0}Se.prototype.clear=function(){this.__data__=me?me(null):{}},Se.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},Se.prototype.get=function(e){var t=this.__data__;if(me){var r=t[e];return r===n?void 0:r}return Z.call(t,e)?t[e]:void 0},Se.prototype.has=function(e){var t=this.__data__;return me?void 0!==t[e]:Z.call(t,e)},Se.prototype.set=function(e,t){return this.__data__[e]=me&&void 0===t?n:t,this},ke.prototype.clear=function(){this.__data__=[]},ke.prototype.delete=function(e){var t=this.__data__,r=Ce(t,e);return!(r<0||(r==t.length-1?t.pop():se.call(t,r,1),0))},ke.prototype.get=function(e){var t=this.__data__,r=Ce(t,e);return r<0?void 0:t[r][1]},ke.prototype.has=function(e){return-1<Ce(this.__data__,e)},ke.prototype.set=function(e,t){var r=this.__data__,n=Ce(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},Ee.prototype.clear=function(){this.__data__={hash:new Se,map:new(de||ke),string:new Se}},Ee.prototype.delete=function(e){return Me(this,e).delete(e)},Ee.prototype.get=function(e){return Me(this,e).get(e)},Ee.prototype.has=function(e){return Me(this,e).has(e)},Ee.prototype.set=function(e,t){return Me(this,e).set(e,t),this},Pe.prototype.clear=function(){this.__data__=new ke},Pe.prototype.delete=function(e){return this.__data__.delete(e)},Pe.prototype.get=function(e){return this.__data__.get(e)},Pe.prototype.has=function(e){return this.__data__.has(e)},Pe.prototype.set=function(e,t){var r=this.__data__;if(r instanceof ke){var n=r.__data__;if(!de||n.length<199)return n.push([e,t]),this;r=this.__data__=new Ee(n)}return r.set(e,t),this};var De=ce?h(ce,Object):function(){return[]},Be=function(e){return ee.call(e)};function Ue(e,t){return!!(t=null==t?r:t)&&("number"==typeof e||u.test(e))&&-1<e&&e%1==0&&e<t}function $e(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||g)}function We(e){if(null!=e){try{return O.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Ye(e,t){return e===t||e!=e&&t!=t}(pe&&Be(new pe(new ArrayBuffer(1)))!=N||de&&Be(new de)!=E||he&&Be(he.resolve())!=o||ve&&Be(new ve)!=C||ye&&Be(new ye)!=i)&&(Be=function(e){var t=ee.call(e),r=t==x?e.constructor:void 0,n=r?We(r):void 0;if(n)switch(n){case ge:return N;case be:return E;case _e:return o;case Oe:return C;case je:return i}return t});var Le=Array.isArray;function qe(e){return null!=e&&("number"==typeof(t=e.length)&&-1<t&&t%1==0&&t<=r)&&!He(e);var t}var ze=le||function(){return!1};function He(e){var t=Je(e)?ee.call(e):"";return t==S||t==k}function Je(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Ge(e){return qe(e)?xe(e):function(e){if(!$e(e))return fe(e);var t=[];for(var r in Object(e))Z.call(e,r)&&"constructor"!=r&&t.push(r);return t}(e)}e.exports=function(e){return Ve(e,!0,!0)}}),ne="Expected a function",oe="__lodash_hash_undefined__",ie=1/0,ae="[object Function]",ue="[object GeneratorFunction]",se="[object Symbol]",ce=/^\./,le=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,fe=/\\(\\)?/g,pe=/^\[object .+?Constructor\]$/,de="object"==typeof Ke&&Ke&&Ke.Object===Object&&Ke,he="object"==typeof self&&self&&self.Object===Object&&self,ve=de||he||Function("return this")();var ye,me=Array.prototype,ge=Function.prototype,be=Object.prototype,_e=ve["__core-js_shared__"],Oe=(ye=/[^.]+$/.exec(_e&&_e.keys&&_e.keys.IE_PROTO||""))?"Symbol(src)_1."+ye:"",je=ge.toString,Fe=be.hasOwnProperty,we=be.toString,Se=RegExp("^"+je.call(Fe).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ke=ve.Symbol,Ee=me.splice,Pe=De(ve,"Map"),xe=De(Object,"create"),Ae=ke?ke.prototype:void 0,Ce=Ae?Ae.toString:void 0;function Ve(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Te(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Re(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Ne(e,t){for(var r,n,o=e.length;o--;)if((r=e[o][0])===(n=t)||r!=r&&n!=n)return o;return-1}function Me(e){return!(!Ye(e)||(t=e,Oe&&Oe in t))&&((n=Ye(r=e)?we.call(r):"")==ae||n==ue||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?Se:pe).test(function(e){if(null!=e){try{return je.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e));var t,r,n}function Ie(e,t){var r,n,o=e.__data__;return("string"==(n=typeof(r=t))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof t?"string":"hash"]:o.map}function De(e,t){var r,n,o=(n=t,null==(r=e)?void 0:r[n]);return Me(o)?o:void 0}Ve.prototype.clear=function(){this.__data__=xe?xe(null):{}},Ve.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},Ve.prototype.get=function(e){var t=this.__data__;if(xe){var r=t[e];return r===oe?void 0:r}return Fe.call(t,e)?t[e]:void 0},Ve.prototype.has=function(e){var t=this.__data__;return xe?void 0!==t[e]:Fe.call(t,e)},Ve.prototype.set=function(e,t){return this.__data__[e]=xe&&void 0===t?oe:t,this},Te.prototype.clear=function(){this.__data__=[]},Te.prototype.delete=function(e){var t=this.__data__,r=Ne(t,e);return!(r<0||(r==t.length-1?t.pop():Ee.call(t,r,1),0))},Te.prototype.get=function(e){var t=this.__data__,r=Ne(t,e);return r<0?void 0:t[r][1]},Te.prototype.has=function(e){return-1<Ne(this.__data__,e)},Te.prototype.set=function(e,t){var r=this.__data__,n=Ne(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},Re.prototype.clear=function(){this.__data__={hash:new Ve,map:new(Pe||Te),string:new Ve}},Re.prototype.delete=function(e){return Ie(this,e).delete(e)},Re.prototype.get=function(e){return Ie(this,e).get(e)},Re.prototype.has=function(e){return Ie(this,e).has(e)},Re.prototype.set=function(e,t){return Ie(this,e).set(e,t),this};var Be=$e(function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(Le(e))return Ce?Ce.call(e):"";var t=e+"";return"0"==t&&1/e==-ie?"-0":t}(t);var o=[];return ce.test(e)&&o.push(""),e.replace(le,function(e,t,r,n){o.push(r?n.replace(fe,"$1"):t||e)}),o});function Ue(e){if("string"==typeof e||Le(e))return e;var t=e+"";return"0"==t&&1/e==-ie?"-0":t}function $e(o,i){if("function"!=typeof o||i&&"function"!=typeof i)throw new TypeError(ne);var a=function(){var e=arguments,t=i?i.apply(this,e):e[0],r=a.cache;if(r.has(t))return r.get(t);var n=o.apply(this,e);return a.cache=r.set(t,n),n};return a.cache=new($e.Cache||Re),a}$e.Cache=Re;var We=Array.isArray;function Ye(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Le(e){return"symbol"==typeof e||!!(t=e)&&"object"==typeof t&&we.call(e)==se;var t}var qe=function(e){return We(e)?function(e,t){for(var r=-1,n=e?e.length:0,o=Array(n);++r<n;)o[r]=t(e[r],r,e);return o}(e,Ue):Le(e)?[e]:function(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}(Be(e))};function ze(e,t,r,n){void 0===n&&(n=0);for(var o=qe(t);e&&n<o.length;)e=e[o[n++]];return void 0===e?r:e}function He(e,t,r){for(var n={},o=n,i=0,a=qe(t);i<a.length-1;i++){var u=a[i],s=ze(e,a.slice(0,i+1));if(o[u])o=o[u];else if(s)o=o[u]=re(s);else{var c=a[i+1];o=o[u]=Xe(c)&&0<=Number(c)?[]:{}}}if((0===i?e:o)[a[i]]===r)return e;void 0===r?delete o[a[i]]:o[a[i]]=r;var l=v({},e,n);return 0===i&&void 0===r&&delete l[a[i]],l}function Je(e,t,r,n){void 0===r&&(r=new WeakMap),void 0===n&&(n={});for(var o=0,i=Object.keys(e);o<i.length;o++){var a=i[o],u=e[a];Qe(u)?r.get(u)||(r.set(u,!0),n[a]=Array.isArray(u)?[]:{},Je(u,t,r,n[a])):n[a]=t}return n}var Ge=function(e){return"function"==typeof e},Qe=function(e){return null!==e&&"object"==typeof e},Xe=function(e){return String(Math.floor(Number(e)))===e},Ze=function(e){return"[object String]"===Object.prototype.toString.call(e)},et=function(e){return e!=e},tt=function(e){return 0===d.Children.count(e)},rt=function(e){return Qe(e)&&Ge(e.then)};var nt=function(t){function e(e){var l=t.call(this,e)||this;return l.hcCache={},l.hbCache={},l.registerField=function(e,t){l.fields[e]=t},l.unregisterField=function(e){delete l.fields[e]},l.setErrors=function(e){l.setState({errors:e})},l.setTouched=function(e){l.setState({touched:e},function(){l.props.validateOnBlur&&l.runValidations(l.state.values)})},l.setValues=function(e){l.setState({values:e},function(){l.props.validateOnChange&&l.runValidations(e)})},l.setStatus=function(e){l.setState({status:e})},l.setError=function(e){l.setState({error:e})},l.setSubmitting=function(e){l.didMount&&l.setState({isSubmitting:e})},l.validateField=function(t){l.setState({isValidating:!0}),l.runSingleFieldLevelValidation(t,ze(l.state.values,t)).then(function(e){l.didMount&&l.setState({errors:He(l.state.errors,t,e),isValidating:!1})})},l.runSingleFieldLevelValidation=function(t,r){return new Promise(function(e){return e(l.fields[t].props.validate(r))}).then(function(e){return e},function(e){return e})},l.runValidationSchema=function(n){return new Promise(function(t){var e=l.props.validationSchema,r=Ge(e)?e():e;it(n,r).then(function(){t({})},function(e){t(ot(e))})})},l.runValidations=function(e){return void 0===e&&(e=l.state.values),l.setState({isValidating:!0}),Promise.all([l.runFieldLevelValidations(e),l.props.validationSchema?l.runValidationSchema(e):{},l.props.validate?l.runValidateHandler(e):{}]).then(function(e){var t=p.all([e[0],e[1],e[2]],{arrayMerge:at});return l.didMount&&l.setState({isValidating:!1,errors:t}),t})},l.handleChange=function(t){var r=function(e,t){var r,n=t,o=e;if(!Ze(e)){e.persist&&e.persist();var i=e.target,a=i.type,u=i.name,s=i.value,c=i.checked;n=t||(u||i.id),o=/number|range/.test(a)?(r=parseFloat(s),et(r)?"":r):/checkbox/.test(a)?c:s}n&&l.setState(function(e){return v({},e,{values:He(e.values,n,o)})},function(){l.props.validateOnChange&&l.runValidations(He(l.state.values,n,o))})};if(Ze(t))return Ge(l.hcCache[t])?l.hcCache[t]:l.hcCache[t]=function(e){return r(e,t)};r(t)},l.setFieldValue=function(t,r,e){void 0===e&&(e=!0),l.didMount&&l.setState(function(e){return v({},e,{values:He(e.values,t,r)})},function(){l.props.validateOnChange&&e&&l.runValidations(l.state.values)})},l.handleSubmit=function(e){e&&e.preventDefault&&e.preventDefault(),l.submitForm()},l.submitForm=function(){return l.setState(function(e){return{touched:Je(e.values,!0),isSubmitting:!0,submitCount:e.submitCount+1}}),l.runValidations().then(function(e){0===Object.keys(e).length?l.executeSubmit():l.didMount&&l.setState({isSubmitting:!1})})},l.executeSubmit=function(){l.props.onSubmit(l.state.values,l.getFormikActions())},l.handleBlur=function(t){var r=function(e,t){e.persist&&e.persist();var r=e.target,n=r.name,o=t||(n||r.id);l.setState(function(e){return{touched:He(e.touched,o,!0)}}),l.props.validateOnBlur&&l.runValidations(l.state.values)};if(Ze(t))return Ge(l.hbCache[t])?l.hbCache[t]:l.hbCache[t]=function(e){return r(e,t)};r(t)},l.setFieldTouched=function(t,r,e){void 0===r&&(r=!0),void 0===e&&(e=!0),l.setState(function(e){return v({},e,{touched:He(e.touched,t,r)})},function(){l.props.validateOnBlur&&e&&l.runValidations(l.state.values)})},l.setFieldError=function(t,r){l.setState(function(e){return v({},e,{errors:He(e.errors,t,r)})})},l.resetForm=function(e){var t=e||l.props.initialValues;l.initialValues=t,l.setState({isSubmitting:!1,isValidating:!1,errors:{},touched:{},error:void 0,status:void 0,values:t,submitCount:0})},l.handleReset=function(){if(l.props.onReset){var e=l.props.onReset(l.state.values,l.getFormikActions());rt(e)?e.then(l.resetForm):l.resetForm()}else l.resetForm()},l.setFormikState=function(e,t){return l.setState(e,t)},l.getFormikActions=function(){return{resetForm:l.resetForm,submitForm:l.submitForm,validateForm:l.runValidations,validateField:l.validateField,setError:l.setError,setErrors:l.setErrors,setFieldError:l.setFieldError,setFieldTouched:l.setFieldTouched,setFieldValue:l.setFieldValue,setStatus:l.setStatus,setSubmitting:l.setSubmitting,setTouched:l.setTouched,setValues:l.setValues,setFormikState:l.setFormikState}},l.getFormikComputedProps=function(){var e=l.props.isInitialValid,t=!r(l.initialValues,l.state.values);return{dirty:t,isValid:t?l.state.errors&&0===Object.keys(l.state.errors).length:!1!==e&&Ge(e)?e(l.props):e,initialValues:l.initialValues}},l.getFormikBag=function(){return v({},l.state,l.getFormikActions(),l.getFormikComputedProps(),{registerField:l.registerField,unregisterField:l.unregisterField,handleBlur:l.handleBlur,handleChange:l.handleChange,handleReset:l.handleReset,handleSubmit:l.handleSubmit,validateOnChange:l.props.validateOnChange,validateOnBlur:l.props.validateOnBlur})},l.getFormikContext=function(){return v({},l.getFormikBag(),{validationSchema:l.props.validationSchema,validate:l.props.validate,initialValues:l.initialValues})},l.state={values:e.initialValues||{},errors:{},touched:{},isSubmitting:!1,isValidating:!1,submitCount:0},l.didMount=!1,l.fields={},l.initialValues=e.initialValues||{},u(!(e.component&&e.render),"You should not use <Formik component> and <Formik render> in the same <Formik> component; <Formik render> will be ignored"),u(!(e.component&&e.children&&!tt(e.children)),"You should not use <Formik component> and <Formik children> in the same <Formik> component; <Formik children> will be ignored"),u(!(e.render&&e.children&&!tt(e.children)),"You should not use <Formik render> and <Formik children> in the same <Formik> component; <Formik children> will be ignored"),l}return a(e,t),e.prototype.componentDidMount=function(){this.didMount=!0},e.prototype.componentWillUnmount=function(){this.didMount=!1},e.prototype.componentDidUpdate=function(e){this.props.enableReinitialize&&!r(e.initialValues,this.props.initialValues)&&(this.initialValues=this.props.initialValues,this.resetForm(this.props.initialValues))},e.prototype.runFieldLevelValidations=function(t){var r=this,n=Object.keys(this.fields).filter(function(e){return r.fields&&r.fields[e]&&r.fields[e].props.validate&&Ge(r.fields[e].props.validate)}),e=0<n.length?n.map(function(e){return r.runSingleFieldLevelValidation(e,ze(t,e))}):[Promise.resolve("DO_NOT_DELETE_YOU_WILL_BE_FIRED")];return Promise.all(e).then(function(e){return e.reduce(function(e,t,r){return"DO_NOT_DELETE_YOU_WILL_BE_FIRED"===t||t&&(e=He(e,n[r],t)),e},{})})},e.prototype.runValidateHandler=function(r){var n=this;return new Promise(function(t){var e=n.props.validate(r);void 0===e?t({}):rt(e)?e.then(function(){t({})},function(e){t(e)}):t(e)})},e.prototype.render=function(){var e=this.props,t=e.component,r=e.render,n=e.children,o=this.getFormikBag(),i=this.getFormikContext();return d.createElement(Z,{value:i},t?d.createElement(t,o):r?r(o):n?Ge(n)?n(o):tt(n)?null:d.Children.only(n):null)},e.defaultProps={validateOnChange:!0,validateOnBlur:!0,isInitialValid:!1,enableReinitialize:!1},e}(d.Component);function ot(e){var t={};if(0===e.inner.length)return He(t,e.path,e.message);for(var r=0,n=e.inner;r<n.length;r++){var o=n[r];t[o.path]||(t=He(t,o.path,o.message))}return t}function it(e,t,r,n){void 0===r&&(r=!1),void 0===n&&(n={});var o={};for(var i in e)if(e.hasOwnProperty(i)){var a=String(i);o[a]=""!==e[a]?e[a]:void 0}return t[r?"validateSync":"validate"](o,{abortEarly:!1,context:n})}function at(n,e,o){var i=n.slice();return e.forEach(function(e,t){if(void 0===i[t]){var r=!1!==o.clone&&o.isMergeableObject(e);i[t]=r?p(Array.isArray(e)?[]:{},e,o):e}else o.isMergeableObject(e)?i[t]=p(n[t],e,o):-1===n.indexOf(e)&&i.push(e)}),i}var ut=te(function(i){function e(e){var t=i.call(this,e)||this,r=e.render,n=e.children,o=e.component;return u(!(o&&r),"You should not use <Field component> and <Field render> in the same <Field> component; <Field component> will be ignored"),u(!(o&&n&&Ge(n)),"You should not use <Field component> and <Field children> as a function in the same <Field> component; <Field component> will be ignored."),u(!(r&&n&&!tt(n)),"You should not use <Field render> and <Field children> in the same <Field> component; <Field children> will be ignored"),t}return a(e,i),e.prototype.componentDidMount=function(){this.props.formik.registerField(this.props.name,this)},e.prototype.componentDidUpdate=function(e){this.props.name!==e.name&&(this.props.formik.unregisterField(e.name),this.props.formik.registerField(this.props.name,this)),this.props.validate!==e.validate&&this.props.formik.registerField(this.props.name,this)},e.prototype.componentWillUnmount=function(){this.props.formik.unregisterField(this.props.name)},e.prototype.render=function(){var e=this.props,t=e.name,r=e.render,n=e.children,o=e.component,i=void 0===o?"input":o,a=e.formik,u=y(e,["validate","name","render","children","component","formik"]),s=y(a,["validate","validationSchema"]),c={value:"radio"===u.type||"checkbox"===u.type?u.value:ze(a.values,t),name:t,onChange:a.handleChange,onBlur:a.handleBlur},l={field:c,form:s};if(r)return r(l);if(Ge(n))return n(l);if("string"!=typeof i)return d.createElement(i,v({},l,u,{children:n}));var f=u.innerRef,p=y(u,["innerRef"]);return d.createElement(i,v({ref:f},c,p,{children:n}))},e}(d.Component)),st=te(function(e){var t=e.formik,r=t.handleReset,n=t.handleSubmit,o=y(e,["formik"]);return d.createElement("form",v({onReset:r,onSubmit:n},o))});st.displayName="Form";var ct=function(e,t,r){var n=(e||[]).slice(),o=n[t];return n.splice(t,1),n.splice(r,0,o),n},lt=function(e,t,r){var n=(e||[]).slice(),o=n[t];return n[t]=n[r],n[r]=o,n},ft=function(e,t,r){var n=(e||[]).slice();return n.splice(t,0,r),n},pt=function(e,t,r){var n=(e||[]).slice();return n[t]=r,n},dt=te(function(t){function e(e){var f=t.call(this,e)||this;return f.updateArrayField=function(t,r,n){var e=f.props,o=e.name,i=e.validateOnChange,a=e.formik,u=a.validateForm,s=a.values,c=a.touched,l=a.errors;(0,a.setFormikState)(function(e){return v({},e,{values:He(e.values,o,t(ze(s,o))),errors:n?He(e.errors,o,t(ze(l,o))):e.errors,touched:r?He(e.touched,o,t(ze(c,o))):e.touched})},function(){i&&u()})},f.push=function(t){return f.updateArrayField(function(e){return(e||[]).concat([re(t)])},!1,!1)},f.handlePush=function(e){return function(){return f.push(e)}},f.swap=function(t,r){return f.updateArrayField(function(e){return lt(e,t,r)},!0,!0)},f.handleSwap=function(e,t){return function(){return f.swap(e,t)}},f.move=function(t,r){return f.updateArrayField(function(e){return ct(e,t,r)},!0,!0)},f.handleMove=function(e,t){return function(){return f.move(e,t)}},f.insert=function(t,r){return f.updateArrayField(function(e){return ft(e,t,r)},!0,!0)},f.handleInsert=function(e,t){return function(){return f.insert(e,t)}},f.replace=function(t,r){return f.updateArrayField(function(e){return pt(e,t,r)},!1,!1)},f.handleReplace=function(e,t){return function(){return f.replace(e,t)}},f.unshift=function(r){var n=-1;return f.updateArrayField(function(e){var t=e?[r].concat(e):[r];return n<0&&(n=t.length),t},!0,!0),n},f.handleUnshift=function(e){return function(){return f.unshift(e)}},f.handleRemove=function(e){return function(){return f.remove(e)}},f.handlePop=function(){return function(){return f.pop()}},f.remove=f.remove.bind(f),f.pop=f.pop.bind(f),f}return a(e,t),e.prototype.remove=function(r){var n;return this.updateArrayField(function(e){var t=e?e.slice():[];return n||(n=t[r]),Ge(t.splice)&&t.splice(r,1),t},!0,!0),n},e.prototype.pop=function(){var r;return this.updateArrayField(function(e){var t=e;return r||(r=t&&t.pop&&t.pop()),t},!0,!0),r},e.prototype.render=function(){var e={push:this.push,pop:this.pop,swap:this.swap,move:this.move,insert:this.insert,replace:this.replace,unshift:this.unshift,remove:this.remove,handlePush:this.handlePush,handlePop:this.handlePop,handleSwap:this.handleSwap,handleMove:this.handleMove,handleInsert:this.handleInsert,handleReplace:this.handleReplace,handleUnshift:this.handleUnshift,handleRemove:this.handleRemove},t=this.props,r=t.component,n=t.render,o=t.children,i=t.name,a=t.formik,u=y(a,["validate","validationSchema"]),s=v({},e,{form:u,name:i});return r?d.createElement(r,s):n?n(s):o?"function"==typeof o?o(s):tt(o)?null:d.Children.only(o):null},e.defaultProps={validateOnChange:!0},e}(d.Component)),ht=te(function(i){function e(e){var t=i.call(this,e)||this,r=e.render,n=e.children,o=e.component;return u(!(o&&r),"You should not use <FastField component> and <FastField render> in the same <FastField> component; <FastField component> will be ignored"),u(!(o&&n&&Ge(n)),"You should not use <FastField component> and <FastField children> as a function in the same <FastField> component; <FastField component> will be ignored."),u(!(r&&n&&!tt(n)),"You should not use <FastField render> and <FastField children> in the same <FastField> component; <FastField children> will be ignored"),t}return a(e,i),e.prototype.shouldComponentUpdate=function(e){return this.props.shouldUpdate?this.props.shouldUpdate(e,this.props):ze(this.props.formik.values,this.props.name)!==ze(e.formik.values,this.props.name)||ze(this.props.formik.errors,this.props.name)!==ze(e.formik.errors,this.props.name)||ze(this.props.formik.touched,this.props.name)!==ze(e.formik.touched,this.props.name)||Object.keys(this.props).length!==Object.keys(e).length||this.props.formik.isSubmitting!==e.formik.isSubmitting},e.prototype.componentDidMount=function(){this.props.formik.registerField(this.props.name,this)},e.prototype.componentDidUpdate=function(e){this.props.name!==e.name&&(this.props.formik.unregisterField(e.name),this.props.formik.registerField(this.props.name,this)),this.props.validate!==e.validate&&this.props.formik.registerField(this.props.name,this)},e.prototype.componentWillUnmount=function(){this.props.formik.unregisterField(this.props.name)},e.prototype.render=function(){var e=this.props,t=e.name,r=e.render,n=e.children,o=e.component,i=void 0===o?"input":o,a=e.formik,u=y(e,["validate","name","render","children","component","formik"]),s=y(a,["validate","validationSchema"]),c={value:"radio"===u.type||"checkbox"===u.type?u.value:ze(a.values,t),name:t,onChange:a.handleChange,onBlur:a.handleBlur},l={field:c,form:s};if(r)return r(l);if(Ge(n))return n(l);if("string"!=typeof i)return d.createElement(i,v({},l,u,{children:n}));var f=u.innerRef,p=y(u,["innerRef"]);return d.createElement(i,v({ref:f},c,p,{children:n}))},e}(d.Component)),vt=te(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return a(t,e),t.prototype.shouldComponentUpdate=function(e){return ze(this.props.formik.errors,this.props.name)!==ze(e.formik.errors,this.props.name)||ze(this.props.formik.touched,this.props.name)!==ze(e.formik.touched,this.props.name)||Object.keys(this.props).length!==Object.keys(e).length},t.prototype.render=function(){var e=this.props,t=e.component,r=e.formik,n=e.render,o=e.children,i=e.name,a=y(e,["component","formik","render","children","name"]),u=ze(r.touched,i),s=ze(r.errors,i);return u&&s?n?Ge(n)?n(s):null:o?Ge(o)?o(s):null:t?d.createElement(t,a,s):s:null},t}(d.Component));e.Formik=nt,e.yupToFormErrors=ot,e.validateYupSchema=it,e.Field=ut,e.Form=st,e.withFormik=function(e){var t=e.mapPropsToValues,o=void 0===t?function(e){var t={};for(var r in e)e.hasOwnProperty(r)&&"function"!=typeof e[r]&&(t[r]=e[r]);return t}:t,i=y(e,["mapPropsToValues"]);return function(n){var r=n.displayName||n.name||n.constructor&&n.constructor.name||"Component",e=function(e){function t(){var r=null!==e&&e.apply(this,arguments)||this;return r.validate=function(e){return i.validate(e,r.props)},r.validationSchema=function(){return Ge(i.validationSchema)?i.validationSchema(r.props):i.validationSchema},r.handleSubmit=function(e,t){return i.handleSubmit(e,v({},t,{props:r.props}))},r.renderFormComponent=function(e){return d.createElement(n,v({},r.props,e))},r}return a(t,e),t.prototype.render=function(){var e=this.props,t=y(e,["children"]);return d.createElement(nt,v({},t,i,{validate:i.validate&&this.validate,validationSchema:i.validationSchema&&this.validationSchema,initialValues:o(this.props),onSubmit:this.handleSubmit,render:this.renderFormComponent}))},t.displayName="WithFormik("+r+")",t}(d.Component);return P(e,n)}},e.move=ct,e.swap=lt,e.insert=ft,e.replace=pt,e.FieldArray=dt,e.getIn=ze,e.setIn=He,e.setNestedObjectValues=Je,e.isFunction=Ge,e.isObject=Qe,e.isInteger=Xe,e.isString=Ze,e.isNaN=et,e.isEmptyChildren=tt,e.isPromise=rt,e.getActiveElement=function(t){if(void 0===(t=t||("undefined"!=typeof document?document:void 0)))return null;try{return t.activeElement||t.body}catch(e){return t.body}},e.FastField=ht,e.FormikProvider=Z,e.FormikConsumer=ee,e.connect=te,e.ErrorMessage=vt,Object.defineProperty(e,"__esModule",{value:!0})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],e):e(t.Formik={},t.React)}(this,function(t,M){"use strict";var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function i(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var D=function(){return(D=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function V(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&(r[n[o]]=t[n[o]])}return r}var d=Array.isArray,h=Object.keys,v=Object.prototype.hasOwnProperty;var x=function(t,e){try{return function t(e,r){if(e===r)return!0;var n,o,a,i=d(e),u=d(r);if(i&&u){if((o=e.length)!=r.length)return!1;for(n=0;n<o;n++)if(!t(e[n],r[n]))return!1;return!0}if(i!=u)return!1;var c=e instanceof Date,s=r instanceof Date;if(c!=s)return!1;if(c&&s)return e.getTime()==r.getTime();var l=e instanceof RegExp,f=r instanceof RegExp;if(l!=f)return!1;if(l&&f)return e.toString()==r.toString();if(e instanceof Object&&r instanceof Object){var p=h(e);if((o=p.length)!==h(r).length)return!1;for(n=0;n<o;n++)if(!v.call(r,p[n]))return!1;for(n=0;n<o;n++)if(!("_owner"===(a=p[n])&&e.$$typeof&&e._store||t(e[a],r[a])))return!1;return!0}return!1}(t,e)}catch(t){if(t.message&&t.message.match(/stack|recursion/i))return console.warn("Warning: react-fast-compare does not handle circular references.",t.name,t.message),!1;throw t}},c=function(t){return!(!(n=t)||"object"!=typeof n||(e=t,"[object RegExp]"===(r=Object.prototype.toString.call(e))||"[object Date]"===r||e.$$typeof===o));var e,r,n};var o="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function s(t,e){return!1!==e.clone&&e.isMergeableObject(t)?f(Array.isArray(t)?[]:{},t,e):t}function l(t,e,r){return t.concat(e).map(function(t){return s(t,r)})}function f(t,e,r){(r=r||{}).arrayMerge=r.arrayMerge||l,r.isMergeableObject=r.isMergeableObject||c;var n,o,a,i,u=Array.isArray(e);return u===Array.isArray(t)?u?r.arrayMerge(t,e,r):(o=e,i={},(a=r).isMergeableObject(n=t)&&Object.keys(n).forEach(function(t){i[t]=s(n[t],a)}),Object.keys(o).forEach(function(t){i[t]=a.isMergeableObject(o[t])&&n[t]?f(n[t],o[t],a):s(o[t],a)}),i):s(e,r)}f.all=function(t,r){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce(function(t,e){return f(t,e,r)},{})};var U=f,Jt="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var e,p=(function(t,e){var n="__lodash_hash_undefined__",r=9007199254740991,E="[object Arguments]",O="[object Boolean]",j="[object Date]",T="[object Function]",F="[object GeneratorFunction]",A="[object Map]",w="[object Number]",I="[object Object]",o="[object Promise]",R="[object RegExp]",P="[object Set]",k="[object String]",C="[object Symbol]",a="[object WeakMap]",M="[object ArrayBuffer]",D="[object DataView]",V="[object Float32Array]",x="[object Float64Array]",U="[object Int8Array]",L="[object Int16Array]",N="[object Int32Array]",$="[object Uint8Array]",B="[object Uint8ClampedArray]",G="[object Uint16Array]",W="[object Uint32Array]",H=/\w*$/,i=/^\[object .+?Constructor\]$/,u=/^(?:0|[1-9]\d*)$/,K={};K[E]=K["[object Array]"]=K[M]=K[D]=K[O]=K[j]=K[V]=K[x]=K[U]=K[L]=K[N]=K[A]=K[w]=K[I]=K[R]=K[P]=K[k]=K[C]=K[$]=K[B]=K[G]=K[W]=!0,K["[object Error]"]=K[T]=K[a]=!1;var c="object"==typeof Jt&&Jt&&Jt.Object===Object&&Jt,s="object"==typeof self&&self&&self.Object===Object&&self,l=c||s||Function("return this")(),f=e&&!e.nodeType&&e,p=f&&t&&!t.nodeType&&t,d=p&&p.exports===f;function Y(t,e){return t.set(e[0],e[1]),t}function z(t,e){return t.add(e),t}function q(t,e,r,n){var o=-1,a=t?t.length:0;for(n&&a&&(r=t[++o]);++o<a;)r=e(r,t[o],o,t);return r}function J(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}function Q(t){var r=-1,n=Array(t.size);return t.forEach(function(t,e){n[++r]=[e,t]}),n}function h(e,r){return function(t){return e(r(t))}}function X(t){var e=-1,r=Array(t.size);return t.forEach(function(t){r[++e]=t}),r}var v,y=Array.prototype,_=Function.prototype,m=Object.prototype,b=l["__core-js_shared__"],g=(v=/[^.]+$/.exec(b&&b.keys&&b.keys.IE_PROTO||""))?"Symbol(src)_1."+v:"",S=_.toString,Z=m.hasOwnProperty,tt=m.toString,et=RegExp("^"+S.call(Z).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),rt=d?l.Buffer:void 0,nt=l.Symbol,ot=l.Uint8Array,at=h(Object.getPrototypeOf,Object),it=Object.create,ut=m.propertyIsEnumerable,ct=y.splice,st=Object.getOwnPropertySymbols,lt=rt?rt.isBuffer:void 0,ft=h(Object.keys,Object),pt=xt(l,"DataView"),dt=xt(l,"Map"),ht=xt(l,"Promise"),vt=xt(l,"Set"),yt=xt(l,"WeakMap"),_t=xt(Object,"create"),mt=Bt(pt),bt=Bt(dt),gt=Bt(ht),St=Bt(vt),Et=Bt(yt),Ot=nt?nt.prototype:void 0,jt=Ot?Ot.valueOf:void 0;function Tt(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Ft(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function At(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function wt(t){this.__data__=new Ft(t)}function It(t,e){var r,n,o,a=Wt(t)||(o=n=r=t)&&"object"==typeof o&&Ht(n)&&Z.call(r,"callee")&&(!ut.call(r,"callee")||tt.call(r)==E)?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],i=a.length,u=!!i;for(var c in t)!e&&!Z.call(t,c)||u&&("length"==c||Nt(c,i))||a.push(c);return a}function Rt(t,e,r){var n=t[e];Z.call(t,e)&&Gt(n,r)&&(void 0!==r||e in t)||(t[e]=r)}function Pt(t,e){for(var r=t.length;r--;)if(Gt(t[r][0],e))return r;return-1}function kt(r,n,o,a,t,e,i){var u;if(a&&(u=e?a(r,t,e,i):a(r)),void 0!==u)return u;if(!zt(r))return r;var c,s,l,f,p,d,h=Wt(r);if(h){if(u=function(t){var e=t.length,r=t.constructor(e);e&&"string"==typeof t[0]&&Z.call(t,"index")&&(r.index=t.index,r.input=t.input);return r}(r),!n)return function(t,e){var r=-1,n=t.length;e||(e=Array(n));for(;++r<n;)e[r]=t[r];return e}(r,u)}else{var v=Lt(r),y=v==T||v==F;if(Kt(r))return function(t,e){if(e)return t.slice();var r=new t.constructor(t.length);return t.copy(r),r}(r,n);if(v==I||v==E||y&&!e){if(J(r))return e?r:{};if(u="function"!=typeof(p=y?{}:r).constructor||$t(p)?{}:zt(d=at(p))?it(d):{},!n)return f=c=r,s=(l=u)&&Dt(f,qt(f),l),Dt(c,Ut(c),s)}else{if(!K[v])return e?r:{};u=function(t,e,r,n){var o=t.constructor;switch(e){case M:return Mt(t);case O:case j:return new o(+t);case D:return h=t,v=n?Mt(h.buffer):h.buffer,new h.constructor(v,h.byteOffset,h.byteLength);case V:case x:case U:case L:case N:case $:case B:case G:case W:return p=t,d=n?Mt(p.buffer):p.buffer,new p.constructor(d,p.byteOffset,p.length);case A:return l=t,f=r,q(n?f(Q(l),!0):Q(l),Y,new l.constructor);case w:case k:return new o(t);case R:return(s=new(c=t).constructor(c.source,H.exec(c))).lastIndex=c.lastIndex,s;case P:return i=t,u=r,q(n?u(X(i),!0):X(i),z,new i.constructor);case C:return a=t,jt?Object(jt.call(a)):{}}var a;var i,u;var c,s;var l,f;var p,d;var h,v}(r,v,kt,n)}}i||(i=new wt);var _,m,b,g=i.get(r);if(g)return g;if(i.set(r,u),!h)var S=o?(m=Ut,b=qt(_=r),Wt(_)?b:function(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}(b,m(_))):qt(r);return function(t,e){for(var r=-1,n=t?t.length:0;++r<n&&!1!==e(t[r],r,t););}(S||r,function(t,e){S&&(t=r[e=t]),Rt(u,e,kt(t,n,o,a,e,r,i))}),u}function Ct(t){return!(!zt(t)||(e=t,g&&g in e))&&(Yt(t)||J(t)?et:i).test(Bt(t));var e}function Mt(t){var e=new t.constructor(t.byteLength);return new ot(e).set(new ot(t)),e}function Dt(t,e,r,n){r||(r={});for(var o=-1,a=e.length;++o<a;){var i=e[o],u=n?n(r[i],t[i],i,r,t):void 0;Rt(r,i,void 0===u?t[i]:u)}return r}function Vt(t,e){var r,n,o=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof e?"string":"hash"]:o.map}function xt(t,e){var r,n,o=(n=e,null==(r=t)?void 0:r[n]);return Ct(o)?o:void 0}Tt.prototype.clear=function(){this.__data__=_t?_t(null):{}},Tt.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},Tt.prototype.get=function(t){var e=this.__data__;if(_t){var r=e[t];return r===n?void 0:r}return Z.call(e,t)?e[t]:void 0},Tt.prototype.has=function(t){var e=this.__data__;return _t?void 0!==e[t]:Z.call(e,t)},Tt.prototype.set=function(t,e){return this.__data__[t]=_t&&void 0===e?n:e,this},Ft.prototype.clear=function(){this.__data__=[]},Ft.prototype.delete=function(t){var e=this.__data__,r=Pt(e,t);return!(r<0||(r==e.length-1?e.pop():ct.call(e,r,1),0))},Ft.prototype.get=function(t){var e=this.__data__,r=Pt(e,t);return r<0?void 0:e[r][1]},Ft.prototype.has=function(t){return-1<Pt(this.__data__,t)},Ft.prototype.set=function(t,e){var r=this.__data__,n=Pt(r,t);return n<0?r.push([t,e]):r[n][1]=e,this},At.prototype.clear=function(){this.__data__={hash:new Tt,map:new(dt||Ft),string:new Tt}},At.prototype.delete=function(t){return Vt(this,t).delete(t)},At.prototype.get=function(t){return Vt(this,t).get(t)},At.prototype.has=function(t){return Vt(this,t).has(t)},At.prototype.set=function(t,e){return Vt(this,t).set(t,e),this},wt.prototype.clear=function(){this.__data__=new Ft},wt.prototype.delete=function(t){return this.__data__.delete(t)},wt.prototype.get=function(t){return this.__data__.get(t)},wt.prototype.has=function(t){return this.__data__.has(t)},wt.prototype.set=function(t,e){var r=this.__data__;if(r instanceof Ft){var n=r.__data__;if(!dt||n.length<199)return n.push([t,e]),this;r=this.__data__=new At(n)}return r.set(t,e),this};var Ut=st?h(st,Object):function(){return[]},Lt=function(t){return tt.call(t)};function Nt(t,e){return!!(e=null==e?r:e)&&("number"==typeof t||u.test(t))&&-1<t&&t%1==0&&t<e}function $t(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||m)}function Bt(t){if(null!=t){try{return S.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function Gt(t,e){return t===e||t!=t&&e!=e}(pt&&Lt(new pt(new ArrayBuffer(1)))!=D||dt&&Lt(new dt)!=A||ht&&Lt(ht.resolve())!=o||vt&&Lt(new vt)!=P||yt&&Lt(new yt)!=a)&&(Lt=function(t){var e=tt.call(t),r=e==I?t.constructor:void 0,n=r?Bt(r):void 0;if(n)switch(n){case mt:return D;case bt:return A;case gt:return o;case St:return P;case Et:return a}return e});var Wt=Array.isArray;function Ht(t){return null!=t&&("number"==typeof(e=t.length)&&-1<e&&e%1==0&&e<=r)&&!Yt(t);var e}var Kt=lt||function(){return!1};function Yt(t){var e=zt(t)?tt.call(t):"";return e==T||e==F}function zt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function qt(t){return Ht(t)?It(t):function(t){if(!$t(t))return ft(t);var e=[];for(var r in Object(t))Z.call(t,r)&&"constructor"!=r&&e.push(r);return e}(t)}t.exports=function(t){return kt(t,!0,!0)}}(e={exports:{}},e.exports),e.exports),r="Expected a function",a="__lodash_hash_undefined__",u=1/0,y="[object Function]",_="[object GeneratorFunction]",m="[object Symbol]",b=/^\./,g=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,S=/\\(\\)?/g,E=/^\[object .+?Constructor\]$/,O="object"==typeof Jt&&Jt&&Jt.Object===Object&&Jt,j="object"==typeof self&&self&&self.Object===Object&&self,T=O||j||Function("return this")();var F,A=Array.prototype,w=Function.prototype,I=Object.prototype,R=T["__core-js_shared__"],P=(F=/[^.]+$/.exec(R&&R.keys&&R.keys.IE_PROTO||""))?"Symbol(src)_1."+F:"",k=w.toString,C=I.hasOwnProperty,L=I.toString,N=RegExp("^"+k.call(C).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),$=T.Symbol,B=A.splice,G=Z(T,"Map"),W=Z(Object,"create"),H=$?$.prototype:void 0,K=H?H.toString:void 0;function Y(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function z(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function q(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function J(t,e){for(var r,n,o=t.length;o--;)if((r=t[o][0])===(n=e)||r!=r&&n!=n)return o;return-1}function Q(t){return!(!ot(t)||(e=t,P&&P in e))&&((n=ot(r=t)?L.call(r):"")==y||n==_||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?N:E).test(function(t){if(null!=t){try{return k.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t));var e,r,n}function X(t,e){var r,n,o=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof e?"string":"hash"]:o.map}function Z(t,e){var r,n,o=(n=e,null==(r=t)?void 0:r[n]);return Q(o)?o:void 0}Y.prototype.clear=function(){this.__data__=W?W(null):{}},Y.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},Y.prototype.get=function(t){var e=this.__data__;if(W){var r=e[t];return r===a?void 0:r}return C.call(e,t)?e[t]:void 0},Y.prototype.has=function(t){var e=this.__data__;return W?void 0!==e[t]:C.call(e,t)},Y.prototype.set=function(t,e){return this.__data__[t]=W&&void 0===e?a:e,this},z.prototype.clear=function(){this.__data__=[]},z.prototype.delete=function(t){var e=this.__data__,r=J(e,t);return!(r<0||(r==e.length-1?e.pop():B.call(e,r,1),0))},z.prototype.get=function(t){var e=this.__data__,r=J(e,t);return r<0?void 0:e[r][1]},z.prototype.has=function(t){return-1<J(this.__data__,t)},z.prototype.set=function(t,e){var r=this.__data__,n=J(r,t);return n<0?r.push([t,e]):r[n][1]=e,this},q.prototype.clear=function(){this.__data__={hash:new Y,map:new(G||z),string:new Y}},q.prototype.delete=function(t){return X(this,t).delete(t)},q.prototype.get=function(t){return X(this,t).get(t)},q.prototype.has=function(t){return X(this,t).has(t)},q.prototype.set=function(t,e){return X(this,t).set(t,e),this};var tt=rt(function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(at(t))return K?K.call(t):"";var e=t+"";return"0"==e&&1/t==-u?"-0":e}(e);var o=[];return b.test(t)&&o.push(""),t.replace(g,function(t,e,r,n){o.push(r?n.replace(S,"$1"):e||t)}),o});function et(t){if("string"==typeof t||at(t))return t;var e=t+"";return"0"==e&&1/t==-u?"-0":e}function rt(o,a){if("function"!=typeof o||a&&"function"!=typeof a)throw new TypeError(r);var i=function(){var t=arguments,e=a?a.apply(this,t):t[0],r=i.cache;if(r.has(e))return r.get(e);var n=o.apply(this,t);return i.cache=r.set(e,n),n};return i.cache=new(rt.Cache||q),i}rt.Cache=q;var nt=Array.isArray;function ot(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function at(t){return"symbol"==typeof t||!!(e=t)&&"object"==typeof e&&L.call(t)==m;var e}var it=function(t){return nt(t)?function(t,e){for(var r=-1,n=t?t.length:0,o=Array(n);++r<n;)o[r]=e(t[r],r,t);return o}(t,et):at(t)?[t]:function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}(tt(t))};function ut(t,e,r,n){void 0===n&&(n=0);for(var o=it(e);t&&n<o.length;)t=t[o[n++]];return void 0===t?r:t}function ct(t,e,r){for(var n={},o=n,a=0,i=it(e);a<i.length-1;a++){var u=i[a],c=ut(t,i.slice(0,a+1));if(o[u])o=o[u];else if(c)o=o[u]=p(c);else{var s=i[a+1];o=o[u]=pt(s)&&0<=Number(s)?[]:{}}}if((0===a?t:o)[i[a]]===r)return t;void 0===r?delete o[i[a]]:o[i[a]]=r;var l=D({},t,n);return 0===a&&void 0===r&&delete l[i[a]],l}function st(t,e,r,n){void 0===r&&(r=new WeakMap),void 0===n&&(n={});for(var o=0,a=Object.keys(t);o<a.length;o++){var i=a[o],u=t[i];ft(u)?r.get(u)||(r.set(u,!0),n[i]=Array.isArray(u)?[]:{},st(u,e,r,n[i])):n[i]=e}return n}var lt=function(t){return"function"==typeof t},ft=function(t){return null!==t&&"object"==typeof t},pt=function(t){return String(Math.floor(Number(t)))===t},dt=function(t){return"[object String]"===Object.prototype.toString.call(t)},ht=function(t){return 0===M.Children.count(t)},vt=function(t){return ft(t)&&lt(t.then)};var yt=M.createContext({}),_t=yt.Provider,mt=yt.Consumer;function bt(){return M.useContext(yt)}process;function gt(t,e){switch(e.type){case"SET_VALUES":return D({},t,{values:e.payload});case"SET_TOUCHED":return D({},t,{touched:e.payload});case"SET_ERRORS":return D({},t,{errors:e.payload});case"SET_STATUS":return D({},t,{status:e.payload});case"SET_ISVALIDATING":return D({},t,{isValidating:e.payload});case"SET_ISSUBMITTING":return D({},t,{isSubmitting:e.payload});case"SET_FIELD_VALUE":return D({},t,{values:ct(t.values,e.payload.field,e.payload.value)});case"SET_FIELD_TOUCHED":return D({},t,{touched:ct(t.touched,e.payload.field,e.payload.value)});case"SET_FIELD_ERROR":return D({},t,{errors:ct(t.errors,e.payload.field,e.payload.value)});case"RESET_FORM":case"SET_FORMIK_STATE":return D({},t,e.payload);case"SUBMIT_ATTEMPT":return D({},t,{touched:st(t.values,!0),isSubmitting:!0,isValidating:!0,submitCount:t.submitCount+1});case"SUBMIT_FAILURE":return D({},t,{isSubmitting:!1});default:return t}}function St(t){var e=t.validateOnChange,r=void 0===e||e,n=t.validateOnBlur,o=void 0===n||n,a=t.isInitialValid,i=void 0!==a&&a,u=V(t,["validateOnChange","validateOnBlur","isInitialValid"]),c=D({validateOnChange:r,validateOnBlur:o,isInitialValid:i},u),s=M.useRef(c.initialValues),l=M.useRef(!1),f=M.useRef({});M.useEffect(function(){s.current=c.initialValues},[c.initialValues]);var p=M.useReducer(gt,{values:c.initialValues,errors:{},touched:{},isSubmitting:!1,isValidating:!1,submitCount:0}),d=p[0],h=p[1];M.useEffect(function(){l.current&&r&&!d.isSubmitting&&A(d.values)},[d.values,r,d.isSubmitting]),M.useEffect(function(){l.current&&o&&!d.isSubmitting&&A(d.values)},[d.touched,o,d.isSubmitting]),M.useEffect(function(){return l.current=!0,function(){l.current=!1}},[]);var v={resetForm:m,submitForm:P,validateForm:A,validateField:T,setErrors:g,setFieldError:E,setFieldTouched:j,setFieldValue:O,setStatus:I,setSubmitting:R,setTouched:b,setValues:S,setFormikState:w};function y(e){if(dt(e))return function(t){return r(t,e)};function r(t,e){t.persist&&t.persist();var r=t.target,n=r.name,o=e||(n||r.id);h({type:"SET_FIELD_TOUCHED",payload:{field:o,value:!0}})}r(e)}function _(e){if(dt(e))return function(t){return r(t,e)};function r(t,e){var r,n=e,o=t;if(!dt(t)){t.persist&&t.persist();var a=t.target,i=a.type,u=a.name,c=a.value,s=a.checked;n=e||(u||a.id),o=/number|range/.test(i)?(r=parseFloat(c),isNaN(r)?"":r):/checkbox/.test(i)?s:c}n&&h({type:"SET_FIELD_VALUE",payload:{field:n,value:o}})}r(e)}function m(t){var e=t||(null!==s.current?s.current:c.initialValues);h({type:"RESET_FORM",payload:{isSubmitting:!1,isValidating:!1,errors:{},touched:{},status:void 0,values:s.current=e,submitCount:0}})}function b(t){h({type:"SET_TOUCHED",payload:t})}function g(t){h({type:"SET_ERRORS",payload:t})}function S(t){h({type:"SET_VALUES",payload:t})}function E(t,e){h({type:"SET_FIELD_ERROR",payload:{field:t,value:e}})}function O(t,e){h({type:"SET_FIELD_VALUE",payload:{field:t,value:e}})}function j(t,e){void 0===e&&(e=!0),h({type:"SET_FIELD_TOUCHED",payload:{field:t,value:e}})}function T(e){if(null!==f.current&&f.current[e]&&f.current[e].validate&&lt(f.current[e].validate)){var t=ut(d.values,e),r=f.current[e].validate(t);return vt(r)?(h({type:"SET_ISVALIDATING",payload:!0}),r.then(function(t){return t},function(t){return t}).then(function(t){h({type:"SET_FIELD_ERROR",payload:{field:e,value:t}}),h({type:"SET_ISVALIDATING",payload:!1})})):(h({type:"SET_FIELD_ERROR",payload:{field:e,value:r}}),Promise.resolve(r))}return Promise.resolve()}function F(n){if(null===f.current)return Promise.resolve({});var o=Object.keys(f.current).filter(function(t){return null!==f.current&&f.current[t]&&f.current[t].validate&&lt(f.current[t].validate)}),t=0<o.length?o.map(function(t){return r=ut(n,e=t),new Promise(function(t){null!==f.current&&f.current[e]&&f.current[e].validate&&lt(f.current[e].validate)&&t(f.current[e].validate(r))}).then(function(t){return t},function(t){return t});var e,r}):[Promise.resolve("DO_NOT_DELETE_YOU_WILL_BE_FIRED")];return Promise.all(t).then(function(t){return t.reduce(function(t,e,r){return"DO_NOT_DELETE_YOU_WILL_BE_FIRED"===e||e&&(t=ct(t,o[r],e)),t},{})})}function A(t,e){return void 0===t&&(t=d.values),h({type:"SET_ISVALIDATING",payload:!0}),Promise.all([F(t),c.validationSchema?(o=t,a=e,new Promise(function(e){var t=c.validationSchema,r=lt(t)?t(a):t;(a&&r.validateAt?r.validateAt(a,o):jt(o,r)).then(function(){e({})},function(t){e(Ot(t))})})):{},c.validate?(r=t,n=e,new Promise(function(e){var t=c.validate(r,n);void 0===t?e({}):vt(t)?t.then(function(){e({})},function(t){e(t)}):e(t)})):{}]).then(function(t){var e=U.all([t[0],t[1],t[2]],{arrayMerge:Tt});return l.current&&(h({type:"SET_ISVALIDATING",payload:!1}),h({type:"SET_ERRORS",payload:e})),e});var r,n,o,a}function w(t){lt(t)?h({type:"SET_FORMIK_STATE",payload:t(d)}):h({type:"SET_FORMIK_STATE",payload:t})}function I(t){h({type:"SET_STATUS",payload:t})}function R(t){h({type:"SET_ISSUBMITTING",payload:t})}function P(){return h({type:"SUBMIT_ATTEMPT"}),A().then(function(t){0===Object.keys(t).length?c.onSubmit(d.values,v):l.current&&h({type:"SUBMIT_FAILURE"})})}var k=M.useMemo(function(){return!x(s.current,d.values)},[s.current,d.values]),C=M.useMemo(function(){return k?d.errors&&0===Object.keys(d.errors).length:!1!==i&&lt(i)?i(c):i},[d.errors,k,i]);return D({},d,{initialValues:s.current||c.initialValues,handleBlur:y,handleChange:_,handleReset:function(){if(c.onReset){var t=c.onReset(d.values,v);vt(t)?t.then(m):m()}else m()},handleSubmit:function(t){t&&t.preventDefault&&t.preventDefault(),P()},resetForm:m,setErrors:g,setFormikState:w,setFieldTouched:j,setFieldValue:O,setFieldError:E,setStatus:I,setSubmitting:R,setTouched:b,setValues:S,submitForm:P,validateForm:A,validateField:T,isValid:C,dirty:k,unregisterField:function(t){null!==f.current&&delete f.current[t]},registerField:function(t,e){null!==f.current&&(f.current[t]={validate:e.validate})},getFieldProps:function(t,e){var r;return[{name:t,value:!e||"radio"!==e&&"checkbox"!==e?ut(d.values,t):void 0,onChange:_,onBlur:y},(r=t,{value:ut(d.values,r),error:ut(d.errors,r),touch:ut(d.touched,r),initialValue:ut(s.current,r)})]}})}function Et(t){var e=St(t),r=t.component,n=t.children,o=t.render;return M.createElement(_t,{value:e},r?M.createElement(r,e):o?o(e):n?lt(n)?n(e):ht(n)?null:M.Children.only(n):null)}function Ot(t){var e={};if(0===t.inner.length)return ct(e,t.path,t.message);for(var r=0,n=t.inner;r<n.length;r++){var o=n[r];e[o.path]||(e=ct(e,o.path,o.message))}return e}function jt(t,e,r,n){void 0===r&&(r=!1),void 0===n&&(n={});var o={};for(var a in t)if(t.hasOwnProperty(a)){var i=String(a);o[i]=""!==t[i]?t[i]:void 0}return e[r?"validateSync":"validate"](o,{abortEarly:!1,context:n})}function Tt(n,t,o){var a=n.slice();return t.forEach(function(t,e){if(void 0===a[e]){var r=!1!==o.clone&&o.isMergeableObject(t);a[e]=r?U(Array.isArray(t)?[]:{},t,o):t}else o.isMergeableObject(t)?a[e]=U(n[e],t,o):-1===n.indexOf(t)&&a.push(t)}),a}function Ft(t){var e=t.name,r=t.render,n=t.children,o=t.component,a=void 0===o?"input":o,i=V(t,["validate","name","render","children","component"]),u=bt(),c=V(u,["validate","validationSchema"]);M.useEffect(function(){return c.registerField(i.name,{validate:i.validate}),function(){c.unregisterField(i.name)}},[i.name,i.validate]);var s=c.getFieldProps(e,i.type)[0],l={field:s,form:c};if(r)return r(l);if(lt(n))return n(l);if("string"!=typeof a)return M.createElement(a,D({},l,i,{children:n}));var f=i.innerRef,p=V(i,["innerRef"]);return M.createElement(a,D({ref:f},s,p,{children:n}))}var At=Ft;function wt(t){var e=bt();return M.createElement("form",D({onSubmit:e.handleSubmit,onReset:e.handleReset},t))}wt.displayName="Form";var It={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},Rt={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},Pt=Object.defineProperty,kt=Object.getOwnPropertyNames,Ct=Object.getOwnPropertySymbols,Mt=Object.getOwnPropertyDescriptor,Dt=Object.getPrototypeOf,Vt=Dt&&Dt(Object);var xt=function t(e,r,n){if("string"==typeof r)return e;if(Vt){var o=Dt(r);o&&o!==Vt&&t(e,o,n)}var a=kt(r);Ct&&(a=a.concat(Ct(r)));for(var i=0;i<a.length;++i){var u=a[i];if(!(It[u]||Rt[u]||n&&n[u])){var c=Mt(r,u);try{Pt(e,u,c)}catch(t){}}}return e};function Ut(r){var t=function(e){return M.createElement(mt,null,function(t){return M.createElement(r,D({},e,{formik:t}))})};return t.WrappedComponent=r,xt(t,r)}var Lt=function(t,e,r){var n=(t||[]).slice(),o=n[e];return n.splice(e,1),n.splice(r,0,o),n},Nt=function(t,e,r){var n=(t||[]).slice(),o=n[e];return n[e]=n[r],n[r]=o,n},$t=function(t,e,r){var n=(t||[]).slice();return n.splice(e,0,r),n},Bt=function(t,e,r){var n=(t||[]).slice();return n[e]=r,n},Gt=Ut(function(e){function t(t){var s=e.call(this,t)||this;return s.updateArrayField=function(e,r,n){var t=s.props,o=t.name,a=t.formik,i=a.values,u=a.touched,c=a.errors;(0,a.setFormikState)(function(t){return D({},t,{values:ct(t.values,o,e(ut(i,o))),errors:n?ct(t.errors,o,e(ut(c,o))):t.errors,touched:r?ct(t.touched,o,e(ut(u,o))):t.touched})})},s.push=function(e){return s.updateArrayField(function(t){return(t||[]).concat([p(e)])},!1,!1)},s.handlePush=function(t){return function(){return s.push(t)}},s.swap=function(e,r){return s.updateArrayField(function(t){return Nt(t,e,r)},!0,!0)},s.handleSwap=function(t,e){return function(){return s.swap(t,e)}},s.move=function(e,r){return s.updateArrayField(function(t){return Lt(t,e,r)},!0,!0)},s.handleMove=function(t,e){return function(){return s.move(t,e)}},s.insert=function(e,r){return s.updateArrayField(function(t){return $t(t,e,r)},!0,!0)},s.handleInsert=function(t,e){return function(){return s.insert(t,e)}},s.replace=function(e,r){return s.updateArrayField(function(t){return Bt(t,e,r)},!1,!1)},s.handleReplace=function(t,e){return function(){return s.replace(t,e)}},s.unshift=function(r){var n=-1;return s.updateArrayField(function(t){var e=t?[r].concat(t):[r];return n<0&&(n=e.length),e},!0,!0),n},s.handleUnshift=function(t){return function(){return s.unshift(t)}},s.handleRemove=function(t){return function(){return s.remove(t)}},s.handlePop=function(){return function(){return s.pop()}},s.remove=s.remove.bind(s),s.pop=s.pop.bind(s),s}return i(t,e),t.prototype.remove=function(r){var n;return this.updateArrayField(function(t){var e=t?t.slice():[];return n||(n=e[r]),lt(e.splice)&&e.splice(r,1),e},!0,!0),n},t.prototype.pop=function(){var r;return this.updateArrayField(function(t){var e=t;return r||(r=e&&e.pop&&e.pop()),e},!0,!0),r},t.prototype.render=function(){var t={push:this.push,pop:this.pop,swap:this.swap,move:this.move,insert:this.insert,replace:this.replace,unshift:this.unshift,remove:this.remove,handlePush:this.handlePush,handlePop:this.handlePop,handleSwap:this.handleSwap,handleMove:this.handleMove,handleInsert:this.handleInsert,handleReplace:this.handleReplace,handleUnshift:this.handleUnshift,handleRemove:this.handleRemove},e=this.props,r=e.component,n=e.render,o=e.children,a=e.name,i=e.formik,u=V(i,["validate","validationSchema"]),c=D({},t,{form:u,name:a});return r?M.createElement(r,c):n?n(c):o?"function"==typeof o?o(c):ht(o)?null:M.Children.only(o):null},t.defaultProps={validateOnChange:!0},t}(M.Component)),Wt=Ut(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.shouldComponentUpdate=function(t){return ut(this.props.formik.errors,this.props.name)!==ut(t.formik.errors,this.props.name)||ut(this.props.formik.touched,this.props.name)!==ut(t.formik.touched,this.props.name)||Object.keys(this.props).length!==Object.keys(t).length},e.prototype.render=function(){var t=this.props,e=t.component,r=t.formik,n=t.render,o=t.children,a=t.name,i=V(t,["component","formik","render","children","name"]),u=ut(r.touched,a),c=ut(r.errors,a);return u&&c?n?lt(n)?n(c):null:o?lt(o)?o(c):null:e?M.createElement(e,i,c):c:null},e}(M.Component));t.useFormik=St,t.Formik=Et,t.yupToFormErrors=Ot,t.validateYupSchema=jt,t.useField=function(t,e){return bt().getFieldProps(t,e)},t.Field=Ft,t.FastField=At,t.Form=wt,t.withFormik=function(t){var e=t.mapPropsToValues,o=void 0===e?function(t){var e={};for(var r in t)t.hasOwnProperty(r)&&"function"!=typeof t[r]&&(e[r]=t[r]);return e}:e,a=V(t,["mapPropsToValues"]);return function(n){var r=n.displayName||n.name||n.constructor&&n.constructor.name||"Component",t=function(t){function e(){var r=null!==t&&t.apply(this,arguments)||this;return r.validate=function(t){return a.validate(t,r.props)},r.validationSchema=function(){return lt(a.validationSchema)?a.validationSchema(r.props):a.validationSchema},r.handleSubmit=function(t,e){return a.handleSubmit(t,D({},e,{props:r.props}))},r.renderFormComponent=function(t){return M.createElement(n,D({},r.props,t))},r}return i(e,t),e.prototype.render=function(){var t=this.props,e=V(t,["children"]);return M.createElement(Et,D({},e,a,{validate:a.validate&&this.validate,validationSchema:a.validationSchema&&this.validationSchema,initialValues:o(this.props),onSubmit:this.handleSubmit,render:this.renderFormComponent}))},e.displayName="WithFormik("+r+")",e}(M.Component);return xt(t,n)}},t.move=Lt,t.swap=Nt,t.insert=$t,t.replace=Bt,t.FieldArray=Gt,t.getIn=ut,t.setIn=ct,t.setNestedObjectValues=st,t.isFunction=lt,t.isObject=ft,t.isInteger=pt,t.isString=dt,t.isNaN=function(t){return t!=t},t.isEmptyChildren=ht,t.isPromise=vt,t.getActiveElement=function(e){if(void 0===(e=e||("undefined"!=typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(t){return e.body}},t.connect=Ut,t.ErrorMessage=Wt,t.FormikProvider=_t,t.FormikConsumer=mt,t.useFormikContext=bt,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=formik.umd.production.js.map

@@ -7,5 +7,5 @@ export * from './Formik';

export * from './utils';
export * from './FastField';
export * from './types';
export * from './connect';
export * from './ErrorMessage';
export * from './FormikContext';

@@ -26,5 +26,4 @@ import * as React from 'react';

}
export interface FormikActions<Values> {
export interface FormikHelpers<Values> {
setStatus(status?: any): void;
setError(e: any): void;
setErrors(errors: FormikErrors<Values>): void;

@@ -41,10 +40,4 @@ setSubmitting(isSubmitting: boolean): void;

submitForm(): void;
setFormikState<K extends keyof FormikState<Values>>(f: (prevState: Readonly<FormikState<Values>>, props: any) => Pick<FormikState<Values>, K>, callback?: () => any): void;
setFormikState(f: FormikState<Values> | ((prevState: FormikState<Values>) => FormikState<Values>)): void;
}
export interface FormikActions<Values> {
setFieldValue(field: string, value: any): void;
setFieldError(field: string, message: string): void;
setFieldTouched(field: string, isTouched?: boolean): void;
setFormikState<K extends keyof FormikState<Values>>(state: Pick<FormikState<Values>, K>, callback?: () => any): void;
}
export interface FormikHandlers {

@@ -69,13 +62,27 @@ handleSubmit: (e?: React.FormEvent<HTMLFormElement>) => void;

initialValues: Values;
onReset?: (values: Values, formikActions: FormikActions<Values>) => void;
onSubmit: (values: Values, formikActions: FormikActions<Values>) => void;
onReset?: (values: Values, formikHelpers: FormikHelpers<Values>) => void;
onSubmit: (values: Values, formikHelpers: FormikHelpers<Values>) => void;
validationSchema?: any | (() => any);
validate?: ((values: Values) => void | object | Promise<FormikErrors<Values>>);
}
export declare type FormikProps<Values> = FormikSharedConfig & FormikState<Values> & FormikActions<Values> & FormikHandlers & FormikComputedProps<Values> & FormikRegistration;
export declare type FormikProps<Values> = FormikSharedConfig & FormikState<Values> & FormikHelpers<Values> & FormikHandlers & FormikComputedProps<Values> & FormikRegistration & {
getFieldProps(name: string, type?: string): [{
value: any;
name: string;
onChange: ((e: React.ChangeEvent<any>) => void);
onBlur: ((e: any) => void);
}, {
value: any;
error?: string | undefined;
touch: boolean;
initialValue?: any;
}];
};
export interface FormikRegistration {
registerField(name: string, Comp: React.Component<any>): void;
registerField(name: string, fns: {
validate?: ((value: any) => string | Promise<void> | undefined);
}): void;
unregisterField(name: string): void;
}
export declare type FormikContext<Values> = FormikProps<Values> & Pick<FormikConfig<Values>, 'validate' | 'validationSchema'>;
export declare type FormikCtx<Values> = FormikProps<Values> & Pick<FormikConfig<Values>, 'validate' | 'validationSchema'>;
export interface SharedRenderProps<T> {

@@ -82,0 +89,0 @@ component?: string | React.ComponentType<T | void>;

import * as React from 'react';
import { FormikActions, FormikProps, FormikSharedConfig, FormikValues } from './types';
import { FormikHelpers, FormikProps, FormikSharedConfig, FormikValues } from './types';
export declare type InjectedFormikProps<Props, Values> = Props & FormikProps<Values>;
export declare type FormikBag<P, V> = {
props: P;
} & FormikActions<V>;
} & FormikHelpers<V>;
export interface WithFormikConfig<Props, Values extends FormikValues = FormikValues, DeprecatedPayload = Values> extends FormikSharedConfig {

@@ -8,0 +8,0 @@ displayName?: string;

{
"name": "formik",
"description": "Forms in React, without tears",
"version": "1.3.2",
"version": "2.0.0-canary.5a8e912",
"license": "MIT",

@@ -56,4 +56,4 @@ "author": "Jared Palmer <jared@palmer.net>",

"resolutions": {
"@types/react": "16.4.14",
"@types/react-dom": "16.0.7"
"@types/react": "16.7.13",
"@types/react-dom": "16.0.11"
},

@@ -67,4 +67,4 @@ "devDependencies": {

"@types/lodash.topath": "4.5.3",
"@types/react": "^16.4.14",
"@types/react-dom": "^16.0.7",
"@types/react": "^16.7.13",
"@types/react-dom": "^16.0.11",
"@types/react-test-renderer": "15.5.2",

@@ -84,4 +84,4 @@ "@types/warning": "^3.0.0",

"raw-loader": "^0.5.1",
"react": "^16.5.0",
"react-dom": "^16.5.0",
"react": "^16.7.0-alpha.2",
"react-dom": "^16.7.0-alpha.2",
"react-testing-library": "^5.2.3",

@@ -102,3 +102,3 @@ "rimraf": "^2.6.2",

"tslint-react": "^3.6.0",
"typescript": "^3.1.1",
"typescript": "^3.2.1",
"yup": "0.21.3"

@@ -105,0 +105,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc