@paragrav/rhf-utils 0.1.0 → 0.60.0

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 (213) hide show
  1. package/README.md +260 -121
  2. package/dist/dts/Register.d.ts +16 -0
  3. package/dist/dts/_exports/config.d.ts +2 -0
  4. package/dist/dts/_exports/errors.d.ts +3 -0
  5. package/dist/dts/_exports/form.d.ts +7 -0
  6. package/dist/dts/_exports/index.d.ts +14 -0
  7. package/dist/dts/_exports/relay.d.ts +8 -0
  8. package/dist/dts/_exports/submit.d.ts +4 -0
  9. package/dist/dts/_exports/trpc.d.ts +2 -0
  10. package/dist/dts/_exports/types.d.ts +6 -0
  11. package/dist/dts/_exports/zod.d.ts +6 -0
  12. package/dist/dts/client/config/RhfUtilsClientConfigType.d.ts +63 -0
  13. package/dist/dts/client/config/context/RhfUtilsClientConfigContext.d.ts +3 -0
  14. package/dist/dts/client/config/context/RhfUtilsClientConfigProvider.d.ts +7 -0
  15. package/dist/dts/client/config/context/useRhfUtilsClientConfig.d.ts +1 -0
  16. package/dist/{types → dts}/devtool/LazyDevTool.d.ts +3 -4
  17. package/dist/dts/devtool/LazyDevToolViaProviders.d.ts +1 -0
  18. package/dist/{types → dts}/errors/flat/FlatFieldErrorsList.d.ts +2 -2
  19. package/dist/{types → dts}/errors/flat/context/FlatFieldErrorsContextProvider.d.ts +3 -3
  20. package/dist/{types → dts}/errors/flat/context/useFlatFieldErrorsContext.d.ts +1 -2
  21. package/dist/dts/errors/flat/context/useFlatFieldErrorsContextHasOnlyOrphans.d.ts +6 -0
  22. package/dist/{types → dts}/errors/flat/context/useFlatFieldErrorsContextOutput.d.ts +1 -2
  23. package/dist/dts/errors/flat/filterFlatFieldErrors.d.ts +7 -0
  24. package/dist/{types → dts}/errors/flat/flattenFieldErrors.d.ts +1 -2
  25. package/dist/{types → dts}/errors/flat/getFlatFieldErrors.d.ts +2 -1
  26. package/dist/dts/errors/getRefdFromFlatFieldErrors.d.ts +1 -0
  27. package/dist/{types → dts}/errors/isFieldErrorRefd.d.ts +1 -2
  28. package/dist/dts/errors/isFlatFieldErrorEntryRefd.d.ts +5 -0
  29. package/dist/{types → dts}/errors/message/FormErrorMessage.d.ts +2 -2
  30. package/dist/{types → dts}/errors/message/RhfUtilsFieldErrorMessage.d.ts +2 -2
  31. package/dist/{types → dts}/errors/nonfield/RhfUtilsNonFieldErrorMarker.d.ts +2 -2
  32. package/dist/dts/errors/nonfield/RhfUtilsNonFieldErrorMarkerHtmlAttribute.d.ts +4 -0
  33. package/dist/{types → dts}/errors/nonfield/isNonFieldError.d.ts +1 -2
  34. package/dist/dts/errors/nonfield/isNonFieldErrorMarkerInDOM.d.ts +5 -0
  35. package/dist/dts/errors/orphan/getIsOrphanFormErrorWithParentElement.d.ts +5 -0
  36. package/dist/dts/errors/orphan/getOrphansFromFlatFieldErrors.d.ts +2 -0
  37. package/dist/dts/errors/orphan/isOrphanFormError.d.ts +2 -0
  38. package/dist/dts/errors/output/consoleErrors.d.ts +5 -0
  39. package/dist/dts/errors/root/RootErrorsListFromFlatFieldErrorsContext.d.ts +1 -0
  40. package/dist/dts/errors/root/getRootsFromFlatFieldErrors.d.ts +1 -0
  41. package/dist/{types → dts}/errors/root/isFlatFieldErrorEntryPathRoot.d.ts +1 -2
  42. package/dist/{types → dts}/errors/root/isFormErrorPathRoot.d.ts +1 -2
  43. package/dist/{types → dts}/errors/trpc/makeOnSubmitTrpcClientErrorHandler.d.ts +2 -3
  44. package/dist/dts/errors/trpc/trpcClientErrorMessageSchema.d.ts +19 -0
  45. package/dist/dts/errors/trpc/trpcClientErrorToFormSubmitFieldErrorsSchemaTransformer.d.ts +23 -0
  46. package/dist/dts/form/RHF_UseFormReturnWithoutProxiesType.d.ts +15 -0
  47. package/dist/dts/form/RhfUtilsFormComponentPropsType.d.ts +17 -0
  48. package/dist/dts/form/RhfUtilsFormStateWithUtilsType.d.ts +7 -0
  49. package/dist/dts/form/UseRhfUtilsFormChildrenPropsType.d.ts +25 -0
  50. package/dist/dts/form/_Controller.d.ts +4 -0
  51. package/dist/dts/form/context/utils/RhfUtilsContextPropsType.d.ts +11 -0
  52. package/dist/dts/form/context/utils/RhfUtilsContextProvider.d.ts +9 -0
  53. package/dist/dts/form/context/utils/useRhfUtilsContext.d.ts +5 -0
  54. package/dist/dts/form/context/utils/useRhfUtilsContextRequestSubmit.d.ts +4 -0
  55. package/dist/dts/form/defaults/UseRhfUtilsFormGlobalDefaults.d.ts +24 -0
  56. package/dist/dts/form/defaults/UseRhfUtilsFormInstanceDefaults.d.ts +18 -0
  57. package/dist/dts/form/defaults/UseRhfUtilsFormResolvedDefaultsType.d.ts +12 -0
  58. package/dist/dts/form/defaults/form/UseRhfUtilsFormInstanceFormProps.d.ts +6 -0
  59. package/dist/dts/form/defaults/form/getRhfUtilsFormResolvedFormProps.d.ts +2 -0
  60. package/dist/dts/form/defaults/form/useRhfUtilsFormResolvedFormProps.d.ts +293 -0
  61. package/dist/{types/form/RhfUtilsFormOptions.d.ts → dts/form/options/RhfUtilsFormOptionsType.d.ts} +6 -7
  62. package/dist/dts/form/options/getRhfUtilsFormResolvedOptions.d.ts +2 -0
  63. package/dist/dts/form/options/useRhfUtilsFormResolvedOptions.d.ts +8 -0
  64. package/dist/dts/form/providers/RhfUtilsFormProviders.d.ts +6 -0
  65. package/dist/dts/form/providers/RhfUtilsFormProvidersPropsType.d.ts +15 -0
  66. package/dist/dts/form/rhf/UseFormPropsType.d.ts +4 -0
  67. package/dist/dts/form/rhf/getRhfUtilsFormResolvedRhfProps.d.ts +4 -0
  68. package/dist/dts/form/rhf/useRhfFormWithResolvedProps.d.ts +5 -0
  69. package/dist/dts/form/state/relay/FormStateRelayContextProvider.d.ts +4 -0
  70. package/dist/dts/form/state/relay/FormStateRelayedAggregatedType.d.ts +10 -0
  71. package/dist/dts/form/state/relay/FormStateRelayedItemType.d.ts +11 -0
  72. package/dist/dts/form/state/relay/FormStateRelayedOptionsType.d.ts +20 -0
  73. package/dist/dts/form/state/relay/FormStateRelayedType.d.ts +3 -0
  74. package/dist/dts/form/state/relay/pull/hooks.d.ts +31 -0
  75. package/dist/dts/form/state/relay/push/FormStateRelayPusher.d.ts +4 -0
  76. package/dist/dts/form/state/relay/push/useFormStateRelayPusher.d.ts +3 -0
  77. package/dist/dts/form/state/relay/useFormStateRelayContext.d.ts +20 -0
  78. package/dist/dts/form/state/relay/utils.d.ts +4 -0
  79. package/dist/dts/form/utils/getSubmitterButtonData.d.ts +6 -0
  80. package/dist/{types → dts}/form/utils/useFormRequestSubmit.d.ts +1 -2
  81. package/dist/dts/form/utils/useHandleCancelWithCheckIfCanBe.d.ts +4 -0
  82. package/dist/dts/form/utils/useHandleCancelWithCheckIfCanBeViaProviders.d.ts +2 -0
  83. package/dist/{types → dts}/form/utils/useShouldFormBlockNavigation.d.ts +1 -2
  84. package/dist/dts/form/with-handlers-and-children/RhfUtilsForm.d.ts +3 -0
  85. package/dist/dts/form/with-handlers-and-children/RhfUtilsFormProps.d.ts +46 -0
  86. package/dist/dts/form/with-handlers-and-children/_ChildrenViaProviders.d.ts +3 -0
  87. package/dist/dts/form/with-handlers-and-children/_FormWithSubmitHandler.d.ts +4 -0
  88. package/dist/dts/form/with-handlers-and-children/_useHandleSubmit.d.ts +11 -0
  89. package/dist/dts/form/with-providers/RhfUtilsFormWithProviders.d.ts +8 -0
  90. package/dist/dts/form/with-providers/RhfUtilsFormWithProvidersProps.d.ts +4 -0
  91. package/dist/dts/resolvers/ObjectSchema.d.ts +7 -0
  92. package/dist/dts/resolvers/zod/RhfUtilsUseZodFormChildrenFCType.d.ts +7 -0
  93. package/dist/dts/resolvers/zod/RhfUtilsUseZodFormChildrenPropsType.d.ts +4 -0
  94. package/dist/dts/resolvers/zod/ZodTypeSafeFieldValuesType.d.ts +5 -0
  95. package/dist/dts/resolvers/zod/consts.d.ts +4 -0
  96. package/dist/dts/resolvers/zod/form/RhfUtilsZodForm.d.ts +7 -0
  97. package/dist/dts/resolvers/zod/getZodResolver.d.ts +4 -0
  98. package/dist/dts/resolvers/zod/providers/RhfUtilsZodFormProviders.d.ts +8 -0
  99. package/dist/dts/resolvers/zod/with-providers/RhfUtilsZodFormWithProviders.d.ts +10 -0
  100. package/dist/dts/submit/UseRhfUtilsFormOnSubmitContextType.d.ts +23 -0
  101. package/dist/dts/submit/error/FormSubmitError.d.ts +6 -0
  102. package/dist/{types → dts}/submit/error/FormSubmitFieldErrors.d.ts +1 -1
  103. package/dist/dts/submit/error/setCtxErrorsByFormSubmitFieldErrors.d.ts +8 -0
  104. package/dist/dts/submit/last-error/LastSubmitErrorContextProvider.d.ts +4 -0
  105. package/dist/dts/submit/last-error/LastSubmitErrorContextType.d.ts +8 -0
  106. package/dist/dts/submit/last-error/useLastSubmitError.d.ts +4 -0
  107. package/dist/dts/submit/last-error/useLastSubmitErrorContext.d.ts +3 -0
  108. package/dist/dts/submit/last-error/useLastSubmitErrorContextWith.d.ts +2 -0
  109. package/dist/{types → dts}/submit/useFormOnSubmitSuccessfulAndReset.d.ts +1 -2
  110. package/dist/dts/submit/useFormOnSubmitted.d.ts +4 -0
  111. package/dist/{types → dts}/submit/useResetFormOnSubmitted.d.ts +1 -2
  112. package/dist/dts/submit/useRhfUtilsFormOnSubmitContext.d.ts +3 -0
  113. package/dist/dts/submit/useSubmitFormOnChange.d.ts +15 -0
  114. package/dist/dts/submit/useSubmitFormOnEvent.d.ts +9 -0
  115. package/dist/dts/submit/useSubmitFormOnWatch.d.ts +14 -0
  116. package/dist/dts/utils/PassthroughChildren.d.ts +7 -0
  117. package/dist/{types → dts}/utils/createContext.d.ts +1 -2
  118. package/dist/dts/utils/fixedForwardRef.d.ts +5 -0
  119. package/dist/dts/utils/isEmptyObject.d.ts +1 -0
  120. package/dist/dts/utils/types.d.ts +3 -0
  121. package/dist/{types → dts}/utils/useImperativeForwardedRef.d.ts +1 -2
  122. package/dist/dts/utils/useIsFirstRender.d.ts +7 -0
  123. package/dist/dts/utils/useRefIfValueWasTrue.d.ts +2 -0
  124. package/dist/dts/utils/useToggle.d.ts +2 -0
  125. package/dist/dts/vite-env.d.ts +1 -0
  126. package/dist/esm/getFlatFieldErrors.mjs +55 -0
  127. package/dist/esm/index.mjs +503 -390
  128. package/dist/esm/relay.mjs +222 -0
  129. package/dist/esm/trpc.mjs +8 -9
  130. package/package.json +91 -72
  131. package/LICENSE.md +0 -21
  132. package/dist/esm/createContext.mjs +0 -16
  133. package/dist/esm/group.mjs +0 -74
  134. package/dist/esm/useFlatFieldErrorsContext.mjs +0 -10
  135. package/dist/esm/utils.mjs +0 -20
  136. package/dist/types/_exports/group.d.ts +0 -9
  137. package/dist/types/_exports/index.d.ts +0 -15
  138. package/dist/types/_exports/trpc.d.ts +0 -2
  139. package/dist/types/_exports/utils.d.ts +0 -1
  140. package/dist/types/client/config/RhfUtilsClientConfig.d.ts +0 -70
  141. package/dist/types/client/config/useRhfUtilsClientConfigContext.d.ts +0 -4
  142. package/dist/types/client/context.d.ts +0 -2
  143. package/dist/types/client/index.d.ts +0 -24
  144. package/dist/types/client/utils.d.ts +0 -12
  145. package/dist/types/client/zod/RhfUtilsUseFormChildrenZodFC.d.ts +0 -12
  146. package/dist/types/client/zod/RhfUtilsUseFormChildrenZodProps.d.ts +0 -4
  147. package/dist/types/client/zod/ZodTypeFieldValues.d.ts +0 -3
  148. package/dist/types/client/zod/consts.d.ts +0 -4
  149. package/dist/types/client/zod/context/RhfUtilsClientForZodContextProvider.d.ts +0 -7
  150. package/dist/types/client/zod/context/RhfUtilsZodForm.d.ts +0 -8
  151. package/dist/types/client/zod/context/useRhfUtilsClientForZodContext.d.ts +0 -5
  152. package/dist/types/client/zod/context/useRhfUtilsZodForm.d.ts +0 -7
  153. package/dist/types/client/zod/createRhfUtilsClientForZod.d.ts +0 -3
  154. package/dist/types/errors/flat/context/useFlatFieldErrorsContextHasOnlyOrphans.d.ts +0 -7
  155. package/dist/types/errors/flat/filterFlatFieldErrors.d.ts +0 -8
  156. package/dist/types/errors/getRefdFromFlatFieldErrors.d.ts +0 -2
  157. package/dist/types/errors/isFlatFieldErrorEntryRefd.d.ts +0 -6
  158. package/dist/types/errors/nonfield/RhfUtilsNonFieldErrorMarkerHtmlAttribute.d.ts +0 -5
  159. package/dist/types/errors/nonfield/isNonFieldErrorMarkerInDOM.d.ts +0 -6
  160. package/dist/types/errors/orphan/getIsOrphanFormErrorWithParentElement.d.ts +0 -6
  161. package/dist/types/errors/orphan/getOrphansFromFlatFieldErrors.d.ts +0 -3
  162. package/dist/types/errors/orphan/isOrphanFormError.d.ts +0 -3
  163. package/dist/types/errors/output/consoleErrors.d.ts +0 -6
  164. package/dist/types/errors/root/RootErrorsListFromFlatFieldErrorsContext.d.ts +0 -2
  165. package/dist/types/errors/root/getRootsFromFlatFieldErrors.d.ts +0 -2
  166. package/dist/types/errors/trpc/trpcClientErrorMessageSchema.d.ts +0 -23
  167. package/dist/types/errors/trpc/trpcClientErrorToFormSubmitFieldErrorsSchemaTransformer.d.ts +0 -27
  168. package/dist/types/form/Form.d.ts +0 -10
  169. package/dist/types/form/FormWithProviders.d.ts +0 -12
  170. package/dist/types/form/RhfUtilsFormProviders.d.ts +0 -11
  171. package/dist/types/form/UseRhfUtilsFormChildrenProps.d.ts +0 -23
  172. package/dist/types/form/UseRhfUtilsFormOnSubmitContext.d.ts +0 -28
  173. package/dist/types/form/UseRhfUtilsFormProps.d.ts +0 -22
  174. package/dist/types/form/UseRhfUtilsFormReturn.d.ts +0 -19
  175. package/dist/types/form/_Controller.d.ts +0 -5
  176. package/dist/types/form/context/group/FormGroupContextProvider.d.ts +0 -4
  177. package/dist/types/form/context/group/index.d.ts +0 -14
  178. package/dist/types/form/context/group/useFormGroupChildIsMountedTracker.d.ts +0 -5
  179. package/dist/types/form/context/group/useFormGroupChildIsSubmittingTracker.d.ts +0 -5
  180. package/dist/types/form/context/group/useFormGroupChildTracker.d.ts +0 -6
  181. package/dist/types/form/context/group/useFormGroupIsAnyBusy.d.ts +0 -2
  182. package/dist/types/form/context/group/useFormGroupIsChildBusy.d.ts +0 -2
  183. package/dist/types/form/context/group/useFormGroupIsParentBusy.d.ts +0 -2
  184. package/dist/types/form/context/group/useFormGroupParentTracker.d.ts +0 -7
  185. package/dist/types/form/context/group/useFormOrParentIsBusy.d.ts +0 -2
  186. package/dist/types/form/context/utils/RhfUtilsContextProvider.d.ts +0 -8
  187. package/dist/types/form/context/utils/useRhfUtilsContext.d.ts +0 -13
  188. package/dist/types/form/context/utils/useRhfUtilsContextRequestSubmit.d.ts +0 -5
  189. package/dist/types/form/useFormIsBusy.d.ts +0 -2
  190. package/dist/types/form/useRhfUtilsForm.d.ts +0 -15
  191. package/dist/types/form/utils/getSubmitterButtonData.d.ts +0 -7
  192. package/dist/types/register.d.ts +0 -7
  193. package/dist/types/submit/error/FormSubmitError.d.ts +0 -6
  194. package/dist/types/submit/error/setCtxErrorsByFormSubmitFieldErrors.d.ts +0 -9
  195. package/dist/types/submit/useFormOnSubmitted.d.ts +0 -5
  196. package/dist/types/submit/useSubmitFormOnChange.d.ts +0 -8
  197. package/dist/types/utils/PassthroughChildren.d.ts +0 -7
  198. package/dist/types/utils/fixedForwardRef.d.ts +0 -6
  199. package/dist/types/utils/isEmptyObject.d.ts +0 -2
  200. package/dist/types/utils/types.d.ts +0 -1
  201. package/dist/types/utils/useRefIfValueWasTrue.d.ts +0 -2
  202. package/dist/types/utils/useThrowAsyncError.d.ts +0 -5
  203. package/dist/types/utils/useToggle.d.ts +0 -3
  204. /package/dist/{types → dts}/errors/flat/context/FlatFieldErrorsOutputConfig.d.ts +0 -0
  205. /package/dist/{types → dts}/errors/flat/types.d.ts +0 -0
  206. /package/dist/{types → dts}/errors/nonfield/RhfUtilsNonFieldErrorMarker.spec.d.ts +0 -0
  207. /package/dist/{types → dts}/errors/nonfield/RhfUtilsNonFieldErrorMarker.utils.d.ts +0 -0
  208. /package/dist/{types → dts}/errors/output/types.d.ts +0 -0
  209. /package/dist/{types → dts}/errors/root/consts.d.ts +0 -0
  210. /package/dist/{types/form/SafeFieldValues.d.ts → dts/form/rhf/SafeFieldValuesType.d.ts} +0 -0
  211. /package/dist/{types → dts}/main.d.ts +0 -0
  212. /package/dist/{types → dts}/utils/timeoutAsync.d.ts +0 -0
  213. /package/dist/{types → dts}/utils/useDebouncedOnChangeValue.d.ts +0 -0
@@ -0,0 +1,11 @@
1
+ import { SubmitErrorHandler, SubmitHandler } from 'react-hook-form';
2
+ import { MaybePromise } from '../../utils/types';
3
+ import { SafeFieldValues } from '../rhf/SafeFieldValuesType';
4
+ type Props<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues> = {
5
+ onValid: SubmitHandler<TTransformedValues>;
6
+ onInvalid?: SubmitErrorHandler<TFieldValues>;
7
+ onError: (error: unknown, event: React.BaseSyntheticEvent) => void;
8
+ onFinally?: () => MaybePromise<unknown>;
9
+ };
10
+ export declare const useRhfUtilsFormHandleSubmit_Internal: <TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues>({ onValid, onInvalid, onError, onFinally, }: Props<TFieldValues, TTransformedValues>) => ((event: React.FormEvent<HTMLFormElement>) => void);
11
+ export {};
@@ -0,0 +1,8 @@
1
+ import { SafeFieldValues } from '../rhf/SafeFieldValuesType';
2
+ import { RhfUtilsFormPropsGetApiValues } from '../with-handlers-and-children/RhfUtilsFormProps';
3
+ import { RhfUtilsFormWithProvidersProps } from './RhfUtilsFormWithProvidersProps';
4
+ /**
5
+ * Form providers (with utils) with immediate descendent {@link RhfUtilsForm}.
6
+ * (Syntactic sugar for {@link useRhfUtilsForm}. Use this for most applications.)
7
+ */
8
+ export declare function RhfUtilsFormWithProviders<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues, TGetApiValues extends undefined | RhfUtilsFormPropsGetApiValues<TTransformedValues, SafeFieldValues>, TOnSubmitReturnType, TApiValues extends undefined | SafeFieldValues = TGetApiValues extends RhfUtilsFormPropsGetApiValues<TTransformedValues, infer U> ? U : undefined>({ getApiData, resolver, rhf, defaultValues, options, onCancel, onSubmitInvalid, onBeforeSubmitInvariants, onBeforeSubmit, onSubmit, onSubmitSuccess, onSubmitError, onSubmitFinally, Children, form, formId, className, }: RhfUtilsFormWithProvidersProps<TFieldValues, TTransformedValues, TGetApiValues, TOnSubmitReturnType, TApiValues>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,4 @@
1
+ import { RhfUtilsFormProvidersProps } from '../providers/RhfUtilsFormProvidersPropsType';
2
+ import { SafeFieldValues } from '../rhf/SafeFieldValuesType';
3
+ import { RhfUtilsFormProps, RhfUtilsFormPropsGetApiValues } from '../with-handlers-and-children/RhfUtilsFormProps';
4
+ export type RhfUtilsFormWithProvidersProps<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues, TGetApiValues extends undefined | RhfUtilsFormPropsGetApiValues<TTransformedValues, SafeFieldValues>, TOnSubmitReturnType, TApiValues extends undefined | SafeFieldValues = TGetApiValues extends RhfUtilsFormPropsGetApiValues<TTransformedValues, infer U> ? U : undefined> = RhfUtilsFormProvidersProps<TFieldValues, TTransformedValues> & RhfUtilsFormProps<TFieldValues, TTransformedValues, TGetApiValues, TOnSubmitReturnType, TApiValues>;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Generic object schema type.
3
+ */
4
+ export type ObjectSchema<
5
+ TInputKey extends string,
6
+ TOutputKey extends string,
7
+ > = Record<TInputKey, SafeFieldValues> & Record<TOutputKey, SafeFieldValues>;
@@ -0,0 +1,7 @@
1
+ import { default as React } from 'react';
2
+ import { RhfUtilsUseZodFormChildrenProps } from './RhfUtilsUseZodFormChildrenPropsType';
3
+ import { ZodTypeSafeFieldValues } from './ZodTypeSafeFieldValuesType';
4
+ /**
5
+ * {@link React.FC} for {@link RhfUtilsUseZodFormChildrenProps}.
6
+ */
7
+ export type RhfUtilsUseZodFormChildrenFC<TSchema extends ZodTypeSafeFieldValues, TChildrenProps = undefined> = React.FC<RhfUtilsUseZodFormChildrenProps<TSchema, TChildrenProps>>;
@@ -0,0 +1,4 @@
1
+ import { UseRhfUtilsFormChildrenProps } from '../../form/UseRhfUtilsFormChildrenPropsType';
2
+ import { zodTypeInput, zodTypeOutput } from './consts';
3
+ import { ZodTypeSafeFieldValues } from './ZodTypeSafeFieldValuesType';
4
+ export type RhfUtilsUseZodFormChildrenProps<TSchema extends ZodTypeSafeFieldValues, TChildrenProps = undefined> = UseRhfUtilsFormChildrenProps<TSchema[typeof zodTypeInput], TSchema[typeof zodTypeOutput], TChildrenProps>;
@@ -0,0 +1,5 @@
1
+ import { z } from 'zod';
2
+ import { SafeFieldValues } from '../../form/rhf/SafeFieldValuesType';
3
+ type ZodTypeOfSafeFieldValues = z.ZodType<SafeFieldValues, z.ZodObjectDef>;
4
+ export type ZodTypeSafeFieldValues = ZodTypeOfSafeFieldValues | z.ZodEffects<ZodTypeOfSafeFieldValues>;
5
+ export {};
@@ -0,0 +1,4 @@
1
+ /** Schema key that returns input type. */
2
+ export declare const zodTypeInput: "_input";
3
+ /** Schema keys that returns output type. */
4
+ export declare const zodTypeOutput: "_output";
@@ -0,0 +1,7 @@
1
+ import { SafeFieldValues } from '../../../form/rhf/SafeFieldValuesType';
2
+ import { RhfUtilsFormProps, RhfUtilsFormPropsGetApiValues } from '../../../form/with-handlers-and-children/RhfUtilsFormProps';
3
+ import { zodTypeInput, zodTypeOutput } from '../consts';
4
+ import { ZodTypeSafeFieldValues } from '../ZodTypeSafeFieldValuesType';
5
+ type Props<TSchema extends ZodTypeSafeFieldValues, TGetApiValues extends undefined | RhfUtilsFormPropsGetApiValues<TSchema[typeof zodTypeOutput], SafeFieldValues>, TOnSubmitReturnType, TApiValues extends undefined | SafeFieldValues = TGetApiValues extends RhfUtilsFormPropsGetApiValues<TSchema[typeof zodTypeOutput], infer U> ? U : undefined> = React.PropsWithChildren<RhfUtilsFormProps<TSchema[typeof zodTypeInput], TSchema[typeof zodTypeOutput], TGetApiValues, TOnSubmitReturnType, TApiValues>>;
6
+ export declare const RhfUtilsZodForm: <TSchema extends ZodTypeSafeFieldValues, TGetApiValues extends undefined | RhfUtilsFormPropsGetApiValues<TSchema[typeof zodTypeOutput], SafeFieldValues>, TOnSubmitReturnType, TApiValues extends undefined | SafeFieldValues = TGetApiValues extends RhfUtilsFormPropsGetApiValues<TSchema[typeof zodTypeOutput], infer U> ? U : undefined>(props: Props<TSchema, TGetApiValues, TOnSubmitReturnType, TApiValues>) => import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,4 @@
1
+ import { Resolver } from 'react-hook-form';
2
+ import { zodTypeInput, zodTypeOutput } from './consts';
3
+ import { ZodTypeSafeFieldValues } from './ZodTypeSafeFieldValuesType';
4
+ export declare const getZodResolver: <TSchema extends ZodTypeSafeFieldValues, TFieldValues extends TSchema[typeof zodTypeInput], TTransformedValues extends TSchema[typeof zodTypeOutput]>(schema: TSchema) => Resolver<TFieldValues, unknown, TTransformedValues>;
@@ -0,0 +1,8 @@
1
+ import { RhfUtilsFormProvidersProps } from '../../../form/providers/RhfUtilsFormProvidersPropsType';
2
+ import { zodTypeInput, zodTypeOutput } from '../consts';
3
+ import { ZodTypeSafeFieldValues } from '../ZodTypeSafeFieldValuesType';
4
+ type Props<TSchema extends ZodTypeSafeFieldValues> = React.PropsWithChildren<{
5
+ schema: TSchema;
6
+ } & RhfUtilsFormProvidersProps<TSchema[typeof zodTypeInput], TSchema[typeof zodTypeOutput]>>;
7
+ export declare const RhfUtilsZodFormProviders: <TSchema extends ZodTypeSafeFieldValues>({ schema, children, ...props }: Props<TSchema>) => import("react/jsx-runtime").JSX.Element;
8
+ export {};
@@ -0,0 +1,10 @@
1
+ import { RhfUtilsFormProvidersProps } from '../../../form/providers/RhfUtilsFormProvidersPropsType';
2
+ import { SafeFieldValues } from '../../../form/rhf/SafeFieldValuesType';
3
+ import { RhfUtilsFormProps, RhfUtilsFormPropsGetApiValues } from '../../../form/with-handlers-and-children/RhfUtilsFormProps';
4
+ import { zodTypeInput, zodTypeOutput } from '../consts';
5
+ import { ZodTypeSafeFieldValues } from '../ZodTypeSafeFieldValuesType';
6
+ type Props<TSchema extends ZodTypeSafeFieldValues, TGetApiValues extends undefined | RhfUtilsFormPropsGetApiValues<TTransformedValues, SafeFieldValues>, TOnSubmitReturnType, TFieldValues extends TSchema[typeof zodTypeInput] = TSchema[typeof zodTypeInput], TTransformedValues extends TSchema[typeof zodTypeOutput] = TSchema[typeof zodTypeOutput], TApiValues extends undefined | SafeFieldValues = TGetApiValues extends RhfUtilsFormPropsGetApiValues<TTransformedValues, infer U> ? U : undefined> = React.PropsWithChildren<{
7
+ schema: TSchema;
8
+ } & Omit<RhfUtilsFormProvidersProps<TFieldValues, TTransformedValues>, 'resolver'> & RhfUtilsFormProps<TFieldValues, TTransformedValues, TGetApiValues, TOnSubmitReturnType, TApiValues>>;
9
+ export declare const RhfUtilsZodFormWithProviders: <TSchema extends ZodTypeSafeFieldValues, TGetApiValues extends undefined | RhfUtilsFormPropsGetApiValues<TTransformedValues, SafeFieldValues>, TOnSubmitReturnType, TFieldValues extends TSchema[typeof zodTypeInput] = TSchema[typeof zodTypeInput], TTransformedValues extends TSchema[typeof zodTypeOutput] = TSchema[typeof zodTypeOutput], TApiValues extends undefined | SafeFieldValues = TGetApiValues extends RhfUtilsFormPropsGetApiValues<TTransformedValues, infer U> ? U : undefined>({ schema, ...props }: Props<TSchema, TGetApiValues, TOnSubmitReturnType, TFieldValues, TTransformedValues, TApiValues>) => import("react/jsx-runtime").JSX.Element;
10
+ export {};
@@ -0,0 +1,23 @@
1
+ import { UseFormReturn } from 'react-hook-form';
2
+ import { FormSubmitError } from './error/FormSubmitError';
3
+ import { FormSubmitFieldErrors } from './error/FormSubmitFieldErrors';
4
+ import { RhfUtilsContextProps } from '../form/context/utils/RhfUtilsContextPropsType';
5
+ import { SafeFieldValues } from '../form/rhf/SafeFieldValuesType';
6
+ /**
7
+ * Props for onSubmit other than `data` and `event`.
8
+ *
9
+ * Consider keeping shape in line with `UseRhfUtilsFormChildrenProps` and `UseRhfUtilsFormReturn`.
10
+ */
11
+ export type UseRhfUtilsFormOnSubmitContext<TFieldValues extends SafeFieldValues = SafeFieldValues, TTransformedValues extends SafeFieldValues = TFieldValues, TApiValues extends undefined | SafeFieldValues = undefined> = {
12
+ utils: RhfUtilsContextProps;
13
+ rhf: UseFormReturn<TFieldValues, unknown, TTransformedValues>;
14
+ FormSubmitError: typeof FormSubmitError<TFieldValues, TApiValues>;
15
+ };
16
+ /**
17
+ * Props for onSubmitError other than `error` and `event`.
18
+ */
19
+ export type UseRhfUtilsFormOnSubmitErrorContext<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues> = {
20
+ utils: RhfUtilsContextProps;
21
+ rhf: UseFormReturn<TFieldValues, unknown, TTransformedValues>;
22
+ errors?: FormSubmitFieldErrors;
23
+ };
@@ -0,0 +1,6 @@
1
+ import { SafeFieldValues } from '../../form/rhf/SafeFieldValuesType';
2
+ import { FormSubmitFieldErrors } from './FormSubmitFieldErrors';
3
+ export declare class FormSubmitError<TFieldValues extends SafeFieldValues = SafeFieldValues, TApiValues extends undefined | SafeFieldValues = undefined, TAllValues extends SafeFieldValues = TApiValues extends undefined ? TFieldValues : TFieldValues | TApiValues> extends Error {
4
+ errors: FormSubmitFieldErrors<TAllValues>;
5
+ constructor(errors: FormSubmitFieldErrors<TAllValues>, message?: string);
6
+ }
@@ -1,5 +1,5 @@
1
1
  import { FieldPath } from 'react-hook-form';
2
- import { SafeFieldValues } from '../../form/SafeFieldValues';
2
+ import { SafeFieldValues } from '../../form/rhf/SafeFieldValuesType';
3
3
  /**
4
4
  * Field errors structure based on RHF's `FieldErrors`.
5
5
  *
@@ -0,0 +1,8 @@
1
+ import { SafeFieldValues } from '../../form/rhf/SafeFieldValuesType';
2
+ import { RHF_UseFormReturnWithoutProxies } from '../../form/RHF_UseFormReturnWithoutProxiesType';
3
+ import { FormSubmitFieldErrors } from './FormSubmitFieldErrors';
4
+ /**
5
+ * Handle thrown {@link FormSubmitError}.
6
+ * Add key/values as name/message to RHF context errors.
7
+ */
8
+ export declare const setCtxErrorsByFormSubmitFieldErrors: <TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues>(ctx: RHF_UseFormReturnWithoutProxies<TFieldValues, TTransformedValues>, errors: FormSubmitFieldErrors) => void;
@@ -0,0 +1,4 @@
1
+ import { default as React } from 'react';
2
+ type Props = React.PropsWithChildren;
3
+ export declare const LastSubmitErrorContextProvider: React.FC<Props>;
4
+ export {};
@@ -0,0 +1,8 @@
1
+ export type LastSubmitErrorContext = {
2
+ current: undefined | {
3
+ error: unknown;
4
+ event: React.BaseSyntheticEvent;
5
+ };
6
+ set: (error: unknown, event: React.BaseSyntheticEvent) => void;
7
+ reset: () => void;
8
+ };
@@ -0,0 +1,4 @@
1
+ export declare const useLastSubmitError: () => {
2
+ error: unknown;
3
+ event: React.BaseSyntheticEvent;
4
+ } | undefined;
@@ -0,0 +1,3 @@
1
+ import { LastSubmitErrorContext } from './LastSubmitErrorContextType';
2
+ declare const _LastSubmitErrorContextProvider: import('react').Provider<LastSubmitErrorContext | undefined>, _useLastSubmitErrorContext: () => LastSubmitErrorContext;
3
+ export { _LastSubmitErrorContextProvider, _useLastSubmitErrorContext };
@@ -0,0 +1,2 @@
1
+ import { MaybePromise } from '../../utils/types';
2
+ export declare const useLastSubmitErrorContextWith: (handleSubmit: (event: React.FormEvent<HTMLFormElement>) => MaybePromise<unknown>) => (event: React.FormEvent<HTMLFormElement>) => Promise<unknown>;
@@ -10,5 +10,4 @@ import { MaybePromise } from '../utils/types';
10
10
  *
11
11
  * SubmitSuccessfulAndReset = was `isSubmitSuccessful` and now `!isDirty`
12
12
  */
13
- declare const useFormOnSubmitSuccessfulAndReset: (callback?: (...data: unknown[]) => MaybePromise<unknown>) => void;
14
- export default useFormOnSubmitSuccessfulAndReset;
13
+ export declare const useFormOnSubmitSuccessfulAndReset: (callback?: (...data: unknown[]) => MaybePromise<unknown>) => void;
@@ -0,0 +1,4 @@
1
+ import { MaybePromise } from '../utils/types';
2
+ export declare const useFormOnSubmitted: (callback?: (success: boolean) => MaybePromise<unknown>, options?: {
3
+ successful?: boolean;
4
+ }) => void;
@@ -32,5 +32,4 @@ export type UseResetFormOnSubmittedOptions = undefined | {
32
32
  * See `Rules` section: https://react-hook-form.com/api/useform/reset/
33
33
  * Specifically: "- It's recommended to reset inside useEffect after submission."
34
34
  */
35
- declare const useResetFormOnSubmitted: (options: UseResetFormOnSubmittedOptions) => void;
36
- export default useResetFormOnSubmitted;
35
+ export declare const useResetFormOnSubmitted: (options: UseResetFormOnSubmittedOptions) => void;
@@ -0,0 +1,3 @@
1
+ import { SafeFieldValues } from '../form/rhf/SafeFieldValuesType';
2
+ import { UseRhfUtilsFormOnSubmitContext } from './UseRhfUtilsFormOnSubmitContextType';
3
+ export declare const useRhfUtilsFormOnSubmitContext: <TFieldValues extends SafeFieldValues = SafeFieldValues, TTransformedValues extends SafeFieldValues = TFieldValues>() => UseRhfUtilsFormOnSubmitContext<TFieldValues, TTransformedValues>;
@@ -0,0 +1,15 @@
1
+ import { default as React } from 'react';
2
+ /**
3
+ * Listens for "change" event on form. (Debounce via `options` param.)
4
+ *
5
+ * Caveats:
6
+ * - uses DOM "change" event listener on form element via ref
7
+ * - in some cases, event does not trigger until input loses focus
8
+ * - no RHF dependency
9
+ */
10
+ export declare const useSubmitFormOnChange: (formRef: React.RefObject<HTMLFormElement | null>, options?: {
11
+ /** Disable behavior. (Default behavior is enabled for sake of simplicity of general usage.) */
12
+ disabled?: boolean;
13
+ /** Milliseconds to debounce form submission. (Default is none.) */
14
+ debounce?: number;
15
+ }) => void;
@@ -0,0 +1,9 @@
1
+ import { default as React } from 'react';
2
+ export type UseSubmitFormOnEventDebouncedOptions = {
3
+ /** Milliseconds to debounce form submission. (Default is none.) */
4
+ debounce?: number;
5
+ };
6
+ /**
7
+ * Internal, shared hook to setup debounced callback for OnChange hooks.
8
+ */
9
+ export declare const useSubmitFormOnEventDebounced: (formRef: React.RefObject<HTMLFormElement | null>, options?: UseSubmitFormOnEventDebouncedOptions) => (value: unknown) => void;
@@ -0,0 +1,14 @@
1
+ import { default as React } from 'react';
2
+ export type UseSubmitFormOnWatchOptions = {
3
+ /** Milliseconds to debounce form submission. (Default is none.) */
4
+ debounce: number;
5
+ };
6
+ /**
7
+ * Watches for changes in form values.
8
+ *
9
+ * Caveats:
10
+ * - uses RHF's useWatch
11
+ * - triggers change immediately as user types, so use sensible debounce time
12
+ * - does not cover uncontrolled inputs
13
+ */
14
+ export declare const useSubmitFormOnWatch: (formRef: React.RefObject<HTMLFormElement | null>, options?: UseSubmitFormOnWatchOptions) => void;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Component for passing-through children and ignoring props.
3
+ *
4
+ * Useful for conditional wrapping of children where conditional wrapper has props.
5
+ * (`React.Fragment` only allows `key` and `children`.)
6
+ */
7
+ export declare const PassthroughChildren: React.FC<React.PropsWithChildren>;
@@ -3,9 +3,8 @@ import { default as React } from 'react';
3
3
  * Create a strictly-typed context that throws error if no provider is found.
4
4
  * @returns A tuple with a function to get the context and the context provider.
5
5
  */
6
- declare function createContext<T = unknown>(): {
6
+ export declare function createContext<T = unknown>(): {
7
7
  readonly Provider: React.Provider<T | undefined>;
8
8
  readonly useMaybe: () => T | undefined;
9
9
  readonly useRequired: () => T & ({} | null);
10
10
  };
11
- export default createContext;
@@ -0,0 +1,5 @@
1
+ import { default as React } from 'react';
2
+ /**
3
+ * @see https://www.totaltypescript.com/forwardref-with-generic-components
4
+ */
5
+ export declare function fixedForwardRef<T, P = object>(render: React.ForwardRefRenderFunction<T, React.PropsWithoutRef<P>>): (props: P & React.RefAttributes<T>) => React.ReactNode;
@@ -0,0 +1 @@
1
+ export declare const isEmptyObject: (obj: Record<string, unknown>) => boolean;
@@ -0,0 +1,3 @@
1
+ export type MaybePromise<T> = T | Promise<T>;
2
+ /** Merge {@link C} into {@link B} into {@link A} (last taking highest precedence). */
3
+ export type Merge<A, B, C = unknown, D = unknown> = D & Omit<C, keyof D> & Omit<Omit<B, keyof C>, keyof D> & Omit<Omit<Omit<A, keyof B>, keyof C>, keyof D>;
@@ -6,5 +6,4 @@ import { default as React } from 'react';
6
6
  *
7
7
  * @param forwardedRef Forwarded `ref` prop.
8
8
  */
9
- declare const useImperativeForwardedRef: <TRef>(forwardedRef?: React.ForwardedRef<TRef>) => React.RefObject<TRef>;
10
- export default useImperativeForwardedRef;
9
+ export declare const useImperativeForwardedRef: <TRef>(forwardedRef?: React.ForwardedRef<TRef>) => React.RefObject<TRef | null>;
@@ -0,0 +1,7 @@
1
+ import { default as React } from 'react';
2
+ /**
3
+ * Use to determine if first render has run.
4
+ *
5
+ * (Supports strict mode.)
6
+ */
7
+ export declare const useIsFirstRender: () => React.RefObject<boolean>;
@@ -0,0 +1,2 @@
1
+ import { default as React } from 'react';
2
+ export declare const useRefIfValueWasTrue: (value: boolean) => readonly [React.RefObject<boolean>, () => void];
@@ -0,0 +1,2 @@
1
+ import { default as React } from 'react';
2
+ export declare const useToggle: (defaultValue?: boolean) => [boolean, React.DispatchWithoutAction];
@@ -0,0 +1 @@
1
+ /// <reference types="vite/client" />
@@ -0,0 +1,55 @@
1
+ import a from "react";
2
+ import { get as c } from "react-hook-form";
3
+ import { flatten as f } from "flat";
4
+ function d() {
5
+ const e = a.createContext(void 0), r = () => a.useContext(e), s = () => {
6
+ const t = r();
7
+ if (t === void 0) throw new Error();
8
+ return t;
9
+ };
10
+ return {
11
+ Provider: e.Provider,
12
+ useMaybe: r,
13
+ useRequired: s
14
+ };
15
+ }
16
+ const {
17
+ Provider: x,
18
+ useRequired: g,
19
+ useMaybe: E
20
+ } = d(), h = (e) => Object.keys(e).length === 0, u = (e) => f(e), b = (e) => {
21
+ const r = u(e), s = Object.keys(r);
22
+ return Object.fromEntries(
23
+ s.reduce(
24
+ (t, n) => {
25
+ const o = n.replace(
26
+ l,
27
+ ""
28
+ );
29
+ if (o === n) return t;
30
+ const i = c(e, o, void 0);
31
+ return i && t.push([o, i]), t;
32
+ },
33
+ []
34
+ // entries
35
+ )
36
+ );
37
+ }, l = /\.(?:type|message)\b$/, v = (e) => Object.fromEntries(
38
+ Object.entries(b(e)).map(([r, s]) => [
39
+ r,
40
+ {
41
+ type: s.type,
42
+ message: s.message
43
+ // strip out ref, etc. (avoid circular JSON error)
44
+ }
45
+ ])
46
+ );
47
+ export {
48
+ x as _,
49
+ E as a,
50
+ v as b,
51
+ d as c,
52
+ b as g,
53
+ h as i,
54
+ g as u
55
+ };