view_component-form 0.2.9 → 0.3.0
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 +4 -4
- data/CHANGELOG.md +25 -2
- data/README.md +5 -5
- data/app/components/view_component/form/base_component.rb +0 -2
- data/app/components/view_component/form/field_component.rb +3 -11
- data/app/components/view_component/form/file_field_component.rb +1 -3
- data/app/components/view_component/form/weekday_select_component.rb +8 -12
- data/lib/generators/vcf/builder/templates/builder.rb.erb +2 -2
- data/lib/view_component/form/builder.rb +4 -1
- data/lib/view_component/form/helpers/custom.rb +2 -2
- data/lib/view_component/form/helpers/rails.rb +20 -14
- data/lib/view_component/form/helpers/rails8.rb +35 -0
- data/lib/view_component/form/renderer.rb +3 -3
- data/lib/view_component/form/test_helpers.rb +7 -11
- data/lib/view_component/form/version.rb +1 -1
- metadata +15 -19
- data/lib/view_component/form/class_names_helper.rb +0 -39
- data/lib/view_component/form/helpers/rails_7_backports.rb +0 -25
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 303f19a27ddf8ea02dfcaa077fb20686c5100dda7be4f4338db348de5da11958
|
|
4
|
+
data.tar.gz: 3c33a63d1d96faa2fb67d32d12b0d90af844099e19157402487ebdc84a17fb5f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b52a03445c25fffd9f96d84748c5cb0b242b567f1671403578816b384f4b8e64666bdf2f2f645a336708940e0243b7edc8f80915a151294dc82324fc9af776ba
|
|
7
|
+
data.tar.gz: 2e9f447ac870c23cce962c909123aff114fe92024a98282f79fa329499e4aa42a737246fd59d157e9c6e6f026842090cc6a87296360062f1ef3ea43a260a486f
|
data/CHANGELOG.md
CHANGED
|
@@ -5,7 +5,28 @@ 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
|
-
|
|
8
|
+
|
|
9
|
+
## [0.3.0] - 2025-10-24
|
|
10
|
+
### Added
|
|
11
|
+
- Support for Rails 8.1
|
|
12
|
+
- Support for view_component 4.x
|
|
13
|
+
### Removed
|
|
14
|
+
- Drop Ruby 3.1 support (EOL March 31, 2025)
|
|
15
|
+
- Drop Rails 7.0 support (EOL)
|
|
16
|
+
- Drop Rails 7.1 support (EOL)
|
|
17
|
+
|
|
18
|
+
## [0.2.11] - 2025-04-05
|
|
19
|
+
### Fixed
|
|
20
|
+
- Fix Rails 8 integration (#189)
|
|
21
|
+
|
|
22
|
+
## [0.2.10] - 2025-03-17 (yanked)
|
|
23
|
+
### Added
|
|
24
|
+
- Support for Ruby 3.4 (#186)
|
|
25
|
+
### Removed
|
|
26
|
+
- Drop Ruby 3.0 support (#186)
|
|
27
|
+
- Drop Rails 6.1 support (#186)
|
|
28
|
+
### Fixed
|
|
29
|
+
- Add `text_area` alias to `textarea` helper to follow Rails 8.0 change (#181)
|
|
9
30
|
|
|
10
31
|
## [0.2.9] - 2024-11-09
|
|
11
32
|
### Added
|
|
@@ -124,7 +145,9 @@ Nothing yet.
|
|
|
124
145
|
- Add CHANGELOG (#50)
|
|
125
146
|
- Add CI (#2)
|
|
126
147
|
|
|
127
|
-
[Unreleased]: https://github.com/pantographe/view_component-form/compare/v0.2.
|
|
148
|
+
[Unreleased]: https://github.com/pantographe/view_component-form/compare/v0.2.11...HEAD
|
|
149
|
+
[0.2.11]: https://github.com/pantographe/view_component-form/compare/v0.2.10...v0.2.11
|
|
150
|
+
[0.2.10]: https://github.com/pantographe/view_component-form/compare/v0.2.9...v0.2.10
|
|
128
151
|
[0.2.9]: https://github.com/pantographe/view_component-form/compare/v0.2.8...v0.2.9
|
|
129
152
|
[0.2.8]: https://github.com/pantographe/view_component-form/compare/v0.2.7...v0.2.8
|
|
130
153
|
[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
|
|
17
|
-
- Ruby 3.
|
|
16
|
+
- Rails 7.2+ (with or without ActionText)
|
|
17
|
+
- Ruby 3.2+
|
|
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(:
|
|
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
|
|
|
@@ -32,18 +32,10 @@ module ViewComponent
|
|
|
32
32
|
.map(&:upcase_first)
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return false unless object_errors
|
|
35
|
+
def method_errors?
|
|
36
|
+
return false unless object_errors
|
|
38
37
|
|
|
39
|
-
|
|
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.intersect?(object_method_names)
|
|
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
|
-
|
|
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
|
|
@@ -13,18 +13,14 @@ module ViewComponent
|
|
|
13
13
|
set_html_options!
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
def call
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
|
@@ -14,8 +14,8 @@ class <%= class_name %> < ViewComponent::Form::Builder
|
|
|
14
14
|
# All standard Rails form helpers
|
|
15
15
|
# include ViewComponent::Form::Helpers::Rails
|
|
16
16
|
|
|
17
|
-
#
|
|
18
|
-
# include ViewComponent::Form::Helpers::
|
|
17
|
+
# Adds support for Rails 8
|
|
18
|
+
# include ViewComponent::Form::Helpers::Rails8
|
|
19
19
|
|
|
20
20
|
# Additional form helpers provided by ViewComponent::Form
|
|
21
21
|
# include ViewComponent::Form::Helpers::Custom
|
|
@@ -6,7 +6,10 @@ module ViewComponent
|
|
|
6
6
|
include ViewComponent::Form::Renderer
|
|
7
7
|
include ViewComponent::Form::ValidationContext
|
|
8
8
|
include ViewComponent::Form::Helpers::Rails
|
|
9
|
-
|
|
9
|
+
|
|
10
|
+
if Gem::Version.new(::Rails::VERSION::STRING) >= Gem::Version.new("8.0")
|
|
11
|
+
include ViewComponent::Form::Helpers::Rails8
|
|
12
|
+
end
|
|
10
13
|
include ViewComponent::Form::Helpers::Custom
|
|
11
14
|
end
|
|
12
15
|
end
|
|
@@ -8,8 +8,8 @@ module ViewComponent
|
|
|
8
8
|
render_component(:error_message, @object_name, method, objectify_options(options))
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
def hint(method, text = nil, options = {}, &
|
|
12
|
-
render_component(:hint, @object_name, method, text, objectify_options(options), &
|
|
11
|
+
def hint(method, text = nil, options = {}, &)
|
|
12
|
+
render_component(:hint, @object_name, method, text, objectify_options(options), &)
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
end
|
|
@@ -7,9 +7,12 @@ module ViewComponent
|
|
|
7
7
|
module Rails
|
|
8
8
|
# rubocop:disable Metrics/MethodLength
|
|
9
9
|
def self.included(base)
|
|
10
|
-
base.class_eval do
|
|
10
|
+
base.class_eval do # rubocop:disable Metrics/BlockLength
|
|
11
11
|
(field_helpers - %i[
|
|
12
|
+
text_area
|
|
13
|
+
textarea
|
|
12
14
|
check_box
|
|
15
|
+
checkbox
|
|
13
16
|
datetime_field
|
|
14
17
|
datetime_local_field
|
|
15
18
|
fields
|
|
@@ -31,14 +34,19 @@ module ViewComponent
|
|
|
31
34
|
end # end
|
|
32
35
|
RUBY_EVAL
|
|
33
36
|
end
|
|
37
|
+
|
|
34
38
|
alias_method :phone_field, :telephone_field
|
|
35
39
|
end
|
|
36
40
|
end
|
|
37
41
|
# rubocop:enable Metrics/MethodLength
|
|
38
42
|
|
|
43
|
+
def text_area(method, options = {})
|
|
44
|
+
render_component(:text_area, @object_name, method, objectify_options(options))
|
|
45
|
+
end
|
|
46
|
+
|
|
39
47
|
# See: https://github.com/rails/rails/blob/33d60cb02dcac26d037332410eabaeeb0bdc384c/actionview/lib/action_view/helpers/form_helper.rb#L2280
|
|
40
|
-
def label(method, text = nil, options = {}, &
|
|
41
|
-
render_component(:label, @object_name, method, text, objectify_options(options), &
|
|
48
|
+
def label(method, text = nil, options = {}, &)
|
|
49
|
+
render_component(:label, @object_name, method, text, objectify_options(options), &)
|
|
42
50
|
end
|
|
43
51
|
|
|
44
52
|
def datetime_field(method, options = {})
|
|
@@ -49,9 +57,7 @@ module ViewComponent
|
|
|
49
57
|
alias datetime_local_field datetime_field
|
|
50
58
|
|
|
51
59
|
def check_box(method, options = {}, checked_value = "1", unchecked_value = "0")
|
|
52
|
-
render_component(
|
|
53
|
-
:check_box, @object_name, method, checked_value, unchecked_value, objectify_options(options)
|
|
54
|
-
)
|
|
60
|
+
render_component(:check_box, @object_name, method, checked_value, unchecked_value, objectify_options(options))
|
|
55
61
|
end
|
|
56
62
|
|
|
57
63
|
def radio_button(method, tag_value, options = {})
|
|
@@ -74,20 +80,20 @@ module ViewComponent
|
|
|
74
80
|
render_component(:submit, value, options)
|
|
75
81
|
end
|
|
76
82
|
|
|
77
|
-
def button(value = nil, options = {}, &
|
|
83
|
+
def button(value = nil, options = {}, &)
|
|
78
84
|
if value.is_a?(Hash)
|
|
79
85
|
options = value
|
|
80
86
|
value = nil
|
|
81
87
|
end
|
|
82
88
|
value ||= submit_default_value
|
|
83
|
-
render_component(:button, value, options, &
|
|
89
|
+
render_component(:button, value, options, &)
|
|
84
90
|
end
|
|
85
91
|
|
|
86
92
|
# See: https://github.com/rails/rails/blob/fe76a95b0d252a2d7c25e69498b720c96b243ea2/actionview/lib/action_view/helpers/form_options_helper.rb
|
|
87
|
-
def select(method, choices = nil, options = {}, html_options = {}, &
|
|
93
|
+
def select(method, choices = nil, options = {}, html_options = {}, &)
|
|
88
94
|
render_component(
|
|
89
95
|
:select, @object_name, method, choices, objectify_options(options),
|
|
90
|
-
@default_html_options.merge(html_options), &
|
|
96
|
+
@default_html_options.merge(html_options), &
|
|
91
97
|
)
|
|
92
98
|
end
|
|
93
99
|
|
|
@@ -112,10 +118,10 @@ module ViewComponent
|
|
|
112
118
|
end
|
|
113
119
|
|
|
114
120
|
def collection_check_boxes(method, collection, value_method, text_method, options = {}, html_options = {},
|
|
115
|
-
&
|
|
121
|
+
&)
|
|
116
122
|
render_component(
|
|
117
123
|
:collection_check_boxes, @object_name, method, collection, value_method, text_method,
|
|
118
|
-
objectify_options(options), @default_html_options.merge(html_options), &
|
|
124
|
+
objectify_options(options), @default_html_options.merge(html_options), &
|
|
119
125
|
)
|
|
120
126
|
end
|
|
121
127
|
|
|
@@ -123,11 +129,11 @@ module ViewComponent
|
|
|
123
129
|
method, collection,
|
|
124
130
|
value_method, text_method,
|
|
125
131
|
options = {}, html_options = {},
|
|
126
|
-
&
|
|
132
|
+
&
|
|
127
133
|
)
|
|
128
134
|
render_component(
|
|
129
135
|
:collection_radio_buttons, @object_name, method, collection, value_method, text_method,
|
|
130
|
-
objectify_options(options), @default_html_options.merge(html_options), &
|
|
136
|
+
objectify_options(options), @default_html_options.merge(html_options), &
|
|
131
137
|
)
|
|
132
138
|
end
|
|
133
139
|
# rubocop:enable Metrics/ParameterLists
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ViewComponent
|
|
4
|
+
module Form
|
|
5
|
+
module Helpers
|
|
6
|
+
# Rails 8.0 changed the spelling of a couple form builder methods while adding aliases
|
|
7
|
+
# for backward compatibility. This module adds those new methods.
|
|
8
|
+
#
|
|
9
|
+
# https://github.com/rails/rails/blob/8-0-stable/actionview/CHANGELOG.md#rails-800beta1-september-26-2024
|
|
10
|
+
module Rails8
|
|
11
|
+
def textarea(method, options = {})
|
|
12
|
+
render_component(:text_area, @object_name, method, objectify_options(options))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def checkbox(method, options = {}, checked_value = "1", unchecked_value = "0")
|
|
16
|
+
render_component(:check_box, @object_name, method, checked_value, unchecked_value, objectify_options(options))
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def collection_checkboxes(method, collection, value_method, text_method, options = {}, html_options = {}, # rubocop:disable Metrics/ParameterLists
|
|
20
|
+
&)
|
|
21
|
+
render_component(
|
|
22
|
+
:collection_check_boxes, @object_name, method, collection, value_method, text_method,
|
|
23
|
+
objectify_options(options), @default_html_options.merge(html_options), &
|
|
24
|
+
)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
if defined?(ActionView::Helpers::Tags::ActionText)
|
|
28
|
+
def rich_textarea(method, options = {})
|
|
29
|
+
render_component(:rich_text_area, @object_name, method, objectify_options(options))
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -41,9 +41,9 @@ module ViewComponent
|
|
|
41
41
|
|
|
42
42
|
private
|
|
43
43
|
|
|
44
|
-
def render_component(component_name,
|
|
45
|
-
component = component_klass(component_name).new(self, *
|
|
46
|
-
component.render_in(@template, &
|
|
44
|
+
def render_component(component_name, *, &)
|
|
45
|
+
component = component_klass(component_name).new(self, *)
|
|
46
|
+
component.render_in(@template, &)
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
def objectify_options(options)
|
|
@@ -4,6 +4,10 @@ require "action_controller"
|
|
|
4
4
|
require "action_controller/test_case"
|
|
5
5
|
require "action_view"
|
|
6
6
|
|
|
7
|
+
class TestView < ActionView::Base
|
|
8
|
+
include ActionText::TagHelper if defined?(ActionText)
|
|
9
|
+
end
|
|
10
|
+
|
|
7
11
|
module ViewComponent
|
|
8
12
|
module Form
|
|
9
13
|
module TestHelpers
|
|
@@ -15,18 +19,10 @@ module ViewComponent
|
|
|
15
19
|
:user
|
|
16
20
|
end
|
|
17
21
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
lookup_context = ActionView::LookupContext.new(ActionController::Base.view_paths)
|
|
21
|
-
|
|
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)
|
|
22
|
+
def template
|
|
23
|
+
lookup_context = ActionView::LookupContext.new(ActionController::Base.view_paths)
|
|
27
24
|
|
|
28
|
-
|
|
29
|
-
end
|
|
25
|
+
TestView.new(lookup_context, {}, ApplicationController.new)
|
|
30
26
|
end
|
|
31
27
|
end
|
|
32
28
|
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.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Pantographe
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: actionview
|
|
@@ -16,40 +15,40 @@ dependencies:
|
|
|
16
15
|
requirements:
|
|
17
16
|
- - ">="
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
18
|
+
version: 7.2.0
|
|
20
19
|
- - "<"
|
|
21
20
|
- !ruby/object:Gem::Version
|
|
22
|
-
version: '8.
|
|
21
|
+
version: '8.2'
|
|
23
22
|
type: :runtime
|
|
24
23
|
prerelease: false
|
|
25
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
26
25
|
requirements:
|
|
27
26
|
- - ">="
|
|
28
27
|
- !ruby/object:Gem::Version
|
|
29
|
-
version:
|
|
28
|
+
version: 7.2.0
|
|
30
29
|
- - "<"
|
|
31
30
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '8.
|
|
31
|
+
version: '8.2'
|
|
33
32
|
- !ruby/object:Gem::Dependency
|
|
34
33
|
name: activesupport
|
|
35
34
|
requirement: !ruby/object:Gem::Requirement
|
|
36
35
|
requirements:
|
|
37
36
|
- - ">="
|
|
38
37
|
- !ruby/object:Gem::Version
|
|
39
|
-
version:
|
|
38
|
+
version: 7.2.0
|
|
40
39
|
- - "<"
|
|
41
40
|
- !ruby/object:Gem::Version
|
|
42
|
-
version: '8.
|
|
41
|
+
version: '8.2'
|
|
43
42
|
type: :runtime
|
|
44
43
|
prerelease: false
|
|
45
44
|
version_requirements: !ruby/object:Gem::Requirement
|
|
46
45
|
requirements:
|
|
47
46
|
- - ">="
|
|
48
47
|
- !ruby/object:Gem::Version
|
|
49
|
-
version:
|
|
48
|
+
version: 7.2.0
|
|
50
49
|
- - "<"
|
|
51
50
|
- !ruby/object:Gem::Version
|
|
52
|
-
version: '8.
|
|
51
|
+
version: '8.2'
|
|
53
52
|
- !ruby/object:Gem::Dependency
|
|
54
53
|
name: view_component
|
|
55
54
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -59,7 +58,7 @@ dependencies:
|
|
|
59
58
|
version: 2.34.0
|
|
60
59
|
- - "<"
|
|
61
60
|
- !ruby/object:Gem::Version
|
|
62
|
-
version: '
|
|
61
|
+
version: '5.0'
|
|
63
62
|
type: :runtime
|
|
64
63
|
prerelease: false
|
|
65
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -69,7 +68,7 @@ dependencies:
|
|
|
69
68
|
version: 2.34.0
|
|
70
69
|
- - "<"
|
|
71
70
|
- !ruby/object:Gem::Version
|
|
72
|
-
version: '
|
|
71
|
+
version: '5.0'
|
|
73
72
|
- !ruby/object:Gem::Dependency
|
|
74
73
|
name: zeitwerk
|
|
75
74
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -135,12 +134,11 @@ files:
|
|
|
135
134
|
- lib/generators/vcf/builder/templates/builder.rb.erb
|
|
136
135
|
- lib/view_component/form.rb
|
|
137
136
|
- lib/view_component/form/builder.rb
|
|
138
|
-
- lib/view_component/form/class_names_helper.rb
|
|
139
137
|
- lib/view_component/form/configuration.rb
|
|
140
138
|
- lib/view_component/form/engine.rb
|
|
141
139
|
- lib/view_component/form/helpers/custom.rb
|
|
142
140
|
- lib/view_component/form/helpers/rails.rb
|
|
143
|
-
- lib/view_component/form/helpers/
|
|
141
|
+
- lib/view_component/form/helpers/rails8.rb
|
|
144
142
|
- lib/view_component/form/renderer.rb
|
|
145
143
|
- lib/view_component/form/test_helpers.rb
|
|
146
144
|
- lib/view_component/form/validation_context.rb
|
|
@@ -154,7 +152,6 @@ metadata:
|
|
|
154
152
|
source_code_uri: https://github.com/pantographe/view_component-form
|
|
155
153
|
bug_tracker_uri: https://github.com/pantographe/view_component-form/issues
|
|
156
154
|
rubygems_mfa_required: 'true'
|
|
157
|
-
post_install_message:
|
|
158
155
|
rdoc_options: []
|
|
159
156
|
require_paths:
|
|
160
157
|
- lib
|
|
@@ -162,15 +159,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
162
159
|
requirements:
|
|
163
160
|
- - ">="
|
|
164
161
|
- !ruby/object:Gem::Version
|
|
165
|
-
version: 3.
|
|
162
|
+
version: 3.2.0
|
|
166
163
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
164
|
requirements:
|
|
168
165
|
- - ">="
|
|
169
166
|
- !ruby/object:Gem::Version
|
|
170
167
|
version: '0'
|
|
171
168
|
requirements: []
|
|
172
|
-
rubygems_version: 3.
|
|
173
|
-
signing_key:
|
|
169
|
+
rubygems_version: 3.6.9
|
|
174
170
|
specification_version: 4
|
|
175
171
|
summary: Rails FormBuilder for ViewComponent
|
|
176
172
|
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
|