@ukhomeoffice/cop-react-form-renderer 5.84.0 → 5.85.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.
@@ -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.placeholder) || placeholder;
25
+ var placeholderValue = (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) {
@@ -39,7 +39,7 @@ var Answer = function Answer(_ref) {
39
39
  };
40
40
  Answer.propTypes = {
41
41
  component: _propTypes.default.shape({
42
- placeholder: _propTypes.default.string
42
+ cyaPlaceholder: _propTypes.default.string
43
43
  }),
44
44
  formData: _propTypes.default.shape({}),
45
45
  value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.shape({})]),
@@ -113,7 +113,7 @@ describe('components', function () {
113
113
  fieldId: 'alpha',
114
114
  type: 'text',
115
115
  label: 'Alpha',
116
- placeholder: 'Alpha not entered'
116
+ cyaPlaceholder: 'Alpha not entered'
117
117
  };
118
118
  _renderWithValidation5 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_Answer.default, {
119
119
  value: VALUE,
@@ -121,7 +121,7 @@ describe('components', function () {
121
121
  placeholder: GLOBAL_PLACEHOLDER
122
122
  })), container = _renderWithValidation5.container;
123
123
  answer = container.childNodes[0];
124
- expect(answer.textContent).toEqual(COMPONENT.placeholder);
124
+ expect(answer.textContent).toEqual(COMPONENT.cyaPlaceholder);
125
125
  case 6:
126
126
  case "end":
127
127
  return _context5.stop();
@@ -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.0",
3
+ "version": "5.85.0",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "clean": "rimraf dist",