Class: UI::Select
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- UI::Select
- Includes:
- SelectBehavior
- Defined in:
- app/components/ui/select.rb
Overview
Select - Phlex 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
-
#initialize(value: nil, classes: "", as_child: false, **attributes) ⇒ Select
constructor
A new instance of Select.
- #view_template(&block) ⇒ Object
Methods included from SelectBehavior
#select_classes, #select_html_attributes
Constructor Details
#initialize(value: nil, classes: "", as_child: false, **attributes) ⇒ Select
Returns a new instance of Select.
34 35 36 37 38 39 |
# File 'app/components/ui/select.rb', line 34 def initialize(value: nil, classes: "", as_child: false, **attributes) @value = value @classes = classes @as_child = as_child @attributes = attributes end |
Instance Method Details
#view_template(&block) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/components/ui/select.rb', line 41 def view_template(&block) select_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 select_attrs[:class] = "contents" span(**select_attrs, &block) else div(**select_attrs, &block) end end |