@ukhomeoffice/cop-react-form-renderer 4.89.2 → 4.90.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.
@@ -132,9 +132,11 @@ var Collection = function Collection(_ref) {
132
132
  index: labelCount
133
133
  }));
134
134
  var removeStyle = config.disableAddAndRemove || index === 0 && config.minimumEntries ? '' : (_config$removeLocatio = config.removeLocation) !== null && _config$removeLocatio !== void 0 ? _config$removeLocatio : 'start';
135
+ var addStyle = index !== 0 && config.subsequentItemStyle ? config.subsequentItemStyle : {};
135
136
  return /*#__PURE__*/_react.default.createElement("div", {
136
137
  className: "".concat(classes('item')),
137
- key: item.id
138
+ key: item.id,
139
+ style: addStyle
138
140
  }, /*#__PURE__*/_react.default.createElement(_copReactComponents.Label, {
139
141
  id: item.id,
140
142
  required: true,
@@ -211,6 +213,7 @@ Collection.propTypes = {
211
213
  minimumEntries: _propTypes.default.number,
212
214
  readonly: _propTypes.default.bool,
213
215
  removeLocation: _propTypes.default.string,
216
+ subsequentItemStyle: _propTypes.default.shape({}),
214
217
  required: _propTypes.default.bool
215
218
  }).isRequired,
216
219
  formData: _propTypes.default.shape({}),
@@ -728,4 +728,80 @@ describe('components.FormComponent.Collection', function () {
728
728
  }
729
729
  }, _callee12);
730
730
  })));
731
+ it('should handle the alternative styling with a background and padding on the subsequent item(s) when subsequentItemStyle is provided', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
732
+ var COLLECTION, container, c, addButton, item, label, secondItem, secondLabel;
733
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
734
+ while (1) switch (_context14.prev = _context14.next) {
735
+ case 0:
736
+ COLLECTION = {
737
+ id: ID,
738
+ fieldId: ID,
739
+ type: _models.ComponentTypes.COLLECTION,
740
+ item: [TEXT_COMPONENT],
741
+ subsequentItemStyle: {
742
+ background: 'white',
743
+ padding: '1px'
744
+ }
745
+ };
746
+ container = document.createElement('div');
747
+ document.body.appendChild(container);
748
+ _context14.next = 5;
749
+ return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
750
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
751
+ while (1) switch (_context13.prev = _context13.next) {
752
+ case 0:
753
+ (0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react2.default.createElement(_FormComponent.default, {
754
+ component: COLLECTION
755
+ }), container);
756
+ case 1:
757
+ case "end":
758
+ return _context13.stop();
759
+ }
760
+ }, _callee13);
761
+ })));
762
+ case 5:
763
+ // Check the container itself.
764
+ c = container.childNodes[0];
765
+ expect(c.tagName).toEqual('DIV');
766
+ expect(c.classList).toContain(_Collection.DEFAULT_CLASS);
767
+
768
+ // And now make sure it has no children OTHER than the button to add an item.
769
+ expect(c.childNodes.length).toEqual(1);
770
+
771
+ // Get hold of that "Add another" button and click it.
772
+ addButton = c.childNodes[0].childNodes[0];
773
+ _react.fireEvent.click(addButton, {});
774
+
775
+ // Make sure an item has been added.
776
+ expect(c.childNodes.length).toEqual(2);
777
+ item = c.childNodes[0];
778
+ label = item.childNodes[0];
779
+ expect(label.textContent).toContain(_utils.default.interpolateString(_models.CollectionLabels.item, {
780
+ index: 1
781
+ }));
782
+
783
+ // Check to see if styling has been untouched for the first item
784
+ expect(item.style.background).toEqual('');
785
+ expect(item.style.padding).toEqual('');
786
+
787
+ // Get hold of that "Add another" button and click it.
788
+ _react.fireEvent.click(addButton, {});
789
+
790
+ // Make sure another item has been added.
791
+ expect(c.childNodes.length).toEqual(3);
792
+ secondItem = c.childNodes[1];
793
+ secondLabel = secondItem.childNodes[0];
794
+ expect(secondLabel.textContent).toContain(_utils.default.interpolateString(_models.CollectionLabels.secondItem, {
795
+ index: 2
796
+ }));
797
+
798
+ // Get hold of the second item and check background and padding has been applied.
799
+ expect(secondItem.style.background).toEqual('white');
800
+ expect(secondItem.style.padding).toEqual('1px');
801
+ case 24:
802
+ case "end":
803
+ return _context14.stop();
804
+ }
805
+ }, _callee14);
806
+ })));
731
807
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ukhomeoffice/cop-react-form-renderer",
3
- "version": "4.89.2",
3
+ "version": "4.90.0",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "clean": "rimraf dist",