defra_ruby_template 6.4.0 → 6.6.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 (180) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +73 -19
  3. data/Rakefile +10 -33
  4. data/lib/defra_ruby_template/version.rb +1 -1
  5. data/node_modules/govuk-frontend/dist/govuk/all.bundle.js +202 -137
  6. data/node_modules/govuk-frontend/dist/govuk/all.bundle.js.map +1 -1
  7. data/node_modules/govuk-frontend/dist/govuk/all.bundle.mjs +202 -137
  8. data/node_modules/govuk-frontend/dist/govuk/all.bundle.mjs.map +1 -1
  9. data/node_modules/govuk-frontend/dist/govuk/common/closest-attribute-value.mjs.map +1 -1
  10. data/node_modules/govuk-frontend/dist/govuk/common/configuration.mjs +5 -1
  11. data/node_modules/govuk-frontend/dist/govuk/common/configuration.mjs.map +1 -1
  12. data/node_modules/govuk-frontend/dist/govuk/common/create-element.mjs +13 -0
  13. data/node_modules/govuk-frontend/dist/govuk/common/create-element.mjs.map +1 -0
  14. data/node_modules/govuk-frontend/dist/govuk/common/govuk-frontend-version.mjs +1 -1
  15. data/node_modules/govuk-frontend/dist/govuk/common/govuk-frontend-version.mjs.map +1 -1
  16. data/node_modules/govuk-frontend/dist/govuk/common/index.mjs.map +1 -1
  17. data/node_modules/govuk-frontend/dist/govuk/component.mjs +2 -1
  18. data/node_modules/govuk-frontend/dist/govuk/component.mjs.map +1 -1
  19. data/node_modules/govuk-frontend/dist/govuk/components/_index.import.scss +2 -0
  20. data/node_modules/govuk-frontend/dist/govuk/components/_index.scss +2 -0
  21. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.js +87 -62
  22. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.js.map +1 -1
  23. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.mjs +87 -62
  24. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.mjs.map +1 -1
  25. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.mjs +60 -56
  26. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.mjs.map +1 -1
  27. data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.js +17 -6
  28. data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.js.map +1 -1
  29. data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.mjs +17 -6
  30. data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.mjs.map +1 -1
  31. data/node_modules/govuk-frontend/dist/govuk/components/button/button.mjs.map +1 -1
  32. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.js +90 -32
  33. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.js.map +1 -1
  34. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.mjs +90 -32
  35. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.mjs.map +1 -1
  36. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.mjs +64 -27
  37. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.mjs.map +1 -1
  38. data/node_modules/govuk-frontend/dist/govuk/components/character-count/fixtures.json +173 -6
  39. data/node_modules/govuk-frontend/dist/govuk/components/character-count/macro-options.json +13 -6
  40. data/node_modules/govuk-frontend/dist/govuk/components/character-count/template-with-count-type-characters-and-error-message.html +12 -0
  41. data/node_modules/govuk-frontend/dist/govuk/components/character-count/template-with-count-type-characters-and-threshold.html +9 -0
  42. data/node_modules/govuk-frontend/dist/govuk/components/character-count/template-with-count-type-characters-and-value.html +9 -0
  43. data/node_modules/govuk-frontend/dist/govuk/components/character-count/template-with-count-type-characters.html +9 -0
  44. data/node_modules/govuk-frontend/dist/govuk/components/character-count/template-with-count-type-length.html +9 -0
  45. data/node_modules/govuk-frontend/dist/govuk/components/character-count/template-with-count-type-words-and-error-message.html +12 -0
  46. data/node_modules/govuk-frontend/dist/govuk/components/character-count/template-with-count-type-words-and-threshold.html +9 -0
  47. data/node_modules/govuk-frontend/dist/govuk/components/character-count/template-with-count-type-words-and-value.html +9 -0
  48. data/node_modules/govuk-frontend/dist/govuk/components/character-count/template-with-count-type-words.html +9 -0
  49. data/node_modules/govuk-frontend/dist/govuk/components/character-count/template-with-maxwords.html +9 -0
  50. data/node_modules/govuk-frontend/dist/govuk/components/character-count/template.njk +10 -3
  51. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.js +12 -5
  52. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.js.map +1 -1
  53. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.mjs +12 -5
  54. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.mjs.map +1 -1
  55. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.mjs.map +1 -1
  56. data/node_modules/govuk-frontend/dist/govuk/components/cookie-banner/_mixin.scss +6 -0
  57. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.js +17 -6
  58. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.js.map +1 -1
  59. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.mjs +17 -6
  60. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.mjs.map +1 -1
  61. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.mjs.map +1 -1
  62. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js +43 -18
  63. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js.map +1 -1
  64. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs +43 -18
  65. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs.map +1 -1
  66. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.mjs +16 -12
  67. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.mjs.map +1 -1
  68. data/node_modules/govuk-frontend/dist/govuk/components/feedback/README.md +15 -0
  69. data/node_modules/govuk-frontend/dist/govuk/components/feedback/_feedback.import.scss +6 -0
  70. data/node_modules/govuk-frontend/dist/govuk/components/feedback/_index.import.scss +8 -0
  71. data/node_modules/govuk-frontend/dist/govuk/components/feedback/_index.scss +5 -0
  72. data/node_modules/govuk-frontend/dist/govuk/components/feedback/_mixin.scss +48 -0
  73. data/node_modules/govuk-frontend/dist/govuk/components/feedback/fixtures.json +95 -0
  74. data/node_modules/govuk-frontend/dist/govuk/components/feedback/macro-options.json +50 -0
  75. data/node_modules/govuk-frontend/dist/govuk/components/feedback/macro.njk +3 -0
  76. data/node_modules/govuk-frontend/dist/govuk/components/feedback/template-default.html +12 -0
  77. data/node_modules/govuk-frontend/dist/govuk/components/feedback/template-silly-example.html +19 -0
  78. data/node_modules/govuk-frontend/dist/govuk/components/feedback/template.njk +24 -0
  79. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.bundle.js +54 -30
  80. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.bundle.js.map +1 -1
  81. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.bundle.mjs +54 -30
  82. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.bundle.mjs.map +1 -1
  83. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.mjs +27 -24
  84. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.mjs.map +1 -1
  85. data/node_modules/govuk-frontend/dist/govuk/components/footer/_mixin.scss +6 -0
  86. data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/README.md +15 -0
  87. data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/_index.import.scss +8 -0
  88. data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/_index.scss +6 -0
  89. data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/_language-navigation.import.scss +6 -0
  90. data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/_mixin.scss +68 -0
  91. data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/fixtures.json +482 -0
  92. data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/macro-options.json +88 -0
  93. data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/macro.njk +3 -0
  94. data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/template-default.html +12 -0
  95. data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/template-inverse.html +12 -0
  96. data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/template-with-language-description.html +12 -0
  97. data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/template-with-large-amount-of-multiple-languages.html +99 -0
  98. data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/template-with-mixed-text-directions.html +12 -0
  99. data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/template-with-multiple-languages.html +24 -0
  100. data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/template-with-translated-navigation-label.html +12 -0
  101. data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/template.njk +33 -0
  102. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.js +17 -6
  103. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.js.map +1 -1
  104. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.mjs +17 -6
  105. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.mjs.map +1 -1
  106. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.mjs.map +1 -1
  107. data/node_modules/govuk-frontend/dist/govuk/components/panel/fixtures.json +13 -11
  108. data/node_modules/govuk-frontend/dist/govuk/components/panel/template-interruption-with-headings-content-and-lists.html +6 -1
  109. data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.js +32 -9
  110. data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.js.map +1 -1
  111. data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.mjs +32 -9
  112. data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.mjs.map +1 -1
  113. data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.mjs +5 -3
  114. data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.mjs.map +1 -1
  115. data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.js +12 -5
  116. data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.js.map +1 -1
  117. data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.mjs +12 -5
  118. data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.mjs.map +1 -1
  119. data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.mjs.map +1 -1
  120. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_mixin.scss +48 -3
  121. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/fixtures.json +121 -0
  122. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/macro-options.json +20 -0
  123. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.js +12 -5
  124. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.js.map +1 -1
  125. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.mjs +12 -5
  126. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.mjs.map +1 -1
  127. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.mjs.map +1 -1
  128. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-inverse-with-language-navigation.html +72 -0
  129. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-inline-end-slot.html +33 -0
  130. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-language-navigation.html +62 -0
  131. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-right-aligned-language-navigation.html +62 -0
  132. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template.njk +8 -3
  133. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.js +14 -6
  134. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.js.map +1 -1
  135. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.mjs +14 -6
  136. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.mjs.map +1 -1
  137. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.mjs +2 -1
  138. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.mjs.map +1 -1
  139. data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.js +12 -5
  140. data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.js.map +1 -1
  141. data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.mjs +12 -5
  142. data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.mjs.map +1 -1
  143. data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.mjs.map +1 -1
  144. data/node_modules/govuk-frontend/dist/govuk/custom-properties/_frontend-version.mixin.scss +1 -1
  145. data/node_modules/govuk-frontend/dist/govuk/custom-properties/_functional-colours.mixin.scss +1 -0
  146. data/node_modules/govuk-frontend/dist/govuk/errors/index.mjs +8 -5
  147. data/node_modules/govuk-frontend/dist/govuk/errors/index.mjs.map +1 -1
  148. data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.css +2 -2
  149. data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.css.map +1 -1
  150. data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.js +1 -1
  151. data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.js.map +1 -1
  152. data/node_modules/govuk-frontend/dist/govuk/helpers/_colour.scss +1 -1
  153. data/node_modules/govuk-frontend/dist/govuk/i18n.mjs.map +1 -1
  154. data/node_modules/govuk-frontend/dist/govuk/init.mjs +8 -8
  155. data/node_modules/govuk-frontend/dist/govuk/init.mjs.map +1 -1
  156. data/node_modules/govuk-frontend/dist/govuk/settings/_colours-organisations.scss +16 -2
  157. data/node_modules/govuk-frontend/govuk-prototype-kit.config.json +9 -1
  158. data/node_modules/govuk-frontend/package.json +9 -7
  159. data/vendor/assets/javascripts/defra_ruby_template.js +202 -137
  160. data/vendor/assets/stylesheets/components/_index.import.scss +2 -0
  161. data/vendor/assets/stylesheets/components/_index.scss +2 -0
  162. data/vendor/assets/stylesheets/components/cookie-banner/_mixin.scss +6 -0
  163. data/vendor/assets/stylesheets/components/feedback/_feedback.import.scss +6 -0
  164. data/vendor/assets/stylesheets/components/feedback/_index.import.scss +8 -0
  165. data/vendor/assets/stylesheets/components/feedback/_index.scss +5 -0
  166. data/vendor/assets/stylesheets/components/feedback/_mixin.scss +48 -0
  167. data/vendor/assets/stylesheets/components/footer/_mixin.scss +6 -0
  168. data/vendor/assets/stylesheets/components/language-navigation/_index.import.scss +8 -0
  169. data/vendor/assets/stylesheets/components/language-navigation/_index.scss +6 -0
  170. data/vendor/assets/stylesheets/components/language-navigation/_language-navigation.import.scss +6 -0
  171. data/vendor/assets/stylesheets/components/language-navigation/_mixin.scss +68 -0
  172. data/vendor/assets/stylesheets/components/service-navigation/_mixin.scss +48 -3
  173. data/vendor/assets/stylesheets/custom-properties/_frontend-version.mixin.scss +1 -1
  174. data/vendor/assets/stylesheets/custom-properties/_functional-colours.mixin.scss +1 -0
  175. data/vendor/assets/stylesheets/defra_ruby_template.scss +8 -30
  176. data/vendor/assets/stylesheets/govuk-frontend.min.css +2 -2
  177. data/vendor/assets/stylesheets/helpers/_colour.scss +1 -1
  178. data/vendor/assets/stylesheets/settings/_colours-organisations.scss +16 -2
  179. metadata +53 -3
  180. data/node_modules/govuk-frontend/dist/govuk/components/character-count/template-with-word-count.html +0 -9
@@ -1,4 +1,4 @@
1
- const version = '6.4.0';
1
+ const version = '6.6.0';
2
2
 
3
3
  function getBreakpoint(name) {
4
4
  const property = `--govuk-breakpoint-${name}`;
@@ -78,11 +78,14 @@ class SupportError extends GOVUKFrontendError {
78
78
  /**
79
79
  * Checks if GOV.UK Frontend is supported on this page
80
80
  *
81
- * @param {HTMLElement | null} [$scope] - HTML element `<body>` checked for browser support
81
+ * @param {Element | Document | null | string} [scopeOrMessage] - HTML element `<body>` checked for browser support or support error message
82
82
  */
83
- constructor($scope = document.body) {
84
- const supportMessage = 'noModule' in HTMLScriptElement.prototype ? 'GOV.UK Frontend initialised without `<body class="govuk-frontend-supported">` from template `<script>` snippet' : 'GOV.UK Frontend is not supported in this browser';
85
- super($scope ? supportMessage : 'GOV.UK Frontend initialised without `<script type="module">`');
83
+ constructor(scopeOrMessage = document.body) {
84
+ let supportMessage = 'noModule' in HTMLScriptElement.prototype ? 'GOV.UK Frontend initialised without `<body class="govuk-frontend-supported">` from template `<script>` snippet' : 'GOV.UK Frontend is not supported in this browser';
85
+ if (!isScope(scopeOrMessage)) {
86
+ supportMessage = 'GOV.UK Frontend initialised without `<script type="module">`';
87
+ }
88
+ super(typeof scopeOrMessage === 'string' ? scopeOrMessage : supportMessage);
86
89
  this.name = 'SupportError';
87
90
  }
88
91
  }
@@ -123,6 +126,7 @@ class InitError extends GOVUKFrontendError {
123
126
  * @import { ComponentWithModuleName } from '../common/index.mjs'
124
127
  */
125
128
 
129
+ const _self$1 = typeof globalThis !== 'undefined' ? globalThis : self;
126
130
  class Component {
127
131
  /**
128
132
  * Returns the root element of the component
@@ -176,7 +180,7 @@ class Component {
176
180
  /**
177
181
  * @typedef {typeof Component & ChildClass} ChildClassConstructor
178
182
  */
179
- Component.elementType = HTMLElement;
183
+ Component.elementType = _self$1.HTMLElement;
180
184
 
181
185
  const configOverride = Symbol.for('configOverride');
182
186
  class ConfigurableComponent extends Component {
@@ -201,10 +205,14 @@ class ConfigurableComponent extends Component {
201
205
  throw new ConfigError(formatErrorMessage(childConstructor, 'Config passed as parameter into constructor but no defaults defined'));
202
206
  }
203
207
  const datasetConfig = normaliseDataset(childConstructor, this._$root.dataset);
204
- this._config = mergeConfigs(childConstructor.defaults, config != null ? config : {}, this[configOverride](datasetConfig), datasetConfig);
208
+ this._config = mergeConfigs(childConstructor.defaults, config != null ? config : {});
209
+ this._config = mergeConfigs(this._config, this[configOverride](datasetConfig), datasetConfig);
205
210
  }
206
211
  }
207
212
  function normaliseString(value, property) {
213
+ if (property != null && property.type && !['string', 'number', 'boolean'].includes(property.type)) {
214
+ return;
215
+ }
208
216
  const trimmedValue = value ? value.trim() : '';
209
217
  let output;
210
218
  let outputType = property == null ? void 0 : property.type;
@@ -368,6 +376,17 @@ function extractConfigByNamespace(schema, dataset, namespace) {
368
376
  * @import { CompatibleClass, Config, CreateAllOptions, OnErrorCallback } from '../init.mjs'
369
377
  */
370
378
 
379
+ function createElement(tagName, attributes = {}, children = []) {
380
+ const $element = document.createElement(tagName);
381
+ Object.entries(attributes).forEach(([name, value]) => {
382
+ $element.setAttribute(name, value);
383
+ });
384
+ for (const child of children) {
385
+ $element.append(child);
386
+ }
387
+ return $element;
388
+ }
389
+
371
390
  class I18n {
372
391
  constructor(translations = {}, config = {}) {
373
392
  var _config$locale;
@@ -459,24 +478,16 @@ class Accordion extends ConfigurableComponent {
459
478
  constructor($root, config = {}) {
460
479
  super($root, config);
461
480
  this.i18n = void 0;
462
- this.controlsClass = 'govuk-accordion__controls';
463
- this.showAllClass = 'govuk-accordion__show-all';
464
- this.showAllTextClass = 'govuk-accordion__show-all-text';
465
481
  this.sectionClass = 'govuk-accordion__section';
466
- this.sectionExpandedClass = 'govuk-accordion__section--expanded';
482
+ this.sectionExpandedModifier = 'govuk-accordion__section--expanded';
467
483
  this.sectionButtonClass = 'govuk-accordion__section-button';
468
484
  this.sectionHeaderClass = 'govuk-accordion__section-header';
469
485
  this.sectionHeadingClass = 'govuk-accordion__section-heading';
470
- this.sectionHeadingDividerClass = 'govuk-accordion__section-heading-divider';
471
486
  this.sectionHeadingTextClass = 'govuk-accordion__section-heading-text';
472
- this.sectionHeadingTextFocusClass = 'govuk-accordion__section-heading-text-focus';
473
- this.sectionShowHideToggleClass = 'govuk-accordion__section-toggle';
474
- this.sectionShowHideToggleFocusClass = 'govuk-accordion__section-toggle-focus';
475
- this.sectionShowHideTextClass = 'govuk-accordion__section-toggle-text';
476
- this.upChevronIconClass = 'govuk-accordion-nav__chevron';
477
- this.downChevronIconClass = 'govuk-accordion-nav__chevron--down';
487
+ this.sectionToggleTextClass = 'govuk-accordion__section-toggle-text';
488
+ this.iconClass = 'govuk-accordion-nav__chevron';
489
+ this.iconOpenModifier = 'govuk-accordion-nav__chevron--down';
478
490
  this.sectionSummaryClass = 'govuk-accordion__section-summary';
479
- this.sectionSummaryFocusClass = 'govuk-accordion__section-summary-focus';
480
491
  this.sectionContentClass = 'govuk-accordion__section-content';
481
492
  this.$sections = void 0;
482
493
  this.$showAllButton = null;
@@ -496,19 +507,23 @@ class Accordion extends ConfigurableComponent {
496
507
  this.updateShowAllButton(this.areAllSectionsOpen());
497
508
  }
498
509
  initControls() {
499
- this.$showAllButton = document.createElement('button');
500
- this.$showAllButton.setAttribute('type', 'button');
501
- this.$showAllButton.setAttribute('class', this.showAllClass);
502
- this.$showAllButton.setAttribute('aria-expanded', 'false');
503
- this.$showAllIcon = document.createElement('span');
504
- this.$showAllIcon.classList.add(this.upChevronIconClass);
510
+ this.$showAllButton = createElement('button', {
511
+ type: 'button',
512
+ class: 'govuk-accordion__show-all',
513
+ 'aria-expanded': 'false'
514
+ });
515
+ this.$showAllIcon = createElement('span', {
516
+ class: this.iconClass
517
+ });
505
518
  this.$showAllButton.appendChild(this.$showAllIcon);
506
- const $accordionControls = document.createElement('div');
507
- $accordionControls.setAttribute('class', this.controlsClass);
519
+ const $accordionControls = createElement('div', {
520
+ class: 'govuk-accordion__controls'
521
+ });
508
522
  $accordionControls.appendChild(this.$showAllButton);
509
523
  this.$root.insertBefore($accordionControls, this.$root.firstChild);
510
- this.$showAllText = document.createElement('span');
511
- this.$showAllText.classList.add(this.showAllTextClass);
524
+ this.$showAllText = createElement('span', {
525
+ class: 'govuk-accordion__show-all-text'
526
+ });
512
527
  this.$showAllButton.appendChild(this.$showAllText);
513
528
  this.$showAllButton.addEventListener('click', () => this.onShowOrHideAllToggle());
514
529
  if ('onbeforematch' in document) {
@@ -546,39 +561,45 @@ class Accordion extends ConfigurableComponent {
546
561
  identifier: `Section button placeholder (\`<span class="${this.sectionButtonClass}">\`)`
547
562
  });
548
563
  }
549
- const $button = document.createElement('button');
550
- $button.setAttribute('type', 'button');
551
- $button.setAttribute('aria-controls', `${this.$root.id}-content-${index + 1}`);
564
+ const $button = createElement('button', {
565
+ type: 'button',
566
+ 'aria-controls': `${this.$root.id}-content-${index + 1}`
567
+ });
552
568
  for (const attr of Array.from($span.attributes)) {
553
569
  if (attr.name !== 'id') {
554
570
  $button.setAttribute(attr.name, attr.value);
555
571
  }
556
572
  }
557
- const $headingText = document.createElement('span');
558
- $headingText.classList.add(this.sectionHeadingTextClass);
559
- $headingText.id = $span.id;
560
- const $headingTextFocus = document.createElement('span');
561
- $headingTextFocus.classList.add(this.sectionHeadingTextFocusClass);
573
+ const $headingText = createElement('span', {
574
+ class: this.sectionHeadingTextClass,
575
+ id: $span.id
576
+ });
577
+ const $headingTextFocus = createElement('span', {
578
+ class: 'govuk-accordion__section-heading-text-focus'
579
+ });
562
580
  $headingText.appendChild($headingTextFocus);
563
581
  Array.from($span.childNodes).forEach($child => $headingTextFocus.appendChild($child));
564
- const $showHideToggle = document.createElement('span');
565
- $showHideToggle.classList.add(this.sectionShowHideToggleClass);
566
- $showHideToggle.setAttribute('data-nosnippet', '');
567
- const $showHideToggleFocus = document.createElement('span');
568
- $showHideToggleFocus.classList.add(this.sectionShowHideToggleFocusClass);
582
+ const $showHideToggle = createElement('span', {
583
+ class: 'govuk-accordion__section-toggle',
584
+ 'data-nosnippet': ''
585
+ });
586
+ const $showHideToggleFocus = createElement('span', {
587
+ class: 'govuk-accordion__section-toggle-focus'
588
+ });
569
589
  $showHideToggle.appendChild($showHideToggleFocus);
570
- const $showHideText = document.createElement('span');
571
- const $showHideIcon = document.createElement('span');
572
- $showHideIcon.classList.add(this.upChevronIconClass);
573
- $showHideToggleFocus.appendChild($showHideIcon);
574
- $showHideText.classList.add(this.sectionShowHideTextClass);
575
- $showHideToggleFocus.appendChild($showHideText);
590
+ $showHideToggleFocus.appendChild(createElement('span', {
591
+ class: this.iconClass
592
+ }));
593
+ $showHideToggleFocus.appendChild(createElement('span', {
594
+ class: this.sectionToggleTextClass
595
+ }));
576
596
  $button.appendChild($headingText);
577
597
  $button.appendChild(this.getButtonPunctuationEl());
578
598
  if ($summary) {
579
- const $summarySpan = document.createElement('span');
580
- const $summarySpanFocus = document.createElement('span');
581
- $summarySpanFocus.classList.add(this.sectionSummaryFocusClass);
599
+ const $summarySpan = createElement('span');
600
+ const $summarySpanFocus = createElement('span', {
601
+ class: 'govuk-accordion__section-summary-focus'
602
+ });
582
603
  $summarySpan.appendChild($summarySpanFocus);
583
604
  for (const attr of Array.from($summary.attributes)) {
584
605
  $summarySpan.setAttribute(attr.name, attr.value);
@@ -616,8 +637,8 @@ class Accordion extends ConfigurableComponent {
616
637
  this.updateShowAllButton(nowExpanded);
617
638
  }
618
639
  setExpanded(expanded, $section) {
619
- const $showHideIcon = $section.querySelector(`.${this.upChevronIconClass}`);
620
- const $showHideText = $section.querySelector(`.${this.sectionShowHideTextClass}`);
640
+ const $showHideIcon = $section.querySelector(`.${this.iconClass}`);
641
+ const $showHideText = $section.querySelector(`.${this.sectionToggleTextClass}`);
621
642
  const $button = $section.querySelector(`.${this.sectionButtonClass}`);
622
643
  const $content = $section.querySelector(`.${this.sectionContentClass}`);
623
644
  if (!$content) {
@@ -646,17 +667,17 @@ class Accordion extends ConfigurableComponent {
646
667
  $button.setAttribute('aria-label', ariaLabelParts.join(' , '));
647
668
  if (expanded) {
648
669
  $content.removeAttribute('hidden');
649
- $section.classList.add(this.sectionExpandedClass);
650
- $showHideIcon.classList.remove(this.downChevronIconClass);
670
+ $section.classList.add(this.sectionExpandedModifier);
671
+ $showHideIcon.classList.remove(this.iconOpenModifier);
651
672
  } else {
652
673
  $content.setAttribute('hidden', 'until-found');
653
- $section.classList.remove(this.sectionExpandedClass);
654
- $showHideIcon.classList.add(this.downChevronIconClass);
674
+ $section.classList.remove(this.sectionExpandedModifier);
675
+ $showHideIcon.classList.add(this.iconOpenModifier);
655
676
  }
656
677
  this.updateShowAllButton(this.areAllSectionsOpen());
657
678
  }
658
679
  isExpanded($section) {
659
- return $section.classList.contains(this.sectionExpandedClass);
680
+ return $section.classList.contains(this.sectionExpandedModifier);
660
681
  }
661
682
  areAllSectionsOpen() {
662
683
  return Array.from(this.$sections).every($section => this.isExpanded($section));
@@ -667,7 +688,7 @@ class Accordion extends ConfigurableComponent {
667
688
  }
668
689
  this.$showAllButton.setAttribute('aria-expanded', expanded.toString());
669
690
  this.$showAllText.textContent = expanded ? this.i18n.t('hideAllSections') : this.i18n.t('showAllSections');
670
- this.$showAllIcon.classList.toggle(this.downChevronIconClass, !expanded);
691
+ this.$showAllIcon.classList.toggle(this.iconOpenModifier, !expanded);
671
692
  }
672
693
 
673
694
  /**
@@ -710,10 +731,11 @@ class Accordion extends ConfigurableComponent {
710
731
  }
711
732
  }
712
733
  getButtonPunctuationEl() {
713
- const $punctuationEl = document.createElement('span');
714
- $punctuationEl.classList.add('govuk-visually-hidden', this.sectionHeadingDividerClass);
715
- $punctuationEl.textContent = ', ';
716
- return $punctuationEl;
734
+ const $element = createElement('span', {
735
+ class: 'govuk-visually-hidden govuk-accordion__section-heading-divider'
736
+ });
737
+ $element.textContent = ', ';
738
+ return $element;
717
739
  }
718
740
  }
719
741
 
@@ -869,6 +891,14 @@ class CharacterCount extends ConfigurableComponent {
869
891
  maxwords: undefined
870
892
  };
871
893
  }
894
+ if ('maxwords' in datasetConfig || this.config.maxwords !== undefined) {
895
+ console.warn(formatErrorMessage(CharacterCount, 'Option `maxwords` is deprecated. Use `maxlength` with `countType: "words"` instead.'));
896
+ if (!('maxlength' in datasetConfig)) {
897
+ var _datasetConfig$maxwor;
898
+ configOverrides.maxlength = (_datasetConfig$maxwor = datasetConfig.maxwords) != null ? _datasetConfig$maxwor : this.config.maxwords;
899
+ configOverrides.countType = 'words';
900
+ }
901
+ }
872
902
  return configOverrides;
873
903
  }
874
904
 
@@ -877,10 +907,11 @@ class CharacterCount extends ConfigurableComponent {
877
907
  * @param {CharacterCountConfig} [config] - Character count config
878
908
  */
879
909
  constructor($root, config = {}) {
880
- var _ref, _this$config$maxwords;
910
+ var _this$config$maxlengt;
881
911
  super($root, config);
882
912
  this.$textarea = void 0;
883
913
  this.count = 0;
914
+ this.segmenter = null;
884
915
  this.$visibleCountMessage = void 0;
885
916
  this.$screenReaderCountMessage = void 0;
886
917
  this.lastInputTimestamp = null;
@@ -904,7 +935,15 @@ class CharacterCount extends ConfigurableComponent {
904
935
  this.i18n = new I18n(this.config.i18n, {
905
936
  locale: closestAttributeValue(this.$root, 'lang')
906
937
  });
907
- this.maxLength = (_ref = (_this$config$maxwords = this.config.maxwords) != null ? _this$config$maxwords : this.config.maxlength) != null ? _ref : Infinity;
938
+ if (this.config.countType === 'characters' || this.config.countType === 'words' && this.config.maxwords === undefined) {
939
+ if (!('Segmenter' in Intl)) {
940
+ throw new SupportError(formatErrorMessage(CharacterCount, 'Support for "Intl.Segmenter" required'));
941
+ }
942
+ this.segmenter = new Intl.Segmenter(this.i18n.locale, {
943
+ granularity: this.config.countType === 'words' ? 'word' : 'grapheme'
944
+ });
945
+ }
946
+ this.maxLength = (_this$config$maxlengt = this.config.maxlength) != null ? _this$config$maxlengt : Infinity;
908
947
  this.$textarea = $textarea;
909
948
  const textareaDescriptionId = `${this.$textarea.id}-info`;
910
949
  const $textareaDescription = document.getElementById(textareaDescriptionId);
@@ -922,15 +961,16 @@ class CharacterCount extends ConfigurableComponent {
922
961
  });
923
962
  }
924
963
  this.$textarea.insertAdjacentElement('afterend', $textareaDescription);
925
- const $screenReaderCountMessage = document.createElement('div');
926
- $screenReaderCountMessage.className = 'govuk-character-count__sr-status govuk-visually-hidden';
927
- $screenReaderCountMessage.setAttribute('aria-live', 'polite');
964
+ const $screenReaderCountMessage = createElement('div', {
965
+ class: 'govuk-character-count__sr-status govuk-visually-hidden',
966
+ 'aria-live': 'polite'
967
+ });
928
968
  this.$screenReaderCountMessage = $screenReaderCountMessage;
929
969
  $textareaDescription.insertAdjacentElement('afterend', $screenReaderCountMessage);
930
- const $visibleCountMessage = document.createElement('div');
931
- $visibleCountMessage.className = $textareaDescription.className;
932
- $visibleCountMessage.classList.add('govuk-character-count__status');
933
- $visibleCountMessage.setAttribute('aria-hidden', 'true');
970
+ const $visibleCountMessage = createElement('div', {
971
+ class: `${$textareaDescription.className} govuk-character-count__status`,
972
+ 'aria-hidden': 'true'
973
+ });
934
974
  this.$visibleCountMessage = $visibleCountMessage;
935
975
  $textareaDescription.insertAdjacentElement('afterend', $visibleCountMessage);
936
976
  $textareaDescription.classList.add('govuk-visually-hidden');
@@ -998,26 +1038,38 @@ class CharacterCount extends ConfigurableComponent {
998
1038
  }
999
1039
  updateCount() {
1000
1040
  const text = this.$textarea.value;
1001
- if (this.config.maxwords) {
1002
- var _text$match;
1003
- const tokens = (_text$match = text.match(/\S+/g)) != null ? _text$match : [];
1004
- this.count = tokens.length;
1041
+ if (this.config.countType === 'characters') {
1042
+ this.count = this.segmenter ? Array.from(this.segmenter.segment(text)).length : 0;
1043
+ return;
1044
+ }
1045
+ if (this.config.countType === 'words') {
1046
+ if (this.config.maxwords !== undefined) {
1047
+ var _text$match$length, _text$match;
1048
+ this.count = (_text$match$length = (_text$match = text.match(/\S+/g)) == null ? void 0 : _text$match.length) != null ? _text$match$length : 0;
1049
+ return;
1050
+ }
1051
+ const segments = this.segmenter ? Array.from(this.segmenter.segment(text)) : [];
1052
+ this.count = segments.filter(segment => segment.isWordLike).length;
1005
1053
  return;
1006
1054
  }
1007
1055
  this.count = text.length;
1008
1056
  }
1009
1057
  getCountMessage() {
1010
1058
  const remainingNumber = this.maxLength - this.count;
1011
- const countType = this.config.maxwords ? 'words' : 'characters';
1012
- return this.formatCountMessage(remainingNumber, countType);
1059
+ return this.formatCountMessage(remainingNumber);
1013
1060
  }
1014
1061
  formatCountMessage(remainingNumber, countType) {
1062
+ countType = countType != null ? countType : this.config.countType;
1063
+ let translationKeyPrefix = 'characters';
1064
+ let translationKeySuffix = remainingNumber < 0 ? 'OverLimit' : 'UnderLimit';
1065
+ if (countType === 'words') {
1066
+ translationKeyPrefix = 'words';
1067
+ }
1015
1068
  if (remainingNumber === 0) {
1016
- return this.i18n.t(`${countType}AtLimit`);
1069
+ translationKeySuffix = 'AtLimit';
1017
1070
  }
1018
- const translationKeySuffix = remainingNumber < 0 ? 'OverLimit' : 'UnderLimit';
1019
- return this.i18n.t(`${countType}${translationKeySuffix}`, {
1020
- count: Math.abs(remainingNumber)
1071
+ return this.i18n.t(`${translationKeyPrefix}${translationKeySuffix}`, {
1072
+ count: remainingNumber === 0 ? undefined : Math.abs(remainingNumber)
1021
1073
  });
1022
1074
  }
1023
1075
  isOverThreshold() {
@@ -1036,13 +1088,15 @@ class CharacterCount extends ConfigurableComponent {
1036
1088
  *
1037
1089
  * @see {@link CharacterCount.defaults}
1038
1090
  * @typedef {object} CharacterCountConfig
1039
- * @property {number} [maxlength] - The maximum number of characters.
1040
- * If maxwords is provided, the maxlength option will be ignored.
1041
- * @property {number} [maxwords] - The maximum number of words. If maxwords is
1042
- * provided, the maxlength option will be ignored.
1091
+ * @property {number} [maxlength] - The maximum number of characters (or words
1092
+ * if `countType` is set to `"words"`).
1093
+ * @property {number} [maxwords] - Deprecated. Use `maxlength` and
1094
+ * `countType: "words"` instead.
1043
1095
  * @property {number} [threshold=0] - The percentage value of the limit at
1044
1096
  * which point the count message is displayed. If this attribute is set, the
1045
1097
  * count message will be hidden by default.
1098
+ * @property {'characters' | 'length' | 'words'} [countType] - The count type
1099
+ * (`"characters"`, `"length"` or `"words"`) used to count the text.
1046
1100
  * @property {CharacterCountTranslations} [i18n=CharacterCount.defaults.i18n] - Character count translations
1047
1101
  */
1048
1102
 
@@ -1088,9 +1142,9 @@ class CharacterCount extends ConfigurableComponent {
1088
1142
  * @property {TranslationPluralForms} [textareaDescription] - Message made
1089
1143
  * available to assistive technologies, if none is already present in the
1090
1144
  * HTML, to describe that the component accepts only a limited amount of
1091
- * content. It is visible on the page when JavaScript is unavailable. The
1092
- * component will replace the `%{count}` placeholder with the value of the
1093
- * `maxlength` or `maxwords` parameter.
1145
+ * content. It is visible on the page if `countType` is not supported or
1146
+ * JavaScript is unavailable. The component will replace the `%{count}`
1147
+ * placeholder with the value of the `maxlength` parameter.
1094
1148
  */
1095
1149
 
1096
1150
  /**
@@ -1100,6 +1154,7 @@ class CharacterCount extends ConfigurableComponent {
1100
1154
  CharacterCount.moduleName = 'govuk-character-count';
1101
1155
  CharacterCount.defaults = Object.freeze({
1102
1156
  threshold: 0,
1157
+ countType: 'length',
1103
1158
  i18n: {
1104
1159
  charactersUnderLimit: {
1105
1160
  one: 'You have %{count} character remaining',
@@ -1137,6 +1192,9 @@ CharacterCount.schema = Object.freeze({
1137
1192
  },
1138
1193
  threshold: {
1139
1194
  type: 'number'
1195
+ },
1196
+ countType: {
1197
+ type: 'string'
1140
1198
  }
1141
1199
  },
1142
1200
  anyOf: [{
@@ -1399,9 +1457,10 @@ class ExitThisPage extends ConfigurableComponent {
1399
1457
  window.addEventListener('pageshow', this.resetPage.bind(this));
1400
1458
  }
1401
1459
  initUpdateSpan() {
1402
- this.$updateSpan = document.createElement('span');
1403
- this.$updateSpan.setAttribute('role', 'status');
1404
- this.$updateSpan.className = 'govuk-visually-hidden';
1460
+ this.$updateSpan = createElement('span', {
1461
+ role: 'status',
1462
+ class: 'govuk-visually-hidden'
1463
+ });
1405
1464
  this.$root.appendChild(this.$updateSpan);
1406
1465
  }
1407
1466
  initButtonClickHandler() {
@@ -1411,13 +1470,14 @@ class ExitThisPage extends ConfigurableComponent {
1411
1470
  }
1412
1471
  }
1413
1472
  buildIndicator() {
1414
- this.$indicatorContainer = document.createElement('div');
1415
- this.$indicatorContainer.className = 'govuk-exit-this-page__indicator';
1416
- this.$indicatorContainer.setAttribute('aria-hidden', 'true');
1473
+ this.$indicatorContainer = createElement('div', {
1474
+ class: 'govuk-exit-this-page__indicator',
1475
+ 'aria-hidden': 'true'
1476
+ });
1417
1477
  for (let i = 0; i < 3; i++) {
1418
- const $indicator = document.createElement('div');
1419
- $indicator.className = 'govuk-exit-this-page__indicator-light';
1420
- this.$indicatorContainer.appendChild($indicator);
1478
+ this.$indicatorContainer.appendChild(createElement('div', {
1479
+ class: 'govuk-exit-this-page__indicator-light'
1480
+ }));
1421
1481
  }
1422
1482
  this.$button.appendChild(this.$indicatorContainer);
1423
1483
  }
@@ -1437,9 +1497,10 @@ class ExitThisPage extends ConfigurableComponent {
1437
1497
  }
1438
1498
  this.$updateSpan.textContent = '';
1439
1499
  document.body.classList.add('govuk-exit-this-page-hide-content');
1440
- this.$overlay = document.createElement('div');
1441
- this.$overlay.className = 'govuk-exit-this-page-overlay';
1442
- this.$overlay.setAttribute('role', 'alert');
1500
+ this.$overlay = createElement('div', {
1501
+ class: 'govuk-exit-this-page-overlay',
1502
+ role: 'alert'
1503
+ });
1443
1504
  document.body.appendChild(this.$overlay);
1444
1505
  this.$overlay.textContent = this.i18n.t('activated');
1445
1506
  window.location.href = this.$button.href;
@@ -1619,46 +1680,48 @@ class FileUpload extends ConfigurableComponent {
1619
1680
  this.$input.addEventListener('change', this.onChange.bind(this));
1620
1681
  this.updateDisabledState();
1621
1682
  this.observeDisabledState();
1622
- this.$announcements = document.createElement('span');
1623
- this.$announcements.classList.add('govuk-file-upload-announcements');
1624
- this.$announcements.classList.add('govuk-visually-hidden');
1625
- this.$announcements.setAttribute('aria-live', 'assertive');
1683
+ this.$announcements = createElement('span', {
1684
+ class: 'govuk-file-upload-announcements govuk-visually-hidden',
1685
+ 'aria-live': 'assertive'
1686
+ });
1626
1687
  this.$root.insertAdjacentElement('afterend', this.$announcements);
1627
1688
  this.bindDraggingEvents();
1628
1689
  }
1629
1690
  createStatus() {
1630
- const $status = document.createElement('span');
1631
- $status.className = 'govuk-body govuk-file-upload-button__status';
1632
- $status.setAttribute('aria-live', 'polite');
1691
+ const $status = createElement('span', {
1692
+ class: 'govuk-body govuk-file-upload-button__status',
1693
+ 'aria-live': 'polite'
1694
+ });
1633
1695
  $status.innerText = this.i18n.t('noFileChosen');
1634
1696
  return $status;
1635
1697
  }
1636
1698
  createButton() {
1637
- const $button = document.createElement('button');
1638
- $button.classList.add('govuk-file-upload-button');
1639
- $button.type = 'button';
1640
- $button.id = this.id;
1641
- $button.classList.add('govuk-file-upload-button--empty');
1699
+ const $button = createElement('button', {
1700
+ class: 'govuk-file-upload-button govuk-file-upload-button--empty',
1701
+ type: 'button',
1702
+ id: this.id
1703
+ });
1642
1704
  const ariaDescribedBy = this.$input.getAttribute('aria-describedby');
1643
1705
  if (ariaDescribedBy) {
1644
1706
  $button.setAttribute('aria-describedby', ariaDescribedBy);
1645
1707
  }
1646
1708
  $button.appendChild(this.$status);
1647
- const commaSpan = document.createElement('span');
1648
- commaSpan.className = 'govuk-visually-hidden';
1649
- commaSpan.innerText = ', ';
1650
- commaSpan.id = `${this.id}-comma`;
1709
+ const commaSpan = createElement('span', {
1710
+ class: 'govuk-visually-hidden',
1711
+ id: `${this.id}-comma`
1712
+ }, [', ']);
1651
1713
  $button.appendChild(commaSpan);
1652
- const containerSpan = document.createElement('span');
1653
- containerSpan.className = 'govuk-file-upload-button__pseudo-button-container';
1654
- const buttonSpan = document.createElement('span');
1655
- buttonSpan.className = 'govuk-button govuk-button--secondary govuk-file-upload-button__pseudo-button';
1656
- buttonSpan.innerText = this.i18n.t('chooseFilesButton');
1714
+ const containerSpan = createElement('span', {
1715
+ class: 'govuk-file-upload-button__pseudo-button-container'
1716
+ });
1717
+ const buttonSpan = createElement('span', {
1718
+ class: 'govuk-button govuk-button--secondary govuk-file-upload-button__pseudo-button'
1719
+ }, [this.i18n.t('chooseFilesButton')]);
1657
1720
  containerSpan.appendChild(buttonSpan);
1658
1721
  containerSpan.insertAdjacentText('beforeend', ' ');
1659
- const instructionSpan = document.createElement('span');
1660
- instructionSpan.className = 'govuk-body govuk-file-upload-button__instruction';
1661
- instructionSpan.innerText = this.i18n.t('dropInstruction');
1722
+ const instructionSpan = createElement('span', {
1723
+ class: 'govuk-body govuk-file-upload-button__instruction'
1724
+ }, [this.i18n.t('dropInstruction')]);
1662
1725
  containerSpan.appendChild(instructionSpan);
1663
1726
  $button.appendChild(containerSpan);
1664
1727
  $button.setAttribute('aria-labelledby', `${this.$label.id} ${commaSpan.id} ${$button.id}`);
@@ -1942,9 +2005,10 @@ class PasswordInput extends ConfigurableComponent {
1942
2005
  locale: closestAttributeValue(this.$root, 'lang')
1943
2006
  });
1944
2007
  this.$showHideButton.removeAttribute('hidden');
1945
- const $screenReaderStatusMessage = document.createElement('div');
1946
- $screenReaderStatusMessage.className = 'govuk-password-input__sr-status govuk-visually-hidden';
1947
- $screenReaderStatusMessage.setAttribute('aria-live', 'polite');
2008
+ const $screenReaderStatusMessage = createElement('div', {
2009
+ class: 'govuk-password-input__sr-status govuk-visually-hidden',
2010
+ 'aria-live': 'polite'
2011
+ });
1948
2012
  this.$screenReaderStatusMessage = $screenReaderStatusMessage;
1949
2013
  this.$input.insertAdjacentElement('afterend', $screenReaderStatusMessage);
1950
2014
  this.$showHideButton.addEventListener('click', this.toggle.bind(this));
@@ -2228,6 +2292,7 @@ function removeAttributes($element, attributeNames) {
2228
2292
  }
2229
2293
  }
2230
2294
 
2295
+ const _self = typeof globalThis !== 'undefined' ? globalThis : self;
2231
2296
  /**
2232
2297
  * Skip link component
2233
2298
  *
@@ -2271,7 +2336,7 @@ class SkipLink extends Component {
2271
2336
  }));
2272
2337
  }
2273
2338
  }
2274
- SkipLink.elementType = HTMLAnchorElement;
2339
+ SkipLink.elementType = _self.HTMLAnchorElement;
2275
2340
  SkipLink.moduleName = 'govuk-skip-link';
2276
2341
 
2277
2342
  /**
@@ -2656,14 +2721,14 @@ function createAll(Component, config, scopeOrOptions) {
2656
2721
  * @typedef {object} Config
2657
2722
  * @property {Element | Document | null} [scope] - Scope of the document to search within
2658
2723
  * @property {OnErrorCallback<CompatibleClass>} [onError] - Initialisation error callback
2659
- * @property {AccordionConfig} [accordion] - Accordion config
2660
- * @property {ButtonConfig} [button] - Button config
2661
- * @property {CharacterCountConfig} [characterCount] - Character Count config
2662
- * @property {ErrorSummaryConfig} [errorSummary] - Error Summary config
2663
- * @property {ExitThisPageConfig} [exitThisPage] - Exit This Page config
2664
- * @property {FileUploadConfig} [fileUpload] - File Upload config
2665
- * @property {NotificationBannerConfig} [notificationBanner] - Notification Banner config
2666
- * @property {PasswordInputConfig} [passwordInput] - Password input config
2724
+ * @property {ComponentConfig<typeof Accordion>} [accordion] - Accordion config
2725
+ * @property {ComponentConfig<typeof Button>} [button] - Button config
2726
+ * @property {ComponentConfig<typeof CharacterCount>} [characterCount] - Character Count config
2727
+ * @property {ComponentConfig<typeof ErrorSummary>} [errorSummary] - Error Summary config
2728
+ * @property {ComponentConfig<typeof ExitThisPage>} [exitThisPage] - Exit This Page config
2729
+ * @property {ComponentConfig<typeof FileUpload>} [fileUpload] - File Upload config
2730
+ * @property {ComponentConfig<typeof NotificationBanner>} [notificationBanner] - Notification Banner config
2731
+ * @property {ComponentConfig<typeof PasswordInput>} [passwordInput] - Password input config
2667
2732
  */
2668
2733
  /**
2669
2734
  * Config for individual components