dsfr-form_builder 0.0.6 → 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 +30 -6
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2982849a585a72f0751a9a7f460d0cb3602a20650b2f2ccb0766ecfef6c553ac
4
- data.tar.gz: 3e693689c709175e2c6b5989ea351283960b9009b75fd1c42da4402e3ed0185b
3
+ metadata.gz: 3a0c8e3318e640b14b7afd55c5537fe023032157365a84b21511711f838953f8
4
+ data.tar.gz: 0a4bb1ea72d2b0b10adcb0ceeeb3352f53e0085129be6ca9b92b2a5444cd6516
5
5
  SHA512:
6
- metadata.gz: 7250f92509c9adc994649641d0dbf6e8aaa6112a2d1179b302c6fba649da016be9d0fbe0232b7b7681502b9e200cc21c7df900eb60acbd9408cf6f889c6238ad
7
- data.tar.gz: b2b19bba65bc870817ee054b08e9d3bffec3e8f474c2c0699812e4f0f0f408db66221c1a16f7a1861c5c55994f35bcf3c0c431eb8b9e55e0240c6af7ab853c8f
6
+ metadata.gz: f7c13e694c9ed5e71a2d337fcd144ceae3ab7be5a432a7bd6a23c1f5148edd9529c2000910dcbc597640a6b41b84a99663b176b9c3cc59cc98fde7c2ce903cff
7
+ data.tar.gz: '0428eb812019cb50208f820a582f8bdf37786f979cb660bd6b5952e905286142bbaefeffc9f84c61583180bd0c4c21eb3df17af110b06916f81894ba1eeefc04'
@@ -47,24 +47,38 @@ 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_check_box(attribute, opts = {}, checked_value = "1", unchecked_value = "0")
58
- @template.content_tag(:div, class: "fr-checkbox-group") do
57
+ def dsfr_file_field(attribute, opts = {})
58
+ @template.content_tag(:div, class: upload_group_classes(attribute, opts), data: opts[:data]) do
59
59
  @template.safe_join(
60
60
  [
61
- check_box(attribute, opts, checked_value, unchecked_value),
62
- dsfr_label_with_hint(attribute, opts)
63
- ]
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
64
65
  )
65
66
  end
66
67
  end
67
68
 
69
+ def dsfr_check_box(attribute, opts = {}, checked_value = "1", unchecked_value = "0")
70
+ @template.content_tag(:div, class: "fr-fieldset__element") do
71
+ @template.content_tag(:div, class: "fr-checkbox-group") do
72
+ @template.safe_join(
73
+ [
74
+ check_box(attribute, opts, checked_value, unchecked_value),
75
+ dsfr_label_with_hint(attribute, opts)
76
+ ]
77
+ )
78
+ end
79
+ end
80
+ end
81
+
68
82
  def dsfr_select(attribute, choices, input_options: {}, **opts)
69
83
  @template.content_tag(:div, class: "fr-select-group") do
70
84
  @template.safe_join(
@@ -166,6 +180,16 @@ module Dsfr
166
180
  )
167
181
  end
168
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
+
169
193
  def label_value(attribute, opts)
170
194
  return opts[:label] if opts[:label]
171
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.6
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-06 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