react-hook-form 7.76.0 → 7.77.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":"AAOA,OAAO,KAAK,EAaV,WAAW,EAiBX,YAAY,EAIZ,aAAa,EAYd,MAAM,UAAU,CAAC;AAuDlB,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,CAssDA"}
1
+ {"version":3,"file":"createFormControl.d.ts","sourceRoot":"","sources":["../../src/logic/createFormControl.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAcV,WAAW,EAiBX,YAAY,EAKZ,aAAa,EAYd,MAAM,UAAU,CAAC;AAuDlB,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,CAsvDA"}
@@ -1,4 +1,3 @@
1
- import appendErrors from './appendErrors';
2
- import { createFormControl } from './createFormControl';
3
- export { appendErrors, createFormControl };
1
+ export { default as appendErrors } from './appendErrors';
2
+ export { createFormControl } from './createFormControl';
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logic/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logic/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -1,4 +1,4 @@
1
1
  import type { InternalFieldName } from '../types';
2
- declare const _default: (names: Set<InternalFieldName>, name: InternalFieldName) => string[];
2
+ declare const _default: (names: Set<InternalFieldName>, name: InternalFieldName) => boolean;
3
3
  export default _default;
4
- //# sourceMappingURL=getFieldArrayParentNames.d.ts.map
4
+ //# sourceMappingURL=isNameInFieldArray.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isNameInFieldArray.d.ts","sourceRoot":"","sources":["../../src/logic/isNameInFieldArray.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;yBAElC,OAAO,GAAG,CAAC,iBAAiB,CAAC,EAAE,MAAM,iBAAiB;AAAtE,wBAMM"}
@@ -1 +1 @@
1
- {"version":3,"file":"isWatched.d.ts","sourceRoot":"","sources":["../../src/logic/isWatched.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;yBAGvD,MAAM,iBAAiB,EACvB,QAAQ,KAAK,EACb,cAAc,OAAO;AAHvB,wBAYO"}
1
+ {"version":3,"file":"isWatched.d.ts","sourceRoot":"","sources":["../../src/logic/isWatched.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;yBAGvD,MAAM,iBAAiB,EACvB,QAAQ,KAAK,EACb,cAAc,OAAO;AAHvB,wBAQ6E"}
@@ -1,7 +1,4 @@
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>) => boolean;
2
+ declare const _default: (isBlurEvent: boolean, isTouched: boolean, isSubmitted: boolean, reValidateMode: Pick<ValidationModeFlags, "isOnBlur" | "isOnChange">, mode: Partial<ValidationModeFlags>) => boolean;
6
3
  export default _default;
7
4
  //# 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;AARpC,wBAoBE"}
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,IAAI,CAAC,mBAAmB,EAAE,UAAU,GAAG,YAAY,CAAC,EACpE,MAAM,OAAO,CAAC,mBAAmB,CAAC;AALpC,wBAiBE"}
@@ -1 +1 @@
1
- {"version":3,"file":"updateFieldArrayRootError.d.ts","sourceRoot":"","sources":["../../src/logic/updateFieldArrayRootError.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,WAAW,EACX,iBAAiB,EAClB,MAAM,UAAU,CAAC;yBAKF,CAAC,SAAS,WAAW,GAAG,WAAW,EACjD,QAAQ,WAAW,CAAC,CAAC,CAAC,EACtB,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,EAC1C,MAAM,iBAAiB,KACtB,WAAW,CAAC,CAAC,CAAC;AAJjB,wBASE"}
1
+ {"version":3,"file":"updateFieldArrayRootError.d.ts","sourceRoot":"","sources":["../../src/logic/updateFieldArrayRootError.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,WAAW,EACX,iBAAiB,EAClB,MAAM,UAAU,CAAC;yBAIF,CAAC,SAAS,WAAW,GAAG,WAAW,EACjD,QAAQ,WAAW,CAAC,CAAC,CAAC,EACtB,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,EAC1C,MAAM,iBAAiB,KACtB,WAAW,CAAC,CAAC,CAAC;AAJjB,wBAUE"}
@@ -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;yBAqBI,CAAC,SAAS,WAAW,EACzC,OAAO,KAAK,EACZ,oBAAoB,eAAe,EACnC,YAAY,CAAC,EACb,0BAA0B,OAAO,EACjC,4BAA4B,OAAO,EACnC,eAAe,OAAO,KACrB,OAAO,CAAC,mBAAmB,CAAC;AAP/B,wBA8PE"}
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,oBAAoB,eAAe,EACnC,YAAY,CAAC,EACb,0BAA0B,OAAO,EACjC,4BAA4B,OAAO,EACnC,eAAe,OAAO,KACrB,OAAO,CAAC,mBAAmB,CAAC;AAP/B,wBA6PE"}
@@ -33,6 +33,7 @@ const INPUT_VALIDATION_RULES = {
33
33
  };
34
34
  const FORM_ERROR_TYPE = 'form';
35
35
  const ROOT_ERROR_TYPE = 'root';
36
+ const PROTOTYPE_KEYWORDS = ['__proto__', 'constructor', 'prototype'];
36
37
 
37
38
  var isDateObject = (value) => value instanceof Date;
38
39
 
@@ -171,13 +172,16 @@ var isKey = (value) => /^\w*$/.test(value);
171
172
 
172
173
  var isUndefined = (val) => val === undefined;
173
174
 
174
- var stringToPath = (input) => compact(input.replace(/["|']|\]/g, '').split(/\.|\[/));
175
+ var stringToPath = (input) => input.split(/[.[\]'"]/g).filter(Boolean);
175
176
 
176
177
  var get = (object, path, defaultValue) => {
177
178
  if (!path || !isObject(object)) {
178
179
  return defaultValue;
179
180
  }
180
181
  const paths = isKey(path) ? [path] : stringToPath(path);
182
+ if (paths.some((key) => PROTOTYPE_KEYWORDS.includes(key))) {
183
+ return defaultValue;
184
+ }
181
185
  const result = paths.reduce((result, key) => {
182
186
  return isNullOrUndefined(result) ? undefined : result[key];
183
187
  }, object);
@@ -234,7 +238,7 @@ var set = (object, path, value) => {
234
238
  ? []
235
239
  : {};
236
240
  }
237
- if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
241
+ if (PROTOTYPE_KEYWORDS.includes(key)) {
238
242
  return;
239
243
  }
240
244
  object[key] = newValue;
@@ -376,16 +380,6 @@ var getEventValue = (event) => isObject(event) && event.target
376
380
  : event.target.value
377
381
  : event;
378
382
 
379
- var getFieldArrayParentNames = (names, name) => {
380
- const parts = name.split('.');
381
- const matches = [];
382
- let prefix = parts[0];
383
- for (let i = 1; i < parts.length; prefix += '.' + parts[i++]) {
384
- !isNaN(+parts[i]) && names.has(prefix) && matches.push(prefix);
385
- }
386
- return matches;
387
- };
388
-
389
383
  const defaultResult = {
390
384
  value: false,
391
385
  isValid: false,
@@ -506,11 +500,14 @@ var hasValidation = (options) => options.mount &&
506
500
  options.pattern ||
507
501
  options.validate);
508
502
 
503
+ var isNameInFieldArray = (names, name) => name
504
+ .split('.')
505
+ .some((part, index, arr) => !isNaN(Number(part)) && names.has(arr.slice(0, index).join('.')));
506
+
509
507
  var isWatched = (name, _names, isBlurEvent) => !isBlurEvent &&
510
508
  (_names.watchAll ||
511
509
  _names.watch.has(name) ||
512
- [..._names.watch].some((watchName) => name.startsWith(watchName) &&
513
- /^\.\w+/.test(name.slice(watchName.length))));
510
+ [..._names.watch].some((watchName) => name.startsWith(`${watchName}.`)));
514
511
 
515
512
  const iterateFieldsByAction = (fields, action, fieldsNames, abortEarly) => {
516
513
  for (const key of fieldsNames || Object.keys(fields)) {
@@ -613,7 +610,8 @@ var skipValidation = (isBlurEvent, isTouched, isSubmitted, reValidateMode, mode)
613
610
  var unsetEmptyArray = (ref, name) => !compact(get(ref, name)).length && unset(ref, name);
614
611
 
615
612
  var updateFieldArrayRootError = (errors, error, name) => {
616
- const fieldArrayErrors = convertToArrayPayload(get(errors, name));
613
+ const existingErrors = get(errors, name);
614
+ const fieldArrayErrors = Array.isArray(existingErrors) ? existingErrors : [];
617
615
  set(fieldArrayErrors, ROOT_ERROR_TYPE, error[name]);
618
616
  set(errors, name, fieldArrayErrors);
619
617
  return errors;
@@ -660,8 +658,7 @@ var validateField = async (field, disabledFieldNames, formValues, validateAllFie
660
658
  isUndefined(inputValue)) ||
661
659
  (isHTMLElement(ref) && ref.value === '') ||
662
660
  inputValue === '' ||
663
- (Array.isArray(inputValue) && !inputValue.length) ||
664
- (valueAsNumber && typeof inputValue === 'number' && isNaN(inputValue));
661
+ (Array.isArray(inputValue) && !inputValue.length);
665
662
  const appendErrorsCurry = appendErrors.bind(null, name, validateAllFieldCriteria, error);
666
663
  const getMinMaxMessage = (exceedMax, maxLengthMessage, minLengthMessage, maxType = INPUT_VALIDATION_RULES.maxLength, minType = INPUT_VALIDATION_RULES.minLength) => {
667
664
  const message = exceedMax ? maxLengthMessage : minLengthMessage;
@@ -1129,7 +1126,9 @@ function createFormControl(props = {}) {
1129
1126
  for (const name of names) {
1130
1127
  const error = get(errors, name);
1131
1128
  error
1132
- ? _names.array.has(name) && isObject(error)
1129
+ ? _names.array.has(name) &&
1130
+ isObject(error) &&
1131
+ !Object.keys(error).some((key) => !Number.isNaN(Number(key)))
1133
1132
  ? updateFieldArrayRootError(_formState.errors, { [name]: error }, name)
1134
1133
  : set(_formState.errors, name, error)
1135
1134
  : unset(_formState.errors, name);
@@ -1259,7 +1258,7 @@ function createFormControl(props = {}) {
1259
1258
  : defaultValue),
1260
1259
  }, isGlobal, defaultValue);
1261
1260
  const _getFieldArray = (name) => compact(get(_state.mount ? _formValues : _defaultValues, name, _options.shouldUnregister ? get(_defaultValues, name, []) : []));
1262
- const setFieldValue = (name, value, options = {}) => {
1261
+ const setFieldValue = (name, value, options = {}, skipClone = false) => {
1263
1262
  const field = get(_fields, name);
1264
1263
  let fieldValue = value;
1265
1264
  if (field) {
@@ -1300,7 +1299,7 @@ function createFormControl(props = {}) {
1300
1299
  if (!fieldReference.ref.type) {
1301
1300
  _subjects.state.next({
1302
1301
  name,
1303
- values: cloneObject(_formValues),
1302
+ values: skipClone ? _formValues : cloneObject(_formValues),
1304
1303
  });
1305
1304
  }
1306
1305
  }
@@ -1310,7 +1309,7 @@ function createFormControl(props = {}) {
1310
1309
  updateTouchAndDirty(name, fieldValue, options.shouldTouch, options.shouldDirty, true);
1311
1310
  options.shouldValidate && trigger(name);
1312
1311
  };
1313
- const setFieldValues = (name, value, options) => {
1312
+ const setFieldValues = (name, value, options, skipClone = false) => {
1314
1313
  for (const fieldKey in value) {
1315
1314
  if (!value.hasOwnProperty(fieldKey)) {
1316
1315
  return;
@@ -1322,14 +1321,14 @@ function createFormControl(props = {}) {
1322
1321
  isObject(fieldValue) ||
1323
1322
  (field && !field._f)) &&
1324
1323
  !isDateObject(fieldValue)
1325
- ? setFieldValues(fieldName, fieldValue, options)
1326
- : setFieldValue(fieldName, fieldValue, options);
1324
+ ? setFieldValues(fieldName, fieldValue, options, skipClone)
1325
+ : setFieldValue(fieldName, fieldValue, options, skipClone);
1327
1326
  }
1328
1327
  };
1329
- const setValue = (name, value, options = {}) => {
1328
+ const _setValue = (name, value, options, skipClone) => {
1330
1329
  const field = get(_fields, name);
1331
1330
  const isFieldArray = _names.array.has(name);
1332
- const cloneValue = cloneObject(value);
1331
+ const cloneValue = skipClone ? value : cloneObject(value);
1333
1332
  const previousValue = get(_formValues, name);
1334
1333
  const isValueUnchanged = deepEqual(previousValue, cloneValue);
1335
1334
  if (!isValueUnchanged) {
@@ -1338,7 +1337,7 @@ function createFormControl(props = {}) {
1338
1337
  if (isFieldArray) {
1339
1338
  _subjects.array.next({
1340
1339
  name,
1341
- values: cloneObject(_formValues),
1340
+ values: skipClone ? _formValues : cloneObject(_formValues),
1342
1341
  });
1343
1342
  if ((_proxyFormState.isDirty ||
1344
1343
  _proxyFormState.dirtyFields ||
@@ -1357,20 +1356,15 @@ function createFormControl(props = {}) {
1357
1356
  const isEmpty = (Array.isArray(cloneValue) && !cloneValue.length) ||
1358
1357
  isEmptyObject(cloneValue);
1359
1358
  if (!field || field._f || isNullOrUndefined(cloneValue) || isEmpty) {
1360
- setFieldValue(name, cloneValue, options);
1359
+ setFieldValue(name, cloneValue, options, skipClone);
1361
1360
  }
1362
1361
  else {
1363
- setFieldValues(name, cloneValue, options);
1362
+ setFieldValues(name, cloneValue, options, skipClone);
1364
1363
  }
1365
1364
  }
1366
1365
  if (!isValueUnchanged) {
1367
1366
  const watched = isWatched(name, _names);
1368
- const values = cloneObject(_formValues);
1369
- if (!isFieldArray) {
1370
- for (const arrayName of getFieldArrayParentNames(_names.array, name)) {
1371
- _subjects.array.next({ name: arrayName, values });
1372
- }
1373
- }
1367
+ const values = skipClone ? _formValues : cloneObject(_formValues);
1374
1368
  _subjects.state.next({
1375
1369
  ...(watched && _formState),
1376
1370
  name: _state.mount || watched ? name : undefined,
@@ -1378,7 +1372,8 @@ function createFormControl(props = {}) {
1378
1372
  });
1379
1373
  }
1380
1374
  };
1381
- const setValues = (formValues) => {
1375
+ const setValue = (name, value, options = {}) => _setValue(name, value, options, false);
1376
+ const setValues = (formValues, options = {}) => {
1382
1377
  const updatedFormValues = isFunction(formValues)
1383
1378
  ? formValues(_formValues)
1384
1379
  : formValues;
@@ -1388,9 +1383,17 @@ function createFormControl(props = {}) {
1388
1383
  ...updatedFormValues,
1389
1384
  };
1390
1385
  for (const fieldName of _names.mount) {
1391
- setValue(fieldName, get(updatedFormValues, fieldName));
1386
+ _setValue(fieldName, get(updatedFormValues, fieldName), options, true);
1387
+ }
1388
+ _subjects.state.next({
1389
+ ..._formState,
1390
+ name: undefined,
1391
+ type: undefined,
1392
+ values: _formValues,
1393
+ });
1394
+ if (options.shouldValidate) {
1395
+ _setValid();
1392
1396
  }
1393
- _subjects.state.next({ ..._formState, values: _formValues });
1394
1397
  }
1395
1398
  };
1396
1399
  const onChange = async (event) => {
@@ -1760,8 +1763,7 @@ function createFormControl(props = {}) {
1760
1763
  field._f.mount = false;
1761
1764
  }
1762
1765
  (_options.shouldUnregister || options.shouldUnregister) &&
1763
- !(getFieldArrayParentNames(_names.array, name).length &&
1764
- _state.action) &&
1766
+ !(isNameInFieldArray(_names.array, name) && _state.action) &&
1765
1767
  _names.unMount.add(name);
1766
1768
  }
1767
1769
  },
@@ -1873,7 +1875,7 @@ function createFormControl(props = {}) {
1873
1875
  const updatedValues = formValues ? cloneObject(formValues) : _defaultValues;
1874
1876
  const cloneUpdatedValues = cloneObject(updatedValues);
1875
1877
  const isEmptyResetValues = isEmptyObject(formValues);
1876
- const values = isEmptyResetValues ? _defaultValues : cloneUpdatedValues;
1878
+ const values = cloneUpdatedValues;
1877
1879
  if (!keepStateOptions.keepDefaultValues) {
1878
1880
  _defaultValues = updatedValues;
1879
1881
  }
@@ -1922,11 +1924,19 @@ function createFormControl(props = {}) {
1922
1924
  _fields = {};
1923
1925
  }
1924
1926
  }
1925
- _formValues = _options.shouldUnregister
1926
- ? keepStateOptions.keepDefaultValues
1927
+ if (_options.shouldUnregister) {
1928
+ _formValues = keepStateOptions.keepDefaultValues
1927
1929
  ? cloneObject(_defaultValues)
1928
- : {}
1929
- : cloneObject(values);
1930
+ : {};
1931
+ if (keepStateOptions.keepFieldsRef) {
1932
+ for (const fieldName of _names.mount) {
1933
+ set(_formValues, fieldName, get(values, fieldName));
1934
+ }
1935
+ }
1936
+ }
1937
+ else {
1938
+ _formValues = cloneObject(values);
1939
+ }
1930
1940
  _subjects.array.next({
1931
1941
  values: { ...values },
1932
1942
  });
@@ -1966,8 +1976,10 @@ function createFormControl(props = {}) {
1966
1976
  ? false
1967
1977
  : keepStateOptions.keepDirty
1968
1978
  ? _formState.isDirty
1969
- : !!(keepStateOptions.keepDefaultValues &&
1970
- !deepEqual(formValues, _defaultValues)),
1979
+ : keepStateOptions.keepValues
1980
+ ? _getDirty()
1981
+ : !!(keepStateOptions.keepDefaultValues &&
1982
+ !deepEqual(formValues, _defaultValues)),
1971
1983
  isSubmitted: keepStateOptions.keepIsSubmitted
1972
1984
  ? _formState.isSubmitted
1973
1985
  : false,
@@ -2028,6 +2040,21 @@ function createFormControl(props = {}) {
2028
2040
  isLoading: false,
2029
2041
  });
2030
2042
  });
2043
+ const resetDefaultValues = (values, options = {}) => {
2044
+ _defaultValues = cloneObject(values);
2045
+ if (!options.keepDirty) {
2046
+ const newDirtyFields = getDirtyFields(_defaultValues, _formValues);
2047
+ _formState.dirtyFields = newDirtyFields;
2048
+ _formState.isDirty = !isEmptyObject(newDirtyFields);
2049
+ }
2050
+ if (!options.keepIsValid) {
2051
+ _setValid();
2052
+ }
2053
+ _subjects.state.next({
2054
+ ..._formState,
2055
+ defaultValues: _defaultValues,
2056
+ });
2057
+ };
2031
2058
  const methods = {
2032
2059
  control: {
2033
2060
  register,
@@ -2096,6 +2123,7 @@ function createFormControl(props = {}) {
2096
2123
  getValues,
2097
2124
  reset,
2098
2125
  resetField,
2126
+ resetDefaultValues,
2099
2127
  clearErrors,
2100
2128
  unregister,
2101
2129
  setError,