Class: Primer::Forms::Dsl::TextFieldInput
  
  
  
  
  
    - Inherits:
 
    - 
      Input
      
        
          - Object
 
          
            - Input
 
          
            - Primer::Forms::Dsl::TextFieldInput
 
          
        
        show all
      
     
  
  
  
  
  
  
  
  
  
  
    - Defined in:
 
    - lib/primer/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
  #base_id, #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
37
38 
     | 
    
      # File 'lib/primer/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)
  if @leading_visual
    @leading_visual[:classes] = class_names(
      "FormControl-input-leadingVisual",
      @leading_visual[:classes]
    )
  end
  super(**system_arguments)
  add_input_data(:target, "primer-text-field.inputElement #{system_arguments.dig(:data, :target) || ''}")
  add_input_classes("FormControl-inset") if inset?
  add_input_classes("FormControl-monospace") if monospace?
end
     | 
  
 
  
 
  
    Instance Method Details
    
      
  
  
    #focusable?  ⇒ Boolean 
  
  
  
  
    
      
52
53
54 
     | 
    
      # File 'lib/primer/forms/dsl/text_field_input.rb', line 52
def focusable?
  true
end 
     | 
  
 
    
      
  
  
    #leading_visual?  ⇒ Boolean 
  
  
  
  
    
      
56
57
58 
     | 
    
      # File 'lib/primer/forms/dsl/text_field_input.rb', line 56
def leading_visual?
  !!@leading_visual
end 
     | 
  
 
    
      
  
  
    #to_component  ⇒ Object 
  
  
  
  
    
      
44
45
46 
     | 
    
      # File 'lib/primer/forms/dsl/text_field_input.rb', line 44
def to_component
  TextField.new(input: self)
end 
     | 
  
 
    
      
  
  
    #type  ⇒ Object 
  
  
  
  
    
      
48
49
50 
     | 
    
      # File 'lib/primer/forms/dsl/text_field_input.rb', line 48
def type
  :text_field
end 
     | 
  
 
    
      
  
  
    #validation_arguments  ⇒ Object 
  
  
  
  
    
      
60
61
62
63
64
65
66
67
68
69
70 
     | 
    
      # File 'lib/primer/forms/dsl/text_field_input.rb', line 60
def validation_arguments
  if auto_check_src.present?
    super.merge(
      data: {
        target: "primer-text-field.validationElement"
      }
    )
  else
    super
  end
end
     | 
  
 
    
      
  
  
    #validation_error_icon_target  ⇒ Object 
  
  
  
  
    
      
76
77
78 
     | 
    
      # File 'lib/primer/forms/dsl/text_field_input.rb', line 76
def validation_error_icon_target
  "primer-text-field.validationErrorIcon"
end 
     | 
  
 
    
      
  
  
    #validation_message_arguments  ⇒ Object 
  
  
  
  
    
      
80
81
82
83
84
85
86
87
88
89
90 
     | 
    
      # File 'lib/primer/forms/dsl/text_field_input.rb', line 80
def validation_message_arguments
  if auto_check_src.present?
    super.merge(
      data: {
        target: "primer-text-field.validationMessageElement"
      }
    )
  else
    super
  end
end
     | 
  
 
    
      
  
  
    #validation_success_icon_target  ⇒ Object 
  
  
  
  
    
      
72
73
74 
     | 
    
      # File 'lib/primer/forms/dsl/text_field_input.rb', line 72
def validation_success_icon_target
  "primer-text-field.validationSuccessIcon"
end 
     |