@ukhomeoffice/cop-react-form-renderer 5.6.0 → 5.7.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.
|
@@ -95,7 +95,7 @@ var CollectionPage = function CollectionPage(_ref) {
|
|
|
95
95
|
formData: _objectSpread(_objectSpread(_objectSpread({}, page.formData), data[activeIndex]), {}, _defineProperty({}, "".concat(page.collection.name, "ActiveIndex"), activeIndex)),
|
|
96
96
|
components: page.components.map(function (component) {
|
|
97
97
|
return _objectSpread(_objectSpread({}, component), {}, {
|
|
98
|
-
|
|
98
|
+
pageCollection: _objectSpread({}, page.collection)
|
|
99
99
|
});
|
|
100
100
|
})
|
|
101
101
|
}),
|
|
@@ -141,7 +141,7 @@ describe('components.CollectionPage', function () {
|
|
|
141
141
|
expect(label.tagName).toEqual('LABEL');
|
|
142
142
|
expect(label.classList).toContain('govuk-label');
|
|
143
143
|
expect(label.textContent).toEqual(lbl);
|
|
144
|
-
expect(label.getAttribute('for')).toEqual(
|
|
144
|
+
expect(label.getAttribute('for')).toEqual(fieldId);
|
|
145
145
|
var hint = formGroup.childNodes[1];
|
|
146
146
|
expect(hint.tagName).toEqual('DIV');
|
|
147
147
|
expect(hint.classList).toContain('govuk-hint');
|
|
@@ -149,7 +149,7 @@ describe('components.CollectionPage', function () {
|
|
|
149
149
|
var input = formGroup.childNodes[2];
|
|
150
150
|
expect(input.tagName).toEqual('INPUT');
|
|
151
151
|
expect(input.classList).toContain('govuk-input');
|
|
152
|
-
expect(input.id).toEqual(
|
|
152
|
+
expect(input.id).toEqual(fieldId);
|
|
153
153
|
expect(input.value).toEqual(val);
|
|
154
154
|
return input;
|
|
155
155
|
};
|
|
@@ -160,7 +160,7 @@ describe('components.CollectionPage', function () {
|
|
|
160
160
|
expect(label.tagName).toEqual('LABEL');
|
|
161
161
|
expect(label.classList).toContain('govuk-label');
|
|
162
162
|
expect(label.textContent).toEqual(lbl);
|
|
163
|
-
expect(label.getAttribute('for')).toEqual(
|
|
163
|
+
expect(label.getAttribute('for')).toEqual(fieldId);
|
|
164
164
|
var hint = formGroup.childNodes[1];
|
|
165
165
|
expect(hint.tagName).toEqual('DIV');
|
|
166
166
|
expect(hint.classList).toContain('govuk-hint');
|
|
@@ -174,7 +174,7 @@ describe('components.CollectionPage', function () {
|
|
|
174
174
|
})[0];
|
|
175
175
|
expect(input.classList).toContain('hods-autocomplete__input');
|
|
176
176
|
expect(input.tagName).toEqual('INPUT');
|
|
177
|
-
expect(input.id).toEqual(
|
|
177
|
+
expect(input.id).toEqual(fieldId);
|
|
178
178
|
expect(input.value).toEqual(val);
|
|
179
179
|
return input;
|
|
180
180
|
};
|
|
@@ -96,10 +96,16 @@ var FormComponent = function FormComponent(_ref) {
|
|
|
96
96
|
}));
|
|
97
97
|
}
|
|
98
98
|
var changeMetaDocuments = function changeMetaDocuments(document) {
|
|
99
|
+
var componentPath = component.full_path || component.fieldId;
|
|
100
|
+
if (component.pageCollection) {
|
|
101
|
+
var activeIndex = _utils.default.CollectionPage.getActiveIndex(component.pageCollection.name, formData);
|
|
102
|
+
var pathPrefix = "".concat(component.pageCollection.name, "[").concat(activeIndex, "]");
|
|
103
|
+
componentPath = "".concat(pathPrefix, ".").concat(componentPath);
|
|
104
|
+
}
|
|
99
105
|
onTopLevelChange({
|
|
100
106
|
target: {
|
|
101
107
|
name: _utils.default.Meta.name,
|
|
102
|
-
value: _utils.default.Meta.documents.setForField(document, formData,
|
|
108
|
+
value: _utils.default.Meta.documents.setForField(document, formData, componentPath, component.allowMultiple)
|
|
103
109
|
}
|
|
104
110
|
});
|
|
105
111
|
};
|
|
@@ -153,7 +159,10 @@ FormComponent.propTypes = {
|
|
|
153
159
|
id: _propTypes.default.string,
|
|
154
160
|
label: _propTypes.default.string,
|
|
155
161
|
suffix: _propTypes.default.string,
|
|
156
|
-
type: _propTypes.default.string
|
|
162
|
+
type: _propTypes.default.string,
|
|
163
|
+
pageCollection: _propTypes.default.shape({
|
|
164
|
+
name: _propTypes.default.string
|
|
165
|
+
})
|
|
157
166
|
}).isRequired,
|
|
158
167
|
value: _propTypes.default.oneOfType([_propTypes.default.node,
|
|
159
168
|
// not included in node
|