Class: Ariadne::Forms::Dsl::TextFieldInput
- Defined in:
- lib/ariadne/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 collapse
-
#auto_check_src ⇒ Object
readonly
Returns the value of attribute auto_check_src.
-
#clear_button_id ⇒ Object
readonly
Returns the value of attribute clear_button_id.
-
#field_wrap_classes ⇒ Object
readonly
Returns the value of attribute field_wrap_classes.
-
#inset ⇒ Object
readonly
Returns the value of attribute inset.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#leading_visual ⇒ Object
readonly
Returns the value of attribute leading_visual.
-
#monospace ⇒ Object
readonly
Returns the value of attribute monospace.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#show_clear_button ⇒ Object
readonly
Returns the value of attribute show_clear_button.
-
#visually_hide_label ⇒ Object
readonly
Returns the value of attribute visually_hide_label.
Attributes inherited from Input
#base_id, #builder, #caption, #form, #form_control, #ids, #input_attributes, #label_attributes, #validation_message
Instance Method Summary collapse
- #focusable? ⇒ Boolean
-
#initialize(name:, label:, **options) ⇒ TextFieldInput
constructor
A new instance of TextFieldInput.
- #to_component ⇒ Object
- #type ⇒ Object
- #validation_arguments ⇒ Object
- #validation_error_icon_target ⇒ Object
- #validation_message_arguments ⇒ Object
- #validation_success_icon_target ⇒ Object
Methods inherited from Input
#add_input_aria, #add_input_classes, #add_input_data, #autofocus!, #caption?, #caption_id, #caption_template?, #disabled?, #hidden?, #id, #input?, #invalid?, #merge_input_attributes!, #remove_input_data, #render_caption_template, #required?, #size, #supports_validation?, #valid?, #validation_id, #validation_messages
Methods included from ClassNameHelper
Constructor Details
#initialize(name:, label:, **options) ⇒ TextFieldInput
Returns a new instance of TextFieldInput.
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ariadne/forms/dsl/text_field_input.rb', line 12 def initialize(name:, label:, **) @name = name @label = label @show_clear_button = .delete(:show_clear_button) @inset = .delete(:inset) @monospace = .delete(:monospace) @auto_check_src = .delete(:auto_check_src) super(**) add_input_data(:target, "ariadne-text-field.inputElement #{@input_attributes.dig(:data, :target) || ""}".rstrip) end |
Instance Attribute Details
#auto_check_src ⇒ Object (readonly)
Returns the value of attribute auto_check_src.
8 9 10 |
# File 'lib/ariadne/forms/dsl/text_field_input.rb', line 8 def auto_check_src @auto_check_src end |
#clear_button_id ⇒ Object (readonly)
Returns the value of attribute clear_button_id.
8 9 10 |
# File 'lib/ariadne/forms/dsl/text_field_input.rb', line 8 def @clear_button_id end |
#field_wrap_classes ⇒ Object (readonly)
Returns the value of attribute field_wrap_classes.
8 9 10 |
# File 'lib/ariadne/forms/dsl/text_field_input.rb', line 8 def field_wrap_classes @field_wrap_classes end |
#inset ⇒ Object (readonly)
Returns the value of attribute inset.
8 9 10 |
# File 'lib/ariadne/forms/dsl/text_field_input.rb', line 8 def inset @inset end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
8 9 10 |
# File 'lib/ariadne/forms/dsl/text_field_input.rb', line 8 def label @label end |
#leading_visual ⇒ Object (readonly)
Returns the value of attribute leading_visual.
8 9 10 |
# File 'lib/ariadne/forms/dsl/text_field_input.rb', line 8 def leading_visual @leading_visual end |
#monospace ⇒ Object (readonly)
Returns the value of attribute monospace.
8 9 10 |
# File 'lib/ariadne/forms/dsl/text_field_input.rb', line 8 def monospace @monospace end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/ariadne/forms/dsl/text_field_input.rb', line 8 def name @name end |
#show_clear_button ⇒ Object (readonly)
Returns the value of attribute show_clear_button.
8 9 10 |
# File 'lib/ariadne/forms/dsl/text_field_input.rb', line 8 def @show_clear_button end |
#visually_hide_label ⇒ Object (readonly)
Returns the value of attribute visually_hide_label.
8 9 10 |
# File 'lib/ariadne/forms/dsl/text_field_input.rb', line 8 def visually_hide_label @visually_hide_label end |
Instance Method Details
#focusable? ⇒ Boolean
41 42 43 |
# File 'lib/ariadne/forms/dsl/text_field_input.rb', line 41 def focusable? true end |
#to_component ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ariadne/forms/dsl/text_field_input.rb', line 26 def to_component html_attrs = @input_attributes || {} html_attrs[:placeholder] = @placeholder if @placeholder.present? html_attrs[:disabled] = true if @disabled leading_visual_heroicon = @options.delete(:leading_visual_heroicon) text = Ariadne::Form::TextField::Component.new(name: @name, label: @label, caption: @caption, html_attrs: html_attrs, **@options) text.with_leading_visual_heroicon(**leading_visual_heroicon) if leading_visual_heroicon.present? text end |
#type ⇒ Object
37 38 39 |
# File 'lib/ariadne/forms/dsl/text_field_input.rb', line 37 def type :text_field end |
#validation_arguments ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ariadne/forms/dsl/text_field_input.rb', line 45 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
61 62 63 |
# File 'lib/ariadne/forms/dsl/text_field_input.rb', line 61 def validation_error_icon_target "primer-text-field.validationErrorIcon" end |
#validation_message_arguments ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/ariadne/forms/dsl/text_field_input.rb', line 65 def if auto_check_src.present? super.merge( data: { target: "primer-text-field.validationMessageElement", }, ) else super end end |
#validation_success_icon_target ⇒ Object
57 58 59 |
# File 'lib/ariadne/forms/dsl/text_field_input.rb', line 57 def validation_success_icon_target "primer-text-field.validationSuccessIcon" end |