All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- [
useForm] Fixed an issue where failed submissions would reset the form.
- [
useForm] Fixed an issue that allowed submission with invalid forms.
- [
useForm,useFields] Change to values object type toany.
- [
useForm,useSubmission] Fixed an issue with asynconSubmithandlers that resulted in theonSubmitfunction being called with empty values.
- [
useForm]resetfunction now supports an optionalevent: SyntheticEventparameter. This parameter is used to call.closest('form').reset()on theevent.targetso that uncontrolled forms like those composed usinguseSettersAsRefEventHandlerare resetted. - [
useForm]onSubmitnow resets uncontrolled forms. See comment above aboutresetfunction.
- [
useForm,useSubmission] Both hooks now return asubmitFeedbackobject that has anerrorormessageproperty. Theerrorproperty is set whenonSubmitthrows an error or returnsPromise.reject(). Themessageproperty is set after callingsetFeedback. Only one of those properties can be set at the same time. Also note that throwing an error or returningPromise.reject()aborts the form reset step. - [
useForm,useSubmission]onSubmitnow accepts avaluesobject as the first parameter and anonSubmitModifiersobject as a new second argument.onSubmitModifiersis an object that consist of asetError: (name: string, error: string) => voidfunction, asetFeedback: (feedback: string) => voidfunction, and the optionalevent: SyntheticEventevent object.setErrorwill set an error value for the input with the specified name as well as prevent the form from resetting.setFeedbackwill set themessageproperty for thesubmitFeedbackvalue (see bullet above).eventis the event that was passed to thesubmitfunction. - [
useSubmission] Added three more props (reset,setError,values) to help streamline the useSubmission hook.resetis a function used to reset the form values after submission.setErroris a fucntion used to set an error for a sepecified form input.valuesis an optional object map of the form values.
- [
useForm,useValidation] Fixed an issues with theerrorstypes.
- [
useForm,useTouch] Adds a isDirty field that is set to true when any field is touched.
- [
useForm] Fixed an issue whereonSubmitwas being called with the current values.
- [
useSubmission]onSubmitwill be called with the current Event ifsubmitis called with an event. - [
useForm]onSubmitthe second argument will be the event ifsubmitis called with an event.
- [
useValidation] RemovedisValidatingfrom the hook. A hook to track if a function is currently being called will be added in a later update.
- Typescript definition files
- [
useSettersAsRefEventHandler] The object api now supports amountedValuesproperty that is the shape of a value object map (eg{email: 'user@example.com'}). When the ref callback is mounted on an element and themountedValuesproperty is set, then the specified element'svalueproperty will be set to the correspondingmountedValuesproperty that shares the same name as the specified element's name propert (egelement.value = mountedValues[element.name]). - [
useValidation] the returned promise forvalidateandvalidateByNameno longer resolves to a map of errors. - [
useSubmission] Now accepts an optionaldisabledflag that is used to prevent submission if the value istrue. This hook also no longer accepts avalidatorthat resolves to a map of errors. The preferred way of preventing submission is to set thedisabledflag to true. Thevalidatorprop is now optional.
- [
useValidateAsSetter] Added a hook that supports usingvalidatefromuseFromwithuseSettersAsRefEventHandler, anduseSettersAsEventHandler
- [
useForm] addsuseConstraintssupport via the optionalconstraintsparameter
- [
useForm] RenameddefaultValuesparameter toinitialValues - [
useSettersAsRefEventHandler]eventis optional when using the hook with options. - [
useSettersAsRefEventHandler]handlersmust be called with an array of function when using the hook with options.
- [
useNormalizers] added a hook (useNormalizers) for normalizing input values - [
normalizeNestedObjects] added auseNormalizercompatible function that handles nested objects and arrays
- [
useSettersAsEventHandler] Changed the third argument that is invoked with each handler from an Event to an EventTarget
- [
useForm,useFields] Resetting fields now sets the value to empty string if no default value
- [
useConstraint] Update the number regex pattern
- [
useError,useFields,useTouch] Added the ability to set values using a function callback
- [
useValidation] Removed the unusedexpectedFieldsparameter
- [
useValidation] Preventsvalidatefrom calling validators twice whenuseValidationis called with a validation map.
- [
useConstraint] Updated the url regex pattern - [
useConstraint] Updated all constraints to accept0as a non-empty value
- [
useConstraint] Fixed an issue with setting custom error messages for required constraints