@ukhomeoffice/cop-react-form-renderer 6.7.0-alpha → 6.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CheckYourAnswers/Answer.js +22 -16
- package/dist/components/CheckYourAnswers/Answer.test.js +180 -92
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +137 -103
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +861 -463
- package/dist/components/CollectionPage/CollectionPage.js +63 -73
- package/dist/components/CollectionPage/CollectionPage.test.js +366 -316
- package/dist/components/CollectionSummary/BannerStrip.js +13 -13
- package/dist/components/CollectionSummary/BannerStrip.test.js +76 -80
- package/dist/components/CollectionSummary/CollectionSummary.js +126 -99
- package/dist/components/CollectionSummary/CollectionSummary.test.js +188 -152
- package/dist/components/CollectionSummary/Confirmation.js +12 -14
- package/dist/components/CollectionSummary/Confirmation.test.js +63 -68
- package/dist/components/CollectionSummary/RenderListView.js +52 -46
- package/dist/components/CollectionSummary/RenderListView.scss +1 -1
- package/dist/components/CollectionSummary/RenderListView.test.js +77 -78
- package/dist/components/CollectionSummary/SummaryCard.js +152 -110
- package/dist/components/CollectionSummary/SummaryCard.test.js +1018 -929
- package/dist/components/CollectionSummary/SummaryCardDetails.js +137 -94
- package/dist/components/CollectionSummary/SummaryCardDetails.scss +13 -4
- package/dist/components/CollectionSummary/SummaryCardDetails.test.js +331 -128
- package/dist/components/CollectionSummary/SummaryCardValidationContext.js +35 -30
- package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +74 -62
- package/dist/components/FormComponent/Collection.js +108 -74
- package/dist/components/FormComponent/Collection.test.js +1081 -909
- package/dist/components/FormComponent/Container.js +39 -40
- package/dist/components/FormComponent/Container.test.js +412 -312
- package/dist/components/FormComponent/FormComponent.js +72 -69
- package/dist/components/FormComponent/FormComponent.test.js +414 -353
- 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 +180 -143
- 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 +1 -1
- package/dist/components/FormRenderer/helpers/canActionProceed.test.js +15 -15
- 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 +97 -103
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +60 -62
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +78 -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 +39 -43
- package/dist/components/FormRenderer/onPageAction.test.js +208 -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 +34 -21
- package/dist/components/SummaryList/SummaryList.scss +15 -0
- package/dist/components/SummaryList/SummaryList.test.js +226 -143
- package/dist/components/SummaryList/SummaryListHeadingRow.js +4 -6
- package/dist/components/SummaryList/SummaryListHeadingRowWithAction.js +53 -0
- package/dist/components/SummaryList/SummaryListHeadingRowWithAction.scss +38 -0
- 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 +92 -49
- package/dist/components/TaskList/TaskList.scss +24 -0
- package/dist/components/TaskList/TaskList.test.js +255 -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 +80 -57
- package/dist/context/HooksContext/HooksContext.test.js +35 -26
- package/dist/context/HooksContext/index.js +4 -3
- package/dist/context/ValidationContext/ValidationContext.js +94 -43
- package/dist/context/ValidationContext/ValidationContext.test.js +68 -56
- 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 -29
- 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 +61 -58
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +108 -87
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +281 -162
- 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/getSummaryListRowForDetails.js +42 -0
- package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.test.js +56 -0
- package/dist/utils/CheckYourAnswers/index.js +1 -1
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +4 -4
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +25 -25
- package/dist/utils/CollectionPage/addCollectionPageEntry.js +2 -2
- package/dist/utils/CollectionPage/addCollectionPageEntry.test.js +5 -5
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +2 -2
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +18 -17
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +22 -12
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +38 -47
- 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/getErrorsForCollection.js +24 -24
- package/dist/utils/CollectionPage/getErrorsForCollection.test.js +22 -20
- package/dist/utils/CollectionPage/getQuickEditPage.js +31 -35
- package/dist/utils/CollectionPage/getQuickEditPage.test.js +27 -15
- package/dist/utils/CollectionPage/index.js +1 -1
- package/dist/utils/CollectionPage/mergeCollectionPages.js +43 -31
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +26 -26
- package/dist/utils/CollectionPage/removeCollectionPageEntry.js +6 -4
- package/dist/utils/CollectionPage/removeCollectionPageEntry.test.js +10 -10
- package/dist/utils/CollectionPage/setCollectionPageData.js +16 -10
- package/dist/utils/CollectionPage/setCollectionPageData.test.js +24 -24
- 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 +7 -6
- package/dist/utils/Component/elevateNestedComponents.test.js +68 -30
- package/dist/utils/Component/getComponent.js +94 -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 +72 -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 +21 -22
- 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 +6 -1
- package/dist/utils/Component/optionIsSelected.test.js +35 -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 +8 -8
- package/dist/utils/Condition/meetsAllConditions.test.js +20 -20
- package/dist/utils/Condition/meetsCondition.js +25 -16
- package/dist/utils/Condition/meetsCondition.test.js +402 -402
- 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 +30 -24
- package/dist/utils/Data/getOptions.test.js +27 -27
- 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/nestInRefdataOptions.js +16 -9
- package/dist/utils/Data/nestInRefdataOptions.test.js +16 -16
- 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/getConditionalText.js +3 -3
- package/dist/utils/FormPage/getConditionalText.test.js +29 -29
- 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/getParagraphFromText.js +7 -5
- package/dist/utils/FormPage/getParagraphFromText.test.js +6 -6
- package/dist/utils/FormPage/index.js +4 -2
- 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 -77
- 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 +78 -50
- package/dist/utils/Format/formatDataForForm.js +8 -6
- package/dist/utils/Format/formatDataForForm.test.js +16 -13
- package/dist/utils/Format/formatDataForPage.js +5 -4
- package/dist/utils/Format/formatDataForPage.test.js +25 -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 +52 -46
- package/dist/utils/Operate/getLength.js +50 -0
- package/dist/utils/Operate/getLength.test.js +89 -0
- 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 +9 -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 +27 -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 +6 -6
- 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 +4 -4
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.test.js +39 -35
- 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 +21 -18
- package/dist/utils/Validate/validateComponent.test.js +176 -166
- package/dist/utils/Validate/validateContainer.js +20 -15
- package/dist/utils/Validate/validateContainer.test.js +52 -58
- package/dist/utils/Validate/validateDate.js +21 -15
- package/dist/utils/Validate/validateDate.test.js +32 -31
- 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 +22 -19
- package/dist/utils/Validate/validatePage.test.js +203 -215
- 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 +26 -11
- package/dist/utils/Validate/validateTime.test.js +62 -16
- package/dist/utils/index.js +9 -7
- package/package.json +2 -2
- package/dist/utils/CheckYourAnswers/getComponentRowForCYA.js +0 -37
- package/dist/utils/CheckYourAnswers/getComponentRowForCYA.test.js +0 -41
|
@@ -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
|
});
|
|
@@ -18,16 +19,26 @@ var _Confirmation = _interopRequireDefault(require("./Confirmation"));
|
|
|
18
19
|
var _SummaryCard = _interopRequireDefault(require("./SummaryCard"));
|
|
19
20
|
var _SummaryCardValidationContext = _interopRequireDefault(require("./SummaryCardValidationContext"));
|
|
20
21
|
require("./CollectionSummary.scss");
|
|
21
|
-
|
|
22
|
-
function
|
|
22
|
+
var _excluded = ["isDuplicate"];
|
|
23
|
+
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); }
|
|
24
|
+
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; }
|
|
23
25
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
27
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
28
|
+
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; }
|
|
29
|
+
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; }
|
|
30
|
+
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; }
|
|
31
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
32
|
+
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); }
|
|
33
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
34
|
+
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."); }
|
|
35
|
+
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); }
|
|
36
|
+
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; }
|
|
37
|
+
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; } }
|
|
38
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } // Global imports.
|
|
26
39
|
// Local imports.
|
|
27
|
-
|
|
28
40
|
// Styles.
|
|
29
|
-
|
|
30
|
-
const DEFAULT_ADD_BUTTON_LABEL = exports.DEFAULT_ADD_BUTTON_LABEL = 'Add';
|
|
41
|
+
var DEFAULT_ADD_BUTTON_LABEL = exports.DEFAULT_ADD_BUTTON_LABEL = 'Add';
|
|
31
42
|
|
|
32
43
|
// A note about validation.
|
|
33
44
|
//
|
|
@@ -41,71 +52,80 @@ const DEFAULT_ADD_BUTTON_LABEL = exports.DEFAULT_ADD_BUTTON_LABEL = 'Add';
|
|
|
41
52
|
// errors found by the summary and allow the Summary Card to keep any Quick Edit
|
|
42
53
|
// errors local to the Quick Edit page.
|
|
43
54
|
|
|
44
|
-
|
|
55
|
+
var CollectionSummary = function CollectionSummary(_ref) {
|
|
45
56
|
var _config$confirmation, _config$confirmation2, _config$confirmation3;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
57
|
+
var config = _ref.config,
|
|
58
|
+
formData = _ref.formData,
|
|
59
|
+
onAction = _ref.onAction,
|
|
60
|
+
onChange = _ref.onChange,
|
|
61
|
+
onTopLevelChange = _ref.onTopLevelChange,
|
|
62
|
+
pages = _ref.pages;
|
|
63
|
+
var _useHooks = (0, _hooks.useHooks)(),
|
|
64
|
+
hooks = _useHooks.hooks;
|
|
65
|
+
var _useValidation = (0, _hooks.useValidation)(),
|
|
66
|
+
errors = _useValidation.errors,
|
|
67
|
+
addErrors = _useValidation.addErrors,
|
|
68
|
+
clearErrors = _useValidation.clearErrors,
|
|
69
|
+
queuedErrors = _useValidation.queuedErrors,
|
|
70
|
+
enqueueErrors = _useValidation.enqueueErrors,
|
|
71
|
+
dequeueErrors = _useValidation.dequeueErrors;
|
|
72
|
+
var _useState = (0, _react.useState)(null),
|
|
73
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
74
|
+
entryToDelete = _useState2[0],
|
|
75
|
+
setEntryToDelete = _useState2[1];
|
|
76
|
+
var data = (0, _react.useMemo)(function () {
|
|
77
|
+
return _utils.default.CollectionPage.getData(config.collectionName, formData) || [];
|
|
78
|
+
}, [formData]);
|
|
79
|
+
var toFocusOn = Array.isArray(data) && data.length > 0 ? data.reduce(function (acc, current) {
|
|
80
|
+
if (current.isDuplicate) {
|
|
81
|
+
if (!acc || current.id > acc.id) {
|
|
82
|
+
return current;
|
|
83
|
+
}
|
|
84
|
+
return acc;
|
|
85
|
+
}
|
|
86
|
+
return acc;
|
|
87
|
+
}, null) : null;
|
|
88
|
+
var masterPage = (0, _react.useMemo)(function () {
|
|
89
|
+
var collectionNameParts = config.collectionName.split('.');
|
|
90
|
+
var childPages = _utils.default.CollectionPage.mergePages(pages || []) || [];
|
|
91
|
+
return collectionNameParts.reduce(function (acc, current, index) {
|
|
71
92
|
var _childPages$find;
|
|
72
|
-
|
|
93
|
+
var currentPath = index === 0 ? "".concat(acc).concat(current) : "".concat(acc, ".").concat(current);
|
|
73
94
|
if (index === collectionNameParts.length - 1) {
|
|
74
95
|
var _childPages;
|
|
75
|
-
return ((_childPages = childPages) === null || _childPages === void 0 ? void 0 : _childPages.find(p
|
|
96
|
+
return ((_childPages = childPages) === null || _childPages === void 0 ? void 0 : _childPages.find(function (p) {
|
|
76
97
|
var _p$collection;
|
|
77
98
|
return ((_p$collection = p.collection) === null || _p$collection === void 0 ? void 0 : _p$collection.name) === currentPath;
|
|
78
99
|
})) || null;
|
|
79
100
|
}
|
|
80
|
-
childPages = ((_childPages$find = childPages.find(p
|
|
101
|
+
childPages = ((_childPages$find = childPages.find(function (p) {
|
|
81
102
|
var _p$collection2;
|
|
82
103
|
return ((_p$collection2 = p.collection) === null || _p$collection2 === void 0 ? void 0 : _p$collection2.name) === currentPath;
|
|
83
104
|
})) === null || _childPages$find === void 0 ? void 0 : _childPages$find.childPages) || null;
|
|
84
105
|
return currentPath;
|
|
85
106
|
}, "");
|
|
86
107
|
}, [pages]);
|
|
87
|
-
|
|
108
|
+
var allComponents = (0, _react.useMemo)(function () {
|
|
88
109
|
if (config.card.listView) {
|
|
89
110
|
var _masterPage$childPage;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
...formData,
|
|
93
|
-
...entryToDelete
|
|
94
|
-
});
|
|
111
|
+
var components = (_masterPage$childPage = masterPage.childPages) === null || _masterPage$childPage === void 0 ? void 0 : _masterPage$childPage.reduce(function (acc, page) {
|
|
112
|
+
var elevatedComponents = (0, _elevateNestedComponents.default)(page.components, _objectSpread(_objectSpread({}, formData), entryToDelete));
|
|
95
113
|
return acc.concat(elevatedComponents);
|
|
96
114
|
}, []);
|
|
97
115
|
return components || [];
|
|
98
116
|
}
|
|
99
117
|
return [];
|
|
100
118
|
}, [masterPage, formData, entryToDelete, config.card.listView]);
|
|
101
|
-
|
|
119
|
+
var validateEntries = function validateEntries() {
|
|
102
120
|
// We only clear queuedErrors if it's not empty to avoid
|
|
103
121
|
// triggering a race condition with the 'data' memo
|
|
104
122
|
// above.
|
|
105
123
|
if (queuedErrors.length > 0) {
|
|
106
|
-
dequeueErrors(
|
|
124
|
+
dequeueErrors(function (e) {
|
|
125
|
+
return e.raisedBy === config.id;
|
|
126
|
+
});
|
|
107
127
|
}
|
|
108
|
-
|
|
128
|
+
var allErrors = (0, _getErrorsForCollection.default)(config, masterPage, formData, hooks);
|
|
109
129
|
|
|
110
130
|
// We only queue allErrors if it's not empty to avoid
|
|
111
131
|
// triggering a race condition with the 'data' memo
|
|
@@ -114,27 +134,26 @@ const CollectionSummary = _ref => {
|
|
|
114
134
|
enqueueErrors(allErrors);
|
|
115
135
|
}
|
|
116
136
|
};
|
|
117
|
-
(0, _react.useEffect)(()
|
|
137
|
+
(0, _react.useEffect)(function () {
|
|
118
138
|
// An empty array here indicates nothing to validate, higher level validation
|
|
119
139
|
// such as 'required' is taken care of at the page level not here
|
|
120
140
|
if (Array.isArray(data) && data.length > 0) {
|
|
121
141
|
validateEntries();
|
|
122
142
|
}
|
|
123
143
|
}, [data]);
|
|
124
|
-
|
|
144
|
+
var onSummaryCardFullEdit = function onSummaryCardFullEdit(page, entryId) {
|
|
125
145
|
if (typeof onAction === 'function') {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
};
|
|
146
|
+
var newData = [].concat(data);
|
|
147
|
+
var entryIndex = data.findIndex(function (e) {
|
|
148
|
+
return e.id === entryId;
|
|
149
|
+
});
|
|
150
|
+
var _data$entryIndex = data[entryIndex],
|
|
151
|
+
isDuplicate = _data$entryIndex.isDuplicate,
|
|
152
|
+
newEntry = _objectWithoutProperties(_data$entryIndex, _excluded);
|
|
153
|
+
newData[entryIndex] = _objectSpread({}, newEntry);
|
|
135
154
|
onAction({
|
|
136
155
|
type: _PageAction.PageActionTypes.SAVE_AND_NAVIGATE,
|
|
137
|
-
page,
|
|
156
|
+
page: page,
|
|
138
157
|
addToFormData: [{
|
|
139
158
|
field: "".concat(config.collectionName.split('.').pop(), "ActiveId"),
|
|
140
159
|
value: entryId
|
|
@@ -146,12 +165,12 @@ const CollectionSummary = _ref => {
|
|
|
146
165
|
});
|
|
147
166
|
}
|
|
148
167
|
};
|
|
149
|
-
|
|
168
|
+
var onDuplicate = function onDuplicate(entry) {
|
|
150
169
|
var _config$card;
|
|
151
170
|
_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) || [], {
|
|
152
171
|
isDuplicate: true
|
|
153
172
|
});
|
|
154
|
-
|
|
173
|
+
var topLevelCollectionName = config.collectionName.split('.').shift();
|
|
155
174
|
// Report the whole top-level collection as being changed. We have to do this
|
|
156
175
|
// because of how patch is applied to formData on a page submission.
|
|
157
176
|
if (typeof onTopLevelChange === 'function') {
|
|
@@ -164,12 +183,12 @@ const CollectionSummary = _ref => {
|
|
|
164
183
|
validateEntries();
|
|
165
184
|
}
|
|
166
185
|
};
|
|
167
|
-
|
|
186
|
+
var onDeleteConfirm = function onDeleteConfirm() {
|
|
168
187
|
if (!entryToDelete) {
|
|
169
188
|
return;
|
|
170
189
|
}
|
|
171
190
|
_utils.default.CollectionPage.removeEntry(config.collectionName, formData, entryToDelete.id);
|
|
172
|
-
|
|
191
|
+
var topLevelCollectionName = config.collectionName.split('.').shift();
|
|
173
192
|
// Report the whole top-level collection as being changed. We have to do this
|
|
174
193
|
// because of how patch is applied to formData on a page submission.
|
|
175
194
|
if (typeof onTopLevelChange === 'function') {
|
|
@@ -183,16 +202,14 @@ const CollectionSummary = _ref => {
|
|
|
183
202
|
setEntryToDelete(null);
|
|
184
203
|
validateEntries();
|
|
185
204
|
};
|
|
186
|
-
|
|
187
|
-
|
|
205
|
+
var renderFieldValue = function renderFieldValue(field) {
|
|
206
|
+
var component = allComponents.find(function (c) {
|
|
207
|
+
return c.fieldId === field;
|
|
208
|
+
});
|
|
188
209
|
if (!component) return null;
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
...formData,
|
|
193
|
-
...entryToDelete
|
|
194
|
-
}
|
|
195
|
-
}, component);
|
|
210
|
+
var row = (0, _getCYARow.default)(_objectSpread(_objectSpread({}, masterPage), {}, {
|
|
211
|
+
formData: _objectSpread(_objectSpread({}, formData), entryToDelete)
|
|
212
|
+
}), component);
|
|
196
213
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
197
214
|
key: field,
|
|
198
215
|
className: "confirmation-field-value"
|
|
@@ -206,22 +223,22 @@ const CollectionSummary = _ref => {
|
|
|
206
223
|
id: config.fieldId
|
|
207
224
|
}, entryToDelete && /*#__PURE__*/_react.default.createElement(_Confirmation.default, {
|
|
208
225
|
id: "".concat(config.fieldId, ".confirmation"),
|
|
209
|
-
message: _utils.default.interpolateString((_config$confirmation = config.confirmation) === null || _config$confirmation === void 0 ? void 0 : _config$confirmation.message, {
|
|
210
|
-
...entryToDelete,
|
|
226
|
+
message: _utils.default.interpolateString((_config$confirmation = config.confirmation) === null || _config$confirmation === void 0 ? void 0 : _config$confirmation.message, _objectSpread(_objectSpread({}, entryToDelete), {}, {
|
|
211
227
|
index: entryToDelete.index + 1
|
|
212
|
-
}) || null,
|
|
228
|
+
})) || null,
|
|
213
229
|
confirmLabel: _utils.default.interpolateString((_config$confirmation2 = config.confirmation) === null || _config$confirmation2 === void 0 ? void 0 : _config$confirmation2.label, entryToDelete) || null,
|
|
214
230
|
onConfirm: onDeleteConfirm,
|
|
215
|
-
onCancel: ()
|
|
231
|
+
onCancel: function onCancel() {
|
|
232
|
+
return setEntryToDelete(null);
|
|
233
|
+
}
|
|
216
234
|
}, config.card.listView ? /*#__PURE__*/_react.default.createElement("div", {
|
|
217
235
|
className: "confirmation-content"
|
|
218
236
|
}, (_config$confirmation3 = config.confirmation) === null || _config$confirmation3 === void 0 ? void 0 : _config$confirmation3.displayFields.map(renderFieldValue)) : /*#__PURE__*/_react.default.createElement(_SummaryCard.default, {
|
|
219
237
|
id: "".concat(config.fieldId, ".confirmationChild"),
|
|
220
238
|
entryData: entryToDelete,
|
|
221
|
-
config: config.card ? {
|
|
222
|
-
...config.card,
|
|
239
|
+
config: config.card ? _objectSpread(_objectSpread({}, config.card), {}, {
|
|
223
240
|
quickEdit: null
|
|
224
|
-
} : {},
|
|
241
|
+
}) : {},
|
|
225
242
|
masterPage: masterPage,
|
|
226
243
|
classModifiers: "nested",
|
|
227
244
|
hideDetails: true
|
|
@@ -235,38 +252,40 @@ const CollectionSummary = _ref => {
|
|
|
235
252
|
classModifiers: ['secondary']
|
|
236
253
|
},
|
|
237
254
|
onAction: onAction
|
|
238
|
-
}), data.map((entry, index)
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
};
|
|
245
|
-
|
|
255
|
+
}), data.map(function (entry, index) {
|
|
256
|
+
var isInError = errors.filter(function (e) {
|
|
257
|
+
return e.entryId === entry.id;
|
|
258
|
+
}).length > 0;
|
|
259
|
+
var finalConfig = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, config.card), entry.isDuplicate && config.duplicatedCard ? config.duplicatedCard : {}), isInError && config.errorCard ? config.errorCard : {}), {}, {
|
|
260
|
+
focusOn: (toFocusOn === null || toFocusOn === void 0 ? void 0 : toFocusOn.id) === entry.id
|
|
261
|
+
});
|
|
262
|
+
var key = "".concat(config.fieldId, ".summaryCard").concat(entry.id);
|
|
246
263
|
return /*#__PURE__*/_react.default.createElement(_SummaryCardValidationContext.default, {
|
|
247
264
|
entryId: entry.id,
|
|
248
265
|
topLevelErrors: errors,
|
|
249
|
-
clearTopLevelErrorsForCard: ()
|
|
250
|
-
|
|
266
|
+
clearTopLevelErrorsForCard: function clearTopLevelErrorsForCard() {
|
|
267
|
+
var newErrors = errors.filter(function (e) {
|
|
268
|
+
return e.entryId !== entry.id;
|
|
269
|
+
});
|
|
251
270
|
clearErrors();
|
|
252
271
|
addErrors(newErrors);
|
|
253
272
|
}
|
|
254
273
|
}, /*#__PURE__*/_react.default.createElement(_SummaryCard.default, {
|
|
255
274
|
id: key,
|
|
256
275
|
key: key,
|
|
257
|
-
entryData: {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
},
|
|
276
|
+
entryData: _objectSpread(_objectSpread({}, entry), {}, {
|
|
277
|
+
index: index
|
|
278
|
+
}),
|
|
261
279
|
masterPage: masterPage,
|
|
262
280
|
config: finalConfig || {},
|
|
263
281
|
onFullEdit: onSummaryCardFullEdit,
|
|
264
282
|
onDuplicate: onDuplicate,
|
|
265
|
-
onDelete: ()
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
283
|
+
onDelete: function onDelete() {
|
|
284
|
+
return setEntryToDelete(_objectSpread(_objectSpread({}, entry), {}, {
|
|
285
|
+
index: index
|
|
286
|
+
}));
|
|
287
|
+
},
|
|
288
|
+
onQuickEdit: function onQuickEdit(target) {
|
|
270
289
|
validateEntries();
|
|
271
290
|
return onChange(target);
|
|
272
291
|
},
|
|
@@ -274,7 +293,9 @@ const CollectionSummary = _ref => {
|
|
|
274
293
|
childCollections: config.childCollections || [],
|
|
275
294
|
formData: formData,
|
|
276
295
|
classModifiers: entry.id === (entryToDelete === null || entryToDelete === void 0 ? void 0 : entryToDelete.id) ? ['deleting-summary-card'] : [''],
|
|
277
|
-
inError: errors.filter(
|
|
296
|
+
inError: errors.filter(function (e) {
|
|
297
|
+
return e.entryId === entry.id;
|
|
298
|
+
}).length > 0
|
|
278
299
|
}));
|
|
279
300
|
}), config.card.listView && config.addButton && /*#__PURE__*/_react.default.createElement(_ActionButton.default, {
|
|
280
301
|
id: "".concat(config.fieldId, ".addButton"),
|
|
@@ -283,7 +304,10 @@ const CollectionSummary = _ref => {
|
|
|
283
304
|
label: config.addButton.label || DEFAULT_ADD_BUTTON_LABEL,
|
|
284
305
|
page: config.addButton.page,
|
|
285
306
|
type: _PageAction.PageActionTypes.COLLECTION_ADD,
|
|
286
|
-
classModifiers: ['secondary']
|
|
307
|
+
classModifiers: ['secondary'],
|
|
308
|
+
customAction: {
|
|
309
|
+
type: config.addButton.customAction
|
|
310
|
+
}
|
|
287
311
|
},
|
|
288
312
|
onAction: onAction
|
|
289
313
|
}));
|
|
@@ -295,7 +319,10 @@ CollectionSummary.propTypes = {
|
|
|
295
319
|
collectionName: _propTypes.default.string.isRequired,
|
|
296
320
|
addButton: _propTypes.default.shape({
|
|
297
321
|
label: _propTypes.default.string,
|
|
298
|
-
page: _propTypes.default.string.isRequired
|
|
322
|
+
page: _propTypes.default.string.isRequired,
|
|
323
|
+
customAction: _propTypes.default.shape({
|
|
324
|
+
type: _propTypes.default.string
|
|
325
|
+
})
|
|
299
326
|
}),
|
|
300
327
|
card: _propTypes.default.shape({
|
|
301
328
|
banners: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.shape({})])),
|