Sha256: 4d28edb520f42053e3ad0b5d501c9b52205c7e3c0dceb11c67f47b3e89b95ba6

Contents?: true

Size: 934 Bytes

Versions: 47

Compression:

Stored size: 934 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

        wrap_classes = ["FormControl-select-wrap"]
        wrap_classes << Primer::Forms::Dsl::Input::INPUT_WIDTH_MAPPINGS[@input.input_width] if @input.input_width

        @field_wrap_arguments = {
          class: class_names(wrap_classes),
          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

47 entries across 47 versions & 1 rubygems

Version Path
openproject-primer_view_components-0.49.2 app/lib/primer/forms/select.rb
openproject-primer_view_components-0.49.1 app/lib/primer/forms/select.rb
openproject-primer_view_components-0.49.0 app/lib/primer/forms/select.rb
openproject-primer_view_components-0.48.2 lib/primer/forms/select.rb
openproject-primer_view_components-0.48.1 lib/primer/forms/select.rb
openproject-primer_view_components-0.48.0 lib/primer/forms/select.rb
openproject-primer_view_components-0.47.1 lib/primer/forms/select.rb
openproject-primer_view_components-0.47.0 lib/primer/forms/select.rb
openproject-primer_view_components-0.46.1 lib/primer/forms/select.rb
openproject-primer_view_components-0.46.0 lib/primer/forms/select.rb
openproject-primer_view_components-0.45.0 lib/primer/forms/select.rb
openproject-primer_view_components-0.44.3 lib/primer/forms/select.rb
openproject-primer_view_components-0.44.2 lib/primer/forms/select.rb
openproject-primer_view_components-0.44.1 lib/primer/forms/select.rb
openproject-primer_view_components-0.44.0 lib/primer/forms/select.rb
openproject-primer_view_components-0.43.1 lib/primer/forms/select.rb
openproject-primer_view_components-0.43.0 lib/primer/forms/select.rb
openproject-primer_view_components-0.42.0 lib/primer/forms/select.rb
openproject-primer_view_components-0.41.1 lib/primer/forms/select.rb
openproject-primer_view_components-0.41.0 lib/primer/forms/select.rb