govuk_publishing_components 35.3.5 → 35.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/component_guide/audit-filter.js +81 -0
  3. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-link-tracker.js +4 -3
  4. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-specialist-link-tracker.js +5 -1
  5. data/app/assets/javascripts/govuk_publishing_components/components/step-by-step-nav.js +1 -1
  6. data/app/assets/javascripts/govuk_publishing_components/vendor/lux/lux-reporter.js +245 -176
  7. data/app/assets/stylesheets/component_guide/application.scss +16 -0
  8. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-super-navigation-header.scss +0 -5
  9. data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +0 -12
  10. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_attachment.scss +0 -11
  11. data/app/models/govuk_publishing_components/audit_applications.rb +14 -0
  12. data/app/models/govuk_publishing_components/audit_comparer.rb +14 -0
  13. data/app/models/govuk_publishing_components/audit_components.rb +34 -32
  14. data/app/views/govuk_publishing_components/audit/_applications.html.erb +40 -32
  15. data/app/views/govuk_publishing_components/audit/_component_contents.html.erb +56 -12
  16. data/app/views/govuk_publishing_components/audit/_components.html.erb +9 -7
  17. data/app/views/govuk_publishing_components/audit/show.html.erb +5 -1
  18. data/app/views/govuk_publishing_components/components/_hint.html.erb +5 -1
  19. data/app/views/govuk_publishing_components/components/_label.html.erb +6 -6
  20. data/app/views/govuk_publishing_components/components/docs/hint.yml +1 -1
  21. data/lib/generators/govuk_publishing_components/component_generator.rb +2 -2
  22. data/lib/govuk_publishing_components/presenters/related_navigation_helper.rb +8 -8
  23. data/lib/govuk_publishing_components/version.rb +1 -1
  24. data/node_modules/axe-core/README.md +1 -3
  25. data/node_modules/axe-core/axe.js +4385 -1157
  26. data/node_modules/axe-core/axe.min.js +2 -2
  27. data/node_modules/axe-core/locales/_template.json +12 -0
  28. data/node_modules/axe-core/package.json +2 -1
  29. data/node_modules/axe-core/sri-history.json +4 -0
  30. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d392a9b81ae24c8b1a28866c2b9de1b8f1416e8242a214b41885d5ffd1bb583
4
- data.tar.gz: 5a8cc4ed7a4819aaf9113f24367a58699e519e9ccebf01c854193f3e010eaa42
3
+ metadata.gz: 6777fd07172bb10deb9d4087b7f6b94bcb82bd663cd2564c255ac045505d5fbf
4
+ data.tar.gz: 810d01deb18dbc67502d07d713235aa85f1c957a986fd3f2d1eb52c12aeade34
5
5
  SHA512:
6
- metadata.gz: 70b9c68201b266e1e19b48346994d5783b5246c5944de3fe59f5b703c634e8ad6db15722d9ef2781750380826b961f170ec9057c365e10f2c4986e528f5d7198
7
- data.tar.gz: c55cfea102e83bc8c2423a77d21ce92dc58c8e33e84b301923bd880254b4082b6bb255f1d22fc6d62077787209417d7acb4bd541947dfc45910322ca24a694f7
6
+ metadata.gz: 7e5c31dd4a6e7e0a0ab01ba19c522a78ea71a734fc194c233d7f3a54d3085cc73280511674d6105b7c398357273ba14434d7eaced2caa852c6f731a2a10dd364
7
+ data.tar.gz: 8d20c9fbf569404e1ce5fdda22509982efd598cdfaba95382f615715e7144f2eeb461b3cc9385eaaabe35c73e89cd95130589fe2c1d5a52e1f710fd0f64442f6
@@ -0,0 +1,81 @@
1
+ window.GOVUK = window.GOVUK || {}
2
+ window.GOVUK.Modules = window.GOVUK.Modules || {};
3
+
4
+ (function (Modules) {
5
+ function AuditFilter ($module) {
6
+ this.module = $module
7
+ this.data = this.module.querySelector('[data-audit-list]')
8
+ }
9
+
10
+ AuditFilter.prototype.init = function () {
11
+ if (this.module && this.data) {
12
+ this.getListOfApplications()
13
+ this.createElements()
14
+
15
+ this.filterComponentsFunction = this.filterComponents.bind(this)
16
+ this.select.addEventListener('change', this.filterComponentsFunction)
17
+ }
18
+ }
19
+
20
+ AuditFilter.prototype.getListOfApplications = function () {
21
+ var applications = []
22
+ var rows = this.data.querySelectorAll('[data-application]')
23
+ for (var i = 0; i < rows.length; i++) {
24
+ var application = rows[i].getAttribute('data-application')
25
+ if (application) {
26
+ if (!applications.includes(application)) {
27
+ applications.push(application)
28
+ }
29
+ }
30
+ }
31
+ this.applications = applications.sort()
32
+ }
33
+
34
+ AuditFilter.prototype.createElements = function () {
35
+ var selectWrapper = document.createElement('div')
36
+ selectWrapper.classList.add('govuk-form-group')
37
+
38
+ this.select = document.createElement('select')
39
+ this.select.classList.add('govuk-select')
40
+ this.select.setAttribute('id', 'sort-components')
41
+
42
+ this.select.append(this.createOption('All', 'all'))
43
+ for (var i = 0; i < this.applications.length; i++) {
44
+ this.select.append(this.createOption(this.applications[i], this.applications[i]))
45
+ }
46
+
47
+ var selectLabel = document.createElement('label')
48
+ selectLabel.classList.add('govuk-label')
49
+ selectLabel.setAttribute('for', 'sort-components')
50
+ selectLabel.textContent = 'Show'
51
+
52
+ selectWrapper.append(selectLabel)
53
+ selectWrapper.append(this.select)
54
+ this.module.prepend(selectWrapper)
55
+ }
56
+
57
+ AuditFilter.prototype.createOption = function (text, value) {
58
+ var option = document.createElement('option')
59
+ option.textContent = text
60
+ option.value = value
61
+ return option
62
+ }
63
+
64
+ AuditFilter.prototype.filterComponents = function () {
65
+ var selectedOption = this.select.value
66
+ var rows = this.data.querySelectorAll('[data-application]')
67
+
68
+ for (var i = 0; i < rows.length; i++) {
69
+ rows[i].removeAttribute('hidden')
70
+ }
71
+ if (selectedOption !== 'all') {
72
+ for (var j = 0; j < rows.length; j++) {
73
+ if (rows[j].getAttribute('data-application') !== selectedOption) {
74
+ rows[j].setAttribute('hidden', true)
75
+ }
76
+ }
77
+ }
78
+ }
79
+
80
+ Modules.AuditFilter = AuditFilter
81
+ })(window.GOVUK.Modules)
@@ -10,6 +10,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
10
10
  this.trackingTrigger = 'data-ga4-link' // elements with this attribute get tracked
11
11
  this.trackLinksOnly = this.module.hasAttribute('data-ga4-track-links-only')
12
12
  this.limitToElementClass = this.module.getAttribute('data-ga4-limit-to-element-class')
13
+ this.PIIRemover = new window.GOVUK.analyticsGa4.PIIRemover()
13
14
  }
14
15
 
15
16
  Ga4LinkTracker.prototype.init = function () {
@@ -61,7 +62,6 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
61
62
 
62
63
  Ga4LinkTracker.prototype.trackClick = function (event) {
63
64
  var element = event.target
64
- var PIIRemover = new window.GOVUK.analyticsGa4.PIIRemover()
65
65
 
66
66
  // don't track this link if it's already being tracked by the ecommerce tracker
67
67
  if (element.closest('[data-ga4-ecommerce-path]')) {
@@ -81,8 +81,9 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
81
81
 
82
82
  var text = data.text || event.target.textContent
83
83
  data.text = window.GOVUK.analyticsGa4.core.trackFunctions.removeLinesAndExtraSpaces(text)
84
+ data.text = this.PIIRemover.stripPIIWithOverride(data.text, true, true)
84
85
  var url = data.url || this.findLink(event.target).getAttribute('href')
85
- data.url = window.GOVUK.analyticsGa4.core.trackFunctions.removeCrossDomainParams(PIIRemover.stripPII(url))
86
+ data.url = window.GOVUK.analyticsGa4.core.trackFunctions.removeCrossDomainParams(this.PIIRemover.stripPIIWithOverride(url, true, true))
86
87
  data.link_domain = window.GOVUK.analyticsGa4.core.trackFunctions.populateLinkDomain(data.url)
87
88
  data.link_path_parts = window.GOVUK.analyticsGa4.core.trackFunctions.populateLinkPathParts(data.url)
88
89
  data.method = window.GOVUK.analyticsGa4.core.trackFunctions.getClickType(event)
@@ -90,7 +91,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
90
91
  data.index = this.setIndex(data.index, event.target)
91
92
 
92
93
  if (data.type === 'smart answer' && data.action === 'change response') {
93
- data.section = PIIRemover.stripPIIWithOverride(data.section, true, true)
94
+ data.section = this.PIIRemover.stripPIIWithOverride(data.section, true, true)
94
95
  }
95
96
 
96
97
  var schemas = new window.GOVUK.analyticsGa4.Schemas()
@@ -15,6 +15,7 @@ window.GOVUK.analyticsGa4.analyticsModules = window.GOVUK.analyticsGa4.analytics
15
15
  window.GOVUK.analyticsGa4.core.trackFunctions.appendDomainsWithoutWWW(this.dedicatedDownloadDomains)
16
16
  this.handleClick = this.handleClick.bind(this)
17
17
  this.handleMousedown = this.handleMousedown.bind(this)
18
+ this.PIIRemover = new window.GOVUK.analyticsGa4.PIIRemover()
18
19
 
19
20
  document.querySelector('body').addEventListener('click', this.handleClick)
20
21
  document.querySelector('body').addEventListener('contextmenu', this.handleClick)
@@ -50,10 +51,12 @@ window.GOVUK.analyticsGa4.analyticsModules = window.GOVUK.analyticsGa4.analytics
50
51
  return
51
52
  }
52
53
  var data = {}
54
+ var mailToLink = false
53
55
  if (window.GOVUK.analyticsGa4.core.trackFunctions.isMailToLink(href)) {
54
56
  data.event_name = 'navigation'
55
57
  data.type = 'email'
56
58
  data.external = 'true'
59
+ mailToLink = true
57
60
  } else if (this.isDownloadLink(href)) {
58
61
  data.event_name = 'file_download'
59
62
  data.type = this.isPreviewLink(href) ? 'preview' : 'generic download'
@@ -65,7 +68,7 @@ window.GOVUK.analyticsGa4.analyticsModules = window.GOVUK.analyticsGa4.analytics
65
68
  }
66
69
 
67
70
  if (Object.keys(data).length > 0) {
68
- data.url = href
71
+ data.url = mailToLink ? href : this.PIIRemover.stripPIIWithOverride(href, true, true)
69
72
  if (data.url) {
70
73
  data.url = window.GOVUK.analyticsGa4.core.trackFunctions.removeCrossDomainParams(data.url)
71
74
  data.link_domain = window.GOVUK.analyticsGa4.core.trackFunctions.populateLinkDomain(data.url)
@@ -73,6 +76,7 @@ window.GOVUK.analyticsGa4.analyticsModules = window.GOVUK.analyticsGa4.analytics
73
76
  }
74
77
 
75
78
  data.text = window.GOVUK.analyticsGa4.core.trackFunctions.removeLinesAndExtraSpaces(element.textContent)
79
+ data.text = mailToLink ? data.text : this.PIIRemover.stripPIIWithOverride(data.text, true, true)
76
80
  data.method = window.GOVUK.analyticsGa4.core.trackFunctions.getClickType(event)
77
81
 
78
82
  var schemas = new window.GOVUK.analyticsGa4.Schemas()
@@ -84,7 +84,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
84
84
 
85
85
  // if GA4 is enabled, set attributes on 'show all sections' for tracking using ga4-event-tracker
86
86
  if (this.$module.isGa4Enabled) {
87
- var showAllAttributesGa4 = { event_name: 'select_content', type: 'step by step', index: 0, index_section_count: this.$module.totalSteps }
87
+ var showAllAttributesGa4 = { event_name: 'select_content', type: 'step by step', index: { index_section: 0, index_section_count: this.$module.totalSteps } }
88
88
  this.$module.showOrHideAllButton.setAttribute('data-ga4-event', JSON.stringify(showAllAttributesGa4))
89
89
  }
90
90
  }