@reactables/forms 2.0.1 → 2.0.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.
package/dist/index.cjs CHANGED
@@ -399,7 +399,7 @@ var updateDescendantValues = function (form, _a, providers) {
399
399
  var _b;
400
400
  var key = _a[0], control = _a[1];
401
401
  if (isChildRef(control.controlRef, controlRef)) {
402
- var newChildValue = value[control.controlRef.at(-1)];
402
+ var newChildValue = value[control.controlRef[control.controlRef.length - 1]];
403
403
  var validatorErrors = getErrors(control, newChildValue, providers);
404
404
  var oldChildValue = control.value;
405
405
  var newControl = __assign(__assign({}, control), { value: newChildValue, validatorErrors: validatorErrors, dirty: !isEqual(newChildValue, control.pristineValue) });
@@ -532,14 +532,14 @@ var removeControl = function (state, action, providers, mergeChanges) {
532
532
  // May need to reindex array items of removed control
533
533
  // if it was part of a Form Array.
534
534
  if (parentIsFormArray) {
535
- var oldIndex = control.controlRef.at(parentRef.length);
535
+ var oldIndex = control.controlRef[parentRef.length];
536
536
  if (
537
537
  // If control is descendant.
538
538
  parentRef.every(function (ref, index) { return control.controlRef[index] === ref; }) &&
539
539
  control.controlRef.length > parentRef.length &&
540
540
  // If the array item index was greater than the index of item removed
541
541
  // we need to decrement its index by 1.
542
- oldIndex > controlRef.at(-1)) {
542
+ oldIndex > controlRef[controlRef.length - 1]) {
543
543
  var newRef = parentRef
544
544
  .concat(oldIndex - 1)
545
545
  .concat(control.controlRef.slice(parentRef.length + 1));
@@ -560,14 +560,14 @@ var removeControl = function (state, action, providers, mergeChanges) {
560
560
  _changedControls = Object.entries(_changedControls).reduce(function (acc, _a) {
561
561
  var _b, _c;
562
562
  var key = _a[0], control = _a[1];
563
- var oldIndex = control.controlRef.at(parentRef.length);
563
+ var oldIndex = control.controlRef[parentRef.length];
564
564
  if (
565
565
  // If control is descendant.
566
566
  parentRef.every(function (ref, index) { return control.controlRef[index] === ref; }) &&
567
567
  control.controlRef.length > parentRef.length &&
568
568
  // If the array item index was greater than the index of item removed
569
569
  // we need to decrement its index by 1.
570
- oldIndex > controlRef.at(-1)) {
570
+ oldIndex > controlRef[controlRef.length - 1]) {
571
571
  var newRef = parentRef
572
572
  .concat(oldIndex - 1)
573
573
  .concat(control.controlRef.slice(parentRef.length + 1));
@@ -694,7 +694,10 @@ var updateAncestorPristineValues = function (form, _a) {
694
694
  if (Array.isArray(form[parentKey].value)) {
695
695
  newValue = siblingControls
696
696
  .slice()
697
- .sort(function (a, b) { return a.controlRef.at(-1) - b.controlRef.at(-1); })
697
+ .sort(function (a, b) {
698
+ return a.controlRef[a.controlRef.length - 1] -
699
+ b.controlRef[b.controlRef.length - 1];
700
+ })
698
701
  .map(function (control) { return control.pristineValue; });
699
702
  }
700
703
  else {
@@ -702,7 +705,7 @@ var updateAncestorPristineValues = function (form, _a) {
702
705
  newValue = siblingControls.reduce(function (acc, _a) {
703
706
  var _b;
704
707
  var controlRef = _a.controlRef, pristineValue = _a.pristineValue;
705
- return __assign(__assign({}, acc), (_b = {}, _b[controlRef.at(-1)] = pristineValue, _b));
708
+ return __assign(__assign({}, acc), (_b = {}, _b[controlRef[controlRef.length - 1]] = pristineValue, _b));
706
709
  }, {});
707
710
  }
708
711
  var newParentControl = __assign(__assign({}, form[parentKey]), { pristineValue: newValue, dirty: isEqual(form[parentKey].value, newValue) });