Sha256: 70732e20b50c483b53fa5a7d35a5e751826e50df1eb4382aabd7da0f40b60abc

Contents?: true

Size: 817 Bytes

Versions: 12

Compression:

Stored size: 817 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",
          Primer::Forms::Dsl::Input::SIZE_MAPPINGS[@input.size]
        )

        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?
        }
      end

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

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
openproject-primer_view_components-0.23.0 lib/primer/forms/select.rb
openproject-primer_view_components-0.22.2 lib/primer/forms/select.rb
openproject-primer_view_components-0.22.1 lib/primer/forms/select.rb
openproject-primer_view_components-0.22.0 lib/primer/forms/select.rb
openproject-primer_view_components-0.21.0 lib/primer/forms/select.rb
openproject-primer_view_components-0.20.0 lib/primer/forms/select.rb
openproject-primer_view_components-0.19.0 lib/primer/forms/select.rb
openproject-primer_view_components-0.18.1 lib/primer/forms/select.rb
openproject-primer_view_components-0.17.1 lib/primer/forms/select.rb
openproject-primer_view_components-0.17.0 lib/primer/forms/select.rb
openproject-primer_view_components-0.16.0 lib/primer/forms/select.rb
openproject-primer_view_components-0.15.0 lib/primer/forms/select.rb