govuk_design_system_formbuilder 3.0.1 → 3.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9bec1bab9191040f7f1c63377dd36f9a662de2f46f29cbaf79722a51fffbb044
4
- data.tar.gz: f99522c38fc58a1ec28b5041c6e934415a44e16a8bdc3e9891a009d8822efdca
3
+ metadata.gz: 7ff442cbd7ee104a7438e56fdb7b3730b3e2d7ee671d6ad324f338b5dcad5f68
4
+ data.tar.gz: 94a9bfbef680abadc21a5f3109265051e77d74f9b0ee8ac3dc850912160cae1b
5
5
  SHA512:
6
- metadata.gz: f007e7563e95ff2d4e45ffb393248b7cc268575940787545f9cd6de5ea70fd1a46326c71ffbfd0b213e8c385723f2b024d6c0de9d4f1c519df665a391096fe21
7
- data.tar.gz: 44a373662b919477b9434151f3d1268781878d4bf428381870561b177219ee2b3d7c950fdd1ffb2f86d329e522912b442dc7833606332b791aaef4b030c02de6
6
+ metadata.gz: b0a1fa2e14207c3210a2c42a00e78b59548cf60c6e443a93d4908973ddee95d7c0e66c988b3475a36ccaf521c846cebed8332e94839d256e3c5070032b43aac9
7
+ data.tar.gz: 415811c062dcb4965964e6cbbbb5412f57e4d14baba0d4b277b39294f632aad8642573b9f0f1298a6721c9ddb450b28230ff1778d8e68de3266b2ac585c49370
data/README.md CHANGED
@@ -6,9 +6,9 @@
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-3.14.0-brightgreen)](https://design-system.service.gov.uk)
10
- [![Rails](https://img.shields.io/badge/Rails-6.1.4.4%20%E2%95%B1%207.0.1-E16D6D)](https://weblog.rubyonrails.org/releases/)
11
- [![Ruby](https://img.shields.io/badge/Ruby-2.7.5%20%20%E2%95%B1%203.0.3%20%20%E2%95%B1%203.1.0-E16D6D)](https://www.ruby-lang.org/en/downloads/)
9
+ [![GOV.UK Design System Version](https://img.shields.io/badge/GOV.UK%20Design%20System-4.1.0-brightgreen)](https://design-system.service.gov.uk)
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
+ [![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
 
13
13
  This library provides an easy-to-use form builder for the [GOV.UK Design System](https://design-system.service.gov.uk/).
14
14
 
@@ -55,7 +55,7 @@ configured.
55
55
  To get up and running quickly and easily try kickstarting your project with a
56
56
  pre-configured template:
57
57
 
58
- * [DfE Boilerplate](https://github.com/DFE-Digital/govuk-rails-boilerplate)
58
+ * [DfE Rails Template](https://github.com/DFE-Digital/rails-template)
59
59
  * [DEFRA Ruby Template](https://github.com/DEFRA/defra-ruby-template)
60
60
 
61
61
  ## Setup 🔧
@@ -130,7 +130,7 @@ git config --global user.name "Julius Hibbert"
130
130
 
131
131
  ## Services using this library
132
132
 
133
- Approximately [40 services use this library](https://github.com/DFE-Digital/govuk-formbuilder/network/dependents),
133
+ Approximately [70 services use this library](https://github.com/DFE-Digital/govuk-formbuilder/network/dependents),
134
134
  here are a few from the <abbr title="Department for Education">DfE</abbr>, <abbr title="Ministry of Justice">MoJ</abbr>, and
135
135
  <abbr title="Department for Business, Energy & Industrial Strategy">BEIS</abbr>.
136
136
 
@@ -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: {}, wildcards: false, **kwargs, &block)
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, wildcards: wildcards, **kwargs, &block).html
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:, wildcards:, date_of_birth: false, **kwargs, &block)
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
 
@@ -107,7 +106,6 @@ module GOVUKDesignSystemFormBuilder
107
106
  class: classes(width),
108
107
  name: name(segment),
109
108
  type: 'text',
110
- pattern: pattern(segment),
111
109
  inputmode: 'numeric',
112
110
  value: value,
113
111
  autocomplete: date_of_birth_autocomplete_value(segment),
@@ -115,12 +113,6 @@ module GOVUKDesignSystemFormBuilder
115
113
  )
116
114
  end
117
115
 
118
- def pattern(segment)
119
- return '[0-9X]*' if @wildcards && segment.in?(%i(day month))
120
-
121
- '[0-9]*'
122
- end
123
-
124
116
  def classes(width)
125
117
  build_classes(
126
118
  %(input),
@@ -121,7 +121,6 @@ module GOVUKDesignSystemFormBuilder
121
121
  def options
122
122
  {
123
123
  class: classes,
124
- tabindex: -1,
125
124
  role: 'alert',
126
125
  data: {
127
126
  module: %(#{brand}-error-summary)
@@ -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, aria: { live: 'polite' }) do
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
@@ -1,68 +1,12 @@
1
1
  module GOVUKDesignSystemFormBuilder
2
2
  module Traits
3
3
  module HTMLAttributes
4
- # Attributes eases working with default and custom attributes by:
5
- # * deeply merging them so both the default (required) attributes are
6
- # present
7
- # * joins the arrays into strings to maintain Rails 6.0.* compatibility
8
- class Attributes
9
- # Only try to combine and merge these attributes that contain a list of
10
- # values separated by a space. All other values should be merged in a
11
- # regular fashion (where the custom value overrides the default)
12
- MERGEABLE = [
13
- %i(class),
14
- %i(aria controls),
15
- %i(aria describedby),
16
- %i(aria flowto),
17
- %i(aria labelledby),
18
- %i(aria owns),
19
- ].freeze
20
-
21
- def initialize(defaults, custom)
22
- @merged = defaults.deeper_merge(deep_split_values(custom))
23
- end
24
-
25
- def to_h
26
- deep_join_values(@merged)
27
- end
28
-
29
- private
30
-
31
- def deep_split_values(hash, parent = nil)
32
- hash.each.with_object({}) do |(key, value), result|
33
- result[key] = case value
34
- when Hash
35
- deep_split_values(value, key)
36
- when String
37
- split_mergeable(key, value, parent)
38
- else
39
- value
40
- end
41
- end
42
- end
43
-
44
- def split_mergeable(key, value, parent = nil)
45
- return value.presence unless [parent, key].compact.in?(MERGEABLE)
46
-
47
- value.split
48
- end
49
-
50
- def deep_join_values(hash)
51
- hash.each.with_object({}) do |(key, value), result|
52
- result[key] = case value
53
- when Hash
54
- deep_join_values(value)
55
- when Array
56
- value.uniq.join(' ').presence
57
- else
58
- value
59
- end
60
- end
61
- end
62
- end
4
+ using HTMLAttributesUtils
63
5
 
64
6
  def attributes(html_attributes = {})
65
- Attributes.new(options, html_attributes).to_h
7
+ options
8
+ .deep_merge_html_attributes(html_attributes)
9
+ .deep_tidy_html_attributes
66
10
  end
67
11
  end
68
12
  end
@@ -1,3 +1,3 @@
1
1
  module GOVUKDesignSystemFormBuilder
2
- VERSION = '3.0.1'.freeze
2
+ VERSION = '3.0.3'.freeze
3
3
  end
@@ -1,5 +1,5 @@
1
- require 'deep_merge/rails_compat'
2
1
  require 'active_support/configurable'
2
+ require 'html_attributes_utils'
3
3
 
4
4
  [%w(presenters *.rb), %w(refinements *.rb), %w(traits *.rb), %w(*.rb), %w(elements ** *.rb), %w(containers ** *.rb)]
5
5
  .flat_map { |matcher| Dir.glob(File.join(__dir__, 'govuk_design_system_formbuilder', *matcher)) }
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_design_system_formbuilder
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Yates
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-22 00:00:00.000000000 Z
11
+ date: 2022-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: deep_merge
14
+ name: html-attributes-utils
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.2.1
19
+ version: 0.9.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.2.1
26
+ version: 0.9.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: actionview
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -134,14 +134,14 @@ dependencies:
134
134
  requirements:
135
135
  - - "~>"
136
136
  - !ruby/object:Gem::Version
137
- version: 4.2.0
137
+ version: 4.4.0
138
138
  type: :development
139
139
  prerelease: false
140
140
  version_requirements: !ruby/object:Gem::Requirement
141
141
  requirements:
142
142
  - - "~>"
143
143
  - !ruby/object:Gem::Version
144
- version: 4.2.0
144
+ version: 4.4.0
145
145
  - !ruby/object:Gem::Dependency
146
146
  name: simplecov
147
147
  requirement: !ruby/object:Gem::Requirement
@@ -190,14 +190,14 @@ dependencies:
190
190
  requirements:
191
191
  - - "~>"
192
192
  - !ruby/object:Gem::Version
193
- version: 3.26.0
193
+ version: 3.28.0
194
194
  type: :development
195
195
  prerelease: false
196
196
  version_requirements: !ruby/object:Gem::Requirement
197
197
  requirements:
198
198
  - - "~>"
199
199
  - !ruby/object:Gem::Version
200
- version: 3.26.0
200
+ version: 3.28.0
201
201
  - !ruby/object:Gem::Dependency
202
202
  name: rubypants
203
203
  requirement: !ruby/object:Gem::Requirement