@ukhomeoffice/cop-react-form-renderer 5.95.0 → 5.97.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.
|
@@ -53,6 +53,17 @@ var getComponentToUse = function getComponentToUse(toUse, formComponents) {
|
|
|
53
53
|
} else {
|
|
54
54
|
wrapper = component;
|
|
55
55
|
}
|
|
56
|
+
|
|
57
|
+
// this allows us to have the 'use: component' functionality inside item array
|
|
58
|
+
if (component.item && Array.isArray(component.item)) {
|
|
59
|
+
component.item = component.item.map(function (item) {
|
|
60
|
+
if (item.use) {
|
|
61
|
+
// eslint-disable-next-line no-use-before-define
|
|
62
|
+
return useComponent(item, formComponents);
|
|
63
|
+
}
|
|
64
|
+
return item;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
56
67
|
return wrapper;
|
|
57
68
|
}
|
|
58
69
|
|
|
@@ -175,6 +175,42 @@ describe('utils', function () {
|
|
|
175
175
|
label: TO_USE.label
|
|
176
176
|
}));
|
|
177
177
|
});
|
|
178
|
+
it('should handle nested use references within item', function () {
|
|
179
|
+
var SEARCH_METHOD = {
|
|
180
|
+
id: 'searchMethod',
|
|
181
|
+
label: 'Search Method',
|
|
182
|
+
type: _models.ComponentTypes.TEXT
|
|
183
|
+
};
|
|
184
|
+
var SEARCH_TECHNIQUES = {
|
|
185
|
+
id: 'searchTechniques',
|
|
186
|
+
label: 'Search Techniques',
|
|
187
|
+
type: _models.ComponentTypes.CONTAINER,
|
|
188
|
+
item: [{
|
|
189
|
+
use: 'searchMethod',
|
|
190
|
+
data: {
|
|
191
|
+
url: 'https://api.example.com/searchtype'
|
|
192
|
+
}
|
|
193
|
+
}]
|
|
194
|
+
};
|
|
195
|
+
var EXTENDED_FORM_COMPONENTS = [].concat(FORM_COMPONENTS, [SEARCH_METHOD, SEARCH_TECHNIQUES]);
|
|
196
|
+
var TO_USE = {
|
|
197
|
+
use: 'searchTechniques'
|
|
198
|
+
};
|
|
199
|
+
var expectedComponent = _objectSpread(_objectSpread({
|
|
200
|
+
use: 'searchTechniques'
|
|
201
|
+
}, SEARCH_TECHNIQUES), {}, {
|
|
202
|
+
cya_label: SEARCH_TECHNIQUES.label,
|
|
203
|
+
item: [_objectSpread(_objectSpread({
|
|
204
|
+
use: 'searchMethod'
|
|
205
|
+
}, SEARCH_METHOD), {}, {
|
|
206
|
+
cya_label: SEARCH_METHOD.label,
|
|
207
|
+
data: {
|
|
208
|
+
url: 'https://api.example.com/searchtype'
|
|
209
|
+
}
|
|
210
|
+
})]
|
|
211
|
+
});
|
|
212
|
+
expect((0, _useComponent.default)(TO_USE, EXTENDED_FORM_COMPONENTS)).toEqual(expectedComponent);
|
|
213
|
+
});
|
|
178
214
|
});
|
|
179
215
|
});
|
|
180
216
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ukhomeoffice/cop-react-form-renderer",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.97.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.24.
|
|
19
|
+
"@ukhomeoffice/cop-react-components": "3.24.3",
|
|
20
20
|
"axios": "^0.23.0",
|
|
21
21
|
"dayjs": "^1.11.0",
|
|
22
22
|
"govuk-frontend": "^4.3.1",
|