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
@@ -23,6 +23,9 @@ function isArray(option) {
23
23
  function isObject(option) {
24
24
  return !!option && typeof option === 'object' && !isArray(option);
25
25
  }
26
+ function isScope($scope) {
27
+ return !!$scope && ($scope instanceof Element || $scope instanceof Document);
28
+ }
26
29
  function formatErrorMessage(Component, message) {
27
30
  return `${Component.moduleName}: ${message}`;
28
31
  }
@@ -41,11 +44,14 @@ class SupportError extends GOVUKFrontendError {
41
44
  /**
42
45
  * Checks if GOV.UK Frontend is supported on this page
43
46
  *
44
- * @param {HTMLElement | null} [$scope] - HTML element `<body>` checked for browser support
47
+ * @param {Element | Document | null | string} [scopeOrMessage] - HTML element `<body>` checked for browser support or support error message
45
48
  */
46
- constructor($scope = document.body) {
47
- 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';
48
- super($scope ? supportMessage : 'GOV.UK Frontend initialised without `<script type="module">`');
49
+ constructor(scopeOrMessage = document.body) {
50
+ 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';
51
+ if (!isScope(scopeOrMessage)) {
52
+ supportMessage = 'GOV.UK Frontend initialised without `<script type="module">`';
53
+ }
54
+ super(typeof scopeOrMessage === 'string' ? scopeOrMessage : supportMessage);
49
55
  this.name = 'SupportError';
50
56
  }
51
57
  }
@@ -86,6 +92,7 @@ class InitError extends GOVUKFrontendError {
86
92
  * @import { ComponentWithModuleName } from '../common/index.mjs'
87
93
  */
88
94
 
95
+ const _self = typeof globalThis !== 'undefined' ? globalThis : self;
89
96
  class Component {
90
97
  /**
91
98
  * Returns the root element of the component
@@ -139,7 +146,7 @@ class Component {
139
146
  /**
140
147
  * @typedef {typeof Component & ChildClass} ChildClassConstructor
141
148
  */
142
- Component.elementType = HTMLElement;
149
+ Component.elementType = _self.HTMLElement;
143
150
 
144
151
  const configOverride = Symbol.for('configOverride');
145
152
  class ConfigurableComponent extends Component {
@@ -164,10 +171,14 @@ class ConfigurableComponent extends Component {
164
171
  throw new ConfigError(formatErrorMessage(childConstructor, 'Config passed as parameter into constructor but no defaults defined'));
165
172
  }
166
173
  const datasetConfig = normaliseDataset(childConstructor, this._$root.dataset);
167
- this._config = mergeConfigs(childConstructor.defaults, config != null ? config : {}, this[configOverride](datasetConfig), datasetConfig);
174
+ this._config = mergeConfigs(childConstructor.defaults, config != null ? config : {});
175
+ this._config = mergeConfigs(this._config, this[configOverride](datasetConfig), datasetConfig);
168
176
  }
169
177
  }
170
178
  function normaliseString(value, property) {
179
+ if (property != null && property.type && !['string', 'number', 'boolean'].includes(property.type)) {
180
+ return;
181
+ }
171
182
  const trimmedValue = value ? value.trim() : '';
172
183
  let output;
173
184
  let outputType = property == null ? void 0 : property.type;
@@ -287,6 +298,17 @@ function extractConfigByNamespace(schema, dataset, namespace) {
287
298
  * @import { CompatibleClass, Config, CreateAllOptions, OnErrorCallback } from '../init.mjs'
288
299
  */
289
300
 
301
+ function createElement(tagName, attributes = {}, children = []) {
302
+ const $element = document.createElement(tagName);
303
+ Object.entries(attributes).forEach(([name, value]) => {
304
+ $element.setAttribute(name, value);
305
+ });
306
+ for (const child of children) {
307
+ $element.append(child);
308
+ }
309
+ return $element;
310
+ }
311
+
290
312
  class I18n {
291
313
  constructor(translations = {}, config = {}) {
292
314
  var _config$locale;
@@ -378,24 +400,16 @@ class Accordion extends ConfigurableComponent {
378
400
  constructor($root, config = {}) {
379
401
  super($root, config);
380
402
  this.i18n = void 0;
381
- this.controlsClass = 'govuk-accordion__controls';
382
- this.showAllClass = 'govuk-accordion__show-all';
383
- this.showAllTextClass = 'govuk-accordion__show-all-text';
384
403
  this.sectionClass = 'govuk-accordion__section';
385
- this.sectionExpandedClass = 'govuk-accordion__section--expanded';
404
+ this.sectionExpandedModifier = 'govuk-accordion__section--expanded';
386
405
  this.sectionButtonClass = 'govuk-accordion__section-button';
387
406
  this.sectionHeaderClass = 'govuk-accordion__section-header';
388
407
  this.sectionHeadingClass = 'govuk-accordion__section-heading';
389
- this.sectionHeadingDividerClass = 'govuk-accordion__section-heading-divider';
390
408
  this.sectionHeadingTextClass = 'govuk-accordion__section-heading-text';
391
- this.sectionHeadingTextFocusClass = 'govuk-accordion__section-heading-text-focus';
392
- this.sectionShowHideToggleClass = 'govuk-accordion__section-toggle';
393
- this.sectionShowHideToggleFocusClass = 'govuk-accordion__section-toggle-focus';
394
- this.sectionShowHideTextClass = 'govuk-accordion__section-toggle-text';
395
- this.upChevronIconClass = 'govuk-accordion-nav__chevron';
396
- this.downChevronIconClass = 'govuk-accordion-nav__chevron--down';
409
+ this.sectionToggleTextClass = 'govuk-accordion__section-toggle-text';
410
+ this.iconClass = 'govuk-accordion-nav__chevron';
411
+ this.iconOpenModifier = 'govuk-accordion-nav__chevron--down';
397
412
  this.sectionSummaryClass = 'govuk-accordion__section-summary';
398
- this.sectionSummaryFocusClass = 'govuk-accordion__section-summary-focus';
399
413
  this.sectionContentClass = 'govuk-accordion__section-content';
400
414
  this.$sections = void 0;
401
415
  this.$showAllButton = null;
@@ -415,19 +429,23 @@ class Accordion extends ConfigurableComponent {
415
429
  this.updateShowAllButton(this.areAllSectionsOpen());
416
430
  }
417
431
  initControls() {
418
- this.$showAllButton = document.createElement('button');
419
- this.$showAllButton.setAttribute('type', 'button');
420
- this.$showAllButton.setAttribute('class', this.showAllClass);
421
- this.$showAllButton.setAttribute('aria-expanded', 'false');
422
- this.$showAllIcon = document.createElement('span');
423
- this.$showAllIcon.classList.add(this.upChevronIconClass);
432
+ this.$showAllButton = createElement('button', {
433
+ type: 'button',
434
+ class: 'govuk-accordion__show-all',
435
+ 'aria-expanded': 'false'
436
+ });
437
+ this.$showAllIcon = createElement('span', {
438
+ class: this.iconClass
439
+ });
424
440
  this.$showAllButton.appendChild(this.$showAllIcon);
425
- const $accordionControls = document.createElement('div');
426
- $accordionControls.setAttribute('class', this.controlsClass);
441
+ const $accordionControls = createElement('div', {
442
+ class: 'govuk-accordion__controls'
443
+ });
427
444
  $accordionControls.appendChild(this.$showAllButton);
428
445
  this.$root.insertBefore($accordionControls, this.$root.firstChild);
429
- this.$showAllText = document.createElement('span');
430
- this.$showAllText.classList.add(this.showAllTextClass);
446
+ this.$showAllText = createElement('span', {
447
+ class: 'govuk-accordion__show-all-text'
448
+ });
431
449
  this.$showAllButton.appendChild(this.$showAllText);
432
450
  this.$showAllButton.addEventListener('click', () => this.onShowOrHideAllToggle());
433
451
  if ('onbeforematch' in document) {
@@ -465,39 +483,45 @@ class Accordion extends ConfigurableComponent {
465
483
  identifier: `Section button placeholder (\`<span class="${this.sectionButtonClass}">\`)`
466
484
  });
467
485
  }
468
- const $button = document.createElement('button');
469
- $button.setAttribute('type', 'button');
470
- $button.setAttribute('aria-controls', `${this.$root.id}-content-${index + 1}`);
486
+ const $button = createElement('button', {
487
+ type: 'button',
488
+ 'aria-controls': `${this.$root.id}-content-${index + 1}`
489
+ });
471
490
  for (const attr of Array.from($span.attributes)) {
472
491
  if (attr.name !== 'id') {
473
492
  $button.setAttribute(attr.name, attr.value);
474
493
  }
475
494
  }
476
- const $headingText = document.createElement('span');
477
- $headingText.classList.add(this.sectionHeadingTextClass);
478
- $headingText.id = $span.id;
479
- const $headingTextFocus = document.createElement('span');
480
- $headingTextFocus.classList.add(this.sectionHeadingTextFocusClass);
495
+ const $headingText = createElement('span', {
496
+ class: this.sectionHeadingTextClass,
497
+ id: $span.id
498
+ });
499
+ const $headingTextFocus = createElement('span', {
500
+ class: 'govuk-accordion__section-heading-text-focus'
501
+ });
481
502
  $headingText.appendChild($headingTextFocus);
482
503
  Array.from($span.childNodes).forEach($child => $headingTextFocus.appendChild($child));
483
- const $showHideToggle = document.createElement('span');
484
- $showHideToggle.classList.add(this.sectionShowHideToggleClass);
485
- $showHideToggle.setAttribute('data-nosnippet', '');
486
- const $showHideToggleFocus = document.createElement('span');
487
- $showHideToggleFocus.classList.add(this.sectionShowHideToggleFocusClass);
504
+ const $showHideToggle = createElement('span', {
505
+ class: 'govuk-accordion__section-toggle',
506
+ 'data-nosnippet': ''
507
+ });
508
+ const $showHideToggleFocus = createElement('span', {
509
+ class: 'govuk-accordion__section-toggle-focus'
510
+ });
488
511
  $showHideToggle.appendChild($showHideToggleFocus);
489
- const $showHideText = document.createElement('span');
490
- const $showHideIcon = document.createElement('span');
491
- $showHideIcon.classList.add(this.upChevronIconClass);
492
- $showHideToggleFocus.appendChild($showHideIcon);
493
- $showHideText.classList.add(this.sectionShowHideTextClass);
494
- $showHideToggleFocus.appendChild($showHideText);
512
+ $showHideToggleFocus.appendChild(createElement('span', {
513
+ class: this.iconClass
514
+ }));
515
+ $showHideToggleFocus.appendChild(createElement('span', {
516
+ class: this.sectionToggleTextClass
517
+ }));
495
518
  $button.appendChild($headingText);
496
519
  $button.appendChild(this.getButtonPunctuationEl());
497
520
  if ($summary) {
498
- const $summarySpan = document.createElement('span');
499
- const $summarySpanFocus = document.createElement('span');
500
- $summarySpanFocus.classList.add(this.sectionSummaryFocusClass);
521
+ const $summarySpan = createElement('span');
522
+ const $summarySpanFocus = createElement('span', {
523
+ class: 'govuk-accordion__section-summary-focus'
524
+ });
501
525
  $summarySpan.appendChild($summarySpanFocus);
502
526
  for (const attr of Array.from($summary.attributes)) {
503
527
  $summarySpan.setAttribute(attr.name, attr.value);
@@ -535,8 +559,8 @@ class Accordion extends ConfigurableComponent {
535
559
  this.updateShowAllButton(nowExpanded);
536
560
  }
537
561
  setExpanded(expanded, $section) {
538
- const $showHideIcon = $section.querySelector(`.${this.upChevronIconClass}`);
539
- const $showHideText = $section.querySelector(`.${this.sectionShowHideTextClass}`);
562
+ const $showHideIcon = $section.querySelector(`.${this.iconClass}`);
563
+ const $showHideText = $section.querySelector(`.${this.sectionToggleTextClass}`);
540
564
  const $button = $section.querySelector(`.${this.sectionButtonClass}`);
541
565
  const $content = $section.querySelector(`.${this.sectionContentClass}`);
542
566
  if (!$content) {
@@ -565,17 +589,17 @@ class Accordion extends ConfigurableComponent {
565
589
  $button.setAttribute('aria-label', ariaLabelParts.join(' , '));
566
590
  if (expanded) {
567
591
  $content.removeAttribute('hidden');
568
- $section.classList.add(this.sectionExpandedClass);
569
- $showHideIcon.classList.remove(this.downChevronIconClass);
592
+ $section.classList.add(this.sectionExpandedModifier);
593
+ $showHideIcon.classList.remove(this.iconOpenModifier);
570
594
  } else {
571
595
  $content.setAttribute('hidden', 'until-found');
572
- $section.classList.remove(this.sectionExpandedClass);
573
- $showHideIcon.classList.add(this.downChevronIconClass);
596
+ $section.classList.remove(this.sectionExpandedModifier);
597
+ $showHideIcon.classList.add(this.iconOpenModifier);
574
598
  }
575
599
  this.updateShowAllButton(this.areAllSectionsOpen());
576
600
  }
577
601
  isExpanded($section) {
578
- return $section.classList.contains(this.sectionExpandedClass);
602
+ return $section.classList.contains(this.sectionExpandedModifier);
579
603
  }
580
604
  areAllSectionsOpen() {
581
605
  return Array.from(this.$sections).every($section => this.isExpanded($section));
@@ -586,7 +610,7 @@ class Accordion extends ConfigurableComponent {
586
610
  }
587
611
  this.$showAllButton.setAttribute('aria-expanded', expanded.toString());
588
612
  this.$showAllText.textContent = expanded ? this.i18n.t('hideAllSections') : this.i18n.t('showAllSections');
589
- this.$showAllIcon.classList.toggle(this.downChevronIconClass, !expanded);
613
+ this.$showAllIcon.classList.toggle(this.iconOpenModifier, !expanded);
590
614
  }
591
615
 
592
616
  /**
@@ -629,10 +653,11 @@ class Accordion extends ConfigurableComponent {
629
653
  }
630
654
  }
631
655
  getButtonPunctuationEl() {
632
- const $punctuationEl = document.createElement('span');
633
- $punctuationEl.classList.add('govuk-visually-hidden', this.sectionHeadingDividerClass);
634
- $punctuationEl.textContent = ', ';
635
- return $punctuationEl;
656
+ const $element = createElement('span', {
657
+ class: 'govuk-visually-hidden govuk-accordion__section-heading-divider'
658
+ });
659
+ $element.textContent = ', ';
660
+ return $element;
636
661
  }
637
662
  }
638
663