lib/ariadne/forms/dsl/button_input.rb



# frozen_string_literal: true

module Ariadne
  module Forms
    module Dsl
      # :nodoc:
      class ButtonInput < Input
        attr_reader :name, :label, :block

        def initialize(name:, label:, **options, &block)
          @name = name
          @label = label
          @caption = options.delete(:caption)
          @block = block

          super(**options)
        end

        def to_component
          html_attrs = @input_attributes || {}
          Ariadne::UI::Button::Component.new(**@options, html_attrs: html_attrs).with_content(@label)
        end

        # :nocov:
        def type
          :button
        end

        def supports_validation?
          false
        end
      end
    end
  end
end