Class: UI::SelectGroup
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- UI::SelectGroup
- Includes:
- SelectGroupBehavior, SharedAsChildBehavior
- Defined in:
- app/components/ui/select_group.rb
Overview
Select Group - Phlex implementation
Container for grouping select items with a label. Supports asChild pattern for composition.
Instance Method Summary collapse
-
#initialize(as_child: false, classes: "", **attributes) ⇒ SelectGroup
constructor
A new instance of SelectGroup.
- #view_template(&block) ⇒ Object
Methods included from SharedAsChildBehavior
Methods included from SelectGroupBehavior
#select_group_classes, #select_group_html_attributes
Constructor Details
#initialize(as_child: false, classes: "", **attributes) ⇒ SelectGroup
Returns a new instance of SelectGroup.
21 22 23 24 25 |
# File 'app/components/ui/select_group.rb', line 21 def initialize(as_child: false, classes: "", **attributes) @as_child = as_child @classes = classes @attributes = attributes end |
Instance Method Details
#view_template(&block) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/components/ui/select_group.rb', line 27 def view_template(&block) group_attrs = select_group_html_attributes.deep_merge(@attributes) if @as_child # asChild mode: yield attributes to block yield(group_attrs) if block_given? else # Default mode: render as div div(**group_attrs, &block) end end |