@paragrav/rhf-utils 0.0.138 → 0.0.140

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 (175) hide show
  1. package/README.md +29 -18
  2. package/dist/esm/{utils/createContext.mjs → createContext.mjs} +1 -1
  3. package/dist/esm/group.mjs +74 -0
  4. package/dist/esm/main.mjs +483 -0
  5. package/dist/esm/trpc.mjs +41 -0
  6. package/dist/esm/useFlatFieldErrorsContext.mjs +10 -0
  7. package/dist/esm/utils.mjs +20 -0
  8. package/dist/types/group.d.ts +9 -0
  9. package/dist/types/main.d.ts +15 -1
  10. package/dist/types/trpc.d.ts +2 -0
  11. package/dist/types/utils.d.ts +1 -0
  12. package/package.json +22 -4
  13. package/dist/esm/client/config/useRhfUtilsClientConfigContext.mjs +0 -9
  14. package/dist/esm/client/index.mjs +0 -49
  15. package/dist/esm/client/utils.mjs +0 -38
  16. package/dist/esm/client/zod/context/RhfUtilsClientForZodContextProvider.mjs +0 -17
  17. package/dist/esm/client/zod/context/RhfUtilsZodForm.mjs +0 -12
  18. package/dist/esm/client/zod/context/useRhfUtilsClientForZodContext.mjs +0 -9
  19. package/dist/esm/client/zod/context/useRhfUtilsZodForm.mjs +0 -5
  20. package/dist/esm/client/zod/createRhfUtilsClientForZod.mjs +0 -6
  21. package/dist/esm/devtool/LazyDevTool.mjs +0 -15
  22. package/dist/esm/errors/flat/FlatFieldErrorsList.mjs +0 -17
  23. package/dist/esm/errors/flat/context/FlatFieldErrorsContextProvider.mjs +0 -27
  24. package/dist/esm/errors/flat/context/useFlatFieldErrorsContext.mjs +0 -9
  25. package/dist/esm/errors/flat/context/useFlatFieldErrorsContextHasOnlyOrphans.mjs +0 -9
  26. package/dist/esm/errors/flat/context/useFlatFieldErrorsContextOutput.mjs +0 -24
  27. package/dist/esm/errors/flat/filterFlatFieldErrors.mjs +0 -10
  28. package/dist/esm/errors/flat/flattenFieldErrors.mjs +0 -5
  29. package/dist/esm/errors/flat/getFlatFieldErrors.mjs +0 -24
  30. package/dist/esm/errors/getRefdFromFlatFieldErrors.mjs +0 -8
  31. package/dist/esm/errors/isFieldErrorRefd.mjs +0 -4
  32. package/dist/esm/errors/isFlatFieldErrorEntryRefd.mjs +0 -5
  33. package/dist/esm/errors/message/FormErrorMessage.mjs +0 -14
  34. package/dist/esm/errors/message/RhfUtilsFieldErrorMessage.mjs +0 -14
  35. package/dist/esm/errors/nonfield/FormNonFieldErrorMarker.mjs +0 -19
  36. package/dist/esm/errors/nonfield/FormNonFieldErrorMarker.utils.mjs +0 -23
  37. package/dist/esm/errors/nonfield/FormNonFieldErrorMarkerHtmlAttribute.mjs +0 -4
  38. package/dist/esm/errors/nonfield/isNonFieldErrorMarkerInDOM.mjs +0 -5
  39. package/dist/esm/errors/orphan/getIsOrphanFormErrorWithParentElement.mjs +0 -5
  40. package/dist/esm/errors/orphan/getOrphansFromFlatFieldErrors.mjs +0 -8
  41. package/dist/esm/errors/orphan/isOrphanFormError.mjs +0 -12
  42. package/dist/esm/errors/output/consoleErrors.mjs +0 -6
  43. package/dist/esm/errors/root/RootErrorsListFromFlatFieldErrorsContext.mjs +0 -10
  44. package/dist/esm/errors/root/consts.mjs +0 -4
  45. package/dist/esm/errors/root/getRootsFromFlatFieldErrors.mjs +0 -8
  46. package/dist/esm/errors/root/isFlatFieldErrorEntryPathRoot.mjs +0 -5
  47. package/dist/esm/errors/root/isFormErrorPathRoot.mjs +0 -5
  48. package/dist/esm/exports.mjs +0 -46
  49. package/dist/esm/form/Form.mjs +0 -86
  50. package/dist/esm/form/FormWithProviders.mjs +0 -11
  51. package/dist/esm/form/RhfUtilsFormProviders.mjs +0 -24
  52. package/dist/esm/form/_Controller.mjs +0 -8
  53. package/dist/esm/form/context/group/FormGroupContextProvider.mjs +0 -30
  54. package/dist/esm/form/context/group/index.mjs +0 -11
  55. package/dist/esm/form/context/group/useFormGroupChildIsMountedTracker.mjs +0 -6
  56. package/dist/esm/form/context/group/useFormGroupChildIsSubmittingTracker.mjs +0 -10
  57. package/dist/esm/form/context/group/useFormGroupChildTracker.mjs +0 -13
  58. package/dist/esm/form/context/group/useFormGroupIsAnyBusy.mjs +0 -8
  59. package/dist/esm/form/context/group/useFormGroupIsChildBusy.mjs +0 -8
  60. package/dist/esm/form/context/group/useFormGroupIsParentBusy.mjs +0 -8
  61. package/dist/esm/form/context/group/useFormGroupParentTracker.mjs +0 -13
  62. package/dist/esm/form/context/group/useFormOrParentIsBusy.mjs +0 -10
  63. package/dist/esm/form/context/utils/RhfUtilsContextProvider.mjs +0 -23
  64. package/dist/esm/form/context/utils/useRhfUtilsContext.mjs +0 -6
  65. package/dist/esm/form/context/utils/useRhfUtilsContextRequestSubmit.mjs +0 -9
  66. package/dist/esm/form/useFormIsBusy.mjs +0 -8
  67. package/dist/esm/form/useRhfUtilsForm.mjs +0 -43
  68. package/dist/esm/form/utils/getSubmitterButtonData.mjs +0 -12
  69. package/dist/esm/form/utils/useFormRequestSubmit.mjs +0 -13
  70. package/dist/esm/submit/error/FormSubmitError.mjs +0 -8
  71. package/dist/esm/submit/error/setCtxErrorsByFormSubmitFieldErrors.mjs +0 -12
  72. package/dist/esm/submit/useFormOnSubmitted.mjs +0 -12
  73. package/dist/esm/submit/useResetFormOnSubmitted.mjs +0 -36
  74. package/dist/esm/submit/useSubmitFormOnChange.mjs +0 -26
  75. package/dist/esm/utils/PassthroughChildren.mjs +0 -7
  76. package/dist/esm/utils/isEmptyObject.mjs +0 -4
  77. package/dist/esm/utils/useDebouncedOnChangeValue.mjs +0 -26
  78. package/dist/esm/utils/useRefIfValueWasTrue.mjs +0 -14
  79. package/dist/types/client/config/RhfUtilsClientConfig.d.ts +0 -71
  80. package/dist/types/client/config/useRhfUtilsClientConfigContext.d.ts +0 -5
  81. package/dist/types/client/context.d.ts +0 -3
  82. package/dist/types/client/index.d.ts +0 -30
  83. package/dist/types/client/utils.d.ts +0 -13
  84. package/dist/types/client/zod/RhfUtilsUseFormChildrenZodFC.d.ts +0 -13
  85. package/dist/types/client/zod/RhfUtilsUseFormChildrenZodProps.d.ts +0 -5
  86. package/dist/types/client/zod/ZodTypeFieldValues.d.ts +0 -4
  87. package/dist/types/client/zod/consts.d.ts +0 -4
  88. package/dist/types/client/zod/context/RhfUtilsClientForZodContextProvider.d.ts +0 -8
  89. package/dist/types/client/zod/context/RhfUtilsZodForm.d.ts +0 -9
  90. package/dist/types/client/zod/context/useRhfUtilsClientForZodContext.d.ts +0 -6
  91. package/dist/types/client/zod/context/useRhfUtilsZodForm.d.ts +0 -8
  92. package/dist/types/client/zod/createRhfUtilsClientForZod.d.ts +0 -4
  93. package/dist/types/devtool/LazyDevTool.d.ts +0 -12
  94. package/dist/types/errors/flat/FlatFieldErrorsList.d.ts +0 -7
  95. package/dist/types/errors/flat/context/FlatFieldErrorsContextProvider.d.ts +0 -11
  96. package/dist/types/errors/flat/context/FlatFieldErrorsOutputConfig.d.ts +0 -20
  97. package/dist/types/errors/flat/context/useFlatFieldErrorsContext.d.ts +0 -13
  98. package/dist/types/errors/flat/context/useFlatFieldErrorsContextHasOnlyOrphans.d.ts +0 -7
  99. package/dist/types/errors/flat/context/useFlatFieldErrorsContextOutput.d.ts +0 -7
  100. package/dist/types/errors/flat/filterFlatFieldErrors.d.ts +0 -9
  101. package/dist/types/errors/flat/flattenFieldErrors.d.ts +0 -16
  102. package/dist/types/errors/flat/getFlatFieldErrors.d.ts +0 -32
  103. package/dist/types/errors/flat/types.d.ts +0 -17
  104. package/dist/types/errors/getRefdFromFlatFieldErrors.d.ts +0 -2
  105. package/dist/types/errors/isFieldErrorRefd.d.ts +0 -7
  106. package/dist/types/errors/isFlatFieldErrorEntryRefd.d.ts +0 -7
  107. package/dist/types/errors/message/FormErrorMessage.d.ts +0 -8
  108. package/dist/types/errors/message/RhfUtilsFieldErrorMessage.d.ts +0 -10
  109. package/dist/types/errors/nonfield/FormNonFieldErrorMarker.d.ts +0 -13
  110. package/dist/types/errors/nonfield/FormNonFieldErrorMarker.spec.d.ts +0 -1
  111. package/dist/types/errors/nonfield/FormNonFieldErrorMarker.utils.d.ts +0 -18
  112. package/dist/types/errors/nonfield/FormNonFieldErrorMarkerHtmlAttribute.d.ts +0 -5
  113. package/dist/types/errors/nonfield/isNonFieldError.d.ts +0 -19
  114. package/dist/types/errors/nonfield/isNonFieldErrorMarkerInDOM.d.ts +0 -6
  115. package/dist/types/errors/orphan/getIsOrphanFormErrorWithParentElement.d.ts +0 -7
  116. package/dist/types/errors/orphan/getOrphansFromFlatFieldErrors.d.ts +0 -4
  117. package/dist/types/errors/orphan/isOrphanFormError.d.ts +0 -4
  118. package/dist/types/errors/output/consoleErrors.d.ts +0 -7
  119. package/dist/types/errors/output/types.d.ts +0 -7
  120. package/dist/types/errors/root/RootErrorsListFromFlatFieldErrorsContext.d.ts +0 -2
  121. package/dist/types/errors/root/consts.d.ts +0 -1
  122. package/dist/types/errors/root/getRootsFromFlatFieldErrors.d.ts +0 -2
  123. package/dist/types/errors/root/isFlatFieldErrorEntryPathRoot.d.ts +0 -7
  124. package/dist/types/errors/root/isFormErrorPathRoot.d.ts +0 -7
  125. package/dist/types/errors/trpc/getOnSubmitTrpcClientErrorHandler.d.ts +0 -11
  126. package/dist/types/errors/trpc/trpcClientErrorMessageSchema.d.ts +0 -24
  127. package/dist/types/errors/trpc/trpcClientErrorToFormSubmitFieldErrorsSchemaTransformer.d.ts +0 -28
  128. package/dist/types/exports.d.ts +0 -29
  129. package/dist/types/form/Form.d.ts +0 -11
  130. package/dist/types/form/FormWithProviders.d.ts +0 -13
  131. package/dist/types/form/RhfUtilsFormOptions.d.ts +0 -29
  132. package/dist/types/form/RhfUtilsFormProviders.d.ts +0 -12
  133. package/dist/types/form/SafeFieldValues.d.ts +0 -4
  134. package/dist/types/form/UseRhfUtilsFormChildrenProps.d.ts +0 -20
  135. package/dist/types/form/UseRhfUtilsFormOnSubmitContext.d.ts +0 -27
  136. package/dist/types/form/UseRhfUtilsFormProps.d.ts +0 -23
  137. package/dist/types/form/UseRhfUtilsFormReturn.d.ts +0 -20
  138. package/dist/types/form/_Controller.d.ts +0 -6
  139. package/dist/types/form/context/group/FormGroupContextProvider.d.ts +0 -5
  140. package/dist/types/form/context/group/index.d.ts +0 -14
  141. package/dist/types/form/context/group/useFormGroupChildIsMountedTracker.d.ts +0 -5
  142. package/dist/types/form/context/group/useFormGroupChildIsSubmittingTracker.d.ts +0 -5
  143. package/dist/types/form/context/group/useFormGroupChildTracker.d.ts +0 -6
  144. package/dist/types/form/context/group/useFormGroupIsAnyBusy.d.ts +0 -2
  145. package/dist/types/form/context/group/useFormGroupIsChildBusy.d.ts +0 -2
  146. package/dist/types/form/context/group/useFormGroupIsParentBusy.d.ts +0 -2
  147. package/dist/types/form/context/group/useFormGroupParentTracker.d.ts +0 -7
  148. package/dist/types/form/context/group/useFormOrParentIsBusy.d.ts +0 -2
  149. package/dist/types/form/context/utils/RhfUtilsContextProvider.d.ts +0 -9
  150. package/dist/types/form/context/utils/useRhfUtilsContext.d.ts +0 -14
  151. package/dist/types/form/context/utils/useRhfUtilsContextRequestSubmit.d.ts +0 -5
  152. package/dist/types/form/useFormIsBusy.d.ts +0 -2
  153. package/dist/types/form/useRhfUtilsForm.d.ts +0 -16
  154. package/dist/types/form/utils/getSubmitterButtonData.d.ts +0 -8
  155. package/dist/types/form/utils/useFormRequestSubmit.d.ts +0 -11
  156. package/dist/types/form/utils/useShouldFormBlockNavigation.d.ts +0 -26
  157. package/dist/types/register.d.ts +0 -7
  158. package/dist/types/submit/error/FormSubmitError.d.ts +0 -7
  159. package/dist/types/submit/error/FormSubmitFieldErrors.d.ts +0 -15
  160. package/dist/types/submit/error/setCtxErrorsByFormSubmitFieldErrors.d.ts +0 -10
  161. package/dist/types/submit/useFormOnSubmitSuccessfulAndReset.d.ts +0 -15
  162. package/dist/types/submit/useFormOnSubmitted.d.ts +0 -6
  163. package/dist/types/submit/useResetFormOnSubmitted.d.ts +0 -36
  164. package/dist/types/submit/useSubmitFormOnChange.d.ts +0 -9
  165. package/dist/types/utils/PassthroughChildren.d.ts +0 -7
  166. package/dist/types/utils/createContext.d.ts +0 -12
  167. package/dist/types/utils/fixedForwardRef.d.ts +0 -7
  168. package/dist/types/utils/isEmptyObject.d.ts +0 -2
  169. package/dist/types/utils/timeoutAsync.d.ts +0 -6
  170. package/dist/types/utils/types.d.ts +0 -1
  171. package/dist/types/utils/useDebouncedOnChangeValue.d.ts +0 -14
  172. package/dist/types/utils/useImperativeForwardedRef.d.ts +0 -11
  173. package/dist/types/utils/useRefIfValueWasTrue.d.ts +0 -2
  174. package/dist/types/utils/useThrowAsyncError.d.ts +0 -5
  175. package/dist/types/utils/useToggle.d.ts +0 -4
@@ -1,46 +0,0 @@
1
- import { default as e } from "./client/zod/context/RhfUtilsClientForZodContextProvider.mjs";
2
- import { default as s } from "./client/zod/context/RhfUtilsZodForm.mjs";
3
- import { default as u } from "./client/zod/context/useRhfUtilsZodForm.mjs";
4
- import { default as m } from "./errors/flat/context/useFlatFieldErrorsContext.mjs";
5
- import { default as d } from "./errors/flat/context/useFlatFieldErrorsContextHasOnlyOrphans.mjs";
6
- import { default as x } from "./errors/message/RhfUtilsFieldErrorMessage.mjs";
7
- import { default as F } from "./errors/nonfield/FormNonFieldErrorMarker.mjs";
8
- import { default as C } from "./errors/root/RootErrorsListFromFlatFieldErrorsContext.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";
23
- export {
24
- I as FormGroupContextProvider,
25
- F as FormNonFieldErrorMarker,
26
- z as FormSubmitError,
27
- e as RhfUtilsClientForZodContextProvider,
28
- x as RhfUtilsFieldErrorMessage,
29
- s as RhfUtilsZodForm,
30
- C as RootErrorsListFromFlatFieldErrorsContext,
31
- L as getSubmitterButtonData,
32
- m as useFlatFieldErrorsContext,
33
- d as useFlatFieldErrorsContextHasOnlyOrphans,
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,
45
- u as useRhfUtilsZodForm
46
- };
@@ -1,86 +0,0 @@
1
- import { jsx as s, jsxs as j } from "react/jsx-runtime";
2
- import "react";
3
- import { useFormContext as W } from "react-hook-form";
4
- import w from "../client/config/useRhfUtilsClientConfigContext.mjs";
5
- import E from "../devtool/LazyDevTool.mjs";
6
- import { FormSubmitError as c } from "../submit/error/FormSubmitError.mjs";
7
- import S from "../submit/error/setCtxErrorsByFormSubmitFieldErrors.mjs";
8
- import U from "../utils/PassthroughChildren.mjs";
9
- import _ from "./_Controller.mjs";
10
- function G({
11
- formId: m,
12
- formRef: p,
13
- //
14
- onSubmit: a,
15
- onSubmitError: d,
16
- onSubmitInvalid: l,
17
- Children: x,
18
- //
19
- form: F,
20
- utils: r
21
- }) {
22
- const e = W(), t = w(), y = async (o) => {
23
- r != null && r.stopSubmitPropagation && o.stopPropagation();
24
- try {
25
- await e.handleSubmit(f, l)(o);
26
- } catch (n) {
27
- P(n, o);
28
- }
29
- }, f = (o, n) => a == null ? void 0 : a(
30
- o,
31
- {
32
- formId: m,
33
- formRef: p,
34
- context: e,
35
- utils: r,
36
- FormSubmitError: c
37
- },
38
- n
39
- ), P = (o, n) => {
40
- var i;
41
- const C = o instanceof c ? (
42
- // consumer can manually throw FormSubmitError (e.g., manual validation)
43
- o.errors
44
- ) : (
45
- // if error is not FormSubmitError, consumer can provide global handler
46
- (i = t == null ? void 0 : t.onSubmitErrorUnknown) == null ? void 0 : i.call(t, o)
47
- );
48
- C && S(e, C), d == null || d(
49
- o,
50
- {
51
- formId: m,
52
- formRef: p,
53
- context: e,
54
- utils: r
55
- },
56
- n
57
- );
58
- }, h = {
59
- formId: m,
60
- formRef: p,
61
- context: e,
62
- utils: r,
63
- Controller: _,
64
- FormSubmitError: c
65
- }, b = h, v = (t == null ? void 0 : t.FormComponent) ?? "form", T = (t == null ? void 0 : t.FormChildrenWrapper) ?? U;
66
- return /* @__PURE__ */ s(
67
- v,
68
- {
69
- ...F,
70
- ref: p,
71
- onSubmit: (o) => void y(o),
72
- children: /* @__PURE__ */ j(T, { ...b, children: [
73
- (r == null ? void 0 : r.devTool) && /* @__PURE__ */ s(
74
- E,
75
- {
76
- props: typeof r.devTool == "object" ? r.devTool : void 0
77
- }
78
- ),
79
- /* @__PURE__ */ s(x, { ...h })
80
- ] })
81
- }
82
- );
83
- }
84
- export {
85
- G as default
86
- };
@@ -1,11 +0,0 @@
1
- import { jsx as o } from "react/jsx-runtime";
2
- import i from "./Form.mjs";
3
- import t from "./RhfUtilsFormProviders.mjs";
4
- import f from "./useRhfUtilsForm.mjs";
5
- function n(m) {
6
- const r = f(m);
7
- return /* @__PURE__ */ o(t, { ...r.providerProps, children: /* @__PURE__ */ o(i, { ...r.formProps }) });
8
- }
9
- export {
10
- n as default
11
- };
@@ -1,24 +0,0 @@
1
- import { jsx as r } from "react/jsx-runtime";
2
- import { FormProvider as d } from "react-hook-form";
3
- import n from "../errors/flat/context/FlatFieldErrorsContextProvider.mjs";
4
- import l from "./context/utils/RhfUtilsContextProvider.mjs";
5
- function v({
6
- formId: t,
7
- formRef: o,
8
- rhfForm: i,
9
- utils: e,
10
- children: m
11
- }) {
12
- return /* @__PURE__ */ r(d, { ...i, children: /* @__PURE__ */ r(n, { formRef: o, children: /* @__PURE__ */ r(
13
- l,
14
- {
15
- formId: t,
16
- formRef: o,
17
- options: e,
18
- children: m
19
- }
20
- ) }) });
21
- }
22
- export {
23
- v as default
24
- };
@@ -1,8 +0,0 @@
1
- import { jsx as o } from "react/jsx-runtime";
2
- import { Controller as t } from "react-hook-form";
3
- function n(r) {
4
- return /* @__PURE__ */ o(t, { ...r });
5
- }
6
- export {
7
- n as default
8
- };
@@ -1,30 +0,0 @@
1
- import { jsx as y } from "react/jsx-runtime";
2
- import s from "react";
3
- import { _FormGroupContextProvider as m } from "./index.mjs";
4
- const B = ({ children: o }) => {
5
- const [t, u] = s.useState([]), n = t.length, a = s.useCallback((e, l) => {
6
- u(
7
- (r) => l ? (
8
- // add to array
9
- [...r, e]
10
- ) : (
11
- // remove from array
12
- r.filter((c) => c !== e)
13
- )
14
- );
15
- }, []), [d, i] = s.useState(!1);
16
- return /* @__PURE__ */ y(m, { value: {
17
- children: {
18
- busyCount: n,
19
- busyIds: t,
20
- setBusyId: a
21
- },
22
- parent: {
23
- isBusy: d,
24
- setIsBusy: i
25
- }
26
- }, children: o });
27
- }, h = B;
28
- export {
29
- h as default
30
- };
@@ -1,11 +0,0 @@
1
- import e from "../../../utils/createContext.mjs";
2
- const {
3
- Provider: r,
4
- useRequired: t,
5
- useMaybe: u
6
- } = e();
7
- export {
8
- r as _FormGroupContextProvider,
9
- t as _useFormGroupContext,
10
- u as _useFormGroupContextMaybe
11
- };
@@ -1,6 +0,0 @@
1
- import r from "./useFormGroupChildTracker.mjs";
2
- import o from "./useFormGroupIsParentBusy.mjs";
3
- const e = () => (r(!0), o()), t = e;
4
- export {
5
- t as default
6
- };
@@ -1,10 +0,0 @@
1
- import { useFormState as o } from "react-hook-form";
2
- import t from "./useFormGroupChildTracker.mjs";
3
- import u from "./useFormGroupIsParentBusy.mjs";
4
- const m = () => {
5
- const { isSubmitting: r } = o();
6
- return t(r), u();
7
- }, n = m;
8
- export {
9
- n as default
10
- };
@@ -1,13 +0,0 @@
1
- import o from "react";
2
- import { _useFormGroupContext as t } from "./index.mjs";
3
- const u = (s) => {
4
- const { setBusyId: e } = t().children, r = o.useId();
5
- o.useEffect(() => {
6
- e(r, s);
7
- }, [s, r, e]), o.useEffect(() => () => {
8
- e(r, !1);
9
- }, []);
10
- }, d = u;
11
- export {
12
- d as default
13
- };
@@ -1,8 +0,0 @@
1
- import { _useFormGroupContextMaybe as s } from "./index.mjs";
2
- const r = () => {
3
- const o = s();
4
- return !!(o != null && o.children.busyCount) || !!(o != null && o.parent.isBusy);
5
- }, e = r;
6
- export {
7
- e as default
8
- };
@@ -1,8 +0,0 @@
1
- import { _useFormGroupContextMaybe as r } from "./index.mjs";
2
- const s = () => {
3
- const o = r();
4
- return !!(o != null && o.children.busyCount);
5
- }, e = s;
6
- export {
7
- e as default
8
- };
@@ -1,8 +0,0 @@
1
- import { _useFormGroupContextMaybe as o } from "./index.mjs";
2
- const s = () => {
3
- const r = o();
4
- return !!(r != null && r.parent.isBusy);
5
- };
6
- export {
7
- s as default
8
- };
@@ -1,13 +0,0 @@
1
- import s from "react";
2
- import t from "../../useFormIsBusy.mjs";
3
- import { _useFormGroupContext as e } from "./index.mjs";
4
- import u from "./useFormGroupIsChildBusy.mjs";
5
- const m = () => {
6
- const r = t(), { setIsBusy: o } = e().parent;
7
- return s.useEffect(() => {
8
- o(r);
9
- }, [o, r]), u();
10
- }, f = m;
11
- export {
12
- f as default
13
- };
@@ -1,10 +0,0 @@
1
- import t from "../../useFormIsBusy.mjs";
2
- import { _useFormGroupContextMaybe as e } from "./index.mjs";
3
- const u = () => {
4
- var s;
5
- const r = t(), o = (s = e()) == null ? void 0 : s.parent.isBusy;
6
- return !!(r || o);
7
- }, a = u;
8
- export {
9
- a as default
10
- };
@@ -1,23 +0,0 @@
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
- import C from "../../../submit/useSubmitFormOnChange.mjs";
6
- import { _RhfUtilsContextProvider as h } from "./useRhfUtilsContext.mjs";
7
- const v = ({
8
- formId: u,
9
- formRef: t,
10
- options: e,
11
- children: a
12
- }) => {
13
- var m;
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 });
20
- };
21
- export {
22
- v as default
23
- };
@@ -1,6 +0,0 @@
1
- import t from "../../../utils/createContext.mjs";
2
- const { Provider: r, useRequired: e } = t(), o = e, i = o;
3
- export {
4
- r as _RhfUtilsContextProvider,
5
- i as default
6
- };
@@ -1,9 +0,0 @@
1
- import e from "../../utils/useFormRequestSubmit.mjs";
2
- import s from "./useRhfUtilsContext.mjs";
3
- const o = () => {
4
- const t = s();
5
- return e(t.formRef);
6
- }, m = o;
7
- export {
8
- m as default
9
- };
@@ -1,8 +0,0 @@
1
- import { useFormState as o } from "react-hook-form";
2
- const e = () => {
3
- const { isSubmitting: t, isLoading: s } = o();
4
- return t || s;
5
- };
6
- export {
7
- e as default
8
- };
@@ -1,43 +0,0 @@
1
- import s from "react";
2
- import { useForm as d } from "react-hook-form";
3
- import { FormSubmitError as F } from "../submit/error/FormSubmitError.mjs";
4
- const v = ({
5
- defaultValues: e,
6
- onSubmit: f,
7
- onSubmitError: p,
8
- onSubmitInvalid: n,
9
- Children: c,
10
- rhf: i,
11
- form: u,
12
- utils: t
13
- }) => {
14
- const r = s.useId(), m = d({
15
- ...i,
16
- defaultValues: e
17
- }), o = s.useRef(null);
18
- return {
19
- id: r,
20
- ref: o,
21
- context: m,
22
- providerProps: {
23
- formId: r,
24
- formRef: o,
25
- rhfForm: m,
26
- utils: t
27
- },
28
- formProps: {
29
- Children: c,
30
- onSubmit: f,
31
- onSubmitError: p,
32
- onSubmitInvalid: n,
33
- formId: r,
34
- formRef: o,
35
- form: u,
36
- utils: t
37
- },
38
- FormSubmitError: F
39
- };
40
- };
41
- export {
42
- v as default
43
- };
@@ -1,12 +0,0 @@
1
- import "react";
2
- const e = (t) => {
3
- if (t.nativeEvent instanceof SubmitEvent && !(!(t.nativeEvent.submitter instanceof HTMLButtonElement) && // not button
4
- !(t.nativeEvent.submitter instanceof HTMLInputElement)) && t.nativeEvent.submitter.name)
5
- return [
6
- t.nativeEvent.submitter.name,
7
- t.nativeEvent.submitter.value
8
- ];
9
- }, i = e;
10
- export {
11
- i as default
12
- };
@@ -1,13 +0,0 @@
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) => {
9
- t.requestSubmit(r);
10
- };
11
- export {
12
- s as default
13
- };
@@ -1,8 +0,0 @@
1
- class t extends Error {
2
- constructor(r, o) {
3
- super(o), this.errors = r;
4
- }
5
- }
6
- export {
7
- t as FormSubmitError
8
- };
@@ -1,12 +0,0 @@
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
- };
@@ -1,12 +0,0 @@
1
- import u from "react";
2
- import { useFormState as o } from "react-hook-form";
3
- import m from "../utils/useRefIfValueWasTrue.mjs";
4
- const c = (e, f) => {
5
- const { isSubmitSuccessful: i, isSubmitting: t } = o(), [r, s] = m(t);
6
- u.useEffect(() => {
7
- e && (t || r && (s(), e(i)));
8
- }, [t]);
9
- };
10
- export {
11
- c as default
12
- };
@@ -1,36 +0,0 @@
1
- import { useFormContext as n } from "react-hook-form";
2
- import i from "./useFormOnSubmitted.mjs";
3
- const p = (e) => {
4
- const { getValues: s, reset: o } = n();
5
- i((m) => {
6
- var u;
7
- if (!e) return;
8
- const t = (u = e[m ? "success" : "error"]) == null ? void 0 : u.values;
9
- if (!t) return;
10
- const r = t === "current", c = r ? s() : void 0;
11
- o(c, {
12
- // keep submit stuff for tracking relevant state (e.g., `useFormOnSubmitSuccessful`)
13
- keepIsSubmitSuccessful: !0,
14
- keepIsSubmitted: !0,
15
- keepSubmitCount: !0,
16
- /**
17
- * This is necessary when setting default values to current values (lest form stop updating).
18
- *
19
- * Technically, we are keeping values and resetting default values to same values.
20
- *
21
- * Steps to repro:
22
- * - RhfUtilsClientConfig with resetOnSubmitted set to success values to current
23
- * - remove `keepValues` prop from reset
24
- * - create valid form, submit
25
- * - form values should be unchanged
26
- * - unexpectedly: can no longer type into input
27
- */
28
- keepValues: r,
29
- // keep errors in the case of unsuccessful submit
30
- keepErrors: !0
31
- });
32
- });
33
- };
34
- export {
35
- p as default
36
- };
@@ -1,26 +0,0 @@
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(() => {
13
- if (!u) return;
14
- const r = n.current;
15
- if (!r) throw new Error();
16
- const t = (m) => {
17
- c(m);
18
- };
19
- return r.addEventListener("change", t), () => {
20
- r.removeEventListener("change", t);
21
- };
22
- }, []);
23
- };
24
- export {
25
- l as default
26
- };
@@ -1,7 +0,0 @@
1
- import { jsx as t, Fragment as o } from "react/jsx-runtime";
2
- const a = ({
3
- children: r
4
- }) => /* @__PURE__ */ t(o, { children: r });
5
- export {
6
- a as default
7
- };
@@ -1,4 +0,0 @@
1
- const e = (t) => Object.keys(t).length === 0;
2
- export {
3
- e as default
4
- };
@@ -1,26 +0,0 @@
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
- };
@@ -1,14 +0,0 @@
1
- import t from "react";
2
- const f = (r) => {
3
- const e = t.useRef(!1);
4
- t.useEffect(() => {
5
- r && (e.current = !0);
6
- }, [r]);
7
- const s = () => {
8
- e.current = !1;
9
- };
10
- return [e.current, s];
11
- };
12
- export {
13
- f as default
14
- };
@@ -1,71 +0,0 @@
1
- import { UseFormProps } from 'react-hook-form';
2
- import { FlatFieldErrorsOutputConfig } from '../../errors/flat/context/FlatFieldErrorsOutputConfig';
3
- import { RhfUtilsFormOptions } from '../../form/RhfUtilsFormOptions';
4
- import { UseRhfUtilsFormChildrenProps } from '../../form/UseRhfUtilsFormChildrenProps';
5
- import { FormSubmitFieldErrors } from '../../submit/error/FormSubmitFieldErrors';
6
-
7
- /**
8
- * Client configuration object.
9
- *
10
- * Options under `defaults` can be overridden at form level.
11
- */
12
- export type RhfUtilsClientConfig = {
13
- /**
14
- * Default options for all forms. (Are overridden by form-specific options.)
15
- */
16
- defaults?: {
17
- /**
18
- * Default RHF `useForm` settings.
19
- *
20
- * (Exposes only non-local props.)
21
- */
22
- rhf?: Pick<UseFormProps, 'mode' | 'reValidateMode' | 'resetOptions' | 'context' | 'shouldFocusError' | 'shouldUnregister' | 'shouldUseNativeValidation' | 'progressive' | 'criteriaMode' | 'delayError'>;
23
- /**
24
- * Global settings and defaults.
25
- *
26
- * (Extend this type via `Register` type to inject custom options/functionality via `Children` component.)
27
- */
28
- utils?: RhfUtilsFormOptions;
29
- /**
30
- * Default props for form element.
31
- */
32
- form?: Omit<React.PropsWithoutRef<JSX.IntrinsicElements['form']>, 'onSubmit'>;
33
- };
34
- /**
35
- * Supply your own `<form>` component.
36
- *
37
- * By default, a primitive `<form>` element is used.
38
- */
39
- FormComponent?: React.FC<React.PropsWithChildren<React.HTMLAttributes<HTMLFormElement>>>;
40
- /**
41
- * Wrap all form bodies with your own hooks, components, etc.
42
- *
43
- * (NOTE: not schema-typed as not possible at this level)
44
- *
45
- * Use cases:
46
- * - custom hooks/behaviors based on `options`
47
- * - shared header, footer
48
- */
49
- FormChildrenWrapper?: (props: RhfUtilsFormChildrenWrapperProps) => React.ReactNode;
50
- /**
51
- * Global submit error handler when/if submit handler throws an error other than {@link FormSubmitError}.
52
- *
53
- * Example use case:
54
- * - transform API errors to {@link FormSubmitFieldErrors}.
55
- *
56
- * @returns
57
- * - if {@link FormSubmitFieldErrors}: merge into context errors.
58
- * - if `undefined`: do nothing.
59
- */
60
- onSubmitErrorUnknown?: (error: unknown) => FormSubmitFieldErrors | undefined;
61
- fieldErrors?: {
62
- /**
63
- * Configure how/if errors should be outputted.
64
- */
65
- output?: FlatFieldErrorsOutputConfig;
66
- };
67
- };
68
- /**
69
- * Non-schema-typed version of `UseRhfUtilsFormChildrenProps` for global config.
70
- */
71
- export type RhfUtilsFormChildrenWrapperProps = React.PropsWithChildren<UseRhfUtilsFormChildrenProps>;