Module: UI::InputGroupTextareaBehavior

Included in:
InputGroupTextarea, InputGroupTextareaComponent
Defined in:
app/helpers/ui/input_group_textarea_behavior.rb,
app/behaviors/ui/input_group_textarea_behavior.rb

Overview

UI::InputGroupTextareaBehavior

Instance Method Summary collapse

Instance Method Details

#input_group_textarea_attributesObject

Returns attributes to pass to the textarea component



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/helpers/ui/input_group_textarea_behavior.rb', line 14

def input_group_textarea_attributes
  attributes_value = respond_to?(:attributes, true) ? attributes : @attributes
  # Merge data-slot to override the default textarea slot with "input-group-control"
  # For Phlex: merge at top level, for ERB/VC: merge inside attributes hash
  data_slot_override = {data: {slot: "input-group-control"}}

  # Merge the data-slot both at top level (for Phlex) and in attributes (for ERB/VC)
  merged_attrs = attributes_value.deep_merge(data_slot_override)

  {
    placeholder: @placeholder,
    value: @value,
    name: @name,
    id: @id,
    rows: @rows,
    classes: input_group_textarea_classes,
    attributes: merged_attrs
  }.compact.merge(data_slot_override)
end

#input_group_textarea_classesObject

Returns combined CSS classes for the textarea



35
36
37
38
39
40
41
42
# File 'app/helpers/ui/input_group_textarea_behavior.rb', line 35

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

  ].compact.join(" "))
end

#input_group_textarea_html_attributesObject

Returns HTML attributes for the input group textarea



9
10
11
# File 'app/helpers/ui/input_group_textarea_behavior.rb', line 9

def input_group_textarea_html_attributes
  input_group_textarea_attributes
end