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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -1
- data/README.md +36 -6
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc97ececf338ced9e9cd73a395c80c804e0ea529b34afa31db131005d7b7fcf9
|
4
|
+
data.tar.gz: 6b40bb7b3618a0fdec455291107d0ef5d5ea62c44d1c12234a1b7f3d843fac82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
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.
|
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.
|
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.
|
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.
|
65
|
+
version: 1.0.0.alpha2
|
66
66
|
- !ruby/object:Gem::Dependency
|
67
67
|
name: phlex
|
68
68
|
requirement: !ruby/object:Gem::Requirement
|