@ukhomeoffice/cop-react-form-renderer 7.1.1-ipm-accessibility → 7.1.1-ipm-accessibility-beta
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/CheckYourAnswers.js +5 -1
- package/dist/components/FormPage/FormPage.js +2 -3
- package/dist/components/FormRenderer/FormRenderer.js +8 -2
- package/package.json +2 -2
- package/dist/components/FormPage/FormPageHeader.js +0 -54
- package/dist/components/FormPage/FormPageHeader.test.js +0 -74
|
@@ -32,6 +32,7 @@ const DEFAULT_MARGIN_BOTTOM = exports.DEFAULT_MARGIN_BOTTOM = 9;
|
|
|
32
32
|
const CheckYourAnswers = _ref => {
|
|
33
33
|
let {
|
|
34
34
|
title,
|
|
35
|
+
titleSize,
|
|
35
36
|
pages: _pages,
|
|
36
37
|
actions,
|
|
37
38
|
onAction,
|
|
@@ -145,7 +146,8 @@ const CheckYourAnswers = _ref => {
|
|
|
145
146
|
};
|
|
146
147
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
147
148
|
className: DEFAULT_CLASS,
|
|
148
|
-
children: [title && !hide_title && /*#__PURE__*/(0, _jsxRuntime.jsx)(_copReactComponents.
|
|
149
|
+
children: [title && !hide_title && /*#__PURE__*/(0, _jsxRuntime.jsx)(_copReactComponents.Heading, {
|
|
150
|
+
size: titleSize,
|
|
149
151
|
children: title
|
|
150
152
|
}, 'heading'), errors && errors.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_copReactComponents.ErrorSummary, {
|
|
151
153
|
errors: getDedupedErrors()
|
|
@@ -225,6 +227,7 @@ CheckYourAnswers.propTypes = {
|
|
|
225
227
|
})),
|
|
226
228
|
summaryListClassModifiers: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
|
|
227
229
|
title: _propTypes.default.string,
|
|
230
|
+
titleSize: _propTypes.default.string,
|
|
228
231
|
type: _propTypes.default.string,
|
|
229
232
|
hideBlankRows: _propTypes.default.bool,
|
|
230
233
|
optionalFieldPlaceholder: _propTypes.default.string
|
|
@@ -240,6 +243,7 @@ CheckYourAnswers.defaultProps = {
|
|
|
240
243
|
sections: [],
|
|
241
244
|
summaryListClassModifiers: null,
|
|
242
245
|
title: DEFAULT_TITLE,
|
|
246
|
+
titleSize: 'l',
|
|
243
247
|
type: null,
|
|
244
248
|
hideBlankRows: false,
|
|
245
249
|
optionalFieldPlaceholder: null
|
|
@@ -11,7 +11,6 @@ var _hooks = require("../../hooks");
|
|
|
11
11
|
var _utils = _interopRequireDefault(require("../../utils"));
|
|
12
12
|
var _FormComponent = _interopRequireDefault(require("../FormComponent"));
|
|
13
13
|
var _PageActions = _interopRequireDefault(require("../PageActions"));
|
|
14
|
-
var _FormPageHeader = _interopRequireDefault(require("./FormPageHeader"));
|
|
15
14
|
require("./FormPage.scss");
|
|
16
15
|
var _validateOnPageLoad = require("../../utils/Validate/validateOnPageLoad");
|
|
17
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -116,8 +115,8 @@ const FormPage = _ref => {
|
|
|
116
115
|
label: _utils.default.interpolateString(action.label, formPage.formData)
|
|
117
116
|
}) : action);
|
|
118
117
|
formPage.formData = _utils.default.Operate.runPageOperations(formPage, _objectSpread(_objectSpread({}, formPage.formData), patch), onWrapperChange || onPageChange);
|
|
119
|
-
const headingContent = page.title ? /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
120
|
-
|
|
118
|
+
const headingContent = page.title ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_copReactComponents.Heading, {
|
|
119
|
+
size: page.titleSize,
|
|
121
120
|
children: _utils.default.FormPage.getTitle(page.title, page.formData)
|
|
122
121
|
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_copReactComponents.Label, {
|
|
123
122
|
id: page.id,
|
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.DEFAULT_CLASS = void 0;
|
|
7
|
-
var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
8
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
10
10
|
var _context = require("../../context");
|
|
11
11
|
var _hooks = require("../../hooks");
|
|
12
12
|
var _models = require("../../models");
|
|
@@ -37,6 +37,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
37
37
|
const FormRenderer = _ref => {
|
|
38
38
|
let {
|
|
39
39
|
title,
|
|
40
|
+
titleSize,
|
|
40
41
|
type,
|
|
41
42
|
cleanseHiddenData,
|
|
42
43
|
components,
|
|
@@ -61,6 +62,7 @@ const FormRenderer = _ref => {
|
|
|
61
62
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_context.ValidationContextProvider, {
|
|
62
63
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(InternalFormRenderer, {
|
|
63
64
|
title: title,
|
|
65
|
+
titleSize: titleSize,
|
|
64
66
|
type: type,
|
|
65
67
|
cleanseHiddenData: cleanseHiddenData,
|
|
66
68
|
components: components,
|
|
@@ -87,6 +89,7 @@ const InternalFormRenderer = _ref2 => {
|
|
|
87
89
|
var _formState$page4, _formState$page$actio, _formState$cya$hideCh, _formState$cya$hideGr;
|
|
88
90
|
let {
|
|
89
91
|
title,
|
|
92
|
+
titleSize,
|
|
90
93
|
type,
|
|
91
94
|
cleanseHiddenData,
|
|
92
95
|
components,
|
|
@@ -305,7 +308,8 @@ const InternalFormRenderer = _ref2 => {
|
|
|
305
308
|
taskDetails = _objectWithoutProperties(hubDetails, _excluded);
|
|
306
309
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
307
310
|
className: classes(),
|
|
308
|
-
children: [title && !hideTitle && pageId === _models.FormPages.HUB && /*#__PURE__*/(0, _jsxRuntime.jsx)(_copReactComponents.
|
|
311
|
+
children: [title && !hideTitle && pageId === _models.FormPages.HUB && /*#__PURE__*/(0, _jsxRuntime.jsx)(_copReactComponents.Heading, {
|
|
312
|
+
size: titleSize,
|
|
309
313
|
children: title
|
|
310
314
|
}), formState.cya && /*#__PURE__*/(0, _jsxRuntime.jsx)(_CheckYourAnswers.default, _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
311
315
|
pages: _helpers.default.getRelevantPages(formState, pages, currentTask.fullPages)
|
|
@@ -382,6 +386,7 @@ const propTypes = {
|
|
|
382
386
|
pages: _propTypes.default.arrayOf(_propTypes.default.shape({})).isRequired,
|
|
383
387
|
summaryListClassModifiers: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
|
|
384
388
|
title: _propTypes.default.string,
|
|
389
|
+
titleSize: _propTypes.default.string,
|
|
385
390
|
cleanseHiddenData: _propTypes.default.bool,
|
|
386
391
|
/** See <a href="/?path=/docs/f-json--page#formtypes">FormTypes</a>. */
|
|
387
392
|
type: _propTypes.default.oneOf([_models.FormTypes.CYA, _models.FormTypes.FORM, _models.FormTypes.HUB, _models.FormTypes.TASK, _models.FormTypes.WIZARD, _models.FormTypes.TASK_CYA, _models.FormTypes.FORM_WITH_TASK]).isRequired,
|
|
@@ -408,6 +413,7 @@ const defaultProps = {
|
|
|
408
413
|
noChangeAction: false,
|
|
409
414
|
summaryListClassModifiers: [],
|
|
410
415
|
title: '',
|
|
416
|
+
titleSize: 'l',
|
|
411
417
|
cleanseHiddenData: false,
|
|
412
418
|
viewOnly: true,
|
|
413
419
|
hideBlankRows: false
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ukhomeoffice/cop-react-form-renderer",
|
|
3
|
-
"version": "7.1.1-ipm-accessibility",
|
|
3
|
+
"version": "7.1.1-ipm-accessibility-beta",
|
|
4
4
|
"private": false,
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build-storybook": "storybook build",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"yalc-publish": "yarn compile-with-maps && cp -r src dist/src && yalc publish --push"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@ukhomeoffice/cop-react-components": "5.1.0",
|
|
21
|
+
"@ukhomeoffice/cop-react-components": "5.1.0-ipm-accessibility",
|
|
22
22
|
"axios": "0.30.0",
|
|
23
23
|
"dayjs": "^1.11.0",
|
|
24
24
|
"govuk-frontend": "5.10.2",
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
9
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
// Global imports
|
|
13
|
-
|
|
14
|
-
const FormPageHeader = _ref => {
|
|
15
|
-
let {
|
|
16
|
-
titleSize,
|
|
17
|
-
children
|
|
18
|
-
} = _ref;
|
|
19
|
-
if (titleSize) {
|
|
20
|
-
const titleLowerCase = titleSize.toLowerCase();
|
|
21
|
-
switch (titleLowerCase) {
|
|
22
|
-
case "l":
|
|
23
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_copReactComponents.LargeHeading, {
|
|
24
|
-
children: children
|
|
25
|
-
});
|
|
26
|
-
case "m":
|
|
27
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_copReactComponents.MediumHeading, {
|
|
28
|
-
children: children
|
|
29
|
-
});
|
|
30
|
-
case "s":
|
|
31
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_copReactComponents.SmallHeading, {
|
|
32
|
-
children: children
|
|
33
|
-
});
|
|
34
|
-
default:
|
|
35
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_copReactComponents.LargeHeading, {
|
|
36
|
-
children: children
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Default title size consistent with old behaviour.
|
|
42
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_copReactComponents.LargeHeading, {
|
|
43
|
-
children: children
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
FormPageHeader.propTypes = {
|
|
47
|
-
children: _propTypes.default.node,
|
|
48
|
-
titleSize: _propTypes.default.string
|
|
49
|
-
};
|
|
50
|
-
FormPageHeader.defaultProps = {
|
|
51
|
-
children: null,
|
|
52
|
-
titleSize: null
|
|
53
|
-
};
|
|
54
|
-
var _default = exports.default = FormPageHeader;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = _interopRequireDefault(require("react"));
|
|
4
|
-
require("@testing-library/jest-dom");
|
|
5
|
-
var _react2 = require("@testing-library/react");
|
|
6
|
-
var _FormPageHeader = _interopRequireDefault(require("./FormPageHeader"));
|
|
7
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
// Global imports
|
|
10
|
-
|
|
11
|
-
// Local imports
|
|
12
|
-
|
|
13
|
-
describe('components.FormPageHeader', () => {
|
|
14
|
-
const PAGE_TITLE = "Page title";
|
|
15
|
-
it("Should render a large title", () => {
|
|
16
|
-
const {
|
|
17
|
-
getByRole
|
|
18
|
-
} = (0, _react2.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_FormPageHeader.default, {
|
|
19
|
-
titleSize: "l",
|
|
20
|
-
children: PAGE_TITLE
|
|
21
|
-
}));
|
|
22
|
-
const heading = getByRole('heading', {
|
|
23
|
-
level: 1
|
|
24
|
-
});
|
|
25
|
-
expect(heading).toHaveTextContent(PAGE_TITLE);
|
|
26
|
-
});
|
|
27
|
-
it("Should render a large title with uppercase L", () => {
|
|
28
|
-
const {
|
|
29
|
-
getByRole
|
|
30
|
-
} = (0, _react2.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_FormPageHeader.default, {
|
|
31
|
-
titleSize: "L",
|
|
32
|
-
children: PAGE_TITLE
|
|
33
|
-
}));
|
|
34
|
-
const heading = getByRole('heading', {
|
|
35
|
-
level: 1
|
|
36
|
-
});
|
|
37
|
-
expect(heading).toHaveTextContent(PAGE_TITLE);
|
|
38
|
-
});
|
|
39
|
-
it("Should render a medium title", () => {
|
|
40
|
-
const {
|
|
41
|
-
getByRole
|
|
42
|
-
} = (0, _react2.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_FormPageHeader.default, {
|
|
43
|
-
titleSize: "m",
|
|
44
|
-
children: PAGE_TITLE
|
|
45
|
-
}));
|
|
46
|
-
const heading = getByRole('heading', {
|
|
47
|
-
level: 2
|
|
48
|
-
});
|
|
49
|
-
expect(heading).toHaveTextContent(PAGE_TITLE);
|
|
50
|
-
});
|
|
51
|
-
it("Should render a small title", () => {
|
|
52
|
-
const {
|
|
53
|
-
getByRole
|
|
54
|
-
} = (0, _react2.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_FormPageHeader.default, {
|
|
55
|
-
titleSize: "s",
|
|
56
|
-
children: PAGE_TITLE
|
|
57
|
-
}));
|
|
58
|
-
const heading = getByRole('heading', {
|
|
59
|
-
level: 3
|
|
60
|
-
});
|
|
61
|
-
expect(heading).toHaveTextContent(PAGE_TITLE);
|
|
62
|
-
});
|
|
63
|
-
it("Should render a large title by default", () => {
|
|
64
|
-
const {
|
|
65
|
-
getByRole
|
|
66
|
-
} = (0, _react2.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_FormPageHeader.default, {
|
|
67
|
-
children: PAGE_TITLE
|
|
68
|
-
}));
|
|
69
|
-
const heading = getByRole('heading', {
|
|
70
|
-
level: 1
|
|
71
|
-
});
|
|
72
|
-
expect(heading).toHaveTextContent(PAGE_TITLE);
|
|
73
|
-
});
|
|
74
|
-
});
|