Sha256: 77e4f9fafeb130c9071b45b0e3f2e116eff0aa365c2d4c431e2f2e2d9ba62b5e
Contents?: true
Size: 2 KB
Versions: 37
Compression:
Stored size: 2 KB
Contents
# frozen_string_literal: true module Ariadne module Forms module Dsl # :nodoc: class TextFieldInput < Input attr_reader( :name, :label, :show_clear_button, :leading_visual, :clear_button_id, :visually_hide_label, :inset, :monospace, :field_wrap_classes, :auto_check_src ) def initialize(name:, label:, **options) @name = name @label = label @show_clear_button = options.delete(:show_clear_button) @inset = options.delete(:inset) @monospace = options.delete(:monospace) @auto_check_src = options.delete(:auto_check_src) super(**options) add_input_data(:target, "ariadne-text-field.inputElement #{@input_attributes.dig(:data, :target) || ""}".rstrip) end def to_component html_attrs = @input_attributes || {} html_attrs[:placeholder] = @placeholder if @placeholder.present? html_attrs[:disabled] = true if @disabled Ariadne::Form::TextField::Component.new(name: @name, label: @label, caption: @caption, html_attrs: html_attrs, **@options) end def type :text_field end def focusable? true end def validation_arguments if auto_check_src.present? super.merge( data: { target: "primer-text-field.validationElement", }, ) else super end end def validation_success_icon_target "primer-text-field.validationSuccessIcon" end def validation_error_icon_target "primer-text-field.validationErrorIcon" end def validation_message_arguments if auto_check_src.present? super.merge( data: { target: "primer-text-field.validationMessageElement", }, ) else super end end end end end end
Version data entries
37 entries across 37 versions & 1 rubygems