Sha256: c8a65d45c7648e7e6c8d2a1fd2229c72c120f9dc788134df8def73142d0bdf06

Contents?: true

Size: 993 Bytes

Versions: 2

Compression:

Stored size: 993 Bytes

Contents

# frozen_string_literal: true

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

      def initialize(input:)
        @input = input

        @field_wrap_arguments = {
          class: class_names(
            "FormControl-input-wrap",
            Yattho::Forms::Dsl::Input::SIZE_MAPPINGS[@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

2 entries across 2 versions & 1 rubygems

Version Path
yattho_view_components-0.1.1 lib/yattho/forms/text_field.rb
yattho_view_components-0.0.1 lib/yattho/forms/text_field.rb