vident 0.10.1 → 0.11.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 +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/vident/base.rb +1 -0
- data/lib/vident/component.rb +1 -0
- data/lib/vident/root_component.rb +20 -1
- data/lib/vident/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea398d33c180c2198ac689bd70d6f830dc625f9e70fd17bd94cb1acbaa7ec690
|
4
|
+
data.tar.gz: 86b1e7379929fbbe3e5b83b9356debfa18490a9cca60599a1a7ecbd9537d97f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e36f069043b62f9d300993e7be4d2cc8666aac6f782ee4ba04fd5efeaffe9ebd28ace5dbfd1022f90f515b253b9778d1123e516606fc20255b0d1bcb5a7bfe5
|
7
|
+
data.tar.gz: abf930b3b049e617544a8fe274b0c7deac1ad4f8226642d88fe120246fa0935b90cbcd3206480604290e2f2b9ff540dbf234ab72df8fb4051d8b6838cbecbc11
|
data/CHANGELOG.md
CHANGED
@@ -14,6 +14,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
14
14
|
|
15
15
|
### Fixed
|
16
16
|
|
17
|
+
|
18
|
+
## [0.11.0] - 2024-02-21
|
19
|
+
|
20
|
+
### Added
|
21
|
+
|
22
|
+
- `outlet_host` DSL method to support components hooking themselves into a host component's outlets
|
23
|
+
|
24
|
+
|
25
|
+
|
17
26
|
## [0.10.1] - 2024-02-21
|
18
27
|
|
19
28
|
### Added
|
data/lib/vident/base.rb
CHANGED
@@ -151,6 +151,7 @@ module Vident
|
|
151
151
|
actions: attribute(:actions) + Array.wrap(options[:actions]),
|
152
152
|
targets: attribute(:targets) + Array.wrap(options[:targets]),
|
153
153
|
outlets: attribute(:outlets) + Array.wrap(options[:outlets]),
|
154
|
+
outlet_host: attribute(:outlet_host),
|
154
155
|
named_classes: merge_stimulus_option(options, :named_classes),
|
155
156
|
data_maps: prepare_stimulus_option(options, :data_maps)
|
156
157
|
}
|
data/lib/vident/component.rb
CHANGED
@@ -17,6 +17,7 @@ module Vident
|
|
17
17
|
attribute :actions, default: [], delegates: false
|
18
18
|
attribute :targets, default: [], delegates: false
|
19
19
|
attribute :outlets, default: [], delegates: false
|
20
|
+
attribute :outlet_host, delegates: false
|
20
21
|
attribute :data_maps, default: [], delegates: false
|
21
22
|
attribute :named_classes, delegates: false
|
22
23
|
end
|
@@ -7,6 +7,7 @@ module Vident
|
|
7
7
|
actions: nil,
|
8
8
|
targets: nil,
|
9
9
|
outlets: nil,
|
10
|
+
outlet_host: nil,
|
10
11
|
named_classes: nil, # https://stimulus.hotwired.dev/reference/css-classes
|
11
12
|
data_maps: nil,
|
12
13
|
element_tag: nil,
|
@@ -23,6 +24,13 @@ module Vident
|
|
23
24
|
@named_classes = named_classes
|
24
25
|
@data_map_kvs = {}
|
25
26
|
@data_maps = data_maps
|
27
|
+
|
28
|
+
outlet_host.connect_outlet(self) if outlet_host.respond_to?(:connect_outlet)
|
29
|
+
end
|
30
|
+
|
31
|
+
def connect_outlet(outlet)
|
32
|
+
@outlets ||= []
|
33
|
+
@outlets << outlet
|
26
34
|
end
|
27
35
|
|
28
36
|
# The view component's helpers for setting stimulus data-* attributes on this component.
|
@@ -61,6 +69,15 @@ module Vident
|
|
61
69
|
build_target_data_attributes([target(name)])
|
62
70
|
end
|
63
71
|
|
72
|
+
def outlet(css_selector: nil)
|
73
|
+
controller = implied_controller_name
|
74
|
+
if css_selector.nil?
|
75
|
+
[controller, "[data-controller~=#{controller}]"]
|
76
|
+
else
|
77
|
+
[controller, css_selector]
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
64
81
|
# Getter for a named classes list so can be used in view to set initial state on SSR
|
65
82
|
# Returns a String of classes that can be used in a `class` attribute.
|
66
83
|
def named_classes(*names)
|
@@ -139,8 +156,10 @@ module Vident
|
|
139
156
|
[outlet_config, "[data-controller~=#{outlet_config}]"]
|
140
157
|
elsif outlet_config.is_a?(Array)
|
141
158
|
outlet_config[..1]
|
142
|
-
elsif respond_to?(:stimulus_identifier)
|
159
|
+
elsif outlet_config.respond_to?(:stimulus_identifier) # Is a Component
|
143
160
|
[outlet_config.stimulus_identifier, "[data-controller~=#{outlet_config.stimulus_identifier}]"]
|
161
|
+
elsif outlet_config.send(:implied_controller_name) # Is a RootComponent ?
|
162
|
+
[outlet_config.send(:implied_controller_name), "[data-controller~=#{outlet_config.send(:implied_controller_name)}]"]
|
144
163
|
else
|
145
164
|
raise ArgumentError, "Invalid outlet config: #{outlet_config}"
|
146
165
|
end
|
data/lib/vident/version.rb
CHANGED