@ukhomeoffice/cop-react-form-renderer 5.0.0-alpha → 5.0.0
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 +18 -7
- package/dist/components/CheckYourAnswers/Answer.test.js +137 -0
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +70 -46
- package/dist/components/CheckYourAnswers/CheckYourAnswers.stories.mdx +410 -0
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +551 -0
- package/dist/components/CollectionPage/CollectionPage.js +15 -10
- package/dist/components/CollectionPage/CollectionPage.test.js +382 -0
- package/dist/components/FormComponent/Collection.js +91 -48
- package/dist/components/FormComponent/Collection.scss +2 -1
- package/dist/components/FormComponent/Collection.test.js +807 -0
- package/dist/components/FormComponent/Container.js +35 -16
- package/dist/components/FormComponent/Container.test.js +370 -0
- package/dist/components/FormComponent/FormComponent.js +39 -13
- package/dist/components/FormComponent/FormComponent.stories.mdx +184 -0
- package/dist/components/FormComponent/FormComponent.test.js +226 -0
- package/dist/components/FormComponent/helpers/addLabel.js +5 -4
- package/dist/components/FormComponent/helpers/getComponentFieldSet.js +16 -0
- package/dist/components/FormComponent/helpers/getComponentFieldSet.test.js +29 -0
- package/dist/components/FormComponent/helpers/index.js +8 -1
- package/dist/components/FormPage/FormPage.js +69 -30
- package/dist/components/FormPage/FormPage.stories.mdx +155 -0
- package/dist/components/FormPage/FormPage.test.js +330 -0
- package/dist/components/FormRenderer/FormRenderer.js +142 -228
- package/dist/components/FormRenderer/FormRenderer.stories.mdx +183 -0
- package/dist/components/FormRenderer/FormRenderer.test.js +968 -0
- package/dist/components/FormRenderer/handlers/index.js +1 -2
- package/dist/components/FormRenderer/handlers/navigate.js +3 -1
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +35 -14
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +88 -5
- package/dist/components/FormRenderer/helpers/getCYA.js +11 -2
- package/dist/components/FormRenderer/helpers/getNextPageId.js +13 -7
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +10 -2
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +1 -1
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +2 -2
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +6 -2
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +171 -51
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +307 -24
- package/dist/components/FormRenderer/helpers/index.js +1 -2
- package/dist/components/FormRenderer/onCYAAction.js +108 -0
- package/dist/components/FormRenderer/onCYAAction.test.js +583 -0
- package/dist/components/FormRenderer/onPageAction.js +145 -0
- package/dist/components/FormRenderer/onPageAction.test.js +678 -0
- package/dist/components/FormRenderer/onTaskAction.js +48 -0
- package/dist/components/FormRenderer/onTaskAction.test.js +217 -0
- package/dist/components/PageActions/ActionButton.js +0 -3
- package/dist/components/PageActions/ActionButton.test.js +93 -0
- package/dist/components/PageActions/PageActions.js +2 -2
- package/dist/components/PageActions/PageActions.stories.mdx +74 -0
- package/dist/components/PageActions/PageActions.test.js +132 -0
- package/dist/components/SummaryList/GroupAction.js +2 -2
- package/dist/components/SummaryList/GroupAction.test.js +80 -0
- package/dist/components/SummaryList/RowAction.js +2 -2
- package/dist/components/SummaryList/RowAction.test.js +80 -0
- package/dist/components/SummaryList/SummaryList.js +29 -12
- package/dist/components/SummaryList/SummaryList.scss +19 -0
- package/dist/components/SummaryList/SummaryList.stories.mdx +90 -0
- package/dist/components/SummaryList/SummaryList.test.js +400 -0
- package/dist/components/SummaryList/SummaryListHeadingRow.js +30 -0
- package/dist/components/SummaryList/SummaryListRow.js +5 -2
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +2 -1
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +2 -1
- package/dist/components/TaskList/Task.js +3 -3
- package/dist/components/TaskList/Task.test.js +167 -0
- package/dist/components/TaskList/TaskList.js +73 -22
- package/dist/components/TaskList/TaskList.stories.mdx +164 -0
- package/dist/components/TaskList/TaskList.test.js +389 -0
- package/dist/components/TaskList/TaskState.js +2 -2
- package/dist/components/TaskList/TaskState.test.js +86 -0
- package/dist/components/index.js +14 -0
- package/dist/context/HooksContext/HooksContext.js +72 -8
- package/dist/context/HooksContext/HooksContext.test.js +44 -0
- package/dist/context/ValidationContext/ValidationContext.js +38 -28
- package/dist/context/ValidationContext/ValidationContext.test.js +84 -0
- package/dist/hooks/useAxios.js +10 -12
- package/dist/hooks/useGetRequest.js +48 -49
- package/dist/hooks/useRefData.js +7 -4
- package/dist/index.js +34 -1
- package/dist/json/addressDetails.json +149 -0
- package/dist/json/areYouACivilServant.json +7 -0
- package/dist/json/firstForm.json +94 -0
- package/dist/json/grade.json +108 -0
- package/dist/json/group.data.json +21 -0
- package/dist/json/group.json +402 -0
- package/dist/json/groupOfRow.json +137 -0
- package/dist/json/groupOfRowData.json +15 -0
- package/dist/json/port.json +346 -0
- package/dist/json/saveAndContinue.json +98 -0
- package/dist/json/sublocation.json +859 -0
- package/dist/json/taskList.json +265 -0
- package/dist/json/team.json +17351 -0
- package/dist/json/terminal.json +81 -0
- package/dist/json/userProfile.data.json +21 -0
- package/dist/json/userProfile.json +276 -0
- package/dist/models/ComponentTypes.js +8 -0
- package/dist/models/PageAction.js +4 -1
- package/dist/models/TaskStates.js +10 -2
- package/dist/models/index.js +16 -1
- package/dist/setupTests.js +46 -0
- package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +121 -0
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +6 -2
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +71 -0
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +6 -2
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +55 -0
- package/dist/utils/CheckYourAnswers/getCYARow.js +14 -11
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +291 -0
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +4 -1
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +70 -0
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +15 -10
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +288 -0
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +94 -36
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +414 -0
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +21 -7
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +486 -0
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +11 -3
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +346 -0
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +19 -3
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +143 -0
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +5 -1
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +40 -0
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +53 -0
- package/dist/utils/CollectionPage/mergeCollectionPages.js +25 -17
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +130 -0
- package/dist/utils/Component/addShowWhen.js +44 -0
- package/dist/utils/Component/addShowWhen.test.js +216 -0
- package/dist/utils/Component/applyToComponentTree.js +71 -0
- package/dist/utils/Component/applyToComponentTree.test.js +127 -0
- package/dist/utils/Component/cleanAttributes.js +8 -2
- package/dist/utils/Component/cleanAttributes.test.js +68 -0
- package/dist/utils/Component/elevateNestedComponents.js +4 -1
- package/dist/utils/Component/elevateNestedComponents.test.js +122 -0
- package/dist/utils/Component/getComponent.js +80 -11
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +4 -4
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +25 -24
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +66 -5
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +2 -2
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +9 -7
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +3 -3
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +3 -3
- package/dist/utils/Component/getComponentTests/getComponent.list.test.js +44 -0
- package/dist/utils/Component/getComponentTests/{getComponent.textarea.test.js → getComponent.multifile.test.js} +29 -21
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +159 -83
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +43 -0
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +3 -3
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +55 -5
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +3 -9
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +3 -3
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +109 -0
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +7 -7
- package/dist/utils/Component/getDefaultValue.js +4 -1
- package/dist/utils/Component/getDefaultValue.test.js +50 -0
- package/dist/utils/Component/index.js +2 -0
- package/dist/utils/Component/isEditable.js +2 -2
- package/dist/utils/Component/isEditable.test.js +43 -0
- package/dist/utils/Component/optionIsSelected.js +22 -0
- package/dist/utils/Component/optionIsSelected.test.js +42 -0
- package/dist/utils/Component/setupContainerComponentsPath.js +40 -0
- package/dist/utils/Component/setupContainerComponentsPath.test.js +78 -0
- package/dist/utils/Component/showComponent.test.js +156 -0
- package/dist/utils/Component/wrapInFormGroup.js +1 -1
- package/dist/utils/Condition/meetsAllConditions.js +1 -1
- package/dist/utils/Condition/meetsAllConditions.test.js +61 -0
- package/dist/utils/Condition/meetsCondition.js +74 -4
- package/dist/utils/Condition/meetsCondition.test.js +763 -0
- package/dist/utils/Condition/meetsOneCondition.js +1 -1
- package/dist/utils/Condition/meetsOneCondition.test.js +100 -0
- package/dist/utils/Condition/setupConditions.js +6 -3
- package/dist/utils/Condition/setupConditions.test.js +33 -0
- package/dist/utils/Container/getEditableComponents.test.js +135 -0
- package/dist/utils/Container/setupNesting.js +21 -2
- package/dist/utils/Container/setupNesting.test.js +145 -0
- package/dist/utils/Container/showContainer.test.js +178 -0
- package/dist/utils/Data/applyFormula.js +20 -11
- package/dist/utils/Data/applyFormula.test.js +263 -0
- package/dist/utils/Data/getAutocompleteSource.js +6 -2
- package/dist/utils/Data/getAutocompleteSource.test.js +352 -0
- package/dist/utils/Data/getDataPath.test.js +48 -0
- package/dist/utils/Data/getOptions.js +17 -3
- package/dist/utils/Data/getOptions.test.js +140 -0
- package/dist/utils/Data/getSourceData.js +2 -2
- package/dist/utils/Data/getSourceData.test.js +153 -0
- package/dist/utils/Data/refDataToOptions.js +4 -1
- package/dist/utils/Data/refDataToOptions.test.js +196 -0
- package/dist/utils/Data/setDataItem.test.js +110 -0
- package/dist/utils/Data/setupFormData.js +39 -16
- package/dist/utils/Data/setupFormData.test.js +410 -0
- package/dist/utils/Data/setupRefDataUrlForComponent.js +4 -1
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +131 -0
- package/dist/utils/FormPage/applyConditionalProperties.js +35 -0
- package/dist/utils/FormPage/applyConditionalProperties.test.js +61 -0
- package/dist/utils/FormPage/getFormPage.js +5 -2
- package/dist/utils/FormPage/getFormPage.test.js +206 -0
- package/dist/utils/FormPage/getFormPages.js +4 -1
- package/dist/utils/FormPage/getFormPages.test.js +97 -0
- package/dist/utils/FormPage/getPageActions.js +8 -4
- package/dist/utils/FormPage/getPageActions.test.js +114 -0
- package/dist/utils/FormPage/getParagraphFromText.test.js +27 -0
- package/dist/utils/FormPage/index.js +2 -0
- package/dist/utils/FormPage/showFormPage.js +2 -2
- package/dist/utils/FormPage/showFormPage.test.js +180 -0
- package/dist/utils/FormPage/showFormPageCYA.js +1 -0
- package/dist/utils/FormPage/showFormPageCYA.test.js +28 -0
- package/dist/utils/FormPage/useComponent.js +29 -14
- package/dist/utils/FormPage/useComponent.test.js +167 -0
- package/dist/utils/Format/formatData.test.js +45 -0
- package/dist/utils/Format/formatDataForComponent.js +2 -1
- package/dist/utils/Format/formatDataForComponent.test.js +142 -0
- package/dist/utils/Format/formatDataForForm.js +4 -1
- package/dist/utils/Format/formatDataForForm.test.js +81 -0
- package/dist/utils/Format/formatDataForPage.test.js +99 -0
- package/dist/utils/Hub/getFormHub.test.js +105 -0
- package/dist/utils/Meta/documents/getDocuments.test.js +4 -1
- package/dist/utils/Meta/documents/index.js +2 -2
- package/dist/utils/Meta/documents/setDocumentsForField.js +31 -0
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +59 -0
- package/dist/utils/Operate/checkValueIsTruthy.test.js +42 -0
- package/dist/utils/Operate/getFirstOf.js +31 -0
- package/dist/utils/Operate/getFirstOf.test.js +86 -0
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +163 -0
- package/dist/utils/Operate/persistValueInFormData.js +2 -1
- package/dist/utils/Operate/persistValueInFormData.test.js +115 -0
- package/dist/utils/Operate/runPageOperations.js +3 -1
- package/dist/utils/Operate/runPageOperations.test.js +105 -0
- package/dist/utils/Operate/setValueInFormData.test.js +44 -0
- package/dist/utils/Operate/shouldRun.js +16 -13
- package/dist/utils/Operate/shouldRun.test.js +66 -0
- package/dist/utils/Validate/additional/conditionallyRequired.js +24 -0
- package/dist/utils/Validate/additional/conditionallyRequired.test.js +73 -0
- package/dist/utils/Validate/additional/index.js +13 -4
- package/dist/utils/Validate/additional/mustBeAfter.js +8 -6
- package/dist/utils/Validate/additional/mustBeAfter.test.js +15 -1
- package/dist/utils/Validate/additional/mustBeBefore.js +9 -5
- package/dist/utils/Validate/additional/mustBeBefore.test.js +14 -0
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +1 -1
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +6 -3
- package/dist/utils/Validate/additional/mustBeGreaterThan.js +22 -0
- package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +56 -0
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +1 -1
- package/dist/utils/Validate/additional/mustBeInThePast.js +5 -5
- package/dist/utils/Validate/additional/mustBeLessThan.js +7 -6
- package/dist/utils/Validate/additional/mustBeLessThan.test.js +11 -1
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +9 -5
- package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +10 -2
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +1 -0
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +4 -1
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +19 -0
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +36 -0
- package/dist/utils/Validate/additional/mustSelectOnlyOne.js +29 -0
- package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +52 -0
- package/dist/utils/Validate/additional/utils.js +18 -18
- package/dist/utils/Validate/index.js +6 -0
- package/dist/utils/Validate/validateCollection.js +20 -5
- package/dist/utils/Validate/validateCollection.test.js +125 -0
- package/dist/utils/Validate/validateComponent.js +36 -20
- package/dist/utils/Validate/validateComponent.test.js +365 -0
- package/dist/utils/Validate/validateContainer.js +9 -3
- package/dist/utils/Validate/validateContainer.test.js +75 -0
- package/dist/utils/Validate/validateDate.js +4 -3
- package/dist/utils/Validate/validateDate.test.js +114 -0
- package/dist/utils/Validate/validateEmail.js +14 -1
- package/dist/utils/Validate/validateEmail.test.js +74 -0
- package/dist/utils/Validate/validateMultifile.js +32 -0
- package/dist/utils/Validate/validateMultifile.test.js +47 -0
- package/dist/utils/Validate/validatePage.js +12 -6
- package/dist/utils/Validate/validatePage.test.js +472 -0
- package/dist/utils/Validate/validateRegex.js +2 -5
- package/dist/utils/Validate/validateRegex.test.js +42 -0
- package/dist/utils/Validate/validateRequired.js +2 -4
- package/dist/utils/Validate/validateRequired.test.js +63 -0
- package/dist/utils/Validate/validateTextArea.js +37 -0
- package/dist/utils/Validate/validateTextArea.test.js +42 -0
- package/dist/utils/Validate/validateTime.js +2 -2
- package/dist/utils/Validate/validateTime.test.js +59 -0
- package/dist/utils/index.js +4 -1
- package/package.json +35 -50
- package/dist/utils/Meta/documents/setDocumentForField.js +0 -29
- package/dist/utils/Meta/documents/setDocumentForField.test.js +0 -49
|
@@ -0,0 +1,410 @@
|
|
|
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
|
+
|