Comparing version 2.0.5 to 2.0.6
@@ -340,3 +340,3 @@ "use strict"; | ||
var value = getValue(name); | ||
var fieldValue = getValue(name); | ||
@@ -347,4 +347,4 @@ var update = function update(newvalue) { | ||
return { | ||
value: value, | ||
var payload = { | ||
fieldValue: fieldValue, | ||
update: update, | ||
@@ -358,2 +358,3 @@ showError: showError, | ||
}; | ||
return payload; | ||
}; | ||
@@ -360,0 +361,0 @@ |
{ | ||
"name": "formact", | ||
"version": "2.0.5", | ||
"version": "2.0.6", | ||
"description": "Context for React form components with validation", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -367,2 +367,13 @@ // @flow | ||
export type FieldPayload = { | ||
fieldValue?: string, | ||
update: (value: string) => any, | ||
showError: boolean, | ||
errorMessage?: string, | ||
onBlur: (e?: Object) => any, | ||
submit: () => any, | ||
submitting: boolean, | ||
valid: boolean, | ||
} | ||
export const useField = (props: FieldProps) => { | ||
@@ -436,6 +447,16 @@ const { name } = props | ||
const value = getValue(name) | ||
const fieldValue = getValue(name) | ||
const update = (newvalue: string) => updateValue(name, newvalue) | ||
return { value, update, showError, error, onBlur, submit, submitting, valid } | ||
const payload: FieldPayload = { | ||
fieldValue, | ||
update, | ||
showError, | ||
error, | ||
onBlur, | ||
submit, | ||
submitting, | ||
valid, | ||
} | ||
return payload | ||
} | ||
@@ -448,3 +469,6 @@ | ||
return (props: Object) => { | ||
const fieldProps = useField({ ...props, defaultErrorMessages }) | ||
const fieldProps: FieldPayload = useField({ | ||
...props, | ||
defaultErrorMessages, | ||
}) | ||
@@ -451,0 +475,0 @@ return <Component {...props} {...fieldProps} /> |
Sorry, the diff of this file is not supported yet
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
33151
791