govuk_publishing_components 51.1.0 → 51.2.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 (112) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/component_guide/application.scss +1 -1
  3. data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +1 -0
  4. data/app/assets/stylesheets/govuk_publishing_components/components/_metadata.scss +3 -19
  5. data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_markdown-typography.scss +1 -0
  6. data/app/models/govuk_publishing_components/audit_comparer.rb +3 -3
  7. data/app/views/govuk_publishing_components/components/_title.html.erb +2 -3
  8. data/app/views/govuk_publishing_components/components/docs/add_another.yml +1 -1
  9. data/app/views/govuk_publishing_components/components/docs/big_number.yml +1 -0
  10. data/lib/govuk_publishing_components/presenters/checkboxes_helper.rb +1 -1
  11. data/lib/govuk_publishing_components/presenters/shared_helper.rb +0 -11
  12. data/lib/govuk_publishing_components/version.rb +1 -1
  13. data/node_modules/govuk-frontend/dist/govuk/all.bundle.js +217 -184
  14. data/node_modules/govuk-frontend/dist/govuk/all.bundle.js.map +1 -1
  15. data/node_modules/govuk-frontend/dist/govuk/all.bundle.mjs +216 -184
  16. data/node_modules/govuk-frontend/dist/govuk/all.bundle.mjs.map +1 -1
  17. data/node_modules/govuk-frontend/dist/govuk/all.mjs +1 -0
  18. data/node_modules/govuk-frontend/dist/govuk/all.mjs.map +1 -1
  19. data/node_modules/govuk-frontend/dist/govuk/all.scss +6 -0
  20. data/node_modules/govuk-frontend/dist/govuk/all.scss.map +1 -1
  21. data/node_modules/govuk-frontend/dist/govuk/common/configuration.mjs +164 -0
  22. data/node_modules/govuk-frontend/dist/govuk/common/configuration.mjs.map +1 -0
  23. data/node_modules/govuk-frontend/dist/govuk/common/govuk-frontend-version.mjs +1 -1
  24. data/node_modules/govuk-frontend/dist/govuk/common/index.mjs +1 -87
  25. data/node_modules/govuk-frontend/dist/govuk/common/index.mjs.map +1 -1
  26. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.js +149 -112
  27. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.js.map +1 -1
  28. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.mjs +148 -111
  29. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.mjs.map +1 -1
  30. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.mjs +5 -8
  31. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.mjs.map +1 -1
  32. data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.js +149 -112
  33. data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.js.map +1 -1
  34. data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.mjs +148 -111
  35. data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.mjs.map +1 -1
  36. data/node_modules/govuk-frontend/dist/govuk/components/button/button.mjs +5 -8
  37. data/node_modules/govuk-frontend/dist/govuk/components/button/button.mjs.map +1 -1
  38. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.js +174 -140
  39. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.js.map +1 -1
  40. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.mjs +173 -139
  41. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.mjs.map +1 -1
  42. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.mjs +17 -16
  43. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.mjs.map +1 -1
  44. data/node_modules/govuk-frontend/dist/govuk/components/character-count/macro-options.json +4 -4
  45. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.js +1 -24
  46. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.js.map +1 -1
  47. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.mjs +0 -23
  48. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.mjs.map +1 -1
  49. data/node_modules/govuk-frontend/dist/govuk/components/date-input/macro-options.json +2 -2
  50. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.js +149 -112
  51. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.js.map +1 -1
  52. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.mjs +148 -111
  53. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.mjs.map +1 -1
  54. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.mjs +6 -8
  55. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.mjs.map +1 -1
  56. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js +149 -112
  57. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js.map +1 -1
  58. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs +148 -111
  59. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs.map +1 -1
  60. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.mjs +5 -8
  61. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.mjs.map +1 -1
  62. data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.js +1 -24
  63. data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.js.map +1 -1
  64. data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.mjs +0 -23
  65. data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.mjs.map +1 -1
  66. data/node_modules/govuk-frontend/dist/govuk/components/input/macro-options.json +4 -4
  67. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.js +149 -112
  68. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.js.map +1 -1
  69. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.mjs +148 -111
  70. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.mjs.map +1 -1
  71. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.mjs +6 -8
  72. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.mjs.map +1 -1
  73. data/node_modules/govuk-frontend/dist/govuk/components/password-input/macro-options.json +1 -1
  74. data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.js +149 -112
  75. data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.js.map +1 -1
  76. data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.mjs +148 -111
  77. data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.mjs.map +1 -1
  78. data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.mjs +5 -8
  79. data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.mjs.map +1 -1
  80. data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.js +1 -24
  81. data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.js.map +1 -1
  82. data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.mjs +0 -23
  83. data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.mjs.map +1 -1
  84. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.js +1 -24
  85. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.js.map +1 -1
  86. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.mjs +0 -23
  87. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.mjs.map +1 -1
  88. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.js +1 -24
  89. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.js.map +1 -1
  90. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.mjs +0 -23
  91. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.mjs.map +1 -1
  92. data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.js +1 -24
  93. data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.js.map +1 -1
  94. data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.mjs +0 -23
  95. data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.mjs.map +1 -1
  96. data/node_modules/govuk-frontend/dist/govuk/components/textarea/macro-options.json +1 -1
  97. data/node_modules/govuk-frontend/dist/govuk/core/_govuk-frontend-properties.scss +1 -1
  98. data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.css +1 -1
  99. data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.css.map +1 -1
  100. data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.js +1 -1
  101. data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.js.map +1 -1
  102. data/node_modules/govuk-frontend/dist/govuk/init.mjs +17 -13
  103. data/node_modules/govuk-frontend/dist/govuk/init.mjs.map +1 -1
  104. data/node_modules/govuk-frontend/dist/govuk/settings/_typography-responsive.scss +5 -10
  105. data/node_modules/govuk-frontend/dist/govuk/settings/_typography-responsive.scss.map +1 -1
  106. data/node_modules/govuk-frontend/govuk-prototype-kit.config.json +1 -1
  107. data/node_modules/govuk-frontend/package.json +9 -9
  108. metadata +4 -6
  109. data/node_modules/govuk-frontend/dist/govuk/common/normalise-dataset.mjs +0 -18
  110. data/node_modules/govuk-frontend/dist/govuk/common/normalise-dataset.mjs.map +0 -1
  111. data/node_modules/govuk-frontend/dist/govuk/common/normalise-string.mjs +0 -31
  112. data/node_modules/govuk-frontend/dist/govuk/common/normalise-string.mjs.map +0 -1
@@ -15,4 +15,5 @@ export { Tabs } from './components/tabs/tabs.mjs';
15
15
  export { createAll, initAll } from './init.mjs';
16
16
  export { isSupported } from './common/index.mjs';
17
17
  export { GOVUKFrontendComponent as Component } from './govuk-frontend-component.mjs';
18
+ export { ConfigurableComponent } from './common/configuration.mjs';
18
19
  //# sourceMappingURL=all.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"all.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"all.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;"}
@@ -1,3 +1,9 @@
1
1
  @import "index";
2
2
 
3
+ @include _warning(
4
+ "import-using-all",
5
+ "Importing using 'govuk/all' is deprecated. Update your import statement to import 'govuk/index'.",
6
+ $silence-further-warnings: false
7
+ );
8
+
3
9
  /*# sourceMappingURL=all.scss.map */
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/govuk/all.scss"],"names":[],"mappings":"AAAA,eAAe","file":"all.scss","sourcesContent":["@import \"index\";\n"]}
1
+ {"version":3,"sources":["../../src/govuk/all.scss"],"names":[],"mappings":"AAAA,eAAe;;AAEf;;;;CAIC","file":"all.scss","sourcesContent":["@import \"index\";\n\n@include _warning(\n \"import-using-all\",\n \"Importing using 'govuk/all' is deprecated. Update your import statement to import 'govuk/index'.\",\n $silence-further-warnings: false\n);\n"]}
@@ -0,0 +1,164 @@
1
+ import { ConfigError } from '../errors/index.mjs';
2
+ import { GOVUKFrontendComponent } from '../govuk-frontend-component.mjs';
3
+ import { formatErrorMessage, isObject } from './index.mjs';
4
+
5
+ const configOverride = Symbol.for('configOverride');
6
+ class ConfigurableComponent extends GOVUKFrontendComponent {
7
+ [configOverride](param) {
8
+ return {};
9
+ }
10
+
11
+ /**
12
+ * Returns the root element of the component
13
+ *
14
+ * @protected
15
+ * @returns {ConfigurationType} - the root element of component
16
+ */
17
+ get config() {
18
+ return this._config;
19
+ }
20
+ constructor($root, config) {
21
+ super($root);
22
+ this._config = void 0;
23
+ const childConstructor = this.constructor;
24
+ if (typeof childConstructor.defaults === 'undefined') {
25
+ throw new ConfigError(formatErrorMessage(childConstructor, 'Config passed as parameter into constructor but no defaults defined'));
26
+ }
27
+ const datasetConfig = normaliseDataset(childConstructor, this._$root.dataset);
28
+ this._config = mergeConfigs(childConstructor.defaults, config != null ? config : {}, this[configOverride](datasetConfig), datasetConfig);
29
+ }
30
+ }
31
+ function normaliseString(value, property) {
32
+ const trimmedValue = value ? value.trim() : '';
33
+ let output;
34
+ let outputType = property == null ? void 0 : property.type;
35
+ if (!outputType) {
36
+ if (['true', 'false'].includes(trimmedValue)) {
37
+ outputType = 'boolean';
38
+ }
39
+ if (trimmedValue.length > 0 && isFinite(Number(trimmedValue))) {
40
+ outputType = 'number';
41
+ }
42
+ }
43
+ switch (outputType) {
44
+ case 'boolean':
45
+ output = trimmedValue === 'true';
46
+ break;
47
+ case 'number':
48
+ output = Number(trimmedValue);
49
+ break;
50
+ default:
51
+ output = value;
52
+ }
53
+ return output;
54
+ }
55
+ function normaliseDataset(Component, dataset) {
56
+ if (typeof Component.schema === 'undefined') {
57
+ throw new ConfigError(formatErrorMessage(Component, 'Config passed as parameter into constructor but no schema defined'));
58
+ }
59
+ const out = {};
60
+ for (const [field, property] of Object.entries(Component.schema.properties)) {
61
+ if (field in dataset) {
62
+ out[field] = normaliseString(dataset[field], property);
63
+ }
64
+ if ((property == null ? void 0 : property.type) === 'object') {
65
+ out[field] = extractConfigByNamespace(Component.schema, dataset, field);
66
+ }
67
+ }
68
+ return out;
69
+ }
70
+ function mergeConfigs(...configObjects) {
71
+ const formattedConfigObject = {};
72
+ for (const configObject of configObjects) {
73
+ for (const key of Object.keys(configObject)) {
74
+ const option = formattedConfigObject[key];
75
+ const override = configObject[key];
76
+ if (isObject(option) && isObject(override)) {
77
+ formattedConfigObject[key] = mergeConfigs(option, override);
78
+ } else {
79
+ formattedConfigObject[key] = override;
80
+ }
81
+ }
82
+ }
83
+ return formattedConfigObject;
84
+ }
85
+ function validateConfig(schema, config) {
86
+ const validationErrors = [];
87
+ for (const [name, conditions] of Object.entries(schema)) {
88
+ const errors = [];
89
+ if (Array.isArray(conditions)) {
90
+ for (const {
91
+ required,
92
+ errorMessage
93
+ } of conditions) {
94
+ if (!required.every(key => !!config[key])) {
95
+ errors.push(errorMessage);
96
+ }
97
+ }
98
+ if (name === 'anyOf' && !(conditions.length - errors.length >= 1)) {
99
+ validationErrors.push(...errors);
100
+ }
101
+ }
102
+ }
103
+ return validationErrors;
104
+ }
105
+ function extractConfigByNamespace(schema, dataset, namespace) {
106
+ const property = schema.properties[namespace];
107
+ if ((property == null ? void 0 : property.type) !== 'object') {
108
+ return;
109
+ }
110
+ const newObject = {
111
+ [namespace]: ({})
112
+ };
113
+ for (const [key, value] of Object.entries(dataset)) {
114
+ let current = newObject;
115
+ const keyParts = key.split('.');
116
+ for (const [index, name] of keyParts.entries()) {
117
+ if (typeof current === 'object') {
118
+ if (index < keyParts.length - 1) {
119
+ if (!isObject(current[name])) {
120
+ current[name] = {};
121
+ }
122
+ current = current[name];
123
+ } else if (key !== namespace) {
124
+ current[name] = normaliseString(value);
125
+ }
126
+ }
127
+ }
128
+ }
129
+ return newObject[namespace];
130
+ }
131
+ /**
132
+ * Schema for component config
133
+ *
134
+ * @typedef {object} Schema
135
+ * @property {{ [field: string]: SchemaProperty | undefined }} properties - Schema properties
136
+ * @property {SchemaCondition[]} [anyOf] - List of schema conditions
137
+ */
138
+ /**
139
+ * Schema property for component config
140
+ *
141
+ * @typedef {object} SchemaProperty
142
+ * @property {'string' | 'boolean' | 'number' | 'object'} type - Property type
143
+ */
144
+ /**
145
+ * Schema condition for component config
146
+ *
147
+ * @typedef {object} SchemaCondition
148
+ * @property {string[]} required - List of required config fields
149
+ * @property {string} errorMessage - Error message when required config fields not provided
150
+ */
151
+ /**
152
+ * @template {ObjectNested} [ConfigurationType={}]
153
+ * @typedef ChildClass
154
+ * @property {string} moduleName - The module name that'll be looked for in the DOM when initialising the component
155
+ * @property {Schema} [schema] - The schema of the component configuration
156
+ * @property {ConfigurationType} [defaults] - The default values of the configuration of the component
157
+ */
158
+ /**
159
+ * @template {ObjectNested} [ConfigurationType={}]
160
+ * @typedef {typeof GOVUKFrontendComponent & ChildClass<ConfigurationType>} ChildClassConstructor<ConfigurationType>
161
+ */
162
+
163
+ export { ConfigurableComponent, configOverride, extractConfigByNamespace, mergeConfigs, normaliseDataset, normaliseString, validateConfig };
164
+ //# sourceMappingURL=configuration.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration.mjs","sources":["../../../src/govuk/common/configuration.mjs"],"sourcesContent":["import { ConfigError } from '../errors/index.mjs'\nimport { GOVUKFrontendComponent } from '../govuk-frontend-component.mjs'\n\nimport { isObject, formatErrorMessage } from './index.mjs'\n\nexport const configOverride = Symbol.for('configOverride')\n\n/**\n * Base Component class\n *\n * Centralises the behaviours shared by our components\n *\n * @virtual\n * @template {ObjectNested} [ConfigurationType={}]\n * @template {Element & { dataset: DOMStringMap }} [RootElementType=HTMLElement]\n * @augments GOVUKFrontendComponent<RootElementType>\n */\nexport class ConfigurableComponent extends GOVUKFrontendComponent {\n /**\n * configOverride\n *\n * Function which defines configuration overrides to prioritize\n * properties from the root element's dataset.\n *\n * It should take a subset of configuration as input and return\n * a new configuration object with properties that should be\n * overridden based on the root element's dataset. A Symbol\n * is used for indexing to prevent conflicts.\n *\n * @internal\n * @virtual\n * @param {ObjectNested} [param] - Configuration object\n * @returns {ObjectNested} return - Configuration object\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n [configOverride](param) {\n return {}\n }\n\n /**\n * Returns the root element of the component\n *\n * @protected\n * @returns {ConfigurationType} - the root element of component\n */\n get config() {\n return this._config\n }\n\n /**\n *\n * @type {ConfigurationType}\n */\n _config\n\n /**\n * Constructs a new component, validating that GOV.UK Frontend is supported\n *\n * @internal\n * @param {Element | null} [$root] - HTML element to use for component\n * @param {ConfigurationType} [config] - HTML element to use for component\n */\n constructor($root, config) {\n super($root)\n\n const childConstructor =\n /** @type {ChildClassConstructor<ConfigurationType>} */ (this.constructor)\n\n if (typeof childConstructor.defaults === 'undefined') {\n throw new ConfigError(\n formatErrorMessage(\n childConstructor,\n 'Config passed as parameter into constructor but no defaults defined'\n )\n )\n }\n\n const datasetConfig = /** @type {ConfigurationType} */ (\n normaliseDataset(childConstructor, this._$root.dataset)\n )\n\n this._config = /** @type {ConfigurationType} */ (\n mergeConfigs(\n childConstructor.defaults,\n config ?? {},\n this[configOverride](datasetConfig),\n datasetConfig\n )\n )\n }\n}\n\n/**\n * Normalise string\n *\n * 'If it looks like a duck, and it quacks like a duck…' 🦆\n *\n * If the passed value looks like a boolean or a number, convert it to a boolean\n * or number.\n *\n * Designed to be used to convert config passed via data attributes (which are\n * always strings) into something sensible.\n *\n * @internal\n * @param {DOMStringMap[string]} value - The value to normalise\n * @param {SchemaProperty} [property] - Component schema property\n * @returns {string | boolean | number | undefined} Normalised data\n */\nexport function normaliseString(value, property) {\n const trimmedValue = value ? value.trim() : ''\n\n let output\n let outputType = property?.type\n\n // No schema type set? Determine automatically\n if (!outputType) {\n if (['true', 'false'].includes(trimmedValue)) {\n outputType = 'boolean'\n }\n\n // Empty / whitespace-only strings are considered finite so we need to check\n // the length of the trimmed string as well\n if (trimmedValue.length > 0 && isFinite(Number(trimmedValue))) {\n outputType = 'number'\n }\n }\n\n switch (outputType) {\n case 'boolean':\n output = trimmedValue === 'true'\n break\n\n case 'number':\n output = Number(trimmedValue)\n break\n\n default:\n output = value\n }\n\n return output\n}\n\n/**\n * Normalise dataset\n *\n * Loop over an object and normalise each value using {@link normaliseString},\n * optionally expanding nested `i18n.field`\n *\n * @internal\n * @param {{ schema?: Schema, moduleName: string }} Component - Component class\n * @param {DOMStringMap} dataset - HTML element dataset\n * @returns {ObjectNested} Normalised dataset\n */\nexport function normaliseDataset(Component, dataset) {\n if (typeof Component.schema === 'undefined') {\n throw new ConfigError(\n formatErrorMessage(\n Component,\n 'Config passed as parameter into constructor but no schema defined'\n )\n )\n }\n\n const out = /** @type {ReturnType<typeof normaliseDataset>} */ ({})\n\n // Normalise top-level dataset ('data-*') values using schema types\n for (const [field, property] of Object.entries(Component.schema.properties)) {\n if (field in dataset) {\n out[field] = normaliseString(dataset[field], property)\n }\n\n /**\n * Extract and normalise nested object values automatically using\n * {@link normaliseString} but only schema object types are allowed\n */\n if (property?.type === 'object') {\n out[field] = extractConfigByNamespace(Component.schema, dataset, field)\n }\n }\n\n return out\n}\n\n/**\n * Config merging function\n *\n * Takes any number of objects and combines them together, with\n * greatest priority on the LAST item passed in.\n *\n * @internal\n * @param {...{ [key: string]: unknown }} configObjects - Config objects to merge\n * @returns {{ [key: string]: unknown }} A merged config object\n */\nexport function mergeConfigs(...configObjects) {\n // Start with an empty object as our base\n /** @type {{ [key: string]: unknown }} */\n const formattedConfigObject = {}\n\n // Loop through each of the passed objects\n for (const configObject of configObjects) {\n for (const key of Object.keys(configObject)) {\n const option = formattedConfigObject[key]\n const override = configObject[key]\n\n // Push their keys one-by-one into formattedConfigObject. Any duplicate\n // keys with object values will be merged, otherwise the new value will\n // override the existing value.\n if (isObject(option) && isObject(override)) {\n // @ts-expect-error Index signature for type 'string' is missing\n formattedConfigObject[key] = mergeConfigs(option, override)\n } else {\n // Apply override\n formattedConfigObject[key] = override\n }\n }\n }\n\n return formattedConfigObject\n}\n\n/**\n * Validate component config by schema\n *\n * Follows limited examples in JSON schema for wider support in future\n *\n * {@link https://ajv.js.org/json-schema.html#compound-keywords}\n * {@link https://ajv.js.org/packages/ajv-errors.html#single-message}\n *\n * @internal\n * @param {Schema} schema - Config schema\n * @param {{ [key: string]: unknown }} config - Component config\n * @returns {string[]} List of validation errors\n */\nexport function validateConfig(schema, config) {\n const validationErrors = []\n\n // Check errors for each schema\n for (const [name, conditions] of Object.entries(schema)) {\n const errors = []\n\n // Check errors for each schema condition\n if (Array.isArray(conditions)) {\n for (const { required, errorMessage } of conditions) {\n if (!required.every((key) => !!config[key])) {\n errors.push(errorMessage) // Missing config key value\n }\n }\n\n // Check one condition passes or add errors\n if (name === 'anyOf' && !(conditions.length - errors.length >= 1)) {\n validationErrors.push(...errors)\n }\n }\n }\n\n return validationErrors\n}\n\n/**\n * Extracts keys starting with a particular namespace from dataset ('data-*')\n * object, removing the namespace in the process, normalising all values\n *\n * @internal\n * @param {Schema} schema - The schema of a component\n * @param {DOMStringMap} dataset - The object to extract key-value pairs from\n * @param {string} namespace - The namespace to filter keys with\n * @returns {ObjectNested | undefined} Nested object with dot-separated key namespace removed\n */\nexport function extractConfigByNamespace(schema, dataset, namespace) {\n const property = schema.properties[namespace]\n\n // Only extract configs for object schema properties\n if (property?.type !== 'object') {\n return\n }\n\n // Add default empty config\n const newObject = {\n [namespace]: /** @type {ObjectNested} */ ({})\n }\n\n for (const [key, value] of Object.entries(dataset)) {\n /** @type {ObjectNested | ObjectNested[NestedKey]} */\n let current = newObject\n\n // Split the key into parts, using . as our namespace separator\n const keyParts = key.split('.')\n\n /**\n * Create new level per part\n *\n * e.g. 'i18n.textareaDescription.other' becomes\n * `{ i18n: { textareaDescription: { other } } }`\n */\n for (const [index, name] of keyParts.entries()) {\n if (typeof current === 'object') {\n // Drop down to nested object until the last part\n if (index < keyParts.length - 1) {\n // New nested object (optionally) replaces existing value\n if (!isObject(current[name])) {\n current[name] = {}\n }\n\n // Drop down into new or existing nested object\n current = current[name]\n } else if (key !== namespace) {\n // Normalised value (optionally) replaces existing value\n current[name] = normaliseString(value)\n }\n }\n }\n }\n\n return newObject[namespace]\n}\n\n/**\n * @internal\n * @typedef {keyof ObjectNested} NestedKey\n * @typedef {{ [key: string]: string | boolean | number | ObjectNested | undefined }} ObjectNested\n */\n\n/**\n * Schema for component config\n *\n * @typedef {object} Schema\n * @property {{ [field: string]: SchemaProperty | undefined }} properties - Schema properties\n * @property {SchemaCondition[]} [anyOf] - List of schema conditions\n */\n\n/**\n * Schema property for component config\n *\n * @typedef {object} SchemaProperty\n * @property {'string' | 'boolean' | 'number' | 'object'} type - Property type\n */\n\n/**\n * Schema condition for component config\n *\n * @typedef {object} SchemaCondition\n * @property {string[]} required - List of required config fields\n * @property {string} errorMessage - Error message when required config fields not provided\n */\n\n/**\n * @template {ObjectNested} [ConfigurationType={}]\n * @typedef ChildClass\n * @property {string} moduleName - The module name that'll be looked for in the DOM when initialising the component\n * @property {Schema} [schema] - The schema of the component configuration\n * @property {ConfigurationType} [defaults] - The default values of the configuration of the component\n */\n\n/**\n * @template {ObjectNested} [ConfigurationType={}]\n * @typedef {typeof GOVUKFrontendComponent & ChildClass<ConfigurationType>} ChildClassConstructor<ConfigurationType>\n */\n"],"names":["configOverride","Symbol","for","ConfigurableComponent","GOVUKFrontendComponent","param","config","_config","constructor","$root","childConstructor","defaults","ConfigError","formatErrorMessage","datasetConfig","normaliseDataset","_$root","dataset","mergeConfigs","normaliseString","value","property","trimmedValue","trim","output","outputType","type","includes","length","isFinite","Number","Component","schema","out","field","Object","entries","properties","extractConfigByNamespace","configObjects","formattedConfigObject","configObject","key","keys","option","override","isObject","validateConfig","validationErrors","name","conditions","errors","Array","isArray","required","errorMessage","every","push","namespace","newObject","current","keyParts","split","index"],"mappings":";;;;AAKO,MAAMA,cAAc,GAAGC,MAAM,CAACC,GAAG,CAAC,gBAAgB,EAAC;AAYnD,MAAMC,qBAAqB,SAASC,sBAAsB,CAAC;EAkBhE,CAACJ,cAAc,CAAEK,CAAAA,KAAK,EAAE;AACtB,IAAA,OAAO,EAAE,CAAA;AACX,GAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;EACE,IAAIC,MAAMA,GAAG;IACX,OAAO,IAAI,CAACC,OAAO,CAAA;AACrB,GAAA;AAeAC,EAAAA,WAAWA,CAACC,KAAK,EAAEH,MAAM,EAAE;IACzB,KAAK,CAACG,KAAK,CAAC,CAAA;AAAA,IAAA,IAAA,CAVdF,OAAO,GAAA,KAAA,CAAA,CAAA;AAYL,IAAA,MAAMG,gBAAgB,GACqC,IAAI,CAACF,WAAY,CAAA;AAE5E,IAAA,IAAI,OAAO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AOuC,SAAS,CAACD,SAAS,CAAC,CAAA;AAC7B,CAAA;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;;;;"}
@@ -1,4 +1,4 @@
1
- const version = '5.7.1';
1
+ const version = '5.8.0';
2
2
 
3
3
  export { version };
4
4
  //# sourceMappingURL=govuk-frontend-version.mjs.map
@@ -1,46 +1,3 @@
1
- import { normaliseString } from './normalise-string.mjs';
2
-
3
- function mergeConfigs(...configObjects) {
4
- const formattedConfigObject = {};
5
- for (const configObject of configObjects) {
6
- for (const key of Object.keys(configObject)) {
7
- const option = formattedConfigObject[key];
8
- const override = configObject[key];
9
- if (isObject(option) && isObject(override)) {
10
- formattedConfigObject[key] = mergeConfigs(option, override);
11
- } else {
12
- formattedConfigObject[key] = override;
13
- }
14
- }
15
- }
16
- return formattedConfigObject;
17
- }
18
- function extractConfigByNamespace(Component, dataset, namespace) {
19
- const property = Component.schema.properties[namespace];
20
- if ((property == null ? void 0 : property.type) !== 'object') {
21
- return;
22
- }
23
- const newObject = {
24
- [namespace]: ({})
25
- };
26
- for (const [key, value] of Object.entries(dataset)) {
27
- let current = newObject;
28
- const keyParts = key.split('.');
29
- for (const [index, name] of keyParts.entries()) {
30
- if (typeof current === 'object') {
31
- if (index < keyParts.length - 1) {
32
- if (!isObject(current[name])) {
33
- current[name] = {};
34
- }
35
- current = current[name];
36
- } else if (key !== namespace) {
37
- current[name] = normaliseString(value);
38
- }
39
- }
40
- }
41
- }
42
- return newObject[namespace];
43
- }
44
1
  function getFragmentFromUrl(url) {
45
2
  if (!url.includes('#')) {
46
3
  return undefined;
@@ -98,26 +55,6 @@ function isSupported($scope = document.body) {
98
55
  }
99
56
  return $scope.classList.contains('govuk-frontend-supported');
100
57
  }
101
- function validateConfig(schema, config) {
102
- const validationErrors = [];
103
- for (const [name, conditions] of Object.entries(schema)) {
104
- const errors = [];
105
- if (Array.isArray(conditions)) {
106
- for (const {
107
- required,
108
- errorMessage
109
- } of conditions) {
110
- if (!required.every(key => !!config[key])) {
111
- errors.push(errorMessage);
112
- }
113
- }
114
- if (name === 'anyOf' && !(conditions.length - errors.length >= 1)) {
115
- validationErrors.push(...errors);
116
- }
117
- }
118
- }
119
- return validationErrors;
120
- }
121
58
  function isArray(option) {
122
59
  return Array.isArray(option);
123
60
  }
@@ -127,33 +64,10 @@ function isObject(option) {
127
64
  function formatErrorMessage(Component, message) {
128
65
  return `${Component.moduleName}: ${message}`;
129
66
  }
130
-
131
- /**
132
- * Schema for component config
133
- *
134
- * @typedef {object} Schema
135
- * @property {{ [field: string]: SchemaProperty | undefined }} properties - Schema properties
136
- * @property {SchemaCondition[]} [anyOf] - List of schema conditions
137
- */
138
-
139
- /**
140
- * Schema property for component config
141
- *
142
- * @typedef {object} SchemaProperty
143
- * @property {'string' | 'boolean' | 'number' | 'object'} type - Property type
144
- */
145
-
146
- /**
147
- * Schema condition for component config
148
- *
149
- * @typedef {object} SchemaCondition
150
- * @property {string[]} required - List of required config fields
151
- * @property {string} errorMessage - Error message when required config fields not provided
152
- */
153
67
  /**
154
68
  * @typedef ComponentWithModuleName
155
69
  * @property {string} moduleName - Name of the component
156
70
  */
157
71
 
158
- export { extractConfigByNamespace, formatErrorMessage, getBreakpoint, getFragmentFromUrl, isInitialised, isSupported, mergeConfigs, setFocus, validateConfig };
72
+ export { formatErrorMessage, getBreakpoint, getFragmentFromUrl, isInitialised, isObject, isSupported, setFocus };
159
73
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../../src/govuk/common/index.mjs"],"sourcesContent":["import { normaliseString } from './normalise-string.mjs'\n\n/**\n * Common helpers which do not require polyfill.\n *\n * IMPORTANT: If a helper require a polyfill, please isolate it in its own module\n * so that the polyfill can be properly tree-shaken and does not burden\n * the components that do not need that helper\n */\n\n/**\n * Config merging function\n *\n * Takes any number of objects and combines them together, with\n * greatest priority on the LAST item passed in.\n *\n * @internal\n * @param {...{ [key: string]: unknown }} configObjects - Config objects to merge\n * @returns {{ [key: string]: unknown }} A merged config object\n */\nexport function mergeConfigs(...configObjects) {\n // Start with an empty object as our base\n /** @type {{ [key: string]: unknown }} */\n const formattedConfigObject = {}\n\n // Loop through each of the passed objects\n for (const configObject of configObjects) {\n for (const key of Object.keys(configObject)) {\n const option = formattedConfigObject[key]\n const override = configObject[key]\n\n // Push their keys one-by-one into formattedConfigObject. Any duplicate\n // keys with object values will be merged, otherwise the new value will\n // override the existing value.\n if (isObject(option) && isObject(override)) {\n // @ts-expect-error Index signature for type 'string' is missing\n formattedConfigObject[key] = mergeConfigs(option, override)\n } else {\n // Apply override\n formattedConfigObject[key] = override\n }\n }\n }\n\n return formattedConfigObject\n}\n\n/**\n * Extracts keys starting with a particular namespace from dataset ('data-*')\n * object, removing the namespace in the process, normalising all values\n *\n * @internal\n * @param {{ schema: Schema }} Component - Component class\n * @param {DOMStringMap} dataset - The object to extract key-value pairs from\n * @param {string} namespace - The namespace to filter keys with\n * @returns {ObjectNested | undefined} Nested object with dot-separated key namespace removed\n */\nexport function extractConfigByNamespace(Component, dataset, namespace) {\n const property = Component.schema.properties[namespace]\n\n // Only extract configs for object schema properties\n if (property?.type !== 'object') {\n return\n }\n\n // Add default empty config\n const newObject = {\n [namespace]: /** @type {ObjectNested} */ ({})\n }\n\n for (const [key, value] of Object.entries(dataset)) {\n /** @type {ObjectNested | ObjectNested[NestedKey]} */\n let current = newObject\n\n // Split the key into parts, using . as our namespace separator\n const keyParts = key.split('.')\n\n /**\n * Create new level per part\n *\n * e.g. 'i18n.textareaDescription.other' becomes\n * `{ i18n: { textareaDescription: { other } } }`\n */\n for (const [index, name] of keyParts.entries()) {\n if (typeof current === 'object') {\n // Drop down to nested object until the last part\n if (index < keyParts.length - 1) {\n // New nested object (optionally) replaces existing value\n if (!isObject(current[name])) {\n current[name] = {}\n }\n\n // Drop down into new or existing nested object\n current = current[name]\n } else if (key !== namespace) {\n // Normalised value (optionally) replaces existing value\n current[name] = normaliseString(value)\n }\n }\n }\n }\n\n return newObject[namespace]\n}\n\n/**\n * Get hash fragment from URL\n *\n * Extract the hash fragment (everything after the hash) from a URL,\n * but not including the hash symbol\n *\n * @private\n * @param {string} url - URL\n * @returns {string | undefined} Fragment from URL, without the hash\n */\nexport function getFragmentFromUrl(url) {\n if (!url.includes('#')) {\n return undefined\n }\n\n return url.split('#').pop()\n}\n\n/**\n * Get GOV.UK Frontend breakpoint value from CSS custom property\n *\n * @private\n * @param {string} name - Breakpoint name\n * @returns {{ property: string, value?: string }} Breakpoint object\n */\nexport function getBreakpoint(name) {\n const property = `--govuk-frontend-breakpoint-${name}`\n\n // Get value from `<html>` with breakpoints on CSS :root\n const value = window\n .getComputedStyle(document.documentElement)\n .getPropertyValue(property)\n\n return {\n property,\n value: value || undefined\n }\n}\n\n/**\n * Move focus to element\n *\n * Sets tabindex to -1 to make the element programmatically focusable,\n * but removes it on blur as the element doesn't need to be focused again.\n *\n * @private\n * @template {HTMLElement} FocusElement\n * @param {FocusElement} $element - HTML element\n * @param {object} [options] - Handler options\n * @param {function(this: FocusElement): void} [options.onBeforeFocus] - Callback before focus\n * @param {function(this: FocusElement): void} [options.onBlur] - Callback on blur\n */\nexport function setFocus($element, options = {}) {\n const isFocusable = $element.getAttribute('tabindex')\n\n if (!isFocusable) {\n $element.setAttribute('tabindex', '-1')\n }\n\n /**\n * Handle element focus\n */\n function onFocus() {\n $element.addEventListener('blur', onBlur, { once: true })\n }\n\n /**\n * Handle element blur\n */\n function onBlur() {\n options.onBlur?.call($element)\n\n if (!isFocusable) {\n $element.removeAttribute('tabindex')\n }\n }\n\n // Add listener to reset element on blur, after focus\n $element.addEventListener('focus', onFocus, { once: true })\n\n // Focus element\n options.onBeforeFocus?.call($element)\n $element.focus()\n}\n\n/**\n * Checks if component is already initialised\n *\n * @internal\n * @param {Element} $root - HTML element to be checked\n * @param {string} moduleName - name of component module\n * @returns {boolean} Whether component is already initialised\n */\nexport function isInitialised($root, moduleName) {\n return (\n $root instanceof HTMLElement &&\n $root.hasAttribute(`data-${moduleName}-init`)\n )\n}\n\n/**\n * Checks if GOV.UK Frontend is supported on this page\n *\n * Some browsers will load and run our JavaScript but GOV.UK Frontend\n * won't be supported.\n *\n * @param {HTMLElement | null} [$scope] - (internal) `<body>` HTML element checked for browser support\n * @returns {boolean} Whether GOV.UK Frontend is supported on this page\n */\nexport function isSupported($scope = document.body) {\n if (!$scope) {\n return false\n }\n\n return $scope.classList.contains('govuk-frontend-supported')\n}\n\n/**\n * Validate component config by schema\n *\n * Follows limited examples in JSON schema for wider support in future\n *\n * {@link https://ajv.js.org/json-schema.html#compound-keywords}\n * {@link https://ajv.js.org/packages/ajv-errors.html#single-message}\n *\n * @internal\n * @param {Schema} schema - Config schema\n * @param {{ [key: string]: unknown }} config - Component config\n * @returns {string[]} List of validation errors\n */\nexport function validateConfig(schema, config) {\n const validationErrors = []\n\n // Check errors for each schema\n for (const [name, conditions] of Object.entries(schema)) {\n const errors = []\n\n // Check errors for each schema condition\n if (Array.isArray(conditions)) {\n for (const { required, errorMessage } of conditions) {\n if (!required.every((key) => !!config[key])) {\n errors.push(errorMessage) // Missing config key value\n }\n }\n\n // Check one condition passes or add errors\n if (name === 'anyOf' && !(conditions.length - errors.length >= 1)) {\n validationErrors.push(...errors)\n }\n }\n }\n\n return validationErrors\n}\n\n/**\n * Check for an array\n *\n * @internal\n * @param {unknown} option - Option to check\n * @returns {boolean} Whether the option is an array\n */\nfunction isArray(option) {\n return Array.isArray(option)\n}\n\n/**\n * Check for an object\n *\n * @internal\n * @param {unknown} option - Option to check\n * @returns {boolean} Whether the option is an object\n */\nfunction isObject(option) {\n return !!option && typeof option === 'object' && !isArray(option)\n}\n\n/**\n * Format error message\n *\n * @internal\n * @param {ComponentWithModuleName} Component - Component that threw the error\n * @param {string} message - Error message\n * @returns {string} - Formatted error message\n */\nexport function formatErrorMessage(Component, message) {\n return `${Component.moduleName}: ${message}`\n}\n\n/**\n * Schema for component config\n *\n * @typedef {object} Schema\n * @property {{ [field: string]: SchemaProperty | undefined }} properties - Schema properties\n * @property {SchemaCondition[]} [anyOf] - List of schema conditions\n */\n\n/**\n * Schema property for component config\n *\n * @typedef {object} SchemaProperty\n * @property {'string' | 'boolean' | 'number' | 'object'} type - Property type\n */\n\n/**\n * Schema condition for component config\n *\n * @typedef {object} SchemaCondition\n * @property {string[]} required - List of required config fields\n * @property {string} errorMessage - Error message when required config fields not provided\n */\n\n/**\n * @internal\n * @typedef {keyof ObjectNested} NestedKey\n * @typedef {{ [key: string]: string | boolean | number | ObjectNested | undefined }} ObjectNested\n */\n\n/* eslint-disable jsdoc/valid-types --\n * `{new(...args: any[] ): object}` is not recognised as valid\n * https://github.com/gajus/eslint-plugin-jsdoc/issues/145#issuecomment-1308722878\n * https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/131\n **/\n\n/**\n * @typedef ComponentWithModuleName\n * @property {string} moduleName - Name of the component\n */\n\n/* eslint-enable jsdoc/valid-types */\n"],"names":["mergeConfigs","configObjects","formattedConfigObject","configObject","key","Object","keys","option","override","isObject","extractConfigByNamespace","Component","dataset","namespace","property","schema","properties","type","newObject","value","entries","current","keyParts","split","index","name","length","normaliseString","getFragmentFromUrl","url","includes","undefined","pop","getBreakpoint","window","getComputedStyle","document","documentElement","getPropertyValue","setFocus","$element","options","_options$onBeforeFocu","isFocusable","getAttribute","setAttribute","onFocus","addEventListener","onBlur","once","_options$onBlur","call","removeAttribute","onBeforeFocus","focus","isInitialised","$root","moduleName","HTMLElement","hasAttribute","isSupported","$scope","body","classList","contains","validateConfig","config","validationErrors","conditions","errors","Array","isArray","required","errorMessage","every","push","formatErrorMessage","message"],"mappings":";;AAoBO,SAASA,YAAYA,CAAC,GAAGC,aAAa,EAAE;EAG7C,MAAMC,qBAAqB,GAAG,EAAE,CAAA;AAGhC,E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AAM,KAAK,QAAQ,IAAI,CAACgE,OAAO,CAAChE,MAAM,CAAC,CAAA;AACnE,CAAA;AAUO,SAASqE,kBAAkBA,CAACjE,SAAS,EAAEkE,OAAO,EAAE;AACrD,EAAA,OAAO,GAAGlE,SAAS,CAAC8C,UAAU,CAAA,EAAA,EAAKoB,OAAO,CAAE,CAAA,CAAA;AAC9C,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAcA;AACA;AACA;AACA;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../../src/govuk/common/index.mjs"],"sourcesContent":["/**\n * Common helpers which do not require polyfill.\n *\n * IMPORTANT: If a helper require a polyfill, please isolate it in its own module\n * so that the polyfill can be properly tree-shaken and does not burden\n * the components that do not need that helper\n */\n\n/**\n * Get hash fragment from URL\n *\n * Extract the hash fragment (everything after the hash) from a URL,\n * but not including the hash symbol\n *\n * @private\n * @param {string} url - URL\n * @returns {string | undefined} Fragment from URL, without the hash\n */\nexport function getFragmentFromUrl(url) {\n if (!url.includes('#')) {\n return undefined\n }\n\n return url.split('#').pop()\n}\n\n/**\n * Get GOV.UK Frontend breakpoint value from CSS custom property\n *\n * @private\n * @param {string} name - Breakpoint name\n * @returns {{ property: string, value?: string }} Breakpoint object\n */\nexport function getBreakpoint(name) {\n const property = `--govuk-frontend-breakpoint-${name}`\n\n // Get value from `<html>` with breakpoints on CSS :root\n const value = window\n .getComputedStyle(document.documentElement)\n .getPropertyValue(property)\n\n return {\n property,\n value: value || undefined\n }\n}\n\n/**\n * Move focus to element\n *\n * Sets tabindex to -1 to make the element programmatically focusable,\n * but removes it on blur as the element doesn't need to be focused again.\n *\n * @private\n * @template {HTMLElement} FocusElement\n * @param {FocusElement} $element - HTML element\n * @param {object} [options] - Handler options\n * @param {function(this: FocusElement): void} [options.onBeforeFocus] - Callback before focus\n * @param {function(this: FocusElement): void} [options.onBlur] - Callback on blur\n */\nexport function setFocus($element, options = {}) {\n const isFocusable = $element.getAttribute('tabindex')\n\n if (!isFocusable) {\n $element.setAttribute('tabindex', '-1')\n }\n\n /**\n * Handle element focus\n */\n function onFocus() {\n $element.addEventListener('blur', onBlur, { once: true })\n }\n\n /**\n * Handle element blur\n */\n function onBlur() {\n options.onBlur?.call($element)\n\n if (!isFocusable) {\n $element.removeAttribute('tabindex')\n }\n }\n\n // Add listener to reset element on blur, after focus\n $element.addEventListener('focus', onFocus, { once: true })\n\n // Focus element\n options.onBeforeFocus?.call($element)\n $element.focus()\n}\n\n/**\n * Checks if component is already initialised\n *\n * @internal\n * @param {Element} $root - HTML element to be checked\n * @param {string} moduleName - name of component module\n * @returns {boolean} Whether component is already initialised\n */\nexport function isInitialised($root, moduleName) {\n return (\n $root instanceof HTMLElement &&\n $root.hasAttribute(`data-${moduleName}-init`)\n )\n}\n\n/**\n * Checks if GOV.UK Frontend is supported on this page\n *\n * Some browsers will load and run our JavaScript but GOV.UK Frontend\n * won't be supported.\n *\n * @param {HTMLElement | null} [$scope] - (internal) `<body>` HTML element checked for browser support\n * @returns {boolean} Whether GOV.UK Frontend is supported on this page\n */\nexport function isSupported($scope = document.body) {\n if (!$scope) {\n return false\n }\n\n return $scope.classList.contains('govuk-frontend-supported')\n}\n\n/**\n * Check for an array\n *\n * @internal\n * @param {unknown} option - Option to check\n * @returns {boolean} Whether the option is an array\n */\nfunction isArray(option) {\n return Array.isArray(option)\n}\n\n/**\n * Check for an object\n *\n * @internal\n * @param {unknown} option - Option to check\n * @returns {boolean} Whether the option is an object\n */\nexport function isObject(option) {\n return !!option && typeof option === 'object' && !isArray(option)\n}\n\n/**\n * Format error message\n *\n * @internal\n * @param {ComponentWithModuleName} Component - Component that threw the error\n * @param {string} message - Error message\n * @returns {string} - Formatted error message\n */\nexport function formatErrorMessage(Component, message) {\n return `${Component.moduleName}: ${message}`\n}\n\n/* eslint-disable jsdoc/valid-types --\n * `{new(...args: any[] ): object}` is not recognised as valid\n * https://github.com/gajus/eslint-plugin-jsdoc/issues/145#issuecomment-1308722878\n * https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/131\n **/\n\n/**\n * @typedef ComponentWithModuleName\n * @property {string} moduleName - Name of the component\n */\n\n/* eslint-enable jsdoc/valid-types */\n"],"names":["getFragmentFromUrl","url","includes","undefined","split","pop","getBreakpoint","name","property","value","window","getComputedStyle","document","documentElement","getPropertyValue","setFocus","$element","options","_options$onBeforeFocu","isFocusable","getAttribute","setAttribute","onFocus","addEventListener","onBlur","once","_options$onBlur","call","removeAttribute","onBeforeFocus","focus","isInitialised","$root","moduleName","HTMLElement","hasAttribute","isSupported","$scope","body","classList","contains","isArray","option","Array","isObject","formatErrorMessage","Component","message"],"mappings":"AAkBO,SAASA,kBAAkBA,CAACC,GAAG,EAAE;AACtC,EAAA,IAAI,CAACA,GAAG,CAACC,QAAQ,CAAC,GAAG,CAAC,EAAE;AACtB,IAAA,OAAOC,SAAS,CAAA;AAClB,GAAA;EAEA,OAAOF,GAAG,CAACG,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,EAAE,CAAA;AAC7B,CAAA;AASO,SAASC,aAAaA,CAACC,IAAI,EAAE;AAClC,EAAA,MAAMC,QAAQ,GAAG,CAA+BD,4BAAAA,EAAAA,IAAI,CAAE,CAAA,CAAA;AAGtD,EAAA,MAAME,KAAK,GAAGC,MAAM,CACjBC,gBAAgB,CAACC,QAAQ,CAACC,eAAe,CAAC,CAC1CC,gBAAgB,CAACN,QAAQ,CAAC,CAAA;EAE7B,OAAO;IACLA,QAAQ;IACRC,KAAK,EAAEA,KAAK,IAAIN,SAAAA;GACjB,CAAA;AACH,CAAA;AAeO,SAASY,QAAQA,CAACC,QAAQ,EAAEC,OAAO,GAAG,EAAE,EAAE;AAAA,EAAA,IAAAC,qBAAA,CAAA;AAC/C,EAAA,MAAMC,WAAW,GAAGH,QAAQ,CAACI,YAAY,CAAC,UAAU,CAAC,CAAA;EAErD,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