Class: Fluxbit::Form::TextFieldComponent
- Inherits:
-
FieldComponent
- Object
- FieldComponent
- Fluxbit::Form::TextFieldComponent
- Includes:
- Config::Form::TextFieldComponent
- Defined in:
- app/components/fluxbit/form/text_field_component.rb
Overview
The ‘Fluxbit::Form::TextFieldComponent` is a form input component that extends `Fluxbit::Form::FieldComponent`. It provides a styled text input (or textarea) with support for various HTML input types, optional icons or add-on content, and color-coded validation states (e.g. default, success, error).
Direct Known Subclasses
Constant Summary collapse
- TYPE_DEFAULT =
:text- TYPE_OPTIONS =
%i[text textarea text_area color number email password search tel url date datetime_local month time week currency]
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(**props) ⇒ TextFieldComponent
constructor
Initializes the text field component with the given properties.
Constructor Details
#initialize(**props) ⇒ TextFieldComponent
Initializes the text field component with the given properties.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/components/fluxbit/form/text_field_component.rb', line 42 def initialize(**props) super(**props) @color = valid_color(@props.delete(:color)) @type = (@props.delete(:type), collection: TYPE_OPTIONS, default: TYPE_DEFAULT) @icon = @props.delete(:icon) @multiline = (@props.delete(:multiline), default: false) @shadow = @props.delete(:shadow) @addon = @props.delete(:addon) @right_icon = @props.delete(:right_icon) @addon_props = @props.delete(:addon_props) || {} @div_props = @props.delete(:div_props) || {} @icon_props = @props.delete(:icon_props) || {} @right_icon_props = @props.delete(:right_icon_props) || {} @sizing = sizing_with_addon @props.delete(:sizing) @props[:type] = @type declare_classes @props[:class] = remove_class(@props.delete(:remove_class) || "", @props[:class]) end |
Instance Method Details
#call ⇒ Object
62 63 64 65 66 |
# File 'app/components/fluxbit/form/text_field_component.rb', line 62 def call content_tag :div, **@wrapper_html do safe_join [ label, icon_container, help_text ] end end |