From e1026429e9b93f476066fa1f50c2bd54decc191c Mon Sep 17 00:00:00 2001 From: divlo Date: Wed, 14 Oct 2020 10:15:08 +0200 Subject: [PATCH] fix: promise compatible with HandleForm --- .github/workflows/node.js.yml | 4 +- example/package-lock.json | 208 ++++++++++++++++++++-------------- package-lock.json | 12 +- package.json | 4 +- src/index.tsx | 12 +- 5 files changed, 135 insertions(+), 105 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index e7609a2..aef011d 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -21,6 +21,4 @@ jobs: with: node-version: ${{ matrix.node-version }} - run: npm ci - - run: npm run test:build - - run: npm run test:lint - - run: npm run test:unit + - run: npm run test diff --git a/example/package-lock.json b/example/package-lock.json index 90aba5d..0b0c414 100644 --- a/example/package-lock.json +++ b/example/package-lock.json @@ -20,7 +20,7 @@ } }, "@testing-library/jest-dom": { - "version": "file:https:/registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-5.11.4.tgz", + "version": "file:../node_modules/@testing-library/jest-dom", "integrity": "sha512-6RRn3epuweBODDIv3dAlWjOEHQLpGJHB2i912VS3JQtsD22+ENInhdDNl4ZZQiViLlIfFinkSET/J736ytV9sw==", "requires": { "@babel/runtime": "^7.9.2", @@ -61,11 +61,6 @@ "chalk": "^3.0.0" } }, - "@types/color-name": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz", - "integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==" - }, "@types/istanbul-lib-coverage": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.3.tgz", @@ -106,9 +101,9 @@ } }, "@types/yargs": { - "version": "15.0.7", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz", - "integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==", + "version": "15.0.8", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.8.tgz", + "integrity": "sha512-b0BYzFUzBpOhPjpl1wtAHU994jBeKF4TKVlT7ssFv44T617XNcPdRoG4AzHLVshLzlrF7i3lTelH7UbuNYV58Q==", "requires": { "@types/yargs-parser": "*" } @@ -124,11 +119,10 @@ "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==" }, "ansi-styles": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", - "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "requires": { - "@types/color-name": "^1.1.1", "color-convert": "^2.0.1" } }, @@ -302,7 +296,7 @@ } }, "@testing-library/react": { - "version": "file:https:/registry.npmjs.org/@testing-library/react/-/react-11.0.4.tgz", + "version": "file:../node_modules/@testing-library/react", "integrity": "sha512-U0fZO2zxm7M0CB5h1+lh31lbAwMSmDMEMGpMT3BUPJwIjDEKYWOV4dx7lb3x2Ue0Pyt77gmz/VropuJnSz/Iew==", "requires": { "@babel/runtime": "^7.11.2", @@ -362,9 +356,9 @@ } }, "@jest/types": { - "version": "26.3.0", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-26.3.0.tgz", - "integrity": "sha512-BDPG23U0qDeAvU4f99haztXwdAg3hz4El95LkAM+tHAqqhiVzRpEGHHU8EDxT/AnxOrA65YjLBwDahdJ9pTLJQ==", + "version": "26.5.2", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-26.5.2.tgz", + "integrity": "sha512-QDs5d0gYiyetI8q+2xWdkixVQMklReZr4ltw7GFDtb4fuJIBCE6mzj2LnitGqCuAlLap6wPyb8fpoHgwZz5fdg==", "requires": { "@types/istanbul-lib-coverage": "^2.0.0", "@types/istanbul-reports": "^3.0.0", @@ -374,9 +368,9 @@ } }, "@testing-library/dom": { - "version": "7.24.3", - "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-7.24.3.tgz", - "integrity": "sha512-6eW9fUhEbR423FZvoHRwbWm9RUUByLWGayYFNVvqTnQLYvsNpBS4uEuKH9aqr3trhxFwGVneJUonehL3B1sHJw==", + "version": "7.26.0", + "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-7.26.0.tgz", + "integrity": "sha512-fyKFrBbS1IigaE3FV21LyeC7kSGF84lqTlSYdKmGaHuK2eYQ/bXVPM5vAa2wx/AU1iPD6oQHsxy2QQ17q9AMCg==", "requires": { "@babel/code-frame": "^7.10.4", "@babel/runtime": "^7.10.3", @@ -384,6 +378,7 @@ "aria-query": "^4.2.2", "chalk": "^4.1.0", "dom-accessibility-api": "^0.5.1", + "lz-string": "^1.4.4", "pretty-format": "^26.4.2" } }, @@ -392,11 +387,6 @@ "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-4.2.0.tgz", "integrity": "sha512-iIgQNzCm0v7QMhhe4Jjn9uRh+I6GoPmt03CbEtwx3ao8/EfoQcmgtqH4vQ5Db/lxiIGaWDv6nwvunuh0RyX0+A==" }, - "@types/color-name": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz", - "integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==" - }, "@types/istanbul-lib-coverage": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.3.tgz", @@ -419,14 +409,14 @@ } }, "@types/node": { - "version": "14.11.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.11.2.tgz", - "integrity": "sha512-jiE3QIxJ8JLNcb1Ps6rDbysDhN4xa8DJJvuC9prr6w+1tIh+QAbYyNF3tyiZNLDBIuBCf4KEcV2UvQm/V60xfA==" + "version": "14.11.8", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.11.8.tgz", + "integrity": "sha512-KPcKqKm5UKDkaYPTuXSx8wEP7vE9GnuaXIZKijwRYcePpZFDVuy2a57LarFKiORbHOuTOOwYzxVxcUzsh2P2Pw==" }, "@types/yargs": { - "version": "15.0.7", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz", - "integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==", + "version": "15.0.8", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.8.tgz", + "integrity": "sha512-b0BYzFUzBpOhPjpl1wtAHU994jBeKF4TKVlT7ssFv44T617XNcPdRoG4AzHLVshLzlrF7i3lTelH7UbuNYV58Q==", "requires": { "@types/yargs-parser": "*" } @@ -468,11 +458,10 @@ }, "dependencies": { "ansi-styles": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", - "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "requires": { - "@types/color-name": "^1.1.1", "color-convert": "^2.0.1" } }, @@ -523,9 +512,9 @@ "integrity": "sha512-lacdXOimsiD0QyNf9BC/mxivNJ/ybBGJXQFKzRekp1WTHoVUWsUHEn+2T8GJAzzIhyOuXA+gOxCVN3l+5PLPUA==" }, "dom-accessibility-api": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.5.3.tgz", - "integrity": "sha512-yfqzAi1GFxK6EoJIZKgxqJyK6j/OjEFEUi2qkNThD/kUhoCFSG1izq31B5xuxzbJBGw9/67uPtkPMYAzWL7L7Q==" + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.5.4.tgz", + "integrity": "sha512-TvrjBckDy2c6v6RLxPv5QXOnU+SmF9nBII5621Ve5fu6Z/BDrENurBEvlC1f44lKEUVqOpK4w9E5Idc5/EgkLQ==" }, "escape-string-regexp": { "version": "1.0.5", @@ -542,23 +531,27 @@ "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" }, + "lz-string": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.4.4.tgz", + "integrity": "sha1-wNjq82BZ9wV5bh40SBHPTEmNOiY=" + }, "pretty-format": { - "version": "26.4.2", - "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-26.4.2.tgz", - "integrity": "sha512-zK6Gd8zDsEiVydOCGLkoBoZuqv8VTiHyAbKznXe/gaph/DAeZOmit9yMfgIz5adIgAMMs5XfoYSwAX3jcCO1tA==", + "version": "26.5.2", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-26.5.2.tgz", + "integrity": "sha512-VizyV669eqESlkOikKJI8Ryxl/kPpbdLwNdPs2GrbQs18MpySB5S0Yo0N7zkg2xTRiFq4CFw8ct5Vg4a0xP0og==", "requires": { - "@jest/types": "^26.3.0", + "@jest/types": "^26.5.2", "ansi-regex": "^5.0.0", "ansi-styles": "^4.0.0", "react-is": "^16.12.0" }, "dependencies": { "ansi-styles": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", - "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "requires": { - "@types/color-name": "^1.1.1", "color-convert": "^2.0.1" } }, @@ -598,7 +591,7 @@ } }, "@testing-library/user-event": { - "version": "file:https:/registry.npmjs.org/@testing-library/user-event/-/user-event-12.1.7.tgz", + "version": "file:../node_modules/@testing-library/user-event", "integrity": "sha512-wuJiPqSQTVIHsYuumv1PAOBjblSrYA5vyN1nkUDF5HgfuWGz44jQsO22u7PQNkuACGYJE4eU0sybX8CzsySv+Q==", "requires": { "@babel/runtime": "^7.10.2" @@ -620,7 +613,7 @@ } }, "@types/jest": { - "version": "file:https:/registry.npmjs.org/@types/jest/-/jest-26.0.14.tgz", + "version": "file:../node_modules/@types/jest", "integrity": "sha512-Hz5q8Vu0D288x3iWXePSn53W7hAjP0H7EQ6QvDO9c7t46mR0lNOLlfuwQ+JkVxuhygHzlzPX+0jKdA3ZgSh+Vg==", "requires": { "jest-diff": "^25.2.1", @@ -638,11 +631,6 @@ "chalk": "^3.0.0" } }, - "@types/color-name": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz", - "integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==" - }, "@types/istanbul-lib-coverage": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.3.tgz", @@ -666,9 +654,9 @@ } }, "@types/yargs": { - "version": "15.0.7", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz", - "integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==", + "version": "15.0.8", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.8.tgz", + "integrity": "sha512-b0BYzFUzBpOhPjpl1wtAHU994jBeKF4TKVlT7ssFv44T617XNcPdRoG4AzHLVshLzlrF7i3lTelH7UbuNYV58Q==", "requires": { "@types/yargs-parser": "*" } @@ -684,11 +672,10 @@ "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==" }, "ansi-styles": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", - "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "requires": { - "@types/color-name": "^1.1.1", "color-convert": "^2.0.1" } }, @@ -767,11 +754,11 @@ } }, "@types/node": { - "version": "file:https:/registry.npmjs.org/@types/node/-/node-14.11.2.tgz", + "version": "file:../node_modules/@types/node", "integrity": "sha512-jiE3QIxJ8JLNcb1Ps6rDbysDhN4xa8DJJvuC9prr6w+1tIh+QAbYyNF3tyiZNLDBIuBCf4KEcV2UvQm/V60xfA==" }, "@types/react": { - "version": "file:https:/registry.npmjs.org/@types/react/-/react-16.9.50.tgz", + "version": "file:../node_modules/@types/react", "integrity": "sha512-kPx5YsNnKDJejTk1P+lqThwxN2PczrocwsvqXnjvVvKpFescoY62ZiM3TV7dH1T8lFhlHZF+PE5xUyimUwqEGA==", "requires": { "@types/prop-types": "*", @@ -791,7 +778,7 @@ } }, "@types/react-dom": { - "version": "file:https:/registry.npmjs.org/@types/react-dom/-/react-dom-16.9.8.tgz", + "version": "file:../node_modules/@types/react-dom", "integrity": "sha512-ykkPQ+5nFknnlU6lDd947WbQ6TE3NNzbQAkInC2EKY1qeYdTKp7onFusmYZb+ityzx2YviqT6BXSu+LyWWJwcA==", "requires": { "@types/react": "*" @@ -803,9 +790,9 @@ "integrity": "sha512-KfRL3PuHmqQLOG+2tGpRO26Ctg+Cq1E01D2DMriKEATHgWLfeNDmq9e29Q9WIky0dQ3NPkd1mzYH8Lm936Z9qw==" }, "@types/react": { - "version": "16.9.50", - "resolved": "https://registry.npmjs.org/@types/react/-/react-16.9.50.tgz", - "integrity": "sha512-kPx5YsNnKDJejTk1P+lqThwxN2PczrocwsvqXnjvVvKpFescoY62ZiM3TV7dH1T8lFhlHZF+PE5xUyimUwqEGA==", + "version": "16.9.52", + "resolved": "https://registry.npmjs.org/@types/react/-/react-16.9.52.tgz", + "integrity": "sha512-EHRjmnxiNivwhGdMh9sz1Yw9AUxTSZFxKqdBWAAzyZx3sufWwx6ogqHYh/WB1m/I4ZpjkoZLExF5QTy2ekVi/Q==", "requires": { "@types/prop-types": "*", "csstype": "^3.0.2" @@ -819,7 +806,7 @@ } }, "react": { - "version": "file:https:/registry.npmjs.org/react/-/react-16.13.1.tgz", + "version": "file:../node_modules/react", "integrity": "sha512-YMZQQq32xHLX0bz5Mnibv1/LHb3Sqzngu7xstSM+vrkE5Kzr9xE0yMByK5kMoTK30YVJE61WfbxIFFvfeDKT1w==", "requires": { "loose-envify": "^1.1.0", @@ -3261,13 +3248,11 @@ "@babel/runtime": "^7.9.2", "@types/testing-library__jest-dom": "^5.9.1", "aria-query": "^4.2.2", - "chalk": "^3.0.0", "css": "^3.0.0", "css.escape": "^1.5.1", "lodash": "^4.17.15", "redent": "^3.0.0" - }, - "dependencies": {} + } }, "@testing-library/react": { "version": "file:https:/registry.npmjs.org/@testing-library/react/-/react-11.0.4.tgz", @@ -3275,16 +3260,14 @@ "requires": { "@babel/runtime": "^7.11.2", "@testing-library/dom": "^7.24.2" - }, - "dependencies": {} + } }, "@testing-library/user-event": { "version": "file:https:/registry.npmjs.org/@testing-library/user-event/-/user-event-12.1.7.tgz", "integrity": "sha512-wuJiPqSQTVIHsYuumv1PAOBjblSrYA5vyN1nkUDF5HgfuWGz44jQsO22u7PQNkuACGYJE4eU0sybX8CzsySv+Q==", "requires": { "@babel/runtime": "^7.10.2" - }, - "dependencies": {} + } }, "@types/aria-query": { "version": "4.2.0", @@ -3375,13 +3358,13 @@ } }, "@types/jest": { - "version": "file:https:/registry.npmjs.org/@types/jest/-/jest-26.0.14.tgz", + "version": "26.0.14", + "resolved": false, "integrity": "sha512-Hz5q8Vu0D288x3iWXePSn53W7hAjP0H7EQ6QvDO9c7t46mR0lNOLlfuwQ+JkVxuhygHzlzPX+0jKdA3ZgSh+Vg==", "requires": { "jest-diff": "^25.2.1", "pretty-format": "^25.2.1" - }, - "dependencies": {} + } }, "@types/json-schema": { "version": "7.0.6", @@ -3399,7 +3382,8 @@ "integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==" }, "@types/node": { - "version": "file:https:/registry.npmjs.org/@types/node/-/node-14.11.2.tgz", + "version": "14.11.2", + "resolved": false, "integrity": "sha512-jiE3QIxJ8JLNcb1Ps6rDbysDhN4xa8DJJvuC9prr6w+1tIh+QAbYyNF3tyiZNLDBIuBCf4KEcV2UvQm/V60xfA==" }, "@types/parse-json": { @@ -3418,21 +3402,20 @@ "integrity": "sha512-1HcDas8SEj4z1Wc696tH56G8OlRaH/sqZOynNNB+HF0WOeXPaxTtbYzJY2oEfiUxjSKjhCKr+MvR7dCHcEelug==" }, "@types/react": { - "version": "file:https:/registry.npmjs.org/@types/react/-/react-16.9.50.tgz", + "version": "16.9.50", + "resolved": false, "integrity": "sha512-kPx5YsNnKDJejTk1P+lqThwxN2PczrocwsvqXnjvVvKpFescoY62ZiM3TV7dH1T8lFhlHZF+PE5xUyimUwqEGA==", "requires": { "@types/prop-types": "*", "csstype": "^3.0.2" - }, - "dependencies": {} + } }, "@types/react-dom": { "version": "file:https:/registry.npmjs.org/@types/react-dom/-/react-dom-16.9.8.tgz", "integrity": "sha512-ykkPQ+5nFknnlU6lDd947WbQ6TE3NNzbQAkInC2EKY1qeYdTKp7onFusmYZb+ityzx2YviqT6BXSu+LyWWJwcA==", "requires": { "@types/react": "*" - }, - "dependencies": {} + } }, "@types/resolve": { "version": "0.0.8", @@ -15434,8 +15417,7 @@ "loose-envify": "^1.1.0", "object-assign": "^4.1.1", "prop-types": "^15.6.2" - }, - "dependencies": {} + } }, "react-app-polyfill": { "version": "1.0.6", @@ -15816,7 +15798,13 @@ }, "react-dom": { "version": "file:https:/registry.npmjs.org/react-dom/-/react-dom-16.13.1.tgz", - "integrity": "sha512-81PIMmVLnCNLO/fFOQxdQkvEq/+Hfpv24XNJfpyZhTRfO0QcmQIF/PgCa1zCOj2w1hrn12MFLyaJ/G0+Mxtfag==" + "integrity": "sha512-81PIMmVLnCNLO/fFOQxdQkvEq/+Hfpv24XNJfpyZhTRfO0QcmQIF/PgCa1zCOj2w1hrn12MFLyaJ/G0+Mxtfag==", + "requires": { + "loose-envify": "^1.1.0", + "object-assign": "^4.1.1", + "prop-types": "^15.6.2", + "scheduler": "^0.19.1" + } }, "react-error-overlay": { "version": "6.0.7", @@ -15830,7 +15818,53 @@ }, "react-scripts": { "version": "file:https:/registry.npmjs.org/react-scripts/-/react-scripts-3.4.3.tgz", - "integrity": "sha512-oSnoWmii/iKdeQiwaO6map1lUaZLmG0xIUyb/HwCVFLT7gNbj8JZ9RmpvMCZ4fB98ZUMRfNmp/ft8uy/xD1RLA==" + "integrity": "sha512-oSnoWmii/iKdeQiwaO6map1lUaZLmG0xIUyb/HwCVFLT7gNbj8JZ9RmpvMCZ4fB98ZUMRfNmp/ft8uy/xD1RLA==", + "requires": { + "@svgr/webpack": "4.3.3", + "babel-eslint": "10.1.0", + "babel-jest": "^24.9.0", + "babel-loader": "8.1.0", + "babel-plugin-named-asset-import": "^0.3.6", + "babel-preset-react-app": "^9.1.2", + "camelcase": "^5.3.1", + "case-sensitive-paths-webpack-plugin": "2.3.0", + "css-loader": "3.4.2", + "dotenv": "8.2.0", + "dotenv-expand": "5.1.0", + "eslint": "^6.6.0", + "eslint-config-react-app": "^5.2.1", + "eslint-loader": "3.0.3", + "eslint-plugin-flowtype": "4.6.0", + "eslint-plugin-jsx-a11y": "6.2.3", + "eslint-plugin-react-hooks": "^1.6.1", + "file-loader": "4.3.0", + "html-webpack-plugin": "4.0.0-beta.11", + "identity-obj-proxy": "3.0.0", + "jest": "24.9.0", + "jest-environment-jsdom-fourteen": "1.0.1", + "jest-resolve": "24.9.0", + "jest-watch-typeahead": "0.4.2", + "mini-css-extract-plugin": "0.9.0", + "optimize-css-assets-webpack-plugin": "5.0.3", + "pnp-webpack-plugin": "1.6.4", + "postcss-flexbugs-fixes": "4.1.0", + "postcss-loader": "3.0.0", + "postcss-normalize": "8.0.1", + "postcss-preset-env": "6.7.0", + "postcss-safe-parser": "4.0.1", + "react-app-polyfill": "^1.0.6", + "react-dev-utils": "^10.2.1", + "resolve-url-loader": "3.1.1", + "sass-loader": "8.0.2", + "style-loader": "0.23.1", + "terser-webpack-plugin": "2.3.8", + "ts-pnp": "1.1.6", + "url-loader": "2.3.0", + "webpack": "4.42.0", + "webpack-dev-server": "3.11.0", + "webpack-manifest-plugin": "2.2.0", + "workbox-webpack-plugin": "4.3.1" + } }, "readable-stream": { "version": "2.3.7", diff --git a/package-lock.json b/package-lock.json index 7b2cc5d..32c8b21 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3253,9 +3253,9 @@ "dev": true }, "@types/node": { - "version": "14.11.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.11.2.tgz", - "integrity": "sha512-jiE3QIxJ8JLNcb1Ps6rDbysDhN4xa8DJJvuC9prr6w+1tIh+QAbYyNF3tyiZNLDBIuBCf4KEcV2UvQm/V60xfA==", + "version": "14.11.8", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.11.8.tgz", + "integrity": "sha512-KPcKqKm5UKDkaYPTuXSx8wEP7vE9GnuaXIZKijwRYcePpZFDVuy2a57LarFKiORbHOuTOOwYzxVxcUzsh2P2Pw==", "dev": true }, "@types/normalize-package-data": { @@ -3283,9 +3283,9 @@ "dev": true }, "@types/react": { - "version": "16.9.50", - "resolved": "https://registry.npmjs.org/@types/react/-/react-16.9.50.tgz", - "integrity": "sha512-kPx5YsNnKDJejTk1P+lqThwxN2PczrocwsvqXnjvVvKpFescoY62ZiM3TV7dH1T8lFhlHZF+PE5xUyimUwqEGA==", + "version": "16.9.52", + "resolved": "https://registry.npmjs.org/@types/react/-/react-16.9.52.tgz", + "integrity": "sha512-EHRjmnxiNivwhGdMh9sz1Yw9AUxTSZFxKqdBWAAzyZx3sufWwx6ogqHYh/WB1m/I4ZpjkoZLExF5QTy2ekVi/Q==", "dev": true, "requires": { "@types/prop-types": "*", diff --git a/package.json b/package.json index 5367d22..ea06bb2 100644 --- a/package.json +++ b/package.json @@ -52,8 +52,8 @@ "@testing-library/react": "^11.0.4", "@testing-library/user-event": "^12.1.7", "@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", "@typescript-eslint/eslint-plugin": "^4.0.1", "@typescript-eslint/parser": "^4.0.1", diff --git a/src/index.tsx b/src/index.tsx index 3a62d58..de37889 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -8,9 +8,7 @@ export interface FormDataObject { export type HandleForm = ( formData: FormDataObject, formElement: HTMLFormElement -) => void - -type Omit = Pick> +) => void | Promise interface ReactFormProps extends Omit, 'onSubmit' | 'onChange'> {} @@ -28,18 +26,18 @@ const Form = (props: FormProps): JSX.Element => { const { onSubmit, onChange, children, ...rest } = props const formRef = useRef(null) - const handleSubmit = (event: React.FormEvent): void => { + const handleSubmit = async (event: React.FormEvent): Promise => { event.preventDefault() if (onSubmit != null) { const formData = getFormDataObject(formRef.current as HTMLFormElement) - onSubmit(formData, formRef.current as HTMLFormElement) + await onSubmit(formData, formRef.current as HTMLFormElement) } } - const handleChange = (): void => { + const handleChange = async (): Promise => { if (onChange != null) { const formData = getFormDataObject(formRef.current as HTMLFormElement) - onChange(formData, formRef.current as HTMLFormElement) + await onChange(formData, formRef.current as HTMLFormElement) } }