phlex-rails 2.0.1 → 2.1.0.rc1

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: 9132f7408f8894ff8986d6cd0ee5bcb3ad4b2b9b31a76d662ae2bb8a94795857
4
- data.tar.gz: 37a11261dfec101579e1b68478895d37b1e449c560f2063b7d18246955374a13
3
+ metadata.gz: 10a23e91480332f073f0878f2ac0f0f2fa4ed528efd0d4ff23801e1ec707255c
4
+ data.tar.gz: 7858023562afee3a06e5c3ec902d3796c702b1217ed29a6b8b692ce838136489
5
5
  SHA512:
6
- metadata.gz: 0aaa46676771388eb1da90da857964ab96efa2ed6569318107707bf900ac721bb2f1fac69b7c7bb54b6267f0e280d24beb1baa2237477e2396674fb164d21c5c
7
- data.tar.gz: 15e57ba0d534f7915b4f097970db93e512791b85ae6d061c4bb7f7a4f235dba7f1564fe0e5364d25fa3d8920df2125eb0d700257bf9577b93a8654213edd1681
6
+ metadata.gz: 0cbd67ad440ba398f12c6c4581e1b7edf0abf53697e7d1cf8a5511ef09524d837161ef49604e5476b385ac55d850aa56db3cd5e3cd4d77168b51439ac0ac8f6b
7
+ data.tar.gz: d067dc252a8c3474d2125e72e25fd619874067391d9924a5a6b71296825079ebcb94003df14261b5b4df356830ad56da1781ce18f11beeb2d7e46dea277a4e09
@@ -8,9 +8,9 @@ module Components
8
8
  end
9
9
 
10
10
  Rails.autoloaders.main.push_dir(
11
- "#{Rails.root}/app/views", namespace: Views
11
+ Rails.root.join("app/views"), namespace: Views
12
12
  )
13
13
 
14
14
  Rails.autoloaders.main.push_dir(
15
- "#{Rails.root}/app/components", namespace: Components
15
+ Rails.root.join("app/components"), namespace: Components
16
16
  )
@@ -1,40 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "forwardable"
4
-
5
3
  module Phlex::Rails
6
4
  class Buffered < BasicObject
7
- extend ::Forwardable
8
-
9
- def self.define_builder_yielding_method(method_name, builder)
10
- class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
11
- # frozen_string_literal: true
12
-
13
- def #{method_name}(*args, **kwargs, &block)
14
- output = if block
15
- @object.#{method_name}(*args, **kwargs) { |builder|
16
- @component.capture do
17
- yield(
18
- ::#{builder.name}.new(builder,
19
- component: @component
20
- )
21
- )
22
- end
23
- }
24
- else
25
- @object.#{method_name}(*args, **kwargs)
26
- end
27
-
28
- case output
29
- when ::ActiveSupport::SafeBuffer
30
- @component.raw(output)
31
- end
32
-
33
- nil
34
- end
35
- RUBY
36
- end
37
-
38
5
  def initialize(object, component:)
39
6
  @object = object
40
7
  @component = component
@@ -45,18 +12,15 @@ module Phlex::Rails
45
12
  end
46
13
 
47
14
  def method_missing(*, **, &block)
48
- output = if block
49
- @object.public_send(*, **) { |*a| @component.capture(*a, &block) }
15
+ if block
16
+ @component.raw(
17
+ @object.public_send(*, **) { |*a| @component.capture(*a, &block) }
18
+ )
50
19
  else
51
- @object.public_send(*, **)
20
+ @component.raw(
21
+ @object.public_send(*, **)
22
+ )
52
23
  end
53
-
54
- case output
55
- when ::ActiveSupport::SafeBuffer
56
- @component.raw(output)
57
- end
58
-
59
- nil
60
24
  end
61
25
  end
62
26
  end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Phlex::Rails::CheckboxBuilder < Phlex::Rails::Decorator
4
+ def text(...) = @object.text(...)
5
+ def value(...) = @object.value(...)
6
+ def object(...) = @object.object(...)
7
+
8
+ output def label(...) = nil
9
+ output def checkbox(...) = nil
10
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Phlex::Rails::Decorator < BasicObject
4
+ def self.output(method_name)
5
+ class_eval(<<~RUBY, __FILE__, __LINE__ + 1)
6
+ def #{method_name}(...)
7
+ @component.raw(
8
+ @object.#{method_name}(...)
9
+ )
10
+ end
11
+ RUBY
12
+ end
13
+
14
+ def initialize(object, component:)
15
+ @object = object
16
+ @component = component
17
+ end
18
+
19
+ def respond_to_missing?(method_name, include_private = false)
20
+ @object.respond_to?(method_name, include_private)
21
+ end
22
+
23
+ def method_missing(...)
24
+ @object.public_send(...)
25
+ end
26
+ end
@@ -0,0 +1,123 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Phlex::Rails::FormBuilder < Phlex::Rails::Decorator
4
+ define_method :__caller_locations__, ::Object.instance_method(:caller_locations)
5
+
6
+ def id(...) = @object.id(...)
7
+ def to_model(...) = @object.to_model(...)
8
+ def field_id(...) = @object.field_id(...)
9
+ def field_name(...) = @object.field_name(...)
10
+ def to_partial_path(...) = @object.to_partial_path(...)
11
+
12
+ def multipart=(value)
13
+ @object.multipart = value
14
+ end
15
+
16
+ output def button(...) = nil
17
+ output def check_box(...) = nil
18
+ output def checkbox(...) = nil
19
+ output def collection_select(...) = nil
20
+ output def color_field(...) = nil
21
+ output def date_field(...) = nil
22
+ output def date_select(...) = nil
23
+ output def datetime_field(...) = nil
24
+ output def datetime_local_field(...) = nil
25
+ output def datetime_select(...) = nil
26
+ output def email_field(...) = nil
27
+ output def file_field(...) = nil
28
+ output def grouped_collection_select(...) = nil
29
+ output def hidden_field(...) = nil
30
+ output def month_field(...) = nil
31
+ output def number_field(...) = nil
32
+ output def password_field(...) = nil
33
+ output def phone_field(...) = nil
34
+ output def radio_button(...) = nil
35
+ output def range_field(...) = nil
36
+ output def rich_text_area(...) = nil
37
+ output def rich_textarea(...) = nil
38
+ output def search_field(...) = nil
39
+ output def select(...) = nil
40
+ output def submit(...) = nil
41
+ output def telephone_field(...) = nil
42
+ output def text_area(...) = nil
43
+ output def text_field(...) = nil
44
+ output def textarea(...) = nil
45
+ output def time_field(...) = nil
46
+ output def time_select(...) = nil
47
+ output def time_zone_select(...) = nil
48
+ output def url_field(...) = nil
49
+ output def week_field(...) = nil
50
+ output def weekday_select(...) = nil
51
+
52
+ def collection_check_boxes(*, **, &block)
53
+ output = if block
54
+ @object.collection_check_boxes(*, **) do |builder|
55
+ yield ::Phlex::Rails::CheckboxBuilder.new(builder, component: @component)
56
+ end
57
+ else
58
+ @object.collection_check_boxes(*, **)
59
+ end
60
+
61
+ @component.raw(output)
62
+ end
63
+
64
+ def collection_checkboxes(*, **, &block)
65
+ output = if block
66
+ @object.collection_checkboxes(*, **) do |builder|
67
+ yield ::Phlex::Rails::CheckboxBuilder.new(builder, component: @component)
68
+ end
69
+ else
70
+ @object.collection_checkboxes(*, **)
71
+ end
72
+
73
+ @component.raw(output)
74
+ end
75
+
76
+ def collection_radio_buttons(*, **, &block)
77
+ output = if block
78
+ @object.collection_radio_buttons(*, **) do |builder|
79
+ yield ::Phlex::Rails::RadioButtonBuilder.new(builder, component: @component)
80
+ end
81
+ else
82
+ @object.collection_radio_buttons(*, **)
83
+ end
84
+
85
+ @component.raw(output)
86
+ end
87
+
88
+ def fields(*, **, &block)
89
+ output = if block
90
+ @object.fields(*, **) do |builder|
91
+ yield ::Phlex::Rails::FormBuilder.new(builder, component: @component)
92
+ end
93
+ else
94
+ @object.fields(*, **)
95
+ end
96
+
97
+ @component.raw(output)
98
+ end
99
+
100
+ def fields_for(*, **, &block)
101
+ output = if block
102
+ @object.fields_for(*, **) do |builder|
103
+ yield ::Phlex::Rails::FormBuilder.new(builder, component: @component)
104
+ end
105
+ else
106
+ @object.fields_for(*, **)
107
+ end
108
+
109
+ @component.raw(output)
110
+ end
111
+
112
+ def label(*, **, &block)
113
+ output = if block
114
+ @object.label(*, **) do |builder|
115
+ yield ::Phlex::Rails::LabelBuilder.new(builder, component: @component)
116
+ end
117
+ else
118
+ @object.label(*, **)
119
+ end
120
+
121
+ @component.raw(output)
122
+ end
123
+ end
@@ -8,7 +8,7 @@ module Phlex::Rails::HelperMacros
8
8
 
9
9
  def #{method_name}(*args, **kwargs, &block)
10
10
  output = if block
11
- view_context.#{method_name}(*args, **kwargs) { capture(&block) }
11
+ view_context.#{method_name}(*args, **kwargs) { |*args| capture(*args, &block) }
12
12
  else
13
13
  view_context.#{method_name}(*args, **kwargs)
14
14
  end
@@ -25,7 +25,7 @@ module Phlex::Rails::HelperMacros
25
25
 
26
26
  def #{method_name}(*args, **kwargs, &block)
27
27
  if block
28
- view_context.#{method_name}(*args, **kwargs) { capture(&block) }
28
+ view_context.#{method_name}(*args, **kwargs) { |*args| capture(*args, &block) }
29
29
  else
30
30
  view_context.#{method_name}(*args, **kwargs)
31
31
  end
@@ -39,14 +39,8 @@ module Phlex::Rails::HelperMacros
39
39
 
40
40
  def #{method_name}(*args, **kwargs)
41
41
  output = if block_given?
42
- view_context.#{method_name}(*args, **kwargs) { |form|
43
- capture do
44
- yield(
45
- #{builder.name}.new(form,
46
- component: self
47
- )
48
- )
49
- end
42
+ view_context.#{method_name}(*args, **kwargs) { |builder|
43
+ yield #{builder.name}.new(builder, component: self)
50
44
  }
51
45
  else
52
46
  view_context.#{method_name}(*args, **kwargs)
@@ -4,5 +4,5 @@ module Phlex::Rails::Helpers::CollectionCheckBoxes
4
4
  extend Phlex::Rails::HelperMacros
5
5
 
6
6
  # [Rails Docs](https://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-collection_check_boxes)
7
- register_builder_yielding_helper def collection_check_boxes(...) = nil, Phlex::Rails::BufferedCheckboxBuilder
7
+ register_builder_yielding_helper def collection_check_boxes(...) = nil, Phlex::Rails::CheckboxBuilder
8
8
  end
@@ -4,5 +4,5 @@ module Phlex::Rails::Helpers::CollectionRadioButtons
4
4
  extend Phlex::Rails::HelperMacros
5
5
 
6
6
  # [Rails Docs](https://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-collection_radio_buttons)
7
- register_builder_yielding_helper def collection_radio_buttons(...) = nil, Phlex::Rails::BufferedRadioButtonBuilder
7
+ register_builder_yielding_helper def collection_radio_buttons(...) = nil, Phlex::Rails::RadioButtonBuilder
8
8
  end
@@ -4,5 +4,5 @@ module Phlex::Rails::Helpers::Fields
4
4
  extend Phlex::Rails::HelperMacros
5
5
 
6
6
  # [Rails Docs](https://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-fields)
7
- register_builder_yielding_helper def fields(...) = nil, Phlex::Rails::BufferedFormBuilder
7
+ register_builder_yielding_helper def fields(...) = nil, Phlex::Rails::FormBuilder
8
8
  end
@@ -4,5 +4,5 @@ module Phlex::Rails::Helpers::FieldsFor
4
4
  extend Phlex::Rails::HelperMacros
5
5
 
6
6
  # [Rails Docs](https://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-fields_for)
7
- register_builder_yielding_helper def fields_for(...) = nil, Phlex::Rails::BufferedFormBuilder
7
+ register_builder_yielding_helper def fields_for(...) = nil, Phlex::Rails::FormBuilder
8
8
  end
@@ -4,5 +4,5 @@ module Phlex::Rails::Helpers::FormFor
4
4
  extend Phlex::Rails::HelperMacros
5
5
 
6
6
  # [Rails Docs](https://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-form_for)
7
- register_builder_yielding_helper def form_for(...) = nil, Phlex::Rails::BufferedFormBuilder
7
+ register_builder_yielding_helper def form_for(...) = nil, Phlex::Rails::FormBuilder
8
8
  end
@@ -4,5 +4,5 @@ module Phlex::Rails::Helpers::FormWith
4
4
  extend Phlex::Rails::HelperMacros
5
5
 
6
6
  # [Rails Docs](https://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-form_with)
7
- register_builder_yielding_helper def form_with(...) = nil, Phlex::Rails::BufferedFormBuilder
7
+ register_builder_yielding_helper def form_with(...) = nil, Phlex::Rails::FormBuilder
8
8
  end
@@ -4,5 +4,5 @@ module Phlex::Rails::Helpers::Label
4
4
  extend Phlex::Rails::HelperMacros
5
5
 
6
6
  # [Rails Docs](https://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-label)
7
- register_builder_yielding_helper def label(...) = nil, Phlex::Rails::BufferedLabelBuilder
7
+ register_builder_yielding_helper def label(...) = nil, Phlex::Rails::LabelBuilder
8
8
  end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Phlex::Rails::LabelBuilder < Phlex::Rails::Decorator
4
+ def object(...) = @object.object(...)
5
+ def translation(...) = @object.translation(...)
6
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Phlex::Rails::RadioButtonBuilder < Phlex::Rails::Decorator
4
+ def text(...) = @object.text(...)
5
+ def value(...) = @object.value(...)
6
+ def object(...) = @object.object(...)
7
+
8
+ output def label(...) = nil
9
+ output def radio_button(...) = nil
10
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Phlex::Rails::SGML::State
4
+ def buffer
5
+ @user_context[:capture_context]&.output_buffer&.raw_buffer || super
6
+ end
7
+
8
+ def around_capture
9
+ original_capturing = @capturing
10
+ original_fragments = @fragments
11
+
12
+ begin
13
+ @capturing = true
14
+ yield
15
+ ensure
16
+ @capturing = original_capturing
17
+ @fragments = original_fragments
18
+ end
19
+ end
20
+ end
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Phlex::Rails::SGML
4
+ autoload :State, "phlex/rails/sgml/state"
5
+
4
6
  def self.included(base)
5
7
  base.extend ClassMethods
6
8
  base.extend Phlex::Rails::HelperMacros
@@ -13,14 +15,28 @@ module Phlex::Rails::SGML
13
15
  end
14
16
  end
15
17
 
16
- def method_missing(name, *args, **kwargs, &block)
17
- return super unless view_context.respond_to?(name)
18
+ def method_missing(name, ...)
19
+ super
20
+ rescue NoMethodError => e
21
+ if rendering? && view_context.respond_to?(name)
22
+ const_name = name.to_s.gsub("?", "")
18
23
 
19
- const_name = name.to_s.gsub("?", "")
20
- module_name = Phlex::Rails::Helpers.constants.find { |mod| mod.to_s.underscore.gsub("domid", "dom_id") == const_name }
21
- return super unless module_name
24
+ module_name = Phlex::Rails::Helpers.constants.find do |mod|
25
+ mod.name.underscore.gsub("domid", "dom_id") == const_name
26
+ end
22
27
 
23
- raise NoMethodError.new("Try including `Phlex::Rails::Helpers::#{module_name}` in #{self.class.name}.")
28
+ # If we're missing a helper module, raise a NoMethodError with a helpful message,
29
+ # otherwise re-raise the original error.
30
+ if module_name
31
+ raise NoMethodError.new(<<~MESSAGE)
32
+ Try including `Phlex::Rails::Helpers::#{module_name}` in #{self.class.name}.
33
+ MESSAGE
34
+ else
35
+ raise e
36
+ end
37
+ else
38
+ raise e
39
+ end
24
40
  end
25
41
 
26
42
  def partial(*, **, &block)
@@ -51,16 +67,18 @@ module Phlex::Rails::SGML
51
67
  end
52
68
 
53
69
  def view_context
54
- context[:rails_view_context] || (
55
- raise Phlex::Rails::HelpersCalledBeforeRenderError.new(
56
- "Do not use rails helpers until after the view has been rendered."
57
- )
58
- )
70
+ if rendering?
71
+ context[:rails_view_context]
72
+ else
73
+ raise Phlex::Rails::HelpersCalledBeforeRenderError.new(<<~MESSAGE)
74
+ You can’t use Rails view helpers until after the component has started rendering.
75
+ MESSAGE
76
+ end
59
77
  end
60
78
 
61
79
  # If we’re rendered from view_component, we need to capture on the view_component context.
62
80
  def capture_context
63
- context[:view_component_context] || view_context
81
+ context[:capture_context]
64
82
  end
65
83
 
66
84
  def render(renderable = nil, &block)
@@ -70,25 +88,17 @@ module Phlex::Rails::SGML
70
88
  when Class
71
89
  return super if renderable < Phlex::SGML
72
90
  when Enumerable
73
- return super unless ActiveRecord::Relation === renderable
91
+ return super unless defined?(ActiveRecord::Relation) && ActiveRecord::Relation === renderable
74
92
  when nil
75
93
  return super
76
94
  end
77
95
 
78
96
  if renderable.respond_to?(:render_in) || renderable.respond_to?(:to_partial_path)
79
- output = if block
80
- view_context.render(renderable) do |*yielded_args|
81
- if yielded_args.length == 1 && defined?(ViewComponent::Base) && ViewComponent::Base === yielded_args[0]
82
- capture(Phlex::Rails::Buffered.new(yielded_args[0], component: self), &block)
83
- else
84
- capture(*yielded_args, &block)
85
- end
86
- end
97
+ if block
98
+ raw capture_context.render(renderable) { |*a| capture(*a, &block) }
87
99
  else
88
- view_context.render(renderable)
100
+ raw capture_context.render(renderable)
89
101
  end
90
-
91
- raw(output)
92
102
  else
93
103
  super
94
104
  end
@@ -97,27 +107,28 @@ module Phlex::Rails::SGML
97
107
  def render_in(view_context, &erb)
98
108
  case view_context
99
109
  when defined?(ViewComponent::Base) && ViewComponent::Base
100
- context = {
101
- rails_view_context: view_context.helpers,
102
- view_component_context: view_context,
103
- }
110
+ rails_view_context = view_context.helpers
111
+ capture_context = view_context
104
112
  else
105
- context = { rails_view_context: view_context }
113
+ rails_view_context = view_context
114
+ capture_context = view_context
106
115
  end
107
116
 
108
- fragments = context[:rails_view_context].request.headers.fetch("X-Fragments", "").split(",").map(&:strip).presence
117
+ context = {
118
+ rails_view_context:,
119
+ capture_context:,
120
+ }
109
121
 
110
- if erb
111
- call(context:, fragments:) { |*args|
112
- if args.length == 1 && Phlex::SGML === args[0] && !erb.source_location&.[](0)&.end_with?(".rb")
113
- unbuffered = Phlex::Rails::Unbuffered.new(args[0])
114
- raw(view_context.capture(unbuffered, &erb))
115
- else
116
- raw(view_context.capture(*args, &erb))
117
- end
118
- }.html_safe
119
- else
120
- call(context:, fragments:).html_safe
122
+ fragments = if (request = context[:rails_view_context].request) && (fragment_header = request.headers["X-Fragments"])
123
+ fragment_header.split(",").map(&:strip).presence
124
+ end
125
+
126
+ capture_context.capture do
127
+ if erb
128
+ call(context:, fragments:, &erb).html_safe
129
+ else
130
+ call(context:, fragments:).html_safe
131
+ end
121
132
  end
122
133
  end
123
134
 
@@ -125,8 +136,20 @@ module Phlex::Rails::SGML
125
136
  # no-op (see https://github.com/ViewComponent/view_component/issues/2207)
126
137
  end
127
138
 
128
- def capture(...)
129
- super&.html_safe
139
+ def capture(*args, &block)
140
+ if capture_context
141
+ return "" unless block
142
+
143
+ @_state.around_capture do
144
+ if args.length == 0
145
+ capture_context.capture { __yield_content__(&block) }
146
+ else
147
+ capture_context.capture(*args) { __yield_content_with_args__(*args, &block) }
148
+ end
149
+ end
150
+ else
151
+ super
152
+ end
130
153
  end
131
154
 
132
155
  def enable_cache_reloading?
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Phlex
4
4
  module Rails
5
- VERSION = "2.0.1"
5
+ VERSION = "2.1.0.rc1"
6
6
  end
7
7
  end
data/lib/phlex/rails.rb CHANGED
@@ -7,19 +7,19 @@ module Phlex
7
7
  class HelpersCalledBeforeRenderError < StandardError; end
8
8
 
9
9
  autoload :Buffered, "phlex/rails/buffered"
10
- autoload :Unbuffered, "phlex/rails/unbuffered"
10
+ autoload :Decorator, "phlex/rails/decorator"
11
11
 
12
- autoload :BufferedCheckboxBuilder, "phlex/rails/buffered_checkbox_builder"
13
- autoload :BufferedFormBuilder, "phlex/rails/buffered_form_builder"
14
- autoload :BufferedLabelBuilder, "phlex/rails/buffered_label_builder"
15
- autoload :BufferedRadioButtonBuilder, "phlex/rails/buffered_radio_button_builder"
16
-
17
- autoload :SGML, "phlex/rails/sgml"
18
- autoload :HTML, "phlex/rails/html"
19
- autoload :SVG, "phlex/rails/svg"
12
+ autoload :FormBuilder, "phlex/rails/form_builder"
13
+ autoload :LabelBuilder, "phlex/rails/label_builder"
14
+ autoload :CheckboxBuilder, "phlex/rails/checkbox_builder"
15
+ autoload :RadioButtonBuilder, "phlex/rails/radio_button_builder"
20
16
 
21
17
  autoload :CSV, "phlex/rails/csv"
22
18
 
19
+ autoload :SVG, "phlex/rails/svg"
20
+ autoload :HTML, "phlex/rails/html"
21
+ autoload :SGML, "phlex/rails/sgml"
22
+
23
23
  autoload :Helpers, "phlex/rails/helpers"
24
24
  autoload :HelperMacros, "phlex/rails/helper_macros"
25
25
 
@@ -34,5 +34,7 @@ module Phlex
34
34
  HTML.include(Phlex::Rails::HTML)
35
35
  SVG.include(Phlex::Rails::SVG)
36
36
 
37
+ SGML::State.prepend(Phlex::Rails::SGML::State)
38
+
37
39
  ActiveSupport::SafeBuffer.include(Phlex::SGML::SafeObject)
38
40
  end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phlex-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Drapper
8
8
  - Will Cosgrove
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2025-02-15 00:00:00.000000000 Z
11
+ date: 2025-02-28 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: phlex
@@ -17,14 +16,14 @@ dependencies:
17
16
  requirements:
18
17
  - - "~>"
19
18
  - !ruby/object:Gem::Version
20
- version: 2.0.0
19
+ version: 2.0.2
21
20
  type: :runtime
22
21
  prerelease: false
23
22
  version_requirements: !ruby/object:Gem::Requirement
24
23
  requirements:
25
24
  - - "~>"
26
25
  - !ruby/object:Gem::Version
27
- version: 2.0.0
26
+ version: 2.0.2
28
27
  - !ruby/object:Gem::Dependency
29
28
  name: railties
30
29
  requirement: !ruby/object:Gem::Requirement
@@ -68,11 +67,10 @@ files:
68
67
  - lib/phlex-rails.rb
69
68
  - lib/phlex/rails.rb
70
69
  - lib/phlex/rails/buffered.rb
71
- - lib/phlex/rails/buffered_checkbox_builder.rb
72
- - lib/phlex/rails/buffered_form_builder.rb
73
- - lib/phlex/rails/buffered_label_builder.rb
74
- - lib/phlex/rails/buffered_radio_button_builder.rb
70
+ - lib/phlex/rails/checkbox_builder.rb
75
71
  - lib/phlex/rails/csv.rb
72
+ - lib/phlex/rails/decorator.rb
73
+ - lib/phlex/rails/form_builder.rb
76
74
  - lib/phlex/rails/helper_macros.rb
77
75
  - lib/phlex/rails/helpers.rb
78
76
  - lib/phlex/rails/helpers/action_cable_meta_tag.rb
@@ -275,12 +273,14 @@ files:
275
273
  - lib/phlex/rails/helpers/with_output_buffer.rb
276
274
  - lib/phlex/rails/helpers/word_wrap.rb
277
275
  - lib/phlex/rails/html.rb
276
+ - lib/phlex/rails/label_builder.rb
278
277
  - lib/phlex/rails/layout.rb
279
278
  - lib/phlex/rails/partial.rb
279
+ - lib/phlex/rails/radio_button_builder.rb
280
280
  - lib/phlex/rails/sgml.rb
281
+ - lib/phlex/rails/sgml/state.rb
281
282
  - lib/phlex/rails/streaming.rb
282
283
  - lib/phlex/rails/svg.rb
283
- - lib/phlex/rails/unbuffered.rb
284
284
  - lib/phlex/rails/version.rb
285
285
  homepage: https://www.phlex.fun
286
286
  licenses:
@@ -291,7 +291,6 @@ metadata:
291
291
  changelog_uri: https://github.com/phlex-ruby/phlex-rails/releases
292
292
  funding_uri: https://github.com/sponsors/joeldrapper
293
293
  rubygems_mfa_required: 'true'
294
- post_install_message:
295
294
  rdoc_options: []
296
295
  require_paths:
297
296
  - lib
@@ -306,8 +305,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
306
305
  - !ruby/object:Gem::Version
307
306
  version: '0'
308
307
  requirements: []
309
- rubygems_version: 3.5.23
310
- signing_key:
308
+ rubygems_version: 3.6.2
311
309
  specification_version: 4
312
310
  summary: A Phlex adapter for Rails
313
311
  test_files: []
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Phlex::Rails
4
- class BufferedCheckboxBuilder < Buffered
5
- def_delegators :@object,
6
- :object,
7
- :text,
8
- :value
9
- end
10
- end
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Phlex::Rails
4
- class BufferedFormBuilder < Buffered
5
- def_delegators :@object,
6
- :to_model,
7
- :to_partial_path,
8
- :options,
9
- :id,
10
- :is_a?,
11
- :field_helpers,
12
- :multipart=,
13
- :field_name,
14
- :index,
15
- :multipart,
16
- :multipart?,
17
- :emitted_hidden_id?,
18
- :field_id,
19
- :options=,
20
- :object=,
21
- :object_name,
22
- :field_helpers=,
23
- :field_helpers?,
24
- :object_name=,
25
- :object,
26
- :convert_to_model,
27
- :model_name_from_record_or_class
28
-
29
- define_builder_yielding_method :label, ::Phlex::Rails::BufferedLabelBuilder
30
- define_builder_yielding_method :fields, ::Phlex::Rails::BufferedFormBuilder
31
- define_builder_yielding_method :fields_for, ::Phlex::Rails::BufferedFormBuilder
32
- define_builder_yielding_method :collection_check_boxes, ::Phlex::Rails::BufferedCheckboxBuilder
33
- define_builder_yielding_method :collection_radio_buttons, ::Phlex::Rails::BufferedRadioButtonBuilder
34
- end
35
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Phlex::Rails
4
- class BufferedLabelBuilder < Buffered
5
- def_delegators :@object,
6
- :object,
7
- :translation
8
- end
9
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Phlex::Rails
4
- class BufferedRadioButtonBuilder < Buffered
5
- def_delegators :@object,
6
- :object,
7
- :text,
8
- :value
9
- end
10
- end
@@ -1,43 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Phlex::Rails::Unbuffered
4
- def initialize(component)
5
- @component = component
6
- end
7
-
8
- def inspect
9
- "Unbuffered(#{@component.inspect})"
10
- end
11
-
12
- def public_send(...)
13
- @component.public_send(...)
14
- end
15
-
16
- def respond_to_missing?(...)
17
- @component.respond_to?(...)
18
- end
19
-
20
- def method_missing(method_name, *, **, &erb)
21
- component = @component
22
-
23
- if component.respond_to?(method_name)
24
- output = component.capture do
25
- if erb
26
- component.public_send(method_name, *, **) do |*a, **kw|
27
- component.raw(
28
- component.capture_context.capture(
29
- *a,
30
- **kw,
31
- &erb
32
- ),
33
- )
34
- end
35
- else # no erb block
36
- component.public_send(method_name, *, **)
37
- end
38
- end
39
- else
40
- super
41
- end
42
- end
43
- end