phlex-stimulus 0.1.3 → 0.2.0
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 +6 -0
- data/README.md +34 -0
- data/lib/phlex/stimulus/components/controller.rb +10 -0
- data/lib/phlex/stimulus/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '01190c3e09b4d2381741d1191ba5b06f2222fed5c20246e69732f80672e742b0'
|
|
4
|
+
data.tar.gz: 79686f42a9561d53b17c94f7652c762ba9d43358ad710f8fd456129907ea0e76
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5e857f549c94fa68e8639f9e8bbcfda48626bbf2e3fb960d25d0e1490f97c453cce96174239c660532a1be4a2abd2be85a82221f3a8c2c380da24b5d9ed24fde
|
|
7
|
+
data.tar.gz: 7d459a8ff17f0626c0fc692b5b9fa929c2081815b8438e38a198518f10e94a16d0157a2c6e5ce94597c37914085d2a8216d121e8e67ffa51bb845af437d43334
|
data/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
9
9
|
|
|
10
10
|
Add changes in new features here. Do not change the gem's version in pull/merge requests.
|
|
11
11
|
|
|
12
|
+
## [0.2.0] - 29.07.2026
|
|
13
|
+
|
|
14
|
+
[Diff](https://github.com/espago/phlex-stimulus/compare/v0.1.3...v0.2.0)
|
|
15
|
+
|
|
16
|
+
- Add action parameter support
|
|
17
|
+
|
|
12
18
|
## [0.1.3] - 28.07.2026
|
|
13
19
|
|
|
14
20
|
[Diff](https://github.com/espago/phlex-stimulus/compare/v0.1.2...v0.1.3)
|
data/README.md
CHANGED
|
@@ -210,6 +210,40 @@ This is the same as:
|
|
|
210
210
|
div(data: { 'summary:redirected' => 'other#do' })
|
|
211
211
|
```
|
|
212
212
|
|
|
213
|
+
#### `param`
|
|
214
|
+
|
|
215
|
+
This method helps you get the names of parameters
|
|
216
|
+
given to stimulus actions.
|
|
217
|
+
You can read more about action parameters [here](https://stimulus.hotwired.dev/reference/https://stimulus.hotwired.dev/reference/actions#action-parameters).
|
|
218
|
+
|
|
219
|
+
```rb
|
|
220
|
+
class SummaryController < Controller
|
|
221
|
+
self.controller_name = 'summary'
|
|
222
|
+
|
|
223
|
+
actions :foo
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
SummaryController.param('id') #=> "summary-id-param"
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
You would use it like so to define a parameter for a stimulus action:
|
|
230
|
+
|
|
231
|
+
```rb
|
|
232
|
+
div(
|
|
233
|
+
data: {
|
|
234
|
+
action: event('click', SummaryController.foo_action),
|
|
235
|
+
# will be available as `event.id` in the action
|
|
236
|
+
SummaryController.param('id') => 35,
|
|
237
|
+
},
|
|
238
|
+
)
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
This is the same as:
|
|
242
|
+
|
|
243
|
+
```rb
|
|
244
|
+
div(data: { 'summary:redirected' => 'other#do' })
|
|
245
|
+
```
|
|
246
|
+
|
|
213
247
|
### Component Helpers
|
|
214
248
|
|
|
215
249
|
There are some useful helper methods you can use in every phlex component.
|
|
@@ -84,6 +84,16 @@ module Phlex::Stimulus
|
|
|
84
84
|
@target_defs ||= []
|
|
85
85
|
end
|
|
86
86
|
|
|
87
|
+
# Constructs a Stimulus action parameter name
|
|
88
|
+
# eg.
|
|
89
|
+
#
|
|
90
|
+
# SummaryController.param('id') #=> "summary-id-param"
|
|
91
|
+
#
|
|
92
|
+
#: (String) -> String
|
|
93
|
+
def param(param_name)
|
|
94
|
+
"#{controller_name}-#{param_name}-param"
|
|
95
|
+
end
|
|
96
|
+
|
|
87
97
|
# Constructs a Stimulus dispatched event name
|
|
88
98
|
# eg.
|
|
89
99
|
#
|