@ukhomeoffice/cop-react-form-renderer 4.66.0 → 4.67.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.
|
@@ -11,6 +11,8 @@ var _Component = _interopRequireDefault(require("../Component"));
|
|
|
11
11
|
|
|
12
12
|
var _Container = _interopRequireDefault(require("../Container"));
|
|
13
13
|
|
|
14
|
+
var _getSourceData = _interopRequireDefault(require("../Data/getSourceData"));
|
|
15
|
+
|
|
14
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
17
|
|
|
16
18
|
// Local imports
|
|
@@ -39,6 +41,14 @@ var showComponentCYA = function showComponentCYA(options, data) {
|
|
|
39
41
|
return false;
|
|
40
42
|
}
|
|
41
43
|
|
|
44
|
+
if (options.hideOnCyaWhenEmpty && options.type === _models.ComponentTypes.COLLECTION) {
|
|
45
|
+
var itemCollectionsData = (0, _getSourceData.default)(data, options.full_path);
|
|
46
|
+
|
|
47
|
+
if (!(itemCollectionsData !== null && itemCollectionsData !== void 0 && itemCollectionsData.length)) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
42
52
|
if (options.type === _models.ComponentTypes.CONTAINER) {
|
|
43
53
|
return _Container.default.show(options, data);
|
|
44
54
|
}
|
|
@@ -59,6 +59,46 @@ describe('utils', function () {
|
|
|
59
59
|
type: _models.ComponentTypes.TEXT
|
|
60
60
|
}, null)).toBeTruthy();
|
|
61
61
|
});
|
|
62
|
+
it('should show when hideOnCyaWhenEmpty is defined and truthy', function () {
|
|
63
|
+
expect((0, _showComponentCYA.default)({
|
|
64
|
+
hideOnCyaWhenEmpty: true
|
|
65
|
+
})).toBeTruthy();
|
|
66
|
+
});
|
|
67
|
+
it('should show collection when hideOnCyaWhenEmpty is not defined', function () {
|
|
68
|
+
expect((0, _showComponentCYA.default)({
|
|
69
|
+
type: _models.ComponentTypes.COLLECTION
|
|
70
|
+
})).toBeTruthy();
|
|
71
|
+
});
|
|
72
|
+
it('should not show when it\'s a collection and hideOnCyaWhenEmpty is truthy', function () {
|
|
73
|
+
expect((0, _showComponentCYA.default)({
|
|
74
|
+
hideOnCyaWhenEmpty: true,
|
|
75
|
+
type: _models.ComponentTypes.COLLECTION
|
|
76
|
+
})).toBeFalsy();
|
|
77
|
+
});
|
|
78
|
+
it('should show when it\'s not a collection and hideOnCyaWhenEmpty is truthy', function () {
|
|
79
|
+
expect((0, _showComponentCYA.default)({
|
|
80
|
+
hideOnCyaWhenEmpty: true,
|
|
81
|
+
type: _models.ComponentTypes.TEXT
|
|
82
|
+
})).toBeTruthy();
|
|
83
|
+
});
|
|
84
|
+
it('should show when length of full_path data is 1 or more', function () {
|
|
85
|
+
expect((0, _showComponentCYA.default)({
|
|
86
|
+
hideOnCyaWhenEmpty: true,
|
|
87
|
+
type: _models.ComponentTypes.COLLECTION,
|
|
88
|
+
full_path: "example"
|
|
89
|
+
}, {
|
|
90
|
+
example: [0, 1]
|
|
91
|
+
})).toBeTruthy();
|
|
92
|
+
});
|
|
93
|
+
it('should not show when length of full_path data is less than 1', function () {
|
|
94
|
+
expect((0, _showComponentCYA.default)({
|
|
95
|
+
hideOnCyaWhenEmpty: true,
|
|
96
|
+
type: _models.ComponentTypes.COLLECTION,
|
|
97
|
+
full_path: "example"
|
|
98
|
+
}, {
|
|
99
|
+
example: []
|
|
100
|
+
})).toBeFalsy();
|
|
101
|
+
});
|
|
62
102
|
});
|
|
63
103
|
});
|
|
64
104
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ukhomeoffice/cop-react-form-renderer",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.67.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.11.
|
|
19
|
+
"@ukhomeoffice/cop-react-components": "^2.11.4",
|
|
20
20
|
"axios": "^0.23.0",
|
|
21
21
|
"dayjs": "^1.11.0",
|
|
22
22
|
"govuk-frontend": "^4.3.1",
|