Module: UI::InputGroupInputBehavior

Included in:
InputGroupInput, InputGroupInputComponent
Defined in:
app/helpers/ui/input_group_input_behavior.rb,
app/behaviors/ui/input_group_input_behavior.rb

Overview

UI::InputGroupInputBehavior

Shared behavior for InputGroupInput component across ERB, ViewComponent, and Phlex implementations. This module provides consistent styling and HTML attribute generation for input group inputs.

Instance Method Summary collapse

Instance Method Details

#input_group_input_attributesObject

Returns attributes to pass to the input 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_input_behavior.rb', line 14

def input_group_input_attributes
  attributes_value = respond_to?(:attributes, true) ? attributes : @attributes
  # Merge data-slot to override the default "input" 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)

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

#input_group_input_classesObject

Returns combined CSS classes for the input



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

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

  ].compact.join(" "))
end

#input_group_input_html_attributesObject

Returns HTML attributes for the input group input



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

def input_group_input_html_attributes
  input_group_input_attributes
end