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 +4 -4
- data/README.md +1 -1
- data/lib/govuk_design_system_formbuilder/builder.rb +45 -2
- data/lib/govuk_design_system_formbuilder/elements/check_boxes/collection.rb +1 -1
- data/lib/govuk_design_system_formbuilder/elements/collection_select.rb +1 -1
- data/lib/govuk_design_system_formbuilder/elements/file.rb +1 -1
- data/lib/govuk_design_system_formbuilder/elements/radios/collection.rb +1 -1
- data/lib/govuk_design_system_formbuilder/elements/text_area.rb +52 -3
- data/lib/govuk_design_system_formbuilder/traits/date_input.rb +1 -1
- data/lib/govuk_design_system_formbuilder/traits/input.rb +1 -1
- data/lib/govuk_design_system_formbuilder/traits/supplemental.rb +0 -6
- data/lib/govuk_design_system_formbuilder/version.rb +1 -1
- metadata +12 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2cf25eca1fc9e5160b36b37bd946844b4662453bb3d7ad41761b669b3ee8bebe
|
|
4
|
+
data.tar.gz: 7173d16c0574e1f4e2477c08ffe2a0bdc5325047d323dd21427d8fc2bdf42b31
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2b34a3a4c6792f6bcfd13c0415f07b9e144e64d97350d9c6cb700feffbc1b90242f05f765ae292523a87ccf212528687c42285442f2b4eab8d9c46ec8a9aa594
|
|
7
|
+
data.tar.gz: ad04540f4c3788b828e154c67b733fdb63fbd46a708e3f83b94400d57ae5016095ab9203c4603c22a4c49f9d01b054590679142fc3e90ee5f852c92bc30960ec
|
data/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://badge.fury.io/rb/govuk_design_system_formbuilder)
|
|
5
5
|
[](https://rubygems.org/gems/govuk_design_system_formbuilder)
|
|
6
6
|

|
|
7
|
-
[](https://design-system.service.gov.uk)
|
|
8
8
|
[](https://weblog.rubyonrails.org/releases/)
|
|
9
9
|
[](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(
|
|
413
|
-
|
|
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
|
|
@@ -10,7 +10,27 @@ module GOVUKDesignSystemFormBuilder
|
|
|
10
10
|
include Traits::HTMLAttributes
|
|
11
11
|
include Traits::HTMLClasses
|
|
12
12
|
|
|
13
|
-
def initialize(
|
|
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,
|
|
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
|
|
30
|
+
{ legend: @legend, caption: @caption, described_by: [error_id, hint_id] }
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def segment_label_text(segment)
|
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.
|
|
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-
|
|
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: '
|
|
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: '
|
|
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: '
|
|
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: '
|
|
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: '
|
|
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: '
|
|
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: '
|
|
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: '
|
|
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:
|
|
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:
|
|
194
|
+
version: 5.0.0
|
|
195
195
|
- !ruby/object:Gem::Dependency
|
|
196
196
|
name: rubypants
|
|
197
197
|
requirement: !ruby/object:Gem::Requirement
|