@paragrav/rhf-utils 0.0.135 → 0.0.137

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.
Files changed (163) hide show
  1. package/README.md +90 -65
  2. package/dist/esm/client/config/useRhfUtilsClientConfigContext.mjs +0 -1
  3. package/dist/esm/client/index.mjs +0 -1
  4. package/dist/esm/client/utils.mjs +0 -1
  5. package/dist/esm/client/zod/context/RhfUtilsClientForZodContextProvider.mjs +3 -2
  6. package/dist/esm/client/zod/context/RhfUtilsZodForm.mjs +0 -1
  7. package/dist/esm/client/zod/context/useRhfUtilsClientForZodContext.mjs +0 -1
  8. package/dist/esm/client/zod/context/useRhfUtilsZodForm.mjs +0 -1
  9. package/dist/esm/client/zod/createRhfUtilsClientForZod.mjs +0 -1
  10. package/dist/esm/devtool/LazyDevTool.mjs +0 -1
  11. package/dist/esm/errors/flat/FlatFieldErrorsList.mjs +0 -1
  12. package/dist/esm/errors/flat/context/FlatFieldErrorsContextProvider.mjs +0 -1
  13. package/dist/esm/errors/flat/context/useFlatFieldErrorsContext.mjs +0 -1
  14. package/dist/esm/errors/flat/context/useFlatFieldErrorsContextHasOnlyOrphans.mjs +0 -1
  15. package/dist/esm/errors/flat/context/useFlatFieldErrorsContextOutput.mjs +0 -1
  16. package/dist/esm/errors/flat/filterFlatFieldErrors.mjs +0 -1
  17. package/dist/esm/errors/flat/flattenFieldErrors.mjs +0 -1
  18. package/dist/esm/errors/flat/getFlatFieldErrors.mjs +10 -11
  19. package/dist/esm/errors/getRefdFromFlatFieldErrors.mjs +0 -1
  20. package/dist/esm/errors/isFieldErrorRefd.mjs +0 -1
  21. package/dist/esm/errors/isFlatFieldErrorEntryRefd.mjs +0 -1
  22. package/dist/esm/errors/message/FormErrorMessage.mjs +0 -1
  23. package/dist/esm/errors/message/RhfUtilsFieldErrorMessage.mjs +14 -0
  24. package/dist/esm/errors/nonfield/FormNonFieldErrorMarker.mjs +0 -1
  25. package/dist/esm/errors/nonfield/FormNonFieldErrorMarker.utils.mjs +0 -1
  26. package/dist/esm/errors/nonfield/FormNonFieldErrorMarkerHtmlAttribute.mjs +0 -1
  27. package/dist/esm/errors/nonfield/isNonFieldErrorMarkerInDOM.mjs +0 -1
  28. package/dist/esm/errors/orphan/getIsOrphanFormErrorWithParentElement.mjs +0 -1
  29. package/dist/esm/errors/orphan/getOrphansFromFlatFieldErrors.mjs +0 -1
  30. package/dist/esm/errors/orphan/isOrphanFormError.mjs +3 -4
  31. package/dist/esm/errors/output/consoleErrors.mjs +0 -1
  32. package/dist/esm/errors/root/RootErrorsListFromFlatFieldErrorsContext.mjs +0 -1
  33. package/dist/esm/errors/root/consts.mjs +0 -1
  34. package/dist/esm/errors/root/getRootsFromFlatFieldErrors.mjs +0 -1
  35. package/dist/esm/errors/root/isFlatFieldErrorEntryPathRoot.mjs +0 -1
  36. package/dist/esm/errors/root/isFormErrorPathRoot.mjs +0 -1
  37. package/dist/esm/exports.mjs +32 -37
  38. package/dist/esm/form/Form.mjs +14 -15
  39. package/dist/esm/form/FormWithProviders.mjs +0 -1
  40. package/dist/esm/form/RhfUtilsFormProviders.mjs +0 -1
  41. package/dist/esm/form/_Controller.mjs +0 -1
  42. package/dist/esm/form/context/group/FormGroupContextProvider.mjs +0 -1
  43. package/dist/esm/form/context/group/index.mjs +0 -1
  44. package/dist/esm/form/context/group/useFormGroupChildIsMountedTracker.mjs +0 -1
  45. package/dist/esm/form/context/group/useFormGroupChildIsSubmittingTracker.mjs +0 -1
  46. package/dist/esm/form/context/group/useFormGroupChildTracker.mjs +0 -1
  47. package/dist/esm/form/context/group/useFormGroupIsAnyBusy.mjs +0 -1
  48. package/dist/esm/form/context/group/useFormGroupIsChildBusy.mjs +0 -1
  49. package/dist/esm/form/context/group/useFormGroupIsParentBusy.mjs +0 -1
  50. package/dist/esm/form/context/group/useFormGroupParentTracker.mjs +0 -1
  51. package/dist/esm/form/context/group/useFormOrParentIsBusy.mjs +0 -1
  52. package/dist/esm/form/context/utils/RhfUtilsContextProvider.mjs +15 -14
  53. package/dist/esm/form/context/utils/useRhfUtilsContext.mjs +0 -1
  54. package/dist/esm/form/context/utils/useRhfUtilsContextRequestSubmit.mjs +0 -1
  55. package/dist/esm/form/useFormIsBusy.mjs +0 -1
  56. package/dist/esm/form/useRhfUtilsForm.mjs +0 -1
  57. package/dist/esm/form/utils/getSubmitterButtonData.mjs +0 -1
  58. package/dist/esm/form/utils/useFormRequestSubmit.mjs +9 -6
  59. package/dist/esm/submit/error/FormSubmitError.mjs +0 -1
  60. package/dist/esm/submit/error/setCtxErrorsByFormSubmitFieldErrors.mjs +12 -0
  61. package/dist/esm/submit/useFormOnSubmitted.mjs +0 -1
  62. package/dist/esm/submit/useResetFormOnSubmitted.mjs +0 -1
  63. package/dist/esm/submit/useSubmitFormOnChange.mjs +18 -12
  64. package/dist/esm/utils/PassthroughChildren.mjs +0 -1
  65. package/dist/esm/utils/createContext.mjs +0 -1
  66. package/dist/esm/utils/isEmptyObject.mjs +0 -1
  67. package/dist/esm/utils/useDebouncedOnChangeValue.mjs +26 -0
  68. package/dist/esm/utils/useRefIfValueWasTrue.mjs +0 -1
  69. package/dist/types/client/config/RhfUtilsClientConfig.d.ts +5 -5
  70. package/dist/types/client/zod/context/RhfUtilsClientForZodContextProvider.d.ts +1 -1
  71. package/dist/types/errors/flat/flattenFieldErrors.d.ts +3 -2
  72. package/dist/types/errors/message/{FormErrorMessageByPath.d.ts → RhfUtilsFieldErrorMessage.d.ts} +2 -2
  73. package/dist/types/errors/trpc/getOnSubmitTrpcClientErrorHandler.d.ts +2 -2
  74. package/dist/types/errors/trpc/trpcClientErrorToFormSubmitFieldErrorsSchemaTransformer.d.ts +28 -0
  75. package/dist/types/exports.d.ts +1 -3
  76. package/dist/types/form/RhfUtilsFormOptions.d.ts +7 -3
  77. package/dist/types/form/UseRhfUtilsFormProps.d.ts +1 -1
  78. package/dist/types/form/utils/useFormRequestSubmit.d.ts +5 -0
  79. package/dist/types/submit/error/FormSubmitError.d.ts +3 -3
  80. package/dist/types/submit/error/{FormSubmitErrors.d.ts → FormSubmitFieldErrors.d.ts} +1 -1
  81. package/dist/types/submit/error/setCtxErrorsByFormSubmitFieldErrors.d.ts +10 -0
  82. package/dist/types/submit/useFormOnSubmitSuccessfulAndReset.d.ts +1 -1
  83. package/dist/types/submit/useFormOnSubmitted.d.ts +1 -1
  84. package/dist/types/submit/useSubmitFormOnChange.d.ts +3 -1
  85. package/dist/types/utils/timeoutAsync.d.ts +6 -0
  86. package/dist/types/utils/useDebouncedOnChangeValue.d.ts +14 -0
  87. package/package.json +1 -1
  88. package/dist/esm/client/config/useRhfUtilsClientConfigContext.mjs.map +0 -1
  89. package/dist/esm/client/index.mjs.map +0 -1
  90. package/dist/esm/client/utils.mjs.map +0 -1
  91. package/dist/esm/client/zod/context/RhfUtilsClientForZodContextProvider.mjs.map +0 -1
  92. package/dist/esm/client/zod/context/RhfUtilsZodForm.mjs.map +0 -1
  93. package/dist/esm/client/zod/context/useRhfUtilsClientForZodContext.mjs.map +0 -1
  94. package/dist/esm/client/zod/context/useRhfUtilsZodForm.mjs.map +0 -1
  95. package/dist/esm/client/zod/createRhfUtilsClientForZod.mjs.map +0 -1
  96. package/dist/esm/devtool/LazyDevTool.mjs.map +0 -1
  97. package/dist/esm/errors/flat/FlatFieldErrorsList.mjs.map +0 -1
  98. package/dist/esm/errors/flat/context/FlatFieldErrorsContextProvider.mjs.map +0 -1
  99. package/dist/esm/errors/flat/context/useFlatFieldErrorsContext.mjs.map +0 -1
  100. package/dist/esm/errors/flat/context/useFlatFieldErrorsContextHasOnlyOrphans.mjs.map +0 -1
  101. package/dist/esm/errors/flat/context/useFlatFieldErrorsContextOutput.mjs.map +0 -1
  102. package/dist/esm/errors/flat/filterFlatFieldErrors.mjs.map +0 -1
  103. package/dist/esm/errors/flat/flattenFieldErrors.mjs.map +0 -1
  104. package/dist/esm/errors/flat/getFlatFieldErrors.mjs.map +0 -1
  105. package/dist/esm/errors/getRefdFromFlatFieldErrors.mjs.map +0 -1
  106. package/dist/esm/errors/isFieldErrorRefd.mjs.map +0 -1
  107. package/dist/esm/errors/isFlatFieldErrorEntryRefd.mjs.map +0 -1
  108. package/dist/esm/errors/message/FormErrorMessage.mjs.map +0 -1
  109. package/dist/esm/errors/message/FormErrorMessageByPath.mjs +0 -15
  110. package/dist/esm/errors/message/FormErrorMessageByPath.mjs.map +0 -1
  111. package/dist/esm/errors/nonfield/FormNonFieldErrorMarker.mjs.map +0 -1
  112. package/dist/esm/errors/nonfield/FormNonFieldErrorMarker.utils.mjs.map +0 -1
  113. package/dist/esm/errors/nonfield/FormNonFieldErrorMarkerHtmlAttribute.mjs.map +0 -1
  114. package/dist/esm/errors/nonfield/isNonFieldErrorMarkerInDOM.mjs.map +0 -1
  115. package/dist/esm/errors/orphan/getIsOrphanFormErrorWithParentElement.mjs.map +0 -1
  116. package/dist/esm/errors/orphan/getOrphansFromFlatFieldErrors.mjs.map +0 -1
  117. package/dist/esm/errors/orphan/isOrphanFormError.mjs.map +0 -1
  118. package/dist/esm/errors/output/consoleErrors.mjs.map +0 -1
  119. package/dist/esm/errors/root/RootErrorsListFromFlatFieldErrorsContext.mjs.map +0 -1
  120. package/dist/esm/errors/root/consts.mjs.map +0 -1
  121. package/dist/esm/errors/root/getRootsFromFlatFieldErrors.mjs.map +0 -1
  122. package/dist/esm/errors/root/isFlatFieldErrorEntryPathRoot.mjs.map +0 -1
  123. package/dist/esm/errors/root/isFormErrorPathRoot.mjs.map +0 -1
  124. package/dist/esm/errors/trpc/getOnSubmitTrpcClientErrorHandler.mjs +0 -7
  125. package/dist/esm/errors/trpc/getOnSubmitTrpcClientErrorHandler.mjs.map +0 -1
  126. package/dist/esm/errors/trpc/trpcClientErrorMessageSchema.mjs +0 -11
  127. package/dist/esm/errors/trpc/trpcClientErrorMessageSchema.mjs.map +0 -1
  128. package/dist/esm/errors/trpc/trpcClientErrorToFormSubmitErrorsSchemaTransformer.mjs +0 -35
  129. package/dist/esm/errors/trpc/trpcClientErrorToFormSubmitErrorsSchemaTransformer.mjs.map +0 -1
  130. package/dist/esm/exports.mjs.map +0 -1
  131. package/dist/esm/form/Form.mjs.map +0 -1
  132. package/dist/esm/form/FormWithProviders.mjs.map +0 -1
  133. package/dist/esm/form/RhfUtilsFormProviders.mjs.map +0 -1
  134. package/dist/esm/form/_Controller.mjs.map +0 -1
  135. package/dist/esm/form/context/group/FormGroupContextProvider.mjs.map +0 -1
  136. package/dist/esm/form/context/group/index.mjs.map +0 -1
  137. package/dist/esm/form/context/group/useFormGroupChildIsMountedTracker.mjs.map +0 -1
  138. package/dist/esm/form/context/group/useFormGroupChildIsSubmittingTracker.mjs.map +0 -1
  139. package/dist/esm/form/context/group/useFormGroupChildTracker.mjs.map +0 -1
  140. package/dist/esm/form/context/group/useFormGroupIsAnyBusy.mjs.map +0 -1
  141. package/dist/esm/form/context/group/useFormGroupIsChildBusy.mjs.map +0 -1
  142. package/dist/esm/form/context/group/useFormGroupIsParentBusy.mjs.map +0 -1
  143. package/dist/esm/form/context/group/useFormGroupParentTracker.mjs.map +0 -1
  144. package/dist/esm/form/context/group/useFormOrParentIsBusy.mjs.map +0 -1
  145. package/dist/esm/form/context/utils/RhfUtilsContextProvider.mjs.map +0 -1
  146. package/dist/esm/form/context/utils/useRhfUtilsContext.mjs.map +0 -1
  147. package/dist/esm/form/context/utils/useRhfUtilsContextRequestSubmit.mjs.map +0 -1
  148. package/dist/esm/form/useFormIsBusy.mjs.map +0 -1
  149. package/dist/esm/form/useRhfUtilsForm.mjs.map +0 -1
  150. package/dist/esm/form/utils/getSubmitterButtonData.mjs.map +0 -1
  151. package/dist/esm/form/utils/useFormRequestSubmit.mjs.map +0 -1
  152. package/dist/esm/submit/error/FormSubmitError.mjs.map +0 -1
  153. package/dist/esm/submit/error/setCtxErrorsByFormSubmitErrors.mjs +0 -13
  154. package/dist/esm/submit/error/setCtxErrorsByFormSubmitErrors.mjs.map +0 -1
  155. package/dist/esm/submit/useFormOnSubmitted.mjs.map +0 -1
  156. package/dist/esm/submit/useResetFormOnSubmitted.mjs.map +0 -1
  157. package/dist/esm/submit/useSubmitFormOnChange.mjs.map +0 -1
  158. package/dist/esm/utils/PassthroughChildren.mjs.map +0 -1
  159. package/dist/esm/utils/createContext.mjs.map +0 -1
  160. package/dist/esm/utils/isEmptyObject.mjs.map +0 -1
  161. package/dist/esm/utils/useRefIfValueWasTrue.mjs.map +0 -1
  162. package/dist/types/errors/trpc/trpcClientErrorToFormSubmitErrorsSchemaTransformer.d.ts +0 -28
  163. package/dist/types/submit/error/setCtxErrorsByFormSubmitErrors.d.ts +0 -10
@@ -1,51 +1,46 @@
1
1
  import { default as e } from "./client/zod/context/RhfUtilsClientForZodContextProvider.mjs";
2
- import { default as a } from "./client/zod/context/RhfUtilsZodForm.mjs";
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
5
  import { default as d } from "./errors/flat/context/useFlatFieldErrorsContextHasOnlyOrphans.mjs";
6
- import { default as x } from "./errors/message/FormErrorMessageByPath.mjs";
6
+ import { default as x } from "./errors/message/RhfUtilsFieldErrorMessage.mjs";
7
7
  import { default as F } from "./errors/nonfield/FormNonFieldErrorMarker.mjs";
8
8
  import { default as C } from "./errors/root/RootErrorsListFromFlatFieldErrorsContext.mjs";
9
- import { default as E } from "./errors/trpc/getOnSubmitTrpcClientErrorHandler.mjs";
10
- import { default 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";
9
+ import { default as R } from "./form/context/utils/useRhfUtilsContext.mjs";
10
+ import { default as E } from "./form/context/utils/useRhfUtilsContextRequestSubmit.mjs";
11
+ import { default as I } from "./form/context/group/FormGroupContextProvider.mjs";
12
+ import { default as b } from "./form/context/group/useFormGroupChildIsMountedTracker.mjs";
13
+ import { default as B } from "./form/context/group/useFormGroupChildIsSubmittingTracker.mjs";
14
+ import { default as S } from "./form/context/group/useFormGroupChildTracker.mjs";
15
+ import { default as T } from "./form/context/group/useFormGroupIsAnyBusy.mjs";
16
+ import { default as M } from "./form/context/group/useFormGroupIsChildBusy.mjs";
17
+ import { default as Z } from "./form/context/group/useFormGroupIsParentBusy.mjs";
18
+ import { default as v } from "./form/context/group/useFormGroupParentTracker.mjs";
19
+ import { default as D } from "./form/context/group/useFormOrParentIsBusy.mjs";
20
+ import { default as L } from "./form/utils/getSubmitterButtonData.mjs";
21
+ import { default as j } from "./form/utils/useFormRequestSubmit.mjs";
22
+ import { FormSubmitError as z } from "./submit/error/FormSubmitError.mjs";
25
23
  export {
26
- x as FormErrorMessageByPath,
27
- B as FormGroupContextProvider,
24
+ I as FormGroupContextProvider,
28
25
  F as FormNonFieldErrorMarker,
29
- V as FormSubmitError,
26
+ z as FormSubmitError,
30
27
  e as RhfUtilsClientForZodContextProvider,
31
- a as RhfUtilsZodForm,
28
+ x as RhfUtilsFieldErrorMessage,
29
+ s as RhfUtilsZodForm,
32
30
  C as RootErrorsListFromFlatFieldErrorsContext,
33
- E as getOnSubmitTrpcClientErrorHandler,
34
- z as getSubmitterButtonData,
35
- R as trpcClientErrorToFormSubmitErrorsSchemaTransformer,
31
+ L as getSubmitterButtonData,
36
32
  m as useFlatFieldErrorsContext,
37
33
  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,
34
+ b as useFormGroupChildIsMountedTracker,
35
+ B as useFormGroupChildIsSubmittingTracker,
36
+ S as useFormGroupChildTracker,
37
+ T as useFormGroupIsAnyBusy,
38
+ M as useFormGroupIsChildBusy,
39
+ Z as useFormGroupIsParentBusy,
40
+ v as useFormGroupParentTracker,
41
+ D as useFormOrParentIsBusy,
42
+ j as useFormRequestSubmit,
43
+ R as useRhfUtilsContext,
44
+ E as useRhfUtilsContextRequestSubmit,
49
45
  u as useRhfUtilsZodForm
50
46
  };
51
- //# sourceMappingURL=exports.mjs.map
@@ -1,10 +1,10 @@
1
- import { jsx as c, jsxs as j } from "react/jsx-runtime";
1
+ import { jsx as s, jsxs as j } from "react/jsx-runtime";
2
2
  import "react";
3
3
  import { useFormContext as W } from "react-hook-form";
4
4
  import w from "../client/config/useRhfUtilsClientConfigContext.mjs";
5
5
  import E from "../devtool/LazyDevTool.mjs";
6
- import { FormSubmitError as d } from "../submit/error/FormSubmitError.mjs";
7
- import S from "../submit/error/setCtxErrorsByFormSubmitErrors.mjs";
6
+ import { FormSubmitError as c } from "../submit/error/FormSubmitError.mjs";
7
+ import S from "../submit/error/setCtxErrorsByFormSubmitFieldErrors.mjs";
8
8
  import U from "../utils/PassthroughChildren.mjs";
9
9
  import _ from "./_Controller.mjs";
10
10
  function G({
@@ -12,9 +12,9 @@ function G({
12
12
  formRef: p,
13
13
  //
14
14
  onSubmit: a,
15
- onSubmitError: s,
16
- onSubmitInvalid: x,
17
- Children: l,
15
+ onSubmitError: d,
16
+ onSubmitInvalid: l,
17
+ Children: x,
18
18
  //
19
19
  form: F,
20
20
  utils: r
@@ -22,7 +22,7 @@ function G({
22
22
  const e = W(), t = w(), y = async (o) => {
23
23
  r != null && r.stopSubmitPropagation && o.stopPropagation();
24
24
  try {
25
- await e.handleSubmit(f, x)(o);
25
+ await e.handleSubmit(f, l)(o);
26
26
  } catch (n) {
27
27
  P(n, o);
28
28
  }
@@ -33,19 +33,19 @@ function G({
33
33
  formRef: p,
34
34
  context: e,
35
35
  utils: r,
36
- FormSubmitError: d
36
+ FormSubmitError: c
37
37
  },
38
38
  n
39
39
  ), P = (o, n) => {
40
40
  var i;
41
- const C = o instanceof d ? (
41
+ const C = o instanceof c ? (
42
42
  // consumer can manually throw FormSubmitError (e.g., manual validation)
43
43
  o.errors
44
44
  ) : (
45
45
  // if error is not FormSubmitError, consumer can provide global handler
46
46
  (i = t == null ? void 0 : t.onSubmitErrorUnknown) == null ? void 0 : i.call(t, o)
47
47
  );
48
- C && S(e, C), s == null || s(
48
+ C && S(e, C), d == null || d(
49
49
  o,
50
50
  {
51
51
  formId: m,
@@ -61,22 +61,22 @@ function G({
61
61
  context: e,
62
62
  utils: r,
63
63
  Controller: _,
64
- FormSubmitError: d
64
+ FormSubmitError: c
65
65
  }, b = h, v = (t == null ? void 0 : t.FormComponent) ?? "form", T = (t == null ? void 0 : t.FormChildrenWrapper) ?? U;
66
- return /* @__PURE__ */ c(
66
+ return /* @__PURE__ */ s(
67
67
  v,
68
68
  {
69
69
  ...F,
70
70
  ref: p,
71
71
  onSubmit: (o) => void y(o),
72
72
  children: /* @__PURE__ */ j(T, { ...b, children: [
73
- (r == null ? void 0 : r.devTool) && /* @__PURE__ */ c(
73
+ (r == null ? void 0 : r.devTool) && /* @__PURE__ */ s(
74
74
  E,
75
75
  {
76
76
  props: typeof r.devTool == "object" ? r.devTool : void 0
77
77
  }
78
78
  ),
79
- /* @__PURE__ */ c(l, { ...h })
79
+ /* @__PURE__ */ s(x, { ...h })
80
80
  ] })
81
81
  }
82
82
  );
@@ -84,4 +84,3 @@ function G({
84
84
  export {
85
85
  G as default
86
86
  };
87
- //# sourceMappingURL=Form.mjs.map
@@ -9,4 +9,3 @@ function n(m) {
9
9
  export {
10
10
  n as default
11
11
  };
12
- //# sourceMappingURL=FormWithProviders.mjs.map
@@ -22,4 +22,3 @@ function v({
22
22
  export {
23
23
  v as default
24
24
  };
25
- //# sourceMappingURL=RhfUtilsFormProviders.mjs.map
@@ -6,4 +6,3 @@ function n(r) {
6
6
  export {
7
7
  n as default
8
8
  };
9
- //# sourceMappingURL=_Controller.mjs.map
@@ -28,4 +28,3 @@ const B = ({ children: o }) => {
28
28
  export {
29
29
  h as default
30
30
  };
31
- //# sourceMappingURL=FormGroupContextProvider.mjs.map
@@ -9,4 +9,3 @@ export {
9
9
  t as _useFormGroupContext,
10
10
  u as _useFormGroupContextMaybe
11
11
  };
12
- //# sourceMappingURL=index.mjs.map
@@ -4,4 +4,3 @@ const e = () => (r(!0), o()), t = e;
4
4
  export {
5
5
  t as default
6
6
  };
7
- //# sourceMappingURL=useFormGroupChildIsMountedTracker.mjs.map
@@ -8,4 +8,3 @@ const m = () => {
8
8
  export {
9
9
  n as default
10
10
  };
11
- //# sourceMappingURL=useFormGroupChildIsSubmittingTracker.mjs.map
@@ -11,4 +11,3 @@ const u = (s) => {
11
11
  export {
12
12
  d as default
13
13
  };
14
- //# sourceMappingURL=useFormGroupChildTracker.mjs.map
@@ -6,4 +6,3 @@ const r = () => {
6
6
  export {
7
7
  e as default
8
8
  };
9
- //# sourceMappingURL=useFormGroupIsAnyBusy.mjs.map
@@ -6,4 +6,3 @@ const s = () => {
6
6
  export {
7
7
  e as default
8
8
  };
9
- //# sourceMappingURL=useFormGroupIsChildBusy.mjs.map
@@ -6,4 +6,3 @@ const s = () => {
6
6
  export {
7
7
  s as default
8
8
  };
9
- //# sourceMappingURL=useFormGroupIsParentBusy.mjs.map
@@ -11,4 +11,3 @@ const m = () => {
11
11
  export {
12
12
  f as default
13
13
  };
14
- //# sourceMappingURL=useFormGroupParentTracker.mjs.map
@@ -8,4 +8,3 @@ const u = () => {
8
8
  export {
9
9
  a as default
10
10
  };
11
- //# sourceMappingURL=useFormOrParentIsBusy.mjs.map
@@ -1,22 +1,23 @@
1
- import { jsx as d } from "react/jsx-runtime";
2
- import i from "../../../client/config/useRhfUtilsClientConfigContext.mjs";
3
- import a from "../../../errors/flat/context/useFlatFieldErrorsContextOutput.mjs";
4
- import f from "../../../submit/useResetFormOnSubmitted.mjs";
1
+ import { jsx as f } from "react/jsx-runtime";
2
+ import l from "../../../client/config/useRhfUtilsClientConfigContext.mjs";
3
+ import d from "../../../errors/flat/context/useFlatFieldErrorsContextOutput.mjs";
4
+ import b from "../../../submit/useResetFormOnSubmitted.mjs";
5
5
  import C from "../../../submit/useSubmitFormOnChange.mjs";
6
- import { _RhfUtilsContextProvider as s } from "./useRhfUtilsContext.mjs";
7
- const n = ({
6
+ import { _RhfUtilsContextProvider as h } from "./useRhfUtilsContext.mjs";
7
+ const v = ({
8
8
  formId: u,
9
9
  formRef: t,
10
- options: r,
11
- children: l
10
+ options: e,
11
+ children: a
12
12
  }) => {
13
13
  var m;
14
- const e = i();
15
- return a((m = e == null ? void 0 : e.FieldErrors) == null ? void 0 : m.output), C(t, {
16
- disabled: !(r != null && r.submitOnChange)
17
- }), f(r == null ? void 0 : r.resetOnSubmitted), /* @__PURE__ */ d(s, { value: { formId: u, formRef: t, options: r }, children: l });
14
+ const r = l();
15
+ return d((m = r == null ? void 0 : r.fieldErrors) == null ? void 0 : m.output), C(t, {
16
+ // check for false/undefined
17
+ disabled: ((e == null ? void 0 : e.submitOnChange) ?? !1) === !1,
18
+ debounce: typeof (e == null ? void 0 : e.submitOnChange) == "number" ? e.submitOnChange : void 0
19
+ }), b(e == null ? void 0 : e.resetOnSubmitted), /* @__PURE__ */ f(h, { value: { formId: u, formRef: t, options: e }, children: a });
18
20
  };
19
21
  export {
20
- n as default
22
+ v as default
21
23
  };
22
- //# sourceMappingURL=RhfUtilsContextProvider.mjs.map
@@ -4,4 +4,3 @@ export {
4
4
  r as _RhfUtilsContextProvider,
5
5
  i as default
6
6
  };
7
- //# sourceMappingURL=useRhfUtilsContext.mjs.map
@@ -7,4 +7,3 @@ const o = () => {
7
7
  export {
8
8
  m as default
9
9
  };
10
- //# sourceMappingURL=useRhfUtilsContextRequestSubmit.mjs.map
@@ -6,4 +6,3 @@ const e = () => {
6
6
  export {
7
7
  e as default
8
8
  };
9
- //# sourceMappingURL=useFormIsBusy.mjs.map
@@ -41,4 +41,3 @@ const v = ({
41
41
  export {
42
42
  v as default
43
43
  };
44
- //# sourceMappingURL=useRhfUtilsForm.mjs.map
@@ -10,4 +10,3 @@ const e = (t) => {
10
10
  export {
11
11
  i as default
12
12
  };
13
- //# sourceMappingURL=getSubmitterButtonData.mjs.map
@@ -1,10 +1,13 @@
1
- const u = (t) => (r) => {
2
- if (!t.current) throw new Error();
3
- e(t.current, r);
4
- }, e = (t, r) => {
1
+ import e from "react";
2
+ const s = (t) => e.useCallback(
3
+ (r) => {
4
+ if (!t.current) throw new Error();
5
+ u(t.current, r);
6
+ },
7
+ [t]
8
+ ), u = (t, r) => {
5
9
  t.requestSubmit(r);
6
10
  };
7
11
  export {
8
- u as default
12
+ s as default
9
13
  };
10
- //# sourceMappingURL=useFormRequestSubmit.mjs.map
@@ -6,4 +6,3 @@ class t extends Error {
6
6
  export {
7
7
  t as FormSubmitError
8
8
  };
9
- //# sourceMappingURL=FormSubmitError.mjs.map
@@ -0,0 +1,12 @@
1
+ const s = (r, t) => {
2
+ Object.entries(t).forEach(([e, o]) => {
3
+ r.setError(e, {
4
+ type: "FormSubmitFieldError",
5
+ // default
6
+ ...o
7
+ });
8
+ });
9
+ };
10
+ export {
11
+ s as default
12
+ };
@@ -10,4 +10,3 @@ const c = (e, f) => {
10
10
  export {
11
11
  c as default
12
12
  };
13
- //# sourceMappingURL=useFormOnSubmitted.mjs.map
@@ -34,4 +34,3 @@ const p = (e) => {
34
34
  export {
35
35
  p as default
36
36
  };
37
- //# sourceMappingURL=useResetFormOnSubmitted.mjs.map
@@ -1,20 +1,26 @@
1
- import c from "react";
2
- import m from "../form/utils/useFormRequestSubmit.mjs";
3
- const d = (t, e) => {
4
- const u = !(e != null && e.disabled), a = m(t);
5
- c.useEffect(() => {
1
+ import d from "react";
2
+ import b from "../form/utils/useFormRequestSubmit.mjs";
3
+ import { useDebouncedOnChangeValue as h } from "../utils/useDebouncedOnChangeValue.mjs";
4
+ const l = (n, e) => {
5
+ const u = !(e != null && e.disabled), a = b(n), [c] = h({
6
+ // on change value after debounce
7
+ onChange: () => {
8
+ a();
9
+ },
10
+ delay: (e == null ? void 0 : e.debounce) ?? 0
11
+ });
12
+ d.useEffect(() => {
6
13
  if (!u) return;
7
- const r = t.current;
14
+ const r = n.current;
8
15
  if (!r) throw new Error();
9
- const n = () => {
10
- a();
16
+ const t = (m) => {
17
+ c(m);
11
18
  };
12
- return r.addEventListener("change", n), () => {
13
- r.removeEventListener("change", n);
19
+ return r.addEventListener("change", t), () => {
20
+ r.removeEventListener("change", t);
14
21
  };
15
22
  }, []);
16
23
  };
17
24
  export {
18
- d as default
25
+ l as default
19
26
  };
20
- //# sourceMappingURL=useSubmitFormOnChange.mjs.map
@@ -5,4 +5,3 @@ const a = ({
5
5
  export {
6
6
  a as default
7
7
  };
8
- //# sourceMappingURL=PassthroughChildren.mjs.map
@@ -14,4 +14,3 @@ function i() {
14
14
  export {
15
15
  i as default
16
16
  };
17
- //# sourceMappingURL=createContext.mjs.map
@@ -2,4 +2,3 @@ const e = (t) => Object.keys(t).length === 0;
2
2
  export {
3
3
  e as default
4
4
  };
5
- //# sourceMappingURL=isEmptyObject.mjs.map
@@ -0,0 +1,26 @@
1
+ import r from "react";
2
+ const a = ({
3
+ onChange: u,
4
+ delay: n
5
+ }) => {
6
+ const e = r.useRef(), c = () => {
7
+ e.current && (u(e.current.value), e.current = void 0);
8
+ }, t = () => {
9
+ e.current && clearTimeout(e.current.timer);
10
+ };
11
+ return r.useEffect(
12
+ // return timeout clearer
13
+ () => t,
14
+ []
15
+ ), [(o) => {
16
+ t(), e.current = {
17
+ // value being tracked
18
+ value: o,
19
+ // new timer
20
+ timer: setTimeout(c, n)
21
+ };
22
+ }];
23
+ };
24
+ export {
25
+ a as useDebouncedOnChangeValue
26
+ };
@@ -12,4 +12,3 @@ const f = (r) => {
12
12
  export {
13
13
  f as default
14
14
  };
15
- //# sourceMappingURL=useRefIfValueWasTrue.mjs.map
@@ -2,7 +2,7 @@ import { UseFormProps } from 'react-hook-form';
2
2
  import { FlatFieldErrorsOutputConfig } from '../../errors/flat/context/FlatFieldErrorsOutputConfig';
3
3
  import { RhfUtilsFormOptions } from '../../form/RhfUtilsFormOptions';
4
4
  import { UseRhfUtilsFormChildrenProps } from '../../form/UseRhfUtilsFormChildrenProps';
5
- import { FormSubmitErrors } from '../../submit/error/FormSubmitErrors';
5
+ import { FormSubmitFieldErrors } from '../../submit/error/FormSubmitFieldErrors';
6
6
 
7
7
  /**
8
8
  * Client configuration object.
@@ -51,14 +51,14 @@ export type RhfUtilsClientConfig = {
51
51
  * Global submit error handler when/if submit handler throws an error other than {@link FormSubmitError}.
52
52
  *
53
53
  * Example use case:
54
- * - transform API errors to {@link FormSubmitErrors}.
54
+ * - transform API errors to {@link FormSubmitFieldErrors}.
55
55
  *
56
56
  * @returns
57
- * - if {@link FormSubmitErrors}: merge into context errors.
57
+ * - if {@link FormSubmitFieldErrors}: merge into context errors.
58
58
  * - if `undefined`: do nothing.
59
59
  */
60
- onSubmitErrorUnknown?: (error: unknown) => FormSubmitErrors | undefined;
61
- FieldErrors?: {
60
+ onSubmitErrorUnknown?: (error: unknown) => FormSubmitFieldErrors | undefined;
61
+ fieldErrors?: {
62
62
  /**
63
63
  * Configure how/if errors should be outputted.
64
64
  */
@@ -2,7 +2,7 @@ import { default as React } from 'react';
2
2
  import { RhfUtilsClientConfig } from '../../config/RhfUtilsClientConfig';
3
3
 
4
4
  type Props = React.PropsWithChildren<{
5
- config: RhfUtilsClientConfig;
5
+ config?: RhfUtilsClientConfig;
6
6
  }>;
7
7
  declare const RhfUtilsClientForZodContextProvider: React.FC<Props>;
8
8
  export default RhfUtilsClientForZodContextProvider;
@@ -1,9 +1,10 @@
1
1
  import { FieldErrors } from 'react-hook-form';
2
2
 
3
3
  /**
4
- * Only flattens a {@link FieldErrors} object.
4
+ * Flatten a {@link FieldErrors} object.
5
+ *
5
6
  * @returns e.g.,
6
- * ```
7
+ * ```ts
7
8
  * {
8
9
  * "address.street.type": "too_short",
9
10
  * "address.street.ref.value": "123",
@@ -6,5 +6,5 @@ type Props = {
6
6
  message: string;
7
7
  }>;
8
8
  };
9
- declare const FormErrorMessageByPath: React.FC<Props>;
10
- export default FormErrorMessageByPath;
9
+ declare const RhfUtilsFieldErrorMessage: React.FC<Props>;
10
+ export default RhfUtilsFieldErrorMessage;
@@ -1,5 +1,5 @@
1
1
  import { RhfUtilsClientConfig } from '../../client/config/RhfUtilsClientConfig';
2
- import { FormSubmitErrors } from '../../submit/error/FormSubmitErrors';
2
+ import { FormSubmitFieldErrors } from '../../submit/error/FormSubmitFieldErrors';
3
3
 
4
4
  /**
5
5
  * HOF that returns submit error handler for {@link RhfUtilsClientConfig.onSubmitErrorUnknown}.
@@ -7,5 +7,5 @@ import { FormSubmitErrors } from '../../submit/error/FormSubmitErrors';
7
7
  * @param onError Fallback for handling non-TRPC errors.
8
8
  * @returns FormSubmitError
9
9
  */
10
- declare const getOnSubmitTrpcClientErrorHandler: (onNotTrpcClientError: NonNullable<RhfUtilsClientConfig["onSubmitErrorUnknown"]>) => (error: unknown) => FormSubmitErrors | undefined;
10
+ declare const getOnSubmitTrpcClientErrorHandler: (onNotTrpcClientError: NonNullable<RhfUtilsClientConfig["onSubmitErrorUnknown"]>) => (error: unknown) => FormSubmitFieldErrors | undefined;
11
11
  export default getOnSubmitTrpcClientErrorHandler;
@@ -0,0 +1,28 @@
1
+ import { TRPCClientErrorLike } from '@trpc/client';
2
+ import { AnyRouter } from '@trpc/server';
3
+ import { z } from 'zod';
4
+ import { FormSubmitFieldErrors } from '../../submit/error/FormSubmitFieldErrors';
5
+
6
+ /**
7
+ * Schema that transforms {@link TRPCClientError} to RHF {@link FormSubmitFieldErrors}.
8
+ */
9
+ declare const trpcClientErrorToFormSubmitFieldErrorsSchemaTransformer: z.ZodEffects<z.ZodEffects<z.ZodPipeline<z.ZodEffects<z.ZodEffects<z.ZodType<TRPCClientErrorLike<AnyRouter>, z.ZodTypeDef, TRPCClientErrorLike<AnyRouter>>, string, TRPCClientErrorLike<AnyRouter>>, unknown, TRPCClientErrorLike<AnyRouter>>, z.ZodArray<z.ZodObject<{
10
+ validation: z.ZodString;
11
+ code: z.ZodString;
12
+ message: z.ZodString;
13
+ path: z.ZodArray<z.ZodString, "many">;
14
+ }, "strip", z.ZodTypeAny, {
15
+ message: string;
16
+ code: string;
17
+ path: string[];
18
+ validation: string;
19
+ }, {
20
+ message: string;
21
+ code: string;
22
+ path: string[];
23
+ validation: string;
24
+ }>, "many">>, (readonly [string, {
25
+ type: string;
26
+ message: string;
27
+ }])[], TRPCClientErrorLike<AnyRouter>>, FormSubmitFieldErrors, TRPCClientErrorLike<AnyRouter>>;
28
+ export default trpcClientErrorToFormSubmitFieldErrorsSchemaTransformer;
@@ -7,11 +7,9 @@ export type { RhfUtilsUseFormChildrenZodFC } from './client/zod/RhfUtilsUseFormC
7
7
  export type { RhfUtilsUseFormChildrenZodProps } from './client/zod/RhfUtilsUseFormChildrenZodProps';
8
8
  export { default as useFlatFieldErrorsContext } from './errors/flat/context/useFlatFieldErrorsContext';
9
9
  export { default as useFlatFieldErrorsContextHasOnlyOrphans } from './errors/flat/context/useFlatFieldErrorsContextHasOnlyOrphans';
10
- export { default as FormErrorMessageByPath } from './errors/message/FormErrorMessageByPath';
10
+ export { default as RhfUtilsFieldErrorMessage } from './errors/message/RhfUtilsFieldErrorMessage';
11
11
  export { default as FormNonFieldErrorMarker } from './errors/nonfield/FormNonFieldErrorMarker';
12
12
  export { default as RootErrorsListFromFlatFieldErrorsContext } from './errors/root/RootErrorsListFromFlatFieldErrorsContext';
13
- export { default as getOnSubmitTrpcClientErrorHandler } from './errors/trpc/getOnSubmitTrpcClientErrorHandler';
14
- export { default as trpcClientErrorToFormSubmitErrorsSchemaTransformer } from './errors/trpc/trpcClientErrorToFormSubmitErrorsSchemaTransformer';
15
13
  export type { RhfUtilsFormOptions } from './form/RhfUtilsFormOptions';
16
14
  export type { SafeFieldValues } from './form/SafeFieldValues';
17
15
  export type { UseRhfUtilsFormChildrenProps } from './form/UseRhfUtilsFormChildrenProps';
@@ -10,8 +10,12 @@ import { Register } from '../register';
10
10
  export type RhfUtilsFormOptions = {
11
11
  /** Stop propagation of submit event. */
12
12
  stopSubmitPropagation?: boolean;
13
- /** Request submit via listener on form change. */
14
- submitOnChange?: boolean;
13
+ /**
14
+ * Request submit via listener on form change.
15
+ * - `true` to submit on any change.
16
+ * - number to debounce in milliseconds.
17
+ */
18
+ submitOnChange?: boolean | number;
15
19
  /** Reset form values and state (e.g., `isDirty`) after submit -- on success and/or error. */
16
20
  resetOnSubmitted?: UseResetFormOnSubmittedOptions;
17
21
  /**
@@ -19,7 +23,7 @@ export type RhfUtilsFormOptions = {
19
23
  * (Lazy-loaded when truthy value supplied.
20
24
  * For zero bundle size in prod, be sure to check for dev environment.)
21
25
  */
22
- devTool?: true | Pick<DevtoolUIProps, 'placement' | 'styles'>;
26
+ devTool?: boolean | Pick<DevtoolUIProps, 'placement' | 'styles'>;
23
27
  } & (Register extends {
24
28
  RhfUtilsFormOptions: infer _RhfUtilsFormOptions;
25
29
  } ? _RhfUtilsFormOptions : {});
@@ -1,6 +1,6 @@
1
- import { MaybePromise } from '@trpc/server/unstable-core-do-not-import';
2
1
  import { default as React } from 'react';
3
2
  import { SubmitErrorHandler, UseFormProps } from 'react-hook-form';
3
+ import { MaybePromise } from '../utils/types';
4
4
  import { RhfUtilsFormOptions } from './RhfUtilsFormOptions';
5
5
  import { SafeFieldValues } from './SafeFieldValues';
6
6
  import { UseRhfUtilsFormChildrenProps } from './UseRhfUtilsFormChildrenProps';