vident-phlex 1.0.2 → 2.0.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: 685f521dd022b3123897a08683295cb84787192a4aabecbd3927843a43d6c668
4
- data.tar.gz: d25cfb1546470d6736b869d0ed54f310fef6e72dc9ed3018265bb4869dddd713
3
+ metadata.gz: 6fd97e08c66d8473338aded609cf45f63d982dddc72e376a598218a5224139c5
4
+ data.tar.gz: 15db0bb5c243e378327792710e491b49c93ab185a0286730e1420d8eae0de2e0
5
5
  SHA512:
6
- metadata.gz: 16be0de4f984e20dc00184a79af7eb3519713c0bee72cae4e7d768434d77cfd6c4aef1241c71a15008634f47b4016b3ec40d7df216f3980880eb261802953e5e
7
- data.tar.gz: 13a4a6bfdde8e2f998a46af8cc5084cc5acc388489cbb46784db850b2c346244e3c726acb150eba7639abec0d6e73d1e7e7a5effd33cc80426eecd255d8d9682
6
+ metadata.gz: e53d2df34d5720dbd801139e0326bc2837b6af70d4a6ef6a3bbe6b718c8021275931a5adae8b1ce409063aec68c9f286af5aa1ba434e91ca97dc812331506f73
7
+ data.tar.gz: 4ea8a5f6707e92a0340bb8f409d33533eac3cd509e4e4f0e108218d303cbb077e3965ec551c8f0f9a8bcfd4fd73e817b98f336923e02258aaf5d452507b242ba
data/CHANGELOG.md CHANGED
@@ -6,6 +6,49 @@ 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.0] - 2026-04-24
10
+
11
+ 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.
12
+
13
+ ### Breaking
14
+
15
+ - **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.
16
+ - **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.
17
+ - **`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]`.
18
+ - **`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.
19
+ - **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.
20
+ - **`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."
21
+ - **`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.
22
+ - **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.
23
+
24
+ ### Added
25
+
26
+ - **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`.
27
+ - **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`.
28
+ - **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.
29
+ - **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.
30
+ - **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.
31
+ - **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.
32
+ - **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.
33
+ - `has_stimulus_controller` class method re-enables the implied controller in a subclass after a parent declared `no_stimulus_controller` (#27).
34
+ - `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).
35
+ - Class-level Stimulus builders — `MyComponent.stimulus_target(:x)` etc. — return value objects without a component instance (#18).
36
+ - `Vident::Types::*` — seven named Literal unions for the built-in `stimulus_*:` prop types, reusable from user components (#16).
37
+ - `cache_component(*keys, **options, &block)` on both adapter base classes — fragment-caches the block using the Vident-computed `cache_key` (#13).
38
+ - 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).
39
+
40
+ ### Fixed
41
+
42
+ - `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).
43
+ - Outlet DSL procs now resolve instead of being treated as identity strings (see Breaking).
44
+ - `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.
45
+
46
+ ### Removed
47
+
48
+ - `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.
49
+ - 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.
50
+
51
+
9
52
  ## [1.0.2] - 2026-04-21
10
53
 
11
54
  ### 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,83 +1,86 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "set"
4
+
3
5
  module Vident
4
6
  module Phlex
5
7
  class HTML < ::Phlex::HTML
6
- include Vident::Component
8
+ include ::Vident::Component
7
9
 
8
- STANDARD_ELEMENTS = [:a, :abbr, :address, :article, :aside, :b, :bdi, :bdo, :blockquote, :body, :button, :caption, :cite, :code, :colgroup, :data, :datalist, :dd, :del, :details, :dfn, :dialog, :div, :dl, :dt, :em, :fieldset, :figcaption, :figure, :footer, :form, :g, :h1, :h2, :h3, :h4, :h5, :h6, :head, :header, :hgroup, :html, :i, :iframe, :ins, :kbd, :label, :legend, :li, :main, :map, :mark, :menuitem, :meter, :nav, :noscript, :object, :ol, :optgroup, :option, :output, :p, :path, :picture, :pre, :progress, :q, :rp, :rt, :ruby, :s, :samp, :script, :section, :select, :slot, :small, :span, :strong, :style, :sub, :summary, :sup, :svg, :table, :tbody, :td, :template_tag, :textarea, :tfoot, :th, :thead, :time, :title, :tr, :u, :ul, :video, :wbr].freeze
9
- VOID_ELEMENTS = [:area, :br, :embed, :hr, :img, :input, :link, :meta, :param, :source, :track, :col].freeze
10
+ STANDARD_ELEMENTS = %i[
11
+ a abbr address article aside b bdi bdo blockquote body button caption
12
+ cite code colgroup data datalist dd del details dfn dialog div dl dt
13
+ em fieldset figcaption figure footer form g h1 h2 h3 h4 h5 h6 head
14
+ header hgroup html i iframe ins kbd label legend li main map mark
15
+ menuitem meter nav noscript object ol optgroup option output p path
16
+ picture pre progress q rp rt ruby s samp script section select slot
17
+ small span strong style sub summary sup svg table tbody td template_tag
18
+ textarea tfoot th thead time title tr u ul video wbr
19
+ ].freeze
20
+ VOID_ELEMENTS = %i[area br embed hr img input link meta param source track col].freeze
10
21
  VALID_TAGS = Set[*(STANDARD_ELEMENTS + VOID_ELEMENTS)].freeze
11
22
 
12
23
  class << self
24
+ # Walks caller_locations to skip the `inherited` frame itself.
13
25
  def inherited(subclass)
14
- subclass.component_source_file_path = caller_locations(1, 10).reject { |l| l.label == "inherited" }[0].path
26
+ loc = caller_locations(1, 10).reject { |l| l.label == "inherited" }[0]
27
+ subclass.component_source_file_path = loc&.path
15
28
  super
16
29
  end
17
30
 
18
31
  attr_accessor :component_source_file_path
19
32
 
20
- # Caching support
21
33
  def cache_component_modified_time
22
34
  path = component_source_file_path
23
- raise StandardError, "No component source file exists #{path}" unless path && ::File.exist?(path)
35
+ raise ::Vident::ConfigurationError, "No component source file exists #{path}" unless path && ::File.exist?(path)
24
36
  ::File.mtime(path).to_i.to_s
25
37
  end
38
+ end
39
+
40
+ # DSL procs stay unresolved until `helpers` is wired; resolve them here.
41
+ def before_template
42
+ resolve_stimulus_attributes_at_render_time
43
+ super
44
+ end
26
45
 
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
46
+ # Fragment-cache this component's render using its Vident-computed
47
+ # `cache_key`. Delegates to Phlex's `cache(...)`; pass extra positional
48
+ # keys to invalidate on state not captured by `with_cache_key`.
49
+ def cache_component(*extra_keys, **options, &block)
50
+ unless respond_to?(:cacheable?) && cacheable?
51
+ raise ::Vident::ConfigurationError,
52
+ "#{self.class.name} is not cacheable — `include Vident::Caching` and declare `with_cache_key` first."
44
53
  end
54
+ cache([cache_key, *extra_keys], **options, &block)
45
55
  end
46
56
 
47
- # Helper to create the main element
57
+ # Capture block first so children can mutate this Draft before it seals (outlet-host pattern).
48
58
  def root_element(**overrides, &block)
49
59
  tag_type = root_element_tag_type
50
60
  check_valid_html_tag!(tag_type)
51
- # Evaluate block first so DSL methods run before outer tag options are computed.
52
- if block_given?
61
+ if block
53
62
  content = capture(self, &block).html_safe
54
- options = resolve_root_element_attributes_before_render(overrides)
63
+ options = build_root_element_attributes(overrides)
55
64
  send(tag_type, **options) { content }
56
65
  else
57
- send(tag_type, **resolve_root_element_attributes_before_render(overrides))
66
+ options = build_root_element_attributes(overrides)
67
+ send(tag_type, **options)
58
68
  end
59
69
  end
60
70
 
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
-
68
71
  private
69
72
 
70
73
  def check_valid_html_tag!(tag_name)
71
- unless VALID_TAGS.include?(tag_name)
72
- raise ArgumentError, "Unsupported HTML tag name #{tag_name}. Valid tags are: #{VALID_TAGS.to_a.join(", ")}"
73
- end
74
+ return if VALID_TAGS.include?(tag_name)
75
+ raise ArgumentError,
76
+ "Unsupported HTML tag name #{tag_name}. Valid tags are: #{VALID_TAGS.to_a.join(", ")}"
74
77
  end
75
78
 
76
- def generate_child_element(tag_type, stimulus_data_attributes, options, &block)
79
+ def generate_child_element(tag_name, stimulus_data_attributes, options, &block)
80
+ check_valid_html_tag!(tag_name)
77
81
  options[:data] ||= {}
78
82
  options[:data].merge!(stimulus_data_attributes)
79
- check_valid_html_tag!(tag_type)
80
- send(tag_type, **options, &block)
83
+ send(tag_name, **options, &block)
81
84
  end
82
85
  end
83
86
  end
data/lib/vident/phlex.rb CHANGED
@@ -1,6 +1,7 @@
1
- require "vident/phlex/version"
1
+ # frozen_string_literal: true
2
+
3
+ require "phlex"
2
4
  require "vident/phlex/html"
3
- require "vident/phlex/engine" if defined?(Rails)
4
5
 
5
6
  module Vident
6
7
  module Phlex
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.2
4
+ version: 2.0.0
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.0
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.0
66
66
  - !ruby/object:Gem::Dependency
67
67
  name: phlex
68
68
  requirement: !ruby/object:Gem::Requirement
@@ -114,9 +114,7 @@ files:
114
114
  - LICENSE.txt
115
115
  - README.md
116
116
  - lib/vident/phlex.rb
117
- - lib/vident/phlex/engine.rb
118
117
  - lib/vident/phlex/html.rb
119
- - lib/vident/phlex/version.rb
120
118
  homepage: https://github.com/stevegeek/vident
121
119
  licenses:
122
120
  - MIT
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Vident
4
- module Phlex
5
- class Engine < ::Rails::Engine
6
- lib_path = File.expand_path("../../../../lib/", __FILE__)
7
- config.autoload_paths << lib_path
8
- config.eager_load_paths << lib_path
9
-
10
- config.before_initialize do
11
- Rails.autoloaders.each do |autoloader|
12
- autoloader.inflector.inflect(
13
- "html" => "HTML",
14
- "version" => "VERSION"
15
- )
16
- end
17
- end
18
- end
19
- end
20
- end
@@ -1,5 +0,0 @@
1
- module Vident
2
- module Phlex
3
- VERSION = Vident::VERSION
4
- end
5
- end