view_component_reflex 3.1.14.pre4 → 3.1.14.pre8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +25 -0
- data/app/components/view_component_reflex/component.rb +16 -4
- data/lib/view_component_reflex/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68c3165a8b1c6121e1be99b4464ade2bf4bea8920b70d6d8b2461239f7278a9c
|
4
|
+
data.tar.gz: 55b823177cf414e6271bfbcaaac376e03dbaae73ebe73df0fff814a8e7b73912
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a053c9d3ecd441c6b3235b590780312df465495f7f81c3be2087c78b0f556f59a0638b9f9a224b36d5f4f4aa4627da3c6df9b6f0159754d3592e4d239d3d2b1
|
7
|
+
data.tar.gz: 720261c26f0d0e45a26d490c6d818a5a3e373db45216bc1a0a7a094be3223012e2bb640a811550e11780ae9676df9ce84fdf03d4dca33fb700bcb1ced50555e0
|
data/README.md
CHANGED
@@ -440,6 +440,31 @@ Otherwise @instance_variables were nil after a reflex
|
|
440
440
|
config.session_store :cache_store
|
441
441
|
```
|
442
442
|
|
443
|
+
## Sidecar assets
|
444
|
+
|
445
|
+
When using ViewComponent generated sidecar assets, the stimulus controller won't resolve properly.
|
446
|
+
To resolve this, override the `self.stimulus_controller` method in your component to the correct method.
|
447
|
+
|
448
|
+
For example, if you have a structure of
|
449
|
+
|
450
|
+
```
|
451
|
+
components/
|
452
|
+
example_component/
|
453
|
+
example_component_controller.js
|
454
|
+
example_component.html.erb
|
455
|
+
example_component.rb
|
456
|
+
```
|
457
|
+
|
458
|
+
You would update your `self.stimulus_controller` method to
|
459
|
+
|
460
|
+
```ruby
|
461
|
+
def self.stimulus_controller
|
462
|
+
"example-component--example-component"
|
463
|
+
end
|
464
|
+
```
|
465
|
+
|
466
|
+
Thanks @omairrazam for this solution
|
467
|
+
|
443
468
|
## License
|
444
469
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
445
470
|
|
@@ -7,7 +7,14 @@ module ViewComponentReflex
|
|
7
7
|
def init_stimulus_reflex
|
8
8
|
factory = ViewComponentReflex::ReflexFactory.new(self)
|
9
9
|
@stimulus_reflex ||= factory.reflex
|
10
|
-
|
10
|
+
|
11
|
+
# Always wire up new callbacks in development
|
12
|
+
if Rails.env.development?
|
13
|
+
reset_callbacks
|
14
|
+
wire_up_callbacks
|
15
|
+
elsif factory.new? # only wire up callbacks in production if they haven't been wired up yet
|
16
|
+
wire_up_callbacks
|
17
|
+
end
|
11
18
|
end
|
12
19
|
|
13
20
|
def queue_callback(key, args, blk)
|
@@ -40,6 +47,11 @@ module ViewComponentReflex
|
|
40
47
|
queue_callback(:around, args, blk)
|
41
48
|
end
|
42
49
|
|
50
|
+
def reset_callbacks
|
51
|
+
# SR uses :process as the underlying callback key
|
52
|
+
@stimulus_reflex.reset_callbacks(:process)
|
53
|
+
end
|
54
|
+
|
43
55
|
def wire_up_callbacks
|
44
56
|
register_callbacks(:before)
|
45
57
|
register_callbacks(:after)
|
@@ -192,7 +204,7 @@ module ViewComponentReflex
|
|
192
204
|
# end
|
193
205
|
|
194
206
|
def safe_instance_variables
|
195
|
-
instance_variables - unsafe_instance_variables - omitted_from_state
|
207
|
+
instance_variables.reject { |ivar| ivar.start_with?("@__vc") } - unsafe_instance_variables - omitted_from_state
|
196
208
|
end
|
197
209
|
|
198
210
|
private
|
@@ -202,8 +214,8 @@ module ViewComponentReflex
|
|
202
214
|
:@view_context, :@lookup_context, :@view_renderer, :@view_flow,
|
203
215
|
:@virtual_path, :@variant, :@current_template, :@output_buffer, :@key,
|
204
216
|
:@helpers, :@controller, :@request, :@tag_builder, :@state_initialized,
|
205
|
-
:@_content_evaluated, :@_render_in_block, :@
|
206
|
-
:@
|
217
|
+
:@_content_evaluated, :@_render_in_block, :@__cached_content,
|
218
|
+
:@original_view_context,
|
207
219
|
]
|
208
220
|
end
|
209
221
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: view_component_reflex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.14.
|
4
|
+
version: 3.1.14.pre8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua LeBlanc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '5.2'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '8.0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '5.2'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '8.0'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: stimulus_reflex
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
112
|
- !ruby/object:Gem::Version
|
113
113
|
version: 1.3.1
|
114
114
|
requirements: []
|
115
|
-
rubygems_version: 3.2.
|
115
|
+
rubygems_version: 3.2.9
|
116
116
|
signing_key:
|
117
117
|
specification_version: 4
|
118
118
|
summary: Allow stimulus reflexes in a view component
|