@ukhomeoffice/cop-react-form-renderer 3.2.4 → 3.3.1-alpha

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.
@@ -37,14 +37,6 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
37
37
 
38
38
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
39
39
 
40
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
41
-
42
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
43
-
44
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
45
-
46
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
47
-
48
40
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
49
41
 
50
42
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -97,7 +89,7 @@ var Collection = function Collection(_ref) {
97
89
  var itemIndex = value.findIndex(function (item) {
98
90
  return item.id === target.name;
99
91
  });
100
- reportChange([].concat(_toConsumableArray(value.slice(0, itemIndex)), [target.value], _toConsumableArray(value.slice(itemIndex + 1))));
92
+ reportChange([].concat(value.slice(0, itemIndex), [target.value], value.slice(itemIndex + 1)));
101
93
  }
102
94
  }
103
95
  };
@@ -108,7 +100,7 @@ var Collection = function Collection(_ref) {
108
100
  while (1) {
109
101
  switch (_context.prev = _context.next) {
110
102
  case 0:
111
- reportChange([].concat(_toConsumableArray(value), [{
103
+ reportChange([].concat(value, [{
112
104
  id: Date.now().toString()
113
105
  }]));
114
106
 
@@ -156,7 +156,7 @@ FormComponent.propTypes = {
156
156
  label: _propTypes.default.string,
157
157
  hint: _propTypes.default.string,
158
158
  data: _propTypes.default.shape({
159
- options: _propTypes.default.arrayOf(_propTypes.default.object),
159
+ options: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.object])),
160
160
  url: _propTypes.default.string
161
161
  })
162
162
  }).isRequired,
@@ -24,18 +24,6 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
24
24
 
25
25
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
26
26
 
27
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
28
-
29
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
30
-
31
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
32
-
33
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
34
-
35
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
36
-
37
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
38
-
39
27
  describe('components.FormPage', function () {
40
28
  describe('FormPage', function () {
41
29
  var TEXT = {
@@ -142,11 +130,9 @@ describe('components.FormPage', function () {
142
130
  expect(outerWrapper.classList).toContain('hods-autocomplete__outer-wrapper');
143
131
  var autocomplete = outerWrapper.childNodes[0];
144
132
  expect(autocomplete.classList).toContain('hods-autocomplete__wrapper');
145
-
146
- var input = _toConsumableArray(autocomplete.childNodes).filter(function (e) {
133
+ var input = [].concat(autocomplete.childNodes).filter(function (e) {
147
134
  return e.tagName === 'INPUT';
148
135
  })[0];
149
-
150
136
  expect(input.classList).toContain('hods-autocomplete__input');
151
137
  expect(input.tagName).toEqual('INPUT');
152
138
  expect(input.id).toEqual(fieldId);
@@ -17,14 +17,6 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
17
17
 
18
18
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
19
 
20
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
21
-
22
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
23
-
24
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
25
-
26
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
27
-
28
20
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
29
21
 
30
22
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
@@ -59,7 +51,7 @@ var ValidationContextProvider = function ValidationContextProvider(_ref) {
59
51
  switch (_context.prev = _context.next) {
60
52
  case 0:
61
53
  setErrors(function (prev) {
62
- return [].concat(_toConsumableArray(prev), _toConsumableArray(errors)).filter(function (e) {
54
+ return [].concat(prev, errors).filter(function (e) {
63
55
  return !!e;
64
56
  });
65
57
  });
@@ -19,6 +19,7 @@ var TYPE_RADIOS = 'radios';
19
19
  var TYPE_TEXT = 'text';
20
20
  var TYPE_TEXT_AREA = 'textarea';
21
21
  var TYPE_TIME = 'time';
22
+ var TYPE_WARNING = 'warning';
22
23
  var ComponentTypes = {
23
24
  AUTOCOMPLETE: TYPE_AUTOCOMPLETE,
24
25
  CHECKBOXES: TYPE_CHECKBOXES,
@@ -34,7 +35,8 @@ var ComponentTypes = {
34
35
  RADIOS: TYPE_RADIOS,
35
36
  TEXT: TYPE_TEXT,
36
37
  TEXT_AREA: TYPE_TEXT_AREA,
37
- TIME: TYPE_TIME
38
+ TIME: TYPE_TIME,
39
+ WARNING: TYPE_WARNING
38
40
  };
39
41
  var _default = ComponentTypes;
40
42
  exports.default = _default;
@@ -27,9 +27,9 @@ var getCYARow = function getCYARow(page, component, onAction) {
27
27
 
28
28
  if (page.formData && component.fieldId) {
29
29
  value = page.formData[component.fieldId];
30
+ setNestedValue(component, page);
30
31
  }
31
32
 
32
- setNestedValue(component, page);
33
33
  return {
34
34
  pageId: page.id,
35
35
  id: component.id,
@@ -46,9 +46,9 @@ var getCYARow = function getCYARow(page, component, onAction) {
46
46
  var setNestedValue = function setNestedValue(component, page) {
47
47
  var _component$data, _component$data$optio;
48
48
 
49
- (_component$data = component.data) === null || _component$data === void 0 ? void 0 : (_component$data$optio = _component$data.options) === null || _component$data$optio === void 0 ? void 0 : _component$data$optio.forEach(function (option, index) {
49
+ (_component$data = component.data) === null || _component$data === void 0 ? void 0 : (_component$data$optio = _component$data.options) === null || _component$data$optio === void 0 ? void 0 : _component$data$optio.forEach(function (option) {
50
50
  //check if option is selected and has nested component
51
- if (page.formData[component.id] === option.value && option.nested) {
51
+ if (Array.isArray(option.nested) && page.formData[component.id] === option.value) {
52
52
  option.nested.forEach(function (child) {
53
53
  child.value = page.formData[child.id];
54
54
  });
@@ -145,7 +145,7 @@ describe('utils', function () {
145
145
  onAction: ON_ACTION
146
146
  });
147
147
  });
148
- it('should update update any nested components with corresponding values from the stored formdata', function () {
148
+ it('should update any nested components with corresponding values from the stored formdata', function () {
149
149
  var SELECTED_VALUE = 'selectedValue';
150
150
  var NESTED_ID = 'nestedId';
151
151
  var NESTED_VALUE = 'nestedValue';
@@ -159,6 +159,7 @@ describe('utils', function () {
159
159
  var COMPONENT = {
160
160
  type: 'radios',
161
161
  id: 'a',
162
+ fieldId: 'a',
162
163
  data: {
163
164
  options: [{
164
165
  value: SELECTED_VALUE,
@@ -171,6 +172,29 @@ describe('utils', function () {
171
172
  var ROW = (0, _getCYARow.default)(PAGE, COMPONENT, function () {});
172
173
  expect(ROW.component.data.options[0].nested[0].value).toEqual(NESTED_VALUE);
173
174
  });
175
+ it('should handle an undefined formData when attempting to set nested values', function () {
176
+ var SELECTED_VALUE = 'selectedValue';
177
+ var NESTED_ID = 'nestedId';
178
+ var PAGE = {
179
+ id: 'page',
180
+ cya_link: {}
181
+ };
182
+ var COMPONENT = {
183
+ type: 'radios',
184
+ id: 'a',
185
+ fieldId: 'a',
186
+ data: {
187
+ options: [{
188
+ value: SELECTED_VALUE,
189
+ nested: [{
190
+ id: NESTED_ID
191
+ }]
192
+ }]
193
+ }
194
+ };
195
+ var ROW = (0, _getCYARow.default)(PAGE, COMPONENT, function () {});
196
+ expect(ROW.component.data.options[0].nested[0].value).toBeUndefined();
197
+ });
174
198
  });
175
199
  });
176
200
  });
@@ -15,18 +15,6 @@ var _showComponentCYA = _interopRequireDefault(require("./showComponentCYA"));
15
15
 
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
 
18
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
19
-
20
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
21
-
22
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
23
-
24
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
25
-
26
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
27
-
28
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
29
-
30
18
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
31
19
 
32
20
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
@@ -76,7 +64,7 @@ var getCYARowsForCollection = function getCYARowsForCollection(page, collection,
76
64
  var labelCount = (collection.countOffset || 0) + index + 1;
77
65
  var full_path = "".concat(collection.full_path || collection.fieldId, "[").concat(index, "]");
78
66
  var container = getContainerForItem(collection, item, labelCount, full_path);
79
- return [getTitleRowForItem(collection, item, page.id, labelCount, full_path)].concat(_toConsumableArray((0, _getCYARowsForContainer.default)(page, container, item, onAction)));
67
+ return [getTitleRowForItem(collection, item, page.id, labelCount, full_path)].concat((0, _getCYARowsForContainer.default)(page, container, item, onAction));
80
68
  }).filter(function (r) {
81
69
  return !!r;
82
70
  });
@@ -7,18 +7,6 @@ exports.default = exports.JSON_ONLY_PROPERTIES = void 0;
7
7
 
8
8
  function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
9
9
 
10
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
11
-
12
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
-
14
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
15
-
16
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
17
-
18
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
19
-
20
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
21
-
22
10
  var JSON_ONLY_PROPERTIES = ['source', 'use', 'show_when', 'options', 'additionalValidation', 'full_path', 'formData'];
23
11
  /**
24
12
  * This method removes and properties that are entirely specific to the JSON
@@ -36,7 +24,7 @@ exports.JSON_ONLY_PROPERTIES = JSON_ONLY_PROPERTIES;
36
24
 
37
25
  var cleanAttributes = function cleanAttributes(options) {
38
26
  var alsoRemove = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
39
- var removeKeys = Array.isArray(alsoRemove) ? [].concat(JSON_ONLY_PROPERTIES, _toConsumableArray(alsoRemove)) : JSON_ONLY_PROPERTIES;
27
+ var removeKeys = Array.isArray(alsoRemove) ? [].concat(JSON_ONLY_PROPERTIES, alsoRemove) : JSON_ONLY_PROPERTIES;
40
28
 
41
29
  if (options && _typeof(options) === 'object') {
42
30
  return Object.keys(options).reduce(function (obj, key) {
@@ -114,6 +114,11 @@ var getTime = function getTime(config) {
114
114
  return /*#__PURE__*/_react.default.createElement(_copReactComponents.TimeInput, attrs);
115
115
  };
116
116
 
117
+ var getWarningText = function getWarningText(config) {
118
+ var attrs = (0, _cleanAttributes.default)(config);
119
+ return /*#__PURE__*/_react.default.createElement(_copReactComponents.WarningText, attrs, config.content);
120
+ };
121
+
117
122
  var getComponentByType = function getComponentByType(config) {
118
123
  switch (config.type) {
119
124
  case _models.ComponentTypes.HTML:
@@ -151,6 +156,9 @@ var getComponentByType = function getComponentByType(config) {
151
156
  case _models.ComponentTypes.FILE:
152
157
  return getFileUpload(config);
153
158
 
159
+ case _models.ComponentTypes.WARNING:
160
+ return getWarningText(config);
161
+
154
162
  default:
155
163
  {
156
164
  return null;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ var _react = require("@testing-library/react");
4
+
5
+ var _models = require("../../../models");
6
+
7
+ var _getComponent = _interopRequireDefault(require("../getComponent"));
8
+
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+
11
+ // Global imports
12
+ // Local imports
13
+ describe('utils.Component.get', function () {
14
+ it('should return an appropriately rendered warning-text component', function () {
15
+ var ID = 'test-id';
16
+ var CONTENT = 'Warning Text';
17
+ var COMPONENT = {
18
+ type: _models.ComponentTypes.WARNING,
19
+ content: CONTENT,
20
+ 'data-testid': ID
21
+ };
22
+
23
+ var _render = (0, _react.render)((0, _getComponent.default)(COMPONENT)),
24
+ container = _render.container;
25
+
26
+ var warningText = (0, _react.getByTestId)(container, ID);
27
+ expect(warningText.innerHTML).toContain(CONTENT);
28
+ expect(warningText.tagName).toEqual('DIV');
29
+ expect(warningText.classList).toContain('govuk-warning-text');
30
+ });
31
+ });
@@ -8,18 +8,7 @@ var _getEditableComponents = _interopRequireDefault(require("./getEditableCompon
8
8
 
9
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
10
 
11
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
12
-
13
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
14
-
15
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
16
-
17
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
18
-
19
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
20
-
21
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
22
-
11
+ // Local imports
23
12
  describe('utils.Container.getEditableComponents', function () {
24
13
  var HTML = {
25
14
  type: 'html',
@@ -130,13 +119,13 @@ describe('utils.Container.getEditableComponents', function () {
130
119
  });
131
120
 
132
121
  var NON_EDITABLE_COMPONENTS = [HTML, INSET_TEXT, HEADING];
133
- var COMPONENTS = [].concat(_toConsumableArray(EDITABLE_COMPONENTS), NON_EDITABLE_COMPONENTS, [{
122
+ var COMPONENTS = [].concat(EDITABLE_COMPONENTS, NON_EDITABLE_COMPONENTS, [{
134
123
  type: _models.ComponentTypes.CONTAINER,
135
124
  id: 'inner',
136
- components: [].concat(_toConsumableArray(EDITABLE_COMPONENTS), NON_EDITABLE_COMPONENTS, [{
125
+ components: [].concat(EDITABLE_COMPONENTS, NON_EDITABLE_COMPONENTS, [{
137
126
  type: _models.ComponentTypes.CONTAINER,
138
127
  id: 'inner-inner',
139
- components: [].concat(NON_EDITABLE_COMPONENTS, _toConsumableArray(EDITABLE_COMPONENTS))
128
+ components: [].concat(NON_EDITABLE_COMPONENTS, EDITABLE_COMPONENTS)
140
129
  }])
141
130
  }]);
142
131
  var RESULT = (0, _getEditableComponents.default)({
@@ -15,6 +15,10 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
15
15
 
16
16
  var interpolateOptions = function interpolateOptions(config, options) {
17
17
  return options.map(function (opt) {
18
+ if (typeof opt === 'string') {
19
+ return opt;
20
+ }
21
+
18
22
  return _objectSpread(_objectSpread({}, opt), {}, {
19
23
  value: _copReactComponents.Utils.interpolateString(opt.value, config.formData),
20
24
  label: _copReactComponents.Utils.interpolateString(opt.label, config.formData)
@@ -88,7 +88,12 @@ var validateComponent = function validateComponent(component, outerData, formDat
88
88
  }, formData));
89
89
  }
90
90
  });
91
- return nestedErrors;
91
+
92
+ if (nestedErrors.length > 0) {
93
+ return nestedErrors;
94
+ }
95
+
96
+ break;
92
97
 
93
98
  default:
94
99
  break;
@@ -220,7 +220,7 @@ describe('utils.Validate.Component', function () {
220
220
  }]
221
221
  }
222
222
  };
223
- expect((0, _validateComponent.default)(COMPONENT, undefined, FORMDATA)).toEqual([]);
223
+ expect((0, _validateComponent.default)(COMPONENT, undefined, FORMDATA)).toBeUndefined();
224
224
  });
225
225
  it('should return an error when the radio component contains nested components with errors', function () {
226
226
  var NESTED_ID = 'nestedId';
@@ -261,7 +261,7 @@ describe('utils.Validate.Component', function () {
261
261
  }]
262
262
  }
263
263
  };
264
- expect((0, _validateComponent.default)(COMPONENT, undefined, {})).toEqual([]);
264
+ expect((0, _validateComponent.default)(COMPONENT, undefined, {})).toBeUndefined();
265
265
  });
266
266
  });
267
267
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ukhomeoffice/cop-react-form-renderer",
3
- "version": "3.2.4",
3
+ "version": "3.3.1-alpha",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "clean": "rimraf dist",
@@ -16,7 +16,7 @@
16
16
  "post-compile": "rimraf dist/*.test.* dist/**/*.test.* dist/**/*.stories.* dist/docs dist/assets"
17
17
  },
18
18
  "dependencies": {
19
- "@ukhomeoffice/cop-react-components": "1.7.4",
19
+ "@ukhomeoffice/cop-react-components": "1.8.0",
20
20
  "axios": "^0.21.1",
21
21
  "dayjs": "^1.11.0",
22
22
  "govuk-frontend": "^3.13.0",