@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.
- package/LICENSE +21 -0
- package/README.md +12 -0
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +16 -5
- package/dist/components/CheckYourAnswers/CheckYourAnswers.stories.mdx +199 -79
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +44 -0
- package/dist/components/FormComponent/FormComponent.js +6 -1
- package/dist/components/FormComponent/FormComponent.test.js +67 -0
- package/dist/components/FormRenderer/FormRenderer.js +122 -11
- package/dist/components/FormRenderer/FormRenderer.stories.mdx +115 -49
- package/dist/components/FormRenderer/FormRenderer.test.js +275 -0
- package/dist/components/FormRenderer/helpers/getNextPageId.js +3 -0
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +6 -0
- package/dist/components/FormRenderer/helpers/getPage.js +1 -1
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +18 -1
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +44 -6
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +50 -0
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +122 -0
- package/dist/components/FormRenderer/helpers/index.js +7 -1
- package/dist/components/SummaryList/SummaryList.js +7 -4
- package/dist/components/SummaryList/SummaryList.scss +10 -2
- package/dist/components/SummaryList/SummaryList.stories.mdx +64 -10
- package/dist/components/SummaryList/SummaryList.test.js +54 -0
- package/dist/components/TaskList/Task.js +83 -0
- package/dist/components/TaskList/Task.test.js +112 -0
- package/dist/components/TaskList/TaskList.js +112 -0
- package/dist/components/TaskList/TaskList.scss +70 -0
- package/dist/components/TaskList/TaskList.stories.mdx +57 -0
- package/dist/components/TaskList/TaskList.test.js +223 -0
- package/dist/components/TaskList/TaskState.js +42 -0
- package/dist/components/TaskList/TaskState.test.js +99 -0
- package/dist/components/TaskList/index.js +13 -0
- package/dist/hooks/useHooks.js +5 -1
- package/dist/index.js +8 -0
- package/dist/json/taskList.json +228 -0
- package/dist/json/userProfile.data.json +2 -1
- package/dist/models/ComponentTypes.js +3 -1
- package/dist/models/FormTypes.js +2 -0
- package/dist/models/HubFormats.js +3 -1
- package/dist/models/PageAction.js +5 -0
- package/dist/models/TaskStates.js +41 -0
- package/dist/models/index.js +8 -0
- package/dist/utils/Component/cleanAttributes.js +1 -1
- package/dist/utils/Component/getComponent.js +26 -0
- package/dist/utils/Component/isEditable.js +1 -1
- package/dist/utils/FormPage/getPageActions.js +6 -0
- package/dist/utils/Hub/getFormHub.js +4 -0
- package/dist/utils/Hub/getFormHub.test.js +10 -2
- package/dist/utils/Validate/additional/index.js +55 -0
- package/dist/utils/Validate/additional/index.test.js +69 -0
- package/dist/utils/Validate/additional/mustBeAfter.js +37 -0
- package/dist/utils/Validate/additional/mustBeAfter.test.js +98 -0
- package/dist/utils/Validate/additional/mustBeBefore.js +35 -0
- package/dist/utils/Validate/additional/mustBeBefore.test.js +66 -0
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +42 -0
- package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +34 -0
- package/dist/utils/Validate/additional/mustBeInThePast.js +44 -0
- package/dist/utils/Validate/additional/mustBeInThePast.test.js +34 -0
- package/dist/utils/Validate/additional/utils.js +66 -0
- package/dist/utils/Validate/validateComponent.js +38 -1
- package/dist/utils/Validate/validateComponent.test.js +48 -2
- package/dist/utils/Validate/validateDate.js +144 -0
- package/dist/utils/Validate/validateDate.test.js +112 -0
- package/dist/utils/Validate/validateRequired.js +11 -0
- package/dist/utils/Validate/validateRequired.test.js +12 -0
- package/dist/utils/Validate/validateTime.js +76 -0
- package/dist/utils/Validate/validateTime.test.js +55 -0
- 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.
|
|
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.
|
|
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
|
},
|