vident 0.11.0 → 0.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/lib/vident/root_component.rb +40 -14
- data/lib/vident/stable_id.rb +7 -1
- data/lib/vident/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f7d8ace3954ce0426a72c2b2d82c847955a78744a88b79bae5c3fa89bc9376c
|
4
|
+
data.tar.gz: 18ea411abbd7d1ecc4a052fe7278a4be99d120bb359a93c069a15d6519fd3c6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56cb329e6bb4b3d0a1111b8015f5d6e2c768087a9c67258dc53016ce04823a2bb1c5b6a96a3983bb2b53b99308ed79191b04727cf518ac97196b3ed8e73f080b
|
7
|
+
data.tar.gz: 5b627477ac164a072b0faf035ef20df401340d4d6fecf6523645908aa3cbe6f5bde8037c9371f194a0ec14e04a669e23abeeaa77a81261f04306b07a4874ca2a
|
data/CHANGELOG.md
CHANGED
@@ -14,6 +14,21 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
14
14
|
|
15
15
|
### Fixed
|
16
16
|
|
17
|
+
## [0.12.1] - 2024-06-12
|
18
|
+
|
19
|
+
### Fixed
|
20
|
+
|
21
|
+
- parsing of targets where the controller is also specified
|
22
|
+
|
23
|
+
## [0.12.0] - 2024-02-25
|
24
|
+
|
25
|
+
### Added
|
26
|
+
|
27
|
+
- `outlet` DSL methods updated so that the selector is scoped to the component's root element by default. This
|
28
|
+
is probably the most common use case, and it's now the default.
|
29
|
+
- `with_outlets` DSL method added to generate the data-* attributes for the outlets and return as a fragment
|
30
|
+
of HTML
|
31
|
+
|
17
32
|
|
18
33
|
## [0.11.0] - 2024-02-21
|
19
34
|
|
@@ -69,10 +69,15 @@ module Vident
|
|
69
69
|
build_target_data_attributes([target(name)])
|
70
70
|
end
|
71
71
|
|
72
|
+
def build_outlet_selector(outlet_selector)
|
73
|
+
prefix = @id ? "##{@id} " : ""
|
74
|
+
"#{prefix}[data-controller~=#{outlet_selector}]"
|
75
|
+
end
|
76
|
+
|
72
77
|
def outlet(css_selector: nil)
|
73
78
|
controller = implied_controller_name
|
74
79
|
if css_selector.nil?
|
75
|
-
[controller,
|
80
|
+
[controller, build_outlet_selector(controller)]
|
76
81
|
else
|
77
82
|
[controller, css_selector]
|
78
83
|
end
|
@@ -104,6 +109,13 @@ module Vident
|
|
104
109
|
end
|
105
110
|
alias_method :with_action, :with_actions
|
106
111
|
|
112
|
+
# Return the HTML `data-` attribute for the given outlets
|
113
|
+
def with_outlets(*outlets)
|
114
|
+
attrs = build_outlet_data_attributes(outlets)
|
115
|
+
attrs.map { |dt, n| "data-#{dt}=\"#{n}\"" }.join(" ").html_safe
|
116
|
+
end
|
117
|
+
alias_method :with_outlet, :with_outlets
|
118
|
+
|
107
119
|
private
|
108
120
|
|
109
121
|
# An implicit Stimulus controller name is built from the implicit controller path
|
@@ -150,19 +162,29 @@ module Vident
|
|
150
162
|
|
151
163
|
def outlet_list
|
152
164
|
return {} unless @outlets&.size&.positive?
|
165
|
+
build_outlet_data_attributes(@outlets)
|
166
|
+
end
|
167
|
+
|
168
|
+
def parse_outlet(outlet_config)
|
169
|
+
if outlet_config.is_a?(String)
|
170
|
+
[outlet_config, build_outlet_selector(outlet_config)]
|
171
|
+
elsif outlet_config.is_a?(Symbol)
|
172
|
+
outlet_config = outlet_config.to_s.tr("_", "-")
|
173
|
+
[outlet_config, build_outlet_selector(outlet_config)]
|
174
|
+
elsif outlet_config.is_a?(Array)
|
175
|
+
outlet_config[..1]
|
176
|
+
elsif outlet_config.respond_to?(:stimulus_identifier) # Is a Component
|
177
|
+
[outlet_config.stimulus_identifier, build_outlet_selector(outlet_config.stimulus_identifier)]
|
178
|
+
elsif outlet_config.send(:implied_controller_name) # Is a RootComponent ?
|
179
|
+
[outlet_config.send(:implied_controller_name), build_outlet_selector(outlet_config.send(:implied_controller_name))]
|
180
|
+
else
|
181
|
+
raise ArgumentError, "Invalid outlet config: #{outlet_config}"
|
182
|
+
end
|
183
|
+
end
|
153
184
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
elsif outlet_config.is_a?(Array)
|
158
|
-
outlet_config[..1]
|
159
|
-
elsif outlet_config.respond_to?(:stimulus_identifier) # Is a Component
|
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)}]"]
|
163
|
-
else
|
164
|
-
raise ArgumentError, "Invalid outlet config: #{outlet_config}"
|
165
|
-
end
|
185
|
+
def build_outlet_data_attributes(outlets)
|
186
|
+
outlets.each_with_object({}) do |outlet_config, obj|
|
187
|
+
identifier, css_selector = parse_outlet(outlet_config)
|
166
188
|
obj[:"#{implied_controller_name}-#{identifier}-outlet"] = css_selector
|
167
189
|
end
|
168
190
|
end
|
@@ -207,7 +229,11 @@ module Vident
|
|
207
229
|
|
208
230
|
def parse_target(raw_target)
|
209
231
|
return raw_target if raw_target.is_a?(String)
|
210
|
-
|
232
|
+
if raw_target.is_a?(Hash)
|
233
|
+
raw_target[:name] = js_name(raw_target[:name]) if raw_target[:name].is_a?(Symbol)
|
234
|
+
return raw_target
|
235
|
+
end
|
236
|
+
return target(*raw_target) if raw_target.is_a?(Array)
|
211
237
|
target(raw_target)
|
212
238
|
end
|
213
239
|
|
data/lib/vident/stable_id.rb
CHANGED
data/lib/vident/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vident
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Ierodiaconou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|