Class: UI::SelectComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- UI::SelectComponent
- Includes:
- SelectBehavior
- Defined in:
- app/view_components/ui/select_component.rb
Overview
SelectComponent - ViewComponent implementation
A custom select component with keyboard navigation, scrollable viewport, and form integration. Root container that wraps trigger, content, and items.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(value: nil, classes: "", as_child: false, **attributes) ⇒ SelectComponent
constructor
A new instance of SelectComponent.
Methods included from SelectBehavior
#select_classes, #select_html_attributes
Constructor Details
#initialize(value: nil, classes: "", as_child: false, **attributes) ⇒ SelectComponent
Returns a new instance of SelectComponent.
23 24 25 26 27 28 |
# File 'app/view_components/ui/select_component.rb', line 23 def initialize(value: nil, classes: "", as_child: false, **attributes) @value = value @classes = classes @as_child = as_child @attributes = attributes end |
Instance Method Details
#call ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/view_components/ui/select_component.rb', line 30 def call attrs = select_html_attributes.deep_merge(@attributes) if @as_child # When as_child, we still need a wrapper for the Stimulus controller # but we use a minimal inline wrapper that doesn't break flex layouts # Override class to use 'contents' which makes the element invisible to layout attrs[:class] = "contents" content_tag :span, content, **attrs else content_tag :div, content, **attrs end end |