Sha256: 3d2df80e3c7f20921e77900ae87ad4d15338f5d4c52fa9b23cd2c3741b5db562

Contents?: true

Size: 1.14 KB

Versions: 9

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

module Slack
  module BlockKit
    module Layout
      # A block that collects information from users - it can hold a plain-text
      # input element, a select menu element, a multi-select menu element, or a
      # datepicker.
      #
      # https://api.slack.com/reference/block-kit/blocks#input
      class Input
        TYPE = 'input'

        attr_accessor :label, :element, :block_id, :hint, :optional, :emoji

        def initialize(
          label:,
          element:,
          block_id: nil,
          hint: nil,
          optional: nil,
          emoji: nil
        )
          @label = Composition::PlainText.new(text: label, emoji: emoji) if label
          @hint = Composition::PlainText.new(text: hint, emoji: emoji) if hint
          @block_id = block_id
          @optional = optional
          @element = element
        end

        def as_json(*)
          {
            type: TYPE,
            element: @element.as_json,
            label: @label&.as_json,
            hint: @hint&.as_json,
            block_id: @block_id,
            optional: optional
          }.compact
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
slack-ruby-block-kit-0.12.0 lib/slack/block_kit/layout/input.rb
slack-ruby-block-kit-0.11.0 lib/slack/block_kit/layout/input.rb
slack-ruby-block-kit-0.10.0 lib/slack/block_kit/layout/input.rb
slack-ruby-block-kit-0.9.0 lib/slack/block_kit/layout/input.rb
slack-ruby-block-kit-0.8.0 lib/slack/block_kit/layout/input.rb
slack-ruby-block-kit-0.7.0 lib/slack/block_kit/layout/input.rb
slack-ruby-block-kit-0.6.1 lib/slack/block_kit/layout/input.rb
slack-ruby-block-kit-0.6.0 lib/slack/block_kit/layout/input.rb
slack-ruby-block-kit-0.5.0 lib/slack/block_kit/layout/input.rb