@mihanizm56/react-final-form-utils
Advanced tools
Comparing version 0.0.7-beta.15 to 0.0.7
@@ -0,1 +1,5 @@ | ||
export declare type ICustomCheckIsErrorField = (params: { | ||
name: string; | ||
formErrors: Record<string, string>; | ||
}) => boolean; | ||
export declare type ScrollToErrorOnFieldParamsType = { | ||
@@ -5,3 +9,4 @@ formErrors: Record<string, string>; | ||
timeoutToScroll?: number; | ||
customCheckIsErrorField?: ICustomCheckIsErrorField; | ||
}; | ||
export declare const scrollToErrorOnField: ({ formErrors, fieldNameFormatter, timeoutToScroll, }: ScrollToErrorOnFieldParamsType) => void; | ||
export declare const scrollToErrorOnField: ({ formErrors, fieldNameFormatter, timeoutToScroll, customCheckIsErrorField, }: ScrollToErrorOnFieldParamsType) => void; |
// https://erikras.com/blog/focus-on-errors | ||
export var scrollToErrorOnField = function (_a) { | ||
var formErrors = _a.formErrors, fieldNameFormatter = _a.fieldNameFormatter, _b = _a.timeoutToScroll, timeoutToScroll = _b === void 0 ? 100 : _b; | ||
var formErrors = _a.formErrors, fieldNameFormatter = _a.fieldNameFormatter, _b = _a.timeoutToScroll, timeoutToScroll = _b === void 0 ? 100 : _b, customCheckIsErrorField = _a.customCheckIsErrorField; | ||
var form = Array.from(document.forms[0]); | ||
@@ -8,6 +8,9 @@ // eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
var firstErrorFieldElement = form.find(function (_a) { | ||
var _b; | ||
var _b, _c; | ||
var name = _a.name; | ||
var fieldName = (_b = fieldNameFormatter === null || fieldNameFormatter === void 0 ? void 0 : fieldNameFormatter(name)) !== null && _b !== void 0 ? _b : name; | ||
return fieldName in formErrors; | ||
return ((_c = customCheckIsErrorField === null || customCheckIsErrorField === void 0 ? void 0 : customCheckIsErrorField({ | ||
name: name, | ||
formErrors: formErrors, | ||
})) !== null && _c !== void 0 ? _c : Boolean(formErrors[fieldName])); | ||
}); | ||
@@ -14,0 +17,0 @@ if (firstErrorFieldElement) { |
@@ -6,2 +6,2 @@ export { ChangeFieldHandler, ChangeFieldHandlerParamsType, } from './_components/change-field-handler'; | ||
export { CustomConditionParamsType, ConditionField, } from './_components/condition-field'; | ||
export { ScrollToErrorOnFieldParamsType, scrollToErrorOnField, } from './_utils/errors-field-scroll'; | ||
export { ScrollToErrorOnFieldParamsType, scrollToErrorOnField, ICustomCheckIsErrorField, } from './_utils/errors-field-scroll'; |
{ | ||
"name": "@mihanizm56/react-final-form-utils", | ||
"version": "0.0.7-beta.15", | ||
"version": "0.0.7", | ||
"description": "form utils module", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21071
345