@ukhomeoffice/cop-react-form-renderer 4.20.0 → 4.21.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/Answer.js +1 -1
- package/dist/components/CheckYourAnswers/Answer.test.js +25 -0
- package/dist/models/ComponentTypes.js +2 -0
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +1 -1
- package/dist/utils/Component/getComponent.js +16 -0
- package/package.json +2 -2
|
@@ -91,5 +91,30 @@ describe('components', function () {
|
|
|
91
91
|
}
|
|
92
92
|
}, _callee3);
|
|
93
93
|
})));
|
|
94
|
+
it('should handle a null component and an object value', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
|
|
95
|
+
var VALUE, COMPONENT, _renderWithValidation4, container;
|
|
96
|
+
|
|
97
|
+
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
98
|
+
while (1) {
|
|
99
|
+
switch (_context4.prev = _context4.next) {
|
|
100
|
+
case 0:
|
|
101
|
+
VALUE = {
|
|
102
|
+
label: 'A label',
|
|
103
|
+
value: 'a_value'
|
|
104
|
+
};
|
|
105
|
+
COMPONENT = null;
|
|
106
|
+
_renderWithValidation4 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_Answer.default, {
|
|
107
|
+
value: VALUE,
|
|
108
|
+
component: COMPONENT
|
|
109
|
+
})), container = _renderWithValidation4.container;
|
|
110
|
+
expect(container.textContent).toEqual(VALUE.label);
|
|
111
|
+
|
|
112
|
+
case 4:
|
|
113
|
+
case "end":
|
|
114
|
+
return _context4.stop();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}, _callee4);
|
|
118
|
+
})));
|
|
94
119
|
});
|
|
95
120
|
});
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
var TYPE_ALERT = 'alert';
|
|
7
8
|
var TYPE_AUTOCOMPLETE = 'autocomplete';
|
|
8
9
|
var TYPE_CALCULATION = 'calculation';
|
|
9
10
|
var TYPE_CHECKBOXES = 'checkboxes';
|
|
@@ -24,6 +25,7 @@ var TYPE_TEXT_AREA = 'textarea';
|
|
|
24
25
|
var TYPE_TIME = 'time';
|
|
25
26
|
var TYPE_WARNING = 'warning';
|
|
26
27
|
var ComponentTypes = {
|
|
28
|
+
ALERT: TYPE_ALERT,
|
|
27
29
|
AUTOCOMPLETE: TYPE_AUTOCOMPLETE,
|
|
28
30
|
CALCULATION: TYPE_CALCULATION,
|
|
29
31
|
CHECKBOXES: TYPE_CHECKBOXES,
|
|
@@ -14,7 +14,7 @@ var _Container = _interopRequireDefault(require("../Container"));
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
|
|
16
16
|
// Local imports
|
|
17
|
-
var EXCLUDE_FROM_CYA = [_models.ComponentTypes.HEADING, _models.ComponentTypes.HTML, _models.ComponentTypes.INSET_TEXT];
|
|
17
|
+
var EXCLUDE_FROM_CYA = [_models.ComponentTypes.ALERT, _models.ComponentTypes.HEADING, _models.ComponentTypes.HTML, _models.ComponentTypes.INSET_TEXT];
|
|
18
18
|
/**
|
|
19
19
|
* Determines whether a given component should display on the Check your answers screen.
|
|
20
20
|
*
|
|
@@ -31,6 +31,19 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
31
31
|
* switch statement increases the cyclomatic complexity and
|
|
32
32
|
* makes it much harder to follow what's going on.
|
|
33
33
|
*/
|
|
34
|
+
var getAlert = function getAlert(config) {
|
|
35
|
+
var attrs = (0, _cleanAttributes.default)(config);
|
|
36
|
+
|
|
37
|
+
var heading = _copReactComponents.Utils.interpolateString(config.heading, config.formData);
|
|
38
|
+
|
|
39
|
+
var children = _copReactComponents.Utils.interpolateString(config.text, config.formData);
|
|
40
|
+
|
|
41
|
+
return /*#__PURE__*/_react.default.createElement(_copReactComponents.Alert, _extends({}, attrs, {
|
|
42
|
+
heading: heading,
|
|
43
|
+
children: children
|
|
44
|
+
}));
|
|
45
|
+
};
|
|
46
|
+
|
|
34
47
|
var getAutocomplete = function getAutocomplete(config) {
|
|
35
48
|
var attrs = (0, _cleanAttributes.default)(config);
|
|
36
49
|
|
|
@@ -207,6 +220,9 @@ var getComponentByType = function getComponentByType(config) {
|
|
|
207
220
|
case _models.ComponentTypes.CALCULATION:
|
|
208
221
|
return getCalculation(config);
|
|
209
222
|
|
|
223
|
+
case _models.ComponentTypes.ALERT:
|
|
224
|
+
return getAlert(config);
|
|
225
|
+
|
|
210
226
|
default:
|
|
211
227
|
{
|
|
212
228
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ukhomeoffice/cop-react-form-renderer",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.21.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": "2.3.
|
|
19
|
+
"@ukhomeoffice/cop-react-components": "2.3.4",
|
|
20
20
|
"axios": "^0.23.0",
|
|
21
21
|
"dayjs": "^1.11.0",
|
|
22
22
|
"govuk-frontend": "^4.3.1",
|