view_component 3.23.1 → 3.24.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 16a94da266921e0bd3ed59abdba704b4edf68873959d74c0d3caad66d3aac082
4
- data.tar.gz: 0520dc669a3c0d1bda117d7a2f1932f6f2b31726a55e44be87062c49c004cd64
3
+ metadata.gz: e50fc0d9c23700e9ca13233ffda7dd983deeaf93200325e81a25852866c115f5
4
+ data.tar.gz: c326352446cf7303cf0a5fb4967ffb391fdf363a272f31d88a9a074619230668
5
5
  SHA512:
6
- metadata.gz: 63ebe85255f6d35c49108590e6d939c1ea21971bfaa8bd476f5f5854073916692d602173e5f607db3aefbbc46cee3ef467232efb4c0231ca85a8c691b1a27ea5
7
- data.tar.gz: 6e4cbef0047c2d3daf22f06b024bca4af0b12fdea8146f9bc1217bc27fa3d318049681b99f5e6030bf42017922fdb82ca0a1255b4aa367f43d793f9d4a0a8528
6
+ metadata.gz: 61d508fd6b1ad6b4c53d85e55e972567b3cd08139380d48966f39be19e04803f480b368f3bdf82f9597ab4f487d2f9141bcf7ffff25b2542fbe4312d7c0d53e8
7
+ data.tar.gz: 546ec854a8ec8f8fbb611a4d45d4d645fcae74f4a5f467a4531d7492ac05695270eeb369f0eca180d67b7b29a427e0053ad456fc037d5fbc9e950d4012aa4d66
data/docs/CHANGELOG.md CHANGED
@@ -10,6 +10,18 @@ nav_order: 6
10
10
 
11
11
  ## main
12
12
 
13
+ ## 3.24.0
14
+
15
+ * Add Rails 8.1 support to ViewComponent v3.
16
+
17
+ *Hans Lemuet*
18
+
19
+ ## 3.23.2
20
+
21
+ * Include .tt files in published gem. Fixes templates not being available when using generators.
22
+
23
+ *Florian Aßmann*
24
+
13
25
  ## 3.23.1
14
26
 
15
27
  * Restore Rake tasks in published gem.
@@ -22,7 +22,7 @@ module Rails
22
22
  class_option :skip_suffix, type: :boolean, default: false
23
23
 
24
24
  def create_component_file
25
- template "component.rb", File.join(component_path, class_path, "#{file_name}#{options[:skip_suffix] ? "" : "_component"}.rb")
25
+ template "component.rb", File.join(component_path, class_path, "#{file_name}#{"_component" unless options[:skip_suffix]}.rb")
26
26
  end
27
27
 
28
28
  hook_for :test_framework
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ <% module_namespacing do -%>
4
+ class <%= class_name %><%= options[:skip_suffix] ? "" : "Component" %> < <%= parent_class %>
5
+ <%- if initialize_signature -%>
6
+ def initialize(<%= initialize_signature %>)
7
+ <%= initialize_body %>
8
+ end
9
+ <%- end -%>
10
+ <%- if initialize_call_method_for_inline? -%>
11
+ def call
12
+ content_tag :h1, "Hello world!"<%= ", data: { controller: \"#{stimulus_controller}\" }" if options["stimulus"] %>
13
+ end
14
+ <%- end -%>
15
+ end
16
+ <% end -%>
@@ -0,0 +1 @@
1
+ <div<%= data_attributes %>>Add <%= class_name %> template here</div>
@@ -0,0 +1 @@
1
+ %div Add <%= class_name %> template here
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ <% module_namespacing do -%>
4
+ class <%= class_name %>ComponentPreview < ViewComponent::Preview
5
+ def default
6
+ render(<%= class_name %>Component.new<%= "(#{render_signature})" if render_signature %>)
7
+ end
8
+ end
9
+ <% end -%>
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails_helper"
4
+
5
+ RSpec.describe <%= namespaced? ? "#{namespace.name}::" : '' %><%= class_name %>Component, type: :component do
6
+ pending "add some examples to (or delete) #{__FILE__}"
7
+
8
+ # it "renders something useful" do
9
+ # expect(
10
+ # render_inline(described_class.new(attr: "value")) { "Hello, components!" }.css("p").to_html
11
+ # ).to include(
12
+ # "Hello, components!"
13
+ # )
14
+ # end
15
+ end
@@ -0,0 +1 @@
1
+ div Add <%= class_name %> template here
@@ -0,0 +1,7 @@
1
+ import { Controller } from "<%= stimulus_module %>";
2
+
3
+ export default class extends Controller {
4
+ connect() {
5
+ console.log("Hello, Stimulus!", this.element);
6
+ }
7
+ }
@@ -0,0 +1,9 @@
1
+ import { Controller } from "<%= stimulus_module %>";
2
+
3
+ export default class extends Controller {
4
+ declare element: HTMLElement;
5
+
6
+ connect() {
7
+ console.log("Hello, Stimulus!", this.element);
8
+ }
9
+ }
@@ -0,0 +1 @@
1
+ <div<%= data_attributes %>>Add <%= class_name %> template here</div>
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class <%= namespaced? ? "#{namespace.name}::" : '' %><%= class_name %>ComponentTest < ViewComponent::TestCase
6
+ def test_component_renders_something_useful
7
+ # assert_equal(
8
+ # %(<span>Hello, components!</span>),
9
+ # render_inline(<%= class_name %>Component.new(message: "Hello, components!")).css("span").to_html
10
+ # )
11
+ end
12
+ end
@@ -5,6 +5,7 @@ require "action_view/renderer/collection_renderer" if Rails.version.to_f >= 6.1
5
5
  module ViewComponent
6
6
  class Collection
7
7
  include Enumerable
8
+
8
9
  attr_reader :component
9
10
 
10
11
  delegate :size, to: :@collection
@@ -3,6 +3,7 @@
3
3
  module ViewComponent # :nodoc:
4
4
  module InlineTemplate
5
5
  extend ActiveSupport::Concern
6
+
6
7
  Template = Struct.new(:source, :language, :path, :lineno)
7
8
 
8
9
  class_methods do
@@ -3,8 +3,8 @@
3
3
  module ViewComponent
4
4
  module VERSION
5
5
  MAJOR = 3
6
- MINOR = 23
7
- PATCH = 1
6
+ MINOR = 24
7
+ PATCH = 0
8
8
  PRE = nil
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join(".")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: view_component
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.23.1
4
+ version: 3.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ViewComponent Team
@@ -18,7 +18,7 @@ dependencies:
18
18
  version: 5.2.0
19
19
  - - "<"
20
20
  - !ruby/object:Gem::Version
21
- version: '8.1'
21
+ version: '8.2'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -28,7 +28,7 @@ dependencies:
28
28
  version: 5.2.0
29
29
  - - "<"
30
30
  - !ruby/object:Gem::Version
31
- version: '8.1'
31
+ version: '8.2'
32
32
  - !ruby/object:Gem::Dependency
33
33
  name: method_source
34
34
  requirement: !ruby/object:Gem::Requirement
@@ -581,15 +581,25 @@ files:
581
581
  - docs/CHANGELOG.md
582
582
  - lib/rails/generators/abstract_generator.rb
583
583
  - lib/rails/generators/component/component_generator.rb
584
+ - lib/rails/generators/component/templates/component.rb.tt
584
585
  - lib/rails/generators/erb/component_generator.rb
586
+ - lib/rails/generators/erb/templates/component.html.erb.tt
585
587
  - lib/rails/generators/haml/component_generator.rb
588
+ - lib/rails/generators/haml/templates/component.html.haml.tt
586
589
  - lib/rails/generators/locale/component_generator.rb
587
590
  - lib/rails/generators/preview/component_generator.rb
591
+ - lib/rails/generators/preview/templates/component_preview.rb.tt
588
592
  - lib/rails/generators/rspec/component_generator.rb
593
+ - lib/rails/generators/rspec/templates/component_spec.rb.tt
589
594
  - lib/rails/generators/slim/component_generator.rb
595
+ - lib/rails/generators/slim/templates/component.html.slim.tt
590
596
  - lib/rails/generators/stimulus/component_generator.rb
597
+ - lib/rails/generators/stimulus/templates/component_controller.js.tt
598
+ - lib/rails/generators/stimulus/templates/component_controller.ts.tt
591
599
  - lib/rails/generators/tailwindcss/component_generator.rb
600
+ - lib/rails/generators/tailwindcss/templates/component.html.erb.tt
592
601
  - lib/rails/generators/test_unit/component_generator.rb
602
+ - lib/rails/generators/test_unit/templates/component_test.rb.tt
593
603
  - lib/view_component.rb
594
604
  - lib/view_component/base.rb
595
605
  - lib/view_component/capture_compatibility.rb
@@ -645,7 +655,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
645
655
  - !ruby/object:Gem::Version
646
656
  version: '0'
647
657
  requirements: []
648
- rubygems_version: 3.6.8
658
+ rubygems_version: 3.7.2
649
659
  specification_version: 4
650
660
  summary: A framework for building reusable, testable & encapsulated view components
651
661
  in Ruby on Rails.