@ukhomeoffice/cop-react-form-renderer 5.51.0 → 6.0.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.
@@ -1,5 +1,5 @@
1
- @import "node_modules/govuk-frontend/govuk/_base";
2
- @import "node_modules/govuk-frontend/govuk/overrides/spacing";
1
+ @import "govuk-frontend/dist/govuk/_base";
2
+ @import "govuk-frontend/dist/govuk/overrides/spacing";
3
3
 
4
4
  .govuk-link {
5
5
  @include govuk-font($size: 19);
@@ -29,6 +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;
32
33
  var page = _ref.page,
33
34
  onCollectionChange = _ref.onCollectionChange,
34
35
  onAction = _ref.onAction,
@@ -109,6 +110,14 @@ var CollectionPage = function CollectionPage(_ref) {
109
110
  reportChange([].concat(data.slice(0, activeIndex), [_objectSpread(_objectSpread({}, data[activeIndex]), {}, _defineProperty({}, target.name, target.value))], data.slice(activeIndex + 1)));
110
111
  }
111
112
  };
113
+ // There is a bug where page.formData is not available on the first render.
114
+ // This results in any Collections on this page passing up their default value
115
+ // of []. This is then used to create a new entry in the Page Collection in patch which
116
+ // on the next page action wipes out existing entries in the Page Collection.
117
+ // We can fix it by waiting for page.formData to be defined and have keys.
118
+ if ((_page$collection = page.collection) !== null && _page$collection !== void 0 && _page$collection.waitForFormData && page.formData && Object.keys(page.formData).length === 0) {
119
+ return null;
120
+ }
112
121
  return /*#__PURE__*/_react.default.createElement(_FormPage.default, {
113
122
  page: _objectSpread(_objectSpread({}, page), {}, {
114
123
  formData: _objectSpread(_objectSpread(_objectSpread({}, page.formData), data[activeIndex]), {}, _defineProperty({}, "".concat(currentCollectionName, "ActiveIndex"), activeIndex)),
@@ -133,7 +142,8 @@ CollectionPage.propTypes = {
133
142
  id: _propTypes.default.string.isRequired,
134
143
  title: _propTypes.default.string,
135
144
  collection: _propTypes.default.shape({
136
- name: _propTypes.default.string.isRequired
145
+ name: _propTypes.default.string.isRequired,
146
+ waitForFormData: _propTypes.default.bool
137
147
  }).isRequired,
138
148
  components: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.object])).isRequired,
139
149
  actions: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.shape({}), _propTypes.default.string])),
@@ -11,6 +11,8 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
11
11
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
14
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
15
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
14
16
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
15
17
  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); } }
16
18
  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); }); }; }
@@ -232,15 +234,36 @@ describe('components.CollectionPage', function () {
232
234
  }
233
235
  }, _callee);
234
236
  })));
235
- it('should render a submit page correctly and submit action button has interpolated label', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
236
- var _renderWithValidation2, container, page, FORM_DATA, heading;
237
+ it('should render nothing when there is no formData and page.collection.waitForFormData is true', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
238
+ var _renderWithValidation2, container;
237
239
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
238
240
  while (1) switch (_context2.prev = _context2.next) {
239
241
  case 0:
240
242
  _renderWithValidation2 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_CollectionPage.default, {
241
- page: PAGE_WITH_BUTTON_ACTIONS,
243
+ page: _objectSpread(_objectSpread({}, PAGE), {}, {
244
+ collection: _objectSpread(_objectSpread({}, PAGE.collection), {}, {
245
+ waitForFormData: true
246
+ }),
247
+ formData: {}
248
+ }),
242
249
  onAction: ON_ACTION
243
250
  })), container = _renderWithValidation2.container;
251
+ expect(container.childNodes.length).toEqual(0);
252
+ case 2:
253
+ case "end":
254
+ return _context2.stop();
255
+ }
256
+ }, _callee2);
257
+ })));
258
+ it('should render a submit page correctly and submit action button has interpolated label', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
259
+ var _renderWithValidation3, container, page, FORM_DATA, heading;
260
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
261
+ while (1) switch (_context3.prev = _context3.next) {
262
+ case 0:
263
+ _renderWithValidation3 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_CollectionPage.default, {
264
+ page: PAGE_WITH_BUTTON_ACTIONS,
265
+ onAction: ON_ACTION
266
+ })), container = _renderWithValidation3.container;
244
267
  page = container.childNodes[0];
245
268
  FORM_DATA = PAGE_WITH_BUTTON_ACTIONS.formData;
246
269
  expect(page.tagName).toEqual('DIV');
@@ -253,37 +276,37 @@ describe('components.CollectionPage', function () {
253
276
  checkFormButtonGroup(page.childNodes[3], ['Next Payment', 'Go back User Details']);
254
277
  case 11:
255
278
  case "end":
256
- return _context2.stop();
279
+ return _context3.stop();
257
280
  }
258
- }, _callee2);
281
+ }, _callee3);
259
282
  })));
260
- it('should render only the conditionally shown button', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
261
- var _renderWithValidation3, container, page;
262
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
263
- while (1) switch (_context3.prev = _context3.next) {
283
+ it('should render only the conditionally shown button', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
284
+ var _renderWithValidation4, container, page;
285
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
286
+ while (1) switch (_context4.prev = _context4.next) {
264
287
  case 0:
265
- _renderWithValidation3 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_CollectionPage.default, {
288
+ _renderWithValidation4 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_CollectionPage.default, {
266
289
  page: PAGE_WITH_CONDITIONAL_BUTTONS,
267
290
  onAction: ON_ACTION
268
- })), container = _renderWithValidation3.container;
291
+ })), container = _renderWithValidation4.container;
269
292
  page = container.childNodes[0];
270
293
  checkFormButtonGroup(page.childNodes[3], ['Button 2']); // Just the second button shown
271
294
  case 3:
272
295
  case "end":
273
- return _context3.stop();
296
+ return _context4.stop();
274
297
  }
275
- }, _callee3);
298
+ }, _callee4);
276
299
  })));
277
300
  describe('with a top-level Collection Page', function () {
278
- it('should handle a page change appropriately', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
279
- var _renderWithValidation4, container, page, input, NEW_VALUE, EVENT;
280
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
281
- while (1) switch (_context4.prev = _context4.next) {
301
+ it('should handle a page change appropriately', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
302
+ var _renderWithValidation5, container, page, input, NEW_VALUE, EVENT;
303
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
304
+ while (1) switch (_context5.prev = _context5.next) {
282
305
  case 0:
283
- _renderWithValidation4 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_CollectionPage.default, {
306
+ _renderWithValidation5 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_CollectionPage.default, {
284
307
  page: PAGE,
285
308
  onAction: ON_ACTION
286
- })), container = _renderWithValidation4.container;
309
+ })), container = _renderWithValidation5.container;
287
310
  page = container.childNodes[0];
288
311
  expect(page.tagName).toEqual('DIV');
289
312
 
@@ -302,19 +325,19 @@ describe('components.CollectionPage', function () {
302
325
  expect(PAGE.formData[COLLECTION_NAME][0].text).toEqual(NEW_VALUE);
303
326
  case 8:
304
327
  case "end":
305
- return _context4.stop();
328
+ return _context5.stop();
306
329
  }
307
- }, _callee4);
330
+ }, _callee5);
308
331
  })));
309
- it('should handle a page action appropriately, updating the active entry if there is one', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
310
- var _renderWithValidation5, container, page, input, NEW_VALUE, CHANGE_EVENT, button;
311
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
312
- while (1) switch (_context5.prev = _context5.next) {
332
+ it('should handle a page action appropriately, updating the active entry if there is one', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
333
+ var _renderWithValidation6, container, page, input, NEW_VALUE, CHANGE_EVENT, button;
334
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
335
+ while (1) switch (_context6.prev = _context6.next) {
313
336
  case 0:
314
- _renderWithValidation5 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_CollectionPage.default, {
337
+ _renderWithValidation6 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_CollectionPage.default, {
315
338
  page: PAGE,
316
339
  onAction: ON_ACTION
317
- })), container = _renderWithValidation5.container;
340
+ })), container = _renderWithValidation6.container;
318
341
  page = container.childNodes[0]; // Change the input.
319
342
  input = page.childNodes[1].childNodes[2];
320
343
  NEW_VALUE = "".concat(VALUE, ".");
@@ -340,21 +363,21 @@ describe('components.CollectionPage', function () {
340
363
  }]));
341
364
  case 12:
342
365
  case "end":
343
- return _context5.stop();
366
+ return _context6.stop();
344
367
  }
345
- }, _callee5);
368
+ }, _callee6);
346
369
  })));
347
- it('should handle a page action appropriately, creating a new active entry if there isn\'t one', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
348
- var _renderWithValidation6, container, page, input, NEW_VALUE, CHANGE_EVENT, button;
349
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
350
- while (1) switch (_context6.prev = _context6.next) {
370
+ it('should handle a page action appropriately, creating a new active entry if there isn\'t one', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
371
+ var _renderWithValidation7, container, page, input, NEW_VALUE, CHANGE_EVENT, button;
372
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
373
+ while (1) switch (_context7.prev = _context7.next) {
351
374
  case 0:
352
375
  // Make sure there is no active entry.
353
376
  PAGE.formData["".concat(COLLECTION_NAME, "ActiveId")] = 'newId';
354
- _renderWithValidation6 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_CollectionPage.default, {
377
+ _renderWithValidation7 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_CollectionPage.default, {
355
378
  page: PAGE,
356
379
  onAction: ON_ACTION
357
- })), container = _renderWithValidation6.container;
380
+ })), container = _renderWithValidation7.container;
358
381
  page = container.childNodes[0]; // Change the input.
359
382
  input = page.childNodes[1].childNodes[2];
360
383
  NEW_VALUE = "".concat(VALUE, ".");
@@ -377,9 +400,9 @@ describe('components.CollectionPage', function () {
377
400
  expect(ON_ACTION_CALLS[0].action).toEqual(_models.PageAction.DEFAULTS.submit);
378
401
  case 13:
379
402
  case "end":
380
- return _context6.stop();
403
+ return _context7.stop();
381
404
  }
382
- }, _callee6);
405
+ }, _callee7);
383
406
  })));
384
407
  });
385
408
  describe('with a nested Collection Page', function () {
@@ -417,15 +440,15 @@ describe('components.CollectionPage', function () {
417
440
  };
418
441
  ON_ACTION_CALLS.length = 0;
419
442
  });
420
- it('should handle a page change appropriately', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
421
- var _renderWithValidation7, container, page, input, NEW_VALUE, EVENT;
422
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
423
- while (1) switch (_context7.prev = _context7.next) {
443
+ it('should handle a page change appropriately', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
444
+ var _renderWithValidation8, container, page, input, NEW_VALUE, EVENT;
445
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
446
+ while (1) switch (_context8.prev = _context8.next) {
424
447
  case 0:
425
- _renderWithValidation7 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_CollectionPage.default, {
448
+ _renderWithValidation8 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_CollectionPage.default, {
426
449
  page: NESTED_PAGE,
427
450
  onAction: ON_ACTION
428
- })), container = _renderWithValidation7.container;
451
+ })), container = _renderWithValidation8.container;
429
452
  page = container.childNodes[0];
430
453
  expect(page.tagName).toEqual('DIV');
431
454
 
@@ -444,19 +467,19 @@ describe('components.CollectionPage', function () {
444
467
  expect(NESTED_PAGE.formData.parent[0].child[0].text).toEqual(NEW_VALUE);
445
468
  case 8:
446
469
  case "end":
447
- return _context7.stop();
470
+ return _context8.stop();
448
471
  }
449
- }, _callee7);
472
+ }, _callee8);
450
473
  })));
451
- it('should handle a page action appropriately, updating the active entry if there is one', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
452
- var _renderWithValidation8, container, page, input, NEW_VALUE, CHANGE_EVENT, button;
453
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
454
- while (1) switch (_context8.prev = _context8.next) {
474
+ it('should handle a page action appropriately, updating the active entry if there is one', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
475
+ var _renderWithValidation9, container, page, input, NEW_VALUE, CHANGE_EVENT, button;
476
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
477
+ while (1) switch (_context9.prev = _context9.next) {
455
478
  case 0:
456
- _renderWithValidation8 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_CollectionPage.default, {
479
+ _renderWithValidation9 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_CollectionPage.default, {
457
480
  page: NESTED_PAGE,
458
481
  onAction: ON_ACTION
459
- })), container = _renderWithValidation8.container;
482
+ })), container = _renderWithValidation9.container;
460
483
  page = container.childNodes[0]; // Change the input.
461
484
  input = page.childNodes[1].childNodes[2];
462
485
  NEW_VALUE = "".concat(VALUE, ".");
@@ -487,21 +510,21 @@ describe('components.CollectionPage', function () {
487
510
  });
488
511
  case 12:
489
512
  case "end":
490
- return _context8.stop();
513
+ return _context9.stop();
491
514
  }
492
- }, _callee8);
515
+ }, _callee9);
493
516
  })));
494
- it('should handle a page action appropriately, creating a new active entry if there isn\'t one', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
495
- var _renderWithValidation9, container, page, input, NEW_VALUE, CHANGE_EVENT, button;
496
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
497
- while (1) switch (_context9.prev = _context9.next) {
517
+ it('should handle a page action appropriately, creating a new active entry if there isn\'t one', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
518
+ var _renderWithValidation10, container, page, input, NEW_VALUE, CHANGE_EVENT, button;
519
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
520
+ while (1) switch (_context10.prev = _context10.next) {
498
521
  case 0:
499
522
  // Make sure there is no active entry.
500
523
  NESTED_PAGE.formData.childActiveId = 'newId';
501
- _renderWithValidation9 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_CollectionPage.default, {
524
+ _renderWithValidation10 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_CollectionPage.default, {
502
525
  page: NESTED_PAGE,
503
526
  onAction: ON_ACTION
504
- })), container = _renderWithValidation9.container;
527
+ })), container = _renderWithValidation10.container;
505
528
  page = container.childNodes[0]; // Change the input.
506
529
  input = page.childNodes[1].childNodes[2];
507
530
  NEW_VALUE = "".concat(VALUE, ".");
@@ -524,9 +547,9 @@ describe('components.CollectionPage', function () {
524
547
  expect(ON_ACTION_CALLS[0].action).toEqual(_models.PageAction.DEFAULTS.submit);
525
548
  case 13:
526
549
  case "end":
527
- return _context9.stop();
550
+ return _context10.stop();
528
551
  }
529
- }, _callee9);
552
+ }, _callee10);
530
553
  })));
531
554
  });
532
555
  });
@@ -1,5 +1,5 @@
1
- @import "node_modules/govuk-frontend/govuk/_base";
2
- @import "node_modules/govuk-frontend/govuk/components/tag/_index";
1
+ @import "govuk-frontend/dist/govuk/_base";
2
+ @import "govuk-frontend/dist/govuk/components/tag/_index";
3
3
 
4
4
  .hods-form-banner-strip {
5
5
  display: block;
@@ -1,4 +1,4 @@
1
- @import "node_modules/govuk-frontend/govuk/_base";
1
+ @import "govuk-frontend/dist/govuk/_base";
2
2
 
3
3
  .hods-form-summary-card.hods-form-summary-card--nested {
4
4
  box-shadow: none;
@@ -1,6 +1,6 @@
1
1
  $govuk-font-family: 'Roboto', arial, sans-serif;
2
2
 
3
- @import "node_modules/govuk-frontend/govuk/_base";
3
+ @import "govuk-frontend/dist/govuk/_base";
4
4
 
5
5
  .hods-form-confirmation {
6
6
  background-color: #E3E3E3;
@@ -1,6 +1,6 @@
1
1
  $govuk-font-family: 'Roboto', arial, sans-serif;
2
2
 
3
- @import "node_modules/govuk-frontend/govuk/_base";
3
+ @import "govuk-frontend/dist/govuk/_base";
4
4
 
5
5
  .govuk-summary-list {
6
6
  @include govuk-font($size: 19);
@@ -159,7 +159,7 @@ var SummaryCard = function SummaryCard(_ref) {
159
159
  }), /*#__PURE__*/_react.default.createElement("div", {
160
160
  id: "".concat(id, ".titleText"),
161
161
  className: classes('header-content-title')
162
- }, _copReactComponents.Utils.interpolateString(config.title || DEFAULT_TITLE, entryData)), config.details && /*#__PURE__*/_react.default.createElement("div", {
162
+ }, _utils.default.FormPage.getTitle(config.title, entryData)), config.details && /*#__PURE__*/_react.default.createElement("div", {
163
163
  id: "".concat(id, ".titleDetail"),
164
164
  className: classes('header-content-detail')
165
165
  }, _copReactComponents.Utils.interpolateString(config.details, entryData))), /*#__PURE__*/_react.default.createElement("div", {
@@ -208,6 +208,9 @@ var SummaryCard = function SummaryCard(_ref) {
208
208
  var allPageComponents = _utils.default.Component.elevateNested(childPage === null || childPage === void 0 ? void 0 : childPage.components, entryData);
209
209
  return (_childPage$summaryLay = childPage.summaryLayout) === null || _childPage$summaryLay === void 0 ? void 0 : _childPage$summaryLay.sections.map(function (section) {
210
210
  var _section$fields;
211
+ if (section.show_when && !_utils.default.Condition.meetsAll(section.show_when, _objectSpread(_objectSpread({}, formData), entryData))) {
212
+ return null;
213
+ }
211
214
  return /*#__PURE__*/_react.default.createElement("div", {
212
215
  key: section.title,
213
216
  className: classes('section')
@@ -233,6 +236,8 @@ var SummaryCard = function SummaryCard(_ref) {
233
236
  }));
234
237
  })));
235
238
  });
239
+ }).filter(function (e) {
240
+ return !!e;
236
241
  }))));
237
242
  };
238
243
  SummaryCard.propTypes = {
@@ -1,6 +1,6 @@
1
1
  $govuk-font-family: 'Roboto', arial, sans-serif;
2
2
 
3
- @import "node_modules/govuk-frontend/govuk/_base";
3
+ @import "govuk-frontend/dist/govuk/_base";
4
4
 
5
5
  .govuk-grid-column-two-thirds:has(.hods-form-summary-card) {
6
6
  width: 100% !important;