@ukhomeoffice/cop-react-form-renderer 2.0.0 → 2.5.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.
Files changed (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +12 -0
  3. package/dist/components/CheckYourAnswers/CheckYourAnswers.js +16 -5
  4. package/dist/components/CheckYourAnswers/CheckYourAnswers.stories.mdx +199 -79
  5. package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +44 -0
  6. package/dist/components/FormComponent/FormComponent.js +6 -1
  7. package/dist/components/FormComponent/FormComponent.test.js +67 -0
  8. package/dist/components/FormRenderer/FormRenderer.js +122 -11
  9. package/dist/components/FormRenderer/FormRenderer.stories.mdx +115 -49
  10. package/dist/components/FormRenderer/FormRenderer.test.js +275 -0
  11. package/dist/components/FormRenderer/helpers/getNextPageId.js +3 -0
  12. package/dist/components/FormRenderer/helpers/getNextPageId.test.js +6 -0
  13. package/dist/components/FormRenderer/helpers/getPage.js +1 -1
  14. package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +18 -1
  15. package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +44 -6
  16. package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +50 -0
  17. package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +122 -0
  18. package/dist/components/FormRenderer/helpers/index.js +7 -1
  19. package/dist/components/SummaryList/SummaryList.js +7 -4
  20. package/dist/components/SummaryList/SummaryList.scss +10 -2
  21. package/dist/components/SummaryList/SummaryList.stories.mdx +64 -10
  22. package/dist/components/SummaryList/SummaryList.test.js +54 -0
  23. package/dist/components/TaskList/Task.js +83 -0
  24. package/dist/components/TaskList/Task.test.js +112 -0
  25. package/dist/components/TaskList/TaskList.js +112 -0
  26. package/dist/components/TaskList/TaskList.scss +70 -0
  27. package/dist/components/TaskList/TaskList.stories.mdx +57 -0
  28. package/dist/components/TaskList/TaskList.test.js +223 -0
  29. package/dist/components/TaskList/TaskState.js +42 -0
  30. package/dist/components/TaskList/TaskState.test.js +99 -0
  31. package/dist/components/TaskList/index.js +13 -0
  32. package/dist/hooks/useHooks.js +5 -1
  33. package/dist/index.js +8 -0
  34. package/dist/json/taskList.json +228 -0
  35. package/dist/json/userProfile.data.json +2 -1
  36. package/dist/models/ComponentTypes.js +3 -1
  37. package/dist/models/FormTypes.js +2 -0
  38. package/dist/models/HubFormats.js +3 -1
  39. package/dist/models/PageAction.js +5 -0
  40. package/dist/models/TaskStates.js +41 -0
  41. package/dist/models/index.js +8 -0
  42. package/dist/utils/Component/cleanAttributes.js +1 -1
  43. package/dist/utils/Component/getComponent.js +26 -0
  44. package/dist/utils/Component/isEditable.js +1 -1
  45. package/dist/utils/FormPage/getPageActions.js +6 -0
  46. package/dist/utils/Hub/getFormHub.js +4 -0
  47. package/dist/utils/Hub/getFormHub.test.js +10 -2
  48. package/dist/utils/Validate/additional/index.js +55 -0
  49. package/dist/utils/Validate/additional/index.test.js +69 -0
  50. package/dist/utils/Validate/additional/mustBeAfter.js +37 -0
  51. package/dist/utils/Validate/additional/mustBeAfter.test.js +98 -0
  52. package/dist/utils/Validate/additional/mustBeBefore.js +35 -0
  53. package/dist/utils/Validate/additional/mustBeBefore.test.js +66 -0
  54. package/dist/utils/Validate/additional/mustBeInTheFuture.js +42 -0
  55. package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +34 -0
  56. package/dist/utils/Validate/additional/mustBeInThePast.js +44 -0
  57. package/dist/utils/Validate/additional/mustBeInThePast.test.js +34 -0
  58. package/dist/utils/Validate/additional/utils.js +66 -0
  59. package/dist/utils/Validate/validateComponent.js +38 -1
  60. package/dist/utils/Validate/validateComponent.test.js +48 -2
  61. package/dist/utils/Validate/validateDate.js +144 -0
  62. package/dist/utils/Validate/validateDate.test.js +112 -0
  63. package/dist/utils/Validate/validateRequired.js +11 -0
  64. package/dist/utils/Validate/validateRequired.test.js +12 -0
  65. package/dist/utils/Validate/validateTime.js +76 -0
  66. package/dist/utils/Validate/validateTime.test.js +55 -0
  67. package/package.json +3 -2
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ var _validateTime = _interopRequireDefault(require("./validateTime"));
4
+
5
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6
+
7
+ describe('utils', function () {
8
+ describe('Validate', function () {
9
+ describe('time', function () {
10
+ test('should return undefined if a time string is valid', function () {
11
+ var output = (0, _validateTime.default)('14:30');
12
+ expect(output).toEqual({
13
+ message: undefined,
14
+ propsInError: undefined
15
+ });
16
+ });
17
+ test('should return an error if no hour is given', function () {
18
+ var output = (0, _validateTime.default)(':30');
19
+ expect(output).toEqual({
20
+ message: 'Time must include a hour',
21
+ propsInError: {
22
+ hour: true
23
+ }
24
+ });
25
+ });
26
+ test('should return an error if the hour is not between 0 and 23', function () {
27
+ var output = (0, _validateTime.default)('35:30');
28
+ expect(output).toEqual({
29
+ message: 'Hour must be between 0 and 23',
30
+ propsInError: {
31
+ hour: true
32
+ }
33
+ });
34
+ });
35
+ test('should return an error if no minute is given', function () {
36
+ var output = (0, _validateTime.default)('14:');
37
+ expect(output).toEqual({
38
+ message: 'Time must include a minute',
39
+ propsInError: {
40
+ minute: true
41
+ }
42
+ });
43
+ });
44
+ test('should return an error if the minute is not between 0 and 59', function () {
45
+ var output = (0, _validateTime.default)('14:75');
46
+ expect(output).toEqual({
47
+ message: 'Minute must be between 0 and 59',
48
+ propsInError: {
49
+ minute: true
50
+ }
51
+ });
52
+ });
53
+ });
54
+ });
55
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ukhomeoffice/cop-react-form-renderer",
3
- "version": "2.0.0",
3
+ "version": "2.5.0",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "clean": "rimraf dist",
@@ -16,8 +16,9 @@
16
16
  "post-compile": "rimraf dist/*.test.* dist/**/*.test.* dist/**/*.stories.* dist/docs dist/assets"
17
17
  },
18
18
  "dependencies": {
19
- "@ukhomeoffice/cop-react-components": "1.1.2",
19
+ "@ukhomeoffice/cop-react-components": "1.2.0",
20
20
  "axios": "^0.21.1",
21
+ "dayjs": "^1.11.0",
21
22
  "govuk-frontend": "^3.13.0",
22
23
  "web-vitals": "^1.0.1"
23
24
  },