govuk_publishing_components 32.0.0 → 33.0.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/app/assets/javascripts/component_guide/accessibility-test.js +0 -1
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-core.js +175 -0
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-ecommerce-tracker.js +1 -1
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-event-tracker.js +5 -13
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-link-tracker.js +80 -309
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-page-views.js +2 -2
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-specialist-link-tracker.js +140 -0
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/init-ga4.js +3 -0
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4.js +1 -0
- data/app/assets/javascripts/govuk_publishing_components/components/accordion.js +12 -1
- data/app/assets/javascripts/govuk_publishing_components/components/layout-super-navigation-header.js +13 -4
- data/app/assets/javascripts/govuk_publishing_components/components/single-page-notification-button.js +24 -8
- data/app/assets/javascripts/govuk_publishing_components/vendor/lux/lux-reporter.js +83 -86
- data/app/assets/stylesheets/govuk_publishing_components/components/_big-number.scss +2 -5
- data/app/assets/stylesheets/govuk_publishing_components/components/_image-card.scss +1 -5
- data/app/assets/stylesheets/govuk_publishing_components/components/_input.scss +3 -5
- data/app/assets/stylesheets/govuk_publishing_components/components/_layout-super-navigation-header.scss +10 -30
- data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +0 -7
- data/app/assets/stylesheets/govuk_publishing_components/components/_share-links.scss +0 -6
- data/app/views/govuk_publishing_components/components/_accordion.html.erb +14 -1
- data/app/views/govuk_publishing_components/components/_error_summary.html.erb +27 -26
- data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +2 -2
- data/app/views/govuk_publishing_components/components/_phase_banner.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/_share_links.html.erb +18 -15
- data/app/views/govuk_publishing_components/components/_single_page_notification_button.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/docs/accordion.yml +15 -3
- data/app/views/govuk_publishing_components/components/docs/button.yml +10 -0
- data/app/views/govuk_publishing_components/components/docs/share_links.yml +59 -30
- data/app/views/govuk_publishing_components/components/docs/single_page_notification_button.yml +10 -1
- data/app/views/govuk_publishing_components/components/feedback/_yes_no_banner.html.erb +3 -3
- data/config/locales/ar.yml +4 -1
- data/config/locales/az.yml +4 -1
- data/config/locales/be.yml +4 -1
- data/config/locales/bg.yml +4 -1
- data/config/locales/bn.yml +4 -1
- data/config/locales/cs.yml +4 -1
- data/config/locales/cy.yml +4 -1
- data/config/locales/da.yml +4 -1
- data/config/locales/de.yml +4 -1
- data/config/locales/dr.yml +4 -1
- data/config/locales/el.yml +4 -1
- data/config/locales/en.yml +20 -17
- data/config/locales/es-419.yml +4 -1
- data/config/locales/es.yml +4 -1
- data/config/locales/et.yml +4 -1
- data/config/locales/fa.yml +4 -1
- data/config/locales/fi.yml +4 -1
- data/config/locales/fr.yml +4 -1
- data/config/locales/gd.yml +4 -1
- data/config/locales/gu.yml +4 -1
- data/config/locales/he.yml +4 -1
- data/config/locales/hi.yml +4 -1
- data/config/locales/hr.yml +4 -1
- data/config/locales/hu.yml +4 -1
- data/config/locales/hy.yml +4 -1
- data/config/locales/id.yml +4 -1
- data/config/locales/is.yml +4 -1
- data/config/locales/it.yml +4 -1
- data/config/locales/ja.yml +4 -1
- data/config/locales/ka.yml +4 -1
- data/config/locales/kk.yml +4 -1
- data/config/locales/ko.yml +4 -1
- data/config/locales/lt.yml +4 -1
- data/config/locales/lv.yml +4 -1
- data/config/locales/ms.yml +4 -1
- data/config/locales/mt.yml +4 -1
- data/config/locales/nl.yml +4 -1
- data/config/locales/no.yml +4 -1
- data/config/locales/pa-pk.yml +4 -1
- data/config/locales/pa.yml +4 -1
- data/config/locales/pl.yml +4 -1
- data/config/locales/ps.yml +4 -1
- data/config/locales/pt.yml +4 -1
- data/config/locales/ro.yml +4 -1
- data/config/locales/ru.yml +4 -1
- data/config/locales/si.yml +4 -1
- data/config/locales/sk.yml +4 -1
- data/config/locales/sl.yml +4 -1
- data/config/locales/so.yml +4 -1
- data/config/locales/sq.yml +4 -1
- data/config/locales/sr.yml +4 -1
- data/config/locales/sv.yml +4 -1
- data/config/locales/sw.yml +4 -1
- data/config/locales/ta.yml +4 -1
- data/config/locales/th.yml +4 -1
- data/config/locales/tk.yml +4 -1
- data/config/locales/tr.yml +4 -1
- data/config/locales/uk.yml +4 -1
- data/config/locales/ur.yml +4 -1
- data/config/locales/uz.yml +4 -1
- data/config/locales/vi.yml +4 -1
- data/config/locales/zh-hk.yml +4 -1
- data/config/locales/zh-tw.yml +4 -1
- data/config/locales/zh.yml +4 -1
- data/lib/govuk_publishing_components/presenters/button_helper.rb +7 -1
- data/lib/govuk_publishing_components/presenters/single_page_notification_button_helper.rb +25 -1
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/axe-core/axe.js +4567 -4678
- data/node_modules/axe-core/axe.min.js +2 -2
- data/node_modules/axe-core/package.json +2 -2
- data/node_modules/axe-core/sri-history.json +8 -0
- data/node_modules/govuk-frontend/README.md +1 -2
- data/node_modules/govuk-frontend/govuk/all.js +1398 -273
- data/node_modules/govuk-frontend/govuk/common/closest-attribute-value.js +70 -0
- data/node_modules/govuk-frontend/govuk/common/index.js +172 -0
- data/node_modules/govuk-frontend/govuk/common/normalise-dataset.js +373 -0
- data/node_modules/govuk-frontend/govuk/common.js +138 -3
- data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js +753 -25
- data/node_modules/govuk-frontend/govuk/components/accordion/fixtures.json +54 -22
- data/node_modules/govuk-frontend/govuk/components/accordion/macro-options.json +36 -0
- data/node_modules/govuk-frontend/govuk/components/accordion/template.njk +7 -1
- data/node_modules/govuk-frontend/govuk/components/back-link/fixtures.json +12 -12
- data/node_modules/govuk-frontend/govuk/components/breadcrumbs/fixtures.json +22 -22
- data/node_modules/govuk-frontend/govuk/components/button/_index.scss +23 -5
- data/node_modules/govuk-frontend/govuk/components/button/button.js +365 -107
- data/node_modules/govuk-frontend/govuk/components/button/fixtures.json +85 -66
- data/node_modules/govuk-frontend/govuk/components/button/template.njk +1 -1
- data/node_modules/govuk-frontend/govuk/components/character-count/_index.scss +9 -0
- data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +1033 -121
- data/node_modules/govuk-frontend/govuk/components/character-count/fixtures.json +112 -36
- data/node_modules/govuk-frontend/govuk/components/character-count/macro-options.json +42 -0
- data/node_modules/govuk-frontend/govuk/components/character-count/template.njk +27 -3
- data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js +30 -2
- data/node_modules/govuk-frontend/govuk/components/checkboxes/fixtures.json +96 -93
- data/node_modules/govuk-frontend/govuk/components/cookie-banner/fixtures.json +46 -46
- data/node_modules/govuk-frontend/govuk/components/date-input/fixtures.json +50 -50
- data/node_modules/govuk-frontend/govuk/components/details/details.js +43 -13
- data/node_modules/govuk-frontend/govuk/components/details/fixtures.json +20 -20
- data/node_modules/govuk-frontend/govuk/components/error-message/fixtures.json +20 -20
- data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js +268 -6
- data/node_modules/govuk-frontend/govuk/components/error-summary/fixtures.json +44 -35
- data/node_modules/govuk-frontend/govuk/components/error-summary/template.njk +25 -21
- data/node_modules/govuk-frontend/govuk/components/fieldset/fixtures.json +51 -39
- data/node_modules/govuk-frontend/govuk/components/file-upload/fixtures.json +26 -26
- data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +1 -1
- data/node_modules/govuk-frontend/govuk/components/footer/fixtures.json +46 -46
- data/node_modules/govuk-frontend/govuk/components/footer/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/header/fixtures.json +93 -38
- data/node_modules/govuk-frontend/govuk/components/header/header.js +6 -0
- data/node_modules/govuk-frontend/govuk/components/header/macro-options.json +8 -2
- data/node_modules/govuk-frontend/govuk/components/header/template.njk +4 -2
- data/node_modules/govuk-frontend/govuk/components/hint/fixtures.json +12 -12
- data/node_modules/govuk-frontend/govuk/components/input/fixtures.json +80 -80
- data/node_modules/govuk-frontend/govuk/components/inset-text/fixtures.json +12 -12
- data/node_modules/govuk-frontend/govuk/components/label/fixtures.json +34 -34
- data/node_modules/govuk-frontend/govuk/components/notification-banner/fixtures.json +56 -46
- data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js +252 -2
- data/node_modules/govuk-frontend/govuk/components/notification-banner/template.njk +1 -1
- data/node_modules/govuk-frontend/govuk/components/pagination/_index.scss +10 -7
- data/node_modules/govuk-frontend/govuk/components/pagination/fixtures.json +33 -26
- data/node_modules/govuk-frontend/govuk/components/panel/fixtures.json +18 -18
- data/node_modules/govuk-frontend/govuk/components/phase-banner/fixtures.json +14 -14
- data/node_modules/govuk-frontend/govuk/components/radios/fixtures.json +94 -91
- data/node_modules/govuk-frontend/govuk/components/radios/radios.js +30 -2
- data/node_modules/govuk-frontend/govuk/components/select/fixtures.json +32 -32
- data/node_modules/govuk-frontend/govuk/components/skip-link/fixtures.json +22 -20
- data/node_modules/govuk-frontend/govuk/components/skip-link/skip-link.js +10 -4
- data/node_modules/govuk-frontend/govuk/components/summary-list/fixtures.json +50 -50
- data/node_modules/govuk-frontend/govuk/components/table/_index.scss +1 -1
- data/node_modules/govuk-frontend/govuk/components/table/fixtures.json +40 -40
- data/node_modules/govuk-frontend/govuk/components/tabs/fixtures.json +29 -29
- data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js +28 -0
- data/node_modules/govuk-frontend/govuk/components/tag/fixtures.json +28 -28
- data/node_modules/govuk-frontend/govuk/components/textarea/fixtures.json +34 -34
- data/node_modules/govuk-frontend/govuk/components/warning-text/fixtures.json +14 -14
- data/node_modules/govuk-frontend/govuk/core/_section-break.scss +1 -1
- data/node_modules/govuk-frontend/govuk/helpers/_colour.scss +2 -2
- data/node_modules/govuk-frontend/govuk/helpers/_links.scss +6 -6
- data/node_modules/govuk-frontend/govuk/i18n.js +390 -0
- data/node_modules/govuk-frontend/govuk/macros/i18n.njk +15 -0
- data/node_modules/govuk-frontend/govuk/settings/_all.scss +1 -0
- data/node_modules/govuk-frontend/govuk/settings/_colours-palette.scss +12 -0
- data/node_modules/govuk-frontend/govuk/settings/_compatibility.scss +26 -0
- data/node_modules/govuk-frontend/govuk/settings/_typography-font.scss +23 -0
- data/node_modules/govuk-frontend/govuk/settings/_typography-responsive.scss +12 -0
- data/node_modules/govuk-frontend/govuk/settings/_warnings.scss +53 -0
- data/node_modules/govuk-frontend/govuk/tools/_compatibility.scss +20 -6
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Date/now.js +21 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/dataset.js +300 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/String/prototype/trim.js +21 -0
- data/node_modules/govuk-frontend/govuk-esm/all.mjs +50 -27
- data/node_modules/govuk-frontend/govuk-esm/common/closest-attribute-value.mjs +15 -0
- data/node_modules/govuk-frontend/govuk-esm/common/index.mjs +159 -0
- data/node_modules/govuk-frontend/govuk-esm/common/normalise-dataset.mjs +58 -0
- data/node_modules/govuk-frontend/govuk-esm/common.mjs +6 -28
- data/node_modules/govuk-frontend/govuk-esm/components/accordion/accordion.mjs +113 -43
- data/node_modules/govuk-frontend/govuk-esm/components/button/button.mjs +67 -30
- data/node_modules/govuk-frontend/govuk-esm/components/character-count/character-count.mjs +325 -123
- data/node_modules/govuk-frontend/govuk-esm/components/checkboxes/checkboxes.mjs +9 -3
- data/node_modules/govuk-frontend/govuk-esm/components/details/details.mjs +22 -8
- data/node_modules/govuk-frontend/govuk-esm/components/error-summary/error-summary.mjs +48 -6
- data/node_modules/govuk-frontend/govuk-esm/components/header/header.mjs +6 -0
- data/node_modules/govuk-frontend/govuk-esm/components/notification-banner/notification-banner.mjs +32 -2
- data/node_modules/govuk-frontend/govuk-esm/components/radios/radios.mjs +9 -3
- data/node_modules/govuk-frontend/govuk-esm/components/skip-link/skip-link.mjs +10 -4
- data/node_modules/govuk-frontend/govuk-esm/components/tabs/tabs.mjs +8 -2
- data/node_modules/govuk-frontend/govuk-esm/i18n.mjs +380 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Date/now.mjs +13 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/dataset.mjs +68 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/String/prototype/trim.mjs +13 -0
- data/node_modules/govuk-frontend/govuk-prototype-kit/init.js +7 -0
- data/node_modules/govuk-frontend/govuk-prototype-kit/init.scss +12 -0
- data/node_modules/govuk-frontend/govuk-prototype-kit.config.json +138 -7
- data/node_modules/govuk-frontend/package.json +1 -1
- metadata +22 -3
@@ -4,10 +4,24 @@
|
|
4
4
|
(factory((global.GOVUKFrontend = {})));
|
5
5
|
}(this, (function (exports) { 'use strict';
|
6
6
|
|
7
|
+
/**
|
8
|
+
* Common helpers which do not require polyfill.
|
9
|
+
*
|
10
|
+
* IMPORTANT: If a helper require a polyfill, please isolate it in its own module
|
11
|
+
* so that the polyfill can be properly tree-shaken and does not burden
|
12
|
+
* the components that do not need that helper
|
13
|
+
*
|
14
|
+
* @module common/index
|
15
|
+
*/
|
16
|
+
|
7
17
|
/**
|
8
18
|
* TODO: Ideally this would be a NodeList.prototype.forEach polyfill
|
9
19
|
* This seems to fail in IE8, requires more investigation.
|
10
20
|
* See: https://github.com/imagitama/nodelist-foreach-polyfill
|
21
|
+
*
|
22
|
+
* @param {NodeListOf<Element>} nodes - NodeList from querySelectorAll()
|
23
|
+
* @param {nodeListIterator} callback - Callback function to run for each node
|
24
|
+
* @returns {undefined}
|
11
25
|
*/
|
12
26
|
function nodeListForEach (nodes, callback) {
|
13
27
|
if (window.NodeList.prototype.forEach) {
|
@@ -18,9 +32,13 @@ function nodeListForEach (nodes, callback) {
|
|
18
32
|
}
|
19
33
|
}
|
20
34
|
|
21
|
-
|
22
|
-
|
23
|
-
|
35
|
+
/**
|
36
|
+
* Used to generate a unique string, allows multiple instances of the component
|
37
|
+
* without them conflicting with each other.
|
38
|
+
* https://stackoverflow.com/a/8809472
|
39
|
+
*
|
40
|
+
* @returns {string} Unique ID
|
41
|
+
*/
|
24
42
|
function generateUniqueID () {
|
25
43
|
var d = new Date().getTime();
|
26
44
|
if (typeof window.performance !== 'undefined' && typeof window.performance.now === 'function') {
|
@@ -33,7 +51,124 @@ function generateUniqueID () {
|
|
33
51
|
})
|
34
52
|
}
|
35
53
|
|
54
|
+
/**
|
55
|
+
* Config flattening function
|
56
|
+
*
|
57
|
+
* Takes any number of objects, flattens them into namespaced key-value pairs,
|
58
|
+
* (e.g. {'i18n.showSection': 'Show section'}) and combines them together, with
|
59
|
+
* greatest priority on the LAST item passed in.
|
60
|
+
*
|
61
|
+
* @returns {object} A flattened object of key-value pairs.
|
62
|
+
*/
|
63
|
+
function mergeConfigs (/* configObject1, configObject2, ...configObjects */) {
|
64
|
+
/**
|
65
|
+
* Function to take nested objects and flatten them to a dot-separated keyed
|
66
|
+
* object. Doing this means we don't need to do any deep/recursive merging of
|
67
|
+
* each of our objects, nor transform our dataset from a flat list into a
|
68
|
+
* nested object.
|
69
|
+
*
|
70
|
+
* @param {object} configObject - Deeply nested object
|
71
|
+
* @returns {object} Flattened object with dot-separated keys
|
72
|
+
*/
|
73
|
+
var flattenObject = function (configObject) {
|
74
|
+
// Prepare an empty return object
|
75
|
+
var flattenedObject = {};
|
76
|
+
|
77
|
+
// Our flattening function, this is called recursively for each level of
|
78
|
+
// depth in the object. At each level we prepend the previous level names to
|
79
|
+
// the key using `prefix`.
|
80
|
+
var flattenLoop = function (obj, prefix) {
|
81
|
+
// Loop through keys...
|
82
|
+
for (var key in obj) {
|
83
|
+
// Check to see if this is a prototypical key/value,
|
84
|
+
// if it is, skip it.
|
85
|
+
if (!Object.prototype.hasOwnProperty.call(obj, key)) {
|
86
|
+
continue
|
87
|
+
}
|
88
|
+
var value = obj[key];
|
89
|
+
var prefixedKey = prefix ? prefix + '.' + key : key;
|
90
|
+
if (typeof value === 'object') {
|
91
|
+
// If the value is a nested object, recurse over that too
|
92
|
+
flattenLoop(value, prefixedKey);
|
93
|
+
} else {
|
94
|
+
// Otherwise, add this value to our return object
|
95
|
+
flattenedObject[prefixedKey] = value;
|
96
|
+
}
|
97
|
+
}
|
98
|
+
};
|
99
|
+
|
100
|
+
// Kick off the recursive loop
|
101
|
+
flattenLoop(configObject);
|
102
|
+
return flattenedObject
|
103
|
+
};
|
104
|
+
|
105
|
+
// Start with an empty object as our base
|
106
|
+
var formattedConfigObject = {};
|
107
|
+
|
108
|
+
// Loop through each of the remaining passed objects and push their keys
|
109
|
+
// one-by-one into configObject. Any duplicate keys will override the existing
|
110
|
+
// key with the new value.
|
111
|
+
for (var i = 0; i < arguments.length; i++) {
|
112
|
+
var obj = flattenObject(arguments[i]);
|
113
|
+
for (var key in obj) {
|
114
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
115
|
+
formattedConfigObject[key] = obj[key];
|
116
|
+
}
|
117
|
+
}
|
118
|
+
}
|
119
|
+
|
120
|
+
return formattedConfigObject
|
121
|
+
}
|
122
|
+
|
123
|
+
/**
|
124
|
+
* Extracts keys starting with a particular namespace from a flattened config
|
125
|
+
* object, removing the namespace in the process.
|
126
|
+
*
|
127
|
+
* @param {object} configObject - The object to extract key-value pairs from.
|
128
|
+
* @param {string} namespace - The namespace to filter keys with.
|
129
|
+
* @returns {object} Flattened object with dot-separated key namespace removed
|
130
|
+
*/
|
131
|
+
function extractConfigByNamespace (configObject, namespace) {
|
132
|
+
// Check we have what we need
|
133
|
+
if (!configObject || typeof configObject !== 'object') {
|
134
|
+
throw new Error('Provide a `configObject` of type "object".')
|
135
|
+
}
|
136
|
+
if (!namespace || typeof namespace !== 'string') {
|
137
|
+
throw new Error('Provide a `namespace` of type "string" to filter the `configObject` by.')
|
138
|
+
}
|
139
|
+
var newObject = {};
|
140
|
+
for (var key in configObject) {
|
141
|
+
// Split the key into parts, using . as our namespace separator
|
142
|
+
var keyParts = key.split('.');
|
143
|
+
// Check if the first namespace matches the configured namespace
|
144
|
+
if (Object.prototype.hasOwnProperty.call(configObject, key) && keyParts[0] === namespace) {
|
145
|
+
// Remove the first item (the namespace) from the parts array,
|
146
|
+
// but only if there is more than one part (we don't want blank keys!)
|
147
|
+
if (keyParts.length > 1) {
|
148
|
+
keyParts.shift();
|
149
|
+
}
|
150
|
+
// Join the remaining parts back together
|
151
|
+
var newKey = keyParts.join('.');
|
152
|
+
// Add them to our new object
|
153
|
+
newObject[newKey] = configObject[key];
|
154
|
+
}
|
155
|
+
}
|
156
|
+
return newObject
|
157
|
+
}
|
158
|
+
|
159
|
+
/**
|
160
|
+
* @callback nodeListIterator
|
161
|
+
* @param {Element} value - The current node being iterated on
|
162
|
+
* @param {number} index - The current index in the iteration
|
163
|
+
* @param {NodeListOf<Element>} nodes - NodeList from querySelectorAll()
|
164
|
+
* @returns {undefined}
|
165
|
+
*/
|
166
|
+
|
167
|
+
// Implementation of common function is gathered in the `common` folder
|
168
|
+
|
36
169
|
exports.nodeListForEach = nodeListForEach;
|
37
170
|
exports.generateUniqueID = generateUniqueID;
|
171
|
+
exports.mergeConfigs = mergeConfigs;
|
172
|
+
exports.extractConfigByNamespace = extractConfigByNamespace;
|
38
173
|
|
39
174
|
})));
|