govuk_publishing_components 29.12.1 → 29.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/govuk_publishing_components/action-link-arrow--white.png +0 -0
  3. data/app/assets/images/govuk_publishing_components/action-link-arrow--white.svg +1 -0
  4. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/gtm-page-views.js +5 -3
  5. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/pii-remover.js +135 -0
  6. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4.js +2 -0
  7. data/app/assets/javascripts/govuk_publishing_components/components/accordion.js +10 -0
  8. data/app/assets/javascripts/govuk_publishing_components/components/feedback.js +19 -0
  9. data/app/assets/javascripts/govuk_publishing_components/components/table.js +52 -0
  10. data/app/assets/stylesheets/govuk_publishing_components/components/_action-link.scss +7 -0
  11. data/app/assets/stylesheets/govuk_publishing_components/components/_previous-and-next-navigation.scss +1 -92
  12. data/app/views/govuk_publishing_components/components/_action_link.html.erb +2 -0
  13. data/app/views/govuk_publishing_components/components/_previous_and_next_navigation.html.erb +33 -36
  14. data/app/views/govuk_publishing_components/components/_table.html.erb +60 -30
  15. data/app/views/govuk_publishing_components/components/docs/accordion.yml +2 -1
  16. data/app/views/govuk_publishing_components/components/docs/action_link.yml +8 -0
  17. data/app/views/govuk_publishing_components/components/docs/previous_and_next_navigation.yml +1 -1
  18. data/app/views/govuk_publishing_components/components/docs/table.yml +30 -0
  19. data/config/locales/ar.yml +6 -0
  20. data/config/locales/az.yml +6 -0
  21. data/config/locales/be.yml +6 -0
  22. data/config/locales/bg.yml +6 -0
  23. data/config/locales/bn.yml +6 -0
  24. data/config/locales/cs.yml +6 -0
  25. data/config/locales/cy.yml +6 -0
  26. data/config/locales/da.yml +6 -0
  27. data/config/locales/de.yml +6 -0
  28. data/config/locales/dr.yml +6 -0
  29. data/config/locales/el.yml +6 -0
  30. data/config/locales/en.yml +8 -2
  31. data/config/locales/es-419.yml +6 -0
  32. data/config/locales/es.yml +6 -0
  33. data/config/locales/et.yml +6 -0
  34. data/config/locales/fa.yml +6 -0
  35. data/config/locales/fi.yml +6 -0
  36. data/config/locales/fr.yml +6 -0
  37. data/config/locales/gd.yml +6 -0
  38. data/config/locales/gu.yml +6 -0
  39. data/config/locales/he.yml +6 -0
  40. data/config/locales/hi.yml +6 -0
  41. data/config/locales/hr.yml +6 -0
  42. data/config/locales/hu.yml +6 -0
  43. data/config/locales/hy.yml +6 -0
  44. data/config/locales/id.yml +6 -0
  45. data/config/locales/is.yml +6 -0
  46. data/config/locales/it.yml +6 -0
  47. data/config/locales/ja.yml +6 -0
  48. data/config/locales/ka.yml +6 -0
  49. data/config/locales/kk.yml +6 -0
  50. data/config/locales/ko.yml +6 -0
  51. data/config/locales/lt.yml +6 -0
  52. data/config/locales/lv.yml +6 -0
  53. data/config/locales/ms.yml +6 -0
  54. data/config/locales/mt.yml +6 -0
  55. data/config/locales/nl.yml +6 -0
  56. data/config/locales/no.yml +6 -0
  57. data/config/locales/pa-pk.yml +6 -0
  58. data/config/locales/pa.yml +6 -0
  59. data/config/locales/pl.yml +6 -0
  60. data/config/locales/ps.yml +6 -0
  61. data/config/locales/pt.yml +6 -0
  62. data/config/locales/ro.yml +6 -0
  63. data/config/locales/ru.yml +6 -0
  64. data/config/locales/si.yml +6 -0
  65. data/config/locales/sk.yml +6 -0
  66. data/config/locales/sl.yml +6 -0
  67. data/config/locales/so.yml +6 -0
  68. data/config/locales/sq.yml +6 -0
  69. data/config/locales/sr.yml +6 -0
  70. data/config/locales/sv.yml +6 -0
  71. data/config/locales/sw.yml +6 -0
  72. data/config/locales/ta.yml +6 -0
  73. data/config/locales/th.yml +6 -0
  74. data/config/locales/tk.yml +6 -0
  75. data/config/locales/tr.yml +6 -0
  76. data/config/locales/uk.yml +6 -0
  77. data/config/locales/ur.yml +6 -0
  78. data/config/locales/uz.yml +6 -0
  79. data/config/locales/vi.yml +6 -0
  80. data/config/locales/zh-hk.yml +6 -0
  81. data/config/locales/zh-tw.yml +6 -0
  82. data/config/locales/zh.yml +6 -0
  83. data/lib/govuk_publishing_components/app_helpers/table_helper.rb +3 -3
  84. data/lib/govuk_publishing_components/version.rb +1 -1
  85. data/node_modules/govuk-frontend/govuk/components/_all.scss +1 -0
  86. data/node_modules/govuk-frontend/govuk/components/accordion/_index.scss +1 -0
  87. data/node_modules/govuk-frontend/govuk/components/character-count/fixtures.json +2 -1
  88. data/node_modules/govuk-frontend/govuk/components/checkboxes/fixtures.json +102 -44
  89. data/node_modules/govuk-frontend/govuk/components/checkboxes/macro-options.json +7 -1
  90. data/node_modules/govuk-frontend/govuk/components/checkboxes/template.njk +3 -2
  91. data/node_modules/govuk-frontend/govuk/components/cookie-banner/fixtures.json +10 -10
  92. data/node_modules/govuk-frontend/govuk/components/fieldset/fixtures.json +92 -1
  93. data/node_modules/govuk-frontend/govuk/components/file-upload/fixtures.json +2 -1
  94. data/node_modules/govuk-frontend/govuk/components/header/_index.scss +3 -0
  95. data/node_modules/govuk-frontend/govuk/components/header/fixtures.json +14 -6
  96. data/node_modules/govuk-frontend/govuk/components/header/template.njk +9 -3
  97. data/node_modules/govuk-frontend/govuk/components/input/fixtures.json +2 -1
  98. data/node_modules/govuk-frontend/govuk/components/input/macro-options.json +1 -1
  99. data/node_modules/govuk-frontend/govuk/components/label/fixtures.json +76 -1
  100. data/node_modules/govuk-frontend/govuk/components/pagination/README.md +15 -0
  101. data/node_modules/govuk-frontend/govuk/components/pagination/_index.scss +244 -0
  102. data/node_modules/govuk-frontend/govuk/components/pagination/_pagination.scss +2 -0
  103. data/node_modules/govuk-frontend/govuk/components/pagination/fixtures.json +300 -0
  104. data/node_modules/govuk-frontend/govuk/components/pagination/macro-options.json +128 -0
  105. data/node_modules/govuk-frontend/govuk/components/pagination/macro.njk +3 -0
  106. data/node_modules/govuk-frontend/govuk/components/pagination/template.njk +62 -0
  107. data/node_modules/govuk-frontend/govuk/components/radios/fixtures.json +147 -43
  108. data/node_modules/govuk-frontend/govuk/components/radios/macro-options.json +7 -1
  109. data/node_modules/govuk-frontend/govuk/components/radios/template.njk +3 -2
  110. data/node_modules/govuk-frontend/govuk/components/select/fixtures.json +56 -2
  111. data/node_modules/govuk-frontend/govuk/components/select/macro-options.json +7 -1
  112. data/node_modules/govuk-frontend/govuk/components/select/template.njk +1 -1
  113. data/node_modules/govuk-frontend/govuk/components/textarea/fixtures.json +2 -1
  114. data/node_modules/govuk-frontend/govuk-esm/all.mjs +12 -12
  115. data/node_modules/govuk-frontend/govuk-esm/components/accordion/accordion.mjs +3 -3
  116. data/node_modules/govuk-frontend/govuk-esm/components/button/button.mjs +2 -2
  117. data/node_modules/govuk-frontend/govuk-esm/components/character-count/character-count.mjs +3 -3
  118. data/node_modules/govuk-frontend/govuk-esm/components/checkboxes/checkboxes.mjs +4 -4
  119. data/node_modules/govuk-frontend/govuk-esm/components/details/details.mjs +3 -3
  120. data/node_modules/govuk-frontend/govuk-esm/components/error-summary/error-summary.mjs +3 -3
  121. data/node_modules/govuk-frontend/govuk-esm/components/header/header.mjs +3 -3
  122. data/node_modules/govuk-frontend/govuk-esm/components/notification-banner/notification-banner.mjs +1 -1
  123. data/node_modules/govuk-frontend/govuk-esm/components/radios/radios.mjs +4 -4
  124. data/node_modules/govuk-frontend/govuk-esm/components/skip-link/skip-link.mjs +3 -3
  125. data/node_modules/govuk-frontend/govuk-esm/components/tabs/tabs.mjs +6 -6
  126. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/{DOMTokenList.js → DOMTokenList.mjs} +0 -0
  127. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/{Document.js → Document.mjs} +0 -0
  128. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/{classList.js → classList.mjs} +4 -4
  129. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/{closest.js → closest.mjs} +1 -1
  130. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/{matches.js → matches.mjs} +0 -0
  131. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/{nextElementSibling.js → nextElementSibling.mjs} +2 -2
  132. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/{previousElementSibling.js → previousElementSibling.mjs} +2 -2
  133. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/{Element.js → Element.mjs} +1 -1
  134. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/{Event.js → Event.mjs} +3 -3
  135. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Function/prototype/{bind.js → bind.mjs} +1 -1
  136. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Object/{defineProperty.js → defineProperty.mjs} +0 -0
  137. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/{Window.js → Window.mjs} +0 -0
  138. data/node_modules/govuk-frontend/package.json +8 -2
  139. metadata +25 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4334fdd441cbca8d9fac8dfa8fd49478fd01cd847eb29707872abf0dd8c523d1
4
- data.tar.gz: fe3f84de2e16d964fb9e7567ce52e8509258f833cc291fee28f54be4c4b8bd8c
3
+ metadata.gz: f53467f684078c59a2e499d0697b47183adacc1b30b9c19839ab8a8983715ff2
4
+ data.tar.gz: edddfebbcd07e825aa735e3bbe59fe000ebf5b2007272522ef94e92506cae352
5
5
  SHA512:
6
- metadata.gz: e6776dd162047045dbad8f70cda8d7eae8cc8e66321d607f614daf49c410d29b40c8cf718c6c04c27756bfa05382a58fe70b94633a49cbce7e4bbd5934006c7f
7
- data.tar.gz: d9411dfa23e431152880d95f455d42d6ac326cae14eddb0f905dcdef5a68e1b19b9affb3407e9c6052ed5f813131ec5cf68a8398d0899bcd150bb35bf0ad85aa
6
+ metadata.gz: 25eed8d95465c897c95ab654b97e2bfc15fbf956fd7535c361354da8326cc23795160413abdca24bb80757f4c6ea4c1033f3ca96474caf705ae92059896bf8c8
7
+ data.tar.gz: a7c01b6e8fa79cde09ef1a04c596a97a2dde847341c7e50fece0997cd78472b8a6f30741f228feb6c29b969c3374664f46d9262827027fc42ec4a67bb0c59bd4
@@ -0,0 +1 @@
1
+ <svg width="39" height="39" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M17.01 6.818l-2.828 2.828 7.853 7.854-22 .066L0 21.5h22.035l-7.853 7.854 2.828 2.828L29.69 19.5zM39 19.5C39 30.27 30.27 39 19.5 39 9.373 39 1.05 31.28.092 21.405A19.737 19.737 0 010 19.5C0 8.73 8.73 0 19.5 0S39 8.73 39 19.5z" fill="#fff"/></svg>
@@ -4,6 +4,8 @@
4
4
  var GOVUK = global.GOVUK || {}
5
5
 
6
6
  GOVUK.Gtm = {
7
+ PIIRemover: new GOVUK.analyticsGA4.PIIRemover(), // imported in analytics-ga4.js
8
+
7
9
  sendPageView: function () {
8
10
  if (window.dataLayer) {
9
11
  var data = {
@@ -48,15 +50,15 @@
48
50
  },
49
51
 
50
52
  getLocation: function () {
51
- return document.location.href
53
+ return this.PIIRemover.stripPII(document.location.href)
52
54
  },
53
55
 
54
56
  getReferrer: function () {
55
- return document.referrer
57
+ return this.PIIRemover.stripPIIWithOverride(document.referrer, true, true)
56
58
  },
57
59
 
58
60
  getTitle: function () {
59
- return document.title
61
+ return this.PIIRemover.stripPII(document.title)
60
62
  },
61
63
 
62
64
  // window.httpStatusCode is set in the source of the error page in static
@@ -0,0 +1,135 @@
1
+ ;(function (global) {
2
+ 'use strict'
3
+
4
+ var GOVUK = global.GOVUK || {}
5
+ var EMAIL_PATTERN = /[^\s=/?&#]+(?:@|%40)[^\s=/?&]+/g
6
+ var POSTCODE_PATTERN = /\b[A-PR-UWYZ][A-HJ-Z]?[0-9][0-9A-HJKMNPR-Y]?(?:[\s+]|%20)*[0-9](?!refund)[ABD-HJLNPQ-Z]{2,3}\b/gi
7
+ var DATE_PATTERN = /\d{4}(-?)\d{2}(-?)\d{2}/g
8
+ var ESCAPE_REGEX_PATTERN = /[|\\{}()[\]^$+*?.]/g
9
+
10
+ // specific URL parameters to be redacted from accounts URLs
11
+ var RESET_PASSWORD_TOKEN_PATTERN = /reset_password_token=[a-zA-Z0-9-]+/g
12
+ var UNLOCK_TOKEN_PATTERN = /unlock_token=[a-zA-Z0-9-]+/g
13
+ var STATE_PATTERN = /state=.[^&]+/g
14
+
15
+ function shouldStripDates () {
16
+ var metas = document.querySelectorAll('meta[name="govuk:static-analytics:strip-dates"]')
17
+ return metas.length > 0
18
+ }
19
+
20
+ function shouldStripPostcodes () {
21
+ var metas = document.querySelectorAll('meta[name="govuk:static-analytics:strip-postcodes"]')
22
+ return metas.length > 0
23
+ }
24
+
25
+ function queryStringParametersToStrip () {
26
+ var meta = document.querySelector('meta[name="govuk:static-analytics:strip-query-string-parameters"]')
27
+ var value = false
28
+ if (meta) {
29
+ value = meta.getAttribute('content')
30
+ }
31
+ var parameters = []
32
+
33
+ if (value) {
34
+ var split = value.split(',')
35
+ for (var i = 0; i < split.length; i++) {
36
+ parameters.push(split[i].trim())
37
+ }
38
+ }
39
+
40
+ return parameters
41
+ }
42
+
43
+ var PIIRemover = function () {
44
+ this.stripDatePII = shouldStripDates()
45
+ this.stripPostcodePII = shouldStripPostcodes()
46
+ this.queryStringParametersToStrip = queryStringParametersToStrip()
47
+ }
48
+
49
+ PIIRemover.prototype.PIISafe = function (value) {
50
+ this.value = value
51
+ }
52
+
53
+ PIIRemover.prototype.stripPII = function (value) {
54
+ if (typeof value === 'string') {
55
+ return this.stripPIIFromString(value)
56
+ } else if (Object.prototype.toString.call(value) === '[object Array]' || Object.prototype.toString.call(value) === '[object Arguments]') {
57
+ return this.stripPIIFromArray(value)
58
+ } else if (typeof value === 'object') {
59
+ return this.stripPIIFromObject(value)
60
+ } else {
61
+ return value
62
+ }
63
+ }
64
+
65
+ PIIRemover.prototype.stripPIIWithOverride = function (value, enableDateStripping, enablePostcodeStripping) {
66
+ var oldStripDatePII = this.stripDatePII
67
+ var oldPostcodePII = this.stripPostcodePII
68
+
69
+ this.stripDatePII = enableDateStripping
70
+ this.stripPostcodePII = enablePostcodeStripping
71
+
72
+ var strippedValue = this.stripPII(value)
73
+
74
+ this.stripDatePII = oldStripDatePII
75
+ this.stripPostcodePII = oldPostcodePII
76
+
77
+ return strippedValue
78
+ }
79
+
80
+ PIIRemover.prototype.stripPIIFromString = function (string) {
81
+ var stripped = string.replace(EMAIL_PATTERN, '[email]')
82
+ stripped = stripped.replace(RESET_PASSWORD_TOKEN_PATTERN, 'reset_password_token=[reset_password_token]')
83
+ stripped = stripped.replace(UNLOCK_TOKEN_PATTERN, 'unlock_token=[unlock_token]')
84
+ stripped = stripped.replace(STATE_PATTERN, 'state=[state]')
85
+ stripped = this.stripQueryStringParameters(stripped)
86
+
87
+ if (this.stripDatePII === true) {
88
+ stripped = stripped.replace(DATE_PATTERN, '[date]')
89
+ }
90
+ if (this.stripPostcodePII === true) {
91
+ stripped = stripped.replace(POSTCODE_PATTERN, '[postcode]')
92
+ }
93
+ return stripped
94
+ }
95
+
96
+ PIIRemover.prototype.stripPIIFromObject = function (object) {
97
+ if (object) {
98
+ if (object instanceof this.PIISafe) {
99
+ return object.value
100
+ } else {
101
+ for (var property in object) {
102
+ var value = object[property]
103
+
104
+ object[property] = this.stripPII(value)
105
+ }
106
+ return object
107
+ }
108
+ }
109
+ }
110
+
111
+ PIIRemover.prototype.stripPIIFromArray = function (array) {
112
+ for (var i = 0, l = array.length; i < l; i++) {
113
+ var elem = array[i]
114
+
115
+ array[i] = this.stripPII(elem)
116
+ }
117
+ return array
118
+ }
119
+
120
+ PIIRemover.prototype.stripQueryStringParameters = function (string) {
121
+ for (var i = 0; i < this.queryStringParametersToStrip.length; i++) {
122
+ var parameter = this.queryStringParametersToStrip[i]
123
+ var escaped = parameter.replace(ESCAPE_REGEX_PATTERN, '\\$&')
124
+ var regexp = new RegExp('((?:\\?|&)' + escaped + '=)(?:[^&#\\s]*)', 'g')
125
+ string = string.replace(regexp, '$1[' + parameter + ']')
126
+ }
127
+
128
+ return string
129
+ }
130
+
131
+ GOVUK.analyticsGA4 = GOVUK.analyticsGA4 || {}
132
+ GOVUK.analyticsGA4.PIIRemover = PIIRemover
133
+
134
+ global.GOVUK = GOVUK
135
+ })(window)
@@ -1,3 +1,5 @@
1
+ // The following modules are imported in a specific order
2
+ //= require ./analytics-ga4/pii-remover
1
3
  //= require ./analytics-ga4/gtm-page-views
2
4
  //= require ./analytics-ga4/gtm-click-tracking
3
5
 
@@ -124,6 +124,16 @@ window.GOVUK.Modules.GovukAccordion = window.GOVUKFrontend.Accordion;
124
124
  var label = expanded ? 'Show all sections' : 'Hide all sections'
125
125
  var action = expanded ? 'accordionOpened' : 'accordionClosed'
126
126
  var options = { transport: 'beacon', label: label }
127
+
128
+ var extraOptions = event.target && event.target.getAttribute('data-track-options')
129
+
130
+ // this uses the same logic as track-click.js handleClick
131
+ // means we can add a custom dimensions on click
132
+ if (extraOptions) {
133
+ extraOptions = JSON.parse(extraOptions)
134
+ for (var k in extraOptions) options[k] = extraOptions[k]
135
+ }
136
+
127
137
  if (window.GOVUK.analytics && window.GOVUK.analytics.trackEvent) {
128
138
  window.GOVUK.analytics.trackEvent('pageElementInteraction', action, options)
129
139
  }
@@ -19,6 +19,8 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
19
19
  this.promptSuccessMessage = this.$module.querySelector('.js-prompt-success')
20
20
  this.surveyWrapper = this.$module.querySelector('#survey-wrapper')
21
21
  this.jshiddenClass = 'js-hidden'
22
+ this.whatDoingInput = this.$module.querySelector('[name=what_doing]')
23
+ this.whatWrongInput = this.$module.querySelector('[name=what_wrong]')
22
24
  }
23
25
 
24
26
  Feedback.prototype.init = function () {
@@ -74,6 +76,13 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
74
76
  this.setHiddenValuesNotUsefulForm(gaClientId)
75
77
  }.bind(this))
76
78
 
79
+ this.somethingIsWrongButton.addEventListener('click', function (e) {
80
+ this.timerInterval = setInterval(function () {
81
+ this.timer = this.timer + 1
82
+ this.timerHoneyPot.setAttribute('value', this.timer)
83
+ }.bind(this), 1000)
84
+ }.bind(this))
85
+
77
86
  // much of the JS needed to support sending the form contents via this script is
78
87
  // unsupported by IE, even IE11. This check causes IE to not intercept form submits
79
88
  // and let them happen normally, which is handled already by the backend
@@ -94,6 +103,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
94
103
  this.revealInitialPrompt()
95
104
  this.setInitialAriaAttributes()
96
105
  this.activeForm.hidden = true
106
+ clearInterval(this.timerInterval)
97
107
  } else {
98
108
  this.showError(xhr)
99
109
  this.enableSubmitFormButton($form)
@@ -142,6 +152,14 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
142
152
  '<h2>Sorry, we’re unable to send your message as you haven’t given us any information.</h2>',
143
153
  ' <p>Please tell us what you were doing or what went wrong</p>'
144
154
  ].join('')
155
+
156
+ this.timer = 0
157
+
158
+ this.timerHoneyPot = document.createElement('input')
159
+ this.timerHoneyPot.setAttribute('type', 'hidden')
160
+ this.timerHoneyPot.setAttribute('name', 'timer')
161
+ this.timerHoneyPot.setAttribute('value', this.timer)
162
+ this.somethingIsWrongForm.appendChild(this.timerHoneyPot)
145
163
  }
146
164
 
147
165
  Feedback.prototype.setHiddenValuesNotUsefulForm = function (gaClientId) {
@@ -185,6 +203,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
185
203
  .focus()
186
204
  } else {
187
205
  this.activeForm = false
206
+ clearInterval(this.timerInterval)
188
207
  }
189
208
  }
190
209
 
@@ -0,0 +1,52 @@
1
+ window.GOVUK = window.GOVUK || {}
2
+ window.GOVUK.Modules = window.GOVUK.Modules || {};
3
+
4
+ (function (Modules) {
5
+ function Table ($module) {
6
+ this.$module = $module
7
+ this.searchInput = $module.querySelector('input[name="filter"]')
8
+ this.tableRows = $module.querySelectorAll('.js-govuk-table__row')
9
+ this.filter = $module.querySelector('.js-gem-c-table__filter')
10
+ this.filterCount = this.filter.querySelector('.js-filter-count')
11
+ this.message = $module.querySelector('.js-gem-c-table__message')
12
+ this.hiddenClass = 'govuk-!-display-none'
13
+ this.filterCountText = this.filterCount.getAttribute('data-count-text')
14
+ this.tableRowsContent = []
15
+
16
+ for (var i = 0; i < this.tableRows.length; i++) {
17
+ this.tableRowsContent.push(this.tableRows[i].textContent.toUpperCase())
18
+ }
19
+ }
20
+
21
+ Table.prototype.init = function () {
22
+ this.$module.updateRows = this.updateRows.bind(this)
23
+ this.filter.classList.remove(this.hiddenClass)
24
+ this.searchInput.addEventListener('input', this.$module.updateRows)
25
+ }
26
+
27
+ // Reads value of input and filters content
28
+ Table.prototype.updateRows = function () {
29
+ var value = this.searchInput.value
30
+ var hiddenRows = 0
31
+ var length = this.tableRows.length
32
+
33
+ for (var i = 0; i < length; i++) {
34
+ if (this.tableRowsContent[i].includes(value.toUpperCase())) {
35
+ this.tableRows[i].classList.remove(this.hiddenClass)
36
+ } else {
37
+ this.tableRows[i].classList.add(this.hiddenClass)
38
+ hiddenRows++
39
+ }
40
+ }
41
+
42
+ this.filterCount.textContent = (length - hiddenRows) + ' ' + this.filterCountText
43
+
44
+ if (length === hiddenRows) {
45
+ this.message.classList.remove(this.hiddenClass)
46
+ } else {
47
+ this.message.classList.add(this.hiddenClass)
48
+ }
49
+ }
50
+
51
+ Modules.Table = Table
52
+ })(window.GOVUK.Modules)
@@ -92,6 +92,13 @@
92
92
  }
93
93
  }
94
94
 
95
+ .gem-c-action-link--white-arrow {
96
+ &:before {
97
+ background-image: image-url("govuk_publishing_components/action-link-arrow--white.png");
98
+ background-image: image-url("govuk_publishing_components/action-link-arrow--white.svg"), linear-gradient(transparent, transparent);
99
+ }
100
+ }
101
+
95
102
  .gem-c-action-link--blue-arrow {
96
103
  &:before {
97
104
  width: 36px;
@@ -1,92 +1 @@
1
- .gem-c-pagination {
2
- display: block;
3
- margin: govuk-spacing(8) 0;
4
- }
5
-
6
- .gem-c-pagination__list {
7
- margin: 0;
8
- padding: 0;
9
- }
10
-
11
- .gem-c-pagination__item {
12
- @include govuk-font($size: 19);
13
- list-style: none;
14
-
15
- &:first-child {
16
- margin-bottom: govuk-spacing(4);
17
- }
18
- }
19
-
20
- .gem-c-pagination__link {
21
- display: block;
22
- text-decoration: none;
23
- padding-bottom: govuk-spacing(4);
24
-
25
- &:hover,
26
- &:active,
27
- &:visited {
28
- color: $govuk-link-colour;
29
- }
30
-
31
- &:hover,
32
- &:active {
33
- background-color: govuk-colour("light-grey", $legacy: "grey-4");
34
-
35
- // Add govuk-link hover decoration to title if no label present
36
- .gem-c-pagination__link-text--decorated {
37
- @include govuk-link-decoration;
38
- }
39
-
40
- .gem-c-pagination__link-label,
41
- .gem-c-pagination__link-text--decorated {
42
- @include govuk-link-hover-decoration;
43
- }
44
- }
45
-
46
- &:focus {
47
- @include govuk-focused-text;
48
-
49
- .gem-c-pagination__link-title {
50
- border-top-color: transparent;
51
- }
52
-
53
- .gem-c-pagination__link-icon {
54
- fill: $govuk-text-colour;
55
- }
56
- }
57
- }
58
-
59
- .gem-c-pagination__link-title {
60
- display: block;
61
- border-top: 1px solid $govuk-border-colour;
62
- padding-top: govuk-spacing(3);
63
- }
64
-
65
- .gem-c-pagination__link-divider {
66
- @include govuk-visually-hidden;
67
- }
68
-
69
- .gem-c-pagination__link-text {
70
- @include govuk-font(19, $weight: bold);
71
- margin-left: govuk-spacing(2);
72
- }
73
-
74
- .gem-c-pagination__link-icon {
75
- @include govuk-font($size: 24, $line-height: (33.75 / 27));
76
- display: inline-block;
77
- margin-bottom: 1px;
78
- height: .482em;
79
- width: .63em;
80
- fill: govuk-colour("dark-grey", $legacy: "grey-1");
81
- }
82
-
83
- .gem-c-pagination__link-label {
84
- display: inline-block;
85
- margin-top: .1em;
86
- margin-left: govuk-spacing(5);
87
- @include govuk-link-decoration;
88
-
89
- @include govuk-media-query($from: tablet) {
90
- margin-left: govuk-spacing(6);
91
- }
92
- }
1
+ @import "govuk/components/pagination/pagination";
@@ -10,6 +10,7 @@
10
10
  mobile_subtext ||= false
11
11
  light_text ||= false
12
12
  blue_arrow ||= false
13
+ white_arrow ||= false
13
14
  simple ||= false
14
15
  simple_light ||= false
15
16
  dark_icon ||= false
@@ -29,6 +30,7 @@
29
30
  css_classes << "gem-c-action-link--nhs" if nhs_icon
30
31
  css_classes << "gem-c-action-link--brexit" if brexit_icon
31
32
  css_classes << "gem-c-action-link--blue-arrow" if blue_arrow
33
+ css_classes << "gem-c-action-link--white-arrow" if white_arrow
32
34
  css_classes << "gem-c-action-link--simple" if simple
33
35
  css_classes << "gem-c-action-link--simple-light" if simple_light
34
36
  css_classes << "gem-c-action-link--with-subtext" if subtext
@@ -1,18 +1,18 @@
1
1
  <% if local_assigns.include?(:next_page) || local_assigns.include?(:previous_page) %>
2
- <nav
3
- class="gem-c-pagination"
4
- role="navigation"
5
- aria-label="<%= t("components.previous_and_next_navigation.pagination") %>"
6
- >
7
- <ul class="gem-c-pagination__list" data-module="gem-track-click">
2
+ <nav
3
+ class="govuk-pagination govuk-pagination--block"
4
+ role="navigation"
5
+ aria-label="<%= t("components.previous_and_next_navigation.pagination") %>"
6
+ >
8
7
  <% if local_assigns.include?(:previous_page) %>
9
8
  <%
10
- link_text_classes = %w[gem-c-pagination__link-text]
11
- link_text_classes << "gem-c-pagination__link-text--decorated" unless previous_page[:label].present?
9
+ title = previous_page[:title] || t("components.previous_and_next_navigation.previous")
10
+ link_text_classes = %w[govuk-pagination__link-title]
11
+ link_text_classes << "govuk-pagination__link-title--decorated" unless previous_page[:label].present?
12
12
  %>
13
- <li class="gem-c-pagination__item gem-c-pagination__item--previous">
14
- <a href="<%= previous_page[:url] %>"
15
- class="govuk-link gem-c-pagination__link"
13
+ <div class="govuk-pagination__prev">
14
+ <a class="govuk-link govuk-pagination__link"
15
+ href="<%= previous_page[:url] %>"
16
16
  rel="prev"
17
17
  data-track-category="contentsClicked"
18
18
  data-track-action="previous"
@@ -20,27 +20,27 @@
20
20
  data-track-dimension="previous"
21
21
  data-track-dimension-index="29"
22
22
  >
23
- <span class="gem-c-pagination__link-title">
24
- <svg class="gem-c-pagination__link-icon" xmlns="http://www.w3.org/2000/svg" height="13" width="17" viewBox="0 0 17 13">
25
- <path d="m6.5938-0.0078125-6.7266 6.7266 6.7441 6.4062 1.377-1.449-4.1856-3.9768h12.896v-2h-12.984l4.2931-4.293-1.414-1.414z"/>
26
- </svg>
27
- <%= tag.span(previous_page[:title], class: link_text_classes) %>
28
- </span>
23
+ <svg class="govuk-pagination__icon govuk-pagination__icon--prev" xmlns="http://www.w3.org/2000/svg" height="13" width="15" aria-hidden="true" focusable="false" viewBox="0 0 15 13">
24
+ <path d="m6.5938-0.0078125-6.7266 6.7266 6.7441 6.4062 1.377-1.449-4.1856-3.9768h12.896v-2h-12.984l4.2931-4.293-1.414-1.414z"></path>
25
+ </svg>
26
+ <%= tag.span(title, class: link_text_classes) %>
29
27
  <% if previous_page[:label].present? %>
30
- <span class="gem-c-pagination__link-divider visually-hidden">:</span>
31
- <span class="gem-c-pagination__link-label"><%= previous_page[:label] %></span>
28
+ <span class="govuk-visually-hidden">:</span>
29
+ <span class="govuk-pagination__link-label"><%= previous_page[:label] %></span>
32
30
  <% end %>
33
31
  </a>
34
- </li>
32
+ </div>
35
33
  <% end %>
34
+
36
35
  <% if local_assigns.include?(:next_page) %>
37
36
  <%
38
- link_text_classes = %w[gem-c-pagination__link-text]
39
- link_text_classes << "gem-c-pagination__link-text--decorated" unless next_page[:label].present?
37
+ title = next_page[:title] || t("components.previous_and_next_navigation.next")
38
+ link_text_classes = %w[govuk-pagination__link-title]
39
+ link_text_classes << "govuk-pagination__link-title--decorated" unless next_page[:label].present?
40
40
  %>
41
- <li class="gem-c-pagination__item gem-c-pagination__item--next">
42
- <a href="<%= next_page[:url] %>"
43
- class="govuk-link gem-c-pagination__link"
41
+ <div class="govuk-pagination__next">
42
+ <a class="govuk-link govuk-pagination__link"
43
+ href="<%= next_page[:url] %>"
44
44
  rel="next"
45
45
  data-track-category="contentsClicked"
46
46
  data-track-action="next"
@@ -48,19 +48,16 @@
48
48
  data-track-dimension="next"
49
49
  data-track-dimension-index="29"
50
50
  >
51
- <span class="gem-c-pagination__link-title">
52
- <svg class="gem-c-pagination__link-icon" xmlns="http://www.w3.org/2000/svg" height="13" width="17" viewBox="0 0 17 13">
53
- <path d="m10.107-0.0078125-1.4136 1.414 4.2926 4.293h-12.986v2h12.896l-4.1855 3.9766 1.377 1.4492 6.7441-6.4062-6.7246-6.7266z"/>
54
- </svg>
55
- <%= tag.span(next_page[:title], class: link_text_classes) %>
56
- </span>
51
+ <svg class="govuk-pagination__icon govuk-pagination__icon--next" xmlns="http://www.w3.org/2000/svg" height="13" width="15" aria-hidden="true" focusable="false" viewBox="0 0 15 13">
52
+ <path d="m8.107-0.0078125-1.4136 1.414 4.2926 4.293h-12.986v2h12.896l-4.1855 3.9766 1.377 1.4492 6.7441-6.4062-6.7246-6.7266z"></path>
53
+ </svg>
54
+ <%= tag.span(title, class: link_text_classes) %>
57
55
  <% if next_page[:label].present? %>
58
- <span class="gem-c-pagination__link-divider visually-hidden">:</span>
59
- <span class="gem-c-pagination__link-label"><%= next_page[:label] %></span>
56
+ <span class="govuk-visually-hidden">:</span>
57
+ <span class="govuk-pagination__link-label"><%= next_page[:label] %></span>
60
58
  <% end %>
61
59
  </a>
62
- </li>
60
+ </div>
63
61
  <% end %>
64
- </ul>
65
- </nav>
62
+ </nav>
66
63
  <% end %>
@@ -2,46 +2,76 @@
2
2
  caption ||= nil
3
3
  head ||= []
4
4
  rows ||= []
5
- first_cell_is_header ||=false
5
+ first_cell_is_header ||= false
6
6
  caption_classes ||= nil
7
- sortable ||=false
7
+ sortable ||= false
8
+ filterable ||= false
9
+ label ||= t("components.table.filter_label")
10
+
11
+ table_id = "table-id-#{SecureRandom.hex(4)}"
12
+ filter_count_id = "filter-count-id-#{SecureRandom.hex(4)}"
8
13
  %>
9
14
 
10
- <%= GovukPublishingComponents::AppHelpers::TableHelper.helper(self, caption, {
11
- sortable: sortable,
12
- caption_classes: caption_classes
13
- }) do |t| %>
14
-
15
- <% if head.any? %>
16
- <%= t.head do %>
17
- <% head.each_with_index do |item, cellindex| %>
18
- <%= t.header item[:text], {
19
- format: item[:format],
20
- href: item[:href],
21
- data_attributes: item[:data_attributes],
22
- sort_direction: item[:sort_direction]
23
- } %>
15
+ <% @table = capture do %>
16
+ <%= GovukPublishingComponents::AppHelpers::TableHelper.helper(self, caption, table_id, {
17
+ sortable: sortable,
18
+ filterable: filterable,
19
+ caption_classes: caption_classes
20
+ }) do |t| %>
21
+
22
+ <% if head.any? %>
23
+ <%= t.head do %>
24
+ <% head.each_with_index do |item, cellindex| %>
25
+ <%= t.header item[:text], {
26
+ format: item[:format],
27
+ href: item[:href],
28
+ data_attributes: item[:data_attributes],
29
+ sort_direction: item[:sort_direction]
30
+ } %>
31
+ <% end %>
24
32
  <% end %>
25
33
  <% end %>
26
- <% end %>
27
34
 
28
- <%= t.body do %>
29
- <% rows.each_with_index do |row, rowindex| %>
30
- <%= t.row do %>
31
- <% row.each_with_index do |cell, cellindex| %>
32
- <% if cellindex == 0 && first_cell_is_header %>
33
- <%= t.header cell[:text], {
34
- scope: "row",
35
- format: cell[:format]
36
- } %>
37
- <% else %>
38
- <%= t.cell cell[:text], {
39
- format: cell[:format]
40
- } %>
35
+ <%= t.body do %>
36
+ <% rows.each_with_index do |row, rowindex| %>
37
+ <%= t.row do %>
38
+ <% row.each_with_index do |cell, cellindex| %>
39
+ <% if cellindex == 0 && first_cell_is_header %>
40
+ <%= t.header cell[:text], {
41
+ scope: "row",
42
+ format: cell[:format]
43
+ } %>
44
+ <% else %>
45
+ <%= t.cell cell[:text], {
46
+ format: cell[:format]
47
+ } %>
48
+ <% end %>
41
49
  <% end %>
42
50
  <% end %>
43
51
  <% end %>
44
52
  <% end %>
45
53
  <% end %>
54
+ <% end %>
55
+
56
+ <% if filterable %>
57
+ <div data-module="table">
58
+ <div class="js-gem-c-table__filter govuk-!-display-none">
59
+ <%= render "govuk_publishing_components/components/input", {
60
+ label: {
61
+ text: label
62
+ },
63
+ name: "filter",
64
+ controls: table_id,
65
+ aria_described_by: filter_count_id,
66
+ } %>
67
+
68
+ <p id="<%= filter_count_id %>" aria-live="polite" class="js-filter-count govuk-visually-hidden" data-count-text="<%= t("components.table.filter_count") %>"></p>
69
+ </div>
70
+
71
+ <%= @table %>
46
72
 
73
+ <p class="govuk-body govuk-!-display-none js-gem-c-table__message"><%= t("components.table.filter_message") %></p>
74
+ </div>
75
+ <% else %>
76
+ <%= @table %>
47
77
  <% end %>
@@ -189,7 +189,7 @@ examples:
189
189
 
190
190
  Each item can also have a `data_attributes` hash. These `data_attributes` are placed on the `button` that triggers the opening and closing - useful for differentiating between each section of the accordion.
191
191
 
192
- Data attributes can also be added to the 'Show/hide all' link using the `data_attributes_show_all` option, primarily where custom tracking is required. These attributes are read from the accordion markup and then added to the link by JavaScript (which is how the link is created).
192
+ Data attributes can also be added to the 'Show/hide all' link using the `data_attributes_show_all` option, primarily where custom tracking is required. These attributes are read from the accordion markup and then added to the link by JavaScript (which is how the link is created). If `track_options` within `data_attributes_show_all` is set, then it is possible to pass a custom dimension when 'Show/Hide all' is clicked.
193
193
  data:
194
194
  data_attributes:
195
195
  gtm: gtm-accordion
@@ -197,6 +197,7 @@ examples:
197
197
  data_attributes_show_all:
198
198
  gtm-event-name: example
199
199
  gtm-attributes: "{ 'ui': { 'type': 'type value', 'section': 'section value' } }"
200
+ tracking-options: "{ 'dimension114': 1 }"
200
201
  items:
201
202
  - heading:
202
203
  text: Writing well for the web