@bombillazo/rhf-plus 7.64.0-plus.0 → 7.64.0-plus.1
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/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.mjs +50 -7
- package/dist/index.esm.mjs.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/logic/createFormControl.d.ts.map +1 -1
- package/dist/logic/skipValidation.d.ts +18 -5
- package/dist/logic/skipValidation.d.ts.map +1 -1
- package/dist/react-server.esm.mjs +32 -6
- package/dist/react-server.esm.mjs.map +1 -1
- package/dist/types/controller.d.ts +4 -2
- package/dist/types/controller.d.ts.map +1 -1
- package/dist/types/validator.d.ts +3 -0
- package/dist/types/validator.d.ts.map +1 -1
- package/dist/useController.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createFormControl.d.ts","sourceRoot":"","sources":["../../src/logic/createFormControl.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAaV,WAAW,EACX,YAAY,EAiBZ,YAAY,EAIZ,aAAa,EAUd,MAAM,UAAU,CAAC;AAyDlB,wBAAgB,iBAAiB,CAC/B,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,QAAQ,GAAG,GAAG,EACd,kBAAkB,GAAG,YAAY,EACjC,SAAS,SAAS,YAAY,GAAG,GAAG,EAEpC,KAAK,GAAE,YAAY,CACjB,YAAY,EACZ,QAAQ,EACR,kBAAkB,EAClB,SAAS,CACL,GACL,IAAI,CACL,aAAa,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,EAAE,SAAS,CAAC,EACpE,WAAW,CACZ,GAAG;IACF,WAAW,EAAE,IAAI,CACf,aAAa,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,EAAE,SAAS,CAAC,EACpE,WAAW,CACZ,CAAC;CACH,
|
|
1
|
+
{"version":3,"file":"createFormControl.d.ts","sourceRoot":"","sources":["../../src/logic/createFormControl.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAaV,WAAW,EACX,YAAY,EAiBZ,YAAY,EAIZ,aAAa,EAUd,MAAM,UAAU,CAAC;AAyDlB,wBAAgB,iBAAiB,CAC/B,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,QAAQ,GAAG,GAAG,EACd,kBAAkB,GAAG,YAAY,EACjC,SAAS,SAAS,YAAY,GAAG,GAAG,EAEpC,KAAK,GAAE,YAAY,CACjB,YAAY,EACZ,QAAQ,EACR,kBAAkB,EAClB,SAAS,CACL,GACL,IAAI,CACL,aAAa,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,EAAE,SAAS,CAAC,EACpE,WAAW,CACZ,GAAG;IACF,WAAW,EAAE,IAAI,CACf,aAAa,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,EAAE,SAAS,CAAC,EACpE,WAAW,CACZ,CAAC;CACH,CA4wDA"}
|
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
import type { ValidationModeFlags } from '../types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Subset of ValidationModeFlags used for revalidation mode checking
|
|
4
|
+
*/
|
|
5
|
+
type ReValidateModeFlags = Pick<ValidationModeFlags, 'isOnBlur' | 'isOnChange'>;
|
|
6
|
+
declare const _default: (isBlurEvent: boolean, isTouched: boolean, isSubmitted: boolean, reValidateMode: ReValidateModeFlags, mode: Partial<ValidationModeFlags>,
|
|
6
7
|
/**
|
|
7
8
|
* Need to keep this order of parameters for backward compatibility
|
|
8
9
|
*/
|
|
9
|
-
isFocusEvent: boolean
|
|
10
|
+
isFocusEvent: boolean,
|
|
11
|
+
/**
|
|
12
|
+
* Optional field-level validation mode that overrides form-level mode.
|
|
13
|
+
* When provided, this field's mode takes precedence over the form's mode.
|
|
14
|
+
* Partial because only the relevant flags (e.g., isOnChange, isOnBlur) need to be checked.
|
|
15
|
+
*/
|
|
16
|
+
fieldMode?: Partial<ValidationModeFlags>,
|
|
17
|
+
/**
|
|
18
|
+
* Optional field-level revalidation mode that overrides form-level reValidateMode.
|
|
19
|
+
* When provided, this field's reValidateMode takes precedence after form submission.
|
|
20
|
+
* Only includes isOnBlur and isOnChange as these are the only valid revalidation modes.
|
|
21
|
+
*/
|
|
22
|
+
fieldReValidateMode?: ReValidateModeFlags) => boolean;
|
|
10
23
|
export default _default;
|
|
11
24
|
//# sourceMappingURL=skipValidation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skipValidation.d.ts","sourceRoot":"","sources":["../../src/logic/skipValidation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"skipValidation.d.ts","sourceRoot":"","sources":["../../src/logic/skipValidation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEpD;;GAEG;AACH,KAAK,mBAAmB,GAAG,IAAI,CAAC,mBAAmB,EAAE,UAAU,GAAG,YAAY,CAAC,CAAC;yBAG9E,aAAa,OAAO,EACpB,WAAW,OAAO,EAClB,aAAa,OAAO,EACpB,gBAAgB,mBAAmB,EACnC,MAAM,OAAO,CAAC,mBAAmB,CAAC;AAClC;;GAEG;AACH,cAAc,OAAO;AACrB;;;;GAIG;AACH,YAAY,OAAO,CAAC,mBAAmB,CAAC;AACxC;;;;GAIG;AACH,sBAAsB,mBAAmB;AArB3C,wBA+CE"}
|
|
@@ -597,21 +597,37 @@ var skipValidation = (isBlurEvent, isTouched, isSubmitted, reValidateMode, mode,
|
|
|
597
597
|
/**
|
|
598
598
|
* Need to keep this order of parameters for backward compatibility
|
|
599
599
|
*/
|
|
600
|
-
isFocusEvent
|
|
600
|
+
isFocusEvent,
|
|
601
|
+
/**
|
|
602
|
+
* Optional field-level validation mode that overrides form-level mode.
|
|
603
|
+
* When provided, this field's mode takes precedence over the form's mode.
|
|
604
|
+
* Partial because only the relevant flags (e.g., isOnChange, isOnBlur) need to be checked.
|
|
605
|
+
*/
|
|
606
|
+
fieldMode,
|
|
607
|
+
/**
|
|
608
|
+
* Optional field-level revalidation mode that overrides form-level reValidateMode.
|
|
609
|
+
* When provided, this field's reValidateMode takes precedence after form submission.
|
|
610
|
+
* Only includes isOnBlur and isOnChange as these are the only valid revalidation modes.
|
|
611
|
+
*/
|
|
612
|
+
fieldReValidateMode) => {
|
|
613
|
+
// Use field-level modes if provided, otherwise fallback to form-level modes
|
|
614
|
+
// This allows individual fields to have different validation timing than the form
|
|
615
|
+
const effectiveMode = fieldMode || mode;
|
|
616
|
+
const effectiveReValidateMode = fieldReValidateMode || reValidateMode;
|
|
601
617
|
// Focus events should always skip validation
|
|
602
618
|
if (isFocusEvent) {
|
|
603
619
|
return true;
|
|
604
620
|
}
|
|
605
|
-
if (
|
|
621
|
+
if (effectiveMode.isOnAll) {
|
|
606
622
|
return false;
|
|
607
623
|
}
|
|
608
|
-
else if (!isSubmitted &&
|
|
624
|
+
else if (!isSubmitted && effectiveMode.isOnTouch) {
|
|
609
625
|
return !(isTouched || isBlurEvent);
|
|
610
626
|
}
|
|
611
|
-
else if (isSubmitted ?
|
|
627
|
+
else if (isSubmitted ? effectiveReValidateMode.isOnBlur : effectiveMode.isOnBlur) {
|
|
612
628
|
return !isBlurEvent;
|
|
613
629
|
}
|
|
614
|
-
else if (isSubmitted ?
|
|
630
|
+
else if (isSubmitted ? effectiveReValidateMode.isOnChange : effectiveMode.isOnChange) {
|
|
615
631
|
return isBlurEvent;
|
|
616
632
|
}
|
|
617
633
|
return true;
|
|
@@ -1356,6 +1372,16 @@ function createFormControl(props = {}) {
|
|
|
1356
1372
|
};
|
|
1357
1373
|
const validationModeBeforeSubmit = getValidationModes(_options.mode);
|
|
1358
1374
|
const validationModeAfterSubmit = getValidationModes(_options.reValidateMode);
|
|
1375
|
+
// Extract field-level validation modes if they exist
|
|
1376
|
+
// Field-level modes take precedence over form-level modes, allowing
|
|
1377
|
+
// individual fields to override when they validate (mode) and when they
|
|
1378
|
+
// revalidate after form submission (reValidateMode)
|
|
1379
|
+
const fieldMode = (field === null || field === void 0 ? void 0 : field._f.mode)
|
|
1380
|
+
? getValidationModes(field._f.mode)
|
|
1381
|
+
: undefined;
|
|
1382
|
+
const fieldReValidateMode = (field === null || field === void 0 ? void 0 : field._f.reValidateMode)
|
|
1383
|
+
? getValidationModes(field._f.reValidateMode)
|
|
1384
|
+
: undefined;
|
|
1359
1385
|
if (field) {
|
|
1360
1386
|
// Check if field is disabled and should not process events
|
|
1361
1387
|
const isFieldDisabled = isBoolean(field._f.disabled)
|
|
@@ -1414,7 +1440,7 @@ function createFormControl(props = {}) {
|
|
|
1414
1440
|
!_options.resolver &&
|
|
1415
1441
|
!get(_formState.errors, name) &&
|
|
1416
1442
|
!field._f.deps) ||
|
|
1417
|
-
skipValidation(isBlurEvent, get(_formState.touchedFields, name), _formState.isSubmitted, validationModeAfterSubmit, validationModeBeforeSubmit, isFocusEvent);
|
|
1443
|
+
skipValidation(isBlurEvent, get(_formState.touchedFields, name), _formState.isSubmitted, validationModeAfterSubmit, validationModeBeforeSubmit, isFocusEvent, fieldMode, fieldReValidateMode);
|
|
1418
1444
|
const watched = isWatched(name, _names, isBlurEvent || isFocusEvent);
|
|
1419
1445
|
set(_formValues, name, fieldValue);
|
|
1420
1446
|
if (isBlurEvent) {
|