Class: Fluxbit::Form::TextInputComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/fluxbit/form/text_input_component.rb

Overview

form: The form to create a input element options:

size: :large, :base, :small,
label: nil | 'Label',
placeholder: nil | 'placeholder',
validators: [:required]
required: true | false | message,

Validators can be predefined or customized: [:required, :min_length, :max_length, :min_value, :max_value,

{ type: :regexp, regex: /dd/, success: '', failure: ''},

]

Instance Method Summary collapse

Constructor Details

#initialize(form: nil, field: nil, id: nil, shadow: false, type: "text", helper_text: nil, helper_popover: nil, helper_popover_placement: "right", icon: nil, right_icon: nil, addon: nil, color: nil, label: nil, sizing: :md, i18n: nil, options: [], validators: [], div_props: {}, icon_props: {}, right_icon_props: {}, addon_props: {}, **props) ⇒ TextInputComponent

rubocop: enable Layout/LineLength, Metrics/BlockLength



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'app/components/fluxbit/form/text_input_component.rb', line 90

def initialize(form: nil, field: nil, id: nil, shadow: false, type: "text", helper_text: nil,
               helper_popover: nil, helper_popover_placement: "right", icon: nil,
               right_icon: nil, addon: nil, color: nil, label: nil, sizing: :md, i18n: nil, options: [],
               validators: [], div_props: {}, icon_props: {}, right_icon_props: {}, addon_props: {}, **props)
  super
  @form = form
  @object = form&.object
  @field = field
  @id = id
  @shadow = shadow
  @type = valid_input_type(type)
  @helper_text = define_helper_text(helper_text, @object, field)
  @helper_popover = define_helper_popover(helper_popover, @object, field)
  @helper_popover_placement = helper_popover_placement
  @icon = icon
  @right_icon = right_icon
  @addon = addon
  @color = valid_color(color)
  @label = label_value(label, @object, field, id)
  @sizing = sizing_with_addon(sizing, addon)
  @validators = validators
  @props = props.merge(type: @type)
  @options = options
  @sizing = :md_addon if addon
  @div_props = div_props
  @icon_props = icon_props
  @right_icon_props = right_icon_props
  @addon_props = addon_props

  declare_classes
end

Instance Method Details

#callObject



122
123
124
# File 'app/components/fluxbit/form/text_input_component.rb', line 122

def call
  safe_join [ label, icon_container, helper_text ]
end