@ukhomeoffice/cop-react-form-renderer 4.18.0 → 5.0.0-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CheckYourAnswers/Answer.js +1 -14
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +19 -57
- package/dist/components/CheckYourAnswers/index.js +0 -3
- package/dist/components/CollectionPage/CollectionPage.js +8 -38
- package/dist/components/CollectionPage/index.js +0 -3
- package/dist/components/FormComponent/Collection.js +13 -54
- package/dist/components/FormComponent/Container.js +6 -30
- package/dist/components/FormComponent/FormComponent.js +14 -57
- package/dist/components/FormComponent/helpers/addLabel.js +4 -7
- package/dist/components/FormComponent/helpers/getComponentDisabled.js +0 -4
- package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +0 -2
- package/dist/components/FormComponent/helpers/getComponentError.js +0 -6
- package/dist/components/FormComponent/helpers/getComponentError.test.js +0 -2
- package/dist/components/FormComponent/helpers/index.js +0 -4
- package/dist/components/FormComponent/index.js +0 -3
- package/dist/components/FormPage/FormPage.js +14 -45
- package/dist/components/FormPage/index.js +0 -3
- package/dist/components/FormRenderer/FormRenderer.js +106 -189
- package/dist/components/FormRenderer/handlers/cyaAction.js +0 -5
- package/dist/components/FormRenderer/handlers/getPageId.js +0 -2
- package/dist/components/FormRenderer/handlers/getPageId.test.js +1 -2
- package/dist/components/FormRenderer/handlers/handlers.test.js +1 -18
- package/dist/components/FormRenderer/handlers/index.js +0 -5
- package/dist/components/FormRenderer/handlers/navigate.js +0 -5
- package/dist/components/FormRenderer/handlers/submissionError.js +0 -2
- package/dist/components/FormRenderer/helpers/canActionProceed.js +0 -3
- package/dist/components/FormRenderer/helpers/canActionProceed.test.js +1 -3
- package/dist/components/FormRenderer/helpers/canCYASubmit.js +0 -2
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +1 -5
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +0 -5
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +1 -2
- package/dist/components/FormRenderer/helpers/getCYA.js +0 -6
- package/dist/components/FormRenderer/helpers/getCYA.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getFormState.js +0 -5
- package/dist/components/FormRenderer/helpers/getFormState.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getNextPageId.js +0 -25
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +1 -4
- package/dist/components/FormRenderer/helpers/getPage.js +0 -5
- package/dist/components/FormRenderer/helpers/getPage.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +0 -6
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +0 -10
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +0 -6
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +6 -20
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +3 -8
- package/dist/components/FormRenderer/helpers/index.js +1 -11
- package/dist/components/FormRenderer/index.js +0 -3
- package/dist/components/PageActions/ActionButton.js +2 -17
- package/dist/components/PageActions/PageActions.js +3 -10
- package/dist/components/PageActions/index.js +0 -3
- package/dist/components/SummaryList/GroupAction.js +3 -24
- package/dist/components/SummaryList/RowAction.js +3 -23
- package/dist/components/SummaryList/SummaryList.js +6 -28
- package/dist/components/SummaryList/SummaryListRow.js +4 -8
- package/dist/components/SummaryList/SummaryListTitleRow.js +2 -7
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +0 -3
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +0 -6
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +0 -3
- package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +0 -6
- package/dist/components/SummaryList/helpers/index.js +0 -2
- package/dist/components/SummaryList/index.js +0 -3
- package/dist/components/TaskList/Task.js +7 -29
- package/dist/components/TaskList/TaskList.js +12 -33
- package/dist/components/TaskList/TaskState.js +2 -10
- package/dist/components/TaskList/index.js +0 -3
- package/dist/components/index.js +0 -6
- package/dist/context/HooksContext/HooksContext.js +14 -34
- package/dist/context/HooksContext/index.js +0 -5
- package/dist/context/ValidationContext/ValidationContext.js +8 -34
- package/dist/context/ValidationContext/index.js +0 -5
- package/dist/context/index.js +0 -3
- package/dist/hooks/index.js +0 -9
- package/dist/hooks/useAxios.js +8 -25
- package/dist/hooks/useGetRequest.js +13 -47
- package/dist/hooks/useHooks.js +2 -4
- package/dist/hooks/useRefData.js +8 -37
- package/dist/hooks/useValidation.js +2 -4
- package/dist/index.js +0 -6
- package/dist/models/PageAction.js +0 -3
- package/dist/models/TaskStates.js +0 -3
- package/dist/models/index.js +0 -9
- package/dist/utils/CheckYourAnswers/getCYAAction.js +1 -9
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +0 -10
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +0 -8
- package/dist/utils/CheckYourAnswers/getCYARow.js +1 -10
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +2 -20
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +0 -18
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +0 -20
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +0 -13
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +2 -22
- package/dist/utils/CheckYourAnswers/index.js +1 -3
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +2 -11
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +0 -11
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +0 -6
- package/dist/utils/CollectionPage/index.js +1 -5
- package/dist/utils/CollectionPage/mergeCollectionPages.js +1 -12
- package/dist/utils/Component/cleanAttributes.js +1 -8
- package/dist/utils/Component/elevateNestedComponents.js +0 -3
- package/dist/utils/Component/getComponent.js +4 -68
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +6 -10
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +10 -28
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +6 -33
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +10 -27
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +4 -10
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +4 -21
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +4 -22
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +3 -7
- package/dist/utils/Component/getComponentTests/getComponent.html.test.js +4 -10
- package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +3 -7
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +6 -15
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +4 -21
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +6 -33
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +4 -21
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +4 -21
- package/dist/utils/Component/getComponentTests/getComponent.textarea.test.js +4 -21
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +10 -29
- package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +1 -2
- package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +3 -7
- package/dist/utils/Component/getDefaultValue.js +0 -7
- package/dist/utils/Component/index.js +0 -9
- package/dist/utils/Component/isEditable.js +1 -4
- package/dist/utils/Component/showComponent.js +1 -8
- package/dist/utils/Component/wrapInFormGroup.js +0 -7
- package/dist/utils/Condition/index.js +0 -5
- package/dist/utils/Condition/meetsAllConditions.js +0 -9
- package/dist/utils/Condition/meetsCondition.js +7 -19
- package/dist/utils/Condition/meetsOneCondition.js +1 -9
- package/dist/utils/Condition/setupConditions.js +0 -12
- package/dist/utils/Container/getEditableComponents.js +0 -7
- package/dist/utils/Container/index.js +0 -5
- package/dist/utils/Container/setupNesting.js +0 -11
- package/dist/utils/Container/showContainer.js +9 -18
- package/dist/utils/Data/applyFormula.js +2 -28
- package/dist/utils/Data/getAutocompleteSource.js +1 -4
- package/dist/utils/Data/getDataPath.js +3 -17
- package/dist/utils/Data/getOptions.js +0 -9
- package/dist/utils/Data/getSourceData.js +4 -19
- package/dist/utils/Data/index.js +1 -11
- package/dist/utils/Data/refDataToOptions.js +1 -12
- package/dist/utils/Data/setDataItem.js +0 -5
- package/dist/utils/Data/setupFormData.js +2 -20
- package/dist/utils/Data/setupRefDataUrlForComponent.js +0 -14
- package/dist/utils/FormPage/getFormPage.js +0 -15
- package/dist/utils/FormPage/getFormPages.js +0 -8
- package/dist/utils/FormPage/getPageActions.js +3 -18
- package/dist/utils/FormPage/getParagraphFromText.js +0 -3
- package/dist/utils/FormPage/index.js +0 -6
- package/dist/utils/FormPage/showFormPage.js +9 -18
- package/dist/utils/FormPage/showFormPageCYA.js +0 -5
- package/dist/utils/FormPage/useComponent.js +3 -18
- package/dist/utils/Format/formatData.js +0 -5
- package/dist/utils/Format/formatDataForComponent.js +1 -6
- package/dist/utils/Format/formatDataForForm.js +0 -8
- package/dist/utils/Format/formatDataForPage.js +1 -5
- package/dist/utils/Format/index.js +1 -6
- package/dist/utils/Hub/getFormHub.js +0 -8
- package/dist/utils/Hub/index.js +1 -3
- package/dist/utils/Meta/documents/getDocuments.js +1 -4
- package/dist/utils/Meta/documents/getDocuments.test.js +0 -9
- package/dist/utils/Meta/documents/index.js +1 -5
- package/dist/utils/Meta/documents/setDocumentForField.js +0 -11
- package/dist/utils/Meta/documents/setDocumentForField.test.js +0 -11
- package/dist/utils/Meta/index.js +2 -6
- package/dist/utils/Operate/checkValueIsTruthy.js +1 -7
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +7 -21
- package/dist/utils/Operate/index.js +0 -3
- package/dist/utils/Operate/persistValueInFormData.js +1 -8
- package/dist/utils/Operate/runPageOperations.js +3 -18
- package/dist/utils/Operate/setValueInFormData.js +2 -7
- package/dist/utils/Operate/shouldRun.js +1 -14
- package/dist/utils/Validate/additional/index.js +1 -18
- package/dist/utils/Validate/additional/index.test.js +0 -6
- package/dist/utils/Validate/additional/mustBeAfter.js +3 -8
- package/dist/utils/Validate/additional/mustBeAfter.test.js +0 -4
- package/dist/utils/Validate/additional/mustBeBefore.js +3 -8
- package/dist/utils/Validate/additional/mustBeBefore.test.js +0 -4
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +5 -16
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +0 -7
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +3 -12
- package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +0 -3
- package/dist/utils/Validate/additional/mustBeInThePast.js +5 -13
- package/dist/utils/Validate/additional/mustBeInThePast.test.js +0 -3
- package/dist/utils/Validate/additional/mustBeLessThan.js +0 -3
- package/dist/utils/Validate/additional/mustBeLessThan.test.js +0 -2
- package/dist/utils/Validate/additional/mustBeLongerThan.js +0 -3
- package/dist/utils/Validate/additional/mustBeLongerThan.test.js +0 -2
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +0 -4
- package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +0 -2
- package/dist/utils/Validate/additional/mustBeShorterThan.js +0 -3
- package/dist/utils/Validate/additional/mustBeShorterThan.test.js +0 -2
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +0 -5
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +0 -4
- package/dist/utils/Validate/additional/utils.js +8 -24
- package/dist/utils/Validate/index.js +1 -9
- package/dist/utils/Validate/validateCollection.js +0 -9
- package/dist/utils/Validate/validateComponent.js +2 -35
- package/dist/utils/Validate/validateContainer.js +0 -13
- package/dist/utils/Validate/validateDate.js +4 -36
- package/dist/utils/Validate/validateEmail.js +1 -7
- package/dist/utils/Validate/validatePage.js +0 -15
- package/dist/utils/Validate/validateRegex.js +0 -10
- package/dist/utils/Validate/validateRequired.js +0 -8
- package/dist/utils/Validate/validateTime.js +3 -20
- package/dist/utils/index.js +0 -19
- package/package.json +50 -34
- package/dist/components/CheckYourAnswers/Answer.test.js +0 -95
- package/dist/components/CheckYourAnswers/CheckYourAnswers.stories.mdx +0 -410
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +0 -680
- package/dist/components/CollectionPage/CollectionPage.test.js +0 -428
- package/dist/components/FormComponent/Collection.test.js +0 -381
- package/dist/components/FormComponent/Container.test.js +0 -423
- package/dist/components/FormComponent/FormComponent.stories.mdx +0 -184
- package/dist/components/FormComponent/FormComponent.test.js +0 -264
- package/dist/components/FormPage/FormPage.stories.mdx +0 -131
- package/dist/components/FormPage/FormPage.test.js +0 -368
- package/dist/components/FormRenderer/FormRenderer.stories.mdx +0 -183
- package/dist/components/FormRenderer/FormRenderer.test.js +0 -1006
- package/dist/components/PageActions/ActionButton.test.js +0 -116
- package/dist/components/PageActions/PageActions.stories.mdx +0 -74
- package/dist/components/PageActions/PageActions.test.js +0 -157
- package/dist/components/SummaryList/GroupAction.test.js +0 -94
- package/dist/components/SummaryList/RowAction.test.js +0 -94
- package/dist/components/SummaryList/SummaryList.stories.mdx +0 -90
- package/dist/components/SummaryList/SummaryList.test.js +0 -361
- package/dist/components/TaskList/Task.test.js +0 -194
- package/dist/components/TaskList/TaskList.stories.mdx +0 -164
- package/dist/components/TaskList/TaskList.test.js +0 -334
- package/dist/components/TaskList/TaskState.test.js +0 -104
- package/dist/context/HooksContext/HooksContext.test.js +0 -60
- package/dist/context/ValidationContext/ValidationContext.test.js +0 -98
- package/dist/json/areYouACivilServant.json +0 -7
- package/dist/json/firstForm.json +0 -94
- package/dist/json/grade.json +0 -108
- package/dist/json/group.data.json +0 -21
- package/dist/json/group.json +0 -402
- package/dist/json/groupOfRow.json +0 -137
- package/dist/json/groupOfRowData.json +0 -15
- package/dist/json/port.json +0 -346
- package/dist/json/saveAndContinue.json +0 -98
- package/dist/json/sublocation.json +0 -859
- package/dist/json/taskList.json +0 -265
- package/dist/json/team.json +0 -17351
- package/dist/json/terminal.json +0 -81
- package/dist/json/userProfile.data.json +0 -21
- package/dist/json/userProfile.json +0 -276
- package/dist/setupTests.js +0 -59
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +0 -139
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +0 -76
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +0 -59
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +0 -256
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +0 -77
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +0 -199
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +0 -170
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +0 -323
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +0 -281
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +0 -64
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +0 -41
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +0 -54
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +0 -131
- package/dist/utils/Component/cleanAttributes.test.js +0 -69
- package/dist/utils/Component/elevateNestedComponents.test.js +0 -92
- package/dist/utils/Component/getDefaultValue.test.js +0 -53
- package/dist/utils/Component/isEditable.test.js +0 -42
- package/dist/utils/Component/showComponent.test.js +0 -157
- package/dist/utils/Condition/meetsAllConditions.test.js +0 -62
- package/dist/utils/Condition/meetsCondition.test.js +0 -391
- package/dist/utils/Condition/meetsOneCondition.test.js +0 -101
- package/dist/utils/Condition/setupConditions.test.js +0 -35
- package/dist/utils/Container/getEditableComponents.test.js +0 -146
- package/dist/utils/Container/setupNesting.test.js +0 -92
- package/dist/utils/Container/showContainer.test.js +0 -179
- package/dist/utils/Data/applyFormula.test.js +0 -264
- package/dist/utils/Data/getAutocompleteSource.test.js +0 -146
- package/dist/utils/Data/getDataPath.test.js +0 -52
- package/dist/utils/Data/getOptions.test.js +0 -71
- package/dist/utils/Data/getSourceData.test.js +0 -141
- package/dist/utils/Data/refDataToOptions.test.js +0 -197
- package/dist/utils/Data/setDataItem.test.js +0 -112
- package/dist/utils/Data/setupFormData.test.js +0 -276
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +0 -133
- package/dist/utils/FormPage/getFormPage.test.js +0 -205
- package/dist/utils/FormPage/getFormPages.test.js +0 -98
- package/dist/utils/FormPage/getPageActions.test.js +0 -89
- package/dist/utils/FormPage/getParagraphFromText.test.js +0 -29
- package/dist/utils/FormPage/showFormPage.test.js +0 -182
- package/dist/utils/FormPage/showFormPageCYA.test.js +0 -30
- package/dist/utils/FormPage/useComponent.test.js +0 -169
- package/dist/utils/Format/formatData.test.js +0 -46
- package/dist/utils/Format/formatDataForComponent.test.js +0 -161
- package/dist/utils/Format/formatDataForForm.test.js +0 -78
- package/dist/utils/Format/formatDataForPage.test.js +0 -96
- package/dist/utils/Hub/getFormHub.test.js +0 -107
- package/dist/utils/Operate/checkValueIsTruthy.test.js +0 -44
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +0 -159
- package/dist/utils/Operate/persistValueInFormData.test.js +0 -106
- package/dist/utils/Operate/runPageOperations.test.js +0 -107
- package/dist/utils/Operate/setValueInFormData.test.js +0 -46
- package/dist/utils/Operate/shouldRun.test.js +0 -69
- package/dist/utils/Validate/validateCollection.test.js +0 -74
- package/dist/utils/Validate/validateComponent.test.js +0 -267
- package/dist/utils/Validate/validateContainer.test.js +0 -81
- package/dist/utils/Validate/validateDate.test.js +0 -118
- package/dist/utils/Validate/validateEmail.test.js +0 -57
- package/dist/utils/Validate/validatePage.test.js +0 -383
- package/dist/utils/Validate/validateRegex.test.js +0 -41
- package/dist/utils/Validate/validateRequired.test.js +0 -62
- package/dist/utils/Validate/validateTime.test.js +0 -61
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ukhomeoffice/cop-react-form-renderer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0-alpha",
|
|
4
4
|
"private": false,
|
|
5
5
|
"scripts": {
|
|
6
6
|
"clean": "rimraf dist",
|
|
7
|
-
"test": "
|
|
8
|
-
"test:coverage": "
|
|
7
|
+
"test": "jest test",
|
|
8
|
+
"test:coverage": "jest test --coverage --watchAll=false",
|
|
9
9
|
"lint": "eslint --ext .js,.jsx src",
|
|
10
10
|
"storybook:start": "start-storybook --docs -s src/assets --no-manager-cache -p 6007",
|
|
11
11
|
"storybook:build": "build-storybook --docs -s src/assets",
|
|
@@ -13,52 +13,68 @@
|
|
|
13
13
|
"storybook": "yarn storybook:start",
|
|
14
14
|
"deploy-storybook": "storybook-to-ghpages -e storybook-static",
|
|
15
15
|
"compile": "yarn clean && cross-env NODE_ENV=production babel src --out-dir dist --copy-files && yarn post-compile",
|
|
16
|
-
"post-compile": "
|
|
16
|
+
"post-compile": "yarn remove-tests && yarn remove-stories && yarn remove-assets",
|
|
17
|
+
"remove-tests": "rimraf dist/*.test.* dist/**/*.test.* dist/**/**/*.test.* dist/setupTests.js",
|
|
18
|
+
"remove-stories": "rimraf dist/*.stories.* dist/**/*.stories.* dist/**/**/*.stories.*",
|
|
19
|
+
"remove-assets": "rimraf dist/json dist/assets"
|
|
17
20
|
},
|
|
18
21
|
"dependencies": {
|
|
19
|
-
"@ukhomeoffice/cop-react-components": "
|
|
22
|
+
"@ukhomeoffice/cop-react-components": "3.0.0-charlie",
|
|
20
23
|
"axios": "^0.23.0",
|
|
21
24
|
"dayjs": "^1.11.0",
|
|
22
25
|
"govuk-frontend": "^4.3.1",
|
|
23
26
|
"web-vitals": "^1.0.1"
|
|
24
27
|
},
|
|
25
28
|
"devDependencies": {
|
|
26
|
-
"@babel/cli": "^7.
|
|
27
|
-
"@babel/
|
|
28
|
-
"@babel/preset-
|
|
29
|
+
"@babel/cli": "^7.19.3",
|
|
30
|
+
"@babel/eslint-parser": "^7.19.1",
|
|
31
|
+
"@babel/preset-env": "^7.19.4",
|
|
32
|
+
"@babel/preset-react": "^7.18.6",
|
|
29
33
|
"@monaco-editor/react": "^4.3.1",
|
|
30
|
-
"@storybook/addon-a11y": "^6.
|
|
31
|
-
"@storybook/addon-actions": "^6.
|
|
32
|
-
"@storybook/addon-docs": "^6.
|
|
33
|
-
"@storybook/addon-essentials": "^6.
|
|
34
|
-
"@storybook/addon-knobs": "^6.
|
|
35
|
-
"@storybook/addon-links": "^6.
|
|
36
|
-
"@storybook/
|
|
37
|
-
"@storybook/
|
|
38
|
-
"@storybook/
|
|
34
|
+
"@storybook/addon-a11y": "^6.5.13",
|
|
35
|
+
"@storybook/addon-actions": "^6.5.13",
|
|
36
|
+
"@storybook/addon-docs": "^6.5.13",
|
|
37
|
+
"@storybook/addon-essentials": "^6.5.13",
|
|
38
|
+
"@storybook/addon-knobs": "^6.4.0",
|
|
39
|
+
"@storybook/addon-links": "^6.5.13",
|
|
40
|
+
"@storybook/builder-webpack5": "^6.5.13",
|
|
41
|
+
"@storybook/manager-webpack5": "^6.5.13",
|
|
42
|
+
"@storybook/node-logger": "^6.5.13",
|
|
43
|
+
"@storybook/preset-create-react-app": "^4.1.2",
|
|
44
|
+
"@storybook/react": "^6.5.13",
|
|
39
45
|
"@storybook/storybook-deployer": "^2.8.10",
|
|
40
|
-
"@storybook/theming": "^6.
|
|
41
|
-
"@testing-library/jest-dom": "^5.
|
|
42
|
-
"@testing-library/react": "^
|
|
43
|
-
"@testing-library/react-hooks": "^
|
|
44
|
-
"@testing-library/user-event": "^
|
|
46
|
+
"@storybook/theming": "^6.5.13",
|
|
47
|
+
"@testing-library/jest-dom": "^5.14.1",
|
|
48
|
+
"@testing-library/react": "^12.1.2",
|
|
49
|
+
"@testing-library/react-hooks": "^8.0.1",
|
|
50
|
+
"@testing-library/user-event": "^13.5.0",
|
|
45
51
|
"axios-mock-adapter": "^1.18.1",
|
|
52
|
+
"babel-loader": "^8.2.3",
|
|
46
53
|
"cross-env": "^7.0.3",
|
|
54
|
+
"eslint": "^7.18.0",
|
|
55
|
+
"eslint-config-airbnb": "^18.2.1",
|
|
56
|
+
"eslint-plugin-babel": "^5.3.1",
|
|
57
|
+
"eslint-plugin-cypress": "^2.11.2",
|
|
58
|
+
"eslint-plugin-filenames": "^1.3.2",
|
|
59
|
+
"eslint-plugin-import": "^2.22.1",
|
|
60
|
+
"eslint-plugin-jest": "^24.1.3",
|
|
61
|
+
"eslint-plugin-jsx-a11y": "^6.4.1",
|
|
62
|
+
"eslint-plugin-react": "^7.22.0",
|
|
63
|
+
"eslint-plugin-react-hooks": "^4.2.0",
|
|
47
64
|
"html-react-parser": "^0.10.5",
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"react
|
|
51
|
-
"react-
|
|
52
|
-
"
|
|
65
|
+
"jest": "^27.3.1",
|
|
66
|
+
"sass": "^1.32.2",
|
|
67
|
+
"react": "^17.0.1",
|
|
68
|
+
"react-dom": "^17.0.1",
|
|
69
|
+
"react-scripts": "^5.0.1",
|
|
70
|
+
"react-test-renderer": "^17.0.2",
|
|
71
|
+
"storybook-addon-mock": "^2.0.1",
|
|
72
|
+
"webpack": "^5.74.0",
|
|
73
|
+
"webpack-cli": "^4.10.0"
|
|
53
74
|
},
|
|
54
75
|
"peerDependencies": {
|
|
55
|
-
"react": "
|
|
56
|
-
"react-dom": "
|
|
57
|
-
"react-scripts": "4.0.3"
|
|
58
|
-
},
|
|
59
|
-
"optionalDependencies": {
|
|
60
|
-
"babel-loader": "8.1.0",
|
|
61
|
-
"webpack": "4.44.2"
|
|
76
|
+
"react": ">=17.0.1",
|
|
77
|
+
"react-dom": ">=17.0.1"
|
|
62
78
|
},
|
|
63
79
|
"main": "dist/index.js",
|
|
64
80
|
"files": [
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _Readonly = require("@ukhomeoffice/cop-react-components/dist/Readonly");
|
|
4
|
-
|
|
5
|
-
var _react = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
|
-
var _setupTests = require("../../setupTests");
|
|
8
|
-
|
|
9
|
-
var _Answer = _interopRequireDefault(require("./Answer"));
|
|
10
|
-
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
|
|
13
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
14
|
-
|
|
15
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
16
|
-
|
|
17
|
-
describe('components', function () {
|
|
18
|
-
describe('CheckYourAnswers.Answer', function () {
|
|
19
|
-
it('should handle a null value', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
20
|
-
var VALUE, COMPONENT, _renderWithValidation, container;
|
|
21
|
-
|
|
22
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
23
|
-
while (1) {
|
|
24
|
-
switch (_context.prev = _context.next) {
|
|
25
|
-
case 0:
|
|
26
|
-
VALUE = null;
|
|
27
|
-
COMPONENT = null;
|
|
28
|
-
_renderWithValidation = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_Answer.default, {
|
|
29
|
-
value: VALUE,
|
|
30
|
-
component: COMPONENT
|
|
31
|
-
})), container = _renderWithValidation.container;
|
|
32
|
-
expect(container.childNodes.length).toEqual(1);
|
|
33
|
-
expect(container.childNodes[0].textContent).toEqual('No answer');
|
|
34
|
-
|
|
35
|
-
case 5:
|
|
36
|
-
case "end":
|
|
37
|
-
return _context.stop();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}, _callee);
|
|
41
|
-
})));
|
|
42
|
-
it('should handle a null component', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
43
|
-
var VALUE, COMPONENT, _renderWithValidation2, container;
|
|
44
|
-
|
|
45
|
-
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
46
|
-
while (1) {
|
|
47
|
-
switch (_context2.prev = _context2.next) {
|
|
48
|
-
case 0:
|
|
49
|
-
VALUE = 'Alpha';
|
|
50
|
-
COMPONENT = null;
|
|
51
|
-
_renderWithValidation2 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_Answer.default, {
|
|
52
|
-
value: VALUE,
|
|
53
|
-
component: COMPONENT
|
|
54
|
-
})), container = _renderWithValidation2.container;
|
|
55
|
-
expect(container.textContent).toEqual(VALUE);
|
|
56
|
-
|
|
57
|
-
case 4:
|
|
58
|
-
case "end":
|
|
59
|
-
return _context2.stop();
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}, _callee2);
|
|
63
|
-
})));
|
|
64
|
-
it('should handle a component', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
|
|
65
|
-
var VALUE, COMPONENT, _renderWithValidation3, container, answer;
|
|
66
|
-
|
|
67
|
-
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
68
|
-
while (1) {
|
|
69
|
-
switch (_context3.prev = _context3.next) {
|
|
70
|
-
case 0:
|
|
71
|
-
VALUE = 'Bravo';
|
|
72
|
-
COMPONENT = {
|
|
73
|
-
id: 'alpha',
|
|
74
|
-
fieldId: 'alpha',
|
|
75
|
-
type: 'text',
|
|
76
|
-
label: 'Alpha'
|
|
77
|
-
};
|
|
78
|
-
_renderWithValidation3 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_Answer.default, {
|
|
79
|
-
value: VALUE,
|
|
80
|
-
component: COMPONENT
|
|
81
|
-
})), container = _renderWithValidation3.container;
|
|
82
|
-
answer = container.childNodes[0];
|
|
83
|
-
expect(answer.tagName).toEqual('DIV');
|
|
84
|
-
expect(answer.classList).toContain(_Readonly.DEFAULT_CLASS);
|
|
85
|
-
expect(answer.textContent).toEqual(VALUE);
|
|
86
|
-
|
|
87
|
-
case 7:
|
|
88
|
-
case "end":
|
|
89
|
-
return _context3.stop();
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}, _callee3);
|
|
93
|
-
})));
|
|
94
|
-
});
|
|
95
|
-
});
|
|
@@ -1,410 +0,0 @@
|
|
|
1
|
-
<!-- Global imports -->
|
|
2
|
-
|
|
3
|
-
import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs';
|
|
4
|
-
import { Details, Heading, Link, Tag } from '@ukhomeoffice/cop-react-components';
|
|
5
|
-
import withMock from 'storybook-addon-mock';
|
|
6
|
-
|
|
7
|
-
<!-- Local imports -->
|
|
8
|
-
import { HooksContextProvider, ValidationContextProvider } from '../../context';
|
|
9
|
-
import Utils from '../../utils';
|
|
10
|
-
import CheckYourAnswers from './CheckYourAnswers';
|
|
11
|
-
|
|
12
|
-
<!-- JSON documents -->
|
|
13
|
-
import CIVIL_SERVANT from '../../json/areYouACivilServant.json';
|
|
14
|
-
import GRADE from '../../json/grade.json';
|
|
15
|
-
import TEAMS from '../../json/team.json';
|
|
16
|
-
import USER_PROFILE_DATA from '../../json/userProfile.data.json';
|
|
17
|
-
import USER_PROFILE from '../../json/userProfile.json';
|
|
18
|
-
import FIRST_FORM from '../../json/firstForm.json';
|
|
19
|
-
import GROUP_OF_ROW from '../../json/groupOfRow.json';
|
|
20
|
-
import GROUP_OF_ROW_DATA from '../../json/groupOfRowData.json';
|
|
21
|
-
import GROUP from'../../json/group.json';
|
|
22
|
-
import GROUP_DATA from '../../json/group.data.json';
|
|
23
|
-
|
|
24
|
-
<Meta
|
|
25
|
-
title='Components/Check your answers'
|
|
26
|
-
id='D-CheckYourAnswers'
|
|
27
|
-
component={CheckYourAnswers}
|
|
28
|
-
decorators={[withMock]}
|
|
29
|
-
/>
|
|
30
|
-
|
|
31
|
-
<Heading size='xl' caption='Components'>
|
|
32
|
-
Check your answers
|
|
33
|
-
</Heading>
|
|
34
|
-
|
|
35
|
-
Renders the **Check your answers** screen for a form.
|
|
36
|
-
|
|
37
|
-
<Canvas withToolbar>
|
|
38
|
-
<Story
|
|
39
|
-
name='Default'
|
|
40
|
-
parameters={{
|
|
41
|
-
mockData: [
|
|
42
|
-
{
|
|
43
|
-
url: `${USER_PROFILE_DATA.urls.refData}/areYouACivilServant`,
|
|
44
|
-
method: 'GET',
|
|
45
|
-
status: 200,
|
|
46
|
-
response: CIVIL_SERVANT,
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
url: `${USER_PROFILE_DATA.urls.refData}/grade`,
|
|
50
|
-
method: 'GET',
|
|
51
|
-
status: 200,
|
|
52
|
-
response: GRADE,
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
url: `${USER_PROFILE_DATA.urls.refData}/team`,
|
|
56
|
-
method: 'GET',
|
|
57
|
-
status: 200,
|
|
58
|
-
response: TEAMS,
|
|
59
|
-
},
|
|
60
|
-
],
|
|
61
|
-
}}
|
|
62
|
-
>
|
|
63
|
-
{() => {
|
|
64
|
-
const DATA = Utils.Data.setupForm(
|
|
65
|
-
USER_PROFILE.pages,
|
|
66
|
-
USER_PROFILE.components,
|
|
67
|
-
USER_PROFILE_DATA
|
|
68
|
-
);
|
|
69
|
-
const PAGES = Utils.FormPage.getAll(
|
|
70
|
-
USER_PROFILE.pages,
|
|
71
|
-
USER_PROFILE.components,
|
|
72
|
-
{ ...DATA }
|
|
73
|
-
);
|
|
74
|
-
const ON_ACTION = (action, patch, onError) => {
|
|
75
|
-
console.log('action invoked', action, patch);
|
|
76
|
-
};
|
|
77
|
-
const ON_ROW_ACTION = (page) => {
|
|
78
|
-
console.log('row action invoked', page);
|
|
79
|
-
};
|
|
80
|
-
return (
|
|
81
|
-
<HooksContextProvider>
|
|
82
|
-
<ValidationContextProvider>
|
|
83
|
-
<CheckYourAnswers
|
|
84
|
-
pages={PAGES}
|
|
85
|
-
onAction={ON_ACTION}
|
|
86
|
-
onRowAction={ON_ROW_ACTION}
|
|
87
|
-
/>
|
|
88
|
-
</ValidationContextProvider>
|
|
89
|
-
</HooksContextProvider>
|
|
90
|
-
);
|
|
91
|
-
}}
|
|
92
|
-
</Story>
|
|
93
|
-
</Canvas>
|
|
94
|
-
|
|
95
|
-
<Details summary='Properties' className='no-indent'>
|
|
96
|
-
<ArgsTable of={CheckYourAnswers} />
|
|
97
|
-
</Details>
|
|
98
|
-
|
|
99
|
-
## Variant
|
|
100
|
-
|
|
101
|
-
### Without page titles
|
|
102
|
-
|
|
103
|
-
<Canvas>
|
|
104
|
-
<Story
|
|
105
|
-
name='No page titles'
|
|
106
|
-
parameters={{
|
|
107
|
-
mockData: [
|
|
108
|
-
{
|
|
109
|
-
url: `${USER_PROFILE_DATA.urls.refData}/areYouACivilServant`,
|
|
110
|
-
method: 'GET',
|
|
111
|
-
status: 200,
|
|
112
|
-
response: CIVIL_SERVANT,
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
url: `${USER_PROFILE_DATA.urls.refData}/grade`,
|
|
116
|
-
method: 'GET',
|
|
117
|
-
status: 200,
|
|
118
|
-
response: GRADE,
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
url: `${USER_PROFILE_DATA.urls.refData}/team`,
|
|
122
|
-
method: 'GET',
|
|
123
|
-
status: 200,
|
|
124
|
-
response: TEAMS,
|
|
125
|
-
},
|
|
126
|
-
],
|
|
127
|
-
}}
|
|
128
|
-
>
|
|
129
|
-
{() => {
|
|
130
|
-
const DATA = Utils.Data.setupForm(
|
|
131
|
-
USER_PROFILE.pages,
|
|
132
|
-
USER_PROFILE.components,
|
|
133
|
-
USER_PROFILE_DATA
|
|
134
|
-
);
|
|
135
|
-
const PAGES = Utils.FormPage.getAll(
|
|
136
|
-
USER_PROFILE.pages,
|
|
137
|
-
USER_PROFILE.components,
|
|
138
|
-
{ ...DATA }
|
|
139
|
-
);
|
|
140
|
-
const ON_ACTION = (action, patch, onError) => {
|
|
141
|
-
console.log('action invoked', action, patch);
|
|
142
|
-
};
|
|
143
|
-
const ON_ROW_ACTION = (page) => {
|
|
144
|
-
console.log('row action invoked', page);
|
|
145
|
-
};
|
|
146
|
-
return (
|
|
147
|
-
<HooksContextProvider>
|
|
148
|
-
<ValidationContextProvider>
|
|
149
|
-
<CheckYourAnswers
|
|
150
|
-
pages={PAGES}
|
|
151
|
-
hide_page_titles={true}
|
|
152
|
-
onAction={ON_ACTION}
|
|
153
|
-
onRowAction={ON_ROW_ACTION}
|
|
154
|
-
/>
|
|
155
|
-
</ValidationContextProvider>
|
|
156
|
-
</HooksContextProvider>
|
|
157
|
-
);
|
|
158
|
-
}}
|
|
159
|
-
</Story>
|
|
160
|
-
</Canvas>
|
|
161
|
-
|
|
162
|
-
### With actions
|
|
163
|
-
|
|
164
|
-
<Canvas>
|
|
165
|
-
<Story
|
|
166
|
-
name='With actions'
|
|
167
|
-
parameters={{
|
|
168
|
-
mockData: [
|
|
169
|
-
{
|
|
170
|
-
url: `${USER_PROFILE_DATA.urls.refData}/areYouACivilServant`,
|
|
171
|
-
method: 'GET',
|
|
172
|
-
status: 200,
|
|
173
|
-
response: CIVIL_SERVANT,
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
url: `${USER_PROFILE_DATA.urls.refData}/grade`,
|
|
177
|
-
method: 'GET',
|
|
178
|
-
status: 200,
|
|
179
|
-
response: GRADE,
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
url: `${USER_PROFILE_DATA.urls.refData}/team`,
|
|
183
|
-
method: 'GET',
|
|
184
|
-
status: 200,
|
|
185
|
-
response: TEAMS,
|
|
186
|
-
},
|
|
187
|
-
],
|
|
188
|
-
}}
|
|
189
|
-
>
|
|
190
|
-
{() => {
|
|
191
|
-
const DATA = { firstName: 'John', surname: 'Smith', age: 41 };
|
|
192
|
-
const PAGES = Utils.FormPage.getAll(
|
|
193
|
-
FIRST_FORM.pages,
|
|
194
|
-
FIRST_FORM.components,
|
|
195
|
-
{ ...DATA }
|
|
196
|
-
);
|
|
197
|
-
const ACTIONS = FIRST_FORM.cya.actions;
|
|
198
|
-
const ON_ACTION = (action, patch, onError) => {
|
|
199
|
-
console.log('action invoked', action, patch);
|
|
200
|
-
};
|
|
201
|
-
const ON_ROW_ACTION = (page) => {
|
|
202
|
-
console.log('row action invoked', page);
|
|
203
|
-
};
|
|
204
|
-
return (
|
|
205
|
-
<HooksContextProvider>
|
|
206
|
-
<ValidationContextProvider>
|
|
207
|
-
<CheckYourAnswers
|
|
208
|
-
pages={PAGES}
|
|
209
|
-
hide_page_titles={true}
|
|
210
|
-
actions={ACTIONS}
|
|
211
|
-
onAction={ON_ACTION}
|
|
212
|
-
onRowAction={ON_ROW_ACTION}
|
|
213
|
-
/>
|
|
214
|
-
</ValidationContextProvider>
|
|
215
|
-
</HooksContextProvider>
|
|
216
|
-
);
|
|
217
|
-
}}
|
|
218
|
-
</Story>
|
|
219
|
-
</Canvas>
|
|
220
|
-
|
|
221
|
-
### Read-only style
|
|
222
|
-
|
|
223
|
-
<Canvas>
|
|
224
|
-
<Story
|
|
225
|
-
name='Read-only style'
|
|
226
|
-
parameters={{
|
|
227
|
-
mockData: [
|
|
228
|
-
{
|
|
229
|
-
url: `${USER_PROFILE_DATA.urls.refData}/areYouACivilServant`,
|
|
230
|
-
method: 'GET',
|
|
231
|
-
status: 200,
|
|
232
|
-
response: CIVIL_SERVANT,
|
|
233
|
-
},
|
|
234
|
-
{
|
|
235
|
-
url: `${USER_PROFILE_DATA.urls.refData}/grade`,
|
|
236
|
-
method: 'GET',
|
|
237
|
-
status: 200,
|
|
238
|
-
response: GRADE,
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
url: `${USER_PROFILE_DATA.urls.refData}/team`,
|
|
242
|
-
method: 'GET',
|
|
243
|
-
status: 200,
|
|
244
|
-
response: TEAMS,
|
|
245
|
-
},
|
|
246
|
-
],
|
|
247
|
-
}}
|
|
248
|
-
>
|
|
249
|
-
{() => {
|
|
250
|
-
const DATA = Utils.Data.setupForm(
|
|
251
|
-
USER_PROFILE.pages,
|
|
252
|
-
USER_PROFILE.components,
|
|
253
|
-
USER_PROFILE_DATA
|
|
254
|
-
);
|
|
255
|
-
const PAGES = Utils.FormPage.getAll(
|
|
256
|
-
USER_PROFILE.pages,
|
|
257
|
-
USER_PROFILE.components,
|
|
258
|
-
{ ...DATA }
|
|
259
|
-
);
|
|
260
|
-
const ON_ACTION = (action, patch, onError) => {
|
|
261
|
-
console.log('action invoked', action, patch);
|
|
262
|
-
};
|
|
263
|
-
const ON_ROW_ACTION = (page) => {
|
|
264
|
-
console.log('row action invoked', page);
|
|
265
|
-
};
|
|
266
|
-
return (
|
|
267
|
-
<HooksContextProvider>
|
|
268
|
-
<ValidationContextProvider>
|
|
269
|
-
<CheckYourAnswers
|
|
270
|
-
pages={PAGES}
|
|
271
|
-
hide_page_titles={true}
|
|
272
|
-
onAction={ON_ACTION}
|
|
273
|
-
onRowAction={ON_ROW_ACTION}
|
|
274
|
-
hide_title={true}
|
|
275
|
-
summaryListClassModifiers='no-border'
|
|
276
|
-
noChangeAction={true}
|
|
277
|
-
/>
|
|
278
|
-
</ValidationContextProvider>
|
|
279
|
-
</HooksContextProvider>
|
|
280
|
-
);
|
|
281
|
-
}}
|
|
282
|
-
</Story>
|
|
283
|
-
</Canvas>
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
### Group of rows
|
|
287
|
-
|
|
288
|
-
<Canvas>
|
|
289
|
-
<Story
|
|
290
|
-
name='Group of rows'
|
|
291
|
-
parameters={{
|
|
292
|
-
mockData: [
|
|
293
|
-
{
|
|
294
|
-
url: `${USER_PROFILE_DATA.urls.refData}/areYouACivilServant`,
|
|
295
|
-
method: 'GET',
|
|
296
|
-
status: 200,
|
|
297
|
-
response: CIVIL_SERVANT,
|
|
298
|
-
},
|
|
299
|
-
{
|
|
300
|
-
url: `${USER_PROFILE_DATA.urls.refData}/grade`,
|
|
301
|
-
method: 'GET',
|
|
302
|
-
status: 200,
|
|
303
|
-
response: GRADE,
|
|
304
|
-
},
|
|
305
|
-
{
|
|
306
|
-
url: `${USER_PROFILE_DATA.urls.refData}/team`,
|
|
307
|
-
method: 'GET',
|
|
308
|
-
status: 200,
|
|
309
|
-
response: TEAMS,
|
|
310
|
-
},
|
|
311
|
-
],
|
|
312
|
-
}}
|
|
313
|
-
>
|
|
314
|
-
{() => {
|
|
315
|
-
const DATA = Utils.Data.setupForm(
|
|
316
|
-
GROUP_OF_ROW.pages,
|
|
317
|
-
GROUP_OF_ROW.components,
|
|
318
|
-
GROUP_OF_ROW_DATA
|
|
319
|
-
);
|
|
320
|
-
const PAGES = Utils.FormPage.getAll(
|
|
321
|
-
GROUP_OF_ROW.pages,
|
|
322
|
-
GROUP_OF_ROW.components,
|
|
323
|
-
{ ...DATA }
|
|
324
|
-
);
|
|
325
|
-
const CYA = GROUP_OF_ROW.cya;
|
|
326
|
-
const ON_ACTION = (action, patch, onError) => {
|
|
327
|
-
console.log('action invoked', action, patch);
|
|
328
|
-
};
|
|
329
|
-
const ON_ROW_ACTION = (page) => {
|
|
330
|
-
console.log('row action invoked', page);
|
|
331
|
-
};
|
|
332
|
-
return (
|
|
333
|
-
<HooksContextProvider>
|
|
334
|
-
<ValidationContextProvider>
|
|
335
|
-
<CheckYourAnswers
|
|
336
|
-
pages={PAGES}
|
|
337
|
-
hide_page_titles={false}
|
|
338
|
-
onAction={ON_ACTION}
|
|
339
|
-
onRowAction={ON_ROW_ACTION}
|
|
340
|
-
groups={CYA.groups}
|
|
341
|
-
/>
|
|
342
|
-
</ValidationContextProvider>
|
|
343
|
-
</HooksContextProvider>
|
|
344
|
-
);
|
|
345
|
-
}}
|
|
346
|
-
</Story>
|
|
347
|
-
</Canvas>
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
### Group of address rows
|
|
351
|
-
<Canvas>
|
|
352
|
-
<Story name='Group of address rows'
|
|
353
|
-
parameters={{
|
|
354
|
-
mockData: [
|
|
355
|
-
{
|
|
356
|
-
url: `${USER_PROFILE_DATA.urls.refData}/areYouACivilServant`,
|
|
357
|
-
method: 'GET',
|
|
358
|
-
status: 200,
|
|
359
|
-
response: CIVIL_SERVANT,
|
|
360
|
-
},
|
|
361
|
-
{
|
|
362
|
-
url: `${USER_PROFILE_DATA.urls.refData}/grade`,
|
|
363
|
-
method: 'GET',
|
|
364
|
-
status: 200,
|
|
365
|
-
response: GRADE,
|
|
366
|
-
},
|
|
367
|
-
{
|
|
368
|
-
url: `${USER_PROFILE_DATA.urls.refData}/team`,
|
|
369
|
-
method: 'GET',
|
|
370
|
-
status: 200,
|
|
371
|
-
response: TEAMS,
|
|
372
|
-
},
|
|
373
|
-
],
|
|
374
|
-
}}>
|
|
375
|
-
{() => {
|
|
376
|
-
const DATA = Utils.Data.setupForm(
|
|
377
|
-
GROUP.pages,
|
|
378
|
-
GROUP.components,
|
|
379
|
-
GROUP_DATA
|
|
380
|
-
);
|
|
381
|
-
const PAGES = Utils.FormPage.getAll(
|
|
382
|
-
GROUP.pages,
|
|
383
|
-
GROUP.components,
|
|
384
|
-
{ ...DATA }
|
|
385
|
-
);
|
|
386
|
-
const ACTIONS = GROUP.cya.actions;
|
|
387
|
-
const ON_ACTION = (action, patch, onError) => {
|
|
388
|
-
console.log('action invoked', action, patch);
|
|
389
|
-
};
|
|
390
|
-
const ON_ROW_ACTION = (page) => {
|
|
391
|
-
console.log('row action invoked', page);
|
|
392
|
-
};
|
|
393
|
-
return (
|
|
394
|
-
<HooksContextProvider>
|
|
395
|
-
<ValidationContextProvider>
|
|
396
|
-
<CheckYourAnswers
|
|
397
|
-
pages={PAGES}
|
|
398
|
-
hide_page_titles={true}
|
|
399
|
-
actions={ACTIONS}
|
|
400
|
-
onAction={ON_ACTION}
|
|
401
|
-
onRowAction={ON_ROW_ACTION}
|
|
402
|
-
/>
|
|
403
|
-
</ValidationContextProvider>
|
|
404
|
-
</HooksContextProvider>
|
|
405
|
-
);
|
|
406
|
-
}}
|
|
407
|
-
</Story>
|
|
408
|
-
</Canvas>
|
|
409
|
-
|
|
410
|
-
|