stimulus_tag_helper 0.3.1 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8ff2c2c234e2e424625b92771a01e0d91a0e9022f197c95a2db0f567fa030b40
4
- data.tar.gz: 346032a31e1beb29637638ebac298294b06e5ff8e6e0e82df1245a3da1c73036
3
+ metadata.gz: d78596e159f3730ada65d162fd8cdf8cff63404bdb72f6770fb544e45693dd8d
4
+ data.tar.gz: 3bed5f63460088309fdb0d5f8448b415a31a86d0efe3b1a17e7b1cb7d354daa4
5
5
  SHA512:
6
- metadata.gz: 28d2e85611dafc3d1f2e299f9db2662fa14a178d11a0b8f96930a7e50b037a022c468da97a98ced7320e234f3e129d0a4bdc43de9f741bc93406283f6919f6a4
7
- data.tar.gz: 9e213aa8a8789b0dd92f05a6e248500f019c34273b7de5397547b5493c2a9656ca288ab8e5a37608c3e80c49c289deca6af8eb1ab05bef99c58280e0b41ae61b
6
+ metadata.gz: 34ce331ca313d214394b301bf5017a469c8d64aa36464c73a1ac6fd580f5e488ca029631318c2cde54b34158284d6323c00ff1614f1e3f2cd690c3b0c1a7faf5
7
+ data.tar.gz: 20fa325fcae63d52d057143213eb707d362028fd54d0b5ee8bd6852d90407c398159b45139a008ac237695c498caa3fcb3b2aeedc9b6258705ff0200c45d50bf
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StimulusTagHelper
4
- VERSION = "0.3.1"
4
+ VERSION = "0.4.0"
5
5
  end
@@ -6,14 +6,17 @@ Zeitwerk::Loader.for_gem.setup
6
6
 
7
7
  module StimulusTagHelper
8
8
  def self.properties
9
- %i[controllers values classes targets actions].freeze
9
+ %i[controllers values classes targets actions outlets].freeze
10
10
  end
11
11
 
12
12
  def self.aliases
13
- @aliases ||=
14
- properties.map { |property| [property.to_s.singularize.to_sym, property] }.to_h.tap do |aliases|
15
- aliases.dup.each { |key, value| aliases[value] = key }
16
- end.freeze
13
+ @aliases ||= {}.tap do |aliases|
14
+ properties.each do |property|
15
+ property_alias = property.to_s.singularize.to_sym
16
+ aliases[property] = property_alias
17
+ aliases[property_alias] = property
18
+ end
19
+ end.freeze
17
20
  end
18
21
 
19
22
  def self.all_possible_properties_names
@@ -31,7 +34,7 @@ module StimulusTagHelper
31
34
  end
32
35
 
33
36
  def self.rendered_as(property)
34
- {controllers: :one, values: :many, classes: :many, targets: :many, actions: :one} \
37
+ {controllers: :one, values: :many, classes: :many, targets: :many, actions: :one, outlets: :many} \
35
38
  [property] || raise(ArgumentError, "Unknown property: #{property.inspect}")
36
39
  end
37
40
 
@@ -163,4 +166,20 @@ module StimulusTagHelper
163
166
  # TODO: find a elegant way to escape -> splitter escaping > back and forth.
164
167
  StimulusAction.new(identifier: identifier, **args_or_string).to_s.html_safe
165
168
  end
169
+
170
+ def stimulus_outlets_attributes(...)
171
+ {data: stimulus_outlets_properties(...)}
172
+ end
173
+
174
+ alias_method :stimulus_outlet_attribute, :stimulus_outlets_attributes
175
+
176
+ def stimulus_outlets_properties(identifier, **outlets)
177
+ {}.tap do |properties|
178
+ outlets.each_pair do |name, selector|
179
+ properties["#{identifier}-#{name}-outlet"] = selector
180
+ end
181
+ end
182
+ end
183
+
184
+ alias_method :stimulus_outlet_property, :stimulus_outlets_properties
166
185
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stimulus_tag_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Topchii
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-18 00:00:00.000000000 Z
11
+ date: 2023-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails