Class: Primer::Forms::Dsl::TextFieldInput
- Defined in:
- lib/primer/forms/dsl/text_field_input.rb
Overview
:nodoc:
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, #ids, #input_arguments, #label_arguments, #validation_message
Instance Method Summary collapse
- #focusable? ⇒ Boolean
-
#initialize(name:, label:, **system_arguments) ⇒ TextFieldInput
constructor
A new instance of TextFieldInput.
- #leading_visual? ⇒ Boolean
- #to_component ⇒ Object
- #type ⇒ Object
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
Methods included from ClassNameHelper
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 37 38 39 40 41 |
# File 'lib/primer/forms/dsl/text_field_input.rb', line 15 def initialize(name:, label:, **system_arguments) @name = name @label = label = system_arguments.delete(:show_clear_button) @leading_visual = system_arguments.delete(:leading_visual) = system_arguments.delete(:clear_button_id) @inset = system_arguments.delete(:inset) @monospace = system_arguments.delete(:monospace) super(**system_arguments) add_input_classes( "FormControl-input", Primer::Forms::Dsl::Input::SIZE_MAPPINGS[size] ) add_input_classes("FormControl-inset") if inset? add_input_classes("FormControl-monospace") if monospace? @field_wrap_classes = class_names( "FormControl-input-wrap", Primer::Forms::Dsl::Input::SIZE_MAPPINGS[size], "FormControl-input-wrap--trailingAction": , "FormControl-input-wrap--leadingVisual": leading_visual? ) end |
Instance Method Details
#focusable? ⇒ Boolean
55 56 57 |
# File 'lib/primer/forms/dsl/text_field_input.rb', line 55 def focusable? true end |
#leading_visual? ⇒ Boolean
59 60 61 |
# File 'lib/primer/forms/dsl/text_field_input.rb', line 59 def leading_visual? !!@leading_visual end |
#to_component ⇒ Object
47 48 49 |
# File 'lib/primer/forms/dsl/text_field_input.rb', line 47 def to_component TextField.new(input: self) end |
#type ⇒ Object
51 52 53 |
# File 'lib/primer/forms/dsl/text_field_input.rb', line 51 def type :text_field end |