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