Sha256: 44ec41e21e5c9b392b3004ebe793734af8739e0e6682345f13bea137bad62298

Contents?: true

Size: 768 Bytes

Versions: 20

Compression:

Stored size: 768 Bytes

Contents

# frozen_string_literal: true

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

      def initialize(input:)
        @input = input
        @input.add_input_classes("FormControl-select")

        if !input.multiple?
          @input.add_input_classes(
            Primer::Forms::Dsl::Input::SIZE_MAPPINGS[@input.size]
          )
        end

        @field_wrap_arguments = {
          class: "FormControl-select-wrap",
          hidden: @input.hidden?,
          data: { multiple: input.multiple? }
        }
      end

      def options
        @options ||= @input.options.map do |option|
          [option.label, option.value, option.system_arguments]
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
primer_view_components-0.35.2 app/lib/primer/forms/select.rb
primer_view_components-0.35.1 app/lib/primer/forms/select.rb
primer_view_components-0.35.0 app/lib/primer/forms/select.rb
primer_view_components-0.34.0 lib/primer/forms/select.rb
primer_view_components-0.33.0 lib/primer/forms/select.rb
primer_view_components-0.32.0 lib/primer/forms/select.rb
primer_view_components-0.31.0 lib/primer/forms/select.rb
primer_view_components-0.30.0 lib/primer/forms/select.rb
primer_view_components-0.29.0 lib/primer/forms/select.rb
primer_view_components-0.28.0 lib/primer/forms/select.rb
primer_view_components-0.27.0 lib/primer/forms/select.rb
primer_view_components-0.26.1 lib/primer/forms/select.rb
primer_view_components-0.26.0 lib/primer/forms/select.rb
primer_view_components-0.25.1 lib/primer/forms/select.rb
primer_view_components-0.23.0 lib/primer/forms/select.rb
primer_view_components-0.22.0 lib/primer/forms/select.rb
primer_view_components-0.21.1 lib/primer/forms/select.rb
primer_view_components-0.21.0 lib/primer/forms/select.rb
primer_view_components-0.20.1 lib/primer/forms/select.rb
primer_view_components-0.20.0 lib/primer/forms/select.rb