Sha256: 4e632c565cfe4221cd628fd51748a2ea576030f3fc8b4112ab7698b8121ac40a

Contents?: true

Size: 1.08 KB

Versions: 5

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

module Slack
  module BlockKit
    module Element
      # An element which lets users easily select a date from a calendar style
      # UI.
      #
      # Date picker elements can be used inside of section and actions blocks.
      #
      # https://api.slack.com/reference/messaging/block-elements#datepicker
      class DatePicker
        include Composition::ConfirmationDialog::Confirmable

        TYPE = 'datepicker'

        def initialize(action_id:, placeholder: nil, initial: nil, emoji: nil)
          @action_id = action_id
          @initial_date = initial
          if placeholder
            @placeholder = Composition::PlainText.new(
              text: placeholder,
              emoji: emoji
            )
          end

          yield(self) if block_given?
        end

        def as_json(*)
          {
            type: TYPE,
            action_id: @action_id,
            placeholder: @placeholder&.as_json,
            initial_date: @initial_date,
            confirm: confirm&.as_json
          }.compact
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
slack-ruby-block-kit-0.14.1 lib/slack/block_kit/element/date_picker.rb
slack-ruby-block-kit-0.14.0 lib/slack/block_kit/element/date_picker.rb
slack-ruby-block-kit-0.13.0 lib/slack/block_kit/element/date_picker.rb
slack-ruby-block-kit-0.12.0 lib/slack/block_kit/element/date_picker.rb
slack-ruby-block-kit-0.11.0 lib/slack/block_kit/element/date_picker.rb