Class: Voom::Presenters::DSL::Components::TextField
- Defined in:
- lib/voom/presenters/dsl/components/text_field.rb
Direct Known Subclasses
Constant Summary collapse
- VALID_CASE_TYPES =
%i[mixed upper lower].freeze
Instance Attribute Summary collapse
-
#auto_complete ⇒ Object
readonly
Returns the value of attribute auto_complete.
-
#behavior ⇒ Object
readonly
Returns the value of attribute behavior.
-
#case_type ⇒ Object
readonly
Returns the value of attribute case_type.
-
#full_width ⇒ Object
readonly
Returns the value of attribute full_width.
-
#required ⇒ Object
readonly
Returns the value of attribute required.
Attributes inherited from Input
Attributes inherited from EventBase
Attributes included from Mixins::Event
Attributes inherited from Base
#attributes, #css_class, #draggable, #drop_zone, #id, #tag, #type
Instance Method Summary collapse
- #hint(hint = nil) ⇒ Object
- #icon(icon = nil, **attribs, &block) ⇒ Object
-
#initialize(**attribs_, &block) ⇒ TextField
constructor
A new instance of TextField.
- #label(text = nil) ⇒ Object
- #pattern(pattern = nil) ⇒ Object
- #value(value = nil) ⇒ Object
Methods inherited from Input
Methods included from Mixins::Tooltips
Methods included from Mixins::Event
Methods inherited from Base
Methods included from Pluggable
#include_plugins, #plugin, #plugin_module
Methods included from Mixins::YieldTo
Methods included from Serializer
Methods included from Lockable
Constructor Details
#initialize(**attribs_, &block) ⇒ TextField
Returns a new instance of TextField.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/voom/presenters/dsl/components/text_field.rb', line 15 def initialize(**attribs_, &block) super(type: :text_field, **attribs_, &block) @required = attribs.delete(:required){ false } @full_width = attribs.delete(:full_width){ true } @case_type = validate_case_type(attribs.delete(:case_type) { :mixed }) @auto_complete = validate_auto_complete(attribs.delete(:auto_complete) { :off }) @behavior = determine_behavior(attribs.delete(:password), attribs.delete(:behavior)) label(attribs.delete(:label))if attribs.key?(:label) value(attribs.delete(:value))if attribs.key?(:value) end |
Instance Attribute Details
#auto_complete ⇒ Object (readonly)
Returns the value of attribute auto_complete.
7 8 9 |
# File 'lib/voom/presenters/dsl/components/text_field.rb', line 7 def auto_complete @auto_complete end |
#behavior ⇒ Object (readonly)
Returns the value of attribute behavior.
7 8 9 |
# File 'lib/voom/presenters/dsl/components/text_field.rb', line 7 def behavior @behavior end |
#case_type ⇒ Object (readonly)
Returns the value of attribute case_type.
7 8 9 |
# File 'lib/voom/presenters/dsl/components/text_field.rb', line 7 def case_type @case_type end |
#full_width ⇒ Object (readonly)
Returns the value of attribute full_width.
7 8 9 |
# File 'lib/voom/presenters/dsl/components/text_field.rb', line 7 def full_width @full_width end |
#required ⇒ Object (readonly)
Returns the value of attribute required.
7 8 9 |
# File 'lib/voom/presenters/dsl/components/text_field.rb', line 7 def required @required end |
Instance Method Details
#hint(hint = nil) ⇒ Object
48 49 50 51 |
# File 'lib/voom/presenters/dsl/components/text_field.rb', line 48 def hint(hint=nil) return @hint if locked? @hint = hint end |
#icon(icon = nil, **attribs, &block) ⇒ Object
32 33 34 35 36 |
# File 'lib/voom/presenters/dsl/components/text_field.rb', line 32 def icon(icon=nil, **attribs, &block) return @icon if locked? @icon = Components::Icon.new(parent: self, icon: icon, position: attribs.delete(:position){:right}, **attribs, &block) end |
#label(text = nil) ⇒ Object
27 28 29 30 |
# File 'lib/voom/presenters/dsl/components/text_field.rb', line 27 def label(text=nil) return @label if locked? @label = text end |
#pattern(pattern = nil) ⇒ Object
43 44 45 46 |
# File 'lib/voom/presenters/dsl/components/text_field.rb', line 43 def pattern(pattern=nil) return @pattern if locked? @pattern = json_regexp(Regexp.new(pattern)) end |
#value(value = nil) ⇒ Object
38 39 40 41 |
# File 'lib/voom/presenters/dsl/components/text_field.rb', line 38 def value(value=nil) return @value if locked? @value = value end |