@jobber/components 4.9.1 → 4.9.2-give-form-.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Form/Form.d.ts +4 -3
- package/dist/Form/index.js +4 -4
- package/package.json +3 -3
package/dist/Form/Form.d.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import React, { ReactNode } from "react";
|
|
2
|
+
import { NestedValue, UnpackNestedValue } from "react-hook-form";
|
|
2
3
|
export interface FormRef {
|
|
3
4
|
submit(): void;
|
|
4
5
|
}
|
|
5
|
-
interface FormProps {
|
|
6
|
+
interface FormProps<T = NestedValue> {
|
|
6
7
|
readonly children: ReactNode;
|
|
7
8
|
/**
|
|
8
9
|
* Callback for when the form has been sucessfully
|
|
9
10
|
* submitted.
|
|
10
11
|
*/
|
|
11
|
-
onSubmit?(): void;
|
|
12
|
+
onSubmit?(data: UnpackNestedValue<T>): void;
|
|
12
13
|
onStateChange?(formState: {
|
|
13
14
|
isDirty: boolean;
|
|
14
15
|
isValid: boolean;
|
|
15
16
|
}): void;
|
|
16
17
|
}
|
|
17
|
-
export declare const Form: React.ForwardRefExoticComponent<FormProps & React.RefAttributes<FormRef>>;
|
|
18
|
+
export declare const Form: React.ForwardRefExoticComponent<FormProps<NestedValue<unknown[] | Record<string, unknown>>> & React.RefAttributes<FormRef>>;
|
|
18
19
|
export {};
|
package/dist/Form/index.js
CHANGED
|
@@ -12,7 +12,7 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
12
12
|
|
|
13
13
|
const Form = React.forwardRef(function InternalForm({ onSubmit, children, onStateChange }, ref) {
|
|
14
14
|
const methods = reactHookForm.useForm({ mode: "onTouched" });
|
|
15
|
-
const { errors, trigger, handleSubmit, formState: { isDirty, isValid }, } = methods;
|
|
15
|
+
const { errors, trigger, handleSubmit, formState: { isDirty, isValid }, getValues, } = methods;
|
|
16
16
|
React.useEffect(() => onStateChange && onStateChange({ isDirty, isValid }), [isDirty, isValid]);
|
|
17
17
|
React.useImperativeHandle(ref, () => ({
|
|
18
18
|
/**
|
|
@@ -24,7 +24,7 @@ const Form = React.forwardRef(function InternalForm({ onSubmit, children, onStat
|
|
|
24
24
|
submit: () => tslib_es6.__awaiter(this, void 0, void 0, function* () {
|
|
25
25
|
const valid = yield trigger();
|
|
26
26
|
if (valid) {
|
|
27
|
-
submitHandler();
|
|
27
|
+
submitHandler(getValues());
|
|
28
28
|
}
|
|
29
29
|
else {
|
|
30
30
|
trigger();
|
|
@@ -43,8 +43,8 @@ const Form = React.forwardRef(function InternalForm({ onSubmit, children, onStat
|
|
|
43
43
|
};
|
|
44
44
|
return (React__default["default"].createElement(reactHookForm.FormProvider, Object.assign({}, methods),
|
|
45
45
|
React__default["default"].createElement(Wrapper, Object.assign({}, formProps, { "data-testid": "atlantis-form" }), children)));
|
|
46
|
-
function submitHandler() {
|
|
47
|
-
onSubmit
|
|
46
|
+
function submitHandler(data) {
|
|
47
|
+
onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(data);
|
|
48
48
|
}
|
|
49
49
|
function errorHandler(errs) {
|
|
50
50
|
const firstErrName = Object.keys(errs)[0];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components",
|
|
3
|
-
"version": "4.9.
|
|
3
|
+
"version": "4.9.2-give-form-.2+4bf78caf",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@jobber/design": "^0.36.0",
|
|
21
|
-
"@jobber/formatters": "
|
|
21
|
+
"@jobber/formatters": "^0.2.2",
|
|
22
22
|
"@jobber/hooks": "^2.1.0",
|
|
23
23
|
"@popperjs/core": "^2.0.6",
|
|
24
24
|
"@std-proposal/temporal": "0.0.1",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"> 1%",
|
|
82
82
|
"IE 10"
|
|
83
83
|
],
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "4bf78caf52b5e976d1192c2b5fd645e132015ea2"
|
|
85
85
|
}
|