@reactables/forms 2.0.0 → 2.0.1

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.
package/dist/index.js CHANGED
@@ -11,10 +11,12 @@ var DEFAULT_HUB2_FIELDS = {
11
11
  childrenValid: null,
12
12
  errors: {},
13
13
  };
14
+ var cloneHub2Fields = function () { return JSON.parse(JSON.stringify(DEFAULT_HUB2_FIELDS)); };
14
15
 
15
16
  var Controls = /*#__PURE__*/Object.freeze({
16
17
  __proto__: null,
17
- DEFAULT_HUB2_FIELDS: DEFAULT_HUB2_FIELDS
18
+ DEFAULT_HUB2_FIELDS: DEFAULT_HUB2_FIELDS,
19
+ cloneHub2Fields: cloneHub2Fields
18
20
  });
19
21
 
20
22
  var required = function (value) {
@@ -962,8 +964,7 @@ var mergeRemoveControl = function (state, form, controlRef) {
962
964
  .reduce(function (acc, baseControl) {
963
965
  var _a;
964
966
  var key = getFormKey(baseControl.controlRef);
965
- var existingControl = existingBranch.find(function (control) { return baseControl.key === control.key; }) ||
966
- structuredClone(DEFAULT_HUB2_FIELDS);
967
+ var existingControl = existingBranch.find(function (control) { return baseControl.key === control.key; }) || cloneHub2Fields();
967
968
  var errors = __assign(__assign({}, baseControl.validatorErrors), existingControl.asyncValidatorErrors);
968
969
  var selfValid = !hasErrors$1(errors);
969
970
  var childrenValid = true;
@@ -1012,9 +1013,7 @@ var mergeControls = function (state, _a) {
1012
1013
  var _a;
1013
1014
  var formKey = getFormKey(control.controlRef);
1014
1015
  var existingControl = controlsRemoved && controlsRemoved[formKey];
1015
- var newControl = __assign(__assign({}, (existingControl
1016
- ? existingControl
1017
- : structuredClone(DEFAULT_HUB2_FIELDS))), control);
1016
+ var newControl = __assign(__assign({}, (existingControl ? existingControl : cloneHub2Fields())), control);
1018
1017
  var errors = __assign(__assign({}, newControl.validatorErrors), newControl.asyncValidatorErrors);
1019
1018
  var selfValid = !hasErrors(errors);
1020
1019
  var childrenValid = true;
@@ -1049,7 +1048,7 @@ var formChange = function (state, _a) {
1049
1048
  return mergeErrors(Object.entries(form).reduce(function (acc, _a) {
1050
1049
  var _b;
1051
1050
  var dictKey = _a[0], baseControl = _a[1];
1052
- return __assign(__assign({}, acc), (_b = {}, _b[dictKey] = __assign(__assign({}, structuredClone(DEFAULT_HUB2_FIELDS)), baseControl), _b));
1051
+ return __assign(__assign({}, acc), (_b = {}, _b[dictKey] = __assign(__assign({}, cloneHub2Fields()), baseControl), _b));
1053
1052
  }, {}));
1054
1053
  }
1055
1054
  return mergeControls(state, payload);