react-component-form
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -5,4 +5,3 @@ import React from 'react'; | ||
} | ||
export declare type HandleForm = (formData: FormDataObject, formElement: HTMLFormElement) => void; | ||
declare type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>; | ||
export declare type HandleForm = (formData: FormDataObject, formElement: HTMLFormElement) => void | Promise<void>; | ||
interface ReactFormProps extends Omit<React.HTMLProps<HTMLFormElement>, 'onSubmit' | 'onChange'> { | ||
@@ -9,0 +8,0 @@ } |
@@ -43,7 +43,15 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var handleSubmit = function handleSubmit(event) { | ||
event.preventDefault(); | ||
try { | ||
event.preventDefault(); | ||
if (onSubmit != null) { | ||
var formData = getFormDataObject(formRef.current); | ||
onSubmit(formData, formRef.current); | ||
var _temp2 = function () { | ||
if (onSubmit != null) { | ||
var formData = getFormDataObject(formRef.current); | ||
return Promise.resolve(onSubmit(formData, formRef.current)).then(function () {}); | ||
} | ||
}(); | ||
return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0); | ||
} catch (e) { | ||
return Promise.reject(e); | ||
} | ||
@@ -53,5 +61,13 @@ }; | ||
var handleChange = function handleChange() { | ||
if (onChange != null) { | ||
var formData = getFormDataObject(formRef.current); | ||
onChange(formData, formRef.current); | ||
try { | ||
var _temp4 = function () { | ||
if (onChange != null) { | ||
var formData = getFormDataObject(formRef.current); | ||
return Promise.resolve(onChange(formData, formRef.current)).then(function () {}); | ||
} | ||
}(); | ||
return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(function () {}) : void 0); | ||
} catch (e) { | ||
return Promise.reject(e); | ||
} | ||
@@ -58,0 +74,0 @@ }; |
@@ -40,7 +40,15 @@ import React, { useRef } from 'react'; | ||
var handleSubmit = function handleSubmit(event) { | ||
event.preventDefault(); | ||
try { | ||
event.preventDefault(); | ||
if (onSubmit != null) { | ||
var formData = getFormDataObject(formRef.current); | ||
onSubmit(formData, formRef.current); | ||
var _temp2 = function () { | ||
if (onSubmit != null) { | ||
var formData = getFormDataObject(formRef.current); | ||
return Promise.resolve(onSubmit(formData, formRef.current)).then(function () {}); | ||
} | ||
}(); | ||
return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0); | ||
} catch (e) { | ||
return Promise.reject(e); | ||
} | ||
@@ -50,5 +58,13 @@ }; | ||
var handleChange = function handleChange() { | ||
if (onChange != null) { | ||
var formData = getFormDataObject(formRef.current); | ||
onChange(formData, formRef.current); | ||
try { | ||
var _temp4 = function () { | ||
if (onChange != null) { | ||
var formData = getFormDataObject(formRef.current); | ||
return Promise.resolve(onChange(formData, formRef.current)).then(function () {}); | ||
} | ||
}(); | ||
return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(function () {}) : void 0); | ||
} catch (e) { | ||
return Promise.reject(e); | ||
} | ||
@@ -55,0 +71,0 @@ }; |
{ | ||
"name": "react-component-form", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Manage React Forms with ease.", | ||
@@ -49,2 +49,4 @@ "author": "Divlo <contact@divlo.fr>", | ||
"devDependencies": { | ||
"@commitlint/cli": "^11.0.0", | ||
"@commitlint/config-conventional": "^11.0.0", | ||
"@testing-library/jest-dom": "^5.11.4", | ||
@@ -54,4 +56,4 @@ "@testing-library/react": "^11.0.4", | ||
"@types/jest": "^26.0.14", | ||
"@types/node": "^14.11.2", | ||
"@types/react": "^16.9.50", | ||
"@types/node": "^14.11.8", | ||
"@types/react": "^16.9.52", | ||
"@types/react-dom": "^16.9.8", | ||
@@ -58,0 +60,0 @@ "@typescript-eslint/eslint-plugin": "^4.0.1", |
Sorry, the diff of this file is not supported yet
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
17711
148
32