@dwp/govuk-casa 8.15.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.
Files changed (201) hide show
  1. package/README.md +9 -9
  2. package/dist/assets/css/casa.css +2 -1
  3. package/dist/assets/css/casa.css.map +1 -0
  4. package/dist/casa.d.ts +122 -99
  5. package/dist/casa.js +120 -88
  6. package/dist/casa.js.map +1 -1
  7. package/dist/lib/CasaTemplateLoader.d.ts +4 -4
  8. package/dist/lib/CasaTemplateLoader.js +16 -16
  9. package/dist/lib/CasaTemplateLoader.js.map +1 -1
  10. package/dist/lib/JourneyContext.d.ts +38 -40
  11. package/dist/lib/JourneyContext.js +89 -75
  12. package/dist/lib/JourneyContext.js.map +1 -1
  13. package/dist/lib/MutableRouter.d.ts +40 -41
  14. package/dist/lib/MutableRouter.js +64 -71
  15. package/dist/lib/MutableRouter.js.map +1 -1
  16. package/dist/lib/Plan.d.ts +29 -26
  17. package/dist/lib/Plan.js +85 -71
  18. package/dist/lib/Plan.js.map +1 -1
  19. package/dist/lib/ValidationError.d.ts +16 -15
  20. package/dist/lib/ValidationError.js +21 -20
  21. package/dist/lib/ValidationError.js.map +1 -1
  22. package/dist/lib/ValidatorFactory.d.ts +15 -13
  23. package/dist/lib/ValidatorFactory.js +14 -12
  24. package/dist/lib/ValidatorFactory.js.map +1 -1
  25. package/dist/lib/configuration-ingestor.d.ts +37 -40
  26. package/dist/lib/configuration-ingestor.js +93 -93
  27. package/dist/lib/configuration-ingestor.js.map +1 -1
  28. package/dist/lib/configure.d.ts +6 -6
  29. package/dist/lib/configure.js +14 -12
  30. package/dist/lib/configure.js.map +1 -1
  31. package/dist/lib/constants.d.ts +1 -3
  32. package/dist/lib/constants.js +9 -11
  33. package/dist/lib/constants.js.map +1 -1
  34. package/dist/lib/context-id-generators.d.ts +3 -5
  35. package/dist/lib/context-id-generators.js +7 -6
  36. package/dist/lib/context-id-generators.js.map +1 -1
  37. package/dist/lib/end-session.d.ts +4 -4
  38. package/dist/lib/end-session.js +5 -5
  39. package/dist/lib/field.d.ts +24 -29
  40. package/dist/lib/field.js +41 -70
  41. package/dist/lib/field.js.map +1 -1
  42. package/dist/lib/index.d.ts +13 -13
  43. package/dist/lib/logger.d.ts +7 -6
  44. package/dist/lib/logger.js +7 -7
  45. package/dist/lib/logger.js.map +1 -1
  46. package/dist/lib/mount.d.ts +5 -5
  47. package/dist/lib/mount.js +12 -17
  48. package/dist/lib/mount.js.map +1 -1
  49. package/dist/lib/nunjucks-filters.d.ts +10 -12
  50. package/dist/lib/nunjucks-filters.js +35 -35
  51. package/dist/lib/nunjucks-filters.js.map +1 -1
  52. package/dist/lib/nunjucks.d.ts +7 -5
  53. package/dist/lib/nunjucks.js +10 -8
  54. package/dist/lib/nunjucks.js.map +1 -1
  55. package/dist/lib/utils.d.ts +19 -19
  56. package/dist/lib/utils.js +62 -55
  57. package/dist/lib/utils.js.map +1 -1
  58. package/dist/lib/validators/dateObject.d.ts +29 -22
  59. package/dist/lib/validators/dateObject.js +58 -49
  60. package/dist/lib/validators/dateObject.js.map +1 -1
  61. package/dist/lib/validators/email.d.ts +4 -4
  62. package/dist/lib/validators/email.js +4 -4
  63. package/dist/lib/validators/inArray.d.ts +4 -4
  64. package/dist/lib/validators/inArray.js +7 -8
  65. package/dist/lib/validators/inArray.js.map +1 -1
  66. package/dist/lib/validators/index.d.ts +10 -10
  67. package/dist/lib/validators/index.js +1 -3
  68. package/dist/lib/validators/index.js.map +1 -1
  69. package/dist/lib/validators/nino.d.ts +9 -8
  70. package/dist/lib/validators/nino.js +14 -10
  71. package/dist/lib/validators/nino.js.map +1 -1
  72. package/dist/lib/validators/postalAddressObject.d.ts +37 -24
  73. package/dist/lib/validators/postalAddressObject.js +65 -46
  74. package/dist/lib/validators/postalAddressObject.js.map +1 -1
  75. package/dist/lib/validators/range.d.ts +12 -8
  76. package/dist/lib/validators/range.js +11 -9
  77. package/dist/lib/validators/range.js.map +1 -1
  78. package/dist/lib/validators/regex.d.ts +4 -4
  79. package/dist/lib/validators/regex.js +5 -5
  80. package/dist/lib/validators/required.d.ts +6 -6
  81. package/dist/lib/validators/required.js +9 -11
  82. package/dist/lib/validators/required.js.map +1 -1
  83. package/dist/lib/validators/strlen.d.ts +12 -8
  84. package/dist/lib/validators/strlen.js +13 -11
  85. package/dist/lib/validators/strlen.js.map +1 -1
  86. package/dist/lib/validators/wordCount.d.ts +12 -8
  87. package/dist/lib/validators/wordCount.js +15 -11
  88. package/dist/lib/validators/wordCount.js.map +1 -1
  89. package/dist/lib/waypoint-url.d.ts +16 -13
  90. package/dist/lib/waypoint-url.js +39 -36
  91. package/dist/lib/waypoint-url.js.map +1 -1
  92. package/dist/middleware/body-parser.d.ts +1 -1
  93. package/dist/middleware/body-parser.js +6 -6
  94. package/dist/middleware/body-parser.js.map +1 -1
  95. package/dist/middleware/data.d.ts +1 -1
  96. package/dist/middleware/data.js +8 -7
  97. package/dist/middleware/data.js.map +1 -1
  98. package/dist/middleware/gather-fields.d.ts +2 -2
  99. package/dist/middleware/gather-fields.js +6 -4
  100. package/dist/middleware/gather-fields.js.map +1 -1
  101. package/dist/middleware/i18n.js +13 -15
  102. package/dist/middleware/i18n.js.map +1 -1
  103. package/dist/middleware/post.js +30 -18
  104. package/dist/middleware/post.js.map +1 -1
  105. package/dist/middleware/pre.d.ts +2 -2
  106. package/dist/middleware/pre.js +46 -26
  107. package/dist/middleware/pre.js.map +1 -1
  108. package/dist/middleware/progress-journey.d.ts +1 -1
  109. package/dist/middleware/progress-journey.js +5 -5
  110. package/dist/middleware/progress-journey.js.map +1 -1
  111. package/dist/middleware/sanitise-fields.d.ts +1 -1
  112. package/dist/middleware/sanitise-fields.js +13 -11
  113. package/dist/middleware/sanitise-fields.js.map +1 -1
  114. package/dist/middleware/serve-first-waypoint.d.ts +3 -3
  115. package/dist/middleware/serve-first-waypoint.js +8 -6
  116. package/dist/middleware/serve-first-waypoint.js.map +1 -1
  117. package/dist/middleware/session.js +14 -11
  118. package/dist/middleware/session.js.map +1 -1
  119. package/dist/middleware/skip-waypoint.d.ts +1 -1
  120. package/dist/middleware/skip-waypoint.js +3 -3
  121. package/dist/middleware/skip-waypoint.js.map +1 -1
  122. package/dist/middleware/steer-journey.d.ts +1 -1
  123. package/dist/middleware/steer-journey.js +16 -14
  124. package/dist/middleware/steer-journey.js.map +1 -1
  125. package/dist/middleware/strip-proxy-path.d.ts +1 -1
  126. package/dist/middleware/strip-proxy-path.js +3 -3
  127. package/dist/middleware/strip-proxy-path.js.map +1 -1
  128. package/dist/middleware/validate-fields.d.ts +1 -1
  129. package/dist/middleware/validate-fields.js +2 -5
  130. package/dist/middleware/validate-fields.js.map +1 -1
  131. package/dist/routes/ancillary.d.ts +3 -3
  132. package/dist/routes/ancillary.js +4 -4
  133. package/dist/routes/ancillary.js.map +1 -1
  134. package/dist/routes/journey.d.ts +2 -2
  135. package/dist/routes/journey.js +91 -39
  136. package/dist/routes/journey.js.map +1 -1
  137. package/dist/routes/static.d.ts +7 -5
  138. package/dist/routes/static.js +20 -20
  139. package/dist/routes/static.js.map +1 -1
  140. package/package.json +17 -16
  141. package/src/casa.js +134 -102
  142. package/src/lib/CasaTemplateLoader.js +24 -19
  143. package/src/lib/JourneyContext.js +147 -107
  144. package/src/lib/MutableRouter.js +72 -74
  145. package/src/lib/Plan.js +145 -97
  146. package/src/lib/ValidationError.js +25 -21
  147. package/src/lib/ValidatorFactory.js +17 -13
  148. package/src/lib/configuration-ingestor.js +147 -110
  149. package/src/lib/configure.js +34 -32
  150. package/src/lib/constants.js +9 -11
  151. package/src/lib/context-id-generators.js +40 -43
  152. package/src/lib/end-session.js +6 -6
  153. package/src/lib/field.js +74 -78
  154. package/src/lib/index.js +12 -12
  155. package/src/lib/logger.js +9 -9
  156. package/src/lib/mount.js +70 -80
  157. package/src/lib/nunjucks-filters.js +56 -59
  158. package/src/lib/nunjucks.js +23 -18
  159. package/src/lib/utils.js +78 -57
  160. package/src/lib/validators/dateObject.js +71 -60
  161. package/src/lib/validators/email.js +8 -8
  162. package/src/lib/validators/inArray.js +10 -11
  163. package/src/lib/validators/index.js +12 -14
  164. package/src/lib/validators/nino.js +29 -15
  165. package/src/lib/validators/postalAddressObject.js +87 -63
  166. package/src/lib/validators/range.js +14 -12
  167. package/src/lib/validators/regex.js +8 -8
  168. package/src/lib/validators/required.js +16 -16
  169. package/src/lib/validators/strlen.js +16 -14
  170. package/src/lib/validators/wordCount.js +22 -14
  171. package/src/lib/waypoint-url.js +64 -46
  172. package/src/middleware/body-parser.js +10 -10
  173. package/src/middleware/csrf.js +1 -1
  174. package/src/middleware/data.js +28 -24
  175. package/src/middleware/gather-fields.js +10 -9
  176. package/src/middleware/i18n.js +35 -37
  177. package/src/middleware/post.js +41 -21
  178. package/src/middleware/pre.js +62 -40
  179. package/src/middleware/progress-journey.js +32 -18
  180. package/src/middleware/sanitise-fields.js +43 -20
  181. package/src/middleware/serve-first-waypoint.js +14 -12
  182. package/src/middleware/session.js +74 -61
  183. package/src/middleware/skip-waypoint.js +7 -9
  184. package/src/middleware/steer-journey.js +40 -28
  185. package/src/middleware/strip-proxy-path.js +8 -7
  186. package/src/middleware/validate-fields.js +5 -12
  187. package/src/routes/ancillary.js +5 -7
  188. package/src/routes/journey.js +159 -85
  189. package/src/routes/static.js +62 -30
  190. package/views/casa/components/character-count/README.md +2 -2
  191. package/views/casa/components/checkboxes/README.md +6 -6
  192. package/views/casa/components/date-input/README.md +7 -7
  193. package/views/casa/components/input/README.md +2 -2
  194. package/views/casa/components/journey-form/README.md +33 -14
  195. package/views/casa/components/postal-address-object/README.md +4 -4
  196. package/views/casa/components/radios/README.md +6 -6
  197. package/views/casa/components/select/README.md +6 -6
  198. package/views/casa/components/textarea/README.md +2 -2
  199. package/views/casa/partials/scripts.njk +5 -3
  200. package/views/casa/partials/styles.njk +1 -4
  201. package/dist/assets/css/casa-ie8.css +0 -1
@@ -1,12 +1,12 @@
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';
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 './dirname.cjs';
8
- import MutableRouter from '../lib/MutableRouter.js';
9
- import { validateUrlPath } from '../lib/utils.js';
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, default 1 hour)
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('404'));
33
+ next(new Error("404"));
35
34
  };
36
35
 
37
36
  const setHeaders = (req, res, next) => {
38
- res.set('cache-control', 'public');
39
- res.set('pragma', 'cache');
40
- res.set('expires', new Date(Date.now() + oneDay).toUTCString());
41
- const { pathname } = new URL(req?.originalUrl ?? '', 'https://placeholder.test/');
42
- if (pathname.substr(-4) === '.css') {
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('content-type', 'text/css');
46
+ res.set("content-type", "text/css");
45
47
  }
46
48
  next();
47
49
  };
@@ -59,22 +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(resolve(dirname, '../../dist/assets/css/casa.css'), { encoding: 'utf8' });
63
- const casaCssIe8 = readFileSync(resolve(dirname, '../../dist/assets/css/casa-ie8.css'), { encoding: 'utf8' });
64
+ const casaCss = readFileSync(
65
+ resolve(dirname, "../../dist/assets/css/casa.css"),
66
+ { encoding: "utf8" },
67
+ );
64
68
  /* eslint-enable security/detect-non-literal-fs-filename */
65
69
 
66
70
  // The static middleware will only server GET/HEAD requests, so we can mount
67
71
  // the middleware using `use()` rather than resorting to `get()`
68
- const govukFrontendDirectory = resolve(createRequire(dirname).resolve('govuk-frontend'), '../../');
72
+ const govukFrontendDirectory = resolve(
73
+ createRequire(dirname).resolve("govuk-frontend"),
74
+ "../../",
75
+ );
69
76
 
70
- router.use('/govuk/assets/js/all.js', ExpressStatic(`${govukFrontendDirectory}/govuk/all.js`, staticConfig));
71
- router.use('/govuk/assets/js/all.js.map', ExpressStatic(`${govukFrontendDirectory}/govuk/all.js.map`, staticConfig));
72
- router.use('/govuk/assets', ExpressStatic(`${govukFrontendDirectory}/govuk/assets`, staticConfig));
73
- router.use('/govuk/assets', notFoundHandler);
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);
74
96
 
75
- router.get('/casa/assets/css/casa.css', setHeaders, (req, res) => res.send(casaCss.replace(/~~~CASA_MOUNT_URL~~~/g, validateUrlPath(`${req.baseUrl}/`))));
76
- router.get('/casa/assets/css/casa-ie8.css', setHeaders, (req, res) => res.send(casaCssIe8.replace(/~~~CASA_MOUNT_URL~~~/g, validateUrlPath(`${req.baseUrl}/`))));
77
- router.use('/casa/assets', notFoundHandler);
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);
78
110
 
79
111
  return router;
80
112
  }
@@ -4,7 +4,7 @@ Extends the [`govukCharacterCount()`](https://design-system.service.gov.uk/compo
4
4
 
5
5
  Custom parameters:
6
6
 
7
- * `casaErrors` - form errors (just pass `formErrors`)
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
- * `data-ga-question`: Holds the fieldset label's text content
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
- * `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**
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
- * `data-ga-question`: Holds the fieldset legend's content
92
- * `data-ga-answer`: Holds the specific answer's text/html value
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
- * `data-ga-question`: Holds the fieldset legend's content after removing all html tags
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
- * `casaValue` (`object`) - the value of the date object, in `{dd: "", mm: "", yyyy: ""}` format
8
- * `casaErrors` - form errors (just pass `formErrors`)
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: 'Your error message',
76
- focusSuffix: '[dd]'
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
- * `data-ga-question`: Holds the fieldset label's text content after removing all html tags
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
- * `casaErrors` - form errors (just pass `formErrors`)
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
- * `data-ga-question`: Holds the fieldset label's text content after removing all html tags
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 action="/form/url" method="post" autocomplete="off" novalidate class="casa-journey-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 type="hidden" name="contextid" value="123e4567-e89b-12d3-a456-426614174000" />
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 type="submit" class="govuk-button" data-prevent-double-click="true" id="continue-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 href="/url/to/review/page" class="govuk-link govuk-link--no-visited-state">Cancel</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 | Type | Required | Description |
53
- |------|------|----------|-------------|
54
- | `formUrl` | string | Yes | The form's "action", available in a `formUrl` template variable |
55
- | `autoComplete` | string | No | Allows you to override the autocomplete parameter - the default value is 'off'
56
- | `csrfToken` | string | Yes | Token used to protect form from CSRF (available to user's templates via the global `casa.csrfToken` variable) |
57
- | `inEditMode` | boolean | No | Toggle edit-mode of the form (available to page templates using default GET/POST handlers via the local `inEditMode` variable) |
58
- | `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) |
59
- | `activeContextId` | string | No | ID of the active context to save data into. Won't be present if the "default" context is active |
60
- | `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 |
61
- | `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 |
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
- * `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
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
- * `data-ga-question`: Holds the specific item's label's text content after removing all html tags
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
- * `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**
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
- * `data-ga-question`: Holds the fieldset legend's content
90
- * `data-ga-answer`: Holds the specific answer's text/html value
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
- * `data-ga-question`: Holds the fieldset legend's content after removing all html tags
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
- * `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**
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
- * `data-ga-question`: Holds the fieldset legend's content
57
- * `data-ga-answer`: Holds the specific answer's text/html value
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
- * `data-ga-question`: Holds the fieldset legend's content after removing all html tags
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
- * `casaErrors` - form errors (just pass `formErrors`)
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
- * `data-ga-question`: Holds the fieldset label's text content after removing all html tags
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
 
@@ -1,7 +1,9 @@
1
1
  <!-- CASA -->
2
- <script src="{{ casa.staticMountUrl }}govuk/assets/js/all.js?{{ casaVersion }}"></script>
3
- <script nonce="{{ cspNonce }}">
4
- window.GOVUKFrontend.initAll();
2
+ {% set jsPath = casa.staticMountUrl + "govuk/govuk-frontend.min.js?" + casaVersion %}
3
+ <script type="module" src="{{ jsPath }}"></script>
4
+ <script type="module"{% if cspNonce %} nonce="{{ cspNonce }}"{% endif %}>
5
+ import { initAll } from '{{ jsPath }}';
6
+ initAll();
5
7
  if (window.history.replaceState) {
6
8
  // Prevent re-submission of POST on refreshing page
7
9
  window.history.replaceState(null, null, window.location.href);
@@ -1,6 +1,3 @@
1
1
  <!-- CASA -->
2
- <!--[if gt IE 8]><!--><link href="{{ casa.staticMountUrl }}casa/assets/css/casa.css?{{ casaVersion }}" rel="stylesheet" /><!--<![endif]-->
3
- <!--[if lte IE 8]>
4
- <link href="{{ casa.staticMountUrl }}casa/assets/css/casa-ie8.css?{{ casaVersion }}" rel="stylesheet" />
5
- <![endif]-->
2
+ <link href="{{ casa.staticMountUrl }}casa/assets/css/casa.css?{{ casaVersion }}" rel="stylesheet" />
6
3
  <!-- /CASA -->