vident-phlex 1.0.0 → 1.0.2
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 +12 -0
- data/README.md +4 -1
- data/lib/vident/phlex/html.rb +26 -0
- 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: 685f521dd022b3123897a08683295cb84787192a4aabecbd3927843a43d6c668
|
|
4
|
+
data.tar.gz: d25cfb1546470d6736b869d0ed54f310fef6e72dc9ed3018265bb4869dddd713
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 16be0de4f984e20dc00184a79af7eb3519713c0bee72cae4e7d768434d77cfd6c4aef1241c71a15008634f47b4016b3ec40d7df216f3980880eb261802953e5e
|
|
7
|
+
data.tar.gz: 13a4a6bfdde8e2f998a46af8cc5084cc5acc388489cbb46784db850b2c346244e3c726acb150eba7639abec0d6e73d1e7e7a5effd33cc80426eecd255d8d9682
|
data/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,17 @@ 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.2] - 2026-04-21
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- Stimulus DSL procs (`values foo: -> { ... }`, `actions -> { ... }`, etc.) now resolve at **render time** — Phlex's `before_template` for `Vident::Phlex::HTML`, ViewComponent's `before_render` for `Vident::ViewComponent::Base` — instead of in `after_initialize`. Procs can now reach `helpers` / `view_context`, so they can call Rails helpers (`number_with_precision`, `t`, `l`, url helpers, etc.). Non-proc DSL entries still land in the collections at init time, so `after_component_initialize` mutators and external readers see them in the same order as before.
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- `phlex_helpers :name1, :name2, ...` class macro on `Vident::Phlex::HTML` — opts the component into Phlex's per-helper Rails adapters (`Phlex::Rails::Helpers::<CamelCase>`) so DSL procs can call helpers bare (`number_with_precision(@amount, precision: 2)`) instead of via the deprecated `helpers.<method>`. Unknown helper names raise `ArgumentError` at class definition.
|
|
18
|
+
|
|
19
|
+
|
|
9
20
|
## [1.0.0] - 2026-04-19
|
|
10
21
|
|
|
11
22
|
### Breaking
|
|
@@ -36,6 +47,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
|
36
47
|
- `Vident::StimulusController`'s `implied_controller_path` / `implied_controller_name` overrides now raise the same `ArgumentError` as the base when `implied_controller` is nil, instead of a confusing `NoMethodError`.
|
|
37
48
|
- `stimulus_values:` and `stimulus_classes:` props now accept cross-controller entries. The type unions include `Array` (matching `stimulus_actions:`/`stimulus_targets:`), and the collection parsers pass through pre-built `StimulusValue`/`StimulusValueCollection` (and class equivalents) instead of re-wrapping them into the single-value constructor and raising `ArgumentError: Invalid number of arguments` (#23).
|
|
38
49
|
- `Vident::ComponentClassLists#class_list_builder` no longer memoises the `ClassListBuilder` instance. The first caller's `root_element_html_class:` was previously latched into the cached builder, which silently dropped the `class:` argument passed to a later `root_element(class: …)` whenever `class_list_for_stimulus_classes(:name)` ran first. The underlying `TailwindMerge::Merger` is still thread-cached, so the re-construction cost is negligible.
|
|
50
|
+
- `Vident::ComponentClassLists#class_list_for_stimulus_classes` no longer leaks root element classes (component name, `root_element_classes`, etc.) into its return value. It previously reused the shared `class_list_builder`, whose `ClassListBuilder` is initialised with all root-element class sources baked in; `build` always prepends those, so child elements received the full root class soup instead of just the named Stimulus class CSS. Fix: build from a fresh `ClassListBuilder` with no root-element sources.
|
|
39
51
|
|
|
40
52
|
## [1.0.0.beta2] - 2026-04-16
|
|
41
53
|
|
data/README.md
CHANGED
|
@@ -415,7 +415,10 @@ class DynamicComponent < Vident::ViewComponent::Base
|
|
|
415
415
|
end
|
|
416
416
|
```
|
|
417
417
|
|
|
418
|
-
Procs have access to instance variables
|
|
418
|
+
Procs have access to instance variables and component methods. They run at render time (Phlex `before_template` / ViewComponent `before_render`), so they can reach the view context:
|
|
419
|
+
|
|
420
|
+
- **Phlex**: `helpers` is deprecated in phlex-rails. Opt in per Rails helper by including the matching adapter — e.g. `include Phlex::Rails::Helpers::NumberWithPrecision` — and call the helper bare (`number_with_precision(@amount, precision: 2)`) inside the proc. Vident ships a `phlex_helpers :number_with_precision, :t, :l` class macro on `Vident::Phlex::HTML` that does the right include for each name. See [phlex.fun/rails/helpers](https://www.phlex.fun/rails/helpers) for the full list of adapters.
|
|
421
|
+
- **ViewComponent**: call `helpers.<method>` or `view_context.<method>` directly.
|
|
419
422
|
|
|
420
423
|
**Important**: Each proc returns a single value for its corresponding stimulus attribute. If a proc returns an array, that entire array is treated as a single value, not multiple separate values. To provide multiple values for an attribute, use multiple procs or mix procs with static values:
|
|
421
424
|
|
data/lib/vident/phlex/html.rb
CHANGED
|
@@ -23,6 +23,25 @@ module Vident
|
|
|
23
23
|
raise StandardError, "No component source file exists #{path}" unless path && ::File.exist?(path)
|
|
24
24
|
::File.mtime(path).to_i.to_s
|
|
25
25
|
end
|
|
26
|
+
|
|
27
|
+
# Include the matching `Phlex::Rails::Helpers::<CamelCase>` module for
|
|
28
|
+
# each Rails helper name. Replaces `helpers.foo(...)` with bare `foo(...)`
|
|
29
|
+
# calls via phlex-rails' adapter macros.
|
|
30
|
+
#
|
|
31
|
+
# class Card < Vident::Phlex::HTML
|
|
32
|
+
# phlex_helpers :number_with_precision, :t, :l
|
|
33
|
+
# end
|
|
34
|
+
def phlex_helpers(*helper_names)
|
|
35
|
+
helper_names.each do |name|
|
|
36
|
+
mod_name = name.to_s.camelize
|
|
37
|
+
mod = begin
|
|
38
|
+
::Phlex::Rails::Helpers.const_get(mod_name)
|
|
39
|
+
rescue NameError
|
|
40
|
+
raise ArgumentError, "No Phlex::Rails::Helpers::#{mod_name} adapter. See https://www.phlex.fun/rails/helpers for the available list."
|
|
41
|
+
end
|
|
42
|
+
include(mod)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
26
45
|
end
|
|
27
46
|
|
|
28
47
|
# Helper to create the main element
|
|
@@ -39,6 +58,13 @@ module Vident
|
|
|
39
58
|
end
|
|
40
59
|
end
|
|
41
60
|
|
|
61
|
+
# Phlex lifecycle hook: resolve stimulus DSL procs now that the view
|
|
62
|
+
# context is wired (so `helpers` / `view_context` work inside them).
|
|
63
|
+
def before_template(&)
|
|
64
|
+
resolve_stimulus_attributes_at_render_time
|
|
65
|
+
super
|
|
66
|
+
end
|
|
67
|
+
|
|
42
68
|
private
|
|
43
69
|
|
|
44
70
|
def check_valid_html_tag!(tag_name)
|
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.
|
|
4
|
+
version: 1.0.2
|
|
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.
|
|
58
|
+
version: 1.0.2
|
|
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.
|
|
65
|
+
version: 1.0.2
|
|
66
66
|
- !ruby/object:Gem::Dependency
|
|
67
67
|
name: phlex
|
|
68
68
|
requirement: !ruby/object:Gem::Requirement
|