stimulus_tag_helper 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1078cddfbd535e267d08882379327c0c4d19d57257fdea47cce3694daca9c2db
4
- data.tar.gz: 33e92a8572f01e606014f24d1834b9fbad415ba631058160d454baf73f677f94
3
+ metadata.gz: d78596e159f3730ada65d162fd8cdf8cff63404bdb72f6770fb544e45693dd8d
4
+ data.tar.gz: 3bed5f63460088309fdb0d5f8448b415a31a86d0efe3b1a17e7b1cb7d354daa4
5
5
  SHA512:
6
- metadata.gz: 9deb8c164aad97521e0f2db8ee6d3ae66f3b8918c4b566d377aea038b44606817646ec8f242c0c5d8072b592bd5969fec3195e01d3d5ececaa5077c1c224776a
7
- data.tar.gz: ead6ee7e15df412012a062ffc9ac1c5c3d0b1b60be4a0cd5e1576d60177390df3823d8f30d04e420d9589b8e476fa33f34601c8797bdd09a05f13de3dc044582
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.2"
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.2
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