Sha256: 8ab84eb568621cd0e4902cd0479b202f45edb584e3f8ce0ed819ad6f227c2a7a

Contents?: true

Size: 1.06 KB

Versions: 23

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

module Primer
  module Forms
    module Dsl
      # :nodoc:
      class SelectInput < Input
        SELECT_ARGUMENTS = [:multiple, :include_blank, :include_hidden, :prompt].freeze

        attr_reader :name, :label, :options, :select_arguments

        def initialize(name:, label:, **options)
          @name = name
          @label = label
          @options = []

          @select_arguments = {}.tap do |select_args|
            SELECT_ARGUMENTS.each do |select_arg|
              select_args[select_arg] = options.delete(select_arg)
            end
          end

          super(**options)

          yield(self) if block_given?
        end

        def multiple?
          @select_arguments.fetch(:multiple, false)
        end

        def to_component
          Ariadne::Form::Select::Component.new(name:, label:, **@options)
        end

        # :nocov:
        def type
          :select_list
        end
        # :nocov:

        # :nocov:
        def focusable?
          true
        end
        # :nocov:
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
ariadne_view_components-0.0.92 lib/ariadne/forms/dsl/select_input.rb
ariadne_view_components-0.0.91 lib/ariadne/forms/dsl/select_input.rb
ariadne_view_components-0.0.90 lib/ariadne/forms/dsl/select_input.rb
ariadne_view_components-0.0.89.1 lib/ariadne/forms/dsl/select_input.rb
ariadne_view_components-0.0.89 lib/ariadne/forms/dsl/select_input.rb
ariadne_view_components-0.0.88 lib/ariadne/forms/dsl/select_input.rb
ariadne_view_components-0.0.87 lib/ariadne/forms/dsl/select_input.rb
ariadne_view_components-0.0.86.9 lib/ariadne/forms/dsl/select_input.rb
ariadne_view_components-0.0.86.8 lib/ariadne/forms/dsl/select_input.rb
ariadne_view_components-0.0.86.7 lib/ariadne/forms/dsl/select_input.rb
ariadne_view_components-0.0.86.6 lib/ariadne/forms/dsl/select_input.rb
ariadne_view_components-0.0.86.5 lib/ariadne/forms/dsl/select_input.rb
ariadne_view_components-0.0.86.4 lib/ariadne/forms/dsl/select_input.rb
ariadne_view_components-0.0.86.3 lib/ariadne/forms/dsl/select_input.rb
ariadne_view_components-0.0.86.2 lib/ariadne/forms/dsl/select_input.rb
ariadne_view_components-0.0.86.1 lib/ariadne/forms/dsl/select_input.rb
ariadne_view_components-0.0.86 lib/ariadne/forms/dsl/select_input.rb
ariadne_view_components-0.0.85 lib/ariadne/forms/dsl/select_input.rb
ariadne_view_components-0.0.84 lib/ariadne/forms/dsl/select_input.rb
ariadne_view_components-0.0.83.3 lib/ariadne/forms/dsl/select_input.rb