view_component 2.62.0 → 2.82.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of view_component might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/app/assets/vendor/prism.css +3 -195
- data/app/assets/vendor/prism.min.js +11 -11
- data/app/controllers/concerns/view_component/preview_actions.rb +6 -10
- data/app/controllers/view_components_system_test_controller.rb +7 -0
- data/app/helpers/preview_helper.rb +2 -2
- data/app/views/view_components/preview.html.erb +2 -2
- data/docs/CHANGELOG.md +383 -21
- data/lib/rails/generators/abstract_generator.rb +3 -5
- data/lib/rails/generators/component/component_generator.rb +5 -4
- data/lib/rails/generators/locale/component_generator.rb +1 -1
- data/lib/rails/generators/preview/component_generator.rb +10 -3
- data/lib/view_component/base.rb +41 -47
- data/lib/view_component/compiler.rb +57 -68
- data/lib/view_component/config.rb +176 -0
- data/lib/view_component/content_areas.rb +2 -3
- data/lib/view_component/deprecation.rb +2 -2
- data/lib/view_component/docs_builder_component.html.erb +1 -1
- data/lib/view_component/docs_builder_component.rb +1 -1
- data/lib/view_component/engine.rb +23 -29
- data/lib/view_component/polymorphic_slots.rb +11 -5
- data/lib/view_component/render_component_helper.rb +1 -0
- data/lib/view_component/slotable.rb +2 -3
- data/lib/view_component/slotable_v2.rb +48 -8
- data/lib/view_component/system_test_case.rb +13 -0
- data/lib/view_component/system_test_helpers.rb +27 -0
- data/lib/view_component/test_helpers.rb +65 -15
- data/lib/view_component/translatable.rb +1 -1
- data/lib/view_component/version.rb +1 -1
- data/lib/view_component.rb +6 -3
- metadata +50 -18
- data/lib/view_component/previewable.rb +0 -62
- data/lib/view_component/render_preview_helper.rb +0 -50
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: view_component
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.82.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- ViewComponent Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 5.
|
19
|
+
version: 5.2.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '8.0'
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 5.
|
29
|
+
version: 5.2.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '8.0'
|
@@ -44,6 +44,20 @@ dependencies:
|
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '1.0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: concurrent-ruby
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1.0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '1.0'
|
47
61
|
- !ruby/object:Gem::Dependency
|
48
62
|
name: appraisal
|
49
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -90,16 +104,16 @@ dependencies:
|
|
90
104
|
name: bundler
|
91
105
|
requirement: !ruby/object:Gem::Requirement
|
92
106
|
requirements:
|
93
|
-
- - "
|
107
|
+
- - "~>"
|
94
108
|
- !ruby/object:Gem::Version
|
95
|
-
version:
|
109
|
+
version: '2'
|
96
110
|
type: :development
|
97
111
|
prerelease: false
|
98
112
|
version_requirements: !ruby/object:Gem::Requirement
|
99
113
|
requirements:
|
100
|
-
- - "
|
114
|
+
- - "~>"
|
101
115
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
116
|
+
version: '2'
|
103
117
|
- !ruby/object:Gem::Dependency
|
104
118
|
name: erb_lint
|
105
119
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,6 +156,20 @@ dependencies:
|
|
142
156
|
- - "~>"
|
143
157
|
- !ruby/object:Gem::Version
|
144
158
|
version: '2'
|
159
|
+
- !ruby/object:Gem::Dependency
|
160
|
+
name: m
|
161
|
+
requirement: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - "~>"
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '1'
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - "~>"
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '1'
|
145
173
|
- !ruby/object:Gem::Dependency
|
146
174
|
name: minitest
|
147
175
|
requirement: !ruby/object:Gem::Requirement
|
@@ -272,19 +300,18 @@ dependencies:
|
|
272
300
|
name: yard-activesupport-concern
|
273
301
|
requirement: !ruby/object:Gem::Requirement
|
274
302
|
requirements:
|
275
|
-
- - "
|
303
|
+
- - "~>"
|
276
304
|
- !ruby/object:Gem::Version
|
277
|
-
version:
|
305
|
+
version: 0.0.1
|
278
306
|
type: :development
|
279
307
|
prerelease: false
|
280
308
|
version_requirements: !ruby/object:Gem::Requirement
|
281
309
|
requirements:
|
282
|
-
- - "
|
310
|
+
- - "~>"
|
283
311
|
- !ruby/object:Gem::Version
|
284
|
-
version:
|
312
|
+
version: 0.0.1
|
285
313
|
description:
|
286
314
|
email:
|
287
|
-
- opensource+view_component@github.com
|
288
315
|
executables: []
|
289
316
|
extensions: []
|
290
317
|
extra_rdoc_files: []
|
@@ -295,6 +322,7 @@ files:
|
|
295
322
|
- app/assets/vendor/prism.min.js
|
296
323
|
- app/controllers/concerns/view_component/preview_actions.rb
|
297
324
|
- app/controllers/view_components_controller.rb
|
325
|
+
- app/controllers/view_components_system_test_controller.rb
|
298
326
|
- app/helpers/preview_helper.rb
|
299
327
|
- app/views/test_mailer/test_email.html.erb
|
300
328
|
- app/views/view_components/_preview_source.html.erb
|
@@ -329,6 +357,7 @@ files:
|
|
329
357
|
- lib/view_component/compile_cache.rb
|
330
358
|
- lib/view_component/compiler.rb
|
331
359
|
- lib/view_component/component_error.rb
|
360
|
+
- lib/view_component/config.rb
|
332
361
|
- lib/view_component/content_areas.rb
|
333
362
|
- lib/view_component/deprecation.rb
|
334
363
|
- lib/view_component/docs_builder_component.html.erb
|
@@ -338,12 +367,10 @@ files:
|
|
338
367
|
- lib/view_component/polymorphic_slots.rb
|
339
368
|
- lib/view_component/preview.rb
|
340
369
|
- lib/view_component/preview_template_error.rb
|
341
|
-
- lib/view_component/previewable.rb
|
342
370
|
- lib/view_component/rails/tasks/view_component.rake
|
343
371
|
- lib/view_component/render_component_helper.rb
|
344
372
|
- lib/view_component/render_component_to_string_helper.rb
|
345
373
|
- lib/view_component/render_monkey_patch.rb
|
346
|
-
- lib/view_component/render_preview_helper.rb
|
347
374
|
- lib/view_component/render_to_string_monkey_patch.rb
|
348
375
|
- lib/view_component/rendering_component_helper.rb
|
349
376
|
- lib/view_component/rendering_monkey_patch.rb
|
@@ -351,6 +378,8 @@ files:
|
|
351
378
|
- lib/view_component/slot_v2.rb
|
352
379
|
- lib/view_component/slotable.rb
|
353
380
|
- lib/view_component/slotable_v2.rb
|
381
|
+
- lib/view_component/system_test_case.rb
|
382
|
+
- lib/view_component/system_test_helpers.rb
|
354
383
|
- lib/view_component/template_error.rb
|
355
384
|
- lib/view_component/test_case.rb
|
356
385
|
- lib/view_component/test_helpers.rb
|
@@ -358,11 +387,13 @@ files:
|
|
358
387
|
- lib/view_component/version.rb
|
359
388
|
- lib/view_component/with_content_helper.rb
|
360
389
|
- lib/yard/mattr_accessor_handler.rb
|
361
|
-
homepage: https://
|
390
|
+
homepage: https://viewcomponent.org
|
362
391
|
licenses:
|
363
392
|
- MIT
|
364
393
|
metadata:
|
365
394
|
allowed_push_host: https://rubygems.org
|
395
|
+
source_code_uri: https://github.com/viewcomponent/view_component
|
396
|
+
changelog_uri: https://github.com/ViewComponent/view_component/blob/main/docs/CHANGELOG.md
|
366
397
|
post_install_message:
|
367
398
|
rdoc_options: []
|
368
399
|
require_paths:
|
@@ -381,5 +412,6 @@ requirements: []
|
|
381
412
|
rubygems_version: 3.2.32
|
382
413
|
signing_key:
|
383
414
|
specification_version: 4
|
384
|
-
summary:
|
415
|
+
summary: A framework for building reusable, testable & encapsulated view components
|
416
|
+
in Ruby on Rails.
|
385
417
|
test_files: []
|
@@ -1,62 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "active_support/concern"
|
4
|
-
|
5
|
-
module ViewComponent
|
6
|
-
module Previewable
|
7
|
-
extend ActiveSupport::Concern
|
8
|
-
|
9
|
-
included do
|
10
|
-
# Enable or disable component previews:
|
11
|
-
#
|
12
|
-
# config.view_component.show_previews = true
|
13
|
-
#
|
14
|
-
# Defaults to `true` in development.
|
15
|
-
#
|
16
|
-
mattr_accessor :show_previews, instance_writer: false
|
17
|
-
|
18
|
-
# Enable or disable source code previews in component previews:
|
19
|
-
#
|
20
|
-
# config.view_component.show_previews_source = true
|
21
|
-
#
|
22
|
-
# Defaults to `false`.
|
23
|
-
#
|
24
|
-
mattr_accessor :show_previews_source, instance_writer: false, default: false
|
25
|
-
|
26
|
-
# Set a custom default layout used for preview index and individual previews:
|
27
|
-
#
|
28
|
-
# config.view_component.default_preview_layout = "component_preview"
|
29
|
-
#
|
30
|
-
mattr_accessor :default_preview_layout, instance_writer: false
|
31
|
-
|
32
|
-
# Set the location of component previews:
|
33
|
-
#
|
34
|
-
# config.view_component.preview_paths << "#{Rails.root}/lib/component_previews"
|
35
|
-
#
|
36
|
-
mattr_accessor :preview_paths, instance_writer: false
|
37
|
-
|
38
|
-
# @deprecated Use `preview_paths` instead. Will be removed in v3.0.0.
|
39
|
-
mattr_accessor :preview_path, instance_writer: false
|
40
|
-
|
41
|
-
# Set the entry route for component previews:
|
42
|
-
#
|
43
|
-
# config.view_component.preview_route = "/previews"
|
44
|
-
#
|
45
|
-
# Defaults to `/rails/view_components` when `show_previews` is enabled.
|
46
|
-
#
|
47
|
-
mattr_accessor :preview_route, instance_writer: false do
|
48
|
-
"/rails/view_components"
|
49
|
-
end
|
50
|
-
|
51
|
-
# Set the controller used for previewing components:
|
52
|
-
#
|
53
|
-
# config.view_component.preview_controller = "MyPreviewController"
|
54
|
-
#
|
55
|
-
# Defaults to `ViewComponentsController`.
|
56
|
-
#
|
57
|
-
mattr_accessor :preview_controller, instance_writer: false do
|
58
|
-
"ViewComponentsController"
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ViewComponent
|
4
|
-
module RenderPreviewHelper
|
5
|
-
# Render a preview inline. Internally sets `page` to be a `Capybara::Node::Simple`,
|
6
|
-
# allowing for Capybara assertions to be used:
|
7
|
-
#
|
8
|
-
# ```ruby
|
9
|
-
# render_preview(:default)
|
10
|
-
# assert_text("Hello, World!")
|
11
|
-
# ```
|
12
|
-
#
|
13
|
-
# Note: `#rendered_preview` expects a preview to be defined with the same class
|
14
|
-
# name as the calling test, but with `Test` replaced with `Preview`:
|
15
|
-
#
|
16
|
-
# MyComponentTest -> MyComponentPreview etc.
|
17
|
-
#
|
18
|
-
# In RSpec, `Preview` is appended to `described_class`.
|
19
|
-
#
|
20
|
-
# @param preview [String] The name of the preview to be rendered.
|
21
|
-
# @return [Nokogiri::HTML]
|
22
|
-
def render_preview(name)
|
23
|
-
begin
|
24
|
-
preview_klass = if respond_to?(:described_class)
|
25
|
-
if described_class.nil?
|
26
|
-
raise "`render_preview` expected a described_class, but it is nil."
|
27
|
-
end
|
28
|
-
|
29
|
-
"#{described_class}Preview"
|
30
|
-
else
|
31
|
-
self.class.name.gsub("Test", "Preview")
|
32
|
-
end
|
33
|
-
preview_klass = preview_klass.constantize
|
34
|
-
rescue NameError
|
35
|
-
raise NameError.new(
|
36
|
-
"`render_preview` expected to find #{preview_klass}, but it does not exist."
|
37
|
-
)
|
38
|
-
end
|
39
|
-
|
40
|
-
previews_controller = build_controller(ViewComponent::Base.preview_controller.constantize)
|
41
|
-
previews_controller.request.params[:path] = "#{preview_klass.preview_name}/#{name}"
|
42
|
-
previews_controller.response = ActionDispatch::Response.new
|
43
|
-
result = previews_controller.previews
|
44
|
-
|
45
|
-
@rendered_content = result
|
46
|
-
|
47
|
-
Nokogiri::HTML.fragment(@rendered_content)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|