Module: UI::SelectTriggerBehavior

Included in:
SelectTrigger, SelectTriggerComponent
Defined in:
app/helpers/ui/select_trigger_behavior.rb,
app/behaviors/ui/select_trigger_behavior.rb

Overview

UI::SelectTriggerBehavior

Shared behavior for Select trigger button across ERB, ViewComponent, and Phlex implementations. This module provides consistent HTML attribute generation and styling.

Instance Method Summary collapse

Instance Method Details

#select_trigger_classesObject

Returns combined CSS classes



26
27
28
29
30
31
32
# File 'app/helpers/ui/select_trigger_behavior.rb', line 26

def select_trigger_classes
  classes_value = respond_to?(:classes, true) ? classes : @classes
  TailwindMerge::Merger.new.merge([
    select_trigger_base_classes,
    classes_value
  ].compact.join(" "))
end

#select_trigger_html_attributesObject

Returns HTML attributes for the select trigger element



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/helpers/ui/select_trigger_behavior.rb', line 9

def select_trigger_html_attributes
  attributes_value = respond_to?(:attributes, true) ? attributes : @attributes
  {
    type: "button",
    role: "combobox",
    "aria-expanded": "false",
    "aria-haspopup": "listbox",
    class: select_trigger_classes,
    data: {
      ui__select_target: "trigger",
      action: "click->ui--select#toggle",
      slot: "select-trigger"
    }
  }.merge(attributes_value || {})
end