@ukhomeoffice/cop-react-form-renderer 7.1.1-ipm-accessibility-gamma → 7.2.0-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.
package/LICENCE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 UKHomeOffice
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -32,7 +32,6 @@ const DEFAULT_MARGIN_BOTTOM = exports.DEFAULT_MARGIN_BOTTOM = 9;
32
32
  const CheckYourAnswers = _ref => {
33
33
  let {
34
34
  title,
35
- titleSize,
36
35
  pages: _pages,
37
36
  actions,
38
37
  onAction,
@@ -146,8 +145,7 @@ const CheckYourAnswers = _ref => {
146
145
  };
147
146
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
148
147
  className: DEFAULT_CLASS,
149
- children: [title && !hide_title && /*#__PURE__*/(0, _jsxRuntime.jsx)(_copReactComponents.Heading, {
150
- size: titleSize,
148
+ children: [title && !hide_title && /*#__PURE__*/(0, _jsxRuntime.jsx)(_copReactComponents.LargeHeading, {
151
149
  children: title
152
150
  }, 'heading'), errors && errors.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_copReactComponents.ErrorSummary, {
153
151
  errors: getDedupedErrors()
@@ -227,7 +225,6 @@ CheckYourAnswers.propTypes = {
227
225
  })),
228
226
  summaryListClassModifiers: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
229
227
  title: _propTypes.default.string,
230
- titleSize: _propTypes.default.string,
231
228
  type: _propTypes.default.string,
232
229
  hideBlankRows: _propTypes.default.bool,
233
230
  optionalFieldPlaceholder: _propTypes.default.string
@@ -243,7 +240,6 @@ CheckYourAnswers.defaultProps = {
243
240
  sections: [],
244
241
  summaryListClassModifiers: null,
245
242
  title: DEFAULT_TITLE,
246
- titleSize: 'l',
247
243
  type: null,
248
244
  hideBlankRows: false,
249
245
  optionalFieldPlaceholder: null
@@ -116,7 +116,7 @@ describe('components', () => {
116
116
  const cya = checkCYA(container);
117
117
  const [, cyaChildNode] = cya.childNodes;
118
118
  const names = cyaChildNode.childNodes[0];
119
- expect(names.tagName).toEqual('DL');
119
+ expect(names.tagName).toEqual('DIV');
120
120
  expect(names.classList).toContain("govuk-!-margin-bottom-".concat(_CheckYourAnswers.DEFAULT_MARGIN_BOTTOM));
121
121
  const [firstName, surname] = names.childNodes;
122
122
  checkRow(firstName, 'First name', 'John', false);
@@ -134,7 +134,7 @@ describe('components', () => {
134
134
  const [,, title, cyaChildNode] = cya.childNodes;
135
135
  const civilServant = cyaChildNode.childNodes[0];
136
136
  expect(title.textContent).toEqual('Are you a civil servant?');
137
- expect(civilServant.tagName).toEqual('DL');
137
+ expect(civilServant.tagName).toEqual('DIV');
138
138
  expect(civilServant.classList).toContain("govuk-!-margin-bottom-".concat(_CheckYourAnswers.DEFAULT_MARGIN_BOTTOM));
139
139
  const [status] = civilServant.childNodes;
140
140
  checkRow(status, 'Are you a civil servant?', 'Yes', true);
@@ -151,7 +151,7 @@ describe('components', () => {
151
151
  const cya = checkCYA(container);
152
152
  const [,, cyaChildNode] = cya.childNodes; // The title simply isn't returned
153
153
  const civilServant = cyaChildNode.childNodes[0];
154
- expect(civilServant.tagName).toEqual('DL');
154
+ expect(civilServant.tagName).toEqual('DIV');
155
155
  expect(civilServant.classList).toContain("govuk-!-margin-bottom-0"); // Changed margin if no titles
156
156
  const [status] = civilServant.childNodes;
157
157
  checkRow(status, 'Are you a civil servant?', 'Yes', true);
@@ -184,7 +184,7 @@ describe('components', () => {
184
184
  expect(titleAction.classList).toContain('heading-action');
185
185
  expect(titleAction.textContent).toEqual("Change page details");
186
186
  const civilServant = cyaChildNode.childNodes[0];
187
- expect(civilServant.tagName).toEqual('DL');
187
+ expect(civilServant.tagName).toEqual('DIV');
188
188
  const [status] = civilServant.childNodes;
189
189
  checkRow(status, 'Are you a civil servant?', 'Yes', false);
190
190
  });
@@ -231,7 +231,7 @@ describe('components', () => {
231
231
  expect(titleAction.classList).toContain('heading-action');
232
232
  expect(titleAction.textContent).toEqual("Change page details");
233
233
  const civilServant = cyaChildNode.childNodes[0];
234
- expect(civilServant.tagName).toEqual('DL');
234
+ expect(civilServant.tagName).toEqual('DIV');
235
235
  const [status] = civilServant.childNodes;
236
236
  checkRow(status, 'Are you a civil servant?', 'Yes', false);
237
237
  });
@@ -247,7 +247,7 @@ describe('components', () => {
247
247
  const cya = checkCYA(container);
248
248
  const [cyaChildNode] = cya.childNodes;
249
249
  const names = cyaChildNode.childNodes[0];
250
- expect(names.tagName).toEqual('DL');
250
+ expect(names.tagName).toEqual('DIV');
251
251
  expect(names.classList).toContain("govuk-!-margin-bottom-".concat(_CheckYourAnswers.DEFAULT_MARGIN_BOTTOM));
252
252
  const [firstName, surname] = names.childNodes;
253
253
  checkRow(firstName, 'First name', 'John', false);
@@ -502,7 +502,7 @@ describe('components', () => {
502
502
  const [, cyaTitle, cyaChildNode] = cya.childNodes;
503
503
  expect(cyaTitle.textContent).toEqual('Alpha ID: 123456789');
504
504
  const names = cyaChildNode.childNodes[0];
505
- expect(names.tagName).toEqual('DL');
505
+ expect(names.tagName).toEqual('DIV');
506
506
  expect(names.classList).toContain("govuk-!-margin-bottom-".concat(_CheckYourAnswers.DEFAULT_MARGIN_BOTTOM));
507
507
  const [firstName, surname] = names.childNodes;
508
508
  const [label] = firstName.childNodes;
@@ -528,7 +528,7 @@ describe('components', () => {
528
528
  const cya = checkCYA(container);
529
529
  const [, cyaChildNode] = cya.childNodes;
530
530
  const names = cyaChildNode.childNodes[0];
531
- expect(names.tagName).toEqual('DL');
531
+ expect(names.tagName).toEqual('DIV');
532
532
  expect(names.classList).toContain("govuk-!-margin-bottom-".concat(_CheckYourAnswers.DEFAULT_MARGIN_BOTTOM));
533
533
  const [firstName, surname] = names.childNodes;
534
534
  const [label] = firstName.childNodes;
@@ -71,12 +71,10 @@ const Container = _ref => {
71
71
  };
72
72
  const classes = _utils.default.classBuilder(DEFAULT_CLASS, [], container.className);
73
73
  const cleanedAttrs = _copReactComponents.Utils.cleanHtmlAttributes(attrs);
74
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", _objectSpread(_objectSpread({}, cleanedAttrs), {}, {
74
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({}, cleanedAttrs), {}, {
75
75
  className: classes(),
76
76
  id: container.id,
77
- children: [container.title && /*#__PURE__*/(0, _jsxRuntime.jsx)(_copReactComponents.MediumHeading, {
78
- children: container.title
79
- }), container.components && container.components.filter(shouldShow).map((component, index) => {
77
+ children: container.components && container.components.filter(shouldShow).map((component, index) => {
80
78
  const defaultValue = component.type === _models.ComponentTypes.FILE ? {} : '';
81
79
  const val = value ? value[component.fieldId] : defaultValue;
82
80
  const fullPath = "".concat(container.full_path || container.fieldId, ".").concat(component.fieldId);
@@ -91,7 +89,7 @@ const Container = _ref => {
91
89
  onChange: onComponentChange,
92
90
  onTopLevelChange: onTopLevelChange
93
91
  }), index);
94
- })]
92
+ })
95
93
  }));
96
94
  };
97
95
  Container.propTypes = {
@@ -104,8 +102,7 @@ Container.propTypes = {
104
102
  fieldId: _propTypes.default.string,
105
103
  full_path: _propTypes.default.string,
106
104
  id: _propTypes.default.string,
107
- readonly: _propTypes.default.bool,
108
- title: _propTypes.default.string
105
+ readonly: _propTypes.default.bool
109
106
  }).isRequired,
110
107
  formData: _propTypes.default.shape({}),
111
108
  fullPath: _propTypes.default.string,
@@ -407,49 +407,4 @@ describe('components.FormComponent.Container', () => {
407
407
  expect(input2.id).toEqual("".concat(ID, ".").concat(TEXT_ID, "Two"));
408
408
  expect(input2.value).toEqual('blue');
409
409
  });
410
- it('should render a container component appropriately with a title', async () => {
411
- const CONTAINER = {
412
- id: ID,
413
- fieldId: ID,
414
- title: "some title",
415
- type: _models.ComponentTypes.CONTAINER,
416
- components: [TEXT_COMPONENT]
417
- };
418
- const {
419
- container
420
- } = (0, _setupTests.renderWithValidation)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_FormComponent.default, {
421
- component: CONTAINER,
422
- value: FORM_DATA[ID],
423
- formData: FORM_DATA
424
- }));
425
-
426
- // Check the container itself.
427
- const c = container.childNodes[0];
428
- expect(c.tagName).toEqual('DIV');
429
- expect(c.classList).toContain(_Container.DEFAULT_CLASS);
430
-
431
- // Check container header.
432
- const containerHeader = c.childNodes[0];
433
- expect(containerHeader.tagName).toEqual('H2');
434
- expect(containerHeader.textContent).toEqual('some title');
435
-
436
- // And now check the single text component within it.
437
- const formGroup = c.childNodes[1];
438
- expect(formGroup.tagName).toEqual('DIV');
439
- expect(formGroup.classList).toContain('govuk-form-group');
440
- const label = formGroup.childNodes[0];
441
- expect(label.tagName).toEqual('LABEL');
442
- expect(label.classList).toContain('govuk-label');
443
- expect(label.textContent).toEqual("".concat(TEXT_COMPONENT.label, " (optional)"));
444
- expect(label.getAttribute('for')).toEqual("".concat(ID, ".").concat(TEXT_ID));
445
- const hint = formGroup.childNodes[1];
446
- expect(hint.tagName).toEqual('DIV');
447
- expect(hint.classList).toContain('govuk-hint');
448
- expect(hint.textContent).toEqual(TEXT_COMPONENT.hint);
449
- const input = formGroup.childNodes[2];
450
- expect(input.tagName).toEqual('INPUT');
451
- expect(input.classList).toContain('govuk-input');
452
- expect(input.id).toEqual("".concat(ID, ".").concat(TEXT_ID));
453
- expect(input.value).toEqual(TEXT_VALUE);
454
- });
455
410
  });
@@ -110,9 +110,6 @@ const FormComponent = _ref => {
110
110
  value: value || _utils.default.Component.defaultValue(component, formData),
111
111
  formData: formData
112
112
  }));
113
- if (component.fieldset) {
114
- container = (0, _wrapInFormGroup.default)(component, container);
115
- }
116
113
  if (component.additionalValidation) {
117
114
  container = (0, _wrapInFormGroup.default)(_objectSpread(_objectSpread({}, component), (0, _helpers.getComponentError)(component, validation === null || validation === void 0 ? void 0 : validation.errors)), container);
118
115
  }
@@ -205,7 +202,6 @@ FormComponent.propTypes = {
205
202
  id: _propTypes.default.string,
206
203
  label: _propTypes.default.string,
207
204
  suffix: _propTypes.default.string,
208
- fieldset: _propTypes.default.bool,
209
205
  type: _propTypes.default.string,
210
206
  pageCollection: _propTypes.default.shape({
211
207
  name: _propTypes.default.string
@@ -366,70 +366,5 @@ describe('components', () => {
366
366
  _userEvent.default.upload(input, FILE);
367
367
  expect(ON_CHANGE_COUNT).toEqual(3);
368
368
  });
369
- it('should render a text component appropriately when wrapped in a formGroups', async () => {
370
- const ID = 'container';
371
- const INNER_COMPONENT_ID = "text";
372
- const VALUE = 'Text value';
373
- const INNER_COMPONENT = {
374
- id: INNER_COMPONENT_ID,
375
- fieldId: INNER_COMPONENT_ID,
376
- type: 'text',
377
- label: 'Text component',
378
- hint: 'Text hint',
379
- value: VALUE
380
- };
381
- const COMPONENT = {
382
- id: ID,
383
- fieldId: ID,
384
- type: 'container',
385
- fieldset: true,
386
- components: [INNER_COMPONENT]
387
- };
388
- const NESTED_VALUE = {
389
- [INNER_COMPONENT_ID]: VALUE
390
- };
391
- const ON_CHANGE = () => {};
392
- const {
393
- container
394
- } = (0, _setupTests.renderWithValidation)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_FormComponent.default, {
395
- "data-testid": ID,
396
- component: COMPONENT,
397
- value: NESTED_VALUE,
398
- onChange: ON_CHANGE
399
- }));
400
-
401
- // Form group
402
- const formGroup = container.childNodes[0];
403
- expect(formGroup.tagName).toEqual('DIV');
404
- expect(formGroup.classList).toContain('govuk-form-group');
405
- // FieldSet
406
- const fieldSet = formGroup.childNodes[0];
407
- expect(fieldSet.tagName).toEqual('FIELDSET');
408
- expect(fieldSet.classList).toContain('govuk-fieldset');
409
- // Form container
410
- const formContainer = fieldSet.childNodes[0];
411
- expect(formContainer.tagName).toEqual('DIV');
412
- expect(formContainer.classList).toContain('hods-form-container');
413
- // Form group for container
414
- const formGroupForContainer = formContainer.childNodes[0];
415
- expect(formGroupForContainer.tagName).toEqual('DIV');
416
- expect(formGroupForContainer.classList).toContain('govuk-form-group');
417
-
418
- // Nested component.
419
- const label = formGroupForContainer.childNodes[0];
420
- expect(label.tagName).toEqual('LABEL');
421
- expect(label.classList).toContain('govuk-label');
422
- expect(label.textContent).toEqual("".concat(INNER_COMPONENT.label, " (optional)"));
423
- expect(label.getAttribute('for')).toEqual("".concat(ID, ".").concat(INNER_COMPONENT_ID));
424
- const hint = formGroupForContainer.childNodes[1];
425
- expect(hint.tagName).toEqual('DIV');
426
- expect(hint.classList).toContain('govuk-hint');
427
- expect(hint.textContent).toEqual(INNER_COMPONENT.hint);
428
- const input = formGroupForContainer.childNodes[2];
429
- expect(input.tagName).toEqual('INPUT');
430
- expect(input.classList).toContain('govuk-input');
431
- expect(input.id).toEqual("".concat(ID, ".").concat(INNER_COMPONENT_ID));
432
- expect(input.value).toEqual(VALUE);
433
- });
434
369
  });
435
370
  });
@@ -115,8 +115,7 @@ const FormPage = _ref => {
115
115
  label: _utils.default.interpolateString(action.label, formPage.formData)
116
116
  }) : action);
117
117
  formPage.formData = _utils.default.Operate.runPageOperations(formPage, _objectSpread(_objectSpread({}, formPage.formData), patch), onWrapperChange || onPageChange);
118
- const headingContent = page.title ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_copReactComponents.Heading, {
119
- size: page.titleSize,
118
+ const headingContent = page.title ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_copReactComponents.LargeHeading, {
120
119
  children: _utils.default.FormPage.getTitle(page.title, page.formData)
121
120
  }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_copReactComponents.Label, {
122
121
  id: page.id,
@@ -178,7 +177,6 @@ FormPage.propTypes = {
178
177
  page: _propTypes.default.shape({
179
178
  id: _propTypes.default.string.isRequired,
180
179
  title: _propTypes.default.string,
181
- titleSize: _propTypes.default.string,
182
180
  components: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.shape({})])).isRequired,
183
181
  fieldset: _propTypes.default.bool,
184
182
  hideOptionalSuffix: _propTypes.default.bool,
@@ -11,12 +11,10 @@ var _FormPage = _interopRequireWildcard(require("./FormPage"));
11
11
  var _jsxRuntime = require("react/jsx-runtime");
12
12
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
13
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
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; }
16
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
17
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
18
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } // Global imports
14
+ // Global imports
15
+
19
16
  // Local imports
17
+
20
18
  describe('components.FormPage', () => {
21
19
  describe('FormPage', () => {
22
20
  const TEXT = {
@@ -339,63 +337,6 @@ describe('components.FormPage', () => {
339
337
  }));
340
338
  expect(ON_ACTION_CALLS.length).toEqual(0);
341
339
  });
342
- it('Should render the page title correctly.', async () => {
343
- const {
344
- container,
345
- getByRole
346
- } = (0, _setupTests.renderWithValidation)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_FormPage.default, {
347
- page: PAGE_WITHOUT_CUSTOM_VALIDATION,
348
- fromTarget: true,
349
- onAction: ON_ACTION
350
- }));
351
- const heading = getByRole('heading', {
352
- level: 1
353
- });
354
- const labels = container.querySelectorAll('label');
355
- expect(labels).toHaveLength(1);
356
- expect(labels[0]).toHaveTextContent('Text component');
357
- expect(heading).toHaveTextContent('Page without Custom Validation');
358
- });
359
- it('Should render the page title correctly as a medium title', async () => {
360
- const PAGE_WITH_TITLE_SIZE = _objectSpread(_objectSpread({}, PAGE_WITHOUT_CUSTOM_VALIDATION), {}, {
361
- titleSize: 'm'
362
- });
363
- const {
364
- container,
365
- getByRole
366
- } = (0, _setupTests.renderWithValidation)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_FormPage.default, {
367
- page: PAGE_WITH_TITLE_SIZE,
368
- fromTarget: true,
369
- onAction: ON_ACTION
370
- }));
371
- const heading = getByRole('heading', {
372
- level: 2
373
- });
374
- const labels = container.querySelectorAll('label');
375
- expect(labels).toHaveLength(1);
376
- expect(labels[0]).toHaveTextContent('Text component');
377
- expect(heading).toHaveTextContent('Page without Custom Validation');
378
- });
379
- it('Should render the label correctly.', async () => {
380
- const PAGE_WITHOUT_CUSTOM_VALIDATION_WITH_LABEL = _objectSpread(_objectSpread({}, PAGE_WITHOUT_CUSTOM_VALIDATION), {}, {
381
- label: 'Some label value'
382
- });
383
- delete PAGE_WITHOUT_CUSTOM_VALIDATION_WITH_LABEL.title;
384
- const {
385
- container,
386
- queryByRole
387
- } = (0, _setupTests.renderWithValidation)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_FormPage.default, {
388
- page: PAGE_WITHOUT_CUSTOM_VALIDATION_WITH_LABEL,
389
- fromTarget: true,
390
- onAction: ON_ACTION
391
- }));
392
- const labels = container.querySelectorAll('label');
393
- const heading = queryByRole('heading');
394
- expect(labels).toHaveLength(2);
395
- expect(labels[0]).toHaveTextContent('Some label value');
396
- expect(labels[1]).toHaveTextContent('Text component');
397
- expect(heading).not.toBeInTheDocument();
398
- });
399
340
  it('removed field from the form data when the value is set to null', () => {
400
341
  const AUTOCOMPLETE = {
401
342
  id: 'autocomplete',
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = exports.DEFAULT_CLASS = void 0;
7
+ var _copReactComponents = require("@ukhomeoffice/cop-react-components");
7
8
  var _react = _interopRequireWildcard(require("react"));
8
9
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
- var _copReactComponents = require("@ukhomeoffice/cop-react-components");
10
10
  var _context = require("../../context");
11
11
  var _hooks = require("../../hooks");
12
12
  var _models = require("../../models");
@@ -37,7 +37,6 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
37
37
  const FormRenderer = _ref => {
38
38
  let {
39
39
  title,
40
- titleSize,
41
40
  type,
42
41
  cleanseHiddenData,
43
42
  components,
@@ -62,7 +61,6 @@ const FormRenderer = _ref => {
62
61
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_context.ValidationContextProvider, {
63
62
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(InternalFormRenderer, {
64
63
  title: title,
65
- titleSize: titleSize,
66
64
  type: type,
67
65
  cleanseHiddenData: cleanseHiddenData,
68
66
  components: components,
@@ -89,7 +87,6 @@ const InternalFormRenderer = _ref2 => {
89
87
  var _formState$page4, _formState$page$actio, _formState$cya$hideCh, _formState$cya$hideGr;
90
88
  let {
91
89
  title,
92
- titleSize,
93
90
  type,
94
91
  cleanseHiddenData,
95
92
  components,
@@ -308,8 +305,7 @@ const InternalFormRenderer = _ref2 => {
308
305
  taskDetails = _objectWithoutProperties(hubDetails, _excluded);
309
306
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
310
307
  className: classes(),
311
- children: [title && !hideTitle && pageId === _models.FormPages.HUB && /*#__PURE__*/(0, _jsxRuntime.jsx)(_copReactComponents.Heading, {
312
- size: titleSize,
308
+ children: [title && !hideTitle && pageId === _models.FormPages.HUB && /*#__PURE__*/(0, _jsxRuntime.jsx)(_copReactComponents.LargeHeading, {
313
309
  children: title
314
310
  }), formState.cya && /*#__PURE__*/(0, _jsxRuntime.jsx)(_CheckYourAnswers.default, _objectSpread(_objectSpread(_objectSpread(_objectSpread({
315
311
  pages: _helpers.default.getRelevantPages(formState, pages, currentTask.fullPages)
@@ -386,7 +382,6 @@ const propTypes = {
386
382
  pages: _propTypes.default.arrayOf(_propTypes.default.shape({})).isRequired,
387
383
  summaryListClassModifiers: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
388
384
  title: _propTypes.default.string,
389
- titleSize: _propTypes.default.string,
390
385
  cleanseHiddenData: _propTypes.default.bool,
391
386
  /** See <a href="/?path=/docs/f-json--page#formtypes">FormTypes</a>. */
392
387
  type: _propTypes.default.oneOf([_models.FormTypes.CYA, _models.FormTypes.FORM, _models.FormTypes.HUB, _models.FormTypes.TASK, _models.FormTypes.WIZARD, _models.FormTypes.TASK_CYA, _models.FormTypes.FORM_WITH_TASK]).isRequired,
@@ -413,7 +408,6 @@ const defaultProps = {
413
408
  noChangeAction: false,
414
409
  summaryListClassModifiers: [],
415
410
  title: '',
416
- titleSize: 'l',
417
411
  cleanseHiddenData: false,
418
412
  viewOnly: true,
419
413
  hideBlankRows: false
@@ -14,7 +14,7 @@ var _SummaryListHeadingRowWithAction = _interopRequireDefault(require("./Summary
14
14
  var _SummaryListTitleRow = _interopRequireDefault(require("./SummaryListTitleRow"));
15
15
  require("./SummaryList.scss");
16
16
  var _jsxRuntime = require("react/jsx-runtime");
17
- const _excluded = ["rows", "noChangeAction", "noGroupAction", "isGroup", "classBlock", "classModifiers", "className", "showGroupAction"]; // Global imports
17
+ const _excluded = ["rows", "noChangeAction", "noGroupAction", "isGroup", "classBlock", "classModifiers", "className"]; // Global imports
18
18
  // Local imports
19
19
  // Styles
20
20
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -34,8 +34,7 @@ const SummaryList = _ref => {
34
34
  isGroup,
35
35
  classBlock,
36
36
  classModifiers,
37
- className,
38
- showGroupAction = true
37
+ className
39
38
  } = _ref,
40
39
  attrs = _objectWithoutProperties(_ref, _excluded);
41
40
  const classes = _copReactComponents.Utils.classBuilder(classBlock, classModifiers, className);
@@ -47,7 +46,7 @@ const SummaryList = _ref => {
47
46
  }
48
47
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
49
48
  className: "group-of-rows",
50
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("dl", _objectSpread(_objectSpread({}, cleanedHtmlAttrs), {}, {
49
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", _objectSpread(_objectSpread({}, cleanedHtmlAttrs), {}, {
51
50
  className: classes(),
52
51
  children: [rows.map(row => {
53
52
  const key = "".concat(row.pageId, "_").concat(row.full_path || row.fieldId);
@@ -83,7 +82,7 @@ const SummaryList = _ref => {
83
82
  classes: classes,
84
83
  showAction: !noChangeAction
85
84
  }, key);
86
- }).filter(r => !!r), showGroupAction && isGroup && !noGroupAction && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
85
+ }).filter(r => !!r), isGroup && !noGroupAction && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
87
86
  className: "change-group-button",
88
87
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_GroupAction.default, {
89
88
  group: groupActionRow
@@ -99,7 +98,6 @@ SummaryList.propTypes = {
99
98
  isGroup: _propTypes.default.bool,
100
99
  noChangeAction: _propTypes.default.bool,
101
100
  noGroupAction: _propTypes.default.bool,
102
- showGroupAction: _propTypes.default.bool,
103
101
  rows: _propTypes.default.arrayOf(_propTypes.default.shape({
104
102
  pageId: _propTypes.default.string.isRequired,
105
103
  fieldId: _propTypes.default.string.isRequired,
@@ -120,7 +118,6 @@ SummaryList.defaultProps = {
120
118
  className: '',
121
119
  isGroup: false,
122
120
  noChangeAction: false,
123
- noGroupAction: false,
124
- showGroupAction: true
121
+ noGroupAction: false
125
122
  };
126
123
  var _default = exports.default = SummaryList;
@@ -14,7 +14,7 @@ describe('components', () => {
14
14
  describe('SummaryList', () => {
15
15
  const checkSummaryList = (container, id) => {
16
16
  const summaryList = (0, _react.getByTestId)(container, id);
17
- expect(summaryList.tagName).toEqual('DL');
17
+ expect(summaryList.tagName).toEqual('DIV');
18
18
  expect(summaryList.classList).toContain(_SummaryList.DEFAULT_CLASS);
19
19
  return summaryList;
20
20
  };
@@ -37,7 +37,7 @@ describe('components', () => {
37
37
  };
38
38
  const checkRow = (summaryList, index) => {
39
39
  const row = summaryList.childNodes[index];
40
- expect(row.tagName).toEqual('DIV');
40
+ expect(row.tagName).toEqual('DL');
41
41
  expect(row.classList).toContain("".concat(_SummaryList.DEFAULT_CLASS, "__row"));
42
42
  const [key, value, actions] = row.childNodes;
43
43
  expect(key.tagName).toEqual('DT');
@@ -61,7 +61,7 @@ describe('components', () => {
61
61
  };
62
62
  const checkRowNoChangeActions = (summaryList, index) => {
63
63
  const row = summaryList.childNodes[index];
64
- expect(row.tagName).toEqual('DIV');
64
+ expect(row.tagName).toEqual('DL');
65
65
  expect(row.classList).toContain("".concat(_SummaryList.DEFAULT_CLASS, "__row"));
66
66
  const [key, value] = row.childNodes;
67
67
  expect(key.tagName).toEqual('DT');
@@ -443,61 +443,6 @@ describe('components', () => {
443
443
  expect(valueDiv.tagName).toEqual('DIV');
444
444
  expect(valueDiv.textContent).toEqual(VALUES[index]);
445
445
  });
446
- // Expect the group action to be rendered at the bottom of the summary.
447
- const groupAction = summaryList.childNodes[ROWS.length].childNodes[0];
448
- expect(groupAction.tagName).toEqual('A');
449
- expect(groupAction.textContent).toEqual('action');
450
- });
451
- it('should render groups of rows correctly and no render the group action', () => {
452
- const ID = 'test-id';
453
- const VALUES = ['Alpha component value', 'Bravo component value', 'Charlie component value'];
454
- const ISGROUP = true;
455
- const ROWS = [{
456
- key: 'a',
457
- pageId: 'p1',
458
- fieldId: 'a',
459
- value: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
460
- children: VALUES[0]
461
- }),
462
- action: {
463
- label: 'action'
464
- }
465
- }, {
466
- key: 'b',
467
- pageId: 'p1',
468
- fieldId: 'b',
469
- value: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
470
- children: VALUES[1]
471
- })
472
- }, {
473
- key: 'c',
474
- pageId: 'p1',
475
- fieldId: 'c',
476
- value: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
477
- children: VALUES[2]
478
- })
479
- }];
480
- const {
481
- container
482
- } = (0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_SummaryList.default, {
483
- "data-testid": ID,
484
- rows: ROWS,
485
- isGroup: ISGROUP,
486
- showGroupAction: false
487
- }));
488
- const summaryList = checkSummaryList(container, ID);
489
- expect(summaryList.childNodes.length).toEqual(ROWS.length);
490
- ROWS.forEach((row, index) => {
491
- const [key, value] = checkRow(summaryList, index);
492
- expect(key.textContent).toEqual("".concat(row.key, " (optional)"));
493
- expect(value.childNodes.length).toEqual(1);
494
- const valueDiv = value.childNodes[0];
495
- expect(valueDiv.tagName).toEqual('DIV');
496
- expect(valueDiv.textContent).toEqual(VALUES[index]);
497
- });
498
- // Expect the group action to not be rendered.
499
- const groupAction = summaryList.childNodes[ROWS.length];
500
- expect(groupAction).toBeUndefined();
501
446
  });
502
447
  });
503
448
  });
@@ -19,7 +19,7 @@ const SummaryListRow = _ref => {
19
19
  classes,
20
20
  showAction
21
21
  } = _ref;
22
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
22
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("dl", {
23
23
  className: classes('row'),
24
24
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("dt", {
25
25
  className: classes('key'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ukhomeoffice/cop-react-form-renderer",
3
- "version": "7.1.1-ipm-accessibility-gamma",
3
+ "version": "7.2.0-alpha",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "build-storybook": "storybook build",
@@ -18,7 +18,7 @@
18
18
  "yalc-publish": "yarn compile-with-maps && cp -r src dist/src && yalc publish --push"
19
19
  },
20
20
  "dependencies": {
21
- "@ukhomeoffice/cop-react-components": "5.1.0-ipm-accessibility-alpha",
21
+ "@ukhomeoffice/cop-react-components": "5.1.0",
22
22
  "axios": "0.30.0",
23
23
  "dayjs": "^1.11.0",
24
24
  "govuk-frontend": "5.10.2",