vident-view_component 1.0.0.alpha2 → 1.0.0.alpha4

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: ad0c1b7dc1807d2f8de65971bad127b5f886a138faae6fd1951d89743e328950
4
+ data.tar.gz: 4ef05f134343065a200c5c109a1d87849c99c37982adf45f79a0b117e5577150
5
5
  SHA512:
6
- metadata.gz: 662e51386d794627b27c2bf6bc836b54f45b9b520e5ee5cc6a2e0814852a8ffca4400d7a5bf1c2b90d7aef42ec367e6a58e55d6b85ed9e2e402611a0de405f53
7
- data.tar.gz: 7d0f18b44084a70178b38cf389a1116f724dfa02c592862aeb5420835b34228b7f9c721da97a3791cd978a8a6cbaae69538b3ef984c1bdd54d35ce1998c75f73
6
+ metadata.gz: b868e1dd942a08188a935630cbdd3c0b39f773b0e42327c32c9960877914c3887920ec22caf1a3e830c17f821d4e4c0b333b09119bb16edf4b0d57bd607b3dd0
7
+ data.tar.gz: f844a54d9699129aacf5fb9ae13af2ae7997c7ea31d4b5c28f947a0a3eede588823acc99bd7b4f8924880fa234d48ec396e259d5f2cf8d5412036d109cb014b6
data/CHANGELOG.md CHANGED
@@ -6,6 +6,19 @@ 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.alpha4] - 2025-12-12
10
+
11
+ - Update to `view_component` 4
12
+
13
+ ## [1.0.0.alpha3] - 2025-07-21
14
+
15
+ ### Breaking
16
+ - `element_classes` is now `root_element_classes` to make more consistent with the other root element methods.
17
+
18
+ ### Added
19
+
20
+ -`.prop_names` and `#prop_values` methods to `Vident::Component` to return the names and values of the component's properties.
21
+
9
22
  ## [1.0.0.alpha2] - 2025-07-08
10
23
 
11
24
  ### Breaking
data/README.md CHANGED
@@ -71,26 +71,28 @@ class ButtonComponent < Vident::ViewComponent::Base
71
71
  # Define typed properties
72
72
  prop :text, String, default: "Click me"
73
73
  prop :url, _Nilable(String)
74
- prop :style, Symbol, in: [:primary, :secondary], default: :primary
74
+ prop :style, _Union(:primary, :secondary), default: :primary
75
75
  prop :clicked_count, Integer, default: 0
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.alpha4
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-12-12 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: railties
@@ -55,28 +55,34 @@ dependencies:
55
55
  requirements:
56
56
  - - "~>"
57
57
  - !ruby/object:Gem::Version
58
- version: 1.0.0.alpha2
58
+ version: 1.0.0.alpha4
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.alpha4
66
66
  - !ruby/object:Gem::Dependency
67
67
  name: view_component
68
68
  requirement: !ruby/object:Gem::Requirement
69
69
  requirements:
70
- - - '='
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '4.0'
73
+ - - "<"
71
74
  - !ruby/object:Gem::Version
72
- version: 4.0.0.rc2
75
+ version: '5'
73
76
  type: :runtime
74
77
  prerelease: false
75
78
  version_requirements: !ruby/object:Gem::Requirement
76
79
  requirements:
77
- - - '='
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '4.0'
83
+ - - "<"
78
84
  - !ruby/object:Gem::Version
79
- version: 4.0.0.rc2
85
+ version: '5'
80
86
  description: Vident with ViewComponent
81
87
  email:
82
88
  - stevegeek@gmail.com