@paragrav/rhf-utils 0.0.114 → 0.0.116

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/README.md CHANGED
@@ -33,8 +33,9 @@ export const rhfUtilsClientConfig: RhfUtilsClientConfig = {
33
33
  // optional (defaults to primitive HTML form)
34
34
  FormComponent: Form.Root,
35
35
 
36
- // transform backend error
37
- onUnknownSubmitError: (
36
+ // non-FormSubmitError throw in onSubmit
37
+ // use case: transform backend error
38
+ onSubmitUnknownError: (
38
39
  error, // unknown
39
40
  ) => {
40
41
  // if other error, re-throw to handle in ErrorBoundary
@@ -96,7 +97,7 @@ And add the context provider to your stack:
96
97
 
97
98
  Currently, only `zod` is supported.
98
99
 
99
- ## Usage
100
+ ## Form
100
101
 
101
102
  ```tsx
102
103
  <RhfUtilsZodForm
@@ -160,7 +161,7 @@ function Children({...}: RhfUtilsUseFormChildrenZodProps<typeof schema>) { }
160
161
 
161
162
  ## `FormSubmitError`
162
163
 
163
- This is a derived `Error` class you can use to throw a structured error in your submit handler. It is strongly-typed, so it only allows field names in schema and `root`/`root.{string}` keys.
164
+ This is an `Error`-based class you can use to throw a structured error in your submit handler. It is strongly-typed, so it only allows field names in schema and `root`/`root.{string}` keys.
164
165
 
165
166
  It uses `FormSubmitErrors` shape, which is a flat (dot notation) equivalent of RHF's `FieldErrors`.
166
167
 
@@ -174,11 +175,15 @@ Example:
174
175
  root: { message: 'There was a problem with the form.' },
175
176
  'street.address': { message: 'Street address invalid.' },
176
177
  });
178
+
179
+ await post('/backend');
177
180
  }}
178
181
  />
179
182
  ```
180
183
 
181
- Any non-`FormSubmitError`s thrown from submit handler can be transformed by `RhfUtilsClientConfig`'s `onUnknownSubmitError` callback. This takes an `unknown` error and can return a `FormSubmitErrors` object, which is merged in RHF's context errors. (Most common use case will be transforming backend errors to frontend shape. You can use `getOnSubmitTrpcClientErrorHandler` HOF for TRPC backends.)
184
+ Any non-`FormSubmitError`s thrown from submit handler (e.g., fetch/axios error) can be transformed by `RhfUtilsClientConfig`'s `onSubmitUnknownError` callback. This takes an `unknown` error and can return a `FormSubmitErrors` object, which is merged in RHF's context errors.
185
+
186
+ Most common use case will be transforming backend errors to frontend shape. (You can use `getOnSubmitTrpcClientErrorHandler` HOF for TRPC backends.)
182
187
 
183
188
  ## `RhfUtilsFormOptions`
184
189
 
@@ -258,8 +263,9 @@ Example use case: Field array with minimum items. (When there are no items, the
258
263
 
259
264
  Orphans are optionally exposed in a few places.
260
265
 
261
- - In errors outputted via console.
266
+ - In errors outputted via console. (Configured via `RhfUtilsClientConfig['errors']['output']`.)
262
267
  - And `useFlatFieldErrorsContext()` hook, which returns an object with divided into `all`, `root`, and `orphans` errors.
268
+ - Boolean value from `useFlatFieldErrorsContextHasOnlyOrphans`.
263
269
 
264
270
  `FlatFieldErrors` is a flattened, simplified version of RHF's `FieldErrors`. Keys represent field paths flattened to dot notation.
265
271
 
@@ -1,23 +1,21 @@
1
- import { jsx as s } from "react/jsx-runtime";
1
+ import { jsx as m } from "react/jsx-runtime";
2
+ import "react";
3
+ import { useFormState as i } from "react-hook-form";
2
4
  import l from "../../orphan/getOrphansFromFlatFieldErrors.mjs";
3
5
  import F from "../../root/getRootsFromFlatFieldErrors.mjs";
4
- import a from "../../useFormErrorsTransformMemo.mjs";
5
- import i from "../getFlatFieldErrors.mjs";
6
+ import a from "../getFlatFieldErrors.mjs";
6
7
  import { _FormErrorsFlatContextProvider as n } from "./useFlatFieldErrorsContext.mjs";
7
- const x = ({
8
+ const g = ({
8
9
  formRef: o,
9
10
  children: t
10
11
  }) => {
11
- const e = a((m) => {
12
- const r = i(m);
13
- return {
14
- all: r,
15
- roots: F(r),
16
- orphans: o.current ? l(r, o.current) : {}
17
- };
18
- });
19
- return /* @__PURE__ */ s(n, { value: e, children: t });
12
+ const { errors: e } = i(), r = a(e), s = {
13
+ all: r,
14
+ roots: F(r),
15
+ orphans: o.current ? l(r, o.current) : {}
16
+ };
17
+ return /* @__PURE__ */ m(n, { value: s, children: t });
20
18
  };
21
19
  export {
22
- x as default
20
+ g as default
23
21
  };
@@ -1,11 +1,6 @@
1
1
  import t from "../../../utils/createContext.mjs";
2
- const [
3
- o,
4
- r,
5
- s
6
- ] = t(), a = r;
2
+ const [, r, e] = t(), s = r;
7
3
  export {
8
- s as _FormErrorsFlatContextProvider,
9
- a as default,
10
- o as useFlatFieldErrorsContextMaybe
4
+ e as _FormErrorsFlatContextProvider,
5
+ s as default
11
6
  };
@@ -0,0 +1,10 @@
1
+ import t from "react";
2
+ import s from "../../../utils/isEmptyObject.mjs";
3
+ import e from "./useFlatFieldErrorsContext.mjs";
4
+ const n = () => {
5
+ const r = e();
6
+ return t.useMemo(() => s(r.orphans) ? !1 : Object.keys(r.orphans).length === Object.keys(r.all).length, [r]);
7
+ }, O = n;
8
+ export {
9
+ O as default
10
+ };
@@ -0,0 +1,29 @@
1
+ import h from "react";
2
+ import { useFormContext as E } from "react-hook-form";
3
+ import c from "../../../utils/isEmptyObject.mjs";
4
+ import F from "../../output/consoleErrors.mjs";
5
+ import x from "./useFlatFieldErrorsContext.mjs";
6
+ const g = (e) => {
7
+ const i = E(), o = x();
8
+ h.useEffect(() => {
9
+ var p, r, l, u, t, a;
10
+ if (c(o.all))
11
+ return;
12
+ const m = {
13
+ isDevelopment: e.isDevelopment,
14
+ hasOrphans: !c(o.orphans)
15
+ }, s = (l = (r = (p = e.errors) == null ? void 0 : p.output) == null ? void 0 : r.console) == null ? void 0 : l.call(r, m);
16
+ s && F(
17
+ s.message ?? f,
18
+ i.getValues(),
19
+ o,
20
+ s.type
21
+ );
22
+ const n = (a = (t = (u = e.errors) == null ? void 0 : u.output) == null ? void 0 : t.throw) == null ? void 0 : a.call(t, m);
23
+ if (n)
24
+ throw new Error(typeof n == "string" ? n : f);
25
+ }, [o]);
26
+ }, f = "Form errors";
27
+ export {
28
+ g as default
29
+ };
@@ -2,47 +2,49 @@ import { default as e } from "./client/zod/context/RhfUtilsClientForZodContextPr
2
2
  import { default as s } from "./client/zod/context/RhfUtilsZodForm.mjs";
3
3
  import { default as u } from "./client/zod/context/useRhfUtilsZodForm.mjs";
4
4
  import { default as m } from "./errors/flat/context/useFlatFieldErrorsContext.mjs";
5
- import { default as d } from "./errors/message/FormErrorMessageByPath.mjs";
6
- import { default as x } from "./errors/nonfield/FormNonFieldErrorMarker.mjs";
7
- import { default as F } from "./errors/root/RootErrorsListFromFlatFieldErrorsContext.mjs";
8
- import { getOnSubmitTrpcClientErrorHandler as C } from "./errors/trpc/getOnSubmitTrpcClientErrorHandler.mjs";
9
- import { trpcClientErrorToFormSubmitErrorsSchemaTransformer as E } from "./errors/trpc/trpcClientErrorToFormSubmitErrorsSchemaTransformer.mjs";
10
- import { default as R } from "./form/context/utils/useRhfUtilsContext.mjs";
11
- import { default as b } from "./form/context/utils/useRhfUtilsContextRequestSubmit.mjs";
12
- import { default as T } from "./form/context/group/FormGroupContextProvider.mjs";
13
- import { default as B } from "./form/context/group/useFormGroupChildIsMountedTracker.mjs";
14
- import { default as P } from "./form/context/group/useFormGroupChildIsSubmittingTracker.mjs";
15
- import { default as U } from "./form/context/group/useFormGroupChildTracker.mjs";
16
- import { default as M } from "./form/context/group/useFormGroupIsAnyBusy.mjs";
17
- import { default as q } from "./form/context/group/useFormGroupIsChildBusy.mjs";
18
- import { default as O } from "./form/context/group/useFormGroupIsParentBusy.mjs";
19
- import { default as D } from "./form/context/group/useFormGroupParentTracker.mjs";
20
- import { default as L } from "./form/context/group/useFormOrParentIsBusy.mjs";
21
- import { default as j } from "./form/utils/getSubmitterButtonData.mjs";
22
- import { default as z } from "./form/utils/useFormRequestSubmit.mjs";
23
- import { FormSubmitError as K } from "./submit/error/FormSubmitError.mjs";
5
+ import { default as d } from "./errors/flat/context/useFlatFieldErrorsContextHasOnlyOrphans.mjs";
6
+ import { default as x } from "./errors/message/FormErrorMessageByPath.mjs";
7
+ import { default as F } from "./errors/nonfield/FormNonFieldErrorMarker.mjs";
8
+ import { default as C } from "./errors/root/RootErrorsListFromFlatFieldErrorsContext.mjs";
9
+ import { getOnSubmitTrpcClientErrorHandler as E } from "./errors/trpc/getOnSubmitTrpcClientErrorHandler.mjs";
10
+ import { trpcClientErrorToFormSubmitErrorsSchemaTransformer as R } from "./errors/trpc/trpcClientErrorToFormSubmitErrorsSchemaTransformer.mjs";
11
+ import { default as b } from "./form/context/utils/useRhfUtilsContext.mjs";
12
+ import { default as y } from "./form/context/utils/useRhfUtilsContextRequestSubmit.mjs";
13
+ import { default as B } from "./form/context/group/FormGroupContextProvider.mjs";
14
+ import { default as P } from "./form/context/group/useFormGroupChildIsMountedTracker.mjs";
15
+ import { default as U } from "./form/context/group/useFormGroupChildIsSubmittingTracker.mjs";
16
+ import { default as O } from "./form/context/group/useFormGroupChildTracker.mjs";
17
+ import { default as Z } from "./form/context/group/useFormGroupIsAnyBusy.mjs";
18
+ import { default as v } from "./form/context/group/useFormGroupIsChildBusy.mjs";
19
+ import { default as A } from "./form/context/group/useFormGroupIsParentBusy.mjs";
20
+ import { default as L } from "./form/context/group/useFormGroupParentTracker.mjs";
21
+ import { default as j } from "./form/context/group/useFormOrParentIsBusy.mjs";
22
+ import { default as z } from "./form/utils/getSubmitterButtonData.mjs";
23
+ import { default as K } from "./form/utils/useFormRequestSubmit.mjs";
24
+ import { FormSubmitError as V } from "./submit/error/FormSubmitError.mjs";
24
25
  export {
25
- d as FormErrorMessageByPath,
26
- T as FormGroupContextProvider,
27
- x as FormNonFieldErrorMarker,
28
- K as FormSubmitError,
26
+ x as FormErrorMessageByPath,
27
+ B as FormGroupContextProvider,
28
+ F as FormNonFieldErrorMarker,
29
+ V as FormSubmitError,
29
30
  e as RhfUtilsClientForZodContextProvider,
30
31
  s as RhfUtilsZodForm,
31
- F as RootErrorsListFromFlatFieldErrorsContext,
32
- C as getOnSubmitTrpcClientErrorHandler,
33
- j as getSubmitterButtonData,
34
- E as trpcClientErrorToFormSubmitErrorsSchemaTransformer,
32
+ C as RootErrorsListFromFlatFieldErrorsContext,
33
+ E as getOnSubmitTrpcClientErrorHandler,
34
+ z as getSubmitterButtonData,
35
+ R as trpcClientErrorToFormSubmitErrorsSchemaTransformer,
35
36
  m as useFlatFieldErrorsContext,
36
- B as useFormGroupChildIsMountedTracker,
37
- P as useFormGroupChildIsSubmittingTracker,
38
- U as useFormGroupChildTracker,
39
- M as useFormGroupIsAnyBusy,
40
- q as useFormGroupIsChildBusy,
41
- O as useFormGroupIsParentBusy,
42
- D as useFormGroupParentTracker,
43
- L as useFormOrParentIsBusy,
44
- z as useFormRequestSubmit,
45
- R as useRhfUtilsContext,
46
- b as useRhfUtilsContextRequestSubmit,
37
+ d as useFlatFieldErrorsContextHasOnlyOrphans,
38
+ P as useFormGroupChildIsMountedTracker,
39
+ U as useFormGroupChildIsSubmittingTracker,
40
+ O as useFormGroupChildTracker,
41
+ Z as useFormGroupIsAnyBusy,
42
+ v as useFormGroupIsChildBusy,
43
+ A as useFormGroupIsParentBusy,
44
+ L as useFormGroupParentTracker,
45
+ j as useFormOrParentIsBusy,
46
+ K as useFormRequestSubmit,
47
+ b as useRhfUtilsContext,
48
+ y as useRhfUtilsContextRequestSubmit,
47
49
  u as useRhfUtilsZodForm
48
50
  };
@@ -45,7 +45,7 @@ function A({
45
45
  e.errors
46
46
  ) : (
47
47
  // if error is not FormSubmitError, consumer can provide global handler
48
- (y = t == null ? void 0 : t.onUnknownSubmitError) == null ? void 0 : y.call(t, e)
48
+ (y = t == null ? void 0 : t.onSubmitUnknownError) == null ? void 0 : y.call(t, e)
49
49
  );
50
50
  a && P(n, a), d == null || d(
51
51
  e,
@@ -1,27 +1,33 @@
1
1
  import { jsx as f } from "react/jsx-runtime";
2
- import t from "../../../errors/flat/useFlatFieldErrorsOutput.mjs";
3
- import l from "../../../submit/useFormOnSubmitSuccessfulAndReset.mjs";
4
- import F from "../../../submit/useResetFormOnSubmitError.mjs";
5
- import O from "../../../submit/useResetFormOnSubmitSuccessful.mjs";
6
- import b from "../../../submit/useSubmitFormOnChange.mjs";
7
- import { _RhfUtilsContextProvider as d } from "./useRhfUtilsContext.mjs";
8
- function P({
9
- formId: u,
10
- formRef: e,
2
+ import C from "../../../client/config/useRhfUtilsClientConfigContext.mjs";
3
+ import F from "../../../errors/flat/context/useFlatFieldErrorsContextOutput.mjs";
4
+ import x from "../../../submit/useFormOnSubmitSuccessfulAndReset.mjs";
5
+ import O from "../../../submit/useResetFormOnSubmitError.mjs";
6
+ import b from "../../../submit/useResetFormOnSubmitSuccessful.mjs";
7
+ import h from "../../../submit/useSubmitFormOnChange.mjs";
8
+ import { _RhfUtilsContextProvider as v } from "./useRhfUtilsContext.mjs";
9
+ const y = ({
10
+ formId: l,
11
+ formRef: t,
11
12
  onSubmitSuccessfulAndReset: m,
12
13
  options: r,
13
14
  children: a
14
- }) {
15
- return t(), b(e, {
15
+ }) => {
16
+ var u;
17
+ const e = C();
18
+ return F({
19
+ ...(u = e == null ? void 0 : e.errors) == null ? void 0 : u.output,
20
+ isDevelopment: e == null ? void 0 : e.isDevelopment
21
+ }), h(t, {
16
22
  disabled: !(r != null && r.submitOnChange)
17
- }), F({
23
+ }), O({
18
24
  disabled: !(r != null && r.resetValuesOnSubmitError)
19
- }), O(
25
+ }), b(
20
26
  (r == null ? void 0 : r.resetFormAfterSubmitSuccessful) || !!m
21
- ), l(() => {
27
+ ), x(() => {
22
28
  m == null || m();
23
- }), /* @__PURE__ */ f(d, { value: { formId: u, formRef: e, options: r }, children: a });
24
- }
29
+ }), /* @__PURE__ */ f(v, { value: { formId: l, formRef: t, options: r }, children: a });
30
+ };
25
31
  export {
26
- P as default
32
+ y as default
27
33
  };
@@ -1,5 +1,5 @@
1
1
  import { UseFormProps } from 'react-hook-form';
2
- import { RhfUtilsErrorsOutputConfigContext, RhfUtilsErrorsOutputConsoleConfig } from '../../errors/output/types';
2
+ import { FlatFieldErrorsOutputConfig } from '../../errors/flat/context/FlatFieldErrorsOutputConfig';
3
3
  import { FormChildrenSlots } from '../../form/Form';
4
4
  import { RhfUtilsFormOptions } from '../../form/RhfUtilsFormOptions';
5
5
  import { UseRhfUtilsFormChildrenProps } from '../../form/UseRhfUtilsFormChildrenProps';
@@ -48,7 +48,7 @@ export type RhfUtilsClientConfig = {
48
48
  * - if {@link FormSubmitErrors}: merge into context errors.
49
49
  * - if `undefined`: do nothing.
50
50
  */
51
- onUnknownSubmitError?: (error: unknown) => FormSubmitErrors | undefined;
51
+ onSubmitUnknownError?: (error: unknown) => FormSubmitErrors | undefined;
52
52
  /**
53
53
  * Components injected by slot across all forms.
54
54
  * (Per-form injection can be done via `Children` prop.)
@@ -61,22 +61,6 @@ export type RhfUtilsClientConfig = {
61
61
  /**
62
62
  * Configure how/if errors should be outputted.
63
63
  */
64
- output?: {
65
- /**
66
- * Configure how/if errors should be outputted to console.
67
- *
68
- * Example use cases:
69
- * - console.debug errors in development environment.
70
- * - console.error certain errors in production environment.
71
- */
72
- console?: (context: RhfUtilsErrorsOutputConfigContext) => RhfUtilsErrorsOutputConsoleConfig | null | false | undefined;
73
- /**
74
- * Configure how/if errors should be thrown.
75
- *
76
- * Example use case:
77
- * - bring attention to certain errors in development environment.
78
- */
79
- throw?: (context: RhfUtilsErrorsOutputConfigContext) => true | string | false | undefined;
80
- };
64
+ output?: FlatFieldErrorsOutputConfig;
81
65
  };
82
66
  };
@@ -1,4 +1,5 @@
1
- /// <reference types="react" />
1
+ import { default as React } from 'react';
2
+
2
3
  type Props = React.PropsWithChildren<{
3
4
  formRef: React.RefObject<HTMLFormElement>;
4
5
  }>;
@@ -0,0 +1,19 @@
1
+ import { RhfUtilsErrorsOutputConfigContext, RhfUtilsErrorsOutputConsoleConfig } from '../../output/types';
2
+
3
+ export type FlatFieldErrorsOutputConfig = {
4
+ /**
5
+ * Configure how/if errors should be outputted to console.
6
+ *
7
+ * Example use cases:
8
+ * - console.debug errors in development environment.
9
+ * - console.error certain errors in production environment.
10
+ */
11
+ console?: (context: RhfUtilsErrorsOutputConfigContext) => RhfUtilsErrorsOutputConsoleConfig | null | false | undefined;
12
+ /**
13
+ * Configure how/if errors should be thrown.
14
+ *
15
+ * Example use case:
16
+ * - bring attention to certain errors in development environment.
17
+ */
18
+ throw?: (context: RhfUtilsErrorsOutputConfigContext) => true | string | false | undefined;
19
+ };
@@ -5,6 +5,6 @@ export type FlatFieldErrorsContext = {
5
5
  roots: FlatFieldErrors;
6
6
  orphans: FlatFieldErrors;
7
7
  };
8
- declare const useFlatFieldErrorsContextMaybe: () => FlatFieldErrorsContext | undefined, useFlatFieldErrorsContext: () => FlatFieldErrorsContext, _FormErrorsFlatContextProvider: import('react').Provider<FlatFieldErrorsContext | undefined>;
8
+ declare const useFlatFieldErrorsContext: () => FlatFieldErrorsContext, _FormErrorsFlatContextProvider: import('react').Provider<FlatFieldErrorsContext | undefined>;
9
9
  export default useFlatFieldErrorsContext;
10
- export { _FormErrorsFlatContextProvider, useFlatFieldErrorsContextMaybe };
10
+ export { _FormErrorsFlatContextProvider };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Returns `true` if all errors are orphans.
3
+ *
4
+ * You may want to treat this case specifically.
5
+ */
6
+ declare const useFlatFieldErrorsContextHasOnlyOrphans: () => boolean;
7
+ export default useFlatFieldErrorsContextHasOnlyOrphans;
@@ -0,0 +1,7 @@
1
+ import { RhfUtilsClientConfig } from '../../../client/config/RhfUtilsClientConfig';
2
+
3
+ /**
4
+ * Outputs (e.g., console, throw) errors based on config.
5
+ */
6
+ declare const useFlatFieldErrorsContextOutput: (config: RhfUtilsClientConfig) => void;
7
+ export default useFlatFieldErrorsContextOutput;
@@ -2,9 +2,9 @@ import { RhfUtilsClientConfig } from '../../client/config/RhfUtilsClientConfig';
2
2
  import { FormSubmitErrors } from '../../submit/error/FormSubmitErrors';
3
3
 
4
4
  /**
5
- * HOF that returns submit error handler for {@link RhfUtilsClientConfig.onUnknownSubmitError}.
5
+ * HOF that returns submit error handler for {@link RhfUtilsClientConfig.onSubmitUnknownError}.
6
6
  *
7
7
  * @param onError Fallback for handling non-TRPC errors.
8
8
  * @returns FormSubmitError
9
9
  */
10
- export declare const getOnSubmitTrpcClientErrorHandler: (onNotTrpcClientError: NonNullable<RhfUtilsClientConfig['onUnknownSubmitError']>) => (error: unknown) => FormSubmitErrors | undefined;
10
+ export declare const getOnSubmitTrpcClientErrorHandler: (onNotTrpcClientError: NonNullable<RhfUtilsClientConfig['onSubmitUnknownError']>) => (error: unknown) => FormSubmitErrors | undefined;
@@ -6,6 +6,7 @@ export { default as useRhfUtilsZodForm } from './client/zod/context/useRhfUtilsZ
6
6
  export type { RhfUtilsUseFormChildrenZodFC } from './client/zod/RhfUtilsUseFormChildrenZodFC';
7
7
  export type { RhfUtilsUseFormChildrenZodProps } from './client/zod/RhfUtilsUseFormChildrenZodProps';
8
8
  export { default as useFlatFieldErrorsContext } from './errors/flat/context/useFlatFieldErrorsContext';
9
+ export { default as useFlatFieldErrorsContextHasOnlyOrphans } from './errors/flat/context/useFlatFieldErrorsContextHasOnlyOrphans';
9
10
  export { default as FormErrorMessageByPath } from './errors/message/FormErrorMessageByPath';
10
11
  export { default as FormNonFieldErrorMarker } from './errors/nonfield/FormNonFieldErrorMarker';
11
12
  export { default as RootErrorsListFromFlatFieldErrorsContext } from './errors/root/RootErrorsListFromFlatFieldErrorsContext';
@@ -7,5 +7,5 @@ type Props = React.PropsWithChildren<{
7
7
  onSubmitSuccessfulAndReset?: () => void;
8
8
  options?: RhfUtilsFormOptions;
9
9
  }>;
10
- declare function RhfUtilsContextProvider({ formId, formRef, onSubmitSuccessfulAndReset, options, children, }: Props): import("react/jsx-runtime").JSX.Element;
10
+ declare const RhfUtilsContextProvider: React.FC<Props>;
11
11
  export default RhfUtilsContextProvider;
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.114",
5
+ "version": "0.0.116",
6
6
  "description": "Integration utilities for react-hook-form.",
7
7
  "type": "module",
8
8
  "sideEffects": false,
@@ -1,30 +0,0 @@
1
- import h from "react";
2
- import { useFormContext as E } from "react-hook-form";
3
- import F from "../../client/config/useRhfUtilsClientConfigContext.mjs";
4
- import i from "../../utils/isEmptyObject.mjs";
5
- import x from "../output/consoleErrors.mjs";
6
- import C from "./context/useFlatFieldErrorsContext.mjs";
7
- const D = () => {
8
- const c = E(), t = F(), r = C();
9
- h.useEffect(() => {
10
- var p, o, l, u, e, a;
11
- if (i(r.all))
12
- return;
13
- const n = {
14
- isDevelopment: t == null ? void 0 : t.isDevelopment,
15
- hasOrphans: !i(r.orphans)
16
- }, s = (l = (o = (p = t == null ? void 0 : t.errors) == null ? void 0 : p.output) == null ? void 0 : o.console) == null ? void 0 : l.call(o, n);
17
- s && x(
18
- s.message ?? f,
19
- c.getValues(),
20
- r,
21
- s.type
22
- );
23
- const m = (a = (e = (u = t == null ? void 0 : t.errors) == null ? void 0 : u.output) == null ? void 0 : e.throw) == null ? void 0 : a.call(e, n);
24
- if (m)
25
- throw new Error(typeof m == "string" ? m : f);
26
- }, [r]);
27
- }, f = "Form errors";
28
- export {
29
- D as default
30
- };
@@ -1,12 +0,0 @@
1
- import e from "react";
2
- import { useFormState as t } from "react-hook-form";
3
- const u = (r) => {
4
- const { errors: o } = t();
5
- return e.useMemo(
6
- () => r(o),
7
- [r, o]
8
- );
9
- };
10
- export {
11
- u as default
12
- };