Sha256: de4bf9ff0ba97b6b7b54839ad5b386c0b19e8b6755338f36101a6050fcd26127

Contents?: true

Size: 1.04 KB

Versions: 18

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

module Primer
  module Forms
    module Dsl
      # :nodoc:
      class SelectListInput < Input
        # :nodoc:
        class Option
          attr_reader :label, :value, :system_arguments

          def initialize(label:, value:, **system_arguments)
            @label = label
            @value = value
            @system_arguments = system_arguments
          end
        end

        attr_reader :name, :label, :options

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

          super(**system_arguments)

          yield(self) if block_given?
        end

        def option(**system_arguments)
          @options << Option.new(**system_arguments)
        end

        def to_component
          SelectList.new(input: self)
        end

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

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

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
primer_view_components-0.0.103 lib/primer/forms/dsl/select_list_input.rb
primer_view_components-0.0.102 lib/primer/forms/dsl/select_list_input.rb
primer_view_components-0.0.101 lib/primer/forms/dsl/select_list_input.rb
primer_view_components-0.0.100 lib/primer/forms/dsl/select_list_input.rb
primer_view_components-0.0.99 lib/primer/forms/dsl/select_list_input.rb
primer_view_components-0.0.98 lib/primer/forms/dsl/select_list_input.rb
primer_view_components-0.0.97 lib/primer/forms/dsl/select_list_input.rb
primer_view_components-0.0.96 lib/primer/forms/dsl/select_list_input.rb
primer_view_components-0.0.95 lib/primer/forms/dsl/select_list_input.rb
primer_view_components-0.0.94 lib/primer/forms/dsl/select_list_input.rb
primer_view_components-0.0.93 lib/primer/forms/dsl/select_list_input.rb
primer_view_components-0.0.92 lib/primer/forms/dsl/select_list_input.rb
primer_view_components-0.0.91 lib/primer/forms/dsl/select_list_input.rb
primer_view_components-0.0.90 lib/primer/forms/dsl/select_list_input.rb
primer_view_components-0.0.89 lib/primer/forms/dsl/select_list_input.rb
primer_view_components-0.0.88 lib/primer/forms/dsl/select_list_input.rb
primer_view_components-0.0.87 lib/primer/forms/dsl/select_list_input.rb
primer_view_components-0.0.86 lib/primer/forms/dsl/select_list_input.rb