govuk_design_system_formbuilder 2.7.1 → 2.7.2

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: 710ba81f8f737d55dd18626c24a9353862d9b53886127a064e5dc10ddf6fd750
4
- data.tar.gz: e82e7198bf059a97d9b0cb9ce0659133b8082dfac2e71c7c37fc4ff3ff1e38fa
3
+ metadata.gz: 06a3aa374a6a6fa23d1fb52cdb7585fe50e067580328683b5dcbbcd8c6444aab
4
+ data.tar.gz: 15c814a5314cbf8aa97fd9e8d47c640062286d6a2239be89265015f6eafab172
5
5
  SHA512:
6
- metadata.gz: cd1fee6e4db64215afaa4ceb8083138ee01f11407137cf5885bf8823e0e86cf34ef27e7178118e2a10fe82eef82ce22163d7cef6e1f8f953e5356dde0de1fe96
7
- data.tar.gz: c5b20b72db3dd9598fe20e3c42527b715cca82d936bd53a9255b7033fff6620fd631e74f3072d5092852b838be89ebb4dd3b04d567c711a17d6a909e52a0eed3
6
+ metadata.gz: c4319d5fbd9168b1869aa94a1206f57c50f4e2d1a238a06da0bbcae0a55b82a020895ca1cfc59de86fdb9ee0248cbd283a3f5b22142946b9951a96906e870c9e
7
+ data.tar.gz: eec0ec045b248bd16cf671b4d289ea91429338693c541c74c30d92d481b2f2a833c490b064ed58bce7e95a49af03725faa6cb58b0222f0a5411153d1673d4a89
@@ -57,7 +57,7 @@ module GOVUKDesignSystemFormBuilder
57
57
  @builder.object.errors.messages[@attribute_name].present?
58
58
  end
59
59
 
60
- def described_by(*ids)
60
+ def combine_references(*ids)
61
61
  ids.flatten.compact
62
62
  end
63
63
 
@@ -22,7 +22,7 @@ module GOVUKDesignSystemFormBuilder
22
22
  end
23
23
 
24
24
  def classes
25
- [%(#{brand}-checkboxes), small_class, custom_classes].flatten.compact
25
+ combine_references(%(#{brand}-checkboxes), small_class, custom_classes)
26
26
  end
27
27
 
28
28
  def small_class
@@ -5,6 +5,8 @@ module GOVUKDesignSystemFormBuilder
5
5
  include Traits::Hint
6
6
 
7
7
  def initialize(builder, object_name, attribute_name, hint:, legend:, caption:, small:, classes:, form_group:, multiple:, &block)
8
+ fail LocalJumpError, 'no block given' unless block_given?
9
+
8
10
  super(builder, object_name, attribute_name, &block)
9
11
 
10
12
  @legend = legend
@@ -14,7 +16,6 @@ module GOVUKDesignSystemFormBuilder
14
16
  @classes = classes
15
17
  @form_group = form_group
16
18
  @multiple = multiple
17
- @block_content = capture { block.call }
18
19
  end
19
20
 
20
21
  def html
@@ -8,7 +8,7 @@ module GOVUKDesignSystemFormBuilder
8
8
 
9
9
  @legend = legend
10
10
  @caption = caption
11
- @described_by = described_by(described_by)
11
+ @described_by = combine_references(described_by)
12
12
  @attribute_name = attribute_name
13
13
  @html_attributes = kwargs
14
14
  end
@@ -15,7 +15,7 @@ module GOVUKDesignSystemFormBuilder
15
15
  private
16
16
 
17
17
  def classes
18
- [form_group_class, error_class, custom_classes].flatten.compact
18
+ combine_references(form_group_class, error_class, custom_classes)
19
19
  end
20
20
 
21
21
  def form_group_class
@@ -5,7 +5,9 @@ module GOVUKDesignSystemFormBuilder
5
5
  include Traits::Error
6
6
 
7
7
  def initialize(builder, object_name, attribute_name, hint:, legend:, caption:, inline:, small:, classes:, form_group:, &block)
8
- super(builder, object_name, attribute_name)
8
+ fail LocalJumpError, 'no block given' unless block_given?
9
+
10
+ super(builder, object_name, attribute_name, &block)
9
11
 
10
12
  @inline = inline
11
13
  @small = small
@@ -14,7 +16,6 @@ module GOVUKDesignSystemFormBuilder
14
16
  @hint = hint
15
17
  @classes = classes
16
18
  @form_group = form_group
17
- @block_content = capture { block.call }
18
19
  end
19
20
 
20
21
  def html
@@ -25,7 +25,7 @@ module GOVUKDesignSystemFormBuilder
25
25
  end
26
26
 
27
27
  def classes
28
- [%(#{brand}-radios), inline_class, small_class, custom_classes].flatten.compact
28
+ combine_references(%(#{brand}-radios), inline_class, small_class, custom_classes)
29
29
  end
30
30
 
31
31
  def inline_class
@@ -8,7 +8,7 @@ module GOVUKDesignSystemFormBuilder
8
8
  include Traits::FieldsetItem
9
9
 
10
10
  def initialize(builder, object_name, attribute_name, value, unchecked_value, label:, hint:, link_errors:, multiple:, exclusive:, **kwargs, &block)
11
- super(builder, object_name, attribute_name)
11
+ super(builder, object_name, attribute_name, &block)
12
12
 
13
13
  @value = value
14
14
  @unchecked_value = unchecked_value
@@ -19,7 +19,7 @@ module GOVUKDesignSystemFormBuilder
19
19
  @html_attributes = kwargs
20
20
  @exclusive = exclusive
21
21
 
22
- conditional_content(&block)
22
+ conditional_content(@block_content)
23
23
  end
24
24
 
25
25
  private
@@ -40,7 +40,7 @@ module GOVUKDesignSystemFormBuilder
40
40
  {
41
41
  id: field_id(link_errors: true),
42
42
  class: classes,
43
- aria: { describedby: described_by(hint_id, error_id, supplemental_id) }
43
+ aria: { describedby: combine_references(hint_id, error_id, supplemental_id) }
44
44
  }
45
45
  end
46
46
 
@@ -35,7 +35,7 @@ module GOVUKDesignSystemFormBuilder
35
35
  {
36
36
  id: field_id(link_errors: true),
37
37
  class: classes,
38
- aria: { describedby: described_by(hint_id, error_id, supplemental_id) }
38
+ aria: { describedby: combine_references(hint_id, error_id, supplemental_id) }
39
39
  }
40
40
  end
41
41
 
@@ -8,7 +8,7 @@ module GOVUKDesignSystemFormBuilder
8
8
  include Traits::FieldsetItem
9
9
 
10
10
  def initialize(builder, object_name, attribute_name, value, label:, hint:, link_errors:, **kwargs, &block)
11
- super(builder, object_name, attribute_name)
11
+ super(builder, object_name, attribute_name, &block)
12
12
 
13
13
  @value = value
14
14
  @label = label
@@ -16,7 +16,7 @@ module GOVUKDesignSystemFormBuilder
16
16
  @link_errors = has_errors? && link_errors
17
17
  @html_attributes = kwargs
18
18
 
19
- conditional_content(&block)
19
+ conditional_content(@block_content)
20
20
  end
21
21
 
22
22
  private
@@ -38,7 +38,7 @@ module GOVUKDesignSystemFormBuilder
38
38
  {
39
39
  id: field_id(link_errors: true),
40
40
  class: classes,
41
- aria: { describedby: described_by(hint_id, error_id) }
41
+ aria: { describedby: combine_references(hint_id, error_id) }
42
42
  }
43
43
  end
44
44
  end
@@ -53,7 +53,7 @@ module GOVUKDesignSystemFormBuilder
53
53
  id: field_id(link_errors: true),
54
54
  class: classes,
55
55
  rows: @rows,
56
- aria: { describedby: described_by(hint_id, error_id, supplemental_id, limit_description_id) },
56
+ aria: { describedby: combine_references(hint_id, error_id, supplemental_id, limit_description_id) },
57
57
  }
58
58
  end
59
59
 
@@ -4,7 +4,7 @@ module GOVUKDesignSystemFormBuilder
4
4
  using PrefixableArray
5
5
 
6
6
  def html
7
- safe_join([item, @conditional])
7
+ safe_join([item, @conditional_content])
8
8
  end
9
9
 
10
10
  private
@@ -61,9 +61,9 @@ module GOVUKDesignSystemFormBuilder
61
61
  build_id('conditional')
62
62
  end
63
63
 
64
- def conditional_content(&block)
65
- if (conditional_block_content = block_given? && (capture { block.call }).presence)
66
- @conditional = conditional_container(conditional_block_content)
64
+ def conditional_content(block_content)
65
+ if block_content.present?
66
+ @conditional_content = conditional_container(block_content)
67
67
  @conditional_id = conditional_id
68
68
  end
69
69
  end
@@ -48,7 +48,7 @@ module GOVUKDesignSystemFormBuilder
48
48
  {
49
49
  id: field_id(link_errors: true),
50
50
  class: classes,
51
- aria: { describedby: described_by(hint_id, error_id, supplemental_id) }
51
+ aria: { describedby: combine_references(hint_id, error_id, supplemental_id) }
52
52
  }
53
53
  end
54
54
 
@@ -4,7 +4,7 @@ module GOVUKDesignSystemFormBuilder
4
4
  private
5
5
 
6
6
  def classes
7
- [%(#{brand}-select), error_class].flatten.compact
7
+ combine_references(%(#{brand}-select), error_class)
8
8
  end
9
9
 
10
10
  def error_class
@@ -1,3 +1,3 @@
1
1
  module GOVUKDesignSystemFormBuilder
2
- VERSION = '2.7.1'.freeze
2
+ VERSION = '2.7.2'.freeze
3
3
  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.7.1
4
+ version: 2.7.2
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-06-25 00:00:00.000000000 Z
11
+ date: 2021-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deep_merge