vident 1.0.0.alpha4 → 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 +4 -4
- data/CHANGELOG.md +20 -0
- data/README.md +6 -6
- data/lib/vident/child_element_helper.rb +63 -0
- data/lib/vident/component.rb +1 -1
- data/lib/vident/stimulus_builder.rb +2 -1
- data/lib/vident/stimulus_component.rb +1 -1
- data/lib/vident/stimulus_outlet.rb +1 -2
- data/lib/vident/version.rb +1 -1
- data/lib/vident.rb +1 -1
- metadata +4 -4
- data/lib/vident/tag_helper.rb +0 -64
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b6c4ad465075f1a6541193c93ae1d96eb9f714b2d22390c30e1e0335ebec0935
|
|
4
|
+
data.tar.gz: ecb1718a8c85835afeb6e408f62300e345b94ac03f05f5f9c6b99f40859a3f0c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5f9d61b1b93ebc7bacee4aab54e82ef3c51211357ab05de0ac4763189dc60304481f2f7b306d03c9a0412b55e26477b4fe0ebb7c6c62f0863d09cea2d91088b3
|
|
7
|
+
data.tar.gz: 1d5aa67d225c9e2c8e9fee2f4cf355afa660a5b80e639b38edc169e293d694400f8d3aa04fa2178d95c61c4e5a15348695fb0e2da68359d6686f758bd69bf53f
|
data/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,26 @@ 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
|
+
|
|
19
|
+
## [1.0.0.beta1] - 2026-04-16
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- `tag(...)` singular stimulus kwargs (e.g. `stimulus_action: [:click, :foo]`) no longer splat `[event, handler]` tuples into two bare handlers (#19).
|
|
24
|
+
- `vident-view_component`'s `tag(...)` now emits void elements (`:input`, `:img`, `:br`, etc.) without a closing tag (#19).
|
|
25
|
+
- `vident-view_component`'s `tag(...)` without a block no longer renders the options hash as element content (#19).
|
|
26
|
+
- `stimulus_targets:` prop now accepts `Array` entries (e.g. `[[controller_path, :name]]`), matching `stimulus_actions:` (#20).
|
|
27
|
+
- `stimulus do ... outlets(...)` DSL now accepts a positional `Hash`, allowing string keys (e.g. stimulus identifiers containing `--`) that cannot be Ruby kwarg keys (#21).
|
|
28
|
+
|
|
9
29
|
## [1.0.0.alpha4] - 2025-12-12
|
|
10
30
|
|
|
11
31
|
- Update to `view_component` 4
|
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.
|
|
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
|
|
486
|
+
<%# OR use the vident child_element helper %>
|
|
487
487
|
|
|
488
|
-
<%= greeter.
|
|
489
|
-
<%= greeter.
|
|
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.
|
|
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.
|
|
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
|
data/lib/vident/component.rb
CHANGED
|
@@ -49,7 +49,7 @@ module Vident
|
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
51
|
prop :stimulus_actions, _Array(_Union(String, Symbol, Array, Hash, StimulusAction, StimulusActionCollection)), default: -> { [] }
|
|
52
|
-
prop :stimulus_targets, _Array(_Union(String, Symbol, Hash, StimulusTarget, StimulusTargetCollection)), default: -> { [] }
|
|
52
|
+
prop :stimulus_targets, _Array(_Union(String, Symbol, Array, Hash, StimulusTarget, StimulusTargetCollection)), default: -> { [] }
|
|
53
53
|
prop :stimulus_outlets, _Array(_Union(String, Symbol, StimulusOutlet, StimulusOutletCollection)), default: -> { [] }
|
|
54
54
|
prop :stimulus_outlet_host, _Nilable(Vident::Component) # A component that will host this component as an outlet
|
|
55
55
|
prop :stimulus_values, _Union(_Hash(Symbol, _Any), StimulusValue, StimulusValueCollection), default: -> { {} } # TODO: instead of _Any, is it _Interface(:to_s)?
|
|
@@ -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
|
data/lib/vident/version.rb
CHANGED
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/
|
|
41
|
+
require "vident/child_element_helper"
|
|
42
42
|
require "vident/stable_id"
|
|
43
43
|
require "vident/class_list_builder"
|
|
44
44
|
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: vident
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.0.
|
|
4
|
+
version: 1.0.0.beta2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stephen Ierodiaconou
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: railties
|
|
@@ -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
|
|
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
133
133
|
- !ruby/object:Gem::Version
|
|
134
134
|
version: '0'
|
|
135
135
|
requirements: []
|
|
136
|
-
rubygems_version:
|
|
136
|
+
rubygems_version: 4.0.3
|
|
137
137
|
specification_version: 4
|
|
138
138
|
summary: Vident is the base of your design system implementation, which provides helpers
|
|
139
139
|
for working with Stimulus. For component libraries with ViewComponent or Phlex.
|
data/lib/vident/tag_helper.rb
DELETED
|
@@ -1,64 +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
|
-
plural || (singular ? Array.wrap(singular) : nil)
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def generate_tag(tag_name, stimulus_data_attributes, options, &block)
|
|
61
|
-
raise NoMethodError, "Not implemented"
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
end
|