@ukhomeoffice/cop-react-form-renderer 6.14.0 → 6.14.2-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/README.md +5 -0
- package/dist/components/CheckYourAnswers/Answer.js +12 -11
- package/dist/components/CheckYourAnswers/Answer.test.js +132 -181
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +98 -133
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +544 -939
- package/dist/components/CheckYourAnswers/index.js +1 -1
- package/dist/components/CollectionPage/CollectionPage.js +62 -60
- package/dist/components/CollectionPage/CollectionPage.test.js +315 -365
- package/dist/components/CollectionPage/index.js +1 -1
- package/dist/components/CollectionSummary/BannerStrip.js +14 -14
- package/dist/components/CollectionSummary/BannerStrip.test.js +79 -74
- package/dist/components/CollectionSummary/CollectionSummary.js +75 -97
- package/dist/components/CollectionSummary/CollectionSummary.test.js +182 -166
- package/dist/components/CollectionSummary/Confirmation.js +15 -13
- package/dist/components/CollectionSummary/Confirmation.test.js +68 -63
- package/dist/components/CollectionSummary/RenderListView.js +34 -47
- package/dist/components/CollectionSummary/RenderListView.test.js +113 -111
- package/dist/components/CollectionSummary/SummaryCard.js +101 -133
- package/dist/components/CollectionSummary/SummaryCard.test.js +961 -993
- package/dist/components/CollectionSummary/SummaryCardButtons.js +25 -30
- package/dist/components/CollectionSummary/SummaryCardButtons.test.js +30 -28
- package/dist/components/CollectionSummary/SummaryCardDetails.js +59 -76
- package/dist/components/CollectionSummary/SummaryCardDetails.test.js +170 -180
- package/dist/components/CollectionSummary/SummaryCardValidationContext.js +31 -36
- package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +63 -75
- package/dist/components/CollectionSummary/index.js +1 -1
- package/dist/components/FormComponent/Collection.js +63 -100
- package/dist/components/FormComponent/Collection.test.js +907 -1080
- package/dist/components/FormComponent/Container.js +35 -29
- package/dist/components/FormComponent/Container.test.js +378 -409
- package/dist/components/FormComponent/FormComponent.js +59 -63
- package/dist/components/FormComponent/FormComponent.test.js +354 -415
- package/dist/components/FormComponent/helpers/addLabel.js +4 -7
- package/dist/components/FormComponent/helpers/getComponentDisabled.js +1 -1
- package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +8 -8
- package/dist/components/FormComponent/helpers/getComponentError.js +3 -5
- package/dist/components/FormComponent/helpers/getComponentError.test.js +15 -15
- package/dist/components/FormComponent/helpers/getComponentFieldSet.js +3 -4
- package/dist/components/FormComponent/helpers/getComponentFieldSet.test.js +7 -7
- package/dist/components/FormComponent/helpers/index.js +5 -5
- package/dist/components/FormComponent/index.js +1 -1
- package/dist/components/FormPage/FormPage.js +70 -93
- package/dist/components/FormPage/FormPage.test.js +150 -202
- package/dist/components/FormPage/index.js +1 -1
- package/dist/components/FormRenderer/FormRenderer.js +131 -173
- package/dist/components/FormRenderer/FormRenderer.test.js +732 -1114
- package/dist/components/FormRenderer/handlers/cyaAction.js +3 -3
- package/dist/components/FormRenderer/handlers/getPageId.js +1 -3
- package/dist/components/FormRenderer/handlers/getPageId.test.js +15 -15
- package/dist/components/FormRenderer/handlers/handlers.test.js +33 -33
- package/dist/components/FormRenderer/handlers/index.js +2 -2
- package/dist/components/FormRenderer/handlers/navigate.js +4 -4
- package/dist/components/FormRenderer/handlers/submissionError.js +1 -1
- package/dist/components/FormRenderer/helpers/canActionProceed.js +1 -1
- package/dist/components/FormRenderer/helpers/canActionProceed.test.js +16 -16
- package/dist/components/FormRenderer/helpers/canCYASubmit.js +1 -3
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +17 -21
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +22 -25
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +21 -21
- package/dist/components/FormRenderer/helpers/getCYA.js +4 -6
- package/dist/components/FormRenderer/helpers/getCYA.test.js +12 -12
- package/dist/components/FormRenderer/helpers/getFormState.js +6 -8
- package/dist/components/FormRenderer/helpers/getFormState.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getNextPageId.js +14 -25
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +68 -68
- package/dist/components/FormRenderer/helpers/getPage.js +2 -4
- package/dist/components/FormRenderer/helpers/getPage.test.js +12 -12
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +7 -9
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +15 -15
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +6 -6
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +104 -98
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +44 -51
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +68 -74
- package/dist/components/FormRenderer/helpers/index.js +2 -2
- package/dist/components/FormRenderer/index.js +1 -1
- package/dist/components/FormRenderer/onCYAAction.js +43 -44
- package/dist/components/FormRenderer/onCYAAction.test.js +126 -133
- package/dist/components/FormRenderer/onPageAction.js +26 -35
- package/dist/components/FormRenderer/onPageAction.test.js +177 -186
- package/dist/components/FormRenderer/onTaskAction.js +11 -12
- package/dist/components/FormRenderer/onTaskAction.test.js +63 -68
- package/dist/components/PageActions/ActionButton.js +14 -14
- package/dist/components/PageActions/ActionButton.test.js +57 -79
- package/dist/components/PageActions/PageActions.js +11 -11
- package/dist/components/PageActions/PageActions.test.js +87 -116
- package/dist/components/PageActions/index.js +1 -1
- package/dist/components/SummaryList/GroupAction.js +10 -18
- package/dist/components/SummaryList/GroupAction.test.js +38 -34
- package/dist/components/SummaryList/RowAction.js +12 -17
- package/dist/components/SummaryList/RowAction.test.js +38 -34
- package/dist/components/SummaryList/SummaryList.js +23 -25
- package/dist/components/SummaryList/SummaryList.test.js +162 -189
- package/dist/components/SummaryList/SummaryListHeadingRow.js +7 -5
- package/dist/components/SummaryList/SummaryListHeadingRowWithAction.js +7 -5
- package/dist/components/SummaryList/SummaryListRow.js +7 -5
- package/dist/components/SummaryList/SummaryListTitleRow.js +6 -4
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +3 -5
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +23 -23
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +3 -5
- package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +23 -23
- package/dist/components/SummaryList/helpers/index.js +2 -2
- package/dist/components/SummaryList/index.js +1 -1
- package/dist/components/TaskList/Task.js +20 -30
- package/dist/components/TaskList/Task.test.js +84 -77
- package/dist/components/TaskList/TaskList.js +56 -79
- package/dist/components/TaskList/TaskList.test.js +149 -149
- package/dist/components/TaskList/TaskState.js +8 -6
- package/dist/components/TaskList/TaskState.test.js +53 -46
- package/dist/components/TaskList/index.js +1 -1
- package/dist/components/index.js +8 -8
- package/dist/context/HooksContext/HooksContext.js +56 -79
- package/dist/context/HooksContext/HooksContext.test.js +27 -36
- package/dist/context/HooksContext/index.js +3 -4
- package/dist/context/ValidationContext/ValidationContext.js +44 -95
- package/dist/context/ValidationContext/ValidationContext.test.js +57 -69
- package/dist/context/ValidationContext/index.js +3 -4
- package/dist/context/index.js +3 -3
- package/dist/hooks/index.js +10 -11
- package/dist/hooks/useAxios.js +15 -41
- package/dist/hooks/useGetRequest.js +62 -98
- package/dist/hooks/useHooks.js +1 -3
- package/dist/hooks/useRefData.js +25 -37
- package/dist/hooks/useValidation.js +1 -3
- package/dist/index.js +14 -15
- package/dist/models/CollectionLabels.js +1 -1
- package/dist/models/ComponentTypes.js +25 -25
- package/dist/models/EventTypes.js +4 -4
- package/dist/models/FormPages.js +4 -4
- package/dist/models/FormTypes.js +8 -8
- package/dist/models/HubFormats.js +3 -3
- package/dist/models/PageAction.js +44 -38
- package/dist/models/TaskStates.js +29 -28
- package/dist/models/index.js +10 -10
- package/dist/setupTests.js +30 -31
- package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +53 -55
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +12 -21
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +32 -33
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +15 -28
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +41 -42
- package/dist/utils/CheckYourAnswers/getCYARow.js +7 -7
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +87 -87
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +19 -21
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +16 -17
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +27 -34
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +48 -52
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +76 -93
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +110 -115
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +11 -16
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +112 -106
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +14 -19
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +69 -73
- package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.js +7 -8
- package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.test.js +15 -16
- package/dist/utils/CheckYourAnswers/index.js +2 -2
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +5 -5
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +26 -26
- package/dist/utils/CollectionPage/addCollectionPageEntry.js +2 -2
- package/dist/utils/CollectionPage/addCollectionPageEntry.test.js +6 -6
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +3 -3
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +18 -19
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +13 -20
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +48 -39
- package/dist/utils/CollectionPage/getCollectionPageActiveId.js +2 -2
- package/dist/utils/CollectionPage/getCollectionPageActiveId.test.js +11 -11
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +7 -11
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +23 -23
- package/dist/utils/CollectionPage/getCollectionPageData.js +8 -12
- package/dist/utils/CollectionPage/getCollectionPageData.test.js +20 -20
- package/dist/utils/CollectionPage/getErrorsForCollection.js +20 -21
- package/dist/utils/CollectionPage/getErrorsForCollection.test.js +21 -23
- package/dist/utils/CollectionPage/getQuickEditPage.js +22 -23
- package/dist/utils/CollectionPage/getQuickEditPage.test.js +17 -18
- package/dist/utils/CollectionPage/index.js +2 -2
- package/dist/utils/CollectionPage/mergeCollectionPages.js +26 -35
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +18 -18
- package/dist/utils/CollectionPage/removeCollectionPageEntry.js +5 -7
- package/dist/utils/CollectionPage/removeCollectionPageEntry.test.js +11 -11
- package/dist/utils/CollectionPage/setCollectionPageData.js +10 -16
- package/dist/utils/CollectionPage/setCollectionPageData.test.js +25 -25
- package/dist/utils/Component/addShowWhen.js +5 -6
- package/dist/utils/Component/addShowWhen.test.js +38 -38
- package/dist/utils/Component/applyToComponentTree.js +12 -15
- package/dist/utils/Component/applyToComponentTree.test.js +28 -31
- package/dist/utils/Component/cleanAttributes.js +12 -11
- package/dist/utils/Component/cleanAttributes.test.js +17 -18
- package/dist/utils/Component/elevateNestedComponents.js +6 -6
- package/dist/utils/Component/elevateNestedComponents.test.js +34 -34
- package/dist/utils/Component/getComponent.js +79 -85
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +19 -18
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +41 -58
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +40 -49
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +24 -34
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +21 -19
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +18 -23
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +21 -26
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +11 -10
- package/dist/utils/Component/getComponentTests/getComponent.html.test.js +18 -16
- package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +10 -9
- package/dist/utils/Component/getComponentTests/getComponent.list.test.js +18 -16
- package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +23 -27
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +201 -226
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +18 -16
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +18 -23
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +58 -73
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +18 -23
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +18 -23
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +32 -39
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +21 -30
- package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +3 -3
- package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +10 -9
- package/dist/utils/Component/getDefaultValue.js +7 -9
- package/dist/utils/Component/getDefaultValue.test.js +13 -13
- package/dist/utils/Component/getDefaultValueFromConfig.js +16 -20
- package/dist/utils/Component/getDefaultValueFromConfig.test.js +32 -32
- package/dist/utils/Component/index.js +2 -2
- package/dist/utils/Component/isEditable.js +2 -4
- package/dist/utils/Component/isEditable.test.js +14 -15
- package/dist/utils/Component/optionIsSelected.js +2 -4
- package/dist/utils/Component/optionIsSelected.test.js +12 -12
- package/dist/utils/Component/setupContainerComponentsPath.js +23 -28
- package/dist/utils/Component/setupContainerComponentsPath.test.js +12 -12
- package/dist/utils/Component/showComponent.js +2 -2
- package/dist/utils/Component/showComponent.test.js +29 -29
- package/dist/utils/Component/wrapInFormGroup.js +4 -4
- package/dist/utils/Condition/index.js +2 -2
- package/dist/utils/Condition/meetsAllConditions.js +9 -9
- package/dist/utils/Condition/meetsAllConditions.test.js +21 -21
- package/dist/utils/Condition/meetsCondition.js +17 -26
- package/dist/utils/Condition/meetsCondition.test.js +403 -403
- package/dist/utils/Condition/meetsOneCondition.js +6 -6
- package/dist/utils/Condition/meetsOneCondition.test.js +17 -17
- package/dist/utils/Condition/setupConditions.js +12 -15
- package/dist/utils/Condition/setupConditions.test.js +8 -8
- package/dist/utils/Container/getEditableComponents.js +4 -6
- package/dist/utils/Container/getEditableComponents.test.js +44 -46
- package/dist/utils/Container/index.js +2 -2
- package/dist/utils/Container/setupNesting.js +14 -15
- package/dist/utils/Container/setupNesting.test.js +20 -23
- package/dist/utils/Container/showContainer.js +4 -8
- package/dist/utils/Container/showContainer.test.js +31 -31
- package/dist/utils/Data/applyFormula.js +30 -44
- package/dist/utils/Data/applyFormula.test.js +21 -21
- package/dist/utils/Data/deleteValues.js +4 -8
- package/dist/utils/Data/deleteValues.test.js +11 -11
- package/dist/utils/Data/getAutocompleteSource.js +72 -63
- package/dist/utils/Data/getAutocompleteSource.test.js +106 -98
- package/dist/utils/Data/getDataPath.js +18 -28
- package/dist/utils/Data/getDataPath.test.js +13 -13
- package/dist/utils/Data/getOptions.js +35 -42
- package/dist/utils/Data/getOptions.test.js +37 -38
- package/dist/utils/Data/getSourceData.js +6 -19
- package/dist/utils/Data/getSourceData.test.js +85 -81
- package/dist/utils/Data/index.js +2 -2
- package/dist/utils/Data/nestInRefdataOptions.js +9 -12
- package/dist/utils/Data/nestInRefdataOptions.test.js +17 -17
- package/dist/utils/Data/refDataToOptions.js +9 -10
- package/dist/utils/Data/refDataToOptions.test.js +20 -20
- package/dist/utils/Data/setDataItem.js +7 -8
- package/dist/utils/Data/setDataItem.test.js +38 -38
- package/dist/utils/Data/setupFormData.js +13 -20
- package/dist/utils/Data/setupFormData.test.js +48 -47
- package/dist/utils/Data/setupRefDataUrlForComponent.js +11 -20
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +25 -25
- package/dist/utils/FormPage/applyConditionalProperties.js +7 -8
- package/dist/utils/FormPage/applyConditionalProperties.test.js +14 -15
- package/dist/utils/FormPage/getConditionalText.js +4 -4
- package/dist/utils/FormPage/getConditionalText.test.js +30 -30
- package/dist/utils/FormPage/getFormPage.js +12 -15
- package/dist/utils/FormPage/getFormPage.test.js +23 -24
- package/dist/utils/FormPage/getFormPages.js +8 -11
- package/dist/utils/FormPage/getFormPages.test.js +15 -16
- package/dist/utils/FormPage/getPageActions.js +10 -13
- package/dist/utils/FormPage/getPageActions.test.js +33 -33
- package/dist/utils/FormPage/getParagraphFromText.js +5 -7
- package/dist/utils/FormPage/getParagraphFromText.test.js +7 -7
- package/dist/utils/FormPage/index.js +3 -5
- package/dist/utils/FormPage/showFormPage.js +4 -8
- package/dist/utils/FormPage/showFormPage.test.js +33 -33
- package/dist/utils/FormPage/showFormPageCYA.js +2 -2
- package/dist/utils/FormPage/showFormPageCYA.test.js +9 -9
- package/dist/utils/FormPage/useComponent.js +15 -23
- package/dist/utils/FormPage/useComponent.test.js +49 -50
- package/dist/utils/Format/formatData.js +1 -1
- package/dist/utils/Format/formatData.test.js +19 -19
- package/dist/utils/Format/formatDataForComponent.js +6 -7
- package/dist/utils/Format/formatDataForComponent.test.js +50 -78
- package/dist/utils/Format/formatDataForForm.js +5 -6
- package/dist/utils/Format/formatDataForForm.test.js +14 -17
- package/dist/utils/Format/formatDataForPage.js +4 -5
- package/dist/utils/Format/formatDataForPage.test.js +20 -25
- package/dist/utils/Format/index.js +2 -2
- package/dist/utils/Hub/getFormHub.js +2 -2
- package/dist/utils/Hub/getFormHub.test.js +23 -24
- package/dist/utils/Hub/index.js +2 -2
- package/dist/utils/Meta/constants.js +2 -2
- package/dist/utils/Meta/documents/getDocuments.js +1 -1
- package/dist/utils/Meta/documents/getDocuments.test.js +25 -17
- package/dist/utils/Meta/documents/index.js +2 -2
- package/dist/utils/Meta/documents/setDocumentsForField.js +12 -13
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +70 -33
- package/dist/utils/Meta/index.js +2 -2
- package/dist/utils/Operate/checkValueIsTruthy.js +3 -3
- package/dist/utils/Operate/checkValueIsTruthy.test.js +17 -17
- package/dist/utils/Operate/deleteValueInFormData.js +2 -2
- package/dist/utils/Operate/deleteValueInFormData.test.js +15 -15
- package/dist/utils/Operate/getFirstOf.js +6 -6
- package/dist/utils/Operate/getFirstOf.test.js +32 -32
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +11 -11
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +47 -53
- package/dist/utils/Operate/getLength.js +9 -9
- package/dist/utils/Operate/getLength.test.js +19 -19
- package/dist/utils/Operate/index.js +2 -2
- package/dist/utils/Operate/persistValueInFormData.js +4 -4
- package/dist/utils/Operate/persistValueInFormData.test.js +23 -21
- package/dist/utils/Operate/runPageOperations.js +8 -8
- package/dist/utils/Operate/runPageOperations.test.js +24 -25
- package/dist/utils/Operate/setValueInFormData.js +3 -3
- package/dist/utils/Operate/setValueInFormData.test.js +17 -17
- package/dist/utils/Operate/shouldRun.js +7 -7
- package/dist/utils/Operate/shouldRun.test.js +22 -24
- package/dist/utils/Validate/additional/conditionallyPermittedChange.js +1 -1
- package/dist/utils/Validate/additional/conditionallyPermittedChange.test.js +15 -15
- package/dist/utils/Validate/additional/conditionallyRequired.js +4 -4
- package/dist/utils/Validate/additional/conditionallyRequired.test.js +19 -19
- package/dist/utils/Validate/additional/index.js +8 -8
- package/dist/utils/Validate/additional/index.test.js +22 -22
- package/dist/utils/Validate/additional/mustBeAfter.js +3 -3
- package/dist/utils/Validate/additional/mustBeAfter.test.js +41 -41
- package/dist/utils/Validate/additional/mustBeBefore.js +3 -3
- package/dist/utils/Validate/additional/mustBeBefore.test.js +29 -29
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +8 -12
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +37 -38
- package/dist/utils/Validate/additional/mustBeGreaterThan.js +2 -2
- package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +19 -19
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +3 -3
- package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeInThePast.js +4 -4
- package/dist/utils/Validate/additional/mustBeInThePast.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeLessThan.js +2 -2
- package/dist/utils/Validate/additional/mustBeLessThan.test.js +18 -18
- package/dist/utils/Validate/additional/mustBeLongerThan.js +1 -1
- package/dist/utils/Validate/additional/mustBeLongerThan.test.js +17 -17
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +2 -2
- package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +21 -21
- package/dist/utils/Validate/additional/mustBeOneOf.js +1 -1
- package/dist/utils/Validate/additional/mustBeOneOf.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeShorterThan.js +1 -1
- package/dist/utils/Validate/additional/mustBeShorterThan.test.js +17 -17
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.js +5 -5
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.test.js +35 -36
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +2 -2
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +15 -17
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +1 -1
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +13 -13
- package/dist/utils/Validate/additional/mustNotContainSql.js +3 -4
- package/dist/utils/Validate/additional/mustNotContainSql.test.js +15 -15
- package/dist/utils/Validate/additional/mustSelectOnlyOne.js +2 -2
- package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +29 -27
- package/dist/utils/Validate/additional/utils.js +9 -22
- package/dist/utils/Validate/index.js +2 -2
- package/dist/utils/Validate/validateCollection.js +18 -23
- package/dist/utils/Validate/validateCollection.test.js +75 -67
- package/dist/utils/Validate/validateComponent.js +19 -19
- package/dist/utils/Validate/validateComponent.test.js +179 -154
- package/dist/utils/Validate/validateContainer.js +14 -17
- package/dist/utils/Validate/validateContainer.test.js +59 -53
- package/dist/utils/Validate/validateDate.js +16 -22
- package/dist/utils/Validate/validateDate.test.js +31 -32
- package/dist/utils/Validate/validateEmail.js +7 -9
- package/dist/utils/Validate/validateEmail.test.js +27 -27
- package/dist/utils/Validate/validateMultifile.js +5 -7
- package/dist/utils/Validate/validateMultifile.test.js +17 -18
- package/dist/utils/Validate/validatePage.js +13 -18
- package/dist/utils/Validate/validatePage.test.js +198 -195
- package/dist/utils/Validate/validateRegex.js +3 -5
- package/dist/utils/Validate/validateRegex.test.js +15 -15
- package/dist/utils/Validate/validateRequired.js +4 -6
- package/dist/utils/Validate/validateRequired.test.js +19 -19
- package/dist/utils/Validate/validateTextArea.js +4 -6
- package/dist/utils/Validate/validateTextArea.test.js +21 -21
- package/dist/utils/Validate/validateTime.js +12 -19
- package/dist/utils/Validate/validateTime.test.js +27 -27
- package/dist/utils/index.js +5 -6
- package/package.json +2 -4
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
@@ -20,48 +19,44 @@ var _handlers = _interopRequireDefault(require("./handlers"));
|
|
|
20
19
|
var _helpers = _interopRequireDefault(require("./helpers"));
|
|
21
20
|
var _onCYAAction = _interopRequireDefault(require("./onCYAAction"));
|
|
22
21
|
var _onPageAction = _interopRequireDefault(require("./onPageAction"));
|
|
23
|
-
var
|
|
22
|
+
var _onTaskAction = _interopRequireDefault(require("./onTaskAction"));
|
|
24
23
|
require("./FormRenderer.scss");
|
|
25
|
-
|
|
26
|
-
function _interopRequireDefault(
|
|
27
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function
|
|
28
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" !=
|
|
29
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (
|
|
30
|
-
function _objectWithoutProperties(
|
|
31
|
-
function _objectWithoutPropertiesLoose(
|
|
24
|
+
const _excluded = ["noTaskCYAs", "nonSequential"];
|
|
25
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
26
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
27
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
28
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
29
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
30
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
|
|
32
31
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
33
32
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
34
|
-
function _defineProperty(
|
|
35
|
-
function _toPropertyKey(
|
|
36
|
-
function _toPrimitive(
|
|
37
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
38
|
-
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."); }
|
|
39
|
-
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); }
|
|
40
|
-
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; }
|
|
41
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
42
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } /* eslint-disable no-shadow */ // Global imports
|
|
33
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
34
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
35
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /* eslint-disable no-shadow */ // Global imports
|
|
43
36
|
// Local imports
|
|
44
37
|
// Styles
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
38
|
+
const FormRenderer = _ref => {
|
|
39
|
+
let {
|
|
40
|
+
title,
|
|
41
|
+
type,
|
|
42
|
+
components,
|
|
43
|
+
pages,
|
|
44
|
+
hub,
|
|
45
|
+
cya,
|
|
46
|
+
data,
|
|
47
|
+
hashLink,
|
|
48
|
+
hooks,
|
|
49
|
+
classBlock,
|
|
50
|
+
classModifiers,
|
|
51
|
+
className,
|
|
52
|
+
hide_title: hideTitle,
|
|
53
|
+
summaryListClassModifiers,
|
|
54
|
+
noChangeAction,
|
|
55
|
+
newPageId,
|
|
56
|
+
viewOnly,
|
|
57
|
+
hideBlankRows,
|
|
58
|
+
fromTarget
|
|
59
|
+
} = _ref;
|
|
65
60
|
return /*#__PURE__*/_react.default.createElement(_context.HooksContextProvider, {
|
|
66
61
|
overrides: hooks
|
|
67
62
|
}, /*#__PURE__*/_react.default.createElement(_context.ValidationContextProvider, null, /*#__PURE__*/_react.default.createElement(InternalFormRenderer, {
|
|
@@ -85,92 +80,63 @@ var FormRenderer = function FormRenderer(_ref) {
|
|
|
85
80
|
fromTarget: fromTarget
|
|
86
81
|
})));
|
|
87
82
|
};
|
|
88
|
-
|
|
89
|
-
|
|
83
|
+
const DEFAULT_CLASS = exports.DEFAULT_CLASS = 'hods-form';
|
|
84
|
+
const InternalFormRenderer = _ref2 => {
|
|
90
85
|
var _formState$page4, _formState$page$actio, _formState$cya$hideCh, _formState$cya$hideGr;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
86
|
+
let {
|
|
87
|
+
title,
|
|
88
|
+
type,
|
|
89
|
+
components,
|
|
90
|
+
pages: _pages,
|
|
91
|
+
hub: _hub,
|
|
92
|
+
cya,
|
|
93
|
+
data: _data,
|
|
94
|
+
classBlock,
|
|
95
|
+
classModifiers,
|
|
96
|
+
className,
|
|
97
|
+
hashLink,
|
|
98
|
+
hide_title: hideTitle,
|
|
99
|
+
summaryListClassModifiers,
|
|
100
|
+
noChangeAction,
|
|
101
|
+
newPageId,
|
|
102
|
+
viewOnly,
|
|
103
|
+
hideBlankRows,
|
|
104
|
+
fromTarget
|
|
105
|
+
} = _ref2;
|
|
109
106
|
// Set up the initial states.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
setPages = _useState6[1];
|
|
122
|
-
var _useState7 = (0, _react.useState)(undefined),
|
|
123
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
124
|
-
hub = _useState8[0],
|
|
125
|
-
setHub = _useState8[1];
|
|
126
|
-
var _useState9 = (0, _react.useState)(_helpers.default.getNextPageId(type, _pages, null, null, _data)),
|
|
127
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
|
128
|
-
pageId = _useState10[0],
|
|
129
|
-
setPageId = _useState10[1];
|
|
130
|
-
var _useState11 = (0, _react.useState)(_helpers.default.getFormState(pageId, pages, hub)),
|
|
131
|
-
_useState12 = _slicedToArray(_useState11, 2),
|
|
132
|
-
formState = _useState12[0],
|
|
133
|
-
setFormState = _useState12[1];
|
|
134
|
-
var _useState13 = (0, _react.useState)({}),
|
|
135
|
-
_useState14 = _slicedToArray(_useState13, 2),
|
|
136
|
-
currentTask = _useState14[0],
|
|
137
|
-
setCurrentTask = _useState14[1];
|
|
138
|
-
var _useState15 = (0, _react.useState)({}),
|
|
139
|
-
_useState16 = _slicedToArray(_useState15, 2),
|
|
140
|
-
hubDetails = _useState16[0],
|
|
141
|
-
setHubDetails = _useState16[1];
|
|
142
|
-
var _useState17 = (0, _react.useState)('load'),
|
|
143
|
-
_useState18 = _slicedToArray(_useState17, 2),
|
|
144
|
-
pagePoint = _useState18[0],
|
|
145
|
-
setPagePoint = _useState18[1];
|
|
146
|
-
var _useState19 = (0, _react.useState)(false),
|
|
147
|
-
_useState20 = _slicedToArray(_useState19, 2),
|
|
148
|
-
goingBack = _useState20[0],
|
|
149
|
-
setGoingBack = _useState20[1];
|
|
150
|
-
var _useState21 = (0, _react.useState)(false),
|
|
151
|
-
_useState22 = _slicedToArray(_useState21, 2),
|
|
152
|
-
submitting = _useState22[0],
|
|
153
|
-
setSubmitting = _useState22[1];
|
|
107
|
+
const [data, setData] = (0, _react.useState)({});
|
|
108
|
+
const [submitted, setSubmitted] = (0, _react.useState)();
|
|
109
|
+
const [pages, setPages] = (0, _react.useState)([]);
|
|
110
|
+
const [hub, setHub] = (0, _react.useState)(undefined);
|
|
111
|
+
const [pageId, setPageId] = (0, _react.useState)(_helpers.default.getNextPageId(type, _pages, null, null, _data));
|
|
112
|
+
const [formState, setFormState] = (0, _react.useState)(_helpers.default.getFormState(pageId, pages, hub));
|
|
113
|
+
const [currentTask, setCurrentTask] = (0, _react.useState)({});
|
|
114
|
+
const [hubDetails, setHubDetails] = (0, _react.useState)({});
|
|
115
|
+
const [pagePoint, setPagePoint] = (0, _react.useState)('load');
|
|
116
|
+
const [goingBack, setGoingBack] = (0, _react.useState)(false);
|
|
117
|
+
const [submitting, setSubmitting] = (0, _react.useState)(false);
|
|
154
118
|
|
|
155
119
|
// Set up hooks.
|
|
156
|
-
|
|
157
|
-
hooks
|
|
120
|
+
const {
|
|
121
|
+
hooks
|
|
122
|
+
} = (0, _hooks.useHooks)();
|
|
158
123
|
|
|
159
124
|
// Set up the useValidation hook.
|
|
160
|
-
|
|
161
|
-
addErrors
|
|
162
|
-
clearErrors
|
|
163
|
-
errors
|
|
164
|
-
validate
|
|
125
|
+
const {
|
|
126
|
+
addErrors,
|
|
127
|
+
clearErrors,
|
|
128
|
+
errors,
|
|
129
|
+
validate
|
|
130
|
+
} = (0, _hooks.useValidation)();
|
|
165
131
|
|
|
166
132
|
// Need to set submission data when going back
|
|
167
|
-
window.onpopstate =
|
|
133
|
+
window.onpopstate = e => {
|
|
168
134
|
var _formState$page;
|
|
169
135
|
if (document.location.hash) {
|
|
170
136
|
return;
|
|
171
137
|
}
|
|
172
138
|
if (e.state && e.state.fullPages !== undefined) {
|
|
173
|
-
setCurrentTask(
|
|
139
|
+
setCurrentTask(prev => {
|
|
174
140
|
var _e$state;
|
|
175
141
|
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
176
142
|
fullPages: (_e$state = e.state) === null || _e$state === void 0 ? void 0 : _e$state.fullPages
|
|
@@ -181,16 +147,16 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
181
147
|
setGoingBack(true);
|
|
182
148
|
hooks.onGoingBack(e.state ? e.state : null);
|
|
183
149
|
if (components && pages && data && (_formState$page = formState.page) !== null && _formState$page !== void 0 && _formState$page.formData && pagePoint === undefined) {
|
|
184
|
-
|
|
185
|
-
pages
|
|
186
|
-
components
|
|
150
|
+
const submissionData = _utils.default.Format.form({
|
|
151
|
+
pages,
|
|
152
|
+
components
|
|
187
153
|
}, _objectSpread(_objectSpread({}, data), formState.page.formData), _models.EventTypes.SUBMIT);
|
|
188
154
|
setData(submissionData);
|
|
189
155
|
}
|
|
190
156
|
};
|
|
191
157
|
|
|
192
158
|
// Setup data.
|
|
193
|
-
(0, _react.useEffect)(
|
|
159
|
+
(0, _react.useEffect)(() => {
|
|
194
160
|
if (components && _pages && _data && (pagePoint === 'load' || viewOnly)) {
|
|
195
161
|
var _data$formStatus;
|
|
196
162
|
setData(_utils.default.Data.setupForm(_pages, components, _data));
|
|
@@ -201,24 +167,22 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
201
167
|
}, [components, _pages, _data, setData, pagePoint, viewOnly]);
|
|
202
168
|
|
|
203
169
|
// Setup pages.
|
|
204
|
-
(0, _react.useEffect)(
|
|
170
|
+
(0, _react.useEffect)(() => {
|
|
205
171
|
setPages(_utils.default.FormPage.getAll(_pages, components, _objectSpread({}, data)));
|
|
206
172
|
}, [components, _pages, data, setPages]);
|
|
207
173
|
|
|
208
174
|
// Setup initial pageId.
|
|
209
|
-
(0, _react.useEffect)(
|
|
210
|
-
setPageId(
|
|
211
|
-
return prev || _helpers.default.getNextPageId(type, pages);
|
|
212
|
-
});
|
|
175
|
+
(0, _react.useEffect)(() => {
|
|
176
|
+
setPageId(prev => prev || _helpers.default.getNextPageId(type, pages));
|
|
213
177
|
}, [type, pages, setPageId]);
|
|
214
178
|
|
|
215
179
|
// Setup hub.
|
|
216
|
-
(0, _react.useEffect)(
|
|
180
|
+
(0, _react.useEffect)(() => {
|
|
217
181
|
setHub(_utils.default.Hub.get(type, _hub, components, _objectSpread({}, data)));
|
|
218
182
|
}, [type, _hub, data, components, setHub]);
|
|
219
183
|
|
|
220
184
|
// Form state.
|
|
221
|
-
(0, _react.useEffect)(
|
|
185
|
+
(0, _react.useEffect)(() => {
|
|
222
186
|
var _formState$page2;
|
|
223
187
|
// revert formData changes if going back in hub-and-spoke
|
|
224
188
|
if (type === _models.FormTypes.HUB && goingBack && data && (_formState$page2 = formState.page) !== null && _formState$page2 !== void 0 && _formState$page2.formData) {
|
|
@@ -229,67 +193,63 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
229
193
|
}, [pages, hub, pageId, setFormState, type, goingBack, data, formState.page]);
|
|
230
194
|
|
|
231
195
|
// Call the onFormLoad hook just when this component first renders.
|
|
232
|
-
(0, _react.useEffect)(
|
|
196
|
+
(0, _react.useEffect)(() => {
|
|
233
197
|
setPagePoint(undefined);
|
|
234
198
|
// In case of refresh the current task needs to be reset
|
|
235
|
-
hooks.onFormLoad(
|
|
199
|
+
hooks.onFormLoad(currentTask => {
|
|
236
200
|
setCurrentTask(currentTask);
|
|
237
201
|
});
|
|
238
202
|
}, [hooks]);
|
|
239
|
-
(0, _react.useEffect)(
|
|
203
|
+
(0, _react.useEffect)(() => {
|
|
240
204
|
setHubDetails(_hub);
|
|
241
205
|
}, [_hub]);
|
|
242
206
|
|
|
243
207
|
// Calling setData directly within the hooks.onSubmit success handler
|
|
244
208
|
// resulted in a synchronisation error. Handling it in a useEffect appears
|
|
245
209
|
// to be the way to deal with this... and it certainly seems to work.
|
|
246
|
-
(0, _react.useEffect)(
|
|
210
|
+
(0, _react.useEffect)(() => {
|
|
247
211
|
if (submitted !== null && submitted !== void 0 && submitted.data) {
|
|
248
212
|
setData(submitted.data);
|
|
249
213
|
setSubmitted(undefined);
|
|
250
214
|
}
|
|
251
215
|
}, [submitted, setData, setSubmitted]);
|
|
252
|
-
|
|
253
|
-
|
|
216
|
+
const theSections = _hub === null || _hub === void 0 ? void 0 : _hub.sections;
|
|
217
|
+
const nonSequential = _hub === null || _hub === void 0 ? void 0 : _hub.nonSequential;
|
|
254
218
|
// Update task list pages with form data and update states
|
|
255
|
-
(0, _react.useEffect)(
|
|
256
|
-
|
|
219
|
+
(0, _react.useEffect)(() => {
|
|
220
|
+
const pages = currentTask.fullPages;
|
|
257
221
|
if (pages) {
|
|
258
|
-
pages.forEach(
|
|
259
|
-
|
|
222
|
+
pages.forEach(page => {
|
|
223
|
+
const p = page;
|
|
260
224
|
if (p) {
|
|
261
225
|
p.formData = data;
|
|
262
226
|
}
|
|
263
227
|
});
|
|
264
|
-
setCurrentTask(
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
});
|
|
268
|
-
});
|
|
228
|
+
setCurrentTask(prev => _objectSpread(_objectSpread({}, prev), {}, {
|
|
229
|
+
fullPages: pages
|
|
230
|
+
}));
|
|
269
231
|
}
|
|
270
232
|
if (theSections) {
|
|
271
233
|
var _data$formStatus2;
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
setHubDetails(
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
});
|
|
278
|
-
});
|
|
234
|
+
const tasks = (data === null || data === void 0 || (_data$formStatus2 = data.formStatus) === null || _data$formStatus2 === void 0 ? void 0 : _data$formStatus2.tasks) || {};
|
|
235
|
+
const updatedSections = _helpers.default.getUpdatedSectionStates(theSections, tasks, nonSequential, data);
|
|
236
|
+
setHubDetails(prev => _objectSpread(_objectSpread({}, prev), {}, {
|
|
237
|
+
sections: [].concat(updatedSections)
|
|
238
|
+
}));
|
|
279
239
|
}
|
|
280
240
|
}, [currentTask.fullPages, data, theSections, nonSequential]);
|
|
281
|
-
|
|
282
|
-
|
|
241
|
+
const onPageChange = function (newPageId) {
|
|
242
|
+
let state = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
283
243
|
clearErrors();
|
|
284
244
|
setPageId(newPageId);
|
|
285
245
|
hooks.onPageChange(newPageId, state);
|
|
286
246
|
};
|
|
287
|
-
(0, _react.useEffect)(
|
|
247
|
+
(0, _react.useEffect)(() => {
|
|
288
248
|
if (newPageId !== undefined) setPageId(newPageId);
|
|
289
249
|
}, [newPageId]);
|
|
290
250
|
|
|
291
251
|
// Handle change to form data in pages.
|
|
292
|
-
|
|
252
|
+
const onChange = data => {
|
|
293
253
|
hooks.onChange(data);
|
|
294
254
|
};
|
|
295
255
|
|
|
@@ -297,49 +257,47 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
297
257
|
// Passing a dataCallback allows changes to formData from the
|
|
298
258
|
// CYA screen. This is necessary to allow changing the active
|
|
299
259
|
// entry in page collections.
|
|
300
|
-
|
|
260
|
+
const onCYARowAction = (page, dataCallback) => {
|
|
301
261
|
var _formState$page3;
|
|
302
262
|
if (typeof dataCallback === 'function') {
|
|
303
|
-
|
|
263
|
+
const newData = dataCallback(_objectSpread({}, data));
|
|
304
264
|
if (newData) {
|
|
305
265
|
setData(newData);
|
|
306
266
|
}
|
|
307
267
|
}
|
|
308
268
|
if (((_formState$page3 = formState.page) === null || _formState$page3 === void 0 ? void 0 : _formState$page3.type) === _models.FormPages.PARTIAL_CYA && !cya.disableTaskSwitch) {
|
|
309
|
-
hubDetails.sections.every(
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
});
|
|
317
|
-
});
|
|
269
|
+
hubDetails.sections.every(section => section.tasks.every(task => {
|
|
270
|
+
if (task.pages.includes(page.pageId) && task.name !== currentTask.name) {
|
|
271
|
+
(0, _onTaskAction.default)(task, pages, setCurrentTask, hubDetails, data, onPageChange);
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
return true;
|
|
275
|
+
}));
|
|
318
276
|
}
|
|
319
277
|
if (page) {
|
|
320
278
|
_handlers.default.cyaAction(page, pageId, onPageChange);
|
|
321
279
|
}
|
|
322
280
|
};
|
|
323
|
-
|
|
281
|
+
const classes = _utils.default.classBuilder(classBlock, classModifiers, className);
|
|
324
282
|
if (hub === _models.HubFormats.TASK) {
|
|
325
|
-
|
|
283
|
+
const currentCYA = cya;
|
|
326
284
|
currentCYA.actions = [_models.PageAction.TYPES.SAVE_AND_CONTINUE, _models.PageAction.TYPES.SAVE_AND_RETURN];
|
|
327
285
|
}
|
|
328
286
|
|
|
329
287
|
// filter out invalid attribs
|
|
330
|
-
|
|
331
|
-
|
|
288
|
+
const {
|
|
289
|
+
noTaskCYAs: _noCYA,
|
|
290
|
+
nonSequential: _nonSeq
|
|
291
|
+
} = hubDetails,
|
|
332
292
|
taskDetails = _objectWithoutProperties(hubDetails, _excluded);
|
|
333
293
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
334
294
|
className: classes()
|
|
335
295
|
}, title && !hideTitle && pageId === _models.FormPages.HUB && /*#__PURE__*/_react.default.createElement(_copReactComponents.LargeHeading, null, title), formState.cya && /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, _extends({
|
|
336
296
|
pages: _helpers.default.getRelevantPages(formState, pages, currentTask.fullPages)
|
|
337
297
|
}, cya, ((_formState$page4 = formState.page) === null || _formState$page4 === void 0 ? void 0 : _formState$page4.type) === _models.FormPages.PARTIAL_CYA && {
|
|
338
|
-
actions: (_formState$page$actio = formState.page.actions) === null || _formState$page$actio === void 0 ? void 0 : _formState$page$actio.filter(
|
|
339
|
-
return _utils.default.Component.show(action, data);
|
|
340
|
-
})
|
|
298
|
+
actions: (_formState$page$actio = formState.page.actions) === null || _formState$page$actio === void 0 ? void 0 : _formState$page$actio.filter(action => _utils.default.Component.show(action, data))
|
|
341
299
|
}, formState.cya, {
|
|
342
|
-
onAction:
|
|
300
|
+
onAction: action => {
|
|
343
301
|
(0, _onCYAAction.default)(setPagePoint, action, pages, validate, components, data, setData, type, pageId, currentTask, hooks, addErrors, hub, onPageChange, formState, submitting, setSubmitting);
|
|
344
302
|
},
|
|
345
303
|
onRowAction: onCYARowAction,
|
|
@@ -352,15 +310,15 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
352
310
|
hideBlankRows: hideBlankRows
|
|
353
311
|
})), hub === _models.HubFormats.TASK && formState.pageId === _models.FormPages.HUB && /*#__PURE__*/_react.default.createElement(_TaskList.default, _extends({}, taskDetails, {
|
|
354
312
|
refNumber: data.businessKey,
|
|
355
|
-
onTaskAction:
|
|
356
|
-
(0,
|
|
313
|
+
onTaskAction: task => {
|
|
314
|
+
(0, _onTaskAction.default)(task, pages, setCurrentTask, hubDetails, data, onPageChange);
|
|
357
315
|
},
|
|
358
316
|
annotations: (hubDetails === null || hubDetails === void 0 ? void 0 : hubDetails.taskListAnnotations) || [],
|
|
359
317
|
formData: data
|
|
360
318
|
})), formState.page && !formState.cya && !formState.page.collection && /*#__PURE__*/_react.default.createElement(_FormPage.default, {
|
|
361
319
|
page: formState.page,
|
|
362
320
|
pages: [].concat(pages),
|
|
363
|
-
onAction:
|
|
321
|
+
onAction: (action, patch, patchLabel) => {
|
|
364
322
|
(0, _onPageAction.default)(action, patch, patchLabel, hooks, data, formState, validate, onPageChange, type, pages, components, pageId, setPagePoint, currentTask, setData, hubDetails, setSubmitted, addErrors, submitting, setSubmitting, errors);
|
|
365
323
|
},
|
|
366
324
|
onChange: onChange,
|
|
@@ -374,7 +332,7 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
374
332
|
page: formState.page,
|
|
375
333
|
pages: pages,
|
|
376
334
|
onCollectionChange: onChange,
|
|
377
|
-
onAction:
|
|
335
|
+
onAction: (action, patch, patchLabel) => {
|
|
378
336
|
(0, _onPageAction.default)(action, patch, patchLabel, hooks, data, formState, validate, onPageChange, type, pages, components, pageId, setPagePoint, currentTask, setData, hubDetails, setSubmitted, addErrors, submitting, setSubmitting, errors);
|
|
379
337
|
},
|
|
380
338
|
hashLink: hashLink,
|
|
@@ -383,7 +341,7 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
383
341
|
submitting: submitting
|
|
384
342
|
}));
|
|
385
343
|
};
|
|
386
|
-
|
|
344
|
+
const propTypes = {
|
|
387
345
|
classBlock: _propTypes.default.string,
|
|
388
346
|
classModifiers: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
|
|
389
347
|
className: _propTypes.default.string,
|
|
@@ -415,7 +373,7 @@ var propTypes = {
|
|
|
415
373
|
hideBlankRows: _propTypes.default.bool,
|
|
416
374
|
fromTarget: _propTypes.default.bool.isRequired
|
|
417
375
|
};
|
|
418
|
-
|
|
376
|
+
const defaultProps = {
|
|
419
377
|
classBlock: DEFAULT_CLASS,
|
|
420
378
|
className: '',
|
|
421
379
|
classModifiers: [],
|