Sha256: 636e0dbf0d79a1ee3be777aa919354423e67ea4a7e9e892fee8cba95b969d2ee

Contents?: true

Size: 1023 Bytes

Versions: 29

Compression:

Stored size: 1023 Bytes

Contents

# frozen_string_literal: true

module Primer
  module Forms
    module Dsl
      # :nodoc:
      class CheckBoxGroupInput < Input
        attr_reader :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 name
          nil
        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

29 entries across 29 versions & 2 rubygems

Version Path
openproject-primer_view_components-0.11.0 lib/primer/forms/dsl/check_box_group_input.rb
openproject-primer_view_components-0.10.0 lib/primer/forms/dsl/check_box_group_input.rb
primer_view_components-0.9.0 lib/primer/forms/dsl/check_box_group_input.rb
openproject-primer_view_components-0.9.1 lib/primer/forms/dsl/check_box_group_input.rb
openproject-primer_view_components-0.9.0 lib/primer/forms/dsl/check_box_group_input.rb
openproject-primer_view_components-0.8.0 lib/primer/forms/dsl/check_box_group_input.rb
primer_view_components-0.8.0 lib/primer/forms/dsl/check_box_group_input.rb
primer_view_components-0.7.0 lib/primer/forms/dsl/check_box_group_input.rb
openproject-primer_view_components-0.7.0 lib/primer/forms/dsl/check_box_group_input.rb
openproject-primer_view_components-0.6.3 lib/primer/forms/dsl/check_box_group_input.rb
primer_view_components-0.6.0 lib/primer/forms/dsl/check_box_group_input.rb
primer_view_components-0.5.1 lib/primer/forms/dsl/check_box_group_input.rb
primer_view_components-0.5.0 lib/primer/forms/dsl/check_box_group_input.rb
primer_view_components-0.4.0 lib/primer/forms/dsl/check_box_group_input.rb
primer_view_components-0.3.1 lib/primer/forms/dsl/check_box_group_input.rb
primer_view_components-0.3.0 lib/primer/forms/dsl/check_box_group_input.rb
primer_view_components-0.2.0 lib/primer/forms/dsl/check_box_group_input.rb
primer_view_components-0.1.9 lib/primer/forms/dsl/check_box_group_input.rb
primer_view_components-0.1.8 lib/primer/forms/dsl/check_box_group_input.rb
primer_view_components-0.1.7 lib/primer/forms/dsl/check_box_group_input.rb