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.
- checksums.yaml +4 -4
- data/README.md +73 -19
- data/Rakefile +10 -33
- data/lib/defra_ruby_template/version.rb +1 -1
- data/node_modules/govuk-frontend/dist/govuk/all.bundle.js +202 -137
- data/node_modules/govuk-frontend/dist/govuk/all.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/all.bundle.mjs +202 -137
- data/node_modules/govuk-frontend/dist/govuk/all.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/common/closest-attribute-value.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/common/configuration.mjs +5 -1
- data/node_modules/govuk-frontend/dist/govuk/common/configuration.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/common/create-element.mjs +13 -0
- data/node_modules/govuk-frontend/dist/govuk/common/create-element.mjs.map +1 -0
- data/node_modules/govuk-frontend/dist/govuk/common/govuk-frontend-version.mjs +1 -1
- data/node_modules/govuk-frontend/dist/govuk/common/govuk-frontend-version.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/common/index.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/component.mjs +2 -1
- data/node_modules/govuk-frontend/dist/govuk/component.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/_index.import.scss +2 -0
- data/node_modules/govuk-frontend/dist/govuk/components/_index.scss +2 -0
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.js +87 -62
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.mjs +87 -62
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.mjs +60 -56
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.js +17 -6
- data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.mjs +17 -6
- data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/button/button.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.js +90 -32
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.mjs +90 -32
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.mjs +64 -27
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/fixtures.json +173 -6
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/macro-options.json +13 -6
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/template-with-count-type-characters-and-error-message.html +12 -0
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/template-with-count-type-characters-and-threshold.html +9 -0
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/template-with-count-type-characters-and-value.html +9 -0
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/template-with-count-type-characters.html +9 -0
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/template-with-count-type-length.html +9 -0
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/template-with-count-type-words-and-error-message.html +12 -0
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/template-with-count-type-words-and-threshold.html +9 -0
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/template-with-count-type-words-and-value.html +9 -0
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/template-with-count-type-words.html +9 -0
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/template-with-maxwords.html +9 -0
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/template.njk +10 -3
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.js +12 -5
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.mjs +12 -5
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/cookie-banner/_mixin.scss +6 -0
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.js +17 -6
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.mjs +17 -6
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js +43 -18
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs +43 -18
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.mjs +16 -12
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/feedback/README.md +15 -0
- data/node_modules/govuk-frontend/dist/govuk/components/feedback/_feedback.import.scss +6 -0
- data/node_modules/govuk-frontend/dist/govuk/components/feedback/_index.import.scss +8 -0
- data/node_modules/govuk-frontend/dist/govuk/components/feedback/_index.scss +5 -0
- data/node_modules/govuk-frontend/dist/govuk/components/feedback/_mixin.scss +48 -0
- data/node_modules/govuk-frontend/dist/govuk/components/feedback/fixtures.json +95 -0
- data/node_modules/govuk-frontend/dist/govuk/components/feedback/macro-options.json +50 -0
- data/node_modules/govuk-frontend/dist/govuk/components/feedback/macro.njk +3 -0
- data/node_modules/govuk-frontend/dist/govuk/components/feedback/template-default.html +12 -0
- data/node_modules/govuk-frontend/dist/govuk/components/feedback/template-silly-example.html +19 -0
- data/node_modules/govuk-frontend/dist/govuk/components/feedback/template.njk +24 -0
- data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.bundle.js +54 -30
- data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.bundle.mjs +54 -30
- data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.mjs +27 -24
- data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/footer/_mixin.scss +6 -0
- data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/README.md +15 -0
- data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/_index.import.scss +8 -0
- data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/_index.scss +6 -0
- data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/_language-navigation.import.scss +6 -0
- data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/_mixin.scss +68 -0
- data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/fixtures.json +482 -0
- data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/macro-options.json +88 -0
- data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/macro.njk +3 -0
- data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/template-default.html +12 -0
- data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/template-inverse.html +12 -0
- data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/template-with-language-description.html +12 -0
- data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/template-with-large-amount-of-multiple-languages.html +99 -0
- data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/template-with-mixed-text-directions.html +12 -0
- data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/template-with-multiple-languages.html +24 -0
- data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/template-with-translated-navigation-label.html +12 -0
- data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/template.njk +33 -0
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.js +17 -6
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.mjs +17 -6
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/panel/fixtures.json +13 -11
- data/node_modules/govuk-frontend/dist/govuk/components/panel/template-interruption-with-headings-content-and-lists.html +6 -1
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.js +32 -9
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.mjs +32 -9
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.mjs +5 -3
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.js +12 -5
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.mjs +12 -5
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_mixin.scss +48 -3
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/fixtures.json +121 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/macro-options.json +20 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.js +12 -5
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.mjs +12 -5
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-inverse-with-language-navigation.html +72 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-inline-end-slot.html +33 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-language-navigation.html +62 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-right-aligned-language-navigation.html +62 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template.njk +8 -3
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.js +14 -6
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.mjs +14 -6
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.mjs +2 -1
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.js +12 -5
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.mjs +12 -5
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/custom-properties/_frontend-version.mixin.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/custom-properties/_functional-colours.mixin.scss +1 -0
- data/node_modules/govuk-frontend/dist/govuk/errors/index.mjs +8 -5
- data/node_modules/govuk-frontend/dist/govuk/errors/index.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.css +2 -2
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.css.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.js +1 -1
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/helpers/_colour.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/i18n.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/init.mjs +8 -8
- data/node_modules/govuk-frontend/dist/govuk/init.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/settings/_colours-organisations.scss +16 -2
- data/node_modules/govuk-frontend/govuk-prototype-kit.config.json +9 -1
- data/node_modules/govuk-frontend/package.json +9 -7
- data/vendor/assets/javascripts/defra_ruby_template.js +202 -137
- data/vendor/assets/stylesheets/components/_index.import.scss +2 -0
- data/vendor/assets/stylesheets/components/_index.scss +2 -0
- data/vendor/assets/stylesheets/components/cookie-banner/_mixin.scss +6 -0
- data/vendor/assets/stylesheets/components/feedback/_feedback.import.scss +6 -0
- data/vendor/assets/stylesheets/components/feedback/_index.import.scss +8 -0
- data/vendor/assets/stylesheets/components/feedback/_index.scss +5 -0
- data/vendor/assets/stylesheets/components/feedback/_mixin.scss +48 -0
- data/vendor/assets/stylesheets/components/footer/_mixin.scss +6 -0
- data/vendor/assets/stylesheets/components/language-navigation/_index.import.scss +8 -0
- data/vendor/assets/stylesheets/components/language-navigation/_index.scss +6 -0
- data/vendor/assets/stylesheets/components/language-navigation/_language-navigation.import.scss +6 -0
- data/vendor/assets/stylesheets/components/language-navigation/_mixin.scss +68 -0
- data/vendor/assets/stylesheets/components/service-navigation/_mixin.scss +48 -3
- data/vendor/assets/stylesheets/custom-properties/_frontend-version.mixin.scss +1 -1
- data/vendor/assets/stylesheets/custom-properties/_functional-colours.mixin.scss +1 -0
- data/vendor/assets/stylesheets/defra_ruby_template.scss +8 -30
- data/vendor/assets/stylesheets/govuk-frontend.min.css +2 -2
- data/vendor/assets/stylesheets/helpers/_colour.scss +1 -1
- data/vendor/assets/stylesheets/settings/_colours-organisations.scss +16 -2
- metadata +53 -3
- 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 {
|
|
47
|
+
* @param {Element | Document | null | string} [scopeOrMessage] - HTML element `<body>` checked for browser support or support error message
|
|
45
48
|
*/
|
|
46
|
-
constructor(
|
|
47
|
-
|
|
48
|
-
|
|
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 : {}
|
|
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.
|
|
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.
|
|
392
|
-
this.
|
|
393
|
-
this.
|
|
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 =
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
this.$showAllIcon
|
|
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 =
|
|
426
|
-
|
|
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 =
|
|
430
|
-
|
|
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 =
|
|
469
|
-
|
|
470
|
-
|
|
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 =
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
$headingTextFocus
|
|
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 =
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
$showHideToggleFocus
|
|
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
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
$showHideToggleFocus.appendChild(
|
|
493
|
-
|
|
494
|
-
|
|
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 =
|
|
499
|
-
const $summarySpanFocus =
|
|
500
|
-
|
|
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.
|
|
539
|
-
const $showHideText = $section.querySelector(`.${this.
|
|
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.
|
|
569
|
-
$showHideIcon.classList.remove(this.
|
|
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.
|
|
573
|
-
$showHideIcon.classList.add(this.
|
|
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.
|
|
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.
|
|
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 $
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
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
|
|