phlex-rails 0.10.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 555800cbdaf17b6f8b17c861a26a3d3db5d189dc85ac2bb8e4a91ee01a3451a5
4
- data.tar.gz: e6f95ee6e6ed074cb90ed8b5761fca2e5885879a6237e53287c9d19a0f7c3dc5
3
+ metadata.gz: ae91b70fed7b9edbe9f7c617a05a88ce362c9e8a108185e80ffbf5e1e27b519f
4
+ data.tar.gz: 16277016b898e55e5fba68ff0163cc652e2505d4785a5e487800cd2ea1111fe5
5
5
  SHA512:
6
- metadata.gz: 5ebedcdc21e1b898181068e2d71b15c8679c00cb66fc3f923fac36151a37fce36ad2486d7e561e6d9af8de82ea1c975d37e72b40bb01ac00a51a2e3ed2a770f1
7
- data.tar.gz: d3f0a529298f5ae7ce3c1b1628488b076a596bef03225a158baa54a80fd28282072c8d88344d5c0c21ff3071d7023d9765a3545dace66bce7f7ca4c54d8f7624
6
+ metadata.gz: 9f9a3961d6f6170a700844fe41230251cc31e4df5735beada75a13df1126fa058fab550b6608c1becf900f8a7f823f344f646231bafb1dba3d4e6e664a5d9282
7
+ data.tar.gz: a1a8e6e3bb03c9c609074cdd2dca2e254b88fe8c169858157d4cbb07fafaf1396f32d29a76a6edd136693f499de5da30939a92b5148467dc3fac1b9b654bd9b0
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.2.1
1
+ 3.2.2
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --private --hide-api private --markup markdown --exclude lib/generators
data/CHANGELOG.md CHANGED
@@ -2,18 +2,33 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
4
4
 
5
+
6
+ ## [1.1.0] 2023-11-24
7
+
8
+ - Dropped dependency on `rails` and now only depends on `railties`
9
+ - Fix an out of order rendering issue when yielding from a partial rendered with a block delegated from a component’s content block
10
+ - Added `flash` helper adapter in `Phlex::Rails::Helpers::Flash`
11
+ - Removed experimental form component
12
+ - Updated `phlex` dependency to `~> 1.9`
13
+
14
+ ## [1.0.0] 2023-04-19
15
+
16
+ ### Added
17
+
18
+ - Added an adapter for the pluralize view helper.
19
+
5
20
  ## 0.10.0
6
21
 
7
- Added
22
+ ### Added
8
23
 
9
24
  - You can now render procs and lambdas and enumerables of renderables.
10
25
  - Experimental streaming interface
11
26
 
12
- Fixed
27
+ ### Fixed
13
28
 
14
29
  - Escaped ERB captures
15
30
  - Use buffered component unless renderin in a template
16
31
 
17
32
  ***
18
33
 
19
- Before this changelog was introduced, changes were logged in the [release notes](https://github.com/phlex-ruby/phlex/releases).
34
+ Before this changelog was introduced, changes were logged in the [release notes](https://github.com/phlex-ruby/phlex-rails/releases).
data/Gemfile CHANGED
@@ -13,3 +13,5 @@ gem "rubocop"
13
13
  gem "solargraph"
14
14
  gem "view_component"
15
15
  gem "appraisal", github: "excid3/appraisal", branch: "fix-bundle-env"
16
+ gem "yard"
17
+ gem "rails"
@@ -4,6 +4,7 @@ require "forwardable"
4
4
 
5
5
  module Phlex::Rails
6
6
  # A decorator that buffers all missing method calls and captures the blocks passed to them.
7
+ # @api private
7
8
  class Buffered < BasicObject
8
9
  extend ::Forwardable
9
10
 
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Phlex::Rails
4
+ # @api private
4
5
  class BufferedCheckboxBuilder < Buffered
5
6
  # @!method object(...)
6
7
  # @!method text(...)
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Phlex::Rails
4
+ # @api private
4
5
  class BufferedFormBuilder < Buffered
5
6
  # @!method field_id(...)
6
7
  # @!method field_name(...)
@@ -13,6 +14,7 @@ module Phlex::Rails
13
14
  :to_partial_path,
14
15
  :options,
15
16
  :id,
17
+ :is_a?,
16
18
  :field_helpers,
17
19
  :multipart=,
18
20
  :field_name,
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Phlex::Rails
4
+ # @api private
4
5
  class BufferedLabelBuilder < Buffered
5
6
  # @!method object(...)
6
7
  # @!method translation(...)
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Phlex::Rails
4
+ # @api private
4
5
  class BufferedRadioButtonBuilder < Buffered
5
6
  # @!method object(...)
6
7
  # @!method text(...)
@@ -4,6 +4,7 @@ require "rails/engine"
4
4
 
5
5
  module Phlex
6
6
  module Rails
7
+ # @api private
7
8
  class Engine < ::Rails::Engine
8
9
  end
9
10
  end
@@ -465,6 +465,13 @@ module Phlex::Rails::Helpers
465
465
  define_output_helper :file_field_tag
466
466
  end
467
467
 
468
+ module Flash
469
+ extend Phlex::Rails::HelperMacros
470
+
471
+ # @!method flash(...)
472
+ define_value_helper :flash
473
+ end
474
+
468
475
  module FontPath
469
476
  extend Phlex::Rails::HelperMacros
470
477
 
@@ -883,6 +890,14 @@ module Phlex::Rails::Helpers
883
890
  define_output_helper :phone_field_tag
884
891
  end
885
892
 
893
+ module Pluralize
894
+ extend Phlex::Rails::HelperMacros
895
+
896
+ # @!method pluralize(...)
897
+ # @return [String]
898
+ define_value_helper :pluralize
899
+ end
900
+
886
901
  module PreloadLinkTag
887
902
  extend Phlex::Rails::HelperMacros
888
903
 
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # @api private
3
4
  module Phlex::Rails::HTML::Format
4
5
  def format
5
6
  :html
@@ -13,6 +13,7 @@ module Phlex::Rails
13
13
  include Helpers::JavaScriptImportMapTags
14
14
  include Helpers::JavaScriptImportModuleTag
15
15
 
16
+ # @api private
16
17
  module Interface
17
18
  def render(view, _locals, &block)
18
19
  component = new
@@ -23,7 +23,7 @@ module Phlex
23
23
  when Enumerable
24
24
  return super unless renderable.is_a?(ActiveRecord::Relation)
25
25
  else
26
- @_context.target << @_view_context.render(*args, **kwargs, &block)
26
+ @_context.target << @_view_context.render(*args, **kwargs) { capture(&block) }
27
27
  end
28
28
 
29
29
  nil
@@ -60,6 +60,7 @@ module Phlex
60
60
  super&.html_safe
61
61
  end
62
62
 
63
+ # @api private
63
64
  def __text__(content)
64
65
  case content
65
66
  when ActiveSupport::SafeBuffer
@@ -69,7 +70,7 @@ module Phlex
69
70
  end
70
71
  end
71
72
 
72
- # @api experimental
73
+ # @api private
73
74
  def await(task)
74
75
  if task.is_a?(ActiveRecord::Relation)
75
76
  flush unless task.loaded?
@@ -81,6 +82,7 @@ module Phlex
81
82
  end
82
83
 
83
84
  # Trick ViewComponent into thinking we're a ViewComponent to fix rendering output
85
+ # @api private
84
86
  def set_original_view_context(view_context)
85
87
  end
86
88
  end
@@ -1,8 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # @api experimental
3
+ # @api private
4
4
  module Phlex::Rails::Streaming
5
- private def stream(view)
5
+ private
6
+
7
+ def stream(view)
6
8
  headers.delete("Content-Length")
7
9
 
8
10
  headers["X-Accel-Buffering"] = "no"
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # @api private
3
4
  module Phlex::Rails::UnbufferedOverrides
4
5
  def method_missing(name, *args, **kwargs, &block)
5
6
  if @object.respond_to?(name)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Phlex
4
4
  module Rails
5
- VERSION = "0.10.0"
5
+ VERSION = "1.1.0"
6
6
  end
7
7
  end
data/lib/phlex/rails.rb CHANGED
@@ -22,11 +22,13 @@ module Phlex
22
22
  prepend Phlex::Rails::SGML::Overrides
23
23
  end
24
24
 
25
+ # @api private
25
26
  class HTML
26
27
  extend Phlex::Rails::HTML::Format
27
28
  include Phlex::Rails::HTML::Format
28
29
  end
29
30
 
31
+ # @api private
30
32
  class Unbuffered
31
33
  prepend ::Phlex::Rails::UnbufferedOverrides
32
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phlex-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Drapper
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-18 00:00:00.000000000 Z
11
+ date: 2023-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: phlex
@@ -16,16 +16,16 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.7.0
19
+ version: '1.9'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.7.0
26
+ version: '1.9'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rails
28
+ name: railties
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -68,6 +68,7 @@ files:
68
68
  - ".editorconfig"
69
69
  - ".rubocop.yml"
70
70
  - ".ruby-version"
71
+ - ".yardopts"
71
72
  - Appraisals
72
73
  - CHANGELOG.md
73
74
  - CODE_OF_CONDUCT.md
@@ -104,7 +105,6 @@ files:
104
105
  - lib/phlex/rails/buffered_label_builder.rb
105
106
  - lib/phlex/rails/buffered_radio_button_builder.rb
106
107
  - lib/phlex/rails/engine.rb
107
- - lib/phlex/rails/form.rb
108
108
  - lib/phlex/rails/helper_macros.rb
109
109
  - lib/phlex/rails/helpers.rb
110
110
  - lib/phlex/rails/helpers/routes.rb
@@ -143,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  - !ruby/object:Gem::Version
144
144
  version: '0'
145
145
  requirements: []
146
- rubygems_version: 3.4.6
146
+ rubygems_version: 3.4.10
147
147
  signing_key:
148
148
  specification_version: 4
149
149
  summary: A Phlex adapter for Rails
@@ -1,67 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Phlex
4
- module Rails
5
- class Form < Phlex::HTML
6
- def initialize(model)
7
- @model = model
8
- end
9
-
10
- def self.input_field(method_name, type:)
11
- define_method method_name do |field, value: @model.attributes[field.to_s], **attributes|
12
- input(
13
- name: field_name(field),
14
- type: type,
15
- value: value,
16
- **attributes
17
- )
18
- end
19
- end
20
-
21
- def template(&block)
22
- form action: @url, method: @method do
23
- authenticity_token_field
24
- yield_content(&block)
25
- end
26
- end
27
-
28
- def authenticity_token_field
29
- input(
30
- name: "authenticity_token",
31
- type: "hidden",
32
- value: helpers.form_authenticity_token
33
- )
34
- end
35
-
36
- def submit(value)
37
- input(
38
- name: "commit",
39
- type: "submit",
40
- value: value
41
- )
42
- end
43
-
44
- def url
45
- helpers.url_for(@model)
46
- end
47
-
48
- def field_name(*field)
49
- helpers.field_name(ActiveModel::Naming.param_key(@model.class), *field)
50
- end
51
-
52
- input_field :url_field, type: "url"
53
- input_field :text_field, type: "text"
54
- input_field :date_field, type: "date"
55
- input_field :time_field, type: "time"
56
- input_field :week_field, type: "week"
57
- input_field :month_field, type: "month"
58
- input_field :email_field, type: "email"
59
- input_field :color_field, type: "color"
60
- input_field :hidden_field, type: "hidden"
61
- input_field :search_field, type: "search"
62
- input_field :password_field, type: "password"
63
- input_field :telephone_field, type: "tel"
64
- input_field :datetime_local_field, type: "datetime-local"
65
- end
66
- end
67
- end