vident-view_component 1.0.0.alpha2 → 1.0.0.alpha3

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: 3452823d17aa9539e3507419b003819c10180119372b8e670a02407f37d3fe1f
4
- data.tar.gz: 8a021b5cbe54b96f431b5ab09c067286174c22852a2cdd338ed6199efffdd2b9
3
+ metadata.gz: 6008f5d78b7230589329a8b2a634767a2f54defd2fc9e3358548b3b641ef99b7
4
+ data.tar.gz: 7456a6c1f34c58cfce0477b623a12025e12665739f8f338687643cf5bea2b578
5
5
  SHA512:
6
- metadata.gz: 662e51386d794627b27c2bf6bc836b54f45b9b520e5ee5cc6a2e0814852a8ffca4400d7a5bf1c2b90d7aef42ec367e6a58e55d6b85ed9e2e402611a0de405f53
7
- data.tar.gz: 7d0f18b44084a70178b38cf389a1116f724dfa02c592862aeb5420835b34228b7f9c721da97a3791cd978a8a6cbaae69538b3ef984c1bdd54d35ce1998c75f73
6
+ metadata.gz: c289ba2437da177d898f6bce6f7275495153aca16b8ada22c57ea046a32f8341b858f0099224b698c6e4607a2ed735991c5992ee3cab75c1ed173eb4cbc89752
7
+ data.tar.gz: fa6d53c82825e7a9be5f000265310521b803543b974a5784082438d3bd44b6b3162e512ff12147ab1646859f99759b9c6a0c4038d7c8f859f575d41546b7810a
data/CHANGELOG.md CHANGED
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
5
5
  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
+ ## [1.0.0.alpha3] - 2025-07-21
9
+
10
+ ### Breaking
11
+ - `element_classes` is now `root_element_classes` to make more consistent with the other root element methods.
12
+
13
+ ### Added
14
+
15
+ -`.prop_names` and `#prop_values` methods to `Vident::Component` to return the names and values of the component's properties.
8
16
 
9
17
  ## [1.0.0.alpha2] - 2025-07-08
10
18
 
data/README.md CHANGED
@@ -76,21 +76,23 @@ class ButtonComponent < Vident::ViewComponent::Base
76
76
 
77
77
  # Configure Stimulus integration
78
78
  stimulus do
79
- actions [:click, :handle_click]
80
- # Static values
81
- values loading_duration: 1000
79
+ # Setup actions, including with proc to evaluate on instance
80
+ actions [:click, :handle_click],
81
+ -> { [stimulus_scoped_event(:my_custom_event), :handle_this] if should_handle_this? }
82
82
  # Map the clicked_count prop as a Stimulus value
83
83
  values_from_props :clicked_count
84
84
  # Dynamic values using procs (evaluated in component context)
85
- values item_count: -> { @items.count }
86
- values api_url: -> { Rails.application.routes.url_helpers.api_items_path }
85
+ values item_count: -> { @items.count },
86
+ api_url: -> { Rails.application.routes.url_helpers.api_items_path },
87
+ loading_duration: 1000 # or set static values
87
88
  # Static and dynamic classes
88
- classes loading: "opacity-50 cursor-wait"
89
- classes size: -> { @items.count > 10 ? "large" : "small" }
89
+ classes loading: "opacity-50 cursor-wait",
90
+ size: -> { @items.count > 10 ? "large" : "small" }
90
91
  end
91
92
 
92
93
  def call
93
94
  root_element do |component|
95
+ # Wire up targets etc
94
96
  component.tag(:span, stimulus_target: :status) do
95
97
  @text
96
98
  end
@@ -99,6 +101,7 @@ class ButtonComponent < Vident::ViewComponent::Base
99
101
 
100
102
  private
101
103
 
104
+ # Configure your components root HTML element
102
105
  def root_element_attributes
103
106
  {
104
107
  element_tag: @url ? :a : :button,
@@ -106,7 +109,8 @@ class ButtonComponent < Vident::ViewComponent::Base
106
109
  }
107
110
  end
108
111
 
109
- def element_classes
112
+ # optionally add logic to determine initial classes
113
+ def root_element_classes
110
114
  base_classes = "btn"
111
115
  case @style
112
116
  when :primary
@@ -263,7 +267,7 @@ The `root_element` helper method renders your component's root element with all
263
267
 
264
268
  ```ruby
265
269
  # In your component class
266
- def element_classes
270
+ def root_element_classes
267
271
  ["card", featured? ? "card-featured" : nil]
268
272
  end
269
273
 
@@ -619,7 +623,7 @@ class StyledComponent < Vident::ViewComponent::Base
619
623
  private
620
624
 
621
625
  # Classes on the root element
622
- def element_classes
626
+ def root_element_classes
623
627
  ["base-class", variant_class]
624
628
  end
625
629
 
@@ -653,7 +657,7 @@ class TailwindComponent < Vident::ViewComponent::Base
653
657
 
654
658
  private
655
659
 
656
- def element_classes
660
+ def root_element_classes
657
661
  # Conflicts with size_class will be resolved automatically
658
662
  "p-2 text-sm #{size_class}"
659
663
  end
@@ -41,10 +41,10 @@ module Vident
41
41
 
42
42
  SELF_CLOSING_TAGS = Set[:area, :base, :br, :col, :embed, :hr, :img, :input, :link, :meta, :param, :source, :track, :wbr].freeze
43
43
 
44
- def root_element(&block)
44
+ def root_element(**overrides, &block)
45
45
  tag_type = root_element_tag_type
46
46
  child_content = view_context.capture(self, &block) if block_given? # Evaluate before generating the outer tag options to ensure DSL methods are executed
47
- options = root_element_tag_options
47
+ options = resolve_root_element_attributes_before_render(overrides)
48
48
  if SELF_CLOSING_TAGS.include?(tag_type)
49
49
  view_context.tag(tag_type, options)
50
50
  else
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vident-view_component
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.alpha2
4
+ version: 1.0.0.alpha3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Ierodiaconou
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-07-08 00:00:00.000000000 Z
10
+ date: 2025-07-21 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: railties
@@ -55,14 +55,14 @@ dependencies:
55
55
  requirements:
56
56
  - - "~>"
57
57
  - !ruby/object:Gem::Version
58
- version: 1.0.0.alpha2
58
+ version: 1.0.0.alpha3
59
59
  type: :runtime
60
60
  prerelease: false
61
61
  version_requirements: !ruby/object:Gem::Requirement
62
62
  requirements:
63
63
  - - "~>"
64
64
  - !ruby/object:Gem::Version
65
- version: 1.0.0.alpha2
65
+ version: 1.0.0.alpha3
66
66
  - !ruby/object:Gem::Dependency
67
67
  name: view_component
68
68
  requirement: !ruby/object:Gem::Requirement