Comparing version 0.5.3 to 0.6.0
@@ -1,9 +0,8 @@ | ||
/// <reference types="react" /> | ||
import { ComponentEnhancer } from 'recompose'; | ||
import * as React from 'react'; | ||
/** | ||
* Given an error from yup validation, turn it into form errors | ||
* Transform Yup ValidationError to a more usable object | ||
*/ | ||
export declare function yupToFormErrors(yupError: any): FormikErrors; | ||
/** | ||
* Given a FormState, return a `touched` value with all of the fields touched. | ||
* Given an object, map keys to boolean | ||
*/ | ||
@@ -13,13 +12,31 @@ export declare function touchAllFields<T>(fields: T): { | ||
}; | ||
export declare function validateFormData<T>(data: T, schema: any, setErrors: (errors: FormikErrors) => void): Promise<boolean>; | ||
/** | ||
* Validate a yup schema. | ||
*/ | ||
export declare function validateFormData<T>(data: T, schema: any): Promise<void>; | ||
export interface FormikValues { | ||
[field: string]: any; | ||
} | ||
export interface FormikErrors { | ||
[field: string]: string; | ||
} | ||
export interface FormikTouched { | ||
[field: string]: boolean; | ||
} | ||
/** | ||
* Formik configuration options | ||
*/ | ||
export interface FormikConfig<Props, Values, Payload> { | ||
displayName: string; | ||
displayName?: string; | ||
mapPropsToValues?: (props: Props) => Values; | ||
mapValuesToPayload?: (values: Values) => Payload; | ||
validationSchema: any; | ||
handleSubmit: (payload: Payload, formikBag: FormikBag) => void; | ||
handleSubmit: (payload: Payload, formikBag: FormikBag<Props, Values>) => void; | ||
} | ||
export interface InjectedFormikProps<Props, Values> { | ||
values: Values; | ||
error: any; | ||
/** | ||
* Formik state tree | ||
*/ | ||
export interface FormikState<V> { | ||
values: V; | ||
error?: any; | ||
/** map of field names to specific error for that field */ | ||
@@ -31,15 +48,8 @@ errors: FormikErrors; | ||
isSubmitting: boolean; | ||
handleSubmit: (e: React.FormEvent<HTMLFormElement>) => void; | ||
handleChange: (e: React.ChangeEvent<any>) => void; | ||
handleBlur: (e: any) => void; | ||
handleChangeValue: (name: string, value: any) => void; | ||
} | ||
/** | ||
* Formik state helpers | ||
*/ | ||
export interface FormikActions<P> { | ||
setError: (e: any) => void; | ||
resetForm: (nextProps?: Props) => void; | ||
handleReset: () => void; | ||
} | ||
export interface FormikBag { | ||
props: { | ||
[field: string]: any; | ||
}; | ||
setError: (error: any) => void; | ||
setErrors: (errors: FormikErrors) => void; | ||
@@ -49,12 +59,31 @@ setSubmitting: (isSubmitting: boolean) => void; | ||
setValues: (values: FormikValues) => void; | ||
resetForm: (nextProps?: P) => void; | ||
} | ||
export interface FormikValues { | ||
[field: string]: any; | ||
/** | ||
* Formik form event handlers | ||
*/ | ||
export interface FormikHandlers { | ||
handleSubmit: (e: React.FormEvent<HTMLFormElement>) => void; | ||
handleChange: (e: React.ChangeEvent<any>) => void; | ||
handleBlur: (e: any) => void; | ||
handleChangeValue: (name: string, value: any) => void; | ||
handleReset: () => void; | ||
} | ||
export interface FormikErrors { | ||
[field: string]: string; | ||
/** | ||
* State, handlers, and helpers injected as props into the wrapped form component. | ||
*/ | ||
export declare type InjectedFormikProps<Props, Values = Props> = Props & FormikState<Values> & FormikActions<Props> & FormikHandlers; | ||
/** | ||
* Formik actions + { props } | ||
*/ | ||
export declare type FormikBag<P, V> = { | ||
props: P; | ||
} & FormikActions<P>; | ||
export declare type CompositeComponent<P> = React.ComponentClass<P> | React.StatelessComponent<P>; | ||
export interface ComponentDecorator<TOwnProps, TMergedProps> { | ||
(component: CompositeComponent<TMergedProps>): React.ComponentClass<TOwnProps>; | ||
} | ||
export interface FormikTouched { | ||
[field: string]: boolean; | ||
export interface InferableComponentDecorator<TOwnProps> { | ||
<T extends CompositeComponent<TOwnProps>>(component: T): T; | ||
} | ||
export default function Formik<Props, Values extends FormikValues, Payload>({displayName, mapPropsToValues, mapValuesToPayload, validationSchema, handleSubmit}: FormikConfig<Props, Values, Payload>): ComponentEnhancer<{}, any>; | ||
export default function formik<Props = {}, Values extends FormikValues = Props, Payload = Values>({displayName, mapPropsToValues, mapValuesToPayload, validationSchema, handleSubmit}: FormikConfig<Props, Values, Payload>): ComponentDecorator<Props, InjectedFormikProps<Props, Values>>; |
220
es6/index.js
import * as tslib_1 from "tslib"; | ||
import { compose, mapProps, setDisplayName, withState, } from 'recompose'; | ||
import * as React from 'react'; | ||
var hoistNonReactStatics = require('hoist-non-react-statics'); | ||
/** | ||
* Given an error from yup validation, turn it into form errors | ||
* Transform Yup ValidationError to a more usable object | ||
*/ | ||
@@ -17,3 +18,3 @@ export function yupToFormErrors(yupError) { | ||
/** | ||
* Given a FormState, return a `touched` value with all of the fields touched. | ||
* Given an object, map keys to boolean | ||
*/ | ||
@@ -28,3 +29,6 @@ export function touchAllFields(fields) { | ||
} | ||
export function validateFormData(data, schema, setErrors) { | ||
/** | ||
* Validate a yup schema. | ||
*/ | ||
export function validateFormData(data, schema) { | ||
var validateData = {}; | ||
@@ -39,16 +43,11 @@ for (var k in data) { | ||
} | ||
return schema.validate(validateData, { abortEarly: false }).then(function () { | ||
setErrors({}); | ||
return true; | ||
}, function (err) { | ||
setErrors(yupToFormErrors(err)); | ||
return false; | ||
}); | ||
return schema.validate(validateData, { abortEarly: false }); | ||
} | ||
export default function Formik(_a) { | ||
var displayName = _a.displayName, _b = _a.mapPropsToValues, mapPropsToValues = _b === void 0 ? function (props) { | ||
export default function formik(_a) { | ||
var displayName = _a.displayName, _b = _a.mapPropsToValues, mapPropsToValues = _b === void 0 ? function (vanillaProps) { | ||
var values = {}; | ||
for (var k in props) { | ||
if (props.hasOwnProperty(k) && typeof props[k] !== 'function') { | ||
values[k] = props[k]; | ||
for (var k in vanillaProps) { | ||
if (vanillaProps.hasOwnProperty(k) && | ||
typeof vanillaProps[k] !== 'function') { | ||
values[k] = vanillaProps[k]; | ||
} | ||
@@ -62,72 +61,123 @@ } | ||
} : _c, validationSchema = _a.validationSchema, handleSubmit = _a.handleSubmit; | ||
return compose(setDisplayName(displayName), withState('values', 'setValues', function (props) { return mapPropsToValues(props); }), withState('errors', 'setErrors', {}), withState('error', 'setError', undefined), withState('touched', 'setTouched', {}), withState('isSubmitting', 'setSubmitting', false), mapProps(function (_a) { | ||
var values = _a.values, error = _a.error, errors = _a.errors, touched = _a.touched, isSubmitting = _a.isSubmitting, setError = _a.setError, setErrors = _a.setErrors, setValues = _a.setValues, setTouched = _a.setTouched, setSubmitting = _a.setSubmitting, otherProps = tslib_1.__rest(_a, ["values", "error", "errors", "touched", "isSubmitting", "setError", "setErrors", "setValues", "setTouched", "setSubmitting"]); | ||
return (tslib_1.__assign({ handleChange: function (e) { | ||
e.persist(); | ||
var _a = e.target, type = _a.type, name = _a.name, id = _a.id, value = _a.value, checked = _a.checked; | ||
var field = name ? name : id; | ||
var val = /number|range/.test(type) | ||
? parseFloat(value) | ||
: /checkbox/.test(type) ? checked : value; | ||
// Set form fields by name | ||
setValues(tslib_1.__assign({}, values, (_b = {}, _b[field] = val, _b))); | ||
// Validate against schema | ||
validateFormData(tslib_1.__assign({}, values, (_c = {}, _c[field] = val, _c)), validationSchema, setErrors); | ||
var _b, _c; | ||
}, handleBlur: function (e) { | ||
e.persist(); | ||
var _a = e.target, name = _a.name, id = _a.id; | ||
var field = name ? name : id; | ||
setTouched(tslib_1.__assign({}, touched, (_b = {}, _b[field] = true, _b))); | ||
var _b; | ||
}, handleChangeValue: function (field, value) { | ||
// Set changed fields as touched | ||
setTouched(tslib_1.__assign({}, touched, (_a = {}, _a[field] = true, _a))); | ||
// Set form fields by name | ||
setValues(tslib_1.__assign({}, values, (_b = {}, _b[field] = value, _b))); | ||
// Validate against schema | ||
validateFormData(tslib_1.__assign({}, values, (_c = {}, _c[field] = value, _c)), validationSchema, setErrors); | ||
var _a, _b, _c; | ||
}, handleSubmit: function (e) { | ||
e.preventDefault(); | ||
setTouched(touchAllFields(values)); | ||
setSubmitting(true); | ||
validateFormData(values, validationSchema, setErrors).then(function (isValid) { | ||
if (isValid) { | ||
handleSubmit(mapValuesToPayload(values), { | ||
setTouched: setTouched, | ||
setErrors: setErrors, | ||
setError: setError, | ||
setSubmitting: setSubmitting, | ||
setValues: setValues, | ||
props: otherProps, | ||
return function wrapWithFormik(WrappedComponent) { | ||
var Formik = (function (_super) { | ||
tslib_1.__extends(Formik, _super); | ||
function Formik(props) { | ||
var _this = _super.call(this, props) || this; | ||
_this.setErrors = function (errors) { | ||
_this.setState({ errors: errors }); | ||
}; | ||
_this.setTouched = function (touched) { | ||
_this.setState({ touched: touched }); | ||
}; | ||
_this.setValues = function (values) { | ||
_this.setState({ values: values }); | ||
}; | ||
_this.setError = function (error) { | ||
_this.setState({ error: error }); | ||
}; | ||
_this.setSubmitting = function (isSubmitting) { | ||
_this.setState({ isSubmitting: isSubmitting }); | ||
}; | ||
_this.handleChange = function (e) { | ||
e.persist(); | ||
var _a = e.target, type = _a.type, name = _a.name, id = _a.id, value = _a.value, checked = _a.checked; | ||
var field = name ? name : id; | ||
var val = /number|range/.test(type) | ||
? parseFloat(value) | ||
: /checkbox/.test(type) ? checked : value; | ||
var values = _this.state.values; | ||
// Set form fields by name | ||
_this.setState(function (state) { | ||
return (tslib_1.__assign({}, state, { values: tslib_1.__assign({}, values, (_a = {}, _a[field] = val, _a)) })); | ||
var _a; | ||
}); | ||
// Validate against schema | ||
validateFormData(tslib_1.__assign({}, values, (_b = {}, _b[field] = val, _b)), validationSchema).then(function () { return _this.setState({ errors: {} }); }, function (err) { return _this.setState({ errors: yupToFormErrors(err) }); }); | ||
var _b; | ||
}; | ||
_this.handleSubmit = function (e) { | ||
e.preventDefault(); | ||
// setTouched(); | ||
// setSubmitting(true); | ||
_this.setState({ | ||
touched: touchAllFields(_this.state.values), | ||
isSubmitting: true, | ||
}); | ||
var values = _this.state.values; | ||
// Validate against schema | ||
validateFormData(values, validationSchema).then(function () { | ||
_this.setState({ errors: {} }); | ||
handleSubmit(mapValuesToPayload(_this.state.values), { | ||
setTouched: _this.setTouched, | ||
setErrors: _this.setErrors, | ||
setError: _this.setError, | ||
setSubmitting: _this.setSubmitting, | ||
setValues: _this.setValues, | ||
resetForm: _this.resetForm, | ||
props: _this.props, | ||
}); | ||
} | ||
}); | ||
}, resetForm: function (nextProps) { | ||
setSubmitting(false); | ||
setErrors({}); | ||
setTouched({}); | ||
setError(undefined); | ||
if (nextProps) { | ||
setValues(mapPropsToValues(nextProps)); | ||
} | ||
else { | ||
setValues(mapPropsToValues(otherProps)); | ||
} | ||
}, handleReset: function () { | ||
setSubmitting(false); | ||
setErrors({}); | ||
setTouched({}); | ||
setError(undefined); | ||
setValues(mapPropsToValues(otherProps)); | ||
}, setValues: setValues, | ||
setErrors: setErrors, | ||
setSubmitting: setSubmitting, | ||
errors: errors, | ||
error: error, | ||
isSubmitting: isSubmitting, | ||
touched: touched, | ||
values: values }, otherProps)); | ||
})); | ||
}, function (err) { return _this.setState({ errors: yupToFormErrors(err) }); }); | ||
}; | ||
_this.handleBlur = function (e) { | ||
e.persist(); | ||
var _a = e.target, name = _a.name, id = _a.id; | ||
var field = name ? name : id; | ||
var touched = _this.state.touched; | ||
_this.setTouched(tslib_1.__assign({}, touched, (_b = {}, _b[field] = true, _b))); | ||
var _b; | ||
}; | ||
_this.handleChangeValue = function (field, value) { | ||
var _a = _this.state, touched = _a.touched, values = _a.values; | ||
// Set touched and form fields by name | ||
_this.setState(function (state) { | ||
return (tslib_1.__assign({}, state, { values: tslib_1.__assign({}, values, (_a = {}, _a[field] = value, _a)), touched: tslib_1.__assign({}, touched, (_b = {}, _b[field] = true, _b)) })); | ||
var _a, _b; | ||
}); | ||
// Validate against schema | ||
validateFormData(tslib_1.__assign({}, values, (_b = {}, _b[field] = value, _b)), validationSchema).then(function () { return _this.setState({ errors: {} }); }, function (err) { return _this.setState({ errors: yupToFormErrors(err) }); }); | ||
var _b; | ||
}; | ||
_this.resetForm = function (nextProps) { | ||
_this.setState({ | ||
isSubmitting: false, | ||
errors: {}, | ||
touched: {}, | ||
error: undefined, | ||
values: nextProps | ||
? mapPropsToValues(nextProps) | ||
: mapPropsToValues(_this.props), | ||
}); | ||
}; | ||
_this.handleReset = function () { | ||
_this.setState({ | ||
isSubmitting: false, | ||
errors: {}, | ||
touched: {}, | ||
error: undefined, | ||
values: mapPropsToValues(_this.props), | ||
}); | ||
}; | ||
_this.state = { | ||
values: mapPropsToValues(props), | ||
errors: {}, | ||
touched: {}, | ||
isSubmitting: false, | ||
}; | ||
return _this; | ||
} | ||
Formik.prototype.render = function () { | ||
return (React.createElement(WrappedComponent, tslib_1.__assign({}, this.props, this.state, { setError: this.setError, setErrors: this.setErrors, setSubmitting: this.setSubmitting, setTouched: this.setTouched, setValues: this.setValues, resetForm: this.resetForm, handleReset: this.handleReset, handleSubmit: this.handleSubmit, handleChange: this.handleChange, handleBlur: this.handleBlur, handleChangeValue: this.handleChangeValue }))); | ||
}; | ||
Formik.displayName = "Formik(" + (displayName || | ||
WrappedComponent.displayName || | ||
WrappedComponent.name || | ||
'Component') + ")"; | ||
Formik.WrappedComponent = WrappedComponent; | ||
return Formik; | ||
}(React.Component)); | ||
// Make sure we preserve any custom statics on the original component. | ||
// @see https://github.com/apollographql/react-apollo/blob/master/src/graphql.tsx | ||
return hoistNonReactStatics(Formik, WrappedComponent); | ||
}; | ||
} |
@@ -1,9 +0,8 @@ | ||
/// <reference types="react" /> | ||
import { ComponentEnhancer } from 'recompose'; | ||
import * as React from 'react'; | ||
/** | ||
* Given an error from yup validation, turn it into form errors | ||
* Transform Yup ValidationError to a more usable object | ||
*/ | ||
export declare function yupToFormErrors(yupError: any): FormikErrors; | ||
/** | ||
* Given a FormState, return a `touched` value with all of the fields touched. | ||
* Given an object, map keys to boolean | ||
*/ | ||
@@ -13,13 +12,31 @@ export declare function touchAllFields<T>(fields: T): { | ||
}; | ||
export declare function validateFormData<T>(data: T, schema: any, setErrors: (errors: FormikErrors) => void): Promise<boolean>; | ||
/** | ||
* Validate a yup schema. | ||
*/ | ||
export declare function validateFormData<T>(data: T, schema: any): Promise<void>; | ||
export interface FormikValues { | ||
[field: string]: any; | ||
} | ||
export interface FormikErrors { | ||
[field: string]: string; | ||
} | ||
export interface FormikTouched { | ||
[field: string]: boolean; | ||
} | ||
/** | ||
* Formik configuration options | ||
*/ | ||
export interface FormikConfig<Props, Values, Payload> { | ||
displayName: string; | ||
displayName?: string; | ||
mapPropsToValues?: (props: Props) => Values; | ||
mapValuesToPayload?: (values: Values) => Payload; | ||
validationSchema: any; | ||
handleSubmit: (payload: Payload, formikBag: FormikBag) => void; | ||
handleSubmit: (payload: Payload, formikBag: FormikBag<Props, Values>) => void; | ||
} | ||
export interface InjectedFormikProps<Props, Values> { | ||
values: Values; | ||
error: any; | ||
/** | ||
* Formik state tree | ||
*/ | ||
export interface FormikState<V> { | ||
values: V; | ||
error?: any; | ||
/** map of field names to specific error for that field */ | ||
@@ -31,15 +48,8 @@ errors: FormikErrors; | ||
isSubmitting: boolean; | ||
handleSubmit: (e: React.FormEvent<HTMLFormElement>) => void; | ||
handleChange: (e: React.ChangeEvent<any>) => void; | ||
handleBlur: (e: any) => void; | ||
handleChangeValue: (name: string, value: any) => void; | ||
} | ||
/** | ||
* Formik state helpers | ||
*/ | ||
export interface FormikActions<P> { | ||
setError: (e: any) => void; | ||
resetForm: (nextProps?: Props) => void; | ||
handleReset: () => void; | ||
} | ||
export interface FormikBag { | ||
props: { | ||
[field: string]: any; | ||
}; | ||
setError: (error: any) => void; | ||
setErrors: (errors: FormikErrors) => void; | ||
@@ -49,12 +59,31 @@ setSubmitting: (isSubmitting: boolean) => void; | ||
setValues: (values: FormikValues) => void; | ||
resetForm: (nextProps?: P) => void; | ||
} | ||
export interface FormikValues { | ||
[field: string]: any; | ||
/** | ||
* Formik form event handlers | ||
*/ | ||
export interface FormikHandlers { | ||
handleSubmit: (e: React.FormEvent<HTMLFormElement>) => void; | ||
handleChange: (e: React.ChangeEvent<any>) => void; | ||
handleBlur: (e: any) => void; | ||
handleChangeValue: (name: string, value: any) => void; | ||
handleReset: () => void; | ||
} | ||
export interface FormikErrors { | ||
[field: string]: string; | ||
/** | ||
* State, handlers, and helpers injected as props into the wrapped form component. | ||
*/ | ||
export declare type InjectedFormikProps<Props, Values = Props> = Props & FormikState<Values> & FormikActions<Props> & FormikHandlers; | ||
/** | ||
* Formik actions + { props } | ||
*/ | ||
export declare type FormikBag<P, V> = { | ||
props: P; | ||
} & FormikActions<P>; | ||
export declare type CompositeComponent<P> = React.ComponentClass<P> | React.StatelessComponent<P>; | ||
export interface ComponentDecorator<TOwnProps, TMergedProps> { | ||
(component: CompositeComponent<TMergedProps>): React.ComponentClass<TOwnProps>; | ||
} | ||
export interface FormikTouched { | ||
[field: string]: boolean; | ||
export interface InferableComponentDecorator<TOwnProps> { | ||
<T extends CompositeComponent<TOwnProps>>(component: T): T; | ||
} | ||
export default function Formik<Props, Values extends FormikValues, Payload>({displayName, mapPropsToValues, mapValuesToPayload, validationSchema, handleSubmit}: FormikConfig<Props, Values, Payload>): ComponentEnhancer<{}, any>; | ||
export default function formik<Props = {}, Values extends FormikValues = Props, Payload = Values>({displayName, mapPropsToValues, mapValuesToPayload, validationSchema, handleSubmit}: FormikConfig<Props, Values, Payload>): ComponentDecorator<Props, InjectedFormikProps<Props, Values>>; |
{ | ||
"name": "formik", | ||
"description": "An elegant way to handle forms in React", | ||
"version": "0.5.3", | ||
"version": "0.6.0", | ||
"license": "MIT", | ||
@@ -29,5 +29,5 @@ "author": "Jared Palmer <jared@palmer.net>", | ||
"dependencies": { | ||
"hoist-non-react-statics": "^1.2.0", | ||
"react": "^15.5.4", | ||
"react-dom": "^15.5.4", | ||
"recompose": "^0.23.5", | ||
"yup": "^0.21.3" | ||
@@ -34,0 +34,0 @@ }, |
@@ -1,9 +0,8 @@ | ||
/// <reference types="react" /> | ||
import { ComponentEnhancer } from 'recompose'; | ||
import * as React from 'react'; | ||
/** | ||
* Given an error from yup validation, turn it into form errors | ||
* Transform Yup ValidationError to a more usable object | ||
*/ | ||
export declare function yupToFormErrors(yupError: any): FormikErrors; | ||
/** | ||
* Given a FormState, return a `touched` value with all of the fields touched. | ||
* Given an object, map keys to boolean | ||
*/ | ||
@@ -13,13 +12,31 @@ export declare function touchAllFields<T>(fields: T): { | ||
}; | ||
export declare function validateFormData<T>(data: T, schema: any, setErrors: (errors: FormikErrors) => void): Promise<boolean>; | ||
/** | ||
* Validate a yup schema. | ||
*/ | ||
export declare function validateFormData<T>(data: T, schema: any): Promise<void>; | ||
export interface FormikValues { | ||
[field: string]: any; | ||
} | ||
export interface FormikErrors { | ||
[field: string]: string; | ||
} | ||
export interface FormikTouched { | ||
[field: string]: boolean; | ||
} | ||
/** | ||
* Formik configuration options | ||
*/ | ||
export interface FormikConfig<Props, Values, Payload> { | ||
displayName: string; | ||
displayName?: string; | ||
mapPropsToValues?: (props: Props) => Values; | ||
mapValuesToPayload?: (values: Values) => Payload; | ||
validationSchema: any; | ||
handleSubmit: (payload: Payload, formikBag: FormikBag) => void; | ||
handleSubmit: (payload: Payload, formikBag: FormikBag<Props, Values>) => void; | ||
} | ||
export interface InjectedFormikProps<Props, Values> { | ||
values: Values; | ||
error: any; | ||
/** | ||
* Formik state tree | ||
*/ | ||
export interface FormikState<V> { | ||
values: V; | ||
error?: any; | ||
/** map of field names to specific error for that field */ | ||
@@ -31,15 +48,8 @@ errors: FormikErrors; | ||
isSubmitting: boolean; | ||
handleSubmit: (e: React.FormEvent<HTMLFormElement>) => void; | ||
handleChange: (e: React.ChangeEvent<any>) => void; | ||
handleBlur: (e: any) => void; | ||
handleChangeValue: (name: string, value: any) => void; | ||
} | ||
/** | ||
* Formik state helpers | ||
*/ | ||
export interface FormikActions<P> { | ||
setError: (e: any) => void; | ||
resetForm: (nextProps?: Props) => void; | ||
handleReset: () => void; | ||
} | ||
export interface FormikBag { | ||
props: { | ||
[field: string]: any; | ||
}; | ||
setError: (error: any) => void; | ||
setErrors: (errors: FormikErrors) => void; | ||
@@ -49,12 +59,31 @@ setSubmitting: (isSubmitting: boolean) => void; | ||
setValues: (values: FormikValues) => void; | ||
resetForm: (nextProps?: P) => void; | ||
} | ||
export interface FormikValues { | ||
[field: string]: any; | ||
/** | ||
* Formik form event handlers | ||
*/ | ||
export interface FormikHandlers { | ||
handleSubmit: (e: React.FormEvent<HTMLFormElement>) => void; | ||
handleChange: (e: React.ChangeEvent<any>) => void; | ||
handleBlur: (e: any) => void; | ||
handleChangeValue: (name: string, value: any) => void; | ||
handleReset: () => void; | ||
} | ||
export interface FormikErrors { | ||
[field: string]: string; | ||
/** | ||
* State, handlers, and helpers injected as props into the wrapped form component. | ||
*/ | ||
export declare type InjectedFormikProps<Props, Values = Props> = Props & FormikState<Values> & FormikActions<Props> & FormikHandlers; | ||
/** | ||
* Formik actions + { props } | ||
*/ | ||
export declare type FormikBag<P, V> = { | ||
props: P; | ||
} & FormikActions<P>; | ||
export declare type CompositeComponent<P> = React.ComponentClass<P> | React.StatelessComponent<P>; | ||
export interface ComponentDecorator<TOwnProps, TMergedProps> { | ||
(component: CompositeComponent<TMergedProps>): React.ComponentClass<TOwnProps>; | ||
} | ||
export interface FormikTouched { | ||
[field: string]: boolean; | ||
export interface InferableComponentDecorator<TOwnProps> { | ||
<T extends CompositeComponent<TOwnProps>>(component: T): T; | ||
} | ||
export default function Formik<Props, Values extends FormikValues, Payload>({displayName, mapPropsToValues, mapValuesToPayload, validationSchema, handleSubmit}: FormikConfig<Props, Values, Payload>): ComponentEnhancer<{}, any>; | ||
export default function formik<Props = {}, Values extends FormikValues = Props, Payload = Values>({displayName, mapPropsToValues, mapValuesToPayload, validationSchema, handleSubmit}: FormikConfig<Props, Values, Payload>): ComponentDecorator<Props, InjectedFormikProps<Props, Values>>; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
636
138800
- Removedrecompose@^0.23.5
- Removedchange-emitter@0.1.6(transitive)
- Removedrecompose@0.23.5(transitive)
- Removedsymbol-observable@1.2.0(transitive)