@paragrav/rhf-utils 0.0.86 → 0.0.88
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/esm/form/Form.mjs +10 -9
- package/dist/esm/form/_FormBase.mjs +13 -9
- package/dist/types/client/config.d.ts +5 -4
- package/dist/types/client/index.d.ts +4 -4
- package/dist/types/client/zod/context/RhfUtilsClientForZodContextProvider.d.ts +1 -1
- package/dist/types/client/zod/createRhfUtilsClientForZod.d.ts +1 -1
- package/dist/types/devtool/LazyDevTool.d.ts +1 -1
- package/dist/types/errors/consoleErrors.d.ts +1 -1
- package/dist/types/errors/flat/getFlatFieldErrors.d.ts +1 -1
- package/dist/types/errors/flat/useRefdFieldErrorsMemo.d.ts +1 -1
- package/dist/types/errors/orphan/getOrphansFromFieldErrors.d.ts +1 -1
- package/dist/types/errors/outputErrors.d.ts +1 -1
- package/dist/types/errors/root/getRootsFromFieldErrors.d.ts +1 -1
- package/dist/types/form/Form.d.ts +2 -2
- package/dist/types/form/FormProviders.d.ts +2 -2
- package/dist/types/form/FormWithProviders.d.ts +1 -1
- package/dist/types/form/_Controller.d.ts +1 -1
- package/dist/types/form/_FormBase.d.ts +4 -2
- package/dist/types/form/useForm.d.ts +8 -8
- package/dist/types/form/useFormOptions.d.ts +2 -2
- package/dist/types/submit/error/FormSubmitError.d.ts +1 -1
- package/dist/types/submit/error/setCtxErrorsByFormSubmitError.d.ts +2 -2
- package/dist/types/submit/useResetFormOnSubmitSuccessful.d.ts +1 -1
- package/package.json +20 -20
package/dist/esm/form/Form.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { FormSubmitError as E } from "../submit/error/FormSubmitError.mjs";
|
|
|
6
6
|
import V from "../submit/error/setCtxErrorsByFormSubmitError.mjs";
|
|
7
7
|
import w from "./_Controller.mjs";
|
|
8
8
|
import z from "./_FormBase.mjs";
|
|
9
|
-
function
|
|
9
|
+
function J({
|
|
10
10
|
formId: B,
|
|
11
11
|
formRef: u,
|
|
12
12
|
//
|
|
@@ -46,16 +46,16 @@ function I({
|
|
|
46
46
|
l,
|
|
47
47
|
e
|
|
48
48
|
);
|
|
49
|
-
},
|
|
49
|
+
}, y = {
|
|
50
50
|
formId: B,
|
|
51
51
|
formRef: u,
|
|
52
52
|
ctx: l,
|
|
53
53
|
options: r,
|
|
54
54
|
Controller: w
|
|
55
|
-
},
|
|
55
|
+
}, c = (t) => {
|
|
56
56
|
var m;
|
|
57
57
|
const e = (m = a == null ? void 0 : a.Children) == null ? void 0 : m[t];
|
|
58
|
-
return e && /* @__PURE__ */ C(e, { ...
|
|
58
|
+
return e && /* @__PURE__ */ C(e, { ...y });
|
|
59
59
|
};
|
|
60
60
|
return /* @__PURE__ */ S(
|
|
61
61
|
z,
|
|
@@ -64,20 +64,21 @@ function I({
|
|
|
64
64
|
style: {
|
|
65
65
|
position: "relative"
|
|
66
66
|
},
|
|
67
|
+
config: a,
|
|
68
|
+
formRef: u,
|
|
67
69
|
...d,
|
|
68
70
|
className: [r == null ? void 0 : r.classNames, d == null ? void 0 : d.className].filter(Boolean).join(" "),
|
|
69
71
|
onSubmit: j,
|
|
70
|
-
formRef: u,
|
|
71
72
|
children: [
|
|
72
|
-
|
|
73
|
+
c("top"),
|
|
73
74
|
(r == null ? void 0 : r.devTool) !== "disabled" && /* @__PURE__ */ C(v, { placement: "top-right", ...r == null ? void 0 : r.devTool }),
|
|
74
|
-
x && /* @__PURE__ */ C(x, { ...
|
|
75
|
+
x && /* @__PURE__ */ C(x, { ...y }),
|
|
75
76
|
_,
|
|
76
|
-
|
|
77
|
+
c("bottom")
|
|
77
78
|
]
|
|
78
79
|
}
|
|
79
80
|
);
|
|
80
81
|
}
|
|
81
82
|
export {
|
|
82
|
-
|
|
83
|
+
J as default
|
|
83
84
|
};
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as p, jsx as s } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
|
-
const
|
|
4
|
-
|
|
3
|
+
const l = ({
|
|
4
|
+
config: e,
|
|
5
|
+
formRef: t,
|
|
5
6
|
antiCsrfToken: r,
|
|
6
7
|
children: o,
|
|
7
|
-
...
|
|
8
|
-
}) =>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
...m
|
|
9
|
+
}) => {
|
|
10
|
+
const n = (e == null ? void 0 : e.FormComponent) ?? "form";
|
|
11
|
+
return /* @__PURE__ */ p(n, { role: "form", ...m, ref: t, children: [
|
|
12
|
+
r && /* @__PURE__ */ s("input", { type: "hidden", name: "anticsrftoken", value: r }),
|
|
13
|
+
o
|
|
14
|
+
] });
|
|
15
|
+
};
|
|
12
16
|
export {
|
|
13
|
-
|
|
17
|
+
l as default
|
|
14
18
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { FormSubmitError } from '../submit/error/FormSubmitError';
|
|
2
|
-
import { UseFormOptions } from '../form/useFormOptions';
|
|
3
|
-
import { UseFormFieldsProps } from '../form/useForm';
|
|
4
|
-
import { FormChildrenSlots } from '../form/Form';
|
|
5
1
|
import { UseFormProps } from 'react-hook-form';
|
|
2
|
+
import { FormChildrenSlots } from '../form/Form';
|
|
3
|
+
import { UseFormFieldsProps } from '../form/useForm';
|
|
4
|
+
import { UseFormOptions } from '../form/useFormOptions';
|
|
5
|
+
import { FormSubmitError } from '../submit/error/FormSubmitError';
|
|
6
6
|
|
|
7
7
|
export type ClientConfig = {
|
|
8
8
|
/**
|
|
@@ -34,4 +34,5 @@ export type ClientConfig = {
|
|
|
34
34
|
* Handle non-{@link FormSubmitError} errors. Optionally, return {@link FormSubmitError} to merge into context errors.
|
|
35
35
|
*/
|
|
36
36
|
onSubmitError?: (error: unknown) => FormSubmitError | undefined;
|
|
37
|
+
FormComponent?: React.FC<React.PropsWithChildren<React.HTMLAttributes<HTMLFormElement>>>;
|
|
37
38
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { UseFormProps, UseFormReturn } from '../form/useForm';
|
|
2
|
-
import { SafeFieldValues } from '../form/SafeFieldValues';
|
|
3
|
-
import { FormWithProvidersProps } from '../form/FormWithProviders';
|
|
4
|
-
import { ClientConfig } from './config';
|
|
5
1
|
import { Resolver } from 'react-hook-form';
|
|
2
|
+
import { ClientConfig } from './config';
|
|
3
|
+
import { FormWithProvidersProps } from '../form/FormWithProviders';
|
|
4
|
+
import { SafeFieldValues } from '../form/SafeFieldValues';
|
|
5
|
+
import { UseFormProps, UseFormReturn } from '../form/useForm';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Generic object schema type.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SafeFieldValues } from '../../form/SafeFieldValues';
|
|
2
1
|
import { z } from 'zod';
|
|
2
|
+
import { SafeFieldValues } from '../../form/SafeFieldValues';
|
|
3
3
|
|
|
4
4
|
export type ZodTypeFieldValues = z.ZodType<SafeFieldValues>;
|
|
5
5
|
declare const createRhfUtilsClientForZod: (config: import('../config').ClientConfig) => import('..').CreateRhfUtilsClient<ZodTypeFieldValues, "_input", "_output">;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FlatFieldErrors } from '../flat/types';
|
|
2
1
|
import { FieldErrors } from 'react-hook-form';
|
|
2
|
+
import { FlatFieldErrors } from '../flat/types';
|
|
3
3
|
|
|
4
4
|
declare const getOrphansFromFieldErrors: (errors: FieldErrors, parentElement: Pick<HTMLElement, 'querySelector'>) => FlatFieldErrors;
|
|
5
5
|
export default getOrphansFromFieldErrors;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FlatFieldErrors } from '../flat/types';
|
|
2
1
|
import { FieldErrors } from 'react-hook-form';
|
|
2
|
+
import { FlatFieldErrors } from '../flat/types';
|
|
3
3
|
|
|
4
4
|
declare const getRootsFromFieldErrors: (errors: FieldErrors) => FlatFieldErrors;
|
|
5
5
|
export default getRootsFromFieldErrors;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { UseFormProps } from './useForm';
|
|
2
|
-
import { SafeFieldValues } from './SafeFieldValues';
|
|
3
1
|
import { default as React } from 'react';
|
|
2
|
+
import { SafeFieldValues } from './SafeFieldValues';
|
|
3
|
+
import { UseFormProps } from './useForm';
|
|
4
4
|
|
|
5
5
|
export type FormChildrenSlots = 'top' | 'bottom';
|
|
6
6
|
export type FormProps<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues> = React.PropsWithChildren<{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { UseFormOptions } from './useFormOptions';
|
|
2
|
-
import { SafeFieldValues } from './SafeFieldValues';
|
|
3
1
|
import { UseFormReturn } from 'react-hook-form';
|
|
2
|
+
import { SafeFieldValues } from './SafeFieldValues';
|
|
3
|
+
import { UseFormOptions } from './useFormOptions';
|
|
4
4
|
|
|
5
5
|
export type FormProvidersProps<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues> = React.PropsWithChildren<{
|
|
6
6
|
formId: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { UseFormProps } from './useForm';
|
|
2
1
|
import { SafeFieldValues } from './SafeFieldValues';
|
|
2
|
+
import { UseFormProps } from './useForm';
|
|
3
3
|
|
|
4
4
|
export type FormWithProvidersProps<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues> = React.PropsWithChildren<UseFormProps<TFieldValues, TTransformedValues>>;
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SafeFieldValues } from './SafeFieldValues';
|
|
2
1
|
import { ControllerProps, FieldPath } from 'react-hook-form';
|
|
2
|
+
import { SafeFieldValues } from './SafeFieldValues';
|
|
3
3
|
|
|
4
4
|
export type _ControllerProps<TFieldValues extends SafeFieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = Omit<ControllerProps<TFieldValues, TName>, 'control'>;
|
|
5
5
|
declare function _Controller<TFieldValues extends SafeFieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>(props: _ControllerProps<TFieldValues, TName>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
+
import { ClientConfig } from '../client/config';
|
|
2
3
|
|
|
3
|
-
export type FormBaseProps = React.
|
|
4
|
+
export type FormBaseProps = React.PropsWithChildren<React.HTMLAttributes<HTMLFormElement>> & {
|
|
5
|
+
config?: ClientConfig;
|
|
4
6
|
formRef: React.RefObject<HTMLFormElement>;
|
|
5
7
|
antiCsrfToken?: string;
|
|
6
8
|
};
|
|
7
|
-
declare const _FormBase: ({ formRef, antiCsrfToken, children, ...props }: FormBaseProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
declare const _FormBase: ({ config, formRef, antiCsrfToken, children, ...props }: FormBaseProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
10
|
export default _FormBase;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { UseFormOptions } from './useFormOptions';
|
|
2
|
-
import { SafeFieldValues } from './SafeFieldValues';
|
|
3
|
-
import { FormProvidersProps } from './FormProviders';
|
|
4
|
-
import { FormProps } from './Form';
|
|
5
|
-
import { default as _Controller } from './_Controller';
|
|
6
|
-
import { FormSubmitError } from '../submit/error/FormSubmitError';
|
|
7
|
-
import { ClientConfig } from '../client/config';
|
|
8
|
-
import { SubmitErrorHandler, UseFormProps as RhfUseFormProps, UseFormReturn as RhfUseFormReturn } from 'react-hook-form';
|
|
9
1
|
import { default as React } from 'react';
|
|
2
|
+
import { SubmitErrorHandler, UseFormProps as RhfUseFormProps, UseFormReturn as RhfUseFormReturn } from 'react-hook-form';
|
|
3
|
+
import { ClientConfig } from '../client/config';
|
|
4
|
+
import { FormSubmitError } from '../submit/error/FormSubmitError';
|
|
5
|
+
import { default as _Controller } from './_Controller';
|
|
6
|
+
import { FormProps } from './Form';
|
|
7
|
+
import { FormProvidersProps } from './FormProviders';
|
|
8
|
+
import { SafeFieldValues } from './SafeFieldValues';
|
|
9
|
+
import { UseFormOptions } from './useFormOptions';
|
|
10
10
|
|
|
11
11
|
export type UseFormFieldsProps<TFieldValues extends SafeFieldValues = SafeFieldValues, TTransformedValues extends SafeFieldValues = SafeFieldValues> = {
|
|
12
12
|
formId: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Register } from '../register';
|
|
2
|
-
import { default as useResetFormAfterSubmitSuccessful } from '../submit/useResetFormOnSubmitSuccessful';
|
|
3
1
|
import { DevtoolUIProps } from '@hookform/devtools/dist/devToolUI';
|
|
2
|
+
import { default as useResetFormAfterSubmitSuccessful } from '../submit/useResetFormOnSubmitSuccessful';
|
|
3
|
+
import { Register } from '../register';
|
|
4
4
|
|
|
5
5
|
export type UseFormOptions = {
|
|
6
6
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SafeFieldValues } from '../../form/SafeFieldValues';
|
|
2
1
|
import { FieldPath } from 'react-hook-form';
|
|
2
|
+
import { SafeFieldValues } from '../../form/SafeFieldValues';
|
|
3
3
|
|
|
4
4
|
export declare class FormSubmitError<TFieldValues extends SafeFieldValues = SafeFieldValues> extends Error {
|
|
5
5
|
errors: Record<FieldPath<TFieldValues> | `root.${string}`, {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FormSubmitError } from './FormSubmitError';
|
|
2
|
-
import { SafeFieldValues } from '../../form/SafeFieldValues';
|
|
3
1
|
import { UseFormReturn } from 'react-hook-form';
|
|
2
|
+
import { SafeFieldValues } from '../../form/SafeFieldValues';
|
|
3
|
+
import { FormSubmitError } from './FormSubmitError';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Handle thrown {@link FormSubmitError}.
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@paragrav/rhf-utils",
|
|
3
3
|
"author": "paragrav.dev",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.88",
|
|
6
6
|
"description": "Integration utilities for react-hook-form.",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"sideEffects": false,
|
|
@@ -26,21 +26,21 @@
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@hookform/devtools": "
|
|
30
|
-
"@hookform/resolvers": "
|
|
31
|
-
"flat": "
|
|
32
|
-
"react": "
|
|
33
|
-
"react-dom": "
|
|
34
|
-
"react-hook-form": "
|
|
35
|
-
"zod": "
|
|
29
|
+
"@hookform/devtools": "4",
|
|
30
|
+
"@hookform/resolvers": "3",
|
|
31
|
+
"flat": "6",
|
|
32
|
+
"react": "18",
|
|
33
|
+
"react-dom": "18",
|
|
34
|
+
"react-hook-form": "7",
|
|
35
|
+
"zod": "3"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@playwright/experimental-ct-react": "^1.
|
|
39
|
-
"@playwright/test": "^1.
|
|
38
|
+
"@playwright/experimental-ct-react": "^1.44.0",
|
|
39
|
+
"@playwright/test": "^1.44.0",
|
|
40
40
|
"@rollup/plugin-typescript": "^11.1.6",
|
|
41
|
-
"@types/node": "^20.12.
|
|
42
|
-
"@types/react": "^18.
|
|
43
|
-
"@types/react-dom": "^18.
|
|
41
|
+
"@types/node": "^20.12.11",
|
|
42
|
+
"@types/react": "^18.3.1",
|
|
43
|
+
"@types/react-dom": "^18.3.0",
|
|
44
44
|
"@typescript-eslint/eslint-plugin": "^7.8.0",
|
|
45
45
|
"@typescript-eslint/parser": "^7.8.0",
|
|
46
46
|
"@vitejs/plugin-react": "^4.2.1",
|
|
@@ -50,18 +50,18 @@
|
|
|
50
50
|
"eslint-import-resolver-typescript": "^3.6.1",
|
|
51
51
|
"eslint-plugin-import": "^2.29.1",
|
|
52
52
|
"eslint-plugin-react": "^7.34.1",
|
|
53
|
-
"eslint-plugin-react-hooks": "^4.6.
|
|
54
|
-
"eslint-plugin-simple-import-sort": "^12.
|
|
55
|
-
"happy-dom": "^14.
|
|
53
|
+
"eslint-plugin-react-hooks": "^4.6.2",
|
|
54
|
+
"eslint-plugin-simple-import-sort": "^12.1.0",
|
|
55
|
+
"happy-dom": "^14.10.1",
|
|
56
56
|
"husky": "^9.0.11",
|
|
57
57
|
"lint-staged": "^15.2.2",
|
|
58
58
|
"prettier": "^3.2.5",
|
|
59
59
|
"rollup": "^4.17.2",
|
|
60
|
-
"typescript": "^5.4.
|
|
60
|
+
"typescript": "^5.4.5",
|
|
61
61
|
"vite": "^5.2.11",
|
|
62
|
-
"vite-plugin-dts": "^3.
|
|
62
|
+
"vite-plugin-dts": "^3.9.1",
|
|
63
63
|
"vite-tsconfig-paths": "^4.3.2",
|
|
64
|
-
"vitest": "^1.
|
|
64
|
+
"vitest": "^1.6.0"
|
|
65
65
|
},
|
|
66
66
|
"engines": {
|
|
67
67
|
"node": ">=20.12",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"lint": "eslint --ignore-path ./.gitignore --ext ts,tsx --report-unused-disable-directives --max-warnings 0 .",
|
|
93
93
|
"preinstall": "npx only-allow pnpm",
|
|
94
94
|
"preview": "vite preview --config vite.config.dev.ts",
|
|
95
|
-
"test": "vitest",
|
|
95
|
+
"test": "vitest run",
|
|
96
96
|
"test:ct": "playwright test -c playwright-ct.config.ts",
|
|
97
97
|
"test:ct:ui": "playwright test -c playwright-ct.config.ts --ui",
|
|
98
98
|
"tsc": "tsc",
|