vident-view_component 1.0.1 → 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 +11 -0
- data/README.md +4 -1
- data/lib/vident/view_component/base.rb +7 -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: a26bc51182683f0f1c47872ef57ac42c09ae59fa3262054bcfc0b37fd1a47e94
|
|
4
|
+
data.tar.gz: 83123c45e6c5faede7e27dd379321b6f276a0da31cb06b4d9d7d2cf6bb08a3ac
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 939ca07e39446a0c78ac91c3d12c9510cc8ccbb7b3a21c12e30d9d063522ffad82a99cb0cba0116f47d0c01f084d53dc20e2ede232836bf1e2315078012945ed
|
|
7
|
+
data.tar.gz: a78683a140e388cc584a5f497a54830ba99cb8b43c96a9691bcbf820e02eb567b33ac1c49aa80f81ffc1a33ae19b85c5b3b1df1596bb4475bf231667ebae6702
|
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
|
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
|
|
|
@@ -41,6 +41,13 @@ module Vident
|
|
|
41
41
|
|
|
42
42
|
SELF_CLOSING_TAGS = Set[:area, :base, :br, :col, :embed, :hr, :img, :input, :link, :meta, :param, :source, :track, :wbr].freeze
|
|
43
43
|
|
|
44
|
+
# ViewComponent lifecycle hook: resolve stimulus DSL procs now that
|
|
45
|
+
# `@view_context` is set (so `helpers` works inside them).
|
|
46
|
+
def before_render
|
|
47
|
+
resolve_stimulus_attributes_at_render_time
|
|
48
|
+
super
|
|
49
|
+
end
|
|
50
|
+
|
|
44
51
|
def root_element(**overrides, &block)
|
|
45
52
|
tag_type = root_element_tag_type
|
|
46
53
|
child_content = view_context.capture(self, &block) if block_given? # Evaluate before generating the outer tag options to ensure DSL methods are executed
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: vident-view_component
|
|
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: view_component
|
|
68
68
|
requirement: !ruby/object:Gem::Requirement
|