@ukhomeoffice/cop-react-form-renderer 4.67.0 → 4.68.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CheckYourAnswers/Answer.js +6 -16
- package/dist/components/CheckYourAnswers/Answer.test.js +104 -129
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +26 -64
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +428 -555
- package/dist/components/CheckYourAnswers/index.js +0 -3
- package/dist/components/CollectionPage/CollectionPage.js +13 -42
- package/dist/components/CollectionPage/CollectionPage.test.js +160 -206
- package/dist/components/CollectionPage/index.js +0 -3
- package/dist/components/FormComponent/Collection.js +35 -79
- package/dist/components/FormComponent/Collection.test.js +340 -391
- package/dist/components/FormComponent/Container.js +10 -31
- package/dist/components/FormComponent/Container.test.js +304 -357
- package/dist/components/FormComponent/FormComponent.js +17 -60
- package/dist/components/FormComponent/FormComponent.test.js +190 -228
- 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 +21 -53
- package/dist/components/FormPage/FormPage.test.js +122 -160
- package/dist/components/FormPage/index.js +0 -3
- package/dist/components/FormRenderer/FormRenderer.js +106 -296
- package/dist/components/FormRenderer/FormRenderer.test.js +820 -1058
- 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 +4 -12
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +1 -2
- package/dist/components/FormRenderer/helpers/getCYA.js +0 -9
- 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 +4 -7
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +32 -41
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +122 -8
- package/dist/components/FormRenderer/helpers/index.js +1 -11
- package/dist/components/FormRenderer/index.js +0 -3
- package/dist/components/FormRenderer/onCYAAction.js +8 -30
- package/dist/components/FormRenderer/onCYAAction.test.js +54 -79
- package/dist/components/FormRenderer/onPageAction.js +123 -0
- package/dist/components/FormRenderer/onPageAction.test.js +632 -0
- package/dist/components/PageActions/ActionButton.js +2 -17
- package/dist/components/PageActions/ActionButton.test.js +58 -81
- package/dist/components/PageActions/PageActions.js +3 -10
- package/dist/components/PageActions/PageActions.test.js +95 -120
- package/dist/components/PageActions/index.js +0 -3
- package/dist/components/SummaryList/GroupAction.js +5 -26
- package/dist/components/SummaryList/GroupAction.test.js +14 -28
- package/dist/components/SummaryList/RowAction.js +5 -25
- package/dist/components/SummaryList/RowAction.test.js +14 -28
- package/dist/components/SummaryList/SummaryList.js +7 -31
- package/dist/components/SummaryList/SummaryList.test.js +69 -126
- package/dist/components/SummaryList/SummaryListHeadingRow.js +3 -8
- 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 +9 -31
- package/dist/components/TaskList/Task.test.js +32 -59
- package/dist/components/TaskList/TaskList.js +32 -59
- package/dist/components/TaskList/TaskList.test.js +52 -90
- package/dist/components/TaskList/TaskState.js +2 -10
- package/dist/components/TaskList/TaskState.test.js +23 -41
- package/dist/components/TaskList/index.js +0 -3
- package/dist/components/index.js +0 -7
- package/dist/context/HooksContext/HooksContext.js +21 -39
- package/dist/context/HooksContext/HooksContext.test.js +18 -34
- package/dist/context/HooksContext/index.js +0 -5
- package/dist/context/ValidationContext/ValidationContext.js +26 -56
- package/dist/context/ValidationContext/ValidationContext.test.js +43 -64
- 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 +17 -36
- package/dist/hooks/useGetRequest.js +57 -93
- package/dist/hooks/useHooks.js +2 -4
- package/dist/hooks/useRefData.js +14 -41
- package/dist/hooks/useValidation.js +2 -4
- package/dist/index.js +0 -9
- package/dist/models/PageAction.js +4 -4
- package/dist/models/TaskStates.js +4 -4
- package/dist/models/index.js +1 -10
- package/dist/setupTests.js +0 -13
- package/dist/utils/CheckYourAnswers/getCYAAction.js +1 -9
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +1 -19
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +4 -11
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +4 -9
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +4 -9
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +4 -8
- package/dist/utils/CheckYourAnswers/getCYARow.js +1 -10
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +8 -23
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +6 -21
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +2 -9
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +4 -20
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +7 -22
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +4 -32
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +4 -34
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +4 -15
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +4 -22
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +2 -22
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +7 -25
- package/dist/utils/CheckYourAnswers/index.js +1 -3
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +2 -15
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +1 -3
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +4 -12
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +5 -6
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +0 -6
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +1 -2
- package/dist/utils/CollectionPage/index.js +1 -5
- package/dist/utils/CollectionPage/mergeCollectionPages.js +5 -11
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +1 -2
- package/dist/utils/Component/addShowWhen.js +4 -10
- package/dist/utils/Component/addShowWhen.test.js +1 -2
- package/dist/utils/Component/applyToComponentTree.js +4 -18
- package/dist/utils/Component/applyToComponentTree.test.js +4 -8
- package/dist/utils/Component/cleanAttributes.js +1 -8
- package/dist/utils/Component/cleanAttributes.test.js +15 -16
- package/dist/utils/Component/elevateNestedComponents.js +0 -6
- package/dist/utils/Component/elevateNestedComponents.test.js +0 -2
- package/dist/utils/Component/getComponent.js +7 -86
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +6 -10
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +33 -51
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +8 -35
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +12 -29
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +4 -10
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +6 -23
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +6 -24
- 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.list.test.js +4 -10
- package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +5 -22
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +156 -175
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +4 -10
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +6 -23
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +8 -35
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +6 -23
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +6 -23
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +10 -34
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +12 -31
- 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 +4 -8
- package/dist/utils/Component/getDefaultValue.test.js +0 -3
- package/dist/utils/Component/index.js +0 -10
- package/dist/utils/Component/isEditable.js +1 -4
- package/dist/utils/Component/isEditable.test.js +1 -5
- package/dist/utils/Component/setupContainerComponentsPath.js +4 -9
- package/dist/utils/Component/setupContainerComponentsPath.test.js +0 -3
- package/dist/utils/Component/showComponent.js +1 -8
- package/dist/utils/Component/showComponent.test.js +1 -2
- 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/meetsAllConditions.test.js +1 -2
- package/dist/utils/Condition/meetsCondition.js +9 -34
- package/dist/utils/Condition/meetsCondition.test.js +21 -14
- package/dist/utils/Condition/meetsOneCondition.js +1 -9
- package/dist/utils/Condition/meetsOneCondition.test.js +1 -2
- package/dist/utils/Condition/setupConditions.js +4 -13
- package/dist/utils/Condition/setupConditions.test.js +0 -2
- package/dist/utils/Container/getEditableComponents.js +0 -7
- package/dist/utils/Container/getEditableComponents.test.js +1 -12
- package/dist/utils/Container/index.js +0 -5
- package/dist/utils/Container/setupNesting.js +4 -12
- package/dist/utils/Container/setupNesting.test.js +4 -10
- package/dist/utils/Container/showContainer.js +9 -18
- package/dist/utils/Container/showContainer.test.js +1 -2
- package/dist/utils/Data/applyFormula.js +6 -29
- package/dist/utils/Data/applyFormula.test.js +1 -2
- package/dist/utils/Data/getAutocompleteSource.js +1 -5
- package/dist/utils/Data/getAutocompleteSource.test.js +1 -2
- package/dist/utils/Data/getDataPath.js +3 -17
- package/dist/utils/Data/getDataPath.test.js +0 -4
- package/dist/utils/Data/getOptions.js +4 -14
- package/dist/utils/Data/getOptions.test.js +1 -2
- package/dist/utils/Data/getSourceData.js +6 -21
- package/dist/utils/Data/getSourceData.test.js +4 -6
- package/dist/utils/Data/index.js +1 -11
- package/dist/utils/Data/refDataToOptions.js +5 -13
- package/dist/utils/Data/refDataToOptions.test.js +1 -2
- package/dist/utils/Data/setDataItem.js +0 -5
- package/dist/utils/Data/setDataItem.test.js +0 -2
- package/dist/utils/Data/setupFormData.js +6 -25
- package/dist/utils/Data/setupFormData.test.js +8 -11
- package/dist/utils/Data/setupRefDataUrlForComponent.js +4 -15
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +1 -3
- package/dist/utils/FormPage/applyConditionalProperties.js +4 -11
- package/dist/utils/FormPage/applyConditionalProperties.test.js +4 -6
- package/dist/utils/FormPage/getFormPage.js +4 -16
- package/dist/utils/FormPage/getFormPage.test.js +10 -9
- package/dist/utils/FormPage/getFormPages.js +4 -9
- package/dist/utils/FormPage/getFormPages.test.js +6 -7
- package/dist/utils/FormPage/getPageActions.js +6 -19
- package/dist/utils/FormPage/getPageActions.test.js +1 -3
- package/dist/utils/FormPage/getParagraphFromText.js +0 -3
- package/dist/utils/FormPage/getParagraphFromText.test.js +1 -3
- package/dist/utils/FormPage/index.js +0 -7
- package/dist/utils/FormPage/showFormPage.js +9 -18
- package/dist/utils/FormPage/showFormPage.test.js +0 -2
- package/dist/utils/FormPage/showFormPageCYA.js +0 -5
- package/dist/utils/FormPage/showFormPageCYA.test.js +0 -2
- package/dist/utils/FormPage/useComponent.js +7 -19
- package/dist/utils/FormPage/useComponent.test.js +4 -7
- package/dist/utils/Format/formatData.js +0 -5
- package/dist/utils/Format/formatData.test.js +1 -2
- package/dist/utils/Format/formatDataForComponent.js +1 -6
- package/dist/utils/Format/formatDataForComponent.test.js +28 -47
- package/dist/utils/Format/formatDataForForm.js +4 -9
- package/dist/utils/Format/formatDataForForm.test.js +14 -11
- package/dist/utils/Format/formatDataForPage.js +1 -5
- package/dist/utils/Format/formatDataForPage.test.js +15 -12
- package/dist/utils/Format/index.js +1 -6
- package/dist/utils/Hub/getFormHub.js +0 -8
- package/dist/utils/Hub/getFormHub.test.js +6 -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 +4 -10
- package/dist/utils/Meta/documents/index.js +1 -5
- package/dist/utils/Meta/documents/setDocumentsForField.js +4 -11
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +4 -16
- package/dist/utils/Meta/index.js +1 -4
- package/dist/utils/Operate/checkValueIsTruthy.js +1 -7
- package/dist/utils/Operate/checkValueIsTruthy.test.js +0 -2
- package/dist/utils/Operate/getFirstOf.js +2 -9
- package/dist/utils/Operate/getFirstOf.test.js +0 -2
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +7 -21
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +6 -2
- package/dist/utils/Operate/index.js +0 -3
- package/dist/utils/Operate/persistValueInFormData.js +1 -8
- package/dist/utils/Operate/persistValueInFormData.test.js +0 -4
- package/dist/utils/Operate/runPageOperations.js +3 -19
- package/dist/utils/Operate/runPageOperations.test.js +4 -6
- package/dist/utils/Operate/setValueInFormData.js +2 -7
- package/dist/utils/Operate/setValueInFormData.test.js +0 -2
- package/dist/utils/Operate/shouldRun.js +1 -14
- package/dist/utils/Operate/shouldRun.test.js +5 -8
- package/dist/utils/Validate/additional/conditionallyRequired.js +0 -3
- package/dist/utils/Validate/additional/conditionallyRequired.test.js +0 -2
- package/dist/utils/Validate/additional/index.js +1 -22
- 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 +4 -8
- package/dist/utils/Validate/additional/mustBeGreaterThan.js +0 -3
- package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +0 -2
- 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 -3
- 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 +4 -5
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +0 -3
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +0 -2
- package/dist/utils/Validate/additional/mustSelectOnlyOne.js +0 -6
- package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +4 -7
- package/dist/utils/Validate/additional/utils.js +10 -26
- package/dist/utils/Validate/index.js +1 -11
- package/dist/utils/Validate/validateCollection.js +4 -10
- package/dist/utils/Validate/validateCollection.test.js +4 -6
- package/dist/utils/Validate/validateComponent.js +2 -39
- package/dist/utils/Validate/validateComponent.test.js +4 -22
- package/dist/utils/Validate/validateContainer.js +4 -14
- package/dist/utils/Validate/validateContainer.test.js +4 -10
- package/dist/utils/Validate/validateDate.js +6 -38
- package/dist/utils/Validate/validateDate.test.js +0 -4
- package/dist/utils/Validate/validateEmail.js +1 -8
- package/dist/utils/Validate/validateEmail.test.js +5 -4
- package/dist/utils/Validate/validateMultifile.js +0 -7
- package/dist/utils/Validate/validateMultifile.test.js +5 -6
- package/dist/utils/Validate/validatePage.js +4 -16
- package/dist/utils/Validate/validatePage.test.js +30 -25
- package/dist/utils/Validate/validateRegex.js +0 -10
- package/dist/utils/Validate/validateRegex.test.js +5 -4
- package/dist/utils/Validate/validateRequired.js +0 -8
- package/dist/utils/Validate/validateRequired.test.js +5 -4
- package/dist/utils/Validate/validateTextArea.js +0 -8
- package/dist/utils/Validate/validateTextArea.test.js +0 -2
- package/dist/utils/Validate/validateTime.js +5 -22
- package/dist/utils/Validate/validateTime.test.js +0 -2
- package/dist/utils/index.js +4 -20
- package/package.json +2 -2
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _models = require("../../models");
|
|
4
|
-
|
|
5
4
|
var _utils = _interopRequireDefault(require("../../utils"));
|
|
6
|
-
|
|
7
5
|
var _handlers = _interopRequireDefault(require("./handlers"));
|
|
8
|
-
|
|
9
6
|
var _helpers = _interopRequireDefault(require("./helpers"));
|
|
10
|
-
|
|
11
7
|
var _onCYAAction = _interopRequireDefault(require("./onCYAAction"));
|
|
12
|
-
|
|
13
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
-
|
|
9
|
+
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); }
|
|
15
10
|
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; }
|
|
16
|
-
|
|
17
11
|
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; }
|
|
18
|
-
|
|
19
|
-
function
|
|
20
|
-
|
|
12
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
14
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
21
15
|
jest.mock('./handlers', function () {
|
|
22
16
|
return {
|
|
23
17
|
submissionErrorCalls: 0,
|
|
@@ -25,7 +19,6 @@ jest.mock('./handlers', function () {
|
|
|
25
19
|
submissionError: function submissionError(errors, addErrors) {
|
|
26
20
|
this.submissionErrorCalls++;
|
|
27
21
|
this.submissionErrorArgs.push(errors);
|
|
28
|
-
|
|
29
22
|
if (typeof addErrors === 'function') {
|
|
30
23
|
addErrors(errors);
|
|
31
24
|
}
|
|
@@ -95,14 +88,12 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
95
88
|
type: type,
|
|
96
89
|
payload: payload
|
|
97
90
|
});
|
|
98
|
-
|
|
99
91
|
if (typeof onSuccess === 'function') {
|
|
100
92
|
onSuccess();
|
|
101
|
-
}
|
|
93
|
+
}
|
|
94
|
+
// onError would not normally be called alongside
|
|
102
95
|
// onSuccess, we're just doing it here to make sure
|
|
103
96
|
// the expected function chain is called.
|
|
104
|
-
|
|
105
|
-
|
|
106
97
|
if (typeof onError === 'function') {
|
|
107
98
|
onError(['an example error']);
|
|
108
99
|
}
|
|
@@ -124,36 +115,28 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
124
115
|
};
|
|
125
116
|
var setPagePointCalls = 0;
|
|
126
117
|
var setPagePointArgs = [];
|
|
127
|
-
|
|
128
118
|
var mockSetPagePoint = function mockSetPagePoint(point) {
|
|
129
119
|
setPagePointCalls++;
|
|
130
120
|
setPagePointArgs.push(point);
|
|
131
121
|
};
|
|
132
|
-
|
|
133
122
|
var setDataCalls = 0;
|
|
134
123
|
var setDataArgs = [];
|
|
135
|
-
|
|
136
124
|
var mockSetData = function mockSetData(data) {
|
|
137
125
|
setDataCalls++;
|
|
138
126
|
setDataArgs.push(data);
|
|
139
127
|
};
|
|
140
|
-
|
|
141
128
|
var onPageChangeCalls = 0;
|
|
142
129
|
var onPageChangeArgs = [];
|
|
143
|
-
|
|
144
130
|
var mockOnPageChange = function mockOnPageChange(pageId) {
|
|
145
131
|
onPageChangeCalls++;
|
|
146
132
|
onPageChangeArgs.push(pageId);
|
|
147
133
|
};
|
|
148
|
-
|
|
149
134
|
var addErrorsCalls = 0;
|
|
150
135
|
var addErrorsArgs = [];
|
|
151
|
-
|
|
152
136
|
var mockAddErrors = function mockAddErrors(errors) {
|
|
153
137
|
addErrorsCalls++;
|
|
154
138
|
addErrorsArgs.push(errors);
|
|
155
139
|
};
|
|
156
|
-
|
|
157
140
|
var COMPONENTS = [{
|
|
158
141
|
id: 'alpha',
|
|
159
142
|
fieldId: 'alpha'
|
|
@@ -199,11 +182,8 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
199
182
|
};
|
|
200
183
|
beforeEach(function () {
|
|
201
184
|
_handlers.default.reset();
|
|
202
|
-
|
|
203
185
|
_helpers.default.reset();
|
|
204
|
-
|
|
205
186
|
_utils.default.reset();
|
|
206
|
-
|
|
207
187
|
MOCK_HOOKS.reset();
|
|
208
188
|
setPagePointCalls = 0;
|
|
209
189
|
setPagePointArgs = [];
|
|
@@ -219,9 +199,7 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
219
199
|
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
220
200
|
hub: _models.HubFormats.CYA
|
|
221
201
|
});
|
|
222
|
-
|
|
223
202
|
_onCYAAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
224
|
-
|
|
225
203
|
expect(setPagePointCalls).toEqual(1);
|
|
226
204
|
expect(setPagePointArgs[0]).toEqual('submit');
|
|
227
205
|
expect(_helpers.default.canCYASubmitCalls).toEqual(1);
|
|
@@ -239,10 +217,12 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
239
217
|
id: 'formId',
|
|
240
218
|
formStatus: 'Good to go!'
|
|
241
219
|
}
|
|
242
|
-
});
|
|
220
|
+
});
|
|
243
221
|
|
|
244
|
-
|
|
222
|
+
// Checking the onSuccess branch.
|
|
223
|
+
expect(MOCK_HOOKS.onFormCompleteCalls).toEqual(1);
|
|
245
224
|
|
|
225
|
+
// Checking the onError branch.
|
|
246
226
|
expect(_handlers.default.submissionErrorCalls).toEqual(1);
|
|
247
227
|
expect(_handlers.default.submissionErrorArgs[0]).toEqual(['an example error']);
|
|
248
228
|
expect(addErrorsCalls).toEqual(1);
|
|
@@ -252,9 +232,7 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
252
232
|
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
253
233
|
hub: _models.HubFormats.TASK
|
|
254
234
|
});
|
|
255
|
-
|
|
256
235
|
_onCYAAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
257
|
-
|
|
258
236
|
expect(setPagePointCalls).toEqual(1);
|
|
259
237
|
expect(setPagePointArgs[0]).toEqual('submit');
|
|
260
238
|
expect(_helpers.default.canCYASubmitCalls).toEqual(1);
|
|
@@ -272,10 +250,12 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
272
250
|
id: 'formId',
|
|
273
251
|
formStatus: 'Good to go!'
|
|
274
252
|
}
|
|
275
|
-
});
|
|
253
|
+
});
|
|
276
254
|
|
|
277
|
-
|
|
255
|
+
// Checking the onSuccess branch.
|
|
256
|
+
expect(MOCK_HOOKS.onFormCompleteCalls).toEqual(1);
|
|
278
257
|
|
|
258
|
+
// Checking the onError branch.
|
|
279
259
|
expect(_handlers.default.submissionErrorCalls).toEqual(1);
|
|
280
260
|
expect(_handlers.default.submissionErrorArgs[0]).toEqual(['an example error']);
|
|
281
261
|
expect(addErrorsCalls).toEqual(1);
|
|
@@ -285,9 +265,7 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
285
265
|
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
286
266
|
hub: null
|
|
287
267
|
});
|
|
288
|
-
|
|
289
268
|
_onCYAAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
290
|
-
|
|
291
269
|
expect(setPagePointCalls).toEqual(1);
|
|
292
270
|
expect(setPagePointArgs[0]).toEqual('submit');
|
|
293
271
|
expect(_helpers.default.canCYASubmitCalls).toEqual(1);
|
|
@@ -305,10 +283,12 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
305
283
|
id: 'formId',
|
|
306
284
|
formStatus: 'Good to go!'
|
|
307
285
|
}
|
|
308
|
-
});
|
|
286
|
+
});
|
|
309
287
|
|
|
310
|
-
|
|
288
|
+
// Checking the onSuccess branch.
|
|
289
|
+
expect(MOCK_HOOKS.onFormCompleteCalls).toEqual(1);
|
|
311
290
|
|
|
291
|
+
// Checking the onError branch.
|
|
312
292
|
expect(_handlers.default.submissionErrorCalls).toEqual(1);
|
|
313
293
|
expect(_handlers.default.submissionErrorArgs[0]).toEqual(['an example error']);
|
|
314
294
|
expect(addErrorsCalls).toEqual(1);
|
|
@@ -323,11 +303,8 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
323
303
|
},
|
|
324
304
|
hub: _models.HubFormats.TASK
|
|
325
305
|
});
|
|
326
|
-
|
|
327
306
|
_onCYAAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
328
|
-
|
|
329
307
|
expect(_helpers.default.canCYASubmitCalls).toEqual(1); // Validating.
|
|
330
|
-
|
|
331
308
|
expect(_utils.default.Format.formCalls).toEqual(1);
|
|
332
309
|
expect(_helpers.default.getSubmissionStatusCalls).toEqual(1);
|
|
333
310
|
expect(setDataCalls).toEqual(1);
|
|
@@ -342,11 +319,13 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
342
319
|
id: 'formId',
|
|
343
320
|
formStatus: 'Good to go!'
|
|
344
321
|
}
|
|
345
|
-
});
|
|
322
|
+
});
|
|
346
323
|
|
|
324
|
+
// Checking the onSuccess branch.
|
|
347
325
|
expect(onPageChangeCalls).toEqual(1);
|
|
348
|
-
expect(onPageChangeArgs[0]).toEqual(_models.FormPages.HUB);
|
|
326
|
+
expect(onPageChangeArgs[0]).toEqual(_models.FormPages.HUB);
|
|
349
327
|
|
|
328
|
+
// Checking the onError branch.
|
|
350
329
|
expect(_handlers.default.submissionErrorCalls).toEqual(1);
|
|
351
330
|
expect(_handlers.default.submissionErrorArgs[0]).toEqual(['an example error']);
|
|
352
331
|
expect(addErrorsCalls).toEqual(1);
|
|
@@ -360,11 +339,8 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
360
339
|
},
|
|
361
340
|
hub: _models.HubFormats.TASK
|
|
362
341
|
});
|
|
363
|
-
|
|
364
342
|
_onCYAAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
365
|
-
|
|
366
343
|
expect(_helpers.default.canCYASubmitCalls).toEqual(1); // Validating.
|
|
367
|
-
|
|
368
344
|
expect(_utils.default.Format.formCalls).toEqual(1);
|
|
369
345
|
expect(_helpers.default.getSubmissionStatusCalls).toEqual(1);
|
|
370
346
|
expect(setDataCalls).toEqual(1);
|
|
@@ -379,11 +355,13 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
379
355
|
id: 'formId',
|
|
380
356
|
formStatus: 'Good to go!'
|
|
381
357
|
}
|
|
382
|
-
});
|
|
358
|
+
});
|
|
383
359
|
|
|
360
|
+
// Checking the onSuccess branch.
|
|
384
361
|
expect(onPageChangeCalls).toEqual(1);
|
|
385
|
-
expect(onPageChangeArgs[0]).toEqual(_models.FormPages.HUB);
|
|
362
|
+
expect(onPageChangeArgs[0]).toEqual(_models.FormPages.HUB);
|
|
386
363
|
|
|
364
|
+
// Checking the onError branch.
|
|
387
365
|
expect(_handlers.default.submissionErrorCalls).toEqual(1);
|
|
388
366
|
expect(_handlers.default.submissionErrorArgs[0]).toEqual(['an example error']);
|
|
389
367
|
expect(addErrorsCalls).toEqual(1);
|
|
@@ -397,13 +375,13 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
397
375
|
},
|
|
398
376
|
hub: _models.HubFormats.TASK
|
|
399
377
|
});
|
|
378
|
+
_onCYAAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
400
379
|
|
|
401
|
-
|
|
402
|
-
|
|
380
|
+
// Validation.
|
|
381
|
+
expect(_helpers.default.canCYASubmitCalls).toEqual(0);
|
|
403
382
|
|
|
404
|
-
|
|
383
|
+
// Everything after this point should be normal, we just
|
|
405
384
|
// haven't validated this time round.
|
|
406
|
-
|
|
407
385
|
expect(_utils.default.Format.formCalls).toEqual(1);
|
|
408
386
|
expect(_helpers.default.getSubmissionStatusCalls).toEqual(1);
|
|
409
387
|
expect(setDataCalls).toEqual(1);
|
|
@@ -418,11 +396,13 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
418
396
|
id: 'formId',
|
|
419
397
|
formStatus: 'Good to go!'
|
|
420
398
|
}
|
|
421
|
-
});
|
|
399
|
+
});
|
|
422
400
|
|
|
401
|
+
// Checking the onSuccess branch.
|
|
423
402
|
expect(onPageChangeCalls).toEqual(1);
|
|
424
|
-
expect(onPageChangeArgs[0]).toEqual(_models.FormPages.HUB);
|
|
403
|
+
expect(onPageChangeArgs[0]).toEqual(_models.FormPages.HUB);
|
|
425
404
|
|
|
405
|
+
// Checking the onError branch.
|
|
426
406
|
expect(_handlers.default.submissionErrorCalls).toEqual(1);
|
|
427
407
|
expect(_handlers.default.submissionErrorArgs[0]).toEqual(['an example error']);
|
|
428
408
|
expect(addErrorsCalls).toEqual(1);
|
|
@@ -437,11 +417,8 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
437
417
|
},
|
|
438
418
|
hub: _models.HubFormats.TASK
|
|
439
419
|
});
|
|
440
|
-
|
|
441
420
|
_onCYAAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
442
|
-
|
|
443
421
|
expect(_helpers.default.canCYASubmitCalls).toEqual(1); // Validating.
|
|
444
|
-
|
|
445
422
|
expect(_utils.default.Format.formCalls).toEqual(1);
|
|
446
423
|
expect(_helpers.default.getSubmissionStatusCalls).toEqual(1);
|
|
447
424
|
expect(setDataCalls).toEqual(1);
|
|
@@ -456,11 +433,13 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
456
433
|
id: 'formId',
|
|
457
434
|
formStatus: 'Good to go!'
|
|
458
435
|
}
|
|
459
|
-
});
|
|
436
|
+
});
|
|
460
437
|
|
|
438
|
+
// Checking the onSuccess branch.
|
|
461
439
|
expect(onPageChangeCalls).toEqual(1);
|
|
462
|
-
expect(onPageChangeArgs[0]).toEqual(_models.FormPages.HUB);
|
|
440
|
+
expect(onPageChangeArgs[0]).toEqual(_models.FormPages.HUB);
|
|
463
441
|
|
|
442
|
+
// Checking the onError branch.
|
|
464
443
|
expect(_handlers.default.submissionErrorCalls).toEqual(1);
|
|
465
444
|
expect(_handlers.default.submissionErrorArgs[0]).toEqual(['an example error']);
|
|
466
445
|
expect(addErrorsCalls).toEqual(1);
|
|
@@ -474,11 +453,8 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
474
453
|
},
|
|
475
454
|
hub: _models.HubFormats.TASK
|
|
476
455
|
});
|
|
477
|
-
|
|
478
456
|
_onCYAAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
479
|
-
|
|
480
457
|
expect(_helpers.default.canCYASubmitCalls).toEqual(1); // Validating.
|
|
481
|
-
|
|
482
458
|
expect(_utils.default.Format.formCalls).toEqual(1);
|
|
483
459
|
expect(_helpers.default.getSubmissionStatusCalls).toEqual(1);
|
|
484
460
|
expect(setDataCalls).toEqual(1);
|
|
@@ -493,11 +469,13 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
493
469
|
id: 'formId',
|
|
494
470
|
formStatus: 'Good to go!'
|
|
495
471
|
}
|
|
496
|
-
});
|
|
472
|
+
});
|
|
497
473
|
|
|
474
|
+
// Checking the onSuccess branch.
|
|
498
475
|
expect(onPageChangeCalls).toEqual(1);
|
|
499
|
-
expect(onPageChangeArgs[0]).toEqual(_models.FormPages.HUB);
|
|
476
|
+
expect(onPageChangeArgs[0]).toEqual(_models.FormPages.HUB);
|
|
500
477
|
|
|
478
|
+
// Checking the onError branch.
|
|
501
479
|
expect(_handlers.default.submissionErrorCalls).toEqual(1);
|
|
502
480
|
expect(_handlers.default.submissionErrorArgs[0]).toEqual(['an example error']);
|
|
503
481
|
expect(addErrorsCalls).toEqual(1);
|
|
@@ -511,13 +489,13 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
511
489
|
},
|
|
512
490
|
hub: _models.HubFormats.TASK
|
|
513
491
|
});
|
|
492
|
+
_onCYAAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
514
493
|
|
|
515
|
-
|
|
516
|
-
|
|
494
|
+
// Validation.
|
|
495
|
+
expect(_helpers.default.canCYASubmitCalls).toEqual(0);
|
|
517
496
|
|
|
518
|
-
|
|
497
|
+
// Everything after this point should be normal, we just
|
|
519
498
|
// haven't validated this time round.
|
|
520
|
-
|
|
521
499
|
expect(_utils.default.Format.formCalls).toEqual(1);
|
|
522
500
|
expect(_helpers.default.getSubmissionStatusCalls).toEqual(1);
|
|
523
501
|
expect(setDataCalls).toEqual(1);
|
|
@@ -532,11 +510,13 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
532
510
|
id: 'formId',
|
|
533
511
|
formStatus: 'Good to go!'
|
|
534
512
|
}
|
|
535
|
-
});
|
|
513
|
+
});
|
|
536
514
|
|
|
515
|
+
// Checking the onSuccess branch.
|
|
537
516
|
expect(onPageChangeCalls).toEqual(1);
|
|
538
|
-
expect(onPageChangeArgs[0]).toEqual(_models.FormPages.HUB);
|
|
517
|
+
expect(onPageChangeArgs[0]).toEqual(_models.FormPages.HUB);
|
|
539
518
|
|
|
519
|
+
// Checking the onError branch.
|
|
540
520
|
expect(_handlers.default.submissionErrorCalls).toEqual(1);
|
|
541
521
|
expect(_handlers.default.submissionErrorArgs[0]).toEqual(['an example error']);
|
|
542
522
|
expect(addErrorsCalls).toEqual(1);
|
|
@@ -551,11 +531,8 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
551
531
|
hub: _models.HubFormats.TASK,
|
|
552
532
|
type: _models.FormTypes.TASK
|
|
553
533
|
});
|
|
554
|
-
|
|
555
534
|
_onCYAAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
556
|
-
|
|
557
535
|
expect(_helpers.default.canCYASubmitCalls).toEqual(1); // Validating.
|
|
558
|
-
|
|
559
536
|
expect(_utils.default.Format.formCalls).toEqual(1);
|
|
560
537
|
expect(_helpers.default.getSubmissionStatusCalls).toEqual(1);
|
|
561
538
|
expect(setDataCalls).toEqual(1);
|
|
@@ -570,11 +547,13 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
570
547
|
id: 'formId',
|
|
571
548
|
formStatus: 'Good to go!'
|
|
572
549
|
}
|
|
573
|
-
});
|
|
550
|
+
});
|
|
574
551
|
|
|
552
|
+
// Checking the onSuccess branch.
|
|
575
553
|
expect(onPageChangeCalls).toEqual(1);
|
|
576
|
-
expect(onPageChangeArgs[0]).toEqual(undefined);
|
|
554
|
+
expect(onPageChangeArgs[0]).toEqual(undefined);
|
|
577
555
|
|
|
556
|
+
// Checking the onError branch.
|
|
578
557
|
expect(_handlers.default.submissionErrorCalls).toEqual(1);
|
|
579
558
|
expect(_handlers.default.submissionErrorArgs[0]).toEqual(['an example error']);
|
|
580
559
|
expect(addErrorsCalls).toEqual(1);
|
|
@@ -588,9 +567,7 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
588
567
|
page: 'page2'
|
|
589
568
|
}
|
|
590
569
|
});
|
|
591
|
-
|
|
592
570
|
_onCYAAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
593
|
-
|
|
594
571
|
expect(onPageChangeCalls).toEqual(1);
|
|
595
572
|
expect(onPageChangeArgs[0]).toEqual('page2');
|
|
596
573
|
});
|
|
@@ -600,9 +577,7 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
600
577
|
type: _models.PageAction.TYPES.CANCEL
|
|
601
578
|
}
|
|
602
579
|
});
|
|
603
|
-
|
|
604
580
|
_onCYAAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
605
|
-
|
|
606
581
|
expect(MOCK_HOOKS.onCancelCalls).toEqual(1);
|
|
607
582
|
});
|
|
608
583
|
});
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _models = require("../../models");
|
|
8
|
+
var _utils = _interopRequireDefault(require("../../utils"));
|
|
9
|
+
var _handlers = _interopRequireDefault(require("./handlers"));
|
|
10
|
+
var _helpers = _interopRequireDefault(require("./helpers"));
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
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); }
|
|
13
|
+
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; }
|
|
14
|
+
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; }
|
|
15
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
16
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
17
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
18
|
+
// Handle actions from pages.
|
|
19
|
+
// (patch captures payload-ready field name and value,
|
|
20
|
+
// patchLabel captures non-ID values
|
|
21
|
+
// for display purposes after submission.)
|
|
22
|
+
var onPageAction = function onPageAction(action, patch, patchLabel, hooks, data, formState, validate, onPageChange, type, pages, components, pageId, setPagePoint, currentTask, setData, hubDetails, setSubmitted, addErrors) {
|
|
23
|
+
if (action.type === _models.PageAction.TYPES.CANCEL) {
|
|
24
|
+
hooks.onCancel();
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
// Save a copy of data in case submit errors and we need to revert
|
|
28
|
+
var preSubmitData = _objectSpread({}, data);
|
|
29
|
+
// Re-apply the patch to the page's formData.
|
|
30
|
+
// This should normally have no effect but will prevent issues
|
|
31
|
+
// with validation if formData happens to have been wiped.
|
|
32
|
+
formState.page.formData = _objectSpread(_objectSpread({}, formState.page.formData), patch);
|
|
33
|
+
// Check to see whether the action is able to proceed, which in
|
|
34
|
+
// in the case of a submission will validate the fields in the page.
|
|
35
|
+
if (_helpers.default.canActionProceed(action, formState.page, validate.page)) {
|
|
36
|
+
patch = _helpers.default.cleanHiddenNestedData(patch, formState.page);
|
|
37
|
+
if (action.addToFormData) {
|
|
38
|
+
formState.page.formData[action.addToFormData.field] = action.addToFormData.value;
|
|
39
|
+
}
|
|
40
|
+
if (action.type === _models.PageAction.TYPES.NAVIGATE) {
|
|
41
|
+
_handlers.default.navigate(action, pageId, onPageChange);
|
|
42
|
+
} else {
|
|
43
|
+
var pageUpdate = function pageUpdate(next) {
|
|
44
|
+
return onPageChange(_helpers.default.getNextPageId(type, pages, pageId, action, next));
|
|
45
|
+
};
|
|
46
|
+
switch (action.type) {
|
|
47
|
+
case _models.PageAction.TYPES.SUBMIT:
|
|
48
|
+
setPagePoint('submit');
|
|
49
|
+
break;
|
|
50
|
+
case _models.PageAction.TYPES.SAVE_AND_NAVIGATE:
|
|
51
|
+
var state = _objectSpread({}, currentTask);
|
|
52
|
+
pageUpdate = function pageUpdate() {
|
|
53
|
+
return _handlers.default.navigate(action, pageId, onPageChange, state);
|
|
54
|
+
};
|
|
55
|
+
break;
|
|
56
|
+
case _models.PageAction.TYPES.COLLECTION_ADD:
|
|
57
|
+
formState.page.formData["".concat(action.collection, "ActiveId")] = Date.now().toString();
|
|
58
|
+
pageUpdate = function pageUpdate() {
|
|
59
|
+
return _handlers.default.navigate(action, pageId, onPageChange);
|
|
60
|
+
};
|
|
61
|
+
break;
|
|
62
|
+
case _models.PageAction.TYPES.COLLECTION_DUPLICATE:
|
|
63
|
+
if (_utils.default.CollectionPage.duplicateActiveEntry(action.collection, formState.page.formData)) {
|
|
64
|
+
pageUpdate = function pageUpdate() {
|
|
65
|
+
return _handlers.default.navigate(action, pageId, onPageChange);
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
break;
|
|
69
|
+
case _models.PageAction.TYPES.COLLECTION_REMOVE:
|
|
70
|
+
var activeId = formState.page.formData["".concat(action.collection, "ActiveId")];
|
|
71
|
+
formState.page.formData["".concat(action.collection)] = formState.page.formData["".concat(action.collection)].map(function (entry) {
|
|
72
|
+
if (entry.id === activeId) {
|
|
73
|
+
// Store the entry.
|
|
74
|
+
if (action.recordRemoval) {
|
|
75
|
+
formState.page.formData["".concat(action.collection, "LastRemoved")] = _objectSpread({}, entry);
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
return entry;
|
|
80
|
+
}).filter(function (e) {
|
|
81
|
+
return !!e;
|
|
82
|
+
});
|
|
83
|
+
break;
|
|
84
|
+
default:
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
// Save draft or submit.
|
|
88
|
+
var submissionData = _utils.default.Format.form({
|
|
89
|
+
pages: pages,
|
|
90
|
+
components: components
|
|
91
|
+
}, _objectSpread(_objectSpread(_objectSpread({}, data), patch), formState.page.formData), _models.EventTypes.SUBMIT);
|
|
92
|
+
submissionData.formStatus = _helpers.default.getSubmissionStatus(type, pages, pageId, action, submissionData, currentTask, true, hubDetails === null || hubDetails === void 0 ? void 0 : hubDetails.sections);
|
|
93
|
+
if (patch) {
|
|
94
|
+
setData(submissionData);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// In case of hub-and-spoke if patchLabel has changed then
|
|
98
|
+
// save name and value to variables for call to onSubmit hook
|
|
99
|
+
var changedFieldName;
|
|
100
|
+
var changedFieldValue;
|
|
101
|
+
if (type === _models.FormTypes.HUB && Object.keys(patchLabel).length > 0) {
|
|
102
|
+
changedFieldName = Object.keys(patchLabel)[0];
|
|
103
|
+
changedFieldValue = Object.values(patchLabel)[0];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Now submit the data to the backend...
|
|
107
|
+
hooks.onSubmit(action.type, submissionData, function (response) {
|
|
108
|
+
// The backend response may well contain data we need so apply it...
|
|
109
|
+
// ... but this needs to happen in a useEffect, not right away.
|
|
110
|
+
var sData = _objectSpread(_objectSpread({}, submissionData), response);
|
|
111
|
+
setSubmitted({
|
|
112
|
+
data: sData
|
|
113
|
+
});
|
|
114
|
+
pageUpdate(sData);
|
|
115
|
+
}, function (errors) {
|
|
116
|
+
_handlers.default.submissionError(errors, addErrors);
|
|
117
|
+
setData(_objectSpread({}, preSubmitData));
|
|
118
|
+
}, changedFieldName, changedFieldValue);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
var _default = onPageAction;
|
|
123
|
+
exports.default = _default;
|