react-hook-form 7.43.0 → 7.43.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.
@@ -603,7 +603,7 @@ var isHTMLElement = (value) => {
603
603
  (owner && owner.defaultView ? owner.defaultView.HTMLElement : HTMLElement));
604
604
  };
605
605
 
606
- var isMessage = (value) => isString(value) || React.isValidElement(value);
606
+ var isMessage = (value) => isString(value);
607
607
 
608
608
  var isRadioInput = (element) => element.type === 'radio';
609
609
 
@@ -1146,8 +1146,11 @@ function useFieldArray(props) {
1146
1146
  function createSubject() {
1147
1147
  let _observers = [];
1148
1148
  const next = (value) => {
1149
- for (const observer of _observers) {
1150
- observer.next(value);
1149
+ let x = 0;
1150
+ const l = _observers.length;
1151
+ while (x < l) {
1152
+ _observers[x].next(value);
1153
+ ++x;
1151
1154
  }
1152
1155
  };
1153
1156
  const subscribe = (observer) => {
@@ -1386,7 +1389,6 @@ function createFormControl(props = {}, flushRootRender) {
1386
1389
  ...defaultOptions,
1387
1390
  ...props,
1388
1391
  };
1389
- const shouldCaptureDirtyFields = props.resetOptions && props.resetOptions.keepDirtyValues;
1390
1392
  let _formState = {
1391
1393
  submitCount: 0,
1392
1394
  isDirty: false,
@@ -1420,6 +1422,7 @@ function createFormControl(props = {}, flushRootRender) {
1420
1422
  };
1421
1423
  let delayErrorCallback;
1422
1424
  let timer = 0;
1425
+ const shouldCaptureDirtyFields = props.resetOptions && props.resetOptions.keepDirtyValues;
1423
1426
  const _proxyFormState = {
1424
1427
  isDirty: false,
1425
1428
  dirtyFields: false,
@@ -1438,7 +1441,7 @@ function createFormControl(props = {}, flushRootRender) {
1438
1441
  const shouldDisplayAllAssociatedErrors = _options.criteriaMode === VALIDATION_MODE.all;
1439
1442
  const debounce = (callback) => (wait) => {
1440
1443
  clearTimeout(timer);
1441
- timer = window.setTimeout(callback, wait);
1444
+ timer = setTimeout(callback, wait);
1442
1445
  };
1443
1446
  const _updateValid = async (shouldUpdateValid) => {
1444
1447
  if (_proxyFormState.isValid || shouldUpdateValid) {
@@ -2007,6 +2010,7 @@ function createFormControl(props = {}, flushRootRender) {
2007
2010
  await onInvalid({ ..._formState.errors }, e);
2008
2011
  }
2009
2012
  _focusError();
2013
+ setTimeout(_focusError);
2010
2014
  }
2011
2015
  _subjects.state.next({
2012
2016
  isSubmitted: true,
@@ -2106,14 +2110,14 @@ function createFormControl(props = {}, flushRootRender) {
2106
2110
  submitCount: keepStateOptions.keepSubmitCount
2107
2111
  ? _formState.submitCount
2108
2112
  : 0,
2109
- isDirty: keepStateOptions.keepDirty || keepStateOptions.keepDirtyValues
2113
+ isDirty: keepStateOptions.keepDirty
2110
2114
  ? _formState.isDirty
2111
2115
  : !!(keepStateOptions.keepDefaultValues &&
2112
2116
  !deepEqual(formValues, _defaultValues)),
2113
2117
  isSubmitted: keepStateOptions.keepIsSubmitted
2114
2118
  ? _formState.isSubmitted
2115
2119
  : false,
2116
- dirtyFields: keepStateOptions.keepDirty || keepStateOptions.keepDirtyValues
2120
+ dirtyFields: keepStateOptions.keepDirtyValues
2117
2121
  ? _formState.dirtyFields
2118
2122
  : keepStateOptions.keepDefaultValues && formValues
2119
2123
  ? getDirtyFields(_defaultValues, formValues)
@@ -2162,7 +2166,6 @@ function createFormControl(props = {}, flushRootRender) {
2162
2166
  unregister,
2163
2167
  getFieldState,
2164
2168
  _executeSchema,
2165
- _focusError,
2166
2169
  _getWatch,
2167
2170
  _getDirty,
2168
2171
  _updateValid,
@@ -2305,9 +2308,6 @@ function useForm(props = {}) {
2305
2308
  control._reset(props.values, control._options.resetOptions);
2306
2309
  }
2307
2310
  }, [props.values, control]);
2308
- React.useEffect(() => {
2309
- formState.submitCount && control._focusError();
2310
- }, [control, formState.submitCount]);
2311
2311
  _formControl.current.formState = getProxyFormState(formState, control);
2312
2312
  return _formControl.current;
2313
2313
  }