@ukhomeoffice/cop-react-form-renderer 4.80.0 → 4.81.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.
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +4 -2
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +7 -3
- package/dist/utils/Component/getComponent.js +5 -5
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +9 -7
- package/dist/utils/Component/wrapInFormGroup.js +1 -1
- package/package.json +1 -1
|
@@ -135,13 +135,15 @@ var CheckYourAnswers = function CheckYourAnswers(_ref) {
|
|
|
135
135
|
}, title), errors && errors.length > 0 && /*#__PURE__*/_react.default.createElement(_copReactComponents.ErrorSummary, {
|
|
136
136
|
errors: errors
|
|
137
137
|
}), type === _models.FormTypes.TASK_CYA && pages.length > 0 && sections && sections.map(function (section) {
|
|
138
|
-
return section.tasks.map(function (task) {
|
|
138
|
+
return section.tasks.map(function (task, taskIndex) {
|
|
139
139
|
var filterPages = pages.filter(function (page) {
|
|
140
140
|
return task.pages.some(function (p) {
|
|
141
141
|
return p === page.name;
|
|
142
142
|
});
|
|
143
143
|
});
|
|
144
|
-
return /*#__PURE__*/_react.default.createElement(_react.
|
|
144
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, {
|
|
145
|
+
key: taskIndex
|
|
146
|
+
}, /*#__PURE__*/_react.default.createElement("h3", {
|
|
145
147
|
className: "govuk-heading-m govuk-!-margin-top-8 govuk-!-margin-bottom-0"
|
|
146
148
|
}, filterPages.length > 0 && task.name), filterPages.map(function (page, pageIndex) {
|
|
147
149
|
var hideActionButtons = isGroup(page.id) || noChangeAction;
|
|
@@ -206,9 +206,13 @@ describe('utils', function () {
|
|
|
206
206
|
}
|
|
207
207
|
};
|
|
208
208
|
var ON_ACTION = function ON_ACTION() {};
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
209
|
+
// rows do not have defined keys which means cannot pass them to render as an array,
|
|
210
|
+
// so just pass the single row instead of array containing single row
|
|
211
|
+
var cyaRow = (0, _getCYARowsForPage.default)(PAGE, ON_ACTION).map(function (row) {
|
|
212
|
+
return row.value;
|
|
213
|
+
});
|
|
214
|
+
expect(cyaRow.length).toEqual(1);
|
|
215
|
+
var _renderWithValidation = (0, _setupTests.renderWithValidation)(cyaRow[0]),
|
|
212
216
|
container = _renderWithValidation.container;
|
|
213
217
|
expect(container.childNodes.length).toEqual(4);
|
|
214
218
|
var addressValues = container.childNodes;
|
|
@@ -24,7 +24,7 @@ var LIST_CLASS = 'govuk-list';
|
|
|
24
24
|
var BODY_CLASS = 'govuk-body';
|
|
25
25
|
var INPUT_CLASS = 'govuk-input';
|
|
26
26
|
|
|
27
|
-
/**
|
|
27
|
+
/**
|
|
28
28
|
* Separate function for each component type for the sake of
|
|
29
29
|
* code clarity - having the additional bits and pieces in the
|
|
30
30
|
* switch statement increases the cyclomatic complexity and
|
|
@@ -86,7 +86,7 @@ var getDate = function getDate(config) {
|
|
|
86
86
|
return /*#__PURE__*/_react.default.createElement(_copReactComponents.DateInput, attrs);
|
|
87
87
|
};
|
|
88
88
|
var getDetails = function getDetails(config) {
|
|
89
|
-
var attrs = (0, _cleanAttributes.default)(config);
|
|
89
|
+
var attrs = (0, _cleanAttributes.default)(config, ['tagName']);
|
|
90
90
|
var html = getHTML(config);
|
|
91
91
|
return /*#__PURE__*/_react.default.createElement(_copReactComponents.Details, attrs, html);
|
|
92
92
|
};
|
|
@@ -112,9 +112,9 @@ var getInsetText = function getInsetText(config) {
|
|
|
112
112
|
};
|
|
113
113
|
var getList = function getList(config) {
|
|
114
114
|
var _attrs$items;
|
|
115
|
-
var attrs = (0, _cleanAttributes.default)(config);
|
|
116
|
-
var tagName =
|
|
117
|
-
var bullet =
|
|
115
|
+
var attrs = (0, _cleanAttributes.default)(config, ['ordered']);
|
|
116
|
+
var tagName = config.ordered ? 'ol' : 'ul';
|
|
117
|
+
var bullet = config.ordered ? 'number' : 'bullet';
|
|
118
118
|
var classes = _copReactComponents.Utils.classBuilder(LIST_CLASS, bullet);
|
|
119
119
|
var content = (_attrs$items = attrs.items) === null || _attrs$items === void 0 ? void 0 : _attrs$items.map(function (item) {
|
|
120
120
|
return "<li>".concat(item, "</li>");
|
|
@@ -34,18 +34,20 @@ describe('utils.Component.get', function () {
|
|
|
34
34
|
type: _models.ComponentTypes.DETAILS,
|
|
35
35
|
content: CONTENT,
|
|
36
36
|
summary: SUMMARY,
|
|
37
|
+
tagName: 'div',
|
|
37
38
|
'data-testid': ID
|
|
38
39
|
};
|
|
39
40
|
var _render2 = (0, _react.render)((0, _getComponent.default)(COMPONENT)),
|
|
40
41
|
container = _render2.container;
|
|
41
42
|
var details = container.querySelector('details');
|
|
42
43
|
expect(details.classList).toContain('hods-details');
|
|
43
|
-
|
|
44
|
-
expect(
|
|
45
|
-
expect(
|
|
46
|
-
expect(
|
|
47
|
-
expect(
|
|
48
|
-
expect(
|
|
49
|
-
expect(
|
|
44
|
+
var content = details.childNodes[1].childNodes[0].childNodes;
|
|
45
|
+
expect(content[0].textContent).toEqual('this is the content');
|
|
46
|
+
expect(content[0].tagName).toEqual('P');
|
|
47
|
+
expect(content[1].childNodes[0].textContent).toEqual('one');
|
|
48
|
+
expect(content[1].childNodes[1].textContent).toEqual('two');
|
|
49
|
+
expect(content[1].tagName).toEqual('OL');
|
|
50
|
+
expect(content[2].textContent).toEqual('second section of content');
|
|
51
|
+
expect(content[2].tagName).toEqual('P');
|
|
50
52
|
});
|
|
51
53
|
});
|
|
@@ -10,7 +10,7 @@ var _cleanAttributes = _interopRequireDefault(require("./cleanAttributes"));
|
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
11
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
|
12
12
|
var wrapInFormGroup = function wrapInFormGroup(config, children) {
|
|
13
|
-
var attrs = (0, _cleanAttributes.default)(config, ['fieldId', 'displayMenu', 'showCharacterCount']);
|
|
13
|
+
var attrs = (0, _cleanAttributes.default)(config, ['fieldId', 'displayMenu', 'showCharacterCount', 'readonly']);
|
|
14
14
|
return /*#__PURE__*/_react.default.createElement(_copReactComponents.FormGroup, _extends({}, attrs, {
|
|
15
15
|
onChange: null
|
|
16
16
|
}), children);
|