@bombillazo/rhf-plus 7.64.0-plus.0 → 7.64.0-plus.2

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.
@@ -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,CA+vDA"}
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,5 +1,5 @@
1
1
  import type { ValidationRule } from '../types';
2
- declare const _default: (validationData?: ValidationRule) => import("../types").ValidationValueMessage<import("../types").ValidationValue> | {
2
+ declare const _default: (validationData?: ValidationRule) => {
3
3
  value: string | number | boolean | RegExp | undefined;
4
4
  message: string;
5
5
  };
@@ -1,4 +1,4 @@
1
1
  import type { Field } from '../types';
2
- declare const _default: (options: Field["_f"]) => string | number | boolean | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("../types").ValidationValueMessage<boolean> | import("../types").ValidationValueMessage<string | number> | import("../types").ValidationRule<RegExp> | import("../types").Validate<any, import("../types").FieldValues> | Record<string, import("../types").Validate<any, import("../types").FieldValues>> | undefined;
2
+ declare const _default: (options: Field["_f"]) => string | number | boolean | import("../types").ValidationValueMessage<boolean> | import("../types").ValidationValueMessage<string | number> | import("../types").ValidationRule<RegExp> | import("../types").Validate<any, import("../types").FieldValues> | Record<string, import("../types").Validate<any, import("../types").FieldValues>> | undefined;
3
3
  export default _default;
4
4
  //# sourceMappingURL=hasValidation.d.ts.map
@@ -1,11 +1,24 @@
1
1
  import type { ValidationModeFlags } from '../types';
2
- declare const _default: (isBlurEvent: boolean, isTouched: boolean, isSubmitted: boolean, reValidateMode: {
3
- isOnBlur: boolean;
4
- isOnChange: boolean;
5
- }, mode: Partial<ValidationModeFlags>,
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) => 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;yBAGlD,aAAa,OAAO,EACpB,WAAW,OAAO,EAClB,aAAa,OAAO,EACpB,gBAAgB;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;CACrB,EACD,MAAM,OAAO,CAAC,mBAAmB,CAAC;AAClC;;GAEG;AACH,cAAc,OAAO;AAZvB,wBA6BE"}
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"}
@@ -1 +1 @@
1
- {"version":3,"file":"validateField.d.ts","sourceRoot":"","sources":["../../src/logic/validateField.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,KAAK,EAEL,WAAW,EACX,mBAAmB,EACnB,eAAe,EAKhB,MAAM,UAAU,CAAC;yBAsBI,CAAC,SAAS,WAAW,EACzC,OAAO,KAAK,EACZ,mBAAmB,eAAe,EAClC,YAAY,CAAC,EACb,0BAA0B,OAAO,EACjC,4BAA4B,OAAO,EACnC,eAAe,OAAO,KACrB,OAAO,CAAC,mBAAmB,CAAC;AAP/B,wBAqQE"}
1
+ {"version":3,"file":"validateField.d.ts","sourceRoot":"","sources":["../../src/logic/validateField.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,KAAK,EAEL,WAAW,EACX,mBAAmB,EACnB,eAAe,EAKhB,MAAM,UAAU,CAAC;yBAqBI,CAAC,SAAS,WAAW,EACzC,OAAO,KAAK,EACZ,mBAAmB,eAAe,EAClC,YAAY,CAAC,EACb,0BAA0B,OAAO,EACjC,4BAA4B,OAAO,EACnC,eAAe,OAAO,KACrB,OAAO,CAAC,mBAAmB,CAAC;AAP/B,wBA6PE"}
@@ -1,5 +1,4 @@
1
1
  import crypto from 'crypto';
2
- import React from 'react';
3
2
 
4
3
  var appendErrors = (name, validateAllFieldCriteria, errors, type, message) => validateAllFieldCriteria
5
4
  ? {
@@ -597,21 +596,37 @@ var skipValidation = (isBlurEvent, isTouched, isSubmitted, reValidateMode, mode,
597
596
  /**
598
597
  * Need to keep this order of parameters for backward compatibility
599
598
  */
600
- isFocusEvent) => {
599
+ isFocusEvent,
600
+ /**
601
+ * Optional field-level validation mode that overrides form-level mode.
602
+ * When provided, this field's mode takes precedence over the form's mode.
603
+ * Partial because only the relevant flags (e.g., isOnChange, isOnBlur) need to be checked.
604
+ */
605
+ fieldMode,
606
+ /**
607
+ * Optional field-level revalidation mode that overrides form-level reValidateMode.
608
+ * When provided, this field's reValidateMode takes precedence after form submission.
609
+ * Only includes isOnBlur and isOnChange as these are the only valid revalidation modes.
610
+ */
611
+ fieldReValidateMode) => {
612
+ // Use field-level modes if provided, otherwise fallback to form-level modes
613
+ // This allows individual fields to have different validation timing than the form
614
+ const effectiveMode = fieldMode || mode;
615
+ const effectiveReValidateMode = fieldReValidateMode || reValidateMode;
601
616
  // Focus events should always skip validation
602
617
  if (isFocusEvent) {
603
618
  return true;
604
619
  }
605
- if (mode.isOnAll) {
620
+ if (effectiveMode.isOnAll) {
606
621
  return false;
607
622
  }
608
- else if (!isSubmitted && mode.isOnTouch) {
623
+ else if (!isSubmitted && effectiveMode.isOnTouch) {
609
624
  return !(isTouched || isBlurEvent);
610
625
  }
611
- else if (isSubmitted ? reValidateMode.isOnBlur : mode.isOnBlur) {
626
+ else if (isSubmitted ? effectiveReValidateMode.isOnBlur : effectiveMode.isOnBlur) {
612
627
  return !isBlurEvent;
613
628
  }
614
- else if (isSubmitted ? reValidateMode.isOnChange : mode.isOnChange) {
629
+ else if (isSubmitted ? effectiveReValidateMode.isOnChange : effectiveMode.isOnChange) {
615
630
  return isBlurEvent;
616
631
  }
617
632
  return true;
@@ -626,25 +641,13 @@ var updateFieldArrayRootError = (errors, error, name) => {
626
641
  return errors;
627
642
  };
628
643
 
629
- var isMessage = (value) => {
630
- // Support strings (existing functionality)
631
- if (isString(value)) {
632
- return true;
633
- }
634
- // Support React elements only (not primitives like null, undefined, numbers)
635
- if (React.isValidElement(value)) {
636
- return true;
637
- }
638
- return false;
639
- };
640
-
641
644
  function getValidateError(result, ref, type = 'validate') {
642
- if (isMessage(result) ||
643
- (Array.isArray(result) && result.every(isMessage)) ||
645
+ if (isString(result) ||
646
+ (Array.isArray(result) && result.every(isString)) ||
644
647
  (isBoolean(result) && !result)) {
645
648
  return {
646
649
  type,
647
- message: isMessage(result) ? result : '',
650
+ message: isString(result) ? result : '',
648
651
  ref,
649
652
  };
650
653
  }
@@ -666,16 +669,7 @@ var validateField = async (field, skippedFieldNames, formValues, validateAllFiel
666
669
  const inputRef = refs ? refs[0] : ref;
667
670
  const setCustomValidity = (message) => {
668
671
  if (shouldUseNativeValidation && inputRef.reportValidity) {
669
- if (isBoolean(message)) {
670
- inputRef.setCustomValidity('');
671
- }
672
- else if (typeof message === 'string') {
673
- inputRef.setCustomValidity(message || '');
674
- }
675
- else {
676
- // For ReactNode messages, convert to string or use empty string for native validation
677
- inputRef.setCustomValidity('');
678
- }
672
+ inputRef.setCustomValidity(isBoolean(message) ? '' : message || '');
679
673
  inputRef.reportValidity();
680
674
  }
681
675
  };
@@ -706,7 +700,7 @@ var validateField = async (field, skippedFieldNames, formValues, validateAllFiel
706
700
  (isBoolean(inputValue) && !inputValue) ||
707
701
  (isCheckBox && !getCheckboxValue(refs).isValid) ||
708
702
  (isRadio && !getRadioValue(refs).isValid))) {
709
- const { value, message } = isMessage(required)
703
+ const { value, message } = isString(required)
710
704
  ? { value: !!required, message: required }
711
705
  : getValueAndMessage(required);
712
706
  if (value) {
@@ -1356,6 +1350,16 @@ function createFormControl(props = {}) {
1356
1350
  };
1357
1351
  const validationModeBeforeSubmit = getValidationModes(_options.mode);
1358
1352
  const validationModeAfterSubmit = getValidationModes(_options.reValidateMode);
1353
+ // Extract field-level validation modes if they exist
1354
+ // Field-level modes take precedence over form-level modes, allowing
1355
+ // individual fields to override when they validate (mode) and when they
1356
+ // revalidate after form submission (reValidateMode)
1357
+ const fieldMode = (field === null || field === void 0 ? void 0 : field._f.mode)
1358
+ ? getValidationModes(field._f.mode)
1359
+ : undefined;
1360
+ const fieldReValidateMode = (field === null || field === void 0 ? void 0 : field._f.reValidateMode)
1361
+ ? getValidationModes(field._f.reValidateMode)
1362
+ : undefined;
1359
1363
  if (field) {
1360
1364
  // Check if field is disabled and should not process events
1361
1365
  const isFieldDisabled = isBoolean(field._f.disabled)
@@ -1414,7 +1418,7 @@ function createFormControl(props = {}) {
1414
1418
  !_options.resolver &&
1415
1419
  !get(_formState.errors, name) &&
1416
1420
  !field._f.deps) ||
1417
- skipValidation(isBlurEvent, get(_formState.touchedFields, name), _formState.isSubmitted, validationModeAfterSubmit, validationModeBeforeSubmit, isFocusEvent);
1421
+ skipValidation(isBlurEvent, get(_formState.touchedFields, name), _formState.isSubmitted, validationModeAfterSubmit, validationModeBeforeSubmit, isFocusEvent, fieldMode, fieldReValidateMode);
1418
1422
  const watched = isWatched(name, _names, isBlurEvent || isFocusEvent);
1419
1423
  set(_formValues, name, fieldValue);
1420
1424
  if (isBlurEvent) {