@mantine/form
Advanced tools
Comparing version 5.3.3 to 5.4.0
@@ -50,2 +50,3 @@ 'use strict'; | ||
validateInputOnChange = false, | ||
validateInputOnBlur = false, | ||
validate: rules | ||
@@ -133,2 +134,8 @@ } = {}) { | ||
payload.onFocus = () => setTouched((current) => __spreadProps(__spreadValues({}, current), { [path]: true })); | ||
payload.onBlur = () => { | ||
if (shouldValidateOnChange.shouldValidateOnChange(path, validateInputOnBlur)) { | ||
const validationResults = validateFieldValue.validateFieldValue(path, rules, values); | ||
validationResults.hasError ? setFieldError(path, validationResults.error) : clearFieldError(path); | ||
} | ||
}; | ||
} | ||
@@ -135,0 +142,0 @@ return payload; |
@@ -42,2 +42,3 @@ import { useState, useRef, useCallback } from 'react'; | ||
validateInputOnChange = false, | ||
validateInputOnBlur = false, | ||
validate: rules | ||
@@ -125,2 +126,8 @@ } = {}) { | ||
payload.onFocus = () => setTouched((current) => __spreadProps(__spreadValues({}, current), { [path]: true })); | ||
payload.onBlur = () => { | ||
if (shouldValidateOnChange(path, validateInputOnBlur)) { | ||
const validationResults = validateFieldValue(path, rules, values); | ||
validationResults.hasError ? setFieldError(path, validationResults.error) : clearFieldError(path); | ||
} | ||
}; | ||
} | ||
@@ -127,0 +134,0 @@ return payload; |
@@ -58,2 +58,3 @@ /// <reference types="react" /> | ||
validateInputOnChange?: boolean | LooseKeys<Values>[]; | ||
validateInputOnBlur?: boolean | LooseKeys<Values>[]; | ||
} | ||
@@ -60,0 +61,0 @@ export interface UseFormReturnType<Values> { |
import { UseFormReturnType, UseFormInput } from './types'; | ||
export declare function useForm<Values = Record<string, unknown>>({ initialValues, initialErrors, initialDirty, initialTouched, clearInputErrorOnChange, validateInputOnChange, validate: rules, }?: UseFormInput<Values>): UseFormReturnType<Values>; | ||
export declare function useForm<Values = Record<string, unknown>>({ initialValues, initialErrors, initialDirty, initialTouched, clearInputErrorOnChange, validateInputOnChange, validateInputOnBlur, validate: rules, }?: UseFormInput<Values>): UseFormReturnType<Values>; | ||
//# sourceMappingURL=use-form.d.ts.map |
{ | ||
"name": "@mantine/form", | ||
"description": "Mantine form management library", | ||
"version": "5.3.3", | ||
"version": "5.4.0", | ||
"main": "cjs/index.js", | ||
@@ -6,0 +6,0 @@ "module": "esm/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
136421
1153