@paragrav/rhf-utils 0.0.91 → 0.0.92

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.
@@ -1,49 +1,55 @@
1
- import { jsx as a } from "react/jsx-runtime";
2
- import d from "../form/FormWithProviders.mjs";
3
- import l from "../form/useForm.mjs";
4
- const v = (t) => (r) => {
5
- const i = u(
6
- t,
1
+ import { jsx as h } from "react/jsx-runtime";
2
+ import F from "../form/FormWithProviders.mjs";
3
+ import a from "../form/useForm.mjs";
4
+ const v = (s) => (r) => {
5
+ const i = d(
6
+ s,
7
7
  r
8
8
  );
9
9
  return {
10
- useForm: (e, o) => l(
11
- i(e, o)
12
- ),
13
- FormWithProviders: F(t, r)
10
+ useForm: (n, o) => {
11
+ const t = i(n, o);
12
+ return {
13
+ ...a(t),
14
+ FormWithProviders: ({
15
+ children: e
16
+ }) => /* @__PURE__ */ h(F, { ...t, children: e })
17
+ };
18
+ },
19
+ FormWithProviders: l(s, r)
14
20
  };
15
- }, F = (t, r) => function({
16
- schema: e,
17
- children: o,
18
- ...s
19
- }) {
20
- const n = u(t, r);
21
- return /* @__PURE__ */ a(
22
- d,
23
- {
24
- ...n(e, s),
25
- children: o
26
- }
27
- );
28
- }, u = (t, r) => function(e, o) {
29
- var s, n, m, f, h;
21
+ }, d = (s, r) => function(n, o) {
22
+ var t, e, m, u, f;
30
23
  return {
31
24
  ...o,
32
25
  config: r,
33
26
  rhf: {
34
- ...(s = r.defaultOptions) == null ? void 0 : s.rhf,
27
+ ...(t = r.defaultOptions) == null ? void 0 : t.rhf,
35
28
  ...o.rhf,
36
- resolver: t(e)
29
+ resolver: s(n)
37
30
  },
38
31
  options: {
39
- ...(n = r.defaultOptions) == null ? void 0 : n.form,
32
+ ...(e = r.defaultOptions) == null ? void 0 : e.form,
40
33
  ...o.options,
41
34
  classNames: [
42
- ...((f = (m = r.defaultOptions) == null ? void 0 : m.form) == null ? void 0 : f.classNames) ?? [],
43
- ...((h = o.options) == null ? void 0 : h.classNames) ?? []
35
+ ...((u = (m = r.defaultOptions) == null ? void 0 : m.form) == null ? void 0 : u.classNames) ?? [],
36
+ ...((f = o.options) == null ? void 0 : f.classNames) ?? []
44
37
  ]
45
38
  }
46
39
  };
40
+ }, l = (s, r) => function({
41
+ schema: n,
42
+ children: o,
43
+ ...t
44
+ }) {
45
+ const e = d(s, r);
46
+ return /* @__PURE__ */ h(
47
+ F,
48
+ {
49
+ ...e(n, t),
50
+ children: o
51
+ }
52
+ );
47
53
  };
48
54
  export {
49
55
  v as createRhfUtilsClient
@@ -1,7 +1,7 @@
1
- import o from "../../../utils/createContext.mjs";
2
- const [, t, s] = o(), r = t, n = () => t().useForm;
1
+ import s from "../../../utils/createContext.mjs";
2
+ const [, t, n] = s(), i = t, l = (o, e) => t().useForm(o, e);
3
3
  export {
4
- s as _RhfUtilsClientForZodContextProvider,
5
- r as default,
6
- n as useRhfUtilsForm
4
+ n as _RhfUtilsClientForZodContextProvider,
5
+ i as default,
6
+ l as useRhfUtilsZodForm
7
7
  };
@@ -1,5 +1,5 @@
1
1
  import { default as e } from "./client/zod/context/RhfUtilsClientForZodContextProvider.mjs";
2
- import { default as s, useRhfUtilsForm as a } from "./client/zod/context/useRhfUtilsClientForZodContext.mjs";
2
+ import { default as s, useRhfUtilsZodForm as a } from "./client/zod/context/useRhfUtilsClientForZodContext.mjs";
3
3
  import { default as f } from "./client/zod/createRhfUtilsClientForZod.mjs";
4
4
  import { default as l } from "./devtool/LazyDevTool.mjs";
5
5
  import { default as p } from "./errors/flat/context/FlatFieldErrorsContextProvider.mjs";
@@ -15,7 +15,7 @@ import { default as I } from "./errors/orphan/useOrphanFormErrorsToConsole.mjs";
15
15
  import { default as g } from "./errors/root/RootErrorsListFromFlatFieldErrorsContext.mjs";
16
16
  import { default as B } from "./errors/root/useRootFormFieldErrorsMemo.mjs";
17
17
  import { default as A } from "./errors/useFormErrorConsoleDebug.mjs";
18
- import { default as L } from "./errors/useFormErrorsEffect.mjs";
18
+ import { default as D } from "./errors/useFormErrorsEffect.mjs";
19
19
  import { default as H } from "./errors/useFormErrorsIfAny.mjs";
20
20
  import { default as q } from "./errors/useFormErrorsTransformMemo.mjs";
21
21
  import { default as W } from "./errors/useFormRequestSubmit.mjs";
@@ -62,7 +62,7 @@ export {
62
62
  F as useFlatFieldErrorsContext,
63
63
  Y as useForm,
64
64
  A as useFormErrorConsoleDebug,
65
- L as useFormErrorsEffect,
65
+ D as useFormErrorsEffect,
66
66
  H as useFormErrorsIfAny,
67
67
  q as useFormErrorsTransformMemo,
68
68
  ar as useFormGroupChildIsMountedTracker,
@@ -83,7 +83,7 @@ export {
83
83
  gr as useResetFormAfterSubmitSuccessful,
84
84
  Ir as useResetFormOnSubmitError,
85
85
  s as useRhfUtilsClientForZodContext,
86
- a as useRhfUtilsForm,
86
+ a as useRhfUtilsZodForm,
87
87
  B as useRootFormFieldErrorsMemo,
88
88
  Br as useSubmitFormOnChange
89
89
  };
@@ -1,44 +1,44 @@
1
1
  import m from "react";
2
2
  import { useForm as F } from "react-hook-form";
3
3
  import { FormSubmitError as a } from "../submit/error/FormSubmitError.mjs";
4
- const I = ({
4
+ const P = ({
5
5
  onSubmit: t,
6
6
  onSubmitError: e,
7
7
  onSubmitInvalid: f,
8
- defaultValues: p,
9
- Fields: n,
8
+ defaultValues: n,
9
+ Fields: p,
10
10
  config: u,
11
11
  rhf: c,
12
12
  form: i,
13
13
  options: d
14
14
  }) => {
15
- const r = m.useId(), s = F({
15
+ const o = m.useId(), s = F({
16
16
  ...c,
17
- defaultValues: p
18
- }), o = m.useRef(null);
17
+ defaultValues: n
18
+ }), r = m.useRef(null);
19
19
  return {
20
- id: r,
21
- ref: o,
20
+ id: o,
21
+ ref: r,
22
22
  context: s,
23
23
  providerProps: {
24
- formId: r,
25
- formRef: o,
24
+ formId: o,
25
+ formRef: r,
26
26
  rhfForm: s,
27
27
  options: d
28
28
  },
29
29
  formProps: {
30
- Fields: n,
30
+ Fields: p,
31
31
  onSubmit: t,
32
32
  onSubmitError: e,
33
33
  onSubmitInvalid: f,
34
- formId: r,
35
- formRef: o,
34
+ formId: o,
35
+ formRef: r,
36
36
  config: u,
37
37
  form: i
38
38
  },
39
39
  FormSubmitError: a
40
40
  };
41
- };
41
+ }, $ = P;
42
42
  export {
43
- I as default
43
+ $ as default
44
44
  };
@@ -13,7 +13,9 @@ export type ObjectSchema<TInputKey extends string, TOutputKey extends string> =
13
13
  [key in TOutputKey]: SafeFieldValues;
14
14
  };
15
15
  export type CreateRhfUtilsClient<TObjectSchema extends ObjectSchema<TObjectSchemaInputKey, TObjectSchemaOutputKey>, TObjectSchemaInputKey extends string, TObjectSchemaOutputKey extends string> = {
16
- useForm: <TSchema extends TObjectSchema, TSchemaInput extends SafeFieldValues = TSchema[TObjectSchemaInputKey], TSchemaOutput extends SafeFieldValues = TSchema[TObjectSchemaOutputKey], UseFormPropsForm extends UseFormProps<TSchemaInput, TSchemaOutput> = UseFormProps<TSchemaInput, TSchemaOutput>>(schema: TSchema, form: Omit<UseFormPropsForm, 'config'>) => UseFormReturn<TSchemaInput, TSchemaOutput>;
16
+ useForm: <TSchema extends TObjectSchema, TSchemaInput extends SafeFieldValues = TSchema[TObjectSchemaInputKey], TSchemaOutput extends SafeFieldValues = TSchema[TObjectSchemaOutputKey], UseFormPropsForm extends UseFormProps<TSchemaInput, TSchemaOutput> = UseFormProps<TSchemaInput, TSchemaOutput>>(schema: TSchema, form: Omit<UseFormPropsForm, 'config'>) => UseFormReturn<TSchemaInput, TSchemaOutput> & {
17
+ FormWithProviders: React.FC<React.PropsWithChildren>;
18
+ };
17
19
  FormWithProviders: <TSchema extends TObjectSchema, TSchemaInput extends SafeFieldValues = TSchema[TObjectSchemaInputKey], TSchemaOutput extends SafeFieldValues = TSchema[TObjectSchemaOutputKey]>(props: {
18
20
  schema: TSchema;
19
21
  } & FormWithProvidersProps<TSchemaInput, TSchemaOutput>) => JSX.Element;
@@ -1,7 +1,12 @@
1
- import { default as createRhfUtilsClientForZod } from '../createRhfUtilsClientForZod';
1
+ import { UseFormProps } from '../../../form/useForm';
2
+ import { default as createRhfUtilsClientForZod, ZodTypeFieldValues } from '../createRhfUtilsClientForZod';
2
3
 
3
4
  export type RhfUtilsClientForZodContext = ReturnType<typeof createRhfUtilsClientForZod>;
4
- declare const useRhfUtilsClientForZodContext: () => import('../..').CreateRhfUtilsClient<import('../createRhfUtilsClientForZod').ZodTypeFieldValues, "_input", "_output">, _RhfUtilsClientForZodContextProvider: import('react').Provider<import('../..').CreateRhfUtilsClient<import('../createRhfUtilsClientForZod').ZodTypeFieldValues, "_input", "_output"> | undefined>;
5
+ declare const useRhfUtilsClientForZodContext: () => import('../..').CreateRhfUtilsClient<ZodTypeFieldValues, "_input", "_output">, _RhfUtilsClientForZodContextProvider: import('react').Provider<import('../..').CreateRhfUtilsClient<ZodTypeFieldValues, "_input", "_output"> | undefined>;
5
6
  export default useRhfUtilsClientForZodContext;
6
7
  export { _RhfUtilsClientForZodContextProvider };
7
- export declare const useRhfUtilsForm: () => <TSchema extends import('../createRhfUtilsClientForZod').ZodTypeFieldValues, TSchemaInput extends import('../../../exports').SafeFieldValues = TSchema["_input"], TSchemaOutput extends import('../../../exports').SafeFieldValues = TSchema["_output"], UseFormPropsForm extends import('../../../form/useForm').UseFormProps<TSchemaInput, TSchemaOutput> = import('../../../form/useForm').UseFormProps<TSchemaInput, TSchemaOutput>>(schema: TSchema, form: Omit<UseFormPropsForm, "config">) => import('../../../form/useForm').UseFormReturn<TSchemaInput, TSchemaOutput>;
8
+ export declare const useRhfUtilsZodForm: <TSchema extends ZodTypeFieldValues>(schema: TSchema, form: Omit<UseFormProps<TSchema['_input'], TSchema['_output']>, 'config'>) => import('../../../form/useForm').UseFormReturn<TSchema["_input"], TSchema["_output"]> & {
9
+ FormWithProviders: import('react').FC<{
10
+ children?: import('react').ReactNode;
11
+ }>;
12
+ };
@@ -1,7 +1,7 @@
1
1
  export type { Register } from './register';
2
2
  export type { ClientConfig } from './client/config';
3
3
  export { default as RhfUtilsClientForZodContextProvider } from './client/zod/context/RhfUtilsClientForZodContextProvider';
4
- export { default as useRhfUtilsClientForZodContext, useRhfUtilsForm, } from './client/zod/context/useRhfUtilsClientForZodContext';
4
+ export { default as useRhfUtilsClientForZodContext, useRhfUtilsZodForm, } from './client/zod/context/useRhfUtilsClientForZodContext';
5
5
  export { default as createRhfUtilsClientForZod } from './client/zod/createRhfUtilsClientForZod';
6
6
  export { default as LazyDevTool } from './devtool/LazyDevTool';
7
7
  export { default as FlatFieldErrorsContextProvider } from './errors/flat/context/FlatFieldErrorsContextProvider';
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.91",
5
+ "version": "0.0.92",
6
6
  "description": "Integration utilities for react-hook-form.",
7
7
  "type": "module",
8
8
  "sideEffects": false,