@paragrav/rhf-utils 0.0.26 → 0.0.28

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 (174) hide show
  1. package/dist/{devtool → esm/devtool}/LazyDevTool.mjs +4 -4
  2. package/dist/esm/errors/context/index.mjs +6 -0
  3. package/dist/esm/errors/context/provider.mjs +19 -0
  4. package/dist/esm/errors/flat/getFlatFieldErrors.mjs +22 -0
  5. package/dist/esm/errors/flat/useRefdFieldErrorsMemo.mjs +13 -0
  6. package/dist/{errors → esm/errors}/nonfield/FormNonFieldErrorMarker.utils.mjs +1 -1
  7. package/dist/{errors → esm/errors}/orphan/getOrphanFlatFieldErrors.mjs +2 -2
  8. package/dist/esm/errors/orphan/useFormHasOrphanAndNoFieldErrors.mjs +10 -0
  9. package/dist/esm/errors/orphan/useOrphanFormErrorsMemo.mjs +14 -0
  10. package/dist/{errors → esm/errors}/orphan/useOrphanFormErrorsToConsoleError.mjs +3 -3
  11. package/dist/esm/errors/root/consts.mjs +4 -0
  12. package/dist/esm/errors/root/getRootFlatFieldErrors.mjs +11 -0
  13. package/dist/esm/errors/root/isFormErrorPathRoot.mjs +5 -0
  14. package/dist/esm/errors/root/useRootFormFieldErrorsMemo.mjs +6 -0
  15. package/dist/{errors → esm/errors}/useFormErrorsEffect.mjs +2 -2
  16. package/dist/{errors/useFormErrorsOnChange.mjs → esm/errors/useFormErrorsMemo.mjs} +3 -3
  17. package/dist/esm/main.mjs +40 -0
  18. package/dist/esm/submit/useFormOnSubmitSuccessful.mjs +11 -0
  19. package/dist/esm/submit/useFormOnSubmitSuccessfulAndReset.mjs +14 -0
  20. package/dist/esm/utils/createRequiredContext.mjs +13 -0
  21. package/dist/types/errors/context/index.d.ts +10 -0
  22. package/dist/types/errors/context/provider.d.ts +10 -0
  23. package/dist/types/errors/flat/getFlatFieldErrors.d.ts +25 -0
  24. package/dist/types/errors/flat/getFlatFieldErrorsByFilter.d.ts +9 -0
  25. package/dist/types/errors/flat/types.d.ts +3 -0
  26. package/dist/types/errors/flat/useFormFlatFieldErrorsMemo.d.ts +5 -0
  27. package/dist/types/errors/flat/useRefdFieldErrorsMemo.d.ts +9 -0
  28. package/dist/types/errors/flattenFieldErrors.d.ts +15 -0
  29. package/dist/{errors → types/errors}/nonfield/FormNonFieldErrorMarker.utils.d.ts +1 -1
  30. package/dist/{errors → types/errors}/orphan/getOrphanFlatFieldErrors.d.ts +1 -1
  31. package/dist/types/errors/orphan/useOrphanFormErrorsMemo.d.ts +4 -0
  32. package/dist/types/errors/root/consts.d.ts +1 -0
  33. package/dist/types/errors/root/getRootFlatFieldErrors.d.ts +8 -0
  34. package/dist/types/errors/root/isFormErrorPathRoot.d.ts +6 -0
  35. package/dist/types/errors/root/useRootFormFieldErrorsMemo.d.ts +6 -0
  36. package/dist/types/errors/useFormErrorsMemo.d.ts +7 -0
  37. package/dist/types/form/Form.d.ts +9 -0
  38. package/dist/types/form/search/FormSearch.d.ts +32 -0
  39. package/dist/types/form/search/FormSearchHiddenInputs.d.ts +13 -0
  40. package/dist/types/form/search/getNewSearchParams.d.ts +2 -0
  41. package/dist/{main.d.ts → types/main.d.ts} +5 -3
  42. package/dist/types/utils/createRequiredContext.d.ts +8 -0
  43. package/dist/types/utils/fixedForwardRef.d.ts +7 -0
  44. package/dist/types/utils/useImperativeForwardedRef.d.ts +11 -0
  45. package/package.json +41 -39
  46. package/dist/_virtual/_commonjsHelpers.mjs +0 -8
  47. package/dist/_virtual/index.mjs +0 -4
  48. package/dist/errors/getFlatFieldErrors.mjs +0 -22
  49. package/dist/errors/orphan/useFormHasOrphanAndNoFieldErrors.mjs +0 -10
  50. package/dist/errors/orphan/useOrphanFormErrors.mjs +0 -14
  51. package/dist/errors/root/useRootFormFieldErrors.mjs +0 -6
  52. package/dist/errors/root/utils.mjs +0 -11
  53. package/dist/errors/useFormFieldErrors.mjs +0 -13
  54. package/dist/main.mjs +0 -36
  55. package/dist/node_modules/@babel/runtime/helpers/esm/extends.mjs +0 -13
  56. package/dist/node_modules/@emotion/cache/dist/emotion-cache.browser.esm.mjs +0 -305
  57. package/dist/node_modules/@emotion/hash/dist/emotion-hash.esm.mjs +0 -22
  58. package/dist/node_modules/@emotion/is-prop-valid/dist/emotion-is-prop-valid.esm.mjs +0 -10
  59. package/dist/node_modules/@emotion/memoize/dist/emotion-memoize.esm.mjs +0 -9
  60. package/dist/node_modules/@emotion/react/dist/emotion-element-43c6fea0.browser.esm.mjs +0 -57
  61. package/dist/node_modules/@emotion/serialize/dist/emotion-serialize.browser.esm.mjs +0 -167
  62. package/dist/node_modules/@emotion/sheet/dist/emotion-sheet.browser.esm.mjs +0 -49
  63. package/dist/node_modules/@emotion/styled/base/dist/emotion-styled-base.browser.esm.mjs +0 -82
  64. package/dist/node_modules/@emotion/styled/dist/emotion-styled.browser.esm.mjs +0 -146
  65. package/dist/node_modules/@emotion/unitless/dist/emotion-unitless.esm.mjs +0 -52
  66. package/dist/node_modules/@emotion/use-insertion-effect-with-fallbacks/dist/emotion-use-insertion-effect-with-fallbacks.browser.esm.mjs +0 -7
  67. package/dist/node_modules/@emotion/utils/dist/emotion-utils.browser.esm.mjs +0 -34
  68. package/dist/node_modules/@hookform/devtools/dist/index.esm.mjs +0 -1402
  69. package/dist/node_modules/dequal/dist/index.mjs +0 -64
  70. package/dist/node_modules/little-state-machine/dist/little-state-machine.es.mjs +0 -67
  71. package/dist/node_modules/lodash/_Hash.mjs +0 -22
  72. package/dist/node_modules/lodash/_ListCache.mjs +0 -22
  73. package/dist/node_modules/lodash/_Map.mjs +0 -6
  74. package/dist/node_modules/lodash/_MapCache.mjs +0 -22
  75. package/dist/node_modules/lodash/_Symbol.mjs +0 -5
  76. package/dist/node_modules/lodash/_arrayMap.mjs +0 -9
  77. package/dist/node_modules/lodash/_assocIndexOf.mjs +0 -12
  78. package/dist/node_modules/lodash/_baseGet.mjs +0 -13
  79. package/dist/node_modules/lodash/_baseGetTag.mjs +0 -11
  80. package/dist/node_modules/lodash/_baseIsNative.mjs +0 -17
  81. package/dist/node_modules/lodash/_baseToString.mjs +0 -19
  82. package/dist/node_modules/lodash/_castPath.mjs +0 -12
  83. package/dist/node_modules/lodash/_coreJsData.mjs +0 -5
  84. package/dist/node_modules/lodash/_freeGlobal.mjs +0 -5
  85. package/dist/node_modules/lodash/_getMapData.mjs +0 -10
  86. package/dist/node_modules/lodash/_getNative.mjs +0 -11
  87. package/dist/node_modules/lodash/_getRawTag.mjs +0 -16
  88. package/dist/node_modules/lodash/_getValue.mjs +0 -7
  89. package/dist/node_modules/lodash/_hashClear.mjs +0 -9
  90. package/dist/node_modules/lodash/_hashDelete.mjs +0 -8
  91. package/dist/node_modules/lodash/_hashGet.mjs +0 -14
  92. package/dist/node_modules/lodash/_hashHas.mjs +0 -10
  93. package/dist/node_modules/lodash/_hashSet.mjs +0 -10
  94. package/dist/node_modules/lodash/_isKey.mjs +0 -13
  95. package/dist/node_modules/lodash/_isKeyable.mjs +0 -8
  96. package/dist/node_modules/lodash/_isMasked.mjs +0 -12
  97. package/dist/node_modules/lodash/_listCacheClear.mjs +0 -7
  98. package/dist/node_modules/lodash/_listCacheDelete.mjs +0 -13
  99. package/dist/node_modules/lodash/_listCacheGet.mjs +0 -10
  100. package/dist/node_modules/lodash/_listCacheHas.mjs +0 -9
  101. package/dist/node_modules/lodash/_listCacheSet.mjs +0 -10
  102. package/dist/node_modules/lodash/_mapCacheClear.mjs +0 -15
  103. package/dist/node_modules/lodash/_mapCacheDelete.mjs +0 -10
  104. package/dist/node_modules/lodash/_mapCacheGet.mjs +0 -9
  105. package/dist/node_modules/lodash/_mapCacheHas.mjs +0 -9
  106. package/dist/node_modules/lodash/_mapCacheSet.mjs +0 -10
  107. package/dist/node_modules/lodash/_memoizeCapped.mjs +0 -12
  108. package/dist/node_modules/lodash/_nativeCreate.mjs +0 -5
  109. package/dist/node_modules/lodash/_objectToString.mjs +0 -8
  110. package/dist/node_modules/lodash/_root.mjs +0 -5
  111. package/dist/node_modules/lodash/_stringToPath.mjs +0 -10
  112. package/dist/node_modules/lodash/_toKey.mjs +0 -12
  113. package/dist/node_modules/lodash/_toSource.mjs +0 -18
  114. package/dist/node_modules/lodash/eq.mjs +0 -7
  115. package/dist/node_modules/lodash/get.mjs +0 -12
  116. package/dist/node_modules/lodash/isArray.mjs +0 -4
  117. package/dist/node_modules/lodash/isFunction.mjs +0 -13
  118. package/dist/node_modules/lodash/isObject.mjs +0 -11
  119. package/dist/node_modules/lodash/isObjectLike.mjs +0 -7
  120. package/dist/node_modules/lodash/isSymbol.mjs +0 -10
  121. package/dist/node_modules/lodash/isUndefined.mjs +0 -9
  122. package/dist/node_modules/lodash/memoize.mjs +0 -19
  123. package/dist/node_modules/lodash/toString.mjs +0 -9
  124. package/dist/node_modules/react-simple-animate/dist/index.mjs +0 -257
  125. package/dist/node_modules/stylis/src/Enum.mjs +0 -12
  126. package/dist/node_modules/stylis/src/Middleware.mjs +0 -18
  127. package/dist/node_modules/stylis/src/Parser.mjs +0 -114
  128. package/dist/node_modules/stylis/src/Serializer.mjs +0 -28
  129. package/dist/node_modules/stylis/src/Tokenizer.mjs +0 -131
  130. package/dist/node_modules/stylis/src/Utility.mjs +0 -50
  131. package/dist/node_modules/use-deep-compare-effect/dist/use-deep-compare-effect.esm.mjs +0 -24
  132. package/dist/node_modules/uuid/dist/esm-browser/regex.mjs +0 -4
  133. package/dist/node_modules/uuid/dist/esm-browser/rng.mjs +0 -9
  134. package/dist/node_modules/uuid/dist/esm-browser/stringify.mjs +0 -13
  135. package/dist/node_modules/uuid/dist/esm-browser/v4.mjs +0 -16
  136. package/dist/node_modules/uuid/dist/esm-browser/validate.mjs +0 -7
  137. package/dist/submit/useFormOnSubmitSuccessful.mjs +0 -11
  138. package/dist/submit/useFormOnSubmitSuccessfulAndReset.mjs +0 -14
  139. /package/dist/{errors → esm/errors/flat}/flattenFieldErrors.mjs +0 -0
  140. /package/dist/{errors → esm/errors}/isFieldError.mjs +0 -0
  141. /package/dist/{errors → esm/errors}/message/FormErrorMessage.mjs +0 -0
  142. /package/dist/{errors → esm/errors}/message/FormErrorMessageByPath.mjs +0 -0
  143. /package/dist/{errors → esm/errors}/nonfield/FormNonFieldErrorMarker.mjs +0 -0
  144. /package/dist/{errors → esm/errors}/nonfield/isNonFieldError.mjs +0 -0
  145. /package/dist/{errors → esm/errors}/useFormErrorConsoleDebug.mjs +0 -0
  146. /package/dist/{errors → esm/errors}/useFormErrorsIfAny.mjs +0 -0
  147. /package/dist/{errors → esm/errors}/useFormRequestSubmit.mjs +0 -0
  148. /package/dist/{isEmptyObject.mjs → esm/isEmptyObject.mjs} +0 -0
  149. /package/dist/{submit → esm/submit}/useResetFormOnSubmitSuccessful.mjs +0 -0
  150. /package/dist/{devtool → types/devtool}/LazyDevTool.d.ts +0 -0
  151. /package/dist/{errors → types/errors/flat}/flattenFieldErrors.d.ts +0 -0
  152. /package/dist/{errors → types/errors}/getFlatFieldErrors.d.ts +0 -0
  153. /package/dist/{errors → types/errors}/isFieldError.d.ts +0 -0
  154. /package/dist/{errors → types/errors}/message/FormErrorMessage.d.ts +0 -0
  155. /package/dist/{errors → types/errors}/message/FormErrorMessageByPath.d.ts +0 -0
  156. /package/dist/{errors → types/errors}/nonfield/FormNonFieldErrorMarker.d.ts +0 -0
  157. /package/dist/{errors → types/errors}/nonfield/FormNonFieldErrorMarker.spec.d.ts +0 -0
  158. /package/dist/{errors → types/errors}/nonfield/isNonFieldError.d.ts +0 -0
  159. /package/dist/{errors → types/errors}/orphan/useFormHasOrphanAndNoFieldErrors.d.ts +0 -0
  160. /package/dist/{errors → types/errors}/orphan/useOrphanFormErrors.d.ts +0 -0
  161. /package/dist/{errors → types/errors}/orphan/useOrphanFormErrorsToConsoleError.d.ts +0 -0
  162. /package/dist/{errors → types/errors}/root/useRootFormFieldErrors.d.ts +0 -0
  163. /package/dist/{errors → types/errors}/root/utils.d.ts +0 -0
  164. /package/dist/{errors → types/errors}/useFormErrorConsoleDebug.d.ts +0 -0
  165. /package/dist/{errors → types/errors}/useFormErrorsEffect.d.ts +0 -0
  166. /package/dist/{errors → types/errors}/useFormErrorsIfAny.d.ts +0 -0
  167. /package/dist/{errors → types/errors}/useFormErrorsOnChange.d.ts +0 -0
  168. /package/dist/{errors → types/errors}/useFormFieldErrors.d.ts +0 -0
  169. /package/dist/{errors → types/errors}/useFormFlatFieldErrors.d.ts +0 -0
  170. /package/dist/{errors → types/errors}/useFormRequestSubmit.d.ts +0 -0
  171. /package/dist/{isEmptyObject.d.ts → types/isEmptyObject.d.ts} +0 -0
  172. /package/dist/{submit → types/submit}/useFormOnSubmitSuccessful.d.ts +0 -0
  173. /package/dist/{submit → types/submit}/useFormOnSubmitSuccessfulAndReset.d.ts +0 -0
  174. /package/dist/{submit → types/submit}/useResetFormOnSubmitSuccessful.d.ts +0 -0
@@ -2,15 +2,15 @@ import { jsx as t } from "react/jsx-runtime";
2
2
  import e from "react";
3
3
  import { useFormContext as n } from "react-hook-form";
4
4
  const a = e.lazy(
5
- () => import("../node_modules/@hookform/devtools/dist/index.esm.mjs").then((o) => ({
5
+ () => import("@hookform/devtools").then((o) => ({
6
6
  default: o.DevTool
7
7
  }))
8
- ), f = ({ isDev: o, ...l }) => {
8
+ ), s = ({ isDev: o, ...l }) => {
9
9
  if (!o)
10
10
  return null;
11
11
  const { control: r } = n();
12
12
  return /* @__PURE__ */ t(e.Suspense, { fallback: null, children: /* @__PURE__ */ t(a, { control: r, ...l }) });
13
- }, m = f;
13
+ }, u = s;
14
14
  export {
15
- m as default
15
+ u as default
16
16
  };
@@ -0,0 +1,6 @@
1
+ import r from "../../utils/createRequiredContext.mjs";
2
+ const [t, e] = r(), s = t;
3
+ export {
4
+ e as _FormErrorsFlatContextProvider,
5
+ s as default
6
+ };
@@ -0,0 +1,19 @@
1
+ import { jsx as F } from "react/jsx-runtime";
2
+ import a from "../flat/getFlatFieldErrors.mjs";
3
+ import i from "../orphan/getOrphanFlatFieldErrors.mjs";
4
+ import l from "../root/getRootFlatFieldErrors.mjs";
5
+ import p from "../useFormErrorsMemo.mjs";
6
+ import { _FormErrorsFlatContextProvider as c } from "./index.mjs";
7
+ const d = ({
8
+ formRef: o,
9
+ children: t
10
+ }) => {
11
+ const e = p((s) => {
12
+ const r = a(s), m = l(r), n = i(r, o.current);
13
+ return { flattened: r, roots: m, orphans: n };
14
+ });
15
+ return /* @__PURE__ */ F(c, { value: e, children: t });
16
+ }, C = d;
17
+ export {
18
+ C as default
19
+ };
@@ -0,0 +1,22 @@
1
+ import { get as d } from "react-hook-form";
2
+ import l from "./flattenFieldErrors.mjs";
3
+ const p = (t) => {
4
+ const a = l(t), c = Object.keys(a);
5
+ return Object.fromEntries(
6
+ c.reduce(
7
+ (r, o) => {
8
+ const e = o.replace(n, "");
9
+ if (e === o)
10
+ return r;
11
+ const f = d(t, e, void 0);
12
+ return !f || r.some(([s]) => s === e) || r.push([e, f]), r;
13
+ },
14
+ []
15
+ // entries
16
+ )
17
+ );
18
+ }, n = /\.(?:type|message)\b$/;
19
+ export {
20
+ p as default,
21
+ n as regexMaybeFieldErrorLeafNode
22
+ };
@@ -0,0 +1,13 @@
1
+ import t from "../isFieldError.mjs";
2
+ import s from "../useFormErrorsMemo.mjs";
3
+ import i from "./getFlatFieldErrors.mjs";
4
+ const d = () => s(m), m = (r) => {
5
+ const e = i(r);
6
+ return Object.fromEntries(
7
+ Object.entries(e).filter(([, o]) => t(o))
8
+ );
9
+ };
10
+ export {
11
+ d as default,
12
+ m as getFlatFieldFormErrors
13
+ };
@@ -1,4 +1,4 @@
1
- const e = "data-paragrav-rhf-utils-nonfield-error-marker-path", a = e, t = (r) => `[role="alert"][${e}="${r}"]`, l = (r, o) => o.querySelector(t(r));
1
+ const e = "data-paragrav-rhf-utils-nonfield-error-marker-path", a = e, t = (r) => `[role="alert"][${e}="${r}"]`, l = (r, o) => !!o.querySelector(t(r));
2
2
  export {
3
3
  a as default,
4
4
  t as getFormNonFieldErrorMarkerQuerySelector,
@@ -1,7 +1,7 @@
1
- import s from "../getFlatFieldErrors.mjs";
1
+ import s from "../flat/getFlatFieldErrors.mjs";
2
2
  import { hasNonFieldErrorMarkerInDOM as l } from "../nonfield/FormNonFieldErrorMarker.utils.mjs";
3
3
  import m from "../nonfield/isNonFieldError.mjs";
4
- import { isFormErrorPathRoot as n } from "../root/utils.mjs";
4
+ import n from "../root/isFormErrorPathRoot.mjs";
5
5
  const d = (o, t) => {
6
6
  const e = s(o);
7
7
  return Object.fromEntries(
@@ -0,0 +1,10 @@
1
+ import r from "../../isEmptyObject.mjs";
2
+ import t from "../flat/useRefdFieldErrorsMemo.mjs";
3
+ import m from "./useOrphanFormErrorsMemo.mjs";
4
+ const n = (o) => {
5
+ const s = m(o), e = t();
6
+ return r(s) ? !1 : !r(e);
7
+ }, d = n;
8
+ export {
9
+ d as default
10
+ };
@@ -0,0 +1,14 @@
1
+ import "react";
2
+ import t from "../../isEmptyObject.mjs";
3
+ import e from "../useFormErrorsMemo.mjs";
4
+ import m from "./getOrphanFlatFieldErrors.mjs";
5
+ const n = (r) => e((o) => {
6
+ if (t(o))
7
+ return {};
8
+ if (!r.current)
9
+ throw new Error();
10
+ return m(o, r.current);
11
+ }), a = n;
12
+ export {
13
+ a as default
14
+ };
@@ -1,9 +1,9 @@
1
1
  import n from "react";
2
- import { useFormContext as a, useFormState as m } from "react-hook-form";
2
+ import { useFormContext as m, useFormState as a } from "react-hook-form";
3
3
  import c from "../../isEmptyObject.mjs";
4
- import p from "./useOrphanFormErrors.mjs";
4
+ import p from "./useOrphanFormErrorsMemo.mjs";
5
5
  const u = (o, e) => {
6
- const { getValues: s } = a(), { errors: t } = m(), r = p(o);
6
+ const { getValues: s } = m(), { errors: t } = a(), r = p(o);
7
7
  n.useEffect(() => {
8
8
  if (!c(r) && (console.error(
9
9
  "useOrphanFormErrorsToConsoleError",
@@ -0,0 +1,4 @@
1
+ const o = "root";
2
+ export {
3
+ o as FormErrorPathRoot
4
+ };
@@ -0,0 +1,11 @@
1
+ import e from "../flat/getFlatFieldErrors.mjs";
2
+ import i from "./isFormErrorPathRoot.mjs";
3
+ const a = (r) => {
4
+ const t = e(r);
5
+ return Object.fromEntries(
6
+ Object.entries(t).filter(([o]) => i(o))
7
+ );
8
+ };
9
+ export {
10
+ a as default
11
+ };
@@ -0,0 +1,5 @@
1
+ import { FormErrorPathRoot as r } from "./consts.mjs";
2
+ const s = (o) => o === r || o.startsWith(r + ".");
3
+ export {
4
+ s as default
5
+ };
@@ -0,0 +1,6 @@
1
+ import o from "../useFormErrorsMemo.mjs";
2
+ import r from "./getRootFlatFieldErrors.mjs";
3
+ const e = () => o(r), s = e;
4
+ export {
5
+ s as default
6
+ };
@@ -5,7 +5,7 @@ const s = (r) => {
5
5
  t.useEffect(() => {
6
6
  r(o);
7
7
  }, [r, o]);
8
- }, u = s;
8
+ }, c = s;
9
9
  export {
10
- u as default
10
+ c as default
11
11
  };
@@ -1,8 +1,8 @@
1
- import o from "react";
1
+ import e from "react";
2
2
  import { useFormState as t } from "react-hook-form";
3
3
  const u = (r) => {
4
- const { errors: e } = t();
5
- return o.useMemo(() => r(e), [r, e]);
4
+ const { errors: o } = t();
5
+ return e.useMemo(() => r(o), [r, o]);
6
6
  };
7
7
  export {
8
8
  u as default
@@ -0,0 +1,40 @@
1
+ import { default as e } from "./devtool/LazyDevTool.mjs";
2
+ import { default as s } from "./errors/context/index.mjs";
3
+ import { default as f } from "./errors/context/provider.mjs";
4
+ import { default as u } from "./errors/message/FormErrorMessage.mjs";
5
+ import { default as d } from "./errors/message/FormErrorMessageByPath.mjs";
6
+ import { default as p } from "./errors/nonfield/FormNonFieldErrorMarker.mjs";
7
+ import { default as E } from "./errors/nonfield/FormNonFieldErrorMarker.utils.mjs";
8
+ import { default as i } from "./errors/orphan/useFormHasOrphanAndNoFieldErrors.mjs";
9
+ import { default as M } from "./errors/orphan/useOrphanFormErrorsMemo.mjs";
10
+ import { default as b } from "./errors/orphan/useOrphanFormErrorsToConsoleError.mjs";
11
+ import { default as O } from "./errors/root/useRootFormFieldErrorsMemo.mjs";
12
+ import { default as C } from "./errors/useFormErrorConsoleDebug.mjs";
13
+ import { default as g } from "./errors/useFormErrorsEffect.mjs";
14
+ import { default as N } from "./errors/useFormErrorsIfAny.mjs";
15
+ import { default as v } from "./errors/useFormErrorsMemo.mjs";
16
+ import { default as H } from "./errors/useFormRequestSubmit.mjs";
17
+ import { default as T } from "./submit/useFormOnSubmitSuccessful.mjs";
18
+ import { default as z } from "./submit/useFormOnSubmitSuccessfulAndReset.mjs";
19
+ import { default as I } from "./submit/useResetFormOnSubmitSuccessful.mjs";
20
+ export {
21
+ u as FormErrorMessage,
22
+ d as FormErrorMessageByPath,
23
+ f as FormErrorsFlatContextProvider,
24
+ p as FormNonFieldErrorMarker,
25
+ E as FormNonFieldErrorMarkerHtmlAttribute,
26
+ e as LazyDevTool,
27
+ C as useFormErrorConsoleDebug,
28
+ g as useFormErrorsEffect,
29
+ s as useFormErrorsFlatContext,
30
+ N as useFormErrorsIfAny,
31
+ v as useFormErrorsMemo,
32
+ i as useFormHasOrphanAndNoFieldErrors,
33
+ T as useFormOnSubmitSuccessful,
34
+ z as useFormOnSubmitSuccessfulAndReset,
35
+ H as useFormRequestSubmit,
36
+ M as useOrphanFormErrorsMemo,
37
+ b as useOrphanFormErrorsToConsoleError,
38
+ I as useResetFormAfterSubmitSuccessful,
39
+ O as useRootFormFieldErrorsMemo
40
+ };
@@ -0,0 +1,11 @@
1
+ import u from "react";
2
+ import { useFormState as e } from "react-hook-form";
3
+ const o = (s) => {
4
+ const { isSubmitSuccessful: t } = e();
5
+ u.useEffect(() => {
6
+ s && t && s();
7
+ }, [s, t]);
8
+ }, r = o;
9
+ export {
10
+ r as default
11
+ };
@@ -0,0 +1,14 @@
1
+ import r from "react";
2
+ import { useFormState as c } from "react-hook-form";
3
+ import f from "./useFormOnSubmitSuccessful.mjs";
4
+ const m = (s) => {
5
+ const { isSubmitSuccessful: t, isDirty: u } = c(), e = r.useRef(!1);
6
+ f(() => {
7
+ e.current = !0;
8
+ }), r.useEffect(() => {
9
+ s && e.current && !t && !u && (s(), e.current = !1);
10
+ }, [t, u]);
11
+ }, S = m;
12
+ export {
13
+ S as default
14
+ };
@@ -0,0 +1,13 @@
1
+ import o from "react";
2
+ function c() {
3
+ const t = o.createContext(void 0);
4
+ return [() => {
5
+ const e = o.useContext(t);
6
+ if (e === void 0)
7
+ throw new Error();
8
+ return e;
9
+ }, t.Provider];
10
+ }
11
+ export {
12
+ c as default
13
+ };
@@ -0,0 +1,10 @@
1
+ import { FlatFieldErrors } from '../flat/types';
2
+
3
+ export type FormErrorsFlatContext = {
4
+ flattened: FlatFieldErrors;
5
+ roots: FlatFieldErrors;
6
+ orphans: FlatFieldErrors;
7
+ };
8
+ declare const useFormErrorsFlatContext: () => FormErrorsFlatContext, _FormErrorsFlatContextProvider: import('react').Provider<FormErrorsFlatContext | undefined>;
9
+ export default useFormErrorsFlatContext;
10
+ export { _FormErrorsFlatContextProvider };
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ type Props = React.PropsWithChildren<{
3
+ formRef: React.MutableRefObject<HTMLFormElement>;
4
+ }>;
5
+ /**
6
+ * Provides a flattened version of the form errors.
7
+ * Allows flattening and filtering to happen once per errors change.
8
+ */
9
+ declare const FormErrorsFlatContextProvider: React.FC<Props>;
10
+ export default FormErrorsFlatContextProvider;
@@ -0,0 +1,25 @@
1
+ import { FlatFieldErrors } from './types';
2
+ import { FieldErrors } from 'react-hook-form';
3
+
4
+ /**
5
+ * Get {@link FlatFieldErrors} from {@link FieldErrors}.
6
+ * This makes it easy to work with potentially deeply-nested {@link FieldErrors}.
7
+ *
8
+ * @param errors {@link FieldErrors} object.
9
+ * @returns FlatFieldErrors object.
10
+ *
11
+ * e.g.,
12
+ * ```
13
+ * [ "address.street", { "address.street": { type: "too_short", ref: { value: "123" }, message: "Required." } } ]
14
+ * ```
15
+ */
16
+ declare const getFlatFieldErrors: (errors: FieldErrors) => FlatFieldErrors;
17
+ export default getFlatFieldErrors;
18
+ /**
19
+ * Regular expression to maybe match the end of a leaf node path.
20
+ *
21
+ * i.e., `name.type`, `address.street.message`
22
+ *
23
+ * iow: dot [?: non-capturing]("type" | "message")[\b word boundary][$ end of string]
24
+ */
25
+ export declare const regexMaybeFieldErrorLeafNode: RegExp;
@@ -0,0 +1,9 @@
1
+ import { FieldError, FieldErrors } from 'react-hook-form';
2
+
3
+ /**
4
+ * Get flat field errors filtered by supplied predicate.
5
+ */
6
+ declare const getFlatFieldErrorsByFilter: (errors: FieldErrors, predicate: (entry: [string, FieldError]) => boolean) => {
7
+ [k: string]: FieldError;
8
+ };
9
+ export default getFlatFieldErrorsByFilter;
@@ -0,0 +1,3 @@
1
+ import { FieldError } from 'react-hook-form';
2
+
3
+ export type FlatFieldErrors = Record<string, FieldError>;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Use {@link FieldErrors} as {@link FlatFieldErrors}.
3
+ */
4
+ declare const useFormFlatFieldErrorsMemo: () => import('./types').FlatFieldErrors;
5
+ export default useFormFlatFieldErrorsMemo;
@@ -0,0 +1,9 @@
1
+ import { FlatFieldErrors } from './types';
2
+ import { FieldErrors } from 'react-hook-form';
3
+
4
+ /**
5
+ * Use errors with refs.
6
+ */
7
+ declare const useRefdFieldErrorsMemo: () => FlatFieldErrors;
8
+ export default useRefdFieldErrorsMemo;
9
+ export declare const getFlatFieldFormErrors: (errors: FieldErrors) => FlatFieldErrors;
@@ -0,0 +1,15 @@
1
+ import { FieldErrors } from 'react-hook-form';
2
+
3
+ /**
4
+ * Only flattens a {@link FieldErrors} object.
5
+ * @returns e.g.,
6
+ * ```
7
+ * {
8
+ * "address.street.type": "too_short",
9
+ * "address.street.ref.value": "123",
10
+ * "address.street.message": "Required."
11
+ * }
12
+ * ```
13
+ */
14
+ declare const flattenFieldErrors: (errors: FieldErrors) => Record<string, unknown>;
15
+ export default flattenFieldErrors;
@@ -4,4 +4,4 @@
4
4
  declare const FormNonFieldErrorMarkerHtmlAttribute = "data-paragrav-rhf-utils-nonfield-error-marker-path";
5
5
  export default FormNonFieldErrorMarkerHtmlAttribute;
6
6
  export declare const getFormNonFieldErrorMarkerQuerySelector: (path: string) => string;
7
- export declare const hasNonFieldErrorMarkerInDOM: (path: string, parentElement: Pick<HTMLElement, 'querySelector'>) => Element | null;
7
+ export declare const hasNonFieldErrorMarkerInDOM: (path: string, parentElement: Pick<HTMLElement, 'querySelector'>) => boolean;
@@ -1,4 +1,4 @@
1
- import { FlatFieldErrors } from '../getFlatFieldErrors';
1
+ import { FlatFieldErrors } from '../flat/types';
2
2
  import { FieldErrors } from 'react-hook-form';
3
3
 
4
4
  declare const getOrphanFlatFieldErrors: (errors: FieldErrors, parentElement: Pick<HTMLElement, 'querySelector'>) => FlatFieldErrors;
@@ -0,0 +1,4 @@
1
+ import { default as React } from 'react';
2
+
3
+ declare const useOrphanFormErrorsMemo: (formRef: React.RefObject<HTMLFormElement>) => import('../flat/types').FlatFieldErrors;
4
+ export default useOrphanFormErrorsMemo;
@@ -0,0 +1 @@
1
+ export declare const FormErrorPathRoot = "root";
@@ -0,0 +1,8 @@
1
+ import { FlatFieldErrors } from '../flat/types';
2
+ import { FieldErrors } from 'react-hook-form';
3
+
4
+ /**
5
+ * Pending.
6
+ */
7
+ declare const getRootFlatFieldErrors: (errors: FieldErrors) => FlatFieldErrors;
8
+ export default getRootFlatFieldErrors;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Determine if an error path is root. (e.g., `root` or `root.nested`)
3
+ * @param path Flat path. (e.g., 'root.nested')
4
+ */
5
+ declare const isFormErrorPathRoot: (path: string) => boolean;
6
+ export default isFormErrorPathRoot;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Root field errors from form.
3
+ * These are typically displayed at the bottom of the form.
4
+ */
5
+ declare const useRootFormFieldErrorsMemo: () => import('../flat/types').FlatFieldErrors;
6
+ export default useRootFormFieldErrorsMemo;
@@ -0,0 +1,7 @@
1
+ import { FieldErrors } from 'react-hook-form';
2
+
3
+ /**
4
+ * Create memoized value from form errors.
5
+ */
6
+ declare const useFormErrorsMemo: <TReturn>(callback: (errors: FieldErrors) => TReturn) => TReturn;
7
+ export default useFormErrorsMemo;
@@ -0,0 +1,9 @@
1
+ import { default as React } from 'react';
2
+
3
+ export type FormProps = React.PropsWithoutRef<JSX.IntrinsicElements['form']> & {
4
+ antiCsrfToken?: string;
5
+ };
6
+ declare const Form: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>, "ref"> & {
7
+ antiCsrfToken?: string | undefined;
8
+ } & React.RefAttributes<HTMLFormElement>>;
9
+ export default Form;
@@ -0,0 +1,32 @@
1
+ import { FormProps } from '../Form';
2
+ import { z } from 'zod';
3
+ import { default as React } from 'react';
4
+
5
+ declare const _default: <TSchema extends z.ZodTypeAny, TSchemaOutput extends z.output<TSchema> = z.output<TSchema>>(props: Omit<FormProps, "children" | "onSubmit"> & {
6
+ /**
7
+ * Search params schema.
8
+ *
9
+ * Make sure all properties are marked as `optional().catch(undefiend)` to avoid errors from parsing.
10
+ */
11
+ schema: TSchema;
12
+ /** Current search params. */
13
+ search: NoInfer<TSchemaOutput>;
14
+ Fields: React.FC<{
15
+ search: TSchemaOutput;
16
+ isSubmitting: boolean;
17
+ }>;
18
+ /**
19
+ * Callback to handle form submission.
20
+ * @param search New search params.
21
+ * @param data Sanitized form data.
22
+ * @param event Form submit event.
23
+ */
24
+ onSubmit?: ((search: TSchemaOutput, data: TSchemaOutput, event: React.FormEvent<HTMLFormElement>) => unknown) | undefined;
25
+ /**
26
+ * Error handler.
27
+ *
28
+ * Obviates need for consumer `try/catch`.
29
+ */
30
+ onSubmitError?: ((error: unknown, search: TSchemaOutput, data: TSchemaOutput, event: React.FormEvent<HTMLFormElement>) => void) | undefined;
31
+ } & React.RefAttributes<HTMLFormElement>) => React.ReactNode;
32
+ export default _default;
@@ -0,0 +1,13 @@
1
+ import { default as React } from 'react';
2
+ import { Stringifiable } from 'query-string';
3
+
4
+ /**
5
+ * Generate hidden inputs from the current search query string.
6
+ * This allows form to not require JS.
7
+ */
8
+ declare const FormSearchHiddenInputs: React.FC<{
9
+ search: Record<string, Stringifiable>;
10
+ /** Keys to ignore. i.e., they have inputs. */
11
+ include: string[];
12
+ }>;
13
+ export default FormSearchHiddenInputs;
@@ -0,0 +1,2 @@
1
+ declare const getNewSearchParams: <TSearchParams extends Record<string, unknown>>(current: TSearchParams | undefined, update: TSearchParams) => TSearchParams;
2
+ export default getNewSearchParams;
@@ -1,16 +1,18 @@
1
1
  export { default as LazyDevTool } from './devtool/LazyDevTool';
2
+ export { default as useFormErrorsFlatContext } from './errors/context';
3
+ export { default as FormErrorsFlatContextProvider } from './errors/context/provider';
2
4
  export { default as FormErrorMessage } from './errors/message/FormErrorMessage';
3
5
  export { default as FormErrorMessageByPath } from './errors/message/FormErrorMessageByPath';
4
6
  export { default as FormNonFieldErrorMarker } from './errors/nonfield/FormNonFieldErrorMarker';
5
7
  export { default as FormNonFieldErrorMarkerHtmlAttribute } from './errors/nonfield/FormNonFieldErrorMarker.utils';
6
8
  export { default as useFormHasOrphanAndNoFieldErrors } from './errors/orphan/useFormHasOrphanAndNoFieldErrors';
7
- export { default as useOrphanFormErrors } from './errors/orphan/useOrphanFormErrors';
9
+ export { default as useOrphanFormErrorsMemo } from './errors/orphan/useOrphanFormErrorsMemo';
8
10
  export { default as useOrphanFormErrorsToConsoleError } from './errors/orphan/useOrphanFormErrorsToConsoleError';
9
- export { default as useRootFormFieldErrors } from './errors/root/useRootFormFieldErrors';
11
+ export { default as useRootFormFieldErrorsMemo } from './errors/root/useRootFormFieldErrorsMemo';
10
12
  export { default as useFormErrorConsoleDebug } from './errors/useFormErrorConsoleDebug';
11
13
  export { default as useFormErrorsEffect } from './errors/useFormErrorsEffect';
12
14
  export { default as useFormErrorsIfAny } from './errors/useFormErrorsIfAny';
13
- export { default as useFormErrorsOnChange } from './errors/useFormErrorsOnChange';
15
+ export { default as useFormErrorsMemo } from './errors/useFormErrorsMemo';
14
16
  export { default as useFormRequestSubmit } from './errors/useFormRequestSubmit';
15
17
  export { default as useFormOnSubmitSuccessful } from './submit/useFormOnSubmitSuccessful';
16
18
  export { default as useFormOnSubmitSuccessfulAndReset } from './submit/useFormOnSubmitSuccessfulAndReset';
@@ -0,0 +1,8 @@
1
+ import { default as React } from 'react';
2
+
3
+ /**
4
+ * Create a strongly-typed context that throws error if no provider is found.
5
+ * @returns A tuple with a function to get the context and the context provider.
6
+ */
7
+ declare function createRequiredContext<T = unknown>(): readonly [() => T & ({} | null), React.Provider<T | undefined>];
8
+ export default createRequiredContext;
@@ -0,0 +1,7 @@
1
+ import { default as React } from 'react';
2
+
3
+ /**
4
+ * @see https://www.totaltypescript.com/forwardref-with-generic-components
5
+ */
6
+ declare function fixedForwardRef<T, P = object>(render: (props: P, ref: React.Ref<T>) => React.ReactNode): (props: P & React.RefAttributes<T>) => React.ReactNode;
7
+ export default fixedForwardRef;
@@ -0,0 +1,11 @@
1
+ import { default as React } from 'react';
2
+
3
+ /**
4
+ * Create a ref and point forwarded ref to it.
5
+ *
6
+ * Use case: forwarded refs are optional, but sometimes you need the ref.
7
+ *
8
+ * @param forwardedRef Forwarded `ref` prop.
9
+ */
10
+ declare const useImperativeForwardedRef: <TRef>(forwardedRef: React.ForwardedRef<TRef> | undefined) => React.RefObject<TRef>;
11
+ export default useImperativeForwardedRef;