react-hook-form 7.82.0 → 7.83.0

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":"AAMA,OAAO,KAAK,EAcV,WAAW,EAkBX,YAAY,EAKZ,aAAa,EAYd,MAAM,UAAU,CAAC;AA0DlB,eAAO,MAAM,kBAAkB;;;;;;;;;;;;CAY9B,CAAC;AAEF,wBAAgB,iBAAiB,CAC/B,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,QAAQ,GAAG,GAAG,EACd,kBAAkB,GAAG,YAAY,EAEjC,KAAK,GAAE,YAAY,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,CAAM,GACnE,IAAI,CACL,aAAa,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,CAAC,EACzD,WAAW,CACZ,GAAG;IACF,WAAW,EAAE,IAAI,CACf,aAAa,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,CAAC,EACzD,WAAW,CACZ,CAAC;CACH,CA62DA"}
1
+ {"version":3,"file":"createFormControl.d.ts","sourceRoot":"","sources":["../../src/logic/createFormControl.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAcV,WAAW,EAkBX,YAAY,EAKZ,aAAa,EAYd,MAAM,UAAU,CAAC;AAuElB,eAAO,MAAM,kBAAkB;;;;;;;;;;;;CAY9B,CAAC;AAEF,wBAAgB,iBAAiB,CAC/B,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,QAAQ,GAAG,GAAG,EACd,kBAAkB,GAAG,YAAY,EAEjC,KAAK,GAAE,YAAY,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,CAAM,GACnE,IAAI,CACL,aAAa,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,CAAC,EACzD,WAAW,CACZ,GAAG;IACF,WAAW,EAAE,IAAI,CACf,aAAa,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,CAAC,EACzD,WAAW,CACZ,CAAC;CACH,CAo3DA"}
@@ -1 +1 @@
1
- {"version":3,"file":"getEventValue.d.ts","sourceRoot":"","sources":["../../src/logic/getEventValue.ts"],"names":[],"mappings":"yBAKgB,OAAO,OAAO;AAA9B,wBAKY"}
1
+ {"version":3,"file":"getEventValue.d.ts","sourceRoot":"","sources":["../../src/logic/getEventValue.ts"],"names":[],"mappings":"yBAMgB,OAAO,OAAO;AAA9B,wBAOY"}
@@ -1,7 +1,4 @@
1
1
  import type { ValidationRule } from '../types';
2
- declare const _default: (validationData?: ValidationRule) => {
3
- value: string | number | boolean | RegExp | undefined;
4
- message: string;
5
- };
2
+ declare const _default: (validationData?: ValidationRule) => import("..").ValidationValueMessage<import("..").ValidationValue>;
6
3
  export default _default;
7
4
  //# sourceMappingURL=getValueAndMessage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getValueAndMessage.d.ts","sourceRoot":"","sources":["../../src/logic/getValueAndMessage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;yBAI/B,iBAAiB,cAAc;;;;AAA/C,wBAMQ"}
1
+ {"version":3,"file":"getValueAndMessage.d.ts","sourceRoot":"","sources":["../../src/logic/getValueAndMessage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;yBAI/B,iBAAiB,cAAc;AAA/C,wBAMQ"}
@@ -419,7 +419,9 @@ function getDirtyFields(data, formValues, dirtyFieldsFromValues, fieldRefs) {
419
419
  var getEventValue = (event) => isObject(event) && event.target
420
420
  ? isCheckBoxInput(event.target)
421
421
  ? event.target.checked
422
- : event.target.value
422
+ : isFileInput(event.target)
423
+ ? event.target.files
424
+ : event.target.value
423
425
  : event;
424
426
 
425
427
  const defaultResult = {
@@ -886,6 +888,14 @@ const defaultOptions = {
886
888
  shouldFocusError: true,
887
889
  };
888
890
  const FORM_ERROR_TYPE = 'form';
891
+ const updateDirtyFields = (dirtyFields, nextDirtyFields) => {
892
+ for (const key in dirtyFields) {
893
+ if (!(key in nextDirtyFields)) {
894
+ delete dirtyFields[key];
895
+ }
896
+ }
897
+ Object.assign(dirtyFields, nextDirtyFields);
898
+ };
889
899
  const DEFAULT_FORM_STATE = {
890
900
  submitCount: 0,
891
901
  isDirty: false,
@@ -1128,7 +1138,7 @@ function createFormControl(props = {}) {
1128
1138
  }
1129
1139
  isPreviousDirty = !!get(_formState.dirtyFields, name);
1130
1140
  if (isCurrentFieldPristine !== _formState.isDirty) {
1131
- _formState.dirtyFields = getDirtyFields(_defaultValues, _formValues, undefined, _fields);
1141
+ updateDirtyFields(_formState.dirtyFields, getDirtyFields(_defaultValues, _formValues, undefined, _fields));
1132
1142
  }
1133
1143
  else {
1134
1144
  isCurrentFieldPristine
@@ -1685,8 +1695,9 @@ function createFormControl(props = {}) {
1685
1695
  });
1686
1696
  }
1687
1697
  else {
1698
+ _formState.errors = {};
1688
1699
  _subjects.state.next({
1689
- errors: {},
1700
+ errors: _formState.errors,
1690
1701
  });
1691
1702
  }
1692
1703
  };
@@ -1871,20 +1882,23 @@ function createFormControl(props = {}) {
1871
1882
  : fieldRef === field._f.ref) {
1872
1883
  return;
1873
1884
  }
1885
+ const newField = {
1886
+ ...field._f,
1887
+ };
1888
+ if (radioOrCheckbox) {
1889
+ newField.refs = [
1890
+ ...refs.filter(live),
1891
+ fieldRef,
1892
+ ...(Array.isArray(get(_defaultValues, name)) ? [{}] : []),
1893
+ ];
1894
+ newField.ref = { type: fieldRef.type, name };
1895
+ }
1896
+ else {
1897
+ newField.ref = fieldRef;
1898
+ delete newField.refs;
1899
+ }
1874
1900
  set(_fields, name, {
1875
- _f: {
1876
- ...field._f,
1877
- ...(radioOrCheckbox
1878
- ? {
1879
- refs: [
1880
- ...refs.filter(live),
1881
- fieldRef,
1882
- ...(Array.isArray(get(_defaultValues, name)) ? [{}] : []),
1883
- ],
1884
- ref: { type: fieldRef.type, name },
1885
- }
1886
- : { ref: fieldRef }),
1887
- },
1901
+ _f: newField,
1888
1902
  });
1889
1903
  updateValidAndValue(name, false, undefined, fieldRef);
1890
1904
  }