dsfr-form_builder 0.0.9 → 0.0.11

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 +13 -17
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9bd7c63d280b90c223ac24825d70fd3b529c71fb1d242335785235a5a6e7370c
4
- data.tar.gz: c90dbb0f5479e9401afebcd99e199c0d2c95be725b2333d84f1b2dd03b24bdee
3
+ metadata.gz: 366f99e6d0977ee58c58828622795c55b42902ab3baf85bfdd31affe0eb631e8
4
+ data.tar.gz: 1ee33673eb7a3ba96ebce100c73ea5307d7f1847d4849db066041051591a41f7
5
5
  SHA512:
6
- metadata.gz: f8d706444e7afec231c0bd8cf094be44c9a8ad4b0c5af3149749fca02d9da74b51d13c69b884183ad97fda19d8f847006f4f7501b9df43b5dbf8436c5764397f
7
- data.tar.gz: e1297220a5fef326d01d1381d70fe85543b9d3371327f25f7d294ac7564ccea48d28d54db4edc747ce199e8765b0fa474ae67ffafa2f340ebcf9d1a2914b33d2
6
+ metadata.gz: cdccd30d638835e4acff3617cc75654535d862cf9540a695aee6c8cf6146eda9fad21b554de26a92d1c22bf7a0d91e099432c5e123dfc2c1efa308d70525a9d4
7
+ data.tar.gz: 99e3faf4d28577af4a11ae7e93392769d1ac270289871a6719a11d30625b3f1f59c6f257c2c6c0d7aa02f2aae816eabedc2cc7cd8d408f142459b7f14c691a86
@@ -2,6 +2,8 @@ module Dsfr
2
2
  include ActiveSupport::Configurable
3
3
 
4
4
  class FormBuilder < ActionView::Helpers::FormBuilder
5
+ VERSION = "0.0.11"
6
+
5
7
  include ActionView::Helpers::OutputSafetyHelper
6
8
 
7
9
  attr_accessor :display_required_tags
@@ -36,20 +38,19 @@ module Dsfr
36
38
  end
37
39
  end
38
40
 
39
- def dsfr_input_group(attribute, opts, kind: :input, &block)
41
+ def dsfr_input_group(attribute, kind: :input, **opts)
40
42
  @template.tag.div(
41
- yield(block),
42
43
  data: opts[:data],
43
44
  class: @template.class_names(
44
45
  "fr-#{kind}-group",
45
46
  opts[:class],
46
47
  "fr-#{kind}-group--error" => @object&.errors&.include?(attribute)
47
48
  )
48
- )
49
+ ) { yield }
49
50
  end
50
51
 
51
52
  def dsfr_input_field(attribute, input_kind, opts = {})
52
- dsfr_input_group(attribute, opts) do
53
+ dsfr_input_group(attribute, **opts) do
53
54
  @template.safe_join([
54
55
  dsfr_label_with_hint(attribute, opts),
55
56
  public_send(input_kind, attribute, class: "fr-input", **opts.except(:class, :hint, :label, :data)),
@@ -59,7 +60,7 @@ module Dsfr
59
60
  end
60
61
 
61
62
  def dsfr_file_field(attribute, opts = {})
62
- dsfr_input_group(attribute, opts, kind: :upload) do
63
+ dsfr_input_group(attribute, **opts, kind: :upload) do
63
64
  @template.safe_join([
64
65
  dsfr_label_with_hint(attribute, opts.except(:class)),
65
66
  file_field(attribute, class: "fr-upload", **opts.except(:class, :hint, :label, :data)),
@@ -70,7 +71,7 @@ module Dsfr
70
71
 
71
72
  def dsfr_check_box(attribute, opts = {}, checked_value = "1", unchecked_value = "0")
72
73
  @template.tag.div(class: @template.class_names("fr-fieldset__element", "fr-fieldset__element--inline" => opts.delete(:inline))) do
73
- dsfr_input_group(attribute, opts, kind: :checkbox) do
74
+ dsfr_input_group(attribute, **opts, kind: :checkbox) do
74
75
  @template.safe_join([
75
76
  check_box(attribute, opts.except(:label, :hint), checked_value, unchecked_value),
76
77
  dsfr_label_with_hint(attribute, opts)
@@ -108,23 +109,18 @@ module Dsfr
108
109
  end
109
110
  end
110
111
 
111
- def dsfr_select(attribute, choices, input_options: {}, **opts)
112
- dsfr_input_group(attribute, opts, kind: :select) do
112
+ def dsfr_select(attribute, choices, input_options = {}, **html_options)
113
+ select_html_options = html_options.dup.except(:hint, :name)
114
+ select_html_options[:class] = @template.class_names("fr-select", select_html_options[:class])
115
+ dsfr_input_group(attribute, **html_options, kind: :select) do
113
116
  @template.safe_join([
114
- dsfr_label_with_hint(attribute, opts),
115
- dsfr_select_tag(attribute, choices, opts.merge(input_options).except(:hint, :name)),
117
+ dsfr_label_with_hint(attribute, html_options),
118
+ select(attribute, choices, input_options, **select_html_options),
116
119
  dsfr_error_message(attribute)
117
120
  ])
118
121
  end
119
122
  end
120
123
 
121
- def dsfr_select_tag(attribute, choices, opts)
122
- opts[:class] = @template.class_names("fr-select", opts[:class])
123
- options = opts.slice(:include_blank, :selected, :disabled)
124
- html_options = opts.except(:include_blank, :selected, :disabled)
125
- select(attribute, choices, options, **html_options)
126
- end
127
-
128
124
  def dsfr_radio_buttons(attribute, choices, legend: nil, hint: nil, **opts)
129
125
  legend_content = @template.safe_join([
130
126
  legend || @object.class.human_attribute_name(attribute),
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.9
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - BetaGouv developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-01-21 00:00:00.000000000 Z
11
+ date: 2026-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview