@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.
Files changed (307) hide show
  1. package/dist/components/CheckYourAnswers/Answer.js +1 -14
  2. package/dist/components/CheckYourAnswers/CheckYourAnswers.js +19 -57
  3. package/dist/components/CheckYourAnswers/index.js +0 -3
  4. package/dist/components/CollectionPage/CollectionPage.js +8 -38
  5. package/dist/components/CollectionPage/index.js +0 -3
  6. package/dist/components/FormComponent/Collection.js +13 -54
  7. package/dist/components/FormComponent/Container.js +6 -30
  8. package/dist/components/FormComponent/FormComponent.js +14 -57
  9. package/dist/components/FormComponent/helpers/addLabel.js +4 -7
  10. package/dist/components/FormComponent/helpers/getComponentDisabled.js +0 -4
  11. package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +0 -2
  12. package/dist/components/FormComponent/helpers/getComponentError.js +0 -6
  13. package/dist/components/FormComponent/helpers/getComponentError.test.js +0 -2
  14. package/dist/components/FormComponent/helpers/index.js +0 -4
  15. package/dist/components/FormComponent/index.js +0 -3
  16. package/dist/components/FormPage/FormPage.js +14 -45
  17. package/dist/components/FormPage/index.js +0 -3
  18. package/dist/components/FormRenderer/FormRenderer.js +106 -189
  19. package/dist/components/FormRenderer/handlers/cyaAction.js +0 -5
  20. package/dist/components/FormRenderer/handlers/getPageId.js +0 -2
  21. package/dist/components/FormRenderer/handlers/getPageId.test.js +1 -2
  22. package/dist/components/FormRenderer/handlers/handlers.test.js +1 -18
  23. package/dist/components/FormRenderer/handlers/index.js +0 -5
  24. package/dist/components/FormRenderer/handlers/navigate.js +0 -5
  25. package/dist/components/FormRenderer/handlers/submissionError.js +0 -2
  26. package/dist/components/FormRenderer/helpers/canActionProceed.js +0 -3
  27. package/dist/components/FormRenderer/helpers/canActionProceed.test.js +1 -3
  28. package/dist/components/FormRenderer/helpers/canCYASubmit.js +0 -2
  29. package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +1 -5
  30. package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +0 -5
  31. package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +1 -2
  32. package/dist/components/FormRenderer/helpers/getCYA.js +0 -6
  33. package/dist/components/FormRenderer/helpers/getCYA.test.js +1 -3
  34. package/dist/components/FormRenderer/helpers/getFormState.js +0 -5
  35. package/dist/components/FormRenderer/helpers/getFormState.test.js +1 -3
  36. package/dist/components/FormRenderer/helpers/getNextPageId.js +0 -25
  37. package/dist/components/FormRenderer/helpers/getNextPageId.test.js +1 -4
  38. package/dist/components/FormRenderer/helpers/getPage.js +0 -5
  39. package/dist/components/FormRenderer/helpers/getPage.test.js +1 -3
  40. package/dist/components/FormRenderer/helpers/getRelevantPages.js +0 -6
  41. package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +1 -3
  42. package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +0 -10
  43. package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +0 -6
  44. package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +6 -20
  45. package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +3 -8
  46. package/dist/components/FormRenderer/helpers/index.js +1 -11
  47. package/dist/components/FormRenderer/index.js +0 -3
  48. package/dist/components/PageActions/ActionButton.js +2 -17
  49. package/dist/components/PageActions/PageActions.js +3 -10
  50. package/dist/components/PageActions/index.js +0 -3
  51. package/dist/components/SummaryList/GroupAction.js +3 -24
  52. package/dist/components/SummaryList/RowAction.js +3 -23
  53. package/dist/components/SummaryList/SummaryList.js +6 -28
  54. package/dist/components/SummaryList/SummaryListRow.js +4 -8
  55. package/dist/components/SummaryList/SummaryListTitleRow.js +2 -7
  56. package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +0 -3
  57. package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +0 -6
  58. package/dist/components/SummaryList/helpers/getRowActionAttributes.js +0 -3
  59. package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +0 -6
  60. package/dist/components/SummaryList/helpers/index.js +0 -2
  61. package/dist/components/SummaryList/index.js +0 -3
  62. package/dist/components/TaskList/Task.js +7 -29
  63. package/dist/components/TaskList/TaskList.js +12 -33
  64. package/dist/components/TaskList/TaskState.js +2 -10
  65. package/dist/components/TaskList/index.js +0 -3
  66. package/dist/components/index.js +0 -6
  67. package/dist/context/HooksContext/HooksContext.js +14 -34
  68. package/dist/context/HooksContext/index.js +0 -5
  69. package/dist/context/ValidationContext/ValidationContext.js +8 -34
  70. package/dist/context/ValidationContext/index.js +0 -5
  71. package/dist/context/index.js +0 -3
  72. package/dist/hooks/index.js +0 -9
  73. package/dist/hooks/useAxios.js +8 -25
  74. package/dist/hooks/useGetRequest.js +13 -47
  75. package/dist/hooks/useHooks.js +2 -4
  76. package/dist/hooks/useRefData.js +8 -37
  77. package/dist/hooks/useValidation.js +2 -4
  78. package/dist/index.js +0 -6
  79. package/dist/models/PageAction.js +0 -3
  80. package/dist/models/TaskStates.js +0 -3
  81. package/dist/models/index.js +0 -9
  82. package/dist/utils/CheckYourAnswers/getCYAAction.js +1 -9
  83. package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +0 -10
  84. package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +0 -8
  85. package/dist/utils/CheckYourAnswers/getCYARow.js +1 -10
  86. package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +2 -20
  87. package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +0 -18
  88. package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +0 -20
  89. package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +0 -13
  90. package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +2 -22
  91. package/dist/utils/CheckYourAnswers/index.js +1 -3
  92. package/dist/utils/CheckYourAnswers/showComponentCYA.js +2 -11
  93. package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +0 -11
  94. package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +0 -6
  95. package/dist/utils/CollectionPage/index.js +1 -5
  96. package/dist/utils/CollectionPage/mergeCollectionPages.js +1 -12
  97. package/dist/utils/Component/cleanAttributes.js +1 -8
  98. package/dist/utils/Component/elevateNestedComponents.js +0 -3
  99. package/dist/utils/Component/getComponent.js +4 -68
  100. package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +6 -10
  101. package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +10 -28
  102. package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +6 -33
  103. package/dist/utils/Component/getComponentTests/getComponent.date.test.js +10 -27
  104. package/dist/utils/Component/getComponentTests/getComponent.details.test.js +4 -10
  105. package/dist/utils/Component/getComponentTests/getComponent.email.test.js +4 -21
  106. package/dist/utils/Component/getComponentTests/getComponent.file.test.js +4 -22
  107. package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +3 -7
  108. package/dist/utils/Component/getComponentTests/getComponent.html.test.js +4 -10
  109. package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +3 -7
  110. package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +6 -15
  111. package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +4 -21
  112. package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +6 -33
  113. package/dist/utils/Component/getComponentTests/getComponent.select.test.js +4 -21
  114. package/dist/utils/Component/getComponentTests/getComponent.text.test.js +4 -21
  115. package/dist/utils/Component/getComponentTests/getComponent.textarea.test.js +4 -21
  116. package/dist/utils/Component/getComponentTests/getComponent.time.test.js +10 -29
  117. package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +1 -2
  118. package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +3 -7
  119. package/dist/utils/Component/getDefaultValue.js +0 -7
  120. package/dist/utils/Component/index.js +0 -9
  121. package/dist/utils/Component/isEditable.js +1 -4
  122. package/dist/utils/Component/showComponent.js +1 -8
  123. package/dist/utils/Component/wrapInFormGroup.js +0 -7
  124. package/dist/utils/Condition/index.js +0 -5
  125. package/dist/utils/Condition/meetsAllConditions.js +0 -9
  126. package/dist/utils/Condition/meetsCondition.js +7 -19
  127. package/dist/utils/Condition/meetsOneCondition.js +1 -9
  128. package/dist/utils/Condition/setupConditions.js +0 -12
  129. package/dist/utils/Container/getEditableComponents.js +0 -7
  130. package/dist/utils/Container/index.js +0 -5
  131. package/dist/utils/Container/setupNesting.js +0 -11
  132. package/dist/utils/Container/showContainer.js +9 -18
  133. package/dist/utils/Data/applyFormula.js +2 -28
  134. package/dist/utils/Data/getAutocompleteSource.js +1 -4
  135. package/dist/utils/Data/getDataPath.js +3 -17
  136. package/dist/utils/Data/getOptions.js +0 -9
  137. package/dist/utils/Data/getSourceData.js +4 -19
  138. package/dist/utils/Data/index.js +1 -11
  139. package/dist/utils/Data/refDataToOptions.js +1 -12
  140. package/dist/utils/Data/setDataItem.js +0 -5
  141. package/dist/utils/Data/setupFormData.js +2 -20
  142. package/dist/utils/Data/setupRefDataUrlForComponent.js +0 -14
  143. package/dist/utils/FormPage/getFormPage.js +0 -15
  144. package/dist/utils/FormPage/getFormPages.js +0 -8
  145. package/dist/utils/FormPage/getPageActions.js +3 -18
  146. package/dist/utils/FormPage/getParagraphFromText.js +0 -3
  147. package/dist/utils/FormPage/index.js +0 -6
  148. package/dist/utils/FormPage/showFormPage.js +9 -18
  149. package/dist/utils/FormPage/showFormPageCYA.js +0 -5
  150. package/dist/utils/FormPage/useComponent.js +3 -18
  151. package/dist/utils/Format/formatData.js +0 -5
  152. package/dist/utils/Format/formatDataForComponent.js +1 -6
  153. package/dist/utils/Format/formatDataForForm.js +0 -8
  154. package/dist/utils/Format/formatDataForPage.js +1 -5
  155. package/dist/utils/Format/index.js +1 -6
  156. package/dist/utils/Hub/getFormHub.js +0 -8
  157. package/dist/utils/Hub/index.js +1 -3
  158. package/dist/utils/Meta/documents/getDocuments.js +1 -4
  159. package/dist/utils/Meta/documents/getDocuments.test.js +0 -9
  160. package/dist/utils/Meta/documents/index.js +1 -5
  161. package/dist/utils/Meta/documents/setDocumentForField.js +0 -11
  162. package/dist/utils/Meta/documents/setDocumentForField.test.js +0 -11
  163. package/dist/utils/Meta/index.js +2 -6
  164. package/dist/utils/Operate/checkValueIsTruthy.js +1 -7
  165. package/dist/utils/Operate/getIndexOfMatchingValueIn.js +7 -21
  166. package/dist/utils/Operate/index.js +0 -3
  167. package/dist/utils/Operate/persistValueInFormData.js +1 -8
  168. package/dist/utils/Operate/runPageOperations.js +3 -18
  169. package/dist/utils/Operate/setValueInFormData.js +2 -7
  170. package/dist/utils/Operate/shouldRun.js +1 -14
  171. package/dist/utils/Validate/additional/index.js +1 -18
  172. package/dist/utils/Validate/additional/index.test.js +0 -6
  173. package/dist/utils/Validate/additional/mustBeAfter.js +3 -8
  174. package/dist/utils/Validate/additional/mustBeAfter.test.js +0 -4
  175. package/dist/utils/Validate/additional/mustBeBefore.js +3 -8
  176. package/dist/utils/Validate/additional/mustBeBefore.test.js +0 -4
  177. package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +5 -16
  178. package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +0 -7
  179. package/dist/utils/Validate/additional/mustBeInTheFuture.js +3 -12
  180. package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +0 -3
  181. package/dist/utils/Validate/additional/mustBeInThePast.js +5 -13
  182. package/dist/utils/Validate/additional/mustBeInThePast.test.js +0 -3
  183. package/dist/utils/Validate/additional/mustBeLessThan.js +0 -3
  184. package/dist/utils/Validate/additional/mustBeLessThan.test.js +0 -2
  185. package/dist/utils/Validate/additional/mustBeLongerThan.js +0 -3
  186. package/dist/utils/Validate/additional/mustBeLongerThan.test.js +0 -2
  187. package/dist/utils/Validate/additional/mustBeNumbersOnly.js +0 -4
  188. package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +0 -2
  189. package/dist/utils/Validate/additional/mustBeShorterThan.js +0 -3
  190. package/dist/utils/Validate/additional/mustBeShorterThan.test.js +0 -2
  191. package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +0 -5
  192. package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +0 -4
  193. package/dist/utils/Validate/additional/utils.js +8 -24
  194. package/dist/utils/Validate/index.js +1 -9
  195. package/dist/utils/Validate/validateCollection.js +0 -9
  196. package/dist/utils/Validate/validateComponent.js +2 -35
  197. package/dist/utils/Validate/validateContainer.js +0 -13
  198. package/dist/utils/Validate/validateDate.js +4 -36
  199. package/dist/utils/Validate/validateEmail.js +1 -7
  200. package/dist/utils/Validate/validatePage.js +0 -15
  201. package/dist/utils/Validate/validateRegex.js +0 -10
  202. package/dist/utils/Validate/validateRequired.js +0 -8
  203. package/dist/utils/Validate/validateTime.js +3 -20
  204. package/dist/utils/index.js +0 -19
  205. package/package.json +50 -34
  206. package/dist/components/CheckYourAnswers/Answer.test.js +0 -95
  207. package/dist/components/CheckYourAnswers/CheckYourAnswers.stories.mdx +0 -410
  208. package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +0 -680
  209. package/dist/components/CollectionPage/CollectionPage.test.js +0 -428
  210. package/dist/components/FormComponent/Collection.test.js +0 -381
  211. package/dist/components/FormComponent/Container.test.js +0 -423
  212. package/dist/components/FormComponent/FormComponent.stories.mdx +0 -184
  213. package/dist/components/FormComponent/FormComponent.test.js +0 -264
  214. package/dist/components/FormPage/FormPage.stories.mdx +0 -131
  215. package/dist/components/FormPage/FormPage.test.js +0 -368
  216. package/dist/components/FormRenderer/FormRenderer.stories.mdx +0 -183
  217. package/dist/components/FormRenderer/FormRenderer.test.js +0 -1006
  218. package/dist/components/PageActions/ActionButton.test.js +0 -116
  219. package/dist/components/PageActions/PageActions.stories.mdx +0 -74
  220. package/dist/components/PageActions/PageActions.test.js +0 -157
  221. package/dist/components/SummaryList/GroupAction.test.js +0 -94
  222. package/dist/components/SummaryList/RowAction.test.js +0 -94
  223. package/dist/components/SummaryList/SummaryList.stories.mdx +0 -90
  224. package/dist/components/SummaryList/SummaryList.test.js +0 -361
  225. package/dist/components/TaskList/Task.test.js +0 -194
  226. package/dist/components/TaskList/TaskList.stories.mdx +0 -164
  227. package/dist/components/TaskList/TaskList.test.js +0 -334
  228. package/dist/components/TaskList/TaskState.test.js +0 -104
  229. package/dist/context/HooksContext/HooksContext.test.js +0 -60
  230. package/dist/context/ValidationContext/ValidationContext.test.js +0 -98
  231. package/dist/json/areYouACivilServant.json +0 -7
  232. package/dist/json/firstForm.json +0 -94
  233. package/dist/json/grade.json +0 -108
  234. package/dist/json/group.data.json +0 -21
  235. package/dist/json/group.json +0 -402
  236. package/dist/json/groupOfRow.json +0 -137
  237. package/dist/json/groupOfRowData.json +0 -15
  238. package/dist/json/port.json +0 -346
  239. package/dist/json/saveAndContinue.json +0 -98
  240. package/dist/json/sublocation.json +0 -859
  241. package/dist/json/taskList.json +0 -265
  242. package/dist/json/team.json +0 -17351
  243. package/dist/json/terminal.json +0 -81
  244. package/dist/json/userProfile.data.json +0 -21
  245. package/dist/json/userProfile.json +0 -276
  246. package/dist/setupTests.js +0 -59
  247. package/dist/utils/CheckYourAnswers/getCYAAction.test.js +0 -139
  248. package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +0 -76
  249. package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +0 -59
  250. package/dist/utils/CheckYourAnswers/getCYARow.test.js +0 -256
  251. package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +0 -77
  252. package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +0 -199
  253. package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +0 -170
  254. package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +0 -323
  255. package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +0 -281
  256. package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +0 -64
  257. package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +0 -41
  258. package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +0 -54
  259. package/dist/utils/CollectionPage/mergeCollectionPages.test.js +0 -131
  260. package/dist/utils/Component/cleanAttributes.test.js +0 -69
  261. package/dist/utils/Component/elevateNestedComponents.test.js +0 -92
  262. package/dist/utils/Component/getDefaultValue.test.js +0 -53
  263. package/dist/utils/Component/isEditable.test.js +0 -42
  264. package/dist/utils/Component/showComponent.test.js +0 -157
  265. package/dist/utils/Condition/meetsAllConditions.test.js +0 -62
  266. package/dist/utils/Condition/meetsCondition.test.js +0 -391
  267. package/dist/utils/Condition/meetsOneCondition.test.js +0 -101
  268. package/dist/utils/Condition/setupConditions.test.js +0 -35
  269. package/dist/utils/Container/getEditableComponents.test.js +0 -146
  270. package/dist/utils/Container/setupNesting.test.js +0 -92
  271. package/dist/utils/Container/showContainer.test.js +0 -179
  272. package/dist/utils/Data/applyFormula.test.js +0 -264
  273. package/dist/utils/Data/getAutocompleteSource.test.js +0 -146
  274. package/dist/utils/Data/getDataPath.test.js +0 -52
  275. package/dist/utils/Data/getOptions.test.js +0 -71
  276. package/dist/utils/Data/getSourceData.test.js +0 -141
  277. package/dist/utils/Data/refDataToOptions.test.js +0 -197
  278. package/dist/utils/Data/setDataItem.test.js +0 -112
  279. package/dist/utils/Data/setupFormData.test.js +0 -276
  280. package/dist/utils/Data/setupRefDataUrlForComponent.test.js +0 -133
  281. package/dist/utils/FormPage/getFormPage.test.js +0 -205
  282. package/dist/utils/FormPage/getFormPages.test.js +0 -98
  283. package/dist/utils/FormPage/getPageActions.test.js +0 -89
  284. package/dist/utils/FormPage/getParagraphFromText.test.js +0 -29
  285. package/dist/utils/FormPage/showFormPage.test.js +0 -182
  286. package/dist/utils/FormPage/showFormPageCYA.test.js +0 -30
  287. package/dist/utils/FormPage/useComponent.test.js +0 -169
  288. package/dist/utils/Format/formatData.test.js +0 -46
  289. package/dist/utils/Format/formatDataForComponent.test.js +0 -161
  290. package/dist/utils/Format/formatDataForForm.test.js +0 -78
  291. package/dist/utils/Format/formatDataForPage.test.js +0 -96
  292. package/dist/utils/Hub/getFormHub.test.js +0 -107
  293. package/dist/utils/Operate/checkValueIsTruthy.test.js +0 -44
  294. package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +0 -159
  295. package/dist/utils/Operate/persistValueInFormData.test.js +0 -106
  296. package/dist/utils/Operate/runPageOperations.test.js +0 -107
  297. package/dist/utils/Operate/setValueInFormData.test.js +0 -46
  298. package/dist/utils/Operate/shouldRun.test.js +0 -69
  299. package/dist/utils/Validate/validateCollection.test.js +0 -74
  300. package/dist/utils/Validate/validateComponent.test.js +0 -267
  301. package/dist/utils/Validate/validateContainer.test.js +0 -81
  302. package/dist/utils/Validate/validateDate.test.js +0 -118
  303. package/dist/utils/Validate/validateEmail.test.js +0 -57
  304. package/dist/utils/Validate/validatePage.test.js +0 -383
  305. package/dist/utils/Validate/validateRegex.test.js +0 -41
  306. package/dist/utils/Validate/validateRequired.test.js +0 -62
  307. package/dist/utils/Validate/validateTime.test.js +0 -61
@@ -1,423 +0,0 @@
1
- "use strict";
2
-
3
- var _react = require("@testing-library/react");
4
-
5
- var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
6
-
7
- var _react2 = _interopRequireDefault(require("react"));
8
-
9
- var _models = require("../../models");
10
-
11
- var _setupTests = require("../../setupTests");
12
-
13
- var _constants = require("../../utils/Meta/constants");
14
-
15
- var _Container = require("./Container");
16
-
17
- var _FormComponent = _interopRequireDefault(require("./FormComponent"));
18
-
19
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
-
21
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
22
-
23
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
24
-
25
- 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); } }
26
-
27
- 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); }); }; }
28
-
29
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
30
-
31
- describe('components.FormComponent.Container', function () {
32
- var _ID, _FORM_DATA;
33
-
34
- var ID = 'container';
35
- var NESTED_ID = 'nested';
36
- var TEXT_ID = 'text';
37
- var TEXT_VALUE = 'alpha';
38
- var NESTED_TEXT_VALUE = 'charlie';
39
- var FORM_DATA = (_FORM_DATA = {}, _defineProperty(_FORM_DATA, ID, (_ID = {}, _defineProperty(_ID, TEXT_ID, TEXT_VALUE), _defineProperty(_ID, NESTED_ID, _defineProperty({}, TEXT_ID, NESTED_TEXT_VALUE)), _ID)), _defineProperty(_FORM_DATA, _constants.META_PROPERTY, _defineProperty({}, _constants.META_DOCUMENTS_PROPERTY, [{
40
- field: 'epsilon.zeta',
41
- name: 'ez.jpg',
42
- type: 'image/jpg',
43
- extension: 'jpg',
44
- url: 'http://files.com/ez.jpg'
45
- }])), _FORM_DATA);
46
- var TEXT_COMPONENT = {
47
- id: TEXT_ID,
48
- fieldId: TEXT_ID,
49
- type: _models.ComponentTypes.TEXT,
50
- label: 'Text component',
51
- hint: 'Text hint'
52
- };
53
- it('should render a container component appropriately', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
54
- var CONTAINER, _renderWithValidation, container, c, formGroup, label, hint, input;
55
-
56
- return regeneratorRuntime.wrap(function _callee$(_context) {
57
- while (1) {
58
- switch (_context.prev = _context.next) {
59
- case 0:
60
- CONTAINER = {
61
- id: ID,
62
- fieldId: ID,
63
- type: _models.ComponentTypes.CONTAINER,
64
- components: [TEXT_COMPONENT]
65
- };
66
- _renderWithValidation = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_FormComponent.default, {
67
- component: CONTAINER,
68
- value: FORM_DATA[ID],
69
- formData: FORM_DATA
70
- })), container = _renderWithValidation.container; // Check the container itself.
71
-
72
- c = container.childNodes[0];
73
- expect(c.tagName).toEqual('DIV');
74
- expect(c.classList).toContain(_Container.DEFAULT_CLASS); // And now check the single text component within it.
75
-
76
- formGroup = c.childNodes[0];
77
- expect(formGroup.tagName).toEqual('DIV');
78
- expect(formGroup.classList).toContain('govuk-form-group');
79
- label = formGroup.childNodes[0];
80
- expect(label.tagName).toEqual('LABEL');
81
- expect(label.classList).toContain('govuk-label');
82
- expect(label.textContent).toEqual("".concat(TEXT_COMPONENT.label, " (optional)"));
83
- expect(label.getAttribute('for')).toEqual("".concat(ID, ".").concat(TEXT_ID));
84
- hint = formGroup.childNodes[1];
85
- expect(hint.tagName).toEqual('SPAN');
86
- expect(hint.classList).toContain('govuk-hint');
87
- expect(hint.textContent).toEqual(TEXT_COMPONENT.hint);
88
- input = formGroup.childNodes[2];
89
- expect(input.tagName).toEqual('INPUT');
90
- expect(input.classList).toContain('govuk-input');
91
- expect(input.id).toEqual("".concat(ID, ".").concat(TEXT_ID));
92
- expect(input.value).toEqual(TEXT_VALUE);
93
-
94
- case 22:
95
- case "end":
96
- return _context.stop();
97
- }
98
- }
99
- }, _callee);
100
- })));
101
- it('should render a nested container component appropriately', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
102
- var CONTAINER, _renderWithValidation2, container, c, nested, formGroup, label, hint, input;
103
-
104
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
105
- while (1) {
106
- switch (_context2.prev = _context2.next) {
107
- case 0:
108
- CONTAINER = {
109
- id: ID,
110
- fieldId: ID,
111
- type: _models.ComponentTypes.CONTAINER,
112
- components: [{
113
- id: NESTED_ID,
114
- fieldId: NESTED_ID,
115
- type: _models.ComponentTypes.CONTAINER,
116
- components: [TEXT_COMPONENT]
117
- }]
118
- };
119
- _renderWithValidation2 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_FormComponent.default, {
120
- component: CONTAINER,
121
- value: FORM_DATA[ID],
122
- formData: FORM_DATA
123
- })), container = _renderWithValidation2.container; // Check the container itself.
124
-
125
- c = container.childNodes[0];
126
- expect(c.tagName).toEqual('DIV');
127
- expect(c.classList).toContain(_Container.DEFAULT_CLASS); // Check the nested container.
128
-
129
- nested = c.childNodes[0];
130
- expect(nested.tagName).toEqual('DIV');
131
- expect(nested.classList).toContain(_Container.DEFAULT_CLASS); // And now check the single text component within the nested container.
132
-
133
- formGroup = nested.childNodes[0];
134
- expect(formGroup.tagName).toEqual('DIV');
135
- expect(formGroup.classList).toContain('govuk-form-group');
136
- label = formGroup.childNodes[0];
137
- expect(label.tagName).toEqual('LABEL');
138
- expect(label.classList).toContain('govuk-label');
139
- expect(label.textContent).toEqual("".concat(TEXT_COMPONENT.label, " (optional)"));
140
- expect(label.getAttribute('for')).toEqual("".concat(ID, ".").concat(NESTED_ID, ".").concat(TEXT_ID));
141
- hint = formGroup.childNodes[1];
142
- expect(hint.tagName).toEqual('SPAN');
143
- expect(hint.classList).toContain('govuk-hint');
144
- expect(hint.textContent).toEqual(TEXT_COMPONENT.hint);
145
- input = formGroup.childNodes[2];
146
- expect(input.tagName).toEqual('INPUT');
147
- expect(input.classList).toContain('govuk-input');
148
- expect(input.id).toEqual("".concat(ID, ".").concat(NESTED_ID, ".").concat(TEXT_ID));
149
- expect(input.value).toEqual(NESTED_TEXT_VALUE);
150
-
151
- case 25:
152
- case "end":
153
- return _context2.stop();
154
- }
155
- }
156
- }, _callee2);
157
- })));
158
- it('should handle a change to a component appropriately', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
159
- var ON_CHANGE_EVENTS, ON_CHANGE, CONTAINER, _renderWithValidation3, container, c, formGroup, input, NEW_TEXT_VALUE, EVENT;
160
-
161
- return regeneratorRuntime.wrap(function _callee3$(_context3) {
162
- while (1) {
163
- switch (_context3.prev = _context3.next) {
164
- case 0:
165
- ON_CHANGE_EVENTS = [];
166
-
167
- ON_CHANGE = function ON_CHANGE(e) {
168
- ON_CHANGE_EVENTS.push(e);
169
- };
170
-
171
- CONTAINER = {
172
- id: ID,
173
- fieldId: ID,
174
- type: _models.ComponentTypes.CONTAINER,
175
- components: [{
176
- id: TEXT_ID,
177
- fieldId: TEXT_ID,
178
- type: _models.ComponentTypes.TEXT,
179
- label: 'Text component'
180
- }]
181
- };
182
- _renderWithValidation3 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_FormComponent.default, {
183
- component: CONTAINER,
184
- value: FORM_DATA[ID],
185
- formData: FORM_DATA,
186
- onChange: ON_CHANGE
187
- })), container = _renderWithValidation3.container; // Get hold of the text input.
188
-
189
- c = container.childNodes[0];
190
- formGroup = c.childNodes[0];
191
- input = formGroup.childNodes[2];
192
- NEW_TEXT_VALUE = 'bravo';
193
- EVENT = {
194
- target: {
195
- name: TEXT_ID,
196
- value: NEW_TEXT_VALUE
197
- }
198
- };
199
-
200
- _react.fireEvent.change(input, EVENT); // And confirm the formData has been changed.
201
-
202
-
203
- expect(ON_CHANGE_EVENTS.length).toEqual(1);
204
- expect(ON_CHANGE_EVENTS[0].target.name).toEqual(ID);
205
- expect(ON_CHANGE_EVENTS[0].target.value[TEXT_ID]).toEqual(NEW_TEXT_VALUE);
206
-
207
- case 13:
208
- case "end":
209
- return _context3.stop();
210
- }
211
- }
212
- }, _callee3);
213
- })));
214
- it('should handle a change to a file type component appropriately', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
215
- var FILE_ID, ON_CHANGE_EVENTS, ON_CHANGE, ON_TOP_LEVEL_CHANGE_EVENTS, ON_TOP_LEVEL_CHANGE, CONTAINER, _renderWithValidation4, container, c, formGroup, input, FILE_EXTENSION, FILE_NAME, FILE_TYPE, str, blob, FILE, containerChangeValue, metaChangeValue;
216
-
217
- return regeneratorRuntime.wrap(function _callee4$(_context4) {
218
- while (1) {
219
- switch (_context4.prev = _context4.next) {
220
- case 0:
221
- FILE_ID = 'file';
222
- ON_CHANGE_EVENTS = [];
223
-
224
- ON_CHANGE = function ON_CHANGE(e) {
225
- ON_CHANGE_EVENTS.push(e);
226
- };
227
-
228
- ON_TOP_LEVEL_CHANGE_EVENTS = [];
229
-
230
- ON_TOP_LEVEL_CHANGE = function ON_TOP_LEVEL_CHANGE(e) {
231
- ON_TOP_LEVEL_CHANGE_EVENTS.push(e);
232
- };
233
-
234
- CONTAINER = {
235
- id: ID,
236
- fieldId: ID,
237
- type: _models.ComponentTypes.CONTAINER,
238
- components: [{
239
- id: FILE_ID,
240
- fieldId: FILE_ID,
241
- full_path: "".concat(ID, ".").concat(FILE_ID),
242
- type: _models.ComponentTypes.FILE,
243
- label: 'File component'
244
- }]
245
- };
246
- _renderWithValidation4 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_FormComponent.default, {
247
- component: CONTAINER,
248
- value: FORM_DATA[ID],
249
- formData: FORM_DATA,
250
- onChange: ON_CHANGE,
251
- onTopLevelChange: ON_TOP_LEVEL_CHANGE
252
- })), container = _renderWithValidation4.container; // Get hold of the text input.
253
-
254
- c = container.childNodes[0];
255
- formGroup = c.childNodes[0];
256
- input = formGroup.childNodes[2].childNodes[0];
257
- FILE_EXTENSION = 'json';
258
- FILE_NAME = "test.".concat(FILE_EXTENSION);
259
- FILE_TYPE = 'application/JSON';
260
- str = JSON.stringify({
261
- alpha: 'bravo'
262
- });
263
- blob = new Blob([str]);
264
- FILE = new File([blob], FILE_NAME, {
265
- type: FILE_TYPE
266
- });
267
-
268
- _userEvent.default.upload(input, FILE); // Expect one call for the regular onChange event, this can change
269
- // depending on whether the Container is on a normal page or regular page.
270
-
271
-
272
- expect(ON_CHANGE_EVENTS.length).toEqual(1);
273
- expect(ON_CHANGE_EVENTS[0].target.name).toEqual(ID); // Expect one call for changing the meta data at top level formData.
274
- // Meta changes should occur at top-level regardless of where the component is.
275
-
276
- expect(ON_TOP_LEVEL_CHANGE_EVENTS.length).toEqual(1);
277
- expect(ON_TOP_LEVEL_CHANGE_EVENTS[0].target.name).toEqual(_constants.META_PROPERTY);
278
- containerChangeValue = JSON.parse(JSON.stringify(ON_CHANGE_EVENTS[0].target.value));
279
- metaChangeValue = JSON.parse(JSON.stringify(ON_TOP_LEVEL_CHANGE_EVENTS[0].target.value));
280
- expect(metaChangeValue.documents.length).toEqual(2); // Existing one, plus this new one.
281
-
282
- expect(metaChangeValue.documents[1]).toMatchObject(_objectSpread(_objectSpread({}, containerChangeValue[FILE_ID]), {}, {
283
- field: "".concat(ID, ".").concat(FILE_ID)
284
- }));
285
-
286
- case 25:
287
- case "end":
288
- return _context4.stop();
289
- }
290
- }
291
- }, _callee4);
292
- })));
293
- it('should handle a null value appropriately', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {
294
- var CONTAINER, _renderWithValidation5, container, c, formGroup, label, hint, input;
295
-
296
- return regeneratorRuntime.wrap(function _callee5$(_context5) {
297
- while (1) {
298
- switch (_context5.prev = _context5.next) {
299
- case 0:
300
- CONTAINER = {
301
- id: ID,
302
- fieldId: ID,
303
- type: _models.ComponentTypes.CONTAINER,
304
- components: [TEXT_COMPONENT]
305
- };
306
- _renderWithValidation5 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_FormComponent.default, {
307
- component: CONTAINER
308
- })), container = _renderWithValidation5.container; // Check the container itself.
309
-
310
- c = container.childNodes[0];
311
- expect(c.tagName).toEqual('DIV');
312
- expect(c.classList).toContain(_Container.DEFAULT_CLASS); // And now check the single text component within it.
313
-
314
- formGroup = c.childNodes[0];
315
- expect(formGroup.tagName).toEqual('DIV');
316
- expect(formGroup.classList).toContain('govuk-form-group');
317
- label = formGroup.childNodes[0];
318
- expect(label.tagName).toEqual('LABEL');
319
- expect(label.classList).toContain('govuk-label');
320
- expect(label.textContent).toEqual("".concat(TEXT_COMPONENT.label, " (optional)"));
321
- expect(label.getAttribute('for')).toEqual("".concat(ID, ".").concat(TEXT_ID));
322
- hint = formGroup.childNodes[1];
323
- expect(hint.tagName).toEqual('SPAN');
324
- expect(hint.classList).toContain('govuk-hint');
325
- expect(hint.textContent).toEqual(TEXT_COMPONENT.hint);
326
- input = formGroup.childNodes[2];
327
- expect(input.tagName).toEqual('INPUT');
328
- expect(input.classList).toContain('govuk-input');
329
- expect(input.id).toEqual("".concat(ID, ".").concat(TEXT_ID));
330
- expect(input.value).toEqual('');
331
-
332
- case 22:
333
- case "end":
334
- return _context5.stop();
335
- }
336
- }
337
- }, _callee5);
338
- })));
339
- it('should handle a className attribute appropriately', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {
340
- var CLASS_NAME, CONTAINER, _renderWithValidation6, container, c;
341
-
342
- return regeneratorRuntime.wrap(function _callee6$(_context6) {
343
- while (1) {
344
- switch (_context6.prev = _context6.next) {
345
- case 0:
346
- CLASS_NAME = 'alpha-bravo';
347
- CONTAINER = {
348
- id: ID,
349
- fieldId: ID,
350
- type: _models.ComponentTypes.CONTAINER,
351
- components: [TEXT_COMPONENT],
352
- className: CLASS_NAME
353
- };
354
- _renderWithValidation6 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_FormComponent.default, {
355
- component: CONTAINER,
356
- value: FORM_DATA[ID],
357
- formData: FORM_DATA
358
- })), container = _renderWithValidation6.container; // Check the container itself.
359
-
360
- c = container.childNodes[0];
361
- expect(c.tagName).toEqual('DIV');
362
- expect(c.classList).toContain(_Container.DEFAULT_CLASS);
363
- expect(c.classList).toContain(CLASS_NAME);
364
-
365
- case 7:
366
- case "end":
367
- return _context6.stop();
368
- }
369
- }
370
- }, _callee6);
371
- })));
372
- it('should appropriately make child components readonly', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7() {
373
- var CONTAINER, _renderWithValidation7, container, c, formGroup, label, hint, input;
374
-
375
- return regeneratorRuntime.wrap(function _callee7$(_context7) {
376
- while (1) {
377
- switch (_context7.prev = _context7.next) {
378
- case 0:
379
- CONTAINER = {
380
- id: ID,
381
- fieldId: ID,
382
- type: _models.ComponentTypes.CONTAINER,
383
- components: [TEXT_COMPONENT],
384
- readonly: true
385
- };
386
- _renderWithValidation7 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_FormComponent.default, {
387
- component: CONTAINER,
388
- value: FORM_DATA[ID],
389
- formData: FORM_DATA
390
- })), container = _renderWithValidation7.container; // Check the container itself.
391
-
392
- c = container.childNodes[0];
393
- expect(c.tagName).toEqual('DIV');
394
- expect(c.classList).toContain(_Container.DEFAULT_CLASS); // And now check the single text component within it.
395
-
396
- formGroup = c.childNodes[0];
397
- expect(formGroup.tagName).toEqual('DIV');
398
- expect(formGroup.classList).toContain('govuk-form-group');
399
- label = formGroup.childNodes[0];
400
- expect(label.tagName).toEqual('LABEL');
401
- expect(label.classList).toContain('govuk-label');
402
- expect(label.textContent).toEqual("".concat(TEXT_COMPONENT.label, " (optional)"));
403
- expect(label.getAttribute('for')).toEqual("".concat(ID, ".").concat(TEXT_ID));
404
- hint = formGroup.childNodes[1];
405
- expect(hint.tagName).toEqual('SPAN');
406
- expect(hint.classList).toContain('govuk-hint');
407
- expect(hint.textContent).toEqual(TEXT_COMPONENT.hint);
408
- input = formGroup.childNodes[2];
409
- expect(input.tagName).toEqual('DIV'); // Now readonly, so a DIV.
410
-
411
- expect(input.classList).toContain('hods-readonly'); // Now readonly, so hods-readonly
412
-
413
- expect(input.id).toEqual("".concat(ID, ".").concat(TEXT_ID));
414
- expect(input.textContent).toEqual(TEXT_VALUE);
415
-
416
- case 22:
417
- case "end":
418
- return _context7.stop();
419
- }
420
- }
421
- }, _callee7);
422
- })));
423
- });
@@ -1,184 +0,0 @@
1
- <!-- Global imports -->
2
- import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs';
3
- import { Details, Heading, Link } from '@ukhomeoffice/cop-react-components';
4
- import withMock from 'storybook-addon-mock';
5
-
6
- <!-- Local imports -->
7
- import { HooksContextProvider, ValidationContextProvider } from '../../context';
8
- import FormComponent from './FormComponent';
9
-
10
- <!-- JSON documents -->
11
- import CIVIL_SERVANT from '../../json/areYouACivilServant.json';
12
- import GRADE from '../../json/grade.json';
13
- import TEAMS from '../../json/team.json';
14
- import USER_PROFILE_DATA from '../../json/userProfile.data.json';
15
- import USER_PROFILE from '../../json/userProfile.json';
16
-
17
- <Meta title="Components/Form component" id="D-FormComponent" component={ FormComponent } decorators={[withMock]} />
18
-
19
- <Heading size="xl" caption="Components">Form component</Heading>
20
-
21
- Renders a single component on a form with <Link href="https://ukhomeoffice.github.io/cop-react-components/?path=/docs/d-alert--default-story">COP React components</Link>,
22
- on the basis of a <Link href="/?path=/docs/f-json-component">JSON</Link> configuration.
23
-
24
- <Canvas withToolbar>
25
- <Story name="Default" parameters={{
26
- mockData: [
27
- {
28
- url: `${USER_PROFILE_DATA.urls.refData}/areYouACivilServant`,
29
- method: 'GET',
30
- status: 200,
31
- response: CIVIL_SERVANT
32
- },
33
- {
34
- url: `${USER_PROFILE_DATA.urls.refData}/grade`,
35
- method: 'GET',
36
- status: 200,
37
- response: GRADE
38
- },
39
- {
40
- url: `${USER_PROFILE_DATA.urls.refData}/team`,
41
- method: 'GET',
42
- status: 200,
43
- response: TEAMS
44
- }
45
- ]
46
- }}>
47
- {() => {
48
- const COMPONENT = {
49
- ...USER_PROFILE.components.find(c => c.id === 'areYouACivilServant'),
50
- data: {
51
- url: `${USER_PROFILE_DATA.urls.refData}/areYouACivilServant`
52
- }
53
- };
54
- const ON_CHANGE = ({ target }) => {
55
- // Do something with the target here.
56
- };
57
- return (
58
- <HooksContextProvider>
59
- <ValidationContextProvider>
60
- <FormComponent component={COMPONENT} value={''} onChange={ON_CHANGE} />
61
- </ValidationContextProvider>
62
- </HooksContextProvider>
63
- );
64
- }}
65
- </Story>
66
- </Canvas>
67
-
68
- <Details summary="Properties" className="no-indent">
69
- <ArgsTable of={ FormComponent } />
70
- </Details>
71
-
72
-
73
- ## Variants
74
- ### `autocomplete`
75
- <Canvas>
76
- <Story name="Autocomplete" parameters={{
77
- mockData: [
78
- {
79
- url: `${USER_PROFILE_DATA.urls.refData}/areYouACivilServant`,
80
- method: 'GET',
81
- status: 200,
82
- response: CIVIL_SERVANT
83
- },
84
- {
85
- url: `${USER_PROFILE_DATA.urls.refData}/grade`,
86
- method: 'GET',
87
- status: 200,
88
- response: GRADE
89
- },
90
- {
91
- url: `${USER_PROFILE_DATA.urls.refData}/team`,
92
- method: 'GET',
93
- status: 200,
94
- response: TEAMS
95
- }
96
- ]
97
- }}>
98
- {() => {
99
- const COMPONENT = {
100
- ...USER_PROFILE.components.find(c => c.id === 'team'),
101
- data: {
102
- url: `${USER_PROFILE_DATA.urls.refData}/team`
103
- }
104
- };
105
- const ON_CHANGE = ({ target }) => {
106
- // Do something with the target here.
107
- };
108
- return (
109
- <HooksContextProvider>
110
- <ValidationContextProvider>
111
- <FormComponent component={COMPONENT} value={''} onChange={ON_CHANGE} />
112
- </ValidationContextProvider>
113
- </HooksContextProvider>
114
- );
115
- }}
116
- </Story>
117
- </Canvas>
118
-
119
- ### `html`
120
-
121
- <Canvas>
122
- <Story name="HTML">
123
- {() => {
124
- const COMPONENT = { type: 'html', tagName: 'p', content: 'A paragraph of text to render' };
125
- const ON_CHANGE = ({ target }) => {
126
- // Do something with the target here.
127
- };
128
- return (
129
- <HooksContextProvider>
130
- <ValidationContextProvider>
131
- <FormComponent component={COMPONENT} value={''} onChange={ON_CHANGE} />
132
- </ValidationContextProvider>
133
- </HooksContextProvider>
134
- );
135
- }}
136
- </Story>
137
- </Canvas>
138
-
139
- ### Unwrapped `autocomplete`
140
- <Canvas>
141
- <Story name="Unwrapped autocomplete" parameters={{
142
- mockData: [
143
- {
144
- url: `${USER_PROFILE_DATA.urls.refData}/areYouACivilServant`,
145
- method: 'GET',
146
- status: 200,
147
- response: CIVIL_SERVANT
148
- },
149
- {
150
- url: `${USER_PROFILE_DATA.urls.refData}/grade`,
151
- method: 'GET',
152
- status: 200,
153
- response: GRADE
154
- },
155
- {
156
- url: `${USER_PROFILE_DATA.urls.refData}/team`,
157
- method: 'GET',
158
- status: 200,
159
- response: TEAMS
160
- }
161
- ]
162
- }}>
163
- {() => {
164
- const COMPONENT = {
165
- ...USER_PROFILE.components.find(c => c.id === 'team'),
166
- id: 'team2',
167
- fieldId: 'team2',
168
- data: {
169
- url: `${USER_PROFILE_DATA.urls.refData}/team`
170
- }
171
- };
172
- const ON_CHANGE = ({ target }) => {
173
- // Do something with the target here.
174
- };
175
- return (
176
- <HooksContextProvider>
177
- <ValidationContextProvider>
178
- <FormComponent component={COMPONENT} value={''} wrap={false} onChange={ON_CHANGE} />
179
- </ValidationContextProvider>
180
- </HooksContextProvider>
181
- );
182
- }}
183
- </Story>
184
- </Canvas>