@ukhomeoffice/cop-react-form-renderer 2.8.3 → 2.9.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.
Files changed (32) hide show
  1. package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +1 -1
  2. package/dist/components/FormComponent/FormComponent.js +2 -1
  3. package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +7 -0
  4. package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +2 -2
  5. package/dist/components/SummaryList/GroupAction.js +5 -1
  6. package/dist/components/SummaryList/SummaryList.js +1 -1
  7. package/dist/json/group.json +1 -17
  8. package/dist/json/port.json +346 -0
  9. package/dist/json/sublocation.json +859 -0
  10. package/dist/json/terminal.json +81 -0
  11. package/dist/models/ComponentTypes.js +2 -0
  12. package/dist/utils/CheckYourAnswers/getCYARow.js +12 -0
  13. package/dist/utils/CheckYourAnswers/getCYARow.test.js +28 -1
  14. package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +1 -0
  15. package/dist/utils/Component/cleanAttributes.js +1 -1
  16. package/dist/utils/Component/getComponent.js +36 -3
  17. package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +92 -0
  18. package/dist/utils/Meta/constants.js +10 -0
  19. package/dist/utils/Meta/documents/getDocuments.js +18 -0
  20. package/dist/utils/Meta/documents/getDocuments.test.js +43 -0
  21. package/dist/utils/Meta/documents/index.js +23 -0
  22. package/dist/utils/Meta/documents/setDocumentForField.js +36 -0
  23. package/dist/utils/Meta/documents/setDocumentForField.test.js +49 -0
  24. package/dist/utils/Meta/index.js +21 -0
  25. package/dist/utils/Validate/validateCollection.js +42 -0
  26. package/dist/utils/Validate/validateCollection.test.js +74 -0
  27. package/dist/utils/Validate/validateComponent.js +67 -48
  28. package/dist/utils/Validate/validateComponent.test.js +247 -188
  29. package/dist/utils/Validate/validateContainer.js +29 -0
  30. package/dist/utils/Validate/validateContainer.test.js +68 -0
  31. package/dist/utils/index.js +4 -1
  32. package/package.json +2 -2
@@ -416,7 +416,7 @@ describe('components', function () {
416
416
  groupedComponent = cya.childNodes[10];
417
417
  keyGroup = groupedComponent.childNodes[0].childNodes[0].childNodes[0];
418
418
  expect(keyGroup.tagName).toEqual('DT');
419
- expect(keyGroup.textContent).toEqual('Address details (optional)');
419
+ expect(keyGroup.textContent).toEqual('Address details');
420
420
  valueGroup = groupedComponent.childNodes[0].childNodes[0].childNodes[1];
421
421
  expect(valueGroup.childNodes.length).toEqual(4);
422
422
  expect(valueGroup.tagName).toEqual('DD');
@@ -208,7 +208,8 @@ var FormComponent = function FormComponent(_ref3) {
208
208
  hint: component.hint || '',
209
209
  options: options,
210
210
  value: value || defaultValue,
211
- onChange: onComponentChange
211
+ onChange: onComponentChange,
212
+ formData: formData
212
213
  }), wrap, hooks.onGetComponent);
213
214
  };
214
215
 
@@ -19,7 +19,14 @@ var getSubmissionStatus = function getSubmissionStatus(formType, pages, currentP
19
19
 
20
20
  if (currentPageId === (_models.FormPages.CYA || 'submitForm') && isCompleted) {
21
21
  formStatus.tasks[currentTask.name].complete = true;
22
+ } else if ((action === null || action === void 0 ? void 0 : action.type) === _models.PageAction.TYPES.SAVE_AND_NAVIGATE) {
23
+ console.log('pg action sc');
24
+ formStatus.tasks[currentTask.name] = {
25
+ complete: false,
26
+ currentPage: (0, _getNextPageId.default)(formType, pages, currentPageId, action, formData)
27
+ };
22
28
  } else {
29
+ console.log('got to else stmt');
23
30
  formStatus.tasks[currentTask.name] = {
24
31
  complete: false,
25
32
  currentPage: currentPageId
@@ -222,7 +222,7 @@ describe('components', function () {
222
222
  })
223
223
  });
224
224
  });
225
- it("should update the current task with the current page and a false complete flag if the current page is not '".concat(_models.FormPages.CYA, "'"), function () {
225
+ it("should update the current task with the current page and a false complete flag if the next page is not '".concat(_models.FormPages.CYA, "'"), function () {
226
226
  var CURRENT_PAGE_ID = 'eventDate';
227
227
  var TASK_NAME = 'taskName';
228
228
  var CURRENT_TASK = {
@@ -236,7 +236,7 @@ describe('components', function () {
236
236
  expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, CURRENT_PAGE_ID, ACTION, {}, CURRENT_TASK)).toMatchObject({
237
237
  tasks: _defineProperty({}, TASK_NAME, {
238
238
  complete: false,
239
- currentPage: CURRENT_PAGE_ID
239
+ currentPage: NEXT_PAGE_ID
240
240
  })
241
241
  });
242
242
  });
@@ -21,6 +21,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
21
21
 
22
22
  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; }
23
23
 
24
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
25
+
24
26
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
25
27
 
26
28
  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."); }
@@ -49,7 +51,9 @@ var GroupAction = function GroupAction(_ref) {
49
51
  return null;
50
52
  }
51
53
 
52
- return /*#__PURE__*/_react.default.createElement(_copReactComponents.Link, attrs, group.action.label, group.action.aria_suffix && /*#__PURE__*/_react.default.createElement("span", {
54
+ return /*#__PURE__*/_react.default.createElement(_copReactComponents.Link, _extends({}, attrs, {
55
+ "aria-label": "".concat(group.action.label, " ").concat(group.action.aria_suffix)
56
+ }), group.action.label, group.action.aria_suffix && /*#__PURE__*/_react.default.createElement("span", {
53
57
  className: "mobile-text govuk-link"
54
58
  }, ' ', "".concat(group.action.aria_suffix)));
55
59
  };
@@ -53,7 +53,7 @@ var SummaryList = function SummaryList(_ref) {
53
53
  className: classes('row')
54
54
  }, /*#__PURE__*/_react.default.createElement("dt", {
55
55
  className: classes('key')
56
- }, row.key, !((_row$component = row.component) !== null && _row$component !== void 0 && _row$component.required) && " (optional)"), /*#__PURE__*/_react.default.createElement("dd", {
56
+ }, row.key, !row.hasOwnProperty('required') && !((_row$component = row.component) !== null && _row$component !== void 0 && _row$component.required) && " (optional)", !row.hasOwnProperty('component') && row.hasOwnProperty('required') && !(row !== null && row !== void 0 && row.required) && " (optional)"), /*#__PURE__*/_react.default.createElement("dd", {
57
57
  className: classes('value')
58
58
  }, row.value), !noChangeAction && /*#__PURE__*/_react.default.createElement("dd", {
59
59
  className: classes('actions')
@@ -175,23 +175,6 @@
175
175
  "field": "addressDetails.town"
176
176
  }
177
177
  },
178
- {
179
- "id": "postCode",
180
- "fieldId": "postCode",
181
- "label": "Postcode",
182
- "type": "text",
183
- "required": true,
184
- "groupId": "addressDetails",
185
- "custom_errors": [
186
- {
187
- "type": "required",
188
- "message": "Please enter postcode"
189
- }
190
- ],
191
- "source": {
192
- "field": "addressDetails.postCode"
193
- }
194
- },
195
178
  {
196
179
  "id": "postCode",
197
180
  "fieldId": "postCode",
@@ -378,6 +361,7 @@
378
361
  {
379
362
  "id": "address",
380
363
  "label": "Address details",
364
+ "required": true,
381
365
  "components": ["firstLineOfTheAddress", "town", "city", "postCode"]
382
366
  }
383
367
  ],
@@ -0,0 +1,346 @@
1
+ {
2
+ "data": [
3
+ {
4
+ "id": 5,
5
+ "countryid": 234,
6
+ "commandid": 27,
7
+ "locationid": null,
8
+ "name": "Abbotsbury",
9
+ "addressid": null,
10
+ "subdivision": "DOR",
11
+ "municipality": null,
12
+ "geolong": null,
13
+ "geolat": null,
14
+ "air": false,
15
+ "land": false,
16
+ "sea": true,
17
+ "rail": false,
18
+ "iata": null,
19
+ "icao": null,
20
+ "localcode": null,
21
+ "unlocode": "AOT",
22
+ "helipad": false,
23
+ "fixedpcp": null,
24
+ "portablepcp": null,
25
+ "egates": null,
26
+ "nonoperational": false,
27
+ "portsizeid": 3,
28
+ "juxtaposed": false,
29
+ "freightparcelposthub": false,
30
+ "validfrom": "2019-01-01T00:01:00.000Z",
31
+ "validto": null,
32
+ "updatedby": null
33
+ },
34
+ {
35
+ "id": 7947,
36
+ "countryid": 234,
37
+ "commandid": null,
38
+ "locationid": null,
39
+ "name": "Whitehall",
40
+ "addressid": null,
41
+ "subdivision": "NA",
42
+ "municipality": null,
43
+ "geolong": "-1.14934",
44
+ "geolat": "51.79353",
45
+ "air": true,
46
+ "land": false,
47
+ "sea": false,
48
+ "rail": false,
49
+ "iata": null,
50
+ "icao": null,
51
+ "localcode": null,
52
+ "unlocode": null,
53
+ "helipad": false,
54
+ "fixedpcp": null,
55
+ "portablepcp": null,
56
+ "egates": null,
57
+ "nonoperational": false,
58
+ "portsizeid": 3,
59
+ "juxtaposed": false,
60
+ "freightparcelposthub": false,
61
+ "validfrom": "2019-01-01T00:01:00.000Z",
62
+ "validto": null,
63
+ "updatedby": null
64
+ },
65
+ {
66
+ "id": 9887,
67
+ "countryid": 234,
68
+ "commandid": 20,
69
+ "locationid": null,
70
+ "name": "The Manor House Castle Combe",
71
+ "addressid": null,
72
+ "subdivision": "NA",
73
+ "municipality": null,
74
+ "geolong": "-2.23211",
75
+ "geolat": "51.49378",
76
+ "air": true,
77
+ "land": false,
78
+ "sea": false,
79
+ "rail": false,
80
+ "iata": null,
81
+ "icao": null,
82
+ "localcode": null,
83
+ "unlocode": null,
84
+ "helipad": true,
85
+ "fixedpcp": null,
86
+ "portablepcp": null,
87
+ "egates": null,
88
+ "nonoperational": false,
89
+ "portsizeid": 3,
90
+ "juxtaposed": false,
91
+ "freightparcelposthub": false,
92
+ "validfrom": "2019-01-01T00:01:00.000Z",
93
+ "validto": null,
94
+ "updatedby": null
95
+ },
96
+ {
97
+ "id": 13418,
98
+ "countryid": 14,
99
+ "commandid": null,
100
+ "locationid": null,
101
+ "name": "Ballast Head",
102
+ "addressid": null,
103
+ "subdivision": "SA",
104
+ "municipality": null,
105
+ "geolong": null,
106
+ "geolat": null,
107
+ "air": false,
108
+ "land": false,
109
+ "sea": true,
110
+ "rail": false,
111
+ "iata": null,
112
+ "icao": null,
113
+ "localcode": null,
114
+ "unlocode": "BAH",
115
+ "helipad": null,
116
+ "fixedpcp": null,
117
+ "portablepcp": null,
118
+ "egates": null,
119
+ "nonoperational": false,
120
+ "portsizeid": null,
121
+ "juxtaposed": false,
122
+ "freightparcelposthub": false,
123
+ "validfrom": "2019-01-01T00:01:00.000Z",
124
+ "validto": null,
125
+ "updatedby": null
126
+ },
127
+ {
128
+ "id": 17391,
129
+ "countryid": 22,
130
+ "commandid": null,
131
+ "locationid": null,
132
+ "name": "Thuin",
133
+ "addressid": null,
134
+ "subdivision": "WHT",
135
+ "municipality": null,
136
+ "geolong": "4.28333",
137
+ "geolat": "50.33333",
138
+ "air": false,
139
+ "land": false,
140
+ "sea": true,
141
+ "rail": false,
142
+ "iata": null,
143
+ "icao": null,
144
+ "localcode": null,
145
+ "unlocode": "THU",
146
+ "helipad": null,
147
+ "fixedpcp": null,
148
+ "portablepcp": null,
149
+ "egates": null,
150
+ "nonoperational": false,
151
+ "portsizeid": null,
152
+ "juxtaposed": false,
153
+ "freightparcelposthub": false,
154
+ "validfrom": "2019-01-01T00:01:00.000Z",
155
+ "validto": null,
156
+ "updatedby": null
157
+ },
158
+ {
159
+ "id": 27077,
160
+ "countryid": 47,
161
+ "commandid": null,
162
+ "locationid": null,
163
+ "name": "Pudongxinqu Pt",
164
+ "addressid": null,
165
+ "subdivision": "31",
166
+ "municipality": null,
167
+ "geolong": null,
168
+ "geolat": null,
169
+ "air": false,
170
+ "land": false,
171
+ "sea": true,
172
+ "rail": false,
173
+ "iata": null,
174
+ "icao": null,
175
+ "localcode": null,
176
+ "unlocode": "PDX",
177
+ "helipad": null,
178
+ "fixedpcp": null,
179
+ "portablepcp": null,
180
+ "egates": null,
181
+ "nonoperational": false,
182
+ "portsizeid": null,
183
+ "juxtaposed": false,
184
+ "freightparcelposthub": false,
185
+ "validfrom": "2019-01-01T00:01:00.000Z",
186
+ "validto": null,
187
+ "updatedby": null
188
+ },
189
+ {
190
+ "id": 52061,
191
+ "countryid": 80,
192
+ "commandid": null,
193
+ "locationid": null,
194
+ "name": "Jouques",
195
+ "addressid": null,
196
+ "subdivision": "13",
197
+ "municipality": null,
198
+ "geolong": "5.63333",
199
+ "geolat": "43.63333",
200
+ "air": false,
201
+ "land": false,
202
+ "sea": true,
203
+ "rail": false,
204
+ "iata": null,
205
+ "icao": null,
206
+ "localcode": null,
207
+ "unlocode": "QUU",
208
+ "helipad": null,
209
+ "fixedpcp": null,
210
+ "portablepcp": null,
211
+ "egates": null,
212
+ "nonoperational": false,
213
+ "portsizeid": null,
214
+ "juxtaposed": false,
215
+ "freightparcelposthub": false,
216
+ "validfrom": "2019-01-01T00:01:00.000Z",
217
+ "validto": null,
218
+ "updatedby": null
219
+ },
220
+ {
221
+ "id": 63838,
222
+ "countryid": 107,
223
+ "commandid": null,
224
+ "locationid": null,
225
+ "name": "Panjang",
226
+ "addressid": null,
227
+ "subdivision": null,
228
+ "municipality": null,
229
+ "geolong": null,
230
+ "geolat": null,
231
+ "air": false,
232
+ "land": false,
233
+ "sea": true,
234
+ "rail": false,
235
+ "iata": null,
236
+ "icao": null,
237
+ "localcode": null,
238
+ "unlocode": "PNJ",
239
+ "helipad": null,
240
+ "fixedpcp": null,
241
+ "portablepcp": null,
242
+ "egates": null,
243
+ "nonoperational": false,
244
+ "portsizeid": null,
245
+ "juxtaposed": false,
246
+ "freightparcelposthub": false,
247
+ "validfrom": "2019-01-01T00:01:00.000Z",
248
+ "validto": null,
249
+ "updatedby": null
250
+ },
251
+ {
252
+ "id": 78550,
253
+ "countryid": 155,
254
+ "commandid": null,
255
+ "locationid": null,
256
+ "name": "Hoek van Holland",
257
+ "addressid": null,
258
+ "subdivision": null,
259
+ "municipality": null,
260
+ "geolong": null,
261
+ "geolat": null,
262
+ "air": false,
263
+ "land": false,
264
+ "sea": true,
265
+ "rail": false,
266
+ "iata": null,
267
+ "icao": null,
268
+ "localcode": null,
269
+ "unlocode": "HVH",
270
+ "helipad": null,
271
+ "fixedpcp": null,
272
+ "portablepcp": null,
273
+ "egates": null,
274
+ "nonoperational": false,
275
+ "portsizeid": null,
276
+ "juxtaposed": false,
277
+ "freightparcelposthub": false,
278
+ "validfrom": "2019-01-01T00:01:00.000Z",
279
+ "validto": null,
280
+ "updatedby": null
281
+ },
282
+ {
283
+ "id": 102163,
284
+ "countryid": 238,
285
+ "commandid": null,
286
+ "locationid": null,
287
+ "name": "Lolita",
288
+ "addressid": null,
289
+ "subdivision": "TX",
290
+ "municipality": null,
291
+ "geolong": "-96.53333",
292
+ "geolat": "28.83333",
293
+ "air": false,
294
+ "land": false,
295
+ "sea": true,
296
+ "rail": false,
297
+ "iata": null,
298
+ "icao": null,
299
+ "localcode": null,
300
+ "unlocode": "OIT",
301
+ "helipad": null,
302
+ "fixedpcp": null,
303
+ "portablepcp": null,
304
+ "egates": null,
305
+ "nonoperational": false,
306
+ "portsizeid": null,
307
+ "juxtaposed": false,
308
+ "freightparcelposthub": false,
309
+ "validfrom": "2019-01-01T00:01:00.000Z",
310
+ "validto": null,
311
+ "updatedby": null
312
+ },
313
+ {
314
+ "id": 113626,
315
+ "countryid": 234,
316
+ "commandid": 6,
317
+ "locationid": null,
318
+ "name": "Rotterdam Central Station",
319
+ "addressid": null,
320
+ "subdivision": "ZH",
321
+ "municipality": null,
322
+ "geolong": "4.469093",
323
+ "geolat": "51.92468",
324
+ "air": false,
325
+ "land": false,
326
+ "sea": false,
327
+ "rail": true,
328
+ "iata": null,
329
+ "icao": null,
330
+ "localcode": null,
331
+ "unlocode": "RTM",
332
+ "helipad": null,
333
+ "fixedpcp": null,
334
+ "portablepcp": null,
335
+ "egates": null,
336
+ "nonoperational": false,
337
+ "portsizeid": 2,
338
+ "juxtaposed": true,
339
+ "freightparcelposthub": false,
340
+ "validfrom": "2022-01-11T00:00:01.000Z",
341
+ "validto": null,
342
+ "updatedby": "Mohammed Abdul Odud"
343
+ }
344
+ ]
345
+ }
346
+