vident-view_component 1.0.2 → 2.0.1

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: a26bc51182683f0f1c47872ef57ac42c09ae59fa3262054bcfc0b37fd1a47e94
4
- data.tar.gz: 83123c45e6c5faede7e27dd379321b6f276a0da31cb06b4d9d7d2cf6bb08a3ac
3
+ metadata.gz: fa78ec0f7f2aad87ee0b10d3f4d354d294332a29dc0b7ad9814b44791739cb06
4
+ data.tar.gz: da78bd43e7b73a5ce53e14126ad297950e6ab18bfb2ea3338ce37a4dbb4b68f4
5
5
  SHA512:
6
- metadata.gz: 939ca07e39446a0c78ac91c3d12c9510cc8ccbb7b3a21c12e30d9d063522ffad82a99cb0cba0116f47d0c01f084d53dc20e2ede232836bf1e2315078012945ed
7
- data.tar.gz: a78683a140e388cc584a5f497a54830ba99cb8b43c96a9691bcbf820e02eb567b33ac1c49aa80f81ffc1a33ae19b85c5b3b1df1596bb4475bf231667ebae6702
6
+ metadata.gz: 1c5d0e27e9ced3bbc2a94e72c4593c2bc3aa69527f64bcf24e86612bd2f6d32a3bb929ee9a87cd1331088eace2e619cd3c4d0491063d3b8db0945479fe9ab2c1
7
+ data.tar.gz: d3bb8e28b96a8b7e33bd538f1e4b0c01a377d7f806d6d625b9aee0e3908bfc60b65b73e6bcb2ec46bc25b1c3469aa82f381c87573a5054f3165beadad15b6721
data/CHANGELOG.md CHANGED
@@ -6,6 +6,56 @@ 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
+ ## [2.0.1] - 2026-04-24
10
+
11
+ ### Fixed
12
+
13
+ - Base gem no longer fails to load when installed without the adapter gems — adapter requires moved to their own entry points (`lib/vident-phlex.rb`, `lib/vident-view_component.rb`) (#29).
14
+
15
+
16
+ ## [2.0.0] - 2026-04-24
17
+
18
+ Vident 2.0 is a ground-up rearchitecture of the DSL, attribute resolution, and composition model. The public shape of `stimulus do ... end`, `root_element`, `child_element`, outlets, props, and the `stimulus_*:` prop/kwarg API is preserved for common cases, but several internals and a handful of edge-case behaviours changed. See `doc/reviews/v1-gotchas.md` for the full list of fixed gotchas; the highlights are below.
19
+
20
+ ### Breaking
21
+
22
+ - **Namespace consolidation.** The `Vident2::*` namespace used during side-by-side development has been removed. Everything now lives under `Vident::*` directly: `Vident::Component`, `Vident::Capabilities::*`, `Vident::Phlex::HTML`, `Vident::ViewComponent::Base`, `Vident::Stimulus::*` (value classes), `Vident::Internals::*` (DSL/Resolver/Plan). Upgrade path is a `s/Vident2::/Vident::/g` on project code.
23
+ - **Legacy collection classes removed.** `Vident::StimulusAction`, `StimulusTarget`, `StimulusController`, `StimulusValue`, `StimulusParam`, `StimulusOutlet`, `StimulusClass`, and each of their `*Collection` companions (plus `StimulusBuilder`, `StimulusDataAttributeBuilder`, `StimulusAttributeBase`, `StimulusAttributes`, `StimulusAction::Descriptor`) are gone. The 2.0 equivalents live under `Vident::Stimulus::*` (`Action`, `Target`, `Controller`, `Value`, `Param`, `Outlet`, `ClassMap`, `Collection`). `#to_h` now uses **Symbol keys** uniformly; V1 returned String keys for some primitives.
24
+ - **`child_element` strictness.** Passing both `stimulus_<singular>:` and `stimulus_<plural>:` kwargs now raises `ArgumentError` (`"mutually exclusive — pass one or the other."`). V1 silently dropped the singular when the plural was an empty array (latent since 1.0.0, see "Fixed" below). Workaround at call sites that relied on the V1 shape: `stimulus_targets: [:input, *control_targets]`.
25
+ - **`stimulus_controllers:` prop appends instead of replacing.** V1 replaced the implied controller when you passed `stimulus_controllers:` at render time; V2 appends, so the root element carries `data-controller="implied extra"`. Migration: if you wanted to *replace*, add `no_stimulus_controller` at the class level.
26
+ - **Outlet DSL procs now resolve.** V1 silently passed a proc through as the outlet selector string, emitting literal `#<Proc:0x...>`. V2 evaluates the proc in the instance binding and emits the returned string. This turns previously broken code into working code, but if you relied on the proc-as-identity string for some reason, you'll now see a different data attribute.
27
+ - **`nil` vs `false` drop rule.** V1 dropped both `nil` and `false` proc returns silently via a `blank?` filter. V2 drops only `nil`; `false` reaches the parser and raises `Vident::ParseError`. Fix: return `nil` (not `false`) to mean "don't emit this entry."
28
+ - **`no_stimulus_controller` + DSL body now raises loudly.** V1 raised a bare `StandardError` at instance init. V2 raises `Vident::DeclarationError` at `stimulus do ... end` time with the offending class name and caller location in the message.
29
+ - **StableId strategy.** Unchanged from 1.0, but reiterated here because it's the biggest gotcha during upgrade. `Vident::StableId` requires an explicit `strategy` and per-request seed — `bin/rails generate vident:install` sets both up correctly.
30
+
31
+ ### Added
32
+
33
+ - **Fluent action DSL.** Inside `stimulus do ... end`, the singular `action(...)` call returns a chainable builder: `action(:escape).on(:keydown).keyboard("esc").window`, `action(:save).modifier(:prevent, :stop)`, `action(:delete).when { admin? }`. Chain methods: `.on`, `.call_method`, `.modifier`, `.keyboard`, `.window`, `.on_controller`, `.when`.
34
+ - **Kwargs shorthand for actions.** `action :save, on: :click, modifier: [:prevent, :stop], keyboard: "ctrl+s", window: true, on_controller: :admin, call_method: :handle_save, when: -> { ... }` — equivalent to the fluent chain, pick whichever reads better. Unknown kwargs raise `ArgumentError`.
35
+ - **Controller aliases.** `controller "admin/users", as: :admin` inside `stimulus do` declares a short alias; `action(...).on_controller(:admin)` or `action(..., on_controller: :admin)` then routes through it. Unknown alias refs raise `Vident::DeclarationError`. Runtime inputs (`stimulus_actions: [{method: :save, controller: :admin}]`) resolve the same map.
36
+ - **Capability mixin composition.** `Vident::Component` is a composition root that includes twelve focused capability mixins (`Tailwind`, `Declarable`, `Identifiable`, `StimulusDeclaring`, `StimulusParsing`, `StimulusMutation`, `StimulusDraft`, `StimulusDataEmitting`, `ClassListBuilding`, `RootElementRendering`, `ChildElementRendering`, `Inspectable`), plus an opt-in `Caching` mixin (thirteen in total, including Caching). Mixin order mirrors capability dependencies.
37
+ - **Singular DSL primitives.** `value(:name, *, **)`, `param(:name, *, **)`, `outlet(:name, *, **)`, `class_map(:name, *, **)`, `controller(path, as: nil)`, `controllers(*paths)`, `target(:name).when { ... }` — full set of singular entry points alongside the plural forms.
38
+ - **Draft → Plan seal pattern.** Internal: `after_component_initialize` mutators (e.g. `add_stimulus_actions`) still work against a mutable Draft; the Draft seals into an immutable Plan once rendering begins. Prevents the V1 "mutator silently ignored post-render" class of bug.
39
+ - **Phase-split proc resolution.** DSL procs are evaluated in two phases: static (after_initialize, no `view_context`) and procs (`before_template` / `before_render`, `view_context`/`helpers` wired). Procs can now call Rails helpers (`number_with_precision`, url helpers, `t`, `l`, etc.) safely — already backported to 1.0.2.
40
+ - `has_stimulus_controller` class method re-enables the implied controller in a subclass after a parent declared `no_stimulus_controller` (#27).
41
+ - `root_element_class_list(extra = nil)` and `root_element_data_attributes` for components rendering through third-party tag helpers instead of `root_element(...)` (#25; V1 names `render_classes` / `stimulus_data_attributes` — see UPGRADING.md §8).
42
+ - Class-level Stimulus builders — `MyComponent.stimulus_target(:x)` etc. — return value objects without a component instance (#18).
43
+ - `Vident::Types::*` — seven named Literal unions for the built-in `stimulus_*:` prop types, reusable from user components (#16).
44
+ - `cache_component(*keys, **options, &block)` on both adapter base classes — fragment-caches the block using the Vident-computed `cache_key` (#13).
45
+ - Shared `Vident::Stimulus::Base` + `Combinable` for the value classes: `with(**overrides)` combinator, canonical `deconstruct_keys` (restores pattern matching — previously shadowed by the `to_h` data-attribute override), and `Action.parse([event, existing_action])` merge form (#28).
46
+
47
+ ### Fixed
48
+
49
+ - `child_element` no longer silently drops a `stimulus_<singular>:` kwarg when `stimulus_<plural>:` is also passed with an empty array. The V1 helper returned early on an empty-but-truthy plural, losing the singular and emitting no data attribute — latent since 1.0.0, surfaced by call sites like `child_element(:input, stimulus_target: :input, stimulus_targets: control_targets)` where `control_targets` defaulted to `[]`. V2 raises `ArgumentError` on both-set (see Breaking); workaround on 1.x is `stimulus_targets: [:input, *control_targets]` (also works on 2.x).
50
+ - Outlet DSL procs now resolve instead of being treated as identity strings (see Breaking).
51
+ - `add_stimulus_actions([:click, :handle])` now treats the Array as *one* action descriptor (event + method pair) rather than splatting it into two separate `:click` and `:handle` actions. Matches the DSL's `actions [:click, :handle]` semantics — the V1 asymmetry is gone.
52
+
53
+ ### Removed
54
+
55
+ - `Vident::StimulusAction::Descriptor` typed data class. The V2 equivalent is `Vident::Stimulus::Action` itself — the Hash shape accepted by the DSL (`{event:, method:, controller:, options:, keyboard:, window:}`) parses directly into the value class now. Callers that instantiated `Descriptor` explicitly should swap to `Vident::Stimulus::Action.parse(hash, implied: ...)` or just pass the Hash.
56
+ - Legacy top-level requires like `require "vident/stimulus_action"`. The main `require "vident"` loads the whole surface; deep requires for individual value classes still work (`require "vident/stimulus/action"`) but are no longer the documented path.
57
+
58
+
9
59
  ## [1.0.2] - 2026-04-21
10
60
 
11
61
  ### Changed
data/README.md CHANGED
@@ -79,9 +79,13 @@ class ButtonComponent < Vident::ViewComponent::Base
79
79
 
80
80
  # Configure Stimulus integration
81
81
  stimulus do
82
- # Setup actions, including with proc to evaluate on instance
83
- actions [:click, :handle_click],
84
- -> { [stimulus_scoped_event(:my_custom_event), :handle_this] if should_handle_this? }
82
+ # Fluent action DSL: reads left-to-right as "the handle_click method fires on the click event".
83
+ action(:handle_click).on(:click)
84
+ # Kwargs shorthand — same result, pick whichever reads better:
85
+ action :handle_submit, on: :submit, modifier: [:prevent, :stop]
86
+ # Proc for conditional / cross-component wiring, evaluated in the instance at render time.
87
+ action(-> { [stimulus_scoped_event(:my_custom_event), :handle_this] if should_handle_this? })
88
+
85
89
  # Map the clicked_count prop as a Stimulus value
86
90
  values_from_props :clicked_count
87
91
  # Dynamic values using procs (evaluated in component context)
@@ -178,7 +182,7 @@ Use the component in your views:
178
182
  <%= render ButtonComponent.new(text: "Cancel", url: "/home", style: :secondary) %>
179
183
 
180
184
  <!-- Override things -->
181
- <%= render ButtonComponent.new(text: "Cancel", url: "/home" classes: "bg-red-900", html_options: {role: "button"}) %>
185
+ <%= render ButtonComponent.new(text: "Cancel", url: "/home", classes: "bg-red-900", html_options: {role: "button"}) %>
182
186
  ```
183
187
 
184
188
  The rendered HTML includes all Stimulus data attributes:
@@ -227,7 +231,7 @@ class CardComponent < Vident::ViewComponent::Base
227
231
  # Property with validation
228
232
  prop :size, _Union(:small, :medium, :large), default: :medium
229
233
 
230
- # Boolean property (creates predicate method)
234
+ # Boolean property (pass `predicate: :public` to also generate a `?` method)
231
235
  prop :featured, _Boolean, default: false
232
236
  end
233
237
  ```
@@ -271,7 +275,7 @@ The `root_element` helper method renders your component's root element with all
271
275
  ```ruby
272
276
  # In your component class
273
277
  def root_element_classes
274
- ["card", featured? ? "card-featured" : nil]
278
+ ["card", @featured ? "card-featured" : nil]
275
279
  end
276
280
 
277
281
  private
@@ -362,17 +366,41 @@ class ToggleComponent < Vident::ViewComponent::Base
362
366
  end
363
367
  ```
364
368
 
365
- **Action modifiers**the Array form `[:click, :method]` handles the common case. For Stimulus's modifier syntax (`:once`/`:prevent`/`:stop`/`:passive`/`:"!passive"`/`:capture`/`:self`, keyboard filters, `@window`), pass a Hash or a `Vident::StimulusAction::Descriptor`:
369
+ **Action modifiers — fluent DSL.** Singular `action(...)` returns a builder you chain with event, modifier, keyboard, and window setters. Kwargs shorthand is equivalent:
370
+
371
+ ```ruby
372
+ stimulus do
373
+ action(:submit).on(:click).modifier(:once, :prevent) # click:once:prevent->implied#submit
374
+ action(:on_key).on(:keydown).keyboard("ctrl+a") # keydown.ctrl+a->implied#onKey
375
+ action(:on_resize).on(:resize).window # resize@window->implied#onResize
376
+
377
+ # kwargs shorthand — same result:
378
+ action :submit, on: :click, modifier: [:once, :prevent]
379
+ action :on_key, on: :keydown, keyboard: "ctrl+a"
380
+ action :on_resize, on: :resize, window: true
381
+ action :save, on: :click, call_method: :handle_save
382
+
383
+ # conditional inclusion via `.when` / `when:`:
384
+ action(:delete).when { admin? }
385
+ end
386
+ ```
387
+
388
+ Chain methods: `.on`, `.call_method`, `.modifier`, `.keyboard`, `.window`, `.on_controller`, `.when`. Recognised kwargs: `on:`, `call_method:`, `modifier:` (Symbol or Array), `keyboard:`, `window:`, `on_controller:`, `when:`. Unknown kwargs or modifier symbols raise `ArgumentError`.
389
+
390
+ **Controller aliases.** Declare a short alias with `controller "path", as: :sym`, then reference it from action entries via the fluent `.on_controller(:sym)` or the `on_controller: :sym` kwarg:
366
391
 
367
392
  ```ruby
368
- actions({event: :click, method: :submit, options: [:once, :prevent]})
369
- actions({event: :keydown, method: :on_key, keyboard: "ctrl+a"})
370
- actions({event: :resize, method: :on_resize, window: true})
371
- # or, if you want a typed, passable object:
372
- actions Vident::StimulusAction::Descriptor.new(event: :click, method: :save, options: [:prevent])
393
+ stimulus do
394
+ controller "admin/users", as: :admin
395
+
396
+ action(:save).on(:click).on_controller(:admin) # click->admin--users#save
397
+ action :save, on: :click, on_controller: :admin # same, kwargs form
398
+ end
373
399
  ```
374
400
 
375
- Unknown option symbols raise `ArgumentError` at attribute construction, not at render.
401
+ Unknown aliases raise `Vident::DeclarationError` at render time.
402
+
403
+ **Legacy Hash form.** Still accepted for compat — `actions({event: :click, method: :submit, options: [:once, :prevent]})` parses the same way. The Hash descriptor is folded directly into `Vident::Stimulus::Action` — pass a Hash and it is parsed in place. Accepted keys: `method:`, `event:`, `controller:`, `options:`, `keyboard:`, `window:`.
376
404
 
377
405
  ### Dynamic Values and Classes with Procs
378
406
 
@@ -489,14 +517,14 @@ class MyComponent < Vident::ViewComponent::Base
489
517
  # This would generate: "my-component:dataLoaded"
490
518
  puts stimulus_scoped_event(:data_loaded)
491
519
 
492
- # For window events, this generates: "my-component:dataLoaded@window"
520
+ # For window events, this generates: :"my-component:dataLoaded@window"
493
521
  puts stimulus_scoped_event_on_window(:data_loaded)
494
522
  end
495
523
  end
496
524
 
497
525
  # Available as both class and instance methods:
498
- MyComponent.stimulus_scoped_event(:data_loaded) # => "my-component:dataLoaded"
499
- MyComponent.new.stimulus_scoped_event(:data_loaded) # => "my-component:dataLoaded"
526
+ MyComponent.stimulus_scoped_event(:data_loaded) # => :"my-component:dataLoaded"
527
+ MyComponent.new.stimulus_scoped_event(:data_loaded) # => :"my-component:dataLoaded"
500
528
  ```
501
529
 
502
530
  This is useful for:
@@ -532,7 +560,7 @@ class CustomComponent < Vident::ViewComponent::Base
532
560
  end
533
561
  ```
534
562
 
535
- All stimulus props accept Symbol paths as well as Strings (e.g. `stimulus_controllers: [:custom, :"admin/users"]`). `stimulus_values:` and `stimulus_classes:` additionally accept Array entries (for cross-controller: `[["admin/users", :name, "value"]]`) and pre-built `StimulusValue`/`StimulusValueCollection` / `StimulusClass`/`StimulusClassCollection` instances, so you can compose attribute sets outside the component and pass them in.
563
+ All stimulus props accept Symbol paths as well as Strings (e.g. `stimulus_controllers: [:custom, :"admin/users"]`). `stimulus_values:` and `stimulus_classes:` additionally accept Array entries (for cross-controller: `[["admin/users", :name, "value"]]`) and pre-built `Vident::Stimulus::Value` / `Vident::Stimulus::ClassMap` instances, so you can compose attribute sets outside the component and pass them in.
536
564
 
537
565
  or you can use tag helpers to generate HTML with Stimulus attributes:
538
566
 
@@ -1,7 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "set"
4
+
1
5
  module Vident
2
6
  module ViewComponent
3
7
  class Base < ::ViewComponent::Base
4
- include Vident::Component
8
+ include ::Vident::Component
5
9
 
6
10
  class << self
7
11
  def cache_component_modified_time
@@ -17,7 +21,6 @@ module Vident
17
21
  end
18
22
 
19
23
  def template_path
20
- # Check for common ViewComponent template extensions in order of preference
21
24
  extensions = [".html.erb", ".erb", ".html.haml", ".haml", ".html.slim", ".slim"]
22
25
  base_path = Rails.root.join(components_base_path, virtual_path)
23
26
 
@@ -26,7 +29,6 @@ module Vident
26
29
  return potential_path if File.exist?(potential_path)
27
30
  end
28
31
 
29
- # Return the default .html.erb path if no template is found
30
32
  Rails.root.join(components_base_path, "#{virtual_path}.html.erb").to_s
31
33
  end
32
34
 
@@ -39,19 +41,30 @@ module Vident
39
41
  end
40
42
  end
41
43
 
42
- SELF_CLOSING_TAGS = Set[:area, :base, :br, :col, :embed, :hr, :img, :input, :link, :meta, :param, :source, :track, :wbr].freeze
44
+ SELF_CLOSING_TAGS = Set[*%i[area base br col embed hr img input link meta param source track wbr]].freeze
43
45
 
44
- # ViewComponent lifecycle hook: resolve stimulus DSL procs now that
45
- # `@view_context` is set (so `helpers` works inside them).
46
+ # DSL procs stay unresolved until `@view_context` is set; resolve them here.
46
47
  def before_render
47
48
  resolve_stimulus_attributes_at_render_time
48
49
  super
49
50
  end
50
51
 
52
+ # Fragment-cache the block's rendered String using the Vident-computed
53
+ # `cache_key`. Useful inside a `call` method; for sidecar ERB templates
54
+ # use the native `<% cache cache_key do %>` pattern instead.
55
+ def cache_component(*extra_keys, expires_in: nil, &block)
56
+ unless respond_to?(:cacheable?) && cacheable?
57
+ raise ::Vident::ConfigurationError,
58
+ "#{self.class.name} is not cacheable — `include Vident::Caching` and declare `with_cache_key` first."
59
+ end
60
+ ::Rails.cache.fetch([cache_key, *extra_keys], expires_in: expires_in) { capture(&block) }
61
+ end
62
+
63
+ # Capture block first so children can mutate this Draft before it seals (outlet-host pattern).
51
64
  def root_element(**overrides, &block)
52
65
  tag_type = root_element_tag_type
53
- child_content = view_context.capture(self, &block) if block_given? # Evaluate before generating the outer tag options to ensure DSL methods are executed
54
- options = resolve_root_element_attributes_before_render(overrides)
66
+ child_content = view_context.capture(self, &block) if block
67
+ options = build_root_element_attributes(overrides)
55
68
  if SELF_CLOSING_TAGS.include?(tag_type)
56
69
  view_context.tag(tag_type, options)
57
70
  else
@@ -59,61 +72,41 @@ module Vident
59
72
  end
60
73
  end
61
74
 
62
- def as_stimulus_targets(...)
63
- to_data_attribute_string(**stimulus_targets(...))
64
- end
75
+ def as_stimulus_targets(...) = to_data_attribute_string(**stimulus_targets(...).to_h)
65
76
 
66
- def as_stimulus_target(...)
67
- to_data_attribute_string(**stimulus_target(...))
68
- end
77
+ def as_stimulus_target(...) = to_data_attribute_string(**stimulus_target(...).to_h)
69
78
 
70
- def as_stimulus_actions(...)
71
- to_data_attribute_string(**stimulus_actions(...))
72
- end
79
+ def as_stimulus_actions(...) = to_data_attribute_string(**stimulus_actions(...).to_h)
73
80
 
74
- def as_stimulus_action(...)
75
- to_data_attribute_string(**stimulus_action(...))
76
- end
81
+ def as_stimulus_action(...) = to_data_attribute_string(**stimulus_action(...).to_h)
77
82
 
78
- def as_stimulus_controllers(...)
79
- to_data_attribute_string(**stimulus_controllers(...))
80
- end
83
+ def as_stimulus_controllers(...) = to_data_attribute_string(**stimulus_controllers(...).to_h)
81
84
 
82
- def as_stimulus_controller(...)
83
- to_data_attribute_string(**stimulus_controller(...))
84
- end
85
+ def as_stimulus_controller(...) = to_data_attribute_string(**stimulus_controller(...).to_h)
85
86
 
86
- def as_stimulus_outlets(...)
87
- to_data_attribute_string(**stimulus_outlets(...))
88
- end
87
+ def as_stimulus_outlets(...) = to_data_attribute_string(**stimulus_outlets(...).to_h)
89
88
 
90
- def as_stimulus_outlet(...)
91
- to_data_attribute_string(**stimulus_outlet(...))
92
- end
89
+ def as_stimulus_outlet(...) = to_data_attribute_string(**stimulus_outlet(...).to_h)
93
90
 
94
- def as_stimulus_values(...)
95
- to_data_attribute_string(**stimulus_values(...))
96
- end
91
+ def as_stimulus_values(...) = to_data_attribute_string(**stimulus_values(...).to_h)
97
92
 
98
- def as_stimulus_value(...)
99
- to_data_attribute_string(**stimulus_value(...))
100
- end
93
+ def as_stimulus_value(...) = to_data_attribute_string(**stimulus_value(...).to_h)
101
94
 
102
- def as_stimulus_params(...)
103
- to_data_attribute_string(**stimulus_params(...))
104
- end
95
+ def as_stimulus_params(...) = to_data_attribute_string(**stimulus_params(...).to_h)
105
96
 
106
- def as_stimulus_param(...)
107
- to_data_attribute_string(**stimulus_param(...))
108
- end
97
+ def as_stimulus_param(...) = to_data_attribute_string(**stimulus_param(...).to_h)
109
98
 
110
- def as_stimulus_classes(...)
111
- to_data_attribute_string(**stimulus_classes(...))
112
- end
99
+ def as_stimulus_classes(...) = to_data_attribute_string(**stimulus_classes(...).to_h)
113
100
 
114
- def as_stimulus_class(...)
115
- to_data_attribute_string(**stimulus_class(...))
116
- end
101
+ def as_stimulus_class(...) = to_data_attribute_string(**stimulus_class(...).to_h)
102
+
103
+ alias_method :as_target, :as_stimulus_target
104
+ alias_method :as_action, :as_stimulus_action
105
+ alias_method :as_controller, :as_stimulus_controller
106
+ alias_method :as_outlet, :as_stimulus_outlet
107
+ alias_method :as_value, :as_stimulus_value
108
+ alias_method :as_param, :as_stimulus_param
109
+ alias_method :as_class, :as_stimulus_class
117
110
 
118
111
  private
119
112
 
@@ -1,6 +1,7 @@
1
- require "vident/view_component/version"
1
+ # frozen_string_literal: true
2
+
3
+ require "view_component"
2
4
  require "vident/view_component/base"
3
- require "vident/view_component/engine" if defined?(Rails)
4
5
 
5
6
  module Vident
6
7
  module ViewComponent
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Entry point for the `vident-view_component` gem — loaded automatically by
4
+ # `Bundler.require` when `gem "vident-view_component"` is in the Gemfile.
5
+
6
+ require "view_component"
7
+ require "vident"
8
+ require "vident/view_component"
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.2
4
+ version: 2.0.1
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.2
58
+ version: 2.0.1
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.2
65
+ version: 2.0.1
66
66
  - !ruby/object:Gem::Dependency
67
67
  name: view_component
68
68
  requirement: !ruby/object:Gem::Requirement
@@ -93,10 +93,9 @@ files:
93
93
  - CHANGELOG.md
94
94
  - LICENSE.txt
95
95
  - README.md
96
+ - lib/vident-view_component.rb
96
97
  - lib/vident/view_component.rb
97
98
  - lib/vident/view_component/base.rb
98
- - lib/vident/view_component/engine.rb
99
- - lib/vident/view_component/version.rb
100
99
  homepage: https://github.com/stevegeek/vident
101
100
  licenses:
102
101
  - MIT
@@ -1,17 +0,0 @@
1
- module Vident
2
- module ViewComponent
3
- class Engine < ::Rails::Engine
4
- lib_path = File.expand_path("../../../../lib/", __FILE__)
5
- config.autoload_paths << lib_path
6
- config.eager_load_paths << lib_path
7
-
8
- config.before_initialize do
9
- Rails.autoloaders.each do |autoloader|
10
- autoloader.inflector.inflect(
11
- "version" => "VERSION"
12
- )
13
- end
14
- end
15
- end
16
- end
17
- end
@@ -1,5 +0,0 @@
1
- module Vident
2
- module ViewComponent
3
- VERSION = Vident::VERSION
4
- end
5
- end