Class: FoxTail::InputComponent

Inherits:
InputBaseComponent show all
Defined in:
app/components/fox_tail/input_component.rb

Direct Known Subclasses

PasswordInputComponent

Instance Attribute Summary

Attributes inherited from BaseComponent

#html_attributes

Instance Method Summary collapse

Methods inherited from InputBaseComponent

stimulus_controller_name, #stimulus_controller_options, #use_stimulus?

Methods inherited from BaseComponent

classname_merger, #initialize, stimulus_merger, use_stimulus?, #with_html_attributes, #with_html_class

Methods inherited from Base

fox_tail_config

Constructor Details

This class inherits a constructor from FoxTail::BaseComponent

Instance Method Details

#before_renderObject



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/components/fox_tail/input_component.rb', line 45

def before_render
  super

  html_attributes[:type] ||= :text
  html_attributes[:class] = classnames theme.apply(:root, self), html_class
  html_attributes[:value] ||= value_before_type_cast

  if html_attributes[:type] == :number
    format_range!
  elsif html_attributes[:type] == :submit
    format_submit!
  end
end

#callObject



59
60
61
62
63
64
65
66
67
68
69
# File 'app/components/fox_tail/input_component.rb', line 59

def call
  if visual?
     :div, class: theme.apply(:container, self) do
      concat render_visual :left, left_visual if left_visual?
      concat input_content
      concat render_visual :right, right_visual if right_visual?
    end
  else
    input_content
  end
end

#visual?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'app/components/fox_tail/input_component.rb', line 41

def visual?
  left_visual? || right_visual?
end