Sha256: f08dbcb3626ddf31e8178cf991097541265f518eab679ff8d44bb2f2f1c037af

Contents?: true

Size: 1.22 KB

Versions: 6

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

module Slack
  module BlockKit
    module Element
      # An element which allows selection of a time of day.
      #
      # On desktop clients, this time picker will take the form of a dropdown
      # list with free-text entry for precise choices. On mobile clients, the
      # time picker will use native time picker UIs.
      #
      # https://api.slack.com/reference/block-kit/block-elements#timepicker
      class Timepicker
        include Composition::ConfirmationDialog::Confirmable

        TYPE = 'timepicker'

        def initialize(action_id:)
          @placeholder, @initial_time = nil
          @action_id = action_id

          yield(self) if block_given?
        end

        def placeholder(text:, emoji: nil)
          @placeholder = Composition::PlainText.new(text: text, emoji: emoji)

          self
        end

        def initial_time(time_str)
          @initial_time = time_str

          self
        end

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
slack-ruby-block-kit-0.17.0 lib/slack/block_kit/element/timepicker.rb
slack-ruby-block-kit-0.16.0 lib/slack/block_kit/element/timepicker.rb
slack-ruby-block-kit-0.15.0 lib/slack/block_kit/element/timepicker.rb
slack-ruby-block-kit-0.14.1 lib/slack/block_kit/element/timepicker.rb
slack-ruby-block-kit-0.14.0 lib/slack/block_kit/element/timepicker.rb
slack-ruby-block-kit-0.13.0 lib/slack/block_kit/element/timepicker.rb