govuk_design_system_formbuilder 3.0.2 → 3.1.0

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: f231ec181996fa0acbc3e94d5382e576331b5900a3399f9b052e0fbd6bc5a7c7
4
- data.tar.gz: 403b62c7f06b053696f7c6fa94eb7ec7971581021cec7b859c20ef5aa318e7b9
3
+ metadata.gz: ef71979d3dc464b8b7bb35004494a1f9bae9af7ac392bc9267acab8c38373964
4
+ data.tar.gz: fec2b0c0cc99f2ebcfb20c38c03db5f13a8b70e3f6d26e5c21b7b86735598541
5
5
  SHA512:
6
- metadata.gz: bce07c94910264bcc88923e9096a84b39bf53104ab6b17571dcc3cc1e5ff2d71cf84782d5497cf67ed0d47d1cba92fcb616cabcf11b03fa2ec3de7a17e7e50c8
7
- data.tar.gz: b4aa94516e3026f53ed50830566ca15e314830d2237e6359bd88eea3469746c8e365ee4eb5a80610db22595396c800fd7659d7aafa48d999a21ed51fbb8e06e7
6
+ metadata.gz: d7e0b380e26ee9b408adc81ff58cf655d3c8e4d133dcf30414da2f0c17dc69b26bdfcd452aee69a2f9f9efb9295c44bb2f77e903e6e830c9adae6781e054b656
7
+ data.tar.gz: f3ada2fd3c9489b74c608b1f647a92e1e6438e84cb6c14dd4086c69ae62e227e230ee8033c6e732da11bab9be46bcc8a9b0e96b86a01e2b76a9c967f0be4e154
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-4.0.1-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.2-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.2.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),
@@ -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.2'.freeze
2
+ VERSION = '3.1.0'.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,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_design_system_formbuilder
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 3.1.0
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-02-12 00:00:00.000000000 Z
11
+ date: 2022-06-27 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'
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: 1.2.1
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.3.0
143
+ version: 4.4.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.3.0
150
+ version: 4.4.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.26.0
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.26.0
206
+ version: 3.29.0
201
207
  - !ruby/object:Gem::Dependency
202
208
  name: rubypants
203
209
  requirement: !ruby/object:Gem::Requirement
@@ -357,7 +363,7 @@ metadata:
357
363
  homepage_uri: https://govuk-form-builder.netlify.app
358
364
  source_code_uri: https://github.com/DFE-Digital/govuk-formbuilder
359
365
  github_repo: https://github.com/DFE-Digital/govuk-formbuilder
360
- post_install_message:
366
+ post_install_message:
361
367
  rdoc_options: []
362
368
  require_paths:
363
369
  - lib
@@ -373,7 +379,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
373
379
  version: '0'
374
380
  requirements: []
375
381
  rubygems_version: 3.1.6
376
- signing_key:
382
+ signing_key:
377
383
  specification_version: 4
378
384
  summary: GOV.UK-compliant Rails form builder
379
385
  test_files: []