@ukhomeoffice/cop-react-form-renderer 5.45.2-alpha → 5.48.1-bravo
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 +12 -12
- package/dist/components/CheckYourAnswers/Answer.test.js +127 -92
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +131 -101
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +769 -464
- package/dist/components/CollectionPage/CollectionPage.js +58 -66
- package/dist/components/CollectionPage/CollectionPage.test.js +342 -300
- package/dist/components/CollectionSummary/BannerStrip.js +12 -12
- package/dist/components/CollectionSummary/BannerStrip.test.js +59 -63
- package/dist/components/CollectionSummary/CollectionSummary.js +88 -61
- package/dist/components/CollectionSummary/CollectionSummary.test.js +96 -102
- package/dist/components/CollectionSummary/Confirmation.js +12 -14
- package/dist/components/CollectionSummary/Confirmation.test.js +63 -68
- package/dist/components/CollectionSummary/SummaryCard.js +148 -109
- package/dist/components/CollectionSummary/SummaryCard.scss +1 -1
- package/dist/components/CollectionSummary/SummaryCard.test.js +927 -905
- package/dist/components/CollectionSummary/SummaryCardValidationContext.js +29 -23
- package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +73 -61
- package/dist/components/FormComponent/Collection.js +107 -73
- package/dist/components/FormComponent/Collection.test.js +945 -809
- package/dist/components/FormComponent/Container.js +38 -40
- package/dist/components/FormComponent/Container.test.js +345 -314
- package/dist/components/FormComponent/FormComponent.js +70 -67
- package/dist/components/FormComponent/FormComponent.test.js +342 -284
- package/dist/components/FormComponent/helpers/addLabel.js +7 -4
- package/dist/components/FormComponent/helpers/getComponentDisabled.js +1 -1
- package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +7 -7
- package/dist/components/FormComponent/helpers/getComponentError.js +5 -3
- package/dist/components/FormComponent/helpers/getComponentError.test.js +14 -14
- package/dist/components/FormComponent/helpers/getComponentFieldSet.js +4 -3
- package/dist/components/FormComponent/helpers/getComponentFieldSet.test.js +6 -6
- package/dist/components/FormComponent/helpers/index.js +4 -4
- package/dist/components/FormPage/FormPage.js +80 -65
- package/dist/components/FormPage/FormPage.test.js +163 -127
- package/dist/components/FormRenderer/FormRenderer.js +181 -144
- package/dist/components/FormRenderer/FormRenderer.test.js +1115 -730
- package/dist/components/FormRenderer/handlers/cyaAction.js +2 -2
- package/dist/components/FormRenderer/handlers/getPageId.js +3 -1
- package/dist/components/FormRenderer/handlers/getPageId.test.js +14 -14
- package/dist/components/FormRenderer/handlers/handlers.test.js +32 -32
- package/dist/components/FormRenderer/handlers/index.js +1 -1
- package/dist/components/FormRenderer/handlers/navigate.js +3 -3
- package/dist/components/FormRenderer/handlers/submissionError.js +1 -1
- package/dist/components/FormRenderer/helpers/canActionProceed.js +5 -1
- package/dist/components/FormRenderer/helpers/canActionProceed.test.js +47 -11
- package/dist/components/FormRenderer/helpers/canCYASubmit.js +3 -1
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +20 -16
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +22 -17
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +16 -16
- package/dist/components/FormRenderer/helpers/getCYA.js +5 -3
- package/dist/components/FormRenderer/helpers/getCYA.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getFormState.js +7 -5
- package/dist/components/FormRenderer/helpers/getFormState.test.js +10 -10
- package/dist/components/FormRenderer/helpers/getNextPageId.js +24 -13
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +67 -67
- package/dist/components/FormRenderer/helpers/getPage.js +4 -2
- package/dist/components/FormRenderer/helpers/getPage.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +9 -7
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +14 -14
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +5 -5
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +91 -97
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +60 -62
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +73 -71
- package/dist/components/FormRenderer/helpers/index.js +1 -1
- package/dist/components/FormRenderer/onCYAAction.js +51 -59
- package/dist/components/FormRenderer/onCYAAction.test.js +152 -164
- package/dist/components/FormRenderer/onPageAction.js +40 -44
- package/dist/components/FormRenderer/onPageAction.test.js +206 -223
- package/dist/components/FormRenderer/onTaskAction.js +13 -9
- package/dist/components/FormRenderer/onTaskAction.test.js +88 -93
- package/dist/components/PageActions/ActionButton.js +15 -12
- package/dist/components/PageActions/ActionButton.test.js +78 -56
- package/dist/components/PageActions/PageActions.js +10 -10
- package/dist/components/PageActions/PageActions.test.js +115 -86
- package/dist/components/SummaryList/GroupAction.js +17 -9
- package/dist/components/SummaryList/GroupAction.test.js +33 -37
- package/dist/components/SummaryList/RowAction.js +16 -11
- package/dist/components/SummaryList/RowAction.test.js +33 -37
- package/dist/components/SummaryList/SummaryList.js +26 -21
- package/dist/components/SummaryList/SummaryList.test.js +166 -143
- package/dist/components/SummaryList/SummaryListHeadingRow.js +4 -6
- package/dist/components/SummaryList/SummaryListRow.js +4 -6
- package/dist/components/SummaryList/SummaryListTitleRow.js +3 -5
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +5 -3
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +22 -22
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +5 -3
- package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +22 -22
- package/dist/components/SummaryList/helpers/index.js +1 -1
- package/dist/components/TaskList/Task.js +29 -19
- package/dist/components/TaskList/Task.test.js +76 -83
- package/dist/components/TaskList/TaskList.js +71 -45
- package/dist/components/TaskList/TaskList.test.js +111 -113
- package/dist/components/TaskList/TaskState.js +5 -7
- package/dist/components/TaskList/TaskState.test.js +45 -52
- package/dist/components/index.js +7 -7
- package/dist/context/HooksContext/HooksContext.js +79 -58
- package/dist/context/HooksContext/HooksContext.test.js +35 -26
- package/dist/context/HooksContext/index.js +4 -3
- package/dist/context/ValidationContext/ValidationContext.js +72 -32
- package/dist/context/ValidationContext/ValidationContext.test.js +59 -47
- package/dist/context/ValidationContext/index.js +4 -3
- package/dist/context/index.js +2 -2
- package/dist/hooks/index.js +10 -9
- package/dist/hooks/useAxios.js +40 -14
- package/dist/hooks/useGetRequest.js +97 -61
- package/dist/hooks/useHooks.js +3 -1
- package/dist/hooks/useRefData.js +39 -26
- package/dist/hooks/useValidation.js +3 -1
- package/dist/index.js +14 -13
- 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 +38 -44
- package/dist/models/TaskStates.js +28 -30
- package/dist/models/index.js +9 -9
- package/dist/setupTests.js +31 -30
- package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +54 -52
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +25 -15
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +35 -33
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +31 -17
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +44 -42
- package/dist/utils/CheckYourAnswers/getCYARow.js +6 -6
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +86 -86
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +24 -18
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +16 -15
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +36 -33
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +60 -58
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +88 -79
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +124 -146
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +20 -25
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +97 -103
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +18 -13
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +76 -70
- package/dist/utils/CheckYourAnswers/index.js +1 -1
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +4 -4
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +24 -24
- package/dist/utils/CollectionPage/addCollectionPageEntry.js +1 -1
- package/dist/utils/CollectionPage/addCollectionPageEntry.test.js +5 -5
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +2 -2
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +17 -17
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +18 -9
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +22 -27
- package/dist/utils/CollectionPage/getCollectionPageActiveId.js +2 -2
- package/dist/utils/CollectionPage/getCollectionPageActiveId.test.js +10 -10
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +11 -7
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +22 -22
- package/dist/utils/CollectionPage/getCollectionPageData.js +12 -8
- package/dist/utils/CollectionPage/getCollectionPageData.test.js +19 -19
- package/dist/utils/CollectionPage/getQuickEditPage.js +19 -19
- package/dist/utils/CollectionPage/getQuickEditPage.test.js +16 -12
- package/dist/utils/CollectionPage/index.js +1 -1
- package/dist/utils/CollectionPage/mergeCollectionPages.js +30 -29
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +17 -17
- package/dist/utils/CollectionPage/removeCollectionPageEntry.js +6 -4
- package/dist/utils/CollectionPage/removeCollectionPageEntry.test.js +10 -10
- package/dist/utils/CollectionPage/setCollectionPageData.js +12 -8
- package/dist/utils/CollectionPage/setCollectionPageData.test.js +17 -17
- package/dist/utils/Component/addShowWhen.js +8 -4
- package/dist/utils/Component/addShowWhen.test.js +37 -37
- package/dist/utils/Component/applyToComponentTree.js +18 -18
- package/dist/utils/Component/applyToComponentTree.test.js +32 -27
- package/dist/utils/Component/cleanAttributes.js +13 -10
- package/dist/utils/Component/cleanAttributes.test.js +18 -17
- package/dist/utils/Component/elevateNestedComponents.js +5 -5
- package/dist/utils/Component/elevateNestedComponents.test.js +30 -30
- package/dist/utils/Component/getComponent.js +95 -88
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +17 -18
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +59 -46
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +48 -39
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +33 -23
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +18 -20
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +22 -17
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +25 -20
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +9 -10
- package/dist/utils/Component/getComponentTests/getComponent.html.test.js +15 -17
- package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +8 -9
- package/dist/utils/Component/getComponentTests/getComponent.list.test.js +15 -17
- package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +26 -22
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +175 -155
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +15 -17
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +22 -17
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +70 -57
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +22 -17
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +22 -17
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +38 -31
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +29 -20
- package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +2 -2
- package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +8 -9
- package/dist/utils/Component/getDefaultValue.js +8 -6
- package/dist/utils/Component/getDefaultValue.test.js +12 -12
- package/dist/utils/Component/getDefaultValueFromConfig.js +22 -23
- package/dist/utils/Component/getDefaultValueFromConfig.test.js +31 -31
- package/dist/utils/Component/index.js +1 -1
- package/dist/utils/Component/isEditable.js +4 -2
- package/dist/utils/Component/isEditable.test.js +15 -14
- package/dist/utils/Component/optionIsSelected.js +1 -1
- package/dist/utils/Component/optionIsSelected.test.js +9 -9
- package/dist/utils/Component/setupContainerComponentsPath.js +29 -27
- package/dist/utils/Component/setupContainerComponentsPath.test.js +11 -11
- package/dist/utils/Component/showComponent.js +1 -1
- package/dist/utils/Component/showComponent.test.js +28 -28
- package/dist/utils/Component/wrapInFormGroup.js +2 -2
- package/dist/utils/Condition/index.js +1 -1
- package/dist/utils/Condition/meetsAllConditions.js +7 -7
- package/dist/utils/Condition/meetsAllConditions.test.js +17 -17
- package/dist/utils/Condition/meetsCondition.js +17 -14
- package/dist/utils/Condition/meetsCondition.test.js +376 -376
- package/dist/utils/Condition/meetsOneCondition.js +5 -5
- package/dist/utils/Condition/meetsOneCondition.test.js +16 -16
- package/dist/utils/Condition/setupConditions.js +18 -13
- package/dist/utils/Condition/setupConditions.test.js +7 -7
- package/dist/utils/Container/getEditableComponents.js +5 -3
- package/dist/utils/Container/getEditableComponents.test.js +45 -43
- package/dist/utils/Container/index.js +1 -1
- package/dist/utils/Container/setupNesting.js +20 -16
- package/dist/utils/Container/setupNesting.test.js +30 -27
- package/dist/utils/Container/showContainer.js +7 -3
- package/dist/utils/Container/showContainer.test.js +30 -30
- package/dist/utils/Data/applyFormula.js +48 -38
- package/dist/utils/Data/applyFormula.test.js +20 -20
- package/dist/utils/Data/getAutocompleteSource.js +26 -18
- package/dist/utils/Data/getAutocompleteSource.test.js +86 -80
- package/dist/utils/Data/getDataPath.js +28 -18
- package/dist/utils/Data/getDataPath.test.js +12 -12
- package/dist/utils/Data/getOptions.js +25 -19
- package/dist/utils/Data/getOptions.test.js +20 -20
- package/dist/utils/Data/getSourceData.js +19 -6
- package/dist/utils/Data/getSourceData.test.js +80 -84
- package/dist/utils/Data/index.js +1 -1
- package/dist/utils/Data/refDataToOptions.js +13 -10
- package/dist/utils/Data/refDataToOptions.test.js +19 -19
- package/dist/utils/Data/setDataItem.js +8 -7
- package/dist/utils/Data/setDataItem.test.js +37 -37
- package/dist/utils/Data/setupFormData.js +21 -13
- package/dist/utils/Data/setupFormData.test.js +50 -51
- package/dist/utils/Data/setupRefDataUrlForComponent.js +26 -20
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +24 -24
- package/dist/utils/FormPage/applyConditionalProperties.js +9 -5
- package/dist/utils/FormPage/applyConditionalProperties.test.js +18 -15
- package/dist/utils/FormPage/getFormPage.js +16 -15
- package/dist/utils/FormPage/getFormPage.test.js +46 -47
- package/dist/utils/FormPage/getFormPages.js +12 -7
- package/dist/utils/FormPage/getFormPages.test.js +23 -20
- package/dist/utils/FormPage/getPageActions.js +15 -9
- package/dist/utils/FormPage/getPageActions.test.js +32 -32
- package/dist/utils/FormPage/getPageTitle.js +2 -2
- package/dist/utils/FormPage/getPageTitle.test.js +22 -22
- package/dist/utils/FormPage/getParagraphFromText.js +7 -5
- package/dist/utils/FormPage/getParagraphFromText.test.js +6 -6
- package/dist/utils/FormPage/index.js +1 -1
- package/dist/utils/FormPage/showFormPage.js +7 -3
- package/dist/utils/FormPage/showFormPage.test.js +32 -32
- package/dist/utils/FormPage/showFormPageCYA.js +1 -1
- package/dist/utils/FormPage/showFormPageCYA.test.js +8 -8
- package/dist/utils/FormPage/useComponent.js +28 -21
- package/dist/utils/FormPage/useComponent.test.js +79 -78
- package/dist/utils/Format/formatData.js +1 -1
- package/dist/utils/Format/formatData.test.js +18 -18
- package/dist/utils/Format/formatDataForComponent.js +6 -5
- package/dist/utils/Format/formatDataForComponent.test.js +77 -50
- package/dist/utils/Format/formatDataForForm.js +8 -6
- package/dist/utils/Format/formatDataForForm.test.js +15 -13
- package/dist/utils/Format/formatDataForPage.js +5 -4
- package/dist/utils/Format/formatDataForPage.test.js +23 -20
- package/dist/utils/Format/index.js +1 -1
- package/dist/utils/Hub/getFormHub.js +1 -1
- package/dist/utils/Hub/getFormHub.test.js +31 -28
- package/dist/utils/Hub/index.js +1 -1
- 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 +16 -24
- package/dist/utils/Meta/documents/index.js +1 -1
- package/dist/utils/Meta/documents/setDocumentsForField.js +16 -14
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +34 -68
- package/dist/utils/Meta/index.js +1 -1
- package/dist/utils/Operate/checkValueIsTruthy.js +2 -2
- package/dist/utils/Operate/checkValueIsTruthy.test.js +16 -16
- package/dist/utils/Operate/getFirstOf.js +5 -5
- package/dist/utils/Operate/getFirstOf.test.js +31 -31
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +10 -10
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +46 -46
- package/dist/utils/Operate/index.js +1 -1
- package/dist/utils/Operate/persistValueInFormData.js +3 -3
- package/dist/utils/Operate/persistValueInFormData.test.js +20 -22
- package/dist/utils/Operate/runPageOperations.js +7 -7
- package/dist/utils/Operate/runPageOperations.test.js +36 -35
- package/dist/utils/Operate/setValueInFormData.js +2 -2
- package/dist/utils/Operate/setValueInFormData.test.js +16 -16
- package/dist/utils/Operate/shouldRun.js +6 -6
- package/dist/utils/Operate/shouldRun.test.js +26 -21
- package/dist/utils/Validate/additional/conditionallyRequired.js +4 -4
- package/dist/utils/Validate/additional/conditionallyRequired.test.js +18 -18
- package/dist/utils/Validate/additional/index.js +10 -8
- package/dist/utils/Validate/additional/index.test.js +12 -12
- package/dist/utils/Validate/additional/mustBeAfter.js +2 -2
- package/dist/utils/Validate/additional/mustBeAfter.test.js +40 -40
- package/dist/utils/Validate/additional/mustBeBefore.js +2 -2
- package/dist/utils/Validate/additional/mustBeBefore.test.js +28 -28
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +11 -7
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +41 -37
- package/dist/utils/Validate/additional/mustBeGreaterThan.js +2 -2
- package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +18 -18
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +2 -2
- package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +12 -12
- package/dist/utils/Validate/additional/mustBeInThePast.js +3 -3
- package/dist/utils/Validate/additional/mustBeInThePast.test.js +12 -12
- package/dist/utils/Validate/additional/mustBeLessThan.js +2 -2
- package/dist/utils/Validate/additional/mustBeLessThan.test.js +17 -17
- package/dist/utils/Validate/additional/mustBeLongerThan.js +1 -1
- package/dist/utils/Validate/additional/mustBeLongerThan.test.js +16 -16
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +2 -2
- package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +20 -20
- package/dist/utils/Validate/additional/mustBeShorterThan.js +1 -1
- package/dist/utils/Validate/additional/mustBeShorterThan.test.js +16 -16
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.js +35 -0
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.test.js +127 -0
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +2 -2
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +16 -14
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +1 -1
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +12 -12
- package/dist/utils/Validate/additional/mustNotContainSql.js +4 -3
- package/dist/utils/Validate/additional/mustNotContainSql.test.js +14 -14
- package/dist/utils/Validate/additional/mustSelectOnlyOne.js +2 -2
- package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +26 -28
- package/dist/utils/Validate/additional/utils.js +22 -9
- package/dist/utils/Validate/index.js +1 -1
- package/dist/utils/Validate/validateCollection.js +25 -19
- package/dist/utils/Validate/validateCollection.test.js +66 -74
- package/dist/utils/Validate/validateComponent.js +16 -18
- package/dist/utils/Validate/validateComponent.test.js +146 -167
- package/dist/utils/Validate/validateContainer.js +19 -14
- package/dist/utils/Validate/validateContainer.test.js +45 -49
- package/dist/utils/Validate/validateDate.js +17 -11
- package/dist/utils/Validate/validateDate.test.js +29 -28
- package/dist/utils/Validate/validateEmail.js +8 -6
- package/dist/utils/Validate/validateEmail.test.js +25 -25
- package/dist/utils/Validate/validateMultifile.js +7 -5
- package/dist/utils/Validate/validateMultifile.test.js +18 -17
- package/dist/utils/Validate/validatePage.js +18 -17
- package/dist/utils/Validate/validatePage.test.js +182 -185
- package/dist/utils/Validate/validateRegex.js +5 -3
- package/dist/utils/Validate/validateRegex.test.js +14 -14
- package/dist/utils/Validate/validateRequired.js +6 -4
- package/dist/utils/Validate/validateRequired.test.js +18 -18
- package/dist/utils/Validate/validateTextArea.js +6 -4
- package/dist/utils/Validate/validateTextArea.test.js +20 -20
- package/dist/utils/Validate/validateTime.js +14 -7
- package/dist/utils/Validate/validateTime.test.js +14 -14
- package/dist/utils/index.js +9 -7
- package/package.json +1 -1
|
@@ -16,21 +16,21 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
16
16
|
|
|
17
17
|
// Styles.
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
var DEFAULT_CLASS = exports.DEFAULT_CLASS = 'hods-form-banner-strip';
|
|
20
|
+
var BannerStrip = function BannerStrip(_ref) {
|
|
21
|
+
var id = _ref.id,
|
|
22
|
+
banners = _ref.banners,
|
|
23
|
+
formData = _ref.formData,
|
|
24
|
+
classModifiers = _ref.classModifiers;
|
|
25
|
+
var classes = _utils.default.classBuilder(DEFAULT_CLASS, classModifiers, '');
|
|
26
|
+
var filteredBanners = banners.filter(function (banner) {
|
|
27
|
+
return _utils.default.Component.show(banner, formData);
|
|
28
|
+
});
|
|
29
29
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
30
30
|
id: id,
|
|
31
31
|
className: classes()
|
|
32
|
-
}, filteredBanners.map((banner, index)
|
|
33
|
-
|
|
32
|
+
}, filteredBanners.map(function (banner, index) {
|
|
33
|
+
var bannerId = "".concat(id, "-banner-").concat(index);
|
|
34
34
|
if (typeof banner === 'string') {
|
|
35
35
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
36
36
|
id: bannerId,
|
|
@@ -1,128 +1,124 @@
|
|
|
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); }
|
|
3
4
|
var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
4
5
|
var _react = _interopRequireDefault(require("react"));
|
|
5
6
|
var _setupTests = require("../../setupTests");
|
|
6
7
|
var _BannerStrip = _interopRequireWildcard(require("./BannerStrip"));
|
|
7
|
-
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); }
|
|
8
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" !=
|
|
8
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
9
|
+
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 && Object.prototype.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; }
|
|
9
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
11
|
// Global imports.
|
|
11
12
|
|
|
12
13
|
// Local imports.
|
|
13
14
|
|
|
14
|
-
describe('components.CollectionSummary.BannerStrip', ()
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
describe('components.CollectionSummary.BannerStrip', function () {
|
|
16
|
+
var ID = 'testBanner';
|
|
17
|
+
var BANNERS = ['Banner 1', 'Banner 2'];
|
|
18
|
+
var FORM_DATA = {
|
|
18
19
|
textField: 'banner'
|
|
19
20
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
var classes = _copReactComponents.Utils.classBuilder(_BannerStrip.DEFAULT_CLASS, [], '');
|
|
22
|
+
var checkSetup = function checkSetup(container) {
|
|
23
|
+
var bannerStripDiv = container.children[0];
|
|
23
24
|
expect(bannerStripDiv.tagName).toEqual('DIV');
|
|
24
25
|
expect(bannerStripDiv.id).toEqual(ID);
|
|
25
26
|
return bannerStripDiv;
|
|
26
27
|
};
|
|
27
|
-
it('should correctly render a BannerStrip component with plain-text banners', ()
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const bannerStripDiv = checkSetup(container);
|
|
28
|
+
it('should correctly render a BannerStrip component with plain-text banners', function () {
|
|
29
|
+
var _renderWithValidation = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_BannerStrip.default, {
|
|
30
|
+
id: ID,
|
|
31
|
+
banners: BANNERS,
|
|
32
|
+
formData: FORM_DATA
|
|
33
|
+
})),
|
|
34
|
+
container = _renderWithValidation.container;
|
|
35
|
+
var bannerStripDiv = checkSetup(container);
|
|
36
36
|
expect(bannerStripDiv.tagName).toEqual('DIV');
|
|
37
37
|
expect(bannerStripDiv.classList).toContain(_BannerStrip.DEFAULT_CLASS);
|
|
38
38
|
expect(bannerStripDiv.children.length).toEqual(2); // One for each banner provided.
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
var firstBanner = bannerStripDiv.children[0];
|
|
41
41
|
expect(firstBanner.tagName).toEqual('DIV');
|
|
42
42
|
expect(firstBanner.classList).toContain(classes('banner'));
|
|
43
43
|
expect(firstBanner.textContent).toEqual(BANNERS[0]);
|
|
44
|
-
|
|
44
|
+
var secondBanner = bannerStripDiv.children[1];
|
|
45
45
|
expect(secondBanner.tagName).toEqual('DIV');
|
|
46
46
|
expect(secondBanner.classList).toContain(classes('banner'));
|
|
47
47
|
expect(secondBanner.textContent).toEqual(BANNERS[1]);
|
|
48
48
|
});
|
|
49
|
-
it('should correctly render a BannerStrip component with tag banners', ()
|
|
50
|
-
|
|
49
|
+
it('should correctly render a BannerStrip component with tag banners', function () {
|
|
50
|
+
var TAG_BANNERS = [{
|
|
51
51
|
text: 'Banner 1'
|
|
52
52
|
}, {
|
|
53
53
|
text: 'Banner 2'
|
|
54
54
|
}];
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const bannerStripDiv = checkSetup(container);
|
|
55
|
+
var _renderWithValidation2 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_BannerStrip.default, {
|
|
56
|
+
id: ID,
|
|
57
|
+
banners: TAG_BANNERS,
|
|
58
|
+
formData: FORM_DATA
|
|
59
|
+
})),
|
|
60
|
+
container = _renderWithValidation2.container;
|
|
61
|
+
var bannerStripDiv = checkSetup(container);
|
|
63
62
|
expect(bannerStripDiv.tagName).toEqual('DIV');
|
|
64
63
|
expect(bannerStripDiv.classList).toContain(_BannerStrip.DEFAULT_CLASS);
|
|
65
64
|
expect(bannerStripDiv.children.length).toEqual(2); // One for each banner provided.
|
|
66
65
|
|
|
67
|
-
|
|
66
|
+
var firstBanner = bannerStripDiv.children[0];
|
|
68
67
|
expect(firstBanner.tagName).toEqual('STRONG');
|
|
69
68
|
expect(firstBanner.classList).toContain(classes('tag'));
|
|
70
69
|
expect(firstBanner.textContent).toEqual(BANNERS[0]);
|
|
71
|
-
|
|
70
|
+
var secondBanner = bannerStripDiv.children[1];
|
|
72
71
|
expect(secondBanner.tagName).toEqual('STRONG');
|
|
73
72
|
expect(secondBanner.classList).toContain(classes('tag'));
|
|
74
73
|
expect(secondBanner.textContent).toEqual(BANNERS[1]);
|
|
75
74
|
});
|
|
76
|
-
it('should correctly interpolate banners', ()
|
|
77
|
-
|
|
75
|
+
it('should correctly interpolate banners', function () {
|
|
76
|
+
var INTERPOLATED_BANNERS = [{
|
|
78
77
|
// eslint-disable-next-line no-template-curly-in-string
|
|
79
78
|
text: 'An interpolated ${textField}'
|
|
80
79
|
},
|
|
81
80
|
// eslint-disable-next-line no-template-curly-in-string
|
|
82
81
|
'Another interpolated ${textField}'];
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const bannerStripDiv = checkSetup(container);
|
|
82
|
+
var _renderWithValidation3 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_BannerStrip.default, {
|
|
83
|
+
id: ID,
|
|
84
|
+
banners: INTERPOLATED_BANNERS,
|
|
85
|
+
formData: FORM_DATA
|
|
86
|
+
})),
|
|
87
|
+
container = _renderWithValidation3.container;
|
|
88
|
+
var bannerStripDiv = checkSetup(container);
|
|
91
89
|
expect(bannerStripDiv.children.length).toEqual(2); // One for each banner provided.
|
|
92
90
|
|
|
93
|
-
|
|
91
|
+
var firstBanner = bannerStripDiv.children[0];
|
|
94
92
|
expect(firstBanner.tagName).toEqual('STRONG');
|
|
95
93
|
expect(firstBanner.classList).toContain(classes('tag'));
|
|
96
94
|
expect(firstBanner.textContent).toEqual("An interpolated ".concat(FORM_DATA.textField));
|
|
97
|
-
|
|
95
|
+
var secondBanner = bannerStripDiv.children[1];
|
|
98
96
|
expect(secondBanner.tagName).toEqual('DIV');
|
|
99
97
|
expect(secondBanner.classList).toContain(classes('banner'));
|
|
100
98
|
expect(secondBanner.textContent).toEqual("Another interpolated ".concat(FORM_DATA.textField));
|
|
101
99
|
});
|
|
102
|
-
it('should render no banners if none are provided', ()
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const bannerStripDiv = checkSetup(container);
|
|
100
|
+
it('should render no banners if none are provided', function () {
|
|
101
|
+
var _renderWithValidation4 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_BannerStrip.default, {
|
|
102
|
+
id: ID,
|
|
103
|
+
formData: FORM_DATA
|
|
104
|
+
})),
|
|
105
|
+
container = _renderWithValidation4.container;
|
|
106
|
+
var bannerStripDiv = checkSetup(container);
|
|
110
107
|
expect(bannerStripDiv.tagName).toEqual('DIV');
|
|
111
108
|
expect(bannerStripDiv.classList).toContain(_BannerStrip.DEFAULT_CLASS);
|
|
112
109
|
expect(bannerStripDiv.children.length).toEqual(0);
|
|
113
110
|
});
|
|
114
|
-
it('should correctly render a BannerStrip component with a plain string banner', ()
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
const bannerStripDiv = checkSetup(container);
|
|
111
|
+
it('should correctly render a BannerStrip component with a plain string banner', function () {
|
|
112
|
+
var PLAIN_STRING_BANNER = 'banner';
|
|
113
|
+
var _renderWithValidation5 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_BannerStrip.default, {
|
|
114
|
+
id: ID,
|
|
115
|
+
banners: [PLAIN_STRING_BANNER],
|
|
116
|
+
formData: FORM_DATA
|
|
117
|
+
})),
|
|
118
|
+
container = _renderWithValidation5.container;
|
|
119
|
+
var bannerStripDiv = checkSetup(container);
|
|
124
120
|
expect(bannerStripDiv.children.length).toEqual(1); // One banner provided.
|
|
125
|
-
|
|
121
|
+
var plainStringBanner = bannerStripDiv.children[0];
|
|
126
122
|
expect(plainStringBanner.tagName).toEqual('DIV');
|
|
127
123
|
expect(plainStringBanner.classList.contains(classes('banner'))).toBe(true);
|
|
128
124
|
expect(plainStringBanner.textContent).toEqual(PLAIN_STRING_BANNER);
|
|
@@ -1,5 +1,6 @@
|
|
|
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); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
@@ -14,16 +15,23 @@ var _Confirmation = _interopRequireDefault(require("./Confirmation"));
|
|
|
14
15
|
var _SummaryCard = _interopRequireDefault(require("./SummaryCard"));
|
|
15
16
|
var _SummaryCardValidationContext = _interopRequireDefault(require("./SummaryCardValidationContext"));
|
|
16
17
|
require("./CollectionSummary.scss");
|
|
17
|
-
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); }
|
|
18
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" !=
|
|
18
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
19
|
+
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 && Object.prototype.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; }
|
|
19
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
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; }
|
|
22
|
+
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; }
|
|
23
|
+
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; }
|
|
24
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
25
|
+
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); }
|
|
26
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
27
|
+
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."); }
|
|
28
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
29
|
+
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; }
|
|
30
|
+
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; } }
|
|
31
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } // Global imports.
|
|
22
32
|
// Local imports.
|
|
23
|
-
|
|
24
33
|
// Styles.
|
|
25
|
-
|
|
26
|
-
const DEFAULT_ADD_BUTTON_LABEL = exports.DEFAULT_ADD_BUTTON_LABEL = 'Add';
|
|
34
|
+
var DEFAULT_ADD_BUTTON_LABEL = exports.DEFAULT_ADD_BUTTON_LABEL = 'Add';
|
|
27
35
|
|
|
28
36
|
// A note about validation.
|
|
29
37
|
//
|
|
@@ -37,55 +45,58 @@ const DEFAULT_ADD_BUTTON_LABEL = exports.DEFAULT_ADD_BUTTON_LABEL = 'Add';
|
|
|
37
45
|
// errors found by the summary and allow the Summary Card to keep any Quick Edit
|
|
38
46
|
// errors local to the Quick Edit page.
|
|
39
47
|
|
|
40
|
-
|
|
48
|
+
var CollectionSummary = function CollectionSummary(_ref) {
|
|
41
49
|
var _config$confirmation, _config$confirmation2;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
var config = _ref.config,
|
|
51
|
+
formData = _ref.formData,
|
|
52
|
+
onAction = _ref.onAction,
|
|
53
|
+
onChange = _ref.onChange,
|
|
54
|
+
pages = _ref.pages;
|
|
55
|
+
var _useValidation = (0, _hooks.useValidation)(),
|
|
56
|
+
errors = _useValidation.errors,
|
|
57
|
+
addErrors = _useValidation.addErrors,
|
|
58
|
+
clearErrors = _useValidation.clearErrors;
|
|
59
|
+
var _useState = (0, _react.useState)(null),
|
|
60
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
61
|
+
entryToDelete = _useState2[0],
|
|
62
|
+
setEntryToDelete = _useState2[1];
|
|
63
|
+
var data = (0, _react.useMemo)(function () {
|
|
64
|
+
return _utils.default.CollectionPage.getData(config.collectionName, formData) || [];
|
|
65
|
+
}, [formData]);
|
|
66
|
+
var masterPage = (0, _react.useMemo)(function () {
|
|
67
|
+
var newMasterPages = _utils.default.CollectionPage.mergePages(pages || []) || [];
|
|
68
|
+
return newMasterPages.find(function (page) {
|
|
59
69
|
var _page$collection;
|
|
60
70
|
return ((_page$collection = page.collection) === null || _page$collection === void 0 ? void 0 : _page$collection.name) === config.collectionName;
|
|
61
71
|
});
|
|
62
72
|
}, [pages]);
|
|
63
|
-
|
|
73
|
+
var validateEntries = function validateEntries() {
|
|
64
74
|
// We only clear errors if it's not empty to avoid
|
|
65
75
|
// triggering a race condition with the 'data' memo
|
|
66
76
|
// above.
|
|
67
77
|
if (errors.length > 0) {
|
|
68
78
|
clearErrors();
|
|
69
79
|
}
|
|
70
|
-
|
|
71
|
-
data.forEach(entry
|
|
80
|
+
var allErrors = [];
|
|
81
|
+
data.forEach(function (entry) {
|
|
72
82
|
// Validation of a collection page uses the data from the
|
|
73
83
|
// active entry, so here we have to set the active ID before
|
|
74
84
|
// validating.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
85
|
+
var childPages = masterPage === null || masterPage === void 0 ? void 0 : masterPage.childPages.map(function (page) {
|
|
86
|
+
return _objectSpread(_objectSpread({}, page), {}, {
|
|
87
|
+
formData: _objectSpread(_objectSpread({}, masterPage.formData), {}, _defineProperty({}, "".concat(config.collectionName, "ActiveId"), entry.id))
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
var allPagesErrors = (childPages === null || childPages === void 0 ? void 0 : childPages.flatMap(function (page) {
|
|
91
|
+
return _utils.default.Validate.page(page);
|
|
92
|
+
})) || [];
|
|
83
93
|
// For each error we found, add the entryId so we know what Summary Card
|
|
84
94
|
// we have to pass it to.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
95
|
+
var entryErrors = allPagesErrors.map(function (e) {
|
|
96
|
+
return _objectSpread(_objectSpread({}, e), {}, {
|
|
97
|
+
entryId: entry.id
|
|
98
|
+
});
|
|
99
|
+
});
|
|
89
100
|
allErrors = allErrors.concat(entryErrors);
|
|
90
101
|
});
|
|
91
102
|
// We only add allErrors if it's not empty to avoid
|
|
@@ -95,26 +106,26 @@ const CollectionSummary = _ref => {
|
|
|
95
106
|
addErrors(allErrors);
|
|
96
107
|
}
|
|
97
108
|
};
|
|
98
|
-
(0, _react.useEffect)(()
|
|
109
|
+
(0, _react.useEffect)(function () {
|
|
99
110
|
validateEntries();
|
|
100
111
|
}, [data]);
|
|
101
|
-
|
|
112
|
+
var onSummaryCardChange = function onSummaryCardChange(page, entryId) {
|
|
102
113
|
if (typeof onAction !== 'function') {
|
|
103
114
|
return;
|
|
104
115
|
}
|
|
105
116
|
onAction({
|
|
106
117
|
type: _PageAction.PageActionTypes.SAVE_AND_NAVIGATE,
|
|
107
|
-
page,
|
|
118
|
+
page: page,
|
|
108
119
|
addToFormData: {
|
|
109
120
|
field: "".concat(config.collectionName.split('.').pop(), "ActiveId"),
|
|
110
121
|
value: entryId
|
|
111
122
|
}
|
|
112
123
|
});
|
|
113
124
|
};
|
|
114
|
-
|
|
125
|
+
var onDuplicate = function onDuplicate(entry) {
|
|
115
126
|
var _config$card;
|
|
116
127
|
_utils.default.CollectionPage.duplicateEntry(config.collectionName, formData, entry.id, ((_config$card = config.card) === null || _config$card === void 0 || (_config$card = _config$card.duplicateAction) === null || _config$card === void 0 ? void 0 : _config$card.fieldsToIgnore) || []);
|
|
117
|
-
|
|
128
|
+
var parentCollection = config.collectionName.split('.').shift();
|
|
118
129
|
// Report the whole top-level collection as being changed. We have to do this
|
|
119
130
|
// because of how patch is applied to formData on a page submission.
|
|
120
131
|
if (typeof onChange === 'function') {
|
|
@@ -127,12 +138,12 @@ const CollectionSummary = _ref => {
|
|
|
127
138
|
validateEntries();
|
|
128
139
|
}
|
|
129
140
|
};
|
|
130
|
-
|
|
141
|
+
var onDeleteConfirm = function onDeleteConfirm() {
|
|
131
142
|
if (!entryToDelete) {
|
|
132
143
|
return;
|
|
133
144
|
}
|
|
134
145
|
_utils.default.CollectionPage.removeEntry(config.collectionName, formData, entryToDelete.id);
|
|
135
|
-
|
|
146
|
+
var parentCollection = config.collectionName.split('.').shift();
|
|
136
147
|
// Report the whole top-level collection as being changed. We have to do this
|
|
137
148
|
// because of how patch is applied to formData on a page submission.
|
|
138
149
|
if (typeof onChange === 'function') {
|
|
@@ -153,14 +164,15 @@ const CollectionSummary = _ref => {
|
|
|
153
164
|
message: _utils.default.interpolateString((_config$confirmation = config.confirmation) === null || _config$confirmation === void 0 ? void 0 : _config$confirmation.message, entryToDelete) || null,
|
|
154
165
|
confirmLabel: _utils.default.interpolateString((_config$confirmation2 = config.confirmation) === null || _config$confirmation2 === void 0 ? void 0 : _config$confirmation2.label, entryToDelete) || null,
|
|
155
166
|
onConfirm: onDeleteConfirm,
|
|
156
|
-
onCancel: ()
|
|
167
|
+
onCancel: function onCancel() {
|
|
168
|
+
return setEntryToDelete(null);
|
|
169
|
+
}
|
|
157
170
|
}, /*#__PURE__*/_react.default.createElement(_SummaryCard.default, {
|
|
158
171
|
id: "".concat(config.fieldId, ".confirmationChild"),
|
|
159
172
|
entryData: entryToDelete,
|
|
160
|
-
config: config.card ? {
|
|
161
|
-
...config.card,
|
|
173
|
+
config: config.card ? _objectSpread(_objectSpread({}, config.card), {}, {
|
|
162
174
|
quickEdit: null
|
|
163
|
-
} : {},
|
|
175
|
+
}) : {},
|
|
164
176
|
masterPage: masterPage,
|
|
165
177
|
classModifiers: "nested",
|
|
166
178
|
hideDetails: true
|
|
@@ -174,32 +186,39 @@ const CollectionSummary = _ref => {
|
|
|
174
186
|
classModifiers: ['secondary']
|
|
175
187
|
},
|
|
176
188
|
onAction: onAction
|
|
177
|
-
}), data.map((entry, index)
|
|
178
|
-
|
|
189
|
+
}), data.map(function (entry, index) {
|
|
190
|
+
var isInError = errors.filter(function (e) {
|
|
191
|
+
return e.entryId === entry.id;
|
|
192
|
+
}).length > 0;
|
|
193
|
+
var finalConfig = _objectSpread(_objectSpread({}, config.card), isInError && config.errorCard ? config.errorCard : {});
|
|
194
|
+
var key = "".concat(config.fieldId, ".summaryCard").concat(entry.id);
|
|
179
195
|
return /*#__PURE__*/_react.default.createElement(_SummaryCardValidationContext.default, {
|
|
180
196
|
entryId: entry.id,
|
|
181
197
|
topLevelErrors: errors
|
|
182
198
|
}, /*#__PURE__*/_react.default.createElement(_SummaryCard.default, {
|
|
183
199
|
id: key,
|
|
184
200
|
key: key,
|
|
185
|
-
entryData: {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
},
|
|
201
|
+
entryData: _objectSpread(_objectSpread({}, entry), {}, {
|
|
202
|
+
index: index
|
|
203
|
+
}),
|
|
189
204
|
masterPage: masterPage,
|
|
190
|
-
config:
|
|
205
|
+
config: finalConfig || {},
|
|
191
206
|
onChange: onSummaryCardChange,
|
|
192
207
|
onDuplicate: onDuplicate,
|
|
193
|
-
onDelete: ()
|
|
208
|
+
onDelete: function onDelete() {
|
|
209
|
+
return setEntryToDelete(entry);
|
|
210
|
+
},
|
|
194
211
|
pages: pages,
|
|
195
|
-
onQuickEdit: target
|
|
212
|
+
onQuickEdit: function onQuickEdit(target) {
|
|
196
213
|
validateEntries();
|
|
197
214
|
return onChange(target);
|
|
198
215
|
},
|
|
199
216
|
parentCollectionName: config.collectionName.split('.').shift(),
|
|
200
217
|
formData: formData,
|
|
201
218
|
classModifiers: entry === entryToDelete ? ['deleting-summary-card'] : [''],
|
|
202
|
-
inError: errors.filter(
|
|
219
|
+
inError: errors.filter(function (e) {
|
|
220
|
+
return e.entryId === entry.id;
|
|
221
|
+
}).length > 0
|
|
203
222
|
}));
|
|
204
223
|
}));
|
|
205
224
|
};
|
|
@@ -219,6 +238,14 @@ CollectionSummary.propTypes = {
|
|
|
219
238
|
fieldsToIgnore: _propTypes.default.arrayOf(_propTypes.default.string)
|
|
220
239
|
})
|
|
221
240
|
}),
|
|
241
|
+
errorCard: _propTypes.default.shape({
|
|
242
|
+
banners: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.shape({})])),
|
|
243
|
+
title: _propTypes.default.string,
|
|
244
|
+
details: _propTypes.default.string,
|
|
245
|
+
duplicateAction: _propTypes.default.shape({
|
|
246
|
+
fieldsToIgnore: _propTypes.default.arrayOf(_propTypes.default.string)
|
|
247
|
+
})
|
|
248
|
+
}),
|
|
222
249
|
confirmation: _propTypes.default.shape({
|
|
223
250
|
message: _propTypes.default.string,
|
|
224
251
|
label: _propTypes.default.string
|