vident-phlex 1.0.0.alpha1 → 1.0.0.alpha2

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -1
  3. data/README.md +36 -6
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 54ed2508614f1ef6b15cc46ca5b7367ce13b7b391da9c2f36fb6605fa273e20e
4
- data.tar.gz: 7f0f214d642cfa83cf4b0ef14e46a5a5c77aadacaa3280abbd821f2eb5ec7c2d
3
+ metadata.gz: cc97ececf338ced9e9cd73a395c80c804e0ea529b34afa31db131005d7b7fcf9
4
+ data.tar.gz: 6b40bb7b3618a0fdec455291107d0ef5d5ea62c44d1c12234a1b7f3d843fac82
5
5
  SHA512:
6
- metadata.gz: 122bd2aefffeb7fa508c765a25166360c503762043f47e1e33609f479b1fd41f50b9e7ab0e3290ae60ba522919333c2ec8ec1f3eed121e1965c38f432239018f
7
- data.tar.gz: 490063b45c857b3155b0bc8631daba6d499ea6feab88aa6e35abc5e3be61de1b68e24a40988735392981930ee452b07b040e47b5d2d07159401f4cf2e7f51fe8
6
+ metadata.gz: f3085a8b4c11321ba8ebf8130cbea930acfc4f49bfe4fa71f9bce52b88b2c62f3b0774c10349e88f7bb9d9729398b08fe49f6561a31da470ff1ec22b81e5b764
7
+ data.tar.gz: 9cea997b9f59aaf9abc40c812cce5b8f985b5dbe0a79fd56d36eb5cb4056b582ce1d635b6a88a316a5cc288ca3f5d126d4ae8fae8dc65bef43932255f37aa8fd
data/CHANGELOG.md CHANGED
@@ -5,7 +5,17 @@ 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.alpha1] - 2025-07-04
8
+
9
+ ## [1.0.0.alpha2] - 2025-07-08
10
+
11
+ ### Breaking
12
+ - `nil` values in Stimulus values are ok, but `nil` for an action/target/outlet makes no sense so is ignored.
13
+
14
+ ### Fixed
15
+
16
+ - `stimulus_scoped_event` must return a Symbol to work with `stimulus_action` and `stimulus_target` methods etc.
17
+
18
+ ## [1.0.0.alpha1] - 2025-07-08
9
19
 
10
20
  This release is a major overhaul of the Vident library, and introduces a new API for defining components and Stimulus attributes. The new API is designed to be more consistent and easier to use.
11
21
 
data/README.md CHANGED
@@ -90,8 +90,10 @@ class ButtonComponent < Vident::ViewComponent::Base
90
90
  end
91
91
 
92
92
  def call
93
- root_element do
94
- @text
93
+ root_element do |component|
94
+ component.tag(:span, stimulus_target: :status) do
95
+ @text
96
+ end
95
97
  end
96
98
  end
97
99
 
@@ -130,14 +132,19 @@ export default class extends Controller {
130
132
  loadingDuration: Number
131
133
  }
132
134
  static classes = ["loading"]
135
+ static targets = ["status"]
133
136
 
134
137
  handleClick(event) {
135
138
  // Increment counter
136
139
  this.clickedCountValue++
137
140
 
141
+ // Store original text
142
+ const originalText = this.statusTarget.textContent
143
+
138
144
  // Add loading state
139
145
  this.element.classList.add(this.loadingClass)
140
146
  this.element.disabled = true
147
+ this.statusTarget.textContent = "Loading..."
141
148
 
142
149
  // Use the loading duration from the component
143
150
  setTimeout(() => {
@@ -145,7 +152,7 @@ export default class extends Controller {
145
152
  this.element.disabled = false
146
153
 
147
154
  // Update text to show count
148
- this.element.textContent = `${this.element.textContent} (${this.clickedCountValue})`
155
+ this.statusTarget.textContent = `${originalText} (${this.clickedCountValue})`
149
156
  }, this.loadingDurationValue)
150
157
  }
151
158
  }
@@ -178,7 +185,7 @@ The rendered HTML includes all Stimulus data attributes:
178
185
  data-button-component-loading-duration-value="1000"
179
186
  data-button-component-loading-class="opacity-50 cursor-wait"
180
187
  id="button-component-123">
181
- Save
188
+ <span data-button-component-target="status">Save</span>
182
189
  </button>
183
190
 
184
191
  <!-- Second button with pre-set count -->
@@ -189,7 +196,7 @@ The rendered HTML includes all Stimulus data attributes:
189
196
  data-button-component-loading-duration-value="1000"
190
197
  data-button-component-loading-class="opacity-50 cursor-wait"
191
198
  id="button-component-456">
192
- Submit
199
+ <span data-button-component-target="status">Submit</span>
193
200
  </button>
194
201
  ```
195
202
 
@@ -218,6 +225,29 @@ class CardComponent < Vident::ViewComponent::Base
218
225
  end
219
226
  ```
220
227
 
228
+ ### Post-Initialization Hooks
229
+
230
+ Vident provides a hook for performing actions after component initialization:
231
+
232
+ ```ruby
233
+ class MyComponent < Vident::ViewComponent::Base
234
+ prop :data, Hash, default: -> { {} }
235
+
236
+ def after_component_initialize
237
+ @processed_data = process_data(@data)
238
+ end
239
+
240
+ private
241
+
242
+ def process_data(data)
243
+ # Your initialization logic here
244
+ data.transform_values(&:upcase)
245
+ end
246
+ end
247
+ ```
248
+
249
+ **Important**: If you decide to override Literal's `after_initialize`, you **must** call `super` first to ensure Vident's initialization completes properly. Alternatively, use `after_component_initialize` which doesn't require calling `super`.
250
+
221
251
  ### Built-in Properties
222
252
 
223
253
  Every Vident component includes these properties:
@@ -389,7 +419,7 @@ Vident provides helper methods to generate scoped event names for dispatching cu
389
419
  class MyComponent < Vident::ViewComponent::Base
390
420
  stimulus do
391
421
  # Define an action that responds to a scoped event
392
- actions [stimulus_scoped_event_on_window(:data_loaded), :handle_data_loaded]
422
+ actions -> { [stimulus_scoped_event_on_window(:data_loaded), :handle_data_loaded] }
393
423
  end
394
424
 
395
425
  def handle_click
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vident-phlex
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.alpha1
4
+ version: 1.0.0.alpha2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Ierodiaconou
@@ -55,14 +55,14 @@ dependencies:
55
55
  requirements:
56
56
  - - "~>"
57
57
  - !ruby/object:Gem::Version
58
- version: 1.0.0.alpha1
58
+ version: 1.0.0.alpha2
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.alpha1
65
+ version: 1.0.0.alpha2
66
66
  - !ruby/object:Gem::Dependency
67
67
  name: phlex
68
68
  requirement: !ruby/object:Gem::Requirement