@ukhomeoffice/cop-react-form-renderer 5.14.0 → 5.15.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/FormComponent/Container.js +3 -3
- package/dist/components/FormRenderer/FormRenderer.test.js +11 -11
- package/dist/components/SummaryList/SummaryList.js +2 -1
- package/dist/components/TaskList/TaskList.js +6 -8
- package/dist/components/TaskList/TaskList.test.js +13 -13
- package/package.json +2 -2
|
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = exports.DEFAULT_CLASS = void 0;
|
|
8
|
+
var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
8
9
|
var _react = _interopRequireDefault(require("react"));
|
|
9
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
11
|
var _models = require("../../models");
|
|
11
12
|
var _utils = _interopRequireDefault(require("../../utils"));
|
|
12
|
-
var _cleanAttributes = _interopRequireDefault(require("../../utils/Component/cleanAttributes"));
|
|
13
13
|
var _FormComponent = _interopRequireDefault(require("./FormComponent"));
|
|
14
14
|
var _excluded = ["container", "value", "formData", "onChange", "wrap", "onTopLevelChange"];
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -61,8 +61,8 @@ var Container = function Container(_ref) {
|
|
|
61
61
|
}), formData);
|
|
62
62
|
};
|
|
63
63
|
var classes = _utils.default.classBuilder(DEFAULT_CLASS, [], container.className);
|
|
64
|
-
var
|
|
65
|
-
return /*#__PURE__*/_react.default.createElement("div", _extends({},
|
|
64
|
+
var cleanedAttrs = _copReactComponents.Utils.cleanHtmlAttributes(attrs);
|
|
65
|
+
return /*#__PURE__*/_react.default.createElement("div", _extends({}, cleanedAttrs, {
|
|
66
66
|
className: classes(),
|
|
67
67
|
id: container.id
|
|
68
68
|
}), container.components && container.components.filter(shouldShow).map(function (component, index) {
|
|
@@ -593,13 +593,13 @@ describe('components', function () {
|
|
|
593
593
|
})));
|
|
594
594
|
case 5:
|
|
595
595
|
taskList = container.childNodes[0].childNodes[1]; // Check statuses are correct
|
|
596
|
-
firstTaskStatus = taskList.childNodes[3].childNodes[
|
|
596
|
+
firstTaskStatus = taskList.childNodes[3].childNodes[0].childNodes[1];
|
|
597
597
|
expect(firstTaskStatus.textContent).toEqual(_models.TaskStates.DETAILS[_models.TaskStates.TYPES.NOT_STARTED].label);
|
|
598
|
-
secondTaskStatus = taskList.childNodes[3].childNodes[
|
|
598
|
+
secondTaskStatus = taskList.childNodes[3].childNodes[1].childNodes[1];
|
|
599
599
|
expect(secondTaskStatus.textContent).toEqual(_models.TaskStates.DETAILS[_models.TaskStates.TYPES.CANNOT_START_YET].label);
|
|
600
600
|
|
|
601
601
|
// Launch first task
|
|
602
|
-
firstTask = taskList.childNodes[3].childNodes[
|
|
602
|
+
firstTask = taskList.childNodes[3].childNodes[0].childNodes[0].childNodes[0];
|
|
603
603
|
expect(firstTask.textContent).toEqual('Date, location and mode details');
|
|
604
604
|
_react.fireEvent.click(firstTask, {});
|
|
605
605
|
|
|
@@ -664,9 +664,9 @@ describe('components', function () {
|
|
|
664
664
|
expect(container.childNodes[0].childNodes[0].textContent).toEqual('Task List Form');
|
|
665
665
|
|
|
666
666
|
// Check statuses are correct
|
|
667
|
-
firstTaskStatus = container.childNodes[0].childNodes[1].childNodes[3].childNodes[
|
|
667
|
+
firstTaskStatus = container.childNodes[0].childNodes[1].childNodes[3].childNodes[0].childNodes[1];
|
|
668
668
|
expect(firstTaskStatus.textContent).toEqual(_models.TaskStates.DETAILS[_models.TaskStates.TYPES.COMPLETE].label);
|
|
669
|
-
secondTaskStatus = container.childNodes[0].childNodes[1].childNodes[3].childNodes[
|
|
669
|
+
secondTaskStatus = container.childNodes[0].childNodes[1].childNodes[3].childNodes[1].childNodes[1];
|
|
670
670
|
expect(secondTaskStatus.textContent).toEqual(_models.TaskStates.DETAILS[_models.TaskStates.TYPES.NOT_STARTED].label);
|
|
671
671
|
|
|
672
672
|
// Check final data submitted to backend is as expected
|
|
@@ -707,7 +707,7 @@ describe('components', function () {
|
|
|
707
707
|
})));
|
|
708
708
|
case 4:
|
|
709
709
|
taskList = container.childNodes[0].childNodes[1]; // Launch first task
|
|
710
|
-
_react.fireEvent.click(taskList.childNodes[3].childNodes[
|
|
710
|
+
_react.fireEvent.click(taskList.childNodes[3].childNodes[0].childNodes[0].childNodes[0], {});
|
|
711
711
|
|
|
712
712
|
// Fill first page and navigate
|
|
713
713
|
newPage = container.childNodes[0].childNodes[0];
|
|
@@ -740,7 +740,7 @@ describe('components', function () {
|
|
|
740
740
|
_react.fireEvent.click(container.childNodes[0].childNodes[0].childNodes[5].childNodes[0], {});
|
|
741
741
|
|
|
742
742
|
// Launch same task again
|
|
743
|
-
_react.fireEvent.click(container.childNodes[0].childNodes[1].childNodes[3].childNodes[
|
|
743
|
+
_react.fireEvent.click(container.childNodes[0].childNodes[1].childNodes[3].childNodes[0].childNodes[0].childNodes[0], {});
|
|
744
744
|
|
|
745
745
|
// Should be at CYA page
|
|
746
746
|
expect(container.childNodes[0].childNodes[0].childNodes[0].textContent).toEqual('Check your answers');
|
|
@@ -790,7 +790,7 @@ describe('components', function () {
|
|
|
790
790
|
})));
|
|
791
791
|
case 5:
|
|
792
792
|
taskList = container.childNodes[0].childNodes[1]; // Launch first task
|
|
793
|
-
_react.fireEvent.click(taskList.childNodes[3].childNodes[
|
|
793
|
+
_react.fireEvent.click(taskList.childNodes[3].childNodes[0].childNodes[0].childNodes[0], {});
|
|
794
794
|
|
|
795
795
|
// Should be at Event Mode page
|
|
796
796
|
expect(container.childNodes[0].childNodes[0].childNodes[0].textContent).toEqual('Event Mode');
|
|
@@ -833,7 +833,7 @@ describe('components', function () {
|
|
|
833
833
|
})));
|
|
834
834
|
case 7:
|
|
835
835
|
taskList = container.childNodes[0].childNodes[1]; // Launch first task
|
|
836
|
-
_react.fireEvent.click(taskList.childNodes[3].childNodes[
|
|
836
|
+
_react.fireEvent.click(taskList.childNodes[3].childNodes[0].childNodes[0].childNodes[0], {});
|
|
837
837
|
|
|
838
838
|
// Fill first page and navigate
|
|
839
839
|
newPage = container.childNodes[0].childNodes[0];
|
|
@@ -864,7 +864,7 @@ describe('components', function () {
|
|
|
864
864
|
_react.fireEvent.click(newPage.childNodes[2].childNodes[0], {});
|
|
865
865
|
|
|
866
866
|
// Launch same task again
|
|
867
|
-
_react.fireEvent.click(container.childNodes[0].childNodes[1].childNodes[3].childNodes[
|
|
867
|
+
_react.fireEvent.click(container.childNodes[0].childNodes[1].childNodes[3].childNodes[0].childNodes[0].childNodes[0], {});
|
|
868
868
|
|
|
869
869
|
// Should be on the first page
|
|
870
870
|
expect(container.childNodes[0].childNodes[0].childNodes[0].textContent).toEqual('Event Date');
|
|
@@ -951,7 +951,7 @@ describe('components', function () {
|
|
|
951
951
|
})));
|
|
952
952
|
case 7:
|
|
953
953
|
taskList = container.childNodes[0].childNodes[1]; // Launch first task of second section
|
|
954
|
-
firstTask = taskList.childNodes[5].childNodes[
|
|
954
|
+
firstTask = taskList.childNodes[5].childNodes[0].childNodes[0].childNodes[0];
|
|
955
955
|
expect(firstTask.textContent).toEqual('People details');
|
|
956
956
|
_react.fireEvent.click(firstTask, {});
|
|
957
957
|
|
|
@@ -29,6 +29,7 @@ var SummaryList = function SummaryList(_ref) {
|
|
|
29
29
|
className = _ref.className,
|
|
30
30
|
attrs = _objectWithoutProperties(_ref, _excluded);
|
|
31
31
|
var classes = _copReactComponents.Utils.classBuilder(classBlock, classModifiers, className);
|
|
32
|
+
var cleanedHtmlAttrs = _copReactComponents.Utils.cleanHtmlAttributes(attrs);
|
|
32
33
|
var groupActionRow = null;
|
|
33
34
|
if (isGroup) {
|
|
34
35
|
var rowActions = rows.filter(function (r) {
|
|
@@ -38,7 +39,7 @@ var SummaryList = function SummaryList(_ref) {
|
|
|
38
39
|
}
|
|
39
40
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
40
41
|
className: "group-of-rows"
|
|
41
|
-
}, /*#__PURE__*/_react.default.createElement("dl", _extends({},
|
|
42
|
+
}, /*#__PURE__*/_react.default.createElement("dl", _extends({}, cleanedHtmlAttrs, {
|
|
42
43
|
className: classes()
|
|
43
44
|
}), rows.map(function (row) {
|
|
44
45
|
var key = "".concat(row.pageId, "_").concat(row.full_path || row.fieldId);
|
|
@@ -5,10 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = exports.DEFAULT_INCOMPLETE_TITLE = exports.DEFAULT_CLASS = void 0;
|
|
8
|
+
var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
8
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
11
|
-
var _dist = require("@ukhomeoffice/cop-react-components/dist");
|
|
12
11
|
var _models = require("../../models");
|
|
13
12
|
var _Task = _interopRequireDefault(require("./Task"));
|
|
14
13
|
var _showComponent = _interopRequireDefault(require("../../utils/Component/showComponent"));
|
|
@@ -45,7 +44,7 @@ var TaskList = function TaskList(_ref) {
|
|
|
45
44
|
formData = _ref.formData,
|
|
46
45
|
attrs = _objectWithoutProperties(_ref, _excluded);
|
|
47
46
|
var classes = _copReactComponents.Utils.classBuilder(classBlock, classModifiers, className);
|
|
48
|
-
|
|
47
|
+
var cleanedHtmlAttrs = _copReactComponents.Utils.cleanHtmlAttributes(attrs);
|
|
49
48
|
// TODO state will be retrieved from a document in S3 rather than given in the component definition, covered under COP-9885
|
|
50
49
|
var _sections$filter$redu = sections.filter(function (section) {
|
|
51
50
|
return !section.skipped;
|
|
@@ -69,9 +68,8 @@ var TaskList = function TaskList(_ref) {
|
|
|
69
68
|
onTaskAction(task);
|
|
70
69
|
}
|
|
71
70
|
};
|
|
72
|
-
return /*#__PURE__*/_react.default.createElement("div", _extends({
|
|
73
|
-
id: id
|
|
74
|
-
}, attrs, {
|
|
71
|
+
return /*#__PURE__*/_react.default.createElement("div", _extends({}, cleanedHtmlAttrs, {
|
|
72
|
+
id: id,
|
|
75
73
|
className: classes()
|
|
76
74
|
}), refNumber && refTitle && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("p", {
|
|
77
75
|
className: "govuk-body govuk-!-margin-bottom-0"
|
|
@@ -101,9 +99,9 @@ var TaskList = function TaskList(_ref) {
|
|
|
101
99
|
key: "".concat(section.name)
|
|
102
100
|
}, /*#__PURE__*/_react.default.createElement("h2", {
|
|
103
101
|
className: classes('section')
|
|
104
|
-
}, sections.length > 1 ? "".concat(index + 1, ". ") : '', section.name), /*#__PURE__*/_react.default.createElement("ol", {
|
|
102
|
+
}, sections.length > 1 ? "".concat(index + 1, ". ") : '', section.name), section.label && /*#__PURE__*/_react.default.createElement(_copReactComponents.Hint, null, section.label), /*#__PURE__*/_react.default.createElement("ol", {
|
|
105
103
|
className: classes('items')
|
|
106
|
-
},
|
|
104
|
+
}, section.tasks.filter(function (task) {
|
|
107
105
|
return task.state !== _models.TaskStates.TYPES.SKIPPED;
|
|
108
106
|
}).map(function (task) {
|
|
109
107
|
return /*#__PURE__*/_react.default.createElement(_Task.default, {
|
|
@@ -59,16 +59,18 @@ describe('components', function () {
|
|
|
59
59
|
container = _render.container;
|
|
60
60
|
var childNodes = container.childNodes;
|
|
61
61
|
expect(childNodes.length).toEqual(1);
|
|
62
|
-
expect(childNodes[0].childNodes.length).toEqual(
|
|
63
|
-
var _childNodes$0$childNo = _slicedToArray(childNodes[0].childNodes,
|
|
62
|
+
expect(childNodes[0].childNodes.length).toEqual(10);
|
|
63
|
+
var _childNodes$0$childNo = _slicedToArray(childNodes[0].childNodes, 10),
|
|
64
64
|
referenceHeading = _childNodes$0$childNo[0],
|
|
65
65
|
referenceNumber = _childNodes$0$childNo[1],
|
|
66
66
|
incompleteForm = _childNodes$0$childNo[2],
|
|
67
67
|
numComplete = _childNodes$0$childNo[3],
|
|
68
68
|
subSectionOneHeading = _childNodes$0$childNo[4],
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
subSectionOneLabel = _childNodes$0$childNo[5],
|
|
70
|
+
subSectionOneList = _childNodes$0$childNo[6],
|
|
71
|
+
subSectionTwoHeading = _childNodes$0$childNo[7],
|
|
72
|
+
subSectionTwoLabel = _childNodes$0$childNo[8],
|
|
73
|
+
subSectionTwoList = _childNodes$0$childNo[9];
|
|
72
74
|
expect(referenceHeading).toMatchObject({
|
|
73
75
|
tagName: 'P',
|
|
74
76
|
textContent: 'COP reference number'
|
|
@@ -89,16 +91,14 @@ describe('components', function () {
|
|
|
89
91
|
tagName: 'H2',
|
|
90
92
|
textContent: '1. These are your tasks'
|
|
91
93
|
});
|
|
92
|
-
expect(
|
|
94
|
+
expect(subSectionOneLabel.textContent).toEqual('This is the label for your first tasks');
|
|
95
|
+
expect(subSectionOneList.childNodes.length).toEqual(3);
|
|
93
96
|
expect(subSectionTwoHeading).toMatchObject({
|
|
94
97
|
tagName: 'H2',
|
|
95
98
|
textContent: '2. These are your extra bonus tasks'
|
|
96
99
|
});
|
|
97
|
-
expect(subSectionTwoList.childNodes.length).toEqual(4);
|
|
98
|
-
var subSectionOneLabel = childNodes[0].childNodes[5].firstChild;
|
|
99
|
-
expect(subSectionOneLabel.textContent).toEqual('This is the label for your first tasks');
|
|
100
|
-
var subSectionTwoLabel = childNodes[0].childNodes[7].firstChild;
|
|
101
100
|
expect(subSectionTwoLabel.textContent).toEqual('This is the label for your extra tasks');
|
|
101
|
+
expect(subSectionTwoList.childNodes.length).toEqual(3);
|
|
102
102
|
});
|
|
103
103
|
it('should not show incomplete title if form is complete', function () {
|
|
104
104
|
var COP_REF = '123';
|
|
@@ -364,9 +364,9 @@ describe('components', function () {
|
|
|
364
364
|
})),
|
|
365
365
|
container = _render7.container;
|
|
366
366
|
var taskList = container.childNodes[0].childNodes[5].childNodes;
|
|
367
|
-
var firstTask = taskList[
|
|
368
|
-
var secondTask = taskList[
|
|
369
|
-
var thirdTask = taskList[
|
|
367
|
+
var firstTask = taskList[0].childNodes[0].childNodes[0];
|
|
368
|
+
var secondTask = taskList[1].childNodes[0].childNodes[0];
|
|
369
|
+
var thirdTask = taskList[2].childNodes[0].childNodes[0];
|
|
370
370
|
_react.fireEvent.click(firstTask.childNodes[0]);
|
|
371
371
|
expect(ON_CLICK_CALLS[0]).toEqual({
|
|
372
372
|
pages: ['pageOne'],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ukhomeoffice/cop-react-form-renderer",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.15.0",
|
|
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": "^3.
|
|
19
|
+
"@ukhomeoffice/cop-react-components": "^3.5.0",
|
|
20
20
|
"axios": "^0.23.0",
|
|
21
21
|
"dayjs": "^1.11.0",
|
|
22
22
|
"govuk-frontend": "^4.3.1",
|