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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a56c925065ab67c7c41493cd5ab9a1c19fedde171ebc2fcc60477359318ef258
4
- data.tar.gz: 595d0ae7292a2548aece9749cbd7dc4e8f177faa6ea49aebfe90a1864c0014ce
3
+ metadata.gz: ea398d33c180c2198ac689bd70d6f830dc625f9e70fd17bd94cb1acbaa7ec690
4
+ data.tar.gz: 86b1e7379929fbbe3e5b83b9356debfa18490a9cca60599a1a7ecbd9537d97f7
5
5
  SHA512:
6
- metadata.gz: c0ee94c716fee4aa83d496beac7f2d7053e82742006ca1483dbd6ba38ba5ec32fc6f8c8b9f0ca691b05ff2c42947f52aa7937a35c5aef6cfd1bacc6454a7d90c
7
- data.tar.gz: 399b0db4d117ee191f871eb5bb23d5419065ca083a58ba778e9a871839e9de1950837868b4b4043a8d72b7e97f18138678f41ef12813905543bc4c4a1619428a
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
  }
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Vident
4
- VERSION = "0.10.1"
4
+ VERSION = "0.11.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vident
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Ierodiaconou