Sha256: 32e59c476d10aa40629315a51c304a5d33783d04213ec9b34b26da4f072f3e1a

Contents?: true

Size: 1.21 KB

Versions: 63

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

module Primer
  module Forms
    # :nodoc:
    class TextField < BaseComponent
      delegate :builder, :form, to: :@input

      INPUT_WRAP_SIZE = {
        small: "FormControl-input-wrap--small",
        large: "FormControl-input-wrap--large"
      }.freeze

      def initialize(input:)
        @input = input

        @input.add_input_classes(
          "FormControl-input",
          Primer::Forms::Dsl::Input::SIZE_MAPPINGS[@input.size]
        )

        @field_wrap_arguments = {
          class: class_names(
            "FormControl-input-wrap",
            INPUT_WRAP_SIZE[input.size],
            "FormControl-input-wrap--trailingAction": @input.show_clear_button?,
            "FormControl-input-wrap--leadingVisual": @input.leading_visual?
          ),

          hidden: @input.hidden?
        }
      end

      def auto_check_authenticity_token
        return @auto_check_authenticity_token if defined?(@auto_check_authenticity_token)

        @auto_check_authenticity_token =
          if @input.auto_check_src
            @view_context.form_authenticity_token(
              form_options: { method: :post, action: @input.auto_check_src }
            )
          end
      end
    end
  end
end

Version data entries

63 entries across 63 versions & 2 rubygems

Version Path
primer_view_components-0.36.3 app/lib/primer/forms/text_field.rb
primer_view_components-0.36.2 app/lib/primer/forms/text_field.rb
primer_view_components-0.36.1 app/lib/primer/forms/text_field.rb
primer_view_components-0.36.0 app/lib/primer/forms/text_field.rb
primer_view_components-0.35.2 app/lib/primer/forms/text_field.rb
primer_view_components-0.35.1 app/lib/primer/forms/text_field.rb
primer_view_components-0.35.0 app/lib/primer/forms/text_field.rb
primer_view_components-0.34.0 lib/primer/forms/text_field.rb
primer_view_components-0.33.0 lib/primer/forms/text_field.rb
primer_view_components-0.32.0 lib/primer/forms/text_field.rb
primer_view_components-0.31.0 lib/primer/forms/text_field.rb
primer_view_components-0.30.0 lib/primer/forms/text_field.rb
primer_view_components-0.29.0 lib/primer/forms/text_field.rb
primer_view_components-0.28.0 lib/primer/forms/text_field.rb
primer_view_components-0.27.0 lib/primer/forms/text_field.rb
primer_view_components-0.26.1 lib/primer/forms/text_field.rb
primer_view_components-0.26.0 lib/primer/forms/text_field.rb
primer_view_components-0.25.1 lib/primer/forms/text_field.rb
primer_view_components-0.23.0 lib/primer/forms/text_field.rb
primer_view_components-0.22.0 lib/primer/forms/text_field.rb