govuk_design_system_formbuilder 2.3.0b1 → 2.3.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/lib/govuk_design_system_formbuilder/base.rb +9 -0
- data/lib/govuk_design_system_formbuilder/builder.rb +0 -1
- data/lib/govuk_design_system_formbuilder/containers/check_boxes_fieldset.rb +2 -2
- data/lib/govuk_design_system_formbuilder/containers/fieldset.rb +1 -1
- data/lib/govuk_design_system_formbuilder/containers/radio_buttons_fieldset.rb +2 -2
- data/lib/govuk_design_system_formbuilder/containers/supplemental.rb +1 -1
- data/lib/govuk_design_system_formbuilder/elements/caption.rb +3 -3
- data/lib/govuk_design_system_formbuilder/elements/check_boxes/collection.rb +2 -2
- data/lib/govuk_design_system_formbuilder/elements/check_boxes/collection_check_box.rb +2 -2
- data/lib/govuk_design_system_formbuilder/elements/date.rb +4 -4
- data/lib/govuk_design_system_formbuilder/elements/error_message.rb +1 -1
- data/lib/govuk_design_system_formbuilder/elements/error_summary.rb +1 -1
- data/lib/govuk_design_system_formbuilder/elements/file.rb +1 -1
- data/lib/govuk_design_system_formbuilder/elements/hint.rb +1 -1
- data/lib/govuk_design_system_formbuilder/elements/label.rb +3 -3
- data/lib/govuk_design_system_formbuilder/elements/legend.rb +3 -5
- data/lib/govuk_design_system_formbuilder/elements/radios/collection.rb +3 -3
- data/lib/govuk_design_system_formbuilder/elements/radios/collection_radio_button.rb +2 -2
- data/lib/govuk_design_system_formbuilder/elements/select.rb +1 -1
- data/lib/govuk_design_system_formbuilder/elements/submit.rb +5 -5
- data/lib/govuk_design_system_formbuilder/elements/text_area.rb +3 -3
- data/lib/govuk_design_system_formbuilder/traits/caption.rb +1 -1
- data/lib/govuk_design_system_formbuilder/traits/error.rb +2 -2
- data/lib/govuk_design_system_formbuilder/traits/fieldset_item.rb +2 -2
- data/lib/govuk_design_system_formbuilder/traits/hint.rb +2 -2
- data/lib/govuk_design_system_formbuilder/traits/input.rb +4 -4
- data/lib/govuk_design_system_formbuilder/traits/label.rb +1 -1
- data/lib/govuk_design_system_formbuilder/traits/supplemental.rb +2 -2
- data/lib/govuk_design_system_formbuilder/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f56b92f232ffd2b98c38637c49b2e4255f3be12cab3825f795a735cbfae0107
|
4
|
+
data.tar.gz: 0f4dfd572130559b3140a838310ce471a4adee41f46fed32ca5046cfa29ed9d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67861fee01f6a14cac7bbf9db87d1633dcf13e569aaa2179f5e16d21f8aed5e7b7d553a5bd96e601ab5b4181e6c27c905fa5fd6d7e80c811a2cff28d42b1f83f
|
7
|
+
data.tar.gz: a889d6d02fd1978e73aa2328debc5b6268993eca88755b3cf31889dfe4c973d28e09dfb9d13bbe462347aeea74a1f46dfb8ba8f4f7c20ad3da5c2c8d1d6aa114
|
@@ -25,6 +25,15 @@ module GOVUKDesignSystemFormBuilder
|
|
25
25
|
|
26
26
|
private
|
27
27
|
|
28
|
+
# returns the attributes bound to the object that are
|
29
|
+
# required to build all contained elements
|
30
|
+
#
|
31
|
+
# @return [GOVUKDesignSystemFormBuilder::FormBuilder, Symbol, Symbol] an array containing the
|
32
|
+
# builder, object name and attribute name
|
33
|
+
def bound
|
34
|
+
[@builder, @object_name, @attribute_name]
|
35
|
+
end
|
36
|
+
|
28
37
|
def brand(override = nil)
|
29
38
|
override || config.brand
|
30
39
|
end
|
@@ -387,7 +387,6 @@ module GOVUKDesignSystemFormBuilder
|
|
387
387
|
# @option label hidden [Boolean] control the visability of the label. Hidden labels will stil be read by screenreaders
|
388
388
|
# @option label kwargs [Hash] additional arguments are applied as attributes on the +label+ element
|
389
389
|
# @param options [Hash] Options hash passed through to Rails' +collection_select+ helper
|
390
|
-
# @param html_options [Hash] HTML Options hash passed through to Rails' +collection_select+ helper
|
391
390
|
# @param form_group [Hash] configures the form group
|
392
391
|
# @option form_group classes [Array,String] sets the form group's classes
|
393
392
|
# @option form_group kwargs [Hash] additional attributes added to the form group
|
@@ -18,8 +18,8 @@ module GOVUKDesignSystemFormBuilder
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def html
|
21
|
-
Containers::FormGroup.new(
|
22
|
-
Containers::Fieldset.new(
|
21
|
+
Containers::FormGroup.new(*bound, **@form_group).html do
|
22
|
+
Containers::Fieldset.new(*bound, **fieldset_options).html do
|
23
23
|
safe_join([hint_element, error_element, hidden_field, checkboxes])
|
24
24
|
end
|
25
25
|
end
|
@@ -18,8 +18,8 @@ module GOVUKDesignSystemFormBuilder
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def html
|
21
|
-
Containers::FormGroup.new(
|
22
|
-
Containers::Fieldset.new(
|
21
|
+
Containers::FormGroup.new(*bound, **@form_group).html do
|
22
|
+
Containers::Fieldset.new(*bound, **fieldset_options).html do
|
23
23
|
safe_join([hint_element, error_element, radios])
|
24
24
|
end
|
25
25
|
end
|
@@ -3,7 +3,7 @@ module GOVUKDesignSystemFormBuilder
|
|
3
3
|
class Caption < Base
|
4
4
|
include Traits::Localisation
|
5
5
|
|
6
|
-
def initialize(builder, object_name, attribute_name, text: nil, size:
|
6
|
+
def initialize(builder, object_name, attribute_name, text: nil, size: config.default_caption_size, **kwargs)
|
7
7
|
super(builder, object_name, attribute_name)
|
8
8
|
|
9
9
|
@text = text(text)
|
@@ -12,7 +12,7 @@ module GOVUKDesignSystemFormBuilder
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def html
|
15
|
-
return
|
15
|
+
return unless active?
|
16
16
|
|
17
17
|
tag.span(@text, class: @size_class, **@html_attributes)
|
18
18
|
end
|
@@ -28,7 +28,7 @@ module GOVUKDesignSystemFormBuilder
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def size_class(size)
|
31
|
-
case size
|
31
|
+
case size
|
32
32
|
when 'xl' then %(#{brand}-caption-xl)
|
33
33
|
when 'l' then %(#{brand}-caption-l)
|
34
34
|
when 'm' then %(#{brand}-caption-m)
|
@@ -23,8 +23,8 @@ module GOVUKDesignSystemFormBuilder
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def html
|
26
|
-
Containers::FormGroup.new(
|
27
|
-
Containers::Fieldset.new(
|
26
|
+
Containers::FormGroup.new(*bound, **@form_group).html do
|
27
|
+
Containers::Fieldset.new(*bound, **fieldset_options).html do
|
28
28
|
safe_join([supplemental_content, hint_element, error_element, check_boxes])
|
29
29
|
end
|
30
30
|
end
|
@@ -36,11 +36,11 @@ module GOVUKDesignSystemFormBuilder
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def label_element
|
39
|
-
@label_element ||= Label.new(
|
39
|
+
@label_element ||= Label.new(*bound, @checkbox, value: @value, link_errors: @link_errors)
|
40
40
|
end
|
41
41
|
|
42
42
|
def hint_element
|
43
|
-
@hint_element ||= Elements::Hint.new(
|
43
|
+
@hint_element ||= Elements::Hint.new(*bound, **hint_options, **hint_content)
|
44
44
|
end
|
45
45
|
|
46
46
|
def hint_options
|
@@ -23,8 +23,8 @@ module GOVUKDesignSystemFormBuilder
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def html
|
26
|
-
Containers::FormGroup.new(
|
27
|
-
Containers::Fieldset.new(
|
26
|
+
Containers::FormGroup.new(*bound, **@form_group, **@html_attributes).html do
|
27
|
+
Containers::Fieldset.new(*bound, **fieldset_options).html do
|
28
28
|
safe_join([supplemental_content, hint_element, error_element, date])
|
29
29
|
end
|
30
30
|
end
|
@@ -47,7 +47,7 @@ module GOVUKDesignSystemFormBuilder
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def day
|
50
|
-
return
|
50
|
+
return if omit_day?
|
51
51
|
|
52
52
|
date_part(:day, width: 2, link_errors: true)
|
53
53
|
end
|
@@ -125,7 +125,7 @@ module GOVUKDesignSystemFormBuilder
|
|
125
125
|
end
|
126
126
|
|
127
127
|
def date_of_birth_autocomplete_value(segment)
|
128
|
-
return
|
128
|
+
return unless @date_of_birth
|
129
129
|
|
130
130
|
{ day: 'bday-day', month: 'bday-month', year: 'bday-year' }.fetch(segment)
|
131
131
|
end
|
@@ -20,7 +20,7 @@ module GOVUKDesignSystemFormBuilder
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def html
|
23
|
-
Containers::FormGroup.new(
|
23
|
+
Containers::FormGroup.new(*bound, **@form_group).html do
|
24
24
|
safe_join([label_element, supplemental_content, hint_element, error_element, file])
|
25
25
|
end
|
26
26
|
end
|
@@ -28,7 +28,7 @@ module GOVUKDesignSystemFormBuilder
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def html
|
31
|
-
return
|
31
|
+
return unless active?
|
32
32
|
|
33
33
|
if @tag.present?
|
34
34
|
content_tag(@tag, class: %(#{brand}-label-wrapper)) { label }
|
@@ -72,13 +72,13 @@ module GOVUKDesignSystemFormBuilder
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def radio_class
|
75
|
-
return
|
75
|
+
return unless @radio
|
76
76
|
|
77
77
|
%(#{brand}-radios__label)
|
78
78
|
end
|
79
79
|
|
80
80
|
def checkbox_class
|
81
|
-
return
|
81
|
+
return unless @checkbox
|
82
82
|
|
83
83
|
%(#{brand}-checkboxes__label)
|
84
84
|
end
|
@@ -39,11 +39,9 @@ module GOVUKDesignSystemFormBuilder
|
|
39
39
|
def legend_content
|
40
40
|
caption_and_text = safe_join([caption_element, @text])
|
41
41
|
|
42
|
-
if @tag.
|
43
|
-
|
44
|
-
|
45
|
-
caption_and_text
|
46
|
-
end
|
42
|
+
return caption_and_text if @tag.blank?
|
43
|
+
|
44
|
+
content_tag(@tag, class: heading_classes) { caption_and_text }
|
47
45
|
end
|
48
46
|
|
49
47
|
def retrieve_text(supplied_text)
|
@@ -25,8 +25,8 @@ module GOVUKDesignSystemFormBuilder
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def html
|
28
|
-
Containers::FormGroup.new(
|
29
|
-
Containers::Fieldset.new(
|
28
|
+
Containers::FormGroup.new(*bound, **@form_group).html do
|
29
|
+
Containers::Fieldset.new(*bound, **fieldset_options).html do
|
30
30
|
safe_join([hidden_field, supplemental_content, hint_element, error_element, radios])
|
31
31
|
end
|
32
32
|
end
|
@@ -56,7 +56,7 @@ module GOVUKDesignSystemFormBuilder
|
|
56
56
|
|
57
57
|
def collection
|
58
58
|
@collection.map.with_index do |item, i|
|
59
|
-
Elements::Radios::CollectionRadioButton.new(
|
59
|
+
Elements::Radios::CollectionRadioButton.new(*bound, item, **collection_options(i)).html
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
@@ -41,7 +41,7 @@ module GOVUKDesignSystemFormBuilder
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def hint_element
|
44
|
-
@hint_element ||= Elements::Hint.new(
|
44
|
+
@hint_element ||= Elements::Hint.new(*bound, **hint_options, **hint_content)
|
45
45
|
end
|
46
46
|
|
47
47
|
def hint_content
|
@@ -53,7 +53,7 @@ module GOVUKDesignSystemFormBuilder
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def label_element
|
56
|
-
@label_element ||= Elements::Label.new(
|
56
|
+
@label_element ||= Elements::Label.new(*bound, **label_options)
|
57
57
|
end
|
58
58
|
|
59
59
|
def label_options
|
@@ -28,7 +28,7 @@ module GOVUKDesignSystemFormBuilder
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def html
|
31
|
-
Containers::FormGroup.new(
|
31
|
+
Containers::FormGroup.new(*bound, **@form_group).html do
|
32
32
|
safe_join([label_element, supplemental_content, hint_element, error_element, select])
|
33
33
|
end
|
34
34
|
end
|
@@ -21,19 +21,19 @@ module GOVUKDesignSystemFormBuilder
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def html
|
24
|
-
@block_content.present? ? button_group :
|
24
|
+
@block_content.present? ? button_group : submit
|
25
25
|
end
|
26
26
|
|
27
27
|
private
|
28
28
|
|
29
|
-
def buttons
|
30
|
-
safe_join([submit, @block_content])
|
31
|
-
end
|
32
|
-
|
33
29
|
def button_group
|
34
30
|
Containers::ButtonGroup.new(@builder, buttons).html
|
35
31
|
end
|
36
32
|
|
33
|
+
def buttons
|
34
|
+
safe_join([submit, @block_content])
|
35
|
+
end
|
36
|
+
|
37
37
|
def submit
|
38
38
|
@builder.submit(@text, **attributes(@html_attributes))
|
39
39
|
end
|
@@ -25,7 +25,7 @@ module GOVUKDesignSystemFormBuilder
|
|
25
25
|
|
26
26
|
def html
|
27
27
|
Containers::CharacterCount.new(@builder, **character_count_options).html do
|
28
|
-
Containers::FormGroup.new(
|
28
|
+
Containers::FormGroup.new(*bound, **@form_group).html do
|
29
29
|
safe_join([label_element, supplemental_content, hint_element, error_element, text_area, limit_description])
|
30
30
|
end
|
31
31
|
end
|
@@ -78,7 +78,7 @@ module GOVUKDesignSystemFormBuilder
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def limit_description
|
81
|
-
return
|
81
|
+
return unless limit?
|
82
82
|
|
83
83
|
tag.span(id: limit_id, class: limit_description_classes, aria: { live: 'polite' }) do
|
84
84
|
"You can enter up to #{limit_quantity} #{limit_type}"
|
@@ -90,7 +90,7 @@ module GOVUKDesignSystemFormBuilder
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def limit_description_id
|
93
|
-
return
|
93
|
+
return unless limit?
|
94
94
|
|
95
95
|
limit_id
|
96
96
|
end
|
@@ -2,7 +2,7 @@ module GOVUKDesignSystemFormBuilder
|
|
2
2
|
module Traits
|
3
3
|
module Error
|
4
4
|
def error_id
|
5
|
-
return
|
5
|
+
return unless has_errors?
|
6
6
|
|
7
7
|
build_id('error')
|
8
8
|
end
|
@@ -10,7 +10,7 @@ module GOVUKDesignSystemFormBuilder
|
|
10
10
|
private
|
11
11
|
|
12
12
|
def error_element
|
13
|
-
@error_element ||= Elements::ErrorMessage.new(
|
13
|
+
@error_element ||= Elements::ErrorMessage.new(*bound)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -7,7 +7,7 @@ module GOVUKDesignSystemFormBuilder
|
|
7
7
|
@label_element ||= if @label.nil?
|
8
8
|
Elements::Null.new
|
9
9
|
else
|
10
|
-
Elements::Label.new(
|
10
|
+
Elements::Label.new(*bound, **label_content, **label_options)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -19,7 +19,7 @@ module GOVUKDesignSystemFormBuilder
|
|
19
19
|
@hint_element ||= if @hint.nil?
|
20
20
|
Elements::Null.new
|
21
21
|
else
|
22
|
-
Elements::Hint.new(
|
22
|
+
Elements::Hint.new(*bound, **hint_options, **hint_content)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -2,7 +2,7 @@ module GOVUKDesignSystemFormBuilder
|
|
2
2
|
module Traits
|
3
3
|
module Hint
|
4
4
|
def hint_id
|
5
|
-
return
|
5
|
+
return unless hint_element.active?
|
6
6
|
|
7
7
|
build_id('hint')
|
8
8
|
end
|
@@ -13,7 +13,7 @@ module GOVUKDesignSystemFormBuilder
|
|
13
13
|
@hint_element ||= if @hint.nil?
|
14
14
|
Elements::Null.new
|
15
15
|
else
|
16
|
-
Elements::Hint.new(
|
16
|
+
Elements::Hint.new(*bound, **hint_content)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -15,7 +15,7 @@ module GOVUKDesignSystemFormBuilder
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def html
|
18
|
-
Containers::FormGroup.new(
|
18
|
+
Containers::FormGroup.new(*bound, **@form_group).html do
|
19
19
|
safe_join([label_element, supplemental_content, hint_element, error_element, content])
|
20
20
|
end
|
21
21
|
end
|
@@ -31,7 +31,7 @@ module GOVUKDesignSystemFormBuilder
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def affixed_input
|
34
|
-
|
34
|
+
tag.div(class: %(#{brand}-input__wrapper)) do
|
35
35
|
safe_join([prefix, input, suffix])
|
36
36
|
end
|
37
37
|
end
|
@@ -86,13 +86,13 @@ module GOVUKDesignSystemFormBuilder
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def prefix
|
89
|
-
return
|
89
|
+
return if @prefix_text.blank?
|
90
90
|
|
91
91
|
tag.span(@prefix_text, class: %(#{brand}-input__prefix), **affix_options)
|
92
92
|
end
|
93
93
|
|
94
94
|
def suffix
|
95
|
-
return
|
95
|
+
return if @suffix_text.blank?
|
96
96
|
|
97
97
|
tag.span(@suffix_text, class: %(#{brand}-input__suffix), **affix_options)
|
98
98
|
end
|
@@ -7,7 +7,7 @@ module GOVUKDesignSystemFormBuilder
|
|
7
7
|
@label_element ||= if @label.nil?
|
8
8
|
Elements::Null.new
|
9
9
|
else
|
10
|
-
Elements::Label.new(
|
10
|
+
Elements::Label.new(*bound, caption: @caption, **label_content)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -2,7 +2,7 @@ module GOVUKDesignSystemFormBuilder
|
|
2
2
|
module Traits
|
3
3
|
module Supplemental
|
4
4
|
def supplemental_id
|
5
|
-
return
|
5
|
+
return if @block_content.blank?
|
6
6
|
|
7
7
|
build_id('supplemental')
|
8
8
|
end
|
@@ -10,7 +10,7 @@ module GOVUKDesignSystemFormBuilder
|
|
10
10
|
private
|
11
11
|
|
12
12
|
def supplemental_content
|
13
|
-
@supplemental_content ||= Containers::Supplemental.new(
|
13
|
+
@supplemental_content ||= Containers::Supplemental.new(*bound, @block_content)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk_design_system_formbuilder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Yates
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deep_merge
|
@@ -347,9 +347,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
347
347
|
version: '0'
|
348
348
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
349
349
|
requirements:
|
350
|
-
- - "
|
350
|
+
- - ">="
|
351
351
|
- !ruby/object:Gem::Version
|
352
|
-
version:
|
352
|
+
version: '0'
|
353
353
|
requirements: []
|
354
354
|
rubygems_version: 3.1.4
|
355
355
|
signing_key:
|