govuk_publishing_components 35.3.5 → 35.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) 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-form-tracker.js +1 -1
  4. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-link-tracker.js +7 -3
  5. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-specialist-link-tracker.js +8 -1
  6. data/app/assets/javascripts/govuk_publishing_components/components/step-by-step-nav.js +1 -1
  7. data/app/assets/javascripts/govuk_publishing_components/vendor/lux/lux-reporter.js +245 -176
  8. data/app/assets/stylesheets/component_guide/application.scss +16 -0
  9. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-super-navigation-header.scss +0 -5
  10. data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +0 -12
  11. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_attachment.scss +0 -11
  12. data/app/models/govuk_publishing_components/audit_applications.rb +14 -0
  13. data/app/models/govuk_publishing_components/audit_comparer.rb +14 -0
  14. data/app/models/govuk_publishing_components/audit_components.rb +34 -32
  15. data/app/views/govuk_publishing_components/audit/_applications.html.erb +40 -32
  16. data/app/views/govuk_publishing_components/audit/_component_contents.html.erb +56 -12
  17. data/app/views/govuk_publishing_components/audit/_components.html.erb +9 -7
  18. data/app/views/govuk_publishing_components/audit/show.html.erb +5 -1
  19. data/app/views/govuk_publishing_components/components/_hint.html.erb +5 -1
  20. data/app/views/govuk_publishing_components/components/_label.html.erb +6 -6
  21. data/app/views/govuk_publishing_components/components/_share_links.html.erb +2 -2
  22. data/app/views/govuk_publishing_components/components/_step_by_step_nav.html.erb +2 -1
  23. data/app/views/govuk_publishing_components/components/docs/hint.yml +1 -1
  24. data/lib/generators/govuk_publishing_components/component_generator.rb +2 -2
  25. data/lib/govuk_publishing_components/presenters/related_navigation_helper.rb +8 -8
  26. data/lib/govuk_publishing_components/version.rb +1 -1
  27. data/node_modules/axe-core/README.md +1 -3
  28. data/node_modules/axe-core/axe.js +4385 -1157
  29. data/node_modules/axe-core/axe.min.js +2 -2
  30. data/node_modules/axe-core/locales/_template.json +12 -0
  31. data/node_modules/axe-core/package.json +2 -1
  32. data/node_modules/axe-core/sri-history.json +4 -0
  33. 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: 83d143fc56ad285e250659a050cb73b185176316d43f40293199ea6cc673c120
4
+ data.tar.gz: b8b9d0b29c550c0abc91be533b38cf3c9b62bd42039c1d31d66ec06883ba9be1
5
5
  SHA512:
6
- metadata.gz: 70b9c68201b266e1e19b48346994d5783b5246c5944de3fe59f5b703c634e8ad6db15722d9ef2781750380826b961f170ec9057c365e10f2c4986e528f5d7198
7
- data.tar.gz: c55cfea102e83bc8c2423a77d21ce92dc58c8e33e84b301923bd880254b4082b6bb255f1d22fc6d62077787209417d7acb4bd541947dfc45910322ca24a694f7
6
+ metadata.gz: 0ebadf89e85215996356032d2f1f1d8e9faaec6287048c61a729da84a28e29dee5f509f6ece7db95341f0ca8e19815172d6d4898a6a624329525c5b36713fefc
7
+ data.tar.gz: 1a13f99b6d61d29e6e1c7c62d89dce9b8b2ee7dbfd5f026e6f0d80502ccd8d90180c990d6f86525c97ccb0816083ea22facfdf84e582e0f8c0765da5e153d732
@@ -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)
@@ -43,7 +43,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
43
43
 
44
44
  var formInputs = this.getFormInputs()
45
45
  var formData = this.getInputValues(formInputs)
46
- data.text = this.combineGivenAnswers(formData) || 'No answer given'
46
+ data.text = data.text || (this.combineGivenAnswers(formData) || 'No answer given')
47
47
 
48
48
  var schemas = new window.GOVUK.analyticsGa4.Schemas()
49
49
  var schema = schemas.mergeProperties(data, 'event_data')
@@ -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,12 @@ 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)
85
+ if (!data.text && (element.querySelector('img') || element.querySelector('svg'))) {
86
+ data.text = 'image'
87
+ }
84
88
  var url = data.url || this.findLink(event.target).getAttribute('href')
85
- data.url = window.GOVUK.analyticsGa4.core.trackFunctions.removeCrossDomainParams(PIIRemover.stripPII(url))
89
+ data.url = window.GOVUK.analyticsGa4.core.trackFunctions.removeCrossDomainParams(this.PIIRemover.stripPIIWithOverride(url, true, true))
86
90
  data.link_domain = window.GOVUK.analyticsGa4.core.trackFunctions.populateLinkDomain(data.url)
87
91
  data.link_path_parts = window.GOVUK.analyticsGa4.core.trackFunctions.populateLinkPathParts(data.url)
88
92
  data.method = window.GOVUK.analyticsGa4.core.trackFunctions.getClickType(event)
@@ -90,7 +94,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
90
94
  data.index = this.setIndex(data.index, event.target)
91
95
 
92
96
  if (data.type === 'smart answer' && data.action === 'change response') {
93
- data.section = PIIRemover.stripPIIWithOverride(data.section, true, true)
97
+ data.section = this.PIIRemover.stripPIIWithOverride(data.section, true, true)
94
98
  }
95
99
 
96
100
  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,10 @@ 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)
80
+ if (!data.text && (element.querySelector('img') || element.querySelector('svg'))) {
81
+ data.text = 'image'
82
+ }
76
83
  data.method = window.GOVUK.analyticsGa4.core.trackFunctions.getClickType(event)
77
84
 
78
85
  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
  }