view_component_reflex 3.1.14.pre2 → 3.1.14.pre6
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2bc64cc6358619458915ab821a8f690257cb8239c8a5e55986c82f12620b642
|
4
|
+
data.tar.gz: 85fbc21a9c3f2a9ce7331fe2b9aaf67255bb74a98d7f4a5ddece7b75ff6a710c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c80401f2a8ed054f8feaa74fa976eb61d1829ba70bc809e836c887463f20b74dc37f85252c8ae9fcc2f5da0f32f7c12d1856fd3592fc13998929323adee2b334
|
7
|
+
data.tar.gz: cf388efa838d347177ffff53969e2ec7f44acedb51e6257d92a135606d3e9b11d2faf3c3f0866238d70c15f6c81e4798f59991f3fbf82b0a529e56d668e662cb
|
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)
|
@@ -204,6 +216,7 @@ module ViewComponentReflex
|
|
204
216
|
:@helpers, :@controller, :@request, :@tag_builder, :@state_initialized,
|
205
217
|
:@_content_evaluated, :@_render_in_block, :@__vc_controller, :@__vc_helpers,
|
206
218
|
:@__cached_content, :@__vc_variant, :@__vc_content_evaluated, :@__vc_render_in_block,
|
219
|
+
:@original_view_context,
|
207
220
|
]
|
208
221
|
end
|
209
222
|
|
@@ -19,11 +19,14 @@ module ViewComponentReflex
|
|
19
19
|
# Since every reflex runs through this monkey patch, we're just going to ignore the ones that aren't for components
|
20
20
|
end
|
21
21
|
|
22
|
-
if component
|
23
|
-
component.init_stimulus_reflex
|
24
|
-
|
25
|
-
|
22
|
+
if component
|
23
|
+
if component.respond_to?(:init_stimulus_reflex)
|
24
|
+
component.init_stimulus_reflex
|
25
|
+
else
|
26
|
+
Rails.logger.info "Tried to initialize view_component_reflex on #{component_name}, but it's not a view_component_reflex"
|
27
|
+
end
|
26
28
|
end
|
29
|
+
|
27
30
|
receive_original(data)
|
28
31
|
end
|
29
32
|
end
|
@@ -147,13 +147,18 @@ module ViewComponentReflex
|
|
147
147
|
end
|
148
148
|
|
149
149
|
def stimulate(target, data)
|
150
|
-
data_to_receive = {
|
150
|
+
data_to_receive = {
|
151
|
+
"dataset" => {
|
152
|
+
"datasetAll" => {},
|
153
|
+
"dataset" => {}
|
154
|
+
}
|
155
|
+
}
|
151
156
|
|
152
157
|
stimulus_reflex_data.each do |k, v|
|
153
158
|
data_to_receive[k.to_s.camelize(:lower)] = v
|
154
159
|
end
|
155
160
|
|
156
|
-
data_to_receive["dataset"] = data.each_with_object({}) do |(k, v), o|
|
161
|
+
data_to_receive["dataset"]["dataset"] = data.each_with_object({}) do |(k, v), o|
|
157
162
|
o["data-#{k}"] = v
|
158
163
|
end
|
159
164
|
|
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.pre6
|
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-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -36,14 +36,14 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: 3.5.0.
|
39
|
+
version: 3.5.0.pre2
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 3.5.0.
|
46
|
+
version: 3.5.0.pre2
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: view_component
|
49
49
|
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
|