govuk_design_system_formbuilder 0.7.5 → 0.7.6
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/lib/govuk_design_system_formbuilder/base.rb +1 -1
- data/lib/govuk_design_system_formbuilder/builder.rb +9 -2
- data/lib/govuk_design_system_formbuilder/containers/fieldset.rb +2 -1
- data/lib/govuk_design_system_formbuilder/elements/date.rb +7 -9
- data/lib/govuk_design_system_formbuilder/elements/error_message.rb +2 -9
- data/lib/govuk_design_system_formbuilder/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0fc37b1f1f89baf5185ef1bc708f03ebe2a9d6a331ae880dacc2b797b670ce6a
|
4
|
+
data.tar.gz: a4195d6fd6b127f972c84277fd56d3ebc0b1eaed3a342257fa68db7c24ee6a14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86bbb01e953d5711ce6767a2cbc4dc97c01ee21ab852a8afe919b4552388f30ed1a00724dc6883208cb609581a9c8c384ea44940289de0ed8931ec6bf7762819
|
7
|
+
data.tar.gz: 3608d0f9feddd47aa1879dfcbb068f0fad726d6f7604738e693a293a7d1dacd81466a81b07c48d69a7bc4701ce82237233c2e4de3e092a37f616bbf7041de5b4
|
@@ -32,7 +32,7 @@ module GOVUKDesignSystemFormBuilder
|
|
32
32
|
|
33
33
|
def has_errors?
|
34
34
|
@builder.object.errors.any? &&
|
35
|
-
@builder.object.errors.messages.
|
35
|
+
@builder.object.errors.messages.dig(@attribute_name).present?
|
36
36
|
end
|
37
37
|
|
38
38
|
def attribute_identifier
|
@@ -140,7 +140,7 @@ module GOVUKDesignSystemFormBuilder
|
|
140
140
|
# @note Setting +max_chars+ or +max_words+ will add a caption beneath the +textarea+ with a live count of words
|
141
141
|
# or characters
|
142
142
|
#
|
143
|
-
# @example A
|
143
|
+
# @example A text area with a custom number of rows and a word limit
|
144
144
|
# = f.govuk_number_field :cv,
|
145
145
|
# label: { text: 'Tell us about your work history' },
|
146
146
|
# rows: 8,
|
@@ -207,6 +207,7 @@ module GOVUKDesignSystemFormBuilder
|
|
207
207
|
# @param inline [Boolean] controls whether the radio buttons are displayed inline or not
|
208
208
|
# @option legend text [String] the fieldset legend's text content
|
209
209
|
# @option legend size [String] the size of the fieldset legend font, can be +xl+, +l+, +m+ or +s+
|
210
|
+
# @option legend tag [Symbol,String] the tag used for the fieldset's header, defaults to +h1+, defaults to +h1+
|
210
211
|
# @param block [Block] any HTML passed in is inserted inside the fieldset container,
|
211
212
|
# between the error and the radios container element
|
212
213
|
# @return [ActiveSupport::SafeBuffer] HTML output
|
@@ -261,6 +262,7 @@ module GOVUKDesignSystemFormBuilder
|
|
261
262
|
# @param inline [Boolean] controls whether the radio buttons are displayed inline or not
|
262
263
|
# @option legend text [String] the fieldset legend's text content
|
263
264
|
# @option legend size [String] the size of the fieldset legend font, can be +xl+, +l+, +m+ or +s+
|
265
|
+
# @option legend tag [Symbol,String] the tag used for the fieldset's header, defaults to +h1+
|
264
266
|
# @param block [Block] any HTML passed in will be injected into the fieldset
|
265
267
|
# element and should contain radio buttons and optionally a divider
|
266
268
|
# @see https://design-system.service.gov.uk/components/radios/ GOV.UK Radios
|
@@ -299,6 +301,7 @@ module GOVUKDesignSystemFormBuilder
|
|
299
301
|
# @param hint_text [String] the contents of the hint
|
300
302
|
# @option legend text [String] the fieldset legend's text content
|
301
303
|
# @option legend size [String] the size of the fieldset legend font, can be +xl+, +l+, +m+ or +s+
|
304
|
+
# @option legend tag [Symbol,String] the tag used for the fieldset's header, defaults to +h1+
|
302
305
|
# @see https://design-system.service.gov.uk/components/radios/ GOV.UK Radios
|
303
306
|
# @param block [Block] Any supplied HTML will be wrapped in a conditional
|
304
307
|
# container and only revealed when the radio button is picked
|
@@ -336,6 +339,7 @@ module GOVUKDesignSystemFormBuilder
|
|
336
339
|
# @param legend [Hash] options for configuring the hash
|
337
340
|
# @option legend text [String] the fieldset legend's text content
|
338
341
|
# @option legend size [String] the size of the fieldset legend font, can be +xl+, +l+, +m+ or +s+
|
342
|
+
# @option legend tag [Symbol,String] the tag used for the fieldset's header, defaults to +h1+
|
339
343
|
# @param block [Block] any HTML passed in will be injected into the fieldset, after the hint and before the checkboxes
|
340
344
|
# @return [ActiveSupport::SafeBuffer] HTML output
|
341
345
|
#
|
@@ -401,7 +405,7 @@ module GOVUKDesignSystemFormBuilder
|
|
401
405
|
Elements::Submit.new(self, text, warning: warning, secondary: secondary, prevent_double_click: prevent_double_click, &block).html
|
402
406
|
end
|
403
407
|
|
404
|
-
# Generates three
|
408
|
+
# Generates three inputs for the +day+, +month+ and +year+ components of a date
|
405
409
|
#
|
406
410
|
# @note When using this input be aware that Rails's multiparam time and date handling falls foul
|
407
411
|
# of {https://bugs.ruby-lang.org/issues/5988 this} bug, so incorrect dates like +2019-09-31+ will
|
@@ -411,11 +415,14 @@ module GOVUKDesignSystemFormBuilder
|
|
411
415
|
# @param legend [Hash] options for configuring the hash
|
412
416
|
# @option legend text [String] the fieldset legend's text content
|
413
417
|
# @option legend size [String] the size of the fieldset legend font, can be +xl+, +l+, +m+ or +s+
|
418
|
+
# @option legend tag [Symbol,String] the tag used for the fieldset's header, defaults to +h1+
|
414
419
|
# @param block [Block] arbitrary HTML that will be rendered between the hint and the input group
|
415
420
|
# @param date_of_birth [Boolean] if +true+ {https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete#Values birth date auto completion attributes}
|
416
421
|
# will be added to the inputs
|
417
422
|
# @return [ActiveSupport::SafeBuffer] HTML output
|
418
423
|
#
|
424
|
+
# @see https://github.com/alphagov/govuk-frontend/issues/1449 GOV.UK date input element attributes, using text instead of number
|
425
|
+
#
|
419
426
|
# @example A regular date input with a legend and hint
|
420
427
|
# = f.govuk_date_field :starts_on,
|
421
428
|
# legend: { 'When does your event start?' },
|
@@ -13,7 +13,7 @@ module GOVUKDesignSystemFormBuilder
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def html
|
16
|
-
@builder.content_tag('
|
16
|
+
@builder.content_tag('fieldset', class: fieldset_classes, aria: { describedby: @described_by }) do
|
17
17
|
@builder.safe_join([
|
18
18
|
build_legend,
|
19
19
|
yield
|
@@ -38,6 +38,7 @@ module GOVUKDesignSystemFormBuilder
|
|
38
38
|
def legend_classes
|
39
39
|
size = @legend.dig(:size)
|
40
40
|
fail "invalid size #{size}, must be #{LEGEND_SIZES.join(', ')}" unless size.in?(LEGEND_SIZES)
|
41
|
+
|
41
42
|
"govuk-fieldset__legend govuk-fieldset__legend--#{size}"
|
42
43
|
end
|
43
44
|
|
@@ -25,10 +25,9 @@ module GOVUKDesignSystemFormBuilder
|
|
25
25
|
@builder.content_tag('div', class: 'govuk-date-input') do
|
26
26
|
@builder.safe_join(
|
27
27
|
[
|
28
|
-
date_input_group(:day
|
29
|
-
date_input_group(:month
|
30
|
-
|
31
|
-
date_input_group(:year, min: 1900, max: 2100, width: 4)
|
28
|
+
date_input_group(:day),
|
29
|
+
date_input_group(:month),
|
30
|
+
date_input_group(:year, width: 4)
|
32
31
|
]
|
33
32
|
)
|
34
33
|
end
|
@@ -40,7 +39,7 @@ module GOVUKDesignSystemFormBuilder
|
|
40
39
|
|
41
40
|
private
|
42
41
|
|
43
|
-
def date_input_group(segment,
|
42
|
+
def date_input_group(segment, width: 2)
|
44
43
|
value = @builder.object.try(@attribute_name).try(segment)
|
45
44
|
|
46
45
|
@builder.content_tag('div', class: %w(govuk-date-input__item)) do
|
@@ -57,10 +56,9 @@ module GOVUKDesignSystemFormBuilder
|
|
57
56
|
id: date_attribute_descriptor(segment),
|
58
57
|
class: date_input_classes(width),
|
59
58
|
name: date_attribute_identifier(segment),
|
60
|
-
type: '
|
61
|
-
|
62
|
-
|
63
|
-
step: 1,
|
59
|
+
type: 'text',
|
60
|
+
pattern: '[0-9]*',
|
61
|
+
inputmode: 'numeric',
|
64
62
|
value: value,
|
65
63
|
autocomplete: date_of_birth_autocomplete_value(segment)
|
66
64
|
)
|
@@ -1,9 +1,8 @@
|
|
1
1
|
module GOVUKDesignSystemFormBuilder
|
2
2
|
module Elements
|
3
3
|
class ErrorMessage < GOVUKDesignSystemFormBuilder::Base
|
4
|
-
def initialize(builder, object_name, attribute_name
|
4
|
+
def initialize(builder, object_name, attribute_name)
|
5
5
|
super(builder, object_name, attribute_name)
|
6
|
-
@options = default_options.merge(options)
|
7
6
|
end
|
8
7
|
|
9
8
|
def html
|
@@ -18,13 +17,7 @@ module GOVUKDesignSystemFormBuilder
|
|
18
17
|
end
|
19
18
|
|
20
19
|
def message
|
21
|
-
@builder.object.errors.messages
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
def default_options
|
27
|
-
{}
|
20
|
+
@builder.object.errors.messages.dig(@attribute_name)
|
28
21
|
end
|
29
22
|
end
|
30
23
|
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: 0.7.
|
4
|
+
version: 0.7.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Yates
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|