govuk_design_system_formbuilder 6.4.0 → 6.6.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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 29036297bb5e5295a95e24f83df755b524f49200fd0d57761a42f5852f4f3fbe
|
|
4
|
+
data.tar.gz: 4264b4e448571d9353104bfceace861527cb1a5b454cbfd319ad569343c274b7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d3b8f99daf733c5f9f2b7d4cb053818b2c1b6ecf223ce5f756ce7627aa181a68e0d1aaf9a615645e361a810e82230cb28ecc3158090e2e36cbaa7c6684541061
|
|
7
|
+
data.tar.gz: b8f20bf97d58571571e8f541be72214971fc78242dd3cb3b29600173a3e5b85a0cb404a74037c698ebcd9a125cfd78a35058307176c39dd7db907b1be78b895c
|
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
|
|
|
@@ -421,6 +421,8 @@ module GOVUKDesignSystemFormBuilder
|
|
|
421
421
|
caption: {},
|
|
422
422
|
max_words: nil,
|
|
423
423
|
max_chars: nil,
|
|
424
|
+
max_length: nil,
|
|
425
|
+
count_type: :length,
|
|
424
426
|
rows: 5,
|
|
425
427
|
threshold: nil,
|
|
426
428
|
form_group: {},
|
|
@@ -442,8 +444,10 @@ module GOVUKDesignSystemFormBuilder
|
|
|
442
444
|
caption:,
|
|
443
445
|
max_words:,
|
|
444
446
|
max_chars:,
|
|
445
|
-
|
|
447
|
+
max_length:,
|
|
448
|
+
count_type:,
|
|
446
449
|
threshold:,
|
|
450
|
+
rows:,
|
|
447
451
|
form_group:,
|
|
448
452
|
description_other_text:,
|
|
449
453
|
under_limit_other_text:,
|
|
@@ -21,6 +21,8 @@ module GOVUKDesignSystemFormBuilder
|
|
|
21
21
|
rows:,
|
|
22
22
|
max_words:,
|
|
23
23
|
max_chars:,
|
|
24
|
+
max_length:,
|
|
25
|
+
count_type:,
|
|
24
26
|
threshold:,
|
|
25
27
|
form_group:,
|
|
26
28
|
description_other_text:,
|
|
@@ -39,13 +41,31 @@ module GOVUKDesignSystemFormBuilder
|
|
|
39
41
|
@label = label
|
|
40
42
|
@caption = caption
|
|
41
43
|
@hint = hint
|
|
42
|
-
@max_words = max_words
|
|
43
|
-
@max_chars = max_chars
|
|
44
44
|
@threshold = threshold
|
|
45
45
|
@rows = rows
|
|
46
46
|
@form_group = form_group
|
|
47
47
|
@html_attributes = kwargs
|
|
48
48
|
|
|
49
|
+
case
|
|
50
|
+
when max_length
|
|
51
|
+
@max_length = max_length
|
|
52
|
+
@count_type = count_type.to_sym
|
|
53
|
+
when max_words
|
|
54
|
+
@max_length = max_words
|
|
55
|
+
@count_type = :words
|
|
56
|
+
|
|
57
|
+
warn("max_words is deprecated, use { max_length: #{@max_length}, count_type: :#{@count_type} }")
|
|
58
|
+
when max_chars
|
|
59
|
+
@max_length = max_chars
|
|
60
|
+
@count_type = :length
|
|
61
|
+
|
|
62
|
+
warn("max_chars is deprecated, use { max_length: #{@max_length} }")
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
if @count_type && !@count_type.in?(%i(length words))
|
|
66
|
+
fail(ArgumentError, "count_type (#{@count_type}) must be :length or :words if present")
|
|
67
|
+
end
|
|
68
|
+
|
|
49
69
|
@description_other_text = description_other_text
|
|
50
70
|
@under_limit_other_text = under_limit_other_text
|
|
51
71
|
@under_limit_one_text = under_limit_one_text
|
|
@@ -88,22 +108,18 @@ module GOVUKDesignSystemFormBuilder
|
|
|
88
108
|
end
|
|
89
109
|
|
|
90
110
|
def limit?
|
|
91
|
-
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
def limit_quantity
|
|
95
|
-
@max_words || @max_chars
|
|
111
|
+
@max_length.present?
|
|
96
112
|
end
|
|
97
113
|
|
|
98
114
|
def limit_type
|
|
99
|
-
@
|
|
115
|
+
@count_type == :words ? 'words' : 'characters'
|
|
100
116
|
end
|
|
101
117
|
|
|
102
118
|
def limit_description
|
|
103
119
|
return unless limit?
|
|
104
120
|
|
|
105
121
|
tag.span(id: limit_id, class: limit_description_classes) do
|
|
106
|
-
"You can enter up to #{
|
|
122
|
+
"You can enter up to #{@max_length} #{limit_type}"
|
|
107
123
|
end
|
|
108
124
|
end
|
|
109
125
|
|
|
@@ -127,11 +143,9 @@ module GOVUKDesignSystemFormBuilder
|
|
|
127
143
|
end
|
|
128
144
|
|
|
129
145
|
def limit_max_options
|
|
130
|
-
if @
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
{ maxlength: @max_chars }
|
|
134
|
-
end
|
|
146
|
+
return { maxlength: @max_length, 'count-type' => 'words' } if @count_type == :words
|
|
147
|
+
|
|
148
|
+
{ maxlength: @max_length }
|
|
135
149
|
end
|
|
136
150
|
|
|
137
151
|
def limit_threshold_options
|
|
@@ -139,10 +153,10 @@ module GOVUKDesignSystemFormBuilder
|
|
|
139
153
|
end
|
|
140
154
|
|
|
141
155
|
def i18n_data
|
|
142
|
-
return {} unless
|
|
156
|
+
return {} unless @max_length
|
|
143
157
|
|
|
144
|
-
attrs = case
|
|
145
|
-
when
|
|
158
|
+
attrs = case @count_type
|
|
159
|
+
when :length
|
|
146
160
|
[
|
|
147
161
|
I18nAttr.new('data-i18n.characters-under-limit.other', @under_limit_other_text, :default_text_area_characters_under_limit_other_text),
|
|
148
162
|
I18nAttr.new('data-i18n.characters-under-limit.one', @under_limit_one_text, :default_text_area_characters_under_limit_one_text),
|
|
@@ -150,7 +164,7 @@ module GOVUKDesignSystemFormBuilder
|
|
|
150
164
|
I18nAttr.new('data-i18n.characters-over-limit.other', @over_limit_other_text, :default_text_area_characters_over_limit_other_text),
|
|
151
165
|
I18nAttr.new('data-i18n.characters-over-limit.one', @over_limit_one_text, :default_text_area_characters_over_limit_one_text),
|
|
152
166
|
]
|
|
153
|
-
when
|
|
167
|
+
when :words
|
|
154
168
|
[
|
|
155
169
|
I18nAttr.new('data-i18n.words-under-limit.other', @under_limit_other_text, :default_text_area_words_under_limit_other_text),
|
|
156
170
|
I18nAttr.new('data-i18n.words-under-limit.one', @under_limit_one_text, :default_text_area_words_under_limit_one_text),
|
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.6.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-10-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: html-attributes-utils
|
|
@@ -142,14 +142,14 @@ dependencies:
|
|
|
142
142
|
requirements:
|
|
143
143
|
- - "~>"
|
|
144
144
|
- !ruby/object:Gem::Version
|
|
145
|
-
version: '0
|
|
145
|
+
version: '1.0'
|
|
146
146
|
type: :development
|
|
147
147
|
prerelease: false
|
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
|
149
149
|
requirements:
|
|
150
150
|
- - "~>"
|
|
151
151
|
- !ruby/object:Gem::Version
|
|
152
|
-
version: '0
|
|
152
|
+
version: '1.0'
|
|
153
153
|
- !ruby/object:Gem::Dependency
|
|
154
154
|
name: htmlbeautifier
|
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -184,14 +184,14 @@ dependencies:
|
|
|
184
184
|
requirements:
|
|
185
185
|
- - "~>"
|
|
186
186
|
- !ruby/object:Gem::Version
|
|
187
|
-
version: 5.
|
|
187
|
+
version: 5.1.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: 5.
|
|
194
|
+
version: 5.1.0
|
|
195
195
|
- !ruby/object:Gem::Dependency
|
|
196
196
|
name: rubypants
|
|
197
197
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -254,14 +254,14 @@ dependencies:
|
|
|
254
254
|
requirements:
|
|
255
255
|
- - "~>"
|
|
256
256
|
- !ruby/object:Gem::Version
|
|
257
|
-
version: 0.
|
|
257
|
+
version: 0.37.0
|
|
258
258
|
type: :development
|
|
259
259
|
prerelease: false
|
|
260
260
|
version_requirements: !ruby/object:Gem::Requirement
|
|
261
261
|
requirements:
|
|
262
262
|
- - "~>"
|
|
263
263
|
- !ruby/object:Gem::Version
|
|
264
|
-
version: 0.
|
|
264
|
+
version: 0.37.0
|
|
265
265
|
- !ruby/object:Gem::Dependency
|
|
266
266
|
name: webrick
|
|
267
267
|
requirement: !ruby/object:Gem::Requirement
|