@ukhomeoffice/cop-react-form-renderer 5.70.0 → 5.71.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.
@@ -29,7 +29,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } // Global
29
29
  // Styles
30
30
  var DEFAULT_CLASS = exports.DEFAULT_CLASS = _FormPage2.DEFAULT_CLASS;
31
31
  var CollectionPage = function CollectionPage(_ref) {
32
- var _page$collection, _objectSpread4;
32
+ var _page$collection, _objectSpread5;
33
33
  var page = _ref.page,
34
34
  pages = _ref.pages,
35
35
  onCollectionChange = _ref.onCollectionChange,
@@ -68,6 +68,9 @@ var CollectionPage = function CollectionPage(_ref) {
68
68
  var onTopLevelChange = function onTopLevelChange(_ref3) {
69
69
  var target = _ref3.target;
70
70
  currentPage.formData[target.name] = target.value;
71
+ setPatch(function (prev) {
72
+ return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, target.name, target.value));
73
+ });
71
74
  };
72
75
  var reportChange = function reportChange(newValue) {
73
76
  onPageChange({
@@ -121,7 +124,7 @@ var CollectionPage = function CollectionPage(_ref) {
121
124
  }
122
125
  return /*#__PURE__*/_react.default.createElement(_FormPage.default, {
123
126
  page: _objectSpread(_objectSpread({}, page), {}, {
124
- formData: _objectSpread(_objectSpread(_objectSpread({}, page.formData), data[activeIndex]), {}, (_objectSpread4 = {}, _defineProperty(_objectSpread4, "".concat(currentCollectionName, "ActiveIndex"), activeIndex), _defineProperty(_objectSpread4, "".concat(currentCollectionName, "NumberedIndex"), typeof activeIndex === 'number' ? activeIndex + 1 : null), _objectSpread4)),
127
+ formData: _objectSpread(_objectSpread(_objectSpread({}, page.formData), data[activeIndex]), {}, (_objectSpread5 = {}, _defineProperty(_objectSpread5, "".concat(currentCollectionName, "ActiveIndex"), activeIndex), _defineProperty(_objectSpread5, "".concat(currentCollectionName, "NumberedIndex"), typeof activeIndex === 'number' ? activeIndex + 1 : null), _objectSpread5)),
125
128
  components: page.components.map(function (component) {
126
129
  return _objectSpread(_objectSpread({}, component), {}, {
127
130
  pageCollection: _objectSpread({}, page.collection)
@@ -117,6 +117,15 @@ var meetsCondition = function meetsCondition(condition, value, data) {
117
117
  }
118
118
  return false;
119
119
  }
120
+ case '!includesObjectProp':
121
+ {
122
+ if (Array.isArray(value)) {
123
+ return !value.some(function (v) {
124
+ return v[condition.key] === compare;
125
+ });
126
+ }
127
+ return true;
128
+ }
120
129
  case 'includesAllOf':
121
130
  {
122
131
  if (Array.isArray(value)) {
@@ -702,6 +702,56 @@ describe('utils.Condition.meetsCondition', function () {
702
702
  expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
703
703
  });
704
704
  });
705
+ describe('operator !includesObjectProp', function () {
706
+ it('should reject a property that exists within one of the objects in the value', function () {
707
+ var VALUE = [{
708
+ id: 1
709
+ }, {
710
+ id: 2
711
+ }, {
712
+ id: 3
713
+ }];
714
+ var CONDITION = {
715
+ op: '!includesObjectProp',
716
+ key: 'id',
717
+ value: 2
718
+ };
719
+ expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
720
+ });
721
+ it('should accept a property that doesnt exist within one of the objects in the value', function () {
722
+ var VALUE = [{
723
+ id: 1
724
+ }, {
725
+ id: 2
726
+ }, {
727
+ id: 3
728
+ }];
729
+ var CONDITION = {
730
+ op: '!includesObjectProp',
731
+ key: 'id',
732
+ value: 4
733
+ };
734
+ expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
735
+ });
736
+ it('should accept a value that is not an array', function () {
737
+ var VALUE = 'badValue';
738
+ var CONDITION = {
739
+ op: '!includesObjectProp',
740
+ key: 'id',
741
+ value: 7
742
+ };
743
+ expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
744
+ });
745
+ it('should accept an empty array', function () {
746
+ var VALUE = [];
747
+ var CONDITION = {
748
+ op: '!includesObjectProp',
749
+ key: 'id',
750
+ value: 7
751
+ };
752
+ expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
753
+ });
754
+ });
705
755
  describe('operator includesAllOf', function () {
706
756
  it('should reject when value is not an array', function () {
707
757
  var VALUE = 'Not an array';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ukhomeoffice/cop-react-form-renderer",
3
- "version": "5.70.0",
3
+ "version": "5.71.1",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "clean": "rimraf dist",