govuk_publishing_components 68.0.0 → 68.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf6fb7638042dd0bc9d2ac0bb19478a4f0cf10d724870e053ff1a024f937d864
4
- data.tar.gz: 9b90cbac0482ebf1cb460e5d721b5525678ac16a47fea078d7ee0f6fa2167d5c
3
+ metadata.gz: ba5b24da8c7e37b1df6a4f4fec4aff4cd3b099923b888a2c844aef00fc54259f
4
+ data.tar.gz: 39e1a0df6c03ca9cc320ec92a6e07738ab30e05a1b7b3c14f61197f23bd0387c
5
5
  SHA512:
6
- metadata.gz: 0cc3516cafd8b43f78621db72c1204a457a47e567354fd54f6128e35a940741c1971150b85d8a725670044f9517601bb781ab7c3e0f08a86cb1002c0d9462bab
7
- data.tar.gz: d9a409ec5a08234d1d81c9a39d13962e4241d804de42056685082f636deba3bbadf9a3fad8a4f9eb4f858a81074492a4c1eeaf826b01121e1fa4ad6dce0d0ae7
6
+ metadata.gz: 1547f4b8b7362ba0105d288a2f484f2a040dba2f7e4955597d040be78dc1b6d891c36856ffab79f88a0b72eb9be616b8b06e8f79c5ca6a5c0c756fec59ae14e9
7
+ data.tar.gz: 35d2a6d741b9ec56ceecc69d311e9490d8c67bee32d4a86a7da37a8f82defe489906e8caa24f921aec4b88eb3fa812b528049bc446ccc36badf653890335edca
@@ -3,13 +3,24 @@
3
3
 
4
4
  function FilterList (module) {
5
5
  this.module = module
6
- this.items = this.module.querySelectorAll('[data-filter-item]')
6
+ this.items = document.querySelectorAll('[data-filter-item]')
7
7
  this.labelText = this.module.getAttribute('data-filter-label') || 'Filter list'
8
+ this.resultsFound = this.items.length
9
+ this.resultsId = 'filter-results-count'
10
+
11
+ window.GOVUK.vars = window.GOVUK.vars || {}
8
12
  }
9
13
 
10
14
  FilterList.prototype.init = function () {
11
- if (this.items.length) {
15
+ if (window.GOVUK.vars.filterStarted) {
16
+ return
17
+ }
18
+
19
+ if (this.resultsFound) {
12
20
  this.appendFilterInput()
21
+ this.resultsElement = document.getElementById(this.resultsId)
22
+ this.updateResultsCount()
23
+ window.GOVUK.vars.filterStarted = true
13
24
  }
14
25
  }
15
26
 
@@ -23,13 +34,19 @@
23
34
  formLabel.textContent = this.labelText
24
35
 
25
36
  const formInput = document.createElement('input')
26
- formInput.classList.add('gem-c-input', 'govuk-input')
37
+ formInput.classList.add('gem-c-input', 'govuk-input', 'govuk-!-margin-bottom-1')
27
38
  formInput.id = 'filterInput'
28
39
  formInput.name = 'name'
29
40
  formInput.spellcheck = false
30
41
  formInput.type = 'text'
42
+ formInput.setAttribute('aria-describedby', this.resultsId)
43
+
44
+ const results = document.createElement('div')
45
+ results.classList.add('govuk-hint')
46
+ results.id = this.resultsId
47
+ results.setAttribute('aria-live', 'polite')
31
48
 
32
- form.append(formLabel, formInput)
49
+ form.append(formLabel, formInput, results)
33
50
 
34
51
  this.module.prepend(form)
35
52
  const input = form.querySelector('.govuk-input')
@@ -50,6 +67,14 @@
50
67
  item.classList.add('govuk-!-display-none')
51
68
  }
52
69
  }
70
+ this.updateResultsCount()
71
+ }
72
+
73
+ FilterList.prototype.updateResultsCount = function () {
74
+ const count = Array.from(this.items).filter((item) => !item.classList.contains('govuk-!-display-none')).length
75
+ const text = count === 1 ? `${count} result found` : `${count === 0 ? 'No' : count} results found`
76
+
77
+ this.resultsElement.innerHTML = count !== this.resultsFound ? text : ''
53
78
  }
54
79
 
55
80
  Modules.FilterList = FilterList
@@ -158,10 +158,11 @@
158
158
 
159
159
  .gem-c-cards__sub-heading {
160
160
  margin: 0 govuk-spacing(6) govuk-spacing(2) 0;
161
+ text-wrap: pretty;
161
162
 
162
163
  // Ensure card content width is constrained to two thirds on desktop
163
164
  @include govuk-media-query($from: "desktop") {
164
- max-width: 66.6667%;
165
+ max-width: 640px;
165
166
  }
166
167
  }
167
168
 
@@ -208,10 +209,11 @@
208
209
 
209
210
  .gem-c-cards__description {
210
211
  margin: 0 govuk-spacing(6) 0 0;
212
+ text-wrap: pretty;
211
213
 
212
214
  // Ensure card content width is constrained to two thirds on desktop
213
215
  @include govuk-media-query($from: "desktop") {
214
- max-width: 66.6667%;
216
+ max-width: 640px;
215
217
  }
216
218
  }
217
219
 
@@ -90,7 +90,7 @@
90
90
  display: none;
91
91
  }
92
92
 
93
- .gem-c-metadata--history {
93
+ .gem-c-metadata--border-top {
94
94
  padding-top: govuk-spacing(2);
95
95
  border-top: 1px solid $govuk-border-colour;
96
96
  }
@@ -110,22 +110,30 @@
110
110
  }
111
111
 
112
112
  .gem-c-metadata__change-history {
113
- margin: govuk-spacing(4) 0 0 0;
113
+ margin: 0;
114
114
  padding: 0;
115
115
  list-style: none;
116
116
  }
117
117
 
118
+ .gem-c-metadata__change-history-item {
119
+ margin-bottom: govuk-spacing(4);
120
+
121
+ &:last-child {
122
+ margin: 0;
123
+ }
124
+
125
+ .gem-c-metadata__change-note {
126
+ margin: 0;
127
+ white-space: pre-line;
128
+ }
129
+ }
130
+
118
131
  .gem-c-metadata__change-date {
119
132
  display: block;
120
- margin: govuk-spacing(3) 0;
133
+ margin: 0 0 govuk-spacing(3) 0;
121
134
  @include govuk-font(16, $weight: bold);
122
135
  }
123
136
 
124
- .gem-c-metadata__change-note {
125
- margin: 0;
126
- white-space: pre-line;
127
- }
128
-
129
137
  // stylelint-disable declaration-no-important
130
138
  @include govuk-media-query($media-type: print) {
131
139
  .gem-c-metadata {
@@ -19,3 +19,11 @@
19
19
  border-color: #16eeee;
20
20
  }
21
21
  }
22
+
23
+ // This can be removed once the organisation is added to govuk-frontend
24
+ .brand--department-for-business-innovation-science-trade {
25
+ &.brand__border-color,
26
+ .brand__border-color {
27
+ border-color: #ff4328;
28
+ }
29
+ }
@@ -13,12 +13,12 @@
13
13
  other ||= nil
14
14
  inverse ||= false
15
15
  inverse_compress ||= false
16
+ border_top ||= false
16
17
 
17
18
  component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
18
19
  component_helper.add_class("gem-c-metadata")
19
20
  component_helper.add_class("direction-#{direction}") if local_assigns.include?(:direction)
20
-
21
- component_helper.add_class("gem-c-metadata--history") if page_history.any?
21
+ component_helper.add_class("gem-c-metadata--border-top") if border_top
22
22
  component_helper.set_id("full-publication-update-history") if page_history.any?
23
23
 
24
24
  if inverse
@@ -49,13 +49,13 @@
49
49
  <dl class="gem-c-metadata__list">
50
50
  <% if from.any? %>
51
51
  <dt class="gem-c-metadata__term"><%= t("components.metadata.from") %>:</dt>
52
- <dd class="gem-c-metadata__definition" data-module="gem-toggle">
52
+ <dd class="gem-c-metadata__definition">
53
53
  <%= render "govuk_publishing_components/components/metadata/sentence", items: from, toggle_id: "from-#{SecureRandom.hex(4)}" %>
54
54
  </dd>
55
55
  <% end %>
56
56
  <% if part_of.any? %>
57
57
  <dt class="gem-c-metadata__term"><%= t("components.metadata.part_of") %>:</dt>
58
- <dd class="gem-c-metadata__definition" data-module="gem-toggle">
58
+ <dd class="gem-c-metadata__definition">
59
59
  <%= render "govuk_publishing_components/components/metadata/sentence", items: part_of, toggle_id: "part-of-#{SecureRandom.hex(4)}" %>
60
60
  </dd>
61
61
  <% end %>
@@ -69,7 +69,7 @@
69
69
  <% end %>
70
70
  <% if local_assigns.include?(:last_updated) && last_updated %>
71
71
  <dt class="gem-c-metadata__term"><%= t("components.metadata.last_updated") %>:</dt>
72
- <dd class="gem-c-metadata__definition" data-module="gem-toggle">
72
+ <dd class="gem-c-metadata__definition">
73
73
  <%= last_updated %>
74
74
  <% if local_assigns.include?(:see_updates_link) %>
75
75
  &#8212; <a href="#full-publication-update-history"
@@ -78,27 +78,19 @@
78
78
  </a>
79
79
  <% end %>
80
80
  <% if page_history.any? %>
81
- <span aria-hidden="true">&#8212; </span>
82
- <% page_history_toggle_id = "page-history-#{SecureRandom.hex(4)}" %>
83
- <a
84
- href="#full-history"
85
- class="gem-c-metadata__toggle govuk-link"
86
- data-controls="<%= page_history_toggle_id %>"
87
- data-expanded="false"
88
- data-toggled-text='<%= t("components.metadata.hide_all_updates", locale: :en) %>'
89
- data-module="ga4-event-tracker"
90
- data-ga4-event='<%= { event_name: "select_content", type: "content history", section: "Footer" }.to_json %>'
91
- data-ga4-expandable>
92
- <%= t("components.metadata.show_all_updates", locale: :en) %>
93
- </a>
94
- <ol class="gem-c-metadata__change-history js-hidden" id="<%= page_history_toggle_id %>">
95
- <% page_history.each do |change| %>
96
- <li>
97
- <time class="gem-c-metadata__change-date timestamp" datetime="<%= change[:timestamp] %>"><%= change[:display_time] %></time>
98
- <p class="gem-c-metadata__change-note"><%= change[:note].strip %></p>
99
- </li>
100
- <% end %>
101
- </ol>
81
+ <%= render "govuk_publishing_components/components/details", {
82
+ title: t("components.metadata.show_all_updates", locale: :en),
83
+ small: true,
84
+ } do %>
85
+ <ol class="gem-c-metadata__change-history">
86
+ <% page_history.each do |change| %>
87
+ <li class="gem-c-metadata__change-history-item">
88
+ <time class="gem-c-metadata__change-date" datetime="<%= change[:timestamp] %>"><%= change[:display_time] %></time>
89
+ <p class="gem-c-metadata__change-note"><%= change[:note].strip %></p>
90
+ </li>
91
+ <% end %>
92
+ </ol>
93
+ <% end %>
102
94
  <% end %>
103
95
  </dd>
104
96
  <% end %>
@@ -111,10 +103,8 @@
111
103
  <% if definition.any? %>
112
104
  <dt class="gem-c-metadata__term"><%= title %>:</dt>
113
105
  <dd class="gem-c-metadata__definition"
114
- <% if disable_ga4 %>
115
- data-module="gem-toggle"
116
- <% else %>
117
- data-module="gem-toggle ga4-link-tracker"
106
+ <% unless disable_ga4 %>
107
+ data-module="ga4-link-tracker"
118
108
  data-ga4-link="<%= ga4_object %>"
119
109
  <% end %>>
120
110
  <%= render "govuk_publishing_components/components/metadata/sentence", items: definition, toggle_id: "#{index}-#{SecureRandom.hex(4)}" %>
@@ -22,6 +22,10 @@ examples:
22
22
  history_only:
23
23
  data:
24
24
  history: Updated 2 weeks ago
25
+ with_border_top:
26
+ data:
27
+ border_top: true
28
+ from: <a href='/government/organisations/ministry-of-defence'>Ministry of Defence</a>
25
29
  published_and_updated:
26
30
  data:
27
31
  first_published: 14 June 2014
@@ -33,6 +37,37 @@ examples:
33
37
  data:
34
38
  last_updated: 10 September 2015
35
39
  see_updates_link: true
40
+ display_page_history:
41
+ description: |
42
+ This will set up an expandable section on the page, with a top border, to let users toggle the display of the page history. It also includes a hidden H2 heading of 'Updates to this page'. This heading will not be included if one is passed to the component using the `title` option.
43
+
44
+ This example includes an expandable 'part of' section to show both toggling elements working together in one component instance.
45
+ data:
46
+ border_top: true
47
+ part_of:
48
+ - <a href="/government/world/afghanistan">Afghanistan</a>
49
+ - <a href="/government/world/albania">Albania</a>
50
+ - <a href="/government/world/algeria">Algeria</a>
51
+ - <a href="/government/world/angola">Angola</a>
52
+ - <a href="/government/world/anguilla">Anguilla</a>
53
+ - <a href="/government/world/argentina">Argentina</a>
54
+ - <a href="/government/world/armenia">Armenia</a>
55
+ - <a href="/government/world/australia">Australia</a>
56
+ - <a href="/government/world/austria">Austria</a>
57
+ - <a href="/government/world/azerbaijan">Azerbaijan</a>
58
+ - <a href="/government/world/bahrain">Bahrain</a>
59
+ first_published: 1st January 1990
60
+ last_updated: 20th October 2016
61
+ page_history:
62
+ - display_time: 1st January 1990
63
+ note: First published
64
+ timestamp: 1990-01-01T15:42:37.000+00:00
65
+ - display_time: 20th July 1995
66
+ note: Updated to include information for 1994
67
+ timestamp: 1995-07-20T15:42:37.000+00:00
68
+ - display_time: 14th October 2000
69
+ note: Updated information on pupil premium reviews and what information schools need to publish on their websites.
70
+ timestamp: 2000-10-14T15:42:37.000+00:00
36
71
  extensive:
37
72
  data:
38
73
  from:
@@ -348,36 +383,6 @@ examples:
348
383
  first_published: 14 June 2014
349
384
  other:
350
385
  Applies to: England, Scotland, and Wales (see detailed guidance for <a href="http://www.dardni.gov.uk/news-dard-pa022-a-13-new-procedure-for" rel="external">Northern Ireland</a>)
351
- display_page_history:
352
- description: |
353
- This will set up an expandable section on the page, with a top border, to let users toggle the display of the page history. It also includes a hidden H2 heading of 'Updates to this page'. This heading will not be included if one is passed to the component using the `title` option.
354
-
355
- This example includes an expandable 'part of' section to show both toggling elements working together in one component instance.
356
- data:
357
- part_of:
358
- - <a href="/government/world/afghanistan">Afghanistan</a>
359
- - <a href="/government/world/albania">Albania</a>
360
- - <a href="/government/world/algeria">Algeria</a>
361
- - <a href="/government/world/angola">Angola</a>
362
- - <a href="/government/world/anguilla">Anguilla</a>
363
- - <a href="/government/world/argentina">Argentina</a>
364
- - <a href="/government/world/armenia">Armenia</a>
365
- - <a href="/government/world/australia">Australia</a>
366
- - <a href="/government/world/austria">Austria</a>
367
- - <a href="/government/world/azerbaijan">Azerbaijan</a>
368
- - <a href="/government/world/bahrain">Bahrain</a>
369
- first_published: 1st January 1990
370
- last_updated: 20th October 2016
371
- page_history:
372
- - display_time: 1st January 1990
373
- note: First published
374
- timestamp: 1990-01-01T15:42:37.000+00:00
375
- - display_time: 20th July 1995
376
- note: Updated to include information for 1994
377
- timestamp: 1995-07-20T15:42:37.000+00:00
378
- - display_time: 14th October 2000
379
- note: Updated information on pupil premium reviews and what information schools need to publish on their websites.
380
- timestamp: 2000-10-14T15:42:37.000+00:00
381
386
  with_title:
382
387
  data:
383
388
  last_updated: 10 September 2015
@@ -9,16 +9,10 @@
9
9
  %>
10
10
  <%= items.to_sentence(two_words_connector: connector, last_word_connector: connector).html_safe %>
11
11
  <% if remaining.any? %>
12
- <div class="gem-c-metadata__toggle-wrap govuk-!-display-none-print">
13
- <a href="#"
14
- class="gem-c-metadata__definition-link govuk-!-display-none-print"
15
- data-controls="toggle-<%= toggle_id %>"
16
- data-expanded="false"
17
- data-toggled-text="<%= t("common.toggle_less") %>">
18
- <%= t("common.toggle_more",
19
- show: t("common.show"),
20
- number: remaining.length) %>
21
- </a>
22
- </div>
23
- <span id="toggle-<%= toggle_id %>" class="gem-c-metadata__toggle-items js-hidden"><%= remaining.to_sentence.html_safe %></span>
12
+ <%= render "govuk_publishing_components/components/details", {
13
+ title: t("common.toggle_more", show: t("common.show"), number: remaining.length),
14
+ small: true,
15
+ } do %>
16
+ <%= remaining.to_sentence.html_safe %>
17
+ <% end %>
24
18
  <% end %>
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "68.0.0".freeze
2
+ VERSION = "68.2.0".freeze
3
3
  end
@@ -28,6 +28,12 @@ First download the package:
28
28
  npm install axe-core --save-dev
29
29
  ```
30
30
 
31
+ Or, using pnpm:
32
+
33
+ ```console
34
+ pnpm add --save-dev axe-core
35
+ ```
36
+
31
37
  Now include the javascript file in each of your iframes in your fixtures or test systems:
32
38
 
33
39
  ```html
@@ -95,17 +101,13 @@ The [axe-core API](doc/API.md) package consists of:
95
101
 
96
102
  Axe can be built using your local language. To do so, a localization file must be added to the `./locales` directory. This file must be named in the following manner: `<langcode>.json`. To build axe using this locale, instead of the default, run axe with the `--lang` flag, like so:
97
103
 
98
- `grunt build --lang=nl`
99
-
100
- or equivalently:
101
-
102
- `npm run build -- --lang=nl`
104
+ `pnpm run build -- --lang=nl`
103
105
 
104
106
  This will create a new build for axe, called `axe.<lang>.js` and `axe.<lang>.min.js`. If you want to build all localized versions, simply pass in `--all-lang` instead. If you want to build multiple localized versions (but not all of them), you can pass in a comma-separated list of languages to the `--lang` flag, like `--lang=nl,ja`.
105
107
 
106
- To create a new translation for axe, start by running `grunt translate --lang=<langcode>`. This will create a json file in the `./locales` directory, with the default English text in it for you to translate. Alternatively, you could copy `./locales/_template.json`. We welcome any localization for axe-core. For details on how to contribute, see the Contributing section below. For details on the message syntax, see [Check Message Template](/doc/check-message-template.md).
108
+ To create a new translation for axe, start by running `pnpm run translate -- --lang=<langcode>`. This will create a json file in the `./locales` directory, with the default English text in it for you to translate. Alternatively, you could copy `./locales/_template.json`. We welcome any localization for axe-core. For details on how to contribute, see the Contributing section below. For details on the message syntax, see [Check Message Template](/doc/check-message-template.md).
107
109
 
108
- To update an existing translation file, re-run `grunt translate --lang=<langcode>`. This will add new messages used in English and remove messages which were not used in English.
110
+ To update an existing translation file, re-run `pnpm run translate -- --lang=<langcode>`. This will add new messages used in English and remove messages which were not used in English.
109
111
 
110
112
  Additionally, locale can be applied at runtime by passing a `locale` object to `axe.configure()`. The locale object must be of the same shape as existing locales in the `./locales` directory. For example:
111
113
 
@@ -153,6 +155,7 @@ Axe-core supports the following locales. Do note that since locales are contribu
153
155
  - Polish
154
156
  - Portuguese (Brazilian)
155
157
  - Spanish
158
+ - Swedish
156
159
 
157
160
  ## Updates & Security
158
161
 
@@ -37,12 +37,7 @@ declare namespace axe {
37
37
  | 'sectionhead';
38
38
 
39
39
  type HtmlContentTypes =
40
- | 'flow'
41
- | 'sectioning'
42
- | 'heading'
43
- | 'phrasing'
44
- | 'embedded'
45
- | 'interactive';
40
+ 'flow' | 'sectioning' | 'heading' | 'phrasing' | 'embedded' | 'interactive';
46
41
 
47
42
  // Array of length 2 or greater
48
43
  type MultiArray<T> = [T, T, ...T[]];
@@ -65,10 +60,7 @@ declare namespace axe {
65
60
 
66
61
  // Context options
67
62
  type Selector =
68
- | Node
69
- | BaseSelector
70
- | LabelledShadowDomSelector
71
- | LabelledFramesSelector;
63
+ Node | BaseSelector | LabelledShadowDomSelector | LabelledFramesSelector;
72
64
  type SelectorList = Array<Selector | FramesSelector> | NodeList;
73
65
  type ContextProp = Selector | SelectorList;
74
66
  type ContextObject =
@@ -85,9 +77,7 @@ declare namespace axe {
85
77
  type ElementContext = ContextSpec;
86
78
 
87
79
  type SerialSelector =
88
- | BaseSelector
89
- | LabelledShadowDomSelector
90
- | LabelledFramesSelector;
80
+ BaseSelector | LabelledShadowDomSelector | LabelledFramesSelector;
91
81
  type SerialFrameSelector = SerialSelector | FramesSelector;
92
82
  type SerialSelectorList = Array<SerialFrameSelector>;
93
83
 
@@ -310,8 +300,7 @@ declare namespace axe {
310
300
  virtualNode: VirtualNode
311
301
  ) => boolean | undefined | void);
312
302
  after?:
313
- | string
314
- | ((results: AfterResult[], options: unknown) => AfterResult[]);
303
+ string | ((results: AfterResult[], options: unknown) => AfterResult[]);
315
304
  options?: any;
316
305
  matches?: string;
317
306
  enabled?: boolean;