govuk_publishing_components 36.0.2 → 36.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9964e934f4ce2788b32ae7209b5838a04a44cadbb302c4cf45bd723fd6e9cf38
4
- data.tar.gz: 9aa95ca3c117ebef6c201f29990e1b12961b53c435c7904936c44e7b22b53cd7
3
+ metadata.gz: 2a1b48c8e40b95414bf80c8315e867f24d29686de682e051b3f85cd7ab0a88b2
4
+ data.tar.gz: dcfa431c373237617dbed7ef353377047874cb3ec7778126db4d5000393fdfb6
5
5
  SHA512:
6
- metadata.gz: 1094205965013e02ab4655bd58fa2e6ac6cfad898ba94275ab93fc3bec5c738fff2fe575e34ac2429e66c912fc54c25afdcf3f878d6090e20ce180bc805e4aa5
7
- data.tar.gz: 52f249d3d4edbf8f16d696154c5faf1e751ea386eae9ede15bde6ad248bd705eda6c91b98dfaf4f221c03908b5dd57e9b8ce84eba0c9e85d2078aee907dfe9a8
6
+ metadata.gz: b35385b4123f674488ea177d7e2761d6f0c8847af76a3e00d932ee0c8bdbb3536c788fd77db99a31a736982204f4140ba1f2667ca957cc73603f6f132846dfc5
7
+ data.tar.gz: f941bbaebaca0c3ed5a91955a1befe12637861b1bde2a65a6c0ef8f65072f27c8d85755452960df8d8913041fef037081faf15fc07780b0eb3c6c644032e3d74
@@ -275,6 +275,19 @@ window.GOVUK.analyticsGa4 = window.GOVUK.analyticsGa4 || {};
275
275
  return url
276
276
  }
277
277
  return this.getPathname() + url
278
+ },
279
+
280
+ standardiseSearchTerm: function (searchTerm) {
281
+ if (!searchTerm) {
282
+ return undefined // Prevents conversion of undefined to a string by this function.
283
+ }
284
+
285
+ var PIIRemover = new window.GOVUK.analyticsGa4.PIIRemover()
286
+ searchTerm = searchTerm.replace(/\++|(%2B)+/gm, ' ') // Turn + characters or unicode + characters (%2B) into a space.
287
+ searchTerm = window.GOVUK.analyticsGa4.core.trackFunctions.removeLinesAndExtraSpaces(searchTerm)
288
+ searchTerm = PIIRemover.stripPIIWithOverride(searchTerm, true, true)
289
+ searchTerm = searchTerm.toLowerCase()
290
+ return searchTerm
278
291
  }
279
292
  },
280
293
 
@@ -313,12 +326,11 @@ window.GOVUK.analyticsGa4 = window.GOVUK.analyticsGa4 || {};
313
326
  var isSearchResult = element.getAttribute('data-ga4-search-query')
314
327
 
315
328
  var ecommerceSchema = new window.GOVUK.analyticsGa4.Schemas().ecommerceSchema()
316
- var PIIRemover = new window.GOVUK.analyticsGa4.PIIRemover()
317
329
  var DEFAULT_LIST_TITLE = 'Smart answer results'
318
330
 
319
331
  if (isSearchResult) {
320
332
  // Limiting to 100 characters to avoid noise from extra long search queries and to stop the size of the payload going over 8k limit.
321
- var searchQuery = PIIRemover.stripPII(element.getAttribute('data-ga4-search-query')).substring(0, 100).toLowerCase()
333
+ var searchQuery = window.GOVUK.analyticsGa4.core.trackFunctions.standardiseSearchTerm(element.getAttribute('data-ga4-search-query')).substring(0, 100)
322
334
  var variant = element.getAttribute('data-ga4-ecommerce-variant')
323
335
  DEFAULT_LIST_TITLE = 'Site search results'
324
336
  }
@@ -47,8 +47,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
47
47
  data.text = data.text || this.combineGivenAnswers(formData) || this.useFallbackValue
48
48
 
49
49
  if (data.action === 'search' && data.text) {
50
- data.text = data.text.toLowerCase()
51
- data.text = window.GOVUK.analyticsGa4.core.trackFunctions.removeLinesAndExtraSpaces(data.text)
50
+ data.text = window.GOVUK.analyticsGa4.core.trackFunctions.standardiseSearchTerm(data.text)
52
51
  }
53
52
  window.GOVUK.analyticsGa4.core.applySchemaAndSendData(data, 'event_data')
54
53
  }
@@ -85,7 +85,13 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
85
85
  if (!data.text && (element.querySelector('img') || element.querySelector('svg') || element.tagName === 'IMG' || element.closest('svg'))) {
86
86
  data.text = 'image'
87
87
  }
88
- var url = data.url || this.findLink(event.target).getAttribute('href')
88
+ try {
89
+ var url = data.url || this.findLink(event.target).getAttribute('href')
90
+ } catch (e) {
91
+ // no href found, so abort
92
+ return
93
+ }
94
+
89
95
  data.url = trackFunctions.removeCrossDomainParams(url)
90
96
  data.url = trackFunctions.applyRedactionIfRequired(this.PIIRemover, element, data.url)
91
97
  data.url = trackFunctions.appendPathToAnchorLinks(data.url)
@@ -86,9 +86,8 @@ window.GOVUK.analyticsGa4.analyticsModules = window.GOVUK.analyticsGa4.analytics
86
86
  }
87
87
 
88
88
  searchTerm = searchTerm[0].replace('keywords=', '')
89
- searchTerm = searchTerm.replace(/\++/g, ' ')
90
- searchTerm = window.GOVUK.analyticsGa4.core.trackFunctions.removeLinesAndExtraSpaces(searchTerm)
91
- searchTerm = this.PIIRemover.stripPIIWithOverride(searchTerm, true, true)
89
+ searchTerm = window.GOVUK.analyticsGa4.core.trackFunctions.standardiseSearchTerm(searchTerm)
90
+
92
91
  return searchTerm
93
92
  },
94
93
 
@@ -116,7 +116,7 @@
116
116
  // https://github.com/alphagov/govuk_publishing_components/pull/908#discussion_r302913995
117
117
  var videoTitle = options.title
118
118
  event.target.getIframe().title = videoTitle + ' (video)'
119
- if (window.GOVUK.analyticsGa4.analyticsModules.VideoTracker) {
119
+ if (window.GOVUK.analyticsGa4.analyticsModules && window.GOVUK.analyticsGa4.analyticsModules.VideoTracker) {
120
120
  window.GOVUK.analyticsGa4.analyticsModules.VideoTracker.configureVideo(event)
121
121
  }
122
122
  },
@@ -161,7 +161,7 @@ module GovukPublishingComponents
161
161
  end
162
162
 
163
163
  def clean_file_path(file)
164
- file[/(?<=#{Regexp.escape(@path.to_s)}\/)[\/a-zA-Z_-]+.[a-zA-Z+.]+/]
164
+ file[/(?<=#{Regexp.escape(@path.to_s)}\/)[\/0-9a-zA-Z_-]+.[0-9a-zA-Z+.]+/]
165
165
  end
166
166
 
167
167
  def clean_file_name(name)
@@ -1,6 +1,8 @@
1
1
  <%
2
2
  add_gem_component_stylesheet("file-upload")
3
3
 
4
+ shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
5
+
4
6
  id ||= "file-upload-#{SecureRandom.hex(4)}"
5
7
  value ||= nil
6
8
  accept ||= nil
@@ -13,6 +15,8 @@
13
15
  has_error = error_message || error_items.any?
14
16
  hint_id = "hint-#{SecureRandom.hex(4)}"
15
17
  error_id = "error-#{SecureRandom.hex(4)}"
18
+ heading_size = false unless shared_helper.valid_heading_size?(heading_size)
19
+ heading_level ||= nil
16
20
 
17
21
  css_classes = %w(gem-c-file-upload govuk-file-upload)
18
22
  css_classes << "govuk-file-upload--error" if has_error
@@ -30,7 +34,20 @@
30
34
 
31
35
  <%= content_tag :div, class: form_group_css_classes do %>
32
36
  <% if label %>
33
- <%= render "govuk_publishing_components/components/label", { html_for: id, text: label[:text] }.merge(label.symbolize_keys) %>
37
+ <% label_markup = capture do %>
38
+ <%= render "govuk_publishing_components/components/label", {
39
+ html_for: id,
40
+ heading_size: heading_size
41
+ }.merge(label.symbolize_keys) %>
42
+ <% end %>
43
+
44
+ <% if heading_level %>
45
+ <%= content_tag(shared_helper.get_heading_level, class: "govuk-label-wrapper") do %>
46
+ <%= label_markup %>
47
+ <% end %>
48
+ <% else %>
49
+ <%= label_markup %>
50
+ <% end %>
34
51
  <% end %>
35
52
 
36
53
  <% if hint %>
@@ -48,3 +48,14 @@ examples:
48
48
  text: "Upload an image"
49
49
  name: "file-upload-specific"
50
50
  accept: "image/*"
51
+ with_label_as_heading:
52
+ description: |
53
+ Wraps the label in a heading tag. Valid options are `1` to `6`. To adjust the size of the label/heading, use the `heading_size` option. Valid options are `s`, `m`, `l` and `xl`.
54
+
55
+ Based on the [heading/label pattern](https://design-system.service.gov.uk/patterns/question-pages/) in the GOV.UK Design System.
56
+ data:
57
+ label:
58
+ text: "This is a heading 1 and a label"
59
+ name: "name"
60
+ heading_level: 1
61
+ heading_size: "l"
@@ -105,6 +105,7 @@ module GovukPublishingComponents
105
105
  { content_type: "application/vnd.openxmlformats-officedocument.presentationml.presentation", name: "MS PowerPoint Presentation" }.freeze, # pptx
106
106
  { content_type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", name: "MS Excel Spreadsheet", spreadsheet: true }.freeze, # xlsx
107
107
  { content_type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document", name: "MS Word Document", document: true }.freeze, # docx
108
+ { content_type: "application/zip", abbr: "ZIP", name: "Zip archive" }.freeze,
108
109
  { content_type: "application/xml", abbr: "XML", name: "XML Document" }.freeze,
109
110
  { content_type: "image/gif", abbr: "GIF", name: "Graphics Interchange Format" }.freeze,
110
111
  { content_type: "image/jpeg", name: "JPEG" }.freeze,
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "36.0.2".freeze
2
+ VERSION = "36.1.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 36.0.2
4
+ version: 36.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-04 00:00:00.000000000 Z
11
+ date: 2023-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config