@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
|
@@ -1,83 +1,54 @@
|
|
|
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 = exports.DEFAULT_CLASS = 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 _context = require("../../context");
|
|
17
|
-
|
|
18
12
|
var _hooks = require("../../hooks");
|
|
19
|
-
|
|
20
13
|
var _models = require("../../models");
|
|
21
|
-
|
|
22
14
|
var _utils = _interopRequireDefault(require("../../utils"));
|
|
23
|
-
|
|
24
15
|
var _CheckYourAnswers = _interopRequireDefault(require("../CheckYourAnswers"));
|
|
25
|
-
|
|
26
16
|
var _CollectionPage = _interopRequireDefault(require("../CollectionPage"));
|
|
27
|
-
|
|
28
17
|
var _FormPage = _interopRequireDefault(require("../FormPage"));
|
|
29
|
-
|
|
30
18
|
var _TaskList = _interopRequireDefault(require("../TaskList"));
|
|
31
|
-
|
|
32
19
|
var _handlers = _interopRequireDefault(require("./handlers"));
|
|
33
|
-
|
|
34
20
|
var _helpers = _interopRequireDefault(require("./helpers"));
|
|
35
|
-
|
|
36
21
|
require("./FormRenderer.scss");
|
|
37
|
-
|
|
38
22
|
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); }
|
|
39
|
-
|
|
40
23
|
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; }
|
|
41
|
-
|
|
42
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
43
|
-
|
|
44
25
|
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); }
|
|
45
|
-
|
|
46
26
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
47
|
-
|
|
48
27
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
49
|
-
|
|
50
28
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
51
|
-
|
|
52
29
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
53
|
-
|
|
54
30
|
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."); }
|
|
55
|
-
|
|
56
31
|
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); }
|
|
57
|
-
|
|
58
32
|
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; }
|
|
59
|
-
|
|
60
33
|
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; }
|
|
61
|
-
|
|
62
34
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
63
|
-
|
|
64
35
|
var FormRenderer = function FormRenderer(_ref) {
|
|
65
36
|
var title = _ref.title,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
37
|
+
type = _ref.type,
|
|
38
|
+
components = _ref.components,
|
|
39
|
+
pages = _ref.pages,
|
|
40
|
+
hub = _ref.hub,
|
|
41
|
+
cya = _ref.cya,
|
|
42
|
+
data = _ref.data,
|
|
43
|
+
hooks = _ref.hooks,
|
|
44
|
+
classBlock = _ref.classBlock,
|
|
45
|
+
classModifiers = _ref.classModifiers,
|
|
46
|
+
className = _ref.className,
|
|
47
|
+
hide_title = _ref.hide_title,
|
|
48
|
+
summaryListClassModifiers = _ref.summaryListClassModifiers,
|
|
49
|
+
noChangeAction = _ref.noChangeAction,
|
|
50
|
+
newPageId = _ref.newPageId,
|
|
51
|
+
viewOnly = _ref.viewOnly;
|
|
81
52
|
return /*#__PURE__*/_react.default.createElement(_context.HooksContextProvider, {
|
|
82
53
|
overrides: hooks
|
|
83
54
|
}, /*#__PURE__*/_react.default.createElement(_context.ValidationContextProvider, null, /*#__PURE__*/_react.default.createElement(InternalFormRenderer, {
|
|
@@ -98,167 +69,153 @@ var FormRenderer = function FormRenderer(_ref) {
|
|
|
98
69
|
viewOnly: viewOnly
|
|
99
70
|
})));
|
|
100
71
|
};
|
|
101
|
-
|
|
102
72
|
var DEFAULT_CLASS = 'hods-form';
|
|
103
73
|
exports.DEFAULT_CLASS = DEFAULT_CLASS;
|
|
104
|
-
|
|
105
74
|
var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
106
75
|
var _formState$page4;
|
|
107
|
-
|
|
108
76
|
var title = _ref2.title,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
77
|
+
type = _ref2.type,
|
|
78
|
+
components = _ref2.components,
|
|
79
|
+
_pages = _ref2.pages,
|
|
80
|
+
_hub = _ref2.hub,
|
|
81
|
+
cya = _ref2.cya,
|
|
82
|
+
_data = _ref2.data,
|
|
83
|
+
classBlock = _ref2.classBlock,
|
|
84
|
+
classModifiers = _ref2.classModifiers,
|
|
85
|
+
className = _ref2.className,
|
|
86
|
+
hide_title = _ref2.hide_title,
|
|
87
|
+
summaryListClassModifiers = _ref2.summaryListClassModifiers,
|
|
88
|
+
noChangeAction = _ref2.noChangeAction,
|
|
89
|
+
newPageId = _ref2.newPageId,
|
|
90
|
+
viewOnly = _ref2.viewOnly;
|
|
124
91
|
// Set up the initial states.
|
|
125
92
|
var _useState = (0, _react.useState)({}),
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
93
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
94
|
+
data = _useState2[0],
|
|
95
|
+
setData = _useState2[1];
|
|
130
96
|
var _useState3 = (0, _react.useState)(),
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
97
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
98
|
+
submitted = _useState4[0],
|
|
99
|
+
setSubmitted = _useState4[1];
|
|
135
100
|
var _useState5 = (0, _react.useState)([]),
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
101
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
102
|
+
pages = _useState6[0],
|
|
103
|
+
setPages = _useState6[1];
|
|
140
104
|
var _useState7 = (0, _react.useState)(undefined),
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
105
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
106
|
+
hub = _useState8[0],
|
|
107
|
+
setHub = _useState8[1];
|
|
145
108
|
var _useState9 = (0, _react.useState)(_helpers.default.getNextPageId(type, _pages, null, null, _data)),
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
109
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
110
|
+
pageId = _useState10[0],
|
|
111
|
+
setPageId = _useState10[1];
|
|
150
112
|
var _useState11 = (0, _react.useState)(_helpers.default.getFormState(pageId, pages, hub)),
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
113
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
114
|
+
formState = _useState12[0],
|
|
115
|
+
setFormState = _useState12[1];
|
|
155
116
|
var _useState13 = (0, _react.useState)({}),
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
117
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
118
|
+
currentTask = _useState14[0],
|
|
119
|
+
setCurrentTask = _useState14[1];
|
|
160
120
|
var _useState15 = (0, _react.useState)({}),
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
121
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
122
|
+
hubDetails = _useState16[0],
|
|
123
|
+
setHubDetails = _useState16[1];
|
|
165
124
|
var _useState17 = (0, _react.useState)('load'),
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
125
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
|
126
|
+
pagePoint = _useState18[0],
|
|
127
|
+
setPagePoint = _useState18[1];
|
|
170
128
|
var _useState19 = (0, _react.useState)(false),
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
129
|
+
_useState20 = _slicedToArray(_useState19, 2),
|
|
130
|
+
goingBack = _useState20[0],
|
|
131
|
+
setGoingBack = _useState20[1];
|
|
175
132
|
|
|
133
|
+
// Set up hooks.
|
|
176
134
|
var _useHooks = (0, _hooks.useHooks)(),
|
|
177
|
-
|
|
178
|
-
|
|
135
|
+
hooks = _useHooks.hooks;
|
|
179
136
|
|
|
137
|
+
// Set up the useValidation hook.
|
|
180
138
|
var _useValidation = (0, _hooks.useValidation)(),
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
139
|
+
addErrors = _useValidation.addErrors,
|
|
140
|
+
clearErrors = _useValidation.clearErrors,
|
|
141
|
+
validate = _useValidation.validate;
|
|
185
142
|
|
|
143
|
+
// Need to set submission data when going back
|
|
186
144
|
window.onpopstate = function () {
|
|
187
145
|
var _formState$page;
|
|
188
|
-
|
|
189
146
|
setGoingBack(true);
|
|
190
147
|
hooks.onGoingBack();
|
|
191
148
|
clearErrors();
|
|
192
|
-
|
|
193
149
|
if (components && pages && data && (_formState$page = formState.page) !== null && _formState$page !== void 0 && _formState$page.formData && pagePoint === undefined) {
|
|
194
150
|
var submissionData = _utils.default.Format.form({
|
|
195
151
|
pages: pages,
|
|
196
152
|
components: components
|
|
197
153
|
}, _objectSpread(_objectSpread({}, data), formState.page.formData), _models.EventTypes.SUBMIT);
|
|
198
|
-
|
|
199
154
|
setData(submissionData);
|
|
200
155
|
}
|
|
201
|
-
};
|
|
202
|
-
|
|
156
|
+
};
|
|
203
157
|
|
|
158
|
+
// Setup data.
|
|
204
159
|
(0, _react.useEffect)(function () {
|
|
205
160
|
if (components && _pages && _data && (pagePoint === 'load' || viewOnly)) {
|
|
206
161
|
var _data$formStatus;
|
|
207
|
-
|
|
208
162
|
setData(_utils.default.Data.setupForm(_pages, components, _data));
|
|
209
|
-
|
|
210
163
|
if ((_data$formStatus = _data.formStatus) !== null && _data$formStatus !== void 0 && _data$formStatus.page) {
|
|
211
164
|
setPageId(_data.formStatus.page);
|
|
212
165
|
}
|
|
213
166
|
}
|
|
214
|
-
}, [components, _pages, _data, setData, pagePoint, viewOnly]);
|
|
167
|
+
}, [components, _pages, _data, setData, pagePoint, viewOnly]);
|
|
215
168
|
|
|
169
|
+
// Setup pages.
|
|
216
170
|
(0, _react.useEffect)(function () {
|
|
217
171
|
setPages(_utils.default.FormPage.getAll(_pages, components, _objectSpread({}, data)));
|
|
218
|
-
}, [components, _pages, data, setPages]);
|
|
172
|
+
}, [components, _pages, data, setPages]);
|
|
219
173
|
|
|
174
|
+
// Setup initial pageId.
|
|
220
175
|
(0, _react.useEffect)(function () {
|
|
221
176
|
setPageId(function (prev) {
|
|
222
177
|
return prev || _helpers.default.getNextPageId(type, pages);
|
|
223
178
|
});
|
|
224
|
-
}, [type, pages, setPageId]);
|
|
179
|
+
}, [type, pages, setPageId]);
|
|
225
180
|
|
|
181
|
+
// Setup hub.
|
|
226
182
|
(0, _react.useEffect)(function () {
|
|
227
183
|
setHub(_utils.default.Hub.get(type, _hub, components, _objectSpread({}, data)));
|
|
228
|
-
}, [type, _hub, data, components, setHub]);
|
|
184
|
+
}, [type, _hub, data, components, setHub]);
|
|
229
185
|
|
|
186
|
+
// Form state.
|
|
230
187
|
(0, _react.useEffect)(function () {
|
|
231
188
|
var _formState$page2;
|
|
232
|
-
|
|
233
189
|
// revert formData changes if going back in hub-and-spoke
|
|
234
190
|
if (type === _models.FormTypes.HUB && goingBack && data && (_formState$page2 = formState.page) !== null && _formState$page2 !== void 0 && _formState$page2.formData) {
|
|
235
191
|
formState.page.formData = _objectSpread({}, data);
|
|
236
192
|
}
|
|
237
|
-
|
|
238
193
|
setGoingBack(false);
|
|
239
194
|
setFormState(_helpers.default.getFormState(pageId, pages, hub));
|
|
240
|
-
}, [pages, hub, pageId, setFormState, type, goingBack, data, formState.page]);
|
|
195
|
+
}, [pages, hub, pageId, setFormState, type, goingBack, data, formState.page]);
|
|
241
196
|
|
|
197
|
+
// Call the onFormLoad hook just when this component first renders.
|
|
242
198
|
(0, _react.useEffect)(function () {
|
|
243
199
|
setPagePoint(undefined);
|
|
244
200
|
hooks.onFormLoad();
|
|
245
201
|
}, [hooks]);
|
|
246
202
|
(0, _react.useEffect)(function () {
|
|
247
203
|
setHubDetails(_hub);
|
|
248
|
-
}, [_hub]);
|
|
204
|
+
}, [_hub]);
|
|
205
|
+
|
|
206
|
+
// Calling setData directly within the hooks.onSubmit success handler
|
|
249
207
|
// resulted in a sychronisation error. Handling it in a useEffect appears
|
|
250
208
|
// to be the way to deal with this... and it certainly seems to work.
|
|
251
|
-
|
|
252
209
|
(0, _react.useEffect)(function () {
|
|
253
210
|
if (submitted !== null && submitted !== void 0 && submitted.data) {
|
|
254
211
|
setData(submitted.data);
|
|
255
212
|
setSubmitted(undefined);
|
|
256
213
|
}
|
|
257
|
-
}, [submitted, setData, setSubmitted]);
|
|
214
|
+
}, [submitted, setData, setSubmitted]);
|
|
258
215
|
|
|
216
|
+
// Update task list pages with form data and update states
|
|
259
217
|
(0, _react.useEffect)(function () {
|
|
260
218
|
var pages = currentTask.fullPages;
|
|
261
|
-
|
|
262
219
|
if (pages) {
|
|
263
220
|
pages.forEach(function (page) {
|
|
264
221
|
page.formData = data;
|
|
@@ -269,128 +226,105 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
269
226
|
});
|
|
270
227
|
});
|
|
271
228
|
}
|
|
272
|
-
|
|
273
229
|
if (hubDetails !== null && hubDetails !== void 0 && hubDetails.sections) {
|
|
274
230
|
var _data$formStatus2;
|
|
275
|
-
|
|
276
231
|
var tasks = (data === null || data === void 0 ? void 0 : (_data$formStatus2 = data.formStatus) === null || _data$formStatus2 === void 0 ? void 0 : _data$formStatus2.tasks) || {};
|
|
277
|
-
|
|
278
232
|
var updatedSections = _helpers.default.getUpdatedSectionStates(hubDetails.sections, tasks, hubDetails.nonSequential);
|
|
279
|
-
|
|
280
233
|
setHubDetails(function (prev) {
|
|
281
234
|
return _objectSpread(_objectSpread({}, prev), updatedSections);
|
|
282
235
|
});
|
|
283
236
|
}
|
|
284
237
|
}, [currentTask.fullPages, data, hubDetails === null || hubDetails === void 0 ? void 0 : hubDetails.sections, hubDetails === null || hubDetails === void 0 ? void 0 : hubDetails.nonSequential]);
|
|
285
|
-
|
|
286
238
|
var onPageChange = function onPageChange(newPageId) {
|
|
287
239
|
clearErrors();
|
|
288
240
|
setPageId(newPageId);
|
|
289
241
|
hooks.onPageChange(newPageId);
|
|
290
242
|
};
|
|
291
|
-
|
|
292
243
|
(0, _react.useEffect)(function () {
|
|
293
244
|
if (newPageId !== undefined) setPageId(newPageId);
|
|
294
|
-
}, [newPageId]);
|
|
245
|
+
}, [newPageId]);
|
|
246
|
+
|
|
247
|
+
// Handle actions from pages.
|
|
295
248
|
// (patch captures payload ready field name and value,
|
|
296
249
|
// patchLabel captures non ID values
|
|
297
250
|
// for display purposes after submission.)
|
|
298
|
-
|
|
299
251
|
var onPageAction = function onPageAction(action, patch, patchLabel) {
|
|
300
252
|
if (action.type === _models.PageAction.TYPES.CANCEL) {
|
|
301
253
|
hooks.onCancel();
|
|
302
254
|
return;
|
|
303
|
-
}
|
|
255
|
+
}
|
|
256
|
+
// Re-apply the patch to the page's formData.
|
|
304
257
|
// This should normally have no effect but will prevent issues
|
|
305
258
|
// with validation if formData happens to have been wiped.
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
formState.page.formData = _objectSpread(_objectSpread({}, formState.page.formData), patch); // Check to see whether the action is able to proceed, which in
|
|
259
|
+
formState.page.formData = _objectSpread(_objectSpread({}, formState.page.formData), patch);
|
|
260
|
+
// Check to see whether the action is able to proceed, which in
|
|
309
261
|
// in the case of a submission will validate the fields in the page.
|
|
310
|
-
|
|
311
262
|
if (_helpers.default.canActionProceed(action, formState.page, validate.page)) {
|
|
312
263
|
patch = _helpers.default.cleanHiddenNestedData(patch, formState.page);
|
|
313
|
-
|
|
314
264
|
if (action.addToFormData) {
|
|
315
265
|
formState.page.formData[action.addToFormData.field] = action.addToFormData.value;
|
|
316
266
|
}
|
|
317
|
-
|
|
318
267
|
if (action.type === _models.PageAction.TYPES.NAVIGATE) {
|
|
319
268
|
_handlers.default.navigate(action, pageId, onPageChange);
|
|
320
269
|
} else {
|
|
321
270
|
var pageUpdate = function pageUpdate(next) {
|
|
322
271
|
return onPageChange(_helpers.default.getNextPageId(type, pages, pageId, action, next));
|
|
323
272
|
};
|
|
324
|
-
|
|
325
273
|
switch (action.type) {
|
|
326
274
|
case _models.PageAction.TYPES.SUBMIT:
|
|
327
275
|
setPagePoint('submit');
|
|
328
276
|
break;
|
|
329
|
-
|
|
330
277
|
case _models.PageAction.TYPES.SAVE_AND_NAVIGATE:
|
|
331
278
|
pageUpdate = function pageUpdate() {
|
|
332
279
|
return _handlers.default.navigate(action, pageId, onPageChange);
|
|
333
280
|
};
|
|
334
|
-
|
|
335
281
|
break;
|
|
336
|
-
|
|
337
282
|
case _models.PageAction.TYPES.COLLECTION_ADD:
|
|
338
283
|
formState.page.formData["".concat(action.collection, "ActiveId")] = Date.now().toString();
|
|
339
|
-
|
|
340
284
|
pageUpdate = function pageUpdate() {
|
|
341
285
|
return _handlers.default.navigate(action, pageId, onPageChange);
|
|
342
286
|
};
|
|
343
|
-
|
|
344
287
|
break;
|
|
345
|
-
|
|
346
288
|
case _models.PageAction.TYPES.COLLECTION_DUPLICATE:
|
|
347
289
|
if (_utils.default.CollectionPage.duplicateActiveEntry(action.collection, formState.page.formData)) {
|
|
348
290
|
pageUpdate = function pageUpdate() {
|
|
349
291
|
return _handlers.default.navigate(action, pageId, onPageChange);
|
|
350
292
|
};
|
|
351
293
|
}
|
|
352
|
-
|
|
353
294
|
break;
|
|
354
|
-
|
|
355
295
|
case _models.PageAction.TYPES.COLLECTION_REMOVE:
|
|
356
296
|
var activeId = formState.page.formData["".concat(action.collection, "ActiveId")];
|
|
357
297
|
formState.page.formData["".concat(action.collection)] = formState.page.formData["".concat(action.collection)].filter(function (entry) {
|
|
358
298
|
return entry.id !== activeId;
|
|
359
299
|
});
|
|
360
300
|
break;
|
|
361
|
-
|
|
362
301
|
default:
|
|
363
302
|
break;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
|
|
303
|
+
}
|
|
304
|
+
// Save draft or submit.
|
|
367
305
|
var submissionData = _utils.default.Format.form({
|
|
368
306
|
pages: pages,
|
|
369
307
|
components: components
|
|
370
308
|
}, _objectSpread(_objectSpread(_objectSpread({}, data), patch), formState.page.formData), _models.EventTypes.SUBMIT);
|
|
371
|
-
|
|
372
309
|
submissionData.formStatus = _helpers.default.getSubmissionStatus(type, pages, pageId, action, submissionData, currentTask, true, hubDetails === null || hubDetails === void 0 ? void 0 : hubDetails.sections);
|
|
373
|
-
|
|
374
310
|
if (patch) {
|
|
375
311
|
setData(submissionData);
|
|
376
|
-
}
|
|
377
|
-
// save name and value to variables for call to onSubmit hook
|
|
378
|
-
|
|
312
|
+
}
|
|
379
313
|
|
|
314
|
+
// In case of hub-and-spoke if patchLabel has changed then
|
|
315
|
+
// save name and value to variables for call to onSubmit hook
|
|
380
316
|
var changedFieldName;
|
|
381
317
|
var changedFieldValue;
|
|
382
|
-
|
|
383
318
|
if (type === _models.FormTypes.HUB && Object.keys(patchLabel).length > 0) {
|
|
384
319
|
changedFieldName = Object.keys(patchLabel)[0];
|
|
385
320
|
changedFieldValue = Object.values(patchLabel)[0];
|
|
386
|
-
}
|
|
387
|
-
|
|
321
|
+
}
|
|
388
322
|
|
|
323
|
+
// Now submit the data to the backend...
|
|
389
324
|
hooks.onSubmit(action.type, submissionData, function (response) {
|
|
390
325
|
// The backend response may well contain data we need so apply it...
|
|
391
326
|
// ... but this needs to happen in a useEffect, not right away.
|
|
392
327
|
var sData = _objectSpread(_objectSpread({}, submissionData), response);
|
|
393
|
-
|
|
394
328
|
setSubmitted({
|
|
395
329
|
data: sData
|
|
396
330
|
});
|
|
@@ -400,27 +334,25 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
400
334
|
}, changedFieldName, changedFieldValue);
|
|
401
335
|
}
|
|
402
336
|
}
|
|
403
|
-
};
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
// Handle navigation from "Check your answers".
|
|
404
340
|
// Passing a dataCallback allows changes to formData from the
|
|
405
341
|
// CYA screen. This is necessary to alow changing the active
|
|
406
342
|
// entry in page collections.
|
|
407
|
-
|
|
408
|
-
|
|
409
343
|
var onCYARowAction = function onCYARowAction(page, dataCallback) {
|
|
410
344
|
if (typeof dataCallback === 'function') {
|
|
411
345
|
var newData = dataCallback(_objectSpread({}, data));
|
|
412
|
-
|
|
413
346
|
if (newData) {
|
|
414
347
|
setData(newData);
|
|
415
348
|
}
|
|
416
349
|
}
|
|
417
|
-
|
|
418
350
|
if (page) {
|
|
419
351
|
_handlers.default.cyaAction(page, pageId, onPageChange);
|
|
420
352
|
}
|
|
421
|
-
};
|
|
422
|
-
|
|
353
|
+
};
|
|
423
354
|
|
|
355
|
+
//Kick off a task, gather required pages and move to the correct point
|
|
424
356
|
var onTaskAction = function onTaskAction(currentTask) {
|
|
425
357
|
if (currentTask) {
|
|
426
358
|
currentTask.fullPages = [];
|
|
@@ -428,7 +360,6 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
428
360
|
currentTask.fullPages.push(_helpers.default.getPage(page, pages));
|
|
429
361
|
});
|
|
430
362
|
setCurrentTask(currentTask);
|
|
431
|
-
|
|
432
363
|
if (currentTask.state === _models.TaskStates.TYPES.COMPLETE) {
|
|
433
364
|
if (hubDetails !== null && hubDetails !== void 0 && hubDetails.noTaskCYAs) {
|
|
434
365
|
var currentPage = data.formStatus.tasks[currentTask.name].currentPage;
|
|
@@ -446,25 +377,23 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
446
377
|
onPageChange(currentTask.pages[0]);
|
|
447
378
|
}
|
|
448
379
|
}
|
|
449
|
-
};
|
|
450
|
-
|
|
380
|
+
};
|
|
451
381
|
|
|
382
|
+
// Handle actions from "Check your answers".
|
|
452
383
|
var onCYAAction = function onCYAAction(action) {
|
|
453
384
|
// Check to see whether the action is able to proceed, which in
|
|
454
385
|
// in the case of a submission will validate the fields in the page.
|
|
455
386
|
if (action.type === _models.PageAction.TYPES.SUBMIT) {
|
|
456
387
|
setPagePoint('submit');
|
|
457
|
-
|
|
458
388
|
if (_helpers.default.canCYASubmit(pages, validate.pages)) {
|
|
459
389
|
// Submit.
|
|
460
390
|
var submissionData = _utils.default.Format.form({
|
|
461
391
|
pages: pages,
|
|
462
392
|
components: components
|
|
463
393
|
}, _objectSpread({}, data), _models.EventTypes.SUBMIT);
|
|
464
|
-
|
|
465
394
|
submissionData.formStatus = _helpers.default.getSubmissionStatus(type, pages, pageId, action, submissionData, currentTask, true);
|
|
466
|
-
setData(submissionData);
|
|
467
|
-
|
|
395
|
+
setData(submissionData);
|
|
396
|
+
// Now submit the data to the backend...
|
|
468
397
|
hooks.onSubmit(action.type, submissionData, function () {
|
|
469
398
|
return hooks.onFormComplete();
|
|
470
399
|
}, function (errors) {
|
|
@@ -472,14 +401,12 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
472
401
|
});
|
|
473
402
|
}
|
|
474
403
|
}
|
|
475
|
-
|
|
476
404
|
if (action.type === _models.PageAction.TYPES.SAVE_AND_CONTINUE && hub === _models.HubFormats.TASK) {
|
|
477
405
|
if (_helpers.default.canCYASubmit(currentTask.fullPages, validate.pages)) {
|
|
478
406
|
var _submissionData = _utils.default.Format.form({
|
|
479
407
|
pages: pages,
|
|
480
408
|
components: components
|
|
481
409
|
}, _objectSpread({}, data), _models.EventTypes.SUBMIT);
|
|
482
|
-
|
|
483
410
|
_submissionData.formStatus = _helpers.default.getSubmissionStatus(type, pages, pageId, action, _submissionData, currentTask, true);
|
|
484
411
|
setData(_submissionData);
|
|
485
412
|
hooks.onSubmit(action.type, _submissionData, function () {
|
|
@@ -489,14 +416,12 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
489
416
|
});
|
|
490
417
|
}
|
|
491
418
|
}
|
|
492
|
-
|
|
493
419
|
if (action.type === _models.PageAction.TYPES.SAVE_AND_RETURN) {
|
|
494
420
|
if (_helpers.default.canCYASubmit(currentTask.fullPages, validate.pages)) {
|
|
495
421
|
var _submissionData2 = _utils.default.Format.form({
|
|
496
422
|
pages: pages,
|
|
497
423
|
components: components
|
|
498
424
|
}, _objectSpread({}, data), _models.EventTypes.SUBMIT);
|
|
499
|
-
|
|
500
425
|
_submissionData2.formStatus = _helpers.default.getSubmissionStatus(type, pages, pageId, action, _submissionData2, currentTask);
|
|
501
426
|
setData(_submissionData2);
|
|
502
427
|
hooks.onSubmit(action.type, _submissionData2, function () {
|
|
@@ -510,24 +435,18 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
510
435
|
});
|
|
511
436
|
}
|
|
512
437
|
}
|
|
513
|
-
|
|
514
438
|
if (action.type === _models.PageAction.TYPES.NAVIGATE) {
|
|
515
439
|
var _formState$page3;
|
|
516
|
-
|
|
517
440
|
onPageChange(_helpers.default.getNextPageId(type, pages, pageId, action, (_formState$page3 = formState.page) === null || _formState$page3 === void 0 ? void 0 : _formState$page3.formData));
|
|
518
441
|
}
|
|
519
|
-
|
|
520
442
|
if (action.type === _models.PageAction.TYPES.CANCEL) {
|
|
521
443
|
hooks.onCancel();
|
|
522
444
|
}
|
|
523
445
|
};
|
|
524
|
-
|
|
525
446
|
var classes = _utils.default.classBuilder(classBlock, classModifiers, className);
|
|
526
|
-
|
|
527
447
|
if (hub === _models.HubFormats.TASK) {
|
|
528
448
|
cya.actions = [_models.PageAction.TYPES.SAVE_AND_CONTINUE, _models.PageAction.TYPES.SAVE_AND_RETURN];
|
|
529
449
|
}
|
|
530
|
-
|
|
531
450
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
532
451
|
className: classes()
|
|
533
452
|
}, title && !hide_title && pageId === _models.FormPages.HUB && /*#__PURE__*/_react.default.createElement(_copReactComponents.LargeHeading, null, title), formState.cya && /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, _extends({
|
|
@@ -553,10 +472,8 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
553
472
|
onAction: onPageAction
|
|
554
473
|
}));
|
|
555
474
|
};
|
|
556
|
-
|
|
557
475
|
FormRenderer.propTypes = InternalFormRenderer.propTypes = {
|
|
558
476
|
title: _propTypes.default.string,
|
|
559
|
-
|
|
560
477
|
/** See <a href="/?path=/docs/f-json--page#formtypes">FormTypes</a>. */
|
|
561
478
|
type: _propTypes.default.oneOf([_models.FormTypes.CYA, _models.FormTypes.FORM, _models.FormTypes.HUB, _models.FormTypes.TASK, _models.FormTypes.WIZARD, _models.FormTypes.TASK_CYA, _models.FormTypes.FORM_WITH_TASK]).isRequired,
|
|
562
479
|
components: _propTypes.default.arrayOf(_propTypes.default.object).isRequired,
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _getPageId = _interopRequireDefault(require("./getPageId"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
9
|
/**
|
|
13
10
|
* Gets the pageId from the invoked CYA action and calls onChange if it is
|
|
14
11
|
* different to the currentPageId.
|
|
@@ -18,11 +15,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
18
15
|
*/
|
|
19
16
|
var cyaAction = function cyaAction(page, currentPageId, onChange) {
|
|
20
17
|
var pageId = (0, _getPageId.default)(page.action, page.pageId);
|
|
21
|
-
|
|
22
18
|
if (pageId !== currentPageId) {
|
|
23
19
|
onChange(pageId);
|
|
24
20
|
}
|
|
25
21
|
};
|
|
26
|
-
|
|
27
22
|
var _default = cyaAction;
|
|
28
23
|
exports.default = _default;
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* Gets the pageId from the invoked CYA action.
|
|
10
9
|
* @param {object} action The invoked action.
|
|
@@ -14,6 +13,5 @@ exports.default = void 0;
|
|
|
14
13
|
var getPageId = function getPageId(action, pageId) {
|
|
15
14
|
return (action === null || action === void 0 ? void 0 : action.page) || pageId;
|
|
16
15
|
};
|
|
17
|
-
|
|
18
16
|
var _default = getPageId;
|
|
19
17
|
exports.default = _default;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _getPageId = _interopRequireDefault(require("./getPageId"));
|
|
4
|
-
|
|
5
4
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
7
5
|
// Local imports
|
|
6
|
+
|
|
8
7
|
describe('components', function () {
|
|
9
8
|
describe('FormRenderer', function () {
|
|
10
9
|
describe('handlers', function () {
|