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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f9daeb0661e299cb12e012622f2fd879e1b0a5b0cb47f35f10fa0d7a306ef1f1
4
- data.tar.gz: e104306fddb134fd3aab3e8c3e987b132e209b4f59ce0196d711cb5b0ec19539
3
+ metadata.gz: '01190c3e09b4d2381741d1191ba5b06f2222fed5c20246e69732f80672e742b0'
4
+ data.tar.gz: 79686f42a9561d53b17c94f7652c762ba9d43358ad710f8fd456129907ea0e76
5
5
  SHA512:
6
- metadata.gz: d89cc17fb9c9d6178adf2a52c5648a2cfce4b338b0b0e703d0ed62186958c1883e35c2597010cc584fc3f63dda930890a7c00b3215f984489bd3524f726182ee
7
- data.tar.gz: 4ef495c9749504edff2fb5fd93e8027ba2ca9a739872078a66b52dbaea6880132101d905c481a594b1245ed1f168d9f5ddf9dd4b4c8d4058b5f3c8206e65faf4
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
  #
@@ -3,6 +3,6 @@
3
3
 
4
4
  module Phlex
5
5
  module Stimulus
6
- VERSION = '0.1.3'
6
+ VERSION = '0.2.0'
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phlex-stimulus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Espago