Sha256: 151e4459921829422ab9be1468a256af18167535b2dd32ee1a4221ca45972eaa

Contents?: true

Size: 957 Bytes

Versions: 79

Compression:

Stored size: 957 Bytes

Contents

# frozen_string_literal: true

module Primer
  module Forms
    module Dsl
      # :nodoc:
      class RadioButtonGroupInput < Input
        attr_reader :name, :label, :radio_buttons

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

          super(**system_arguments)

          yield(self) if block_given?
        end

        def to_component
          RadioButtonGroup.new(input: self)
        end

        def type
          :radio_button_group
        end

        def autofocus!
          @radio_buttons.first&.autofocus!
        end

        def focusable?
          true
        end

        def radio_button(**system_arguments, &block)
          @radio_buttons << RadioButtonInput.new(
            builder: @builder, form: @form, name: @name, disabled: disabled?,
            **system_arguments, &block
          )
        end
      end
    end
  end
end

Version data entries

79 entries across 79 versions & 2 rubygems

Version Path
primer_view_components-0.36.5 app/lib/primer/forms/dsl/radio_button_group_input.rb
openproject-primer_view_components-0.52.2 app/lib/primer/forms/dsl/radio_button_group_input.rb
primer_view_components-0.36.4 app/lib/primer/forms/dsl/radio_button_group_input.rb
openproject-primer_view_components-0.52.1 app/lib/primer/forms/dsl/radio_button_group_input.rb
openproject-primer_view_components-0.52.0 app/lib/primer/forms/dsl/radio_button_group_input.rb
primer_view_components-0.36.3 app/lib/primer/forms/dsl/radio_button_group_input.rb
openproject-primer_view_components-0.51.0 app/lib/primer/forms/dsl/radio_button_group_input.rb
primer_view_components-0.36.2 app/lib/primer/forms/dsl/radio_button_group_input.rb
openproject-primer_view_components-0.50.1 app/lib/primer/forms/dsl/radio_button_group_input.rb
openproject-primer_view_components-0.50.0 app/lib/primer/forms/dsl/radio_button_group_input.rb
primer_view_components-0.36.1 app/lib/primer/forms/dsl/radio_button_group_input.rb
primer_view_components-0.36.0 app/lib/primer/forms/dsl/radio_button_group_input.rb
openproject-primer_view_components-0.49.2 app/lib/primer/forms/dsl/radio_button_group_input.rb
primer_view_components-0.35.2 app/lib/primer/forms/dsl/radio_button_group_input.rb
openproject-primer_view_components-0.49.1 app/lib/primer/forms/dsl/radio_button_group_input.rb
openproject-primer_view_components-0.49.0 app/lib/primer/forms/dsl/radio_button_group_input.rb
primer_view_components-0.35.1 app/lib/primer/forms/dsl/radio_button_group_input.rb
primer_view_components-0.35.0 app/lib/primer/forms/dsl/radio_button_group_input.rb
openproject-primer_view_components-0.48.2 lib/primer/forms/dsl/radio_button_group_input.rb
openproject-primer_view_components-0.48.1 lib/primer/forms/dsl/radio_button_group_input.rb