@depup/react-hook-form 7.85.0-depup.0 → 7.86.0-depup.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.
Files changed (45) hide show
  1. package/README.md +2 -2
  2. package/changes.json +1 -1
  3. package/dist/controller.d.ts +1 -2
  4. package/dist/controller.d.ts.map +1 -1
  5. package/dist/form.d.ts +1 -2
  6. package/dist/form.d.ts.map +1 -1
  7. package/dist/{formStateSubscribe.d.ts → formState.d.ts} +1 -1
  8. package/dist/formState.d.ts.map +1 -0
  9. package/dist/index.cjs.js +1 -1
  10. package/dist/index.cjs.js.map +1 -1
  11. package/dist/index.d.ts +2 -2
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.esm.mjs +128 -82
  14. package/dist/index.esm.mjs.map +1 -1
  15. package/dist/index.umd.js +1 -1
  16. package/dist/index.umd.js.map +1 -1
  17. package/dist/logic/createFormControl.d.ts.map +1 -1
  18. package/dist/logic/generateId.d.ts.map +1 -1
  19. package/dist/logic/getCheckboxValue.d.ts.map +1 -1
  20. package/dist/logic/getFieldArrayItemNames.d.ts +4 -0
  21. package/dist/logic/getFieldArrayItemNames.d.ts.map +1 -0
  22. package/dist/logic/getProxyFormState.d.ts +1 -1
  23. package/dist/logic/getProxyFormState.d.ts.map +1 -1
  24. package/dist/logic/hasValidation.d.ts +1 -1
  25. package/dist/logic/hasValidation.d.ts.map +1 -1
  26. package/dist/logic/validateField.d.ts.map +1 -1
  27. package/dist/types/form.d.ts +47 -2
  28. package/dist/types/form.d.ts.map +1 -1
  29. package/dist/useFieldArray.d.ts.map +1 -1
  30. package/dist/useFormContext.d.ts +1 -1
  31. package/dist/useFormContext.d.ts.map +1 -1
  32. package/dist/utils/cloneObject.d.ts.map +1 -1
  33. package/dist/utils/deepEqual.d.ts +1 -1
  34. package/dist/utils/deepEqual.d.ts.map +1 -1
  35. package/dist/utils/flatten.d.ts.map +1 -1
  36. package/dist/utils/has.d.ts +3 -0
  37. package/dist/utils/has.d.ts.map +1 -0
  38. package/dist/utils/json.d.ts +2 -2
  39. package/dist/utils/json.d.ts.map +1 -1
  40. package/package.json +3 -3
  41. package/dist/formStateSubscribe.d.ts.map +0 -1
  42. package/dist/index.react-server.d.ts +0 -3
  43. package/dist/index.react-server.d.ts.map +0 -1
  44. package/dist/react-server.esm.mjs +0 -2367
  45. package/dist/react-server.esm.mjs.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  export * from './controller';
2
2
  export { FieldArray } from './fieldArray';
3
3
  export * from './form';
4
- export type { FormStateProps, FormStateSubscribeProps, } from './formStateSubscribe';
5
- export { FormState, FormStateSubscribe } from './formStateSubscribe';
4
+ export type { FormStateProps, FormStateSubscribeProps } from './formState';
5
+ export { FormState, FormStateSubscribe } from './formState';
6
6
  export * from './logic';
7
7
  export * from './types';
8
8
  export * from './useController';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,cAAc,QAAQ,CAAC;AACvB,YAAY,EACV,cAAc,EACd,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACrE,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,cAAc,QAAQ,CAAC;AACvB,YAAY,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC5D,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
@@ -26,16 +26,14 @@ var isNameInFieldArray = (names, name) => name
26
26
  .split('.')
27
27
  .some((part, index, arr) => !isNaN(Number(part)) && names.has(arr.slice(0, index).join('.')));
28
28
 
29
- var isPlainObject = (tempObject) => {
30
- const prototypeCopy = tempObject.constructor && tempObject.constructor.prototype;
31
- return (isObject(prototypeCopy) && prototypeCopy.hasOwnProperty('isPrototypeOf'));
32
- };
33
-
34
29
  var isWeb = typeof window !== 'undefined' &&
35
30
  typeof window.HTMLElement !== 'undefined' &&
36
31
  typeof document !== 'undefined';
37
32
 
38
33
  function cloneObject(data) {
34
+ if (data === null || typeof data !== 'object') {
35
+ return data;
36
+ }
39
37
  if (data instanceof Date) {
40
38
  return new Date(data);
41
39
  }
@@ -44,7 +42,7 @@ function cloneObject(data) {
44
42
  return data;
45
43
  }
46
44
  const isArray = Array.isArray(data);
47
- if (!isArray && !(isObject(data) && isPlainObject(data))) {
45
+ if (!isArray && data.constructor !== Object) {
48
46
  return data;
49
47
  }
50
48
  const copy = isArray ? [] : Object.create(Object.getPrototypeOf(data));
@@ -170,6 +168,11 @@ const useIsomorphicLayoutEffect = isWeb
170
168
  ? React.useLayoutEffect
171
169
  : React.useEffect;
172
170
 
171
+ var isPlainObject = (tempObject) => {
172
+ const prototypeCopy = tempObject.constructor && tempObject.constructor.prototype;
173
+ return (isObject(prototypeCopy) && prototypeCopy.hasOwnProperty('isPrototypeOf'));
174
+ };
175
+
173
176
  var isPrimitive = (value) => isNullOrUndefined(value) || !isObjectType(value);
174
177
 
175
178
  const isEmptyObjectWithCustomPrototype = (object, keys) => keys.length === 0 && !Array.isArray(object) && !isPlainObject(object);
@@ -427,17 +430,17 @@ function useWatch(props) {
427
430
  // Optimize: Check control reference first before expensive deepEqual
428
431
  const controlChanged = _prevControl.current !== control;
429
432
  const prevName = _prevName.current;
430
- // Cache the computed output to avoid duplicate calls within the same render
431
- // We include shouldReturnImmediate in deps to ensure proper recomputation
432
- const computedOutput = React.useMemo(() => {
433
+ // `null`/`undefined` are valid watched values, so a boolean flag (rather
434
+ // than a sentinel return value) decides whether to return the freshly
435
+ // computed output instead of the possibly-stale state value.
436
+ const shouldReturnImmediate = React.useMemo(() => {
433
437
  if (disabled) {
434
- return null;
438
+ return false;
435
439
  }
436
440
  const nameChanged = !controlChanged && !deepEqual(prevName, name);
437
- const shouldReturnImmediate = controlChanged || nameChanged;
438
- return shouldReturnImmediate ? getCurrentOutput() : null;
439
- }, [disabled, controlChanged, name, prevName, getCurrentOutput]);
440
- return computedOutput !== null ? computedOutput : value;
441
+ return controlChanged || nameChanged;
442
+ }, [disabled, controlChanged, name, prevName]);
443
+ return shouldReturnImmediate ? getCurrentOutput() : value;
441
444
  }
442
445
 
443
446
  /**
@@ -653,16 +656,12 @@ function useController(props) {
653
656
  */
654
657
  const Controller = (props) => props.render(useController(props));
655
658
 
656
- var generateId = () => {
657
- if (typeof crypto !== 'undefined' && crypto.randomUUID) {
658
- return crypto.randomUUID();
659
- }
660
- const d = typeof performance === 'undefined' ? Date.now() : performance.now() * 1000;
661
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
662
- const r = ((Math.random() * 16 + d) % 16) | 0;
663
- return (c == 'x' ? r : (r & 0x3) | 0x8).toString(16);
659
+ var generateId = () => typeof crypto !== 'undefined' && crypto.randomUUID
660
+ ? crypto.randomUUID()
661
+ : 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
662
+ const r = (Math.random() * 16) | 0;
663
+ return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16);
664
664
  });
665
- };
666
665
 
667
666
  var getFocusFieldName = (name, index, options = {}) => options.shouldFocus || isUndefined(options.shouldFocus)
668
667
  ? options.focusName ||
@@ -759,23 +758,25 @@ const defaultResult = {
759
758
  };
760
759
  const validResult = { value: true, isValid: true };
761
760
  var getCheckboxValue = (options) => {
762
- if (Array.isArray(options)) {
763
- if (options.length > 1) {
764
- const values = options
765
- .filter((option) => option && option.checked && !option.disabled)
766
- .map((option) => option.value);
767
- return { value: values, isValid: !!values.length };
768
- }
769
- return options[0].checked && !options[0].disabled
770
- ? // @ts-expect-error expected to work in the browser
771
- options[0].attributes && !isUndefined(options[0].attributes.value)
772
- ? isUndefined(options[0].value) || options[0].value === ''
773
- ? validResult
774
- : { value: options[0].value, isValid: true }
775
- : validResult
776
- : defaultResult;
777
- }
778
- return defaultResult;
761
+ if (!Array.isArray(options)) {
762
+ return defaultResult;
763
+ }
764
+ if (options.length > 1) {
765
+ const values = options
766
+ .filter((option) => option && option.checked && !option.disabled)
767
+ .map((option) => option.value);
768
+ return { value: values, isValid: !!values.length };
769
+ }
770
+ const option = options[0];
771
+ if (!option || !option.checked || option.disabled) {
772
+ return defaultResult;
773
+ }
774
+ if (!option.attributes || !('value' in option.attributes)) {
775
+ return validResult;
776
+ }
777
+ return isUndefined(option.value) || option.value === ''
778
+ ? validResult
779
+ : { value: option.value, isValid: true };
779
780
  };
780
781
 
781
782
  const defaultReturn = {
@@ -993,7 +994,8 @@ var validateField = async (field, disabledFieldNames, formValues, validateAllFie
993
994
  }
994
995
  }
995
996
  }
996
- setCustomValidity(true);
997
+ const fieldError = error[name];
998
+ setCustomValidity(fieldError ? fieldError.message : true);
997
999
  return error;
998
1000
  };
999
1001
 
@@ -1272,8 +1274,8 @@ function useFieldArray(props) {
1272
1274
  setFields([...updatedFieldArrayValues]);
1273
1275
  control._setFieldArray(name, updatedFieldArrayValues, updateAt, {
1274
1276
  argA: index,
1275
- argB: updateValue,
1276
- }, true, false);
1277
+ argB: fillEmptyArray(value),
1278
+ });
1277
1279
  };
1278
1280
  const replace = (value) => {
1279
1281
  if (disabled) {
@@ -1333,10 +1335,7 @@ function useFieldArray(props) {
1333
1335
  }
1334
1336
  else {
1335
1337
  const field = get(control._fields, name);
1336
- if (field &&
1337
- field._f &&
1338
- !(getValidationModes(control._options.reValidateMode).isOnSubmit &&
1339
- getValidationModes(control._options.mode).isOnSubmit)) {
1338
+ if (field && field._f) {
1340
1339
  validateField(field, control._names.disabled, control._formValues, control._options.criteriaMode === VALIDATION_MODE.all, control._options.shouldUseNativeValidation, true).then((error) => !isEmptyObject(error) &&
1341
1340
  control._subjects.state.next({
1342
1341
  errors: updateFieldArrayRootError(control._formState.errors, error, name),
@@ -1454,12 +1453,15 @@ function useFieldArray(props) {
1454
1453
  */
1455
1454
  const FieldArray = (props) => props.render(useFieldArray(props));
1456
1455
 
1456
+ const isFileLike = (value) => (typeof Blob !== 'undefined' && value instanceof Blob) ||
1457
+ (typeof File !== 'undefined' && value instanceof File);
1457
1458
  const flatten = (obj) => {
1458
1459
  const output = {};
1459
1460
  for (const key of Object.keys(obj)) {
1460
1461
  if (isObjectType(obj[key]) &&
1461
1462
  obj[key] !== null &&
1462
- !isDateObject(obj[key])) {
1463
+ !isDateObject(obj[key]) &&
1464
+ !isFileLike(obj[key])) {
1463
1465
  const nested = flatten(obj[key]);
1464
1466
  for (const nestedKey of Object.keys(nested)) {
1465
1467
  output[`${key}.${nestedKey}`] = nested[nestedKey];
@@ -1555,10 +1557,11 @@ const useFormContext = () => React.useContext(HookFormContext);
1555
1557
  * }
1556
1558
  * ```
1557
1559
  */
1558
- const FormProvider = ({ children, watch, getValues, getFieldState, setError, clearErrors, setValue, setValues, trigger, formState, resetField, reset, resetDefaultValues, handleSubmit, unregister, control, register, setFocus, subscribe, }) => {
1560
+ const FormProvider = ({ children, watch, getValues, getErrors, getFieldState, setError, clearErrors, setValue, setValues, trigger, formState, resetField, reset, resetDefaultValues, handleSubmit, unregister, control, register, setFocus, subscribe, }) => {
1559
1561
  const memoizedValue = React.useMemo(() => ({
1560
1562
  watch,
1561
1563
  getValues,
1564
+ getErrors,
1562
1565
  getFieldState,
1563
1566
  setError,
1564
1567
  clearErrors,
@@ -1579,6 +1582,7 @@ const FormProvider = ({ children, watch, getValues, getFieldState, setError, cle
1579
1582
  clearErrors,
1580
1583
  control,
1581
1584
  formState,
1585
+ getErrors,
1582
1586
  getFieldState,
1583
1587
  getValues,
1584
1588
  handleSubmit,
@@ -1766,6 +1770,24 @@ function extractFormValues(fieldsState, formValues) {
1766
1770
  return values;
1767
1771
  }
1768
1772
 
1773
+ const hasOwn = (value, key) => value !== null &&
1774
+ isObjectType(value) &&
1775
+ Object.prototype.hasOwnProperty.call(value, key);
1776
+ var has = (object, path) => {
1777
+ if (!path) {
1778
+ return false;
1779
+ }
1780
+ let result = object;
1781
+ for (const key of isKey(path) ? [path] : stringToPath(path)) {
1782
+ if (!hasOwn(result, key)) {
1783
+ // `get` also resolves a path held as a single literal key, eg `{ 'a.b': 1 }`
1784
+ return hasOwn(object, path);
1785
+ }
1786
+ result = result[key];
1787
+ }
1788
+ return true;
1789
+ };
1790
+
1769
1791
  var isMultipleSelect = (element) => element.type === `select-multiple`;
1770
1792
 
1771
1793
  var isRadioOrCheckbox = (ref) => isRadioInput(ref) || isCheckBoxInput(ref);
@@ -1865,6 +1887,18 @@ function getDirtyFields(data, formValues, dirtyFieldsFromValues, fieldRefs) {
1865
1887
  return dirtyFieldsFromValues;
1866
1888
  }
1867
1889
 
1890
+ var getFieldArrayItemNames = (names, name) => {
1891
+ const segments = name.split('.');
1892
+ const matches = [];
1893
+ let prefix = segments[0];
1894
+ for (let i = 1; i < segments.length; prefix += '.' + segments[i++]) {
1895
+ if (!isNaN(+segments[i]) && names.has(prefix)) {
1896
+ matches.push(`${prefix}.${segments[i]}`);
1897
+ }
1898
+ }
1899
+ return matches;
1900
+ };
1901
+
1868
1902
  var getFieldValueAs = (value, { valueAsNumber, valueAsDate, setValueAs }) => isUndefined(value)
1869
1903
  ? value
1870
1904
  : valueAsNumber
@@ -1940,10 +1974,11 @@ var hasPromiseValidation = (fieldReference) => {
1940
1974
 
1941
1975
  var hasValidation = (options) => options.mount &&
1942
1976
  (options.required ||
1943
- options.min ||
1944
- options.max ||
1945
- options.maxLength ||
1946
- options.minLength ||
1977
+ (!isUndefined(options.required) && options.required !== false) ||
1978
+ !isUndefined(options.min) ||
1979
+ !isUndefined(options.max) ||
1980
+ !isUndefined(options.maxLength) ||
1981
+ !isUndefined(options.minLength) ||
1947
1982
  options.pattern ||
1948
1983
  options.validate);
1949
1984
 
@@ -2147,7 +2182,7 @@ function createFormControl(props = {}) {
2147
2182
  _proxyFormState.validatingFields ||
2148
2183
  _proxySubscribeFormState.isValidating ||
2149
2184
  _proxySubscribeFormState.validatingFields)) {
2150
- (names || Array.from(_names.mount)).forEach((name) => {
2185
+ (names || _names.mount).forEach((name) => {
2151
2186
  if (name) {
2152
2187
  isValidating
2153
2188
  ? set(_formState.validatingFields, name, isValidating)
@@ -2166,17 +2201,16 @@ function createFormControl(props = {}) {
2166
2201
  const _setFieldArray = (name, values = [], method, args, shouldSetValues = true, shouldUpdateFieldsAndState = true) => {
2167
2202
  if (args && method && !_options.disabled) {
2168
2203
  _state.action = true;
2204
+ const fields = get(_fields, name);
2169
2205
  if (!_state.actionArrayLengths.has(name)) {
2170
- const preActionFields = get(_fields, name);
2171
- _state.actionArrayLengths.set(name, Array.isArray(preActionFields) ? preActionFields.length : 0);
2206
+ _state.actionArrayLengths.set(name, Array.isArray(fields) ? fields.length : 0);
2172
2207
  }
2173
- if (shouldUpdateFieldsAndState && Array.isArray(get(_fields, name))) {
2174
- const fieldValues = method(get(_fields, name), args.argA, args.argB);
2208
+ if (shouldUpdateFieldsAndState && Array.isArray(fields)) {
2209
+ const fieldValues = method(fields, args.argA, args.argB);
2175
2210
  shouldSetValues && set(_fields, name, fieldValues);
2176
2211
  }
2177
- if (shouldUpdateFieldsAndState &&
2178
- Array.isArray(get(_formState.errors, name))) {
2179
- const fieldArrayErrors = get(_formState.errors, name);
2212
+ const fieldArrayErrors = get(_formState.errors, name);
2213
+ if (shouldUpdateFieldsAndState && Array.isArray(fieldArrayErrors)) {
2180
2214
  const rootError = fieldArrayErrors.root;
2181
2215
  const errors = method(fieldArrayErrors, args.argA, args.argB) || fieldArrayErrors;
2182
2216
  if (rootError) {
@@ -2185,11 +2219,12 @@ function createFormControl(props = {}) {
2185
2219
  shouldSetValues && set(_formState.errors, name, errors);
2186
2220
  unsetEmptyArray(_formState.errors, name);
2187
2221
  }
2222
+ const touchedFieldsArray = get(_formState.touchedFields, name);
2188
2223
  if ((_proxyFormState.touchedFields ||
2189
2224
  _proxySubscribeFormState.touchedFields) &&
2190
2225
  shouldUpdateFieldsAndState &&
2191
- Array.isArray(get(_formState.touchedFields, name))) {
2192
- const touchedFields = method(get(_formState.touchedFields, name), args.argA, args.argB);
2226
+ Array.isArray(touchedFieldsArray)) {
2227
+ const touchedFields = method(touchedFieldsArray, args.argA, args.argB);
2193
2228
  shouldSetValues && set(_formState.touchedFields, name, touchedFields);
2194
2229
  }
2195
2230
  if (_proxyFormState.dirtyFields || _proxySubscribeFormState.dirtyFields) {
@@ -2375,10 +2410,6 @@ function createFormControl(props = {}) {
2375
2410
  errors: _formState.errors,
2376
2411
  name,
2377
2412
  };
2378
- _formState = {
2379
- ..._formState,
2380
- ...updatedFormState,
2381
- };
2382
2413
  _subjects.state.next(updatedFormState);
2383
2414
  }
2384
2415
  };
@@ -2647,6 +2678,11 @@ function createFormControl(props = {}) {
2647
2678
  name: _state.mount || watched ? name : undefined,
2648
2679
  values,
2649
2680
  });
2681
+ if (!isFieldArray) {
2682
+ for (const itemName of getFieldArrayItemNames(_names.array, name)) {
2683
+ _subjects.state.next({ name: itemName, values });
2684
+ }
2685
+ }
2650
2686
  }
2651
2687
  };
2652
2688
  const setValue = (name, value, options = {}) => _setValue(name, value, options, false);
@@ -2659,10 +2695,9 @@ function createFormControl(props = {}) {
2659
2695
  ..._formValues,
2660
2696
  ...updatedFormValues,
2661
2697
  };
2662
- const flattenedUpdates = flatten(updatedFormValues);
2663
2698
  for (const fieldName of _names.mount) {
2664
- if (fieldName in flattenedUpdates) {
2665
- _setValue(fieldName, flattenedUpdates[fieldName], options, true, true);
2699
+ if (has(updatedFormValues, fieldName)) {
2700
+ _setValue(fieldName, get(updatedFormValues, fieldName), options, true, true);
2666
2701
  }
2667
2702
  }
2668
2703
  _subjects.state.next({
@@ -2862,13 +2897,22 @@ function createFormControl(props = {}) {
2862
2897
  ? get(values, fieldNames)
2863
2898
  : fieldNames.map((name) => get(values, name));
2864
2899
  };
2865
- const getFieldState = (name, formState) => ({
2866
- invalid: !!get((formState || _formState).errors, name),
2867
- isDirty: !!get((formState || _formState).dirtyFields, name),
2868
- error: get((formState || _formState).errors, name),
2869
- isValidating: !!get(_formState.validatingFields, name),
2870
- isTouched: !!get((formState || _formState).touchedFields, name),
2871
- });
2900
+ const getErrors = (fieldNames) => isUndefined(fieldNames)
2901
+ ? { ..._formState.errors }
2902
+ : isString(fieldNames)
2903
+ ? get(_formState.errors, fieldNames)
2904
+ : fieldNames.map((name) => get(_formState.errors, name));
2905
+ const getFieldState = (name, formState) => {
2906
+ const targetFormState = formState || _formState;
2907
+ const error = get(targetFormState.errors, name);
2908
+ return {
2909
+ invalid: !!error,
2910
+ isDirty: !!get(targetFormState.dirtyFields, name),
2911
+ error,
2912
+ isValidating: !!get(_formState.validatingFields, name),
2913
+ isTouched: !!get(targetFormState.touchedFields, name),
2914
+ };
2915
+ };
2872
2916
  const clearErrors = (name) => {
2873
2917
  const names = name ? convertToArrayPayload(name) : undefined;
2874
2918
  names === null || names === void 0 ? void 0 : names.forEach((inputName) => unset(_formState.errors, inputName));
@@ -2988,12 +3032,13 @@ function createFormControl(props = {}) {
2988
3032
  !options.keepDefaultValue &&
2989
3033
  unset(_defaultValues, fieldName);
2990
3034
  }
2991
- _subjects.state.next({
2992
- values: cloneObject(_formValues),
2993
- });
3035
+ _valuesSubscriberCount &&
3036
+ _subjects.state.next({
3037
+ values: cloneObject(_formValues),
3038
+ });
2994
3039
  _subjects.state.next({
2995
3040
  ..._formState,
2996
- ...(!options.keepDirty ? {} : { isDirty: _getDirty() }),
3041
+ ...(options.keepDirty ? {} : { isDirty: _getDirty() }),
2997
3042
  });
2998
3043
  !options.keepIsValid && _setValid();
2999
3044
  };
@@ -3219,7 +3264,7 @@ function createFormControl(props = {}) {
3219
3264
  ..._names.mount,
3220
3265
  ...collectDirtyFieldNames(getDirtyFields(_defaultValues, _formValues, undefined, fieldRefs), _formState.dirtyFields),
3221
3266
  ]);
3222
- for (const fieldName of Array.from(fieldsToCheck)) {
3267
+ for (const fieldName of fieldsToCheck) {
3223
3268
  const isDirty = get(_formState.dirtyFields, fieldName);
3224
3269
  const existingValue = get(_formValues, fieldName);
3225
3270
  const newValue = get(values, fieldName);
@@ -3462,6 +3507,7 @@ function createFormControl(props = {}) {
3462
3507
  setValue,
3463
3508
  setValues,
3464
3509
  getValues,
3510
+ getErrors,
3465
3511
  reset,
3466
3512
  resetField,
3467
3513
  resetDefaultValues,