dsfr-form_builder 0.0.1 → 0.0.2

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 +36 -5
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f78a8ca84967d63fc6f95b3e23ace1f50d1b7c766b384e5581c80b582efad0ce
4
- data.tar.gz: ed4c78246f7de17792c50af66a13251d70c888c028aa2a1f7cab74c8e6336268
3
+ metadata.gz: 0bc0aed96262591bbeeeb63159fa94ca318ab11b9de0c88d294a0d7083390bf5
4
+ data.tar.gz: 5e2fabca8dcb56d0daf8de0dbb0ea4c4f26a258c9a2258b20b9ee5decc58d71a
5
5
  SHA512:
6
- metadata.gz: 907d5214d6ee90397b97b7be0ee73b3538fecc6043c22a3d1722b3216dc64edcd1f3c91ae6f94dbcb1cd11a8a1b9a13e1f0d56f336d61840b9f1bd4d7b99ecc7
7
- data.tar.gz: 8512492bed98876820620cab73bf5a2ec76eb7e49e5d50945bdd7dda8d6c1430e687b2b7ca97f555a922d44a7ab5c7757fef72f5bd22ecb2d939805d74277dd6
6
+ metadata.gz: 3875f3099634c72fb24d81887ed86096d511c15b598048cbe2f3be0464086bdeeb5406d4481864f98d1b87722494455660a1b8de6b8201d502c637930b09314b
7
+ data.tar.gz: be2d320662631073b6a17c3b05072e24dcdc5f8b81a1d6df1e748dd25a5aa17f27a6f29e986e066883a377c9f8614ddca45622e78be038956bde4ce85f2a364a
@@ -19,7 +19,7 @@ module Dsfr
19
19
  def dsfr_email_field(attribute, opts = {})
20
20
  dsfr_input_field(attribute, :email_field, opts)
21
21
  end
22
-
22
+
23
23
  def dsfr_url_field(attribute, opts = {})
24
24
  dsfr_input_field(attribute, :url_field, opts)
25
25
  end
@@ -28,6 +28,10 @@ module Dsfr
28
28
  dsfr_input_field(attribute, :phone_field, opts)
29
29
  end
30
30
 
31
+ def dsfr_number_field(attribute, opts = {})
32
+ dsfr_input_field(attribute, :number_field, opts)
33
+ end
34
+
31
35
  def dsfr_input_group(attribute, opts, &block)
32
36
  @template.content_tag(:div, class: input_group_classes(attribute, opts), data: opts[:data]) do
33
37
  yield(block)
@@ -39,17 +43,44 @@ module Dsfr
39
43
  @template.safe_join(
40
44
  [
41
45
  dsfr_label_with_hint(attribute, opts),
42
- public_send(input_kind, attribute, class: "fr-input", **opts.except(:class)),
43
- dsfr_error_message(attribute),
46
+ public_send(input_kind, attribute, class: "fr-input", **opts.except(:class, :hint)),
47
+ dsfr_error_message(attribute)
48
+ ]
49
+ )
50
+ end
51
+ end
52
+
53
+ def dsfr_check_box(attribute, opts = {})
54
+ @template.content_tag(:div, class: "fr-checkbox-group") do
55
+ @template.safe_join(
56
+ [
57
+ check_box(attribute, opts),
58
+ label(attribute, class: "fr-label")
59
+ ]
60
+ )
61
+ end
62
+ end
63
+
64
+ def dsfr_select(attribute, choices, input_options: {}, **opts)
65
+ @template.content_tag(:div, class: "fr-select-group") do
66
+ @template.safe_join(
67
+ [
68
+ dsfr_label_with_hint(attribute, opts),
69
+ dsfr_select_tag(attribute, choices, **opts, **(input_options)),
70
+ dsfr_error_message(attribute)
44
71
  ]
45
72
  )
46
73
  end
47
74
  end
48
75
 
76
+ def dsfr_select_tag(attribute, choices, opts)
77
+ select(attribute, choices, { include_blank: opts[:include_blank] }, class: "fr-select")
78
+ end
79
+
49
80
  def dsfr_label_with_hint(attribute, opts = {})
50
81
  label_class = "fr-label #{opts[:class]}"
51
82
  label(attribute, class: label_class) do
52
- label_and_tags = [label_value(attribute, opts)]
83
+ label_and_tags = [ label_value(attribute, opts) ]
53
84
  label_and_tags.push(required_tag) if opts[:required] && display_required_tags
54
85
  label_and_tags.push(hint_tag(opts[:hint])) if opts[:hint]
55
86
 
@@ -90,7 +121,7 @@ module Dsfr
90
121
  [
91
122
  "fr-input-group",
92
123
  @object.errors[attribute].any? ? "fr-input-group--error" : nil,
93
- opts[:class],
124
+ opts[:class]
94
125
  ]
95
126
  )
96
127
  end
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.1
4
+ version: 0.0.2
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-01-21 00:00:00.000000000 Z
11
+ date: 2025-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview