@paragrav/rhf-utils 0.0.19 → 0.0.20
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.
- package/dist/cjs/errors/nonfield/FormNonFieldErrorMarker.js +5 -2
- package/dist/cjs/errors/nonfield/FormNonFieldErrorMarker.utils.d.ts +2 -1
- package/dist/cjs/errors/nonfield/FormNonFieldErrorMarker.utils.js +5 -3
- package/dist/cjs/errors/nonfield/utils.d.ts +1 -1
- package/dist/cjs/errors/nonfield/utils.js +1 -1
- package/dist/cjs/errors/orphan/useFormErrorsHasOnlyOrphans.d.ts +2 -0
- package/dist/cjs/errors/orphan/useFormErrorsHasOnlyOrphans.js +19 -0
- package/dist/cjs/errors/{orphans/useFormOrphanErrors.d.ts → orphan/useOrphanFormErrors.d.ts} +2 -2
- package/dist/cjs/errors/{orphans/useFormOrphanErrors.js → orphan/useOrphanFormErrors.js} +6 -7
- package/dist/cjs/errors/orphan/useOrphanFormErrorsToConsoleError.d.ts +7 -0
- package/dist/cjs/errors/{orphans/useFormErrorOrphansToConsoleError.js → orphan/useOrphanFormErrorsToConsoleError.js} +6 -8
- package/dist/cjs/errors/orphan/utils.d.ts +3 -0
- package/dist/cjs/errors/{orphans → orphan}/utils.js +3 -3
- package/dist/cjs/errors/root/{useFormRootFieldErrors.d.ts → useRootFormFieldErrors.d.ts} +2 -2
- package/dist/cjs/errors/root/{useFormRootFieldErrors.js → useRootFormFieldErrors.js} +2 -2
- package/dist/cjs/errors/useFormErrorConsoleDebug.js +2 -2
- package/dist/cjs/errors/useFormErrorsIfAny.d.ts +6 -0
- package/dist/cjs/errors/{useFormContextErrorsIfAny.js → useFormErrorsIfAny.js} +2 -2
- package/dist/cjs/errors/useFormFlatFieldErrors.d.ts +5 -0
- package/dist/cjs/errors/useFormFlatFieldErrors.js +12 -0
- package/dist/cjs/main.d.ts +6 -4
- package/dist/cjs/main.js +12 -8
- package/dist/esm/errors/getFlatFieldErrors.mjs +8 -8
- package/dist/esm/errors/nonfield/FormNonFieldErrorMarker.mjs +1 -1
- package/dist/esm/errors/nonfield/FormNonFieldErrorMarker.utils.mjs +3 -3
- package/dist/esm/errors/orphan/useFormErrorsHasOnlyOrphans.mjs +10 -0
- package/dist/esm/errors/orphan/useOrphanFormErrors.mjs +14 -0
- package/dist/esm/errors/{orphans/useFormErrorOrphansToConsoleError.mjs → orphan/useOrphanFormErrorsToConsoleError.mjs} +2 -2
- package/dist/esm/errors/{orphans → orphan}/utils.mjs +1 -1
- package/dist/esm/errors/useFormErrorConsoleDebug.mjs +3 -3
- package/dist/esm/errors/useFormErrorsIfAny.mjs +9 -0
- package/dist/esm/errors/useFormFlatFieldErrors.mjs +6 -0
- package/dist/esm/main.mjs +20 -16
- package/dist/types/errors/nonfield/FormNonFieldErrorMarker.utils.d.ts +2 -1
- package/dist/types/errors/nonfield/utils.d.ts +1 -1
- package/dist/types/errors/orphan/useFormErrorsHasOnlyOrphans.d.ts +2 -0
- package/dist/types/errors/{orphans/useFormOrphanErrors.d.ts → orphan/useOrphanFormErrors.d.ts} +2 -2
- package/dist/types/errors/orphan/useOrphanFormErrorsToConsoleError.d.ts +8 -0
- package/dist/types/errors/orphan/utils.d.ts +4 -0
- package/dist/types/errors/root/{useFormRootFieldErrors.d.ts → useRootFormFieldErrors.d.ts} +2 -2
- package/dist/types/errors/useFormErrorsIfAny.d.ts +6 -0
- package/dist/types/errors/useFormFlatFieldErrors.d.ts +5 -0
- package/dist/types/main.d.ts +6 -4
- package/package.json +58 -13
- package/dist/cjs/errors/orphans/useFormErrorOrphansToConsoleError.d.ts +0 -9
- package/dist/cjs/errors/orphans/useFormErrorsHasOnlyOrphan.d.ts +0 -2
- package/dist/cjs/errors/orphans/useFormErrorsHasOnlyOrphan.js +0 -21
- package/dist/cjs/errors/orphans/utils.d.ts +0 -3
- package/dist/cjs/errors/useFormContextErrorsIfAny.d.ts +0 -6
- package/dist/esm/errors/orphans/useFormOrphanErrors.mjs +0 -14
- package/dist/esm/errors/useFormContextErrorsIfAny.mjs +0 -9
- package/dist/types/errors/orphans/useFormErrorOrphansToConsoleError.d.ts +0 -10
- package/dist/types/errors/orphans/useFormErrorsHasOnlyOrphan.d.ts +0 -2
- package/dist/types/errors/orphans/utils.d.ts +0 -4
- package/dist/types/errors/useFormContextErrorsIfAny.d.ts +0 -6
- /package/dist/esm/errors/root/{useFormRootFieldErrors.mjs → useRootFormFieldErrors.mjs} +0 -0
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
-
const FormNonFieldErrorMarker_utils_1 = require("./FormNonFieldErrorMarker.utils");
|
|
7
|
+
const FormNonFieldErrorMarker_utils_1 = __importDefault(require("./FormNonFieldErrorMarker.utils"));
|
|
5
8
|
/**
|
|
6
9
|
* Empty, hidden marker to indicate a non-field error is presented to user.
|
|
7
10
|
*/
|
|
8
11
|
const FormNonFieldErrorMarker = ({ path }) => {
|
|
9
12
|
const dataAttribute = {
|
|
10
|
-
[FormNonFieldErrorMarker_utils_1.
|
|
13
|
+
[FormNonFieldErrorMarker_utils_1.default]: path,
|
|
11
14
|
};
|
|
12
15
|
return ((0, jsx_runtime_1.jsx)("div", { role: "alert", "aria-hidden": "true" // hide from screen readers
|
|
13
16
|
, style: { display: 'none' }, ...dataAttribute }));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* HTML data attribute for {@link FormNonFieldErrorMarker}.
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
declare const FormNonFieldErrorMarkerHtmlAttribute = "data-paragrav-rhf-utils-nonfield-error-marker-path";
|
|
5
|
+
export default FormNonFieldErrorMarkerHtmlAttribute;
|
|
5
6
|
export declare const getFormNonFieldErrorMarkerQuerySelector: (path: string) => string;
|
|
6
7
|
export declare const hasNonFieldErrorMarkerInDOM: (path: string, parentElement: Pick<HTMLElement, 'querySelector'>) => Element | null;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasNonFieldErrorMarkerInDOM = exports.getFormNonFieldErrorMarkerQuerySelector =
|
|
3
|
+
exports.hasNonFieldErrorMarkerInDOM = exports.getFormNonFieldErrorMarkerQuerySelector = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* HTML data attribute for {@link FormNonFieldErrorMarker}.
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const FormNonFieldErrorMarkerHtmlAttribute = 'data-paragrav-rhf-utils-nonfield-error-marker-path';
|
|
8
|
+
exports.default = FormNonFieldErrorMarkerHtmlAttribute;
|
|
9
|
+
// utils
|
|
10
|
+
const getFormNonFieldErrorMarkerQuerySelector = (path) => `[role="alert"][${FormNonFieldErrorMarkerHtmlAttribute}="${path}"]`;
|
|
9
11
|
exports.getFormNonFieldErrorMarkerQuerySelector = getFormNonFieldErrorMarkerQuerySelector;
|
|
10
12
|
const hasNonFieldErrorMarkerInDOM = (path, parentElement) => parentElement.querySelector((0, exports.getFormNonFieldErrorMarkerQuerySelector)(path));
|
|
11
13
|
exports.hasNonFieldErrorMarkerInDOM = hasNonFieldErrorMarkerInDOM;
|
|
@@ -12,6 +12,6 @@ import type { FieldError } from 'react-hook-form';
|
|
|
12
12
|
* - Orphan (undisplayed), which are typically caused by one of the following cases:
|
|
13
13
|
* - The input is missing.
|
|
14
14
|
* - The schema is incorrect.
|
|
15
|
-
* - The
|
|
15
|
+
* - The error is not displayed to user with `FormErrorNonFieldMarker`.
|
|
16
16
|
*/
|
|
17
17
|
export declare const isNonFieldError: (error: FieldError) => boolean;
|
|
@@ -14,7 +14,7 @@ exports.isNonFieldError = void 0;
|
|
|
14
14
|
* - Orphan (undisplayed), which are typically caused by one of the following cases:
|
|
15
15
|
* - The input is missing.
|
|
16
16
|
* - The schema is incorrect.
|
|
17
|
-
* - The
|
|
17
|
+
* - The error is not displayed to user with `FormErrorNonFieldMarker`.
|
|
18
18
|
*/
|
|
19
19
|
const isNonFieldError = (error) => !error.ref;
|
|
20
20
|
exports.isNonFieldError = isNonFieldError;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("@/utils");
|
|
7
|
+
const useFormFlatFieldErrors_1 = __importDefault(require("../useFormFlatFieldErrors"));
|
|
8
|
+
const useOrphanFormErrors_1 = __importDefault(require("./useOrphanFormErrors"));
|
|
9
|
+
const useFormErrorsHasOnlyOrphans = (formRef) => {
|
|
10
|
+
// get flat field errors of orphans and all errors
|
|
11
|
+
const orphans = (0, useOrphanFormErrors_1.default)(formRef);
|
|
12
|
+
const errors = (0, useFormFlatFieldErrors_1.default)();
|
|
13
|
+
// if no orphans, or no errors
|
|
14
|
+
if ([orphans, errors].some(utils_1.isEmptyObject))
|
|
15
|
+
return false;
|
|
16
|
+
// equal length
|
|
17
|
+
return Object.keys(orphans).length === Object.keys(errors).length;
|
|
18
|
+
};
|
|
19
|
+
exports.default = useFormErrorsHasOnlyOrphans;
|
package/dist/cjs/errors/{orphans/useFormOrphanErrors.d.ts → orphan/useOrphanFormErrors.d.ts}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
declare const
|
|
3
|
-
export default
|
|
2
|
+
declare const useOrphanFormErrors: (formRef: React.RefObject<HTMLFormElement>) => import("@/errors/getFlatFieldErrors").FlatFieldErrors;
|
|
3
|
+
export default useOrphanFormErrors;
|
|
@@ -6,14 +6,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const utils_1 = require("@/utils");
|
|
7
7
|
const useFormErrorsOnChange_1 = __importDefault(require("../useFormErrorsOnChange"));
|
|
8
8
|
const utils_2 = require("./utils");
|
|
9
|
-
const
|
|
9
|
+
const useOrphanFormErrors = (formRef) => (0, useFormErrorsOnChange_1.default)((errors) => {
|
|
10
10
|
// if no errors, return early
|
|
11
11
|
if ((0, utils_1.isEmptyObject)(errors))
|
|
12
12
|
return {};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
throw new Error(
|
|
16
|
-
|
|
17
|
-
return (0, utils_2.getRootFlatFieldErrors)(errors, formRef.current);
|
|
13
|
+
// this should never happen
|
|
14
|
+
if (!formRef.current)
|
|
15
|
+
throw new Error();
|
|
16
|
+
return (0, utils_2.getOrphanFlatFieldErrors)(errors, formRef.current);
|
|
18
17
|
});
|
|
19
|
-
exports.default =
|
|
18
|
+
exports.default = useOrphanFormErrors;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Outputs orphan errors to `console.error` all errors with `ref: undefined` that do not begin with `root(.*)`.
|
|
4
|
+
* Sentry (or equivalent) should capture.
|
|
5
|
+
*/
|
|
6
|
+
declare const useOrphanFormErrorsToConsoleError: (formRef: React.RefObject<HTMLFormElement>) => void;
|
|
7
|
+
export default useOrphanFormErrorsToConsoleError;
|
|
@@ -5,25 +5,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const react_1 = __importDefault(require("react"));
|
|
7
7
|
const react_hook_form_1 = require("react-hook-form");
|
|
8
|
-
const
|
|
8
|
+
const useOrphanFormErrors_1 = __importDefault(require("./useOrphanFormErrors"));
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
* (Most commonly `root(.*)`, but these are filtered out. They are handled by `useFormRootFieldErrors`.)
|
|
12
|
-
* Outputs to `console.error` all errors with `ref: undefined` that do not begin with `root(.*)`.
|
|
10
|
+
* Outputs orphan errors to `console.error` all errors with `ref: undefined` that do not begin with `root(.*)`.
|
|
13
11
|
* Sentry (or equivalent) should capture.
|
|
14
12
|
*/
|
|
15
|
-
const
|
|
13
|
+
const useOrphanFormErrorsToConsoleError = (formRef) => {
|
|
16
14
|
const { getValues } = (0, react_hook_form_1.useFormContext)();
|
|
17
15
|
const { errors } = (0, react_hook_form_1.useFormState)();
|
|
18
|
-
const orphans = (0,
|
|
16
|
+
const orphans = (0, useOrphanFormErrors_1.default)(formRef);
|
|
19
17
|
react_1.default.useEffect(() => {
|
|
20
18
|
if (!Object.keys(orphans).length)
|
|
21
19
|
return;
|
|
22
|
-
console.error('
|
|
20
|
+
console.error('useOrphanFormErrorsToConsoleError', {
|
|
23
21
|
location: window.location,
|
|
24
22
|
values: getValues(),
|
|
25
23
|
orphans,
|
|
26
24
|
});
|
|
27
25
|
}, [errors, getValues, orphans]);
|
|
28
26
|
};
|
|
29
|
-
exports.default =
|
|
27
|
+
exports.default = useOrphanFormErrorsToConsoleError;
|
|
@@ -3,12 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.getOrphanFlatFieldErrors = void 0;
|
|
7
7
|
const getFlatFieldErrors_1 = __importDefault(require("../getFlatFieldErrors"));
|
|
8
8
|
const FormNonFieldErrorMarker_utils_1 = require("../nonfield/FormNonFieldErrorMarker.utils");
|
|
9
9
|
const utils_1 = require("../nonfield/utils");
|
|
10
10
|
const utils_2 = require("../root/utils");
|
|
11
|
-
const
|
|
11
|
+
const getOrphanFlatFieldErrors = (errors, parentElement) => {
|
|
12
12
|
const flatFieldErrors = (0, getFlatFieldErrors_1.default)(errors);
|
|
13
13
|
return Object.fromEntries(Object.entries(flatFieldErrors).filter(([path, error]) =>
|
|
14
14
|
// not root path
|
|
@@ -18,4 +18,4 @@ const getRootFlatFieldErrors = (errors, parentElement) => {
|
|
|
18
18
|
// does not have marker
|
|
19
19
|
!(0, FormNonFieldErrorMarker_utils_1.hasNonFieldErrorMarkerInDOM)(path, parentElement)));
|
|
20
20
|
};
|
|
21
|
-
exports.
|
|
21
|
+
exports.getOrphanFlatFieldErrors = getOrphanFlatFieldErrors;
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Root field errors from form.
|
|
3
3
|
* These are typically displayed at the bottom of the form.
|
|
4
4
|
*/
|
|
5
|
-
declare const
|
|
6
|
-
export default
|
|
5
|
+
declare const useRootFormFieldErrors: () => import("@/errors/getFlatFieldErrors").FlatFieldErrors;
|
|
6
|
+
export default useRootFormFieldErrors;
|
|
@@ -9,5 +9,5 @@ const utils_1 = require("./utils");
|
|
|
9
9
|
* Root field errors from form.
|
|
10
10
|
* These are typically displayed at the bottom of the form.
|
|
11
11
|
*/
|
|
12
|
-
const
|
|
13
|
-
exports.default =
|
|
12
|
+
const useRootFormFieldErrors = () => (0, useFormErrorsOnChange_1.default)(utils_1.getRootFlatFieldErrors);
|
|
13
|
+
exports.default = useRootFormFieldErrors;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
6
|
+
const useFormErrorsIfAny_1 = __importDefault(require("./useFormErrorsIfAny"));
|
|
7
7
|
/**
|
|
8
8
|
* Output form errors to console.debug() for easier debugging for certain condition.
|
|
9
9
|
* (e.g., in dev/staging environments or certain users)
|
|
@@ -11,7 +11,7 @@ const useFormContextErrorsIfAny_1 = __importDefault(require("./useFormContextErr
|
|
|
11
11
|
* `console.debug()` is unlikely to trigger any automated console capture reporting.
|
|
12
12
|
*/
|
|
13
13
|
const useFormErrorConsoleDebug = (condition) => {
|
|
14
|
-
const errors = (0,
|
|
14
|
+
const errors = (0, useFormErrorsIfAny_1.default)();
|
|
15
15
|
if (!condition)
|
|
16
16
|
return;
|
|
17
17
|
if (!errors)
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns errors only if there are errors.
|
|
3
|
+
* Allows simple typeguard without `isEmpty` dependency.
|
|
4
|
+
*/
|
|
5
|
+
declare const useFormErrorsIfAny: () => false | import("react-hook-form").FieldErrors<import("react-hook-form").FieldValues>;
|
|
6
|
+
export default useFormErrorsIfAny;
|
|
@@ -6,8 +6,8 @@ const utils_1 = require("@/utils");
|
|
|
6
6
|
* Returns errors only if there are errors.
|
|
7
7
|
* Allows simple typeguard without `isEmpty` dependency.
|
|
8
8
|
*/
|
|
9
|
-
const
|
|
9
|
+
const useFormErrorsIfAny = () => {
|
|
10
10
|
const { errors } = (0, react_hook_form_1.useFormState)();
|
|
11
11
|
return (0, utils_1.isEmptyObject)(errors) ? false : errors;
|
|
12
12
|
};
|
|
13
|
-
exports.default =
|
|
13
|
+
exports.default = useFormErrorsIfAny;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const getFlatFieldErrors_1 = __importDefault(require("./getFlatFieldErrors"));
|
|
7
|
+
const useFormErrorsOnChange_1 = __importDefault(require("./useFormErrorsOnChange"));
|
|
8
|
+
/**
|
|
9
|
+
* Use {@link FieldErrors} as {@link FlatFieldErrors}.
|
|
10
|
+
*/
|
|
11
|
+
const useFormFlatFieldErrors = () => (0, useFormErrorsOnChange_1.default)(getFlatFieldErrors_1.default);
|
|
12
|
+
exports.default = useFormFlatFieldErrors;
|
package/dist/cjs/main.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export { default as FormNonFieldErrorMarker } from './errors/nonfield/FormNonFieldErrorMarker';
|
|
2
|
-
export { FormNonFieldErrorMarkerHtmlAttribute } from './errors/nonfield/FormNonFieldErrorMarker.utils';
|
|
3
|
-
export { default as
|
|
4
|
-
export { default as
|
|
5
|
-
export { default as
|
|
2
|
+
export { default as FormNonFieldErrorMarkerHtmlAttribute } from './errors/nonfield/FormNonFieldErrorMarker.utils';
|
|
3
|
+
export { default as useFormErrorsHasOnlyOrphans } from './errors/orphan/useFormErrorsHasOnlyOrphans';
|
|
4
|
+
export { default as useOrphanFormErrors } from './errors/orphan/useOrphanFormErrors';
|
|
5
|
+
export { default as useOrphanFormErrorsToConsoleError } from './errors/orphan/useOrphanFormErrorsToConsoleError';
|
|
6
|
+
export { default as useRootFormFieldErrors } from './errors/root/useRootFormFieldErrors';
|
|
6
7
|
export { default as useFormErrorConsoleDebug } from './errors/useFormErrorConsoleDebug';
|
|
7
8
|
export { default as useFormErrorsEffect } from './errors/useFormErrorsEffect';
|
|
9
|
+
export { default as useFormErrorsIfAny } from './errors/useFormErrorsIfAny';
|
|
8
10
|
export { default as useFormErrorsOnChange } from './errors/useFormErrorsOnChange';
|
|
9
11
|
export { default as useFormRequestSubmit } from './errors/useFormRequestSubmit';
|
package/dist/cjs/main.js
CHANGED
|
@@ -3,21 +3,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.useFormRequestSubmit = exports.useFormErrorsOnChange = exports.useFormErrorsEffect = exports.useFormErrorConsoleDebug = exports.
|
|
6
|
+
exports.useFormRequestSubmit = exports.useFormErrorsOnChange = exports.useFormErrorsIfAny = exports.useFormErrorsEffect = exports.useFormErrorConsoleDebug = exports.useRootFormFieldErrors = exports.useOrphanFormErrorsToConsoleError = exports.useOrphanFormErrors = exports.useFormErrorsHasOnlyOrphans = exports.FormNonFieldErrorMarkerHtmlAttribute = exports.FormNonFieldErrorMarker = void 0;
|
|
7
7
|
var FormNonFieldErrorMarker_1 = require("./errors/nonfield/FormNonFieldErrorMarker");
|
|
8
8
|
Object.defineProperty(exports, "FormNonFieldErrorMarker", { enumerable: true, get: function () { return __importDefault(FormNonFieldErrorMarker_1).default; } });
|
|
9
9
|
var FormNonFieldErrorMarker_utils_1 = require("./errors/nonfield/FormNonFieldErrorMarker.utils");
|
|
10
|
-
Object.defineProperty(exports, "FormNonFieldErrorMarkerHtmlAttribute", { enumerable: true, get: function () { return FormNonFieldErrorMarker_utils_1.
|
|
11
|
-
var
|
|
12
|
-
Object.defineProperty(exports, "
|
|
13
|
-
var
|
|
14
|
-
Object.defineProperty(exports, "
|
|
15
|
-
var
|
|
16
|
-
Object.defineProperty(exports, "
|
|
10
|
+
Object.defineProperty(exports, "FormNonFieldErrorMarkerHtmlAttribute", { enumerable: true, get: function () { return __importDefault(FormNonFieldErrorMarker_utils_1).default; } });
|
|
11
|
+
var useFormErrorsHasOnlyOrphans_1 = require("./errors/orphan/useFormErrorsHasOnlyOrphans");
|
|
12
|
+
Object.defineProperty(exports, "useFormErrorsHasOnlyOrphans", { enumerable: true, get: function () { return __importDefault(useFormErrorsHasOnlyOrphans_1).default; } });
|
|
13
|
+
var useOrphanFormErrors_1 = require("./errors/orphan/useOrphanFormErrors");
|
|
14
|
+
Object.defineProperty(exports, "useOrphanFormErrors", { enumerable: true, get: function () { return __importDefault(useOrphanFormErrors_1).default; } });
|
|
15
|
+
var useOrphanFormErrorsToConsoleError_1 = require("./errors/orphan/useOrphanFormErrorsToConsoleError");
|
|
16
|
+
Object.defineProperty(exports, "useOrphanFormErrorsToConsoleError", { enumerable: true, get: function () { return __importDefault(useOrphanFormErrorsToConsoleError_1).default; } });
|
|
17
|
+
var useRootFormFieldErrors_1 = require("./errors/root/useRootFormFieldErrors");
|
|
18
|
+
Object.defineProperty(exports, "useRootFormFieldErrors", { enumerable: true, get: function () { return __importDefault(useRootFormFieldErrors_1).default; } });
|
|
17
19
|
var useFormErrorConsoleDebug_1 = require("./errors/useFormErrorConsoleDebug");
|
|
18
20
|
Object.defineProperty(exports, "useFormErrorConsoleDebug", { enumerable: true, get: function () { return __importDefault(useFormErrorConsoleDebug_1).default; } });
|
|
19
21
|
var useFormErrorsEffect_1 = require("./errors/useFormErrorsEffect");
|
|
20
22
|
Object.defineProperty(exports, "useFormErrorsEffect", { enumerable: true, get: function () { return __importDefault(useFormErrorsEffect_1).default; } });
|
|
23
|
+
var useFormErrorsIfAny_1 = require("./errors/useFormErrorsIfAny");
|
|
24
|
+
Object.defineProperty(exports, "useFormErrorsIfAny", { enumerable: true, get: function () { return __importDefault(useFormErrorsIfAny_1).default; } });
|
|
21
25
|
var useFormErrorsOnChange_1 = require("./errors/useFormErrorsOnChange");
|
|
22
26
|
Object.defineProperty(exports, "useFormErrorsOnChange", { enumerable: true, get: function () { return __importDefault(useFormErrorsOnChange_1).default; } });
|
|
23
27
|
var useFormRequestSubmit_1 = require("./errors/useFormRequestSubmit");
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { get as
|
|
1
|
+
import { get as l } from "react-hook-form";
|
|
2
2
|
import d from "./flattenFieldErrors.mjs";
|
|
3
|
-
const
|
|
4
|
-
const
|
|
3
|
+
const f = (e) => {
|
|
4
|
+
const s = d(e), c = Object.keys(s);
|
|
5
5
|
return Object.fromEntries(
|
|
6
|
-
|
|
6
|
+
c.reduce(
|
|
7
7
|
(t, o) => {
|
|
8
|
-
const r = o.replace(
|
|
8
|
+
const r = o.replace(a, "");
|
|
9
9
|
if (r === o)
|
|
10
10
|
return t;
|
|
11
|
-
const n =
|
|
11
|
+
const n = l(e, r, void 0);
|
|
12
12
|
return n && t.push([r, n]), t;
|
|
13
13
|
},
|
|
14
14
|
[]
|
|
15
15
|
// entries
|
|
16
16
|
)
|
|
17
17
|
);
|
|
18
|
-
},
|
|
18
|
+
}, u = f, a = /\.type$/;
|
|
19
19
|
export {
|
|
20
|
-
|
|
20
|
+
u as default
|
|
21
21
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const
|
|
1
|
+
const e = "data-paragrav-rhf-utils-nonfield-error-marker-path", a = e, t = (r) => `[role="alert"][${e}="${r}"]`, l = (r, o) => o.querySelector(t(r));
|
|
2
2
|
export {
|
|
3
|
-
|
|
3
|
+
a as default,
|
|
4
4
|
t as getFormNonFieldErrorMarkerQuerySelector,
|
|
5
|
-
|
|
5
|
+
l as hasNonFieldErrorMarkerInDOM
|
|
6
6
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { isEmptyObject as e } from "../../utils.mjs";
|
|
2
|
+
import t from "../useFormFlatFieldErrors.mjs";
|
|
3
|
+
import n from "./useOrphanFormErrors.mjs";
|
|
4
|
+
const m = (o) => {
|
|
5
|
+
const r = n(o), s = t();
|
|
6
|
+
return [r, s].some(e) ? !1 : Object.keys(r).length === Object.keys(s).length;
|
|
7
|
+
}, O = m;
|
|
8
|
+
export {
|
|
9
|
+
O as default
|
|
10
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "react";
|
|
2
|
+
import { isEmptyObject as t } from "../../utils.mjs";
|
|
3
|
+
import e from "../useFormErrorsOnChange.mjs";
|
|
4
|
+
import { getOrphanFlatFieldErrors as n } from "./utils.mjs";
|
|
5
|
+
const m = (r) => e((o) => {
|
|
6
|
+
if (t(o))
|
|
7
|
+
return {};
|
|
8
|
+
if (!r.current)
|
|
9
|
+
throw new Error();
|
|
10
|
+
return n(o, r.current);
|
|
11
|
+
}), a = m;
|
|
12
|
+
export {
|
|
13
|
+
a as default
|
|
14
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import t from "react";
|
|
2
2
|
import { useFormContext as n, useFormState as a } from "react-hook-form";
|
|
3
|
-
import m from "./
|
|
3
|
+
import m from "./useOrphanFormErrors.mjs";
|
|
4
4
|
const c = (e) => {
|
|
5
5
|
const { getValues: o } = n(), { errors: s } = a(), r = m(e);
|
|
6
6
|
t.useEffect(() => {
|
|
7
|
-
Object.keys(r).length && console.error("
|
|
7
|
+
Object.keys(r).length && console.error("useOrphanFormErrorsToConsoleError", {
|
|
8
8
|
location: window.location,
|
|
9
9
|
values: o(),
|
|
10
10
|
orphans: r
|
package/dist/esm/main.mjs
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import { default as e } from "./errors/nonfield/FormNonFieldErrorMarker.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { default as
|
|
4
|
-
import { default as u } from "./errors/
|
|
5
|
-
import { default as
|
|
6
|
-
import { default as
|
|
7
|
-
import { default as
|
|
8
|
-
import { default as i } from "./errors/
|
|
9
|
-
import { default as h } from "./errors/
|
|
2
|
+
import { default as t } from "./errors/nonfield/FormNonFieldErrorMarker.utils.mjs";
|
|
3
|
+
import { default as f } from "./errors/orphan/useFormErrorsHasOnlyOrphans.mjs";
|
|
4
|
+
import { default as u } from "./errors/orphan/useOrphanFormErrors.mjs";
|
|
5
|
+
import { default as d } from "./errors/orphan/useOrphanFormErrorsToConsoleError.mjs";
|
|
6
|
+
import { default as F } from "./errors/root/useRootFormFieldErrors.mjs";
|
|
7
|
+
import { default as n } from "./errors/useFormErrorConsoleDebug.mjs";
|
|
8
|
+
import { default as i } from "./errors/useFormErrorsEffect.mjs";
|
|
9
|
+
import { default as h } from "./errors/useFormErrorsIfAny.mjs";
|
|
10
|
+
import { default as C } from "./errors/useFormErrorsOnChange.mjs";
|
|
11
|
+
import { default as k } from "./errors/useFormRequestSubmit.mjs";
|
|
10
12
|
export {
|
|
11
13
|
e as FormNonFieldErrorMarker,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
t as FormNonFieldErrorMarkerHtmlAttribute,
|
|
15
|
+
n as useFormErrorConsoleDebug,
|
|
16
|
+
i as useFormErrorsEffect,
|
|
17
|
+
f as useFormErrorsHasOnlyOrphans,
|
|
18
|
+
h as useFormErrorsIfAny,
|
|
19
|
+
C as useFormErrorsOnChange,
|
|
20
|
+
k as useFormRequestSubmit,
|
|
21
|
+
u as useOrphanFormErrors,
|
|
22
|
+
d as useOrphanFormErrorsToConsoleError,
|
|
23
|
+
F as useRootFormFieldErrors
|
|
20
24
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* HTML data attribute for {@link FormNonFieldErrorMarker}.
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
declare const FormNonFieldErrorMarkerHtmlAttribute = "data-paragrav-rhf-utils-nonfield-error-marker-path";
|
|
5
|
+
export default FormNonFieldErrorMarkerHtmlAttribute;
|
|
5
6
|
export declare const getFormNonFieldErrorMarkerQuerySelector: (path: string) => string;
|
|
6
7
|
export declare const hasNonFieldErrorMarkerInDOM: (path: string, parentElement: Pick<HTMLElement, 'querySelector'>) => Element | null;
|
|
@@ -13,6 +13,6 @@ import { FieldError } from 'react-hook-form';
|
|
|
13
13
|
* - Orphan (undisplayed), which are typically caused by one of the following cases:
|
|
14
14
|
* - The input is missing.
|
|
15
15
|
* - The schema is incorrect.
|
|
16
|
-
* - The
|
|
16
|
+
* - The error is not displayed to user with `FormErrorNonFieldMarker`.
|
|
17
17
|
*/
|
|
18
18
|
export declare const isNonFieldError: (error: FieldError) => boolean;
|
package/dist/types/errors/{orphans/useFormOrphanErrors.d.ts → orphan/useOrphanFormErrors.d.ts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
|
|
3
|
-
declare const
|
|
4
|
-
export default
|
|
3
|
+
declare const useOrphanFormErrors: (formRef: React.RefObject<HTMLFormElement>) => import('../getFlatFieldErrors').FlatFieldErrors;
|
|
4
|
+
export default useOrphanFormErrors;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Outputs orphan errors to `console.error` all errors with `ref: undefined` that do not begin with `root(.*)`.
|
|
5
|
+
* Sentry (or equivalent) should capture.
|
|
6
|
+
*/
|
|
7
|
+
declare const useOrphanFormErrorsToConsoleError: (formRef: React.RefObject<HTMLFormElement>) => void;
|
|
8
|
+
export default useOrphanFormErrorsToConsoleError;
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Root field errors from form.
|
|
3
3
|
* These are typically displayed at the bottom of the form.
|
|
4
4
|
*/
|
|
5
|
-
declare const
|
|
6
|
-
export default
|
|
5
|
+
declare const useRootFormFieldErrors: () => import('../getFlatFieldErrors').FlatFieldErrors;
|
|
6
|
+
export default useRootFormFieldErrors;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns errors only if there are errors.
|
|
3
|
+
* Allows simple typeguard without `isEmpty` dependency.
|
|
4
|
+
*/
|
|
5
|
+
declare const useFormErrorsIfAny: () => false | import('react-hook-form').FieldErrors<import("react-hook-form").FieldValues>;
|
|
6
|
+
export default useFormErrorsIfAny;
|
package/dist/types/main.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export { default as FormNonFieldErrorMarker } from './errors/nonfield/FormNonFieldErrorMarker';
|
|
2
|
-
export { FormNonFieldErrorMarkerHtmlAttribute } from './errors/nonfield/FormNonFieldErrorMarker.utils';
|
|
3
|
-
export { default as
|
|
4
|
-
export { default as
|
|
5
|
-
export { default as
|
|
2
|
+
export { default as FormNonFieldErrorMarkerHtmlAttribute } from './errors/nonfield/FormNonFieldErrorMarker.utils';
|
|
3
|
+
export { default as useFormErrorsHasOnlyOrphans } from './errors/orphan/useFormErrorsHasOnlyOrphans';
|
|
4
|
+
export { default as useOrphanFormErrors } from './errors/orphan/useOrphanFormErrors';
|
|
5
|
+
export { default as useOrphanFormErrorsToConsoleError } from './errors/orphan/useOrphanFormErrorsToConsoleError';
|
|
6
|
+
export { default as useRootFormFieldErrors } from './errors/root/useRootFormFieldErrors';
|
|
6
7
|
export { default as useFormErrorConsoleDebug } from './errors/useFormErrorConsoleDebug';
|
|
7
8
|
export { default as useFormErrorsEffect } from './errors/useFormErrorsEffect';
|
|
9
|
+
export { default as useFormErrorsIfAny } from './errors/useFormErrorsIfAny';
|
|
8
10
|
export { default as useFormErrorsOnChange } from './errors/useFormErrorsOnChange';
|
|
9
11
|
export { default as useFormRequestSubmit } from './errors/useFormRequestSubmit';
|
package/package.json
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
"name": "@paragrav/rhf-utils",
|
|
3
3
|
"author": "paragrav.dev",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.20",
|
|
6
6
|
"description": "Integration utilities for react-hook-form.",
|
|
7
7
|
"type": "module",
|
|
8
|
+
"sideEffects": false,
|
|
8
9
|
"files": [
|
|
9
10
|
"dist"
|
|
10
11
|
],
|
|
@@ -12,22 +13,66 @@
|
|
|
12
13
|
"module": "./dist/esm/main.mjs",
|
|
13
14
|
"exports": {
|
|
14
15
|
".": {
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
},
|
|
19
|
-
"import": {
|
|
20
|
-
"types": "./dist/types/main.d.ts",
|
|
21
|
-
"default": "./dist/esm/main.mjs"
|
|
22
|
-
}
|
|
16
|
+
"import": "./dist/esm/main.mjs",
|
|
17
|
+
"require": "./dist/cjs/main.js",
|
|
18
|
+
"types": "./dist/types/main.d.ts"
|
|
23
19
|
},
|
|
24
|
-
"./useFormErrorConsoleDebug": {
|
|
25
|
-
"
|
|
20
|
+
"./errors/useFormErrorConsoleDebug": {
|
|
21
|
+
"import": "./dist/esm/errors/useFormErrorConsoleDebug.mjs",
|
|
26
22
|
"require": "./dist/cjs/errors/useFormErrorConsoleDebug.cjs",
|
|
27
|
-
"
|
|
23
|
+
"types": "./dist/types/errors/useFormErrorConsoleDebug.d.ts"
|
|
24
|
+
},
|
|
25
|
+
"./errors/useFormErrorsEffect": {
|
|
26
|
+
"import": "./dist/esm/errors/useFormErrorsEffect.mjs",
|
|
27
|
+
"require": "./dist/cjs/errors/useFormErrorsEffect.cjs",
|
|
28
|
+
"types": "./dist/types/errors/useFormErrorsEffect.d.ts"
|
|
29
|
+
},
|
|
30
|
+
"./errors/useFormErrorsIfAny": {
|
|
31
|
+
"import": "./dist/esm/errors/useFormErrorsIfAny.mjs",
|
|
32
|
+
"require": "./dist/cjs/errors/useFormErrorsIfAny.cjs",
|
|
33
|
+
"types": "./dist/types/errors/useFormErrorsIfAny.d.ts"
|
|
34
|
+
},
|
|
35
|
+
"./errors/useFormErrorsOnChange": {
|
|
36
|
+
"import": "./dist/esm/errors/useFormErrorsOnChange.mjs",
|
|
37
|
+
"require": "./dist/cjs/errors/useFormErrorsOnChange.cjs",
|
|
38
|
+
"types": "./dist/types/errors/useFormErrorsOnChange.d.ts"
|
|
39
|
+
},
|
|
40
|
+
"./errors/useFormRequestSubmit": {
|
|
41
|
+
"import": "./dist/esm/errors/useFormRequestSubmit.mjs",
|
|
42
|
+
"require": "./dist/cjs/errors/useFormRequestSubmit.cjs",
|
|
43
|
+
"types": "./dist/types/errors/useFormRequestSubmit.d.ts"
|
|
44
|
+
},
|
|
45
|
+
"./errors/FormNonFieldErrorMarker": {
|
|
46
|
+
"import": "./dist/esm/errors/nonfield/FormNonFieldErrorMarker.mjs",
|
|
47
|
+
"require": "./dist/cjs/errors/nonfield/FormNonFieldErrorMarker.cjs",
|
|
48
|
+
"types": "./dist/types/errors/nonfield/FormNonFieldErrorMarker.d.ts"
|
|
49
|
+
},
|
|
50
|
+
"./errors/FormNonFieldErrorMarkerHtmlAttribute": {
|
|
51
|
+
"import": "./dist/esm/errors/nonfield/FormNonFieldErrorMarker.utils.mjs",
|
|
52
|
+
"require": "./dist/cjs/errors/nonfield/FormNonFieldErrorMarker.utils.cjs",
|
|
53
|
+
"types": "./dist/types/errors/nonfield/FormNonFieldErrorMarker.utils.d.ts"
|
|
54
|
+
},
|
|
55
|
+
"./errors/useOrphanFormErrorsToConsoleError": {
|
|
56
|
+
"import": "./dist/esm/errors/orphan/useOrphanFormErrorsToConsoleError.mjs",
|
|
57
|
+
"require": "./dist/cjs/errors/orphan/useOrphanFormErrorsToConsoleError.cjs",
|
|
58
|
+
"types": "./dist/types/errors/orphan/useOrphanFormErrorsToConsoleError.d.ts"
|
|
59
|
+
},
|
|
60
|
+
"./errors/useFormErrorsHasOnlyOrphans": {
|
|
61
|
+
"import": "./dist/esm/errors/orphan/useFormErrorsHasOnlyOrphans.mjs",
|
|
62
|
+
"require": "./dist/cjs/errors/orphan/useFormErrorsHasOnlyOrphans.cjs",
|
|
63
|
+
"types": "./dist/types/errors/orphan/useFormErrorsHasOnlyOrphans.d.ts"
|
|
64
|
+
},
|
|
65
|
+
"./errors/useOrphanFormErrors": {
|
|
66
|
+
"import": "./dist/esm/errors/orphan/useOrphanFormErrors.mjs",
|
|
67
|
+
"require": "./dist/cjs/errors/orphan/useOrphanFormErrors.cjs",
|
|
68
|
+
"types": "./dist/types/errors/orphan/useOrphanFormErrors.d.ts"
|
|
69
|
+
},
|
|
70
|
+
"./errors/useRootFormFieldErrors": {
|
|
71
|
+
"import": "./dist/esm/errors/root/useRootFormFieldErrors.mjs",
|
|
72
|
+
"require": "./dist/cjs/errors/root/useRootFormFieldErrors.cjs",
|
|
73
|
+
"types": "./dist/types/errors/root/useRootFormFieldErrors.d.ts"
|
|
28
74
|
}
|
|
29
75
|
},
|
|
30
|
-
"sideEffects": false,
|
|
31
76
|
"scripts": {
|
|
32
77
|
"build": "npm run validate && npm run build:cjs && npm run build:esm",
|
|
33
78
|
"build:cjs": "tsc -p ./tsconfig.cjs.json",
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* Orphans are field errors that do not have a ref.
|
|
4
|
-
* (Most commonly `root(.*)`, but these are filtered out. They are handled by `useFormRootFieldErrors`.)
|
|
5
|
-
* Outputs to `console.error` all errors with `ref: undefined` that do not begin with `root(.*)`.
|
|
6
|
-
* Sentry (or equivalent) should capture.
|
|
7
|
-
*/
|
|
8
|
-
declare const useFormErrorOrphansToConsoleError: (formRef: React.RefObject<HTMLFormElement>) => void;
|
|
9
|
-
export default useFormErrorOrphansToConsoleError;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const utils_1 = require("@/utils");
|
|
7
|
-
const useFormContextErrorsIfAny_1 = __importDefault(require("../useFormContextErrorsIfAny"));
|
|
8
|
-
const useFormOrphanErrors_1 = __importDefault(require("./useFormOrphanErrors"));
|
|
9
|
-
const useFormErrorsHasOnlyOrphan = (formRef) => {
|
|
10
|
-
const orphans = (0, useFormOrphanErrors_1.default)(formRef);
|
|
11
|
-
const errors = (0, useFormContextErrorsIfAny_1.default)();
|
|
12
|
-
// no errors
|
|
13
|
-
if (!errors)
|
|
14
|
-
return false;
|
|
15
|
-
// no orphans
|
|
16
|
-
if ((0, utils_1.isEmptyObject)(orphans))
|
|
17
|
-
return false;
|
|
18
|
-
// equal length
|
|
19
|
-
return Object.keys(orphans).length === Object.keys(errors).length;
|
|
20
|
-
};
|
|
21
|
-
exports.default = useFormErrorsHasOnlyOrphan;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns errors only if there are errors.
|
|
3
|
-
* Allows simple typeguard without `isEmpty` dependency.
|
|
4
|
-
*/
|
|
5
|
-
declare const useFormContextErrorsIfAny: () => false | import("react-hook-form").FieldErrors<import("react-hook-form").FieldValues>;
|
|
6
|
-
export default useFormContextErrorsIfAny;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import "react";
|
|
2
|
-
import { isEmptyObject as t } from "../../utils.mjs";
|
|
3
|
-
import e from "../useFormErrorsOnChange.mjs";
|
|
4
|
-
import { getRootFlatFieldErrors as n } from "./utils.mjs";
|
|
5
|
-
const s = (o) => e((r) => {
|
|
6
|
-
if (t(r))
|
|
7
|
-
return {};
|
|
8
|
-
if (!o.current)
|
|
9
|
-
throw console.error(r), new Error("This should not happen.");
|
|
10
|
-
return n(r, o.current);
|
|
11
|
-
}), a = s;
|
|
12
|
-
export {
|
|
13
|
-
a as default
|
|
14
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Orphans are field errors that do not have a ref.
|
|
5
|
-
* (Most commonly `root(.*)`, but these are filtered out. They are handled by `useFormRootFieldErrors`.)
|
|
6
|
-
* Outputs to `console.error` all errors with `ref: undefined` that do not begin with `root(.*)`.
|
|
7
|
-
* Sentry (or equivalent) should capture.
|
|
8
|
-
*/
|
|
9
|
-
declare const useFormErrorOrphansToConsoleError: (formRef: React.RefObject<HTMLFormElement>) => void;
|
|
10
|
-
export default useFormErrorOrphansToConsoleError;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns errors only if there are errors.
|
|
3
|
-
* Allows simple typeguard without `isEmpty` dependency.
|
|
4
|
-
*/
|
|
5
|
-
declare const useFormContextErrorsIfAny: () => false | import('react-hook-form').FieldErrors<import("react-hook-form").FieldValues>;
|
|
6
|
-
export default useFormContextErrorsIfAny;
|
|
File without changes
|