vcfb 1.0.0 → 2.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 (101) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -0
  3. data/README.md +30 -0
  4. data/lib/generators/vcfb/components/components_generator.rb +5 -0
  5. data/lib/generators/vcfb/components/templates/button/component.html.erb +1 -1
  6. data/lib/generators/vcfb/components/templates/button/component.rb.tt +1 -12
  7. data/lib/generators/vcfb/components/templates/check_box/component.rb.tt +1 -14
  8. data/lib/generators/vcfb/components/templates/collection_check_boxes/check_box/component.rb.tt +1 -14
  9. data/lib/generators/vcfb/components/templates/collection_check_boxes/component.html.erb +1 -1
  10. data/lib/generators/vcfb/components/templates/collection_check_boxes/component.rb.tt +1 -24
  11. data/lib/generators/vcfb/components/templates/collection_check_boxes/label/component.html.erb +1 -1
  12. data/lib/generators/vcfb/components/templates/collection_check_boxes/label/component.rb.tt +1 -14
  13. data/lib/generators/vcfb/components/templates/collection_radio_buttons/component.html.erb +1 -1
  14. data/lib/generators/vcfb/components/templates/collection_radio_buttons/component.rb.tt +1 -24
  15. data/lib/generators/vcfb/components/templates/collection_radio_buttons/label/component.html.erb +1 -1
  16. data/lib/generators/vcfb/components/templates/collection_radio_buttons/label/component.rb.tt +1 -14
  17. data/lib/generators/vcfb/components/templates/collection_radio_buttons/radio_button/component.rb.tt +1 -13
  18. data/lib/generators/vcfb/components/templates/collection_select/component.rb.tt +1 -16
  19. data/lib/generators/vcfb/components/templates/color_field/component.rb.tt +1 -12
  20. data/lib/generators/vcfb/components/templates/component.html.erb +3 -0
  21. data/lib/generators/vcfb/components/templates/component.rb.tt +4 -0
  22. data/lib/generators/vcfb/components/templates/date_field/component.rb.tt +1 -12
  23. data/lib/generators/vcfb/components/templates/date_select/component.rb.tt +1 -13
  24. data/lib/generators/vcfb/components/templates/datetime_field/component.rb.tt +1 -12
  25. data/lib/generators/vcfb/components/templates/datetime_select/component.rb.tt +1 -13
  26. data/lib/generators/vcfb/components/templates/email_field/component.rb.tt +1 -12
  27. data/lib/generators/vcfb/components/templates/file_field/component.rb.tt +1 -12
  28. data/lib/generators/vcfb/components/templates/grouped_collection_select/component.rb.tt +1 -18
  29. data/lib/generators/vcfb/components/templates/label/component.html.erb +1 -1
  30. data/lib/generators/vcfb/components/templates/label/component.rb.tt +1 -14
  31. data/lib/generators/vcfb/components/templates/month_field/component.rb.tt +1 -12
  32. data/lib/generators/vcfb/components/templates/number_field/component.rb.tt +1 -12
  33. data/lib/generators/vcfb/components/templates/password_field/component.rb.tt +1 -12
  34. data/lib/generators/vcfb/components/templates/radio_button/component.rb.tt +1 -13
  35. data/lib/generators/vcfb/components/templates/range_field/component.rb.tt +1 -12
  36. data/lib/generators/vcfb/components/templates/rich_text_area/component.rb.tt +1 -12
  37. data/lib/generators/vcfb/components/templates/search_field/component.rb.tt +1 -12
  38. data/lib/generators/vcfb/components/templates/select/component.rb.tt +1 -18
  39. data/lib/generators/vcfb/components/templates/submit/component.rb.tt +1 -12
  40. data/lib/generators/vcfb/components/templates/telephone_field/component.rb.tt +1 -12
  41. data/lib/generators/vcfb/components/templates/text_area/component.rb.tt +1 -12
  42. data/lib/generators/vcfb/components/templates/text_field/component.rb.tt +1 -12
  43. data/lib/generators/vcfb/components/templates/time_field/component.rb.tt +1 -12
  44. data/lib/generators/vcfb/components/templates/time_select/component.rb.tt +1 -13
  45. data/lib/generators/vcfb/components/templates/time_zone_select/component.rb.tt +1 -14
  46. data/lib/generators/vcfb/components/templates/url_field/component.rb.tt +1 -12
  47. data/lib/generators/vcfb/components/templates/week_field/component.rb.tt +1 -12
  48. data/lib/generators/vcfb/components/templates/weekday_select/component.rb.tt +1 -13
  49. data/lib/generators/vcfb/initializer/initializer_generator.rb +12 -0
  50. data/lib/generators/vcfb/initializer/template/vcfb.rb.tt +3 -0
  51. data/lib/vcfb/component/base.rb +40 -0
  52. data/lib/vcfb/component/base_collection.rb +18 -0
  53. data/lib/vcfb/component/button.rb +17 -0
  54. data/lib/vcfb/component/check_box.rb +19 -0
  55. data/lib/vcfb/component/collection_check_boxes.rb +36 -0
  56. data/lib/vcfb/component/collection_radio_buttons.rb +36 -0
  57. data/lib/vcfb/component/collection_select.rb +21 -0
  58. data/lib/vcfb/component/color_field.rb +17 -0
  59. data/lib/vcfb/component/date_field.rb +17 -0
  60. data/lib/vcfb/component/date_select.rb +18 -0
  61. data/lib/vcfb/component/datetime_field.rb +17 -0
  62. data/lib/vcfb/component/datetime_select.rb +18 -0
  63. data/lib/vcfb/component/email_field.rb +17 -0
  64. data/lib/vcfb/component/file_field.rb +17 -0
  65. data/lib/vcfb/component/form.rb +41 -0
  66. data/lib/vcfb/component/grouped_collection_select.rb +23 -0
  67. data/lib/vcfb/component/label.rb +28 -0
  68. data/lib/vcfb/component/month_field.rb +17 -0
  69. data/lib/vcfb/component/number_field.rb +17 -0
  70. data/lib/vcfb/component/password_field.rb +17 -0
  71. data/lib/vcfb/component/radio_button.rb +18 -0
  72. data/lib/vcfb/component/range_field.rb +17 -0
  73. data/lib/vcfb/component/rich_text_area.rb +17 -0
  74. data/lib/vcfb/component/search_field.rb +17 -0
  75. data/lib/vcfb/component/select.rb +23 -0
  76. data/lib/vcfb/component/submit.rb +17 -0
  77. data/lib/vcfb/component/telephone_field.rb +17 -0
  78. data/lib/vcfb/component/text_area.rb +17 -0
  79. data/lib/vcfb/component/text_field.rb +17 -0
  80. data/lib/vcfb/component/time_field.rb +17 -0
  81. data/lib/vcfb/component/time_select.rb +18 -0
  82. data/lib/vcfb/component/time_zone_select.rb +19 -0
  83. data/lib/vcfb/component/url_field.rb +17 -0
  84. data/lib/vcfb/component/week_field.rb +17 -0
  85. data/lib/vcfb/component/weekday_select.rb +18 -0
  86. data/lib/vcfb/errors/component_missing.rb +5 -0
  87. data/lib/vcfb/errors/error.rb +5 -0
  88. data/lib/vcfb/form_builder.rb +56 -19
  89. data/lib/vcfb/form_helper.rb +12 -0
  90. data/lib/vcfb/railtie.rb +7 -0
  91. data/lib/vcfb/resolver.rb +8 -6
  92. data/lib/vcfb/tags/collection_check_boxes.rb +2 -2
  93. data/lib/vcfb/tags/collection_helpers.rb +0 -2
  94. data/lib/vcfb/tags/collection_radio_buttons.rb +2 -2
  95. data/lib/vcfb/template.rb +11 -6
  96. data/lib/vcfb/version.rb +1 -1
  97. data/lib/vcfb.rb +68 -10
  98. metadata +44 -5
  99. data/lib/vcfb/acts_as_form_collection_component.rb +0 -19
  100. data/lib/vcfb/acts_as_form_component.rb +0 -22
  101. data/lib/vcfb/acts_as_form_label_component.rb +0 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d279e150ad43b12161abe30108b84e3e4dc37f03b9fb2ee39245875e671e573
4
- data.tar.gz: ba88556e3028d56d89d3359aaf006163fab1ae4f1665cd3e094b97175258918b
3
+ metadata.gz: 37ed059430db4dec9fa83fc4afede218952117e5fcbe393bec25d12b19977e96
4
+ data.tar.gz: 72786a8449548594a9abd8afa51c1bb3b28a0963cfb1299aad0d8afad766e731
5
5
  SHA512:
6
- metadata.gz: d0cc8de0c202e26745ec4442b8006681749717580c136769e9789ec308fc1efb76ca2f158fadba091ebf43a990f3532ae3bee6679c795c6da0f1c7f0dfb96dc7
7
- data.tar.gz: 97a1b2840265b7b6fd773fa46e9bd45a77f929f5d25d157f1f92a4540bb98afe5013db3f3ec844b198c8b6382841926dc0872bd4cb0a9825a67219c3731eee14
6
+ metadata.gz: d606a6d676d287b684d28220054b38b1bc84bde12237f90e42e63d4b93e4813139aa30f21c71738ac80c7094894d353a042a59428e08050c4f0ca07045208502
7
+ data.tar.gz: 80743157ca8269d9323458d21081b03043565d4cab53172aa788abd29bd6acf6d2b54ab9439b6e077fe135ff9e408340e114d4939accb9b3b654f6de4908302d
data/CHANGELOG.md CHANGED
@@ -4,6 +4,28 @@
4
4
 
5
5
  -
6
6
 
7
+ ## 2.0.2
8
+
9
+ - Support for ViewComponent 2.61.0
10
+
11
+ ## 2.0.1
12
+
13
+ - Restore usage of tag options gem if present.
14
+
15
+ ## 2.0.0
16
+
17
+ - Support rendering of the base form tag via component (including slot support
18
+ for ViewComponent v2.54.0 and above).
19
+ - Support rendering of slots for button, label, collection checkbox label, and
20
+ collection radio button label components for ViewComponent v2.54.0 and above.
21
+ - Extracted form component logic out of generated components to ease future
22
+ updates.
23
+ - Added the `vcfb:initializer` generator.
24
+
25
+ > **Breaking Change**: If you have previously run the component generator, you
26
+ > will need to re-run `vcfb:component` and merge the changes into your existing
27
+ > components.
28
+
7
29
  ## 1.0.0
8
30
 
9
31
  - Initial release
data/README.md CHANGED
@@ -64,6 +64,36 @@ a class that inherits from it when using `form_with` or `form_for`.
64
64
  <% end %>
65
65
  ```
66
66
 
67
+ Generated components support `before_initialize`, `after_initialization`, and `around_initialize` callbacks to minimize the need to override the initlialize methods.
68
+
69
+ ```ruby
70
+ module Form
71
+ module Label
72
+ after_initialize :set_component_options
73
+
74
+ private
75
+
76
+ def set_component_options
77
+ @size = @options.delete(:size) || :default
78
+ end
79
+ end
80
+ end
81
+ ```
82
+
83
+ By default, components will inherit from `ApplicationComponent` if it exists or
84
+ `ViewComponent::Base` if it does not. If you wish to change this behavior,
85
+ generate an initializer and specify the `parent_component`.
86
+
87
+ ```sh
88
+ rails generate vcfb:initializer
89
+ ```
90
+
91
+ ```ruby
92
+ VCFB.configure do |config|
93
+ config.parent_component = "MyCustomBaseComponent"
94
+ end
95
+ ```
96
+
67
97
  ## Development
68
98
 
69
99
  After checking out the repo, run `bin/setup` to install dependencies. Then, run
@@ -137,6 +137,11 @@ module Vcfb
137
137
  end
138
138
  end
139
139
 
140
+ def create_form_component
141
+ copy_file "component.html.erb", "#{destination}/component.html.erb"
142
+ template "component.rb.tt", "#{destination}/component.rb"
143
+ end
144
+
140
145
  private
141
146
 
142
147
  def destination
@@ -1,3 +1,3 @@
1
1
  <%= form_element @options do %>
2
- <%= content || @text %>
2
+ <%= content.presence || @text %>
3
3
  <% end %>
@@ -1,17 +1,6 @@
1
1
  <% module_namespacing do -%>
2
2
  module Button
3
- class Component < <%= defined?(ApplicationComponent) ? "ApplicationComponent" : "ViewComponent::Base" %>
4
- include VCFB::ActsAsFormComponent
5
-
6
- def initialize(form, text = nil, options = {})
7
- @form = form
8
- @text = text
9
- @options = <%= defined?(TagOptions::Hash) ? "TagOptions::Hash.new(options)" : "options" %>
10
- end
11
-
12
- def form_element(options = {}, &block)
13
- button_tag(options, &block)
14
- end
3
+ class Component < VCFB::Component::Button
15
4
  end
16
5
  end
17
6
  <% end -%>
@@ -1,19 +1,6 @@
1
1
  <% module_namespacing do -%>
2
2
  module CheckBox
3
- class Component < <%= defined?(ApplicationComponent) ? "ApplicationComponent" : "ViewComponent::Base" %>
4
- include VCFB::ActsAsFormComponent
5
-
6
- def initialize(form, method, options = {}, checked_value = "1", unchecked_value = "0")
7
- @form = form
8
- @method = method
9
- @options = <%= defined?(TagOptions::Hash) ? "TagOptions::Hash.new(options)" : "options" %>
10
- @checked_value = checked_value
11
- @unchecked_value = unchecked_value
12
- end
13
-
14
- def form_element(options = {})
15
- check_box(@form.object_name, @method, options, @checked_value, @unchecked_value)
16
- end
3
+ class Component < VCFB::Component::CheckBox
17
4
  end
18
5
  end
19
6
  <% end -%>
@@ -1,20 +1,7 @@
1
1
  <% module_namespacing do -%>
2
2
  module CollectionCheckBoxes
3
3
  module CheckBox
4
- class Component < <%= defined?(ApplicationComponent) ? "ApplicationComponent" : "ViewComponent::Base" %>
5
- include VCFB::ActsAsFormComponent
6
-
7
- def initialize(form, method, options = {}, checked_value = "1", unchecked_value = "0")
8
- @form = form
9
- @method = method
10
- @options = <%= defined?(TagOptions::Hash) ? "TagOptions::Hash.new(options)" : "options" %>
11
- @checked_value = checked_value
12
- @unchecked_value = unchecked_value
13
- end
14
-
15
- def form_element(options = {})
16
- check_box(@form.object_name, @method, options, @checked_value, @unchecked_value)
17
- end
4
+ class Component < VCFB::Component::CheckBox
18
5
  end
19
6
  end
20
7
  end
@@ -1,3 +1,3 @@
1
1
  <%= form_element @options, @html_options do |builder| %>
2
- <%= content(builder) %>
2
+ <%= content %>
3
3
  <% end %>
@@ -1,29 +1,6 @@
1
1
  <% module_namespacing do -%>
2
2
  module CollectionCheckBoxes
3
- class Component < <%= defined?(ApplicationComponent) ? "ApplicationComponent" : "ViewComponent::Base" %>
4
- include VCFB::ActsAsFormCollectionComponent
5
-
6
- def initialize(form, method, collection, value_method, text_method, options = {}, html_options = {})
7
- @form = form
8
- @method = method
9
- @collection = collection
10
- @value_method = value_method
11
- @text_method = text_method
12
- @options = <%= defined?(TagOptions::Hash) ? "TagOptions::Hash.new(options)" : "options" %>
13
- @html_options = <%= defined?(TagOptions::Hash) ? "TagOptions::Hash.new(html_options)" : "html_options" %>
14
- end
15
-
16
- def form_element(options = {}, html_options = {}, &block)
17
- collection_check_boxes(@form.object_name, @method, @collection, @value_method, @text_method, options, html_options) do |builder|
18
- block&.call(builder)
19
- end
20
- end
21
-
22
- private
23
-
24
- def default_content(builder)
25
- builder.check_box + builder.label
26
- end
3
+ class Component < VCFB::Component::CollectionCheckBoxes
27
4
  end
28
5
  end
29
6
  <% end -%>
@@ -1,3 +1,3 @@
1
1
  <%= form_element @options do %>
2
- <%= content.presence || @text %>
2
+ <%= content.presence || @text || default_text %>
3
3
  <% end %>
@@ -1,20 +1,7 @@
1
1
  <% module_namespacing do -%>
2
2
  module CollectionCheckBoxes
3
3
  module Label
4
- class Component < <%= defined?(ApplicationComponent) ? "ApplicationComponent" : "ViewComponent::Base" %>
5
- include VCFB::ActsAsFormLabelComponent
6
-
7
- def initialize(form, method, text = nil, options = {})
8
- @form = form
9
- @method = method
10
- @text = text
11
- @options = <%= defined?(TagOptions::Hash) ? "TagOptions::Hash.new(options)" : "options" %>
12
- end
13
-
14
- def form_element(options = {}, &block)
15
- @text = capture(&block) if block
16
- label(@form.object_name, @method, @text, options)
17
- end
4
+ class Component < VCFB::Component::Label
18
5
  end
19
6
  end
20
7
  end
@@ -1,3 +1,3 @@
1
1
  <%= form_element @options, @html_options do |builder| %>
2
- <%= content(builder) %>
2
+ <%= content %>
3
3
  <% end %>
@@ -1,29 +1,6 @@
1
1
  <% module_namespacing do -%>
2
2
  module CollectionRadioButtons
3
- class Component < <%= defined?(ApplicationComponent) ? "ApplicationComponent" : "ViewComponent::Base" %>
4
- include VCFB::ActsAsFormCollectionComponent
5
-
6
- def initialize(form, method, collection, value_method, text_method, options = {}, html_options = {})
7
- @form = form
8
- @method = method
9
- @collection = collection
10
- @value_method = value_method
11
- @text_method = text_method
12
- @options = <%= defined?(TagOptions::Hash) ? "TagOptions::Hash.new(options)" : "options" %>
13
- @html_options = <%= defined?(TagOptions::Hash) ? "TagOptions::Hash.new(html_options)" : "html_options" %>
14
- end
15
-
16
- def form_element(options = {}, html_options = {}, &block)
17
- collection_radio_buttons(@form.object_name, @method, @collection, @value_method, @text_method, options, html_options) do |builder|
18
- block&.call(builder)
19
- end
20
- end
21
-
22
- private
23
-
24
- def default_content(builder)
25
- builder.radio_button + builder.label
26
- end
3
+ class Component < VCFB::Component::CollectionRadioButtons
27
4
  end
28
5
  end
29
6
  <% end -%>
@@ -1,3 +1,3 @@
1
1
  <%= form_element @options do %>
2
- <%= content.presence || @text %>
2
+ <%= content.presence || @text || default_text %>
3
3
  <% end %>
@@ -1,20 +1,7 @@
1
1
  <% module_namespacing do -%>
2
2
  module CollectionRadioButtons
3
3
  module Label
4
- class Component < <%= defined?(ApplicationComponent) ? "ApplicationComponent" : "ViewComponent::Base" %>
5
- include VCFB::ActsAsFormLabelComponent
6
-
7
- def initialize(form, method, text = nil, options = {})
8
- @form = form
9
- @method = method
10
- @text = text
11
- @options = <%= defined?(TagOptions::Hash) ? "TagOptions::Hash.new(options)" : "options" %>
12
- end
13
-
14
- def form_element(options = {}, &block)
15
- @text = capture(&block) if block
16
- label(@form.object_name, @method, @text, options)
17
- end
4
+ class Component < VCFB::Component::Label
18
5
  end
19
6
  end
20
7
  end
@@ -1,19 +1,7 @@
1
1
  <% module_namespacing do -%>
2
2
  module CollectionRadioButtons
3
3
  module RadioButton
4
- class Component < <%= defined?(ApplicationComponent) ? "ApplicationComponent" : "ViewComponent::Base" %>
5
- include VCFB::ActsAsFormComponent
6
-
7
- def initialize(form, method, value, options = {})
8
- @form = form
9
- @method = method
10
- @value = value
11
- @options = <%= defined?(TagOptions::Hash) ? "TagOptions::Hash.new(options)" : "options" %>
12
- end
13
-
14
- def form_element(options = {})
15
- radio_button(@form.object_name, @method, @value, options)
16
- end
4
+ class Component < VCFB::Component::RadioButton
17
5
  end
18
6
  end
19
7
  end
@@ -1,21 +1,6 @@
1
1
  <% module_namespacing do -%>
2
2
  module CollectionSelect
3
- class Component < <%= defined?(ApplicationComponent) ? "ApplicationComponent" : "ViewComponent::Base" %>
4
- include VCFB::ActsAsFormCollectionComponent
5
-
6
- def initialize(form, method, collection, value_method, text_method, options = {}, html_options = {})
7
- @form = form
8
- @method = method
9
- @collection = collection
10
- @value_method = value_method
11
- @text_method = text_method
12
- @options = <%= defined?(TagOptions::Hash) ? "TagOptions::Hash.new(options)" : "options" %>
13
- @html_options = <%= defined?(TagOptions::Hash) ? "TagOptions::Hash.new(html_options)" : "html_options" %>
14
- end
15
-
16
- def form_element(options = {}, html_options = {})
17
- collection_select(@form.object_name, @method, @collection, @value_method, @text_method, options, html_options)
18
- end
3
+ class Component < VCFB::Component::CollectionSelect
19
4
  end
20
5
  end
21
6
  <% end -%>
@@ -1,17 +1,6 @@
1
1
  <% module_namespacing do -%>
2
2
  module ColorField
3
- class Component < <%= defined?(ApplicationComponent) ? "ApplicationComponent" : "ViewComponent::Base" %>
4
- include VCFB::ActsAsFormComponent
5
-
6
- def initialize(form, method, options = {})
7
- @form = form
8
- @method = method
9
- @options = <%= defined?(TagOptions::Hash) ? "TagOptions::Hash.new(options)" : "options" %>
10
- end
11
-
12
- def form_element(options = {})
13
- color_field(@form.object_name, @method, options)
14
- end
3
+ class Component < VCFB::Component::ColorField
15
4
  end
16
5
  end
17
6
  <% end -%>
@@ -0,0 +1,3 @@
1
+ <%= form_tag @options do |form| %>
2
+ <%= content %>
3
+ <% end %>
@@ -0,0 +1,4 @@
1
+ <% module_namespacing do -%>
2
+ class Component < VCFB::Component::Form
3
+ end
4
+ <% end -%>
@@ -1,17 +1,6 @@
1
1
  <% module_namespacing do -%>
2
2
  module DateField
3
- class Component < <%= defined?(ApplicationComponent) ? "ApplicationComponent" : "ViewComponent::Base" %>
4
- include VCFB::ActsAsFormComponent
5
-
6
- def initialize(form, method, options = {})
7
- @form = form
8
- @method = method
9
- @options = <%= defined?(TagOptions::Hash) ? "TagOptions::Hash.new(options)" : "options" %>
10
- end
11
-
12
- def form_element(options = {})
13
- date_field(@form.object_name, @method, options)
14
- end
3
+ class Component < VCFB::Component::DateField
15
4
  end
16
5
  end
17
6
  <% end -%>
@@ -1,18 +1,6 @@
1
1
  <% module_namespacing do -%>
2
2
  module DateSelect
3
- class Component < <%= defined?(ApplicationComponent) ? "ApplicationComponent" : "ViewComponent::Base" %>
4
- include VCFB::ActsAsFormComponent
5
-
6
- def initialize(form, method, options = {}, html_options = {})
7
- @form = form
8
- @method = method
9
- @options = <%= defined?(TagOptions::Hash) ? "TagOptions::Hash.new(options)" : "options" %>
10
- @html_options = <%= defined?(TagOptions::Hash) ? "TagOptions::Hash.new(html_options)" : "html_options" %>
11
- end
12
-
13
- def form_element(options = {}, html_options = {})
14
- date_select(@form.object_name, @method, options, html_options)
15
- end
3
+ class Component < VCFB::Component::DateSelect
16
4
  end
17
5
  end
18
6
  <% end -%>
@@ -1,17 +1,6 @@
1
1
  <% module_namespacing do -%>
2
2
  module DatetimeField
3
- class Component < <%= defined?(ApplicationComponent) ? "ApplicationComponent" : "ViewComponent::Base" %>
4
- include VCFB::ActsAsFormComponent
5
-
6
- def initialize(form, method, options = {})
7
- @form = form
8
- @method = method
9
- @options = <%= defined?(TagOptions::Hash) ? "TagOptions::Hash.new(options)" : "options" %>
10
- end
11
-
12
- def form_element(options = {})
13
- datetime_field(@form.object_name, @method, options)
14
- end
3
+ class Component < VCFB::Component::DatetimeField
15
4
  end
16
5
  end
17
6
  <% end -%>
@@ -1,18 +1,6 @@
1
1
  <% module_namespacing do -%>
2
2
  module DatetimeSelect
3
- class Component < <%= defined?(ApplicationComponent) ? "ApplicationComponent" : "ViewComponent::Base" %>
4
- include VCFB::ActsAsFormComponent
5
-
6
- def initialize(form, method, options = {}, html_options = {})
7
- @form = form
8
- @method = method
9
- @options = <%= defined?(TagOptions::Hash) ? "TagOptions::Hash.new(options)" : "options" %>
10
- @html_options = <%= defined?(TagOptions::Hash) ? "TagOptions::Hash.new(html_options)" : "html_options" %>
11
- end
12
-
13
- def form_element(options = {}, html_options = {})
14
- datetime_select(@form.object_name, @method, options, html_options)
15
- end
3
+ class Component < VCFB::Component::DatetimeSelect
16
4
  end
17
5
  end
18
6
  <% end -%>
@@ -1,17 +1,6 @@
1
1
  <% module_namespacing do -%>
2
2
  module EmailField
3
- class Component < <%= defined?(ApplicationComponent) ? "ApplicationComponent" : "ViewComponent::Base" %>
4
- include VCFB::ActsAsFormComponent
5
-
6
- def initialize(form, method, options = {})
7
- @form = form
8
- @method = method
9
- @options = <%= defined?(TagOptions::Hash) ? "TagOptions::Hash.new(options)" : "options" %>
10
- end
11
-
12
- def form_element(options = {})
13
- email_field(@form.object_name, @method, options)
14
- end
3
+ class Component < VCFB::Component::EmailField
15
4
  end
16
5
  end
17
6
  <% end -%>
@@ -1,17 +1,6 @@
1
1
  <% module_namespacing do -%>
2
2
  module FileField
3
- class Component < <%= defined?(ApplicationComponent) ? "ApplicationComponent" : "ViewComponent::Base" %>
4
- include VCFB::ActsAsFormComponent
5
-
6
- def initialize(form, method, options = {})
7
- @form = form
8
- @method = method
9
- @options = <%= defined?(TagOptions::Hash) ? "TagOptions::Hash.new(options)" : "options" %>
10
- end
11
-
12
- def form_element(options = {})
13
- file_field(@form.object_name, @method, options)
14
- end
3
+ class Component < VCFB::Component::FileField
15
4
  end
16
5
  end
17
6
  <% end -%>
@@ -1,23 +1,6 @@
1
1
  <% module_namespacing do -%>
2
2
  module GroupedCollectionSelect
3
- class Component < <%= defined?(ApplicationComponent) ? "ApplicationComponent" : "ViewComponent::Base" %>
4
- include VCFB::ActsAsFormCollectionComponent
5
-
6
- def initialize(form, method, collection, group_method, group_label_method, option_key_method, option_value_method, options = {}, html_options = {})
7
- @form = form
8
- @method = method
9
- @collection = collection
10
- @group_method = group_method
11
- @group_label_method = group_label_method
12
- @option_key_method = option_key_method
13
- @option_value_method = option_value_method
14
- @options = <%= defined?(TagOptions::Hash) ? "TagOptions::Hash.new(options)" : "options" %>
15
- @html_options = <%= defined?(TagOptions::Hash) ? "TagOptions::Hash.new(html_options)" : "html_options" %>
16
- end
17
-
18
- def form_element(options = {}, html_options = {})
19
- grouped_collection_select(@form.object_name, @method, @collection, @group_method, @group_label_method, @option_key_method, @option_value_method, options, html_options)
20
- end
3
+ class Component < VCFB::Component::GroupedCollectionSelect
21
4
  end
22
5
  end
23
6
  <% end -%>
@@ -1,3 +1,3 @@
1
1
  <%= form_element @options do %>
2
- <%= content.presence || @text %>
2
+ <%= content.presence || @text || default_text %>
3
3
  <% end %>
@@ -1,19 +1,6 @@
1
1
  <% module_namespacing do -%>
2
2
  module Label
3
- class Component < <%= defined?(ApplicationComponent) ? "ApplicationComponent" : "ViewComponent::Base" %>
4
- include VCFB::ActsAsFormLabelComponent
5
-
6
- def initialize(form, method, text = nil, options = {})
7
- @form = form
8
- @method = method
9
- @text = text
10
- @options = <%= defined?(TagOptions::Hash) ? "TagOptions::Hash.new(options)" : "options" %>
11
- end
12
-
13
- def form_element(options = {}, &block)
14
- @text = capture(&block) if block
15
- label(@form.object_name, @method, @text, options)
16
- end
3
+ class Component < VCFB::Component::Label
17
4
  end
18
5
  end
19
6
  <% end -%>
@@ -1,17 +1,6 @@
1
1
  <% module_namespacing do -%>
2
2
  module MonthField
3
- class Component < <%= defined?(ApplicationComponent) ? "ApplicationComponent" : "ViewComponent::Base" %>
4
- include VCFB::ActsAsFormComponent
5
-
6
- def initialize(form, method, options = {})
7
- @form = form
8
- @method = method
9
- @options = <%= defined?(TagOptions::Hash) ? "TagOptions::Hash.new(options)" : "options" %>
10
- end
11
-
12
- def form_element(options = {})
13
- month_field(@form.object_name, @method, options)
14
- end
3
+ class Component < VCFB::Component::MonthField
15
4
  end
16
5
  end
17
6
  <% end -%>
@@ -1,17 +1,6 @@
1
1
  <% module_namespacing do -%>
2
2
  module NumberField
3
- class Component < <%= defined?(ApplicationComponent) ? "ApplicationComponent" : "ViewComponent::Base" %>
4
- include VCFB::ActsAsFormComponent
5
-
6
- def initialize(form, method, options = {})
7
- @form = form
8
- @method = method
9
- @options = <%= defined?(TagOptions::Hash) ? "TagOptions::Hash.new(options)" : "options" %>
10
- end
11
-
12
- def form_element(options = {})
13
- number_field(@form.object_name, @method, options)
14
- end
3
+ class Component < VCFB::Component::NumberField
15
4
  end
16
5
  end
17
6
  <% end -%>
@@ -1,17 +1,6 @@
1
1
  <% module_namespacing do -%>
2
2
  module PasswordField
3
- class Component < <%= defined?(ApplicationComponent) ? "ApplicationComponent" : "ViewComponent::Base" %>
4
- include VCFB::ActsAsFormComponent
5
-
6
- def initialize(form, method, options = {})
7
- @form = form
8
- @method = method
9
- @options = <%= defined?(TagOptions::Hash) ? "TagOptions::Hash.new(options)" : "options" %>
10
- end
11
-
12
- def form_element(options = {})
13
- password_field(@form.object_name, @method, options)
14
- end
3
+ class Component < VCFB::Component::PasswordField
15
4
  end
16
5
  end
17
6
  <% end -%>
@@ -1,18 +1,6 @@
1
1
  <% module_namespacing do -%>
2
2
  module RadioButton
3
- class Component < <%= defined?(ApplicationComponent) ? "ApplicationComponent" : "ViewComponent::Base" %>
4
- include VCFB::ActsAsFormComponent
5
-
6
- def initialize(form, method, value, options = {})
7
- @form = form
8
- @method = method
9
- @value = value
10
- @options = <%= defined?(TagOptions::Hash) ? "TagOptions::Hash.new(options)" : "options" %>
11
- end
12
-
13
- def form_element(options = {})
14
- radio_button(@form.object_name, @method, @value, options)
15
- end
3
+ class Component < VCFB::Component::RadioButton
16
4
  end
17
5
  end
18
6
  <% end -%>
@@ -1,17 +1,6 @@
1
1
  <% module_namespacing do -%>
2
2
  module RangeField
3
- class Component < <%= defined?(ApplicationComponent) ? "ApplicationComponent" : "ViewComponent::Base" %>
4
- include VCFB::ActsAsFormComponent
5
-
6
- def initialize(form, method, options = {})
7
- @form = form
8
- @method = method
9
- @options = <%= defined?(TagOptions::Hash) ? "TagOptions::Hash.new(options)" : "options" %>
10
- end
11
-
12
- def form_element(options = {})
13
- range_field(@form.object_name, @method, options)
14
- end
3
+ class Component < VCFB::Component::RangeField
15
4
  end
16
5
  end
17
6
  <% end -%>