vident-phlex 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: cc97ececf338ced9e9cd73a395c80c804e0ea529b34afa31db131005d7b7fcf9
4
- data.tar.gz: 6b40bb7b3618a0fdec455291107d0ef5d5ea62c44d1c12234a1b7f3d843fac82
3
+ metadata.gz: 690fe9845d80be2c5204bd6ca64df999e7969d89e9c7c5ca9be48c5d8641a625
4
+ data.tar.gz: d5499b956b2c5433144fc33a98a3212d5285706487d57ac39772d704d0058f17
5
5
  SHA512:
6
- metadata.gz: f3085a8b4c11321ba8ebf8130cbea930acfc4f49bfe4fa71f9bce52b88b2c62f3b0774c10349e88f7bb9d9729398b08fe49f6561a31da470ff1ec22b81e5b764
7
- data.tar.gz: 9cea997b9f59aaf9abc40c812cce5b8f985b5dbe0a79fd56d36eb5cb4056b582ce1d635b6a88a316a5cc288ca3f5d126d4ae8fae8dc65bef43932255f37aa8fd
6
+ metadata.gz: 80d00c3523e9ec7fcbc5a412201f011ecee809cb31df470e5f84d63e7409174817cc507941e149242ef5a9fbe7b20c86e09d6f53d95e69841c3e718c7cd13922
7
+ data.tar.gz: 2b7b789d4233806eb1b036da69054d307df7450e6930d1302557b1a70d7437cb253f61271b096fcdf3c77a4c8dcab0f492b34631618458fd14edecb1fb063a51
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
@@ -26,20 +26,20 @@ module Vident
26
26
  end
27
27
 
28
28
  # Helper to create the main element
29
- def root_element(&block)
29
+ def root_element(**overrides, &block)
30
30
  tag_type = root_element_tag_type
31
31
  check_valid_html_tag!(tag_type)
32
32
  # Evaluate before generating the outer tag options to ensure DSL methods are executed
33
33
  if block_given?
34
34
  content = capture(self, &block).html_safe
35
- options = root_element_tag_options
35
+ options = resolve_root_element_attributes_before_render(overrides)
36
36
  if content
37
37
  send(tag_type, **options) { content }
38
38
  else
39
39
  send(tag_type, **options)
40
40
  end
41
41
  else
42
- send(tag_type, **root_element_tag_options)
42
+ send(tag_type, **resolve_root_element_attributes_before_render(overrides))
43
43
  end
44
44
  end
45
45
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vident-phlex
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: phlex
68
68
  requirement: !ruby/object:Gem::Requirement