@ukhomeoffice/cop-react-form-renderer 2.2.0 → 2.6.1-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/FormComponent/Container.test.js +250 -0
- package/dist/components/FormComponent/FormComponent.js +101 -22
- package/dist/components/FormPage/FormPage.js +2 -1
- package/dist/components/FormRenderer/FormRenderer.js +105 -6
- package/dist/components/FormRenderer/FormRenderer.test.js +235 -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/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/index.js +19 -1
- package/dist/json/taskList.json +228 -0
- package/dist/json/userProfile.data.json +2 -1
- package/dist/models/ComponentTypes.js +5 -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/CheckYourAnswers/getCYARowsForContainer.js +40 -0
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +257 -0
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +9 -1
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +44 -0
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +6 -0
- package/dist/utils/Component/cleanAttributes.js +1 -1
- package/dist/utils/Component/getComponent.js +8 -0
- package/dist/utils/Component/isEditable.js +1 -1
- package/dist/utils/Component/showComponent.js +2 -20
- package/dist/utils/Condition/index.js +19 -0
- package/dist/utils/Condition/meetsAllConditions.js +40 -0
- package/dist/utils/Condition/meetsAllConditions.test.js +62 -0
- package/dist/utils/{meetsCondition.js → Condition/meetsCondition.js} +0 -0
- package/dist/utils/Condition/meetsCondition.test.js +302 -0
- package/dist/utils/Condition/setupConditions.js +47 -0
- package/dist/utils/Condition/setupConditions.test.js +35 -0
- package/dist/utils/Container/getEditableComponents.js +38 -0
- package/dist/utils/Container/getEditableComponents.test.js +157 -0
- package/dist/utils/Container/index.js +22 -0
- package/dist/utils/Container/setupNesting.js +45 -0
- package/dist/utils/Container/setupNesting.test.js +92 -0
- package/dist/utils/Container/showContainer.js +61 -0
- package/dist/utils/Container/showContainer.test.js +128 -0
- package/dist/utils/Data/getDataPath.js +90 -0
- package/dist/utils/Data/getDataPath.test.js +52 -0
- package/dist/utils/Data/index.js +3 -0
- package/dist/utils/FormPage/getFormPage.js +4 -2
- package/dist/utils/FormPage/getFormPage.test.js +18 -7
- package/dist/utils/FormPage/getFormPages.test.js +5 -2
- package/dist/utils/FormPage/getPageActions.js +6 -0
- package/dist/utils/FormPage/index.js +0 -3
- package/dist/utils/FormPage/showFormPage.js +7 -27
- package/dist/utils/Hub/getFormHub.js +4 -0
- package/dist/utils/Hub/getFormHub.test.js +15 -4
- 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/index.js +7 -1
- package/dist/utils/Validate/validateComponent.js +57 -0
- package/dist/utils/Validate/validateComponent.test.js +92 -2
- package/dist/utils/Validate/validateDate.js +155 -0
- package/dist/utils/Validate/validateDate.test.js +118 -0
- package/dist/utils/Validate/validatePage.js +6 -8
- package/dist/utils/Validate/validateTime.js +95 -0
- package/dist/utils/Validate/validateTime.test.js +61 -0
- package/dist/utils/index.js +6 -3
- package/package.json +5 -4
- package/dist/utils/FormPage/getEditableComponents.js +0 -28
- package/dist/utils/FormPage/getEditableComponents.test.js +0 -75
package/dist/utils/index.js
CHANGED
|
@@ -11,6 +11,10 @@ var _CheckYourAnswers = _interopRequireDefault(require("./CheckYourAnswers"));
|
|
|
11
11
|
|
|
12
12
|
var _Component = _interopRequireDefault(require("./Component"));
|
|
13
13
|
|
|
14
|
+
var _Condition = _interopRequireDefault(require("./Condition"));
|
|
15
|
+
|
|
16
|
+
var _Container = _interopRequireDefault(require("./Container"));
|
|
17
|
+
|
|
14
18
|
var _Data = _interopRequireDefault(require("./Data"));
|
|
15
19
|
|
|
16
20
|
var _Format = _interopRequireDefault(require("./Format"));
|
|
@@ -19,8 +23,6 @@ var _FormPage = _interopRequireDefault(require("./FormPage"));
|
|
|
19
23
|
|
|
20
24
|
var _Hub = _interopRequireDefault(require("./Hub"));
|
|
21
25
|
|
|
22
|
-
var _meetsCondition = _interopRequireDefault(require("./meetsCondition"));
|
|
23
|
-
|
|
24
26
|
var _Validate = _interopRequireDefault(require("./Validate"));
|
|
25
27
|
|
|
26
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -34,11 +36,12 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
34
36
|
var Utils = _objectSpread({
|
|
35
37
|
CheckYourAnswers: _CheckYourAnswers.default,
|
|
36
38
|
Component: _Component.default,
|
|
39
|
+
Container: _Container.default,
|
|
37
40
|
Data: _Data.default,
|
|
38
41
|
Format: _Format.default,
|
|
39
42
|
FormPage: _FormPage.default,
|
|
40
43
|
Hub: _Hub.default,
|
|
41
|
-
|
|
44
|
+
Condition: _Condition.default,
|
|
42
45
|
Validate: _Validate.default
|
|
43
46
|
}, _copReactComponents.Utils);
|
|
44
47
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ukhomeoffice/cop-react-form-renderer",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.1-alpha",
|
|
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
|
},
|
|
@@ -51,8 +52,8 @@
|
|
|
51
52
|
"storybook-addon-mock": "^2.0.1"
|
|
52
53
|
},
|
|
53
54
|
"peerDependencies": {
|
|
54
|
-
"react": "
|
|
55
|
-
"react-dom": "
|
|
55
|
+
"react": ">=16.13.1",
|
|
56
|
+
"react-dom": ">=16.13.1",
|
|
56
57
|
"react-scripts": "4.0.3"
|
|
57
58
|
},
|
|
58
59
|
"optionalDependencies": {
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _Component = _interopRequireDefault(require("../Component"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Gets all the editable components on a page.
|
|
14
|
-
* @param {object} page The page to consider.
|
|
15
|
-
* @returns An array of ONLY the editable components on a page.
|
|
16
|
-
*/
|
|
17
|
-
var getEditableComponents = function getEditableComponents(page) {
|
|
18
|
-
if (page && Array.isArray(page.components)) {
|
|
19
|
-
return page.components.filter(function (c) {
|
|
20
|
-
return _Component.default.editable(c);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return [];
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
var _default = getEditableComponents;
|
|
28
|
-
exports.default = _default;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _getEditableComponents = _interopRequireDefault(require("./getEditableComponents"));
|
|
4
|
-
|
|
5
|
-
var _isEditable = require("../Component/isEditable");
|
|
6
|
-
|
|
7
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
-
|
|
9
|
-
describe('utils', function () {
|
|
10
|
-
describe('FormPage', function () {
|
|
11
|
-
describe('getEditableComponents', function () {
|
|
12
|
-
var HTML = {
|
|
13
|
-
type: 'html',
|
|
14
|
-
tagName: 'p',
|
|
15
|
-
content: 'Alpha'
|
|
16
|
-
};
|
|
17
|
-
var INSET_TEXT = {
|
|
18
|
-
type: 'inset-text',
|
|
19
|
-
content: 'Bravo'
|
|
20
|
-
};
|
|
21
|
-
var HEADING = {
|
|
22
|
-
type: 'heading',
|
|
23
|
-
size: 'm',
|
|
24
|
-
content: 'Charlie'
|
|
25
|
-
};
|
|
26
|
-
it('should return an empty array for a null page', function () {
|
|
27
|
-
expect((0, _getEditableComponents.default)(null)).toEqual([]);
|
|
28
|
-
});
|
|
29
|
-
it('should return an empty array for a page with no components', function () {
|
|
30
|
-
expect((0, _getEditableComponents.default)({
|
|
31
|
-
components: []
|
|
32
|
-
})).toEqual([]);
|
|
33
|
-
});
|
|
34
|
-
it('should return an empty array for a page with only non-editable components', function () {
|
|
35
|
-
var COMPONENTS = [HTML, INSET_TEXT, HEADING];
|
|
36
|
-
expect((0, _getEditableComponents.default)({
|
|
37
|
-
components: COMPONENTS
|
|
38
|
-
})).toEqual([]);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
_isEditable.EDITABLE_TYPES.forEach(function (type) {
|
|
42
|
-
it("should return just the \"".concat(type, "\" component if it exists in the components but no non-editable ones"), function () {
|
|
43
|
-
var EDITABLE = {
|
|
44
|
-
type: type
|
|
45
|
-
};
|
|
46
|
-
var COMPONENTS = [HTML, EDITABLE, INSET_TEXT, HEADING];
|
|
47
|
-
expect((0, _getEditableComponents.default)({
|
|
48
|
-
components: COMPONENTS
|
|
49
|
-
})).toEqual([EDITABLE]);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('should return all editable components and no non-editable ones', function () {
|
|
54
|
-
var COMPONENTS = [HTML, INSET_TEXT, HEADING];
|
|
55
|
-
|
|
56
|
-
_isEditable.EDITABLE_TYPES.forEach(function (type) {
|
|
57
|
-
COMPONENTS.push({
|
|
58
|
-
type: type
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
var RESULT = (0, _getEditableComponents.default)({
|
|
63
|
-
components: COMPONENTS
|
|
64
|
-
});
|
|
65
|
-
expect(RESULT.length).toEqual(_isEditable.EDITABLE_TYPES.length);
|
|
66
|
-
|
|
67
|
-
_isEditable.EDITABLE_TYPES.forEach(function (type) {
|
|
68
|
-
expect(RESULT).toContainEqual({
|
|
69
|
-
type: type
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
});
|