Class: Yattho::Forms::Dsl::TextFieldInput
- Inherits:
-
Input
- Object
- Input
- Yattho::Forms::Dsl::TextFieldInput
show all
- Defined in:
- lib/yattho/forms/dsl/text_field_input.rb
Overview
Constant Summary
Constants inherited
from Input
Input::DEFAULT_SIZE, Input::SIZE_MAPPINGS, Input::SIZE_OPTIONS, Input::SPACE_DELIMITED_ARIA_ATTRIBUTES
Instance Attribute Summary
Attributes inherited from Input
#builder, #caption, #form, #form_control, #ids, #input_arguments, #label_arguments, #validation_message
Instance Method Summary
collapse
Methods inherited from Input
#add_input_aria, #add_input_classes, #add_input_data, #add_label_classes, #autofocus!, #caption?, #caption_id, #caption_template?, #disabled?, #full_width?, #hidden?, #input?, #invalid?, #label, #merge_input_arguments!, #name, #remove_input_data, #render_caption_template, #required?, #size, #valid?, #validation_id, #validation_messages
#class_names
Constructor Details
#initialize(name:, label:, **system_arguments) ⇒ TextFieldInput
Returns a new instance of TextFieldInput.
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/yattho/forms/dsl/text_field_input.rb', line 15
def initialize(name:, label:, **system_arguments)
@name = name
@label = label
@show_clear_button = system_arguments.delete(:show_clear_button)
@leading_visual = system_arguments.delete(:leading_visual)
@clear_button_id = system_arguments.delete(:clear_button_id)
@inset = system_arguments.delete(:inset)
@monospace = system_arguments.delete(:monospace)
@auto_check_src = system_arguments.delete(:auto_check_src)
super(**system_arguments)
add_input_classes(
"FormControl-input",
Yattho::Forms::Dsl::Input::SIZE_MAPPINGS[size]
)
add_input_data(:target, "yattho-text-field.inputElement") if auto_check_src.present?
add_input_classes("FormControl-inset") if inset?
add_input_classes("FormControl-monospace") if monospace?
end
|
Instance Method Details
#focusable? ⇒ Boolean
50
51
52
|
# File 'lib/yattho/forms/dsl/text_field_input.rb', line 50
def focusable?
true
end
|
#leading_visual? ⇒ Boolean
54
55
56
|
# File 'lib/yattho/forms/dsl/text_field_input.rb', line 54
def leading_visual?
!!@leading_visual
end
|
#need_validation_element? ⇒ Boolean
58
59
60
|
# File 'lib/yattho/forms/dsl/text_field_input.rb', line 58
def need_validation_element?
super || auto_check_src.present?
end
|
#to_component ⇒ Object
42
43
44
|
# File 'lib/yattho/forms/dsl/text_field_input.rb', line 42
def to_component
TextField.new(input: self)
end
|
#type ⇒ Object
46
47
48
|
# File 'lib/yattho/forms/dsl/text_field_input.rb', line 46
def type
:text_field
end
|
#validation_arguments ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/yattho/forms/dsl/text_field_input.rb', line 62
def validation_arguments
if auto_check_src.present?
super.merge(
data: {
target: "yattho-text-field.validationElement"
}
)
else
super
end
end
|
#validation_message_arguments ⇒ Object
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/yattho/forms/dsl/text_field_input.rb', line 74
def validation_message_arguments
if auto_check_src.present?
super.merge(
data: {
target: "yattho-text-field.validationMessageElement"
}
)
else
super
end
end
|