@ukhomeoffice/cop-react-form-renderer 5.84.1 → 5.85.1

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.
@@ -22,7 +22,7 @@ var Answer = function Answer(_ref) {
22
22
  formData = _ref.formData,
23
23
  placeholder = _ref.placeholder;
24
24
  if (!value) {
25
- var placeholderValue = (component === null || component === void 0 ? void 0 : component.cyaPlaceholder) || placeholder;
25
+ var placeholderValue = Object.prototype.hasOwnProperty.call(component || {}, 'cyaPlaceholder') ? component === null || component === void 0 ? void 0 : component.cyaPlaceholder : placeholder;
26
26
  return placeholderValue || /*#__PURE__*/_react.default.createElement(_VisuallyHidden.default, null, "No answer");
27
27
  }
28
28
  if (!component) {
@@ -204,8 +204,9 @@ var getCYARowsForCollectionPage = function getCYARowsForCollectionPage(page, onA
204
204
  rows.push(getCollectionNameHeading(page, collectionName, page.collection.collectionHeading, headingChangeAction));
205
205
  }
206
206
  var itemIndex = 0;
207
- var result = Array.isArray(page.collection.onlyShowActiveEntryOnCYA) ? (0, _meetsAllConditions.default)(page.collection.onlyShowActiveEntryOnCYA, data) : page.collection.onlyShowActiveEntryOnCYA;
208
- if (result) {
207
+ var hideItemTitles = Array.isArray(page.collection.hideItemTitles) ? (0, _meetsAllConditions.default)(page.collection.hideItemTitles, data) : page.collection.hideItemTitles;
208
+ var onlyShowActiveEntry = Array.isArray(page.collection.onlyShowActiveEntryOnCYA) ? (0, _meetsAllConditions.default)(page.collection.onlyShowActiveEntryOnCYA, data) : page.collection.onlyShowActiveEntryOnCYA;
209
+ if (onlyShowActiveEntry) {
209
210
  var activeEntry = collectionData.find(function (entry, index) {
210
211
  itemIndex = index;
211
212
  return entry.id === activeId;
@@ -222,9 +223,11 @@ var getCYARowsForCollectionPage = function getCYARowsForCollectionPage(page, onA
222
223
  var labelCount = itemIndex + 1;
223
224
  var actionPosition = ((_page$collection2 = page.collection) === null || _page$collection2 === void 0 ? void 0 : _page$collection2.actionPosition) || 'top';
224
225
  var fullPath = "".concat(page.collection.name, "[").concat(itemIndex, "]");
225
- var titleRow = getTitleRowForItem(page, item, page.id, labelCount, fullPath);
226
226
  var actionRows = getActionRows(page, item, onAction, labelCount, activeIds);
227
- rows = rows.concat(titleRow);
227
+ if (!hideItemTitles) {
228
+ var titleRow = getTitleRowForItem(page, item, page.id, labelCount, fullPath);
229
+ rows = rows.concat(titleRow);
230
+ }
228
231
  if (actionPosition === 'top') {
229
232
  rows = rows.concat(actionRows);
230
233
  }
@@ -103,6 +103,45 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
103
103
  expect(ROWS.length).toEqual(7); // Collection title, item title, action rows & component rows
104
104
  expect(ROWS[1].key).toEqual('Collection entry 1');
105
105
  });
106
+ it('should hide titles when hideItemTitles is true', function () {
107
+ var FORM_DATA = {
108
+ collection: [{
109
+ id: '01',
110
+ testText: 'value'
111
+ }]
112
+ };
113
+ var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
114
+ formData: FORM_DATA,
115
+ collection: _objectSpread(_objectSpread({}, MASTER_PAGE.collection), {}, {
116
+ hideItemTitles: true
117
+ })
118
+ });
119
+ var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
120
+ expect(ROWS.length).toEqual(6); // Collection title, NO item title, action rows & component rows
121
+ });
122
+
123
+ it('should hide titles when hideItemTitles is a show_when that is true', function () {
124
+ var FORM_DATA = {
125
+ shouldShow: false,
126
+ collection: [{
127
+ id: '01',
128
+ testText: 'value'
129
+ }]
130
+ };
131
+ var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
132
+ formData: FORM_DATA,
133
+ collection: _objectSpread(_objectSpread({}, MASTER_PAGE.collection), {}, {
134
+ hideItemTitles: [{
135
+ field: 'shouldShow',
136
+ op: '=',
137
+ value: false
138
+ }]
139
+ })
140
+ });
141
+ var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
142
+ expect(ROWS.length).toEqual(6); // Collection title, NO item title, action rows & component rows
143
+ });
144
+
106
145
  it('should provide default titles if collection.labels.item is not specified', function () {
107
146
  var FORM_DATA = {
108
147
  collection: [{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ukhomeoffice/cop-react-form-renderer",
3
- "version": "5.84.1",
3
+ "version": "5.85.1",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "clean": "rimraf dist",