react-hook-form 7.55.0-next.1 → 7.55.0-next.3

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,EAaL,WAAW,EAiBX,YAAY,EAIZ,aAAa,EAUd,MAAM,UAAU,CAAC;AAoDlB,wBAAgB,iBAAiB,CAC/B,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,QAAQ,GAAG,GAAG,EAEd,KAAK,GAAE,YAAY,CAAC,YAAY,EAAE,QAAQ,CAAM,GAC/C,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,QAAQ,CAAC,EAAE,WAAW,CAAC,GAAG;IAC5D,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,QAAQ,CAAC,EAAE,WAAW,CAAC,CAAC;CACvE,CAu6CA"}
1
+ {"version":3,"file":"createFormControl.d.ts","sourceRoot":"","sources":["../../src/logic/createFormControl.ts"],"names":[],"mappings":"AACA,OAAO,EAaL,WAAW,EAgBX,YAAY,EAIZ,aAAa,EAUd,MAAM,UAAU,CAAC;AAoDlB,wBAAgB,iBAAiB,CAC/B,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,QAAQ,GAAG,GAAG,EAEd,KAAK,GAAE,YAAY,CAAC,YAAY,EAAE,QAAQ,CAAM,GAC/C,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,QAAQ,CAAC,EAAE,WAAW,CAAC,GAAG;IAC5D,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,QAAQ,CAAC,EAAE,WAAW,CAAC,CAAC;CACvE,CAo5CA"}
@@ -214,7 +214,6 @@ var set = (object, path, value) => {
214
214
  object[key] = newValue;
215
215
  object = object[key];
216
216
  }
217
- return object;
218
217
  };
219
218
 
220
219
  function baseGet(object, updatePath) {
@@ -921,18 +920,15 @@ function createFormControl(props = {}) {
921
920
  name,
922
921
  };
923
922
  if (!_options.disabled) {
924
- const disabledField = !!(get(_fields, name) &&
925
- get(_fields, name)._f &&
926
- get(_fields, name)._f.disabled);
927
923
  if (!isBlurEvent || shouldDirty) {
928
924
  if (_proxyFormState.isDirty || _proxySubscribeFormState.isDirty) {
929
925
  isPreviousDirty = _formState.isDirty;
930
926
  _formState.isDirty = output.isDirty = _getDirty();
931
927
  shouldUpdateField = isPreviousDirty !== output.isDirty;
932
928
  }
933
- const isCurrentFieldPristine = disabledField || deepEqual(get(_defaultValues, name), fieldValue);
934
- isPreviousDirty = !!(!disabledField && get(_formState.dirtyFields, name));
935
- isCurrentFieldPristine || disabledField
929
+ const isCurrentFieldPristine = deepEqual(get(_defaultValues, name), fieldValue);
930
+ isPreviousDirty = !!get(_formState.dirtyFields, name);
931
+ isCurrentFieldPristine
936
932
  ? unset(_formState.dirtyFields, name)
937
933
  : set(_formState.dirtyFields, name, true);
938
934
  output.dirtyFields = _formState.dirtyFields;
@@ -1108,7 +1104,7 @@ function createFormControl(props = {}) {
1108
1104
  if (!fieldReference.ref.type) {
1109
1105
  _subjects.state.next({
1110
1106
  name,
1111
- values: { ..._formValues },
1107
+ values: cloneObject(_formValues),
1112
1108
  });
1113
1109
  }
1114
1110
  }
@@ -1139,7 +1135,7 @@ function createFormControl(props = {}) {
1139
1135
  if (isFieldArray) {
1140
1136
  _subjects.array.next({
1141
1137
  name,
1142
- values: { ..._formValues },
1138
+ values: cloneObject(_formValues),
1143
1139
  });
1144
1140
  if ((_proxyFormState.isDirty ||
1145
1141
  _proxyFormState.dirtyFields ||
@@ -1161,7 +1157,7 @@ function createFormControl(props = {}) {
1161
1157
  isWatched(name, _names) && _subjects.state.next({ ..._formState });
1162
1158
  _subjects.state.next({
1163
1159
  name: _state.mount ? name : undefined,
1164
- values: { ..._formValues },
1160
+ values: cloneObject(_formValues),
1165
1161
  });
1166
1162
  };
1167
1163
  const onChange = async (event) => {
@@ -1203,7 +1199,7 @@ function createFormControl(props = {}) {
1203
1199
  _subjects.state.next({
1204
1200
  name,
1205
1201
  type: event.type,
1206
- values: { ..._formValues },
1202
+ values: cloneObject(_formValues),
1207
1203
  });
1208
1204
  if (shouldSkipValidation) {
1209
1205
  if (_proxyFormState.isValid || _proxySubscribeFormState.isValid) {
@@ -1344,7 +1340,7 @@ function createFormControl(props = {}) {
1344
1340
  if (shouldSubscribeByName(props.name, formState.name, props.exact) &&
1345
1341
  shouldRenderFormState(formState, props.formState || _proxyFormState, _setFormState, props.reRenderRoot)) {
1346
1342
  props.callback({
1347
- values: _formValues,
1343
+ values: { ..._formValues },
1348
1344
  ..._formState,
1349
1345
  ...formState,
1350
1346
  });
@@ -1380,7 +1376,7 @@ function createFormControl(props = {}) {
1380
1376
  unset(_defaultValues, fieldName);
1381
1377
  }
1382
1378
  _subjects.state.next({
1383
- values: { ..._formValues },
1379
+ values: cloneObject(_formValues),
1384
1380
  });
1385
1381
  _subjects.state.next({
1386
1382
  ..._formState,
@@ -1388,12 +1384,11 @@ function createFormControl(props = {}) {
1388
1384
  });
1389
1385
  !options.keepIsValid && _setValid();
1390
1386
  };
1391
- const _setDisabledField = ({ disabled, name, field, fields, }) => {
1387
+ const _setDisabledField = ({ disabled, name, }) => {
1392
1388
  if ((isBoolean(disabled) && _state.mount) ||
1393
1389
  !!disabled ||
1394
1390
  _names.disabled.has(name)) {
1395
1391
  disabled ? _names.disabled.add(name) : _names.disabled.delete(name);
1396
- updateTouchAndDirty(name, getFieldValue(field ? field._f : get(fields, name)._f), false, false, true);
1397
1392
  }
1398
1393
  };
1399
1394
  const register = (name, options = {}) => {
@@ -1411,7 +1406,6 @@ function createFormControl(props = {}) {
1411
1406
  _names.mount.add(name);
1412
1407
  if (field) {
1413
1408
  _setDisabledField({
1414
- field,
1415
1409
  disabled: isBoolean(options.disabled)
1416
1410
  ? options.disabled
1417
1411
  : _options.disabled,