Sha256: 132991a7646ca10b0909216d18cebbe503d27d8bc44d7fb27bdf821fc3e927c9

Contents?: true

Size: 986 Bytes

Versions: 32

Compression:

Stored size: 986 Bytes

Contents

# frozen_string_literal: true

module Primer
  module Forms
    module Dsl
      # :nodoc:
      class CheckBoxGroupInput < Input
        attr_reader :name, :label, :check_boxes

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

          super(**system_arguments)

          yield(self) if block_given?
        end

        def to_component
          CheckBoxGroup.new(input: self)
        end

        def type
          :check_box_group
        end

        def check_box(**system_arguments, &block)
          args = {
            name: @name,
            builder: @builder,
            form: @form,
            scheme: scheme,
            disabled: disabled?,
            **system_arguments
          }

          @check_boxes << CheckBoxInput.new(**args, &block)
        end

        private

        def scheme
          @name ? :array : :boolean
        end
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 2 rubygems

Version Path
openproject-primer_view_components-0.23.0 lib/primer/forms/dsl/check_box_group_input.rb
primer_view_components-0.19.0 lib/primer/forms/dsl/check_box_group_input.rb
openproject-primer_view_components-0.22.2 lib/primer/forms/dsl/check_box_group_input.rb
primer_view_components-0.18.2 lib/primer/forms/dsl/check_box_group_input.rb
openproject-primer_view_components-0.22.1 lib/primer/forms/dsl/check_box_group_input.rb
primer_view_components-0.18.1 lib/primer/forms/dsl/check_box_group_input.rb
openproject-primer_view_components-0.22.0 lib/primer/forms/dsl/check_box_group_input.rb
primer_view_components-0.18.0 lib/primer/forms/dsl/check_box_group_input.rb
openproject-primer_view_components-0.21.0 lib/primer/forms/dsl/check_box_group_input.rb
primer_view_components-0.17.0 lib/primer/forms/dsl/check_box_group_input.rb
openproject-primer_view_components-0.20.0 lib/primer/forms/dsl/check_box_group_input.rb
primer_view_components-0.16.1 lib/primer/forms/dsl/check_box_group_input.rb
primer_view_components-0.16.0 lib/primer/forms/dsl/check_box_group_input.rb
openproject-primer_view_components-0.19.0 lib/primer/forms/dsl/check_box_group_input.rb
primer_view_components-0.15.1 lib/primer/forms/dsl/check_box_group_input.rb
primer_view_components-0.15.0 lib/primer/forms/dsl/check_box_group_input.rb
openproject-primer_view_components-0.18.1 lib/primer/forms/dsl/check_box_group_input.rb
openproject-primer_view_components-0.17.1 lib/primer/forms/dsl/check_box_group_input.rb
openproject-primer_view_components-0.17.0 lib/primer/forms/dsl/check_box_group_input.rb
primer_view_components-0.14.0 lib/primer/forms/dsl/check_box_group_input.rb