view_component-form 0.2.9 → 0.2.10

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 124aec584d29d1b7d181aa25ee3293d0719d9cf4c531f7a0d5cb5859b6be734b
4
- data.tar.gz: b78538a52578b141f4c6d8eb45a92d80d8f7bf4f693a63acd9ce36fce80d8921
3
+ metadata.gz: 70dddaed82323d1b71d85b5b08af2207d49806118c83dc6e36ac19294e0e4efc
4
+ data.tar.gz: 1ccea5a6b477af64d68cafadf3805e242a24a5e843152aaee0532b04c6ba443d
5
5
  SHA512:
6
- metadata.gz: d18ac72e6c391c0466be730ab40c6d61ebbf807bc7d2f6a6fb53e35d6f9a23f223a0250e7cf87c6ad5bef507c84e63b141f21af1f2bbcd5baaca050b3b4ab904
7
- data.tar.gz: 31353a6e4c1ff4547981b311229cfdfd01d590601a95b38688d357f4db02c5b2ccaed71cffdf1db1290d3a5bb515132eeecd2c1c0881cb00d5eae0da349b966d
6
+ metadata.gz: 1019f8316a12f90e9225c366e77822d4cb179960fca3560586d6b6dbf3de15572a66fd5921d374f15dcae350250010ba250a921ac897a85d2815859073a4a2da
7
+ data.tar.gz: 2910e5cb17bdb3dc173f5f50871ccc4cde00f9a1a1f5ea522328bd121a8e142799c8b429e7b076c24db38eda0188e2e3a4a3af1cffa57093015b062520fdedc5
data/CHANGELOG.md CHANGED
@@ -5,7 +5,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
7
  ## [Unreleased]
8
- Nothing yet.
8
+ Nothing yet
9
+
10
+ ## [0.2.10] - 2025-03-17
11
+ ### Added
12
+ - Support for Ruby 3.4 (#186)
13
+ ### Removed
14
+ - Drop Ruby 3.0 support (#186)
15
+ - Drop Rails 6.1 support (#186)
16
+ ### Fixed
17
+ - Add `text_area` alias to `textarea` helper to follow Rails 8.0 change (#181)
9
18
 
10
19
  ## [0.2.9] - 2024-11-09
11
20
  ### Added
@@ -124,7 +133,8 @@ Nothing yet.
124
133
  - Add CHANGELOG (#50)
125
134
  - Add CI (#2)
126
135
 
127
- [Unreleased]: https://github.com/pantographe/view_component-form/compare/v0.2.9...HEAD
136
+ [Unreleased]: https://github.com/pantographe/view_component-form/compare/v0.2.10...HEAD
137
+ [0.2.10]: https://github.com/pantographe/view_component-form/compare/v0.2.9...v0.2.10
128
138
  [0.2.9]: https://github.com/pantographe/view_component-form/compare/v0.2.8...v0.2.9
129
139
  [0.2.8]: https://github.com/pantographe/view_component-form/compare/v0.2.7...v0.2.8
130
140
  [0.2.7]: https://github.com/pantographe/view_component-form/compare/v0.2.6...v0.2.7
data/README.md CHANGED
@@ -13,8 +13,8 @@ Development of this gem is sponsored by:
13
13
 
14
14
  This gem is tested on:
15
15
 
16
- - Rails 6.1+ (with or without ActionText)
17
- - Ruby 3.0+
16
+ - Rails 7.0+ (with or without ActionText)
17
+ - Ruby 3.1+
18
18
 
19
19
  ## Installation
20
20
 
@@ -100,7 +100,7 @@ Then use ActionView form builder helpers as you would normally:
100
100
  <%= f.label :password %> <%# renders a ViewComponent::Form::LabelComponent %>
101
101
  <%= f.password_field :password, aria: { describedby: f.field_id(:password, :description) } %>
102
102
  <%# renders a ViewComponent::Form::PasswordFieldComponent %>
103
- <div id="<%= f.field_id(:title, :description) %>">
103
+ <div id="<%= f.field_id(:password, :description) %>">
104
104
  <%= f.hint :password, 'The password should be at least 8 characters long' %>
105
105
  <%# renders a ViewComponent::Form::HintComponent %>
106
106
  <%= f.error_message :password %> <%# renders a ViewComponent::Form::ErrorMessageComponent %>
@@ -358,9 +358,9 @@ The following helpers are currently supported by `ViewComponent::Form`.
358
358
 
359
359
  ### `ActionView::Helpers::FormBuilder`
360
360
 
361
- **Supported:** `button` `check_box` `collection_check_boxes` `collection_radio_buttons` `collection_select` `color_field` `date_field` `date_select` `datetime_field` `datetime_local_field` `datetime_select` `email_field` `fields` `fields_for` `file_field` `field_id` `grouped_collection_select` `hidden_field` `month_field` `number_field` `password_field` `phone_field` `radio_button` `range_field` `search_field` `select` `submit` `telephone_field` `text_area` `text_field` `time_field` `time_select` `time_zone_select` `to_model` `to_partial_path` `url_field` `week_field` `weekday_select`
361
+ **Supported:** `button` `check_box` `collection_check_boxes` `collection_radio_buttons` `collection_select` `color_field` `date_field` `date_select` `datetime_field` `datetime_local_field` `datetime_select` `email_field` `fields` `fields_for` `file_field` `field_id` `grouped_collection_select` `hidden_field` `month_field` `number_field` `password_field` `phone_field` `radio_button` `range_field` `search_field` `select` `submit` `telephone_field` `textarea` (formerly `text_area` before Rails 8) `text_field` `time_field` `time_select` `time_zone_select` `to_model` `to_partial_path` `url_field` `week_field` `weekday_select`
362
362
 
363
- **Partially supported:** `label` (blocks not supported) `rich_text_area` (untested)
363
+ **Partially supported:** `label` (blocks not supported) `rich_textarea` (formerly`rich_text_area` before Rails 8) (untested)
364
364
 
365
365
  **Unsupported for now:** `field_name`
366
366
 
@@ -7,8 +7,6 @@ module ViewComponent
7
7
  attr_accessor :default_options
8
8
  end
9
9
 
10
- include ClassNamesHelper if Gem::Version.new(Rails::VERSION::STRING) < Gem::Version.new("6.1")
11
-
12
10
  attr_reader :form, :object_name, :options
13
11
 
14
12
  delegate :object, to: :form, allow_nil: true
@@ -32,18 +32,10 @@ module ViewComponent
32
32
  .map(&:upcase_first)
33
33
  end
34
34
 
35
- if Gem::Version.new(Rails::VERSION::STRING) >= Gem::Version.new("6.1")
36
- def method_errors?
37
- return false unless object_errors
35
+ def method_errors?
36
+ return false unless object_errors
38
37
 
39
- (object_errors.attribute_names & object_method_names).any?
40
- end
41
- else
42
- def method_errors?
43
- return false unless object_errors
44
-
45
- (object_errors.keys & object_method_names).any?
46
- end
38
+ (object_errors.attribute_names & object_method_names).any?
47
39
  end
48
40
 
49
41
  def value
@@ -6,9 +6,7 @@ module ViewComponent
6
6
  self.tag_klass = ActionView::Helpers::Tags::FileField
7
7
 
8
8
  def before_render
9
- if Gem::Version.new(Rails::VERSION::STRING) >= Gem::Version.new("7.0")
10
- @options = { include_hidden: multiple_file_field_include_hidden }.merge!(options)
11
- end
9
+ @options = { include_hidden: multiple_file_field_include_hidden }.merge!(options)
12
10
  @options = convert_direct_upload_option_to_url(@options.dup)
13
11
 
14
12
  super
@@ -1,10 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module ViewComponent
4
- module Form
5
- class RichTextAreaComponent < FieldComponent
6
- if defined?(ActionView::Helpers::Tags::ActionText) # rubocop:disable Style/IfUnlessModifier
7
- self.tag_klass = ActionView::Helpers::Tags::ActionText
3
+ if Gem::Version.new(Rails::VERSION::STRING) < Gem::Version.new("8.0")
4
+ module ViewComponent
5
+ module Form
6
+ class RichTextAreaComponent < RichTextareaComponent
8
7
  end
9
8
  end
10
9
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ViewComponent
4
+ module Form
5
+ class RichTextareaComponent < FieldComponent
6
+ if defined?(ActionView::Helpers::Tags::ActionText) # rubocop:disable Style/IfUnlessModifier
7
+ self.tag_klass = ActionView::Helpers::Tags::ActionText
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,9 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module ViewComponent
4
- module Form
5
- class TextAreaComponent < FieldComponent
6
- self.tag_klass = ActionView::Helpers::Tags::TextArea
3
+ if Gem::Version.new(Rails::VERSION::STRING) < Gem::Version.new("8.0")
4
+ module ViewComponent
5
+ module Form
6
+ class TextAreaComponent < TextareaComponent
7
+ end
7
8
  end
8
9
  end
9
10
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ViewComponent
4
+ module Form
5
+ class TextareaComponent < FieldComponent
6
+ self.tag_klass = ActionView::Helpers::Tags::TextArea
7
+ end
8
+ end
9
+ end
@@ -13,18 +13,14 @@ module ViewComponent
13
13
  set_html_options!
14
14
  end
15
15
 
16
- def call # rubocop:disable Metrics/MethodLength
17
- if Rails::VERSION::MAJOR >= 7 # rubocop:disable Style/GuardClause
18
- ActionView::Helpers::Tags::WeekdaySelect.new(
19
- object_name,
20
- method_name,
21
- @view_context,
22
- options,
23
- html_options
24
- ).render
25
- else
26
- raise NotImplementedError, "#{self.class} is only available in Rails >= 7"
27
- end
16
+ def call
17
+ ActionView::Helpers::Tags::WeekdaySelect.new(
18
+ object_name,
19
+ method_name,
20
+ @view_context,
21
+ options,
22
+ html_options
23
+ ).render
28
24
  end
29
25
 
30
26
  protected
@@ -6,7 +6,6 @@ module ViewComponent
6
6
  include ViewComponent::Form::Renderer
7
7
  include ViewComponent::Form::ValidationContext
8
8
  include ViewComponent::Form::Helpers::Rails
9
- include ViewComponent::Form::Helpers::Rails7Backports if ::Rails::VERSION::MAJOR < 7
10
9
  include ViewComponent::Form::Helpers::Custom
11
10
  end
12
11
  end
@@ -161,9 +161,10 @@ module ViewComponent
161
161
  end
162
162
 
163
163
  if defined?(ActionView::Helpers::Tags::ActionText)
164
- def rich_text_area(method, options = {})
164
+ def rich_textarea(method, options = {})
165
165
  render_component(:rich_text_area, @object_name, method, objectify_options(options))
166
166
  end
167
+ alias rich_text_area rich_textarea
167
168
  end
168
169
  end
169
170
  # rubocop:enable Metrics/ModuleLength
@@ -15,18 +15,10 @@ module ViewComponent
15
15
  :user
16
16
  end
17
17
 
18
- if Gem::Version.new(Rails::VERSION::STRING) >= Gem::Version.new("6.1")
19
- def template
20
- lookup_context = ActionView::LookupContext.new(ActionController::Base.view_paths)
18
+ def template
19
+ lookup_context = ActionView::LookupContext.new(ActionController::Base.view_paths)
21
20
 
22
- ActionView::Base.new(lookup_context, {}, ApplicationController.new)
23
- end
24
- else
25
- def template
26
- lookup_context = ActionView::LookupContext.new(ActionController::Base.view_paths)
27
-
28
- ActionView::Base.new(lookup_context, {})
29
- end
21
+ ActionView::Base.new(lookup_context, {}, ApplicationController.new)
30
22
  end
31
23
  end
32
24
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ViewComponent
4
4
  module Form
5
- VERSION = "0.2.9"
5
+ VERSION = "0.2.10"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: view_component-form
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.2.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pantographe
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-11-09 00:00:00.000000000 Z
10
+ date: 2025-03-17 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: actionview
@@ -16,7 +15,7 @@ dependencies:
16
15
  requirements:
17
16
  - - ">="
18
17
  - !ruby/object:Gem::Version
19
- version: 6.1.0
18
+ version: 7.0.0
20
19
  - - "<"
21
20
  - !ruby/object:Gem::Version
22
21
  version: '8.1'
@@ -26,7 +25,7 @@ dependencies:
26
25
  requirements:
27
26
  - - ">="
28
27
  - !ruby/object:Gem::Version
29
- version: 6.1.0
28
+ version: 7.0.0
30
29
  - - "<"
31
30
  - !ruby/object:Gem::Version
32
31
  version: '8.1'
@@ -36,7 +35,7 @@ dependencies:
36
35
  requirements:
37
36
  - - ">="
38
37
  - !ruby/object:Gem::Version
39
- version: 6.1.0
38
+ version: 7.0.0
40
39
  - - "<"
41
40
  - !ruby/object:Gem::Version
42
41
  version: '8.1'
@@ -46,7 +45,7 @@ dependencies:
46
45
  requirements:
47
46
  - - ">="
48
47
  - !ruby/object:Gem::Version
49
- version: 6.1.0
48
+ version: 7.0.0
50
49
  - - "<"
51
50
  - !ruby/object:Gem::Version
52
51
  version: '8.1'
@@ -119,12 +118,14 @@ files:
119
118
  - app/components/view_component/form/radio_button_component.rb
120
119
  - app/components/view_component/form/range_field_component.rb
121
120
  - app/components/view_component/form/rich_text_area_component.rb
121
+ - app/components/view_component/form/rich_textarea_component.rb
122
122
  - app/components/view_component/form/search_field_component.rb
123
123
  - app/components/view_component/form/select_component.rb
124
124
  - app/components/view_component/form/submit_component.rb
125
125
  - app/components/view_component/form/telephone_field_component.rb
126
126
  - app/components/view_component/form/text_area_component.rb
127
127
  - app/components/view_component/form/text_field_component.rb
128
+ - app/components/view_component/form/textarea_component.rb
128
129
  - app/components/view_component/form/time_field_component.rb
129
130
  - app/components/view_component/form/time_select_component.rb
130
131
  - app/components/view_component/form/time_zone_select_component.rb
@@ -135,12 +136,10 @@ files:
135
136
  - lib/generators/vcf/builder/templates/builder.rb.erb
136
137
  - lib/view_component/form.rb
137
138
  - lib/view_component/form/builder.rb
138
- - lib/view_component/form/class_names_helper.rb
139
139
  - lib/view_component/form/configuration.rb
140
140
  - lib/view_component/form/engine.rb
141
141
  - lib/view_component/form/helpers/custom.rb
142
142
  - lib/view_component/form/helpers/rails.rb
143
- - lib/view_component/form/helpers/rails_7_backports.rb
144
143
  - lib/view_component/form/renderer.rb
145
144
  - lib/view_component/form/test_helpers.rb
146
145
  - lib/view_component/form/validation_context.rb
@@ -154,7 +153,6 @@ metadata:
154
153
  source_code_uri: https://github.com/pantographe/view_component-form
155
154
  bug_tracker_uri: https://github.com/pantographe/view_component-form/issues
156
155
  rubygems_mfa_required: 'true'
157
- post_install_message:
158
156
  rdoc_options: []
159
157
  require_paths:
160
158
  - lib
@@ -169,8 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
167
  - !ruby/object:Gem::Version
170
168
  version: '0'
171
169
  requirements: []
172
- rubygems_version: 3.5.22
173
- signing_key:
170
+ rubygems_version: 3.6.3
174
171
  specification_version: 4
175
172
  summary: Rails FormBuilder for ViewComponent
176
173
  test_files: []
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Backport of https://api.rubyonrails.org/classes/ActionView/Helpers/TagHelper.html#method-i-class_names
4
- # :nocov:
5
- module ViewComponent
6
- module Form
7
- module ClassNamesHelper
8
- # rubocop:disable Metrics/CyclomaticComplexity
9
- # rubocop:disable Metrics/MethodLength
10
- def build_tag_values(*args)
11
- tag_values = []
12
-
13
- args.each do |tag_value|
14
- case tag_value
15
- when Hash
16
- tag_value.each do |key, val|
17
- tag_values << key.to_s if val && key.present?
18
- end
19
- when Array
20
- tag_values.concat build_tag_values(*tag_value)
21
- else
22
- tag_values << tag_value.to_s if tag_value.present?
23
- end
24
- end
25
-
26
- tag_values
27
- end
28
- # rubocop:enable Metrics/CyclomaticComplexity
29
- # rubocop:enable Metrics/MethodLength
30
-
31
- def class_names(*args)
32
- tokens = build_tag_values(*args).flat_map { |value| value.to_s.split(/\s+/) }.uniq
33
-
34
- safe_join(tokens, " ")
35
- end
36
- end
37
- end
38
- end
39
- # :nocov:
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ViewComponent
4
- module Form
5
- module Helpers
6
- module Rails7Backports
7
- def field_id(method_name, *suffixes, namespace: @options[:namespace], index: @index)
8
- object_name = object_name.model_name.singular if object_name.respond_to?(:model_name)
9
-
10
- sanitized_object_name = object_name.to_s.gsub(/\]\[|[^-a-zA-Z0-9:.]/, "_").delete_suffix("_")
11
-
12
- sanitized_method_name = method_name.to_s.delete_suffix("?")
13
-
14
- [
15
- namespace,
16
- sanitized_object_name.presence,
17
- (index unless sanitized_object_name.empty?),
18
- sanitized_method_name,
19
- *suffixes
20
- ].tap(&:compact!).join("_")
21
- end
22
- end
23
- end
24
- end
25
- end