@reactables/forms 0.4.4-alpha.0 → 0.4.6-alpha.0

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.
@@ -39,4 +39,5 @@ export interface Form<T> {
39
39
  root?: FormControl<T>;
40
40
  [key: string]: FormControl<unknown>;
41
41
  }
42
+ export declare const DEFAULT_HUB2_FIELDS: Hub2Fields;
42
43
  export {};
@@ -4,6 +4,4 @@ export { markControlAsUntouched } from './markControlAsUntouched';
4
4
  export { removeControl } from './removeControl';
5
5
  export { resetControl } from './resetControl';
6
6
  export { syncValidate } from './syncValidate';
7
- export { updateDirty } from './updateDirty';
8
7
  export { updateValues } from './updateValues';
9
- export { buildHub1Reducer } from './buildHub1Reducer';
@@ -1,4 +1,3 @@
1
1
  import { Reducer } from '@reactables/core';
2
- import { Form, Hub2Fields } from '../../Models/Controls';
3
- export declare const DEFAULT_HUB2_FIELDS: Hub2Fields;
2
+ import { Form } from '../../Models/Controls';
4
3
  export declare const formChange: Reducer<Form<unknown>>;
@@ -0,0 +1,6 @@
1
+ import { Form, BaseForm, FormControl } from '../../Models/Controls';
2
+ import { ControlRef } from '../../Models/ControlRef';
3
+ export declare const mergeRemoveControl: <T>(state: Form<T>, form: BaseForm<T>, controlRef: ControlRef) => {
4
+ [x: string]: FormControl<unknown>;
5
+ root?: FormControl<T>;
6
+ };
@@ -0,0 +1,6 @@
1
+ import { Form, BaseForm, FormControl } from '../../Models/Controls';
2
+ import { ControlRef } from '../../Models/ControlRef';
3
+ export declare const mergeTouchUpdated: <T>(state: Form<T>, form: BaseForm<T>, controlRef: ControlRef) => {
4
+ [x: string]: FormControl<unknown>;
5
+ root?: FormControl<T>;
6
+ };
@@ -1,3 +1,6 @@
1
- import { Form, BaseForm } from '../../Models/Controls';
1
+ import { Form, BaseForm, FormControl } from '../../Models/Controls';
2
2
  import { ControlRef } from '../../Models/ControlRef';
3
- export declare const mergeValueUpdated: <T>(state: Form<T>, form: BaseForm<T>, controlRef: ControlRef) => Form<T>;
3
+ export declare const mergeValueUpdated: <T>(state: Form<T>, form: BaseForm<T>, controlRef: ControlRef) => {
4
+ [x: string]: FormControl<unknown>;
5
+ root?: FormControl<T>;
6
+ };
package/dist/index.js CHANGED
@@ -11,8 +11,17 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
11
11
 
12
12
  var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
13
13
 
14
+ var DEFAULT_HUB2_FIELDS = {
15
+ asyncValidatorErrors: {},
16
+ asyncValidateInProgress: {},
17
+ pending: false,
18
+ valid: null,
19
+ errors: null
20
+ };
21
+
14
22
  var Controls = /*#__PURE__*/Object.freeze({
15
- __proto__: null
23
+ __proto__: null,
24
+ DEFAULT_HUB2_FIELDS: DEFAULT_HUB2_FIELDS
16
25
  });
17
26
 
18
27
  var required = function (value) {
@@ -346,7 +355,8 @@ var isChildRef = function (controlRef, parentRef) {
346
355
  var UPDATE_DESCENDANT_VALUES = 'UPDATE_DESCENDANT_VALUES';
347
356
  var updateDescendants = function (form, _a) {
348
357
  var _b = _a.payload, controlRef = _b.controlRef, value = _b.value;
349
- var result = Object.entries(form).reduce(function (acc, _a) {
358
+ var descendants = getDescendantControls(controlRef, form, true).map(function (control) { return [getFormKey(control.controlRef), control]; });
359
+ var result = descendants.reduce(function (acc, _a) {
350
360
  var _b;
351
361
  var key = _a[0], control = _a[1];
352
362
  if (isChildRef(control.controlRef, controlRef)) {
@@ -435,14 +445,16 @@ var removeControl = function (_a, action) {
435
445
  return { form: form, action: action };
436
446
  var parentRef = controlRef.slice(0, -1);
437
447
  var parentIsFormArray = Array.isArray(getControl(parentRef, form).config.controls);
448
+ var descendantkeys = getDescendantControls(controlRef, form).map(function (_a) {
449
+ var controlRef = _a.controlRef;
450
+ return getFormKey(controlRef);
451
+ });
452
+ var controlsRemoved = __assign({}, form);
453
+ descendantkeys.forEach(function (key) {
454
+ delete controlsRemoved[key];
455
+ });
438
456
  // Remove control and all descendants
439
- var controlRemoved = Object.entries(form)
440
- .filter(function (_a) {
441
- _a[0]; var control = _a[1];
442
- return !(control.controlRef.length > parentRef.length &&
443
- controlRef.every(function (key, index) { return key === control.controlRef[index]; }));
444
- })
445
- .reduce(function (acc, _a) {
457
+ var controlRemoved = Object.entries(controlsRemoved).reduce(function (acc, _a) {
446
458
  var _b, _c;
447
459
  var key = _a[0], control = _a[1];
448
460
  // May need to reindex array items of removed control
@@ -551,7 +563,7 @@ var updateAncestorPristineValues = function (form, _a) {
551
563
  return __assign(__assign({}, acc), (_b = {}, _b[controlRef.at(-1)] = pristineValue, _b));
552
564
  }, {});
553
565
  }
554
- var newParentControl = __assign(__assign({}, form[parentKey]), { pristineValue: newValue });
566
+ var newParentControl = __assign(__assign({}, form[parentKey]), { pristineValue: newValue, dirty: isEqual__default["default"](form[parentKey].value, newValue) });
555
567
  return updateAncestorPristineValues(__assign(__assign({}, form), (_b = {}, _b[parentKey] = newParentControl, _b)), {
556
568
  type: UPDATE_ANCESTOR_PRISTINE_VALUES,
557
569
  payload: parentRef
@@ -560,46 +572,32 @@ var updateAncestorPristineValues = function (form, _a) {
560
572
  return form;
561
573
  };
562
574
 
563
- var updateDirty = function (form) {
564
- return Object.entries(form).reduce(function (acc, _a) {
565
- var _b;
566
- var key = _a[0], control = _a[1];
567
- return __assign(__assign({}, acc), (_b = {}, _b[key] = __assign(__assign({}, control), { dirty: !isEqual__default["default"](control.value, control.pristineValue) }), _b));
568
- }, {});
569
- };
570
-
571
575
  var markControlAsPristine = function (_a, action) {
572
576
  var form = _a.form;
573
577
  var controlRef = action.payload;
574
- var descendants = getDescendantControls(controlRef, form);
575
- var result = Object.entries(form).reduce(function (acc, _a) {
576
- var _b;
577
- var key = _a[0], control = _a[1];
578
- var isDescendant = descendants.includes(control);
579
- return __assign(__assign({}, acc), (_b = {}, _b[key] = isDescendant
580
- ? __assign(__assign({}, control), { pristineValue: control.value, dirty: false }) : control, _b));
578
+ var descendants = getDescendantControls(controlRef, form).reduce(function (acc, control) {
579
+ var _a;
580
+ return (__assign(__assign({}, acc), (_a = {}, _a[getFormKey(control.controlRef)] = __assign(__assign({}, control), { dirty: false, pristineValue: control.value }), _a)));
581
581
  }, {});
582
+ var result = __assign(__assign({}, form), descendants);
582
583
  if (controlRef.length) {
583
584
  result = updateAncestorPristineValues(result, {
584
585
  type: UPDATE_ANCESTOR_PRISTINE_VALUES,
585
586
  payload: controlRef
586
587
  });
587
588
  }
588
- return { form: updateDirty(result), action: action };
589
+ return { form: result, action: action };
589
590
  };
590
591
 
591
592
  var markControlAsTouched = function (_a, action) {
592
593
  var form = _a.form;
593
594
  var _b = action.payload, controlRef = _b.controlRef, markAll = _b.markAll;
594
- var controls = markAll
595
- ? getControlBranch(controlRef, form)
596
- : getAncestorControls(controlRef, form);
595
+ var controls = (markAll ? getControlBranch(controlRef, form) : getAncestorControls(controlRef, form)).reduce(function (acc, control) {
596
+ var _a;
597
+ return (__assign(__assign({}, acc), (_a = {}, _a[getFormKey(control.controlRef)] = __assign(__assign({}, control), { touched: true }), _a)));
598
+ }, {});
597
599
  return {
598
- form: Object.entries(form).reduce(function (acc, _a) {
599
- var _b;
600
- var key = _a[0], control = _a[1];
601
- return (__assign(__assign({}, acc), (_b = {}, _b[key] = __assign(__assign({}, control), { touched: controls.includes(control) ? true : control.touched }), _b)));
602
- }, {}),
600
+ form: __assign(__assign({}, form), controls),
603
601
  action: action
604
602
  };
605
603
  };
@@ -608,12 +606,11 @@ var markControlAsUntouched = function (_a, action) {
608
606
  var _b;
609
607
  var form = _a.form;
610
608
  var controlRef = action.payload;
611
- var descendants = getDescendantControls(controlRef, form);
612
- var result = Object.entries(form).reduce(function (acc, _a) {
613
- var _b;
614
- var key = _a[0], control = _a[1];
615
- return (__assign(__assign({}, acc), (_b = {}, _b[key] = __assign(__assign({}, control), { touched: descendants.includes(control) ? false : control.touched }), _b)));
609
+ var result = getDescendantControls(controlRef, form).reduce(function (acc, control) {
610
+ var _a;
611
+ return (__assign(__assign({}, acc), (_a = {}, _a[getFormKey(control.controlRef)] = __assign(__assign({}, control), { touched: false }), _a)));
616
612
  }, {});
613
+ result = __assign(__assign({}, form), result);
617
614
  // Update ancestors
618
615
  var currentRef = controlRef;
619
616
  var key;
@@ -651,54 +648,53 @@ var resetControl = function (_a, action) {
651
648
 
652
649
  var asyncValidation = function (form, _a) {
653
650
  var controlRef = _a.payload.controlRef;
654
- var ancestors = getAncestorControls(controlRef, form);
655
- var result = Object.entries(form).reduce(function (acc, _a) {
656
- var _b, _c;
657
- var key = _a[0], control = _a[1];
658
- if (ancestors.includes(control)) {
659
- var isChangedControl = getFormKey(control.controlRef) === getFormKey(controlRef);
660
- return __assign(__assign({}, acc), (_b = {}, _b[key] = __assign(__assign({}, control), { pending: true, asyncValidateInProgress: isChangedControl
661
- ? __assign({}, control.config.asyncValidators.reduce(function (acc, _, index) {
662
- var _a;
663
- return (__assign(__assign({}, acc), (_a = {}, _a[index] = true, _a)));
664
- }, {})) : control.asyncValidateInProgress }), _b));
665
- }
666
- return __assign(__assign({}, acc), (_c = {}, _c[key] = control, _c));
651
+ var updatedSelfAndAncestors = getAncestorControls(controlRef, form).reduce(function (acc, control) {
652
+ var _a;
653
+ var isChangedControl = getFormKey(control.controlRef) === getFormKey(controlRef);
654
+ return __assign(__assign({}, acc), (_a = {}, _a[getFormKey(control.controlRef)] = __assign(__assign({}, control), { pending: true, asyncValidateInProgress: isChangedControl
655
+ ? __assign({}, control.config.asyncValidators.reduce(function (acc, _, index) {
656
+ var _a;
657
+ return (__assign(__assign({}, acc), (_a = {}, _a[index] = true, _a)));
658
+ }, {})) : control.asyncValidateInProgress }), _a));
667
659
  }, {});
668
- return result;
660
+ return __assign(__assign({}, form), updatedSelfAndAncestors);
669
661
  };
670
662
 
671
- var hasErrors$1 = function (errors) {
663
+ var hasErrors$3 = function (errors) {
672
664
  return Object.values(errors).some(function (hasError) { return hasError; });
673
665
  };
674
- // TODO: update merge errors to not do the entire form but just a subset of it
675
- // TODO: separation of concern to update validity of control and ancestors
676
- var mergeErrors = function (form) {
677
- var errorsMerged = Object.entries(form)
666
+ var mergeBranchErrors = function (form, controlRef) {
667
+ var controlBranch = getControlBranch(controlRef, form).reduce(function (acc, ctrl) {
668
+ var _a;
669
+ return __assign(__assign({}, acc), (_a = {}, _a[getFormKey(ctrl.controlRef)] = ctrl, _a));
670
+ }, {});
671
+ var errorsMerged = Object.entries(controlBranch)
678
672
  .reverse()
679
673
  .reduce(function (acc, _a) {
680
674
  var _b;
681
675
  var key = _a[0], control = _a[1];
682
676
  var errors = __assign(__assign({}, control.validatorErrors), control.asyncValidatorErrors);
683
- var selfValid = !hasErrors$1(errors);
677
+ var selfValid = !hasErrors$3(errors);
684
678
  var childrenValid = true;
685
679
  if (Array.isArray(control.config.controls)) {
686
680
  // If control is a FormArray
687
- childrenValid = control.value.every(function (item, index) { return acc[getFormKey(control.controlRef.concat(index))].valid; });
681
+ childrenValid = control.value.every(function (item, index) {
682
+ var formKey = getFormKey(control.controlRef.concat(index));
683
+ var valid = acc[formKey] === undefined ? form[formKey].valid : acc[formKey].valid;
684
+ return valid;
685
+ });
688
686
  }
689
687
  else if (control.config.controls) {
690
688
  // If control is a FormGroup
691
- childrenValid = Object.keys(control.value).every(function (childKey) { return acc[getFormKey(control.controlRef.concat(childKey))].valid; });
689
+ childrenValid = Object.keys(control.value).every(function (childKey) {
690
+ var formKey = getFormKey(control.controlRef.concat(childKey));
691
+ var valid = acc[formKey] === undefined ? form[formKey].valid : acc[formKey].valid;
692
+ return valid;
693
+ });
692
694
  }
693
695
  return __assign(__assign({}, acc), (_b = {}, _b[key] = __assign(__assign({}, control), { errors: errors, valid: selfValid && childrenValid }), _b));
694
696
  }, {});
695
- var restoredOrder = Object.keys(errorsMerged)
696
- .reverse()
697
- .reduce(function (acc, key) {
698
- acc[key] = errorsMerged[key];
699
- return acc;
700
- }, {});
701
- return restoredOrder;
697
+ return __assign(__assign({}, form), errorsMerged);
702
698
  };
703
699
 
704
700
  var isControlValidating = function (control) {
@@ -727,30 +723,60 @@ var asyncValidationResponseSuccess = function (form, _a) {
727
723
  }
728
724
  return __assign(__assign({}, acc), (_c = {}, _c[key] = control, _c));
729
725
  }, {});
730
- return mergeErrors(ancestorsUpdated);
726
+ return mergeBranchErrors(ancestorsUpdated, control.controlRef);
731
727
  };
732
728
 
733
- var hasErrors = function (errors) {
729
+ var hasErrors$2 = function (errors) {
734
730
  return Object.values(errors).some(function (hasError) { return hasError; });
735
731
  };
736
- var mergeBranchErrors = function (form, controlRef) {
737
- var controlBranch = getControlBranch(controlRef, form).reduce(function (acc, ctrl) {
738
- var _a;
739
- return __assign(__assign({}, acc), (_a = {}, _a[getFormKey(ctrl.controlRef)] = ctrl, _a));
740
- }, {});
741
- var errorsMerged = Object.entries(controlBranch)
732
+ // TODO: update merge errors to not do the entire form but just a subset of it
733
+ // TODO: separation of concern to update validity of control and ancestors
734
+ var mergeErrors = function (form) {
735
+ var errorsMerged = Object.entries(form)
742
736
  .reverse()
743
737
  .reduce(function (acc, _a) {
744
738
  var _b;
745
739
  var key = _a[0], control = _a[1];
746
740
  var errors = __assign(__assign({}, control.validatorErrors), control.asyncValidatorErrors);
747
- var selfValid = !hasErrors(errors);
741
+ var selfValid = !hasErrors$2(errors);
742
+ var childrenValid = true;
743
+ if (Array.isArray(control.config.controls)) {
744
+ // If control is a FormArray
745
+ childrenValid = control.value.every(function (item, index) { return acc[getFormKey(control.controlRef.concat(index))].valid; });
746
+ }
747
+ else if (control.config.controls) {
748
+ // If control is a FormGroup
749
+ childrenValid = Object.keys(control.value).every(function (childKey) { return acc[getFormKey(control.controlRef.concat(childKey))].valid; });
750
+ }
751
+ return __assign(__assign({}, acc), (_b = {}, _b[key] = __assign(__assign({}, control), { errors: errors, valid: selfValid && childrenValid }), _b));
752
+ }, {});
753
+ var restoredOrder = Object.keys(errorsMerged)
754
+ .reverse()
755
+ .reduce(function (acc, key) {
756
+ acc[key] = errorsMerged[key];
757
+ return acc;
758
+ }, {});
759
+ return restoredOrder;
760
+ };
761
+
762
+ var hasErrors$1 = function (errors) {
763
+ return Object.values(errors).some(function (hasError) { return hasError; });
764
+ };
765
+ var mergeValueUpdated = function (state, form, controlRef) {
766
+ var controlBranch = getControlBranch(controlRef, form)
767
+ .reverse()
768
+ .reduce(function (acc, control) {
769
+ var _a;
770
+ var key = getFormKey(control.controlRef);
771
+ var existingControl = state[key] || structuredClone(DEFAULT_HUB2_FIELDS);
772
+ var errors = __assign(__assign({}, control.validatorErrors), existingControl.asyncValidatorErrors);
773
+ var selfValid = !hasErrors$1(errors);
748
774
  var childrenValid = true;
749
775
  if (Array.isArray(control.config.controls)) {
750
776
  // If control is a FormArray
751
777
  childrenValid = control.value.every(function (item, index) {
752
778
  var formKey = getFormKey(control.controlRef.concat(index));
753
- var valid = acc[formKey] === undefined ? form[formKey].valid : acc[formKey].valid;
779
+ var valid = acc[formKey] === undefined ? state[formKey].valid : acc[formKey].valid;
754
780
  return valid;
755
781
  });
756
782
  }
@@ -758,31 +784,66 @@ var mergeBranchErrors = function (form, controlRef) {
758
784
  // If control is a FormGroup
759
785
  childrenValid = Object.keys(control.value).every(function (childKey) {
760
786
  var formKey = getFormKey(control.controlRef.concat(childKey));
761
- var valid = acc[formKey] === undefined ? form[formKey].valid : acc[formKey].valid;
787
+ var valid = acc[formKey] === undefined ? state[formKey].valid : acc[formKey].valid;
762
788
  return valid;
763
789
  });
764
790
  }
765
- return __assign(__assign({}, acc), (_b = {}, _b[key] = __assign(__assign({}, control), { errors: errors, valid: selfValid && childrenValid }), _b));
791
+ return __assign(__assign({}, acc), (_a = {}, _a[key] = __assign(__assign(__assign({}, existingControl), control), { errors: errors, valid: selfValid && childrenValid }), _a));
766
792
  }, {});
767
- return __assign(__assign({}, form), errorsMerged);
793
+ return __assign(__assign({}, state), controlBranch);
768
794
  };
769
795
 
770
- var mergeValueUpdated = function (state, form, controlRef) {
796
+ var hasErrors = function (errors) {
797
+ return Object.values(errors).some(function (hasError) { return hasError; });
798
+ };
799
+ var mergeRemoveControl = function (state, form, controlRef) {
800
+ var parentRef = controlRef.slice(0, -1);
801
+ var existingBranch = getControlBranch(parentRef, state);
802
+ var descendants = existingBranch.filter(function (control) { return control.controlRef.length < parentRef.length; });
803
+ var controlBranch = getControlBranch(parentRef, form)
804
+ .reverse()
805
+ .reduce(function (acc, baseControl) {
806
+ var _a;
807
+ var key = getFormKey(baseControl.controlRef);
808
+ var existingControl = existingBranch.find(function (control) { return baseControl.key === control.key; }) ||
809
+ structuredClone(DEFAULT_HUB2_FIELDS);
810
+ var errors = __assign(__assign({}, baseControl.validatorErrors), existingControl.asyncValidatorErrors);
811
+ var selfValid = !hasErrors(errors);
812
+ var childrenValid = true;
813
+ if (Array.isArray(baseControl.config.controls)) {
814
+ // If control is a FormArray
815
+ childrenValid = baseControl.value.every(function (item, index) {
816
+ var formKey = getFormKey(baseControl.controlRef.concat(index));
817
+ var valid = acc[formKey] === undefined ? state[formKey].valid : acc[formKey].valid;
818
+ return valid;
819
+ });
820
+ }
821
+ else if (baseControl.config.controls) {
822
+ // If control is a FormGroup
823
+ childrenValid = Object.keys(baseControl.value).every(function (childKey) {
824
+ var formKey = getFormKey(baseControl.controlRef.concat(childKey));
825
+ var valid = acc[formKey] === undefined ? state[formKey].valid : acc[formKey].valid;
826
+ return valid;
827
+ });
828
+ }
829
+ return __assign(__assign({}, acc), (_a = {}, _a[key] = __assign(__assign(__assign({}, existingControl), baseControl), { errors: errors, valid: selfValid && childrenValid }), _a));
830
+ }, {});
831
+ var removedControls = __assign({}, state);
832
+ descendants.forEach(function (control) {
833
+ delete removedControls[getFormKey(control.controlRef)];
834
+ });
835
+ return __assign(__assign({}, removedControls), controlBranch);
836
+ };
837
+
838
+ var mergeTouchUpdated = function (state, form, controlRef) {
771
839
  var controlBranch = getControlBranch(controlRef, form).reduce(function (acc, control) {
772
840
  var _a;
773
841
  var key = getFormKey(control.controlRef);
774
842
  return __assign(__assign({}, acc), (_a = {}, _a[key] = __assign(__assign({}, state[key]), control), _a));
775
843
  }, {});
776
- return mergeBranchErrors(__assign(__assign({}, state), controlBranch), controlRef);
844
+ return __assign(__assign({}, state), controlBranch);
777
845
  };
778
846
 
779
- var DEFAULT_HUB2_FIELDS = {
780
- asyncValidatorErrors: {},
781
- asyncValidateInProgress: {},
782
- pending: false,
783
- valid: null,
784
- errors: null
785
- };
786
847
  var formChange = function (state, _a) {
787
848
  if (state === void 0) { state = null; }
788
849
  var _b = _a.payload, form = _b.form, action = _b.action;
@@ -794,15 +855,22 @@ var formChange = function (state, _a) {
794
855
  }, {}));
795
856
  }
796
857
  switch (action === null || action === void 0 ? void 0 : action.type) {
858
+ case 'addControl':
797
859
  case 'updateValues':
798
860
  return mergeValueUpdated(state, form, action.payload.controlRef);
861
+ case 'resetControl':
862
+ case 'removeControl':
863
+ return mergeRemoveControl(state, form, action.payload);
864
+ case 'markControlAsPristine':
865
+ case 'markControlAsUntouched':
866
+ return mergeTouchUpdated(state, form, action.payload);
867
+ case 'markControlAsTouched':
868
+ return mergeTouchUpdated(state, form, action.payload.controlRef);
799
869
  default:
800
870
  return mergeErrors(Object.entries(form).reduce(function (acc, _a) {
801
871
  var _b;
802
872
  var dictKey = _a[0], baseControl = _a[1];
803
- var existingControl = (action === null || action === void 0 ? void 0 : action.type) === 'removeControl'
804
- ? state && Object.values(state).find(function (control) { return baseControl.key === control.key; })
805
- : state && state[dictKey];
873
+ var existingControl = state && state[dictKey];
806
874
  return __assign(__assign({}, acc), (_b = {}, _b[dictKey] = __assign(__assign({}, (existingControl
807
875
  ? existingControl
808
876
  : structuredClone(DEFAULT_HUB2_FIELDS))), baseControl), _b));
@@ -865,17 +933,12 @@ var RxForm = {
865
933
  };
866
934
 
867
935
  var getArrayItems = function (controlRef, form) {
868
- if (!Array.isArray(getControl(controlRef, form).config.controls)) {
936
+ var control = getControl(controlRef, form);
937
+ if (!Array.isArray(control.config.controls)) {
869
938
  throw "".concat(controlRef.join('.'), " is not a Form Array control");
870
939
  }
871
- return Object.values(form)
872
- .filter(function (control) {
873
- var isItem = controlRef.every(function (key, index) { return key === control.controlRef[index]; }) &&
874
- control.controlRef.length === controlRef.length + 1 &&
875
- typeof control.controlRef[controlRef.length] === 'number';
876
- return isItem;
877
- })
878
- .sort(function (a, b) { return +a.controlRef.slice(-1) - +b.controlRef.slice(-1); });
940
+ var result = control.value.map(function (_, index) { return form[getFormKey(controlRef.concat(index))]; });
941
+ return result;
879
942
  };
880
943
 
881
944
  exports.ControlModels = Controls;
package/package.json CHANGED
@@ -14,12 +14,12 @@
14
14
  "author": "David Lai",
15
15
  "license": "ISC",
16
16
  "dependencies": {
17
- "@reactables/core": "^0.4.4-alpha.0",
17
+ "@reactables/core": "^0.4.6-alpha.0",
18
18
  "lodash.clonedeep": "^4.5.0",
19
19
  "lodash.isequal": "^4.5.0"
20
20
  },
21
21
  "peerDependencies": {
22
22
  "rxjs": "^6.0.0 || ^7.0.0"
23
23
  },
24
- "version": "0.4.4-alpha.0"
24
+ "version": "0.4.6-alpha.0"
25
25
  }
@@ -1,2 +0,0 @@
1
- import { BaseForm } from '../../Models/Controls';
2
- export declare const updateDirty: <T>(form: BaseForm<T>) => BaseForm<T>;
@@ -1 +0,0 @@
1
- export {};