@dwp/govuk-casa 9.0.0 → 9.1.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/README.md +9 -9
- package/dist/assets/css/casa.css +1 -1
- package/dist/assets/css/casa.css.map +1 -1
- package/dist/casa.d.ts +122 -95
- package/dist/casa.js +119 -86
- package/dist/casa.js.map +1 -1
- package/dist/lib/CasaTemplateLoader.d.ts +4 -4
- package/dist/lib/CasaTemplateLoader.js +16 -16
- package/dist/lib/CasaTemplateLoader.js.map +1 -1
- package/dist/lib/JourneyContext.d.ts +38 -40
- package/dist/lib/JourneyContext.js +81 -75
- package/dist/lib/JourneyContext.js.map +1 -1
- package/dist/lib/MutableRouter.d.ts +40 -41
- package/dist/lib/MutableRouter.js +64 -71
- package/dist/lib/MutableRouter.js.map +1 -1
- package/dist/lib/Plan.d.ts +29 -26
- package/dist/lib/Plan.js +85 -71
- package/dist/lib/Plan.js.map +1 -1
- package/dist/lib/ValidationError.d.ts +16 -15
- package/dist/lib/ValidationError.js +21 -20
- package/dist/lib/ValidationError.js.map +1 -1
- package/dist/lib/ValidatorFactory.d.ts +15 -13
- package/dist/lib/ValidatorFactory.js +14 -12
- package/dist/lib/ValidatorFactory.js.map +1 -1
- package/dist/lib/configuration-ingestor.d.ts +37 -40
- package/dist/lib/configuration-ingestor.js +93 -93
- package/dist/lib/configuration-ingestor.js.map +1 -1
- package/dist/lib/configure.d.ts +6 -6
- package/dist/lib/configure.js +14 -12
- package/dist/lib/configure.js.map +1 -1
- package/dist/lib/constants.d.ts +1 -3
- package/dist/lib/constants.js +9 -11
- package/dist/lib/constants.js.map +1 -1
- package/dist/lib/context-id-generators.d.ts +3 -5
- package/dist/lib/context-id-generators.js +7 -6
- package/dist/lib/context-id-generators.js.map +1 -1
- package/dist/lib/end-session.d.ts +4 -4
- package/dist/lib/end-session.js +5 -5
- package/dist/lib/field.d.ts +20 -18
- package/dist/lib/field.js +35 -48
- package/dist/lib/field.js.map +1 -1
- package/dist/lib/index.d.ts +13 -13
- package/dist/lib/logger.d.ts +7 -6
- package/dist/lib/logger.js +7 -7
- package/dist/lib/logger.js.map +1 -1
- package/dist/lib/mount.d.ts +5 -5
- package/dist/lib/mount.js +11 -10
- package/dist/lib/mount.js.map +1 -1
- package/dist/lib/nunjucks-filters.d.ts +10 -12
- package/dist/lib/nunjucks-filters.js +35 -35
- package/dist/lib/nunjucks-filters.js.map +1 -1
- package/dist/lib/nunjucks.d.ts +7 -5
- package/dist/lib/nunjucks.js +10 -8
- package/dist/lib/nunjucks.js.map +1 -1
- package/dist/lib/utils.d.ts +19 -19
- package/dist/lib/utils.js +62 -55
- package/dist/lib/utils.js.map +1 -1
- package/dist/lib/validators/dateObject.d.ts +29 -22
- package/dist/lib/validators/dateObject.js +58 -49
- package/dist/lib/validators/dateObject.js.map +1 -1
- package/dist/lib/validators/email.d.ts +4 -4
- package/dist/lib/validators/email.js +4 -4
- package/dist/lib/validators/inArray.d.ts +4 -4
- package/dist/lib/validators/inArray.js +7 -8
- package/dist/lib/validators/inArray.js.map +1 -1
- package/dist/lib/validators/index.d.ts +10 -10
- package/dist/lib/validators/index.js +1 -3
- package/dist/lib/validators/index.js.map +1 -1
- package/dist/lib/validators/nino.d.ts +9 -8
- package/dist/lib/validators/nino.js +14 -10
- package/dist/lib/validators/nino.js.map +1 -1
- package/dist/lib/validators/postalAddressObject.d.ts +37 -24
- package/dist/lib/validators/postalAddressObject.js +65 -46
- package/dist/lib/validators/postalAddressObject.js.map +1 -1
- package/dist/lib/validators/range.d.ts +12 -8
- package/dist/lib/validators/range.js +11 -9
- package/dist/lib/validators/range.js.map +1 -1
- package/dist/lib/validators/regex.d.ts +4 -4
- package/dist/lib/validators/regex.js +5 -5
- package/dist/lib/validators/required.d.ts +6 -6
- package/dist/lib/validators/required.js +9 -11
- package/dist/lib/validators/required.js.map +1 -1
- package/dist/lib/validators/strlen.d.ts +12 -8
- package/dist/lib/validators/strlen.js +13 -11
- package/dist/lib/validators/strlen.js.map +1 -1
- package/dist/lib/validators/wordCount.d.ts +12 -8
- package/dist/lib/validators/wordCount.js +15 -11
- package/dist/lib/validators/wordCount.js.map +1 -1
- package/dist/lib/waypoint-url.d.ts +16 -13
- package/dist/lib/waypoint-url.js +39 -36
- package/dist/lib/waypoint-url.js.map +1 -1
- package/dist/middleware/body-parser.d.ts +1 -1
- package/dist/middleware/body-parser.js +6 -6
- package/dist/middleware/body-parser.js.map +1 -1
- package/dist/middleware/data.d.ts +1 -1
- package/dist/middleware/data.js +8 -7
- package/dist/middleware/data.js.map +1 -1
- package/dist/middleware/gather-fields.d.ts +2 -2
- package/dist/middleware/gather-fields.js +6 -4
- package/dist/middleware/gather-fields.js.map +1 -1
- package/dist/middleware/i18n.js +13 -15
- package/dist/middleware/i18n.js.map +1 -1
- package/dist/middleware/post.js +30 -18
- package/dist/middleware/post.js.map +1 -1
- package/dist/middleware/pre.d.ts +2 -2
- package/dist/middleware/pre.js +46 -27
- package/dist/middleware/pre.js.map +1 -1
- package/dist/middleware/progress-journey.d.ts +1 -1
- package/dist/middleware/progress-journey.js +5 -5
- package/dist/middleware/progress-journey.js.map +1 -1
- package/dist/middleware/sanitise-fields.d.ts +1 -1
- package/dist/middleware/sanitise-fields.js +13 -11
- package/dist/middleware/sanitise-fields.js.map +1 -1
- package/dist/middleware/serve-first-waypoint.d.ts +3 -3
- package/dist/middleware/serve-first-waypoint.js +8 -6
- package/dist/middleware/serve-first-waypoint.js.map +1 -1
- package/dist/middleware/session.js +14 -11
- package/dist/middleware/session.js.map +1 -1
- package/dist/middleware/skip-waypoint.d.ts +1 -1
- package/dist/middleware/skip-waypoint.js +3 -3
- package/dist/middleware/skip-waypoint.js.map +1 -1
- package/dist/middleware/steer-journey.d.ts +1 -1
- package/dist/middleware/steer-journey.js +16 -14
- package/dist/middleware/steer-journey.js.map +1 -1
- package/dist/middleware/strip-proxy-path.d.ts +1 -1
- package/dist/middleware/strip-proxy-path.js +3 -3
- package/dist/middleware/strip-proxy-path.js.map +1 -1
- package/dist/middleware/validate-fields.d.ts +1 -1
- package/dist/middleware/validate-fields.js +2 -5
- package/dist/middleware/validate-fields.js.map +1 -1
- package/dist/routes/ancillary.d.ts +3 -3
- package/dist/routes/ancillary.js +4 -4
- package/dist/routes/ancillary.js.map +1 -1
- package/dist/routes/journey.d.ts +2 -2
- package/dist/routes/journey.js +91 -39
- package/dist/routes/journey.js.map +1 -1
- package/dist/routes/static.d.ts +7 -5
- package/dist/routes/static.js +20 -19
- package/dist/routes/static.js.map +1 -1
- package/package.json +19 -18
- package/src/casa.js +133 -100
- package/src/lib/CasaTemplateLoader.js +24 -19
- package/src/lib/JourneyContext.js +138 -107
- package/src/lib/MutableRouter.js +72 -74
- package/src/lib/Plan.js +145 -97
- package/src/lib/ValidationError.js +25 -21
- package/src/lib/ValidatorFactory.js +17 -13
- package/src/lib/configuration-ingestor.js +147 -110
- package/src/lib/configure.js +34 -32
- package/src/lib/constants.js +9 -11
- package/src/lib/context-id-generators.js +40 -43
- package/src/lib/end-session.js +6 -6
- package/src/lib/field.js +69 -58
- package/src/lib/index.js +12 -12
- package/src/lib/logger.js +9 -9
- package/src/lib/mount.js +70 -74
- package/src/lib/nunjucks-filters.js +56 -59
- package/src/lib/nunjucks.js +23 -18
- package/src/lib/utils.js +78 -57
- package/src/lib/validators/dateObject.js +71 -60
- package/src/lib/validators/email.js +8 -8
- package/src/lib/validators/inArray.js +10 -11
- package/src/lib/validators/index.js +12 -14
- package/src/lib/validators/nino.js +29 -15
- package/src/lib/validators/postalAddressObject.js +87 -63
- package/src/lib/validators/range.js +14 -12
- package/src/lib/validators/regex.js +8 -8
- package/src/lib/validators/required.js +16 -16
- package/src/lib/validators/strlen.js +16 -14
- package/src/lib/validators/wordCount.js +22 -14
- package/src/lib/waypoint-url.js +64 -46
- package/src/middleware/body-parser.js +10 -10
- package/src/middleware/csrf.js +1 -1
- package/src/middleware/data.js +28 -24
- package/src/middleware/gather-fields.js +10 -9
- package/src/middleware/i18n.js +35 -37
- package/src/middleware/post.js +41 -21
- package/src/middleware/pre.js +62 -41
- package/src/middleware/progress-journey.js +32 -18
- package/src/middleware/sanitise-fields.js +43 -20
- package/src/middleware/serve-first-waypoint.js +14 -12
- package/src/middleware/session.js +74 -61
- package/src/middleware/skip-waypoint.js +7 -9
- package/src/middleware/steer-journey.js +40 -28
- package/src/middleware/strip-proxy-path.js +8 -7
- package/src/middleware/validate-fields.js +5 -12
- package/src/routes/ancillary.js +5 -7
- package/src/routes/journey.js +159 -85
- package/src/routes/static.js +62 -29
- package/views/casa/components/character-count/README.md +2 -2
- package/views/casa/components/checkboxes/README.md +6 -6
- package/views/casa/components/date-input/README.md +7 -7
- package/views/casa/components/input/README.md +2 -2
- package/views/casa/components/journey-form/README.md +33 -14
- package/views/casa/components/postal-address-object/README.md +4 -4
- package/views/casa/components/radios/README.md +6 -6
- package/views/casa/components/select/README.md +6 -6
- package/views/casa/components/textarea/README.md +2 -2
- package/views/casa/layouts/main.njk +2 -1
package/src/routes/static.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import ExpressJS from
|
|
2
|
-
import { readFileSync } from
|
|
3
|
-
import { URL } from
|
|
4
|
-
import { resolve } from
|
|
5
|
-
import { createRequire } from
|
|
1
|
+
import ExpressJS from "express";
|
|
2
|
+
import { readFileSync } from "fs";
|
|
3
|
+
import { URL } from "url";
|
|
4
|
+
import { resolve } from "path";
|
|
5
|
+
import { createRequire } from "module";
|
|
6
6
|
|
|
7
|
-
import dirname from
|
|
8
|
-
import MutableRouter from
|
|
9
|
-
import { validateUrlPath } from
|
|
7
|
+
import dirname from "./dirname.cjs";
|
|
8
|
+
import MutableRouter from "../lib/MutableRouter.js";
|
|
9
|
+
import { validateUrlPath } from "../lib/utils.js";
|
|
10
10
|
|
|
11
11
|
const { static: ExpressStatic } = ExpressJS; // CommonJS
|
|
12
12
|
|
|
@@ -14,34 +14,36 @@ const oneDay = 86400000;
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* @typedef {object} StaticOptions Options to configure static router
|
|
17
|
-
* @property {number} [maxAge=3600000] Cache TTL for all assets (optional,
|
|
17
|
+
* @property {number} [maxAge=3600000] Cache TTL for all assets (optional,
|
|
18
|
+
* default 1 hour). Default is `3600000`
|
|
18
19
|
*/
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* Create a router for serving CASA's static assets.
|
|
22
23
|
*
|
|
23
|
-
* @access private
|
|
24
24
|
* @param {StaticOptions} options Options
|
|
25
25
|
* @returns {MutableRouter} ExpressJS Router instance
|
|
26
|
+
* @access private
|
|
26
27
|
*/
|
|
27
|
-
export default function staticRouter({
|
|
28
|
-
maxAge = 3600000,
|
|
29
|
-
} = {}) {
|
|
28
|
+
export default function staticRouter({ maxAge = 3600000 } = {}) {
|
|
30
29
|
const router = new MutableRouter();
|
|
31
30
|
|
|
32
31
|
const notFoundHandler = (req, res, next) => {
|
|
33
32
|
// Fall through to a general purpose error handler
|
|
34
|
-
next(new Error(
|
|
33
|
+
next(new Error("404"));
|
|
35
34
|
};
|
|
36
35
|
|
|
37
36
|
const setHeaders = (req, res, next) => {
|
|
38
|
-
res.set(
|
|
39
|
-
res.set(
|
|
40
|
-
res.set(
|
|
41
|
-
const { pathname } = new URL(
|
|
42
|
-
|
|
37
|
+
res.set("cache-control", "public");
|
|
38
|
+
res.set("pragma", "cache");
|
|
39
|
+
res.set("expires", new Date(Date.now() + oneDay).toUTCString());
|
|
40
|
+
const { pathname } = new URL(
|
|
41
|
+
req?.originalUrl ?? "",
|
|
42
|
+
"https://placeholder.test/",
|
|
43
|
+
);
|
|
44
|
+
if (pathname.substr(-4) === ".css") {
|
|
43
45
|
// Just needed for our in-memory CSS assets
|
|
44
|
-
res.set(
|
|
46
|
+
res.set("content-type", "text/css");
|
|
45
47
|
}
|
|
46
48
|
next();
|
|
47
49
|
};
|
|
@@ -59,21 +61,52 @@ export default function staticRouter({
|
|
|
59
61
|
// must be replaced with the dynamic `mountUrl` to ensure govuk-frontend
|
|
60
62
|
// assets are served from the correct location.
|
|
61
63
|
/* eslint-disable security/detect-non-literal-fs-filename */
|
|
62
|
-
const casaCss = readFileSync(
|
|
64
|
+
const casaCss = readFileSync(
|
|
65
|
+
resolve(dirname, "../../dist/assets/css/casa.css"),
|
|
66
|
+
{ encoding: "utf8" },
|
|
67
|
+
);
|
|
63
68
|
/* eslint-enable security/detect-non-literal-fs-filename */
|
|
64
69
|
|
|
65
70
|
// The static middleware will only server GET/HEAD requests, so we can mount
|
|
66
71
|
// the middleware using `use()` rather than resorting to `get()`
|
|
67
|
-
const govukFrontendDirectory = resolve(
|
|
72
|
+
const govukFrontendDirectory = resolve(
|
|
73
|
+
createRequire(dirname).resolve("govuk-frontend"),
|
|
74
|
+
"../../",
|
|
75
|
+
);
|
|
68
76
|
|
|
69
|
-
router.use(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
77
|
+
router.use(
|
|
78
|
+
"/govuk/govuk-frontend.min.js",
|
|
79
|
+
ExpressStatic(
|
|
80
|
+
`${govukFrontendDirectory}/govuk/govuk-frontend.min.js`,
|
|
81
|
+
staticConfig,
|
|
82
|
+
),
|
|
83
|
+
);
|
|
84
|
+
router.use(
|
|
85
|
+
"/govuk/govuk-frontend.min.js.map",
|
|
86
|
+
ExpressStatic(
|
|
87
|
+
`${govukFrontendDirectory}/govuk/govuk-frontend.min.js.map`,
|
|
88
|
+
staticConfig,
|
|
89
|
+
),
|
|
90
|
+
);
|
|
91
|
+
router.use(
|
|
92
|
+
"/govuk/assets",
|
|
93
|
+
ExpressStatic(`${govukFrontendDirectory}/govuk/assets`, staticConfig),
|
|
94
|
+
);
|
|
95
|
+
router.use("/govuk/assets", notFoundHandler);
|
|
73
96
|
|
|
74
|
-
router.get(
|
|
75
|
-
|
|
76
|
-
|
|
97
|
+
router.get("/casa/assets/css/casa.css", setHeaders, (req, res) =>
|
|
98
|
+
res.send(
|
|
99
|
+
casaCss.replace(
|
|
100
|
+
/~~~CASA_MOUNT_URL~~~/g,
|
|
101
|
+
validateUrlPath(`${req.baseUrl}/`),
|
|
102
|
+
),
|
|
103
|
+
),
|
|
104
|
+
);
|
|
105
|
+
router.use(
|
|
106
|
+
"/casa/assets/css/casa.css.map",
|
|
107
|
+
ExpressStatic(resolve(dirname, "../../dist/assets/css/casa.css.map")),
|
|
108
|
+
);
|
|
109
|
+
router.use("/casa/assets", notFoundHandler);
|
|
77
110
|
|
|
78
111
|
return router;
|
|
79
112
|
}
|
|
@@ -4,7 +4,7 @@ Extends the [`govukCharacterCount()`](https://design-system.service.gov.uk/compo
|
|
|
4
4
|
|
|
5
5
|
Custom parameters:
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- `casaErrors` - form errors (just pass `formErrors`)
|
|
8
8
|
|
|
9
9
|
## Example usage
|
|
10
10
|
|
|
@@ -24,7 +24,7 @@ casaGovukCharacterCount({
|
|
|
24
24
|
|
|
25
25
|
The following attributes will be attached to the error `<p>` tag if `casaWithAnalytics` is `true`:
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
- `data-ga-question`: Holds the fieldset label's text content
|
|
28
28
|
|
|
29
29
|
These are the conventions used by DWP.
|
|
30
30
|
|
|
@@ -6,9 +6,9 @@ Note that for consistency, values gathered from this macro will always be an arr
|
|
|
6
6
|
|
|
7
7
|
Custom parameters:
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
- `casaValue` (`array`) - the value of the chosen checkbox(es). This is a convenience for toggling the `checked` flag on the appropriate `item`, but you can also manually set `checked` on each item if you need to use more specific logic for determining checked state.
|
|
10
|
+
- `casaErrors` - form errors (just pass `formErrors`)
|
|
11
|
+
- `casaWithAnalytics` - enable DWP's conventional Google Analytics attributes (`data-ga-question` and `data-ga-answer`) - `false` by default; **IMPORTANT: DO NOT ENABLE this option if the question or answer may contain personally-identifiable information as values will be pushed to Google**
|
|
12
12
|
|
|
13
13
|
## Example usage
|
|
14
14
|
|
|
@@ -88,12 +88,12 @@ The error summary link must set focus on the first checkbox in the group. Unless
|
|
|
88
88
|
|
|
89
89
|
The following attributes will be attached to each `<input>` option if `casaWithAnalytics` is `true`:
|
|
90
90
|
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
- `data-ga-question`: Holds the fieldset legend's content
|
|
92
|
+
- `data-ga-answer`: Holds the specific answer's text/html value
|
|
93
93
|
|
|
94
94
|
The following attributes will be attached to the error `<p>` tag if `casaWithAnalytics` is `true`:
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
- `data-ga-question`: Holds the fieldset legend's content after removing all html tags
|
|
97
97
|
|
|
98
98
|
These are the conventions used by DWP.
|
|
99
99
|
|
|
@@ -4,8 +4,8 @@ Extends the [`govukDateInput()`](https://design-system.service.gov.uk/components
|
|
|
4
4
|
|
|
5
5
|
Custom parameters:
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
- `casaValue` (`object`) - the value of the date object, in `{dd: "", mm: "", yyyy: ""}` format
|
|
8
|
+
- `casaErrors` - form errors (just pass `formErrors`)
|
|
9
9
|
|
|
10
10
|
Note that the underlying GOVUK macro has no support for a `name` parameter, and instead you will need to use the `namePrefix` attribute.
|
|
11
11
|
|
|
@@ -72,11 +72,11 @@ module.exports = {
|
|
|
72
72
|
myDateField: sf([
|
|
73
73
|
r.required.make({
|
|
74
74
|
errorMsg: {
|
|
75
|
-
summary:
|
|
76
|
-
focusSuffix:
|
|
77
|
-
}
|
|
75
|
+
summary: "Your error message",
|
|
76
|
+
focusSuffix: "[dd]",
|
|
77
|
+
},
|
|
78
78
|
}),
|
|
79
|
-
r.dateObject
|
|
79
|
+
r.dateObject,
|
|
80
80
|
]),
|
|
81
81
|
};
|
|
82
82
|
```
|
|
@@ -107,7 +107,7 @@ You can also pass a locale:
|
|
|
107
107
|
|
|
108
108
|
The following attributes will be attached to the error `<p>` tag if `casaWithAnalytics` is `true`:
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
- `data-ga-question`: Holds the fieldset label's text content after removing all html tags
|
|
111
111
|
|
|
112
112
|
These are the conventions used by DWP.
|
|
113
113
|
|
|
@@ -4,7 +4,7 @@ Extends the [`govukInput()`](https://design-system.service.gov.uk/components/tex
|
|
|
4
4
|
|
|
5
5
|
Custom parameters:
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- `casaErrors` - form errors (just pass `formErrors`)
|
|
8
8
|
|
|
9
9
|
## Example usage
|
|
10
10
|
|
|
@@ -24,7 +24,7 @@ casaGovukInput({
|
|
|
24
24
|
|
|
25
25
|
The following attributes will be attached to the error `<p>` tag if `casaWithAnalytics` is `true`:
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
- `data-ga-question`: Holds the fieldset label's text content after removing all html tags
|
|
28
28
|
|
|
29
29
|
These are the conventions used by DWP.
|
|
30
30
|
|
|
@@ -27,20 +27,39 @@ A "Continue" button (and "Cancel" link if in edit mode) will also be added.
|
|
|
27
27
|
Which will render something like this:
|
|
28
28
|
|
|
29
29
|
```html
|
|
30
|
-
<form
|
|
30
|
+
<form
|
|
31
|
+
action="/form/url"
|
|
32
|
+
method="post"
|
|
33
|
+
autocomplete="off"
|
|
34
|
+
novalidate
|
|
35
|
+
class="casa-journey-form"
|
|
36
|
+
>
|
|
31
37
|
<input type="hidden" name="_csrf" value="..." />
|
|
32
38
|
<input type="hidden" name="edit" value="true" />
|
|
33
39
|
<input type="hidden" name="editorigin" value="/url/to/review/page" />
|
|
34
|
-
<input
|
|
40
|
+
<input
|
|
41
|
+
type="hidden"
|
|
42
|
+
name="contextid"
|
|
43
|
+
value="123e4567-e89b-12d3-a456-426614174000"
|
|
44
|
+
/>
|
|
35
45
|
|
|
36
46
|
... your form inputs here ...
|
|
37
47
|
|
|
38
48
|
<div class="govuk-button-group casa-form-control-block">
|
|
39
|
-
<button
|
|
49
|
+
<button
|
|
50
|
+
type="submit"
|
|
51
|
+
class="govuk-button"
|
|
52
|
+
data-prevent-double-click="true"
|
|
53
|
+
id="continue-button"
|
|
54
|
+
>
|
|
40
55
|
Save changes
|
|
41
56
|
</button>
|
|
42
57
|
|
|
43
|
-
<a
|
|
58
|
+
<a
|
|
59
|
+
href="/url/to/review/page"
|
|
60
|
+
class="govuk-link govuk-link--no-visited-state"
|
|
61
|
+
>Cancel</a
|
|
62
|
+
>
|
|
44
63
|
</div>
|
|
45
64
|
</form>
|
|
46
65
|
```
|
|
@@ -49,13 +68,13 @@ Note that the submit button is configured to prevent double-clicks and avoid dup
|
|
|
49
68
|
|
|
50
69
|
## Component arguments
|
|
51
70
|
|
|
52
|
-
| Name
|
|
53
|
-
|
|
54
|
-
| `formUrl`
|
|
55
|
-
| `autoComplete`
|
|
56
|
-
| `csrfToken`
|
|
57
|
-
| `inEditMode`
|
|
58
|
-
| `editOriginUrl`
|
|
59
|
-
| `activeContextId` | string
|
|
60
|
-
| `buttonBarHidden` | boolean | No
|
|
61
|
-
| `buttonText`
|
|
71
|
+
| Name | Type | Required | Description |
|
|
72
|
+
| ----------------- | ------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
73
|
+
| `formUrl` | string | Yes | The form's "action", available in a `formUrl` template variable |
|
|
74
|
+
| `autoComplete` | string | No | Allows you to override the autocomplete parameter - the default value is 'off' |
|
|
75
|
+
| `csrfToken` | string | Yes | Token used to protect form from CSRF (available to user's templates via the global `casa.csrfToken` variable) |
|
|
76
|
+
| `inEditMode` | boolean | No | Toggle edit-mode of the form (available to page templates using default GET/POST handlers via the local `inEditMode` variable) |
|
|
77
|
+
| `editOriginUrl` | string | No | Absolute URL to the page from which the edit request came (defaults to `review`) (available to user's templates using default GET/POST handlers via the local `editOriginUrl` variable) |
|
|
78
|
+
| `activeContextId` | string | No | ID of the active context to save data into. Won't be present if the "default" context is active |
|
|
79
|
+
| `buttonBarHidden` | boolean | No | Toggle the rendering of the bar containing the "Continue" button and "Cancel" link.Useful if you want to render your own buttons |
|
|
80
|
+
| `buttonText` | string | No | Overrides default button text i.e Save changes. If you need to retain the save changes switch you will need to add this logic |
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Custom parameters:
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
- `value` - the value of the address object, in `{address1: '', address2: '', address3: '', address4: '', postcode: ''}` format
|
|
6
|
+
- `casaErrors` - form errors (just pass `formErrors`)
|
|
7
|
+
- `address[1-4]` and `postcode` - for specifying extra attributes for each of the address input components
|
|
8
8
|
|
|
9
9
|
## Example usage
|
|
10
10
|
|
|
@@ -57,7 +57,7 @@ And when using the `required` field validator in conjunction with this macro, yo
|
|
|
57
57
|
|
|
58
58
|
The following attributes will be attached to the error `<p>` tags if `casaWithAnalytics` is `true`:
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
- `data-ga-question`: Holds the specific item's label's text content after removing all html tags
|
|
61
61
|
|
|
62
62
|
These are the conventions used by DWP.
|
|
63
63
|
|
|
@@ -4,9 +4,9 @@ Extends the [`govukRadios()`](https://design-system.service.gov.uk/components/ra
|
|
|
4
4
|
|
|
5
5
|
Custom parameters:
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
- `casaValue` - the value of the chosen radio button. This is a convenience for toggling the `checked` flag on the appropriate `item`, but you can also manually set `checked` on each item if you need to use more specific logic for determining checked state.
|
|
8
|
+
- `casaErrors` - form errors (just pass `formErrors`)
|
|
9
|
+
- `casaWithAnalytics` - enable DWP's conventional Google Analytics attributes (`data-ga-question` and `data-ga-answer`) - `false` by default; **IMPORTANT: DO NOT ENABLE this option if the question or answer may contain personally-identifiable information as values will be pushed to Google**
|
|
10
10
|
|
|
11
11
|
## Example usage
|
|
12
12
|
|
|
@@ -86,12 +86,12 @@ The error summary link must set focus on the first radio in the group. Unless yo
|
|
|
86
86
|
|
|
87
87
|
The following attributes will be attached to each `<input>` option if `casaWithAnalytics` is `true`:
|
|
88
88
|
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
- `data-ga-question`: Holds the fieldset legend's content
|
|
90
|
+
- `data-ga-answer`: Holds the specific answer's text/html value
|
|
91
91
|
|
|
92
92
|
The following attributes will be attached to the error `<p>` tag if `casaWithAnalytics` is `true`:
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
- `data-ga-question`: Holds the fieldset legend's content after removing all html tags
|
|
95
95
|
|
|
96
96
|
These are the conventions used by DWP.
|
|
97
97
|
|
|
@@ -4,9 +4,9 @@ Extends the [`govukSelect()`](https://design-system.service.gov.uk/components/se
|
|
|
4
4
|
|
|
5
5
|
Custom parameters:
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
- `casaValue` - the value of the selected option. This is a convenience for toggling the `selected` flag on the appropriate `item`, but you can also manually set `selected` on each item of you need to use more specific logic for determining selected state.
|
|
8
|
+
- `casaErrors` - form errors (just pass `formErrors`)
|
|
9
|
+
- `casaWithAnalytics` - enable DWP's conventional Google Analytics attributes (`data-ga-question` and `data-ga-answer`) - `false` by default; **IMPORTANT: DO NOT ENABLE this option if the question or answer may contain personally-identifiable information as values will be pushed to Google**
|
|
10
10
|
|
|
11
11
|
## Example usage
|
|
12
12
|
|
|
@@ -53,12 +53,12 @@ The error summary link must set focus on the select item in the group. Unless yo
|
|
|
53
53
|
|
|
54
54
|
The following attributes will be attached to each `<input>` option if `casaWithAnalytics` is `true`:
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
- `data-ga-question`: Holds the fieldset legend's content
|
|
57
|
+
- `data-ga-answer`: Holds the specific answer's text/html value
|
|
58
58
|
|
|
59
59
|
The following attributes will be attached to the error `<p>` tag if `casaWithAnalytics` is `true`:
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
- `data-ga-question`: Holds the fieldset legend's content after removing all html tags
|
|
62
62
|
|
|
63
63
|
These are the conventions used by DWP.
|
|
64
64
|
|
|
@@ -4,7 +4,7 @@ Extends the [`govukTextarea()`](https://design-system.service.gov.uk/components/
|
|
|
4
4
|
|
|
5
5
|
Custom parameters:
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- `casaErrors` - form errors (just pass `formErrors`)
|
|
8
8
|
|
|
9
9
|
## Example usage
|
|
10
10
|
|
|
@@ -24,7 +24,7 @@ casaGovukTextarea({
|
|
|
24
24
|
|
|
25
25
|
The following attributes will be attached to the error `<p>` tag if `casaWithAnalytics` is `true`:
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
- `data-ga-question`: Holds the fieldset label's text content after removing all html tags
|
|
28
28
|
|
|
29
29
|
These are the conventions used by DWP.
|
|
30
30
|
|