@ukhomeoffice/cop-react-form-renderer 4.17.0 → 5.0.0-alpha
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 +1 -14
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +19 -57
- package/dist/components/CheckYourAnswers/index.js +0 -3
- package/dist/components/CollectionPage/CollectionPage.js +8 -38
- package/dist/components/CollectionPage/index.js +0 -3
- package/dist/components/FormComponent/Collection.js +13 -54
- package/dist/components/FormComponent/Container.js +6 -30
- package/dist/components/FormComponent/FormComponent.js +14 -57
- package/dist/components/FormComponent/helpers/addLabel.js +4 -7
- package/dist/components/FormComponent/helpers/getComponentDisabled.js +0 -4
- package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +0 -2
- package/dist/components/FormComponent/helpers/getComponentError.js +0 -6
- package/dist/components/FormComponent/helpers/getComponentError.test.js +0 -2
- package/dist/components/FormComponent/helpers/index.js +0 -4
- package/dist/components/FormComponent/index.js +0 -3
- package/dist/components/FormPage/FormPage.js +14 -45
- package/dist/components/FormPage/index.js +0 -3
- package/dist/components/FormRenderer/FormRenderer.js +106 -189
- package/dist/components/FormRenderer/handlers/cyaAction.js +0 -5
- package/dist/components/FormRenderer/handlers/getPageId.js +0 -2
- package/dist/components/FormRenderer/handlers/getPageId.test.js +1 -2
- package/dist/components/FormRenderer/handlers/handlers.test.js +1 -18
- package/dist/components/FormRenderer/handlers/index.js +0 -5
- package/dist/components/FormRenderer/handlers/navigate.js +0 -5
- package/dist/components/FormRenderer/handlers/submissionError.js +0 -2
- package/dist/components/FormRenderer/helpers/canActionProceed.js +0 -3
- package/dist/components/FormRenderer/helpers/canActionProceed.test.js +1 -3
- package/dist/components/FormRenderer/helpers/canCYASubmit.js +0 -2
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +1 -5
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +0 -5
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +1 -2
- package/dist/components/FormRenderer/helpers/getCYA.js +0 -6
- package/dist/components/FormRenderer/helpers/getCYA.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getFormState.js +0 -5
- package/dist/components/FormRenderer/helpers/getFormState.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getNextPageId.js +0 -25
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +1 -4
- package/dist/components/FormRenderer/helpers/getPage.js +0 -5
- package/dist/components/FormRenderer/helpers/getPage.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +0 -6
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +0 -10
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +0 -6
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +6 -20
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +3 -8
- package/dist/components/FormRenderer/helpers/index.js +1 -11
- package/dist/components/FormRenderer/index.js +0 -3
- package/dist/components/PageActions/ActionButton.js +2 -17
- package/dist/components/PageActions/PageActions.js +3 -10
- package/dist/components/PageActions/index.js +0 -3
- package/dist/components/SummaryList/GroupAction.js +3 -24
- package/dist/components/SummaryList/RowAction.js +3 -23
- package/dist/components/SummaryList/SummaryList.js +6 -28
- package/dist/components/SummaryList/SummaryListRow.js +4 -8
- package/dist/components/SummaryList/SummaryListTitleRow.js +2 -7
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +0 -3
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +0 -6
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +0 -3
- package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +0 -6
- package/dist/components/SummaryList/helpers/index.js +0 -2
- package/dist/components/SummaryList/index.js +0 -3
- package/dist/components/TaskList/Task.js +7 -29
- package/dist/components/TaskList/TaskList.js +12 -33
- package/dist/components/TaskList/TaskState.js +2 -10
- package/dist/components/TaskList/index.js +0 -3
- package/dist/components/index.js +0 -6
- package/dist/context/HooksContext/HooksContext.js +14 -34
- package/dist/context/HooksContext/index.js +0 -5
- package/dist/context/ValidationContext/ValidationContext.js +8 -34
- package/dist/context/ValidationContext/index.js +0 -5
- package/dist/context/index.js +0 -3
- package/dist/hooks/index.js +0 -9
- package/dist/hooks/useAxios.js +8 -25
- package/dist/hooks/useGetRequest.js +13 -47
- package/dist/hooks/useHooks.js +2 -4
- package/dist/hooks/useRefData.js +8 -37
- package/dist/hooks/useValidation.js +2 -4
- package/dist/index.js +0 -6
- package/dist/models/PageAction.js +0 -3
- package/dist/models/TaskStates.js +0 -3
- package/dist/models/index.js +0 -9
- package/dist/utils/CheckYourAnswers/getCYAAction.js +1 -9
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +0 -10
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +0 -8
- package/dist/utils/CheckYourAnswers/getCYARow.js +1 -10
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +2 -20
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +0 -18
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +0 -20
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +0 -13
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +2 -22
- package/dist/utils/CheckYourAnswers/index.js +1 -3
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +2 -11
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +0 -11
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +0 -6
- package/dist/utils/CollectionPage/index.js +1 -5
- package/dist/utils/CollectionPage/mergeCollectionPages.js +1 -12
- package/dist/utils/Component/cleanAttributes.js +1 -8
- package/dist/utils/Component/elevateNestedComponents.js +0 -3
- package/dist/utils/Component/getComponent.js +4 -68
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +6 -10
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +10 -28
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +6 -33
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +10 -27
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +4 -10
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +4 -21
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +4 -22
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +3 -7
- package/dist/utils/Component/getComponentTests/getComponent.html.test.js +4 -10
- package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +3 -7
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +6 -15
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +4 -21
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +6 -33
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +4 -21
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +4 -21
- package/dist/utils/Component/getComponentTests/getComponent.textarea.test.js +4 -21
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +10 -29
- package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +1 -2
- package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +3 -7
- package/dist/utils/Component/getDefaultValue.js +0 -7
- package/dist/utils/Component/index.js +0 -9
- package/dist/utils/Component/isEditable.js +1 -4
- package/dist/utils/Component/showComponent.js +1 -8
- package/dist/utils/Component/wrapInFormGroup.js +0 -7
- package/dist/utils/Condition/index.js +0 -5
- package/dist/utils/Condition/meetsAllConditions.js +0 -9
- package/dist/utils/Condition/meetsCondition.js +7 -19
- package/dist/utils/Condition/meetsOneCondition.js +1 -9
- package/dist/utils/Condition/setupConditions.js +0 -12
- package/dist/utils/Container/getEditableComponents.js +0 -7
- package/dist/utils/Container/index.js +0 -5
- package/dist/utils/Container/setupNesting.js +0 -11
- package/dist/utils/Container/showContainer.js +9 -18
- package/dist/utils/Data/applyFormula.js +2 -28
- package/dist/utils/Data/getAutocompleteSource.js +1 -4
- package/dist/utils/Data/getDataPath.js +3 -17
- package/dist/utils/Data/getOptions.js +0 -9
- package/dist/utils/Data/getSourceData.js +4 -19
- package/dist/utils/Data/index.js +1 -11
- package/dist/utils/Data/refDataToOptions.js +1 -12
- package/dist/utils/Data/setDataItem.js +0 -5
- package/dist/utils/Data/setupFormData.js +2 -20
- package/dist/utils/Data/setupRefDataUrlForComponent.js +0 -14
- package/dist/utils/FormPage/getFormPage.js +0 -15
- package/dist/utils/FormPage/getFormPages.js +0 -8
- package/dist/utils/FormPage/getPageActions.js +3 -18
- package/dist/utils/FormPage/getParagraphFromText.js +0 -3
- package/dist/utils/FormPage/index.js +0 -6
- package/dist/utils/FormPage/showFormPage.js +9 -18
- package/dist/utils/FormPage/showFormPageCYA.js +0 -5
- package/dist/utils/FormPage/useComponent.js +3 -18
- package/dist/utils/Format/formatData.js +0 -5
- package/dist/utils/Format/formatDataForComponent.js +1 -6
- package/dist/utils/Format/formatDataForForm.js +0 -8
- package/dist/utils/Format/formatDataForPage.js +1 -5
- package/dist/utils/Format/index.js +1 -6
- package/dist/utils/Hub/getFormHub.js +0 -8
- package/dist/utils/Hub/index.js +1 -3
- package/dist/utils/Meta/documents/getDocuments.js +1 -4
- package/dist/utils/Meta/documents/getDocuments.test.js +0 -9
- package/dist/utils/Meta/documents/index.js +1 -5
- package/dist/utils/Meta/documents/setDocumentForField.js +0 -11
- package/dist/utils/Meta/documents/setDocumentForField.test.js +0 -11
- package/dist/utils/Meta/index.js +2 -6
- package/dist/utils/Operate/checkValueIsTruthy.js +1 -7
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +7 -21
- package/dist/utils/Operate/index.js +0 -3
- package/dist/utils/Operate/persistValueInFormData.js +1 -8
- package/dist/utils/Operate/runPageOperations.js +3 -18
- package/dist/utils/Operate/setValueInFormData.js +2 -7
- package/dist/utils/Operate/shouldRun.js +1 -14
- package/dist/utils/Validate/additional/index.js +1 -18
- package/dist/utils/Validate/additional/index.test.js +0 -6
- package/dist/utils/Validate/additional/mustBeAfter.js +3 -8
- package/dist/utils/Validate/additional/mustBeAfter.test.js +0 -4
- package/dist/utils/Validate/additional/mustBeBefore.js +3 -8
- package/dist/utils/Validate/additional/mustBeBefore.test.js +0 -4
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +5 -16
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +0 -7
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +3 -12
- package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +0 -3
- package/dist/utils/Validate/additional/mustBeInThePast.js +5 -13
- package/dist/utils/Validate/additional/mustBeInThePast.test.js +0 -3
- package/dist/utils/Validate/additional/mustBeLessThan.js +0 -3
- package/dist/utils/Validate/additional/mustBeLessThan.test.js +0 -2
- package/dist/utils/Validate/additional/mustBeLongerThan.js +0 -3
- package/dist/utils/Validate/additional/mustBeLongerThan.test.js +0 -2
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +0 -4
- package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +0 -2
- package/dist/utils/Validate/additional/mustBeShorterThan.js +0 -3
- package/dist/utils/Validate/additional/mustBeShorterThan.test.js +0 -2
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +0 -5
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +0 -4
- package/dist/utils/Validate/additional/utils.js +8 -24
- package/dist/utils/Validate/index.js +1 -9
- package/dist/utils/Validate/validateCollection.js +0 -9
- package/dist/utils/Validate/validateComponent.js +2 -35
- package/dist/utils/Validate/validateContainer.js +0 -13
- package/dist/utils/Validate/validateDate.js +4 -36
- package/dist/utils/Validate/validateEmail.js +1 -7
- package/dist/utils/Validate/validatePage.js +0 -15
- package/dist/utils/Validate/validateRegex.js +0 -10
- package/dist/utils/Validate/validateRequired.js +0 -8
- package/dist/utils/Validate/validateTime.js +3 -20
- package/dist/utils/index.js +0 -19
- package/package.json +50 -34
- package/dist/components/CheckYourAnswers/Answer.test.js +0 -95
- package/dist/components/CheckYourAnswers/CheckYourAnswers.stories.mdx +0 -410
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +0 -680
- package/dist/components/CollectionPage/CollectionPage.test.js +0 -428
- package/dist/components/FormComponent/Collection.test.js +0 -381
- package/dist/components/FormComponent/Container.test.js +0 -423
- package/dist/components/FormComponent/FormComponent.stories.mdx +0 -184
- package/dist/components/FormComponent/FormComponent.test.js +0 -264
- package/dist/components/FormPage/FormPage.stories.mdx +0 -131
- package/dist/components/FormPage/FormPage.test.js +0 -368
- package/dist/components/FormRenderer/FormRenderer.stories.mdx +0 -183
- package/dist/components/FormRenderer/FormRenderer.test.js +0 -1006
- package/dist/components/PageActions/ActionButton.test.js +0 -116
- package/dist/components/PageActions/PageActions.stories.mdx +0 -74
- package/dist/components/PageActions/PageActions.test.js +0 -157
- package/dist/components/SummaryList/GroupAction.test.js +0 -94
- package/dist/components/SummaryList/RowAction.test.js +0 -94
- package/dist/components/SummaryList/SummaryList.stories.mdx +0 -90
- package/dist/components/SummaryList/SummaryList.test.js +0 -361
- package/dist/components/TaskList/Task.test.js +0 -194
- package/dist/components/TaskList/TaskList.stories.mdx +0 -164
- package/dist/components/TaskList/TaskList.test.js +0 -334
- package/dist/components/TaskList/TaskState.test.js +0 -104
- package/dist/context/HooksContext/HooksContext.test.js +0 -60
- package/dist/context/ValidationContext/ValidationContext.test.js +0 -98
- package/dist/json/areYouACivilServant.json +0 -7
- package/dist/json/firstForm.json +0 -94
- package/dist/json/grade.json +0 -108
- package/dist/json/group.data.json +0 -21
- package/dist/json/group.json +0 -402
- package/dist/json/groupOfRow.json +0 -137
- package/dist/json/groupOfRowData.json +0 -15
- package/dist/json/port.json +0 -346
- package/dist/json/saveAndContinue.json +0 -98
- package/dist/json/sublocation.json +0 -859
- package/dist/json/taskList.json +0 -265
- package/dist/json/team.json +0 -17351
- package/dist/json/terminal.json +0 -81
- package/dist/json/userProfile.data.json +0 -21
- package/dist/json/userProfile.json +0 -276
- package/dist/setupTests.js +0 -59
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +0 -139
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +0 -76
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +0 -59
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +0 -256
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +0 -77
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +0 -199
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +0 -170
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +0 -323
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +0 -281
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +0 -64
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +0 -41
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +0 -54
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +0 -131
- package/dist/utils/Component/cleanAttributes.test.js +0 -69
- package/dist/utils/Component/elevateNestedComponents.test.js +0 -92
- package/dist/utils/Component/getDefaultValue.test.js +0 -53
- package/dist/utils/Component/isEditable.test.js +0 -42
- package/dist/utils/Component/showComponent.test.js +0 -157
- package/dist/utils/Condition/meetsAllConditions.test.js +0 -62
- package/dist/utils/Condition/meetsCondition.test.js +0 -391
- package/dist/utils/Condition/meetsOneCondition.test.js +0 -101
- package/dist/utils/Condition/setupConditions.test.js +0 -35
- package/dist/utils/Container/getEditableComponents.test.js +0 -146
- package/dist/utils/Container/setupNesting.test.js +0 -92
- package/dist/utils/Container/showContainer.test.js +0 -179
- package/dist/utils/Data/applyFormula.test.js +0 -264
- package/dist/utils/Data/getAutocompleteSource.test.js +0 -146
- package/dist/utils/Data/getDataPath.test.js +0 -52
- package/dist/utils/Data/getOptions.test.js +0 -71
- package/dist/utils/Data/getSourceData.test.js +0 -141
- package/dist/utils/Data/refDataToOptions.test.js +0 -197
- package/dist/utils/Data/setDataItem.test.js +0 -112
- package/dist/utils/Data/setupFormData.test.js +0 -276
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +0 -133
- package/dist/utils/FormPage/getFormPage.test.js +0 -205
- package/dist/utils/FormPage/getFormPages.test.js +0 -98
- package/dist/utils/FormPage/getPageActions.test.js +0 -89
- package/dist/utils/FormPage/getParagraphFromText.test.js +0 -29
- package/dist/utils/FormPage/showFormPage.test.js +0 -182
- package/dist/utils/FormPage/showFormPageCYA.test.js +0 -30
- package/dist/utils/FormPage/useComponent.test.js +0 -169
- package/dist/utils/Format/formatData.test.js +0 -46
- package/dist/utils/Format/formatDataForComponent.test.js +0 -161
- package/dist/utils/Format/formatDataForForm.test.js +0 -78
- package/dist/utils/Format/formatDataForPage.test.js +0 -96
- package/dist/utils/Hub/getFormHub.test.js +0 -107
- package/dist/utils/Operate/checkValueIsTruthy.test.js +0 -44
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +0 -159
- package/dist/utils/Operate/persistValueInFormData.test.js +0 -106
- package/dist/utils/Operate/runPageOperations.test.js +0 -107
- package/dist/utils/Operate/setValueInFormData.test.js +0 -46
- package/dist/utils/Operate/shouldRun.test.js +0 -69
- package/dist/utils/Validate/validateCollection.test.js +0 -74
- package/dist/utils/Validate/validateComponent.test.js +0 -267
- package/dist/utils/Validate/validateContainer.test.js +0 -81
- package/dist/utils/Validate/validateDate.test.js +0 -118
- package/dist/utils/Validate/validateEmail.test.js +0 -57
- package/dist/utils/Validate/validatePage.test.js +0 -383
- package/dist/utils/Validate/validateRegex.test.js +0 -41
- package/dist/utils/Validate/validateRequired.test.js +0 -62
- package/dist/utils/Validate/validateTime.test.js +0 -61
|
@@ -4,31 +4,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _models = require("../../../models");
|
|
9
|
-
|
|
10
8
|
var getCurrentTaskState = function getCurrentTaskState(_ref, defaultState) {
|
|
11
9
|
var complete = _ref.complete,
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
currentPage = _ref.currentPage;
|
|
14
11
|
if (complete) {
|
|
15
12
|
return _models.TaskStates.TYPES.COMPLETE;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
14
|
if (currentPage) {
|
|
19
15
|
return _models.TaskStates.TYPES.IN_PROGRESS;
|
|
20
16
|
}
|
|
21
|
-
|
|
22
17
|
return defaultState;
|
|
23
18
|
};
|
|
24
|
-
|
|
25
19
|
var allDependentTasksComplete = function allDependentTasksComplete(tasks, mustBeComplete) {
|
|
26
20
|
return mustBeComplete.reduce(function (allComplete, taskName) {
|
|
27
21
|
var _tasks$taskName;
|
|
28
|
-
|
|
29
22
|
return allComplete && ((_tasks$taskName = tasks[taskName]) === null || _tasks$taskName === void 0 ? void 0 : _tasks$taskName.complete);
|
|
30
23
|
}, true);
|
|
31
24
|
};
|
|
25
|
+
|
|
32
26
|
/**
|
|
33
27
|
* Updates the given task list sections with the latest states
|
|
34
28
|
* @param {object} sections The JSON defining the sections in the task list
|
|
@@ -41,8 +35,6 @@ var allDependentTasksComplete = function allDependentTasksComplete(tasks, mustBe
|
|
|
41
35
|
}
|
|
42
36
|
* @returns An JSON representation of the task list sections with up to date states
|
|
43
37
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
38
|
var getUpdatedSequentialStates = function getUpdatedSequentialStates(sections, tasks) {
|
|
47
39
|
return sections.map(function (section, sectionIndex, sectionArray) {
|
|
48
40
|
return section.tasks.map(function (task, taskIndex, taskArray) {
|
|
@@ -50,9 +42,10 @@ var getUpdatedSequentialStates = function getUpdatedSequentialStates(sections, t
|
|
|
50
42
|
task.state = getCurrentTaskState(tasks[task.name], task.state);
|
|
51
43
|
} else {
|
|
52
44
|
var _taskArray, _sectionArray, _sectionArray$tasks$s;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
((_taskArray = taskArray[taskIndex - 1]) === null || _taskArray === void 0 ? void 0 : _taskArray.state) === _models.TaskStates.TYPES.COMPLETE ||
|
|
45
|
+
if (taskIndex === 0 && sectionIndex === 0 ||
|
|
46
|
+
//First task in tasklist
|
|
47
|
+
((_taskArray = taskArray[taskIndex - 1]) === null || _taskArray === void 0 ? void 0 : _taskArray.state) === _models.TaskStates.TYPES.COMPLETE ||
|
|
48
|
+
//any task after a complete task in same section
|
|
56
49
|
taskIndex === 0 && ((_sectionArray = sectionArray[sectionIndex - 1]) === null || _sectionArray === void 0 ? void 0 : (_sectionArray$tasks$s = _sectionArray.tasks.slice(-1)[0]) === null || _sectionArray$tasks$s === void 0 ? void 0 : _sectionArray$tasks$s.state) === _models.TaskStates.TYPES.COMPLETE //any task after a complete task in the preceeding section
|
|
57
50
|
) {
|
|
58
51
|
task.state = _models.TaskStates.TYPES.NOT_STARTED;
|
|
@@ -60,12 +53,10 @@ var getUpdatedSequentialStates = function getUpdatedSequentialStates(sections, t
|
|
|
60
53
|
task.state = _models.TaskStates.TYPES.CANNOT_START_YET;
|
|
61
54
|
}
|
|
62
55
|
}
|
|
63
|
-
|
|
64
56
|
return task;
|
|
65
57
|
});
|
|
66
58
|
});
|
|
67
59
|
};
|
|
68
|
-
|
|
69
60
|
var getUpdatedNonSequentialStates = function getUpdatedNonSequentialStates(sections, tasks) {
|
|
70
61
|
return sections.map(function (section) {
|
|
71
62
|
return section.tasks.map(function (task) {
|
|
@@ -76,21 +67,16 @@ var getUpdatedNonSequentialStates = function getUpdatedNonSequentialStates(secti
|
|
|
76
67
|
} else {
|
|
77
68
|
task.state = _models.TaskStates.TYPES.NOT_STARTED;
|
|
78
69
|
}
|
|
79
|
-
|
|
80
70
|
return task;
|
|
81
71
|
});
|
|
82
72
|
});
|
|
83
73
|
};
|
|
84
|
-
|
|
85
74
|
var getUpdatedSectionStates = function getUpdatedSectionStates(sections, tasks) {
|
|
86
75
|
var nonSequential = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
87
|
-
|
|
88
76
|
if (nonSequential === true) {
|
|
89
77
|
return getUpdatedNonSequentialStates(sections, tasks);
|
|
90
78
|
}
|
|
91
|
-
|
|
92
79
|
return getUpdatedSequentialStates(sections, tasks);
|
|
93
80
|
};
|
|
94
|
-
|
|
95
81
|
var _default = getUpdatedSectionStates;
|
|
96
82
|
exports.default = _default;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _getUpdatedSectionStates = _interopRequireDefault(require("./getUpdatedSectionStates"));
|
|
4
|
-
|
|
5
4
|
var _models = require("../../../models");
|
|
6
|
-
|
|
7
5
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
-
|
|
9
6
|
// Local imports
|
|
7
|
+
|
|
10
8
|
describe('components.FormRenderer.helpers.getUpdatedSectionStates', function () {
|
|
11
9
|
describe('sequential tasks', function () {
|
|
12
10
|
it("should set all tasks to '".concat(_models.TaskStates.TYPES.CANNOT_START_YET, "' excluding the first which should be '").concat(_models.TaskStates.TYPES.NOT_STARTED, "'"), function () {
|
|
@@ -139,13 +137,11 @@ describe('components.FormRenderer.helpers.getUpdatedSectionStates', function ()
|
|
|
139
137
|
it("should set all states to '".concat(_models.TaskStates.TYPES.NOT_STARTED, "', except any that depend on others"), function () {
|
|
140
138
|
var RESULT = (0, _getUpdatedSectionStates.default)(SECTIONS, {}, NON_SEQUENTIAL);
|
|
141
139
|
expect(RESULT[0][0].state).toEqual(_models.TaskStates.TYPES.NOT_STARTED); // Alpha
|
|
142
|
-
|
|
143
140
|
expect(RESULT[0][1].state).toEqual(_models.TaskStates.TYPES.NOT_STARTED); // Bravo
|
|
144
|
-
|
|
145
141
|
expect(RESULT[1][0].state).toEqual(_models.TaskStates.TYPES.CANNOT_START_YET); // Charlie
|
|
146
|
-
|
|
147
142
|
expect(RESULT[2][0].state).toEqual(_models.TaskStates.TYPES.NOT_STARTED); // Delta
|
|
148
143
|
});
|
|
144
|
+
|
|
149
145
|
it('should keep dependent state unable to start if any dependencies are not complete', function () {
|
|
150
146
|
var ALPHA_COMPLETE = (0, _getUpdatedSectionStates.default)(SECTIONS, {
|
|
151
147
|
Alpha: {
|
|
@@ -153,7 +149,6 @@ describe('components.FormRenderer.helpers.getUpdatedSectionStates', function ()
|
|
|
153
149
|
}
|
|
154
150
|
}, NON_SEQUENTIAL);
|
|
155
151
|
expect(ALPHA_COMPLETE[1][0].state).toEqual(_models.TaskStates.TYPES.CANNOT_START_YET); // Charlie
|
|
156
|
-
|
|
157
152
|
var BRAVO_COMPLETE = (0, _getUpdatedSectionStates.default)(SECTIONS, {
|
|
158
153
|
Bravo: {
|
|
159
154
|
complete: true
|
|
@@ -161,6 +156,7 @@ describe('components.FormRenderer.helpers.getUpdatedSectionStates', function ()
|
|
|
161
156
|
}, NON_SEQUENTIAL);
|
|
162
157
|
expect(BRAVO_COMPLETE[1][0].state).toEqual(_models.TaskStates.TYPES.CANNOT_START_YET); // Charlie
|
|
163
158
|
});
|
|
159
|
+
|
|
164
160
|
it('should allow dependent state to start if all dependencies are complete', function () {
|
|
165
161
|
var TASKS = {
|
|
166
162
|
'Alpha': {
|
|
@@ -173,7 +169,6 @@ describe('components.FormRenderer.helpers.getUpdatedSectionStates', function ()
|
|
|
173
169
|
};
|
|
174
170
|
var RESULT = (0, _getUpdatedSectionStates.default)(SECTIONS, TASKS, NON_SEQUENTIAL);
|
|
175
171
|
expect(RESULT[1][0].state).toEqual(_models.TaskStates.TYPES.NOT_STARTED); // Charlie
|
|
176
|
-
|
|
177
172
|
expect(RESULT[2][0].state).toEqual(_models.TaskStates.TYPES.NOT_STARTED); // Delta
|
|
178
173
|
});
|
|
179
174
|
});
|
|
@@ -4,28 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.helpers = exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _canActionProceed = _interopRequireDefault(require("./canActionProceed"));
|
|
9
|
-
|
|
10
8
|
var _canCYASubmit = _interopRequireDefault(require("./canCYASubmit"));
|
|
11
|
-
|
|
12
9
|
var _cleanHiddenNestedData = _interopRequireDefault(require("./cleanHiddenNestedData"));
|
|
13
|
-
|
|
14
10
|
var _getFormState = _interopRequireDefault(require("./getFormState"));
|
|
15
|
-
|
|
16
11
|
var _getRelevantPages = _interopRequireDefault(require("./getRelevantPages"));
|
|
17
|
-
|
|
18
12
|
var _getNextPageId = _interopRequireDefault(require("./getNextPageId"));
|
|
19
|
-
|
|
20
13
|
var _getPage = _interopRequireDefault(require("./getPage"));
|
|
21
|
-
|
|
22
14
|
var _getSubmissionStatus = _interopRequireDefault(require("./getSubmissionStatus"));
|
|
23
|
-
|
|
24
15
|
var _getUpdatedSectionStates = _interopRequireDefault(require("./getUpdatedSectionStates"));
|
|
25
|
-
|
|
26
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
-
|
|
28
17
|
// Local imports
|
|
18
|
+
|
|
29
19
|
var helpers = {
|
|
30
20
|
canActionProceed: _canActionProceed.default,
|
|
31
21
|
canCYASubmit: _canCYASubmit.default,
|
|
@@ -4,10 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _FormRenderer = _interopRequireDefault(require("./FormRenderer"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
9
|
var _default = _FormRenderer.default;
|
|
13
10
|
exports.default = _default;
|
|
@@ -4,40 +4,26 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.DEFAULT_LABEL = void 0;
|
|
7
|
-
|
|
8
7
|
var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _react = _interopRequireDefault(require("react"));
|
|
13
|
-
|
|
14
10
|
var _models = require("../../models");
|
|
15
|
-
|
|
16
11
|
var _excluded = ["action", "onAction"];
|
|
17
|
-
|
|
18
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
13
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
21
|
-
|
|
22
14
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
23
|
-
|
|
24
15
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
25
|
-
|
|
26
16
|
var DEFAULT_LABEL = 'Continue';
|
|
27
17
|
exports.DEFAULT_LABEL = DEFAULT_LABEL;
|
|
28
|
-
|
|
29
18
|
var ActionButton = function ActionButton(_ref) {
|
|
30
19
|
var _action = _ref.action,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
20
|
+
onAction = _ref.onAction,
|
|
21
|
+
attrs = _objectWithoutProperties(_ref, _excluded);
|
|
34
22
|
var action = typeof _action === 'string' ? _models.PageAction.DEFAULTS[_action] : _action;
|
|
35
23
|
var actionLabel = _models.PageAction.DEFAULTS[_action.type];
|
|
36
|
-
|
|
37
24
|
if (!action) {
|
|
38
25
|
return null;
|
|
39
26
|
}
|
|
40
|
-
|
|
41
27
|
return /*#__PURE__*/_react.default.createElement(_copReactComponents.Button, _extends({}, attrs, {
|
|
42
28
|
className: action.className,
|
|
43
29
|
classModifiers: action.classModifiers,
|
|
@@ -47,7 +33,6 @@ var ActionButton = function ActionButton(_ref) {
|
|
|
47
33
|
}
|
|
48
34
|
}), action.label || (actionLabel === null || actionLabel === void 0 ? void 0 : actionLabel.label) || DEFAULT_LABEL);
|
|
49
35
|
};
|
|
50
|
-
|
|
51
36
|
ActionButton.propTypes = {
|
|
52
37
|
action: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.object]).isRequired,
|
|
53
38
|
onAction: _propTypes.default.func.isRequired
|
|
@@ -4,27 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _react = _interopRequireDefault(require("react"));
|
|
13
|
-
|
|
14
10
|
var _ActionButton = _interopRequireDefault(require("./ActionButton"));
|
|
15
|
-
|
|
16
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
12
|
// Global imports
|
|
13
|
+
|
|
19
14
|
// Local imports
|
|
15
|
+
|
|
20
16
|
var PageActions = function PageActions(_ref) {
|
|
21
17
|
var actions = _ref.actions,
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
onAction = _ref.onAction;
|
|
24
19
|
if (!actions || actions.length === 0) {
|
|
25
20
|
return null;
|
|
26
21
|
}
|
|
27
|
-
|
|
28
22
|
return /*#__PURE__*/_react.default.createElement(_copReactComponents.ButtonGroup, null, actions.map(function (action, index) {
|
|
29
23
|
return /*#__PURE__*/_react.default.createElement(_ActionButton.default, {
|
|
30
24
|
key: index,
|
|
@@ -33,7 +27,6 @@ var PageActions = function PageActions(_ref) {
|
|
|
33
27
|
});
|
|
34
28
|
}));
|
|
35
29
|
};
|
|
36
|
-
|
|
37
30
|
PageActions.propTypes = {
|
|
38
31
|
actions: _propTypes.default.array,
|
|
39
32
|
onAction: _propTypes.default.func.isRequired
|
|
@@ -4,10 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _PageActions = _interopRequireDefault(require("./PageActions"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
9
|
var _default = _PageActions.default;
|
|
13
10
|
exports.default = _default;
|
|
@@ -1,63 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
9
|
var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
13
|
-
|
|
14
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
-
|
|
16
11
|
var _getGroupActionAttributes = _interopRequireDefault(require("./helpers/getGroupActionAttributes"));
|
|
17
|
-
|
|
18
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
13
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
-
|
|
22
14
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
-
|
|
24
15
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
25
|
-
|
|
26
16
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
27
|
-
|
|
28
17
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
29
|
-
|
|
30
18
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
31
|
-
|
|
32
19
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
33
|
-
|
|
34
20
|
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
35
|
-
|
|
36
21
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
37
|
-
|
|
38
22
|
var GroupAction = function GroupAction(_ref) {
|
|
39
23
|
var group = _ref.group;
|
|
40
|
-
|
|
41
24
|
var _useState = (0, _react.useState)({}),
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
25
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
26
|
+
attrs = _useState2[0],
|
|
27
|
+
setAttrs = _useState2[1];
|
|
46
28
|
(0, _react.useEffect)(function () {
|
|
47
29
|
setAttrs((0, _getGroupActionAttributes.default)(group));
|
|
48
30
|
}, [group, setAttrs]);
|
|
49
|
-
|
|
50
31
|
if (!(group !== null && group !== void 0 && group.action)) {
|
|
51
32
|
return null;
|
|
52
33
|
}
|
|
53
|
-
|
|
54
34
|
return /*#__PURE__*/_react.default.createElement(_copReactComponents.Link, _extends({}, attrs, {
|
|
55
35
|
"aria-label": "".concat(group.action.label, " ").concat(group.action.aria_suffix)
|
|
56
36
|
}), group.action.label, group.action.aria_suffix && /*#__PURE__*/_react.default.createElement("span", {
|
|
57
37
|
className: "mobile-text govuk-link"
|
|
58
38
|
}, ' ', "".concat(group.action.aria_suffix)));
|
|
59
39
|
};
|
|
60
|
-
|
|
61
40
|
GroupAction.propTypes = {
|
|
62
41
|
group: _propTypes.default.shape({
|
|
63
42
|
action: _propTypes.default.shape({
|
|
@@ -1,57 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
11
|
-
|
|
12
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
-
|
|
16
11
|
var _helpers = require("./helpers");
|
|
17
|
-
|
|
18
12
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
-
|
|
20
13
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
-
|
|
22
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
-
|
|
24
15
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
25
|
-
|
|
26
16
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
27
|
-
|
|
28
17
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
29
|
-
|
|
30
18
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
31
|
-
|
|
32
19
|
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
33
|
-
|
|
34
20
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
35
|
-
|
|
36
21
|
var RowAction = function RowAction(_ref) {
|
|
37
22
|
var row = _ref.row;
|
|
38
|
-
|
|
39
23
|
var _useState = (0, _react.useState)({}),
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
24
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
25
|
+
attrs = _useState2[0],
|
|
26
|
+
setAttrs = _useState2[1];
|
|
44
27
|
(0, _react.useEffect)(function () {
|
|
45
28
|
setAttrs((0, _helpers.getRowActionAttributes)(row));
|
|
46
29
|
}, [row, setAttrs]);
|
|
47
|
-
|
|
48
30
|
if (!row.action) {
|
|
49
31
|
return null;
|
|
50
32
|
}
|
|
51
|
-
|
|
52
33
|
return /*#__PURE__*/_react.default.createElement(_copReactComponents.Link, attrs, row.action.label, row.action.aria_suffix && /*#__PURE__*/_react.default.createElement(_copReactComponents.VisuallyHidden, null, " ", row.action.aria_suffix));
|
|
53
34
|
};
|
|
54
|
-
|
|
55
35
|
RowAction.propTypes = {
|
|
56
36
|
row: _propTypes.default.shape({
|
|
57
37
|
action: _propTypes.default.shape({
|
|
@@ -4,61 +4,42 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.DEFAULT_CLASS = void 0;
|
|
7
|
-
|
|
8
7
|
var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _react = _interopRequireDefault(require("react"));
|
|
13
|
-
|
|
14
10
|
var _GroupAction = _interopRequireDefault(require("./GroupAction"));
|
|
15
|
-
|
|
16
11
|
var _SummaryListRow = _interopRequireDefault(require("./SummaryListRow"));
|
|
17
|
-
|
|
18
12
|
var _SummaryListTitleRow = _interopRequireDefault(require("./SummaryListTitleRow"));
|
|
19
|
-
|
|
20
13
|
require("./SummaryList.scss");
|
|
21
|
-
|
|
22
14
|
var _excluded = ["rows", "noChangeAction", "isGroup", "classBlock", "classModifiers", "className"];
|
|
23
|
-
|
|
24
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
-
|
|
26
16
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
27
|
-
|
|
28
17
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
29
|
-
|
|
30
18
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
31
|
-
|
|
32
19
|
var DEFAULT_CLASS = 'govuk-summary-list';
|
|
33
20
|
exports.DEFAULT_CLASS = DEFAULT_CLASS;
|
|
34
|
-
|
|
35
21
|
var SummaryList = function SummaryList(_ref) {
|
|
36
22
|
var rows = _ref.rows,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
23
|
+
noChangeAction = _ref.noChangeAction,
|
|
24
|
+
isGroup = _ref.isGroup,
|
|
25
|
+
classBlock = _ref.classBlock,
|
|
26
|
+
classModifiers = _ref.classModifiers,
|
|
27
|
+
className = _ref.className,
|
|
28
|
+
attrs = _objectWithoutProperties(_ref, _excluded);
|
|
44
29
|
var classes = _copReactComponents.Utils.classBuilder(classBlock, classModifiers, className);
|
|
45
|
-
|
|
46
30
|
var groupActionRow = null;
|
|
47
|
-
|
|
48
31
|
if (isGroup) {
|
|
49
32
|
var rowActions = rows.filter(function (r) {
|
|
50
33
|
return !!r.action;
|
|
51
34
|
});
|
|
52
35
|
groupActionRow = rowActions.length > 0 ? rowActions[0] : null;
|
|
53
36
|
}
|
|
54
|
-
|
|
55
37
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
56
38
|
className: "group-of-rows"
|
|
57
39
|
}, /*#__PURE__*/_react.default.createElement("dl", _extends({}, attrs, {
|
|
58
40
|
className: classes()
|
|
59
41
|
}), rows.map(function (row) {
|
|
60
42
|
var key = "".concat(row.pageId, "_").concat(row.full_path || row.fieldId);
|
|
61
|
-
|
|
62
43
|
if (row.type === 'title') {
|
|
63
44
|
return /*#__PURE__*/_react.default.createElement(_SummaryListTitleRow.default, {
|
|
64
45
|
key: key,
|
|
@@ -66,7 +47,6 @@ var SummaryList = function SummaryList(_ref) {
|
|
|
66
47
|
classes: classes
|
|
67
48
|
});
|
|
68
49
|
}
|
|
69
|
-
|
|
70
50
|
if (row.type === 'action') {
|
|
71
51
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
72
52
|
key: "".concat(key, "-actions")
|
|
@@ -74,7 +54,6 @@ var SummaryList = function SummaryList(_ref) {
|
|
|
74
54
|
group: row
|
|
75
55
|
}));
|
|
76
56
|
}
|
|
77
|
-
|
|
78
57
|
return /*#__PURE__*/_react.default.createElement(_SummaryListRow.default, {
|
|
79
58
|
key: key,
|
|
80
59
|
row: row,
|
|
@@ -87,7 +66,6 @@ var SummaryList = function SummaryList(_ref) {
|
|
|
87
66
|
group: groupActionRow
|
|
88
67
|
}))));
|
|
89
68
|
};
|
|
90
|
-
|
|
91
69
|
SummaryList.propTypes = {
|
|
92
70
|
rows: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
93
71
|
pageId: _propTypes.default.string.isRequired,
|
|
@@ -4,21 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
9
|
var _RowAction = _interopRequireDefault(require("./RowAction"));
|
|
13
|
-
|
|
14
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
11
|
// Global imports
|
|
12
|
+
|
|
17
13
|
// Local imports
|
|
14
|
+
|
|
18
15
|
var SummaryListRow = function SummaryListRow(_ref) {
|
|
19
16
|
var row = _ref.row,
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
classes = _ref.classes,
|
|
18
|
+
showAction = _ref.showAction;
|
|
22
19
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
23
20
|
className: classes('row')
|
|
24
21
|
}, /*#__PURE__*/_react.default.createElement("dt", {
|
|
@@ -31,7 +28,6 @@ var SummaryListRow = function SummaryListRow(_ref) {
|
|
|
31
28
|
row: row
|
|
32
29
|
})));
|
|
33
30
|
};
|
|
34
|
-
|
|
35
31
|
SummaryListRow.propTypes = {
|
|
36
32
|
row: _propTypes.default.shape({
|
|
37
33
|
key: _propTypes.default.string.isRequired,
|
|
@@ -4,24 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _react = _interopRequireDefault(require("react"));
|
|
13
|
-
|
|
14
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
11
|
// Global imports
|
|
12
|
+
|
|
17
13
|
var SummaryListTitleRow = function SummaryListTitleRow(_ref) {
|
|
18
14
|
var title = _ref.title,
|
|
19
|
-
|
|
15
|
+
classes = _ref.classes;
|
|
20
16
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
21
17
|
className: "".concat(classes('row'), " ").concat(classes('title'))
|
|
22
18
|
}, /*#__PURE__*/_react.default.createElement(_copReactComponents.SmallHeading, null, title));
|
|
23
19
|
};
|
|
24
|
-
|
|
25
20
|
SummaryListTitleRow.propTypes = {
|
|
26
21
|
title: _propTypes.default.string.isRequired,
|
|
27
22
|
classes: _propTypes.default.func.isRequired
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var getGroupActionAttributes = function getGroupActionAttributes(groupRow) {
|
|
9
8
|
if (groupRow && Object.prototype.hasOwnProperty.call(groupRow, 'action')) {
|
|
10
9
|
if (typeof groupRow.action.onAction === 'function') {
|
|
@@ -25,9 +24,7 @@ var getGroupActionAttributes = function getGroupActionAttributes(groupRow) {
|
|
|
25
24
|
};
|
|
26
25
|
}
|
|
27
26
|
}
|
|
28
|
-
|
|
29
27
|
return {};
|
|
30
28
|
};
|
|
31
|
-
|
|
32
29
|
var _default = getGroupActionAttributes;
|
|
33
30
|
exports.default = _default;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _getGroupActionAttributes = _interopRequireDefault(require("./getGroupActionAttributes"));
|
|
4
|
-
|
|
5
4
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
7
5
|
describe('components', function () {
|
|
8
6
|
describe('SummaryList', function () {
|
|
9
7
|
describe('helpers', function () {
|
|
@@ -33,11 +31,9 @@ describe('components', function () {
|
|
|
33
31
|
});
|
|
34
32
|
it('should handle a row with an onAction function', function () {
|
|
35
33
|
var ON_ACTION_CALLS = [];
|
|
36
|
-
|
|
37
34
|
var ON_ACTION = function ON_ACTION(row) {
|
|
38
35
|
ON_ACTION_CALLS.push(row);
|
|
39
36
|
};
|
|
40
|
-
|
|
41
37
|
var ROW = {
|
|
42
38
|
action: {
|
|
43
39
|
onAction: ON_ACTION
|
|
@@ -52,11 +48,9 @@ describe('components', function () {
|
|
|
52
48
|
});
|
|
53
49
|
it('should favour onAction over href', function () {
|
|
54
50
|
var ON_ACTION_CALLS = [];
|
|
55
|
-
|
|
56
51
|
var ON_ACTION = function ON_ACTION(row) {
|
|
57
52
|
ON_ACTION_CALLS.push(row);
|
|
58
53
|
};
|
|
59
|
-
|
|
60
54
|
var HREF = 'http://alpha.homeoffice.gov.uk';
|
|
61
55
|
var ROW = {
|
|
62
56
|
action: {
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var getRowActionAttributes = function getRowActionAttributes(row) {
|
|
9
8
|
if (row && row.action) {
|
|
10
9
|
if (typeof row.action.onAction === 'function') {
|
|
@@ -25,9 +24,7 @@ var getRowActionAttributes = function getRowActionAttributes(row) {
|
|
|
25
24
|
};
|
|
26
25
|
}
|
|
27
26
|
}
|
|
28
|
-
|
|
29
27
|
return {};
|
|
30
28
|
};
|
|
31
|
-
|
|
32
29
|
var _default = getRowActionAttributes;
|
|
33
30
|
exports.default = _default;
|