Module: UI::SelectBehavior
- Included in:
- Select, SelectComponent
- Defined in:
- app/helpers/ui/select_behavior.rb,
app/behaviors/ui/select_behavior.rb
Overview
UI::SelectBehavior
Shared behavior for Select component across ERB, ViewComponent, and Phlex implementations. This module provides consistent size styling and HTML attribute generation.
Instance Method Summary collapse
-
#select_classes ⇒ Object
Returns combined CSS classes for the select.
-
#select_html_attributes ⇒ Object
Returns HTML attributes for the select element.
Instance Method Details
#select_classes ⇒ Object
Returns combined CSS classes for the select
34 35 36 37 38 39 40 41 |
# File 'app/helpers/ui/select_behavior.rb', line 34 def select_classes classes_value = respond_to?(:classes, true) ? classes : @classes TailwindMerge::Merger.new.merge([ select_base_classes, select_size_classes, classes_value ].compact.join(" ")) end |
#select_html_attributes ⇒ Object
Returns HTML attributes for the select element
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/helpers/ui/select_behavior.rb', line 9 def select_html_attributes data_attrs = { controller: "ui--select", ui__select_open_value: "false" } # Add value if provided if @value.present? data_attrs[:ui__select_value_value] = @value.to_s end attrs = { class: select_classes, data: data_attrs } # Add data-placeholder attribute if there's a placeholder and no selected value if @placeholder.present? && @selected.nil? attrs[:"data-placeholder"] = "true" end attrs.compact end |