@paragrav/rhf-utils 0.0.139 → 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 (111) hide show
  1. package/README.md +20 -2
  2. package/dist/esm/group.mjs +74 -0
  3. package/dist/esm/{exports.mjs → main.mjs} +161 -163
  4. package/dist/esm/trpc.mjs +41 -0
  5. package/dist/esm/useFlatFieldErrorsContext.mjs +10 -0
  6. package/dist/esm/utils.mjs +20 -0
  7. package/dist/types/group.d.ts +9 -0
  8. package/dist/types/main.d.ts +15 -1
  9. package/dist/types/trpc.d.ts +2 -0
  10. package/dist/types/utils.d.ts +1 -0
  11. package/package.json +19 -7
  12. package/dist/esm/form/context/group/exports.mjs +0 -74
  13. package/dist/types/client/config/RhfUtilsClientConfig.d.ts +0 -71
  14. package/dist/types/client/config/useRhfUtilsClientConfigContext.d.ts +0 -5
  15. package/dist/types/client/context.d.ts +0 -3
  16. package/dist/types/client/index.d.ts +0 -30
  17. package/dist/types/client/utils.d.ts +0 -13
  18. package/dist/types/client/zod/RhfUtilsUseFormChildrenZodFC.d.ts +0 -13
  19. package/dist/types/client/zod/RhfUtilsUseFormChildrenZodProps.d.ts +0 -5
  20. package/dist/types/client/zod/ZodTypeFieldValues.d.ts +0 -4
  21. package/dist/types/client/zod/consts.d.ts +0 -4
  22. package/dist/types/client/zod/context/RhfUtilsClientForZodContextProvider.d.ts +0 -8
  23. package/dist/types/client/zod/context/RhfUtilsZodForm.d.ts +0 -9
  24. package/dist/types/client/zod/context/useRhfUtilsClientForZodContext.d.ts +0 -6
  25. package/dist/types/client/zod/context/useRhfUtilsZodForm.d.ts +0 -8
  26. package/dist/types/client/zod/createRhfUtilsClientForZod.d.ts +0 -4
  27. package/dist/types/devtool/LazyDevTool.d.ts +0 -12
  28. package/dist/types/errors/flat/FlatFieldErrorsList.d.ts +0 -7
  29. package/dist/types/errors/flat/context/FlatFieldErrorsContextProvider.d.ts +0 -11
  30. package/dist/types/errors/flat/context/FlatFieldErrorsOutputConfig.d.ts +0 -20
  31. package/dist/types/errors/flat/context/useFlatFieldErrorsContext.d.ts +0 -13
  32. package/dist/types/errors/flat/context/useFlatFieldErrorsContextHasOnlyOrphans.d.ts +0 -7
  33. package/dist/types/errors/flat/context/useFlatFieldErrorsContextOutput.d.ts +0 -7
  34. package/dist/types/errors/flat/filterFlatFieldErrors.d.ts +0 -9
  35. package/dist/types/errors/flat/flattenFieldErrors.d.ts +0 -16
  36. package/dist/types/errors/flat/getFlatFieldErrors.d.ts +0 -32
  37. package/dist/types/errors/flat/types.d.ts +0 -17
  38. package/dist/types/errors/getRefdFromFlatFieldErrors.d.ts +0 -2
  39. package/dist/types/errors/isFieldErrorRefd.d.ts +0 -7
  40. package/dist/types/errors/isFlatFieldErrorEntryRefd.d.ts +0 -7
  41. package/dist/types/errors/message/FormErrorMessage.d.ts +0 -8
  42. package/dist/types/errors/message/RhfUtilsFieldErrorMessage.d.ts +0 -10
  43. package/dist/types/errors/nonfield/RhfUtilsNonFieldErrorMarker.d.ts +0 -13
  44. package/dist/types/errors/nonfield/RhfUtilsNonFieldErrorMarker.spec.d.ts +0 -1
  45. package/dist/types/errors/nonfield/RhfUtilsNonFieldErrorMarker.utils.d.ts +0 -18
  46. package/dist/types/errors/nonfield/RhfUtilsNonFieldErrorMarkerHtmlAttribute.d.ts +0 -5
  47. package/dist/types/errors/nonfield/isNonFieldError.d.ts +0 -19
  48. package/dist/types/errors/nonfield/isNonFieldErrorMarkerInDOM.d.ts +0 -6
  49. package/dist/types/errors/orphan/getIsOrphanFormErrorWithParentElement.d.ts +0 -7
  50. package/dist/types/errors/orphan/getOrphansFromFlatFieldErrors.d.ts +0 -4
  51. package/dist/types/errors/orphan/isOrphanFormError.d.ts +0 -4
  52. package/dist/types/errors/output/consoleErrors.d.ts +0 -7
  53. package/dist/types/errors/output/types.d.ts +0 -7
  54. package/dist/types/errors/root/RootErrorsListFromFlatFieldErrorsContext.d.ts +0 -2
  55. package/dist/types/errors/root/consts.d.ts +0 -1
  56. package/dist/types/errors/root/getRootsFromFlatFieldErrors.d.ts +0 -2
  57. package/dist/types/errors/root/isFlatFieldErrorEntryPathRoot.d.ts +0 -7
  58. package/dist/types/errors/root/isFormErrorPathRoot.d.ts +0 -7
  59. package/dist/types/errors/trpc/getOnSubmitTrpcClientErrorHandler.d.ts +0 -11
  60. package/dist/types/errors/trpc/trpcClientErrorMessageSchema.d.ts +0 -24
  61. package/dist/types/errors/trpc/trpcClientErrorToFormSubmitFieldErrorsSchemaTransformer.d.ts +0 -28
  62. package/dist/types/exports.d.ts +0 -15
  63. package/dist/types/form/Form.d.ts +0 -11
  64. package/dist/types/form/FormWithProviders.d.ts +0 -13
  65. package/dist/types/form/RhfUtilsFormOptions.d.ts +0 -29
  66. package/dist/types/form/RhfUtilsFormProviders.d.ts +0 -12
  67. package/dist/types/form/SafeFieldValues.d.ts +0 -4
  68. package/dist/types/form/UseRhfUtilsFormChildrenProps.d.ts +0 -20
  69. package/dist/types/form/UseRhfUtilsFormOnSubmitContext.d.ts +0 -27
  70. package/dist/types/form/UseRhfUtilsFormProps.d.ts +0 -23
  71. package/dist/types/form/UseRhfUtilsFormReturn.d.ts +0 -20
  72. package/dist/types/form/_Controller.d.ts +0 -6
  73. package/dist/types/form/context/group/FormGroupContextProvider.d.ts +0 -5
  74. package/dist/types/form/context/group/exports.d.ts +0 -9
  75. package/dist/types/form/context/group/index.d.ts +0 -14
  76. package/dist/types/form/context/group/useFormGroupChildIsMountedTracker.d.ts +0 -5
  77. package/dist/types/form/context/group/useFormGroupChildIsSubmittingTracker.d.ts +0 -5
  78. package/dist/types/form/context/group/useFormGroupChildTracker.d.ts +0 -6
  79. package/dist/types/form/context/group/useFormGroupIsAnyBusy.d.ts +0 -2
  80. package/dist/types/form/context/group/useFormGroupIsChildBusy.d.ts +0 -2
  81. package/dist/types/form/context/group/useFormGroupIsParentBusy.d.ts +0 -2
  82. package/dist/types/form/context/group/useFormGroupParentTracker.d.ts +0 -7
  83. package/dist/types/form/context/group/useFormOrParentIsBusy.d.ts +0 -2
  84. package/dist/types/form/context/utils/RhfUtilsContextProvider.d.ts +0 -9
  85. package/dist/types/form/context/utils/useRhfUtilsContext.d.ts +0 -14
  86. package/dist/types/form/context/utils/useRhfUtilsContextRequestSubmit.d.ts +0 -5
  87. package/dist/types/form/useFormIsBusy.d.ts +0 -2
  88. package/dist/types/form/useRhfUtilsForm.d.ts +0 -16
  89. package/dist/types/form/utils/getSubmitterButtonData.d.ts +0 -8
  90. package/dist/types/form/utils/useFormRequestSubmit.d.ts +0 -11
  91. package/dist/types/form/utils/useShouldFormBlockNavigation.d.ts +0 -26
  92. package/dist/types/register.d.ts +0 -7
  93. package/dist/types/submit/error/FormSubmitError.d.ts +0 -7
  94. package/dist/types/submit/error/FormSubmitFieldErrors.d.ts +0 -15
  95. package/dist/types/submit/error/setCtxErrorsByFormSubmitFieldErrors.d.ts +0 -10
  96. package/dist/types/submit/useFormOnSubmitSuccessfulAndReset.d.ts +0 -15
  97. package/dist/types/submit/useFormOnSubmitted.d.ts +0 -6
  98. package/dist/types/submit/useResetFormOnSubmitted.d.ts +0 -36
  99. package/dist/types/submit/useSubmitFormOnChange.d.ts +0 -9
  100. package/dist/types/utils/PassthroughChildren.d.ts +0 -7
  101. package/dist/types/utils/createContext.d.ts +0 -12
  102. package/dist/types/utils/fixedForwardRef.d.ts +0 -7
  103. package/dist/types/utils/isEmptyObject.d.ts +0 -2
  104. package/dist/types/utils/timeoutAsync.d.ts +0 -6
  105. package/dist/types/utils/types.d.ts +0 -1
  106. package/dist/types/utils/useDebouncedOnChangeValue.d.ts +0 -14
  107. package/dist/types/utils/useImperativeForwardedRef.d.ts +0 -11
  108. package/dist/types/utils/useRefIfValueWasTrue.d.ts +0 -2
  109. package/dist/types/utils/useThrowAsyncError.d.ts +0 -5
  110. package/dist/types/utils/useToggle.d.ts +0 -4
  111. /package/dist/esm/{createContext-Jzs0Nsql.js → createContext.mjs} +0 -0
@@ -1 +1,15 @@
1
- export {};
1
+ export type { Register } from '../register';
2
+ export type { RhfUtilsClientConfig } from '../client/config/RhfUtilsClientConfig';
3
+ export { default as RhfUtilsClientForZodContextProvider } from '../client/zod/context/RhfUtilsClientForZodContextProvider';
4
+ export { default as RhfUtilsZodForm } from '../client/zod/context/RhfUtilsZodForm';
5
+ export { default as useRhfUtilsZodForm } from '../client/zod/context/useRhfUtilsZodForm';
6
+ export type { RhfUtilsUseFormChildrenZodFC } from '../client/zod/RhfUtilsUseFormChildrenZodFC';
7
+ export type { RhfUtilsUseFormChildrenZodProps } from '../client/zod/RhfUtilsUseFormChildrenZodProps';
8
+ export { default as useFlatFieldErrorsContext } from '../errors/flat/context/useFlatFieldErrorsContext';
9
+ export { default as useFlatFieldErrorsContextHasOnlyOrphans } from '../errors/flat/context/useFlatFieldErrorsContextHasOnlyOrphans';
10
+ export { default as RhfUtilsNonFieldErrorMarker } from '../errors/nonfield/RhfUtilsNonFieldErrorMarker';
11
+ export type { RhfUtilsFormOptions } from '../form/RhfUtilsFormOptions';
12
+ export type { SafeFieldValues } from '../form/SafeFieldValues';
13
+ export type { UseRhfUtilsFormChildrenProps } from '../form/UseRhfUtilsFormChildrenProps';
14
+ export { default as useRhfUtilsContext } from '../form/context/utils/useRhfUtilsContext';
15
+ export { FormSubmitError } from '../submit/error/FormSubmitError';
@@ -0,0 +1,2 @@
1
+ export { default as makeOnSubmitTrpcClientErrorHandler } from '../errors/trpc/makeOnSubmitTrpcClientErrorHandler';
2
+ export { default as trpcClientErrorToFormSubmitFieldErrorsSchemaTransformer } from '../errors/trpc/trpcClientErrorToFormSubmitFieldErrorsSchemaTransformer';
@@ -0,0 +1 @@
1
+ export { default as RootErrorsListFromFlatFieldErrorsContext } from '../errors/root/RootErrorsListFromFlatFieldErrorsContext';
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@paragrav/rhf-utils",
3
3
  "author": "paragrav.dev",
4
4
  "license": "MIT",
5
- "version": "0.0.139",
5
+ "version": "0.0.140",
6
6
  "description": "Integration utilities for react-hook-form.",
7
7
  "type": "module",
8
8
  "sideEffects": false,
@@ -10,18 +10,30 @@
10
10
  "dist/esm/*",
11
11
  "dist/types/*"
12
12
  ],
13
- "module": "./dist/esm/exports.mjs",
13
+ "module": "./dist/esm/main.mjs",
14
14
  "exports": {
15
15
  ".": {
16
16
  "import": {
17
- "default": "./dist/esm/exports.mjs",
18
- "types": "./dist/types/exports.d.ts"
17
+ "default": "./dist/esm/main.mjs",
18
+ "types": "./dist/types/main.d.ts"
19
19
  }
20
20
  },
21
- "./form/context/group": {
21
+ "./group": {
22
22
  "import": {
23
- "default": "./dist/esm/form/context/group/exports.mjs",
24
- "types": "./dist/types/form/context/group/exports.d.ts"
23
+ "default": "./dist/esm/group.mjs",
24
+ "types": "./dist/types/group.d.ts"
25
+ }
26
+ },
27
+ "./trpc": {
28
+ "import": {
29
+ "default": "./dist/esm/trpc.mjs",
30
+ "types": "./dist/types/trpc.d.ts"
31
+ }
32
+ },
33
+ "./utils": {
34
+ "import": {
35
+ "default": "./dist/esm/utils.mjs",
36
+ "types": "./dist/types/utils.d.ts"
25
37
  }
26
38
  }
27
39
  },
@@ -1,74 +0,0 @@
1
- import { jsx as C } from "react/jsx-runtime";
2
- import o from "react";
3
- import { c as G } from "../../../createContext-Jzs0Nsql.js";
4
- import { useFormState as c } from "react-hook-form";
5
- const {
6
- Provider: h,
7
- useRequired: i,
8
- useMaybe: u
9
- } = G(), P = ({ children: s }) => {
10
- const [r, e] = o.useState([]), y = r.length, p = o.useCallback((t, B) => {
11
- e(
12
- (n) => B ? (
13
- // add to array
14
- [...n, t]
15
- ) : (
16
- // remove from array
17
- n.filter((I) => I !== t)
18
- )
19
- );
20
- }, []), [F, l] = o.useState(!1);
21
- return /* @__PURE__ */ C(h, { value: {
22
- children: {
23
- busyCount: y,
24
- busyIds: r,
25
- setBusyId: p
26
- },
27
- parent: {
28
- isBusy: F,
29
- setIsBusy: l
30
- }
31
- }, children: s });
32
- }, _ = P, f = (s) => {
33
- const { setBusyId: r } = i().children, e = o.useId();
34
- o.useEffect(() => {
35
- r(e, s);
36
- }, [s, e, r]), o.useEffect(() => () => {
37
- r(e, !1);
38
- }, []);
39
- }, a = f, m = () => {
40
- const s = u();
41
- return !!(s != null && s.parent.isBusy);
42
- }, b = () => (a(!0), m()), R = b, k = () => {
43
- const { isSubmitting: s } = c();
44
- return a(s), m();
45
- }, j = k, T = () => {
46
- const s = u();
47
- return !!(s != null && s.children.busyCount) || !!(s != null && s.parent.isBusy);
48
- }, q = T, S = () => {
49
- const s = u();
50
- return !!(s != null && s.children.busyCount);
51
- }, $ = S, d = () => {
52
- const { isSubmitting: s, isLoading: r } = c();
53
- return s || r;
54
- }, g = () => {
55
- const s = d(), { setIsBusy: r } = i().parent;
56
- return o.useEffect(() => {
57
- r(s);
58
- }, [r, s]), $();
59
- }, L = g, v = () => {
60
- var e;
61
- const s = d(), r = (e = u()) == null ? void 0 : e.parent.isBusy;
62
- return !!(s || r);
63
- }, w = v;
64
- export {
65
- _ as FormGroupContextProvider,
66
- R as useFormGroupChildIsMountedTracker,
67
- j as useFormGroupChildIsSubmittingTracker,
68
- a as useFormGroupChildTracker,
69
- q as useFormGroupIsAnyBusy,
70
- $ as useFormGroupIsChildBusy,
71
- m as useFormGroupIsParentBusy,
72
- L as useFormGroupParentTracker,
73
- w as useFormOrParentIsBusy
74
- };
@@ -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>;
@@ -1,5 +0,0 @@
1
- import { RhfUtilsClientConfig } from './RhfUtilsClientConfig';
2
-
3
- declare const _RhfUtilsClientConfigContextProvider: import('react').Provider<RhfUtilsClientConfig | undefined>, useRhfUtilsClientConfigMaybeContext: () => RhfUtilsClientConfig | undefined;
4
- export default useRhfUtilsClientConfigMaybeContext;
5
- export { _RhfUtilsClientConfigContextProvider };
@@ -1,3 +0,0 @@
1
- import { CreateRhfUtilsClient, ObjectSchema } from '.';
2
-
3
- export type RhfUtilsClientContext<TObjectSchema extends ObjectSchema<TObjectSchemaInputKey, TObjectSchemaOutputKey>, TObjectSchemaInputKey extends string, TObjectSchemaOutputKey extends string> = CreateRhfUtilsClient<TObjectSchema, TObjectSchemaInputKey, TObjectSchemaOutputKey>;
@@ -1,30 +0,0 @@
1
- import { default as React } from 'react';
2
- import { Resolver } from 'react-hook-form';
3
- import { RhfUtilsClientConfig } from './config/RhfUtilsClientConfig';
4
- import { FormWithProvidersProps } from '../form/FormWithProviders';
5
- import { SafeFieldValues } from '../form/SafeFieldValues';
6
- import { UseRhfUtilsFormProps } from '../form/UseRhfUtilsFormProps';
7
- import { UseRhfUtilsFormReturn } from '../form/UseRhfUtilsFormReturn';
8
-
9
- /**
10
- * Generic object schema type.
11
- */
12
- export type ObjectSchema<TInputKey extends string, TOutputKey extends string> = {
13
- [key in TInputKey]: SafeFieldValues;
14
- } & {
15
- [key in TOutputKey]: SafeFieldValues;
16
- };
17
- export type CreateRhfUtilsClient<TObjectSchema extends ObjectSchema<TObjectSchemaInputKey, TObjectSchemaOutputKey>, TObjectSchemaInputKey extends string, TObjectSchemaOutputKey extends string> = {
18
- useForm: <TSchema extends TObjectSchema, TSchemaInput extends SafeFieldValues = TSchema[TObjectSchemaInputKey], TSchemaOutput extends SafeFieldValues = TSchema[TObjectSchemaOutputKey], UseRhfUtilsFormPropsForm extends UseRhfUtilsFormProps<TSchemaInput, TSchemaOutput> = UseRhfUtilsFormProps<TSchemaInput, TSchemaOutput>>(schema: TSchema, form: UseRhfUtilsFormPropsForm) => UseRhfUtilsFormReturn<TSchemaInput, TSchemaOutput> & {
19
- FormWithProviders: React.FC<React.PropsWithChildren>;
20
- };
21
- FormWithProviders: <TSchema extends TObjectSchema, TSchemaInput extends SafeFieldValues = TSchema[TObjectSchemaInputKey], TSchemaOutput extends SafeFieldValues = TSchema[TObjectSchemaOutputKey]>(props: {
22
- schema: TSchema;
23
- } & FormWithProvidersProps<TSchemaInput, TSchemaOutput>) => JSX.Element;
24
- };
25
- /**
26
- * ...
27
- *
28
- * (We need to use generics to generate types for schema resolver.)
29
- */
30
- export declare const createRhfUtilsClient: <TObjectSchema extends ObjectSchema<TObjectSchemaInputKey, TObjectSchemaOutputKey>, TObjectSchemaInputKey extends string, TObjectSchemaOutputKey extends string>(resolver: (schema: TObjectSchema) => Resolver<SafeFieldValues, unknown>) => (config: RhfUtilsClientConfig) => CreateRhfUtilsClient<TObjectSchema, TObjectSchemaInputKey, TObjectSchemaOutputKey>;
@@ -1,13 +0,0 @@
1
- import { RhfUtilsFormOptions } from '../form/RhfUtilsFormOptions';
2
- import { SafeFieldValues } from '../form/SafeFieldValues';
3
- import { UseRhfUtilsFormProps } from '../form/UseRhfUtilsFormProps';
4
- import { RhfUtilsClientConfig } from './config/RhfUtilsClientConfig';
5
-
6
- /**
7
- * Merge {@link RhfUtilsClientConfig.defaults} with array of {@link UseRhfUtilsFormProps}'s overrides.
8
- */
9
- export declare const mergeRhfUtilsClientConfigDefaultsWithUseRhfUtilsFormProps: <TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues>(defaults: RhfUtilsClientConfig["defaults"], ...props: Pick<UseRhfUtilsFormProps<TFieldValues, TTransformedValues>, "rhf" | "utils" | "form">[]) => {
10
- rhf?: Pick<import('react-hook-form').UseFormProps, "mode" | "reValidateMode" | "resetOptions" | "context" | "shouldFocusError" | "shouldUnregister" | "shouldUseNativeValidation" | "progressive" | "criteriaMode" | "delayError">;
11
- utils?: RhfUtilsFormOptions;
12
- form?: Omit<React.PropsWithoutRef<JSX.IntrinsicElements["form"]>, "onSubmit">;
13
- } | undefined;
@@ -1,13 +0,0 @@
1
- import { default as React } from 'react';
2
- import { RhfUtilsUseFormChildrenZodProps } from './RhfUtilsUseFormChildrenZodProps';
3
- import { ZodTypeFieldValues } from './ZodTypeFieldValues';
4
-
5
- /**
6
- * {@link React.FC} for {@link RhfUtilsUseFormChildrenZodProps}.
7
- *
8
- * @example
9
- * ```tsx
10
- * const Children: RhfUtilsUseFormChildrenZodFC<typeof schema> = () => {};
11
- * ```
12
- */
13
- export type RhfUtilsUseFormChildrenZodFC<TSchema extends ZodTypeFieldValues> = React.FC<RhfUtilsUseFormChildrenZodProps<TSchema>>;
@@ -1,5 +0,0 @@
1
- import { UseRhfUtilsFormChildrenProps } from '../../form/UseRhfUtilsFormChildrenProps';
2
- import { zodTypeInput, zodTypeOutput } from './consts';
3
- import { ZodTypeFieldValues } from './ZodTypeFieldValues';
4
-
5
- export type RhfUtilsUseFormChildrenZodProps<TSchema extends ZodTypeFieldValues> = UseRhfUtilsFormChildrenProps<TSchema[typeof zodTypeInput], TSchema[typeof zodTypeOutput]>;
@@ -1,4 +0,0 @@
1
- import { z } from 'zod';
2
- import { SafeFieldValues } from '../../form/SafeFieldValues';
3
-
4
- export type ZodTypeFieldValues = z.ZodType<SafeFieldValues>;
@@ -1,4 +0,0 @@
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";
@@ -1,8 +0,0 @@
1
- import { default as React } from 'react';
2
- import { RhfUtilsClientConfig } from '../../config/RhfUtilsClientConfig';
3
-
4
- type Props = React.PropsWithChildren<{
5
- config?: RhfUtilsClientConfig;
6
- }>;
7
- declare const RhfUtilsClientForZodContextProvider: React.FC<Props>;
8
- export default RhfUtilsClientForZodContextProvider;
@@ -1,9 +0,0 @@
1
- import { UseRhfUtilsFormProps } from '../../../form/UseRhfUtilsFormProps';
2
- import { zodTypeInput, zodTypeOutput } from '../consts';
3
- import { ZodTypeFieldValues } from '../ZodTypeFieldValues';
4
-
5
- type Props<TSchema extends ZodTypeFieldValues> = {
6
- schema: TSchema;
7
- } & UseRhfUtilsFormProps<TSchema[typeof zodTypeInput], TSchema[typeof zodTypeOutput]>;
8
- declare function RhfUtilsZodForm<TSchema extends ZodTypeFieldValues>({ schema, ...props }: Props<TSchema>): import("react/jsx-runtime").JSX.Element;
9
- export default RhfUtilsZodForm;
@@ -1,6 +0,0 @@
1
- import { default as createRhfUtilsClientForZod } from '../createRhfUtilsClientForZod';
2
-
3
- export type RhfUtilsClientForZodContext = ReturnType<typeof createRhfUtilsClientForZod>;
4
- declare const _RhfUtilsClientForZodContextProvider: import('react').Provider<import('../..').CreateRhfUtilsClient<import('../ZodTypeFieldValues').ZodTypeFieldValues, "_input", "_output"> | undefined>, useRhfUtilsClientForZodContext: () => import('../..').CreateRhfUtilsClient<import('../ZodTypeFieldValues').ZodTypeFieldValues, "_input", "_output">;
5
- export default useRhfUtilsClientForZodContext;
6
- export { _RhfUtilsClientForZodContextProvider };
@@ -1,8 +0,0 @@
1
- import { UseRhfUtilsFormProps } from '../../../form/UseRhfUtilsFormProps';
2
- import { zodTypeInput, zodTypeOutput } from '../consts';
3
- import { ZodTypeFieldValues } from '../ZodTypeFieldValues';
4
-
5
- declare const useRhfUtilsZodForm: <TSchema extends ZodTypeFieldValues>(schema: TSchema, form: UseRhfUtilsFormProps<TSchema[typeof zodTypeInput], TSchema[typeof zodTypeOutput]>) => import('../../../form/UseRhfUtilsFormReturn').UseRhfUtilsFormReturn<TSchema["_input"], TSchema["_output"]> & {
6
- FormWithProviders: import('react').FC<import('react').PropsWithChildren>;
7
- };
8
- export default useRhfUtilsZodForm;
@@ -1,4 +0,0 @@
1
- import { ZodTypeFieldValues } from './ZodTypeFieldValues';
2
-
3
- declare const createRhfUtilsClientForZod: (config: import('../config/RhfUtilsClientConfig').RhfUtilsClientConfig) => import('..').CreateRhfUtilsClient<ZodTypeFieldValues, "_input", "_output">;
4
- export default createRhfUtilsClientForZod;
@@ -1,12 +0,0 @@
1
- import { DevtoolUIProps } from '@hookform/devtools/dist/devToolUI';
2
- import { default as React } from 'react';
3
-
4
- type LazyDevToolProps = {
5
- enabled?: boolean;
6
- props?: Omit<DevtoolUIProps, 'control'>;
7
- };
8
- /**
9
- * Lazy-loaded RHF DevTool.
10
- */
11
- declare const LazyDevTool: React.FC<LazyDevToolProps>;
12
- export default LazyDevTool;
@@ -1,7 +0,0 @@
1
- import { FlatFieldErrors } from './types';
2
-
3
- export type Props = {
4
- errors: FlatFieldErrors | null | undefined;
5
- };
6
- declare const FlatFieldErrorsList: React.FC<Props>;
7
- export default FlatFieldErrorsList;
@@ -1,11 +0,0 @@
1
- import { default as React } from 'react';
2
-
3
- type Props = React.PropsWithChildren<{
4
- formRef: React.RefObject<HTMLFormElement>;
5
- }>;
6
- /**
7
- * Provides a flattened version of the form errors.
8
- * Allows flattening and filtering to happen once per errors change.
9
- */
10
- declare const FlatFieldErrorsContextProvider: React.FC<Props>;
11
- export default FlatFieldErrorsContextProvider;
@@ -1,20 +0,0 @@
1
- import { RhfUtilsErrorsOutputConsoleConfig } from '../../output/types';
2
- import { FlatFieldErrorsContext } from './useFlatFieldErrorsContext';
3
-
4
- export type FlatFieldErrorsOutputConfig = {
5
- /**
6
- * Configure how/if errors should be outputted to console.
7
- *
8
- * Example use cases:
9
- * - console.debug errors in development environment.
10
- * - console.error certain errors in production environment.
11
- */
12
- console?: (context: FlatFieldErrorsContext) => RhfUtilsErrorsOutputConsoleConfig | null | false | undefined;
13
- /**
14
- * Configure how/if errors should be thrown.
15
- *
16
- * Example use case:
17
- * - bring attention to certain errors in development environment.
18
- */
19
- throw?: (context: FlatFieldErrorsContext) => true | string | false | undefined;
20
- };
@@ -1,13 +0,0 @@
1
- import { FlatFieldErrors } from '../types';
2
-
3
- export type FlatFieldErrorsContext = {
4
- all: FlatFieldErrors;
5
- fields: FlatFieldErrors;
6
- roots: FlatFieldErrors;
7
- orphans: FlatFieldErrors;
8
- hasErrors: boolean;
9
- hasOrphans: boolean;
10
- };
11
- declare const _FormErrorsFlatContextProvider: import('react').Provider<FlatFieldErrorsContext | undefined>, useFlatFieldErrorsContext: () => FlatFieldErrorsContext;
12
- export default useFlatFieldErrorsContext;
13
- export { _FormErrorsFlatContextProvider };
@@ -1,7 +0,0 @@
1
- /**
2
- * Returns `true` if all errors are orphans.
3
- *
4
- * You may want to treat this case specifically.
5
- */
6
- declare const useFlatFieldErrorsContextHasOnlyOrphans: () => boolean;
7
- export default useFlatFieldErrorsContextHasOnlyOrphans;
@@ -1,7 +0,0 @@
1
- import { FlatFieldErrorsOutputConfig } from './FlatFieldErrorsOutputConfig';
2
-
3
- /**
4
- * Outputs (e.g., console, throw) errors based on config.
5
- */
6
- declare const useFlatFieldErrorsContextOutput: (config?: FlatFieldErrorsOutputConfig) => void;
7
- export default useFlatFieldErrorsContextOutput;
@@ -1,9 +0,0 @@
1
- import { FlatFieldErrorEntry, FlatFieldErrors } from './types';
2
-
3
- /**
4
- * Filter {@link FlatFieldErrors} by a predicate.
5
- *
6
- * (Encapsulates to and from Object entries.)
7
- */
8
- declare const makeFlatFieldErrorsFilter: (predicate: (entry: FlatFieldErrorEntry, index: number) => boolean) => (errors: FlatFieldErrors) => FlatFieldErrors;
9
- export default makeFlatFieldErrorsFilter;
@@ -1,16 +0,0 @@
1
- import { FieldErrors } from 'react-hook-form';
2
-
3
- /**
4
- * Flatten a {@link FieldErrors} object.
5
- *
6
- * @returns e.g.,
7
- * ```ts
8
- * {
9
- * "address.street.type": "too_short",
10
- * "address.street.ref.value": "123",
11
- * "address.street.message": "Required."
12
- * }
13
- * ```
14
- */
15
- declare const flattenFieldErrors: (errors: FieldErrors) => Record<string, unknown>;
16
- export default flattenFieldErrors;
@@ -1,32 +0,0 @@
1
- import { FieldErrors } from 'react-hook-form';
2
- import { FlatFieldErrors } from './types';
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
- *
10
- * @returns `FlatFieldErrors` object.
11
- *
12
- * @example
13
- * ```
14
- * {
15
- * "address.street": {
16
- * type: "too_short",
17
- * ref: { value: "123" },
18
- * message: "Required." }
19
- * }
20
- * }
21
- * ```
22
- */
23
- declare const getFlatFieldErrors: (errors: FieldErrors) => FlatFieldErrors;
24
- export default getFlatFieldErrors;
25
- /**
26
- * Regular expression to maybe match the end of a leaf node path.
27
- *
28
- * i.e., `name.type`, `address.street.message`
29
- *
30
- * iow: dot [?: non-capturing]("type" | "message")[\b word boundary][$ end of string]
31
- */
32
- export declare const regexMaybeFieldErrorLeafNodeSuffix: RegExp;
@@ -1,17 +0,0 @@
1
- import { FieldError } from 'react-hook-form';
2
-
3
- /**
4
- * Flattened field errors object.
5
- *
6
- * @example
7
- * ```ts
8
- * {
9
- * 'address.street': FieldError
10
- * }
11
- * ```
12
- */
13
- export type FlatFieldErrors = Record<string, FieldError>;
14
- /**
15
- * Return from `Object.entries` on {@link FlatFieldErrors}.
16
- */
17
- export type FlatFieldErrorEntry = [path: string, error: FieldError];
@@ -1,2 +0,0 @@
1
- declare const getRefdFromFlatFieldErrors: (errors: import('./flat/types').FlatFieldErrors) => import('./flat/types').FlatFieldErrors;
2
- export default getRefdFromFlatFieldErrors;
@@ -1,7 +0,0 @@
1
- import { FieldError } from 'react-hook-form';
2
-
3
- /**
4
- * Determine if {@link FieldError} is a `ref`'d field error.
5
- */
6
- declare const isFieldErrorRefd: (error: FieldError) => boolean;
7
- export default isFieldErrorRefd;
@@ -1,7 +0,0 @@
1
- import { FlatFieldErrorEntry } from './flat/types';
2
-
3
- /**
4
- * Determine if {@link FieldError} is a `ref`'d field error.
5
- */
6
- declare const isFlatFieldErrorEntryRefd: ([, error]: FlatFieldErrorEntry) => boolean;
7
- export default isFlatFieldErrorEntryRefd;
@@ -1,8 +0,0 @@
1
- import { default as React } from 'react';
2
-
3
- type Props = {
4
- message: string;
5
- className?: string;
6
- };
7
- declare const FormErrorMessage: React.FC<Props>;
8
- export default FormErrorMessage;
@@ -1,10 +0,0 @@
1
- type Props = {
2
- /** Field name as flat path. (e.g., "address.street") */
3
- path: string;
4
- /** Optional component to use to display message. (Defaults to {@link FormErrorMessage}) */
5
- Component?: React.FC<{
6
- message: string;
7
- }>;
8
- };
9
- declare const RhfUtilsFieldErrorMessage: React.FC<Props>;
10
- export default RhfUtilsFieldErrorMessage;
@@ -1,13 +0,0 @@
1
- type Props = {
2
- /** Flat field name. (e.g., `address.street`) */
3
- path: string;
4
- };
5
- /**
6
- * Empty, hidden marker to indicate a non-field/non-root error is being displayed to user.
7
- *
8
- * Example use case:
9
- * Field array with minimum items.
10
- * (When there are no items, the error is not associated with a field and is displayed separately.)
11
- */
12
- declare const RhfUtilsNonFieldErrorMarker: React.FC<Props>;
13
- export default RhfUtilsNonFieldErrorMarker;
@@ -1,18 +0,0 @@
1
- /**
2
- * Returns query selector for matching non-field error marker.
3
- * By default includes nested field matching. (See `options.excludeNested`.)
4
- *
5
- * @returns One or more selectors in a comma-separated list.
6
- */
7
- export declare const getRhfUtilsNonFieldErrorMarkerQuerySelector: (path: string, options?: {
8
- /**
9
- * Do not look for match as nested field.
10
- *
11
- * By default this is enabled to facilitate looking for fields that may be nested inside objects.
12
- * This is only a problem when a front-end field is nested more deeply than back-end.
13
- * For example, field arrays require objects as items, so actual field may be `field.value`.
14
- * This should be safe, as fields are by definition leaf nodes, so will not have nested fields.
15
- * (If this check should need to be more precise in the future, it may be ideal to distinguish between client/server errors or paths.)
16
- */
17
- excludeNested?: boolean;
18
- }) => string;
@@ -1,5 +0,0 @@
1
- /**
2
- * HTML data attribute for {@link RhfUtilsNonFieldErrorMarker}.
3
- */
4
- declare const RhfUtilsNonFieldErrorMarkerHtmlAttribute = "data-rhfutils-nonfield-error-marker-path";
5
- export default RhfUtilsNonFieldErrorMarkerHtmlAttribute;
@@ -1,19 +0,0 @@
1
- import { FieldError } from 'react-hook-form';
2
-
3
- /**
4
- * Determine if {@link FieldError} is a non-field error (i.e., has no `ref`).
5
- *
6
- * A non-field error has no association to an input via {@link FieldError.ref}.
7
- *
8
- * These fall into one of two categories:
9
- * - Root, which are typically displayed to user at bottom/top of form.
10
- * - Non-root, which fall into two main sub-sets:
11
- * - Non-orphan (displayed -- typically manually)
12
- * - e.g., array min/max validation
13
- * - Orphan (undisplayed), which are typically caused by one of the following cases:
14
- * - The input is missing.
15
- * - The schema is incorrect.
16
- * - The error is not displayed to user with `FormErrorNonFieldMarker`.
17
- */
18
- declare const isNonFieldError: (error: FieldError) => boolean;
19
- export default isNonFieldError;
@@ -1,6 +0,0 @@
1
- /**
2
- * Determine if a non-field error marker is in the DOM.
3
- * Note: this will also look for nested markers to accommodate field arrays
4
- */
5
- declare const isNonFieldErrorMarkerInDOM: (path: string, parentElement: Pick<HTMLElement, "querySelector">) => boolean;
6
- export default isNonFieldErrorMarkerInDOM;