govuk_publishing_components 51.1.1 → 51.2.1
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/app/assets/javascripts/govuk_publishing_components/components/feedback.js +29 -34
- data/app/assets/javascripts/govuk_publishing_components/vendor/lux/lux-reporter.js +7 -2
- data/app/assets/stylesheets/component_guide/application.scss +1 -1
- data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_markdown-typography.scss +2 -2
- data/app/models/govuk_publishing_components/audit_comparer.rb +3 -3
- data/app/views/govuk_publishing_components/components/_title.html.erb +2 -3
- data/app/views/govuk_publishing_components/components/docs/add_another.yml +1 -1
- data/app/views/govuk_publishing_components/components/docs/feedback.yml +1 -1
- data/lib/govuk_publishing_components/presenters/checkboxes_helper.rb +1 -1
- data/lib/govuk_publishing_components/presenters/shared_helper.rb +0 -11
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/govuk-frontend/dist/govuk/all.bundle.js +217 -184
- data/node_modules/govuk-frontend/dist/govuk/all.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/all.bundle.mjs +216 -184
- data/node_modules/govuk-frontend/dist/govuk/all.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/all.mjs +1 -0
- data/node_modules/govuk-frontend/dist/govuk/all.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/all.scss +6 -0
- data/node_modules/govuk-frontend/dist/govuk/all.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/common/configuration.mjs +164 -0
- data/node_modules/govuk-frontend/dist/govuk/common/configuration.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/index.mjs +1 -87
- data/node_modules/govuk-frontend/dist/govuk/common/index.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.js +149 -112
- 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 +148 -111
- 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 +5 -8
- 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 +149 -112
- 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 +148 -111
- 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 +5 -8
- 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 +174 -140
- 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 +173 -139
- 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 +17 -16
- 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/macro-options.json +4 -4
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.js +1 -24
- 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 +0 -23
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/date-input/macro-options.json +2 -2
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.js +149 -112
- 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 +148 -111
- 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 +6 -8
- 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 +149 -112
- 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 +148 -111
- 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 +5 -8
- 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/header/header.bundle.js +1 -24
- data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.mjs +0 -23
- data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/input/macro-options.json +4 -4
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.js +149 -112
- 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 +148 -111
- 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 +6 -8
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/macro-options.json +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.js +149 -112
- 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 +148 -111
- 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 -8
- 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 +1 -24
- 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 +0 -23
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.js +1 -24
- 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 +0 -23
- 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/skip-link/skip-link.bundle.js +1 -24
- 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 +0 -23
- 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/tabs/tabs.bundle.js +1 -24
- 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 +0 -23
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/textarea/macro-options.json +1 -1
- data/node_modules/govuk-frontend/dist/govuk/core/_govuk-frontend-properties.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.css +1 -1
- 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/init.mjs +17 -13
- data/node_modules/govuk-frontend/dist/govuk/init.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/settings/_typography-responsive.scss +5 -10
- data/node_modules/govuk-frontend/dist/govuk/settings/_typography-responsive.scss.map +1 -1
- data/node_modules/govuk-frontend/govuk-prototype-kit.config.json +1 -1
- data/node_modules/govuk-frontend/package.json +9 -9
- metadata +4 -6
- data/node_modules/govuk-frontend/dist/govuk/common/normalise-dataset.mjs +0 -18
- data/node_modules/govuk-frontend/dist/govuk/common/normalise-dataset.mjs.map +0 -1
- data/node_modules/govuk-frontend/dist/govuk/common/normalise-string.mjs +0 -31
- data/node_modules/govuk-frontend/dist/govuk/common/normalise-string.mjs.map +0 -1
@@ -1,79 +1,9 @@
|
|
1
1
|
(function (global, factory) {
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.GOVUKFrontend = {}));
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.GOVUKFrontend = global.GOVUKFrontend || {}));
|
5
5
|
})(this, (function (exports) { 'use strict';
|
6
6
|
|
7
|
-
function normaliseString(value, property) {
|
8
|
-
const trimmedValue = value ? value.trim() : '';
|
9
|
-
let output;
|
10
|
-
let outputType = property == null ? void 0 : property.type;
|
11
|
-
if (!outputType) {
|
12
|
-
if (['true', 'false'].includes(trimmedValue)) {
|
13
|
-
outputType = 'boolean';
|
14
|
-
}
|
15
|
-
if (trimmedValue.length > 0 && isFinite(Number(trimmedValue))) {
|
16
|
-
outputType = 'number';
|
17
|
-
}
|
18
|
-
}
|
19
|
-
switch (outputType) {
|
20
|
-
case 'boolean':
|
21
|
-
output = trimmedValue === 'true';
|
22
|
-
break;
|
23
|
-
case 'number':
|
24
|
-
output = Number(trimmedValue);
|
25
|
-
break;
|
26
|
-
default:
|
27
|
-
output = value;
|
28
|
-
}
|
29
|
-
return output;
|
30
|
-
}
|
31
|
-
|
32
|
-
/**
|
33
|
-
* @typedef {import('./index.mjs').SchemaProperty} SchemaProperty
|
34
|
-
*/
|
35
|
-
|
36
|
-
function mergeConfigs(...configObjects) {
|
37
|
-
const formattedConfigObject = {};
|
38
|
-
for (const configObject of configObjects) {
|
39
|
-
for (const key of Object.keys(configObject)) {
|
40
|
-
const option = formattedConfigObject[key];
|
41
|
-
const override = configObject[key];
|
42
|
-
if (isObject(option) && isObject(override)) {
|
43
|
-
formattedConfigObject[key] = mergeConfigs(option, override);
|
44
|
-
} else {
|
45
|
-
formattedConfigObject[key] = override;
|
46
|
-
}
|
47
|
-
}
|
48
|
-
}
|
49
|
-
return formattedConfigObject;
|
50
|
-
}
|
51
|
-
function extractConfigByNamespace(Component, dataset, namespace) {
|
52
|
-
const property = Component.schema.properties[namespace];
|
53
|
-
if ((property == null ? void 0 : property.type) !== 'object') {
|
54
|
-
return;
|
55
|
-
}
|
56
|
-
const newObject = {
|
57
|
-
[namespace]: ({})
|
58
|
-
};
|
59
|
-
for (const [key, value] of Object.entries(dataset)) {
|
60
|
-
let current = newObject;
|
61
|
-
const keyParts = key.split('.');
|
62
|
-
for (const [index, name] of keyParts.entries()) {
|
63
|
-
if (typeof current === 'object') {
|
64
|
-
if (index < keyParts.length - 1) {
|
65
|
-
if (!isObject(current[name])) {
|
66
|
-
current[name] = {};
|
67
|
-
}
|
68
|
-
current = current[name];
|
69
|
-
} else if (key !== namespace) {
|
70
|
-
current[name] = normaliseString(value);
|
71
|
-
}
|
72
|
-
}
|
73
|
-
}
|
74
|
-
}
|
75
|
-
return newObject[namespace];
|
76
|
-
}
|
77
7
|
function isInitialised($root, moduleName) {
|
78
8
|
return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
|
79
9
|
}
|
@@ -102,47 +32,11 @@
|
|
102
32
|
function formatErrorMessage(Component, message) {
|
103
33
|
return `${Component.moduleName}: ${message}`;
|
104
34
|
}
|
105
|
-
|
106
|
-
/**
|
107
|
-
* Schema for component config
|
108
|
-
*
|
109
|
-
* @typedef {object} Schema
|
110
|
-
* @property {{ [field: string]: SchemaProperty | undefined }} properties - Schema properties
|
111
|
-
* @property {SchemaCondition[]} [anyOf] - List of schema conditions
|
112
|
-
*/
|
113
|
-
|
114
|
-
/**
|
115
|
-
* Schema property for component config
|
116
|
-
*
|
117
|
-
* @typedef {object} SchemaProperty
|
118
|
-
* @property {'string' | 'boolean' | 'number' | 'object'} type - Property type
|
119
|
-
*/
|
120
|
-
|
121
|
-
/**
|
122
|
-
* Schema condition for component config
|
123
|
-
*
|
124
|
-
* @typedef {object} SchemaCondition
|
125
|
-
* @property {string[]} required - List of required config fields
|
126
|
-
* @property {string} errorMessage - Error message when required config fields not provided
|
127
|
-
*/
|
128
35
|
/**
|
129
36
|
* @typedef ComponentWithModuleName
|
130
37
|
* @property {string} moduleName - Name of the component
|
131
38
|
*/
|
132
39
|
|
133
|
-
function normaliseDataset(Component, dataset) {
|
134
|
-
const out = {};
|
135
|
-
for (const [field, property] of Object.entries(Component.schema.properties)) {
|
136
|
-
if (field in dataset) {
|
137
|
-
out[field] = normaliseString(dataset[field], property);
|
138
|
-
}
|
139
|
-
if ((property == null ? void 0 : property.type) === 'object') {
|
140
|
-
out[field] = extractConfigByNamespace(Component, dataset, field);
|
141
|
-
}
|
142
|
-
}
|
143
|
-
return out;
|
144
|
-
}
|
145
|
-
|
146
40
|
class GOVUKFrontendError extends Error {
|
147
41
|
constructor(...args) {
|
148
42
|
super(...args);
|
@@ -161,6 +55,12 @@
|
|
161
55
|
this.name = 'SupportError';
|
162
56
|
}
|
163
57
|
}
|
58
|
+
class ConfigError extends GOVUKFrontendError {
|
59
|
+
constructor(...args) {
|
60
|
+
super(...args);
|
61
|
+
this.name = 'ConfigError';
|
62
|
+
}
|
63
|
+
}
|
164
64
|
class ElementError extends GOVUKFrontendError {
|
165
65
|
constructor(messageOrOptions) {
|
166
66
|
let message = typeof messageOrOptions === 'string' ? messageOrOptions : '';
|
@@ -245,6 +145,144 @@
|
|
245
145
|
*/
|
246
146
|
GOVUKFrontendComponent.elementType = HTMLElement;
|
247
147
|
|
148
|
+
const configOverride = Symbol.for('configOverride');
|
149
|
+
class ConfigurableComponent extends GOVUKFrontendComponent {
|
150
|
+
[configOverride](param) {
|
151
|
+
return {};
|
152
|
+
}
|
153
|
+
|
154
|
+
/**
|
155
|
+
* Returns the root element of the component
|
156
|
+
*
|
157
|
+
* @protected
|
158
|
+
* @returns {ConfigurationType} - the root element of component
|
159
|
+
*/
|
160
|
+
get config() {
|
161
|
+
return this._config;
|
162
|
+
}
|
163
|
+
constructor($root, config) {
|
164
|
+
super($root);
|
165
|
+
this._config = void 0;
|
166
|
+
const childConstructor = this.constructor;
|
167
|
+
if (typeof childConstructor.defaults === 'undefined') {
|
168
|
+
throw new ConfigError(formatErrorMessage(childConstructor, 'Config passed as parameter into constructor but no defaults defined'));
|
169
|
+
}
|
170
|
+
const datasetConfig = normaliseDataset(childConstructor, this._$root.dataset);
|
171
|
+
this._config = mergeConfigs(childConstructor.defaults, config != null ? config : {}, this[configOverride](datasetConfig), datasetConfig);
|
172
|
+
}
|
173
|
+
}
|
174
|
+
function normaliseString(value, property) {
|
175
|
+
const trimmedValue = value ? value.trim() : '';
|
176
|
+
let output;
|
177
|
+
let outputType = property == null ? void 0 : property.type;
|
178
|
+
if (!outputType) {
|
179
|
+
if (['true', 'false'].includes(trimmedValue)) {
|
180
|
+
outputType = 'boolean';
|
181
|
+
}
|
182
|
+
if (trimmedValue.length > 0 && isFinite(Number(trimmedValue))) {
|
183
|
+
outputType = 'number';
|
184
|
+
}
|
185
|
+
}
|
186
|
+
switch (outputType) {
|
187
|
+
case 'boolean':
|
188
|
+
output = trimmedValue === 'true';
|
189
|
+
break;
|
190
|
+
case 'number':
|
191
|
+
output = Number(trimmedValue);
|
192
|
+
break;
|
193
|
+
default:
|
194
|
+
output = value;
|
195
|
+
}
|
196
|
+
return output;
|
197
|
+
}
|
198
|
+
function normaliseDataset(Component, dataset) {
|
199
|
+
if (typeof Component.schema === 'undefined') {
|
200
|
+
throw new ConfigError(formatErrorMessage(Component, 'Config passed as parameter into constructor but no schema defined'));
|
201
|
+
}
|
202
|
+
const out = {};
|
203
|
+
for (const [field, property] of Object.entries(Component.schema.properties)) {
|
204
|
+
if (field in dataset) {
|
205
|
+
out[field] = normaliseString(dataset[field], property);
|
206
|
+
}
|
207
|
+
if ((property == null ? void 0 : property.type) === 'object') {
|
208
|
+
out[field] = extractConfigByNamespace(Component.schema, dataset, field);
|
209
|
+
}
|
210
|
+
}
|
211
|
+
return out;
|
212
|
+
}
|
213
|
+
function mergeConfigs(...configObjects) {
|
214
|
+
const formattedConfigObject = {};
|
215
|
+
for (const configObject of configObjects) {
|
216
|
+
for (const key of Object.keys(configObject)) {
|
217
|
+
const option = formattedConfigObject[key];
|
218
|
+
const override = configObject[key];
|
219
|
+
if (isObject(option) && isObject(override)) {
|
220
|
+
formattedConfigObject[key] = mergeConfigs(option, override);
|
221
|
+
} else {
|
222
|
+
formattedConfigObject[key] = override;
|
223
|
+
}
|
224
|
+
}
|
225
|
+
}
|
226
|
+
return formattedConfigObject;
|
227
|
+
}
|
228
|
+
function extractConfigByNamespace(schema, dataset, namespace) {
|
229
|
+
const property = schema.properties[namespace];
|
230
|
+
if ((property == null ? void 0 : property.type) !== 'object') {
|
231
|
+
return;
|
232
|
+
}
|
233
|
+
const newObject = {
|
234
|
+
[namespace]: ({})
|
235
|
+
};
|
236
|
+
for (const [key, value] of Object.entries(dataset)) {
|
237
|
+
let current = newObject;
|
238
|
+
const keyParts = key.split('.');
|
239
|
+
for (const [index, name] of keyParts.entries()) {
|
240
|
+
if (typeof current === 'object') {
|
241
|
+
if (index < keyParts.length - 1) {
|
242
|
+
if (!isObject(current[name])) {
|
243
|
+
current[name] = {};
|
244
|
+
}
|
245
|
+
current = current[name];
|
246
|
+
} else if (key !== namespace) {
|
247
|
+
current[name] = normaliseString(value);
|
248
|
+
}
|
249
|
+
}
|
250
|
+
}
|
251
|
+
}
|
252
|
+
return newObject[namespace];
|
253
|
+
}
|
254
|
+
/**
|
255
|
+
* Schema for component config
|
256
|
+
*
|
257
|
+
* @typedef {object} Schema
|
258
|
+
* @property {{ [field: string]: SchemaProperty | undefined }} properties - Schema properties
|
259
|
+
* @property {SchemaCondition[]} [anyOf] - List of schema conditions
|
260
|
+
*/
|
261
|
+
/**
|
262
|
+
* Schema property for component config
|
263
|
+
*
|
264
|
+
* @typedef {object} SchemaProperty
|
265
|
+
* @property {'string' | 'boolean' | 'number' | 'object'} type - Property type
|
266
|
+
*/
|
267
|
+
/**
|
268
|
+
* Schema condition for component config
|
269
|
+
*
|
270
|
+
* @typedef {object} SchemaCondition
|
271
|
+
* @property {string[]} required - List of required config fields
|
272
|
+
* @property {string} errorMessage - Error message when required config fields not provided
|
273
|
+
*/
|
274
|
+
/**
|
275
|
+
* @template {ObjectNested} [ConfigurationType={}]
|
276
|
+
* @typedef ChildClass
|
277
|
+
* @property {string} moduleName - The module name that'll be looked for in the DOM when initialising the component
|
278
|
+
* @property {Schema} [schema] - The schema of the component configuration
|
279
|
+
* @property {ConfigurationType} [defaults] - The default values of the configuration of the component
|
280
|
+
*/
|
281
|
+
/**
|
282
|
+
* @template {ObjectNested} [ConfigurationType={}]
|
283
|
+
* @typedef {typeof GOVUKFrontendComponent & ChildClass<ConfigurationType>} ChildClassConstructor<ConfigurationType>
|
284
|
+
*/
|
285
|
+
|
248
286
|
class I18n {
|
249
287
|
constructor(translations = {}, config = {}) {
|
250
288
|
var _config$locale;
|
@@ -451,15 +489,15 @@
|
|
451
489
|
* attribute, which also provides accessibility.
|
452
490
|
*
|
453
491
|
* @preserve
|
492
|
+
* @augments ConfigurableComponent<AccordionConfig>
|
454
493
|
*/
|
455
|
-
class Accordion extends
|
494
|
+
class Accordion extends ConfigurableComponent {
|
456
495
|
/**
|
457
496
|
* @param {Element | null} $root - HTML element to use for accordion
|
458
497
|
* @param {AccordionConfig} [config] - Accordion config
|
459
498
|
*/
|
460
499
|
constructor($root, config = {}) {
|
461
|
-
super($root);
|
462
|
-
this.config = void 0;
|
500
|
+
super($root, config);
|
463
501
|
this.i18n = void 0;
|
464
502
|
this.controlsClass = 'govuk-accordion__controls';
|
465
503
|
this.showAllClass = 'govuk-accordion__show-all';
|
@@ -484,7 +522,6 @@
|
|
484
522
|
this.$showAllButton = null;
|
485
523
|
this.$showAllIcon = null;
|
486
524
|
this.$showAllText = null;
|
487
|
-
this.config = mergeConfigs(Accordion.defaults, config, normaliseDataset(Accordion, this.$root.dataset));
|
488
525
|
this.i18n = new I18n(this.config.i18n);
|
489
526
|
const $sections = this.$root.querySelectorAll(`.${this.sectionClass}`);
|
490
527
|
if (!$sections.length) {
|
@@ -754,7 +791,7 @@
|
|
754
791
|
*/
|
755
792
|
|
756
793
|
/**
|
757
|
-
* @typedef {import('../../common/
|
794
|
+
* @typedef {import('../../common/configuration.mjs').Schema} Schema
|
758
795
|
*/
|
759
796
|
Accordion.moduleName = 'govuk-accordion';
|
760
797
|
Accordion.defaults = Object.freeze({
|