@ukhomeoffice/cop-react-form-renderer 6.16.0-charlie → 7.0.0-echo
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.
- package/dist/components/CheckYourAnswers/Answer.js +5 -2
- package/dist/components/CheckYourAnswers/Answer.test.js +8 -7
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +86 -68
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +22 -22
- package/dist/components/CollectionPage/CollectionPage.js +3 -3
- package/dist/components/CollectionPage/CollectionPage.test.js +13 -13
- package/dist/components/CollectionSummary/BannerStrip.js +22 -21
- package/dist/components/CollectionSummary/BannerStrip.test.js +8 -8
- package/dist/components/CollectionSummary/CollectionSummary.js +105 -99
- package/dist/components/CollectionSummary/CollectionSummary.test.js +23 -19
- package/dist/components/CollectionSummary/Confirmation.js +16 -10
- package/dist/components/CollectionSummary/Confirmation.test.js +12 -11
- package/dist/components/CollectionSummary/RenderListView.js +78 -65
- package/dist/components/CollectionSummary/RenderListView.test.js +18 -12
- package/dist/components/CollectionSummary/SummaryCard.js +83 -72
- package/dist/components/CollectionSummary/SummaryCard.test.js +105 -101
- package/dist/components/CollectionSummary/SummaryCardButtons.js +17 -13
- package/dist/components/CollectionSummary/SummaryCardButtons.test.js +3 -2
- package/dist/components/CollectionSummary/SummaryCardDetails.js +72 -67
- package/dist/components/CollectionSummary/SummaryCardDetails.test.js +12 -12
- package/dist/components/CollectionSummary/SummaryCardValidationContext.js +6 -5
- package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +29 -13
- package/dist/components/FormComponent/Collection.js +91 -82
- package/dist/components/FormComponent/Collection.test.js +16 -15
- package/dist/components/FormComponent/Container.js +21 -22
- package/dist/components/FormComponent/Container.test.js +9 -8
- package/dist/components/FormComponent/FormComponent.js +7 -8
- package/dist/components/FormComponent/FormComponent.test.js +18 -13
- package/dist/components/FormPage/FormPage.js +29 -23
- package/dist/components/FormPage/FormPage.test.js +11 -11
- package/dist/components/FormRenderer/FormRenderer.js +81 -92
- package/dist/components/FormRenderer/FormRenderer.test.js +23 -24
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/forms/form-hidden-component-with-nested-questions-visible-elsewhere.json +118 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/forms/form-nested-answers-hidden-by-option-visible-elsewhere.json +113 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/forms/form-page-nested-component.json +26003 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/input/data-hidden-component-with-nested-questions-visible-elsewhere.json +12 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/input/data-nested-answers-hidden-by-option-visible-elsewhere.json +12 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/input/data-page-nested-component.json +63 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/output/data-hidden-component-with-nested-questions-visible-elsewhere-removed.json +11 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/output/data-nested-answers-hidden-by-option-visible-elsewhere-removed.json +12 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/output/data-page-nested-component.json +63 -0
- package/dist/components/FormRenderer/helpers/clearOutUncompletedRoutes.js +18 -16
- package/dist/components/FormRenderer/helpers/clearOutUncompletedRoutes.test.js +31 -0
- package/dist/components/FormRenderer/helpers/clearOutUncompletedRoutesUtils.js +44 -35
- package/dist/components/FormRenderer/helpers/clearOutUncompletedRoutesUtils.test.js +1 -2
- package/dist/components/PageActions/ActionButton.js +12 -6
- package/dist/components/PageActions/ActionButton.test.js +5 -5
- package/dist/components/PageActions/PageActions.js +7 -5
- package/dist/components/PageActions/PageActions.test.js +5 -4
- package/dist/components/SummaryList/GroupAction.js +14 -8
- package/dist/components/SummaryList/GroupAction.test.js +5 -4
- package/dist/components/SummaryList/RowAction.js +12 -6
- package/dist/components/SummaryList/RowAction.test.js +5 -4
- package/dist/components/SummaryList/SummaryList.js +54 -49
- package/dist/components/SummaryList/SummaryList.test.js +33 -19
- package/dist/components/SummaryList/SummaryListHeadingRow.js +9 -3
- package/dist/components/SummaryList/SummaryListHeadingRowWithAction.js +20 -12
- package/dist/components/SummaryList/SummaryListRow.js +16 -11
- package/dist/components/SummaryList/SummaryListTitleRow.js +7 -3
- package/dist/components/TaskList/Task.js +20 -17
- package/dist/components/TaskList/Task.test.js +8 -7
- package/dist/components/TaskList/TaskList.js +68 -45
- package/dist/components/TaskList/TaskList.test.js +11 -11
- package/dist/components/TaskList/TaskState.js +5 -3
- package/dist/components/TaskList/TaskState.test.js +8 -7
- package/dist/context/HooksContext/HooksContext.js +6 -5
- package/dist/context/HooksContext/HooksContext.test.js +14 -6
- package/dist/context/HooksContext/index.js +1 -2
- package/dist/context/ValidationContext/ValidationContext.js +6 -5
- package/dist/context/ValidationContext/ValidationContext.test.js +33 -9
- package/dist/context/ValidationContext/index.js +1 -2
- package/dist/hooks/index.js +1 -2
- package/dist/hooks/useRefData.js +1 -2
- package/dist/index.js +1 -2
- package/dist/setupTests.js +23 -18
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +19 -16
- package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.js +5 -5
- package/dist/utils/CollectionPage/getQuickEditPage.js +2 -2
- package/dist/utils/Component/cleanAttributes.test.js +1 -2
- package/dist/utils/Component/getComponent.js +38 -28
- package/dist/utils/Component/getDefaultValueFromConfig.js +1 -2
- package/dist/utils/Component/isEditable.test.js +1 -2
- package/dist/utils/Component/wrapInFormGroup.js +10 -4
- package/dist/utils/Format/formatDataForComponent.test.js +1 -2
- package/dist/utils/Format/formatDataForPage.test.js +1 -2
- package/dist/utils/Validate/validateDate.test.js +1 -2
- package/dist/utils/Validate/validateMultifile.test.js +1 -2
- package/package.json +89 -27
|
@@ -12,6 +12,7 @@ var _utils = _interopRequireDefault(require("../../utils"));
|
|
|
12
12
|
var _getSummaryListRowForDetails = _interopRequireDefault(require("../../utils/CheckYourAnswers/getSummaryListRowForDetails"));
|
|
13
13
|
var _Condition = _interopRequireDefault(require("../../utils/Condition"));
|
|
14
14
|
require("./RenderListView.scss");
|
|
15
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
17
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
17
18
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -41,73 +42,85 @@ const RenderListView = _ref => {
|
|
|
41
42
|
} = _ref;
|
|
42
43
|
const classes = _copReactComponents.Utils.classBuilder(DEFAULT_CLASS, classModifiers, config.className);
|
|
43
44
|
const listClass = _copReactComponents.Utils.classBuilder(DEFAULT_LIST_CLASS);
|
|
44
|
-
return /*#__PURE__*/
|
|
45
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
45
46
|
className: classes(),
|
|
46
|
-
id: id
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
47
|
+
id: id,
|
|
48
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
49
|
+
className: classes('title-wrapper', [], 'dark'),
|
|
50
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
51
|
+
className: classes('title-content'),
|
|
52
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("h2", {
|
|
53
|
+
className: classes('title'),
|
|
54
|
+
children: _copReactComponents.Utils.interpolateString(config.title || DEFAULT_TITLE, _objectSpread(_objectSpread({}, entryData), {}, {
|
|
55
|
+
index: entryData.index + 1
|
|
56
|
+
}))
|
|
57
|
+
}), config.banners && /*#__PURE__*/(0, _jsxRuntime.jsx)(_BannerStrip.default, {
|
|
58
|
+
id: "BannerStrip".concat(entryData.id),
|
|
59
|
+
banners: config.banners,
|
|
60
|
+
formData: entryData
|
|
61
|
+
})]
|
|
62
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("ul", {
|
|
63
|
+
className: classes('actions'),
|
|
64
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
|
|
65
|
+
className: classes('action'),
|
|
66
|
+
children: config.changeAction && typeof onFullEdit === 'function' &&
|
|
67
|
+
// If passed a value for classModifiers, render a Button with those classModifiers applied -
|
|
68
|
+
// otherwise, revert to the default GOVUK List View styling of rendering a Link button instead:
|
|
69
|
+
config.changeAction.classModifiers ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_copReactComponents.Button, {
|
|
70
|
+
id: "".concat(id, ".changeButton"),
|
|
71
|
+
onClick: () => onFullEdit(config.changeAction.page, entryData.id),
|
|
72
|
+
classModifiers: config.changeAction.classModifiers,
|
|
73
|
+
"aria-label": _copReactComponents.Utils.interpolateString("".concat(((_config$changeAction = config.changeAction) === null || _config$changeAction === void 0 ? void 0 : _config$changeAction.label) || DEFAULT_CHANGE_BUTTON_LABEL, " ").concat(config.title || DEFAULT_TITLE), _objectSpread(_objectSpread({}, entryData), {}, {
|
|
74
|
+
index: entryData.index + 1
|
|
75
|
+
})),
|
|
76
|
+
children: ((_config$changeAction2 = config.changeAction) === null || _config$changeAction2 === void 0 ? void 0 : _config$changeAction2.label) || DEFAULT_CHANGE_BUTTON_LABEL
|
|
77
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
|
|
78
|
+
type: "button",
|
|
79
|
+
className: "govuk-link govuk-link-button",
|
|
80
|
+
onClick: () => onFullEdit(config.changeAction.page, entryData.id),
|
|
81
|
+
"aria-label": _copReactComponents.Utils.interpolateString("".concat(((_config$changeAction3 = config.changeAction) === null || _config$changeAction3 === void 0 ? void 0 : _config$changeAction3.label) || DEFAULT_CHANGE_BUTTON_LABEL, " ").concat(config.title || DEFAULT_TITLE), _objectSpread(_objectSpread({}, entryData), {}, {
|
|
82
|
+
index: entryData.index + 1
|
|
83
|
+
})),
|
|
84
|
+
children: ((_config$changeAction4 = config.changeAction) === null || _config$changeAction4 === void 0 ? void 0 : _config$changeAction4.label) || DEFAULT_CHANGE_BUTTON_LABEL
|
|
85
|
+
})
|
|
86
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
|
|
87
|
+
className: classes('action'),
|
|
88
|
+
children: config.deleteAction && typeof onDelete === 'function' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_copReactComponents.Button, {
|
|
89
|
+
id: "".concat(id, ".deleteButton"),
|
|
90
|
+
onClick: () => onDelete(entryData),
|
|
91
|
+
classModifiers: config.deleteAction.classModifiers || DEFAULT_DELETE_BUTTON_CLASS,
|
|
92
|
+
"aria-label": _copReactComponents.Utils.interpolateString("".concat(((_config$deleteAction = config.deleteAction) === null || _config$deleteAction === void 0 ? void 0 : _config$deleteAction.label) || DEFAULT_DELETE_BUTTON_LABEL, " ").concat(config.title || DEFAULT_TITLE), _objectSpread(_objectSpread({}, entryData), {}, {
|
|
93
|
+
index: entryData.index + 1
|
|
94
|
+
})),
|
|
95
|
+
children: config.deleteAction.label || DEFAULT_DELETE_BUTTON_LABEL
|
|
96
|
+
})
|
|
97
|
+
})]
|
|
98
|
+
})]
|
|
99
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
100
|
+
className: classes('content'),
|
|
101
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("dl", {
|
|
102
|
+
className: listClass(),
|
|
103
|
+
children: masterPage === null || masterPage === void 0 || (_masterPage$childPage = masterPage.childPages) === null || _masterPage$childPage === void 0 ? void 0 : _masterPage$childPage.flatMap(childPage => {
|
|
104
|
+
var _childPage$summaryLay;
|
|
105
|
+
const elevatedComponents = childPage.components.map(component => _utils.default.Component.elevateNested([component], entryData)).flat().filter(Boolean);
|
|
106
|
+
return (_childPage$summaryLay = childPage.summaryLayout) === null || _childPage$summaryLay === void 0 || (_childPage$summaryLay = _childPage$summaryLay.sections) === null || _childPage$summaryLay === void 0 ? void 0 : _childPage$summaryLay.flatMap(section => {
|
|
107
|
+
const filteredColumns = section.columns.filter(column => _Condition.default.meetsAll(column, _objectSpread(_objectSpread({}, childPage.formData), entryData)));
|
|
108
|
+
const summaryFields = filteredColumns.flatMap(column => column.fields || []);
|
|
109
|
+
if (summaryFields.length) {
|
|
110
|
+
return summaryFields.flatMap(fieldId => {
|
|
111
|
+
const component = elevatedComponents.find(comp => comp.fieldId === fieldId);
|
|
112
|
+
if (!component) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
return (0, _getSummaryListRowForDetails.default)(childPage, component, listClass, entryData, optionalFieldPlaceholder);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
103
118
|
return null;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
});
|
|
110
|
-
}))));
|
|
119
|
+
});
|
|
120
|
+
})
|
|
121
|
+
})
|
|
122
|
+
})]
|
|
123
|
+
});
|
|
111
124
|
};
|
|
112
125
|
RenderListView.propTypes = {
|
|
113
126
|
id: _propTypes.default.string.isRequired,
|
|
@@ -5,6 +5,7 @@ var _react2 = _interopRequireDefault(require("react"));
|
|
|
5
5
|
var _setupTests = require("../../setupTests");
|
|
6
6
|
var _RenderListView = _interopRequireDefault(require("./RenderListView"));
|
|
7
7
|
var _models = require("../../models");
|
|
8
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
10
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
11
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -109,13 +110,18 @@ describe('components.CollectionSummary.RenderListView', () => {
|
|
|
109
110
|
beforeEach(() => {
|
|
110
111
|
onDeleteArgs = [];
|
|
111
112
|
});
|
|
112
|
-
const getComponentRow = () => /*#__PURE__*/
|
|
113
|
-
className: "govuk-summary-list__row"
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
113
|
+
const getComponentRow = () => /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
114
|
+
className: "govuk-summary-list__row",
|
|
115
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("dt", {
|
|
116
|
+
className: "govuk-summary-list__key",
|
|
117
|
+
children: "Test Key"
|
|
118
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("dd", {
|
|
119
|
+
className: "govuk-summary-list__value",
|
|
120
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
121
|
+
children: "Test Value"
|
|
122
|
+
})
|
|
123
|
+
})]
|
|
124
|
+
});
|
|
119
125
|
|
|
120
126
|
// Setup function to check rendered elements
|
|
121
127
|
const checkSetup = container => {
|
|
@@ -127,7 +133,7 @@ describe('components.CollectionSummary.RenderListView', () => {
|
|
|
127
133
|
it('should correctly render RenderListView component', () => {
|
|
128
134
|
const {
|
|
129
135
|
container
|
|
130
|
-
} = (0, _setupTests.renderWithValidation)(/*#__PURE__*/
|
|
136
|
+
} = (0, _setupTests.renderWithValidation)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_RenderListView.default, {
|
|
131
137
|
id: ID,
|
|
132
138
|
entryData: ENTRY,
|
|
133
139
|
config: CONFIG,
|
|
@@ -169,7 +175,7 @@ describe('components.CollectionSummary.RenderListView', () => {
|
|
|
169
175
|
it('should render the index correctly in the title', () => {
|
|
170
176
|
const {
|
|
171
177
|
container
|
|
172
|
-
} = (0, _setupTests.renderWithValidation)(/*#__PURE__*/
|
|
178
|
+
} = (0, _setupTests.renderWithValidation)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_RenderListView.default, {
|
|
173
179
|
id: ID,
|
|
174
180
|
entryData: ENTRY,
|
|
175
181
|
config: CONFIG,
|
|
@@ -192,7 +198,7 @@ describe('components.CollectionSummary.RenderListView', () => {
|
|
|
192
198
|
it('should render an Error Tag with Error className when passed an error in the Banner and ClassName', () => {
|
|
193
199
|
const {
|
|
194
200
|
container
|
|
195
|
-
} = (0, _setupTests.renderWithValidation)(/*#__PURE__*/
|
|
201
|
+
} = (0, _setupTests.renderWithValidation)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_RenderListView.default, {
|
|
196
202
|
id: ID,
|
|
197
203
|
entryData: ENTRY,
|
|
198
204
|
config: CONFIG_ERROR,
|
|
@@ -227,7 +233,7 @@ describe('components.CollectionSummary.RenderListView', () => {
|
|
|
227
233
|
it('should render and handle action buttons correctly, including a GOVUK default Change Link when no classModifiers are passed in', () => {
|
|
228
234
|
const {
|
|
229
235
|
container
|
|
230
|
-
} = (0, _setupTests.renderWithValidation)(/*#__PURE__*/
|
|
236
|
+
} = (0, _setupTests.renderWithValidation)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_RenderListView.default, {
|
|
231
237
|
id: ID,
|
|
232
238
|
entryData: ENTRY,
|
|
233
239
|
config: CONFIG,
|
|
@@ -268,7 +274,7 @@ describe('components.CollectionSummary.RenderListView', () => {
|
|
|
268
274
|
});
|
|
269
275
|
const {
|
|
270
276
|
container
|
|
271
|
-
} = (0, _setupTests.renderWithValidation)(/*#__PURE__*/
|
|
277
|
+
} = (0, _setupTests.renderWithValidation)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_RenderListView.default, {
|
|
272
278
|
id: ID,
|
|
273
279
|
entryData: ENTRY,
|
|
274
280
|
config: CONFIG_WITH_BUTTON,
|
|
@@ -16,12 +16,12 @@ var _RenderListView = _interopRequireDefault(require("./RenderListView"));
|
|
|
16
16
|
var _SummaryCardDetails = _interopRequireDefault(require("./SummaryCardDetails"));
|
|
17
17
|
var _SummaryCardButtons = require("./SummaryCardButtons");
|
|
18
18
|
require("./SummaryCard.scss");
|
|
19
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
20
|
const _excluded = ["isDuplicate"];
|
|
20
|
-
function
|
|
21
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
21
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
22
22
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
23
|
-
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var
|
|
24
|
-
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.
|
|
23
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
24
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
25
25
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
26
26
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
27
27
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
@@ -126,7 +126,7 @@ const SummaryCard = _ref => {
|
|
|
126
126
|
// To render summary card in list view as per https://design-system.service.gov.uk/components/summary-list
|
|
127
127
|
if (config.listView) {
|
|
128
128
|
var _config$fullDetails;
|
|
129
|
-
return /*#__PURE__*/
|
|
129
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_RenderListView.default, {
|
|
130
130
|
id: id,
|
|
131
131
|
entryData: entryData,
|
|
132
132
|
config: config,
|
|
@@ -137,74 +137,85 @@ const SummaryCard = _ref => {
|
|
|
137
137
|
optionalFieldPlaceholder: (_config$fullDetails = config.fullDetails) === null || _config$fullDetails === void 0 ? void 0 : _config$fullDetails.optionalFieldPlaceholder
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
|
-
return /*#__PURE__*/
|
|
140
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
141
141
|
className: classes(),
|
|
142
|
-
id: id
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
142
|
+
id: id,
|
|
143
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
144
|
+
className: classes('header'),
|
|
145
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
146
|
+
className: classes('header-content'),
|
|
147
|
+
children: [config.banners && /*#__PURE__*/(0, _jsxRuntime.jsx)(_BannerStrip.default, {
|
|
148
|
+
id: "BannerStrip".concat(entryData.id),
|
|
149
|
+
banners: config.banners,
|
|
150
|
+
formData: entryData
|
|
151
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("h2", {
|
|
152
|
+
id: "".concat(id, ".titleText"),
|
|
153
|
+
className: classes('header-content-title'),
|
|
154
|
+
children: _utils.default.FormPage.getTitle(config.title, entryData)
|
|
155
|
+
}), config.details && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
156
|
+
id: "".concat(id, ".titleDetail"),
|
|
157
|
+
className: classes('header-content-detail'),
|
|
158
|
+
children: _utils.default.FormPage.getConditionalText(config.details, entryData)
|
|
159
|
+
})]
|
|
160
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
161
|
+
className: classes('header-actions'),
|
|
162
|
+
children: [config.quickEdit && /*#__PURE__*/(0, _jsxRuntime.jsx)(_copReactComponents.Button, {
|
|
163
|
+
"data-testid": "quickedit-button",
|
|
164
|
+
id: "".concat(id, ".quickEditButton"),
|
|
165
|
+
onClick: () => setQuickEdit(prevState => !prevState),
|
|
166
|
+
classModifiers: "primary",
|
|
167
|
+
disabled: quickEdit,
|
|
168
|
+
name: "QuickEdit",
|
|
169
|
+
autoFocus: config.focusOn,
|
|
170
|
+
children: DEFAULT_EDIT_LABEL
|
|
171
|
+
}), config.changeAction && typeof onFullEdit === 'function' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_SummaryCardButtons.SummaryCardButtons, {
|
|
172
|
+
id: "".concat(id, ".changeButton"),
|
|
173
|
+
"data-testid": "change-button",
|
|
174
|
+
actions: config.changeAction,
|
|
175
|
+
onFullEdit: onFullEdit,
|
|
176
|
+
entryData: entryData,
|
|
177
|
+
formData: formData,
|
|
178
|
+
name: "Change",
|
|
179
|
+
autoFocus: config.focusOn
|
|
180
|
+
}), config.deleteAction && typeof onDelete === 'function' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_copReactComponents.Button, {
|
|
181
|
+
id: "".concat(id, ".deleteButton"),
|
|
182
|
+
onClick: () => onDelete(entryData),
|
|
183
|
+
classModifiers: "secondary",
|
|
184
|
+
"aria-label": _utils.default.FormPage.getConditionalText((_config$deleteAction = config.deleteAction) === null || _config$deleteAction === void 0 ? void 0 : _config$deleteAction.aria_label, entryData),
|
|
185
|
+
name: "Delete",
|
|
186
|
+
children: ((_config$deleteAction2 = config.deleteAction) === null || _config$deleteAction2 === void 0 ? void 0 : _config$deleteAction2.label) || DEFAULT_DELETE_BUTTON_LABEL
|
|
187
|
+
}), config.duplicateAction && typeof onDuplicate === 'function' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_copReactComponents.Button, {
|
|
188
|
+
"data-testid": "duplicate-button",
|
|
189
|
+
id: "".concat(id, ".duplicateButton"),
|
|
190
|
+
onClick: () => {
|
|
191
|
+
onDuplicate(entryData);
|
|
192
|
+
},
|
|
193
|
+
classModifiers: "secondary",
|
|
194
|
+
"aria-label": _utils.default.FormPage.getConditionalText((_config$duplicateActi = config.duplicateAction) === null || _config$duplicateActi === void 0 ? void 0 : _config$duplicateActi.aria_label, entryData),
|
|
195
|
+
name: "Duplicate",
|
|
196
|
+
autoFocus: config.focusOn,
|
|
197
|
+
children: ((_config$duplicateActi2 = config.duplicateAction) === null || _config$duplicateActi2 === void 0 ? void 0 : _config$duplicateActi2.label) || DEFAULT_DUPLICATE_BUTTON_LABEL
|
|
198
|
+
})]
|
|
199
|
+
})]
|
|
200
|
+
}), quickEdit && quickEditPage && /*#__PURE__*/(0, _jsxRuntime.jsx)(_FormPage.default, {
|
|
201
|
+
page: quickEditPage,
|
|
202
|
+
onAction: (action, patch) => onAction(action, patch),
|
|
203
|
+
className: classes('editpage')
|
|
204
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
205
|
+
className: classes('body'),
|
|
206
|
+
children: !hideDetails && /*#__PURE__*/(0, _jsxRuntime.jsx)(_copReactComponents.Details, {
|
|
207
|
+
summary: config.detailsTitle || DEFAULT_DETAILS_TITLE,
|
|
208
|
+
className: "details",
|
|
209
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_SummaryCardDetails.default, {
|
|
210
|
+
masterPage: masterPage,
|
|
211
|
+
childCollections: childCollections,
|
|
212
|
+
formData: formData,
|
|
213
|
+
entryData: entryData,
|
|
214
|
+
optionalFieldPlaceholder: (_config$fullDetails2 = config.fullDetails) === null || _config$fullDetails2 === void 0 ? void 0 : _config$fullDetails2.optionalFieldPlaceholder
|
|
215
|
+
})
|
|
216
|
+
})
|
|
217
|
+
})]
|
|
218
|
+
});
|
|
208
219
|
};
|
|
209
220
|
SummaryCard.propTypes = {
|
|
210
221
|
id: _propTypes.default.string.isRequired,
|