govuk_design_system_formbuilder 6.1.0 → 6.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: 59950d2e47e3ad35319e27cdb1e17e2df0564801a7e826baa688535549c5bdc5
4
- data.tar.gz: 1e929e58ae4f08ba5a38a74c5719609fb7e53b365bbd86e6e41100adba40ac41
3
+ metadata.gz: 2cf25eca1fc9e5160b36b37bd946844b4662453bb3d7ad41761b669b3ee8bebe
4
+ data.tar.gz: 7173d16c0574e1f4e2477c08ffe2a0bdc5325047d323dd21427d8fc2bdf42b31
5
5
  SHA512:
6
- metadata.gz: f548176983fcaa0ca23708f7cf56244a1e1b0f70501ad48ee5b6461baf3381b088c329cd5140fdd534a765ae673cba564ce6af5d943abc3b05027478c4958536
7
- data.tar.gz: 4ae536feca91926575a076231a3029b2ee962dffc4614ae7186d77c103fe8fccfcc411dfc6ad335df1f33eca979973d863531801a46659b73c2f69205a26ac05
6
+ metadata.gz: 2b34a3a4c6792f6bcfd13c0415f07b9e144e64d97350d9c6cb700feffbc1b90242f05f765ae292523a87ccf212528687c42285442f2b4eab8d9c46ec8a9aa594
7
+ data.tar.gz: ad04540f4c3788b828e154c67b733fdb63fbd46a708e3f83b94400d57ae5016095ab9203c4603c22a4c49f9d01b054590679142fc3e90ee5f852c92bc30960ec
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![Gem version](https://badge.fury.io/rb/govuk_design_system_formbuilder.svg)](https://badge.fury.io/rb/govuk_design_system_formbuilder)
5
5
  [![Gem](https://img.shields.io/gem/dt/govuk_design_system_formbuilder?logo=rubygems)](https://rubygems.org/gems/govuk_design_system_formbuilder)
6
6
  ![GitHub license](https://img.shields.io/github/license/x-govuk/govuk-form-builder)
7
- [![GOV.UK Design System version](https://img.shields.io/badge/GOV.UK%20Design%20System-6.1.0-brightgreen)](https://design-system.service.gov.uk)
7
+ [![GOV.UK Design System version](https://img.shields.io/badge/GOV.UK%20Design%20System-6.2.0-brightgreen)](https://design-system.service.gov.uk)
8
8
  [![Rails](https://img.shields.io/badge/Rails-7.2.3%20%E2%95%B1%208.0.1%20%E2%95%B1%208.1.2-E16D6D)](https://weblog.rubyonrails.org/releases/)
9
9
  [![Ruby](https://img.shields.io/badge/Ruby-3.2.10%20%20%E2%95%B1%203.4.8%20%20%E2%95%B1%204.0.1-E16D6D)](https://www.ruby-lang.org/en/downloads/)
10
10
 
@@ -385,6 +385,11 @@ module GOVUKDesignSystemFormBuilder
385
385
  # @option form_group kwargs [Hash] additional attributes added to the form group
386
386
  # @option kwargs [Hash] kwargs additional arguments are applied as attributes to the +textarea+ element
387
387
  # @param block [Block] arbitrary HTML that will be rendered between the hint and the input
388
+ # @param characters_under_limit_other_text [String] Text that informs the user they have X word/characters remaining. Default is "%{count} characters to go". If javascript is not provided, this option will be ignored.
389
+ # @param characters_under_limit_one_text [String] Text that informs the user they have 1 word/character remaining. Default is "%{count} character to go". If javascript is not provided, this option will be ignored.
390
+ # @param characters_at_limit_text [String] The text that informs the user they've reached the character limit. Default is "No characters left". If javascript is not provided, this option will be ignored.
391
+ # @param characters_over_limit_other_text [String] Text that informs the user they have added X words/characters too many. Default is "%{count} characters to go". If javascript is not provided, this option will be ignored.
392
+ # @param characters_over_limit_one_text [String] Text that informs the user they have added 1 word/character too many. Default is "%{count} character to go". If javascript is not provided, this option will be ignored.
388
393
  # @return [ActiveSupport::SafeBuffer] HTML output
389
394
  # @see https://design-system.service.gov.uk/components/textarea/ GOV.UK text area component
390
395
  # @see https://design-system.service.gov.uk/components/character-count GOV.UK character count component
@@ -409,8 +414,46 @@ module GOVUKDesignSystemFormBuilder
409
414
  # = f.govuk_text_area :instructions,
410
415
  # label: -> { tag.h3("How do you set it up?") }
411
416
  #
412
- def govuk_text_area(attribute_name, hint: {}, label: {}, caption: {}, max_words: nil, max_chars: nil, rows: 5, threshold: nil, form_group: {}, **kwargs, &block)
413
- Elements::TextArea.new(self, object_name, attribute_name, hint:, label:, caption:, max_words:, max_chars:, rows:, threshold:, form_group:, **kwargs, &block).html
417
+ def govuk_text_area(
418
+ attribute_name,
419
+ hint: {},
420
+ label: {},
421
+ caption: {},
422
+ max_words: nil,
423
+ max_chars: nil,
424
+ rows: 5,
425
+ threshold: nil,
426
+ form_group: {},
427
+ description_other_text: nil,
428
+ under_limit_other_text: nil,
429
+ under_limit_one_text: nil,
430
+ at_limit_text: nil,
431
+ over_limit_one_text: nil,
432
+ over_limit_other_text: nil,
433
+ **kwargs,
434
+ &block
435
+ )
436
+ Elements::TextArea.new(
437
+ self,
438
+ object_name,
439
+ attribute_name,
440
+ hint:,
441
+ label:,
442
+ caption:,
443
+ max_words:,
444
+ max_chars:,
445
+ rows:,
446
+ threshold:,
447
+ form_group:,
448
+ description_other_text:,
449
+ under_limit_other_text:,
450
+ under_limit_one_text:,
451
+ at_limit_text:,
452
+ over_limit_one_text:,
453
+ over_limit_other_text:,
454
+ **kwargs,
455
+ &block
456
+ ).html
414
457
  end
415
458
 
416
459
  # Generates a +select+ element containing +option+ for each member in the provided collection
@@ -36,7 +36,7 @@ module GOVUKDesignSystemFormBuilder
36
36
  {
37
37
  legend: @legend,
38
38
  caption: @caption,
39
- described_by: [error_id, hint_id, supplemental_id]
39
+ described_by: [error_id, hint_id]
40
40
  }
41
41
  end
42
42
 
@@ -43,7 +43,7 @@ module GOVUKDesignSystemFormBuilder
43
43
  {
44
44
  id: field_id(link_errors: true),
45
45
  class: classes,
46
- aria: { describedby: combine_references(hint_id, error_id, supplemental_id) }
46
+ aria: { describedby: combine_references(hint_id, error_id) }
47
47
  }
48
48
  end
49
49
 
@@ -55,7 +55,7 @@ module GOVUKDesignSystemFormBuilder
55
55
  {
56
56
  id: field_id(link_errors: true),
57
57
  class: classes,
58
- aria: { describedby: combine_references(hint_id, error_id, supplemental_id) }
58
+ aria: { describedby: combine_references(hint_id, error_id) }
59
59
  }
60
60
  end
61
61
 
@@ -43,7 +43,7 @@ module GOVUKDesignSystemFormBuilder
43
43
  {
44
44
  legend: @legend,
45
45
  caption: @caption,
46
- described_by: [error_id, hint_id, supplemental_id]
46
+ described_by: [error_id, hint_id]
47
47
  }
48
48
  end
49
49
 
@@ -10,7 +10,27 @@ module GOVUKDesignSystemFormBuilder
10
10
  include Traits::HTMLAttributes
11
11
  include Traits::HTMLClasses
12
12
 
13
- def initialize(builder, object_name, attribute_name, hint:, label:, caption:, rows:, max_words:, max_chars:, threshold:, form_group:, **kwargs, &block)
13
+ def initialize(
14
+ builder,
15
+ object_name,
16
+ attribute_name,
17
+ hint:,
18
+ label:,
19
+ caption:,
20
+ rows:,
21
+ max_words:,
22
+ max_chars:,
23
+ threshold:,
24
+ form_group:,
25
+ description_other_text:,
26
+ under_limit_other_text:,
27
+ under_limit_one_text:,
28
+ at_limit_text:,
29
+ over_limit_other_text:,
30
+ over_limit_one_text:,
31
+ **kwargs,
32
+ &block
33
+ )
14
34
  super(builder, object_name, attribute_name, &block)
15
35
 
16
36
  fail ArgumentError, 'limit can be words or chars' if max_words && max_chars
@@ -24,10 +44,17 @@ module GOVUKDesignSystemFormBuilder
24
44
  @rows = rows
25
45
  @form_group = form_group
26
46
  @html_attributes = kwargs
47
+
48
+ @description_other_text = description_other_text
49
+ @under_limit_other_text = under_limit_other_text
50
+ @under_limit_one_text = under_limit_one_text
51
+ @at_limit_text = at_limit_text
52
+ @over_limit_other_text = over_limit_other_text
53
+ @over_limit_one_text = over_limit_one_text
27
54
  end
28
55
 
29
56
  def html
30
- Containers::FormGroup.new(*bound, **@form_group.merge(limit_form_group_options)).html do
57
+ Containers::FormGroup.new(*bound, **@form_group.merge(limit_form_group_options), **i18n_data).html do
31
58
  safe_join([label_element, supplemental_content, hint_element, error_element, text_area, limit_description])
32
59
  end
33
60
  end
@@ -47,7 +74,7 @@ module GOVUKDesignSystemFormBuilder
47
74
  id: field_id(link_errors: true),
48
75
  class: classes,
49
76
  rows: @rows,
50
- aria: { describedby: combine_references(hint_id, error_id, supplemental_id, limit_description_id) },
77
+ aria: { describedby: combine_references(hint_id, error_id, limit_description_id) },
51
78
  }
52
79
  end
53
80
 
@@ -109,6 +136,28 @@ module GOVUKDesignSystemFormBuilder
109
136
  def limit_threshold_options
110
137
  { threshold: @threshold }
111
138
  end
139
+
140
+ def i18n_data
141
+ # "data-i18n.textarea-description.other" => @textarea_description_other_text,
142
+ case limit_type
143
+ when 'characters'
144
+ {
145
+ 'data-i18n.characters-at-limit' => @at_limit_text,
146
+ 'data-i18n.characters-under-limit.other' => @under_limit_other_text,
147
+ 'data-i18n.characters-under-limit.one' => @under_limit_one_text,
148
+ 'data-i18n.characters-over-limit.other' => @over_limit_other_text,
149
+ 'data-i18n.characters-over-limit.one' => @over_limit_one_text,
150
+ }.compact
151
+ when 'words'
152
+ {
153
+ 'data-i18n.words-at-limit' => @at_limit_text,
154
+ 'data-i18n.words-under-limit.other' => @under_limit_other_text,
155
+ 'data-i18n.words-under-limit.one' => @under_limit_one_text,
156
+ 'data-i18n.words-over-limit.other' => @over_limit_other_text,
157
+ 'data-i18n.words-over-limit.one' => @over_limit_one_text,
158
+ }.compact
159
+ end
160
+ end
112
161
  end
113
162
  end
114
163
  end
@@ -27,7 +27,7 @@ module GOVUKDesignSystemFormBuilder
27
27
  end
28
28
 
29
29
  def fieldset_options
30
- { legend: @legend, caption: @caption, described_by: [error_id, hint_id, supplemental_id] }
30
+ { legend: @legend, caption: @caption, described_by: [error_id, hint_id] }
31
31
  end
32
32
 
33
33
  def segment_label_text(segment)
@@ -55,7 +55,7 @@ module GOVUKDesignSystemFormBuilder
55
55
  {
56
56
  id: field_id(link_errors: true),
57
57
  class: classes,
58
- aria: { describedby: combine_references(hint_id, error_id, supplemental_id) }
58
+ aria: { describedby: combine_references(hint_id, error_id) }
59
59
  }
60
60
  end
61
61
 
@@ -1,12 +1,6 @@
1
1
  module GOVUKDesignSystemFormBuilder
2
2
  module Traits
3
3
  module Supplemental
4
- def supplemental_id
5
- return if @block_content.blank?
6
-
7
- build_id('supplemental')
8
- end
9
-
10
4
  private
11
5
 
12
6
  def supplemental_content
@@ -1,3 +1,3 @@
1
1
  module GOVUKDesignSystemFormBuilder
2
- VERSION = '6.1.0'.freeze
2
+ VERSION = '6.2.0'.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: 6.1.0
4
+ version: 6.2.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: 2026-04-01 00:00:00.000000000 Z
11
+ date: 2026-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: html-attributes-utils
@@ -30,42 +30,42 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '6.1'
33
+ version: '7.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '6.1'
40
+ version: '7.2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: activemodel
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '6.1'
47
+ version: '7.2'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '6.1'
54
+ version: '7.2'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: activesupport
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '6.1'
61
+ version: '7.2'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '6.1'
68
+ version: '7.2'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: ostruct
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '6.0'
117
+ version: '8.0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '6.0'
124
+ version: '8.0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rubocop-govuk
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -184,14 +184,14 @@ dependencies:
184
184
  requirements:
185
185
  - - "~>"
186
186
  - !ruby/object:Gem::Version
187
- version: 4.7.0
187
+ version: 5.0.0
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
- version: 4.7.0
194
+ version: 5.0.0
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: rubypants
197
197
  requirement: !ruby/object:Gem::Requirement