@paragrav/rhf-utils 0.0.45 → 0.0.50

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 (69) hide show
  1. package/dist/assets/index-BgBykTYQ.js +40 -0
  2. package/dist/esm/errors/context/provider.mjs +10 -8
  3. package/dist/esm/errors/flat/getFlatFieldErrors.mjs +11 -11
  4. package/dist/esm/errors/isFieldError.mjs +2 -2
  5. package/dist/esm/errors/orphan/getOrphansFromFieldErrors.mjs +9 -0
  6. package/dist/esm/errors/orphan/getOrphansFromFlatFieldErrors.mjs +16 -0
  7. package/dist/esm/errors/orphan/useOrphanFormErrorsMemo.mjs +4 -4
  8. package/dist/esm/errors/root/FormRootErrors.mjs +7 -7
  9. package/dist/esm/errors/root/FormRootErrorsFromContext.mjs +11 -0
  10. package/dist/esm/errors/root/getRootsFromFieldErrors.mjs +9 -0
  11. package/dist/esm/errors/root/getRootsFromFlatFieldErrors.mjs +7 -0
  12. package/dist/esm/errors/root/useRootFormFieldErrorsMemo.mjs +1 -1
  13. package/dist/esm/errors/useFormErrorsEffect.mjs +6 -6
  14. package/dist/esm/errors/useFormErrorsToConsole.mjs +17 -13
  15. package/dist/esm/exports.mjs +76 -0
  16. package/dist/esm/form/Form.mjs +45 -56
  17. package/dist/esm/form/FormWithProviders.mjs +10 -0
  18. package/dist/esm/form/context/group/useFormGroupChildIsMountedTracker.mjs +3 -1
  19. package/dist/esm/form/useForm.mjs +1 -1
  20. package/dist/esm/form/{useFormWithProvider.mjs → useFormWithProviders.mjs} +6 -6
  21. package/dist/esm/{form/FormError.mjs → submit/error/FormSubmitError.mjs} +2 -2
  22. package/dist/esm/submit/error/handleFormSubmitError.mjs +12 -0
  23. package/dist/esm/submit/useResetFormOnSubmitError.mjs +18 -0
  24. package/dist/esm/submit/useSubmitFormOnChange.mjs +21 -0
  25. package/dist/index.html +12 -0
  26. package/dist/types/errors/context/provider.d.ts +1 -1
  27. package/dist/types/errors/orphan/getOrphansFromFieldErrors.d.ts +5 -0
  28. package/dist/types/errors/orphan/getOrphansFromFlatFieldErrors.d.ts +4 -0
  29. package/dist/types/errors/root/FormRootErrorsFromContext.d.ts +3 -0
  30. package/dist/types/errors/root/getRootsFromFieldErrors.d.ts +5 -0
  31. package/dist/types/errors/root/getRootsFromFlatFieldErrors.d.ts +4 -0
  32. package/dist/types/errors/useFormErrorsIfAny.d.ts +1 -1
  33. package/dist/types/exports.d.ts +37 -0
  34. package/dist/types/form/ErrorBoundary.d.ts +15 -0
  35. package/dist/types/form/Form.d.ts +10 -3
  36. package/dist/types/form/FormWithProviders.d.ts +13 -0
  37. package/dist/types/form/{useFormWithProvider.d.ts → useFormWithProviders.d.ts} +4 -4
  38. package/dist/types/main.d.ts +1 -35
  39. package/dist/types/{form/FormError.d.ts → submit/error/FormSubmitError.d.ts} +1 -1
  40. package/dist/types/submit/error/handleFormSubmitError.d.ts +7 -0
  41. package/dist/types/submit/useResetFormOnSubmitError.d.ts +7 -0
  42. package/dist/types/submit/useSubmitFormOnChange.d.ts +4 -0
  43. package/dist/types/utils/useThrowAsyncError.d.ts +5 -0
  44. package/package.json +28 -17
  45. package/dist/esm/errors/nonfield/isNonFieldError.mjs +0 -5
  46. package/dist/esm/errors/orphan/getOrphanFlatFieldErrors.mjs +0 -20
  47. package/dist/esm/errors/root/getRootFlatFieldErrors.mjs +0 -11
  48. package/dist/esm/form/FormWithProvider.mjs +0 -9
  49. package/dist/esm/main.mjs +0 -72
  50. package/dist/types/errors/flat/getFlatFieldErrorsByFilter.d.ts +0 -9
  51. package/dist/types/errors/flattenFieldErrors.d.ts +0 -15
  52. package/dist/types/errors/getFlatFieldErrors.d.ts +0 -25
  53. package/dist/types/errors/orphan/getOrphanFlatFieldErrors.d.ts +0 -5
  54. package/dist/types/errors/orphan/useOrphanFormErrors.d.ts +0 -4
  55. package/dist/types/errors/orphan/useOrphanFormErrorsToConsoleError.d.ts +0 -9
  56. package/dist/types/errors/root/getRootFlatFieldErrors.d.ts +0 -8
  57. package/dist/types/errors/root/useRootFormFieldErrors.d.ts +0 -6
  58. package/dist/types/errors/root/utils.d.ts +0 -12
  59. package/dist/types/errors/useFormErrorsOnChange.d.ts +0 -7
  60. package/dist/types/errors/useFormFieldErrors.d.ts +0 -6
  61. package/dist/types/errors/useFormFlatFieldErrors.d.ts +0 -5
  62. package/dist/types/form/FormWithProvider.d.ts +0 -13
  63. package/dist/types/form/context/group/useAsFormGroupParent.d.ts +0 -7
  64. package/dist/types/form/context/parent/FormParentContextProvider.d.ts +0 -5
  65. package/dist/types/form/context/parent/index.d.ts +0 -6
  66. package/dist/types/form/context/parent/useAsFormParentState.d.ts +0 -7
  67. package/dist/types/form/context/parent/useFormParentIsBusy.d.ts +0 -7
  68. package/dist/types/form/toggle/ToggleForm.d.ts +0 -18
  69. package/dist/types/utils/createRequiredContext.d.ts +0 -8
@@ -0,0 +1,5 @@
1
+ /**
2
+ * React cannot handle async errors in event handlers or useEffects.
3
+ */
4
+ declare const useThrowAsyncError: () => (error: unknown) => void;
5
+ export default useThrowAsyncError;
package/package.json CHANGED
@@ -2,18 +2,18 @@
2
2
  "name": "@paragrav/rhf-utils",
3
3
  "author": "paragrav.dev",
4
4
  "license": "MIT",
5
- "version": "0.0.45",
5
+ "version": "0.0.50",
6
6
  "description": "Integration utilities for react-hook-form.",
7
7
  "type": "module",
8
8
  "sideEffects": false,
9
9
  "files": [
10
10
  "dist"
11
11
  ],
12
- "module": "./dist/esm/main.mjs",
12
+ "module": "./dist/esm/exports.mjs",
13
13
  "exports": {
14
14
  ".": {
15
- "default": "./dist/esm/main.mjs",
16
- "types": "./dist/types/main.d.ts"
15
+ "default": "./dist/esm/exports.mjs",
16
+ "types": "./dist/types/exports.d.ts"
17
17
  },
18
18
  "./LazyDevTool": {
19
19
  "default": "./dist/esm/devtool/LazyDevTool.mjs",
@@ -75,21 +75,17 @@
75
75
  "default": "./dist/esm/form/Form.mjs",
76
76
  "types": "./dist/types/form/Form.d.ts"
77
77
  },
78
- "./form/FormError": {
79
- "default": "./dist/esm/form/FormError.mjs",
80
- "types": "./dist/types/form/FormError.d.ts"
81
- },
82
- "./form/context/FormWithProvider": {
83
- "default": "./dist/esm/form/context/FormWithProvider.mjs",
84
- "types": "./dist/types/form/context/FormWithProvider.d.ts"
78
+ "./form/context/FormWithProviders": {
79
+ "default": "./dist/esm/form/context/FormWithProviders.mjs",
80
+ "types": "./dist/types/form/context/FormWithProviders.d.ts"
85
81
  },
86
82
  "./form/useForm": {
87
83
  "default": "./dist/esm/form/useForm.mjs",
88
84
  "types": "./dist/types/form/useForm.d.ts"
89
85
  },
90
- "./form/useFormWithProvider": {
91
- "default": "./dist/esm/form/useFormWithProvider.mjs",
92
- "types": "./dist/types/form/useFormWithProvider.d.ts"
86
+ "./form/useFormWithProviders": {
87
+ "default": "./dist/esm/form/useFormWithProviders.mjs",
88
+ "types": "./dist/types/form/useFormWithProviders.d.ts"
93
89
  },
94
90
  "./form/context/FormProvider": {
95
91
  "default": "./dist/esm/form/context/FormProvider.mjs",
@@ -139,27 +135,41 @@
139
135
  "default": "./dist/esm/submit/useFormOnSubmitSuccessful.mjs",
140
136
  "types": "./dist/types/submit/useFormOnSubmitSuccessful.d.ts"
141
137
  },
138
+ "./submit/error/FormSubmitError": {
139
+ "default": "./dist/esm/submit/error/FormSubmitError.mjs",
140
+ "types": "./dist/types/submit/error/FormSubmitError.d.ts"
141
+ },
142
142
  "./submit/useFormOnSubmitSuccessfulAndReset": {
143
143
  "default": "./dist/esm/submit/useFormOnSubmitSuccessfulAndReset.mjs",
144
144
  "types": "./dist/types/submit/useFormOnSubmitSuccessfulAndReset.d.ts"
145
145
  },
146
+ "./submit/useResetFormOnSubmitError": {
147
+ "default": "./dist/esm/submit/useResetFormOnSubmitError.mjs",
148
+ "types": "./dist/types/submit/useResetFormOnSubmitError.d.ts"
149
+ },
146
150
  "./submit/useResetFormAfterSubmitSuccessful": {
147
151
  "default": "./dist/esm/submit/useResetFormAfterSubmitSuccessful.mjs",
148
152
  "types": "./dist/types/submit/useResetFormAfterSubmitSuccessful.d.ts"
153
+ },
154
+ "./submit/useSubmitFormOnChange": {
155
+ "default": "./dist/esm/submit/useSubmitFormOnChange.mjs",
156
+ "types": "./dist/types/submit/useSubmitFormOnChange.d.ts"
149
157
  }
150
158
  },
151
159
  "scripts": {
152
- "build": "npm install && npm run validate && npm run build:esm",
153
- "build:esm": "vite build",
160
+ "build": "npm install && npm run validate && vite build",
161
+ "build:dev": "vite build --config vite.config.dev.ts",
162
+ "dev": "vite",
154
163
  "lint": "eslint --ignore-path ./.gitignore --ext ts,tsx --report-unused-disable-directives --max-warnings 0 .",
155
164
  "preinstall": "npx only-allow npm",
156
165
  "prepare": "husky",
157
166
  "prepublishOnly": "npm run build",
167
+ "preview": "vite preview",
158
168
  "test": "vitest",
159
169
  "test:ct": "playwright test -c playwright-ct.config.ts",
160
170
  "test:ct:ui": "playwright test -c playwright-ct.config.ts --ui",
161
171
  "tsc": "tsc",
162
- "validate": "npm run tsc & npm run lint & npm run test & npm run test:ct"
172
+ "validate": "cross-env CI=1 npm run tsc & npm run lint & npm run test & npm run test:ct"
163
173
  },
164
174
  "peerDependencies": {
165
175
  "@hookform/devtools": "^4",
@@ -178,6 +188,7 @@
178
188
  "@typescript-eslint/eslint-plugin": "^7.3.1",
179
189
  "@typescript-eslint/parser": "^7.3.1",
180
190
  "@vitejs/plugin-react": "^4.2.1",
191
+ "cross-env": "^7.0.3",
181
192
  "eslint": "^8.57.0",
182
193
  "eslint-config-prettier": "^9.1.0",
183
194
  "eslint-plugin-import": "^2.29.1",
@@ -1,5 +0,0 @@
1
- import o from "../isFieldError.mjs";
2
- const e = (r) => !o(r);
3
- export {
4
- e as default
5
- };
@@ -1,20 +0,0 @@
1
- import s from "../flat/getFlatFieldErrors.mjs";
2
- import { hasNonFieldErrorMarkerInDOM as l } from "../nonfield/FormNonFieldErrorMarker.utils.mjs";
3
- import m from "../nonfield/isNonFieldError.mjs";
4
- import n from "../root/isFormErrorPathRoot.mjs";
5
- const d = (o, t) => {
6
- const e = s(o);
7
- return Object.fromEntries(
8
- Object.entries(e).filter(
9
- ([r, i]) => (
10
- // not root path
11
- !n(r) && // non-field
12
- m(i) && // does not have marker
13
- !l(r, t)
14
- )
15
- )
16
- );
17
- };
18
- export {
19
- d as default
20
- };
@@ -1,11 +0,0 @@
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
- };
@@ -1,9 +0,0 @@
1
- import { jsx as o } from "react/jsx-runtime";
2
- import e from "./useFormWithProvider.mjs";
3
- function f({ children: i, ...t }) {
4
- const r = e(t);
5
- return /* @__PURE__ */ o(r.Provider, { children: /* @__PURE__ */ o(r.Form, { children: i }) });
6
- }
7
- export {
8
- f as default
9
- };
package/dist/esm/main.mjs DELETED
@@ -1,72 +0,0 @@
1
- import { default as e } from "./devtool/LazyDevTool.mjs";
2
- import { default as s } from "./errors/context/index.mjs";
3
- import { default as u } from "./errors/context/provider.mjs";
4
- import { default as f } from "./errors/message/FormErrorMessage.mjs";
5
- import { default as d } from "./errors/message/FormErrorMessageByPath.mjs";
6
- import { default as x } from "./errors/nonfield/FormNonFieldErrorMarker.mjs";
7
- import { default as i } from "./errors/nonfield/FormNonFieldErrorMarkerHtmlAttribute.mjs";
8
- import { default as E } from "./errors/orphan/useFormHasOrphanAndNoFieldErrors.mjs";
9
- import { default as C } from "./errors/orphan/useOrphanFormErrorsMemo.mjs";
10
- import { default as P } from "./errors/orphan/useOrphanFormErrorsToConsole.mjs";
11
- import { default as b } from "./errors/root/useRootFormFieldErrorsMemo.mjs";
12
- import { default as v } from "./errors/useFormErrorConsoleDebug.mjs";
13
- import { default as G } from "./errors/useFormErrorsEffect.mjs";
14
- import { default as I } from "./errors/useFormErrorsIfAny.mjs";
15
- import { default as k } from "./errors/useFormErrorsMemo.mjs";
16
- import { default as O } from "./errors/useFormRequestSubmit.mjs";
17
- import { default as R } from "./form/Form.mjs";
18
- import { FormError as N } from "./form/FormError.mjs";
19
- import { default as U } from "./form/FormWithProvider.mjs";
20
- import { default as q } from "./form/useForm.mjs";
21
- import { default as L } from "./form/useFormWithProvider.mjs";
22
- import { default as w } from "./form/context/FormProvider.mjs";
23
- import { default as K } from "./form/context/utils/FormUtilsContextProvider.mjs";
24
- import { default as V } from "./form/context/utils/useFormUtilsContext.mjs";
25
- import { default as Y } from "./form/context/group/FormGroupContextProvider.mjs";
26
- import { default as _ } from "./form/context/group/useFormGroupChildIsMountedTracker.mjs";
27
- import { default as rr } from "./form/context/group/useFormGroupChildIsSubmittingTracker.mjs";
28
- import { default as er } from "./form/context/group/useFormGroupIsAnyBusy.mjs";
29
- import { default as sr } from "./form/context/group/useFormGroupIsChildBusy.mjs";
30
- import { default as ur } from "./form/context/group/useFormGroupIsParentBusy.mjs";
31
- import { default as fr } from "./form/context/group/useFormGroupParentTracker.mjs";
32
- import { default as dr } from "./form/utils/getSubmitterButtonData.mjs";
33
- import { default as xr } from "./submit/useFormOnSubmitSuccessful.mjs";
34
- import { default as ir } from "./submit/useFormOnSubmitSuccessfulAndReset.mjs";
35
- import { default as Er } from "./submit/useResetFormOnSubmitSuccessful.mjs";
36
- export {
37
- R as Form,
38
- N as FormError,
39
- f as FormErrorMessage,
40
- d as FormErrorMessageByPath,
41
- u as FormErrorsFlatContextProvider,
42
- Y as FormGroupContextProvider,
43
- x as FormNonFieldErrorMarker,
44
- i as FormNonFieldErrorMarkerHtmlAttribute,
45
- w as FormProvider,
46
- K as FormUtilsContextProvider,
47
- U as FormWithProvider,
48
- e as LazyDevTool,
49
- dr as getSubmitterButtonData,
50
- q as useForm,
51
- v as useFormErrorConsoleDebug,
52
- G as useFormErrorsEffect,
53
- s as useFormErrorsFlatContext,
54
- I as useFormErrorsIfAny,
55
- k as useFormErrorsMemo,
56
- _ as useFormGroupChildIsMountedTracker,
57
- rr as useFormGroupChildIsSubmittingTracker,
58
- er as useFormGroupIsAnyBusy,
59
- sr as useFormGroupIsChildBusy,
60
- ur as useFormGroupIsParentBusy,
61
- fr as useFormGroupParentTracker,
62
- E as useFormHasOrphanAndNoFieldErrors,
63
- xr as useFormOnSubmitSuccessful,
64
- ir as useFormOnSubmitSuccessfulAndReset,
65
- O as useFormRequestSubmit,
66
- V as useFormUtilsContext,
67
- L as useFormWithProvider,
68
- C as useOrphanFormErrorsMemo,
69
- P as useOrphanFormErrorsToConsole,
70
- Er as useResetFormAfterSubmitSuccessful,
71
- b as useRootFormFieldErrorsMemo
72
- };
@@ -1,9 +0,0 @@
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;
@@ -1,15 +0,0 @@
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;
@@ -1,25 +0,0 @@
1
- import { FieldError, FieldErrors } from 'react-hook-form';
2
-
3
- export type FlatFieldErrors = Record<string, FieldError>;
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;
@@ -1,5 +0,0 @@
1
- import { FlatFieldErrors } from '../flat/types';
2
- import { FieldErrors } from 'react-hook-form';
3
-
4
- declare const getOrphanFlatFieldErrors: (errors: FieldErrors, parentElement: Pick<HTMLElement, 'querySelector'>) => FlatFieldErrors;
5
- export default getOrphanFlatFieldErrors;
@@ -1,4 +0,0 @@
1
- import { default as React } from 'react';
2
-
3
- declare const useOrphanFormErrors: (formRef: React.RefObject<HTMLFormElement>) => import('../getFlatFieldErrors').FlatFieldErrors;
4
- export default useOrphanFormErrors;
@@ -1,9 +0,0 @@
1
- import { default as React } from 'react';
2
-
3
- /**
4
- * Logs out orphan errors to console.error.
5
- *
6
- * When `isDev`, it will also throw an error to bring attention to dev.
7
- */
8
- declare const useOrphanFormErrorsToConsoleError: (formRef: React.RefObject<HTMLFormElement>, isDev?: boolean) => void;
9
- export default useOrphanFormErrorsToConsoleError;
@@ -1,8 +0,0 @@
1
- import { FlatFieldErrors } from '../flat/types';
2
- import { FieldErrors } from 'react-hook-form';
3
-
4
- /**
5
- * Generate {@link FlatFieldErrors} object from {@link FieldErrors}.
6
- */
7
- declare const getRootFlatFieldErrors: (errors: FieldErrors) => FlatFieldErrors;
8
- export default getRootFlatFieldErrors;
@@ -1,6 +0,0 @@
1
- /**
2
- * Root field errors from form.
3
- * These are typically displayed at the bottom of the form.
4
- */
5
- declare const useRootFormFieldErrors: () => import('../getFlatFieldErrors').FlatFieldErrors;
6
- export default useRootFormFieldErrors;
@@ -1,12 +0,0 @@
1
- import { FlatFieldErrors } from '../getFlatFieldErrors';
2
- import { FieldErrors } from 'react-hook-form';
3
-
4
- /**
5
- * Determine if an error path is root. (e.g., `root` or `root.nested`)
6
- * @param path Flat path. (e.g., 'root.nested')
7
- */
8
- export declare const isFormErrorPathRoot: (path: string) => boolean;
9
- /**
10
- *
11
- */
12
- export declare const getRootFlatFieldErrors: (errors: FieldErrors) => FlatFieldErrors;
@@ -1,7 +0,0 @@
1
- import { FieldErrors } from 'react-hook-form';
2
-
3
- /**
4
- * Provide a callback to call when RHF errors change.
5
- */
6
- declare const useFormErrorsOnChange: <TReturn>(callback: (errors: FieldErrors) => TReturn) => TReturn;
7
- export default useFormErrorsOnChange;
@@ -1,6 +0,0 @@
1
- import { FlatFieldErrors } from './getFlatFieldErrors';
2
- import { FieldErrors } from 'react-hook-form';
3
-
4
- declare const useFormFieldErrors: () => FlatFieldErrors;
5
- export default useFormFieldErrors;
6
- export declare const getFlatFieldFormErrors: (errors: FieldErrors) => FlatFieldErrors;
@@ -1,5 +0,0 @@
1
- /**
2
- * Use {@link FieldErrors} as {@link FlatFieldErrors}.
3
- */
4
- declare const useFormFlatFieldErrors: () => import('./getFlatFieldErrors').FlatFieldErrors;
5
- export default useFormFlatFieldErrors;
@@ -1,13 +0,0 @@
1
- import { UseFormProps } from './useForm';
2
- import { FieldValues } from 'react-hook-form';
3
-
4
- export type FormWithProvider<TFieldValues extends FieldValues, TTransformedValues extends FieldValues> = React.PropsWithChildren<UseFormProps<TFieldValues, TTransformedValues>>;
5
- /**
6
- * {@link FormProvider} (and utils) with immediate descendent {@link Form}.
7
- * (Syntactic sugar for {@link useForm}. Use this for most applications.)
8
- *
9
- * Use {@link useForm} if you need to specific nesting hierarchy.
10
- * (e.g., wrapping `<tr>` with provider and nesting `<form>` within `<td>` to appease HTML rules.)
11
- */
12
- declare function FormWithProvider<TFieldValues extends FieldValues, TTransformedValues extends FieldValues>({ children, ...props }: FormWithProvider<TFieldValues, TTransformedValues>): import("react/jsx-runtime").JSX.Element;
13
- export default FormWithProvider;
@@ -1,7 +0,0 @@
1
- /**
2
- * Connect specific form state as parent context.
3
- *
4
- * Requires usage of provider.
5
- */
6
- declare const useAsFormGroupParent: () => void;
7
- export default useAsFormGroupParent;
@@ -1,5 +0,0 @@
1
- import { default as React } from 'react';
2
-
3
- type Props = React.PropsWithChildren;
4
- declare const FormParentContextProvider: React.FC<Props>;
5
- export default FormParentContextProvider;
@@ -1,6 +0,0 @@
1
- /// <reference types="react" />
2
- export type FormParentContext = {
3
- isBusy: boolean;
4
- setIsBusy: (isBusy: boolean) => void;
5
- };
6
- export declare const _useFormParentContext: () => FormParentContext | undefined, _FormParentContextProvider: import('react').Provider<FormParentContext | undefined>;
@@ -1,7 +0,0 @@
1
- /**
2
- * Connect specific form state as parent context.
3
- *
4
- * Requires usage of provider.
5
- */
6
- declare const useAsFormParentState: () => void;
7
- export default useAsFormParentState;
@@ -1,7 +0,0 @@
1
- /**
2
- * Get parent form state, if exists.
3
- *
4
- * Context provider not required. (`undefined` value in this case.)
5
- */
6
- declare const useFormParentIsBusy: () => boolean | undefined;
7
- export default useFormParentIsBusy;
@@ -1,18 +0,0 @@
1
- import { UseFormWithProviderProps } from '../useFormWithProvider';
2
- import { FieldValues, UseFormReturn } from 'react-hook-form';
3
- import { default as React } from 'react';
4
-
5
- type Props<TFieldValues extends FieldValues, TTransformedValues extends FieldValues> = React.PropsWithChildren<UseFormWithProviderProps<TFieldValues, TTransformedValues> & {
6
- Fields: React.FC<{
7
- ctx: UseFormReturn<TFieldValues, unknown, TTransformedValues>;
8
- }>;
9
- }>;
10
- /**
11
- * This form submits upon selecting a new value, and reverts (via re-render) if there is an error.
12
- *
13
- * The entire form is disabled while submitting.
14
- *
15
- * Probably not ideal to use with text inputs. Would need to implement debounce or submit on blur.
16
- */
17
- declare function ToggleForm<TFieldValues extends FieldValues, TTransformedValues extends FieldValues>({ isDev, rhf, form, utils, Fields, children, }: Props<TFieldValues, TTransformedValues>): import("react/jsx-runtime").JSX.Element;
18
- export default ToggleForm;
@@ -1,8 +0,0 @@
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;