govuk_design_system_formbuilder 3.0.3b1 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/govuk_design_system_formbuilder/builder.rb +2 -3
- data/lib/govuk_design_system_formbuilder/elements/date.rb +9 -10
- data/lib/govuk_design_system_formbuilder/elements/radios/collection.rb +6 -5
- data/lib/govuk_design_system_formbuilder/elements/text_area.rb +1 -1
- data/lib/govuk_design_system_formbuilder/version.rb +1 -1
- data/lib/govuk_design_system_formbuilder.rb +6 -0
- metadata +19 -14
- data/LICENSE +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 849a616e7c297a30b940baee74c033d8ee809d80397d1a09bca32993058a7127
|
4
|
+
data.tar.gz: b154ec1a5517573f061eb294bbd0b7bb2e1ccaacee2868dc2efe8bea4a26d55d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a54832be5fe555c971756f3d80c4439b2a18c7a55642d4f11433c4a9174eb8bed2aaa313be6721a6174b996bfbd60333c6e677481e8b443c9ac0c5436618749b
|
7
|
+
data.tar.gz: 1a49c45ed2ec43cc1eca56eb52adc0bae7a4543813516de3005b12fa79974bc4863b8f9218bc64f83a190f9b46dad2738c2986bc5b6e2311f2314a49a4628933
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
[![Gem](https://img.shields.io/gem/dt/govuk_design_system_formbuilder?logo=rubygems)](https://rubygems.org/gems/govuk_design_system_formbuilder)
|
7
7
|
[![Test Coverage](https://api.codeclimate.com/v1/badges/110136fb22341d3ba646/test_coverage)](https://codeclimate.com/github/DFE-Digital/govuk-formbuilder/test_coverage)
|
8
8
|
[![GitHub license](https://img.shields.io/github/license/DFE-Digital/govuk_design_system_formbuilder)](https://github.com/DFE-Digital/govuk-formbuilder/blob/main/LICENSE)
|
9
|
-
[![GOV.UK Design System Version](https://img.shields.io/badge/GOV.UK%20Design%20System-4.0
|
9
|
+
[![GOV.UK Design System Version](https://img.shields.io/badge/GOV.UK%20Design%20System-4.2.0-brightgreen)](https://design-system.service.gov.uk)
|
10
10
|
[![Rails](https://img.shields.io/badge/Rails-6.1.5%20%E2%95%B1%207.0.3-E16D6D)](https://weblog.rubyonrails.org/releases/)
|
11
11
|
[![Ruby](https://img.shields.io/badge/Ruby-2.7.6%20%20%E2%95%B1%203.0.4%20%20%E2%95%B1%203.1.2-E16D6D)](https://www.ruby-lang.org/en/downloads/)
|
12
12
|
|
@@ -913,7 +913,6 @@ module GOVUKDesignSystemFormBuilder
|
|
913
913
|
# @option caption kwargs [Hash] additional arguments are applied as attributes on the caption +span+ element
|
914
914
|
# @param omit_day [Boolean] do not render a day input, only capture month and year
|
915
915
|
# @param maxlength_enabled [Boolean] adds maxlength attribute to day, month and year inputs (2, 2, and 4, respectively)
|
916
|
-
# @param wildcards [Boolean] add an 'X' to the day and month patterns so users can add approximate dates
|
917
916
|
# @param form_group [Hash] configures the form group
|
918
917
|
# @option form_group classes [Array,String] sets the form group's classes
|
919
918
|
# @option form_group kwargs [Hash] additional attributes added to the form group
|
@@ -937,8 +936,8 @@ module GOVUKDesignSystemFormBuilder
|
|
937
936
|
# @example A date input with legend supplied as a proc
|
938
937
|
# = f.govuk_date_field :finishes_on,
|
939
938
|
# legend: -> { tag.h3('Which category do you belong to?') }
|
940
|
-
def govuk_date_field(attribute_name, hint: {}, legend: {}, caption: {}, date_of_birth: false, omit_day: false, maxlength_enabled: false, form_group: {},
|
941
|
-
Elements::Date.new(self, object_name, attribute_name, hint: hint, legend: legend, caption: caption, date_of_birth: date_of_birth, omit_day: omit_day, maxlength_enabled: maxlength_enabled, form_group: form_group,
|
939
|
+
def govuk_date_field(attribute_name, hint: {}, legend: {}, caption: {}, date_of_birth: false, omit_day: false, maxlength_enabled: false, form_group: {}, **kwargs, &block)
|
940
|
+
Elements::Date.new(self, object_name, attribute_name, hint: hint, legend: legend, caption: caption, date_of_birth: date_of_birth, omit_day: omit_day, maxlength_enabled: maxlength_enabled, form_group: form_group, **kwargs, &block).html
|
942
941
|
end
|
943
942
|
|
944
943
|
# Generates a summary of errors in the form, each linking to the corresponding
|
@@ -11,7 +11,7 @@ module GOVUKDesignSystemFormBuilder
|
|
11
11
|
SEGMENTS = { day: '3i', month: '2i', year: '1i' }.freeze
|
12
12
|
MULTIPARAMETER_KEY = { day: 3, month: 2, year: 1 }.freeze
|
13
13
|
|
14
|
-
def initialize(builder, object_name, attribute_name, legend:, caption:, hint:, omit_day:, maxlength_enabled:, form_group:,
|
14
|
+
def initialize(builder, object_name, attribute_name, legend:, caption:, hint:, omit_day:, maxlength_enabled:, form_group:, date_of_birth: false, **kwargs, &block)
|
15
15
|
super(builder, object_name, attribute_name, &block)
|
16
16
|
|
17
17
|
@legend = legend
|
@@ -21,7 +21,6 @@ module GOVUKDesignSystemFormBuilder
|
|
21
21
|
@omit_day = omit_day
|
22
22
|
@maxlength_enabled = maxlength_enabled
|
23
23
|
@form_group = form_group
|
24
|
-
@wildcards = wildcards
|
25
24
|
@html_attributes = kwargs
|
26
25
|
end
|
27
26
|
|
@@ -54,7 +53,14 @@ module GOVUKDesignSystemFormBuilder
|
|
54
53
|
end
|
55
54
|
|
56
55
|
def day
|
57
|
-
|
56
|
+
if omit_day?
|
57
|
+
return tag.input(
|
58
|
+
id: id(:day, false),
|
59
|
+
name: name(:day),
|
60
|
+
type: 'hidden',
|
61
|
+
value: value(:day) || 1,
|
62
|
+
)
|
63
|
+
end
|
58
64
|
|
59
65
|
date_part(:day, width: 2, link_errors: true)
|
60
66
|
end
|
@@ -107,7 +113,6 @@ module GOVUKDesignSystemFormBuilder
|
|
107
113
|
class: classes(width),
|
108
114
|
name: name(segment),
|
109
115
|
type: 'text',
|
110
|
-
pattern: pattern(segment),
|
111
116
|
inputmode: 'numeric',
|
112
117
|
value: value,
|
113
118
|
autocomplete: date_of_birth_autocomplete_value(segment),
|
@@ -115,12 +120,6 @@ module GOVUKDesignSystemFormBuilder
|
|
115
120
|
)
|
116
121
|
end
|
117
122
|
|
118
|
-
def pattern(segment)
|
119
|
-
return '[0-9X]*' if @wildcards && segment.in?(%i(day month))
|
120
|
-
|
121
|
-
'[0-9]*'
|
122
|
-
end
|
123
|
-
|
124
123
|
def classes(width)
|
125
124
|
build_classes(
|
126
125
|
%(input),
|
@@ -21,11 +21,7 @@ module GOVUKDesignSystemFormBuilder
|
|
21
21
|
@classes = classes
|
22
22
|
@form_group = form_group
|
23
23
|
@include_hidden = include_hidden
|
24
|
-
@bold_labels =
|
25
|
-
hint_method.present?
|
26
|
-
else
|
27
|
-
bold_labels
|
28
|
-
end
|
24
|
+
@bold_labels = (bold_labels.nil? && auto_bold_labels?) || bold_labels
|
29
25
|
end
|
30
26
|
|
31
27
|
def html
|
@@ -38,6 +34,11 @@ module GOVUKDesignSystemFormBuilder
|
|
38
34
|
|
39
35
|
private
|
40
36
|
|
37
|
+
def auto_bold_labels?
|
38
|
+
(config.default_collection_radio_buttons_auto_bold_labels &&
|
39
|
+
@hint_method.present?)
|
40
|
+
end
|
41
|
+
|
41
42
|
def fieldset_options
|
42
43
|
{
|
43
44
|
legend: @legend,
|
@@ -78,7 +78,7 @@ module GOVUKDesignSystemFormBuilder
|
|
78
78
|
def limit_description
|
79
79
|
return unless limit?
|
80
80
|
|
81
|
-
tag.span(id: limit_id, class: limit_description_classes
|
81
|
+
tag.span(id: limit_id, class: limit_description_classes) do
|
82
82
|
"You can enter up to #{limit_quantity} #{limit_type}"
|
83
83
|
end
|
84
84
|
end
|
@@ -43,6 +43,11 @@ module GOVUKDesignSystemFormBuilder
|
|
43
43
|
# * +:default_collection_radio_buttons_include_hidden+ controls whether or not
|
44
44
|
# a hidden field is added when rendering a collection of radio buttons
|
45
45
|
#
|
46
|
+
# * +:default_collection_radio_buttons_auto_bold_labels+ will automatically
|
47
|
+
# make labels on {#govuk_collection_radio_buttons} bold when a +:hint_method+
|
48
|
+
# is present. The default can be overridden using the +bold_labels:+ argument.
|
49
|
+
# The default value is 'true'.
|
50
|
+
#
|
46
51
|
# * +:default_error_summary_title+ sets the text used in error summary
|
47
52
|
# blocks. As per the GOV.UK Design System spec, it defaults to
|
48
53
|
# 'There is a problem'.
|
@@ -91,6 +96,7 @@ module GOVUKDesignSystemFormBuilder
|
|
91
96
|
default_error_summary_turbo_prefix: 'turbo',
|
92
97
|
default_collection_check_boxes_include_hidden: true,
|
93
98
|
default_collection_radio_buttons_include_hidden: true,
|
99
|
+
default_collection_radio_buttons_auto_bold_labels: true,
|
94
100
|
default_submit_validate: false,
|
95
101
|
|
96
102
|
localisation_schema_fallback: %i(helpers __context__),
|
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: 3.
|
4
|
+
version: 3.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Yates
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: html-attributes-utils
|
@@ -16,14 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.9
|
19
|
+
version: '0.9'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.9.2
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
27
|
- - "~>"
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.9
|
29
|
+
version: '0.9'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.9.2
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: actionview
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -134,14 +140,14 @@ dependencies:
|
|
134
140
|
requirements:
|
135
141
|
- - "~>"
|
136
142
|
- !ruby/object:Gem::Version
|
137
|
-
version: 4.
|
143
|
+
version: 4.5.0
|
138
144
|
type: :development
|
139
145
|
prerelease: false
|
140
146
|
version_requirements: !ruby/object:Gem::Requirement
|
141
147
|
requirements:
|
142
148
|
- - "~>"
|
143
149
|
- !ruby/object:Gem::Version
|
144
|
-
version: 4.
|
150
|
+
version: 4.5.0
|
145
151
|
- !ruby/object:Gem::Dependency
|
146
152
|
name: simplecov
|
147
153
|
requirement: !ruby/object:Gem::Requirement
|
@@ -190,14 +196,14 @@ dependencies:
|
|
190
196
|
requirements:
|
191
197
|
- - "~>"
|
192
198
|
- !ruby/object:Gem::Version
|
193
|
-
version: 3.
|
199
|
+
version: 3.29.0
|
194
200
|
type: :development
|
195
201
|
prerelease: false
|
196
202
|
version_requirements: !ruby/object:Gem::Requirement
|
197
203
|
requirements:
|
198
204
|
- - "~>"
|
199
205
|
- !ruby/object:Gem::Version
|
200
|
-
version: 3.
|
206
|
+
version: 3.29.0
|
201
207
|
- !ruby/object:Gem::Dependency
|
202
208
|
name: rubypants
|
203
209
|
requirement: !ruby/object:Gem::Requirement
|
@@ -290,7 +296,6 @@ executables: []
|
|
290
296
|
extensions: []
|
291
297
|
extra_rdoc_files: []
|
292
298
|
files:
|
293
|
-
- LICENSE
|
294
299
|
- README.md
|
295
300
|
- lib/govuk_design_system_formbuilder.rb
|
296
301
|
- lib/govuk_design_system_formbuilder/base.rb
|
@@ -357,7 +362,7 @@ metadata:
|
|
357
362
|
homepage_uri: https://govuk-form-builder.netlify.app
|
358
363
|
source_code_uri: https://github.com/DFE-Digital/govuk-formbuilder
|
359
364
|
github_repo: https://github.com/DFE-Digital/govuk-formbuilder
|
360
|
-
post_install_message:
|
365
|
+
post_install_message:
|
361
366
|
rdoc_options: []
|
362
367
|
require_paths:
|
363
368
|
- lib
|
@@ -368,12 +373,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
368
373
|
version: '0'
|
369
374
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
370
375
|
requirements:
|
371
|
-
- - "
|
376
|
+
- - ">="
|
372
377
|
- !ruby/object:Gem::Version
|
373
|
-
version:
|
378
|
+
version: '0'
|
374
379
|
requirements: []
|
375
380
|
rubygems_version: 3.1.6
|
376
|
-
signing_key:
|
381
|
+
signing_key:
|
377
382
|
specification_version: 4
|
378
383
|
summary: GOV.UK-compliant Rails form builder
|
379
384
|
test_files: []
|
data/LICENSE
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
The MIT License
|
2
|
-
|
3
|
-
Copyright (C) 2019 Crown Copyright (Government Digital Service)
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
-
this software and associated documentation files (the "Software"), to deal in
|
7
|
-
the Software without restriction, including without limitation the rights to
|
8
|
-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
9
|
-
of the Software, and to permit persons to whom the Software is furnished to do
|
10
|
-
so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|