dsfr-form_builder 0.0.7 → 0.0.8

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/dsfr-form_builder.rb +23 -1
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a4e816709049a90277c9e2b5483c9dba3151de298cbe31e31c82c2726b27498d
4
- data.tar.gz: 9f0079eeca19ecc0379603d01388cf6b73235a3aaab2c540e782f89742745692
3
+ metadata.gz: 3a0c8e3318e640b14b7afd55c5537fe023032157365a84b21511711f838953f8
4
+ data.tar.gz: 0a4bb1ea72d2b0b10adcb0ceeeb3352f53e0085129be6ca9b92b2a5444cd6516
5
5
  SHA512:
6
- metadata.gz: 27a89a0ce90dfe65b2c69bec7f62bf5b499b2093427fd2bf381b8b30a83107fdfbea4a6f5639e46f10a86918edc6d8a22d11ba72bc1e4154b56eba22beea94dc
7
- data.tar.gz: '00187f9758bdb49d5a70a7a506fea6423a86325076fdde5b3ce6c9123f9eef3e8cebe7b7deb564fce890fec7f1924596f218c21e51209e2221935bc1b43d6b03'
6
+ metadata.gz: f7c13e694c9ed5e71a2d337fcd144ceae3ab7be5a432a7bd6a23c1f5148edd9529c2000910dcbc597640a6b41b84a99663b176b9c3cc59cc98fde7c2ce903cff
7
+ data.tar.gz: '0428eb812019cb50208f820a582f8bdf37786f979cb660bd6b5952e905286142bbaefeffc9f84c61583180bd0c4c21eb3df17af110b06916f81894ba1eeefc04'
@@ -47,13 +47,25 @@ module Dsfr
47
47
  @template.safe_join(
48
48
  [
49
49
  dsfr_label_with_hint(attribute, opts),
50
- public_send(input_kind, attribute, class: "fr-input", **opts.except(:class, :hint)),
50
+ public_send(input_kind, attribute, class: "fr-input", **opts.except(:class, :hint, :label, :data)),
51
51
  dsfr_error_message(attribute)
52
52
  ]
53
53
  )
54
54
  end
55
55
  end
56
56
 
57
+ def dsfr_file_field(attribute, opts = {})
58
+ @template.content_tag(:div, class: upload_group_classes(attribute, opts), data: opts[:data]) do
59
+ @template.safe_join(
60
+ [
61
+ dsfr_label_with_hint(attribute, opts.except(:class)),
62
+ file_field(attribute, class: "fr-upload", **opts.except(:class, :hint, :label, :data)),
63
+ dsfr_error_message(attribute)
64
+ ].compact
65
+ )
66
+ end
67
+ end
68
+
57
69
  def dsfr_check_box(attribute, opts = {}, checked_value = "1", unchecked_value = "0")
58
70
  @template.content_tag(:div, class: "fr-fieldset__element") do
59
71
  @template.content_tag(:div, class: "fr-checkbox-group") do
@@ -168,6 +180,16 @@ module Dsfr
168
180
  )
169
181
  end
170
182
 
183
+ def upload_group_classes(attribute, opts)
184
+ join_classes(
185
+ [
186
+ "fr-upload-group",
187
+ @object.errors[attribute].any? ? "fr-upload-group--error" : nil,
188
+ opts[:class]
189
+ ]
190
+ )
191
+ end
192
+
171
193
  def label_value(attribute, opts)
172
194
  return opts[:label] if opts[:label]
173
195
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dsfr-form_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - BetaGouv developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-10 00:00:00.000000000 Z
11
+ date: 2025-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
104
  - !ruby/object:Gem::Version
105
105
  version: '0'
106
106
  requirements: []
107
- rubygems_version: 3.5.22
107
+ rubygems_version: 3.5.13
108
108
  signing_key:
109
109
  specification_version: 4
110
110
  summary: Ruby on Rails form builder pour le Système de Design de l'État (DSFR)