govuk_publishing_components 28.5.0 → 28.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/app/assets/javascripts/govuk_publishing_components/analytics/page-content.js +3 -3
  4. data/app/assets/javascripts/govuk_publishing_components/analytics/track-select-change.js +4 -3
  5. data/app/assets/javascripts/govuk_publishing_components/components/accordion.js +21 -291
  6. data/app/assets/javascripts/govuk_publishing_components/components/button.js +1 -1
  7. data/app/assets/javascripts/govuk_publishing_components/components/character-count.js +1 -1
  8. data/app/assets/javascripts/govuk_publishing_components/components/checkboxes.js +1 -1
  9. data/app/assets/javascripts/govuk_publishing_components/components/details.js +1 -1
  10. data/app/assets/javascripts/govuk_publishing_components/components/error-summary.js +1 -1
  11. data/app/assets/javascripts/govuk_publishing_components/components/feedback.js +7 -6
  12. data/app/assets/javascripts/govuk_publishing_components/components/layout-header.js +1 -1
  13. data/app/assets/javascripts/govuk_publishing_components/components/radio.js +1 -1
  14. data/app/assets/javascripts/govuk_publishing_components/components/skip-link.js +5 -0
  15. data/app/assets/javascripts/govuk_publishing_components/components/step-by-step-nav.js +40 -37
  16. data/app/assets/javascripts/govuk_publishing_components/components/tabs.js +1 -1
  17. data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js +2 -1
  18. data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/magna-charta.js +8 -10
  19. data/app/assets/javascripts/govuk_publishing_components/lib/initial-focus.js +4 -3
  20. data/app/assets/javascripts/govuk_publishing_components/lib/toggle-input-class-on-focus.js +4 -3
  21. data/app/assets/javascripts/govuk_publishing_components/lib/toggle.js +4 -3
  22. data/app/assets/javascripts/govuk_publishing_components/vendor/lux/lux-reporter.js +1796 -911
  23. data/app/assets/stylesheets/govuk_publishing_components/components/_accordion.scss +1 -329
  24. data/app/assets/stylesheets/govuk_publishing_components/components/_share-links.scss +1 -1
  25. data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav.scss +95 -56
  26. data/app/assets/stylesheets/govuk_publishing_components/components/print/_accordion.scss +6 -17
  27. data/app/assets/stylesheets/govuk_publishing_components/govuk_frontend_support.scss +0 -9
  28. data/app/models/govuk_publishing_components/component_docs.rb +1 -1
  29. data/app/views/govuk_publishing_components/components/_accordion.html.erb +31 -16
  30. data/app/views/govuk_publishing_components/components/_attachment.html.erb +3 -1
  31. data/app/views/govuk_publishing_components/components/_button.html.erb +4 -4
  32. data/app/views/govuk_publishing_components/components/_character_count.html.erb +2 -2
  33. data/app/views/govuk_publishing_components/components/_checkboxes.html.erb +2 -2
  34. data/app/views/govuk_publishing_components/components/_error_message.html.erb +1 -1
  35. data/app/views/govuk_publishing_components/components/_error_summary.html.erb +0 -1
  36. data/app/views/govuk_publishing_components/components/_input.html.erb +3 -3
  37. data/app/views/govuk_publishing_components/components/_inset_text.html.erb +12 -1
  38. data/app/views/govuk_publishing_components/components/_intervention.html.erb +2 -2
  39. data/app/views/govuk_publishing_components/components/_layout_footer.html.erb +1 -1
  40. data/app/views/govuk_publishing_components/components/_modal_dialogue.html.erb +1 -1
  41. data/app/views/govuk_publishing_components/components/_radio.html.erb +1 -1
  42. data/app/views/govuk_publishing_components/components/_search.html.erb +2 -4
  43. data/app/views/govuk_publishing_components/components/_select.html.erb +15 -43
  44. data/app/views/govuk_publishing_components/components/_skip_link.html.erb +1 -1
  45. data/app/views/govuk_publishing_components/components/_subscription_links.html.erb +7 -8
  46. data/app/views/govuk_publishing_components/components/docs/accordion.yml +2 -97
  47. data/app/views/govuk_publishing_components/components/docs/attachment.yml +11 -0
  48. data/app/views/govuk_publishing_components/components/docs/govspeak.yml +1 -1
  49. data/app/views/govuk_publishing_components/components/docs/inset_text.yml +6 -0
  50. data/app/views/govuk_publishing_components/components/docs/select.yml +1 -1
  51. data/app/views/govuk_publishing_components/components/docs/share_links.yml +1 -1
  52. data/app/views/govuk_publishing_components/components/docs/step_by_step_nav.yml +13 -13
  53. data/app/views/govuk_publishing_components/components/docs/tabs.yml +1 -1
  54. data/app/views/govuk_publishing_components/components/docs/textarea.yml +1 -1
  55. data/app/views/govuk_publishing_components/components/layout_header/_navigation_items.html.erb +11 -11
  56. data/config/initializers/assets.rb +1 -0
  57. data/lib/govuk_publishing_components/presenters/attachment.rb +23 -0
  58. data/lib/govuk_publishing_components/presenters/select_helper.rb +85 -0
  59. data/lib/govuk_publishing_components/version.rb +1 -1
  60. data/lib/govuk_publishing_components.rb +1 -1
  61. data/node_modules/govuk-frontend/govuk/all.js +294 -76
  62. data/node_modules/govuk-frontend/govuk/components/accordion/_index.scss +274 -99
  63. data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js +169 -65
  64. data/node_modules/govuk-frontend/govuk/components/accordion/fixtures.json +37 -5
  65. data/node_modules/govuk-frontend/govuk/components/accordion/macro-options.json +4 -4
  66. data/node_modules/govuk-frontend/govuk/components/button/button.js +2 -2
  67. data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +3 -3
  68. data/node_modules/govuk-frontend/govuk/components/character-count/fixtures.json +15 -2
  69. data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js +8 -10
  70. data/node_modules/govuk-frontend/govuk/components/checkboxes/fixtures.json +52 -15
  71. data/node_modules/govuk-frontend/govuk/components/cookie-banner/_index.scss +0 -2
  72. data/node_modules/govuk-frontend/govuk/components/cookie-banner/fixtures.json +31 -0
  73. data/node_modules/govuk-frontend/govuk/components/date-input/fixtures.json +25 -25
  74. data/node_modules/govuk-frontend/govuk/components/details/details.js +2 -2
  75. data/node_modules/govuk-frontend/govuk/components/error-message/_index.scss +1 -0
  76. data/node_modules/govuk-frontend/govuk/components/error-message/fixtures.json +8 -8
  77. data/node_modules/govuk-frontend/govuk/components/error-message/template.njk +2 -2
  78. data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js +24 -3
  79. data/node_modules/govuk-frontend/govuk/components/error-summary/fixtures.json +25 -16
  80. data/node_modules/govuk-frontend/govuk/components/error-summary/macro-options.json +6 -0
  81. data/node_modules/govuk-frontend/govuk/components/error-summary/template.njk +2 -1
  82. data/node_modules/govuk-frontend/govuk/components/file-upload/fixtures.json +4 -4
  83. data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +3 -37
  84. data/node_modules/govuk-frontend/govuk/components/footer/fixtures.json +119 -15
  85. data/node_modules/govuk-frontend/govuk/components/footer/macro-options.json +6 -0
  86. data/node_modules/govuk-frontend/govuk/components/footer/template.njk +1 -1
  87. data/node_modules/govuk-frontend/govuk/components/header/_index.scss +10 -4
  88. data/node_modules/govuk-frontend/govuk/components/header/fixtures.json +11 -11
  89. data/node_modules/govuk-frontend/govuk/components/header/header.js +4 -4
  90. data/node_modules/govuk-frontend/govuk/components/header/template.njk +4 -3
  91. data/node_modules/govuk-frontend/govuk/components/hint/_index.scss +1 -3
  92. data/node_modules/govuk-frontend/govuk/components/input/_index.scss +1 -1
  93. data/node_modules/govuk-frontend/govuk/components/input/fixtures.json +40 -40
  94. data/node_modules/govuk-frontend/govuk/components/input/template.njk +4 -3
  95. data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js +499 -2
  96. data/node_modules/govuk-frontend/govuk/components/phase-banner/fixtures.json +2 -2
  97. data/node_modules/govuk-frontend/govuk/components/radios/_index.scss +0 -8
  98. data/node_modules/govuk-frontend/govuk/components/radios/fixtures.json +44 -45
  99. data/node_modules/govuk-frontend/govuk/components/radios/radios.js +4 -4
  100. data/node_modules/govuk-frontend/govuk/components/radios/template.njk +2 -9
  101. data/node_modules/govuk-frontend/govuk/components/select/_index.scss +6 -1
  102. data/node_modules/govuk-frontend/govuk/components/select/fixtures.json +3 -3
  103. data/node_modules/govuk-frontend/govuk/components/skip-link/_index.scss +13 -0
  104. data/node_modules/govuk-frontend/govuk/components/skip-link/fixtures.json +9 -9
  105. data/node_modules/govuk-frontend/govuk/components/skip-link/skip-link.js +1108 -0
  106. data/node_modules/govuk-frontend/govuk/components/skip-link/template.njk +1 -1
  107. data/node_modules/govuk-frontend/govuk/components/summary-list/_index.scss +20 -23
  108. data/node_modules/govuk-frontend/govuk/components/summary-list/fixtures.json +86 -1
  109. data/node_modules/govuk-frontend/govuk/components/summary-list/template.njk +1 -4
  110. data/node_modules/govuk-frontend/govuk/components/tabs/_index.scss +2 -2
  111. data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js +2 -2
  112. data/node_modules/govuk-frontend/govuk/components/tag/_index.scss +0 -5
  113. data/node_modules/govuk-frontend/govuk/components/tag/fixtures.json +2 -2
  114. data/node_modules/govuk-frontend/govuk/components/textarea/_index.scss +1 -1
  115. data/node_modules/govuk-frontend/govuk/components/textarea/fixtures.json +4 -4
  116. data/node_modules/govuk-frontend/govuk/core/_all.scss +0 -1
  117. data/node_modules/govuk-frontend/govuk/core/_global-styles.scss +0 -6
  118. data/node_modules/govuk-frontend/govuk/core/_links.scss +0 -6
  119. data/node_modules/govuk-frontend/govuk/core/_lists.scss +0 -6
  120. data/node_modules/govuk-frontend/govuk/core/_section-break.scss +0 -6
  121. data/node_modules/govuk-frontend/govuk/core/_typography.scss +0 -6
  122. data/node_modules/govuk-frontend/govuk/objects/_all.scss +1 -0
  123. data/node_modules/govuk-frontend/govuk/objects/_main-wrapper.scss +15 -30
  124. data/node_modules/govuk-frontend/govuk/{core → objects}/_template.scss +1 -5
  125. data/node_modules/govuk-frontend/govuk/overrides/_display.scss +0 -6
  126. data/node_modules/govuk-frontend/govuk/overrides/_spacing.scss +0 -6
  127. data/node_modules/govuk-frontend/govuk/overrides/_text-align.scss +0 -6
  128. data/node_modules/govuk-frontend/govuk/overrides/_typography.scss +0 -6
  129. data/node_modules/govuk-frontend/govuk/overrides/_width.scss +0 -6
  130. data/node_modules/govuk-frontend/govuk/settings/_colours-organisations.scss +3 -0
  131. data/node_modules/govuk-frontend/govuk/settings/_measurements.scss +0 -10
  132. data/node_modules/govuk-frontend/govuk/tools/_all.scss +0 -1
  133. data/node_modules/govuk-frontend/package.json +1 -1
  134. metadata +22 -37
  135. data/app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js +0 -100
  136. data/lib/govuk_publishing_components/presenters/select.rb +0 -43
  137. data/lib/tasks/govuk_publishing_components_tasks.rake +0 -49
  138. data/node_modules/govuk-frontend/govuk/tools/_iff.scss +0 -17
@@ -96,7 +96,7 @@ examples:
96
96
  }
97
97
  ]
98
98
  with_a_different_heading_level:
99
- description: Steps have a H2 by default, but this can be changed. The heading level does not change any styling.
99
+ description: Steps have a `h2` by default, but this can be changed. The heading level does not change any styling.
100
100
  data:
101
101
  heading_level: 3
102
102
  steps: [
@@ -164,7 +164,7 @@ examples:
164
164
  ]
165
165
  remember_last_opened_step:
166
166
  description: |
167
- If steps are opened their IDs are added to an array in sessionStorage, so that if the user returns to this page in the same session, those steps will be opened on page load. This option can technically be used together with the option to open a step by default, but this is not recommended as it could confuse users.
167
+ If steps are opened their IDs are added to an array in `sessionStorage`, so that if the user returns to this page in the same session, those steps will be opened on page load. This option can technically be used together with the option to open a step by default, but this is not recommended as it could confuse users.
168
168
  data:
169
169
  remember_last_step: true
170
170
  steps: [
@@ -192,9 +192,9 @@ examples:
192
192
  Links can have the following attributes:
193
193
 
194
194
  - style, an attribute on the parent list that controls its appearance. Defaults to optional but can be set to 'choice' (adds indent and bullets to the list)
195
- - context, an optional text field to show some extra information after the link, usually a monetary value
196
- - active, whether to make the link highlighted (to indicate the current page)
197
- - highlight_step, a general option to highlight the step. Usually the active link would be in the active step, but in some circumstances there might be an active step but no highlighted link.
195
+ - `context`, an optional text field to show some extra information after the link, usually a monetary value
196
+ - `active`, whether to make the link highlighted (to indicate the current page)
197
+ - `highlight_step`, a general option to highlight the step. Usually the active link would be in the active step, but in some circumstances there might be an active step but no highlighted link.
198
198
  data:
199
199
  highlight_step: 2
200
200
  show_step: 2
@@ -338,11 +338,11 @@ examples:
338
338
 
339
339
  If a link is in a step by step navigation more than once and the user is on that page, the backend doesn't know which link to highlight, so it highlights both of them.
340
340
 
341
- JavaScript is included in the component to solve this. It uses sessionStorage to capture the data-position attribute of non-external links when clicked, and then uses this value to decide which link to highlight after the new page loads. It uses the value of the tracking_id option to uniquely identify the current step nav in the session (if this is not passed to the component this may result in other step navs having the wrong link highlighted).
341
+ JavaScript is included in the component to solve this. It uses `sessionStorage` to capture the data-position attribute of non-external links when clicked, and then uses this value to decide which link to highlight after the new page loads. It uses the value of the `tracking_id` option to uniquely identify the current step nav in the session (if this is not passed to the component this may result in other step navs having the wrong link highlighted).
342
342
 
343
- If a user has not clicked a link (i.e. has visited the page without first clicking on a step by step navigation) only the first duplicate link will be highlighted. If that link is not in the active step, the JS makes the highlighted link's parent the active step. If there is no active step, the first active link will be highlighted (but there should always be an active step).
343
+ If a user has not clicked a link (i.e. has visited the page without first clicking on a step by step navigation) only the first duplicate link will be highlighted. If that link is not in the active step, the JavaScript makes the highlighted link's parent the active step. If there is no active step, the first active link will be highlighted (but there should always be an active step).
344
344
 
345
- The example below will show all non-external links highlighted if JS is disabled. In the real world no more than two or three links are likely to be highlighted at once.
345
+ The example below will show all non-external links highlighted if JavaScript is disabled. In the real world no more than two or three links are likely to be highlighted at once.
346
346
 
347
347
  Changes to the active step and highlighted link are also applied on click, if the user clicks one of the other links that is to the same page (they are amended by the component to be jump links to the top of the page). Open this example using the 'preview' link and try clicking on the 'internal' links to see how it behaves.
348
348
  data:
@@ -417,15 +417,15 @@ examples:
417
417
 
418
418
  The solution is to track the step by step journey the user is on.
419
419
 
420
- This has been achieved by adding a query string to all of the internal links in the step by step that contains the content_id of the step by step.
420
+ This has been achieved by adding a query string to all of the internal links in the step by step that contains the `content_id` of the step by step.
421
421
 
422
- For example, if the step by step contains a link to [/check-uk-visa](/check-uk-visa), the component will renders the link as [/check-uk-visa?step-by-step-nav=d8f3c2e0-d544-4664-9616-ab71323e4d18](/check-uk-visa?step-by-step-nav=d8f3c2e0-d544-4664-9616-ab71323e4d18)
422
+ For example, if the step by step contains a link to [/check-uk-visa](/check-uk-visa), the component will render the link as [/check-uk-visa?step-by-step-nav=d8f3c2e0-d544-4664-9616-ab71323e4d18](/check-uk-visa?step-by-step-nav=d8f3c2e0-d544-4664-9616-ab71323e4d18)
423
423
 
424
424
  As long as the user follows the links in the step by step (and not the inline links in the content), the component will know which step by step journey the user is on.
425
425
 
426
- If the content item is part of multiple step by steps, the component fetches the content_id of the `active` step by step from the query string and expands that one. The other step by steps that the content item is part of are displayed as a list of titles under an "Also part of" heading.
426
+ If the content item is part of multiple step by steps, the component fetches the `content_id` of the `active` step by step from the query string and expands that one. The other step by steps that the content item is part of are displayed as a list of titles under an "Also part of" heading.
427
427
 
428
- Additionally, if content designers have chosen to "hide" a step by step on a content page, but we can see that the user is following a step by step journey (the content_id of the step by step is in the querystring), the step by step will still be displayed and expanded in the sidebar, and the other step by steps that the content item is part of, but content designers have chosen to hide will also be displayed as a list of titles under an "Also part of heading".
428
+ Additionally, if content designers have chosen to "hide" a step by step on a content page, but we can see that the user is following a step by step journey (the `content_id` of the step by step is in the querystring), the step by step will still be displayed and expanded in the sidebar, and the other step by steps that the content item is part of, but content designers have chosen to hide will also be displayed as a list of titles under an "Also part of heading".
429
429
 
430
430
  In both cases, we never show more than 5 step by steps in the list.
431
431
 
@@ -523,7 +523,7 @@ examples:
523
523
  description: |
524
524
  Steps can be optional. This is controlled by two parameters, 'optional' and 'logic'.
525
525
 
526
- - Optional steps used to have a dotted line down the side but this was removed as it confused users. In some cases we may still need to record if a step is optional, so if this parameter is applied, GA tracking events will have 'optional' appended to the end of the eventLabel.
526
+ - Optional steps used to have a dotted line down the side but this was removed as it confused users. In some cases we may still need to record if a step is optional, so if this parameter is applied, Google Analytics tracking events will have 'optional' appended to the end of the eventLabel.
527
527
  - Logic will change the number next to a step to the word 'and' or the word 'or'.
528
528
 
529
529
  If a step is optional this should be conveyed by the text within that step.
@@ -2,7 +2,7 @@ name: "Tabs (experimental)"
2
2
  description: "The tabs component lets users toggle between related sections of content."
3
3
  body: |
4
4
  This component is based on the [GOV.UK Design System tabs component](https://design-system.service.gov.uk/components/tabs/)
5
- and is currently experimental. If using this component, please feed back any research findings to the Design System team](https://design-system.service.gov.uk/get-in-touch/).
5
+ and is currently experimental. If using this component, please feed back any research findings to the [GOV.UK Design System team](https://design-system.service.gov.uk/get-in-touch/).
6
6
 
7
7
  The tabs component lets users navigate between related sections of content on a single page,
8
8
  displaying one section at a time. Note that they are not intended to be used to navigate
@@ -83,7 +83,7 @@ examples:
83
83
  text: "How about a hint below?"
84
84
  name: "more-elements"
85
85
  block: |
86
- <span class="govuk-hint">Here's a hint</span>
86
+ <div class="govuk-hint">Here's a hint</div>
87
87
  with_maxlength:
88
88
  data:
89
89
  label:
@@ -1,17 +1,17 @@
1
1
  <% navigation_aria_label ||= "Top level" %>
2
2
 
3
3
  <% if navigation_items.any? %>
4
- <button
5
- aria-controls="navigation"
6
- aria-label="Show or hide Top Level Navigation"
7
- class="govuk-header__menu-button govuk-js-header-toggle gem-c-header__menu-button govuk-!-display-none-print"
8
- type="button"
9
- data-button-name="menu"
10
- >
11
- <%= t("components.layout_header.menu") %>
12
- </button>
13
- <%= tag.nav class: "gem-c-header__nav", aria: { label: navigation_aria_label } do %>
14
- <ul id="navigation" class="govuk-header__navigation govuk-header__navigation--end">
4
+ <%= tag.nav class: "gem-c-header__nav govuk-header__navigation govuk-header__navigation--end", aria: { label: navigation_aria_label } do %>
5
+ <button
6
+ aria-controls="navigation"
7
+ aria-label="Show or hide Top Level Navigation"
8
+ class="govuk-header__menu-button govuk-js-header-toggle gem-c-header__menu-button govuk-!-display-none-print"
9
+ type="button"
10
+ data-button-name="menu"
11
+ >
12
+ <%= t("components.layout_header.menu") %>
13
+ </button>
14
+ <ul id="navigation" class="govuk-header__navigation-list">
15
15
  <% navigation_items.each_with_index do |item, index| %>
16
16
  <%
17
17
  li_classes = %w(govuk-header__navigation-item)
@@ -10,6 +10,7 @@ Rails.application.config.assets.precompile += %w[
10
10
  govuk_publishing_components/vendor/lux/lux-reporter.js
11
11
  govuk_publishing_components/vendor/lux/lux-measurer.js
12
12
  govuk_publishing_components/all_components.js
13
+ govuk_publishing_components/dependencies.js
13
14
  govuk_publishing_components/ie.js
14
15
  govuk_publishing_components/modules.js
15
16
  govuk_publishing_components/vendor/modernizr.js
@@ -1,6 +1,16 @@
1
1
  module GovukPublishingComponents
2
2
  module Presenters
3
3
  class Attachment
4
+ # DfE, DWP, DHSC, HMRC, DVSA and PHE are taking part in a pilot to use a form
5
+ # rather than direct email for users to request accessible formats. When the pilot
6
+ # scheme is rolled out further this can be removed.
7
+ EMAILS_IN_ACCESSIBLE_FORMAT_REQUEST_PILOT = %w[alternative.formats@education.gov.uk
8
+ accessible.formats@dwp.gov.uk
9
+ publications@dhsc.gov.uk
10
+ different.format@hmrc.gov.uk
11
+ gov.uk.publishing@dvsa.gov.uk
12
+ publications@phe.gov.uk].freeze
13
+
4
14
  delegate :opendocument?, :document?, :spreadsheet?, to: :content_type
5
15
 
6
16
  attr_reader :attachment_data
@@ -8,6 +18,7 @@ module GovukPublishingComponents
8
18
  # Expects a hash of attachment data
9
19
  # * title and url are required
10
20
  # * content_type, filename, file_size, number of pages, alternative_format_contact_email can be provided
21
+ # * attachment_id and owning_document_content_id are required to use the accessible format request form
11
22
  def initialize(attachment_data)
12
23
  @attachment_data = attachment_data.with_indifferent_access
13
24
  end
@@ -47,6 +58,14 @@ module GovukPublishingComponents
47
58
  attachment_data[:alternative_format_contact_email]
48
59
  end
49
60
 
61
+ def attachment_id
62
+ attachment_data[:attachment_id]
63
+ end
64
+
65
+ def owning_document_content_id
66
+ attachment_data[:owning_document_content_id]
67
+ end
68
+
50
69
  def reference
51
70
  reference = []
52
71
  reference << "ISBN #{attachment_data[:isbn]}" if attachment_data[:isbn].present?
@@ -71,6 +90,10 @@ module GovukPublishingComponents
71
90
  attachment_data[:command_paper_number].present? || attachment_data[:hoc_paper_number].present? || attachment_data[:unnumbered_command_paper].eql?(true) || attachment_data[:unnumbered_hoc_paper].eql?(true)
72
91
  end
73
92
 
93
+ def display_accessible_format_request_form_link?
94
+ EMAILS_IN_ACCESSIBLE_FORMAT_REQUEST_PILOT.include?(alternative_format_contact_email) && owning_document_content_id.present? && attachment_id.present?
95
+ end
96
+
74
97
  class SupportedContentType
75
98
  attr_reader :content_type_data
76
99
 
@@ -0,0 +1,85 @@
1
+ module GovukPublishingComponents
2
+ module Presenters
3
+ class SelectHelper
4
+ attr_reader :options, :option_markup, :selected_option, :error_message, :error_id, :hint, :hint_id, :describedby
5
+
6
+ def initialize(local_assigns)
7
+ @options = local_assigns[:options] || []
8
+ @error_message = local_assigns[:error_message]
9
+ @error_id = local_assigns[:error_id] || nil
10
+ @hint = local_assigns[:hint] || nil
11
+ @hint_id = local_assigns[:hint_id] || nil
12
+ @heading_size = local_assigns[:heading_size]
13
+ @full_width = local_assigns[:full_width] || false
14
+ @option_markup = get_options
15
+ @describedby = get_describedby
16
+ end
17
+
18
+ def data_tracking?
19
+ @options.any? { |item| item[:data_attributes] && item[:data_attributes][:track_category] && item[:data_attributes][:track_action] }
20
+ end
21
+
22
+ def css_classes
23
+ classes = %w[govuk-form-group gem-c-select]
24
+ classes << "govuk-form-group--error" if @error_message
25
+ classes
26
+ end
27
+
28
+ def select_classes
29
+ classes = %w[govuk-select]
30
+ classes << "gem-c-select__select--full-width" if @full_width
31
+ classes << "govuk-select--error" if @error_id
32
+ classes
33
+ end
34
+
35
+ def label_classes
36
+ classes = %w[govuk-label]
37
+ classes << "govuk-label--#{@heading_size}" if @heading_size
38
+ classes
39
+ end
40
+
41
+ private
42
+
43
+ def get_options
44
+ return if options.nil?
45
+
46
+ options.map do |option|
47
+ @selected_option = option[:value] if option[:selected]
48
+ [
49
+ option[:text],
50
+ option[:value],
51
+ options_data_attribute(option[:data_attributes]),
52
+ ]
53
+ end
54
+ end
55
+
56
+ def options_data_attribute(attributes)
57
+ return {} if attributes.nil?
58
+
59
+ attrs = {}
60
+ attributes.each do |key, value|
61
+ key_name = "data-#{key.to_s.split('_').join('-')}"
62
+ attrs[key_name] = value.is_a?(Hash) ? value.to_json : value
63
+ end
64
+
65
+ attrs
66
+ end
67
+
68
+ def get_describedby
69
+ describedby = %w[]
70
+
71
+ if @error_message || @error_id
72
+ @error_id ||= "error-#{SecureRandom.hex(4)}"
73
+ describedby << @error_id
74
+ end
75
+
76
+ if @hint
77
+ @hint_id ||= "hint-#{SecureRandom.hex(4)}"
78
+ describedby << @hint_id
79
+ end
80
+
81
+ describedby
82
+ end
83
+ end
84
+ end
85
+ end
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "28.5.0".freeze
2
+ VERSION = "28.8.0".freeze
3
3
  end
@@ -21,7 +21,7 @@ require "govuk_publishing_components/presenters/content_breadcrumbs_based_on_pri
21
21
  require "govuk_publishing_components/presenters/content_breadcrumbs_based_on_taxons"
22
22
  require "govuk_publishing_components/presenters/content_breadcrumbs_based_on_topic"
23
23
  require "govuk_publishing_components/presenters/checkboxes_helper"
24
- require "govuk_publishing_components/presenters/select"
24
+ require "govuk_publishing_components/presenters/select_helper"
25
25
  require "govuk_publishing_components/presenters/meta_tags"
26
26
  require "govuk_publishing_components/presenters/content_item"
27
27
  require "govuk_publishing_components/presenters/translation_nav_helper"