govuk_publishing_components 58.1.1 → 59.0.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 +4 -4
- data/app/assets/images/select-with-search/cross-icon.svg +6 -0
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-search-tracker.js +4 -0
- data/app/assets/javascripts/govuk_publishing_components/components/select-with-search.js +57 -0
- data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_action-link.scss +14 -136
- data/app/assets/stylesheets/govuk_publishing_components/components/_heading.scss +0 -5
- data/app/assets/stylesheets/govuk_publishing_components/components/_layout-header.scss +6 -48
- data/app/assets/stylesheets/govuk_publishing_components/components/_select-with-search.scss +168 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_select.scss +6 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_tag.scss +14 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_markdown-typography.scss +1 -1
- data/app/views/govuk_publishing_components/components/_action_link.html.erb +4 -37
- data/app/views/govuk_publishing_components/components/_layout_header.html.erb +0 -2
- data/app/views/govuk_publishing_components/components/_select.html.erb +22 -23
- data/app/views/govuk_publishing_components/components/_select_with_search.html.erb +14 -0
- data/app/views/govuk_publishing_components/components/_share_links.html.erb +17 -9
- data/app/views/govuk_publishing_components/components/_tag.html.erb +20 -0
- data/app/views/govuk_publishing_components/components/docs/action_link.yml +0 -62
- data/app/views/govuk_publishing_components/components/docs/layout_header.yml +13 -0
- data/app/views/govuk_publishing_components/components/docs/select.yml +11 -0
- data/app/views/govuk_publishing_components/components/docs/select_with_search.yml +196 -0
- data/app/views/govuk_publishing_components/components/docs/share_links.yml +10 -0
- data/app/views/govuk_publishing_components/components/docs/signup_link.yml +0 -7
- data/app/views/govuk_publishing_components/components/docs/single_page_notification_button.yml +1 -7
- data/app/views/govuk_publishing_components/components/docs/subscription_links.yml +1 -7
- data/app/views/govuk_publishing_components/components/docs/tag.yml +57 -0
- data/app/views/govuk_publishing_components/components/layout_header/_header_logo.html.erb +16 -5
- data/lib/govuk_publishing_components/presenters/heading_helper.rb +1 -2
- data/lib/govuk_publishing_components/presenters/select_helper.rb +8 -5
- data/lib/govuk_publishing_components/presenters/select_with_search_helper.rb +92 -0
- data/lib/govuk_publishing_components/presenters/single_page_notification_button_helper.rb +1 -1
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/lib/govuk_publishing_components.rb +1 -0
- data/node_modules/choices.js/LICENSE +21 -0
- data/node_modules/choices.js/README.md +1360 -0
- data/node_modules/choices.js/package.json +173 -0
- data/node_modules/choices.js/public/assets/scripts/choices.js +5230 -0
- data/node_modules/choices.js/public/assets/scripts/choices.min.js +2 -0
- data/node_modules/choices.js/public/assets/scripts/choices.mjs +5222 -0
- data/node_modules/choices.js/public/assets/scripts/choices.search-basic.js +4748 -0
- data/node_modules/choices.js/public/assets/scripts/choices.search-basic.min.js +2 -0
- data/node_modules/choices.js/public/assets/scripts/choices.search-basic.mjs +4740 -0
- data/node_modules/choices.js/public/assets/scripts/choices.search-kmp.js +3631 -0
- data/node_modules/choices.js/public/assets/scripts/choices.search-kmp.min.js +2 -0
- data/node_modules/choices.js/public/assets/scripts/choices.search-kmp.mjs +3623 -0
- data/node_modules/choices.js/public/assets/scripts/choices.search-prefix.js +3590 -0
- data/node_modules/choices.js/public/assets/scripts/choices.search-prefix.min.js +2 -0
- data/node_modules/choices.js/public/assets/scripts/choices.search-prefix.mjs +3582 -0
- data/node_modules/choices.js/public/assets/styles/base.css +180 -0
- data/node_modules/choices.js/public/assets/styles/base.css.map +1 -0
- data/node_modules/choices.js/public/assets/styles/base.min.css +1 -0
- data/node_modules/choices.js/public/assets/styles/choices.css +338 -0
- data/node_modules/choices.js/public/assets/styles/choices.css.map +1 -0
- data/node_modules/choices.js/public/assets/styles/choices.min.css +1 -0
- data/node_modules/choices.js/public/types/src/index.d.ts +6 -0
- data/node_modules/choices.js/public/types/src/scripts/actions/choices.d.ts +30 -0
- data/node_modules/choices.js/public/types/src/scripts/actions/groups.d.ts +8 -0
- data/node_modules/choices.js/public/types/src/scripts/actions/items.d.ts +17 -0
- data/node_modules/choices.js/public/types/src/scripts/choices.d.ts +210 -0
- data/node_modules/choices.js/public/types/src/scripts/components/container.d.ts +36 -0
- data/node_modules/choices.js/public/types/src/scripts/components/dropdown.d.ts +21 -0
- data/node_modules/choices.js/public/types/src/scripts/components/index.d.ts +7 -0
- data/node_modules/choices.js/public/types/src/scripts/components/input.d.ts +37 -0
- data/node_modules/choices.js/public/types/src/scripts/components/list.d.ts +14 -0
- data/node_modules/choices.js/public/types/src/scripts/components/wrapped-element.d.ts +21 -0
- data/node_modules/choices.js/public/types/src/scripts/components/wrapped-input.d.ts +3 -0
- data/node_modules/choices.js/public/types/src/scripts/components/wrapped-select.d.ts +20 -0
- data/node_modules/choices.js/public/types/src/scripts/constants.d.ts +1 -0
- data/node_modules/choices.js/public/types/src/scripts/defaults.d.ts +4 -0
- data/node_modules/choices.js/public/types/src/scripts/interfaces/action-type.d.ts +13 -0
- data/node_modules/choices.js/public/types/src/scripts/interfaces/build-flags.d.ts +11 -0
- data/node_modules/choices.js/public/types/src/scripts/interfaces/choice-full.d.ts +23 -0
- data/node_modules/choices.js/public/types/src/scripts/interfaces/class-names.d.ts +61 -0
- data/node_modules/choices.js/public/types/src/scripts/interfaces/event-choice.d.ts +7 -0
- data/node_modules/choices.js/public/types/src/scripts/interfaces/event-type.d.ts +14 -0
- data/node_modules/choices.js/public/types/src/scripts/interfaces/group-full.d.ts +10 -0
- data/node_modules/choices.js/public/types/src/scripts/interfaces/index.d.ts +14 -0
- data/node_modules/choices.js/public/types/src/scripts/interfaces/input-choice.d.ts +15 -0
- data/node_modules/choices.js/public/types/src/scripts/interfaces/input-group.d.ts +10 -0
- data/node_modules/choices.js/public/types/src/scripts/interfaces/item.d.ts +17 -0
- data/node_modules/choices.js/public/types/src/scripts/interfaces/keycode-map.d.ts +13 -0
- data/node_modules/choices.js/public/types/src/scripts/interfaces/options.d.ts +566 -0
- data/node_modules/choices.js/public/types/src/scripts/interfaces/passed-element-type.d.ts +7 -0
- data/node_modules/choices.js/public/types/src/scripts/interfaces/passed-element.d.ts +95 -0
- data/node_modules/choices.js/public/types/src/scripts/interfaces/position-options-type.d.ts +1 -0
- data/node_modules/choices.js/public/types/src/scripts/interfaces/search.d.ts +11 -0
- data/node_modules/choices.js/public/types/src/scripts/interfaces/state.d.ts +10 -0
- data/node_modules/choices.js/public/types/src/scripts/interfaces/store.d.ts +64 -0
- data/node_modules/choices.js/public/types/src/scripts/interfaces/string-pre-escaped.d.ts +3 -0
- data/node_modules/choices.js/public/types/src/scripts/interfaces/string-untrusted.d.ts +4 -0
- data/node_modules/choices.js/public/types/src/scripts/interfaces/templates.d.ts +29 -0
- data/node_modules/choices.js/public/types/src/scripts/interfaces/types.d.ts +18 -0
- data/node_modules/choices.js/public/types/src/scripts/lib/choice-input.d.ts +9 -0
- data/node_modules/choices.js/public/types/src/scripts/lib/html-guard-statements.d.ts +4 -0
- data/node_modules/choices.js/public/types/src/scripts/lib/utils.d.ts +31 -0
- data/node_modules/choices.js/public/types/src/scripts/reducers/choices.d.ts +8 -0
- data/node_modules/choices.js/public/types/src/scripts/reducers/groups.d.ts +8 -0
- data/node_modules/choices.js/public/types/src/scripts/reducers/items.d.ts +9 -0
- data/node_modules/choices.js/public/types/src/scripts/search/fuse.d.ts +14 -0
- data/node_modules/choices.js/public/types/src/scripts/search/index.d.ts +3 -0
- data/node_modules/choices.js/public/types/src/scripts/search/kmp.d.ts +11 -0
- data/node_modules/choices.js/public/types/src/scripts/search/prefix-filter.d.ts +11 -0
- data/node_modules/choices.js/public/types/src/scripts/store/store.d.ts +59 -0
- data/node_modules/choices.js/public/types/src/scripts/templates.d.ts +8 -0
- data/node_modules/choices.js/src/entry.js +3 -0
- data/node_modules/choices.js/src/icons/cross-inverse.svg +1 -0
- data/node_modules/choices.js/src/icons/cross.svg +1 -0
- data/node_modules/choices.js/src/index.ts +8 -0
- data/node_modules/choices.js/src/scripts/actions/choices.ts +59 -0
- data/node_modules/choices.js/src/scripts/actions/groups.ts +14 -0
- data/node_modules/choices.js/src/scripts/actions/items.ts +34 -0
- data/node_modules/choices.js/src/scripts/choices.ts +2364 -0
- data/node_modules/choices.js/src/scripts/components/container.ts +157 -0
- data/node_modules/choices.js/src/scripts/components/dropdown.ts +50 -0
- data/node_modules/choices.js/src/scripts/components/index.ts +8 -0
- data/node_modules/choices.js/src/scripts/components/input.ts +146 -0
- data/node_modules/choices.js/src/scripts/components/list.ts +89 -0
- data/node_modules/choices.js/src/scripts/components/wrapped-element.ts +89 -0
- data/node_modules/choices.js/src/scripts/components/wrapped-input.ts +3 -0
- data/node_modules/choices.js/src/scripts/components/wrapped-select.ts +115 -0
- data/node_modules/choices.js/src/scripts/constants.ts +1 -0
- data/node_modules/choices.js/src/scripts/defaults.ts +93 -0
- data/node_modules/choices.js/src/scripts/interfaces/action-type.ts +15 -0
- data/node_modules/choices.js/src/scripts/interfaces/build-flags.ts +17 -0
- data/node_modules/choices.js/src/scripts/interfaces/choice-full.ts +30 -0
- data/node_modules/choices.js/src/scripts/interfaces/class-names.ts +61 -0
- data/node_modules/choices.js/src/scripts/interfaces/event-choice.ts +9 -0
- data/node_modules/choices.js/src/scripts/interfaces/event-type.ts +16 -0
- data/node_modules/choices.js/src/scripts/interfaces/group-full.ts +12 -0
- data/node_modules/choices.js/src/scripts/interfaces/index.ts +14 -0
- data/node_modules/choices.js/src/scripts/interfaces/input-choice.ts +17 -0
- data/node_modules/choices.js/src/scripts/interfaces/input-group.ts +11 -0
- data/node_modules/choices.js/src/scripts/interfaces/item.ts +17 -0
- data/node_modules/choices.js/src/scripts/interfaces/keycode-map.ts +13 -0
- data/node_modules/choices.js/src/scripts/interfaces/options.ts +619 -0
- data/node_modules/choices.js/src/scripts/interfaces/passed-element-type.ts +9 -0
- data/node_modules/choices.js/src/scripts/interfaces/passed-element.ts +96 -0
- data/node_modules/choices.js/src/scripts/interfaces/position-options-type.ts +1 -0
- data/node_modules/choices.js/src/scripts/interfaces/search.ts +12 -0
- data/node_modules/choices.js/src/scripts/interfaces/state.ts +12 -0
- data/node_modules/choices.js/src/scripts/interfaces/store.ts +84 -0
- data/node_modules/choices.js/src/scripts/interfaces/string-pre-escaped.ts +3 -0
- data/node_modules/choices.js/src/scripts/interfaces/string-untrusted.ts +5 -0
- data/node_modules/choices.js/src/scripts/interfaces/templates.ts +66 -0
- data/node_modules/choices.js/src/scripts/interfaces/types.ts +21 -0
- data/node_modules/choices.js/src/scripts/lib/choice-input.ts +88 -0
- data/node_modules/choices.js/src/scripts/lib/html-guard-statements.ts +7 -0
- data/node_modules/choices.js/src/scripts/lib/utils.ts +230 -0
- data/node_modules/choices.js/src/scripts/reducers/choices.ts +86 -0
- data/node_modules/choices.js/src/scripts/reducers/groups.ts +32 -0
- data/node_modules/choices.js/src/scripts/reducers/items.ts +86 -0
- data/node_modules/choices.js/src/scripts/search/fuse.ts +59 -0
- data/node_modules/choices.js/src/scripts/search/index.ts +17 -0
- data/node_modules/choices.js/src/scripts/search/kmp.ts +87 -0
- data/node_modules/choices.js/src/scripts/search/prefix-filter.ts +42 -0
- data/node_modules/choices.js/src/scripts/store/store.ts +184 -0
- data/node_modules/choices.js/src/scripts/templates.ts +409 -0
- data/node_modules/choices.js/src/styles/base.scss +189 -0
- data/node_modules/choices.js/src/styles/choices.scss +414 -0
- data/node_modules/choices.js/src/tsconfig.json +22 -0
- metadata +137 -4
- data/app/assets/images/govuk_publishing_components/action-link-arrow--dark.svg +0 -5
- data/app/assets/images/govuk_publishing_components/action-link-arrow--simple-light.svg +0 -4
- data/app/assets/images/govuk_publishing_components/action-link-arrow.svg +0 -5
@@ -1,23 +1,26 @@
|
|
1
1
|
module GovukPublishingComponents
|
2
2
|
module Presenters
|
3
3
|
class SelectHelper
|
4
|
-
|
4
|
+
include ActionView::Helpers::FormOptionsHelper
|
5
|
+
|
6
|
+
attr_reader :options, :options_markup, :error_items, :error_id, :hint, :hint_id, :describedby
|
5
7
|
|
6
8
|
def initialize(local_assigns)
|
7
9
|
@options = local_assigns[:options] || []
|
8
|
-
@
|
10
|
+
@error_items = local_assigns[:error_items] || []
|
11
|
+
@error_items << { text: local_assigns[:error_message] } if local_assigns[:error_message]
|
9
12
|
@error_id = local_assigns[:error_id] || nil
|
10
13
|
@hint = local_assigns[:hint] || nil
|
11
14
|
@hint_id = local_assigns[:hint_id] || nil
|
12
15
|
@heading_size = local_assigns[:heading_size]
|
13
16
|
@full_width = local_assigns[:full_width] || false
|
14
|
-
@
|
17
|
+
@options_markup = options_for_select(get_options, @selected_option)
|
15
18
|
@describedby = get_describedby
|
16
19
|
end
|
17
20
|
|
18
21
|
def css_classes
|
19
22
|
classes = %w[govuk-form-group gem-c-select]
|
20
|
-
classes << "govuk-form-group--error" if @
|
23
|
+
classes << "govuk-form-group--error" if @error_items.present?
|
21
24
|
classes
|
22
25
|
end
|
23
26
|
|
@@ -66,7 +69,7 @@ module GovukPublishingComponents
|
|
66
69
|
def get_describedby
|
67
70
|
describedby = %w[]
|
68
71
|
|
69
|
-
if @
|
72
|
+
if @error_items.present? || @error_id
|
70
73
|
@error_id ||= "error-#{SecureRandom.hex(4)}"
|
71
74
|
describedby << @error_id
|
72
75
|
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
##
|
2
|
+
# Helper methods for use with the "select-with-search" component.
|
3
|
+
# This wraps and extends the Select component's helper methods to add support for option groups.
|
4
|
+
##
|
5
|
+
module GovukPublishingComponents
|
6
|
+
module Presenters
|
7
|
+
class SelectWithSearchHelper
|
8
|
+
include ActionView::Helpers::FormOptionsHelper
|
9
|
+
|
10
|
+
attr_reader :options, :selected_options, :aria, :options_markup
|
11
|
+
|
12
|
+
delegate :describedby,
|
13
|
+
:hint_id,
|
14
|
+
:hint,
|
15
|
+
:label_classes,
|
16
|
+
:select_classes,
|
17
|
+
:error_items,
|
18
|
+
:error_id,
|
19
|
+
to: :@select_helper
|
20
|
+
|
21
|
+
def initialize(local_assigns)
|
22
|
+
@select_helper = SelectHelper.new(local_assigns.except(:options, :grouped_options))
|
23
|
+
@options = local_assigns[:options]
|
24
|
+
@grouped_options = local_assigns[:grouped_options]
|
25
|
+
@include_blank = local_assigns[:include_blank]
|
26
|
+
@selected_options = []
|
27
|
+
@options_markup = get_options
|
28
|
+
@local_assigns = local_assigns
|
29
|
+
end
|
30
|
+
|
31
|
+
def css_classes
|
32
|
+
classes = @select_helper.css_classes
|
33
|
+
classes << "gem-c-select-with-search"
|
34
|
+
classes
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def get_options
|
40
|
+
blank_option_if_include_blank +
|
41
|
+
if @grouped_options.present?
|
42
|
+
grouped_and_ungrouped_options_for_select(@grouped_options)
|
43
|
+
elsif @options.present?
|
44
|
+
options_for_select(
|
45
|
+
transform_options(@options),
|
46
|
+
selected_options,
|
47
|
+
)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def grouped_and_ungrouped_options_for_select(unsorted_options)
|
52
|
+
# Filter out the 'single option' options and treat them as simply `<option>`
|
53
|
+
# The remainder should be treated as true 'grouped options', i.e. `<optgroup>`
|
54
|
+
single_options = []
|
55
|
+
grouped_options = []
|
56
|
+
unsorted_options.each_with_index do |(group, options), _index|
|
57
|
+
if group == ""
|
58
|
+
single_options << options
|
59
|
+
else
|
60
|
+
grouped_options << [group, options]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
single_options.flatten!
|
64
|
+
|
65
|
+
options_for_select(transform_options(single_options), selected_options) +
|
66
|
+
grouped_options_for_select(transform_grouped_options(grouped_options), selected_options)
|
67
|
+
end
|
68
|
+
|
69
|
+
def transform_options(options)
|
70
|
+
options.map do |option|
|
71
|
+
@selected_options << option[:value] if option[:selected]
|
72
|
+
[
|
73
|
+
option[:text],
|
74
|
+
option[:value],
|
75
|
+
]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def transform_grouped_options(grouped_options)
|
80
|
+
grouped_options.map do |(group, options)|
|
81
|
+
[group, transform_options(options)]
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def blank_option_if_include_blank
|
86
|
+
return "".html_safe if @include_blank.blank?
|
87
|
+
|
88
|
+
options_for_select([["", ""]])
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -27,6 +27,7 @@ require "govuk_publishing_components/presenters/content_breadcrumbs_based_on_org
|
|
27
27
|
require "govuk_publishing_components/presenters/content_breadcrumbs_based_on_taxons"
|
28
28
|
require "govuk_publishing_components/presenters/checkboxes_helper"
|
29
29
|
require "govuk_publishing_components/presenters/select_helper"
|
30
|
+
require "govuk_publishing_components/presenters/select_with_search_helper"
|
30
31
|
require "govuk_publishing_components/presenters/meta_tags"
|
31
32
|
require "govuk_publishing_components/presenters/content_item"
|
32
33
|
require "govuk_publishing_components/presenters/translation_nav_helper"
|
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Josh Johnson
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|