Module: UI::RadioButtonBehavior

Included in:
RadioButton, RadioButtonComponent
Defined in:
app/behaviors/ui/radio_button_behavior.rb

Overview

UI::RadioButtonBehavior

Instance Method Summary collapse

Instance Method Details

#radio_button_classesObject



37
38
39
40
41
42
43
44
# File 'app/behaviors/ui/radio_button_behavior.rb', line 37

def radio_button_classes
  classes_value = respond_to?(:classes, true) ? classes : @classes
  TailwindMerge::Merger.new.merge([
    radio_button_base_classes,
    classes_value

  ].compact.join(" "))
end

#radio_button_data_attributesObject



46
47
48
49
50
# File 'app/behaviors/ui/radio_button_behavior.rb', line 46

def radio_button_data_attributes
  {
    slot: "radio-group-item"
  }
end

#radio_button_html_attributesObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/behaviors/ui/radio_button_behavior.rb', line 22

def radio_button_html_attributes
  attributes_value = respond_to?(:attributes, true) ? attributes : @attributes
  {
    type: "radio",
    class: radio_button_classes,
    name: @name,
    id: radio_button_id,
    value: @value,
    checked: (@checked ? true : nil),
    disabled: (@disabled ? true : nil),
    required: (@required ? true : nil),
    data: radio_button_data_attributes
  }.merge(attributes_value).compact
end

#radio_button_idObject



52
53
54
# File 'app/behaviors/ui/radio_button_behavior.rb', line 52

def radio_button_id
  @id || "radio-#{SecureRandom.hex(4)}"
end