vident 1.0.0.beta1 → 1.0.0.beta2

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: afda27d62ee5246fc8fdd81ab6f53720ec58ebbd8ca42099b120f7c388788688
4
- data.tar.gz: c2ddd4762e650cd0ce63ff01662bb691cb76943c3f538eb490348dd211c98a1a
3
+ metadata.gz: b6c4ad465075f1a6541193c93ae1d96eb9f714b2d22390c30e1e0335ebec0935
4
+ data.tar.gz: ecb1718a8c85835afeb6e408f62300e345b94ac03f05f5f9c6b99f40859a3f0c
5
5
  SHA512:
6
- metadata.gz: 00fb4a976875313eed41e49f235417a6dd6d5d42a7d0aeed572d62eb3bca61636cbd6cf14c4483f34e95744772375cdcdbc1c9ad889e9c18e8a0dcf9d061b0f8
7
- data.tar.gz: 995ba08626a953e7212b16d4bea31a18277bf764e327b02498ac0893599a050fcbe9be5c88c71bbff264b5822d9b59d41781dc7f940fa039ffcd9b176bea2159
6
+ metadata.gz: 5f9d61b1b93ebc7bacee4aab54e82ef3c51211357ab05de0ac4763189dc60304481f2f7b306d03c9a0412b55e26477b4fe0ebb7c6c62f0863d09cea2d91088b3
7
+ data.tar.gz: 1d5aa67d225c9e2c8e9fee2f4cf355afa660a5b80e639b38edc169e293d694400f8d3aa04fa2178d95c61c4e5a15348695fb0e2da68359d6686f758bd69bf53f
data/CHANGELOG.md CHANGED
@@ -6,6 +6,16 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
6
6
  and this project adheres to [Semantic Versioning](http://semver.org/).
7
7
 
8
8
 
9
+ ## [1.0.0.beta2] - 2026-04-16
10
+
11
+ ### Breaking
12
+
13
+ - Renamed the `tag(...)` helper to `child_element(...)` (and the internal `Vident::TagHelper` module to `Vident::ChildElementHelper`). The old name shadowed Rails' own `tag(name, options)` positional API, which breaks Rails helpers like `hidden_field_tag` and `image_tag` when called inside vident components. Rename any `component.tag(...)` calls to `component.child_element(...)`.
14
+
15
+ ### Fixed
16
+
17
+ - `stimulus_outlet` parser now accepts `(String, String)` arguments so string-keyed outlets produced by the DSL actually render.
18
+
9
19
  ## [1.0.0.beta1] - 2026-04-16
10
20
 
11
21
  ### Fixed
data/README.md CHANGED
@@ -93,7 +93,7 @@ class ButtonComponent < Vident::ViewComponent::Base
93
93
  def call
94
94
  root_element do |component|
95
95
  # Wire up targets etc
96
- component.tag(:span, stimulus_target: :status) do
96
+ component.child_element(:span, stimulus_target: :status) do
97
97
  @text
98
98
  end
99
99
  end
@@ -483,13 +483,13 @@ or you can use tag helpers to generate HTML with Stimulus attributes:
483
483
  <% end %>
484
484
  <%= content_tag(:span, class: "...", data: {**greeter.stimulus_target(:output)}) %>
485
485
 
486
- <%# OR use the vident tag helper %>
486
+ <%# OR use the vident child_element helper %>
487
487
 
488
- <%= greeter.tag(:input, stimulus_target: :name, type: "text", class: "...") %>
489
- <%= greeter.tag(:button, stimulus_action: [:click, :greet], class: "...") do %>
488
+ <%= greeter.child_element(:input, stimulus_target: :name, type: "text", class: "...") %>
489
+ <%= greeter.child_element(:button, stimulus_action: [:click, :greet], class: "...") do %>
490
490
  <%= @cta %>
491
491
  <% end %>
492
- <%= greeter.tag(:span, stimulus_target: :output, class: "...") %>
492
+ <%= greeter.child_element(:span, stimulus_target: :output, class: "...") %>
493
493
  ```
494
494
 
495
495
  or in your Phlex templates:
@@ -498,7 +498,7 @@ or in your Phlex templates:
498
498
  root_element do |greeter|
499
499
  input(type: "text", data: {**greeter.stimulus_target(:name)}, class: %(...))
500
500
  trigger_or_default(greeter)
501
- greeter.tag(:span, stimulus_target: :output, class: "ml-4 #{greeter.class_list_for_stimulus_classes(:pre_click)}") do
501
+ greeter.child_element(:span, stimulus_target: :output, class: "ml-4 #{greeter.class_list_for_stimulus_classes(:pre_click)}") do
502
502
  plain %( ... )
503
503
  end
504
504
  end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Vident
4
+ module ChildElementHelper
5
+ def child_element(
6
+ tag_name,
7
+ stimulus_controllers: nil,
8
+ stimulus_targets: nil,
9
+ stimulus_actions: nil,
10
+ stimulus_outlets: nil,
11
+ stimulus_values: nil,
12
+ stimulus_classes: nil,
13
+ stimulus_controller: nil,
14
+ stimulus_target: nil,
15
+ stimulus_action: nil,
16
+ stimulus_outlet: nil,
17
+ stimulus_value: nil,
18
+ stimulus_class: nil,
19
+ **options,
20
+ &block
21
+ )
22
+ child_element_attribute_must_be_collection!(stimulus_controllers, "stimulus_controllers")
23
+ child_element_attribute_must_be_collection!(stimulus_targets, "stimulus_targets")
24
+ child_element_attribute_must_be_collection!(stimulus_actions, "stimulus_actions")
25
+ child_element_attribute_must_be_collection!(stimulus_outlets, "stimulus_outlets")
26
+ child_element_attribute_must_be_collection!(stimulus_values, "stimulus_values")
27
+ child_element_attribute_must_be_collection!(stimulus_classes, "stimulus_classes")
28
+
29
+ stimulus_controllers_collection = send(:stimulus_controllers, *child_element_wrap_single_stimulus_attribute(stimulus_controllers, stimulus_controller))
30
+ stimulus_targets_collection = send(:stimulus_targets, *child_element_wrap_single_stimulus_attribute(stimulus_targets, stimulus_target))
31
+ stimulus_actions_collection = send(:stimulus_actions, *child_element_wrap_single_stimulus_attribute(stimulus_actions, stimulus_action))
32
+ stimulus_outlets_collection = send(:stimulus_outlets, *child_element_wrap_single_stimulus_attribute(stimulus_outlets, stimulus_outlet))
33
+ stimulus_values_collection = send(:stimulus_values, stimulus_values || stimulus_value)
34
+ stimulus_classes_collection = send(:stimulus_classes, stimulus_classes || stimulus_class)
35
+
36
+ stimulus_data_attributes = StimulusDataAttributeBuilder.new(
37
+ controllers: stimulus_controllers_collection,
38
+ actions: stimulus_actions_collection,
39
+ targets: stimulus_targets_collection,
40
+ outlets: stimulus_outlets_collection,
41
+ values: stimulus_values_collection,
42
+ classes: stimulus_classes_collection
43
+ ).build
44
+ generate_child_element(tag_name, stimulus_data_attributes, options, &block)
45
+ end
46
+
47
+ private
48
+
49
+ def child_element_attribute_must_be_collection!(collection, name)
50
+ return unless collection
51
+ raise ArgumentError, "'#{name}:' must be an enumerable. Did you mean '#{name.to_s.singularize}:'?" unless collection.is_a?(Enumerable)
52
+ end
53
+
54
+ def child_element_wrap_single_stimulus_attribute(plural, singular)
55
+ return plural if plural
56
+ singular.nil? ? nil : [singular]
57
+ end
58
+
59
+ def generate_child_element(tag_name, stimulus_data_attributes, options, &block)
60
+ raise NoMethodError, "Not implemented"
61
+ end
62
+ end
63
+ end
@@ -27,7 +27,7 @@ module Vident
27
27
  include ComponentClassLists
28
28
  include ComponentAttributeResolver
29
29
 
30
- include TagHelper
30
+ include ChildElementHelper
31
31
  include Tailwind
32
32
  include StimulusHelper
33
33
 
@@ -67,8 +67,7 @@ module Vident
67
67
  end
68
68
 
69
69
  def parse_two_arguments(arg1, arg2)
70
- if arg1.is_a?(Symbol) && arg2.is_a?(String)
71
- # outlet name on implied controller + custom selector
70
+ if (arg1.is_a?(Symbol) || arg1.is_a?(String)) && arg2.is_a?(String)
72
71
  @controller = implied_controller_name
73
72
  @outlet_name = arg1.to_s.dasherize
74
73
  @selector = arg2
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Vident
4
- VERSION = "1.0.0.beta1"
4
+ VERSION = "1.0.0.beta2"
5
5
 
6
6
  # Shared version for all vident gems
7
7
  def self.version
data/lib/vident.rb CHANGED
@@ -38,7 +38,7 @@ require "vident/stimulus_class_collection"
38
38
  require "vident/stimulus_attributes"
39
39
  require "vident/stimulus_data_attribute_builder"
40
40
 
41
- require "vident/tag_helper"
41
+ require "vident/child_element_helper"
42
42
  require "vident/stable_id"
43
43
  require "vident/class_list_builder"
44
44
 
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: 1.0.0.beta1
4
+ version: 1.0.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Ierodiaconou
@@ -84,6 +84,7 @@ files:
84
84
  - README.md
85
85
  - lib/vident.rb
86
86
  - lib/vident/caching.rb
87
+ - lib/vident/child_element_helper.rb
87
88
  - lib/vident/class_list_builder.rb
88
89
  - lib/vident/component.rb
89
90
  - lib/vident/component_attribute_resolver.rb
@@ -109,7 +110,6 @@ files:
109
110
  - lib/vident/stimulus_target_collection.rb
110
111
  - lib/vident/stimulus_value.rb
111
112
  - lib/vident/stimulus_value_collection.rb
112
- - lib/vident/tag_helper.rb
113
113
  - lib/vident/tailwind.rb
114
114
  - lib/vident/version.rb
115
115
  homepage: https://github.com/stevegeek/vident
@@ -1,65 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Vident
4
- module TagHelper
5
- # Generate a tag with the given name and options, including stimulus data attributes
6
- def tag(
7
- tag_name,
8
- stimulus_controllers: nil,
9
- stimulus_targets: nil,
10
- stimulus_actions: nil,
11
- stimulus_outlets: nil,
12
- stimulus_values: nil,
13
- stimulus_classes: nil,
14
- stimulus_controller: nil,
15
- stimulus_target: nil,
16
- stimulus_action: nil,
17
- stimulus_outlet: nil,
18
- stimulus_value: nil,
19
- stimulus_class: nil,
20
- **options,
21
- &block
22
- )
23
- # Ensure the plural attributes are actually enumerables
24
- tag_attribute_must_be_collection!(stimulus_controllers, "stimulus_controllers")
25
- tag_attribute_must_be_collection!(stimulus_targets, "stimulus_targets")
26
- tag_attribute_must_be_collection!(stimulus_actions, "stimulus_actions")
27
- tag_attribute_must_be_collection!(stimulus_outlets, "stimulus_outlets")
28
- tag_attribute_must_be_collection!(stimulus_values, "stimulus_values")
29
- tag_attribute_must_be_collection!(stimulus_classes, "stimulus_classes")
30
-
31
- stimulus_controllers_collection = send(:stimulus_controllers, *tag_wrap_single_stimulus_attribute(stimulus_controllers, stimulus_controller))
32
- stimulus_targets_collection = send(:stimulus_targets, *tag_wrap_single_stimulus_attribute(stimulus_targets, stimulus_target))
33
- stimulus_actions_collection = send(:stimulus_actions, *tag_wrap_single_stimulus_attribute(stimulus_actions, stimulus_action))
34
- stimulus_outlets_collection = send(:stimulus_outlets, *tag_wrap_single_stimulus_attribute(stimulus_outlets, stimulus_outlet))
35
- stimulus_values_collection = send(:stimulus_values, stimulus_values || stimulus_value)
36
- stimulus_classes_collection = send(:stimulus_classes, stimulus_classes || stimulus_class)
37
-
38
- stimulus_data_attributes = StimulusDataAttributeBuilder.new(
39
- controllers: stimulus_controllers_collection,
40
- actions: stimulus_actions_collection,
41
- targets: stimulus_targets_collection,
42
- outlets: stimulus_outlets_collection,
43
- values: stimulus_values_collection,
44
- classes: stimulus_classes_collection
45
- ).build
46
- generate_tag(tag_name, stimulus_data_attributes, options, &block)
47
- end
48
-
49
- private
50
-
51
- def tag_attribute_must_be_collection!(collection, name)
52
- return unless collection
53
- raise ArgumentError, "'#{name}:' must be an enumerable. Did you mean '#{name.to_s.singularize}:'?" unless collection.is_a?(Enumerable)
54
- end
55
-
56
- def tag_wrap_single_stimulus_attribute(plural, singular)
57
- return plural if plural
58
- singular.nil? ? nil : [singular]
59
- end
60
-
61
- def generate_tag(tag_name, stimulus_data_attributes, options, &block)
62
- raise NoMethodError, "Not implemented"
63
- end
64
- end
65
- end